aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/ABI/testing/sysfs-tty3
-rw-r--r--Documentation/PCI/MSI-HOWTO.txt119
-rw-r--r--Documentation/devicetree/bindings/arm/omap/omap.txt2
-rw-r--r--Documentation/devicetree/bindings/clock/renesas,cpg-mstp-clocks.txt4
-rw-r--r--Documentation/devicetree/bindings/dma/fsl-imx-sdma.txt16
-rw-r--r--Documentation/devicetree/bindings/net/opencores-ethoc.txt22
-rw-r--r--Documentation/networking/can.txt6
-rw-r--r--MAINTAINERS133
-rw-r--r--Makefile10
-rw-r--r--arch/arm/boot/dts/Makefile3
-rw-r--r--arch/arm/boot/dts/am335x-evmsk.dts11
-rw-r--r--arch/arm/boot/dts/armada-xp-mv78260.dtsi3
-rw-r--r--arch/arm/boot/dts/dove.dtsi11
-rw-r--r--arch/arm/boot/dts/keystone-clocks.dtsi2
-rw-r--r--arch/arm/boot/dts/omap3-gta04.dts6
-rw-r--r--arch/arm/boot/dts/omap3-n9.dts2
-rw-r--r--arch/arm/boot/dts/omap3-n900.dts4
-rw-r--r--arch/arm/boot/dts/omap3-n950.dts2
-rw-r--r--arch/arm/boot/dts/omap3-overo-storm-tobi.dts22
-rw-r--r--arch/arm/boot/dts/omap3-overo-tobi-common.dtsi (renamed from arch/arm/boot/dts/omap3-tobi.dts)3
-rw-r--r--arch/arm/boot/dts/omap3-overo-tobi.dts22
-rw-r--r--arch/arm/boot/dts/omap3-overo.dtsi3
-rw-r--r--arch/arm/boot/dts/tegra114.dtsi4
-rw-r--r--arch/arm/boot/dts/tegra20.dtsi4
-rw-r--r--arch/arm/boot/dts/tegra30-cardhu.dtsi2
-rw-r--r--arch/arm/boot/dts/tegra30.dtsi4
-rw-r--r--arch/arm/boot/dts/testcases/tests.dtsi2
-rw-r--r--arch/arm/boot/dts/versatile-pb.dts4
-rw-r--r--arch/arm/kvm/arm.c3
-rw-r--r--arch/arm/kvm/interrupts.S11
-rw-r--r--arch/arm/mach-imx/Makefile2
-rw-r--r--arch/arm/mach-imx/common.h4
-rw-r--r--arch/arm/mach-omap1/board-nokia770.c1
-rw-r--r--arch/arm/mach-omap2/Kconfig8
-rw-r--r--arch/arm/mach-omap2/gpmc.c4
-rw-r--r--arch/arm/mach-omap2/io.c9
-rw-r--r--arch/arm/mach-pxa/mioa701.c9
-rw-r--r--arch/arm/mach-tegra/pm.c1
-rw-r--r--arch/arm/mach-tegra/tegra.c10
-rw-r--r--arch/arm/mm/dma-mapping.c2
-rw-r--r--arch/arm64/include/asm/percpu.h8
-rw-r--r--arch/arm64/include/asm/pgtable.h10
-rw-r--r--arch/arm64/kernel/stacktrace.c6
-rw-r--r--arch/arm64/kvm/hyp.S27
-rw-r--r--arch/m68k/include/asm/Kbuild6
-rw-r--r--arch/m68k/include/asm/barrier.h8
-rw-r--r--arch/m68k/include/asm/unistd.h2
-rw-r--r--arch/m68k/include/uapi/asm/unistd.h2
-rw-r--r--arch/m68k/kernel/syscalltable.S2
-rw-r--r--arch/powerpc/include/asm/compat.h5
-rw-r--r--arch/powerpc/include/asm/opal.h4
-rw-r--r--arch/powerpc/include/asm/ptrace.h16
-rw-r--r--arch/powerpc/kernel/crash_dump.c8
-rw-r--r--arch/powerpc/kernel/ftrace.c1
-rw-r--r--arch/powerpc/kernel/signal_64.c4
-rw-r--r--arch/powerpc/platforms/powernv/eeh-ioda.c96
-rw-r--r--arch/powerpc/platforms/powernv/opal-xscom.c21
-rw-r--r--arch/powerpc/platforms/powernv/pci.c220
-rw-r--r--arch/powerpc/platforms/pseries/hotplug-cpu.c22
-rw-r--r--arch/s390/kernel/compat_wrapper.S2
-rw-r--r--arch/s390/pci/pci_dma.c8
-rw-r--r--arch/sh/include/cpu-sh2/cpu/cache.h2
-rw-r--r--arch/sh/include/cpu-sh2a/cpu/cache.h4
-rw-r--r--arch/sh/include/cpu-sh3/cpu/cache.h2
-rw-r--r--arch/sh/include/cpu-sh4/cpu/cache.h2
-rw-r--r--arch/sh/kernel/cpu/init.c4
-rw-r--r--arch/sh/mm/cache-debugfs.c2
-rw-r--r--arch/sh/mm/cache-sh2.c4
-rw-r--r--arch/sh/mm/cache-sh2a.c6
-rw-r--r--arch/sh/mm/cache-sh4.c4
-rw-r--r--arch/sh/mm/cache-shx3.c4
-rw-r--r--arch/sh/mm/cache.c4
-rw-r--r--arch/sparc/Kconfig2
-rw-r--r--arch/sparc/mm/srmmu.c2
-rw-r--r--arch/x86/boot/compressed/aslr.c9
-rw-r--r--arch/x86/include/asm/tsc.h2
-rw-r--r--arch/x86/kernel/cpu/perf_event.c11
-rw-r--r--arch/x86/kernel/cpu/perf_event.h1
-rw-r--r--arch/x86/kernel/cpu/perf_event_intel.c11
-rw-r--r--arch/x86/kernel/cpu/perf_event_intel_uncore.c10
-rw-r--r--arch/x86/kernel/cpu/perf_event_p6.c48
-rw-r--r--arch/x86/kernel/machine_kexec_64.c2
-rw-r--r--arch/x86/kernel/pci-dma.c4
-rw-r--r--arch/x86/kernel/tsc.c7
-rw-r--r--arch/x86/kernel/tsc_msr.c30
-rw-r--r--arch/x86/kvm/mmu.c1
-rw-r--r--arch/x86/kvm/vmx.c2
-rw-r--r--arch/x86/kvm/x86.c2
-rw-r--r--arch/xtensa/Kconfig3
-rw-r--r--arch/xtensa/boot/dts/xtfpga.dtsi12
-rw-r--r--arch/xtensa/include/asm/io.h2
-rw-r--r--arch/xtensa/include/asm/traps.h44
-rw-r--r--arch/xtensa/include/asm/vectors.h2
-rw-r--r--arch/xtensa/include/uapi/asm/unistd.h7
-rw-r--r--arch/xtensa/kernel/entry.S449
-rw-r--r--arch/xtensa/kernel/setup.c2
-rw-r--r--arch/xtensa/kernel/time.c1
-rw-r--r--arch/xtensa/kernel/vectors.S2
-rw-r--r--arch/xtensa/kernel/xtensa_ksyms.c2
-rw-r--r--arch/xtensa/mm/init.c13
-rw-r--r--arch/xtensa/mm/mmu.c2
-rw-r--r--arch/xtensa/platforms/xtfpga/setup.c7
-rw-r--r--arch/xtensa/variants/fsf/include/variant/tie.h9
-rw-r--r--drivers/acpi/ac.c2
-rw-r--r--drivers/acpi/battery.c2
-rw-r--r--drivers/acpi/blacklist.c58
-rw-r--r--drivers/acpi/button.c2
-rw-r--r--drivers/acpi/dock.c8
-rw-r--r--drivers/acpi/fan.c3
-rw-r--r--drivers/acpi/pci_irq.c1
-rw-r--r--drivers/acpi/processor_throttling.c69
-rw-r--r--drivers/acpi/sbs.c4
-rw-r--r--drivers/acpi/thermal.c2
-rw-r--r--drivers/acpi/video.c147
-rw-r--r--drivers/acpi/video_detect.c16
-rw-r--r--drivers/ata/Kconfig1
-rw-r--r--drivers/ata/ahci.c18
-rw-r--r--drivers/ata/libata-pmp.c7
-rw-r--r--drivers/ata/pata_imx.c8
-rw-r--r--drivers/ata/sata_mv.c12
-rw-r--r--drivers/ata/sata_sil.c1
-rw-r--r--drivers/base/firmware_class.c1
-rw-r--r--drivers/block/aoe/aoecmd.c4
-rw-r--r--drivers/block/zram/zram_drv.c2
-rw-r--r--drivers/clk/at91/clk-master.c2
-rw-r--r--drivers/clk/clk-nomadik.c3
-rw-r--r--drivers/clk/clk.c13
-rw-r--r--drivers/clk/keystone/gate.c1
-rw-r--r--drivers/clk/mvebu/armada-370.c21
-rw-r--r--drivers/clk/mvebu/armada-xp.c20
-rw-r--r--drivers/clk/mvebu/dove.c19
-rw-r--r--drivers/clk/mvebu/kirkwood.c34
-rw-r--r--drivers/clk/shmobile/clk-rcar-gen2.c12
-rw-r--r--drivers/clk/tegra/clk-divider.c2
-rw-r--r--drivers/clk/tegra/clk-id.h4
-rw-r--r--drivers/clk/tegra/clk-tegra-periph.c10
-rw-r--r--drivers/clk/tegra/clk-tegra-super-gen4.c2
-rw-r--r--drivers/clk/tegra/clk-tegra114.c8
-rw-r--r--drivers/clk/tegra/clk-tegra124.c48
-rw-r--r--drivers/clk/tegra/clk-tegra20.c2
-rw-r--r--drivers/cpufreq/cpufreq.c3
-rw-r--r--drivers/cpufreq/intel_pstate.c45
-rw-r--r--drivers/cpufreq/powernow-k8.c10
-rw-r--r--drivers/dma/imx-sdma.c1
-rw-r--r--drivers/dma/ioat/dma.c52
-rw-r--r--drivers/dma/ioat/dma.h1
-rw-r--r--drivers/dma/ioat/dma_v2.c11
-rw-r--r--drivers/dma/ioat/dma_v3.c3
-rw-r--r--drivers/dma/ste_dma40.c4
-rw-r--r--drivers/edac/i7300_edac.c38
-rw-r--r--drivers/edac/i7core_edac.c9
-rw-r--r--drivers/extcon/extcon-arizona.c12
-rw-r--r--drivers/fmc/fmc-write-eeprom.c2
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_acpi.c26
-rw-r--r--drivers/gpu/drm/radeon/atombios_crtc.c16
-rw-r--r--drivers/gpu/drm/radeon/dce6_afmt.c15
-rw-r--r--drivers/gpu/drm/radeon/evergreen.c2
-rw-r--r--drivers/gpu/drm/radeon/evergreen_hdmi.c26
-rw-r--r--drivers/gpu/drm/radeon/r600_audio.c14
-rw-r--r--drivers/gpu/drm/radeon/r600_hdmi.c15
-rw-r--r--drivers/gpu/drm/radeon/radeon.h6
-rw-r--r--drivers/gpu/drm/radeon/radeon_atpx_handler.c3
-rw-r--r--drivers/gpu/drm/radeon/radeon_kms.c6
-rw-r--r--drivers/gpu/drm/radeon/radeon_uvd.c2
-rw-r--r--drivers/gpu/drm/radeon/rv770.c2
-rw-r--r--drivers/gpu/drm/tegra/drm.c2
-rw-r--r--drivers/gpu/drm/tegra/rgb.c11
-rw-r--r--drivers/gpu/drm/vmwgfx/svga3d_reg.h7
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_drv.h2
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_mob.c35
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_resource.c3
-rw-r--r--drivers/gpu/host1x/job.c2
-rw-r--r--drivers/hwmon/max1668.c2
-rw-r--r--drivers/iio/gyro/Kconfig2
-rw-r--r--drivers/iio/gyro/st_gyro.h1
-rw-r--r--drivers/iio/gyro/st_gyro_core.c9
-rw-r--r--drivers/iio/gyro/st_gyro_i2c.c1
-rw-r--r--drivers/iio/gyro/st_gyro_spi.c1
-rw-r--r--drivers/iio/light/cm32181.c16
-rw-r--r--drivers/iio/light/cm36651.c45
-rw-r--r--drivers/infiniband/hw/mlx4/main.c4
-rw-r--r--drivers/infiniband/hw/mlx5/main.c4
-rw-r--r--drivers/input/misc/arizona-haptics.c19
-rw-r--r--drivers/iommu/arm-smmu.c105
-rw-r--r--drivers/iommu/omap-iommu-debug.c4
-rw-r--r--drivers/irqchip/irq-metag-ext.c2
-rw-r--r--drivers/irqchip/irq-metag.c2
-rw-r--r--drivers/irqchip/irq-orion.c22
-rw-r--r--drivers/md/dm-cache-target.c13
-rw-r--r--drivers/md/dm-io.c23
-rw-r--r--drivers/md/dm-mpath.c7
-rw-r--r--drivers/md/dm-raid1.c3
-rw-r--r--drivers/md/dm-thin-metadata.c21
-rw-r--r--drivers/md/dm-thin-metadata.h10
-rw-r--r--drivers/md/dm-thin.c39
-rw-r--r--drivers/md/persistent-data/dm-space-map-metadata.c2
-rw-r--r--drivers/md/persistent-data/dm-space-map-metadata.h11
-rw-r--r--drivers/mfd/da9055-i2c.c12
-rw-r--r--drivers/mfd/max14577.c2
-rw-r--r--drivers/mfd/max8997.c6
-rw-r--r--drivers/mfd/max8998.c6
-rw-r--r--drivers/mfd/sec-core.c2
-rw-r--r--drivers/mfd/tps65217.c4
-rw-r--r--drivers/mfd/wm8994-core.c2
-rw-r--r--drivers/misc/mei/client.c4
-rw-r--r--drivers/mtd/nand/nand_base.c2
-rw-r--r--drivers/mtd/nand/omap2.c61
-rw-r--r--drivers/mtd/ubi/fastmap.c8
-rw-r--r--drivers/net/bonding/bond_3ad.c16
-rw-r--r--drivers/net/bonding/bond_main.c124
-rw-r--r--drivers/net/bonding/bonding.h47
-rw-r--r--drivers/net/can/flexcan.c172
-rw-r--r--drivers/net/ethernet/broadcom/b44.c14
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c9
-rw-r--r--drivers/net/ethernet/broadcom/tg3.c3
-rw-r--r--drivers/net/ethernet/broadcom/tg3.h6
-rw-r--r--drivers/net/ethernet/brocade/bna/bnad.c40
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c1
-rw-r--r--drivers/net/ethernet/emulex/benet/be.h4
-rw-r--r--drivers/net/ethernet/emulex/benet/be_main.c84
-rw-r--r--drivers/net/ethernet/freescale/fec_main.c13
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/mlx4.h4
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/mlx4_en.h4
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/main.c4
-rw-r--r--drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c1
-rw-r--r--drivers/net/ethernet/qlogic/qlcnic/qlcnic_dcb.c4
-rw-r--r--drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c5
-rw-r--r--drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_pf.c9
-rw-r--r--drivers/net/ethernet/realtek/r8169.c2
-rw-r--r--drivers/net/ethernet/sfc/ptp.c7
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_main.c2
-rw-r--r--drivers/net/ethernet/ti/cpsw.c6
-rw-r--r--drivers/net/macvlan.c7
-rw-r--r--drivers/net/phy/phy_device.c16
-rw-r--r--drivers/net/tun.c4
-rw-r--r--drivers/net/usb/ax88179_178a.c34
-rw-r--r--drivers/net/veth.c3
-rw-r--r--drivers/net/virtio_net.c3
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9462_2p0_initvals.h4
-rw-r--r--drivers/net/wireless/ath/ath9k/hw.c8
-rw-r--r--drivers/net/wireless/ath/ath9k/recv.c77
-rw-r--r--drivers/net/wireless/ath/ath9k/xmit.c13
-rw-r--r--drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c14
-rw-r--r--drivers/net/wireless/hostap/hostap_ap.c2
-rw-r--r--drivers/net/wireless/iwlwifi/dvm/sta.c1
-rw-r--r--drivers/net/wireless/iwlwifi/dvm/tx.c14
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/mvm.h2
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/tx.c18
-rw-r--r--drivers/net/wireless/libertas/cfg.c2
-rw-r--r--drivers/net/wireless/mwifiex/pcie.c34
-rw-r--r--drivers/net/wireless/mwifiex/usb.c12
-rw-r--r--drivers/net/wireless/mwifiex/wmm.c3
-rw-r--r--drivers/net/xen-netfront.c1
-rw-r--r--drivers/of/base.c150
-rw-r--r--drivers/of/selftest.c67
-rw-r--r--drivers/of/testcase-data/testcases.dtsi3
-rw-r--r--drivers/of/testcase-data/tests-interrupts.dtsi (renamed from arch/arm/boot/dts/testcases/tests-interrupts.dtsi)0
-rw-r--r--drivers/of/testcase-data/tests-match.dtsi19
-rw-r--r--drivers/of/testcase-data/tests-phandle.dtsi (renamed from arch/arm/boot/dts/testcases/tests-phandle.dtsi)0
-rw-r--r--drivers/pci/host/pci-mvebu.c11
-rw-r--r--drivers/pci/msi.c10
-rw-r--r--drivers/pci/pci.c10
-rw-r--r--drivers/phy/Kconfig3
-rw-r--r--drivers/phy/phy-core.c14
-rw-r--r--drivers/phy/phy-exynos-dp-video.c8
-rw-r--r--drivers/phy/phy-exynos-mipi-video.c10
-rw-r--r--drivers/phy/phy-mvebu-sata.c10
-rw-r--r--drivers/phy/phy-omap-usb2.c10
-rw-r--r--drivers/phy/phy-twl4030-usb.c10
-rw-r--r--drivers/pwm/pwm-lp3943.c4
-rw-r--r--drivers/rapidio/devices/tsi721.h1
-rw-r--r--drivers/rapidio/devices/tsi721_dma.c27
-rw-r--r--drivers/regulator/core.c50
-rw-r--r--drivers/regulator/da9063-regulator.c4
-rw-r--r--drivers/regulator/max14577.c5
-rw-r--r--drivers/regulator/s5m8767.c4
-rw-r--r--drivers/rtc/rtc-s3c.c17
-rw-r--r--drivers/s390/cio/chsc.c1
-rw-r--r--drivers/s390/crypto/zcrypt_msgtype6.c24
-rw-r--r--drivers/s390/net/qeth_core_main.c5
-rw-r--r--drivers/s390/net/qeth_l2_main.c3
-rw-r--r--drivers/s390/net/qeth_l3_main.c3
-rw-r--r--drivers/sbus/char/jsflash.c1
-rw-r--r--drivers/scsi/qla2xxx/qla_target.c42
-rw-r--r--drivers/scsi/qla2xxx/qla_target.h2
-rw-r--r--drivers/scsi/qla2xxx/tcm_qla2xxx.c158
-rw-r--r--drivers/scsi/qla2xxx/tcm_qla2xxx.h7
-rw-r--r--drivers/staging/android/binder.c3
-rw-r--r--drivers/staging/iio/adc/mxs-lradc.c1
-rw-r--r--drivers/staging/rtl8188eu/os_dep/usb_intf.c1
-rw-r--r--drivers/target/target_core_sbc.c15
-rw-r--r--drivers/target/target_core_transport.c3
-rw-r--r--drivers/tty/tty_io.c25
-rw-r--r--drivers/usb/chipidea/udc.c4
-rw-r--r--drivers/usb/gadget/bcm63xx_udc.c58
-rw-r--r--drivers/usb/gadget/f_fs.c7
-rw-r--r--drivers/usb/gadget/printer.c2
-rw-r--r--drivers/usb/gadget/s3c2410_udc.c2
-rw-r--r--drivers/usb/host/ehci-hcd.c13
-rw-r--r--drivers/usb/host/ehci-hub.c26
-rw-r--r--drivers/usb/musb/musb_core.c15
-rw-r--r--drivers/usb/musb/musb_host.c3
-rw-r--r--drivers/usb/musb/musb_virthub.c26
-rw-r--r--drivers/usb/musb/omap2430.c2
-rw-r--r--drivers/usb/phy/phy-msm-usb.c57
-rw-r--r--drivers/usb/serial/ftdi_sio.c2
-rw-r--r--drivers/usb/serial/ftdi_sio_ids.h6
-rw-r--r--drivers/usb/serial/option.c3
-rw-r--r--drivers/vfio/vfio_iommu_type1.c4
-rw-r--r--drivers/vhost/scsi.c6
-rw-r--r--drivers/watchdog/w83697hf_wdt.c2
-rw-r--r--fs/fs-writeback.c33
-rw-r--r--fs/hfsplus/options.c2
-rw-r--r--fs/kernfs/mount.c8
-rw-r--r--fs/nfs/inode.c14
-rw-r--r--fs/nfs/internal.h12
-rw-r--r--fs/nfs/nfs3proc.c1
-rw-r--r--fs/nfs/nfs4client.c7
-rw-r--r--fs/nfs/nfs4namespace.c12
-rw-r--r--fs/nfs/nfs4state.c5
-rw-r--r--fs/notify/dnotify/dnotify.c2
-rw-r--r--fs/notify/fanotify/fanotify.c8
-rw-r--r--fs/notify/fanotify/fanotify_user.c13
-rw-r--r--fs/notify/fsnotify.c2
-rw-r--r--fs/notify/group.c8
-rw-r--r--fs/notify/inotify/inotify.h2
-rw-r--r--fs/notify/inotify/inotify_fsnotify.c3
-rw-r--r--fs/notify/inotify/inotify_user.c14
-rw-r--r--fs/notify/notification.c20
-rw-r--r--fs/ocfs2/quota_global.c27
-rw-r--r--fs/ocfs2/quota_local.c4
-rw-r--r--fs/proc/page.c5
-rw-r--r--fs/quota/dquot.c14
-rw-r--r--fs/sync.c15
-rw-r--r--fs/sysfs/mount.c5
-rw-r--r--fs/udf/file.c14
-rw-r--r--fs/udf/inode.c1
-rw-r--r--fs/xfs/xfs_iops.c16
-rw-r--r--fs/xfs/xfs_log_cil.c19
-rw-r--r--fs/xfs/xfs_mount.c24
-rw-r--r--fs/xfs/xfs_sb.c10
-rw-r--r--fs/xfs/xfs_super.c2
-rw-r--r--include/dt-bindings/clock/tegra124-car.h4
-rw-r--r--include/linux/cgroup.h2
-rw-r--r--include/linux/fsnotify_backend.h4
-rw-r--r--include/linux/huge_mm.h41
-rw-r--r--include/linux/ipc_namespace.h2
-rw-r--r--include/linux/kernfs.h9
-rw-r--r--include/linux/mfd/max8997-private.h2
-rw-r--r--include/linux/mfd/max8998-private.h2
-rw-r--r--include/linux/mfd/tps65217.h4
-rw-r--r--include/linux/mm.h20
-rw-r--r--include/linux/pci.h20
-rw-r--r--include/linux/skbuff.h5
-rw-r--r--include/linux/syscalls.h6
-rw-r--r--include/linux/workqueue.h5
-rw-r--r--include/linux/writeback.h2
-rw-r--r--include/net/ip_tunnels.h1
-rw-r--r--include/net/tcp.h3
-rw-r--r--include/net/xfrm.h11
-rw-r--r--include/sound/soc-dapm.h8
-rw-r--r--include/trace/events/writeback.h6
-rw-r--r--include/uapi/asm-generic/unistd.h6
-rw-r--r--ipc/mq_sysctl.c18
-rw-r--r--ipc/mqueue.c6
-rw-r--r--kernel/audit_tree.c2
-rw-r--r--kernel/audit_watch.c2
-rw-r--r--kernel/cgroup.c60
-rw-r--r--kernel/events/core.c12
-rw-r--r--kernel/power/console.c1
-rw-r--r--kernel/sched/core.c28
-rw-r--r--kernel/sched/cpudeadline.c6
-rw-r--r--kernel/sched/deadline.c20
-rw-r--r--kernel/sched/fair.c10
-rw-r--r--kernel/sched/rt.c8
-rw-r--r--kernel/sched/sched.h1
-rw-r--r--kernel/time/sched_clock.c46
-rw-r--r--kernel/user_namespace.c2
-rw-r--r--kernel/workqueue.c7
-rw-r--r--lib/dma-debug.c131
-rw-r--r--lib/radix-tree.c4
-rw-r--r--mm/huge_memory.c11
-rw-r--r--mm/ksm.c2
-rw-r--r--mm/memcontrol.c20
-rw-r--r--mm/memory-failure.c2
-rw-r--r--mm/memory.c15
-rw-r--r--mm/page_alloc.c30
-rw-r--r--mm/swap.c4
-rw-r--r--mm/vmpressure.c1
-rw-r--r--net/can/raw.c26
-rw-r--r--net/core/neighbour.c8
-rw-r--r--net/core/skbuff.c3
-rw-r--r--net/hsr/hsr_framereg.c2
-rw-r--r--net/ipv4/af_inet.c7
-rw-r--r--net/ipv4/ip_output.c3
-rw-r--r--net/ipv4/ip_tunnel.c53
-rw-r--r--net/ipv4/ip_tunnel_core.c47
-rw-r--r--net/ipv4/netfilter/nf_nat_snmp_basic.c4
-rw-r--r--net/ipv4/tcp.c8
-rw-r--r--net/ipv4/tcp_cong.c3
-rw-r--r--net/ipv4/tcp_input.c3
-rw-r--r--net/ipv4/tcp_output.c22
-rw-r--r--net/ipv6/Kconfig1
-rw-r--r--net/ipv6/exthdrs_core.c2
-rw-r--r--net/ipv6/ip6_offload.c20
-rw-r--r--net/ipv6/ip6_output.c3
-rw-r--r--net/ipv6/ping.c1
-rw-r--r--net/ipv6/sit.c19
-rw-r--r--net/ipv6/udp_offload.c2
-rw-r--r--net/mac80211/ieee80211_i.h10
-rw-r--r--net/mac80211/mlme.c24
-rw-r--r--net/mac80211/rx.c7
-rw-r--r--net/mac80211/sta_info.c66
-rw-r--r--net/mac80211/sta_info.h7
-rw-r--r--net/mac80211/tx.c15
-rw-r--r--net/mac80211/util.c48
-rw-r--r--net/mac80211/wme.c5
-rw-r--r--net/netfilter/nf_conntrack_netlink.c35
-rw-r--r--net/netfilter/nf_nat_core.c56
-rw-r--r--net/netfilter/nft_meta.c4
-rw-r--r--net/netfilter/nft_payload.c3
-rw-r--r--net/netfilter/nft_reject_inet.c4
-rw-r--r--net/netlink/af_netlink.c4
-rw-r--r--net/nfc/nci/core.c2
-rw-r--r--net/sched/sch_tbf.c24
-rw-r--r--net/sctp/associola.c129
-rw-r--r--net/sctp/sm_sideeffect.c7
-rw-r--r--net/sctp/sm_statefuns.c7
-rw-r--r--net/sunrpc/auth_gss/auth_gss.c19
-rw-r--r--net/sunrpc/backchannel_rqst.c6
-rw-r--r--net/sunrpc/xprtsock.c6
-rw-r--r--net/tipc/bearer.c7
-rw-r--r--net/tipc/config.c2
-rw-r--r--net/tipc/core.c109
-rw-r--r--net/tipc/core.h1
-rw-r--r--net/tipc/name_table.c3
-rw-r--r--net/tipc/netlink.c8
-rw-r--r--net/tipc/ref.c3
-rw-r--r--net/tipc/server.c5
-rw-r--r--net/tipc/server.h2
-rw-r--r--net/tipc/socket.c8
-rw-r--r--net/wireless/reg.c12
-rw-r--r--net/xfrm/xfrm_policy.c2
-rw-r--r--net/xfrm/xfrm_state.c23
-rw-r--r--net/xfrm/xfrm_user.c5
-rw-r--r--scripts/Makefile.lib1
-rw-r--r--scripts/gen_initramfs_list.sh2
-rw-r--r--scripts/kallsyms.c3
-rw-r--r--security/selinux/ss/policydb.c8
-rw-r--r--sound/pci/hda/patch_ca0132.c68
-rw-r--r--sound/pci/hda/patch_realtek.c50
-rw-r--r--sound/pci/hda/patch_sigmatel.c33
-rw-r--r--sound/soc/blackfin/Kconfig11
-rw-r--r--sound/soc/codecs/ad1980.c4
-rw-r--r--sound/soc/codecs/da732x.c12
-rw-r--r--sound/soc/codecs/da9055.c11
-rw-r--r--sound/soc/codecs/isabelle.c52
-rw-r--r--sound/soc/codecs/max98090.c21
-rw-r--r--sound/soc/codecs/rt5640.c1
-rw-r--r--sound/soc/codecs/sta32x.c76
-rw-r--r--sound/soc/codecs/wm8400.c34
-rw-r--r--sound/soc/codecs/wm8770.c4
-rw-r--r--sound/soc/codecs/wm8900.c44
-rw-r--r--sound/soc/codecs/wm8958-dsp2.c2
-rw-r--r--sound/soc/codecs/wm8993.c1
-rw-r--r--sound/soc/codecs/wm8994.c135
-rw-r--r--sound/soc/davinci/davinci-evm.c1
-rw-r--r--sound/soc/davinci/davinci-mcasp.c83
-rw-r--r--sound/soc/fsl/fsl_esai.c4
-rw-r--r--sound/soc/fsl/fsl_esai.h2
-rw-r--r--sound/soc/fsl/imx-mc13783.c1
-rw-r--r--sound/soc/fsl/imx-sgtl5000.c10
-rw-r--r--sound/soc/fsl/imx-wm8962.c11
-rw-r--r--sound/soc/samsung/Kconfig6
-rw-r--r--sound/soc/soc-dapm.c139
-rw-r--r--sound/soc/txx9/txx9aclc-ac97.c8
-rw-r--r--sound/usb/mixer_maps.c9
-rw-r--r--tools/lib/lockdep/Makefile6
-rw-r--r--tools/lib/lockdep/preload.c2
-rwxr-xr-x[-rw-r--r--]tools/lib/lockdep/run_tests.sh0
-rw-r--r--tools/lib/lockdep/uinclude/asm/hash.h6
-rw-r--r--tools/lib/lockdep/uinclude/linux/rcu.h5
-rw-r--r--tools/perf/builtin-report.c40
-rw-r--r--tools/perf/builtin-top.c6
-rw-r--r--tools/perf/builtin-trace.c22
-rw-r--r--tools/perf/config/Makefile2
-rw-r--r--tools/perf/config/feature-checks/Makefile2
-rw-r--r--tools/perf/util/annotate.c9
-rw-r--r--tools/perf/util/annotate.h2
-rw-r--r--tools/perf/util/include/linux/bitops.h4
-rw-r--r--tools/perf/util/parse-events.c17
-rw-r--r--tools/perf/util/probe-event.c2
-rw-r--r--tools/perf/util/session.c6
-rw-r--r--tools/perf/util/symbol.c2
494 files changed, 4840 insertions, 2963 deletions
diff --git a/Documentation/ABI/testing/sysfs-tty b/Documentation/ABI/testing/sysfs-tty
index a2ccec35ffce..ad22fb0ee765 100644
--- a/Documentation/ABI/testing/sysfs-tty
+++ b/Documentation/ABI/testing/sysfs-tty
@@ -3,8 +3,7 @@ Date: Nov 2010
3Contact: Kay Sievers <kay.sievers@vrfy.org> 3Contact: Kay Sievers <kay.sievers@vrfy.org>
4Description: 4Description:
5 Shows the list of currently configured 5 Shows the list of currently configured
6 tty devices used for the console, 6 console devices, like 'tty1 ttyS0'.
7 like 'tty1 ttyS0'.
8 The last entry in the file is the active 7 The last entry in the file is the active
9 device connected to /dev/console. 8 device connected to /dev/console.
10 The file supports poll() to detect virtual 9 The file supports poll() to detect virtual
diff --git a/Documentation/PCI/MSI-HOWTO.txt b/Documentation/PCI/MSI-HOWTO.txt
index a8d01005f480..10a93696e55a 100644
--- a/Documentation/PCI/MSI-HOWTO.txt
+++ b/Documentation/PCI/MSI-HOWTO.txt
@@ -82,7 +82,19 @@ Most of the hard work is done for the driver in the PCI layer. It simply
82has to request that the PCI layer set up the MSI capability for this 82has to request that the PCI layer set up the MSI capability for this
83device. 83device.
84 84
854.2.1 pci_enable_msi_range 854.2.1 pci_enable_msi
86
87int pci_enable_msi(struct pci_dev *dev)
88
89A successful call allocates ONE interrupt to the device, regardless
90of how many MSIs the device supports. The device is switched from
91pin-based interrupt mode to MSI mode. The dev->irq number is changed
92to a new number which represents the message signaled interrupt;
93consequently, this function should be called before the driver calls
94request_irq(), because an MSI is delivered via a vector that is
95different from the vector of a pin-based interrupt.
96
974.2.2 pci_enable_msi_range
86 98
87int pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec) 99int pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec)
88 100
@@ -147,6 +159,11 @@ static int foo_driver_enable_msi(struct pci_dev *pdev, int nvec)
147 return pci_enable_msi_range(pdev, nvec, nvec); 159 return pci_enable_msi_range(pdev, nvec, nvec);
148} 160}
149 161
162Note, unlike pci_enable_msi_exact() function, which could be also used to
163enable a particular number of MSI-X interrupts, pci_enable_msi_range()
164returns either a negative errno or 'nvec' (not negative errno or 0 - as
165pci_enable_msi_exact() does).
166
1504.2.1.3 Single MSI mode 1674.2.1.3 Single MSI mode
151 168
152The most notorious example of the request type described above is 169The most notorious example of the request type described above is
@@ -158,7 +175,27 @@ static int foo_driver_enable_single_msi(struct pci_dev *pdev)
158 return pci_enable_msi_range(pdev, 1, 1); 175 return pci_enable_msi_range(pdev, 1, 1);
159} 176}
160 177
1614.2.2 pci_disable_msi 178Note, unlike pci_enable_msi() function, which could be also used to
179enable the single MSI mode, pci_enable_msi_range() returns either a
180negative errno or 1 (not negative errno or 0 - as pci_enable_msi()
181does).
182
1834.2.3 pci_enable_msi_exact
184
185int pci_enable_msi_exact(struct pci_dev *dev, int nvec)
186
187This variation on pci_enable_msi_range() call allows a device driver to
188request exactly 'nvec' MSIs.
189
190If this function returns a negative number, it indicates an error and
191the driver should not attempt to request any more MSI interrupts for
192this device.
193
194By contrast with pci_enable_msi_range() function, pci_enable_msi_exact()
195returns zero in case of success, which indicates MSI interrupts have been
196successfully allocated.
197
1984.2.4 pci_disable_msi
162 199
163void pci_disable_msi(struct pci_dev *dev) 200void pci_disable_msi(struct pci_dev *dev)
164 201
@@ -172,7 +209,7 @@ on any interrupt for which it previously called request_irq().
172Failure to do so results in a BUG_ON(), leaving the device with 209Failure to do so results in a BUG_ON(), leaving the device with
173MSI enabled and thus leaking its vector. 210MSI enabled and thus leaking its vector.
174 211
1754.2.3 pci_msi_vec_count 2124.2.4 pci_msi_vec_count
176 213
177int pci_msi_vec_count(struct pci_dev *dev) 214int pci_msi_vec_count(struct pci_dev *dev)
178 215
@@ -257,8 +294,8 @@ possible, likely up to the limit returned by pci_msix_vec_count() function:
257 294
258static int foo_driver_enable_msix(struct foo_adapter *adapter, int nvec) 295static int foo_driver_enable_msix(struct foo_adapter *adapter, int nvec)
259{ 296{
260 return pci_enable_msi_range(adapter->pdev, adapter->msix_entries, 297 return pci_enable_msix_range(adapter->pdev, adapter->msix_entries,
261 1, nvec); 298 1, nvec);
262} 299}
263 300
264Note the value of 'minvec' parameter is 1. As 'minvec' is inclusive, 301Note the value of 'minvec' parameter is 1. As 'minvec' is inclusive,
@@ -269,8 +306,8 @@ In this case the function could look like this:
269 306
270static int foo_driver_enable_msix(struct foo_adapter *adapter, int nvec) 307static int foo_driver_enable_msix(struct foo_adapter *adapter, int nvec)
271{ 308{
272 return pci_enable_msi_range(adapter->pdev, adapter->msix_entries, 309 return pci_enable_msix_range(adapter->pdev, adapter->msix_entries,
273 FOO_DRIVER_MINIMUM_NVEC, nvec); 310 FOO_DRIVER_MINIMUM_NVEC, nvec);
274} 311}
275 312
2764.3.1.2 Exact number of MSI-X interrupts 3134.3.1.2 Exact number of MSI-X interrupts
@@ -282,10 +319,15 @@ parameters:
282 319
283static int foo_driver_enable_msix(struct foo_adapter *adapter, int nvec) 320static int foo_driver_enable_msix(struct foo_adapter *adapter, int nvec)
284{ 321{
285 return pci_enable_msi_range(adapter->pdev, adapter->msix_entries, 322 return pci_enable_msix_range(adapter->pdev, adapter->msix_entries,
286 nvec, nvec); 323 nvec, nvec);
287} 324}
288 325
326Note, unlike pci_enable_msix_exact() function, which could be also used to
327enable a particular number of MSI-X interrupts, pci_enable_msix_range()
328returns either a negative errno or 'nvec' (not negative errno or 0 - as
329pci_enable_msix_exact() does).
330
2894.3.1.3 Specific requirements to the number of MSI-X interrupts 3314.3.1.3 Specific requirements to the number of MSI-X interrupts
290 332
291As noted above, there could be devices that can not operate with just any 333As noted above, there could be devices that can not operate with just any
@@ -332,7 +374,64 @@ Note how pci_enable_msix_range() return value is analized for a fallback -
332any error code other than -ENOSPC indicates a fatal error and should not 374any error code other than -ENOSPC indicates a fatal error and should not
333be retried. 375be retried.
334 376
3354.3.2 pci_disable_msix 3774.3.2 pci_enable_msix_exact
378
379int pci_enable_msix_exact(struct pci_dev *dev,
380 struct msix_entry *entries, int nvec)
381
382This variation on pci_enable_msix_range() call allows a device driver to
383request exactly 'nvec' MSI-Xs.
384
385If this function returns a negative number, it indicates an error and
386the driver should not attempt to allocate any more MSI-X interrupts for
387this device.
388
389By contrast with pci_enable_msix_range() function, pci_enable_msix_exact()
390returns zero in case of success, which indicates MSI-X interrupts have been
391successfully allocated.
392
393Another version of a routine that enables MSI-X mode for a device with
394specific requirements described in chapter 4.3.1.3 might look like this:
395
396/*
397 * Assume 'minvec' and 'maxvec' are non-zero
398 */
399static int foo_driver_enable_msix(struct foo_adapter *adapter,
400 int minvec, int maxvec)
401{
402 int rc;
403
404 minvec = roundup_pow_of_two(minvec);
405 maxvec = rounddown_pow_of_two(maxvec);
406
407 if (minvec > maxvec)
408 return -ERANGE;
409
410retry:
411 rc = pci_enable_msix_exact(adapter->pdev,
412 adapter->msix_entries, maxvec);
413
414 /*
415 * -ENOSPC is the only error code allowed to be analyzed
416 */
417 if (rc == -ENOSPC) {
418 if (maxvec == 1)
419 return -ENOSPC;
420
421 maxvec /= 2;
422
423 if (minvec > maxvec)
424 return -ENOSPC;
425
426 goto retry;
427 } else if (rc < 0) {
428 return rc;
429 }
430
431 return maxvec;
432}
433
4344.3.3 pci_disable_msix
336 435
337void pci_disable_msix(struct pci_dev *dev) 436void pci_disable_msix(struct pci_dev *dev)
338 437
diff --git a/Documentation/devicetree/bindings/arm/omap/omap.txt b/Documentation/devicetree/bindings/arm/omap/omap.txt
index 34dc40cffdfd..af9b4a0d902b 100644
--- a/Documentation/devicetree/bindings/arm/omap/omap.txt
+++ b/Documentation/devicetree/bindings/arm/omap/omap.txt
@@ -91,7 +91,7 @@ Boards:
91 compatible = "ti,omap3-beagle", "ti,omap3" 91 compatible = "ti,omap3-beagle", "ti,omap3"
92 92
93- OMAP3 Tobi with Overo : Commercial expansion board with daughter board 93- OMAP3 Tobi with Overo : Commercial expansion board with daughter board
94 compatible = "ti,omap3-tobi", "ti,omap3-overo", "ti,omap3" 94 compatible = "gumstix,omap3-overo-tobi", "gumstix,omap3-overo", "ti,omap3"
95 95
96- OMAP4 SDP : Software Development Board 96- OMAP4 SDP : Software Development Board
97 compatible = "ti,omap4-sdp", "ti,omap4430" 97 compatible = "ti,omap4-sdp", "ti,omap4430"
diff --git a/Documentation/devicetree/bindings/clock/renesas,cpg-mstp-clocks.txt b/Documentation/devicetree/bindings/clock/renesas,cpg-mstp-clocks.txt
index a6a352c2771e..5992dceec7af 100644
--- a/Documentation/devicetree/bindings/clock/renesas,cpg-mstp-clocks.txt
+++ b/Documentation/devicetree/bindings/clock/renesas,cpg-mstp-clocks.txt
@@ -21,9 +21,9 @@ Required Properties:
21 must appear in the same order as the output clocks. 21 must appear in the same order as the output clocks.
22 - #clock-cells: Must be 1 22 - #clock-cells: Must be 1
23 - clock-output-names: The name of the clocks as free-form strings 23 - clock-output-names: The name of the clocks as free-form strings
24 - renesas,indices: Indices of the gate clocks into the group (0 to 31) 24 - renesas,clock-indices: Indices of the gate clocks into the group (0 to 31)
25 25
26The clocks, clock-output-names and renesas,indices properties contain one 26The clocks, clock-output-names and renesas,clock-indices properties contain one
27entry per gate clock. The MSTP groups are sparsely populated. Unimplemented 27entry per gate clock. The MSTP groups are sparsely populated. Unimplemented
28gate clocks must not be declared. 28gate clocks must not be declared.
29 29
diff --git a/Documentation/devicetree/bindings/dma/fsl-imx-sdma.txt b/Documentation/devicetree/bindings/dma/fsl-imx-sdma.txt
index 68b83ecc3850..ee9be9961524 100644
--- a/Documentation/devicetree/bindings/dma/fsl-imx-sdma.txt
+++ b/Documentation/devicetree/bindings/dma/fsl-imx-sdma.txt
@@ -1,12 +1,16 @@
1* Freescale Smart Direct Memory Access (SDMA) Controller for i.MX 1* Freescale Smart Direct Memory Access (SDMA) Controller for i.MX
2 2
3Required properties: 3Required properties:
4- compatible : Should be "fsl,imx31-sdma", "fsl,imx31-to1-sdma", 4- compatible : Should be one of
5 "fsl,imx31-to2-sdma", "fsl,imx35-sdma", "fsl,imx35-to1-sdma", 5 "fsl,imx25-sdma"
6 "fsl,imx35-to2-sdma", "fsl,imx51-sdma", "fsl,imx53-sdma" or 6 "fsl,imx31-sdma", "fsl,imx31-to1-sdma", "fsl,imx31-to2-sdma"
7 "fsl,imx6q-sdma". The -to variants should be preferred since they 7 "fsl,imx35-sdma", "fsl,imx35-to1-sdma", "fsl,imx35-to2-sdma"
8 allow to determnine the correct ROM script addresses needed for 8 "fsl,imx51-sdma"
9 the driver to work without additional firmware. 9 "fsl,imx53-sdma"
10 "fsl,imx6q-sdma"
11 The -to variants should be preferred since they allow to determnine the
12 correct ROM script addresses needed for the driver to work without additional
13 firmware.
10- reg : Should contain SDMA registers location and length 14- reg : Should contain SDMA registers location and length
11- interrupts : Should contain SDMA interrupt 15- interrupts : Should contain SDMA interrupt
12- #dma-cells : Must be <3>. 16- #dma-cells : Must be <3>.
diff --git a/Documentation/devicetree/bindings/net/opencores-ethoc.txt b/Documentation/devicetree/bindings/net/opencores-ethoc.txt
new file mode 100644
index 000000000000..2dc127c30d9b
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/opencores-ethoc.txt
@@ -0,0 +1,22 @@
1* OpenCores MAC 10/100 Mbps
2
3Required properties:
4- compatible: Should be "opencores,ethoc".
5- reg: two memory regions (address and length),
6 first region is for the device registers and descriptor rings,
7 second is for the device packet memory.
8- interrupts: interrupt for the device.
9
10Optional properties:
11- clocks: phandle to refer to the clk used as per
12 Documentation/devicetree/bindings/clock/clock-bindings.txt
13
14Examples:
15
16 enet0: ethoc@fd030000 {
17 compatible = "opencores,ethoc";
18 reg = <0xfd030000 0x4000 0xfd800000 0x4000>;
19 interrupts = <1>;
20 local-mac-address = [00 50 c2 13 6f 00];
21 clocks = <&osc>;
22 };
diff --git a/Documentation/networking/can.txt b/Documentation/networking/can.txt
index f3089d423515..0cbe6ec22d6f 100644
--- a/Documentation/networking/can.txt
+++ b/Documentation/networking/can.txt
@@ -554,12 +554,6 @@ solution for a couple of reasons:
554 not specified in the struct can_frame and therefore it is only valid in 554 not specified in the struct can_frame and therefore it is only valid in
555 CANFD_MTU sized CAN FD frames. 555 CANFD_MTU sized CAN FD frames.
556 556
557 As long as the payload length is <=8 the received CAN frames from CAN FD
558 capable CAN devices can be received and read by legacy sockets too. When
559 user-generated CAN FD frames have a payload length <=8 these can be send
560 by legacy CAN network interfaces too. Sending CAN FD frames with payload
561 length > 8 to a legacy CAN network interface returns an -EMSGSIZE error.
562
563 Implementation hint for new CAN applications: 557 Implementation hint for new CAN applications:
564 558
565 To build a CAN FD aware application use struct canfd_frame as basic CAN 559 To build a CAN FD aware application use struct canfd_frame as basic CAN
diff --git a/MAINTAINERS b/MAINTAINERS
index ebd298e00f44..e4ee191f9ffa 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -73,7 +73,8 @@ Descriptions of section entries:
73 L: Mailing list that is relevant to this area 73 L: Mailing list that is relevant to this area
74 W: Web-page with status/info 74 W: Web-page with status/info
75 Q: Patchwork web based patch tracking system site 75 Q: Patchwork web based patch tracking system site
76 T: SCM tree type and location. Type is one of: git, hg, quilt, stgit, topgit. 76 T: SCM tree type and location.
77 Type is one of: git, hg, quilt, stgit, topgit
77 S: Status, one of the following: 78 S: Status, one of the following:
78 Supported: Someone is actually paid to look after this. 79 Supported: Someone is actually paid to look after this.
79 Maintained: Someone actually looks after it. 80 Maintained: Someone actually looks after it.
@@ -538,7 +539,7 @@ F: arch/alpha/
538ALTERA UART/JTAG UART SERIAL DRIVERS 539ALTERA UART/JTAG UART SERIAL DRIVERS
539M: Tobias Klauser <tklauser@distanz.ch> 540M: Tobias Klauser <tklauser@distanz.ch>
540L: linux-serial@vger.kernel.org 541L: linux-serial@vger.kernel.org
541L: nios2-dev@sopc.et.ntust.edu.tw (moderated for non-subscribers) 542L: nios2-dev@lists.rocketboards.org (moderated for non-subscribers)
542S: Maintained 543S: Maintained
543F: drivers/tty/serial/altera_uart.c 544F: drivers/tty/serial/altera_uart.c
544F: drivers/tty/serial/altera_jtaguart.c 545F: drivers/tty/serial/altera_jtaguart.c
@@ -1612,11 +1613,11 @@ S: Maintained
1612F: drivers/net/wireless/atmel* 1613F: drivers/net/wireless/atmel*
1613 1614
1614ATTO EXPRESSSAS SAS/SATA RAID SCSI DRIVER 1615ATTO EXPRESSSAS SAS/SATA RAID SCSI DRIVER
1615M: Bradley Grove <linuxdrivers@attotech.com> 1616M: Bradley Grove <linuxdrivers@attotech.com>
1616L: linux-scsi@vger.kernel.org 1617L: linux-scsi@vger.kernel.org
1617W: http://www.attotech.com 1618W: http://www.attotech.com
1618S: Supported 1619S: Supported
1619F: drivers/scsi/esas2r 1620F: drivers/scsi/esas2r
1620 1621
1621AUDIT SUBSYSTEM 1622AUDIT SUBSYSTEM
1622M: Eric Paris <eparis@redhat.com> 1623M: Eric Paris <eparis@redhat.com>
@@ -1866,6 +1867,7 @@ F: drivers/net/ethernet/broadcom/bnx2x/
1866 1867
1867BROADCOM BCM281XX/BCM11XXX ARM ARCHITECTURE 1868BROADCOM BCM281XX/BCM11XXX ARM ARCHITECTURE
1868M: Christian Daudt <bcm@fixthebug.org> 1869M: Christian Daudt <bcm@fixthebug.org>
1870M: Matt Porter <mporter@linaro.org>
1869L: bcm-kernel-feedback-list@broadcom.com 1871L: bcm-kernel-feedback-list@broadcom.com
1870T: git git://git.github.com/broadcom/bcm11351 1872T: git git://git.github.com/broadcom/bcm11351
1871S: Maintained 1873S: Maintained
@@ -2164,7 +2166,7 @@ F: Documentation/zh_CN/
2164 2166
2165CHIPIDEA USB HIGH SPEED DUAL ROLE CONTROLLER 2167CHIPIDEA USB HIGH SPEED DUAL ROLE CONTROLLER
2166M: Peter Chen <Peter.Chen@freescale.com> 2168M: Peter Chen <Peter.Chen@freescale.com>
2167T: git://github.com/hzpeterchen/linux-usb.git 2169T: git git://github.com/hzpeterchen/linux-usb.git
2168L: linux-usb@vger.kernel.org 2170L: linux-usb@vger.kernel.org
2169S: Maintained 2171S: Maintained
2170F: drivers/usb/chipidea/ 2172F: drivers/usb/chipidea/
@@ -2184,9 +2186,9 @@ S: Supported
2184F: drivers/net/ethernet/cisco/enic/ 2186F: drivers/net/ethernet/cisco/enic/
2185 2187
2186CISCO VIC LOW LATENCY NIC DRIVER 2188CISCO VIC LOW LATENCY NIC DRIVER
2187M: Upinder Malhi <umalhi@cisco.com> 2189M: Upinder Malhi <umalhi@cisco.com>
2188S: Supported 2190S: Supported
2189F: drivers/infiniband/hw/usnic 2191F: drivers/infiniband/hw/usnic
2190 2192
2191CIRRUS LOGIC EP93XX ETHERNET DRIVER 2193CIRRUS LOGIC EP93XX ETHERNET DRIVER
2192M: Hartley Sweeten <hsweeten@visionengravers.com> 2194M: Hartley Sweeten <hsweeten@visionengravers.com>
@@ -2383,20 +2385,20 @@ F: drivers/cpufreq/arm_big_little.c
2383F: drivers/cpufreq/arm_big_little_dt.c 2385F: drivers/cpufreq/arm_big_little_dt.c
2384 2386
2385CPUIDLE DRIVER - ARM BIG LITTLE 2387CPUIDLE DRIVER - ARM BIG LITTLE
2386M: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> 2388M: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
2387M: Daniel Lezcano <daniel.lezcano@linaro.org> 2389M: Daniel Lezcano <daniel.lezcano@linaro.org>
2388L: linux-pm@vger.kernel.org 2390L: linux-pm@vger.kernel.org
2389L: linux-arm-kernel@lists.infradead.org 2391L: linux-arm-kernel@lists.infradead.org
2390T: git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git 2392T: git git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git
2391S: Maintained 2393S: Maintained
2392F: drivers/cpuidle/cpuidle-big_little.c 2394F: drivers/cpuidle/cpuidle-big_little.c
2393 2395
2394CPUIDLE DRIVERS 2396CPUIDLE DRIVERS
2395M: Rafael J. Wysocki <rjw@rjwysocki.net> 2397M: Rafael J. Wysocki <rjw@rjwysocki.net>
2396M: Daniel Lezcano <daniel.lezcano@linaro.org> 2398M: Daniel Lezcano <daniel.lezcano@linaro.org>
2397L: linux-pm@vger.kernel.org 2399L: linux-pm@vger.kernel.org
2398S: Maintained 2400S: Maintained
2399T: git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git 2401T: git git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git
2400F: drivers/cpuidle/* 2402F: drivers/cpuidle/*
2401F: include/linux/cpuidle.h 2403F: include/linux/cpuidle.h
2402 2404
@@ -2414,8 +2416,10 @@ F: tools/power/cpupower/
2414 2416
2415CPUSETS 2417CPUSETS
2416M: Li Zefan <lizefan@huawei.com> 2418M: Li Zefan <lizefan@huawei.com>
2419L: cgroups@vger.kernel.org
2417W: http://www.bullopensource.org/cpuset/ 2420W: http://www.bullopensource.org/cpuset/
2418W: http://oss.sgi.com/projects/cpusets/ 2421W: http://oss.sgi.com/projects/cpusets/
2422T: git git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup.git
2419S: Maintained 2423S: Maintained
2420F: Documentation/cgroups/cpusets.txt 2424F: Documentation/cgroups/cpusets.txt
2421F: include/linux/cpuset.h 2425F: include/linux/cpuset.h
@@ -2461,9 +2465,9 @@ S: Maintained
2461F: sound/pci/cs5535audio/ 2465F: sound/pci/cs5535audio/
2462 2466
2463CW1200 WLAN driver 2467CW1200 WLAN driver
2464M: Solomon Peachy <pizza@shaftnet.org> 2468M: Solomon Peachy <pizza@shaftnet.org>
2465S: Maintained 2469S: Maintained
2466F: drivers/net/wireless/cw1200/ 2470F: drivers/net/wireless/cw1200/
2467 2471
2468CX18 VIDEO4LINUX DRIVER 2472CX18 VIDEO4LINUX DRIVER
2469M: Andy Walls <awalls@md.metrocast.net> 2473M: Andy Walls <awalls@md.metrocast.net>
@@ -2614,9 +2618,9 @@ DC395x SCSI driver
2614M: Oliver Neukum <oliver@neukum.org> 2618M: Oliver Neukum <oliver@neukum.org>
2615M: Ali Akcaagac <aliakc@web.de> 2619M: Ali Akcaagac <aliakc@web.de>
2616M: Jamie Lenehan <lenehan@twibble.org> 2620M: Jamie Lenehan <lenehan@twibble.org>
2617W: http://twibble.org/dist/dc395x/
2618L: dc395x@twibble.org 2621L: dc395x@twibble.org
2619L: http://lists.twibble.org/mailman/listinfo/dc395x/ 2622W: http://twibble.org/dist/dc395x/
2623W: http://lists.twibble.org/mailman/listinfo/dc395x/
2620S: Maintained 2624S: Maintained
2621F: Documentation/scsi/dc395x.txt 2625F: Documentation/scsi/dc395x.txt
2622F: drivers/scsi/dc395x.* 2626F: drivers/scsi/dc395x.*
@@ -2851,12 +2855,22 @@ F: lib/kobj*
2851DRM DRIVERS 2855DRM DRIVERS
2852M: David Airlie <airlied@linux.ie> 2856M: David Airlie <airlied@linux.ie>
2853L: dri-devel@lists.freedesktop.org 2857L: dri-devel@lists.freedesktop.org
2854T: git git://git.kernel.org/pub/scm/linux/kernel/git/airlied/drm-2.6.git 2858T: git git://people.freedesktop.org/~airlied/linux
2855S: Maintained 2859S: Maintained
2856F: drivers/gpu/drm/ 2860F: drivers/gpu/drm/
2857F: include/drm/ 2861F: include/drm/
2858F: include/uapi/drm/ 2862F: include/uapi/drm/
2859 2863
2864RADEON DRM DRIVERS
2865M: Alex Deucher <alexander.deucher@amd.com>
2866M: Christian König <christian.koenig@amd.com>
2867L: dri-devel@lists.freedesktop.org
2868T: git git://people.freedesktop.org/~agd5f/linux
2869S: Supported
2870F: drivers/gpu/drm/radeon/
2871F: include/drm/radeon*
2872F: include/uapi/drm/radeon*
2873
2860INTEL DRM DRIVERS (excluding Poulsbo, Moorestown and derivative chipsets) 2874INTEL DRM DRIVERS (excluding Poulsbo, Moorestown and derivative chipsets)
2861M: Daniel Vetter <daniel.vetter@ffwll.ch> 2875M: Daniel Vetter <daniel.vetter@ffwll.ch>
2862M: Jani Nikula <jani.nikula@linux.intel.com> 2876M: Jani Nikula <jani.nikula@linux.intel.com>
@@ -3088,6 +3102,8 @@ F: fs/ecryptfs/
3088 3102
3089EDAC-CORE 3103EDAC-CORE
3090M: Doug Thompson <dougthompson@xmission.com> 3104M: Doug Thompson <dougthompson@xmission.com>
3105M: Borislav Petkov <bp@alien8.de>
3106M: Mauro Carvalho Chehab <m.chehab@samsung.com>
3091L: linux-edac@vger.kernel.org 3107L: linux-edac@vger.kernel.org
3092W: bluesmoke.sourceforge.net 3108W: bluesmoke.sourceforge.net
3093S: Supported 3109S: Supported
@@ -4551,6 +4567,7 @@ F: Documentation/networking/ixgbevf.txt
4551F: Documentation/networking/i40e.txt 4567F: Documentation/networking/i40e.txt
4552F: Documentation/networking/i40evf.txt 4568F: Documentation/networking/i40evf.txt
4553F: drivers/net/ethernet/intel/ 4569F: drivers/net/ethernet/intel/
4570F: drivers/net/ethernet/intel/*/
4554 4571
4555INTEL-MID GPIO DRIVER 4572INTEL-MID GPIO DRIVER
4556M: David Cohen <david.a.cohen@linux.intel.com> 4573M: David Cohen <david.a.cohen@linux.intel.com>
@@ -4907,7 +4924,7 @@ F: drivers/staging/ktap/
4907KCONFIG 4924KCONFIG
4908M: "Yann E. MORIN" <yann.morin.1998@free.fr> 4925M: "Yann E. MORIN" <yann.morin.1998@free.fr>
4909L: linux-kbuild@vger.kernel.org 4926L: linux-kbuild@vger.kernel.org
4910T: git://gitorious.org/linux-kconfig/linux-kconfig 4927T: git git://gitorious.org/linux-kconfig/linux-kconfig
4911S: Maintained 4928S: Maintained
4912F: Documentation/kbuild/kconfig-language.txt 4929F: Documentation/kbuild/kconfig-language.txt
4913F: scripts/kconfig/ 4930F: scripts/kconfig/
@@ -5464,11 +5481,11 @@ S: Maintained
5464F: drivers/media/tuners/m88ts2022* 5481F: drivers/media/tuners/m88ts2022*
5465 5482
5466MA901 MASTERKIT USB FM RADIO DRIVER 5483MA901 MASTERKIT USB FM RADIO DRIVER
5467M: Alexey Klimov <klimov.linux@gmail.com> 5484M: Alexey Klimov <klimov.linux@gmail.com>
5468L: linux-media@vger.kernel.org 5485L: linux-media@vger.kernel.org
5469T: git git://linuxtv.org/media_tree.git 5486T: git git://linuxtv.org/media_tree.git
5470S: Maintained 5487S: Maintained
5471F: drivers/media/radio/radio-ma901.c 5488F: drivers/media/radio/radio-ma901.c
5472 5489
5473MAC80211 5490MAC80211
5474M: Johannes Berg <johannes@sipsolutions.net> 5491M: Johannes Berg <johannes@sipsolutions.net>
@@ -5504,6 +5521,11 @@ W: http://www.kernel.org/doc/man-pages
5504L: linux-man@vger.kernel.org 5521L: linux-man@vger.kernel.org
5505S: Maintained 5522S: Maintained
5506 5523
5524MARVELL ARMADA DRM SUPPORT
5525M: Russell King <rmk+kernel@arm.linux.org.uk>
5526S: Maintained
5527F: drivers/gpu/drm/armada/
5528
5507MARVELL GIGABIT ETHERNET DRIVERS (skge/sky2) 5529MARVELL GIGABIT ETHERNET DRIVERS (skge/sky2)
5508M: Mirko Lindner <mlindner@marvell.com> 5530M: Mirko Lindner <mlindner@marvell.com>
5509M: Stephen Hemminger <stephen@networkplumber.org> 5531M: Stephen Hemminger <stephen@networkplumber.org>
@@ -5624,7 +5646,7 @@ F: drivers/scsi/megaraid/
5624 5646
5625MELLANOX ETHERNET DRIVER (mlx4_en) 5647MELLANOX ETHERNET DRIVER (mlx4_en)
5626M: Amir Vadai <amirv@mellanox.com> 5648M: Amir Vadai <amirv@mellanox.com>
5627L: netdev@vger.kernel.org 5649L: netdev@vger.kernel.org
5628S: Supported 5650S: Supported
5629W: http://www.mellanox.com 5651W: http://www.mellanox.com
5630Q: http://patchwork.ozlabs.org/project/netdev/list/ 5652Q: http://patchwork.ozlabs.org/project/netdev/list/
@@ -5665,7 +5687,7 @@ F: include/linux/mtd/
5665F: include/uapi/mtd/ 5687F: include/uapi/mtd/
5666 5688
5667MEN A21 WATCHDOG DRIVER 5689MEN A21 WATCHDOG DRIVER
5668M: Johannes Thumshirn <johannes.thumshirn@men.de> 5690M: Johannes Thumshirn <johannes.thumshirn@men.de>
5669L: linux-watchdog@vger.kernel.org 5691L: linux-watchdog@vger.kernel.org
5670S: Supported 5692S: Supported
5671F: drivers/watchdog/mena21_wdt.c 5693F: drivers/watchdog/mena21_wdt.c
@@ -5721,20 +5743,20 @@ L: linux-rdma@vger.kernel.org
5721W: http://www.mellanox.com 5743W: http://www.mellanox.com
5722Q: http://patchwork.ozlabs.org/project/netdev/list/ 5744Q: http://patchwork.ozlabs.org/project/netdev/list/
5723Q: http://patchwork.kernel.org/project/linux-rdma/list/ 5745Q: http://patchwork.kernel.org/project/linux-rdma/list/
5724T: git://openfabrics.org/~eli/connect-ib.git 5746T: git git://openfabrics.org/~eli/connect-ib.git
5725S: Supported 5747S: Supported
5726F: drivers/net/ethernet/mellanox/mlx5/core/ 5748F: drivers/net/ethernet/mellanox/mlx5/core/
5727F: include/linux/mlx5/ 5749F: include/linux/mlx5/
5728 5750
5729Mellanox MLX5 IB driver 5751Mellanox MLX5 IB driver
5730M: Eli Cohen <eli@mellanox.com> 5752M: Eli Cohen <eli@mellanox.com>
5731L: linux-rdma@vger.kernel.org 5753L: linux-rdma@vger.kernel.org
5732W: http://www.mellanox.com 5754W: http://www.mellanox.com
5733Q: http://patchwork.kernel.org/project/linux-rdma/list/ 5755Q: http://patchwork.kernel.org/project/linux-rdma/list/
5734T: git://openfabrics.org/~eli/connect-ib.git 5756T: git git://openfabrics.org/~eli/connect-ib.git
5735S: Supported 5757S: Supported
5736F: include/linux/mlx5/ 5758F: include/linux/mlx5/
5737F: drivers/infiniband/hw/mlx5/ 5759F: drivers/infiniband/hw/mlx5/
5738 5760
5739MODULE SUPPORT 5761MODULE SUPPORT
5740M: Rusty Russell <rusty@rustcorp.com.au> 5762M: Rusty Russell <rusty@rustcorp.com.au>
@@ -8442,8 +8464,8 @@ TARGET SUBSYSTEM
8442M: Nicholas A. Bellinger <nab@linux-iscsi.org> 8464M: Nicholas A. Bellinger <nab@linux-iscsi.org>
8443L: linux-scsi@vger.kernel.org 8465L: linux-scsi@vger.kernel.org
8444L: target-devel@vger.kernel.org 8466L: target-devel@vger.kernel.org
8445L: http://groups.google.com/group/linux-iscsi-target-dev
8446W: http://www.linux-iscsi.org 8467W: http://www.linux-iscsi.org
8468W: http://groups.google.com/group/linux-iscsi-target-dev
8447T: git git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending.git master 8469T: git git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending.git master
8448S: Supported 8470S: Supported
8449F: drivers/target/ 8471F: drivers/target/
@@ -8684,17 +8706,17 @@ S: Maintained
8684F: drivers/media/radio/radio-raremono.c 8706F: drivers/media/radio/radio-raremono.c
8685 8707
8686THERMAL 8708THERMAL
8687M: Zhang Rui <rui.zhang@intel.com> 8709M: Zhang Rui <rui.zhang@intel.com>
8688M: Eduardo Valentin <eduardo.valentin@ti.com> 8710M: Eduardo Valentin <eduardo.valentin@ti.com>
8689L: linux-pm@vger.kernel.org 8711L: linux-pm@vger.kernel.org
8690T: git git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux.git 8712T: git git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux.git
8691T: git git://git.kernel.org/pub/scm/linux/kernel/git/evalenti/linux-soc-thermal.git 8713T: git git://git.kernel.org/pub/scm/linux/kernel/git/evalenti/linux-soc-thermal.git
8692Q: https://patchwork.kernel.org/project/linux-pm/list/ 8714Q: https://patchwork.kernel.org/project/linux-pm/list/
8693S: Supported 8715S: Supported
8694F: drivers/thermal/ 8716F: drivers/thermal/
8695F: include/linux/thermal.h 8717F: include/linux/thermal.h
8696F: include/linux/cpu_cooling.h 8718F: include/linux/cpu_cooling.h
8697F: Documentation/devicetree/bindings/thermal/ 8719F: Documentation/devicetree/bindings/thermal/
8698 8720
8699THINGM BLINK(1) USB RGB LED DRIVER 8721THINGM BLINK(1) USB RGB LED DRIVER
8700M: Vivien Didelot <vivien.didelot@savoirfairelinux.com> 8722M: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
@@ -9728,7 +9750,6 @@ F: drivers/xen/*swiotlb*
9728XFS FILESYSTEM 9750XFS FILESYSTEM
9729P: Silicon Graphics Inc 9751P: Silicon Graphics Inc
9730M: Dave Chinner <david@fromorbit.com> 9752M: Dave Chinner <david@fromorbit.com>
9731M: Ben Myers <bpm@sgi.com>
9732M: xfs@oss.sgi.com 9753M: xfs@oss.sgi.com
9733L: xfs@oss.sgi.com 9754L: xfs@oss.sgi.com
9734W: http://oss.sgi.com/projects/xfs 9755W: http://oss.sgi.com/projects/xfs
@@ -9797,7 +9818,7 @@ ZR36067 VIDEO FOR LINUX DRIVER
9797L: mjpeg-users@lists.sourceforge.net 9818L: mjpeg-users@lists.sourceforge.net
9798L: linux-media@vger.kernel.org 9819L: linux-media@vger.kernel.org
9799W: http://mjpeg.sourceforge.net/driver-zoran/ 9820W: http://mjpeg.sourceforge.net/driver-zoran/
9800T: Mercurial http://linuxtv.org/hg/v4l-dvb 9821T: hg http://linuxtv.org/hg/v4l-dvb
9801S: Odd Fixes 9822S: Odd Fixes
9802F: drivers/media/pci/zoran/ 9823F: drivers/media/pci/zoran/
9803 9824
diff --git a/Makefile b/Makefile
index 893d6f0e875b..78209ee1f981 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
1VERSION = 3 1VERSION = 3
2PATCHLEVEL = 14 2PATCHLEVEL = 14
3SUBLEVEL = 0 3SUBLEVEL = 0
4EXTRAVERSION = -rc3 4EXTRAVERSION = -rc5
5NAME = Shuffling Zombie Juror 5NAME = Shuffling Zombie Juror
6 6
7# *DOCUMENTATION* 7# *DOCUMENTATION*
@@ -605,10 +605,11 @@ endif
605ifdef CONFIG_CC_STACKPROTECTOR_REGULAR 605ifdef CONFIG_CC_STACKPROTECTOR_REGULAR
606 stackp-flag := -fstack-protector 606 stackp-flag := -fstack-protector
607 ifeq ($(call cc-option, $(stackp-flag)),) 607 ifeq ($(call cc-option, $(stackp-flag)),)
608 $(warning Cannot use CONFIG_CC_STACKPROTECTOR: \ 608 $(warning Cannot use CONFIG_CC_STACKPROTECTOR_REGULAR: \
609 -fstack-protector not supported by compiler)) 609 -fstack-protector not supported by compiler)
610 endif 610 endif
611else ifdef CONFIG_CC_STACKPROTECTOR_STRONG 611else
612ifdef CONFIG_CC_STACKPROTECTOR_STRONG
612 stackp-flag := -fstack-protector-strong 613 stackp-flag := -fstack-protector-strong
613 ifeq ($(call cc-option, $(stackp-flag)),) 614 ifeq ($(call cc-option, $(stackp-flag)),)
614 $(warning Cannot use CONFIG_CC_STACKPROTECTOR_STRONG: \ 615 $(warning Cannot use CONFIG_CC_STACKPROTECTOR_STRONG: \
@@ -618,6 +619,7 @@ else
618 # Force off for distro compilers that enable stack protector by default. 619 # Force off for distro compilers that enable stack protector by default.
619 stackp-flag := $(call cc-option, -fno-stack-protector) 620 stackp-flag := $(call cc-option, -fno-stack-protector)
620endif 621endif
622endif
621KBUILD_CFLAGS += $(stackp-flag) 623KBUILD_CFLAGS += $(stackp-flag)
622 624
623# This warning generated too much noise in a regular build. 625# This warning generated too much noise in a regular build.
diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index 6d1e43d46187..032030361bef 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -209,7 +209,8 @@ dtb-$(CONFIG_ARCH_OMAP2PLUS) += omap2420-h4.dtb \
209 omap3-n900.dtb \ 209 omap3-n900.dtb \
210 omap3-n9.dtb \ 210 omap3-n9.dtb \
211 omap3-n950.dtb \ 211 omap3-n950.dtb \
212 omap3-tobi.dtb \ 212 omap3-overo-tobi.dtb \
213 omap3-overo-storm-tobi.dtb \
213 omap3-gta04.dtb \ 214 omap3-gta04.dtb \
214 omap3-igep0020.dtb \ 215 omap3-igep0020.dtb \
215 omap3-igep0030.dtb \ 216 omap3-igep0030.dtb \
diff --git a/arch/arm/boot/dts/am335x-evmsk.dts b/arch/arm/boot/dts/am335x-evmsk.dts
index 4718ec4a4dbf..486880b74831 100644
--- a/arch/arm/boot/dts/am335x-evmsk.dts
+++ b/arch/arm/boot/dts/am335x-evmsk.dts
@@ -121,7 +121,7 @@
121 ti,model = "AM335x-EVMSK"; 121 ti,model = "AM335x-EVMSK";
122 ti,audio-codec = <&tlv320aic3106>; 122 ti,audio-codec = <&tlv320aic3106>;
123 ti,mcasp-controller = <&mcasp1>; 123 ti,mcasp-controller = <&mcasp1>;
124 ti,codec-clock-rate = <24576000>; 124 ti,codec-clock-rate = <24000000>;
125 ti,audio-routing = 125 ti,audio-routing =
126 "Headphone Jack", "HPLOUT", 126 "Headphone Jack", "HPLOUT",
127 "Headphone Jack", "HPROUT"; 127 "Headphone Jack", "HPROUT";
@@ -256,6 +256,12 @@
256 >; 256 >;
257 }; 257 };
258 258
259 mmc1_pins: pinmux_mmc1_pins {
260 pinctrl-single,pins = <
261 0x160 (PIN_INPUT | MUX_MODE7) /* spi0_cs1.gpio0_6 */
262 >;
263 };
264
259 mcasp1_pins: mcasp1_pins { 265 mcasp1_pins: mcasp1_pins {
260 pinctrl-single,pins = < 266 pinctrl-single,pins = <
261 0x10c (PIN_INPUT_PULLDOWN | MUX_MODE4) /* mii1_crs.mcasp1_aclkx */ 267 0x10c (PIN_INPUT_PULLDOWN | MUX_MODE4) /* mii1_crs.mcasp1_aclkx */
@@ -456,6 +462,9 @@
456 status = "okay"; 462 status = "okay";
457 vmmc-supply = <&vmmc_reg>; 463 vmmc-supply = <&vmmc_reg>;
458 bus-width = <4>; 464 bus-width = <4>;
465 pinctrl-names = "default";
466 pinctrl-0 = <&mmc1_pins>;
467 cd-gpios = <&gpio0 6 GPIO_ACTIVE_HIGH>;
459}; 468};
460 469
461&sham { 470&sham {
diff --git a/arch/arm/boot/dts/armada-xp-mv78260.dtsi b/arch/arm/boot/dts/armada-xp-mv78260.dtsi
index 66609684d41b..9480cf891f8c 100644
--- a/arch/arm/boot/dts/armada-xp-mv78260.dtsi
+++ b/arch/arm/boot/dts/armada-xp-mv78260.dtsi
@@ -23,6 +23,7 @@
23 gpio0 = &gpio0; 23 gpio0 = &gpio0;
24 gpio1 = &gpio1; 24 gpio1 = &gpio1;
25 gpio2 = &gpio2; 25 gpio2 = &gpio2;
26 eth3 = &eth3;
26 }; 27 };
27 28
28 cpus { 29 cpus {
@@ -291,7 +292,7 @@
291 interrupts = <91>; 292 interrupts = <91>;
292 }; 293 };
293 294
294 ethernet@34000 { 295 eth3: ethernet@34000 {
295 compatible = "marvell,armada-370-neta"; 296 compatible = "marvell,armada-370-neta";
296 reg = <0x34000 0x4000>; 297 reg = <0x34000 0x4000>;
297 interrupts = <14>; 298 interrupts = <14>;
diff --git a/arch/arm/boot/dts/dove.dtsi b/arch/arm/boot/dts/dove.dtsi
index 2b76524f4aa7..187fd46b7b5e 100644
--- a/arch/arm/boot/dts/dove.dtsi
+++ b/arch/arm/boot/dts/dove.dtsi
@@ -379,15 +379,6 @@
379 #clock-cells = <1>; 379 #clock-cells = <1>;
380 }; 380 };
381 381
382 pmu_intc: pmu-interrupt-ctrl@d0050 {
383 compatible = "marvell,dove-pmu-intc";
384 interrupt-controller;
385 #interrupt-cells = <1>;
386 reg = <0xd0050 0x8>;
387 interrupts = <33>;
388 marvell,#interrupts = <7>;
389 };
390
391 pinctrl: pin-ctrl@d0200 { 382 pinctrl: pin-ctrl@d0200 {
392 compatible = "marvell,dove-pinctrl"; 383 compatible = "marvell,dove-pinctrl";
393 reg = <0xd0200 0x10>; 384 reg = <0xd0200 0x10>;
@@ -610,8 +601,6 @@
610 rtc: real-time-clock@d8500 { 601 rtc: real-time-clock@d8500 {
611 compatible = "marvell,orion-rtc"; 602 compatible = "marvell,orion-rtc";
612 reg = <0xd8500 0x20>; 603 reg = <0xd8500 0x20>;
613 interrupt-parent = <&pmu_intc>;
614 interrupts = <5>;
615 }; 604 };
616 605
617 gpio2: gpio-ctrl@e8400 { 606 gpio2: gpio-ctrl@e8400 {
diff --git a/arch/arm/boot/dts/keystone-clocks.dtsi b/arch/arm/boot/dts/keystone-clocks.dtsi
index 2363593e1050..ef58d1c24313 100644
--- a/arch/arm/boot/dts/keystone-clocks.dtsi
+++ b/arch/arm/boot/dts/keystone-clocks.dtsi
@@ -612,7 +612,7 @@ clocks {
612 compatible = "ti,keystone,psc-clock"; 612 compatible = "ti,keystone,psc-clock";
613 clocks = <&chipclk13>; 613 clocks = <&chipclk13>;
614 clock-output-names = "vcp-3"; 614 clock-output-names = "vcp-3";
615 reg = <0x0235000a8 0xb00>, <0x02350060 0x400>; 615 reg = <0x023500a8 0xb00>, <0x02350060 0x400>;
616 reg-names = "control", "domain"; 616 reg-names = "control", "domain";
617 domain-id = <24>; 617 domain-id = <24>;
618 }; 618 };
diff --git a/arch/arm/boot/dts/omap3-gta04.dts b/arch/arm/boot/dts/omap3-gta04.dts
index b9b55c95a566..c551e4af4d83 100644
--- a/arch/arm/boot/dts/omap3-gta04.dts
+++ b/arch/arm/boot/dts/omap3-gta04.dts
@@ -32,7 +32,7 @@
32 aux-button { 32 aux-button {
33 label = "aux"; 33 label = "aux";
34 linux,code = <169>; 34 linux,code = <169>;
35 gpios = <&gpio1 7 GPIO_ACTIVE_LOW>; 35 gpios = <&gpio1 7 GPIO_ACTIVE_HIGH>;
36 gpio-key,wakeup; 36 gpio-key,wakeup;
37 }; 37 };
38 }; 38 };
@@ -92,6 +92,8 @@
92 bmp085@77 { 92 bmp085@77 {
93 compatible = "bosch,bmp085"; 93 compatible = "bosch,bmp085";
94 reg = <0x77>; 94 reg = <0x77>;
95 interrupt-parent = <&gpio4>;
96 interrupts = <17 IRQ_TYPE_EDGE_RISING>;
95 }; 97 };
96 98
97 /* leds */ 99 /* leds */
@@ -141,8 +143,8 @@
141 pinctrl-names = "default"; 143 pinctrl-names = "default";
142 pinctrl-0 = <&mmc1_pins>; 144 pinctrl-0 = <&mmc1_pins>;
143 vmmc-supply = <&vmmc1>; 145 vmmc-supply = <&vmmc1>;
144 vmmc_aux-supply = <&vsim>;
145 bus-width = <4>; 146 bus-width = <4>;
147 ti,non-removable;
146}; 148};
147 149
148&mmc2 { 150&mmc2 {
diff --git a/arch/arm/boot/dts/omap3-n9.dts b/arch/arm/boot/dts/omap3-n9.dts
index 39828ce464ee..9938b5dc1909 100644
--- a/arch/arm/boot/dts/omap3-n9.dts
+++ b/arch/arm/boot/dts/omap3-n9.dts
@@ -14,5 +14,5 @@
14 14
15/ { 15/ {
16 model = "Nokia N9"; 16 model = "Nokia N9";
17 compatible = "nokia,omap3-n9", "ti,omap3"; 17 compatible = "nokia,omap3-n9", "ti,omap36xx", "ti,omap3";
18}; 18};
diff --git a/arch/arm/boot/dts/omap3-n900.dts b/arch/arm/boot/dts/omap3-n900.dts
index 6fc85f963530..0bf40c90faba 100644
--- a/arch/arm/boot/dts/omap3-n900.dts
+++ b/arch/arm/boot/dts/omap3-n900.dts
@@ -1,6 +1,6 @@
1/* 1/*
2 * Copyright (C) 2013 Pavel Machek <pavel@ucw.cz> 2 * Copyright (C) 2013 Pavel Machek <pavel@ucw.cz>
3 * Copyright 2013 Aaro Koskinen <aaro.koskinen@iki.fi> 3 * Copyright (C) 2013-2014 Aaro Koskinen <aaro.koskinen@iki.fi>
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 (or later) as 6 * it under the terms of the GNU General Public License version 2 (or later) as
@@ -13,7 +13,7 @@
13 13
14/ { 14/ {
15 model = "Nokia N900"; 15 model = "Nokia N900";
16 compatible = "nokia,omap3-n900", "ti,omap3"; 16 compatible = "nokia,omap3-n900", "ti,omap3430", "ti,omap3";
17 17
18 cpus { 18 cpus {
19 cpu@0 { 19 cpu@0 {
diff --git a/arch/arm/boot/dts/omap3-n950.dts b/arch/arm/boot/dts/omap3-n950.dts
index b076a526b999..261c5589bfa3 100644
--- a/arch/arm/boot/dts/omap3-n950.dts
+++ b/arch/arm/boot/dts/omap3-n950.dts
@@ -14,5 +14,5 @@
14 14
15/ { 15/ {
16 model = "Nokia N950"; 16 model = "Nokia N950";
17 compatible = "nokia,omap3-n950", "ti,omap3"; 17 compatible = "nokia,omap3-n950", "ti,omap36xx", "ti,omap3";
18}; 18};
diff --git a/arch/arm/boot/dts/omap3-overo-storm-tobi.dts b/arch/arm/boot/dts/omap3-overo-storm-tobi.dts
new file mode 100644
index 000000000000..966b5c9cd96a
--- /dev/null
+++ b/arch/arm/boot/dts/omap3-overo-storm-tobi.dts
@@ -0,0 +1,22 @@
1/*
2 * Copyright (C) 2012 Florian Vaussard, EPFL Mobots group
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
8
9/*
10 * Tobi expansion board is manufactured by Gumstix Inc.
11 */
12
13/dts-v1/;
14
15#include "omap36xx.dtsi"
16#include "omap3-overo-tobi-common.dtsi"
17
18/ {
19 model = "OMAP36xx/AM37xx/DM37xx Gumstix Overo on Tobi";
20 compatible = "gumstix,omap3-overo-tobi", "gumstix,omap3-overo", "ti,omap36xx", "ti,omap3";
21};
22
diff --git a/arch/arm/boot/dts/omap3-tobi.dts b/arch/arm/boot/dts/omap3-overo-tobi-common.dtsi
index 7e4ad2aec37a..4edc013a91c1 100644
--- a/arch/arm/boot/dts/omap3-tobi.dts
+++ b/arch/arm/boot/dts/omap3-overo-tobi-common.dtsi
@@ -13,9 +13,6 @@
13#include "omap3-overo.dtsi" 13#include "omap3-overo.dtsi"
14 14
15/ { 15/ {
16 model = "TI OMAP3 Gumstix Overo on Tobi";
17 compatible = "ti,omap3-tobi", "ti,omap3-overo", "ti,omap3";
18
19 leds { 16 leds {
20 compatible = "gpio-leds"; 17 compatible = "gpio-leds";
21 heartbeat { 18 heartbeat {
diff --git a/arch/arm/boot/dts/omap3-overo-tobi.dts b/arch/arm/boot/dts/omap3-overo-tobi.dts
new file mode 100644
index 000000000000..de5653e1b5ca
--- /dev/null
+++ b/arch/arm/boot/dts/omap3-overo-tobi.dts
@@ -0,0 +1,22 @@
1/*
2 * Copyright (C) 2012 Florian Vaussard, EPFL Mobots group
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
8
9/*
10 * Tobi expansion board is manufactured by Gumstix Inc.
11 */
12
13/dts-v1/;
14
15#include "omap34xx.dtsi"
16#include "omap3-overo-tobi-common.dtsi"
17
18/ {
19 model = "OMAP35xx Gumstix Overo on Tobi";
20 compatible = "gumstix,omap3-overo-tobi", "gumstix,omap3-overo", "ti,omap3430", "ti,omap3";
21};
22
diff --git a/arch/arm/boot/dts/omap3-overo.dtsi b/arch/arm/boot/dts/omap3-overo.dtsi
index a461d2fd1fb0..597099907f8e 100644
--- a/arch/arm/boot/dts/omap3-overo.dtsi
+++ b/arch/arm/boot/dts/omap3-overo.dtsi
@@ -9,9 +9,6 @@
9/* 9/*
10 * The Gumstix Overo must be combined with an expansion board. 10 * The Gumstix Overo must be combined with an expansion board.
11 */ 11 */
12/dts-v1/;
13
14#include "omap34xx.dtsi"
15 12
16/ { 13/ {
17 pwmleds { 14 pwmleds {
diff --git a/arch/arm/boot/dts/tegra114.dtsi b/arch/arm/boot/dts/tegra114.dtsi
index 389e987ec281..44ec401ec366 100644
--- a/arch/arm/boot/dts/tegra114.dtsi
+++ b/arch/arm/boot/dts/tegra114.dtsi
@@ -57,6 +57,8 @@
57 resets = <&tegra_car 27>; 57 resets = <&tegra_car 27>;
58 reset-names = "dc"; 58 reset-names = "dc";
59 59
60 nvidia,head = <0>;
61
60 rgb { 62 rgb {
61 status = "disabled"; 63 status = "disabled";
62 }; 64 };
@@ -72,6 +74,8 @@
72 resets = <&tegra_car 26>; 74 resets = <&tegra_car 26>;
73 reset-names = "dc"; 75 reset-names = "dc";
74 76
77 nvidia,head = <1>;
78
75 rgb { 79 rgb {
76 status = "disabled"; 80 status = "disabled";
77 }; 81 };
diff --git a/arch/arm/boot/dts/tegra20.dtsi b/arch/arm/boot/dts/tegra20.dtsi
index 480ecda3416b..48d2a7f4d0c0 100644
--- a/arch/arm/boot/dts/tegra20.dtsi
+++ b/arch/arm/boot/dts/tegra20.dtsi
@@ -94,6 +94,8 @@
94 resets = <&tegra_car 27>; 94 resets = <&tegra_car 27>;
95 reset-names = "dc"; 95 reset-names = "dc";
96 96
97 nvidia,head = <0>;
98
97 rgb { 99 rgb {
98 status = "disabled"; 100 status = "disabled";
99 }; 101 };
@@ -109,6 +111,8 @@
109 resets = <&tegra_car 26>; 111 resets = <&tegra_car 26>;
110 reset-names = "dc"; 112 reset-names = "dc";
111 113
114 nvidia,head = <1>;
115
112 rgb { 116 rgb {
113 status = "disabled"; 117 status = "disabled";
114 }; 118 };
diff --git a/arch/arm/boot/dts/tegra30-cardhu.dtsi b/arch/arm/boot/dts/tegra30-cardhu.dtsi
index 9104224124ee..1e156d9d0506 100644
--- a/arch/arm/boot/dts/tegra30-cardhu.dtsi
+++ b/arch/arm/boot/dts/tegra30-cardhu.dtsi
@@ -28,7 +28,7 @@
28 compatible = "nvidia,cardhu", "nvidia,tegra30"; 28 compatible = "nvidia,cardhu", "nvidia,tegra30";
29 29
30 aliases { 30 aliases {
31 rtc0 = "/i2c@7000d000/tps6586x@34"; 31 rtc0 = "/i2c@7000d000/tps65911@2d";
32 rtc1 = "/rtc@7000e000"; 32 rtc1 = "/rtc@7000e000";
33 }; 33 };
34 34
diff --git a/arch/arm/boot/dts/tegra30.dtsi b/arch/arm/boot/dts/tegra30.dtsi
index ed8e7700b46d..19a84e933f4e 100644
--- a/arch/arm/boot/dts/tegra30.dtsi
+++ b/arch/arm/boot/dts/tegra30.dtsi
@@ -170,6 +170,8 @@
170 resets = <&tegra_car 27>; 170 resets = <&tegra_car 27>;
171 reset-names = "dc"; 171 reset-names = "dc";
172 172
173 nvidia,head = <0>;
174
173 rgb { 175 rgb {
174 status = "disabled"; 176 status = "disabled";
175 }; 177 };
@@ -185,6 +187,8 @@
185 resets = <&tegra_car 26>; 187 resets = <&tegra_car 26>;
186 reset-names = "dc"; 188 reset-names = "dc";
187 189
190 nvidia,head = <1>;
191
188 rgb { 192 rgb {
189 status = "disabled"; 193 status = "disabled";
190 }; 194 };
diff --git a/arch/arm/boot/dts/testcases/tests.dtsi b/arch/arm/boot/dts/testcases/tests.dtsi
deleted file mode 100644
index 3f123ecc9dd7..000000000000
--- a/arch/arm/boot/dts/testcases/tests.dtsi
+++ /dev/null
@@ -1,2 +0,0 @@
1/include/ "tests-phandle.dtsi"
2/include/ "tests-interrupts.dtsi"
diff --git a/arch/arm/boot/dts/versatile-pb.dts b/arch/arm/boot/dts/versatile-pb.dts
index f43907c40c93..65f657711323 100644
--- a/arch/arm/boot/dts/versatile-pb.dts
+++ b/arch/arm/boot/dts/versatile-pb.dts
@@ -1,4 +1,4 @@
1/include/ "versatile-ab.dts" 1#include <versatile-ab.dts>
2 2
3/ { 3/ {
4 model = "ARM Versatile PB"; 4 model = "ARM Versatile PB";
@@ -47,4 +47,4 @@
47 }; 47 };
48}; 48};
49 49
50/include/ "testcases/tests.dtsi" 50#include <testcases.dtsi>
diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
index 1d8248ea5669..bd18bb8b2770 100644
--- a/arch/arm/kvm/arm.c
+++ b/arch/arm/kvm/arm.c
@@ -878,7 +878,8 @@ static int hyp_init_cpu_pm_notifier(struct notifier_block *self,
878 unsigned long cmd, 878 unsigned long cmd,
879 void *v) 879 void *v)
880{ 880{
881 if (cmd == CPU_PM_EXIT) { 881 if (cmd == CPU_PM_EXIT &&
882 __hyp_get_vectors() == hyp_default_vectors) {
882 cpu_init_hyp_mode(NULL); 883 cpu_init_hyp_mode(NULL);
883 return NOTIFY_OK; 884 return NOTIFY_OK;
884 } 885 }
diff --git a/arch/arm/kvm/interrupts.S b/arch/arm/kvm/interrupts.S
index ddc15539bad2..0d68d4073068 100644
--- a/arch/arm/kvm/interrupts.S
+++ b/arch/arm/kvm/interrupts.S
@@ -220,6 +220,10 @@ after_vfp_restore:
220 * in Hyp mode (see init_hyp_mode in arch/arm/kvm/arm.c). Return values are 220 * in Hyp mode (see init_hyp_mode in arch/arm/kvm/arm.c). Return values are
221 * passed in r0 and r1. 221 * passed in r0 and r1.
222 * 222 *
223 * A function pointer with a value of 0xffffffff has a special meaning,
224 * and is used to implement __hyp_get_vectors in the same way as in
225 * arch/arm/kernel/hyp_stub.S.
226 *
223 * The calling convention follows the standard AAPCS: 227 * The calling convention follows the standard AAPCS:
224 * r0 - r3: caller save 228 * r0 - r3: caller save
225 * r12: caller save 229 * r12: caller save
@@ -363,6 +367,11 @@ hyp_hvc:
363host_switch_to_hyp: 367host_switch_to_hyp:
364 pop {r0, r1, r2} 368 pop {r0, r1, r2}
365 369
370 /* Check for __hyp_get_vectors */
371 cmp r0, #-1
372 mrceq p15, 4, r0, c12, c0, 0 @ get HVBAR
373 beq 1f
374
366 push {lr} 375 push {lr}
367 mrs lr, SPSR 376 mrs lr, SPSR
368 push {lr} 377 push {lr}
@@ -378,7 +387,7 @@ THUMB( orr lr, #1)
378 pop {lr} 387 pop {lr}
379 msr SPSR_csxf, lr 388 msr SPSR_csxf, lr
380 pop {lr} 389 pop {lr}
381 eret 3901: eret
382 391
383guest_trap: 392guest_trap:
384 load_vcpu @ Load VCPU pointer to r0 393 load_vcpu @ Load VCPU pointer to r0
diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile
index befcaf5d0574..ec419649320f 100644
--- a/arch/arm/mach-imx/Makefile
+++ b/arch/arm/mach-imx/Makefile
@@ -101,11 +101,9 @@ obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o
101obj-$(CONFIG_SOC_IMX6Q) += clk-imx6q.o mach-imx6q.o 101obj-$(CONFIG_SOC_IMX6Q) += clk-imx6q.o mach-imx6q.o
102obj-$(CONFIG_SOC_IMX6SL) += clk-imx6sl.o mach-imx6sl.o 102obj-$(CONFIG_SOC_IMX6SL) += clk-imx6sl.o mach-imx6sl.o
103 103
104ifeq ($(CONFIG_PM),y)
105obj-$(CONFIG_SOC_IMX6Q) += pm-imx6q.o headsmp.o 104obj-$(CONFIG_SOC_IMX6Q) += pm-imx6q.o headsmp.o
106# i.MX6SL reuses i.MX6Q code 105# i.MX6SL reuses i.MX6Q code
107obj-$(CONFIG_SOC_IMX6SL) += pm-imx6q.o headsmp.o 106obj-$(CONFIG_SOC_IMX6SL) += pm-imx6q.o headsmp.o
108endif
109 107
110# i.MX5 based machines 108# i.MX5 based machines
111obj-$(CONFIG_MACH_MX51_BABBAGE) += mach-mx51_babbage.o 109obj-$(CONFIG_MACH_MX51_BABBAGE) += mach-mx51_babbage.o
diff --git a/arch/arm/mach-imx/common.h b/arch/arm/mach-imx/common.h
index 59c3b9b26bb4..baf439dc22d8 100644
--- a/arch/arm/mach-imx/common.h
+++ b/arch/arm/mach-imx/common.h
@@ -144,13 +144,11 @@ void imx6q_set_chicken_bit(void);
144void imx_cpu_die(unsigned int cpu); 144void imx_cpu_die(unsigned int cpu);
145int imx_cpu_kill(unsigned int cpu); 145int imx_cpu_kill(unsigned int cpu);
146 146
147#ifdef CONFIG_PM
148void imx6q_pm_init(void); 147void imx6q_pm_init(void);
149void imx6q_pm_set_ccm_base(void __iomem *base); 148void imx6q_pm_set_ccm_base(void __iomem *base);
149#ifdef CONFIG_PM
150void imx5_pm_init(void); 150void imx5_pm_init(void);
151#else 151#else
152static inline void imx6q_pm_init(void) {}
153static inline void imx6q_pm_set_ccm_base(void __iomem *base) {}
154static inline void imx5_pm_init(void) {} 152static inline void imx5_pm_init(void) {}
155#endif 153#endif
156 154
diff --git a/arch/arm/mach-omap1/board-nokia770.c b/arch/arm/mach-omap1/board-nokia770.c
index 91449c5cb70f..85089d821982 100644
--- a/arch/arm/mach-omap1/board-nokia770.c
+++ b/arch/arm/mach-omap1/board-nokia770.c
@@ -156,6 +156,7 @@ static struct omap_usb_config nokia770_usb_config __initdata = {
156 .register_dev = 1, 156 .register_dev = 1,
157 .hmc_mode = 16, 157 .hmc_mode = 16,
158 .pins[0] = 6, 158 .pins[0] = 6,
159 .extcon = "tahvo-usb",
159}; 160};
160 161
161#if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE) 162#if defined(CONFIG_MMC_OMAP) || defined(CONFIG_MMC_OMAP_MODULE)
diff --git a/arch/arm/mach-omap2/Kconfig b/arch/arm/mach-omap2/Kconfig
index e2ce4f8366a7..0af7ca02314d 100644
--- a/arch/arm/mach-omap2/Kconfig
+++ b/arch/arm/mach-omap2/Kconfig
@@ -50,6 +50,7 @@ config SOC_OMAP5
50 bool "TI OMAP5" 50 bool "TI OMAP5"
51 depends on ARCH_MULTI_V7 51 depends on ARCH_MULTI_V7
52 select ARCH_OMAP2PLUS 52 select ARCH_OMAP2PLUS
53 select ARCH_HAS_OPP
53 select ARM_CPU_SUSPEND if PM 54 select ARM_CPU_SUSPEND if PM
54 select ARM_GIC 55 select ARM_GIC
55 select CPU_V7 56 select CPU_V7
@@ -63,6 +64,7 @@ config SOC_AM33XX
63 bool "TI AM33XX" 64 bool "TI AM33XX"
64 depends on ARCH_MULTI_V7 65 depends on ARCH_MULTI_V7
65 select ARCH_OMAP2PLUS 66 select ARCH_OMAP2PLUS
67 select ARCH_HAS_OPP
66 select ARM_CPU_SUSPEND if PM 68 select ARM_CPU_SUSPEND if PM
67 select CPU_V7 69 select CPU_V7
68 select MULTI_IRQ_HANDLER 70 select MULTI_IRQ_HANDLER
@@ -72,6 +74,7 @@ config SOC_AM43XX
72 depends on ARCH_MULTI_V7 74 depends on ARCH_MULTI_V7
73 select CPU_V7 75 select CPU_V7
74 select ARCH_OMAP2PLUS 76 select ARCH_OMAP2PLUS
77 select ARCH_HAS_OPP
75 select MULTI_IRQ_HANDLER 78 select MULTI_IRQ_HANDLER
76 select ARM_GIC 79 select ARM_GIC
77 select MACH_OMAP_GENERIC 80 select MACH_OMAP_GENERIC
@@ -80,6 +83,7 @@ config SOC_DRA7XX
80 bool "TI DRA7XX" 83 bool "TI DRA7XX"
81 depends on ARCH_MULTI_V7 84 depends on ARCH_MULTI_V7
82 select ARCH_OMAP2PLUS 85 select ARCH_OMAP2PLUS
86 select ARCH_HAS_OPP
83 select ARM_CPU_SUSPEND if PM 87 select ARM_CPU_SUSPEND if PM
84 select ARM_GIC 88 select ARM_GIC
85 select CPU_V7 89 select CPU_V7
@@ -268,9 +272,6 @@ config MACH_OMAP_3430SDP
268 default y 272 default y
269 select OMAP_PACKAGE_CBB 273 select OMAP_PACKAGE_CBB
270 274
271config MACH_NOKIA_N800
272 bool
273
274config MACH_NOKIA_N810 275config MACH_NOKIA_N810
275 bool 276 bool
276 277
@@ -281,7 +282,6 @@ config MACH_NOKIA_N8X0
281 bool "Nokia N800/N810" 282 bool "Nokia N800/N810"
282 depends on SOC_OMAP2420 283 depends on SOC_OMAP2420
283 default y 284 default y
284 select MACH_NOKIA_N800
285 select MACH_NOKIA_N810 285 select MACH_NOKIA_N810
286 select MACH_NOKIA_N810_WIMAX 286 select MACH_NOKIA_N810_WIMAX
287 select OMAP_PACKAGE_ZAC 287 select OMAP_PACKAGE_ZAC
diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
index d24926e6340f..ab43755364f5 100644
--- a/arch/arm/mach-omap2/gpmc.c
+++ b/arch/arm/mach-omap2/gpmc.c
@@ -1339,7 +1339,7 @@ static void __maybe_unused gpmc_read_timings_dt(struct device_node *np,
1339 of_property_read_bool(np, "gpmc,time-para-granularity"); 1339 of_property_read_bool(np, "gpmc,time-para-granularity");
1340} 1340}
1341 1341
1342#ifdef CONFIG_MTD_NAND 1342#if IS_ENABLED(CONFIG_MTD_NAND)
1343 1343
1344static const char * const nand_xfer_types[] = { 1344static const char * const nand_xfer_types[] = {
1345 [NAND_OMAP_PREFETCH_POLLED] = "prefetch-polled", 1345 [NAND_OMAP_PREFETCH_POLLED] = "prefetch-polled",
@@ -1429,7 +1429,7 @@ static int gpmc_probe_nand_child(struct platform_device *pdev,
1429} 1429}
1430#endif 1430#endif
1431 1431
1432#ifdef CONFIG_MTD_ONENAND 1432#if IS_ENABLED(CONFIG_MTD_ONENAND)
1433static int gpmc_probe_onenand_child(struct platform_device *pdev, 1433static int gpmc_probe_onenand_child(struct platform_device *pdev,
1434 struct device_node *child) 1434 struct device_node *child)
1435{ 1435{
diff --git a/arch/arm/mach-omap2/io.c b/arch/arm/mach-omap2/io.c
index d408b15b4fbf..af432b191255 100644
--- a/arch/arm/mach-omap2/io.c
+++ b/arch/arm/mach-omap2/io.c
@@ -179,15 +179,6 @@ static struct map_desc omap34xx_io_desc[] __initdata = {
179 .length = L4_EMU_34XX_SIZE, 179 .length = L4_EMU_34XX_SIZE,
180 .type = MT_DEVICE 180 .type = MT_DEVICE
181 }, 181 },
182#if defined(CONFIG_DEBUG_LL) && \
183 (defined(CONFIG_MACH_OMAP_ZOOM2) || defined(CONFIG_MACH_OMAP_ZOOM3))
184 {
185 .virtual = ZOOM_UART_VIRT,
186 .pfn = __phys_to_pfn(ZOOM_UART_BASE),
187 .length = SZ_1M,
188 .type = MT_DEVICE
189 },
190#endif
191}; 182};
192#endif 183#endif
193 184
diff --git a/arch/arm/mach-pxa/mioa701.c b/arch/arm/mach-pxa/mioa701.c
index f70583fee59f..29997bde277d 100644
--- a/arch/arm/mach-pxa/mioa701.c
+++ b/arch/arm/mach-pxa/mioa701.c
@@ -38,6 +38,7 @@
38#include <linux/mtd/physmap.h> 38#include <linux/mtd/physmap.h>
39#include <linux/usb/gpio_vbus.h> 39#include <linux/usb/gpio_vbus.h>
40#include <linux/reboot.h> 40#include <linux/reboot.h>
41#include <linux/regulator/fixed.h>
41#include <linux/regulator/max1586.h> 42#include <linux/regulator/max1586.h>
42#include <linux/slab.h> 43#include <linux/slab.h>
43#include <linux/i2c/pxa-i2c.h> 44#include <linux/i2c/pxa-i2c.h>
@@ -714,6 +715,10 @@ static struct gpio global_gpios[] = {
714 { GPIO56_MT9M111_nOE, GPIOF_OUT_INIT_LOW, "Camera nOE" }, 715 { GPIO56_MT9M111_nOE, GPIOF_OUT_INIT_LOW, "Camera nOE" },
715}; 716};
716 717
718static struct regulator_consumer_supply fixed_5v0_consumers[] = {
719 REGULATOR_SUPPLY("power", "pwm-backlight"),
720};
721
717static void __init mioa701_machine_init(void) 722static void __init mioa701_machine_init(void)
718{ 723{
719 int rc; 724 int rc;
@@ -753,6 +758,10 @@ static void __init mioa701_machine_init(void)
753 pxa_set_i2c_info(&i2c_pdata); 758 pxa_set_i2c_info(&i2c_pdata);
754 pxa27x_set_i2c_power_info(NULL); 759 pxa27x_set_i2c_power_info(NULL);
755 pxa_set_camera_info(&mioa701_pxacamera_platform_data); 760 pxa_set_camera_info(&mioa701_pxacamera_platform_data);
761
762 regulator_register_always_on(0, "fixed-5.0V", fixed_5v0_consumers,
763 ARRAY_SIZE(fixed_5v0_consumers),
764 5000000);
756} 765}
757 766
758static void mioa701_machine_exit(void) 767static void mioa701_machine_exit(void)
diff --git a/arch/arm/mach-tegra/pm.c b/arch/arm/mach-tegra/pm.c
index 4ae0286b468d..f55b05a29b55 100644
--- a/arch/arm/mach-tegra/pm.c
+++ b/arch/arm/mach-tegra/pm.c
@@ -24,6 +24,7 @@
24#include <linux/cpu_pm.h> 24#include <linux/cpu_pm.h>
25#include <linux/suspend.h> 25#include <linux/suspend.h>
26#include <linux/err.h> 26#include <linux/err.h>
27#include <linux/slab.h>
27#include <linux/clk/tegra.h> 28#include <linux/clk/tegra.h>
28 29
29#include <asm/smp_plat.h> 30#include <asm/smp_plat.h>
diff --git a/arch/arm/mach-tegra/tegra.c b/arch/arm/mach-tegra/tegra.c
index 303a285d80fd..6191603379e1 100644
--- a/arch/arm/mach-tegra/tegra.c
+++ b/arch/arm/mach-tegra/tegra.c
@@ -73,10 +73,20 @@ u32 tegra_uart_config[3] = {
73static void __init tegra_init_cache(void) 73static void __init tegra_init_cache(void)
74{ 74{
75#ifdef CONFIG_CACHE_L2X0 75#ifdef CONFIG_CACHE_L2X0
76 static const struct of_device_id pl310_ids[] __initconst = {
77 { .compatible = "arm,pl310-cache", },
78 {}
79 };
80
81 struct device_node *np;
76 int ret; 82 int ret;
77 void __iomem *p = IO_ADDRESS(TEGRA_ARM_PERIF_BASE) + 0x3000; 83 void __iomem *p = IO_ADDRESS(TEGRA_ARM_PERIF_BASE) + 0x3000;
78 u32 aux_ctrl, cache_type; 84 u32 aux_ctrl, cache_type;
79 85
86 np = of_find_matching_node(NULL, pl310_ids);
87 if (!np)
88 return;
89
80 cache_type = readl(p + L2X0_CACHE_TYPE); 90 cache_type = readl(p + L2X0_CACHE_TYPE);
81 aux_ctrl = (cache_type & 0x700) << (17-8); 91 aux_ctrl = (cache_type & 0x700) << (17-8);
82 aux_ctrl |= 0x7C400001; 92 aux_ctrl |= 0x7C400001;
diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
index 1a77450e728a..11b3914660d2 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -1358,7 +1358,7 @@ static void *arm_iommu_alloc_attrs(struct device *dev, size_t size,
1358 *handle = DMA_ERROR_CODE; 1358 *handle = DMA_ERROR_CODE;
1359 size = PAGE_ALIGN(size); 1359 size = PAGE_ALIGN(size);
1360 1360
1361 if (gfp & GFP_ATOMIC) 1361 if (!(gfp & __GFP_WAIT))
1362 return __iommu_alloc_atomic(dev, size, handle); 1362 return __iommu_alloc_atomic(dev, size, handle);
1363 1363
1364 /* 1364 /*
diff --git a/arch/arm64/include/asm/percpu.h b/arch/arm64/include/asm/percpu.h
index 13fb0b3efc5f..453a179469a3 100644
--- a/arch/arm64/include/asm/percpu.h
+++ b/arch/arm64/include/asm/percpu.h
@@ -16,6 +16,8 @@
16#ifndef __ASM_PERCPU_H 16#ifndef __ASM_PERCPU_H
17#define __ASM_PERCPU_H 17#define __ASM_PERCPU_H
18 18
19#ifdef CONFIG_SMP
20
19static inline void set_my_cpu_offset(unsigned long off) 21static inline void set_my_cpu_offset(unsigned long off)
20{ 22{
21 asm volatile("msr tpidr_el1, %0" :: "r" (off) : "memory"); 23 asm volatile("msr tpidr_el1, %0" :: "r" (off) : "memory");
@@ -36,6 +38,12 @@ static inline unsigned long __my_cpu_offset(void)
36} 38}
37#define __my_cpu_offset __my_cpu_offset() 39#define __my_cpu_offset __my_cpu_offset()
38 40
41#else /* !CONFIG_SMP */
42
43#define set_my_cpu_offset(x) do { } while (0)
44
45#endif /* CONFIG_SMP */
46
39#include <asm-generic/percpu.h> 47#include <asm-generic/percpu.h>
40 48
41#endif /* __ASM_PERCPU_H */ 49#endif /* __ASM_PERCPU_H */
diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
index b524dcd17243..aa3917c8b623 100644
--- a/arch/arm64/include/asm/pgtable.h
+++ b/arch/arm64/include/asm/pgtable.h
@@ -136,11 +136,11 @@ extern struct page *empty_zero_page;
136/* 136/*
137 * The following only work if pte_present(). Undefined behaviour otherwise. 137 * The following only work if pte_present(). Undefined behaviour otherwise.
138 */ 138 */
139#define pte_present(pte) (pte_val(pte) & (PTE_VALID | PTE_PROT_NONE)) 139#define pte_present(pte) (!!(pte_val(pte) & (PTE_VALID | PTE_PROT_NONE)))
140#define pte_dirty(pte) (pte_val(pte) & PTE_DIRTY) 140#define pte_dirty(pte) (!!(pte_val(pte) & PTE_DIRTY))
141#define pte_young(pte) (pte_val(pte) & PTE_AF) 141#define pte_young(pte) (!!(pte_val(pte) & PTE_AF))
142#define pte_special(pte) (pte_val(pte) & PTE_SPECIAL) 142#define pte_special(pte) (!!(pte_val(pte) & PTE_SPECIAL))
143#define pte_write(pte) (pte_val(pte) & PTE_WRITE) 143#define pte_write(pte) (!!(pte_val(pte) & PTE_WRITE))
144#define pte_exec(pte) (!(pte_val(pte) & PTE_UXN)) 144#define pte_exec(pte) (!(pte_val(pte) & PTE_UXN))
145 145
146#define pte_valid_user(pte) \ 146#define pte_valid_user(pte) \
diff --git a/arch/arm64/kernel/stacktrace.c b/arch/arm64/kernel/stacktrace.c
index c3b6c63ea5fb..38f0558f0c0a 100644
--- a/arch/arm64/kernel/stacktrace.c
+++ b/arch/arm64/kernel/stacktrace.c
@@ -48,7 +48,11 @@ int unwind_frame(struct stackframe *frame)
48 48
49 frame->sp = fp + 0x10; 49 frame->sp = fp + 0x10;
50 frame->fp = *(unsigned long *)(fp); 50 frame->fp = *(unsigned long *)(fp);
51 frame->pc = *(unsigned long *)(fp + 8); 51 /*
52 * -4 here because we care about the PC at time of bl,
53 * not where the return will go.
54 */
55 frame->pc = *(unsigned long *)(fp + 8) - 4;
52 56
53 return 0; 57 return 0;
54} 58}
diff --git a/arch/arm64/kvm/hyp.S b/arch/arm64/kvm/hyp.S
index 3b47c36e10ff..2c56012cb2d2 100644
--- a/arch/arm64/kvm/hyp.S
+++ b/arch/arm64/kvm/hyp.S
@@ -694,6 +694,24 @@ __hyp_panic_str:
694 694
695 .align 2 695 .align 2
696 696
697/*
698 * u64 kvm_call_hyp(void *hypfn, ...);
699 *
700 * This is not really a variadic function in the classic C-way and care must
701 * be taken when calling this to ensure parameters are passed in registers
702 * only, since the stack will change between the caller and the callee.
703 *
704 * Call the function with the first argument containing a pointer to the
705 * function you wish to call in Hyp mode, and subsequent arguments will be
706 * passed as x0, x1, and x2 (a maximum of 3 arguments in addition to the
707 * function pointer can be passed). The function being called must be mapped
708 * in Hyp mode (see init_hyp_mode in arch/arm/kvm/arm.c). Return values are
709 * passed in r0 and r1.
710 *
711 * A function pointer with a value of 0 has a special meaning, and is
712 * used to implement __hyp_get_vectors in the same way as in
713 * arch/arm64/kernel/hyp_stub.S.
714 */
697ENTRY(kvm_call_hyp) 715ENTRY(kvm_call_hyp)
698 hvc #0 716 hvc #0
699 ret 717 ret
@@ -737,7 +755,12 @@ el1_sync: // Guest trapped into EL2
737 pop x2, x3 755 pop x2, x3
738 pop x0, x1 756 pop x0, x1
739 757
740 push lr, xzr 758 /* Check for __hyp_get_vectors */
759 cbnz x0, 1f
760 mrs x0, vbar_el2
761 b 2f
762
7631: push lr, xzr
741 764
742 /* 765 /*
743 * Compute the function address in EL2, and shuffle the parameters. 766 * Compute the function address in EL2, and shuffle the parameters.
@@ -750,7 +773,7 @@ el1_sync: // Guest trapped into EL2
750 blr lr 773 blr lr
751 774
752 pop lr, xzr 775 pop lr, xzr
753 eret 7762: eret
754 777
755el1_trap: 778el1_trap:
756 /* 779 /*
diff --git a/arch/m68k/include/asm/Kbuild b/arch/m68k/include/asm/Kbuild
index 7cc8c364924d..6fb9e813a910 100644
--- a/arch/m68k/include/asm/Kbuild
+++ b/arch/m68k/include/asm/Kbuild
@@ -1,4 +1,4 @@
1 1generic-y += barrier.h
2generic-y += bitsperlong.h 2generic-y += bitsperlong.h
3generic-y += clkdev.h 3generic-y += clkdev.h
4generic-y += cputime.h 4generic-y += cputime.h
@@ -6,6 +6,7 @@ generic-y += device.h
6generic-y += emergency-restart.h 6generic-y += emergency-restart.h
7generic-y += errno.h 7generic-y += errno.h
8generic-y += exec.h 8generic-y += exec.h
9generic-y += hash.h
9generic-y += hw_irq.h 10generic-y += hw_irq.h
10generic-y += ioctl.h 11generic-y += ioctl.h
11generic-y += ipcbuf.h 12generic-y += ipcbuf.h
@@ -18,6 +19,7 @@ generic-y += local.h
18generic-y += mman.h 19generic-y += mman.h
19generic-y += mutex.h 20generic-y += mutex.h
20generic-y += percpu.h 21generic-y += percpu.h
22generic-y += preempt.h
21generic-y += resource.h 23generic-y += resource.h
22generic-y += scatterlist.h 24generic-y += scatterlist.h
23generic-y += sections.h 25generic-y += sections.h
@@ -31,5 +33,3 @@ generic-y += trace_clock.h
31generic-y += types.h 33generic-y += types.h
32generic-y += word-at-a-time.h 34generic-y += word-at-a-time.h
33generic-y += xor.h 35generic-y += xor.h
34generic-y += preempt.h
35generic-y += hash.h
diff --git a/arch/m68k/include/asm/barrier.h b/arch/m68k/include/asm/barrier.h
deleted file mode 100644
index 15c5f77c1614..000000000000
--- a/arch/m68k/include/asm/barrier.h
+++ /dev/null
@@ -1,8 +0,0 @@
1#ifndef _M68K_BARRIER_H
2#define _M68K_BARRIER_H
3
4#define nop() do { asm volatile ("nop"); barrier(); } while (0)
5
6#include <asm-generic/barrier.h>
7
8#endif /* _M68K_BARRIER_H */
diff --git a/arch/m68k/include/asm/unistd.h b/arch/m68k/include/asm/unistd.h
index 014f288fc813..9d38b73989eb 100644
--- a/arch/m68k/include/asm/unistd.h
+++ b/arch/m68k/include/asm/unistd.h
@@ -4,7 +4,7 @@
4#include <uapi/asm/unistd.h> 4#include <uapi/asm/unistd.h>
5 5
6 6
7#define NR_syscalls 349 7#define NR_syscalls 351
8 8
9#define __ARCH_WANT_OLD_READDIR 9#define __ARCH_WANT_OLD_READDIR
10#define __ARCH_WANT_OLD_STAT 10#define __ARCH_WANT_OLD_STAT
diff --git a/arch/m68k/include/uapi/asm/unistd.h b/arch/m68k/include/uapi/asm/unistd.h
index 625f321001dc..b932dd470041 100644
--- a/arch/m68k/include/uapi/asm/unistd.h
+++ b/arch/m68k/include/uapi/asm/unistd.h
@@ -354,5 +354,7 @@
354#define __NR_process_vm_writev 346 354#define __NR_process_vm_writev 346
355#define __NR_kcmp 347 355#define __NR_kcmp 347
356#define __NR_finit_module 348 356#define __NR_finit_module 348
357#define __NR_sched_setattr 349
358#define __NR_sched_getattr 350
357 359
358#endif /* _UAPI_ASM_M68K_UNISTD_H_ */ 360#endif /* _UAPI_ASM_M68K_UNISTD_H_ */
diff --git a/arch/m68k/kernel/syscalltable.S b/arch/m68k/kernel/syscalltable.S
index 3f04ea0ab802..b6223dc41d82 100644
--- a/arch/m68k/kernel/syscalltable.S
+++ b/arch/m68k/kernel/syscalltable.S
@@ -369,4 +369,6 @@ ENTRY(sys_call_table)
369 .long sys_process_vm_writev 369 .long sys_process_vm_writev
370 .long sys_kcmp 370 .long sys_kcmp
371 .long sys_finit_module 371 .long sys_finit_module
372 .long sys_sched_setattr
373 .long sys_sched_getattr /* 350 */
372 374
diff --git a/arch/powerpc/include/asm/compat.h b/arch/powerpc/include/asm/compat.h
index 84fdf6857c31..a613d2c82fd9 100644
--- a/arch/powerpc/include/asm/compat.h
+++ b/arch/powerpc/include/asm/compat.h
@@ -200,10 +200,11 @@ static inline void __user *arch_compat_alloc_user_space(long len)
200 200
201 /* 201 /*
202 * We can't access below the stack pointer in the 32bit ABI and 202 * We can't access below the stack pointer in the 32bit ABI and
203 * can access 288 bytes in the 64bit ABI 203 * can access 288 bytes in the 64bit big-endian ABI,
204 * or 512 bytes with the new ELFv2 little-endian ABI.
204 */ 205 */
205 if (!is_32bit_task()) 206 if (!is_32bit_task())
206 usp -= 288; 207 usp -= USER_REDZONE_SIZE;
207 208
208 return (void __user *) (usp - len); 209 return (void __user *) (usp - len);
209} 210}
diff --git a/arch/powerpc/include/asm/opal.h b/arch/powerpc/include/asm/opal.h
index 40157e2ca691..ed82142a3251 100644
--- a/arch/powerpc/include/asm/opal.h
+++ b/arch/powerpc/include/asm/opal.h
@@ -816,8 +816,8 @@ int64_t opal_pci_next_error(uint64_t phb_id, uint64_t *first_frozen_pe,
816int64_t opal_pci_poll(uint64_t phb_id); 816int64_t opal_pci_poll(uint64_t phb_id);
817int64_t opal_return_cpu(void); 817int64_t opal_return_cpu(void);
818 818
819int64_t opal_xscom_read(uint32_t gcid, uint32_t pcb_addr, __be64 *val); 819int64_t opal_xscom_read(uint32_t gcid, uint64_t pcb_addr, __be64 *val);
820int64_t opal_xscom_write(uint32_t gcid, uint32_t pcb_addr, uint64_t val); 820int64_t opal_xscom_write(uint32_t gcid, uint64_t pcb_addr, uint64_t val);
821 821
822int64_t opal_lpc_write(uint32_t chip_id, enum OpalLPCAddressType addr_type, 822int64_t opal_lpc_write(uint32_t chip_id, enum OpalLPCAddressType addr_type,
823 uint32_t addr, uint32_t data, uint32_t sz); 823 uint32_t addr, uint32_t data, uint32_t sz);
diff --git a/arch/powerpc/include/asm/ptrace.h b/arch/powerpc/include/asm/ptrace.h
index becc08e6a65c..279b80f3bb29 100644
--- a/arch/powerpc/include/asm/ptrace.h
+++ b/arch/powerpc/include/asm/ptrace.h
@@ -28,11 +28,23 @@
28 28
29#ifdef __powerpc64__ 29#ifdef __powerpc64__
30 30
31/*
32 * Size of redzone that userspace is allowed to use below the stack
33 * pointer. This is 288 in the 64-bit big-endian ELF ABI, and 512 in
34 * the new ELFv2 little-endian ABI, so we allow the larger amount.
35 *
36 * For kernel code we allow a 288-byte redzone, in order to conserve
37 * kernel stack space; gcc currently only uses 288 bytes, and will
38 * hopefully allow explicit control of the redzone size in future.
39 */
40#define USER_REDZONE_SIZE 512
41#define KERNEL_REDZONE_SIZE 288
42
31#define STACK_FRAME_OVERHEAD 112 /* size of minimum stack frame */ 43#define STACK_FRAME_OVERHEAD 112 /* size of minimum stack frame */
32#define STACK_FRAME_LR_SAVE 2 /* Location of LR in stack frame */ 44#define STACK_FRAME_LR_SAVE 2 /* Location of LR in stack frame */
33#define STACK_FRAME_REGS_MARKER ASM_CONST(0x7265677368657265) 45#define STACK_FRAME_REGS_MARKER ASM_CONST(0x7265677368657265)
34#define STACK_INT_FRAME_SIZE (sizeof(struct pt_regs) + \ 46#define STACK_INT_FRAME_SIZE (sizeof(struct pt_regs) + \
35 STACK_FRAME_OVERHEAD + 288) 47 STACK_FRAME_OVERHEAD + KERNEL_REDZONE_SIZE)
36#define STACK_FRAME_MARKER 12 48#define STACK_FRAME_MARKER 12
37 49
38/* Size of dummy stack frame allocated when calling signal handler. */ 50/* Size of dummy stack frame allocated when calling signal handler. */
@@ -41,6 +53,8 @@
41 53
42#else /* __powerpc64__ */ 54#else /* __powerpc64__ */
43 55
56#define USER_REDZONE_SIZE 0
57#define KERNEL_REDZONE_SIZE 0
44#define STACK_FRAME_OVERHEAD 16 /* size of minimum stack frame */ 58#define STACK_FRAME_OVERHEAD 16 /* size of minimum stack frame */
45#define STACK_FRAME_LR_SAVE 1 /* Location of LR in stack frame */ 59#define STACK_FRAME_LR_SAVE 1 /* Location of LR in stack frame */
46#define STACK_FRAME_REGS_MARKER ASM_CONST(0x72656773) 60#define STACK_FRAME_REGS_MARKER ASM_CONST(0x72656773)
diff --git a/arch/powerpc/kernel/crash_dump.c b/arch/powerpc/kernel/crash_dump.c
index 11c1d069d920..7a13f378ca2c 100644
--- a/arch/powerpc/kernel/crash_dump.c
+++ b/arch/powerpc/kernel/crash_dump.c
@@ -98,17 +98,19 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
98 size_t csize, unsigned long offset, int userbuf) 98 size_t csize, unsigned long offset, int userbuf)
99{ 99{
100 void *vaddr; 100 void *vaddr;
101 phys_addr_t paddr;
101 102
102 if (!csize) 103 if (!csize)
103 return 0; 104 return 0;
104 105
105 csize = min_t(size_t, csize, PAGE_SIZE); 106 csize = min_t(size_t, csize, PAGE_SIZE);
107 paddr = pfn << PAGE_SHIFT;
106 108
107 if ((min_low_pfn < pfn) && (pfn < max_pfn)) { 109 if (memblock_is_region_memory(paddr, csize)) {
108 vaddr = __va(pfn << PAGE_SHIFT); 110 vaddr = __va(paddr);
109 csize = copy_oldmem_vaddr(vaddr, buf, csize, offset, userbuf); 111 csize = copy_oldmem_vaddr(vaddr, buf, csize, offset, userbuf);
110 } else { 112 } else {
111 vaddr = __ioremap(pfn << PAGE_SHIFT, PAGE_SIZE, 0); 113 vaddr = __ioremap(paddr, PAGE_SIZE, 0);
112 csize = copy_oldmem_vaddr(vaddr, buf, csize, offset, userbuf); 114 csize = copy_oldmem_vaddr(vaddr, buf, csize, offset, userbuf);
113 iounmap(vaddr); 115 iounmap(vaddr);
114 } 116 }
diff --git a/arch/powerpc/kernel/ftrace.c b/arch/powerpc/kernel/ftrace.c
index 9b27b293a922..b0ded97ee4e1 100644
--- a/arch/powerpc/kernel/ftrace.c
+++ b/arch/powerpc/kernel/ftrace.c
@@ -74,6 +74,7 @@ ftrace_modify_code(unsigned long ip, unsigned int old, unsigned int new)
74 */ 74 */
75static int test_24bit_addr(unsigned long ip, unsigned long addr) 75static int test_24bit_addr(unsigned long ip, unsigned long addr)
76{ 76{
77 addr = ppc_function_entry((void *)addr);
77 78
78 /* use the create_branch to verify that this offset can be branched */ 79 /* use the create_branch to verify that this offset can be branched */
79 return create_branch((unsigned int *)ip, addr, 0); 80 return create_branch((unsigned int *)ip, addr, 0);
diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
index e35bf773df7a..8d253c29649b 100644
--- a/arch/powerpc/kernel/signal_64.c
+++ b/arch/powerpc/kernel/signal_64.c
@@ -65,8 +65,8 @@ struct rt_sigframe {
65 struct siginfo __user *pinfo; 65 struct siginfo __user *pinfo;
66 void __user *puc; 66 void __user *puc;
67 struct siginfo info; 67 struct siginfo info;
68 /* 64 bit ABI allows for 288 bytes below sp before decrementing it. */ 68 /* New 64 bit little-endian ABI allows redzone of 512 bytes below sp */
69 char abigap[288]; 69 char abigap[USER_REDZONE_SIZE];
70} __attribute__ ((aligned (16))); 70} __attribute__ ((aligned (16)));
71 71
72static const char fmt32[] = KERN_INFO \ 72static const char fmt32[] = KERN_INFO \
diff --git a/arch/powerpc/platforms/powernv/eeh-ioda.c b/arch/powerpc/platforms/powernv/eeh-ioda.c
index f51474336460..253fefe3d1a0 100644
--- a/arch/powerpc/platforms/powernv/eeh-ioda.c
+++ b/arch/powerpc/platforms/powernv/eeh-ioda.c
@@ -114,6 +114,7 @@ DEFINE_SIMPLE_ATTRIBUTE(ioda_eeh_inbB_dbgfs_ops, ioda_eeh_inbB_dbgfs_get,
114 ioda_eeh_inbB_dbgfs_set, "0x%llx\n"); 114 ioda_eeh_inbB_dbgfs_set, "0x%llx\n");
115#endif /* CONFIG_DEBUG_FS */ 115#endif /* CONFIG_DEBUG_FS */
116 116
117
117/** 118/**
118 * ioda_eeh_post_init - Chip dependent post initialization 119 * ioda_eeh_post_init - Chip dependent post initialization
119 * @hose: PCI controller 120 * @hose: PCI controller
@@ -221,6 +222,22 @@ static int ioda_eeh_set_option(struct eeh_pe *pe, int option)
221 return ret; 222 return ret;
222} 223}
223 224
225static void ioda_eeh_phb_diag(struct pci_controller *hose)
226{
227 struct pnv_phb *phb = hose->private_data;
228 long rc;
229
230 rc = opal_pci_get_phb_diag_data2(phb->opal_id, phb->diag.blob,
231 PNV_PCI_DIAG_BUF_SIZE);
232 if (rc != OPAL_SUCCESS) {
233 pr_warning("%s: Failed to get diag-data for PHB#%x (%ld)\n",
234 __func__, hose->global_number, rc);
235 return;
236 }
237
238 pnv_pci_dump_phb_diag_data(hose, phb->diag.blob);
239}
240
224/** 241/**
225 * ioda_eeh_get_state - Retrieve the state of PE 242 * ioda_eeh_get_state - Retrieve the state of PE
226 * @pe: EEH PE 243 * @pe: EEH PE
@@ -272,6 +289,9 @@ static int ioda_eeh_get_state(struct eeh_pe *pe)
272 result |= EEH_STATE_DMA_ACTIVE; 289 result |= EEH_STATE_DMA_ACTIVE;
273 result |= EEH_STATE_MMIO_ENABLED; 290 result |= EEH_STATE_MMIO_ENABLED;
274 result |= EEH_STATE_DMA_ENABLED; 291 result |= EEH_STATE_DMA_ENABLED;
292 } else if (!(pe->state & EEH_PE_ISOLATED)) {
293 eeh_pe_state_mark(pe, EEH_PE_ISOLATED);
294 ioda_eeh_phb_diag(hose);
275 } 295 }
276 296
277 return result; 297 return result;
@@ -315,6 +335,15 @@ static int ioda_eeh_get_state(struct eeh_pe *pe)
315 __func__, fstate, hose->global_number, pe_no); 335 __func__, fstate, hose->global_number, pe_no);
316 } 336 }
317 337
338 /* Dump PHB diag-data for frozen PE */
339 if (result != EEH_STATE_NOT_SUPPORT &&
340 (result & (EEH_STATE_MMIO_ACTIVE | EEH_STATE_DMA_ACTIVE)) !=
341 (EEH_STATE_MMIO_ACTIVE | EEH_STATE_DMA_ACTIVE) &&
342 !(pe->state & EEH_PE_ISOLATED)) {
343 eeh_pe_state_mark(pe, EEH_PE_ISOLATED);
344 ioda_eeh_phb_diag(hose);
345 }
346
318 return result; 347 return result;
319} 348}
320 349
@@ -530,42 +559,6 @@ static int ioda_eeh_reset(struct eeh_pe *pe, int option)
530} 559}
531 560
532/** 561/**
533 * ioda_eeh_get_log - Retrieve error log
534 * @pe: EEH PE
535 * @severity: Severity level of the log
536 * @drv_log: buffer to store the log
537 * @len: space of the log buffer
538 *
539 * The function is used to retrieve error log from P7IOC.
540 */
541static int ioda_eeh_get_log(struct eeh_pe *pe, int severity,
542 char *drv_log, unsigned long len)
543{
544 s64 ret;
545 unsigned long flags;
546 struct pci_controller *hose = pe->phb;
547 struct pnv_phb *phb = hose->private_data;
548
549 spin_lock_irqsave(&phb->lock, flags);
550
551 ret = opal_pci_get_phb_diag_data2(phb->opal_id,
552 phb->diag.blob, PNV_PCI_DIAG_BUF_SIZE);
553 if (ret) {
554 spin_unlock_irqrestore(&phb->lock, flags);
555 pr_warning("%s: Can't get log for PHB#%x-PE#%x (%lld)\n",
556 __func__, hose->global_number, pe->addr, ret);
557 return -EIO;
558 }
559
560 /* The PHB diag-data is always indicative */
561 pnv_pci_dump_phb_diag_data(hose, phb->diag.blob);
562
563 spin_unlock_irqrestore(&phb->lock, flags);
564
565 return 0;
566}
567
568/**
569 * ioda_eeh_configure_bridge - Configure the PCI bridges for the indicated PE 562 * ioda_eeh_configure_bridge - Configure the PCI bridges for the indicated PE
570 * @pe: EEH PE 563 * @pe: EEH PE
571 * 564 *
@@ -646,22 +639,6 @@ static void ioda_eeh_hub_diag(struct pci_controller *hose)
646 } 639 }
647} 640}
648 641
649static void ioda_eeh_phb_diag(struct pci_controller *hose)
650{
651 struct pnv_phb *phb = hose->private_data;
652 long rc;
653
654 rc = opal_pci_get_phb_diag_data2(phb->opal_id, phb->diag.blob,
655 PNV_PCI_DIAG_BUF_SIZE);
656 if (rc != OPAL_SUCCESS) {
657 pr_warning("%s: Failed to get diag-data for PHB#%x (%ld)\n",
658 __func__, hose->global_number, rc);
659 return;
660 }
661
662 pnv_pci_dump_phb_diag_data(hose, phb->diag.blob);
663}
664
665static int ioda_eeh_get_phb_pe(struct pci_controller *hose, 642static int ioda_eeh_get_phb_pe(struct pci_controller *hose,
666 struct eeh_pe **pe) 643 struct eeh_pe **pe)
667{ 644{
@@ -835,6 +812,20 @@ static int ioda_eeh_next_error(struct eeh_pe **pe)
835 } 812 }
836 813
837 /* 814 /*
815 * EEH core will try recover from fenced PHB or
816 * frozen PE. In the time for frozen PE, EEH core
817 * enable IO path for that before collecting logs,
818 * but it ruins the site. So we have to dump the
819 * log in advance here.
820 */
821 if ((ret == EEH_NEXT_ERR_FROZEN_PE ||
822 ret == EEH_NEXT_ERR_FENCED_PHB) &&
823 !((*pe)->state & EEH_PE_ISOLATED)) {
824 eeh_pe_state_mark(*pe, EEH_PE_ISOLATED);
825 ioda_eeh_phb_diag(hose);
826 }
827
828 /*
838 * If we have no errors on the specific PHB or only 829 * If we have no errors on the specific PHB or only
839 * informative error there, we continue poking it. 830 * informative error there, we continue poking it.
840 * Otherwise, we need actions to be taken by upper 831 * Otherwise, we need actions to be taken by upper
@@ -852,7 +843,6 @@ struct pnv_eeh_ops ioda_eeh_ops = {
852 .set_option = ioda_eeh_set_option, 843 .set_option = ioda_eeh_set_option,
853 .get_state = ioda_eeh_get_state, 844 .get_state = ioda_eeh_get_state,
854 .reset = ioda_eeh_reset, 845 .reset = ioda_eeh_reset,
855 .get_log = ioda_eeh_get_log,
856 .configure_bridge = ioda_eeh_configure_bridge, 846 .configure_bridge = ioda_eeh_configure_bridge,
857 .next_error = ioda_eeh_next_error 847 .next_error = ioda_eeh_next_error
858}; 848};
diff --git a/arch/powerpc/platforms/powernv/opal-xscom.c b/arch/powerpc/platforms/powernv/opal-xscom.c
index 4fbf276ac99e..4cd2ea6c0dbe 100644
--- a/arch/powerpc/platforms/powernv/opal-xscom.c
+++ b/arch/powerpc/platforms/powernv/opal-xscom.c
@@ -71,11 +71,11 @@ static int opal_xscom_err_xlate(int64_t rc)
71 } 71 }
72} 72}
73 73
74static u64 opal_scom_unmangle(u64 reg) 74static u64 opal_scom_unmangle(u64 addr)
75{ 75{
76 /* 76 /*
77 * XSCOM indirect addresses have the top bit set. Additionally 77 * XSCOM indirect addresses have the top bit set. Additionally
78 * the reset of the top 3 nibbles is always 0. 78 * the rest of the top 3 nibbles is always 0.
79 * 79 *
80 * Because the debugfs interface uses signed offsets and shifts 80 * Because the debugfs interface uses signed offsets and shifts
81 * the address left by 3, we basically cannot use the top 4 bits 81 * the address left by 3, we basically cannot use the top 4 bits
@@ -86,10 +86,13 @@ static u64 opal_scom_unmangle(u64 reg)
86 * conversion here. To leave room for further xscom address 86 * conversion here. To leave room for further xscom address
87 * expansion, we only clear out the top byte 87 * expansion, we only clear out the top byte
88 * 88 *
89 * For in-kernel use, we also support the real indirect bit, so
90 * we test for any of the top 5 bits
91 *
89 */ 92 */
90 if (reg & (1ull << 59)) 93 if (addr & (0x1full << 59))
91 reg = (reg & ~(0xffull << 56)) | (1ull << 63); 94 addr = (addr & ~(0xffull << 56)) | (1ull << 63);
92 return reg; 95 return addr;
93} 96}
94 97
95static int opal_scom_read(scom_map_t map, u64 reg, u64 *value) 98static int opal_scom_read(scom_map_t map, u64 reg, u64 *value)
@@ -98,8 +101,8 @@ static int opal_scom_read(scom_map_t map, u64 reg, u64 *value)
98 int64_t rc; 101 int64_t rc;
99 __be64 v; 102 __be64 v;
100 103
101 reg = opal_scom_unmangle(reg); 104 reg = opal_scom_unmangle(m->addr + reg);
102 rc = opal_xscom_read(m->chip, m->addr + reg, (__be64 *)__pa(&v)); 105 rc = opal_xscom_read(m->chip, reg, (__be64 *)__pa(&v));
103 *value = be64_to_cpu(v); 106 *value = be64_to_cpu(v);
104 return opal_xscom_err_xlate(rc); 107 return opal_xscom_err_xlate(rc);
105} 108}
@@ -109,8 +112,8 @@ static int opal_scom_write(scom_map_t map, u64 reg, u64 value)
109 struct opal_scom_map *m = map; 112 struct opal_scom_map *m = map;
110 int64_t rc; 113 int64_t rc;
111 114
112 reg = opal_scom_unmangle(reg); 115 reg = opal_scom_unmangle(m->addr + reg);
113 rc = opal_xscom_write(m->chip, m->addr + reg, value); 116 rc = opal_xscom_write(m->chip, reg, value);
114 return opal_xscom_err_xlate(rc); 117 return opal_xscom_err_xlate(rc);
115} 118}
116 119
diff --git a/arch/powerpc/platforms/powernv/pci.c b/arch/powerpc/platforms/powernv/pci.c
index 95633d79ef5d..8518817dcdfd 100644
--- a/arch/powerpc/platforms/powernv/pci.c
+++ b/arch/powerpc/platforms/powernv/pci.c
@@ -134,57 +134,72 @@ static void pnv_pci_dump_p7ioc_diag_data(struct pci_controller *hose,
134 pr_info("P7IOC PHB#%d Diag-data (Version: %d)\n\n", 134 pr_info("P7IOC PHB#%d Diag-data (Version: %d)\n\n",
135 hose->global_number, common->version); 135 hose->global_number, common->version);
136 136
137 pr_info(" brdgCtl: %08x\n", data->brdgCtl); 137 if (data->brdgCtl)
138 138 pr_info(" brdgCtl: %08x\n",
139 pr_info(" portStatusReg: %08x\n", data->portStatusReg); 139 data->brdgCtl);
140 pr_info(" rootCmplxStatus: %08x\n", data->rootCmplxStatus); 140 if (data->portStatusReg || data->rootCmplxStatus ||
141 pr_info(" busAgentStatus: %08x\n", data->busAgentStatus); 141 data->busAgentStatus)
142 142 pr_info(" UtlSts: %08x %08x %08x\n",
143 pr_info(" deviceStatus: %08x\n", data->deviceStatus); 143 data->portStatusReg, data->rootCmplxStatus,
144 pr_info(" slotStatus: %08x\n", data->slotStatus); 144 data->busAgentStatus);
145 pr_info(" linkStatus: %08x\n", data->linkStatus); 145 if (data->deviceStatus || data->slotStatus ||
146 pr_info(" devCmdStatus: %08x\n", data->devCmdStatus); 146 data->linkStatus || data->devCmdStatus ||
147 pr_info(" devSecStatus: %08x\n", data->devSecStatus); 147 data->devSecStatus)
148 148 pr_info(" RootSts: %08x %08x %08x %08x %08x\n",
149 pr_info(" rootErrorStatus: %08x\n", data->rootErrorStatus); 149 data->deviceStatus, data->slotStatus,
150 pr_info(" uncorrErrorStatus: %08x\n", data->uncorrErrorStatus); 150 data->linkStatus, data->devCmdStatus,
151 pr_info(" corrErrorStatus: %08x\n", data->corrErrorStatus); 151 data->devSecStatus);
152 pr_info(" tlpHdr1: %08x\n", data->tlpHdr1); 152 if (data->rootErrorStatus || data->uncorrErrorStatus ||
153 pr_info(" tlpHdr2: %08x\n", data->tlpHdr2); 153 data->corrErrorStatus)
154 pr_info(" tlpHdr3: %08x\n", data->tlpHdr3); 154 pr_info(" RootErrSts: %08x %08x %08x\n",
155 pr_info(" tlpHdr4: %08x\n", data->tlpHdr4); 155 data->rootErrorStatus, data->uncorrErrorStatus,
156 pr_info(" sourceId: %08x\n", data->sourceId); 156 data->corrErrorStatus);
157 pr_info(" errorClass: %016llx\n", data->errorClass); 157 if (data->tlpHdr1 || data->tlpHdr2 ||
158 pr_info(" correlator: %016llx\n", data->correlator); 158 data->tlpHdr3 || data->tlpHdr4)
159 pr_info(" p7iocPlssr: %016llx\n", data->p7iocPlssr); 159 pr_info(" RootErrLog: %08x %08x %08x %08x\n",
160 pr_info(" p7iocCsr: %016llx\n", data->p7iocCsr); 160 data->tlpHdr1, data->tlpHdr2,
161 pr_info(" lemFir: %016llx\n", data->lemFir); 161 data->tlpHdr3, data->tlpHdr4);
162 pr_info(" lemErrorMask: %016llx\n", data->lemErrorMask); 162 if (data->sourceId || data->errorClass ||
163 pr_info(" lemWOF: %016llx\n", data->lemWOF); 163 data->correlator)
164 pr_info(" phbErrorStatus: %016llx\n", data->phbErrorStatus); 164 pr_info(" RootErrLog1: %08x %016llx %016llx\n",
165 pr_info(" phbFirstErrorStatus: %016llx\n", data->phbFirstErrorStatus); 165 data->sourceId, data->errorClass,
166 pr_info(" phbErrorLog0: %016llx\n", data->phbErrorLog0); 166 data->correlator);
167 pr_info(" phbErrorLog1: %016llx\n", data->phbErrorLog1); 167 if (data->p7iocPlssr || data->p7iocCsr)
168 pr_info(" mmioErrorStatus: %016llx\n", data->mmioErrorStatus); 168 pr_info(" PhbSts: %016llx %016llx\n",
169 pr_info(" mmioFirstErrorStatus: %016llx\n", data->mmioFirstErrorStatus); 169 data->p7iocPlssr, data->p7iocCsr);
170 pr_info(" mmioErrorLog0: %016llx\n", data->mmioErrorLog0); 170 if (data->lemFir || data->lemErrorMask ||
171 pr_info(" mmioErrorLog1: %016llx\n", data->mmioErrorLog1); 171 data->lemWOF)
172 pr_info(" dma0ErrorStatus: %016llx\n", data->dma0ErrorStatus); 172 pr_info(" Lem: %016llx %016llx %016llx\n",
173 pr_info(" dma0FirstErrorStatus: %016llx\n", data->dma0FirstErrorStatus); 173 data->lemFir, data->lemErrorMask,
174 pr_info(" dma0ErrorLog0: %016llx\n", data->dma0ErrorLog0); 174 data->lemWOF);
175 pr_info(" dma0ErrorLog1: %016llx\n", data->dma0ErrorLog1); 175 if (data->phbErrorStatus || data->phbFirstErrorStatus ||
176 pr_info(" dma1ErrorStatus: %016llx\n", data->dma1ErrorStatus); 176 data->phbErrorLog0 || data->phbErrorLog1)
177 pr_info(" dma1FirstErrorStatus: %016llx\n", data->dma1FirstErrorStatus); 177 pr_info(" PhbErr: %016llx %016llx %016llx %016llx\n",
178 pr_info(" dma1ErrorLog0: %016llx\n", data->dma1ErrorLog0); 178 data->phbErrorStatus, data->phbFirstErrorStatus,
179 pr_info(" dma1ErrorLog1: %016llx\n", data->dma1ErrorLog1); 179 data->phbErrorLog0, data->phbErrorLog1);
180 if (data->mmioErrorStatus || data->mmioFirstErrorStatus ||
181 data->mmioErrorLog0 || data->mmioErrorLog1)
182 pr_info(" OutErr: %016llx %016llx %016llx %016llx\n",
183 data->mmioErrorStatus, data->mmioFirstErrorStatus,
184 data->mmioErrorLog0, data->mmioErrorLog1);
185 if (data->dma0ErrorStatus || data->dma0FirstErrorStatus ||
186 data->dma0ErrorLog0 || data->dma0ErrorLog1)
187 pr_info(" InAErr: %016llx %016llx %016llx %016llx\n",
188 data->dma0ErrorStatus, data->dma0FirstErrorStatus,
189 data->dma0ErrorLog0, data->dma0ErrorLog1);
190 if (data->dma1ErrorStatus || data->dma1FirstErrorStatus ||
191 data->dma1ErrorLog0 || data->dma1ErrorLog1)
192 pr_info(" InBErr: %016llx %016llx %016llx %016llx\n",
193 data->dma1ErrorStatus, data->dma1FirstErrorStatus,
194 data->dma1ErrorLog0, data->dma1ErrorLog1);
180 195
181 for (i = 0; i < OPAL_P7IOC_NUM_PEST_REGS; i++) { 196 for (i = 0; i < OPAL_P7IOC_NUM_PEST_REGS; i++) {
182 if ((data->pestA[i] >> 63) == 0 && 197 if ((data->pestA[i] >> 63) == 0 &&
183 (data->pestB[i] >> 63) == 0) 198 (data->pestB[i] >> 63) == 0)
184 continue; 199 continue;
185 200
186 pr_info(" PE[%3d] PESTA: %016llx\n", i, data->pestA[i]); 201 pr_info(" PE[%3d] A/B: %016llx %016llx\n",
187 pr_info(" PESTB: %016llx\n", data->pestB[i]); 202 i, data->pestA[i], data->pestB[i]);
188 } 203 }
189} 204}
190 205
@@ -197,62 +212,77 @@ static void pnv_pci_dump_phb3_diag_data(struct pci_controller *hose,
197 data = (struct OpalIoPhb3ErrorData*)common; 212 data = (struct OpalIoPhb3ErrorData*)common;
198 pr_info("PHB3 PHB#%d Diag-data (Version: %d)\n\n", 213 pr_info("PHB3 PHB#%d Diag-data (Version: %d)\n\n",
199 hose->global_number, common->version); 214 hose->global_number, common->version);
200 215 if (data->brdgCtl)
201 pr_info(" brdgCtl: %08x\n", data->brdgCtl); 216 pr_info(" brdgCtl: %08x\n",
202 217 data->brdgCtl);
203 pr_info(" portStatusReg: %08x\n", data->portStatusReg); 218 if (data->portStatusReg || data->rootCmplxStatus ||
204 pr_info(" rootCmplxStatus: %08x\n", data->rootCmplxStatus); 219 data->busAgentStatus)
205 pr_info(" busAgentStatus: %08x\n", data->busAgentStatus); 220 pr_info(" UtlSts: %08x %08x %08x\n",
206 221 data->portStatusReg, data->rootCmplxStatus,
207 pr_info(" deviceStatus: %08x\n", data->deviceStatus); 222 data->busAgentStatus);
208 pr_info(" slotStatus: %08x\n", data->slotStatus); 223 if (data->deviceStatus || data->slotStatus ||
209 pr_info(" linkStatus: %08x\n", data->linkStatus); 224 data->linkStatus || data->devCmdStatus ||
210 pr_info(" devCmdStatus: %08x\n", data->devCmdStatus); 225 data->devSecStatus)
211 pr_info(" devSecStatus: %08x\n", data->devSecStatus); 226 pr_info(" RootSts: %08x %08x %08x %08x %08x\n",
212 227 data->deviceStatus, data->slotStatus,
213 pr_info(" rootErrorStatus: %08x\n", data->rootErrorStatus); 228 data->linkStatus, data->devCmdStatus,
214 pr_info(" uncorrErrorStatus: %08x\n", data->uncorrErrorStatus); 229 data->devSecStatus);
215 pr_info(" corrErrorStatus: %08x\n", data->corrErrorStatus); 230 if (data->rootErrorStatus || data->uncorrErrorStatus ||
216 pr_info(" tlpHdr1: %08x\n", data->tlpHdr1); 231 data->corrErrorStatus)
217 pr_info(" tlpHdr2: %08x\n", data->tlpHdr2); 232 pr_info(" RootErrSts: %08x %08x %08x\n",
218 pr_info(" tlpHdr3: %08x\n", data->tlpHdr3); 233 data->rootErrorStatus, data->uncorrErrorStatus,
219 pr_info(" tlpHdr4: %08x\n", data->tlpHdr4); 234 data->corrErrorStatus);
220 pr_info(" sourceId: %08x\n", data->sourceId); 235 if (data->tlpHdr1 || data->tlpHdr2 ||
221 pr_info(" errorClass: %016llx\n", data->errorClass); 236 data->tlpHdr3 || data->tlpHdr4)
222 pr_info(" correlator: %016llx\n", data->correlator); 237 pr_info(" RootErrLog: %08x %08x %08x %08x\n",
223 238 data->tlpHdr1, data->tlpHdr2,
224 pr_info(" nFir: %016llx\n", data->nFir); 239 data->tlpHdr3, data->tlpHdr4);
225 pr_info(" nFirMask: %016llx\n", data->nFirMask); 240 if (data->sourceId || data->errorClass ||
226 pr_info(" nFirWOF: %016llx\n", data->nFirWOF); 241 data->correlator)
227 pr_info(" PhbPlssr: %016llx\n", data->phbPlssr); 242 pr_info(" RootErrLog1: %08x %016llx %016llx\n",
228 pr_info(" PhbCsr: %016llx\n", data->phbCsr); 243 data->sourceId, data->errorClass,
229 pr_info(" lemFir: %016llx\n", data->lemFir); 244 data->correlator);
230 pr_info(" lemErrorMask: %016llx\n", data->lemErrorMask); 245 if (data->nFir || data->nFirMask ||
231 pr_info(" lemWOF: %016llx\n", data->lemWOF); 246 data->nFirWOF)
232 pr_info(" phbErrorStatus: %016llx\n", data->phbErrorStatus); 247 pr_info(" nFir: %016llx %016llx %016llx\n",
233 pr_info(" phbFirstErrorStatus: %016llx\n", data->phbFirstErrorStatus); 248 data->nFir, data->nFirMask,
234 pr_info(" phbErrorLog0: %016llx\n", data->phbErrorLog0); 249 data->nFirWOF);
235 pr_info(" phbErrorLog1: %016llx\n", data->phbErrorLog1); 250 if (data->phbPlssr || data->phbCsr)
236 pr_info(" mmioErrorStatus: %016llx\n", data->mmioErrorStatus); 251 pr_info(" PhbSts: %016llx %016llx\n",
237 pr_info(" mmioFirstErrorStatus: %016llx\n", data->mmioFirstErrorStatus); 252 data->phbPlssr, data->phbCsr);
238 pr_info(" mmioErrorLog0: %016llx\n", data->mmioErrorLog0); 253 if (data->lemFir || data->lemErrorMask ||
239 pr_info(" mmioErrorLog1: %016llx\n", data->mmioErrorLog1); 254 data->lemWOF)
240 pr_info(" dma0ErrorStatus: %016llx\n", data->dma0ErrorStatus); 255 pr_info(" Lem: %016llx %016llx %016llx\n",
241 pr_info(" dma0FirstErrorStatus: %016llx\n", data->dma0FirstErrorStatus); 256 data->lemFir, data->lemErrorMask,
242 pr_info(" dma0ErrorLog0: %016llx\n", data->dma0ErrorLog0); 257 data->lemWOF);
243 pr_info(" dma0ErrorLog1: %016llx\n", data->dma0ErrorLog1); 258 if (data->phbErrorStatus || data->phbFirstErrorStatus ||
244 pr_info(" dma1ErrorStatus: %016llx\n", data->dma1ErrorStatus); 259 data->phbErrorLog0 || data->phbErrorLog1)
245 pr_info(" dma1FirstErrorStatus: %016llx\n", data->dma1FirstErrorStatus); 260 pr_info(" PhbErr: %016llx %016llx %016llx %016llx\n",
246 pr_info(" dma1ErrorLog0: %016llx\n", data->dma1ErrorLog0); 261 data->phbErrorStatus, data->phbFirstErrorStatus,
247 pr_info(" dma1ErrorLog1: %016llx\n", data->dma1ErrorLog1); 262 data->phbErrorLog0, data->phbErrorLog1);
263 if (data->mmioErrorStatus || data->mmioFirstErrorStatus ||
264 data->mmioErrorLog0 || data->mmioErrorLog1)
265 pr_info(" OutErr: %016llx %016llx %016llx %016llx\n",
266 data->mmioErrorStatus, data->mmioFirstErrorStatus,
267 data->mmioErrorLog0, data->mmioErrorLog1);
268 if (data->dma0ErrorStatus || data->dma0FirstErrorStatus ||
269 data->dma0ErrorLog0 || data->dma0ErrorLog1)
270 pr_info(" InAErr: %016llx %016llx %016llx %016llx\n",
271 data->dma0ErrorStatus, data->dma0FirstErrorStatus,
272 data->dma0ErrorLog0, data->dma0ErrorLog1);
273 if (data->dma1ErrorStatus || data->dma1FirstErrorStatus ||
274 data->dma1ErrorLog0 || data->dma1ErrorLog1)
275 pr_info(" InBErr: %016llx %016llx %016llx %016llx\n",
276 data->dma1ErrorStatus, data->dma1FirstErrorStatus,
277 data->dma1ErrorLog0, data->dma1ErrorLog1);
248 278
249 for (i = 0; i < OPAL_PHB3_NUM_PEST_REGS; i++) { 279 for (i = 0; i < OPAL_PHB3_NUM_PEST_REGS; i++) {
250 if ((data->pestA[i] >> 63) == 0 && 280 if ((data->pestA[i] >> 63) == 0 &&
251 (data->pestB[i] >> 63) == 0) 281 (data->pestB[i] >> 63) == 0)
252 continue; 282 continue;
253 283
254 pr_info(" PE[%3d] PESTA: %016llx\n", i, data->pestA[i]); 284 pr_info(" PE[%3d] A/B: %016llx %016llx\n",
255 pr_info(" PESTB: %016llx\n", data->pestB[i]); 285 i, data->pestA[i], data->pestB[i]);
256 } 286 }
257} 287}
258 288
diff --git a/arch/powerpc/platforms/pseries/hotplug-cpu.c b/arch/powerpc/platforms/pseries/hotplug-cpu.c
index 82789e79e539..0ea99e3d4815 100644
--- a/arch/powerpc/platforms/pseries/hotplug-cpu.c
+++ b/arch/powerpc/platforms/pseries/hotplug-cpu.c
@@ -35,12 +35,7 @@
35#include "offline_states.h" 35#include "offline_states.h"
36 36
37/* This version can't take the spinlock, because it never returns */ 37/* This version can't take the spinlock, because it never returns */
38static struct rtas_args rtas_stop_self_args = { 38static int rtas_stop_self_token = RTAS_UNKNOWN_SERVICE;
39 .token = RTAS_UNKNOWN_SERVICE,
40 .nargs = 0,
41 .nret = 1,
42 .rets = &rtas_stop_self_args.args[0],
43};
44 39
45static DEFINE_PER_CPU(enum cpu_state_vals, preferred_offline_state) = 40static DEFINE_PER_CPU(enum cpu_state_vals, preferred_offline_state) =
46 CPU_STATE_OFFLINE; 41 CPU_STATE_OFFLINE;
@@ -93,15 +88,20 @@ void set_default_offline_state(int cpu)
93 88
94static void rtas_stop_self(void) 89static void rtas_stop_self(void)
95{ 90{
96 struct rtas_args *args = &rtas_stop_self_args; 91 struct rtas_args args = {
92 .token = cpu_to_be32(rtas_stop_self_token),
93 .nargs = 0,
94 .nret = 1,
95 .rets = &args.args[0],
96 };
97 97
98 local_irq_disable(); 98 local_irq_disable();
99 99
100 BUG_ON(args->token == RTAS_UNKNOWN_SERVICE); 100 BUG_ON(rtas_stop_self_token == RTAS_UNKNOWN_SERVICE);
101 101
102 printk("cpu %u (hwid %u) Ready to die...\n", 102 printk("cpu %u (hwid %u) Ready to die...\n",
103 smp_processor_id(), hard_smp_processor_id()); 103 smp_processor_id(), hard_smp_processor_id());
104 enter_rtas(__pa(args)); 104 enter_rtas(__pa(&args));
105 105
106 panic("Alas, I survived.\n"); 106 panic("Alas, I survived.\n");
107} 107}
@@ -392,10 +392,10 @@ static int __init pseries_cpu_hotplug_init(void)
392 } 392 }
393 } 393 }
394 394
395 rtas_stop_self_args.token = rtas_token("stop-self"); 395 rtas_stop_self_token = rtas_token("stop-self");
396 qcss_tok = rtas_token("query-cpu-stopped-state"); 396 qcss_tok = rtas_token("query-cpu-stopped-state");
397 397
398 if (rtas_stop_self_args.token == RTAS_UNKNOWN_SERVICE || 398 if (rtas_stop_self_token == RTAS_UNKNOWN_SERVICE ||
399 qcss_tok == RTAS_UNKNOWN_SERVICE) { 399 qcss_tok == RTAS_UNKNOWN_SERVICE) {
400 printk(KERN_INFO "CPU Hotplug not supported by firmware " 400 printk(KERN_INFO "CPU Hotplug not supported by firmware "
401 "- disabling.\n"); 401 "- disabling.\n");
diff --git a/arch/s390/kernel/compat_wrapper.S b/arch/s390/kernel/compat_wrapper.S
index 59c8efce1b99..0248949a756d 100644
--- a/arch/s390/kernel/compat_wrapper.S
+++ b/arch/s390/kernel/compat_wrapper.S
@@ -1421,5 +1421,5 @@ ENTRY(sys_sched_setattr_wrapper)
1421ENTRY(sys_sched_getattr_wrapper) 1421ENTRY(sys_sched_getattr_wrapper)
1422 lgfr %r2,%r2 # pid_t 1422 lgfr %r2,%r2 # pid_t
1423 llgtr %r3,%r3 # const char __user * 1423 llgtr %r3,%r3 # const char __user *
1424 llgfr %r3,%r3 # unsigned int 1424 llgfr %r4,%r4 # unsigned int
1425 jg sys_sched_getattr 1425 jg sys_sched_getattr
diff --git a/arch/s390/pci/pci_dma.c b/arch/s390/pci/pci_dma.c
index 60c11a629d96..f91c03119804 100644
--- a/arch/s390/pci/pci_dma.c
+++ b/arch/s390/pci/pci_dma.c
@@ -206,11 +206,13 @@ static void dma_cleanup_tables(struct zpci_dev *zdev)
206 zdev->dma_table = NULL; 206 zdev->dma_table = NULL;
207} 207}
208 208
209static unsigned long __dma_alloc_iommu(struct zpci_dev *zdev, unsigned long start, 209static unsigned long __dma_alloc_iommu(struct zpci_dev *zdev,
210 int size) 210 unsigned long start, int size)
211{ 211{
212 unsigned long boundary_size = 0x1000000; 212 unsigned long boundary_size;
213 213
214 boundary_size = ALIGN(dma_get_seg_boundary(&zdev->pdev->dev) + 1,
215 PAGE_SIZE) >> PAGE_SHIFT;
214 return iommu_area_alloc(zdev->iommu_bitmap, zdev->iommu_pages, 216 return iommu_area_alloc(zdev->iommu_bitmap, zdev->iommu_pages,
215 start, size, 0, boundary_size, 0); 217 start, size, 0, boundary_size, 0);
216} 218}
diff --git a/arch/sh/include/cpu-sh2/cpu/cache.h b/arch/sh/include/cpu-sh2/cpu/cache.h
index 673515bc4135..aa1b2b9088a7 100644
--- a/arch/sh/include/cpu-sh2/cpu/cache.h
+++ b/arch/sh/include/cpu-sh2/cpu/cache.h
@@ -18,7 +18,7 @@
18#define SH_CACHE_ASSOC 8 18#define SH_CACHE_ASSOC 8
19 19
20#if defined(CONFIG_CPU_SUBTYPE_SH7619) 20#if defined(CONFIG_CPU_SUBTYPE_SH7619)
21#define CCR 0xffffffec 21#define SH_CCR 0xffffffec
22 22
23#define CCR_CACHE_CE 0x01 /* Cache enable */ 23#define CCR_CACHE_CE 0x01 /* Cache enable */
24#define CCR_CACHE_WT 0x02 /* CCR[bit1=1,bit2=1] */ 24#define CCR_CACHE_WT 0x02 /* CCR[bit1=1,bit2=1] */
diff --git a/arch/sh/include/cpu-sh2a/cpu/cache.h b/arch/sh/include/cpu-sh2a/cpu/cache.h
index defb0baa5a06..b27ce92cb600 100644
--- a/arch/sh/include/cpu-sh2a/cpu/cache.h
+++ b/arch/sh/include/cpu-sh2a/cpu/cache.h
@@ -17,8 +17,8 @@
17#define SH_CACHE_COMBINED 4 17#define SH_CACHE_COMBINED 4
18#define SH_CACHE_ASSOC 8 18#define SH_CACHE_ASSOC 8
19 19
20#define CCR 0xfffc1000 /* CCR1 */ 20#define SH_CCR 0xfffc1000 /* CCR1 */
21#define CCR2 0xfffc1004 21#define SH_CCR2 0xfffc1004
22 22
23/* 23/*
24 * Most of the SH-2A CCR1 definitions resemble the SH-4 ones. All others not 24 * Most of the SH-2A CCR1 definitions resemble the SH-4 ones. All others not
diff --git a/arch/sh/include/cpu-sh3/cpu/cache.h b/arch/sh/include/cpu-sh3/cpu/cache.h
index bee2d81c56bf..29700fd88c75 100644
--- a/arch/sh/include/cpu-sh3/cpu/cache.h
+++ b/arch/sh/include/cpu-sh3/cpu/cache.h
@@ -17,7 +17,7 @@
17#define SH_CACHE_COMBINED 4 17#define SH_CACHE_COMBINED 4
18#define SH_CACHE_ASSOC 8 18#define SH_CACHE_ASSOC 8
19 19
20#define CCR 0xffffffec /* Address of Cache Control Register */ 20#define SH_CCR 0xffffffec /* Address of Cache Control Register */
21 21
22#define CCR_CACHE_CE 0x01 /* Cache Enable */ 22#define CCR_CACHE_CE 0x01 /* Cache Enable */
23#define CCR_CACHE_WT 0x02 /* Write-Through (for P0,U0,P3) (else writeback) */ 23#define CCR_CACHE_WT 0x02 /* Write-Through (for P0,U0,P3) (else writeback) */
diff --git a/arch/sh/include/cpu-sh4/cpu/cache.h b/arch/sh/include/cpu-sh4/cpu/cache.h
index 7bfb9e8b069c..92c4cd119b66 100644
--- a/arch/sh/include/cpu-sh4/cpu/cache.h
+++ b/arch/sh/include/cpu-sh4/cpu/cache.h
@@ -17,7 +17,7 @@
17#define SH_CACHE_COMBINED 4 17#define SH_CACHE_COMBINED 4
18#define SH_CACHE_ASSOC 8 18#define SH_CACHE_ASSOC 8
19 19
20#define CCR 0xff00001c /* Address of Cache Control Register */ 20#define SH_CCR 0xff00001c /* Address of Cache Control Register */
21#define CCR_CACHE_OCE 0x0001 /* Operand Cache Enable */ 21#define CCR_CACHE_OCE 0x0001 /* Operand Cache Enable */
22#define CCR_CACHE_WT 0x0002 /* Write-Through (for P0,U0,P3) (else writeback)*/ 22#define CCR_CACHE_WT 0x0002 /* Write-Through (for P0,U0,P3) (else writeback)*/
23#define CCR_CACHE_CB 0x0004 /* Copy-Back (for P1) (else writethrough) */ 23#define CCR_CACHE_CB 0x0004 /* Copy-Back (for P1) (else writethrough) */
diff --git a/arch/sh/kernel/cpu/init.c b/arch/sh/kernel/cpu/init.c
index ecf83cd158dc..0d7360d549c1 100644
--- a/arch/sh/kernel/cpu/init.c
+++ b/arch/sh/kernel/cpu/init.c
@@ -112,7 +112,7 @@ static void cache_init(void)
112 unsigned long ccr, flags; 112 unsigned long ccr, flags;
113 113
114 jump_to_uncached(); 114 jump_to_uncached();
115 ccr = __raw_readl(CCR); 115 ccr = __raw_readl(SH_CCR);
116 116
117 /* 117 /*
118 * At this point we don't know whether the cache is enabled or not - a 118 * At this point we don't know whether the cache is enabled or not - a
@@ -189,7 +189,7 @@ static void cache_init(void)
189 189
190 l2_cache_init(); 190 l2_cache_init();
191 191
192 __raw_writel(flags, CCR); 192 __raw_writel(flags, SH_CCR);
193 back_to_cached(); 193 back_to_cached();
194} 194}
195#else 195#else
diff --git a/arch/sh/mm/cache-debugfs.c b/arch/sh/mm/cache-debugfs.c
index 115725198038..777e50f33c00 100644
--- a/arch/sh/mm/cache-debugfs.c
+++ b/arch/sh/mm/cache-debugfs.c
@@ -36,7 +36,7 @@ static int cache_seq_show(struct seq_file *file, void *iter)
36 */ 36 */
37 jump_to_uncached(); 37 jump_to_uncached();
38 38
39 ccr = __raw_readl(CCR); 39 ccr = __raw_readl(SH_CCR);
40 if ((ccr & CCR_CACHE_ENABLE) == 0) { 40 if ((ccr & CCR_CACHE_ENABLE) == 0) {
41 back_to_cached(); 41 back_to_cached();
42 42
diff --git a/arch/sh/mm/cache-sh2.c b/arch/sh/mm/cache-sh2.c
index defcf719f2e8..a74259f2f981 100644
--- a/arch/sh/mm/cache-sh2.c
+++ b/arch/sh/mm/cache-sh2.c
@@ -63,9 +63,9 @@ static void sh2__flush_invalidate_region(void *start, int size)
63 local_irq_save(flags); 63 local_irq_save(flags);
64 jump_to_uncached(); 64 jump_to_uncached();
65 65
66 ccr = __raw_readl(CCR); 66 ccr = __raw_readl(SH_CCR);
67 ccr |= CCR_CACHE_INVALIDATE; 67 ccr |= CCR_CACHE_INVALIDATE;
68 __raw_writel(ccr, CCR); 68 __raw_writel(ccr, SH_CCR);
69 69
70 back_to_cached(); 70 back_to_cached();
71 local_irq_restore(flags); 71 local_irq_restore(flags);
diff --git a/arch/sh/mm/cache-sh2a.c b/arch/sh/mm/cache-sh2a.c
index 949e2d3138a0..ee87d081259b 100644
--- a/arch/sh/mm/cache-sh2a.c
+++ b/arch/sh/mm/cache-sh2a.c
@@ -134,7 +134,8 @@ static void sh2a__flush_invalidate_region(void *start, int size)
134 134
135 /* If there are too many pages then just blow the cache */ 135 /* If there are too many pages then just blow the cache */
136 if (((end - begin) >> PAGE_SHIFT) >= MAX_OCACHE_PAGES) { 136 if (((end - begin) >> PAGE_SHIFT) >= MAX_OCACHE_PAGES) {
137 __raw_writel(__raw_readl(CCR) | CCR_OCACHE_INVALIDATE, CCR); 137 __raw_writel(__raw_readl(SH_CCR) | CCR_OCACHE_INVALIDATE,
138 SH_CCR);
138 } else { 139 } else {
139 for (v = begin; v < end; v += L1_CACHE_BYTES) 140 for (v = begin; v < end; v += L1_CACHE_BYTES)
140 sh2a_invalidate_line(CACHE_OC_ADDRESS_ARRAY, v); 141 sh2a_invalidate_line(CACHE_OC_ADDRESS_ARRAY, v);
@@ -167,7 +168,8 @@ static void sh2a_flush_icache_range(void *args)
167 /* I-Cache invalidate */ 168 /* I-Cache invalidate */
168 /* If there are too many pages then just blow the cache */ 169 /* If there are too many pages then just blow the cache */
169 if (((end - start) >> PAGE_SHIFT) >= MAX_ICACHE_PAGES) { 170 if (((end - start) >> PAGE_SHIFT) >= MAX_ICACHE_PAGES) {
170 __raw_writel(__raw_readl(CCR) | CCR_ICACHE_INVALIDATE, CCR); 171 __raw_writel(__raw_readl(SH_CCR) | CCR_ICACHE_INVALIDATE,
172 SH_CCR);
171 } else { 173 } else {
172 for (v = start; v < end; v += L1_CACHE_BYTES) 174 for (v = start; v < end; v += L1_CACHE_BYTES)
173 sh2a_invalidate_line(CACHE_IC_ADDRESS_ARRAY, v); 175 sh2a_invalidate_line(CACHE_IC_ADDRESS_ARRAY, v);
diff --git a/arch/sh/mm/cache-sh4.c b/arch/sh/mm/cache-sh4.c
index 0e529285b28d..51d8f7f31d1d 100644
--- a/arch/sh/mm/cache-sh4.c
+++ b/arch/sh/mm/cache-sh4.c
@@ -133,9 +133,9 @@ static void flush_icache_all(void)
133 jump_to_uncached(); 133 jump_to_uncached();
134 134
135 /* Flush I-cache */ 135 /* Flush I-cache */
136 ccr = __raw_readl(CCR); 136 ccr = __raw_readl(SH_CCR);
137 ccr |= CCR_CACHE_ICI; 137 ccr |= CCR_CACHE_ICI;
138 __raw_writel(ccr, CCR); 138 __raw_writel(ccr, SH_CCR);
139 139
140 /* 140 /*
141 * back_to_cached() will take care of the barrier for us, don't add 141 * back_to_cached() will take care of the barrier for us, don't add
diff --git a/arch/sh/mm/cache-shx3.c b/arch/sh/mm/cache-shx3.c
index c0adbee97b5f..24c58b7dc022 100644
--- a/arch/sh/mm/cache-shx3.c
+++ b/arch/sh/mm/cache-shx3.c
@@ -19,7 +19,7 @@ void __init shx3_cache_init(void)
19{ 19{
20 unsigned int ccr; 20 unsigned int ccr;
21 21
22 ccr = __raw_readl(CCR); 22 ccr = __raw_readl(SH_CCR);
23 23
24 /* 24 /*
25 * If we've got cache aliases, resolve them in hardware. 25 * If we've got cache aliases, resolve them in hardware.
@@ -40,5 +40,5 @@ void __init shx3_cache_init(void)
40 ccr |= CCR_CACHE_IBE; 40 ccr |= CCR_CACHE_IBE;
41#endif 41#endif
42 42
43 writel_uncached(ccr, CCR); 43 writel_uncached(ccr, SH_CCR);
44} 44}
diff --git a/arch/sh/mm/cache.c b/arch/sh/mm/cache.c
index 616966a96cba..097c2cdd117f 100644
--- a/arch/sh/mm/cache.c
+++ b/arch/sh/mm/cache.c
@@ -285,8 +285,8 @@ void __init cpu_cache_init(void)
285{ 285{
286 unsigned int cache_disabled = 0; 286 unsigned int cache_disabled = 0;
287 287
288#ifdef CCR 288#ifdef SH_CCR
289 cache_disabled = !(__raw_readl(CCR) & CCR_CACHE_ENABLE); 289 cache_disabled = !(__raw_readl(SH_CCR) & CCR_CACHE_ENABLE);
290#endif 290#endif
291 291
292 compute_alias(&boot_cpu_data.icache); 292 compute_alias(&boot_cpu_data.icache);
diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index c51efdcd07a2..7d8b7e94b93b 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -27,7 +27,7 @@ config SPARC
27 select RTC_DRV_M48T59 27 select RTC_DRV_M48T59
28 select HAVE_DMA_ATTRS 28 select HAVE_DMA_ATTRS
29 select HAVE_DMA_API_DEBUG 29 select HAVE_DMA_API_DEBUG
30 select HAVE_ARCH_JUMP_LABEL 30 select HAVE_ARCH_JUMP_LABEL if SPARC64
31 select GENERIC_IRQ_SHOW 31 select GENERIC_IRQ_SHOW
32 select ARCH_WANT_IPC_PARSE_VERSION 32 select ARCH_WANT_IPC_PARSE_VERSION
33 select GENERIC_PCI_IOMAP 33 select GENERIC_PCI_IOMAP
diff --git a/arch/sparc/mm/srmmu.c b/arch/sparc/mm/srmmu.c
index 869023abe5a4..cfbe53c17b0d 100644
--- a/arch/sparc/mm/srmmu.c
+++ b/arch/sparc/mm/srmmu.c
@@ -14,6 +14,7 @@
14#include <linux/pagemap.h> 14#include <linux/pagemap.h>
15#include <linux/vmalloc.h> 15#include <linux/vmalloc.h>
16#include <linux/kdebug.h> 16#include <linux/kdebug.h>
17#include <linux/export.h>
17#include <linux/kernel.h> 18#include <linux/kernel.h>
18#include <linux/init.h> 19#include <linux/init.h>
19#include <linux/log2.h> 20#include <linux/log2.h>
@@ -62,6 +63,7 @@ extern unsigned long last_valid_pfn;
62static pgd_t *srmmu_swapper_pg_dir; 63static pgd_t *srmmu_swapper_pg_dir;
63 64
64const struct sparc32_cachetlb_ops *sparc32_cachetlb_ops; 65const struct sparc32_cachetlb_ops *sparc32_cachetlb_ops;
66EXPORT_SYMBOL(sparc32_cachetlb_ops);
65 67
66#ifdef CONFIG_SMP 68#ifdef CONFIG_SMP
67const struct sparc32_cachetlb_ops *local_ops; 69const struct sparc32_cachetlb_ops *local_ops;
diff --git a/arch/x86/boot/compressed/aslr.c b/arch/x86/boot/compressed/aslr.c
index 90a21f430117..4dbf967da50d 100644
--- a/arch/x86/boot/compressed/aslr.c
+++ b/arch/x86/boot/compressed/aslr.c
@@ -111,7 +111,7 @@ struct mem_vector {
111}; 111};
112 112
113#define MEM_AVOID_MAX 5 113#define MEM_AVOID_MAX 5
114struct mem_vector mem_avoid[MEM_AVOID_MAX]; 114static struct mem_vector mem_avoid[MEM_AVOID_MAX];
115 115
116static bool mem_contains(struct mem_vector *region, struct mem_vector *item) 116static bool mem_contains(struct mem_vector *region, struct mem_vector *item)
117{ 117{
@@ -180,7 +180,7 @@ static void mem_avoid_init(unsigned long input, unsigned long input_size,
180} 180}
181 181
182/* Does this memory vector overlap a known avoided area? */ 182/* Does this memory vector overlap a known avoided area? */
183bool mem_avoid_overlap(struct mem_vector *img) 183static bool mem_avoid_overlap(struct mem_vector *img)
184{ 184{
185 int i; 185 int i;
186 186
@@ -192,8 +192,9 @@ bool mem_avoid_overlap(struct mem_vector *img)
192 return false; 192 return false;
193} 193}
194 194
195unsigned long slots[CONFIG_RANDOMIZE_BASE_MAX_OFFSET / CONFIG_PHYSICAL_ALIGN]; 195static unsigned long slots[CONFIG_RANDOMIZE_BASE_MAX_OFFSET /
196unsigned long slot_max = 0; 196 CONFIG_PHYSICAL_ALIGN];
197static unsigned long slot_max;
197 198
198static void slots_append(unsigned long addr) 199static void slots_append(unsigned long addr)
199{ 200{
diff --git a/arch/x86/include/asm/tsc.h b/arch/x86/include/asm/tsc.h
index 57ae63cd6ee2..94605c0e9cee 100644
--- a/arch/x86/include/asm/tsc.h
+++ b/arch/x86/include/asm/tsc.h
@@ -66,6 +66,6 @@ extern void tsc_save_sched_clock_state(void);
66extern void tsc_restore_sched_clock_state(void); 66extern void tsc_restore_sched_clock_state(void);
67 67
68/* MSR based TSC calibration for Intel Atom SoC platforms */ 68/* MSR based TSC calibration for Intel Atom SoC platforms */
69int try_msr_calibrate_tsc(unsigned long *fast_calibrate); 69unsigned long try_msr_calibrate_tsc(void);
70 70
71#endif /* _ASM_X86_TSC_H */ 71#endif /* _ASM_X86_TSC_H */
diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
index b88645191fe5..79f9f848bee4 100644
--- a/arch/x86/kernel/cpu/perf_event.c
+++ b/arch/x86/kernel/cpu/perf_event.c
@@ -1192,6 +1192,9 @@ static void x86_pmu_del(struct perf_event *event, int flags)
1192 for (i = 0; i < cpuc->n_events; i++) { 1192 for (i = 0; i < cpuc->n_events; i++) {
1193 if (event == cpuc->event_list[i]) { 1193 if (event == cpuc->event_list[i]) {
1194 1194
1195 if (i >= cpuc->n_events - cpuc->n_added)
1196 --cpuc->n_added;
1197
1195 if (x86_pmu.put_event_constraints) 1198 if (x86_pmu.put_event_constraints)
1196 x86_pmu.put_event_constraints(cpuc, event); 1199 x86_pmu.put_event_constraints(cpuc, event);
1197 1200
@@ -1521,6 +1524,8 @@ static int __init init_hw_perf_events(void)
1521 1524
1522 pr_cont("%s PMU driver.\n", x86_pmu.name); 1525 pr_cont("%s PMU driver.\n", x86_pmu.name);
1523 1526
1527 x86_pmu.attr_rdpmc = 1; /* enable userspace RDPMC usage by default */
1528
1524 for (quirk = x86_pmu.quirks; quirk; quirk = quirk->next) 1529 for (quirk = x86_pmu.quirks; quirk; quirk = quirk->next)
1525 quirk->func(); 1530 quirk->func();
1526 1531
@@ -1534,7 +1539,6 @@ static int __init init_hw_perf_events(void)
1534 __EVENT_CONSTRAINT(0, (1ULL << x86_pmu.num_counters) - 1, 1539 __EVENT_CONSTRAINT(0, (1ULL << x86_pmu.num_counters) - 1,
1535 0, x86_pmu.num_counters, 0, 0); 1540 0, x86_pmu.num_counters, 0, 0);
1536 1541
1537 x86_pmu.attr_rdpmc = 1; /* enable userspace RDPMC usage by default */
1538 x86_pmu_format_group.attrs = x86_pmu.format_attrs; 1542 x86_pmu_format_group.attrs = x86_pmu.format_attrs;
1539 1543
1540 if (x86_pmu.event_attrs) 1544 if (x86_pmu.event_attrs)
@@ -1820,9 +1824,12 @@ static ssize_t set_attr_rdpmc(struct device *cdev,
1820 if (ret) 1824 if (ret)
1821 return ret; 1825 return ret;
1822 1826
1827 if (x86_pmu.attr_rdpmc_broken)
1828 return -ENOTSUPP;
1829
1823 if (!!val != !!x86_pmu.attr_rdpmc) { 1830 if (!!val != !!x86_pmu.attr_rdpmc) {
1824 x86_pmu.attr_rdpmc = !!val; 1831 x86_pmu.attr_rdpmc = !!val;
1825 smp_call_function(change_rdpmc, (void *)val, 1); 1832 on_each_cpu(change_rdpmc, (void *)val, 1);
1826 } 1833 }
1827 1834
1828 return count; 1835 return count;
diff --git a/arch/x86/kernel/cpu/perf_event.h b/arch/x86/kernel/cpu/perf_event.h
index c1a861829d81..4972c244d0bc 100644
--- a/arch/x86/kernel/cpu/perf_event.h
+++ b/arch/x86/kernel/cpu/perf_event.h
@@ -409,6 +409,7 @@ struct x86_pmu {
409 /* 409 /*
410 * sysfs attrs 410 * sysfs attrs
411 */ 411 */
412 int attr_rdpmc_broken;
412 int attr_rdpmc; 413 int attr_rdpmc;
413 struct attribute **format_attrs; 414 struct attribute **format_attrs;
414 struct attribute **event_attrs; 415 struct attribute **event_attrs;
diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
index 0fa4f242f050..aa333d966886 100644
--- a/arch/x86/kernel/cpu/perf_event_intel.c
+++ b/arch/x86/kernel/cpu/perf_event_intel.c
@@ -1361,10 +1361,8 @@ static int intel_pmu_handle_irq(struct pt_regs *regs)
1361 intel_pmu_disable_all(); 1361 intel_pmu_disable_all();
1362 handled = intel_pmu_drain_bts_buffer(); 1362 handled = intel_pmu_drain_bts_buffer();
1363 status = intel_pmu_get_status(); 1363 status = intel_pmu_get_status();
1364 if (!status) { 1364 if (!status)
1365 intel_pmu_enable_all(0); 1365 goto done;
1366 return handled;
1367 }
1368 1366
1369 loops = 0; 1367 loops = 0;
1370again: 1368again:
@@ -2310,10 +2308,7 @@ __init int intel_pmu_init(void)
2310 if (version > 1) 2308 if (version > 1)
2311 x86_pmu.num_counters_fixed = max((int)edx.split.num_counters_fixed, 3); 2309 x86_pmu.num_counters_fixed = max((int)edx.split.num_counters_fixed, 3);
2312 2310
2313 /* 2311 if (boot_cpu_has(X86_FEATURE_PDCM)) {
2314 * v2 and above have a perf capabilities MSR
2315 */
2316 if (version > 1) {
2317 u64 capabilities; 2312 u64 capabilities;
2318 2313
2319 rdmsrl(MSR_IA32_PERF_CAPABILITIES, capabilities); 2314 rdmsrl(MSR_IA32_PERF_CAPABILITIES, capabilities);
diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
index 29c248799ced..c88f7f4b03ee 100644
--- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
+++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
@@ -501,8 +501,11 @@ static struct extra_reg snbep_uncore_cbox_extra_regs[] = {
501 SNBEP_CBO_EVENT_EXTRA_REG(SNBEP_CBO_PMON_CTL_TID_EN, 501 SNBEP_CBO_EVENT_EXTRA_REG(SNBEP_CBO_PMON_CTL_TID_EN,
502 SNBEP_CBO_PMON_CTL_TID_EN, 0x1), 502 SNBEP_CBO_PMON_CTL_TID_EN, 0x1),
503 SNBEP_CBO_EVENT_EXTRA_REG(0x0334, 0xffff, 0x4), 503 SNBEP_CBO_EVENT_EXTRA_REG(0x0334, 0xffff, 0x4),
504 SNBEP_CBO_EVENT_EXTRA_REG(0x4334, 0xffff, 0x6),
504 SNBEP_CBO_EVENT_EXTRA_REG(0x0534, 0xffff, 0x4), 505 SNBEP_CBO_EVENT_EXTRA_REG(0x0534, 0xffff, 0x4),
506 SNBEP_CBO_EVENT_EXTRA_REG(0x4534, 0xffff, 0x6),
505 SNBEP_CBO_EVENT_EXTRA_REG(0x0934, 0xffff, 0x4), 507 SNBEP_CBO_EVENT_EXTRA_REG(0x0934, 0xffff, 0x4),
508 SNBEP_CBO_EVENT_EXTRA_REG(0x4934, 0xffff, 0x6),
506 SNBEP_CBO_EVENT_EXTRA_REG(0x4134, 0xffff, 0x6), 509 SNBEP_CBO_EVENT_EXTRA_REG(0x4134, 0xffff, 0x6),
507 SNBEP_CBO_EVENT_EXTRA_REG(0x0135, 0xffff, 0x8), 510 SNBEP_CBO_EVENT_EXTRA_REG(0x0135, 0xffff, 0x8),
508 SNBEP_CBO_EVENT_EXTRA_REG(0x0335, 0xffff, 0x8), 511 SNBEP_CBO_EVENT_EXTRA_REG(0x0335, 0xffff, 0x8),
@@ -1178,10 +1181,15 @@ static struct extra_reg ivt_uncore_cbox_extra_regs[] = {
1178 SNBEP_CBO_EVENT_EXTRA_REG(SNBEP_CBO_PMON_CTL_TID_EN, 1181 SNBEP_CBO_EVENT_EXTRA_REG(SNBEP_CBO_PMON_CTL_TID_EN,
1179 SNBEP_CBO_PMON_CTL_TID_EN, 0x1), 1182 SNBEP_CBO_PMON_CTL_TID_EN, 0x1),
1180 SNBEP_CBO_EVENT_EXTRA_REG(0x1031, 0x10ff, 0x2), 1183 SNBEP_CBO_EVENT_EXTRA_REG(0x1031, 0x10ff, 0x2),
1184 SNBEP_CBO_EVENT_EXTRA_REG(0x1134, 0xffff, 0x4),
1185 SNBEP_CBO_EVENT_EXTRA_REG(0x4134, 0xffff, 0xc),
1186 SNBEP_CBO_EVENT_EXTRA_REG(0x5134, 0xffff, 0xc),
1181 SNBEP_CBO_EVENT_EXTRA_REG(0x0334, 0xffff, 0x4), 1187 SNBEP_CBO_EVENT_EXTRA_REG(0x0334, 0xffff, 0x4),
1188 SNBEP_CBO_EVENT_EXTRA_REG(0x4334, 0xffff, 0xc),
1182 SNBEP_CBO_EVENT_EXTRA_REG(0x0534, 0xffff, 0x4), 1189 SNBEP_CBO_EVENT_EXTRA_REG(0x0534, 0xffff, 0x4),
1190 SNBEP_CBO_EVENT_EXTRA_REG(0x4534, 0xffff, 0xc),
1183 SNBEP_CBO_EVENT_EXTRA_REG(0x0934, 0xffff, 0x4), 1191 SNBEP_CBO_EVENT_EXTRA_REG(0x0934, 0xffff, 0x4),
1184 SNBEP_CBO_EVENT_EXTRA_REG(0x4134, 0xffff, 0xc), 1192 SNBEP_CBO_EVENT_EXTRA_REG(0x4934, 0xffff, 0xc),
1185 SNBEP_CBO_EVENT_EXTRA_REG(0x0135, 0xffff, 0x10), 1193 SNBEP_CBO_EVENT_EXTRA_REG(0x0135, 0xffff, 0x10),
1186 SNBEP_CBO_EVENT_EXTRA_REG(0x0335, 0xffff, 0x10), 1194 SNBEP_CBO_EVENT_EXTRA_REG(0x0335, 0xffff, 0x10),
1187 SNBEP_CBO_EVENT_EXTRA_REG(0x2135, 0xffff, 0x10), 1195 SNBEP_CBO_EVENT_EXTRA_REG(0x2135, 0xffff, 0x10),
diff --git a/arch/x86/kernel/cpu/perf_event_p6.c b/arch/x86/kernel/cpu/perf_event_p6.c
index b1e2fe115323..7c1a0c07b607 100644
--- a/arch/x86/kernel/cpu/perf_event_p6.c
+++ b/arch/x86/kernel/cpu/perf_event_p6.c
@@ -231,31 +231,49 @@ static __initconst const struct x86_pmu p6_pmu = {
231 231
232}; 232};
233 233
234static __init void p6_pmu_rdpmc_quirk(void)
235{
236 if (boot_cpu_data.x86_mask < 9) {
237 /*
238 * PPro erratum 26; fixed in stepping 9 and above.
239 */
240 pr_warn("Userspace RDPMC support disabled due to a CPU erratum\n");
241 x86_pmu.attr_rdpmc_broken = 1;
242 x86_pmu.attr_rdpmc = 0;
243 }
244}
245
234__init int p6_pmu_init(void) 246__init int p6_pmu_init(void)
235{ 247{
248 x86_pmu = p6_pmu;
249
236 switch (boot_cpu_data.x86_model) { 250 switch (boot_cpu_data.x86_model) {
237 case 1: 251 case 1: /* Pentium Pro */
238 case 3: /* Pentium Pro */ 252 x86_add_quirk(p6_pmu_rdpmc_quirk);
239 case 5: 253 break;
240 case 6: /* Pentium II */ 254
241 case 7: 255 case 3: /* Pentium II - Klamath */
242 case 8: 256 case 5: /* Pentium II - Deschutes */
243 case 11: /* Pentium III */ 257 case 6: /* Pentium II - Mendocino */
244 case 9:
245 case 13:
246 /* Pentium M */
247 break; 258 break;
259
260 case 7: /* Pentium III - Katmai */
261 case 8: /* Pentium III - Coppermine */
262 case 10: /* Pentium III Xeon */
263 case 11: /* Pentium III - Tualatin */
264 break;
265
266 case 9: /* Pentium M - Banias */
267 case 13: /* Pentium M - Dothan */
268 break;
269
248 default: 270 default:
249 pr_cont("unsupported p6 CPU model %d ", 271 pr_cont("unsupported p6 CPU model %d ", boot_cpu_data.x86_model);
250 boot_cpu_data.x86_model);
251 return -ENODEV; 272 return -ENODEV;
252 } 273 }
253 274
254 x86_pmu = p6_pmu;
255
256 memcpy(hw_cache_event_ids, p6_hw_cache_event_ids, 275 memcpy(hw_cache_event_ids, p6_hw_cache_event_ids,
257 sizeof(hw_cache_event_ids)); 276 sizeof(hw_cache_event_ids));
258 277
259
260 return 0; 278 return 0;
261} 279}
diff --git a/arch/x86/kernel/machine_kexec_64.c b/arch/x86/kernel/machine_kexec_64.c
index 4eabc160696f..679cef0791cd 100644
--- a/arch/x86/kernel/machine_kexec_64.c
+++ b/arch/x86/kernel/machine_kexec_64.c
@@ -279,5 +279,7 @@ void arch_crash_save_vmcoreinfo(void)
279 VMCOREINFO_SYMBOL(node_data); 279 VMCOREINFO_SYMBOL(node_data);
280 VMCOREINFO_LENGTH(node_data, MAX_NUMNODES); 280 VMCOREINFO_LENGTH(node_data, MAX_NUMNODES);
281#endif 281#endif
282 vmcoreinfo_append_str("KERNELOFFSET=%lx\n",
283 (unsigned long)&_text - __START_KERNEL);
282} 284}
283 285
diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c
index 872079a67e4d..f7d0672481fd 100644
--- a/arch/x86/kernel/pci-dma.c
+++ b/arch/x86/kernel/pci-dma.c
@@ -100,8 +100,10 @@ void *dma_generic_alloc_coherent(struct device *dev, size_t size,
100 flag |= __GFP_ZERO; 100 flag |= __GFP_ZERO;
101again: 101again:
102 page = NULL; 102 page = NULL;
103 if (!(flag & GFP_ATOMIC)) 103 /* CMA can be used only in the context which permits sleeping */
104 if (flag & __GFP_WAIT)
104 page = dma_alloc_from_contiguous(dev, count, get_order(size)); 105 page = dma_alloc_from_contiguous(dev, count, get_order(size));
106 /* fallback */
105 if (!page) 107 if (!page)
106 page = alloc_pages_node(dev_to_node(dev), flag, get_order(size)); 108 page = alloc_pages_node(dev_to_node(dev), flag, get_order(size));
107 if (!page) 109 if (!page)
diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
index acb3b606613e..cfbe99f88830 100644
--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -653,13 +653,10 @@ unsigned long native_calibrate_tsc(void)
653 653
654 /* Calibrate TSC using MSR for Intel Atom SoCs */ 654 /* Calibrate TSC using MSR for Intel Atom SoCs */
655 local_irq_save(flags); 655 local_irq_save(flags);
656 i = try_msr_calibrate_tsc(&fast_calibrate); 656 fast_calibrate = try_msr_calibrate_tsc();
657 local_irq_restore(flags); 657 local_irq_restore(flags);
658 if (i >= 0) { 658 if (fast_calibrate)
659 if (i == 0)
660 pr_warn("Fast TSC calibration using MSR failed\n");
661 return fast_calibrate; 659 return fast_calibrate;
662 }
663 660
664 local_irq_save(flags); 661 local_irq_save(flags);
665 fast_calibrate = quick_pit_calibrate(); 662 fast_calibrate = quick_pit_calibrate();
diff --git a/arch/x86/kernel/tsc_msr.c b/arch/x86/kernel/tsc_msr.c
index 8b5434f4389f..92ae6acac8a7 100644
--- a/arch/x86/kernel/tsc_msr.c
+++ b/arch/x86/kernel/tsc_msr.c
@@ -53,7 +53,7 @@ static struct freq_desc freq_desc_tables[] = {
53 /* TNG */ 53 /* TNG */
54 { 6, 0x4a, 1, { 0, FREQ_100, FREQ_133, 0, 0, 0, 0, 0 } }, 54 { 6, 0x4a, 1, { 0, FREQ_100, FREQ_133, 0, 0, 0, 0, 0 } },
55 /* VLV2 */ 55 /* VLV2 */
56 { 6, 0x37, 1, { 0, FREQ_100, FREQ_133, FREQ_166, 0, 0, 0, 0 } }, 56 { 6, 0x37, 1, { FREQ_83, FREQ_100, FREQ_133, FREQ_166, 0, 0, 0, 0 } },
57 /* ANN */ 57 /* ANN */
58 { 6, 0x5a, 1, { FREQ_83, FREQ_100, FREQ_133, FREQ_100, 0, 0, 0, 0 } }, 58 { 6, 0x5a, 1, { FREQ_83, FREQ_100, FREQ_133, FREQ_100, 0, 0, 0, 0 } },
59}; 59};
@@ -77,21 +77,18 @@ static int match_cpu(u8 family, u8 model)
77 77
78/* 78/*
79 * Do MSR calibration only for known/supported CPUs. 79 * Do MSR calibration only for known/supported CPUs.
80 * Return values: 80 *
81 * -1: CPU is unknown/unsupported for MSR based calibration 81 * Returns the calibration value or 0 if MSR calibration failed.
82 * 0: CPU is known/supported, but calibration failed
83 * 1: CPU is known/supported, and calibration succeeded
84 */ 82 */
85int try_msr_calibrate_tsc(unsigned long *fast_calibrate) 83unsigned long try_msr_calibrate_tsc(void)
86{ 84{
87 int cpu_index;
88 u32 lo, hi, ratio, freq_id, freq; 85 u32 lo, hi, ratio, freq_id, freq;
86 unsigned long res;
87 int cpu_index;
89 88
90 cpu_index = match_cpu(boot_cpu_data.x86, boot_cpu_data.x86_model); 89 cpu_index = match_cpu(boot_cpu_data.x86, boot_cpu_data.x86_model);
91 if (cpu_index < 0) 90 if (cpu_index < 0)
92 return -1; 91 return 0;
93
94 *fast_calibrate = 0;
95 92
96 if (freq_desc_tables[cpu_index].msr_plat) { 93 if (freq_desc_tables[cpu_index].msr_plat) {
97 rdmsr(MSR_PLATFORM_INFO, lo, hi); 94 rdmsr(MSR_PLATFORM_INFO, lo, hi);
@@ -103,7 +100,7 @@ int try_msr_calibrate_tsc(unsigned long *fast_calibrate)
103 pr_info("Maximum core-clock to bus-clock ratio: 0x%x\n", ratio); 100 pr_info("Maximum core-clock to bus-clock ratio: 0x%x\n", ratio);
104 101
105 if (!ratio) 102 if (!ratio)
106 return 0; 103 goto fail;
107 104
108 /* Get FSB FREQ ID */ 105 /* Get FSB FREQ ID */
109 rdmsr(MSR_FSB_FREQ, lo, hi); 106 rdmsr(MSR_FSB_FREQ, lo, hi);
@@ -112,16 +109,19 @@ int try_msr_calibrate_tsc(unsigned long *fast_calibrate)
112 pr_info("Resolved frequency ID: %u, frequency: %u KHz\n", 109 pr_info("Resolved frequency ID: %u, frequency: %u KHz\n",
113 freq_id, freq); 110 freq_id, freq);
114 if (!freq) 111 if (!freq)
115 return 0; 112 goto fail;
116 113
117 /* TSC frequency = maximum resolved freq * maximum resolved bus ratio */ 114 /* TSC frequency = maximum resolved freq * maximum resolved bus ratio */
118 *fast_calibrate = freq * ratio; 115 res = freq * ratio;
119 pr_info("TSC runs at %lu KHz\n", *fast_calibrate); 116 pr_info("TSC runs at %lu KHz\n", res);
120 117
121#ifdef CONFIG_X86_LOCAL_APIC 118#ifdef CONFIG_X86_LOCAL_APIC
122 lapic_timer_frequency = (freq * 1000) / HZ; 119 lapic_timer_frequency = (freq * 1000) / HZ;
123 pr_info("lapic_timer_frequency = %d\n", lapic_timer_frequency); 120 pr_info("lapic_timer_frequency = %d\n", lapic_timer_frequency);
124#endif 121#endif
122 return res;
125 123
126 return 1; 124fail:
125 pr_warn("Fast TSC calibration using MSR failed\n");
126 return 0;
127} 127}
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index e50425d0f5f7..9b531351a587 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -2672,6 +2672,7 @@ static int __direct_map(struct kvm_vcpu *vcpu, gpa_t v, int write,
2672 break; 2672 break;
2673 } 2673 }
2674 2674
2675 drop_large_spte(vcpu, iterator.sptep);
2675 if (!is_shadow_present_pte(*iterator.sptep)) { 2676 if (!is_shadow_present_pte(*iterator.sptep)) {
2676 u64 base_addr = iterator.addr; 2677 u64 base_addr = iterator.addr;
2677 2678
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index a06f101ef64b..392752834751 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -6688,7 +6688,7 @@ static bool nested_vmx_exit_handled(struct kvm_vcpu *vcpu)
6688 else if (is_page_fault(intr_info)) 6688 else if (is_page_fault(intr_info))
6689 return enable_ept; 6689 return enable_ept;
6690 else if (is_no_device(intr_info) && 6690 else if (is_no_device(intr_info) &&
6691 !(nested_read_cr0(vmcs12) & X86_CR0_TS)) 6691 !(vmcs12->guest_cr0 & X86_CR0_TS))
6692 return 0; 6692 return 0;
6693 return vmcs12->exception_bitmap & 6693 return vmcs12->exception_bitmap &
6694 (1u << (intr_info & INTR_INFO_VECTOR_MASK)); 6694 (1u << (intr_info & INTR_INFO_VECTOR_MASK));
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 39c28f09dfd5..2b8578432d5b 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -6186,7 +6186,7 @@ static int complete_emulated_mmio(struct kvm_vcpu *vcpu)
6186 frag->len -= len; 6186 frag->len -= len;
6187 } 6187 }
6188 6188
6189 if (vcpu->mmio_cur_fragment == vcpu->mmio_nr_fragments) { 6189 if (vcpu->mmio_cur_fragment >= vcpu->mmio_nr_fragments) {
6190 vcpu->mmio_needed = 0; 6190 vcpu->mmio_needed = 0;
6191 6191
6192 /* FIXME: return into emulator if single-stepping. */ 6192 /* FIXME: return into emulator if single-stepping. */
diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig
index ba56e11cbf77..c87ae7c6e5f9 100644
--- a/arch/xtensa/Kconfig
+++ b/arch/xtensa/Kconfig
@@ -20,6 +20,7 @@ config XTENSA
20 select HAVE_FUNCTION_TRACER 20 select HAVE_FUNCTION_TRACER
21 select HAVE_IRQ_TIME_ACCOUNTING 21 select HAVE_IRQ_TIME_ACCOUNTING
22 select HAVE_PERF_EVENTS 22 select HAVE_PERF_EVENTS
23 select COMMON_CLK
23 help 24 help
24 Xtensa processors are 32-bit RISC machines designed by Tensilica 25 Xtensa processors are 32-bit RISC machines designed by Tensilica
25 primarily for embedded systems. These processors are both 26 primarily for embedded systems. These processors are both
@@ -80,7 +81,6 @@ choice
80config XTENSA_VARIANT_FSF 81config XTENSA_VARIANT_FSF
81 bool "fsf - default (not generic) configuration" 82 bool "fsf - default (not generic) configuration"
82 select MMU 83 select MMU
83 select HAVE_XTENSA_GPIO32
84 84
85config XTENSA_VARIANT_DC232B 85config XTENSA_VARIANT_DC232B
86 bool "dc232b - Diamond 232L Standard Core Rev.B (LE)" 86 bool "dc232b - Diamond 232L Standard Core Rev.B (LE)"
@@ -135,7 +135,6 @@ config HAVE_SMP
135config SMP 135config SMP
136 bool "Enable Symmetric multi-processing support" 136 bool "Enable Symmetric multi-processing support"
137 depends on HAVE_SMP 137 depends on HAVE_SMP
138 select USE_GENERIC_SMP_HELPERS
139 select GENERIC_SMP_IDLE_THREAD 138 select GENERIC_SMP_IDLE_THREAD
140 help 139 help
141 Enabled SMP Software; allows more than one CPU/CORE 140 Enabled SMP Software; allows more than one CPU/CORE
diff --git a/arch/xtensa/boot/dts/xtfpga.dtsi b/arch/xtensa/boot/dts/xtfpga.dtsi
index 46b4f5eab421..e7370b11348e 100644
--- a/arch/xtensa/boot/dts/xtfpga.dtsi
+++ b/arch/xtensa/boot/dts/xtfpga.dtsi
@@ -35,6 +35,13 @@
35 interrupt-controller; 35 interrupt-controller;
36 }; 36 };
37 37
38 clocks {
39 osc: main-oscillator {
40 #clock-cells = <0>;
41 compatible = "fixed-clock";
42 };
43 };
44
38 serial0: serial@fd050020 { 45 serial0: serial@fd050020 {
39 device_type = "serial"; 46 device_type = "serial";
40 compatible = "ns16550a"; 47 compatible = "ns16550a";
@@ -42,9 +49,7 @@
42 reg = <0xfd050020 0x20>; 49 reg = <0xfd050020 0x20>;
43 reg-shift = <2>; 50 reg-shift = <2>;
44 interrupts = <0 1>; /* external irq 0 */ 51 interrupts = <0 1>; /* external irq 0 */
45 /* Filled in by platform_setup from FPGA register 52 clocks = <&osc>;
46 * clock-frequency = <100000000>;
47 */
48 }; 53 };
49 54
50 enet0: ethoc@fd030000 { 55 enet0: ethoc@fd030000 {
@@ -52,5 +57,6 @@
52 reg = <0xfd030000 0x4000 0xfd800000 0x4000>; 57 reg = <0xfd030000 0x4000 0xfd800000 0x4000>;
53 interrupts = <1 1>; /* external irq 1 */ 58 interrupts = <1 1>; /* external irq 1 */
54 local-mac-address = [00 50 c2 13 6f 00]; 59 local-mac-address = [00 50 c2 13 6f 00];
60 clocks = <&osc>;
55 }; 61 };
56}; 62};
diff --git a/arch/xtensa/include/asm/io.h b/arch/xtensa/include/asm/io.h
index 2a042d430c25..74944207167e 100644
--- a/arch/xtensa/include/asm/io.h
+++ b/arch/xtensa/include/asm/io.h
@@ -25,7 +25,7 @@
25 25
26#ifdef CONFIG_MMU 26#ifdef CONFIG_MMU
27 27
28#if XCHAL_HAVE_PTP_MMU && XCHAL_HAVE_SPANNING_WAY && CONFIG_OF 28#if XCHAL_HAVE_PTP_MMU && XCHAL_HAVE_SPANNING_WAY && defined(CONFIG_OF)
29extern unsigned long xtensa_kio_paddr; 29extern unsigned long xtensa_kio_paddr;
30 30
31static inline unsigned long xtensa_get_kio_paddr(void) 31static inline unsigned long xtensa_get_kio_paddr(void)
diff --git a/arch/xtensa/include/asm/traps.h b/arch/xtensa/include/asm/traps.h
index 8c194f6af45e..677bfcf4ee5d 100644
--- a/arch/xtensa/include/asm/traps.h
+++ b/arch/xtensa/include/asm/traps.h
@@ -23,25 +23,37 @@ void secondary_trap_init(void);
23 23
24static inline void spill_registers(void) 24static inline void spill_registers(void)
25{ 25{
26 26#if XCHAL_NUM_AREGS > 16
27 __asm__ __volatile__ ( 27 __asm__ __volatile__ (
28 "movi a14, "__stringify((1 << PS_EXCM_BIT) | LOCKLEVEL)"\n\t" 28 " call12 1f\n"
29 "mov a12, a0\n\t" 29 " _j 2f\n"
30 "rsr a13, sar\n\t" 30 " retw\n"
31 "xsr a14, ps\n\t" 31 " .align 4\n"
32 "movi a0, _spill_registers\n\t" 32 "1:\n"
33 "rsync\n\t" 33 " _entry a1, 48\n"
34 "callx0 a0\n\t" 34 " addi a12, a0, 3\n"
35 "mov a0, a12\n\t" 35#if XCHAL_NUM_AREGS > 32
36 "wsr a13, sar\n\t" 36 " .rept (" __stringify(XCHAL_NUM_AREGS) " - 32) / 12\n"
37 "wsr a14, ps\n\t" 37 " _entry a1, 48\n"
38 : : 38 " mov a12, a0\n"
39#if defined(CONFIG_FRAME_POINTER) 39 " .endr\n"
40 : "a2", "a3", "a4", "a11", "a12", "a13", "a14", "a15", 40#endif
41 " _entry a1, 48\n"
42#if XCHAL_NUM_AREGS % 12 == 0
43 " mov a8, a8\n"
44#elif XCHAL_NUM_AREGS % 12 == 4
45 " mov a12, a12\n"
46#elif XCHAL_NUM_AREGS % 12 == 8
47 " mov a4, a4\n"
48#endif
49 " retw\n"
50 "2:\n"
51 : : : "a12", "a13", "memory");
41#else 52#else
42 : "a2", "a3", "a4", "a7", "a11", "a12", "a13", "a14", "a15", 53 __asm__ __volatile__ (
54 " mov a12, a12\n"
55 : : : "memory");
43#endif 56#endif
44 "memory");
45} 57}
46 58
47#endif /* _XTENSA_TRAPS_H */ 59#endif /* _XTENSA_TRAPS_H */
diff --git a/arch/xtensa/include/asm/vectors.h b/arch/xtensa/include/asm/vectors.h
index 5791b45d5a5d..f74ddfbb92ef 100644
--- a/arch/xtensa/include/asm/vectors.h
+++ b/arch/xtensa/include/asm/vectors.h
@@ -25,7 +25,7 @@
25#define XCHAL_KIO_DEFAULT_PADDR 0xf0000000 25#define XCHAL_KIO_DEFAULT_PADDR 0xf0000000
26#define XCHAL_KIO_SIZE 0x10000000 26#define XCHAL_KIO_SIZE 0x10000000
27 27
28#if XCHAL_HAVE_PTP_MMU && XCHAL_HAVE_SPANNING_WAY && CONFIG_OF 28#if XCHAL_HAVE_PTP_MMU && XCHAL_HAVE_SPANNING_WAY && defined(CONFIG_OF)
29#define XCHAL_KIO_PADDR xtensa_get_kio_paddr() 29#define XCHAL_KIO_PADDR xtensa_get_kio_paddr()
30#else 30#else
31#define XCHAL_KIO_PADDR XCHAL_KIO_DEFAULT_PADDR 31#define XCHAL_KIO_PADDR XCHAL_KIO_DEFAULT_PADDR
diff --git a/arch/xtensa/include/uapi/asm/unistd.h b/arch/xtensa/include/uapi/asm/unistd.h
index 51940fec6990..b9395529f02d 100644
--- a/arch/xtensa/include/uapi/asm/unistd.h
+++ b/arch/xtensa/include/uapi/asm/unistd.h
@@ -734,7 +734,12 @@ __SYSCALL(332, sys_finit_module, 3)
734#define __NR_accept4 333 734#define __NR_accept4 333
735__SYSCALL(333, sys_accept4, 4) 735__SYSCALL(333, sys_accept4, 4)
736 736
737#define __NR_syscall_count 334 737#define __NR_sched_setattr 334
738__SYSCALL(334, sys_sched_setattr, 2)
739#define __NR_sched_getattr 335
740__SYSCALL(335, sys_sched_getattr, 3)
741
742#define __NR_syscall_count 336
738 743
739/* 744/*
740 * sysxtensa syscall handler 745 * sysxtensa syscall handler
diff --git a/arch/xtensa/kernel/entry.S b/arch/xtensa/kernel/entry.S
index 21dbe6bdb8ed..ef7f4990722b 100644
--- a/arch/xtensa/kernel/entry.S
+++ b/arch/xtensa/kernel/entry.S
@@ -1081,196 +1081,53 @@ ENTRY(fast_syscall_spill_registers)
1081 1081
1082 rsr a0, sar 1082 rsr a0, sar
1083 s32i a3, a2, PT_AREG3 1083 s32i a3, a2, PT_AREG3
1084 s32i a4, a2, PT_AREG4 1084 s32i a0, a2, PT_SAR
1085 s32i a0, a2, PT_AREG5 # store SAR to PT_AREG5
1086 1085
1087 /* The spill routine might clobber a7, a11, and a15. */ 1086 /* The spill routine might clobber a4, a7, a8, a11, a12, and a15. */
1088 1087
1088 s32i a4, a2, PT_AREG4
1089 s32i a7, a2, PT_AREG7 1089 s32i a7, a2, PT_AREG7
1090 s32i a8, a2, PT_AREG8
1090 s32i a11, a2, PT_AREG11 1091 s32i a11, a2, PT_AREG11
1092 s32i a12, a2, PT_AREG12
1091 s32i a15, a2, PT_AREG15 1093 s32i a15, a2, PT_AREG15
1092 1094
1093 call0 _spill_registers # destroys a3, a4, and SAR
1094
1095 /* Advance PC, restore registers and SAR, and return from exception. */
1096
1097 l32i a3, a2, PT_AREG5
1098 l32i a4, a2, PT_AREG4
1099 l32i a0, a2, PT_AREG0
1100 wsr a3, sar
1101 l32i a3, a2, PT_AREG3
1102
1103 /* Restore clobbered registers. */
1104
1105 l32i a7, a2, PT_AREG7
1106 l32i a11, a2, PT_AREG11
1107 l32i a15, a2, PT_AREG15
1108
1109 movi a2, 0
1110 rfe
1111
1112ENDPROC(fast_syscall_spill_registers)
1113
1114/* Fixup handler.
1115 *
1116 * We get here if the spill routine causes an exception, e.g. tlb miss.
1117 * We basically restore WINDOWBASE and WINDOWSTART to the condition when
1118 * we entered the spill routine and jump to the user exception handler.
1119 *
1120 * a0: value of depc, original value in depc
1121 * a2: trashed, original value in EXC_TABLE_DOUBLE_SAVE
1122 * a3: exctable, original value in excsave1
1123 */
1124
1125ENTRY(fast_syscall_spill_registers_fixup)
1126
1127 rsr a2, windowbase # get current windowbase (a2 is saved)
1128 xsr a0, depc # restore depc and a0
1129 ssl a2 # set shift (32 - WB)
1130
1131 /* We need to make sure the current registers (a0-a3) are preserved.
1132 * To do this, we simply set the bit for the current window frame
1133 * in WS, so that the exception handlers save them to the task stack.
1134 */
1135
1136 xsr a3, excsave1 # get spill-mask
1137 slli a3, a3, 1 # shift left by one
1138
1139 slli a2, a3, 32-WSBITS
1140 src a2, a3, a2 # a2 = xxwww1yyxxxwww1yy......
1141 wsr a2, windowstart # set corrected windowstart
1142
1143 srli a3, a3, 1
1144 rsr a2, excsave1
1145 l32i a2, a2, EXC_TABLE_DOUBLE_SAVE # restore a2
1146 xsr a2, excsave1
1147 s32i a3, a2, EXC_TABLE_DOUBLE_SAVE # save a3
1148 l32i a3, a2, EXC_TABLE_PARAM # original WB (in user task)
1149 xsr a2, excsave1
1150
1151 /* Return to the original (user task) WINDOWBASE.
1152 * We leave the following frame behind:
1153 * a0, a1, a2 same
1154 * a3: trashed (saved in EXC_TABLE_DOUBLE_SAVE)
1155 * depc: depc (we have to return to that address)
1156 * excsave_1: exctable
1157 */
1158
1159 wsr a3, windowbase
1160 rsync
1161
1162 /* We are now in the original frame when we entered _spill_registers:
1163 * a0: return address
1164 * a1: used, stack pointer
1165 * a2: kernel stack pointer
1166 * a3: available
1167 * depc: exception address
1168 * excsave: exctable
1169 * Note: This frame might be the same as above.
1170 */
1171
1172 /* Setup stack pointer. */
1173
1174 addi a2, a2, -PT_USER_SIZE
1175 s32i a0, a2, PT_AREG0
1176
1177 /* Make sure we return to this fixup handler. */
1178
1179 movi a3, fast_syscall_spill_registers_fixup_return
1180 s32i a3, a2, PT_DEPC # setup depc
1181
1182 /* Jump to the exception handler. */
1183
1184 rsr a3, excsave1
1185 rsr a0, exccause
1186 addx4 a0, a0, a3 # find entry in table
1187 l32i a0, a0, EXC_TABLE_FAST_USER # load handler
1188 l32i a3, a3, EXC_TABLE_DOUBLE_SAVE
1189 jx a0
1190
1191ENDPROC(fast_syscall_spill_registers_fixup)
1192
1193ENTRY(fast_syscall_spill_registers_fixup_return)
1194
1195 /* When we return here, all registers have been restored (a2: DEPC) */
1196
1197 wsr a2, depc # exception address
1198
1199 /* Restore fixup handler. */
1200
1201 rsr a2, excsave1
1202 s32i a3, a2, EXC_TABLE_DOUBLE_SAVE
1203 movi a3, fast_syscall_spill_registers_fixup
1204 s32i a3, a2, EXC_TABLE_FIXUP
1205 rsr a3, windowbase
1206 s32i a3, a2, EXC_TABLE_PARAM
1207 l32i a2, a2, EXC_TABLE_KSTK
1208
1209 /* Load WB at the time the exception occurred. */
1210
1211 rsr a3, sar # WB is still in SAR
1212 neg a3, a3
1213 wsr a3, windowbase
1214 rsync
1215
1216 rsr a3, excsave1
1217 l32i a3, a3, EXC_TABLE_DOUBLE_SAVE
1218
1219 rfde
1220
1221ENDPROC(fast_syscall_spill_registers_fixup_return)
1222
1223/*
1224 * spill all registers.
1225 *
1226 * This is not a real function. The following conditions must be met:
1227 *
1228 * - must be called with call0.
1229 * - uses a3, a4 and SAR.
1230 * - the last 'valid' register of each frame are clobbered.
1231 * - the caller must have registered a fixup handler
1232 * (or be inside a critical section)
1233 * - PS_EXCM must be set (PS_WOE cleared?)
1234 */
1235
1236ENTRY(_spill_registers)
1237
1238 /* 1095 /*
1239 * Rotate ws so that the current windowbase is at bit 0. 1096 * Rotate ws so that the current windowbase is at bit 0.
1240 * Assume ws = xxxwww1yy (www1 current window frame). 1097 * Assume ws = xxxwww1yy (www1 current window frame).
1241 * Rotate ws right so that a4 = yyxxxwww1. 1098 * Rotate ws right so that a4 = yyxxxwww1.
1242 */ 1099 */
1243 1100
1244 rsr a4, windowbase 1101 rsr a0, windowbase
1245 rsr a3, windowstart # a3 = xxxwww1yy 1102 rsr a3, windowstart # a3 = xxxwww1yy
1246 ssr a4 # holds WB 1103 ssr a0 # holds WB
1247 slli a4, a3, WSBITS 1104 slli a0, a3, WSBITS
1248 or a3, a3, a4 # a3 = xxxwww1yyxxxwww1yy 1105 or a3, a3, a0 # a3 = xxxwww1yyxxxwww1yy
1249 srl a3, a3 # a3 = 00xxxwww1yyxxxwww1 1106 srl a3, a3 # a3 = 00xxxwww1yyxxxwww1
1250 1107
1251 /* We are done if there are no more than the current register frame. */ 1108 /* We are done if there are no more than the current register frame. */
1252 1109
1253 extui a3, a3, 1, WSBITS-1 # a3 = 0yyxxxwww 1110 extui a3, a3, 1, WSBITS-1 # a3 = 0yyxxxwww
1254 movi a4, (1 << (WSBITS-1)) 1111 movi a0, (1 << (WSBITS-1))
1255 _beqz a3, .Lnospill # only one active frame? jump 1112 _beqz a3, .Lnospill # only one active frame? jump
1256 1113
1257 /* We want 1 at the top, so that we return to the current windowbase */ 1114 /* We want 1 at the top, so that we return to the current windowbase */
1258 1115
1259 or a3, a3, a4 # 1yyxxxwww 1116 or a3, a3, a0 # 1yyxxxwww
1260 1117
1261 /* Skip empty frames - get 'oldest' WINDOWSTART-bit. */ 1118 /* Skip empty frames - get 'oldest' WINDOWSTART-bit. */
1262 1119
1263 wsr a3, windowstart # save shifted windowstart 1120 wsr a3, windowstart # save shifted windowstart
1264 neg a4, a3 1121 neg a0, a3
1265 and a3, a4, a3 # first bit set from right: 000010000 1122 and a3, a0, a3 # first bit set from right: 000010000
1266 1123
1267 ffs_ws a4, a3 # a4: shifts to skip empty frames 1124 ffs_ws a0, a3 # a0: shifts to skip empty frames
1268 movi a3, WSBITS 1125 movi a3, WSBITS
1269 sub a4, a3, a4 # WSBITS-a4:number of 0-bits from right 1126 sub a0, a3, a0 # WSBITS-a0:number of 0-bits from right
1270 ssr a4 # save in SAR for later. 1127 ssr a0 # save in SAR for later.
1271 1128
1272 rsr a3, windowbase 1129 rsr a3, windowbase
1273 add a3, a3, a4 1130 add a3, a3, a0
1274 wsr a3, windowbase 1131 wsr a3, windowbase
1275 rsync 1132 rsync
1276 1133
@@ -1285,22 +1142,6 @@ ENTRY(_spill_registers)
1285 * we have to save 4,8. or 12 registers. 1142 * we have to save 4,8. or 12 registers.
1286 */ 1143 */
1287 1144
1288 _bbsi.l a3, 1, .Lc4
1289 _bbsi.l a3, 2, .Lc8
1290
1291 /* Special case: we have a call12-frame starting at a4. */
1292
1293 _bbci.l a3, 3, .Lc12 # bit 3 shouldn't be zero! (Jump to Lc12 first)
1294
1295 s32e a4, a1, -16 # a1 is valid with an empty spill area
1296 l32e a4, a5, -12
1297 s32e a8, a4, -48
1298 mov a8, a4
1299 l32e a4, a1, -16
1300 j .Lc12c
1301
1302.Lnospill:
1303 ret
1304 1145
1305.Lloop: _bbsi.l a3, 1, .Lc4 1146.Lloop: _bbsi.l a3, 1, .Lc4
1306 _bbci.l a3, 2, .Lc12 1147 _bbci.l a3, 2, .Lc12
@@ -1314,20 +1155,10 @@ ENTRY(_spill_registers)
1314 s32e a9, a4, -28 1155 s32e a9, a4, -28
1315 s32e a10, a4, -24 1156 s32e a10, a4, -24
1316 s32e a11, a4, -20 1157 s32e a11, a4, -20
1317
1318 srli a11, a3, 2 # shift windowbase by 2 1158 srli a11, a3, 2 # shift windowbase by 2
1319 rotw 2 1159 rotw 2
1320 _bnei a3, 1, .Lloop 1160 _bnei a3, 1, .Lloop
1321 1161 j .Lexit
1322.Lexit: /* Done. Do the final rotation, set WS, and return. */
1323
1324 rotw 1
1325 rsr a3, windowbase
1326 ssl a3
1327 movi a3, 1
1328 sll a3, a3
1329 wsr a3, windowstart
1330 ret
1331 1162
1332.Lc4: s32e a4, a9, -16 1163.Lc4: s32e a4, a9, -16
1333 s32e a5, a9, -12 1164 s32e a5, a9, -12
@@ -1343,11 +1174,11 @@ ENTRY(_spill_registers)
1343 1174
1344 /* 12-register frame (call12) */ 1175 /* 12-register frame (call12) */
1345 1176
1346 l32e a2, a5, -12 1177 l32e a0, a5, -12
1347 s32e a8, a2, -48 1178 s32e a8, a0, -48
1348 mov a8, a2 1179 mov a8, a0
1349 1180
1350.Lc12c: s32e a9, a8, -44 1181 s32e a9, a8, -44
1351 s32e a10, a8, -40 1182 s32e a10, a8, -40
1352 s32e a11, a8, -36 1183 s32e a11, a8, -36
1353 s32e a12, a8, -32 1184 s32e a12, a8, -32
@@ -1367,30 +1198,54 @@ ENTRY(_spill_registers)
1367 */ 1198 */
1368 1199
1369 rotw 1 1200 rotw 1
1370 mov a5, a13 1201 mov a4, a13
1371 rotw -1 1202 rotw -1
1372 1203
1373 s32e a4, a9, -16 1204 s32e a4, a8, -16
1374 s32e a5, a9, -12 1205 s32e a5, a8, -12
1375 s32e a6, a9, -8 1206 s32e a6, a8, -8
1376 s32e a7, a9, -4 1207 s32e a7, a8, -4
1377 1208
1378 rotw 3 1209 rotw 3
1379 1210
1380 _beqi a3, 1, .Lexit 1211 _beqi a3, 1, .Lexit
1381 j .Lloop 1212 j .Lloop
1382 1213
1383.Linvalid_mask: 1214.Lexit:
1384 1215
1385 /* We get here because of an unrecoverable error in the window 1216 /* Done. Do the final rotation and set WS */
1386 * registers. If we are in user space, we kill the application, 1217
1387 * however, this condition is unrecoverable in kernel space. 1218 rotw 1
1388 */ 1219 rsr a3, windowbase
1220 ssl a3
1221 movi a3, 1
1222 sll a3, a3
1223 wsr a3, windowstart
1224.Lnospill:
1225
1226 /* Advance PC, restore registers and SAR, and return from exception. */
1227
1228 l32i a3, a2, PT_SAR
1229 l32i a0, a2, PT_AREG0
1230 wsr a3, sar
1231 l32i a3, a2, PT_AREG3
1389 1232
1390 rsr a0, ps 1233 /* Restore clobbered registers. */
1391 _bbci.l a0, PS_UM_BIT, 1f
1392 1234
1393 /* User space: Setup a dummy frame and kill application. 1235 l32i a4, a2, PT_AREG4
1236 l32i a7, a2, PT_AREG7
1237 l32i a8, a2, PT_AREG8
1238 l32i a11, a2, PT_AREG11
1239 l32i a12, a2, PT_AREG12
1240 l32i a15, a2, PT_AREG15
1241
1242 movi a2, 0
1243 rfe
1244
1245.Linvalid_mask:
1246
1247 /* We get here because of an unrecoverable error in the window
1248 * registers, so set up a dummy frame and kill the user application.
1394 * Note: We assume EXC_TABLE_KSTK contains a valid stack pointer. 1249 * Note: We assume EXC_TABLE_KSTK contains a valid stack pointer.
1395 */ 1250 */
1396 1251
@@ -1414,14 +1269,136 @@ ENTRY(_spill_registers)
1414 movi a4, do_exit 1269 movi a4, do_exit
1415 callx4 a4 1270 callx4 a4
1416 1271
14171: /* Kernel space: PANIC! */ 1272 /* shouldn't return, so panic */
1418 1273
1419 wsr a0, excsave1 1274 wsr a0, excsave1
1420 movi a0, unrecoverable_exception 1275 movi a0, unrecoverable_exception
1421 callx0 a0 # should not return 1276 callx0 a0 # should not return
14221: j 1b 12771: j 1b
1423 1278
1424ENDPROC(_spill_registers) 1279
1280ENDPROC(fast_syscall_spill_registers)
1281
1282/* Fixup handler.
1283 *
1284 * We get here if the spill routine causes an exception, e.g. tlb miss.
1285 * We basically restore WINDOWBASE and WINDOWSTART to the condition when
1286 * we entered the spill routine and jump to the user exception handler.
1287 *
1288 * Note that we only need to restore the bits in windowstart that have not
1289 * been spilled yet by the _spill_register routine. Luckily, a3 contains a
1290 * rotated windowstart with only those bits set for frames that haven't been
1291 * spilled yet. Because a3 is rotated such that bit 0 represents the register
1292 * frame for the current windowbase - 1, we need to rotate a3 left by the
1293 * value of the current windowbase + 1 and move it to windowstart.
1294 *
1295 * a0: value of depc, original value in depc
1296 * a2: trashed, original value in EXC_TABLE_DOUBLE_SAVE
1297 * a3: exctable, original value in excsave1
1298 */
1299
1300ENTRY(fast_syscall_spill_registers_fixup)
1301
1302 rsr a2, windowbase # get current windowbase (a2 is saved)
1303 xsr a0, depc # restore depc and a0
1304 ssl a2 # set shift (32 - WB)
1305
1306 /* We need to make sure the current registers (a0-a3) are preserved.
1307 * To do this, we simply set the bit for the current window frame
1308 * in WS, so that the exception handlers save them to the task stack.
1309 *
1310 * Note: we use a3 to set the windowbase, so we take a special care
1311 * of it, saving it in the original _spill_registers frame across
1312 * the exception handler call.
1313 */
1314
1315 xsr a3, excsave1 # get spill-mask
1316 slli a3, a3, 1 # shift left by one
1317 addi a3, a3, 1 # set the bit for the current window frame
1318
1319 slli a2, a3, 32-WSBITS
1320 src a2, a3, a2 # a2 = xxwww1yyxxxwww1yy......
1321 wsr a2, windowstart # set corrected windowstart
1322
1323 srli a3, a3, 1
1324 rsr a2, excsave1
1325 l32i a2, a2, EXC_TABLE_DOUBLE_SAVE # restore a2
1326 xsr a2, excsave1
1327 s32i a3, a2, EXC_TABLE_DOUBLE_SAVE # save a3
1328 l32i a3, a2, EXC_TABLE_PARAM # original WB (in user task)
1329 xsr a2, excsave1
1330
1331 /* Return to the original (user task) WINDOWBASE.
1332 * We leave the following frame behind:
1333 * a0, a1, a2 same
1334 * a3: trashed (saved in EXC_TABLE_DOUBLE_SAVE)
1335 * depc: depc (we have to return to that address)
1336 * excsave_1: exctable
1337 */
1338
1339 wsr a3, windowbase
1340 rsync
1341
1342 /* We are now in the original frame when we entered _spill_registers:
1343 * a0: return address
1344 * a1: used, stack pointer
1345 * a2: kernel stack pointer
1346 * a3: available
1347 * depc: exception address
1348 * excsave: exctable
1349 * Note: This frame might be the same as above.
1350 */
1351
1352 /* Setup stack pointer. */
1353
1354 addi a2, a2, -PT_USER_SIZE
1355 s32i a0, a2, PT_AREG0
1356
1357 /* Make sure we return to this fixup handler. */
1358
1359 movi a3, fast_syscall_spill_registers_fixup_return
1360 s32i a3, a2, PT_DEPC # setup depc
1361
1362 /* Jump to the exception handler. */
1363
1364 rsr a3, excsave1
1365 rsr a0, exccause
1366 addx4 a0, a0, a3 # find entry in table
1367 l32i a0, a0, EXC_TABLE_FAST_USER # load handler
1368 l32i a3, a3, EXC_TABLE_DOUBLE_SAVE
1369 jx a0
1370
1371ENDPROC(fast_syscall_spill_registers_fixup)
1372
1373ENTRY(fast_syscall_spill_registers_fixup_return)
1374
1375 /* When we return here, all registers have been restored (a2: DEPC) */
1376
1377 wsr a2, depc # exception address
1378
1379 /* Restore fixup handler. */
1380
1381 rsr a2, excsave1
1382 s32i a3, a2, EXC_TABLE_DOUBLE_SAVE
1383 movi a3, fast_syscall_spill_registers_fixup
1384 s32i a3, a2, EXC_TABLE_FIXUP
1385 rsr a3, windowbase
1386 s32i a3, a2, EXC_TABLE_PARAM
1387 l32i a2, a2, EXC_TABLE_KSTK
1388
1389 /* Load WB at the time the exception occurred. */
1390
1391 rsr a3, sar # WB is still in SAR
1392 neg a3, a3
1393 wsr a3, windowbase
1394 rsync
1395
1396 rsr a3, excsave1
1397 l32i a3, a3, EXC_TABLE_DOUBLE_SAVE
1398
1399 rfde
1400
1401ENDPROC(fast_syscall_spill_registers_fixup_return)
1425 1402
1426#ifdef CONFIG_MMU 1403#ifdef CONFIG_MMU
1427/* 1404/*
@@ -1794,6 +1771,43 @@ ENTRY(system_call)
1794 1771
1795ENDPROC(system_call) 1772ENDPROC(system_call)
1796 1773
1774/*
1775 * Spill live registers on the kernel stack macro.
1776 *
1777 * Entry condition: ps.woe is set, ps.excm is cleared
1778 * Exit condition: windowstart has single bit set
1779 * May clobber: a12, a13
1780 */
1781 .macro spill_registers_kernel
1782
1783#if XCHAL_NUM_AREGS > 16
1784 call12 1f
1785 _j 2f
1786 retw
1787 .align 4
17881:
1789 _entry a1, 48
1790 addi a12, a0, 3
1791#if XCHAL_NUM_AREGS > 32
1792 .rept (XCHAL_NUM_AREGS - 32) / 12
1793 _entry a1, 48
1794 mov a12, a0
1795 .endr
1796#endif
1797 _entry a1, 48
1798#if XCHAL_NUM_AREGS % 12 == 0
1799 mov a8, a8
1800#elif XCHAL_NUM_AREGS % 12 == 4
1801 mov a12, a12
1802#elif XCHAL_NUM_AREGS % 12 == 8
1803 mov a4, a4
1804#endif
1805 retw
18062:
1807#else
1808 mov a12, a12
1809#endif
1810 .endm
1797 1811
1798/* 1812/*
1799 * Task switch. 1813 * Task switch.
@@ -1806,21 +1820,20 @@ ENTRY(_switch_to)
1806 1820
1807 entry a1, 16 1821 entry a1, 16
1808 1822
1809 mov a12, a2 # preserve 'prev' (a2) 1823 mov a10, a2 # preserve 'prev' (a2)
1810 mov a13, a3 # and 'next' (a3) 1824 mov a11, a3 # and 'next' (a3)
1811 1825
1812 l32i a4, a2, TASK_THREAD_INFO 1826 l32i a4, a2, TASK_THREAD_INFO
1813 l32i a5, a3, TASK_THREAD_INFO 1827 l32i a5, a3, TASK_THREAD_INFO
1814 1828
1815 save_xtregs_user a4 a6 a8 a9 a10 a11 THREAD_XTREGS_USER 1829 save_xtregs_user a4 a6 a8 a9 a12 a13 THREAD_XTREGS_USER
1816 1830
1817 s32i a0, a12, THREAD_RA # save return address 1831 s32i a0, a10, THREAD_RA # save return address
1818 s32i a1, a12, THREAD_SP # save stack pointer 1832 s32i a1, a10, THREAD_SP # save stack pointer
1819 1833
1820 /* Disable ints while we manipulate the stack pointer. */ 1834 /* Disable ints while we manipulate the stack pointer. */
1821 1835
1822 movi a14, (1 << PS_EXCM_BIT) | LOCKLEVEL 1836 rsil a14, LOCKLEVEL
1823 xsr a14, ps
1824 rsr a3, excsave1 1837 rsr a3, excsave1
1825 rsync 1838 rsync
1826 s32i a3, a3, EXC_TABLE_FIXUP /* enter critical section */ 1839 s32i a3, a3, EXC_TABLE_FIXUP /* enter critical section */
@@ -1835,7 +1848,7 @@ ENTRY(_switch_to)
1835 1848
1836 /* Flush register file. */ 1849 /* Flush register file. */
1837 1850
1838 call0 _spill_registers # destroys a3, a4, and SAR 1851 spill_registers_kernel
1839 1852
1840 /* Set kernel stack (and leave critical section) 1853 /* Set kernel stack (and leave critical section)
1841 * Note: It's save to set it here. The stack will not be overwritten 1854 * Note: It's save to set it here. The stack will not be overwritten
@@ -1851,13 +1864,13 @@ ENTRY(_switch_to)
1851 1864
1852 /* restore context of the task 'next' */ 1865 /* restore context of the task 'next' */
1853 1866
1854 l32i a0, a13, THREAD_RA # restore return address 1867 l32i a0, a11, THREAD_RA # restore return address
1855 l32i a1, a13, THREAD_SP # restore stack pointer 1868 l32i a1, a11, THREAD_SP # restore stack pointer
1856 1869
1857 load_xtregs_user a5 a6 a8 a9 a10 a11 THREAD_XTREGS_USER 1870 load_xtregs_user a5 a6 a8 a9 a12 a13 THREAD_XTREGS_USER
1858 1871
1859 wsr a14, ps 1872 wsr a14, ps
1860 mov a2, a12 # return 'prev' 1873 mov a2, a10 # return 'prev'
1861 rsync 1874 rsync
1862 1875
1863 retw 1876 retw
diff --git a/arch/xtensa/kernel/setup.c b/arch/xtensa/kernel/setup.c
index 7d12af1317f1..84fe931bb60e 100644
--- a/arch/xtensa/kernel/setup.c
+++ b/arch/xtensa/kernel/setup.c
@@ -22,6 +22,7 @@
22#include <linux/bootmem.h> 22#include <linux/bootmem.h>
23#include <linux/kernel.h> 23#include <linux/kernel.h>
24#include <linux/percpu.h> 24#include <linux/percpu.h>
25#include <linux/clk-provider.h>
25#include <linux/cpu.h> 26#include <linux/cpu.h>
26#include <linux/of_fdt.h> 27#include <linux/of_fdt.h>
27#include <linux/of_platform.h> 28#include <linux/of_platform.h>
@@ -276,6 +277,7 @@ void __init early_init_devtree(void *params)
276 277
277static int __init xtensa_device_probe(void) 278static int __init xtensa_device_probe(void)
278{ 279{
280 of_clk_init(NULL);
279 of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); 281 of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
280 return 0; 282 return 0;
281} 283}
diff --git a/arch/xtensa/kernel/time.c b/arch/xtensa/kernel/time.c
index 08b769d3b3a1..2a1823de69cc 100644
--- a/arch/xtensa/kernel/time.c
+++ b/arch/xtensa/kernel/time.c
@@ -30,6 +30,7 @@
30#include <asm/platform.h> 30#include <asm/platform.h>
31 31
32unsigned long ccount_freq; /* ccount Hz */ 32unsigned long ccount_freq; /* ccount Hz */
33EXPORT_SYMBOL(ccount_freq);
33 34
34static cycle_t ccount_read(struct clocksource *cs) 35static cycle_t ccount_read(struct clocksource *cs)
35{ 36{
diff --git a/arch/xtensa/kernel/vectors.S b/arch/xtensa/kernel/vectors.S
index cb8fd44caabc..f9e1ec346e35 100644
--- a/arch/xtensa/kernel/vectors.S
+++ b/arch/xtensa/kernel/vectors.S
@@ -235,7 +235,7 @@ ENTRY(_DoubleExceptionVector)
235 235
236 /* Check for overflow/underflow exception, jump if overflow. */ 236 /* Check for overflow/underflow exception, jump if overflow. */
237 237
238 _bbci.l a0, 6, _DoubleExceptionVector_WindowOverflow 238 bbci.l a0, 6, _DoubleExceptionVector_WindowOverflow
239 239
240 /* 240 /*
241 * Restart window underflow exception. 241 * Restart window underflow exception.
diff --git a/arch/xtensa/kernel/xtensa_ksyms.c b/arch/xtensa/kernel/xtensa_ksyms.c
index 74a60c7e085e..80b33ed51f31 100644
--- a/arch/xtensa/kernel/xtensa_ksyms.c
+++ b/arch/xtensa/kernel/xtensa_ksyms.c
@@ -122,9 +122,7 @@ EXPORT_SYMBOL(insw);
122EXPORT_SYMBOL(insl); 122EXPORT_SYMBOL(insl);
123 123
124extern long common_exception_return; 124extern long common_exception_return;
125extern long _spill_registers;
126EXPORT_SYMBOL(common_exception_return); 125EXPORT_SYMBOL(common_exception_return);
127EXPORT_SYMBOL(_spill_registers);
128 126
129#ifdef CONFIG_FUNCTION_TRACER 127#ifdef CONFIG_FUNCTION_TRACER
130EXPORT_SYMBOL(_mcount); 128EXPORT_SYMBOL(_mcount);
diff --git a/arch/xtensa/mm/init.c b/arch/xtensa/mm/init.c
index 479d7537a32a..aff108df92d3 100644
--- a/arch/xtensa/mm/init.c
+++ b/arch/xtensa/mm/init.c
@@ -90,7 +90,7 @@ int __init mem_reserve(unsigned long start, unsigned long end, int must_exist)
90 90
91 91
92/* 92/*
93 * Initialize the bootmem system and give it all the memory we have available. 93 * Initialize the bootmem system and give it all low memory we have available.
94 */ 94 */
95 95
96void __init bootmem_init(void) 96void __init bootmem_init(void)
@@ -142,9 +142,14 @@ void __init bootmem_init(void)
142 142
143 /* Add all remaining memory pieces into the bootmem map */ 143 /* Add all remaining memory pieces into the bootmem map */
144 144
145 for (i=0; i<sysmem.nr_banks; i++) 145 for (i = 0; i < sysmem.nr_banks; i++) {
146 free_bootmem(sysmem.bank[i].start, 146 if (sysmem.bank[i].start >> PAGE_SHIFT < max_low_pfn) {
147 sysmem.bank[i].end - sysmem.bank[i].start); 147 unsigned long end = min(max_low_pfn << PAGE_SHIFT,
148 sysmem.bank[i].end);
149 free_bootmem(sysmem.bank[i].start,
150 end - sysmem.bank[i].start);
151 }
152 }
148 153
149} 154}
150 155
diff --git a/arch/xtensa/mm/mmu.c b/arch/xtensa/mm/mmu.c
index 36ec171698b8..861203e958da 100644
--- a/arch/xtensa/mm/mmu.c
+++ b/arch/xtensa/mm/mmu.c
@@ -39,7 +39,7 @@ void init_mmu(void)
39 set_itlbcfg_register(0); 39 set_itlbcfg_register(0);
40 set_dtlbcfg_register(0); 40 set_dtlbcfg_register(0);
41#endif 41#endif
42#if XCHAL_HAVE_PTP_MMU && XCHAL_HAVE_SPANNING_WAY && CONFIG_OF 42#if XCHAL_HAVE_PTP_MMU && XCHAL_HAVE_SPANNING_WAY && defined(CONFIG_OF)
43 /* 43 /*
44 * Update the IO area mapping in case xtensa_kio_paddr has changed 44 * Update the IO area mapping in case xtensa_kio_paddr has changed
45 */ 45 */
diff --git a/arch/xtensa/platforms/xtfpga/setup.c b/arch/xtensa/platforms/xtfpga/setup.c
index 800227862fe8..57fd08b36f51 100644
--- a/arch/xtensa/platforms/xtfpga/setup.c
+++ b/arch/xtensa/platforms/xtfpga/setup.c
@@ -135,11 +135,11 @@ static void __init update_local_mac(struct device_node *node)
135 135
136static int __init machine_setup(void) 136static int __init machine_setup(void)
137{ 137{
138 struct device_node *serial; 138 struct device_node *clock;
139 struct device_node *eth = NULL; 139 struct device_node *eth = NULL;
140 140
141 for_each_compatible_node(serial, NULL, "ns16550a") 141 for_each_node_by_name(clock, "main-oscillator")
142 update_clock_frequency(serial); 142 update_clock_frequency(clock);
143 143
144 if ((eth = of_find_compatible_node(eth, NULL, "opencores,ethoc"))) 144 if ((eth = of_find_compatible_node(eth, NULL, "opencores,ethoc")))
145 update_local_mac(eth); 145 update_local_mac(eth);
@@ -290,6 +290,7 @@ static int __init xtavnet_init(void)
290 * knows whether they set it correctly on the DIP switches. 290 * knows whether they set it correctly on the DIP switches.
291 */ 291 */
292 pr_info("XTFPGA: Ethernet MAC %pM\n", ethoc_pdata.hwaddr); 292 pr_info("XTFPGA: Ethernet MAC %pM\n", ethoc_pdata.hwaddr);
293 ethoc_pdata.eth_clkfreq = *(long *)XTFPGA_CLKFRQ_VADDR;
293 294
294 return 0; 295 return 0;
295} 296}
diff --git a/arch/xtensa/variants/fsf/include/variant/tie.h b/arch/xtensa/variants/fsf/include/variant/tie.h
index bf4020116df5..244cdea4dee5 100644
--- a/arch/xtensa/variants/fsf/include/variant/tie.h
+++ b/arch/xtensa/variants/fsf/include/variant/tie.h
@@ -18,13 +18,6 @@
18#define XCHAL_CP_MASK 0x00 /* bitmask of all CPs by ID */ 18#define XCHAL_CP_MASK 0x00 /* bitmask of all CPs by ID */
19#define XCHAL_CP_PORT_MASK 0x00 /* bitmask of only port CPs */ 19#define XCHAL_CP_PORT_MASK 0x00 /* bitmask of only port CPs */
20 20
21/* Basic parameters of each coprocessor: */
22#define XCHAL_CP7_NAME "XTIOP"
23#define XCHAL_CP7_IDENT XTIOP
24#define XCHAL_CP7_SA_SIZE 0 /* size of state save area */
25#define XCHAL_CP7_SA_ALIGN 1 /* min alignment of save area */
26#define XCHAL_CP_ID_XTIOP 7 /* coprocessor ID (0..7) */
27
28/* Filler info for unassigned coprocessors, to simplify arrays etc: */ 21/* Filler info for unassigned coprocessors, to simplify arrays etc: */
29#define XCHAL_NCP_SA_SIZE 0 22#define XCHAL_NCP_SA_SIZE 0
30#define XCHAL_NCP_SA_ALIGN 1 23#define XCHAL_NCP_SA_ALIGN 1
@@ -42,6 +35,8 @@
42#define XCHAL_CP5_SA_ALIGN 1 35#define XCHAL_CP5_SA_ALIGN 1
43#define XCHAL_CP6_SA_SIZE 0 36#define XCHAL_CP6_SA_SIZE 0
44#define XCHAL_CP6_SA_ALIGN 1 37#define XCHAL_CP6_SA_ALIGN 1
38#define XCHAL_CP7_SA_SIZE 0
39#define XCHAL_CP7_SA_ALIGN 1
45 40
46/* Save area for non-coprocessor optional and custom (TIE) state: */ 41/* Save area for non-coprocessor optional and custom (TIE) state: */
47#define XCHAL_NCP_SA_SIZE 0 42#define XCHAL_NCP_SA_SIZE 0
diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c
index e7515aa43d6b..6f190bc2b8b7 100644
--- a/drivers/acpi/ac.c
+++ b/drivers/acpi/ac.c
@@ -243,6 +243,8 @@ static int acpi_ac_resume(struct device *dev)
243 kobject_uevent(&ac->charger.dev->kobj, KOBJ_CHANGE); 243 kobject_uevent(&ac->charger.dev->kobj, KOBJ_CHANGE);
244 return 0; 244 return 0;
245} 245}
246#else
247#define acpi_ac_resume NULL
246#endif 248#endif
247static SIMPLE_DEV_PM_OPS(acpi_ac_pm_ops, NULL, acpi_ac_resume); 249static SIMPLE_DEV_PM_OPS(acpi_ac_pm_ops, NULL, acpi_ac_resume);
248 250
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index 018a42883706..797a6938d051 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -841,6 +841,8 @@ static int acpi_battery_resume(struct device *dev)
841 acpi_battery_update(battery); 841 acpi_battery_update(battery);
842 return 0; 842 return 0;
843} 843}
844#else
845#define acpi_battery_resume NULL
844#endif 846#endif
845 847
846static SIMPLE_DEV_PM_OPS(acpi_battery_pm, NULL, acpi_battery_resume); 848static SIMPLE_DEV_PM_OPS(acpi_battery_pm, NULL, acpi_battery_resume);
diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
index 10e4964d051a..afec4526c48a 100644
--- a/drivers/acpi/blacklist.c
+++ b/drivers/acpi/blacklist.c
@@ -260,14 +260,6 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
260 }, 260 },
261 { 261 {
262 .callback = dmi_disable_osi_win8, 262 .callback = dmi_disable_osi_win8,
263 .ident = "Dell Inspiron 15R SE",
264 .matches = {
265 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
266 DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 7520"),
267 },
268 },
269 {
270 .callback = dmi_disable_osi_win8,
271 .ident = "ThinkPad Edge E530", 263 .ident = "ThinkPad Edge E530",
272 .matches = { 264 .matches = {
273 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), 265 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
@@ -322,56 +314,6 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
322 DMI_MATCH(DMI_PRODUCT_VERSION, "2349D15"), 314 DMI_MATCH(DMI_PRODUCT_VERSION, "2349D15"),
323 }, 315 },
324 }, 316 },
325 {
326 .callback = dmi_disable_osi_win8,
327 .ident = "HP ProBook 2013 models",
328 .matches = {
329 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
330 DMI_MATCH(DMI_PRODUCT_NAME, "HP ProBook "),
331 DMI_MATCH(DMI_PRODUCT_NAME, " G1"),
332 },
333 },
334 {
335 .callback = dmi_disable_osi_win8,
336 .ident = "HP EliteBook 2013 models",
337 .matches = {
338 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
339 DMI_MATCH(DMI_PRODUCT_NAME, "HP EliteBook "),
340 DMI_MATCH(DMI_PRODUCT_NAME, " G1"),
341 },
342 },
343 {
344 .callback = dmi_disable_osi_win8,
345 .ident = "HP ZBook 14",
346 .matches = {
347 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
348 DMI_MATCH(DMI_PRODUCT_NAME, "HP ZBook 14"),
349 },
350 },
351 {
352 .callback = dmi_disable_osi_win8,
353 .ident = "HP ZBook 15",
354 .matches = {
355 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
356 DMI_MATCH(DMI_PRODUCT_NAME, "HP ZBook 15"),
357 },
358 },
359 {
360 .callback = dmi_disable_osi_win8,
361 .ident = "HP ZBook 17",
362 .matches = {
363 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
364 DMI_MATCH(DMI_PRODUCT_NAME, "HP ZBook 17"),
365 },
366 },
367 {
368 .callback = dmi_disable_osi_win8,
369 .ident = "HP EliteBook 8780w",
370 .matches = {
371 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
372 DMI_MATCH(DMI_PRODUCT_NAME, "HP EliteBook 8780w"),
373 },
374 },
375 317
376 /* 318 /*
377 * BIOS invocation of _OSI(Linux) is almost always a BIOS bug. 319 * BIOS invocation of _OSI(Linux) is almost always a BIOS bug.
diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c
index 11c11f6b8fa1..714e957a871a 100644
--- a/drivers/acpi/button.c
+++ b/drivers/acpi/button.c
@@ -80,6 +80,8 @@ static void acpi_button_notify(struct acpi_device *device, u32 event);
80 80
81#ifdef CONFIG_PM_SLEEP 81#ifdef CONFIG_PM_SLEEP
82static int acpi_button_resume(struct device *dev); 82static int acpi_button_resume(struct device *dev);
83#else
84#define acpi_button_resume NULL
83#endif 85#endif
84static SIMPLE_DEV_PM_OPS(acpi_button_pm, NULL, acpi_button_resume); 86static SIMPLE_DEV_PM_OPS(acpi_button_pm, NULL, acpi_button_resume);
85 87
diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c
index e9b3081c4fe9..5bfd769fc91f 100644
--- a/drivers/acpi/dock.c
+++ b/drivers/acpi/dock.c
@@ -713,13 +713,11 @@ static acpi_status __init find_dock_devices(acpi_handle handle, u32 lvl,
713static ssize_t show_docked(struct device *dev, 713static ssize_t show_docked(struct device *dev,
714 struct device_attribute *attr, char *buf) 714 struct device_attribute *attr, char *buf)
715{ 715{
716 struct acpi_device *tmp;
717
718 struct dock_station *dock_station = dev->platform_data; 716 struct dock_station *dock_station = dev->platform_data;
717 struct acpi_device *adev = NULL;
719 718
720 if (!acpi_bus_get_device(dock_station->handle, &tmp)) 719 acpi_bus_get_device(dock_station->handle, &adev);
721 return snprintf(buf, PAGE_SIZE, "1\n"); 720 return snprintf(buf, PAGE_SIZE, "%u\n", acpi_device_enumerated(adev));
722 return snprintf(buf, PAGE_SIZE, "0\n");
723} 721}
724static DEVICE_ATTR(docked, S_IRUGO, show_docked, NULL); 722static DEVICE_ATTR(docked, S_IRUGO, show_docked, NULL);
725 723
diff --git a/drivers/acpi/fan.c b/drivers/acpi/fan.c
index 1fb62900f32a..09e423f3d8ad 100644
--- a/drivers/acpi/fan.c
+++ b/drivers/acpi/fan.c
@@ -55,6 +55,9 @@ MODULE_DEVICE_TABLE(acpi, fan_device_ids);
55#ifdef CONFIG_PM_SLEEP 55#ifdef CONFIG_PM_SLEEP
56static int acpi_fan_suspend(struct device *dev); 56static int acpi_fan_suspend(struct device *dev);
57static int acpi_fan_resume(struct device *dev); 57static int acpi_fan_resume(struct device *dev);
58#else
59#define acpi_fan_suspend NULL
60#define acpi_fan_resume NULL
58#endif 61#endif
59static SIMPLE_DEV_PM_OPS(acpi_fan_pm, acpi_fan_suspend, acpi_fan_resume); 62static SIMPLE_DEV_PM_OPS(acpi_fan_pm, acpi_fan_suspend, acpi_fan_resume);
60 63
diff --git a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c
index 52d45ea2bc4f..361b40c10c3f 100644
--- a/drivers/acpi/pci_irq.c
+++ b/drivers/acpi/pci_irq.c
@@ -430,6 +430,7 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
430 pin_name(pin)); 430 pin_name(pin));
431 } 431 }
432 432
433 kfree(entry);
433 return 0; 434 return 0;
434 } 435 }
435 436
diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c
index 28baa05b8018..84243c32e29c 100644
--- a/drivers/acpi/processor_throttling.c
+++ b/drivers/acpi/processor_throttling.c
@@ -56,6 +56,12 @@ struct throttling_tstate {
56 int target_state; /* target T-state */ 56 int target_state; /* target T-state */
57}; 57};
58 58
59struct acpi_processor_throttling_arg {
60 struct acpi_processor *pr;
61 int target_state;
62 bool force;
63};
64
59#define THROTTLING_PRECHANGE (1) 65#define THROTTLING_PRECHANGE (1)
60#define THROTTLING_POSTCHANGE (2) 66#define THROTTLING_POSTCHANGE (2)
61 67
@@ -1060,16 +1066,24 @@ static int acpi_processor_set_throttling_ptc(struct acpi_processor *pr,
1060 return 0; 1066 return 0;
1061} 1067}
1062 1068
1069static long acpi_processor_throttling_fn(void *data)
1070{
1071 struct acpi_processor_throttling_arg *arg = data;
1072 struct acpi_processor *pr = arg->pr;
1073
1074 return pr->throttling.acpi_processor_set_throttling(pr,
1075 arg->target_state, arg->force);
1076}
1077
1063int acpi_processor_set_throttling(struct acpi_processor *pr, 1078int acpi_processor_set_throttling(struct acpi_processor *pr,
1064 int state, bool force) 1079 int state, bool force)
1065{ 1080{
1066 cpumask_var_t saved_mask;
1067 int ret = 0; 1081 int ret = 0;
1068 unsigned int i; 1082 unsigned int i;
1069 struct acpi_processor *match_pr; 1083 struct acpi_processor *match_pr;
1070 struct acpi_processor_throttling *p_throttling; 1084 struct acpi_processor_throttling *p_throttling;
1085 struct acpi_processor_throttling_arg arg;
1071 struct throttling_tstate t_state; 1086 struct throttling_tstate t_state;
1072 cpumask_var_t online_throttling_cpus;
1073 1087
1074 if (!pr) 1088 if (!pr)
1075 return -EINVAL; 1089 return -EINVAL;
@@ -1080,14 +1094,6 @@ int acpi_processor_set_throttling(struct acpi_processor *pr,
1080 if ((state < 0) || (state > (pr->throttling.state_count - 1))) 1094 if ((state < 0) || (state > (pr->throttling.state_count - 1)))
1081 return -EINVAL; 1095 return -EINVAL;
1082 1096
1083 if (!alloc_cpumask_var(&saved_mask, GFP_KERNEL))
1084 return -ENOMEM;
1085
1086 if (!alloc_cpumask_var(&online_throttling_cpus, GFP_KERNEL)) {
1087 free_cpumask_var(saved_mask);
1088 return -ENOMEM;
1089 }
1090
1091 if (cpu_is_offline(pr->id)) { 1097 if (cpu_is_offline(pr->id)) {
1092 /* 1098 /*
1093 * the cpu pointed by pr->id is offline. Unnecessary to change 1099 * the cpu pointed by pr->id is offline. Unnecessary to change
@@ -1096,17 +1102,15 @@ int acpi_processor_set_throttling(struct acpi_processor *pr,
1096 return -ENODEV; 1102 return -ENODEV;
1097 } 1103 }
1098 1104
1099 cpumask_copy(saved_mask, &current->cpus_allowed);
1100 t_state.target_state = state; 1105 t_state.target_state = state;
1101 p_throttling = &(pr->throttling); 1106 p_throttling = &(pr->throttling);
1102 cpumask_and(online_throttling_cpus, cpu_online_mask, 1107
1103 p_throttling->shared_cpu_map);
1104 /* 1108 /*
1105 * The throttling notifier will be called for every 1109 * The throttling notifier will be called for every
1106 * affected cpu in order to get one proper T-state. 1110 * affected cpu in order to get one proper T-state.
1107 * The notifier event is THROTTLING_PRECHANGE. 1111 * The notifier event is THROTTLING_PRECHANGE.
1108 */ 1112 */
1109 for_each_cpu(i, online_throttling_cpus) { 1113 for_each_cpu_and(i, cpu_online_mask, p_throttling->shared_cpu_map) {
1110 t_state.cpu = i; 1114 t_state.cpu = i;
1111 acpi_processor_throttling_notifier(THROTTLING_PRECHANGE, 1115 acpi_processor_throttling_notifier(THROTTLING_PRECHANGE,
1112 &t_state); 1116 &t_state);
@@ -1118,21 +1122,18 @@ int acpi_processor_set_throttling(struct acpi_processor *pr,
1118 * it can be called only for the cpu pointed by pr. 1122 * it can be called only for the cpu pointed by pr.
1119 */ 1123 */
1120 if (p_throttling->shared_type == DOMAIN_COORD_TYPE_SW_ANY) { 1124 if (p_throttling->shared_type == DOMAIN_COORD_TYPE_SW_ANY) {
1121 /* FIXME: use work_on_cpu() */ 1125 arg.pr = pr;
1122 if (set_cpus_allowed_ptr(current, cpumask_of(pr->id))) { 1126 arg.target_state = state;
1123 /* Can't migrate to the pr->id CPU. Exit */ 1127 arg.force = force;
1124 ret = -ENODEV; 1128 ret = work_on_cpu(pr->id, acpi_processor_throttling_fn, &arg);
1125 goto exit;
1126 }
1127 ret = p_throttling->acpi_processor_set_throttling(pr,
1128 t_state.target_state, force);
1129 } else { 1129 } else {
1130 /* 1130 /*
1131 * When the T-state coordination is SW_ALL or HW_ALL, 1131 * When the T-state coordination is SW_ALL or HW_ALL,
1132 * it is necessary to set T-state for every affected 1132 * it is necessary to set T-state for every affected
1133 * cpus. 1133 * cpus.
1134 */ 1134 */
1135 for_each_cpu(i, online_throttling_cpus) { 1135 for_each_cpu_and(i, cpu_online_mask,
1136 p_throttling->shared_cpu_map) {
1136 match_pr = per_cpu(processors, i); 1137 match_pr = per_cpu(processors, i);
1137 /* 1138 /*
1138 * If the pointer is invalid, we will report the 1139 * If the pointer is invalid, we will report the
@@ -1153,13 +1154,12 @@ int acpi_processor_set_throttling(struct acpi_processor *pr,
1153 "on CPU %d\n", i)); 1154 "on CPU %d\n", i));
1154 continue; 1155 continue;
1155 } 1156 }
1156 t_state.cpu = i; 1157
1157 /* FIXME: use work_on_cpu() */ 1158 arg.pr = match_pr;
1158 if (set_cpus_allowed_ptr(current, cpumask_of(i))) 1159 arg.target_state = state;
1159 continue; 1160 arg.force = force;
1160 ret = match_pr->throttling. 1161 ret = work_on_cpu(pr->id, acpi_processor_throttling_fn,
1161 acpi_processor_set_throttling( 1162 &arg);
1162 match_pr, t_state.target_state, force);
1163 } 1163 }
1164 } 1164 }
1165 /* 1165 /*
@@ -1168,17 +1168,12 @@ int acpi_processor_set_throttling(struct acpi_processor *pr,
1168 * affected cpu to update the T-states. 1168 * affected cpu to update the T-states.
1169 * The notifier event is THROTTLING_POSTCHANGE 1169 * The notifier event is THROTTLING_POSTCHANGE
1170 */ 1170 */
1171 for_each_cpu(i, online_throttling_cpus) { 1171 for_each_cpu_and(i, cpu_online_mask, p_throttling->shared_cpu_map) {
1172 t_state.cpu = i; 1172 t_state.cpu = i;
1173 acpi_processor_throttling_notifier(THROTTLING_POSTCHANGE, 1173 acpi_processor_throttling_notifier(THROTTLING_POSTCHANGE,
1174 &t_state); 1174 &t_state);
1175 } 1175 }
1176 /* restore the previous state */ 1176
1177 /* FIXME: use work_on_cpu() */
1178 set_cpus_allowed_ptr(current, saved_mask);
1179exit:
1180 free_cpumask_var(online_throttling_cpus);
1181 free_cpumask_var(saved_mask);
1182 return ret; 1177 return ret;
1183} 1178}
1184 1179
diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c
index d465ae6cdd00..dbd48498b938 100644
--- a/drivers/acpi/sbs.c
+++ b/drivers/acpi/sbs.c
@@ -450,7 +450,7 @@ static ssize_t acpi_battery_alarm_store(struct device *dev,
450{ 450{
451 unsigned long x; 451 unsigned long x;
452 struct acpi_battery *battery = to_acpi_battery(dev_get_drvdata(dev)); 452 struct acpi_battery *battery = to_acpi_battery(dev_get_drvdata(dev));
453 if (sscanf(buf, "%ld\n", &x) == 1) 453 if (sscanf(buf, "%lu\n", &x) == 1)
454 battery->alarm_capacity = x / 454 battery->alarm_capacity = x /
455 (1000 * acpi_battery_scale(battery)); 455 (1000 * acpi_battery_scale(battery));
456 if (battery->present) 456 if (battery->present)
@@ -668,6 +668,8 @@ static int acpi_sbs_resume(struct device *dev)
668 acpi_sbs_callback(sbs); 668 acpi_sbs_callback(sbs);
669 return 0; 669 return 0;
670} 670}
671#else
672#define acpi_sbs_resume NULL
671#endif 673#endif
672 674
673static SIMPLE_DEV_PM_OPS(acpi_sbs_pm, NULL, acpi_sbs_resume); 675static SIMPLE_DEV_PM_OPS(acpi_sbs_pm, NULL, acpi_sbs_resume);
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index 8349a555b92b..08626c851be7 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -102,6 +102,8 @@ MODULE_DEVICE_TABLE(acpi, thermal_device_ids);
102 102
103#ifdef CONFIG_PM_SLEEP 103#ifdef CONFIG_PM_SLEEP
104static int acpi_thermal_resume(struct device *dev); 104static int acpi_thermal_resume(struct device *dev);
105#else
106#define acpi_thermal_resume NULL
105#endif 107#endif
106static SIMPLE_DEV_PM_OPS(acpi_thermal_pm, NULL, acpi_thermal_resume); 108static SIMPLE_DEV_PM_OPS(acpi_thermal_pm, NULL, acpi_thermal_resume);
107 109
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index b727d105046d..b6ba88ed31ae 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -81,11 +81,12 @@ static bool allow_duplicates;
81module_param(allow_duplicates, bool, 0644); 81module_param(allow_duplicates, bool, 0644);
82 82
83/* 83/*
84 * For Windows 8 systems: if set ture and the GPU driver has 84 * For Windows 8 systems: used to decide if video module
85 * registered a backlight interface, skip registering ACPI video's. 85 * should skip registering backlight interface of its own.
86 */ 86 */
87static bool use_native_backlight = false; 87static int use_native_backlight_param = -1;
88module_param(use_native_backlight, bool, 0644); 88module_param_named(use_native_backlight, use_native_backlight_param, int, 0444);
89static bool use_native_backlight_dmi = false;
89 90
90static int register_count; 91static int register_count;
91static struct mutex video_list_lock; 92static struct mutex video_list_lock;
@@ -231,9 +232,17 @@ static int acpi_video_get_next_level(struct acpi_video_device *device,
231static int acpi_video_switch_brightness(struct acpi_video_device *device, 232static int acpi_video_switch_brightness(struct acpi_video_device *device,
232 int event); 233 int event);
233 234
235static bool acpi_video_use_native_backlight(void)
236{
237 if (use_native_backlight_param != -1)
238 return use_native_backlight_param;
239 else
240 return use_native_backlight_dmi;
241}
242
234static bool acpi_video_verify_backlight_support(void) 243static bool acpi_video_verify_backlight_support(void)
235{ 244{
236 if (acpi_osi_is_win8() && use_native_backlight && 245 if (acpi_osi_is_win8() && acpi_video_use_native_backlight() &&
237 backlight_device_registered(BACKLIGHT_RAW)) 246 backlight_device_registered(BACKLIGHT_RAW))
238 return false; 247 return false;
239 return acpi_video_backlight_support(); 248 return acpi_video_backlight_support();
@@ -398,6 +407,12 @@ static int __init video_set_bqc_offset(const struct dmi_system_id *d)
398 return 0; 407 return 0;
399} 408}
400 409
410static int __init video_set_use_native_backlight(const struct dmi_system_id *d)
411{
412 use_native_backlight_dmi = true;
413 return 0;
414}
415
401static struct dmi_system_id video_dmi_table[] __initdata = { 416static struct dmi_system_id video_dmi_table[] __initdata = {
402 /* 417 /*
403 * Broken _BQC workaround http://bugzilla.kernel.org/show_bug.cgi?id=13121 418 * Broken _BQC workaround http://bugzilla.kernel.org/show_bug.cgi?id=13121
@@ -442,6 +457,120 @@ static struct dmi_system_id video_dmi_table[] __initdata = {
442 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 7720"), 457 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 7720"),
443 }, 458 },
444 }, 459 },
460 {
461 .callback = video_set_use_native_backlight,
462 .ident = "ThinkPad T430s",
463 .matches = {
464 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
465 DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad T430s"),
466 },
467 },
468 {
469 .callback = video_set_use_native_backlight,
470 .ident = "ThinkPad X230",
471 .matches = {
472 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
473 DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad X230"),
474 },
475 },
476 {
477 .callback = video_set_use_native_backlight,
478 .ident = "ThinkPad X1 Carbon",
479 .matches = {
480 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
481 DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad X1 Carbon"),
482 },
483 },
484 {
485 .callback = video_set_use_native_backlight,
486 .ident = "Lenovo Yoga 13",
487 .matches = {
488 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
489 DMI_MATCH(DMI_PRODUCT_VERSION, "Lenovo IdeaPad Yoga 13"),
490 },
491 },
492 {
493 .callback = video_set_use_native_backlight,
494 .ident = "Dell Inspiron 7520",
495 .matches = {
496 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
497 DMI_MATCH(DMI_PRODUCT_VERSION, "Inspiron 7520"),
498 },
499 },
500 {
501 .callback = video_set_use_native_backlight,
502 .ident = "Acer Aspire 5733Z",
503 .matches = {
504 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
505 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5733Z"),
506 },
507 },
508 {
509 .callback = video_set_use_native_backlight,
510 .ident = "Acer Aspire V5-431",
511 .matches = {
512 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
513 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire V5-431"),
514 },
515 },
516 {
517 .callback = video_set_use_native_backlight,
518 .ident = "HP ProBook 4340s",
519 .matches = {
520 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
521 DMI_MATCH(DMI_PRODUCT_VERSION, "HP ProBook 4340s"),
522 },
523 },
524 {
525 .callback = video_set_use_native_backlight,
526 .ident = "HP ProBook 2013 models",
527 .matches = {
528 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
529 DMI_MATCH(DMI_PRODUCT_NAME, "HP ProBook "),
530 DMI_MATCH(DMI_PRODUCT_NAME, " G1"),
531 },
532 },
533 {
534 .callback = video_set_use_native_backlight,
535 .ident = "HP EliteBook 2013 models",
536 .matches = {
537 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
538 DMI_MATCH(DMI_PRODUCT_NAME, "HP EliteBook "),
539 DMI_MATCH(DMI_PRODUCT_NAME, " G1"),
540 },
541 },
542 {
543 .callback = video_set_use_native_backlight,
544 .ident = "HP ZBook 14",
545 .matches = {
546 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
547 DMI_MATCH(DMI_PRODUCT_NAME, "HP ZBook 14"),
548 },
549 },
550 {
551 .callback = video_set_use_native_backlight,
552 .ident = "HP ZBook 15",
553 .matches = {
554 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
555 DMI_MATCH(DMI_PRODUCT_NAME, "HP ZBook 15"),
556 },
557 },
558 {
559 .callback = video_set_use_native_backlight,
560 .ident = "HP ZBook 17",
561 .matches = {
562 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
563 DMI_MATCH(DMI_PRODUCT_NAME, "HP ZBook 17"),
564 },
565 },
566 {
567 .callback = video_set_use_native_backlight,
568 .ident = "HP EliteBook 8780w",
569 .matches = {
570 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
571 DMI_MATCH(DMI_PRODUCT_NAME, "HP EliteBook 8780w"),
572 },
573 },
445 {} 574 {}
446}; 575};
447 576
@@ -685,6 +814,7 @@ acpi_video_init_brightness(struct acpi_video_device *device)
685 union acpi_object *o; 814 union acpi_object *o;
686 struct acpi_video_device_brightness *br = NULL; 815 struct acpi_video_device_brightness *br = NULL;
687 int result = -EINVAL; 816 int result = -EINVAL;
817 u32 value;
688 818
689 if (!ACPI_SUCCESS(acpi_video_device_lcd_query_levels(device, &obj))) { 819 if (!ACPI_SUCCESS(acpi_video_device_lcd_query_levels(device, &obj))) {
690 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Could not query available " 820 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Could not query available "
@@ -715,7 +845,12 @@ acpi_video_init_brightness(struct acpi_video_device *device)
715 printk(KERN_ERR PREFIX "Invalid data\n"); 845 printk(KERN_ERR PREFIX "Invalid data\n");
716 continue; 846 continue;
717 } 847 }
718 br->levels[count] = (u32) o->integer.value; 848 value = (u32) o->integer.value;
849 /* Skip duplicate entries */
850 if (count > 2 && br->levels[count - 1] == value)
851 continue;
852
853 br->levels[count] = value;
719 854
720 if (br->levels[count] > max_level) 855 if (br->levels[count] > max_level)
721 max_level = br->levels[count]; 856 max_level = br->levels[count];
diff --git a/drivers/acpi/video_detect.c b/drivers/acpi/video_detect.c
index a697b77b8865..19080c8e2f2a 100644
--- a/drivers/acpi/video_detect.c
+++ b/drivers/acpi/video_detect.c
@@ -168,22 +168,6 @@ static struct dmi_system_id video_detect_dmi_table[] = {
168 DMI_MATCH(DMI_PRODUCT_NAME, "UL30A"), 168 DMI_MATCH(DMI_PRODUCT_NAME, "UL30A"),
169 }, 169 },
170 }, 170 },
171 {
172 .callback = video_detect_force_vendor,
173 .ident = "HP EliteBook Revolve 810",
174 .matches = {
175 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
176 DMI_MATCH(DMI_PRODUCT_NAME, "HP EliteBook Revolve 810 G1"),
177 },
178 },
179 {
180 .callback = video_detect_force_vendor,
181 .ident = "Lenovo Yoga 13",
182 .matches = {
183 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
184 DMI_MATCH(DMI_PRODUCT_VERSION, "Lenovo IdeaPad Yoga 13"),
185 },
186 },
187 { }, 171 { },
188}; 172};
189 173
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index 4e737728aee2..868429a47be4 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -247,6 +247,7 @@ config SATA_HIGHBANK
247 247
248config SATA_MV 248config SATA_MV
249 tristate "Marvell SATA support" 249 tristate "Marvell SATA support"
250 select GENERIC_PHY
250 help 251 help
251 This option enables support for the Marvell Serial ATA family. 252 This option enables support for the Marvell Serial ATA family.
252 Currently supports 88SX[56]0[48][01] PCI(-X) chips, 253 Currently supports 88SX[56]0[48][01] PCI(-X) chips,
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index dc2756fb6f33..c81d809c111b 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -61,6 +61,7 @@ enum board_ids {
61 /* board IDs by feature in alphabetical order */ 61 /* board IDs by feature in alphabetical order */
62 board_ahci, 62 board_ahci,
63 board_ahci_ign_iferr, 63 board_ahci_ign_iferr,
64 board_ahci_noncq,
64 board_ahci_nosntf, 65 board_ahci_nosntf,
65 board_ahci_yes_fbs, 66 board_ahci_yes_fbs,
66 67
@@ -121,6 +122,13 @@ static const struct ata_port_info ahci_port_info[] = {
121 .udma_mask = ATA_UDMA6, 122 .udma_mask = ATA_UDMA6,
122 .port_ops = &ahci_ops, 123 .port_ops = &ahci_ops,
123 }, 124 },
125 [board_ahci_noncq] = {
126 AHCI_HFLAGS (AHCI_HFLAG_NO_NCQ),
127 .flags = AHCI_FLAG_COMMON,
128 .pio_mask = ATA_PIO4,
129 .udma_mask = ATA_UDMA6,
130 .port_ops = &ahci_ops,
131 },
124 [board_ahci_nosntf] = { 132 [board_ahci_nosntf] = {
125 AHCI_HFLAGS (AHCI_HFLAG_NO_SNTF), 133 AHCI_HFLAGS (AHCI_HFLAG_NO_SNTF),
126 .flags = AHCI_FLAG_COMMON, 134 .flags = AHCI_FLAG_COMMON,
@@ -452,6 +460,12 @@ static const struct pci_device_id ahci_pci_tbl[] = {
452 { PCI_VDEVICE(ASMEDIA, 0x0611), board_ahci }, /* ASM1061 */ 460 { PCI_VDEVICE(ASMEDIA, 0x0611), board_ahci }, /* ASM1061 */
453 { PCI_VDEVICE(ASMEDIA, 0x0612), board_ahci }, /* ASM1062 */ 461 { PCI_VDEVICE(ASMEDIA, 0x0612), board_ahci }, /* ASM1062 */
454 462
463 /*
464 * Samsung SSDs found on some macbooks. NCQ times out.
465 * https://bugzilla.kernel.org/show_bug.cgi?id=60731
466 */
467 { PCI_VDEVICE(SAMSUNG, 0x1600), board_ahci_noncq },
468
455 /* Enmotus */ 469 /* Enmotus */
456 { PCI_DEVICE(0x1c44, 0x8000), board_ahci }, 470 { PCI_DEVICE(0x1c44, 0x8000), board_ahci },
457 471
@@ -1170,8 +1184,10 @@ static int ahci_init_interrupts(struct pci_dev *pdev, unsigned int n_ports,
1170 1184
1171 nvec = rc; 1185 nvec = rc;
1172 rc = pci_enable_msi_block(pdev, nvec); 1186 rc = pci_enable_msi_block(pdev, nvec);
1173 if (rc) 1187 if (rc < 0)
1174 goto intx; 1188 goto intx;
1189 else if (rc > 0)
1190 goto single_msi;
1175 1191
1176 return nvec; 1192 return nvec;
1177 1193
diff --git a/drivers/ata/libata-pmp.c b/drivers/ata/libata-pmp.c
index 20fd337a5731..7ccc084bf1df 100644
--- a/drivers/ata/libata-pmp.c
+++ b/drivers/ata/libata-pmp.c
@@ -447,8 +447,11 @@ static void sata_pmp_quirks(struct ata_port *ap)
447 * otherwise. Don't try hard to recover it. 447 * otherwise. Don't try hard to recover it.
448 */ 448 */
449 ap->pmp_link[ap->nr_pmp_links - 1].flags |= ATA_LFLAG_NO_RETRY; 449 ap->pmp_link[ap->nr_pmp_links - 1].flags |= ATA_LFLAG_NO_RETRY;
450 } else if (vendor == 0x197b && devid == 0x2352) { 450 } else if (vendor == 0x197b && (devid == 0x2352 || devid == 0x0325)) {
451 /* chip found in Thermaltake BlackX Duet, jmicron JMB350? */ 451 /*
452 * 0x2352: found in Thermaltake BlackX Duet, jmicron JMB350?
453 * 0x0325: jmicron JMB394.
454 */
452 ata_for_each_link(link, ap, EDGE) { 455 ata_for_each_link(link, ap, EDGE) {
453 /* SRST breaks detection and disks get misclassified 456 /* SRST breaks detection and disks get misclassified
454 * LPM disabled to avoid potential problems 457 * LPM disabled to avoid potential problems
diff --git a/drivers/ata/pata_imx.c b/drivers/ata/pata_imx.c
index 26386f0b89a8..b0b18ec5465f 100644
--- a/drivers/ata/pata_imx.c
+++ b/drivers/ata/pata_imx.c
@@ -119,7 +119,9 @@ static int pata_imx_probe(struct platform_device *pdev)
119 return PTR_ERR(priv->clk); 119 return PTR_ERR(priv->clk);
120 } 120 }
121 121
122 clk_prepare_enable(priv->clk); 122 ret = clk_prepare_enable(priv->clk);
123 if (ret)
124 return ret;
123 125
124 host = ata_host_alloc(&pdev->dev, 1); 126 host = ata_host_alloc(&pdev->dev, 1);
125 if (!host) { 127 if (!host) {
@@ -212,7 +214,9 @@ static int pata_imx_resume(struct device *dev)
212 struct ata_host *host = dev_get_drvdata(dev); 214 struct ata_host *host = dev_get_drvdata(dev);
213 struct pata_imx_priv *priv = host->private_data; 215 struct pata_imx_priv *priv = host->private_data;
214 216
215 clk_prepare_enable(priv->clk); 217 int ret = clk_prepare_enable(priv->clk);
218 if (ret)
219 return ret;
216 220
217 __raw_writel(priv->ata_ctl, priv->host_regs + PATA_IMX_ATA_CONTROL); 221 __raw_writel(priv->ata_ctl, priv->host_regs + PATA_IMX_ATA_CONTROL);
218 222
diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c
index 52b8181ddafd..05c8a44adf8e 100644
--- a/drivers/ata/sata_mv.c
+++ b/drivers/ata/sata_mv.c
@@ -4104,7 +4104,6 @@ static int mv_platform_probe(struct platform_device *pdev)
4104 if (!hpriv->port_phys) 4104 if (!hpriv->port_phys)
4105 return -ENOMEM; 4105 return -ENOMEM;
4106 host->private_data = hpriv; 4106 host->private_data = hpriv;
4107 hpriv->n_ports = n_ports;
4108 hpriv->board_idx = chip_soc; 4107 hpriv->board_idx = chip_soc;
4109 4108
4110 host->iomap = NULL; 4109 host->iomap = NULL;
@@ -4132,13 +4131,18 @@ static int mv_platform_probe(struct platform_device *pdev)
4132 rc = PTR_ERR(hpriv->port_phys[port]); 4131 rc = PTR_ERR(hpriv->port_phys[port]);
4133 hpriv->port_phys[port] = NULL; 4132 hpriv->port_phys[port] = NULL;
4134 if (rc != -EPROBE_DEFER) 4133 if (rc != -EPROBE_DEFER)
4135 dev_warn(&pdev->dev, "error getting phy %d", 4134 dev_warn(&pdev->dev, "error getting phy %d", rc);
4136 rc); 4135
4136 /* Cleanup only the initialized ports */
4137 hpriv->n_ports = port;
4137 goto err; 4138 goto err;
4138 } else 4139 } else
4139 phy_power_on(hpriv->port_phys[port]); 4140 phy_power_on(hpriv->port_phys[port]);
4140 } 4141 }
4141 4142
4143 /* All the ports have been initialized */
4144 hpriv->n_ports = n_ports;
4145
4142 /* 4146 /*
4143 * (Re-)program MBUS remapping windows if we are asked to. 4147 * (Re-)program MBUS remapping windows if we are asked to.
4144 */ 4148 */
@@ -4176,7 +4180,7 @@ err:
4176 clk_disable_unprepare(hpriv->clk); 4180 clk_disable_unprepare(hpriv->clk);
4177 clk_put(hpriv->clk); 4181 clk_put(hpriv->clk);
4178 } 4182 }
4179 for (port = 0; port < n_ports; port++) { 4183 for (port = 0; port < hpriv->n_ports; port++) {
4180 if (!IS_ERR(hpriv->port_clks[port])) { 4184 if (!IS_ERR(hpriv->port_clks[port])) {
4181 clk_disable_unprepare(hpriv->port_clks[port]); 4185 clk_disable_unprepare(hpriv->port_clks[port]);
4182 clk_put(hpriv->port_clks[port]); 4186 clk_put(hpriv->port_clks[port]);
diff --git a/drivers/ata/sata_sil.c b/drivers/ata/sata_sil.c
index d67fc351343c..b7695e804635 100644
--- a/drivers/ata/sata_sil.c
+++ b/drivers/ata/sata_sil.c
@@ -157,6 +157,7 @@ static const struct sil_drivelist {
157 { "ST380011ASL", SIL_QUIRK_MOD15WRITE }, 157 { "ST380011ASL", SIL_QUIRK_MOD15WRITE },
158 { "ST3120022ASL", SIL_QUIRK_MOD15WRITE }, 158 { "ST3120022ASL", SIL_QUIRK_MOD15WRITE },
159 { "ST3160021ASL", SIL_QUIRK_MOD15WRITE }, 159 { "ST3160021ASL", SIL_QUIRK_MOD15WRITE },
160 { "TOSHIBA MK2561GSYN", SIL_QUIRK_MOD15WRITE },
160 { "Maxtor 4D060H3", SIL_QUIRK_UDMA5MAX }, 161 { "Maxtor 4D060H3", SIL_QUIRK_UDMA5MAX },
161 { } 162 { }
162}; 163};
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index 8a97ddfa6122..c30df50e4440 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -1580,6 +1580,7 @@ static int fw_pm_notify(struct notifier_block *notify_block,
1580 switch (mode) { 1580 switch (mode) {
1581 case PM_HIBERNATION_PREPARE: 1581 case PM_HIBERNATION_PREPARE:
1582 case PM_SUSPEND_PREPARE: 1582 case PM_SUSPEND_PREPARE:
1583 case PM_RESTORE_PREPARE:
1583 kill_requests_without_uevent(); 1584 kill_requests_without_uevent();
1584 device_cache_fw_images(); 1585 device_cache_fw_images();
1585 break; 1586 break;
diff --git a/drivers/block/aoe/aoecmd.c b/drivers/block/aoe/aoecmd.c
index 8184451b57c0..422b7d84f686 100644
--- a/drivers/block/aoe/aoecmd.c
+++ b/drivers/block/aoe/aoecmd.c
@@ -874,7 +874,7 @@ bio_pageinc(struct bio *bio)
874 /* Non-zero page count for non-head members of 874 /* Non-zero page count for non-head members of
875 * compound pages is no longer allowed by the kernel. 875 * compound pages is no longer allowed by the kernel.
876 */ 876 */
877 page = compound_trans_head(bv.bv_page); 877 page = compound_head(bv.bv_page);
878 atomic_inc(&page->_count); 878 atomic_inc(&page->_count);
879 } 879 }
880} 880}
@@ -887,7 +887,7 @@ bio_pagedec(struct bio *bio)
887 struct bvec_iter iter; 887 struct bvec_iter iter;
888 888
889 bio_for_each_segment(bv, bio, iter) { 889 bio_for_each_segment(bv, bio, iter) {
890 page = compound_trans_head(bv.bv_page); 890 page = compound_head(bv.bv_page);
891 atomic_dec(&page->_count); 891 atomic_dec(&page->_count);
892 } 892 }
893} 893}
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index 011e55d820b1..51c557cfd92b 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -612,6 +612,8 @@ static ssize_t disksize_store(struct device *dev,
612 612
613 disksize = PAGE_ALIGN(disksize); 613 disksize = PAGE_ALIGN(disksize);
614 meta = zram_meta_alloc(disksize); 614 meta = zram_meta_alloc(disksize);
615 if (!meta)
616 return -ENOMEM;
615 down_write(&zram->init_lock); 617 down_write(&zram->init_lock);
616 if (zram->init_done) { 618 if (zram->init_done) {
617 up_write(&zram->init_lock); 619 up_write(&zram->init_lock);
diff --git a/drivers/clk/at91/clk-master.c b/drivers/clk/at91/clk-master.c
index bd313f7816a8..c1af80bcdf20 100644
--- a/drivers/clk/at91/clk-master.c
+++ b/drivers/clk/at91/clk-master.c
@@ -242,7 +242,7 @@ of_at91_clk_master_setup(struct device_node *np, struct at91_pmc *pmc,
242 242
243 irq = irq_of_parse_and_map(np, 0); 243 irq = irq_of_parse_and_map(np, 0);
244 if (!irq) 244 if (!irq)
245 return; 245 goto out_free_characteristics;
246 246
247 clk = at91_clk_register_master(pmc, irq, name, num_parents, 247 clk = at91_clk_register_master(pmc, irq, name, num_parents,
248 parent_names, layout, 248 parent_names, layout,
diff --git a/drivers/clk/clk-nomadik.c b/drivers/clk/clk-nomadik.c
index 6a934a5296bd..05e04ce0f148 100644
--- a/drivers/clk/clk-nomadik.c
+++ b/drivers/clk/clk-nomadik.c
@@ -494,6 +494,9 @@ static const struct file_operations nomadik_src_clk_debugfs_ops = {
494 494
495static int __init nomadik_src_clk_init_debugfs(void) 495static int __init nomadik_src_clk_init_debugfs(void)
496{ 496{
497 /* Vital for multiplatform */
498 if (!src_base)
499 return -ENODEV;
497 src_pcksr0_boot = readl(src_base + SRC_PCKSR0); 500 src_pcksr0_boot = readl(src_base + SRC_PCKSR0);
498 src_pcksr1_boot = readl(src_base + SRC_PCKSR1); 501 src_pcksr1_boot = readl(src_base + SRC_PCKSR1);
499 debugfs_create_file("nomadik-src-clk", S_IFREG | S_IRUGO, 502 debugfs_create_file("nomadik-src-clk", S_IFREG | S_IRUGO,
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 5517944495d8..c42e608af6bb 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -2226,24 +2226,25 @@ EXPORT_SYMBOL_GPL(devm_clk_unregister);
2226 */ 2226 */
2227int __clk_get(struct clk *clk) 2227int __clk_get(struct clk *clk)
2228{ 2228{
2229 if (clk && !try_module_get(clk->owner)) 2229 if (clk) {
2230 return 0; 2230 if (!try_module_get(clk->owner))
2231 return 0;
2231 2232
2232 kref_get(&clk->ref); 2233 kref_get(&clk->ref);
2234 }
2233 return 1; 2235 return 1;
2234} 2236}
2235 2237
2236void __clk_put(struct clk *clk) 2238void __clk_put(struct clk *clk)
2237{ 2239{
2238 if (WARN_ON_ONCE(IS_ERR(clk))) 2240 if (!clk || WARN_ON_ONCE(IS_ERR(clk)))
2239 return; 2241 return;
2240 2242
2241 clk_prepare_lock(); 2243 clk_prepare_lock();
2242 kref_put(&clk->ref, __clk_release); 2244 kref_put(&clk->ref, __clk_release);
2243 clk_prepare_unlock(); 2245 clk_prepare_unlock();
2244 2246
2245 if (clk) 2247 module_put(clk->owner);
2246 module_put(clk->owner);
2247} 2248}
2248 2249
2249/*** clk rate change notifiers ***/ 2250/*** clk rate change notifiers ***/
diff --git a/drivers/clk/keystone/gate.c b/drivers/clk/keystone/gate.c
index 17a598398a53..86f1e362eafb 100644
--- a/drivers/clk/keystone/gate.c
+++ b/drivers/clk/keystone/gate.c
@@ -179,6 +179,7 @@ static struct clk *clk_register_psc(struct device *dev,
179 179
180 init.name = name; 180 init.name = name;
181 init.ops = &clk_psc_ops; 181 init.ops = &clk_psc_ops;
182 init.flags = 0;
182 init.parent_names = (parent_name ? &parent_name : NULL); 183 init.parent_names = (parent_name ? &parent_name : NULL);
183 init.num_parents = (parent_name ? 1 : 0); 184 init.num_parents = (parent_name ? 1 : 0);
184 185
diff --git a/drivers/clk/mvebu/armada-370.c b/drivers/clk/mvebu/armada-370.c
index 81a202d12a7a..bef198a83863 100644
--- a/drivers/clk/mvebu/armada-370.c
+++ b/drivers/clk/mvebu/armada-370.c
@@ -141,13 +141,6 @@ static const struct coreclk_soc_desc a370_coreclks = {
141 .num_ratios = ARRAY_SIZE(a370_coreclk_ratios), 141 .num_ratios = ARRAY_SIZE(a370_coreclk_ratios),
142}; 142};
143 143
144static void __init a370_coreclk_init(struct device_node *np)
145{
146 mvebu_coreclk_setup(np, &a370_coreclks);
147}
148CLK_OF_DECLARE(a370_core_clk, "marvell,armada-370-core-clock",
149 a370_coreclk_init);
150
151/* 144/*
152 * Clock Gating Control 145 * Clock Gating Control
153 */ 146 */
@@ -168,9 +161,15 @@ static const struct clk_gating_soc_desc a370_gating_desc[] __initconst = {
168 { } 161 { }
169}; 162};
170 163
171static void __init a370_clk_gating_init(struct device_node *np) 164static void __init a370_clk_init(struct device_node *np)
172{ 165{
173 mvebu_clk_gating_setup(np, a370_gating_desc); 166 struct device_node *cgnp =
167 of_find_compatible_node(NULL, NULL, "marvell,armada-370-gating-clock");
168
169 mvebu_coreclk_setup(np, &a370_coreclks);
170
171 if (cgnp)
172 mvebu_clk_gating_setup(cgnp, a370_gating_desc);
174} 173}
175CLK_OF_DECLARE(a370_clk_gating, "marvell,armada-370-gating-clock", 174CLK_OF_DECLARE(a370_clk, "marvell,armada-370-core-clock", a370_clk_init);
176 a370_clk_gating_init); 175
diff --git a/drivers/clk/mvebu/armada-xp.c b/drivers/clk/mvebu/armada-xp.c
index 9922c4475aa8..b3094315a3c0 100644
--- a/drivers/clk/mvebu/armada-xp.c
+++ b/drivers/clk/mvebu/armada-xp.c
@@ -158,13 +158,6 @@ static const struct coreclk_soc_desc axp_coreclks = {
158 .num_ratios = ARRAY_SIZE(axp_coreclk_ratios), 158 .num_ratios = ARRAY_SIZE(axp_coreclk_ratios),
159}; 159};
160 160
161static void __init axp_coreclk_init(struct device_node *np)
162{
163 mvebu_coreclk_setup(np, &axp_coreclks);
164}
165CLK_OF_DECLARE(axp_core_clk, "marvell,armada-xp-core-clock",
166 axp_coreclk_init);
167
168/* 161/*
169 * Clock Gating Control 162 * Clock Gating Control
170 */ 163 */
@@ -202,9 +195,14 @@ static const struct clk_gating_soc_desc axp_gating_desc[] __initconst = {
202 { } 195 { }
203}; 196};
204 197
205static void __init axp_clk_gating_init(struct device_node *np) 198static void __init axp_clk_init(struct device_node *np)
206{ 199{
207 mvebu_clk_gating_setup(np, axp_gating_desc); 200 struct device_node *cgnp =
201 of_find_compatible_node(NULL, NULL, "marvell,armada-xp-gating-clock");
202
203 mvebu_coreclk_setup(np, &axp_coreclks);
204
205 if (cgnp)
206 mvebu_clk_gating_setup(cgnp, axp_gating_desc);
208} 207}
209CLK_OF_DECLARE(axp_clk_gating, "marvell,armada-xp-gating-clock", 208CLK_OF_DECLARE(axp_clk, "marvell,armada-xp-core-clock", axp_clk_init);
210 axp_clk_gating_init);
diff --git a/drivers/clk/mvebu/dove.c b/drivers/clk/mvebu/dove.c
index 38aee1e3f242..b8c2424ac926 100644
--- a/drivers/clk/mvebu/dove.c
+++ b/drivers/clk/mvebu/dove.c
@@ -154,12 +154,6 @@ static const struct coreclk_soc_desc dove_coreclks = {
154 .num_ratios = ARRAY_SIZE(dove_coreclk_ratios), 154 .num_ratios = ARRAY_SIZE(dove_coreclk_ratios),
155}; 155};
156 156
157static void __init dove_coreclk_init(struct device_node *np)
158{
159 mvebu_coreclk_setup(np, &dove_coreclks);
160}
161CLK_OF_DECLARE(dove_core_clk, "marvell,dove-core-clock", dove_coreclk_init);
162
163/* 157/*
164 * Clock Gating Control 158 * Clock Gating Control
165 */ 159 */
@@ -186,9 +180,14 @@ static const struct clk_gating_soc_desc dove_gating_desc[] __initconst = {
186 { } 180 { }
187}; 181};
188 182
189static void __init dove_clk_gating_init(struct device_node *np) 183static void __init dove_clk_init(struct device_node *np)
190{ 184{
191 mvebu_clk_gating_setup(np, dove_gating_desc); 185 struct device_node *cgnp =
186 of_find_compatible_node(NULL, NULL, "marvell,dove-gating-clock");
187
188 mvebu_coreclk_setup(np, &dove_coreclks);
189
190 if (cgnp)
191 mvebu_clk_gating_setup(cgnp, dove_gating_desc);
192} 192}
193CLK_OF_DECLARE(dove_clk_gating, "marvell,dove-gating-clock", 193CLK_OF_DECLARE(dove_clk, "marvell,dove-core-clock", dove_clk_init);
194 dove_clk_gating_init);
diff --git a/drivers/clk/mvebu/kirkwood.c b/drivers/clk/mvebu/kirkwood.c
index 2636a55f29f9..ddb666a86500 100644
--- a/drivers/clk/mvebu/kirkwood.c
+++ b/drivers/clk/mvebu/kirkwood.c
@@ -193,13 +193,6 @@ static const struct coreclk_soc_desc kirkwood_coreclks = {
193 .num_ratios = ARRAY_SIZE(kirkwood_coreclk_ratios), 193 .num_ratios = ARRAY_SIZE(kirkwood_coreclk_ratios),
194}; 194};
195 195
196static void __init kirkwood_coreclk_init(struct device_node *np)
197{
198 mvebu_coreclk_setup(np, &kirkwood_coreclks);
199}
200CLK_OF_DECLARE(kirkwood_core_clk, "marvell,kirkwood-core-clock",
201 kirkwood_coreclk_init);
202
203static const struct coreclk_soc_desc mv88f6180_coreclks = { 196static const struct coreclk_soc_desc mv88f6180_coreclks = {
204 .get_tclk_freq = kirkwood_get_tclk_freq, 197 .get_tclk_freq = kirkwood_get_tclk_freq,
205 .get_cpu_freq = mv88f6180_get_cpu_freq, 198 .get_cpu_freq = mv88f6180_get_cpu_freq,
@@ -208,13 +201,6 @@ static const struct coreclk_soc_desc mv88f6180_coreclks = {
208 .num_ratios = ARRAY_SIZE(kirkwood_coreclk_ratios), 201 .num_ratios = ARRAY_SIZE(kirkwood_coreclk_ratios),
209}; 202};
210 203
211static void __init mv88f6180_coreclk_init(struct device_node *np)
212{
213 mvebu_coreclk_setup(np, &mv88f6180_coreclks);
214}
215CLK_OF_DECLARE(mv88f6180_core_clk, "marvell,mv88f6180-core-clock",
216 mv88f6180_coreclk_init);
217
218/* 204/*
219 * Clock Gating Control 205 * Clock Gating Control
220 */ 206 */
@@ -239,9 +225,21 @@ static const struct clk_gating_soc_desc kirkwood_gating_desc[] __initconst = {
239 { } 225 { }
240}; 226};
241 227
242static void __init kirkwood_clk_gating_init(struct device_node *np) 228static void __init kirkwood_clk_init(struct device_node *np)
243{ 229{
244 mvebu_clk_gating_setup(np, kirkwood_gating_desc); 230 struct device_node *cgnp =
231 of_find_compatible_node(NULL, NULL, "marvell,kirkwood-gating-clock");
232
233
234 if (of_device_is_compatible(np, "marvell,mv88f6180-core-clock"))
235 mvebu_coreclk_setup(np, &mv88f6180_coreclks);
236 else
237 mvebu_coreclk_setup(np, &kirkwood_coreclks);
238
239 if (cgnp)
240 mvebu_clk_gating_setup(cgnp, kirkwood_gating_desc);
245} 241}
246CLK_OF_DECLARE(kirkwood_clk_gating, "marvell,kirkwood-gating-clock", 242CLK_OF_DECLARE(kirkwood_clk, "marvell,kirkwood-core-clock",
247 kirkwood_clk_gating_init); 243 kirkwood_clk_init);
244CLK_OF_DECLARE(mv88f6180_clk, "marvell,mv88f6180-core-clock",
245 kirkwood_clk_init);
diff --git a/drivers/clk/shmobile/clk-rcar-gen2.c b/drivers/clk/shmobile/clk-rcar-gen2.c
index a59ec217a124..dd272a0d1446 100644
--- a/drivers/clk/shmobile/clk-rcar-gen2.c
+++ b/drivers/clk/shmobile/clk-rcar-gen2.c
@@ -186,7 +186,7 @@ rcar_gen2_cpg_register_clock(struct device_node *np, struct rcar_gen2_cpg *cpg,
186 const char *name) 186 const char *name)
187{ 187{
188 const struct clk_div_table *table = NULL; 188 const struct clk_div_table *table = NULL;
189 const char *parent_name = "main"; 189 const char *parent_name;
190 unsigned int shift; 190 unsigned int shift;
191 unsigned int mult = 1; 191 unsigned int mult = 1;
192 unsigned int div = 1; 192 unsigned int div = 1;
@@ -201,23 +201,31 @@ rcar_gen2_cpg_register_clock(struct device_node *np, struct rcar_gen2_cpg *cpg,
201 * the multiplier value. 201 * the multiplier value.
202 */ 202 */
203 u32 value = clk_readl(cpg->reg + CPG_PLL0CR); 203 u32 value = clk_readl(cpg->reg + CPG_PLL0CR);
204 parent_name = "main";
204 mult = ((value >> 24) & ((1 << 7) - 1)) + 1; 205 mult = ((value >> 24) & ((1 << 7) - 1)) + 1;
205 } else if (!strcmp(name, "pll1")) { 206 } else if (!strcmp(name, "pll1")) {
207 parent_name = "main";
206 mult = config->pll1_mult / 2; 208 mult = config->pll1_mult / 2;
207 } else if (!strcmp(name, "pll3")) { 209 } else if (!strcmp(name, "pll3")) {
210 parent_name = "main";
208 mult = config->pll3_mult; 211 mult = config->pll3_mult;
209 } else if (!strcmp(name, "lb")) { 212 } else if (!strcmp(name, "lb")) {
213 parent_name = "pll1_div2";
210 div = cpg_mode & BIT(18) ? 36 : 24; 214 div = cpg_mode & BIT(18) ? 36 : 24;
211 } else if (!strcmp(name, "qspi")) { 215 } else if (!strcmp(name, "qspi")) {
216 parent_name = "pll1_div2";
212 div = (cpg_mode & (BIT(3) | BIT(2) | BIT(1))) == BIT(2) 217 div = (cpg_mode & (BIT(3) | BIT(2) | BIT(1))) == BIT(2)
213 ? 16 : 20; 218 ? 8 : 10;
214 } else if (!strcmp(name, "sdh")) { 219 } else if (!strcmp(name, "sdh")) {
220 parent_name = "pll1_div2";
215 table = cpg_sdh_div_table; 221 table = cpg_sdh_div_table;
216 shift = 8; 222 shift = 8;
217 } else if (!strcmp(name, "sd0")) { 223 } else if (!strcmp(name, "sd0")) {
224 parent_name = "pll1_div2";
218 table = cpg_sd01_div_table; 225 table = cpg_sd01_div_table;
219 shift = 4; 226 shift = 4;
220 } else if (!strcmp(name, "sd1")) { 227 } else if (!strcmp(name, "sd1")) {
228 parent_name = "pll1_div2";
221 table = cpg_sd01_div_table; 229 table = cpg_sd01_div_table;
222 shift = 0; 230 shift = 0;
223 } else if (!strcmp(name, "z")) { 231 } else if (!strcmp(name, "z")) {
diff --git a/drivers/clk/tegra/clk-divider.c b/drivers/clk/tegra/clk-divider.c
index 4d75b1f37e3a..290f9c1a3749 100644
--- a/drivers/clk/tegra/clk-divider.c
+++ b/drivers/clk/tegra/clk-divider.c
@@ -59,7 +59,7 @@ static int get_div(struct tegra_clk_frac_div *divider, unsigned long rate,
59 return 0; 59 return 0;
60 60
61 if (divider_ux1 > get_max_div(divider)) 61 if (divider_ux1 > get_max_div(divider))
62 return -EINVAL; 62 return get_max_div(divider);
63 63
64 return divider_ux1; 64 return divider_ux1;
65} 65}
diff --git a/drivers/clk/tegra/clk-id.h b/drivers/clk/tegra/clk-id.h
index cf0c323f2c36..c39613c519af 100644
--- a/drivers/clk/tegra/clk-id.h
+++ b/drivers/clk/tegra/clk-id.h
@@ -180,9 +180,13 @@ enum clk_id {
180 tegra_clk_sbc6_8, 180 tegra_clk_sbc6_8,
181 tegra_clk_sclk, 181 tegra_clk_sclk,
182 tegra_clk_sdmmc1, 182 tegra_clk_sdmmc1,
183 tegra_clk_sdmmc1_8,
183 tegra_clk_sdmmc2, 184 tegra_clk_sdmmc2,
185 tegra_clk_sdmmc2_8,
184 tegra_clk_sdmmc3, 186 tegra_clk_sdmmc3,
187 tegra_clk_sdmmc3_8,
185 tegra_clk_sdmmc4, 188 tegra_clk_sdmmc4,
189 tegra_clk_sdmmc4_8,
186 tegra_clk_se, 190 tegra_clk_se,
187 tegra_clk_soc_therm, 191 tegra_clk_soc_therm,
188 tegra_clk_sor0, 192 tegra_clk_sor0,
diff --git a/drivers/clk/tegra/clk-tegra-periph.c b/drivers/clk/tegra/clk-tegra-periph.c
index 5c35885f4a7c..1fa5c3f33b20 100644
--- a/drivers/clk/tegra/clk-tegra-periph.c
+++ b/drivers/clk/tegra/clk-tegra-periph.c
@@ -371,9 +371,7 @@ static const char *mux_pllp3_pllc_clkm[] = {
371static const char *mux_pllm_pllc_pllp_plla_pllc2_c3_clkm[] = { 371static const char *mux_pllm_pllc_pllp_plla_pllc2_c3_clkm[] = {
372 "pll_m", "pll_c", "pll_p", "pll_a", "pll_c2", "pll_c3", "clk_m" 372 "pll_m", "pll_c", "pll_p", "pll_a", "pll_c2", "pll_c3", "clk_m"
373}; 373};
374static u32 mux_pllm_pllc_pllp_plla_pllc2_c3_clkm_idx[] = { 374#define mux_pllm_pllc_pllp_plla_pllc2_c3_clkm_idx NULL
375 [0] = 0, [1] = 1, [2] = 2, [3] = 3, [4] = 4, [5] = 6,
376};
377 375
378static const char *mux_pllm_pllc2_c_c3_pllp_plla_pllc4[] = { 376static const char *mux_pllm_pllc2_c_c3_pllp_plla_pllc4[] = {
379 "pll_m", "pll_c2", "pll_c", "pll_c3", "pll_p", "pll_a_out0", "pll_c4", 377 "pll_m", "pll_c2", "pll_c", "pll_c3", "pll_p", "pll_a_out0", "pll_c4",
@@ -465,6 +463,10 @@ static struct tegra_periph_init_data periph_clks[] = {
465 MUX("adx1", mux_plla_pllc_pllp_clkm, CLK_SOURCE_ADX1, 180, TEGRA_PERIPH_ON_APB, tegra_clk_adx1), 463 MUX("adx1", mux_plla_pllc_pllp_clkm, CLK_SOURCE_ADX1, 180, TEGRA_PERIPH_ON_APB, tegra_clk_adx1),
466 MUX("amx1", mux_plla_pllc_pllp_clkm, CLK_SOURCE_AMX1, 185, TEGRA_PERIPH_ON_APB, tegra_clk_amx1), 464 MUX("amx1", mux_plla_pllc_pllp_clkm, CLK_SOURCE_AMX1, 185, TEGRA_PERIPH_ON_APB, tegra_clk_amx1),
467 MUX("vi_sensor2", mux_pllm_pllc2_c_c3_pllp_plla, CLK_SOURCE_VI_SENSOR2, 20, TEGRA_PERIPH_NO_RESET, tegra_clk_vi_sensor2), 465 MUX("vi_sensor2", mux_pllm_pllc2_c_c3_pllp_plla, CLK_SOURCE_VI_SENSOR2, 20, TEGRA_PERIPH_NO_RESET, tegra_clk_vi_sensor2),
466 MUX8("sdmmc1", mux_pllp_pllc2_c_c3_pllm_clkm, CLK_SOURCE_SDMMC1, 14, 0, tegra_clk_sdmmc1_8),
467 MUX8("sdmmc2", mux_pllp_pllc2_c_c3_pllm_clkm, CLK_SOURCE_SDMMC2, 9, 0, tegra_clk_sdmmc2_8),
468 MUX8("sdmmc3", mux_pllp_pllc2_c_c3_pllm_clkm, CLK_SOURCE_SDMMC3, 69, 0, tegra_clk_sdmmc3_8),
469 MUX8("sdmmc4", mux_pllp_pllc2_c_c3_pllm_clkm, CLK_SOURCE_SDMMC4, 15, 0, tegra_clk_sdmmc4_8),
468 MUX8("sbc1", mux_pllp_pllc2_c_c3_pllm_clkm, CLK_SOURCE_SBC1, 41, TEGRA_PERIPH_ON_APB, tegra_clk_sbc1_8), 470 MUX8("sbc1", mux_pllp_pllc2_c_c3_pllm_clkm, CLK_SOURCE_SBC1, 41, TEGRA_PERIPH_ON_APB, tegra_clk_sbc1_8),
469 MUX8("sbc2", mux_pllp_pllc2_c_c3_pllm_clkm, CLK_SOURCE_SBC2, 44, TEGRA_PERIPH_ON_APB, tegra_clk_sbc2_8), 471 MUX8("sbc2", mux_pllp_pllc2_c_c3_pllm_clkm, CLK_SOURCE_SBC2, 44, TEGRA_PERIPH_ON_APB, tegra_clk_sbc2_8),
470 MUX8("sbc3", mux_pllp_pllc2_c_c3_pllm_clkm, CLK_SOURCE_SBC3, 46, TEGRA_PERIPH_ON_APB, tegra_clk_sbc3_8), 472 MUX8("sbc3", mux_pllp_pllc2_c_c3_pllm_clkm, CLK_SOURCE_SBC3, 46, TEGRA_PERIPH_ON_APB, tegra_clk_sbc3_8),
@@ -492,7 +494,7 @@ static struct tegra_periph_init_data periph_clks[] = {
492 UART("uartb", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_UARTB, 7, tegra_clk_uartb), 494 UART("uartb", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_UARTB, 7, tegra_clk_uartb),
493 UART("uartc", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_UARTC, 55, tegra_clk_uartc), 495 UART("uartc", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_UARTC, 55, tegra_clk_uartc),
494 UART("uartd", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_UARTD, 65, tegra_clk_uartd), 496 UART("uartd", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_UARTD, 65, tegra_clk_uartd),
495 UART("uarte", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_UARTE, 65, tegra_clk_uarte), 497 UART("uarte", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_UARTE, 66, tegra_clk_uarte),
496 XUSB("xusb_host_src", mux_clkm_pllp_pllc_pllre, CLK_SOURCE_XUSB_HOST_SRC, 143, TEGRA_PERIPH_ON_APB | TEGRA_PERIPH_NO_RESET, tegra_clk_xusb_host_src), 498 XUSB("xusb_host_src", mux_clkm_pllp_pllc_pllre, CLK_SOURCE_XUSB_HOST_SRC, 143, TEGRA_PERIPH_ON_APB | TEGRA_PERIPH_NO_RESET, tegra_clk_xusb_host_src),
497 XUSB("xusb_falcon_src", mux_clkm_pllp_pllc_pllre, CLK_SOURCE_XUSB_FALCON_SRC, 143, TEGRA_PERIPH_NO_RESET, tegra_clk_xusb_falcon_src), 499 XUSB("xusb_falcon_src", mux_clkm_pllp_pllc_pllre, CLK_SOURCE_XUSB_FALCON_SRC, 143, TEGRA_PERIPH_NO_RESET, tegra_clk_xusb_falcon_src),
498 XUSB("xusb_fs_src", mux_clkm_48M_pllp_480M, CLK_SOURCE_XUSB_FS_SRC, 143, TEGRA_PERIPH_NO_RESET, tegra_clk_xusb_fs_src), 500 XUSB("xusb_fs_src", mux_clkm_48M_pllp_480M, CLK_SOURCE_XUSB_FS_SRC, 143, TEGRA_PERIPH_NO_RESET, tegra_clk_xusb_fs_src),
diff --git a/drivers/clk/tegra/clk-tegra-super-gen4.c b/drivers/clk/tegra/clk-tegra-super-gen4.c
index 05dce4aa2c11..feb3201c85ce 100644
--- a/drivers/clk/tegra/clk-tegra-super-gen4.c
+++ b/drivers/clk/tegra/clk-tegra-super-gen4.c
@@ -120,7 +120,7 @@ void __init tegra_super_clk_gen4_init(void __iomem *clk_base,
120 ARRAY_SIZE(cclk_lp_parents), 120 ARRAY_SIZE(cclk_lp_parents),
121 CLK_SET_RATE_PARENT, 121 CLK_SET_RATE_PARENT,
122 clk_base + CCLKLP_BURST_POLICY, 122 clk_base + CCLKLP_BURST_POLICY,
123 0, 4, 8, 9, NULL); 123 TEGRA_DIVIDER_2, 4, 8, 9, NULL);
124 *dt_clk = clk; 124 *dt_clk = clk;
125 } 125 }
126 126
diff --git a/drivers/clk/tegra/clk-tegra114.c b/drivers/clk/tegra/clk-tegra114.c
index 90d9d25f2228..80431f0fb268 100644
--- a/drivers/clk/tegra/clk-tegra114.c
+++ b/drivers/clk/tegra/clk-tegra114.c
@@ -682,12 +682,12 @@ static struct tegra_clk tegra114_clks[tegra_clk_max] __initdata = {
682 [tegra_clk_timer] = { .dt_id = TEGRA114_CLK_TIMER, .present = true }, 682 [tegra_clk_timer] = { .dt_id = TEGRA114_CLK_TIMER, .present = true },
683 [tegra_clk_uarta] = { .dt_id = TEGRA114_CLK_UARTA, .present = true }, 683 [tegra_clk_uarta] = { .dt_id = TEGRA114_CLK_UARTA, .present = true },
684 [tegra_clk_uartd] = { .dt_id = TEGRA114_CLK_UARTD, .present = true }, 684 [tegra_clk_uartd] = { .dt_id = TEGRA114_CLK_UARTD, .present = true },
685 [tegra_clk_sdmmc2] = { .dt_id = TEGRA114_CLK_SDMMC2, .present = true }, 685 [tegra_clk_sdmmc2_8] = { .dt_id = TEGRA114_CLK_SDMMC2, .present = true },
686 [tegra_clk_i2s1] = { .dt_id = TEGRA114_CLK_I2S1, .present = true }, 686 [tegra_clk_i2s1] = { .dt_id = TEGRA114_CLK_I2S1, .present = true },
687 [tegra_clk_i2c1] = { .dt_id = TEGRA114_CLK_I2C1, .present = true }, 687 [tegra_clk_i2c1] = { .dt_id = TEGRA114_CLK_I2C1, .present = true },
688 [tegra_clk_ndflash] = { .dt_id = TEGRA114_CLK_NDFLASH, .present = true }, 688 [tegra_clk_ndflash] = { .dt_id = TEGRA114_CLK_NDFLASH, .present = true },
689 [tegra_clk_sdmmc1] = { .dt_id = TEGRA114_CLK_SDMMC1, .present = true }, 689 [tegra_clk_sdmmc1_8] = { .dt_id = TEGRA114_CLK_SDMMC1, .present = true },
690 [tegra_clk_sdmmc4] = { .dt_id = TEGRA114_CLK_SDMMC4, .present = true }, 690 [tegra_clk_sdmmc4_8] = { .dt_id = TEGRA114_CLK_SDMMC4, .present = true },
691 [tegra_clk_pwm] = { .dt_id = TEGRA114_CLK_PWM, .present = true }, 691 [tegra_clk_pwm] = { .dt_id = TEGRA114_CLK_PWM, .present = true },
692 [tegra_clk_i2s0] = { .dt_id = TEGRA114_CLK_I2S0, .present = true }, 692 [tegra_clk_i2s0] = { .dt_id = TEGRA114_CLK_I2S0, .present = true },
693 [tegra_clk_i2s2] = { .dt_id = TEGRA114_CLK_I2S2, .present = true }, 693 [tegra_clk_i2s2] = { .dt_id = TEGRA114_CLK_I2S2, .present = true },
@@ -723,7 +723,7 @@ static struct tegra_clk tegra114_clks[tegra_clk_max] __initdata = {
723 [tegra_clk_bsev] = { .dt_id = TEGRA114_CLK_BSEV, .present = true }, 723 [tegra_clk_bsev] = { .dt_id = TEGRA114_CLK_BSEV, .present = true },
724 [tegra_clk_i2c3] = { .dt_id = TEGRA114_CLK_I2C3, .present = true }, 724 [tegra_clk_i2c3] = { .dt_id = TEGRA114_CLK_I2C3, .present = true },
725 [tegra_clk_sbc4_8] = { .dt_id = TEGRA114_CLK_SBC4, .present = true }, 725 [tegra_clk_sbc4_8] = { .dt_id = TEGRA114_CLK_SBC4, .present = true },
726 [tegra_clk_sdmmc3] = { .dt_id = TEGRA114_CLK_SDMMC3, .present = true }, 726 [tegra_clk_sdmmc3_8] = { .dt_id = TEGRA114_CLK_SDMMC3, .present = true },
727 [tegra_clk_owr] = { .dt_id = TEGRA114_CLK_OWR, .present = true }, 727 [tegra_clk_owr] = { .dt_id = TEGRA114_CLK_OWR, .present = true },
728 [tegra_clk_csite] = { .dt_id = TEGRA114_CLK_CSITE, .present = true }, 728 [tegra_clk_csite] = { .dt_id = TEGRA114_CLK_CSITE, .present = true },
729 [tegra_clk_la] = { .dt_id = TEGRA114_CLK_LA, .present = true }, 729 [tegra_clk_la] = { .dt_id = TEGRA114_CLK_LA, .present = true },
diff --git a/drivers/clk/tegra/clk-tegra124.c b/drivers/clk/tegra/clk-tegra124.c
index aff86b5bc745..166e02f16c8a 100644
--- a/drivers/clk/tegra/clk-tegra124.c
+++ b/drivers/clk/tegra/clk-tegra124.c
@@ -516,11 +516,11 @@ static struct div_nmp pllp_nmp = {
516}; 516};
517 517
518static struct tegra_clk_pll_freq_table pll_p_freq_table[] = { 518static struct tegra_clk_pll_freq_table pll_p_freq_table[] = {
519 {12000000, 216000000, 432, 12, 1, 8}, 519 {12000000, 408000000, 408, 12, 0, 8},
520 {13000000, 216000000, 432, 13, 1, 8}, 520 {13000000, 408000000, 408, 13, 0, 8},
521 {16800000, 216000000, 360, 14, 1, 8}, 521 {16800000, 408000000, 340, 14, 0, 8},
522 {19200000, 216000000, 360, 16, 1, 8}, 522 {19200000, 408000000, 340, 16, 0, 8},
523 {26000000, 216000000, 432, 26, 1, 8}, 523 {26000000, 408000000, 408, 26, 0, 8},
524 {0, 0, 0, 0, 0, 0}, 524 {0, 0, 0, 0, 0, 0},
525}; 525};
526 526
@@ -570,6 +570,15 @@ static struct tegra_clk_pll_params pll_a_params = {
570 .flags = TEGRA_PLL_HAS_CPCON | TEGRA_PLL_USE_LOCK, 570 .flags = TEGRA_PLL_HAS_CPCON | TEGRA_PLL_USE_LOCK,
571}; 571};
572 572
573static struct div_nmp plld_nmp = {
574 .divm_shift = 0,
575 .divm_width = 5,
576 .divn_shift = 8,
577 .divn_width = 11,
578 .divp_shift = 20,
579 .divp_width = 3,
580};
581
573static struct tegra_clk_pll_freq_table pll_d_freq_table[] = { 582static struct tegra_clk_pll_freq_table pll_d_freq_table[] = {
574 {12000000, 216000000, 864, 12, 4, 12}, 583 {12000000, 216000000, 864, 12, 4, 12},
575 {13000000, 216000000, 864, 13, 4, 12}, 584 {13000000, 216000000, 864, 13, 4, 12},
@@ -603,19 +612,18 @@ static struct tegra_clk_pll_params pll_d_params = {
603 .lock_mask = PLL_BASE_LOCK, 612 .lock_mask = PLL_BASE_LOCK,
604 .lock_enable_bit_idx = PLLDU_MISC_LOCK_ENABLE, 613 .lock_enable_bit_idx = PLLDU_MISC_LOCK_ENABLE,
605 .lock_delay = 1000, 614 .lock_delay = 1000,
606 .div_nmp = &pllp_nmp, 615 .div_nmp = &plld_nmp,
607 .freq_table = pll_d_freq_table, 616 .freq_table = pll_d_freq_table,
608 .flags = TEGRA_PLL_HAS_CPCON | TEGRA_PLL_SET_LFCON | 617 .flags = TEGRA_PLL_HAS_CPCON | TEGRA_PLL_SET_LFCON |
609 TEGRA_PLL_USE_LOCK, 618 TEGRA_PLL_USE_LOCK,
610}; 619};
611 620
612static struct tegra_clk_pll_freq_table tegra124_pll_d2_freq_table[] = { 621static struct tegra_clk_pll_freq_table tegra124_pll_d2_freq_table[] = {
613 { 12000000, 148500000, 99, 1, 8}, 622 { 12000000, 594000000, 99, 1, 2},
614 { 12000000, 594000000, 99, 1, 1}, 623 { 13000000, 594000000, 91, 1, 2}, /* actual: 591.5 MHz */
615 { 13000000, 594000000, 91, 1, 1}, /* actual: 591.5 MHz */ 624 { 16800000, 594000000, 71, 1, 2}, /* actual: 596.4 MHz */
616 { 16800000, 594000000, 71, 1, 1}, /* actual: 596.4 MHz */ 625 { 19200000, 594000000, 62, 1, 2}, /* actual: 595.2 MHz */
617 { 19200000, 594000000, 62, 1, 1}, /* actual: 595.2 MHz */ 626 { 26000000, 594000000, 91, 2, 2}, /* actual: 591.5 MHz */
618 { 26000000, 594000000, 91, 2, 1}, /* actual: 591.5 MHz */
619 { 0, 0, 0, 0, 0, 0 }, 627 { 0, 0, 0, 0, 0, 0 },
620}; 628};
621 629
@@ -753,21 +761,19 @@ static struct tegra_clk tegra124_clks[tegra_clk_max] __initdata = {
753 [tegra_clk_rtc] = { .dt_id = TEGRA124_CLK_RTC, .present = true }, 761 [tegra_clk_rtc] = { .dt_id = TEGRA124_CLK_RTC, .present = true },
754 [tegra_clk_timer] = { .dt_id = TEGRA124_CLK_TIMER, .present = true }, 762 [tegra_clk_timer] = { .dt_id = TEGRA124_CLK_TIMER, .present = true },
755 [tegra_clk_uarta] = { .dt_id = TEGRA124_CLK_UARTA, .present = true }, 763 [tegra_clk_uarta] = { .dt_id = TEGRA124_CLK_UARTA, .present = true },
756 [tegra_clk_sdmmc2] = { .dt_id = TEGRA124_CLK_SDMMC2, .present = true }, 764 [tegra_clk_sdmmc2_8] = { .dt_id = TEGRA124_CLK_SDMMC2, .present = true },
757 [tegra_clk_i2s1] = { .dt_id = TEGRA124_CLK_I2S1, .present = true }, 765 [tegra_clk_i2s1] = { .dt_id = TEGRA124_CLK_I2S1, .present = true },
758 [tegra_clk_i2c1] = { .dt_id = TEGRA124_CLK_I2C1, .present = true }, 766 [tegra_clk_i2c1] = { .dt_id = TEGRA124_CLK_I2C1, .present = true },
759 [tegra_clk_ndflash] = { .dt_id = TEGRA124_CLK_NDFLASH, .present = true }, 767 [tegra_clk_ndflash] = { .dt_id = TEGRA124_CLK_NDFLASH, .present = true },
760 [tegra_clk_sdmmc1] = { .dt_id = TEGRA124_CLK_SDMMC1, .present = true }, 768 [tegra_clk_sdmmc1_8] = { .dt_id = TEGRA124_CLK_SDMMC1, .present = true },
761 [tegra_clk_sdmmc4] = { .dt_id = TEGRA124_CLK_SDMMC4, .present = true }, 769 [tegra_clk_sdmmc4_8] = { .dt_id = TEGRA124_CLK_SDMMC4, .present = true },
762 [tegra_clk_pwm] = { .dt_id = TEGRA124_CLK_PWM, .present = true }, 770 [tegra_clk_pwm] = { .dt_id = TEGRA124_CLK_PWM, .present = true },
763 [tegra_clk_i2s2] = { .dt_id = TEGRA124_CLK_I2S2, .present = true }, 771 [tegra_clk_i2s2] = { .dt_id = TEGRA124_CLK_I2S2, .present = true },
764 [tegra_clk_gr2d] = { .dt_id = TEGRA124_CLK_GR_2D, .present = true },
765 [tegra_clk_usbd] = { .dt_id = TEGRA124_CLK_USBD, .present = true }, 772 [tegra_clk_usbd] = { .dt_id = TEGRA124_CLK_USBD, .present = true },
766 [tegra_clk_isp_8] = { .dt_id = TEGRA124_CLK_ISP, .present = true }, 773 [tegra_clk_isp_8] = { .dt_id = TEGRA124_CLK_ISP, .present = true },
767 [tegra_clk_gr3d] = { .dt_id = TEGRA124_CLK_GR_3D, .present = true },
768 [tegra_clk_disp2] = { .dt_id = TEGRA124_CLK_DISP2, .present = true }, 774 [tegra_clk_disp2] = { .dt_id = TEGRA124_CLK_DISP2, .present = true },
769 [tegra_clk_disp1] = { .dt_id = TEGRA124_CLK_DISP1, .present = true }, 775 [tegra_clk_disp1] = { .dt_id = TEGRA124_CLK_DISP1, .present = true },
770 [tegra_clk_host1x] = { .dt_id = TEGRA124_CLK_HOST1X, .present = true }, 776 [tegra_clk_host1x_8] = { .dt_id = TEGRA124_CLK_HOST1X, .present = true },
771 [tegra_clk_vcp] = { .dt_id = TEGRA124_CLK_VCP, .present = true }, 777 [tegra_clk_vcp] = { .dt_id = TEGRA124_CLK_VCP, .present = true },
772 [tegra_clk_i2s0] = { .dt_id = TEGRA124_CLK_I2S0, .present = true }, 778 [tegra_clk_i2s0] = { .dt_id = TEGRA124_CLK_I2S0, .present = true },
773 [tegra_clk_apbdma] = { .dt_id = TEGRA124_CLK_APBDMA, .present = true }, 779 [tegra_clk_apbdma] = { .dt_id = TEGRA124_CLK_APBDMA, .present = true },
@@ -794,7 +800,7 @@ static struct tegra_clk tegra124_clks[tegra_clk_max] __initdata = {
794 [tegra_clk_uartd] = { .dt_id = TEGRA124_CLK_UARTD, .present = true }, 800 [tegra_clk_uartd] = { .dt_id = TEGRA124_CLK_UARTD, .present = true },
795 [tegra_clk_i2c3] = { .dt_id = TEGRA124_CLK_I2C3, .present = true }, 801 [tegra_clk_i2c3] = { .dt_id = TEGRA124_CLK_I2C3, .present = true },
796 [tegra_clk_sbc4] = { .dt_id = TEGRA124_CLK_SBC4, .present = true }, 802 [tegra_clk_sbc4] = { .dt_id = TEGRA124_CLK_SBC4, .present = true },
797 [tegra_clk_sdmmc3] = { .dt_id = TEGRA124_CLK_SDMMC3, .present = true }, 803 [tegra_clk_sdmmc3_8] = { .dt_id = TEGRA124_CLK_SDMMC3, .present = true },
798 [tegra_clk_pcie] = { .dt_id = TEGRA124_CLK_PCIE, .present = true }, 804 [tegra_clk_pcie] = { .dt_id = TEGRA124_CLK_PCIE, .present = true },
799 [tegra_clk_owr] = { .dt_id = TEGRA124_CLK_OWR, .present = true }, 805 [tegra_clk_owr] = { .dt_id = TEGRA124_CLK_OWR, .present = true },
800 [tegra_clk_afi] = { .dt_id = TEGRA124_CLK_AFI, .present = true }, 806 [tegra_clk_afi] = { .dt_id = TEGRA124_CLK_AFI, .present = true },
@@ -1286,9 +1292,9 @@ static void __init tegra124_pll_init(void __iomem *clk_base,
1286 clk_register_clkdev(clk, "pll_d2", NULL); 1292 clk_register_clkdev(clk, "pll_d2", NULL);
1287 clks[TEGRA124_CLK_PLL_D2] = clk; 1293 clks[TEGRA124_CLK_PLL_D2] = clk;
1288 1294
1289 /* PLLD2_OUT0 ?? */ 1295 /* PLLD2_OUT0 */
1290 clk = clk_register_fixed_factor(NULL, "pll_d2_out0", "pll_d2", 1296 clk = clk_register_fixed_factor(NULL, "pll_d2_out0", "pll_d2",
1291 CLK_SET_RATE_PARENT, 1, 2); 1297 CLK_SET_RATE_PARENT, 1, 1);
1292 clk_register_clkdev(clk, "pll_d2_out0", NULL); 1298 clk_register_clkdev(clk, "pll_d2_out0", NULL);
1293 clks[TEGRA124_CLK_PLL_D2_OUT0] = clk; 1299 clks[TEGRA124_CLK_PLL_D2_OUT0] = clk;
1294 1300
diff --git a/drivers/clk/tegra/clk-tegra20.c b/drivers/clk/tegra/clk-tegra20.c
index dbace152b2fa..dace2b1b5ae6 100644
--- a/drivers/clk/tegra/clk-tegra20.c
+++ b/drivers/clk/tegra/clk-tegra20.c
@@ -574,6 +574,8 @@ static struct tegra_clk tegra20_clks[tegra_clk_max] __initdata = {
574 [tegra_clk_tvdac] = { .dt_id = TEGRA20_CLK_TVDAC, .present = true }, 574 [tegra_clk_tvdac] = { .dt_id = TEGRA20_CLK_TVDAC, .present = true },
575 [tegra_clk_vi_sensor] = { .dt_id = TEGRA20_CLK_VI_SENSOR, .present = true }, 575 [tegra_clk_vi_sensor] = { .dt_id = TEGRA20_CLK_VI_SENSOR, .present = true },
576 [tegra_clk_afi] = { .dt_id = TEGRA20_CLK_AFI, .present = true }, 576 [tegra_clk_afi] = { .dt_id = TEGRA20_CLK_AFI, .present = true },
577 [tegra_clk_fuse] = { .dt_id = TEGRA20_CLK_FUSE, .present = true },
578 [tegra_clk_kfuse] = { .dt_id = TEGRA20_CLK_KFUSE, .present = true },
577}; 579};
578 580
579static unsigned long tegra20_clk_measure_input_freq(void) 581static unsigned long tegra20_clk_measure_input_freq(void)
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 08ca8c9f41cd..cb003a6b72c8 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -1323,8 +1323,7 @@ static int __cpufreq_remove_dev_prepare(struct device *dev,
1323 up_read(&policy->rwsem); 1323 up_read(&policy->rwsem);
1324 1324
1325 if (cpu != policy->cpu) { 1325 if (cpu != policy->cpu) {
1326 if (!frozen) 1326 sysfs_remove_link(&dev->kobj, "cpufreq");
1327 sysfs_remove_link(&dev->kobj, "cpufreq");
1328 } else if (cpus > 1) { 1327 } else if (cpus > 1) {
1329 new_cpu = cpufreq_nominate_new_policy_cpu(policy, cpu); 1328 new_cpu = cpufreq_nominate_new_policy_cpu(policy, cpu);
1330 if (new_cpu >= 0) { 1329 if (new_cpu >= 0) {
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index c788abf1c457..2cd36b9297f3 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -34,12 +34,15 @@
34 34
35#define SAMPLE_COUNT 3 35#define SAMPLE_COUNT 3
36 36
37#define BYT_RATIOS 0x66a 37#define BYT_RATIOS 0x66a
38#define BYT_VIDS 0x66b 38#define BYT_VIDS 0x66b
39#define BYT_TURBO_RATIOS 0x66c
39 40
40#define FRAC_BITS 8 41
42#define FRAC_BITS 6
41#define int_tofp(X) ((int64_t)(X) << FRAC_BITS) 43#define int_tofp(X) ((int64_t)(X) << FRAC_BITS)
42#define fp_toint(X) ((X) >> FRAC_BITS) 44#define fp_toint(X) ((X) >> FRAC_BITS)
45#define FP_ROUNDUP(X) ((X) += 1 << FRAC_BITS)
43 46
44static inline int32_t mul_fp(int32_t x, int32_t y) 47static inline int32_t mul_fp(int32_t x, int32_t y)
45{ 48{
@@ -357,7 +360,7 @@ static int byt_get_min_pstate(void)
357{ 360{
358 u64 value; 361 u64 value;
359 rdmsrl(BYT_RATIOS, value); 362 rdmsrl(BYT_RATIOS, value);
360 return value & 0xFF; 363 return (value >> 8) & 0xFF;
361} 364}
362 365
363static int byt_get_max_pstate(void) 366static int byt_get_max_pstate(void)
@@ -367,6 +370,13 @@ static int byt_get_max_pstate(void)
367 return (value >> 16) & 0xFF; 370 return (value >> 16) & 0xFF;
368} 371}
369 372
373static int byt_get_turbo_pstate(void)
374{
375 u64 value;
376 rdmsrl(BYT_TURBO_RATIOS, value);
377 return value & 0x3F;
378}
379
370static void byt_set_pstate(struct cpudata *cpudata, int pstate) 380static void byt_set_pstate(struct cpudata *cpudata, int pstate)
371{ 381{
372 u64 val; 382 u64 val;
@@ -469,7 +479,7 @@ static struct cpu_defaults byt_params = {
469 .funcs = { 479 .funcs = {
470 .get_max = byt_get_max_pstate, 480 .get_max = byt_get_max_pstate,
471 .get_min = byt_get_min_pstate, 481 .get_min = byt_get_min_pstate,
472 .get_turbo = byt_get_max_pstate, 482 .get_turbo = byt_get_turbo_pstate,
473 .set = byt_set_pstate, 483 .set = byt_set_pstate,
474 .get_vid = byt_get_vid, 484 .get_vid = byt_get_vid,
475 }, 485 },
@@ -547,18 +557,20 @@ static void intel_pstate_get_cpu_pstates(struct cpudata *cpu)
547static inline void intel_pstate_calc_busy(struct cpudata *cpu, 557static inline void intel_pstate_calc_busy(struct cpudata *cpu,
548 struct sample *sample) 558 struct sample *sample)
549{ 559{
550 u64 core_pct; 560 int32_t core_pct;
551 u64 c0_pct; 561 int32_t c0_pct;
552 562
553 core_pct = div64_u64(sample->aperf * 100, sample->mperf); 563 core_pct = div_fp(int_tofp((sample->aperf)),
564 int_tofp((sample->mperf)));
565 core_pct = mul_fp(core_pct, int_tofp(100));
566 FP_ROUNDUP(core_pct);
567
568 c0_pct = div_fp(int_tofp(sample->mperf), int_tofp(sample->tsc));
554 569
555 c0_pct = div64_u64(sample->mperf * 100, sample->tsc);
556 sample->freq = fp_toint( 570 sample->freq = fp_toint(
557 mul_fp(int_tofp(cpu->pstate.max_pstate), 571 mul_fp(int_tofp(cpu->pstate.max_pstate * 1000), core_pct));
558 int_tofp(core_pct * 1000)));
559 572
560 sample->core_pct_busy = mul_fp(int_tofp(core_pct), 573 sample->core_pct_busy = mul_fp(core_pct, c0_pct);
561 div_fp(int_tofp(c0_pct + 1), int_tofp(100)));
562} 574}
563 575
564static inline void intel_pstate_sample(struct cpudata *cpu) 576static inline void intel_pstate_sample(struct cpudata *cpu)
@@ -570,6 +582,10 @@ static inline void intel_pstate_sample(struct cpudata *cpu)
570 rdmsrl(MSR_IA32_MPERF, mperf); 582 rdmsrl(MSR_IA32_MPERF, mperf);
571 tsc = native_read_tsc(); 583 tsc = native_read_tsc();
572 584
585 aperf = aperf >> FRAC_BITS;
586 mperf = mperf >> FRAC_BITS;
587 tsc = tsc >> FRAC_BITS;
588
573 cpu->sample_ptr = (cpu->sample_ptr + 1) % SAMPLE_COUNT; 589 cpu->sample_ptr = (cpu->sample_ptr + 1) % SAMPLE_COUNT;
574 cpu->samples[cpu->sample_ptr].aperf = aperf; 590 cpu->samples[cpu->sample_ptr].aperf = aperf;
575 cpu->samples[cpu->sample_ptr].mperf = mperf; 591 cpu->samples[cpu->sample_ptr].mperf = mperf;
@@ -601,7 +617,8 @@ static inline int32_t intel_pstate_get_scaled_busy(struct cpudata *cpu)
601 core_busy = cpu->samples[cpu->sample_ptr].core_pct_busy; 617 core_busy = cpu->samples[cpu->sample_ptr].core_pct_busy;
602 max_pstate = int_tofp(cpu->pstate.max_pstate); 618 max_pstate = int_tofp(cpu->pstate.max_pstate);
603 current_pstate = int_tofp(cpu->pstate.current_pstate); 619 current_pstate = int_tofp(cpu->pstate.current_pstate);
604 return mul_fp(core_busy, div_fp(max_pstate, current_pstate)); 620 core_busy = mul_fp(core_busy, div_fp(max_pstate, current_pstate));
621 return FP_ROUNDUP(core_busy);
605} 622}
606 623
607static inline void intel_pstate_adjust_busy_pstate(struct cpudata *cpu) 624static inline void intel_pstate_adjust_busy_pstate(struct cpudata *cpu)
diff --git a/drivers/cpufreq/powernow-k8.c b/drivers/cpufreq/powernow-k8.c
index e10b646634d7..6684e0342792 100644
--- a/drivers/cpufreq/powernow-k8.c
+++ b/drivers/cpufreq/powernow-k8.c
@@ -1076,7 +1076,7 @@ static int powernowk8_cpu_init(struct cpufreq_policy *pol)
1076{ 1076{
1077 struct powernow_k8_data *data; 1077 struct powernow_k8_data *data;
1078 struct init_on_cpu init_on_cpu; 1078 struct init_on_cpu init_on_cpu;
1079 int rc; 1079 int rc, cpu;
1080 1080
1081 smp_call_function_single(pol->cpu, check_supported_cpu, &rc, 1); 1081 smp_call_function_single(pol->cpu, check_supported_cpu, &rc, 1);
1082 if (rc) 1082 if (rc)
@@ -1140,7 +1140,9 @@ static int powernowk8_cpu_init(struct cpufreq_policy *pol)
1140 pr_debug("cpu_init done, current fid 0x%x, vid 0x%x\n", 1140 pr_debug("cpu_init done, current fid 0x%x, vid 0x%x\n",
1141 data->currfid, data->currvid); 1141 data->currfid, data->currvid);
1142 1142
1143 per_cpu(powernow_data, pol->cpu) = data; 1143 /* Point all the CPUs in this policy to the same data */
1144 for_each_cpu(cpu, pol->cpus)
1145 per_cpu(powernow_data, cpu) = data;
1144 1146
1145 return 0; 1147 return 0;
1146 1148
@@ -1155,6 +1157,7 @@ err_out:
1155static int powernowk8_cpu_exit(struct cpufreq_policy *pol) 1157static int powernowk8_cpu_exit(struct cpufreq_policy *pol)
1156{ 1158{
1157 struct powernow_k8_data *data = per_cpu(powernow_data, pol->cpu); 1159 struct powernow_k8_data *data = per_cpu(powernow_data, pol->cpu);
1160 int cpu;
1158 1161
1159 if (!data) 1162 if (!data)
1160 return -EINVAL; 1163 return -EINVAL;
@@ -1165,7 +1168,8 @@ static int powernowk8_cpu_exit(struct cpufreq_policy *pol)
1165 1168
1166 kfree(data->powernow_table); 1169 kfree(data->powernow_table);
1167 kfree(data); 1170 kfree(data);
1168 per_cpu(powernow_data, pol->cpu) = NULL; 1171 for_each_cpu(cpu, pol->cpus)
1172 per_cpu(powernow_data, cpu) = NULL;
1169 1173
1170 return 0; 1174 return 0;
1171} 1175}
diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
index 4e7918339b12..19041cefabb1 100644
--- a/drivers/dma/imx-sdma.c
+++ b/drivers/dma/imx-sdma.c
@@ -449,6 +449,7 @@ static const struct of_device_id sdma_dt_ids[] = {
449 { .compatible = "fsl,imx51-sdma", .data = &sdma_imx51, }, 449 { .compatible = "fsl,imx51-sdma", .data = &sdma_imx51, },
450 { .compatible = "fsl,imx35-sdma", .data = &sdma_imx35, }, 450 { .compatible = "fsl,imx35-sdma", .data = &sdma_imx35, },
451 { .compatible = "fsl,imx31-sdma", .data = &sdma_imx31, }, 451 { .compatible = "fsl,imx31-sdma", .data = &sdma_imx31, },
452 { .compatible = "fsl,imx25-sdma", .data = &sdma_imx25, },
452 { /* sentinel */ } 453 { /* sentinel */ }
453}; 454};
454MODULE_DEVICE_TABLE(of, sdma_dt_ids); 455MODULE_DEVICE_TABLE(of, sdma_dt_ids);
diff --git a/drivers/dma/ioat/dma.c b/drivers/dma/ioat/dma.c
index 87529181efcc..4e3549a16132 100644
--- a/drivers/dma/ioat/dma.c
+++ b/drivers/dma/ioat/dma.c
@@ -77,7 +77,8 @@ static irqreturn_t ioat_dma_do_interrupt(int irq, void *data)
77 attnstatus = readl(instance->reg_base + IOAT_ATTNSTATUS_OFFSET); 77 attnstatus = readl(instance->reg_base + IOAT_ATTNSTATUS_OFFSET);
78 for_each_set_bit(bit, &attnstatus, BITS_PER_LONG) { 78 for_each_set_bit(bit, &attnstatus, BITS_PER_LONG) {
79 chan = ioat_chan_by_index(instance, bit); 79 chan = ioat_chan_by_index(instance, bit);
80 tasklet_schedule(&chan->cleanup_task); 80 if (test_bit(IOAT_RUN, &chan->state))
81 tasklet_schedule(&chan->cleanup_task);
81 } 82 }
82 83
83 writeb(intrctrl, instance->reg_base + IOAT_INTRCTRL_OFFSET); 84 writeb(intrctrl, instance->reg_base + IOAT_INTRCTRL_OFFSET);
@@ -93,7 +94,8 @@ static irqreturn_t ioat_dma_do_interrupt_msix(int irq, void *data)
93{ 94{
94 struct ioat_chan_common *chan = data; 95 struct ioat_chan_common *chan = data;
95 96
96 tasklet_schedule(&chan->cleanup_task); 97 if (test_bit(IOAT_RUN, &chan->state))
98 tasklet_schedule(&chan->cleanup_task);
97 99
98 return IRQ_HANDLED; 100 return IRQ_HANDLED;
99} 101}
@@ -116,7 +118,6 @@ void ioat_init_channel(struct ioatdma_device *device, struct ioat_chan_common *c
116 chan->timer.function = device->timer_fn; 118 chan->timer.function = device->timer_fn;
117 chan->timer.data = data; 119 chan->timer.data = data;
118 tasklet_init(&chan->cleanup_task, device->cleanup_fn, data); 120 tasklet_init(&chan->cleanup_task, device->cleanup_fn, data);
119 tasklet_disable(&chan->cleanup_task);
120} 121}
121 122
122/** 123/**
@@ -354,13 +355,49 @@ static int ioat1_dma_alloc_chan_resources(struct dma_chan *c)
354 writel(((u64) chan->completion_dma) >> 32, 355 writel(((u64) chan->completion_dma) >> 32,
355 chan->reg_base + IOAT_CHANCMP_OFFSET_HIGH); 356 chan->reg_base + IOAT_CHANCMP_OFFSET_HIGH);
356 357
357 tasklet_enable(&chan->cleanup_task); 358 set_bit(IOAT_RUN, &chan->state);
358 ioat1_dma_start_null_desc(ioat); /* give chain to dma device */ 359 ioat1_dma_start_null_desc(ioat); /* give chain to dma device */
359 dev_dbg(to_dev(chan), "%s: allocated %d descriptors\n", 360 dev_dbg(to_dev(chan), "%s: allocated %d descriptors\n",
360 __func__, ioat->desccount); 361 __func__, ioat->desccount);
361 return ioat->desccount; 362 return ioat->desccount;
362} 363}
363 364
365void ioat_stop(struct ioat_chan_common *chan)
366{
367 struct ioatdma_device *device = chan->device;
368 struct pci_dev *pdev = device->pdev;
369 int chan_id = chan_num(chan);
370 struct msix_entry *msix;
371
372 /* 1/ stop irq from firing tasklets
373 * 2/ stop the tasklet from re-arming irqs
374 */
375 clear_bit(IOAT_RUN, &chan->state);
376
377 /* flush inflight interrupts */
378 switch (device->irq_mode) {
379 case IOAT_MSIX:
380 msix = &device->msix_entries[chan_id];
381 synchronize_irq(msix->vector);
382 break;
383 case IOAT_MSI:
384 case IOAT_INTX:
385 synchronize_irq(pdev->irq);
386 break;
387 default:
388 break;
389 }
390
391 /* flush inflight timers */
392 del_timer_sync(&chan->timer);
393
394 /* flush inflight tasklet runs */
395 tasklet_kill(&chan->cleanup_task);
396
397 /* final cleanup now that everything is quiesced and can't re-arm */
398 device->cleanup_fn((unsigned long) &chan->common);
399}
400
364/** 401/**
365 * ioat1_dma_free_chan_resources - release all the descriptors 402 * ioat1_dma_free_chan_resources - release all the descriptors
366 * @chan: the channel to be cleaned 403 * @chan: the channel to be cleaned
@@ -379,9 +416,7 @@ static void ioat1_dma_free_chan_resources(struct dma_chan *c)
379 if (ioat->desccount == 0) 416 if (ioat->desccount == 0)
380 return; 417 return;
381 418
382 tasklet_disable(&chan->cleanup_task); 419 ioat_stop(chan);
383 del_timer_sync(&chan->timer);
384 ioat1_cleanup(ioat);
385 420
386 /* Delay 100ms after reset to allow internal DMA logic to quiesce 421 /* Delay 100ms after reset to allow internal DMA logic to quiesce
387 * before removing DMA descriptor resources. 422 * before removing DMA descriptor resources.
@@ -526,8 +561,11 @@ ioat1_dma_prep_memcpy(struct dma_chan *c, dma_addr_t dma_dest,
526static void ioat1_cleanup_event(unsigned long data) 561static void ioat1_cleanup_event(unsigned long data)
527{ 562{
528 struct ioat_dma_chan *ioat = to_ioat_chan((void *) data); 563 struct ioat_dma_chan *ioat = to_ioat_chan((void *) data);
564 struct ioat_chan_common *chan = &ioat->base;
529 565
530 ioat1_cleanup(ioat); 566 ioat1_cleanup(ioat);
567 if (!test_bit(IOAT_RUN, &chan->state))
568 return;
531 writew(IOAT_CHANCTRL_RUN, ioat->base.reg_base + IOAT_CHANCTRL_OFFSET); 569 writew(IOAT_CHANCTRL_RUN, ioat->base.reg_base + IOAT_CHANCTRL_OFFSET);
532} 570}
533 571
diff --git a/drivers/dma/ioat/dma.h b/drivers/dma/ioat/dma.h
index 11fb877ddca9..e982f00a9843 100644
--- a/drivers/dma/ioat/dma.h
+++ b/drivers/dma/ioat/dma.h
@@ -356,6 +356,7 @@ bool ioat_cleanup_preamble(struct ioat_chan_common *chan,
356void ioat_kobject_add(struct ioatdma_device *device, struct kobj_type *type); 356void ioat_kobject_add(struct ioatdma_device *device, struct kobj_type *type);
357void ioat_kobject_del(struct ioatdma_device *device); 357void ioat_kobject_del(struct ioatdma_device *device);
358int ioat_dma_setup_interrupts(struct ioatdma_device *device); 358int ioat_dma_setup_interrupts(struct ioatdma_device *device);
359void ioat_stop(struct ioat_chan_common *chan);
359extern const struct sysfs_ops ioat_sysfs_ops; 360extern const struct sysfs_ops ioat_sysfs_ops;
360extern struct ioat_sysfs_entry ioat_version_attr; 361extern struct ioat_sysfs_entry ioat_version_attr;
361extern struct ioat_sysfs_entry ioat_cap_attr; 362extern struct ioat_sysfs_entry ioat_cap_attr;
diff --git a/drivers/dma/ioat/dma_v2.c b/drivers/dma/ioat/dma_v2.c
index 5d3affe7e976..8d1058085eeb 100644
--- a/drivers/dma/ioat/dma_v2.c
+++ b/drivers/dma/ioat/dma_v2.c
@@ -190,8 +190,11 @@ static void ioat2_cleanup(struct ioat2_dma_chan *ioat)
190void ioat2_cleanup_event(unsigned long data) 190void ioat2_cleanup_event(unsigned long data)
191{ 191{
192 struct ioat2_dma_chan *ioat = to_ioat2_chan((void *) data); 192 struct ioat2_dma_chan *ioat = to_ioat2_chan((void *) data);
193 struct ioat_chan_common *chan = &ioat->base;
193 194
194 ioat2_cleanup(ioat); 195 ioat2_cleanup(ioat);
196 if (!test_bit(IOAT_RUN, &chan->state))
197 return;
195 writew(IOAT_CHANCTRL_RUN, ioat->base.reg_base + IOAT_CHANCTRL_OFFSET); 198 writew(IOAT_CHANCTRL_RUN, ioat->base.reg_base + IOAT_CHANCTRL_OFFSET);
196} 199}
197 200
@@ -553,10 +556,10 @@ int ioat2_alloc_chan_resources(struct dma_chan *c)
553 ioat->issued = 0; 556 ioat->issued = 0;
554 ioat->tail = 0; 557 ioat->tail = 0;
555 ioat->alloc_order = order; 558 ioat->alloc_order = order;
559 set_bit(IOAT_RUN, &chan->state);
556 spin_unlock_bh(&ioat->prep_lock); 560 spin_unlock_bh(&ioat->prep_lock);
557 spin_unlock_bh(&chan->cleanup_lock); 561 spin_unlock_bh(&chan->cleanup_lock);
558 562
559 tasklet_enable(&chan->cleanup_task);
560 ioat2_start_null_desc(ioat); 563 ioat2_start_null_desc(ioat);
561 564
562 /* check that we got off the ground */ 565 /* check that we got off the ground */
@@ -566,7 +569,6 @@ int ioat2_alloc_chan_resources(struct dma_chan *c)
566 } while (i++ < 20 && !is_ioat_active(status) && !is_ioat_idle(status)); 569 } while (i++ < 20 && !is_ioat_active(status) && !is_ioat_idle(status));
567 570
568 if (is_ioat_active(status) || is_ioat_idle(status)) { 571 if (is_ioat_active(status) || is_ioat_idle(status)) {
569 set_bit(IOAT_RUN, &chan->state);
570 return 1 << ioat->alloc_order; 572 return 1 << ioat->alloc_order;
571 } else { 573 } else {
572 u32 chanerr = readl(chan->reg_base + IOAT_CHANERR_OFFSET); 574 u32 chanerr = readl(chan->reg_base + IOAT_CHANERR_OFFSET);
@@ -809,11 +811,8 @@ void ioat2_free_chan_resources(struct dma_chan *c)
809 if (!ioat->ring) 811 if (!ioat->ring)
810 return; 812 return;
811 813
812 tasklet_disable(&chan->cleanup_task); 814 ioat_stop(chan);
813 del_timer_sync(&chan->timer);
814 device->cleanup_fn((unsigned long) c);
815 device->reset_hw(chan); 815 device->reset_hw(chan);
816 clear_bit(IOAT_RUN, &chan->state);
817 816
818 spin_lock_bh(&chan->cleanup_lock); 817 spin_lock_bh(&chan->cleanup_lock);
819 spin_lock_bh(&ioat->prep_lock); 818 spin_lock_bh(&ioat->prep_lock);
diff --git a/drivers/dma/ioat/dma_v3.c b/drivers/dma/ioat/dma_v3.c
index 820817e97e62..b9b38a1cf92f 100644
--- a/drivers/dma/ioat/dma_v3.c
+++ b/drivers/dma/ioat/dma_v3.c
@@ -464,8 +464,11 @@ static void ioat3_cleanup(struct ioat2_dma_chan *ioat)
464static void ioat3_cleanup_event(unsigned long data) 464static void ioat3_cleanup_event(unsigned long data)
465{ 465{
466 struct ioat2_dma_chan *ioat = to_ioat2_chan((void *) data); 466 struct ioat2_dma_chan *ioat = to_ioat2_chan((void *) data);
467 struct ioat_chan_common *chan = &ioat->base;
467 468
468 ioat3_cleanup(ioat); 469 ioat3_cleanup(ioat);
470 if (!test_bit(IOAT_RUN, &chan->state))
471 return;
469 writew(IOAT_CHANCTRL_RUN, ioat->base.reg_base + IOAT_CHANCTRL_OFFSET); 472 writew(IOAT_CHANCTRL_RUN, ioat->base.reg_base + IOAT_CHANCTRL_OFFSET);
470} 473}
471 474
diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c
index 00a2de957b23..bf18c786ed40 100644
--- a/drivers/dma/ste_dma40.c
+++ b/drivers/dma/ste_dma40.c
@@ -1641,6 +1641,7 @@ static void dma_tasklet(unsigned long data)
1641 struct d40_chan *d40c = (struct d40_chan *) data; 1641 struct d40_chan *d40c = (struct d40_chan *) data;
1642 struct d40_desc *d40d; 1642 struct d40_desc *d40d;
1643 unsigned long flags; 1643 unsigned long flags;
1644 bool callback_active;
1644 dma_async_tx_callback callback; 1645 dma_async_tx_callback callback;
1645 void *callback_param; 1646 void *callback_param;
1646 1647
@@ -1668,6 +1669,7 @@ static void dma_tasklet(unsigned long data)
1668 } 1669 }
1669 1670
1670 /* Callback to client */ 1671 /* Callback to client */
1672 callback_active = !!(d40d->txd.flags & DMA_PREP_INTERRUPT);
1671 callback = d40d->txd.callback; 1673 callback = d40d->txd.callback;
1672 callback_param = d40d->txd.callback_param; 1674 callback_param = d40d->txd.callback_param;
1673 1675
@@ -1690,7 +1692,7 @@ static void dma_tasklet(unsigned long data)
1690 1692
1691 spin_unlock_irqrestore(&d40c->lock, flags); 1693 spin_unlock_irqrestore(&d40c->lock, flags);
1692 1694
1693 if (callback && (d40d->txd.flags & DMA_PREP_INTERRUPT)) 1695 if (callback_active && callback)
1694 callback(callback_param); 1696 callback(callback_param);
1695 1697
1696 return; 1698 return;
diff --git a/drivers/edac/i7300_edac.c b/drivers/edac/i7300_edac.c
index d63f4798f7d0..57e96a3350f0 100644
--- a/drivers/edac/i7300_edac.c
+++ b/drivers/edac/i7300_edac.c
@@ -943,33 +943,35 @@ static int i7300_get_devices(struct mem_ctl_info *mci)
943 943
944 /* Attempt to 'get' the MCH register we want */ 944 /* Attempt to 'get' the MCH register we want */
945 pdev = NULL; 945 pdev = NULL;
946 while (!pvt->pci_dev_16_1_fsb_addr_map || 946 while ((pdev = pci_get_device(PCI_VENDOR_ID_INTEL,
947 !pvt->pci_dev_16_2_fsb_err_regs) { 947 PCI_DEVICE_ID_INTEL_I7300_MCH_ERR,
948 pdev = pci_get_device(PCI_VENDOR_ID_INTEL, 948 pdev))) {
949 PCI_DEVICE_ID_INTEL_I7300_MCH_ERR, pdev);
950 if (!pdev) {
951 /* End of list, leave */
952 i7300_printk(KERN_ERR,
953 "'system address,Process Bus' "
954 "device not found:"
955 "vendor 0x%x device 0x%x ERR funcs "
956 "(broken BIOS?)\n",
957 PCI_VENDOR_ID_INTEL,
958 PCI_DEVICE_ID_INTEL_I7300_MCH_ERR);
959 goto error;
960 }
961
962 /* Store device 16 funcs 1 and 2 */ 949 /* Store device 16 funcs 1 and 2 */
963 switch (PCI_FUNC(pdev->devfn)) { 950 switch (PCI_FUNC(pdev->devfn)) {
964 case 1: 951 case 1:
965 pvt->pci_dev_16_1_fsb_addr_map = pdev; 952 if (!pvt->pci_dev_16_1_fsb_addr_map)
953 pvt->pci_dev_16_1_fsb_addr_map =
954 pci_dev_get(pdev);
966 break; 955 break;
967 case 2: 956 case 2:
968 pvt->pci_dev_16_2_fsb_err_regs = pdev; 957 if (!pvt->pci_dev_16_2_fsb_err_regs)
958 pvt->pci_dev_16_2_fsb_err_regs =
959 pci_dev_get(pdev);
969 break; 960 break;
970 } 961 }
971 } 962 }
972 963
964 if (!pvt->pci_dev_16_1_fsb_addr_map ||
965 !pvt->pci_dev_16_2_fsb_err_regs) {
966 /* At least one device was not found */
967 i7300_printk(KERN_ERR,
968 "'system address,Process Bus' device not found:"
969 "vendor 0x%x device 0x%x ERR funcs (broken BIOS?)\n",
970 PCI_VENDOR_ID_INTEL,
971 PCI_DEVICE_ID_INTEL_I7300_MCH_ERR);
972 goto error;
973 }
974
973 edac_dbg(1, "System Address, processor bus- PCI Bus ID: %s %x:%x\n", 975 edac_dbg(1, "System Address, processor bus- PCI Bus ID: %s %x:%x\n",
974 pci_name(pvt->pci_dev_16_0_fsb_ctlr), 976 pci_name(pvt->pci_dev_16_0_fsb_ctlr),
975 pvt->pci_dev_16_0_fsb_ctlr->vendor, 977 pvt->pci_dev_16_0_fsb_ctlr->vendor,
diff --git a/drivers/edac/i7core_edac.c b/drivers/edac/i7core_edac.c
index 87533ca7752e..d871275196f6 100644
--- a/drivers/edac/i7core_edac.c
+++ b/drivers/edac/i7core_edac.c
@@ -1334,14 +1334,19 @@ static int i7core_get_onedevice(struct pci_dev **prev,
1334 * is at addr 8086:2c40, instead of 8086:2c41. So, we need 1334 * is at addr 8086:2c40, instead of 8086:2c41. So, we need
1335 * to probe for the alternate address in case of failure 1335 * to probe for the alternate address in case of failure
1336 */ 1336 */
1337 if (dev_descr->dev_id == PCI_DEVICE_ID_INTEL_I7_NONCORE && !pdev) 1337 if (dev_descr->dev_id == PCI_DEVICE_ID_INTEL_I7_NONCORE && !pdev) {
1338 pci_dev_get(*prev); /* pci_get_device will put it */
1338 pdev = pci_get_device(PCI_VENDOR_ID_INTEL, 1339 pdev = pci_get_device(PCI_VENDOR_ID_INTEL,
1339 PCI_DEVICE_ID_INTEL_I7_NONCORE_ALT, *prev); 1340 PCI_DEVICE_ID_INTEL_I7_NONCORE_ALT, *prev);
1341 }
1340 1342
1341 if (dev_descr->dev_id == PCI_DEVICE_ID_INTEL_LYNNFIELD_NONCORE && !pdev) 1343 if (dev_descr->dev_id == PCI_DEVICE_ID_INTEL_LYNNFIELD_NONCORE &&
1344 !pdev) {
1345 pci_dev_get(*prev); /* pci_get_device will put it */
1342 pdev = pci_get_device(PCI_VENDOR_ID_INTEL, 1346 pdev = pci_get_device(PCI_VENDOR_ID_INTEL,
1343 PCI_DEVICE_ID_INTEL_LYNNFIELD_NONCORE_ALT, 1347 PCI_DEVICE_ID_INTEL_LYNNFIELD_NONCORE_ALT,
1344 *prev); 1348 *prev);
1349 }
1345 1350
1346 if (!pdev) { 1351 if (!pdev) {
1347 if (*prev) { 1352 if (*prev) {
diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c
index c20602f601ee..98a14f6143a7 100644
--- a/drivers/extcon/extcon-arizona.c
+++ b/drivers/extcon/extcon-arizona.c
@@ -222,27 +222,19 @@ static void arizona_extcon_pulse_micbias(struct arizona_extcon_info *info)
222 struct snd_soc_dapm_context *dapm = arizona->dapm; 222 struct snd_soc_dapm_context *dapm = arizona->dapm;
223 int ret; 223 int ret;
224 224
225 mutex_lock(&dapm->card->dapm_mutex);
226
227 ret = snd_soc_dapm_force_enable_pin(dapm, widget); 225 ret = snd_soc_dapm_force_enable_pin(dapm, widget);
228 if (ret != 0) 226 if (ret != 0)
229 dev_warn(arizona->dev, "Failed to enable %s: %d\n", 227 dev_warn(arizona->dev, "Failed to enable %s: %d\n",
230 widget, ret); 228 widget, ret);
231 229
232 mutex_unlock(&dapm->card->dapm_mutex);
233
234 snd_soc_dapm_sync(dapm); 230 snd_soc_dapm_sync(dapm);
235 231
236 if (!arizona->pdata.micd_force_micbias) { 232 if (!arizona->pdata.micd_force_micbias) {
237 mutex_lock(&dapm->card->dapm_mutex);
238
239 ret = snd_soc_dapm_disable_pin(arizona->dapm, widget); 233 ret = snd_soc_dapm_disable_pin(arizona->dapm, widget);
240 if (ret != 0) 234 if (ret != 0)
241 dev_warn(arizona->dev, "Failed to disable %s: %d\n", 235 dev_warn(arizona->dev, "Failed to disable %s: %d\n",
242 widget, ret); 236 widget, ret);
243 237
244 mutex_unlock(&dapm->card->dapm_mutex);
245
246 snd_soc_dapm_sync(dapm); 238 snd_soc_dapm_sync(dapm);
247 } 239 }
248} 240}
@@ -304,16 +296,12 @@ static void arizona_stop_mic(struct arizona_extcon_info *info)
304 ARIZONA_MICD_ENA, 0, 296 ARIZONA_MICD_ENA, 0,
305 &change); 297 &change);
306 298
307 mutex_lock(&dapm->card->dapm_mutex);
308
309 ret = snd_soc_dapm_disable_pin(dapm, widget); 299 ret = snd_soc_dapm_disable_pin(dapm, widget);
310 if (ret != 0) 300 if (ret != 0)
311 dev_warn(arizona->dev, 301 dev_warn(arizona->dev,
312 "Failed to disable %s: %d\n", 302 "Failed to disable %s: %d\n",
313 widget, ret); 303 widget, ret);
314 304
315 mutex_unlock(&dapm->card->dapm_mutex);
316
317 snd_soc_dapm_sync(dapm); 305 snd_soc_dapm_sync(dapm);
318 306
319 if (info->micd_reva) { 307 if (info->micd_reva) {
diff --git a/drivers/fmc/fmc-write-eeprom.c b/drivers/fmc/fmc-write-eeprom.c
index ee5b47904130..9bb2cbd5c9f2 100644
--- a/drivers/fmc/fmc-write-eeprom.c
+++ b/drivers/fmc/fmc-write-eeprom.c
@@ -27,7 +27,7 @@ FMC_PARAM_BUSID(fwe_drv);
27/* The "file=" is like the generic "gateware=" used elsewhere */ 27/* The "file=" is like the generic "gateware=" used elsewhere */
28static char *fwe_file[FMC_MAX_CARDS]; 28static char *fwe_file[FMC_MAX_CARDS];
29static int fwe_file_n; 29static int fwe_file_n;
30module_param_array_named(file, fwe_file, charp, &fwe_file_n, 444); 30module_param_array_named(file, fwe_file, charp, &fwe_file_n, 0444);
31 31
32static int fwe_run_tlv(struct fmc_device *fmc, const struct firmware *fw, 32static int fwe_run_tlv(struct fmc_device *fmc, const struct firmware *fw,
33 int write) 33 int write)
diff --git a/drivers/gpu/drm/nouveau/nouveau_acpi.c b/drivers/gpu/drm/nouveau/nouveau_acpi.c
index 4ef83df2b246..83face3f608f 100644
--- a/drivers/gpu/drm/nouveau/nouveau_acpi.c
+++ b/drivers/gpu/drm/nouveau/nouveau_acpi.c
@@ -106,6 +106,29 @@ static int nouveau_optimus_dsm(acpi_handle handle, int func, int arg, uint32_t *
106 return 0; 106 return 0;
107} 107}
108 108
109/*
110 * On some platforms, _DSM(nouveau_op_dsm_muid, func0) has special
111 * requirements on the fourth parameter, so a private implementation
112 * instead of using acpi_check_dsm().
113 */
114static int nouveau_check_optimus_dsm(acpi_handle handle)
115{
116 int result;
117
118 /*
119 * Function 0 returns a Buffer containing available functions.
120 * The args parameter is ignored for function 0, so just put 0 in it
121 */
122 if (nouveau_optimus_dsm(handle, 0, 0, &result))
123 return 0;
124
125 /*
126 * ACPI Spec v4 9.14.1: if bit 0 is zero, no function is supported.
127 * If the n-th bit is enabled, function n is supported
128 */
129 return result & 1 && result & (1 << NOUVEAU_DSM_OPTIMUS_CAPS);
130}
131
109static int nouveau_dsm(acpi_handle handle, int func, int arg) 132static int nouveau_dsm(acpi_handle handle, int func, int arg)
110{ 133{
111 int ret = 0; 134 int ret = 0;
@@ -207,8 +230,7 @@ static int nouveau_dsm_pci_probe(struct pci_dev *pdev)
207 1 << NOUVEAU_DSM_POWER)) 230 1 << NOUVEAU_DSM_POWER))
208 retval |= NOUVEAU_DSM_HAS_MUX; 231 retval |= NOUVEAU_DSM_HAS_MUX;
209 232
210 if (acpi_check_dsm(dhandle, nouveau_op_dsm_muid, 0x00000100, 233 if (nouveau_check_optimus_dsm(dhandle))
211 1 << NOUVEAU_DSM_OPTIMUS_CAPS))
212 retval |= NOUVEAU_DSM_HAS_OPT; 234 retval |= NOUVEAU_DSM_HAS_OPT;
213 235
214 if (retval & NOUVEAU_DSM_HAS_OPT) { 236 if (retval & NOUVEAU_DSM_HAS_OPT) {
diff --git a/drivers/gpu/drm/radeon/atombios_crtc.c b/drivers/gpu/drm/radeon/atombios_crtc.c
index 0d19f4f94d5a..daa4dd375ab1 100644
--- a/drivers/gpu/drm/radeon/atombios_crtc.c
+++ b/drivers/gpu/drm/radeon/atombios_crtc.c
@@ -1774,6 +1774,20 @@ static int radeon_atom_pick_pll(struct drm_crtc *crtc)
1774 return ATOM_PPLL1; 1774 return ATOM_PPLL1;
1775 DRM_ERROR("unable to allocate a PPLL\n"); 1775 DRM_ERROR("unable to allocate a PPLL\n");
1776 return ATOM_PPLL_INVALID; 1776 return ATOM_PPLL_INVALID;
1777 } else if (ASIC_IS_DCE41(rdev)) {
1778 /* Don't share PLLs on DCE4.1 chips */
1779 if (ENCODER_MODE_IS_DP(atombios_get_encoder_mode(radeon_crtc->encoder))) {
1780 if (rdev->clock.dp_extclk)
1781 /* skip PPLL programming if using ext clock */
1782 return ATOM_PPLL_INVALID;
1783 }
1784 pll_in_use = radeon_get_pll_use_mask(crtc);
1785 if (!(pll_in_use & (1 << ATOM_PPLL1)))
1786 return ATOM_PPLL1;
1787 if (!(pll_in_use & (1 << ATOM_PPLL2)))
1788 return ATOM_PPLL2;
1789 DRM_ERROR("unable to allocate a PPLL\n");
1790 return ATOM_PPLL_INVALID;
1777 } else if (ASIC_IS_DCE4(rdev)) { 1791 } else if (ASIC_IS_DCE4(rdev)) {
1778 /* in DP mode, the DP ref clock can come from PPLL, DCPLL, or ext clock, 1792 /* in DP mode, the DP ref clock can come from PPLL, DCPLL, or ext clock,
1779 * depending on the asic: 1793 * depending on the asic:
@@ -1801,7 +1815,7 @@ static int radeon_atom_pick_pll(struct drm_crtc *crtc)
1801 if (pll != ATOM_PPLL_INVALID) 1815 if (pll != ATOM_PPLL_INVALID)
1802 return pll; 1816 return pll;
1803 } 1817 }
1804 } else if (!ASIC_IS_DCE41(rdev)) { /* Don't share PLLs on DCE4.1 chips */ 1818 } else {
1805 /* use the same PPLL for all monitors with the same clock */ 1819 /* use the same PPLL for all monitors with the same clock */
1806 pll = radeon_get_shared_nondp_ppll(crtc); 1820 pll = radeon_get_shared_nondp_ppll(crtc);
1807 if (pll != ATOM_PPLL_INVALID) 1821 if (pll != ATOM_PPLL_INVALID)
diff --git a/drivers/gpu/drm/radeon/dce6_afmt.c b/drivers/gpu/drm/radeon/dce6_afmt.c
index 713a5d359901..94e858751994 100644
--- a/drivers/gpu/drm/radeon/dce6_afmt.c
+++ b/drivers/gpu/drm/radeon/dce6_afmt.c
@@ -278,13 +278,15 @@ static int dce6_audio_chipset_supported(struct radeon_device *rdev)
278 return !ASIC_IS_NODCE(rdev); 278 return !ASIC_IS_NODCE(rdev);
279} 279}
280 280
281static void dce6_audio_enable(struct radeon_device *rdev, 281void dce6_audio_enable(struct radeon_device *rdev,
282 struct r600_audio_pin *pin, 282 struct r600_audio_pin *pin,
283 bool enable) 283 bool enable)
284{ 284{
285 if (!pin)
286 return;
287
285 WREG32_ENDPOINT(pin->offset, AZ_F0_CODEC_PIN_CONTROL_HOTPLUG_CONTROL, 288 WREG32_ENDPOINT(pin->offset, AZ_F0_CODEC_PIN_CONTROL_HOTPLUG_CONTROL,
286 AUDIO_ENABLED); 289 enable ? AUDIO_ENABLED : 0);
287 DRM_INFO("%s audio %d support\n", enable ? "Enabling" : "Disabling", pin->id);
288} 290}
289 291
290static const u32 pin_offsets[7] = 292static const u32 pin_offsets[7] =
@@ -323,7 +325,8 @@ int dce6_audio_init(struct radeon_device *rdev)
323 rdev->audio.pin[i].connected = false; 325 rdev->audio.pin[i].connected = false;
324 rdev->audio.pin[i].offset = pin_offsets[i]; 326 rdev->audio.pin[i].offset = pin_offsets[i];
325 rdev->audio.pin[i].id = i; 327 rdev->audio.pin[i].id = i;
326 dce6_audio_enable(rdev, &rdev->audio.pin[i], true); 328 /* disable audio. it will be set up later */
329 dce6_audio_enable(rdev, &rdev->audio.pin[i], false);
327 } 330 }
328 331
329 return 0; 332 return 0;
diff --git a/drivers/gpu/drm/radeon/evergreen.c b/drivers/gpu/drm/radeon/evergreen.c
index 5623e7542d99..8a2c010b7dc5 100644
--- a/drivers/gpu/drm/radeon/evergreen.c
+++ b/drivers/gpu/drm/radeon/evergreen.c
@@ -5475,9 +5475,9 @@ void evergreen_fini(struct radeon_device *rdev)
5475 radeon_wb_fini(rdev); 5475 radeon_wb_fini(rdev);
5476 radeon_ib_pool_fini(rdev); 5476 radeon_ib_pool_fini(rdev);
5477 radeon_irq_kms_fini(rdev); 5477 radeon_irq_kms_fini(rdev);
5478 evergreen_pcie_gart_fini(rdev);
5479 uvd_v1_0_fini(rdev); 5478 uvd_v1_0_fini(rdev);
5480 radeon_uvd_fini(rdev); 5479 radeon_uvd_fini(rdev);
5480 evergreen_pcie_gart_fini(rdev);
5481 r600_vram_scratch_fini(rdev); 5481 r600_vram_scratch_fini(rdev);
5482 radeon_gem_fini(rdev); 5482 radeon_gem_fini(rdev);
5483 radeon_fence_driver_fini(rdev); 5483 radeon_fence_driver_fini(rdev);
diff --git a/drivers/gpu/drm/radeon/evergreen_hdmi.c b/drivers/gpu/drm/radeon/evergreen_hdmi.c
index 0c6d5cef4cf1..05b0c95813fd 100644
--- a/drivers/gpu/drm/radeon/evergreen_hdmi.c
+++ b/drivers/gpu/drm/radeon/evergreen_hdmi.c
@@ -306,6 +306,15 @@ void evergreen_hdmi_setmode(struct drm_encoder *encoder, struct drm_display_mode
306 return; 306 return;
307 offset = dig->afmt->offset; 307 offset = dig->afmt->offset;
308 308
309 /* disable audio prior to setting up hw */
310 if (ASIC_IS_DCE6(rdev)) {
311 dig->afmt->pin = dce6_audio_get_pin(rdev);
312 dce6_audio_enable(rdev, dig->afmt->pin, false);
313 } else {
314 dig->afmt->pin = r600_audio_get_pin(rdev);
315 r600_audio_enable(rdev, dig->afmt->pin, false);
316 }
317
309 evergreen_audio_set_dto(encoder, mode->clock); 318 evergreen_audio_set_dto(encoder, mode->clock);
310 319
311 WREG32(HDMI_VBI_PACKET_CONTROL + offset, 320 WREG32(HDMI_VBI_PACKET_CONTROL + offset,
@@ -409,12 +418,16 @@ void evergreen_hdmi_setmode(struct drm_encoder *encoder, struct drm_display_mode
409 WREG32(AFMT_RAMP_CONTROL1 + offset, 0x007FFFFF); 418 WREG32(AFMT_RAMP_CONTROL1 + offset, 0x007FFFFF);
410 WREG32(AFMT_RAMP_CONTROL2 + offset, 0x00000001); 419 WREG32(AFMT_RAMP_CONTROL2 + offset, 0x00000001);
411 WREG32(AFMT_RAMP_CONTROL3 + offset, 0x00000001); 420 WREG32(AFMT_RAMP_CONTROL3 + offset, 0x00000001);
421
422 /* enable audio after to setting up hw */
423 if (ASIC_IS_DCE6(rdev))
424 dce6_audio_enable(rdev, dig->afmt->pin, true);
425 else
426 r600_audio_enable(rdev, dig->afmt->pin, true);
412} 427}
413 428
414void evergreen_hdmi_enable(struct drm_encoder *encoder, bool enable) 429void evergreen_hdmi_enable(struct drm_encoder *encoder, bool enable)
415{ 430{
416 struct drm_device *dev = encoder->dev;
417 struct radeon_device *rdev = dev->dev_private;
418 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 431 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
419 struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv; 432 struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
420 433
@@ -427,15 +440,6 @@ void evergreen_hdmi_enable(struct drm_encoder *encoder, bool enable)
427 if (!enable && !dig->afmt->enabled) 440 if (!enable && !dig->afmt->enabled)
428 return; 441 return;
429 442
430 if (enable) {
431 if (ASIC_IS_DCE6(rdev))
432 dig->afmt->pin = dce6_audio_get_pin(rdev);
433 else
434 dig->afmt->pin = r600_audio_get_pin(rdev);
435 } else {
436 dig->afmt->pin = NULL;
437 }
438
439 dig->afmt->enabled = enable; 443 dig->afmt->enabled = enable;
440 444
441 DRM_DEBUG("%sabling HDMI interface @ 0x%04X for encoder 0x%x\n", 445 DRM_DEBUG("%sabling HDMI interface @ 0x%04X for encoder 0x%x\n",
diff --git a/drivers/gpu/drm/radeon/r600_audio.c b/drivers/gpu/drm/radeon/r600_audio.c
index 47fc2b886979..bffac10c4296 100644
--- a/drivers/gpu/drm/radeon/r600_audio.c
+++ b/drivers/gpu/drm/radeon/r600_audio.c
@@ -142,12 +142,15 @@ void r600_audio_update_hdmi(struct work_struct *work)
142} 142}
143 143
144/* enable the audio stream */ 144/* enable the audio stream */
145static void r600_audio_enable(struct radeon_device *rdev, 145void r600_audio_enable(struct radeon_device *rdev,
146 struct r600_audio_pin *pin, 146 struct r600_audio_pin *pin,
147 bool enable) 147 bool enable)
148{ 148{
149 u32 value = 0; 149 u32 value = 0;
150 150
151 if (!pin)
152 return;
153
151 if (ASIC_IS_DCE4(rdev)) { 154 if (ASIC_IS_DCE4(rdev)) {
152 if (enable) { 155 if (enable) {
153 value |= 0x81000000; /* Required to enable audio */ 156 value |= 0x81000000; /* Required to enable audio */
@@ -158,7 +161,6 @@ static void r600_audio_enable(struct radeon_device *rdev,
158 WREG32_P(R600_AUDIO_ENABLE, 161 WREG32_P(R600_AUDIO_ENABLE,
159 enable ? 0x81000000 : 0x0, ~0x81000000); 162 enable ? 0x81000000 : 0x0, ~0x81000000);
160 } 163 }
161 DRM_INFO("%s audio %d support\n", enable ? "Enabling" : "Disabling", pin->id);
162} 164}
163 165
164/* 166/*
@@ -178,8 +180,8 @@ int r600_audio_init(struct radeon_device *rdev)
178 rdev->audio.pin[0].status_bits = 0; 180 rdev->audio.pin[0].status_bits = 0;
179 rdev->audio.pin[0].category_code = 0; 181 rdev->audio.pin[0].category_code = 0;
180 rdev->audio.pin[0].id = 0; 182 rdev->audio.pin[0].id = 0;
181 183 /* disable audio. it will be set up later */
182 r600_audio_enable(rdev, &rdev->audio.pin[0], true); 184 r600_audio_enable(rdev, &rdev->audio.pin[0], false);
183 185
184 return 0; 186 return 0;
185} 187}
diff --git a/drivers/gpu/drm/radeon/r600_hdmi.c b/drivers/gpu/drm/radeon/r600_hdmi.c
index 3016fc14f502..85a2bb28aed2 100644
--- a/drivers/gpu/drm/radeon/r600_hdmi.c
+++ b/drivers/gpu/drm/radeon/r600_hdmi.c
@@ -329,9 +329,6 @@ static void dce3_2_afmt_write_speaker_allocation(struct drm_encoder *encoder)
329 u8 *sadb; 329 u8 *sadb;
330 int sad_count; 330 int sad_count;
331 331
332 /* XXX: setting this register causes hangs on some asics */
333 return;
334
335 list_for_each_entry(connector, &encoder->dev->mode_config.connector_list, head) { 332 list_for_each_entry(connector, &encoder->dev->mode_config.connector_list, head) {
336 if (connector->encoder == encoder) { 333 if (connector->encoder == encoder) {
337 radeon_connector = to_radeon_connector(connector); 334 radeon_connector = to_radeon_connector(connector);
@@ -460,6 +457,10 @@ void r600_hdmi_setmode(struct drm_encoder *encoder, struct drm_display_mode *mod
460 return; 457 return;
461 offset = dig->afmt->offset; 458 offset = dig->afmt->offset;
462 459
460 /* disable audio prior to setting up hw */
461 dig->afmt->pin = r600_audio_get_pin(rdev);
462 r600_audio_enable(rdev, dig->afmt->pin, false);
463
463 r600_audio_set_dto(encoder, mode->clock); 464 r600_audio_set_dto(encoder, mode->clock);
464 465
465 WREG32(HDMI0_VBI_PACKET_CONTROL + offset, 466 WREG32(HDMI0_VBI_PACKET_CONTROL + offset,
@@ -531,6 +532,9 @@ void r600_hdmi_setmode(struct drm_encoder *encoder, struct drm_display_mode *mod
531 WREG32(HDMI0_RAMP_CONTROL3 + offset, 0x00000001); 532 WREG32(HDMI0_RAMP_CONTROL3 + offset, 0x00000001);
532 533
533 r600_hdmi_audio_workaround(encoder); 534 r600_hdmi_audio_workaround(encoder);
535
536 /* enable audio after to setting up hw */
537 r600_audio_enable(rdev, dig->afmt->pin, true);
534} 538}
535 539
536/* 540/*
@@ -651,11 +655,6 @@ void r600_hdmi_enable(struct drm_encoder *encoder, bool enable)
651 if (!enable && !dig->afmt->enabled) 655 if (!enable && !dig->afmt->enabled)
652 return; 656 return;
653 657
654 if (enable)
655 dig->afmt->pin = r600_audio_get_pin(rdev);
656 else
657 dig->afmt->pin = NULL;
658
659 /* Older chipsets require setting HDMI and routing manually */ 658 /* Older chipsets require setting HDMI and routing manually */
660 if (!ASIC_IS_DCE3(rdev)) { 659 if (!ASIC_IS_DCE3(rdev)) {
661 if (enable) 660 if (enable)
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index 024db37b1832..e887d027b6d0 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -2747,6 +2747,12 @@ int radeon_vm_bo_rmv(struct radeon_device *rdev,
2747void r600_audio_update_hdmi(struct work_struct *work); 2747void r600_audio_update_hdmi(struct work_struct *work);
2748struct r600_audio_pin *r600_audio_get_pin(struct radeon_device *rdev); 2748struct r600_audio_pin *r600_audio_get_pin(struct radeon_device *rdev);
2749struct r600_audio_pin *dce6_audio_get_pin(struct radeon_device *rdev); 2749struct r600_audio_pin *dce6_audio_get_pin(struct radeon_device *rdev);
2750void r600_audio_enable(struct radeon_device *rdev,
2751 struct r600_audio_pin *pin,
2752 bool enable);
2753void dce6_audio_enable(struct radeon_device *rdev,
2754 struct r600_audio_pin *pin,
2755 bool enable);
2750 2756
2751/* 2757/*
2752 * R600 vram scratch functions 2758 * R600 vram scratch functions
diff --git a/drivers/gpu/drm/radeon/radeon_atpx_handler.c b/drivers/gpu/drm/radeon/radeon_atpx_handler.c
index 485848f889f5..fa9a9c02751e 100644
--- a/drivers/gpu/drm/radeon/radeon_atpx_handler.c
+++ b/drivers/gpu/drm/radeon/radeon_atpx_handler.c
@@ -219,7 +219,8 @@ static int radeon_atpx_verify_interface(struct radeon_atpx *atpx)
219 memcpy(&output, info->buffer.pointer, size); 219 memcpy(&output, info->buffer.pointer, size);
220 220
221 /* TODO: check version? */ 221 /* TODO: check version? */
222 printk("ATPX version %u\n", output.version); 222 printk("ATPX version %u, functions 0x%08x\n",
223 output.version, output.function_bits);
223 224
224 radeon_atpx_parse_functions(&atpx->functions, output.function_bits); 225 radeon_atpx_parse_functions(&atpx->functions, output.function_bits);
225 226
diff --git a/drivers/gpu/drm/radeon/radeon_kms.c b/drivers/gpu/drm/radeon/radeon_kms.c
index 114d1672d616..2aecd6dc2610 100644
--- a/drivers/gpu/drm/radeon/radeon_kms.c
+++ b/drivers/gpu/drm/radeon/radeon_kms.c
@@ -537,6 +537,10 @@ int radeon_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv)
537 537
538 radeon_vm_init(rdev, &fpriv->vm); 538 radeon_vm_init(rdev, &fpriv->vm);
539 539
540 r = radeon_bo_reserve(rdev->ring_tmp_bo.bo, false);
541 if (r)
542 return r;
543
540 /* map the ib pool buffer read only into 544 /* map the ib pool buffer read only into
541 * virtual address space */ 545 * virtual address space */
542 bo_va = radeon_vm_bo_add(rdev, &fpriv->vm, 546 bo_va = radeon_vm_bo_add(rdev, &fpriv->vm,
@@ -544,6 +548,8 @@ int radeon_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv)
544 r = radeon_vm_bo_set_addr(rdev, bo_va, RADEON_VA_IB_OFFSET, 548 r = radeon_vm_bo_set_addr(rdev, bo_va, RADEON_VA_IB_OFFSET,
545 RADEON_VM_PAGE_READABLE | 549 RADEON_VM_PAGE_READABLE |
546 RADEON_VM_PAGE_SNOOPED); 550 RADEON_VM_PAGE_SNOOPED);
551
552 radeon_bo_unreserve(rdev->ring_tmp_bo.bo);
547 if (r) { 553 if (r) {
548 radeon_vm_fini(rdev, &fpriv->vm); 554 radeon_vm_fini(rdev, &fpriv->vm);
549 kfree(fpriv); 555 kfree(fpriv);
diff --git a/drivers/gpu/drm/radeon/radeon_uvd.c b/drivers/gpu/drm/radeon/radeon_uvd.c
index 6781fee1eaad..3e6804b2b2ef 100644
--- a/drivers/gpu/drm/radeon/radeon_uvd.c
+++ b/drivers/gpu/drm/radeon/radeon_uvd.c
@@ -171,6 +171,8 @@ void radeon_uvd_fini(struct radeon_device *rdev)
171 171
172 radeon_bo_unref(&rdev->uvd.vcpu_bo); 172 radeon_bo_unref(&rdev->uvd.vcpu_bo);
173 173
174 radeon_ring_fini(rdev, &rdev->ring[R600_RING_TYPE_UVD_INDEX]);
175
174 release_firmware(rdev->uvd_fw); 176 release_firmware(rdev->uvd_fw);
175} 177}
176 178
diff --git a/drivers/gpu/drm/radeon/rv770.c b/drivers/gpu/drm/radeon/rv770.c
index 6c772e58c784..4e37a42305d8 100644
--- a/drivers/gpu/drm/radeon/rv770.c
+++ b/drivers/gpu/drm/radeon/rv770.c
@@ -1955,9 +1955,9 @@ void rv770_fini(struct radeon_device *rdev)
1955 radeon_wb_fini(rdev); 1955 radeon_wb_fini(rdev);
1956 radeon_ib_pool_fini(rdev); 1956 radeon_ib_pool_fini(rdev);
1957 radeon_irq_kms_fini(rdev); 1957 radeon_irq_kms_fini(rdev);
1958 rv770_pcie_gart_fini(rdev);
1959 uvd_v1_0_fini(rdev); 1958 uvd_v1_0_fini(rdev);
1960 radeon_uvd_fini(rdev); 1959 radeon_uvd_fini(rdev);
1960 rv770_pcie_gart_fini(rdev);
1961 r600_vram_scratch_fini(rdev); 1961 r600_vram_scratch_fini(rdev);
1962 radeon_gem_fini(rdev); 1962 radeon_gem_fini(rdev);
1963 radeon_fence_driver_fini(rdev); 1963 radeon_fence_driver_fini(rdev);
diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c
index 88a529008ce0..c71594754f46 100644
--- a/drivers/gpu/drm/tegra/drm.c
+++ b/drivers/gpu/drm/tegra/drm.c
@@ -104,7 +104,7 @@ static void tegra_drm_context_free(struct tegra_drm_context *context)
104 104
105static void tegra_drm_lastclose(struct drm_device *drm) 105static void tegra_drm_lastclose(struct drm_device *drm)
106{ 106{
107#ifdef CONFIG_TEGRA_DRM_FBDEV 107#ifdef CONFIG_DRM_TEGRA_FBDEV
108 struct tegra_drm *tegra = drm->dev_private; 108 struct tegra_drm *tegra = drm->dev_private;
109 109
110 tegra_fbdev_restore_mode(tegra->fbdev); 110 tegra_fbdev_restore_mode(tegra->fbdev);
diff --git a/drivers/gpu/drm/tegra/rgb.c b/drivers/gpu/drm/tegra/rgb.c
index 338f7f6561d7..0266fb40479e 100644
--- a/drivers/gpu/drm/tegra/rgb.c
+++ b/drivers/gpu/drm/tegra/rgb.c
@@ -15,6 +15,7 @@
15struct tegra_rgb { 15struct tegra_rgb {
16 struct tegra_output output; 16 struct tegra_output output;
17 struct tegra_dc *dc; 17 struct tegra_dc *dc;
18 bool enabled;
18 19
19 struct clk *clk_parent; 20 struct clk *clk_parent;
20 struct clk *clk; 21 struct clk *clk;
@@ -89,6 +90,9 @@ static int tegra_output_rgb_enable(struct tegra_output *output)
89 struct tegra_rgb *rgb = to_rgb(output); 90 struct tegra_rgb *rgb = to_rgb(output);
90 unsigned long value; 91 unsigned long value;
91 92
93 if (rgb->enabled)
94 return 0;
95
92 tegra_dc_write_regs(rgb->dc, rgb_enable, ARRAY_SIZE(rgb_enable)); 96 tegra_dc_write_regs(rgb->dc, rgb_enable, ARRAY_SIZE(rgb_enable));
93 97
94 value = DE_SELECT_ACTIVE | DE_CONTROL_NORMAL; 98 value = DE_SELECT_ACTIVE | DE_CONTROL_NORMAL;
@@ -122,6 +126,8 @@ static int tegra_output_rgb_enable(struct tegra_output *output)
122 tegra_dc_writel(rgb->dc, GENERAL_ACT_REQ << 8, DC_CMD_STATE_CONTROL); 126 tegra_dc_writel(rgb->dc, GENERAL_ACT_REQ << 8, DC_CMD_STATE_CONTROL);
123 tegra_dc_writel(rgb->dc, GENERAL_ACT_REQ, DC_CMD_STATE_CONTROL); 127 tegra_dc_writel(rgb->dc, GENERAL_ACT_REQ, DC_CMD_STATE_CONTROL);
124 128
129 rgb->enabled = true;
130
125 return 0; 131 return 0;
126} 132}
127 133
@@ -130,6 +136,9 @@ static int tegra_output_rgb_disable(struct tegra_output *output)
130 struct tegra_rgb *rgb = to_rgb(output); 136 struct tegra_rgb *rgb = to_rgb(output);
131 unsigned long value; 137 unsigned long value;
132 138
139 if (!rgb->enabled)
140 return 0;
141
133 value = tegra_dc_readl(rgb->dc, DC_CMD_DISPLAY_POWER_CONTROL); 142 value = tegra_dc_readl(rgb->dc, DC_CMD_DISPLAY_POWER_CONTROL);
134 value &= ~(PW0_ENABLE | PW1_ENABLE | PW2_ENABLE | PW3_ENABLE | 143 value &= ~(PW0_ENABLE | PW1_ENABLE | PW2_ENABLE | PW3_ENABLE |
135 PW4_ENABLE | PM0_ENABLE | PM1_ENABLE); 144 PW4_ENABLE | PM0_ENABLE | PM1_ENABLE);
@@ -144,6 +153,8 @@ static int tegra_output_rgb_disable(struct tegra_output *output)
144 153
145 tegra_dc_write_regs(rgb->dc, rgb_disable, ARRAY_SIZE(rgb_disable)); 154 tegra_dc_write_regs(rgb->dc, rgb_disable, ARRAY_SIZE(rgb_disable));
146 155
156 rgb->enabled = false;
157
147 return 0; 158 return 0;
148} 159}
149 160
diff --git a/drivers/gpu/drm/vmwgfx/svga3d_reg.h b/drivers/gpu/drm/vmwgfx/svga3d_reg.h
index bb594c11605e..f58dc7dd15c5 100644
--- a/drivers/gpu/drm/vmwgfx/svga3d_reg.h
+++ b/drivers/gpu/drm/vmwgfx/svga3d_reg.h
@@ -261,12 +261,7 @@ typedef enum SVGA3dSurfaceFormat {
261 /* Planar video formats. */ 261 /* Planar video formats. */
262 SVGA3D_YV12 = 121, 262 SVGA3D_YV12 = 121,
263 263
264 /* Shader constant formats. */ 264 SVGA3D_FORMAT_MAX = 122,
265 SVGA3D_SURFACE_SHADERCONST_FLOAT = 122,
266 SVGA3D_SURFACE_SHADERCONST_INT = 123,
267 SVGA3D_SURFACE_SHADERCONST_BOOL = 124,
268
269 SVGA3D_FORMAT_MAX = 125,
270} SVGA3dSurfaceFormat; 265} SVGA3dSurfaceFormat;
271 266
272typedef uint32 SVGA3dColor; /* a, r, g, b */ 267typedef uint32 SVGA3dColor; /* a, r, g, b */
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
index 9e4be1725985..07831554dad7 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
@@ -40,7 +40,7 @@
40#include <drm/ttm/ttm_module.h> 40#include <drm/ttm/ttm_module.h>
41#include "vmwgfx_fence.h" 41#include "vmwgfx_fence.h"
42 42
43#define VMWGFX_DRIVER_DATE "20121114" 43#define VMWGFX_DRIVER_DATE "20140228"
44#define VMWGFX_DRIVER_MAJOR 2 44#define VMWGFX_DRIVER_MAJOR 2
45#define VMWGFX_DRIVER_MINOR 5 45#define VMWGFX_DRIVER_MINOR 5
46#define VMWGFX_DRIVER_PATCHLEVEL 0 46#define VMWGFX_DRIVER_PATCHLEVEL 0
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_mob.c b/drivers/gpu/drm/vmwgfx/vmwgfx_mob.c
index d4a5a19cb8c3..04a64b8cd3cd 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_mob.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_mob.c
@@ -188,18 +188,20 @@ static void vmw_takedown_otable_base(struct vmw_private *dev_priv,
188 188
189 bo = otable->page_table->pt_bo; 189 bo = otable->page_table->pt_bo;
190 cmd = vmw_fifo_reserve(dev_priv, sizeof(*cmd)); 190 cmd = vmw_fifo_reserve(dev_priv, sizeof(*cmd));
191 if (unlikely(cmd == NULL)) 191 if (unlikely(cmd == NULL)) {
192 DRM_ERROR("Failed reserving FIFO space for OTable setup.\n"); 192 DRM_ERROR("Failed reserving FIFO space for OTable "
193 193 "takedown.\n");
194 memset(cmd, 0, sizeof(*cmd)); 194 } else {
195 cmd->header.id = SVGA_3D_CMD_SET_OTABLE_BASE; 195 memset(cmd, 0, sizeof(*cmd));
196 cmd->header.size = sizeof(cmd->body); 196 cmd->header.id = SVGA_3D_CMD_SET_OTABLE_BASE;
197 cmd->body.type = type; 197 cmd->header.size = sizeof(cmd->body);
198 cmd->body.baseAddress = 0; 198 cmd->body.type = type;
199 cmd->body.sizeInBytes = 0; 199 cmd->body.baseAddress = 0;
200 cmd->body.validSizeInBytes = 0; 200 cmd->body.sizeInBytes = 0;
201 cmd->body.ptDepth = SVGA3D_MOBFMT_INVALID; 201 cmd->body.validSizeInBytes = 0;
202 vmw_fifo_commit(dev_priv, sizeof(*cmd)); 202 cmd->body.ptDepth = SVGA3D_MOBFMT_INVALID;
203 vmw_fifo_commit(dev_priv, sizeof(*cmd));
204 }
203 205
204 if (bo) { 206 if (bo) {
205 int ret; 207 int ret;
@@ -562,11 +564,12 @@ void vmw_mob_unbind(struct vmw_private *dev_priv,
562 if (unlikely(cmd == NULL)) { 564 if (unlikely(cmd == NULL)) {
563 DRM_ERROR("Failed reserving FIFO space for Memory " 565 DRM_ERROR("Failed reserving FIFO space for Memory "
564 "Object unbinding.\n"); 566 "Object unbinding.\n");
567 } else {
568 cmd->header.id = SVGA_3D_CMD_DESTROY_GB_MOB;
569 cmd->header.size = sizeof(cmd->body);
570 cmd->body.mobid = mob->id;
571 vmw_fifo_commit(dev_priv, sizeof(*cmd));
565 } 572 }
566 cmd->header.id = SVGA_3D_CMD_DESTROY_GB_MOB;
567 cmd->header.size = sizeof(cmd->body);
568 cmd->body.mobid = mob->id;
569 vmw_fifo_commit(dev_priv, sizeof(*cmd));
570 if (bo) { 573 if (bo) {
571 vmw_fence_single_bo(bo, NULL); 574 vmw_fence_single_bo(bo, NULL);
572 ttm_bo_unreserve(bo); 575 ttm_bo_unreserve(bo);
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
index 2aa4bc6a4d60..9757b57f8388 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
@@ -427,8 +427,7 @@ int vmw_dmabuf_init(struct vmw_private *dev_priv,
427 INIT_LIST_HEAD(&vmw_bo->res_list); 427 INIT_LIST_HEAD(&vmw_bo->res_list);
428 428
429 ret = ttm_bo_init(bdev, &vmw_bo->base, size, 429 ret = ttm_bo_init(bdev, &vmw_bo->base, size,
430 (user) ? ttm_bo_type_device : 430 ttm_bo_type_device, placement,
431 ttm_bo_type_kernel, placement,
432 0, interruptible, 431 0, interruptible,
433 NULL, acc_size, NULL, bo_free); 432 NULL, acc_size, NULL, bo_free);
434 return ret; 433 return ret;
diff --git a/drivers/gpu/host1x/job.c b/drivers/gpu/host1x/job.c
index 1146e3bba6e1..112f27e51bc7 100644
--- a/drivers/gpu/host1x/job.c
+++ b/drivers/gpu/host1x/job.c
@@ -538,7 +538,7 @@ int host1x_job_pin(struct host1x_job *job, struct device *dev)
538 538
539 g->base = job->gather_addr_phys[i]; 539 g->base = job->gather_addr_phys[i];
540 540
541 for (j = 0; j < job->num_gathers; j++) 541 for (j = i + 1; j < job->num_gathers; j++)
542 if (job->gathers[j].bo == g->bo) 542 if (job->gathers[j].bo == g->bo)
543 job->gathers[j].handled = true; 543 job->gathers[j].handled = true;
544 544
diff --git a/drivers/hwmon/max1668.c b/drivers/hwmon/max1668.c
index a7626358c95d..029b65e6c589 100644
--- a/drivers/hwmon/max1668.c
+++ b/drivers/hwmon/max1668.c
@@ -243,7 +243,7 @@ static ssize_t set_temp_min(struct device *dev,
243 data->temp_min[index] = clamp_val(temp/1000, -128, 127); 243 data->temp_min[index] = clamp_val(temp/1000, -128, 127);
244 if (i2c_smbus_write_byte_data(client, 244 if (i2c_smbus_write_byte_data(client,
245 MAX1668_REG_LIML_WR(index), 245 MAX1668_REG_LIML_WR(index),
246 data->temp_max[index])) 246 data->temp_min[index]))
247 count = -EIO; 247 count = -EIO;
248 mutex_unlock(&data->update_lock); 248 mutex_unlock(&data->update_lock);
249 249
diff --git a/drivers/iio/gyro/Kconfig b/drivers/iio/gyro/Kconfig
index 41c64a43bcab..ac2d69e34c8c 100644
--- a/drivers/iio/gyro/Kconfig
+++ b/drivers/iio/gyro/Kconfig
@@ -70,7 +70,7 @@ config IIO_ST_GYRO_3AXIS
70 select IIO_TRIGGERED_BUFFER if (IIO_BUFFER) 70 select IIO_TRIGGERED_BUFFER if (IIO_BUFFER)
71 help 71 help
72 Say yes here to build support for STMicroelectronics gyroscopes: 72 Say yes here to build support for STMicroelectronics gyroscopes:
73 L3G4200D, LSM330DL, L3GD20, L3GD20H, LSM330DLC, L3G4IS, LSM330. 73 L3G4200D, LSM330DL, L3GD20, LSM330DLC, L3G4IS, LSM330.
74 74
75 This driver can also be built as a module. If so, these modules 75 This driver can also be built as a module. If so, these modules
76 will be created: 76 will be created:
diff --git a/drivers/iio/gyro/st_gyro.h b/drivers/iio/gyro/st_gyro.h
index f8f2bf84a5a2..c197360c450b 100644
--- a/drivers/iio/gyro/st_gyro.h
+++ b/drivers/iio/gyro/st_gyro.h
@@ -19,7 +19,6 @@
19#define LSM330DL_GYRO_DEV_NAME "lsm330dl_gyro" 19#define LSM330DL_GYRO_DEV_NAME "lsm330dl_gyro"
20#define LSM330DLC_GYRO_DEV_NAME "lsm330dlc_gyro" 20#define LSM330DLC_GYRO_DEV_NAME "lsm330dlc_gyro"
21#define L3GD20_GYRO_DEV_NAME "l3gd20" 21#define L3GD20_GYRO_DEV_NAME "l3gd20"
22#define L3GD20H_GYRO_DEV_NAME "l3gd20h"
23#define L3G4IS_GYRO_DEV_NAME "l3g4is_ui" 22#define L3G4IS_GYRO_DEV_NAME "l3g4is_ui"
24#define LSM330_GYRO_DEV_NAME "lsm330_gyro" 23#define LSM330_GYRO_DEV_NAME "lsm330_gyro"
25 24
diff --git a/drivers/iio/gyro/st_gyro_core.c b/drivers/iio/gyro/st_gyro_core.c
index d53d91adfb55..a8e174a47bc4 100644
--- a/drivers/iio/gyro/st_gyro_core.c
+++ b/drivers/iio/gyro/st_gyro_core.c
@@ -167,11 +167,10 @@ static const struct st_sensors st_gyro_sensors[] = {
167 .wai = ST_GYRO_2_WAI_EXP, 167 .wai = ST_GYRO_2_WAI_EXP,
168 .sensors_supported = { 168 .sensors_supported = {
169 [0] = L3GD20_GYRO_DEV_NAME, 169 [0] = L3GD20_GYRO_DEV_NAME,
170 [1] = L3GD20H_GYRO_DEV_NAME, 170 [1] = LSM330D_GYRO_DEV_NAME,
171 [2] = LSM330D_GYRO_DEV_NAME, 171 [2] = LSM330DLC_GYRO_DEV_NAME,
172 [3] = LSM330DLC_GYRO_DEV_NAME, 172 [3] = L3G4IS_GYRO_DEV_NAME,
173 [4] = L3G4IS_GYRO_DEV_NAME, 173 [4] = LSM330_GYRO_DEV_NAME,
174 [5] = LSM330_GYRO_DEV_NAME,
175 }, 174 },
176 .ch = (struct iio_chan_spec *)st_gyro_16bit_channels, 175 .ch = (struct iio_chan_spec *)st_gyro_16bit_channels,
177 .odr = { 176 .odr = {
diff --git a/drivers/iio/gyro/st_gyro_i2c.c b/drivers/iio/gyro/st_gyro_i2c.c
index 16b8b8d70bf1..23c12f361b05 100644
--- a/drivers/iio/gyro/st_gyro_i2c.c
+++ b/drivers/iio/gyro/st_gyro_i2c.c
@@ -55,7 +55,6 @@ static const struct i2c_device_id st_gyro_id_table[] = {
55 { LSM330DL_GYRO_DEV_NAME }, 55 { LSM330DL_GYRO_DEV_NAME },
56 { LSM330DLC_GYRO_DEV_NAME }, 56 { LSM330DLC_GYRO_DEV_NAME },
57 { L3GD20_GYRO_DEV_NAME }, 57 { L3GD20_GYRO_DEV_NAME },
58 { L3GD20H_GYRO_DEV_NAME },
59 { L3G4IS_GYRO_DEV_NAME }, 58 { L3G4IS_GYRO_DEV_NAME },
60 { LSM330_GYRO_DEV_NAME }, 59 { LSM330_GYRO_DEV_NAME },
61 {}, 60 {},
diff --git a/drivers/iio/gyro/st_gyro_spi.c b/drivers/iio/gyro/st_gyro_spi.c
index 94763e25caf9..b4ad3be26687 100644
--- a/drivers/iio/gyro/st_gyro_spi.c
+++ b/drivers/iio/gyro/st_gyro_spi.c
@@ -54,7 +54,6 @@ static const struct spi_device_id st_gyro_id_table[] = {
54 { LSM330DL_GYRO_DEV_NAME }, 54 { LSM330DL_GYRO_DEV_NAME },
55 { LSM330DLC_GYRO_DEV_NAME }, 55 { LSM330DLC_GYRO_DEV_NAME },
56 { L3GD20_GYRO_DEV_NAME }, 56 { L3GD20_GYRO_DEV_NAME },
57 { L3GD20H_GYRO_DEV_NAME },
58 { L3G4IS_GYRO_DEV_NAME }, 57 { L3G4IS_GYRO_DEV_NAME },
59 { LSM330_GYRO_DEV_NAME }, 58 { LSM330_GYRO_DEV_NAME },
60 {}, 59 {},
diff --git a/drivers/iio/light/cm32181.c b/drivers/iio/light/cm32181.c
index f17b4e6183c6..47a6dbac2d0c 100644
--- a/drivers/iio/light/cm32181.c
+++ b/drivers/iio/light/cm32181.c
@@ -103,13 +103,13 @@ static int cm32181_reg_init(struct cm32181_chip *cm32181)
103/** 103/**
104 * cm32181_read_als_it() - Get sensor integration time (ms) 104 * cm32181_read_als_it() - Get sensor integration time (ms)
105 * @cm32181: pointer of struct cm32181 105 * @cm32181: pointer of struct cm32181
106 * @val: pointer of int to load the als_it value. 106 * @val2: pointer of int to load the als_it value.
107 * 107 *
108 * Report the current integartion time by millisecond. 108 * Report the current integartion time by millisecond.
109 * 109 *
110 * Return: IIO_VAL_INT for success, otherwise -EINVAL. 110 * Return: IIO_VAL_INT_PLUS_MICRO for success, otherwise -EINVAL.
111 */ 111 */
112static int cm32181_read_als_it(struct cm32181_chip *cm32181, int *val) 112static int cm32181_read_als_it(struct cm32181_chip *cm32181, int *val2)
113{ 113{
114 u16 als_it; 114 u16 als_it;
115 int i; 115 int i;
@@ -119,8 +119,8 @@ static int cm32181_read_als_it(struct cm32181_chip *cm32181, int *val)
119 als_it >>= CM32181_CMD_ALS_IT_SHIFT; 119 als_it >>= CM32181_CMD_ALS_IT_SHIFT;
120 for (i = 0; i < ARRAY_SIZE(als_it_bits); i++) { 120 for (i = 0; i < ARRAY_SIZE(als_it_bits); i++) {
121 if (als_it == als_it_bits[i]) { 121 if (als_it == als_it_bits[i]) {
122 *val = als_it_value[i]; 122 *val2 = als_it_value[i];
123 return IIO_VAL_INT; 123 return IIO_VAL_INT_PLUS_MICRO;
124 } 124 }
125 } 125 }
126 126
@@ -221,7 +221,7 @@ static int cm32181_read_raw(struct iio_dev *indio_dev,
221 *val = cm32181->calibscale; 221 *val = cm32181->calibscale;
222 return IIO_VAL_INT; 222 return IIO_VAL_INT;
223 case IIO_CHAN_INFO_INT_TIME: 223 case IIO_CHAN_INFO_INT_TIME:
224 ret = cm32181_read_als_it(cm32181, val); 224 ret = cm32181_read_als_it(cm32181, val2);
225 return ret; 225 return ret;
226 } 226 }
227 227
@@ -240,7 +240,7 @@ static int cm32181_write_raw(struct iio_dev *indio_dev,
240 cm32181->calibscale = val; 240 cm32181->calibscale = val;
241 return val; 241 return val;
242 case IIO_CHAN_INFO_INT_TIME: 242 case IIO_CHAN_INFO_INT_TIME:
243 ret = cm32181_write_als_it(cm32181, val); 243 ret = cm32181_write_als_it(cm32181, val2);
244 return ret; 244 return ret;
245 } 245 }
246 246
@@ -264,7 +264,7 @@ static ssize_t cm32181_get_it_available(struct device *dev,
264 264
265 n = ARRAY_SIZE(als_it_value); 265 n = ARRAY_SIZE(als_it_value);
266 for (i = 0, len = 0; i < n; i++) 266 for (i = 0, len = 0; i < n; i++)
267 len += sprintf(buf + len, "%d ", als_it_value[i]); 267 len += sprintf(buf + len, "0.%06u ", als_it_value[i]);
268 return len + sprintf(buf + len, "\n"); 268 return len + sprintf(buf + len, "\n");
269} 269}
270 270
diff --git a/drivers/iio/light/cm36651.c b/drivers/iio/light/cm36651.c
index 0a142af83e25..a45e07492db3 100644
--- a/drivers/iio/light/cm36651.c
+++ b/drivers/iio/light/cm36651.c
@@ -50,10 +50,10 @@
50#define CM36651_CS_CONF2_DEFAULT_BIT 0x08 50#define CM36651_CS_CONF2_DEFAULT_BIT 0x08
51 51
52/* CS_CONF3 channel integration time */ 52/* CS_CONF3 channel integration time */
53#define CM36651_CS_IT1 0x00 /* Integration time 80000 usec */ 53#define CM36651_CS_IT1 0x00 /* Integration time 80 msec */
54#define CM36651_CS_IT2 0x40 /* Integration time 160000 usec */ 54#define CM36651_CS_IT2 0x40 /* Integration time 160 msec */
55#define CM36651_CS_IT3 0x80 /* Integration time 320000 usec */ 55#define CM36651_CS_IT3 0x80 /* Integration time 320 msec */
56#define CM36651_CS_IT4 0xC0 /* Integration time 640000 usec */ 56#define CM36651_CS_IT4 0xC0 /* Integration time 640 msec */
57 57
58/* PS_CONF1 command code */ 58/* PS_CONF1 command code */
59#define CM36651_PS_ENABLE 0x00 59#define CM36651_PS_ENABLE 0x00
@@ -64,10 +64,10 @@
64#define CM36651_PS_PERS4 0x0C 64#define CM36651_PS_PERS4 0x0C
65 65
66/* PS_CONF1 command code: integration time */ 66/* PS_CONF1 command code: integration time */
67#define CM36651_PS_IT1 0x00 /* Integration time 320 usec */ 67#define CM36651_PS_IT1 0x00 /* Integration time 0.32 msec */
68#define CM36651_PS_IT2 0x10 /* Integration time 420 usec */ 68#define CM36651_PS_IT2 0x10 /* Integration time 0.42 msec */
69#define CM36651_PS_IT3 0x20 /* Integration time 520 usec */ 69#define CM36651_PS_IT3 0x20 /* Integration time 0.52 msec */
70#define CM36651_PS_IT4 0x30 /* Integration time 640 usec */ 70#define CM36651_PS_IT4 0x30 /* Integration time 0.64 msec */
71 71
72/* PS_CONF1 command code: duty ratio */ 72/* PS_CONF1 command code: duty ratio */
73#define CM36651_PS_DR1 0x00 /* Duty ratio 1/80 */ 73#define CM36651_PS_DR1 0x00 /* Duty ratio 1/80 */
@@ -93,8 +93,8 @@
93#define CM36651_CLOSE_PROXIMITY 0x32 93#define CM36651_CLOSE_PROXIMITY 0x32
94#define CM36651_FAR_PROXIMITY 0x33 94#define CM36651_FAR_PROXIMITY 0x33
95 95
96#define CM36651_CS_INT_TIME_AVAIL "80000 160000 320000 640000" 96#define CM36651_CS_INT_TIME_AVAIL "0.08 0.16 0.32 0.64"
97#define CM36651_PS_INT_TIME_AVAIL "320 420 520 640" 97#define CM36651_PS_INT_TIME_AVAIL "0.000320 0.000420 0.000520 0.000640"
98 98
99enum cm36651_operation_mode { 99enum cm36651_operation_mode {
100 CM36651_LIGHT_EN, 100 CM36651_LIGHT_EN,
@@ -356,30 +356,30 @@ static int cm36651_read_channel(struct cm36651_data *cm36651,
356} 356}
357 357
358static int cm36651_read_int_time(struct cm36651_data *cm36651, 358static int cm36651_read_int_time(struct cm36651_data *cm36651,
359 struct iio_chan_spec const *chan, int *val) 359 struct iio_chan_spec const *chan, int *val2)
360{ 360{
361 switch (chan->type) { 361 switch (chan->type) {
362 case IIO_LIGHT: 362 case IIO_LIGHT:
363 if (cm36651->cs_int_time[chan->address] == CM36651_CS_IT1) 363 if (cm36651->cs_int_time[chan->address] == CM36651_CS_IT1)
364 *val = 80000; 364 *val2 = 80000;
365 else if (cm36651->cs_int_time[chan->address] == CM36651_CS_IT2) 365 else if (cm36651->cs_int_time[chan->address] == CM36651_CS_IT2)
366 *val = 160000; 366 *val2 = 160000;
367 else if (cm36651->cs_int_time[chan->address] == CM36651_CS_IT3) 367 else if (cm36651->cs_int_time[chan->address] == CM36651_CS_IT3)
368 *val = 320000; 368 *val2 = 320000;
369 else if (cm36651->cs_int_time[chan->address] == CM36651_CS_IT4) 369 else if (cm36651->cs_int_time[chan->address] == CM36651_CS_IT4)
370 *val = 640000; 370 *val2 = 640000;
371 else 371 else
372 return -EINVAL; 372 return -EINVAL;
373 break; 373 break;
374 case IIO_PROXIMITY: 374 case IIO_PROXIMITY:
375 if (cm36651->ps_int_time == CM36651_PS_IT1) 375 if (cm36651->ps_int_time == CM36651_PS_IT1)
376 *val = 320; 376 *val2 = 320;
377 else if (cm36651->ps_int_time == CM36651_PS_IT2) 377 else if (cm36651->ps_int_time == CM36651_PS_IT2)
378 *val = 420; 378 *val2 = 420;
379 else if (cm36651->ps_int_time == CM36651_PS_IT3) 379 else if (cm36651->ps_int_time == CM36651_PS_IT3)
380 *val = 520; 380 *val2 = 520;
381 else if (cm36651->ps_int_time == CM36651_PS_IT4) 381 else if (cm36651->ps_int_time == CM36651_PS_IT4)
382 *val = 640; 382 *val2 = 640;
383 else 383 else
384 return -EINVAL; 384 return -EINVAL;
385 break; 385 break;
@@ -387,7 +387,7 @@ static int cm36651_read_int_time(struct cm36651_data *cm36651,
387 return -EINVAL; 387 return -EINVAL;
388 } 388 }
389 389
390 return IIO_VAL_INT; 390 return IIO_VAL_INT_PLUS_MICRO;
391} 391}
392 392
393static int cm36651_write_int_time(struct cm36651_data *cm36651, 393static int cm36651_write_int_time(struct cm36651_data *cm36651,
@@ -459,7 +459,8 @@ static int cm36651_read_raw(struct iio_dev *indio_dev,
459 ret = cm36651_read_channel(cm36651, chan, val); 459 ret = cm36651_read_channel(cm36651, chan, val);
460 break; 460 break;
461 case IIO_CHAN_INFO_INT_TIME: 461 case IIO_CHAN_INFO_INT_TIME:
462 ret = cm36651_read_int_time(cm36651, chan, val); 462 *val = 0;
463 ret = cm36651_read_int_time(cm36651, chan, val2);
463 break; 464 break;
464 default: 465 default:
465 ret = -EINVAL; 466 ret = -EINVAL;
@@ -479,7 +480,7 @@ static int cm36651_write_raw(struct iio_dev *indio_dev,
479 int ret = -EINVAL; 480 int ret = -EINVAL;
480 481
481 if (mask == IIO_CHAN_INFO_INT_TIME) { 482 if (mask == IIO_CHAN_INFO_INT_TIME) {
482 ret = cm36651_write_int_time(cm36651, chan, val); 483 ret = cm36651_write_int_time(cm36651, chan, val2);
483 if (ret < 0) 484 if (ret < 0)
484 dev_err(&client->dev, "Integration time write failed\n"); 485 dev_err(&client->dev, "Integration time write failed\n");
485 } 486 }
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index e81c5547e647..f9c12e92fdd6 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -53,8 +53,8 @@
53#include "user.h" 53#include "user.h"
54 54
55#define DRV_NAME MLX4_IB_DRV_NAME 55#define DRV_NAME MLX4_IB_DRV_NAME
56#define DRV_VERSION "1.0" 56#define DRV_VERSION "2.2-1"
57#define DRV_RELDATE "April 4, 2008" 57#define DRV_RELDATE "Feb 2014"
58 58
59#define MLX4_IB_FLOW_MAX_PRIO 0xFFF 59#define MLX4_IB_FLOW_MAX_PRIO 0xFFF
60#define MLX4_IB_FLOW_QPN_MASK 0xFFFFFF 60#define MLX4_IB_FLOW_QPN_MASK 0xFFFFFF
diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c
index aa03e732b6a8..bf900579ac08 100644
--- a/drivers/infiniband/hw/mlx5/main.c
+++ b/drivers/infiniband/hw/mlx5/main.c
@@ -46,8 +46,8 @@
46#include "mlx5_ib.h" 46#include "mlx5_ib.h"
47 47
48#define DRIVER_NAME "mlx5_ib" 48#define DRIVER_NAME "mlx5_ib"
49#define DRIVER_VERSION "1.0" 49#define DRIVER_VERSION "2.2-1"
50#define DRIVER_RELDATE "June 2013" 50#define DRIVER_RELDATE "Feb 2014"
51 51
52MODULE_AUTHOR("Eli Cohen <eli@mellanox.com>"); 52MODULE_AUTHOR("Eli Cohen <eli@mellanox.com>");
53MODULE_DESCRIPTION("Mellanox Connect-IB HCA IB driver"); 53MODULE_DESCRIPTION("Mellanox Connect-IB HCA IB driver");
diff --git a/drivers/input/misc/arizona-haptics.c b/drivers/input/misc/arizona-haptics.c
index 7a04f54ef961..ef2e281b0a43 100644
--- a/drivers/input/misc/arizona-haptics.c
+++ b/drivers/input/misc/arizona-haptics.c
@@ -37,7 +37,6 @@ static void arizona_haptics_work(struct work_struct *work)
37 struct arizona_haptics, 37 struct arizona_haptics,
38 work); 38 work);
39 struct arizona *arizona = haptics->arizona; 39 struct arizona *arizona = haptics->arizona;
40 struct mutex *dapm_mutex = &arizona->dapm->card->dapm_mutex;
41 int ret; 40 int ret;
42 41
43 if (!haptics->arizona->dapm) { 42 if (!haptics->arizona->dapm) {
@@ -67,13 +66,10 @@ static void arizona_haptics_work(struct work_struct *work)
67 return; 66 return;
68 } 67 }
69 68
70 mutex_lock_nested(dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
71
72 ret = snd_soc_dapm_enable_pin(arizona->dapm, "HAPTICS"); 69 ret = snd_soc_dapm_enable_pin(arizona->dapm, "HAPTICS");
73 if (ret != 0) { 70 if (ret != 0) {
74 dev_err(arizona->dev, "Failed to start HAPTICS: %d\n", 71 dev_err(arizona->dev, "Failed to start HAPTICS: %d\n",
75 ret); 72 ret);
76 mutex_unlock(dapm_mutex);
77 return; 73 return;
78 } 74 }
79 75
@@ -81,21 +77,14 @@ static void arizona_haptics_work(struct work_struct *work)
81 if (ret != 0) { 77 if (ret != 0) {
82 dev_err(arizona->dev, "Failed to sync DAPM: %d\n", 78 dev_err(arizona->dev, "Failed to sync DAPM: %d\n",
83 ret); 79 ret);
84 mutex_unlock(dapm_mutex);
85 return; 80 return;
86 } 81 }
87
88 mutex_unlock(dapm_mutex);
89
90 } else { 82 } else {
91 /* This disable sequence will be a noop if already enabled */ 83 /* This disable sequence will be a noop if already enabled */
92 mutex_lock_nested(dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
93
94 ret = snd_soc_dapm_disable_pin(arizona->dapm, "HAPTICS"); 84 ret = snd_soc_dapm_disable_pin(arizona->dapm, "HAPTICS");
95 if (ret != 0) { 85 if (ret != 0) {
96 dev_err(arizona->dev, "Failed to disable HAPTICS: %d\n", 86 dev_err(arizona->dev, "Failed to disable HAPTICS: %d\n",
97 ret); 87 ret);
98 mutex_unlock(dapm_mutex);
99 return; 88 return;
100 } 89 }
101 90
@@ -103,12 +92,9 @@ static void arizona_haptics_work(struct work_struct *work)
103 if (ret != 0) { 92 if (ret != 0) {
104 dev_err(arizona->dev, "Failed to sync DAPM: %d\n", 93 dev_err(arizona->dev, "Failed to sync DAPM: %d\n",
105 ret); 94 ret);
106 mutex_unlock(dapm_mutex);
107 return; 95 return;
108 } 96 }
109 97
110 mutex_unlock(dapm_mutex);
111
112 ret = regmap_update_bits(arizona->regmap, 98 ret = regmap_update_bits(arizona->regmap,
113 ARIZONA_HAPTICS_CONTROL_1, 99 ARIZONA_HAPTICS_CONTROL_1,
114 ARIZONA_HAP_CTRL_MASK, 100 ARIZONA_HAP_CTRL_MASK,
@@ -155,16 +141,11 @@ static int arizona_haptics_play(struct input_dev *input, void *data,
155static void arizona_haptics_close(struct input_dev *input) 141static void arizona_haptics_close(struct input_dev *input)
156{ 142{
157 struct arizona_haptics *haptics = input_get_drvdata(input); 143 struct arizona_haptics *haptics = input_get_drvdata(input);
158 struct mutex *dapm_mutex = &haptics->arizona->dapm->card->dapm_mutex;
159 144
160 cancel_work_sync(&haptics->work); 145 cancel_work_sync(&haptics->work);
161 146
162 mutex_lock_nested(dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
163
164 if (haptics->arizona->dapm) 147 if (haptics->arizona->dapm)
165 snd_soc_dapm_disable_pin(haptics->arizona->dapm, "HAPTICS"); 148 snd_soc_dapm_disable_pin(haptics->arizona->dapm, "HAPTICS");
166
167 mutex_unlock(dapm_mutex);
168} 149}
169 150
170static int arizona_haptics_probe(struct platform_device *pdev) 151static int arizona_haptics_probe(struct platform_device *pdev)
diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c
index 8911850c9444..1d9ab39af29f 100644
--- a/drivers/iommu/arm-smmu.c
+++ b/drivers/iommu/arm-smmu.c
@@ -79,7 +79,6 @@
79 79
80#define ARM_SMMU_PTE_CONT_SIZE (PAGE_SIZE * ARM_SMMU_PTE_CONT_ENTRIES) 80#define ARM_SMMU_PTE_CONT_SIZE (PAGE_SIZE * ARM_SMMU_PTE_CONT_ENTRIES)
81#define ARM_SMMU_PTE_CONT_MASK (~(ARM_SMMU_PTE_CONT_SIZE - 1)) 81#define ARM_SMMU_PTE_CONT_MASK (~(ARM_SMMU_PTE_CONT_SIZE - 1))
82#define ARM_SMMU_PTE_HWTABLE_SIZE (PTRS_PER_PTE * sizeof(pte_t))
83 82
84/* Stage-1 PTE */ 83/* Stage-1 PTE */
85#define ARM_SMMU_PTE_AP_UNPRIV (((pteval_t)1) << 6) 84#define ARM_SMMU_PTE_AP_UNPRIV (((pteval_t)1) << 6)
@@ -191,6 +190,9 @@
191#define ARM_SMMU_GR1_CBAR(n) (0x0 + ((n) << 2)) 190#define ARM_SMMU_GR1_CBAR(n) (0x0 + ((n) << 2))
192#define CBAR_VMID_SHIFT 0 191#define CBAR_VMID_SHIFT 0
193#define CBAR_VMID_MASK 0xff 192#define CBAR_VMID_MASK 0xff
193#define CBAR_S1_BPSHCFG_SHIFT 8
194#define CBAR_S1_BPSHCFG_MASK 3
195#define CBAR_S1_BPSHCFG_NSH 3
194#define CBAR_S1_MEMATTR_SHIFT 12 196#define CBAR_S1_MEMATTR_SHIFT 12
195#define CBAR_S1_MEMATTR_MASK 0xf 197#define CBAR_S1_MEMATTR_MASK 0xf
196#define CBAR_S1_MEMATTR_WB 0xf 198#define CBAR_S1_MEMATTR_WB 0xf
@@ -393,7 +395,7 @@ struct arm_smmu_domain {
393 struct arm_smmu_cfg root_cfg; 395 struct arm_smmu_cfg root_cfg;
394 phys_addr_t output_mask; 396 phys_addr_t output_mask;
395 397
396 struct mutex lock; 398 spinlock_t lock;
397}; 399};
398 400
399static DEFINE_SPINLOCK(arm_smmu_devices_lock); 401static DEFINE_SPINLOCK(arm_smmu_devices_lock);
@@ -632,6 +634,28 @@ static irqreturn_t arm_smmu_global_fault(int irq, void *dev)
632 return IRQ_HANDLED; 634 return IRQ_HANDLED;
633} 635}
634 636
637static void arm_smmu_flush_pgtable(struct arm_smmu_device *smmu, void *addr,
638 size_t size)
639{
640 unsigned long offset = (unsigned long)addr & ~PAGE_MASK;
641
642
643 /* Ensure new page tables are visible to the hardware walker */
644 if (smmu->features & ARM_SMMU_FEAT_COHERENT_WALK) {
645 dsb();
646 } else {
647 /*
648 * If the SMMU can't walk tables in the CPU caches, treat them
649 * like non-coherent DMA since we need to flush the new entries
650 * all the way out to memory. There's no possibility of
651 * recursion here as the SMMU table walker will not be wired
652 * through another SMMU.
653 */
654 dma_map_page(smmu->dev, virt_to_page(addr), offset, size,
655 DMA_TO_DEVICE);
656 }
657}
658
635static void arm_smmu_init_context_bank(struct arm_smmu_domain *smmu_domain) 659static void arm_smmu_init_context_bank(struct arm_smmu_domain *smmu_domain)
636{ 660{
637 u32 reg; 661 u32 reg;
@@ -650,11 +674,16 @@ static void arm_smmu_init_context_bank(struct arm_smmu_domain *smmu_domain)
650 if (smmu->version == 1) 674 if (smmu->version == 1)
651 reg |= root_cfg->irptndx << CBAR_IRPTNDX_SHIFT; 675 reg |= root_cfg->irptndx << CBAR_IRPTNDX_SHIFT;
652 676
653 /* Use the weakest memory type, so it is overridden by the pte */ 677 /*
654 if (stage1) 678 * Use the weakest shareability/memory types, so they are
655 reg |= (CBAR_S1_MEMATTR_WB << CBAR_S1_MEMATTR_SHIFT); 679 * overridden by the ttbcr/pte.
656 else 680 */
681 if (stage1) {
682 reg |= (CBAR_S1_BPSHCFG_NSH << CBAR_S1_BPSHCFG_SHIFT) |
683 (CBAR_S1_MEMATTR_WB << CBAR_S1_MEMATTR_SHIFT);
684 } else {
657 reg |= ARM_SMMU_CB_VMID(root_cfg) << CBAR_VMID_SHIFT; 685 reg |= ARM_SMMU_CB_VMID(root_cfg) << CBAR_VMID_SHIFT;
686 }
658 writel_relaxed(reg, gr1_base + ARM_SMMU_GR1_CBAR(root_cfg->cbndx)); 687 writel_relaxed(reg, gr1_base + ARM_SMMU_GR1_CBAR(root_cfg->cbndx));
659 688
660 if (smmu->version > 1) { 689 if (smmu->version > 1) {
@@ -715,6 +744,8 @@ static void arm_smmu_init_context_bank(struct arm_smmu_domain *smmu_domain)
715 } 744 }
716 745
717 /* TTBR0 */ 746 /* TTBR0 */
747 arm_smmu_flush_pgtable(smmu, root_cfg->pgd,
748 PTRS_PER_PGD * sizeof(pgd_t));
718 reg = __pa(root_cfg->pgd); 749 reg = __pa(root_cfg->pgd);
719 writel_relaxed(reg, cb_base + ARM_SMMU_CB_TTBR0_LO); 750 writel_relaxed(reg, cb_base + ARM_SMMU_CB_TTBR0_LO);
720 reg = (phys_addr_t)__pa(root_cfg->pgd) >> 32; 751 reg = (phys_addr_t)__pa(root_cfg->pgd) >> 32;
@@ -901,7 +932,7 @@ static int arm_smmu_domain_init(struct iommu_domain *domain)
901 goto out_free_domain; 932 goto out_free_domain;
902 smmu_domain->root_cfg.pgd = pgd; 933 smmu_domain->root_cfg.pgd = pgd;
903 934
904 mutex_init(&smmu_domain->lock); 935 spin_lock_init(&smmu_domain->lock);
905 domain->priv = smmu_domain; 936 domain->priv = smmu_domain;
906 return 0; 937 return 0;
907 938
@@ -1128,6 +1159,7 @@ static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev)
1128 struct arm_smmu_domain *smmu_domain = domain->priv; 1159 struct arm_smmu_domain *smmu_domain = domain->priv;
1129 struct arm_smmu_device *device_smmu = dev->archdata.iommu; 1160 struct arm_smmu_device *device_smmu = dev->archdata.iommu;
1130 struct arm_smmu_master *master; 1161 struct arm_smmu_master *master;
1162 unsigned long flags;
1131 1163
1132 if (!device_smmu) { 1164 if (!device_smmu) {
1133 dev_err(dev, "cannot attach to SMMU, is it on the same bus?\n"); 1165 dev_err(dev, "cannot attach to SMMU, is it on the same bus?\n");
@@ -1138,7 +1170,7 @@ static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev)
1138 * Sanity check the domain. We don't currently support domains 1170 * Sanity check the domain. We don't currently support domains
1139 * that cross between different SMMU chains. 1171 * that cross between different SMMU chains.
1140 */ 1172 */
1141 mutex_lock(&smmu_domain->lock); 1173 spin_lock_irqsave(&smmu_domain->lock, flags);
1142 if (!smmu_domain->leaf_smmu) { 1174 if (!smmu_domain->leaf_smmu) {
1143 /* Now that we have a master, we can finalise the domain */ 1175 /* Now that we have a master, we can finalise the domain */
1144 ret = arm_smmu_init_domain_context(domain, dev); 1176 ret = arm_smmu_init_domain_context(domain, dev);
@@ -1153,7 +1185,7 @@ static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev)
1153 dev_name(device_smmu->dev)); 1185 dev_name(device_smmu->dev));
1154 goto err_unlock; 1186 goto err_unlock;
1155 } 1187 }
1156 mutex_unlock(&smmu_domain->lock); 1188 spin_unlock_irqrestore(&smmu_domain->lock, flags);
1157 1189
1158 /* Looks ok, so add the device to the domain */ 1190 /* Looks ok, so add the device to the domain */
1159 master = find_smmu_master(smmu_domain->leaf_smmu, dev->of_node); 1191 master = find_smmu_master(smmu_domain->leaf_smmu, dev->of_node);
@@ -1163,7 +1195,7 @@ static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev)
1163 return arm_smmu_domain_add_master(smmu_domain, master); 1195 return arm_smmu_domain_add_master(smmu_domain, master);
1164 1196
1165err_unlock: 1197err_unlock:
1166 mutex_unlock(&smmu_domain->lock); 1198 spin_unlock_irqrestore(&smmu_domain->lock, flags);
1167 return ret; 1199 return ret;
1168} 1200}
1169 1201
@@ -1177,23 +1209,6 @@ static void arm_smmu_detach_dev(struct iommu_domain *domain, struct device *dev)
1177 arm_smmu_domain_remove_master(smmu_domain, master); 1209 arm_smmu_domain_remove_master(smmu_domain, master);
1178} 1210}
1179 1211
1180static void arm_smmu_flush_pgtable(struct arm_smmu_device *smmu, void *addr,
1181 size_t size)
1182{
1183 unsigned long offset = (unsigned long)addr & ~PAGE_MASK;
1184
1185 /*
1186 * If the SMMU can't walk tables in the CPU caches, treat them
1187 * like non-coherent DMA since we need to flush the new entries
1188 * all the way out to memory. There's no possibility of recursion
1189 * here as the SMMU table walker will not be wired through another
1190 * SMMU.
1191 */
1192 if (!(smmu->features & ARM_SMMU_FEAT_COHERENT_WALK))
1193 dma_map_page(smmu->dev, virt_to_page(addr), offset, size,
1194 DMA_TO_DEVICE);
1195}
1196
1197static bool arm_smmu_pte_is_contiguous_range(unsigned long addr, 1212static bool arm_smmu_pte_is_contiguous_range(unsigned long addr,
1198 unsigned long end) 1213 unsigned long end)
1199{ 1214{
@@ -1210,12 +1225,11 @@ static int arm_smmu_alloc_init_pte(struct arm_smmu_device *smmu, pmd_t *pmd,
1210 1225
1211 if (pmd_none(*pmd)) { 1226 if (pmd_none(*pmd)) {
1212 /* Allocate a new set of tables */ 1227 /* Allocate a new set of tables */
1213 pgtable_t table = alloc_page(PGALLOC_GFP); 1228 pgtable_t table = alloc_page(GFP_ATOMIC|__GFP_ZERO);
1214 if (!table) 1229 if (!table)
1215 return -ENOMEM; 1230 return -ENOMEM;
1216 1231
1217 arm_smmu_flush_pgtable(smmu, page_address(table), 1232 arm_smmu_flush_pgtable(smmu, page_address(table), PAGE_SIZE);
1218 ARM_SMMU_PTE_HWTABLE_SIZE);
1219 if (!pgtable_page_ctor(table)) { 1233 if (!pgtable_page_ctor(table)) {
1220 __free_page(table); 1234 __free_page(table);
1221 return -ENOMEM; 1235 return -ENOMEM;
@@ -1317,9 +1331,15 @@ static int arm_smmu_alloc_init_pmd(struct arm_smmu_device *smmu, pud_t *pud,
1317 1331
1318#ifndef __PAGETABLE_PMD_FOLDED 1332#ifndef __PAGETABLE_PMD_FOLDED
1319 if (pud_none(*pud)) { 1333 if (pud_none(*pud)) {
1320 pmd = pmd_alloc_one(NULL, addr); 1334 pmd = (pmd_t *)get_zeroed_page(GFP_ATOMIC);
1321 if (!pmd) 1335 if (!pmd)
1322 return -ENOMEM; 1336 return -ENOMEM;
1337
1338 arm_smmu_flush_pgtable(smmu, pmd, PAGE_SIZE);
1339 pud_populate(NULL, pud, pmd);
1340 arm_smmu_flush_pgtable(smmu, pud, sizeof(*pud));
1341
1342 pmd += pmd_index(addr);
1323 } else 1343 } else
1324#endif 1344#endif
1325 pmd = pmd_offset(pud, addr); 1345 pmd = pmd_offset(pud, addr);
@@ -1328,8 +1348,6 @@ static int arm_smmu_alloc_init_pmd(struct arm_smmu_device *smmu, pud_t *pud,
1328 next = pmd_addr_end(addr, end); 1348 next = pmd_addr_end(addr, end);
1329 ret = arm_smmu_alloc_init_pte(smmu, pmd, addr, end, pfn, 1349 ret = arm_smmu_alloc_init_pte(smmu, pmd, addr, end, pfn,
1330 flags, stage); 1350 flags, stage);
1331 pud_populate(NULL, pud, pmd);
1332 arm_smmu_flush_pgtable(smmu, pud, sizeof(*pud));
1333 phys += next - addr; 1351 phys += next - addr;
1334 } while (pmd++, addr = next, addr < end); 1352 } while (pmd++, addr = next, addr < end);
1335 1353
@@ -1346,9 +1364,15 @@ static int arm_smmu_alloc_init_pud(struct arm_smmu_device *smmu, pgd_t *pgd,
1346 1364
1347#ifndef __PAGETABLE_PUD_FOLDED 1365#ifndef __PAGETABLE_PUD_FOLDED
1348 if (pgd_none(*pgd)) { 1366 if (pgd_none(*pgd)) {
1349 pud = pud_alloc_one(NULL, addr); 1367 pud = (pud_t *)get_zeroed_page(GFP_ATOMIC);
1350 if (!pud) 1368 if (!pud)
1351 return -ENOMEM; 1369 return -ENOMEM;
1370
1371 arm_smmu_flush_pgtable(smmu, pud, PAGE_SIZE);
1372 pgd_populate(NULL, pgd, pud);
1373 arm_smmu_flush_pgtable(smmu, pgd, sizeof(*pgd));
1374
1375 pud += pud_index(addr);
1352 } else 1376 } else
1353#endif 1377#endif
1354 pud = pud_offset(pgd, addr); 1378 pud = pud_offset(pgd, addr);
@@ -1357,8 +1381,6 @@ static int arm_smmu_alloc_init_pud(struct arm_smmu_device *smmu, pgd_t *pgd,
1357 next = pud_addr_end(addr, end); 1381 next = pud_addr_end(addr, end);
1358 ret = arm_smmu_alloc_init_pmd(smmu, pud, addr, next, phys, 1382 ret = arm_smmu_alloc_init_pmd(smmu, pud, addr, next, phys,
1359 flags, stage); 1383 flags, stage);
1360 pgd_populate(NULL, pud, pgd);
1361 arm_smmu_flush_pgtable(smmu, pgd, sizeof(*pgd));
1362 phys += next - addr; 1384 phys += next - addr;
1363 } while (pud++, addr = next, addr < end); 1385 } while (pud++, addr = next, addr < end);
1364 1386
@@ -1375,6 +1397,7 @@ static int arm_smmu_handle_mapping(struct arm_smmu_domain *smmu_domain,
1375 struct arm_smmu_cfg *root_cfg = &smmu_domain->root_cfg; 1397 struct arm_smmu_cfg *root_cfg = &smmu_domain->root_cfg;
1376 pgd_t *pgd = root_cfg->pgd; 1398 pgd_t *pgd = root_cfg->pgd;
1377 struct arm_smmu_device *smmu = root_cfg->smmu; 1399 struct arm_smmu_device *smmu = root_cfg->smmu;
1400 unsigned long irqflags;
1378 1401
1379 if (root_cfg->cbar == CBAR_TYPE_S2_TRANS) { 1402 if (root_cfg->cbar == CBAR_TYPE_S2_TRANS) {
1380 stage = 2; 1403 stage = 2;
@@ -1397,7 +1420,7 @@ static int arm_smmu_handle_mapping(struct arm_smmu_domain *smmu_domain,
1397 if (paddr & ~output_mask) 1420 if (paddr & ~output_mask)
1398 return -ERANGE; 1421 return -ERANGE;
1399 1422
1400 mutex_lock(&smmu_domain->lock); 1423 spin_lock_irqsave(&smmu_domain->lock, irqflags);
1401 pgd += pgd_index(iova); 1424 pgd += pgd_index(iova);
1402 end = iova + size; 1425 end = iova + size;
1403 do { 1426 do {
@@ -1413,11 +1436,7 @@ static int arm_smmu_handle_mapping(struct arm_smmu_domain *smmu_domain,
1413 } while (pgd++, iova != end); 1436 } while (pgd++, iova != end);
1414 1437
1415out_unlock: 1438out_unlock:
1416 mutex_unlock(&smmu_domain->lock); 1439 spin_unlock_irqrestore(&smmu_domain->lock, irqflags);
1417
1418 /* Ensure new page tables are visible to the hardware walker */
1419 if (smmu->features & ARM_SMMU_FEAT_COHERENT_WALK)
1420 dsb();
1421 1440
1422 return ret; 1441 return ret;
1423} 1442}
@@ -1987,8 +2006,10 @@ static int __init arm_smmu_init(void)
1987 if (!iommu_present(&platform_bus_type)) 2006 if (!iommu_present(&platform_bus_type))
1988 bus_set_iommu(&platform_bus_type, &arm_smmu_ops); 2007 bus_set_iommu(&platform_bus_type, &arm_smmu_ops);
1989 2008
2009#ifdef CONFIG_ARM_AMBA
1990 if (!iommu_present(&amba_bustype)) 2010 if (!iommu_present(&amba_bustype))
1991 bus_set_iommu(&amba_bustype, &arm_smmu_ops); 2011 bus_set_iommu(&amba_bustype, &arm_smmu_ops);
2012#endif
1992 2013
1993 return 0; 2014 return 0;
1994} 2015}
diff --git a/drivers/iommu/omap-iommu-debug.c b/drivers/iommu/omap-iommu-debug.c
index d97fbe4fb9b1..80fffba7f12d 100644
--- a/drivers/iommu/omap-iommu-debug.c
+++ b/drivers/iommu/omap-iommu-debug.c
@@ -354,8 +354,8 @@ DEBUG_FOPS(mem);
354 return -ENOMEM; \ 354 return -ENOMEM; \
355 } 355 }
356 356
357#define DEBUG_ADD_FILE(name) __DEBUG_ADD_FILE(name, 600) 357#define DEBUG_ADD_FILE(name) __DEBUG_ADD_FILE(name, 0600)
358#define DEBUG_ADD_FILE_RO(name) __DEBUG_ADD_FILE(name, 400) 358#define DEBUG_ADD_FILE_RO(name) __DEBUG_ADD_FILE(name, 0400)
359 359
360static int iommu_debug_register(struct device *dev, void *data) 360static int iommu_debug_register(struct device *dev, void *data)
361{ 361{
diff --git a/drivers/irqchip/irq-metag-ext.c b/drivers/irqchip/irq-metag-ext.c
index 92c41ab4dbfd..2cb474ad8809 100644
--- a/drivers/irqchip/irq-metag-ext.c
+++ b/drivers/irqchip/irq-metag-ext.c
@@ -515,7 +515,7 @@ static int meta_intc_set_affinity(struct irq_data *data,
515 * one cpu (the interrupt code doesn't support it), so we just 515 * one cpu (the interrupt code doesn't support it), so we just
516 * pick the first cpu we find in 'cpumask'. 516 * pick the first cpu we find in 'cpumask'.
517 */ 517 */
518 cpu = cpumask_any(cpumask); 518 cpu = cpumask_any_and(cpumask, cpu_online_mask);
519 thread = cpu_2_hwthread_id[cpu]; 519 thread = cpu_2_hwthread_id[cpu];
520 520
521 metag_out32(TBI_TRIG_VEC(TBID_SIGNUM_TR2(thread)), vec_addr); 521 metag_out32(TBI_TRIG_VEC(TBID_SIGNUM_TR2(thread)), vec_addr);
diff --git a/drivers/irqchip/irq-metag.c b/drivers/irqchip/irq-metag.c
index 8e94d7a3b20d..c16c186d97d3 100644
--- a/drivers/irqchip/irq-metag.c
+++ b/drivers/irqchip/irq-metag.c
@@ -201,7 +201,7 @@ static int metag_internal_irq_set_affinity(struct irq_data *data,
201 * one cpu (the interrupt code doesn't support it), so we just 201 * one cpu (the interrupt code doesn't support it), so we just
202 * pick the first cpu we find in 'cpumask'. 202 * pick the first cpu we find in 'cpumask'.
203 */ 203 */
204 cpu = cpumask_any(cpumask); 204 cpu = cpumask_any_and(cpumask, cpu_online_mask);
205 thread = cpu_2_hwthread_id[cpu]; 205 thread = cpu_2_hwthread_id[cpu];
206 206
207 metag_out32(TBI_TRIG_VEC(TBID_SIGNUM_TR1(thread)), 207 metag_out32(TBI_TRIG_VEC(TBID_SIGNUM_TR1(thread)),
diff --git a/drivers/irqchip/irq-orion.c b/drivers/irqchip/irq-orion.c
index e51d40031884..8e41be62812e 100644
--- a/drivers/irqchip/irq-orion.c
+++ b/drivers/irqchip/irq-orion.c
@@ -111,7 +111,8 @@ IRQCHIP_DECLARE(orion_intc, "marvell,orion-intc", orion_irq_init);
111static void orion_bridge_irq_handler(unsigned int irq, struct irq_desc *desc) 111static void orion_bridge_irq_handler(unsigned int irq, struct irq_desc *desc)
112{ 112{
113 struct irq_domain *d = irq_get_handler_data(irq); 113 struct irq_domain *d = irq_get_handler_data(irq);
114 struct irq_chip_generic *gc = irq_get_domain_generic_chip(d, irq); 114
115 struct irq_chip_generic *gc = irq_get_domain_generic_chip(d, 0);
115 u32 stat = readl_relaxed(gc->reg_base + ORION_BRIDGE_IRQ_CAUSE) & 116 u32 stat = readl_relaxed(gc->reg_base + ORION_BRIDGE_IRQ_CAUSE) &
116 gc->mask_cache; 117 gc->mask_cache;
117 118
@@ -123,6 +124,19 @@ static void orion_bridge_irq_handler(unsigned int irq, struct irq_desc *desc)
123 } 124 }
124} 125}
125 126
127/*
128 * Bridge IRQ_CAUSE is asserted regardless of IRQ_MASK register.
129 * To avoid interrupt events on stale irqs, we clear them before unmask.
130 */
131static unsigned int orion_bridge_irq_startup(struct irq_data *d)
132{
133 struct irq_chip_type *ct = irq_data_get_chip_type(d);
134
135 ct->chip.irq_ack(d);
136 ct->chip.irq_unmask(d);
137 return 0;
138}
139
126static int __init orion_bridge_irq_init(struct device_node *np, 140static int __init orion_bridge_irq_init(struct device_node *np,
127 struct device_node *parent) 141 struct device_node *parent)
128{ 142{
@@ -143,7 +157,7 @@ static int __init orion_bridge_irq_init(struct device_node *np,
143 } 157 }
144 158
145 ret = irq_alloc_domain_generic_chips(domain, nrirqs, 1, np->name, 159 ret = irq_alloc_domain_generic_chips(domain, nrirqs, 1, np->name,
146 handle_level_irq, clr, 0, IRQ_GC_INIT_MASK_CACHE); 160 handle_edge_irq, clr, 0, IRQ_GC_INIT_MASK_CACHE);
147 if (ret) { 161 if (ret) {
148 pr_err("%s: unable to alloc irq domain gc\n", np->name); 162 pr_err("%s: unable to alloc irq domain gc\n", np->name);
149 return ret; 163 return ret;
@@ -176,12 +190,14 @@ static int __init orion_bridge_irq_init(struct device_node *np,
176 190
177 gc->chip_types[0].regs.ack = ORION_BRIDGE_IRQ_CAUSE; 191 gc->chip_types[0].regs.ack = ORION_BRIDGE_IRQ_CAUSE;
178 gc->chip_types[0].regs.mask = ORION_BRIDGE_IRQ_MASK; 192 gc->chip_types[0].regs.mask = ORION_BRIDGE_IRQ_MASK;
193 gc->chip_types[0].chip.irq_startup = orion_bridge_irq_startup;
179 gc->chip_types[0].chip.irq_ack = irq_gc_ack_clr_bit; 194 gc->chip_types[0].chip.irq_ack = irq_gc_ack_clr_bit;
180 gc->chip_types[0].chip.irq_mask = irq_gc_mask_clr_bit; 195 gc->chip_types[0].chip.irq_mask = irq_gc_mask_clr_bit;
181 gc->chip_types[0].chip.irq_unmask = irq_gc_mask_set_bit; 196 gc->chip_types[0].chip.irq_unmask = irq_gc_mask_set_bit;
182 197
183 /* mask all interrupts */ 198 /* mask and clear all interrupts */
184 writel(0, gc->reg_base + ORION_BRIDGE_IRQ_MASK); 199 writel(0, gc->reg_base + ORION_BRIDGE_IRQ_MASK);
200 writel(0, gc->reg_base + ORION_BRIDGE_IRQ_CAUSE);
185 201
186 irq_set_handler_data(irq, domain); 202 irq_set_handler_data(irq, domain);
187 irq_set_chained_handler(irq, orion_bridge_irq_handler); 203 irq_set_chained_handler(irq, orion_bridge_irq_handler);
diff --git a/drivers/md/dm-cache-target.c b/drivers/md/dm-cache-target.c
index ffd472e015ca..1af70145fab9 100644
--- a/drivers/md/dm-cache-target.c
+++ b/drivers/md/dm-cache-target.c
@@ -289,6 +289,7 @@ struct per_bio_data {
289 bool tick:1; 289 bool tick:1;
290 unsigned req_nr:2; 290 unsigned req_nr:2;
291 struct dm_deferred_entry *all_io_entry; 291 struct dm_deferred_entry *all_io_entry;
292 struct dm_hook_info hook_info;
292 293
293 /* 294 /*
294 * writethrough fields. These MUST remain at the end of this 295 * writethrough fields. These MUST remain at the end of this
@@ -297,7 +298,6 @@ struct per_bio_data {
297 */ 298 */
298 struct cache *cache; 299 struct cache *cache;
299 dm_cblock_t cblock; 300 dm_cblock_t cblock;
300 struct dm_hook_info hook_info;
301 struct dm_bio_details bio_details; 301 struct dm_bio_details bio_details;
302}; 302};
303 303
@@ -671,15 +671,16 @@ static void remap_to_cache(struct cache *cache, struct bio *bio,
671 dm_cblock_t cblock) 671 dm_cblock_t cblock)
672{ 672{
673 sector_t bi_sector = bio->bi_iter.bi_sector; 673 sector_t bi_sector = bio->bi_iter.bi_sector;
674 sector_t block = from_cblock(cblock);
674 675
675 bio->bi_bdev = cache->cache_dev->bdev; 676 bio->bi_bdev = cache->cache_dev->bdev;
676 if (!block_size_is_power_of_two(cache)) 677 if (!block_size_is_power_of_two(cache))
677 bio->bi_iter.bi_sector = 678 bio->bi_iter.bi_sector =
678 (from_cblock(cblock) * cache->sectors_per_block) + 679 (block * cache->sectors_per_block) +
679 sector_div(bi_sector, cache->sectors_per_block); 680 sector_div(bi_sector, cache->sectors_per_block);
680 else 681 else
681 bio->bi_iter.bi_sector = 682 bio->bi_iter.bi_sector =
682 (from_cblock(cblock) << cache->sectors_per_block_shift) | 683 (block << cache->sectors_per_block_shift) |
683 (bi_sector & (cache->sectors_per_block - 1)); 684 (bi_sector & (cache->sectors_per_block - 1));
684} 685}
685 686
@@ -1010,13 +1011,15 @@ static void overwrite_endio(struct bio *bio, int err)
1010 struct per_bio_data *pb = get_per_bio_data(bio, pb_data_size); 1011 struct per_bio_data *pb = get_per_bio_data(bio, pb_data_size);
1011 unsigned long flags; 1012 unsigned long flags;
1012 1013
1014 dm_unhook_bio(&pb->hook_info, bio);
1015
1013 if (err) 1016 if (err)
1014 mg->err = true; 1017 mg->err = true;
1015 1018
1019 mg->requeue_holder = false;
1020
1016 spin_lock_irqsave(&cache->lock, flags); 1021 spin_lock_irqsave(&cache->lock, flags);
1017 list_add_tail(&mg->list, &cache->completed_migrations); 1022 list_add_tail(&mg->list, &cache->completed_migrations);
1018 dm_unhook_bio(&pb->hook_info, bio);
1019 mg->requeue_holder = false;
1020 spin_unlock_irqrestore(&cache->lock, flags); 1023 spin_unlock_irqrestore(&cache->lock, flags);
1021 1024
1022 wake_worker(cache); 1025 wake_worker(cache);
diff --git a/drivers/md/dm-io.c b/drivers/md/dm-io.c
index b2b8a10e8427..3842ac738f98 100644
--- a/drivers/md/dm-io.c
+++ b/drivers/md/dm-io.c
@@ -201,29 +201,28 @@ static void list_dp_init(struct dpages *dp, struct page_list *pl, unsigned offse
201/* 201/*
202 * Functions for getting the pages from a bvec. 202 * Functions for getting the pages from a bvec.
203 */ 203 */
204static void bio_get_page(struct dpages *dp, 204static void bio_get_page(struct dpages *dp, struct page **p,
205 struct page **p, unsigned long *len, unsigned *offset) 205 unsigned long *len, unsigned *offset)
206{ 206{
207 struct bio *bio = dp->context_ptr; 207 struct bio_vec *bvec = dp->context_ptr;
208 struct bio_vec bvec = bio_iovec(bio); 208 *p = bvec->bv_page;
209 *p = bvec.bv_page; 209 *len = bvec->bv_len - dp->context_u;
210 *len = bvec.bv_len; 210 *offset = bvec->bv_offset + dp->context_u;
211 *offset = bvec.bv_offset;
212} 211}
213 212
214static void bio_next_page(struct dpages *dp) 213static void bio_next_page(struct dpages *dp)
215{ 214{
216 struct bio *bio = dp->context_ptr; 215 struct bio_vec *bvec = dp->context_ptr;
217 struct bio_vec bvec = bio_iovec(bio); 216 dp->context_ptr = bvec + 1;
218 217 dp->context_u = 0;
219 bio_advance(bio, bvec.bv_len);
220} 218}
221 219
222static void bio_dp_init(struct dpages *dp, struct bio *bio) 220static void bio_dp_init(struct dpages *dp, struct bio *bio)
223{ 221{
224 dp->get_page = bio_get_page; 222 dp->get_page = bio_get_page;
225 dp->next_page = bio_next_page; 223 dp->next_page = bio_next_page;
226 dp->context_ptr = bio; 224 dp->context_ptr = __bvec_iter_bvec(bio->bi_io_vec, bio->bi_iter);
225 dp->context_u = bio->bi_iter.bi_bvec_done;
227} 226}
228 227
229/* 228/*
diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c
index 6eb9dc9ef8f3..422a9fdeb53e 100644
--- a/drivers/md/dm-mpath.c
+++ b/drivers/md/dm-mpath.c
@@ -1626,8 +1626,11 @@ static int multipath_ioctl(struct dm_target *ti, unsigned int cmd,
1626 /* 1626 /*
1627 * Only pass ioctls through if the device sizes match exactly. 1627 * Only pass ioctls through if the device sizes match exactly.
1628 */ 1628 */
1629 if (!r && ti->len != i_size_read(bdev->bd_inode) >> SECTOR_SHIFT) 1629 if (!bdev || ti->len != i_size_read(bdev->bd_inode) >> SECTOR_SHIFT) {
1630 r = scsi_verify_blk_ioctl(NULL, cmd); 1630 int err = scsi_verify_blk_ioctl(NULL, cmd);
1631 if (err)
1632 r = err;
1633 }
1631 1634
1632 if (r == -ENOTCONN && !fatal_signal_pending(current)) 1635 if (r == -ENOTCONN && !fatal_signal_pending(current))
1633 queue_work(kmultipathd, &m->process_queued_ios); 1636 queue_work(kmultipathd, &m->process_queued_ios);
diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
index f284e0bfb25f..7dfdb5c746d6 100644
--- a/drivers/md/dm-raid1.c
+++ b/drivers/md/dm-raid1.c
@@ -1244,6 +1244,9 @@ static int mirror_end_io(struct dm_target *ti, struct bio *bio, int error)
1244 1244
1245 dm_bio_restore(bd, bio); 1245 dm_bio_restore(bd, bio);
1246 bio_record->details.bi_bdev = NULL; 1246 bio_record->details.bi_bdev = NULL;
1247
1248 atomic_inc(&bio->bi_remaining);
1249
1247 queue_bio(ms, bio, rw); 1250 queue_bio(ms, bio, rw);
1248 return DM_ENDIO_INCOMPLETE; 1251 return DM_ENDIO_INCOMPLETE;
1249 } 1252 }
diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c
index 7da347665552..baa87ff12816 100644
--- a/drivers/md/dm-thin-metadata.c
+++ b/drivers/md/dm-thin-metadata.c
@@ -483,7 +483,7 @@ static int __write_initial_superblock(struct dm_pool_metadata *pmd)
483 483
484 disk_super->data_mapping_root = cpu_to_le64(pmd->root); 484 disk_super->data_mapping_root = cpu_to_le64(pmd->root);
485 disk_super->device_details_root = cpu_to_le64(pmd->details_root); 485 disk_super->device_details_root = cpu_to_le64(pmd->details_root);
486 disk_super->metadata_block_size = cpu_to_le32(THIN_METADATA_BLOCK_SIZE >> SECTOR_SHIFT); 486 disk_super->metadata_block_size = cpu_to_le32(THIN_METADATA_BLOCK_SIZE);
487 disk_super->metadata_nr_blocks = cpu_to_le64(bdev_size >> SECTOR_TO_BLOCK_SHIFT); 487 disk_super->metadata_nr_blocks = cpu_to_le64(bdev_size >> SECTOR_TO_BLOCK_SHIFT);
488 disk_super->data_block_size = cpu_to_le32(pmd->data_block_size); 488 disk_super->data_block_size = cpu_to_le32(pmd->data_block_size);
489 489
@@ -651,7 +651,7 @@ static int __create_persistent_data_objects(struct dm_pool_metadata *pmd, bool f
651{ 651{
652 int r; 652 int r;
653 653
654 pmd->bm = dm_block_manager_create(pmd->bdev, THIN_METADATA_BLOCK_SIZE, 654 pmd->bm = dm_block_manager_create(pmd->bdev, THIN_METADATA_BLOCK_SIZE << SECTOR_SHIFT,
655 THIN_METADATA_CACHE_SIZE, 655 THIN_METADATA_CACHE_SIZE,
656 THIN_MAX_CONCURRENT_LOCKS); 656 THIN_MAX_CONCURRENT_LOCKS);
657 if (IS_ERR(pmd->bm)) { 657 if (IS_ERR(pmd->bm)) {
@@ -1489,6 +1489,23 @@ bool dm_thin_changed_this_transaction(struct dm_thin_device *td)
1489 return r; 1489 return r;
1490} 1490}
1491 1491
1492bool dm_pool_changed_this_transaction(struct dm_pool_metadata *pmd)
1493{
1494 bool r = false;
1495 struct dm_thin_device *td, *tmp;
1496
1497 down_read(&pmd->root_lock);
1498 list_for_each_entry_safe(td, tmp, &pmd->thin_devices, list) {
1499 if (td->changed) {
1500 r = td->changed;
1501 break;
1502 }
1503 }
1504 up_read(&pmd->root_lock);
1505
1506 return r;
1507}
1508
1492bool dm_thin_aborted_changes(struct dm_thin_device *td) 1509bool dm_thin_aborted_changes(struct dm_thin_device *td)
1493{ 1510{
1494 bool r; 1511 bool r;
diff --git a/drivers/md/dm-thin-metadata.h b/drivers/md/dm-thin-metadata.h
index 9a368567632f..82ea384d36ff 100644
--- a/drivers/md/dm-thin-metadata.h
+++ b/drivers/md/dm-thin-metadata.h
@@ -9,16 +9,14 @@
9 9
10#include "persistent-data/dm-block-manager.h" 10#include "persistent-data/dm-block-manager.h"
11#include "persistent-data/dm-space-map.h" 11#include "persistent-data/dm-space-map.h"
12#include "persistent-data/dm-space-map-metadata.h"
12 13
13#define THIN_METADATA_BLOCK_SIZE 4096 14#define THIN_METADATA_BLOCK_SIZE DM_SM_METADATA_BLOCK_SIZE
14 15
15/* 16/*
16 * The metadata device is currently limited in size. 17 * The metadata device is currently limited in size.
17 *
18 * We have one block of index, which can hold 255 index entries. Each
19 * index entry contains allocation info about 16k metadata blocks.
20 */ 18 */
21#define THIN_METADATA_MAX_SECTORS (255 * (1 << 14) * (THIN_METADATA_BLOCK_SIZE / (1 << SECTOR_SHIFT))) 19#define THIN_METADATA_MAX_SECTORS DM_SM_METADATA_MAX_SECTORS
22 20
23/* 21/*
24 * A metadata device larger than 16GB triggers a warning. 22 * A metadata device larger than 16GB triggers a warning.
@@ -161,6 +159,8 @@ int dm_thin_remove_block(struct dm_thin_device *td, dm_block_t block);
161 */ 159 */
162bool dm_thin_changed_this_transaction(struct dm_thin_device *td); 160bool dm_thin_changed_this_transaction(struct dm_thin_device *td);
163 161
162bool dm_pool_changed_this_transaction(struct dm_pool_metadata *pmd);
163
164bool dm_thin_aborted_changes(struct dm_thin_device *td); 164bool dm_thin_aborted_changes(struct dm_thin_device *td);
165 165
166int dm_thin_get_highest_mapped_block(struct dm_thin_device *td, 166int dm_thin_get_highest_mapped_block(struct dm_thin_device *td,
diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c
index faaf944597ab..7e84baccf0ad 100644
--- a/drivers/md/dm-thin.c
+++ b/drivers/md/dm-thin.c
@@ -1357,7 +1357,8 @@ static void process_deferred_bios(struct pool *pool)
1357 bio_list_init(&pool->deferred_flush_bios); 1357 bio_list_init(&pool->deferred_flush_bios);
1358 spin_unlock_irqrestore(&pool->lock, flags); 1358 spin_unlock_irqrestore(&pool->lock, flags);
1359 1359
1360 if (bio_list_empty(&bios) && !need_commit_due_to_time(pool)) 1360 if (bio_list_empty(&bios) &&
1361 !(dm_pool_changed_this_transaction(pool->pmd) && need_commit_due_to_time(pool)))
1361 return; 1362 return;
1362 1363
1363 if (commit(pool)) { 1364 if (commit(pool)) {
@@ -1999,16 +2000,27 @@ static void metadata_low_callback(void *context)
1999 dm_table_event(pool->ti->table); 2000 dm_table_event(pool->ti->table);
2000} 2001}
2001 2002
2002static sector_t get_metadata_dev_size(struct block_device *bdev) 2003static sector_t get_dev_size(struct block_device *bdev)
2004{
2005 return i_size_read(bdev->bd_inode) >> SECTOR_SHIFT;
2006}
2007
2008static void warn_if_metadata_device_too_big(struct block_device *bdev)
2003{ 2009{
2004 sector_t metadata_dev_size = i_size_read(bdev->bd_inode) >> SECTOR_SHIFT; 2010 sector_t metadata_dev_size = get_dev_size(bdev);
2005 char buffer[BDEVNAME_SIZE]; 2011 char buffer[BDEVNAME_SIZE];
2006 2012
2007 if (metadata_dev_size > THIN_METADATA_MAX_SECTORS_WARNING) { 2013 if (metadata_dev_size > THIN_METADATA_MAX_SECTORS_WARNING)
2008 DMWARN("Metadata device %s is larger than %u sectors: excess space will not be used.", 2014 DMWARN("Metadata device %s is larger than %u sectors: excess space will not be used.",
2009 bdevname(bdev, buffer), THIN_METADATA_MAX_SECTORS); 2015 bdevname(bdev, buffer), THIN_METADATA_MAX_SECTORS);
2010 metadata_dev_size = THIN_METADATA_MAX_SECTORS_WARNING; 2016}
2011 } 2017
2018static sector_t get_metadata_dev_size(struct block_device *bdev)
2019{
2020 sector_t metadata_dev_size = get_dev_size(bdev);
2021
2022 if (metadata_dev_size > THIN_METADATA_MAX_SECTORS)
2023 metadata_dev_size = THIN_METADATA_MAX_SECTORS;
2012 2024
2013 return metadata_dev_size; 2025 return metadata_dev_size;
2014} 2026}
@@ -2017,7 +2029,7 @@ static dm_block_t get_metadata_dev_size_in_blocks(struct block_device *bdev)
2017{ 2029{
2018 sector_t metadata_dev_size = get_metadata_dev_size(bdev); 2030 sector_t metadata_dev_size = get_metadata_dev_size(bdev);
2019 2031
2020 sector_div(metadata_dev_size, THIN_METADATA_BLOCK_SIZE >> SECTOR_SHIFT); 2032 sector_div(metadata_dev_size, THIN_METADATA_BLOCK_SIZE);
2021 2033
2022 return metadata_dev_size; 2034 return metadata_dev_size;
2023} 2035}
@@ -2095,12 +2107,7 @@ static int pool_ctr(struct dm_target *ti, unsigned argc, char **argv)
2095 ti->error = "Error opening metadata block device"; 2107 ti->error = "Error opening metadata block device";
2096 goto out_unlock; 2108 goto out_unlock;
2097 } 2109 }
2098 2110 warn_if_metadata_device_too_big(metadata_dev->bdev);
2099 /*
2100 * Run for the side-effect of possibly issuing a warning if the
2101 * device is too big.
2102 */
2103 (void) get_metadata_dev_size(metadata_dev->bdev);
2104 2111
2105 r = dm_get_device(ti, argv[1], FMODE_READ | FMODE_WRITE, &data_dev); 2112 r = dm_get_device(ti, argv[1], FMODE_READ | FMODE_WRITE, &data_dev);
2106 if (r) { 2113 if (r) {
@@ -2287,6 +2294,7 @@ static int maybe_resize_metadata_dev(struct dm_target *ti, bool *need_commit)
2287 return -EINVAL; 2294 return -EINVAL;
2288 2295
2289 } else if (metadata_dev_size > sb_metadata_dev_size) { 2296 } else if (metadata_dev_size > sb_metadata_dev_size) {
2297 warn_if_metadata_device_too_big(pool->md_dev);
2290 DMINFO("%s: growing the metadata device from %llu to %llu blocks", 2298 DMINFO("%s: growing the metadata device from %llu to %llu blocks",
2291 dm_device_name(pool->pool_md), 2299 dm_device_name(pool->pool_md),
2292 sb_metadata_dev_size, metadata_dev_size); 2300 sb_metadata_dev_size, metadata_dev_size);
@@ -2894,6 +2902,7 @@ static int thin_ctr(struct dm_target *ti, unsigned argc, char **argv)
2894 2902
2895 if (get_pool_mode(tc->pool) == PM_FAIL) { 2903 if (get_pool_mode(tc->pool) == PM_FAIL) {
2896 ti->error = "Couldn't open thin device, Pool is in fail mode"; 2904 ti->error = "Couldn't open thin device, Pool is in fail mode";
2905 r = -EINVAL;
2897 goto bad_thin_open; 2906 goto bad_thin_open;
2898 } 2907 }
2899 2908
@@ -2905,7 +2914,7 @@ static int thin_ctr(struct dm_target *ti, unsigned argc, char **argv)
2905 2914
2906 r = dm_set_target_max_io_len(ti, tc->pool->sectors_per_block); 2915 r = dm_set_target_max_io_len(ti, tc->pool->sectors_per_block);
2907 if (r) 2916 if (r)
2908 goto bad_thin_open; 2917 goto bad_target_max_io_len;
2909 2918
2910 ti->num_flush_bios = 1; 2919 ti->num_flush_bios = 1;
2911 ti->flush_supported = true; 2920 ti->flush_supported = true;
@@ -2926,6 +2935,8 @@ static int thin_ctr(struct dm_target *ti, unsigned argc, char **argv)
2926 2935
2927 return 0; 2936 return 0;
2928 2937
2938bad_target_max_io_len:
2939 dm_pool_close_thin_device(tc->td);
2929bad_thin_open: 2940bad_thin_open:
2930 __pool_dec(tc->pool); 2941 __pool_dec(tc->pool);
2931bad_pool_lookup: 2942bad_pool_lookup:
diff --git a/drivers/md/persistent-data/dm-space-map-metadata.c b/drivers/md/persistent-data/dm-space-map-metadata.c
index 536782e3bcb7..e9bdd462f4f5 100644
--- a/drivers/md/persistent-data/dm-space-map-metadata.c
+++ b/drivers/md/persistent-data/dm-space-map-metadata.c
@@ -680,6 +680,8 @@ int dm_sm_metadata_create(struct dm_space_map *sm,
680 if (r) 680 if (r)
681 return r; 681 return r;
682 682
683 if (nr_blocks > DM_SM_METADATA_MAX_BLOCKS)
684 nr_blocks = DM_SM_METADATA_MAX_BLOCKS;
683 r = sm_ll_extend(&smm->ll, nr_blocks); 685 r = sm_ll_extend(&smm->ll, nr_blocks);
684 if (r) 686 if (r)
685 return r; 687 return r;
diff --git a/drivers/md/persistent-data/dm-space-map-metadata.h b/drivers/md/persistent-data/dm-space-map-metadata.h
index 39bba0801cf2..64df923974d8 100644
--- a/drivers/md/persistent-data/dm-space-map-metadata.h
+++ b/drivers/md/persistent-data/dm-space-map-metadata.h
@@ -9,6 +9,17 @@
9 9
10#include "dm-transaction-manager.h" 10#include "dm-transaction-manager.h"
11 11
12#define DM_SM_METADATA_BLOCK_SIZE (4096 >> SECTOR_SHIFT)
13
14/*
15 * The metadata device is currently limited in size.
16 *
17 * We have one block of index, which can hold 255 index entries. Each
18 * index entry contains allocation info about ~16k metadata blocks.
19 */
20#define DM_SM_METADATA_MAX_BLOCKS (255 * ((1 << 14) - 64))
21#define DM_SM_METADATA_MAX_SECTORS (DM_SM_METADATA_MAX_BLOCKS * DM_SM_METADATA_BLOCK_SIZE)
22
12/* 23/*
13 * Unfortunately we have to use two-phase construction due to the cycle 24 * Unfortunately we have to use two-phase construction due to the cycle
14 * between the tm and sm. 25 * between the tm and sm.
diff --git a/drivers/mfd/da9055-i2c.c b/drivers/mfd/da9055-i2c.c
index 13af7e50021e..8103e4362132 100644
--- a/drivers/mfd/da9055-i2c.c
+++ b/drivers/mfd/da9055-i2c.c
@@ -53,17 +53,25 @@ static int da9055_i2c_remove(struct i2c_client *i2c)
53 return 0; 53 return 0;
54} 54}
55 55
56/*
57 * DO NOT change the device Ids. The naming is intentionally specific as both
58 * the PMIC and CODEC parts of this chip are instantiated separately as I2C
59 * devices (both have configurable I2C addresses, and are to all intents and
60 * purposes separate). As a result there are specific DA9055 ids for PMIC
61 * and CODEC, which must be different to operate together.
62 */
56static struct i2c_device_id da9055_i2c_id[] = { 63static struct i2c_device_id da9055_i2c_id[] = {
57 {"da9055", 0}, 64 {"da9055-pmic", 0},
58 { } 65 { }
59}; 66};
67MODULE_DEVICE_TABLE(i2c, da9055_i2c_id);
60 68
61static struct i2c_driver da9055_i2c_driver = { 69static struct i2c_driver da9055_i2c_driver = {
62 .probe = da9055_i2c_probe, 70 .probe = da9055_i2c_probe,
63 .remove = da9055_i2c_remove, 71 .remove = da9055_i2c_remove,
64 .id_table = da9055_i2c_id, 72 .id_table = da9055_i2c_id,
65 .driver = { 73 .driver = {
66 .name = "da9055", 74 .name = "da9055-pmic",
67 .owner = THIS_MODULE, 75 .owner = THIS_MODULE,
68 }, 76 },
69}; 77};
diff --git a/drivers/mfd/max14577.c b/drivers/mfd/max14577.c
index ac514fb2b877..71aa14a6bfbb 100644
--- a/drivers/mfd/max14577.c
+++ b/drivers/mfd/max14577.c
@@ -173,6 +173,7 @@ static const struct i2c_device_id max14577_i2c_id[] = {
173}; 173};
174MODULE_DEVICE_TABLE(i2c, max14577_i2c_id); 174MODULE_DEVICE_TABLE(i2c, max14577_i2c_id);
175 175
176#ifdef CONFIG_PM_SLEEP
176static int max14577_suspend(struct device *dev) 177static int max14577_suspend(struct device *dev)
177{ 178{
178 struct i2c_client *i2c = container_of(dev, struct i2c_client, dev); 179 struct i2c_client *i2c = container_of(dev, struct i2c_client, dev);
@@ -208,6 +209,7 @@ static int max14577_resume(struct device *dev)
208 209
209 return 0; 210 return 0;
210} 211}
212#endif /* CONFIG_PM_SLEEP */
211 213
212static struct of_device_id max14577_dt_match[] = { 214static struct of_device_id max14577_dt_match[] = {
213 { .compatible = "maxim,max14577", }, 215 { .compatible = "maxim,max14577", },
diff --git a/drivers/mfd/max8997.c b/drivers/mfd/max8997.c
index be88a3bf7b85..5adede0fb04c 100644
--- a/drivers/mfd/max8997.c
+++ b/drivers/mfd/max8997.c
@@ -164,15 +164,15 @@ static struct max8997_platform_data *max8997_i2c_parse_dt_pdata(
164 return pd; 164 return pd;
165} 165}
166 166
167static inline int max8997_i2c_get_driver_data(struct i2c_client *i2c, 167static inline unsigned long max8997_i2c_get_driver_data(struct i2c_client *i2c,
168 const struct i2c_device_id *id) 168 const struct i2c_device_id *id)
169{ 169{
170 if (IS_ENABLED(CONFIG_OF) && i2c->dev.of_node) { 170 if (IS_ENABLED(CONFIG_OF) && i2c->dev.of_node) {
171 const struct of_device_id *match; 171 const struct of_device_id *match;
172 match = of_match_node(max8997_pmic_dt_match, i2c->dev.of_node); 172 match = of_match_node(max8997_pmic_dt_match, i2c->dev.of_node);
173 return (int)match->data; 173 return (unsigned long)match->data;
174 } 174 }
175 return (int)id->driver_data; 175 return id->driver_data;
176} 176}
177 177
178static int max8997_i2c_probe(struct i2c_client *i2c, 178static int max8997_i2c_probe(struct i2c_client *i2c,
diff --git a/drivers/mfd/max8998.c b/drivers/mfd/max8998.c
index 612ca404e150..5d5e186b5d8b 100644
--- a/drivers/mfd/max8998.c
+++ b/drivers/mfd/max8998.c
@@ -169,16 +169,16 @@ static struct max8998_platform_data *max8998_i2c_parse_dt_pdata(
169 return pd; 169 return pd;
170} 170}
171 171
172static inline int max8998_i2c_get_driver_data(struct i2c_client *i2c, 172static inline unsigned long max8998_i2c_get_driver_data(struct i2c_client *i2c,
173 const struct i2c_device_id *id) 173 const struct i2c_device_id *id)
174{ 174{
175 if (IS_ENABLED(CONFIG_OF) && i2c->dev.of_node) { 175 if (IS_ENABLED(CONFIG_OF) && i2c->dev.of_node) {
176 const struct of_device_id *match; 176 const struct of_device_id *match;
177 match = of_match_node(max8998_dt_match, i2c->dev.of_node); 177 match = of_match_node(max8998_dt_match, i2c->dev.of_node);
178 return (int)(long)match->data; 178 return (unsigned long)match->data;
179 } 179 }
180 180
181 return (int)id->driver_data; 181 return id->driver_data;
182} 182}
183 183
184static int max8998_i2c_probe(struct i2c_client *i2c, 184static int max8998_i2c_probe(struct i2c_client *i2c,
diff --git a/drivers/mfd/sec-core.c b/drivers/mfd/sec-core.c
index a139798b8065..714e2135210e 100644
--- a/drivers/mfd/sec-core.c
+++ b/drivers/mfd/sec-core.c
@@ -315,6 +315,7 @@ static int sec_pmic_remove(struct i2c_client *i2c)
315 return 0; 315 return 0;
316} 316}
317 317
318#ifdef CONFIG_PM_SLEEP
318static int sec_pmic_suspend(struct device *dev) 319static int sec_pmic_suspend(struct device *dev)
319{ 320{
320 struct i2c_client *i2c = container_of(dev, struct i2c_client, dev); 321 struct i2c_client *i2c = container_of(dev, struct i2c_client, dev);
@@ -349,6 +350,7 @@ static int sec_pmic_resume(struct device *dev)
349 350
350 return 0; 351 return 0;
351} 352}
353#endif /* CONFIG_PM_SLEEP */
352 354
353static SIMPLE_DEV_PM_OPS(sec_pmic_pm_ops, sec_pmic_suspend, sec_pmic_resume); 355static SIMPLE_DEV_PM_OPS(sec_pmic_pm_ops, sec_pmic_suspend, sec_pmic_resume);
354 356
diff --git a/drivers/mfd/tps65217.c b/drivers/mfd/tps65217.c
index 966cf65c5c36..3cc4c7084b92 100644
--- a/drivers/mfd/tps65217.c
+++ b/drivers/mfd/tps65217.c
@@ -158,7 +158,7 @@ static int tps65217_probe(struct i2c_client *client,
158{ 158{
159 struct tps65217 *tps; 159 struct tps65217 *tps;
160 unsigned int version; 160 unsigned int version;
161 unsigned int chip_id = ids->driver_data; 161 unsigned long chip_id = ids->driver_data;
162 const struct of_device_id *match; 162 const struct of_device_id *match;
163 bool status_off = false; 163 bool status_off = false;
164 int ret; 164 int ret;
@@ -170,7 +170,7 @@ static int tps65217_probe(struct i2c_client *client,
170 "Failed to find matching dt id\n"); 170 "Failed to find matching dt id\n");
171 return -EINVAL; 171 return -EINVAL;
172 } 172 }
173 chip_id = (unsigned int)(unsigned long)match->data; 173 chip_id = (unsigned long)match->data;
174 status_off = of_property_read_bool(client->dev.of_node, 174 status_off = of_property_read_bool(client->dev.of_node,
175 "ti,pmic-shutdown-controller"); 175 "ti,pmic-shutdown-controller");
176 } 176 }
diff --git a/drivers/mfd/wm8994-core.c b/drivers/mfd/wm8994-core.c
index ba04f1bc70eb..e6fab94e2c8a 100644
--- a/drivers/mfd/wm8994-core.c
+++ b/drivers/mfd/wm8994-core.c
@@ -636,7 +636,7 @@ static int wm8994_i2c_probe(struct i2c_client *i2c,
636 if (i2c->dev.of_node) { 636 if (i2c->dev.of_node) {
637 of_id = of_match_device(wm8994_of_match, &i2c->dev); 637 of_id = of_match_device(wm8994_of_match, &i2c->dev);
638 if (of_id) 638 if (of_id)
639 wm8994->type = (int)of_id->data; 639 wm8994->type = (enum wm8994_type)of_id->data;
640 } else { 640 } else {
641 wm8994->type = id->driver_data; 641 wm8994->type = id->driver_data;
642 } 642 }
diff --git a/drivers/misc/mei/client.c b/drivers/misc/mei/client.c
index 9b809cfc2899..89a557972d1b 100644
--- a/drivers/misc/mei/client.c
+++ b/drivers/misc/mei/client.c
@@ -666,7 +666,6 @@ int mei_cl_read_start(struct mei_cl *cl, size_t length)
666 goto err; 666 goto err;
667 667
668 cb->fop_type = MEI_FOP_READ; 668 cb->fop_type = MEI_FOP_READ;
669 cl->read_cb = cb;
670 if (dev->hbuf_is_ready) { 669 if (dev->hbuf_is_ready) {
671 dev->hbuf_is_ready = false; 670 dev->hbuf_is_ready = false;
672 if (mei_hbm_cl_flow_control_req(dev, cl)) { 671 if (mei_hbm_cl_flow_control_req(dev, cl)) {
@@ -678,6 +677,9 @@ int mei_cl_read_start(struct mei_cl *cl, size_t length)
678 } else { 677 } else {
679 list_add_tail(&cb->list, &dev->ctrl_wr_list.list); 678 list_add_tail(&cb->list, &dev->ctrl_wr_list.list);
680 } 679 }
680
681 cl->read_cb = cb;
682
681 return rets; 683 return rets;
682err: 684err:
683 mei_io_cb_free(cb); 685 mei_io_cb_free(cb);
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 59eba5d2c685..9715a7ba164a 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -1584,7 +1584,7 @@ read_retry:
1584 } 1584 }
1585 1585
1586 if (mtd->ecc_stats.failed - ecc_failures) { 1586 if (mtd->ecc_stats.failed - ecc_failures) {
1587 if (retry_mode + 1 <= chip->read_retries) { 1587 if (retry_mode + 1 < chip->read_retries) {
1588 retry_mode++; 1588 retry_mode++;
1589 ret = nand_setup_read_retry(mtd, 1589 ret = nand_setup_read_retry(mtd,
1590 retry_mode); 1590 retry_mode);
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index ef4190a02b7b..bf642ceef681 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -1633,6 +1633,7 @@ static int omap_nand_probe(struct platform_device *pdev)
1633 int i; 1633 int i;
1634 dma_cap_mask_t mask; 1634 dma_cap_mask_t mask;
1635 unsigned sig; 1635 unsigned sig;
1636 unsigned oob_index;
1636 struct resource *res; 1637 struct resource *res;
1637 struct mtd_part_parser_data ppdata = {}; 1638 struct mtd_part_parser_data ppdata = {};
1638 1639
@@ -1826,11 +1827,14 @@ static int omap_nand_probe(struct platform_device *pdev)
1826 (mtd->writesize / 1827 (mtd->writesize /
1827 nand_chip->ecc.size); 1828 nand_chip->ecc.size);
1828 if (nand_chip->options & NAND_BUSWIDTH_16) 1829 if (nand_chip->options & NAND_BUSWIDTH_16)
1829 ecclayout->eccpos[0] = BADBLOCK_MARKER_LENGTH; 1830 oob_index = BADBLOCK_MARKER_LENGTH;
1830 else 1831 else
1831 ecclayout->eccpos[0] = 1; 1832 oob_index = 1;
1832 ecclayout->oobfree->offset = ecclayout->eccpos[0] + 1833 for (i = 0; i < ecclayout->eccbytes; i++, oob_index++)
1833 ecclayout->eccbytes; 1834 ecclayout->eccpos[i] = oob_index;
1835 /* no reserved-marker in ecclayout for this ecc-scheme */
1836 ecclayout->oobfree->offset =
1837 ecclayout->eccpos[ecclayout->eccbytes - 1] + 1;
1834 break; 1838 break;
1835 1839
1836 case OMAP_ECC_BCH4_CODE_HW_DETECTION_SW: 1840 case OMAP_ECC_BCH4_CODE_HW_DETECTION_SW:
@@ -1847,9 +1851,15 @@ static int omap_nand_probe(struct platform_device *pdev)
1847 ecclayout->eccbytes = nand_chip->ecc.bytes * 1851 ecclayout->eccbytes = nand_chip->ecc.bytes *
1848 (mtd->writesize / 1852 (mtd->writesize /
1849 nand_chip->ecc.size); 1853 nand_chip->ecc.size);
1850 ecclayout->eccpos[0] = BADBLOCK_MARKER_LENGTH; 1854 oob_index = BADBLOCK_MARKER_LENGTH;
1851 ecclayout->oobfree->offset = ecclayout->eccpos[0] + 1855 for (i = 0; i < ecclayout->eccbytes; i++, oob_index++) {
1852 ecclayout->eccbytes; 1856 ecclayout->eccpos[i] = oob_index;
1857 if (((i + 1) % nand_chip->ecc.bytes) == 0)
1858 oob_index++;
1859 }
1860 /* include reserved-marker in ecclayout->oobfree calculation */
1861 ecclayout->oobfree->offset = 1 +
1862 ecclayout->eccpos[ecclayout->eccbytes - 1] + 1;
1853 /* software bch library is used for locating errors */ 1863 /* software bch library is used for locating errors */
1854 nand_chip->ecc.priv = nand_bch_init(mtd, 1864 nand_chip->ecc.priv = nand_bch_init(mtd,
1855 nand_chip->ecc.size, 1865 nand_chip->ecc.size,
@@ -1883,9 +1893,12 @@ static int omap_nand_probe(struct platform_device *pdev)
1883 ecclayout->eccbytes = nand_chip->ecc.bytes * 1893 ecclayout->eccbytes = nand_chip->ecc.bytes *
1884 (mtd->writesize / 1894 (mtd->writesize /
1885 nand_chip->ecc.size); 1895 nand_chip->ecc.size);
1886 ecclayout->eccpos[0] = BADBLOCK_MARKER_LENGTH; 1896 oob_index = BADBLOCK_MARKER_LENGTH;
1887 ecclayout->oobfree->offset = ecclayout->eccpos[0] + 1897 for (i = 0; i < ecclayout->eccbytes; i++, oob_index++)
1888 ecclayout->eccbytes; 1898 ecclayout->eccpos[i] = oob_index;
1899 /* reserved marker already included in ecclayout->eccbytes */
1900 ecclayout->oobfree->offset =
1901 ecclayout->eccpos[ecclayout->eccbytes - 1] + 1;
1889 /* This ECC scheme requires ELM H/W block */ 1902 /* This ECC scheme requires ELM H/W block */
1890 if (is_elm_present(info, pdata->elm_of_node, BCH4_ECC) < 0) { 1903 if (is_elm_present(info, pdata->elm_of_node, BCH4_ECC) < 0) {
1891 pr_err("nand: error: could not initialize ELM\n"); 1904 pr_err("nand: error: could not initialize ELM\n");
@@ -1913,9 +1926,15 @@ static int omap_nand_probe(struct platform_device *pdev)
1913 ecclayout->eccbytes = nand_chip->ecc.bytes * 1926 ecclayout->eccbytes = nand_chip->ecc.bytes *
1914 (mtd->writesize / 1927 (mtd->writesize /
1915 nand_chip->ecc.size); 1928 nand_chip->ecc.size);
1916 ecclayout->eccpos[0] = BADBLOCK_MARKER_LENGTH; 1929 oob_index = BADBLOCK_MARKER_LENGTH;
1917 ecclayout->oobfree->offset = ecclayout->eccpos[0] + 1930 for (i = 0; i < ecclayout->eccbytes; i++, oob_index++) {
1918 ecclayout->eccbytes; 1931 ecclayout->eccpos[i] = oob_index;
1932 if (((i + 1) % nand_chip->ecc.bytes) == 0)
1933 oob_index++;
1934 }
1935 /* include reserved-marker in ecclayout->oobfree calculation */
1936 ecclayout->oobfree->offset = 1 +
1937 ecclayout->eccpos[ecclayout->eccbytes - 1] + 1;
1919 /* software bch library is used for locating errors */ 1938 /* software bch library is used for locating errors */
1920 nand_chip->ecc.priv = nand_bch_init(mtd, 1939 nand_chip->ecc.priv = nand_bch_init(mtd,
1921 nand_chip->ecc.size, 1940 nand_chip->ecc.size,
@@ -1956,9 +1975,12 @@ static int omap_nand_probe(struct platform_device *pdev)
1956 ecclayout->eccbytes = nand_chip->ecc.bytes * 1975 ecclayout->eccbytes = nand_chip->ecc.bytes *
1957 (mtd->writesize / 1976 (mtd->writesize /
1958 nand_chip->ecc.size); 1977 nand_chip->ecc.size);
1959 ecclayout->eccpos[0] = BADBLOCK_MARKER_LENGTH; 1978 oob_index = BADBLOCK_MARKER_LENGTH;
1960 ecclayout->oobfree->offset = ecclayout->eccpos[0] + 1979 for (i = 0; i < ecclayout->eccbytes; i++, oob_index++)
1961 ecclayout->eccbytes; 1980 ecclayout->eccpos[i] = oob_index;
1981 /* reserved marker already included in ecclayout->eccbytes */
1982 ecclayout->oobfree->offset =
1983 ecclayout->eccpos[ecclayout->eccbytes - 1] + 1;
1962 break; 1984 break;
1963#else 1985#else
1964 pr_err("nand: error: CONFIG_MTD_NAND_OMAP_BCH not enabled\n"); 1986 pr_err("nand: error: CONFIG_MTD_NAND_OMAP_BCH not enabled\n");
@@ -1972,11 +1994,8 @@ static int omap_nand_probe(struct platform_device *pdev)
1972 goto return_error; 1994 goto return_error;
1973 } 1995 }
1974 1996
1975 /* populate remaining ECC layout data */ 1997 /* all OOB bytes from oobfree->offset till end off OOB are free */
1976 ecclayout->oobfree->length = mtd->oobsize - (BADBLOCK_MARKER_LENGTH + 1998 ecclayout->oobfree->length = mtd->oobsize - ecclayout->oobfree->offset;
1977 ecclayout->eccbytes);
1978 for (i = 1; i < ecclayout->eccbytes; i++)
1979 ecclayout->eccpos[i] = ecclayout->eccpos[0] + i;
1980 /* check if NAND device's OOB is enough to store ECC signatures */ 1999 /* check if NAND device's OOB is enough to store ECC signatures */
1981 if (mtd->oobsize < (ecclayout->eccbytes + BADBLOCK_MARKER_LENGTH)) { 2000 if (mtd->oobsize < (ecclayout->eccbytes + BADBLOCK_MARKER_LENGTH)) {
1982 pr_err("not enough OOB bytes required = %d, available=%d\n", 2001 pr_err("not enough OOB bytes required = %d, available=%d\n",
diff --git a/drivers/mtd/ubi/fastmap.c b/drivers/mtd/ubi/fastmap.c
index ead861307b3c..c5dad652614d 100644
--- a/drivers/mtd/ubi/fastmap.c
+++ b/drivers/mtd/ubi/fastmap.c
@@ -463,8 +463,8 @@ static int scan_pool(struct ubi_device *ubi, struct ubi_attach_info *ai,
463 } 463 }
464 } 464 }
465 if (found_orphan) { 465 if (found_orphan) {
466 kmem_cache_free(ai->aeb_slab_cache, tmp_aeb);
467 list_del(&tmp_aeb->u.list); 466 list_del(&tmp_aeb->u.list);
467 kmem_cache_free(ai->aeb_slab_cache, tmp_aeb);
468 } 468 }
469 469
470 new_aeb = kmem_cache_alloc(ai->aeb_slab_cache, 470 new_aeb = kmem_cache_alloc(ai->aeb_slab_cache,
@@ -846,16 +846,16 @@ fail_bad:
846 ret = UBI_BAD_FASTMAP; 846 ret = UBI_BAD_FASTMAP;
847fail: 847fail:
848 list_for_each_entry_safe(tmp_aeb, _tmp_aeb, &used, u.list) { 848 list_for_each_entry_safe(tmp_aeb, _tmp_aeb, &used, u.list) {
849 kmem_cache_free(ai->aeb_slab_cache, tmp_aeb);
850 list_del(&tmp_aeb->u.list); 849 list_del(&tmp_aeb->u.list);
850 kmem_cache_free(ai->aeb_slab_cache, tmp_aeb);
851 } 851 }
852 list_for_each_entry_safe(tmp_aeb, _tmp_aeb, &eba_orphans, u.list) { 852 list_for_each_entry_safe(tmp_aeb, _tmp_aeb, &eba_orphans, u.list) {
853 kmem_cache_free(ai->aeb_slab_cache, tmp_aeb);
854 list_del(&tmp_aeb->u.list); 853 list_del(&tmp_aeb->u.list);
854 kmem_cache_free(ai->aeb_slab_cache, tmp_aeb);
855 } 855 }
856 list_for_each_entry_safe(tmp_aeb, _tmp_aeb, &free, u.list) { 856 list_for_each_entry_safe(tmp_aeb, _tmp_aeb, &free, u.list) {
857 kmem_cache_free(ai->aeb_slab_cache, tmp_aeb);
858 list_del(&tmp_aeb->u.list); 857 list_del(&tmp_aeb->u.list);
858 kmem_cache_free(ai->aeb_slab_cache, tmp_aeb);
859 } 859 }
860 860
861 return ret; 861 return ret;
diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c
index f04f3625e944..a2ef3f72de88 100644
--- a/drivers/net/bonding/bond_3ad.c
+++ b/drivers/net/bonding/bond_3ad.c
@@ -181,7 +181,7 @@ static inline int __agg_has_partner(struct aggregator *agg)
181 */ 181 */
182static inline void __disable_port(struct port *port) 182static inline void __disable_port(struct port *port)
183{ 183{
184 bond_set_slave_inactive_flags(port->slave); 184 bond_set_slave_inactive_flags(port->slave, BOND_SLAVE_NOTIFY_LATER);
185} 185}
186 186
187/** 187/**
@@ -193,7 +193,7 @@ static inline void __enable_port(struct port *port)
193 struct slave *slave = port->slave; 193 struct slave *slave = port->slave;
194 194
195 if ((slave->link == BOND_LINK_UP) && IS_UP(slave->dev)) 195 if ((slave->link == BOND_LINK_UP) && IS_UP(slave->dev))
196 bond_set_slave_active_flags(slave); 196 bond_set_slave_active_flags(slave, BOND_SLAVE_NOTIFY_LATER);
197} 197}
198 198
199/** 199/**
@@ -2063,6 +2063,7 @@ void bond_3ad_state_machine_handler(struct work_struct *work)
2063 struct list_head *iter; 2063 struct list_head *iter;
2064 struct slave *slave; 2064 struct slave *slave;
2065 struct port *port; 2065 struct port *port;
2066 bool should_notify_rtnl = BOND_SLAVE_NOTIFY_LATER;
2066 2067
2067 read_lock(&bond->lock); 2068 read_lock(&bond->lock);
2068 rcu_read_lock(); 2069 rcu_read_lock();
@@ -2120,8 +2121,19 @@ void bond_3ad_state_machine_handler(struct work_struct *work)
2120 } 2121 }
2121 2122
2122re_arm: 2123re_arm:
2124 bond_for_each_slave_rcu(bond, slave, iter) {
2125 if (slave->should_notify) {
2126 should_notify_rtnl = BOND_SLAVE_NOTIFY_NOW;
2127 break;
2128 }
2129 }
2123 rcu_read_unlock(); 2130 rcu_read_unlock();
2124 read_unlock(&bond->lock); 2131 read_unlock(&bond->lock);
2132
2133 if (should_notify_rtnl && rtnl_trylock()) {
2134 bond_slave_state_notify(bond);
2135 rtnl_unlock();
2136 }
2125 queue_delayed_work(bond->wq, &bond->ad_work, ad_delta_in_ticks); 2137 queue_delayed_work(bond->wq, &bond->ad_work, ad_delta_in_ticks);
2126} 2138}
2127 2139
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 12861e37d526..730d72c706c9 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -829,21 +829,25 @@ void bond_change_active_slave(struct bonding *bond, struct slave *new_active)
829 if (bond_is_lb(bond)) { 829 if (bond_is_lb(bond)) {
830 bond_alb_handle_active_change(bond, new_active); 830 bond_alb_handle_active_change(bond, new_active);
831 if (old_active) 831 if (old_active)
832 bond_set_slave_inactive_flags(old_active); 832 bond_set_slave_inactive_flags(old_active,
833 BOND_SLAVE_NOTIFY_NOW);
833 if (new_active) 834 if (new_active)
834 bond_set_slave_active_flags(new_active); 835 bond_set_slave_active_flags(new_active,
836 BOND_SLAVE_NOTIFY_NOW);
835 } else { 837 } else {
836 rcu_assign_pointer(bond->curr_active_slave, new_active); 838 rcu_assign_pointer(bond->curr_active_slave, new_active);
837 } 839 }
838 840
839 if (bond->params.mode == BOND_MODE_ACTIVEBACKUP) { 841 if (bond->params.mode == BOND_MODE_ACTIVEBACKUP) {
840 if (old_active) 842 if (old_active)
841 bond_set_slave_inactive_flags(old_active); 843 bond_set_slave_inactive_flags(old_active,
844 BOND_SLAVE_NOTIFY_NOW);
842 845
843 if (new_active) { 846 if (new_active) {
844 bool should_notify_peers = false; 847 bool should_notify_peers = false;
845 848
846 bond_set_slave_active_flags(new_active); 849 bond_set_slave_active_flags(new_active,
850 BOND_SLAVE_NOTIFY_NOW);
847 851
848 if (bond->params.fail_over_mac) 852 if (bond->params.fail_over_mac)
849 bond_do_fail_over_mac(bond, new_active, 853 bond_do_fail_over_mac(bond, new_active,
@@ -1182,6 +1186,11 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
1182 return -EBUSY; 1186 return -EBUSY;
1183 } 1187 }
1184 1188
1189 if (bond_dev == slave_dev) {
1190 pr_err("%s: cannot enslave bond to itself.\n", bond_dev->name);
1191 return -EPERM;
1192 }
1193
1185 /* vlan challenged mutual exclusion */ 1194 /* vlan challenged mutual exclusion */
1186 /* no need to lock since we're protected by rtnl_lock */ 1195 /* no need to lock since we're protected by rtnl_lock */
1187 if (slave_dev->features & NETIF_F_VLAN_CHALLENGED) { 1196 if (slave_dev->features & NETIF_F_VLAN_CHALLENGED) {
@@ -1451,14 +1460,15 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
1451 1460
1452 switch (bond->params.mode) { 1461 switch (bond->params.mode) {
1453 case BOND_MODE_ACTIVEBACKUP: 1462 case BOND_MODE_ACTIVEBACKUP:
1454 bond_set_slave_inactive_flags(new_slave); 1463 bond_set_slave_inactive_flags(new_slave,
1464 BOND_SLAVE_NOTIFY_NOW);
1455 break; 1465 break;
1456 case BOND_MODE_8023AD: 1466 case BOND_MODE_8023AD:
1457 /* in 802.3ad mode, the internal mechanism 1467 /* in 802.3ad mode, the internal mechanism
1458 * will activate the slaves in the selected 1468 * will activate the slaves in the selected
1459 * aggregator 1469 * aggregator
1460 */ 1470 */
1461 bond_set_slave_inactive_flags(new_slave); 1471 bond_set_slave_inactive_flags(new_slave, BOND_SLAVE_NOTIFY_NOW);
1462 /* if this is the first slave */ 1472 /* if this is the first slave */
1463 if (!prev_slave) { 1473 if (!prev_slave) {
1464 SLAVE_AD_INFO(new_slave).id = 1; 1474 SLAVE_AD_INFO(new_slave).id = 1;
@@ -1476,7 +1486,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
1476 case BOND_MODE_TLB: 1486 case BOND_MODE_TLB:
1477 case BOND_MODE_ALB: 1487 case BOND_MODE_ALB:
1478 bond_set_active_slave(new_slave); 1488 bond_set_active_slave(new_slave);
1479 bond_set_slave_inactive_flags(new_slave); 1489 bond_set_slave_inactive_flags(new_slave, BOND_SLAVE_NOTIFY_NOW);
1480 break; 1490 break;
1481 default: 1491 default:
1482 pr_debug("This slave is always active in trunk mode\n"); 1492 pr_debug("This slave is always active in trunk mode\n");
@@ -1641,9 +1651,6 @@ static int __bond_release_one(struct net_device *bond_dev,
1641 return -EINVAL; 1651 return -EINVAL;
1642 } 1652 }
1643 1653
1644 /* release the slave from its bond */
1645 bond->slave_cnt--;
1646
1647 bond_sysfs_slave_del(slave); 1654 bond_sysfs_slave_del(slave);
1648 1655
1649 bond_upper_dev_unlink(bond_dev, slave_dev); 1656 bond_upper_dev_unlink(bond_dev, slave_dev);
@@ -1725,6 +1732,7 @@ static int __bond_release_one(struct net_device *bond_dev,
1725 1732
1726 unblock_netpoll_tx(); 1733 unblock_netpoll_tx();
1727 synchronize_rcu(); 1734 synchronize_rcu();
1735 bond->slave_cnt--;
1728 1736
1729 if (!bond_has_slaves(bond)) { 1737 if (!bond_has_slaves(bond)) {
1730 call_netdevice_notifiers(NETDEV_CHANGEADDR, bond->dev); 1738 call_netdevice_notifiers(NETDEV_CHANGEADDR, bond->dev);
@@ -1998,7 +2006,8 @@ static void bond_miimon_commit(struct bonding *bond)
1998 2006
1999 if (bond->params.mode == BOND_MODE_ACTIVEBACKUP || 2007 if (bond->params.mode == BOND_MODE_ACTIVEBACKUP ||
2000 bond->params.mode == BOND_MODE_8023AD) 2008 bond->params.mode == BOND_MODE_8023AD)
2001 bond_set_slave_inactive_flags(slave); 2009 bond_set_slave_inactive_flags(slave,
2010 BOND_SLAVE_NOTIFY_NOW);
2002 2011
2003 pr_info("%s: link status definitely down for interface %s, disabling it\n", 2012 pr_info("%s: link status definitely down for interface %s, disabling it\n",
2004 bond->dev->name, slave->dev->name); 2013 bond->dev->name, slave->dev->name);
@@ -2553,7 +2562,8 @@ static void bond_ab_arp_commit(struct bonding *bond)
2553 slave->link = BOND_LINK_UP; 2562 slave->link = BOND_LINK_UP;
2554 if (bond->current_arp_slave) { 2563 if (bond->current_arp_slave) {
2555 bond_set_slave_inactive_flags( 2564 bond_set_slave_inactive_flags(
2556 bond->current_arp_slave); 2565 bond->current_arp_slave,
2566 BOND_SLAVE_NOTIFY_NOW);
2557 bond->current_arp_slave = NULL; 2567 bond->current_arp_slave = NULL;
2558 } 2568 }
2559 2569
@@ -2573,7 +2583,8 @@ static void bond_ab_arp_commit(struct bonding *bond)
2573 slave->link_failure_count++; 2583 slave->link_failure_count++;
2574 2584
2575 slave->link = BOND_LINK_DOWN; 2585 slave->link = BOND_LINK_DOWN;
2576 bond_set_slave_inactive_flags(slave); 2586 bond_set_slave_inactive_flags(slave,
2587 BOND_SLAVE_NOTIFY_NOW);
2577 2588
2578 pr_info("%s: link status definitely down for interface %s, disabling it\n", 2589 pr_info("%s: link status definitely down for interface %s, disabling it\n",
2579 bond->dev->name, slave->dev->name); 2590 bond->dev->name, slave->dev->name);
@@ -2606,17 +2617,17 @@ do_failover:
2606 2617
2607/* 2618/*
2608 * Send ARP probes for active-backup mode ARP monitor. 2619 * Send ARP probes for active-backup mode ARP monitor.
2620 *
2621 * Called with rcu_read_lock hold.
2609 */ 2622 */
2610static bool bond_ab_arp_probe(struct bonding *bond) 2623static bool bond_ab_arp_probe(struct bonding *bond)
2611{ 2624{
2612 struct slave *slave, *before = NULL, *new_slave = NULL, 2625 struct slave *slave, *before = NULL, *new_slave = NULL,
2613 *curr_arp_slave, *curr_active_slave; 2626 *curr_arp_slave = rcu_dereference(bond->current_arp_slave),
2627 *curr_active_slave = rcu_dereference(bond->curr_active_slave);
2614 struct list_head *iter; 2628 struct list_head *iter;
2615 bool found = false; 2629 bool found = false;
2616 2630 bool should_notify_rtnl = BOND_SLAVE_NOTIFY_LATER;
2617 rcu_read_lock();
2618 curr_arp_slave = rcu_dereference(bond->current_arp_slave);
2619 curr_active_slave = rcu_dereference(bond->curr_active_slave);
2620 2631
2621 if (curr_arp_slave && curr_active_slave) 2632 if (curr_arp_slave && curr_active_slave)
2622 pr_info("PROBE: c_arp %s && cas %s BAD\n", 2633 pr_info("PROBE: c_arp %s && cas %s BAD\n",
@@ -2625,32 +2636,23 @@ static bool bond_ab_arp_probe(struct bonding *bond)
2625 2636
2626 if (curr_active_slave) { 2637 if (curr_active_slave) {
2627 bond_arp_send_all(bond, curr_active_slave); 2638 bond_arp_send_all(bond, curr_active_slave);
2628 rcu_read_unlock(); 2639 return should_notify_rtnl;
2629 return true;
2630 } 2640 }
2631 rcu_read_unlock();
2632 2641
2633 /* if we don't have a curr_active_slave, search for the next available 2642 /* if we don't have a curr_active_slave, search for the next available
2634 * backup slave from the current_arp_slave and make it the candidate 2643 * backup slave from the current_arp_slave and make it the candidate
2635 * for becoming the curr_active_slave 2644 * for becoming the curr_active_slave
2636 */ 2645 */
2637 2646
2638 if (!rtnl_trylock())
2639 return false;
2640 /* curr_arp_slave might have gone away */
2641 curr_arp_slave = ACCESS_ONCE(bond->current_arp_slave);
2642
2643 if (!curr_arp_slave) { 2647 if (!curr_arp_slave) {
2644 curr_arp_slave = bond_first_slave(bond); 2648 curr_arp_slave = bond_first_slave_rcu(bond);
2645 if (!curr_arp_slave) { 2649 if (!curr_arp_slave)
2646 rtnl_unlock(); 2650 return should_notify_rtnl;
2647 return true;
2648 }
2649 } 2651 }
2650 2652
2651 bond_set_slave_inactive_flags(curr_arp_slave); 2653 bond_set_slave_inactive_flags(curr_arp_slave, BOND_SLAVE_NOTIFY_LATER);
2652 2654
2653 bond_for_each_slave(bond, slave, iter) { 2655 bond_for_each_slave_rcu(bond, slave, iter) {
2654 if (!found && !before && IS_UP(slave->dev)) 2656 if (!found && !before && IS_UP(slave->dev))
2655 before = slave; 2657 before = slave;
2656 2658
@@ -2668,7 +2670,8 @@ static bool bond_ab_arp_probe(struct bonding *bond)
2668 if (slave->link_failure_count < UINT_MAX) 2670 if (slave->link_failure_count < UINT_MAX)
2669 slave->link_failure_count++; 2671 slave->link_failure_count++;
2670 2672
2671 bond_set_slave_inactive_flags(slave); 2673 bond_set_slave_inactive_flags(slave,
2674 BOND_SLAVE_NOTIFY_LATER);
2672 2675
2673 pr_info("%s: backup interface %s is now down\n", 2676 pr_info("%s: backup interface %s is now down\n",
2674 bond->dev->name, slave->dev->name); 2677 bond->dev->name, slave->dev->name);
@@ -2680,26 +2683,31 @@ static bool bond_ab_arp_probe(struct bonding *bond)
2680 if (!new_slave && before) 2683 if (!new_slave && before)
2681 new_slave = before; 2684 new_slave = before;
2682 2685
2683 if (!new_slave) { 2686 if (!new_slave)
2684 rtnl_unlock(); 2687 goto check_state;
2685 return true;
2686 }
2687 2688
2688 new_slave->link = BOND_LINK_BACK; 2689 new_slave->link = BOND_LINK_BACK;
2689 bond_set_slave_active_flags(new_slave); 2690 bond_set_slave_active_flags(new_slave, BOND_SLAVE_NOTIFY_LATER);
2690 bond_arp_send_all(bond, new_slave); 2691 bond_arp_send_all(bond, new_slave);
2691 new_slave->last_link_up = jiffies; 2692 new_slave->last_link_up = jiffies;
2692 rcu_assign_pointer(bond->current_arp_slave, new_slave); 2693 rcu_assign_pointer(bond->current_arp_slave, new_slave);
2693 rtnl_unlock();
2694 2694
2695 return true; 2695check_state:
2696 bond_for_each_slave_rcu(bond, slave, iter) {
2697 if (slave->should_notify) {
2698 should_notify_rtnl = BOND_SLAVE_NOTIFY_NOW;
2699 break;
2700 }
2701 }
2702 return should_notify_rtnl;
2696} 2703}
2697 2704
2698static void bond_activebackup_arp_mon(struct work_struct *work) 2705static void bond_activebackup_arp_mon(struct work_struct *work)
2699{ 2706{
2700 struct bonding *bond = container_of(work, struct bonding, 2707 struct bonding *bond = container_of(work, struct bonding,
2701 arp_work.work); 2708 arp_work.work);
2702 bool should_notify_peers = false, should_commit = false; 2709 bool should_notify_peers = false;
2710 bool should_notify_rtnl = false;
2703 int delta_in_ticks; 2711 int delta_in_ticks;
2704 2712
2705 delta_in_ticks = msecs_to_jiffies(bond->params.arp_interval); 2713 delta_in_ticks = msecs_to_jiffies(bond->params.arp_interval);
@@ -2708,11 +2716,12 @@ static void bond_activebackup_arp_mon(struct work_struct *work)
2708 goto re_arm; 2716 goto re_arm;
2709 2717
2710 rcu_read_lock(); 2718 rcu_read_lock();
2719
2711 should_notify_peers = bond_should_notify_peers(bond); 2720 should_notify_peers = bond_should_notify_peers(bond);
2712 should_commit = bond_ab_arp_inspect(bond);
2713 rcu_read_unlock();
2714 2721
2715 if (should_commit) { 2722 if (bond_ab_arp_inspect(bond)) {
2723 rcu_read_unlock();
2724
2716 /* Race avoidance with bond_close flush of workqueue */ 2725 /* Race avoidance with bond_close flush of workqueue */
2717 if (!rtnl_trylock()) { 2726 if (!rtnl_trylock()) {
2718 delta_in_ticks = 1; 2727 delta_in_ticks = 1;
@@ -2721,23 +2730,28 @@ static void bond_activebackup_arp_mon(struct work_struct *work)
2721 } 2730 }
2722 2731
2723 bond_ab_arp_commit(bond); 2732 bond_ab_arp_commit(bond);
2733
2724 rtnl_unlock(); 2734 rtnl_unlock();
2735 rcu_read_lock();
2725 } 2736 }
2726 2737
2727 if (!bond_ab_arp_probe(bond)) { 2738 should_notify_rtnl = bond_ab_arp_probe(bond);
2728 /* rtnl locking failed, re-arm */ 2739 rcu_read_unlock();
2729 delta_in_ticks = 1;
2730 should_notify_peers = false;
2731 }
2732 2740
2733re_arm: 2741re_arm:
2734 if (bond->params.arp_interval) 2742 if (bond->params.arp_interval)
2735 queue_delayed_work(bond->wq, &bond->arp_work, delta_in_ticks); 2743 queue_delayed_work(bond->wq, &bond->arp_work, delta_in_ticks);
2736 2744
2737 if (should_notify_peers) { 2745 if (should_notify_peers || should_notify_rtnl) {
2738 if (!rtnl_trylock()) 2746 if (!rtnl_trylock())
2739 return; 2747 return;
2740 call_netdevice_notifiers(NETDEV_NOTIFY_PEERS, bond->dev); 2748
2749 if (should_notify_peers)
2750 call_netdevice_notifiers(NETDEV_NOTIFY_PEERS,
2751 bond->dev);
2752 if (should_notify_rtnl)
2753 bond_slave_state_notify(bond);
2754
2741 rtnl_unlock(); 2755 rtnl_unlock();
2742 } 2756 }
2743} 2757}
@@ -3036,9 +3050,11 @@ static int bond_open(struct net_device *bond_dev)
3036 bond_for_each_slave(bond, slave, iter) { 3050 bond_for_each_slave(bond, slave, iter) {
3037 if ((bond->params.mode == BOND_MODE_ACTIVEBACKUP) 3051 if ((bond->params.mode == BOND_MODE_ACTIVEBACKUP)
3038 && (slave != bond->curr_active_slave)) { 3052 && (slave != bond->curr_active_slave)) {
3039 bond_set_slave_inactive_flags(slave); 3053 bond_set_slave_inactive_flags(slave,
3054 BOND_SLAVE_NOTIFY_NOW);
3040 } else { 3055 } else {
3041 bond_set_slave_active_flags(slave); 3056 bond_set_slave_active_flags(slave,
3057 BOND_SLAVE_NOTIFY_NOW);
3042 } 3058 }
3043 } 3059 }
3044 read_unlock(&bond->curr_slave_lock); 3060 read_unlock(&bond->curr_slave_lock);
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
index 430362891d0d..b7127a1ba2c9 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -196,7 +196,8 @@ struct slave {
196 s8 new_link; 196 s8 new_link;
197 u8 backup:1, /* indicates backup slave. Value corresponds with 197 u8 backup:1, /* indicates backup slave. Value corresponds with
198 BOND_STATE_ACTIVE and BOND_STATE_BACKUP */ 198 BOND_STATE_ACTIVE and BOND_STATE_BACKUP */
199 inactive:1; /* indicates inactive slave */ 199 inactive:1, /* indicates inactive slave */
200 should_notify:1; /* indicateds whether the state changed */
200 u8 duplex; 201 u8 duplex;
201 u32 original_mtu; 202 u32 original_mtu;
202 u32 link_failure_count; 203 u32 link_failure_count;
@@ -304,6 +305,24 @@ static inline void bond_set_backup_slave(struct slave *slave)
304 } 305 }
305} 306}
306 307
308static inline void bond_set_slave_state(struct slave *slave,
309 int slave_state, bool notify)
310{
311 if (slave->backup == slave_state)
312 return;
313
314 slave->backup = slave_state;
315 if (notify) {
316 rtmsg_ifinfo(RTM_NEWLINK, slave->dev, 0, GFP_KERNEL);
317 slave->should_notify = 0;
318 } else {
319 if (slave->should_notify)
320 slave->should_notify = 0;
321 else
322 slave->should_notify = 1;
323 }
324}
325
307static inline void bond_slave_state_change(struct bonding *bond) 326static inline void bond_slave_state_change(struct bonding *bond)
308{ 327{
309 struct list_head *iter; 328 struct list_head *iter;
@@ -317,6 +336,19 @@ static inline void bond_slave_state_change(struct bonding *bond)
317 } 336 }
318} 337}
319 338
339static inline void bond_slave_state_notify(struct bonding *bond)
340{
341 struct list_head *iter;
342 struct slave *tmp;
343
344 bond_for_each_slave(bond, tmp, iter) {
345 if (tmp->should_notify) {
346 rtmsg_ifinfo(RTM_NEWLINK, tmp->dev, 0, GFP_KERNEL);
347 tmp->should_notify = 0;
348 }
349 }
350}
351
320static inline int bond_slave_state(struct slave *slave) 352static inline int bond_slave_state(struct slave *slave)
321{ 353{
322 return slave->backup; 354 return slave->backup;
@@ -349,6 +381,9 @@ static inline bool bond_is_active_slave(struct slave *slave)
349#define BOND_ARP_FILTER_BACKUP (BOND_ARP_VALIDATE_BACKUP | \ 381#define BOND_ARP_FILTER_BACKUP (BOND_ARP_VALIDATE_BACKUP | \
350 BOND_ARP_FILTER) 382 BOND_ARP_FILTER)
351 383
384#define BOND_SLAVE_NOTIFY_NOW true
385#define BOND_SLAVE_NOTIFY_LATER false
386
352static inline int slave_do_arp_validate(struct bonding *bond, 387static inline int slave_do_arp_validate(struct bonding *bond,
353 struct slave *slave) 388 struct slave *slave)
354{ 389{
@@ -402,17 +437,19 @@ static inline void bond_netpoll_send_skb(const struct slave *slave,
402} 437}
403#endif 438#endif
404 439
405static inline void bond_set_slave_inactive_flags(struct slave *slave) 440static inline void bond_set_slave_inactive_flags(struct slave *slave,
441 bool notify)
406{ 442{
407 if (!bond_is_lb(slave->bond)) 443 if (!bond_is_lb(slave->bond))
408 bond_set_backup_slave(slave); 444 bond_set_slave_state(slave, BOND_STATE_BACKUP, notify);
409 if (!slave->bond->params.all_slaves_active) 445 if (!slave->bond->params.all_slaves_active)
410 slave->inactive = 1; 446 slave->inactive = 1;
411} 447}
412 448
413static inline void bond_set_slave_active_flags(struct slave *slave) 449static inline void bond_set_slave_active_flags(struct slave *slave,
450 bool notify)
414{ 451{
415 bond_set_active_slave(slave); 452 bond_set_slave_state(slave, BOND_STATE_ACTIVE, notify);
416 slave->inactive = 0; 453 slave->inactive = 0;
417} 454}
418 455
diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
index 320bef2dba42..61376abdab39 100644
--- a/drivers/net/can/flexcan.c
+++ b/drivers/net/can/flexcan.c
@@ -144,6 +144,8 @@
144 144
145#define FLEXCAN_MB_CODE_MASK (0xf0ffffff) 145#define FLEXCAN_MB_CODE_MASK (0xf0ffffff)
146 146
147#define FLEXCAN_TIMEOUT_US (50)
148
147/* 149/*
148 * FLEXCAN hardware feature flags 150 * FLEXCAN hardware feature flags
149 * 151 *
@@ -262,6 +264,22 @@ static inline void flexcan_write(u32 val, void __iomem *addr)
262} 264}
263#endif 265#endif
264 266
267static inline int flexcan_transceiver_enable(const struct flexcan_priv *priv)
268{
269 if (!priv->reg_xceiver)
270 return 0;
271
272 return regulator_enable(priv->reg_xceiver);
273}
274
275static inline int flexcan_transceiver_disable(const struct flexcan_priv *priv)
276{
277 if (!priv->reg_xceiver)
278 return 0;
279
280 return regulator_disable(priv->reg_xceiver);
281}
282
265static inline int flexcan_has_and_handle_berr(const struct flexcan_priv *priv, 283static inline int flexcan_has_and_handle_berr(const struct flexcan_priv *priv,
266 u32 reg_esr) 284 u32 reg_esr)
267{ 285{
@@ -269,26 +287,95 @@ static inline int flexcan_has_and_handle_berr(const struct flexcan_priv *priv,
269 (reg_esr & FLEXCAN_ESR_ERR_BUS); 287 (reg_esr & FLEXCAN_ESR_ERR_BUS);
270} 288}
271 289
272static inline void flexcan_chip_enable(struct flexcan_priv *priv) 290static int flexcan_chip_enable(struct flexcan_priv *priv)
273{ 291{
274 struct flexcan_regs __iomem *regs = priv->base; 292 struct flexcan_regs __iomem *regs = priv->base;
293 unsigned int timeout = FLEXCAN_TIMEOUT_US / 10;
275 u32 reg; 294 u32 reg;
276 295
277 reg = flexcan_read(&regs->mcr); 296 reg = flexcan_read(&regs->mcr);
278 reg &= ~FLEXCAN_MCR_MDIS; 297 reg &= ~FLEXCAN_MCR_MDIS;
279 flexcan_write(reg, &regs->mcr); 298 flexcan_write(reg, &regs->mcr);
280 299
281 udelay(10); 300 while (timeout-- && (flexcan_read(&regs->mcr) & FLEXCAN_MCR_LPM_ACK))
301 usleep_range(10, 20);
302
303 if (flexcan_read(&regs->mcr) & FLEXCAN_MCR_LPM_ACK)
304 return -ETIMEDOUT;
305
306 return 0;
282} 307}
283 308
284static inline void flexcan_chip_disable(struct flexcan_priv *priv) 309static int flexcan_chip_disable(struct flexcan_priv *priv)
285{ 310{
286 struct flexcan_regs __iomem *regs = priv->base; 311 struct flexcan_regs __iomem *regs = priv->base;
312 unsigned int timeout = FLEXCAN_TIMEOUT_US / 10;
287 u32 reg; 313 u32 reg;
288 314
289 reg = flexcan_read(&regs->mcr); 315 reg = flexcan_read(&regs->mcr);
290 reg |= FLEXCAN_MCR_MDIS; 316 reg |= FLEXCAN_MCR_MDIS;
291 flexcan_write(reg, &regs->mcr); 317 flexcan_write(reg, &regs->mcr);
318
319 while (timeout-- && !(flexcan_read(&regs->mcr) & FLEXCAN_MCR_LPM_ACK))
320 usleep_range(10, 20);
321
322 if (!(flexcan_read(&regs->mcr) & FLEXCAN_MCR_LPM_ACK))
323 return -ETIMEDOUT;
324
325 return 0;
326}
327
328static int flexcan_chip_freeze(struct flexcan_priv *priv)
329{
330 struct flexcan_regs __iomem *regs = priv->base;
331 unsigned int timeout = 1000 * 1000 * 10 / priv->can.bittiming.bitrate;
332 u32 reg;
333
334 reg = flexcan_read(&regs->mcr);
335 reg |= FLEXCAN_MCR_HALT;
336 flexcan_write(reg, &regs->mcr);
337
338 while (timeout-- && !(flexcan_read(&regs->mcr) & FLEXCAN_MCR_FRZ_ACK))
339 usleep_range(100, 200);
340
341 if (!(flexcan_read(&regs->mcr) & FLEXCAN_MCR_FRZ_ACK))
342 return -ETIMEDOUT;
343
344 return 0;
345}
346
347static int flexcan_chip_unfreeze(struct flexcan_priv *priv)
348{
349 struct flexcan_regs __iomem *regs = priv->base;
350 unsigned int timeout = FLEXCAN_TIMEOUT_US / 10;
351 u32 reg;
352
353 reg = flexcan_read(&regs->mcr);
354 reg &= ~FLEXCAN_MCR_HALT;
355 flexcan_write(reg, &regs->mcr);
356
357 while (timeout-- && (flexcan_read(&regs->mcr) & FLEXCAN_MCR_FRZ_ACK))
358 usleep_range(10, 20);
359
360 if (flexcan_read(&regs->mcr) & FLEXCAN_MCR_FRZ_ACK)
361 return -ETIMEDOUT;
362
363 return 0;
364}
365
366static int flexcan_chip_softreset(struct flexcan_priv *priv)
367{
368 struct flexcan_regs __iomem *regs = priv->base;
369 unsigned int timeout = FLEXCAN_TIMEOUT_US / 10;
370
371 flexcan_write(FLEXCAN_MCR_SOFTRST, &regs->mcr);
372 while (timeout-- && (flexcan_read(&regs->mcr) & FLEXCAN_MCR_SOFTRST))
373 usleep_range(10, 20);
374
375 if (flexcan_read(&regs->mcr) & FLEXCAN_MCR_SOFTRST)
376 return -ETIMEDOUT;
377
378 return 0;
292} 379}
293 380
294static int flexcan_get_berr_counter(const struct net_device *dev, 381static int flexcan_get_berr_counter(const struct net_device *dev,
@@ -709,19 +796,14 @@ static int flexcan_chip_start(struct net_device *dev)
709 u32 reg_mcr, reg_ctrl; 796 u32 reg_mcr, reg_ctrl;
710 797
711 /* enable module */ 798 /* enable module */
712 flexcan_chip_enable(priv); 799 err = flexcan_chip_enable(priv);
800 if (err)
801 return err;
713 802
714 /* soft reset */ 803 /* soft reset */
715 flexcan_write(FLEXCAN_MCR_SOFTRST, &regs->mcr); 804 err = flexcan_chip_softreset(priv);
716 udelay(10); 805 if (err)
717 806 goto out_chip_disable;
718 reg_mcr = flexcan_read(&regs->mcr);
719 if (reg_mcr & FLEXCAN_MCR_SOFTRST) {
720 netdev_err(dev, "Failed to softreset can module (mcr=0x%08x)\n",
721 reg_mcr);
722 err = -ENODEV;
723 goto out;
724 }
725 807
726 flexcan_set_bittiming(dev); 808 flexcan_set_bittiming(dev);
727 809
@@ -788,16 +870,14 @@ static int flexcan_chip_start(struct net_device *dev)
788 if (priv->devtype_data->features & FLEXCAN_HAS_V10_FEATURES) 870 if (priv->devtype_data->features & FLEXCAN_HAS_V10_FEATURES)
789 flexcan_write(0x0, &regs->rxfgmask); 871 flexcan_write(0x0, &regs->rxfgmask);
790 872
791 if (priv->reg_xceiver) { 873 err = flexcan_transceiver_enable(priv);
792 err = regulator_enable(priv->reg_xceiver); 874 if (err)
793 if (err) 875 goto out_chip_disable;
794 goto out;
795 }
796 876
797 /* synchronize with the can bus */ 877 /* synchronize with the can bus */
798 reg_mcr = flexcan_read(&regs->mcr); 878 err = flexcan_chip_unfreeze(priv);
799 reg_mcr &= ~FLEXCAN_MCR_HALT; 879 if (err)
800 flexcan_write(reg_mcr, &regs->mcr); 880 goto out_transceiver_disable;
801 881
802 priv->can.state = CAN_STATE_ERROR_ACTIVE; 882 priv->can.state = CAN_STATE_ERROR_ACTIVE;
803 883
@@ -810,7 +890,9 @@ static int flexcan_chip_start(struct net_device *dev)
810 890
811 return 0; 891 return 0;
812 892
813 out: 893 out_transceiver_disable:
894 flexcan_transceiver_disable(priv);
895 out_chip_disable:
814 flexcan_chip_disable(priv); 896 flexcan_chip_disable(priv);
815 return err; 897 return err;
816} 898}
@@ -825,18 +907,17 @@ static void flexcan_chip_stop(struct net_device *dev)
825{ 907{
826 struct flexcan_priv *priv = netdev_priv(dev); 908 struct flexcan_priv *priv = netdev_priv(dev);
827 struct flexcan_regs __iomem *regs = priv->base; 909 struct flexcan_regs __iomem *regs = priv->base;
828 u32 reg; 910
911 /* freeze + disable module */
912 flexcan_chip_freeze(priv);
913 flexcan_chip_disable(priv);
829 914
830 /* Disable all interrupts */ 915 /* Disable all interrupts */
831 flexcan_write(0, &regs->imask1); 916 flexcan_write(0, &regs->imask1);
917 flexcan_write(priv->reg_ctrl_default & ~FLEXCAN_CTRL_ERR_ALL,
918 &regs->ctrl);
832 919
833 /* Disable + halt module */ 920 flexcan_transceiver_disable(priv);
834 reg = flexcan_read(&regs->mcr);
835 reg |= FLEXCAN_MCR_MDIS | FLEXCAN_MCR_HALT;
836 flexcan_write(reg, &regs->mcr);
837
838 if (priv->reg_xceiver)
839 regulator_disable(priv->reg_xceiver);
840 priv->can.state = CAN_STATE_STOPPED; 921 priv->can.state = CAN_STATE_STOPPED;
841 922
842 return; 923 return;
@@ -866,7 +947,7 @@ static int flexcan_open(struct net_device *dev)
866 /* start chip and queuing */ 947 /* start chip and queuing */
867 err = flexcan_chip_start(dev); 948 err = flexcan_chip_start(dev);
868 if (err) 949 if (err)
869 goto out_close; 950 goto out_free_irq;
870 951
871 can_led_event(dev, CAN_LED_EVENT_OPEN); 952 can_led_event(dev, CAN_LED_EVENT_OPEN);
872 953
@@ -875,6 +956,8 @@ static int flexcan_open(struct net_device *dev)
875 956
876 return 0; 957 return 0;
877 958
959 out_free_irq:
960 free_irq(dev->irq, dev);
878 out_close: 961 out_close:
879 close_candev(dev); 962 close_candev(dev);
880 out_disable_per: 963 out_disable_per:
@@ -945,12 +1028,16 @@ static int register_flexcandev(struct net_device *dev)
945 goto out_disable_ipg; 1028 goto out_disable_ipg;
946 1029
947 /* select "bus clock", chip must be disabled */ 1030 /* select "bus clock", chip must be disabled */
948 flexcan_chip_disable(priv); 1031 err = flexcan_chip_disable(priv);
1032 if (err)
1033 goto out_disable_per;
949 reg = flexcan_read(&regs->ctrl); 1034 reg = flexcan_read(&regs->ctrl);
950 reg |= FLEXCAN_CTRL_CLK_SRC; 1035 reg |= FLEXCAN_CTRL_CLK_SRC;
951 flexcan_write(reg, &regs->ctrl); 1036 flexcan_write(reg, &regs->ctrl);
952 1037
953 flexcan_chip_enable(priv); 1038 err = flexcan_chip_enable(priv);
1039 if (err)
1040 goto out_chip_disable;
954 1041
955 /* set freeze, halt and activate FIFO, restrict register access */ 1042 /* set freeze, halt and activate FIFO, restrict register access */
956 reg = flexcan_read(&regs->mcr); 1043 reg = flexcan_read(&regs->mcr);
@@ -967,14 +1054,15 @@ static int register_flexcandev(struct net_device *dev)
967 if (!(reg & FLEXCAN_MCR_FEN)) { 1054 if (!(reg & FLEXCAN_MCR_FEN)) {
968 netdev_err(dev, "Could not enable RX FIFO, unsupported core\n"); 1055 netdev_err(dev, "Could not enable RX FIFO, unsupported core\n");
969 err = -ENODEV; 1056 err = -ENODEV;
970 goto out_disable_per; 1057 goto out_chip_disable;
971 } 1058 }
972 1059
973 err = register_candev(dev); 1060 err = register_candev(dev);
974 1061
975 out_disable_per:
976 /* disable core and turn off clocks */ 1062 /* disable core and turn off clocks */
1063 out_chip_disable:
977 flexcan_chip_disable(priv); 1064 flexcan_chip_disable(priv);
1065 out_disable_per:
978 clk_disable_unprepare(priv->clk_per); 1066 clk_disable_unprepare(priv->clk_per);
979 out_disable_ipg: 1067 out_disable_ipg:
980 clk_disable_unprepare(priv->clk_ipg); 1068 clk_disable_unprepare(priv->clk_ipg);
@@ -1104,9 +1192,10 @@ static int flexcan_probe(struct platform_device *pdev)
1104static int flexcan_remove(struct platform_device *pdev) 1192static int flexcan_remove(struct platform_device *pdev)
1105{ 1193{
1106 struct net_device *dev = platform_get_drvdata(pdev); 1194 struct net_device *dev = platform_get_drvdata(pdev);
1195 struct flexcan_priv *priv = netdev_priv(dev);
1107 1196
1108 unregister_flexcandev(dev); 1197 unregister_flexcandev(dev);
1109 1198 netif_napi_del(&priv->napi);
1110 free_candev(dev); 1199 free_candev(dev);
1111 1200
1112 return 0; 1201 return 0;
@@ -1117,8 +1206,11 @@ static int flexcan_suspend(struct device *device)
1117{ 1206{
1118 struct net_device *dev = dev_get_drvdata(device); 1207 struct net_device *dev = dev_get_drvdata(device);
1119 struct flexcan_priv *priv = netdev_priv(dev); 1208 struct flexcan_priv *priv = netdev_priv(dev);
1209 int err;
1120 1210
1121 flexcan_chip_disable(priv); 1211 err = flexcan_chip_disable(priv);
1212 if (err)
1213 return err;
1122 1214
1123 if (netif_running(dev)) { 1215 if (netif_running(dev)) {
1124 netif_stop_queue(dev); 1216 netif_stop_queue(dev);
@@ -1139,9 +1231,7 @@ static int flexcan_resume(struct device *device)
1139 netif_device_attach(dev); 1231 netif_device_attach(dev);
1140 netif_start_queue(dev); 1232 netif_start_queue(dev);
1141 } 1233 }
1142 flexcan_chip_enable(priv); 1234 return flexcan_chip_enable(priv);
1143
1144 return 0;
1145} 1235}
1146#endif /* CONFIG_PM_SLEEP */ 1236#endif /* CONFIG_PM_SLEEP */
1147 1237
diff --git a/drivers/net/ethernet/broadcom/b44.c b/drivers/net/ethernet/broadcom/b44.c
index 1f7b5aa114fa..8a7bf7dad898 100644
--- a/drivers/net/ethernet/broadcom/b44.c
+++ b/drivers/net/ethernet/broadcom/b44.c
@@ -1484,6 +1484,10 @@ static int b44_open(struct net_device *dev)
1484 add_timer(&bp->timer); 1484 add_timer(&bp->timer);
1485 1485
1486 b44_enable_ints(bp); 1486 b44_enable_ints(bp);
1487
1488 if (bp->flags & B44_FLAG_EXTERNAL_PHY)
1489 phy_start(bp->phydev);
1490
1487 netif_start_queue(dev); 1491 netif_start_queue(dev);
1488out: 1492out:
1489 return err; 1493 return err;
@@ -1646,6 +1650,9 @@ static int b44_close(struct net_device *dev)
1646 1650
1647 netif_stop_queue(dev); 1651 netif_stop_queue(dev);
1648 1652
1653 if (bp->flags & B44_FLAG_EXTERNAL_PHY)
1654 phy_stop(bp->phydev);
1655
1649 napi_disable(&bp->napi); 1656 napi_disable(&bp->napi);
1650 1657
1651 del_timer_sync(&bp->timer); 1658 del_timer_sync(&bp->timer);
@@ -2222,7 +2229,12 @@ static void b44_adjust_link(struct net_device *dev)
2222 } 2229 }
2223 2230
2224 if (status_changed) { 2231 if (status_changed) {
2225 b44_check_phy(bp); 2232 u32 val = br32(bp, B44_TX_CTRL);
2233 if (bp->flags & B44_FLAG_FULL_DUPLEX)
2234 val |= TX_CTRL_DUPLEX;
2235 else
2236 val &= ~TX_CTRL_DUPLEX;
2237 bw32(bp, B44_TX_CTRL, val);
2226 phy_print_status(phydev); 2238 phy_print_status(phydev);
2227 } 2239 }
2228} 2240}
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
index 26bc25bd465d..117b5c7f8ac9 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
@@ -3875,7 +3875,9 @@ netdev_tx_t bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev)
3875 xmit_type); 3875 xmit_type);
3876 } 3876 }
3877 3877
3878 /* Add the macs to the parsing BD this is a vf */ 3878 /* Add the macs to the parsing BD if this is a vf or if
3879 * Tx Switching is enabled.
3880 */
3879 if (IS_VF(bp)) { 3881 if (IS_VF(bp)) {
3880 /* override GRE parameters in BD */ 3882 /* override GRE parameters in BD */
3881 bnx2x_set_fw_mac_addr(&pbd_e2->data.mac_addr.src_hi, 3883 bnx2x_set_fw_mac_addr(&pbd_e2->data.mac_addr.src_hi,
@@ -3887,6 +3889,11 @@ netdev_tx_t bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev)
3887 &pbd_e2->data.mac_addr.dst_mid, 3889 &pbd_e2->data.mac_addr.dst_mid,
3888 &pbd_e2->data.mac_addr.dst_lo, 3890 &pbd_e2->data.mac_addr.dst_lo,
3889 eth->h_dest); 3891 eth->h_dest);
3892 } else if (bp->flags & TX_SWITCHING) {
3893 bnx2x_set_fw_mac_addr(&pbd_e2->data.mac_addr.dst_hi,
3894 &pbd_e2->data.mac_addr.dst_mid,
3895 &pbd_e2->data.mac_addr.dst_lo,
3896 eth->h_dest);
3890 } 3897 }
3891 3898
3892 SET_FLAG(pbd_e2_parsing_data, 3899 SET_FLAG(pbd_e2_parsing_data,
diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index 6e5e7c0ffbd7..e12735fbdcdb 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -6843,8 +6843,7 @@ static int tg3_rx(struct tg3_napi *tnapi, int budget)
6843 6843
6844 work_mask |= opaque_key; 6844 work_mask |= opaque_key;
6845 6845
6846 if ((desc->err_vlan & RXD_ERR_MASK) != 0 && 6846 if (desc->err_vlan & RXD_ERR_MASK) {
6847 (desc->err_vlan != RXD_ERR_ODD_NIBBLE_RCVD_MII)) {
6848 drop_it: 6847 drop_it:
6849 tg3_recycle_rx(tnapi, tpr, opaque_key, 6848 tg3_recycle_rx(tnapi, tpr, opaque_key,
6850 desc_idx, *post_ptr); 6849 desc_idx, *post_ptr);
diff --git a/drivers/net/ethernet/broadcom/tg3.h b/drivers/net/ethernet/broadcom/tg3.h
index ef472385bce4..04321e5a356e 100644
--- a/drivers/net/ethernet/broadcom/tg3.h
+++ b/drivers/net/ethernet/broadcom/tg3.h
@@ -2608,7 +2608,11 @@ struct tg3_rx_buffer_desc {
2608#define RXD_ERR_TOO_SMALL 0x00400000 2608#define RXD_ERR_TOO_SMALL 0x00400000
2609#define RXD_ERR_NO_RESOURCES 0x00800000 2609#define RXD_ERR_NO_RESOURCES 0x00800000
2610#define RXD_ERR_HUGE_FRAME 0x01000000 2610#define RXD_ERR_HUGE_FRAME 0x01000000
2611#define RXD_ERR_MASK 0xffff0000 2611
2612#define RXD_ERR_MASK (RXD_ERR_BAD_CRC | RXD_ERR_COLLISION | \
2613 RXD_ERR_LINK_LOST | RXD_ERR_PHY_DECODE | \
2614 RXD_ERR_MAC_ABRT | RXD_ERR_TOO_SMALL | \
2615 RXD_ERR_NO_RESOURCES | RXD_ERR_HUGE_FRAME)
2612 2616
2613 u32 reserved; 2617 u32 reserved;
2614 u32 opaque; 2618 u32 opaque;
diff --git a/drivers/net/ethernet/brocade/bna/bnad.c b/drivers/net/ethernet/brocade/bna/bnad.c
index bf436d0a1094..aeec9ccc0b39 100644
--- a/drivers/net/ethernet/brocade/bna/bnad.c
+++ b/drivers/net/ethernet/brocade/bna/bnad.c
@@ -707,7 +707,8 @@ bnad_cq_process(struct bnad *bnad, struct bna_ccb *ccb, int budget)
707 else 707 else
708 skb_checksum_none_assert(skb); 708 skb_checksum_none_assert(skb);
709 709
710 if (flags & BNA_CQ_EF_VLAN) 710 if ((flags & BNA_CQ_EF_VLAN) &&
711 (bnad->netdev->features & NETIF_F_HW_VLAN_CTAG_RX))
711 __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), ntohs(cmpl->vlan_tag)); 712 __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), ntohs(cmpl->vlan_tag));
712 713
713 if (BNAD_RXBUF_IS_SK_BUFF(unmap_q->type)) 714 if (BNAD_RXBUF_IS_SK_BUFF(unmap_q->type))
@@ -2094,7 +2095,9 @@ bnad_init_rx_config(struct bnad *bnad, struct bna_rx_config *rx_config)
2094 rx_config->q1_buf_size = BFI_SMALL_RXBUF_SIZE; 2095 rx_config->q1_buf_size = BFI_SMALL_RXBUF_SIZE;
2095 } 2096 }
2096 2097
2097 rx_config->vlan_strip_status = BNA_STATUS_T_ENABLED; 2098 rx_config->vlan_strip_status =
2099 (bnad->netdev->features & NETIF_F_HW_VLAN_CTAG_RX) ?
2100 BNA_STATUS_T_ENABLED : BNA_STATUS_T_DISABLED;
2098} 2101}
2099 2102
2100static void 2103static void
@@ -3240,11 +3243,6 @@ bnad_set_rx_mode(struct net_device *netdev)
3240 BNA_RXMODE_ALLMULTI; 3243 BNA_RXMODE_ALLMULTI;
3241 bna_rx_mode_set(bnad->rx_info[0].rx, new_mode, mode_mask, NULL); 3244 bna_rx_mode_set(bnad->rx_info[0].rx, new_mode, mode_mask, NULL);
3242 3245
3243 if (bnad->cfg_flags & BNAD_CF_PROMISC)
3244 bna_rx_vlan_strip_disable(bnad->rx_info[0].rx);
3245 else
3246 bna_rx_vlan_strip_enable(bnad->rx_info[0].rx);
3247
3248 spin_unlock_irqrestore(&bnad->bna_lock, flags); 3246 spin_unlock_irqrestore(&bnad->bna_lock, flags);
3249} 3247}
3250 3248
@@ -3369,6 +3367,27 @@ bnad_vlan_rx_kill_vid(struct net_device *netdev, __be16 proto, u16 vid)
3369 return 0; 3367 return 0;
3370} 3368}
3371 3369
3370static int bnad_set_features(struct net_device *dev, netdev_features_t features)
3371{
3372 struct bnad *bnad = netdev_priv(dev);
3373 netdev_features_t changed = features ^ dev->features;
3374
3375 if ((changed & NETIF_F_HW_VLAN_CTAG_RX) && netif_running(dev)) {
3376 unsigned long flags;
3377
3378 spin_lock_irqsave(&bnad->bna_lock, flags);
3379
3380 if (features & NETIF_F_HW_VLAN_CTAG_RX)
3381 bna_rx_vlan_strip_enable(bnad->rx_info[0].rx);
3382 else
3383 bna_rx_vlan_strip_disable(bnad->rx_info[0].rx);
3384
3385 spin_unlock_irqrestore(&bnad->bna_lock, flags);
3386 }
3387
3388 return 0;
3389}
3390
3372#ifdef CONFIG_NET_POLL_CONTROLLER 3391#ifdef CONFIG_NET_POLL_CONTROLLER
3373static void 3392static void
3374bnad_netpoll(struct net_device *netdev) 3393bnad_netpoll(struct net_device *netdev)
@@ -3416,6 +3435,7 @@ static const struct net_device_ops bnad_netdev_ops = {
3416 .ndo_change_mtu = bnad_change_mtu, 3435 .ndo_change_mtu = bnad_change_mtu,
3417 .ndo_vlan_rx_add_vid = bnad_vlan_rx_add_vid, 3436 .ndo_vlan_rx_add_vid = bnad_vlan_rx_add_vid,
3418 .ndo_vlan_rx_kill_vid = bnad_vlan_rx_kill_vid, 3437 .ndo_vlan_rx_kill_vid = bnad_vlan_rx_kill_vid,
3438 .ndo_set_features = bnad_set_features,
3419#ifdef CONFIG_NET_POLL_CONTROLLER 3439#ifdef CONFIG_NET_POLL_CONTROLLER
3420 .ndo_poll_controller = bnad_netpoll 3440 .ndo_poll_controller = bnad_netpoll
3421#endif 3441#endif
@@ -3428,14 +3448,14 @@ bnad_netdev_init(struct bnad *bnad, bool using_dac)
3428 3448
3429 netdev->hw_features = NETIF_F_SG | NETIF_F_RXCSUM | 3449 netdev->hw_features = NETIF_F_SG | NETIF_F_RXCSUM |
3430 NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | 3450 NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM |
3431 NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_HW_VLAN_CTAG_TX; 3451 NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_HW_VLAN_CTAG_TX |
3452 NETIF_F_HW_VLAN_CTAG_RX;
3432 3453
3433 netdev->vlan_features = NETIF_F_SG | NETIF_F_HIGHDMA | 3454 netdev->vlan_features = NETIF_F_SG | NETIF_F_HIGHDMA |
3434 NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | 3455 NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM |
3435 NETIF_F_TSO | NETIF_F_TSO6; 3456 NETIF_F_TSO | NETIF_F_TSO6;
3436 3457
3437 netdev->features |= netdev->hw_features | 3458 netdev->features |= netdev->hw_features | NETIF_F_HW_VLAN_CTAG_FILTER;
3438 NETIF_F_HW_VLAN_CTAG_RX | NETIF_F_HW_VLAN_CTAG_FILTER;
3439 3459
3440 if (using_dac) 3460 if (using_dac)
3441 netdev->features |= NETIF_F_HIGHDMA; 3461 netdev->features |= NETIF_F_HIGHDMA;
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index da4edc1c77b3..0ac53dd84c61 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -6206,6 +6206,7 @@ static struct pci_driver cxgb4_driver = {
6206 .id_table = cxgb4_pci_tbl, 6206 .id_table = cxgb4_pci_tbl,
6207 .probe = init_one, 6207 .probe = init_one,
6208 .remove = remove_one, 6208 .remove = remove_one,
6209 .shutdown = remove_one,
6209 .err_handler = &cxgb4_eeh, 6210 .err_handler = &cxgb4_eeh,
6210}; 6211};
6211 6212
diff --git a/drivers/net/ethernet/emulex/benet/be.h b/drivers/net/ethernet/emulex/benet/be.h
index bf5ca71df77f..a91267be715a 100644
--- a/drivers/net/ethernet/emulex/benet/be.h
+++ b/drivers/net/ethernet/emulex/benet/be.h
@@ -350,11 +350,13 @@ struct be_drv_stats {
350 u32 roce_drops_crc; 350 u32 roce_drops_crc;
351}; 351};
352 352
353/* A vlan-id of 0xFFFF must be used to clear transparent vlan-tagging */
354#define BE_RESET_VLAN_TAG_ID 0xFFFF
355
353struct be_vf_cfg { 356struct be_vf_cfg {
354 unsigned char mac_addr[ETH_ALEN]; 357 unsigned char mac_addr[ETH_ALEN];
355 int if_handle; 358 int if_handle;
356 int pmac_id; 359 int pmac_id;
357 u16 def_vid;
358 u16 vlan_tag; 360 u16 vlan_tag;
359 u32 tx_rate; 361 u32 tx_rate;
360}; 362};
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
index 34644969a4be..6e10230a2ee0 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -913,24 +913,14 @@ static int be_ipv6_tx_stall_chk(struct be_adapter *adapter,
913 return BE3_chip(adapter) && be_ipv6_exthdr_check(skb); 913 return BE3_chip(adapter) && be_ipv6_exthdr_check(skb);
914} 914}
915 915
916static struct sk_buff *be_xmit_workarounds(struct be_adapter *adapter, 916static struct sk_buff *be_lancer_xmit_workarounds(struct be_adapter *adapter,
917 struct sk_buff *skb, 917 struct sk_buff *skb,
918 bool *skip_hw_vlan) 918 bool *skip_hw_vlan)
919{ 919{
920 struct vlan_ethhdr *veh = (struct vlan_ethhdr *)skb->data; 920 struct vlan_ethhdr *veh = (struct vlan_ethhdr *)skb->data;
921 unsigned int eth_hdr_len; 921 unsigned int eth_hdr_len;
922 struct iphdr *ip; 922 struct iphdr *ip;
923 923
924 /* Lancer, SH-R ASICs have a bug wherein Packets that are 32 bytes or less
925 * may cause a transmit stall on that port. So the work-around is to
926 * pad short packets (<= 32 bytes) to a 36-byte length.
927 */
928 if (unlikely(!BEx_chip(adapter) && skb->len <= 32)) {
929 if (skb_padto(skb, 36))
930 goto tx_drop;
931 skb->len = 36;
932 }
933
934 /* For padded packets, BE HW modifies tot_len field in IP header 924 /* For padded packets, BE HW modifies tot_len field in IP header
935 * incorrecly when VLAN tag is inserted by HW. 925 * incorrecly when VLAN tag is inserted by HW.
936 * For padded packets, Lancer computes incorrect checksum. 926 * For padded packets, Lancer computes incorrect checksum.
@@ -959,7 +949,7 @@ static struct sk_buff *be_xmit_workarounds(struct be_adapter *adapter,
959 vlan_tx_tag_present(skb)) { 949 vlan_tx_tag_present(skb)) {
960 skb = be_insert_vlan_in_pkt(adapter, skb, skip_hw_vlan); 950 skb = be_insert_vlan_in_pkt(adapter, skb, skip_hw_vlan);
961 if (unlikely(!skb)) 951 if (unlikely(!skb))
962 goto tx_drop; 952 goto err;
963 } 953 }
964 954
965 /* HW may lockup when VLAN HW tagging is requested on 955 /* HW may lockup when VLAN HW tagging is requested on
@@ -981,15 +971,39 @@ static struct sk_buff *be_xmit_workarounds(struct be_adapter *adapter,
981 be_vlan_tag_tx_chk(adapter, skb)) { 971 be_vlan_tag_tx_chk(adapter, skb)) {
982 skb = be_insert_vlan_in_pkt(adapter, skb, skip_hw_vlan); 972 skb = be_insert_vlan_in_pkt(adapter, skb, skip_hw_vlan);
983 if (unlikely(!skb)) 973 if (unlikely(!skb))
984 goto tx_drop; 974 goto err;
985 } 975 }
986 976
987 return skb; 977 return skb;
988tx_drop: 978tx_drop:
989 dev_kfree_skb_any(skb); 979 dev_kfree_skb_any(skb);
980err:
990 return NULL; 981 return NULL;
991} 982}
992 983
984static struct sk_buff *be_xmit_workarounds(struct be_adapter *adapter,
985 struct sk_buff *skb,
986 bool *skip_hw_vlan)
987{
988 /* Lancer, SH-R ASICs have a bug wherein Packets that are 32 bytes or
989 * less may cause a transmit stall on that port. So the work-around is
990 * to pad short packets (<= 32 bytes) to a 36-byte length.
991 */
992 if (unlikely(!BEx_chip(adapter) && skb->len <= 32)) {
993 if (skb_padto(skb, 36))
994 return NULL;
995 skb->len = 36;
996 }
997
998 if (BEx_chip(adapter) || lancer_chip(adapter)) {
999 skb = be_lancer_xmit_workarounds(adapter, skb, skip_hw_vlan);
1000 if (!skb)
1001 return NULL;
1002 }
1003
1004 return skb;
1005}
1006
993static netdev_tx_t be_xmit(struct sk_buff *skb, struct net_device *netdev) 1007static netdev_tx_t be_xmit(struct sk_buff *skb, struct net_device *netdev)
994{ 1008{
995 struct be_adapter *adapter = netdev_priv(netdev); 1009 struct be_adapter *adapter = netdev_priv(netdev);
@@ -1157,6 +1171,14 @@ ret:
1157 return status; 1171 return status;
1158} 1172}
1159 1173
1174static void be_clear_promisc(struct be_adapter *adapter)
1175{
1176 adapter->promiscuous = false;
1177 adapter->flags &= ~BE_FLAGS_VLAN_PROMISC;
1178
1179 be_cmd_rx_filter(adapter, IFF_PROMISC, OFF);
1180}
1181
1160static void be_set_rx_mode(struct net_device *netdev) 1182static void be_set_rx_mode(struct net_device *netdev)
1161{ 1183{
1162 struct be_adapter *adapter = netdev_priv(netdev); 1184 struct be_adapter *adapter = netdev_priv(netdev);
@@ -1170,9 +1192,7 @@ static void be_set_rx_mode(struct net_device *netdev)
1170 1192
1171 /* BE was previously in promiscuous mode; disable it */ 1193 /* BE was previously in promiscuous mode; disable it */
1172 if (adapter->promiscuous) { 1194 if (adapter->promiscuous) {
1173 adapter->promiscuous = false; 1195 be_clear_promisc(adapter);
1174 be_cmd_rx_filter(adapter, IFF_PROMISC, OFF);
1175
1176 if (adapter->vlans_added) 1196 if (adapter->vlans_added)
1177 be_vid_config(adapter); 1197 be_vid_config(adapter);
1178 } 1198 }
@@ -1287,24 +1307,20 @@ static int be_set_vf_vlan(struct net_device *netdev,
1287 1307
1288 if (vlan || qos) { 1308 if (vlan || qos) {
1289 vlan |= qos << VLAN_PRIO_SHIFT; 1309 vlan |= qos << VLAN_PRIO_SHIFT;
1290 if (vf_cfg->vlan_tag != vlan) { 1310 if (vf_cfg->vlan_tag != vlan)
1291 /* If this is new value, program it. Else skip. */
1292 vf_cfg->vlan_tag = vlan;
1293 status = be_cmd_set_hsw_config(adapter, vlan, vf + 1, 1311 status = be_cmd_set_hsw_config(adapter, vlan, vf + 1,
1294 vf_cfg->if_handle, 0); 1312 vf_cfg->if_handle, 0);
1295 }
1296 } else { 1313 } else {
1297 /* Reset Transparent Vlan Tagging. */ 1314 /* Reset Transparent Vlan Tagging. */
1298 vf_cfg->vlan_tag = 0; 1315 status = be_cmd_set_hsw_config(adapter, BE_RESET_VLAN_TAG_ID,
1299 vlan = vf_cfg->def_vid; 1316 vf + 1, vf_cfg->if_handle, 0);
1300 status = be_cmd_set_hsw_config(adapter, vlan, vf + 1,
1301 vf_cfg->if_handle, 0);
1302 } 1317 }
1303 1318
1304 1319 if (!status)
1305 if (status) 1320 vf_cfg->vlan_tag = vlan;
1321 else
1306 dev_info(&adapter->pdev->dev, 1322 dev_info(&adapter->pdev->dev,
1307 "VLAN %d config on VF %d failed\n", vlan, vf); 1323 "VLAN %d config on VF %d failed\n", vlan, vf);
1308 return status; 1324 return status;
1309} 1325}
1310 1326
@@ -3022,11 +3038,11 @@ static int be_vf_setup_init(struct be_adapter *adapter)
3022 3038
3023static int be_vf_setup(struct be_adapter *adapter) 3039static int be_vf_setup(struct be_adapter *adapter)
3024{ 3040{
3041 struct device *dev = &adapter->pdev->dev;
3025 struct be_vf_cfg *vf_cfg; 3042 struct be_vf_cfg *vf_cfg;
3026 u16 def_vlan, lnk_speed;
3027 int status, old_vfs, vf; 3043 int status, old_vfs, vf;
3028 struct device *dev = &adapter->pdev->dev;
3029 u32 privileges; 3044 u32 privileges;
3045 u16 lnk_speed;
3030 3046
3031 old_vfs = pci_num_vf(adapter->pdev); 3047 old_vfs = pci_num_vf(adapter->pdev);
3032 if (old_vfs) { 3048 if (old_vfs) {
@@ -3093,12 +3109,6 @@ static int be_vf_setup(struct be_adapter *adapter)
3093 if (!status) 3109 if (!status)
3094 vf_cfg->tx_rate = lnk_speed; 3110 vf_cfg->tx_rate = lnk_speed;
3095 3111
3096 status = be_cmd_get_hsw_config(adapter, &def_vlan,
3097 vf + 1, vf_cfg->if_handle, NULL);
3098 if (status)
3099 goto err;
3100 vf_cfg->def_vid = def_vlan;
3101
3102 if (!old_vfs) 3112 if (!old_vfs)
3103 be_cmd_enable_vf(adapter, vf + 1); 3113 be_cmd_enable_vf(adapter, vf + 1);
3104 } 3114 }
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index 903362a7b584..479a7cba45c0 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -389,12 +389,6 @@ fec_enet_start_xmit(struct sk_buff *skb, struct net_device *ndev)
389 netdev_err(ndev, "Tx DMA memory map failed\n"); 389 netdev_err(ndev, "Tx DMA memory map failed\n");
390 return NETDEV_TX_OK; 390 return NETDEV_TX_OK;
391 } 391 }
392 /* Send it on its way. Tell FEC it's ready, interrupt when done,
393 * it's the last BD of the frame, and to put the CRC on the end.
394 */
395 status |= (BD_ENET_TX_READY | BD_ENET_TX_INTR
396 | BD_ENET_TX_LAST | BD_ENET_TX_TC);
397 bdp->cbd_sc = status;
398 392
399 if (fep->bufdesc_ex) { 393 if (fep->bufdesc_ex) {
400 394
@@ -416,6 +410,13 @@ fec_enet_start_xmit(struct sk_buff *skb, struct net_device *ndev)
416 } 410 }
417 } 411 }
418 412
413 /* Send it on its way. Tell FEC it's ready, interrupt when done,
414 * it's the last BD of the frame, and to put the CRC on the end.
415 */
416 status |= (BD_ENET_TX_READY | BD_ENET_TX_INTR
417 | BD_ENET_TX_LAST | BD_ENET_TX_TC);
418 bdp->cbd_sc = status;
419
419 bdp_pre = fec_enet_get_prevdesc(bdp, fep); 420 bdp_pre = fec_enet_get_prevdesc(bdp, fep);
420 if ((id_entry->driver_data & FEC_QUIRK_ERR006358) && 421 if ((id_entry->driver_data & FEC_QUIRK_ERR006358) &&
421 !(bdp_pre->cbd_sc & BD_ENET_TX_READY)) { 422 !(bdp_pre->cbd_sc & BD_ENET_TX_READY)) {
diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4.h b/drivers/net/ethernet/mellanox/mlx4/mlx4.h
index 6b65f7795215..7aec6c833973 100644
--- a/drivers/net/ethernet/mellanox/mlx4/mlx4.h
+++ b/drivers/net/ethernet/mellanox/mlx4/mlx4.h
@@ -51,8 +51,8 @@
51 51
52#define DRV_NAME "mlx4_core" 52#define DRV_NAME "mlx4_core"
53#define PFX DRV_NAME ": " 53#define PFX DRV_NAME ": "
54#define DRV_VERSION "1.1" 54#define DRV_VERSION "2.2-1"
55#define DRV_RELDATE "Dec, 2011" 55#define DRV_RELDATE "Feb, 2014"
56 56
57#define MLX4_FS_UDP_UC_EN (1 << 1) 57#define MLX4_FS_UDP_UC_EN (1 << 1)
58#define MLX4_FS_TCP_UC_EN (1 << 2) 58#define MLX4_FS_TCP_UC_EN (1 << 2)
diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
index 4ff7da83c4b3..69e1f36858e0 100644
--- a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
+++ b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
@@ -57,8 +57,8 @@
57#include "en_port.h" 57#include "en_port.h"
58 58
59#define DRV_NAME "mlx4_en" 59#define DRV_NAME "mlx4_en"
60#define DRV_VERSION "2.0" 60#define DRV_VERSION "2.2-1"
61#define DRV_RELDATE "Dec 2011" 61#define DRV_RELDATE "Feb 2014"
62 62
63#define MLX4_EN_MSG_LEVEL (NETIF_MSG_LINK | NETIF_MSG_IFDOWN) 63#define MLX4_EN_MSG_LEVEL (NETIF_MSG_LINK | NETIF_MSG_IFDOWN)
64 64
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c
index 81df046a6d69..6f7c866d0bfa 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c
@@ -46,8 +46,8 @@
46#include "mlx5_core.h" 46#include "mlx5_core.h"
47 47
48#define DRIVER_NAME "mlx5_core" 48#define DRIVER_NAME "mlx5_core"
49#define DRIVER_VERSION "1.0" 49#define DRIVER_VERSION "2.2-1"
50#define DRIVER_RELDATE "June 2013" 50#define DRIVER_RELDATE "Feb 2014"
51 51
52MODULE_AUTHOR("Eli Cohen <eli@mellanox.com>"); 52MODULE_AUTHOR("Eli Cohen <eli@mellanox.com>");
53MODULE_DESCRIPTION("Mellanox ConnectX-IB HCA core library"); 53MODULE_DESCRIPTION("Mellanox ConnectX-IB HCA core library");
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c
index 0f39778e0e5b..3b83fbde4975 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c
@@ -345,6 +345,7 @@ int qlcnic_83xx_setup_intr(struct qlcnic_adapter *adapter)
345 if (qlcnic_sriov_vf_check(adapter)) 345 if (qlcnic_sriov_vf_check(adapter))
346 return -EINVAL; 346 return -EINVAL;
347 num_msix = 1; 347 num_msix = 1;
348 adapter->drv_sds_rings = QLCNIC_SINGLE_RING;
348 adapter->drv_tx_rings = QLCNIC_SINGLE_RING; 349 adapter->drv_tx_rings = QLCNIC_SINGLE_RING;
349 } 350 }
350 } 351 }
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_dcb.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_dcb.c
index 77f1bce432d2..7d4f54912bad 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_dcb.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_dcb.c
@@ -807,7 +807,7 @@ qlcnic_dcb_get_pg_tc_cfg_tx(struct net_device *netdev, int tc, u8 *prio,
807 !type->tc_param_valid) 807 !type->tc_param_valid)
808 return; 808 return;
809 809
810 if (tc < 0 || (tc > QLC_DCB_MAX_TC)) 810 if (tc < 0 || (tc >= QLC_DCB_MAX_TC))
811 return; 811 return;
812 812
813 tc_cfg = &type->tc_cfg[tc]; 813 tc_cfg = &type->tc_cfg[tc];
@@ -843,7 +843,7 @@ static void qlcnic_dcb_get_pg_bwg_cfg_tx(struct net_device *netdev, int pgid,
843 !type->tc_param_valid) 843 !type->tc_param_valid)
844 return; 844 return;
845 845
846 if (pgid < 0 || pgid > QLC_DCB_MAX_PG) 846 if (pgid < 0 || pgid >= QLC_DCB_MAX_PG)
847 return; 847 return;
848 848
849 pgcfg = &type->pg_cfg[pgid]; 849 pgcfg = &type->pg_cfg[pgid];
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
index a33547292878..4b92d9d90267 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
@@ -825,9 +825,10 @@ static int qlcnic_82xx_setup_intr(struct qlcnic_adapter *adapter)
825 825
826 if (!(adapter->flags & QLCNIC_MSIX_ENABLED)) { 826 if (!(adapter->flags & QLCNIC_MSIX_ENABLED)) {
827 qlcnic_disable_multi_tx(adapter); 827 qlcnic_disable_multi_tx(adapter);
828 adapter->drv_sds_rings = QLCNIC_SINGLE_RING;
828 829
829 err = qlcnic_enable_msi_legacy(adapter); 830 err = qlcnic_enable_msi_legacy(adapter);
830 if (!err) 831 if (err)
831 return err; 832 return err;
832 } 833 }
833 } 834 }
@@ -3872,7 +3873,7 @@ int qlcnic_validate_rings(struct qlcnic_adapter *adapter, __u32 ring_cnt,
3872 strcpy(buf, "Tx"); 3873 strcpy(buf, "Tx");
3873 } 3874 }
3874 3875
3875 if (!qlcnic_use_msi_x && !qlcnic_use_msi) { 3876 if (!QLCNIC_IS_MSI_FAMILY(adapter)) {
3876 netdev_err(netdev, "No RSS/TSS support in INT-x mode\n"); 3877 netdev_err(netdev, "No RSS/TSS support in INT-x mode\n");
3877 return -EINVAL; 3878 return -EINVAL;
3878 } 3879 }
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_pf.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_pf.c
index a28460cf873d..14f748cbf0de 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_pf.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_pf.c
@@ -13,8 +13,6 @@
13#define QLC_VF_MIN_TX_RATE 100 13#define QLC_VF_MIN_TX_RATE 100
14#define QLC_VF_MAX_TX_RATE 9999 14#define QLC_VF_MAX_TX_RATE 9999
15#define QLC_MAC_OPCODE_MASK 0x7 15#define QLC_MAC_OPCODE_MASK 0x7
16#define QLC_MAC_STAR_ADD 6
17#define QLC_MAC_STAR_DEL 7
18#define QLC_VF_FLOOD_BIT BIT_16 16#define QLC_VF_FLOOD_BIT BIT_16
19#define QLC_FLOOD_MODE 0x5 17#define QLC_FLOOD_MODE 0x5
20#define QLC_SRIOV_ALLOW_VLAN0 BIT_19 18#define QLC_SRIOV_ALLOW_VLAN0 BIT_19
@@ -1210,13 +1208,6 @@ static int qlcnic_sriov_validate_cfg_macvlan(struct qlcnic_adapter *adapter,
1210 struct qlcnic_vport *vp = vf->vp; 1208 struct qlcnic_vport *vp = vf->vp;
1211 u8 op, new_op; 1209 u8 op, new_op;
1212 1210
1213 if (((cmd->req.arg[1] & QLC_MAC_OPCODE_MASK) == QLC_MAC_STAR_ADD) ||
1214 ((cmd->req.arg[1] & QLC_MAC_OPCODE_MASK) == QLC_MAC_STAR_DEL)) {
1215 netdev_err(adapter->netdev, "MAC + any VLAN filter not allowed from VF %d\n",
1216 vf->pci_func);
1217 return -EINVAL;
1218 }
1219
1220 if (!(cmd->req.arg[1] & BIT_8)) 1211 if (!(cmd->req.arg[1] & BIT_8))
1221 return -EINVAL; 1212 return -EINVAL;
1222 1213
diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
index 91a67ae8f17b..e9779653cd4c 100644
--- a/drivers/net/ethernet/realtek/r8169.c
+++ b/drivers/net/ethernet/realtek/r8169.c
@@ -7118,6 +7118,8 @@ rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
7118 } 7118 }
7119 7119
7120 mutex_init(&tp->wk.mutex); 7120 mutex_init(&tp->wk.mutex);
7121 u64_stats_init(&tp->rx_stats.syncp);
7122 u64_stats_init(&tp->tx_stats.syncp);
7121 7123
7122 /* Get MAC address */ 7124 /* Get MAC address */
7123 for (i = 0; i < ETH_ALEN; i++) 7125 for (i = 0; i < ETH_ALEN; i++)
diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c
index 28275e395cb8..722344fcd155 100644
--- a/drivers/net/ethernet/sfc/ptp.c
+++ b/drivers/net/ethernet/sfc/ptp.c
@@ -1652,6 +1652,13 @@ void efx_ptp_event(struct efx_nic *efx, efx_qword_t *ev)
1652 struct efx_ptp_data *ptp = efx->ptp_data; 1652 struct efx_ptp_data *ptp = efx->ptp_data;
1653 int code = EFX_QWORD_FIELD(*ev, MCDI_EVENT_CODE); 1653 int code = EFX_QWORD_FIELD(*ev, MCDI_EVENT_CODE);
1654 1654
1655 if (!ptp) {
1656 if (net_ratelimit())
1657 netif_warn(efx, drv, efx->net_dev,
1658 "Received PTP event but PTP not set up\n");
1659 return;
1660 }
1661
1655 if (!ptp->enabled) 1662 if (!ptp->enabled)
1656 return; 1663 return;
1657 1664
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index a2e7d2c96e36..078ad0ec8593 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -1705,7 +1705,7 @@ static int stmmac_open(struct net_device *dev)
1705 priv->dma_rx_size = STMMAC_ALIGN(dma_rxsize); 1705 priv->dma_rx_size = STMMAC_ALIGN(dma_rxsize);
1706 priv->dma_buf_sz = STMMAC_ALIGN(buf_sz); 1706 priv->dma_buf_sz = STMMAC_ALIGN(buf_sz);
1707 1707
1708 alloc_dma_desc_resources(priv); 1708 ret = alloc_dma_desc_resources(priv);
1709 if (ret < 0) { 1709 if (ret < 0) {
1710 pr_err("%s: DMA descriptors allocation failed\n", __func__); 1710 pr_err("%s: DMA descriptors allocation failed\n", __func__);
1711 goto dma_desc_error; 1711 goto dma_desc_error;
diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index 0b6a2802d51b..53f85dd3bbad 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -1164,11 +1164,17 @@ static void cpsw_init_host_port(struct cpsw_priv *priv)
1164 1164
1165static void cpsw_slave_stop(struct cpsw_slave *slave, struct cpsw_priv *priv) 1165static void cpsw_slave_stop(struct cpsw_slave *slave, struct cpsw_priv *priv)
1166{ 1166{
1167 u32 slave_port;
1168
1169 slave_port = cpsw_get_slave_port(priv, slave->slave_num);
1170
1167 if (!slave->phy) 1171 if (!slave->phy)
1168 return; 1172 return;
1169 phy_stop(slave->phy); 1173 phy_stop(slave->phy);
1170 phy_disconnect(slave->phy); 1174 phy_disconnect(slave->phy);
1171 slave->phy = NULL; 1175 slave->phy = NULL;
1176 cpsw_ale_control_set(priv->ale, slave_port,
1177 ALE_PORT_STATE, ALE_PORT_STATE_DISABLE);
1172} 1178}
1173 1179
1174static int cpsw_ndo_open(struct net_device *ndev) 1180static int cpsw_ndo_open(struct net_device *ndev)
diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index 44227c25a276..c683ac2c8c94 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -506,6 +506,9 @@ static int macvlan_change_mtu(struct net_device *dev, int new_mtu)
506static struct lock_class_key macvlan_netdev_xmit_lock_key; 506static struct lock_class_key macvlan_netdev_xmit_lock_key;
507static struct lock_class_key macvlan_netdev_addr_lock_key; 507static struct lock_class_key macvlan_netdev_addr_lock_key;
508 508
509#define ALWAYS_ON_FEATURES \
510 (NETIF_F_SG | NETIF_F_GEN_CSUM | NETIF_F_GSO_SOFTWARE | NETIF_F_LLTX)
511
509#define MACVLAN_FEATURES \ 512#define MACVLAN_FEATURES \
510 (NETIF_F_SG | NETIF_F_ALL_CSUM | NETIF_F_HIGHDMA | NETIF_F_FRAGLIST | \ 513 (NETIF_F_SG | NETIF_F_ALL_CSUM | NETIF_F_HIGHDMA | NETIF_F_FRAGLIST | \
511 NETIF_F_GSO | NETIF_F_TSO | NETIF_F_UFO | NETIF_F_GSO_ROBUST | \ 514 NETIF_F_GSO | NETIF_F_TSO | NETIF_F_UFO | NETIF_F_GSO_ROBUST | \
@@ -538,7 +541,7 @@ static int macvlan_init(struct net_device *dev)
538 dev->state = (dev->state & ~MACVLAN_STATE_MASK) | 541 dev->state = (dev->state & ~MACVLAN_STATE_MASK) |
539 (lowerdev->state & MACVLAN_STATE_MASK); 542 (lowerdev->state & MACVLAN_STATE_MASK);
540 dev->features = lowerdev->features & MACVLAN_FEATURES; 543 dev->features = lowerdev->features & MACVLAN_FEATURES;
541 dev->features |= NETIF_F_LLTX; 544 dev->features |= ALWAYS_ON_FEATURES;
542 dev->gso_max_size = lowerdev->gso_max_size; 545 dev->gso_max_size = lowerdev->gso_max_size;
543 dev->iflink = lowerdev->ifindex; 546 dev->iflink = lowerdev->ifindex;
544 dev->hard_header_len = lowerdev->hard_header_len; 547 dev->hard_header_len = lowerdev->hard_header_len;
@@ -692,7 +695,7 @@ static netdev_features_t macvlan_fix_features(struct net_device *dev,
692 features = netdev_increment_features(vlan->lowerdev->features, 695 features = netdev_increment_features(vlan->lowerdev->features,
693 features, 696 features,
694 mask); 697 mask);
695 features |= NETIF_F_LLTX; 698 features |= ALWAYS_ON_FEATURES;
696 699
697 return features; 700 return features;
698} 701}
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index a70b604ac644..a2fbb3e1db9a 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -933,6 +933,8 @@ int genphy_read_status(struct phy_device *phydev)
933 int err; 933 int err;
934 int lpa; 934 int lpa;
935 int lpagb = 0; 935 int lpagb = 0;
936 int common_adv;
937 int common_adv_gb = 0;
936 938
937 /* Update the link, but return if there was an error */ 939 /* Update the link, but return if there was an error */
938 err = genphy_update_link(phydev); 940 err = genphy_update_link(phydev);
@@ -954,7 +956,7 @@ int genphy_read_status(struct phy_device *phydev)
954 956
955 phydev->lp_advertising = 957 phydev->lp_advertising =
956 mii_stat1000_to_ethtool_lpa_t(lpagb); 958 mii_stat1000_to_ethtool_lpa_t(lpagb);
957 lpagb &= adv << 2; 959 common_adv_gb = lpagb & adv << 2;
958 } 960 }
959 961
960 lpa = phy_read(phydev, MII_LPA); 962 lpa = phy_read(phydev, MII_LPA);
@@ -967,25 +969,25 @@ int genphy_read_status(struct phy_device *phydev)
967 if (adv < 0) 969 if (adv < 0)
968 return adv; 970 return adv;
969 971
970 lpa &= adv; 972 common_adv = lpa & adv;
971 973
972 phydev->speed = SPEED_10; 974 phydev->speed = SPEED_10;
973 phydev->duplex = DUPLEX_HALF; 975 phydev->duplex = DUPLEX_HALF;
974 phydev->pause = 0; 976 phydev->pause = 0;
975 phydev->asym_pause = 0; 977 phydev->asym_pause = 0;
976 978
977 if (lpagb & (LPA_1000FULL | LPA_1000HALF)) { 979 if (common_adv_gb & (LPA_1000FULL | LPA_1000HALF)) {
978 phydev->speed = SPEED_1000; 980 phydev->speed = SPEED_1000;
979 981
980 if (lpagb & LPA_1000FULL) 982 if (common_adv_gb & LPA_1000FULL)
981 phydev->duplex = DUPLEX_FULL; 983 phydev->duplex = DUPLEX_FULL;
982 } else if (lpa & (LPA_100FULL | LPA_100HALF)) { 984 } else if (common_adv & (LPA_100FULL | LPA_100HALF)) {
983 phydev->speed = SPEED_100; 985 phydev->speed = SPEED_100;
984 986
985 if (lpa & LPA_100FULL) 987 if (common_adv & LPA_100FULL)
986 phydev->duplex = DUPLEX_FULL; 988 phydev->duplex = DUPLEX_FULL;
987 } else 989 } else
988 if (lpa & LPA_10FULL) 990 if (common_adv & LPA_10FULL)
989 phydev->duplex = DUPLEX_FULL; 991 phydev->duplex = DUPLEX_FULL;
990 992
991 if (phydev->duplex == DUPLEX_FULL) { 993 if (phydev->duplex == DUPLEX_FULL) {
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 8fe9cb7d0f72..26f8635b027d 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -1686,7 +1686,9 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
1686 TUN_USER_FEATURES | NETIF_F_HW_VLAN_CTAG_TX | 1686 TUN_USER_FEATURES | NETIF_F_HW_VLAN_CTAG_TX |
1687 NETIF_F_HW_VLAN_STAG_TX; 1687 NETIF_F_HW_VLAN_STAG_TX;
1688 dev->features = dev->hw_features; 1688 dev->features = dev->hw_features;
1689 dev->vlan_features = dev->features; 1689 dev->vlan_features = dev->features &
1690 ~(NETIF_F_HW_VLAN_CTAG_TX |
1691 NETIF_F_HW_VLAN_STAG_TX);
1690 1692
1691 INIT_LIST_HEAD(&tun->disabled); 1693 INIT_LIST_HEAD(&tun->disabled);
1692 err = tun_attach(tun, file, false); 1694 err = tun_attach(tun, file, false);
diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
index 955df81a4358..d2e6fdb25e28 100644
--- a/drivers/net/usb/ax88179_178a.c
+++ b/drivers/net/usb/ax88179_178a.c
@@ -1395,6 +1395,19 @@ static const struct driver_info ax88178a_info = {
1395 .tx_fixup = ax88179_tx_fixup, 1395 .tx_fixup = ax88179_tx_fixup,
1396}; 1396};
1397 1397
1398static const struct driver_info dlink_dub1312_info = {
1399 .description = "D-Link DUB-1312 USB 3.0 to Gigabit Ethernet Adapter",
1400 .bind = ax88179_bind,
1401 .unbind = ax88179_unbind,
1402 .status = ax88179_status,
1403 .link_reset = ax88179_link_reset,
1404 .reset = ax88179_reset,
1405 .stop = ax88179_stop,
1406 .flags = FLAG_ETHER | FLAG_FRAMING_AX,
1407 .rx_fixup = ax88179_rx_fixup,
1408 .tx_fixup = ax88179_tx_fixup,
1409};
1410
1398static const struct driver_info sitecom_info = { 1411static const struct driver_info sitecom_info = {
1399 .description = "Sitecom USB 3.0 to Gigabit Adapter", 1412 .description = "Sitecom USB 3.0 to Gigabit Adapter",
1400 .bind = ax88179_bind, 1413 .bind = ax88179_bind,
@@ -1421,6 +1434,19 @@ static const struct driver_info samsung_info = {
1421 .tx_fixup = ax88179_tx_fixup, 1434 .tx_fixup = ax88179_tx_fixup,
1422}; 1435};
1423 1436
1437static const struct driver_info lenovo_info = {
1438 .description = "Lenovo OneLinkDock Gigabit LAN",
1439 .bind = ax88179_bind,
1440 .unbind = ax88179_unbind,
1441 .status = ax88179_status,
1442 .link_reset = ax88179_link_reset,
1443 .reset = ax88179_reset,
1444 .stop = ax88179_stop,
1445 .flags = FLAG_ETHER | FLAG_FRAMING_AX,
1446 .rx_fixup = ax88179_rx_fixup,
1447 .tx_fixup = ax88179_tx_fixup,
1448};
1449
1424static const struct usb_device_id products[] = { 1450static const struct usb_device_id products[] = {
1425{ 1451{
1426 /* ASIX AX88179 10/100/1000 */ 1452 /* ASIX AX88179 10/100/1000 */
@@ -1431,6 +1457,10 @@ static const struct usb_device_id products[] = {
1431 USB_DEVICE(0x0b95, 0x178a), 1457 USB_DEVICE(0x0b95, 0x178a),
1432 .driver_info = (unsigned long)&ax88178a_info, 1458 .driver_info = (unsigned long)&ax88178a_info,
1433}, { 1459}, {
1460 /* D-Link DUB-1312 USB 3.0 to Gigabit Ethernet Adapter */
1461 USB_DEVICE(0x2001, 0x4a00),
1462 .driver_info = (unsigned long)&dlink_dub1312_info,
1463}, {
1434 /* Sitecom USB 3.0 to Gigabit Adapter */ 1464 /* Sitecom USB 3.0 to Gigabit Adapter */
1435 USB_DEVICE(0x0df6, 0x0072), 1465 USB_DEVICE(0x0df6, 0x0072),
1436 .driver_info = (unsigned long)&sitecom_info, 1466 .driver_info = (unsigned long)&sitecom_info,
@@ -1438,6 +1468,10 @@ static const struct usb_device_id products[] = {
1438 /* Samsung USB Ethernet Adapter */ 1468 /* Samsung USB Ethernet Adapter */
1439 USB_DEVICE(0x04e8, 0xa100), 1469 USB_DEVICE(0x04e8, 0xa100),
1440 .driver_info = (unsigned long)&samsung_info, 1470 .driver_info = (unsigned long)&samsung_info,
1471}, {
1472 /* Lenovo OneLinkDock Gigabit LAN */
1473 USB_DEVICE(0x17ef, 0x304b),
1474 .driver_info = (unsigned long)&lenovo_info,
1441}, 1475},
1442 { }, 1476 { },
1443}; 1477};
diff --git a/drivers/net/veth.c b/drivers/net/veth.c
index 34b52638e12d..3aca92e80e1e 100644
--- a/drivers/net/veth.c
+++ b/drivers/net/veth.c
@@ -277,7 +277,8 @@ static void veth_setup(struct net_device *dev)
277 dev->ethtool_ops = &veth_ethtool_ops; 277 dev->ethtool_ops = &veth_ethtool_ops;
278 dev->features |= NETIF_F_LLTX; 278 dev->features |= NETIF_F_LLTX;
279 dev->features |= VETH_FEATURES; 279 dev->features |= VETH_FEATURES;
280 dev->vlan_features = dev->features; 280 dev->vlan_features = dev->features &
281 ~(NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_STAG_TX);
281 dev->destructor = veth_dev_free; 282 dev->destructor = veth_dev_free;
282 283
283 dev->hw_features = VETH_FEATURES; 284 dev->hw_features = VETH_FEATURES;
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index d75f8edf4fb3..5632a99cbbd2 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -1711,7 +1711,8 @@ static int virtnet_probe(struct virtio_device *vdev)
1711 /* If we can receive ANY GSO packets, we must allocate large ones. */ 1711 /* If we can receive ANY GSO packets, we must allocate large ones. */
1712 if (virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO4) || 1712 if (virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO4) ||
1713 virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO6) || 1713 virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO6) ||
1714 virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_ECN)) 1714 virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_ECN) ||
1715 virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_UFO))
1715 vi->big_packets = true; 1716 vi->big_packets = true;
1716 1717
1717 if (virtio_has_feature(vdev, VIRTIO_NET_F_MRG_RXBUF)) 1718 if (virtio_has_feature(vdev, VIRTIO_NET_F_MRG_RXBUF))
diff --git a/drivers/net/wireless/ath/ath9k/ar9462_2p0_initvals.h b/drivers/net/wireless/ath/ath9k/ar9462_2p0_initvals.h
index 1cc13569b17b..1b6b4d0cfa97 100644
--- a/drivers/net/wireless/ath/ath9k/ar9462_2p0_initvals.h
+++ b/drivers/net/wireless/ath/ath9k/ar9462_2p0_initvals.h
@@ -57,7 +57,7 @@ static const u32 ar9462_2p0_baseband_postamble[][5] = {
57 {0x00009e14, 0x37b95d5e, 0x37b9605e, 0x3236605e, 0x32365a5e}, 57 {0x00009e14, 0x37b95d5e, 0x37b9605e, 0x3236605e, 0x32365a5e},
58 {0x00009e18, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, 58 {0x00009e18, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
59 {0x00009e1c, 0x0001cf9c, 0x0001cf9c, 0x00021f9c, 0x00021f9c}, 59 {0x00009e1c, 0x0001cf9c, 0x0001cf9c, 0x00021f9c, 0x00021f9c},
60 {0x00009e20, 0x000003b5, 0x000003b5, 0x000003ce, 0x000003ce}, 60 {0x00009e20, 0x000003a5, 0x000003a5, 0x000003a5, 0x000003a5},
61 {0x00009e2c, 0x0000001c, 0x0000001c, 0x00000021, 0x00000021}, 61 {0x00009e2c, 0x0000001c, 0x0000001c, 0x00000021, 0x00000021},
62 {0x00009e3c, 0xcf946220, 0xcf946220, 0xcfd5c782, 0xcfd5c282}, 62 {0x00009e3c, 0xcf946220, 0xcf946220, 0xcfd5c782, 0xcfd5c282},
63 {0x00009e44, 0x62321e27, 0x62321e27, 0xfe291e27, 0xfe291e27}, 63 {0x00009e44, 0x62321e27, 0x62321e27, 0xfe291e27, 0xfe291e27},
@@ -96,7 +96,7 @@ static const u32 ar9462_2p0_baseband_postamble[][5] = {
96 {0x0000ae04, 0x001c0000, 0x001c0000, 0x001c0000, 0x00100000}, 96 {0x0000ae04, 0x001c0000, 0x001c0000, 0x001c0000, 0x00100000},
97 {0x0000ae18, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, 97 {0x0000ae18, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
98 {0x0000ae1c, 0x0000019c, 0x0000019c, 0x0000019c, 0x0000019c}, 98 {0x0000ae1c, 0x0000019c, 0x0000019c, 0x0000019c, 0x0000019c},
99 {0x0000ae20, 0x000001b5, 0x000001b5, 0x000001ce, 0x000001ce}, 99 {0x0000ae20, 0x000001a6, 0x000001a6, 0x000001aa, 0x000001aa},
100 {0x0000b284, 0x00000000, 0x00000000, 0x00000550, 0x00000550}, 100 {0x0000b284, 0x00000000, 0x00000000, 0x00000550, 0x00000550},
101}; 101};
102 102
diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c
index 5db01b4212c8..2509c2ff0828 100644
--- a/drivers/net/wireless/ath/ath9k/hw.c
+++ b/drivers/net/wireless/ath/ath9k/hw.c
@@ -1533,7 +1533,7 @@ EXPORT_SYMBOL(ath9k_hw_check_nav);
1533bool ath9k_hw_check_alive(struct ath_hw *ah) 1533bool ath9k_hw_check_alive(struct ath_hw *ah)
1534{ 1534{
1535 int count = 50; 1535 int count = 50;
1536 u32 reg; 1536 u32 reg, last_val;
1537 1537
1538 if (AR_SREV_9300(ah)) 1538 if (AR_SREV_9300(ah))
1539 return !ath9k_hw_detect_mac_hang(ah); 1539 return !ath9k_hw_detect_mac_hang(ah);
@@ -1541,9 +1541,13 @@ bool ath9k_hw_check_alive(struct ath_hw *ah)
1541 if (AR_SREV_9285_12_OR_LATER(ah)) 1541 if (AR_SREV_9285_12_OR_LATER(ah))
1542 return true; 1542 return true;
1543 1543
1544 last_val = REG_READ(ah, AR_OBS_BUS_1);
1544 do { 1545 do {
1545 reg = REG_READ(ah, AR_OBS_BUS_1); 1546 reg = REG_READ(ah, AR_OBS_BUS_1);
1547 if (reg != last_val)
1548 return true;
1546 1549
1550 last_val = reg;
1547 if ((reg & 0x7E7FFFEF) == 0x00702400) 1551 if ((reg & 0x7E7FFFEF) == 0x00702400)
1548 continue; 1552 continue;
1549 1553
@@ -1555,6 +1559,8 @@ bool ath9k_hw_check_alive(struct ath_hw *ah)
1555 default: 1559 default:
1556 return true; 1560 return true;
1557 } 1561 }
1562
1563 udelay(1);
1558 } while (count-- > 0); 1564 } while (count-- > 0);
1559 1565
1560 return false; 1566 return false;
diff --git a/drivers/net/wireless/ath/ath9k/recv.c b/drivers/net/wireless/ath/ath9k/recv.c
index 076dae1e5ab7..425e34f94af4 100644
--- a/drivers/net/wireless/ath/ath9k/recv.c
+++ b/drivers/net/wireless/ath/ath9k/recv.c
@@ -732,11 +732,18 @@ static struct ath_rxbuf *ath_get_next_rx_buf(struct ath_softc *sc,
732 return NULL; 732 return NULL;
733 733
734 /* 734 /*
735 * mark descriptor as zero-length and set the 'more' 735 * Re-check previous descriptor, in case it has been filled
736 * flag to ensure that both buffers get discarded 736 * in the mean time.
737 */ 737 */
738 rs->rs_datalen = 0; 738 ret = ath9k_hw_rxprocdesc(ah, ds, rs);
739 rs->rs_more = true; 739 if (ret == -EINPROGRESS) {
740 /*
741 * mark descriptor as zero-length and set the 'more'
742 * flag to ensure that both buffers get discarded
743 */
744 rs->rs_datalen = 0;
745 rs->rs_more = true;
746 }
740 } 747 }
741 748
742 list_del(&bf->list); 749 list_del(&bf->list);
@@ -787,32 +794,32 @@ static int ath9k_rx_skb_preprocess(struct ath_softc *sc,
787 struct ath_common *common = ath9k_hw_common(ah); 794 struct ath_common *common = ath9k_hw_common(ah);
788 struct ieee80211_hdr *hdr; 795 struct ieee80211_hdr *hdr;
789 bool discard_current = sc->rx.discard_next; 796 bool discard_current = sc->rx.discard_next;
790 int ret = 0;
791 797
792 /* 798 /*
793 * Discard corrupt descriptors which are marked in 799 * Discard corrupt descriptors which are marked in
794 * ath_get_next_rx_buf(). 800 * ath_get_next_rx_buf().
795 */ 801 */
796 sc->rx.discard_next = rx_stats->rs_more;
797 if (discard_current) 802 if (discard_current)
798 return -EINVAL; 803 goto corrupt;
804
805 sc->rx.discard_next = false;
799 806
800 /* 807 /*
801 * Discard zero-length packets. 808 * Discard zero-length packets.
802 */ 809 */
803 if (!rx_stats->rs_datalen) { 810 if (!rx_stats->rs_datalen) {
804 RX_STAT_INC(rx_len_err); 811 RX_STAT_INC(rx_len_err);
805 return -EINVAL; 812 goto corrupt;
806 } 813 }
807 814
808 /* 815 /*
809 * rs_status follows rs_datalen so if rs_datalen is too large 816 * rs_status follows rs_datalen so if rs_datalen is too large
810 * we can take a hint that hardware corrupted it, so ignore 817 * we can take a hint that hardware corrupted it, so ignore
811 * those frames. 818 * those frames.
812 */ 819 */
813 if (rx_stats->rs_datalen > (common->rx_bufsize - ah->caps.rx_status_len)) { 820 if (rx_stats->rs_datalen > (common->rx_bufsize - ah->caps.rx_status_len)) {
814 RX_STAT_INC(rx_len_err); 821 RX_STAT_INC(rx_len_err);
815 return -EINVAL; 822 goto corrupt;
816 } 823 }
817 824
818 /* Only use status info from the last fragment */ 825 /* Only use status info from the last fragment */
@@ -826,10 +833,8 @@ static int ath9k_rx_skb_preprocess(struct ath_softc *sc,
826 * This is different from the other corrupt descriptor 833 * This is different from the other corrupt descriptor
827 * condition handled above. 834 * condition handled above.
828 */ 835 */
829 if (rx_stats->rs_status & ATH9K_RXERR_CORRUPT_DESC) { 836 if (rx_stats->rs_status & ATH9K_RXERR_CORRUPT_DESC)
830 ret = -EINVAL; 837 goto corrupt;
831 goto exit;
832 }
833 838
834 hdr = (struct ieee80211_hdr *) (skb->data + ah->caps.rx_status_len); 839 hdr = (struct ieee80211_hdr *) (skb->data + ah->caps.rx_status_len);
835 840
@@ -845,18 +850,15 @@ static int ath9k_rx_skb_preprocess(struct ath_softc *sc,
845 if (ath_process_fft(sc, hdr, rx_stats, rx_status->mactime)) 850 if (ath_process_fft(sc, hdr, rx_stats, rx_status->mactime))
846 RX_STAT_INC(rx_spectral); 851 RX_STAT_INC(rx_spectral);
847 852
848 ret = -EINVAL; 853 return -EINVAL;
849 goto exit;
850 } 854 }
851 855
852 /* 856 /*
853 * everything but the rate is checked here, the rate check is done 857 * everything but the rate is checked here, the rate check is done
854 * separately to avoid doing two lookups for a rate for each frame. 858 * separately to avoid doing two lookups for a rate for each frame.
855 */ 859 */
856 if (!ath9k_cmn_rx_accept(common, hdr, rx_status, rx_stats, decrypt_error, sc->rx.rxfilter)) { 860 if (!ath9k_cmn_rx_accept(common, hdr, rx_status, rx_stats, decrypt_error, sc->rx.rxfilter))
857 ret = -EINVAL; 861 return -EINVAL;
858 goto exit;
859 }
860 862
861 if (ath_is_mybeacon(common, hdr)) { 863 if (ath_is_mybeacon(common, hdr)) {
862 RX_STAT_INC(rx_beacons); 864 RX_STAT_INC(rx_beacons);
@@ -866,22 +868,11 @@ static int ath9k_rx_skb_preprocess(struct ath_softc *sc,
866 /* 868 /*
867 * This shouldn't happen, but have a safety check anyway. 869 * This shouldn't happen, but have a safety check anyway.
868 */ 870 */
869 if (WARN_ON(!ah->curchan)) { 871 if (WARN_ON(!ah->curchan))
870 ret = -EINVAL; 872 return -EINVAL;
871 goto exit;
872 }
873 873
874 if (ath9k_cmn_process_rate(common, hw, rx_stats, rx_status)) { 874 if (ath9k_cmn_process_rate(common, hw, rx_stats, rx_status))
875 /* 875 return -EINVAL;
876 * No valid hardware bitrate found -- we should not get here
877 * because hardware has already validated this frame as OK.
878 */
879 ath_dbg(common, ANY, "unsupported hw bitrate detected 0x%02x using 1 Mbit\n",
880 rx_stats->rs_rate);
881 RX_STAT_INC(rx_rate_err);
882 ret =-EINVAL;
883 goto exit;
884 }
885 876
886 ath9k_cmn_process_rssi(common, hw, rx_stats, rx_status); 877 ath9k_cmn_process_rssi(common, hw, rx_stats, rx_status);
887 878
@@ -896,9 +887,11 @@ static int ath9k_rx_skb_preprocess(struct ath_softc *sc,
896 sc->rx.num_pkts++; 887 sc->rx.num_pkts++;
897#endif 888#endif
898 889
899exit: 890 return 0;
900 sc->rx.discard_next = false; 891
901 return ret; 892corrupt:
893 sc->rx.discard_next = rx_stats->rs_more;
894 return -EINVAL;
902} 895}
903 896
904/* 897/*
diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c
index a6507046dfe8..312314ce7642 100644
--- a/drivers/net/wireless/ath/ath9k/xmit.c
+++ b/drivers/net/wireless/ath/ath9k/xmit.c
@@ -1444,14 +1444,16 @@ void ath_tx_aggr_sleep(struct ieee80211_sta *sta, struct ath_softc *sc,
1444 for (tidno = 0, tid = &an->tid[tidno]; 1444 for (tidno = 0, tid = &an->tid[tidno];
1445 tidno < IEEE80211_NUM_TIDS; tidno++, tid++) { 1445 tidno < IEEE80211_NUM_TIDS; tidno++, tid++) {
1446 1446
1447 if (!tid->sched)
1448 continue;
1449
1450 ac = tid->ac; 1447 ac = tid->ac;
1451 txq = ac->txq; 1448 txq = ac->txq;
1452 1449
1453 ath_txq_lock(sc, txq); 1450 ath_txq_lock(sc, txq);
1454 1451
1452 if (!tid->sched) {
1453 ath_txq_unlock(sc, txq);
1454 continue;
1455 }
1456
1455 buffered = ath_tid_has_buffered(tid); 1457 buffered = ath_tid_has_buffered(tid);
1456 1458
1457 tid->sched = false; 1459 tid->sched = false;
@@ -2184,14 +2186,15 @@ int ath_tx_start(struct ieee80211_hw *hw, struct sk_buff *skb,
2184 txq->stopped = true; 2186 txq->stopped = true;
2185 } 2187 }
2186 2188
2189 if (txctl->an)
2190 tid = ath_get_skb_tid(sc, txctl->an, skb);
2191
2187 if (info->flags & IEEE80211_TX_CTL_PS_RESPONSE) { 2192 if (info->flags & IEEE80211_TX_CTL_PS_RESPONSE) {
2188 ath_txq_unlock(sc, txq); 2193 ath_txq_unlock(sc, txq);
2189 txq = sc->tx.uapsdq; 2194 txq = sc->tx.uapsdq;
2190 ath_txq_lock(sc, txq); 2195 ath_txq_lock(sc, txq);
2191 } else if (txctl->an && 2196 } else if (txctl->an &&
2192 ieee80211_is_data_present(hdr->frame_control)) { 2197 ieee80211_is_data_present(hdr->frame_control)) {
2193 tid = ath_get_skb_tid(sc, txctl->an, skb);
2194
2195 WARN_ON(tid->ac->txq != txctl->txq); 2198 WARN_ON(tid->ac->txq != txctl->txq);
2196 2199
2197 if (info->flags & IEEE80211_TX_CTL_CLEAR_PS_FILT) 2200 if (info->flags & IEEE80211_TX_CTL_CLEAR_PS_FILT)
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
index 631d5dc5b6d5..49d4196ef9d2 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
@@ -485,7 +485,6 @@ struct brcmf_sdio {
485 485
486 u8 tx_hdrlen; /* sdio bus header length for tx packet */ 486 u8 tx_hdrlen; /* sdio bus header length for tx packet */
487 bool txglom; /* host tx glomming enable flag */ 487 bool txglom; /* host tx glomming enable flag */
488 struct sk_buff *txglom_sgpad; /* scatter-gather padding buffer */
489 u16 head_align; /* buffer pointer alignment */ 488 u16 head_align; /* buffer pointer alignment */
490 u16 sgentry_align; /* scatter-gather buffer alignment */ 489 u16 sgentry_align; /* scatter-gather buffer alignment */
491}; 490};
@@ -2101,9 +2100,8 @@ static int brcmf_sdio_txpkt_prep_sg(struct brcmf_sdio *bus,
2101 if (lastfrm && chain_pad) 2100 if (lastfrm && chain_pad)
2102 tail_pad += blksize - chain_pad; 2101 tail_pad += blksize - chain_pad;
2103 if (skb_tailroom(pkt) < tail_pad && pkt->len > blksize) { 2102 if (skb_tailroom(pkt) < tail_pad && pkt->len > blksize) {
2104 pkt_pad = bus->txglom_sgpad; 2103 pkt_pad = brcmu_pkt_buf_get_skb(tail_pad + tail_chop +
2105 if (pkt_pad == NULL) 2104 bus->head_align);
2106 brcmu_pkt_buf_get_skb(tail_pad + tail_chop);
2107 if (pkt_pad == NULL) 2105 if (pkt_pad == NULL)
2108 return -ENOMEM; 2106 return -ENOMEM;
2109 ret = brcmf_sdio_txpkt_hdalign(bus, pkt_pad); 2107 ret = brcmf_sdio_txpkt_hdalign(bus, pkt_pad);
@@ -2114,6 +2112,7 @@ static int brcmf_sdio_txpkt_prep_sg(struct brcmf_sdio *bus,
2114 tail_chop); 2112 tail_chop);
2115 *(u32 *)(pkt_pad->cb) = ALIGN_SKB_FLAG + tail_chop; 2113 *(u32 *)(pkt_pad->cb) = ALIGN_SKB_FLAG + tail_chop;
2116 skb_trim(pkt, pkt->len - tail_chop); 2114 skb_trim(pkt, pkt->len - tail_chop);
2115 skb_trim(pkt_pad, tail_pad + tail_chop);
2117 __skb_queue_after(pktq, pkt, pkt_pad); 2116 __skb_queue_after(pktq, pkt, pkt_pad);
2118 } else { 2117 } else {
2119 ntail = pkt->data_len + tail_pad - 2118 ntail = pkt->data_len + tail_pad -
@@ -2168,7 +2167,7 @@ brcmf_sdio_txpkt_prep(struct brcmf_sdio *bus, struct sk_buff_head *pktq,
2168 return ret; 2167 return ret;
2169 head_pad = (u16)ret; 2168 head_pad = (u16)ret;
2170 if (head_pad) 2169 if (head_pad)
2171 memset(pkt_next->data, 0, head_pad + bus->tx_hdrlen); 2170 memset(pkt_next->data + bus->tx_hdrlen, 0, head_pad);
2172 2171
2173 total_len += pkt_next->len; 2172 total_len += pkt_next->len;
2174 2173
@@ -3527,10 +3526,6 @@ static int brcmf_sdio_bus_preinit(struct device *dev)
3527 bus->txglom = false; 3526 bus->txglom = false;
3528 value = 1; 3527 value = 1;
3529 pad_size = bus->sdiodev->func[2]->cur_blksize << 1; 3528 pad_size = bus->sdiodev->func[2]->cur_blksize << 1;
3530 bus->txglom_sgpad = brcmu_pkt_buf_get_skb(pad_size);
3531 if (!bus->txglom_sgpad)
3532 brcmf_err("allocating txglom padding skb failed, reduced performance\n");
3533
3534 err = brcmf_iovar_data_set(bus->sdiodev->dev, "bus:rxglom", 3529 err = brcmf_iovar_data_set(bus->sdiodev->dev, "bus:rxglom",
3535 &value, sizeof(u32)); 3530 &value, sizeof(u32));
3536 if (err < 0) { 3531 if (err < 0) {
@@ -4253,7 +4248,6 @@ void brcmf_sdio_remove(struct brcmf_sdio *bus)
4253 brcmf_chip_detach(bus->ci); 4248 brcmf_chip_detach(bus->ci);
4254 } 4249 }
4255 4250
4256 brcmu_pkt_buf_free_skb(bus->txglom_sgpad);
4257 kfree(bus->rxbuf); 4251 kfree(bus->rxbuf);
4258 kfree(bus->hdrbuf); 4252 kfree(bus->hdrbuf);
4259 kfree(bus); 4253 kfree(bus);
diff --git a/drivers/net/wireless/hostap/hostap_ap.c b/drivers/net/wireless/hostap/hostap_ap.c
index d36e252d2ccb..596525528f50 100644
--- a/drivers/net/wireless/hostap/hostap_ap.c
+++ b/drivers/net/wireless/hostap/hostap_ap.c
@@ -147,7 +147,7 @@ static void ap_free_sta(struct ap_data *ap, struct sta_info *sta)
147 147
148 if (!sta->ap && sta->u.sta.challenge) 148 if (!sta->ap && sta->u.sta.challenge)
149 kfree(sta->u.sta.challenge); 149 kfree(sta->u.sta.challenge);
150 del_timer(&sta->timer); 150 del_timer_sync(&sta->timer);
151#endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */ 151#endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
152 152
153 kfree(sta); 153 kfree(sta);
diff --git a/drivers/net/wireless/iwlwifi/dvm/sta.c b/drivers/net/wireless/iwlwifi/dvm/sta.c
index c0d070c5df5e..9cdd91cdf661 100644
--- a/drivers/net/wireless/iwlwifi/dvm/sta.c
+++ b/drivers/net/wireless/iwlwifi/dvm/sta.c
@@ -590,6 +590,7 @@ void iwl_deactivate_station(struct iwl_priv *priv, const u8 sta_id,
590 sizeof(priv->tid_data[sta_id][tid])); 590 sizeof(priv->tid_data[sta_id][tid]));
591 591
592 priv->stations[sta_id].used &= ~IWL_STA_DRIVER_ACTIVE; 592 priv->stations[sta_id].used &= ~IWL_STA_DRIVER_ACTIVE;
593 priv->stations[sta_id].used &= ~IWL_STA_UCODE_INPROGRESS;
593 594
594 priv->num_stations--; 595 priv->num_stations--;
595 596
diff --git a/drivers/net/wireless/iwlwifi/dvm/tx.c b/drivers/net/wireless/iwlwifi/dvm/tx.c
index a6839dfcb82d..398dd096674c 100644
--- a/drivers/net/wireless/iwlwifi/dvm/tx.c
+++ b/drivers/net/wireless/iwlwifi/dvm/tx.c
@@ -1291,8 +1291,6 @@ int iwlagn_rx_reply_compressed_ba(struct iwl_priv *priv,
1291 struct iwl_compressed_ba_resp *ba_resp = (void *)pkt->data; 1291 struct iwl_compressed_ba_resp *ba_resp = (void *)pkt->data;
1292 struct iwl_ht_agg *agg; 1292 struct iwl_ht_agg *agg;
1293 struct sk_buff_head reclaimed_skbs; 1293 struct sk_buff_head reclaimed_skbs;
1294 struct ieee80211_tx_info *info;
1295 struct ieee80211_hdr *hdr;
1296 struct sk_buff *skb; 1294 struct sk_buff *skb;
1297 int sta_id; 1295 int sta_id;
1298 int tid; 1296 int tid;
@@ -1379,22 +1377,28 @@ int iwlagn_rx_reply_compressed_ba(struct iwl_priv *priv,
1379 freed = 0; 1377 freed = 0;
1380 1378
1381 skb_queue_walk(&reclaimed_skbs, skb) { 1379 skb_queue_walk(&reclaimed_skbs, skb) {
1382 hdr = (struct ieee80211_hdr *)skb->data; 1380 struct ieee80211_hdr *hdr = (void *)skb->data;
1381 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
1383 1382
1384 if (ieee80211_is_data_qos(hdr->frame_control)) 1383 if (ieee80211_is_data_qos(hdr->frame_control))
1385 freed++; 1384 freed++;
1386 else 1385 else
1387 WARN_ON_ONCE(1); 1386 WARN_ON_ONCE(1);
1388 1387
1389 info = IEEE80211_SKB_CB(skb);
1390 iwl_trans_free_tx_cmd(priv->trans, info->driver_data[1]); 1388 iwl_trans_free_tx_cmd(priv->trans, info->driver_data[1]);
1391 1389
1390 memset(&info->status, 0, sizeof(info->status));
1391 /* Packet was transmitted successfully, failures come as single
1392 * frames because before failing a frame the firmware transmits
1393 * it without aggregation at least once.
1394 */
1395 info->flags |= IEEE80211_TX_STAT_ACK;
1396
1392 if (freed == 1) { 1397 if (freed == 1) {
1393 /* this is the first skb we deliver in this batch */ 1398 /* this is the first skb we deliver in this batch */
1394 /* put the rate scaling data there */ 1399 /* put the rate scaling data there */
1395 info = IEEE80211_SKB_CB(skb); 1400 info = IEEE80211_SKB_CB(skb);
1396 memset(&info->status, 0, sizeof(info->status)); 1401 memset(&info->status, 0, sizeof(info->status));
1397 info->flags |= IEEE80211_TX_STAT_ACK;
1398 info->flags |= IEEE80211_TX_STAT_AMPDU; 1402 info->flags |= IEEE80211_TX_STAT_AMPDU;
1399 info->status.ampdu_ack_len = ba_resp->txed_2_done; 1403 info->status.ampdu_ack_len = ba_resp->txed_2_done;
1400 info->status.ampdu_len = ba_resp->txed; 1404 info->status.ampdu_len = ba_resp->txed;
diff --git a/drivers/net/wireless/iwlwifi/mvm/mvm.h b/drivers/net/wireless/iwlwifi/mvm/mvm.h
index ebea5f2e2741..ad0315abf765 100644
--- a/drivers/net/wireless/iwlwifi/mvm/mvm.h
+++ b/drivers/net/wireless/iwlwifi/mvm/mvm.h
@@ -151,7 +151,7 @@ enum iwl_power_scheme {
151 IWL_POWER_SCHEME_LP 151 IWL_POWER_SCHEME_LP
152}; 152};
153 153
154#define IWL_CONN_MAX_LISTEN_INTERVAL 70 154#define IWL_CONN_MAX_LISTEN_INTERVAL 10
155#define IWL_UAPSD_AC_INFO (IEEE80211_WMM_IE_STA_QOSINFO_AC_VO |\ 155#define IWL_UAPSD_AC_INFO (IEEE80211_WMM_IE_STA_QOSINFO_AC_VO |\
156 IEEE80211_WMM_IE_STA_QOSINFO_AC_VI |\ 156 IEEE80211_WMM_IE_STA_QOSINFO_AC_VI |\
157 IEEE80211_WMM_IE_STA_QOSINFO_AC_BK |\ 157 IEEE80211_WMM_IE_STA_QOSINFO_AC_BK |\
diff --git a/drivers/net/wireless/iwlwifi/mvm/tx.c b/drivers/net/wireless/iwlwifi/mvm/tx.c
index 74d60bf27750..98096fa364cd 100644
--- a/drivers/net/wireless/iwlwifi/mvm/tx.c
+++ b/drivers/net/wireless/iwlwifi/mvm/tx.c
@@ -845,16 +845,12 @@ int iwl_mvm_rx_ba_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
845 struct iwl_mvm_ba_notif *ba_notif = (void *)pkt->data; 845 struct iwl_mvm_ba_notif *ba_notif = (void *)pkt->data;
846 struct sk_buff_head reclaimed_skbs; 846 struct sk_buff_head reclaimed_skbs;
847 struct iwl_mvm_tid_data *tid_data; 847 struct iwl_mvm_tid_data *tid_data;
848 struct ieee80211_tx_info *info;
849 struct ieee80211_sta *sta; 848 struct ieee80211_sta *sta;
850 struct iwl_mvm_sta *mvmsta; 849 struct iwl_mvm_sta *mvmsta;
851 struct ieee80211_hdr *hdr;
852 struct sk_buff *skb; 850 struct sk_buff *skb;
853 int sta_id, tid, freed; 851 int sta_id, tid, freed;
854
855 /* "flow" corresponds to Tx queue */ 852 /* "flow" corresponds to Tx queue */
856 u16 scd_flow = le16_to_cpu(ba_notif->scd_flow); 853 u16 scd_flow = le16_to_cpu(ba_notif->scd_flow);
857
858 /* "ssn" is start of block-ack Tx window, corresponds to index 854 /* "ssn" is start of block-ack Tx window, corresponds to index
859 * (in Tx queue's circular buffer) of first TFD/frame in window */ 855 * (in Tx queue's circular buffer) of first TFD/frame in window */
860 u16 ba_resp_scd_ssn = le16_to_cpu(ba_notif->scd_ssn); 856 u16 ba_resp_scd_ssn = le16_to_cpu(ba_notif->scd_ssn);
@@ -911,22 +907,26 @@ int iwl_mvm_rx_ba_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
911 freed = 0; 907 freed = 0;
912 908
913 skb_queue_walk(&reclaimed_skbs, skb) { 909 skb_queue_walk(&reclaimed_skbs, skb) {
914 hdr = (struct ieee80211_hdr *)skb->data; 910 struct ieee80211_hdr *hdr = (void *)skb->data;
911 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
915 912
916 if (ieee80211_is_data_qos(hdr->frame_control)) 913 if (ieee80211_is_data_qos(hdr->frame_control))
917 freed++; 914 freed++;
918 else 915 else
919 WARN_ON_ONCE(1); 916 WARN_ON_ONCE(1);
920 917
921 info = IEEE80211_SKB_CB(skb);
922 iwl_trans_free_tx_cmd(mvm->trans, info->driver_data[1]); 918 iwl_trans_free_tx_cmd(mvm->trans, info->driver_data[1]);
923 919
920 memset(&info->status, 0, sizeof(info->status));
921 /* Packet was transmitted successfully, failures come as single
922 * frames because before failing a frame the firmware transmits
923 * it without aggregation at least once.
924 */
925 info->flags |= IEEE80211_TX_STAT_ACK;
926
924 if (freed == 1) { 927 if (freed == 1) {
925 /* this is the first skb we deliver in this batch */ 928 /* this is the first skb we deliver in this batch */
926 /* put the rate scaling data there */ 929 /* put the rate scaling data there */
927 info = IEEE80211_SKB_CB(skb);
928 memset(&info->status, 0, sizeof(info->status));
929 info->flags |= IEEE80211_TX_STAT_ACK;
930 info->flags |= IEEE80211_TX_STAT_AMPDU; 930 info->flags |= IEEE80211_TX_STAT_AMPDU;
931 info->status.ampdu_ack_len = ba_notif->txed_2_done; 931 info->status.ampdu_ack_len = ba_notif->txed_2_done;
932 info->status.ampdu_len = ba_notif->txed; 932 info->status.ampdu_len = ba_notif->txed;
diff --git a/drivers/net/wireless/libertas/cfg.c b/drivers/net/wireless/libertas/cfg.c
index 2d72a6b4b93e..54e344aed6e0 100644
--- a/drivers/net/wireless/libertas/cfg.c
+++ b/drivers/net/wireless/libertas/cfg.c
@@ -621,7 +621,7 @@ static int lbs_ret_scan(struct lbs_private *priv, unsigned long dummy,
621 id = *pos++; 621 id = *pos++;
622 elen = *pos++; 622 elen = *pos++;
623 left -= 2; 623 left -= 2;
624 if (elen > left || elen == 0) { 624 if (elen > left) {
625 lbs_deb_scan("scan response: invalid IE fmt\n"); 625 lbs_deb_scan("scan response: invalid IE fmt\n");
626 goto done; 626 goto done;
627 } 627 }
diff --git a/drivers/net/wireless/mwifiex/pcie.c b/drivers/net/wireless/mwifiex/pcie.c
index d11d4acf0890..31d8a9df1331 100644
--- a/drivers/net/wireless/mwifiex/pcie.c
+++ b/drivers/net/wireless/mwifiex/pcie.c
@@ -1217,6 +1217,12 @@ static int mwifiex_pcie_process_recv_data(struct mwifiex_adapter *adapter)
1217 rd_index = card->rxbd_rdptr & reg->rx_mask; 1217 rd_index = card->rxbd_rdptr & reg->rx_mask;
1218 skb_data = card->rx_buf_list[rd_index]; 1218 skb_data = card->rx_buf_list[rd_index];
1219 1219
1220 /* If skb allocation was failed earlier for Rx packet,
1221 * rx_buf_list[rd_index] would have been left with a NULL.
1222 */
1223 if (!skb_data)
1224 return -ENOMEM;
1225
1220 mwifiex_unmap_pci_memory(adapter, skb_data, PCI_DMA_FROMDEVICE); 1226 mwifiex_unmap_pci_memory(adapter, skb_data, PCI_DMA_FROMDEVICE);
1221 card->rx_buf_list[rd_index] = NULL; 1227 card->rx_buf_list[rd_index] = NULL;
1222 1228
@@ -1529,6 +1535,14 @@ static int mwifiex_pcie_process_cmd_complete(struct mwifiex_adapter *adapter)
1529 if (adapter->ps_state == PS_STATE_SLEEP_CFM) { 1535 if (adapter->ps_state == PS_STATE_SLEEP_CFM) {
1530 mwifiex_process_sleep_confirm_resp(adapter, skb->data, 1536 mwifiex_process_sleep_confirm_resp(adapter, skb->data,
1531 skb->len); 1537 skb->len);
1538 mwifiex_pcie_enable_host_int(adapter);
1539 if (mwifiex_write_reg(adapter,
1540 PCIE_CPU_INT_EVENT,
1541 CPU_INTR_SLEEP_CFM_DONE)) {
1542 dev_warn(adapter->dev,
1543 "Write register failed\n");
1544 return -1;
1545 }
1532 while (reg->sleep_cookie && (count++ < 10) && 1546 while (reg->sleep_cookie && (count++ < 10) &&
1533 mwifiex_pcie_ok_to_access_hw(adapter)) 1547 mwifiex_pcie_ok_to_access_hw(adapter))
1534 usleep_range(50, 60); 1548 usleep_range(50, 60);
@@ -1975,23 +1989,9 @@ static void mwifiex_interrupt_status(struct mwifiex_adapter *adapter)
1975 adapter->int_status |= pcie_ireg; 1989 adapter->int_status |= pcie_ireg;
1976 spin_unlock_irqrestore(&adapter->int_lock, flags); 1990 spin_unlock_irqrestore(&adapter->int_lock, flags);
1977 1991
1978 if (pcie_ireg & HOST_INTR_CMD_DONE) { 1992 if (!adapter->pps_uapsd_mode &&
1979 if ((adapter->ps_state == PS_STATE_SLEEP_CFM) || 1993 adapter->ps_state == PS_STATE_SLEEP &&
1980 (adapter->ps_state == PS_STATE_SLEEP)) { 1994 mwifiex_pcie_ok_to_access_hw(adapter)) {
1981 mwifiex_pcie_enable_host_int(adapter);
1982 if (mwifiex_write_reg(adapter,
1983 PCIE_CPU_INT_EVENT,
1984 CPU_INTR_SLEEP_CFM_DONE)
1985 ) {
1986 dev_warn(adapter->dev,
1987 "Write register failed\n");
1988 return;
1989
1990 }
1991 }
1992 } else if (!adapter->pps_uapsd_mode &&
1993 adapter->ps_state == PS_STATE_SLEEP &&
1994 mwifiex_pcie_ok_to_access_hw(adapter)) {
1995 /* Potentially for PCIe we could get other 1995 /* Potentially for PCIe we could get other
1996 * interrupts like shared. Don't change power 1996 * interrupts like shared. Don't change power
1997 * state until cookie is set */ 1997 * state until cookie is set */
diff --git a/drivers/net/wireless/mwifiex/usb.c b/drivers/net/wireless/mwifiex/usb.c
index e8ebbd4bc3cd..208748804a55 100644
--- a/drivers/net/wireless/mwifiex/usb.c
+++ b/drivers/net/wireless/mwifiex/usb.c
@@ -22,8 +22,6 @@
22 22
23#define USB_VERSION "1.0" 23#define USB_VERSION "1.0"
24 24
25static const char usbdriver_name[] = "usb8xxx";
26
27static struct mwifiex_if_ops usb_ops; 25static struct mwifiex_if_ops usb_ops;
28static struct semaphore add_remove_card_sem; 26static struct semaphore add_remove_card_sem;
29static struct usb_card_rec *usb_card; 27static struct usb_card_rec *usb_card;
@@ -527,13 +525,6 @@ static int mwifiex_usb_resume(struct usb_interface *intf)
527 MWIFIEX_BSS_ROLE_ANY), 525 MWIFIEX_BSS_ROLE_ANY),
528 MWIFIEX_ASYNC_CMD); 526 MWIFIEX_ASYNC_CMD);
529 527
530#ifdef CONFIG_PM
531 /* Resume handler may be called due to remote wakeup,
532 * force to exit suspend anyway
533 */
534 usb_disable_autosuspend(card->udev);
535#endif /* CONFIG_PM */
536
537 return 0; 528 return 0;
538} 529}
539 530
@@ -567,13 +558,12 @@ static void mwifiex_usb_disconnect(struct usb_interface *intf)
567} 558}
568 559
569static struct usb_driver mwifiex_usb_driver = { 560static struct usb_driver mwifiex_usb_driver = {
570 .name = usbdriver_name, 561 .name = "mwifiex_usb",
571 .probe = mwifiex_usb_probe, 562 .probe = mwifiex_usb_probe,
572 .disconnect = mwifiex_usb_disconnect, 563 .disconnect = mwifiex_usb_disconnect,
573 .id_table = mwifiex_usb_table, 564 .id_table = mwifiex_usb_table,
574 .suspend = mwifiex_usb_suspend, 565 .suspend = mwifiex_usb_suspend,
575 .resume = mwifiex_usb_resume, 566 .resume = mwifiex_usb_resume,
576 .supports_autosuspend = 1,
577}; 567};
578 568
579static int mwifiex_usb_tx_init(struct mwifiex_adapter *adapter) 569static int mwifiex_usb_tx_init(struct mwifiex_adapter *adapter)
diff --git a/drivers/net/wireless/mwifiex/wmm.c b/drivers/net/wireless/mwifiex/wmm.c
index e0ba0115e5ae..1c5f2b66f057 100644
--- a/drivers/net/wireless/mwifiex/wmm.c
+++ b/drivers/net/wireless/mwifiex/wmm.c
@@ -554,7 +554,8 @@ mwifiex_clean_txrx(struct mwifiex_private *priv)
554 mwifiex_wmm_delete_all_ralist(priv); 554 mwifiex_wmm_delete_all_ralist(priv);
555 memcpy(tos_to_tid, ac_to_tid, sizeof(tos_to_tid)); 555 memcpy(tos_to_tid, ac_to_tid, sizeof(tos_to_tid));
556 556
557 if (priv->adapter->if_ops.clean_pcie_ring) 557 if (priv->adapter->if_ops.clean_pcie_ring &&
558 !priv->adapter->surprise_removed)
558 priv->adapter->if_ops.clean_pcie_ring(priv->adapter); 559 priv->adapter->if_ops.clean_pcie_ring(priv->adapter);
559 spin_unlock_irqrestore(&priv->wmm.ra_list_spinlock, flags); 560 spin_unlock_irqrestore(&priv->wmm.ra_list_spinlock, flags);
560 561
diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index 2b62d799bfd8..a38f03ded5a4 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -907,6 +907,7 @@ static int handle_incoming_queue(struct net_device *dev,
907 907
908 /* Ethernet work: Delayed to here as it peeks the header. */ 908 /* Ethernet work: Delayed to here as it peeks the header. */
909 skb->protocol = eth_type_trans(skb, dev); 909 skb->protocol = eth_type_trans(skb, dev);
910 skb_reset_network_header(skb);
910 911
911 if (checksum_setup(dev, skb)) { 912 if (checksum_setup(dev, skb)) {
912 kfree_skb(skb); 913 kfree_skb(skb);
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 10b51106c854..89e888a78899 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -342,27 +342,72 @@ struct device_node *of_get_cpu_node(int cpu, unsigned int *thread)
342} 342}
343EXPORT_SYMBOL(of_get_cpu_node); 343EXPORT_SYMBOL(of_get_cpu_node);
344 344
345/** Checks if the given "compat" string matches one of the strings in 345/**
346 * the device's "compatible" property 346 * __of_device_is_compatible() - Check if the node matches given constraints
347 * @device: pointer to node
348 * @compat: required compatible string, NULL or "" for any match
349 * @type: required device_type value, NULL or "" for any match
350 * @name: required node name, NULL or "" for any match
351 *
352 * Checks if the given @compat, @type and @name strings match the
353 * properties of the given @device. A constraints can be skipped by
354 * passing NULL or an empty string as the constraint.
355 *
356 * Returns 0 for no match, and a positive integer on match. The return
357 * value is a relative score with larger values indicating better
358 * matches. The score is weighted for the most specific compatible value
359 * to get the highest score. Matching type is next, followed by matching
360 * name. Practically speaking, this results in the following priority
361 * order for matches:
362 *
363 * 1. specific compatible && type && name
364 * 2. specific compatible && type
365 * 3. specific compatible && name
366 * 4. specific compatible
367 * 5. general compatible && type && name
368 * 6. general compatible && type
369 * 7. general compatible && name
370 * 8. general compatible
371 * 9. type && name
372 * 10. type
373 * 11. name
347 */ 374 */
348static int __of_device_is_compatible(const struct device_node *device, 375static int __of_device_is_compatible(const struct device_node *device,
349 const char *compat) 376 const char *compat, const char *type, const char *name)
350{ 377{
351 const char* cp; 378 struct property *prop;
352 int cplen, l; 379 const char *cp;
380 int index = 0, score = 0;
381
382 /* Compatible match has highest priority */
383 if (compat && compat[0]) {
384 prop = __of_find_property(device, "compatible", NULL);
385 for (cp = of_prop_next_string(prop, NULL); cp;
386 cp = of_prop_next_string(prop, cp), index++) {
387 if (of_compat_cmp(cp, compat, strlen(compat)) == 0) {
388 score = INT_MAX/2 - (index << 2);
389 break;
390 }
391 }
392 if (!score)
393 return 0;
394 }
353 395
354 cp = __of_get_property(device, "compatible", &cplen); 396 /* Matching type is better than matching name */
355 if (cp == NULL) 397 if (type && type[0]) {
356 return 0; 398 if (!device->type || of_node_cmp(type, device->type))
357 while (cplen > 0) { 399 return 0;
358 if (of_compat_cmp(cp, compat, strlen(compat)) == 0) 400 score += 2;
359 return 1;
360 l = strlen(cp) + 1;
361 cp += l;
362 cplen -= l;
363 } 401 }
364 402
365 return 0; 403 /* Matching name is a bit better than not */
404 if (name && name[0]) {
405 if (!device->name || of_node_cmp(name, device->name))
406 return 0;
407 score++;
408 }
409
410 return score;
366} 411}
367 412
368/** Checks if the given "compat" string matches one of the strings in 413/** Checks if the given "compat" string matches one of the strings in
@@ -375,7 +420,7 @@ int of_device_is_compatible(const struct device_node *device,
375 int res; 420 int res;
376 421
377 raw_spin_lock_irqsave(&devtree_lock, flags); 422 raw_spin_lock_irqsave(&devtree_lock, flags);
378 res = __of_device_is_compatible(device, compat); 423 res = __of_device_is_compatible(device, compat, NULL, NULL);
379 raw_spin_unlock_irqrestore(&devtree_lock, flags); 424 raw_spin_unlock_irqrestore(&devtree_lock, flags);
380 return res; 425 return res;
381} 426}
@@ -681,10 +726,7 @@ struct device_node *of_find_compatible_node(struct device_node *from,
681 raw_spin_lock_irqsave(&devtree_lock, flags); 726 raw_spin_lock_irqsave(&devtree_lock, flags);
682 np = from ? from->allnext : of_allnodes; 727 np = from ? from->allnext : of_allnodes;
683 for (; np; np = np->allnext) { 728 for (; np; np = np->allnext) {
684 if (type 729 if (__of_device_is_compatible(np, compatible, type, NULL) &&
685 && !(np->type && (of_node_cmp(np->type, type) == 0)))
686 continue;
687 if (__of_device_is_compatible(np, compatible) &&
688 of_node_get(np)) 730 of_node_get(np))
689 break; 731 break;
690 } 732 }
@@ -730,65 +772,26 @@ out:
730} 772}
731EXPORT_SYMBOL(of_find_node_with_property); 773EXPORT_SYMBOL(of_find_node_with_property);
732 774
733static const struct of_device_id *
734of_match_compatible(const struct of_device_id *matches,
735 const struct device_node *node)
736{
737 const char *cp;
738 int cplen, l;
739 const struct of_device_id *m;
740
741 cp = __of_get_property(node, "compatible", &cplen);
742 while (cp && (cplen > 0)) {
743 m = matches;
744 while (m->name[0] || m->type[0] || m->compatible[0]) {
745 /* Only match for the entries without type and name */
746 if (m->name[0] || m->type[0] ||
747 of_compat_cmp(m->compatible, cp,
748 strlen(m->compatible)))
749 m++;
750 else
751 return m;
752 }
753
754 /* Get node's next compatible string */
755 l = strlen(cp) + 1;
756 cp += l;
757 cplen -= l;
758 }
759
760 return NULL;
761}
762
763static 775static
764const struct of_device_id *__of_match_node(const struct of_device_id *matches, 776const struct of_device_id *__of_match_node(const struct of_device_id *matches,
765 const struct device_node *node) 777 const struct device_node *node)
766{ 778{
767 const struct of_device_id *m; 779 const struct of_device_id *best_match = NULL;
780 int score, best_score = 0;
768 781
769 if (!matches) 782 if (!matches)
770 return NULL; 783 return NULL;
771 784
772 m = of_match_compatible(matches, node); 785 for (; matches->name[0] || matches->type[0] || matches->compatible[0]; matches++) {
773 if (m) 786 score = __of_device_is_compatible(node, matches->compatible,
774 return m; 787 matches->type, matches->name);
775 788 if (score > best_score) {
776 while (matches->name[0] || matches->type[0] || matches->compatible[0]) { 789 best_match = matches;
777 int match = 1; 790 best_score = score;
778 if (matches->name[0]) 791 }
779 match &= node->name
780 && !strcmp(matches->name, node->name);
781 if (matches->type[0])
782 match &= node->type
783 && !strcmp(matches->type, node->type);
784 if (matches->compatible[0])
785 match &= __of_device_is_compatible(node,
786 matches->compatible);
787 if (match)
788 return matches;
789 matches++;
790 } 792 }
791 return NULL; 793
794 return best_match;
792} 795}
793 796
794/** 797/**
@@ -796,12 +799,7 @@ const struct of_device_id *__of_match_node(const struct of_device_id *matches,
796 * @matches: array of of device match structures to search in 799 * @matches: array of of device match structures to search in
797 * @node: the of device structure to match against 800 * @node: the of device structure to match against
798 * 801 *
799 * Low level utility function used by device matching. We have two ways 802 * Low level utility function used by device matching.
800 * of matching:
801 * - Try to find the best compatible match by comparing each compatible
802 * string of device node with all the given matches respectively.
803 * - If the above method failed, then try to match the compatible by using
804 * __of_device_is_compatible() besides the match in type and name.
805 */ 803 */
806const struct of_device_id *of_match_node(const struct of_device_id *matches, 804const struct of_device_id *of_match_node(const struct of_device_id *matches,
807 const struct device_node *node) 805 const struct device_node *node)
diff --git a/drivers/of/selftest.c b/drivers/of/selftest.c
index e21012bde639..6643d1920985 100644
--- a/drivers/of/selftest.c
+++ b/drivers/of/selftest.c
@@ -300,6 +300,72 @@ static void __init of_selftest_parse_interrupts_extended(void)
300 of_node_put(np); 300 of_node_put(np);
301} 301}
302 302
303static struct of_device_id match_node_table[] = {
304 { .data = "A", .name = "name0", }, /* Name alone is lowest priority */
305 { .data = "B", .type = "type1", }, /* followed by type alone */
306
307 { .data = "Ca", .name = "name2", .type = "type1", }, /* followed by both together */
308 { .data = "Cb", .name = "name2", }, /* Only match when type doesn't match */
309 { .data = "Cc", .name = "name2", .type = "type2", },
310
311 { .data = "E", .compatible = "compat3" },
312 { .data = "G", .compatible = "compat2", },
313 { .data = "H", .compatible = "compat2", .name = "name5", },
314 { .data = "I", .compatible = "compat2", .type = "type1", },
315 { .data = "J", .compatible = "compat2", .type = "type1", .name = "name8", },
316 { .data = "K", .compatible = "compat2", .name = "name9", },
317 {}
318};
319
320static struct {
321 const char *path;
322 const char *data;
323} match_node_tests[] = {
324 { .path = "/testcase-data/match-node/name0", .data = "A", },
325 { .path = "/testcase-data/match-node/name1", .data = "B", },
326 { .path = "/testcase-data/match-node/a/name2", .data = "Ca", },
327 { .path = "/testcase-data/match-node/b/name2", .data = "Cb", },
328 { .path = "/testcase-data/match-node/c/name2", .data = "Cc", },
329 { .path = "/testcase-data/match-node/name3", .data = "E", },
330 { .path = "/testcase-data/match-node/name4", .data = "G", },
331 { .path = "/testcase-data/match-node/name5", .data = "H", },
332 { .path = "/testcase-data/match-node/name6", .data = "G", },
333 { .path = "/testcase-data/match-node/name7", .data = "I", },
334 { .path = "/testcase-data/match-node/name8", .data = "J", },
335 { .path = "/testcase-data/match-node/name9", .data = "K", },
336};
337
338static void __init of_selftest_match_node(void)
339{
340 struct device_node *np;
341 const struct of_device_id *match;
342 int i;
343
344 for (i = 0; i < ARRAY_SIZE(match_node_tests); i++) {
345 np = of_find_node_by_path(match_node_tests[i].path);
346 if (!np) {
347 selftest(0, "missing testcase node %s\n",
348 match_node_tests[i].path);
349 continue;
350 }
351
352 match = of_match_node(match_node_table, np);
353 if (!match) {
354 selftest(0, "%s didn't match anything\n",
355 match_node_tests[i].path);
356 continue;
357 }
358
359 if (strcmp(match->data, match_node_tests[i].data) != 0) {
360 selftest(0, "%s got wrong match. expected %s, got %s\n",
361 match_node_tests[i].path, match_node_tests[i].data,
362 (const char *)match->data);
363 continue;
364 }
365 selftest(1, "passed");
366 }
367}
368
303static int __init of_selftest(void) 369static int __init of_selftest(void)
304{ 370{
305 struct device_node *np; 371 struct device_node *np;
@@ -316,6 +382,7 @@ static int __init of_selftest(void)
316 of_selftest_property_match_string(); 382 of_selftest_property_match_string();
317 of_selftest_parse_interrupts(); 383 of_selftest_parse_interrupts();
318 of_selftest_parse_interrupts_extended(); 384 of_selftest_parse_interrupts_extended();
385 of_selftest_match_node();
319 pr_info("end of selftest - %i passed, %i failed\n", 386 pr_info("end of selftest - %i passed, %i failed\n",
320 selftest_results.passed, selftest_results.failed); 387 selftest_results.passed, selftest_results.failed);
321 return 0; 388 return 0;
diff --git a/drivers/of/testcase-data/testcases.dtsi b/drivers/of/testcase-data/testcases.dtsi
new file mode 100644
index 000000000000..3a5b75a8e4d7
--- /dev/null
+++ b/drivers/of/testcase-data/testcases.dtsi
@@ -0,0 +1,3 @@
1#include "tests-phandle.dtsi"
2#include "tests-interrupts.dtsi"
3#include "tests-match.dtsi"
diff --git a/arch/arm/boot/dts/testcases/tests-interrupts.dtsi b/drivers/of/testcase-data/tests-interrupts.dtsi
index c843720bd3e5..c843720bd3e5 100644
--- a/arch/arm/boot/dts/testcases/tests-interrupts.dtsi
+++ b/drivers/of/testcase-data/tests-interrupts.dtsi
diff --git a/drivers/of/testcase-data/tests-match.dtsi b/drivers/of/testcase-data/tests-match.dtsi
new file mode 100644
index 000000000000..c9e541129534
--- /dev/null
+++ b/drivers/of/testcase-data/tests-match.dtsi
@@ -0,0 +1,19 @@
1
2/ {
3 testcase-data {
4 match-node {
5 name0 { };
6 name1 { device_type = "type1"; };
7 a { name2 { device_type = "type1"; }; };
8 b { name2 { }; };
9 c { name2 { device_type = "type2"; }; };
10 name3 { compatible = "compat3"; };
11 name4 { compatible = "compat2", "compat3"; };
12 name5 { compatible = "compat2", "compat3"; };
13 name6 { compatible = "compat1", "compat2", "compat3"; };
14 name7 { compatible = "compat2"; device_type = "type1"; };
15 name8 { compatible = "compat2"; device_type = "type1"; };
16 name9 { compatible = "compat2"; };
17 };
18 };
19};
diff --git a/arch/arm/boot/dts/testcases/tests-phandle.dtsi b/drivers/of/testcase-data/tests-phandle.dtsi
index 0007d3cd7dc2..0007d3cd7dc2 100644
--- a/arch/arm/boot/dts/testcases/tests-phandle.dtsi
+++ b/drivers/of/testcase-data/tests-phandle.dtsi
diff --git a/drivers/pci/host/pci-mvebu.c b/drivers/pci/host/pci-mvebu.c
index 13478ecd4113..0e79665afd44 100644
--- a/drivers/pci/host/pci-mvebu.c
+++ b/drivers/pci/host/pci-mvebu.c
@@ -60,14 +60,6 @@
60#define PCIE_DEBUG_CTRL 0x1a60 60#define PCIE_DEBUG_CTRL 0x1a60
61#define PCIE_DEBUG_SOFT_RESET BIT(20) 61#define PCIE_DEBUG_SOFT_RESET BIT(20)
62 62
63/*
64 * This product ID is registered by Marvell, and used when the Marvell
65 * SoC is not the root complex, but an endpoint on the PCIe bus. It is
66 * therefore safe to re-use this PCI ID for our emulated PCI-to-PCI
67 * bridge.
68 */
69#define MARVELL_EMULATED_PCI_PCI_BRIDGE_ID 0x7846
70
71/* PCI configuration space of a PCI-to-PCI bridge */ 63/* PCI configuration space of a PCI-to-PCI bridge */
72struct mvebu_sw_pci_bridge { 64struct mvebu_sw_pci_bridge {
73 u16 vendor; 65 u16 vendor;
@@ -388,7 +380,8 @@ static void mvebu_sw_pci_bridge_init(struct mvebu_pcie_port *port)
388 380
389 bridge->class = PCI_CLASS_BRIDGE_PCI; 381 bridge->class = PCI_CLASS_BRIDGE_PCI;
390 bridge->vendor = PCI_VENDOR_ID_MARVELL; 382 bridge->vendor = PCI_VENDOR_ID_MARVELL;
391 bridge->device = MARVELL_EMULATED_PCI_PCI_BRIDGE_ID; 383 bridge->device = mvebu_readl(port, PCIE_DEV_ID_OFF) >> 16;
384 bridge->revision = mvebu_readl(port, PCIE_DEV_REV_OFF) & 0xff;
392 bridge->header_type = PCI_HEADER_TYPE_BRIDGE; 385 bridge->header_type = PCI_HEADER_TYPE_BRIDGE;
393 bridge->cache_line_size = 0x10; 386 bridge->cache_line_size = 0x10;
394 387
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index 7a0fec6ce571..955ab7990c5b 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -545,9 +545,15 @@ static int populate_msi_sysfs(struct pci_dev *pdev)
545 return -ENOMEM; 545 return -ENOMEM;
546 list_for_each_entry(entry, &pdev->msi_list, list) { 546 list_for_each_entry(entry, &pdev->msi_list, list) {
547 char *name = kmalloc(20, GFP_KERNEL); 547 char *name = kmalloc(20, GFP_KERNEL);
548 if (!name)
549 goto error_attrs;
550
548 msi_dev_attr = kzalloc(sizeof(*msi_dev_attr), GFP_KERNEL); 551 msi_dev_attr = kzalloc(sizeof(*msi_dev_attr), GFP_KERNEL);
549 if (!msi_dev_attr) 552 if (!msi_dev_attr) {
553 kfree(name);
550 goto error_attrs; 554 goto error_attrs;
555 }
556
551 sprintf(name, "%d", entry->irq); 557 sprintf(name, "%d", entry->irq);
552 sysfs_attr_init(&msi_dev_attr->attr); 558 sysfs_attr_init(&msi_dev_attr->attr);
553 msi_dev_attr->attr.name = name; 559 msi_dev_attr->attr.name = name;
@@ -589,6 +595,7 @@ error_attrs:
589 ++count; 595 ++count;
590 msi_attr = msi_attrs[count]; 596 msi_attr = msi_attrs[count];
591 } 597 }
598 kfree(msi_attrs);
592 return ret; 599 return ret;
593} 600}
594 601
@@ -959,7 +966,6 @@ EXPORT_SYMBOL(pci_disable_msi);
959/** 966/**
960 * pci_msix_vec_count - return the number of device's MSI-X table entries 967 * pci_msix_vec_count - return the number of device's MSI-X table entries
961 * @dev: pointer to the pci_dev data structure of MSI-X device function 968 * @dev: pointer to the pci_dev data structure of MSI-X device function
962
963 * This function returns the number of device's MSI-X table entries and 969 * This function returns the number of device's MSI-X table entries and
964 * therefore the number of MSI-X vectors device is capable of sending. 970 * therefore the number of MSI-X vectors device is capable of sending.
965 * It returns a negative errno if the device is not capable of sending MSI-X 971 * It returns a negative errno if the device is not capable of sending MSI-X
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 1febe90831b4..6b05f6134b68 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -1181,6 +1181,8 @@ EXPORT_SYMBOL_GPL(pci_load_and_free_saved_state);
1181static int do_pci_enable_device(struct pci_dev *dev, int bars) 1181static int do_pci_enable_device(struct pci_dev *dev, int bars)
1182{ 1182{
1183 int err; 1183 int err;
1184 u16 cmd;
1185 u8 pin;
1184 1186
1185 err = pci_set_power_state(dev, PCI_D0); 1187 err = pci_set_power_state(dev, PCI_D0);
1186 if (err < 0 && err != -EIO) 1188 if (err < 0 && err != -EIO)
@@ -1190,6 +1192,14 @@ static int do_pci_enable_device(struct pci_dev *dev, int bars)
1190 return err; 1192 return err;
1191 pci_fixup_device(pci_fixup_enable, dev); 1193 pci_fixup_device(pci_fixup_enable, dev);
1192 1194
1195 pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin);
1196 if (pin) {
1197 pci_read_config_word(dev, PCI_COMMAND, &cmd);
1198 if (cmd & PCI_COMMAND_INTX_DISABLE)
1199 pci_write_config_word(dev, PCI_COMMAND,
1200 cmd & ~PCI_COMMAND_INTX_DISABLE);
1201 }
1202
1193 return 0; 1203 return 0;
1194} 1204}
1195 1205
diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index afa2354f6600..c7a551c2d5f1 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -5,7 +5,7 @@
5menu "PHY Subsystem" 5menu "PHY Subsystem"
6 6
7config GENERIC_PHY 7config GENERIC_PHY
8 tristate "PHY Core" 8 bool "PHY Core"
9 help 9 help
10 Generic PHY support. 10 Generic PHY support.
11 11
@@ -61,6 +61,7 @@ config PHY_EXYNOS_DP_VIDEO
61config BCM_KONA_USB2_PHY 61config BCM_KONA_USB2_PHY
62 tristate "Broadcom Kona USB2 PHY Driver" 62 tristate "Broadcom Kona USB2 PHY Driver"
63 depends on GENERIC_PHY 63 depends on GENERIC_PHY
64 depends on HAS_IOMEM
64 help 65 help
65 Enable this to support the Broadcom Kona USB 2.0 PHY. 66 Enable this to support the Broadcom Kona USB 2.0 PHY.
66 67
diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
index 5f5b0f4be5be..6c738376daff 100644
--- a/drivers/phy/phy-core.c
+++ b/drivers/phy/phy-core.c
@@ -176,6 +176,8 @@ int phy_init(struct phy *phy)
176 dev_err(&phy->dev, "phy init failed --> %d\n", ret); 176 dev_err(&phy->dev, "phy init failed --> %d\n", ret);
177 goto out; 177 goto out;
178 } 178 }
179 } else {
180 ret = 0; /* Override possible ret == -ENOTSUPP */
179 } 181 }
180 ++phy->init_count; 182 ++phy->init_count;
181 183
@@ -232,6 +234,8 @@ int phy_power_on(struct phy *phy)
232 dev_err(&phy->dev, "phy poweron failed --> %d\n", ret); 234 dev_err(&phy->dev, "phy poweron failed --> %d\n", ret);
233 goto out; 235 goto out;
234 } 236 }
237 } else {
238 ret = 0; /* Override possible ret == -ENOTSUPP */
235 } 239 }
236 ++phy->power_count; 240 ++phy->power_count;
237 mutex_unlock(&phy->mutex); 241 mutex_unlock(&phy->mutex);
@@ -404,17 +408,11 @@ struct phy *phy_get(struct device *dev, const char *string)
404 index = of_property_match_string(dev->of_node, "phy-names", 408 index = of_property_match_string(dev->of_node, "phy-names",
405 string); 409 string);
406 phy = of_phy_get(dev, index); 410 phy = of_phy_get(dev, index);
407 if (IS_ERR(phy)) {
408 dev_err(dev, "unable to find phy\n");
409 return phy;
410 }
411 } else { 411 } else {
412 phy = phy_lookup(dev, string); 412 phy = phy_lookup(dev, string);
413 if (IS_ERR(phy)) {
414 dev_err(dev, "unable to find phy\n");
415 return phy;
416 }
417 } 413 }
414 if (IS_ERR(phy))
415 return phy;
418 416
419 if (!try_module_get(phy->ops->owner)) 417 if (!try_module_get(phy->ops->owner))
420 return ERR_PTR(-EPROBE_DEFER); 418 return ERR_PTR(-EPROBE_DEFER);
diff --git a/drivers/phy/phy-exynos-dp-video.c b/drivers/phy/phy-exynos-dp-video.c
index 1dbe6ce7b2ce..0786fef842e7 100644
--- a/drivers/phy/phy-exynos-dp-video.c
+++ b/drivers/phy/phy-exynos-dp-video.c
@@ -76,10 +76,6 @@ static int exynos_dp_video_phy_probe(struct platform_device *pdev)
76 if (IS_ERR(state->regs)) 76 if (IS_ERR(state->regs))
77 return PTR_ERR(state->regs); 77 return PTR_ERR(state->regs);
78 78
79 phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
80 if (IS_ERR(phy_provider))
81 return PTR_ERR(phy_provider);
82
83 phy = devm_phy_create(dev, &exynos_dp_video_phy_ops, NULL); 79 phy = devm_phy_create(dev, &exynos_dp_video_phy_ops, NULL);
84 if (IS_ERR(phy)) { 80 if (IS_ERR(phy)) {
85 dev_err(dev, "failed to create Display Port PHY\n"); 81 dev_err(dev, "failed to create Display Port PHY\n");
@@ -87,6 +83,10 @@ static int exynos_dp_video_phy_probe(struct platform_device *pdev)
87 } 83 }
88 phy_set_drvdata(phy, state); 84 phy_set_drvdata(phy, state);
89 85
86 phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
87 if (IS_ERR(phy_provider))
88 return PTR_ERR(phy_provider);
89
90 return 0; 90 return 0;
91} 91}
92 92
diff --git a/drivers/phy/phy-exynos-mipi-video.c b/drivers/phy/phy-exynos-mipi-video.c
index 0c5efab11af1..7f139326a642 100644
--- a/drivers/phy/phy-exynos-mipi-video.c
+++ b/drivers/phy/phy-exynos-mipi-video.c
@@ -134,11 +134,6 @@ static int exynos_mipi_video_phy_probe(struct platform_device *pdev)
134 dev_set_drvdata(dev, state); 134 dev_set_drvdata(dev, state);
135 spin_lock_init(&state->slock); 135 spin_lock_init(&state->slock);
136 136
137 phy_provider = devm_of_phy_provider_register(dev,
138 exynos_mipi_video_phy_xlate);
139 if (IS_ERR(phy_provider))
140 return PTR_ERR(phy_provider);
141
142 for (i = 0; i < EXYNOS_MIPI_PHYS_NUM; i++) { 137 for (i = 0; i < EXYNOS_MIPI_PHYS_NUM; i++) {
143 struct phy *phy = devm_phy_create(dev, 138 struct phy *phy = devm_phy_create(dev,
144 &exynos_mipi_video_phy_ops, NULL); 139 &exynos_mipi_video_phy_ops, NULL);
@@ -152,6 +147,11 @@ static int exynos_mipi_video_phy_probe(struct platform_device *pdev)
152 phy_set_drvdata(phy, &state->phys[i]); 147 phy_set_drvdata(phy, &state->phys[i]);
153 } 148 }
154 149
150 phy_provider = devm_of_phy_provider_register(dev,
151 exynos_mipi_video_phy_xlate);
152 if (IS_ERR(phy_provider))
153 return PTR_ERR(phy_provider);
154
155 return 0; 155 return 0;
156} 156}
157 157
diff --git a/drivers/phy/phy-mvebu-sata.c b/drivers/phy/phy-mvebu-sata.c
index d43786f62437..d70ecd6a1b3f 100644
--- a/drivers/phy/phy-mvebu-sata.c
+++ b/drivers/phy/phy-mvebu-sata.c
@@ -99,17 +99,17 @@ static int phy_mvebu_sata_probe(struct platform_device *pdev)
99 if (IS_ERR(priv->clk)) 99 if (IS_ERR(priv->clk))
100 return PTR_ERR(priv->clk); 100 return PTR_ERR(priv->clk);
101 101
102 phy_provider = devm_of_phy_provider_register(&pdev->dev,
103 of_phy_simple_xlate);
104 if (IS_ERR(phy_provider))
105 return PTR_ERR(phy_provider);
106
107 phy = devm_phy_create(&pdev->dev, &phy_mvebu_sata_ops, NULL); 102 phy = devm_phy_create(&pdev->dev, &phy_mvebu_sata_ops, NULL);
108 if (IS_ERR(phy)) 103 if (IS_ERR(phy))
109 return PTR_ERR(phy); 104 return PTR_ERR(phy);
110 105
111 phy_set_drvdata(phy, priv); 106 phy_set_drvdata(phy, priv);
112 107
108 phy_provider = devm_of_phy_provider_register(&pdev->dev,
109 of_phy_simple_xlate);
110 if (IS_ERR(phy_provider))
111 return PTR_ERR(phy_provider);
112
113 /* The boot loader may of left it on. Turn it off. */ 113 /* The boot loader may of left it on. Turn it off. */
114 phy_mvebu_sata_power_off(phy); 114 phy_mvebu_sata_power_off(phy);
115 115
diff --git a/drivers/phy/phy-omap-usb2.c b/drivers/phy/phy-omap-usb2.c
index bfc5c337f99a..7699752fba11 100644
--- a/drivers/phy/phy-omap-usb2.c
+++ b/drivers/phy/phy-omap-usb2.c
@@ -177,11 +177,6 @@ static int omap_usb2_probe(struct platform_device *pdev)
177 phy->phy.otg = otg; 177 phy->phy.otg = otg;
178 phy->phy.type = USB_PHY_TYPE_USB2; 178 phy->phy.type = USB_PHY_TYPE_USB2;
179 179
180 phy_provider = devm_of_phy_provider_register(phy->dev,
181 of_phy_simple_xlate);
182 if (IS_ERR(phy_provider))
183 return PTR_ERR(phy_provider);
184
185 control_node = of_parse_phandle(node, "ctrl-module", 0); 180 control_node = of_parse_phandle(node, "ctrl-module", 0);
186 if (!control_node) { 181 if (!control_node) {
187 dev_err(&pdev->dev, "Failed to get control device phandle\n"); 182 dev_err(&pdev->dev, "Failed to get control device phandle\n");
@@ -214,6 +209,11 @@ static int omap_usb2_probe(struct platform_device *pdev)
214 209
215 phy_set_drvdata(generic_phy, phy); 210 phy_set_drvdata(generic_phy, phy);
216 211
212 phy_provider = devm_of_phy_provider_register(phy->dev,
213 of_phy_simple_xlate);
214 if (IS_ERR(phy_provider))
215 return PTR_ERR(phy_provider);
216
217 phy->wkupclk = devm_clk_get(phy->dev, "usb_phy_cm_clk32k"); 217 phy->wkupclk = devm_clk_get(phy->dev, "usb_phy_cm_clk32k");
218 if (IS_ERR(phy->wkupclk)) { 218 if (IS_ERR(phy->wkupclk)) {
219 dev_err(&pdev->dev, "unable to get usb_phy_cm_clk32k\n"); 219 dev_err(&pdev->dev, "unable to get usb_phy_cm_clk32k\n");
diff --git a/drivers/phy/phy-twl4030-usb.c b/drivers/phy/phy-twl4030-usb.c
index daf65e68aaab..c3ace1db8136 100644
--- a/drivers/phy/phy-twl4030-usb.c
+++ b/drivers/phy/phy-twl4030-usb.c
@@ -695,11 +695,6 @@ static int twl4030_usb_probe(struct platform_device *pdev)
695 otg->set_host = twl4030_set_host; 695 otg->set_host = twl4030_set_host;
696 otg->set_peripheral = twl4030_set_peripheral; 696 otg->set_peripheral = twl4030_set_peripheral;
697 697
698 phy_provider = devm_of_phy_provider_register(twl->dev,
699 of_phy_simple_xlate);
700 if (IS_ERR(phy_provider))
701 return PTR_ERR(phy_provider);
702
703 phy = devm_phy_create(twl->dev, &ops, init_data); 698 phy = devm_phy_create(twl->dev, &ops, init_data);
704 if (IS_ERR(phy)) { 699 if (IS_ERR(phy)) {
705 dev_dbg(&pdev->dev, "Failed to create PHY\n"); 700 dev_dbg(&pdev->dev, "Failed to create PHY\n");
@@ -708,6 +703,11 @@ static int twl4030_usb_probe(struct platform_device *pdev)
708 703
709 phy_set_drvdata(phy, twl); 704 phy_set_drvdata(phy, twl);
710 705
706 phy_provider = devm_of_phy_provider_register(twl->dev,
707 of_phy_simple_xlate);
708 if (IS_ERR(phy_provider))
709 return PTR_ERR(phy_provider);
710
711 /* init spinlock for workqueue */ 711 /* init spinlock for workqueue */
712 spin_lock_init(&twl->lock); 712 spin_lock_init(&twl->lock);
713 713
diff --git a/drivers/pwm/pwm-lp3943.c b/drivers/pwm/pwm-lp3943.c
index 8a843a04c224..a40b9c34e9ff 100644
--- a/drivers/pwm/pwm-lp3943.c
+++ b/drivers/pwm/pwm-lp3943.c
@@ -52,8 +52,10 @@ lp3943_pwm_request_map(struct lp3943_pwm *lp3943_pwm, int hwpwm)
52 offset = pwm_map->output[i]; 52 offset = pwm_map->output[i];
53 53
54 /* Return an error if the pin is already assigned */ 54 /* Return an error if the pin is already assigned */
55 if (test_and_set_bit(offset, &lp3943->pin_used)) 55 if (test_and_set_bit(offset, &lp3943->pin_used)) {
56 kfree(pwm_map);
56 return ERR_PTR(-EBUSY); 57 return ERR_PTR(-EBUSY);
58 }
57 } 59 }
58 60
59 return pwm_map; 61 return pwm_map;
diff --git a/drivers/rapidio/devices/tsi721.h b/drivers/rapidio/devices/tsi721.h
index b4b0d83f9ef6..7061ac0ad428 100644
--- a/drivers/rapidio/devices/tsi721.h
+++ b/drivers/rapidio/devices/tsi721.h
@@ -678,6 +678,7 @@ struct tsi721_bdma_chan {
678 struct list_head free_list; 678 struct list_head free_list;
679 dma_cookie_t completed_cookie; 679 dma_cookie_t completed_cookie;
680 struct tasklet_struct tasklet; 680 struct tasklet_struct tasklet;
681 bool active;
681}; 682};
682 683
683#endif /* CONFIG_RAPIDIO_DMA_ENGINE */ 684#endif /* CONFIG_RAPIDIO_DMA_ENGINE */
diff --git a/drivers/rapidio/devices/tsi721_dma.c b/drivers/rapidio/devices/tsi721_dma.c
index 502663f5f7c6..91245f5dbe81 100644
--- a/drivers/rapidio/devices/tsi721_dma.c
+++ b/drivers/rapidio/devices/tsi721_dma.c
@@ -206,8 +206,8 @@ void tsi721_bdma_handler(struct tsi721_bdma_chan *bdma_chan)
206{ 206{
207 /* Disable BDMA channel interrupts */ 207 /* Disable BDMA channel interrupts */
208 iowrite32(0, bdma_chan->regs + TSI721_DMAC_INTE); 208 iowrite32(0, bdma_chan->regs + TSI721_DMAC_INTE);
209 209 if (bdma_chan->active)
210 tasklet_schedule(&bdma_chan->tasklet); 210 tasklet_schedule(&bdma_chan->tasklet);
211} 211}
212 212
213#ifdef CONFIG_PCI_MSI 213#ifdef CONFIG_PCI_MSI
@@ -562,7 +562,7 @@ static int tsi721_alloc_chan_resources(struct dma_chan *dchan)
562 } 562 }
563#endif /* CONFIG_PCI_MSI */ 563#endif /* CONFIG_PCI_MSI */
564 564
565 tasklet_enable(&bdma_chan->tasklet); 565 bdma_chan->active = true;
566 tsi721_bdma_interrupt_enable(bdma_chan, 1); 566 tsi721_bdma_interrupt_enable(bdma_chan, 1);
567 567
568 return bdma_chan->bd_num - 1; 568 return bdma_chan->bd_num - 1;
@@ -576,9 +576,7 @@ err_out:
576static void tsi721_free_chan_resources(struct dma_chan *dchan) 576static void tsi721_free_chan_resources(struct dma_chan *dchan)
577{ 577{
578 struct tsi721_bdma_chan *bdma_chan = to_tsi721_chan(dchan); 578 struct tsi721_bdma_chan *bdma_chan = to_tsi721_chan(dchan);
579#ifdef CONFIG_PCI_MSI
580 struct tsi721_device *priv = to_tsi721(dchan->device); 579 struct tsi721_device *priv = to_tsi721(dchan->device);
581#endif
582 LIST_HEAD(list); 580 LIST_HEAD(list);
583 581
584 dev_dbg(dchan->device->dev, "%s: Entry\n", __func__); 582 dev_dbg(dchan->device->dev, "%s: Entry\n", __func__);
@@ -589,14 +587,25 @@ static void tsi721_free_chan_resources(struct dma_chan *dchan)
589 BUG_ON(!list_empty(&bdma_chan->active_list)); 587 BUG_ON(!list_empty(&bdma_chan->active_list));
590 BUG_ON(!list_empty(&bdma_chan->queue)); 588 BUG_ON(!list_empty(&bdma_chan->queue));
591 589
592 tasklet_disable(&bdma_chan->tasklet); 590 tsi721_bdma_interrupt_enable(bdma_chan, 0);
591 bdma_chan->active = false;
592
593#ifdef CONFIG_PCI_MSI
594 if (priv->flags & TSI721_USING_MSIX) {
595 synchronize_irq(priv->msix[TSI721_VECT_DMA0_DONE +
596 bdma_chan->id].vector);
597 synchronize_irq(priv->msix[TSI721_VECT_DMA0_INT +
598 bdma_chan->id].vector);
599 } else
600#endif
601 synchronize_irq(priv->pdev->irq);
602
603 tasklet_kill(&bdma_chan->tasklet);
593 604
594 spin_lock_bh(&bdma_chan->lock); 605 spin_lock_bh(&bdma_chan->lock);
595 list_splice_init(&bdma_chan->free_list, &list); 606 list_splice_init(&bdma_chan->free_list, &list);
596 spin_unlock_bh(&bdma_chan->lock); 607 spin_unlock_bh(&bdma_chan->lock);
597 608
598 tsi721_bdma_interrupt_enable(bdma_chan, 0);
599
600#ifdef CONFIG_PCI_MSI 609#ifdef CONFIG_PCI_MSI
601 if (priv->flags & TSI721_USING_MSIX) { 610 if (priv->flags & TSI721_USING_MSIX) {
602 free_irq(priv->msix[TSI721_VECT_DMA0_DONE + 611 free_irq(priv->msix[TSI721_VECT_DMA0_DONE +
@@ -790,6 +799,7 @@ int tsi721_register_dma(struct tsi721_device *priv)
790 bdma_chan->dchan.cookie = 1; 799 bdma_chan->dchan.cookie = 1;
791 bdma_chan->dchan.chan_id = i; 800 bdma_chan->dchan.chan_id = i;
792 bdma_chan->id = i; 801 bdma_chan->id = i;
802 bdma_chan->active = false;
793 803
794 spin_lock_init(&bdma_chan->lock); 804 spin_lock_init(&bdma_chan->lock);
795 805
@@ -799,7 +809,6 @@ int tsi721_register_dma(struct tsi721_device *priv)
799 809
800 tasklet_init(&bdma_chan->tasklet, tsi721_dma_tasklet, 810 tasklet_init(&bdma_chan->tasklet, tsi721_dma_tasklet,
801 (unsigned long)bdma_chan); 811 (unsigned long)bdma_chan);
802 tasklet_disable(&bdma_chan->tasklet);
803 list_add_tail(&bdma_chan->dchan.device_node, 812 list_add_tail(&bdma_chan->dchan.device_node,
804 &mport->dma.channels); 813 &mport->dma.channels);
805 } 814 }
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 16a309e5c024..afca1bc24f26 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -953,6 +953,8 @@ static int machine_constraints_current(struct regulator_dev *rdev,
953 return 0; 953 return 0;
954} 954}
955 955
956static int _regulator_do_enable(struct regulator_dev *rdev);
957
956/** 958/**
957 * set_machine_constraints - sets regulator constraints 959 * set_machine_constraints - sets regulator constraints
958 * @rdev: regulator source 960 * @rdev: regulator source
@@ -1013,10 +1015,9 @@ static int set_machine_constraints(struct regulator_dev *rdev,
1013 /* If the constraints say the regulator should be on at this point 1015 /* If the constraints say the regulator should be on at this point
1014 * and we have control then make sure it is enabled. 1016 * and we have control then make sure it is enabled.
1015 */ 1017 */
1016 if ((rdev->constraints->always_on || rdev->constraints->boot_on) && 1018 if (rdev->constraints->always_on || rdev->constraints->boot_on) {
1017 ops->enable) { 1019 ret = _regulator_do_enable(rdev);
1018 ret = ops->enable(rdev); 1020 if (ret < 0 && ret != -EINVAL) {
1019 if (ret < 0) {
1020 rdev_err(rdev, "failed to enable\n"); 1021 rdev_err(rdev, "failed to enable\n");
1021 goto out; 1022 goto out;
1022 } 1023 }
@@ -1359,7 +1360,7 @@ static struct regulator *_regulator_get(struct device *dev, const char *id,
1359 goto found; 1360 goto found;
1360 /* Don't log an error when called from regulator_get_optional() */ 1361 /* Don't log an error when called from regulator_get_optional() */
1361 } else if (!have_full_constraints() || exclusive) { 1362 } else if (!have_full_constraints() || exclusive) {
1362 dev_err(dev, "dummy supplies not allowed\n"); 1363 dev_warn(dev, "dummy supplies not allowed\n");
1363 } 1364 }
1364 1365
1365 mutex_unlock(&regulator_list_mutex); 1366 mutex_unlock(&regulator_list_mutex);
@@ -1907,8 +1908,6 @@ static int _regulator_do_disable(struct regulator_dev *rdev)
1907 1908
1908 trace_regulator_disable_complete(rdev_get_name(rdev)); 1909 trace_regulator_disable_complete(rdev_get_name(rdev));
1909 1910
1910 _notifier_call_chain(rdev, REGULATOR_EVENT_DISABLE,
1911 NULL);
1912 return 0; 1911 return 0;
1913} 1912}
1914 1913
@@ -1932,6 +1931,8 @@ static int _regulator_disable(struct regulator_dev *rdev)
1932 rdev_err(rdev, "failed to disable\n"); 1931 rdev_err(rdev, "failed to disable\n");
1933 return ret; 1932 return ret;
1934 } 1933 }
1934 _notifier_call_chain(rdev, REGULATOR_EVENT_DISABLE,
1935 NULL);
1935 } 1936 }
1936 1937
1937 rdev->use_count = 0; 1938 rdev->use_count = 0;
@@ -1984,20 +1985,16 @@ static int _regulator_force_disable(struct regulator_dev *rdev)
1984{ 1985{
1985 int ret = 0; 1986 int ret = 0;
1986 1987
1987 /* force disable */ 1988 ret = _regulator_do_disable(rdev);
1988 if (rdev->desc->ops->disable) { 1989 if (ret < 0) {
1989 /* ah well, who wants to live forever... */ 1990 rdev_err(rdev, "failed to force disable\n");
1990 ret = rdev->desc->ops->disable(rdev); 1991 return ret;
1991 if (ret < 0) {
1992 rdev_err(rdev, "failed to force disable\n");
1993 return ret;
1994 }
1995 /* notify other consumers that power has been forced off */
1996 _notifier_call_chain(rdev, REGULATOR_EVENT_FORCE_DISABLE |
1997 REGULATOR_EVENT_DISABLE, NULL);
1998 } 1992 }
1999 1993
2000 return ret; 1994 _notifier_call_chain(rdev, REGULATOR_EVENT_FORCE_DISABLE |
1995 REGULATOR_EVENT_DISABLE, NULL);
1996
1997 return 0;
2001} 1998}
2002 1999
2003/** 2000/**
@@ -3630,23 +3627,18 @@ int regulator_suspend_finish(void)
3630 3627
3631 mutex_lock(&regulator_list_mutex); 3628 mutex_lock(&regulator_list_mutex);
3632 list_for_each_entry(rdev, &regulator_list, list) { 3629 list_for_each_entry(rdev, &regulator_list, list) {
3633 struct regulator_ops *ops = rdev->desc->ops;
3634
3635 mutex_lock(&rdev->mutex); 3630 mutex_lock(&rdev->mutex);
3636 if ((rdev->use_count > 0 || rdev->constraints->always_on) && 3631 if (rdev->use_count > 0 || rdev->constraints->always_on) {
3637 ops->enable) { 3632 error = _regulator_do_enable(rdev);
3638 error = ops->enable(rdev);
3639 if (error) 3633 if (error)
3640 ret = error; 3634 ret = error;
3641 } else { 3635 } else {
3642 if (!have_full_constraints()) 3636 if (!have_full_constraints())
3643 goto unlock; 3637 goto unlock;
3644 if (!ops->disable)
3645 goto unlock;
3646 if (!_regulator_is_enabled(rdev)) 3638 if (!_regulator_is_enabled(rdev))
3647 goto unlock; 3639 goto unlock;
3648 3640
3649 error = ops->disable(rdev); 3641 error = _regulator_do_disable(rdev);
3650 if (error) 3642 if (error)
3651 ret = error; 3643 ret = error;
3652 } 3644 }
@@ -3820,7 +3812,7 @@ static int __init regulator_init_complete(void)
3820 ops = rdev->desc->ops; 3812 ops = rdev->desc->ops;
3821 c = rdev->constraints; 3813 c = rdev->constraints;
3822 3814
3823 if (!ops->disable || (c && c->always_on)) 3815 if (c && c->always_on)
3824 continue; 3816 continue;
3825 3817
3826 mutex_lock(&rdev->mutex); 3818 mutex_lock(&rdev->mutex);
@@ -3841,7 +3833,7 @@ static int __init regulator_init_complete(void)
3841 /* We log since this may kill the system if it 3833 /* We log since this may kill the system if it
3842 * goes wrong. */ 3834 * goes wrong. */
3843 rdev_info(rdev, "disabling\n"); 3835 rdev_info(rdev, "disabling\n");
3844 ret = ops->disable(rdev); 3836 ret = _regulator_do_disable(rdev);
3845 if (ret != 0) 3837 if (ret != 0)
3846 rdev_err(rdev, "couldn't disable: %d\n", ret); 3838 rdev_err(rdev, "couldn't disable: %d\n", ret);
3847 } else { 3839 } else {
diff --git a/drivers/regulator/da9063-regulator.c b/drivers/regulator/da9063-regulator.c
index 56727eb745df..91e99a2c8dc1 100644
--- a/drivers/regulator/da9063-regulator.c
+++ b/drivers/regulator/da9063-regulator.c
@@ -1,3 +1,4 @@
1
1/* 2/*
2 * Regulator driver for DA9063 PMIC series 3 * Regulator driver for DA9063 PMIC series
3 * 4 *
@@ -60,7 +61,8 @@ struct da9063_regulator_info {
60 .desc.ops = &da9063_ldo_ops, \ 61 .desc.ops = &da9063_ldo_ops, \
61 .desc.min_uV = (min_mV) * 1000, \ 62 .desc.min_uV = (min_mV) * 1000, \
62 .desc.uV_step = (step_mV) * 1000, \ 63 .desc.uV_step = (step_mV) * 1000, \
63 .desc.n_voltages = (((max_mV) - (min_mV))/(step_mV) + 1), \ 64 .desc.n_voltages = (((max_mV) - (min_mV))/(step_mV) + 1 \
65 + (DA9063_V##regl_name##_BIAS)), \
64 .desc.enable_reg = DA9063_REG_##regl_name##_CONT, \ 66 .desc.enable_reg = DA9063_REG_##regl_name##_CONT, \
65 .desc.enable_mask = DA9063_LDO_EN, \ 67 .desc.enable_mask = DA9063_LDO_EN, \
66 .desc.vsel_reg = DA9063_REG_V##regl_name##_A, \ 68 .desc.vsel_reg = DA9063_REG_V##regl_name##_A, \
diff --git a/drivers/regulator/max14577.c b/drivers/regulator/max14577.c
index 186df8785a91..e0619526708c 100644
--- a/drivers/regulator/max14577.c
+++ b/drivers/regulator/max14577.c
@@ -166,9 +166,10 @@ static int max14577_regulator_dt_parse_pdata(struct platform_device *pdev)
166 166
167 ret = of_regulator_match(&pdev->dev, np, max14577_regulator_matches, 167 ret = of_regulator_match(&pdev->dev, np, max14577_regulator_matches,
168 MAX14577_REG_MAX); 168 MAX14577_REG_MAX);
169 if (ret < 0) { 169 if (ret < 0)
170 dev_err(&pdev->dev, "Error parsing regulator init data: %d\n", ret); 170 dev_err(&pdev->dev, "Error parsing regulator init data: %d\n", ret);
171 } 171 else
172 ret = 0;
172 173
173 of_node_put(np); 174 of_node_put(np);
174 175
diff --git a/drivers/regulator/s5m8767.c b/drivers/regulator/s5m8767.c
index d7164bb75d3e..d958dfa05125 100644
--- a/drivers/regulator/s5m8767.c
+++ b/drivers/regulator/s5m8767.c
@@ -535,7 +535,7 @@ static int s5m8767_pmic_dt_parse_pdata(struct platform_device *pdev,
535 return -ENODEV; 535 return -ENODEV;
536 } 536 }
537 537
538 regulators_np = of_find_node_by_name(pmic_np, "regulators"); 538 regulators_np = of_get_child_by_name(pmic_np, "regulators");
539 if (!regulators_np) { 539 if (!regulators_np) {
540 dev_err(iodev->dev, "could not find regulators sub-node\n"); 540 dev_err(iodev->dev, "could not find regulators sub-node\n");
541 return -EINVAL; 541 return -EINVAL;
@@ -591,6 +591,8 @@ static int s5m8767_pmic_dt_parse_pdata(struct platform_device *pdev,
591 rmode++; 591 rmode++;
592 } 592 }
593 593
594 of_node_put(regulators_np);
595
594 if (of_get_property(pmic_np, "s5m8767,pmic-buck2-uses-gpio-dvs", NULL)) { 596 if (of_get_property(pmic_np, "s5m8767,pmic-buck2-uses-gpio-dvs", NULL)) {
595 pdata->buck2_gpiodvs = true; 597 pdata->buck2_gpiodvs = true;
596 598
diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c
index 7afd373b9595..c4cde9c08f1f 100644
--- a/drivers/rtc/rtc-s3c.c
+++ b/drivers/rtc/rtc-s3c.c
@@ -580,10 +580,12 @@ static int s3c_rtc_suspend(struct device *dev)
580 580
581 clk_enable(rtc_clk); 581 clk_enable(rtc_clk);
582 /* save TICNT for anyone using periodic interrupts */ 582 /* save TICNT for anyone using periodic interrupts */
583 ticnt_save = readb(s3c_rtc_base + S3C2410_TICNT);
584 if (s3c_rtc_cpu_type == TYPE_S3C64XX) { 583 if (s3c_rtc_cpu_type == TYPE_S3C64XX) {
585 ticnt_en_save = readw(s3c_rtc_base + S3C2410_RTCCON); 584 ticnt_en_save = readw(s3c_rtc_base + S3C2410_RTCCON);
586 ticnt_en_save &= S3C64XX_RTCCON_TICEN; 585 ticnt_en_save &= S3C64XX_RTCCON_TICEN;
586 ticnt_save = readl(s3c_rtc_base + S3C2410_TICNT);
587 } else {
588 ticnt_save = readb(s3c_rtc_base + S3C2410_TICNT);
587 } 589 }
588 s3c_rtc_enable(pdev, 0); 590 s3c_rtc_enable(pdev, 0);
589 591
@@ -605,10 +607,15 @@ static int s3c_rtc_resume(struct device *dev)
605 607
606 clk_enable(rtc_clk); 608 clk_enable(rtc_clk);
607 s3c_rtc_enable(pdev, 1); 609 s3c_rtc_enable(pdev, 1);
608 writeb(ticnt_save, s3c_rtc_base + S3C2410_TICNT); 610 if (s3c_rtc_cpu_type == TYPE_S3C64XX) {
609 if (s3c_rtc_cpu_type == TYPE_S3C64XX && ticnt_en_save) { 611 writel(ticnt_save, s3c_rtc_base + S3C2410_TICNT);
610 tmp = readw(s3c_rtc_base + S3C2410_RTCCON); 612 if (ticnt_en_save) {
611 writew(tmp | ticnt_en_save, s3c_rtc_base + S3C2410_RTCCON); 613 tmp = readw(s3c_rtc_base + S3C2410_RTCCON);
614 writew(tmp | ticnt_en_save,
615 s3c_rtc_base + S3C2410_RTCCON);
616 }
617 } else {
618 writeb(ticnt_save, s3c_rtc_base + S3C2410_TICNT);
612 } 619 }
613 620
614 if (device_may_wakeup(dev) && wake_en) { 621 if (device_may_wakeup(dev) && wake_en) {
diff --git a/drivers/s390/cio/chsc.c b/drivers/s390/cio/chsc.c
index f6b9188c5af5..9f0ea6cb6922 100644
--- a/drivers/s390/cio/chsc.c
+++ b/drivers/s390/cio/chsc.c
@@ -610,6 +610,7 @@ void chsc_chp_online(struct chp_id chpid)
610 css_wait_for_slow_path(); 610 css_wait_for_slow_path();
611 for_each_subchannel_staged(__s390_process_res_acc, NULL, 611 for_each_subchannel_staged(__s390_process_res_acc, NULL,
612 &link); 612 &link);
613 css_schedule_reprobe();
613 } 614 }
614} 615}
615 616
diff --git a/drivers/s390/crypto/zcrypt_msgtype6.c b/drivers/s390/crypto/zcrypt_msgtype6.c
index dc542e0a3055..0bc91e46395a 100644
--- a/drivers/s390/crypto/zcrypt_msgtype6.c
+++ b/drivers/s390/crypto/zcrypt_msgtype6.c
@@ -311,7 +311,7 @@ static int XCRB_msg_to_type6CPRB_msgX(struct zcrypt_device *zdev,
311 } __packed * msg = ap_msg->message; 311 } __packed * msg = ap_msg->message;
312 312
313 int rcblen = CEIL4(xcRB->request_control_blk_length); 313 int rcblen = CEIL4(xcRB->request_control_blk_length);
314 int replylen; 314 int replylen, req_sumlen, resp_sumlen;
315 char *req_data = ap_msg->message + sizeof(struct type6_hdr) + rcblen; 315 char *req_data = ap_msg->message + sizeof(struct type6_hdr) + rcblen;
316 char *function_code; 316 char *function_code;
317 317
@@ -321,12 +321,34 @@ static int XCRB_msg_to_type6CPRB_msgX(struct zcrypt_device *zdev,
321 xcRB->request_data_length; 321 xcRB->request_data_length;
322 if (ap_msg->length > MSGTYPE06_MAX_MSG_SIZE) 322 if (ap_msg->length > MSGTYPE06_MAX_MSG_SIZE)
323 return -EINVAL; 323 return -EINVAL;
324
325 /* Overflow check
326 sum must be greater (or equal) than the largest operand */
327 req_sumlen = CEIL4(xcRB->request_control_blk_length) +
328 xcRB->request_data_length;
329 if ((CEIL4(xcRB->request_control_blk_length) <=
330 xcRB->request_data_length) ?
331 (req_sumlen < xcRB->request_data_length) :
332 (req_sumlen < CEIL4(xcRB->request_control_blk_length))) {
333 return -EINVAL;
334 }
335
324 replylen = sizeof(struct type86_fmt2_msg) + 336 replylen = sizeof(struct type86_fmt2_msg) +
325 CEIL4(xcRB->reply_control_blk_length) + 337 CEIL4(xcRB->reply_control_blk_length) +
326 xcRB->reply_data_length; 338 xcRB->reply_data_length;
327 if (replylen > MSGTYPE06_MAX_MSG_SIZE) 339 if (replylen > MSGTYPE06_MAX_MSG_SIZE)
328 return -EINVAL; 340 return -EINVAL;
329 341
342 /* Overflow check
343 sum must be greater (or equal) than the largest operand */
344 resp_sumlen = CEIL4(xcRB->reply_control_blk_length) +
345 xcRB->reply_data_length;
346 if ((CEIL4(xcRB->reply_control_blk_length) <= xcRB->reply_data_length) ?
347 (resp_sumlen < xcRB->reply_data_length) :
348 (resp_sumlen < CEIL4(xcRB->reply_control_blk_length))) {
349 return -EINVAL;
350 }
351
330 /* prepare type6 header */ 352 /* prepare type6 header */
331 msg->hdr = static_type6_hdrX; 353 msg->hdr = static_type6_hdrX;
332 memcpy(msg->hdr.agent_id , &(xcRB->agent_ID), sizeof(xcRB->agent_ID)); 354 memcpy(msg->hdr.agent_id , &(xcRB->agent_ID), sizeof(xcRB->agent_ID));
diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c
index c3a83df07894..795ed61a5496 100644
--- a/drivers/s390/net/qeth_core_main.c
+++ b/drivers/s390/net/qeth_core_main.c
@@ -1660,7 +1660,6 @@ int qeth_qdio_clear_card(struct qeth_card *card, int use_halt)
1660 QDIO_FLAG_CLEANUP_USING_CLEAR); 1660 QDIO_FLAG_CLEANUP_USING_CLEAR);
1661 if (rc) 1661 if (rc)
1662 QETH_CARD_TEXT_(card, 3, "1err%d", rc); 1662 QETH_CARD_TEXT_(card, 3, "1err%d", rc);
1663 qdio_free(CARD_DDEV(card));
1664 atomic_set(&card->qdio.state, QETH_QDIO_ALLOCATED); 1663 atomic_set(&card->qdio.state, QETH_QDIO_ALLOCATED);
1665 break; 1664 break;
1666 case QETH_QDIO_CLEANING: 1665 case QETH_QDIO_CLEANING:
@@ -2605,6 +2604,7 @@ static int qeth_mpc_initialize(struct qeth_card *card)
2605 return 0; 2604 return 0;
2606out_qdio: 2605out_qdio:
2607 qeth_qdio_clear_card(card, card->info.type != QETH_CARD_TYPE_IQD); 2606 qeth_qdio_clear_card(card, card->info.type != QETH_CARD_TYPE_IQD);
2607 qdio_free(CARD_DDEV(card));
2608 return rc; 2608 return rc;
2609} 2609}
2610 2610
@@ -4906,9 +4906,11 @@ retry:
4906 if (retries < 3) 4906 if (retries < 3)
4907 QETH_DBF_MESSAGE(2, "%s Retrying to do IDX activates.\n", 4907 QETH_DBF_MESSAGE(2, "%s Retrying to do IDX activates.\n",
4908 dev_name(&card->gdev->dev)); 4908 dev_name(&card->gdev->dev));
4909 rc = qeth_qdio_clear_card(card, card->info.type != QETH_CARD_TYPE_IQD);
4909 ccw_device_set_offline(CARD_DDEV(card)); 4910 ccw_device_set_offline(CARD_DDEV(card));
4910 ccw_device_set_offline(CARD_WDEV(card)); 4911 ccw_device_set_offline(CARD_WDEV(card));
4911 ccw_device_set_offline(CARD_RDEV(card)); 4912 ccw_device_set_offline(CARD_RDEV(card));
4913 qdio_free(CARD_DDEV(card));
4912 rc = ccw_device_set_online(CARD_RDEV(card)); 4914 rc = ccw_device_set_online(CARD_RDEV(card));
4913 if (rc) 4915 if (rc)
4914 goto retriable; 4916 goto retriable;
@@ -4918,7 +4920,6 @@ retry:
4918 rc = ccw_device_set_online(CARD_DDEV(card)); 4920 rc = ccw_device_set_online(CARD_DDEV(card));
4919 if (rc) 4921 if (rc)
4920 goto retriable; 4922 goto retriable;
4921 rc = qeth_qdio_clear_card(card, card->info.type != QETH_CARD_TYPE_IQD);
4922retriable: 4923retriable:
4923 if (rc == -ERESTARTSYS) { 4924 if (rc == -ERESTARTSYS) {
4924 QETH_DBF_TEXT(SETUP, 2, "break1"); 4925 QETH_DBF_TEXT(SETUP, 2, "break1");
diff --git a/drivers/s390/net/qeth_l2_main.c b/drivers/s390/net/qeth_l2_main.c
index 0710550093ce..908d82529ee9 100644
--- a/drivers/s390/net/qeth_l2_main.c
+++ b/drivers/s390/net/qeth_l2_main.c
@@ -1091,6 +1091,7 @@ out_remove:
1091 ccw_device_set_offline(CARD_DDEV(card)); 1091 ccw_device_set_offline(CARD_DDEV(card));
1092 ccw_device_set_offline(CARD_WDEV(card)); 1092 ccw_device_set_offline(CARD_WDEV(card));
1093 ccw_device_set_offline(CARD_RDEV(card)); 1093 ccw_device_set_offline(CARD_RDEV(card));
1094 qdio_free(CARD_DDEV(card));
1094 if (recover_flag == CARD_STATE_RECOVER) 1095 if (recover_flag == CARD_STATE_RECOVER)
1095 card->state = CARD_STATE_RECOVER; 1096 card->state = CARD_STATE_RECOVER;
1096 else 1097 else
@@ -1132,6 +1133,7 @@ static int __qeth_l2_set_offline(struct ccwgroup_device *cgdev,
1132 rc = (rc2) ? rc2 : rc3; 1133 rc = (rc2) ? rc2 : rc3;
1133 if (rc) 1134 if (rc)
1134 QETH_DBF_TEXT_(SETUP, 2, "1err%d", rc); 1135 QETH_DBF_TEXT_(SETUP, 2, "1err%d", rc);
1136 qdio_free(CARD_DDEV(card));
1135 if (recover_flag == CARD_STATE_UP) 1137 if (recover_flag == CARD_STATE_UP)
1136 card->state = CARD_STATE_RECOVER; 1138 card->state = CARD_STATE_RECOVER;
1137 /* let user_space know that device is offline */ 1139 /* let user_space know that device is offline */
@@ -1194,6 +1196,7 @@ static void qeth_l2_shutdown(struct ccwgroup_device *gdev)
1194 qeth_hw_trap(card, QETH_DIAGS_TRAP_DISARM); 1196 qeth_hw_trap(card, QETH_DIAGS_TRAP_DISARM);
1195 qeth_qdio_clear_card(card, 0); 1197 qeth_qdio_clear_card(card, 0);
1196 qeth_clear_qdio_buffers(card); 1198 qeth_clear_qdio_buffers(card);
1199 qdio_free(CARD_DDEV(card));
1197} 1200}
1198 1201
1199static int qeth_l2_pm_suspend(struct ccwgroup_device *gdev) 1202static int qeth_l2_pm_suspend(struct ccwgroup_device *gdev)
diff --git a/drivers/s390/net/qeth_l3_main.c b/drivers/s390/net/qeth_l3_main.c
index 0f430424c3b8..3524d34ff694 100644
--- a/drivers/s390/net/qeth_l3_main.c
+++ b/drivers/s390/net/qeth_l3_main.c
@@ -3447,6 +3447,7 @@ out_remove:
3447 ccw_device_set_offline(CARD_DDEV(card)); 3447 ccw_device_set_offline(CARD_DDEV(card));
3448 ccw_device_set_offline(CARD_WDEV(card)); 3448 ccw_device_set_offline(CARD_WDEV(card));
3449 ccw_device_set_offline(CARD_RDEV(card)); 3449 ccw_device_set_offline(CARD_RDEV(card));
3450 qdio_free(CARD_DDEV(card));
3450 if (recover_flag == CARD_STATE_RECOVER) 3451 if (recover_flag == CARD_STATE_RECOVER)
3451 card->state = CARD_STATE_RECOVER; 3452 card->state = CARD_STATE_RECOVER;
3452 else 3453 else
@@ -3493,6 +3494,7 @@ static int __qeth_l3_set_offline(struct ccwgroup_device *cgdev,
3493 rc = (rc2) ? rc2 : rc3; 3494 rc = (rc2) ? rc2 : rc3;
3494 if (rc) 3495 if (rc)
3495 QETH_DBF_TEXT_(SETUP, 2, "1err%d", rc); 3496 QETH_DBF_TEXT_(SETUP, 2, "1err%d", rc);
3497 qdio_free(CARD_DDEV(card));
3496 if (recover_flag == CARD_STATE_UP) 3498 if (recover_flag == CARD_STATE_UP)
3497 card->state = CARD_STATE_RECOVER; 3499 card->state = CARD_STATE_RECOVER;
3498 /* let user_space know that device is offline */ 3500 /* let user_space know that device is offline */
@@ -3545,6 +3547,7 @@ static void qeth_l3_shutdown(struct ccwgroup_device *gdev)
3545 qeth_hw_trap(card, QETH_DIAGS_TRAP_DISARM); 3547 qeth_hw_trap(card, QETH_DIAGS_TRAP_DISARM);
3546 qeth_qdio_clear_card(card, 0); 3548 qeth_qdio_clear_card(card, 0);
3547 qeth_clear_qdio_buffers(card); 3549 qeth_clear_qdio_buffers(card);
3550 qdio_free(CARD_DDEV(card));
3548} 3551}
3549 3552
3550static int qeth_l3_pm_suspend(struct ccwgroup_device *gdev) 3553static int qeth_l3_pm_suspend(struct ccwgroup_device *gdev)
diff --git a/drivers/sbus/char/jsflash.c b/drivers/sbus/char/jsflash.c
index 6b4678a7900a..4ccb5d869389 100644
--- a/drivers/sbus/char/jsflash.c
+++ b/drivers/sbus/char/jsflash.c
@@ -507,7 +507,6 @@ static int jsflash_init(void)
507 } 507 }
508 508
509 /* Let us be really paranoid for modifications to probing code. */ 509 /* Let us be really paranoid for modifications to probing code. */
510 /* extern enum sparc_cpu sparc_cpu_model; */ /* in <asm/system.h> */
511 if (sparc_cpu_model != sun4m) { 510 if (sparc_cpu_model != sun4m) {
512 /* We must be on sun4m because we use MMU Bypass ASI. */ 511 /* We must be on sun4m because we use MMU Bypass ASI. */
513 return -ENXIO; 512 return -ENXIO;
diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c
index 2eb97d7e8d12..0cb73074c199 100644
--- a/drivers/scsi/qla2xxx/qla_target.c
+++ b/drivers/scsi/qla2xxx/qla_target.c
@@ -790,17 +790,32 @@ static inline int test_tgt_sess_count(struct qla_tgt *tgt)
790} 790}
791 791
792/* Called by tcm_qla2xxx configfs code */ 792/* Called by tcm_qla2xxx configfs code */
793void qlt_stop_phase1(struct qla_tgt *tgt) 793int qlt_stop_phase1(struct qla_tgt *tgt)
794{ 794{
795 struct scsi_qla_host *vha = tgt->vha; 795 struct scsi_qla_host *vha = tgt->vha;
796 struct qla_hw_data *ha = tgt->ha; 796 struct qla_hw_data *ha = tgt->ha;
797 unsigned long flags; 797 unsigned long flags;
798 798
799 mutex_lock(&qla_tgt_mutex);
800 if (!vha->fc_vport) {
801 struct Scsi_Host *sh = vha->host;
802 struct fc_host_attrs *fc_host = shost_to_fc_host(sh);
803 bool npiv_vports;
804
805 spin_lock_irqsave(sh->host_lock, flags);
806 npiv_vports = (fc_host->npiv_vports_inuse);
807 spin_unlock_irqrestore(sh->host_lock, flags);
808
809 if (npiv_vports) {
810 mutex_unlock(&qla_tgt_mutex);
811 return -EPERM;
812 }
813 }
799 if (tgt->tgt_stop || tgt->tgt_stopped) { 814 if (tgt->tgt_stop || tgt->tgt_stopped) {
800 ql_dbg(ql_dbg_tgt_mgt, vha, 0xf04e, 815 ql_dbg(ql_dbg_tgt_mgt, vha, 0xf04e,
801 "Already in tgt->tgt_stop or tgt_stopped state\n"); 816 "Already in tgt->tgt_stop or tgt_stopped state\n");
802 dump_stack(); 817 mutex_unlock(&qla_tgt_mutex);
803 return; 818 return -EPERM;
804 } 819 }
805 820
806 ql_dbg(ql_dbg_tgt, vha, 0xe003, "Stopping target for host %ld(%p)\n", 821 ql_dbg(ql_dbg_tgt, vha, 0xe003, "Stopping target for host %ld(%p)\n",
@@ -815,6 +830,7 @@ void qlt_stop_phase1(struct qla_tgt *tgt)
815 qlt_clear_tgt_db(tgt, true); 830 qlt_clear_tgt_db(tgt, true);
816 spin_unlock_irqrestore(&ha->hardware_lock, flags); 831 spin_unlock_irqrestore(&ha->hardware_lock, flags);
817 mutex_unlock(&vha->vha_tgt.tgt_mutex); 832 mutex_unlock(&vha->vha_tgt.tgt_mutex);
833 mutex_unlock(&qla_tgt_mutex);
818 834
819 flush_delayed_work(&tgt->sess_del_work); 835 flush_delayed_work(&tgt->sess_del_work);
820 836
@@ -841,6 +857,7 @@ void qlt_stop_phase1(struct qla_tgt *tgt)
841 857
842 /* Wait for sessions to clear out (just in case) */ 858 /* Wait for sessions to clear out (just in case) */
843 wait_event(tgt->waitQ, test_tgt_sess_count(tgt)); 859 wait_event(tgt->waitQ, test_tgt_sess_count(tgt));
860 return 0;
844} 861}
845EXPORT_SYMBOL(qlt_stop_phase1); 862EXPORT_SYMBOL(qlt_stop_phase1);
846 863
@@ -3185,7 +3202,8 @@ restart:
3185 ql_dbg(ql_dbg_tgt_mgt, vha, 0xf02c, 3202 ql_dbg(ql_dbg_tgt_mgt, vha, 0xf02c,
3186 "SRR cmd %p (se_cmd %p, tag %d, op %x), " 3203 "SRR cmd %p (se_cmd %p, tag %d, op %x), "
3187 "sg_cnt=%d, offset=%d", cmd, &cmd->se_cmd, cmd->tag, 3204 "sg_cnt=%d, offset=%d", cmd, &cmd->se_cmd, cmd->tag,
3188 se_cmd->t_task_cdb[0], cmd->sg_cnt, cmd->offset); 3205 se_cmd->t_task_cdb ? se_cmd->t_task_cdb[0] : 0,
3206 cmd->sg_cnt, cmd->offset);
3189 3207
3190 qlt_handle_srr(vha, sctio, imm); 3208 qlt_handle_srr(vha, sctio, imm);
3191 3209
@@ -4181,6 +4199,9 @@ int qlt_add_target(struct qla_hw_data *ha, struct scsi_qla_host *base_vha)
4181 tgt->datasegs_per_cmd = QLA_TGT_DATASEGS_PER_CMD_24XX; 4199 tgt->datasegs_per_cmd = QLA_TGT_DATASEGS_PER_CMD_24XX;
4182 tgt->datasegs_per_cont = QLA_TGT_DATASEGS_PER_CONT_24XX; 4200 tgt->datasegs_per_cont = QLA_TGT_DATASEGS_PER_CONT_24XX;
4183 4201
4202 if (base_vha->fc_vport)
4203 return 0;
4204
4184 mutex_lock(&qla_tgt_mutex); 4205 mutex_lock(&qla_tgt_mutex);
4185 list_add_tail(&tgt->tgt_list_entry, &qla_tgt_glist); 4206 list_add_tail(&tgt->tgt_list_entry, &qla_tgt_glist);
4186 mutex_unlock(&qla_tgt_mutex); 4207 mutex_unlock(&qla_tgt_mutex);
@@ -4194,6 +4215,10 @@ int qlt_remove_target(struct qla_hw_data *ha, struct scsi_qla_host *vha)
4194 if (!vha->vha_tgt.qla_tgt) 4215 if (!vha->vha_tgt.qla_tgt)
4195 return 0; 4216 return 0;
4196 4217
4218 if (vha->fc_vport) {
4219 qlt_release(vha->vha_tgt.qla_tgt);
4220 return 0;
4221 }
4197 mutex_lock(&qla_tgt_mutex); 4222 mutex_lock(&qla_tgt_mutex);
4198 list_del(&vha->vha_tgt.qla_tgt->tgt_list_entry); 4223 list_del(&vha->vha_tgt.qla_tgt->tgt_list_entry);
4199 mutex_unlock(&qla_tgt_mutex); 4224 mutex_unlock(&qla_tgt_mutex);
@@ -4265,6 +4290,12 @@ int qlt_lport_register(void *target_lport_ptr, u64 phys_wwpn,
4265 spin_unlock_irqrestore(&ha->hardware_lock, flags); 4290 spin_unlock_irqrestore(&ha->hardware_lock, flags);
4266 continue; 4291 continue;
4267 } 4292 }
4293 if (tgt->tgt_stop) {
4294 pr_debug("MODE_TARGET in shutdown on qla2xxx(%d)\n",
4295 host->host_no);
4296 spin_unlock_irqrestore(&ha->hardware_lock, flags);
4297 continue;
4298 }
4268 spin_unlock_irqrestore(&ha->hardware_lock, flags); 4299 spin_unlock_irqrestore(&ha->hardware_lock, flags);
4269 4300
4270 if (!scsi_host_get(host)) { 4301 if (!scsi_host_get(host)) {
@@ -4279,12 +4310,11 @@ int qlt_lport_register(void *target_lport_ptr, u64 phys_wwpn,
4279 scsi_host_put(host); 4310 scsi_host_put(host);
4280 continue; 4311 continue;
4281 } 4312 }
4282 mutex_unlock(&qla_tgt_mutex);
4283
4284 rc = (*callback)(vha, target_lport_ptr, npiv_wwpn, npiv_wwnn); 4313 rc = (*callback)(vha, target_lport_ptr, npiv_wwpn, npiv_wwnn);
4285 if (rc != 0) 4314 if (rc != 0)
4286 scsi_host_put(host); 4315 scsi_host_put(host);
4287 4316
4317 mutex_unlock(&qla_tgt_mutex);
4288 return rc; 4318 return rc;
4289 } 4319 }
4290 mutex_unlock(&qla_tgt_mutex); 4320 mutex_unlock(&qla_tgt_mutex);
diff --git a/drivers/scsi/qla2xxx/qla_target.h b/drivers/scsi/qla2xxx/qla_target.h
index 66e755cdde57..ce33d8c26406 100644
--- a/drivers/scsi/qla2xxx/qla_target.h
+++ b/drivers/scsi/qla2xxx/qla_target.h
@@ -1001,7 +1001,7 @@ extern void qlt_modify_vp_config(struct scsi_qla_host *,
1001extern void qlt_probe_one_stage1(struct scsi_qla_host *, struct qla_hw_data *); 1001extern void qlt_probe_one_stage1(struct scsi_qla_host *, struct qla_hw_data *);
1002extern int qlt_mem_alloc(struct qla_hw_data *); 1002extern int qlt_mem_alloc(struct qla_hw_data *);
1003extern void qlt_mem_free(struct qla_hw_data *); 1003extern void qlt_mem_free(struct qla_hw_data *);
1004extern void qlt_stop_phase1(struct qla_tgt *); 1004extern int qlt_stop_phase1(struct qla_tgt *);
1005extern void qlt_stop_phase2(struct qla_tgt *); 1005extern void qlt_stop_phase2(struct qla_tgt *);
1006extern irqreturn_t qla83xx_msix_atio_q(int, void *); 1006extern irqreturn_t qla83xx_msix_atio_q(int, void *);
1007extern void qlt_83xx_iospace_config(struct qla_hw_data *); 1007extern void qlt_83xx_iospace_config(struct qla_hw_data *);
diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
index 75a141bbe74d..788c4fe2b0c9 100644
--- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c
+++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
@@ -182,20 +182,6 @@ static int tcm_qla2xxx_npiv_parse_wwn(
182 return 0; 182 return 0;
183} 183}
184 184
185static ssize_t tcm_qla2xxx_npiv_format_wwn(char *buf, size_t len,
186 u64 wwpn, u64 wwnn)
187{
188 u8 b[8], b2[8];
189
190 put_unaligned_be64(wwpn, b);
191 put_unaligned_be64(wwnn, b2);
192 return snprintf(buf, len,
193 "%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x,"
194 "%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x",
195 b[0], b[1], b[2], b[3], b[4], b[5], b[6], b[7],
196 b2[0], b2[1], b2[2], b2[3], b2[4], b2[5], b2[6], b2[7]);
197}
198
199static char *tcm_qla2xxx_npiv_get_fabric_name(void) 185static char *tcm_qla2xxx_npiv_get_fabric_name(void)
200{ 186{
201 return "qla2xxx_npiv"; 187 return "qla2xxx_npiv";
@@ -227,15 +213,6 @@ static char *tcm_qla2xxx_get_fabric_wwn(struct se_portal_group *se_tpg)
227 return lport->lport_naa_name; 213 return lport->lport_naa_name;
228} 214}
229 215
230static char *tcm_qla2xxx_npiv_get_fabric_wwn(struct se_portal_group *se_tpg)
231{
232 struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg,
233 struct tcm_qla2xxx_tpg, se_tpg);
234 struct tcm_qla2xxx_lport *lport = tpg->lport;
235
236 return &lport->lport_npiv_name[0];
237}
238
239static u16 tcm_qla2xxx_get_tag(struct se_portal_group *se_tpg) 216static u16 tcm_qla2xxx_get_tag(struct se_portal_group *se_tpg)
240{ 217{
241 struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg, 218 struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg,
@@ -941,15 +918,41 @@ static ssize_t tcm_qla2xxx_tpg_show_enable(
941 atomic_read(&tpg->lport_tpg_enabled)); 918 atomic_read(&tpg->lport_tpg_enabled));
942} 919}
943 920
921static void tcm_qla2xxx_depend_tpg(struct work_struct *work)
922{
923 struct tcm_qla2xxx_tpg *base_tpg = container_of(work,
924 struct tcm_qla2xxx_tpg, tpg_base_work);
925 struct se_portal_group *se_tpg = &base_tpg->se_tpg;
926 struct scsi_qla_host *base_vha = base_tpg->lport->qla_vha;
927
928 if (!configfs_depend_item(se_tpg->se_tpg_tfo->tf_subsys,
929 &se_tpg->tpg_group.cg_item)) {
930 atomic_set(&base_tpg->lport_tpg_enabled, 1);
931 qlt_enable_vha(base_vha);
932 }
933 complete(&base_tpg->tpg_base_comp);
934}
935
936static void tcm_qla2xxx_undepend_tpg(struct work_struct *work)
937{
938 struct tcm_qla2xxx_tpg *base_tpg = container_of(work,
939 struct tcm_qla2xxx_tpg, tpg_base_work);
940 struct se_portal_group *se_tpg = &base_tpg->se_tpg;
941 struct scsi_qla_host *base_vha = base_tpg->lport->qla_vha;
942
943 if (!qlt_stop_phase1(base_vha->vha_tgt.qla_tgt)) {
944 atomic_set(&base_tpg->lport_tpg_enabled, 0);
945 configfs_undepend_item(se_tpg->se_tpg_tfo->tf_subsys,
946 &se_tpg->tpg_group.cg_item);
947 }
948 complete(&base_tpg->tpg_base_comp);
949}
950
944static ssize_t tcm_qla2xxx_tpg_store_enable( 951static ssize_t tcm_qla2xxx_tpg_store_enable(
945 struct se_portal_group *se_tpg, 952 struct se_portal_group *se_tpg,
946 const char *page, 953 const char *page,
947 size_t count) 954 size_t count)
948{ 955{
949 struct se_wwn *se_wwn = se_tpg->se_tpg_wwn;
950 struct tcm_qla2xxx_lport *lport = container_of(se_wwn,
951 struct tcm_qla2xxx_lport, lport_wwn);
952 struct scsi_qla_host *vha = lport->qla_vha;
953 struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg, 956 struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg,
954 struct tcm_qla2xxx_tpg, se_tpg); 957 struct tcm_qla2xxx_tpg, se_tpg);
955 unsigned long op; 958 unsigned long op;
@@ -964,19 +967,28 @@ static ssize_t tcm_qla2xxx_tpg_store_enable(
964 pr_err("Illegal value for tpg_enable: %lu\n", op); 967 pr_err("Illegal value for tpg_enable: %lu\n", op);
965 return -EINVAL; 968 return -EINVAL;
966 } 969 }
967
968 if (op) { 970 if (op) {
969 atomic_set(&tpg->lport_tpg_enabled, 1); 971 if (atomic_read(&tpg->lport_tpg_enabled))
970 qlt_enable_vha(vha); 972 return -EEXIST;
973
974 INIT_WORK(&tpg->tpg_base_work, tcm_qla2xxx_depend_tpg);
971 } else { 975 } else {
972 if (!vha->vha_tgt.qla_tgt) { 976 if (!atomic_read(&tpg->lport_tpg_enabled))
973 pr_err("struct qla_hw_data *vha->vha_tgt.qla_tgt is NULL\n"); 977 return count;
974 return -ENODEV; 978
975 } 979 INIT_WORK(&tpg->tpg_base_work, tcm_qla2xxx_undepend_tpg);
976 atomic_set(&tpg->lport_tpg_enabled, 0);
977 qlt_stop_phase1(vha->vha_tgt.qla_tgt);
978 } 980 }
981 init_completion(&tpg->tpg_base_comp);
982 schedule_work(&tpg->tpg_base_work);
983 wait_for_completion(&tpg->tpg_base_comp);
979 984
985 if (op) {
986 if (!atomic_read(&tpg->lport_tpg_enabled))
987 return -ENODEV;
988 } else {
989 if (atomic_read(&tpg->lport_tpg_enabled))
990 return -EPERM;
991 }
980 return count; 992 return count;
981} 993}
982 994
@@ -1053,11 +1065,64 @@ static void tcm_qla2xxx_drop_tpg(struct se_portal_group *se_tpg)
1053 /* 1065 /*
1054 * Clear local TPG=1 pointer for non NPIV mode. 1066 * Clear local TPG=1 pointer for non NPIV mode.
1055 */ 1067 */
1056 lport->tpg_1 = NULL; 1068 lport->tpg_1 = NULL;
1057
1058 kfree(tpg); 1069 kfree(tpg);
1059} 1070}
1060 1071
1072static ssize_t tcm_qla2xxx_npiv_tpg_show_enable(
1073 struct se_portal_group *se_tpg,
1074 char *page)
1075{
1076 return tcm_qla2xxx_tpg_show_enable(se_tpg, page);
1077}
1078
1079static ssize_t tcm_qla2xxx_npiv_tpg_store_enable(
1080 struct se_portal_group *se_tpg,
1081 const char *page,
1082 size_t count)
1083{
1084 struct se_wwn *se_wwn = se_tpg->se_tpg_wwn;
1085 struct tcm_qla2xxx_lport *lport = container_of(se_wwn,
1086 struct tcm_qla2xxx_lport, lport_wwn);
1087 struct scsi_qla_host *vha = lport->qla_vha;
1088 struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg,
1089 struct tcm_qla2xxx_tpg, se_tpg);
1090 unsigned long op;
1091 int rc;
1092
1093 rc = kstrtoul(page, 0, &op);
1094 if (rc < 0) {
1095 pr_err("kstrtoul() returned %d\n", rc);
1096 return -EINVAL;
1097 }
1098 if ((op != 1) && (op != 0)) {
1099 pr_err("Illegal value for tpg_enable: %lu\n", op);
1100 return -EINVAL;
1101 }
1102 if (op) {
1103 if (atomic_read(&tpg->lport_tpg_enabled))
1104 return -EEXIST;
1105
1106 atomic_set(&tpg->lport_tpg_enabled, 1);
1107 qlt_enable_vha(vha);
1108 } else {
1109 if (!atomic_read(&tpg->lport_tpg_enabled))
1110 return count;
1111
1112 atomic_set(&tpg->lport_tpg_enabled, 0);
1113 qlt_stop_phase1(vha->vha_tgt.qla_tgt);
1114 }
1115
1116 return count;
1117}
1118
1119TF_TPG_BASE_ATTR(tcm_qla2xxx_npiv, enable, S_IRUGO | S_IWUSR);
1120
1121static struct configfs_attribute *tcm_qla2xxx_npiv_tpg_attrs[] = {
1122 &tcm_qla2xxx_npiv_tpg_enable.attr,
1123 NULL,
1124};
1125
1061static struct se_portal_group *tcm_qla2xxx_npiv_make_tpg( 1126static struct se_portal_group *tcm_qla2xxx_npiv_make_tpg(
1062 struct se_wwn *wwn, 1127 struct se_wwn *wwn,
1063 struct config_group *group, 1128 struct config_group *group,
@@ -1650,6 +1715,9 @@ static int tcm_qla2xxx_lport_register_npiv_cb(struct scsi_qla_host *base_vha,
1650 struct scsi_qla_host *npiv_vha; 1715 struct scsi_qla_host *npiv_vha;
1651 struct tcm_qla2xxx_lport *lport = 1716 struct tcm_qla2xxx_lport *lport =
1652 (struct tcm_qla2xxx_lport *)target_lport_ptr; 1717 (struct tcm_qla2xxx_lport *)target_lport_ptr;
1718 struct tcm_qla2xxx_lport *base_lport =
1719 (struct tcm_qla2xxx_lport *)base_vha->vha_tgt.target_lport_ptr;
1720 struct tcm_qla2xxx_tpg *base_tpg;
1653 struct fc_vport_identifiers vport_id; 1721 struct fc_vport_identifiers vport_id;
1654 1722
1655 if (!qla_tgt_mode_enabled(base_vha)) { 1723 if (!qla_tgt_mode_enabled(base_vha)) {
@@ -1657,6 +1725,13 @@ static int tcm_qla2xxx_lport_register_npiv_cb(struct scsi_qla_host *base_vha,
1657 return -EPERM; 1725 return -EPERM;
1658 } 1726 }
1659 1727
1728 if (!base_lport || !base_lport->tpg_1 ||
1729 !atomic_read(&base_lport->tpg_1->lport_tpg_enabled)) {
1730 pr_err("qla2xxx base_lport or tpg_1 not available\n");
1731 return -EPERM;
1732 }
1733 base_tpg = base_lport->tpg_1;
1734
1660 memset(&vport_id, 0, sizeof(vport_id)); 1735 memset(&vport_id, 0, sizeof(vport_id));
1661 vport_id.port_name = npiv_wwpn; 1736 vport_id.port_name = npiv_wwpn;
1662 vport_id.node_name = npiv_wwnn; 1737 vport_id.node_name = npiv_wwnn;
@@ -1675,7 +1750,6 @@ static int tcm_qla2xxx_lport_register_npiv_cb(struct scsi_qla_host *base_vha,
1675 npiv_vha = (struct scsi_qla_host *)vport->dd_data; 1750 npiv_vha = (struct scsi_qla_host *)vport->dd_data;
1676 npiv_vha->vha_tgt.target_lport_ptr = target_lport_ptr; 1751 npiv_vha->vha_tgt.target_lport_ptr = target_lport_ptr;
1677 lport->qla_vha = npiv_vha; 1752 lport->qla_vha = npiv_vha;
1678
1679 scsi_host_get(npiv_vha->host); 1753 scsi_host_get(npiv_vha->host);
1680 return 0; 1754 return 0;
1681} 1755}
@@ -1714,8 +1788,6 @@ static struct se_wwn *tcm_qla2xxx_npiv_make_lport(
1714 } 1788 }
1715 lport->lport_npiv_wwpn = npiv_wwpn; 1789 lport->lport_npiv_wwpn = npiv_wwpn;
1716 lport->lport_npiv_wwnn = npiv_wwnn; 1790 lport->lport_npiv_wwnn = npiv_wwnn;
1717 tcm_qla2xxx_npiv_format_wwn(&lport->lport_npiv_name[0],
1718 TCM_QLA2XXX_NAMELEN, npiv_wwpn, npiv_wwnn);
1719 sprintf(lport->lport_naa_name, "naa.%016llx", (unsigned long long) npiv_wwpn); 1791 sprintf(lport->lport_naa_name, "naa.%016llx", (unsigned long long) npiv_wwpn);
1720 1792
1721 ret = tcm_qla2xxx_init_lport(lport); 1793 ret = tcm_qla2xxx_init_lport(lport);
@@ -1824,7 +1896,7 @@ static struct target_core_fabric_ops tcm_qla2xxx_ops = {
1824static struct target_core_fabric_ops tcm_qla2xxx_npiv_ops = { 1896static struct target_core_fabric_ops tcm_qla2xxx_npiv_ops = {
1825 .get_fabric_name = tcm_qla2xxx_npiv_get_fabric_name, 1897 .get_fabric_name = tcm_qla2xxx_npiv_get_fabric_name,
1826 .get_fabric_proto_ident = tcm_qla2xxx_get_fabric_proto_ident, 1898 .get_fabric_proto_ident = tcm_qla2xxx_get_fabric_proto_ident,
1827 .tpg_get_wwn = tcm_qla2xxx_npiv_get_fabric_wwn, 1899 .tpg_get_wwn = tcm_qla2xxx_get_fabric_wwn,
1828 .tpg_get_tag = tcm_qla2xxx_get_tag, 1900 .tpg_get_tag = tcm_qla2xxx_get_tag,
1829 .tpg_get_default_depth = tcm_qla2xxx_get_default_depth, 1901 .tpg_get_default_depth = tcm_qla2xxx_get_default_depth,
1830 .tpg_get_pr_transport_id = tcm_qla2xxx_get_pr_transport_id, 1902 .tpg_get_pr_transport_id = tcm_qla2xxx_get_pr_transport_id,
@@ -1935,7 +2007,7 @@ static int tcm_qla2xxx_register_configfs(void)
1935 */ 2007 */
1936 npiv_fabric->tf_cit_tmpl.tfc_wwn_cit.ct_attrs = tcm_qla2xxx_wwn_attrs; 2008 npiv_fabric->tf_cit_tmpl.tfc_wwn_cit.ct_attrs = tcm_qla2xxx_wwn_attrs;
1937 npiv_fabric->tf_cit_tmpl.tfc_tpg_base_cit.ct_attrs = 2009 npiv_fabric->tf_cit_tmpl.tfc_tpg_base_cit.ct_attrs =
1938 tcm_qla2xxx_tpg_attrs; 2010 tcm_qla2xxx_npiv_tpg_attrs;
1939 npiv_fabric->tf_cit_tmpl.tfc_tpg_attrib_cit.ct_attrs = NULL; 2011 npiv_fabric->tf_cit_tmpl.tfc_tpg_attrib_cit.ct_attrs = NULL;
1940 npiv_fabric->tf_cit_tmpl.tfc_tpg_param_cit.ct_attrs = NULL; 2012 npiv_fabric->tf_cit_tmpl.tfc_tpg_param_cit.ct_attrs = NULL;
1941 npiv_fabric->tf_cit_tmpl.tfc_tpg_np_base_cit.ct_attrs = NULL; 2013 npiv_fabric->tf_cit_tmpl.tfc_tpg_np_base_cit.ct_attrs = NULL;
diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.h b/drivers/scsi/qla2xxx/tcm_qla2xxx.h
index 275d8b9a7a34..33aaac8c7d59 100644
--- a/drivers/scsi/qla2xxx/tcm_qla2xxx.h
+++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.h
@@ -4,8 +4,6 @@
4#define TCM_QLA2XXX_VERSION "v0.1" 4#define TCM_QLA2XXX_VERSION "v0.1"
5/* length of ASCII WWPNs including pad */ 5/* length of ASCII WWPNs including pad */
6#define TCM_QLA2XXX_NAMELEN 32 6#define TCM_QLA2XXX_NAMELEN 32
7/* lenth of ASCII NPIV 'WWPN+WWNN' including pad */
8#define TCM_QLA2XXX_NPIV_NAMELEN 66
9 7
10#include "qla_target.h" 8#include "qla_target.h"
11 9
@@ -43,6 +41,9 @@ struct tcm_qla2xxx_tpg {
43 struct tcm_qla2xxx_tpg_attrib tpg_attrib; 41 struct tcm_qla2xxx_tpg_attrib tpg_attrib;
44 /* Returned by tcm_qla2xxx_make_tpg() */ 42 /* Returned by tcm_qla2xxx_make_tpg() */
45 struct se_portal_group se_tpg; 43 struct se_portal_group se_tpg;
44 /* Items for dealing with configfs_depend_item */
45 struct completion tpg_base_comp;
46 struct work_struct tpg_base_work;
46}; 47};
47 48
48struct tcm_qla2xxx_fc_loopid { 49struct tcm_qla2xxx_fc_loopid {
@@ -62,8 +63,6 @@ struct tcm_qla2xxx_lport {
62 char lport_name[TCM_QLA2XXX_NAMELEN]; 63 char lport_name[TCM_QLA2XXX_NAMELEN];
63 /* ASCII formatted naa WWPN for VPD page 83 etc */ 64 /* ASCII formatted naa WWPN for VPD page 83 etc */
64 char lport_naa_name[TCM_QLA2XXX_NAMELEN]; 65 char lport_naa_name[TCM_QLA2XXX_NAMELEN];
65 /* ASCII formatted WWPN+WWNN for NPIV FC Target Lport */
66 char lport_npiv_name[TCM_QLA2XXX_NPIV_NAMELEN];
67 /* map for fc_port pointers in 24-bit FC Port ID space */ 66 /* map for fc_port pointers in 24-bit FC Port ID space */
68 struct btree_head32 lport_fcport_map; 67 struct btree_head32 lport_fcport_map;
69 /* vmalloc-ed memory for fc_port pointers for 16-bit FC loop ID */ 68 /* vmalloc-ed memory for fc_port pointers for 16-bit FC loop ID */
diff --git a/drivers/staging/android/binder.c b/drivers/staging/android/binder.c
index eaec1dab7fe4..1432d956769c 100644
--- a/drivers/staging/android/binder.c
+++ b/drivers/staging/android/binder.c
@@ -2904,7 +2904,7 @@ static int binder_node_release(struct binder_node *node, int refs)
2904 refs++; 2904 refs++;
2905 2905
2906 if (!ref->death) 2906 if (!ref->death)
2907 goto out; 2907 continue;
2908 2908
2909 death++; 2909 death++;
2910 2910
@@ -2917,7 +2917,6 @@ static int binder_node_release(struct binder_node *node, int refs)
2917 BUG(); 2917 BUG();
2918 } 2918 }
2919 2919
2920out:
2921 binder_debug(BINDER_DEBUG_DEAD_BINDER, 2920 binder_debug(BINDER_DEBUG_DEAD_BINDER,
2922 "node %d now dead, refs %d, death %d\n", 2921 "node %d now dead, refs %d, death %d\n",
2923 node->debug_id, refs, death); 2922 node->debug_id, refs, death);
diff --git a/drivers/staging/iio/adc/mxs-lradc.c b/drivers/staging/iio/adc/mxs-lradc.c
index 7fc66a6a6e36..514844efac75 100644
--- a/drivers/staging/iio/adc/mxs-lradc.c
+++ b/drivers/staging/iio/adc/mxs-lradc.c
@@ -757,6 +757,7 @@ static void mxs_lradc_finish_touch_event(struct mxs_lradc *lradc, bool valid)
757 } 757 }
758 758
759 /* if it is released, wait for the next touch via IRQ */ 759 /* if it is released, wait for the next touch via IRQ */
760 lradc->cur_plate = LRADC_TOUCH;
760 mxs_lradc_reg_clear(lradc, LRADC_CTRL1_TOUCH_DETECT_IRQ, LRADC_CTRL1); 761 mxs_lradc_reg_clear(lradc, LRADC_CTRL1_TOUCH_DETECT_IRQ, LRADC_CTRL1);
761 mxs_lradc_reg_set(lradc, LRADC_CTRL1_TOUCH_DETECT_IRQ_EN, LRADC_CTRL1); 762 mxs_lradc_reg_set(lradc, LRADC_CTRL1_TOUCH_DETECT_IRQ_EN, LRADC_CTRL1);
762} 763}
diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c b/drivers/staging/rtl8188eu/os_dep/usb_intf.c
index a70dcef1419e..2f40ff5901d6 100644
--- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c
+++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c
@@ -55,6 +55,7 @@ static struct usb_device_id rtw_usb_id_tbl[] = {
55 /****** 8188EUS ********/ 55 /****** 8188EUS ********/
56 {USB_DEVICE(0x07b8, 0x8179)}, /* Abocom - Abocom */ 56 {USB_DEVICE(0x07b8, 0x8179)}, /* Abocom - Abocom */
57 {USB_DEVICE(0x2001, 0x330F)}, /* DLink DWA-125 REV D1 */ 57 {USB_DEVICE(0x2001, 0x330F)}, /* DLink DWA-125 REV D1 */
58 {USB_DEVICE(0x2001, 0x3310)}, /* Dlink DWA-123 REV D1 */
58 {} /* Terminating entry */ 59 {} /* Terminating entry */
59}; 60};
60 61
diff --git a/drivers/target/target_core_sbc.c b/drivers/target/target_core_sbc.c
index a4489444ffbc..42f18fc1067b 100644
--- a/drivers/target/target_core_sbc.c
+++ b/drivers/target/target_core_sbc.c
@@ -1074,7 +1074,7 @@ sbc_dif_copy_prot(struct se_cmd *cmd, unsigned int sectors, bool read,
1074 struct scatterlist *psg; 1074 struct scatterlist *psg;
1075 void *paddr, *addr; 1075 void *paddr, *addr;
1076 unsigned int i, len, left; 1076 unsigned int i, len, left;
1077 unsigned int offset = 0; 1077 unsigned int offset = sg_off;
1078 1078
1079 left = sectors * dev->prot_length; 1079 left = sectors * dev->prot_length;
1080 1080
@@ -1084,11 +1084,10 @@ sbc_dif_copy_prot(struct se_cmd *cmd, unsigned int sectors, bool read,
1084 if (offset >= sg->length) { 1084 if (offset >= sg->length) {
1085 sg = sg_next(sg); 1085 sg = sg_next(sg);
1086 offset = 0; 1086 offset = 0;
1087 sg_off = sg->offset;
1088 } 1087 }
1089 1088
1090 paddr = kmap_atomic(sg_page(psg)) + psg->offset; 1089 paddr = kmap_atomic(sg_page(psg)) + psg->offset;
1091 addr = kmap_atomic(sg_page(sg)) + sg_off; 1090 addr = kmap_atomic(sg_page(sg)) + sg->offset + offset;
1092 1091
1093 if (read) 1092 if (read)
1094 memcpy(paddr, addr, len); 1093 memcpy(paddr, addr, len);
@@ -1163,7 +1162,7 @@ sbc_dif_verify_read(struct se_cmd *cmd, sector_t start, unsigned int sectors,
1163{ 1162{
1164 struct se_device *dev = cmd->se_dev; 1163 struct se_device *dev = cmd->se_dev;
1165 struct se_dif_v1_tuple *sdt; 1164 struct se_dif_v1_tuple *sdt;
1166 struct scatterlist *dsg; 1165 struct scatterlist *dsg, *psg = sg;
1167 sector_t sector = start; 1166 sector_t sector = start;
1168 void *daddr, *paddr; 1167 void *daddr, *paddr;
1169 int i, j, offset = sg_off; 1168 int i, j, offset = sg_off;
@@ -1171,14 +1170,14 @@ sbc_dif_verify_read(struct se_cmd *cmd, sector_t start, unsigned int sectors,
1171 1170
1172 for_each_sg(cmd->t_data_sg, dsg, cmd->t_data_nents, i) { 1171 for_each_sg(cmd->t_data_sg, dsg, cmd->t_data_nents, i) {
1173 daddr = kmap_atomic(sg_page(dsg)) + dsg->offset; 1172 daddr = kmap_atomic(sg_page(dsg)) + dsg->offset;
1174 paddr = kmap_atomic(sg_page(sg)) + sg->offset; 1173 paddr = kmap_atomic(sg_page(psg)) + sg->offset;
1175 1174
1176 for (j = 0; j < dsg->length; j += dev->dev_attrib.block_size) { 1175 for (j = 0; j < dsg->length; j += dev->dev_attrib.block_size) {
1177 1176
1178 if (offset >= sg->length) { 1177 if (offset >= psg->length) {
1179 kunmap_atomic(paddr); 1178 kunmap_atomic(paddr);
1180 sg = sg_next(sg); 1179 psg = sg_next(psg);
1181 paddr = kmap_atomic(sg_page(sg)) + sg->offset; 1180 paddr = kmap_atomic(sg_page(psg)) + psg->offset;
1182 offset = 0; 1181 offset = 0;
1183 } 1182 }
1184 1183
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index 24b4f65d8777..2956250b7225 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -1601,6 +1601,9 @@ void transport_generic_request_failure(struct se_cmd *cmd,
1601 case TCM_CHECK_CONDITION_ABORT_CMD: 1601 case TCM_CHECK_CONDITION_ABORT_CMD:
1602 case TCM_CHECK_CONDITION_UNIT_ATTENTION: 1602 case TCM_CHECK_CONDITION_UNIT_ATTENTION:
1603 case TCM_CHECK_CONDITION_NOT_READY: 1603 case TCM_CHECK_CONDITION_NOT_READY:
1604 case TCM_LOGICAL_BLOCK_GUARD_CHECK_FAILED:
1605 case TCM_LOGICAL_BLOCK_APP_TAG_CHECK_FAILED:
1606 case TCM_LOGICAL_BLOCK_REF_TAG_CHECK_FAILED:
1604 break; 1607 break;
1605 case TCM_OUT_OF_RESOURCES: 1608 case TCM_OUT_OF_RESOURCES:
1606 sense_reason = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; 1609 sense_reason = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index bd2715a9d8e5..c74a00ad7add 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -1267,17 +1267,16 @@ static void pty_line_name(struct tty_driver *driver, int index, char *p)
1267 * @p: output buffer of at least 7 bytes 1267 * @p: output buffer of at least 7 bytes
1268 * 1268 *
1269 * Generate a name from a driver reference and write it to the output 1269 * Generate a name from a driver reference and write it to the output
1270 * buffer. Return the number of bytes written. 1270 * buffer.
1271 * 1271 *
1272 * Locking: None 1272 * Locking: None
1273 */ 1273 */
1274static ssize_t tty_line_name(struct tty_driver *driver, int index, char *p) 1274static void tty_line_name(struct tty_driver *driver, int index, char *p)
1275{ 1275{
1276 if (driver->flags & TTY_DRIVER_UNNUMBERED_NODE) 1276 if (driver->flags & TTY_DRIVER_UNNUMBERED_NODE)
1277 return sprintf(p, "%s", driver->name); 1277 strcpy(p, driver->name);
1278 else 1278 else
1279 return sprintf(p, "%s%d", driver->name, 1279 sprintf(p, "%s%d", driver->name, index + driver->name_base);
1280 index + driver->name_base);
1281} 1280}
1282 1281
1283/** 1282/**
@@ -3546,19 +3545,9 @@ static ssize_t show_cons_active(struct device *dev,
3546 if (i >= ARRAY_SIZE(cs)) 3545 if (i >= ARRAY_SIZE(cs))
3547 break; 3546 break;
3548 } 3547 }
3549 while (i--) { 3548 while (i--)
3550 struct tty_driver *driver; 3549 count += sprintf(buf + count, "%s%d%c",
3551 const char *name = cs[i]->name; 3550 cs[i]->name, cs[i]->index, i ? ' ':'\n');
3552 int index = cs[i]->index;
3553
3554 driver = cs[i]->device(cs[i], &index);
3555 if (driver) {
3556 count += tty_line_name(driver, index, buf + count);
3557 count += sprintf(buf + count, "%c", i ? ' ':'\n');
3558 } else
3559 count += sprintf(buf + count, "%s%d%c",
3560 name, index, i ? ' ':'\n');
3561 }
3562 console_unlock(); 3551 console_unlock();
3563 3552
3564 return count; 3553 return count;
diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index 80de2f88ed2c..4ab2cb62dfce 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -105,7 +105,7 @@ static int hw_ep_flush(struct ci_hdrc *ci, int num, int dir)
105 105
106 do { 106 do {
107 /* flush any pending transfer */ 107 /* flush any pending transfer */
108 hw_write(ci, OP_ENDPTFLUSH, BIT(n), BIT(n)); 108 hw_write(ci, OP_ENDPTFLUSH, ~0, BIT(n));
109 while (hw_read(ci, OP_ENDPTFLUSH, BIT(n))) 109 while (hw_read(ci, OP_ENDPTFLUSH, BIT(n)))
110 cpu_relax(); 110 cpu_relax();
111 } while (hw_read(ci, OP_ENDPTSTAT, BIT(n))); 111 } while (hw_read(ci, OP_ENDPTSTAT, BIT(n)));
@@ -205,7 +205,7 @@ static int hw_ep_prime(struct ci_hdrc *ci, int num, int dir, int is_ctrl)
205 if (is_ctrl && dir == RX && hw_read(ci, OP_ENDPTSETUPSTAT, BIT(num))) 205 if (is_ctrl && dir == RX && hw_read(ci, OP_ENDPTSETUPSTAT, BIT(num)))
206 return -EAGAIN; 206 return -EAGAIN;
207 207
208 hw_write(ci, OP_ENDPTPRIME, BIT(n), BIT(n)); 208 hw_write(ci, OP_ENDPTPRIME, ~0, BIT(n));
209 209
210 while (hw_read(ci, OP_ENDPTPRIME, BIT(n))) 210 while (hw_read(ci, OP_ENDPTPRIME, BIT(n)))
211 cpu_relax(); 211 cpu_relax();
diff --git a/drivers/usb/gadget/bcm63xx_udc.c b/drivers/usb/gadget/bcm63xx_udc.c
index 888fbb43b338..e969eb809a85 100644
--- a/drivers/usb/gadget/bcm63xx_udc.c
+++ b/drivers/usb/gadget/bcm63xx_udc.c
@@ -360,24 +360,30 @@ static inline void usb_dma_writel(struct bcm63xx_udc *udc, u32 val, u32 off)
360 bcm_writel(val, udc->iudma_regs + off); 360 bcm_writel(val, udc->iudma_regs + off);
361} 361}
362 362
363static inline u32 usb_dmac_readl(struct bcm63xx_udc *udc, u32 off) 363static inline u32 usb_dmac_readl(struct bcm63xx_udc *udc, u32 off, int chan)
364{ 364{
365 return bcm_readl(udc->iudma_regs + IUDMA_DMAC_OFFSET + off); 365 return bcm_readl(udc->iudma_regs + IUDMA_DMAC_OFFSET + off +
366 (ENETDMA_CHAN_WIDTH * chan));
366} 367}
367 368
368static inline void usb_dmac_writel(struct bcm63xx_udc *udc, u32 val, u32 off) 369static inline void usb_dmac_writel(struct bcm63xx_udc *udc, u32 val, u32 off,
370 int chan)
369{ 371{
370 bcm_writel(val, udc->iudma_regs + IUDMA_DMAC_OFFSET + off); 372 bcm_writel(val, udc->iudma_regs + IUDMA_DMAC_OFFSET + off +
373 (ENETDMA_CHAN_WIDTH * chan));
371} 374}
372 375
373static inline u32 usb_dmas_readl(struct bcm63xx_udc *udc, u32 off) 376static inline u32 usb_dmas_readl(struct bcm63xx_udc *udc, u32 off, int chan)
374{ 377{
375 return bcm_readl(udc->iudma_regs + IUDMA_DMAS_OFFSET + off); 378 return bcm_readl(udc->iudma_regs + IUDMA_DMAS_OFFSET + off +
379 (ENETDMA_CHAN_WIDTH * chan));
376} 380}
377 381
378static inline void usb_dmas_writel(struct bcm63xx_udc *udc, u32 val, u32 off) 382static inline void usb_dmas_writel(struct bcm63xx_udc *udc, u32 val, u32 off,
383 int chan)
379{ 384{
380 bcm_writel(val, udc->iudma_regs + IUDMA_DMAS_OFFSET + off); 385 bcm_writel(val, udc->iudma_regs + IUDMA_DMAS_OFFSET + off +
386 (ENETDMA_CHAN_WIDTH * chan));
381} 387}
382 388
383static inline void set_clocks(struct bcm63xx_udc *udc, bool is_enabled) 389static inline void set_clocks(struct bcm63xx_udc *udc, bool is_enabled)
@@ -638,7 +644,7 @@ static void iudma_write(struct bcm63xx_udc *udc, struct iudma_ch *iudma,
638 } while (!last_bd); 644 } while (!last_bd);
639 645
640 usb_dmac_writel(udc, ENETDMAC_CHANCFG_EN_MASK, 646 usb_dmac_writel(udc, ENETDMAC_CHANCFG_EN_MASK,
641 ENETDMAC_CHANCFG_REG(iudma->ch_idx)); 647 ENETDMAC_CHANCFG_REG, iudma->ch_idx);
642} 648}
643 649
644/** 650/**
@@ -694,9 +700,9 @@ static void iudma_reset_channel(struct bcm63xx_udc *udc, struct iudma_ch *iudma)
694 bcm63xx_fifo_reset_ep(udc, max(0, iudma->ep_num)); 700 bcm63xx_fifo_reset_ep(udc, max(0, iudma->ep_num));
695 701
696 /* stop DMA, then wait for the hardware to wrap up */ 702 /* stop DMA, then wait for the hardware to wrap up */
697 usb_dmac_writel(udc, 0, ENETDMAC_CHANCFG_REG(ch_idx)); 703 usb_dmac_writel(udc, 0, ENETDMAC_CHANCFG_REG, ch_idx);
698 704
699 while (usb_dmac_readl(udc, ENETDMAC_CHANCFG_REG(ch_idx)) & 705 while (usb_dmac_readl(udc, ENETDMAC_CHANCFG_REG, ch_idx) &
700 ENETDMAC_CHANCFG_EN_MASK) { 706 ENETDMAC_CHANCFG_EN_MASK) {
701 udelay(1); 707 udelay(1);
702 708
@@ -713,10 +719,10 @@ static void iudma_reset_channel(struct bcm63xx_udc *udc, struct iudma_ch *iudma)
713 dev_warn(udc->dev, "forcibly halting IUDMA channel %d\n", 719 dev_warn(udc->dev, "forcibly halting IUDMA channel %d\n",
714 ch_idx); 720 ch_idx);
715 usb_dmac_writel(udc, ENETDMAC_CHANCFG_BUFHALT_MASK, 721 usb_dmac_writel(udc, ENETDMAC_CHANCFG_BUFHALT_MASK,
716 ENETDMAC_CHANCFG_REG(ch_idx)); 722 ENETDMAC_CHANCFG_REG, ch_idx);
717 } 723 }
718 } 724 }
719 usb_dmac_writel(udc, ~0, ENETDMAC_IR_REG(ch_idx)); 725 usb_dmac_writel(udc, ~0, ENETDMAC_IR_REG, ch_idx);
720 726
721 /* don't leave "live" HW-owned entries for the next guy to step on */ 727 /* don't leave "live" HW-owned entries for the next guy to step on */
722 for (d = iudma->bd_ring; d <= iudma->end_bd; d++) 728 for (d = iudma->bd_ring; d <= iudma->end_bd; d++)
@@ -728,11 +734,11 @@ static void iudma_reset_channel(struct bcm63xx_udc *udc, struct iudma_ch *iudma)
728 734
729 /* set up IRQs, UBUS burst size, and BD base for this channel */ 735 /* set up IRQs, UBUS burst size, and BD base for this channel */
730 usb_dmac_writel(udc, ENETDMAC_IR_BUFDONE_MASK, 736 usb_dmac_writel(udc, ENETDMAC_IR_BUFDONE_MASK,
731 ENETDMAC_IRMASK_REG(ch_idx)); 737 ENETDMAC_IRMASK_REG, ch_idx);
732 usb_dmac_writel(udc, 8, ENETDMAC_MAXBURST_REG(ch_idx)); 738 usb_dmac_writel(udc, 8, ENETDMAC_MAXBURST_REG, ch_idx);
733 739
734 usb_dmas_writel(udc, iudma->bd_ring_dma, ENETDMAS_RSTART_REG(ch_idx)); 740 usb_dmas_writel(udc, iudma->bd_ring_dma, ENETDMAS_RSTART_REG, ch_idx);
735 usb_dmas_writel(udc, 0, ENETDMAS_SRAM2_REG(ch_idx)); 741 usb_dmas_writel(udc, 0, ENETDMAS_SRAM2_REG, ch_idx);
736} 742}
737 743
738/** 744/**
@@ -2035,7 +2041,7 @@ static irqreturn_t bcm63xx_udc_data_isr(int irq, void *dev_id)
2035 spin_lock(&udc->lock); 2041 spin_lock(&udc->lock);
2036 2042
2037 usb_dmac_writel(udc, ENETDMAC_IR_BUFDONE_MASK, 2043 usb_dmac_writel(udc, ENETDMAC_IR_BUFDONE_MASK,
2038 ENETDMAC_IR_REG(iudma->ch_idx)); 2044 ENETDMAC_IR_REG, iudma->ch_idx);
2039 bep = iudma->bep; 2045 bep = iudma->bep;
2040 rc = iudma_read(udc, iudma); 2046 rc = iudma_read(udc, iudma);
2041 2047
@@ -2175,18 +2181,18 @@ static int bcm63xx_iudma_dbg_show(struct seq_file *s, void *p)
2175 seq_printf(s, " [ep%d]:\n", 2181 seq_printf(s, " [ep%d]:\n",
2176 max_t(int, iudma_defaults[ch_idx].ep_num, 0)); 2182 max_t(int, iudma_defaults[ch_idx].ep_num, 0));
2177 seq_printf(s, " cfg: %08x; irqstat: %08x; irqmask: %08x; maxburst: %08x\n", 2183 seq_printf(s, " cfg: %08x; irqstat: %08x; irqmask: %08x; maxburst: %08x\n",
2178 usb_dmac_readl(udc, ENETDMAC_CHANCFG_REG(ch_idx)), 2184 usb_dmac_readl(udc, ENETDMAC_CHANCFG_REG, ch_idx),
2179 usb_dmac_readl(udc, ENETDMAC_IR_REG(ch_idx)), 2185 usb_dmac_readl(udc, ENETDMAC_IR_REG, ch_idx),
2180 usb_dmac_readl(udc, ENETDMAC_IRMASK_REG(ch_idx)), 2186 usb_dmac_readl(udc, ENETDMAC_IRMASK_REG, ch_idx),
2181 usb_dmac_readl(udc, ENETDMAC_MAXBURST_REG(ch_idx))); 2187 usb_dmac_readl(udc, ENETDMAC_MAXBURST_REG, ch_idx));
2182 2188
2183 sram2 = usb_dmas_readl(udc, ENETDMAS_SRAM2_REG(ch_idx)); 2189 sram2 = usb_dmas_readl(udc, ENETDMAS_SRAM2_REG, ch_idx);
2184 sram3 = usb_dmas_readl(udc, ENETDMAS_SRAM3_REG(ch_idx)); 2190 sram3 = usb_dmas_readl(udc, ENETDMAS_SRAM3_REG, ch_idx);
2185 seq_printf(s, " base: %08x; index: %04x_%04x; desc: %04x_%04x %08x\n", 2191 seq_printf(s, " base: %08x; index: %04x_%04x; desc: %04x_%04x %08x\n",
2186 usb_dmas_readl(udc, ENETDMAS_RSTART_REG(ch_idx)), 2192 usb_dmas_readl(udc, ENETDMAS_RSTART_REG, ch_idx),
2187 sram2 >> 16, sram2 & 0xffff, 2193 sram2 >> 16, sram2 & 0xffff,
2188 sram3 >> 16, sram3 & 0xffff, 2194 sram3 >> 16, sram3 & 0xffff,
2189 usb_dmas_readl(udc, ENETDMAS_SRAM4_REG(ch_idx))); 2195 usb_dmas_readl(udc, ENETDMAS_SRAM4_REG, ch_idx));
2190 seq_printf(s, " desc: %d/%d used", iudma->n_bds_used, 2196 seq_printf(s, " desc: %d/%d used", iudma->n_bds_used,
2191 iudma->n_bds); 2197 iudma->n_bds);
2192 2198
diff --git a/drivers/usb/gadget/f_fs.c b/drivers/usb/gadget/f_fs.c
index 306a2b52125c..2b4334394076 100644
--- a/drivers/usb/gadget/f_fs.c
+++ b/drivers/usb/gadget/f_fs.c
@@ -585,7 +585,6 @@ static ssize_t ffs_epfile_io(struct file *file,
585 char __user *buf, size_t len, int read) 585 char __user *buf, size_t len, int read)
586{ 586{
587 struct ffs_epfile *epfile = file->private_data; 587 struct ffs_epfile *epfile = file->private_data;
588 struct usb_gadget *gadget = epfile->ffs->gadget;
589 struct ffs_ep *ep; 588 struct ffs_ep *ep;
590 char *data = NULL; 589 char *data = NULL;
591 ssize_t ret, data_len; 590 ssize_t ret, data_len;
@@ -622,6 +621,12 @@ static ssize_t ffs_epfile_io(struct file *file,
622 /* Allocate & copy */ 621 /* Allocate & copy */
623 if (!halt) { 622 if (!halt) {
624 /* 623 /*
624 * if we _do_ wait above, the epfile->ffs->gadget might be NULL
625 * before the waiting completes, so do not assign to 'gadget' earlier
626 */
627 struct usb_gadget *gadget = epfile->ffs->gadget;
628
629 /*
625 * Controller may require buffer size to be aligned to 630 * Controller may require buffer size to be aligned to
626 * maxpacketsize of an out endpoint. 631 * maxpacketsize of an out endpoint.
627 */ 632 */
diff --git a/drivers/usb/gadget/printer.c b/drivers/usb/gadget/printer.c
index bf7a56b6d48a..69b76efd11e9 100644
--- a/drivers/usb/gadget/printer.c
+++ b/drivers/usb/gadget/printer.c
@@ -1157,7 +1157,7 @@ static int __init printer_bind_config(struct usb_configuration *c)
1157 1157
1158 usb_gadget_set_selfpowered(gadget); 1158 usb_gadget_set_selfpowered(gadget);
1159 1159
1160 if (gadget->is_otg) { 1160 if (gadget_is_otg(gadget)) {
1161 otg_descriptor.bmAttributes |= USB_OTG_HNP; 1161 otg_descriptor.bmAttributes |= USB_OTG_HNP;
1162 printer_cfg_driver.descriptors = otg_desc; 1162 printer_cfg_driver.descriptors = otg_desc;
1163 printer_cfg_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP; 1163 printer_cfg_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
diff --git a/drivers/usb/gadget/s3c2410_udc.c b/drivers/usb/gadget/s3c2410_udc.c
index f04b2c3154de..dd9678f85c58 100644
--- a/drivers/usb/gadget/s3c2410_udc.c
+++ b/drivers/usb/gadget/s3c2410_udc.c
@@ -1629,7 +1629,7 @@ static void s3c2410_udc_reinit(struct s3c2410_udc *dev)
1629 ep->ep.desc = NULL; 1629 ep->ep.desc = NULL;
1630 ep->halted = 0; 1630 ep->halted = 0;
1631 INIT_LIST_HEAD(&ep->queue); 1631 INIT_LIST_HEAD(&ep->queue);
1632 usb_ep_set_maxpacket_limit(&ep->ep, &ep->ep.maxpacket); 1632 usb_ep_set_maxpacket_limit(&ep->ep, ep->ep.maxpacket);
1633 } 1633 }
1634} 1634}
1635 1635
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 471142725ffe..81cda09b47e3 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -685,8 +685,15 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd)
685 struct ehci_hcd *ehci = hcd_to_ehci (hcd); 685 struct ehci_hcd *ehci = hcd_to_ehci (hcd);
686 u32 status, masked_status, pcd_status = 0, cmd; 686 u32 status, masked_status, pcd_status = 0, cmd;
687 int bh; 687 int bh;
688 unsigned long flags;
688 689
689 spin_lock (&ehci->lock); 690 /*
691 * For threadirqs option we use spin_lock_irqsave() variant to prevent
692 * deadlock with ehci hrtimer callback, because hrtimer callbacks run
693 * in interrupt context even when threadirqs is specified. We can go
694 * back to spin_lock() variant when hrtimer callbacks become threaded.
695 */
696 spin_lock_irqsave(&ehci->lock, flags);
690 697
691 status = ehci_readl(ehci, &ehci->regs->status); 698 status = ehci_readl(ehci, &ehci->regs->status);
692 699
@@ -704,7 +711,7 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd)
704 711
705 /* Shared IRQ? */ 712 /* Shared IRQ? */
706 if (!masked_status || unlikely(ehci->rh_state == EHCI_RH_HALTED)) { 713 if (!masked_status || unlikely(ehci->rh_state == EHCI_RH_HALTED)) {
707 spin_unlock(&ehci->lock); 714 spin_unlock_irqrestore(&ehci->lock, flags);
708 return IRQ_NONE; 715 return IRQ_NONE;
709 } 716 }
710 717
@@ -815,7 +822,7 @@ dead:
815 822
816 if (bh) 823 if (bh)
817 ehci_work (ehci); 824 ehci_work (ehci);
818 spin_unlock (&ehci->lock); 825 spin_unlock_irqrestore(&ehci->lock, flags);
819 if (pcd_status) 826 if (pcd_status)
820 usb_hcd_poll_rh_status(hcd); 827 usb_hcd_poll_rh_status(hcd);
821 return IRQ_HANDLED; 828 return IRQ_HANDLED;
diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
index 47b858fc50b2..7ae0c4d51741 100644
--- a/drivers/usb/host/ehci-hub.c
+++ b/drivers/usb/host/ehci-hub.c
@@ -238,6 +238,7 @@ static int ehci_bus_suspend (struct usb_hcd *hcd)
238 int port; 238 int port;
239 int mask; 239 int mask;
240 int changed; 240 int changed;
241 bool fs_idle_delay;
241 242
242 ehci_dbg(ehci, "suspend root hub\n"); 243 ehci_dbg(ehci, "suspend root hub\n");
243 244
@@ -272,6 +273,7 @@ static int ehci_bus_suspend (struct usb_hcd *hcd)
272 ehci->bus_suspended = 0; 273 ehci->bus_suspended = 0;
273 ehci->owned_ports = 0; 274 ehci->owned_ports = 0;
274 changed = 0; 275 changed = 0;
276 fs_idle_delay = false;
275 port = HCS_N_PORTS(ehci->hcs_params); 277 port = HCS_N_PORTS(ehci->hcs_params);
276 while (port--) { 278 while (port--) {
277 u32 __iomem *reg = &ehci->regs->port_status [port]; 279 u32 __iomem *reg = &ehci->regs->port_status [port];
@@ -300,16 +302,32 @@ static int ehci_bus_suspend (struct usb_hcd *hcd)
300 } 302 }
301 303
302 if (t1 != t2) { 304 if (t1 != t2) {
305 /*
306 * On some controllers, Wake-On-Disconnect will
307 * generate false wakeup signals until the bus
308 * switches over to full-speed idle. For their
309 * sake, add a delay if we need one.
310 */
311 if ((t2 & PORT_WKDISC_E) &&
312 ehci_port_speed(ehci, t2) ==
313 USB_PORT_STAT_HIGH_SPEED)
314 fs_idle_delay = true;
303 ehci_writel(ehci, t2, reg); 315 ehci_writel(ehci, t2, reg);
304 changed = 1; 316 changed = 1;
305 } 317 }
306 } 318 }
319 spin_unlock_irq(&ehci->lock);
320
321 if ((changed && ehci->has_tdi_phy_lpm) || fs_idle_delay) {
322 /*
323 * Wait for HCD to enter low-power mode or for the bus
324 * to switch to full-speed idle.
325 */
326 usleep_range(5000, 5500);
327 }
307 328
308 if (changed && ehci->has_tdi_phy_lpm) { 329 if (changed && ehci->has_tdi_phy_lpm) {
309 spin_unlock_irq(&ehci->lock);
310 msleep(5); /* 5 ms for HCD to enter low-power mode */
311 spin_lock_irq(&ehci->lock); 330 spin_lock_irq(&ehci->lock);
312
313 port = HCS_N_PORTS(ehci->hcs_params); 331 port = HCS_N_PORTS(ehci->hcs_params);
314 while (port--) { 332 while (port--) {
315 u32 __iomem *hostpc_reg = &ehci->regs->hostpc[port]; 333 u32 __iomem *hostpc_reg = &ehci->regs->hostpc[port];
@@ -322,8 +340,8 @@ static int ehci_bus_suspend (struct usb_hcd *hcd)
322 port, (t3 & HOSTPC_PHCD) ? 340 port, (t3 & HOSTPC_PHCD) ?
323 "succeeded" : "failed"); 341 "succeeded" : "failed");
324 } 342 }
343 spin_unlock_irq(&ehci->lock);
325 } 344 }
326 spin_unlock_irq(&ehci->lock);
327 345
328 /* Apparently some devices need a >= 1-uframe delay here */ 346 /* Apparently some devices need a >= 1-uframe delay here */
329 if (ehci->bus_suspended) 347 if (ehci->bus_suspended)
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index fc192ad9cc6a..239ad0b1ceb6 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -477,8 +477,11 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
477 musb->port1_status |= 477 musb->port1_status |=
478 (USB_PORT_STAT_C_SUSPEND << 16) 478 (USB_PORT_STAT_C_SUSPEND << 16)
479 | MUSB_PORT_STAT_RESUME; 479 | MUSB_PORT_STAT_RESUME;
480 musb->rh_timer = jiffies
481 + msecs_to_jiffies(20);
480 schedule_delayed_work( 482 schedule_delayed_work(
481 &musb->finish_resume_work, 20); 483 &musb->finish_resume_work,
484 msecs_to_jiffies(20));
482 485
483 musb->xceiv->state = OTG_STATE_A_HOST; 486 musb->xceiv->state = OTG_STATE_A_HOST;
484 musb->is_active = 1; 487 musb->is_active = 1;
@@ -2157,11 +2160,19 @@ static void musb_restore_context(struct musb *musb)
2157 void __iomem *musb_base = musb->mregs; 2160 void __iomem *musb_base = musb->mregs;
2158 void __iomem *ep_target_regs; 2161 void __iomem *ep_target_regs;
2159 void __iomem *epio; 2162 void __iomem *epio;
2163 u8 power;
2160 2164
2161 musb_writew(musb_base, MUSB_FRAME, musb->context.frame); 2165 musb_writew(musb_base, MUSB_FRAME, musb->context.frame);
2162 musb_writeb(musb_base, MUSB_TESTMODE, musb->context.testmode); 2166 musb_writeb(musb_base, MUSB_TESTMODE, musb->context.testmode);
2163 musb_write_ulpi_buscontrol(musb->mregs, musb->context.busctl); 2167 musb_write_ulpi_buscontrol(musb->mregs, musb->context.busctl);
2164 musb_writeb(musb_base, MUSB_POWER, musb->context.power); 2168
2169 /* Don't affect SUSPENDM/RESUME bits in POWER reg */
2170 power = musb_readb(musb_base, MUSB_POWER);
2171 power &= MUSB_POWER_SUSPENDM | MUSB_POWER_RESUME;
2172 musb->context.power &= ~(MUSB_POWER_SUSPENDM | MUSB_POWER_RESUME);
2173 power |= musb->context.power;
2174 musb_writeb(musb_base, MUSB_POWER, power);
2175
2165 musb_writew(musb_base, MUSB_INTRTXE, musb->intrtxe); 2176 musb_writew(musb_base, MUSB_INTRTXE, musb->intrtxe);
2166 musb_writew(musb_base, MUSB_INTRRXE, musb->intrrxe); 2177 musb_writew(musb_base, MUSB_INTRRXE, musb->intrrxe);
2167 musb_writeb(musb_base, MUSB_INTRUSBE, musb->context.intrusbe); 2178 musb_writeb(musb_base, MUSB_INTRUSBE, musb->context.intrusbe);
diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
index ed455724017b..abb38c3833ef 100644
--- a/drivers/usb/musb/musb_host.c
+++ b/drivers/usb/musb/musb_host.c
@@ -1183,6 +1183,9 @@ irqreturn_t musb_h_ep0_irq(struct musb *musb)
1183 csr = MUSB_CSR0_H_STATUSPKT 1183 csr = MUSB_CSR0_H_STATUSPKT
1184 | MUSB_CSR0_TXPKTRDY; 1184 | MUSB_CSR0_TXPKTRDY;
1185 1185
1186 /* disable ping token in status phase */
1187 csr |= MUSB_CSR0_H_DIS_PING;
1188
1186 /* flag status stage */ 1189 /* flag status stage */
1187 musb->ep0_stage = MUSB_EP0_STATUS; 1190 musb->ep0_stage = MUSB_EP0_STATUS;
1188 1191
diff --git a/drivers/usb/musb/musb_virthub.c b/drivers/usb/musb/musb_virthub.c
index eb634433ef09..e2d2d8c9891b 100644
--- a/drivers/usb/musb/musb_virthub.c
+++ b/drivers/usb/musb/musb_virthub.c
@@ -135,7 +135,8 @@ void musb_port_suspend(struct musb *musb, bool do_suspend)
135 135
136 /* later, GetPortStatus will stop RESUME signaling */ 136 /* later, GetPortStatus will stop RESUME signaling */
137 musb->port1_status |= MUSB_PORT_STAT_RESUME; 137 musb->port1_status |= MUSB_PORT_STAT_RESUME;
138 schedule_delayed_work(&musb->finish_resume_work, 20); 138 schedule_delayed_work(&musb->finish_resume_work,
139 msecs_to_jiffies(20));
139 } 140 }
140} 141}
141 142
@@ -158,7 +159,6 @@ void musb_port_reset(struct musb *musb, bool do_reset)
158 */ 159 */
159 power = musb_readb(mbase, MUSB_POWER); 160 power = musb_readb(mbase, MUSB_POWER);
160 if (do_reset) { 161 if (do_reset) {
161
162 /* 162 /*
163 * If RESUME is set, we must make sure it stays minimum 20 ms. 163 * If RESUME is set, we must make sure it stays minimum 20 ms.
164 * Then we must clear RESUME and wait a bit to let musb start 164 * Then we must clear RESUME and wait a bit to let musb start
@@ -167,11 +167,22 @@ void musb_port_reset(struct musb *musb, bool do_reset)
167 * detected". 167 * detected".
168 */ 168 */
169 if (power & MUSB_POWER_RESUME) { 169 if (power & MUSB_POWER_RESUME) {
170 while (time_before(jiffies, musb->rh_timer)) 170 long remain = (unsigned long) musb->rh_timer - jiffies;
171 msleep(1); 171
172 if (musb->rh_timer > 0 && remain > 0) {
173 /* take into account the minimum delay after resume */
174 schedule_delayed_work(
175 &musb->deassert_reset_work, remain);
176 return;
177 }
178
172 musb_writeb(mbase, MUSB_POWER, 179 musb_writeb(mbase, MUSB_POWER,
173 power & ~MUSB_POWER_RESUME); 180 power & ~MUSB_POWER_RESUME);
174 msleep(1); 181
182 /* Give the core 1 ms to clear MUSB_POWER_RESUME */
183 schedule_delayed_work(&musb->deassert_reset_work,
184 msecs_to_jiffies(1));
185 return;
175 } 186 }
176 187
177 power &= 0xf0; 188 power &= 0xf0;
@@ -180,7 +191,8 @@ void musb_port_reset(struct musb *musb, bool do_reset)
180 191
181 musb->port1_status |= USB_PORT_STAT_RESET; 192 musb->port1_status |= USB_PORT_STAT_RESET;
182 musb->port1_status &= ~USB_PORT_STAT_ENABLE; 193 musb->port1_status &= ~USB_PORT_STAT_ENABLE;
183 schedule_delayed_work(&musb->deassert_reset_work, 50); 194 schedule_delayed_work(&musb->deassert_reset_work,
195 msecs_to_jiffies(50));
184 } else { 196 } else {
185 dev_dbg(musb->controller, "root port reset stopped\n"); 197 dev_dbg(musb->controller, "root port reset stopped\n");
186 musb_writeb(mbase, MUSB_POWER, 198 musb_writeb(mbase, MUSB_POWER,
diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
index 2a408cdaf7b2..8aa59a2c5eb2 100644
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -659,7 +659,6 @@ static int omap2430_runtime_suspend(struct device *dev)
659 OTG_INTERFSEL); 659 OTG_INTERFSEL);
660 660
661 omap2430_low_level_exit(musb); 661 omap2430_low_level_exit(musb);
662 phy_power_off(musb->phy);
663 } 662 }
664 663
665 return 0; 664 return 0;
@@ -674,7 +673,6 @@ static int omap2430_runtime_resume(struct device *dev)
674 omap2430_low_level_init(musb); 673 omap2430_low_level_init(musb);
675 musb_writel(musb->mregs, OTG_INTERFSEL, 674 musb_writel(musb->mregs, OTG_INTERFSEL,
676 musb->context.otg_interfsel); 675 musb->context.otg_interfsel);
677 phy_power_on(musb->phy);
678 } 676 }
679 677
680 return 0; 678 return 0;
diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index 8546c8dccd51..d204f745ed05 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -159,32 +159,6 @@ put_3p3:
159 return rc; 159 return rc;
160} 160}
161 161
162#ifdef CONFIG_PM_SLEEP
163#define USB_PHY_SUSP_DIG_VOL 500000
164static int msm_hsusb_config_vddcx(int high)
165{
166 int max_vol = USB_PHY_VDD_DIG_VOL_MAX;
167 int min_vol;
168 int ret;
169
170 if (high)
171 min_vol = USB_PHY_VDD_DIG_VOL_MIN;
172 else
173 min_vol = USB_PHY_SUSP_DIG_VOL;
174
175 ret = regulator_set_voltage(hsusb_vddcx, min_vol, max_vol);
176 if (ret) {
177 pr_err("%s: unable to set the voltage for regulator "
178 "HSUSB_VDDCX\n", __func__);
179 return ret;
180 }
181
182 pr_debug("%s: min_vol:%d max_vol:%d\n", __func__, min_vol, max_vol);
183
184 return ret;
185}
186#endif
187
188static int msm_hsusb_ldo_set_mode(int on) 162static int msm_hsusb_ldo_set_mode(int on)
189{ 163{
190 int ret = 0; 164 int ret = 0;
@@ -440,7 +414,32 @@ static int msm_otg_reset(struct usb_phy *phy)
440#define PHY_SUSPEND_TIMEOUT_USEC (500 * 1000) 414#define PHY_SUSPEND_TIMEOUT_USEC (500 * 1000)
441#define PHY_RESUME_TIMEOUT_USEC (100 * 1000) 415#define PHY_RESUME_TIMEOUT_USEC (100 * 1000)
442 416
443#ifdef CONFIG_PM_SLEEP 417#ifdef CONFIG_PM
418
419#define USB_PHY_SUSP_DIG_VOL 500000
420static int msm_hsusb_config_vddcx(int high)
421{
422 int max_vol = USB_PHY_VDD_DIG_VOL_MAX;
423 int min_vol;
424 int ret;
425
426 if (high)
427 min_vol = USB_PHY_VDD_DIG_VOL_MIN;
428 else
429 min_vol = USB_PHY_SUSP_DIG_VOL;
430
431 ret = regulator_set_voltage(hsusb_vddcx, min_vol, max_vol);
432 if (ret) {
433 pr_err("%s: unable to set the voltage for regulator "
434 "HSUSB_VDDCX\n", __func__);
435 return ret;
436 }
437
438 pr_debug("%s: min_vol:%d max_vol:%d\n", __func__, min_vol, max_vol);
439
440 return ret;
441}
442
444static int msm_otg_suspend(struct msm_otg *motg) 443static int msm_otg_suspend(struct msm_otg *motg)
445{ 444{
446 struct usb_phy *phy = &motg->phy; 445 struct usb_phy *phy = &motg->phy;
@@ -1733,22 +1732,18 @@ static int msm_otg_pm_resume(struct device *dev)
1733} 1732}
1734#endif 1733#endif
1735 1734
1736#ifdef CONFIG_PM
1737static const struct dev_pm_ops msm_otg_dev_pm_ops = { 1735static const struct dev_pm_ops msm_otg_dev_pm_ops = {
1738 SET_SYSTEM_SLEEP_PM_OPS(msm_otg_pm_suspend, msm_otg_pm_resume) 1736 SET_SYSTEM_SLEEP_PM_OPS(msm_otg_pm_suspend, msm_otg_pm_resume)
1739 SET_RUNTIME_PM_OPS(msm_otg_runtime_suspend, msm_otg_runtime_resume, 1737 SET_RUNTIME_PM_OPS(msm_otg_runtime_suspend, msm_otg_runtime_resume,
1740 msm_otg_runtime_idle) 1738 msm_otg_runtime_idle)
1741}; 1739};
1742#endif
1743 1740
1744static struct platform_driver msm_otg_driver = { 1741static struct platform_driver msm_otg_driver = {
1745 .remove = msm_otg_remove, 1742 .remove = msm_otg_remove,
1746 .driver = { 1743 .driver = {
1747 .name = DRIVER_NAME, 1744 .name = DRIVER_NAME,
1748 .owner = THIS_MODULE, 1745 .owner = THIS_MODULE,
1749#ifdef CONFIG_PM
1750 .pm = &msm_otg_dev_pm_ops, 1746 .pm = &msm_otg_dev_pm_ops,
1751#endif
1752 }, 1747 },
1753}; 1748};
1754 1749
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index ee1f00f03c43..44ab12986805 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -907,6 +907,8 @@ static const struct usb_device_id id_table_combined[] = {
907 /* Crucible Devices */ 907 /* Crucible Devices */
908 { USB_DEVICE(FTDI_VID, FTDI_CT_COMET_PID) }, 908 { USB_DEVICE(FTDI_VID, FTDI_CT_COMET_PID) },
909 { USB_DEVICE(FTDI_VID, FTDI_Z3X_PID) }, 909 { USB_DEVICE(FTDI_VID, FTDI_Z3X_PID) },
910 /* Cressi Devices */
911 { USB_DEVICE(FTDI_VID, FTDI_CRESSI_PID) },
910 { } /* Terminating entry */ 912 { } /* Terminating entry */
911}; 913};
912 914
diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h
index 1e2d369df86e..e599fbfcde5f 100644
--- a/drivers/usb/serial/ftdi_sio_ids.h
+++ b/drivers/usb/serial/ftdi_sio_ids.h
@@ -1320,3 +1320,9 @@
1320 * Manufacturer: Smart GSM Team 1320 * Manufacturer: Smart GSM Team
1321 */ 1321 */
1322#define FTDI_Z3X_PID 0x0011 1322#define FTDI_Z3X_PID 0x0011
1323
1324/*
1325 * Product: Cressi PC Interface
1326 * Manufacturer: Cressi
1327 */
1328#define FTDI_CRESSI_PID 0x87d0
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index 216d20affba8..68fc9fe65936 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -1526,7 +1526,8 @@ static const struct usb_device_id option_ids[] = {
1526 /* Cinterion */ 1526 /* Cinterion */
1527 { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_EU3_E) }, 1527 { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_EU3_E) },
1528 { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_EU3_P) }, 1528 { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_EU3_P) },
1529 { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_PH8) }, 1529 { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_PH8),
1530 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
1530 { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_AHXX) }, 1531 { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_AHXX) },
1531 { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_PLXX), 1532 { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_PLXX),
1532 .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, 1533 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
index 4fb7a8f83c8a..54af4e933695 100644
--- a/drivers/vfio/vfio_iommu_type1.c
+++ b/drivers/vfio/vfio_iommu_type1.c
@@ -186,12 +186,12 @@ static bool is_invalid_reserved_pfn(unsigned long pfn)
186 if (pfn_valid(pfn)) { 186 if (pfn_valid(pfn)) {
187 bool reserved; 187 bool reserved;
188 struct page *tail = pfn_to_page(pfn); 188 struct page *tail = pfn_to_page(pfn);
189 struct page *head = compound_trans_head(tail); 189 struct page *head = compound_head(tail);
190 reserved = !!(PageReserved(head)); 190 reserved = !!(PageReserved(head));
191 if (head != tail) { 191 if (head != tail) {
192 /* 192 /*
193 * "head" is not a dangling pointer 193 * "head" is not a dangling pointer
194 * (compound_trans_head takes care of that) 194 * (compound_head takes care of that)
195 * but the hugepage may have been split 195 * but the hugepage may have been split
196 * from under us (and we may not hold a 196 * from under us (and we may not hold a
197 * reference count on the head page so it can 197 * reference count on the head page so it can
diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c
index 0a025b8e2a12..e48d4a672580 100644
--- a/drivers/vhost/scsi.c
+++ b/drivers/vhost/scsi.c
@@ -1001,6 +1001,12 @@ vhost_scsi_handle_vq(struct vhost_scsi *vs, struct vhost_virtqueue *vq)
1001 break; 1001 break;
1002 } 1002 }
1003 1003
1004 /* virtio-scsi spec requires byte 0 of the lun to be 1 */
1005 if (unlikely(v_req.lun[0] != 1)) {
1006 vhost_scsi_send_bad_target(vs, vq, head, out);
1007 continue;
1008 }
1009
1004 /* Extract the tpgt */ 1010 /* Extract the tpgt */
1005 target = v_req.lun[1]; 1011 target = v_req.lun[1];
1006 tpg = ACCESS_ONCE(vs_tpg[target]); 1012 tpg = ACCESS_ONCE(vs_tpg[target]);
diff --git a/drivers/watchdog/w83697hf_wdt.c b/drivers/watchdog/w83697hf_wdt.c
index aaf2995d37f4..68b45fc9ba6a 100644
--- a/drivers/watchdog/w83697hf_wdt.c
+++ b/drivers/watchdog/w83697hf_wdt.c
@@ -402,7 +402,7 @@ static int __init wdt_init(void)
402 402
403 if (!found) { 403 if (!found) {
404 pr_err("No W83697HF/HG could be found\n"); 404 pr_err("No W83697HF/HG could be found\n");
405 ret = -EIO; 405 ret = -ENODEV;
406 goto out; 406 goto out;
407 } 407 }
408 408
diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index e0259a163f98..d754e3cf99a8 100644
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -40,18 +40,13 @@
40struct wb_writeback_work { 40struct wb_writeback_work {
41 long nr_pages; 41 long nr_pages;
42 struct super_block *sb; 42 struct super_block *sb;
43 /* 43 unsigned long *older_than_this;
44 * Write only inodes dirtied before this time. Don't forget to set
45 * older_than_this_is_set when you set this.
46 */
47 unsigned long older_than_this;
48 enum writeback_sync_modes sync_mode; 44 enum writeback_sync_modes sync_mode;
49 unsigned int tagged_writepages:1; 45 unsigned int tagged_writepages:1;
50 unsigned int for_kupdate:1; 46 unsigned int for_kupdate:1;
51 unsigned int range_cyclic:1; 47 unsigned int range_cyclic:1;
52 unsigned int for_background:1; 48 unsigned int for_background:1;
53 unsigned int for_sync:1; /* sync(2) WB_SYNC_ALL writeback */ 49 unsigned int for_sync:1; /* sync(2) WB_SYNC_ALL writeback */
54 unsigned int older_than_this_is_set:1;
55 enum wb_reason reason; /* why was writeback initiated? */ 50 enum wb_reason reason; /* why was writeback initiated? */
56 51
57 struct list_head list; /* pending work list */ 52 struct list_head list; /* pending work list */
@@ -252,10 +247,10 @@ static int move_expired_inodes(struct list_head *delaying_queue,
252 int do_sb_sort = 0; 247 int do_sb_sort = 0;
253 int moved = 0; 248 int moved = 0;
254 249
255 WARN_ON_ONCE(!work->older_than_this_is_set);
256 while (!list_empty(delaying_queue)) { 250 while (!list_empty(delaying_queue)) {
257 inode = wb_inode(delaying_queue->prev); 251 inode = wb_inode(delaying_queue->prev);
258 if (inode_dirtied_after(inode, work->older_than_this)) 252 if (work->older_than_this &&
253 inode_dirtied_after(inode, *work->older_than_this))
259 break; 254 break;
260 list_move(&inode->i_wb_list, &tmp); 255 list_move(&inode->i_wb_list, &tmp);
261 moved++; 256 moved++;
@@ -742,8 +737,6 @@ static long writeback_inodes_wb(struct bdi_writeback *wb, long nr_pages,
742 .sync_mode = WB_SYNC_NONE, 737 .sync_mode = WB_SYNC_NONE,
743 .range_cyclic = 1, 738 .range_cyclic = 1,
744 .reason = reason, 739 .reason = reason,
745 .older_than_this = jiffies,
746 .older_than_this_is_set = 1,
747 }; 740 };
748 741
749 spin_lock(&wb->list_lock); 742 spin_lock(&wb->list_lock);
@@ -802,13 +795,12 @@ static long wb_writeback(struct bdi_writeback *wb,
802{ 795{
803 unsigned long wb_start = jiffies; 796 unsigned long wb_start = jiffies;
804 long nr_pages = work->nr_pages; 797 long nr_pages = work->nr_pages;
798 unsigned long oldest_jif;
805 struct inode *inode; 799 struct inode *inode;
806 long progress; 800 long progress;
807 801
808 if (!work->older_than_this_is_set) { 802 oldest_jif = jiffies;
809 work->older_than_this = jiffies; 803 work->older_than_this = &oldest_jif;
810 work->older_than_this_is_set = 1;
811 }
812 804
813 spin_lock(&wb->list_lock); 805 spin_lock(&wb->list_lock);
814 for (;;) { 806 for (;;) {
@@ -842,10 +834,10 @@ static long wb_writeback(struct bdi_writeback *wb,
842 * safe. 834 * safe.
843 */ 835 */
844 if (work->for_kupdate) { 836 if (work->for_kupdate) {
845 work->older_than_this = jiffies - 837 oldest_jif = jiffies -
846 msecs_to_jiffies(dirty_expire_interval * 10); 838 msecs_to_jiffies(dirty_expire_interval * 10);
847 } else if (work->for_background) 839 } else if (work->for_background)
848 work->older_than_this = jiffies; 840 oldest_jif = jiffies;
849 841
850 trace_writeback_start(wb->bdi, work); 842 trace_writeback_start(wb->bdi, work);
851 if (list_empty(&wb->b_io)) 843 if (list_empty(&wb->b_io))
@@ -1357,21 +1349,18 @@ EXPORT_SYMBOL(try_to_writeback_inodes_sb);
1357 1349
1358/** 1350/**
1359 * sync_inodes_sb - sync sb inode pages 1351 * sync_inodes_sb - sync sb inode pages
1360 * @sb: the superblock 1352 * @sb: the superblock
1361 * @older_than_this: timestamp
1362 * 1353 *
1363 * This function writes and waits on any dirty inode belonging to this 1354 * This function writes and waits on any dirty inode belonging to this
1364 * superblock that has been dirtied before given timestamp. 1355 * super_block.
1365 */ 1356 */
1366void sync_inodes_sb(struct super_block *sb, unsigned long older_than_this) 1357void sync_inodes_sb(struct super_block *sb)
1367{ 1358{
1368 DECLARE_COMPLETION_ONSTACK(done); 1359 DECLARE_COMPLETION_ONSTACK(done);
1369 struct wb_writeback_work work = { 1360 struct wb_writeback_work work = {
1370 .sb = sb, 1361 .sb = sb,
1371 .sync_mode = WB_SYNC_ALL, 1362 .sync_mode = WB_SYNC_ALL,
1372 .nr_pages = LONG_MAX, 1363 .nr_pages = LONG_MAX,
1373 .older_than_this = older_than_this,
1374 .older_than_this_is_set = 1,
1375 .range_cyclic = 0, 1364 .range_cyclic = 0,
1376 .done = &done, 1365 .done = &done,
1377 .reason = WB_REASON_SYNC, 1366 .reason = WB_REASON_SYNC,
diff --git a/fs/hfsplus/options.c b/fs/hfsplus/options.c
index 968eab5bc1f5..68537e8b7a09 100644
--- a/fs/hfsplus/options.c
+++ b/fs/hfsplus/options.c
@@ -75,7 +75,7 @@ int hfsplus_parse_options_remount(char *input, int *force)
75 int token; 75 int token;
76 76
77 if (!input) 77 if (!input)
78 return 0; 78 return 1;
79 79
80 while ((p = strsep(&input, ",")) != NULL) { 80 while ((p = strsep(&input, ",")) != NULL) {
81 if (!*p) 81 if (!*p)
diff --git a/fs/kernfs/mount.c b/fs/kernfs/mount.c
index 0d6ce895a9ee..0f4152defe7b 100644
--- a/fs/kernfs/mount.c
+++ b/fs/kernfs/mount.c
@@ -94,6 +94,7 @@ const void *kernfs_super_ns(struct super_block *sb)
94 * @fs_type: file_system_type of the fs being mounted 94 * @fs_type: file_system_type of the fs being mounted
95 * @flags: mount flags specified for the mount 95 * @flags: mount flags specified for the mount
96 * @root: kernfs_root of the hierarchy being mounted 96 * @root: kernfs_root of the hierarchy being mounted
97 * @new_sb_created: tell the caller if we allocated a new superblock
97 * @ns: optional namespace tag of the mount 98 * @ns: optional namespace tag of the mount
98 * 99 *
99 * This is to be called from each kernfs user's file_system_type->mount() 100 * This is to be called from each kernfs user's file_system_type->mount()
@@ -104,7 +105,8 @@ const void *kernfs_super_ns(struct super_block *sb)
104 * The return value can be passed to the vfs layer verbatim. 105 * The return value can be passed to the vfs layer verbatim.
105 */ 106 */
106struct dentry *kernfs_mount_ns(struct file_system_type *fs_type, int flags, 107struct dentry *kernfs_mount_ns(struct file_system_type *fs_type, int flags,
107 struct kernfs_root *root, const void *ns) 108 struct kernfs_root *root, bool *new_sb_created,
109 const void *ns)
108{ 110{
109 struct super_block *sb; 111 struct super_block *sb;
110 struct kernfs_super_info *info; 112 struct kernfs_super_info *info;
@@ -122,6 +124,10 @@ struct dentry *kernfs_mount_ns(struct file_system_type *fs_type, int flags,
122 kfree(info); 124 kfree(info);
123 if (IS_ERR(sb)) 125 if (IS_ERR(sb))
124 return ERR_CAST(sb); 126 return ERR_CAST(sb);
127
128 if (new_sb_created)
129 *new_sb_created = !sb->s_root;
130
125 if (!sb->s_root) { 131 if (!sb->s_root) {
126 error = kernfs_fill_super(sb); 132 error = kernfs_fill_super(sb);
127 if (error) { 133 if (error) {
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index 28a0a3cbd3b7..360114ae8b82 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -164,17 +164,16 @@ static void nfs_zap_caches_locked(struct inode *inode)
164 if (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode)) { 164 if (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode)) {
165 nfs_fscache_invalidate(inode); 165 nfs_fscache_invalidate(inode);
166 nfsi->cache_validity |= NFS_INO_INVALID_ATTR 166 nfsi->cache_validity |= NFS_INO_INVALID_ATTR
167 | NFS_INO_INVALID_LABEL
168 | NFS_INO_INVALID_DATA 167 | NFS_INO_INVALID_DATA
169 | NFS_INO_INVALID_ACCESS 168 | NFS_INO_INVALID_ACCESS
170 | NFS_INO_INVALID_ACL 169 | NFS_INO_INVALID_ACL
171 | NFS_INO_REVAL_PAGECACHE; 170 | NFS_INO_REVAL_PAGECACHE;
172 } else 171 } else
173 nfsi->cache_validity |= NFS_INO_INVALID_ATTR 172 nfsi->cache_validity |= NFS_INO_INVALID_ATTR
174 | NFS_INO_INVALID_LABEL
175 | NFS_INO_INVALID_ACCESS 173 | NFS_INO_INVALID_ACCESS
176 | NFS_INO_INVALID_ACL 174 | NFS_INO_INVALID_ACL
177 | NFS_INO_REVAL_PAGECACHE; 175 | NFS_INO_REVAL_PAGECACHE;
176 nfs_zap_label_cache_locked(nfsi);
178} 177}
179 178
180void nfs_zap_caches(struct inode *inode) 179void nfs_zap_caches(struct inode *inode)
@@ -266,6 +265,13 @@ nfs_init_locked(struct inode *inode, void *opaque)
266} 265}
267 266
268#ifdef CONFIG_NFS_V4_SECURITY_LABEL 267#ifdef CONFIG_NFS_V4_SECURITY_LABEL
268static void nfs_clear_label_invalid(struct inode *inode)
269{
270 spin_lock(&inode->i_lock);
271 NFS_I(inode)->cache_validity &= ~NFS_INO_INVALID_LABEL;
272 spin_unlock(&inode->i_lock);
273}
274
269void nfs_setsecurity(struct inode *inode, struct nfs_fattr *fattr, 275void nfs_setsecurity(struct inode *inode, struct nfs_fattr *fattr,
270 struct nfs4_label *label) 276 struct nfs4_label *label)
271{ 277{
@@ -283,6 +289,7 @@ void nfs_setsecurity(struct inode *inode, struct nfs_fattr *fattr,
283 __func__, 289 __func__,
284 (char *)label->label, 290 (char *)label->label,
285 label->len, error); 291 label->len, error);
292 nfs_clear_label_invalid(inode);
286 } 293 }
287} 294}
288 295
@@ -1648,7 +1655,7 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
1648 inode->i_blocks = fattr->du.nfs2.blocks; 1655 inode->i_blocks = fattr->du.nfs2.blocks;
1649 1656
1650 /* Update attrtimeo value if we're out of the unstable period */ 1657 /* Update attrtimeo value if we're out of the unstable period */
1651 if (invalid & (NFS_INO_INVALID_ATTR|NFS_INO_INVALID_LABEL)) { 1658 if (invalid & NFS_INO_INVALID_ATTR) {
1652 nfs_inc_stats(inode, NFSIOS_ATTRINVALIDATE); 1659 nfs_inc_stats(inode, NFSIOS_ATTRINVALIDATE);
1653 nfsi->attrtimeo = NFS_MINATTRTIMEO(inode); 1660 nfsi->attrtimeo = NFS_MINATTRTIMEO(inode);
1654 nfsi->attrtimeo_timestamp = now; 1661 nfsi->attrtimeo_timestamp = now;
@@ -1661,7 +1668,6 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
1661 } 1668 }
1662 } 1669 }
1663 invalid &= ~NFS_INO_INVALID_ATTR; 1670 invalid &= ~NFS_INO_INVALID_ATTR;
1664 invalid &= ~NFS_INO_INVALID_LABEL;
1665 /* Don't invalidate the data if we were to blame */ 1671 /* Don't invalidate the data if we were to blame */
1666 if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) 1672 if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode)
1667 || S_ISLNK(inode->i_mode))) 1673 || S_ISLNK(inode->i_mode)))
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index 8b5cc04a8611..b46cf5a67329 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -176,7 +176,8 @@ extern struct nfs_server *nfs4_create_server(
176extern struct nfs_server *nfs4_create_referral_server(struct nfs_clone_mount *, 176extern struct nfs_server *nfs4_create_referral_server(struct nfs_clone_mount *,
177 struct nfs_fh *); 177 struct nfs_fh *);
178extern int nfs4_update_server(struct nfs_server *server, const char *hostname, 178extern int nfs4_update_server(struct nfs_server *server, const char *hostname,
179 struct sockaddr *sap, size_t salen); 179 struct sockaddr *sap, size_t salen,
180 struct net *net);
180extern void nfs_free_server(struct nfs_server *server); 181extern void nfs_free_server(struct nfs_server *server);
181extern struct nfs_server *nfs_clone_server(struct nfs_server *, 182extern struct nfs_server *nfs_clone_server(struct nfs_server *,
182 struct nfs_fh *, 183 struct nfs_fh *,
@@ -279,9 +280,18 @@ static inline void nfs4_label_free(struct nfs4_label *label)
279 } 280 }
280 return; 281 return;
281} 282}
283
284static inline void nfs_zap_label_cache_locked(struct nfs_inode *nfsi)
285{
286 if (nfs_server_capable(&nfsi->vfs_inode, NFS_CAP_SECURITY_LABEL))
287 nfsi->cache_validity |= NFS_INO_INVALID_LABEL;
288}
282#else 289#else
283static inline struct nfs4_label *nfs4_label_alloc(struct nfs_server *server, gfp_t flags) { return NULL; } 290static inline struct nfs4_label *nfs4_label_alloc(struct nfs_server *server, gfp_t flags) { return NULL; }
284static inline void nfs4_label_free(void *label) {} 291static inline void nfs4_label_free(void *label) {}
292static inline void nfs_zap_label_cache_locked(struct nfs_inode *nfsi)
293{
294}
285#endif /* CONFIG_NFS_V4_SECURITY_LABEL */ 295#endif /* CONFIG_NFS_V4_SECURITY_LABEL */
286 296
287/* proc.c */ 297/* proc.c */
diff --git a/fs/nfs/nfs3proc.c b/fs/nfs/nfs3proc.c
index aa9bc973f36a..a462ef0fb5d6 100644
--- a/fs/nfs/nfs3proc.c
+++ b/fs/nfs/nfs3proc.c
@@ -18,6 +18,7 @@
18#include <linux/lockd/bind.h> 18#include <linux/lockd/bind.h>
19#include <linux/nfs_mount.h> 19#include <linux/nfs_mount.h>
20#include <linux/freezer.h> 20#include <linux/freezer.h>
21#include <linux/xattr.h>
21 22
22#include "iostat.h" 23#include "iostat.h"
23#include "internal.h" 24#include "internal.h"
diff --git a/fs/nfs/nfs4client.c b/fs/nfs/nfs4client.c
index 860ad26a5590..0e46d3d1b6cc 100644
--- a/fs/nfs/nfs4client.c
+++ b/fs/nfs/nfs4client.c
@@ -1135,6 +1135,7 @@ static int nfs_probe_destination(struct nfs_server *server)
1135 * @hostname: new end-point's hostname 1135 * @hostname: new end-point's hostname
1136 * @sap: new end-point's socket address 1136 * @sap: new end-point's socket address
1137 * @salen: size of "sap" 1137 * @salen: size of "sap"
1138 * @net: net namespace
1138 * 1139 *
1139 * The nfs_server must be quiescent before this function is invoked. 1140 * The nfs_server must be quiescent before this function is invoked.
1140 * Either its session is drained (NFSv4.1+), or its transport is 1141 * Either its session is drained (NFSv4.1+), or its transport is
@@ -1143,13 +1144,13 @@ static int nfs_probe_destination(struct nfs_server *server)
1143 * Returns zero on success, or a negative errno value. 1144 * Returns zero on success, or a negative errno value.
1144 */ 1145 */
1145int nfs4_update_server(struct nfs_server *server, const char *hostname, 1146int nfs4_update_server(struct nfs_server *server, const char *hostname,
1146 struct sockaddr *sap, size_t salen) 1147 struct sockaddr *sap, size_t salen, struct net *net)
1147{ 1148{
1148 struct nfs_client *clp = server->nfs_client; 1149 struct nfs_client *clp = server->nfs_client;
1149 struct rpc_clnt *clnt = server->client; 1150 struct rpc_clnt *clnt = server->client;
1150 struct xprt_create xargs = { 1151 struct xprt_create xargs = {
1151 .ident = clp->cl_proto, 1152 .ident = clp->cl_proto,
1152 .net = &init_net, 1153 .net = net,
1153 .dstaddr = sap, 1154 .dstaddr = sap,
1154 .addrlen = salen, 1155 .addrlen = salen,
1155 .servername = hostname, 1156 .servername = hostname,
@@ -1189,7 +1190,7 @@ int nfs4_update_server(struct nfs_server *server, const char *hostname,
1189 error = nfs4_set_client(server, hostname, sap, salen, buf, 1190 error = nfs4_set_client(server, hostname, sap, salen, buf,
1190 clp->cl_rpcclient->cl_auth->au_flavor, 1191 clp->cl_rpcclient->cl_auth->au_flavor,
1191 clp->cl_proto, clnt->cl_timeout, 1192 clp->cl_proto, clnt->cl_timeout,
1192 clp->cl_minorversion, clp->cl_net); 1193 clp->cl_minorversion, net);
1193 nfs_put_client(clp); 1194 nfs_put_client(clp);
1194 if (error != 0) { 1195 if (error != 0) {
1195 nfs_server_insert_lists(server); 1196 nfs_server_insert_lists(server);
diff --git a/fs/nfs/nfs4namespace.c b/fs/nfs/nfs4namespace.c
index 4e7f05d3e9db..3d5dbf80d46a 100644
--- a/fs/nfs/nfs4namespace.c
+++ b/fs/nfs/nfs4namespace.c
@@ -121,9 +121,8 @@ static int nfs4_validate_fspath(struct dentry *dentry,
121} 121}
122 122
123static size_t nfs_parse_server_name(char *string, size_t len, 123static size_t nfs_parse_server_name(char *string, size_t len,
124 struct sockaddr *sa, size_t salen, struct nfs_server *server) 124 struct sockaddr *sa, size_t salen, struct net *net)
125{ 125{
126 struct net *net = rpc_net_ns(server->client);
127 ssize_t ret; 126 ssize_t ret;
128 127
129 ret = rpc_pton(net, string, len, sa, salen); 128 ret = rpc_pton(net, string, len, sa, salen);
@@ -223,6 +222,7 @@ static struct vfsmount *try_location(struct nfs_clone_mount *mountdata,
223 const struct nfs4_fs_location *location) 222 const struct nfs4_fs_location *location)
224{ 223{
225 const size_t addr_bufsize = sizeof(struct sockaddr_storage); 224 const size_t addr_bufsize = sizeof(struct sockaddr_storage);
225 struct net *net = rpc_net_ns(NFS_SB(mountdata->sb)->client);
226 struct vfsmount *mnt = ERR_PTR(-ENOENT); 226 struct vfsmount *mnt = ERR_PTR(-ENOENT);
227 char *mnt_path; 227 char *mnt_path;
228 unsigned int maxbuflen; 228 unsigned int maxbuflen;
@@ -248,8 +248,7 @@ static struct vfsmount *try_location(struct nfs_clone_mount *mountdata,
248 continue; 248 continue;
249 249
250 mountdata->addrlen = nfs_parse_server_name(buf->data, buf->len, 250 mountdata->addrlen = nfs_parse_server_name(buf->data, buf->len,
251 mountdata->addr, addr_bufsize, 251 mountdata->addr, addr_bufsize, net);
252 NFS_SB(mountdata->sb));
253 if (mountdata->addrlen == 0) 252 if (mountdata->addrlen == 0)
254 continue; 253 continue;
255 254
@@ -419,6 +418,7 @@ static int nfs4_try_replacing_one_location(struct nfs_server *server,
419 const struct nfs4_fs_location *location) 418 const struct nfs4_fs_location *location)
420{ 419{
421 const size_t addr_bufsize = sizeof(struct sockaddr_storage); 420 const size_t addr_bufsize = sizeof(struct sockaddr_storage);
421 struct net *net = rpc_net_ns(server->client);
422 struct sockaddr *sap; 422 struct sockaddr *sap;
423 unsigned int s; 423 unsigned int s;
424 size_t salen; 424 size_t salen;
@@ -440,7 +440,7 @@ static int nfs4_try_replacing_one_location(struct nfs_server *server,
440 continue; 440 continue;
441 441
442 salen = nfs_parse_server_name(buf->data, buf->len, 442 salen = nfs_parse_server_name(buf->data, buf->len,
443 sap, addr_bufsize, server); 443 sap, addr_bufsize, net);
444 if (salen == 0) 444 if (salen == 0)
445 continue; 445 continue;
446 rpc_set_port(sap, NFS_PORT); 446 rpc_set_port(sap, NFS_PORT);
@@ -450,7 +450,7 @@ static int nfs4_try_replacing_one_location(struct nfs_server *server,
450 if (hostname == NULL) 450 if (hostname == NULL)
451 break; 451 break;
452 452
453 error = nfs4_update_server(server, hostname, sap, salen); 453 error = nfs4_update_server(server, hostname, sap, salen, net);
454 kfree(hostname); 454 kfree(hostname);
455 if (error == 0) 455 if (error == 0)
456 break; 456 break;
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
index e5be72518bd7..e1a47217c05e 100644
--- a/fs/nfs/nfs4state.c
+++ b/fs/nfs/nfs4state.c
@@ -1015,8 +1015,11 @@ int nfs4_select_rw_stateid(nfs4_stateid *dst, struct nfs4_state *state,
1015 if (ret == -EIO) 1015 if (ret == -EIO)
1016 /* A lost lock - don't even consider delegations */ 1016 /* A lost lock - don't even consider delegations */
1017 goto out; 1017 goto out;
1018 if (nfs4_copy_delegation_stateid(dst, state->inode, fmode)) 1018 /* returns true if delegation stateid found and copied */
1019 if (nfs4_copy_delegation_stateid(dst, state->inode, fmode)) {
1020 ret = 0;
1019 goto out; 1021 goto out;
1022 }
1020 if (ret != -ENOENT) 1023 if (ret != -ENOENT)
1021 /* nfs4_copy_delegation_stateid() didn't over-write 1024 /* nfs4_copy_delegation_stateid() didn't over-write
1022 * dst, so it still has the lock stateid which we now 1025 * dst, so it still has the lock stateid which we now
diff --git a/fs/notify/dnotify/dnotify.c b/fs/notify/dnotify/dnotify.c
index 0b9ff4395e6a..abc8cbcfe90e 100644
--- a/fs/notify/dnotify/dnotify.c
+++ b/fs/notify/dnotify/dnotify.c
@@ -86,7 +86,7 @@ static int dnotify_handle_event(struct fsnotify_group *group,
86 struct fsnotify_mark *inode_mark, 86 struct fsnotify_mark *inode_mark,
87 struct fsnotify_mark *vfsmount_mark, 87 struct fsnotify_mark *vfsmount_mark,
88 u32 mask, void *data, int data_type, 88 u32 mask, void *data, int data_type,
89 const unsigned char *file_name) 89 const unsigned char *file_name, u32 cookie)
90{ 90{
91 struct dnotify_mark *dn_mark; 91 struct dnotify_mark *dn_mark;
92 struct dnotify_struct *dn; 92 struct dnotify_struct *dn;
diff --git a/fs/notify/fanotify/fanotify.c b/fs/notify/fanotify/fanotify.c
index 0e792f5e3147..dc638f786d5c 100644
--- a/fs/notify/fanotify/fanotify.c
+++ b/fs/notify/fanotify/fanotify.c
@@ -147,7 +147,7 @@ static int fanotify_handle_event(struct fsnotify_group *group,
147 struct fsnotify_mark *inode_mark, 147 struct fsnotify_mark *inode_mark,
148 struct fsnotify_mark *fanotify_mark, 148 struct fsnotify_mark *fanotify_mark,
149 u32 mask, void *data, int data_type, 149 u32 mask, void *data, int data_type,
150 const unsigned char *file_name) 150 const unsigned char *file_name, u32 cookie)
151{ 151{
152 int ret = 0; 152 int ret = 0;
153 struct fanotify_event_info *event; 153 struct fanotify_event_info *event;
@@ -192,10 +192,12 @@ static int fanotify_handle_event(struct fsnotify_group *group,
192 192
193 ret = fsnotify_add_notify_event(group, fsn_event, fanotify_merge); 193 ret = fsnotify_add_notify_event(group, fsn_event, fanotify_merge);
194 if (ret) { 194 if (ret) {
195 BUG_ON(mask & FAN_ALL_PERM_EVENTS); 195 /* Permission events shouldn't be merged */
196 BUG_ON(ret == 1 && mask & FAN_ALL_PERM_EVENTS);
196 /* Our event wasn't used in the end. Free it. */ 197 /* Our event wasn't used in the end. Free it. */
197 fsnotify_destroy_event(group, fsn_event); 198 fsnotify_destroy_event(group, fsn_event);
198 ret = 0; 199
200 return 0;
199 } 201 }
200 202
201#ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS 203#ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS
diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
index b6175fa11bf8..287a22c04149 100644
--- a/fs/notify/fanotify/fanotify_user.c
+++ b/fs/notify/fanotify/fanotify_user.c
@@ -698,6 +698,7 @@ SYSCALL_DEFINE2(fanotify_init, unsigned int, flags, unsigned int, event_f_flags)
698 struct fsnotify_group *group; 698 struct fsnotify_group *group;
699 int f_flags, fd; 699 int f_flags, fd;
700 struct user_struct *user; 700 struct user_struct *user;
701 struct fanotify_event_info *oevent;
701 702
702 pr_debug("%s: flags=%d event_f_flags=%d\n", 703 pr_debug("%s: flags=%d event_f_flags=%d\n",
703 __func__, flags, event_f_flags); 704 __func__, flags, event_f_flags);
@@ -730,8 +731,20 @@ SYSCALL_DEFINE2(fanotify_init, unsigned int, flags, unsigned int, event_f_flags)
730 group->fanotify_data.user = user; 731 group->fanotify_data.user = user;
731 atomic_inc(&user->fanotify_listeners); 732 atomic_inc(&user->fanotify_listeners);
732 733
734 oevent = kmem_cache_alloc(fanotify_event_cachep, GFP_KERNEL);
735 if (unlikely(!oevent)) {
736 fd = -ENOMEM;
737 goto out_destroy_group;
738 }
739 group->overflow_event = &oevent->fse;
740 fsnotify_init_event(group->overflow_event, NULL, FS_Q_OVERFLOW);
741 oevent->tgid = get_pid(task_tgid(current));
742 oevent->path.mnt = NULL;
743 oevent->path.dentry = NULL;
744
733 group->fanotify_data.f_flags = event_f_flags; 745 group->fanotify_data.f_flags = event_f_flags;
734#ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS 746#ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS
747 oevent->response = 0;
735 mutex_init(&group->fanotify_data.access_mutex); 748 mutex_init(&group->fanotify_data.access_mutex);
736 init_waitqueue_head(&group->fanotify_data.access_waitq); 749 init_waitqueue_head(&group->fanotify_data.access_waitq);
737 INIT_LIST_HEAD(&group->fanotify_data.access_list); 750 INIT_LIST_HEAD(&group->fanotify_data.access_list);
diff --git a/fs/notify/fsnotify.c b/fs/notify/fsnotify.c
index 1d4e1ea2f37c..9d3e9c50066a 100644
--- a/fs/notify/fsnotify.c
+++ b/fs/notify/fsnotify.c
@@ -179,7 +179,7 @@ static int send_to_group(struct inode *to_tell,
179 179
180 return group->ops->handle_event(group, to_tell, inode_mark, 180 return group->ops->handle_event(group, to_tell, inode_mark,
181 vfsmount_mark, mask, data, data_is, 181 vfsmount_mark, mask, data, data_is,
182 file_name); 182 file_name, cookie);
183} 183}
184 184
185/* 185/*
diff --git a/fs/notify/group.c b/fs/notify/group.c
index ee674fe2cec7..ad1995980456 100644
--- a/fs/notify/group.c
+++ b/fs/notify/group.c
@@ -55,6 +55,13 @@ void fsnotify_destroy_group(struct fsnotify_group *group)
55 /* clear the notification queue of all events */ 55 /* clear the notification queue of all events */
56 fsnotify_flush_notify(group); 56 fsnotify_flush_notify(group);
57 57
58 /*
59 * Destroy overflow event (we cannot use fsnotify_destroy_event() as
60 * that deliberately ignores overflow events.
61 */
62 if (group->overflow_event)
63 group->ops->free_event(group->overflow_event);
64
58 fsnotify_put_group(group); 65 fsnotify_put_group(group);
59} 66}
60 67
@@ -99,7 +106,6 @@ struct fsnotify_group *fsnotify_alloc_group(const struct fsnotify_ops *ops)
99 INIT_LIST_HEAD(&group->marks_list); 106 INIT_LIST_HEAD(&group->marks_list);
100 107
101 group->ops = ops; 108 group->ops = ops;
102 fsnotify_init_event(&group->overflow_event, NULL, FS_Q_OVERFLOW);
103 109
104 return group; 110 return group;
105} 111}
diff --git a/fs/notify/inotify/inotify.h b/fs/notify/inotify/inotify.h
index 485eef3f4407..ed855ef6f077 100644
--- a/fs/notify/inotify/inotify.h
+++ b/fs/notify/inotify/inotify.h
@@ -27,6 +27,6 @@ extern int inotify_handle_event(struct fsnotify_group *group,
27 struct fsnotify_mark *inode_mark, 27 struct fsnotify_mark *inode_mark,
28 struct fsnotify_mark *vfsmount_mark, 28 struct fsnotify_mark *vfsmount_mark,
29 u32 mask, void *data, int data_type, 29 u32 mask, void *data, int data_type,
30 const unsigned char *file_name); 30 const unsigned char *file_name, u32 cookie);
31 31
32extern const struct fsnotify_ops inotify_fsnotify_ops; 32extern const struct fsnotify_ops inotify_fsnotify_ops;
diff --git a/fs/notify/inotify/inotify_fsnotify.c b/fs/notify/inotify/inotify_fsnotify.c
index d5ee56348bb8..43ab1e1a07a2 100644
--- a/fs/notify/inotify/inotify_fsnotify.c
+++ b/fs/notify/inotify/inotify_fsnotify.c
@@ -67,7 +67,7 @@ int inotify_handle_event(struct fsnotify_group *group,
67 struct fsnotify_mark *inode_mark, 67 struct fsnotify_mark *inode_mark,
68 struct fsnotify_mark *vfsmount_mark, 68 struct fsnotify_mark *vfsmount_mark,
69 u32 mask, void *data, int data_type, 69 u32 mask, void *data, int data_type,
70 const unsigned char *file_name) 70 const unsigned char *file_name, u32 cookie)
71{ 71{
72 struct inotify_inode_mark *i_mark; 72 struct inotify_inode_mark *i_mark;
73 struct inotify_event_info *event; 73 struct inotify_event_info *event;
@@ -103,6 +103,7 @@ int inotify_handle_event(struct fsnotify_group *group,
103 fsn_event = &event->fse; 103 fsn_event = &event->fse;
104 fsnotify_init_event(fsn_event, inode, mask); 104 fsnotify_init_event(fsn_event, inode, mask);
105 event->wd = i_mark->wd; 105 event->wd = i_mark->wd;
106 event->sync_cookie = cookie;
106 event->name_len = len; 107 event->name_len = len;
107 if (len) 108 if (len)
108 strcpy(event->name, file_name); 109 strcpy(event->name, file_name);
diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c
index 497395c8274b..78a2ca3966c3 100644
--- a/fs/notify/inotify/inotify_user.c
+++ b/fs/notify/inotify/inotify_user.c
@@ -495,7 +495,7 @@ void inotify_ignored_and_remove_idr(struct fsnotify_mark *fsn_mark,
495 495
496 /* Queue ignore event for the watch */ 496 /* Queue ignore event for the watch */
497 inotify_handle_event(group, NULL, fsn_mark, NULL, FS_IN_IGNORED, 497 inotify_handle_event(group, NULL, fsn_mark, NULL, FS_IN_IGNORED,
498 NULL, FSNOTIFY_EVENT_NONE, NULL); 498 NULL, FSNOTIFY_EVENT_NONE, NULL, 0);
499 499
500 i_mark = container_of(fsn_mark, struct inotify_inode_mark, fsn_mark); 500 i_mark = container_of(fsn_mark, struct inotify_inode_mark, fsn_mark);
501 /* remove this mark from the idr */ 501 /* remove this mark from the idr */
@@ -633,11 +633,23 @@ static int inotify_update_watch(struct fsnotify_group *group, struct inode *inod
633static struct fsnotify_group *inotify_new_group(unsigned int max_events) 633static struct fsnotify_group *inotify_new_group(unsigned int max_events)
634{ 634{
635 struct fsnotify_group *group; 635 struct fsnotify_group *group;
636 struct inotify_event_info *oevent;
636 637
637 group = fsnotify_alloc_group(&inotify_fsnotify_ops); 638 group = fsnotify_alloc_group(&inotify_fsnotify_ops);
638 if (IS_ERR(group)) 639 if (IS_ERR(group))
639 return group; 640 return group;
640 641
642 oevent = kmalloc(sizeof(struct inotify_event_info), GFP_KERNEL);
643 if (unlikely(!oevent)) {
644 fsnotify_destroy_group(group);
645 return ERR_PTR(-ENOMEM);
646 }
647 group->overflow_event = &oevent->fse;
648 fsnotify_init_event(group->overflow_event, NULL, FS_Q_OVERFLOW);
649 oevent->wd = -1;
650 oevent->sync_cookie = 0;
651 oevent->name_len = 0;
652
641 group->max_events = max_events; 653 group->max_events = max_events;
642 654
643 spin_lock_init(&group->inotify_data.idr_lock); 655 spin_lock_init(&group->inotify_data.idr_lock);
diff --git a/fs/notify/notification.c b/fs/notify/notification.c
index 18b3c4427dca..1e58402171a5 100644
--- a/fs/notify/notification.c
+++ b/fs/notify/notification.c
@@ -80,7 +80,8 @@ void fsnotify_destroy_event(struct fsnotify_group *group,
80/* 80/*
81 * Add an event to the group notification queue. The group can later pull this 81 * Add an event to the group notification queue. The group can later pull this
82 * event off the queue to deal with. The function returns 0 if the event was 82 * event off the queue to deal with. The function returns 0 if the event was
83 * added to the queue, 1 if the event was merged with some other queued event. 83 * added to the queue, 1 if the event was merged with some other queued event,
84 * 2 if the queue of events has overflown.
84 */ 85 */
85int fsnotify_add_notify_event(struct fsnotify_group *group, 86int fsnotify_add_notify_event(struct fsnotify_group *group,
86 struct fsnotify_event *event, 87 struct fsnotify_event *event,
@@ -95,10 +96,14 @@ int fsnotify_add_notify_event(struct fsnotify_group *group,
95 mutex_lock(&group->notification_mutex); 96 mutex_lock(&group->notification_mutex);
96 97
97 if (group->q_len >= group->max_events) { 98 if (group->q_len >= group->max_events) {
99 ret = 2;
98 /* Queue overflow event only if it isn't already queued */ 100 /* Queue overflow event only if it isn't already queued */
99 if (list_empty(&group->overflow_event.list)) 101 if (!list_empty(&group->overflow_event->list)) {
100 event = &group->overflow_event; 102 mutex_unlock(&group->notification_mutex);
101 ret = 1; 103 return ret;
104 }
105 event = group->overflow_event;
106 goto queue;
102 } 107 }
103 108
104 if (!list_empty(list) && merge) { 109 if (!list_empty(list) && merge) {
@@ -109,6 +114,7 @@ int fsnotify_add_notify_event(struct fsnotify_group *group,
109 } 114 }
110 } 115 }
111 116
117queue:
112 group->q_len++; 118 group->q_len++;
113 list_add_tail(&event->list, list); 119 list_add_tail(&event->list, list);
114 mutex_unlock(&group->notification_mutex); 120 mutex_unlock(&group->notification_mutex);
@@ -132,7 +138,11 @@ struct fsnotify_event *fsnotify_remove_notify_event(struct fsnotify_group *group
132 138
133 event = list_first_entry(&group->notification_list, 139 event = list_first_entry(&group->notification_list,
134 struct fsnotify_event, list); 140 struct fsnotify_event, list);
135 list_del(&event->list); 141 /*
142 * We need to init list head for the case of overflow event so that
143 * check in fsnotify_add_notify_events() works
144 */
145 list_del_init(&event->list);
136 group->q_len--; 146 group->q_len--;
137 147
138 return event; 148 return event;
diff --git a/fs/ocfs2/quota_global.c b/fs/ocfs2/quota_global.c
index aaa50611ec66..d7b5108789e2 100644
--- a/fs/ocfs2/quota_global.c
+++ b/fs/ocfs2/quota_global.c
@@ -717,6 +717,12 @@ static int ocfs2_release_dquot(struct dquot *dquot)
717 */ 717 */
718 if (status < 0) 718 if (status < 0)
719 mlog_errno(status); 719 mlog_errno(status);
720 /*
721 * Clear dq_off so that we search for the structure in quota file next
722 * time we acquire it. The structure might be deleted and reallocated
723 * elsewhere by another node while our dquot structure is on freelist.
724 */
725 dquot->dq_off = 0;
720 clear_bit(DQ_ACTIVE_B, &dquot->dq_flags); 726 clear_bit(DQ_ACTIVE_B, &dquot->dq_flags);
721out_trans: 727out_trans:
722 ocfs2_commit_trans(osb, handle); 728 ocfs2_commit_trans(osb, handle);
@@ -756,16 +762,17 @@ static int ocfs2_acquire_dquot(struct dquot *dquot)
756 status = ocfs2_lock_global_qf(info, 1); 762 status = ocfs2_lock_global_qf(info, 1);
757 if (status < 0) 763 if (status < 0)
758 goto out; 764 goto out;
759 if (!test_bit(DQ_READ_B, &dquot->dq_flags)) { 765 status = ocfs2_qinfo_lock(info, 0);
760 status = ocfs2_qinfo_lock(info, 0); 766 if (status < 0)
761 if (status < 0) 767 goto out_dq;
762 goto out_dq; 768 /*
763 status = qtree_read_dquot(&info->dqi_gi, dquot); 769 * We always want to read dquot structure from disk because we don't
764 ocfs2_qinfo_unlock(info, 0); 770 * know what happened with it while it was on freelist.
765 if (status < 0) 771 */
766 goto out_dq; 772 status = qtree_read_dquot(&info->dqi_gi, dquot);
767 } 773 ocfs2_qinfo_unlock(info, 0);
768 set_bit(DQ_READ_B, &dquot->dq_flags); 774 if (status < 0)
775 goto out_dq;
769 776
770 OCFS2_DQUOT(dquot)->dq_use_count++; 777 OCFS2_DQUOT(dquot)->dq_use_count++;
771 OCFS2_DQUOT(dquot)->dq_origspace = dquot->dq_dqb.dqb_curspace; 778 OCFS2_DQUOT(dquot)->dq_origspace = dquot->dq_dqb.dqb_curspace;
diff --git a/fs/ocfs2/quota_local.c b/fs/ocfs2/quota_local.c
index 2e4344be3b96..2001862bf2b1 100644
--- a/fs/ocfs2/quota_local.c
+++ b/fs/ocfs2/quota_local.c
@@ -1303,10 +1303,6 @@ int ocfs2_local_release_dquot(handle_t *handle, struct dquot *dquot)
1303 ocfs2_journal_dirty(handle, od->dq_chunk->qc_headerbh); 1303 ocfs2_journal_dirty(handle, od->dq_chunk->qc_headerbh);
1304 1304
1305out: 1305out:
1306 /* Clear the read bit so that next time someone uses this
1307 * dquot he reads fresh info from disk and allocates local
1308 * dquot structure */
1309 clear_bit(DQ_READ_B, &dquot->dq_flags);
1310 return status; 1306 return status;
1311} 1307}
1312 1308
diff --git a/fs/proc/page.c b/fs/proc/page.c
index 02174a610315..e647c55275d9 100644
--- a/fs/proc/page.c
+++ b/fs/proc/page.c
@@ -121,9 +121,8 @@ u64 stable_page_flags(struct page *page)
121 * just checks PG_head/PG_tail, so we need to check PageLRU/PageAnon 121 * just checks PG_head/PG_tail, so we need to check PageLRU/PageAnon
122 * to make sure a given page is a thp, not a non-huge compound page. 122 * to make sure a given page is a thp, not a non-huge compound page.
123 */ 123 */
124 else if (PageTransCompound(page) && 124 else if (PageTransCompound(page) && (PageLRU(compound_head(page)) ||
125 (PageLRU(compound_trans_head(page)) || 125 PageAnon(compound_head(page))))
126 PageAnon(compound_trans_head(page))))
127 u |= 1 << KPF_THP; 126 u |= 1 << KPF_THP;
128 127
129 /* 128 /*
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
index 831d49a4111f..cfc8dcc16043 100644
--- a/fs/quota/dquot.c
+++ b/fs/quota/dquot.c
@@ -581,9 +581,17 @@ int dquot_scan_active(struct super_block *sb,
581 dqstats_inc(DQST_LOOKUPS); 581 dqstats_inc(DQST_LOOKUPS);
582 dqput(old_dquot); 582 dqput(old_dquot);
583 old_dquot = dquot; 583 old_dquot = dquot;
584 ret = fn(dquot, priv); 584 /*
585 if (ret < 0) 585 * ->release_dquot() can be racing with us. Our reference
586 goto out; 586 * protects us from new calls to it so just wait for any
587 * outstanding call and recheck the DQ_ACTIVE_B after that.
588 */
589 wait_on_dquot(dquot);
590 if (test_bit(DQ_ACTIVE_B, &dquot->dq_flags)) {
591 ret = fn(dquot, priv);
592 if (ret < 0)
593 goto out;
594 }
587 spin_lock(&dq_list_lock); 595 spin_lock(&dq_list_lock);
588 /* We are safe to continue now because our dquot could not 596 /* We are safe to continue now because our dquot could not
589 * be moved out of the inuse list while we hold the reference */ 597 * be moved out of the inuse list while we hold the reference */
diff --git a/fs/sync.c b/fs/sync.c
index e8ba024a055b..b28d1dd10e8b 100644
--- a/fs/sync.c
+++ b/fs/sync.c
@@ -27,11 +27,10 @@
27 * wait == 1 case since in that case write_inode() functions do 27 * wait == 1 case since in that case write_inode() functions do
28 * sync_dirty_buffer() and thus effectively write one block at a time. 28 * sync_dirty_buffer() and thus effectively write one block at a time.
29 */ 29 */
30static int __sync_filesystem(struct super_block *sb, int wait, 30static int __sync_filesystem(struct super_block *sb, int wait)
31 unsigned long start)
32{ 31{
33 if (wait) 32 if (wait)
34 sync_inodes_sb(sb, start); 33 sync_inodes_sb(sb);
35 else 34 else
36 writeback_inodes_sb(sb, WB_REASON_SYNC); 35 writeback_inodes_sb(sb, WB_REASON_SYNC);
37 36
@@ -48,7 +47,6 @@ static int __sync_filesystem(struct super_block *sb, int wait,
48int sync_filesystem(struct super_block *sb) 47int sync_filesystem(struct super_block *sb)
49{ 48{
50 int ret; 49 int ret;
51 unsigned long start = jiffies;
52 50
53 /* 51 /*
54 * We need to be protected against the filesystem going from 52 * We need to be protected against the filesystem going from
@@ -62,17 +60,17 @@ int sync_filesystem(struct super_block *sb)
62 if (sb->s_flags & MS_RDONLY) 60 if (sb->s_flags & MS_RDONLY)
63 return 0; 61 return 0;
64 62
65 ret = __sync_filesystem(sb, 0, start); 63 ret = __sync_filesystem(sb, 0);
66 if (ret < 0) 64 if (ret < 0)
67 return ret; 65 return ret;
68 return __sync_filesystem(sb, 1, start); 66 return __sync_filesystem(sb, 1);
69} 67}
70EXPORT_SYMBOL_GPL(sync_filesystem); 68EXPORT_SYMBOL_GPL(sync_filesystem);
71 69
72static void sync_inodes_one_sb(struct super_block *sb, void *arg) 70static void sync_inodes_one_sb(struct super_block *sb, void *arg)
73{ 71{
74 if (!(sb->s_flags & MS_RDONLY)) 72 if (!(sb->s_flags & MS_RDONLY))
75 sync_inodes_sb(sb, *((unsigned long *)arg)); 73 sync_inodes_sb(sb);
76} 74}
77 75
78static void sync_fs_one_sb(struct super_block *sb, void *arg) 76static void sync_fs_one_sb(struct super_block *sb, void *arg)
@@ -104,10 +102,9 @@ static void fdatawait_one_bdev(struct block_device *bdev, void *arg)
104SYSCALL_DEFINE0(sync) 102SYSCALL_DEFINE0(sync)
105{ 103{
106 int nowait = 0, wait = 1; 104 int nowait = 0, wait = 1;
107 unsigned long start = jiffies;
108 105
109 wakeup_flusher_threads(0, WB_REASON_SYNC); 106 wakeup_flusher_threads(0, WB_REASON_SYNC);
110 iterate_supers(sync_inodes_one_sb, &start); 107 iterate_supers(sync_inodes_one_sb, NULL);
111 iterate_supers(sync_fs_one_sb, &nowait); 108 iterate_supers(sync_fs_one_sb, &nowait);
112 iterate_supers(sync_fs_one_sb, &wait); 109 iterate_supers(sync_fs_one_sb, &wait);
113 iterate_bdevs(fdatawrite_one_bdev, NULL); 110 iterate_bdevs(fdatawrite_one_bdev, NULL);
diff --git a/fs/sysfs/mount.c b/fs/sysfs/mount.c
index 6211230814fd..3eaf5c6622eb 100644
--- a/fs/sysfs/mount.c
+++ b/fs/sysfs/mount.c
@@ -27,6 +27,7 @@ static struct dentry *sysfs_mount(struct file_system_type *fs_type,
27{ 27{
28 struct dentry *root; 28 struct dentry *root;
29 void *ns; 29 void *ns;
30 bool new_sb;
30 31
31 if (!(flags & MS_KERNMOUNT)) { 32 if (!(flags & MS_KERNMOUNT)) {
32 if (!capable(CAP_SYS_ADMIN) && !fs_fully_visible(fs_type)) 33 if (!capable(CAP_SYS_ADMIN) && !fs_fully_visible(fs_type))
@@ -37,8 +38,8 @@ static struct dentry *sysfs_mount(struct file_system_type *fs_type,
37 } 38 }
38 39
39 ns = kobj_ns_grab_current(KOBJ_NS_TYPE_NET); 40 ns = kobj_ns_grab_current(KOBJ_NS_TYPE_NET);
40 root = kernfs_mount_ns(fs_type, flags, sysfs_root, ns); 41 root = kernfs_mount_ns(fs_type, flags, sysfs_root, &new_sb, ns);
41 if (IS_ERR(root)) 42 if (IS_ERR(root) || !new_sb)
42 kobj_ns_drop(KOBJ_NS_TYPE_NET, ns); 43 kobj_ns_drop(KOBJ_NS_TYPE_NET, ns);
43 return root; 44 return root;
44} 45}
diff --git a/fs/udf/file.c b/fs/udf/file.c
index c02a27a19c6d..1037637957c7 100644
--- a/fs/udf/file.c
+++ b/fs/udf/file.c
@@ -144,6 +144,7 @@ static ssize_t udf_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
144 size_t count = iocb->ki_nbytes; 144 size_t count = iocb->ki_nbytes;
145 struct udf_inode_info *iinfo = UDF_I(inode); 145 struct udf_inode_info *iinfo = UDF_I(inode);
146 146
147 mutex_lock(&inode->i_mutex);
147 down_write(&iinfo->i_data_sem); 148 down_write(&iinfo->i_data_sem);
148 if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) { 149 if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) {
149 if (file->f_flags & O_APPEND) 150 if (file->f_flags & O_APPEND)
@@ -156,6 +157,7 @@ static ssize_t udf_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
156 pos + count)) { 157 pos + count)) {
157 err = udf_expand_file_adinicb(inode); 158 err = udf_expand_file_adinicb(inode);
158 if (err) { 159 if (err) {
160 mutex_unlock(&inode->i_mutex);
159 udf_debug("udf_expand_adinicb: err=%d\n", err); 161 udf_debug("udf_expand_adinicb: err=%d\n", err);
160 return err; 162 return err;
161 } 163 }
@@ -169,9 +171,17 @@ static ssize_t udf_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
169 } else 171 } else
170 up_write(&iinfo->i_data_sem); 172 up_write(&iinfo->i_data_sem);
171 173
172 retval = generic_file_aio_write(iocb, iov, nr_segs, ppos); 174 retval = __generic_file_aio_write(iocb, iov, nr_segs, &iocb->ki_pos);
173 if (retval > 0) 175 mutex_unlock(&inode->i_mutex);
176
177 if (retval > 0) {
178 ssize_t err;
179
174 mark_inode_dirty(inode); 180 mark_inode_dirty(inode);
181 err = generic_write_sync(file, iocb->ki_pos - retval, retval);
182 if (err < 0)
183 retval = err;
184 }
175 185
176 return retval; 186 return retval;
177} 187}
diff --git a/fs/udf/inode.c b/fs/udf/inode.c
index 062b7925bca0..982ce05c87ed 100644
--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -265,6 +265,7 @@ int udf_expand_file_adinicb(struct inode *inode)
265 .nr_to_write = 1, 265 .nr_to_write = 1,
266 }; 266 };
267 267
268 WARN_ON_ONCE(!mutex_is_locked(&inode->i_mutex));
268 if (!iinfo->i_lenAlloc) { 269 if (!iinfo->i_lenAlloc) {
269 if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_SHORT_AD)) 270 if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_SHORT_AD))
270 iinfo->i_alloc_type = ICBTAG_FLAG_AD_SHORT; 271 iinfo->i_alloc_type = ICBTAG_FLAG_AD_SHORT;
diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
index f35d5c953ff9..9ddfb8190ca1 100644
--- a/fs/xfs/xfs_iops.c
+++ b/fs/xfs/xfs_iops.c
@@ -705,7 +705,6 @@ xfs_setattr_size(
705{ 705{
706 struct xfs_mount *mp = ip->i_mount; 706 struct xfs_mount *mp = ip->i_mount;
707 struct inode *inode = VFS_I(ip); 707 struct inode *inode = VFS_I(ip);
708 int mask = iattr->ia_valid;
709 xfs_off_t oldsize, newsize; 708 xfs_off_t oldsize, newsize;
710 struct xfs_trans *tp; 709 struct xfs_trans *tp;
711 int error; 710 int error;
@@ -726,8 +725,8 @@ xfs_setattr_size(
726 725
727 ASSERT(xfs_isilocked(ip, XFS_IOLOCK_EXCL)); 726 ASSERT(xfs_isilocked(ip, XFS_IOLOCK_EXCL));
728 ASSERT(S_ISREG(ip->i_d.di_mode)); 727 ASSERT(S_ISREG(ip->i_d.di_mode));
729 ASSERT((mask & (ATTR_UID|ATTR_GID|ATTR_ATIME|ATTR_ATIME_SET| 728 ASSERT((iattr->ia_valid & (ATTR_UID|ATTR_GID|ATTR_ATIME|ATTR_ATIME_SET|
730 ATTR_MTIME_SET|ATTR_KILL_PRIV|ATTR_TIMES_SET)) == 0); 729 ATTR_MTIME_SET|ATTR_KILL_PRIV|ATTR_TIMES_SET)) == 0);
731 730
732 oldsize = inode->i_size; 731 oldsize = inode->i_size;
733 newsize = iattr->ia_size; 732 newsize = iattr->ia_size;
@@ -736,7 +735,7 @@ xfs_setattr_size(
736 * Short circuit the truncate case for zero length files. 735 * Short circuit the truncate case for zero length files.
737 */ 736 */
738 if (newsize == 0 && oldsize == 0 && ip->i_d.di_nextents == 0) { 737 if (newsize == 0 && oldsize == 0 && ip->i_d.di_nextents == 0) {
739 if (!(mask & (ATTR_CTIME|ATTR_MTIME))) 738 if (!(iattr->ia_valid & (ATTR_CTIME|ATTR_MTIME)))
740 return 0; 739 return 0;
741 740
742 /* 741 /*
@@ -824,10 +823,11 @@ xfs_setattr_size(
824 * these flags set. For all other operations the VFS set these flags 823 * these flags set. For all other operations the VFS set these flags
825 * explicitly if it wants a timestamp update. 824 * explicitly if it wants a timestamp update.
826 */ 825 */
827 if (newsize != oldsize && (!(mask & (ATTR_CTIME | ATTR_MTIME)))) { 826 if (newsize != oldsize &&
827 !(iattr->ia_valid & (ATTR_CTIME | ATTR_MTIME))) {
828 iattr->ia_ctime = iattr->ia_mtime = 828 iattr->ia_ctime = iattr->ia_mtime =
829 current_fs_time(inode->i_sb); 829 current_fs_time(inode->i_sb);
830 mask |= ATTR_CTIME | ATTR_MTIME; 830 iattr->ia_valid |= ATTR_CTIME | ATTR_MTIME;
831 } 831 }
832 832
833 /* 833 /*
@@ -863,9 +863,9 @@ xfs_setattr_size(
863 xfs_inode_clear_eofblocks_tag(ip); 863 xfs_inode_clear_eofblocks_tag(ip);
864 } 864 }
865 865
866 if (mask & ATTR_MODE) 866 if (iattr->ia_valid & ATTR_MODE)
867 xfs_setattr_mode(ip, iattr); 867 xfs_setattr_mode(ip, iattr);
868 if (mask & (ATTR_ATIME|ATTR_CTIME|ATTR_MTIME)) 868 if (iattr->ia_valid & (ATTR_ATIME|ATTR_CTIME|ATTR_MTIME))
869 xfs_setattr_time(ip, iattr); 869 xfs_setattr_time(ip, iattr);
870 870
871 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); 871 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
diff --git a/fs/xfs/xfs_log_cil.c b/fs/xfs/xfs_log_cil.c
index cdebd832c3db..4ef6fdbced78 100644
--- a/fs/xfs/xfs_log_cil.c
+++ b/fs/xfs/xfs_log_cil.c
@@ -205,16 +205,25 @@ xlog_cil_insert_format_items(
205 /* 205 /*
206 * We 64-bit align the length of each iovec so that the start 206 * We 64-bit align the length of each iovec so that the start
207 * of the next one is naturally aligned. We'll need to 207 * of the next one is naturally aligned. We'll need to
208 * account for that slack space here. 208 * account for that slack space here. Then round nbytes up
209 * to 64-bit alignment so that the initial buffer alignment is
210 * easy to calculate and verify.
209 */ 211 */
210 nbytes += niovecs * sizeof(uint64_t); 212 nbytes += niovecs * sizeof(uint64_t);
213 nbytes = round_up(nbytes, sizeof(uint64_t));
211 214
212 /* grab the old item if it exists for reservation accounting */ 215 /* grab the old item if it exists for reservation accounting */
213 old_lv = lip->li_lv; 216 old_lv = lip->li_lv;
214 217
215 /* calc buffer size */ 218 /*
216 buf_size = sizeof(struct xfs_log_vec) + nbytes + 219 * The data buffer needs to start 64-bit aligned, so round up
217 niovecs * sizeof(struct xfs_log_iovec); 220 * that space to ensure we can align it appropriately and not
221 * overrun the buffer.
222 */
223 buf_size = nbytes +
224 round_up((sizeof(struct xfs_log_vec) +
225 niovecs * sizeof(struct xfs_log_iovec)),
226 sizeof(uint64_t));
218 227
219 /* compare to existing item size */ 228 /* compare to existing item size */
220 if (lip->li_lv && buf_size <= lip->li_lv->lv_size) { 229 if (lip->li_lv && buf_size <= lip->li_lv->lv_size) {
@@ -251,6 +260,8 @@ xlog_cil_insert_format_items(
251 /* The allocated data region lies beyond the iovec region */ 260 /* The allocated data region lies beyond the iovec region */
252 lv->lv_buf_len = 0; 261 lv->lv_buf_len = 0;
253 lv->lv_buf = (char *)lv + buf_size - nbytes; 262 lv->lv_buf = (char *)lv + buf_size - nbytes;
263 ASSERT(IS_ALIGNED((unsigned long)lv->lv_buf, sizeof(uint64_t)));
264
254 lip->li_ops->iop_format(lip, lv); 265 lip->li_ops->iop_format(lip, lv);
255insert: 266insert:
256 ASSERT(lv->lv_buf_len <= nbytes); 267 ASSERT(lv->lv_buf_len <= nbytes);
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index 02df7b408a26..f96c05669a9e 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -282,22 +282,29 @@ xfs_readsb(
282 struct xfs_sb *sbp = &mp->m_sb; 282 struct xfs_sb *sbp = &mp->m_sb;
283 int error; 283 int error;
284 int loud = !(flags & XFS_MFSI_QUIET); 284 int loud = !(flags & XFS_MFSI_QUIET);
285 const struct xfs_buf_ops *buf_ops;
285 286
286 ASSERT(mp->m_sb_bp == NULL); 287 ASSERT(mp->m_sb_bp == NULL);
287 ASSERT(mp->m_ddev_targp != NULL); 288 ASSERT(mp->m_ddev_targp != NULL);
288 289
289 /* 290 /*
291 * For the initial read, we must guess at the sector
292 * size based on the block device. It's enough to
293 * get the sb_sectsize out of the superblock and
294 * then reread with the proper length.
295 * We don't verify it yet, because it may not be complete.
296 */
297 sector_size = xfs_getsize_buftarg(mp->m_ddev_targp);
298 buf_ops = NULL;
299
300 /*
290 * Allocate a (locked) buffer to hold the superblock. 301 * Allocate a (locked) buffer to hold the superblock.
291 * This will be kept around at all times to optimize 302 * This will be kept around at all times to optimize
292 * access to the superblock. 303 * access to the superblock.
293 */ 304 */
294 sector_size = xfs_getsize_buftarg(mp->m_ddev_targp);
295
296reread: 305reread:
297 bp = xfs_buf_read_uncached(mp->m_ddev_targp, XFS_SB_DADDR, 306 bp = xfs_buf_read_uncached(mp->m_ddev_targp, XFS_SB_DADDR,
298 BTOBB(sector_size), 0, 307 BTOBB(sector_size), 0, buf_ops);
299 loud ? &xfs_sb_buf_ops
300 : &xfs_sb_quiet_buf_ops);
301 if (!bp) { 308 if (!bp) {
302 if (loud) 309 if (loud)
303 xfs_warn(mp, "SB buffer read failed"); 310 xfs_warn(mp, "SB buffer read failed");
@@ -328,12 +335,13 @@ reread:
328 } 335 }
329 336
330 /* 337 /*
331 * If device sector size is smaller than the superblock size, 338 * Re-read the superblock so the buffer is correctly sized,
332 * re-read the superblock so the buffer is correctly sized. 339 * and properly verified.
333 */ 340 */
334 if (sector_size < sbp->sb_sectsize) { 341 if (buf_ops == NULL) {
335 xfs_buf_relse(bp); 342 xfs_buf_relse(bp);
336 sector_size = sbp->sb_sectsize; 343 sector_size = sbp->sb_sectsize;
344 buf_ops = loud ? &xfs_sb_buf_ops : &xfs_sb_quiet_buf_ops;
337 goto reread; 345 goto reread;
338 } 346 }
339 347
diff --git a/fs/xfs/xfs_sb.c b/fs/xfs/xfs_sb.c
index b7c9aea77f8f..1e116794bb66 100644
--- a/fs/xfs/xfs_sb.c
+++ b/fs/xfs/xfs_sb.c
@@ -295,8 +295,7 @@ xfs_mount_validate_sb(
295 sbp->sb_dblocks == 0 || 295 sbp->sb_dblocks == 0 ||
296 sbp->sb_dblocks > XFS_MAX_DBLOCKS(sbp) || 296 sbp->sb_dblocks > XFS_MAX_DBLOCKS(sbp) ||
297 sbp->sb_dblocks < XFS_MIN_DBLOCKS(sbp))) { 297 sbp->sb_dblocks < XFS_MIN_DBLOCKS(sbp))) {
298 XFS_CORRUPTION_ERROR("SB sanity check failed", 298 xfs_notice(mp, "SB sanity check failed");
299 XFS_ERRLEVEL_LOW, mp, sbp);
300 return XFS_ERROR(EFSCORRUPTED); 299 return XFS_ERROR(EFSCORRUPTED);
301 } 300 }
302 301
@@ -611,10 +610,10 @@ xfs_sb_read_verify(
611 XFS_SB_VERSION_5) || 610 XFS_SB_VERSION_5) ||
612 dsb->sb_crc != 0)) { 611 dsb->sb_crc != 0)) {
613 612
614 if (!xfs_verify_cksum(bp->b_addr, be16_to_cpu(dsb->sb_sectsize), 613 if (!xfs_verify_cksum(bp->b_addr, BBTOB(bp->b_length),
615 offsetof(struct xfs_sb, sb_crc))) { 614 offsetof(struct xfs_sb, sb_crc))) {
616 /* Only fail bad secondaries on a known V5 filesystem */ 615 /* Only fail bad secondaries on a known V5 filesystem */
617 if (bp->b_bn != XFS_SB_DADDR && 616 if (bp->b_bn == XFS_SB_DADDR ||
618 xfs_sb_version_hascrc(&mp->m_sb)) { 617 xfs_sb_version_hascrc(&mp->m_sb)) {
619 error = EFSCORRUPTED; 618 error = EFSCORRUPTED;
620 goto out_error; 619 goto out_error;
@@ -625,7 +624,7 @@ xfs_sb_read_verify(
625 624
626out_error: 625out_error:
627 if (error) { 626 if (error) {
628 if (error != EWRONGFS) 627 if (error == EFSCORRUPTED)
629 XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, 628 XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW,
630 mp, bp->b_addr); 629 mp, bp->b_addr);
631 xfs_buf_ioerror(bp, error); 630 xfs_buf_ioerror(bp, error);
@@ -644,7 +643,6 @@ xfs_sb_quiet_read_verify(
644{ 643{
645 struct xfs_dsb *dsb = XFS_BUF_TO_SBP(bp); 644 struct xfs_dsb *dsb = XFS_BUF_TO_SBP(bp);
646 645
647
648 if (dsb->sb_magicnum == cpu_to_be32(XFS_SB_MAGIC)) { 646 if (dsb->sb_magicnum == cpu_to_be32(XFS_SB_MAGIC)) {
649 /* XFS filesystem, verify noisily! */ 647 /* XFS filesystem, verify noisily! */
650 xfs_sb_read_verify(bp); 648 xfs_sb_read_verify(bp);
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index f317488263dd..d971f4932b5d 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -913,7 +913,7 @@ xfs_flush_inodes(
913 struct super_block *sb = mp->m_super; 913 struct super_block *sb = mp->m_super;
914 914
915 if (down_read_trylock(&sb->s_umount)) { 915 if (down_read_trylock(&sb->s_umount)) {
916 sync_inodes_sb(sb, jiffies); 916 sync_inodes_sb(sb);
917 up_read(&sb->s_umount); 917 up_read(&sb->s_umount);
918 } 918 }
919} 919}
diff --git a/include/dt-bindings/clock/tegra124-car.h b/include/dt-bindings/clock/tegra124-car.h
index a1116a3b54ef..8c1603b10665 100644
--- a/include/dt-bindings/clock/tegra124-car.h
+++ b/include/dt-bindings/clock/tegra124-car.h
@@ -36,10 +36,10 @@
36#define TEGRA124_CLK_PWM 17 36#define TEGRA124_CLK_PWM 17
37#define TEGRA124_CLK_I2S2 18 37#define TEGRA124_CLK_I2S2 18
38/* 20 (register bit affects vi and vi_sensor) */ 38/* 20 (register bit affects vi and vi_sensor) */
39#define TEGRA124_CLK_GR_2D 21 39/* 21 */
40#define TEGRA124_CLK_USBD 22 40#define TEGRA124_CLK_USBD 22
41#define TEGRA124_CLK_ISP 23 41#define TEGRA124_CLK_ISP 23
42#define TEGRA124_CLK_GR_3D 24 42/* 26 */
43/* 25 */ 43/* 25 */
44#define TEGRA124_CLK_DISP2 26 44#define TEGRA124_CLK_DISP2 26
45#define TEGRA124_CLK_DISP1 27 45#define TEGRA124_CLK_DISP1 27
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
index 5c097596104b..9450f025fe0c 100644
--- a/include/linux/cgroup.h
+++ b/include/linux/cgroup.h
@@ -166,6 +166,8 @@ struct cgroup {
166 * 166 *
167 * The ID of the root cgroup is always 0, and a new cgroup 167 * The ID of the root cgroup is always 0, and a new cgroup
168 * will be assigned with a smallest available ID. 168 * will be assigned with a smallest available ID.
169 *
170 * Allocating/Removing ID must be protected by cgroup_mutex.
169 */ 171 */
170 int id; 172 int id;
171 173
diff --git a/include/linux/fsnotify_backend.h b/include/linux/fsnotify_backend.h
index 3d286ff49ab0..64cf3ef50696 100644
--- a/include/linux/fsnotify_backend.h
+++ b/include/linux/fsnotify_backend.h
@@ -99,7 +99,7 @@ struct fsnotify_ops {
99 struct fsnotify_mark *inode_mark, 99 struct fsnotify_mark *inode_mark,
100 struct fsnotify_mark *vfsmount_mark, 100 struct fsnotify_mark *vfsmount_mark,
101 u32 mask, void *data, int data_type, 101 u32 mask, void *data, int data_type,
102 const unsigned char *file_name); 102 const unsigned char *file_name, u32 cookie);
103 void (*free_group_priv)(struct fsnotify_group *group); 103 void (*free_group_priv)(struct fsnotify_group *group);
104 void (*freeing_mark)(struct fsnotify_mark *mark, struct fsnotify_group *group); 104 void (*freeing_mark)(struct fsnotify_mark *mark, struct fsnotify_group *group);
105 void (*free_event)(struct fsnotify_event *event); 105 void (*free_event)(struct fsnotify_event *event);
@@ -160,7 +160,7 @@ struct fsnotify_group {
160 160
161 struct fasync_struct *fsn_fa; /* async notification */ 161 struct fasync_struct *fsn_fa; /* async notification */
162 162
163 struct fsnotify_event overflow_event; /* Event we queue when the 163 struct fsnotify_event *overflow_event; /* Event we queue when the
164 * notification list is too 164 * notification list is too
165 * full */ 165 * full */
166 166
diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h
index db512014e061..b826239bdce0 100644
--- a/include/linux/huge_mm.h
+++ b/include/linux/huge_mm.h
@@ -157,46 +157,6 @@ static inline int hpage_nr_pages(struct page *page)
157 return HPAGE_PMD_NR; 157 return HPAGE_PMD_NR;
158 return 1; 158 return 1;
159} 159}
160/*
161 * compound_trans_head() should be used instead of compound_head(),
162 * whenever the "page" passed as parameter could be the tail of a
163 * transparent hugepage that could be undergoing a
164 * __split_huge_page_refcount(). The page structure layout often
165 * changes across releases and it makes extensive use of unions. So if
166 * the page structure layout will change in a way that
167 * page->first_page gets clobbered by __split_huge_page_refcount, the
168 * implementation making use of smp_rmb() will be required.
169 *
170 * Currently we define compound_trans_head as compound_head, because
171 * page->private is in the same union with page->first_page, and
172 * page->private isn't clobbered. However this also means we're
173 * currently leaving dirt into the page->private field of anonymous
174 * pages resulting from a THP split, instead of setting page->private
175 * to zero like for every other page that has PG_private not set. But
176 * anonymous pages don't use page->private so this is not a problem.
177 */
178#if 0
179/* This will be needed if page->private will be clobbered in split_huge_page */
180static inline struct page *compound_trans_head(struct page *page)
181{
182 if (PageTail(page)) {
183 struct page *head;
184 head = page->first_page;
185 smp_rmb();
186 /*
187 * head may be a dangling pointer.
188 * __split_huge_page_refcount clears PageTail before
189 * overwriting first_page, so if PageTail is still
190 * there it means the head pointer isn't dangling.
191 */
192 if (PageTail(page))
193 return head;
194 }
195 return page;
196}
197#else
198#define compound_trans_head(page) compound_head(page)
199#endif
200 160
201extern int do_huge_pmd_numa_page(struct mm_struct *mm, struct vm_area_struct *vma, 161extern int do_huge_pmd_numa_page(struct mm_struct *mm, struct vm_area_struct *vma,
202 unsigned long addr, pmd_t pmd, pmd_t *pmdp); 162 unsigned long addr, pmd_t pmd, pmd_t *pmdp);
@@ -226,7 +186,6 @@ static inline int split_huge_page(struct page *page)
226 do { } while (0) 186 do { } while (0)
227#define split_huge_page_pmd_mm(__mm, __address, __pmd) \ 187#define split_huge_page_pmd_mm(__mm, __address, __pmd) \
228 do { } while (0) 188 do { } while (0)
229#define compound_trans_head(page) compound_head(page)
230static inline int hugepage_madvise(struct vm_area_struct *vma, 189static inline int hugepage_madvise(struct vm_area_struct *vma,
231 unsigned long *vm_flags, int advice) 190 unsigned long *vm_flags, int advice)
232{ 191{
diff --git a/include/linux/ipc_namespace.h b/include/linux/ipc_namespace.h
index e7831d203737..35e7eca4e33b 100644
--- a/include/linux/ipc_namespace.h
+++ b/include/linux/ipc_namespace.h
@@ -118,9 +118,7 @@ extern int mq_init_ns(struct ipc_namespace *ns);
118 * the new maximum will handle anyone else. I may have to revisit this 118 * the new maximum will handle anyone else. I may have to revisit this
119 * in the future. 119 * in the future.
120 */ 120 */
121#define MIN_QUEUESMAX 1
122#define DFLT_QUEUESMAX 256 121#define DFLT_QUEUESMAX 256
123#define HARD_QUEUESMAX 1024
124#define MIN_MSGMAX 1 122#define MIN_MSGMAX 1
125#define DFLT_MSG 10U 123#define DFLT_MSG 10U
126#define DFLT_MSGMAX 10 124#define DFLT_MSGMAX 10
diff --git a/include/linux/kernfs.h b/include/linux/kernfs.h
index 5be9f0228a3b..d267623c28cf 100644
--- a/include/linux/kernfs.h
+++ b/include/linux/kernfs.h
@@ -249,7 +249,8 @@ void kernfs_notify(struct kernfs_node *kn);
249 249
250const void *kernfs_super_ns(struct super_block *sb); 250const void *kernfs_super_ns(struct super_block *sb);
251struct dentry *kernfs_mount_ns(struct file_system_type *fs_type, int flags, 251struct dentry *kernfs_mount_ns(struct file_system_type *fs_type, int flags,
252 struct kernfs_root *root, const void *ns); 252 struct kernfs_root *root, bool *new_sb_created,
253 const void *ns);
253void kernfs_kill_sb(struct super_block *sb); 254void kernfs_kill_sb(struct super_block *sb);
254 255
255void kernfs_init(void); 256void kernfs_init(void);
@@ -317,7 +318,7 @@ static inline const void *kernfs_super_ns(struct super_block *sb)
317 318
318static inline struct dentry * 319static inline struct dentry *
319kernfs_mount_ns(struct file_system_type *fs_type, int flags, 320kernfs_mount_ns(struct file_system_type *fs_type, int flags,
320 struct kernfs_root *root, const void *ns) 321 struct kernfs_root *root, bool *new_sb_created, const void *ns)
321{ return ERR_PTR(-ENOSYS); } 322{ return ERR_PTR(-ENOSYS); }
322 323
323static inline void kernfs_kill_sb(struct super_block *sb) { } 324static inline void kernfs_kill_sb(struct super_block *sb) { }
@@ -368,9 +369,9 @@ static inline int kernfs_remove_by_name(struct kernfs_node *parent,
368 369
369static inline struct dentry * 370static inline struct dentry *
370kernfs_mount(struct file_system_type *fs_type, int flags, 371kernfs_mount(struct file_system_type *fs_type, int flags,
371 struct kernfs_root *root) 372 struct kernfs_root *root, bool *new_sb_created)
372{ 373{
373 return kernfs_mount_ns(fs_type, flags, root, NULL); 374 return kernfs_mount_ns(fs_type, flags, root, new_sb_created, NULL);
374} 375}
375 376
376#endif /* __LINUX_KERNFS_H */ 377#endif /* __LINUX_KERNFS_H */
diff --git a/include/linux/mfd/max8997-private.h b/include/linux/mfd/max8997-private.h
index ad1ae7f345ad..78c76cd4d37b 100644
--- a/include/linux/mfd/max8997-private.h
+++ b/include/linux/mfd/max8997-private.h
@@ -387,7 +387,7 @@ struct max8997_dev {
387 struct i2c_client *muic; /* slave addr 0x4a */ 387 struct i2c_client *muic; /* slave addr 0x4a */
388 struct mutex iolock; 388 struct mutex iolock;
389 389
390 int type; 390 unsigned long type;
391 struct platform_device *battery; /* battery control (not fuel gauge) */ 391 struct platform_device *battery; /* battery control (not fuel gauge) */
392 392
393 int irq; 393 int irq;
diff --git a/include/linux/mfd/max8998-private.h b/include/linux/mfd/max8998-private.h
index 4ecb24b4b863..d68ada502ff3 100644
--- a/include/linux/mfd/max8998-private.h
+++ b/include/linux/mfd/max8998-private.h
@@ -163,7 +163,7 @@ struct max8998_dev {
163 int ono; 163 int ono;
164 u8 irq_masks_cur[MAX8998_NUM_IRQ_REGS]; 164 u8 irq_masks_cur[MAX8998_NUM_IRQ_REGS];
165 u8 irq_masks_cache[MAX8998_NUM_IRQ_REGS]; 165 u8 irq_masks_cache[MAX8998_NUM_IRQ_REGS];
166 int type; 166 unsigned long type;
167 bool wakeup; 167 bool wakeup;
168}; 168};
169 169
diff --git a/include/linux/mfd/tps65217.h b/include/linux/mfd/tps65217.h
index a5a7f0130e96..54b5458ec084 100644
--- a/include/linux/mfd/tps65217.h
+++ b/include/linux/mfd/tps65217.h
@@ -252,7 +252,7 @@ struct tps65217_board {
252struct tps65217 { 252struct tps65217 {
253 struct device *dev; 253 struct device *dev;
254 struct tps65217_board *pdata; 254 struct tps65217_board *pdata;
255 unsigned int id; 255 unsigned long id;
256 struct regulator_desc desc[TPS65217_NUM_REGULATOR]; 256 struct regulator_desc desc[TPS65217_NUM_REGULATOR];
257 struct regulator_dev *rdev[TPS65217_NUM_REGULATOR]; 257 struct regulator_dev *rdev[TPS65217_NUM_REGULATOR];
258 struct regmap *regmap; 258 struct regmap *regmap;
@@ -263,7 +263,7 @@ static inline struct tps65217 *dev_to_tps65217(struct device *dev)
263 return dev_get_drvdata(dev); 263 return dev_get_drvdata(dev);
264} 264}
265 265
266static inline int tps65217_chip_id(struct tps65217 *tps65217) 266static inline unsigned long tps65217_chip_id(struct tps65217 *tps65217)
267{ 267{
268 return tps65217->id; 268 return tps65217->id;
269} 269}
diff --git a/include/linux/mm.h b/include/linux/mm.h
index f28f46eade6a..c1b7414c7bef 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -175,7 +175,7 @@ extern unsigned int kobjsize(const void *objp);
175 * Special vmas that are non-mergable, non-mlock()able. 175 * Special vmas that are non-mergable, non-mlock()able.
176 * Note: mm/huge_memory.c VM_NO_THP depends on this definition. 176 * Note: mm/huge_memory.c VM_NO_THP depends on this definition.
177 */ 177 */
178#define VM_SPECIAL (VM_IO | VM_DONTEXPAND | VM_PFNMAP) 178#define VM_SPECIAL (VM_IO | VM_DONTEXPAND | VM_PFNMAP | VM_MIXEDMAP)
179 179
180/* 180/*
181 * mapping from the currently active vm_flags protection bits (the 181 * mapping from the currently active vm_flags protection bits (the
@@ -399,8 +399,18 @@ static inline void compound_unlock_irqrestore(struct page *page,
399 399
400static inline struct page *compound_head(struct page *page) 400static inline struct page *compound_head(struct page *page)
401{ 401{
402 if (unlikely(PageTail(page))) 402 if (unlikely(PageTail(page))) {
403 return page->first_page; 403 struct page *head = page->first_page;
404
405 /*
406 * page->first_page may be a dangling pointer to an old
407 * compound page, so recheck that it is still a tail
408 * page before returning.
409 */
410 smp_rmb();
411 if (likely(PageTail(page)))
412 return head;
413 }
404 return page; 414 return page;
405} 415}
406 416
@@ -757,7 +767,7 @@ static inline bool __cpupid_match_pid(pid_t task_pid, int cpupid)
757#ifdef LAST_CPUPID_NOT_IN_PAGE_FLAGS 767#ifdef LAST_CPUPID_NOT_IN_PAGE_FLAGS
758static inline int page_cpupid_xchg_last(struct page *page, int cpupid) 768static inline int page_cpupid_xchg_last(struct page *page, int cpupid)
759{ 769{
760 return xchg(&page->_last_cpupid, cpupid); 770 return xchg(&page->_last_cpupid, cpupid & LAST_CPUPID_MASK);
761} 771}
762 772
763static inline int page_cpupid_last(struct page *page) 773static inline int page_cpupid_last(struct page *page)
@@ -766,7 +776,7 @@ static inline int page_cpupid_last(struct page *page)
766} 776}
767static inline void page_cpupid_reset_last(struct page *page) 777static inline void page_cpupid_reset_last(struct page *page)
768{ 778{
769 page->_last_cpupid = -1; 779 page->_last_cpupid = -1 & LAST_CPUPID_MASK;
770} 780}
771#else 781#else
772static inline int page_cpupid_last(struct page *page) 782static inline int page_cpupid_last(struct page *page)
diff --git a/include/linux/pci.h b/include/linux/pci.h
index fb57c892b214..33aa2caf0f0c 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1169,8 +1169,23 @@ void msi_remove_pci_irq_vectors(struct pci_dev *dev);
1169void pci_restore_msi_state(struct pci_dev *dev); 1169void pci_restore_msi_state(struct pci_dev *dev);
1170int pci_msi_enabled(void); 1170int pci_msi_enabled(void);
1171int pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec); 1171int pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec);
1172static inline int pci_enable_msi_exact(struct pci_dev *dev, int nvec)
1173{
1174 int rc = pci_enable_msi_range(dev, nvec, nvec);
1175 if (rc < 0)
1176 return rc;
1177 return 0;
1178}
1172int pci_enable_msix_range(struct pci_dev *dev, struct msix_entry *entries, 1179int pci_enable_msix_range(struct pci_dev *dev, struct msix_entry *entries,
1173 int minvec, int maxvec); 1180 int minvec, int maxvec);
1181static inline int pci_enable_msix_exact(struct pci_dev *dev,
1182 struct msix_entry *entries, int nvec)
1183{
1184 int rc = pci_enable_msix_range(dev, entries, nvec, nvec);
1185 if (rc < 0)
1186 return rc;
1187 return 0;
1188}
1174#else 1189#else
1175static inline int pci_msi_vec_count(struct pci_dev *dev) { return -ENOSYS; } 1190static inline int pci_msi_vec_count(struct pci_dev *dev) { return -ENOSYS; }
1176static inline int pci_enable_msi_block(struct pci_dev *dev, int nvec) 1191static inline int pci_enable_msi_block(struct pci_dev *dev, int nvec)
@@ -1189,9 +1204,14 @@ static inline int pci_msi_enabled(void) { return 0; }
1189static inline int pci_enable_msi_range(struct pci_dev *dev, int minvec, 1204static inline int pci_enable_msi_range(struct pci_dev *dev, int minvec,
1190 int maxvec) 1205 int maxvec)
1191{ return -ENOSYS; } 1206{ return -ENOSYS; }
1207static inline int pci_enable_msi_exact(struct pci_dev *dev, int nvec)
1208{ return -ENOSYS; }
1192static inline int pci_enable_msix_range(struct pci_dev *dev, 1209static inline int pci_enable_msix_range(struct pci_dev *dev,
1193 struct msix_entry *entries, int minvec, int maxvec) 1210 struct msix_entry *entries, int minvec, int maxvec)
1194{ return -ENOSYS; } 1211{ return -ENOSYS; }
1212static inline int pci_enable_msix_exact(struct pci_dev *dev,
1213 struct msix_entry *entries, int nvec)
1214{ return -ENOSYS; }
1195#endif 1215#endif
1196 1216
1197#ifdef CONFIG_PCIEPORTBUS 1217#ifdef CONFIG_PCIEPORTBUS
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 6d8ed22accb4..03db95ab8a8c 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -2782,7 +2782,7 @@ static inline void nf_reset(struct sk_buff *skb)
2782 2782
2783static inline void nf_reset_trace(struct sk_buff *skb) 2783static inline void nf_reset_trace(struct sk_buff *skb)
2784{ 2784{
2785#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE) 2785#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE) || defined(CONFIG_NF_TABLES)
2786 skb->nf_trace = 0; 2786 skb->nf_trace = 0;
2787#endif 2787#endif
2788} 2788}
@@ -2799,6 +2799,9 @@ static inline void __nf_copy(struct sk_buff *dst, const struct sk_buff *src)
2799 dst->nf_bridge = src->nf_bridge; 2799 dst->nf_bridge = src->nf_bridge;
2800 nf_bridge_get(src->nf_bridge); 2800 nf_bridge_get(src->nf_bridge);
2801#endif 2801#endif
2802#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE) || defined(CONFIG_NF_TABLES)
2803 dst->nf_trace = src->nf_trace;
2804#endif
2802} 2805}
2803 2806
2804static inline void nf_copy(struct sk_buff *dst, const struct sk_buff *src) 2807static inline void nf_copy(struct sk_buff *dst, const struct sk_buff *src)
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index 40ed9e9a77e5..a747a77ea584 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -281,13 +281,15 @@ asmlinkage long sys_sched_setscheduler(pid_t pid, int policy,
281asmlinkage long sys_sched_setparam(pid_t pid, 281asmlinkage long sys_sched_setparam(pid_t pid,
282 struct sched_param __user *param); 282 struct sched_param __user *param);
283asmlinkage long sys_sched_setattr(pid_t pid, 283asmlinkage long sys_sched_setattr(pid_t pid,
284 struct sched_attr __user *attr); 284 struct sched_attr __user *attr,
285 unsigned int flags);
285asmlinkage long sys_sched_getscheduler(pid_t pid); 286asmlinkage long sys_sched_getscheduler(pid_t pid);
286asmlinkage long sys_sched_getparam(pid_t pid, 287asmlinkage long sys_sched_getparam(pid_t pid,
287 struct sched_param __user *param); 288 struct sched_param __user *param);
288asmlinkage long sys_sched_getattr(pid_t pid, 289asmlinkage long sys_sched_getattr(pid_t pid,
289 struct sched_attr __user *attr, 290 struct sched_attr __user *attr,
290 unsigned int size); 291 unsigned int size,
292 unsigned int flags);
291asmlinkage long sys_sched_setaffinity(pid_t pid, unsigned int len, 293asmlinkage long sys_sched_setaffinity(pid_t pid, unsigned int len,
292 unsigned long __user *user_mask_ptr); 294 unsigned long __user *user_mask_ptr);
293asmlinkage long sys_sched_getaffinity(pid_t pid, unsigned int len, 295asmlinkage long sys_sched_getaffinity(pid_t pid, unsigned int len,
diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h
index 594521ba0d43..704f4f652d0a 100644
--- a/include/linux/workqueue.h
+++ b/include/linux/workqueue.h
@@ -419,10 +419,7 @@ __alloc_workqueue_key(const char *fmt, unsigned int flags, int max_active,
419 static struct lock_class_key __key; \ 419 static struct lock_class_key __key; \
420 const char *__lock_name; \ 420 const char *__lock_name; \
421 \ 421 \
422 if (__builtin_constant_p(fmt)) \ 422 __lock_name = #fmt#args; \
423 __lock_name = (fmt); \
424 else \
425 __lock_name = #fmt; \
426 \ 423 \
427 __alloc_workqueue_key((fmt), (flags), (max_active), \ 424 __alloc_workqueue_key((fmt), (flags), (max_active), \
428 &__key, __lock_name, ##args); \ 425 &__key, __lock_name, ##args); \
diff --git a/include/linux/writeback.h b/include/linux/writeback.h
index fc0e4320aa6d..021b8a319b9e 100644
--- a/include/linux/writeback.h
+++ b/include/linux/writeback.h
@@ -97,7 +97,7 @@ void writeback_inodes_sb_nr(struct super_block *, unsigned long nr,
97int try_to_writeback_inodes_sb(struct super_block *, enum wb_reason reason); 97int try_to_writeback_inodes_sb(struct super_block *, enum wb_reason reason);
98int try_to_writeback_inodes_sb_nr(struct super_block *, unsigned long nr, 98int try_to_writeback_inodes_sb_nr(struct super_block *, unsigned long nr,
99 enum wb_reason reason); 99 enum wb_reason reason);
100void sync_inodes_sb(struct super_block *sb, unsigned long older_than_this); 100void sync_inodes_sb(struct super_block *);
101void wakeup_flusher_threads(long nr_pages, enum wb_reason reason); 101void wakeup_flusher_threads(long nr_pages, enum wb_reason reason);
102void inode_wait_for_writeback(struct inode *inode); 102void inode_wait_for_writeback(struct inode *inode);
103 103
diff --git a/include/net/ip_tunnels.h b/include/net/ip_tunnels.h
index 48ed75c21260..e77c10405d51 100644
--- a/include/net/ip_tunnels.h
+++ b/include/net/ip_tunnels.h
@@ -129,6 +129,7 @@ int ip_tunnel_changelink(struct net_device *dev, struct nlattr *tb[],
129int ip_tunnel_newlink(struct net_device *dev, struct nlattr *tb[], 129int ip_tunnel_newlink(struct net_device *dev, struct nlattr *tb[],
130 struct ip_tunnel_parm *p); 130 struct ip_tunnel_parm *p);
131void ip_tunnel_setup(struct net_device *dev, int net_id); 131void ip_tunnel_setup(struct net_device *dev, int net_id);
132void ip_tunnel_dst_reset_all(struct ip_tunnel *t);
132 133
133/* Extract dsfield from inner protocol */ 134/* Extract dsfield from inner protocol */
134static inline u8 ip_tunnel_get_dsfield(const struct iphdr *iph, 135static inline u8 ip_tunnel_get_dsfield(const struct iphdr *iph,
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 93eab0b9da60..bb253b9b2f06 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -1304,7 +1304,8 @@ struct tcp_fastopen_request {
1304 /* Fast Open cookie. Size 0 means a cookie request */ 1304 /* Fast Open cookie. Size 0 means a cookie request */
1305 struct tcp_fastopen_cookie cookie; 1305 struct tcp_fastopen_cookie cookie;
1306 struct msghdr *data; /* data in MSG_FASTOPEN */ 1306 struct msghdr *data; /* data in MSG_FASTOPEN */
1307 u16 copied; /* queued in tcp_connect() */ 1307 size_t size;
1308 int copied; /* queued in tcp_connect() */
1308}; 1309};
1309void tcp_free_fastopen_req(struct tcp_sock *tp); 1310void tcp_free_fastopen_req(struct tcp_sock *tp);
1310 1311
diff --git a/include/net/xfrm.h b/include/net/xfrm.h
index 8b925288a8bc..23bfd4591e8b 100644
--- a/include/net/xfrm.h
+++ b/include/net/xfrm.h
@@ -1684,6 +1684,11 @@ static inline int xfrm_acquire_is_on(struct net *net)
1684} 1684}
1685#endif 1685#endif
1686 1686
1687static inline int aead_len(struct xfrm_algo_aead *alg)
1688{
1689 return sizeof(*alg) + ((alg->alg_key_len + 7) / 8);
1690}
1691
1687static inline int xfrm_alg_len(const struct xfrm_algo *alg) 1692static inline int xfrm_alg_len(const struct xfrm_algo *alg)
1688{ 1693{
1689 return sizeof(*alg) + ((alg->alg_key_len + 7) / 8); 1694 return sizeof(*alg) + ((alg->alg_key_len + 7) / 8);
@@ -1722,6 +1727,12 @@ static inline int xfrm_replay_clone(struct xfrm_state *x,
1722 return 0; 1727 return 0;
1723} 1728}
1724 1729
1730static inline struct xfrm_algo_aead *xfrm_algo_aead_clone(struct xfrm_algo_aead *orig)
1731{
1732 return kmemdup(orig, aead_len(orig), GFP_KERNEL);
1733}
1734
1735
1725static inline struct xfrm_algo *xfrm_algo_clone(struct xfrm_algo *orig) 1736static inline struct xfrm_algo *xfrm_algo_clone(struct xfrm_algo *orig)
1726{ 1737{
1727 return kmemdup(orig, xfrm_alg_len(orig), GFP_KERNEL); 1738 return kmemdup(orig, xfrm_alg_len(orig), GFP_KERNEL);
diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h
index 68d92e36facd..6e89ef6c11c1 100644
--- a/include/sound/soc-dapm.h
+++ b/include/sound/soc-dapm.h
@@ -449,14 +449,22 @@ void snd_soc_dapm_debugfs_init(struct snd_soc_dapm_context *dapm,
449/* dapm audio pin control and status */ 449/* dapm audio pin control and status */
450int snd_soc_dapm_enable_pin(struct snd_soc_dapm_context *dapm, 450int snd_soc_dapm_enable_pin(struct snd_soc_dapm_context *dapm,
451 const char *pin); 451 const char *pin);
452int snd_soc_dapm_enable_pin_unlocked(struct snd_soc_dapm_context *dapm,
453 const char *pin);
452int snd_soc_dapm_disable_pin(struct snd_soc_dapm_context *dapm, 454int snd_soc_dapm_disable_pin(struct snd_soc_dapm_context *dapm,
453 const char *pin); 455 const char *pin);
456int snd_soc_dapm_disable_pin_unlocked(struct snd_soc_dapm_context *dapm,
457 const char *pin);
454int snd_soc_dapm_nc_pin(struct snd_soc_dapm_context *dapm, const char *pin); 458int snd_soc_dapm_nc_pin(struct snd_soc_dapm_context *dapm, const char *pin);
459int snd_soc_dapm_nc_pin_unlocked(struct snd_soc_dapm_context *dapm,
460 const char *pin);
455int snd_soc_dapm_get_pin_status(struct snd_soc_dapm_context *dapm, 461int snd_soc_dapm_get_pin_status(struct snd_soc_dapm_context *dapm,
456 const char *pin); 462 const char *pin);
457int snd_soc_dapm_sync(struct snd_soc_dapm_context *dapm); 463int snd_soc_dapm_sync(struct snd_soc_dapm_context *dapm);
458int snd_soc_dapm_force_enable_pin(struct snd_soc_dapm_context *dapm, 464int snd_soc_dapm_force_enable_pin(struct snd_soc_dapm_context *dapm,
459 const char *pin); 465 const char *pin);
466int snd_soc_dapm_force_enable_pin_unlocked(struct snd_soc_dapm_context *dapm,
467 const char *pin);
460int snd_soc_dapm_ignore_suspend(struct snd_soc_dapm_context *dapm, 468int snd_soc_dapm_ignore_suspend(struct snd_soc_dapm_context *dapm,
461 const char *pin); 469 const char *pin);
462void snd_soc_dapm_auto_nc_codec_pins(struct snd_soc_codec *codec); 470void snd_soc_dapm_auto_nc_codec_pins(struct snd_soc_codec *codec);
diff --git a/include/trace/events/writeback.h b/include/trace/events/writeback.h
index c7bbbe794e65..464ea82e10db 100644
--- a/include/trace/events/writeback.h
+++ b/include/trace/events/writeback.h
@@ -287,11 +287,11 @@ TRACE_EVENT(writeback_queue_io,
287 __field(int, reason) 287 __field(int, reason)
288 ), 288 ),
289 TP_fast_assign( 289 TP_fast_assign(
290 unsigned long older_than_this = work->older_than_this; 290 unsigned long *older_than_this = work->older_than_this;
291 strncpy(__entry->name, dev_name(wb->bdi->dev), 32); 291 strncpy(__entry->name, dev_name(wb->bdi->dev), 32);
292 __entry->older = older_than_this; 292 __entry->older = older_than_this ? *older_than_this : 0;
293 __entry->age = older_than_this ? 293 __entry->age = older_than_this ?
294 (jiffies - older_than_this) * 1000 / HZ : -1; 294 (jiffies - *older_than_this) * 1000 / HZ : -1;
295 __entry->moved = moved; 295 __entry->moved = moved;
296 __entry->reason = work->reason; 296 __entry->reason = work->reason;
297 ), 297 ),
diff --git a/include/uapi/asm-generic/unistd.h b/include/uapi/asm-generic/unistd.h
index a20a9b4d3871..dde8041f40d2 100644
--- a/include/uapi/asm-generic/unistd.h
+++ b/include/uapi/asm-generic/unistd.h
@@ -692,9 +692,13 @@ __SC_COMP(__NR_process_vm_writev, sys_process_vm_writev, \
692__SYSCALL(__NR_kcmp, sys_kcmp) 692__SYSCALL(__NR_kcmp, sys_kcmp)
693#define __NR_finit_module 273 693#define __NR_finit_module 273
694__SYSCALL(__NR_finit_module, sys_finit_module) 694__SYSCALL(__NR_finit_module, sys_finit_module)
695#define __NR_sched_setattr 274
696__SYSCALL(__NR_sched_setattr, sys_sched_setattr)
697#define __NR_sched_getattr 275
698__SYSCALL(__NR_sched_getattr, sys_sched_getattr)
695 699
696#undef __NR_syscalls 700#undef __NR_syscalls
697#define __NR_syscalls 274 701#define __NR_syscalls 276
698 702
699/* 703/*
700 * All syscalls below here should go away really, 704 * All syscalls below here should go away really,
diff --git a/ipc/mq_sysctl.c b/ipc/mq_sysctl.c
index 383d638340b8..5bb8bfe67149 100644
--- a/ipc/mq_sysctl.c
+++ b/ipc/mq_sysctl.c
@@ -22,6 +22,16 @@ static void *get_mq(ctl_table *table)
22 return which; 22 return which;
23} 23}
24 24
25static int proc_mq_dointvec(ctl_table *table, int write,
26 void __user *buffer, size_t *lenp, loff_t *ppos)
27{
28 struct ctl_table mq_table;
29 memcpy(&mq_table, table, sizeof(mq_table));
30 mq_table.data = get_mq(table);
31
32 return proc_dointvec(&mq_table, write, buffer, lenp, ppos);
33}
34
25static int proc_mq_dointvec_minmax(ctl_table *table, int write, 35static int proc_mq_dointvec_minmax(ctl_table *table, int write,
26 void __user *buffer, size_t *lenp, loff_t *ppos) 36 void __user *buffer, size_t *lenp, loff_t *ppos)
27{ 37{
@@ -33,12 +43,10 @@ static int proc_mq_dointvec_minmax(ctl_table *table, int write,
33 lenp, ppos); 43 lenp, ppos);
34} 44}
35#else 45#else
46#define proc_mq_dointvec NULL
36#define proc_mq_dointvec_minmax NULL 47#define proc_mq_dointvec_minmax NULL
37#endif 48#endif
38 49
39static int msg_queues_limit_min = MIN_QUEUESMAX;
40static int msg_queues_limit_max = HARD_QUEUESMAX;
41
42static int msg_max_limit_min = MIN_MSGMAX; 50static int msg_max_limit_min = MIN_MSGMAX;
43static int msg_max_limit_max = HARD_MSGMAX; 51static int msg_max_limit_max = HARD_MSGMAX;
44 52
@@ -51,9 +59,7 @@ static ctl_table mq_sysctls[] = {
51 .data = &init_ipc_ns.mq_queues_max, 59 .data = &init_ipc_ns.mq_queues_max,
52 .maxlen = sizeof(int), 60 .maxlen = sizeof(int),
53 .mode = 0644, 61 .mode = 0644,
54 .proc_handler = proc_mq_dointvec_minmax, 62 .proc_handler = proc_mq_dointvec,
55 .extra1 = &msg_queues_limit_min,
56 .extra2 = &msg_queues_limit_max,
57 }, 63 },
58 { 64 {
59 .procname = "msg_max", 65 .procname = "msg_max",
diff --git a/ipc/mqueue.c b/ipc/mqueue.c
index ccf1f9fd263a..c3b31179122c 100644
--- a/ipc/mqueue.c
+++ b/ipc/mqueue.c
@@ -433,9 +433,9 @@ static int mqueue_create(struct inode *dir, struct dentry *dentry,
433 error = -EACCES; 433 error = -EACCES;
434 goto out_unlock; 434 goto out_unlock;
435 } 435 }
436 if (ipc_ns->mq_queues_count >= HARD_QUEUESMAX || 436
437 (ipc_ns->mq_queues_count >= ipc_ns->mq_queues_max && 437 if (ipc_ns->mq_queues_count >= ipc_ns->mq_queues_max &&
438 !capable(CAP_SYS_RESOURCE))) { 438 !capable(CAP_SYS_RESOURCE)) {
439 error = -ENOSPC; 439 error = -ENOSPC;
440 goto out_unlock; 440 goto out_unlock;
441 } 441 }
diff --git a/kernel/audit_tree.c b/kernel/audit_tree.c
index 67ccf0e7cca9..135944a7b28a 100644
--- a/kernel/audit_tree.c
+++ b/kernel/audit_tree.c
@@ -916,7 +916,7 @@ static int audit_tree_handle_event(struct fsnotify_group *group,
916 struct fsnotify_mark *inode_mark, 916 struct fsnotify_mark *inode_mark,
917 struct fsnotify_mark *vfsmount_mark, 917 struct fsnotify_mark *vfsmount_mark,
918 u32 mask, void *data, int data_type, 918 u32 mask, void *data, int data_type,
919 const unsigned char *file_name) 919 const unsigned char *file_name, u32 cookie)
920{ 920{
921 return 0; 921 return 0;
922} 922}
diff --git a/kernel/audit_watch.c b/kernel/audit_watch.c
index 2596fac5dcb4..70b4554d2fbe 100644
--- a/kernel/audit_watch.c
+++ b/kernel/audit_watch.c
@@ -471,7 +471,7 @@ static int audit_watch_handle_event(struct fsnotify_group *group,
471 struct fsnotify_mark *inode_mark, 471 struct fsnotify_mark *inode_mark,
472 struct fsnotify_mark *vfsmount_mark, 472 struct fsnotify_mark *vfsmount_mark,
473 u32 mask, void *data, int data_type, 473 u32 mask, void *data, int data_type,
474 const unsigned char *dname) 474 const unsigned char *dname, u32 cookie)
475{ 475{
476 struct inode *inode; 476 struct inode *inode;
477 struct audit_parent *parent; 477 struct audit_parent *parent;
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index e2f46ba37f72..105f273b6f86 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -886,7 +886,9 @@ static void cgroup_diput(struct dentry *dentry, struct inode *inode)
886 * per-subsystem and moved to css->id so that lookups are 886 * per-subsystem and moved to css->id so that lookups are
887 * successful until the target css is released. 887 * successful until the target css is released.
888 */ 888 */
889 mutex_lock(&cgroup_mutex);
889 idr_remove(&cgrp->root->cgroup_idr, cgrp->id); 890 idr_remove(&cgrp->root->cgroup_idr, cgrp->id);
891 mutex_unlock(&cgroup_mutex);
890 cgrp->id = -1; 892 cgrp->id = -1;
891 893
892 call_rcu(&cgrp->rcu_head, cgroup_free_rcu); 894 call_rcu(&cgrp->rcu_head, cgroup_free_rcu);
@@ -1566,10 +1568,10 @@ static struct dentry *cgroup_mount(struct file_system_type *fs_type,
1566 mutex_lock(&cgroup_mutex); 1568 mutex_lock(&cgroup_mutex);
1567 mutex_lock(&cgroup_root_mutex); 1569 mutex_lock(&cgroup_root_mutex);
1568 1570
1569 root_cgrp->id = idr_alloc(&root->cgroup_idr, root_cgrp, 1571 ret = idr_alloc(&root->cgroup_idr, root_cgrp, 0, 1, GFP_KERNEL);
1570 0, 1, GFP_KERNEL); 1572 if (ret < 0)
1571 if (root_cgrp->id < 0)
1572 goto unlock_drop; 1573 goto unlock_drop;
1574 root_cgrp->id = ret;
1573 1575
1574 /* Check for name clashes with existing mounts */ 1576 /* Check for name clashes with existing mounts */
1575 ret = -EBUSY; 1577 ret = -EBUSY;
@@ -2763,10 +2765,7 @@ static int cgroup_cfts_commit(struct cftype *cfts, bool is_add)
2763 */ 2765 */
2764 update_before = cgroup_serial_nr_next; 2766 update_before = cgroup_serial_nr_next;
2765 2767
2766 mutex_unlock(&cgroup_mutex);
2767
2768 /* add/rm files for all cgroups created before */ 2768 /* add/rm files for all cgroups created before */
2769 rcu_read_lock();
2770 css_for_each_descendant_pre(css, cgroup_css(root, ss)) { 2769 css_for_each_descendant_pre(css, cgroup_css(root, ss)) {
2771 struct cgroup *cgrp = css->cgroup; 2770 struct cgroup *cgrp = css->cgroup;
2772 2771
@@ -2775,23 +2774,19 @@ static int cgroup_cfts_commit(struct cftype *cfts, bool is_add)
2775 2774
2776 inode = cgrp->dentry->d_inode; 2775 inode = cgrp->dentry->d_inode;
2777 dget(cgrp->dentry); 2776 dget(cgrp->dentry);
2778 rcu_read_unlock();
2779
2780 dput(prev); 2777 dput(prev);
2781 prev = cgrp->dentry; 2778 prev = cgrp->dentry;
2782 2779
2780 mutex_unlock(&cgroup_mutex);
2783 mutex_lock(&inode->i_mutex); 2781 mutex_lock(&inode->i_mutex);
2784 mutex_lock(&cgroup_mutex); 2782 mutex_lock(&cgroup_mutex);
2785 if (cgrp->serial_nr < update_before && !cgroup_is_dead(cgrp)) 2783 if (cgrp->serial_nr < update_before && !cgroup_is_dead(cgrp))
2786 ret = cgroup_addrm_files(cgrp, cfts, is_add); 2784 ret = cgroup_addrm_files(cgrp, cfts, is_add);
2787 mutex_unlock(&cgroup_mutex);
2788 mutex_unlock(&inode->i_mutex); 2785 mutex_unlock(&inode->i_mutex);
2789
2790 rcu_read_lock();
2791 if (ret) 2786 if (ret)
2792 break; 2787 break;
2793 } 2788 }
2794 rcu_read_unlock(); 2789 mutex_unlock(&cgroup_mutex);
2795 dput(prev); 2790 dput(prev);
2796 deactivate_super(sb); 2791 deactivate_super(sb);
2797 return ret; 2792 return ret;
@@ -2910,9 +2905,14 @@ static void cgroup_enable_task_cg_lists(void)
2910 * We should check if the process is exiting, otherwise 2905 * We should check if the process is exiting, otherwise
2911 * it will race with cgroup_exit() in that the list 2906 * it will race with cgroup_exit() in that the list
2912 * entry won't be deleted though the process has exited. 2907 * entry won't be deleted though the process has exited.
2908 * Do it while holding siglock so that we don't end up
2909 * racing against cgroup_exit().
2913 */ 2910 */
2911 spin_lock_irq(&p->sighand->siglock);
2914 if (!(p->flags & PF_EXITING) && list_empty(&p->cg_list)) 2912 if (!(p->flags & PF_EXITING) && list_empty(&p->cg_list))
2915 list_add(&p->cg_list, &task_css_set(p)->tasks); 2913 list_add(&p->cg_list, &task_css_set(p)->tasks);
2914 spin_unlock_irq(&p->sighand->siglock);
2915
2916 task_unlock(p); 2916 task_unlock(p);
2917 } while_each_thread(g, p); 2917 } while_each_thread(g, p);
2918 read_unlock(&tasklist_lock); 2918 read_unlock(&tasklist_lock);
@@ -4158,7 +4158,7 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry,
4158 struct cgroup *cgrp; 4158 struct cgroup *cgrp;
4159 struct cgroup_name *name; 4159 struct cgroup_name *name;
4160 struct cgroupfs_root *root = parent->root; 4160 struct cgroupfs_root *root = parent->root;
4161 int ssid, err = 0; 4161 int ssid, err;
4162 struct cgroup_subsys *ss; 4162 struct cgroup_subsys *ss;
4163 struct super_block *sb = root->sb; 4163 struct super_block *sb = root->sb;
4164 4164
@@ -4168,19 +4168,13 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry,
4168 return -ENOMEM; 4168 return -ENOMEM;
4169 4169
4170 name = cgroup_alloc_name(dentry); 4170 name = cgroup_alloc_name(dentry);
4171 if (!name) 4171 if (!name) {
4172 err = -ENOMEM;
4172 goto err_free_cgrp; 4173 goto err_free_cgrp;
4174 }
4173 rcu_assign_pointer(cgrp->name, name); 4175 rcu_assign_pointer(cgrp->name, name);
4174 4176
4175 /* 4177 /*
4176 * Temporarily set the pointer to NULL, so idr_find() won't return
4177 * a half-baked cgroup.
4178 */
4179 cgrp->id = idr_alloc(&root->cgroup_idr, NULL, 1, 0, GFP_KERNEL);
4180 if (cgrp->id < 0)
4181 goto err_free_name;
4182
4183 /*
4184 * Only live parents can have children. Note that the liveliness 4178 * Only live parents can have children. Note that the liveliness
4185 * check isn't strictly necessary because cgroup_mkdir() and 4179 * check isn't strictly necessary because cgroup_mkdir() and
4186 * cgroup_rmdir() are fully synchronized by i_mutex; however, do it 4180 * cgroup_rmdir() are fully synchronized by i_mutex; however, do it
@@ -4189,7 +4183,17 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry,
4189 */ 4183 */
4190 if (!cgroup_lock_live_group(parent)) { 4184 if (!cgroup_lock_live_group(parent)) {
4191 err = -ENODEV; 4185 err = -ENODEV;
4192 goto err_free_id; 4186 goto err_free_name;
4187 }
4188
4189 /*
4190 * Temporarily set the pointer to NULL, so idr_find() won't return
4191 * a half-baked cgroup.
4192 */
4193 cgrp->id = idr_alloc(&root->cgroup_idr, NULL, 1, 0, GFP_KERNEL);
4194 if (cgrp->id < 0) {
4195 err = -ENOMEM;
4196 goto err_unlock;
4193 } 4197 }
4194 4198
4195 /* Grab a reference on the superblock so the hierarchy doesn't 4199 /* Grab a reference on the superblock so the hierarchy doesn't
@@ -4221,7 +4225,7 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry,
4221 */ 4225 */
4222 err = cgroup_create_file(dentry, S_IFDIR | mode, sb); 4226 err = cgroup_create_file(dentry, S_IFDIR | mode, sb);
4223 if (err < 0) 4227 if (err < 0)
4224 goto err_unlock; 4228 goto err_free_id;
4225 lockdep_assert_held(&dentry->d_inode->i_mutex); 4229 lockdep_assert_held(&dentry->d_inode->i_mutex);
4226 4230
4227 cgrp->serial_nr = cgroup_serial_nr_next++; 4231 cgrp->serial_nr = cgroup_serial_nr_next++;
@@ -4257,12 +4261,12 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry,
4257 4261
4258 return 0; 4262 return 0;
4259 4263
4260err_unlock:
4261 mutex_unlock(&cgroup_mutex);
4262 /* Release the reference count that we took on the superblock */
4263 deactivate_super(sb);
4264err_free_id: 4264err_free_id:
4265 idr_remove(&root->cgroup_idr, cgrp->id); 4265 idr_remove(&root->cgroup_idr, cgrp->id);
4266 /* Release the reference count that we took on the superblock */
4267 deactivate_super(sb);
4268err_unlock:
4269 mutex_unlock(&cgroup_mutex);
4266err_free_name: 4270err_free_name:
4267 kfree(rcu_dereference_raw(cgrp->name)); 4271 kfree(rcu_dereference_raw(cgrp->name));
4268err_free_cgrp: 4272err_free_cgrp:
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 56003c6edfd3..fa0b2d4ad83c 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -7856,14 +7856,14 @@ static void perf_pmu_rotate_stop(struct pmu *pmu)
7856static void __perf_event_exit_context(void *__info) 7856static void __perf_event_exit_context(void *__info)
7857{ 7857{
7858 struct perf_event_context *ctx = __info; 7858 struct perf_event_context *ctx = __info;
7859 struct perf_event *event, *tmp; 7859 struct perf_event *event;
7860 7860
7861 perf_pmu_rotate_stop(ctx->pmu); 7861 perf_pmu_rotate_stop(ctx->pmu);
7862 7862
7863 list_for_each_entry_safe(event, tmp, &ctx->pinned_groups, group_entry) 7863 rcu_read_lock();
7864 __perf_remove_from_context(event); 7864 list_for_each_entry_rcu(event, &ctx->event_list, event_entry)
7865 list_for_each_entry_safe(event, tmp, &ctx->flexible_groups, group_entry)
7866 __perf_remove_from_context(event); 7865 __perf_remove_from_context(event);
7866 rcu_read_unlock();
7867} 7867}
7868 7868
7869static void perf_event_exit_cpu_context(int cpu) 7869static void perf_event_exit_cpu_context(int cpu)
@@ -7887,11 +7887,11 @@ static void perf_event_exit_cpu(int cpu)
7887{ 7887{
7888 struct swevent_htable *swhash = &per_cpu(swevent_htable, cpu); 7888 struct swevent_htable *swhash = &per_cpu(swevent_htable, cpu);
7889 7889
7890 perf_event_exit_cpu_context(cpu);
7891
7890 mutex_lock(&swhash->hlist_mutex); 7892 mutex_lock(&swhash->hlist_mutex);
7891 swevent_hlist_release(swhash); 7893 swevent_hlist_release(swhash);
7892 mutex_unlock(&swhash->hlist_mutex); 7894 mutex_unlock(&swhash->hlist_mutex);
7893
7894 perf_event_exit_cpu_context(cpu);
7895} 7895}
7896#else 7896#else
7897static inline void perf_event_exit_cpu(int cpu) { } 7897static inline void perf_event_exit_cpu(int cpu) { }
diff --git a/kernel/power/console.c b/kernel/power/console.c
index eacb8bd8cab4..aba9c545a0e3 100644
--- a/kernel/power/console.c
+++ b/kernel/power/console.c
@@ -9,6 +9,7 @@
9#include <linux/kbd_kern.h> 9#include <linux/kbd_kern.h>
10#include <linux/vt.h> 10#include <linux/vt.h>
11#include <linux/module.h> 11#include <linux/module.h>
12#include <linux/slab.h>
12#include "power.h" 13#include "power.h"
13 14
14#define SUSPEND_CONSOLE (MAX_NR_CONSOLES-1) 15#define SUSPEND_CONSOLE (MAX_NR_CONSOLES-1)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index b46131ef6aab..6edbef296ece 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -1952,7 +1952,7 @@ static int dl_overflow(struct task_struct *p, int policy,
1952{ 1952{
1953 1953
1954 struct dl_bw *dl_b = dl_bw_of(task_cpu(p)); 1954 struct dl_bw *dl_b = dl_bw_of(task_cpu(p));
1955 u64 period = attr->sched_period; 1955 u64 period = attr->sched_period ?: attr->sched_deadline;
1956 u64 runtime = attr->sched_runtime; 1956 u64 runtime = attr->sched_runtime;
1957 u64 new_bw = dl_policy(policy) ? to_ratio(period, runtime) : 0; 1957 u64 new_bw = dl_policy(policy) ? to_ratio(period, runtime) : 0;
1958 int cpus, err = -1; 1958 int cpus, err = -1;
@@ -3661,13 +3661,14 @@ SYSCALL_DEFINE2(sched_setparam, pid_t, pid, struct sched_param __user *, param)
3661 * @pid: the pid in question. 3661 * @pid: the pid in question.
3662 * @uattr: structure containing the extended parameters. 3662 * @uattr: structure containing the extended parameters.
3663 */ 3663 */
3664SYSCALL_DEFINE2(sched_setattr, pid_t, pid, struct sched_attr __user *, uattr) 3664SYSCALL_DEFINE3(sched_setattr, pid_t, pid, struct sched_attr __user *, uattr,
3665 unsigned int, flags)
3665{ 3666{
3666 struct sched_attr attr; 3667 struct sched_attr attr;
3667 struct task_struct *p; 3668 struct task_struct *p;
3668 int retval; 3669 int retval;
3669 3670
3670 if (!uattr || pid < 0) 3671 if (!uattr || pid < 0 || flags)
3671 return -EINVAL; 3672 return -EINVAL;
3672 3673
3673 if (sched_copy_attr(uattr, &attr)) 3674 if (sched_copy_attr(uattr, &attr))
@@ -3786,7 +3787,7 @@ static int sched_read_attr(struct sched_attr __user *uattr,
3786 attr->size = usize; 3787 attr->size = usize;
3787 } 3788 }
3788 3789
3789 ret = copy_to_user(uattr, attr, usize); 3790 ret = copy_to_user(uattr, attr, attr->size);
3790 if (ret) 3791 if (ret)
3791 return -EFAULT; 3792 return -EFAULT;
3792 3793
@@ -3804,8 +3805,8 @@ err_size:
3804 * @uattr: structure containing the extended parameters. 3805 * @uattr: structure containing the extended parameters.
3805 * @size: sizeof(attr) for fwd/bwd comp. 3806 * @size: sizeof(attr) for fwd/bwd comp.
3806 */ 3807 */
3807SYSCALL_DEFINE3(sched_getattr, pid_t, pid, struct sched_attr __user *, uattr, 3808SYSCALL_DEFINE4(sched_getattr, pid_t, pid, struct sched_attr __user *, uattr,
3808 unsigned int, size) 3809 unsigned int, size, unsigned int, flags)
3809{ 3810{
3810 struct sched_attr attr = { 3811 struct sched_attr attr = {
3811 .size = sizeof(struct sched_attr), 3812 .size = sizeof(struct sched_attr),
@@ -3814,7 +3815,7 @@ SYSCALL_DEFINE3(sched_getattr, pid_t, pid, struct sched_attr __user *, uattr,
3814 int retval; 3815 int retval;
3815 3816
3816 if (!uattr || pid < 0 || size > PAGE_SIZE || 3817 if (!uattr || pid < 0 || size > PAGE_SIZE ||
3817 size < SCHED_ATTR_SIZE_VER0) 3818 size < SCHED_ATTR_SIZE_VER0 || flags)
3818 return -EINVAL; 3819 return -EINVAL;
3819 3820
3820 rcu_read_lock(); 3821 rcu_read_lock();
@@ -7422,6 +7423,7 @@ static int sched_dl_global_constraints(void)
7422 u64 period = global_rt_period(); 7423 u64 period = global_rt_period();
7423 u64 new_bw = to_ratio(period, runtime); 7424 u64 new_bw = to_ratio(period, runtime);
7424 int cpu, ret = 0; 7425 int cpu, ret = 0;
7426 unsigned long flags;
7425 7427
7426 /* 7428 /*
7427 * Here we want to check the bandwidth not being set to some 7429 * Here we want to check the bandwidth not being set to some
@@ -7435,10 +7437,10 @@ static int sched_dl_global_constraints(void)
7435 for_each_possible_cpu(cpu) { 7437 for_each_possible_cpu(cpu) {
7436 struct dl_bw *dl_b = dl_bw_of(cpu); 7438 struct dl_bw *dl_b = dl_bw_of(cpu);
7437 7439
7438 raw_spin_lock(&dl_b->lock); 7440 raw_spin_lock_irqsave(&dl_b->lock, flags);
7439 if (new_bw < dl_b->total_bw) 7441 if (new_bw < dl_b->total_bw)
7440 ret = -EBUSY; 7442 ret = -EBUSY;
7441 raw_spin_unlock(&dl_b->lock); 7443 raw_spin_unlock_irqrestore(&dl_b->lock, flags);
7442 7444
7443 if (ret) 7445 if (ret)
7444 break; 7446 break;
@@ -7451,6 +7453,7 @@ static void sched_dl_do_global(void)
7451{ 7453{
7452 u64 new_bw = -1; 7454 u64 new_bw = -1;
7453 int cpu; 7455 int cpu;
7456 unsigned long flags;
7454 7457
7455 def_dl_bandwidth.dl_period = global_rt_period(); 7458 def_dl_bandwidth.dl_period = global_rt_period();
7456 def_dl_bandwidth.dl_runtime = global_rt_runtime(); 7459 def_dl_bandwidth.dl_runtime = global_rt_runtime();
@@ -7464,9 +7467,9 @@ static void sched_dl_do_global(void)
7464 for_each_possible_cpu(cpu) { 7467 for_each_possible_cpu(cpu) {
7465 struct dl_bw *dl_b = dl_bw_of(cpu); 7468 struct dl_bw *dl_b = dl_bw_of(cpu);
7466 7469
7467 raw_spin_lock(&dl_b->lock); 7470 raw_spin_lock_irqsave(&dl_b->lock, flags);
7468 dl_b->bw = new_bw; 7471 dl_b->bw = new_bw;
7469 raw_spin_unlock(&dl_b->lock); 7472 raw_spin_unlock_irqrestore(&dl_b->lock, flags);
7470 } 7473 }
7471} 7474}
7472 7475
@@ -7475,7 +7478,8 @@ static int sched_rt_global_validate(void)
7475 if (sysctl_sched_rt_period <= 0) 7478 if (sysctl_sched_rt_period <= 0)
7476 return -EINVAL; 7479 return -EINVAL;
7477 7480
7478 if (sysctl_sched_rt_runtime > sysctl_sched_rt_period) 7481 if ((sysctl_sched_rt_runtime != RUNTIME_INF) &&
7482 (sysctl_sched_rt_runtime > sysctl_sched_rt_period))
7479 return -EINVAL; 7483 return -EINVAL;
7480 7484
7481 return 0; 7485 return 0;
diff --git a/kernel/sched/cpudeadline.c b/kernel/sched/cpudeadline.c
index 045fc74e3f09..5b9bb42b2d47 100644
--- a/kernel/sched/cpudeadline.c
+++ b/kernel/sched/cpudeadline.c
@@ -70,7 +70,7 @@ static void cpudl_heapify(struct cpudl *cp, int idx)
70 70
71static void cpudl_change_key(struct cpudl *cp, int idx, u64 new_dl) 71static void cpudl_change_key(struct cpudl *cp, int idx, u64 new_dl)
72{ 72{
73 WARN_ON(idx > num_present_cpus() || idx == IDX_INVALID); 73 WARN_ON(idx == IDX_INVALID || !cpu_present(idx));
74 74
75 if (dl_time_before(new_dl, cp->elements[idx].dl)) { 75 if (dl_time_before(new_dl, cp->elements[idx].dl)) {
76 cp->elements[idx].dl = new_dl; 76 cp->elements[idx].dl = new_dl;
@@ -117,7 +117,7 @@ int cpudl_find(struct cpudl *cp, struct task_struct *p,
117 } 117 }
118 118
119out: 119out:
120 WARN_ON(best_cpu > num_present_cpus() && best_cpu != -1); 120 WARN_ON(best_cpu != -1 && !cpu_present(best_cpu));
121 121
122 return best_cpu; 122 return best_cpu;
123} 123}
@@ -137,7 +137,7 @@ void cpudl_set(struct cpudl *cp, int cpu, u64 dl, int is_valid)
137 int old_idx, new_cpu; 137 int old_idx, new_cpu;
138 unsigned long flags; 138 unsigned long flags;
139 139
140 WARN_ON(cpu > num_present_cpus()); 140 WARN_ON(!cpu_present(cpu));
141 141
142 raw_spin_lock_irqsave(&cp->lock, flags); 142 raw_spin_lock_irqsave(&cp->lock, flags);
143 old_idx = cp->cpu_to_idx[cpu]; 143 old_idx = cp->cpu_to_idx[cpu];
diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
index 0dd5e0971a07..6e79b3faa4cd 100644
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -121,7 +121,7 @@ static inline void dl_clear_overload(struct rq *rq)
121 121
122static void update_dl_migration(struct dl_rq *dl_rq) 122static void update_dl_migration(struct dl_rq *dl_rq)
123{ 123{
124 if (dl_rq->dl_nr_migratory && dl_rq->dl_nr_total > 1) { 124 if (dl_rq->dl_nr_migratory && dl_rq->dl_nr_running > 1) {
125 if (!dl_rq->overloaded) { 125 if (!dl_rq->overloaded) {
126 dl_set_overload(rq_of_dl_rq(dl_rq)); 126 dl_set_overload(rq_of_dl_rq(dl_rq));
127 dl_rq->overloaded = 1; 127 dl_rq->overloaded = 1;
@@ -135,9 +135,7 @@ static void update_dl_migration(struct dl_rq *dl_rq)
135static void inc_dl_migration(struct sched_dl_entity *dl_se, struct dl_rq *dl_rq) 135static void inc_dl_migration(struct sched_dl_entity *dl_se, struct dl_rq *dl_rq)
136{ 136{
137 struct task_struct *p = dl_task_of(dl_se); 137 struct task_struct *p = dl_task_of(dl_se);
138 dl_rq = &rq_of_dl_rq(dl_rq)->dl;
139 138
140 dl_rq->dl_nr_total++;
141 if (p->nr_cpus_allowed > 1) 139 if (p->nr_cpus_allowed > 1)
142 dl_rq->dl_nr_migratory++; 140 dl_rq->dl_nr_migratory++;
143 141
@@ -147,9 +145,7 @@ static void inc_dl_migration(struct sched_dl_entity *dl_se, struct dl_rq *dl_rq)
147static void dec_dl_migration(struct sched_dl_entity *dl_se, struct dl_rq *dl_rq) 145static void dec_dl_migration(struct sched_dl_entity *dl_se, struct dl_rq *dl_rq)
148{ 146{
149 struct task_struct *p = dl_task_of(dl_se); 147 struct task_struct *p = dl_task_of(dl_se);
150 dl_rq = &rq_of_dl_rq(dl_rq)->dl;
151 148
152 dl_rq->dl_nr_total--;
153 if (p->nr_cpus_allowed > 1) 149 if (p->nr_cpus_allowed > 1)
154 dl_rq->dl_nr_migratory--; 150 dl_rq->dl_nr_migratory--;
155 151
@@ -566,6 +562,8 @@ int dl_runtime_exceeded(struct rq *rq, struct sched_dl_entity *dl_se)
566 return 1; 562 return 1;
567} 563}
568 564
565extern bool sched_rt_bandwidth_account(struct rt_rq *rt_rq);
566
569/* 567/*
570 * Update the current task's runtime statistics (provided it is still 568 * Update the current task's runtime statistics (provided it is still
571 * a -deadline task and has not been removed from the dl_rq). 569 * a -deadline task and has not been removed from the dl_rq).
@@ -629,11 +627,13 @@ static void update_curr_dl(struct rq *rq)
629 struct rt_rq *rt_rq = &rq->rt; 627 struct rt_rq *rt_rq = &rq->rt;
630 628
631 raw_spin_lock(&rt_rq->rt_runtime_lock); 629 raw_spin_lock(&rt_rq->rt_runtime_lock);
632 rt_rq->rt_time += delta_exec;
633 /* 630 /*
634 * We'll let actual RT tasks worry about the overflow here, we 631 * We'll let actual RT tasks worry about the overflow here, we
635 * have our own CBS to keep us inline -- see above. 632 * have our own CBS to keep us inline; only account when RT
633 * bandwidth is relevant.
636 */ 634 */
635 if (sched_rt_bandwidth_account(rt_rq))
636 rt_rq->rt_time += delta_exec;
637 raw_spin_unlock(&rt_rq->rt_runtime_lock); 637 raw_spin_unlock(&rt_rq->rt_runtime_lock);
638 } 638 }
639} 639}
@@ -717,6 +717,7 @@ void inc_dl_tasks(struct sched_dl_entity *dl_se, struct dl_rq *dl_rq)
717 717
718 WARN_ON(!dl_prio(prio)); 718 WARN_ON(!dl_prio(prio));
719 dl_rq->dl_nr_running++; 719 dl_rq->dl_nr_running++;
720 inc_nr_running(rq_of_dl_rq(dl_rq));
720 721
721 inc_dl_deadline(dl_rq, deadline); 722 inc_dl_deadline(dl_rq, deadline);
722 inc_dl_migration(dl_se, dl_rq); 723 inc_dl_migration(dl_se, dl_rq);
@@ -730,6 +731,7 @@ void dec_dl_tasks(struct sched_dl_entity *dl_se, struct dl_rq *dl_rq)
730 WARN_ON(!dl_prio(prio)); 731 WARN_ON(!dl_prio(prio));
731 WARN_ON(!dl_rq->dl_nr_running); 732 WARN_ON(!dl_rq->dl_nr_running);
732 dl_rq->dl_nr_running--; 733 dl_rq->dl_nr_running--;
734 dec_nr_running(rq_of_dl_rq(dl_rq));
733 735
734 dec_dl_deadline(dl_rq, dl_se->deadline); 736 dec_dl_deadline(dl_rq, dl_se->deadline);
735 dec_dl_migration(dl_se, dl_rq); 737 dec_dl_migration(dl_se, dl_rq);
@@ -836,8 +838,6 @@ static void enqueue_task_dl(struct rq *rq, struct task_struct *p, int flags)
836 838
837 if (!task_current(rq, p) && p->nr_cpus_allowed > 1) 839 if (!task_current(rq, p) && p->nr_cpus_allowed > 1)
838 enqueue_pushable_dl_task(rq, p); 840 enqueue_pushable_dl_task(rq, p);
839
840 inc_nr_running(rq);
841} 841}
842 842
843static void __dequeue_task_dl(struct rq *rq, struct task_struct *p, int flags) 843static void __dequeue_task_dl(struct rq *rq, struct task_struct *p, int flags)
@@ -850,8 +850,6 @@ static void dequeue_task_dl(struct rq *rq, struct task_struct *p, int flags)
850{ 850{
851 update_curr_dl(rq); 851 update_curr_dl(rq);
852 __dequeue_task_dl(rq, p, flags); 852 __dequeue_task_dl(rq, p, flags);
853
854 dec_nr_running(rq);
855} 853}
856 854
857/* 855/*
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 966cc2bfcb77..9b4c4f320130 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -1757,6 +1757,8 @@ void task_numa_work(struct callback_head *work)
1757 start = end; 1757 start = end;
1758 if (pages <= 0) 1758 if (pages <= 0)
1759 goto out; 1759 goto out;
1760
1761 cond_resched();
1760 } while (end != vma->vm_end); 1762 } while (end != vma->vm_end);
1761 } 1763 }
1762 1764
@@ -6999,15 +7001,15 @@ static void switched_from_fair(struct rq *rq, struct task_struct *p)
6999 struct cfs_rq *cfs_rq = cfs_rq_of(se); 7001 struct cfs_rq *cfs_rq = cfs_rq_of(se);
7000 7002
7001 /* 7003 /*
7002 * Ensure the task's vruntime is normalized, so that when its 7004 * Ensure the task's vruntime is normalized, so that when it's
7003 * switched back to the fair class the enqueue_entity(.flags=0) will 7005 * switched back to the fair class the enqueue_entity(.flags=0) will
7004 * do the right thing. 7006 * do the right thing.
7005 * 7007 *
7006 * If it was on_rq, then the dequeue_entity(.flags=0) will already 7008 * If it's on_rq, then the dequeue_entity(.flags=0) will already
7007 * have normalized the vruntime, if it was !on_rq, then only when 7009 * have normalized the vruntime, if it's !on_rq, then only when
7008 * the task is sleeping will it still have non-normalized vruntime. 7010 * the task is sleeping will it still have non-normalized vruntime.
7009 */ 7011 */
7010 if (!se->on_rq && p->state != TASK_RUNNING) { 7012 if (!p->on_rq && p->state != TASK_RUNNING) {
7011 /* 7013 /*
7012 * Fix up our vruntime so that the current sleep doesn't 7014 * Fix up our vruntime so that the current sleep doesn't
7013 * cause 'unlimited' sleep bonus. 7015 * cause 'unlimited' sleep bonus.
diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
index a2740b775b45..1999021042c7 100644
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -538,6 +538,14 @@ static inline struct rt_bandwidth *sched_rt_bandwidth(struct rt_rq *rt_rq)
538 538
539#endif /* CONFIG_RT_GROUP_SCHED */ 539#endif /* CONFIG_RT_GROUP_SCHED */
540 540
541bool sched_rt_bandwidth_account(struct rt_rq *rt_rq)
542{
543 struct rt_bandwidth *rt_b = sched_rt_bandwidth(rt_rq);
544
545 return (hrtimer_active(&rt_b->rt_period_timer) ||
546 rt_rq->rt_time < rt_b->rt_runtime);
547}
548
541#ifdef CONFIG_SMP 549#ifdef CONFIG_SMP
542/* 550/*
543 * We ran out of runtime, see if we can borrow some from our neighbours. 551 * We ran out of runtime, see if we can borrow some from our neighbours.
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index c2119fd20f8b..f964add50f38 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -462,7 +462,6 @@ struct dl_rq {
462 } earliest_dl; 462 } earliest_dl;
463 463
464 unsigned long dl_nr_migratory; 464 unsigned long dl_nr_migratory;
465 unsigned long dl_nr_total;
466 int overloaded; 465 int overloaded;
467 466
468 /* 467 /*
diff --git a/kernel/time/sched_clock.c b/kernel/time/sched_clock.c
index 0abb36464281..4d23dc4d8139 100644
--- a/kernel/time/sched_clock.c
+++ b/kernel/time/sched_clock.c
@@ -116,20 +116,42 @@ static enum hrtimer_restart sched_clock_poll(struct hrtimer *hrt)
116void __init sched_clock_register(u64 (*read)(void), int bits, 116void __init sched_clock_register(u64 (*read)(void), int bits,
117 unsigned long rate) 117 unsigned long rate)
118{ 118{
119 u64 res, wrap, new_mask, new_epoch, cyc, ns;
120 u32 new_mult, new_shift;
121 ktime_t new_wrap_kt;
119 unsigned long r; 122 unsigned long r;
120 u64 res, wrap;
121 char r_unit; 123 char r_unit;
122 124
123 if (cd.rate > rate) 125 if (cd.rate > rate)
124 return; 126 return;
125 127
126 WARN_ON(!irqs_disabled()); 128 WARN_ON(!irqs_disabled());
127 read_sched_clock = read;
128 sched_clock_mask = CLOCKSOURCE_MASK(bits);
129 cd.rate = rate;
130 129
131 /* calculate the mult/shift to convert counter ticks to ns. */ 130 /* calculate the mult/shift to convert counter ticks to ns. */
132 clocks_calc_mult_shift(&cd.mult, &cd.shift, rate, NSEC_PER_SEC, 3600); 131 clocks_calc_mult_shift(&new_mult, &new_shift, rate, NSEC_PER_SEC, 3600);
132
133 new_mask = CLOCKSOURCE_MASK(bits);
134
135 /* calculate how many ns until we wrap */
136 wrap = clocks_calc_max_nsecs(new_mult, new_shift, 0, new_mask);
137 new_wrap_kt = ns_to_ktime(wrap - (wrap >> 3));
138
139 /* update epoch for new counter and update epoch_ns from old counter*/
140 new_epoch = read();
141 cyc = read_sched_clock();
142 ns = cd.epoch_ns + cyc_to_ns((cyc - cd.epoch_cyc) & sched_clock_mask,
143 cd.mult, cd.shift);
144
145 raw_write_seqcount_begin(&cd.seq);
146 read_sched_clock = read;
147 sched_clock_mask = new_mask;
148 cd.rate = rate;
149 cd.wrap_kt = new_wrap_kt;
150 cd.mult = new_mult;
151 cd.shift = new_shift;
152 cd.epoch_cyc = new_epoch;
153 cd.epoch_ns = ns;
154 raw_write_seqcount_end(&cd.seq);
133 155
134 r = rate; 156 r = rate;
135 if (r >= 4000000) { 157 if (r >= 4000000) {
@@ -141,22 +163,12 @@ void __init sched_clock_register(u64 (*read)(void), int bits,
141 } else 163 } else
142 r_unit = ' '; 164 r_unit = ' ';
143 165
144 /* calculate how many ns until we wrap */
145 wrap = clocks_calc_max_nsecs(cd.mult, cd.shift, 0, sched_clock_mask);
146 cd.wrap_kt = ns_to_ktime(wrap - (wrap >> 3));
147
148 /* calculate the ns resolution of this counter */ 166 /* calculate the ns resolution of this counter */
149 res = cyc_to_ns(1ULL, cd.mult, cd.shift); 167 res = cyc_to_ns(1ULL, new_mult, new_shift);
168
150 pr_info("sched_clock: %u bits at %lu%cHz, resolution %lluns, wraps every %lluns\n", 169 pr_info("sched_clock: %u bits at %lu%cHz, resolution %lluns, wraps every %lluns\n",
151 bits, r, r_unit, res, wrap); 170 bits, r, r_unit, res, wrap);
152 171
153 update_sched_clock();
154
155 /*
156 * Ensure that sched_clock() starts off at 0ns
157 */
158 cd.epoch_ns = 0;
159
160 /* Enable IRQ time accounting if we have a fast enough sched_clock */ 172 /* Enable IRQ time accounting if we have a fast enough sched_clock */
161 if (irqtime > 0 || (irqtime == -1 && rate >= 1000000)) 173 if (irqtime > 0 || (irqtime == -1 && rate >= 1000000))
162 enable_sched_clock_irqtime(); 174 enable_sched_clock_irqtime();
diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
index 240fb62cf394..dd06439b9c84 100644
--- a/kernel/user_namespace.c
+++ b/kernel/user_namespace.c
@@ -225,7 +225,7 @@ static u32 map_id_up(struct uid_gid_map *map, u32 id)
225 * 225 *
226 * When there is no mapping defined for the user-namespace uid 226 * When there is no mapping defined for the user-namespace uid
227 * pair INVALID_UID is returned. Callers are expected to test 227 * pair INVALID_UID is returned. Callers are expected to test
228 * for and handle handle INVALID_UID being returned. INVALID_UID 228 * for and handle INVALID_UID being returned. INVALID_UID
229 * may be tested for using uid_valid(). 229 * may be tested for using uid_valid().
230 */ 230 */
231kuid_t make_kuid(struct user_namespace *ns, uid_t uid) 231kuid_t make_kuid(struct user_namespace *ns, uid_t uid)
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 82ef9f3b7473..193e977a10ea 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -1851,6 +1851,12 @@ static void destroy_worker(struct worker *worker)
1851 if (worker->flags & WORKER_IDLE) 1851 if (worker->flags & WORKER_IDLE)
1852 pool->nr_idle--; 1852 pool->nr_idle--;
1853 1853
1854 /*
1855 * Once WORKER_DIE is set, the kworker may destroy itself at any
1856 * point. Pin to ensure the task stays until we're done with it.
1857 */
1858 get_task_struct(worker->task);
1859
1854 list_del_init(&worker->entry); 1860 list_del_init(&worker->entry);
1855 worker->flags |= WORKER_DIE; 1861 worker->flags |= WORKER_DIE;
1856 1862
@@ -1859,6 +1865,7 @@ static void destroy_worker(struct worker *worker)
1859 spin_unlock_irq(&pool->lock); 1865 spin_unlock_irq(&pool->lock);
1860 1866
1861 kthread_stop(worker->task); 1867 kthread_stop(worker->task);
1868 put_task_struct(worker->task);
1862 kfree(worker); 1869 kfree(worker);
1863 1870
1864 spin_lock_irq(&pool->lock); 1871 spin_lock_irq(&pool->lock);
diff --git a/lib/dma-debug.c b/lib/dma-debug.c
index 2defd1308b04..98f2d7e91a91 100644
--- a/lib/dma-debug.c
+++ b/lib/dma-debug.c
@@ -424,111 +424,134 @@ void debug_dma_dump_mappings(struct device *dev)
424EXPORT_SYMBOL(debug_dma_dump_mappings); 424EXPORT_SYMBOL(debug_dma_dump_mappings);
425 425
426/* 426/*
427 * For each page mapped (initial page in the case of 427 * For each mapping (initial cacheline in the case of
428 * dma_alloc_coherent/dma_map_{single|page}, or each page in a 428 * dma_alloc_coherent/dma_map_page, initial cacheline in each page of a
429 * scatterlist) insert into this tree using the pfn as the key. At 429 * scatterlist, or the cacheline specified in dma_map_single) insert
430 * into this tree using the cacheline as the key. At
430 * dma_unmap_{single|sg|page} or dma_free_coherent delete the entry. If 431 * dma_unmap_{single|sg|page} or dma_free_coherent delete the entry. If
431 * the pfn already exists at insertion time add a tag as a reference 432 * the entry already exists at insertion time add a tag as a reference
432 * count for the overlapping mappings. For now, the overlap tracking 433 * count for the overlapping mappings. For now, the overlap tracking
433 * just ensures that 'unmaps' balance 'maps' before marking the pfn 434 * just ensures that 'unmaps' balance 'maps' before marking the
434 * idle, but we should also be flagging overlaps as an API violation. 435 * cacheline idle, but we should also be flagging overlaps as an API
436 * violation.
435 * 437 *
436 * Memory usage is mostly constrained by the maximum number of available 438 * Memory usage is mostly constrained by the maximum number of available
437 * dma-debug entries in that we need a free dma_debug_entry before 439 * dma-debug entries in that we need a free dma_debug_entry before
438 * inserting into the tree. In the case of dma_map_{single|page} and 440 * inserting into the tree. In the case of dma_map_page and
439 * dma_alloc_coherent there is only one dma_debug_entry and one pfn to 441 * dma_alloc_coherent there is only one dma_debug_entry and one
440 * track per event. dma_map_sg(), on the other hand, 442 * dma_active_cacheline entry to track per event. dma_map_sg(), on the
441 * consumes a single dma_debug_entry, but inserts 'nents' entries into 443 * other hand, consumes a single dma_debug_entry, but inserts 'nents'
442 * the tree. 444 * entries into the tree.
443 * 445 *
444 * At any time debug_dma_assert_idle() can be called to trigger a 446 * At any time debug_dma_assert_idle() can be called to trigger a
445 * warning if the given page is in the active set. 447 * warning if any cachelines in the given page are in the active set.
446 */ 448 */
447static RADIX_TREE(dma_active_pfn, GFP_NOWAIT); 449static RADIX_TREE(dma_active_cacheline, GFP_NOWAIT);
448static DEFINE_SPINLOCK(radix_lock); 450static DEFINE_SPINLOCK(radix_lock);
449#define ACTIVE_PFN_MAX_OVERLAP ((1 << RADIX_TREE_MAX_TAGS) - 1) 451#define ACTIVE_CACHELINE_MAX_OVERLAP ((1 << RADIX_TREE_MAX_TAGS) - 1)
452#define CACHELINE_PER_PAGE_SHIFT (PAGE_SHIFT - L1_CACHE_SHIFT)
453#define CACHELINES_PER_PAGE (1 << CACHELINE_PER_PAGE_SHIFT)
450 454
451static int active_pfn_read_overlap(unsigned long pfn) 455static phys_addr_t to_cacheline_number(struct dma_debug_entry *entry)
456{
457 return (entry->pfn << CACHELINE_PER_PAGE_SHIFT) +
458 (entry->offset >> L1_CACHE_SHIFT);
459}
460
461static int active_cacheline_read_overlap(phys_addr_t cln)
452{ 462{
453 int overlap = 0, i; 463 int overlap = 0, i;
454 464
455 for (i = RADIX_TREE_MAX_TAGS - 1; i >= 0; i--) 465 for (i = RADIX_TREE_MAX_TAGS - 1; i >= 0; i--)
456 if (radix_tree_tag_get(&dma_active_pfn, pfn, i)) 466 if (radix_tree_tag_get(&dma_active_cacheline, cln, i))
457 overlap |= 1 << i; 467 overlap |= 1 << i;
458 return overlap; 468 return overlap;
459} 469}
460 470
461static int active_pfn_set_overlap(unsigned long pfn, int overlap) 471static int active_cacheline_set_overlap(phys_addr_t cln, int overlap)
462{ 472{
463 int i; 473 int i;
464 474
465 if (overlap > ACTIVE_PFN_MAX_OVERLAP || overlap < 0) 475 if (overlap > ACTIVE_CACHELINE_MAX_OVERLAP || overlap < 0)
466 return overlap; 476 return overlap;
467 477
468 for (i = RADIX_TREE_MAX_TAGS - 1; i >= 0; i--) 478 for (i = RADIX_TREE_MAX_TAGS - 1; i >= 0; i--)
469 if (overlap & 1 << i) 479 if (overlap & 1 << i)
470 radix_tree_tag_set(&dma_active_pfn, pfn, i); 480 radix_tree_tag_set(&dma_active_cacheline, cln, i);
471 else 481 else
472 radix_tree_tag_clear(&dma_active_pfn, pfn, i); 482 radix_tree_tag_clear(&dma_active_cacheline, cln, i);
473 483
474 return overlap; 484 return overlap;
475} 485}
476 486
477static void active_pfn_inc_overlap(unsigned long pfn) 487static void active_cacheline_inc_overlap(phys_addr_t cln)
478{ 488{
479 int overlap = active_pfn_read_overlap(pfn); 489 int overlap = active_cacheline_read_overlap(cln);
480 490
481 overlap = active_pfn_set_overlap(pfn, ++overlap); 491 overlap = active_cacheline_set_overlap(cln, ++overlap);
482 492
483 /* If we overflowed the overlap counter then we're potentially 493 /* If we overflowed the overlap counter then we're potentially
484 * leaking dma-mappings. Otherwise, if maps and unmaps are 494 * leaking dma-mappings. Otherwise, if maps and unmaps are
485 * balanced then this overflow may cause false negatives in 495 * balanced then this overflow may cause false negatives in
486 * debug_dma_assert_idle() as the pfn may be marked idle 496 * debug_dma_assert_idle() as the cacheline may be marked idle
487 * prematurely. 497 * prematurely.
488 */ 498 */
489 WARN_ONCE(overlap > ACTIVE_PFN_MAX_OVERLAP, 499 WARN_ONCE(overlap > ACTIVE_CACHELINE_MAX_OVERLAP,
490 "DMA-API: exceeded %d overlapping mappings of pfn %lx\n", 500 "DMA-API: exceeded %d overlapping mappings of cacheline %pa\n",
491 ACTIVE_PFN_MAX_OVERLAP, pfn); 501 ACTIVE_CACHELINE_MAX_OVERLAP, &cln);
492} 502}
493 503
494static int active_pfn_dec_overlap(unsigned long pfn) 504static int active_cacheline_dec_overlap(phys_addr_t cln)
495{ 505{
496 int overlap = active_pfn_read_overlap(pfn); 506 int overlap = active_cacheline_read_overlap(cln);
497 507
498 return active_pfn_set_overlap(pfn, --overlap); 508 return active_cacheline_set_overlap(cln, --overlap);
499} 509}
500 510
501static int active_pfn_insert(struct dma_debug_entry *entry) 511static int active_cacheline_insert(struct dma_debug_entry *entry)
502{ 512{
513 phys_addr_t cln = to_cacheline_number(entry);
503 unsigned long flags; 514 unsigned long flags;
504 int rc; 515 int rc;
505 516
517 /* If the device is not writing memory then we don't have any
518 * concerns about the cpu consuming stale data. This mitigates
519 * legitimate usages of overlapping mappings.
520 */
521 if (entry->direction == DMA_TO_DEVICE)
522 return 0;
523
506 spin_lock_irqsave(&radix_lock, flags); 524 spin_lock_irqsave(&radix_lock, flags);
507 rc = radix_tree_insert(&dma_active_pfn, entry->pfn, entry); 525 rc = radix_tree_insert(&dma_active_cacheline, cln, entry);
508 if (rc == -EEXIST) 526 if (rc == -EEXIST)
509 active_pfn_inc_overlap(entry->pfn); 527 active_cacheline_inc_overlap(cln);
510 spin_unlock_irqrestore(&radix_lock, flags); 528 spin_unlock_irqrestore(&radix_lock, flags);
511 529
512 return rc; 530 return rc;
513} 531}
514 532
515static void active_pfn_remove(struct dma_debug_entry *entry) 533static void active_cacheline_remove(struct dma_debug_entry *entry)
516{ 534{
535 phys_addr_t cln = to_cacheline_number(entry);
517 unsigned long flags; 536 unsigned long flags;
518 537
538 /* ...mirror the insert case */
539 if (entry->direction == DMA_TO_DEVICE)
540 return;
541
519 spin_lock_irqsave(&radix_lock, flags); 542 spin_lock_irqsave(&radix_lock, flags);
520 /* since we are counting overlaps the final put of the 543 /* since we are counting overlaps the final put of the
521 * entry->pfn will occur when the overlap count is 0. 544 * cacheline will occur when the overlap count is 0.
522 * active_pfn_dec_overlap() returns -1 in that case 545 * active_cacheline_dec_overlap() returns -1 in that case
523 */ 546 */
524 if (active_pfn_dec_overlap(entry->pfn) < 0) 547 if (active_cacheline_dec_overlap(cln) < 0)
525 radix_tree_delete(&dma_active_pfn, entry->pfn); 548 radix_tree_delete(&dma_active_cacheline, cln);
526 spin_unlock_irqrestore(&radix_lock, flags); 549 spin_unlock_irqrestore(&radix_lock, flags);
527} 550}
528 551
529/** 552/**
530 * debug_dma_assert_idle() - assert that a page is not undergoing dma 553 * debug_dma_assert_idle() - assert that a page is not undergoing dma
531 * @page: page to lookup in the dma_active_pfn tree 554 * @page: page to lookup in the dma_active_cacheline tree
532 * 555 *
533 * Place a call to this routine in cases where the cpu touching the page 556 * Place a call to this routine in cases where the cpu touching the page
534 * before the dma completes (page is dma_unmapped) will lead to data 557 * before the dma completes (page is dma_unmapped) will lead to data
@@ -536,22 +559,38 @@ static void active_pfn_remove(struct dma_debug_entry *entry)
536 */ 559 */
537void debug_dma_assert_idle(struct page *page) 560void debug_dma_assert_idle(struct page *page)
538{ 561{
562 static struct dma_debug_entry *ents[CACHELINES_PER_PAGE];
563 struct dma_debug_entry *entry = NULL;
564 void **results = (void **) &ents;
565 unsigned int nents, i;
539 unsigned long flags; 566 unsigned long flags;
540 struct dma_debug_entry *entry; 567 phys_addr_t cln;
541 568
542 if (!page) 569 if (!page)
543 return; 570 return;
544 571
572 cln = (phys_addr_t) page_to_pfn(page) << CACHELINE_PER_PAGE_SHIFT;
545 spin_lock_irqsave(&radix_lock, flags); 573 spin_lock_irqsave(&radix_lock, flags);
546 entry = radix_tree_lookup(&dma_active_pfn, page_to_pfn(page)); 574 nents = radix_tree_gang_lookup(&dma_active_cacheline, results, cln,
575 CACHELINES_PER_PAGE);
576 for (i = 0; i < nents; i++) {
577 phys_addr_t ent_cln = to_cacheline_number(ents[i]);
578
579 if (ent_cln == cln) {
580 entry = ents[i];
581 break;
582 } else if (ent_cln >= cln + CACHELINES_PER_PAGE)
583 break;
584 }
547 spin_unlock_irqrestore(&radix_lock, flags); 585 spin_unlock_irqrestore(&radix_lock, flags);
548 586
549 if (!entry) 587 if (!entry)
550 return; 588 return;
551 589
590 cln = to_cacheline_number(entry);
552 err_printk(entry->dev, entry, 591 err_printk(entry->dev, entry,
553 "DMA-API: cpu touching an active dma mapped page " 592 "DMA-API: cpu touching an active dma mapped cacheline [cln=%pa]\n",
554 "[pfn=0x%lx]\n", entry->pfn); 593 &cln);
555} 594}
556 595
557/* 596/*
@@ -568,9 +607,9 @@ static void add_dma_entry(struct dma_debug_entry *entry)
568 hash_bucket_add(bucket, entry); 607 hash_bucket_add(bucket, entry);
569 put_hash_bucket(bucket, &flags); 608 put_hash_bucket(bucket, &flags);
570 609
571 rc = active_pfn_insert(entry); 610 rc = active_cacheline_insert(entry);
572 if (rc == -ENOMEM) { 611 if (rc == -ENOMEM) {
573 pr_err("DMA-API: pfn tracking ENOMEM, dma-debug disabled\n"); 612 pr_err("DMA-API: cacheline tracking ENOMEM, dma-debug disabled\n");
574 global_disable = true; 613 global_disable = true;
575 } 614 }
576 615
@@ -631,7 +670,7 @@ static void dma_entry_free(struct dma_debug_entry *entry)
631{ 670{
632 unsigned long flags; 671 unsigned long flags;
633 672
634 active_pfn_remove(entry); 673 active_cacheline_remove(entry);
635 674
636 /* 675 /*
637 * add to beginning of the list - this way the entries are 676 * add to beginning of the list - this way the entries are
diff --git a/lib/radix-tree.c b/lib/radix-tree.c
index 7811ed3b4e70..bd4a8dfdf0b8 100644
--- a/lib/radix-tree.c
+++ b/lib/radix-tree.c
@@ -1253,8 +1253,10 @@ unsigned long radix_tree_locate_item(struct radix_tree_root *root, void *item)
1253 1253
1254 node = indirect_to_ptr(node); 1254 node = indirect_to_ptr(node);
1255 max_index = radix_tree_maxindex(node->height); 1255 max_index = radix_tree_maxindex(node->height);
1256 if (cur_index > max_index) 1256 if (cur_index > max_index) {
1257 rcu_read_unlock();
1257 break; 1258 break;
1259 }
1258 1260
1259 cur_index = __locate(node, item, cur_index, &found_index); 1261 cur_index = __locate(node, item, cur_index, &found_index);
1260 rcu_read_unlock(); 1262 rcu_read_unlock();
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index da23eb96779f..1546655a2d78 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -1166,8 +1166,10 @@ alloc:
1166 } else { 1166 } else {
1167 ret = do_huge_pmd_wp_page_fallback(mm, vma, address, 1167 ret = do_huge_pmd_wp_page_fallback(mm, vma, address,
1168 pmd, orig_pmd, page, haddr); 1168 pmd, orig_pmd, page, haddr);
1169 if (ret & VM_FAULT_OOM) 1169 if (ret & VM_FAULT_OOM) {
1170 split_huge_page(page); 1170 split_huge_page(page);
1171 ret |= VM_FAULT_FALLBACK;
1172 }
1171 put_page(page); 1173 put_page(page);
1172 } 1174 }
1173 count_vm_event(THP_FAULT_FALLBACK); 1175 count_vm_event(THP_FAULT_FALLBACK);
@@ -1179,9 +1181,10 @@ alloc:
1179 if (page) { 1181 if (page) {
1180 split_huge_page(page); 1182 split_huge_page(page);
1181 put_page(page); 1183 put_page(page);
1182 } 1184 } else
1185 split_huge_page_pmd(vma, address, pmd);
1186 ret |= VM_FAULT_FALLBACK;
1183 count_vm_event(THP_FAULT_FALLBACK); 1187 count_vm_event(THP_FAULT_FALLBACK);
1184 ret |= VM_FAULT_OOM;
1185 goto out; 1188 goto out;
1186 } 1189 }
1187 1190
@@ -1958,7 +1961,7 @@ out:
1958 return ret; 1961 return ret;
1959} 1962}
1960 1963
1961#define VM_NO_THP (VM_SPECIAL|VM_MIXEDMAP|VM_HUGETLB|VM_SHARED|VM_MAYSHARE) 1964#define VM_NO_THP (VM_SPECIAL | VM_HUGETLB | VM_SHARED | VM_MAYSHARE)
1962 1965
1963int hugepage_madvise(struct vm_area_struct *vma, 1966int hugepage_madvise(struct vm_area_struct *vma,
1964 unsigned long *vm_flags, int advice) 1967 unsigned long *vm_flags, int advice)
diff --git a/mm/ksm.c b/mm/ksm.c
index aa4c7c7250c1..68710e80994a 100644
--- a/mm/ksm.c
+++ b/mm/ksm.c
@@ -444,7 +444,7 @@ static void break_cow(struct rmap_item *rmap_item)
444static struct page *page_trans_compound_anon(struct page *page) 444static struct page *page_trans_compound_anon(struct page *page)
445{ 445{
446 if (PageTransCompound(page)) { 446 if (PageTransCompound(page)) {
447 struct page *head = compound_trans_head(page); 447 struct page *head = compound_head(page);
448 /* 448 /*
449 * head may actually be splitted and freed from under 449 * head may actually be splitted and freed from under
450 * us but it's ok here. 450 * us but it's ok here.
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 53385cd4e6f0..5b6b0039f725 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1127,8 +1127,8 @@ skip_node:
1127 * skipping css reference should be safe. 1127 * skipping css reference should be safe.
1128 */ 1128 */
1129 if (next_css) { 1129 if (next_css) {
1130 if ((next_css->flags & CSS_ONLINE) && 1130 if ((next_css == &root->css) ||
1131 (next_css == &root->css || css_tryget(next_css))) 1131 ((next_css->flags & CSS_ONLINE) && css_tryget(next_css)))
1132 return mem_cgroup_from_css(next_css); 1132 return mem_cgroup_from_css(next_css);
1133 1133
1134 prev_css = next_css; 1134 prev_css = next_css;
@@ -1687,7 +1687,7 @@ void mem_cgroup_print_oom_info(struct mem_cgroup *memcg, struct task_struct *p)
1687 * protects memcg_name and makes sure that parallel ooms do not 1687 * protects memcg_name and makes sure that parallel ooms do not
1688 * interleave 1688 * interleave
1689 */ 1689 */
1690 static DEFINE_SPINLOCK(oom_info_lock); 1690 static DEFINE_MUTEX(oom_info_lock);
1691 struct cgroup *task_cgrp; 1691 struct cgroup *task_cgrp;
1692 struct cgroup *mem_cgrp; 1692 struct cgroup *mem_cgrp;
1693 static char memcg_name[PATH_MAX]; 1693 static char memcg_name[PATH_MAX];
@@ -1698,7 +1698,7 @@ void mem_cgroup_print_oom_info(struct mem_cgroup *memcg, struct task_struct *p)
1698 if (!p) 1698 if (!p)
1699 return; 1699 return;
1700 1700
1701 spin_lock(&oom_info_lock); 1701 mutex_lock(&oom_info_lock);
1702 rcu_read_lock(); 1702 rcu_read_lock();
1703 1703
1704 mem_cgrp = memcg->css.cgroup; 1704 mem_cgrp = memcg->css.cgroup;
@@ -1767,7 +1767,7 @@ done:
1767 1767
1768 pr_cont("\n"); 1768 pr_cont("\n");
1769 } 1769 }
1770 spin_unlock(&oom_info_lock); 1770 mutex_unlock(&oom_info_lock);
1771} 1771}
1772 1772
1773/* 1773/*
@@ -6595,6 +6595,7 @@ static void mem_cgroup_css_offline(struct cgroup_subsys_state *css)
6595{ 6595{
6596 struct mem_cgroup *memcg = mem_cgroup_from_css(css); 6596 struct mem_cgroup *memcg = mem_cgroup_from_css(css);
6597 struct mem_cgroup_event *event, *tmp; 6597 struct mem_cgroup_event *event, *tmp;
6598 struct cgroup_subsys_state *iter;
6598 6599
6599 /* 6600 /*
6600 * Unregister events and notify userspace. 6601 * Unregister events and notify userspace.
@@ -6611,7 +6612,14 @@ static void mem_cgroup_css_offline(struct cgroup_subsys_state *css)
6611 kmem_cgroup_css_offline(memcg); 6612 kmem_cgroup_css_offline(memcg);
6612 6613
6613 mem_cgroup_invalidate_reclaim_iterators(memcg); 6614 mem_cgroup_invalidate_reclaim_iterators(memcg);
6614 mem_cgroup_reparent_charges(memcg); 6615
6616 /*
6617 * This requires that offlining is serialized. Right now that is
6618 * guaranteed because css_killed_work_fn() holds the cgroup_mutex.
6619 */
6620 css_for_each_descendant_post(iter, css)
6621 mem_cgroup_reparent_charges(mem_cgroup_from_css(iter));
6622
6615 mem_cgroup_destroy_all_caches(memcg); 6623 mem_cgroup_destroy_all_caches(memcg);
6616 vmpressure_cleanup(&memcg->vmpressure); 6624 vmpressure_cleanup(&memcg->vmpressure);
6617} 6625}
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 2f2f34a4e77d..90002ea43638 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -1651,7 +1651,7 @@ int soft_offline_page(struct page *page, int flags)
1651{ 1651{
1652 int ret; 1652 int ret;
1653 unsigned long pfn = page_to_pfn(page); 1653 unsigned long pfn = page_to_pfn(page);
1654 struct page *hpage = compound_trans_head(page); 1654 struct page *hpage = compound_head(page);
1655 1655
1656 if (PageHWPoison(page)) { 1656 if (PageHWPoison(page)) {
1657 pr_info("soft offline: %#lx page already poisoned\n", pfn); 1657 pr_info("soft offline: %#lx page already poisoned\n", pfn);
diff --git a/mm/memory.c b/mm/memory.c
index be6a0c0d4ae0..22dfa617bddb 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -3348,6 +3348,7 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
3348 if (ret & VM_FAULT_LOCKED) 3348 if (ret & VM_FAULT_LOCKED)
3349 unlock_page(vmf.page); 3349 unlock_page(vmf.page);
3350 ret = VM_FAULT_HWPOISON; 3350 ret = VM_FAULT_HWPOISON;
3351 page_cache_release(vmf.page);
3351 goto uncharge_out; 3352 goto uncharge_out;
3352 } 3353 }
3353 3354
@@ -3703,7 +3704,6 @@ static int __handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
3703 if (unlikely(is_vm_hugetlb_page(vma))) 3704 if (unlikely(is_vm_hugetlb_page(vma)))
3704 return hugetlb_fault(mm, vma, address, flags); 3705 return hugetlb_fault(mm, vma, address, flags);
3705 3706
3706retry:
3707 pgd = pgd_offset(mm, address); 3707 pgd = pgd_offset(mm, address);
3708 pud = pud_alloc(mm, pgd, address); 3708 pud = pud_alloc(mm, pgd, address);
3709 if (!pud) 3709 if (!pud)
@@ -3741,20 +3741,13 @@ retry:
3741 if (dirty && !pmd_write(orig_pmd)) { 3741 if (dirty && !pmd_write(orig_pmd)) {
3742 ret = do_huge_pmd_wp_page(mm, vma, address, pmd, 3742 ret = do_huge_pmd_wp_page(mm, vma, address, pmd,
3743 orig_pmd); 3743 orig_pmd);
3744 /* 3744 if (!(ret & VM_FAULT_FALLBACK))
3745 * If COW results in an oom, the huge pmd will 3745 return ret;
3746 * have been split, so retry the fault on the
3747 * pte for a smaller charge.
3748 */
3749 if (unlikely(ret & VM_FAULT_OOM))
3750 goto retry;
3751 return ret;
3752 } else { 3746 } else {
3753 huge_pmd_set_accessed(mm, vma, address, pmd, 3747 huge_pmd_set_accessed(mm, vma, address, pmd,
3754 orig_pmd, dirty); 3748 orig_pmd, dirty);
3749 return 0;
3755 } 3750 }
3756
3757 return 0;
3758 } 3751 }
3759 } 3752 }
3760 3753
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index e3758a09a009..3bac76ae4b30 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -369,9 +369,11 @@ void prep_compound_page(struct page *page, unsigned long order)
369 __SetPageHead(page); 369 __SetPageHead(page);
370 for (i = 1; i < nr_pages; i++) { 370 for (i = 1; i < nr_pages; i++) {
371 struct page *p = page + i; 371 struct page *p = page + i;
372 __SetPageTail(p);
373 set_page_count(p, 0); 372 set_page_count(p, 0);
374 p->first_page = page; 373 p->first_page = page;
374 /* Make sure p->first_page is always valid for PageTail() */
375 smp_wmb();
376 __SetPageTail(p);
375 } 377 }
376} 378}
377 379
@@ -1236,6 +1238,15 @@ void drain_zone_pages(struct zone *zone, struct per_cpu_pages *pcp)
1236 } 1238 }
1237 local_irq_restore(flags); 1239 local_irq_restore(flags);
1238} 1240}
1241static bool gfp_thisnode_allocation(gfp_t gfp_mask)
1242{
1243 return (gfp_mask & GFP_THISNODE) == GFP_THISNODE;
1244}
1245#else
1246static bool gfp_thisnode_allocation(gfp_t gfp_mask)
1247{
1248 return false;
1249}
1239#endif 1250#endif
1240 1251
1241/* 1252/*
@@ -1572,7 +1583,13 @@ again:
1572 get_pageblock_migratetype(page)); 1583 get_pageblock_migratetype(page));
1573 } 1584 }
1574 1585
1575 __mod_zone_page_state(zone, NR_ALLOC_BATCH, -(1 << order)); 1586 /*
1587 * NOTE: GFP_THISNODE allocations do not partake in the kswapd
1588 * aging protocol, so they can't be fair.
1589 */
1590 if (!gfp_thisnode_allocation(gfp_flags))
1591 __mod_zone_page_state(zone, NR_ALLOC_BATCH, -(1 << order));
1592
1576 __count_zone_vm_events(PGALLOC, zone, 1 << order); 1593 __count_zone_vm_events(PGALLOC, zone, 1 << order);
1577 zone_statistics(preferred_zone, zone, gfp_flags); 1594 zone_statistics(preferred_zone, zone, gfp_flags);
1578 local_irq_restore(flags); 1595 local_irq_restore(flags);
@@ -1944,8 +1961,12 @@ zonelist_scan:
1944 * ultimately fall back to remote zones that do not 1961 * ultimately fall back to remote zones that do not
1945 * partake in the fairness round-robin cycle of this 1962 * partake in the fairness round-robin cycle of this
1946 * zonelist. 1963 * zonelist.
1964 *
1965 * NOTE: GFP_THISNODE allocations do not partake in
1966 * the kswapd aging protocol, so they can't be fair.
1947 */ 1967 */
1948 if (alloc_flags & ALLOC_WMARK_LOW) { 1968 if ((alloc_flags & ALLOC_WMARK_LOW) &&
1969 !gfp_thisnode_allocation(gfp_mask)) {
1949 if (zone_page_state(zone, NR_ALLOC_BATCH) <= 0) 1970 if (zone_page_state(zone, NR_ALLOC_BATCH) <= 0)
1950 continue; 1971 continue;
1951 if (!zone_local(preferred_zone, zone)) 1972 if (!zone_local(preferred_zone, zone))
@@ -2501,8 +2522,7 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order,
2501 * allowed per node queues are empty and that nodes are 2522 * allowed per node queues are empty and that nodes are
2502 * over allocated. 2523 * over allocated.
2503 */ 2524 */
2504 if (IS_ENABLED(CONFIG_NUMA) && 2525 if (gfp_thisnode_allocation(gfp_mask))
2505 (gfp_mask & GFP_THISNODE) == GFP_THISNODE)
2506 goto nopage; 2526 goto nopage;
2507 2527
2508restart: 2528restart:
diff --git a/mm/swap.c b/mm/swap.c
index b31ba67d440a..0092097b3f4c 100644
--- a/mm/swap.c
+++ b/mm/swap.c
@@ -98,7 +98,7 @@ static void put_compound_page(struct page *page)
98 } 98 }
99 99
100 /* __split_huge_page_refcount can run under us */ 100 /* __split_huge_page_refcount can run under us */
101 page_head = compound_trans_head(page); 101 page_head = compound_head(page);
102 102
103 /* 103 /*
104 * THP can not break up slab pages so avoid taking 104 * THP can not break up slab pages so avoid taking
@@ -253,7 +253,7 @@ bool __get_page_tail(struct page *page)
253 */ 253 */
254 unsigned long flags; 254 unsigned long flags;
255 bool got; 255 bool got;
256 struct page *page_head = compound_trans_head(page); 256 struct page *page_head = compound_head(page);
257 257
258 /* Ref to put_compound_page() comment. */ 258 /* Ref to put_compound_page() comment. */
259 if (!__compound_tail_refcounted(page_head)) { 259 if (!__compound_tail_refcounted(page_head)) {
diff --git a/mm/vmpressure.c b/mm/vmpressure.c
index 196970a4541f..d4042e75f7c7 100644
--- a/mm/vmpressure.c
+++ b/mm/vmpressure.c
@@ -19,6 +19,7 @@
19#include <linux/mm.h> 19#include <linux/mm.h>
20#include <linux/vmstat.h> 20#include <linux/vmstat.h>
21#include <linux/eventfd.h> 21#include <linux/eventfd.h>
22#include <linux/slab.h>
22#include <linux/swap.h> 23#include <linux/swap.h>
23#include <linux/printk.h> 24#include <linux/printk.h>
24#include <linux/vmpressure.h> 25#include <linux/vmpressure.h>
diff --git a/net/can/raw.c b/net/can/raw.c
index 8be757cca2ec..081e81fd017f 100644
--- a/net/can/raw.c
+++ b/net/can/raw.c
@@ -121,13 +121,9 @@ static void raw_rcv(struct sk_buff *oskb, void *data)
121 if (!ro->recv_own_msgs && oskb->sk == sk) 121 if (!ro->recv_own_msgs && oskb->sk == sk)
122 return; 122 return;
123 123
124 /* do not pass frames with DLC > 8 to a legacy socket */ 124 /* do not pass non-CAN2.0 frames to a legacy socket */
125 if (!ro->fd_frames) { 125 if (!ro->fd_frames && oskb->len != CAN_MTU)
126 struct canfd_frame *cfd = (struct canfd_frame *)oskb->data; 126 return;
127
128 if (unlikely(cfd->len > CAN_MAX_DLEN))
129 return;
130 }
131 127
132 /* clone the given skb to be able to enqueue it into the rcv queue */ 128 /* clone the given skb to be able to enqueue it into the rcv queue */
133 skb = skb_clone(oskb, GFP_ATOMIC); 129 skb = skb_clone(oskb, GFP_ATOMIC);
@@ -738,9 +734,7 @@ static int raw_recvmsg(struct kiocb *iocb, struct socket *sock,
738 struct msghdr *msg, size_t size, int flags) 734 struct msghdr *msg, size_t size, int flags)
739{ 735{
740 struct sock *sk = sock->sk; 736 struct sock *sk = sock->sk;
741 struct raw_sock *ro = raw_sk(sk);
742 struct sk_buff *skb; 737 struct sk_buff *skb;
743 int rxmtu;
744 int err = 0; 738 int err = 0;
745 int noblock; 739 int noblock;
746 740
@@ -751,20 +745,10 @@ static int raw_recvmsg(struct kiocb *iocb, struct socket *sock,
751 if (!skb) 745 if (!skb)
752 return err; 746 return err;
753 747
754 /* 748 if (size < skb->len)
755 * when serving a legacy socket the DLC <= 8 is already checked inside
756 * raw_rcv(). Now check if we need to pass a canfd_frame to a legacy
757 * socket and cut the possible CANFD_MTU/CAN_MTU length to CAN_MTU
758 */
759 if (!ro->fd_frames)
760 rxmtu = CAN_MTU;
761 else
762 rxmtu = skb->len;
763
764 if (size < rxmtu)
765 msg->msg_flags |= MSG_TRUNC; 749 msg->msg_flags |= MSG_TRUNC;
766 else 750 else
767 size = rxmtu; 751 size = skb->len;
768 752
769 err = memcpy_toiovec(msg->msg_iov, skb->data, size); 753 err = memcpy_toiovec(msg->msg_iov, skb->data, size);
770 if (err < 0) { 754 if (err < 0) {
diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index fbde4e3ce802..8f8a96ef9f3f 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -766,9 +766,6 @@ static void neigh_periodic_work(struct work_struct *work)
766 nht = rcu_dereference_protected(tbl->nht, 766 nht = rcu_dereference_protected(tbl->nht,
767 lockdep_is_held(&tbl->lock)); 767 lockdep_is_held(&tbl->lock));
768 768
769 if (atomic_read(&tbl->entries) < tbl->gc_thresh1)
770 goto out;
771
772 /* 769 /*
773 * periodically recompute ReachableTime from random function 770 * periodically recompute ReachableTime from random function
774 */ 771 */
@@ -781,6 +778,9 @@ static void neigh_periodic_work(struct work_struct *work)
781 neigh_rand_reach_time(NEIGH_VAR(p, BASE_REACHABLE_TIME)); 778 neigh_rand_reach_time(NEIGH_VAR(p, BASE_REACHABLE_TIME));
782 } 779 }
783 780
781 if (atomic_read(&tbl->entries) < tbl->gc_thresh1)
782 goto out;
783
784 for (i = 0 ; i < (1 << nht->hash_shift); i++) { 784 for (i = 0 ; i < (1 << nht->hash_shift); i++) {
785 np = &nht->hash_buckets[i]; 785 np = &nht->hash_buckets[i];
786 786
@@ -3047,7 +3047,7 @@ int neigh_sysctl_register(struct net_device *dev, struct neigh_parms *p,
3047 if (!t) 3047 if (!t)
3048 goto err; 3048 goto err;
3049 3049
3050 for (i = 0; i < ARRAY_SIZE(t->neigh_vars); i++) { 3050 for (i = 0; i < NEIGH_VAR_GC_INTERVAL; i++) {
3051 t->neigh_vars[i].data += (long) p; 3051 t->neigh_vars[i].data += (long) p;
3052 t->neigh_vars[i].extra1 = dev; 3052 t->neigh_vars[i].extra1 = dev;
3053 t->neigh_vars[i].extra2 = p; 3053 t->neigh_vars[i].extra2 = p;
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index f28c37996aad..465a01c97c76 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -707,9 +707,6 @@ static void __copy_skb_header(struct sk_buff *new, const struct sk_buff *old)
707 new->mark = old->mark; 707 new->mark = old->mark;
708 new->skb_iif = old->skb_iif; 708 new->skb_iif = old->skb_iif;
709 __nf_copy(new, old); 709 __nf_copy(new, old);
710#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE)
711 new->nf_trace = old->nf_trace;
712#endif
713#ifdef CONFIG_NET_SCHED 710#ifdef CONFIG_NET_SCHED
714 new->tc_index = old->tc_index; 711 new->tc_index = old->tc_index;
715#ifdef CONFIG_NET_CLS_ACT 712#ifdef CONFIG_NET_CLS_ACT
diff --git a/net/hsr/hsr_framereg.c b/net/hsr/hsr_framereg.c
index 3d0100f0bae3..83e58449366a 100644
--- a/net/hsr/hsr_framereg.c
+++ b/net/hsr/hsr_framereg.c
@@ -297,7 +297,7 @@ static bool seq_nr_after(u16 a, u16 b)
297 297
298void hsr_register_frame_in(struct node_entry *node, enum hsr_dev_idx dev_idx) 298void hsr_register_frame_in(struct node_entry *node, enum hsr_dev_idx dev_idx)
299{ 299{
300 if ((dev_idx < 0) || (dev_idx >= HSR_MAX_DEV)) { 300 if ((dev_idx < 0) || (dev_idx >= HSR_MAX_SLAVE)) {
301 WARN_ONCE(1, "%s: Invalid dev_idx (%d)\n", __func__, dev_idx); 301 WARN_ONCE(1, "%s: Invalid dev_idx (%d)\n", __func__, dev_idx);
302 return; 302 return;
303 } 303 }
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index ecd2c3f245ce..19ab78aca547 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -1296,8 +1296,11 @@ static struct sk_buff *inet_gso_segment(struct sk_buff *skb,
1296 1296
1297 segs = ERR_PTR(-EPROTONOSUPPORT); 1297 segs = ERR_PTR(-EPROTONOSUPPORT);
1298 1298
1299 /* Note : following gso_segment() might change skb->encapsulation */ 1299 if (skb->encapsulation &&
1300 udpfrag = !skb->encapsulation && proto == IPPROTO_UDP; 1300 skb_shinfo(skb)->gso_type & (SKB_GSO_SIT|SKB_GSO_IPIP))
1301 udpfrag = proto == IPPROTO_UDP && encap;
1302 else
1303 udpfrag = proto == IPPROTO_UDP && !skb->encapsulation;
1301 1304
1302 ops = rcu_dereference(inet_offloads[proto]); 1305 ops = rcu_dereference(inet_offloads[proto]);
1303 if (likely(ops && ops->callbacks.gso_segment)) 1306 if (likely(ops && ops->callbacks.gso_segment))
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index e85445b2b102..1a0755fea491 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -422,9 +422,6 @@ static void ip_copy_metadata(struct sk_buff *to, struct sk_buff *from)
422 to->tc_index = from->tc_index; 422 to->tc_index = from->tc_index;
423#endif 423#endif
424 nf_copy(to, from); 424 nf_copy(to, from);
425#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE)
426 to->nf_trace = from->nf_trace;
427#endif
428#if defined(CONFIG_IP_VS) || defined(CONFIG_IP_VS_MODULE) 425#if defined(CONFIG_IP_VS) || defined(CONFIG_IP_VS_MODULE)
429 to->ipvs_property = from->ipvs_property; 426 to->ipvs_property = from->ipvs_property;
430#endif 427#endif
diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c
index 4fff64418fb2..66aaf506fbef 100644
--- a/net/ipv4/ip_tunnel.c
+++ b/net/ipv4/ip_tunnel.c
@@ -93,13 +93,14 @@ static void tunnel_dst_reset(struct ip_tunnel *t)
93 tunnel_dst_set(t, NULL); 93 tunnel_dst_set(t, NULL);
94} 94}
95 95
96static void tunnel_dst_reset_all(struct ip_tunnel *t) 96void ip_tunnel_dst_reset_all(struct ip_tunnel *t)
97{ 97{
98 int i; 98 int i;
99 99
100 for_each_possible_cpu(i) 100 for_each_possible_cpu(i)
101 __tunnel_dst_set(per_cpu_ptr(t->dst_cache, i), NULL); 101 __tunnel_dst_set(per_cpu_ptr(t->dst_cache, i), NULL);
102} 102}
103EXPORT_SYMBOL(ip_tunnel_dst_reset_all);
103 104
104static struct rtable *tunnel_rtable_get(struct ip_tunnel *t, u32 cookie) 105static struct rtable *tunnel_rtable_get(struct ip_tunnel *t, u32 cookie)
105{ 106{
@@ -119,52 +120,6 @@ static struct rtable *tunnel_rtable_get(struct ip_tunnel *t, u32 cookie)
119 return (struct rtable *)dst; 120 return (struct rtable *)dst;
120} 121}
121 122
122/* Often modified stats are per cpu, other are shared (netdev->stats) */
123struct rtnl_link_stats64 *ip_tunnel_get_stats64(struct net_device *dev,
124 struct rtnl_link_stats64 *tot)
125{
126 int i;
127
128 for_each_possible_cpu(i) {
129 const struct pcpu_sw_netstats *tstats =
130 per_cpu_ptr(dev->tstats, i);
131 u64 rx_packets, rx_bytes, tx_packets, tx_bytes;
132 unsigned int start;
133
134 do {
135 start = u64_stats_fetch_begin_bh(&tstats->syncp);
136 rx_packets = tstats->rx_packets;
137 tx_packets = tstats->tx_packets;
138 rx_bytes = tstats->rx_bytes;
139 tx_bytes = tstats->tx_bytes;
140 } while (u64_stats_fetch_retry_bh(&tstats->syncp, start));
141
142 tot->rx_packets += rx_packets;
143 tot->tx_packets += tx_packets;
144 tot->rx_bytes += rx_bytes;
145 tot->tx_bytes += tx_bytes;
146 }
147
148 tot->multicast = dev->stats.multicast;
149
150 tot->rx_crc_errors = dev->stats.rx_crc_errors;
151 tot->rx_fifo_errors = dev->stats.rx_fifo_errors;
152 tot->rx_length_errors = dev->stats.rx_length_errors;
153 tot->rx_frame_errors = dev->stats.rx_frame_errors;
154 tot->rx_errors = dev->stats.rx_errors;
155
156 tot->tx_fifo_errors = dev->stats.tx_fifo_errors;
157 tot->tx_carrier_errors = dev->stats.tx_carrier_errors;
158 tot->tx_dropped = dev->stats.tx_dropped;
159 tot->tx_aborted_errors = dev->stats.tx_aborted_errors;
160 tot->tx_errors = dev->stats.tx_errors;
161
162 tot->collisions = dev->stats.collisions;
163
164 return tot;
165}
166EXPORT_SYMBOL_GPL(ip_tunnel_get_stats64);
167
168static bool ip_tunnel_key_match(const struct ip_tunnel_parm *p, 123static bool ip_tunnel_key_match(const struct ip_tunnel_parm *p,
169 __be16 flags, __be32 key) 124 __be16 flags, __be32 key)
170{ 125{
@@ -763,7 +718,7 @@ static void ip_tunnel_update(struct ip_tunnel_net *itn,
763 if (set_mtu) 718 if (set_mtu)
764 dev->mtu = mtu; 719 dev->mtu = mtu;
765 } 720 }
766 tunnel_dst_reset_all(t); 721 ip_tunnel_dst_reset_all(t);
767 netdev_state_change(dev); 722 netdev_state_change(dev);
768} 723}
769 724
@@ -1091,7 +1046,7 @@ void ip_tunnel_uninit(struct net_device *dev)
1091 if (itn->fb_tunnel_dev != dev) 1046 if (itn->fb_tunnel_dev != dev)
1092 ip_tunnel_del(netdev_priv(dev)); 1047 ip_tunnel_del(netdev_priv(dev));
1093 1048
1094 tunnel_dst_reset_all(tunnel); 1049 ip_tunnel_dst_reset_all(tunnel);
1095} 1050}
1096EXPORT_SYMBOL_GPL(ip_tunnel_uninit); 1051EXPORT_SYMBOL_GPL(ip_tunnel_uninit);
1097 1052
diff --git a/net/ipv4/ip_tunnel_core.c b/net/ipv4/ip_tunnel_core.c
index 6156f4ef5e91..6f847dd56dbc 100644
--- a/net/ipv4/ip_tunnel_core.c
+++ b/net/ipv4/ip_tunnel_core.c
@@ -108,7 +108,6 @@ int iptunnel_pull_header(struct sk_buff *skb, int hdr_len, __be16 inner_proto)
108 nf_reset(skb); 108 nf_reset(skb);
109 secpath_reset(skb); 109 secpath_reset(skb);
110 skb_clear_hash_if_not_l4(skb); 110 skb_clear_hash_if_not_l4(skb);
111 skb_dst_drop(skb);
112 skb->vlan_tci = 0; 111 skb->vlan_tci = 0;
113 skb_set_queue_mapping(skb, 0); 112 skb_set_queue_mapping(skb, 0);
114 skb->pkt_type = PACKET_HOST; 113 skb->pkt_type = PACKET_HOST;
@@ -148,3 +147,49 @@ error:
148 return ERR_PTR(err); 147 return ERR_PTR(err);
149} 148}
150EXPORT_SYMBOL_GPL(iptunnel_handle_offloads); 149EXPORT_SYMBOL_GPL(iptunnel_handle_offloads);
150
151/* Often modified stats are per cpu, other are shared (netdev->stats) */
152struct rtnl_link_stats64 *ip_tunnel_get_stats64(struct net_device *dev,
153 struct rtnl_link_stats64 *tot)
154{
155 int i;
156
157 for_each_possible_cpu(i) {
158 const struct pcpu_sw_netstats *tstats =
159 per_cpu_ptr(dev->tstats, i);
160 u64 rx_packets, rx_bytes, tx_packets, tx_bytes;
161 unsigned int start;
162
163 do {
164 start = u64_stats_fetch_begin_bh(&tstats->syncp);
165 rx_packets = tstats->rx_packets;
166 tx_packets = tstats->tx_packets;
167 rx_bytes = tstats->rx_bytes;
168 tx_bytes = tstats->tx_bytes;
169 } while (u64_stats_fetch_retry_bh(&tstats->syncp, start));
170
171 tot->rx_packets += rx_packets;
172 tot->tx_packets += tx_packets;
173 tot->rx_bytes += rx_bytes;
174 tot->tx_bytes += tx_bytes;
175 }
176
177 tot->multicast = dev->stats.multicast;
178
179 tot->rx_crc_errors = dev->stats.rx_crc_errors;
180 tot->rx_fifo_errors = dev->stats.rx_fifo_errors;
181 tot->rx_length_errors = dev->stats.rx_length_errors;
182 tot->rx_frame_errors = dev->stats.rx_frame_errors;
183 tot->rx_errors = dev->stats.rx_errors;
184
185 tot->tx_fifo_errors = dev->stats.tx_fifo_errors;
186 tot->tx_carrier_errors = dev->stats.tx_carrier_errors;
187 tot->tx_dropped = dev->stats.tx_dropped;
188 tot->tx_aborted_errors = dev->stats.tx_aborted_errors;
189 tot->tx_errors = dev->stats.tx_errors;
190
191 tot->collisions = dev->stats.collisions;
192
193 return tot;
194}
195EXPORT_SYMBOL_GPL(ip_tunnel_get_stats64);
diff --git a/net/ipv4/netfilter/nf_nat_snmp_basic.c b/net/ipv4/netfilter/nf_nat_snmp_basic.c
index d551e31b416e..7c676671329d 100644
--- a/net/ipv4/netfilter/nf_nat_snmp_basic.c
+++ b/net/ipv4/netfilter/nf_nat_snmp_basic.c
@@ -1198,8 +1198,8 @@ static int snmp_translate(struct nf_conn *ct,
1198 map.to = NOCT1(&ct->tuplehash[!dir].tuple.dst.u3.ip); 1198 map.to = NOCT1(&ct->tuplehash[!dir].tuple.dst.u3.ip);
1199 } else { 1199 } else {
1200 /* DNAT replies */ 1200 /* DNAT replies */
1201 map.from = NOCT1(&ct->tuplehash[dir].tuple.src.u3.ip); 1201 map.from = NOCT1(&ct->tuplehash[!dir].tuple.src.u3.ip);
1202 map.to = NOCT1(&ct->tuplehash[!dir].tuple.dst.u3.ip); 1202 map.to = NOCT1(&ct->tuplehash[dir].tuple.dst.u3.ip);
1203 } 1203 }
1204 1204
1205 if (map.from == map.to) 1205 if (map.from == map.to)
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 7374905b3701..4bd6d52eeffb 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -1044,7 +1044,8 @@ void tcp_free_fastopen_req(struct tcp_sock *tp)
1044 } 1044 }
1045} 1045}
1046 1046
1047static int tcp_sendmsg_fastopen(struct sock *sk, struct msghdr *msg, int *size) 1047static int tcp_sendmsg_fastopen(struct sock *sk, struct msghdr *msg,
1048 int *copied, size_t size)
1048{ 1049{
1049 struct tcp_sock *tp = tcp_sk(sk); 1050 struct tcp_sock *tp = tcp_sk(sk);
1050 int err, flags; 1051 int err, flags;
@@ -1059,11 +1060,12 @@ static int tcp_sendmsg_fastopen(struct sock *sk, struct msghdr *msg, int *size)
1059 if (unlikely(tp->fastopen_req == NULL)) 1060 if (unlikely(tp->fastopen_req == NULL))
1060 return -ENOBUFS; 1061 return -ENOBUFS;
1061 tp->fastopen_req->data = msg; 1062 tp->fastopen_req->data = msg;
1063 tp->fastopen_req->size = size;
1062 1064
1063 flags = (msg->msg_flags & MSG_DONTWAIT) ? O_NONBLOCK : 0; 1065 flags = (msg->msg_flags & MSG_DONTWAIT) ? O_NONBLOCK : 0;
1064 err = __inet_stream_connect(sk->sk_socket, msg->msg_name, 1066 err = __inet_stream_connect(sk->sk_socket, msg->msg_name,
1065 msg->msg_namelen, flags); 1067 msg->msg_namelen, flags);
1066 *size = tp->fastopen_req->copied; 1068 *copied = tp->fastopen_req->copied;
1067 tcp_free_fastopen_req(tp); 1069 tcp_free_fastopen_req(tp);
1068 return err; 1070 return err;
1069} 1071}
@@ -1083,7 +1085,7 @@ int tcp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
1083 1085
1084 flags = msg->msg_flags; 1086 flags = msg->msg_flags;
1085 if (flags & MSG_FASTOPEN) { 1087 if (flags & MSG_FASTOPEN) {
1086 err = tcp_sendmsg_fastopen(sk, msg, &copied_syn); 1088 err = tcp_sendmsg_fastopen(sk, msg, &copied_syn, size);
1087 if (err == -EINPROGRESS && copied_syn > 0) 1089 if (err == -EINPROGRESS && copied_syn > 0)
1088 goto out; 1090 goto out;
1089 else if (err) 1091 else if (err)
diff --git a/net/ipv4/tcp_cong.c b/net/ipv4/tcp_cong.c
index f49351edf97d..2b9464c93b88 100644
--- a/net/ipv4/tcp_cong.c
+++ b/net/ipv4/tcp_cong.c
@@ -290,8 +290,7 @@ bool tcp_is_cwnd_limited(const struct sock *sk, u32 in_flight)
290 left = tp->snd_cwnd - in_flight; 290 left = tp->snd_cwnd - in_flight;
291 if (sk_can_gso(sk) && 291 if (sk_can_gso(sk) &&
292 left * sysctl_tcp_tso_win_divisor < tp->snd_cwnd && 292 left * sysctl_tcp_tso_win_divisor < tp->snd_cwnd &&
293 left * tp->mss_cache < sk->sk_gso_max_size && 293 left < tp->xmit_size_goal_segs)
294 left < sk->sk_gso_max_segs)
295 return true; 294 return true;
296 return left <= tcp_max_tso_deferred_mss(tp); 295 return left <= tcp_max_tso_deferred_mss(tp);
297} 296}
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 6e4809389cbf..b99003f556d8 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -1944,8 +1944,9 @@ void tcp_enter_loss(struct sock *sk, int how)
1944 if (skb == tcp_send_head(sk)) 1944 if (skb == tcp_send_head(sk))
1945 break; 1945 break;
1946 1946
1947 if (TCP_SKB_CB(skb)->sacked & TCPCB_RETRANS) 1947 if (TCP_SKB_CB(skb)->sacked & TCPCB_SACKED_RETRANS)
1948 tp->undo_marker = 0; 1948 tp->undo_marker = 0;
1949
1949 TCP_SKB_CB(skb)->sacked &= (~TCPCB_TAGBITS)|TCPCB_SACKED_ACKED; 1950 TCP_SKB_CB(skb)->sacked &= (~TCPCB_TAGBITS)|TCPCB_SACKED_ACKED;
1950 if (!(TCP_SKB_CB(skb)->sacked&TCPCB_SACKED_ACKED) || how) { 1951 if (!(TCP_SKB_CB(skb)->sacked&TCPCB_SACKED_ACKED) || how) {
1951 TCP_SKB_CB(skb)->sacked &= ~TCPCB_SACKED_ACKED; 1952 TCP_SKB_CB(skb)->sacked &= ~TCPCB_SACKED_ACKED;
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index aaa68f5b1055..5286228679bd 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -873,8 +873,8 @@ static int tcp_transmit_skb(struct sock *sk, struct sk_buff *skb, int clone_it,
873 873
874 if (unlikely(skb->fclone == SKB_FCLONE_ORIG && 874 if (unlikely(skb->fclone == SKB_FCLONE_ORIG &&
875 fclone->fclone == SKB_FCLONE_CLONE)) 875 fclone->fclone == SKB_FCLONE_CLONE))
876 NET_INC_STATS_BH(sock_net(sk), 876 NET_INC_STATS(sock_net(sk),
877 LINUX_MIB_TCPSPURIOUS_RTX_HOSTQUEUES); 877 LINUX_MIB_TCPSPURIOUS_RTX_HOSTQUEUES);
878 878
879 if (unlikely(skb_cloned(skb))) 879 if (unlikely(skb_cloned(skb)))
880 skb = pskb_copy(skb, gfp_mask); 880 skb = pskb_copy(skb, gfp_mask);
@@ -2358,6 +2358,7 @@ int __tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb)
2358 struct tcp_sock *tp = tcp_sk(sk); 2358 struct tcp_sock *tp = tcp_sk(sk);
2359 struct inet_connection_sock *icsk = inet_csk(sk); 2359 struct inet_connection_sock *icsk = inet_csk(sk);
2360 unsigned int cur_mss; 2360 unsigned int cur_mss;
2361 int err;
2361 2362
2362 /* Inconslusive MTU probe */ 2363 /* Inconslusive MTU probe */
2363 if (icsk->icsk_mtup.probe_size) { 2364 if (icsk->icsk_mtup.probe_size) {
@@ -2421,11 +2422,15 @@ int __tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb)
2421 skb_headroom(skb) >= 0xFFFF)) { 2422 skb_headroom(skb) >= 0xFFFF)) {
2422 struct sk_buff *nskb = __pskb_copy(skb, MAX_TCP_HEADER, 2423 struct sk_buff *nskb = __pskb_copy(skb, MAX_TCP_HEADER,
2423 GFP_ATOMIC); 2424 GFP_ATOMIC);
2424 return nskb ? tcp_transmit_skb(sk, nskb, 0, GFP_ATOMIC) : 2425 err = nskb ? tcp_transmit_skb(sk, nskb, 0, GFP_ATOMIC) :
2425 -ENOBUFS; 2426 -ENOBUFS;
2426 } else { 2427 } else {
2427 return tcp_transmit_skb(sk, skb, 1, GFP_ATOMIC); 2428 err = tcp_transmit_skb(sk, skb, 1, GFP_ATOMIC);
2428 } 2429 }
2430
2431 if (likely(!err))
2432 TCP_SKB_CB(skb)->sacked |= TCPCB_EVER_RETRANS;
2433 return err;
2429} 2434}
2430 2435
2431int tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb) 2436int tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb)
@@ -2930,7 +2935,12 @@ static int tcp_send_syn_data(struct sock *sk, struct sk_buff *syn)
2930 space = __tcp_mtu_to_mss(sk, inet_csk(sk)->icsk_pmtu_cookie) - 2935 space = __tcp_mtu_to_mss(sk, inet_csk(sk)->icsk_pmtu_cookie) -
2931 MAX_TCP_OPTION_SPACE; 2936 MAX_TCP_OPTION_SPACE;
2932 2937
2933 syn_data = skb_copy_expand(syn, skb_headroom(syn), space, 2938 space = min_t(size_t, space, fo->size);
2939
2940 /* limit to order-0 allocations */
2941 space = min_t(size_t, space, SKB_MAX_HEAD(MAX_TCP_HEADER));
2942
2943 syn_data = skb_copy_expand(syn, MAX_TCP_HEADER, space,
2934 sk->sk_allocation); 2944 sk->sk_allocation);
2935 if (syn_data == NULL) 2945 if (syn_data == NULL)
2936 goto fallback; 2946 goto fallback;
diff --git a/net/ipv6/Kconfig b/net/ipv6/Kconfig
index d92e5586783e..438a73aa777c 100644
--- a/net/ipv6/Kconfig
+++ b/net/ipv6/Kconfig
@@ -138,6 +138,7 @@ config INET6_XFRM_MODE_ROUTEOPTIMIZATION
138config IPV6_VTI 138config IPV6_VTI
139tristate "Virtual (secure) IPv6: tunneling" 139tristate "Virtual (secure) IPv6: tunneling"
140 select IPV6_TUNNEL 140 select IPV6_TUNNEL
141 select NET_IP_TUNNEL
141 depends on INET6_XFRM_MODE_TUNNEL 142 depends on INET6_XFRM_MODE_TUNNEL
142 ---help--- 143 ---help---
143 Tunneling means encapsulating data of one protocol type within 144 Tunneling means encapsulating data of one protocol type within
diff --git a/net/ipv6/exthdrs_core.c b/net/ipv6/exthdrs_core.c
index 140748debc4a..8af3eb57f438 100644
--- a/net/ipv6/exthdrs_core.c
+++ b/net/ipv6/exthdrs_core.c
@@ -212,7 +212,7 @@ int ipv6_find_hdr(const struct sk_buff *skb, unsigned int *offset,
212 found = (nexthdr == target); 212 found = (nexthdr == target);
213 213
214 if ((!ipv6_ext_hdr(nexthdr)) || nexthdr == NEXTHDR_NONE) { 214 if ((!ipv6_ext_hdr(nexthdr)) || nexthdr == NEXTHDR_NONE) {
215 if (target < 0) 215 if (target < 0 || found)
216 break; 216 break;
217 return -ENOENT; 217 return -ENOENT;
218 } 218 }
diff --git a/net/ipv6/ip6_offload.c b/net/ipv6/ip6_offload.c
index 1e8683b135bb..59f95affceb0 100644
--- a/net/ipv6/ip6_offload.c
+++ b/net/ipv6/ip6_offload.c
@@ -89,7 +89,7 @@ static struct sk_buff *ipv6_gso_segment(struct sk_buff *skb,
89 unsigned int unfrag_ip6hlen; 89 unsigned int unfrag_ip6hlen;
90 u8 *prevhdr; 90 u8 *prevhdr;
91 int offset = 0; 91 int offset = 0;
92 bool tunnel; 92 bool encap, udpfrag;
93 int nhoff; 93 int nhoff;
94 94
95 if (unlikely(skb_shinfo(skb)->gso_type & 95 if (unlikely(skb_shinfo(skb)->gso_type &
@@ -110,8 +110,8 @@ static struct sk_buff *ipv6_gso_segment(struct sk_buff *skb,
110 if (unlikely(!pskb_may_pull(skb, sizeof(*ipv6h)))) 110 if (unlikely(!pskb_may_pull(skb, sizeof(*ipv6h))))
111 goto out; 111 goto out;
112 112
113 tunnel = SKB_GSO_CB(skb)->encap_level > 0; 113 encap = SKB_GSO_CB(skb)->encap_level > 0;
114 if (tunnel) 114 if (encap)
115 features = skb->dev->hw_enc_features & netif_skb_features(skb); 115 features = skb->dev->hw_enc_features & netif_skb_features(skb);
116 SKB_GSO_CB(skb)->encap_level += sizeof(*ipv6h); 116 SKB_GSO_CB(skb)->encap_level += sizeof(*ipv6h);
117 117
@@ -121,6 +121,12 @@ static struct sk_buff *ipv6_gso_segment(struct sk_buff *skb,
121 121
122 proto = ipv6_gso_pull_exthdrs(skb, ipv6h->nexthdr); 122 proto = ipv6_gso_pull_exthdrs(skb, ipv6h->nexthdr);
123 123
124 if (skb->encapsulation &&
125 skb_shinfo(skb)->gso_type & (SKB_GSO_SIT|SKB_GSO_IPIP))
126 udpfrag = proto == IPPROTO_UDP && encap;
127 else
128 udpfrag = proto == IPPROTO_UDP && !skb->encapsulation;
129
124 ops = rcu_dereference(inet6_offloads[proto]); 130 ops = rcu_dereference(inet6_offloads[proto]);
125 if (likely(ops && ops->callbacks.gso_segment)) { 131 if (likely(ops && ops->callbacks.gso_segment)) {
126 skb_reset_transport_header(skb); 132 skb_reset_transport_header(skb);
@@ -133,13 +139,9 @@ static struct sk_buff *ipv6_gso_segment(struct sk_buff *skb,
133 for (skb = segs; skb; skb = skb->next) { 139 for (skb = segs; skb; skb = skb->next) {
134 ipv6h = (struct ipv6hdr *)(skb_mac_header(skb) + nhoff); 140 ipv6h = (struct ipv6hdr *)(skb_mac_header(skb) + nhoff);
135 ipv6h->payload_len = htons(skb->len - nhoff - sizeof(*ipv6h)); 141 ipv6h->payload_len = htons(skb->len - nhoff - sizeof(*ipv6h));
136 if (tunnel) {
137 skb_reset_inner_headers(skb);
138 skb->encapsulation = 1;
139 }
140 skb->network_header = (u8 *)ipv6h - skb->head; 142 skb->network_header = (u8 *)ipv6h - skb->head;
141 143
142 if (!tunnel && proto == IPPROTO_UDP) { 144 if (udpfrag) {
143 unfrag_ip6hlen = ip6_find_1stfragopt(skb, &prevhdr); 145 unfrag_ip6hlen = ip6_find_1stfragopt(skb, &prevhdr);
144 fptr = (struct frag_hdr *)((u8 *)ipv6h + unfrag_ip6hlen); 146 fptr = (struct frag_hdr *)((u8 *)ipv6h + unfrag_ip6hlen);
145 fptr->frag_off = htons(offset); 147 fptr->frag_off = htons(offset);
@@ -148,6 +150,8 @@ static struct sk_buff *ipv6_gso_segment(struct sk_buff *skb,
148 offset += (ntohs(ipv6h->payload_len) - 150 offset += (ntohs(ipv6h->payload_len) -
149 sizeof(struct frag_hdr)); 151 sizeof(struct frag_hdr));
150 } 152 }
153 if (encap)
154 skb_reset_inner_headers(skb);
151 } 155 }
152 156
153out: 157out:
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index be1b7f5a3a54..2bc10701182b 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -530,9 +530,6 @@ static void ip6_copy_metadata(struct sk_buff *to, struct sk_buff *from)
530 to->tc_index = from->tc_index; 530 to->tc_index = from->tc_index;
531#endif 531#endif
532 nf_copy(to, from); 532 nf_copy(to, from);
533#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE)
534 to->nf_trace = from->nf_trace;
535#endif
536 skb_copy_secmark(to, from); 533 skb_copy_secmark(to, from);
537} 534}
538 535
diff --git a/net/ipv6/ping.c b/net/ipv6/ping.c
index fb9beb78f00b..587bbdcb22b4 100644
--- a/net/ipv6/ping.c
+++ b/net/ipv6/ping.c
@@ -135,6 +135,7 @@ int ping_v6_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
135 fl6.flowi6_proto = IPPROTO_ICMPV6; 135 fl6.flowi6_proto = IPPROTO_ICMPV6;
136 fl6.saddr = np->saddr; 136 fl6.saddr = np->saddr;
137 fl6.daddr = *daddr; 137 fl6.daddr = *daddr;
138 fl6.flowi6_mark = sk->sk_mark;
138 fl6.fl6_icmp_type = user_icmph.icmp6_type; 139 fl6.fl6_icmp_type = user_icmph.icmp6_type;
139 fl6.fl6_icmp_code = user_icmph.icmp6_code; 140 fl6.fl6_icmp_code = user_icmph.icmp6_code;
140 security_sk_classify_flow(sk, flowi6_to_flowi(&fl6)); 141 security_sk_classify_flow(sk, flowi6_to_flowi(&fl6));
diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
index 958027be0e94..1693c8d885f0 100644
--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -475,6 +475,7 @@ static void ipip6_tunnel_uninit(struct net_device *dev)
475 ipip6_tunnel_unlink(sitn, tunnel); 475 ipip6_tunnel_unlink(sitn, tunnel);
476 ipip6_tunnel_del_prl(tunnel, NULL); 476 ipip6_tunnel_del_prl(tunnel, NULL);
477 } 477 }
478 ip_tunnel_dst_reset_all(tunnel);
478 dev_put(dev); 479 dev_put(dev);
479} 480}
480 481
@@ -1082,6 +1083,7 @@ static void ipip6_tunnel_update(struct ip_tunnel *t, struct ip_tunnel_parm *p)
1082 t->parms.link = p->link; 1083 t->parms.link = p->link;
1083 ipip6_tunnel_bind_dev(t->dev); 1084 ipip6_tunnel_bind_dev(t->dev);
1084 } 1085 }
1086 ip_tunnel_dst_reset_all(t);
1085 netdev_state_change(t->dev); 1087 netdev_state_change(t->dev);
1086} 1088}
1087 1089
@@ -1112,6 +1114,7 @@ static int ipip6_tunnel_update_6rd(struct ip_tunnel *t,
1112 t->ip6rd.relay_prefix = relay_prefix; 1114 t->ip6rd.relay_prefix = relay_prefix;
1113 t->ip6rd.prefixlen = ip6rd->prefixlen; 1115 t->ip6rd.prefixlen = ip6rd->prefixlen;
1114 t->ip6rd.relay_prefixlen = ip6rd->relay_prefixlen; 1116 t->ip6rd.relay_prefixlen = ip6rd->relay_prefixlen;
1117 ip_tunnel_dst_reset_all(t);
1115 netdev_state_change(t->dev); 1118 netdev_state_change(t->dev);
1116 return 0; 1119 return 0;
1117} 1120}
@@ -1271,6 +1274,7 @@ ipip6_tunnel_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd)
1271 err = ipip6_tunnel_add_prl(t, &prl, cmd == SIOCCHGPRL); 1274 err = ipip6_tunnel_add_prl(t, &prl, cmd == SIOCCHGPRL);
1272 break; 1275 break;
1273 } 1276 }
1277 ip_tunnel_dst_reset_all(t);
1274 netdev_state_change(dev); 1278 netdev_state_change(dev);
1275 break; 1279 break;
1276 1280
@@ -1326,6 +1330,9 @@ static const struct net_device_ops ipip6_netdev_ops = {
1326 1330
1327static void ipip6_dev_free(struct net_device *dev) 1331static void ipip6_dev_free(struct net_device *dev)
1328{ 1332{
1333 struct ip_tunnel *tunnel = netdev_priv(dev);
1334
1335 free_percpu(tunnel->dst_cache);
1329 free_percpu(dev->tstats); 1336 free_percpu(dev->tstats);
1330 free_netdev(dev); 1337 free_netdev(dev);
1331} 1338}
@@ -1368,6 +1375,12 @@ static int ipip6_tunnel_init(struct net_device *dev)
1368 if (!dev->tstats) 1375 if (!dev->tstats)
1369 return -ENOMEM; 1376 return -ENOMEM;
1370 1377
1378 tunnel->dst_cache = alloc_percpu(struct ip_tunnel_dst);
1379 if (!tunnel->dst_cache) {
1380 free_percpu(dev->tstats);
1381 return -ENOMEM;
1382 }
1383
1371 return 0; 1384 return 0;
1372} 1385}
1373 1386
@@ -1391,6 +1404,12 @@ static int __net_init ipip6_fb_tunnel_init(struct net_device *dev)
1391 if (!dev->tstats) 1404 if (!dev->tstats)
1392 return -ENOMEM; 1405 return -ENOMEM;
1393 1406
1407 tunnel->dst_cache = alloc_percpu(struct ip_tunnel_dst);
1408 if (!tunnel->dst_cache) {
1409 free_percpu(dev->tstats);
1410 return -ENOMEM;
1411 }
1412
1394 dev_hold(dev); 1413 dev_hold(dev);
1395 rcu_assign_pointer(sitn->tunnels_wc[0], tunnel); 1414 rcu_assign_pointer(sitn->tunnels_wc[0], tunnel);
1396 return 0; 1415 return 0;
diff --git a/net/ipv6/udp_offload.c b/net/ipv6/udp_offload.c
index e7359f9eaa8d..b261ee8b83fc 100644
--- a/net/ipv6/udp_offload.c
+++ b/net/ipv6/udp_offload.c
@@ -113,7 +113,7 @@ static struct sk_buff *udp6_ufo_fragment(struct sk_buff *skb,
113 fptr = (struct frag_hdr *)(skb_network_header(skb) + unfrag_ip6hlen); 113 fptr = (struct frag_hdr *)(skb_network_header(skb) + unfrag_ip6hlen);
114 fptr->nexthdr = nexthdr; 114 fptr->nexthdr = nexthdr;
115 fptr->reserved = 0; 115 fptr->reserved = 0;
116 ipv6_select_ident(fptr, (struct rt6_info *)skb_dst(skb)); 116 fptr->identification = skb_shinfo(skb)->ip6_frag_id;
117 117
118 /* Fragment the skb. ipv6 header and the remaining fields of the 118 /* Fragment the skb. ipv6 header and the remaining fields of the
119 * fragment header are updated in ipv6_gso_segment() 119 * fragment header are updated in ipv6_gso_segment()
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index 0014b5396ce5..906e211b1dd1 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -1698,14 +1698,8 @@ void ieee80211_stop_queue_by_reason(struct ieee80211_hw *hw, int queue,
1698void ieee80211_propagate_queue_wake(struct ieee80211_local *local, int queue); 1698void ieee80211_propagate_queue_wake(struct ieee80211_local *local, int queue);
1699void ieee80211_add_pending_skb(struct ieee80211_local *local, 1699void ieee80211_add_pending_skb(struct ieee80211_local *local,
1700 struct sk_buff *skb); 1700 struct sk_buff *skb);
1701void ieee80211_add_pending_skbs_fn(struct ieee80211_local *local, 1701void ieee80211_add_pending_skbs(struct ieee80211_local *local,
1702 struct sk_buff_head *skbs, 1702 struct sk_buff_head *skbs);
1703 void (*fn)(void *data), void *data);
1704static inline void ieee80211_add_pending_skbs(struct ieee80211_local *local,
1705 struct sk_buff_head *skbs)
1706{
1707 ieee80211_add_pending_skbs_fn(local, skbs, NULL, NULL);
1708}
1709void ieee80211_flush_queues(struct ieee80211_local *local, 1703void ieee80211_flush_queues(struct ieee80211_local *local,
1710 struct ieee80211_sub_if_data *sdata); 1704 struct ieee80211_sub_if_data *sdata);
1711 1705
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index 61604834b914..4bc227550f25 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -222,6 +222,7 @@ ieee80211_determine_chantype(struct ieee80211_sub_if_data *sdata,
222 switch (vht_oper->chan_width) { 222 switch (vht_oper->chan_width) {
223 case IEEE80211_VHT_CHANWIDTH_USE_HT: 223 case IEEE80211_VHT_CHANWIDTH_USE_HT:
224 vht_chandef.width = chandef->width; 224 vht_chandef.width = chandef->width;
225 vht_chandef.center_freq1 = chandef->center_freq1;
225 break; 226 break;
226 case IEEE80211_VHT_CHANWIDTH_80MHZ: 227 case IEEE80211_VHT_CHANWIDTH_80MHZ:
227 vht_chandef.width = NL80211_CHAN_WIDTH_80; 228 vht_chandef.width = NL80211_CHAN_WIDTH_80;
@@ -271,6 +272,28 @@ ieee80211_determine_chantype(struct ieee80211_sub_if_data *sdata,
271 ret = 0; 272 ret = 0;
272 273
273out: 274out:
275 /*
276 * When tracking the current AP, don't do any further checks if the
277 * new chandef is identical to the one we're currently using for the
278 * connection. This keeps us from playing ping-pong with regulatory,
279 * without it the following can happen (for example):
280 * - connect to an AP with 80 MHz, world regdom allows 80 MHz
281 * - AP advertises regdom US
282 * - CRDA loads regdom US with 80 MHz prohibited (old database)
283 * - the code below detects an unsupported channel, downgrades, and
284 * we disconnect from the AP in the caller
285 * - disconnect causes CRDA to reload world regdomain and the game
286 * starts anew.
287 * (see https://bugzilla.kernel.org/show_bug.cgi?id=70881)
288 *
289 * It seems possible that there are still scenarios with CSA or real
290 * bandwidth changes where a this could happen, but those cases are
291 * less common and wouldn't completely prevent using the AP.
292 */
293 if (tracking &&
294 cfg80211_chandef_identical(chandef, &sdata->vif.bss_conf.chandef))
295 return ret;
296
274 /* don't print the message below for VHT mismatch if VHT is disabled */ 297 /* don't print the message below for VHT mismatch if VHT is disabled */
275 if (ret & IEEE80211_STA_DISABLE_VHT) 298 if (ret & IEEE80211_STA_DISABLE_VHT)
276 vht_chandef = *chandef; 299 vht_chandef = *chandef;
@@ -3792,6 +3815,7 @@ static int ieee80211_prep_connection(struct ieee80211_sub_if_data *sdata,
3792 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); 3815 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
3793 if (WARN_ON(!chanctx_conf)) { 3816 if (WARN_ON(!chanctx_conf)) {
3794 rcu_read_unlock(); 3817 rcu_read_unlock();
3818 sta_info_free(local, new_sta);
3795 return -EINVAL; 3819 return -EINVAL;
3796 } 3820 }
3797 rate_flags = ieee80211_chandef_rate_flags(&chanctx_conf->def); 3821 rate_flags = ieee80211_chandef_rate_flags(&chanctx_conf->def);
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index 593062109c50..282440216a87 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -1092,6 +1092,13 @@ static void sta_ps_end(struct sta_info *sta)
1092 sta->sta.addr, sta->sta.aid); 1092 sta->sta.addr, sta->sta.aid);
1093 1093
1094 if (test_sta_flag(sta, WLAN_STA_PS_DRIVER)) { 1094 if (test_sta_flag(sta, WLAN_STA_PS_DRIVER)) {
1095 /*
1096 * Clear the flag only if the other one is still set
1097 * so that the TX path won't start TX'ing new frames
1098 * directly ... In the case that the driver flag isn't
1099 * set ieee80211_sta_ps_deliver_wakeup() will clear it.
1100 */
1101 clear_sta_flag(sta, WLAN_STA_PS_STA);
1095 ps_dbg(sta->sdata, "STA %pM aid %d driver-ps-blocked\n", 1102 ps_dbg(sta->sdata, "STA %pM aid %d driver-ps-blocked\n",
1096 sta->sta.addr, sta->sta.aid); 1103 sta->sta.addr, sta->sta.aid);
1097 return; 1104 return;
diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c
index decd30c1e290..a023b432143b 100644
--- a/net/mac80211/sta_info.c
+++ b/net/mac80211/sta_info.c
@@ -91,7 +91,7 @@ static int sta_info_hash_del(struct ieee80211_local *local,
91 return -ENOENT; 91 return -ENOENT;
92} 92}
93 93
94static void cleanup_single_sta(struct sta_info *sta) 94static void __cleanup_single_sta(struct sta_info *sta)
95{ 95{
96 int ac, i; 96 int ac, i;
97 struct tid_ampdu_tx *tid_tx; 97 struct tid_ampdu_tx *tid_tx;
@@ -99,7 +99,8 @@ static void cleanup_single_sta(struct sta_info *sta)
99 struct ieee80211_local *local = sdata->local; 99 struct ieee80211_local *local = sdata->local;
100 struct ps_data *ps; 100 struct ps_data *ps;
101 101
102 if (test_sta_flag(sta, WLAN_STA_PS_STA)) { 102 if (test_sta_flag(sta, WLAN_STA_PS_STA) ||
103 test_sta_flag(sta, WLAN_STA_PS_DRIVER)) {
103 if (sta->sdata->vif.type == NL80211_IFTYPE_AP || 104 if (sta->sdata->vif.type == NL80211_IFTYPE_AP ||
104 sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN) 105 sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
105 ps = &sdata->bss->ps; 106 ps = &sdata->bss->ps;
@@ -109,6 +110,7 @@ static void cleanup_single_sta(struct sta_info *sta)
109 return; 110 return;
110 111
111 clear_sta_flag(sta, WLAN_STA_PS_STA); 112 clear_sta_flag(sta, WLAN_STA_PS_STA);
113 clear_sta_flag(sta, WLAN_STA_PS_DRIVER);
112 114
113 atomic_dec(&ps->num_sta_ps); 115 atomic_dec(&ps->num_sta_ps);
114 sta_info_recalc_tim(sta); 116 sta_info_recalc_tim(sta);
@@ -139,7 +141,14 @@ static void cleanup_single_sta(struct sta_info *sta)
139 ieee80211_purge_tx_queue(&local->hw, &tid_tx->pending); 141 ieee80211_purge_tx_queue(&local->hw, &tid_tx->pending);
140 kfree(tid_tx); 142 kfree(tid_tx);
141 } 143 }
144}
142 145
146static void cleanup_single_sta(struct sta_info *sta)
147{
148 struct ieee80211_sub_if_data *sdata = sta->sdata;
149 struct ieee80211_local *local = sdata->local;
150
151 __cleanup_single_sta(sta);
143 sta_info_free(local, sta); 152 sta_info_free(local, sta);
144} 153}
145 154
@@ -330,6 +339,7 @@ struct sta_info *sta_info_alloc(struct ieee80211_sub_if_data *sdata,
330 rcu_read_unlock(); 339 rcu_read_unlock();
331 340
332 spin_lock_init(&sta->lock); 341 spin_lock_init(&sta->lock);
342 spin_lock_init(&sta->ps_lock);
333 INIT_WORK(&sta->drv_unblock_wk, sta_unblock); 343 INIT_WORK(&sta->drv_unblock_wk, sta_unblock);
334 INIT_WORK(&sta->ampdu_mlme.work, ieee80211_ba_session_work); 344 INIT_WORK(&sta->ampdu_mlme.work, ieee80211_ba_session_work);
335 mutex_init(&sta->ampdu_mlme.mtx); 345 mutex_init(&sta->ampdu_mlme.mtx);
@@ -487,21 +497,26 @@ static int sta_info_insert_finish(struct sta_info *sta) __acquires(RCU)
487 goto out_err; 497 goto out_err;
488 } 498 }
489 499
490 /* notify driver */
491 err = sta_info_insert_drv_state(local, sdata, sta);
492 if (err)
493 goto out_err;
494
495 local->num_sta++; 500 local->num_sta++;
496 local->sta_generation++; 501 local->sta_generation++;
497 smp_mb(); 502 smp_mb();
498 503
504 /* simplify things and don't accept BA sessions yet */
505 set_sta_flag(sta, WLAN_STA_BLOCK_BA);
506
499 /* make the station visible */ 507 /* make the station visible */
500 sta_info_hash_add(local, sta); 508 sta_info_hash_add(local, sta);
501 509
502 list_add_rcu(&sta->list, &local->sta_list); 510 list_add_rcu(&sta->list, &local->sta_list);
503 511
512 /* notify driver */
513 err = sta_info_insert_drv_state(local, sdata, sta);
514 if (err)
515 goto out_remove;
516
504 set_sta_flag(sta, WLAN_STA_INSERTED); 517 set_sta_flag(sta, WLAN_STA_INSERTED);
518 /* accept BA sessions now */
519 clear_sta_flag(sta, WLAN_STA_BLOCK_BA);
505 520
506 ieee80211_recalc_min_chandef(sdata); 521 ieee80211_recalc_min_chandef(sdata);
507 ieee80211_sta_debugfs_add(sta); 522 ieee80211_sta_debugfs_add(sta);
@@ -522,6 +537,12 @@ static int sta_info_insert_finish(struct sta_info *sta) __acquires(RCU)
522 mesh_accept_plinks_update(sdata); 537 mesh_accept_plinks_update(sdata);
523 538
524 return 0; 539 return 0;
540 out_remove:
541 sta_info_hash_del(local, sta);
542 list_del_rcu(&sta->list);
543 local->num_sta--;
544 synchronize_net();
545 __cleanup_single_sta(sta);
525 out_err: 546 out_err:
526 mutex_unlock(&local->sta_mtx); 547 mutex_unlock(&local->sta_mtx);
527 rcu_read_lock(); 548 rcu_read_lock();
@@ -1071,10 +1092,14 @@ struct ieee80211_sta *ieee80211_find_sta(struct ieee80211_vif *vif,
1071} 1092}
1072EXPORT_SYMBOL(ieee80211_find_sta); 1093EXPORT_SYMBOL(ieee80211_find_sta);
1073 1094
1074static void clear_sta_ps_flags(void *_sta) 1095/* powersave support code */
1096void ieee80211_sta_ps_deliver_wakeup(struct sta_info *sta)
1075{ 1097{
1076 struct sta_info *sta = _sta;
1077 struct ieee80211_sub_if_data *sdata = sta->sdata; 1098 struct ieee80211_sub_if_data *sdata = sta->sdata;
1099 struct ieee80211_local *local = sdata->local;
1100 struct sk_buff_head pending;
1101 int filtered = 0, buffered = 0, ac;
1102 unsigned long flags;
1078 struct ps_data *ps; 1103 struct ps_data *ps;
1079 1104
1080 if (sdata->vif.type == NL80211_IFTYPE_AP || 1105 if (sdata->vif.type == NL80211_IFTYPE_AP ||
@@ -1085,20 +1110,6 @@ static void clear_sta_ps_flags(void *_sta)
1085 else 1110 else
1086 return; 1111 return;
1087 1112
1088 clear_sta_flag(sta, WLAN_STA_PS_DRIVER);
1089 if (test_and_clear_sta_flag(sta, WLAN_STA_PS_STA))
1090 atomic_dec(&ps->num_sta_ps);
1091}
1092
1093/* powersave support code */
1094void ieee80211_sta_ps_deliver_wakeup(struct sta_info *sta)
1095{
1096 struct ieee80211_sub_if_data *sdata = sta->sdata;
1097 struct ieee80211_local *local = sdata->local;
1098 struct sk_buff_head pending;
1099 int filtered = 0, buffered = 0, ac;
1100 unsigned long flags;
1101
1102 clear_sta_flag(sta, WLAN_STA_SP); 1113 clear_sta_flag(sta, WLAN_STA_SP);
1103 1114
1104 BUILD_BUG_ON(BITS_TO_LONGS(IEEE80211_NUM_TIDS) > 1); 1115 BUILD_BUG_ON(BITS_TO_LONGS(IEEE80211_NUM_TIDS) > 1);
@@ -1109,6 +1120,8 @@ void ieee80211_sta_ps_deliver_wakeup(struct sta_info *sta)
1109 1120
1110 skb_queue_head_init(&pending); 1121 skb_queue_head_init(&pending);
1111 1122
1123 /* sync with ieee80211_tx_h_unicast_ps_buf */
1124 spin_lock(&sta->ps_lock);
1112 /* Send all buffered frames to the station */ 1125 /* Send all buffered frames to the station */
1113 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) { 1126 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) {
1114 int count = skb_queue_len(&pending), tmp; 1127 int count = skb_queue_len(&pending), tmp;
@@ -1127,7 +1140,12 @@ void ieee80211_sta_ps_deliver_wakeup(struct sta_info *sta)
1127 buffered += tmp - count; 1140 buffered += tmp - count;
1128 } 1141 }
1129 1142
1130 ieee80211_add_pending_skbs_fn(local, &pending, clear_sta_ps_flags, sta); 1143 ieee80211_add_pending_skbs(local, &pending);
1144 clear_sta_flag(sta, WLAN_STA_PS_DRIVER);
1145 clear_sta_flag(sta, WLAN_STA_PS_STA);
1146 spin_unlock(&sta->ps_lock);
1147
1148 atomic_dec(&ps->num_sta_ps);
1131 1149
1132 /* This station just woke up and isn't aware of our SMPS state */ 1150 /* This station just woke up and isn't aware of our SMPS state */
1133 if (!ieee80211_smps_is_restrictive(sta->known_smps_mode, 1151 if (!ieee80211_smps_is_restrictive(sta->known_smps_mode,
diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h
index d4d85de0d75d..4acc5fc402fa 100644
--- a/net/mac80211/sta_info.h
+++ b/net/mac80211/sta_info.h
@@ -268,6 +268,7 @@ struct ieee80211_tx_latency_stat {
268 * @drv_unblock_wk: used for driver PS unblocking 268 * @drv_unblock_wk: used for driver PS unblocking
269 * @listen_interval: listen interval of this station, when we're acting as AP 269 * @listen_interval: listen interval of this station, when we're acting as AP
270 * @_flags: STA flags, see &enum ieee80211_sta_info_flags, do not use directly 270 * @_flags: STA flags, see &enum ieee80211_sta_info_flags, do not use directly
271 * @ps_lock: used for powersave (when mac80211 is the AP) related locking
271 * @ps_tx_buf: buffers (per AC) of frames to transmit to this station 272 * @ps_tx_buf: buffers (per AC) of frames to transmit to this station
272 * when it leaves power saving state or polls 273 * when it leaves power saving state or polls
273 * @tx_filtered: buffers (per AC) of frames we already tried to 274 * @tx_filtered: buffers (per AC) of frames we already tried to
@@ -357,10 +358,8 @@ struct sta_info {
357 /* use the accessors defined below */ 358 /* use the accessors defined below */
358 unsigned long _flags; 359 unsigned long _flags;
359 360
360 /* 361 /* STA powersave lock and frame queues */
361 * STA powersave frame queues, no more than the internal 362 spinlock_t ps_lock;
362 * locking required.
363 */
364 struct sk_buff_head ps_tx_buf[IEEE80211_NUM_ACS]; 363 struct sk_buff_head ps_tx_buf[IEEE80211_NUM_ACS];
365 struct sk_buff_head tx_filtered[IEEE80211_NUM_ACS]; 364 struct sk_buff_head tx_filtered[IEEE80211_NUM_ACS];
366 unsigned long driver_buffered_tids; 365 unsigned long driver_buffered_tids;
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index 722151fa5dce..cd9f80498c48 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -477,6 +477,20 @@ ieee80211_tx_h_unicast_ps_buf(struct ieee80211_tx_data *tx)
477 sta->sta.addr, sta->sta.aid, ac); 477 sta->sta.addr, sta->sta.aid, ac);
478 if (tx->local->total_ps_buffered >= TOTAL_MAX_TX_BUFFER) 478 if (tx->local->total_ps_buffered >= TOTAL_MAX_TX_BUFFER)
479 purge_old_ps_buffers(tx->local); 479 purge_old_ps_buffers(tx->local);
480
481 /* sync with ieee80211_sta_ps_deliver_wakeup */
482 spin_lock(&sta->ps_lock);
483 /*
484 * STA woke up the meantime and all the frames on ps_tx_buf have
485 * been queued to pending queue. No reordering can happen, go
486 * ahead and Tx the packet.
487 */
488 if (!test_sta_flag(sta, WLAN_STA_PS_STA) &&
489 !test_sta_flag(sta, WLAN_STA_PS_DRIVER)) {
490 spin_unlock(&sta->ps_lock);
491 return TX_CONTINUE;
492 }
493
480 if (skb_queue_len(&sta->ps_tx_buf[ac]) >= STA_MAX_TX_BUFFER) { 494 if (skb_queue_len(&sta->ps_tx_buf[ac]) >= STA_MAX_TX_BUFFER) {
481 struct sk_buff *old = skb_dequeue(&sta->ps_tx_buf[ac]); 495 struct sk_buff *old = skb_dequeue(&sta->ps_tx_buf[ac]);
482 ps_dbg(tx->sdata, 496 ps_dbg(tx->sdata,
@@ -491,6 +505,7 @@ ieee80211_tx_h_unicast_ps_buf(struct ieee80211_tx_data *tx)
491 info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING; 505 info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING;
492 info->flags &= ~IEEE80211_TX_TEMPORARY_FLAGS; 506 info->flags &= ~IEEE80211_TX_TEMPORARY_FLAGS;
493 skb_queue_tail(&sta->ps_tx_buf[ac], tx->skb); 507 skb_queue_tail(&sta->ps_tx_buf[ac], tx->skb);
508 spin_unlock(&sta->ps_lock);
494 509
495 if (!timer_pending(&local->sta_cleanup)) 510 if (!timer_pending(&local->sta_cleanup))
496 mod_timer(&local->sta_cleanup, 511 mod_timer(&local->sta_cleanup,
diff --git a/net/mac80211/util.c b/net/mac80211/util.c
index d842af5c8a95..275c94f995f7 100644
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -435,9 +435,8 @@ void ieee80211_add_pending_skb(struct ieee80211_local *local,
435 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); 435 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
436} 436}
437 437
438void ieee80211_add_pending_skbs_fn(struct ieee80211_local *local, 438void ieee80211_add_pending_skbs(struct ieee80211_local *local,
439 struct sk_buff_head *skbs, 439 struct sk_buff_head *skbs)
440 void (*fn)(void *data), void *data)
441{ 440{
442 struct ieee80211_hw *hw = &local->hw; 441 struct ieee80211_hw *hw = &local->hw;
443 struct sk_buff *skb; 442 struct sk_buff *skb;
@@ -461,9 +460,6 @@ void ieee80211_add_pending_skbs_fn(struct ieee80211_local *local,
461 __skb_queue_tail(&local->pending[queue], skb); 460 __skb_queue_tail(&local->pending[queue], skb);
462 } 461 }
463 462
464 if (fn)
465 fn(data);
466
467 for (i = 0; i < hw->queues; i++) 463 for (i = 0; i < hw->queues; i++)
468 __ieee80211_wake_queue(hw, i, 464 __ieee80211_wake_queue(hw, i,
469 IEEE80211_QUEUE_STOP_REASON_SKB_ADD); 465 IEEE80211_QUEUE_STOP_REASON_SKB_ADD);
@@ -1767,6 +1763,26 @@ int ieee80211_reconfig(struct ieee80211_local *local)
1767 IEEE80211_QUEUE_STOP_REASON_SUSPEND); 1763 IEEE80211_QUEUE_STOP_REASON_SUSPEND);
1768 1764
1769 /* 1765 /*
1766 * Reconfigure sched scan if it was interrupted by FW restart or
1767 * suspend.
1768 */
1769 mutex_lock(&local->mtx);
1770 sched_scan_sdata = rcu_dereference_protected(local->sched_scan_sdata,
1771 lockdep_is_held(&local->mtx));
1772 if (sched_scan_sdata && local->sched_scan_req)
1773 /*
1774 * Sched scan stopped, but we don't want to report it. Instead,
1775 * we're trying to reschedule.
1776 */
1777 if (__ieee80211_request_sched_scan_start(sched_scan_sdata,
1778 local->sched_scan_req))
1779 sched_scan_stopped = true;
1780 mutex_unlock(&local->mtx);
1781
1782 if (sched_scan_stopped)
1783 cfg80211_sched_scan_stopped(local->hw.wiphy);
1784
1785 /*
1770 * If this is for hw restart things are still running. 1786 * If this is for hw restart things are still running.
1771 * We may want to change that later, however. 1787 * We may want to change that later, however.
1772 */ 1788 */
@@ -1794,26 +1810,6 @@ int ieee80211_reconfig(struct ieee80211_local *local)
1794 WARN_ON(1); 1810 WARN_ON(1);
1795#endif 1811#endif
1796 1812
1797 /*
1798 * Reconfigure sched scan if it was interrupted by FW restart or
1799 * suspend.
1800 */
1801 mutex_lock(&local->mtx);
1802 sched_scan_sdata = rcu_dereference_protected(local->sched_scan_sdata,
1803 lockdep_is_held(&local->mtx));
1804 if (sched_scan_sdata && local->sched_scan_req)
1805 /*
1806 * Sched scan stopped, but we don't want to report it. Instead,
1807 * we're trying to reschedule.
1808 */
1809 if (__ieee80211_request_sched_scan_start(sched_scan_sdata,
1810 local->sched_scan_req))
1811 sched_scan_stopped = true;
1812 mutex_unlock(&local->mtx);
1813
1814 if (sched_scan_stopped)
1815 cfg80211_sched_scan_stopped(local->hw.wiphy);
1816
1817 return 0; 1813 return 0;
1818} 1814}
1819 1815
diff --git a/net/mac80211/wme.c b/net/mac80211/wme.c
index 21211c60ca98..d51422c778de 100644
--- a/net/mac80211/wme.c
+++ b/net/mac80211/wme.c
@@ -154,6 +154,11 @@ u16 ieee80211_select_queue(struct ieee80211_sub_if_data *sdata,
154 return IEEE80211_AC_BE; 154 return IEEE80211_AC_BE;
155 } 155 }
156 156
157 if (skb->protocol == sdata->control_port_protocol) {
158 skb->priority = 7;
159 return ieee80211_downgrade_queue(sdata, skb);
160 }
161
157 /* use the data classifier to determine what 802.1d tag the 162 /* use the data classifier to determine what 802.1d tag the
158 * data frame has */ 163 * data frame has */
159 rcu_read_lock(); 164 rcu_read_lock();
diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c
index bb322d0beb48..b9f0e0374322 100644
--- a/net/netfilter/nf_conntrack_netlink.c
+++ b/net/netfilter/nf_conntrack_netlink.c
@@ -1310,27 +1310,22 @@ ctnetlink_change_status(struct nf_conn *ct, const struct nlattr * const cda[])
1310} 1310}
1311 1311
1312static int 1312static int
1313ctnetlink_change_nat(struct nf_conn *ct, const struct nlattr * const cda[]) 1313ctnetlink_setup_nat(struct nf_conn *ct, const struct nlattr * const cda[])
1314{ 1314{
1315#ifdef CONFIG_NF_NAT_NEEDED 1315#ifdef CONFIG_NF_NAT_NEEDED
1316 int ret; 1316 int ret;
1317 1317
1318 if (cda[CTA_NAT_DST]) { 1318 ret = ctnetlink_parse_nat_setup(ct, NF_NAT_MANIP_DST,
1319 ret = ctnetlink_parse_nat_setup(ct, 1319 cda[CTA_NAT_DST]);
1320 NF_NAT_MANIP_DST, 1320 if (ret < 0)
1321 cda[CTA_NAT_DST]); 1321 return ret;
1322 if (ret < 0) 1322
1323 return ret; 1323 ret = ctnetlink_parse_nat_setup(ct, NF_NAT_MANIP_SRC,
1324 } 1324 cda[CTA_NAT_SRC]);
1325 if (cda[CTA_NAT_SRC]) { 1325 return ret;
1326 ret = ctnetlink_parse_nat_setup(ct,
1327 NF_NAT_MANIP_SRC,
1328 cda[CTA_NAT_SRC]);
1329 if (ret < 0)
1330 return ret;
1331 }
1332 return 0;
1333#else 1326#else
1327 if (!cda[CTA_NAT_DST] && !cda[CTA_NAT_SRC])
1328 return 0;
1334 return -EOPNOTSUPP; 1329 return -EOPNOTSUPP;
1335#endif 1330#endif
1336} 1331}
@@ -1659,11 +1654,9 @@ ctnetlink_create_conntrack(struct net *net, u16 zone,
1659 goto err2; 1654 goto err2;
1660 } 1655 }
1661 1656
1662 if (cda[CTA_NAT_SRC] || cda[CTA_NAT_DST]) { 1657 err = ctnetlink_setup_nat(ct, cda);
1663 err = ctnetlink_change_nat(ct, cda); 1658 if (err < 0)
1664 if (err < 0) 1659 goto err2;
1665 goto err2;
1666 }
1667 1660
1668 nf_ct_acct_ext_add(ct, GFP_ATOMIC); 1661 nf_ct_acct_ext_add(ct, GFP_ATOMIC);
1669 nf_ct_tstamp_ext_add(ct, GFP_ATOMIC); 1662 nf_ct_tstamp_ext_add(ct, GFP_ATOMIC);
diff --git a/net/netfilter/nf_nat_core.c b/net/netfilter/nf_nat_core.c
index d3f5cd6dd962..52ca952b802c 100644
--- a/net/netfilter/nf_nat_core.c
+++ b/net/netfilter/nf_nat_core.c
@@ -432,15 +432,15 @@ nf_nat_setup_info(struct nf_conn *ct,
432} 432}
433EXPORT_SYMBOL(nf_nat_setup_info); 433EXPORT_SYMBOL(nf_nat_setup_info);
434 434
435unsigned int 435static unsigned int
436nf_nat_alloc_null_binding(struct nf_conn *ct, unsigned int hooknum) 436__nf_nat_alloc_null_binding(struct nf_conn *ct, enum nf_nat_manip_type manip)
437{ 437{
438 /* Force range to this IP; let proto decide mapping for 438 /* Force range to this IP; let proto decide mapping for
439 * per-proto parts (hence not IP_NAT_RANGE_PROTO_SPECIFIED). 439 * per-proto parts (hence not IP_NAT_RANGE_PROTO_SPECIFIED).
440 * Use reply in case it's already been mangled (eg local packet). 440 * Use reply in case it's already been mangled (eg local packet).
441 */ 441 */
442 union nf_inet_addr ip = 442 union nf_inet_addr ip =
443 (HOOK2MANIP(hooknum) == NF_NAT_MANIP_SRC ? 443 (manip == NF_NAT_MANIP_SRC ?
444 ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u3 : 444 ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u3 :
445 ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.u3); 445 ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.u3);
446 struct nf_nat_range range = { 446 struct nf_nat_range range = {
@@ -448,7 +448,13 @@ nf_nat_alloc_null_binding(struct nf_conn *ct, unsigned int hooknum)
448 .min_addr = ip, 448 .min_addr = ip,
449 .max_addr = ip, 449 .max_addr = ip,
450 }; 450 };
451 return nf_nat_setup_info(ct, &range, HOOK2MANIP(hooknum)); 451 return nf_nat_setup_info(ct, &range, manip);
452}
453
454unsigned int
455nf_nat_alloc_null_binding(struct nf_conn *ct, unsigned int hooknum)
456{
457 return __nf_nat_alloc_null_binding(ct, HOOK2MANIP(hooknum));
452} 458}
453EXPORT_SYMBOL_GPL(nf_nat_alloc_null_binding); 459EXPORT_SYMBOL_GPL(nf_nat_alloc_null_binding);
454 460
@@ -702,9 +708,9 @@ static const struct nla_policy nat_nla_policy[CTA_NAT_MAX+1] = {
702 708
703static int 709static int
704nfnetlink_parse_nat(const struct nlattr *nat, 710nfnetlink_parse_nat(const struct nlattr *nat,
705 const struct nf_conn *ct, struct nf_nat_range *range) 711 const struct nf_conn *ct, struct nf_nat_range *range,
712 const struct nf_nat_l3proto *l3proto)
706{ 713{
707 const struct nf_nat_l3proto *l3proto;
708 struct nlattr *tb[CTA_NAT_MAX+1]; 714 struct nlattr *tb[CTA_NAT_MAX+1];
709 int err; 715 int err;
710 716
@@ -714,38 +720,46 @@ nfnetlink_parse_nat(const struct nlattr *nat,
714 if (err < 0) 720 if (err < 0)
715 return err; 721 return err;
716 722
717 rcu_read_lock();
718 l3proto = __nf_nat_l3proto_find(nf_ct_l3num(ct));
719 if (l3proto == NULL) {
720 err = -EAGAIN;
721 goto out;
722 }
723 err = l3proto->nlattr_to_range(tb, range); 723 err = l3proto->nlattr_to_range(tb, range);
724 if (err < 0) 724 if (err < 0)
725 goto out; 725 return err;
726 726
727 if (!tb[CTA_NAT_PROTO]) 727 if (!tb[CTA_NAT_PROTO])
728 goto out; 728 return 0;
729 729
730 err = nfnetlink_parse_nat_proto(tb[CTA_NAT_PROTO], ct, range); 730 return nfnetlink_parse_nat_proto(tb[CTA_NAT_PROTO], ct, range);
731out:
732 rcu_read_unlock();
733 return err;
734} 731}
735 732
733/* This function is called under rcu_read_lock() */
736static int 734static int
737nfnetlink_parse_nat_setup(struct nf_conn *ct, 735nfnetlink_parse_nat_setup(struct nf_conn *ct,
738 enum nf_nat_manip_type manip, 736 enum nf_nat_manip_type manip,
739 const struct nlattr *attr) 737 const struct nlattr *attr)
740{ 738{
741 struct nf_nat_range range; 739 struct nf_nat_range range;
740 const struct nf_nat_l3proto *l3proto;
742 int err; 741 int err;
743 742
744 err = nfnetlink_parse_nat(attr, ct, &range); 743 /* Should not happen, restricted to creating new conntracks
744 * via ctnetlink.
745 */
746 if (WARN_ON_ONCE(nf_nat_initialized(ct, manip)))
747 return -EEXIST;
748
749 /* Make sure that L3 NAT is there by when we call nf_nat_setup_info to
750 * attach the null binding, otherwise this may oops.
751 */
752 l3proto = __nf_nat_l3proto_find(nf_ct_l3num(ct));
753 if (l3proto == NULL)
754 return -EAGAIN;
755
756 /* No NAT information has been passed, allocate the null-binding */
757 if (attr == NULL)
758 return __nf_nat_alloc_null_binding(ct, manip);
759
760 err = nfnetlink_parse_nat(attr, ct, &range, l3proto);
745 if (err < 0) 761 if (err < 0)
746 return err; 762 return err;
747 if (nf_nat_initialized(ct, manip))
748 return -EEXIST;
749 763
750 return nf_nat_setup_info(ct, &range, manip); 764 return nf_nat_setup_info(ct, &range, manip);
751} 765}
diff --git a/net/netfilter/nft_meta.c b/net/netfilter/nft_meta.c
index e8254ad2e5a9..425cf39af890 100644
--- a/net/netfilter/nft_meta.c
+++ b/net/netfilter/nft_meta.c
@@ -116,7 +116,7 @@ static void nft_meta_get_eval(const struct nft_expr *expr,
116 skb->sk->sk_socket->file->f_cred->fsgid); 116 skb->sk->sk_socket->file->f_cred->fsgid);
117 read_unlock_bh(&skb->sk->sk_callback_lock); 117 read_unlock_bh(&skb->sk->sk_callback_lock);
118 break; 118 break;
119#ifdef CONFIG_NET_CLS_ROUTE 119#ifdef CONFIG_IP_ROUTE_CLASSID
120 case NFT_META_RTCLASSID: { 120 case NFT_META_RTCLASSID: {
121 const struct dst_entry *dst = skb_dst(skb); 121 const struct dst_entry *dst = skb_dst(skb);
122 122
@@ -199,7 +199,7 @@ static int nft_meta_init_validate_get(uint32_t key)
199 case NFT_META_OIFTYPE: 199 case NFT_META_OIFTYPE:
200 case NFT_META_SKUID: 200 case NFT_META_SKUID:
201 case NFT_META_SKGID: 201 case NFT_META_SKGID:
202#ifdef CONFIG_NET_CLS_ROUTE 202#ifdef CONFIG_IP_ROUTE_CLASSID
203 case NFT_META_RTCLASSID: 203 case NFT_META_RTCLASSID:
204#endif 204#endif
205#ifdef CONFIG_NETWORK_SECMARK 205#ifdef CONFIG_NETWORK_SECMARK
diff --git a/net/netfilter/nft_payload.c b/net/netfilter/nft_payload.c
index a2aeb318678f..85daa84bfdfe 100644
--- a/net/netfilter/nft_payload.c
+++ b/net/netfilter/nft_payload.c
@@ -135,7 +135,8 @@ nft_payload_select_ops(const struct nft_ctx *ctx,
135 if (len == 0 || len > FIELD_SIZEOF(struct nft_data, data)) 135 if (len == 0 || len > FIELD_SIZEOF(struct nft_data, data))
136 return ERR_PTR(-EINVAL); 136 return ERR_PTR(-EINVAL);
137 137
138 if (len <= 4 && IS_ALIGNED(offset, len) && base != NFT_PAYLOAD_LL_HEADER) 138 if (len <= 4 && is_power_of_2(len) && IS_ALIGNED(offset, len) &&
139 base != NFT_PAYLOAD_LL_HEADER)
139 return &nft_payload_fast_ops; 140 return &nft_payload_fast_ops;
140 else 141 else
141 return &nft_payload_ops; 142 return &nft_payload_ops;
diff --git a/net/netfilter/nft_reject_inet.c b/net/netfilter/nft_reject_inet.c
index 8a310f239c93..b718a52a4654 100644
--- a/net/netfilter/nft_reject_inet.c
+++ b/net/netfilter/nft_reject_inet.c
@@ -21,9 +21,9 @@ static void nft_reject_inet_eval(const struct nft_expr *expr,
21{ 21{
22 switch (pkt->ops->pf) { 22 switch (pkt->ops->pf) {
23 case NFPROTO_IPV4: 23 case NFPROTO_IPV4:
24 nft_reject_ipv4_eval(expr, data, pkt); 24 return nft_reject_ipv4_eval(expr, data, pkt);
25 case NFPROTO_IPV6: 25 case NFPROTO_IPV6:
26 nft_reject_ipv6_eval(expr, data, pkt); 26 return nft_reject_ipv6_eval(expr, data, pkt);
27 } 27 }
28} 28}
29 29
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index e42214b932c3..9db8bab27fa2 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -1489,8 +1489,8 @@ static int netlink_connect(struct socket *sock, struct sockaddr *addr,
1489 if (addr->sa_family != AF_NETLINK) 1489 if (addr->sa_family != AF_NETLINK)
1490 return -EINVAL; 1490 return -EINVAL;
1491 1491
1492 /* Only superuser is allowed to send multicasts */ 1492 if ((nladdr->nl_groups || nladdr->nl_pid) &&
1493 if (nladdr->nl_groups && !netlink_capable(sock, NL_CFG_F_NONROOT_SEND)) 1493 !netlink_capable(sock, NL_CFG_F_NONROOT_SEND))
1494 return -EPERM; 1494 return -EPERM;
1495 1495
1496 if (!nlk->portid) 1496 if (!nlk->portid)
diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c
index 46bda010bf11..56db888b1cd5 100644
--- a/net/nfc/nci/core.c
+++ b/net/nfc/nci/core.c
@@ -301,7 +301,7 @@ static int nci_open_device(struct nci_dev *ndev)
301 rc = __nci_request(ndev, nci_reset_req, 0, 301 rc = __nci_request(ndev, nci_reset_req, 0,
302 msecs_to_jiffies(NCI_RESET_TIMEOUT)); 302 msecs_to_jiffies(NCI_RESET_TIMEOUT));
303 303
304 if (ndev->ops->setup(ndev)) 304 if (ndev->ops->setup)
305 ndev->ops->setup(ndev); 305 ndev->ops->setup(ndev);
306 306
307 if (!rc) { 307 if (!rc) {
diff --git a/net/sched/sch_tbf.c b/net/sched/sch_tbf.c
index 0893161b0262..87a02bfa707b 100644
--- a/net/sched/sch_tbf.c
+++ b/net/sched/sch_tbf.c
@@ -338,18 +338,6 @@ static int tbf_change(struct Qdisc *sch, struct nlattr *opt)
338 qdisc_put_rtab(qdisc_get_rtab(&qopt->peakrate, 338 qdisc_put_rtab(qdisc_get_rtab(&qopt->peakrate,
339 tb[TCA_TBF_PTAB])); 339 tb[TCA_TBF_PTAB]));
340 340
341 if (q->qdisc != &noop_qdisc) {
342 err = fifo_set_limit(q->qdisc, qopt->limit);
343 if (err)
344 goto done;
345 } else if (qopt->limit > 0) {
346 child = fifo_create_dflt(sch, &bfifo_qdisc_ops, qopt->limit);
347 if (IS_ERR(child)) {
348 err = PTR_ERR(child);
349 goto done;
350 }
351 }
352
353 buffer = min_t(u64, PSCHED_TICKS2NS(qopt->buffer), ~0U); 341 buffer = min_t(u64, PSCHED_TICKS2NS(qopt->buffer), ~0U);
354 mtu = min_t(u64, PSCHED_TICKS2NS(qopt->mtu), ~0U); 342 mtu = min_t(u64, PSCHED_TICKS2NS(qopt->mtu), ~0U);
355 343
@@ -396,6 +384,18 @@ static int tbf_change(struct Qdisc *sch, struct nlattr *opt)
396 goto done; 384 goto done;
397 } 385 }
398 386
387 if (q->qdisc != &noop_qdisc) {
388 err = fifo_set_limit(q->qdisc, qopt->limit);
389 if (err)
390 goto done;
391 } else if (qopt->limit > 0) {
392 child = fifo_create_dflt(sch, &bfifo_qdisc_ops, qopt->limit);
393 if (IS_ERR(child)) {
394 err = PTR_ERR(child);
395 goto done;
396 }
397 }
398
399 sch_tree_lock(sch); 399 sch_tree_lock(sch);
400 if (child) { 400 if (child) {
401 qdisc_tree_decrease_qlen(q->qdisc, q->qdisc->q.qlen); 401 qdisc_tree_decrease_qlen(q->qdisc, q->qdisc->q.qlen);
diff --git a/net/sctp/associola.c b/net/sctp/associola.c
index f558433537b8..ee13d28d39d1 100644
--- a/net/sctp/associola.c
+++ b/net/sctp/associola.c
@@ -1239,78 +1239,107 @@ void sctp_assoc_update(struct sctp_association *asoc,
1239} 1239}
1240 1240
1241/* Update the retran path for sending a retransmitted packet. 1241/* Update the retran path for sending a retransmitted packet.
1242 * Round-robin through the active transports, else round-robin 1242 * See also RFC4960, 6.4. Multi-Homed SCTP Endpoints:
1243 * through the inactive transports as this is the next best thing 1243 *
1244 * we can try. 1244 * When there is outbound data to send and the primary path
1245 * becomes inactive (e.g., due to failures), or where the
1246 * SCTP user explicitly requests to send data to an
1247 * inactive destination transport address, before reporting
1248 * an error to its ULP, the SCTP endpoint should try to send
1249 * the data to an alternate active destination transport
1250 * address if one exists.
1251 *
1252 * When retransmitting data that timed out, if the endpoint
1253 * is multihomed, it should consider each source-destination
1254 * address pair in its retransmission selection policy.
1255 * When retransmitting timed-out data, the endpoint should
1256 * attempt to pick the most divergent source-destination
1257 * pair from the original source-destination pair to which
1258 * the packet was transmitted.
1259 *
1260 * Note: Rules for picking the most divergent source-destination
1261 * pair are an implementation decision and are not specified
1262 * within this document.
1263 *
1264 * Our basic strategy is to round-robin transports in priorities
1265 * according to sctp_state_prio_map[] e.g., if no such
1266 * transport with state SCTP_ACTIVE exists, round-robin through
1267 * SCTP_UNKNOWN, etc. You get the picture.
1245 */ 1268 */
1246void sctp_assoc_update_retran_path(struct sctp_association *asoc) 1269static const u8 sctp_trans_state_to_prio_map[] = {
1270 [SCTP_ACTIVE] = 3, /* best case */
1271 [SCTP_UNKNOWN] = 2,
1272 [SCTP_PF] = 1,
1273 [SCTP_INACTIVE] = 0, /* worst case */
1274};
1275
1276static u8 sctp_trans_score(const struct sctp_transport *trans)
1247{ 1277{
1248 struct sctp_transport *t, *next; 1278 return sctp_trans_state_to_prio_map[trans->state];
1249 struct list_head *head = &asoc->peer.transport_addr_list; 1279}
1250 struct list_head *pos;
1251 1280
1252 if (asoc->peer.transport_count == 1) 1281static struct sctp_transport *sctp_trans_elect_best(struct sctp_transport *curr,
1253 return; 1282 struct sctp_transport *best)
1283{
1284 if (best == NULL)
1285 return curr;
1254 1286
1255 /* Find the next transport in a round-robin fashion. */ 1287 return sctp_trans_score(curr) > sctp_trans_score(best) ? curr : best;
1256 t = asoc->peer.retran_path; 1288}
1257 pos = &t->transports;
1258 next = NULL;
1259 1289
1260 while (1) { 1290void sctp_assoc_update_retran_path(struct sctp_association *asoc)
1261 /* Skip the head. */ 1291{
1262 if (pos->next == head) 1292 struct sctp_transport *trans = asoc->peer.retran_path;
1263 pos = head->next; 1293 struct sctp_transport *trans_next = NULL;
1264 else
1265 pos = pos->next;
1266 1294
1267 t = list_entry(pos, struct sctp_transport, transports); 1295 /* We're done as we only have the one and only path. */
1296 if (asoc->peer.transport_count == 1)
1297 return;
1298 /* If active_path and retran_path are the same and active,
1299 * then this is the only active path. Use it.
1300 */
1301 if (asoc->peer.active_path == asoc->peer.retran_path &&
1302 asoc->peer.active_path->state == SCTP_ACTIVE)
1303 return;
1268 1304
1269 /* We have exhausted the list, but didn't find any 1305 /* Iterate from retran_path's successor back to retran_path. */
1270 * other active transports. If so, use the next 1306 for (trans = list_next_entry(trans, transports); 1;
1271 * transport. 1307 trans = list_next_entry(trans, transports)) {
1272 */ 1308 /* Manually skip the head element. */
1273 if (t == asoc->peer.retran_path) { 1309 if (&trans->transports == &asoc->peer.transport_addr_list)
1274 t = next; 1310 continue;
1311 if (trans->state == SCTP_UNCONFIRMED)
1312 continue;
1313 trans_next = sctp_trans_elect_best(trans, trans_next);
1314 /* Active is good enough for immediate return. */
1315 if (trans_next->state == SCTP_ACTIVE)
1275 break; 1316 break;
1276 } 1317 /* We've reached the end, time to update path. */
1277 1318 if (trans == asoc->peer.retran_path)
1278 /* Try to find an active transport. */
1279
1280 if ((t->state == SCTP_ACTIVE) ||
1281 (t->state == SCTP_UNKNOWN)) {
1282 break; 1319 break;
1283 } else {
1284 /* Keep track of the next transport in case
1285 * we don't find any active transport.
1286 */
1287 if (t->state != SCTP_UNCONFIRMED && !next)
1288 next = t;
1289 }
1290 } 1320 }
1291 1321
1292 if (t) 1322 if (trans_next != NULL)
1293 asoc->peer.retran_path = t; 1323 asoc->peer.retran_path = trans_next;
1294 else
1295 t = asoc->peer.retran_path;
1296 1324
1297 pr_debug("%s: association:%p addr:%pISpc\n", __func__, asoc, 1325 pr_debug("%s: association:%p updated new path to addr:%pISpc\n",
1298 &t->ipaddr.sa); 1326 __func__, asoc, &asoc->peer.retran_path->ipaddr.sa);
1299} 1327}
1300 1328
1301/* Choose the transport for sending retransmit packet. */ 1329struct sctp_transport *
1302struct sctp_transport *sctp_assoc_choose_alter_transport( 1330sctp_assoc_choose_alter_transport(struct sctp_association *asoc,
1303 struct sctp_association *asoc, struct sctp_transport *last_sent_to) 1331 struct sctp_transport *last_sent_to)
1304{ 1332{
1305 /* If this is the first time packet is sent, use the active path, 1333 /* If this is the first time packet is sent, use the active path,
1306 * else use the retran path. If the last packet was sent over the 1334 * else use the retran path. If the last packet was sent over the
1307 * retran path, update the retran path and use it. 1335 * retran path, update the retran path and use it.
1308 */ 1336 */
1309 if (!last_sent_to) 1337 if (last_sent_to == NULL) {
1310 return asoc->peer.active_path; 1338 return asoc->peer.active_path;
1311 else { 1339 } else {
1312 if (last_sent_to == asoc->peer.retran_path) 1340 if (last_sent_to == asoc->peer.retran_path)
1313 sctp_assoc_update_retran_path(asoc); 1341 sctp_assoc_update_retran_path(asoc);
1342
1314 return asoc->peer.retran_path; 1343 return asoc->peer.retran_path;
1315 } 1344 }
1316} 1345}
diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
index bd859154000e..5d6883ff00c3 100644
--- a/net/sctp/sm_sideeffect.c
+++ b/net/sctp/sm_sideeffect.c
@@ -495,11 +495,12 @@ static void sctp_do_8_2_transport_strike(sctp_cmd_seq_t *commands,
495 } 495 }
496 496
497 /* If the transport error count is greater than the pf_retrans 497 /* If the transport error count is greater than the pf_retrans
498 * threshold, and less than pathmaxrtx, then mark this transport 498 * threshold, and less than pathmaxrtx, and if the current state
499 * as Partially Failed, ee SCTP Quick Failover Draft, secon 5.1, 499 * is not SCTP_UNCONFIRMED, then mark this transport as Partially
500 * point 1 500 * Failed, see SCTP Quick Failover Draft, section 5.1
501 */ 501 */
502 if ((transport->state != SCTP_PF) && 502 if ((transport->state != SCTP_PF) &&
503 (transport->state != SCTP_UNCONFIRMED) &&
503 (asoc->pf_retrans < transport->pathmaxrxt) && 504 (asoc->pf_retrans < transport->pathmaxrxt) &&
504 (transport->error_count > asoc->pf_retrans)) { 505 (transport->error_count > asoc->pf_retrans)) {
505 506
diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c
index 591b44d3b7de..ae65b6b5973a 100644
--- a/net/sctp/sm_statefuns.c
+++ b/net/sctp/sm_statefuns.c
@@ -758,6 +758,13 @@ sctp_disposition_t sctp_sf_do_5_1D_ce(struct net *net,
758 struct sctp_chunk auth; 758 struct sctp_chunk auth;
759 sctp_ierror_t ret; 759 sctp_ierror_t ret;
760 760
761 /* Make sure that we and the peer are AUTH capable */
762 if (!net->sctp.auth_enable || !new_asoc->peer.auth_capable) {
763 kfree_skb(chunk->auth_chunk);
764 sctp_association_free(new_asoc);
765 return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands);
766 }
767
761 /* set-up our fake chunk so that we can process it */ 768 /* set-up our fake chunk so that we can process it */
762 auth.skb = chunk->auth_chunk; 769 auth.skb = chunk->auth_chunk;
763 auth.asoc = chunk->asoc; 770 auth.asoc = chunk->asoc;
diff --git a/net/sunrpc/auth_gss/auth_gss.c b/net/sunrpc/auth_gss/auth_gss.c
index 6c0513a7f992..36e431ee1c90 100644
--- a/net/sunrpc/auth_gss/auth_gss.c
+++ b/net/sunrpc/auth_gss/auth_gss.c
@@ -108,6 +108,7 @@ struct gss_auth {
108static DEFINE_SPINLOCK(pipe_version_lock); 108static DEFINE_SPINLOCK(pipe_version_lock);
109static struct rpc_wait_queue pipe_version_rpc_waitqueue; 109static struct rpc_wait_queue pipe_version_rpc_waitqueue;
110static DECLARE_WAIT_QUEUE_HEAD(pipe_version_waitqueue); 110static DECLARE_WAIT_QUEUE_HEAD(pipe_version_waitqueue);
111static void gss_put_auth(struct gss_auth *gss_auth);
111 112
112static void gss_free_ctx(struct gss_cl_ctx *); 113static void gss_free_ctx(struct gss_cl_ctx *);
113static const struct rpc_pipe_ops gss_upcall_ops_v0; 114static const struct rpc_pipe_ops gss_upcall_ops_v0;
@@ -320,6 +321,7 @@ gss_release_msg(struct gss_upcall_msg *gss_msg)
320 if (gss_msg->ctx != NULL) 321 if (gss_msg->ctx != NULL)
321 gss_put_ctx(gss_msg->ctx); 322 gss_put_ctx(gss_msg->ctx);
322 rpc_destroy_wait_queue(&gss_msg->rpc_waitqueue); 323 rpc_destroy_wait_queue(&gss_msg->rpc_waitqueue);
324 gss_put_auth(gss_msg->auth);
323 kfree(gss_msg); 325 kfree(gss_msg);
324} 326}
325 327
@@ -498,9 +500,12 @@ gss_alloc_msg(struct gss_auth *gss_auth,
498 default: 500 default:
499 err = gss_encode_v1_msg(gss_msg, service_name, gss_auth->target_name); 501 err = gss_encode_v1_msg(gss_msg, service_name, gss_auth->target_name);
500 if (err) 502 if (err)
501 goto err_free_msg; 503 goto err_put_pipe_version;
502 }; 504 };
505 kref_get(&gss_auth->kref);
503 return gss_msg; 506 return gss_msg;
507err_put_pipe_version:
508 put_pipe_version(gss_auth->net);
504err_free_msg: 509err_free_msg:
505 kfree(gss_msg); 510 kfree(gss_msg);
506err: 511err:
@@ -991,6 +996,8 @@ gss_create_new(struct rpc_auth_create_args *args, struct rpc_clnt *clnt)
991 gss_auth->service = gss_pseudoflavor_to_service(gss_auth->mech, flavor); 996 gss_auth->service = gss_pseudoflavor_to_service(gss_auth->mech, flavor);
992 if (gss_auth->service == 0) 997 if (gss_auth->service == 0)
993 goto err_put_mech; 998 goto err_put_mech;
999 if (!gssd_running(gss_auth->net))
1000 goto err_put_mech;
994 auth = &gss_auth->rpc_auth; 1001 auth = &gss_auth->rpc_auth;
995 auth->au_cslack = GSS_CRED_SLACK >> 2; 1002 auth->au_cslack = GSS_CRED_SLACK >> 2;
996 auth->au_rslack = GSS_VERF_SLACK >> 2; 1003 auth->au_rslack = GSS_VERF_SLACK >> 2;
@@ -1062,6 +1069,12 @@ gss_free_callback(struct kref *kref)
1062} 1069}
1063 1070
1064static void 1071static void
1072gss_put_auth(struct gss_auth *gss_auth)
1073{
1074 kref_put(&gss_auth->kref, gss_free_callback);
1075}
1076
1077static void
1065gss_destroy(struct rpc_auth *auth) 1078gss_destroy(struct rpc_auth *auth)
1066{ 1079{
1067 struct gss_auth *gss_auth = container_of(auth, 1080 struct gss_auth *gss_auth = container_of(auth,
@@ -1082,7 +1095,7 @@ gss_destroy(struct rpc_auth *auth)
1082 gss_auth->gss_pipe[1] = NULL; 1095 gss_auth->gss_pipe[1] = NULL;
1083 rpcauth_destroy_credcache(auth); 1096 rpcauth_destroy_credcache(auth);
1084 1097
1085 kref_put(&gss_auth->kref, gss_free_callback); 1098 gss_put_auth(gss_auth);
1086} 1099}
1087 1100
1088/* 1101/*
@@ -1253,7 +1266,7 @@ gss_destroy_nullcred(struct rpc_cred *cred)
1253 call_rcu(&cred->cr_rcu, gss_free_cred_callback); 1266 call_rcu(&cred->cr_rcu, gss_free_cred_callback);
1254 if (ctx) 1267 if (ctx)
1255 gss_put_ctx(ctx); 1268 gss_put_ctx(ctx);
1256 kref_put(&gss_auth->kref, gss_free_callback); 1269 gss_put_auth(gss_auth);
1257} 1270}
1258 1271
1259static void 1272static void
diff --git a/net/sunrpc/backchannel_rqst.c b/net/sunrpc/backchannel_rqst.c
index 890a29912d5a..e860d4f7ed2a 100644
--- a/net/sunrpc/backchannel_rqst.c
+++ b/net/sunrpc/backchannel_rqst.c
@@ -64,7 +64,6 @@ static void xprt_free_allocation(struct rpc_rqst *req)
64 free_page((unsigned long)xbufp->head[0].iov_base); 64 free_page((unsigned long)xbufp->head[0].iov_base);
65 xbufp = &req->rq_snd_buf; 65 xbufp = &req->rq_snd_buf;
66 free_page((unsigned long)xbufp->head[0].iov_base); 66 free_page((unsigned long)xbufp->head[0].iov_base);
67 list_del(&req->rq_bc_pa_list);
68 kfree(req); 67 kfree(req);
69} 68}
70 69
@@ -168,8 +167,10 @@ out_free:
168 /* 167 /*
169 * Memory allocation failed, free the temporary list 168 * Memory allocation failed, free the temporary list
170 */ 169 */
171 list_for_each_entry_safe(req, tmp, &tmp_list, rq_bc_pa_list) 170 list_for_each_entry_safe(req, tmp, &tmp_list, rq_bc_pa_list) {
171 list_del(&req->rq_bc_pa_list);
172 xprt_free_allocation(req); 172 xprt_free_allocation(req);
173 }
173 174
174 dprintk("RPC: setup backchannel transport failed\n"); 175 dprintk("RPC: setup backchannel transport failed\n");
175 return -ENOMEM; 176 return -ENOMEM;
@@ -198,6 +199,7 @@ void xprt_destroy_backchannel(struct rpc_xprt *xprt, unsigned int max_reqs)
198 xprt_dec_alloc_count(xprt, max_reqs); 199 xprt_dec_alloc_count(xprt, max_reqs);
199 list_for_each_entry_safe(req, tmp, &xprt->bc_pa_list, rq_bc_pa_list) { 200 list_for_each_entry_safe(req, tmp, &xprt->bc_pa_list, rq_bc_pa_list) {
200 dprintk("RPC: req=%p\n", req); 201 dprintk("RPC: req=%p\n", req);
202 list_del(&req->rq_bc_pa_list);
201 xprt_free_allocation(req); 203 xprt_free_allocation(req);
202 if (--max_reqs == 0) 204 if (--max_reqs == 0)
203 break; 205 break;
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
index 817a1e523969..0addefca8e77 100644
--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@ -510,6 +510,7 @@ static int xs_nospace(struct rpc_task *task)
510 struct rpc_rqst *req = task->tk_rqstp; 510 struct rpc_rqst *req = task->tk_rqstp;
511 struct rpc_xprt *xprt = req->rq_xprt; 511 struct rpc_xprt *xprt = req->rq_xprt;
512 struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt); 512 struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt);
513 struct sock *sk = transport->inet;
513 int ret = -EAGAIN; 514 int ret = -EAGAIN;
514 515
515 dprintk("RPC: %5u xmit incomplete (%u left of %u)\n", 516 dprintk("RPC: %5u xmit incomplete (%u left of %u)\n",
@@ -527,7 +528,7 @@ static int xs_nospace(struct rpc_task *task)
527 * window size 528 * window size
528 */ 529 */
529 set_bit(SOCK_NOSPACE, &transport->sock->flags); 530 set_bit(SOCK_NOSPACE, &transport->sock->flags);
530 transport->inet->sk_write_pending++; 531 sk->sk_write_pending++;
531 /* ...and wait for more buffer space */ 532 /* ...and wait for more buffer space */
532 xprt_wait_for_buffer_space(task, xs_nospace_callback); 533 xprt_wait_for_buffer_space(task, xs_nospace_callback);
533 } 534 }
@@ -537,6 +538,9 @@ static int xs_nospace(struct rpc_task *task)
537 } 538 }
538 539
539 spin_unlock_bh(&xprt->transport_lock); 540 spin_unlock_bh(&xprt->transport_lock);
541
542 /* Race breaker in case memory is freed before above code is called */
543 sk->sk_write_space(sk);
540 return ret; 544 return ret;
541} 545}
542 546
diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c
index 242cddd35a47..89c4c2d23ac0 100644
--- a/net/tipc/bearer.c
+++ b/net/tipc/bearer.c
@@ -586,8 +586,13 @@ static struct notifier_block notifier = {
586 586
587int tipc_bearer_setup(void) 587int tipc_bearer_setup(void)
588{ 588{
589 int err;
590
591 err = register_netdevice_notifier(&notifier);
592 if (err)
593 return err;
589 dev_add_pack(&tipc_packet_type); 594 dev_add_pack(&tipc_packet_type);
590 return register_netdevice_notifier(&notifier); 595 return 0;
591} 596}
592 597
593void tipc_bearer_cleanup(void) 598void tipc_bearer_cleanup(void)
diff --git a/net/tipc/config.c b/net/tipc/config.c
index c301a9a592d8..e74eef2e7490 100644
--- a/net/tipc/config.c
+++ b/net/tipc/config.c
@@ -181,7 +181,7 @@ static struct sk_buff *cfg_set_own_addr(void)
181 if (tipc_own_addr) 181 if (tipc_own_addr)
182 return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED 182 return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED
183 " (cannot change node address once assigned)"); 183 " (cannot change node address once assigned)");
184 tipc_core_start_net(addr); 184 tipc_net_start(addr);
185 return tipc_cfg_reply_none(); 185 return tipc_cfg_reply_none();
186} 186}
187 187
diff --git a/net/tipc/core.c b/net/tipc/core.c
index 3f76b98d2fed..e2491b341edb 100644
--- a/net/tipc/core.c
+++ b/net/tipc/core.c
@@ -77,37 +77,13 @@ struct sk_buff *tipc_buf_acquire(u32 size)
77} 77}
78 78
79/** 79/**
80 * tipc_core_stop_net - shut down TIPC networking sub-systems
81 */
82static void tipc_core_stop_net(void)
83{
84 tipc_net_stop();
85 tipc_bearer_cleanup();
86}
87
88/**
89 * start_net - start TIPC networking sub-systems
90 */
91int tipc_core_start_net(unsigned long addr)
92{
93 int res;
94
95 tipc_net_start(addr);
96 res = tipc_bearer_setup();
97 if (res < 0)
98 goto err;
99 return res;
100
101err:
102 tipc_core_stop_net();
103 return res;
104}
105
106/**
107 * tipc_core_stop - switch TIPC from SINGLE NODE to NOT RUNNING mode 80 * tipc_core_stop - switch TIPC from SINGLE NODE to NOT RUNNING mode
108 */ 81 */
109static void tipc_core_stop(void) 82static void tipc_core_stop(void)
110{ 83{
84 tipc_handler_stop();
85 tipc_net_stop();
86 tipc_bearer_cleanup();
111 tipc_netlink_stop(); 87 tipc_netlink_stop();
112 tipc_cfg_stop(); 88 tipc_cfg_stop();
113 tipc_subscr_stop(); 89 tipc_subscr_stop();
@@ -122,30 +98,65 @@ static void tipc_core_stop(void)
122 */ 98 */
123static int tipc_core_start(void) 99static int tipc_core_start(void)
124{ 100{
125 int res; 101 int err;
126 102
127 get_random_bytes(&tipc_random, sizeof(tipc_random)); 103 get_random_bytes(&tipc_random, sizeof(tipc_random));
128 104
129 res = tipc_handler_start(); 105 err = tipc_handler_start();
130 if (!res) 106 if (err)
131 res = tipc_ref_table_init(tipc_max_ports, tipc_random); 107 goto out_handler;
132 if (!res) 108
133 res = tipc_nametbl_init(); 109 err = tipc_ref_table_init(tipc_max_ports, tipc_random);
134 if (!res) 110 if (err)
135 res = tipc_netlink_start(); 111 goto out_reftbl;
136 if (!res) 112
137 res = tipc_socket_init(); 113 err = tipc_nametbl_init();
138 if (!res) 114 if (err)
139 res = tipc_register_sysctl(); 115 goto out_nametbl;
140 if (!res) 116
141 res = tipc_subscr_start(); 117 err = tipc_netlink_start();
142 if (!res) 118 if (err)
143 res = tipc_cfg_init(); 119 goto out_netlink;
144 if (res) { 120
145 tipc_handler_stop(); 121 err = tipc_socket_init();
146 tipc_core_stop(); 122 if (err)
147 } 123 goto out_socket;
148 return res; 124
125 err = tipc_register_sysctl();
126 if (err)
127 goto out_sysctl;
128
129 err = tipc_subscr_start();
130 if (err)
131 goto out_subscr;
132
133 err = tipc_cfg_init();
134 if (err)
135 goto out_cfg;
136
137 err = tipc_bearer_setup();
138 if (err)
139 goto out_bearer;
140
141 return 0;
142out_bearer:
143 tipc_cfg_stop();
144out_cfg:
145 tipc_subscr_stop();
146out_subscr:
147 tipc_unregister_sysctl();
148out_sysctl:
149 tipc_socket_stop();
150out_socket:
151 tipc_netlink_stop();
152out_netlink:
153 tipc_nametbl_stop();
154out_nametbl:
155 tipc_ref_table_stop();
156out_reftbl:
157 tipc_handler_stop();
158out_handler:
159 return err;
149} 160}
150 161
151static int __init tipc_init(void) 162static int __init tipc_init(void)
@@ -174,8 +185,6 @@ static int __init tipc_init(void)
174 185
175static void __exit tipc_exit(void) 186static void __exit tipc_exit(void)
176{ 187{
177 tipc_handler_stop();
178 tipc_core_stop_net();
179 tipc_core_stop(); 188 tipc_core_stop();
180 pr_info("Deactivated\n"); 189 pr_info("Deactivated\n");
181} 190}
diff --git a/net/tipc/core.h b/net/tipc/core.h
index 5569d96b4da3..4dfe137587bb 100644
--- a/net/tipc/core.h
+++ b/net/tipc/core.h
@@ -90,7 +90,6 @@ extern int tipc_random __read_mostly;
90/* 90/*
91 * Routines available to privileged subsystems 91 * Routines available to privileged subsystems
92 */ 92 */
93int tipc_core_start_net(unsigned long);
94int tipc_handler_start(void); 93int tipc_handler_start(void);
95void tipc_handler_stop(void); 94void tipc_handler_stop(void);
96int tipc_netlink_start(void); 95int tipc_netlink_start(void);
diff --git a/net/tipc/name_table.c b/net/tipc/name_table.c
index 92a1533af4e0..48302be175ce 100644
--- a/net/tipc/name_table.c
+++ b/net/tipc/name_table.c
@@ -945,9 +945,6 @@ void tipc_nametbl_stop(void)
945{ 945{
946 u32 i; 946 u32 i;
947 947
948 if (!table.types)
949 return;
950
951 /* Verify name table is empty, then release it */ 948 /* Verify name table is empty, then release it */
952 write_lock_bh(&tipc_nametbl_lock); 949 write_lock_bh(&tipc_nametbl_lock);
953 for (i = 0; i < TIPC_NAMETBL_SIZE; i++) { 950 for (i = 0; i < TIPC_NAMETBL_SIZE; i++) {
diff --git a/net/tipc/netlink.c b/net/tipc/netlink.c
index 9f72a6376362..3aaf73de9e2d 100644
--- a/net/tipc/netlink.c
+++ b/net/tipc/netlink.c
@@ -83,8 +83,6 @@ static struct genl_ops tipc_genl_ops[] = {
83 }, 83 },
84}; 84};
85 85
86static int tipc_genl_family_registered;
87
88int tipc_netlink_start(void) 86int tipc_netlink_start(void)
89{ 87{
90 int res; 88 int res;
@@ -94,16 +92,10 @@ int tipc_netlink_start(void)
94 pr_err("Failed to register netlink interface\n"); 92 pr_err("Failed to register netlink interface\n");
95 return res; 93 return res;
96 } 94 }
97
98 tipc_genl_family_registered = 1;
99 return 0; 95 return 0;
100} 96}
101 97
102void tipc_netlink_stop(void) 98void tipc_netlink_stop(void)
103{ 99{
104 if (!tipc_genl_family_registered)
105 return;
106
107 genl_unregister_family(&tipc_genl_family); 100 genl_unregister_family(&tipc_genl_family);
108 tipc_genl_family_registered = 0;
109} 101}
diff --git a/net/tipc/ref.c b/net/tipc/ref.c
index 2a2a938dc22c..de3d593e2fee 100644
--- a/net/tipc/ref.c
+++ b/net/tipc/ref.c
@@ -126,9 +126,6 @@ int tipc_ref_table_init(u32 requested_size, u32 start)
126 */ 126 */
127void tipc_ref_table_stop(void) 127void tipc_ref_table_stop(void)
128{ 128{
129 if (!tipc_ref_table.entries)
130 return;
131
132 vfree(tipc_ref_table.entries); 129 vfree(tipc_ref_table.entries);
133 tipc_ref_table.entries = NULL; 130 tipc_ref_table.entries = NULL;
134} 131}
diff --git a/net/tipc/server.c b/net/tipc/server.c
index b635ca347a87..373979789a73 100644
--- a/net/tipc/server.c
+++ b/net/tipc/server.c
@@ -573,7 +573,6 @@ int tipc_server_start(struct tipc_server *s)
573 kmem_cache_destroy(s->rcvbuf_cache); 573 kmem_cache_destroy(s->rcvbuf_cache);
574 return ret; 574 return ret;
575 } 575 }
576 s->enabled = 1;
577 return ret; 576 return ret;
578} 577}
579 578
@@ -583,10 +582,6 @@ void tipc_server_stop(struct tipc_server *s)
583 int total = 0; 582 int total = 0;
584 int id; 583 int id;
585 584
586 if (!s->enabled)
587 return;
588
589 s->enabled = 0;
590 spin_lock_bh(&s->idr_lock); 585 spin_lock_bh(&s->idr_lock);
591 for (id = 0; total < s->idr_in_use; id++) { 586 for (id = 0; total < s->idr_in_use; id++) {
592 con = idr_find(&s->conn_idr, id); 587 con = idr_find(&s->conn_idr, id);
diff --git a/net/tipc/server.h b/net/tipc/server.h
index 98b23f20bc0f..be817b0b547e 100644
--- a/net/tipc/server.h
+++ b/net/tipc/server.h
@@ -56,7 +56,6 @@
56 * @name: server name 56 * @name: server name
57 * @imp: message importance 57 * @imp: message importance
58 * @type: socket type 58 * @type: socket type
59 * @enabled: identify whether server is launched or not
60 */ 59 */
61struct tipc_server { 60struct tipc_server {
62 struct idr conn_idr; 61 struct idr conn_idr;
@@ -74,7 +73,6 @@ struct tipc_server {
74 const char name[TIPC_SERVER_NAME_LEN]; 73 const char name[TIPC_SERVER_NAME_LEN];
75 int imp; 74 int imp;
76 int type; 75 int type;
77 int enabled;
78}; 76};
79 77
80int tipc_conn_sendmsg(struct tipc_server *s, int conid, 78int tipc_conn_sendmsg(struct tipc_server *s, int conid,
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index fb885977bd2a..336e18d6cf46 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -70,8 +70,6 @@ static const struct proto_ops msg_ops;
70static struct proto tipc_proto; 70static struct proto tipc_proto;
71static struct proto tipc_proto_kern; 71static struct proto tipc_proto_kern;
72 72
73static int sockets_enabled;
74
75/* 73/*
76 * Revised TIPC socket locking policy: 74 * Revised TIPC socket locking policy:
77 * 75 *
@@ -2029,8 +2027,6 @@ int tipc_socket_init(void)
2029 proto_unregister(&tipc_proto); 2027 proto_unregister(&tipc_proto);
2030 goto out; 2028 goto out;
2031 } 2029 }
2032
2033 sockets_enabled = 1;
2034 out: 2030 out:
2035 return res; 2031 return res;
2036} 2032}
@@ -2040,10 +2036,6 @@ int tipc_socket_init(void)
2040 */ 2036 */
2041void tipc_socket_stop(void) 2037void tipc_socket_stop(void)
2042{ 2038{
2043 if (!sockets_enabled)
2044 return;
2045
2046 sockets_enabled = 0;
2047 sock_unregister(tipc_family_ops.family); 2039 sock_unregister(tipc_family_ops.family);
2048 proto_unregister(&tipc_proto); 2040 proto_unregister(&tipc_proto);
2049} 2041}
diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index 27c5253e7a61..24c257cd706b 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -1788,7 +1788,7 @@ static void reg_process_hint(struct regulatory_request *reg_request)
1788 return; 1788 return;
1789 case NL80211_REGDOM_SET_BY_USER: 1789 case NL80211_REGDOM_SET_BY_USER:
1790 treatment = reg_process_hint_user(reg_request); 1790 treatment = reg_process_hint_user(reg_request);
1791 if (treatment == REG_REQ_OK || 1791 if (treatment == REG_REQ_IGNORE ||
1792 treatment == REG_REQ_ALREADY_SET) 1792 treatment == REG_REQ_ALREADY_SET)
1793 return; 1793 return;
1794 queue_delayed_work(system_power_efficient_wq, 1794 queue_delayed_work(system_power_efficient_wq,
@@ -2481,6 +2481,7 @@ static int reg_set_rd_country_ie(const struct ieee80211_regdomain *rd,
2481int set_regdom(const struct ieee80211_regdomain *rd) 2481int set_regdom(const struct ieee80211_regdomain *rd)
2482{ 2482{
2483 struct regulatory_request *lr; 2483 struct regulatory_request *lr;
2484 bool user_reset = false;
2484 int r; 2485 int r;
2485 2486
2486 if (!reg_is_valid_request(rd->alpha2)) { 2487 if (!reg_is_valid_request(rd->alpha2)) {
@@ -2497,6 +2498,7 @@ int set_regdom(const struct ieee80211_regdomain *rd)
2497 break; 2498 break;
2498 case NL80211_REGDOM_SET_BY_USER: 2499 case NL80211_REGDOM_SET_BY_USER:
2499 r = reg_set_rd_user(rd, lr); 2500 r = reg_set_rd_user(rd, lr);
2501 user_reset = true;
2500 break; 2502 break;
2501 case NL80211_REGDOM_SET_BY_DRIVER: 2503 case NL80211_REGDOM_SET_BY_DRIVER:
2502 r = reg_set_rd_driver(rd, lr); 2504 r = reg_set_rd_driver(rd, lr);
@@ -2510,8 +2512,14 @@ int set_regdom(const struct ieee80211_regdomain *rd)
2510 } 2512 }
2511 2513
2512 if (r) { 2514 if (r) {
2513 if (r == -EALREADY) 2515 switch (r) {
2516 case -EALREADY:
2514 reg_set_request_processed(); 2517 reg_set_request_processed();
2518 break;
2519 default:
2520 /* Back to world regulatory in case of errors */
2521 restore_regulatory_settings(user_reset);
2522 }
2515 2523
2516 kfree(rd); 2524 kfree(rd);
2517 return r; 2525 return r;
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index bb3669d973a7..a75fae4b045a 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -1156,7 +1156,7 @@ static struct xfrm_policy *__xfrm_policy_unlink(struct xfrm_policy *pol,
1156 if (hlist_unhashed(&pol->bydst)) 1156 if (hlist_unhashed(&pol->bydst))
1157 return NULL; 1157 return NULL;
1158 1158
1159 hlist_del(&pol->bydst); 1159 hlist_del_init(&pol->bydst);
1160 hlist_del(&pol->byidx); 1160 hlist_del(&pol->byidx);
1161 list_del(&pol->walk.all); 1161 list_del(&pol->walk.all);
1162 net->xfrm.policy_count[dir]--; 1162 net->xfrm.policy_count[dir]--;
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index 5339c26bb0cf..06970fee9155 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -1171,6 +1171,11 @@ static struct xfrm_state *xfrm_state_clone(struct xfrm_state *orig)
1171 } 1171 }
1172 x->props.aalgo = orig->props.aalgo; 1172 x->props.aalgo = orig->props.aalgo;
1173 1173
1174 if (orig->aead) {
1175 x->aead = xfrm_algo_aead_clone(orig->aead);
1176 if (!x->aead)
1177 goto error;
1178 }
1174 if (orig->ealg) { 1179 if (orig->ealg) {
1175 x->ealg = xfrm_algo_clone(orig->ealg); 1180 x->ealg = xfrm_algo_clone(orig->ealg);
1176 if (!x->ealg) 1181 if (!x->ealg)
@@ -1211,6 +1216,9 @@ static struct xfrm_state *xfrm_state_clone(struct xfrm_state *orig)
1211 x->props.flags = orig->props.flags; 1216 x->props.flags = orig->props.flags;
1212 x->props.extra_flags = orig->props.extra_flags; 1217 x->props.extra_flags = orig->props.extra_flags;
1213 1218
1219 x->tfcpad = orig->tfcpad;
1220 x->replay_maxdiff = orig->replay_maxdiff;
1221 x->replay_maxage = orig->replay_maxage;
1214 x->curlft.add_time = orig->curlft.add_time; 1222 x->curlft.add_time = orig->curlft.add_time;
1215 x->km.state = orig->km.state; 1223 x->km.state = orig->km.state;
1216 x->km.seq = orig->km.seq; 1224 x->km.seq = orig->km.seq;
@@ -1223,11 +1231,12 @@ out:
1223 return NULL; 1231 return NULL;
1224} 1232}
1225 1233
1226/* net->xfrm.xfrm_state_lock is held */
1227struct xfrm_state *xfrm_migrate_state_find(struct xfrm_migrate *m, struct net *net) 1234struct xfrm_state *xfrm_migrate_state_find(struct xfrm_migrate *m, struct net *net)
1228{ 1235{
1229 unsigned int h; 1236 unsigned int h;
1230 struct xfrm_state *x; 1237 struct xfrm_state *x = NULL;
1238
1239 spin_lock_bh(&net->xfrm.xfrm_state_lock);
1231 1240
1232 if (m->reqid) { 1241 if (m->reqid) {
1233 h = xfrm_dst_hash(net, &m->old_daddr, &m->old_saddr, 1242 h = xfrm_dst_hash(net, &m->old_daddr, &m->old_saddr,
@@ -1244,7 +1253,7 @@ struct xfrm_state *xfrm_migrate_state_find(struct xfrm_migrate *m, struct net *n
1244 m->old_family)) 1253 m->old_family))
1245 continue; 1254 continue;
1246 xfrm_state_hold(x); 1255 xfrm_state_hold(x);
1247 return x; 1256 break;
1248 } 1257 }
1249 } else { 1258 } else {
1250 h = xfrm_src_hash(net, &m->old_daddr, &m->old_saddr, 1259 h = xfrm_src_hash(net, &m->old_daddr, &m->old_saddr,
@@ -1259,11 +1268,13 @@ struct xfrm_state *xfrm_migrate_state_find(struct xfrm_migrate *m, struct net *n
1259 m->old_family)) 1268 m->old_family))
1260 continue; 1269 continue;
1261 xfrm_state_hold(x); 1270 xfrm_state_hold(x);
1262 return x; 1271 break;
1263 } 1272 }
1264 } 1273 }
1265 1274
1266 return NULL; 1275 spin_unlock_bh(&net->xfrm.xfrm_state_lock);
1276
1277 return x;
1267} 1278}
1268EXPORT_SYMBOL(xfrm_migrate_state_find); 1279EXPORT_SYMBOL(xfrm_migrate_state_find);
1269 1280
@@ -1458,7 +1469,7 @@ xfrm_state_sort(struct xfrm_state **dst, struct xfrm_state **src, int n,
1458{ 1469{
1459 int err = 0; 1470 int err = 0;
1460 struct xfrm_state_afinfo *afinfo = xfrm_state_get_afinfo(family); 1471 struct xfrm_state_afinfo *afinfo = xfrm_state_get_afinfo(family);
1461 struct net *net = xs_net(*dst); 1472 struct net *net = xs_net(*src);
1462 1473
1463 if (!afinfo) 1474 if (!afinfo)
1464 return -EAFNOSUPPORT; 1475 return -EAFNOSUPPORT;
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index 023e5e7ea4c6..195dbe230b98 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -32,11 +32,6 @@
32#include <linux/in6.h> 32#include <linux/in6.h>
33#endif 33#endif
34 34
35static inline int aead_len(struct xfrm_algo_aead *alg)
36{
37 return sizeof(*alg) + ((alg->alg_key_len + 7) / 8);
38}
39
40static int verify_one_alg(struct nlattr **attrs, enum xfrm_attr_type_t type) 35static int verify_one_alg(struct nlattr **attrs, enum xfrm_attr_type_t type)
41{ 36{
42 struct nlattr *rt = attrs[type]; 37 struct nlattr *rt = attrs[type];
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 49392ecbef17..79c059e70860 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -152,6 +152,7 @@ ld_flags = $(LDFLAGS) $(ldflags-y)
152dtc_cpp_flags = -Wp,-MD,$(depfile).pre.tmp -nostdinc \ 152dtc_cpp_flags = -Wp,-MD,$(depfile).pre.tmp -nostdinc \
153 -I$(srctree)/arch/$(SRCARCH)/boot/dts \ 153 -I$(srctree)/arch/$(SRCARCH)/boot/dts \
154 -I$(srctree)/arch/$(SRCARCH)/boot/dts/include \ 154 -I$(srctree)/arch/$(SRCARCH)/boot/dts/include \
155 -I$(srctree)/drivers/of/testcase-data \
155 -undef -D__DTS__ 156 -undef -D__DTS__
156 157
157# Finds the multi-part object the current object will be linked into 158# Finds the multi-part object the current object will be linked into
diff --git a/scripts/gen_initramfs_list.sh b/scripts/gen_initramfs_list.sh
index ef474098d9f1..17fa901418ae 100644
--- a/scripts/gen_initramfs_list.sh
+++ b/scripts/gen_initramfs_list.sh
@@ -257,7 +257,7 @@ case "$arg" in
257 && compr="lzop -9 -f" 257 && compr="lzop -9 -f"
258 echo "$output_file" | grep -q "\.lz4$" \ 258 echo "$output_file" | grep -q "\.lz4$" \
259 && [ -x "`which lz4 2> /dev/null`" ] \ 259 && [ -x "`which lz4 2> /dev/null`" ] \
260 && compr="lz4 -9 -f" 260 && compr="lz4 -l -9 -f"
261 echo "$output_file" | grep -q "\.cpio$" && compr="cat" 261 echo "$output_file" | grep -q "\.cpio$" && compr="cat"
262 shift 262 shift
263 ;; 263 ;;
diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c
index 10085de886fe..276e84b8a8e5 100644
--- a/scripts/kallsyms.c
+++ b/scripts/kallsyms.c
@@ -330,8 +330,7 @@ static void write_src(void)
330 printf("\tPTR\t_text + %#llx\n", 330 printf("\tPTR\t_text + %#llx\n",
331 table[i].addr - _text); 331 table[i].addr - _text);
332 else 332 else
333 printf("\tPTR\t_text - %#llx\n", 333 printf("\tPTR\t%#llx\n", table[i].addr);
334 _text - table[i].addr);
335 } else { 334 } else {
336 printf("\tPTR\t%#llx\n", table[i].addr); 335 printf("\tPTR\t%#llx\n", table[i].addr);
337 } 336 }
diff --git a/security/selinux/ss/policydb.c b/security/selinux/ss/policydb.c
index c0f498842129..9c5cdc2caaef 100644
--- a/security/selinux/ss/policydb.c
+++ b/security/selinux/ss/policydb.c
@@ -3338,10 +3338,10 @@ static int filename_write_helper(void *key, void *data, void *ptr)
3338 if (rc) 3338 if (rc)
3339 return rc; 3339 return rc;
3340 3340
3341 buf[0] = ft->stype; 3341 buf[0] = cpu_to_le32(ft->stype);
3342 buf[1] = ft->ttype; 3342 buf[1] = cpu_to_le32(ft->ttype);
3343 buf[2] = ft->tclass; 3343 buf[2] = cpu_to_le32(ft->tclass);
3344 buf[3] = otype->otype; 3344 buf[3] = cpu_to_le32(otype->otype);
3345 3345
3346 rc = put_entry(buf, sizeof(u32), 4, fp); 3346 rc = put_entry(buf, sizeof(u32), 4, fp);
3347 if (rc) 3347 if (rc)
diff --git a/sound/pci/hda/patch_ca0132.c b/sound/pci/hda/patch_ca0132.c
index 54d14793725a..46ecdbb9053f 100644
--- a/sound/pci/hda/patch_ca0132.c
+++ b/sound/pci/hda/patch_ca0132.c
@@ -2662,60 +2662,6 @@ static bool dspload_wait_loaded(struct hda_codec *codec)
2662} 2662}
2663 2663
2664/* 2664/*
2665 * PCM stuffs
2666 */
2667static void ca0132_setup_stream(struct hda_codec *codec, hda_nid_t nid,
2668 u32 stream_tag,
2669 int channel_id, int format)
2670{
2671 unsigned int oldval, newval;
2672
2673 if (!nid)
2674 return;
2675
2676 snd_printdd(
2677 "ca0132_setup_stream: NID=0x%x, stream=0x%x, "
2678 "channel=%d, format=0x%x\n",
2679 nid, stream_tag, channel_id, format);
2680
2681 /* update the format-id if changed */
2682 oldval = snd_hda_codec_read(codec, nid, 0,
2683 AC_VERB_GET_STREAM_FORMAT,
2684 0);
2685 if (oldval != format) {
2686 msleep(20);
2687 snd_hda_codec_write(codec, nid, 0,
2688 AC_VERB_SET_STREAM_FORMAT,
2689 format);
2690 }
2691
2692 oldval = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONV, 0);
2693 newval = (stream_tag << 4) | channel_id;
2694 if (oldval != newval) {
2695 snd_hda_codec_write(codec, nid, 0,
2696 AC_VERB_SET_CHANNEL_STREAMID,
2697 newval);
2698 }
2699}
2700
2701static void ca0132_cleanup_stream(struct hda_codec *codec, hda_nid_t nid)
2702{
2703 unsigned int val;
2704
2705 if (!nid)
2706 return;
2707
2708 snd_printdd(KERN_INFO "ca0132_cleanup_stream: NID=0x%x\n", nid);
2709
2710 val = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONV, 0);
2711 if (!val)
2712 return;
2713
2714 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_STREAM_FORMAT, 0);
2715 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CHANNEL_STREAMID, 0);
2716}
2717
2718/*
2719 * PCM callbacks 2665 * PCM callbacks
2720 */ 2666 */
2721static int ca0132_playback_pcm_prepare(struct hda_pcm_stream *hinfo, 2667static int ca0132_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
@@ -2726,7 +2672,7 @@ static int ca0132_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2726{ 2672{
2727 struct ca0132_spec *spec = codec->spec; 2673 struct ca0132_spec *spec = codec->spec;
2728 2674
2729 ca0132_setup_stream(codec, spec->dacs[0], stream_tag, 0, format); 2675 snd_hda_codec_setup_stream(codec, spec->dacs[0], stream_tag, 0, format);
2730 2676
2731 return 0; 2677 return 0;
2732} 2678}
@@ -2745,7 +2691,7 @@ static int ca0132_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2745 if (spec->effects_switch[PLAY_ENHANCEMENT - EFFECT_START_NID]) 2691 if (spec->effects_switch[PLAY_ENHANCEMENT - EFFECT_START_NID])
2746 msleep(50); 2692 msleep(50);
2747 2693
2748 ca0132_cleanup_stream(codec, spec->dacs[0]); 2694 snd_hda_codec_cleanup_stream(codec, spec->dacs[0]);
2749 2695
2750 return 0; 2696 return 0;
2751} 2697}
@@ -2822,10 +2768,8 @@ static int ca0132_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2822 unsigned int format, 2768 unsigned int format,
2823 struct snd_pcm_substream *substream) 2769 struct snd_pcm_substream *substream)
2824{ 2770{
2825 struct ca0132_spec *spec = codec->spec; 2771 snd_hda_codec_setup_stream(codec, hinfo->nid,
2826 2772 stream_tag, 0, format);
2827 ca0132_setup_stream(codec, spec->adcs[substream->number],
2828 stream_tag, 0, format);
2829 2773
2830 return 0; 2774 return 0;
2831} 2775}
@@ -2839,7 +2783,7 @@ static int ca0132_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2839 if (spec->dsp_state == DSP_DOWNLOADING) 2783 if (spec->dsp_state == DSP_DOWNLOADING)
2840 return 0; 2784 return 0;
2841 2785
2842 ca0132_cleanup_stream(codec, hinfo->nid); 2786 snd_hda_codec_cleanup_stream(codec, hinfo->nid);
2843 return 0; 2787 return 0;
2844} 2788}
2845 2789
@@ -4742,6 +4686,8 @@ static int patch_ca0132(struct hda_codec *codec)
4742 return err; 4686 return err;
4743 4687
4744 codec->patch_ops = ca0132_patch_ops; 4688 codec->patch_ops = ca0132_patch_ops;
4689 codec->pcm_format_first = 1;
4690 codec->no_sticky_stream = 1;
4745 4691
4746 return 0; 4692 return 0;
4747} 4693}
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index a9a83b85517a..ec304f3ae3b4 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -4308,7 +4308,9 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
4308 SND_PCI_QUIRK(0x1028, 0x0651, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE), 4308 SND_PCI_QUIRK(0x1028, 0x0651, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE),
4309 SND_PCI_QUIRK(0x1028, 0x0652, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE), 4309 SND_PCI_QUIRK(0x1028, 0x0652, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE),
4310 SND_PCI_QUIRK(0x1028, 0x0653, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE), 4310 SND_PCI_QUIRK(0x1028, 0x0653, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE),
4311 SND_PCI_QUIRK(0x1028, 0x0657, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE),
4311 SND_PCI_QUIRK(0x1028, 0x0658, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE), 4312 SND_PCI_QUIRK(0x1028, 0x0658, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
4313 SND_PCI_QUIRK(0x1028, 0x065f, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE),
4312 SND_PCI_QUIRK(0x1028, 0x0662, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE), 4314 SND_PCI_QUIRK(0x1028, 0x0662, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE),
4313 SND_PCI_QUIRK(0x1028, 0x15cc, "Dell X5 Precision", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE), 4315 SND_PCI_QUIRK(0x1028, 0x15cc, "Dell X5 Precision", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
4314 SND_PCI_QUIRK(0x1028, 0x15cd, "Dell X5 Precision", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE), 4316 SND_PCI_QUIRK(0x1028, 0x15cd, "Dell X5 Precision", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
@@ -4317,6 +4319,54 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
4317 SND_PCI_QUIRK(0x103c, 0x1973, "HP Pavilion", ALC269_FIXUP_HP_MUTE_LED_MIC1), 4319 SND_PCI_QUIRK(0x103c, 0x1973, "HP Pavilion", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4318 SND_PCI_QUIRK(0x103c, 0x1983, "HP Pavilion", ALC269_FIXUP_HP_MUTE_LED_MIC1), 4320 SND_PCI_QUIRK(0x103c, 0x1983, "HP Pavilion", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4319 SND_PCI_QUIRK(0x103c, 0x218b, "HP", ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED), 4321 SND_PCI_QUIRK(0x103c, 0x218b, "HP", ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED),
4322 /* ALC282 */
4323 SND_PCI_QUIRK(0x103c, 0x220f, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4324 SND_PCI_QUIRK(0x103c, 0x2213, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4325 SND_PCI_QUIRK(0x103c, 0x2266, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4326 SND_PCI_QUIRK(0x103c, 0x2267, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4327 SND_PCI_QUIRK(0x103c, 0x2268, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4328 SND_PCI_QUIRK(0x103c, 0x2269, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4329 SND_PCI_QUIRK(0x103c, 0x226a, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4330 SND_PCI_QUIRK(0x103c, 0x226b, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4331 SND_PCI_QUIRK(0x103c, 0x227a, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4332 SND_PCI_QUIRK(0x103c, 0x227b, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4333 SND_PCI_QUIRK(0x103c, 0x229e, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4334 SND_PCI_QUIRK(0x103c, 0x22a0, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4335 SND_PCI_QUIRK(0x103c, 0x22b2, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4336 SND_PCI_QUIRK(0x103c, 0x22b7, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4337 SND_PCI_QUIRK(0x103c, 0x22bf, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4338 SND_PCI_QUIRK(0x103c, 0x22c0, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4339 SND_PCI_QUIRK(0x103c, 0x22c1, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4340 SND_PCI_QUIRK(0x103c, 0x22c2, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4341 SND_PCI_QUIRK(0x103c, 0x22cd, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4342 SND_PCI_QUIRK(0x103c, 0x22ce, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4343 SND_PCI_QUIRK(0x103c, 0x22cf, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4344 SND_PCI_QUIRK(0x103c, 0x22d0, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4345 /* ALC290 */
4346 SND_PCI_QUIRK(0x103c, 0x2260, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4347 SND_PCI_QUIRK(0x103c, 0x2261, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4348 SND_PCI_QUIRK(0x103c, 0x2262, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4349 SND_PCI_QUIRK(0x103c, 0x2263, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4350 SND_PCI_QUIRK(0x103c, 0x2264, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4351 SND_PCI_QUIRK(0x103c, 0x2265, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4352 SND_PCI_QUIRK(0x103c, 0x227d, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4353 SND_PCI_QUIRK(0x103c, 0x227e, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4354 SND_PCI_QUIRK(0x103c, 0x227f, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4355 SND_PCI_QUIRK(0x103c, 0x2280, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4356 SND_PCI_QUIRK(0x103c, 0x2281, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4357 SND_PCI_QUIRK(0x103c, 0x2282, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4358 SND_PCI_QUIRK(0x103c, 0x2289, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4359 SND_PCI_QUIRK(0x103c, 0x228a, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4360 SND_PCI_QUIRK(0x103c, 0x228b, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4361 SND_PCI_QUIRK(0x103c, 0x228c, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4362 SND_PCI_QUIRK(0x103c, 0x228d, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4363 SND_PCI_QUIRK(0x103c, 0x228e, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4364 SND_PCI_QUIRK(0x103c, 0x22c5, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4365 SND_PCI_QUIRK(0x103c, 0x22c6, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4366 SND_PCI_QUIRK(0x103c, 0x22c7, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4367 SND_PCI_QUIRK(0x103c, 0x22c8, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4368 SND_PCI_QUIRK(0x103c, 0x22c3, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4369 SND_PCI_QUIRK(0x103c, 0x22c4, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
4320 SND_PCI_QUIRK_VENDOR(0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED), 4370 SND_PCI_QUIRK_VENDOR(0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED),
4321 SND_PCI_QUIRK(0x1043, 0x103f, "ASUS TX300", ALC282_FIXUP_ASUS_TX300), 4371 SND_PCI_QUIRK(0x1043, 0x103f, "ASUS TX300", ALC282_FIXUP_ASUS_TX300),
4322 SND_PCI_QUIRK(0x1043, 0x106d, "Asus K53BE", ALC269_FIXUP_LIMIT_INT_MIC_BOOST), 4372 SND_PCI_QUIRK(0x1043, 0x106d, "Asus K53BE", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
index 7311badf6a94..3bc29c9b2529 100644
--- a/sound/pci/hda/patch_sigmatel.c
+++ b/sound/pci/hda/patch_sigmatel.c
@@ -83,6 +83,7 @@ enum {
83 STAC_DELL_M6_BOTH, 83 STAC_DELL_M6_BOTH,
84 STAC_DELL_EQ, 84 STAC_DELL_EQ,
85 STAC_ALIENWARE_M17X, 85 STAC_ALIENWARE_M17X,
86 STAC_92HD89XX_HP_FRONT_JACK,
86 STAC_92HD73XX_MODELS 87 STAC_92HD73XX_MODELS
87}; 88};
88 89
@@ -97,6 +98,7 @@ enum {
97 STAC_92HD83XXX_HP_LED, 98 STAC_92HD83XXX_HP_LED,
98 STAC_92HD83XXX_HP_INV_LED, 99 STAC_92HD83XXX_HP_INV_LED,
99 STAC_92HD83XXX_HP_MIC_LED, 100 STAC_92HD83XXX_HP_MIC_LED,
101 STAC_HP_LED_GPIO10,
100 STAC_92HD83XXX_HEADSET_JACK, 102 STAC_92HD83XXX_HEADSET_JACK,
101 STAC_92HD83XXX_HP, 103 STAC_92HD83XXX_HP,
102 STAC_HP_ENVY_BASS, 104 STAC_HP_ENVY_BASS,
@@ -1795,6 +1797,12 @@ static const struct hda_pintbl intel_dg45id_pin_configs[] = {
1795 {} 1797 {}
1796}; 1798};
1797 1799
1800static const struct hda_pintbl stac92hd89xx_hp_front_jack_pin_configs[] = {
1801 { 0x0a, 0x02214030 },
1802 { 0x0b, 0x02A19010 },
1803 {}
1804};
1805
1798static void stac92hd73xx_fixup_ref(struct hda_codec *codec, 1806static void stac92hd73xx_fixup_ref(struct hda_codec *codec,
1799 const struct hda_fixup *fix, int action) 1807 const struct hda_fixup *fix, int action)
1800{ 1808{
@@ -1913,6 +1921,10 @@ static const struct hda_fixup stac92hd73xx_fixups[] = {
1913 [STAC_92HD73XX_NO_JD] = { 1921 [STAC_92HD73XX_NO_JD] = {
1914 .type = HDA_FIXUP_FUNC, 1922 .type = HDA_FIXUP_FUNC,
1915 .v.func = stac92hd73xx_fixup_no_jd, 1923 .v.func = stac92hd73xx_fixup_no_jd,
1924 },
1925 [STAC_92HD89XX_HP_FRONT_JACK] = {
1926 .type = HDA_FIXUP_PINS,
1927 .v.pins = stac92hd89xx_hp_front_jack_pin_configs,
1916 } 1928 }
1917}; 1929};
1918 1930
@@ -1973,6 +1985,8 @@ static const struct snd_pci_quirk stac92hd73xx_fixup_tbl[] = {
1973 "Alienware M17x", STAC_ALIENWARE_M17X), 1985 "Alienware M17x", STAC_ALIENWARE_M17X),
1974 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0490, 1986 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0490,
1975 "Alienware M17x R3", STAC_DELL_EQ), 1987 "Alienware M17x R3", STAC_DELL_EQ),
1988 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x2b17,
1989 "unknown HP", STAC_92HD89XX_HP_FRONT_JACK),
1976 {} /* terminator */ 1990 {} /* terminator */
1977}; 1991};
1978 1992
@@ -2117,6 +2131,17 @@ static void stac92hd83xxx_fixup_hp_mic_led(struct hda_codec *codec,
2117 } 2131 }
2118} 2132}
2119 2133
2134static void stac92hd83xxx_fixup_hp_led_gpio10(struct hda_codec *codec,
2135 const struct hda_fixup *fix, int action)
2136{
2137 struct sigmatel_spec *spec = codec->spec;
2138
2139 if (action == HDA_FIXUP_ACT_PRE_PROBE) {
2140 spec->gpio_led = 0x10; /* GPIO4 */
2141 spec->default_polarity = 0;
2142 }
2143}
2144
2120static void stac92hd83xxx_fixup_headset_jack(struct hda_codec *codec, 2145static void stac92hd83xxx_fixup_headset_jack(struct hda_codec *codec,
2121 const struct hda_fixup *fix, int action) 2146 const struct hda_fixup *fix, int action)
2122{ 2147{
@@ -2611,6 +2636,12 @@ static const struct hda_fixup stac92hd83xxx_fixups[] = {
2611 .chained = true, 2636 .chained = true,
2612 .chain_id = STAC_92HD83XXX_HP, 2637 .chain_id = STAC_92HD83XXX_HP,
2613 }, 2638 },
2639 [STAC_HP_LED_GPIO10] = {
2640 .type = HDA_FIXUP_FUNC,
2641 .v.func = stac92hd83xxx_fixup_hp_led_gpio10,
2642 .chained = true,
2643 .chain_id = STAC_92HD83XXX_HP,
2644 },
2614 [STAC_92HD83XXX_HEADSET_JACK] = { 2645 [STAC_92HD83XXX_HEADSET_JACK] = {
2615 .type = HDA_FIXUP_FUNC, 2646 .type = HDA_FIXUP_FUNC,
2616 .v.func = stac92hd83xxx_fixup_headset_jack, 2647 .v.func = stac92hd83xxx_fixup_headset_jack,
@@ -2689,6 +2720,8 @@ static const struct snd_pci_quirk stac92hd83xxx_fixup_tbl[] = {
2689 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD), 2720 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
2690 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1888, 2721 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1888,
2691 "HP Envy Spectre", STAC_HP_ENVY_BASS), 2722 "HP Envy Spectre", STAC_HP_ENVY_BASS),
2723 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1899,
2724 "HP Folio 13", STAC_HP_LED_GPIO10),
2692 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x18df, 2725 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x18df,
2693 "HP Folio", STAC_HP_BNB13_EQ), 2726 "HP Folio", STAC_HP_BNB13_EQ),
2694 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x18F8, 2727 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x18F8,
diff --git a/sound/soc/blackfin/Kconfig b/sound/soc/blackfin/Kconfig
index 54f74f8cbb75..4544d8eb1452 100644
--- a/sound/soc/blackfin/Kconfig
+++ b/sound/soc/blackfin/Kconfig
@@ -11,7 +11,7 @@ config SND_BF5XX_I2S
11 11
12config SND_BF5XX_SOC_SSM2602 12config SND_BF5XX_SOC_SSM2602
13 tristate "SoC SSM2602 Audio Codec Add-On Card support" 13 tristate "SoC SSM2602 Audio Codec Add-On Card support"
14 depends on SND_BF5XX_I2S && (SPI_MASTER || I2C) 14 depends on SND_BF5XX_I2S && SND_SOC_I2C_AND_SPI
15 select SND_BF5XX_SOC_I2S if !BF60x 15 select SND_BF5XX_SOC_I2S if !BF60x
16 select SND_BF6XX_SOC_I2S if BF60x 16 select SND_BF6XX_SOC_I2S if BF60x
17 select SND_SOC_SSM2602 17 select SND_SOC_SSM2602
@@ -21,10 +21,9 @@ config SND_BF5XX_SOC_SSM2602
21 21
22config SND_SOC_BFIN_EVAL_ADAU1701 22config SND_SOC_BFIN_EVAL_ADAU1701
23 tristate "Support for the EVAL-ADAU1701MINIZ board on Blackfin eval boards" 23 tristate "Support for the EVAL-ADAU1701MINIZ board on Blackfin eval boards"
24 depends on SND_BF5XX_I2S 24 depends on SND_BF5XX_I2S && I2C
25 select SND_BF5XX_SOC_I2S 25 select SND_BF5XX_SOC_I2S
26 select SND_SOC_ADAU1701 26 select SND_SOC_ADAU1701
27 select I2C
28 help 27 help
29 Say Y if you want to add support for the Analog Devices EVAL-ADAU1701MINIZ 28 Say Y if you want to add support for the Analog Devices EVAL-ADAU1701MINIZ
30 board connected to one of the Blackfin evaluation boards like the 29 board connected to one of the Blackfin evaluation boards like the
@@ -45,7 +44,7 @@ config SND_SOC_BFIN_EVAL_ADAU1373
45 44
46config SND_SOC_BFIN_EVAL_ADAV80X 45config SND_SOC_BFIN_EVAL_ADAV80X
47 tristate "Support for the EVAL-ADAV80X boards on Blackfin eval boards" 46 tristate "Support for the EVAL-ADAV80X boards on Blackfin eval boards"
48 depends on SND_BF5XX_I2S && (SPI_MASTER || I2C) 47 depends on SND_BF5XX_I2S && SND_SOC_I2C_AND_SPI
49 select SND_BF5XX_SOC_I2S 48 select SND_BF5XX_SOC_I2S
50 select SND_SOC_ADAV80X 49 select SND_SOC_ADAV80X
51 help 50 help
@@ -58,7 +57,7 @@ config SND_SOC_BFIN_EVAL_ADAV80X
58 57
59config SND_BF5XX_SOC_AD1836 58config SND_BF5XX_SOC_AD1836
60 tristate "SoC AD1836 Audio support for BF5xx" 59 tristate "SoC AD1836 Audio support for BF5xx"
61 depends on SND_BF5XX_I2S 60 depends on SND_BF5XX_I2S && SPI_MASTER
62 select SND_BF5XX_SOC_I2S 61 select SND_BF5XX_SOC_I2S
63 select SND_SOC_AD1836 62 select SND_SOC_AD1836
64 help 63 help
@@ -66,7 +65,7 @@ config SND_BF5XX_SOC_AD1836
66 65
67config SND_BF5XX_SOC_AD193X 66config SND_BF5XX_SOC_AD193X
68 tristate "SoC AD193X Audio support for Blackfin" 67 tristate "SoC AD193X Audio support for Blackfin"
69 depends on SND_BF5XX_I2S 68 depends on SND_BF5XX_I2S && SND_SOC_I2C_AND_SPI
70 select SND_BF5XX_SOC_I2S 69 select SND_BF5XX_SOC_I2S
71 select SND_SOC_AD193X 70 select SND_SOC_AD193X
72 help 71 help
diff --git a/sound/soc/codecs/ad1980.c b/sound/soc/codecs/ad1980.c
index 7257a8885f42..34d965a4a040 100644
--- a/sound/soc/codecs/ad1980.c
+++ b/sound/soc/codecs/ad1980.c
@@ -57,8 +57,8 @@ static const u16 ad1980_reg[] = {
57static const char *ad1980_rec_sel[] = {"Mic", "CD", "NC", "AUX", "Line", 57static const char *ad1980_rec_sel[] = {"Mic", "CD", "NC", "AUX", "Line",
58 "Stereo Mix", "Mono Mix", "Phone"}; 58 "Stereo Mix", "Mono Mix", "Phone"};
59 59
60static const struct soc_enum ad1980_cap_src = 60static SOC_ENUM_DOUBLE_DECL(ad1980_cap_src,
61 SOC_ENUM_DOUBLE(AC97_REC_SEL, 8, 0, 7, ad1980_rec_sel); 61 AC97_REC_SEL, 8, 0, ad1980_rec_sel);
62 62
63static const struct snd_kcontrol_new ad1980_snd_ac97_controls[] = { 63static const struct snd_kcontrol_new ad1980_snd_ac97_controls[] = {
64SOC_DOUBLE("Master Playback Volume", AC97_MASTER, 8, 0, 31, 1), 64SOC_DOUBLE("Master Playback Volume", AC97_MASTER, 8, 0, 31, 1),
diff --git a/sound/soc/codecs/da732x.c b/sound/soc/codecs/da732x.c
index f295b6569910..f4d965ebc29e 100644
--- a/sound/soc/codecs/da732x.c
+++ b/sound/soc/codecs/da732x.c
@@ -1268,11 +1268,23 @@ static struct snd_soc_dai_driver da732x_dai[] = {
1268 }, 1268 },
1269}; 1269};
1270 1270
1271static bool da732x_volatile(struct device *dev, unsigned int reg)
1272{
1273 switch (reg) {
1274 case DA732X_REG_HPL_DAC_OFF_CNTL:
1275 case DA732X_REG_HPR_DAC_OFF_CNTL:
1276 return true;
1277 default:
1278 return false;
1279 }
1280}
1281
1271static const struct regmap_config da732x_regmap = { 1282static const struct regmap_config da732x_regmap = {
1272 .reg_bits = 8, 1283 .reg_bits = 8,
1273 .val_bits = 8, 1284 .val_bits = 8,
1274 1285
1275 .max_register = DA732X_MAX_REG, 1286 .max_register = DA732X_MAX_REG,
1287 .volatile_reg = da732x_volatile,
1276 .reg_defaults = da732x_reg_cache, 1288 .reg_defaults = da732x_reg_cache,
1277 .num_reg_defaults = ARRAY_SIZE(da732x_reg_cache), 1289 .num_reg_defaults = ARRAY_SIZE(da732x_reg_cache),
1278 .cache_type = REGCACHE_RBTREE, 1290 .cache_type = REGCACHE_RBTREE,
diff --git a/sound/soc/codecs/da9055.c b/sound/soc/codecs/da9055.c
index 52b79a487ac7..422812613a28 100644
--- a/sound/soc/codecs/da9055.c
+++ b/sound/soc/codecs/da9055.c
@@ -1523,8 +1523,15 @@ static int da9055_remove(struct i2c_client *client)
1523 return 0; 1523 return 0;
1524} 1524}
1525 1525
1526/*
1527 * DO NOT change the device Ids. The naming is intentionally specific as both
1528 * the CODEC and PMIC parts of this chip are instantiated separately as I2C
1529 * devices (both have configurable I2C addresses, and are to all intents and
1530 * purposes separate). As a result there are specific DA9055 Ids for CODEC
1531 * and PMIC, which must be different to operate together.
1532 */
1526static const struct i2c_device_id da9055_i2c_id[] = { 1533static const struct i2c_device_id da9055_i2c_id[] = {
1527 { "da9055", 0 }, 1534 { "da9055-codec", 0 },
1528 { } 1535 { }
1529}; 1536};
1530MODULE_DEVICE_TABLE(i2c, da9055_i2c_id); 1537MODULE_DEVICE_TABLE(i2c, da9055_i2c_id);
@@ -1532,7 +1539,7 @@ MODULE_DEVICE_TABLE(i2c, da9055_i2c_id);
1532/* I2C codec control layer */ 1539/* I2C codec control layer */
1533static struct i2c_driver da9055_i2c_driver = { 1540static struct i2c_driver da9055_i2c_driver = {
1534 .driver = { 1541 .driver = {
1535 .name = "da9055", 1542 .name = "da9055-codec",
1536 .owner = THIS_MODULE, 1543 .owner = THIS_MODULE,
1537 }, 1544 },
1538 .probe = da9055_i2c_probe, 1545 .probe = da9055_i2c_probe,
diff --git a/sound/soc/codecs/isabelle.c b/sound/soc/codecs/isabelle.c
index 5839048ec467..cb736ddc446d 100644
--- a/sound/soc/codecs/isabelle.c
+++ b/sound/soc/codecs/isabelle.c
@@ -140,13 +140,17 @@ static const char *isabelle_rx1_texts[] = {"VRX1", "ARX1"};
140static const char *isabelle_rx2_texts[] = {"VRX2", "ARX2"}; 140static const char *isabelle_rx2_texts[] = {"VRX2", "ARX2"};
141 141
142static const struct soc_enum isabelle_rx1_enum[] = { 142static const struct soc_enum isabelle_rx1_enum[] = {
143 SOC_ENUM_SINGLE(ISABELLE_VOICE_HPF_CFG_REG, 3, 1, isabelle_rx1_texts), 143 SOC_ENUM_SINGLE(ISABELLE_VOICE_HPF_CFG_REG, 3,
144 SOC_ENUM_SINGLE(ISABELLE_AUDIO_HPF_CFG_REG, 5, 1, isabelle_rx1_texts), 144 ARRAY_SIZE(isabelle_rx1_texts), isabelle_rx1_texts),
145 SOC_ENUM_SINGLE(ISABELLE_AUDIO_HPF_CFG_REG, 5,
146 ARRAY_SIZE(isabelle_rx1_texts), isabelle_rx1_texts),
145}; 147};
146 148
147static const struct soc_enum isabelle_rx2_enum[] = { 149static const struct soc_enum isabelle_rx2_enum[] = {
148 SOC_ENUM_SINGLE(ISABELLE_VOICE_HPF_CFG_REG, 2, 1, isabelle_rx2_texts), 150 SOC_ENUM_SINGLE(ISABELLE_VOICE_HPF_CFG_REG, 2,
149 SOC_ENUM_SINGLE(ISABELLE_AUDIO_HPF_CFG_REG, 4, 1, isabelle_rx2_texts), 151 ARRAY_SIZE(isabelle_rx2_texts), isabelle_rx2_texts),
152 SOC_ENUM_SINGLE(ISABELLE_AUDIO_HPF_CFG_REG, 4,
153 ARRAY_SIZE(isabelle_rx2_texts), isabelle_rx2_texts),
150}; 154};
151 155
152/* Headset DAC playback switches */ 156/* Headset DAC playback switches */
@@ -161,13 +165,17 @@ static const char *isabelle_atx_texts[] = {"AMIC1", "DMIC"};
161static const char *isabelle_vtx_texts[] = {"AMIC2", "DMIC"}; 165static const char *isabelle_vtx_texts[] = {"AMIC2", "DMIC"};
162 166
163static const struct soc_enum isabelle_atx_enum[] = { 167static const struct soc_enum isabelle_atx_enum[] = {
164 SOC_ENUM_SINGLE(ISABELLE_AMIC_CFG_REG, 7, 1, isabelle_atx_texts), 168 SOC_ENUM_SINGLE(ISABELLE_AMIC_CFG_REG, 7,
165 SOC_ENUM_SINGLE(ISABELLE_DMIC_CFG_REG, 0, 1, isabelle_atx_texts), 169 ARRAY_SIZE(isabelle_atx_texts), isabelle_atx_texts),
170 SOC_ENUM_SINGLE(ISABELLE_DMIC_CFG_REG, 0,
171 ARRAY_SIZE(isabelle_atx_texts), isabelle_atx_texts),
166}; 172};
167 173
168static const struct soc_enum isabelle_vtx_enum[] = { 174static const struct soc_enum isabelle_vtx_enum[] = {
169 SOC_ENUM_SINGLE(ISABELLE_AMIC_CFG_REG, 6, 1, isabelle_vtx_texts), 175 SOC_ENUM_SINGLE(ISABELLE_AMIC_CFG_REG, 6,
170 SOC_ENUM_SINGLE(ISABELLE_DMIC_CFG_REG, 0, 1, isabelle_vtx_texts), 176 ARRAY_SIZE(isabelle_vtx_texts), isabelle_vtx_texts),
177 SOC_ENUM_SINGLE(ISABELLE_DMIC_CFG_REG, 0,
178 ARRAY_SIZE(isabelle_vtx_texts), isabelle_vtx_texts),
171}; 179};
172 180
173static const struct snd_kcontrol_new atx_mux_controls = 181static const struct snd_kcontrol_new atx_mux_controls =
@@ -183,17 +191,13 @@ static const char *isabelle_amic1_texts[] = {
183/* Left analog microphone selection */ 191/* Left analog microphone selection */
184static const char *isabelle_amic2_texts[] = {"Sub Mic", "Aux/FM Right"}; 192static const char *isabelle_amic2_texts[] = {"Sub Mic", "Aux/FM Right"};
185 193
186static const struct soc_enum isabelle_amic1_enum[] = { 194static SOC_ENUM_SINGLE_DECL(isabelle_amic1_enum,
187 SOC_ENUM_SINGLE(ISABELLE_AMIC_CFG_REG, 5, 195 ISABELLE_AMIC_CFG_REG, 5,
188 ARRAY_SIZE(isabelle_amic1_texts), 196 isabelle_amic1_texts);
189 isabelle_amic1_texts),
190};
191 197
192static const struct soc_enum isabelle_amic2_enum[] = { 198static SOC_ENUM_SINGLE_DECL(isabelle_amic2_enum,
193 SOC_ENUM_SINGLE(ISABELLE_AMIC_CFG_REG, 4, 199 ISABELLE_AMIC_CFG_REG, 4,
194 ARRAY_SIZE(isabelle_amic2_texts), 200 isabelle_amic2_texts);
195 isabelle_amic2_texts),
196};
197 201
198static const struct snd_kcontrol_new amic1_control = 202static const struct snd_kcontrol_new amic1_control =
199 SOC_DAPM_ENUM("Route", isabelle_amic1_enum); 203 SOC_DAPM_ENUM("Route", isabelle_amic1_enum);
@@ -206,16 +210,20 @@ static const char *isabelle_st_audio_texts[] = {"ATX1", "ATX2"};
206static const char *isabelle_st_voice_texts[] = {"VTX1", "VTX2"}; 210static const char *isabelle_st_voice_texts[] = {"VTX1", "VTX2"};
207 211
208static const struct soc_enum isabelle_st_audio_enum[] = { 212static const struct soc_enum isabelle_st_audio_enum[] = {
209 SOC_ENUM_SINGLE(ISABELLE_ATX_STPGA1_CFG_REG, 7, 1, 213 SOC_ENUM_SINGLE(ISABELLE_ATX_STPGA1_CFG_REG, 7,
214 ARRAY_SIZE(isabelle_st_audio_texts),
210 isabelle_st_audio_texts), 215 isabelle_st_audio_texts),
211 SOC_ENUM_SINGLE(ISABELLE_ATX_STPGA2_CFG_REG, 7, 1, 216 SOC_ENUM_SINGLE(ISABELLE_ATX_STPGA2_CFG_REG, 7,
217 ARRAY_SIZE(isabelle_st_audio_texts),
212 isabelle_st_audio_texts), 218 isabelle_st_audio_texts),
213}; 219};
214 220
215static const struct soc_enum isabelle_st_voice_enum[] = { 221static const struct soc_enum isabelle_st_voice_enum[] = {
216 SOC_ENUM_SINGLE(ISABELLE_VTX_STPGA1_CFG_REG, 7, 1, 222 SOC_ENUM_SINGLE(ISABELLE_VTX_STPGA1_CFG_REG, 7,
223 ARRAY_SIZE(isabelle_st_voice_texts),
217 isabelle_st_voice_texts), 224 isabelle_st_voice_texts),
218 SOC_ENUM_SINGLE(ISABELLE_VTX2_STPGA2_CFG_REG, 7, 1, 225 SOC_ENUM_SINGLE(ISABELLE_VTX2_STPGA2_CFG_REG, 7,
226 ARRAY_SIZE(isabelle_st_voice_texts),
219 isabelle_st_voice_texts), 227 isabelle_st_voice_texts),
220}; 228};
221 229
diff --git a/sound/soc/codecs/max98090.c b/sound/soc/codecs/max98090.c
index 51f9b3d16b41..9f714ea86613 100644
--- a/sound/soc/codecs/max98090.c
+++ b/sound/soc/codecs/max98090.c
@@ -336,6 +336,7 @@ static bool max98090_readable_register(struct device *dev, unsigned int reg)
336 case M98090_REG_RECORD_TDM_SLOT: 336 case M98090_REG_RECORD_TDM_SLOT:
337 case M98090_REG_SAMPLE_RATE: 337 case M98090_REG_SAMPLE_RATE:
338 case M98090_REG_DMIC34_BIQUAD_BASE ... M98090_REG_DMIC34_BIQUAD_BASE + 0x0E: 338 case M98090_REG_DMIC34_BIQUAD_BASE ... M98090_REG_DMIC34_BIQUAD_BASE + 0x0E:
339 case M98090_REG_REVISION_ID:
339 return true; 340 return true;
340 default: 341 default:
341 return false; 342 return false;
@@ -1769,16 +1770,6 @@ static int max98090_set_bias_level(struct snd_soc_codec *codec,
1769 1770
1770 switch (level) { 1771 switch (level) {
1771 case SND_SOC_BIAS_ON: 1772 case SND_SOC_BIAS_ON:
1772 if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) {
1773 ret = regcache_sync(max98090->regmap);
1774
1775 if (ret != 0) {
1776 dev_err(codec->dev,
1777 "Failed to sync cache: %d\n", ret);
1778 return ret;
1779 }
1780 }
1781
1782 if (max98090->jack_state == M98090_JACK_STATE_HEADSET) { 1773 if (max98090->jack_state == M98090_JACK_STATE_HEADSET) {
1783 /* 1774 /*
1784 * Set to normal bias level. 1775 * Set to normal bias level.
@@ -1792,6 +1783,16 @@ static int max98090_set_bias_level(struct snd_soc_codec *codec,
1792 break; 1783 break;
1793 1784
1794 case SND_SOC_BIAS_STANDBY: 1785 case SND_SOC_BIAS_STANDBY:
1786 if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) {
1787 ret = regcache_sync(max98090->regmap);
1788 if (ret != 0) {
1789 dev_err(codec->dev,
1790 "Failed to sync cache: %d\n", ret);
1791 return ret;
1792 }
1793 }
1794 break;
1795
1795 case SND_SOC_BIAS_OFF: 1796 case SND_SOC_BIAS_OFF:
1796 /* Set internal pull-up to lowest power mode */ 1797 /* Set internal pull-up to lowest power mode */
1797 snd_soc_update_bits(codec, M98090_REG_JACK_DETECT, 1798 snd_soc_update_bits(codec, M98090_REG_JACK_DETECT,
diff --git a/sound/soc/codecs/rt5640.c b/sound/soc/codecs/rt5640.c
index a3fb41179636..886924934aa5 100644
--- a/sound/soc/codecs/rt5640.c
+++ b/sound/soc/codecs/rt5640.c
@@ -2093,6 +2093,7 @@ MODULE_DEVICE_TABLE(i2c, rt5640_i2c_id);
2093#ifdef CONFIG_ACPI 2093#ifdef CONFIG_ACPI
2094static struct acpi_device_id rt5640_acpi_match[] = { 2094static struct acpi_device_id rt5640_acpi_match[] = {
2095 { "INT33CA", 0 }, 2095 { "INT33CA", 0 },
2096 { "10EC5640", 0 },
2096 { }, 2097 { },
2097}; 2098};
2098MODULE_DEVICE_TABLE(acpi, rt5640_acpi_match); 2099MODULE_DEVICE_TABLE(acpi, rt5640_acpi_match);
diff --git a/sound/soc/codecs/sta32x.c b/sound/soc/codecs/sta32x.c
index 06edb396e733..2735361a4c3c 100644
--- a/sound/soc/codecs/sta32x.c
+++ b/sound/soc/codecs/sta32x.c
@@ -187,42 +187,42 @@ static const unsigned int sta32x_limiter_drc_release_tlv[] = {
187 13, 16, TLV_DB_SCALE_ITEM(-1500, 300, 0), 187 13, 16, TLV_DB_SCALE_ITEM(-1500, 300, 0),
188}; 188};
189 189
190static const struct soc_enum sta32x_drc_ac_enum = 190static SOC_ENUM_SINGLE_DECL(sta32x_drc_ac_enum,
191 SOC_ENUM_SINGLE(STA32X_CONFD, STA32X_CONFD_DRC_SHIFT, 191 STA32X_CONFD, STA32X_CONFD_DRC_SHIFT,
192 2, sta32x_drc_ac); 192 sta32x_drc_ac);
193static const struct soc_enum sta32x_auto_eq_enum = 193static SOC_ENUM_SINGLE_DECL(sta32x_auto_eq_enum,
194 SOC_ENUM_SINGLE(STA32X_AUTO1, STA32X_AUTO1_AMEQ_SHIFT, 194 STA32X_AUTO1, STA32X_AUTO1_AMEQ_SHIFT,
195 3, sta32x_auto_eq_mode); 195 sta32x_auto_eq_mode);
196static const struct soc_enum sta32x_auto_gc_enum = 196static SOC_ENUM_SINGLE_DECL(sta32x_auto_gc_enum,
197 SOC_ENUM_SINGLE(STA32X_AUTO1, STA32X_AUTO1_AMGC_SHIFT, 197 STA32X_AUTO1, STA32X_AUTO1_AMGC_SHIFT,
198 4, sta32x_auto_gc_mode); 198 sta32x_auto_gc_mode);
199static const struct soc_enum sta32x_auto_xo_enum = 199static SOC_ENUM_SINGLE_DECL(sta32x_auto_xo_enum,
200 SOC_ENUM_SINGLE(STA32X_AUTO2, STA32X_AUTO2_XO_SHIFT, 200 STA32X_AUTO2, STA32X_AUTO2_XO_SHIFT,
201 16, sta32x_auto_xo_mode); 201 sta32x_auto_xo_mode);
202static const struct soc_enum sta32x_preset_eq_enum = 202static SOC_ENUM_SINGLE_DECL(sta32x_preset_eq_enum,
203 SOC_ENUM_SINGLE(STA32X_AUTO3, STA32X_AUTO3_PEQ_SHIFT, 203 STA32X_AUTO3, STA32X_AUTO3_PEQ_SHIFT,
204 32, sta32x_preset_eq_mode); 204 sta32x_preset_eq_mode);
205static const struct soc_enum sta32x_limiter_ch1_enum = 205static SOC_ENUM_SINGLE_DECL(sta32x_limiter_ch1_enum,
206 SOC_ENUM_SINGLE(STA32X_C1CFG, STA32X_CxCFG_LS_SHIFT, 206 STA32X_C1CFG, STA32X_CxCFG_LS_SHIFT,
207 3, sta32x_limiter_select); 207 sta32x_limiter_select);
208static const struct soc_enum sta32x_limiter_ch2_enum = 208static SOC_ENUM_SINGLE_DECL(sta32x_limiter_ch2_enum,
209 SOC_ENUM_SINGLE(STA32X_C2CFG, STA32X_CxCFG_LS_SHIFT, 209 STA32X_C2CFG, STA32X_CxCFG_LS_SHIFT,
210 3, sta32x_limiter_select); 210 sta32x_limiter_select);
211static const struct soc_enum sta32x_limiter_ch3_enum = 211static SOC_ENUM_SINGLE_DECL(sta32x_limiter_ch3_enum,
212 SOC_ENUM_SINGLE(STA32X_C3CFG, STA32X_CxCFG_LS_SHIFT, 212 STA32X_C3CFG, STA32X_CxCFG_LS_SHIFT,
213 3, sta32x_limiter_select); 213 sta32x_limiter_select);
214static const struct soc_enum sta32x_limiter1_attack_rate_enum = 214static SOC_ENUM_SINGLE_DECL(sta32x_limiter1_attack_rate_enum,
215 SOC_ENUM_SINGLE(STA32X_L1AR, STA32X_LxA_SHIFT, 215 STA32X_L1AR, STA32X_LxA_SHIFT,
216 16, sta32x_limiter_attack_rate); 216 sta32x_limiter_attack_rate);
217static const struct soc_enum sta32x_limiter2_attack_rate_enum = 217static SOC_ENUM_SINGLE_DECL(sta32x_limiter2_attack_rate_enum,
218 SOC_ENUM_SINGLE(STA32X_L2AR, STA32X_LxA_SHIFT, 218 STA32X_L2AR, STA32X_LxA_SHIFT,
219 16, sta32x_limiter_attack_rate); 219 sta32x_limiter_attack_rate);
220static const struct soc_enum sta32x_limiter1_release_rate_enum = 220static SOC_ENUM_SINGLE_DECL(sta32x_limiter1_release_rate_enum,
221 SOC_ENUM_SINGLE(STA32X_L1AR, STA32X_LxR_SHIFT, 221 STA32X_L1AR, STA32X_LxR_SHIFT,
222 16, sta32x_limiter_release_rate); 222 sta32x_limiter_release_rate);
223static const struct soc_enum sta32x_limiter2_release_rate_enum = 223static SOC_ENUM_SINGLE_DECL(sta32x_limiter2_release_rate_enum,
224 SOC_ENUM_SINGLE(STA32X_L2AR, STA32X_LxR_SHIFT, 224 STA32X_L2AR, STA32X_LxR_SHIFT,
225 16, sta32x_limiter_release_rate); 225 sta32x_limiter_release_rate);
226 226
227/* byte array controls for setting biquad, mixer, scaling coefficients; 227/* byte array controls for setting biquad, mixer, scaling coefficients;
228 * for biquads all five coefficients need to be set in one go, 228 * for biquads all five coefficients need to be set in one go,
@@ -331,7 +331,7 @@ static int sta32x_sync_coef_shadow(struct snd_soc_codec *codec)
331 331
332static int sta32x_cache_sync(struct snd_soc_codec *codec) 332static int sta32x_cache_sync(struct snd_soc_codec *codec)
333{ 333{
334 struct sta32x_priv *sta32x = codec->control_data; 334 struct sta32x_priv *sta32x = snd_soc_codec_get_drvdata(codec);
335 unsigned int mute; 335 unsigned int mute;
336 int rc; 336 int rc;
337 337
@@ -434,7 +434,7 @@ SOC_SINGLE_TLV("Treble Tone Control", STA32X_TONE, STA32X_TONE_TTC_SHIFT, 15, 0,
434SOC_ENUM("Limiter1 Attack Rate (dB/ms)", sta32x_limiter1_attack_rate_enum), 434SOC_ENUM("Limiter1 Attack Rate (dB/ms)", sta32x_limiter1_attack_rate_enum),
435SOC_ENUM("Limiter2 Attack Rate (dB/ms)", sta32x_limiter2_attack_rate_enum), 435SOC_ENUM("Limiter2 Attack Rate (dB/ms)", sta32x_limiter2_attack_rate_enum),
436SOC_ENUM("Limiter1 Release Rate (dB/ms)", sta32x_limiter1_release_rate_enum), 436SOC_ENUM("Limiter1 Release Rate (dB/ms)", sta32x_limiter1_release_rate_enum),
437SOC_ENUM("Limiter2 Release Rate (dB/ms)", sta32x_limiter1_release_rate_enum), 437SOC_ENUM("Limiter2 Release Rate (dB/ms)", sta32x_limiter2_release_rate_enum),
438 438
439/* depending on mode, the attack/release thresholds have 439/* depending on mode, the attack/release thresholds have
440 * two different enum definitions; provide both 440 * two different enum definitions; provide both
diff --git a/sound/soc/codecs/wm8400.c b/sound/soc/codecs/wm8400.c
index 48dc7d2fee36..6d684d934f4d 100644
--- a/sound/soc/codecs/wm8400.c
+++ b/sound/soc/codecs/wm8400.c
@@ -117,19 +117,23 @@ static int wm8400_outpga_put_volsw_vu(struct snd_kcontrol *kcontrol,
117static const char *wm8400_digital_sidetone[] = 117static const char *wm8400_digital_sidetone[] =
118 {"None", "Left ADC", "Right ADC", "Reserved"}; 118 {"None", "Left ADC", "Right ADC", "Reserved"};
119 119
120static const struct soc_enum wm8400_left_digital_sidetone_enum = 120static SOC_ENUM_SINGLE_DECL(wm8400_left_digital_sidetone_enum,
121SOC_ENUM_SINGLE(WM8400_DIGITAL_SIDE_TONE, 121 WM8400_DIGITAL_SIDE_TONE,
122 WM8400_ADC_TO_DACL_SHIFT, 2, wm8400_digital_sidetone); 122 WM8400_ADC_TO_DACL_SHIFT,
123 wm8400_digital_sidetone);
123 124
124static const struct soc_enum wm8400_right_digital_sidetone_enum = 125static SOC_ENUM_SINGLE_DECL(wm8400_right_digital_sidetone_enum,
125SOC_ENUM_SINGLE(WM8400_DIGITAL_SIDE_TONE, 126 WM8400_DIGITAL_SIDE_TONE,
126 WM8400_ADC_TO_DACR_SHIFT, 2, wm8400_digital_sidetone); 127 WM8400_ADC_TO_DACR_SHIFT,
128 wm8400_digital_sidetone);
127 129
128static const char *wm8400_adcmode[] = 130static const char *wm8400_adcmode[] =
129 {"Hi-fi mode", "Voice mode 1", "Voice mode 2", "Voice mode 3"}; 131 {"Hi-fi mode", "Voice mode 1", "Voice mode 2", "Voice mode 3"};
130 132
131static const struct soc_enum wm8400_right_adcmode_enum = 133static SOC_ENUM_SINGLE_DECL(wm8400_right_adcmode_enum,
132SOC_ENUM_SINGLE(WM8400_ADC_CTRL, WM8400_ADC_HPF_CUT_SHIFT, 3, wm8400_adcmode); 134 WM8400_ADC_CTRL,
135 WM8400_ADC_HPF_CUT_SHIFT,
136 wm8400_adcmode);
133 137
134static const struct snd_kcontrol_new wm8400_snd_controls[] = { 138static const struct snd_kcontrol_new wm8400_snd_controls[] = {
135/* INMIXL */ 139/* INMIXL */
@@ -422,9 +426,10 @@ SOC_DAPM_SINGLE("RINPGA34 Switch", WM8400_INPUT_MIXER3, WM8400_L34MNB_SHIFT,
422static const char *wm8400_ainlmux[] = 426static const char *wm8400_ainlmux[] =
423 {"INMIXL Mix", "RXVOICE Mix", "DIFFINL Mix"}; 427 {"INMIXL Mix", "RXVOICE Mix", "DIFFINL Mix"};
424 428
425static const struct soc_enum wm8400_ainlmux_enum = 429static SOC_ENUM_SINGLE_DECL(wm8400_ainlmux_enum,
426SOC_ENUM_SINGLE( WM8400_INPUT_MIXER1, WM8400_AINLMODE_SHIFT, 430 WM8400_INPUT_MIXER1,
427 ARRAY_SIZE(wm8400_ainlmux), wm8400_ainlmux); 431 WM8400_AINLMODE_SHIFT,
432 wm8400_ainlmux);
428 433
429static const struct snd_kcontrol_new wm8400_dapm_ainlmux_controls = 434static const struct snd_kcontrol_new wm8400_dapm_ainlmux_controls =
430SOC_DAPM_ENUM("Route", wm8400_ainlmux_enum); 435SOC_DAPM_ENUM("Route", wm8400_ainlmux_enum);
@@ -435,9 +440,10 @@ SOC_DAPM_ENUM("Route", wm8400_ainlmux_enum);
435static const char *wm8400_ainrmux[] = 440static const char *wm8400_ainrmux[] =
436 {"INMIXR Mix", "RXVOICE Mix", "DIFFINR Mix"}; 441 {"INMIXR Mix", "RXVOICE Mix", "DIFFINR Mix"};
437 442
438static const struct soc_enum wm8400_ainrmux_enum = 443static SOC_ENUM_SINGLE_DECL(wm8400_ainrmux_enum,
439SOC_ENUM_SINGLE( WM8400_INPUT_MIXER1, WM8400_AINRMODE_SHIFT, 444 WM8400_INPUT_MIXER1,
440 ARRAY_SIZE(wm8400_ainrmux), wm8400_ainrmux); 445 WM8400_AINRMODE_SHIFT,
446 wm8400_ainrmux);
441 447
442static const struct snd_kcontrol_new wm8400_dapm_ainrmux_controls = 448static const struct snd_kcontrol_new wm8400_dapm_ainrmux_controls =
443SOC_DAPM_ENUM("Route", wm8400_ainrmux_enum); 449SOC_DAPM_ENUM("Route", wm8400_ainrmux_enum);
diff --git a/sound/soc/codecs/wm8770.c b/sound/soc/codecs/wm8770.c
index 89a18d82f303..5bce21013485 100644
--- a/sound/soc/codecs/wm8770.c
+++ b/sound/soc/codecs/wm8770.c
@@ -196,8 +196,8 @@ static const char *ain_text[] = {
196 "AIN5", "AIN6", "AIN7", "AIN8" 196 "AIN5", "AIN6", "AIN7", "AIN8"
197}; 197};
198 198
199static const struct soc_enum ain_enum = 199static SOC_ENUM_DOUBLE_DECL(ain_enum,
200 SOC_ENUM_DOUBLE(WM8770_ADCMUX, 0, 4, 8, ain_text); 200 WM8770_ADCMUX, 0, 4, ain_text);
201 201
202static const struct snd_kcontrol_new ain_mux = 202static const struct snd_kcontrol_new ain_mux =
203 SOC_DAPM_ENUM("Capture Mux", ain_enum); 203 SOC_DAPM_ENUM("Capture Mux", ain_enum);
diff --git a/sound/soc/codecs/wm8900.c b/sound/soc/codecs/wm8900.c
index e98bc7038a08..43c2201cb901 100644
--- a/sound/soc/codecs/wm8900.c
+++ b/sound/soc/codecs/wm8900.c
@@ -304,53 +304,53 @@ static const DECLARE_TLV_DB_SCALE(adc_tlv, -7200, 75, 1);
304 304
305static const char *mic_bias_level_txt[] = { "0.9*AVDD", "0.65*AVDD" }; 305static const char *mic_bias_level_txt[] = { "0.9*AVDD", "0.65*AVDD" };
306 306
307static const struct soc_enum mic_bias_level = 307static SOC_ENUM_SINGLE_DECL(mic_bias_level,
308SOC_ENUM_SINGLE(WM8900_REG_INCTL, 8, 2, mic_bias_level_txt); 308 WM8900_REG_INCTL, 8, mic_bias_level_txt);
309 309
310static const char *dac_mute_rate_txt[] = { "Fast", "Slow" }; 310static const char *dac_mute_rate_txt[] = { "Fast", "Slow" };
311 311
312static const struct soc_enum dac_mute_rate = 312static SOC_ENUM_SINGLE_DECL(dac_mute_rate,
313SOC_ENUM_SINGLE(WM8900_REG_DACCTRL, 7, 2, dac_mute_rate_txt); 313 WM8900_REG_DACCTRL, 7, dac_mute_rate_txt);
314 314
315static const char *dac_deemphasis_txt[] = { 315static const char *dac_deemphasis_txt[] = {
316 "Disabled", "32kHz", "44.1kHz", "48kHz" 316 "Disabled", "32kHz", "44.1kHz", "48kHz"
317}; 317};
318 318
319static const struct soc_enum dac_deemphasis = 319static SOC_ENUM_SINGLE_DECL(dac_deemphasis,
320SOC_ENUM_SINGLE(WM8900_REG_DACCTRL, 4, 4, dac_deemphasis_txt); 320 WM8900_REG_DACCTRL, 4, dac_deemphasis_txt);
321 321
322static const char *adc_hpf_cut_txt[] = { 322static const char *adc_hpf_cut_txt[] = {
323 "Hi-fi mode", "Voice mode 1", "Voice mode 2", "Voice mode 3" 323 "Hi-fi mode", "Voice mode 1", "Voice mode 2", "Voice mode 3"
324}; 324};
325 325
326static const struct soc_enum adc_hpf_cut = 326static SOC_ENUM_SINGLE_DECL(adc_hpf_cut,
327SOC_ENUM_SINGLE(WM8900_REG_ADCCTRL, 5, 4, adc_hpf_cut_txt); 327 WM8900_REG_ADCCTRL, 5, adc_hpf_cut_txt);
328 328
329static const char *lr_txt[] = { 329static const char *lr_txt[] = {
330 "Left", "Right" 330 "Left", "Right"
331}; 331};
332 332
333static const struct soc_enum aifl_src = 333static SOC_ENUM_SINGLE_DECL(aifl_src,
334SOC_ENUM_SINGLE(WM8900_REG_AUDIO1, 15, 2, lr_txt); 334 WM8900_REG_AUDIO1, 15, lr_txt);
335 335
336static const struct soc_enum aifr_src = 336static SOC_ENUM_SINGLE_DECL(aifr_src,
337SOC_ENUM_SINGLE(WM8900_REG_AUDIO1, 14, 2, lr_txt); 337 WM8900_REG_AUDIO1, 14, lr_txt);
338 338
339static const struct soc_enum dacl_src = 339static SOC_ENUM_SINGLE_DECL(dacl_src,
340SOC_ENUM_SINGLE(WM8900_REG_AUDIO2, 15, 2, lr_txt); 340 WM8900_REG_AUDIO2, 15, lr_txt);
341 341
342static const struct soc_enum dacr_src = 342static SOC_ENUM_SINGLE_DECL(dacr_src,
343SOC_ENUM_SINGLE(WM8900_REG_AUDIO2, 14, 2, lr_txt); 343 WM8900_REG_AUDIO2, 14, lr_txt);
344 344
345static const char *sidetone_txt[] = { 345static const char *sidetone_txt[] = {
346 "Disabled", "Left ADC", "Right ADC" 346 "Disabled", "Left ADC", "Right ADC"
347}; 347};
348 348
349static const struct soc_enum dacl_sidetone = 349static SOC_ENUM_SINGLE_DECL(dacl_sidetone,
350SOC_ENUM_SINGLE(WM8900_REG_SIDETONE, 2, 3, sidetone_txt); 350 WM8900_REG_SIDETONE, 2, sidetone_txt);
351 351
352static const struct soc_enum dacr_sidetone = 352static SOC_ENUM_SINGLE_DECL(dacr_sidetone,
353SOC_ENUM_SINGLE(WM8900_REG_SIDETONE, 0, 3, sidetone_txt); 353 WM8900_REG_SIDETONE, 0, sidetone_txt);
354 354
355static const struct snd_kcontrol_new wm8900_snd_controls[] = { 355static const struct snd_kcontrol_new wm8900_snd_controls[] = {
356SOC_ENUM("Mic Bias Level", mic_bias_level), 356SOC_ENUM("Mic Bias Level", mic_bias_level),
@@ -496,8 +496,8 @@ SOC_DAPM_SINGLE("RINPUT3 Switch", WM8900_REG_INCTL, 0, 1, 0),
496 496
497static const char *wm8900_lp_mux[] = { "Disabled", "Enabled" }; 497static const char *wm8900_lp_mux[] = { "Disabled", "Enabled" };
498 498
499static const struct soc_enum wm8900_lineout2_lp_mux = 499static SOC_ENUM_SINGLE_DECL(wm8900_lineout2_lp_mux,
500SOC_ENUM_SINGLE(WM8900_REG_LOUTMIXCTL1, 1, 2, wm8900_lp_mux); 500 WM8900_REG_LOUTMIXCTL1, 1, wm8900_lp_mux);
501 501
502static const struct snd_kcontrol_new wm8900_lineout2_lp = 502static const struct snd_kcontrol_new wm8900_lineout2_lp =
503SOC_DAPM_ENUM("Route", wm8900_lineout2_lp_mux); 503SOC_DAPM_ENUM("Route", wm8900_lineout2_lp_mux);
diff --git a/sound/soc/codecs/wm8958-dsp2.c b/sound/soc/codecs/wm8958-dsp2.c
index b7488f190d2b..d4248e00160e 100644
--- a/sound/soc/codecs/wm8958-dsp2.c
+++ b/sound/soc/codecs/wm8958-dsp2.c
@@ -153,7 +153,7 @@ static int wm8958_dsp2_fw(struct snd_soc_codec *codec, const char *name,
153 153
154 data32 &= 0xffffff; 154 data32 &= 0xffffff;
155 155
156 wm8994_bulk_write(codec->control_data, 156 wm8994_bulk_write(wm8994->wm8994,
157 data32 & 0xffffff, 157 data32 & 0xffffff,
158 block_len / 2, 158 block_len / 2,
159 (void *)(data + 8)); 159 (void *)(data + 8));
diff --git a/sound/soc/codecs/wm8993.c b/sound/soc/codecs/wm8993.c
index 433d59a0f3ef..2ee23a39622c 100644
--- a/sound/soc/codecs/wm8993.c
+++ b/sound/soc/codecs/wm8993.c
@@ -1562,7 +1562,6 @@ static int wm8993_remove(struct snd_soc_codec *codec)
1562 struct wm8993_priv *wm8993 = snd_soc_codec_get_drvdata(codec); 1562 struct wm8993_priv *wm8993 = snd_soc_codec_get_drvdata(codec);
1563 1563
1564 wm8993_set_bias_level(codec, SND_SOC_BIAS_OFF); 1564 wm8993_set_bias_level(codec, SND_SOC_BIAS_OFF);
1565 regulator_bulk_free(ARRAY_SIZE(wm8993->supplies), wm8993->supplies);
1566 return 0; 1565 return 0;
1567} 1566}
1568 1567
diff --git a/sound/soc/codecs/wm8994.c b/sound/soc/codecs/wm8994.c
index b9be9cbc4603..adb72063d44e 100644
--- a/sound/soc/codecs/wm8994.c
+++ b/sound/soc/codecs/wm8994.c
@@ -265,21 +265,21 @@ static const char *sidetone_hpf_text[] = {
265 "2.7kHz", "1.35kHz", "675Hz", "370Hz", "180Hz", "90Hz", "45Hz" 265 "2.7kHz", "1.35kHz", "675Hz", "370Hz", "180Hz", "90Hz", "45Hz"
266}; 266};
267 267
268static const struct soc_enum sidetone_hpf = 268static SOC_ENUM_SINGLE_DECL(sidetone_hpf,
269 SOC_ENUM_SINGLE(WM8994_SIDETONE, 7, 7, sidetone_hpf_text); 269 WM8994_SIDETONE, 7, sidetone_hpf_text);
270 270
271static const char *adc_hpf_text[] = { 271static const char *adc_hpf_text[] = {
272 "HiFi", "Voice 1", "Voice 2", "Voice 3" 272 "HiFi", "Voice 1", "Voice 2", "Voice 3"
273}; 273};
274 274
275static const struct soc_enum aif1adc1_hpf = 275static SOC_ENUM_SINGLE_DECL(aif1adc1_hpf,
276 SOC_ENUM_SINGLE(WM8994_AIF1_ADC1_FILTERS, 13, 4, adc_hpf_text); 276 WM8994_AIF1_ADC1_FILTERS, 13, adc_hpf_text);
277 277
278static const struct soc_enum aif1adc2_hpf = 278static SOC_ENUM_SINGLE_DECL(aif1adc2_hpf,
279 SOC_ENUM_SINGLE(WM8994_AIF1_ADC2_FILTERS, 13, 4, adc_hpf_text); 279 WM8994_AIF1_ADC2_FILTERS, 13, adc_hpf_text);
280 280
281static const struct soc_enum aif2adc_hpf = 281static SOC_ENUM_SINGLE_DECL(aif2adc_hpf,
282 SOC_ENUM_SINGLE(WM8994_AIF2_ADC_FILTERS, 13, 4, adc_hpf_text); 282 WM8994_AIF2_ADC_FILTERS, 13, adc_hpf_text);
283 283
284static const DECLARE_TLV_DB_SCALE(aif_tlv, 0, 600, 0); 284static const DECLARE_TLV_DB_SCALE(aif_tlv, 0, 600, 0);
285static const DECLARE_TLV_DB_SCALE(digital_tlv, -7200, 75, 1); 285static const DECLARE_TLV_DB_SCALE(digital_tlv, -7200, 75, 1);
@@ -501,39 +501,39 @@ static const char *aif_chan_src_text[] = {
501 "Left", "Right" 501 "Left", "Right"
502}; 502};
503 503
504static const struct soc_enum aif1adcl_src = 504static SOC_ENUM_SINGLE_DECL(aif1adcl_src,
505 SOC_ENUM_SINGLE(WM8994_AIF1_CONTROL_1, 15, 2, aif_chan_src_text); 505 WM8994_AIF1_CONTROL_1, 15, aif_chan_src_text);
506 506
507static const struct soc_enum aif1adcr_src = 507static SOC_ENUM_SINGLE_DECL(aif1adcr_src,
508 SOC_ENUM_SINGLE(WM8994_AIF1_CONTROL_1, 14, 2, aif_chan_src_text); 508 WM8994_AIF1_CONTROL_1, 14, aif_chan_src_text);
509 509
510static const struct soc_enum aif2adcl_src = 510static SOC_ENUM_SINGLE_DECL(aif2adcl_src,
511 SOC_ENUM_SINGLE(WM8994_AIF2_CONTROL_1, 15, 2, aif_chan_src_text); 511 WM8994_AIF2_CONTROL_1, 15, aif_chan_src_text);
512 512
513static const struct soc_enum aif2adcr_src = 513static SOC_ENUM_SINGLE_DECL(aif2adcr_src,
514 SOC_ENUM_SINGLE(WM8994_AIF2_CONTROL_1, 14, 2, aif_chan_src_text); 514 WM8994_AIF2_CONTROL_1, 14, aif_chan_src_text);
515 515
516static const struct soc_enum aif1dacl_src = 516static SOC_ENUM_SINGLE_DECL(aif1dacl_src,
517 SOC_ENUM_SINGLE(WM8994_AIF1_CONTROL_2, 15, 2, aif_chan_src_text); 517 WM8994_AIF1_CONTROL_2, 15, aif_chan_src_text);
518 518
519static const struct soc_enum aif1dacr_src = 519static SOC_ENUM_SINGLE_DECL(aif1dacr_src,
520 SOC_ENUM_SINGLE(WM8994_AIF1_CONTROL_2, 14, 2, aif_chan_src_text); 520 WM8994_AIF1_CONTROL_2, 14, aif_chan_src_text);
521 521
522static const struct soc_enum aif2dacl_src = 522static SOC_ENUM_SINGLE_DECL(aif2dacl_src,
523 SOC_ENUM_SINGLE(WM8994_AIF2_CONTROL_2, 15, 2, aif_chan_src_text); 523 WM8994_AIF2_CONTROL_2, 15, aif_chan_src_text);
524 524
525static const struct soc_enum aif2dacr_src = 525static SOC_ENUM_SINGLE_DECL(aif2dacr_src,
526 SOC_ENUM_SINGLE(WM8994_AIF2_CONTROL_2, 14, 2, aif_chan_src_text); 526 WM8994_AIF2_CONTROL_2, 14, aif_chan_src_text);
527 527
528static const char *osr_text[] = { 528static const char *osr_text[] = {
529 "Low Power", "High Performance", 529 "Low Power", "High Performance",
530}; 530};
531 531
532static const struct soc_enum dac_osr = 532static SOC_ENUM_SINGLE_DECL(dac_osr,
533 SOC_ENUM_SINGLE(WM8994_OVERSAMPLING, 0, 2, osr_text); 533 WM8994_OVERSAMPLING, 0, osr_text);
534 534
535static const struct soc_enum adc_osr = 535static SOC_ENUM_SINGLE_DECL(adc_osr,
536 SOC_ENUM_SINGLE(WM8994_OVERSAMPLING, 1, 2, osr_text); 536 WM8994_OVERSAMPLING, 1, osr_text);
537 537
538static const struct snd_kcontrol_new wm8994_snd_controls[] = { 538static const struct snd_kcontrol_new wm8994_snd_controls[] = {
539SOC_DOUBLE_R_TLV("AIF1ADC1 Volume", WM8994_AIF1_ADC1_LEFT_VOLUME, 539SOC_DOUBLE_R_TLV("AIF1ADC1 Volume", WM8994_AIF1_ADC1_LEFT_VOLUME,
@@ -690,17 +690,20 @@ static const char *wm8958_ng_text[] = {
690 "30ms", "125ms", "250ms", "500ms", 690 "30ms", "125ms", "250ms", "500ms",
691}; 691};
692 692
693static const struct soc_enum wm8958_aif1dac1_ng_hold = 693static SOC_ENUM_SINGLE_DECL(wm8958_aif1dac1_ng_hold,
694 SOC_ENUM_SINGLE(WM8958_AIF1_DAC1_NOISE_GATE, 694 WM8958_AIF1_DAC1_NOISE_GATE,
695 WM8958_AIF1DAC1_NG_THR_SHIFT, 4, wm8958_ng_text); 695 WM8958_AIF1DAC1_NG_THR_SHIFT,
696 wm8958_ng_text);
696 697
697static const struct soc_enum wm8958_aif1dac2_ng_hold = 698static SOC_ENUM_SINGLE_DECL(wm8958_aif1dac2_ng_hold,
698 SOC_ENUM_SINGLE(WM8958_AIF1_DAC2_NOISE_GATE, 699 WM8958_AIF1_DAC2_NOISE_GATE,
699 WM8958_AIF1DAC2_NG_THR_SHIFT, 4, wm8958_ng_text); 700 WM8958_AIF1DAC2_NG_THR_SHIFT,
701 wm8958_ng_text);
700 702
701static const struct soc_enum wm8958_aif2dac_ng_hold = 703static SOC_ENUM_SINGLE_DECL(wm8958_aif2dac_ng_hold,
702 SOC_ENUM_SINGLE(WM8958_AIF2_DAC_NOISE_GATE, 704 WM8958_AIF2_DAC_NOISE_GATE,
703 WM8958_AIF2DAC_NG_THR_SHIFT, 4, wm8958_ng_text); 705 WM8958_AIF2DAC_NG_THR_SHIFT,
706 wm8958_ng_text);
704 707
705static const struct snd_kcontrol_new wm8958_snd_controls[] = { 708static const struct snd_kcontrol_new wm8958_snd_controls[] = {
706SOC_SINGLE_TLV("AIF3 Boost Volume", WM8958_AIF3_CONTROL_2, 10, 3, 0, aif_tlv), 709SOC_SINGLE_TLV("AIF3 Boost Volume", WM8958_AIF3_CONTROL_2, 10, 3, 0, aif_tlv),
@@ -1341,8 +1344,8 @@ static const char *adc_mux_text[] = {
1341 "DMIC", 1344 "DMIC",
1342}; 1345};
1343 1346
1344static const struct soc_enum adc_enum = 1347static SOC_ENUM_SINGLE_DECL(adc_enum,
1345 SOC_ENUM_SINGLE(0, 0, 2, adc_mux_text); 1348 0, 0, adc_mux_text);
1346 1349
1347static const struct snd_kcontrol_new adcl_mux = 1350static const struct snd_kcontrol_new adcl_mux =
1348 SOC_DAPM_ENUM_VIRT("ADCL Mux", adc_enum); 1351 SOC_DAPM_ENUM_VIRT("ADCL Mux", adc_enum);
@@ -1478,14 +1481,14 @@ static const char *sidetone_text[] = {
1478 "ADC/DMIC1", "DMIC2", 1481 "ADC/DMIC1", "DMIC2",
1479}; 1482};
1480 1483
1481static const struct soc_enum sidetone1_enum = 1484static SOC_ENUM_SINGLE_DECL(sidetone1_enum,
1482 SOC_ENUM_SINGLE(WM8994_SIDETONE, 0, 2, sidetone_text); 1485 WM8994_SIDETONE, 0, sidetone_text);
1483 1486
1484static const struct snd_kcontrol_new sidetone1_mux = 1487static const struct snd_kcontrol_new sidetone1_mux =
1485 SOC_DAPM_ENUM("Left Sidetone Mux", sidetone1_enum); 1488 SOC_DAPM_ENUM("Left Sidetone Mux", sidetone1_enum);
1486 1489
1487static const struct soc_enum sidetone2_enum = 1490static SOC_ENUM_SINGLE_DECL(sidetone2_enum,
1488 SOC_ENUM_SINGLE(WM8994_SIDETONE, 1, 2, sidetone_text); 1491 WM8994_SIDETONE, 1, sidetone_text);
1489 1492
1490static const struct snd_kcontrol_new sidetone2_mux = 1493static const struct snd_kcontrol_new sidetone2_mux =
1491 SOC_DAPM_ENUM("Right Sidetone Mux", sidetone2_enum); 1494 SOC_DAPM_ENUM("Right Sidetone Mux", sidetone2_enum);
@@ -1498,22 +1501,24 @@ static const char *loopback_text[] = {
1498 "None", "ADCDAT", 1501 "None", "ADCDAT",
1499}; 1502};
1500 1503
1501static const struct soc_enum aif1_loopback_enum = 1504static SOC_ENUM_SINGLE_DECL(aif1_loopback_enum,
1502 SOC_ENUM_SINGLE(WM8994_AIF1_CONTROL_2, WM8994_AIF1_LOOPBACK_SHIFT, 2, 1505 WM8994_AIF1_CONTROL_2,
1503 loopback_text); 1506 WM8994_AIF1_LOOPBACK_SHIFT,
1507 loopback_text);
1504 1508
1505static const struct snd_kcontrol_new aif1_loopback = 1509static const struct snd_kcontrol_new aif1_loopback =
1506 SOC_DAPM_ENUM("AIF1 Loopback", aif1_loopback_enum); 1510 SOC_DAPM_ENUM("AIF1 Loopback", aif1_loopback_enum);
1507 1511
1508static const struct soc_enum aif2_loopback_enum = 1512static SOC_ENUM_SINGLE_DECL(aif2_loopback_enum,
1509 SOC_ENUM_SINGLE(WM8994_AIF2_CONTROL_2, WM8994_AIF2_LOOPBACK_SHIFT, 2, 1513 WM8994_AIF2_CONTROL_2,
1510 loopback_text); 1514 WM8994_AIF2_LOOPBACK_SHIFT,
1515 loopback_text);
1511 1516
1512static const struct snd_kcontrol_new aif2_loopback = 1517static const struct snd_kcontrol_new aif2_loopback =
1513 SOC_DAPM_ENUM("AIF2 Loopback", aif2_loopback_enum); 1518 SOC_DAPM_ENUM("AIF2 Loopback", aif2_loopback_enum);
1514 1519
1515static const struct soc_enum aif1dac_enum = 1520static SOC_ENUM_SINGLE_DECL(aif1dac_enum,
1516 SOC_ENUM_SINGLE(WM8994_POWER_MANAGEMENT_6, 0, 2, aif1dac_text); 1521 WM8994_POWER_MANAGEMENT_6, 0, aif1dac_text);
1517 1522
1518static const struct snd_kcontrol_new aif1dac_mux = 1523static const struct snd_kcontrol_new aif1dac_mux =
1519 SOC_DAPM_ENUM("AIF1DAC Mux", aif1dac_enum); 1524 SOC_DAPM_ENUM("AIF1DAC Mux", aif1dac_enum);
@@ -1522,8 +1527,8 @@ static const char *aif2dac_text[] = {
1522 "AIF2DACDAT", "AIF3DACDAT", 1527 "AIF2DACDAT", "AIF3DACDAT",
1523}; 1528};
1524 1529
1525static const struct soc_enum aif2dac_enum = 1530static SOC_ENUM_SINGLE_DECL(aif2dac_enum,
1526 SOC_ENUM_SINGLE(WM8994_POWER_MANAGEMENT_6, 1, 2, aif2dac_text); 1531 WM8994_POWER_MANAGEMENT_6, 1, aif2dac_text);
1527 1532
1528static const struct snd_kcontrol_new aif2dac_mux = 1533static const struct snd_kcontrol_new aif2dac_mux =
1529 SOC_DAPM_ENUM("AIF2DAC Mux", aif2dac_enum); 1534 SOC_DAPM_ENUM("AIF2DAC Mux", aif2dac_enum);
@@ -1532,8 +1537,8 @@ static const char *aif2adc_text[] = {
1532 "AIF2ADCDAT", "AIF3DACDAT", 1537 "AIF2ADCDAT", "AIF3DACDAT",
1533}; 1538};
1534 1539
1535static const struct soc_enum aif2adc_enum = 1540static SOC_ENUM_SINGLE_DECL(aif2adc_enum,
1536 SOC_ENUM_SINGLE(WM8994_POWER_MANAGEMENT_6, 2, 2, aif2adc_text); 1541 WM8994_POWER_MANAGEMENT_6, 2, aif2adc_text);
1537 1542
1538static const struct snd_kcontrol_new aif2adc_mux = 1543static const struct snd_kcontrol_new aif2adc_mux =
1539 SOC_DAPM_ENUM("AIF2ADC Mux", aif2adc_enum); 1544 SOC_DAPM_ENUM("AIF2ADC Mux", aif2adc_enum);
@@ -1542,14 +1547,14 @@ static const char *aif3adc_text[] = {
1542 "AIF1ADCDAT", "AIF2ADCDAT", "AIF2DACDAT", "Mono PCM", 1547 "AIF1ADCDAT", "AIF2ADCDAT", "AIF2DACDAT", "Mono PCM",
1543}; 1548};
1544 1549
1545static const struct soc_enum wm8994_aif3adc_enum = 1550static SOC_ENUM_SINGLE_DECL(wm8994_aif3adc_enum,
1546 SOC_ENUM_SINGLE(WM8994_POWER_MANAGEMENT_6, 3, 3, aif3adc_text); 1551 WM8994_POWER_MANAGEMENT_6, 3, aif3adc_text);
1547 1552
1548static const struct snd_kcontrol_new wm8994_aif3adc_mux = 1553static const struct snd_kcontrol_new wm8994_aif3adc_mux =
1549 SOC_DAPM_ENUM("AIF3ADC Mux", wm8994_aif3adc_enum); 1554 SOC_DAPM_ENUM("AIF3ADC Mux", wm8994_aif3adc_enum);
1550 1555
1551static const struct soc_enum wm8958_aif3adc_enum = 1556static SOC_ENUM_SINGLE_DECL(wm8958_aif3adc_enum,
1552 SOC_ENUM_SINGLE(WM8994_POWER_MANAGEMENT_6, 3, 4, aif3adc_text); 1557 WM8994_POWER_MANAGEMENT_6, 3, aif3adc_text);
1553 1558
1554static const struct snd_kcontrol_new wm8958_aif3adc_mux = 1559static const struct snd_kcontrol_new wm8958_aif3adc_mux =
1555 SOC_DAPM_ENUM("AIF3ADC Mux", wm8958_aif3adc_enum); 1560 SOC_DAPM_ENUM("AIF3ADC Mux", wm8958_aif3adc_enum);
@@ -1558,8 +1563,8 @@ static const char *mono_pcm_out_text[] = {
1558 "None", "AIF2ADCL", "AIF2ADCR", 1563 "None", "AIF2ADCL", "AIF2ADCR",
1559}; 1564};
1560 1565
1561static const struct soc_enum mono_pcm_out_enum = 1566static SOC_ENUM_SINGLE_DECL(mono_pcm_out_enum,
1562 SOC_ENUM_SINGLE(WM8994_POWER_MANAGEMENT_6, 9, 3, mono_pcm_out_text); 1567 WM8994_POWER_MANAGEMENT_6, 9, mono_pcm_out_text);
1563 1568
1564static const struct snd_kcontrol_new mono_pcm_out_mux = 1569static const struct snd_kcontrol_new mono_pcm_out_mux =
1565 SOC_DAPM_ENUM("Mono PCM Out Mux", mono_pcm_out_enum); 1570 SOC_DAPM_ENUM("Mono PCM Out Mux", mono_pcm_out_enum);
@@ -1569,14 +1574,14 @@ static const char *aif2dac_src_text[] = {
1569}; 1574};
1570 1575
1571/* Note that these two control shouldn't be simultaneously switched to AIF3 */ 1576/* Note that these two control shouldn't be simultaneously switched to AIF3 */
1572static const struct soc_enum aif2dacl_src_enum = 1577static SOC_ENUM_SINGLE_DECL(aif2dacl_src_enum,
1573 SOC_ENUM_SINGLE(WM8994_POWER_MANAGEMENT_6, 7, 2, aif2dac_src_text); 1578 WM8994_POWER_MANAGEMENT_6, 7, aif2dac_src_text);
1574 1579
1575static const struct snd_kcontrol_new aif2dacl_src_mux = 1580static const struct snd_kcontrol_new aif2dacl_src_mux =
1576 SOC_DAPM_ENUM("AIF2DACL Mux", aif2dacl_src_enum); 1581 SOC_DAPM_ENUM("AIF2DACL Mux", aif2dacl_src_enum);
1577 1582
1578static const struct soc_enum aif2dacr_src_enum = 1583static SOC_ENUM_SINGLE_DECL(aif2dacr_src_enum,
1579 SOC_ENUM_SINGLE(WM8994_POWER_MANAGEMENT_6, 8, 2, aif2dac_src_text); 1584 WM8994_POWER_MANAGEMENT_6, 8, aif2dac_src_text);
1580 1585
1581static const struct snd_kcontrol_new aif2dacr_src_mux = 1586static const struct snd_kcontrol_new aif2dacr_src_mux =
1582 SOC_DAPM_ENUM("AIF2DACR Mux", aif2dacr_src_enum); 1587 SOC_DAPM_ENUM("AIF2DACR Mux", aif2dacr_src_enum);
diff --git a/sound/soc/davinci/davinci-evm.c b/sound/soc/davinci/davinci-evm.c
index 70ff3772079f..5e3bc3c6801a 100644
--- a/sound/soc/davinci/davinci-evm.c
+++ b/sound/soc/davinci/davinci-evm.c
@@ -399,6 +399,7 @@ static struct platform_driver davinci_evm_driver = {
399 .driver = { 399 .driver = {
400 .name = "davinci_evm", 400 .name = "davinci_evm",
401 .owner = THIS_MODULE, 401 .owner = THIS_MODULE,
402 .pm = &snd_soc_pm_ops,
402 .of_match_table = of_match_ptr(davinci_evm_dt_ids), 403 .of_match_table = of_match_ptr(davinci_evm_dt_ids),
403 }, 404 },
404}; 405};
diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c
index b7858bfa0295..670afa29e30d 100644
--- a/sound/soc/davinci/davinci-mcasp.c
+++ b/sound/soc/davinci/davinci-mcasp.c
@@ -263,7 +263,9 @@ static int davinci_mcasp_set_dai_fmt(struct snd_soc_dai *cpu_dai,
263 unsigned int fmt) 263 unsigned int fmt)
264{ 264{
265 struct davinci_mcasp *mcasp = snd_soc_dai_get_drvdata(cpu_dai); 265 struct davinci_mcasp *mcasp = snd_soc_dai_get_drvdata(cpu_dai);
266 int ret = 0;
266 267
268 pm_runtime_get_sync(mcasp->dev);
267 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { 269 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
268 case SND_SOC_DAIFMT_DSP_B: 270 case SND_SOC_DAIFMT_DSP_B:
269 case SND_SOC_DAIFMT_AC97: 271 case SND_SOC_DAIFMT_AC97:
@@ -317,7 +319,8 @@ static int davinci_mcasp_set_dai_fmt(struct snd_soc_dai *cpu_dai,
317 break; 319 break;
318 320
319 default: 321 default:
320 return -EINVAL; 322 ret = -EINVAL;
323 goto out;
321 } 324 }
322 325
323 switch (fmt & SND_SOC_DAIFMT_INV_MASK) { 326 switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
@@ -354,10 +357,12 @@ static int davinci_mcasp_set_dai_fmt(struct snd_soc_dai *cpu_dai,
354 break; 357 break;
355 358
356 default: 359 default:
357 return -EINVAL; 360 ret = -EINVAL;
361 break;
358 } 362 }
359 363out:
360 return 0; 364 pm_runtime_put_sync(mcasp->dev);
365 return ret;
361} 366}
362 367
363static int davinci_mcasp_set_clkdiv(struct snd_soc_dai *dai, int div_id, int div) 368static int davinci_mcasp_set_clkdiv(struct snd_soc_dai *dai, int div_id, int div)
@@ -448,7 +453,7 @@ static int davinci_config_channel_size(struct davinci_mcasp *mcasp,
448 return 0; 453 return 0;
449} 454}
450 455
451static int davinci_hw_common_param(struct davinci_mcasp *mcasp, int stream, 456static int mcasp_common_hw_param(struct davinci_mcasp *mcasp, int stream,
452 int channels) 457 int channels)
453{ 458{
454 int i; 459 int i;
@@ -524,12 +529,18 @@ static int davinci_hw_common_param(struct davinci_mcasp *mcasp, int stream,
524 return 0; 529 return 0;
525} 530}
526 531
527static void davinci_hw_param(struct davinci_mcasp *mcasp, int stream) 532static int mcasp_i2s_hw_param(struct davinci_mcasp *mcasp, int stream)
528{ 533{
529 int i, active_slots; 534 int i, active_slots;
530 u32 mask = 0; 535 u32 mask = 0;
531 u32 busel = 0; 536 u32 busel = 0;
532 537
538 if ((mcasp->tdm_slots < 2) || (mcasp->tdm_slots > 32)) {
539 dev_err(mcasp->dev, "tdm slot %d not supported\n",
540 mcasp->tdm_slots);
541 return -EINVAL;
542 }
543
533 active_slots = (mcasp->tdm_slots > 31) ? 32 : mcasp->tdm_slots; 544 active_slots = (mcasp->tdm_slots > 31) ? 32 : mcasp->tdm_slots;
534 for (i = 0; i < active_slots; i++) 545 for (i = 0; i < active_slots; i++)
535 mask |= (1 << i); 546 mask |= (1 << i);
@@ -539,35 +550,21 @@ static void davinci_hw_param(struct davinci_mcasp *mcasp, int stream)
539 if (!mcasp->dat_port) 550 if (!mcasp->dat_port)
540 busel = TXSEL; 551 busel = TXSEL;
541 552
542 if (stream == SNDRV_PCM_STREAM_PLAYBACK) { 553 mcasp_set_reg(mcasp, DAVINCI_MCASP_TXTDM_REG, mask);
543 /* bit stream is MSB first with no delay */ 554 mcasp_set_bits(mcasp, DAVINCI_MCASP_TXFMT_REG, busel | TXORD);
544 /* DSP_B mode */ 555 mcasp_mod_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG,
545 mcasp_set_reg(mcasp, DAVINCI_MCASP_TXTDM_REG, mask); 556 FSXMOD(mcasp->tdm_slots), FSXMOD(0x1FF));
546 mcasp_set_bits(mcasp, DAVINCI_MCASP_TXFMT_REG, busel | TXORD); 557
547 558 mcasp_set_reg(mcasp, DAVINCI_MCASP_RXTDM_REG, mask);
548 if ((mcasp->tdm_slots >= 2) && (mcasp->tdm_slots <= 32)) 559 mcasp_set_bits(mcasp, DAVINCI_MCASP_RXFMT_REG, busel | RXORD);
549 mcasp_mod_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG, 560 mcasp_mod_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG,
550 FSXMOD(mcasp->tdm_slots), FSXMOD(0x1FF)); 561 FSRMOD(mcasp->tdm_slots), FSRMOD(0x1FF));
551 else 562
552 printk(KERN_ERR "playback tdm slot %d not supported\n", 563 return 0;
553 mcasp->tdm_slots);
554 } else {
555 /* bit stream is MSB first with no delay */
556 /* DSP_B mode */
557 mcasp_set_bits(mcasp, DAVINCI_MCASP_RXFMT_REG, busel | RXORD);
558 mcasp_set_reg(mcasp, DAVINCI_MCASP_RXTDM_REG, mask);
559
560 if ((mcasp->tdm_slots >= 2) && (mcasp->tdm_slots <= 32))
561 mcasp_mod_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG,
562 FSRMOD(mcasp->tdm_slots), FSRMOD(0x1FF));
563 else
564 printk(KERN_ERR "capture tdm slot %d not supported\n",
565 mcasp->tdm_slots);
566 }
567} 564}
568 565
569/* S/PDIF */ 566/* S/PDIF */
570static void davinci_hw_dit_param(struct davinci_mcasp *mcasp) 567static int mcasp_dit_hw_param(struct davinci_mcasp *mcasp)
571{ 568{
572 /* Set the TX format : 24 bit right rotation, 32 bit slot, Pad 0 569 /* Set the TX format : 24 bit right rotation, 32 bit slot, Pad 0
573 and LSB first */ 570 and LSB first */
@@ -589,6 +586,8 @@ static void davinci_hw_dit_param(struct davinci_mcasp *mcasp)
589 586
590 /* Enable the DIT */ 587 /* Enable the DIT */
591 mcasp_set_bits(mcasp, DAVINCI_MCASP_TXDITCTL_REG, DITEN); 588 mcasp_set_bits(mcasp, DAVINCI_MCASP_TXDITCTL_REG, DITEN);
589
590 return 0;
592} 591}
593 592
594static int davinci_mcasp_hw_params(struct snd_pcm_substream *substream, 593static int davinci_mcasp_hw_params(struct snd_pcm_substream *substream,
@@ -605,13 +604,14 @@ static int davinci_mcasp_hw_params(struct snd_pcm_substream *substream,
605 u8 slots = mcasp->tdm_slots; 604 u8 slots = mcasp->tdm_slots;
606 u8 active_serializers; 605 u8 active_serializers;
607 int channels; 606 int channels;
607 int ret;
608 struct snd_interval *pcm_channels = hw_param_interval(params, 608 struct snd_interval *pcm_channels = hw_param_interval(params,
609 SNDRV_PCM_HW_PARAM_CHANNELS); 609 SNDRV_PCM_HW_PARAM_CHANNELS);
610 channels = pcm_channels->min; 610 channels = pcm_channels->min;
611 611
612 active_serializers = (channels + slots - 1) / slots; 612 active_serializers = (channels + slots - 1) / slots;
613 613
614 if (davinci_hw_common_param(mcasp, substream->stream, channels) == -EINVAL) 614 if (mcasp_common_hw_param(mcasp, substream->stream, channels) == -EINVAL)
615 return -EINVAL; 615 return -EINVAL;
616 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) 616 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
617 fifo_level = mcasp->txnumevt * active_serializers; 617 fifo_level = mcasp->txnumevt * active_serializers;
@@ -619,9 +619,12 @@ static int davinci_mcasp_hw_params(struct snd_pcm_substream *substream,
619 fifo_level = mcasp->rxnumevt * active_serializers; 619 fifo_level = mcasp->rxnumevt * active_serializers;
620 620
621 if (mcasp->op_mode == DAVINCI_MCASP_DIT_MODE) 621 if (mcasp->op_mode == DAVINCI_MCASP_DIT_MODE)
622 davinci_hw_dit_param(mcasp); 622 ret = mcasp_dit_hw_param(mcasp);
623 else 623 else
624 davinci_hw_param(mcasp, substream->stream); 624 ret = mcasp_i2s_hw_param(mcasp, substream->stream);
625
626 if (ret)
627 return ret;
625 628
626 switch (params_format(params)) { 629 switch (params_format(params)) {
627 case SNDRV_PCM_FORMAT_U8: 630 case SNDRV_PCM_FORMAT_U8:
@@ -678,19 +681,9 @@ static int davinci_mcasp_trigger(struct snd_pcm_substream *substream,
678 case SNDRV_PCM_TRIGGER_RESUME: 681 case SNDRV_PCM_TRIGGER_RESUME:
679 case SNDRV_PCM_TRIGGER_START: 682 case SNDRV_PCM_TRIGGER_START:
680 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: 683 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
681 ret = pm_runtime_get_sync(mcasp->dev);
682 if (IS_ERR_VALUE(ret))
683 dev_err(mcasp->dev, "pm_runtime_get_sync() failed\n");
684 davinci_mcasp_start(mcasp, substream->stream); 684 davinci_mcasp_start(mcasp, substream->stream);
685 break; 685 break;
686
687 case SNDRV_PCM_TRIGGER_SUSPEND: 686 case SNDRV_PCM_TRIGGER_SUSPEND:
688 davinci_mcasp_stop(mcasp, substream->stream);
689 ret = pm_runtime_put_sync(mcasp->dev);
690 if (IS_ERR_VALUE(ret))
691 dev_err(mcasp->dev, "pm_runtime_put_sync() failed\n");
692 break;
693
694 case SNDRV_PCM_TRIGGER_STOP: 687 case SNDRV_PCM_TRIGGER_STOP:
695 case SNDRV_PCM_TRIGGER_PAUSE_PUSH: 688 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
696 davinci_mcasp_stop(mcasp, substream->stream); 689 davinci_mcasp_stop(mcasp, substream->stream);
diff --git a/sound/soc/fsl/fsl_esai.c b/sound/soc/fsl/fsl_esai.c
index d0c72ed261e7..c84026c99134 100644
--- a/sound/soc/fsl/fsl_esai.c
+++ b/sound/soc/fsl/fsl_esai.c
@@ -326,7 +326,7 @@ static int fsl_esai_set_dai_tdm_slot(struct snd_soc_dai *dai, u32 tx_mask,
326 regmap_update_bits(esai_priv->regmap, REG_ESAI_TSMA, 326 regmap_update_bits(esai_priv->regmap, REG_ESAI_TSMA,
327 ESAI_xSMA_xS_MASK, ESAI_xSMA_xS(tx_mask)); 327 ESAI_xSMA_xS_MASK, ESAI_xSMA_xS(tx_mask));
328 regmap_update_bits(esai_priv->regmap, REG_ESAI_TSMB, 328 regmap_update_bits(esai_priv->regmap, REG_ESAI_TSMB,
329 ESAI_xSMA_xS_MASK, ESAI_xSMB_xS(tx_mask)); 329 ESAI_xSMB_xS_MASK, ESAI_xSMB_xS(tx_mask));
330 330
331 regmap_update_bits(esai_priv->regmap, REG_ESAI_RCCR, 331 regmap_update_bits(esai_priv->regmap, REG_ESAI_RCCR,
332 ESAI_xCCR_xDC_MASK, ESAI_xCCR_xDC(slots)); 332 ESAI_xCCR_xDC_MASK, ESAI_xCCR_xDC(slots));
@@ -334,7 +334,7 @@ static int fsl_esai_set_dai_tdm_slot(struct snd_soc_dai *dai, u32 tx_mask,
334 regmap_update_bits(esai_priv->regmap, REG_ESAI_RSMA, 334 regmap_update_bits(esai_priv->regmap, REG_ESAI_RSMA,
335 ESAI_xSMA_xS_MASK, ESAI_xSMA_xS(rx_mask)); 335 ESAI_xSMA_xS_MASK, ESAI_xSMA_xS(rx_mask));
336 regmap_update_bits(esai_priv->regmap, REG_ESAI_RSMB, 336 regmap_update_bits(esai_priv->regmap, REG_ESAI_RSMB,
337 ESAI_xSMA_xS_MASK, ESAI_xSMB_xS(rx_mask)); 337 ESAI_xSMB_xS_MASK, ESAI_xSMB_xS(rx_mask));
338 338
339 esai_priv->slot_width = slot_width; 339 esai_priv->slot_width = slot_width;
340 340
diff --git a/sound/soc/fsl/fsl_esai.h b/sound/soc/fsl/fsl_esai.h
index 9c9f957fcae1..75e14033e8d8 100644
--- a/sound/soc/fsl/fsl_esai.h
+++ b/sound/soc/fsl/fsl_esai.h
@@ -322,7 +322,7 @@
322#define ESAI_xSMB_xS_SHIFT 0 322#define ESAI_xSMB_xS_SHIFT 0
323#define ESAI_xSMB_xS_WIDTH 16 323#define ESAI_xSMB_xS_WIDTH 16
324#define ESAI_xSMB_xS_MASK (((1 << ESAI_xSMB_xS_WIDTH) - 1) << ESAI_xSMB_xS_SHIFT) 324#define ESAI_xSMB_xS_MASK (((1 << ESAI_xSMB_xS_WIDTH) - 1) << ESAI_xSMB_xS_SHIFT)
325#define ESAI_xSMB_xS(v) (((v) >> ESAI_xSMA_xS_WIDTH) & ESAI_xSMA_xS_MASK) 325#define ESAI_xSMB_xS(v) (((v) >> ESAI_xSMA_xS_WIDTH) & ESAI_xSMB_xS_MASK)
326 326
327/* Port C Direction Register -- REG_ESAI_PRRC 0xF8 */ 327/* Port C Direction Register -- REG_ESAI_PRRC 0xF8 */
328#define ESAI_PRRC_PDC_SHIFT 0 328#define ESAI_PRRC_PDC_SHIFT 0
diff --git a/sound/soc/fsl/imx-mc13783.c b/sound/soc/fsl/imx-mc13783.c
index 79cee782dbbf..a2fd7321b5a9 100644
--- a/sound/soc/fsl/imx-mc13783.c
+++ b/sound/soc/fsl/imx-mc13783.c
@@ -160,7 +160,6 @@ static struct platform_driver imx_mc13783_audio_driver = {
160 .driver = { 160 .driver = {
161 .name = "imx_mc13783", 161 .name = "imx_mc13783",
162 .owner = THIS_MODULE, 162 .owner = THIS_MODULE,
163 .pm = &snd_soc_pm_ops,
164 }, 163 },
165 .probe = imx_mc13783_probe, 164 .probe = imx_mc13783_probe,
166 .remove = imx_mc13783_remove 165 .remove = imx_mc13783_remove
diff --git a/sound/soc/fsl/imx-sgtl5000.c b/sound/soc/fsl/imx-sgtl5000.c
index f2beae78969f..1cb22dd034eb 100644
--- a/sound/soc/fsl/imx-sgtl5000.c
+++ b/sound/soc/fsl/imx-sgtl5000.c
@@ -33,8 +33,7 @@ struct imx_sgtl5000_data {
33 33
34static int imx_sgtl5000_dai_init(struct snd_soc_pcm_runtime *rtd) 34static int imx_sgtl5000_dai_init(struct snd_soc_pcm_runtime *rtd)
35{ 35{
36 struct imx_sgtl5000_data *data = container_of(rtd->card, 36 struct imx_sgtl5000_data *data = snd_soc_card_get_drvdata(rtd->card);
37 struct imx_sgtl5000_data, card);
38 struct device *dev = rtd->card->dev; 37 struct device *dev = rtd->card->dev;
39 int ret; 38 int ret;
40 39
@@ -159,13 +158,15 @@ static int imx_sgtl5000_probe(struct platform_device *pdev)
159 data->card.dapm_widgets = imx_sgtl5000_dapm_widgets; 158 data->card.dapm_widgets = imx_sgtl5000_dapm_widgets;
160 data->card.num_dapm_widgets = ARRAY_SIZE(imx_sgtl5000_dapm_widgets); 159 data->card.num_dapm_widgets = ARRAY_SIZE(imx_sgtl5000_dapm_widgets);
161 160
161 platform_set_drvdata(pdev, &data->card);
162 snd_soc_card_set_drvdata(&data->card, data);
163
162 ret = devm_snd_soc_register_card(&pdev->dev, &data->card); 164 ret = devm_snd_soc_register_card(&pdev->dev, &data->card);
163 if (ret) { 165 if (ret) {
164 dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret); 166 dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret);
165 goto fail; 167 goto fail;
166 } 168 }
167 169
168 platform_set_drvdata(pdev, data);
169 of_node_put(ssi_np); 170 of_node_put(ssi_np);
170 of_node_put(codec_np); 171 of_node_put(codec_np);
171 172
@@ -184,7 +185,8 @@ fail:
184 185
185static int imx_sgtl5000_remove(struct platform_device *pdev) 186static int imx_sgtl5000_remove(struct platform_device *pdev)
186{ 187{
187 struct imx_sgtl5000_data *data = platform_get_drvdata(pdev); 188 struct snd_soc_card *card = platform_get_drvdata(pdev);
189 struct imx_sgtl5000_data *data = snd_soc_card_get_drvdata(card);
188 190
189 clk_put(data->codec_clk); 191 clk_put(data->codec_clk);
190 192
diff --git a/sound/soc/fsl/imx-wm8962.c b/sound/soc/fsl/imx-wm8962.c
index 3fd76bc391de..3a3d17ce6ba4 100644
--- a/sound/soc/fsl/imx-wm8962.c
+++ b/sound/soc/fsl/imx-wm8962.c
@@ -71,7 +71,7 @@ static int imx_wm8962_set_bias_level(struct snd_soc_card *card,
71{ 71{
72 struct snd_soc_dai *codec_dai = card->rtd[0].codec_dai; 72 struct snd_soc_dai *codec_dai = card->rtd[0].codec_dai;
73 struct imx_priv *priv = &card_priv; 73 struct imx_priv *priv = &card_priv;
74 struct imx_wm8962_data *data = platform_get_drvdata(priv->pdev); 74 struct imx_wm8962_data *data = snd_soc_card_get_drvdata(card);
75 struct device *dev = &priv->pdev->dev; 75 struct device *dev = &priv->pdev->dev;
76 unsigned int pll_out; 76 unsigned int pll_out;
77 int ret; 77 int ret;
@@ -137,7 +137,7 @@ static int imx_wm8962_late_probe(struct snd_soc_card *card)
137{ 137{
138 struct snd_soc_dai *codec_dai = card->rtd[0].codec_dai; 138 struct snd_soc_dai *codec_dai = card->rtd[0].codec_dai;
139 struct imx_priv *priv = &card_priv; 139 struct imx_priv *priv = &card_priv;
140 struct imx_wm8962_data *data = platform_get_drvdata(priv->pdev); 140 struct imx_wm8962_data *data = snd_soc_card_get_drvdata(card);
141 struct device *dev = &priv->pdev->dev; 141 struct device *dev = &priv->pdev->dev;
142 int ret; 142 int ret;
143 143
@@ -264,13 +264,15 @@ static int imx_wm8962_probe(struct platform_device *pdev)
264 data->card.late_probe = imx_wm8962_late_probe; 264 data->card.late_probe = imx_wm8962_late_probe;
265 data->card.set_bias_level = imx_wm8962_set_bias_level; 265 data->card.set_bias_level = imx_wm8962_set_bias_level;
266 266
267 platform_set_drvdata(pdev, &data->card);
268 snd_soc_card_set_drvdata(&data->card, data);
269
267 ret = devm_snd_soc_register_card(&pdev->dev, &data->card); 270 ret = devm_snd_soc_register_card(&pdev->dev, &data->card);
268 if (ret) { 271 if (ret) {
269 dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret); 272 dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret);
270 goto clk_fail; 273 goto clk_fail;
271 } 274 }
272 275
273 platform_set_drvdata(pdev, data);
274 of_node_put(ssi_np); 276 of_node_put(ssi_np);
275 of_node_put(codec_np); 277 of_node_put(codec_np);
276 278
@@ -289,7 +291,8 @@ fail:
289 291
290static int imx_wm8962_remove(struct platform_device *pdev) 292static int imx_wm8962_remove(struct platform_device *pdev)
291{ 293{
292 struct imx_wm8962_data *data = platform_get_drvdata(pdev); 294 struct snd_soc_card *card = platform_get_drvdata(pdev);
295 struct imx_wm8962_data *data = snd_soc_card_get_drvdata(card);
293 296
294 if (!IS_ERR(data->codec_clk)) 297 if (!IS_ERR(data->codec_clk))
295 clk_disable_unprepare(data->codec_clk); 298 clk_disable_unprepare(data->codec_clk);
diff --git a/sound/soc/samsung/Kconfig b/sound/soc/samsung/Kconfig
index 454f41cfc828..350757400391 100644
--- a/sound/soc/samsung/Kconfig
+++ b/sound/soc/samsung/Kconfig
@@ -59,7 +59,7 @@ config SND_SOC_SAMSUNG_JIVE_WM8750
59 select SND_SOC_WM8750 59 select SND_SOC_WM8750
60 select SND_S3C2412_SOC_I2S 60 select SND_S3C2412_SOC_I2S
61 help 61 help
62 Sat Y if you want to add support for SoC audio on the Jive. 62 Say Y if you want to add support for SoC audio on the Jive.
63 63
64config SND_SOC_SAMSUNG_SMDK_WM8580 64config SND_SOC_SAMSUNG_SMDK_WM8580
65 tristate "SoC I2S Audio support for WM8580 on SMDK" 65 tristate "SoC I2S Audio support for WM8580 on SMDK"
@@ -145,11 +145,11 @@ config SND_SOC_SAMSUNG_RX1950_UDA1380
145 145
146config SND_SOC_SAMSUNG_SMDK_WM9713 146config SND_SOC_SAMSUNG_SMDK_WM9713
147 tristate "SoC AC97 Audio support for SMDK with WM9713" 147 tristate "SoC AC97 Audio support for SMDK with WM9713"
148 depends on SND_SOC_SAMSUNG && (MACH_SMDK6410 || MACH_SMDKC100 || MACH_SMDKV210 || MACH_SMDKC110 || MACH_SMDKV310 || MACH_SMDKC210) 148 depends on SND_SOC_SAMSUNG && (MACH_SMDK6410 || MACH_SMDKC100 || MACH_SMDKV210 || MACH_SMDKC110)
149 select SND_SOC_WM9713 149 select SND_SOC_WM9713
150 select SND_SAMSUNG_AC97 150 select SND_SAMSUNG_AC97
151 help 151 help
152 Sat Y if you want to add support for SoC audio on the SMDK. 152 Say Y if you want to add support for SoC audio on the SMDK.
153 153
154config SND_SOC_SMARTQ 154config SND_SOC_SMARTQ
155 tristate "SoC I2S Audio support for SmartQ board" 155 tristate "SoC I2S Audio support for SmartQ board"
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index dc8ff13187f7..b9dc6acbba8c 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -1218,7 +1218,7 @@ int dapm_regulator_event(struct snd_soc_dapm_widget *w,
1218 ret = regulator_allow_bypass(w->regulator, false); 1218 ret = regulator_allow_bypass(w->regulator, false);
1219 if (ret != 0) 1219 if (ret != 0)
1220 dev_warn(w->dapm->dev, 1220 dev_warn(w->dapm->dev,
1221 "ASoC: Failed to bypass %s: %d\n", 1221 "ASoC: Failed to unbypass %s: %d\n",
1222 w->name, ret); 1222 w->name, ret);
1223 } 1223 }
1224 1224
@@ -1228,7 +1228,7 @@ int dapm_regulator_event(struct snd_soc_dapm_widget *w,
1228 ret = regulator_allow_bypass(w->regulator, true); 1228 ret = regulator_allow_bypass(w->regulator, true);
1229 if (ret != 0) 1229 if (ret != 0)
1230 dev_warn(w->dapm->dev, 1230 dev_warn(w->dapm->dev,
1231 "ASoC: Failed to unbypass %s: %d\n", 1231 "ASoC: Failed to bypass %s: %d\n",
1232 w->name, ret); 1232 w->name, ret);
1233 } 1233 }
1234 1234
@@ -3210,15 +3210,11 @@ int snd_soc_dapm_put_pin_switch(struct snd_kcontrol *kcontrol,
3210 struct snd_soc_card *card = snd_kcontrol_chip(kcontrol); 3210 struct snd_soc_card *card = snd_kcontrol_chip(kcontrol);
3211 const char *pin = (const char *)kcontrol->private_value; 3211 const char *pin = (const char *)kcontrol->private_value;
3212 3212
3213 mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
3214
3215 if (ucontrol->value.integer.value[0]) 3213 if (ucontrol->value.integer.value[0])
3216 snd_soc_dapm_enable_pin(&card->dapm, pin); 3214 snd_soc_dapm_enable_pin(&card->dapm, pin);
3217 else 3215 else
3218 snd_soc_dapm_disable_pin(&card->dapm, pin); 3216 snd_soc_dapm_disable_pin(&card->dapm, pin);
3219 3217
3220 mutex_unlock(&card->dapm_mutex);
3221
3222 snd_soc_dapm_sync(&card->dapm); 3218 snd_soc_dapm_sync(&card->dapm);
3223 return 0; 3219 return 0;
3224} 3220}
@@ -3248,7 +3244,7 @@ snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm,
3248 ret = regulator_allow_bypass(w->regulator, true); 3244 ret = regulator_allow_bypass(w->regulator, true);
3249 if (ret != 0) 3245 if (ret != 0)
3250 dev_warn(w->dapm->dev, 3246 dev_warn(w->dapm->dev,
3251 "ASoC: Failed to unbypass %s: %d\n", 3247 "ASoC: Failed to bypass %s: %d\n",
3252 w->name, ret); 3248 w->name, ret);
3253 } 3249 }
3254 break; 3250 break;
@@ -3767,23 +3763,52 @@ void snd_soc_dapm_stream_event(struct snd_soc_pcm_runtime *rtd, int stream,
3767} 3763}
3768 3764
3769/** 3765/**
3766 * snd_soc_dapm_enable_pin_unlocked - enable pin.
3767 * @dapm: DAPM context
3768 * @pin: pin name
3769 *
3770 * Enables input/output pin and its parents or children widgets iff there is
3771 * a valid audio route and active audio stream.
3772 *
3773 * Requires external locking.
3774 *
3775 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
3776 * do any widget power switching.
3777 */
3778int snd_soc_dapm_enable_pin_unlocked(struct snd_soc_dapm_context *dapm,
3779 const char *pin)
3780{
3781 return snd_soc_dapm_set_pin(dapm, pin, 1);
3782}
3783EXPORT_SYMBOL_GPL(snd_soc_dapm_enable_pin_unlocked);
3784
3785/**
3770 * snd_soc_dapm_enable_pin - enable pin. 3786 * snd_soc_dapm_enable_pin - enable pin.
3771 * @dapm: DAPM context 3787 * @dapm: DAPM context
3772 * @pin: pin name 3788 * @pin: pin name
3773 * 3789 *
3774 * Enables input/output pin and its parents or children widgets iff there is 3790 * Enables input/output pin and its parents or children widgets iff there is
3775 * a valid audio route and active audio stream. 3791 * a valid audio route and active audio stream.
3792 *
3776 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to 3793 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
3777 * do any widget power switching. 3794 * do any widget power switching.
3778 */ 3795 */
3779int snd_soc_dapm_enable_pin(struct snd_soc_dapm_context *dapm, const char *pin) 3796int snd_soc_dapm_enable_pin(struct snd_soc_dapm_context *dapm, const char *pin)
3780{ 3797{
3781 return snd_soc_dapm_set_pin(dapm, pin, 1); 3798 int ret;
3799
3800 mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
3801
3802 ret = snd_soc_dapm_set_pin(dapm, pin, 1);
3803
3804 mutex_unlock(&dapm->card->dapm_mutex);
3805
3806 return ret;
3782} 3807}
3783EXPORT_SYMBOL_GPL(snd_soc_dapm_enable_pin); 3808EXPORT_SYMBOL_GPL(snd_soc_dapm_enable_pin);
3784 3809
3785/** 3810/**
3786 * snd_soc_dapm_force_enable_pin - force a pin to be enabled 3811 * snd_soc_dapm_force_enable_pin_unlocked - force a pin to be enabled
3787 * @dapm: DAPM context 3812 * @dapm: DAPM context
3788 * @pin: pin name 3813 * @pin: pin name
3789 * 3814 *
@@ -3791,11 +3816,13 @@ EXPORT_SYMBOL_GPL(snd_soc_dapm_enable_pin);
3791 * intended for use with microphone bias supplies used in microphone 3816 * intended for use with microphone bias supplies used in microphone
3792 * jack detection. 3817 * jack detection.
3793 * 3818 *
3819 * Requires external locking.
3820 *
3794 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to 3821 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
3795 * do any widget power switching. 3822 * do any widget power switching.
3796 */ 3823 */
3797int snd_soc_dapm_force_enable_pin(struct snd_soc_dapm_context *dapm, 3824int snd_soc_dapm_force_enable_pin_unlocked(struct snd_soc_dapm_context *dapm,
3798 const char *pin) 3825 const char *pin)
3799{ 3826{
3800 struct snd_soc_dapm_widget *w = dapm_find_widget(dapm, pin, true); 3827 struct snd_soc_dapm_widget *w = dapm_find_widget(dapm, pin, true);
3801 3828
@@ -3811,25 +3838,103 @@ int snd_soc_dapm_force_enable_pin(struct snd_soc_dapm_context *dapm,
3811 3838
3812 return 0; 3839 return 0;
3813} 3840}
3841EXPORT_SYMBOL_GPL(snd_soc_dapm_force_enable_pin_unlocked);
3842
3843/**
3844 * snd_soc_dapm_force_enable_pin - force a pin to be enabled
3845 * @dapm: DAPM context
3846 * @pin: pin name
3847 *
3848 * Enables input/output pin regardless of any other state. This is
3849 * intended for use with microphone bias supplies used in microphone
3850 * jack detection.
3851 *
3852 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
3853 * do any widget power switching.
3854 */
3855int snd_soc_dapm_force_enable_pin(struct snd_soc_dapm_context *dapm,
3856 const char *pin)
3857{
3858 int ret;
3859
3860 mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
3861
3862 ret = snd_soc_dapm_force_enable_pin_unlocked(dapm, pin);
3863
3864 mutex_unlock(&dapm->card->dapm_mutex);
3865
3866 return ret;
3867}
3814EXPORT_SYMBOL_GPL(snd_soc_dapm_force_enable_pin); 3868EXPORT_SYMBOL_GPL(snd_soc_dapm_force_enable_pin);
3815 3869
3816/** 3870/**
3871 * snd_soc_dapm_disable_pin_unlocked - disable pin.
3872 * @dapm: DAPM context
3873 * @pin: pin name
3874 *
3875 * Disables input/output pin and its parents or children widgets.
3876 *
3877 * Requires external locking.
3878 *
3879 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
3880 * do any widget power switching.
3881 */
3882int snd_soc_dapm_disable_pin_unlocked(struct snd_soc_dapm_context *dapm,
3883 const char *pin)
3884{
3885 return snd_soc_dapm_set_pin(dapm, pin, 0);
3886}
3887EXPORT_SYMBOL_GPL(snd_soc_dapm_disable_pin_unlocked);
3888
3889/**
3817 * snd_soc_dapm_disable_pin - disable pin. 3890 * snd_soc_dapm_disable_pin - disable pin.
3818 * @dapm: DAPM context 3891 * @dapm: DAPM context
3819 * @pin: pin name 3892 * @pin: pin name
3820 * 3893 *
3821 * Disables input/output pin and its parents or children widgets. 3894 * Disables input/output pin and its parents or children widgets.
3895 *
3822 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to 3896 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
3823 * do any widget power switching. 3897 * do any widget power switching.
3824 */ 3898 */
3825int snd_soc_dapm_disable_pin(struct snd_soc_dapm_context *dapm, 3899int snd_soc_dapm_disable_pin(struct snd_soc_dapm_context *dapm,
3826 const char *pin) 3900 const char *pin)
3827{ 3901{
3828 return snd_soc_dapm_set_pin(dapm, pin, 0); 3902 int ret;
3903
3904 mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
3905
3906 ret = snd_soc_dapm_set_pin(dapm, pin, 0);
3907
3908 mutex_unlock(&dapm->card->dapm_mutex);
3909
3910 return ret;
3829} 3911}
3830EXPORT_SYMBOL_GPL(snd_soc_dapm_disable_pin); 3912EXPORT_SYMBOL_GPL(snd_soc_dapm_disable_pin);
3831 3913
3832/** 3914/**
3915 * snd_soc_dapm_nc_pin_unlocked - permanently disable pin.
3916 * @dapm: DAPM context
3917 * @pin: pin name
3918 *
3919 * Marks the specified pin as being not connected, disabling it along
3920 * any parent or child widgets. At present this is identical to
3921 * snd_soc_dapm_disable_pin() but in future it will be extended to do
3922 * additional things such as disabling controls which only affect
3923 * paths through the pin.
3924 *
3925 * Requires external locking.
3926 *
3927 * NOTE: snd_soc_dapm_sync() needs to be called after this for DAPM to
3928 * do any widget power switching.
3929 */
3930int snd_soc_dapm_nc_pin_unlocked(struct snd_soc_dapm_context *dapm,
3931 const char *pin)
3932{
3933 return snd_soc_dapm_set_pin(dapm, pin, 0);
3934}
3935EXPORT_SYMBOL_GPL(snd_soc_dapm_nc_pin_unlocked);
3936
3937/**
3833 * snd_soc_dapm_nc_pin - permanently disable pin. 3938 * snd_soc_dapm_nc_pin - permanently disable pin.
3834 * @dapm: DAPM context 3939 * @dapm: DAPM context
3835 * @pin: pin name 3940 * @pin: pin name
@@ -3845,7 +3950,15 @@ EXPORT_SYMBOL_GPL(snd_soc_dapm_disable_pin);
3845 */ 3950 */
3846int snd_soc_dapm_nc_pin(struct snd_soc_dapm_context *dapm, const char *pin) 3951int snd_soc_dapm_nc_pin(struct snd_soc_dapm_context *dapm, const char *pin)
3847{ 3952{
3848 return snd_soc_dapm_set_pin(dapm, pin, 0); 3953 int ret;
3954
3955 mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
3956
3957 ret = snd_soc_dapm_set_pin(dapm, pin, 0);
3958
3959 mutex_unlock(&dapm->card->dapm_mutex);
3960
3961 return ret;
3849} 3962}
3850EXPORT_SYMBOL_GPL(snd_soc_dapm_nc_pin); 3963EXPORT_SYMBOL_GPL(snd_soc_dapm_nc_pin);
3851 3964
diff --git a/sound/soc/txx9/txx9aclc-ac97.c b/sound/soc/txx9/txx9aclc-ac97.c
index e0305a148568..9edd68db9f48 100644
--- a/sound/soc/txx9/txx9aclc-ac97.c
+++ b/sound/soc/txx9/txx9aclc-ac97.c
@@ -183,14 +183,16 @@ static int txx9aclc_ac97_dev_probe(struct platform_device *pdev)
183 irq = platform_get_irq(pdev, 0); 183 irq = platform_get_irq(pdev, 0);
184 if (irq < 0) 184 if (irq < 0)
185 return irq; 185 return irq;
186
187 drvdata = devm_kzalloc(&pdev->dev, sizeof(*drvdata), GFP_KERNEL);
188 if (!drvdata)
189 return -ENOMEM;
190
186 r = platform_get_resource(pdev, IORESOURCE_MEM, 0); 191 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
187 drvdata->base = devm_ioremap_resource(&pdev->dev, r); 192 drvdata->base = devm_ioremap_resource(&pdev->dev, r);
188 if (IS_ERR(drvdata->base)) 193 if (IS_ERR(drvdata->base))
189 return PTR_ERR(drvdata->base); 194 return PTR_ERR(drvdata->base);
190 195
191 drvdata = devm_kzalloc(&pdev->dev, sizeof(*drvdata), GFP_KERNEL);
192 if (!drvdata)
193 return -ENOMEM;
194 platform_set_drvdata(pdev, drvdata); 196 platform_set_drvdata(pdev, drvdata);
195 drvdata->physbase = r->start; 197 drvdata->physbase = r->start;
196 if (sizeof(drvdata->physbase) > sizeof(r->start) && 198 if (sizeof(drvdata->physbase) > sizeof(r->start) &&
diff --git a/sound/usb/mixer_maps.c b/sound/usb/mixer_maps.c
index 32af6b741ef5..d1d72ff50347 100644
--- a/sound/usb/mixer_maps.c
+++ b/sound/usb/mixer_maps.c
@@ -328,6 +328,11 @@ static struct usbmix_name_map gamecom780_map[] = {
328 {} 328 {}
329}; 329};
330 330
331static const struct usbmix_name_map kef_x300a_map[] = {
332 { 10, NULL }, /* firmware locks up (?) when we try to access this FU */
333 { 0 }
334};
335
331/* 336/*
332 * Control map entries 337 * Control map entries
333 */ 338 */
@@ -419,6 +424,10 @@ static struct usbmix_ctl_map usbmix_ctl_maps[] = {
419 .id = USB_ID(0x200c, 0x1018), 424 .id = USB_ID(0x200c, 0x1018),
420 .map = ebox44_map, 425 .map = ebox44_map,
421 }, 426 },
427 {
428 .id = USB_ID(0x27ac, 0x1000),
429 .map = kef_x300a_map,
430 },
422 { 0 } /* terminator */ 431 { 0 } /* terminator */
423}; 432};
424 433
diff --git a/tools/lib/lockdep/Makefile b/tools/lib/lockdep/Makefile
index da8b7aa3d351..07b0b7542511 100644
--- a/tools/lib/lockdep/Makefile
+++ b/tools/lib/lockdep/Makefile
@@ -87,8 +87,8 @@ endif # BUILD_SRC
87# We process the rest of the Makefile if this is the final invocation of make 87# We process the rest of the Makefile if this is the final invocation of make
88ifeq ($(skip-makefile),) 88ifeq ($(skip-makefile),)
89 89
90srctree := $(if $(BUILD_SRC),$(BUILD_SRC),$(CURDIR)) 90srctree := $(realpath $(if $(BUILD_SRC),$(BUILD_SRC),$(CURDIR)))
91objtree := $(CURDIR) 91objtree := $(realpath $(CURDIR))
92src := $(srctree) 92src := $(srctree)
93obj := $(objtree) 93obj := $(objtree)
94 94
@@ -112,7 +112,7 @@ export Q VERBOSE
112 112
113LIBLOCKDEP_VERSION = $(LL_VERSION).$(LL_PATCHLEVEL).$(LL_EXTRAVERSION) 113LIBLOCKDEP_VERSION = $(LL_VERSION).$(LL_PATCHLEVEL).$(LL_EXTRAVERSION)
114 114
115INCLUDES = -I. -I/usr/local/include -I./uinclude $(CONFIG_INCLUDES) 115INCLUDES = -I. -I/usr/local/include -I./uinclude -I./include $(CONFIG_INCLUDES)
116 116
117# Set compile option CFLAGS if not set elsewhere 117# Set compile option CFLAGS if not set elsewhere
118CFLAGS ?= -g -DCONFIG_LOCKDEP -DCONFIG_STACKTRACE -DCONFIG_PROVE_LOCKING -DBITS_PER_LONG=__WORDSIZE -DLIBLOCKDEP_VERSION='"$(LIBLOCKDEP_VERSION)"' -rdynamic -O0 -g 118CFLAGS ?= -g -DCONFIG_LOCKDEP -DCONFIG_STACKTRACE -DCONFIG_PROVE_LOCKING -DBITS_PER_LONG=__WORDSIZE -DLIBLOCKDEP_VERSION='"$(LIBLOCKDEP_VERSION)"' -rdynamic -O0 -g
diff --git a/tools/lib/lockdep/preload.c b/tools/lib/lockdep/preload.c
index f8465a811aa5..23bd69cb5ade 100644
--- a/tools/lib/lockdep/preload.c
+++ b/tools/lib/lockdep/preload.c
@@ -418,7 +418,7 @@ int pthread_rwlock_unlock(pthread_rwlock_t *rwlock)
418 418
419__attribute__((constructor)) static void init_preload(void) 419__attribute__((constructor)) static void init_preload(void)
420{ 420{
421 if (__init_state != done) 421 if (__init_state == done)
422 return; 422 return;
423 423
424#ifndef __GLIBC__ 424#ifndef __GLIBC__
diff --git a/tools/lib/lockdep/run_tests.sh b/tools/lib/lockdep/run_tests.sh
index 5334ad9d39b7..5334ad9d39b7 100644..100755
--- a/tools/lib/lockdep/run_tests.sh
+++ b/tools/lib/lockdep/run_tests.sh
diff --git a/tools/lib/lockdep/uinclude/asm/hash.h b/tools/lib/lockdep/uinclude/asm/hash.h
new file mode 100644
index 000000000000..d82b170bb216
--- /dev/null
+++ b/tools/lib/lockdep/uinclude/asm/hash.h
@@ -0,0 +1,6 @@
1#ifndef __ASM_GENERIC_HASH_H
2#define __ASM_GENERIC_HASH_H
3
4/* Stub */
5
6#endif /* __ASM_GENERIC_HASH_H */
diff --git a/tools/lib/lockdep/uinclude/linux/rcu.h b/tools/lib/lockdep/uinclude/linux/rcu.h
index 4c99fcb5da27..042ee8e463c9 100644
--- a/tools/lib/lockdep/uinclude/linux/rcu.h
+++ b/tools/lib/lockdep/uinclude/linux/rcu.h
@@ -13,4 +13,9 @@ static inline int rcu_is_cpu_idle(void)
13 return 1; 13 return 1;
14} 14}
15 15
16static inline bool rcu_is_watching(void)
17{
18 return false;
19}
20
16#endif 21#endif
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 3c53ec268fbc..02f985f3a396 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -113,14 +113,16 @@ static int report__add_mem_hist_entry(struct perf_tool *tool, struct addr_locati
113 if (!he) 113 if (!he)
114 return -ENOMEM; 114 return -ENOMEM;
115 115
116 err = hist_entry__inc_addr_samples(he, evsel->idx, al->addr); 116 if (ui__has_annotation()) {
117 if (err) 117 err = hist_entry__inc_addr_samples(he, evsel->idx, al->addr);
118 goto out; 118 if (err)
119 goto out;
119 120
120 mx = he->mem_info; 121 mx = he->mem_info;
121 err = addr_map_symbol__inc_samples(&mx->daddr, evsel->idx); 122 err = addr_map_symbol__inc_samples(&mx->daddr, evsel->idx);
122 if (err) 123 if (err)
123 goto out; 124 goto out;
125 }
124 126
125 evsel->hists.stats.total_period += cost; 127 evsel->hists.stats.total_period += cost;
126 hists__inc_nr_events(&evsel->hists, PERF_RECORD_SAMPLE); 128 hists__inc_nr_events(&evsel->hists, PERF_RECORD_SAMPLE);
@@ -164,14 +166,18 @@ static int report__add_branch_hist_entry(struct perf_tool *tool, struct addr_loc
164 he = __hists__add_entry(&evsel->hists, al, parent, &bi[i], NULL, 166 he = __hists__add_entry(&evsel->hists, al, parent, &bi[i], NULL,
165 1, 1, 0); 167 1, 1, 0);
166 if (he) { 168 if (he) {
167 bx = he->branch_info; 169 if (ui__has_annotation()) {
168 err = addr_map_symbol__inc_samples(&bx->from, evsel->idx); 170 bx = he->branch_info;
169 if (err) 171 err = addr_map_symbol__inc_samples(&bx->from,
170 goto out; 172 evsel->idx);
171 173 if (err)
172 err = addr_map_symbol__inc_samples(&bx->to, evsel->idx); 174 goto out;
173 if (err) 175
174 goto out; 176 err = addr_map_symbol__inc_samples(&bx->to,
177 evsel->idx);
178 if (err)
179 goto out;
180 }
175 181
176 evsel->hists.stats.total_period += 1; 182 evsel->hists.stats.total_period += 1;
177 hists__inc_nr_events(&evsel->hists, PERF_RECORD_SAMPLE); 183 hists__inc_nr_events(&evsel->hists, PERF_RECORD_SAMPLE);
@@ -205,7 +211,9 @@ static int report__add_hist_entry(struct perf_tool *tool, struct perf_evsel *evs
205 if (err) 211 if (err)
206 goto out; 212 goto out;
207 213
208 err = hist_entry__inc_addr_samples(he, evsel->idx, al->addr); 214 if (ui__has_annotation())
215 err = hist_entry__inc_addr_samples(he, evsel->idx, al->addr);
216
209 evsel->hists.stats.total_period += sample->period; 217 evsel->hists.stats.total_period += sample->period;
210 hists__inc_nr_events(&evsel->hists, PERF_RECORD_SAMPLE); 218 hists__inc_nr_events(&evsel->hists, PERF_RECORD_SAMPLE);
211out: 219out:
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 76cd510d34d0..5f989a7d8bc2 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -176,7 +176,7 @@ static void perf_top__record_precise_ip(struct perf_top *top,
176{ 176{
177 struct annotation *notes; 177 struct annotation *notes;
178 struct symbol *sym; 178 struct symbol *sym;
179 int err; 179 int err = 0;
180 180
181 if (he == NULL || he->ms.sym == NULL || 181 if (he == NULL || he->ms.sym == NULL ||
182 ((top->sym_filter_entry == NULL || 182 ((top->sym_filter_entry == NULL ||
@@ -190,7 +190,9 @@ static void perf_top__record_precise_ip(struct perf_top *top,
190 return; 190 return;
191 191
192 ip = he->ms.map->map_ip(he->ms.map, ip); 192 ip = he->ms.map->map_ip(he->ms.map, ip);
193 err = hist_entry__inc_addr_samples(he, counter, ip); 193
194 if (ui__has_annotation())
195 err = hist_entry__inc_addr_samples(he, counter, ip);
194 196
195 pthread_mutex_unlock(&notes->lock); 197 pthread_mutex_unlock(&notes->lock);
196 198
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 896f27047ed6..6aa6fb6f7bd9 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -37,6 +37,10 @@
37# define MADV_UNMERGEABLE 13 37# define MADV_UNMERGEABLE 13
38#endif 38#endif
39 39
40#ifndef EFD_SEMAPHORE
41# define EFD_SEMAPHORE 1
42#endif
43
40struct tp_field { 44struct tp_field {
41 int offset; 45 int offset;
42 union { 46 union {
@@ -279,6 +283,11 @@ static size_t syscall_arg__scnprintf_strarray(char *bf, size_t size,
279 283
280#define SCA_STRARRAY syscall_arg__scnprintf_strarray 284#define SCA_STRARRAY syscall_arg__scnprintf_strarray
281 285
286#if defined(__i386__) || defined(__x86_64__)
287/*
288 * FIXME: Make this available to all arches as soon as the ioctl beautifier
289 * gets rewritten to support all arches.
290 */
282static size_t syscall_arg__scnprintf_strhexarray(char *bf, size_t size, 291static size_t syscall_arg__scnprintf_strhexarray(char *bf, size_t size,
283 struct syscall_arg *arg) 292 struct syscall_arg *arg)
284{ 293{
@@ -286,6 +295,7 @@ static size_t syscall_arg__scnprintf_strhexarray(char *bf, size_t size,
286} 295}
287 296
288#define SCA_STRHEXARRAY syscall_arg__scnprintf_strhexarray 297#define SCA_STRHEXARRAY syscall_arg__scnprintf_strhexarray
298#endif /* defined(__i386__) || defined(__x86_64__) */
289 299
290static size_t syscall_arg__scnprintf_fd(char *bf, size_t size, 300static size_t syscall_arg__scnprintf_fd(char *bf, size_t size,
291 struct syscall_arg *arg); 301 struct syscall_arg *arg);
@@ -839,6 +849,10 @@ static size_t syscall_arg__scnprintf_signum(char *bf, size_t size, struct syscal
839 849
840#define SCA_SIGNUM syscall_arg__scnprintf_signum 850#define SCA_SIGNUM syscall_arg__scnprintf_signum
841 851
852#if defined(__i386__) || defined(__x86_64__)
853/*
854 * FIXME: Make this available to all arches.
855 */
842#define TCGETS 0x5401 856#define TCGETS 0x5401
843 857
844static const char *tioctls[] = { 858static const char *tioctls[] = {
@@ -860,6 +874,7 @@ static const char *tioctls[] = {
860}; 874};
861 875
862static DEFINE_STRARRAY_OFFSET(tioctls, 0x5401); 876static DEFINE_STRARRAY_OFFSET(tioctls, 0x5401);
877#endif /* defined(__i386__) || defined(__x86_64__) */
863 878
864#define STRARRAY(arg, name, array) \ 879#define STRARRAY(arg, name, array) \
865 .arg_scnprintf = { [arg] = SCA_STRARRAY, }, \ 880 .arg_scnprintf = { [arg] = SCA_STRARRAY, }, \
@@ -941,9 +956,16 @@ static struct syscall_fmt {
941 { .name = "getrlimit", .errmsg = true, STRARRAY(0, resource, rlimit_resources), }, 956 { .name = "getrlimit", .errmsg = true, STRARRAY(0, resource, rlimit_resources), },
942 { .name = "ioctl", .errmsg = true, 957 { .name = "ioctl", .errmsg = true,
943 .arg_scnprintf = { [0] = SCA_FD, /* fd */ 958 .arg_scnprintf = { [0] = SCA_FD, /* fd */
959#if defined(__i386__) || defined(__x86_64__)
960/*
961 * FIXME: Make this available to all arches.
962 */
944 [1] = SCA_STRHEXARRAY, /* cmd */ 963 [1] = SCA_STRHEXARRAY, /* cmd */
945 [2] = SCA_HEX, /* arg */ }, 964 [2] = SCA_HEX, /* arg */ },
946 .arg_parm = { [1] = &strarray__tioctls, /* cmd */ }, }, 965 .arg_parm = { [1] = &strarray__tioctls, /* cmd */ }, },
966#else
967 [2] = SCA_HEX, /* arg */ }, },
968#endif
947 { .name = "kill", .errmsg = true, 969 { .name = "kill", .errmsg = true,
948 .arg_scnprintf = { [1] = SCA_SIGNUM, /* sig */ }, }, 970 .arg_scnprintf = { [1] = SCA_SIGNUM, /* sig */ }, },
949 { .name = "linkat", .errmsg = true, 971 { .name = "linkat", .errmsg = true,
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index c48d44958172..0331ea2701a3 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -478,7 +478,7 @@ else
478endif 478endif
479 479
480ifeq ($(feature-libbfd), 1) 480ifeq ($(feature-libbfd), 1)
481 EXTLIBS += -lbfd 481 EXTLIBS += -lbfd -lz -liberty
482endif 482endif
483 483
484ifdef NO_DEMANGLE 484ifdef NO_DEMANGLE
diff --git a/tools/perf/config/feature-checks/Makefile b/tools/perf/config/feature-checks/Makefile
index 12e551346fa6..523b7bc10553 100644
--- a/tools/perf/config/feature-checks/Makefile
+++ b/tools/perf/config/feature-checks/Makefile
@@ -121,7 +121,7 @@ test-libpython-version.bin:
121 $(BUILD) $(FLAGS_PYTHON_EMBED) 121 $(BUILD) $(FLAGS_PYTHON_EMBED)
122 122
123test-libbfd.bin: 123test-libbfd.bin:
124 $(BUILD) -DPACKAGE='"perf"' -lbfd -ldl 124 $(BUILD) -DPACKAGE='"perf"' -lbfd -lz -liberty -ldl
125 125
126test-liberty.bin: 126test-liberty.bin:
127 $(CC) -o $(OUTPUT)$@ test-libbfd.c -DPACKAGE='"perf"' -lbfd -ldl -liberty 127 $(CC) -o $(OUTPUT)$@ test-libbfd.c -DPACKAGE='"perf"' -lbfd -ldl -liberty
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 469eb679fb9d..3aa555ff9d89 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -8,6 +8,8 @@
8 */ 8 */
9 9
10#include "util.h" 10#include "util.h"
11#include "ui/ui.h"
12#include "sort.h"
11#include "build-id.h" 13#include "build-id.h"
12#include "color.h" 14#include "color.h"
13#include "cache.h" 15#include "cache.h"
@@ -489,7 +491,7 @@ static int symbol__inc_addr_samples(struct symbol *sym, struct map *map,
489{ 491{
490 struct annotation *notes; 492 struct annotation *notes;
491 493
492 if (sym == NULL || use_browser != 1 || !sort__has_sym) 494 if (sym == NULL)
493 return 0; 495 return 0;
494 496
495 notes = symbol__annotation(sym); 497 notes = symbol__annotation(sym);
@@ -1399,3 +1401,8 @@ int hist_entry__annotate(struct hist_entry *he, size_t privsize)
1399{ 1401{
1400 return symbol__annotate(he->ms.sym, he->ms.map, privsize); 1402 return symbol__annotate(he->ms.sym, he->ms.map, privsize);
1401} 1403}
1404
1405bool ui__has_annotation(void)
1406{
1407 return use_browser == 1 && sort__has_sym;
1408}
diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h
index b2aef59d6bb2..56ad4f5287de 100644
--- a/tools/perf/util/annotate.h
+++ b/tools/perf/util/annotate.h
@@ -151,6 +151,8 @@ void symbol__annotate_zero_histogram(struct symbol *sym, int evidx);
151void symbol__annotate_decay_histogram(struct symbol *sym, int evidx); 151void symbol__annotate_decay_histogram(struct symbol *sym, int evidx);
152void disasm__purge(struct list_head *head); 152void disasm__purge(struct list_head *head);
153 153
154bool ui__has_annotation(void);
155
154int symbol__tty_annotate(struct symbol *sym, struct map *map, 156int symbol__tty_annotate(struct symbol *sym, struct map *map,
155 struct perf_evsel *evsel, bool print_lines, 157 struct perf_evsel *evsel, bool print_lines,
156 bool full_paths, int min_pcnt, int max_lines); 158 bool full_paths, int min_pcnt, int max_lines);
diff --git a/tools/perf/util/include/linux/bitops.h b/tools/perf/util/include/linux/bitops.h
index 45cf10a562bd..dadfa7e54287 100644
--- a/tools/perf/util/include/linux/bitops.h
+++ b/tools/perf/util/include/linux/bitops.h
@@ -87,13 +87,15 @@ static __always_inline unsigned long __ffs(unsigned long word)
87 return num; 87 return num;
88} 88}
89 89
90typedef const unsigned long __attribute__((__may_alias__)) long_alias_t;
91
90/* 92/*
91 * Find the first set bit in a memory region. 93 * Find the first set bit in a memory region.
92 */ 94 */
93static inline unsigned long 95static inline unsigned long
94find_first_bit(const unsigned long *addr, unsigned long size) 96find_first_bit(const unsigned long *addr, unsigned long size)
95{ 97{
96 const unsigned long *p = addr; 98 long_alias_t *p = (long_alias_t *) addr;
97 unsigned long result = 0; 99 unsigned long result = 0;
98 unsigned long tmp; 100 unsigned long tmp;
99 101
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index d248fca6d7ed..1e15df10a88c 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -1091,12 +1091,12 @@ int is_valid_tracepoint(const char *event_string)
1091static bool is_event_supported(u8 type, unsigned config) 1091static bool is_event_supported(u8 type, unsigned config)
1092{ 1092{
1093 bool ret = true; 1093 bool ret = true;
1094 int open_return;
1094 struct perf_evsel *evsel; 1095 struct perf_evsel *evsel;
1095 struct perf_event_attr attr = { 1096 struct perf_event_attr attr = {
1096 .type = type, 1097 .type = type,
1097 .config = config, 1098 .config = config,
1098 .disabled = 1, 1099 .disabled = 1,
1099 .exclude_kernel = 1,
1100 }; 1100 };
1101 struct { 1101 struct {
1102 struct thread_map map; 1102 struct thread_map map;
@@ -1108,7 +1108,20 @@ static bool is_event_supported(u8 type, unsigned config)
1108 1108
1109 evsel = perf_evsel__new(&attr); 1109 evsel = perf_evsel__new(&attr);
1110 if (evsel) { 1110 if (evsel) {
1111 ret = perf_evsel__open(evsel, NULL, &tmap.map) >= 0; 1111 open_return = perf_evsel__open(evsel, NULL, &tmap.map);
1112 ret = open_return >= 0;
1113
1114 if (open_return == -EACCES) {
1115 /*
1116 * This happens if the paranoid value
1117 * /proc/sys/kernel/perf_event_paranoid is set to 2
1118 * Re-run with exclude_kernel set; we don't do that
1119 * by default as some ARM machines do not support it.
1120 *
1121 */
1122 evsel->attr.exclude_kernel = 1;
1123 ret = perf_evsel__open(evsel, NULL, &tmap.map) >= 0;
1124 }
1112 perf_evsel__delete(evsel); 1125 perf_evsel__delete(evsel);
1113 } 1126 }
1114 1127
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index a8a9b6cd93a8..d8b048c20cde 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -336,8 +336,8 @@ static int add_exec_to_probe_trace_events(struct probe_trace_event *tevs,
336 return ret; 336 return ret;
337 337
338 for (i = 0; i < ntevs && ret >= 0; i++) { 338 for (i = 0; i < ntevs && ret >= 0; i++) {
339 /* point.address is the addres of point.symbol + point.offset */
339 offset = tevs[i].point.address - stext; 340 offset = tevs[i].point.address - stext;
340 offset += tevs[i].point.offset;
341 tevs[i].point.offset = 0; 341 tevs[i].point.offset = 0;
342 zfree(&tevs[i].point.symbol); 342 zfree(&tevs[i].point.symbol);
343 ret = e_snprintf(buf, 32, "0x%lx", offset); 343 ret = e_snprintf(buf, 32, "0x%lx", offset);
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 0b39a48e5110..5da6ce74c676 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -1008,6 +1008,12 @@ static int perf_session__process_user_event(struct perf_session *session, union
1008 if (err == 0) 1008 if (err == 0)
1009 perf_session__set_id_hdr_size(session); 1009 perf_session__set_id_hdr_size(session);
1010 return err; 1010 return err;
1011 case PERF_RECORD_HEADER_EVENT_TYPE:
1012 /*
1013 * Depreceated, but we need to handle it for sake
1014 * of old data files create in pipe mode.
1015 */
1016 return 0;
1011 case PERF_RECORD_HEADER_TRACING_DATA: 1017 case PERF_RECORD_HEADER_TRACING_DATA:
1012 /* setup for reading amidst mmap */ 1018 /* setup for reading amidst mmap */
1013 lseek(fd, file_offset, SEEK_SET); 1019 lseek(fd, file_offset, SEEK_SET);
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index a9d758a3b371..e89afc097d8a 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -1336,6 +1336,8 @@ int dso__load(struct dso *dso, struct map *map, symbol_filter_t filter)
1336 1336
1337 if (syms_ss && runtime_ss) 1337 if (syms_ss && runtime_ss)
1338 break; 1338 break;
1339 } else {
1340 symsrc__destroy(ss);
1339 } 1341 }
1340 1342
1341 } 1343 }