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/bus/imx-weim.txt28
-rw-r--r--Documentation/devicetree/bindings/net/sti-dwmac.txt58
-rw-r--r--Documentation/networking/3c505.txt45
-rw-r--r--MAINTAINERS15
-rw-r--r--Makefile2
-rw-r--r--arch/arm/Kconfig15
-rw-r--r--arch/arm/Makefile1
-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/imx6dl-hummingboard.dts10
-rw-r--r--arch/arm/boot/dts/imx6qdl-cubox-i.dtsi10
-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/configs/imx_v4_v5_defconfig1
-rw-r--r--arch/arm/configs/imx_v6_v7_defconfig7
-rw-r--r--arch/arm/include/asm/cacheflush.h1
-rw-r--r--arch/arm/include/asm/pgtable-3level.h15
-rw-r--r--arch/arm/include/asm/spinlock.h15
-rw-r--r--arch/arm/kernel/setup.c2
-rw-r--r--arch/arm/mach-bcm/Kconfig5
-rw-r--r--arch/arm/mach-bcm2835/Kconfig4
-rw-r--r--arch/arm/mach-berlin/Kconfig4
-rw-r--r--arch/arm/mach-cns3xxx/Kconfig3
-rw-r--r--arch/arm/mach-highbank/Kconfig7
-rw-r--r--arch/arm/mach-hisi/Kconfig4
-rw-r--r--arch/arm/mach-imx/Kconfig57
-rw-r--r--arch/arm/mach-imx/Makefile9
-rw-r--r--arch/arm/mach-imx/clk-imx21.c1
-rw-r--r--arch/arm/mach-imx/clk-imx25.c8
-rw-r--r--arch/arm/mach-imx/clk-imx27.c1
-rw-r--r--arch/arm/mach-imx/clk-imx51-imx53.c2
-rw-r--r--arch/arm/mach-imx/clk-imx6q.c7
-rw-r--r--arch/arm/mach-imx/clk-imx6sl.c159
-rw-r--r--arch/arm/mach-imx/clk-vf610.c36
-rw-r--r--arch/arm/mach-imx/common.h21
-rw-r--r--arch/arm/mach-imx/cpuidle-imx6q.c4
-rw-r--r--arch/arm/mach-imx/cpuidle-imx6sl.c57
-rw-r--r--arch/arm/mach-imx/cpuidle.h5
-rw-r--r--arch/arm/mach-imx/devices-imx25.h4
-rw-r--r--arch/arm/mach-imx/devices-imx51.h4
-rw-r--r--arch/arm/mach-imx/devices/Kconfig3
-rw-r--r--arch/arm/mach-imx/devices/Makefile1
-rw-r--r--arch/arm/mach-imx/devices/devices-common.h9
-rw-r--r--arch/arm/mach-imx/devices/platform-mxc_pwm.c69
-rw-r--r--arch/arm/mach-imx/hardware.h4
-rw-r--r--arch/arm/mach-imx/headsmp.S40
-rw-r--r--arch/arm/mach-imx/mach-imx6q.c98
-rw-r--r--arch/arm/mach-imx/mach-imx6sl.c6
-rw-r--r--arch/arm/mach-imx/pm-imx6.c552
-rw-r--r--arch/arm/mach-imx/pm-imx6q.c241
-rw-r--r--arch/arm/mach-imx/suspend-imx6.S361
-rw-r--r--arch/arm/mach-imx/time.c12
-rw-r--r--arch/arm/mach-keystone/Kconfig4
-rw-r--r--arch/arm/mach-moxart/Kconfig5
-rw-r--r--arch/arm/mach-mvebu/Kconfig6
-rw-r--r--arch/arm/mach-mxs/Kconfig4
-rw-r--r--arch/arm/mach-nomadik/Kconfig5
-rw-r--r--arch/arm/mach-nspire/Kconfig5
-rw-r--r--arch/arm/mach-omap1/board-nokia770.c1
-rw-r--r--arch/arm/mach-omap2/Kconfig25
-rw-r--r--arch/arm/mach-omap2/gpmc.c4
-rw-r--r--arch/arm/mach-omap2/io.c9
-rw-r--r--arch/arm/mach-picoxcell/Kconfig5
-rw-r--r--arch/arm/mach-prima2/Kconfig6
-rw-r--r--arch/arm/mach-pxa/mioa701.c9
-rw-r--r--arch/arm/mach-rockchip/Kconfig3
-rw-r--r--arch/arm/mach-shmobile/Kconfig5
-rw-r--r--arch/arm/mach-socfpga/Kconfig7
-rw-r--r--arch/arm/mach-spear/Kconfig10
-rw-r--r--arch/arm/mach-sti/Kconfig4
-rw-r--r--arch/arm/mach-sunxi/Kconfig5
-rw-r--r--arch/arm/mach-tegra/Kconfig8
-rw-r--r--arch/arm/mach-tegra/pm.c1
-rw-r--r--arch/arm/mach-tegra/tegra.c10
-rw-r--r--arch/arm/mach-u300/Kconfig6
-rw-r--r--arch/arm/mach-ux500/Kconfig6
-rw-r--r--arch/arm/mach-vexpress/Kconfig5
-rw-r--r--arch/arm/mach-virt/Kconfig10
-rw-r--r--arch/arm/mach-virt/Makefile5
-rw-r--r--arch/arm/mach-virt/virt.c41
-rw-r--r--arch/arm/mach-vt8500/Kconfig4
-rw-r--r--arch/arm/mach-zynq/Kconfig7
-rw-r--r--arch/arm/mm/dma-mapping.c2
-rw-r--r--arch/arm/mm/mm.h1
-rw-r--r--arch/arm/mm/mmu.c7
-rw-r--r--arch/arm/mm/proc-v6.S3
-rw-r--r--arch/arm/mm/proc-v7.S2
-rw-r--r--arch/avr32/Makefile2
-rw-r--r--arch/avr32/boards/mimc200/fram.c1
-rw-r--r--arch/avr32/include/asm/Kbuild1
-rw-r--r--arch/avr32/include/asm/io.h2
-rw-r--r--arch/powerpc/include/asm/eeh.h21
-rw-r--r--arch/powerpc/include/asm/hugetlb.h2
-rw-r--r--arch/powerpc/include/asm/pgtable-ppc64.h26
-rw-r--r--arch/powerpc/include/asm/pgtable.h22
-rw-r--r--arch/powerpc/include/asm/vdso.h6
-rw-r--r--arch/powerpc/kernel/eeh.c32
-rw-r--r--arch/powerpc/kernel/misc_32.S5
-rw-r--r--arch/powerpc/kernel/vdso32/vdso32_wrapper.S2
-rw-r--r--arch/powerpc/kernel/vdso64/vdso64_wrapper.S2
-rw-r--r--arch/powerpc/mm/pgtable_64.c12
-rw-r--r--arch/powerpc/mm/subpage-prot.c2
-rw-r--r--arch/powerpc/platforms/powernv/eeh-ioda.c32
-rw-r--r--arch/powerpc/platforms/powernv/eeh-powernv.c2
-rw-r--r--arch/powerpc/platforms/pseries/eeh_pseries.c2
-rw-r--r--arch/powerpc/platforms/pseries/pci.c22
-rw-r--r--arch/sparc/Kconfig2
-rw-r--r--arch/sparc/mm/srmmu.c2
-rw-r--r--arch/x86/include/asm/tsc.h2
-rw-r--r--arch/x86/kernel/cpu/perf_event.c8
-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/pci-dma.c4
-rw-r--r--arch/x86/kernel/tsc.c7
-rw-r--r--arch/x86/kernel/tsc_msr.c30
-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/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/dma-buf.c25
-rw-r--r--drivers/bus/imx-weim.c58
-rw-r--r--drivers/cpufreq/cpufreq.c3
-rw-r--r--drivers/cpufreq/intel_pstate.c17
-rw-r--r--drivers/cpufreq/powernow-k8.c10
-rw-r--r--drivers/gpu/drm/drm_ioctl.c12
-rw-r--r--drivers/gpu/drm/i2c/tda998x_drv.c4
-rw-r--r--drivers/gpu/drm/i915/intel_display.c14
-rw-r--r--drivers/gpu/drm/i915/intel_dp.c19
-rw-r--r--drivers/gpu/drm/i915/intel_ringbuffer.c21
-rw-r--r--drivers/gpu/drm/i915/intel_ringbuffer.h1
-rw-r--r--drivers/gpu/drm/nouveau/Makefile1
-rw-r--r--drivers/gpu/drm/nouveau/core/engine/device/nv40.c10
-rw-r--r--drivers/gpu/drm/nouveau/core/engine/disp/nv50.c2
-rw-r--r--drivers/gpu/drm/nouveau/core/engine/fifo/nve0.c2
-rw-r--r--drivers/gpu/drm/nouveau/core/engine/graph/nv50.c2
-rw-r--r--drivers/gpu/drm/nouveau/core/include/subdev/mc.h1
-rw-r--r--drivers/gpu/drm/nouveau/core/subdev/bios/base.c4
-rw-r--r--drivers/gpu/drm/nouveau/core/subdev/fb/nv1a.c2
-rw-r--r--drivers/gpu/drm/nouveau/core/subdev/mc/nv04.h1
-rw-r--r--drivers/gpu/drm/nouveau/core/subdev/mc/nv44.c2
-rw-r--r--drivers/gpu/drm/nouveau/core/subdev/mc/nv4c.c45
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_acpi.c26
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_bo.c2
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_drm.c3
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_vga.c4
-rw-r--r--drivers/gpu/drm/radeon/atombios_crtc.c15
-rw-r--r--drivers/gpu/drm/radeon/atombios_encoders.c7
-rw-r--r--drivers/gpu/drm/radeon/evergreen.c2
-rw-r--r--drivers/gpu/drm/radeon/ni_dpm.c2
-rw-r--r--drivers/gpu/drm/radeon/radeon.h4
-rw-r--r--drivers/gpu/drm/radeon/radeon_display.c2
-rw-r--r--drivers/gpu/drm/radeon/radeon_ring.c2
-rw-r--r--drivers/gpu/drm/radeon/radeon_semaphore.c19
-rw-r--r--drivers/gpu/drm/radeon/rv770_dpm.c9
-rw-r--r--drivers/gpu/drm/radeon/si_dpm.c2
-rw-r--r--drivers/gpu/drm/ttm/ttm_agp_backend.c1
-rw-r--r--drivers/gpu/drm/vmwgfx/svga3d_reg.h122
-rw-r--r--drivers/gpu/drm/vmwgfx/svga3d_surfacedefs.h11
-rw-r--r--drivers/gpu/drm/vmwgfx/svga_reg.h9
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_context.c9
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_drv.c3
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_drv.h1
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c9
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c3
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_shader.c16
-rw-r--r--drivers/hid/hid-apple.c3
-rw-r--r--drivers/hid/hid-core.c3
-rw-r--r--drivers/hid/hid-hyperv.c11
-rw-r--r--drivers/hid/hid-ids.h8
-rw-r--r--drivers/hid/hid-input.c2
-rw-r--r--drivers/hid/hid-microsoft.c4
-rw-r--r--drivers/hid/hid-multitouch.c5
-rw-r--r--drivers/hid/hid-sensor-hub.c3
-rw-r--r--drivers/hid/i2c-hid/i2c-hid.c2
-rw-r--r--drivers/hid/usbhid/hid-quirks.c1
-rw-r--r--drivers/hwmon/max1668.c2
-rw-r--r--drivers/iommu/arm-smmu.c105
-rw-r--r--drivers/irqchip/irq-orion.c22
-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/mmc/card/queue.c2
-rw-r--r--drivers/net/Kconfig2
-rw-r--r--drivers/net/bonding/bond_3ad.c6
-rw-r--r--drivers/net/bonding/bond_3ad.h1
-rw-r--r--drivers/net/bonding/bond_main.c9
-rw-r--r--drivers/net/bonding/bond_options.c2
-rw-r--r--drivers/net/can/usb/kvaser_usb.c2
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c4
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h2
-rw-r--r--drivers/net/ethernet/dec/tulip/tulip_core.c1
-rw-r--r--drivers/net/ethernet/freescale/fec_main.c4
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_main.c6
-rw-r--r--drivers/net/ethernet/lantiq_etop.c2
-rw-r--r--drivers/net/ethernet/marvell/Kconfig6
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_tx.c4
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/mlx4_en.h2
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/Kconfig11
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/Makefile1
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c330
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac.h3
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c5
-rw-r--r--drivers/net/ethernet/ti/cpsw.c11
-rw-r--r--drivers/net/ethernet/tile/tilegx.c2
-rw-r--r--drivers/net/ethernet/xilinx/xilinx_axienet_main.c13
-rw-r--r--drivers/net/hyperv/netvsc_drv.c53
-rw-r--r--drivers/net/irda/irtty-sir.c1
-rw-r--r--drivers/net/macvlan.c5
-rw-r--r--drivers/net/phy/dp83640.c13
-rw-r--r--drivers/net/team/team.c2
-rw-r--r--drivers/net/tun.c2
-rw-r--r--drivers/net/usb/Kconfig1
-rw-r--r--drivers/net/usb/asix_devices.c3
-rw-r--r--drivers/net/usb/ax88179_178a.c4
-rw-r--r--drivers/net/usb/gl620a.c4
-rw-r--r--drivers/net/usb/mcs7830.c5
-rw-r--r--drivers/net/usb/net1080.c4
-rw-r--r--drivers/net/usb/qmi_wwan.c9
-rw-r--r--drivers/net/usb/rndis_host.c4
-rw-r--r--drivers/net/usb/smsc75xx.c4
-rw-r--r--drivers/net/usb/smsc95xx.c4
-rw-r--r--drivers/net/usb/sr9800.c6
-rw-r--r--drivers/net/usb/usbnet.c25
-rw-r--r--drivers/net/wireless/ath/ath5k/phy.c2
-rw-r--r--drivers/net/wireless/hostap/hostap_proc.c2
-rw-r--r--drivers/net/wireless/iwlwifi/dvm/mac80211.c22
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-drv.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-modparams.h11
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/mac80211.c22
-rw-r--r--drivers/net/wireless/mwifiex/main.c2
-rw-r--r--drivers/net/wireless/rtl818x/rtl8187/rtl8187.h10
-rw-r--r--drivers/net/wireless/rtlwifi/ps.c2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192ce/hw.c18
-rw-r--r--drivers/of/base.c150
-rw-r--r--drivers/of/of_mdio.c22
-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/regulator/core.c2
-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/sbus/char/jsflash.c1
-rw-r--r--drivers/scsi/scsi_lib.c2
-rw-r--r--drivers/staging/android/binder.c3
-rw-r--r--drivers/staging/bcm/Bcmnet.c2
-rw-r--r--drivers/staging/netlogic/xlr_net.c2
-rw-r--r--drivers/staging/rtl8188eu/os_dep/os_intfs.c2
-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-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/option.c3
-rw-r--r--drivers/vhost/net.c47
-rw-r--r--drivers/watchdog/w83697hf_wdt.c2
-rw-r--r--fs/ceph/acl.c11
-rw-r--r--fs/ceph/dir.c23
-rw-r--r--fs/ceph/file.c1
-rw-r--r--fs/ceph/super.c32
-rw-r--r--fs/ceph/super.h7
-rw-r--r--fs/ceph/xattr.c54
-rw-r--r--fs/cifs/cifsacl.c33
-rw-r--r--fs/cifs/cifsglob.h2
-rw-r--r--fs/cifs/cifsproto.h6
-rw-r--r--fs/cifs/dir.c2
-rw-r--r--fs/cifs/file.c39
-rw-r--r--fs/cifs/inode.c2
-rw-r--r--fs/cifs/smb1ops.c1
-rw-r--r--fs/cifs/smb2glob.h3
-rw-r--r--fs/cifs/smb2ops.c14
-rw-r--r--fs/cifs/smb2pdu.c4
-rw-r--r--fs/ext4/ext4.h2
-rw-r--r--fs/ext4/extents.c1
-rw-r--r--fs/ext4/ioctl.c3
-rw-r--r--fs/ext4/resize.c34
-rw-r--r--fs/ext4/super.c20
-rw-r--r--fs/fscache/object-list.c5
-rw-r--r--fs/fscache/object.c3
-rw-r--r--fs/jbd2/transaction.c6
-rw-r--r--fs/jfs/acl.c2
-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/reiserfs/do_balan.c895
-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--include/asm-generic/pgtable.h39
-rw-r--r--include/drm/drm_crtc.h3
-rw-r--r--include/drm/ttm/ttm_page_alloc.h2
-rw-r--r--include/linux/ceph/ceph_fs.h5
-rw-r--r--include/linux/cgroup.h2
-rw-r--r--include/linux/dma-buf.h2
-rw-r--r--include/linux/mfd/max8997-private.h2
-rw-r--r--include/linux/mfd/max8998-private.h2
-rw-r--r--include/linux/mfd/syscon/imx6q-iomuxc-gpr.h18
-rw-r--r--include/linux/mfd/tps65217.h4
-rw-r--r--include/linux/netdevice.h36
-rw-r--r--include/linux/pci.h20
-rw-r--r--include/linux/skbuff.h17
-rw-r--r--include/linux/syscalls.h6
-rw-r--r--include/linux/workqueue.h5
-rw-r--r--include/net/sctp/structs.h14
-rw-r--r--include/uapi/drm/drm.h2
-rw-r--r--include/uapi/drm/vmwgfx_drm.h1
-rw-r--r--kernel/cgroup.c60
-rw-r--r--kernel/power/console.c1
-rw-r--r--kernel/printk/printk.c2
-rw-r--r--kernel/sched/core.c28
-rw-r--r--kernel/sched/cpudeadline.c6
-rw-r--r--kernel/sched/deadline.c10
-rw-r--r--kernel/sched/fair.c2
-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--mm/huge_memory.c9
-rw-r--r--mm/mprotect.c25
-rw-r--r--mm/vmpressure.c1
-rw-r--r--net/batman-adv/bat_iv_ogm.c30
-rw-r--r--net/batman-adv/hard-interface.c22
-rw-r--r--net/batman-adv/originator.c36
-rw-r--r--net/batman-adv/originator.h4
-rw-r--r--net/batman-adv/routing.c4
-rw-r--r--net/batman-adv/send.c9
-rw-r--r--net/batman-adv/translation-table.c23
-rw-r--r--net/bluetooth/hidp/core.c16
-rw-r--r--net/bluetooth/hidp/hidp.h4
-rw-r--r--net/core/dev.c22
-rw-r--r--net/core/flow_dissector.c20
-rw-r--r--net/core/rtnetlink.c19
-rw-r--r--net/dccp/ccids/lib/tfrc.c2
-rw-r--r--net/dccp/ccids/lib/tfrc.h1
-rw-r--r--net/ipv4/ip_forward.c71
-rw-r--r--net/ipv4/ipconfig.c2
-rw-r--r--net/ipv4/route.c13
-rw-r--r--net/ipv6/addrconf.c2
-rw-r--r--net/ipv6/ip6_output.c17
-rw-r--r--net/mac80211/iface.c6
-rw-r--r--net/packet/af_packet.c26
-rw-r--r--net/sched/sch_pie.c21
-rw-r--r--net/sctp/associola.c82
-rw-r--r--net/sctp/sm_statefuns.c2
-rw-r--r--net/sctp/socket.c47
-rw-r--r--net/sctp/sysctl.c18
-rw-r--r--net/sctp/ulpevent.c8
-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/core.h1
-rw-r--r--net/tipc/link.c7
-rw-r--r--scripts/Makefile.lib1
-rw-r--r--sound/pci/hda/patch_ca0132.c68
-rw-r--r--sound/pci/hda/patch_realtek.c2
-rw-r--r--sound/pci/hda/patch_sigmatel.c13
-rw-r--r--sound/soc/blackfin/Kconfig11
-rw-r--r--sound/soc/codecs/da9055.c11
-rw-r--r--sound/soc/codecs/max98090.c21
-rw-r--r--sound/soc/codecs/rt5640.c1
-rw-r--r--sound/soc/codecs/wm8993.c1
-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/txx9/txx9aclc-ac97.c8
-rw-r--r--sound/usb/mixer_maps.c9
-rw-r--r--tools/perf/builtin-trace.c22
-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
435 files changed, 4885 insertions, 2893 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/bus/imx-weim.txt b/Documentation/devicetree/bindings/bus/imx-weim.txt
index 0fd76c405208..6630d842c7a3 100644
--- a/Documentation/devicetree/bindings/bus/imx-weim.txt
+++ b/Documentation/devicetree/bindings/bus/imx-weim.txt
@@ -8,7 +8,12 @@ The actual devices are instantiated from the child nodes of a WEIM node.
8 8
9Required properties: 9Required properties:
10 10
11 - compatible: Should be set to "fsl,<soc>-weim" 11 - compatible: Should contain one of the following:
12 "fsl,imx1-weim"
13 "fsl,imx27-weim"
14 "fsl,imx51-weim"
15 "fsl,imx50-weim"
16 "fsl,imx6q-weim"
12 - reg: A resource specifier for the register space 17 - reg: A resource specifier for the register space
13 (see the example below) 18 (see the example below)
14 - clocks: the clock, see the example below. 19 - clocks: the clock, see the example below.
@@ -19,6 +24,26 @@ Required properties:
19 24
20 <cs-number> 0 <physical address of mapping> <size> 25 <cs-number> 0 <physical address of mapping> <size>
21 26
27Optional properties:
28
29 - fsl,weim-cs-gpr: For "fsl,imx50-weim" and "fsl,imx6q-weim" type of
30 devices, it should be the phandle to the system General
31 Purpose Register controller that contains WEIM CS GPR
32 register, e.g. IOMUXC_GPR1 on i.MX6Q. IOMUXC_GPR1[11:0]
33 should be set up as one of the following 4 possible
34 values depending on the CS space configuration.
35
36 IOMUXC_GPR1[11:0] CS0 CS1 CS2 CS3
37 ---------------------------------------------
38 05 128M 0M 0M 0M
39 033 64M 64M 0M 0M
40 0113 64M 32M 32M 0M
41 01111 32M 32M 32M 32M
42
43 In case that the property is absent, the reset value or
44 what bootloader sets up in IOMUXC_GPR1[11:0] will be
45 used.
46
22Timing property for child nodes. It is mandatory, not optional. 47Timing property for child nodes. It is mandatory, not optional.
23 48
24 - fsl,weim-cs-timing: The timing array, contains timing values for the 49 - fsl,weim-cs-timing: The timing array, contains timing values for the
@@ -43,6 +68,7 @@ Example for an imx6q-sabreauto board, the NOR flash connected to the WEIM:
43 #address-cells = <2>; 68 #address-cells = <2>;
44 #size-cells = <1>; 69 #size-cells = <1>;
45 ranges = <0 0 0x08000000 0x08000000>; 70 ranges = <0 0 0x08000000 0x08000000>;
71 fsl,weim-cs-gpr = <&gpr>;
46 72
47 nor@0,0 { 73 nor@0,0 {
48 compatible = "cfi-flash"; 74 compatible = "cfi-flash";
diff --git a/Documentation/devicetree/bindings/net/sti-dwmac.txt b/Documentation/devicetree/bindings/net/sti-dwmac.txt
new file mode 100644
index 000000000000..3dd3d0bf112f
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/sti-dwmac.txt
@@ -0,0 +1,58 @@
1STMicroelectronics SoC DWMAC glue layer controller
2
3The device node has following properties.
4
5Required properties:
6 - compatible : Can be "st,stih415-dwmac", "st,stih416-dwmac" or
7 "st,stid127-dwmac".
8 - reg : Offset of the glue configuration register map in system
9 configuration regmap pointed by st,syscon property and size.
10
11 - reg-names : Should be "sti-ethconf".
12
13 - st,syscon : Should be phandle to system configuration node which
14 encompases this glue registers.
15
16 - st,tx-retime-src: On STi Parts for Giga bit speeds, 125Mhz clocks can be
17 wired up in from different sources. One via TXCLK pin and other via CLK_125
18 pin. This wiring is totally board dependent. However the retiming glue
19 logic should be configured accordingly. Possible values for this property
20
21 "txclk" - if 125Mhz clock is wired up via txclk line.
22 "clk_125" - if 125Mhz clock is wired up via clk_125 line.
23
24 This property is only valid for Giga bit setup( GMII, RGMII), and it is
25 un-used for non-giga bit (MII and RMII) setups. Also note that internal
26 clockgen can not generate stable 125Mhz clock.
27
28 - st,ext-phyclk: This boolean property indicates who is generating the clock
29 for tx and rx. This property is only valid for RMII case where the clock can
30 be generated from the MAC or PHY.
31
32 - clock-names: should be "sti-ethclk".
33 - clocks: Should point to ethernet clockgen which can generate phyclk.
34
35
36Example:
37
38ethernet0: dwmac@fe810000 {
39 device_type = "network";
40 compatible = "st,stih416-dwmac", "snps,dwmac", "snps,dwmac-3.710";
41 reg = <0xfe810000 0x8000>, <0x8bc 0x4>;
42 reg-names = "stmmaceth", "sti-ethconf";
43 interrupts = <0 133 0>, <0 134 0>, <0 135 0>;
44 interrupt-names = "macirq", "eth_wake_irq", "eth_lpi";
45 phy-mode = "mii";
46
47 st,syscon = <&syscfg_rear>;
48
49 snps,pbl = <32>;
50 snps,mixed-burst;
51
52 resets = <&softreset STIH416_ETH0_SOFTRESET>;
53 reset-names = "stmmaceth";
54 pinctrl-0 = <&pinctrl_mii0>;
55 pinctrl-names = "default";
56 clocks = <&CLK_S_GMAC0_PHY>;
57 clock-names = "stmmaceth";
58};
diff --git a/Documentation/networking/3c505.txt b/Documentation/networking/3c505.txt
deleted file mode 100644
index 72f38b13101d..000000000000
--- a/Documentation/networking/3c505.txt
+++ /dev/null
@@ -1,45 +0,0 @@
1The 3Com Etherlink Plus (3c505) driver.
2
3This driver now uses DMA. There is currently no support for PIO operation.
4The default DMA channel is 6; this is _not_ autoprobed, so you must
5make sure you configure it correctly. If loading the driver as a
6module, you can do this with "modprobe 3c505 dma=n". If the driver is
7linked statically into the kernel, you must either use an "ether="
8statement on the command line, or change the definition of ELP_DMA in 3c505.h.
9
10The driver will warn you if it has to fall back on the compiled in
11default DMA channel.
12
13If no base address is given at boot time, the driver will autoprobe
14ports 0x300, 0x280 and 0x310 (in that order). If no IRQ is given, the driver
15will try to probe for it.
16
17The driver can be used as a loadable module.
18
19Theoretically, one instance of the driver can now run multiple cards,
20in the standard way (when loading a module, say "modprobe 3c505
21io=0x300,0x340 irq=10,11 dma=6,7" or whatever). I have not tested
22this, though.
23
24The driver may now support revision 2 hardware; the dependency on
25being able to read the host control register has been removed. This
26is also untested, since I don't have a suitable card.
27
28Known problems:
29 I still see "DMA upload timed out" messages from time to time. These
30seem to be fairly non-fatal though.
31 The card is old and slow.
32
33To do:
34 Improve probe/setup code
35 Test multicast and promiscuous operation
36
37Authors:
38 The driver is mainly written by Craig Southeren, email
39 <craigs@ineluki.apana.org.au>.
40 Parts of the driver (adapting the driver to 1.1.4+ kernels,
41 IRQ/address detection, some changes) and this README by
42 Juha Laiho <jlaiho@ichaos.nullnet.fi>.
43 DMA mode, more fixes, etc, by Philip Blundell <pjb27@cam.ac.uk>
44 Multicard support, Software configurable DMA, etc., by
45 Christopher Collins <ccollins@pcug.org.au>
diff --git a/MAINTAINERS b/MAINTAINERS
index 9dbf7f1898c5..e4812f9319bd 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1868,6 +1868,7 @@ F: drivers/net/ethernet/broadcom/bnx2x/
1868 1868
1869BROADCOM BCM281XX/BCM11XXX ARM ARCHITECTURE 1869BROADCOM BCM281XX/BCM11XXX ARM ARCHITECTURE
1870M: Christian Daudt <bcm@fixthebug.org> 1870M: Christian Daudt <bcm@fixthebug.org>
1871M: Matt Porter <mporter@linaro.org>
1871L: bcm-kernel-feedback-list@broadcom.com 1872L: bcm-kernel-feedback-list@broadcom.com
1872T: git git://git.github.com/broadcom/bcm11351 1873T: git git://git.github.com/broadcom/bcm11351
1873S: Maintained 1874S: Maintained
@@ -2416,8 +2417,10 @@ F: tools/power/cpupower/
2416 2417
2417CPUSETS 2418CPUSETS
2418M: Li Zefan <lizefan@huawei.com> 2419M: Li Zefan <lizefan@huawei.com>
2420L: cgroups@vger.kernel.org
2419W: http://www.bullopensource.org/cpuset/ 2421W: http://www.bullopensource.org/cpuset/
2420W: http://oss.sgi.com/projects/cpusets/ 2422W: http://oss.sgi.com/projects/cpusets/
2423T: git git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup.git
2421S: Maintained 2424S: Maintained
2422F: Documentation/cgroups/cpusets.txt 2425F: Documentation/cgroups/cpusets.txt
2423F: include/linux/cpuset.h 2426F: include/linux/cpuset.h
@@ -3332,6 +3335,17 @@ S: Maintained
3332F: include/linux/netfilter_bridge/ 3335F: include/linux/netfilter_bridge/
3333F: net/bridge/ 3336F: net/bridge/
3334 3337
3338ETHERNET PHY LIBRARY
3339M: Florian Fainelli <f.fainelli@gmail.com>
3340L: netdev@vger.kernel.org
3341S: Maintained
3342F: include/linux/phy.h
3343F: include/linux/phy_fixed.h
3344F: drivers/net/phy/
3345F: Documentation/networking/phy.txt
3346F: drivers/of/of_mdio.c
3347F: drivers/of/of_net.c
3348
3335EXT2 FILE SYSTEM 3349EXT2 FILE SYSTEM
3336M: Jan Kara <jack@suse.cz> 3350M: Jan Kara <jack@suse.cz>
3337L: linux-ext4@vger.kernel.org 3351L: linux-ext4@vger.kernel.org
@@ -9723,7 +9737,6 @@ F: drivers/xen/*swiotlb*
9723XFS FILESYSTEM 9737XFS FILESYSTEM
9724P: Silicon Graphics Inc 9738P: Silicon Graphics Inc
9725M: Dave Chinner <david@fromorbit.com> 9739M: Dave Chinner <david@fromorbit.com>
9726M: Ben Myers <bpm@sgi.com>
9727M: xfs@oss.sgi.com 9740M: xfs@oss.sgi.com
9728L: xfs@oss.sgi.com 9741L: xfs@oss.sgi.com
9729W: http://oss.sgi.com/projects/xfs 9742W: http://oss.sgi.com/projects/xfs
diff --git a/Makefile b/Makefile
index 893d6f0e875b..831b36a6b0a1 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
1VERSION = 3 1VERSION = 3
2PATCHLEVEL = 14 2PATCHLEVEL = 14
3SUBLEVEL = 0 3SUBLEVEL = 0
4EXTRAVERSION = -rc3 4EXTRAVERSION = -rc4
5NAME = Shuffling Zombie Juror 5NAME = Shuffling Zombie Juror
6 6
7# *DOCUMENTATION* 7# *DOCUMENTATION*
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index d57b4753585d..cbee1169b883 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -306,9 +306,11 @@ choice
306config ARCH_MULTIPLATFORM 306config ARCH_MULTIPLATFORM
307 bool "Allow multiple platforms to be selected" 307 bool "Allow multiple platforms to be selected"
308 depends on MMU 308 depends on MMU
309 select ARCH_WANT_OPTIONAL_GPIOLIB
309 select ARM_PATCH_PHYS_VIRT 310 select ARM_PATCH_PHYS_VIRT
310 select AUTO_ZRELADDR 311 select AUTO_ZRELADDR
311 select COMMON_CLK 312 select COMMON_CLK
313 select GENERIC_CLOCKEVENTS
312 select MULTI_IRQ_HANDLER 314 select MULTI_IRQ_HANDLER
313 select SPARSE_IRQ 315 select SPARSE_IRQ
314 select USE_OF 316 select USE_OF
@@ -905,16 +907,18 @@ config ARCH_MULTI_V4_V5
905config ARCH_MULTI_V6 907config ARCH_MULTI_V6
906 bool "ARMv6 based platforms (ARM11)" 908 bool "ARMv6 based platforms (ARM11)"
907 select ARCH_MULTI_V6_V7 909 select ARCH_MULTI_V6_V7
908 select CPU_V6 910 select CPU_V6K
909 911
910config ARCH_MULTI_V7 912config ARCH_MULTI_V7
911 bool "ARMv7 based platforms (Cortex-A, PJ4, Scorpion, Krait)" 913 bool "ARMv7 based platforms (Cortex-A, PJ4, Scorpion, Krait)"
912 default y 914 default y
913 select ARCH_MULTI_V6_V7 915 select ARCH_MULTI_V6_V7
914 select CPU_V7 916 select CPU_V7
917 select HAVE_SMP
915 918
916config ARCH_MULTI_V6_V7 919config ARCH_MULTI_V6_V7
917 bool 920 bool
921 select MIGHT_HAVE_CACHE_L2X0
918 922
919config ARCH_MULTI_CPU_AUTO 923config ARCH_MULTI_CPU_AUTO
920 def_bool !(ARCH_MULTI_V4 || ARCH_MULTI_V4T || ARCH_MULTI_V6_V7) 924 def_bool !(ARCH_MULTI_V4 || ARCH_MULTI_V4T || ARCH_MULTI_V6_V7)
@@ -922,6 +926,13 @@ config ARCH_MULTI_CPU_AUTO
922 926
923endmenu 927endmenu
924 928
929config ARCH_VIRT
930 bool "Dummy Virtual Machine" if ARCH_MULTI_V7
931 select ARM_AMBA
932 select ARM_GIC
933 select ARM_PSCI
934 select HAVE_ARM_ARCH_TIMER
935
925# 936#
926# This is sorted alphabetically by mach-* pathname. However, plat-* 937# This is sorted alphabetically by mach-* pathname. However, plat-*
927# Kconfigs may be included either alphabetically (according to the 938# Kconfigs may be included either alphabetically (according to the
@@ -1047,8 +1058,6 @@ source "arch/arm/mach-versatile/Kconfig"
1047source "arch/arm/mach-vexpress/Kconfig" 1058source "arch/arm/mach-vexpress/Kconfig"
1048source "arch/arm/plat-versatile/Kconfig" 1059source "arch/arm/plat-versatile/Kconfig"
1049 1060
1050source "arch/arm/mach-virt/Kconfig"
1051
1052source "arch/arm/mach-vt8500/Kconfig" 1061source "arch/arm/mach-vt8500/Kconfig"
1053 1062
1054source "arch/arm/mach-w90x900/Kconfig" 1063source "arch/arm/mach-w90x900/Kconfig"
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 51e5bede657f..dd1bd7ed77be 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -200,7 +200,6 @@ machine-$(CONFIG_ARCH_U300) += u300
200machine-$(CONFIG_ARCH_U8500) += ux500 200machine-$(CONFIG_ARCH_U8500) += ux500
201machine-$(CONFIG_ARCH_VERSATILE) += versatile 201machine-$(CONFIG_ARCH_VERSATILE) += versatile
202machine-$(CONFIG_ARCH_VEXPRESS) += vexpress 202machine-$(CONFIG_ARCH_VEXPRESS) += vexpress
203machine-$(CONFIG_ARCH_VIRT) += virt
204machine-$(CONFIG_ARCH_VT8500) += vt8500 203machine-$(CONFIG_ARCH_VT8500) += vt8500
205machine-$(CONFIG_ARCH_W90X900) += w90x900 204machine-$(CONFIG_ARCH_W90X900) += w90x900
206machine-$(CONFIG_ARCH_ZYNQ) += zynq 205machine-$(CONFIG_ARCH_ZYNQ) += zynq
diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index 3269029a1ce6..4a89023f55ab 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -206,7 +206,8 @@ dtb-$(CONFIG_ARCH_OMAP2PLUS) += omap2420-h4.dtb \
206 omap3-n900.dtb \ 206 omap3-n900.dtb \
207 omap3-n9.dtb \ 207 omap3-n9.dtb \
208 omap3-n950.dtb \ 208 omap3-n950.dtb \
209 omap3-tobi.dtb \ 209 omap3-overo-tobi.dtb \
210 omap3-overo-storm-tobi.dtb \
210 omap3-gta04.dtb \ 211 omap3-gta04.dtb \
211 omap3-igep0020.dtb \ 212 omap3-igep0020.dtb \
212 omap3-igep0030.dtb \ 213 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/imx6dl-hummingboard.dts b/arch/arm/boot/dts/imx6dl-hummingboard.dts
index fd8fc7cd53f3..5bfae54fb780 100644
--- a/arch/arm/boot/dts/imx6dl-hummingboard.dts
+++ b/arch/arm/boot/dts/imx6dl-hummingboard.dts
@@ -52,12 +52,6 @@
52 }; 52 };
53 }; 53 };
54 54
55 codec: spdif-transmitter {
56 compatible = "linux,spdif-dit";
57 pinctrl-names = "default";
58 pinctrl-0 = <&pinctrl_hummingboard_spdif>;
59 };
60
61 sound-spdif { 55 sound-spdif {
62 compatible = "fsl,imx-audio-spdif"; 56 compatible = "fsl,imx-audio-spdif";
63 model = "imx-spdif"; 57 model = "imx-spdif";
@@ -111,7 +105,7 @@
111 }; 105 };
112 106
113 pinctrl_hummingboard_spdif: hummingboard-spdif { 107 pinctrl_hummingboard_spdif: hummingboard-spdif {
114 fsl,pins = <MX6QDL_PAD_GPIO_17__SPDIF_OUT 0x1b0b0>; 108 fsl,pins = <MX6QDL_PAD_GPIO_17__SPDIF_OUT 0x13091>;
115 }; 109 };
116 110
117 pinctrl_hummingboard_usbh1_vbus: hummingboard-usbh1-vbus { 111 pinctrl_hummingboard_usbh1_vbus: hummingboard-usbh1-vbus {
@@ -142,6 +136,8 @@
142}; 136};
143 137
144&spdif { 138&spdif {
139 pinctrl-names = "default";
140 pinctrl-0 = <&pinctrl_hummingboard_spdif>;
145 status = "okay"; 141 status = "okay";
146}; 142};
147 143
diff --git a/arch/arm/boot/dts/imx6qdl-cubox-i.dtsi b/arch/arm/boot/dts/imx6qdl-cubox-i.dtsi
index 64daa3b311f6..c2a24888a276 100644
--- a/arch/arm/boot/dts/imx6qdl-cubox-i.dtsi
+++ b/arch/arm/boot/dts/imx6qdl-cubox-i.dtsi
@@ -46,12 +46,6 @@
46 }; 46 };
47 }; 47 };
48 48
49 codec: spdif-transmitter {
50 compatible = "linux,spdif-dit";
51 pinctrl-names = "default";
52 pinctrl-0 = <&pinctrl_cubox_i_spdif>;
53 };
54
55 sound-spdif { 49 sound-spdif {
56 compatible = "fsl,imx-audio-spdif"; 50 compatible = "fsl,imx-audio-spdif";
57 model = "imx-spdif"; 51 model = "imx-spdif";
@@ -89,7 +83,7 @@
89 }; 83 };
90 84
91 pinctrl_cubox_i_spdif: cubox-i-spdif { 85 pinctrl_cubox_i_spdif: cubox-i-spdif {
92 fsl,pins = <MX6QDL_PAD_GPIO_17__SPDIF_OUT 0x1b0b0>; 86 fsl,pins = <MX6QDL_PAD_GPIO_17__SPDIF_OUT 0x13091>;
93 }; 87 };
94 88
95 pinctrl_cubox_i_usbh1_vbus: cubox-i-usbh1-vbus { 89 pinctrl_cubox_i_usbh1_vbus: cubox-i-usbh1-vbus {
@@ -121,6 +115,8 @@
121}; 115};
122 116
123&spdif { 117&spdif {
118 pinctrl-names = "default";
119 pinctrl-0 = <&pinctrl_cubox_i_spdif>;
124 status = "okay"; 120 status = "okay";
125}; 121};
126 122
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/configs/imx_v4_v5_defconfig b/arch/arm/configs/imx_v4_v5_defconfig
index 6309ee52ccfc..f1aeb7d72712 100644
--- a/arch/arm/configs/imx_v4_v5_defconfig
+++ b/arch/arm/configs/imx_v4_v5_defconfig
@@ -154,6 +154,7 @@ CONFIG_USB=y
154CONFIG_USB_EHCI_HCD=y 154CONFIG_USB_EHCI_HCD=y
155CONFIG_USB_EHCI_MXC=y 155CONFIG_USB_EHCI_MXC=y
156CONFIG_MMC=y 156CONFIG_MMC=y
157CONFIG_MMC_UNSAFE_RESUME=y
157CONFIG_MMC_SDHCI=y 158CONFIG_MMC_SDHCI=y
158CONFIG_MMC_SDHCI_PLTFM=y 159CONFIG_MMC_SDHCI_PLTFM=y
159CONFIG_MMC_SDHCI_ESDHC_IMX=y 160CONFIG_MMC_SDHCI_ESDHC_IMX=y
diff --git a/arch/arm/configs/imx_v6_v7_defconfig b/arch/arm/configs/imx_v6_v7_defconfig
index 53e82c2523eb..09e974392fa1 100644
--- a/arch/arm/configs/imx_v6_v7_defconfig
+++ b/arch/arm/configs/imx_v6_v7_defconfig
@@ -39,6 +39,8 @@ CONFIG_SOC_IMX53=y
39CONFIG_SOC_IMX6Q=y 39CONFIG_SOC_IMX6Q=y
40CONFIG_SOC_IMX6SL=y 40CONFIG_SOC_IMX6SL=y
41CONFIG_SOC_VF610=y 41CONFIG_SOC_VF610=y
42CONFIG_PCI=y
43CONFIG_PCI_IMX6=y
42CONFIG_SMP=y 44CONFIG_SMP=y
43CONFIG_VMSPLIT_2G=y 45CONFIG_VMSPLIT_2G=y
44CONFIG_PREEMPT_VOLUNTARY=y 46CONFIG_PREEMPT_VOLUNTARY=y
@@ -165,6 +167,7 @@ CONFIG_REGULATOR=y
165CONFIG_REGULATOR_FIXED_VOLTAGE=y 167CONFIG_REGULATOR_FIXED_VOLTAGE=y
166CONFIG_REGULATOR_ANATOP=y 168CONFIG_REGULATOR_ANATOP=y
167CONFIG_REGULATOR_DA9052=y 169CONFIG_REGULATOR_DA9052=y
170CONFIG_REGULATOR_GPIO=y
168CONFIG_REGULATOR_MC13783=y 171CONFIG_REGULATOR_MC13783=y
169CONFIG_REGULATOR_MC13892=y 172CONFIG_REGULATOR_MC13892=y
170CONFIG_REGULATOR_PFUZE100=y 173CONFIG_REGULATOR_PFUZE100=y
@@ -186,6 +189,7 @@ CONFIG_LCD_L4F00242T03=y
186CONFIG_LCD_PLATFORM=y 189CONFIG_LCD_PLATFORM=y
187CONFIG_BACKLIGHT_CLASS_DEVICE=y 190CONFIG_BACKLIGHT_CLASS_DEVICE=y
188CONFIG_BACKLIGHT_PWM=y 191CONFIG_BACKLIGHT_PWM=y
192CONFIG_BACKLIGHT_GPIO=y
189CONFIG_FRAMEBUFFER_CONSOLE=y 193CONFIG_FRAMEBUFFER_CONSOLE=y
190CONFIG_LOGO=y 194CONFIG_LOGO=y
191CONFIG_SOUND=y 195CONFIG_SOUND=y
@@ -211,6 +215,7 @@ CONFIG_USB_GADGET=y
211CONFIG_USB_ETH=m 215CONFIG_USB_ETH=m
212CONFIG_USB_MASS_STORAGE=m 216CONFIG_USB_MASS_STORAGE=m
213CONFIG_MMC=y 217CONFIG_MMC=y
218CONFIG_MMC_UNSAFE_RESUME=y
214CONFIG_MMC_SDHCI=y 219CONFIG_MMC_SDHCI=y
215CONFIG_MMC_SDHCI_PLTFM=y 220CONFIG_MMC_SDHCI_PLTFM=y
216CONFIG_MMC_SDHCI_ESDHC_IMX=y 221CONFIG_MMC_SDHCI_ESDHC_IMX=y
@@ -225,6 +230,7 @@ CONFIG_LEDS_TRIGGER_BACKLIGHT=y
225CONFIG_LEDS_TRIGGER_GPIO=y 230CONFIG_LEDS_TRIGGER_GPIO=y
226CONFIG_RTC_CLASS=y 231CONFIG_RTC_CLASS=y
227CONFIG_RTC_INTF_DEV_UIE_EMUL=y 232CONFIG_RTC_INTF_DEV_UIE_EMUL=y
233CONFIG_RTC_DRV_PCF8563=y
228CONFIG_RTC_DRV_MC13XXX=y 234CONFIG_RTC_DRV_MC13XXX=y
229CONFIG_RTC_DRV_MXC=y 235CONFIG_RTC_DRV_MXC=y
230CONFIG_RTC_DRV_SNVS=y 236CONFIG_RTC_DRV_SNVS=y
@@ -277,6 +283,7 @@ CONFIG_NLS_ASCII=y
277CONFIG_NLS_ISO8859_1=y 283CONFIG_NLS_ISO8859_1=y
278CONFIG_NLS_ISO8859_15=m 284CONFIG_NLS_ISO8859_15=m
279CONFIG_NLS_UTF8=y 285CONFIG_NLS_UTF8=y
286CONFIG_DEBUG_FS=y
280CONFIG_MAGIC_SYSRQ=y 287CONFIG_MAGIC_SYSRQ=y
281# CONFIG_SCHED_DEBUG is not set 288# CONFIG_SCHED_DEBUG is not set
282CONFIG_PROVE_LOCKING=y 289CONFIG_PROVE_LOCKING=y
diff --git a/arch/arm/include/asm/cacheflush.h b/arch/arm/include/asm/cacheflush.h
index e9a49fe0284e..8b8b61685a34 100644
--- a/arch/arm/include/asm/cacheflush.h
+++ b/arch/arm/include/asm/cacheflush.h
@@ -212,6 +212,7 @@ extern void copy_to_user_page(struct vm_area_struct *, struct page *,
212static inline void __flush_icache_all(void) 212static inline void __flush_icache_all(void)
213{ 213{
214 __flush_icache_preferred(); 214 __flush_icache_preferred();
215 dsb();
215} 216}
216 217
217/* 218/*
diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h
index 03243f7eeddf..85c60adc8b60 100644
--- a/arch/arm/include/asm/pgtable-3level.h
+++ b/arch/arm/include/asm/pgtable-3level.h
@@ -120,13 +120,16 @@
120/* 120/*
121 * 2nd stage PTE definitions for LPAE. 121 * 2nd stage PTE definitions for LPAE.
122 */ 122 */
123#define L_PTE_S2_MT_UNCACHED (_AT(pteval_t, 0x5) << 2) /* MemAttr[3:0] */ 123#define L_PTE_S2_MT_UNCACHED (_AT(pteval_t, 0x0) << 2) /* strongly ordered */
124#define L_PTE_S2_MT_WRITETHROUGH (_AT(pteval_t, 0xa) << 2) /* MemAttr[3:0] */ 124#define L_PTE_S2_MT_WRITETHROUGH (_AT(pteval_t, 0xa) << 2) /* normal inner write-through */
125#define L_PTE_S2_MT_WRITEBACK (_AT(pteval_t, 0xf) << 2) /* MemAttr[3:0] */ 125#define L_PTE_S2_MT_WRITEBACK (_AT(pteval_t, 0xf) << 2) /* normal inner write-back */
126#define L_PTE_S2_RDONLY (_AT(pteval_t, 1) << 6) /* HAP[1] */ 126#define L_PTE_S2_MT_DEV_SHARED (_AT(pteval_t, 0x1) << 2) /* device */
127#define L_PTE_S2_RDWR (_AT(pteval_t, 3) << 6) /* HAP[2:1] */ 127#define L_PTE_S2_MT_MASK (_AT(pteval_t, 0xf) << 2)
128 128
129#define L_PMD_S2_RDWR (_AT(pmdval_t, 3) << 6) /* HAP[2:1] */ 129#define L_PTE_S2_RDONLY (_AT(pteval_t, 1) << 6) /* HAP[1] */
130#define L_PTE_S2_RDWR (_AT(pteval_t, 3) << 6) /* HAP[2:1] */
131
132#define L_PMD_S2_RDWR (_AT(pmdval_t, 3) << 6) /* HAP[2:1] */
130 133
131/* 134/*
132 * Hyp-mode PL2 PTE definitions for LPAE. 135 * Hyp-mode PL2 PTE definitions for LPAE.
diff --git a/arch/arm/include/asm/spinlock.h b/arch/arm/include/asm/spinlock.h
index ef3c6072aa45..ac4bfae26702 100644
--- a/arch/arm/include/asm/spinlock.h
+++ b/arch/arm/include/asm/spinlock.h
@@ -37,18 +37,9 @@
37 37
38static inline void dsb_sev(void) 38static inline void dsb_sev(void)
39{ 39{
40#if __LINUX_ARM_ARCH__ >= 7 40
41 __asm__ __volatile__ ( 41 dsb(ishst);
42 "dsb ishst\n" 42 __asm__(SEV);
43 SEV
44 );
45#else
46 __asm__ __volatile__ (
47 "mcr p15, 0, %0, c7, c10, 4\n"
48 SEV
49 : : "r" (0)
50 );
51#endif
52} 43}
53 44
54/* 45/*
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index b0df9761de6d..1e8b030dbefd 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -731,7 +731,7 @@ static void __init request_standard_resources(const struct machine_desc *mdesc)
731 kernel_data.end = virt_to_phys(_end - 1); 731 kernel_data.end = virt_to_phys(_end - 1);
732 732
733 for_each_memblock(memory, region) { 733 for_each_memblock(memory, region) {
734 res = memblock_virt_alloc_low(sizeof(*res), 0); 734 res = memblock_virt_alloc(sizeof(*res), 0);
735 res->name = "System RAM"; 735 res->name = "System RAM";
736 res->start = __pfn_to_phys(memblock_region_memory_base_pfn(region)); 736 res->start = __pfn_to_phys(memblock_region_memory_base_pfn(region));
737 res->end = __pfn_to_phys(memblock_region_memory_end_pfn(region)) - 1; 737 res->end = __pfn_to_phys(memblock_region_memory_end_pfn(region)) - 1;
diff --git a/arch/arm/mach-bcm/Kconfig b/arch/arm/mach-bcm/Kconfig
index b1aa6a9b3bd1..af4f2dfda40c 100644
--- a/arch/arm/mach-bcm/Kconfig
+++ b/arch/arm/mach-bcm/Kconfig
@@ -16,12 +16,7 @@ config ARCH_BCM_MOBILE
16 select ARM_ERRATA_754322 16 select ARM_ERRATA_754322
17 select ARM_ERRATA_764369 if SMP 17 select ARM_ERRATA_764369 if SMP
18 select ARM_GIC 18 select ARM_GIC
19 select CPU_V7
20 select CLKSRC_OF
21 select GENERIC_CLOCKEVENTS
22 select GENERIC_TIME
23 select GPIO_BCM_KONA 19 select GPIO_BCM_KONA
24 select SPARSE_IRQ
25 select TICK_ONESHOT 20 select TICK_ONESHOT
26 select CACHE_L2X0 21 select CACHE_L2X0
27 select HAVE_ARM_ARCH_TIMER 22 select HAVE_ARM_ARCH_TIMER
diff --git a/arch/arm/mach-bcm2835/Kconfig b/arch/arm/mach-bcm2835/Kconfig
index d1f9612f8c15..3a369350a26f 100644
--- a/arch/arm/mach-bcm2835/Kconfig
+++ b/arch/arm/mach-bcm2835/Kconfig
@@ -4,10 +4,6 @@ config ARCH_BCM2835
4 select ARM_AMBA 4 select ARM_AMBA
5 select ARM_ERRATA_411920 5 select ARM_ERRATA_411920
6 select ARM_TIMER_SP804 6 select ARM_TIMER_SP804
7 select CLKDEV_LOOKUP
8 select CLKSRC_OF
9 select CPU_V6
10 select GENERIC_CLOCKEVENTS
11 select PINCTRL 7 select PINCTRL
12 select PINCTRL_BCM2835 8 select PINCTRL_BCM2835
13 help 9 help
diff --git a/arch/arm/mach-berlin/Kconfig b/arch/arm/mach-berlin/Kconfig
index 7a02d222c378..b0cb0722acd2 100644
--- a/arch/arm/mach-berlin/Kconfig
+++ b/arch/arm/mach-berlin/Kconfig
@@ -1,9 +1,7 @@
1config ARCH_BERLIN 1config ARCH_BERLIN
2 bool "Marvell Berlin SoCs" if ARCH_MULTI_V7 2 bool "Marvell Berlin SoCs" if ARCH_MULTI_V7
3 select ARM_GIC 3 select ARM_GIC
4 select GENERIC_CLOCKEVENTS
5 select GENERIC_IRQ_CHIP 4 select GENERIC_IRQ_CHIP
6 select COMMON_CLK
7 select DW_APB_ICTL 5 select DW_APB_ICTL
8 select DW_APB_TIMER_OF 6 select DW_APB_TIMER_OF
9 7
@@ -16,12 +14,10 @@ config MACH_BERLIN_BG2
16 select CACHE_L2X0 14 select CACHE_L2X0
17 select CPU_PJ4B 15 select CPU_PJ4B
18 select HAVE_ARM_TWD if SMP 16 select HAVE_ARM_TWD if SMP
19 select HAVE_SMP
20 17
21config MACH_BERLIN_BG2CD 18config MACH_BERLIN_BG2CD
22 bool "Marvell Armada 1500-mini (BG2CD)" 19 bool "Marvell Armada 1500-mini (BG2CD)"
23 select CACHE_L2X0 20 select CACHE_L2X0
24 select CPU_V7
25 select HAVE_ARM_TWD if SMP 21 select HAVE_ARM_TWD if SMP
26 22
27endmenu 23endmenu
diff --git a/arch/arm/mach-cns3xxx/Kconfig b/arch/arm/mach-cns3xxx/Kconfig
index dbf0df8bb0ac..dce8decd5d46 100644
--- a/arch/arm/mach-cns3xxx/Kconfig
+++ b/arch/arm/mach-cns3xxx/Kconfig
@@ -1,9 +1,6 @@
1config ARCH_CNS3XXX 1config ARCH_CNS3XXX
2 bool "Cavium Networks CNS3XXX family" if ARCH_MULTI_V6 2 bool "Cavium Networks CNS3XXX family" if ARCH_MULTI_V6
3 select ARM_GIC 3 select ARM_GIC
4 select CPU_V6K
5 select GENERIC_CLOCKEVENTS
6 select MIGHT_HAVE_CACHE_L2X0
7 select MIGHT_HAVE_PCI 4 select MIGHT_HAVE_PCI
8 select PCI_DOMAINS if PCI 5 select PCI_DOMAINS if PCI
9 help 6 help
diff --git a/arch/arm/mach-highbank/Kconfig b/arch/arm/mach-highbank/Kconfig
index 0aded64a9ebc..830b76e70250 100644
--- a/arch/arm/mach-highbank/Kconfig
+++ b/arch/arm/mach-highbank/Kconfig
@@ -5,7 +5,6 @@ config ARCH_HIGHBANK
5 select ARCH_HAS_HOLES_MEMORYMODEL 5 select ARCH_HAS_HOLES_MEMORYMODEL
6 select ARCH_HAS_OPP 6 select ARCH_HAS_OPP
7 select ARCH_SUPPORTS_BIG_ENDIAN 7 select ARCH_SUPPORTS_BIG_ENDIAN
8 select ARCH_WANT_OPTIONAL_GPIOLIB
9 select ARM_AMBA 8 select ARM_AMBA
10 select ARM_ERRATA_764369 if SMP 9 select ARM_ERRATA_764369 if SMP
11 select ARM_ERRATA_775420 10 select ARM_ERRATA_775420
@@ -14,14 +13,8 @@ config ARCH_HIGHBANK
14 select ARM_PSCI 13 select ARM_PSCI
15 select ARM_TIMER_SP804 14 select ARM_TIMER_SP804
16 select CACHE_L2X0 15 select CACHE_L2X0
17 select COMMON_CLK
18 select CPU_V7
19 select GENERIC_CLOCKEVENTS
20 select HAVE_ARM_SCU 16 select HAVE_ARM_SCU
21 select HAVE_ARM_TWD if SMP 17 select HAVE_ARM_TWD if SMP
22 select HAVE_SMP
23 select MAILBOX 18 select MAILBOX
24 select PL320_MBOX 19 select PL320_MBOX
25 select SPARSE_IRQ
26 select USE_OF
27 select ZONE_DMA if ARM_LPAE 20 select ZONE_DMA if ARM_LPAE
diff --git a/arch/arm/mach-hisi/Kconfig b/arch/arm/mach-hisi/Kconfig
index 1abae5f6a418..9d0a87b025e3 100644
--- a/arch/arm/mach-hisi/Kconfig
+++ b/arch/arm/mach-hisi/Kconfig
@@ -3,13 +3,9 @@ config ARCH_HI3xxx
3 select ARM_AMBA 3 select ARM_AMBA
4 select ARM_GIC 4 select ARM_GIC
5 select ARM_TIMER_SP804 5 select ARM_TIMER_SP804
6 select ARCH_WANT_OPTIONAL_GPIOLIB
7 select CACHE_L2X0 6 select CACHE_L2X0
8 select CLKSRC_OF
9 select GENERIC_CLOCKEVENTS
10 select HAVE_ARM_SCU 7 select HAVE_ARM_SCU
11 select HAVE_ARM_TWD if SMP 8 select HAVE_ARM_TWD if SMP
12 select HAVE_SMP
13 select PINCTRL 9 select PINCTRL
14 select PINCTRL_SINGLE 10 select PINCTRL_SINGLE
15 help 11 help
diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig
index 33567aa5880f..5740296dc429 100644
--- a/arch/arm/mach-imx/Kconfig
+++ b/arch/arm/mach-imx/Kconfig
@@ -1,19 +1,15 @@
1config ARCH_MXC 1config ARCH_MXC
2 bool "Freescale i.MX family" if ARCH_MULTI_V4_V5 || ARCH_MULTI_V6_V7 2 bool "Freescale i.MX family" if ARCH_MULTI_V4_V5 || ARCH_MULTI_V6_V7
3 select ARCH_HAS_CPUFREQ
4 select ARCH_HAS_OPP
3 select ARCH_REQUIRE_GPIOLIB 5 select ARCH_REQUIRE_GPIOLIB
4 select ARM_CPU_SUSPEND if PM 6 select ARM_CPU_SUSPEND if PM
5 select ARM_PATCH_PHYS_VIRT
6 select CLKSRC_MMIO 7 select CLKSRC_MMIO
7 select COMMON_CLK
8 select GENERIC_ALLOCATOR
9 select GENERIC_CLOCKEVENTS
10 select GENERIC_IRQ_CHIP 8 select GENERIC_IRQ_CHIP
11 select MIGHT_HAVE_CACHE_L2X0 if ARCH_MULTI_V6_V7
12 select MULTI_IRQ_HANDLER
13 select PINCTRL 9 select PINCTRL
10 select PM_OPP if PM
14 select SOC_BUS 11 select SOC_BUS
15 select SPARSE_IRQ 12 select SRAM
16 select USE_OF
17 help 13 help
18 Support for Freescale MXC/iMX-based family of processors 14 Support for Freescale MXC/iMX-based family of processors
19 15
@@ -121,18 +117,16 @@ config SOC_IMX31
121config SOC_IMX35 117config SOC_IMX35
122 bool 118 bool
123 select ARCH_MXC_IOMUX_V3 119 select ARCH_MXC_IOMUX_V3
124 select CPU_V6K
125 select HAVE_EPIT 120 select HAVE_EPIT
126 select MXC_AVIC 121 select MXC_AVIC
122 select PINCTRL_IMX35
127 select SMP_ON_UP if SMP 123 select SMP_ON_UP if SMP
128 select PINCTRL
129 124
130config SOC_IMX5 125config SOC_IMX5
131 bool 126 bool
132 select ARCH_HAS_CPUFREQ 127 select ARCH_HAS_CPUFREQ
133 select ARCH_HAS_OPP 128 select ARCH_HAS_OPP
134 select ARCH_MXC_IOMUX_V3 129 select ARCH_MXC_IOMUX_V3
135 select CPU_V7
136 select MXC_TZIC 130 select MXC_TZIC
137 131
138config SOC_IMX51 132config SOC_IMX51
@@ -777,65 +771,50 @@ config SOC_IMX50
777config SOC_IMX53 771config SOC_IMX53
778 bool "i.MX53 support" 772 bool "i.MX53 support"
779 select HAVE_IMX_SRC 773 select HAVE_IMX_SRC
780 select IMX_HAVE_PLATFORM_IMX2_WDT
781 select PINCTRL_IMX53 774 select PINCTRL_IMX53
782 select SOC_IMX5 775 select SOC_IMX5
783 776
784 help 777 help
785 This enables support for Freescale i.MX53 processor. 778 This enables support for Freescale i.MX53 processor.
786 779
787config SOC_IMX6Q 780config SOC_IMX6
788 bool "i.MX6 Quad/DualLite support" 781 bool
789 select ARCH_HAS_CPUFREQ
790 select ARCH_HAS_OPP
791 select ARM_ERRATA_754322 782 select ARM_ERRATA_754322
792 select ARM_ERRATA_764369 if SMP
793 select ARM_ERRATA_775420 783 select ARM_ERRATA_775420
794 select ARM_GIC 784 select ARM_GIC
795 select CPU_V7
796 select HAVE_ARM_SCU if SMP
797 select HAVE_ARM_TWD if SMP
798 select HAVE_IMX_ANATOP 785 select HAVE_IMX_ANATOP
799 select HAVE_IMX_GPC 786 select HAVE_IMX_GPC
800 select HAVE_IMX_MMDC 787 select HAVE_IMX_MMDC
801 select HAVE_IMX_SRC 788 select HAVE_IMX_SRC
802 select HAVE_SMP
803 select MFD_SYSCON 789 select MFD_SYSCON
804 select MIGHT_HAVE_PCI
805 select PCI_DOMAINS if PCI
806 select PINCTRL_IMX6Q
807 select PL310_ERRATA_588369 if CACHE_PL310 790 select PL310_ERRATA_588369 if CACHE_PL310
808 select PL310_ERRATA_727915 if CACHE_PL310 791 select PL310_ERRATA_727915 if CACHE_PL310
809 select PL310_ERRATA_769419 if CACHE_PL310 792 select PL310_ERRATA_769419 if CACHE_PL310
810 select PM_OPP if PM 793
794config SOC_IMX6Q
795 bool "i.MX6 Quad/DualLite support"
796 select ARM_ERRATA_764369 if SMP
797 select HAVE_ARM_SCU if SMP
798 select HAVE_ARM_TWD if SMP
799 select MIGHT_HAVE_PCI
800 select PCI_DOMAINS if PCI
801 select PINCTRL_IMX6Q
802 select SOC_IMX6
811 803
812 help 804 help
813 This enables support for Freescale i.MX6 Quad processor. 805 This enables support for Freescale i.MX6 Quad processor.
814 806
815config SOC_IMX6SL 807config SOC_IMX6SL
816 bool "i.MX6 SoloLite support" 808 bool "i.MX6 SoloLite support"
817 select ARM_ERRATA_754322
818 select ARM_ERRATA_775420
819 select ARM_GIC
820 select CPU_V7
821 select HAVE_IMX_ANATOP
822 select HAVE_IMX_GPC
823 select HAVE_IMX_MMDC
824 select HAVE_IMX_SRC
825 select MFD_SYSCON
826 select PINCTRL_IMX6SL 809 select PINCTRL_IMX6SL
827 select PL310_ERRATA_588369 if CACHE_PL310 810 select SOC_IMX6
828 select PL310_ERRATA_727915 if CACHE_PL310
829 select PL310_ERRATA_769419 if CACHE_PL310
830 811
831 help 812 help
832 This enables support for Freescale i.MX6 SoloLite processor. 813 This enables support for Freescale i.MX6 SoloLite processor.
833 814
834config SOC_VF610 815config SOC_VF610
835 bool "Vybrid Family VF610 support" 816 bool "Vybrid Family VF610 support"
836 select CPU_V7
837 select ARM_GIC 817 select ARM_GIC
838 select CLKSRC_OF
839 select PINCTRL_VF610 818 select PINCTRL_VF610
840 select VF_PIT_TIMER 819 select VF_PIT_TIMER
841 select PL310_ERRATA_588369 if CACHE_PL310 820 select PL310_ERRATA_588369 if CACHE_PL310
diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile
index befcaf5d0574..f4ed83032dd0 100644
--- a/arch/arm/mach-imx/Makefile
+++ b/arch/arm/mach-imx/Makefile
@@ -30,6 +30,7 @@ obj-$(CONFIG_MXC_DEBUG_BOARD) += 3ds_debugboard.o
30ifeq ($(CONFIG_CPU_IDLE),y) 30ifeq ($(CONFIG_CPU_IDLE),y)
31obj-$(CONFIG_SOC_IMX5) += cpuidle-imx5.o 31obj-$(CONFIG_SOC_IMX5) += cpuidle-imx5.o
32obj-$(CONFIG_SOC_IMX6Q) += cpuidle-imx6q.o 32obj-$(CONFIG_SOC_IMX6Q) += cpuidle-imx6q.o
33obj-$(CONFIG_SOC_IMX6SL) += cpuidle-imx6sl.o
33endif 34endif
34 35
35ifdef CONFIG_SND_IMX_SOC 36ifdef CONFIG_SND_IMX_SOC
@@ -101,11 +102,11 @@ obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o
101obj-$(CONFIG_SOC_IMX6Q) += clk-imx6q.o mach-imx6q.o 102obj-$(CONFIG_SOC_IMX6Q) += clk-imx6q.o mach-imx6q.o
102obj-$(CONFIG_SOC_IMX6SL) += clk-imx6sl.o mach-imx6sl.o 103obj-$(CONFIG_SOC_IMX6SL) += clk-imx6sl.o mach-imx6sl.o
103 104
104ifeq ($(CONFIG_PM),y) 105ifeq ($(CONFIG_SUSPEND),y)
105obj-$(CONFIG_SOC_IMX6Q) += pm-imx6q.o headsmp.o 106AFLAGS_suspend-imx6.o :=-Wa,-march=armv7-a
106# i.MX6SL reuses i.MX6Q code 107obj-$(CONFIG_SOC_IMX6) += suspend-imx6.o
107obj-$(CONFIG_SOC_IMX6SL) += pm-imx6q.o headsmp.o
108endif 108endif
109obj-$(CONFIG_SOC_IMX6) += pm-imx6.o
109 110
110# i.MX5 based machines 111# i.MX5 based machines
111obj-$(CONFIG_MACH_MX51_BABBAGE) += mach-mx51_babbage.o 112obj-$(CONFIG_MACH_MX51_BABBAGE) += mach-mx51_babbage.o
diff --git a/arch/arm/mach-imx/clk-imx21.c b/arch/arm/mach-imx/clk-imx21.c
index d7ed66091a2a..bdc2e4630a08 100644
--- a/arch/arm/mach-imx/clk-imx21.c
+++ b/arch/arm/mach-imx/clk-imx21.c
@@ -149,7 +149,6 @@ int __init mx21_clocks_init(unsigned long lref, unsigned long href)
149 clk_register_clkdev(clk[per1], "per", "imx-gpt.1"); 149 clk_register_clkdev(clk[per1], "per", "imx-gpt.1");
150 clk_register_clkdev(clk[gpt3_ipg_gate], "ipg", "imx-gpt.2"); 150 clk_register_clkdev(clk[gpt3_ipg_gate], "ipg", "imx-gpt.2");
151 clk_register_clkdev(clk[per1], "per", "imx-gpt.2"); 151 clk_register_clkdev(clk[per1], "per", "imx-gpt.2");
152 clk_register_clkdev(clk[pwm_ipg_gate], "pwm", "mxc_pwm.0");
153 clk_register_clkdev(clk[per2], "per", "imx21-cspi.0"); 152 clk_register_clkdev(clk[per2], "per", "imx21-cspi.0");
154 clk_register_clkdev(clk[cspi1_ipg_gate], "ipg", "imx21-cspi.0"); 153 clk_register_clkdev(clk[cspi1_ipg_gate], "ipg", "imx21-cspi.0");
155 clk_register_clkdev(clk[per2], "per", "imx21-cspi.1"); 154 clk_register_clkdev(clk[per2], "per", "imx21-cspi.1");
diff --git a/arch/arm/mach-imx/clk-imx25.c b/arch/arm/mach-imx/clk-imx25.c
index 69858c78f40d..dc36e6c2f1da 100644
--- a/arch/arm/mach-imx/clk-imx25.c
+++ b/arch/arm/mach-imx/clk-imx25.c
@@ -265,14 +265,6 @@ int __init mx25_clocks_init(void)
265 clk_register_clkdev(clk[cspi1_ipg], NULL, "imx35-cspi.0"); 265 clk_register_clkdev(clk[cspi1_ipg], NULL, "imx35-cspi.0");
266 clk_register_clkdev(clk[cspi2_ipg], NULL, "imx35-cspi.1"); 266 clk_register_clkdev(clk[cspi2_ipg], NULL, "imx35-cspi.1");
267 clk_register_clkdev(clk[cspi3_ipg], NULL, "imx35-cspi.2"); 267 clk_register_clkdev(clk[cspi3_ipg], NULL, "imx35-cspi.2");
268 clk_register_clkdev(clk[pwm1_ipg], "ipg", "mxc_pwm.0");
269 clk_register_clkdev(clk[per10], "per", "mxc_pwm.0");
270 clk_register_clkdev(clk[pwm1_ipg], "ipg", "mxc_pwm.1");
271 clk_register_clkdev(clk[per10], "per", "mxc_pwm.1");
272 clk_register_clkdev(clk[pwm1_ipg], "ipg", "mxc_pwm.2");
273 clk_register_clkdev(clk[per10], "per", "mxc_pwm.2");
274 clk_register_clkdev(clk[pwm1_ipg], "ipg", "mxc_pwm.3");
275 clk_register_clkdev(clk[per10], "per", "mxc_pwm.3");
276 clk_register_clkdev(clk[kpp_ipg], NULL, "imx-keypad"); 268 clk_register_clkdev(clk[kpp_ipg], NULL, "imx-keypad");
277 clk_register_clkdev(clk[tsc_ipg], NULL, "mx25-adc"); 269 clk_register_clkdev(clk[tsc_ipg], NULL, "mx25-adc");
278 clk_register_clkdev(clk[i2c_ipg_per], NULL, "imx21-i2c.0"); 270 clk_register_clkdev(clk[i2c_ipg_per], NULL, "imx21-i2c.0");
diff --git a/arch/arm/mach-imx/clk-imx27.c b/arch/arm/mach-imx/clk-imx27.c
index c6b40f386786..d2da8908b268 100644
--- a/arch/arm/mach-imx/clk-imx27.c
+++ b/arch/arm/mach-imx/clk-imx27.c
@@ -231,7 +231,6 @@ int __init mx27_clocks_init(unsigned long fref)
231 clk_register_clkdev(clk[per1_gate], "per", "imx-gpt.4"); 231 clk_register_clkdev(clk[per1_gate], "per", "imx-gpt.4");
232 clk_register_clkdev(clk[gpt6_ipg_gate], "ipg", "imx-gpt.5"); 232 clk_register_clkdev(clk[gpt6_ipg_gate], "ipg", "imx-gpt.5");
233 clk_register_clkdev(clk[per1_gate], "per", "imx-gpt.5"); 233 clk_register_clkdev(clk[per1_gate], "per", "imx-gpt.5");
234 clk_register_clkdev(clk[pwm_ipg_gate], NULL, "mxc_pwm.0");
235 clk_register_clkdev(clk[per2_gate], "per", "imx21-mmc.0"); 234 clk_register_clkdev(clk[per2_gate], "per", "imx21-mmc.0");
236 clk_register_clkdev(clk[sdhc1_ipg_gate], "ipg", "imx21-mmc.0"); 235 clk_register_clkdev(clk[sdhc1_ipg_gate], "ipg", "imx21-mmc.0");
237 clk_register_clkdev(clk[per2_gate], "per", "imx21-mmc.1"); 236 clk_register_clkdev(clk[per2_gate], "per", "imx21-mmc.1");
diff --git a/arch/arm/mach-imx/clk-imx51-imx53.c b/arch/arm/mach-imx/clk-imx51-imx53.c
index 19fca1fdc6fe..568ef0a4de84 100644
--- a/arch/arm/mach-imx/clk-imx51-imx53.c
+++ b/arch/arm/mach-imx/clk-imx51-imx53.c
@@ -266,8 +266,6 @@ static void __init mx5_clocks_common_init(unsigned long rate_ckil,
266 clk_register_clkdev(clk[IMX5_CLK_ECSPI2_PER_GATE], "per", "imx51-ecspi.1"); 266 clk_register_clkdev(clk[IMX5_CLK_ECSPI2_PER_GATE], "per", "imx51-ecspi.1");
267 clk_register_clkdev(clk[IMX5_CLK_ECSPI2_IPG_GATE], "ipg", "imx51-ecspi.1"); 267 clk_register_clkdev(clk[IMX5_CLK_ECSPI2_IPG_GATE], "ipg", "imx51-ecspi.1");
268 clk_register_clkdev(clk[IMX5_CLK_CSPI_IPG_GATE], NULL, "imx35-cspi.2"); 268 clk_register_clkdev(clk[IMX5_CLK_CSPI_IPG_GATE], NULL, "imx35-cspi.2");
269 clk_register_clkdev(clk[IMX5_CLK_PWM1_IPG_GATE], "pwm", "mxc_pwm.0");
270 clk_register_clkdev(clk[IMX5_CLK_PWM2_IPG_GATE], "pwm", "mxc_pwm.1");
271 clk_register_clkdev(clk[IMX5_CLK_I2C1_GATE], NULL, "imx21-i2c.0"); 269 clk_register_clkdev(clk[IMX5_CLK_I2C1_GATE], NULL, "imx21-i2c.0");
272 clk_register_clkdev(clk[IMX5_CLK_I2C2_GATE], NULL, "imx21-i2c.1"); 270 clk_register_clkdev(clk[IMX5_CLK_I2C2_GATE], NULL, "imx21-i2c.1");
273 clk_register_clkdev(clk[IMX5_CLK_USBOH3_PER_GATE], "per", "mxc-ehci.0"); 271 clk_register_clkdev(clk[IMX5_CLK_USBOH3_PER_GATE], "per", "mxc-ehci.0");
diff --git a/arch/arm/mach-imx/clk-imx6q.c b/arch/arm/mach-imx/clk-imx6q.c
index 4d677f442539..b0e7f9d2c245 100644
--- a/arch/arm/mach-imx/clk-imx6q.c
+++ b/arch/arm/mach-imx/clk-imx6q.c
@@ -437,12 +437,7 @@ static void __init imx6q_clocks_init(struct device_node *ccm_node)
437 437
438 clk_register_clkdev(clk[gpt_ipg], "ipg", "imx-gpt.0"); 438 clk_register_clkdev(clk[gpt_ipg], "ipg", "imx-gpt.0");
439 clk_register_clkdev(clk[gpt_ipg_per], "per", "imx-gpt.0"); 439 clk_register_clkdev(clk[gpt_ipg_per], "per", "imx-gpt.0");
440 clk_register_clkdev(clk[cko1_sel], "cko1_sel", NULL); 440 clk_register_clkdev(clk[enet_ref], "enet_ref", NULL);
441 clk_register_clkdev(clk[ahb], "ahb", NULL);
442 clk_register_clkdev(clk[cko1], "cko1", NULL);
443 clk_register_clkdev(clk[arm], NULL, "cpu0");
444 clk_register_clkdev(clk[pll4_post_div], "pll4_post_div", NULL);
445 clk_register_clkdev(clk[pll4_audio], "pll4_audio", NULL);
446 441
447 if ((imx_get_soc_revision() != IMX_CHIP_REVISION_1_0) || 442 if ((imx_get_soc_revision() != IMX_CHIP_REVISION_1_0) ||
448 cpu_is_imx6dl()) { 443 cpu_is_imx6dl()) {
diff --git a/arch/arm/mach-imx/clk-imx6sl.c b/arch/arm/mach-imx/clk-imx6sl.c
index 4c86f3035205..f7073c0782fb 100644
--- a/arch/arm/mach-imx/clk-imx6sl.c
+++ b/arch/arm/mach-imx/clk-imx6sl.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright 2013 Freescale Semiconductor, Inc. 2 * Copyright 2013-2014 Freescale Semiconductor, Inc.
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify 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 5 * it under the terms of the GNU General Public License version 2 as
@@ -18,27 +18,43 @@
18#include "clk.h" 18#include "clk.h"
19#include "common.h" 19#include "common.h"
20 20
21static const char const *step_sels[] = { "osc", "pll2_pfd2", }; 21#define CCSR 0xc
22static const char const *pll1_sw_sels[] = { "pll1_sys", "step", }; 22#define BM_CCSR_PLL1_SW_CLK_SEL (1 << 2)
23static const char const *ocram_alt_sels[] = { "pll2_pfd2", "pll3_pfd1", }; 23#define CACRR 0x10
24static const char const *ocram_sels[] = { "periph", "ocram_alt_sels", }; 24#define CDHIPR 0x48
25static const char const *pre_periph_sels[] = { "pll2_bus", "pll2_pfd2", "pll2_pfd0", "pll2_198m", }; 25#define BM_CDHIPR_ARM_PODF_BUSY (1 << 16)
26static const char const *periph_clk2_sels[] = { "pll3_usb_otg", "osc", "osc", "dummy", }; 26#define ARM_WAIT_DIV_396M 2
27static const char const *periph2_clk2_sels[] = { "pll3_usb_otg", "pll2_bus", }; 27#define ARM_WAIT_DIV_792M 4
28static const char const *periph_sels[] = { "pre_periph_sel", "periph_clk2_podf", }; 28#define ARM_WAIT_DIV_996M 6
29static const char const *periph2_sels[] = { "pre_periph2_sel", "periph2_clk2_podf", }; 29
30static const char const *csi_lcdif_sels[] = { "mmdc", "pll2_pfd2", "pll3_120m", "pll3_pfd1", }; 30#define PLL_ARM 0x0
31static const char const *usdhc_sels[] = { "pll2_pfd2", "pll2_pfd0", }; 31#define BM_PLL_ARM_DIV_SELECT (0x7f << 0)
32static const char const *ssi_sels[] = { "pll3_pfd2", "pll3_pfd3", "pll4_audio_div", "dummy", }; 32#define BM_PLL_ARM_POWERDOWN (1 << 12)
33static const char const *perclk_sels[] = { "ipg", "osc", }; 33#define BM_PLL_ARM_ENABLE (1 << 13)
34static const char const *epdc_pxp_sels[] = { "mmdc", "pll3_usb_otg", "pll5_video_div", "pll2_pfd0", "pll2_pfd2", "pll3_pfd1", }; 34#define BM_PLL_ARM_LOCK (1 << 31)
35static const char const *gpu2d_ovg_sels[] = { "pll3_pfd1", "pll3_usb_otg", "pll2_bus", "pll2_pfd2", }; 35#define PLL_ARM_DIV_792M 66
36static const char const *gpu2d_sels[] = { "pll2_pfd2", "pll3_usb_otg", "pll3_pfd1", "pll2_bus", }; 36
37static const char const *lcdif_pix_sels[] = { "pll2_bus", "pll3_usb_otg", "pll5_video_div", "pll2_pfd0", "pll3_pfd0", "pll3_pfd1", }; 37static const char *step_sels[] = { "osc", "pll2_pfd2", };
38static const char const *epdc_pix_sels[] = { "pll2_bus", "pll3_usb_otg", "pll5_video_div", "pll2_pfd0", "pll2_pfd1", "pll3_pfd1", }; 38static const char *pll1_sw_sels[] = { "pll1_sys", "step", };
39static const char const *audio_sels[] = { "pll4_audio_div", "pll3_pfd2", "pll3_pfd3", "pll3_usb_otg", }; 39static const char *ocram_alt_sels[] = { "pll2_pfd2", "pll3_pfd1", };
40static const char const *ecspi_sels[] = { "pll3_60m", "osc", }; 40static const char *ocram_sels[] = { "periph", "ocram_alt_sels", };
41static const char const *uart_sels[] = { "pll3_80m", "osc", }; 41static const char *pre_periph_sels[] = { "pll2_bus", "pll2_pfd2", "pll2_pfd0", "pll2_198m", };
42static const char *periph_clk2_sels[] = { "pll3_usb_otg", "osc", "osc", "dummy", };
43static const char *periph2_clk2_sels[] = { "pll3_usb_otg", "pll2_bus", };
44static const char *periph_sels[] = { "pre_periph_sel", "periph_clk2_podf", };
45static const char *periph2_sels[] = { "pre_periph2_sel", "periph2_clk2_podf", };
46static const char *csi_lcdif_sels[] = { "mmdc", "pll2_pfd2", "pll3_120m", "pll3_pfd1", };
47static const char *usdhc_sels[] = { "pll2_pfd2", "pll2_pfd0", };
48static const char *ssi_sels[] = { "pll3_pfd2", "pll3_pfd3", "pll4_audio_div", "dummy", };
49static const char *perclk_sels[] = { "ipg", "osc", };
50static const char *epdc_pxp_sels[] = { "mmdc", "pll3_usb_otg", "pll5_video_div", "pll2_pfd0", "pll2_pfd2", "pll3_pfd1", };
51static const char *gpu2d_ovg_sels[] = { "pll3_pfd1", "pll3_usb_otg", "pll2_bus", "pll2_pfd2", };
52static const char *gpu2d_sels[] = { "pll2_pfd2", "pll3_usb_otg", "pll3_pfd1", "pll2_bus", };
53static const char *lcdif_pix_sels[] = { "pll2_bus", "pll3_usb_otg", "pll5_video_div", "pll2_pfd0", "pll3_pfd0", "pll3_pfd1", };
54static const char *epdc_pix_sels[] = { "pll2_bus", "pll3_usb_otg", "pll5_video_div", "pll2_pfd0", "pll2_pfd1", "pll3_pfd1", };
55static const char *audio_sels[] = { "pll4_audio_div", "pll3_pfd2", "pll3_pfd3", "pll3_usb_otg", };
56static const char *ecspi_sels[] = { "pll3_60m", "osc", };
57static const char *uart_sels[] = { "pll3_80m", "osc", };
42 58
43static struct clk_div_table clk_enet_ref_table[] = { 59static struct clk_div_table clk_enet_ref_table[] = {
44 { .val = 0, .div = 20, }, 60 { .val = 0, .div = 20, },
@@ -65,6 +81,89 @@ static struct clk_div_table video_div_table[] = {
65 81
66static struct clk *clks[IMX6SL_CLK_END]; 82static struct clk *clks[IMX6SL_CLK_END];
67static struct clk_onecell_data clk_data; 83static struct clk_onecell_data clk_data;
84static void __iomem *ccm_base;
85static void __iomem *anatop_base;
86
87static const u32 clks_init_on[] __initconst = {
88 IMX6SL_CLK_IPG, IMX6SL_CLK_ARM, IMX6SL_CLK_MMDC_ROOT,
89};
90
91/*
92 * ERR005311 CCM: After exit from WAIT mode, unwanted interrupt(s) taken
93 * during WAIT mode entry process could cause cache memory
94 * corruption.
95 *
96 * Software workaround:
97 * To prevent this issue from occurring, software should ensure that the
98 * ARM to IPG clock ratio is less than 12:5 (that is < 2.4x), before
99 * entering WAIT mode.
100 *
101 * This function will set the ARM clk to max value within the 12:5 limit.
102 * As IPG clock is fixed at 66MHz(so ARM freq must not exceed 158.4MHz),
103 * ARM freq are one of below setpoints: 396MHz, 792MHz and 996MHz, since
104 * the clk APIs can NOT be called in idle thread(may cause kernel schedule
105 * as there is sleep function in PLL wait function), so here we just slow
106 * down ARM to below freq according to previous freq:
107 *
108 * run mode wait mode
109 * 396MHz -> 132MHz;
110 * 792MHz -> 158.4MHz;
111 * 996MHz -> 142.3MHz;
112 */
113static int imx6sl_get_arm_divider_for_wait(void)
114{
115 if (readl_relaxed(ccm_base + CCSR) & BM_CCSR_PLL1_SW_CLK_SEL) {
116 return ARM_WAIT_DIV_396M;
117 } else {
118 if ((readl_relaxed(anatop_base + PLL_ARM) &
119 BM_PLL_ARM_DIV_SELECT) == PLL_ARM_DIV_792M)
120 return ARM_WAIT_DIV_792M;
121 else
122 return ARM_WAIT_DIV_996M;
123 }
124}
125
126static void imx6sl_enable_pll_arm(bool enable)
127{
128 static u32 saved_pll_arm;
129 u32 val;
130
131 if (enable) {
132 saved_pll_arm = val = readl_relaxed(anatop_base + PLL_ARM);
133 val |= BM_PLL_ARM_ENABLE;
134 val &= ~BM_PLL_ARM_POWERDOWN;
135 writel_relaxed(val, anatop_base + PLL_ARM);
136 while (!(__raw_readl(anatop_base + PLL_ARM) & BM_PLL_ARM_LOCK))
137 ;
138 } else {
139 writel_relaxed(saved_pll_arm, anatop_base + PLL_ARM);
140 }
141}
142
143void imx6sl_set_wait_clk(bool enter)
144{
145 static unsigned long saved_arm_div;
146 int arm_div_for_wait = imx6sl_get_arm_divider_for_wait();
147
148 /*
149 * According to hardware design, arm podf change need
150 * PLL1 clock enabled.
151 */
152 if (arm_div_for_wait == ARM_WAIT_DIV_396M)
153 imx6sl_enable_pll_arm(true);
154
155 if (enter) {
156 saved_arm_div = readl_relaxed(ccm_base + CACRR);
157 writel_relaxed(arm_div_for_wait, ccm_base + CACRR);
158 } else {
159 writel_relaxed(saved_arm_div, ccm_base + CACRR);
160 }
161 while (__raw_readl(ccm_base + CDHIPR) & BM_CDHIPR_ARM_PODF_BUSY)
162 ;
163
164 if (arm_div_for_wait == ARM_WAIT_DIV_396M)
165 imx6sl_enable_pll_arm(false);
166}
68 167
69static void __init imx6sl_clocks_init(struct device_node *ccm_node) 168static void __init imx6sl_clocks_init(struct device_node *ccm_node)
70{ 169{
@@ -72,6 +171,7 @@ static void __init imx6sl_clocks_init(struct device_node *ccm_node)
72 void __iomem *base; 171 void __iomem *base;
73 int irq; 172 int irq;
74 int i; 173 int i;
174 int ret;
75 175
76 clks[IMX6SL_CLK_DUMMY] = imx_clk_fixed("dummy", 0); 176 clks[IMX6SL_CLK_DUMMY] = imx_clk_fixed("dummy", 0);
77 clks[IMX6SL_CLK_CKIL] = imx_obtain_fixed_clock("ckil", 0); 177 clks[IMX6SL_CLK_CKIL] = imx_obtain_fixed_clock("ckil", 0);
@@ -80,6 +180,7 @@ static void __init imx6sl_clocks_init(struct device_node *ccm_node)
80 np = of_find_compatible_node(NULL, NULL, "fsl,imx6sl-anatop"); 180 np = of_find_compatible_node(NULL, NULL, "fsl,imx6sl-anatop");
81 base = of_iomap(np, 0); 181 base = of_iomap(np, 0);
82 WARN_ON(!base); 182 WARN_ON(!base);
183 anatop_base = base;
83 184
84 /* type name parent base div_mask */ 185 /* type name parent base div_mask */
85 clks[IMX6SL_CLK_PLL1_SYS] = imx_clk_pllv3(IMX_PLLV3_SYS, "pll1_sys", "osc", base, 0x7f); 186 clks[IMX6SL_CLK_PLL1_SYS] = imx_clk_pllv3(IMX_PLLV3_SYS, "pll1_sys", "osc", base, 0x7f);
@@ -127,6 +228,7 @@ static void __init imx6sl_clocks_init(struct device_node *ccm_node)
127 np = ccm_node; 228 np = ccm_node;
128 base = of_iomap(np, 0); 229 base = of_iomap(np, 0);
129 WARN_ON(!base); 230 WARN_ON(!base);
231 ccm_base = base;
130 232
131 /* Reuse imx6q pm code */ 233 /* Reuse imx6q pm code */
132 imx6q_pm_set_ccm_base(base); 234 imx6q_pm_set_ccm_base(base);
@@ -258,6 +360,19 @@ static void __init imx6sl_clocks_init(struct device_node *ccm_node)
258 clk_register_clkdev(clks[IMX6SL_CLK_GPT], "ipg", "imx-gpt.0"); 360 clk_register_clkdev(clks[IMX6SL_CLK_GPT], "ipg", "imx-gpt.0");
259 clk_register_clkdev(clks[IMX6SL_CLK_GPT_SERIAL], "per", "imx-gpt.0"); 361 clk_register_clkdev(clks[IMX6SL_CLK_GPT_SERIAL], "per", "imx-gpt.0");
260 362
363 /* Ensure the AHB clk is at 132MHz. */
364 ret = clk_set_rate(clks[IMX6SL_CLK_AHB], 132000000);
365 if (ret)
366 pr_warn("%s: failed to set AHB clock rate %d!\n",
367 __func__, ret);
368
369 /*
370 * Make sure those always on clocks are enabled to maintain the correct
371 * usecount and enabling/disabling of parent PLLs.
372 */
373 for (i = 0; i < ARRAY_SIZE(clks_init_on); i++)
374 clk_prepare_enable(clks[clks_init_on[i]]);
375
261 if (IS_ENABLED(CONFIG_USB_MXS_PHY)) { 376 if (IS_ENABLED(CONFIG_USB_MXS_PHY)) {
262 clk_prepare_enable(clks[IMX6SL_CLK_USBPHY1_GATE]); 377 clk_prepare_enable(clks[IMX6SL_CLK_USBPHY1_GATE]);
263 clk_prepare_enable(clks[IMX6SL_CLK_USBPHY2_GATE]); 378 clk_prepare_enable(clks[IMX6SL_CLK_USBPHY2_GATE]);
diff --git a/arch/arm/mach-imx/clk-vf610.c b/arch/arm/mach-imx/clk-vf610.c
index ecd66d8e20b6..22dc3ee21fd4 100644
--- a/arch/arm/mach-imx/clk-vf610.c
+++ b/arch/arm/mach-imx/clk-vf610.c
@@ -63,25 +63,25 @@ static void __iomem *anatop_base;
63static void __iomem *ccm_base; 63static void __iomem *ccm_base;
64 64
65/* sources for multiplexer clocks, this is used multiple times */ 65/* sources for multiplexer clocks, this is used multiple times */
66static const char const *fast_sels[] = { "firc", "fxosc", }; 66static const char *fast_sels[] = { "firc", "fxosc", };
67static const char const *slow_sels[] = { "sirc_32k", "sxosc", }; 67static const char *slow_sels[] = { "sirc_32k", "sxosc", };
68static const char const *pll1_sels[] = { "pll1_main", "pll1_pfd1", "pll1_pfd2", "pll1_pfd3", "pll1_pfd4", }; 68static const char *pll1_sels[] = { "pll1_main", "pll1_pfd1", "pll1_pfd2", "pll1_pfd3", "pll1_pfd4", };
69static const char const *pll2_sels[] = { "pll2_main", "pll2_pfd1", "pll2_pfd2", "pll2_pfd3", "pll2_pfd4", }; 69static const char *pll2_sels[] = { "pll2_main", "pll2_pfd1", "pll2_pfd2", "pll2_pfd3", "pll2_pfd4", };
70static const char const *sys_sels[] = { "fast_clk_sel", "slow_clk_sel", "pll2_pfd_sel", "pll2_main", "pll1_pfd_sel", "pll3_main", }; 70static const char *sys_sels[] = { "fast_clk_sel", "slow_clk_sel", "pll2_pfd_sel", "pll2_main", "pll1_pfd_sel", "pll3_main", };
71static const char const *ddr_sels[] = { "pll2_pfd2", "sys_sel", }; 71static const char *ddr_sels[] = { "pll2_pfd2", "sys_sel", };
72static const char const *rmii_sels[] = { "enet_ext", "audio_ext", "enet_50m", "enet_25m", }; 72static const char *rmii_sels[] = { "enet_ext", "audio_ext", "enet_50m", "enet_25m", };
73static const char const *enet_ts_sels[] = { "enet_ext", "fxosc", "audio_ext", "usb", "enet_ts", "enet_25m", "enet_50m", }; 73static const char *enet_ts_sels[] = { "enet_ext", "fxosc", "audio_ext", "usb", "enet_ts", "enet_25m", "enet_50m", };
74static const char const *esai_sels[] = { "audio_ext", "mlb", "spdif_rx", "pll4_main_div", }; 74static const char *esai_sels[] = { "audio_ext", "mlb", "spdif_rx", "pll4_main_div", };
75static const char const *sai_sels[] = { "audio_ext", "mlb", "spdif_rx", "pll4_main_div", }; 75static const char *sai_sels[] = { "audio_ext", "mlb", "spdif_rx", "pll4_main_div", };
76static const char const *nfc_sels[] = { "platform_bus", "pll1_pfd1", "pll3_pfd1", "pll3_pfd3", }; 76static const char *nfc_sels[] = { "platform_bus", "pll1_pfd1", "pll3_pfd1", "pll3_pfd3", };
77static const char const *qspi_sels[] = { "pll3_main", "pll3_pfd4", "pll2_pfd4", "pll1_pfd4", }; 77static const char *qspi_sels[] = { "pll3_main", "pll3_pfd4", "pll2_pfd4", "pll1_pfd4", };
78static const char const *esdhc_sels[] = { "pll3_main", "pll3_pfd3", "pll1_pfd3", "platform_bus", }; 78static const char *esdhc_sels[] = { "pll3_main", "pll3_pfd3", "pll1_pfd3", "platform_bus", };
79static const char const *dcu_sels[] = { "pll1_pfd2", "pll3_main", }; 79static const char *dcu_sels[] = { "pll1_pfd2", "pll3_main", };
80static const char const *gpu_sels[] = { "pll2_pfd2", "pll3_pfd2", }; 80static const char *gpu_sels[] = { "pll2_pfd2", "pll3_pfd2", };
81static const char const *vadc_sels[] = { "pll6_main_div", "pll3_main_div", "pll3_main", }; 81static const char *vadc_sels[] = { "pll6_main_div", "pll3_main_div", "pll3_main", };
82/* FTM counter clock source, not module clock */ 82/* FTM counter clock source, not module clock */
83static const char const *ftm_ext_sels[] = {"sirc_128k", "sxosc", "fxosc_half", "audio_ext", }; 83static const char *ftm_ext_sels[] = {"sirc_128k", "sxosc", "fxosc_half", "audio_ext", };
84static const char const *ftm_fix_sels[] = { "sxosc", "ipg_bus", }; 84static const char *ftm_fix_sels[] = { "sxosc", "ipg_bus", };
85 85
86static struct clk_div_table pll4_main_div_table[] = { 86static struct clk_div_table pll4_main_div_table[] = {
87 { .val = 0, .div = 1 }, 87 { .val = 0, .div = 1 },
diff --git a/arch/arm/mach-imx/common.h b/arch/arm/mach-imx/common.h
index 59c3b9b26bb4..b5241ea76706 100644
--- a/arch/arm/mach-imx/common.h
+++ b/arch/arm/mach-imx/common.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright 2004-2013 Freescale Semiconductor, Inc. All Rights Reserved. 2 * Copyright 2004-2014 Freescale Semiconductor, Inc. All Rights Reserved.
3 */ 3 */
4 4
5/* 5/*
@@ -116,7 +116,6 @@ void imx_enable_cpu(int cpu, bool enable);
116void imx_set_cpu_jump(int cpu, void *jump_addr); 116void imx_set_cpu_jump(int cpu, void *jump_addr);
117u32 imx_get_cpu_arg(int cpu); 117u32 imx_get_cpu_arg(int cpu);
118void imx_set_cpu_arg(int cpu, u32 arg); 118void imx_set_cpu_arg(int cpu, u32 arg);
119void v7_cpu_resume(void);
120#ifdef CONFIG_SMP 119#ifdef CONFIG_SMP
121void v7_secondary_startup(void); 120void v7_secondary_startup(void);
122void imx_scu_map_io(void); 121void imx_scu_map_io(void);
@@ -139,18 +138,28 @@ void imx_anatop_init(void);
139void imx_anatop_pre_suspend(void); 138void imx_anatop_pre_suspend(void);
140void imx_anatop_post_resume(void); 139void imx_anatop_post_resume(void);
141int imx6q_set_lpm(enum mxc_cpu_pwr_mode mode); 140int imx6q_set_lpm(enum mxc_cpu_pwr_mode mode);
142void imx6q_set_chicken_bit(void); 141void imx6q_set_int_mem_clk_lpm(void);
142void imx6sl_set_wait_clk(bool enter);
143 143
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 147#ifdef CONFIG_SUSPEND
148void v7_cpu_resume(void);
149void imx6_suspend(void __iomem *ocram_vbase);
150#else
151static inline void v7_cpu_resume(void) {}
152static inline void imx6_suspend(void __iomem *ocram_vbase) {}
153#endif
154
148void imx6q_pm_init(void); 155void imx6q_pm_init(void);
156void imx6dl_pm_init(void);
157void imx6sl_pm_init(void);
149void imx6q_pm_set_ccm_base(void __iomem *base); 158void imx6q_pm_set_ccm_base(void __iomem *base);
159
160#ifdef CONFIG_PM
150void imx5_pm_init(void); 161void imx5_pm_init(void);
151#else 162#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) {} 163static inline void imx5_pm_init(void) {}
155#endif 164#endif
156 165
diff --git a/arch/arm/mach-imx/cpuidle-imx6q.c b/arch/arm/mach-imx/cpuidle-imx6q.c
index 23ddfb693b2d..6bcae0479049 100644
--- a/arch/arm/mach-imx/cpuidle-imx6q.c
+++ b/arch/arm/mach-imx/cpuidle-imx6q.c
@@ -68,8 +68,8 @@ int __init imx6q_cpuidle_init(void)
68 /* Need to enable SCU standby for entering WAIT modes */ 68 /* Need to enable SCU standby for entering WAIT modes */
69 imx_scu_standby_enable(); 69 imx_scu_standby_enable();
70 70
71 /* Set chicken bit to get a reliable WAIT mode support */ 71 /* Set INT_MEM_CLK_LPM bit to get a reliable WAIT mode support */
72 imx6q_set_chicken_bit(); 72 imx6q_set_int_mem_clk_lpm();
73 73
74 return cpuidle_register(&imx6q_cpuidle_driver, NULL); 74 return cpuidle_register(&imx6q_cpuidle_driver, NULL);
75} 75}
diff --git a/arch/arm/mach-imx/cpuidle-imx6sl.c b/arch/arm/mach-imx/cpuidle-imx6sl.c
new file mode 100644
index 000000000000..d4b6b8171fa9
--- /dev/null
+++ b/arch/arm/mach-imx/cpuidle-imx6sl.c
@@ -0,0 +1,57 @@
1/*
2 * Copyright (C) 2014 Freescale Semiconductor, Inc.
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#include <linux/cpuidle.h>
10#include <linux/module.h>
11#include <asm/cpuidle.h>
12#include <asm/proc-fns.h>
13
14#include "common.h"
15#include "cpuidle.h"
16
17static int imx6sl_enter_wait(struct cpuidle_device *dev,
18 struct cpuidle_driver *drv, int index)
19{
20 imx6q_set_lpm(WAIT_UNCLOCKED);
21 /*
22 * Software workaround for ERR005311, see function
23 * description for details.
24 */
25 imx6sl_set_wait_clk(true);
26 cpu_do_idle();
27 imx6sl_set_wait_clk(false);
28 imx6q_set_lpm(WAIT_CLOCKED);
29
30 return index;
31}
32
33static struct cpuidle_driver imx6sl_cpuidle_driver = {
34 .name = "imx6sl_cpuidle",
35 .owner = THIS_MODULE,
36 .states = {
37 /* WFI */
38 ARM_CPUIDLE_WFI_STATE,
39 /* WAIT */
40 {
41 .exit_latency = 50,
42 .target_residency = 75,
43 .flags = CPUIDLE_FLAG_TIME_VALID |
44 CPUIDLE_FLAG_TIMER_STOP,
45 .enter = imx6sl_enter_wait,
46 .name = "WAIT",
47 .desc = "Clock off",
48 },
49 },
50 .state_count = 2,
51 .safe_state_index = 0,
52};
53
54int __init imx6sl_cpuidle_init(void)
55{
56 return cpuidle_register(&imx6sl_cpuidle_driver, NULL);
57}
diff --git a/arch/arm/mach-imx/cpuidle.h b/arch/arm/mach-imx/cpuidle.h
index 786f98ecc145..24e33670417c 100644
--- a/arch/arm/mach-imx/cpuidle.h
+++ b/arch/arm/mach-imx/cpuidle.h
@@ -13,6 +13,7 @@
13#ifdef CONFIG_CPU_IDLE 13#ifdef CONFIG_CPU_IDLE
14extern int imx5_cpuidle_init(void); 14extern int imx5_cpuidle_init(void);
15extern int imx6q_cpuidle_init(void); 15extern int imx6q_cpuidle_init(void);
16extern int imx6sl_cpuidle_init(void);
16#else 17#else
17static inline int imx5_cpuidle_init(void) 18static inline int imx5_cpuidle_init(void)
18{ 19{
@@ -22,4 +23,8 @@ static inline int imx6q_cpuidle_init(void)
22{ 23{
23 return 0; 24 return 0;
24} 25}
26static inline int imx6sl_cpuidle_init(void)
27{
28 return 0;
29}
25#endif 30#endif
diff --git a/arch/arm/mach-imx/devices-imx25.h b/arch/arm/mach-imx/devices-imx25.h
index 769563fdeaa0..61a114cddc39 100644
--- a/arch/arm/mach-imx/devices-imx25.h
+++ b/arch/arm/mach-imx/devices-imx25.h
@@ -83,7 +83,3 @@ extern const struct imx_spi_imx_data imx25_cspi_data[];
83#define imx25_add_spi_imx0(pdata) imx25_add_spi_imx(0, pdata) 83#define imx25_add_spi_imx0(pdata) imx25_add_spi_imx(0, pdata)
84#define imx25_add_spi_imx1(pdata) imx25_add_spi_imx(1, pdata) 84#define imx25_add_spi_imx1(pdata) imx25_add_spi_imx(1, pdata)
85#define imx25_add_spi_imx2(pdata) imx25_add_spi_imx(2, pdata) 85#define imx25_add_spi_imx2(pdata) imx25_add_spi_imx(2, pdata)
86
87extern struct imx_mxc_pwm_data imx25_mxc_pwm_data[];
88#define imx25_add_mxc_pwm(id) \
89 imx_add_mxc_pwm(&imx25_mxc_pwm_data[id])
diff --git a/arch/arm/mach-imx/devices-imx51.h b/arch/arm/mach-imx/devices-imx51.h
index deee5baee88c..26389f35a2b2 100644
--- a/arch/arm/mach-imx/devices-imx51.h
+++ b/arch/arm/mach-imx/devices-imx51.h
@@ -57,10 +57,6 @@ extern const struct imx_imx2_wdt_data imx51_imx2_wdt_data[];
57#define imx51_add_imx2_wdt(id) \ 57#define imx51_add_imx2_wdt(id) \
58 imx_add_imx2_wdt(&imx51_imx2_wdt_data[id]) 58 imx_add_imx2_wdt(&imx51_imx2_wdt_data[id])
59 59
60extern const struct imx_mxc_pwm_data imx51_mxc_pwm_data[];
61#define imx51_add_mxc_pwm(id) \
62 imx_add_mxc_pwm(&imx51_mxc_pwm_data[id])
63
64extern const struct imx_imx_keypad_data imx51_imx_keypad_data; 60extern const struct imx_imx_keypad_data imx51_imx_keypad_data;
65#define imx51_add_imx_keypad(pdata) \ 61#define imx51_add_imx_keypad(pdata) \
66 imx_add_imx_keypad(&imx51_imx_keypad_data, pdata) 62 imx_add_imx_keypad(&imx51_imx_keypad_data, pdata)
diff --git a/arch/arm/mach-imx/devices/Kconfig b/arch/arm/mach-imx/devices/Kconfig
index 68c74fb0373c..2d260a5a307c 100644
--- a/arch/arm/mach-imx/devices/Kconfig
+++ b/arch/arm/mach-imx/devices/Kconfig
@@ -67,9 +67,6 @@ config IMX_HAVE_PLATFORM_MXC_MMC
67config IMX_HAVE_PLATFORM_MXC_NAND 67config IMX_HAVE_PLATFORM_MXC_NAND
68 bool 68 bool
69 69
70config IMX_HAVE_PLATFORM_MXC_PWM
71 bool
72
73config IMX_HAVE_PLATFORM_MXC_RNGA 70config IMX_HAVE_PLATFORM_MXC_RNGA
74 bool 71 bool
75 select ARCH_HAS_RNGA 72 select ARCH_HAS_RNGA
diff --git a/arch/arm/mach-imx/devices/Makefile b/arch/arm/mach-imx/devices/Makefile
index 67416fb1dc69..1cbc14cd80d1 100644
--- a/arch/arm/mach-imx/devices/Makefile
+++ b/arch/arm/mach-imx/devices/Makefile
@@ -23,7 +23,6 @@ obj-$(CONFIG_IMX_HAVE_PLATFORM_MX2_CAMERA) += platform-mx2-camera.o
23obj-$(CONFIG_IMX_HAVE_PLATFORM_MXC_EHCI) += platform-mxc-ehci.o 23obj-$(CONFIG_IMX_HAVE_PLATFORM_MXC_EHCI) += platform-mxc-ehci.o
24obj-$(CONFIG_IMX_HAVE_PLATFORM_MXC_MMC) += platform-mxc-mmc.o 24obj-$(CONFIG_IMX_HAVE_PLATFORM_MXC_MMC) += platform-mxc-mmc.o
25obj-$(CONFIG_IMX_HAVE_PLATFORM_MXC_NAND) += platform-mxc_nand.o 25obj-$(CONFIG_IMX_HAVE_PLATFORM_MXC_NAND) += platform-mxc_nand.o
26obj-$(CONFIG_IMX_HAVE_PLATFORM_MXC_PWM) += platform-mxc_pwm.o
27obj-$(CONFIG_IMX_HAVE_PLATFORM_MXC_RNGA) += platform-mxc_rnga.o 26obj-$(CONFIG_IMX_HAVE_PLATFORM_MXC_RNGA) += platform-mxc_rnga.o
28obj-$(CONFIG_IMX_HAVE_PLATFORM_MXC_RTC) += platform-mxc_rtc.o 27obj-$(CONFIG_IMX_HAVE_PLATFORM_MXC_RTC) += platform-mxc_rtc.o
29obj-$(CONFIG_IMX_HAVE_PLATFORM_MXC_W1) += platform-mxc_w1.o 28obj-$(CONFIG_IMX_HAVE_PLATFORM_MXC_W1) += platform-mxc_w1.o
diff --git a/arch/arm/mach-imx/devices/devices-common.h b/arch/arm/mach-imx/devices/devices-common.h
index c13b76b9f6b3..61352a80bb59 100644
--- a/arch/arm/mach-imx/devices/devices-common.h
+++ b/arch/arm/mach-imx/devices/devices-common.h
@@ -290,15 +290,6 @@ struct imx_pata_imx_data {
290struct platform_device *__init imx_add_pata_imx( 290struct platform_device *__init imx_add_pata_imx(
291 const struct imx_pata_imx_data *data); 291 const struct imx_pata_imx_data *data);
292 292
293struct imx_mxc_pwm_data {
294 int id;
295 resource_size_t iobase;
296 resource_size_t iosize;
297 resource_size_t irq;
298};
299struct platform_device *__init imx_add_mxc_pwm(
300 const struct imx_mxc_pwm_data *data);
301
302/* mxc_rtc */ 293/* mxc_rtc */
303struct imx_mxc_rtc_data { 294struct imx_mxc_rtc_data {
304 const char *devid; 295 const char *devid;
diff --git a/arch/arm/mach-imx/devices/platform-mxc_pwm.c b/arch/arm/mach-imx/devices/platform-mxc_pwm.c
deleted file mode 100644
index dcd289777687..000000000000
--- a/arch/arm/mach-imx/devices/platform-mxc_pwm.c
+++ /dev/null
@@ -1,69 +0,0 @@
1/*
2 * Copyright (C) 2009-2010 Pengutronix
3 * Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de>
4 *
5 * This program is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU General Public License version 2 as published by the
7 * Free Software Foundation.
8 */
9#include "../hardware.h"
10#include "devices-common.h"
11
12#define imx_mxc_pwm_data_entry_single(soc, _id, _hwid, _size) \
13 { \
14 .id = _id, \
15 .iobase = soc ## _PWM ## _hwid ## _BASE_ADDR, \
16 .iosize = _size, \
17 .irq = soc ## _INT_PWM ## _hwid, \
18 }
19#define imx_mxc_pwm_data_entry(soc, _id, _hwid, _size) \
20 [_id] = imx_mxc_pwm_data_entry_single(soc, _id, _hwid, _size)
21
22#ifdef CONFIG_SOC_IMX21
23const struct imx_mxc_pwm_data imx21_mxc_pwm_data __initconst =
24 imx_mxc_pwm_data_entry_single(MX21, 0, , SZ_4K);
25#endif /* ifdef CONFIG_SOC_IMX21 */
26
27#ifdef CONFIG_SOC_IMX25
28const struct imx_mxc_pwm_data imx25_mxc_pwm_data[] __initconst = {
29#define imx25_mxc_pwm_data_entry(_id, _hwid) \
30 imx_mxc_pwm_data_entry(MX25, _id, _hwid, SZ_16K)
31 imx25_mxc_pwm_data_entry(0, 1),
32 imx25_mxc_pwm_data_entry(1, 2),
33 imx25_mxc_pwm_data_entry(2, 3),
34 imx25_mxc_pwm_data_entry(3, 4),
35};
36#endif /* ifdef CONFIG_SOC_IMX25 */
37
38#ifdef CONFIG_SOC_IMX27
39const struct imx_mxc_pwm_data imx27_mxc_pwm_data __initconst =
40 imx_mxc_pwm_data_entry_single(MX27, 0, , SZ_4K);
41#endif /* ifdef CONFIG_SOC_IMX27 */
42
43#ifdef CONFIG_SOC_IMX51
44const struct imx_mxc_pwm_data imx51_mxc_pwm_data[] __initconst = {
45#define imx51_mxc_pwm_data_entry(_id, _hwid) \
46 imx_mxc_pwm_data_entry(MX51, _id, _hwid, SZ_16K)
47 imx51_mxc_pwm_data_entry(0, 1),
48 imx51_mxc_pwm_data_entry(1, 2),
49};
50#endif /* ifdef CONFIG_SOC_IMX51 */
51
52struct platform_device *__init imx_add_mxc_pwm(
53 const struct imx_mxc_pwm_data *data)
54{
55 struct resource res[] = {
56 {
57 .start = data->iobase,
58 .end = data->iobase + data->iosize - 1,
59 .flags = IORESOURCE_MEM,
60 }, {
61 .start = data->irq,
62 .end = data->irq,
63 .flags = IORESOURCE_IRQ,
64 },
65 };
66
67 return imx_add_platform_device("mxc_pwm", data->id,
68 res, ARRAY_SIZE(res), NULL, 0);
69}
diff --git a/arch/arm/mach-imx/hardware.h b/arch/arm/mach-imx/hardware.h
index a3b0b04b45c9..abf43bb47eca 100644
--- a/arch/arm/mach-imx/hardware.h
+++ b/arch/arm/mach-imx/hardware.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved. 2 * Copyright 2004-2007, 2014 Freescale Semiconductor, Inc. All Rights Reserved.
3 * Copyright 2008 Juergen Beisert, kernel@pengutronix.de 3 * Copyright 2008 Juergen Beisert, kernel@pengutronix.de
4 * 4 *
5 * This program is free software; you can redistribute it and/or 5 * This program is free software; you can redistribute it and/or
@@ -20,7 +20,9 @@
20#ifndef __ASM_ARCH_MXC_HARDWARE_H__ 20#ifndef __ASM_ARCH_MXC_HARDWARE_H__
21#define __ASM_ARCH_MXC_HARDWARE_H__ 21#define __ASM_ARCH_MXC_HARDWARE_H__
22 22
23#ifndef __ASSEMBLY__
23#include <asm/io.h> 24#include <asm/io.h>
25#endif
24#include <asm/sizes.h> 26#include <asm/sizes.h>
25 27
26#define addr_in_module(addr, mod) \ 28#define addr_in_module(addr, mod) \
diff --git a/arch/arm/mach-imx/headsmp.S b/arch/arm/mach-imx/headsmp.S
index 627f16f0e9d1..de5047c8a6c8 100644
--- a/arch/arm/mach-imx/headsmp.S
+++ b/arch/arm/mach-imx/headsmp.S
@@ -12,12 +12,7 @@
12 12
13#include <linux/linkage.h> 13#include <linux/linkage.h>
14#include <linux/init.h> 14#include <linux/init.h>
15#include <asm/asm-offsets.h>
16#include <asm/hardware/cache-l2x0.h>
17 15
18 .section ".text.head", "ax"
19
20#ifdef CONFIG_SMP
21diag_reg_offset: 16diag_reg_offset:
22 .word g_diag_reg - . 17 .word g_diag_reg - .
23 18
@@ -34,38 +29,3 @@ ENTRY(v7_secondary_startup)
34 set_diag_reg 29 set_diag_reg
35 b secondary_startup 30 b secondary_startup
36ENDPROC(v7_secondary_startup) 31ENDPROC(v7_secondary_startup)
37#endif
38
39#ifdef CONFIG_ARM_CPU_SUSPEND
40/*
41 * The following code must assume it is running from physical address
42 * where absolute virtual addresses to the data section have to be
43 * turned into relative ones.
44 */
45
46#ifdef CONFIG_CACHE_L2X0
47 .macro pl310_resume
48 adr r0, l2x0_saved_regs_offset
49 ldr r2, [r0]
50 add r2, r2, r0
51 ldr r0, [r2, #L2X0_R_PHY_BASE] @ get physical base of l2x0
52 ldr r1, [r2, #L2X0_R_AUX_CTRL] @ get aux_ctrl value
53 str r1, [r0, #L2X0_AUX_CTRL] @ restore aux_ctrl
54 mov r1, #0x1
55 str r1, [r0, #L2X0_CTRL] @ re-enable L2
56 .endm
57
58l2x0_saved_regs_offset:
59 .word l2x0_saved_regs - .
60
61#else
62 .macro pl310_resume
63 .endm
64#endif
65
66ENTRY(v7_cpu_resume)
67 bl v7_invalidate_l1
68 pl310_resume
69 b cpu_resume
70ENDPROC(v7_cpu_resume)
71#endif
diff --git a/arch/arm/mach-imx/mach-imx6q.c b/arch/arm/mach-imx/mach-imx6q.c
index 76e5db4fce35..e60456d85c9d 100644
--- a/arch/arm/mach-imx/mach-imx6q.c
+++ b/arch/arm/mach-imx/mach-imx6q.c
@@ -182,16 +182,83 @@ static void __init imx6q_enet_phy_init(void)
182 182
183static void __init imx6q_1588_init(void) 183static void __init imx6q_1588_init(void)
184{ 184{
185 struct device_node *np;
186 struct clk *ptp_clk;
187 struct clk *enet_ref;
185 struct regmap *gpr; 188 struct regmap *gpr;
189 u32 clksel;
186 190
191 np = of_find_compatible_node(NULL, NULL, "fsl,imx6q-fec");
192 if (!np) {
193 pr_warn("%s: failed to find fec node\n", __func__);
194 return;
195 }
196
197 ptp_clk = of_clk_get(np, 2);
198 if (IS_ERR(ptp_clk)) {
199 pr_warn("%s: failed to get ptp clock\n", __func__);
200 goto put_node;
201 }
202
203 enet_ref = clk_get_sys(NULL, "enet_ref");
204 if (IS_ERR(enet_ref)) {
205 pr_warn("%s: failed to get enet clock\n", __func__);
206 goto put_ptp_clk;
207 }
208
209 /*
210 * If enet_ref from ANATOP/CCM is the PTP clock source, we need to
211 * set bit IOMUXC_GPR1[21]. Or the PTP clock must be from pad
212 * (external OSC), and we need to clear the bit.
213 */
214 clksel = ptp_clk == enet_ref ? IMX6Q_GPR1_ENET_CLK_SEL_ANATOP :
215 IMX6Q_GPR1_ENET_CLK_SEL_PAD;
187 gpr = syscon_regmap_lookup_by_compatible("fsl,imx6q-iomuxc-gpr"); 216 gpr = syscon_regmap_lookup_by_compatible("fsl,imx6q-iomuxc-gpr");
188 if (!IS_ERR(gpr)) 217 if (!IS_ERR(gpr))
189 regmap_update_bits(gpr, IOMUXC_GPR1, 218 regmap_update_bits(gpr, IOMUXC_GPR1,
190 IMX6Q_GPR1_ENET_CLK_SEL_MASK, 219 IMX6Q_GPR1_ENET_CLK_SEL_MASK,
191 IMX6Q_GPR1_ENET_CLK_SEL_ANATOP); 220 clksel);
192 else 221 else
193 pr_err("failed to find fsl,imx6q-iomux-gpr regmap\n"); 222 pr_err("failed to find fsl,imx6q-iomux-gpr regmap\n");
194 223
224 clk_put(enet_ref);
225put_ptp_clk:
226 clk_put(ptp_clk);
227put_node:
228 of_node_put(np);
229}
230
231static void __init imx6q_axi_init(void)
232{
233 struct regmap *gpr;
234 unsigned int mask;
235
236 gpr = syscon_regmap_lookup_by_compatible("fsl,imx6q-iomuxc-gpr");
237 if (!IS_ERR(gpr)) {
238 /*
239 * Enable the cacheable attribute of VPU and IPU
240 * AXI transactions.
241 */
242 mask = IMX6Q_GPR4_VPU_WR_CACHE_SEL |
243 IMX6Q_GPR4_VPU_RD_CACHE_SEL |
244 IMX6Q_GPR4_VPU_P_WR_CACHE_VAL |
245 IMX6Q_GPR4_VPU_P_RD_CACHE_VAL_MASK |
246 IMX6Q_GPR4_IPU_WR_CACHE_CTL |
247 IMX6Q_GPR4_IPU_RD_CACHE_CTL;
248 regmap_update_bits(gpr, IOMUXC_GPR4, mask, mask);
249
250 /* Increase IPU read QoS priority */
251 regmap_update_bits(gpr, IOMUXC_GPR6,
252 IMX6Q_GPR6_IPU1_ID00_RD_QOS_MASK |
253 IMX6Q_GPR6_IPU1_ID01_RD_QOS_MASK,
254 (0xf << 16) | (0x7 << 20));
255 regmap_update_bits(gpr, IOMUXC_GPR7,
256 IMX6Q_GPR7_IPU2_ID00_RD_QOS_MASK |
257 IMX6Q_GPR7_IPU2_ID01_RD_QOS_MASK,
258 (0xf << 16) | (0x7 << 20));
259 } else {
260 pr_warn("failed to find fsl,imx6q-iomuxc-gpr regmap\n");
261 }
195} 262}
196 263
197static void __init imx6q_init_machine(void) 264static void __init imx6q_init_machine(void)
@@ -212,15 +279,18 @@ static void __init imx6q_init_machine(void)
212 of_platform_populate(NULL, of_default_bus_match_table, NULL, parent); 279 of_platform_populate(NULL, of_default_bus_match_table, NULL, parent);
213 280
214 imx_anatop_init(); 281 imx_anatop_init();
215 imx6q_pm_init(); 282 cpu_is_imx6q() ? imx6q_pm_init() : imx6dl_pm_init();
216 imx6q_1588_init(); 283 imx6q_1588_init();
284 imx6q_axi_init();
217} 285}
218 286
219#define OCOTP_CFG3 0x440 287#define OCOTP_CFG3 0x440
220#define OCOTP_CFG3_SPEED_SHIFT 16 288#define OCOTP_CFG3_SPEED_SHIFT 16
221#define OCOTP_CFG3_SPEED_1P2GHZ 0x3 289#define OCOTP_CFG3_SPEED_1P2GHZ 0x3
290#define OCOTP_CFG3_SPEED_996MHZ 0x2
291#define OCOTP_CFG3_SPEED_852MHZ 0x1
222 292
223static void __init imx6q_opp_check_1p2ghz(struct device *cpu_dev) 293static void __init imx6q_opp_check_speed_grading(struct device *cpu_dev)
224{ 294{
225 struct device_node *np; 295 struct device_node *np;
226 void __iomem *base; 296 void __iomem *base;
@@ -238,11 +308,29 @@ static void __init imx6q_opp_check_1p2ghz(struct device *cpu_dev)
238 goto put_node; 308 goto put_node;
239 } 309 }
240 310
311 /*
312 * SPEED_GRADING[1:0] defines the max speed of ARM:
313 * 2b'11: 1200000000Hz;
314 * 2b'10: 996000000Hz;
315 * 2b'01: 852000000Hz; -- i.MX6Q Only, exclusive with 996MHz.
316 * 2b'00: 792000000Hz;
317 * We need to set the max speed of ARM according to fuse map.
318 */
241 val = readl_relaxed(base + OCOTP_CFG3); 319 val = readl_relaxed(base + OCOTP_CFG3);
242 val >>= OCOTP_CFG3_SPEED_SHIFT; 320 val >>= OCOTP_CFG3_SPEED_SHIFT;
243 if ((val & 0x3) != OCOTP_CFG3_SPEED_1P2GHZ) 321 val &= 0x3;
322
323 if (val != OCOTP_CFG3_SPEED_1P2GHZ)
244 if (dev_pm_opp_disable(cpu_dev, 1200000000)) 324 if (dev_pm_opp_disable(cpu_dev, 1200000000))
245 pr_warn("failed to disable 1.2 GHz OPP\n"); 325 pr_warn("failed to disable 1.2 GHz OPP\n");
326 if (val < OCOTP_CFG3_SPEED_996MHZ)
327 if (dev_pm_opp_disable(cpu_dev, 996000000))
328 pr_warn("failed to disable 996 MHz OPP\n");
329 if (cpu_is_imx6q()) {
330 if (val != OCOTP_CFG3_SPEED_852MHZ)
331 if (dev_pm_opp_disable(cpu_dev, 852000000))
332 pr_warn("failed to disable 852 MHz OPP\n");
333 }
246 334
247put_node: 335put_node:
248 of_node_put(np); 336 of_node_put(np);
@@ -268,7 +356,7 @@ static void __init imx6q_opp_init(void)
268 goto put_node; 356 goto put_node;
269 } 357 }
270 358
271 imx6q_opp_check_1p2ghz(cpu_dev); 359 imx6q_opp_check_speed_grading(cpu_dev);
272 360
273put_node: 361put_node:
274 of_node_put(np); 362 of_node_put(np);
diff --git a/arch/arm/mach-imx/mach-imx6sl.c b/arch/arm/mach-imx/mach-imx6sl.c
index 0f4fd4c0ab8e..ad323385115c 100644
--- a/arch/arm/mach-imx/mach-imx6sl.c
+++ b/arch/arm/mach-imx/mach-imx6sl.c
@@ -17,6 +17,7 @@
17#include <asm/mach/map.h> 17#include <asm/mach/map.h>
18 18
19#include "common.h" 19#include "common.h"
20#include "cpuidle.h"
20 21
21static void __init imx6sl_fec_init(void) 22static void __init imx6sl_fec_init(void)
22{ 23{
@@ -39,6 +40,8 @@ static void __init imx6sl_init_late(void)
39 /* imx6sl reuses imx6q cpufreq driver */ 40 /* imx6sl reuses imx6q cpufreq driver */
40 if (IS_ENABLED(CONFIG_ARM_IMX6Q_CPUFREQ)) 41 if (IS_ENABLED(CONFIG_ARM_IMX6Q_CPUFREQ))
41 platform_device_register_simple("imx6q-cpufreq", -1, NULL, 0); 42 platform_device_register_simple("imx6q-cpufreq", -1, NULL, 0);
43
44 imx6sl_cpuidle_init();
42} 45}
43 46
44static void __init imx6sl_init_machine(void) 47static void __init imx6sl_init_machine(void)
@@ -55,8 +58,7 @@ static void __init imx6sl_init_machine(void)
55 58
56 imx6sl_fec_init(); 59 imx6sl_fec_init();
57 imx_anatop_init(); 60 imx_anatop_init();
58 /* Reuse imx6q pm code */ 61 imx6sl_pm_init();
59 imx6q_pm_init();
60} 62}
61 63
62static void __init imx6sl_init_irq(void) 64static void __init imx6sl_init_irq(void)
diff --git a/arch/arm/mach-imx/pm-imx6.c b/arch/arm/mach-imx/pm-imx6.c
new file mode 100644
index 000000000000..16f0d249f6a7
--- /dev/null
+++ b/arch/arm/mach-imx/pm-imx6.c
@@ -0,0 +1,552 @@
1/*
2 * Copyright 2011-2014 Freescale Semiconductor, Inc.
3 * Copyright 2011 Linaro Ltd.
4 *
5 * The code contained herein is licensed under the GNU General Public
6 * License. You may obtain a copy of the GNU General Public License
7 * Version 2 or later at the following locations:
8 *
9 * http://www.opensource.org/licenses/gpl-license.html
10 * http://www.gnu.org/copyleft/gpl.html
11 */
12
13#include <linux/delay.h>
14#include <linux/init.h>
15#include <linux/io.h>
16#include <linux/irq.h>
17#include <linux/genalloc.h>
18#include <linux/mfd/syscon.h>
19#include <linux/mfd/syscon/imx6q-iomuxc-gpr.h>
20#include <linux/of.h>
21#include <linux/of_address.h>
22#include <linux/of_platform.h>
23#include <linux/regmap.h>
24#include <linux/suspend.h>
25#include <asm/cacheflush.h>
26#include <asm/fncpy.h>
27#include <asm/proc-fns.h>
28#include <asm/suspend.h>
29#include <asm/tlb.h>
30
31#include "common.h"
32#include "hardware.h"
33
34#define CCR 0x0
35#define BM_CCR_WB_COUNT (0x7 << 16)
36#define BM_CCR_RBC_BYPASS_COUNT (0x3f << 21)
37#define BM_CCR_RBC_EN (0x1 << 27)
38
39#define CLPCR 0x54
40#define BP_CLPCR_LPM 0
41#define BM_CLPCR_LPM (0x3 << 0)
42#define BM_CLPCR_BYPASS_PMIC_READY (0x1 << 2)
43#define BM_CLPCR_ARM_CLK_DIS_ON_LPM (0x1 << 5)
44#define BM_CLPCR_SBYOS (0x1 << 6)
45#define BM_CLPCR_DIS_REF_OSC (0x1 << 7)
46#define BM_CLPCR_VSTBY (0x1 << 8)
47#define BP_CLPCR_STBY_COUNT 9
48#define BM_CLPCR_STBY_COUNT (0x3 << 9)
49#define BM_CLPCR_COSC_PWRDOWN (0x1 << 11)
50#define BM_CLPCR_WB_PER_AT_LPM (0x1 << 16)
51#define BM_CLPCR_WB_CORE_AT_LPM (0x1 << 17)
52#define BM_CLPCR_BYP_MMDC_CH0_LPM_HS (0x1 << 19)
53#define BM_CLPCR_BYP_MMDC_CH1_LPM_HS (0x1 << 21)
54#define BM_CLPCR_MASK_CORE0_WFI (0x1 << 22)
55#define BM_CLPCR_MASK_CORE1_WFI (0x1 << 23)
56#define BM_CLPCR_MASK_CORE2_WFI (0x1 << 24)
57#define BM_CLPCR_MASK_CORE3_WFI (0x1 << 25)
58#define BM_CLPCR_MASK_SCU_IDLE (0x1 << 26)
59#define BM_CLPCR_MASK_L2CC_IDLE (0x1 << 27)
60
61#define CGPR 0x64
62#define BM_CGPR_INT_MEM_CLK_LPM (0x1 << 17)
63
64#define MX6Q_SUSPEND_OCRAM_SIZE 0x1000
65#define MX6_MAX_MMDC_IO_NUM 33
66
67static void __iomem *ccm_base;
68static void __iomem *suspend_ocram_base;
69static void (*imx6_suspend_in_ocram_fn)(void __iomem *ocram_vbase);
70
71/*
72 * suspend ocram space layout:
73 * ======================== high address ======================
74 * .
75 * .
76 * .
77 * ^
78 * ^
79 * ^
80 * imx6_suspend code
81 * PM_INFO structure(imx6_cpu_pm_info)
82 * ======================== low address =======================
83 */
84
85struct imx6_pm_base {
86 phys_addr_t pbase;
87 void __iomem *vbase;
88};
89
90struct imx6_pm_socdata {
91 u32 cpu_type;
92 const char *mmdc_compat;
93 const char *src_compat;
94 const char *iomuxc_compat;
95 const char *gpc_compat;
96 const u32 mmdc_io_num;
97 const u32 *mmdc_io_offset;
98};
99
100static const u32 imx6q_mmdc_io_offset[] __initconst = {
101 0x5ac, 0x5b4, 0x528, 0x520, /* DQM0 ~ DQM3 */
102 0x514, 0x510, 0x5bc, 0x5c4, /* DQM4 ~ DQM7 */
103 0x56c, 0x578, 0x588, 0x594, /* CAS, RAS, SDCLK_0, SDCLK_1 */
104 0x5a8, 0x5b0, 0x524, 0x51c, /* SDQS0 ~ SDQS3 */
105 0x518, 0x50c, 0x5b8, 0x5c0, /* SDQS4 ~ SDQS7 */
106 0x784, 0x788, 0x794, 0x79c, /* GPR_B0DS ~ GPR_B3DS */
107 0x7a0, 0x7a4, 0x7a8, 0x748, /* GPR_B4DS ~ GPR_B7DS */
108 0x59c, 0x5a0, 0x750, 0x774, /* SODT0, SODT1, MODE_CTL, MODE */
109 0x74c, /* GPR_ADDS */
110};
111
112static const u32 imx6dl_mmdc_io_offset[] __initconst = {
113 0x470, 0x474, 0x478, 0x47c, /* DQM0 ~ DQM3 */
114 0x480, 0x484, 0x488, 0x48c, /* DQM4 ~ DQM7 */
115 0x464, 0x490, 0x4ac, 0x4b0, /* CAS, RAS, SDCLK_0, SDCLK_1 */
116 0x4bc, 0x4c0, 0x4c4, 0x4c8, /* DRAM_SDQS0 ~ DRAM_SDQS3 */
117 0x4cc, 0x4d0, 0x4d4, 0x4d8, /* DRAM_SDQS4 ~ DRAM_SDQS7 */
118 0x764, 0x770, 0x778, 0x77c, /* GPR_B0DS ~ GPR_B3DS */
119 0x780, 0x784, 0x78c, 0x748, /* GPR_B4DS ~ GPR_B7DS */
120 0x4b4, 0x4b8, 0x750, 0x760, /* SODT0, SODT1, MODE_CTL, MODE */
121 0x74c, /* GPR_ADDS */
122};
123
124static const u32 imx6sl_mmdc_io_offset[] __initconst = {
125 0x30c, 0x310, 0x314, 0x318, /* DQM0 ~ DQM3 */
126 0x5c4, 0x5cc, 0x5d4, 0x5d8, /* GPR_B0DS ~ GPR_B3DS */
127 0x300, 0x31c, 0x338, 0x5ac, /* CAS, RAS, SDCLK_0, GPR_ADDS */
128 0x33c, 0x340, 0x5b0, 0x5c0, /* SODT0, SODT1, MODE_CTL, MODE */
129 0x330, 0x334, 0x320, /* SDCKE0, SDCKE1, RESET */
130};
131
132static const struct imx6_pm_socdata imx6q_pm_data __initconst = {
133 .cpu_type = MXC_CPU_IMX6Q,
134 .mmdc_compat = "fsl,imx6q-mmdc",
135 .src_compat = "fsl,imx6q-src",
136 .iomuxc_compat = "fsl,imx6q-iomuxc",
137 .gpc_compat = "fsl,imx6q-gpc",
138 .mmdc_io_num = ARRAY_SIZE(imx6q_mmdc_io_offset),
139 .mmdc_io_offset = imx6q_mmdc_io_offset,
140};
141
142static const struct imx6_pm_socdata imx6dl_pm_data __initconst = {
143 .cpu_type = MXC_CPU_IMX6DL,
144 .mmdc_compat = "fsl,imx6q-mmdc",
145 .src_compat = "fsl,imx6q-src",
146 .iomuxc_compat = "fsl,imx6dl-iomuxc",
147 .gpc_compat = "fsl,imx6q-gpc",
148 .mmdc_io_num = ARRAY_SIZE(imx6dl_mmdc_io_offset),
149 .mmdc_io_offset = imx6dl_mmdc_io_offset,
150};
151
152static const struct imx6_pm_socdata imx6sl_pm_data __initconst = {
153 .cpu_type = MXC_CPU_IMX6SL,
154 .mmdc_compat = "fsl,imx6sl-mmdc",
155 .src_compat = "fsl,imx6sl-src",
156 .iomuxc_compat = "fsl,imx6sl-iomuxc",
157 .gpc_compat = "fsl,imx6sl-gpc",
158 .mmdc_io_num = ARRAY_SIZE(imx6sl_mmdc_io_offset),
159 .mmdc_io_offset = imx6sl_mmdc_io_offset,
160};
161
162/*
163 * This structure is for passing necessary data for low level ocram
164 * suspend code(arch/arm/mach-imx/suspend-imx6.S), if this struct
165 * definition is changed, the offset definition in
166 * arch/arm/mach-imx/suspend-imx6.S must be also changed accordingly,
167 * otherwise, the suspend to ocram function will be broken!
168 */
169struct imx6_cpu_pm_info {
170 phys_addr_t pbase; /* The physical address of pm_info. */
171 phys_addr_t resume_addr; /* The physical resume address for asm code */
172 u32 cpu_type;
173 u32 pm_info_size; /* Size of pm_info. */
174 struct imx6_pm_base mmdc_base;
175 struct imx6_pm_base src_base;
176 struct imx6_pm_base iomuxc_base;
177 struct imx6_pm_base ccm_base;
178 struct imx6_pm_base gpc_base;
179 struct imx6_pm_base l2_base;
180 u32 mmdc_io_num; /* Number of MMDC IOs which need saved/restored. */
181 u32 mmdc_io_val[MX6_MAX_MMDC_IO_NUM][2]; /* To save offset and value */
182} __aligned(8);
183
184void imx6q_set_int_mem_clk_lpm(void)
185{
186 u32 val = readl_relaxed(ccm_base + CGPR);
187
188 val |= BM_CGPR_INT_MEM_CLK_LPM;
189 writel_relaxed(val, ccm_base + CGPR);
190}
191
192static void imx6q_enable_rbc(bool enable)
193{
194 u32 val;
195
196 /*
197 * need to mask all interrupts in GPC before
198 * operating RBC configurations
199 */
200 imx_gpc_mask_all();
201
202 /* configure RBC enable bit */
203 val = readl_relaxed(ccm_base + CCR);
204 val &= ~BM_CCR_RBC_EN;
205 val |= enable ? BM_CCR_RBC_EN : 0;
206 writel_relaxed(val, ccm_base + CCR);
207
208 /* configure RBC count */
209 val = readl_relaxed(ccm_base + CCR);
210 val &= ~BM_CCR_RBC_BYPASS_COUNT;
211 val |= enable ? BM_CCR_RBC_BYPASS_COUNT : 0;
212 writel(val, ccm_base + CCR);
213
214 /*
215 * need to delay at least 2 cycles of CKIL(32K)
216 * due to hardware design requirement, which is
217 * ~61us, here we use 65us for safe
218 */
219 udelay(65);
220
221 /* restore GPC interrupt mask settings */
222 imx_gpc_restore_all();
223}
224
225static void imx6q_enable_wb(bool enable)
226{
227 u32 val;
228
229 /* configure well bias enable bit */
230 val = readl_relaxed(ccm_base + CLPCR);
231 val &= ~BM_CLPCR_WB_PER_AT_LPM;
232 val |= enable ? BM_CLPCR_WB_PER_AT_LPM : 0;
233 writel_relaxed(val, ccm_base + CLPCR);
234
235 /* configure well bias count */
236 val = readl_relaxed(ccm_base + CCR);
237 val &= ~BM_CCR_WB_COUNT;
238 val |= enable ? BM_CCR_WB_COUNT : 0;
239 writel_relaxed(val, ccm_base + CCR);
240}
241
242int imx6q_set_lpm(enum mxc_cpu_pwr_mode mode)
243{
244 struct irq_desc *iomuxc_irq_desc;
245 u32 val = readl_relaxed(ccm_base + CLPCR);
246
247 val &= ~BM_CLPCR_LPM;
248 switch (mode) {
249 case WAIT_CLOCKED:
250 break;
251 case WAIT_UNCLOCKED:
252 val |= 0x1 << BP_CLPCR_LPM;
253 val |= BM_CLPCR_ARM_CLK_DIS_ON_LPM;
254 break;
255 case STOP_POWER_ON:
256 val |= 0x2 << BP_CLPCR_LPM;
257 break;
258 case WAIT_UNCLOCKED_POWER_OFF:
259 val |= 0x1 << BP_CLPCR_LPM;
260 val &= ~BM_CLPCR_VSTBY;
261 val &= ~BM_CLPCR_SBYOS;
262 break;
263 case STOP_POWER_OFF:
264 val |= 0x2 << BP_CLPCR_LPM;
265 val |= 0x3 << BP_CLPCR_STBY_COUNT;
266 val |= BM_CLPCR_VSTBY;
267 val |= BM_CLPCR_SBYOS;
268 if (cpu_is_imx6sl()) {
269 val |= BM_CLPCR_BYPASS_PMIC_READY;
270 val |= BM_CLPCR_BYP_MMDC_CH0_LPM_HS;
271 } else {
272 val |= BM_CLPCR_BYP_MMDC_CH1_LPM_HS;
273 }
274 break;
275 default:
276 return -EINVAL;
277 }
278
279 /*
280 * ERR007265: CCM: When improper low-power sequence is used,
281 * the SoC enters low power mode before the ARM core executes WFI.
282 *
283 * Software workaround:
284 * 1) Software should trigger IRQ #32 (IOMUX) to be always pending
285 * by setting IOMUX_GPR1_GINT.
286 * 2) Software should then unmask IRQ #32 in GPC before setting CCM
287 * Low-Power mode.
288 * 3) Software should mask IRQ #32 right after CCM Low-Power mode
289 * is set (set bits 0-1 of CCM_CLPCR).
290 */
291 iomuxc_irq_desc = irq_to_desc(32);
292 imx_gpc_irq_unmask(&iomuxc_irq_desc->irq_data);
293 writel_relaxed(val, ccm_base + CLPCR);
294 imx_gpc_irq_mask(&iomuxc_irq_desc->irq_data);
295
296 return 0;
297}
298
299static int imx6q_suspend_finish(unsigned long val)
300{
301 if (!imx6_suspend_in_ocram_fn) {
302 cpu_do_idle();
303 } else {
304 /*
305 * call low level suspend function in ocram,
306 * as we need to float DDR IO.
307 */
308 local_flush_tlb_all();
309 imx6_suspend_in_ocram_fn(suspend_ocram_base);
310 }
311
312 return 0;
313}
314
315static int imx6q_pm_enter(suspend_state_t state)
316{
317 switch (state) {
318 case PM_SUSPEND_MEM:
319 imx6q_set_lpm(STOP_POWER_OFF);
320 imx6q_enable_wb(true);
321 /*
322 * For suspend into ocram, asm code already take care of
323 * RBC setting, so we do NOT need to do that here.
324 */
325 if (!imx6_suspend_in_ocram_fn)
326 imx6q_enable_rbc(true);
327 imx_gpc_pre_suspend();
328 imx_anatop_pre_suspend();
329 imx_set_cpu_jump(0, v7_cpu_resume);
330 /* Zzz ... */
331 cpu_suspend(0, imx6q_suspend_finish);
332 if (cpu_is_imx6q() || cpu_is_imx6dl())
333 imx_smp_prepare();
334 imx_anatop_post_resume();
335 imx_gpc_post_resume();
336 imx6q_enable_rbc(false);
337 imx6q_enable_wb(false);
338 imx6q_set_lpm(WAIT_CLOCKED);
339 break;
340 default:
341 return -EINVAL;
342 }
343
344 return 0;
345}
346
347static const struct platform_suspend_ops imx6q_pm_ops = {
348 .enter = imx6q_pm_enter,
349 .valid = suspend_valid_only_mem,
350};
351
352void __init imx6q_pm_set_ccm_base(void __iomem *base)
353{
354 ccm_base = base;
355}
356
357static int __init imx6_pm_get_base(struct imx6_pm_base *base,
358 const char *compat)
359{
360 struct device_node *node;
361 struct resource res;
362 int ret = 0;
363
364 node = of_find_compatible_node(NULL, NULL, compat);
365 if (!node) {
366 ret = -ENODEV;
367 goto out;
368 }
369
370 ret = of_address_to_resource(node, 0, &res);
371 if (ret)
372 goto put_node;
373
374 base->pbase = res.start;
375 base->vbase = ioremap(res.start, resource_size(&res));
376 if (!base->vbase)
377 ret = -ENOMEM;
378
379put_node:
380 of_node_put(node);
381out:
382 return ret;
383}
384
385static int __init imx6q_suspend_init(const struct imx6_pm_socdata *socdata)
386{
387 phys_addr_t ocram_pbase;
388 struct device_node *node;
389 struct platform_device *pdev;
390 struct imx6_cpu_pm_info *pm_info;
391 struct gen_pool *ocram_pool;
392 unsigned long ocram_base;
393 int i, ret = 0;
394 const u32 *mmdc_offset_array;
395
396 suspend_set_ops(&imx6q_pm_ops);
397
398 if (!socdata) {
399 pr_warn("%s: invalid argument!\n", __func__);
400 return -EINVAL;
401 }
402
403 node = of_find_compatible_node(NULL, NULL, "mmio-sram");
404 if (!node) {
405 pr_warn("%s: failed to find ocram node!\n", __func__);
406 return -ENODEV;
407 }
408
409 pdev = of_find_device_by_node(node);
410 if (!pdev) {
411 pr_warn("%s: failed to find ocram device!\n", __func__);
412 ret = -ENODEV;
413 goto put_node;
414 }
415
416 ocram_pool = dev_get_gen_pool(&pdev->dev);
417 if (!ocram_pool) {
418 pr_warn("%s: ocram pool unavailable!\n", __func__);
419 ret = -ENODEV;
420 goto put_node;
421 }
422
423 ocram_base = gen_pool_alloc(ocram_pool, MX6Q_SUSPEND_OCRAM_SIZE);
424 if (!ocram_base) {
425 pr_warn("%s: unable to alloc ocram!\n", __func__);
426 ret = -ENOMEM;
427 goto put_node;
428 }
429
430 ocram_pbase = gen_pool_virt_to_phys(ocram_pool, ocram_base);
431
432 suspend_ocram_base = __arm_ioremap_exec(ocram_pbase,
433 MX6Q_SUSPEND_OCRAM_SIZE, false);
434
435 pm_info = suspend_ocram_base;
436 pm_info->pbase = ocram_pbase;
437 pm_info->resume_addr = virt_to_phys(v7_cpu_resume);
438 pm_info->pm_info_size = sizeof(*pm_info);
439
440 /*
441 * ccm physical address is not used by asm code currently,
442 * so get ccm virtual address directly, as we already have
443 * it from ccm driver.
444 */
445 pm_info->ccm_base.vbase = ccm_base;
446
447 ret = imx6_pm_get_base(&pm_info->mmdc_base, socdata->mmdc_compat);
448 if (ret) {
449 pr_warn("%s: failed to get mmdc base %d!\n", __func__, ret);
450 goto put_node;
451 }
452
453 ret = imx6_pm_get_base(&pm_info->src_base, socdata->src_compat);
454 if (ret) {
455 pr_warn("%s: failed to get src base %d!\n", __func__, ret);
456 goto src_map_failed;
457 }
458
459 ret = imx6_pm_get_base(&pm_info->iomuxc_base, socdata->iomuxc_compat);
460 if (ret) {
461 pr_warn("%s: failed to get iomuxc base %d!\n", __func__, ret);
462 goto iomuxc_map_failed;
463 }
464
465 ret = imx6_pm_get_base(&pm_info->gpc_base, socdata->gpc_compat);
466 if (ret) {
467 pr_warn("%s: failed to get gpc base %d!\n", __func__, ret);
468 goto gpc_map_failed;
469 }
470
471 ret = imx6_pm_get_base(&pm_info->l2_base, "arm,pl310-cache");
472 if (ret) {
473 pr_warn("%s: failed to get pl310-cache base %d!\n",
474 __func__, ret);
475 goto pl310_cache_map_failed;
476 }
477
478 pm_info->cpu_type = socdata->cpu_type;
479 pm_info->mmdc_io_num = socdata->mmdc_io_num;
480 mmdc_offset_array = socdata->mmdc_io_offset;
481
482 for (i = 0; i < pm_info->mmdc_io_num; i++) {
483 pm_info->mmdc_io_val[i][0] =
484 mmdc_offset_array[i];
485 pm_info->mmdc_io_val[i][1] =
486 readl_relaxed(pm_info->iomuxc_base.vbase +
487 mmdc_offset_array[i]);
488 }
489
490 imx6_suspend_in_ocram_fn = fncpy(
491 suspend_ocram_base + sizeof(*pm_info),
492 &imx6_suspend,
493 MX6Q_SUSPEND_OCRAM_SIZE - sizeof(*pm_info));
494
495 goto put_node;
496
497pl310_cache_map_failed:
498 iounmap(&pm_info->gpc_base.vbase);
499gpc_map_failed:
500 iounmap(&pm_info->iomuxc_base.vbase);
501iomuxc_map_failed:
502 iounmap(&pm_info->src_base.vbase);
503src_map_failed:
504 iounmap(&pm_info->mmdc_base.vbase);
505put_node:
506 of_node_put(node);
507
508 return ret;
509}
510
511static void __init imx6_pm_common_init(const struct imx6_pm_socdata
512 *socdata)
513{
514 struct regmap *gpr;
515 int ret;
516
517 WARN_ON(!ccm_base);
518
519 if (IS_ENABLED(CONFIG_SUSPEND)) {
520 ret = imx6q_suspend_init(socdata);
521 if (ret)
522 pr_warn("%s: No DDR LPM support with suspend %d!\n",
523 __func__, ret);
524 }
525
526 /*
527 * This is for SW workaround step #1 of ERR007265, see comments
528 * in imx6q_set_lpm for details of this errata.
529 * Force IOMUXC irq pending, so that the interrupt to GPC can be
530 * used to deassert dsm_request signal when the signal gets
531 * asserted unexpectedly.
532 */
533 gpr = syscon_regmap_lookup_by_compatible("fsl,imx6q-iomuxc-gpr");
534 if (!IS_ERR(gpr))
535 regmap_update_bits(gpr, IOMUXC_GPR1, IMX6Q_GPR1_GINT,
536 IMX6Q_GPR1_GINT);
537}
538
539void __init imx6q_pm_init(void)
540{
541 imx6_pm_common_init(&imx6q_pm_data);
542}
543
544void __init imx6dl_pm_init(void)
545{
546 imx6_pm_common_init(&imx6dl_pm_data);
547}
548
549void __init imx6sl_pm_init(void)
550{
551 imx6_pm_common_init(&imx6sl_pm_data);
552}
diff --git a/arch/arm/mach-imx/pm-imx6q.c b/arch/arm/mach-imx/pm-imx6q.c
deleted file mode 100644
index 7a9b98589db7..000000000000
--- a/arch/arm/mach-imx/pm-imx6q.c
+++ /dev/null
@@ -1,241 +0,0 @@
1/*
2 * Copyright 2011-2013 Freescale Semiconductor, Inc.
3 * Copyright 2011 Linaro Ltd.
4 *
5 * The code contained herein is licensed under the GNU General Public
6 * License. You may obtain a copy of the GNU General Public License
7 * Version 2 or later at the following locations:
8 *
9 * http://www.opensource.org/licenses/gpl-license.html
10 * http://www.gnu.org/copyleft/gpl.html
11 */
12
13#include <linux/delay.h>
14#include <linux/init.h>
15#include <linux/io.h>
16#include <linux/irq.h>
17#include <linux/mfd/syscon.h>
18#include <linux/mfd/syscon/imx6q-iomuxc-gpr.h>
19#include <linux/of.h>
20#include <linux/of_address.h>
21#include <linux/regmap.h>
22#include <linux/suspend.h>
23#include <asm/cacheflush.h>
24#include <asm/proc-fns.h>
25#include <asm/suspend.h>
26#include <asm/hardware/cache-l2x0.h>
27
28#include "common.h"
29#include "hardware.h"
30
31#define CCR 0x0
32#define BM_CCR_WB_COUNT (0x7 << 16)
33#define BM_CCR_RBC_BYPASS_COUNT (0x3f << 21)
34#define BM_CCR_RBC_EN (0x1 << 27)
35
36#define CLPCR 0x54
37#define BP_CLPCR_LPM 0
38#define BM_CLPCR_LPM (0x3 << 0)
39#define BM_CLPCR_BYPASS_PMIC_READY (0x1 << 2)
40#define BM_CLPCR_ARM_CLK_DIS_ON_LPM (0x1 << 5)
41#define BM_CLPCR_SBYOS (0x1 << 6)
42#define BM_CLPCR_DIS_REF_OSC (0x1 << 7)
43#define BM_CLPCR_VSTBY (0x1 << 8)
44#define BP_CLPCR_STBY_COUNT 9
45#define BM_CLPCR_STBY_COUNT (0x3 << 9)
46#define BM_CLPCR_COSC_PWRDOWN (0x1 << 11)
47#define BM_CLPCR_WB_PER_AT_LPM (0x1 << 16)
48#define BM_CLPCR_WB_CORE_AT_LPM (0x1 << 17)
49#define BM_CLPCR_BYP_MMDC_CH0_LPM_HS (0x1 << 19)
50#define BM_CLPCR_BYP_MMDC_CH1_LPM_HS (0x1 << 21)
51#define BM_CLPCR_MASK_CORE0_WFI (0x1 << 22)
52#define BM_CLPCR_MASK_CORE1_WFI (0x1 << 23)
53#define BM_CLPCR_MASK_CORE2_WFI (0x1 << 24)
54#define BM_CLPCR_MASK_CORE3_WFI (0x1 << 25)
55#define BM_CLPCR_MASK_SCU_IDLE (0x1 << 26)
56#define BM_CLPCR_MASK_L2CC_IDLE (0x1 << 27)
57
58#define CGPR 0x64
59#define BM_CGPR_CHICKEN_BIT (0x1 << 17)
60
61static void __iomem *ccm_base;
62
63void imx6q_set_chicken_bit(void)
64{
65 u32 val = readl_relaxed(ccm_base + CGPR);
66
67 val |= BM_CGPR_CHICKEN_BIT;
68 writel_relaxed(val, ccm_base + CGPR);
69}
70
71static void imx6q_enable_rbc(bool enable)
72{
73 u32 val;
74
75 /*
76 * need to mask all interrupts in GPC before
77 * operating RBC configurations
78 */
79 imx_gpc_mask_all();
80
81 /* configure RBC enable bit */
82 val = readl_relaxed(ccm_base + CCR);
83 val &= ~BM_CCR_RBC_EN;
84 val |= enable ? BM_CCR_RBC_EN : 0;
85 writel_relaxed(val, ccm_base + CCR);
86
87 /* configure RBC count */
88 val = readl_relaxed(ccm_base + CCR);
89 val &= ~BM_CCR_RBC_BYPASS_COUNT;
90 val |= enable ? BM_CCR_RBC_BYPASS_COUNT : 0;
91 writel(val, ccm_base + CCR);
92
93 /*
94 * need to delay at least 2 cycles of CKIL(32K)
95 * due to hardware design requirement, which is
96 * ~61us, here we use 65us for safe
97 */
98 udelay(65);
99
100 /* restore GPC interrupt mask settings */
101 imx_gpc_restore_all();
102}
103
104static void imx6q_enable_wb(bool enable)
105{
106 u32 val;
107
108 /* configure well bias enable bit */
109 val = readl_relaxed(ccm_base + CLPCR);
110 val &= ~BM_CLPCR_WB_PER_AT_LPM;
111 val |= enable ? BM_CLPCR_WB_PER_AT_LPM : 0;
112 writel_relaxed(val, ccm_base + CLPCR);
113
114 /* configure well bias count */
115 val = readl_relaxed(ccm_base + CCR);
116 val &= ~BM_CCR_WB_COUNT;
117 val |= enable ? BM_CCR_WB_COUNT : 0;
118 writel_relaxed(val, ccm_base + CCR);
119}
120
121int imx6q_set_lpm(enum mxc_cpu_pwr_mode mode)
122{
123 struct irq_desc *iomuxc_irq_desc;
124 u32 val = readl_relaxed(ccm_base + CLPCR);
125
126 val &= ~BM_CLPCR_LPM;
127 switch (mode) {
128 case WAIT_CLOCKED:
129 break;
130 case WAIT_UNCLOCKED:
131 val |= 0x1 << BP_CLPCR_LPM;
132 val |= BM_CLPCR_ARM_CLK_DIS_ON_LPM;
133 break;
134 case STOP_POWER_ON:
135 val |= 0x2 << BP_CLPCR_LPM;
136 break;
137 case WAIT_UNCLOCKED_POWER_OFF:
138 val |= 0x1 << BP_CLPCR_LPM;
139 val &= ~BM_CLPCR_VSTBY;
140 val &= ~BM_CLPCR_SBYOS;
141 break;
142 case STOP_POWER_OFF:
143 val |= 0x2 << BP_CLPCR_LPM;
144 val |= 0x3 << BP_CLPCR_STBY_COUNT;
145 val |= BM_CLPCR_VSTBY;
146 val |= BM_CLPCR_SBYOS;
147 if (cpu_is_imx6sl()) {
148 val |= BM_CLPCR_BYPASS_PMIC_READY;
149 val |= BM_CLPCR_BYP_MMDC_CH0_LPM_HS;
150 } else {
151 val |= BM_CLPCR_BYP_MMDC_CH1_LPM_HS;
152 }
153 break;
154 default:
155 return -EINVAL;
156 }
157
158 /*
159 * ERR007265: CCM: When improper low-power sequence is used,
160 * the SoC enters low power mode before the ARM core executes WFI.
161 *
162 * Software workaround:
163 * 1) Software should trigger IRQ #32 (IOMUX) to be always pending
164 * by setting IOMUX_GPR1_GINT.
165 * 2) Software should then unmask IRQ #32 in GPC before setting CCM
166 * Low-Power mode.
167 * 3) Software should mask IRQ #32 right after CCM Low-Power mode
168 * is set (set bits 0-1 of CCM_CLPCR).
169 */
170 iomuxc_irq_desc = irq_to_desc(32);
171 imx_gpc_irq_unmask(&iomuxc_irq_desc->irq_data);
172 writel_relaxed(val, ccm_base + CLPCR);
173 imx_gpc_irq_mask(&iomuxc_irq_desc->irq_data);
174
175 return 0;
176}
177
178static int imx6q_suspend_finish(unsigned long val)
179{
180 cpu_do_idle();
181 return 0;
182}
183
184static int imx6q_pm_enter(suspend_state_t state)
185{
186 switch (state) {
187 case PM_SUSPEND_MEM:
188 imx6q_set_lpm(STOP_POWER_OFF);
189 imx6q_enable_wb(true);
190 imx6q_enable_rbc(true);
191 imx_gpc_pre_suspend();
192 imx_anatop_pre_suspend();
193 imx_set_cpu_jump(0, v7_cpu_resume);
194 /* Zzz ... */
195 cpu_suspend(0, imx6q_suspend_finish);
196 if (cpu_is_imx6q() || cpu_is_imx6dl())
197 imx_smp_prepare();
198 imx_anatop_post_resume();
199 imx_gpc_post_resume();
200 imx6q_enable_rbc(false);
201 imx6q_enable_wb(false);
202 imx6q_set_lpm(WAIT_CLOCKED);
203 break;
204 default:
205 return -EINVAL;
206 }
207
208 return 0;
209}
210
211static const struct platform_suspend_ops imx6q_pm_ops = {
212 .enter = imx6q_pm_enter,
213 .valid = suspend_valid_only_mem,
214};
215
216void __init imx6q_pm_set_ccm_base(void __iomem *base)
217{
218 ccm_base = base;
219}
220
221void __init imx6q_pm_init(void)
222{
223 struct regmap *gpr;
224
225 WARN_ON(!ccm_base);
226
227 /*
228 * This is for SW workaround step #1 of ERR007265, see comments
229 * in imx6q_set_lpm for details of this errata.
230 * Force IOMUXC irq pending, so that the interrupt to GPC can be
231 * used to deassert dsm_request signal when the signal gets
232 * asserted unexpectedly.
233 */
234 gpr = syscon_regmap_lookup_by_compatible("fsl,imx6q-iomuxc-gpr");
235 if (!IS_ERR(gpr))
236 regmap_update_bits(gpr, IOMUXC_GPR1, IMX6Q_GPR1_GINT,
237 IMX6Q_GPR1_GINT);
238
239
240 suspend_set_ops(&imx6q_pm_ops);
241}
diff --git a/arch/arm/mach-imx/suspend-imx6.S b/arch/arm/mach-imx/suspend-imx6.S
new file mode 100644
index 000000000000..20048ff05739
--- /dev/null
+++ b/arch/arm/mach-imx/suspend-imx6.S
@@ -0,0 +1,361 @@
1/*
2 * Copyright 2014 Freescale Semiconductor, Inc.
3 *
4 * The code contained herein is licensed under the GNU General Public
5 * License. You may obtain a copy of the GNU General Public License
6 * Version 2 or later at the following locations:
7 *
8 * http://www.opensource.org/licenses/gpl-license.html
9 * http://www.gnu.org/copyleft/gpl.html
10 */
11
12#include <linux/linkage.h>
13#include <asm/asm-offsets.h>
14#include <asm/hardware/cache-l2x0.h>
15#include "hardware.h"
16
17/*
18 * ==================== low level suspend ====================
19 *
20 * Better to follow below rules to use ARM registers:
21 * r0: pm_info structure address;
22 * r1 ~ r4: for saving pm_info members;
23 * r5 ~ r10: free registers;
24 * r11: io base address.
25 *
26 * suspend ocram space layout:
27 * ======================== high address ======================
28 * .
29 * .
30 * .
31 * ^
32 * ^
33 * ^
34 * imx6_suspend code
35 * PM_INFO structure(imx6_cpu_pm_info)
36 * ======================== low address =======================
37 */
38
39/*
40 * Below offsets are based on struct imx6_cpu_pm_info
41 * which defined in arch/arm/mach-imx/pm-imx6q.c, this
42 * structure contains necessary pm info for low level
43 * suspend related code.
44 */
45#define PM_INFO_PBASE_OFFSET 0x0
46#define PM_INFO_RESUME_ADDR_OFFSET 0x4
47#define PM_INFO_CPU_TYPE_OFFSET 0x8
48#define PM_INFO_PM_INFO_SIZE_OFFSET 0xC
49#define PM_INFO_MX6Q_MMDC_P_OFFSET 0x10
50#define PM_INFO_MX6Q_MMDC_V_OFFSET 0x14
51#define PM_INFO_MX6Q_SRC_P_OFFSET 0x18
52#define PM_INFO_MX6Q_SRC_V_OFFSET 0x1C
53#define PM_INFO_MX6Q_IOMUXC_P_OFFSET 0x20
54#define PM_INFO_MX6Q_IOMUXC_V_OFFSET 0x24
55#define PM_INFO_MX6Q_CCM_P_OFFSET 0x28
56#define PM_INFO_MX6Q_CCM_V_OFFSET 0x2C
57#define PM_INFO_MX6Q_GPC_P_OFFSET 0x30
58#define PM_INFO_MX6Q_GPC_V_OFFSET 0x34
59#define PM_INFO_MX6Q_L2_P_OFFSET 0x38
60#define PM_INFO_MX6Q_L2_V_OFFSET 0x3C
61#define PM_INFO_MMDC_IO_NUM_OFFSET 0x40
62#define PM_INFO_MMDC_IO_VAL_OFFSET 0x44
63
64#define MX6Q_SRC_GPR1 0x20
65#define MX6Q_SRC_GPR2 0x24
66#define MX6Q_MMDC_MAPSR 0x404
67#define MX6Q_MMDC_MPDGCTRL0 0x83c
68#define MX6Q_GPC_IMR1 0x08
69#define MX6Q_GPC_IMR2 0x0c
70#define MX6Q_GPC_IMR3 0x10
71#define MX6Q_GPC_IMR4 0x14
72#define MX6Q_CCM_CCR 0x0
73
74 .align 3
75
76 .macro sync_l2_cache
77
78 /* sync L2 cache to drain L2's buffers to DRAM. */
79#ifdef CONFIG_CACHE_L2X0
80 ldr r11, [r0, #PM_INFO_MX6Q_L2_V_OFFSET]
81 mov r6, #0x0
82 str r6, [r11, #L2X0_CACHE_SYNC]
831:
84 ldr r6, [r11, #L2X0_CACHE_SYNC]
85 ands r6, r6, #0x1
86 bne 1b
87#endif
88
89 .endm
90
91 .macro resume_mmdc
92
93 /* restore MMDC IO */
94 cmp r5, #0x0
95 ldreq r11, [r0, #PM_INFO_MX6Q_IOMUXC_V_OFFSET]
96 ldrne r11, [r0, #PM_INFO_MX6Q_IOMUXC_P_OFFSET]
97
98 ldr r6, [r0, #PM_INFO_MMDC_IO_NUM_OFFSET]
99 ldr r7, =PM_INFO_MMDC_IO_VAL_OFFSET
100 add r7, r7, r0
1011:
102 ldr r8, [r7], #0x4
103 ldr r9, [r7], #0x4
104 str r9, [r11, r8]
105 subs r6, r6, #0x1
106 bne 1b
107
108 cmp r5, #0x0
109 ldreq r11, [r0, #PM_INFO_MX6Q_MMDC_V_OFFSET]
110 ldrne r11, [r0, #PM_INFO_MX6Q_MMDC_P_OFFSET]
111
112 cmp r3, #MXC_CPU_IMX6SL
113 bne 4f
114
115 /* reset read FIFO, RST_RD_FIFO */
116 ldr r7, =MX6Q_MMDC_MPDGCTRL0
117 ldr r6, [r11, r7]
118 orr r6, r6, #(1 << 31)
119 str r6, [r11, r7]
1202:
121 ldr r6, [r11, r7]
122 ands r6, r6, #(1 << 31)
123 bne 2b
124
125 /* reset FIFO a second time */
126 ldr r6, [r11, r7]
127 orr r6, r6, #(1 << 31)
128 str r6, [r11, r7]
1293:
130 ldr r6, [r11, r7]
131 ands r6, r6, #(1 << 31)
132 bne 3b
1334:
134 /* let DDR out of self-refresh */
135 ldr r7, [r11, #MX6Q_MMDC_MAPSR]
136 bic r7, r7, #(1 << 21)
137 str r7, [r11, #MX6Q_MMDC_MAPSR]
1385:
139 ldr r7, [r11, #MX6Q_MMDC_MAPSR]
140 ands r7, r7, #(1 << 25)
141 bne 5b
142
143 /* enable DDR auto power saving */
144 ldr r7, [r11, #MX6Q_MMDC_MAPSR]
145 bic r7, r7, #0x1
146 str r7, [r11, #MX6Q_MMDC_MAPSR]
147
148 .endm
149
150ENTRY(imx6_suspend)
151 ldr r1, [r0, #PM_INFO_PBASE_OFFSET]
152 ldr r2, [r0, #PM_INFO_RESUME_ADDR_OFFSET]
153 ldr r3, [r0, #PM_INFO_CPU_TYPE_OFFSET]
154 ldr r4, [r0, #PM_INFO_PM_INFO_SIZE_OFFSET]
155
156 /*
157 * counting the resume address in iram
158 * to set it in SRC register.
159 */
160 ldr r6, =imx6_suspend
161 ldr r7, =resume
162 sub r7, r7, r6
163 add r8, r1, r4
164 add r9, r8, r7
165
166 /*
167 * make sure TLB contain the addr we want,
168 * as we will access them after MMDC IO floated.
169 */
170
171 ldr r11, [r0, #PM_INFO_MX6Q_CCM_V_OFFSET]
172 ldr r6, [r11, #0x0]
173 ldr r11, [r0, #PM_INFO_MX6Q_GPC_V_OFFSET]
174 ldr r6, [r11, #0x0]
175
176 /* use r11 to store the IO address */
177 ldr r11, [r0, #PM_INFO_MX6Q_SRC_V_OFFSET]
178 /* store physical resume addr and pm_info address. */
179 str r9, [r11, #MX6Q_SRC_GPR1]
180 str r1, [r11, #MX6Q_SRC_GPR2]
181
182 /* need to sync L2 cache before DSM. */
183 sync_l2_cache
184
185 ldr r11, [r0, #PM_INFO_MX6Q_MMDC_V_OFFSET]
186 /*
187 * put DDR explicitly into self-refresh and
188 * disable automatic power savings.
189 */
190 ldr r7, [r11, #MX6Q_MMDC_MAPSR]
191 orr r7, r7, #0x1
192 str r7, [r11, #MX6Q_MMDC_MAPSR]
193
194 /* make the DDR explicitly enter self-refresh. */
195 ldr r7, [r11, #MX6Q_MMDC_MAPSR]
196 orr r7, r7, #(1 << 21)
197 str r7, [r11, #MX6Q_MMDC_MAPSR]
198
199poll_dvfs_set:
200 ldr r7, [r11, #MX6Q_MMDC_MAPSR]
201 ands r7, r7, #(1 << 25)
202 beq poll_dvfs_set
203
204 ldr r11, [r0, #PM_INFO_MX6Q_IOMUXC_V_OFFSET]
205 ldr r6, =0x0
206 ldr r7, [r0, #PM_INFO_MMDC_IO_NUM_OFFSET]
207 ldr r8, =PM_INFO_MMDC_IO_VAL_OFFSET
208 add r8, r8, r0
209 /* i.MX6SL's last 3 IOs need special setting */
210 cmp r3, #MXC_CPU_IMX6SL
211 subeq r7, r7, #0x3
212set_mmdc_io_lpm:
213 ldr r9, [r8], #0x8
214 str r6, [r11, r9]
215 subs r7, r7, #0x1
216 bne set_mmdc_io_lpm
217
218 cmp r3, #MXC_CPU_IMX6SL
219 bne set_mmdc_io_lpm_done
220 ldr r6, =0x1000
221 ldr r9, [r8], #0x8
222 str r6, [r11, r9]
223 ldr r9, [r8], #0x8
224 str r6, [r11, r9]
225 ldr r6, =0x80000
226 ldr r9, [r8]
227 str r6, [r11, r9]
228set_mmdc_io_lpm_done:
229
230 /*
231 * mask all GPC interrupts before
232 * enabling the RBC counters to
233 * avoid the counter starting too
234 * early if an interupt is already
235 * pending.
236 */
237 ldr r11, [r0, #PM_INFO_MX6Q_GPC_V_OFFSET]
238 ldr r6, [r11, #MX6Q_GPC_IMR1]
239 ldr r7, [r11, #MX6Q_GPC_IMR2]
240 ldr r8, [r11, #MX6Q_GPC_IMR3]
241 ldr r9, [r11, #MX6Q_GPC_IMR4]
242
243 ldr r10, =0xffffffff
244 str r10, [r11, #MX6Q_GPC_IMR1]
245 str r10, [r11, #MX6Q_GPC_IMR2]
246 str r10, [r11, #MX6Q_GPC_IMR3]
247 str r10, [r11, #MX6Q_GPC_IMR4]
248
249 /*
250 * enable the RBC bypass counter here
251 * to hold off the interrupts. RBC counter
252 * = 32 (1ms), Minimum RBC delay should be
253 * 400us for the analog LDOs to power down.
254 */
255 ldr r11, [r0, #PM_INFO_MX6Q_CCM_V_OFFSET]
256 ldr r10, [r11, #MX6Q_CCM_CCR]
257 bic r10, r10, #(0x3f << 21)
258 orr r10, r10, #(0x20 << 21)
259 str r10, [r11, #MX6Q_CCM_CCR]
260
261 /* enable the counter. */
262 ldr r10, [r11, #MX6Q_CCM_CCR]
263 orr r10, r10, #(0x1 << 27)
264 str r10, [r11, #MX6Q_CCM_CCR]
265
266 /* unmask all the GPC interrupts. */
267 ldr r11, [r0, #PM_INFO_MX6Q_GPC_V_OFFSET]
268 str r6, [r11, #MX6Q_GPC_IMR1]
269 str r7, [r11, #MX6Q_GPC_IMR2]
270 str r8, [r11, #MX6Q_GPC_IMR3]
271 str r9, [r11, #MX6Q_GPC_IMR4]
272
273 /*
274 * now delay for a short while (3usec)
275 * ARM is at 1GHz at this point
276 * so a short loop should be enough.
277 * this delay is required to ensure that
278 * the RBC counter can start counting in
279 * case an interrupt is already pending
280 * or in case an interrupt arrives just
281 * as ARM is about to assert DSM_request.
282 */
283 ldr r6, =2000
284rbc_loop:
285 subs r6, r6, #0x1
286 bne rbc_loop
287
288 /* Zzz, enter stop mode */
289 wfi
290 nop
291 nop
292 nop
293 nop
294
295 /*
296 * run to here means there is pending
297 * wakeup source, system should auto
298 * resume, we need to restore MMDC IO first
299 */
300 mov r5, #0x0
301 resume_mmdc
302
303 /* return to suspend finish */
304 mov pc, lr
305
306resume:
307 /* invalidate L1 I-cache first */
308 mov r6, #0x0
309 mcr p15, 0, r6, c7, c5, 0
310 mcr p15, 0, r6, c7, c5, 6
311 /* enable the Icache and branch prediction */
312 mov r6, #0x1800
313 mcr p15, 0, r6, c1, c0, 0
314 isb
315
316 /* get physical resume address from pm_info. */
317 ldr lr, [r0, #PM_INFO_RESUME_ADDR_OFFSET]
318 /* clear core0's entry and parameter */
319 ldr r11, [r0, #PM_INFO_MX6Q_SRC_P_OFFSET]
320 mov r7, #0x0
321 str r7, [r11, #MX6Q_SRC_GPR1]
322 str r7, [r11, #MX6Q_SRC_GPR2]
323
324 ldr r3, [r0, #PM_INFO_CPU_TYPE_OFFSET]
325 mov r5, #0x1
326 resume_mmdc
327
328 mov pc, lr
329ENDPROC(imx6_suspend)
330
331/*
332 * The following code must assume it is running from physical address
333 * where absolute virtual addresses to the data section have to be
334 * turned into relative ones.
335 */
336
337#ifdef CONFIG_CACHE_L2X0
338 .macro pl310_resume
339 adr r0, l2x0_saved_regs_offset
340 ldr r2, [r0]
341 add r2, r2, r0
342 ldr r0, [r2, #L2X0_R_PHY_BASE] @ get physical base of l2x0
343 ldr r1, [r2, #L2X0_R_AUX_CTRL] @ get aux_ctrl value
344 str r1, [r0, #L2X0_AUX_CTRL] @ restore aux_ctrl
345 mov r1, #0x1
346 str r1, [r0, #L2X0_CTRL] @ re-enable L2
347 .endm
348
349l2x0_saved_regs_offset:
350 .word l2x0_saved_regs - .
351
352#else
353 .macro pl310_resume
354 .endm
355#endif
356
357ENTRY(v7_cpu_resume)
358 bl v7_invalidate_l1
359 pl310_resume
360 b cpu_resume
361ENDPROC(v7_cpu_resume)
diff --git a/arch/arm/mach-imx/time.c b/arch/arm/mach-imx/time.c
index 1a3a5f615770..65222ea0df6d 100644
--- a/arch/arm/mach-imx/time.c
+++ b/arch/arm/mach-imx/time.c
@@ -25,6 +25,7 @@
25#include <linux/irq.h> 25#include <linux/irq.h>
26#include <linux/clockchips.h> 26#include <linux/clockchips.h>
27#include <linux/clk.h> 27#include <linux/clk.h>
28#include <linux/delay.h>
28#include <linux/err.h> 29#include <linux/err.h>
29#include <linux/sched_clock.h> 30#include <linux/sched_clock.h>
30 31
@@ -116,11 +117,22 @@ static u64 notrace mxc_read_sched_clock(void)
116 return sched_clock_reg ? __raw_readl(sched_clock_reg) : 0; 117 return sched_clock_reg ? __raw_readl(sched_clock_reg) : 0;
117} 118}
118 119
120static struct delay_timer imx_delay_timer;
121
122static unsigned long imx_read_current_timer(void)
123{
124 return __raw_readl(sched_clock_reg);
125}
126
119static int __init mxc_clocksource_init(struct clk *timer_clk) 127static int __init mxc_clocksource_init(struct clk *timer_clk)
120{ 128{
121 unsigned int c = clk_get_rate(timer_clk); 129 unsigned int c = clk_get_rate(timer_clk);
122 void __iomem *reg = timer_base + (timer_is_v2() ? V2_TCN : MX1_2_TCN); 130 void __iomem *reg = timer_base + (timer_is_v2() ? V2_TCN : MX1_2_TCN);
123 131
132 imx_delay_timer.read_current_timer = &imx_read_current_timer;
133 imx_delay_timer.freq = c;
134 register_current_timer_delay(&imx_delay_timer);
135
124 sched_clock_reg = reg; 136 sched_clock_reg = reg;
125 137
126 sched_clock_register(mxc_read_sched_clock, 32, c); 138 sched_clock_register(mxc_read_sched_clock, 32, c);
diff --git a/arch/arm/mach-keystone/Kconfig b/arch/arm/mach-keystone/Kconfig
index 90a708fef541..f50bc936cb84 100644
--- a/arch/arm/mach-keystone/Kconfig
+++ b/arch/arm/mach-keystone/Kconfig
@@ -1,13 +1,9 @@
1config ARCH_KEYSTONE 1config ARCH_KEYSTONE
2 bool "Texas Instruments Keystone Devices" 2 bool "Texas Instruments Keystone Devices"
3 depends on ARCH_MULTI_V7 3 depends on ARCH_MULTI_V7
4 select CPU_V7
5 select ARM_GIC 4 select ARM_GIC
6 select HAVE_ARM_ARCH_TIMER 5 select HAVE_ARM_ARCH_TIMER
7 select HAVE_SMP
8 select CLKSRC_MMIO 6 select CLKSRC_MMIO
9 select GENERIC_CLOCKEVENTS
10 select ARCH_WANT_OPTIONAL_GPIOLIB
11 select ARM_ERRATA_798181 if SMP 7 select ARM_ERRATA_798181 if SMP
12 select COMMON_CLK_KEYSTONE 8 select COMMON_CLK_KEYSTONE
13 select ARCH_SUPPORTS_BIG_ENDIAN 9 select ARCH_SUPPORTS_BIG_ENDIAN
diff --git a/arch/arm/mach-moxart/Kconfig b/arch/arm/mach-moxart/Kconfig
index 3795ae28a613..95a6a4b43c37 100644
--- a/arch/arm/mach-moxart/Kconfig
+++ b/arch/arm/mach-moxart/Kconfig
@@ -2,14 +2,9 @@ config ARCH_MOXART
2 bool "MOXA ART SoC" if ARCH_MULTI_V4T 2 bool "MOXA ART SoC" if ARCH_MULTI_V4T
3 select CPU_FA526 3 select CPU_FA526
4 select ARM_DMA_MEM_BUFFERABLE 4 select ARM_DMA_MEM_BUFFERABLE
5 select USE_OF
6 select CLKSRC_OF
7 select CLKSRC_MMIO 5 select CLKSRC_MMIO
8 select HAVE_CLK
9 select COMMON_CLK
10 select GENERIC_IRQ_CHIP 6 select GENERIC_IRQ_CHIP
11 select ARCH_REQUIRE_GPIOLIB 7 select ARCH_REQUIRE_GPIOLIB
12 select GENERIC_CLOCKEVENTS
13 select PHYLIB if NETDEVICES 8 select PHYLIB if NETDEVICES
14 help 9 help
15 Say Y here if you want to run your kernel on hardware with a 10 Say Y here if you want to run your kernel on hardware with a
diff --git a/arch/arm/mach-mvebu/Kconfig b/arch/arm/mach-mvebu/Kconfig
index 884b275ab056..f961ae4ec4ee 100644
--- a/arch/arm/mach-mvebu/Kconfig
+++ b/arch/arm/mach-mvebu/Kconfig
@@ -2,15 +2,10 @@ config ARCH_MVEBU
2 bool "Marvell SOCs with Device Tree support" if ARCH_MULTI_V7 2 bool "Marvell SOCs with Device Tree support" if ARCH_MULTI_V7
3 select ARCH_SUPPORTS_BIG_ENDIAN 3 select ARCH_SUPPORTS_BIG_ENDIAN
4 select CLKSRC_MMIO 4 select CLKSRC_MMIO
5 select COMMON_CLK
6 select GENERIC_CLOCKEVENTS
7 select GENERIC_IRQ_CHIP 5 select GENERIC_IRQ_CHIP
8 select IRQ_DOMAIN 6 select IRQ_DOMAIN
9 select MULTI_IRQ_HANDLER
10 select PINCTRL 7 select PINCTRL
11 select PLAT_ORION 8 select PLAT_ORION
12 select SPARSE_IRQ
13 select CLKDEV_LOOKUP
14 select MVEBU_MBUS 9 select MVEBU_MBUS
15 select ZONE_DMA if ARM_LPAE 10 select ZONE_DMA if ARM_LPAE
16 select ARCH_REQUIRE_GPIOLIB 11 select ARCH_REQUIRE_GPIOLIB
@@ -24,7 +19,6 @@ menu "Marvell SOC with device tree"
24config MACH_MVEBU_V7 19config MACH_MVEBU_V7
25 bool 20 bool
26 select ARMADA_370_XP_TIMER 21 select ARMADA_370_XP_TIMER
27 select HAVE_SMP
28 select CACHE_L2X0 22 select CACHE_L2X0
29 23
30config MACH_ARMADA_370 24config MACH_ARMADA_370
diff --git a/arch/arm/mach-mxs/Kconfig b/arch/arm/mach-mxs/Kconfig
index 8cde9e05b5d6..84794137b175 100644
--- a/arch/arm/mach-mxs/Kconfig
+++ b/arch/arm/mach-mxs/Kconfig
@@ -16,11 +16,7 @@ config ARCH_MXS
16 bool "Freescale MXS (i.MX23, i.MX28) support" 16 bool "Freescale MXS (i.MX23, i.MX28) support"
17 depends on ARCH_MULTI_V5 17 depends on ARCH_MULTI_V5
18 select ARCH_REQUIRE_GPIOLIB 18 select ARCH_REQUIRE_GPIOLIB
19 select CLKDEV_LOOKUP
20 select CLKSRC_MMIO 19 select CLKSRC_MMIO
21 select CLKSRC_OF
22 select GENERIC_CLOCKEVENTS
23 select HAVE_CLK_PREPARE
24 select PINCTRL 20 select PINCTRL
25 select SOC_BUS 21 select SOC_BUS
26 select SOC_IMX23 22 select SOC_IMX23
diff --git a/arch/arm/mach-nomadik/Kconfig b/arch/arm/mach-nomadik/Kconfig
index 4d42da49753c..486d301f43fd 100644
--- a/arch/arm/mach-nomadik/Kconfig
+++ b/arch/arm/mach-nomadik/Kconfig
@@ -6,16 +6,11 @@ config ARCH_NOMADIK
6 select ARM_VIC 6 select ARM_VIC
7 select CLKSRC_NOMADIK_MTU 7 select CLKSRC_NOMADIK_MTU
8 select CLKSRC_NOMADIK_MTU_SCHED_CLOCK 8 select CLKSRC_NOMADIK_MTU_SCHED_CLOCK
9 select CLKSRC_OF
10 select COMMON_CLK
11 select CPU_ARM926T 9 select CPU_ARM926T
12 select GENERIC_CLOCKEVENTS
13 select MIGHT_HAVE_CACHE_L2X0 10 select MIGHT_HAVE_CACHE_L2X0
14 select PINCTRL 11 select PINCTRL
15 select PINCTRL_NOMADIK 12 select PINCTRL_NOMADIK
16 select PINCTRL_STN8815 13 select PINCTRL_STN8815
17 select SPARSE_IRQ
18 select USE_OF
19 help 14 help
20 Support for the Nomadik platform by ST-Ericsson 15 Support for the Nomadik platform by ST-Ericsson
21 16
diff --git a/arch/arm/mach-nspire/Kconfig b/arch/arm/mach-nspire/Kconfig
index 59d8f0a70919..bc41f26c1a12 100644
--- a/arch/arm/mach-nspire/Kconfig
+++ b/arch/arm/mach-nspire/Kconfig
@@ -3,14 +3,9 @@ config ARCH_NSPIRE
3 depends on ARCH_MULTI_V4_V5 3 depends on ARCH_MULTI_V4_V5
4 depends on MMU 4 depends on MMU
5 select CPU_ARM926T 5 select CPU_ARM926T
6 select COMMON_CLK
7 select GENERIC_CLOCKEVENTS
8 select GENERIC_IRQ_CHIP 6 select GENERIC_IRQ_CHIP
9 select SPARSE_IRQ
10 select ARM_AMBA 7 select ARM_AMBA
11 select ARM_VIC 8 select ARM_VIC
12 select ARM_TIMER_SP804 9 select ARM_TIMER_SP804
13 select USE_OF
14 select CLKSRC_OF
15 help 10 help
16 This enables support for systems using the TI-NSPIRE CPU 11 This enables support for systems using the TI-NSPIRE CPU
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 40fd5c31b594..e55ae63bb030 100644
--- a/arch/arm/mach-omap2/Kconfig
+++ b/arch/arm/mach-omap2/Kconfig
@@ -6,7 +6,6 @@ config ARCH_OMAP2
6 depends on ARCH_MULTI_V6 6 depends on ARCH_MULTI_V6
7 select ARCH_OMAP2PLUS 7 select ARCH_OMAP2PLUS
8 select CPU_V6 8 select CPU_V6
9 select MULTI_IRQ_HANDLER
10 select SOC_HAS_OMAP2_SDRC 9 select SOC_HAS_OMAP2_SDRC
11 10
12config ARCH_OMAP3 11config ARCH_OMAP3
@@ -15,8 +14,6 @@ config ARCH_OMAP3
15 select ARCH_OMAP2PLUS 14 select ARCH_OMAP2PLUS
16 select ARCH_HAS_OPP 15 select ARCH_HAS_OPP
17 select ARM_CPU_SUSPEND if PM 16 select ARM_CPU_SUSPEND if PM
18 select CPU_V7
19 select MULTI_IRQ_HANDLER
20 select OMAP_INTERCONNECT 17 select OMAP_INTERCONNECT
21 select PM_OPP if PM 18 select PM_OPP if PM
22 select PM_RUNTIME if CPU_IDLE 19 select PM_RUNTIME if CPU_IDLE
@@ -33,10 +30,8 @@ config ARCH_OMAP4
33 select ARM_ERRATA_720789 30 select ARM_ERRATA_720789
34 select ARM_GIC 31 select ARM_GIC
35 select CACHE_L2X0 32 select CACHE_L2X0
36 select CPU_V7
37 select HAVE_ARM_SCU if SMP 33 select HAVE_ARM_SCU if SMP
38 select HAVE_ARM_TWD if SMP 34 select HAVE_ARM_TWD if SMP
39 select HAVE_SMP
40 select OMAP_INTERCONNECT 35 select OMAP_INTERCONNECT
41 select PL310_ERRATA_588369 36 select PL310_ERRATA_588369
42 select PL310_ERRATA_727915 37 select PL310_ERRATA_727915
@@ -50,12 +45,11 @@ config SOC_OMAP5
50 bool "TI OMAP5" 45 bool "TI OMAP5"
51 depends on ARCH_MULTI_V7 46 depends on ARCH_MULTI_V7
52 select ARCH_OMAP2PLUS 47 select ARCH_OMAP2PLUS
48 select ARCH_HAS_OPP
53 select ARM_CPU_SUSPEND if PM 49 select ARM_CPU_SUSPEND if PM
54 select ARM_GIC 50 select ARM_GIC
55 select CPU_V7
56 select HAVE_ARM_SCU if SMP 51 select HAVE_ARM_SCU if SMP
57 select HAVE_ARM_TWD if SMP 52 select HAVE_ARM_TWD if SMP
58 select HAVE_SMP
59 select HAVE_ARM_ARCH_TIMER 53 select HAVE_ARM_ARCH_TIMER
60 select ARM_ERRATA_798181 if SMP 54 select ARM_ERRATA_798181 if SMP
61 55
@@ -63,16 +57,14 @@ config SOC_AM33XX
63 bool "TI AM33XX" 57 bool "TI AM33XX"
64 depends on ARCH_MULTI_V7 58 depends on ARCH_MULTI_V7
65 select ARCH_OMAP2PLUS 59 select ARCH_OMAP2PLUS
60 select ARCH_HAS_OPP
66 select ARM_CPU_SUSPEND if PM 61 select ARM_CPU_SUSPEND if PM
67 select CPU_V7
68 select MULTI_IRQ_HANDLER
69 62
70config SOC_AM43XX 63config SOC_AM43XX
71 bool "TI AM43x" 64 bool "TI AM43x"
72 depends on ARCH_MULTI_V7 65 depends on ARCH_MULTI_V7
73 select CPU_V7
74 select ARCH_OMAP2PLUS 66 select ARCH_OMAP2PLUS
75 select MULTI_IRQ_HANDLER 67 select ARCH_HAS_OPP
76 select ARM_GIC 68 select ARM_GIC
77 select MACH_OMAP_GENERIC 69 select MACH_OMAP_GENERIC
78 70
@@ -80,10 +72,9 @@ config SOC_DRA7XX
80 bool "TI DRA7XX" 72 bool "TI DRA7XX"
81 depends on ARCH_MULTI_V7 73 depends on ARCH_MULTI_V7
82 select ARCH_OMAP2PLUS 74 select ARCH_OMAP2PLUS
75 select ARCH_HAS_OPP
83 select ARM_CPU_SUSPEND if PM 76 select ARM_CPU_SUSPEND if PM
84 select ARM_GIC 77 select ARM_GIC
85 select CPU_V7
86 select HAVE_SMP
87 select HAVE_ARM_ARCH_TIMER 78 select HAVE_ARM_ARCH_TIMER
88 79
89config ARCH_OMAP2PLUS 80config ARCH_OMAP2PLUS
@@ -94,17 +85,13 @@ config ARCH_OMAP2PLUS
94 select ARCH_OMAP 85 select ARCH_OMAP
95 select ARCH_REQUIRE_GPIOLIB 86 select ARCH_REQUIRE_GPIOLIB
96 select CLKSRC_MMIO 87 select CLKSRC_MMIO
97 select COMMON_CLK
98 select GENERIC_CLOCKEVENTS
99 select GENERIC_IRQ_CHIP 88 select GENERIC_IRQ_CHIP
100 select MACH_OMAP_GENERIC 89 select MACH_OMAP_GENERIC
101 select OMAP_DM_TIMER 90 select OMAP_DM_TIMER
102 select PINCTRL 91 select PINCTRL
103 select PROC_DEVICETREE if PROC_FS 92 select PROC_DEVICETREE if PROC_FS
104 select SOC_BUS 93 select SOC_BUS
105 select SPARSE_IRQ
106 select TI_PRIV_EDMA 94 select TI_PRIV_EDMA
107 select USE_OF
108 help 95 help
109 Systems based on OMAP2, OMAP3, OMAP4 or OMAP5 96 Systems based on OMAP2, OMAP3, OMAP4 or OMAP5
110 97
@@ -262,9 +249,6 @@ config MACH_OMAP_3430SDP
262 default y 249 default y
263 select OMAP_PACKAGE_CBB 250 select OMAP_PACKAGE_CBB
264 251
265config MACH_NOKIA_N800
266 bool
267
268config MACH_NOKIA_N810 252config MACH_NOKIA_N810
269 bool 253 bool
270 254
@@ -275,7 +259,6 @@ config MACH_NOKIA_N8X0
275 bool "Nokia N800/N810" 259 bool "Nokia N800/N810"
276 depends on SOC_OMAP2420 260 depends on SOC_OMAP2420
277 default y 261 default y
278 select MACH_NOKIA_N800
279 select MACH_NOKIA_N810 262 select MACH_NOKIA_N810
280 select MACH_NOKIA_N810_WIMAX 263 select MACH_NOKIA_N810_WIMAX
281 264
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 d9714113a01a..f14f9ac2dca1 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-picoxcell/Kconfig b/arch/arm/mach-picoxcell/Kconfig
index b1022f4315f7..eca9eb1c5931 100644
--- a/arch/arm/mach-picoxcell/Kconfig
+++ b/arch/arm/mach-picoxcell/Kconfig
@@ -1,12 +1,7 @@
1config ARCH_PICOXCELL 1config ARCH_PICOXCELL
2 bool "Picochip PicoXcell" if ARCH_MULTI_V6 2 bool "Picochip PicoXcell" if ARCH_MULTI_V6
3 select ARCH_REQUIRE_GPIOLIB 3 select ARCH_REQUIRE_GPIOLIB
4 select ARM_PATCH_PHYS_VIRT
5 select ARM_VIC 4 select ARM_VIC
6 select CPU_V6K
7 select DW_APB_TIMER_OF 5 select DW_APB_TIMER_OF
8 select GENERIC_CLOCKEVENTS
9 select HAVE_TCM 6 select HAVE_TCM
10 select NO_IOPORT 7 select NO_IOPORT
11 select SPARSE_IRQ
12 select USE_OF
diff --git a/arch/arm/mach-prima2/Kconfig b/arch/arm/mach-prima2/Kconfig
index 6988b117fc17..2c726b4f9356 100644
--- a/arch/arm/mach-prima2/Kconfig
+++ b/arch/arm/mach-prima2/Kconfig
@@ -1,9 +1,7 @@
1config ARCH_SIRF 1config ARCH_SIRF
2 bool "CSR SiRF" if ARCH_MULTI_V7 2 bool "CSR SiRF" if ARCH_MULTI_V7
3 select ARCH_REQUIRE_GPIOLIB 3 select ARCH_REQUIRE_GPIOLIB
4 select GENERIC_CLOCKEVENTS
5 select GENERIC_IRQ_CHIP 4 select GENERIC_IRQ_CHIP
6 select MIGHT_HAVE_CACHE_L2X0
7 select NO_IOPORT 5 select NO_IOPORT
8 select PINCTRL 6 select PINCTRL
9 select PINCTRL_SIRF 7 select PINCTRL_SIRF
@@ -17,7 +15,6 @@ menu "CSR SiRF atlas6/primaII/Marco/Polo Specific Features"
17config ARCH_ATLAS6 15config ARCH_ATLAS6
18 bool "CSR SiRFSoC ATLAS6 ARM Cortex A9 Platform" 16 bool "CSR SiRFSoC ATLAS6 ARM Cortex A9 Platform"
19 default y 17 default y
20 select CPU_V7
21 select SIRF_IRQ 18 select SIRF_IRQ
22 help 19 help
23 Support for CSR SiRFSoC ARM Cortex A9 Platform 20 Support for CSR SiRFSoC ARM Cortex A9 Platform
@@ -25,7 +22,6 @@ config ARCH_ATLAS6
25config ARCH_PRIMA2 22config ARCH_PRIMA2
26 bool "CSR SiRFSoC PRIMA2 ARM Cortex A9 Platform" 23 bool "CSR SiRFSoC PRIMA2 ARM Cortex A9 Platform"
27 default y 24 default y
28 select CPU_V7
29 select SIRF_IRQ 25 select SIRF_IRQ
30 select ZONE_DMA 26 select ZONE_DMA
31 help 27 help
@@ -35,9 +31,7 @@ config ARCH_MARCO
35 bool "CSR SiRFSoC MARCO ARM Cortex A9 Platform" 31 bool "CSR SiRFSoC MARCO ARM Cortex A9 Platform"
36 default y 32 default y
37 select ARM_GIC 33 select ARM_GIC
38 select CPU_V7
39 select HAVE_ARM_SCU if SMP 34 select HAVE_ARM_SCU if SMP
40 select HAVE_SMP
41 select SMP_ON_UP if SMP 35 select SMP_ON_UP if SMP
42 help 36 help
43 Support for CSR SiRFSoC ARM Cortex A9 Platform 37 Support for CSR SiRFSoC ARM Cortex A9 Platform
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-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig
index 133410e178a7..1caee6d548b8 100644
--- a/arch/arm/mach-rockchip/Kconfig
+++ b/arch/arm/mach-rockchip/Kconfig
@@ -7,9 +7,6 @@ config ARCH_ROCKCHIP
7 select CACHE_L2X0 7 select CACHE_L2X0
8 select HAVE_ARM_SCU if SMP 8 select HAVE_ARM_SCU if SMP
9 select HAVE_ARM_TWD if SMP 9 select HAVE_ARM_TWD if SMP
10 select HAVE_SMP
11 select COMMON_CLK
12 select GENERIC_CLOCKEVENTS
13 select DW_APB_TIMER_OF 10 select DW_APB_TIMER_OF
14 select ARM_GLOBAL_TIMER 11 select ARM_GLOBAL_TIMER
15 select CLKSRC_ARM_GLOBAL_TIMER_SCHED_CLOCK 12 select CLKSRC_ARM_GLOBAL_TIMER_SCHED_CLOCK
diff --git a/arch/arm/mach-shmobile/Kconfig b/arch/arm/mach-shmobile/Kconfig
index 05fa505df585..8a685edf3bbc 100644
--- a/arch/arm/mach-shmobile/Kconfig
+++ b/arch/arm/mach-shmobile/Kconfig
@@ -5,18 +5,13 @@ config ARCH_SHMOBILE_MULTI
5 bool "Renesas ARM SoCs" if ARCH_MULTI_V7 5 bool "Renesas ARM SoCs" if ARCH_MULTI_V7
6 depends on MMU 6 depends on MMU
7 select ARCH_SHMOBILE 7 select ARCH_SHMOBILE
8 select CPU_V7
9 select GENERIC_CLOCKEVENTS
10 select HAVE_ARM_SCU if SMP 8 select HAVE_ARM_SCU if SMP
11 select HAVE_ARM_TWD if SMP 9 select HAVE_ARM_TWD if SMP
12 select HAVE_SMP
13 select ARM_GIC 10 select ARM_GIC
14 select MIGHT_HAVE_CACHE_L2X0
15 select MIGHT_HAVE_PCI 11 select MIGHT_HAVE_PCI
16 select NO_IOPORT 12 select NO_IOPORT
17 select PINCTRL 13 select PINCTRL
18 select ARCH_REQUIRE_GPIOLIB 14 select ARCH_REQUIRE_GPIOLIB
19 select CLKDEV_LOOKUP
20 15
21if ARCH_SHMOBILE_MULTI 16if ARCH_SHMOBILE_MULTI
22 17
diff --git a/arch/arm/mach-socfpga/Kconfig b/arch/arm/mach-socfpga/Kconfig
index aee77f06f887..b5f8d75d51a0 100644
--- a/arch/arm/mach-socfpga/Kconfig
+++ b/arch/arm/mach-socfpga/Kconfig
@@ -1,17 +1,10 @@
1config ARCH_SOCFPGA 1config ARCH_SOCFPGA
2 bool "Altera SOCFPGA family" if ARCH_MULTI_V7 2 bool "Altera SOCFPGA family" if ARCH_MULTI_V7
3 select ARCH_WANT_OPTIONAL_GPIOLIB
4 select ARM_AMBA 3 select ARM_AMBA
5 select ARM_GIC 4 select ARM_GIC
6 select CACHE_L2X0 5 select CACHE_L2X0
7 select COMMON_CLK
8 select CPU_V7
9 select DW_APB_TIMER_OF 6 select DW_APB_TIMER_OF
10 select GENERIC_CLOCKEVENTS
11 select GPIO_PL061 if GPIOLIB 7 select GPIO_PL061 if GPIOLIB
12 select HAVE_ARM_SCU 8 select HAVE_ARM_SCU
13 select HAVE_ARM_TWD if SMP 9 select HAVE_ARM_TWD if SMP
14 select HAVE_SMP
15 select MFD_SYSCON 10 select MFD_SYSCON
16 select SPARSE_IRQ
17 select USE_OF
diff --git a/arch/arm/mach-spear/Kconfig b/arch/arm/mach-spear/Kconfig
index ac1710e64d9a..5c57262b97e9 100644
--- a/arch/arm/mach-spear/Kconfig
+++ b/arch/arm/mach-spear/Kconfig
@@ -8,8 +8,6 @@ menuconfig PLAT_SPEAR
8 select ARCH_REQUIRE_GPIOLIB 8 select ARCH_REQUIRE_GPIOLIB
9 select ARM_AMBA 9 select ARM_AMBA
10 select CLKSRC_MMIO 10 select CLKSRC_MMIO
11 select COMMON_CLK
12 select GENERIC_CLOCKEVENTS
13 11
14if PLAT_SPEAR 12if PLAT_SPEAR
15 13
@@ -18,14 +16,10 @@ config ARCH_SPEAR13XX
18 depends on ARCH_MULTI_V7 || PLAT_SPEAR_SINGLE 16 depends on ARCH_MULTI_V7 || PLAT_SPEAR_SINGLE
19 select ARCH_HAS_CPUFREQ 17 select ARCH_HAS_CPUFREQ
20 select ARM_GIC 18 select ARM_GIC
21 select CPU_V7
22 select GPIO_SPEAR_SPICS 19 select GPIO_SPEAR_SPICS
23 select HAVE_ARM_SCU if SMP 20 select HAVE_ARM_SCU if SMP
24 select HAVE_ARM_TWD if SMP 21 select HAVE_ARM_TWD if SMP
25 select HAVE_SMP
26 select MIGHT_HAVE_CACHE_L2X0
27 select PINCTRL 22 select PINCTRL
28 select USE_OF
29 help 23 help
30 Supports for ARM's SPEAR13XX family 24 Supports for ARM's SPEAR13XX family
31 25
@@ -50,9 +44,7 @@ config ARCH_SPEAR3XX
50 depends on ARCH_MULTI_V5 || PLAT_SPEAR_SINGLE 44 depends on ARCH_MULTI_V5 || PLAT_SPEAR_SINGLE
51 depends on !ARCH_SPEAR13XX 45 depends on !ARCH_SPEAR13XX
52 select ARM_VIC 46 select ARM_VIC
53 select CPU_ARM926T
54 select PINCTRL 47 select PINCTRL
55 select USE_OF
56 help 48 help
57 Supports for ARM's SPEAR3XX family 49 Supports for ARM's SPEAR3XX family
58 50
@@ -83,14 +75,12 @@ config ARCH_SPEAR6XX
83 depends on ARCH_MULTI_V5 || PLAT_SPEAR_SINGLE 75 depends on ARCH_MULTI_V5 || PLAT_SPEAR_SINGLE
84 depends on !ARCH_SPEAR13XX 76 depends on !ARCH_SPEAR13XX
85 select ARM_VIC 77 select ARM_VIC
86 select CPU_ARM926T
87 help 78 help
88 Supports for ARM's SPEAR6XX family 79 Supports for ARM's SPEAR6XX family
89 80
90config MACH_SPEAR600 81config MACH_SPEAR600
91 def_bool y 82 def_bool y
92 depends on ARCH_SPEAR6XX 83 depends on ARCH_SPEAR6XX
93 select USE_OF
94 help 84 help
95 Supports ST SPEAr600 boards configured via the device-treesource "arch/arm/mach-spear6xx/Kconfig" 85 Supports ST SPEAr600 boards configured via the device-treesource "arch/arm/mach-spear6xx/Kconfig"
96 86
diff --git a/arch/arm/mach-sti/Kconfig b/arch/arm/mach-sti/Kconfig
index d71654bc8d54..d2c13ba1190b 100644
--- a/arch/arm/mach-sti/Kconfig
+++ b/arch/arm/mach-sti/Kconfig
@@ -1,14 +1,10 @@
1menuconfig ARCH_STI 1menuconfig ARCH_STI
2 bool "STMicroelectronics Consumer Electronics SOCs with Device Trees" if ARCH_MULTI_V7 2 bool "STMicroelectronics Consumer Electronics SOCs with Device Trees" if ARCH_MULTI_V7
3 select GENERIC_CLOCKEVENTS
4 select CLKDEV_LOOKUP
5 select ARM_GIC 3 select ARM_GIC
6 select ARM_GLOBAL_TIMER 4 select ARM_GLOBAL_TIMER
7 select PINCTRL 5 select PINCTRL
8 select PINCTRL_ST 6 select PINCTRL_ST
9 select MFD_SYSCON 7 select MFD_SYSCON
10 select MIGHT_HAVE_CACHE_L2X0
11 select HAVE_SMP
12 select HAVE_ARM_SCU if SMP 8 select HAVE_ARM_SCU if SMP
13 select ARCH_REQUIRE_GPIOLIB 9 select ARCH_REQUIRE_GPIOLIB
14 select ARM_ERRATA_754322 10 select ARM_ERRATA_754322
diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig
index b9d6cad8669b..9de27cfa688f 100644
--- a/arch/arm/mach-sunxi/Kconfig
+++ b/arch/arm/mach-sunxi/Kconfig
@@ -5,14 +5,9 @@ config ARCH_SUNXI
5 select ARM_GIC 5 select ARM_GIC
6 select ARM_PSCI 6 select ARM_PSCI
7 select CLKSRC_MMIO 7 select CLKSRC_MMIO
8 select CLKSRC_OF
9 select COMMON_CLK
10 select GENERIC_CLOCKEVENTS
11 select GENERIC_IRQ_CHIP 8 select GENERIC_IRQ_CHIP
12 select HAVE_SMP
13 select PINCTRL 9 select PINCTRL
14 select PINCTRL_SUNXI 10 select PINCTRL_SUNXI
15 select RESET_CONTROLLER 11 select RESET_CONTROLLER
16 select SPARSE_IRQ
17 select SUN4I_TIMER 12 select SUN4I_TIMER
18 select SUN5I_HSTIMER 13 select SUN5I_HSTIMER
diff --git a/arch/arm/mach-tegra/Kconfig b/arch/arm/mach-tegra/Kconfig
index b1232d8be6f5..f61cd5b9f103 100644
--- a/arch/arm/mach-tegra/Kconfig
+++ b/arch/arm/mach-tegra/Kconfig
@@ -5,24 +5,16 @@ config ARCH_TEGRA
5 select ARCH_SUPPORTS_TRUSTED_FOUNDATIONS 5 select ARCH_SUPPORTS_TRUSTED_FOUNDATIONS
6 select ARM_GIC 6 select ARM_GIC
7 select CLKSRC_MMIO 7 select CLKSRC_MMIO
8 select CLKSRC_OF
9 select COMMON_CLK
10 select CPU_V7
11 select GENERIC_CLOCKEVENTS
12 select HAVE_ARM_SCU if SMP 8 select HAVE_ARM_SCU if SMP
13 select HAVE_ARM_TWD if SMP 9 select HAVE_ARM_TWD if SMP
14 select HAVE_SMP
15 select MIGHT_HAVE_CACHE_L2X0
16 select MIGHT_HAVE_PCI 10 select MIGHT_HAVE_PCI
17 select PINCTRL 11 select PINCTRL
18 select ARCH_HAS_RESET_CONTROLLER 12 select ARCH_HAS_RESET_CONTROLLER
19 select RESET_CONTROLLER 13 select RESET_CONTROLLER
20 select SOC_BUS 14 select SOC_BUS
21 select SPARSE_IRQ
22 select USB_ARCH_HAS_EHCI if USB_SUPPORT 15 select USB_ARCH_HAS_EHCI if USB_SUPPORT
23 select USB_ULPI if USB_PHY 16 select USB_ULPI if USB_PHY
24 select USB_ULPI_VIEWPORT if USB_PHY 17 select USB_ULPI_VIEWPORT if USB_PHY
25 select USE_OF
26 help 18 help
27 This enables support for NVIDIA Tegra based systems. 19 This enables support for NVIDIA Tegra based systems.
28 20
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/mach-u300/Kconfig b/arch/arm/mach-u300/Kconfig
index 8e23071bd1b3..e3a96d7302e9 100644
--- a/arch/arm/mach-u300/Kconfig
+++ b/arch/arm/mach-u300/Kconfig
@@ -3,20 +3,14 @@ config ARCH_U300
3 depends on MMU 3 depends on MMU
4 select ARCH_REQUIRE_GPIOLIB 4 select ARCH_REQUIRE_GPIOLIB
5 select ARM_AMBA 5 select ARM_AMBA
6 select ARM_PATCH_PHYS_VIRT
7 select ARM_VIC 6 select ARM_VIC
8 select CLKSRC_MMIO 7 select CLKSRC_MMIO
9 select CLKSRC_OF
10 select COMMON_CLK
11 select CPU_ARM926T 8 select CPU_ARM926T
12 select GENERIC_CLOCKEVENTS
13 select HAVE_TCM 9 select HAVE_TCM
14 select PINCTRL 10 select PINCTRL
15 select PINCTRL_COH901 11 select PINCTRL_COH901
16 select PINCTRL_U300 12 select PINCTRL_U300
17 select SPARSE_IRQ
18 select MFD_SYSCON 13 select MFD_SYSCON
19 select USE_OF
20 help 14 help
21 Support for ST-Ericsson U300 series mobile platforms. 15 Support for ST-Ericsson U300 series mobile platforms.
22 16
diff --git a/arch/arm/mach-ux500/Kconfig b/arch/arm/mach-ux500/Kconfig
index 0034d2cd6973..8052bd52450d 100644
--- a/arch/arm/mach-ux500/Kconfig
+++ b/arch/arm/mach-ux500/Kconfig
@@ -11,13 +11,8 @@ config ARCH_U8500
11 select ARM_GIC 11 select ARM_GIC
12 select CACHE_L2X0 12 select CACHE_L2X0
13 select CLKSRC_NOMADIK_MTU 13 select CLKSRC_NOMADIK_MTU
14 select COMMON_CLK
15 select CPU_V7
16 select GENERIC_CLOCKEVENTS
17 select HAVE_ARM_SCU if SMP 14 select HAVE_ARM_SCU if SMP
18 select HAVE_ARM_TWD if SMP 15 select HAVE_ARM_TWD if SMP
19 select HAVE_SMP
20 select MIGHT_HAVE_CACHE_L2X0
21 select PINCTRL 16 select PINCTRL
22 select PINCTRL_ABX500 17 select PINCTRL_ABX500
23 select PINCTRL_NOMADIK 18 select PINCTRL_NOMADIK
@@ -76,7 +71,6 @@ config UX500_AUTO_PLATFORM
76config MACH_UX500_DT 71config MACH_UX500_DT
77 bool "Generic U8500 support using device tree" 72 bool "Generic U8500 support using device tree"
78 depends on MACH_MOP500 73 depends on MACH_MOP500
79 select USE_OF
80 74
81endmenu 75endmenu
82 76
diff --git a/arch/arm/mach-vexpress/Kconfig b/arch/arm/mach-vexpress/Kconfig
index 4a70be485ff8..80b4be36f10a 100644
--- a/arch/arm/mach-vexpress/Kconfig
+++ b/arch/arm/mach-vexpress/Kconfig
@@ -5,16 +5,11 @@ config ARCH_VEXPRESS
5 select ARM_AMBA 5 select ARM_AMBA
6 select ARM_GIC 6 select ARM_GIC
7 select ARM_TIMER_SP804 7 select ARM_TIMER_SP804
8 select COMMON_CLK
9 select COMMON_CLK_VERSATILE 8 select COMMON_CLK_VERSATILE
10 select CPU_V7
11 select GENERIC_CLOCKEVENTS
12 select HAVE_ARM_SCU if SMP 9 select HAVE_ARM_SCU if SMP
13 select HAVE_ARM_TWD if SMP 10 select HAVE_ARM_TWD if SMP
14 select HAVE_PATA_PLATFORM 11 select HAVE_PATA_PLATFORM
15 select HAVE_SMP
16 select ICST 12 select ICST
17 select MIGHT_HAVE_CACHE_L2X0
18 select NO_IOPORT 13 select NO_IOPORT
19 select PLAT_VERSATILE 14 select PLAT_VERSATILE
20 select PLAT_VERSATILE_CLCD 15 select PLAT_VERSATILE_CLCD
diff --git a/arch/arm/mach-virt/Kconfig b/arch/arm/mach-virt/Kconfig
deleted file mode 100644
index 081d46929436..000000000000
--- a/arch/arm/mach-virt/Kconfig
+++ /dev/null
@@ -1,10 +0,0 @@
1config ARCH_VIRT
2 bool "Dummy Virtual Machine" if ARCH_MULTI_V7
3 select ARCH_WANT_OPTIONAL_GPIOLIB
4 select ARM_GIC
5 select HAVE_ARM_ARCH_TIMER
6 select ARM_PSCI
7 select HAVE_SMP
8 select CPU_V7
9 select SPARSE_IRQ
10 select USE_OF
diff --git a/arch/arm/mach-virt/Makefile b/arch/arm/mach-virt/Makefile
deleted file mode 100644
index 7ddbfa60227f..000000000000
--- a/arch/arm/mach-virt/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
1#
2# Makefile for the linux kernel.
3#
4
5obj-y := virt.o
diff --git a/arch/arm/mach-virt/virt.c b/arch/arm/mach-virt/virt.c
deleted file mode 100644
index b184e57d1854..000000000000
--- a/arch/arm/mach-virt/virt.c
+++ /dev/null
@@ -1,41 +0,0 @@
1/*
2 * Dummy Virtual Machine - does what it says on the tin.
3 *
4 * Copyright (C) 2012 ARM Ltd
5 * Authors: Will Deacon <will.deacon@arm.com>,
6 * Marc Zyngier <marc.zyngier@arm.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#include <linux/of_irq.h>
22#include <linux/of_platform.h>
23#include <linux/smp.h>
24
25#include <asm/mach/arch.h>
26
27static void __init virt_init(void)
28{
29 of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
30}
31
32static const char *virt_dt_match[] = {
33 "linux,dummy-virt",
34 "xen,xenvm",
35 NULL
36};
37
38DT_MACHINE_START(VIRT, "Dummy Virtual Machine")
39 .init_machine = virt_init,
40 .dt_compat = virt_dt_match,
41MACHINE_END
diff --git a/arch/arm/mach-vt8500/Kconfig b/arch/arm/mach-vt8500/Kconfig
index 927be93b692e..08f56a41cb55 100644
--- a/arch/arm/mach-vt8500/Kconfig
+++ b/arch/arm/mach-vt8500/Kconfig
@@ -3,8 +3,6 @@ config ARCH_VT8500
3 select ARCH_HAS_CPUFREQ 3 select ARCH_HAS_CPUFREQ
4 select ARCH_REQUIRE_GPIOLIB 4 select ARCH_REQUIRE_GPIOLIB
5 select CLKDEV_LOOKUP 5 select CLKDEV_LOOKUP
6 select CLKSRC_OF
7 select GENERIC_CLOCKEVENTS
8 select VT8500_TIMER 6 select VT8500_TIMER
9 select PINCTRL 7 select PINCTRL
10 help 8 help
@@ -21,7 +19,6 @@ config ARCH_WM8750
21 bool "WonderMedia WM8750" 19 bool "WonderMedia WM8750"
22 depends on ARCH_MULTI_V6 20 depends on ARCH_MULTI_V6
23 select ARCH_VT8500 21 select ARCH_VT8500
24 select CPU_V6
25 help 22 help
26 Support for WonderMedia WM8750 System-on-Chip. 23 Support for WonderMedia WM8750 System-on-Chip.
27 24
@@ -29,6 +26,5 @@ config ARCH_WM8850
29 bool "WonderMedia WM8850" 26 bool "WonderMedia WM8850"
30 depends on ARCH_MULTI_V7 27 depends on ARCH_MULTI_V7
31 select ARCH_VT8500 28 select ARCH_VT8500
32 select CPU_V7
33 help 29 help
34 Support for WonderMedia WM8850 System-on-Chip. 30 Support for WonderMedia WM8850 System-on-Chip.
diff --git a/arch/arm/mach-zynq/Kconfig b/arch/arm/mach-zynq/Kconfig
index 6b04260aa142..105d39b72a25 100644
--- a/arch/arm/mach-zynq/Kconfig
+++ b/arch/arm/mach-zynq/Kconfig
@@ -2,16 +2,9 @@ config ARCH_ZYNQ
2 bool "Xilinx Zynq ARM Cortex A9 Platform" if ARCH_MULTI_V7 2 bool "Xilinx Zynq ARM Cortex A9 Platform" if ARCH_MULTI_V7
3 select ARM_AMBA 3 select ARM_AMBA
4 select ARM_GIC 4 select ARM_GIC
5 select COMMON_CLK
6 select CPU_V7
7 select GENERIC_CLOCKEVENTS
8 select HAVE_ARM_SCU if SMP 5 select HAVE_ARM_SCU if SMP
9 select HAVE_ARM_TWD if SMP 6 select HAVE_ARM_TWD if SMP
10 select ICST 7 select ICST
11 select MIGHT_HAVE_CACHE_L2X0
12 select USE_OF
13 select HAVE_SMP
14 select SPARSE_IRQ
15 select CADENCE_TTC_TIMER 8 select CADENCE_TTC_TIMER
16 select ARM_GLOBAL_TIMER 9 select ARM_GLOBAL_TIMER
17 help 10 help
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/arm/mm/mm.h b/arch/arm/mm/mm.h
index d5a982d15a88..7ea641b7aa7d 100644
--- a/arch/arm/mm/mm.h
+++ b/arch/arm/mm/mm.h
@@ -38,6 +38,7 @@ static inline pmd_t *pmd_off_k(unsigned long virt)
38 38
39struct mem_type { 39struct mem_type {
40 pteval_t prot_pte; 40 pteval_t prot_pte;
41 pteval_t prot_pte_s2;
41 pmdval_t prot_l1; 42 pmdval_t prot_l1;
42 pmdval_t prot_sect; 43 pmdval_t prot_sect;
43 unsigned int domain; 44 unsigned int domain;
diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
index 4f08c133cc25..a623cb3ad012 100644
--- a/arch/arm/mm/mmu.c
+++ b/arch/arm/mm/mmu.c
@@ -232,12 +232,16 @@ __setup("noalign", noalign_setup);
232#endif /* ifdef CONFIG_CPU_CP15 / else */ 232#endif /* ifdef CONFIG_CPU_CP15 / else */
233 233
234#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY|L_PTE_XN 234#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY|L_PTE_XN
235#define PROT_PTE_S2_DEVICE PROT_PTE_DEVICE
235#define PROT_SECT_DEVICE PMD_TYPE_SECT|PMD_SECT_AP_WRITE 236#define PROT_SECT_DEVICE PMD_TYPE_SECT|PMD_SECT_AP_WRITE
236 237
237static struct mem_type mem_types[] = { 238static struct mem_type mem_types[] = {
238 [MT_DEVICE] = { /* Strongly ordered / ARMv6 shared device */ 239 [MT_DEVICE] = { /* Strongly ordered / ARMv6 shared device */
239 .prot_pte = PROT_PTE_DEVICE | L_PTE_MT_DEV_SHARED | 240 .prot_pte = PROT_PTE_DEVICE | L_PTE_MT_DEV_SHARED |
240 L_PTE_SHARED, 241 L_PTE_SHARED,
242 .prot_pte_s2 = s2_policy(PROT_PTE_S2_DEVICE) |
243 s2_policy(L_PTE_S2_MT_DEV_SHARED) |
244 L_PTE_SHARED,
241 .prot_l1 = PMD_TYPE_TABLE, 245 .prot_l1 = PMD_TYPE_TABLE,
242 .prot_sect = PROT_SECT_DEVICE | PMD_SECT_S, 246 .prot_sect = PROT_SECT_DEVICE | PMD_SECT_S,
243 .domain = DOMAIN_IO, 247 .domain = DOMAIN_IO,
@@ -508,7 +512,8 @@ static void __init build_mem_type_table(void)
508 cp = &cache_policies[cachepolicy]; 512 cp = &cache_policies[cachepolicy];
509 vecs_pgprot = kern_pgprot = user_pgprot = cp->pte; 513 vecs_pgprot = kern_pgprot = user_pgprot = cp->pte;
510 s2_pgprot = cp->pte_s2; 514 s2_pgprot = cp->pte_s2;
511 hyp_device_pgprot = s2_device_pgprot = mem_types[MT_DEVICE].prot_pte; 515 hyp_device_pgprot = mem_types[MT_DEVICE].prot_pte;
516 s2_device_pgprot = mem_types[MT_DEVICE].prot_pte_s2;
512 517
513 /* 518 /*
514 * ARMv6 and above have extended page tables. 519 * ARMv6 and above have extended page tables.
diff --git a/arch/arm/mm/proc-v6.S b/arch/arm/mm/proc-v6.S
index 45dc29f85d56..32b3558321c4 100644
--- a/arch/arm/mm/proc-v6.S
+++ b/arch/arm/mm/proc-v6.S
@@ -208,7 +208,6 @@ __v6_setup:
208 mcr p15, 0, r0, c7, c14, 0 @ clean+invalidate D cache 208 mcr p15, 0, r0, c7, c14, 0 @ clean+invalidate D cache
209 mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache 209 mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache
210 mcr p15, 0, r0, c7, c15, 0 @ clean+invalidate cache 210 mcr p15, 0, r0, c7, c15, 0 @ clean+invalidate cache
211 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer
212#ifdef CONFIG_MMU 211#ifdef CONFIG_MMU
213 mcr p15, 0, r0, c8, c7, 0 @ invalidate I + D TLBs 212 mcr p15, 0, r0, c8, c7, 0 @ invalidate I + D TLBs
214 mcr p15, 0, r0, c2, c0, 2 @ TTB control register 213 mcr p15, 0, r0, c2, c0, 2 @ TTB control register
@@ -218,6 +217,8 @@ __v6_setup:
218 ALT_UP(orr r8, r8, #TTB_FLAGS_UP) 217 ALT_UP(orr r8, r8, #TTB_FLAGS_UP)
219 mcr p15, 0, r8, c2, c0, 1 @ load TTB1 218 mcr p15, 0, r8, c2, c0, 1 @ load TTB1
220#endif /* CONFIG_MMU */ 219#endif /* CONFIG_MMU */
220 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer and
221 @ complete invalidations
221 adr r5, v6_crval 222 adr r5, v6_crval
222 ldmia r5, {r5, r6} 223 ldmia r5, {r5, r6}
223 ARM_BE8(orr r6, r6, #1 << 25) @ big-endian page tables 224 ARM_BE8(orr r6, r6, #1 << 25) @ big-endian page tables
diff --git a/arch/arm/mm/proc-v7.S b/arch/arm/mm/proc-v7.S
index bd1781979a39..74f6033e76dd 100644
--- a/arch/arm/mm/proc-v7.S
+++ b/arch/arm/mm/proc-v7.S
@@ -351,7 +351,6 @@ __v7_setup:
351 351
3524: mov r10, #0 3524: mov r10, #0
353 mcr p15, 0, r10, c7, c5, 0 @ I+BTB cache invalidate 353 mcr p15, 0, r10, c7, c5, 0 @ I+BTB cache invalidate
354 dsb
355#ifdef CONFIG_MMU 354#ifdef CONFIG_MMU
356 mcr p15, 0, r10, c8, c7, 0 @ invalidate I + D TLBs 355 mcr p15, 0, r10, c8, c7, 0 @ invalidate I + D TLBs
357 v7_ttb_setup r10, r4, r8, r5 @ TTBCR, TTBRx setup 356 v7_ttb_setup r10, r4, r8, r5 @ TTBCR, TTBRx setup
@@ -360,6 +359,7 @@ __v7_setup:
360 mcr p15, 0, r5, c10, c2, 0 @ write PRRR 359 mcr p15, 0, r5, c10, c2, 0 @ write PRRR
361 mcr p15, 0, r6, c10, c2, 1 @ write NMRR 360 mcr p15, 0, r6, c10, c2, 1 @ write NMRR
362#endif 361#endif
362 dsb @ Complete invalidations
363#ifndef CONFIG_ARM_THUMBEE 363#ifndef CONFIG_ARM_THUMBEE
364 mrc p15, 0, r0, c0, c1, 0 @ read ID_PFR0 for ThumbEE 364 mrc p15, 0, r0, c0, c1, 0 @ read ID_PFR0 for ThumbEE
365 and r0, r0, #(0xf << 12) @ ThumbEE enabled field 365 and r0, r0, #(0xf << 12) @ ThumbEE enabled field
diff --git a/arch/avr32/Makefile b/arch/avr32/Makefile
index 22fb66590dcd..dba48a5d5bb9 100644
--- a/arch/avr32/Makefile
+++ b/arch/avr32/Makefile
@@ -11,7 +11,7 @@ all: uImage vmlinux.elf
11 11
12KBUILD_DEFCONFIG := atstk1002_defconfig 12KBUILD_DEFCONFIG := atstk1002_defconfig
13 13
14KBUILD_CFLAGS += -pipe -fno-builtin -mno-pic 14KBUILD_CFLAGS += -pipe -fno-builtin -mno-pic -D__linux__
15KBUILD_AFLAGS += -mrelax -mno-pic 15KBUILD_AFLAGS += -mrelax -mno-pic
16KBUILD_CFLAGS_MODULE += -mno-relax 16KBUILD_CFLAGS_MODULE += -mno-relax
17LDFLAGS_vmlinux += --relax 17LDFLAGS_vmlinux += --relax
diff --git a/arch/avr32/boards/mimc200/fram.c b/arch/avr32/boards/mimc200/fram.c
index 9764a1a1073e..c1466a872b9c 100644
--- a/arch/avr32/boards/mimc200/fram.c
+++ b/arch/avr32/boards/mimc200/fram.c
@@ -11,6 +11,7 @@
11#define FRAM_VERSION "1.0" 11#define FRAM_VERSION "1.0"
12 12
13#include <linux/miscdevice.h> 13#include <linux/miscdevice.h>
14#include <linux/module.h>
14#include <linux/proc_fs.h> 15#include <linux/proc_fs.h>
15#include <linux/mm.h> 16#include <linux/mm.h>
16#include <linux/io.h> 17#include <linux/io.h>
diff --git a/arch/avr32/include/asm/Kbuild b/arch/avr32/include/asm/Kbuild
index cfb9fe1b8df9..c7c64a63c29f 100644
--- a/arch/avr32/include/asm/Kbuild
+++ b/arch/avr32/include/asm/Kbuild
@@ -17,5 +17,6 @@ generic-y += scatterlist.h
17generic-y += sections.h 17generic-y += sections.h
18generic-y += topology.h 18generic-y += topology.h
19generic-y += trace_clock.h 19generic-y += trace_clock.h
20generic-y += vga.h
20generic-y += xor.h 21generic-y += xor.h
21generic-y += hash.h 22generic-y += hash.h
diff --git a/arch/avr32/include/asm/io.h b/arch/avr32/include/asm/io.h
index fc6483f83ccc..4f5ec2bb7172 100644
--- a/arch/avr32/include/asm/io.h
+++ b/arch/avr32/include/asm/io.h
@@ -295,6 +295,8 @@ extern void __iounmap(void __iomem *addr);
295#define iounmap(addr) \ 295#define iounmap(addr) \
296 __iounmap(addr) 296 __iounmap(addr)
297 297
298#define ioremap_wc ioremap_nocache
299
298#define cached(addr) P1SEGADDR(addr) 300#define cached(addr) P1SEGADDR(addr)
299#define uncached(addr) P2SEGADDR(addr) 301#define uncached(addr) P2SEGADDR(addr)
300 302
diff --git a/arch/powerpc/include/asm/eeh.h b/arch/powerpc/include/asm/eeh.h
index 9e39ceb1d19f..d4dd41fb951b 100644
--- a/arch/powerpc/include/asm/eeh.h
+++ b/arch/powerpc/include/asm/eeh.h
@@ -172,10 +172,20 @@ struct eeh_ops {
172}; 172};
173 173
174extern struct eeh_ops *eeh_ops; 174extern struct eeh_ops *eeh_ops;
175extern int eeh_subsystem_enabled; 175extern bool eeh_subsystem_enabled;
176extern raw_spinlock_t confirm_error_lock; 176extern raw_spinlock_t confirm_error_lock;
177extern int eeh_probe_mode; 177extern int eeh_probe_mode;
178 178
179static inline bool eeh_enabled(void)
180{
181 return eeh_subsystem_enabled;
182}
183
184static inline void eeh_set_enable(bool mode)
185{
186 eeh_subsystem_enabled = mode;
187}
188
179#define EEH_PROBE_MODE_DEV (1<<0) /* From PCI device */ 189#define EEH_PROBE_MODE_DEV (1<<0) /* From PCI device */
180#define EEH_PROBE_MODE_DEVTREE (1<<1) /* From device tree */ 190#define EEH_PROBE_MODE_DEVTREE (1<<1) /* From device tree */
181 191
@@ -246,7 +256,7 @@ void eeh_remove_device(struct pci_dev *);
246 * If this macro yields TRUE, the caller relays to eeh_check_failure() 256 * If this macro yields TRUE, the caller relays to eeh_check_failure()
247 * which does further tests out of line. 257 * which does further tests out of line.
248 */ 258 */
249#define EEH_POSSIBLE_ERROR(val, type) ((val) == (type)~0 && eeh_subsystem_enabled) 259#define EEH_POSSIBLE_ERROR(val, type) ((val) == (type)~0 && eeh_enabled())
250 260
251/* 261/*
252 * Reads from a device which has been isolated by EEH will return 262 * Reads from a device which has been isolated by EEH will return
@@ -257,6 +267,13 @@ void eeh_remove_device(struct pci_dev *);
257 267
258#else /* !CONFIG_EEH */ 268#else /* !CONFIG_EEH */
259 269
270static inline bool eeh_enabled(void)
271{
272 return false;
273}
274
275static inline void eeh_set_enable(bool mode) { }
276
260static inline int eeh_init(void) 277static inline int eeh_init(void)
261{ 278{
262 return 0; 279 return 0;
diff --git a/arch/powerpc/include/asm/hugetlb.h b/arch/powerpc/include/asm/hugetlb.h
index d750336b171d..623f2971ce0e 100644
--- a/arch/powerpc/include/asm/hugetlb.h
+++ b/arch/powerpc/include/asm/hugetlb.h
@@ -127,7 +127,7 @@ static inline pte_t huge_ptep_get_and_clear(struct mm_struct *mm,
127 unsigned long addr, pte_t *ptep) 127 unsigned long addr, pte_t *ptep)
128{ 128{
129#ifdef CONFIG_PPC64 129#ifdef CONFIG_PPC64
130 return __pte(pte_update(mm, addr, ptep, ~0UL, 1)); 130 return __pte(pte_update(mm, addr, ptep, ~0UL, 0, 1));
131#else 131#else
132 return __pte(pte_update(ptep, ~0UL, 0)); 132 return __pte(pte_update(ptep, ~0UL, 0));
133#endif 133#endif
diff --git a/arch/powerpc/include/asm/pgtable-ppc64.h b/arch/powerpc/include/asm/pgtable-ppc64.h
index bc141c950b1e..eb9261024f51 100644
--- a/arch/powerpc/include/asm/pgtable-ppc64.h
+++ b/arch/powerpc/include/asm/pgtable-ppc64.h
@@ -195,6 +195,7 @@ extern void hpte_need_flush(struct mm_struct *mm, unsigned long addr,
195static inline unsigned long pte_update(struct mm_struct *mm, 195static inline unsigned long pte_update(struct mm_struct *mm,
196 unsigned long addr, 196 unsigned long addr,
197 pte_t *ptep, unsigned long clr, 197 pte_t *ptep, unsigned long clr,
198 unsigned long set,
198 int huge) 199 int huge)
199{ 200{
200#ifdef PTE_ATOMIC_UPDATES 201#ifdef PTE_ATOMIC_UPDATES
@@ -205,14 +206,15 @@ static inline unsigned long pte_update(struct mm_struct *mm,
205 andi. %1,%0,%6\n\ 206 andi. %1,%0,%6\n\
206 bne- 1b \n\ 207 bne- 1b \n\
207 andc %1,%0,%4 \n\ 208 andc %1,%0,%4 \n\
209 or %1,%1,%7\n\
208 stdcx. %1,0,%3 \n\ 210 stdcx. %1,0,%3 \n\
209 bne- 1b" 211 bne- 1b"
210 : "=&r" (old), "=&r" (tmp), "=m" (*ptep) 212 : "=&r" (old), "=&r" (tmp), "=m" (*ptep)
211 : "r" (ptep), "r" (clr), "m" (*ptep), "i" (_PAGE_BUSY) 213 : "r" (ptep), "r" (clr), "m" (*ptep), "i" (_PAGE_BUSY), "r" (set)
212 : "cc" ); 214 : "cc" );
213#else 215#else
214 unsigned long old = pte_val(*ptep); 216 unsigned long old = pte_val(*ptep);
215 *ptep = __pte(old & ~clr); 217 *ptep = __pte((old & ~clr) | set);
216#endif 218#endif
217 /* huge pages use the old page table lock */ 219 /* huge pages use the old page table lock */
218 if (!huge) 220 if (!huge)
@@ -231,9 +233,9 @@ static inline int __ptep_test_and_clear_young(struct mm_struct *mm,
231{ 233{
232 unsigned long old; 234 unsigned long old;
233 235
234 if ((pte_val(*ptep) & (_PAGE_ACCESSED | _PAGE_HASHPTE)) == 0) 236 if ((pte_val(*ptep) & (_PAGE_ACCESSED | _PAGE_HASHPTE)) == 0)
235 return 0; 237 return 0;
236 old = pte_update(mm, addr, ptep, _PAGE_ACCESSED, 0); 238 old = pte_update(mm, addr, ptep, _PAGE_ACCESSED, 0, 0);
237 return (old & _PAGE_ACCESSED) != 0; 239 return (old & _PAGE_ACCESSED) != 0;
238} 240}
239#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG 241#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG
@@ -252,7 +254,7 @@ static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr,
252 if ((pte_val(*ptep) & _PAGE_RW) == 0) 254 if ((pte_val(*ptep) & _PAGE_RW) == 0)
253 return; 255 return;
254 256
255 pte_update(mm, addr, ptep, _PAGE_RW, 0); 257 pte_update(mm, addr, ptep, _PAGE_RW, 0, 0);
256} 258}
257 259
258static inline void huge_ptep_set_wrprotect(struct mm_struct *mm, 260static inline void huge_ptep_set_wrprotect(struct mm_struct *mm,
@@ -261,7 +263,7 @@ static inline void huge_ptep_set_wrprotect(struct mm_struct *mm,
261 if ((pte_val(*ptep) & _PAGE_RW) == 0) 263 if ((pte_val(*ptep) & _PAGE_RW) == 0)
262 return; 264 return;
263 265
264 pte_update(mm, addr, ptep, _PAGE_RW, 1); 266 pte_update(mm, addr, ptep, _PAGE_RW, 0, 1);
265} 267}
266 268
267/* 269/*
@@ -284,14 +286,14 @@ static inline void huge_ptep_set_wrprotect(struct mm_struct *mm,
284static inline pte_t ptep_get_and_clear(struct mm_struct *mm, 286static inline pte_t ptep_get_and_clear(struct mm_struct *mm,
285 unsigned long addr, pte_t *ptep) 287 unsigned long addr, pte_t *ptep)
286{ 288{
287 unsigned long old = pte_update(mm, addr, ptep, ~0UL, 0); 289 unsigned long old = pte_update(mm, addr, ptep, ~0UL, 0, 0);
288 return __pte(old); 290 return __pte(old);
289} 291}
290 292
291static inline void pte_clear(struct mm_struct *mm, unsigned long addr, 293static inline void pte_clear(struct mm_struct *mm, unsigned long addr,
292 pte_t * ptep) 294 pte_t * ptep)
293{ 295{
294 pte_update(mm, addr, ptep, ~0UL, 0); 296 pte_update(mm, addr, ptep, ~0UL, 0, 0);
295} 297}
296 298
297 299
@@ -506,7 +508,9 @@ extern int pmdp_set_access_flags(struct vm_area_struct *vma,
506 508
507extern unsigned long pmd_hugepage_update(struct mm_struct *mm, 509extern unsigned long pmd_hugepage_update(struct mm_struct *mm,
508 unsigned long addr, 510 unsigned long addr,
509 pmd_t *pmdp, unsigned long clr); 511 pmd_t *pmdp,
512 unsigned long clr,
513 unsigned long set);
510 514
511static inline int __pmdp_test_and_clear_young(struct mm_struct *mm, 515static inline int __pmdp_test_and_clear_young(struct mm_struct *mm,
512 unsigned long addr, pmd_t *pmdp) 516 unsigned long addr, pmd_t *pmdp)
@@ -515,7 +519,7 @@ static inline int __pmdp_test_and_clear_young(struct mm_struct *mm,
515 519
516 if ((pmd_val(*pmdp) & (_PAGE_ACCESSED | _PAGE_HASHPTE)) == 0) 520 if ((pmd_val(*pmdp) & (_PAGE_ACCESSED | _PAGE_HASHPTE)) == 0)
517 return 0; 521 return 0;
518 old = pmd_hugepage_update(mm, addr, pmdp, _PAGE_ACCESSED); 522 old = pmd_hugepage_update(mm, addr, pmdp, _PAGE_ACCESSED, 0);
519 return ((old & _PAGE_ACCESSED) != 0); 523 return ((old & _PAGE_ACCESSED) != 0);
520} 524}
521 525
@@ -542,7 +546,7 @@ static inline void pmdp_set_wrprotect(struct mm_struct *mm, unsigned long addr,
542 if ((pmd_val(*pmdp) & _PAGE_RW) == 0) 546 if ((pmd_val(*pmdp) & _PAGE_RW) == 0)
543 return; 547 return;
544 548
545 pmd_hugepage_update(mm, addr, pmdp, _PAGE_RW); 549 pmd_hugepage_update(mm, addr, pmdp, _PAGE_RW, 0);
546} 550}
547 551
548#define __HAVE_ARCH_PMDP_SPLITTING_FLUSH 552#define __HAVE_ARCH_PMDP_SPLITTING_FLUSH
diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h
index f83b6f3e1b39..3ebb188c3ff5 100644
--- a/arch/powerpc/include/asm/pgtable.h
+++ b/arch/powerpc/include/asm/pgtable.h
@@ -75,12 +75,34 @@ static inline pte_t pte_mknuma(pte_t pte)
75 return pte; 75 return pte;
76} 76}
77 77
78#define ptep_set_numa ptep_set_numa
79static inline void ptep_set_numa(struct mm_struct *mm, unsigned long addr,
80 pte_t *ptep)
81{
82 if ((pte_val(*ptep) & _PAGE_PRESENT) == 0)
83 VM_BUG_ON(1);
84
85 pte_update(mm, addr, ptep, _PAGE_PRESENT, _PAGE_NUMA, 0);
86 return;
87}
88
78#define pmd_numa pmd_numa 89#define pmd_numa pmd_numa
79static inline int pmd_numa(pmd_t pmd) 90static inline int pmd_numa(pmd_t pmd)
80{ 91{
81 return pte_numa(pmd_pte(pmd)); 92 return pte_numa(pmd_pte(pmd));
82} 93}
83 94
95#define pmdp_set_numa pmdp_set_numa
96static inline void pmdp_set_numa(struct mm_struct *mm, unsigned long addr,
97 pmd_t *pmdp)
98{
99 if ((pmd_val(*pmdp) & _PAGE_PRESENT) == 0)
100 VM_BUG_ON(1);
101
102 pmd_hugepage_update(mm, addr, pmdp, _PAGE_PRESENT, _PAGE_NUMA);
103 return;
104}
105
84#define pmd_mknonnuma pmd_mknonnuma 106#define pmd_mknonnuma pmd_mknonnuma
85static inline pmd_t pmd_mknonnuma(pmd_t pmd) 107static inline pmd_t pmd_mknonnuma(pmd_t pmd)
86{ 108{
diff --git a/arch/powerpc/include/asm/vdso.h b/arch/powerpc/include/asm/vdso.h
index 0d9cecddf8a4..c53f5f6d1761 100644
--- a/arch/powerpc/include/asm/vdso.h
+++ b/arch/powerpc/include/asm/vdso.h
@@ -4,11 +4,11 @@
4#ifdef __KERNEL__ 4#ifdef __KERNEL__
5 5
6/* Default link addresses for the vDSOs */ 6/* Default link addresses for the vDSOs */
7#define VDSO32_LBASE 0x100000 7#define VDSO32_LBASE 0x0
8#define VDSO64_LBASE 0x100000 8#define VDSO64_LBASE 0x0
9 9
10/* Default map addresses for 32bit vDSO */ 10/* Default map addresses for 32bit vDSO */
11#define VDSO32_MBASE VDSO32_LBASE 11#define VDSO32_MBASE 0x100000
12 12
13#define VDSO_VERSION_STRING LINUX_2.6.15 13#define VDSO_VERSION_STRING LINUX_2.6.15
14 14
diff --git a/arch/powerpc/kernel/eeh.c b/arch/powerpc/kernel/eeh.c
index 148db72a8c43..e7b76a6bf150 100644
--- a/arch/powerpc/kernel/eeh.c
+++ b/arch/powerpc/kernel/eeh.c
@@ -28,6 +28,7 @@
28#include <linux/pci.h> 28#include <linux/pci.h>
29#include <linux/proc_fs.h> 29#include <linux/proc_fs.h>
30#include <linux/rbtree.h> 30#include <linux/rbtree.h>
31#include <linux/reboot.h>
31#include <linux/seq_file.h> 32#include <linux/seq_file.h>
32#include <linux/spinlock.h> 33#include <linux/spinlock.h>
33#include <linux/export.h> 34#include <linux/export.h>
@@ -89,7 +90,7 @@
89/* Platform dependent EEH operations */ 90/* Platform dependent EEH operations */
90struct eeh_ops *eeh_ops = NULL; 91struct eeh_ops *eeh_ops = NULL;
91 92
92int eeh_subsystem_enabled; 93bool eeh_subsystem_enabled = false;
93EXPORT_SYMBOL(eeh_subsystem_enabled); 94EXPORT_SYMBOL(eeh_subsystem_enabled);
94 95
95/* 96/*
@@ -364,7 +365,7 @@ int eeh_dev_check_failure(struct eeh_dev *edev)
364 365
365 eeh_stats.total_mmio_ffs++; 366 eeh_stats.total_mmio_ffs++;
366 367
367 if (!eeh_subsystem_enabled) 368 if (!eeh_enabled())
368 return 0; 369 return 0;
369 370
370 if (!edev) { 371 if (!edev) {
@@ -747,6 +748,17 @@ int __exit eeh_ops_unregister(const char *name)
747 return -EEXIST; 748 return -EEXIST;
748} 749}
749 750
751static int eeh_reboot_notifier(struct notifier_block *nb,
752 unsigned long action, void *unused)
753{
754 eeh_set_enable(false);
755 return NOTIFY_DONE;
756}
757
758static struct notifier_block eeh_reboot_nb = {
759 .notifier_call = eeh_reboot_notifier,
760};
761
750/** 762/**
751 * eeh_init - EEH initialization 763 * eeh_init - EEH initialization
752 * 764 *
@@ -778,6 +790,14 @@ int eeh_init(void)
778 if (machine_is(powernv) && cnt++ <= 0) 790 if (machine_is(powernv) && cnt++ <= 0)
779 return ret; 791 return ret;
780 792
793 /* Register reboot notifier */
794 ret = register_reboot_notifier(&eeh_reboot_nb);
795 if (ret) {
796 pr_warn("%s: Failed to register notifier (%d)\n",
797 __func__, ret);
798 return ret;
799 }
800
781 /* call platform initialization function */ 801 /* call platform initialization function */
782 if (!eeh_ops) { 802 if (!eeh_ops) {
783 pr_warning("%s: Platform EEH operation not found\n", 803 pr_warning("%s: Platform EEH operation not found\n",
@@ -822,7 +842,7 @@ int eeh_init(void)
822 return ret; 842 return ret;
823 } 843 }
824 844
825 if (eeh_subsystem_enabled) 845 if (eeh_enabled())
826 pr_info("EEH: PCI Enhanced I/O Error Handling Enabled\n"); 846 pr_info("EEH: PCI Enhanced I/O Error Handling Enabled\n");
827 else 847 else
828 pr_warning("EEH: No capable adapters found\n"); 848 pr_warning("EEH: No capable adapters found\n");
@@ -897,7 +917,7 @@ void eeh_add_device_late(struct pci_dev *dev)
897 struct device_node *dn; 917 struct device_node *dn;
898 struct eeh_dev *edev; 918 struct eeh_dev *edev;
899 919
900 if (!dev || !eeh_subsystem_enabled) 920 if (!dev || !eeh_enabled())
901 return; 921 return;
902 922
903 pr_debug("EEH: Adding device %s\n", pci_name(dev)); 923 pr_debug("EEH: Adding device %s\n", pci_name(dev));
@@ -1005,7 +1025,7 @@ void eeh_remove_device(struct pci_dev *dev)
1005{ 1025{
1006 struct eeh_dev *edev; 1026 struct eeh_dev *edev;
1007 1027
1008 if (!dev || !eeh_subsystem_enabled) 1028 if (!dev || !eeh_enabled())
1009 return; 1029 return;
1010 edev = pci_dev_to_eeh_dev(dev); 1030 edev = pci_dev_to_eeh_dev(dev);
1011 1031
@@ -1045,7 +1065,7 @@ void eeh_remove_device(struct pci_dev *dev)
1045 1065
1046static int proc_eeh_show(struct seq_file *m, void *v) 1066static int proc_eeh_show(struct seq_file *m, void *v)
1047{ 1067{
1048 if (0 == eeh_subsystem_enabled) { 1068 if (!eeh_enabled()) {
1049 seq_printf(m, "EEH Subsystem is globally disabled\n"); 1069 seq_printf(m, "EEH Subsystem is globally disabled\n");
1050 seq_printf(m, "eeh_total_mmio_ffs=%llu\n", eeh_stats.total_mmio_ffs); 1070 seq_printf(m, "eeh_total_mmio_ffs=%llu\n", eeh_stats.total_mmio_ffs);
1051 } else { 1071 } else {
diff --git a/arch/powerpc/kernel/misc_32.S b/arch/powerpc/kernel/misc_32.S
index 879f09620f83..7c6bb4b17b49 100644
--- a/arch/powerpc/kernel/misc_32.S
+++ b/arch/powerpc/kernel/misc_32.S
@@ -57,11 +57,14 @@ _GLOBAL(call_do_softirq)
57 mtlr r0 57 mtlr r0
58 blr 58 blr
59 59
60/*
61 * void call_do_irq(struct pt_regs *regs, struct thread_info *irqtp);
62 */
60_GLOBAL(call_do_irq) 63_GLOBAL(call_do_irq)
61 mflr r0 64 mflr r0
62 stw r0,4(r1) 65 stw r0,4(r1)
63 lwz r10,THREAD+KSP_LIMIT(r2) 66 lwz r10,THREAD+KSP_LIMIT(r2)
64 addi r11,r3,THREAD_INFO_GAP 67 addi r11,r4,THREAD_INFO_GAP
65 stwu r1,THREAD_SIZE-STACK_FRAME_OVERHEAD(r4) 68 stwu r1,THREAD_SIZE-STACK_FRAME_OVERHEAD(r4)
66 mr r1,r4 69 mr r1,r4
67 stw r10,8(r1) 70 stw r10,8(r1)
diff --git a/arch/powerpc/kernel/vdso32/vdso32_wrapper.S b/arch/powerpc/kernel/vdso32/vdso32_wrapper.S
index 79683d0393f5..6ac107ac402a 100644
--- a/arch/powerpc/kernel/vdso32/vdso32_wrapper.S
+++ b/arch/powerpc/kernel/vdso32/vdso32_wrapper.S
@@ -6,7 +6,7 @@
6 .globl vdso32_start, vdso32_end 6 .globl vdso32_start, vdso32_end
7 .balign PAGE_SIZE 7 .balign PAGE_SIZE
8vdso32_start: 8vdso32_start:
9 .incbin "arch/powerpc/kernel/vdso32/vdso32.so" 9 .incbin "arch/powerpc/kernel/vdso32/vdso32.so.dbg"
10 .balign PAGE_SIZE 10 .balign PAGE_SIZE
11vdso32_end: 11vdso32_end:
12 12
diff --git a/arch/powerpc/kernel/vdso64/vdso64_wrapper.S b/arch/powerpc/kernel/vdso64/vdso64_wrapper.S
index 8df9e2463007..df60fca6a13d 100644
--- a/arch/powerpc/kernel/vdso64/vdso64_wrapper.S
+++ b/arch/powerpc/kernel/vdso64/vdso64_wrapper.S
@@ -6,7 +6,7 @@
6 .globl vdso64_start, vdso64_end 6 .globl vdso64_start, vdso64_end
7 .balign PAGE_SIZE 7 .balign PAGE_SIZE
8vdso64_start: 8vdso64_start:
9 .incbin "arch/powerpc/kernel/vdso64/vdso64.so" 9 .incbin "arch/powerpc/kernel/vdso64/vdso64.so.dbg"
10 .balign PAGE_SIZE 10 .balign PAGE_SIZE
11vdso64_end: 11vdso64_end:
12 12
diff --git a/arch/powerpc/mm/pgtable_64.c b/arch/powerpc/mm/pgtable_64.c
index 65b7b65e8708..62bf5e8e78da 100644
--- a/arch/powerpc/mm/pgtable_64.c
+++ b/arch/powerpc/mm/pgtable_64.c
@@ -510,7 +510,8 @@ int pmdp_set_access_flags(struct vm_area_struct *vma, unsigned long address,
510} 510}
511 511
512unsigned long pmd_hugepage_update(struct mm_struct *mm, unsigned long addr, 512unsigned long pmd_hugepage_update(struct mm_struct *mm, unsigned long addr,
513 pmd_t *pmdp, unsigned long clr) 513 pmd_t *pmdp, unsigned long clr,
514 unsigned long set)
514{ 515{
515 516
516 unsigned long old, tmp; 517 unsigned long old, tmp;
@@ -526,14 +527,15 @@ unsigned long pmd_hugepage_update(struct mm_struct *mm, unsigned long addr,
526 andi. %1,%0,%6\n\ 527 andi. %1,%0,%6\n\
527 bne- 1b \n\ 528 bne- 1b \n\
528 andc %1,%0,%4 \n\ 529 andc %1,%0,%4 \n\
530 or %1,%1,%7\n\
529 stdcx. %1,0,%3 \n\ 531 stdcx. %1,0,%3 \n\
530 bne- 1b" 532 bne- 1b"
531 : "=&r" (old), "=&r" (tmp), "=m" (*pmdp) 533 : "=&r" (old), "=&r" (tmp), "=m" (*pmdp)
532 : "r" (pmdp), "r" (clr), "m" (*pmdp), "i" (_PAGE_BUSY) 534 : "r" (pmdp), "r" (clr), "m" (*pmdp), "i" (_PAGE_BUSY), "r" (set)
533 : "cc" ); 535 : "cc" );
534#else 536#else
535 old = pmd_val(*pmdp); 537 old = pmd_val(*pmdp);
536 *pmdp = __pmd(old & ~clr); 538 *pmdp = __pmd((old & ~clr) | set);
537#endif 539#endif
538 if (old & _PAGE_HASHPTE) 540 if (old & _PAGE_HASHPTE)
539 hpte_do_hugepage_flush(mm, addr, pmdp); 541 hpte_do_hugepage_flush(mm, addr, pmdp);
@@ -708,7 +710,7 @@ void set_pmd_at(struct mm_struct *mm, unsigned long addr,
708void pmdp_invalidate(struct vm_area_struct *vma, unsigned long address, 710void pmdp_invalidate(struct vm_area_struct *vma, unsigned long address,
709 pmd_t *pmdp) 711 pmd_t *pmdp)
710{ 712{
711 pmd_hugepage_update(vma->vm_mm, address, pmdp, _PAGE_PRESENT); 713 pmd_hugepage_update(vma->vm_mm, address, pmdp, _PAGE_PRESENT, 0);
712} 714}
713 715
714/* 716/*
@@ -835,7 +837,7 @@ pmd_t pmdp_get_and_clear(struct mm_struct *mm,
835 unsigned long old; 837 unsigned long old;
836 pgtable_t *pgtable_slot; 838 pgtable_t *pgtable_slot;
837 839
838 old = pmd_hugepage_update(mm, addr, pmdp, ~0UL); 840 old = pmd_hugepage_update(mm, addr, pmdp, ~0UL, 0);
839 old_pmd = __pmd(old); 841 old_pmd = __pmd(old);
840 /* 842 /*
841 * We have pmd == none and we are holding page_table_lock. 843 * We have pmd == none and we are holding page_table_lock.
diff --git a/arch/powerpc/mm/subpage-prot.c b/arch/powerpc/mm/subpage-prot.c
index a770df2dae70..6c0b1f5f8d2c 100644
--- a/arch/powerpc/mm/subpage-prot.c
+++ b/arch/powerpc/mm/subpage-prot.c
@@ -78,7 +78,7 @@ static void hpte_flush_range(struct mm_struct *mm, unsigned long addr,
78 pte = pte_offset_map_lock(mm, pmd, addr, &ptl); 78 pte = pte_offset_map_lock(mm, pmd, addr, &ptl);
79 arch_enter_lazy_mmu_mode(); 79 arch_enter_lazy_mmu_mode();
80 for (; npages > 0; --npages) { 80 for (; npages > 0; --npages) {
81 pte_update(mm, addr, pte, 0, 0); 81 pte_update(mm, addr, pte, 0, 0, 0);
82 addr += PAGE_SIZE; 82 addr += PAGE_SIZE;
83 ++pte; 83 ++pte;
84 } 84 }
diff --git a/arch/powerpc/platforms/powernv/eeh-ioda.c b/arch/powerpc/platforms/powernv/eeh-ioda.c
index e1e71618b70c..f51474336460 100644
--- a/arch/powerpc/platforms/powernv/eeh-ioda.c
+++ b/arch/powerpc/platforms/powernv/eeh-ioda.c
@@ -44,7 +44,8 @@ static int ioda_eeh_event(struct notifier_block *nb,
44 44
45 /* We simply send special EEH event */ 45 /* We simply send special EEH event */
46 if ((changed_evts & OPAL_EVENT_PCI_ERROR) && 46 if ((changed_evts & OPAL_EVENT_PCI_ERROR) &&
47 (events & OPAL_EVENT_PCI_ERROR)) 47 (events & OPAL_EVENT_PCI_ERROR) &&
48 eeh_enabled())
48 eeh_send_failure_event(NULL); 49 eeh_send_failure_event(NULL);
49 50
50 return 0; 51 return 0;
@@ -489,8 +490,7 @@ static int ioda_eeh_bridge_reset(struct pci_controller *hose,
489static int ioda_eeh_reset(struct eeh_pe *pe, int option) 490static int ioda_eeh_reset(struct eeh_pe *pe, int option)
490{ 491{
491 struct pci_controller *hose = pe->phb; 492 struct pci_controller *hose = pe->phb;
492 struct eeh_dev *edev; 493 struct pci_bus *bus;
493 struct pci_dev *dev;
494 int ret; 494 int ret;
495 495
496 /* 496 /*
@@ -519,31 +519,11 @@ static int ioda_eeh_reset(struct eeh_pe *pe, int option)
519 if (pe->type & EEH_PE_PHB) { 519 if (pe->type & EEH_PE_PHB) {
520 ret = ioda_eeh_phb_reset(hose, option); 520 ret = ioda_eeh_phb_reset(hose, option);
521 } else { 521 } else {
522 if (pe->type & EEH_PE_DEVICE) { 522 bus = eeh_pe_bus_get(pe);
523 /* 523 if (pci_is_root_bus(bus))
524 * If it's device PE, we didn't refer to the parent
525 * PCI bus yet. So we have to figure it out indirectly.
526 */
527 edev = list_first_entry(&pe->edevs,
528 struct eeh_dev, list);
529 dev = eeh_dev_to_pci_dev(edev);
530 dev = dev->bus->self;
531 } else {
532 /*
533 * If it's bus PE, the parent PCI bus is already there
534 * and just pick it up.
535 */
536 dev = pe->bus->self;
537 }
538
539 /*
540 * Do reset based on the fact that the direct upstream bridge
541 * is root bridge (port) or not.
542 */
543 if (dev->bus->number == 0)
544 ret = ioda_eeh_root_reset(hose, option); 524 ret = ioda_eeh_root_reset(hose, option);
545 else 525 else
546 ret = ioda_eeh_bridge_reset(hose, dev, option); 526 ret = ioda_eeh_bridge_reset(hose, bus->self, option);
547 } 527 }
548 528
549 return ret; 529 return ret;
diff --git a/arch/powerpc/platforms/powernv/eeh-powernv.c b/arch/powerpc/platforms/powernv/eeh-powernv.c
index a79fddc5e74e..a59788e83b8b 100644
--- a/arch/powerpc/platforms/powernv/eeh-powernv.c
+++ b/arch/powerpc/platforms/powernv/eeh-powernv.c
@@ -145,7 +145,7 @@ static int powernv_eeh_dev_probe(struct pci_dev *dev, void *flag)
145 * Enable EEH explicitly so that we will do EEH check 145 * Enable EEH explicitly so that we will do EEH check
146 * while accessing I/O stuff 146 * while accessing I/O stuff
147 */ 147 */
148 eeh_subsystem_enabled = 1; 148 eeh_set_enable(true);
149 149
150 /* Save memory bars */ 150 /* Save memory bars */
151 eeh_save_bars(edev); 151 eeh_save_bars(edev);
diff --git a/arch/powerpc/platforms/pseries/eeh_pseries.c b/arch/powerpc/platforms/pseries/eeh_pseries.c
index 9ef3cc8ebc11..8a8f0472d98f 100644
--- a/arch/powerpc/platforms/pseries/eeh_pseries.c
+++ b/arch/powerpc/platforms/pseries/eeh_pseries.c
@@ -265,7 +265,7 @@ static void *pseries_eeh_of_probe(struct device_node *dn, void *flag)
265 enable = 1; 265 enable = 1;
266 266
267 if (enable) { 267 if (enable) {
268 eeh_subsystem_enabled = 1; 268 eeh_set_enable(true);
269 eeh_add_to_parent_pe(edev); 269 eeh_add_to_parent_pe(edev);
270 270
271 pr_debug("%s: EEH enabled on %s PHB#%d-PE#%x, config addr#%x\n", 271 pr_debug("%s: EEH enabled on %s PHB#%d-PE#%x, config addr#%x\n",
diff --git a/arch/powerpc/platforms/pseries/pci.c b/arch/powerpc/platforms/pseries/pci.c
index 70670a2d9cf2..c413ec158ff5 100644
--- a/arch/powerpc/platforms/pseries/pci.c
+++ b/arch/powerpc/platforms/pseries/pci.c
@@ -113,7 +113,8 @@ int pseries_root_bridge_prepare(struct pci_host_bridge *bridge)
113{ 113{
114 struct device_node *dn, *pdn; 114 struct device_node *dn, *pdn;
115 struct pci_bus *bus; 115 struct pci_bus *bus;
116 const __be32 *pcie_link_speed_stats; 116 u32 pcie_link_speed_stats[2];
117 int rc;
117 118
118 bus = bridge->bus; 119 bus = bridge->bus;
119 120
@@ -122,38 +123,45 @@ int pseries_root_bridge_prepare(struct pci_host_bridge *bridge)
122 return 0; 123 return 0;
123 124
124 for (pdn = dn; pdn != NULL; pdn = of_get_next_parent(pdn)) { 125 for (pdn = dn; pdn != NULL; pdn = of_get_next_parent(pdn)) {
125 pcie_link_speed_stats = of_get_property(pdn, 126 rc = of_property_read_u32_array(pdn,
126 "ibm,pcie-link-speed-stats", NULL); 127 "ibm,pcie-link-speed-stats",
127 if (pcie_link_speed_stats) 128 &pcie_link_speed_stats[0], 2);
129 if (!rc)
128 break; 130 break;
129 } 131 }
130 132
131 of_node_put(pdn); 133 of_node_put(pdn);
132 134
133 if (!pcie_link_speed_stats) { 135 if (rc) {
134 pr_err("no ibm,pcie-link-speed-stats property\n"); 136 pr_err("no ibm,pcie-link-speed-stats property\n");
135 return 0; 137 return 0;
136 } 138 }
137 139
138 switch (be32_to_cpup(pcie_link_speed_stats)) { 140 switch (pcie_link_speed_stats[0]) {
139 case 0x01: 141 case 0x01:
140 bus->max_bus_speed = PCIE_SPEED_2_5GT; 142 bus->max_bus_speed = PCIE_SPEED_2_5GT;
141 break; 143 break;
142 case 0x02: 144 case 0x02:
143 bus->max_bus_speed = PCIE_SPEED_5_0GT; 145 bus->max_bus_speed = PCIE_SPEED_5_0GT;
144 break; 146 break;
147 case 0x04:
148 bus->max_bus_speed = PCIE_SPEED_8_0GT;
149 break;
145 default: 150 default:
146 bus->max_bus_speed = PCI_SPEED_UNKNOWN; 151 bus->max_bus_speed = PCI_SPEED_UNKNOWN;
147 break; 152 break;
148 } 153 }
149 154
150 switch (be32_to_cpup(pcie_link_speed_stats)) { 155 switch (pcie_link_speed_stats[1]) {
151 case 0x01: 156 case 0x01:
152 bus->cur_bus_speed = PCIE_SPEED_2_5GT; 157 bus->cur_bus_speed = PCIE_SPEED_2_5GT;
153 break; 158 break;
154 case 0x02: 159 case 0x02:
155 bus->cur_bus_speed = PCIE_SPEED_5_0GT; 160 bus->cur_bus_speed = PCIE_SPEED_5_0GT;
156 break; 161 break;
162 case 0x04:
163 bus->cur_bus_speed = PCIE_SPEED_8_0GT;
164 break;
157 default: 165 default:
158 bus->cur_bus_speed = PCI_SPEED_UNKNOWN; 166 bus->cur_bus_speed = PCI_SPEED_UNKNOWN;
159 break; 167 break;
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/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..895604f2e916 100644
--- a/arch/x86/kernel/cpu/perf_event.c
+++ b/arch/x86/kernel/cpu/perf_event.c
@@ -1521,6 +1521,8 @@ static int __init init_hw_perf_events(void)
1521 1521
1522 pr_cont("%s PMU driver.\n", x86_pmu.name); 1522 pr_cont("%s PMU driver.\n", x86_pmu.name);
1523 1523
1524 x86_pmu.attr_rdpmc = 1; /* enable userspace RDPMC usage by default */
1525
1524 for (quirk = x86_pmu.quirks; quirk; quirk = quirk->next) 1526 for (quirk = x86_pmu.quirks; quirk; quirk = quirk->next)
1525 quirk->func(); 1527 quirk->func();
1526 1528
@@ -1534,7 +1536,6 @@ static int __init init_hw_perf_events(void)
1534 __EVENT_CONSTRAINT(0, (1ULL << x86_pmu.num_counters) - 1, 1536 __EVENT_CONSTRAINT(0, (1ULL << x86_pmu.num_counters) - 1,
1535 0, x86_pmu.num_counters, 0, 0); 1537 0, x86_pmu.num_counters, 0, 0);
1536 1538
1537 x86_pmu.attr_rdpmc = 1; /* enable userspace RDPMC usage by default */
1538 x86_pmu_format_group.attrs = x86_pmu.format_attrs; 1539 x86_pmu_format_group.attrs = x86_pmu.format_attrs;
1539 1540
1540 if (x86_pmu.event_attrs) 1541 if (x86_pmu.event_attrs)
@@ -1820,9 +1821,12 @@ static ssize_t set_attr_rdpmc(struct device *cdev,
1820 if (ret) 1821 if (ret)
1821 return ret; 1822 return ret;
1822 1823
1824 if (x86_pmu.attr_rdpmc_broken)
1825 return -ENOTSUPP;
1826
1823 if (!!val != !!x86_pmu.attr_rdpmc) { 1827 if (!!val != !!x86_pmu.attr_rdpmc) {
1824 x86_pmu.attr_rdpmc = !!val; 1828 x86_pmu.attr_rdpmc = !!val;
1825 smp_call_function(change_rdpmc, (void *)val, 1); 1829 on_each_cpu(change_rdpmc, (void *)val, 1);
1826 } 1830 }
1827 1831
1828 return count; 1832 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/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/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/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/dma-buf.c b/drivers/base/dma-buf.c
index 1e16cbd61da2..61d6d62cc0d3 100644
--- a/drivers/base/dma-buf.c
+++ b/drivers/base/dma-buf.c
@@ -616,36 +616,35 @@ static int dma_buf_describe(struct seq_file *s)
616 if (ret) 616 if (ret)
617 return ret; 617 return ret;
618 618
619 seq_printf(s, "\nDma-buf Objects:\n"); 619 seq_puts(s, "\nDma-buf Objects:\n");
620 seq_printf(s, "\texp_name\tsize\tflags\tmode\tcount\n"); 620 seq_puts(s, "size\tflags\tmode\tcount\texp_name\n");
621 621
622 list_for_each_entry(buf_obj, &db_list.head, list_node) { 622 list_for_each_entry(buf_obj, &db_list.head, list_node) {
623 ret = mutex_lock_interruptible(&buf_obj->lock); 623 ret = mutex_lock_interruptible(&buf_obj->lock);
624 624
625 if (ret) { 625 if (ret) {
626 seq_printf(s, 626 seq_puts(s,
627 "\tERROR locking buffer object: skipping\n"); 627 "\tERROR locking buffer object: skipping\n");
628 continue; 628 continue;
629 } 629 }
630 630
631 seq_printf(s, "\t"); 631 seq_printf(s, "%08zu\t%08x\t%08x\t%08ld\t%s\n",
632 632 buf_obj->size,
633 seq_printf(s, "\t%s\t%08zu\t%08x\t%08x\t%08ld\n",
634 buf_obj->exp_name, buf_obj->size,
635 buf_obj->file->f_flags, buf_obj->file->f_mode, 633 buf_obj->file->f_flags, buf_obj->file->f_mode,
636 (long)(buf_obj->file->f_count.counter)); 634 (long)(buf_obj->file->f_count.counter),
635 buf_obj->exp_name);
637 636
638 seq_printf(s, "\t\tAttached Devices:\n"); 637 seq_puts(s, "\tAttached Devices:\n");
639 attach_count = 0; 638 attach_count = 0;
640 639
641 list_for_each_entry(attach_obj, &buf_obj->attachments, node) { 640 list_for_each_entry(attach_obj, &buf_obj->attachments, node) {
642 seq_printf(s, "\t\t"); 641 seq_puts(s, "\t");
643 642
644 seq_printf(s, "%s\n", attach_obj->dev->init_name); 643 seq_printf(s, "%s\n", dev_name(attach_obj->dev));
645 attach_count++; 644 attach_count++;
646 } 645 }
647 646
648 seq_printf(s, "\n\t\tTotal %d devices attached\n", 647 seq_printf(s, "Total %d devices attached\n\n",
649 attach_count); 648 attach_count);
650 649
651 count++; 650 count++;
diff --git a/drivers/bus/imx-weim.c b/drivers/bus/imx-weim.c
index 3ef58c8dbf11..f8ee13c7bf7b 100644
--- a/drivers/bus/imx-weim.c
+++ b/drivers/bus/imx-weim.c
@@ -11,6 +11,9 @@
11#include <linux/clk.h> 11#include <linux/clk.h>
12#include <linux/io.h> 12#include <linux/io.h>
13#include <linux/of_device.h> 13#include <linux/of_device.h>
14#include <linux/mfd/syscon.h>
15#include <linux/mfd/syscon/imx6q-iomuxc-gpr.h>
16#include <linux/regmap.h>
14 17
15struct imx_weim_devtype { 18struct imx_weim_devtype {
16 unsigned int cs_count; 19 unsigned int cs_count;
@@ -56,6 +59,55 @@ static const struct of_device_id weim_id_table[] = {
56}; 59};
57MODULE_DEVICE_TABLE(of, weim_id_table); 60MODULE_DEVICE_TABLE(of, weim_id_table);
58 61
62static int __init imx_weim_gpr_setup(struct platform_device *pdev)
63{
64 struct device_node *np = pdev->dev.of_node;
65 struct property *prop;
66 const __be32 *p;
67 struct regmap *gpr;
68 u32 gprvals[4] = {
69 05, /* CS0(128M) CS1(0M) CS2(0M) CS3(0M) */
70 033, /* CS0(64M) CS1(64M) CS2(0M) CS3(0M) */
71 0113, /* CS0(64M) CS1(32M) CS2(32M) CS3(0M) */
72 01111, /* CS0(32M) CS1(32M) CS2(32M) CS3(32M) */
73 };
74 u32 gprval = 0;
75 u32 val;
76 int cs = 0;
77 int i = 0;
78
79 gpr = syscon_regmap_lookup_by_phandle(np, "fsl,weim-cs-gpr");
80 if (IS_ERR(gpr)) {
81 dev_dbg(&pdev->dev, "failed to find weim-cs-gpr\n");
82 return 0;
83 }
84
85 of_property_for_each_u32(np, "ranges", prop, p, val) {
86 if (i % 4 == 0) {
87 cs = val;
88 } else if (i % 4 == 3 && val) {
89 val = (val / SZ_32M) | 1;
90 gprval |= val << cs * 3;
91 }
92 i++;
93 }
94
95 if (i == 0 || i % 4)
96 goto err;
97
98 for (i = 0; i < ARRAY_SIZE(gprvals); i++) {
99 if (gprval == gprvals[i]) {
100 /* Found it. Set up IOMUXC_GPR1[11:0] with it. */
101 regmap_update_bits(gpr, IOMUXC_GPR1, 0xfff, gprval);
102 return 0;
103 }
104 }
105
106err:
107 dev_err(&pdev->dev, "Invalid 'ranges' configuration\n");
108 return -EINVAL;
109}
110
59/* Parse and set the timing for this device. */ 111/* Parse and set the timing for this device. */
60static int __init weim_timing_setup(struct device_node *np, void __iomem *base, 112static int __init weim_timing_setup(struct device_node *np, void __iomem *base,
61 const struct imx_weim_devtype *devtype) 113 const struct imx_weim_devtype *devtype)
@@ -92,6 +144,12 @@ static int __init weim_parse_dt(struct platform_device *pdev,
92 struct device_node *child; 144 struct device_node *child;
93 int ret; 145 int ret;
94 146
147 if (devtype == &imx50_weim_devtype) {
148 ret = imx_weim_gpr_setup(pdev);
149 if (ret)
150 return ret;
151 }
152
95 for_each_child_of_node(pdev->dev.of_node, child) { 153 for_each_child_of_node(pdev->dev.of_node, child) {
96 if (!child->name) 154 if (!child->name)
97 continue; 155 continue;
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..e90816105921 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -34,8 +34,10 @@
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
40
39 41
40#define FRAC_BITS 8 42#define FRAC_BITS 8
41#define int_tofp(X) ((int64_t)(X) << FRAC_BITS) 43#define int_tofp(X) ((int64_t)(X) << FRAC_BITS)
@@ -357,7 +359,7 @@ static int byt_get_min_pstate(void)
357{ 359{
358 u64 value; 360 u64 value;
359 rdmsrl(BYT_RATIOS, value); 361 rdmsrl(BYT_RATIOS, value);
360 return value & 0xFF; 362 return (value >> 8) & 0xFF;
361} 363}
362 364
363static int byt_get_max_pstate(void) 365static int byt_get_max_pstate(void)
@@ -367,6 +369,13 @@ static int byt_get_max_pstate(void)
367 return (value >> 16) & 0xFF; 369 return (value >> 16) & 0xFF;
368} 370}
369 371
372static int byt_get_turbo_pstate(void)
373{
374 u64 value;
375 rdmsrl(BYT_TURBO_RATIOS, value);
376 return value & 0x3F;
377}
378
370static void byt_set_pstate(struct cpudata *cpudata, int pstate) 379static void byt_set_pstate(struct cpudata *cpudata, int pstate)
371{ 380{
372 u64 val; 381 u64 val;
@@ -469,7 +478,7 @@ static struct cpu_defaults byt_params = {
469 .funcs = { 478 .funcs = {
470 .get_max = byt_get_max_pstate, 479 .get_max = byt_get_max_pstate,
471 .get_min = byt_get_min_pstate, 480 .get_min = byt_get_min_pstate,
472 .get_turbo = byt_get_max_pstate, 481 .get_turbo = byt_get_turbo_pstate,
473 .set = byt_set_pstate, 482 .set = byt_set_pstate,
474 .get_vid = byt_get_vid, 483 .get_vid = byt_get_vid,
475 }, 484 },
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/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
index dffc836144cc..f4dc9b7a3831 100644
--- a/drivers/gpu/drm/drm_ioctl.c
+++ b/drivers/gpu/drm/drm_ioctl.c
@@ -296,6 +296,18 @@ int drm_getcap(struct drm_device *dev, void *data, struct drm_file *file_priv)
296 case DRM_CAP_ASYNC_PAGE_FLIP: 296 case DRM_CAP_ASYNC_PAGE_FLIP:
297 req->value = dev->mode_config.async_page_flip; 297 req->value = dev->mode_config.async_page_flip;
298 break; 298 break;
299 case DRM_CAP_CURSOR_WIDTH:
300 if (dev->mode_config.cursor_width)
301 req->value = dev->mode_config.cursor_width;
302 else
303 req->value = 64;
304 break;
305 case DRM_CAP_CURSOR_HEIGHT:
306 if (dev->mode_config.cursor_height)
307 req->value = dev->mode_config.cursor_height;
308 else
309 req->value = 64;
310 break;
299 default: 311 default:
300 return -EINVAL; 312 return -EINVAL;
301 } 313 }
diff --git a/drivers/gpu/drm/i2c/tda998x_drv.c b/drivers/gpu/drm/i2c/tda998x_drv.c
index fa18cf374470..faa77f543a07 100644
--- a/drivers/gpu/drm/i2c/tda998x_drv.c
+++ b/drivers/gpu/drm/i2c/tda998x_drv.c
@@ -1151,8 +1151,10 @@ tda998x_encoder_init(struct i2c_client *client,
1151 1151
1152 priv->current_page = 0xff; 1152 priv->current_page = 0xff;
1153 priv->cec = i2c_new_dummy(client->adapter, 0x34); 1153 priv->cec = i2c_new_dummy(client->adapter, 0x34);
1154 if (!priv->cec) 1154 if (!priv->cec) {
1155 kfree(priv);
1155 return -ENODEV; 1156 return -ENODEV;
1157 }
1156 priv->dpms = DRM_MODE_DPMS_OFF; 1158 priv->dpms = DRM_MODE_DPMS_OFF;
1157 1159
1158 encoder_slave->slave_priv = priv; 1160 encoder_slave->slave_priv = priv;
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 9fa24347963a..4c1672809493 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -8586,6 +8586,20 @@ static int intel_gen7_queue_flip(struct drm_device *dev,
8586 if (ring->id == RCS) 8586 if (ring->id == RCS)
8587 len += 6; 8587 len += 6;
8588 8588
8589 /*
8590 * BSpec MI_DISPLAY_FLIP for IVB:
8591 * "The full packet must be contained within the same cache line."
8592 *
8593 * Currently the LRI+SRM+MI_DISPLAY_FLIP all fit within the same
8594 * cacheline, if we ever start emitting more commands before
8595 * the MI_DISPLAY_FLIP we may need to first emit everything else,
8596 * then do the cacheline alignment, and finally emit the
8597 * MI_DISPLAY_FLIP.
8598 */
8599 ret = intel_ring_cacheline_align(ring);
8600 if (ret)
8601 goto err_unpin;
8602
8589 ret = intel_ring_begin(ring, len); 8603 ret = intel_ring_begin(ring, len);
8590 if (ret) 8604 if (ret)
8591 goto err_unpin; 8605 goto err_unpin;
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index 2f517b85b3f4..57552eb386b0 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -537,6 +537,7 @@ intel_dp_aux_native_write(struct intel_dp *intel_dp,
537 uint8_t msg[20]; 537 uint8_t msg[20];
538 int msg_bytes; 538 int msg_bytes;
539 uint8_t ack; 539 uint8_t ack;
540 int retry;
540 541
541 if (WARN_ON(send_bytes > 16)) 542 if (WARN_ON(send_bytes > 16))
542 return -E2BIG; 543 return -E2BIG;
@@ -548,19 +549,21 @@ intel_dp_aux_native_write(struct intel_dp *intel_dp,
548 msg[3] = send_bytes - 1; 549 msg[3] = send_bytes - 1;
549 memcpy(&msg[4], send, send_bytes); 550 memcpy(&msg[4], send, send_bytes);
550 msg_bytes = send_bytes + 4; 551 msg_bytes = send_bytes + 4;
551 for (;;) { 552 for (retry = 0; retry < 7; retry++) {
552 ret = intel_dp_aux_ch(intel_dp, msg, msg_bytes, &ack, 1); 553 ret = intel_dp_aux_ch(intel_dp, msg, msg_bytes, &ack, 1);
553 if (ret < 0) 554 if (ret < 0)
554 return ret; 555 return ret;
555 ack >>= 4; 556 ack >>= 4;
556 if ((ack & DP_AUX_NATIVE_REPLY_MASK) == DP_AUX_NATIVE_REPLY_ACK) 557 if ((ack & DP_AUX_NATIVE_REPLY_MASK) == DP_AUX_NATIVE_REPLY_ACK)
557 break; 558 return send_bytes;
558 else if ((ack & DP_AUX_NATIVE_REPLY_MASK) == DP_AUX_NATIVE_REPLY_DEFER) 559 else if ((ack & DP_AUX_NATIVE_REPLY_MASK) == DP_AUX_NATIVE_REPLY_DEFER)
559 udelay(100); 560 usleep_range(400, 500);
560 else 561 else
561 return -EIO; 562 return -EIO;
562 } 563 }
563 return send_bytes; 564
565 DRM_ERROR("too many retries, giving up\n");
566 return -EIO;
564} 567}
565 568
566/* Write a single byte to the aux channel in native mode */ 569/* Write a single byte to the aux channel in native mode */
@@ -582,6 +585,7 @@ intel_dp_aux_native_read(struct intel_dp *intel_dp,
582 int reply_bytes; 585 int reply_bytes;
583 uint8_t ack; 586 uint8_t ack;
584 int ret; 587 int ret;
588 int retry;
585 589
586 if (WARN_ON(recv_bytes > 19)) 590 if (WARN_ON(recv_bytes > 19))
587 return -E2BIG; 591 return -E2BIG;
@@ -595,7 +599,7 @@ intel_dp_aux_native_read(struct intel_dp *intel_dp,
595 msg_bytes = 4; 599 msg_bytes = 4;
596 reply_bytes = recv_bytes + 1; 600 reply_bytes = recv_bytes + 1;
597 601
598 for (;;) { 602 for (retry = 0; retry < 7; retry++) {
599 ret = intel_dp_aux_ch(intel_dp, msg, msg_bytes, 603 ret = intel_dp_aux_ch(intel_dp, msg, msg_bytes,
600 reply, reply_bytes); 604 reply, reply_bytes);
601 if (ret == 0) 605 if (ret == 0)
@@ -608,10 +612,13 @@ intel_dp_aux_native_read(struct intel_dp *intel_dp,
608 return ret - 1; 612 return ret - 1;
609 } 613 }
610 else if ((ack & DP_AUX_NATIVE_REPLY_MASK) == DP_AUX_NATIVE_REPLY_DEFER) 614 else if ((ack & DP_AUX_NATIVE_REPLY_MASK) == DP_AUX_NATIVE_REPLY_DEFER)
611 udelay(100); 615 usleep_range(400, 500);
612 else 616 else
613 return -EIO; 617 return -EIO;
614 } 618 }
619
620 DRM_ERROR("too many retries, giving up\n");
621 return -EIO;
615} 622}
616 623
617static int 624static int
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
index b7f1742caf87..31b36c5ac894 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.c
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
@@ -1653,6 +1653,27 @@ int intel_ring_begin(struct intel_ring_buffer *ring,
1653 return 0; 1653 return 0;
1654} 1654}
1655 1655
1656/* Align the ring tail to a cacheline boundary */
1657int intel_ring_cacheline_align(struct intel_ring_buffer *ring)
1658{
1659 int num_dwords = (64 - (ring->tail & 63)) / sizeof(uint32_t);
1660 int ret;
1661
1662 if (num_dwords == 0)
1663 return 0;
1664
1665 ret = intel_ring_begin(ring, num_dwords);
1666 if (ret)
1667 return ret;
1668
1669 while (num_dwords--)
1670 intel_ring_emit(ring, MI_NOOP);
1671
1672 intel_ring_advance(ring);
1673
1674 return 0;
1675}
1676
1656void intel_ring_init_seqno(struct intel_ring_buffer *ring, u32 seqno) 1677void intel_ring_init_seqno(struct intel_ring_buffer *ring, u32 seqno)
1657{ 1678{
1658 struct drm_i915_private *dev_priv = ring->dev->dev_private; 1679 struct drm_i915_private *dev_priv = ring->dev->dev_private;
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.h b/drivers/gpu/drm/i915/intel_ringbuffer.h
index 71a73f4fe252..0b243ce33714 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.h
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.h
@@ -233,6 +233,7 @@ intel_write_status_page(struct intel_ring_buffer *ring,
233void intel_cleanup_ring_buffer(struct intel_ring_buffer *ring); 233void intel_cleanup_ring_buffer(struct intel_ring_buffer *ring);
234 234
235int __must_check intel_ring_begin(struct intel_ring_buffer *ring, int n); 235int __must_check intel_ring_begin(struct intel_ring_buffer *ring, int n);
236int __must_check intel_ring_cacheline_align(struct intel_ring_buffer *ring);
236static inline void intel_ring_emit(struct intel_ring_buffer *ring, 237static inline void intel_ring_emit(struct intel_ring_buffer *ring,
237 u32 data) 238 u32 data)
238{ 239{
diff --git a/drivers/gpu/drm/nouveau/Makefile b/drivers/gpu/drm/nouveau/Makefile
index e88145ba1bf5..d310c195bdfe 100644
--- a/drivers/gpu/drm/nouveau/Makefile
+++ b/drivers/gpu/drm/nouveau/Makefile
@@ -141,6 +141,7 @@ nouveau-y += core/subdev/mc/base.o
141nouveau-y += core/subdev/mc/nv04.o 141nouveau-y += core/subdev/mc/nv04.o
142nouveau-y += core/subdev/mc/nv40.o 142nouveau-y += core/subdev/mc/nv40.o
143nouveau-y += core/subdev/mc/nv44.o 143nouveau-y += core/subdev/mc/nv44.o
144nouveau-y += core/subdev/mc/nv4c.o
144nouveau-y += core/subdev/mc/nv50.o 145nouveau-y += core/subdev/mc/nv50.o
145nouveau-y += core/subdev/mc/nv94.o 146nouveau-y += core/subdev/mc/nv94.o
146nouveau-y += core/subdev/mc/nv98.o 147nouveau-y += core/subdev/mc/nv98.o
diff --git a/drivers/gpu/drm/nouveau/core/engine/device/nv40.c b/drivers/gpu/drm/nouveau/core/engine/device/nv40.c
index 1b653dd74a70..08b88591ed60 100644
--- a/drivers/gpu/drm/nouveau/core/engine/device/nv40.c
+++ b/drivers/gpu/drm/nouveau/core/engine/device/nv40.c
@@ -311,7 +311,7 @@ nv40_identify(struct nouveau_device *device)
311 device->oclass[NVDEV_SUBDEV_CLOCK ] = &nv40_clock_oclass; 311 device->oclass[NVDEV_SUBDEV_CLOCK ] = &nv40_clock_oclass;
312 device->oclass[NVDEV_SUBDEV_THERM ] = &nv40_therm_oclass; 312 device->oclass[NVDEV_SUBDEV_THERM ] = &nv40_therm_oclass;
313 device->oclass[NVDEV_SUBDEV_DEVINIT] = nv1a_devinit_oclass; 313 device->oclass[NVDEV_SUBDEV_DEVINIT] = nv1a_devinit_oclass;
314 device->oclass[NVDEV_SUBDEV_MC ] = nv44_mc_oclass; 314 device->oclass[NVDEV_SUBDEV_MC ] = nv4c_mc_oclass;
315 device->oclass[NVDEV_SUBDEV_BUS ] = nv31_bus_oclass; 315 device->oclass[NVDEV_SUBDEV_BUS ] = nv31_bus_oclass;
316 device->oclass[NVDEV_SUBDEV_TIMER ] = &nv04_timer_oclass; 316 device->oclass[NVDEV_SUBDEV_TIMER ] = &nv04_timer_oclass;
317 device->oclass[NVDEV_SUBDEV_FB ] = nv46_fb_oclass; 317 device->oclass[NVDEV_SUBDEV_FB ] = nv46_fb_oclass;
@@ -334,7 +334,7 @@ nv40_identify(struct nouveau_device *device)
334 device->oclass[NVDEV_SUBDEV_CLOCK ] = &nv40_clock_oclass; 334 device->oclass[NVDEV_SUBDEV_CLOCK ] = &nv40_clock_oclass;
335 device->oclass[NVDEV_SUBDEV_THERM ] = &nv40_therm_oclass; 335 device->oclass[NVDEV_SUBDEV_THERM ] = &nv40_therm_oclass;
336 device->oclass[NVDEV_SUBDEV_DEVINIT] = nv1a_devinit_oclass; 336 device->oclass[NVDEV_SUBDEV_DEVINIT] = nv1a_devinit_oclass;
337 device->oclass[NVDEV_SUBDEV_MC ] = nv44_mc_oclass; 337 device->oclass[NVDEV_SUBDEV_MC ] = nv4c_mc_oclass;
338 device->oclass[NVDEV_SUBDEV_BUS ] = nv31_bus_oclass; 338 device->oclass[NVDEV_SUBDEV_BUS ] = nv31_bus_oclass;
339 device->oclass[NVDEV_SUBDEV_TIMER ] = &nv04_timer_oclass; 339 device->oclass[NVDEV_SUBDEV_TIMER ] = &nv04_timer_oclass;
340 device->oclass[NVDEV_SUBDEV_FB ] = nv4e_fb_oclass; 340 device->oclass[NVDEV_SUBDEV_FB ] = nv4e_fb_oclass;
@@ -357,7 +357,7 @@ nv40_identify(struct nouveau_device *device)
357 device->oclass[NVDEV_SUBDEV_CLOCK ] = &nv40_clock_oclass; 357 device->oclass[NVDEV_SUBDEV_CLOCK ] = &nv40_clock_oclass;
358 device->oclass[NVDEV_SUBDEV_THERM ] = &nv40_therm_oclass; 358 device->oclass[NVDEV_SUBDEV_THERM ] = &nv40_therm_oclass;
359 device->oclass[NVDEV_SUBDEV_DEVINIT] = nv1a_devinit_oclass; 359 device->oclass[NVDEV_SUBDEV_DEVINIT] = nv1a_devinit_oclass;
360 device->oclass[NVDEV_SUBDEV_MC ] = nv44_mc_oclass; 360 device->oclass[NVDEV_SUBDEV_MC ] = nv4c_mc_oclass;
361 device->oclass[NVDEV_SUBDEV_BUS ] = nv31_bus_oclass; 361 device->oclass[NVDEV_SUBDEV_BUS ] = nv31_bus_oclass;
362 device->oclass[NVDEV_SUBDEV_TIMER ] = &nv04_timer_oclass; 362 device->oclass[NVDEV_SUBDEV_TIMER ] = &nv04_timer_oclass;
363 device->oclass[NVDEV_SUBDEV_FB ] = nv46_fb_oclass; 363 device->oclass[NVDEV_SUBDEV_FB ] = nv46_fb_oclass;
@@ -380,7 +380,7 @@ nv40_identify(struct nouveau_device *device)
380 device->oclass[NVDEV_SUBDEV_CLOCK ] = &nv40_clock_oclass; 380 device->oclass[NVDEV_SUBDEV_CLOCK ] = &nv40_clock_oclass;
381 device->oclass[NVDEV_SUBDEV_THERM ] = &nv40_therm_oclass; 381 device->oclass[NVDEV_SUBDEV_THERM ] = &nv40_therm_oclass;
382 device->oclass[NVDEV_SUBDEV_DEVINIT] = nv1a_devinit_oclass; 382 device->oclass[NVDEV_SUBDEV_DEVINIT] = nv1a_devinit_oclass;
383 device->oclass[NVDEV_SUBDEV_MC ] = nv44_mc_oclass; 383 device->oclass[NVDEV_SUBDEV_MC ] = nv4c_mc_oclass;
384 device->oclass[NVDEV_SUBDEV_BUS ] = nv31_bus_oclass; 384 device->oclass[NVDEV_SUBDEV_BUS ] = nv31_bus_oclass;
385 device->oclass[NVDEV_SUBDEV_TIMER ] = &nv04_timer_oclass; 385 device->oclass[NVDEV_SUBDEV_TIMER ] = &nv04_timer_oclass;
386 device->oclass[NVDEV_SUBDEV_FB ] = nv46_fb_oclass; 386 device->oclass[NVDEV_SUBDEV_FB ] = nv46_fb_oclass;
@@ -403,7 +403,7 @@ nv40_identify(struct nouveau_device *device)
403 device->oclass[NVDEV_SUBDEV_CLOCK ] = &nv40_clock_oclass; 403 device->oclass[NVDEV_SUBDEV_CLOCK ] = &nv40_clock_oclass;
404 device->oclass[NVDEV_SUBDEV_THERM ] = &nv40_therm_oclass; 404 device->oclass[NVDEV_SUBDEV_THERM ] = &nv40_therm_oclass;
405 device->oclass[NVDEV_SUBDEV_DEVINIT] = nv1a_devinit_oclass; 405 device->oclass[NVDEV_SUBDEV_DEVINIT] = nv1a_devinit_oclass;
406 device->oclass[NVDEV_SUBDEV_MC ] = nv44_mc_oclass; 406 device->oclass[NVDEV_SUBDEV_MC ] = nv4c_mc_oclass;
407 device->oclass[NVDEV_SUBDEV_BUS ] = nv31_bus_oclass; 407 device->oclass[NVDEV_SUBDEV_BUS ] = nv31_bus_oclass;
408 device->oclass[NVDEV_SUBDEV_TIMER ] = &nv04_timer_oclass; 408 device->oclass[NVDEV_SUBDEV_TIMER ] = &nv04_timer_oclass;
409 device->oclass[NVDEV_SUBDEV_FB ] = nv46_fb_oclass; 409 device->oclass[NVDEV_SUBDEV_FB ] = nv46_fb_oclass;
diff --git a/drivers/gpu/drm/nouveau/core/engine/disp/nv50.c b/drivers/gpu/drm/nouveau/core/engine/disp/nv50.c
index 940eaa5d8b9a..9ad722e4e087 100644
--- a/drivers/gpu/drm/nouveau/core/engine/disp/nv50.c
+++ b/drivers/gpu/drm/nouveau/core/engine/disp/nv50.c
@@ -1142,7 +1142,7 @@ nv50_disp_intr_unk20_2(struct nv50_disp_priv *priv, int head)
1142 if (conf != ~0) { 1142 if (conf != ~0) {
1143 if (outp.location == 0 && outp.type == DCB_OUTPUT_DP) { 1143 if (outp.location == 0 && outp.type == DCB_OUTPUT_DP) {
1144 u32 soff = (ffs(outp.or) - 1) * 0x08; 1144 u32 soff = (ffs(outp.or) - 1) * 0x08;
1145 u32 ctrl = nv_rd32(priv, 0x610798 + soff); 1145 u32 ctrl = nv_rd32(priv, 0x610794 + soff);
1146 u32 datarate; 1146 u32 datarate;
1147 1147
1148 switch ((ctrl & 0x000f0000) >> 16) { 1148 switch ((ctrl & 0x000f0000) >> 16) {
diff --git a/drivers/gpu/drm/nouveau/core/engine/fifo/nve0.c b/drivers/gpu/drm/nouveau/core/engine/fifo/nve0.c
index 9a850fe19515..54c1b5b471cd 100644
--- a/drivers/gpu/drm/nouveau/core/engine/fifo/nve0.c
+++ b/drivers/gpu/drm/nouveau/core/engine/fifo/nve0.c
@@ -112,7 +112,7 @@ nve0_fifo_runlist_update(struct nve0_fifo_priv *priv, u32 engine)
112 112
113 nv_wr32(priv, 0x002270, cur->addr >> 12); 113 nv_wr32(priv, 0x002270, cur->addr >> 12);
114 nv_wr32(priv, 0x002274, (engine << 20) | (p >> 3)); 114 nv_wr32(priv, 0x002274, (engine << 20) | (p >> 3));
115 if (!nv_wait(priv, 0x002284 + (engine * 4), 0x00100000, 0x00000000)) 115 if (!nv_wait(priv, 0x002284 + (engine * 8), 0x00100000, 0x00000000))
116 nv_error(priv, "runlist %d update timeout\n", engine); 116 nv_error(priv, "runlist %d update timeout\n", engine);
117 mutex_unlock(&nv_subdev(priv)->mutex); 117 mutex_unlock(&nv_subdev(priv)->mutex);
118} 118}
diff --git a/drivers/gpu/drm/nouveau/core/engine/graph/nv50.c b/drivers/gpu/drm/nouveau/core/engine/graph/nv50.c
index 30ed19c52e05..7a367c402978 100644
--- a/drivers/gpu/drm/nouveau/core/engine/graph/nv50.c
+++ b/drivers/gpu/drm/nouveau/core/engine/graph/nv50.c
@@ -539,7 +539,7 @@ nv50_priv_tp_trap(struct nv50_graph_priv *priv, int type, u32 ustatus_old,
539 ustatus &= ~0x04030000; 539 ustatus &= ~0x04030000;
540 } 540 }
541 if (ustatus && display) { 541 if (ustatus && display) {
542 nv_error("%s - TP%d:", name, i); 542 nv_error(priv, "%s - TP%d:", name, i);
543 nouveau_bitfield_print(nv50_mpc_traps, ustatus); 543 nouveau_bitfield_print(nv50_mpc_traps, ustatus);
544 pr_cont("\n"); 544 pr_cont("\n");
545 ustatus = 0; 545 ustatus = 0;
diff --git a/drivers/gpu/drm/nouveau/core/include/subdev/mc.h b/drivers/gpu/drm/nouveau/core/include/subdev/mc.h
index adc88b73d911..3c6738edd127 100644
--- a/drivers/gpu/drm/nouveau/core/include/subdev/mc.h
+++ b/drivers/gpu/drm/nouveau/core/include/subdev/mc.h
@@ -47,6 +47,7 @@ struct nouveau_mc_oclass {
47extern struct nouveau_oclass *nv04_mc_oclass; 47extern struct nouveau_oclass *nv04_mc_oclass;
48extern struct nouveau_oclass *nv40_mc_oclass; 48extern struct nouveau_oclass *nv40_mc_oclass;
49extern struct nouveau_oclass *nv44_mc_oclass; 49extern struct nouveau_oclass *nv44_mc_oclass;
50extern struct nouveau_oclass *nv4c_mc_oclass;
50extern struct nouveau_oclass *nv50_mc_oclass; 51extern struct nouveau_oclass *nv50_mc_oclass;
51extern struct nouveau_oclass *nv94_mc_oclass; 52extern struct nouveau_oclass *nv94_mc_oclass;
52extern struct nouveau_oclass *nv98_mc_oclass; 53extern struct nouveau_oclass *nv98_mc_oclass;
diff --git a/drivers/gpu/drm/nouveau/core/subdev/bios/base.c b/drivers/gpu/drm/nouveau/core/subdev/bios/base.c
index aa0fbbec7f08..ef0c9c4a8cc3 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/bios/base.c
+++ b/drivers/gpu/drm/nouveau/core/subdev/bios/base.c
@@ -130,6 +130,10 @@ nouveau_bios_shadow_prom(struct nouveau_bios *bios)
130 u16 pcir; 130 u16 pcir;
131 int i; 131 int i;
132 132
133 /* there is no prom on nv4x IGP's */
134 if (device->card_type == NV_40 && device->chipset >= 0x4c)
135 return;
136
133 /* enable access to rom */ 137 /* enable access to rom */
134 if (device->card_type >= NV_50) 138 if (device->card_type >= NV_50)
135 pcireg = 0x088050; 139 pcireg = 0x088050;
diff --git a/drivers/gpu/drm/nouveau/core/subdev/fb/nv1a.c b/drivers/gpu/drm/nouveau/core/subdev/fb/nv1a.c
index 9159a5ccee93..265d1253624a 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/fb/nv1a.c
+++ b/drivers/gpu/drm/nouveau/core/subdev/fb/nv1a.c
@@ -36,7 +36,7 @@ nv1a_fb_oclass = &(struct nv04_fb_impl) {
36 .fini = _nouveau_fb_fini, 36 .fini = _nouveau_fb_fini,
37 }, 37 },
38 .base.memtype = nv04_fb_memtype_valid, 38 .base.memtype = nv04_fb_memtype_valid,
39 .base.ram = &nv10_ram_oclass, 39 .base.ram = &nv1a_ram_oclass,
40 .tile.regions = 8, 40 .tile.regions = 8,
41 .tile.init = nv10_fb_tile_init, 41 .tile.init = nv10_fb_tile_init,
42 .tile.fini = nv10_fb_tile_fini, 42 .tile.fini = nv10_fb_tile_fini,
diff --git a/drivers/gpu/drm/nouveau/core/subdev/mc/nv04.h b/drivers/gpu/drm/nouveau/core/subdev/mc/nv04.h
index b0d5c31606c1..81a408e7d034 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/mc/nv04.h
+++ b/drivers/gpu/drm/nouveau/core/subdev/mc/nv04.h
@@ -14,6 +14,7 @@ int nv04_mc_ctor(struct nouveau_object *, struct nouveau_object *,
14extern const struct nouveau_mc_intr nv04_mc_intr[]; 14extern const struct nouveau_mc_intr nv04_mc_intr[];
15int nv04_mc_init(struct nouveau_object *); 15int nv04_mc_init(struct nouveau_object *);
16void nv40_mc_msi_rearm(struct nouveau_mc *); 16void nv40_mc_msi_rearm(struct nouveau_mc *);
17int nv44_mc_init(struct nouveau_object *object);
17int nv50_mc_init(struct nouveau_object *); 18int nv50_mc_init(struct nouveau_object *);
18extern const struct nouveau_mc_intr nv50_mc_intr[]; 19extern const struct nouveau_mc_intr nv50_mc_intr[];
19extern const struct nouveau_mc_intr nvc0_mc_intr[]; 20extern const struct nouveau_mc_intr nvc0_mc_intr[];
diff --git a/drivers/gpu/drm/nouveau/core/subdev/mc/nv44.c b/drivers/gpu/drm/nouveau/core/subdev/mc/nv44.c
index 3bfee5c6c4f2..cc4d0d2d886e 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/mc/nv44.c
+++ b/drivers/gpu/drm/nouveau/core/subdev/mc/nv44.c
@@ -24,7 +24,7 @@
24 24
25#include "nv04.h" 25#include "nv04.h"
26 26
27static int 27int
28nv44_mc_init(struct nouveau_object *object) 28nv44_mc_init(struct nouveau_object *object)
29{ 29{
30 struct nv04_mc_priv *priv = (void *)object; 30 struct nv04_mc_priv *priv = (void *)object;
diff --git a/drivers/gpu/drm/nouveau/core/subdev/mc/nv4c.c b/drivers/gpu/drm/nouveau/core/subdev/mc/nv4c.c
new file mode 100644
index 000000000000..a75c35ccf25c
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/core/subdev/mc/nv4c.c
@@ -0,0 +1,45 @@
1/*
2 * Copyright 2014 Ilia Mirkin
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 *
22 * Authors: Ilia Mirkin
23 */
24
25#include "nv04.h"
26
27static void
28nv4c_mc_msi_rearm(struct nouveau_mc *pmc)
29{
30 struct nv04_mc_priv *priv = (void *)pmc;
31 nv_wr08(priv, 0x088050, 0xff);
32}
33
34struct nouveau_oclass *
35nv4c_mc_oclass = &(struct nouveau_mc_oclass) {
36 .base.handle = NV_SUBDEV(MC, 0x4c),
37 .base.ofuncs = &(struct nouveau_ofuncs) {
38 .ctor = nv04_mc_ctor,
39 .dtor = _nouveau_mc_dtor,
40 .init = nv44_mc_init,
41 .fini = _nouveau_mc_fini,
42 },
43 .intr = nv04_mc_intr,
44 .msi_rearm = nv4c_mc_msi_rearm,
45}.base;
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/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
index 488686d490c0..4aed1714b9ab 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -1249,7 +1249,7 @@ nouveau_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem)
1249 mem->bus.is_iomem = !dev->agp->cant_use_aperture; 1249 mem->bus.is_iomem = !dev->agp->cant_use_aperture;
1250 } 1250 }
1251#endif 1251#endif
1252 if (!node->memtype) 1252 if (nv_device(drm->device)->card_type < NV_50 || !node->memtype)
1253 /* untiled */ 1253 /* untiled */
1254 break; 1254 break;
1255 /* fallthrough, tiled memory */ 1255 /* fallthrough, tiled memory */
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index 78c8e7146d56..89c484d8ac26 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -376,6 +376,8 @@ nouveau_drm_load(struct drm_device *dev, unsigned long flags)
376 if (ret) 376 if (ret)
377 goto fail_device; 377 goto fail_device;
378 378
379 dev->irq_enabled = true;
380
379 /* workaround an odd issue on nvc1 by disabling the device's 381 /* workaround an odd issue on nvc1 by disabling the device's
380 * nosnoop capability. hopefully won't cause issues until a 382 * nosnoop capability. hopefully won't cause issues until a
381 * better fix is found - assuming there is one... 383 * better fix is found - assuming there is one...
@@ -475,6 +477,7 @@ nouveau_drm_remove(struct pci_dev *pdev)
475 struct nouveau_drm *drm = nouveau_drm(dev); 477 struct nouveau_drm *drm = nouveau_drm(dev);
476 struct nouveau_object *device; 478 struct nouveau_object *device;
477 479
480 dev->irq_enabled = false;
478 device = drm->client.base.device; 481 device = drm->client.base.device;
479 drm_put_dev(dev); 482 drm_put_dev(dev);
480 483
diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c
index 81638d7f2eff..471347edc27e 100644
--- a/drivers/gpu/drm/nouveau/nouveau_vga.c
+++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
@@ -14,7 +14,9 @@ nouveau_vga_set_decode(void *priv, bool state)
14{ 14{
15 struct nouveau_device *device = nouveau_dev(priv); 15 struct nouveau_device *device = nouveau_dev(priv);
16 16
17 if (device->chipset >= 0x40) 17 if (device->card_type == NV_40 && device->chipset >= 0x4c)
18 nv_wr32(device, 0x088060, state);
19 else if (device->chipset >= 0x40)
18 nv_wr32(device, 0x088054, state); 20 nv_wr32(device, 0x088054, state);
19 else 21 else
20 nv_wr32(device, 0x001854, state); 22 nv_wr32(device, 0x001854, state);
diff --git a/drivers/gpu/drm/radeon/atombios_crtc.c b/drivers/gpu/drm/radeon/atombios_crtc.c
index a9338c85630f..0d19f4f94d5a 100644
--- a/drivers/gpu/drm/radeon/atombios_crtc.c
+++ b/drivers/gpu/drm/radeon/atombios_crtc.c
@@ -559,7 +559,7 @@ static u32 atombios_adjust_pll(struct drm_crtc *crtc,
559 u32 adjusted_clock = mode->clock; 559 u32 adjusted_clock = mode->clock;
560 int encoder_mode = atombios_get_encoder_mode(encoder); 560 int encoder_mode = atombios_get_encoder_mode(encoder);
561 u32 dp_clock = mode->clock; 561 u32 dp_clock = mode->clock;
562 int bpc = radeon_get_monitor_bpc(connector); 562 int bpc = radeon_crtc->bpc;
563 bool is_duallink = radeon_dig_monitor_is_duallink(encoder, mode->clock); 563 bool is_duallink = radeon_dig_monitor_is_duallink(encoder, mode->clock);
564 564
565 /* reset the pll flags */ 565 /* reset the pll flags */
@@ -1176,7 +1176,7 @@ static int dce4_crtc_do_set_base(struct drm_crtc *crtc,
1176 evergreen_tiling_fields(tiling_flags, &bankw, &bankh, &mtaspect, &tile_split); 1176 evergreen_tiling_fields(tiling_flags, &bankw, &bankh, &mtaspect, &tile_split);
1177 1177
1178 /* Set NUM_BANKS. */ 1178 /* Set NUM_BANKS. */
1179 if (rdev->family >= CHIP_BONAIRE) { 1179 if (rdev->family >= CHIP_TAHITI) {
1180 unsigned tileb, index, num_banks, tile_split_bytes; 1180 unsigned tileb, index, num_banks, tile_split_bytes;
1181 1181
1182 /* Calculate the macrotile mode index. */ 1182 /* Calculate the macrotile mode index. */
@@ -1194,13 +1194,14 @@ static int dce4_crtc_do_set_base(struct drm_crtc *crtc,
1194 return -EINVAL; 1194 return -EINVAL;
1195 } 1195 }
1196 1196
1197 num_banks = (rdev->config.cik.macrotile_mode_array[index] >> 6) & 0x3; 1197 if (rdev->family >= CHIP_BONAIRE)
1198 num_banks = (rdev->config.cik.macrotile_mode_array[index] >> 6) & 0x3;
1199 else
1200 num_banks = (rdev->config.si.tile_mode_array[index] >> 20) & 0x3;
1198 fb_format |= EVERGREEN_GRPH_NUM_BANKS(num_banks); 1201 fb_format |= EVERGREEN_GRPH_NUM_BANKS(num_banks);
1199 } else { 1202 } else {
1200 /* SI and older. */ 1203 /* NI and older. */
1201 if (rdev->family >= CHIP_TAHITI) 1204 if (rdev->family >= CHIP_CAYMAN)
1202 tmp = rdev->config.si.tile_config;
1203 else if (rdev->family >= CHIP_CAYMAN)
1204 tmp = rdev->config.cayman.tile_config; 1205 tmp = rdev->config.cayman.tile_config;
1205 else 1206 else
1206 tmp = rdev->config.evergreen.tile_config; 1207 tmp = rdev->config.evergreen.tile_config;
diff --git a/drivers/gpu/drm/radeon/atombios_encoders.c b/drivers/gpu/drm/radeon/atombios_encoders.c
index a42d61571f49..2cec2ab02f80 100644
--- a/drivers/gpu/drm/radeon/atombios_encoders.c
+++ b/drivers/gpu/drm/radeon/atombios_encoders.c
@@ -464,11 +464,12 @@ atombios_tv_setup(struct drm_encoder *encoder, int action)
464 464
465static u8 radeon_atom_get_bpc(struct drm_encoder *encoder) 465static u8 radeon_atom_get_bpc(struct drm_encoder *encoder)
466{ 466{
467 struct drm_connector *connector = radeon_get_connector_for_encoder(encoder);
468 int bpc = 8; 467 int bpc = 8;
469 468
470 if (connector) 469 if (encoder->crtc) {
471 bpc = radeon_get_monitor_bpc(connector); 470 struct radeon_crtc *radeon_crtc = to_radeon_crtc(encoder->crtc);
471 bpc = radeon_crtc->bpc;
472 }
472 473
473 switch (bpc) { 474 switch (bpc) {
474 case 0: 475 case 0:
diff --git a/drivers/gpu/drm/radeon/evergreen.c b/drivers/gpu/drm/radeon/evergreen.c
index f2b9e21ce4da..5623e7542d99 100644
--- a/drivers/gpu/drm/radeon/evergreen.c
+++ b/drivers/gpu/drm/radeon/evergreen.c
@@ -1680,7 +1680,7 @@ bool evergreen_hpd_sense(struct radeon_device *rdev, enum radeon_hpd_id hpd)
1680 case RADEON_HPD_6: 1680 case RADEON_HPD_6:
1681 if (RREG32(DC_HPD6_INT_STATUS) & DC_HPDx_SENSE) 1681 if (RREG32(DC_HPD6_INT_STATUS) & DC_HPDx_SENSE)
1682 connected = true; 1682 connected = true;
1683 break; 1683 break;
1684 default: 1684 default:
1685 break; 1685 break;
1686 } 1686 }
diff --git a/drivers/gpu/drm/radeon/ni_dpm.c b/drivers/gpu/drm/radeon/ni_dpm.c
index 1217fbcbdcca..ca814276b075 100644
--- a/drivers/gpu/drm/radeon/ni_dpm.c
+++ b/drivers/gpu/drm/radeon/ni_dpm.c
@@ -2588,7 +2588,7 @@ static int ni_populate_sq_ramping_values(struct radeon_device *rdev,
2588 if (NISLANDS_DPM2_SQ_RAMP_STI_SIZE > (STI_SIZE_MASK >> STI_SIZE_SHIFT)) 2588 if (NISLANDS_DPM2_SQ_RAMP_STI_SIZE > (STI_SIZE_MASK >> STI_SIZE_SHIFT))
2589 enable_sq_ramping = false; 2589 enable_sq_ramping = false;
2590 2590
2591 if (NISLANDS_DPM2_SQ_RAMP_LTI_RATIO <= (LTI_RATIO_MASK >> LTI_RATIO_SHIFT)) 2591 if (NISLANDS_DPM2_SQ_RAMP_LTI_RATIO > (LTI_RATIO_MASK >> LTI_RATIO_SHIFT))
2592 enable_sq_ramping = false; 2592 enable_sq_ramping = false;
2593 2593
2594 for (i = 0; i < state->performance_level_count; i++) { 2594 for (i = 0; i < state->performance_level_count; i++) {
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index 4a8ac1cd6b4c..024db37b1832 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -135,6 +135,9 @@ extern int radeon_hard_reset;
135/* R600+ */ 135/* R600+ */
136#define R600_RING_TYPE_UVD_INDEX 5 136#define R600_RING_TYPE_UVD_INDEX 5
137 137
138/* number of hw syncs before falling back on blocking */
139#define RADEON_NUM_SYNCS 4
140
138/* hardcode those limit for now */ 141/* hardcode those limit for now */
139#define RADEON_VA_IB_OFFSET (1 << 20) 142#define RADEON_VA_IB_OFFSET (1 << 20)
140#define RADEON_VA_RESERVED_SIZE (8 << 20) 143#define RADEON_VA_RESERVED_SIZE (8 << 20)
@@ -554,7 +557,6 @@ int radeon_mode_dumb_mmap(struct drm_file *filp,
554/* 557/*
555 * Semaphores. 558 * Semaphores.
556 */ 559 */
557/* everything here is constant */
558struct radeon_semaphore { 560struct radeon_semaphore {
559 struct radeon_sa_bo *sa_bo; 561 struct radeon_sa_bo *sa_bo;
560 signed waiters; 562 signed waiters;
diff --git a/drivers/gpu/drm/radeon/radeon_display.c b/drivers/gpu/drm/radeon/radeon_display.c
index d680608f6f5b..fbd8b930f2be 100644
--- a/drivers/gpu/drm/radeon/radeon_display.c
+++ b/drivers/gpu/drm/radeon/radeon_display.c
@@ -571,6 +571,8 @@ static void radeon_crtc_init(struct drm_device *dev, int index)
571 radeon_crtc->max_cursor_width = CURSOR_WIDTH; 571 radeon_crtc->max_cursor_width = CURSOR_WIDTH;
572 radeon_crtc->max_cursor_height = CURSOR_HEIGHT; 572 radeon_crtc->max_cursor_height = CURSOR_HEIGHT;
573 } 573 }
574 dev->mode_config.cursor_width = radeon_crtc->max_cursor_width;
575 dev->mode_config.cursor_height = radeon_crtc->max_cursor_height;
574 576
575#if 0 577#if 0
576 radeon_crtc->mode_set.crtc = &radeon_crtc->base; 578 radeon_crtc->mode_set.crtc = &radeon_crtc->base;
diff --git a/drivers/gpu/drm/radeon/radeon_ring.c b/drivers/gpu/drm/radeon/radeon_ring.c
index 1b783f0e6d3a..15e44a7281ab 100644
--- a/drivers/gpu/drm/radeon/radeon_ring.c
+++ b/drivers/gpu/drm/radeon/radeon_ring.c
@@ -139,7 +139,7 @@ int radeon_ib_schedule(struct radeon_device *rdev, struct radeon_ib *ib,
139 } 139 }
140 140
141 /* 64 dwords should be enough for fence too */ 141 /* 64 dwords should be enough for fence too */
142 r = radeon_ring_lock(rdev, ring, 64 + RADEON_NUM_RINGS * 8); 142 r = radeon_ring_lock(rdev, ring, 64 + RADEON_NUM_SYNCS * 8);
143 if (r) { 143 if (r) {
144 dev_err(rdev->dev, "scheduling IB failed (%d).\n", r); 144 dev_err(rdev->dev, "scheduling IB failed (%d).\n", r);
145 return r; 145 return r;
diff --git a/drivers/gpu/drm/radeon/radeon_semaphore.c b/drivers/gpu/drm/radeon/radeon_semaphore.c
index 2b42aa1914f2..9006b32d5eed 100644
--- a/drivers/gpu/drm/radeon/radeon_semaphore.c
+++ b/drivers/gpu/drm/radeon/radeon_semaphore.c
@@ -34,14 +34,15 @@
34int radeon_semaphore_create(struct radeon_device *rdev, 34int radeon_semaphore_create(struct radeon_device *rdev,
35 struct radeon_semaphore **semaphore) 35 struct radeon_semaphore **semaphore)
36{ 36{
37 uint32_t *cpu_addr;
37 int i, r; 38 int i, r;
38 39
39 *semaphore = kmalloc(sizeof(struct radeon_semaphore), GFP_KERNEL); 40 *semaphore = kmalloc(sizeof(struct radeon_semaphore), GFP_KERNEL);
40 if (*semaphore == NULL) { 41 if (*semaphore == NULL) {
41 return -ENOMEM; 42 return -ENOMEM;
42 } 43 }
43 r = radeon_sa_bo_new(rdev, &rdev->ring_tmp_bo, 44 r = radeon_sa_bo_new(rdev, &rdev->ring_tmp_bo, &(*semaphore)->sa_bo,
44 &(*semaphore)->sa_bo, 8, 8, true); 45 8 * RADEON_NUM_SYNCS, 8, true);
45 if (r) { 46 if (r) {
46 kfree(*semaphore); 47 kfree(*semaphore);
47 *semaphore = NULL; 48 *semaphore = NULL;
@@ -49,7 +50,10 @@ int radeon_semaphore_create(struct radeon_device *rdev,
49 } 50 }
50 (*semaphore)->waiters = 0; 51 (*semaphore)->waiters = 0;
51 (*semaphore)->gpu_addr = radeon_sa_bo_gpu_addr((*semaphore)->sa_bo); 52 (*semaphore)->gpu_addr = radeon_sa_bo_gpu_addr((*semaphore)->sa_bo);
52 *((uint64_t*)radeon_sa_bo_cpu_addr((*semaphore)->sa_bo)) = 0; 53
54 cpu_addr = radeon_sa_bo_cpu_addr((*semaphore)->sa_bo);
55 for (i = 0; i < RADEON_NUM_SYNCS; ++i)
56 cpu_addr[i] = 0;
53 57
54 for (i = 0; i < RADEON_NUM_RINGS; ++i) 58 for (i = 0; i < RADEON_NUM_RINGS; ++i)
55 (*semaphore)->sync_to[i] = NULL; 59 (*semaphore)->sync_to[i] = NULL;
@@ -125,6 +129,7 @@ int radeon_semaphore_sync_rings(struct radeon_device *rdev,
125 struct radeon_semaphore *semaphore, 129 struct radeon_semaphore *semaphore,
126 int ring) 130 int ring)
127{ 131{
132 unsigned count = 0;
128 int i, r; 133 int i, r;
129 134
130 for (i = 0; i < RADEON_NUM_RINGS; ++i) { 135 for (i = 0; i < RADEON_NUM_RINGS; ++i) {
@@ -140,6 +145,12 @@ int radeon_semaphore_sync_rings(struct radeon_device *rdev,
140 return -EINVAL; 145 return -EINVAL;
141 } 146 }
142 147
148 if (++count > RADEON_NUM_SYNCS) {
149 /* not enough room, wait manually */
150 radeon_fence_wait_locked(fence);
151 continue;
152 }
153
143 /* allocate enough space for sync command */ 154 /* allocate enough space for sync command */
144 r = radeon_ring_alloc(rdev, &rdev->ring[i], 16); 155 r = radeon_ring_alloc(rdev, &rdev->ring[i], 16);
145 if (r) { 156 if (r) {
@@ -164,6 +175,8 @@ int radeon_semaphore_sync_rings(struct radeon_device *rdev,
164 175
165 radeon_ring_commit(rdev, &rdev->ring[i]); 176 radeon_ring_commit(rdev, &rdev->ring[i]);
166 radeon_fence_note_sync(fence, ring); 177 radeon_fence_note_sync(fence, ring);
178
179 semaphore->gpu_addr += 8;
167 } 180 }
168 181
169 return 0; 182 return 0;
diff --git a/drivers/gpu/drm/radeon/rv770_dpm.c b/drivers/gpu/drm/radeon/rv770_dpm.c
index 5b2ea8ac0731..b5f63f5e22a3 100644
--- a/drivers/gpu/drm/radeon/rv770_dpm.c
+++ b/drivers/gpu/drm/radeon/rv770_dpm.c
@@ -2526,14 +2526,7 @@ u32 rv770_dpm_get_mclk(struct radeon_device *rdev, bool low)
2526bool rv770_dpm_vblank_too_short(struct radeon_device *rdev) 2526bool rv770_dpm_vblank_too_short(struct radeon_device *rdev)
2527{ 2527{
2528 u32 vblank_time = r600_dpm_get_vblank_time(rdev); 2528 u32 vblank_time = r600_dpm_get_vblank_time(rdev);
2529 u32 switch_limit = 300; 2529 u32 switch_limit = 200; /* 300 */
2530
2531 /* quirks */
2532 /* ASUS K70AF */
2533 if ((rdev->pdev->device == 0x9553) &&
2534 (rdev->pdev->subsystem_vendor == 0x1043) &&
2535 (rdev->pdev->subsystem_device == 0x1c42))
2536 switch_limit = 200;
2537 2530
2538 /* RV770 */ 2531 /* RV770 */
2539 /* mclk switching doesn't seem to work reliably on desktop RV770s */ 2532 /* mclk switching doesn't seem to work reliably on desktop RV770s */
diff --git a/drivers/gpu/drm/radeon/si_dpm.c b/drivers/gpu/drm/radeon/si_dpm.c
index eafb0e6bc67e..0a2f5b4bca43 100644
--- a/drivers/gpu/drm/radeon/si_dpm.c
+++ b/drivers/gpu/drm/radeon/si_dpm.c
@@ -2395,7 +2395,7 @@ static int si_populate_sq_ramping_values(struct radeon_device *rdev,
2395 if (SISLANDS_DPM2_SQ_RAMP_STI_SIZE > (STI_SIZE_MASK >> STI_SIZE_SHIFT)) 2395 if (SISLANDS_DPM2_SQ_RAMP_STI_SIZE > (STI_SIZE_MASK >> STI_SIZE_SHIFT))
2396 enable_sq_ramping = false; 2396 enable_sq_ramping = false;
2397 2397
2398 if (SISLANDS_DPM2_SQ_RAMP_LTI_RATIO <= (LTI_RATIO_MASK >> LTI_RATIO_SHIFT)) 2398 if (SISLANDS_DPM2_SQ_RAMP_LTI_RATIO > (LTI_RATIO_MASK >> LTI_RATIO_SHIFT))
2399 enable_sq_ramping = false; 2399 enable_sq_ramping = false;
2400 2400
2401 for (i = 0; i < state->performance_level_count; i++) { 2401 for (i = 0; i < state->performance_level_count; i++) {
diff --git a/drivers/gpu/drm/ttm/ttm_agp_backend.c b/drivers/gpu/drm/ttm/ttm_agp_backend.c
index 3302f99e7497..764be36397fd 100644
--- a/drivers/gpu/drm/ttm/ttm_agp_backend.c
+++ b/drivers/gpu/drm/ttm/ttm_agp_backend.c
@@ -126,6 +126,7 @@ struct ttm_tt *ttm_agp_tt_create(struct ttm_bo_device *bdev,
126 agp_be->ttm.func = &ttm_agp_func; 126 agp_be->ttm.func = &ttm_agp_func;
127 127
128 if (ttm_tt_init(&agp_be->ttm, bdev, size, page_flags, dummy_read_page)) { 128 if (ttm_tt_init(&agp_be->ttm, bdev, size, page_flags, dummy_read_page)) {
129 kfree(agp_be);
129 return NULL; 130 return NULL;
130 } 131 }
131 132
diff --git a/drivers/gpu/drm/vmwgfx/svga3d_reg.h b/drivers/gpu/drm/vmwgfx/svga3d_reg.h
index b645647b7776..bb594c11605e 100644
--- a/drivers/gpu/drm/vmwgfx/svga3d_reg.h
+++ b/drivers/gpu/drm/vmwgfx/svga3d_reg.h
@@ -1223,9 +1223,19 @@ typedef enum {
1223#define SVGA_3D_CMD_INVALIDATE_GB_IMAGE_PARTIAL 1129 1223#define SVGA_3D_CMD_INVALIDATE_GB_IMAGE_PARTIAL 1129
1224 1224
1225#define SVGA_3D_CMD_SET_GB_SHADERCONSTS_INLINE 1130 1225#define SVGA_3D_CMD_SET_GB_SHADERCONSTS_INLINE 1130
1226 1226#define SVGA_3D_CMD_GB_SCREEN_DMA 1131
1227#define SVGA_3D_CMD_BIND_GB_SURFACE_WITH_PITCH 1132
1228#define SVGA_3D_CMD_GB_MOB_FENCE 1133
1229#define SVGA_3D_CMD_DEFINE_GB_SURFACE_V2 1134
1227#define SVGA_3D_CMD_DEFINE_GB_MOB64 1135 1230#define SVGA_3D_CMD_DEFINE_GB_MOB64 1135
1228#define SVGA_3D_CMD_REDEFINE_GB_MOB64 1136 1231#define SVGA_3D_CMD_REDEFINE_GB_MOB64 1136
1232#define SVGA_3D_CMD_NOP_ERROR 1137
1233
1234#define SVGA_3D_CMD_RESERVED1 1138
1235#define SVGA_3D_CMD_RESERVED2 1139
1236#define SVGA_3D_CMD_RESERVED3 1140
1237#define SVGA_3D_CMD_RESERVED4 1141
1238#define SVGA_3D_CMD_RESERVED5 1142
1229 1239
1230#define SVGA_3D_CMD_MAX 1142 1240#define SVGA_3D_CMD_MAX 1142
1231#define SVGA_3D_CMD_FUTURE_MAX 3000 1241#define SVGA_3D_CMD_FUTURE_MAX 3000
@@ -1973,8 +1983,7 @@ struct {
1973 uint32 sizeInBytes; 1983 uint32 sizeInBytes;
1974 uint32 validSizeInBytes; 1984 uint32 validSizeInBytes;
1975 SVGAMobFormat ptDepth; 1985 SVGAMobFormat ptDepth;
1976} 1986} __packed
1977__attribute__((__packed__))
1978SVGA3dCmdSetOTableBase; /* SVGA_3D_CMD_SET_OTABLE_BASE */ 1987SVGA3dCmdSetOTableBase; /* SVGA_3D_CMD_SET_OTABLE_BASE */
1979 1988
1980typedef 1989typedef
@@ -1984,15 +1993,13 @@ struct {
1984 uint32 sizeInBytes; 1993 uint32 sizeInBytes;
1985 uint32 validSizeInBytes; 1994 uint32 validSizeInBytes;
1986 SVGAMobFormat ptDepth; 1995 SVGAMobFormat ptDepth;
1987} 1996} __packed
1988__attribute__((__packed__))
1989SVGA3dCmdSetOTableBase64; /* SVGA_3D_CMD_SET_OTABLE_BASE64 */ 1997SVGA3dCmdSetOTableBase64; /* SVGA_3D_CMD_SET_OTABLE_BASE64 */
1990 1998
1991typedef 1999typedef
1992struct { 2000struct {
1993 SVGAOTableType type; 2001 SVGAOTableType type;
1994} 2002} __packed
1995__attribute__((__packed__))
1996SVGA3dCmdReadbackOTable; /* SVGA_3D_CMD_READBACK_OTABLE */ 2003SVGA3dCmdReadbackOTable; /* SVGA_3D_CMD_READBACK_OTABLE */
1997 2004
1998/* 2005/*
@@ -2005,8 +2012,7 @@ struct SVGA3dCmdDefineGBMob {
2005 SVGAMobFormat ptDepth; 2012 SVGAMobFormat ptDepth;
2006 PPN base; 2013 PPN base;
2007 uint32 sizeInBytes; 2014 uint32 sizeInBytes;
2008} 2015} __packed
2009__attribute__((__packed__))
2010SVGA3dCmdDefineGBMob; /* SVGA_3D_CMD_DEFINE_GB_MOB */ 2016SVGA3dCmdDefineGBMob; /* SVGA_3D_CMD_DEFINE_GB_MOB */
2011 2017
2012 2018
@@ -2017,8 +2023,7 @@ SVGA3dCmdDefineGBMob; /* SVGA_3D_CMD_DEFINE_GB_MOB */
2017typedef 2023typedef
2018struct SVGA3dCmdDestroyGBMob { 2024struct SVGA3dCmdDestroyGBMob {
2019 SVGAMobId mobid; 2025 SVGAMobId mobid;
2020} 2026} __packed
2021__attribute__((__packed__))
2022SVGA3dCmdDestroyGBMob; /* SVGA_3D_CMD_DESTROY_GB_MOB */ 2027SVGA3dCmdDestroyGBMob; /* SVGA_3D_CMD_DESTROY_GB_MOB */
2023 2028
2024/* 2029/*
@@ -2031,8 +2036,7 @@ struct SVGA3dCmdRedefineGBMob {
2031 SVGAMobFormat ptDepth; 2036 SVGAMobFormat ptDepth;
2032 PPN base; 2037 PPN base;
2033 uint32 sizeInBytes; 2038 uint32 sizeInBytes;
2034} 2039} __packed
2035__attribute__((__packed__))
2036SVGA3dCmdRedefineGBMob; /* SVGA_3D_CMD_REDEFINE_GB_MOB */ 2040SVGA3dCmdRedefineGBMob; /* SVGA_3D_CMD_REDEFINE_GB_MOB */
2037 2041
2038/* 2042/*
@@ -2045,8 +2049,7 @@ struct SVGA3dCmdDefineGBMob64 {
2045 SVGAMobFormat ptDepth; 2049 SVGAMobFormat ptDepth;
2046 PPN64 base; 2050 PPN64 base;
2047 uint32 sizeInBytes; 2051 uint32 sizeInBytes;
2048} 2052} __packed
2049__attribute__((__packed__))
2050SVGA3dCmdDefineGBMob64; /* SVGA_3D_CMD_DEFINE_GB_MOB64 */ 2053SVGA3dCmdDefineGBMob64; /* SVGA_3D_CMD_DEFINE_GB_MOB64 */
2051 2054
2052/* 2055/*
@@ -2059,8 +2062,7 @@ struct SVGA3dCmdRedefineGBMob64 {
2059 SVGAMobFormat ptDepth; 2062 SVGAMobFormat ptDepth;
2060 PPN64 base; 2063 PPN64 base;
2061 uint32 sizeInBytes; 2064 uint32 sizeInBytes;
2062} 2065} __packed
2063__attribute__((__packed__))
2064SVGA3dCmdRedefineGBMob64; /* SVGA_3D_CMD_REDEFINE_GB_MOB64 */ 2066SVGA3dCmdRedefineGBMob64; /* SVGA_3D_CMD_REDEFINE_GB_MOB64 */
2065 2067
2066/* 2068/*
@@ -2070,8 +2072,7 @@ SVGA3dCmdRedefineGBMob64; /* SVGA_3D_CMD_REDEFINE_GB_MOB64 */
2070typedef 2072typedef
2071struct SVGA3dCmdUpdateGBMobMapping { 2073struct SVGA3dCmdUpdateGBMobMapping {
2072 SVGAMobId mobid; 2074 SVGAMobId mobid;
2073} 2075} __packed
2074__attribute__((__packed__))
2075SVGA3dCmdUpdateGBMobMapping; /* SVGA_3D_CMD_UPDATE_GB_MOB_MAPPING */ 2076SVGA3dCmdUpdateGBMobMapping; /* SVGA_3D_CMD_UPDATE_GB_MOB_MAPPING */
2076 2077
2077/* 2078/*
@@ -2087,7 +2088,8 @@ struct SVGA3dCmdDefineGBSurface {
2087 uint32 multisampleCount; 2088 uint32 multisampleCount;
2088 SVGA3dTextureFilter autogenFilter; 2089 SVGA3dTextureFilter autogenFilter;
2089 SVGA3dSize size; 2090 SVGA3dSize size;
2090} SVGA3dCmdDefineGBSurface; /* SVGA_3D_CMD_DEFINE_GB_SURFACE */ 2091} __packed
2092SVGA3dCmdDefineGBSurface; /* SVGA_3D_CMD_DEFINE_GB_SURFACE */
2091 2093
2092/* 2094/*
2093 * Destroy a guest-backed surface. 2095 * Destroy a guest-backed surface.
@@ -2096,7 +2098,8 @@ struct SVGA3dCmdDefineGBSurface {
2096typedef 2098typedef
2097struct SVGA3dCmdDestroyGBSurface { 2099struct SVGA3dCmdDestroyGBSurface {
2098 uint32 sid; 2100 uint32 sid;
2099} SVGA3dCmdDestroyGBSurface; /* SVGA_3D_CMD_DESTROY_GB_SURFACE */ 2101} __packed
2102SVGA3dCmdDestroyGBSurface; /* SVGA_3D_CMD_DESTROY_GB_SURFACE */
2100 2103
2101/* 2104/*
2102 * Bind a guest-backed surface to an object. 2105 * Bind a guest-backed surface to an object.
@@ -2106,7 +2109,8 @@ typedef
2106struct SVGA3dCmdBindGBSurface { 2109struct SVGA3dCmdBindGBSurface {
2107 uint32 sid; 2110 uint32 sid;
2108 SVGAMobId mobid; 2111 SVGAMobId mobid;
2109} SVGA3dCmdBindGBSurface; /* SVGA_3D_CMD_BIND_GB_SURFACE */ 2112} __packed
2113SVGA3dCmdBindGBSurface; /* SVGA_3D_CMD_BIND_GB_SURFACE */
2110 2114
2111/* 2115/*
2112 * Conditionally bind a mob to a guest backed surface if testMobid 2116 * Conditionally bind a mob to a guest backed surface if testMobid
@@ -2123,7 +2127,7 @@ struct{
2123 SVGAMobId testMobid; 2127 SVGAMobId testMobid;
2124 SVGAMobId mobid; 2128 SVGAMobId mobid;
2125 uint32 flags; 2129 uint32 flags;
2126} 2130} __packed
2127SVGA3dCmdCondBindGBSurface; /* SVGA_3D_CMD_COND_BIND_GB_SURFACE */ 2131SVGA3dCmdCondBindGBSurface; /* SVGA_3D_CMD_COND_BIND_GB_SURFACE */
2128 2132
2129/* 2133/*
@@ -2135,7 +2139,8 @@ typedef
2135struct SVGA3dCmdUpdateGBImage { 2139struct SVGA3dCmdUpdateGBImage {
2136 SVGA3dSurfaceImageId image; 2140 SVGA3dSurfaceImageId image;
2137 SVGA3dBox box; 2141 SVGA3dBox box;
2138} SVGA3dCmdUpdateGBImage; /* SVGA_3D_CMD_UPDATE_GB_IMAGE */ 2142} __packed
2143SVGA3dCmdUpdateGBImage; /* SVGA_3D_CMD_UPDATE_GB_IMAGE */
2139 2144
2140/* 2145/*
2141 * Update an entire guest-backed surface. 2146 * Update an entire guest-backed surface.
@@ -2145,7 +2150,8 @@ struct SVGA3dCmdUpdateGBImage {
2145typedef 2150typedef
2146struct SVGA3dCmdUpdateGBSurface { 2151struct SVGA3dCmdUpdateGBSurface {
2147 uint32 sid; 2152 uint32 sid;
2148} SVGA3dCmdUpdateGBSurface; /* SVGA_3D_CMD_UPDATE_GB_SURFACE */ 2153} __packed
2154SVGA3dCmdUpdateGBSurface; /* SVGA_3D_CMD_UPDATE_GB_SURFACE */
2149 2155
2150/* 2156/*
2151 * Readback an image in a guest-backed surface. 2157 * Readback an image in a guest-backed surface.
@@ -2155,7 +2161,8 @@ struct SVGA3dCmdUpdateGBSurface {
2155typedef 2161typedef
2156struct SVGA3dCmdReadbackGBImage { 2162struct SVGA3dCmdReadbackGBImage {
2157 SVGA3dSurfaceImageId image; 2163 SVGA3dSurfaceImageId image;
2158} SVGA3dCmdReadbackGBImage; /* SVGA_3D_CMD_READBACK_GB_IMAGE*/ 2164} __packed
2165SVGA3dCmdReadbackGBImage; /* SVGA_3D_CMD_READBACK_GB_IMAGE*/
2159 2166
2160/* 2167/*
2161 * Readback an entire guest-backed surface. 2168 * Readback an entire guest-backed surface.
@@ -2165,7 +2172,8 @@ struct SVGA3dCmdReadbackGBImage {
2165typedef 2172typedef
2166struct SVGA3dCmdReadbackGBSurface { 2173struct SVGA3dCmdReadbackGBSurface {
2167 uint32 sid; 2174 uint32 sid;
2168} SVGA3dCmdReadbackGBSurface; /* SVGA_3D_CMD_READBACK_GB_SURFACE */ 2175} __packed
2176SVGA3dCmdReadbackGBSurface; /* SVGA_3D_CMD_READBACK_GB_SURFACE */
2169 2177
2170/* 2178/*
2171 * Readback a sub rect of an image in a guest-backed surface. After 2179 * Readback a sub rect of an image in a guest-backed surface. After
@@ -2179,7 +2187,7 @@ struct SVGA3dCmdReadbackGBImagePartial {
2179 SVGA3dSurfaceImageId image; 2187 SVGA3dSurfaceImageId image;
2180 SVGA3dBox box; 2188 SVGA3dBox box;
2181 uint32 invertBox; 2189 uint32 invertBox;
2182} 2190} __packed
2183SVGA3dCmdReadbackGBImagePartial; /* SVGA_3D_CMD_READBACK_GB_IMAGE_PARTIAL */ 2191SVGA3dCmdReadbackGBImagePartial; /* SVGA_3D_CMD_READBACK_GB_IMAGE_PARTIAL */
2184 2192
2185/* 2193/*
@@ -2190,7 +2198,8 @@ SVGA3dCmdReadbackGBImagePartial; /* SVGA_3D_CMD_READBACK_GB_IMAGE_PARTIAL */
2190typedef 2198typedef
2191struct SVGA3dCmdInvalidateGBImage { 2199struct SVGA3dCmdInvalidateGBImage {
2192 SVGA3dSurfaceImageId image; 2200 SVGA3dSurfaceImageId image;
2193} SVGA3dCmdInvalidateGBImage; /* SVGA_3D_CMD_INVALIDATE_GB_IMAGE */ 2201} __packed
2202SVGA3dCmdInvalidateGBImage; /* SVGA_3D_CMD_INVALIDATE_GB_IMAGE */
2194 2203
2195/* 2204/*
2196 * Invalidate an entire guest-backed surface. 2205 * Invalidate an entire guest-backed surface.
@@ -2200,7 +2209,8 @@ struct SVGA3dCmdInvalidateGBImage {
2200typedef 2209typedef
2201struct SVGA3dCmdInvalidateGBSurface { 2210struct SVGA3dCmdInvalidateGBSurface {
2202 uint32 sid; 2211 uint32 sid;
2203} SVGA3dCmdInvalidateGBSurface; /* SVGA_3D_CMD_INVALIDATE_GB_SURFACE */ 2212} __packed
2213SVGA3dCmdInvalidateGBSurface; /* SVGA_3D_CMD_INVALIDATE_GB_SURFACE */
2204 2214
2205/* 2215/*
2206 * Invalidate a sub rect of an image in a guest-backed surface. After 2216 * Invalidate a sub rect of an image in a guest-backed surface. After
@@ -2214,7 +2224,7 @@ struct SVGA3dCmdInvalidateGBImagePartial {
2214 SVGA3dSurfaceImageId image; 2224 SVGA3dSurfaceImageId image;
2215 SVGA3dBox box; 2225 SVGA3dBox box;
2216 uint32 invertBox; 2226 uint32 invertBox;
2217} 2227} __packed
2218SVGA3dCmdInvalidateGBImagePartial; /* SVGA_3D_CMD_INVALIDATE_GB_IMAGE_PARTIAL */ 2228SVGA3dCmdInvalidateGBImagePartial; /* SVGA_3D_CMD_INVALIDATE_GB_IMAGE_PARTIAL */
2219 2229
2220/* 2230/*
@@ -2224,7 +2234,8 @@ SVGA3dCmdInvalidateGBImagePartial; /* SVGA_3D_CMD_INVALIDATE_GB_IMAGE_PARTIAL */
2224typedef 2234typedef
2225struct SVGA3dCmdDefineGBContext { 2235struct SVGA3dCmdDefineGBContext {
2226 uint32 cid; 2236 uint32 cid;
2227} SVGA3dCmdDefineGBContext; /* SVGA_3D_CMD_DEFINE_GB_CONTEXT */ 2237} __packed
2238SVGA3dCmdDefineGBContext; /* SVGA_3D_CMD_DEFINE_GB_CONTEXT */
2228 2239
2229/* 2240/*
2230 * Destroy a guest-backed context. 2241 * Destroy a guest-backed context.
@@ -2233,7 +2244,8 @@ struct SVGA3dCmdDefineGBContext {
2233typedef 2244typedef
2234struct SVGA3dCmdDestroyGBContext { 2245struct SVGA3dCmdDestroyGBContext {
2235 uint32 cid; 2246 uint32 cid;
2236} SVGA3dCmdDestroyGBContext; /* SVGA_3D_CMD_DESTROY_GB_CONTEXT */ 2247} __packed
2248SVGA3dCmdDestroyGBContext; /* SVGA_3D_CMD_DESTROY_GB_CONTEXT */
2237 2249
2238/* 2250/*
2239 * Bind a guest-backed context. 2251 * Bind a guest-backed context.
@@ -2252,7 +2264,8 @@ struct SVGA3dCmdBindGBContext {
2252 uint32 cid; 2264 uint32 cid;
2253 SVGAMobId mobid; 2265 SVGAMobId mobid;
2254 uint32 validContents; 2266 uint32 validContents;
2255} SVGA3dCmdBindGBContext; /* SVGA_3D_CMD_BIND_GB_CONTEXT */ 2267} __packed
2268SVGA3dCmdBindGBContext; /* SVGA_3D_CMD_BIND_GB_CONTEXT */
2256 2269
2257/* 2270/*
2258 * Readback a guest-backed context. 2271 * Readback a guest-backed context.
@@ -2262,7 +2275,8 @@ struct SVGA3dCmdBindGBContext {
2262typedef 2275typedef
2263struct SVGA3dCmdReadbackGBContext { 2276struct SVGA3dCmdReadbackGBContext {
2264 uint32 cid; 2277 uint32 cid;
2265} SVGA3dCmdReadbackGBContext; /* SVGA_3D_CMD_READBACK_GB_CONTEXT */ 2278} __packed
2279SVGA3dCmdReadbackGBContext; /* SVGA_3D_CMD_READBACK_GB_CONTEXT */
2266 2280
2267/* 2281/*
2268 * Invalidate a guest-backed context. 2282 * Invalidate a guest-backed context.
@@ -2270,7 +2284,8 @@ struct SVGA3dCmdReadbackGBContext {
2270typedef 2284typedef
2271struct SVGA3dCmdInvalidateGBContext { 2285struct SVGA3dCmdInvalidateGBContext {
2272 uint32 cid; 2286 uint32 cid;
2273} SVGA3dCmdInvalidateGBContext; /* SVGA_3D_CMD_INVALIDATE_GB_CONTEXT */ 2287} __packed
2288SVGA3dCmdInvalidateGBContext; /* SVGA_3D_CMD_INVALIDATE_GB_CONTEXT */
2274 2289
2275/* 2290/*
2276 * Define a guest-backed shader. 2291 * Define a guest-backed shader.
@@ -2281,7 +2296,8 @@ struct SVGA3dCmdDefineGBShader {
2281 uint32 shid; 2296 uint32 shid;
2282 SVGA3dShaderType type; 2297 SVGA3dShaderType type;
2283 uint32 sizeInBytes; 2298 uint32 sizeInBytes;
2284} SVGA3dCmdDefineGBShader; /* SVGA_3D_CMD_DEFINE_GB_SHADER */ 2299} __packed
2300SVGA3dCmdDefineGBShader; /* SVGA_3D_CMD_DEFINE_GB_SHADER */
2285 2301
2286/* 2302/*
2287 * Bind a guest-backed shader. 2303 * Bind a guest-backed shader.
@@ -2291,7 +2307,8 @@ typedef struct SVGA3dCmdBindGBShader {
2291 uint32 shid; 2307 uint32 shid;
2292 SVGAMobId mobid; 2308 SVGAMobId mobid;
2293 uint32 offsetInBytes; 2309 uint32 offsetInBytes;
2294} SVGA3dCmdBindGBShader; /* SVGA_3D_CMD_BIND_GB_SHADER */ 2310} __packed
2311SVGA3dCmdBindGBShader; /* SVGA_3D_CMD_BIND_GB_SHADER */
2295 2312
2296/* 2313/*
2297 * Destroy a guest-backed shader. 2314 * Destroy a guest-backed shader.
@@ -2299,7 +2316,8 @@ typedef struct SVGA3dCmdBindGBShader {
2299 2316
2300typedef struct SVGA3dCmdDestroyGBShader { 2317typedef struct SVGA3dCmdDestroyGBShader {
2301 uint32 shid; 2318 uint32 shid;
2302} SVGA3dCmdDestroyGBShader; /* SVGA_3D_CMD_DESTROY_GB_SHADER */ 2319} __packed
2320SVGA3dCmdDestroyGBShader; /* SVGA_3D_CMD_DESTROY_GB_SHADER */
2303 2321
2304typedef 2322typedef
2305struct { 2323struct {
@@ -2314,14 +2332,16 @@ struct {
2314 * Note that FLOAT and INT constants are 4-dwords in length, while 2332 * Note that FLOAT and INT constants are 4-dwords in length, while
2315 * BOOL constants are 1-dword in length. 2333 * BOOL constants are 1-dword in length.
2316 */ 2334 */
2317} SVGA3dCmdSetGBShaderConstInline; 2335} __packed
2336SVGA3dCmdSetGBShaderConstInline;
2318/* SVGA_3D_CMD_SET_GB_SHADERCONSTS_INLINE */ 2337/* SVGA_3D_CMD_SET_GB_SHADERCONSTS_INLINE */
2319 2338
2320typedef 2339typedef
2321struct { 2340struct {
2322 uint32 cid; 2341 uint32 cid;
2323 SVGA3dQueryType type; 2342 SVGA3dQueryType type;
2324} SVGA3dCmdBeginGBQuery; /* SVGA_3D_CMD_BEGIN_GB_QUERY */ 2343} __packed
2344SVGA3dCmdBeginGBQuery; /* SVGA_3D_CMD_BEGIN_GB_QUERY */
2325 2345
2326typedef 2346typedef
2327struct { 2347struct {
@@ -2329,7 +2349,8 @@ struct {
2329 SVGA3dQueryType type; 2349 SVGA3dQueryType type;
2330 SVGAMobId mobid; 2350 SVGAMobId mobid;
2331 uint32 offset; 2351 uint32 offset;
2332} SVGA3dCmdEndGBQuery; /* SVGA_3D_CMD_END_GB_QUERY */ 2352} __packed
2353SVGA3dCmdEndGBQuery; /* SVGA_3D_CMD_END_GB_QUERY */
2333 2354
2334 2355
2335/* 2356/*
@@ -2346,21 +2367,22 @@ struct {
2346 SVGA3dQueryType type; 2367 SVGA3dQueryType type;
2347 SVGAMobId mobid; 2368 SVGAMobId mobid;
2348 uint32 offset; 2369 uint32 offset;
2349} SVGA3dCmdWaitForGBQuery; /* SVGA_3D_CMD_WAIT_FOR_GB_QUERY */ 2370} __packed
2371SVGA3dCmdWaitForGBQuery; /* SVGA_3D_CMD_WAIT_FOR_GB_QUERY */
2350 2372
2351typedef 2373typedef
2352struct { 2374struct {
2353 SVGAMobId mobid; 2375 SVGAMobId mobid;
2354 uint32 fbOffset; 2376 uint32 fbOffset;
2355 uint32 initalized; 2377 uint32 initalized;
2356} 2378} __packed
2357SVGA3dCmdEnableGart; /* SVGA_3D_CMD_ENABLE_GART */ 2379SVGA3dCmdEnableGart; /* SVGA_3D_CMD_ENABLE_GART */
2358 2380
2359typedef 2381typedef
2360struct { 2382struct {
2361 SVGAMobId mobid; 2383 SVGAMobId mobid;
2362 uint32 gartOffset; 2384 uint32 gartOffset;
2363} 2385} __packed
2364SVGA3dCmdMapMobIntoGart; /* SVGA_3D_CMD_MAP_MOB_INTO_GART */ 2386SVGA3dCmdMapMobIntoGart; /* SVGA_3D_CMD_MAP_MOB_INTO_GART */
2365 2387
2366 2388
@@ -2368,7 +2390,7 @@ typedef
2368struct { 2390struct {
2369 uint32 gartOffset; 2391 uint32 gartOffset;
2370 uint32 numPages; 2392 uint32 numPages;
2371} 2393} __packed
2372SVGA3dCmdUnmapGartRange; /* SVGA_3D_CMD_UNMAP_GART_RANGE */ 2394SVGA3dCmdUnmapGartRange; /* SVGA_3D_CMD_UNMAP_GART_RANGE */
2373 2395
2374 2396
@@ -2385,27 +2407,27 @@ struct {
2385 int32 xRoot; 2407 int32 xRoot;
2386 int32 yRoot; 2408 int32 yRoot;
2387 uint32 flags; 2409 uint32 flags;
2388} 2410} __packed
2389SVGA3dCmdDefineGBScreenTarget; /* SVGA_3D_CMD_DEFINE_GB_SCREENTARGET */ 2411SVGA3dCmdDefineGBScreenTarget; /* SVGA_3D_CMD_DEFINE_GB_SCREENTARGET */
2390 2412
2391typedef 2413typedef
2392struct { 2414struct {
2393 uint32 stid; 2415 uint32 stid;
2394} 2416} __packed
2395SVGA3dCmdDestroyGBScreenTarget; /* SVGA_3D_CMD_DESTROY_GB_SCREENTARGET */ 2417SVGA3dCmdDestroyGBScreenTarget; /* SVGA_3D_CMD_DESTROY_GB_SCREENTARGET */
2396 2418
2397typedef 2419typedef
2398struct { 2420struct {
2399 uint32 stid; 2421 uint32 stid;
2400 SVGA3dSurfaceImageId image; 2422 SVGA3dSurfaceImageId image;
2401} 2423} __packed
2402SVGA3dCmdBindGBScreenTarget; /* SVGA_3D_CMD_BIND_GB_SCREENTARGET */ 2424SVGA3dCmdBindGBScreenTarget; /* SVGA_3D_CMD_BIND_GB_SCREENTARGET */
2403 2425
2404typedef 2426typedef
2405struct { 2427struct {
2406 uint32 stid; 2428 uint32 stid;
2407 SVGA3dBox box; 2429 SVGA3dBox box;
2408} 2430} __packed
2409SVGA3dCmdUpdateGBScreenTarget; /* SVGA_3D_CMD_UPDATE_GB_SCREENTARGET */ 2431SVGA3dCmdUpdateGBScreenTarget; /* SVGA_3D_CMD_UPDATE_GB_SCREENTARGET */
2410 2432
2411/* 2433/*
diff --git a/drivers/gpu/drm/vmwgfx/svga3d_surfacedefs.h b/drivers/gpu/drm/vmwgfx/svga3d_surfacedefs.h
index 8369c3ba10fe..ef3385096145 100644
--- a/drivers/gpu/drm/vmwgfx/svga3d_surfacedefs.h
+++ b/drivers/gpu/drm/vmwgfx/svga3d_surfacedefs.h
@@ -38,8 +38,11 @@
38 38
39#define DIV_ROUND_UP(x, y) (((x) + (y) - 1) / (y)) 39#define DIV_ROUND_UP(x, y) (((x) + (y) - 1) / (y))
40#define max_t(type, x, y) ((x) > (y) ? (x) : (y)) 40#define max_t(type, x, y) ((x) > (y) ? (x) : (y))
41#define min_t(type, x, y) ((x) < (y) ? (x) : (y))
41#define surf_size_struct SVGA3dSize 42#define surf_size_struct SVGA3dSize
42#define u32 uint32 43#define u32 uint32
44#define u64 uint64_t
45#define U32_MAX ((u32)~0U)
43 46
44#endif /* __KERNEL__ */ 47#endif /* __KERNEL__ */
45 48
@@ -704,8 +707,8 @@ static const struct svga3d_surface_desc svga3d_surface_descs[] = {
704 707
705static inline u32 clamped_umul32(u32 a, u32 b) 708static inline u32 clamped_umul32(u32 a, u32 b)
706{ 709{
707 uint64_t tmp = (uint64_t) a*b; 710 u64 tmp = (u64) a*b;
708 return (tmp > (uint64_t) ((u32) -1)) ? (u32) -1 : tmp; 711 return (tmp > (u64) U32_MAX) ? U32_MAX : tmp;
709} 712}
710 713
711static inline const struct svga3d_surface_desc * 714static inline const struct svga3d_surface_desc *
@@ -834,7 +837,7 @@ svga3dsurface_get_serialized_size(SVGA3dSurfaceFormat format,
834 bool cubemap) 837 bool cubemap)
835{ 838{
836 const struct svga3d_surface_desc *desc = svga3dsurface_get_desc(format); 839 const struct svga3d_surface_desc *desc = svga3dsurface_get_desc(format);
837 u32 total_size = 0; 840 u64 total_size = 0;
838 u32 mip; 841 u32 mip;
839 842
840 for (mip = 0; mip < num_mip_levels; mip++) { 843 for (mip = 0; mip < num_mip_levels; mip++) {
@@ -847,7 +850,7 @@ svga3dsurface_get_serialized_size(SVGA3dSurfaceFormat format,
847 if (cubemap) 850 if (cubemap)
848 total_size *= SVGA3D_MAX_SURFACE_FACES; 851 total_size *= SVGA3D_MAX_SURFACE_FACES;
849 852
850 return total_size; 853 return (u32) min_t(u64, total_size, (u64) U32_MAX);
851} 854}
852 855
853 856
diff --git a/drivers/gpu/drm/vmwgfx/svga_reg.h b/drivers/gpu/drm/vmwgfx/svga_reg.h
index 71defa4d2d75..11323dd5196f 100644
--- a/drivers/gpu/drm/vmwgfx/svga_reg.h
+++ b/drivers/gpu/drm/vmwgfx/svga_reg.h
@@ -169,10 +169,17 @@ enum {
169 SVGA_REG_TRACES = 45, /* Enable trace-based updates even when FIFO is on */ 169 SVGA_REG_TRACES = 45, /* Enable trace-based updates even when FIFO is on */
170 SVGA_REG_GMRS_MAX_PAGES = 46, /* Maximum number of 4KB pages for all GMRs */ 170 SVGA_REG_GMRS_MAX_PAGES = 46, /* Maximum number of 4KB pages for all GMRs */
171 SVGA_REG_MEMORY_SIZE = 47, /* Total dedicated device memory excluding FIFO */ 171 SVGA_REG_MEMORY_SIZE = 47, /* Total dedicated device memory excluding FIFO */
172 SVGA_REG_COMMAND_LOW = 48, /* Lower 32 bits and submits commands */
173 SVGA_REG_COMMAND_HIGH = 49, /* Upper 32 bits of command buffer PA */
172 SVGA_REG_MAX_PRIMARY_BOUNDING_BOX_MEM = 50, /* Max primary memory */ 174 SVGA_REG_MAX_PRIMARY_BOUNDING_BOX_MEM = 50, /* Max primary memory */
173 SVGA_REG_SUGGESTED_GBOBJECT_MEM_SIZE_KB = 51, /* Suggested limit on mob mem */ 175 SVGA_REG_SUGGESTED_GBOBJECT_MEM_SIZE_KB = 51, /* Suggested limit on mob mem */
174 SVGA_REG_DEV_CAP = 52, /* Write dev cap index, read value */ 176 SVGA_REG_DEV_CAP = 52, /* Write dev cap index, read value */
175 SVGA_REG_TOP = 53, /* Must be 1 more than the last register */ 177 SVGA_REG_CMD_PREPEND_LOW = 53,
178 SVGA_REG_CMD_PREPEND_HIGH = 54,
179 SVGA_REG_SCREENTARGET_MAX_WIDTH = 55,
180 SVGA_REG_SCREENTARGET_MAX_HEIGHT = 56,
181 SVGA_REG_MOB_MAX_SIZE = 57,
182 SVGA_REG_TOP = 58, /* Must be 1 more than the last register */
176 183
177 SVGA_PALETTE_BASE = 1024, /* Base of SVGA color map */ 184 SVGA_PALETTE_BASE = 1024, /* Base of SVGA color map */
178 /* Next 768 (== 256*3) registers exist for colormap */ 185 /* Next 768 (== 256*3) registers exist for colormap */
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_context.c b/drivers/gpu/drm/vmwgfx/vmwgfx_context.c
index 9426c53fb483..1e80152674b5 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_context.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_context.c
@@ -551,8 +551,7 @@ static int vmw_context_scrub_shader(struct vmw_ctx_bindinfo *bi, bool rebind)
551 cmd->header.size = sizeof(cmd->body); 551 cmd->header.size = sizeof(cmd->body);
552 cmd->body.cid = bi->ctx->id; 552 cmd->body.cid = bi->ctx->id;
553 cmd->body.type = bi->i1.shader_type; 553 cmd->body.type = bi->i1.shader_type;
554 cmd->body.shid = 554 cmd->body.shid = ((rebind) ? bi->res->id : SVGA3D_INVALID_ID);
555 cpu_to_le32((rebind) ? bi->res->id : SVGA3D_INVALID_ID);
556 vmw_fifo_commit(dev_priv, sizeof(*cmd)); 555 vmw_fifo_commit(dev_priv, sizeof(*cmd));
557 556
558 return 0; 557 return 0;
@@ -585,8 +584,7 @@ static int vmw_context_scrub_render_target(struct vmw_ctx_bindinfo *bi,
585 cmd->header.size = sizeof(cmd->body); 584 cmd->header.size = sizeof(cmd->body);
586 cmd->body.cid = bi->ctx->id; 585 cmd->body.cid = bi->ctx->id;
587 cmd->body.type = bi->i1.rt_type; 586 cmd->body.type = bi->i1.rt_type;
588 cmd->body.target.sid = 587 cmd->body.target.sid = ((rebind) ? bi->res->id : SVGA3D_INVALID_ID);
589 cpu_to_le32((rebind) ? bi->res->id : SVGA3D_INVALID_ID);
590 cmd->body.target.face = 0; 588 cmd->body.target.face = 0;
591 cmd->body.target.mipmap = 0; 589 cmd->body.target.mipmap = 0;
592 vmw_fifo_commit(dev_priv, sizeof(*cmd)); 590 vmw_fifo_commit(dev_priv, sizeof(*cmd));
@@ -628,8 +626,7 @@ static int vmw_context_scrub_texture(struct vmw_ctx_bindinfo *bi,
628 cmd->body.c.cid = bi->ctx->id; 626 cmd->body.c.cid = bi->ctx->id;
629 cmd->body.s1.stage = bi->i1.texture_stage; 627 cmd->body.s1.stage = bi->i1.texture_stage;
630 cmd->body.s1.name = SVGA3D_TS_BIND_TEXTURE; 628 cmd->body.s1.name = SVGA3D_TS_BIND_TEXTURE;
631 cmd->body.s1.value = 629 cmd->body.s1.value = ((rebind) ? bi->res->id : SVGA3D_INVALID_ID);
632 cpu_to_le32((rebind) ? bi->res->id : SVGA3D_INVALID_ID);
633 vmw_fifo_commit(dev_priv, sizeof(*cmd)); 630 vmw_fifo_commit(dev_priv, sizeof(*cmd));
634 631
635 return 0; 632 return 0;
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
index 3bdc0adc656d..0083cbf99edf 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
@@ -667,6 +667,7 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset)
667 dev_priv->memory_size = 512*1024*1024; 667 dev_priv->memory_size = 512*1024*1024;
668 } 668 }
669 dev_priv->max_mob_pages = 0; 669 dev_priv->max_mob_pages = 0;
670 dev_priv->max_mob_size = 0;
670 if (dev_priv->capabilities & SVGA_CAP_GBOBJECTS) { 671 if (dev_priv->capabilities & SVGA_CAP_GBOBJECTS) {
671 uint64_t mem_size = 672 uint64_t mem_size =
672 vmw_read(dev_priv, 673 vmw_read(dev_priv,
@@ -676,6 +677,8 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset)
676 dev_priv->prim_bb_mem = 677 dev_priv->prim_bb_mem =
677 vmw_read(dev_priv, 678 vmw_read(dev_priv,
678 SVGA_REG_MAX_PRIMARY_BOUNDING_BOX_MEM); 679 SVGA_REG_MAX_PRIMARY_BOUNDING_BOX_MEM);
680 dev_priv->max_mob_size =
681 vmw_read(dev_priv, SVGA_REG_MOB_MAX_SIZE);
679 } else 682 } else
680 dev_priv->prim_bb_mem = dev_priv->vram_size; 683 dev_priv->prim_bb_mem = dev_priv->vram_size;
681 684
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
index ecaa302a6154..9e4be1725985 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
@@ -386,6 +386,7 @@ struct vmw_private {
386 uint32_t max_gmr_ids; 386 uint32_t max_gmr_ids;
387 uint32_t max_gmr_pages; 387 uint32_t max_gmr_pages;
388 uint32_t max_mob_pages; 388 uint32_t max_mob_pages;
389 uint32_t max_mob_size;
389 uint32_t memory_size; 390 uint32_t memory_size;
390 bool has_gmr; 391 bool has_gmr;
391 bool has_mob; 392 bool has_mob;
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
index 269b85cc875a..efb575a7996c 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
@@ -602,7 +602,7 @@ static int vmw_cmd_cid_check(struct vmw_private *dev_priv,
602{ 602{
603 struct vmw_cid_cmd { 603 struct vmw_cid_cmd {
604 SVGA3dCmdHeader header; 604 SVGA3dCmdHeader header;
605 __le32 cid; 605 uint32_t cid;
606 } *cmd; 606 } *cmd;
607 607
608 cmd = container_of(header, struct vmw_cid_cmd, header); 608 cmd = container_of(header, struct vmw_cid_cmd, header);
@@ -1835,7 +1835,7 @@ static int vmw_cmd_check_not_3d(struct vmw_private *dev_priv,
1835 return 0; 1835 return 0;
1836} 1836}
1837 1837
1838static const struct vmw_cmd_entry const vmw_cmd_entries[SVGA_3D_CMD_MAX] = { 1838static const struct vmw_cmd_entry vmw_cmd_entries[SVGA_3D_CMD_MAX] = {
1839 VMW_CMD_DEF(SVGA_3D_CMD_SURFACE_DEFINE, &vmw_cmd_invalid, 1839 VMW_CMD_DEF(SVGA_3D_CMD_SURFACE_DEFINE, &vmw_cmd_invalid,
1840 false, false, false), 1840 false, false, false),
1841 VMW_CMD_DEF(SVGA_3D_CMD_SURFACE_DESTROY, &vmw_cmd_invalid, 1841 VMW_CMD_DEF(SVGA_3D_CMD_SURFACE_DESTROY, &vmw_cmd_invalid,
@@ -2032,6 +2032,9 @@ static int vmw_cmd_check(struct vmw_private *dev_priv,
2032 goto out_invalid; 2032 goto out_invalid;
2033 2033
2034 entry = &vmw_cmd_entries[cmd_id]; 2034 entry = &vmw_cmd_entries[cmd_id];
2035 if (unlikely(!entry->func))
2036 goto out_invalid;
2037
2035 if (unlikely(!entry->user_allow && !sw_context->kernel)) 2038 if (unlikely(!entry->user_allow && !sw_context->kernel))
2036 goto out_privileged; 2039 goto out_privileged;
2037 2040
@@ -2469,7 +2472,7 @@ int vmw_execbuf_process(struct drm_file *file_priv,
2469 if (dev_priv->has_mob) { 2472 if (dev_priv->has_mob) {
2470 ret = vmw_rebind_contexts(sw_context); 2473 ret = vmw_rebind_contexts(sw_context);
2471 if (unlikely(ret != 0)) 2474 if (unlikely(ret != 0))
2472 goto out_err; 2475 goto out_unlock_binding;
2473 } 2476 }
2474 2477
2475 cmd = vmw_fifo_reserve(dev_priv, command_size); 2478 cmd = vmw_fifo_reserve(dev_priv, command_size);
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
index f9881f9e62bd..47b70949bf3a 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
@@ -102,6 +102,9 @@ int vmw_getparam_ioctl(struct drm_device *dev, void *data,
102 vmw_fp->gb_aware = true; 102 vmw_fp->gb_aware = true;
103 param->value = dev_priv->max_mob_pages * PAGE_SIZE; 103 param->value = dev_priv->max_mob_pages * PAGE_SIZE;
104 break; 104 break;
105 case DRM_VMW_PARAM_MAX_MOB_SIZE:
106 param->value = dev_priv->max_mob_size;
107 break;
105 default: 108 default:
106 DRM_ERROR("Illegal vmwgfx get param request: %d\n", 109 DRM_ERROR("Illegal vmwgfx get param request: %d\n",
107 param->param); 110 param->param);
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_shader.c b/drivers/gpu/drm/vmwgfx/vmwgfx_shader.c
index 217d941b8176..ee3856578a12 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_shader.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_shader.c
@@ -371,13 +371,13 @@ int vmw_shader_destroy_ioctl(struct drm_device *dev, void *data,
371 TTM_REF_USAGE); 371 TTM_REF_USAGE);
372} 372}
373 373
374int vmw_shader_alloc(struct vmw_private *dev_priv, 374static int vmw_shader_alloc(struct vmw_private *dev_priv,
375 struct vmw_dma_buffer *buffer, 375 struct vmw_dma_buffer *buffer,
376 size_t shader_size, 376 size_t shader_size,
377 size_t offset, 377 size_t offset,
378 SVGA3dShaderType shader_type, 378 SVGA3dShaderType shader_type,
379 struct ttm_object_file *tfile, 379 struct ttm_object_file *tfile,
380 u32 *handle) 380 u32 *handle)
381{ 381{
382 struct vmw_user_shader *ushader; 382 struct vmw_user_shader *ushader;
383 struct vmw_resource *res, *tmp; 383 struct vmw_resource *res, *tmp;
@@ -779,6 +779,8 @@ vmw_compat_shader_man_create(struct vmw_private *dev_priv)
779 int ret; 779 int ret;
780 780
781 man = kzalloc(sizeof(*man), GFP_KERNEL); 781 man = kzalloc(sizeof(*man), GFP_KERNEL);
782 if (man == NULL)
783 return ERR_PTR(-ENOMEM);
782 784
783 man->dev_priv = dev_priv; 785 man->dev_priv = dev_priv;
784 INIT_LIST_HEAD(&man->list); 786 INIT_LIST_HEAD(&man->list);
diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c
index 497558127bb3..f822fd2a1ada 100644
--- a/drivers/hid/hid-apple.c
+++ b/drivers/hid/hid-apple.c
@@ -469,6 +469,9 @@ static const struct hid_device_id apple_devices[] = {
469 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, 469 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE,
470 USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ANSI), 470 USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ANSI),
471 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, 471 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
472 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE,
473 USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_JIS),
474 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
472 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS), 475 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS),
473 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, 476 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
474 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ANSI), 477 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ANSI),
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 3bfac3accd22..cc32a6f96c64 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1679,6 +1679,7 @@ static const struct hid_device_id hid_have_special_driver[] = {
1679 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS) }, 1679 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS) },
1680 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ANSI) }, 1680 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ANSI) },
1681 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ISO) }, 1681 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ISO) },
1682 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_JIS) },
1682 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) }, 1683 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) },
1683 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) }, 1684 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) },
1684 { HID_USB_DEVICE(USB_VENDOR_ID_AUREAL, USB_DEVICE_ID_AUREAL_W01RN) }, 1685 { HID_USB_DEVICE(USB_VENDOR_ID_AUREAL, USB_DEVICE_ID_AUREAL_W01RN) },
@@ -1779,6 +1780,8 @@ static const struct hid_device_id hid_have_special_driver[] = {
1779 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_USB) }, 1780 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_USB) },
1780 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_DIGITAL_MEDIA_3K) }, 1781 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_DIGITAL_MEDIA_3K) },
1781 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_WIRELESS_OPTICAL_DESKTOP_3_0) }, 1782 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_WIRELESS_OPTICAL_DESKTOP_3_0) },
1783 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TYPE_COVER_2) },
1784 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TOUCH_COVER_2) },
1782 { HID_USB_DEVICE(USB_VENDOR_ID_MONTEREY, USB_DEVICE_ID_GENIUS_KB29E) }, 1785 { HID_USB_DEVICE(USB_VENDOR_ID_MONTEREY, USB_DEVICE_ID_GENIUS_KB29E) },
1783 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN) }, 1786 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN) },
1784 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_1) }, 1787 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_1) },
diff --git a/drivers/hid/hid-hyperv.c b/drivers/hid/hid-hyperv.c
index 8fae6d1414cc..c24908f14934 100644
--- a/drivers/hid/hid-hyperv.c
+++ b/drivers/hid/hid-hyperv.c
@@ -157,6 +157,7 @@ struct mousevsc_dev {
157 u32 report_desc_size; 157 u32 report_desc_size;
158 struct hv_input_dev_info hid_dev_info; 158 struct hv_input_dev_info hid_dev_info;
159 struct hid_device *hid_device; 159 struct hid_device *hid_device;
160 u8 input_buf[HID_MAX_BUFFER_SIZE];
160}; 161};
161 162
162 163
@@ -256,6 +257,7 @@ static void mousevsc_on_receive(struct hv_device *device,
256 struct synthhid_msg *hid_msg; 257 struct synthhid_msg *hid_msg;
257 struct mousevsc_dev *input_dev = hv_get_drvdata(device); 258 struct mousevsc_dev *input_dev = hv_get_drvdata(device);
258 struct synthhid_input_report *input_report; 259 struct synthhid_input_report *input_report;
260 size_t len;
259 261
260 pipe_msg = (struct pipe_prt_msg *)((unsigned long)packet + 262 pipe_msg = (struct pipe_prt_msg *)((unsigned long)packet +
261 (packet->offset8 << 3)); 263 (packet->offset8 << 3));
@@ -300,9 +302,12 @@ static void mousevsc_on_receive(struct hv_device *device,
300 (struct synthhid_input_report *)pipe_msg->data; 302 (struct synthhid_input_report *)pipe_msg->data;
301 if (!input_dev->init_complete) 303 if (!input_dev->init_complete)
302 break; 304 break;
303 hid_input_report(input_dev->hid_device, 305
304 HID_INPUT_REPORT, input_report->buffer, 306 len = min(input_report->header.size,
305 input_report->header.size, 1); 307 (u32)sizeof(input_dev->input_buf));
308 memcpy(input_dev->input_buf, input_report->buffer, len);
309 hid_input_report(input_dev->hid_device, HID_INPUT_REPORT,
310 input_dev->input_buf, len, 1);
306 break; 311 break;
307 default: 312 default:
308 pr_err("unsupported hid msg type - type %d len %d", 313 pr_err("unsupported hid msg type - type %d len %d",
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index 5a5248f2cc07..22f28d6b33a8 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -135,6 +135,7 @@
135#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS 0x023b 135#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS 0x023b
136#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ANSI 0x0255 136#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ANSI 0x0255
137#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ISO 0x0256 137#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ISO 0x0256
138#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_JIS 0x0257
138#define USB_DEVICE_ID_APPLE_WELLSPRING8_ANSI 0x0290 139#define USB_DEVICE_ID_APPLE_WELLSPRING8_ANSI 0x0290
139#define USB_DEVICE_ID_APPLE_WELLSPRING8_ISO 0x0291 140#define USB_DEVICE_ID_APPLE_WELLSPRING8_ISO 0x0291
140#define USB_DEVICE_ID_APPLE_WELLSPRING8_JIS 0x0292 141#define USB_DEVICE_ID_APPLE_WELLSPRING8_JIS 0x0292
@@ -240,6 +241,7 @@
240 241
241#define USB_VENDOR_ID_CYGNAL 0x10c4 242#define USB_VENDOR_ID_CYGNAL 0x10c4
242#define USB_DEVICE_ID_CYGNAL_RADIO_SI470X 0x818a 243#define USB_DEVICE_ID_CYGNAL_RADIO_SI470X 0x818a
244#define USB_DEVICE_ID_FOCALTECH_FTXXXX_MULTITOUCH 0x81b9
243 245
244#define USB_DEVICE_ID_CYGNAL_RADIO_SI4713 0x8244 246#define USB_DEVICE_ID_CYGNAL_RADIO_SI4713 0x8244
245 247
@@ -451,6 +453,9 @@
451#define USB_VENDOR_ID_INTEL_1 0x8087 453#define USB_VENDOR_ID_INTEL_1 0x8087
452#define USB_DEVICE_ID_INTEL_HID_SENSOR 0x09fa 454#define USB_DEVICE_ID_INTEL_HID_SENSOR 0x09fa
453 455
456#define USB_VENDOR_ID_STM_0 0x0483
457#define USB_DEVICE_ID_STM_HID_SENSOR 0x91d1
458
454#define USB_VENDOR_ID_ION 0x15e4 459#define USB_VENDOR_ID_ION 0x15e4
455#define USB_DEVICE_ID_ICADE 0x0132 460#define USB_DEVICE_ID_ICADE 0x0132
456 461
@@ -619,6 +624,8 @@
619#define USB_DEVICE_ID_MS_PRESENTER_8K_USB 0x0713 624#define USB_DEVICE_ID_MS_PRESENTER_8K_USB 0x0713
620#define USB_DEVICE_ID_MS_DIGITAL_MEDIA_3K 0x0730 625#define USB_DEVICE_ID_MS_DIGITAL_MEDIA_3K 0x0730
621#define USB_DEVICE_ID_MS_COMFORT_MOUSE_4500 0x076c 626#define USB_DEVICE_ID_MS_COMFORT_MOUSE_4500 0x076c
627#define USB_DEVICE_ID_MS_TOUCH_COVER_2 0x07a7
628#define USB_DEVICE_ID_MS_TYPE_COVER_2 0x07a9
622 629
623#define USB_VENDOR_ID_MOJO 0x8282 630#define USB_VENDOR_ID_MOJO 0x8282
624#define USB_DEVICE_ID_RETRO_ADAPTER 0x3201 631#define USB_DEVICE_ID_RETRO_ADAPTER 0x3201
@@ -644,6 +651,7 @@
644 651
645#define USB_VENDOR_ID_NEXIO 0x1870 652#define USB_VENDOR_ID_NEXIO 0x1870
646#define USB_DEVICE_ID_NEXIO_MULTITOUCH_420 0x010d 653#define USB_DEVICE_ID_NEXIO_MULTITOUCH_420 0x010d
654#define USB_DEVICE_ID_NEXIO_MULTITOUCH_PTI0750 0x0110
647 655
648#define USB_VENDOR_ID_NEXTWINDOW 0x1926 656#define USB_VENDOR_ID_NEXTWINDOW 0x1926
649#define USB_DEVICE_ID_NEXTWINDOW_TOUCHSCREEN 0x0003 657#define USB_DEVICE_ID_NEXTWINDOW_TOUCHSCREEN 0x0003
diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
index d50e7313b171..a713e6211419 100644
--- a/drivers/hid/hid-input.c
+++ b/drivers/hid/hid-input.c
@@ -1178,7 +1178,7 @@ static void hidinput_led_worker(struct work_struct *work)
1178 1178
1179 /* fall back to generic raw-output-report */ 1179 /* fall back to generic raw-output-report */
1180 len = ((report->size - 1) >> 3) + 1 + (report->id > 0); 1180 len = ((report->size - 1) >> 3) + 1 + (report->id > 0);
1181 buf = kmalloc(len, GFP_KERNEL); 1181 buf = hid_alloc_report_buf(report, GFP_KERNEL);
1182 if (!buf) 1182 if (!buf)
1183 return; 1183 return;
1184 1184
diff --git a/drivers/hid/hid-microsoft.c b/drivers/hid/hid-microsoft.c
index c6ef6eed3091..404a3a8a82f1 100644
--- a/drivers/hid/hid-microsoft.c
+++ b/drivers/hid/hid-microsoft.c
@@ -208,6 +208,10 @@ static const struct hid_device_id ms_devices[] = {
208 .driver_data = MS_NOGET }, 208 .driver_data = MS_NOGET },
209 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_COMFORT_MOUSE_4500), 209 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_COMFORT_MOUSE_4500),
210 .driver_data = MS_DUPLICATE_USAGES }, 210 .driver_data = MS_DUPLICATE_USAGES },
211 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TYPE_COVER_2),
212 .driver_data = 0 },
213 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TOUCH_COVER_2),
214 .driver_data = 0 },
211 215
212 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_BT), 216 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_BT),
213 .driver_data = MS_PRESENTER }, 217 .driver_data = MS_PRESENTER },
diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
index f134d73beca1..221d503f1c24 100644
--- a/drivers/hid/hid-multitouch.c
+++ b/drivers/hid/hid-multitouch.c
@@ -1166,6 +1166,11 @@ static const struct hid_device_id mt_devices[] = {
1166 MT_USB_DEVICE(USB_VENDOR_ID_FLATFROG, 1166 MT_USB_DEVICE(USB_VENDOR_ID_FLATFROG,
1167 USB_DEVICE_ID_MULTITOUCH_3200) }, 1167 USB_DEVICE_ID_MULTITOUCH_3200) },
1168 1168
1169 /* FocalTech Panels */
1170 { .driver_data = MT_CLS_SERIAL,
1171 MT_USB_DEVICE(USB_VENDOR_ID_CYGNAL,
1172 USB_DEVICE_ID_FOCALTECH_FTXXXX_MULTITOUCH) },
1173
1169 /* GeneralTouch panel */ 1174 /* GeneralTouch panel */
1170 { .driver_data = MT_CLS_GENERALTOUCH_TWOFINGERS, 1175 { .driver_data = MT_CLS_GENERALTOUCH_TWOFINGERS,
1171 MT_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 1176 MT_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH,
diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c
index 46f4480035bc..9c22e14c57f0 100644
--- a/drivers/hid/hid-sensor-hub.c
+++ b/drivers/hid/hid-sensor-hub.c
@@ -665,6 +665,9 @@ static const struct hid_device_id sensor_hub_devices[] = {
665 { HID_DEVICE(HID_BUS_ANY, HID_GROUP_SENSOR_HUB, USB_VENDOR_ID_INTEL_1, 665 { HID_DEVICE(HID_BUS_ANY, HID_GROUP_SENSOR_HUB, USB_VENDOR_ID_INTEL_1,
666 USB_DEVICE_ID_INTEL_HID_SENSOR), 666 USB_DEVICE_ID_INTEL_HID_SENSOR),
667 .driver_data = HID_SENSOR_HUB_ENUM_QUIRK}, 667 .driver_data = HID_SENSOR_HUB_ENUM_QUIRK},
668 { HID_DEVICE(HID_BUS_ANY, HID_GROUP_SENSOR_HUB, USB_VENDOR_ID_STM_0,
669 USB_DEVICE_ID_STM_HID_SENSOR),
670 .driver_data = HID_SENSOR_HUB_ENUM_QUIRK},
668 { HID_DEVICE(HID_BUS_ANY, HID_GROUP_SENSOR_HUB, HID_ANY_ID, 671 { HID_DEVICE(HID_BUS_ANY, HID_GROUP_SENSOR_HUB, HID_ANY_ID,
669 HID_ANY_ID) }, 672 HID_ANY_ID) },
670 { } 673 { }
diff --git a/drivers/hid/i2c-hid/i2c-hid.c b/drivers/hid/i2c-hid/i2c-hid.c
index d1f81f52481a..42eebd14de1f 100644
--- a/drivers/hid/i2c-hid/i2c-hid.c
+++ b/drivers/hid/i2c-hid/i2c-hid.c
@@ -582,7 +582,7 @@ static void i2c_hid_request(struct hid_device *hid, struct hid_report *rep,
582 int ret; 582 int ret;
583 int len = i2c_hid_get_report_length(rep) - 2; 583 int len = i2c_hid_get_report_length(rep) - 2;
584 584
585 buf = kzalloc(len, GFP_KERNEL); 585 buf = hid_alloc_report_buf(rep, GFP_KERNEL);
586 if (!buf) 586 if (!buf)
587 return; 587 return;
588 588
diff --git a/drivers/hid/usbhid/hid-quirks.c b/drivers/hid/usbhid/hid-quirks.c
index 175ec0afb70c..dbd83878ff99 100644
--- a/drivers/hid/usbhid/hid-quirks.c
+++ b/drivers/hid/usbhid/hid-quirks.c
@@ -74,6 +74,7 @@ static const struct hid_blacklist {
74 { USB_VENDOR_ID_FREESCALE, USB_DEVICE_ID_FREESCALE_MX28, HID_QUIRK_NOGET }, 74 { USB_VENDOR_ID_FREESCALE, USB_DEVICE_ID_FREESCALE_MX28, HID_QUIRK_NOGET },
75 { USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS, HID_QUIRK_NOGET }, 75 { USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS, HID_QUIRK_NOGET },
76 { USB_VENDOR_ID_MSI, USB_DEVICE_ID_MSI_GX680R_LED_PANEL, HID_QUIRK_NO_INIT_REPORTS }, 76 { USB_VENDOR_ID_MSI, USB_DEVICE_ID_MSI_GX680R_LED_PANEL, HID_QUIRK_NO_INIT_REPORTS },
77 { USB_VENDOR_ID_NEXIO, USB_DEVICE_ID_NEXIO_MULTITOUCH_PTI0750, HID_QUIRK_NO_INIT_REPORTS },
77 { USB_VENDOR_ID_NOVATEK, USB_DEVICE_ID_NOVATEK_MOUSE, HID_QUIRK_NO_INIT_REPORTS }, 78 { USB_VENDOR_ID_NOVATEK, USB_DEVICE_ID_NOVATEK_MOUSE, HID_QUIRK_NO_INIT_REPORTS },
78 { USB_VENDOR_ID_PIXART, USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN, HID_QUIRK_NO_INIT_REPORTS }, 79 { USB_VENDOR_ID_PIXART, USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN, HID_QUIRK_NO_INIT_REPORTS },
79 { USB_VENDOR_ID_PIXART, USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN1, HID_QUIRK_NO_INIT_REPORTS }, 80 { USB_VENDOR_ID_PIXART, USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN1, HID_QUIRK_NO_INIT_REPORTS },
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/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/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/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/mmc/card/queue.c b/drivers/mmc/card/queue.c
index 357bbc54fe4b..3e049c13429c 100644
--- a/drivers/mmc/card/queue.c
+++ b/drivers/mmc/card/queue.c
@@ -197,7 +197,7 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card,
197 struct mmc_queue_req *mqrq_prev = &mq->mqrq[1]; 197 struct mmc_queue_req *mqrq_prev = &mq->mqrq[1];
198 198
199 if (mmc_dev(host)->dma_mask && *mmc_dev(host)->dma_mask) 199 if (mmc_dev(host)->dma_mask && *mmc_dev(host)->dma_mask)
200 limit = dma_max_pfn(mmc_dev(host)) << PAGE_SHIFT; 200 limit = (u64)dma_max_pfn(mmc_dev(host)) << PAGE_SHIFT;
201 201
202 mq->card = card; 202 mq->card = card;
203 mq->queue = blk_init_queue(mmc_request_fn, lock); 203 mq->queue = blk_init_queue(mmc_request_fn, lock);
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index f342278539d5..494b888a6568 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -139,7 +139,7 @@ config MACVTAP
139 This adds a specialized tap character device driver that is based 139 This adds a specialized tap character device driver that is based
140 on the MAC-VLAN network interface, called macvtap. A macvtap device 140 on the MAC-VLAN network interface, called macvtap. A macvtap device
141 can be added in the same way as a macvlan device, using 'type 141 can be added in the same way as a macvlan device, using 'type
142 macvlan', and then be accessed through the tap user space interface. 142 macvtap', and then be accessed through the tap user space interface.
143 143
144 To compile this driver as a module, choose M here: the module 144 To compile this driver as a module, choose M here: the module
145 will be called macvtap. 145 will be called macvtap.
diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c
index cce1f1bf90b4..6d20fbde8d43 100644
--- a/drivers/net/bonding/bond_3ad.c
+++ b/drivers/net/bonding/bond_3ad.c
@@ -1796,8 +1796,6 @@ void bond_3ad_initiate_agg_selection(struct bonding *bond, int timeout)
1796 BOND_AD_INFO(bond).agg_select_timer = timeout; 1796 BOND_AD_INFO(bond).agg_select_timer = timeout;
1797} 1797}
1798 1798
1799static u16 aggregator_identifier;
1800
1801/** 1799/**
1802 * bond_3ad_initialize - initialize a bond's 802.3ad parameters and structures 1800 * bond_3ad_initialize - initialize a bond's 802.3ad parameters and structures
1803 * @bond: bonding struct to work on 1801 * @bond: bonding struct to work on
@@ -1811,7 +1809,7 @@ void bond_3ad_initialize(struct bonding *bond, u16 tick_resolution)
1811 if (!MAC_ADDRESS_EQUAL(&(BOND_AD_INFO(bond).system.sys_mac_addr), 1809 if (!MAC_ADDRESS_EQUAL(&(BOND_AD_INFO(bond).system.sys_mac_addr),
1812 bond->dev->dev_addr)) { 1810 bond->dev->dev_addr)) {
1813 1811
1814 aggregator_identifier = 0; 1812 BOND_AD_INFO(bond).aggregator_identifier = 0;
1815 1813
1816 BOND_AD_INFO(bond).system.sys_priority = 0xFFFF; 1814 BOND_AD_INFO(bond).system.sys_priority = 0xFFFF;
1817 BOND_AD_INFO(bond).system.sys_mac_addr = *((struct mac_addr *)bond->dev->dev_addr); 1815 BOND_AD_INFO(bond).system.sys_mac_addr = *((struct mac_addr *)bond->dev->dev_addr);
@@ -1880,7 +1878,7 @@ void bond_3ad_bind_slave(struct slave *slave)
1880 ad_initialize_agg(aggregator); 1878 ad_initialize_agg(aggregator);
1881 1879
1882 aggregator->aggregator_mac_address = *((struct mac_addr *)bond->dev->dev_addr); 1880 aggregator->aggregator_mac_address = *((struct mac_addr *)bond->dev->dev_addr);
1883 aggregator->aggregator_identifier = (++aggregator_identifier); 1881 aggregator->aggregator_identifier = ++BOND_AD_INFO(bond).aggregator_identifier;
1884 aggregator->slave = slave; 1882 aggregator->slave = slave;
1885 aggregator->is_active = 0; 1883 aggregator->is_active = 0;
1886 aggregator->num_of_ports = 0; 1884 aggregator->num_of_ports = 0;
diff --git a/drivers/net/bonding/bond_3ad.h b/drivers/net/bonding/bond_3ad.h
index 13dc9d3c5e34..f4dd9592ac62 100644
--- a/drivers/net/bonding/bond_3ad.h
+++ b/drivers/net/bonding/bond_3ad.h
@@ -253,6 +253,7 @@ struct ad_system {
253struct ad_bond_info { 253struct ad_bond_info {
254 struct ad_system system; /* 802.3ad system structure */ 254 struct ad_system system; /* 802.3ad system structure */
255 u32 agg_select_timer; // Timer to select aggregator after all adapter's hand shakes 255 u32 agg_select_timer; // Timer to select aggregator after all adapter's hand shakes
256 u16 aggregator_identifier;
256}; 257};
257 258
258struct ad_slave_info { 259struct ad_slave_info {
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 71ba18efa15b..1c6104d3501d 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -1543,9 +1543,11 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
1543 bond_set_carrier(bond); 1543 bond_set_carrier(bond);
1544 1544
1545 if (USES_PRIMARY(bond->params.mode)) { 1545 if (USES_PRIMARY(bond->params.mode)) {
1546 block_netpoll_tx();
1546 write_lock_bh(&bond->curr_slave_lock); 1547 write_lock_bh(&bond->curr_slave_lock);
1547 bond_select_active_slave(bond); 1548 bond_select_active_slave(bond);
1548 write_unlock_bh(&bond->curr_slave_lock); 1549 write_unlock_bh(&bond->curr_slave_lock);
1550 unblock_netpoll_tx();
1549 } 1551 }
1550 1552
1551 pr_info("%s: enslaving %s as a%s interface with a%s link.\n", 1553 pr_info("%s: enslaving %s as a%s interface with a%s link.\n",
@@ -1571,10 +1573,12 @@ err_detach:
1571 if (bond->primary_slave == new_slave) 1573 if (bond->primary_slave == new_slave)
1572 bond->primary_slave = NULL; 1574 bond->primary_slave = NULL;
1573 if (bond->curr_active_slave == new_slave) { 1575 if (bond->curr_active_slave == new_slave) {
1576 block_netpoll_tx();
1574 write_lock_bh(&bond->curr_slave_lock); 1577 write_lock_bh(&bond->curr_slave_lock);
1575 bond_change_active_slave(bond, NULL); 1578 bond_change_active_slave(bond, NULL);
1576 bond_select_active_slave(bond); 1579 bond_select_active_slave(bond);
1577 write_unlock_bh(&bond->curr_slave_lock); 1580 write_unlock_bh(&bond->curr_slave_lock);
1581 unblock_netpoll_tx();
1578 } 1582 }
1579 slave_disable_netpoll(new_slave); 1583 slave_disable_netpoll(new_slave);
1580 1584
@@ -2864,9 +2868,12 @@ static int bond_slave_netdev_event(unsigned long event,
2864 pr_info("%s: Primary slave changed to %s, reselecting active slave.\n", 2868 pr_info("%s: Primary slave changed to %s, reselecting active slave.\n",
2865 bond->dev->name, bond->primary_slave ? slave_dev->name : 2869 bond->dev->name, bond->primary_slave ? slave_dev->name :
2866 "none"); 2870 "none");
2871
2872 block_netpoll_tx();
2867 write_lock_bh(&bond->curr_slave_lock); 2873 write_lock_bh(&bond->curr_slave_lock);
2868 bond_select_active_slave(bond); 2874 bond_select_active_slave(bond);
2869 write_unlock_bh(&bond->curr_slave_lock); 2875 write_unlock_bh(&bond->curr_slave_lock);
2876 unblock_netpoll_tx();
2870 break; 2877 break;
2871 case NETDEV_FEAT_CHANGE: 2878 case NETDEV_FEAT_CHANGE:
2872 bond_compute_features(bond); 2879 bond_compute_features(bond);
@@ -3700,7 +3707,7 @@ static inline int bond_slave_override(struct bonding *bond,
3700 3707
3701 3708
3702static u16 bond_select_queue(struct net_device *dev, struct sk_buff *skb, 3709static u16 bond_select_queue(struct net_device *dev, struct sk_buff *skb,
3703 void *accel_priv) 3710 void *accel_priv, select_queue_fallback_t fallback)
3704{ 3711{
3705 /* 3712 /*
3706 * This helper function exists to help dev_pick_tx get the correct 3713 * This helper function exists to help dev_pick_tx get the correct
diff --git a/drivers/net/bonding/bond_options.c b/drivers/net/bonding/bond_options.c
index 11cb943222d5..c37878432717 100644
--- a/drivers/net/bonding/bond_options.c
+++ b/drivers/net/bonding/bond_options.c
@@ -14,7 +14,7 @@
14#include <linux/errno.h> 14#include <linux/errno.h>
15#include <linux/if.h> 15#include <linux/if.h>
16#include <linux/netdevice.h> 16#include <linux/netdevice.h>
17#include <linux/rwlock.h> 17#include <linux/spinlock.h>
18#include <linux/rcupdate.h> 18#include <linux/rcupdate.h>
19#include <linux/ctype.h> 19#include <linux/ctype.h>
20#include <linux/inet.h> 20#include <linux/inet.h>
diff --git a/drivers/net/can/usb/kvaser_usb.c b/drivers/net/can/usb/kvaser_usb.c
index 6c859bba8b65..e77d11049747 100644
--- a/drivers/net/can/usb/kvaser_usb.c
+++ b/drivers/net/can/usb/kvaser_usb.c
@@ -473,6 +473,8 @@ static int kvaser_usb_get_card_info(struct kvaser_usb *dev)
473 return err; 473 return err;
474 474
475 dev->nchannels = msg.u.cardinfo.nchannels; 475 dev->nchannels = msg.u.cardinfo.nchannels;
476 if (dev->nchannels > MAX_NET_DEVICES)
477 return -EINVAL;
476 478
477 return 0; 479 return 0;
478} 480}
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
index 9d7419e0390b..66c0df78c3ff 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
@@ -1873,7 +1873,7 @@ void bnx2x_netif_stop(struct bnx2x *bp, int disable_hw)
1873} 1873}
1874 1874
1875u16 bnx2x_select_queue(struct net_device *dev, struct sk_buff *skb, 1875u16 bnx2x_select_queue(struct net_device *dev, struct sk_buff *skb,
1876 void *accel_priv) 1876 void *accel_priv, select_queue_fallback_t fallback)
1877{ 1877{
1878 struct bnx2x *bp = netdev_priv(dev); 1878 struct bnx2x *bp = netdev_priv(dev);
1879 1879
@@ -1895,7 +1895,7 @@ u16 bnx2x_select_queue(struct net_device *dev, struct sk_buff *skb,
1895 } 1895 }
1896 1896
1897 /* select a non-FCoE queue */ 1897 /* select a non-FCoE queue */
1898 return __netdev_pick_tx(dev, skb) % BNX2X_NUM_ETH_QUEUES(bp); 1898 return fallback(dev, skb) % BNX2X_NUM_ETH_QUEUES(bp);
1899} 1899}
1900 1900
1901void bnx2x_set_num_queues(struct bnx2x *bp) 1901void bnx2x_set_num_queues(struct bnx2x *bp)
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
index bfc58d488bb5..a89a40f88c25 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
@@ -496,7 +496,7 @@ int bnx2x_set_vf_vlan(struct net_device *netdev, int vf, u16 vlan, u8 qos);
496 496
497/* select_queue callback */ 497/* select_queue callback */
498u16 bnx2x_select_queue(struct net_device *dev, struct sk_buff *skb, 498u16 bnx2x_select_queue(struct net_device *dev, struct sk_buff *skb,
499 void *accel_priv); 499 void *accel_priv, select_queue_fallback_t fallback);
500 500
501static inline void bnx2x_update_rx_prod(struct bnx2x *bp, 501static inline void bnx2x_update_rx_prod(struct bnx2x *bp,
502 struct bnx2x_fastpath *fp, 502 struct bnx2x_fastpath *fp,
diff --git a/drivers/net/ethernet/dec/tulip/tulip_core.c b/drivers/net/ethernet/dec/tulip/tulip_core.c
index add05f14b38b..1642de78aac8 100644
--- a/drivers/net/ethernet/dec/tulip/tulip_core.c
+++ b/drivers/net/ethernet/dec/tulip/tulip_core.c
@@ -1939,6 +1939,7 @@ static void tulip_remove_one(struct pci_dev *pdev)
1939 pci_iounmap(pdev, tp->base_addr); 1939 pci_iounmap(pdev, tp->base_addr);
1940 free_netdev (dev); 1940 free_netdev (dev);
1941 pci_release_regions (pdev); 1941 pci_release_regions (pdev);
1942 pci_disable_device(pdev);
1942 1943
1943 /* pci_power_off (pdev, -1); */ 1944 /* pci_power_off (pdev, -1); */
1944} 1945}
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index d4782b42401b..903362a7b584 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -1778,8 +1778,6 @@ fec_enet_open(struct net_device *ndev)
1778 struct fec_enet_private *fep = netdev_priv(ndev); 1778 struct fec_enet_private *fep = netdev_priv(ndev);
1779 int ret; 1779 int ret;
1780 1780
1781 napi_enable(&fep->napi);
1782
1783 /* I should reset the ring buffers here, but I don't yet know 1781 /* I should reset the ring buffers here, but I don't yet know
1784 * a simple way to do that. 1782 * a simple way to do that.
1785 */ 1783 */
@@ -1794,6 +1792,8 @@ fec_enet_open(struct net_device *ndev)
1794 fec_enet_free_buffers(ndev); 1792 fec_enet_free_buffers(ndev);
1795 return ret; 1793 return ret;
1796 } 1794 }
1795
1796 napi_enable(&fep->napi);
1797 phy_start(fep->phy_dev); 1797 phy_start(fep->phy_dev);
1798 netif_start_queue(ndev); 1798 netif_start_queue(ndev);
1799 fep->opened = 1; 1799 fep->opened = 1;
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index 6d4ada72dfd0..18076c4178b4 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -6881,7 +6881,7 @@ static inline int ixgbe_maybe_stop_tx(struct ixgbe_ring *tx_ring, u16 size)
6881} 6881}
6882 6882
6883static u16 ixgbe_select_queue(struct net_device *dev, struct sk_buff *skb, 6883static u16 ixgbe_select_queue(struct net_device *dev, struct sk_buff *skb,
6884 void *accel_priv) 6884 void *accel_priv, select_queue_fallback_t fallback)
6885{ 6885{
6886 struct ixgbe_fwd_adapter *fwd_adapter = accel_priv; 6886 struct ixgbe_fwd_adapter *fwd_adapter = accel_priv;
6887#ifdef IXGBE_FCOE 6887#ifdef IXGBE_FCOE
@@ -6907,7 +6907,7 @@ static u16 ixgbe_select_queue(struct net_device *dev, struct sk_buff *skb,
6907 if (adapter->flags & IXGBE_FLAG_FCOE_ENABLED) 6907 if (adapter->flags & IXGBE_FLAG_FCOE_ENABLED)
6908 break; 6908 break;
6909 default: 6909 default:
6910 return __netdev_pick_tx(dev, skb); 6910 return fallback(dev, skb);
6911 } 6911 }
6912 6912
6913 f = &adapter->ring_feature[RING_F_FCOE]; 6913 f = &adapter->ring_feature[RING_F_FCOE];
@@ -6920,7 +6920,7 @@ static u16 ixgbe_select_queue(struct net_device *dev, struct sk_buff *skb,
6920 6920
6921 return txq + f->offset; 6921 return txq + f->offset;
6922#else 6922#else
6923 return __netdev_pick_tx(dev, skb); 6923 return fallback(dev, skb);
6924#endif 6924#endif
6925} 6925}
6926 6926
diff --git a/drivers/net/ethernet/lantiq_etop.c b/drivers/net/ethernet/lantiq_etop.c
index 8f9266c64c75..fd4b6aecf6ee 100644
--- a/drivers/net/ethernet/lantiq_etop.c
+++ b/drivers/net/ethernet/lantiq_etop.c
@@ -619,7 +619,7 @@ ltq_etop_set_multicast_list(struct net_device *dev)
619 619
620static u16 620static u16
621ltq_etop_select_queue(struct net_device *dev, struct sk_buff *skb, 621ltq_etop_select_queue(struct net_device *dev, struct sk_buff *skb,
622 void *accel_priv) 622 void *accel_priv, select_queue_fallback_t fallback)
623{ 623{
624 /* we are currently only using the first queue */ 624 /* we are currently only using the first queue */
625 return 0; 625 return 0;
diff --git a/drivers/net/ethernet/marvell/Kconfig b/drivers/net/ethernet/marvell/Kconfig
index 6300fd27f2db..68e6a6613e9a 100644
--- a/drivers/net/ethernet/marvell/Kconfig
+++ b/drivers/net/ethernet/marvell/Kconfig
@@ -43,12 +43,12 @@ config MVMDIO
43 This driver is used by the MV643XX_ETH and MVNETA drivers. 43 This driver is used by the MV643XX_ETH and MVNETA drivers.
44 44
45config MVNETA 45config MVNETA
46 tristate "Marvell Armada 370/XP network interface support" 46 tristate "Marvell Armada 370/38x/XP network interface support"
47 depends on MACH_ARMADA_370_XP 47 depends on PLAT_ORION
48 select MVMDIO 48 select MVMDIO
49 ---help--- 49 ---help---
50 This driver supports the network interface units in the 50 This driver supports the network interface units in the
51 Marvell ARMADA XP and ARMADA 370 SoC family. 51 Marvell ARMADA XP, ARMADA 370 and ARMADA 38x SoC family.
52 52
53 Note that this driver is distinct from the mv643xx_eth 53 Note that this driver is distinct from the mv643xx_eth
54 driver, which should be used for the older Marvell SoCs 54 driver, which should be used for the older Marvell SoCs
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_tx.c b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
index 8e8a7eb43a2c..13457032d15f 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
@@ -629,7 +629,7 @@ static void build_inline_wqe(struct mlx4_en_tx_desc *tx_desc, struct sk_buff *sk
629} 629}
630 630
631u16 mlx4_en_select_queue(struct net_device *dev, struct sk_buff *skb, 631u16 mlx4_en_select_queue(struct net_device *dev, struct sk_buff *skb,
632 void *accel_priv) 632 void *accel_priv, select_queue_fallback_t fallback)
633{ 633{
634 struct mlx4_en_priv *priv = netdev_priv(dev); 634 struct mlx4_en_priv *priv = netdev_priv(dev);
635 u16 rings_p_up = priv->num_tx_rings_p_up; 635 u16 rings_p_up = priv->num_tx_rings_p_up;
@@ -641,7 +641,7 @@ u16 mlx4_en_select_queue(struct net_device *dev, struct sk_buff *skb,
641 if (vlan_tx_tag_present(skb)) 641 if (vlan_tx_tag_present(skb))
642 up = vlan_tx_tag_get(skb) >> VLAN_PRIO_SHIFT; 642 up = vlan_tx_tag_get(skb) >> VLAN_PRIO_SHIFT;
643 643
644 return __netdev_pick_tx(dev, skb) % rings_p_up + up * rings_p_up; 644 return fallback(dev, skb) % rings_p_up + up * rings_p_up;
645} 645}
646 646
647static void mlx4_bf_copy(void __iomem *dst, unsigned long *src, unsigned bytecnt) 647static void mlx4_bf_copy(void __iomem *dst, unsigned long *src, unsigned bytecnt)
diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
index 3af04c3f42ea..9ca223bc90fc 100644
--- a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
+++ b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
@@ -723,7 +723,7 @@ int mlx4_en_arm_cq(struct mlx4_en_priv *priv, struct mlx4_en_cq *cq);
723 723
724void mlx4_en_tx_irq(struct mlx4_cq *mcq); 724void mlx4_en_tx_irq(struct mlx4_cq *mcq);
725u16 mlx4_en_select_queue(struct net_device *dev, struct sk_buff *skb, 725u16 mlx4_en_select_queue(struct net_device *dev, struct sk_buff *skb,
726 void *accel_priv); 726 void *accel_priv, select_queue_fallback_t fallback);
727netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev); 727netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev);
728 728
729int mlx4_en_create_tx_ring(struct mlx4_en_priv *priv, 729int mlx4_en_create_tx_ring(struct mlx4_en_priv *priv,
diff --git a/drivers/net/ethernet/stmicro/stmmac/Kconfig b/drivers/net/ethernet/stmicro/stmmac/Kconfig
index e2f202e3932f..f2d7c702c77f 100644
--- a/drivers/net/ethernet/stmicro/stmmac/Kconfig
+++ b/drivers/net/ethernet/stmicro/stmmac/Kconfig
@@ -37,6 +37,17 @@ config DWMAC_SUNXI
37 stmmac device driver. This driver is used for A20/A31 37 stmmac device driver. This driver is used for A20/A31
38 GMAC ethernet controller. 38 GMAC ethernet controller.
39 39
40config DWMAC_STI
41 bool "STi GMAC support"
42 depends on STMMAC_PLATFORM && ARCH_STI
43 default y
44 ---help---
45 Support for ethernet controller on STi SOCs.
46
47 This selects STi SoC glue layer support for the stmmac
48 device driver. This driver is used on for the STi series
49 SOCs GMAC ethernet controller.
50
40config STMMAC_PCI 51config STMMAC_PCI
41 bool "STMMAC PCI bus support" 52 bool "STMMAC PCI bus support"
42 depends on STMMAC_ETH && PCI 53 depends on STMMAC_ETH && PCI
diff --git a/drivers/net/ethernet/stmicro/stmmac/Makefile b/drivers/net/ethernet/stmicro/stmmac/Makefile
index ecadecea79b2..dcef28775dad 100644
--- a/drivers/net/ethernet/stmicro/stmmac/Makefile
+++ b/drivers/net/ethernet/stmicro/stmmac/Makefile
@@ -2,6 +2,7 @@ obj-$(CONFIG_STMMAC_ETH) += stmmac.o
2stmmac-$(CONFIG_STMMAC_PLATFORM) += stmmac_platform.o 2stmmac-$(CONFIG_STMMAC_PLATFORM) += stmmac_platform.o
3stmmac-$(CONFIG_STMMAC_PCI) += stmmac_pci.o 3stmmac-$(CONFIG_STMMAC_PCI) += stmmac_pci.o
4stmmac-$(CONFIG_DWMAC_SUNXI) += dwmac-sunxi.o 4stmmac-$(CONFIG_DWMAC_SUNXI) += dwmac-sunxi.o
5stmmac-$(CONFIG_DWMAC_STI) += dwmac-sti.o
5stmmac-objs:= stmmac_main.o stmmac_ethtool.o stmmac_mdio.o ring_mode.o \ 6stmmac-objs:= stmmac_main.o stmmac_ethtool.o stmmac_mdio.o ring_mode.o \
6 chain_mode.o dwmac_lib.o dwmac1000_core.o dwmac1000_dma.o \ 7 chain_mode.o dwmac_lib.o dwmac1000_core.o dwmac1000_dma.o \
7 dwmac100_core.o dwmac100_dma.o enh_desc.o norm_desc.o \ 8 dwmac100_core.o dwmac100_dma.o enh_desc.o norm_desc.o \
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c
new file mode 100644
index 000000000000..552bbc17863c
--- /dev/null
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c
@@ -0,0 +1,330 @@
1/**
2 * dwmac-sti.c - STMicroelectronics DWMAC Specific Glue layer
3 *
4 * Copyright (C) 2003-2014 STMicroelectronics (R&D) Limited
5 * Author: Srinivas Kandagatla <srinivas.kandagatla@st.com>
6 *
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 */
13
14#include <linux/kernel.h>
15#include <linux/slab.h>
16#include <linux/platform_device.h>
17#include <linux/stmmac.h>
18#include <linux/phy.h>
19#include <linux/mfd/syscon.h>
20#include <linux/regmap.h>
21#include <linux/clk.h>
22#include <linux/of.h>
23#include <linux/of_net.h>
24
25/**
26 * STi GMAC glue logic.
27 * --------------------
28 *
29 * _
30 * | \
31 * --------|0 \ ETH_SEL_INTERNAL_NOTEXT_PHYCLK
32 * phyclk | |___________________________________________
33 * | | | (phyclk-in)
34 * --------|1 / |
35 * int-clk |_ / |
36 * | _
37 * | | \
38 * |_______|1 \ ETH_SEL_TX_RETIME_CLK
39 * | |___________________________
40 * | | (tx-retime-clk)
41 * _______|0 /
42 * | |_ /
43 * _ |
44 * | \ |
45 * --------|0 \ |
46 * clk_125 | |__|
47 * | | ETH_SEL_TXCLK_NOT_CLK125
48 * --------|1 /
49 * txclk |_ /
50 *
51 *
52 * ETH_SEL_INTERNAL_NOTEXT_PHYCLK is valid only for RMII where PHY can
53 * generate 50MHz clock or MAC can generate it.
54 * This bit is configured by "st,ext-phyclk" property.
55 *
56 * ETH_SEL_TXCLK_NOT_CLK125 is only valid for gigabit modes, where the 125Mhz
57 * clock either comes from clk-125 pin or txclk pin. This configuration is
58 * totally driven by the board wiring. This bit is configured by
59 * "st,tx-retime-src" property.
60 *
61 * TXCLK configuration is different for different phy interface modes
62 * and changes according to link speed in modes like RGMII.
63 *
64 * Below table summarizes the clock requirement and clock sources for
65 * supported phy interface modes with link speeds.
66 * ________________________________________________
67 *| PHY_MODE | 1000 Mbit Link | 100 Mbit Link |
68 * ------------------------------------------------
69 *| MII | n/a | 25Mhz |
70 *| | | txclk |
71 * ------------------------------------------------
72 *| GMII | 125Mhz | 25Mhz |
73 *| | clk-125/txclk | txclk |
74 * ------------------------------------------------
75 *| RGMII | 125Mhz | 25Mhz |
76 *| | clk-125/txclk | clkgen |
77 * ------------------------------------------------
78 *| RMII | n/a | 25Mhz |
79 *| | |clkgen/phyclk-in |
80 * ------------------------------------------------
81 *
82 * TX lines are always retimed with a clk, which can vary depending
83 * on the board configuration. Below is the table of these bits
84 * in eth configuration register depending on source of retime clk.
85 *
86 *---------------------------------------------------------------
87 * src | tx_rt_clk | int_not_ext_phyclk | txclk_n_clk125|
88 *---------------------------------------------------------------
89 * txclk | 0 | n/a | 1 |
90 *---------------------------------------------------------------
91 * ck_125| 0 | n/a | 0 |
92 *---------------------------------------------------------------
93 * phyclk| 1 | 0 | n/a |
94 *---------------------------------------------------------------
95 * clkgen| 1 | 1 | n/a |
96 *---------------------------------------------------------------
97 */
98
99 /* Register definition */
100
101 /* 3 bits [8:6]
102 * [6:6] ETH_SEL_TXCLK_NOT_CLK125
103 * [7:7] ETH_SEL_INTERNAL_NOTEXT_PHYCLK
104 * [8:8] ETH_SEL_TX_RETIME_CLK
105 *
106 */
107
108#define TX_RETIME_SRC_MASK GENMASK(8, 6)
109#define ETH_SEL_TX_RETIME_CLK BIT(8)
110#define ETH_SEL_INTERNAL_NOTEXT_PHYCLK BIT(7)
111#define ETH_SEL_TXCLK_NOT_CLK125 BIT(6)
112
113#define ENMII_MASK GENMASK(5, 5)
114#define ENMII BIT(5)
115
116/**
117 * 3 bits [4:2]
118 * 000-GMII/MII
119 * 001-RGMII
120 * 010-SGMII
121 * 100-RMII
122*/
123#define MII_PHY_SEL_MASK GENMASK(4, 2)
124#define ETH_PHY_SEL_RMII BIT(4)
125#define ETH_PHY_SEL_SGMII BIT(3)
126#define ETH_PHY_SEL_RGMII BIT(2)
127#define ETH_PHY_SEL_GMII 0x0
128#define ETH_PHY_SEL_MII 0x0
129
130#define IS_PHY_IF_MODE_RGMII(iface) (iface == PHY_INTERFACE_MODE_RGMII || \
131 iface == PHY_INTERFACE_MODE_RGMII_ID || \
132 iface == PHY_INTERFACE_MODE_RGMII_RXID || \
133 iface == PHY_INTERFACE_MODE_RGMII_TXID)
134
135#define IS_PHY_IF_MODE_GBIT(iface) (IS_PHY_IF_MODE_RGMII(iface) || \
136 iface == PHY_INTERFACE_MODE_GMII)
137
138struct sti_dwmac {
139 int interface;
140 bool ext_phyclk;
141 bool is_tx_retime_src_clk_125;
142 struct clk *clk;
143 int reg;
144 struct device *dev;
145 struct regmap *regmap;
146};
147
148static u32 phy_intf_sels[] = {
149 [PHY_INTERFACE_MODE_MII] = ETH_PHY_SEL_MII,
150 [PHY_INTERFACE_MODE_GMII] = ETH_PHY_SEL_GMII,
151 [PHY_INTERFACE_MODE_RGMII] = ETH_PHY_SEL_RGMII,
152 [PHY_INTERFACE_MODE_RGMII_ID] = ETH_PHY_SEL_RGMII,
153 [PHY_INTERFACE_MODE_SGMII] = ETH_PHY_SEL_SGMII,
154 [PHY_INTERFACE_MODE_RMII] = ETH_PHY_SEL_RMII,
155};
156
157enum {
158 TX_RETIME_SRC_NA = 0,
159 TX_RETIME_SRC_TXCLK = 1,
160 TX_RETIME_SRC_CLK_125,
161 TX_RETIME_SRC_PHYCLK,
162 TX_RETIME_SRC_CLKGEN,
163};
164
165static const char *const tx_retime_srcs[] = {
166 [TX_RETIME_SRC_NA] = "",
167 [TX_RETIME_SRC_TXCLK] = "txclk",
168 [TX_RETIME_SRC_CLK_125] = "clk_125",
169 [TX_RETIME_SRC_PHYCLK] = "phyclk",
170 [TX_RETIME_SRC_CLKGEN] = "clkgen",
171};
172
173static u32 tx_retime_val[] = {
174 [TX_RETIME_SRC_TXCLK] = ETH_SEL_TXCLK_NOT_CLK125,
175 [TX_RETIME_SRC_CLK_125] = 0x0,
176 [TX_RETIME_SRC_PHYCLK] = ETH_SEL_TX_RETIME_CLK,
177 [TX_RETIME_SRC_CLKGEN] = ETH_SEL_TX_RETIME_CLK |
178 ETH_SEL_INTERNAL_NOTEXT_PHYCLK,
179};
180
181static void setup_retime_src(struct sti_dwmac *dwmac, u32 spd)
182{
183 u32 src = 0, freq = 0;
184
185 if (spd == SPEED_100) {
186 if (dwmac->interface == PHY_INTERFACE_MODE_MII ||
187 dwmac->interface == PHY_INTERFACE_MODE_GMII) {
188 src = TX_RETIME_SRC_TXCLK;
189 } else if (dwmac->interface == PHY_INTERFACE_MODE_RMII) {
190 if (dwmac->ext_phyclk) {
191 src = TX_RETIME_SRC_PHYCLK;
192 } else {
193 src = TX_RETIME_SRC_CLKGEN;
194 freq = 50000000;
195 }
196
197 } else if (IS_PHY_IF_MODE_RGMII(dwmac->interface)) {
198 src = TX_RETIME_SRC_CLKGEN;
199 freq = 25000000;
200 }
201
202 if (src == TX_RETIME_SRC_CLKGEN && dwmac->clk)
203 clk_set_rate(dwmac->clk, freq);
204
205 } else if (spd == SPEED_1000) {
206 if (dwmac->is_tx_retime_src_clk_125)
207 src = TX_RETIME_SRC_CLK_125;
208 else
209 src = TX_RETIME_SRC_TXCLK;
210 }
211
212 regmap_update_bits(dwmac->regmap, dwmac->reg,
213 TX_RETIME_SRC_MASK, tx_retime_val[src]);
214}
215
216static void sti_dwmac_exit(struct platform_device *pdev, void *priv)
217{
218 struct sti_dwmac *dwmac = priv;
219
220 if (dwmac->clk)
221 clk_disable_unprepare(dwmac->clk);
222}
223
224static void sti_fix_mac_speed(void *priv, unsigned int spd)
225{
226 struct sti_dwmac *dwmac = priv;
227
228 setup_retime_src(dwmac, spd);
229
230 return;
231}
232
233static int sti_dwmac_parse_data(struct sti_dwmac *dwmac,
234 struct platform_device *pdev)
235{
236 struct resource *res;
237 struct device *dev = &pdev->dev;
238 struct device_node *np = dev->of_node;
239 struct regmap *regmap;
240 int err;
241
242 if (!np)
243 return -EINVAL;
244
245 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "sti-ethconf");
246 if (!res)
247 return -ENODATA;
248
249 regmap = syscon_regmap_lookup_by_phandle(np, "st,syscon");
250 if (IS_ERR(regmap))
251 return PTR_ERR(regmap);
252
253 dwmac->dev = dev;
254 dwmac->interface = of_get_phy_mode(np);
255 dwmac->regmap = regmap;
256 dwmac->reg = res->start;
257 dwmac->ext_phyclk = of_property_read_bool(np, "st,ext-phyclk");
258 dwmac->is_tx_retime_src_clk_125 = false;
259
260 if (IS_PHY_IF_MODE_GBIT(dwmac->interface)) {
261 const char *rs;
262
263 err = of_property_read_string(np, "st,tx-retime-src", &rs);
264 if (err < 0) {
265 dev_err(dev, "st,tx-retime-src not specified\n");
266 return err;
267 }
268
269 if (!strcasecmp(rs, "clk_125"))
270 dwmac->is_tx_retime_src_clk_125 = true;
271 }
272
273 dwmac->clk = devm_clk_get(dev, "sti-ethclk");
274
275 if (IS_ERR(dwmac->clk))
276 dwmac->clk = NULL;
277
278 return 0;
279}
280
281static int sti_dwmac_init(struct platform_device *pdev, void *priv)
282{
283 struct sti_dwmac *dwmac = priv;
284 struct regmap *regmap = dwmac->regmap;
285 int iface = dwmac->interface;
286 u32 reg = dwmac->reg;
287 u32 val, spd;
288
289 if (dwmac->clk)
290 clk_prepare_enable(dwmac->clk);
291
292 regmap_update_bits(regmap, reg, MII_PHY_SEL_MASK, phy_intf_sels[iface]);
293
294 val = (iface == PHY_INTERFACE_MODE_REVMII) ? 0 : ENMII;
295 regmap_update_bits(regmap, reg, ENMII_MASK, val);
296
297 if (IS_PHY_IF_MODE_GBIT(iface))
298 spd = SPEED_1000;
299 else
300 spd = SPEED_100;
301
302 setup_retime_src(dwmac, spd);
303
304 return 0;
305}
306
307static void *sti_dwmac_setup(struct platform_device *pdev)
308{
309 struct sti_dwmac *dwmac;
310 int ret;
311
312 dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL);
313 if (!dwmac)
314 return ERR_PTR(-ENOMEM);
315
316 ret = sti_dwmac_parse_data(dwmac, pdev);
317 if (ret) {
318 dev_err(&pdev->dev, "Unable to parse OF data\n");
319 return ERR_PTR(ret);
320 }
321
322 return dwmac;
323}
324
325const struct stmmac_of_data sti_gmac_data = {
326 .fix_mac_speed = sti_fix_mac_speed,
327 .setup = sti_dwmac_setup,
328 .init = sti_dwmac_init,
329 .exit = sti_dwmac_exit,
330};
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
index d9af26ed58ee..f9e60d7918c4 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
@@ -133,6 +133,9 @@ bool stmmac_eee_init(struct stmmac_priv *priv);
133#ifdef CONFIG_DWMAC_SUNXI 133#ifdef CONFIG_DWMAC_SUNXI
134extern const struct stmmac_of_data sun7i_gmac_data; 134extern const struct stmmac_of_data sun7i_gmac_data;
135#endif 135#endif
136#ifdef CONFIG_DWMAC_STI
137extern const struct stmmac_of_data sti_gmac_data;
138#endif
136extern struct platform_driver stmmac_pltfr_driver; 139extern struct platform_driver stmmac_pltfr_driver;
137static inline int stmmac_register_platform(void) 140static inline int stmmac_register_platform(void)
138{ 141{
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index 5884a7d2063b..c61bc72b8e90 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -33,6 +33,11 @@ static const struct of_device_id stmmac_dt_ids[] = {
33#ifdef CONFIG_DWMAC_SUNXI 33#ifdef CONFIG_DWMAC_SUNXI
34 { .compatible = "allwinner,sun7i-a20-gmac", .data = &sun7i_gmac_data}, 34 { .compatible = "allwinner,sun7i-a20-gmac", .data = &sun7i_gmac_data},
35#endif 35#endif
36#ifdef CONFIG_DWMAC_STI
37 { .compatible = "st,stih415-dwmac", .data = &sti_gmac_data},
38 { .compatible = "st,stih416-dwmac", .data = &sti_gmac_data},
39 { .compatible = "st,stih127-dwmac", .data = &sti_gmac_data},
40#endif
36 /* SoC specific glue layers should come before generic bindings */ 41 /* SoC specific glue layers should come before generic bindings */
37 { .compatible = "st,spear600-gmac"}, 42 { .compatible = "st,spear600-gmac"},
38 { .compatible = "snps,dwmac-3.610"}, 43 { .compatible = "snps,dwmac-3.610"},
diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index 1d860ce914ed..651087b5c8da 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -554,7 +554,7 @@ static void cpsw_set_promiscious(struct net_device *ndev, bool enable)
554 * common for both the interface as the interface shares 554 * common for both the interface as the interface shares
555 * the same hardware resource. 555 * the same hardware resource.
556 */ 556 */
557 for (i = 0; i <= priv->data.slaves; i++) 557 for (i = 0; i < priv->data.slaves; i++)
558 if (priv->slaves[i].ndev->flags & IFF_PROMISC) 558 if (priv->slaves[i].ndev->flags & IFF_PROMISC)
559 flag = true; 559 flag = true;
560 560
@@ -578,7 +578,7 @@ static void cpsw_set_promiscious(struct net_device *ndev, bool enable)
578 unsigned long timeout = jiffies + HZ; 578 unsigned long timeout = jiffies + HZ;
579 579
580 /* Disable Learn for all ports */ 580 /* Disable Learn for all ports */
581 for (i = 0; i <= priv->data.slaves; i++) { 581 for (i = 0; i < priv->data.slaves; i++) {
582 cpsw_ale_control_set(ale, i, 582 cpsw_ale_control_set(ale, i,
583 ALE_PORT_NOLEARN, 1); 583 ALE_PORT_NOLEARN, 1);
584 cpsw_ale_control_set(ale, i, 584 cpsw_ale_control_set(ale, i,
@@ -606,7 +606,7 @@ static void cpsw_set_promiscious(struct net_device *ndev, bool enable)
606 cpsw_ale_control_set(ale, 0, ALE_P0_UNI_FLOOD, 0); 606 cpsw_ale_control_set(ale, 0, ALE_P0_UNI_FLOOD, 0);
607 607
608 /* Enable Learn for all ports */ 608 /* Enable Learn for all ports */
609 for (i = 0; i <= priv->data.slaves; i++) { 609 for (i = 0; i < priv->data.slaves; i++) {
610 cpsw_ale_control_set(ale, i, 610 cpsw_ale_control_set(ale, i,
611 ALE_PORT_NOLEARN, 0); 611 ALE_PORT_NOLEARN, 0);
612 cpsw_ale_control_set(ale, i, 612 cpsw_ale_control_set(ale, i,
@@ -1896,6 +1896,11 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data,
1896 memcpy(slave_data->mac_addr, mac_addr, ETH_ALEN); 1896 memcpy(slave_data->mac_addr, mac_addr, ETH_ALEN);
1897 1897
1898 slave_data->phy_if = of_get_phy_mode(slave_node); 1898 slave_data->phy_if = of_get_phy_mode(slave_node);
1899 if (slave_data->phy_if < 0) {
1900 pr_err("Missing or malformed slave[%d] phy-mode property\n",
1901 i);
1902 return slave_data->phy_if;
1903 }
1899 1904
1900 if (data->dual_emac) { 1905 if (data->dual_emac) {
1901 if (of_property_read_u32(slave_node, "dual_emac_res_vlan", 1906 if (of_property_read_u32(slave_node, "dual_emac_res_vlan",
diff --git a/drivers/net/ethernet/tile/tilegx.c b/drivers/net/ethernet/tile/tilegx.c
index 023237a65720..17503da9f7a5 100644
--- a/drivers/net/ethernet/tile/tilegx.c
+++ b/drivers/net/ethernet/tile/tilegx.c
@@ -2071,7 +2071,7 @@ static int tile_net_tx(struct sk_buff *skb, struct net_device *dev)
2071 2071
2072/* Return subqueue id on this core (one per core). */ 2072/* Return subqueue id on this core (one per core). */
2073static u16 tile_net_select_queue(struct net_device *dev, struct sk_buff *skb, 2073static u16 tile_net_select_queue(struct net_device *dev, struct sk_buff *skb,
2074 void *accel_priv) 2074 void *accel_priv, select_queue_fallback_t fallback)
2075{ 2075{
2076 return smp_processor_id(); 2076 return smp_processor_id();
2077} 2077}
diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
index 1ec65feebb9e..4bfdf8c7ada0 100644
--- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
+++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
@@ -26,6 +26,7 @@
26#include <linux/netdevice.h> 26#include <linux/netdevice.h>
27#include <linux/of_mdio.h> 27#include <linux/of_mdio.h>
28#include <linux/of_platform.h> 28#include <linux/of_platform.h>
29#include <linux/of_irq.h>
29#include <linux/of_address.h> 30#include <linux/of_address.h>
30#include <linux/skbuff.h> 31#include <linux/skbuff.h>
31#include <linux/spinlock.h> 32#include <linux/spinlock.h>
@@ -600,7 +601,8 @@ static void axienet_start_xmit_done(struct net_device *ndev)
600 size += status & XAXIDMA_BD_STS_ACTUAL_LEN_MASK; 601 size += status & XAXIDMA_BD_STS_ACTUAL_LEN_MASK;
601 packets++; 602 packets++;
602 603
603 lp->tx_bd_ci = ++lp->tx_bd_ci % TX_BD_NUM; 604 ++lp->tx_bd_ci;
605 lp->tx_bd_ci %= TX_BD_NUM;
604 cur_p = &lp->tx_bd_v[lp->tx_bd_ci]; 606 cur_p = &lp->tx_bd_v[lp->tx_bd_ci];
605 status = cur_p->status; 607 status = cur_p->status;
606 } 608 }
@@ -686,7 +688,8 @@ static int axienet_start_xmit(struct sk_buff *skb, struct net_device *ndev)
686 skb_headlen(skb), DMA_TO_DEVICE); 688 skb_headlen(skb), DMA_TO_DEVICE);
687 689
688 for (ii = 0; ii < num_frag; ii++) { 690 for (ii = 0; ii < num_frag; ii++) {
689 lp->tx_bd_tail = ++lp->tx_bd_tail % TX_BD_NUM; 691 ++lp->tx_bd_tail;
692 lp->tx_bd_tail %= TX_BD_NUM;
690 cur_p = &lp->tx_bd_v[lp->tx_bd_tail]; 693 cur_p = &lp->tx_bd_v[lp->tx_bd_tail];
691 frag = &skb_shinfo(skb)->frags[ii]; 694 frag = &skb_shinfo(skb)->frags[ii];
692 cur_p->phys = dma_map_single(ndev->dev.parent, 695 cur_p->phys = dma_map_single(ndev->dev.parent,
@@ -702,7 +705,8 @@ static int axienet_start_xmit(struct sk_buff *skb, struct net_device *ndev)
702 tail_p = lp->tx_bd_p + sizeof(*lp->tx_bd_v) * lp->tx_bd_tail; 705 tail_p = lp->tx_bd_p + sizeof(*lp->tx_bd_v) * lp->tx_bd_tail;
703 /* Start the transfer */ 706 /* Start the transfer */
704 axienet_dma_out32(lp, XAXIDMA_TX_TDESC_OFFSET, tail_p); 707 axienet_dma_out32(lp, XAXIDMA_TX_TDESC_OFFSET, tail_p);
705 lp->tx_bd_tail = ++lp->tx_bd_tail % TX_BD_NUM; 708 ++lp->tx_bd_tail;
709 lp->tx_bd_tail %= TX_BD_NUM;
706 710
707 return NETDEV_TX_OK; 711 return NETDEV_TX_OK;
708} 712}
@@ -774,7 +778,8 @@ static void axienet_recv(struct net_device *ndev)
774 cur_p->status = 0; 778 cur_p->status = 0;
775 cur_p->sw_id_offset = (u32) new_skb; 779 cur_p->sw_id_offset = (u32) new_skb;
776 780
777 lp->rx_bd_ci = ++lp->rx_bd_ci % RX_BD_NUM; 781 ++lp->rx_bd_ci;
782 lp->rx_bd_ci %= RX_BD_NUM;
778 cur_p = &lp->rx_bd_v[lp->rx_bd_ci]; 783 cur_p = &lp->rx_bd_v[lp->rx_bd_ci];
779 } 784 }
780 785
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 7756118c2f0a..7141a1937360 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -88,8 +88,12 @@ static int netvsc_open(struct net_device *net)
88{ 88{
89 struct net_device_context *net_device_ctx = netdev_priv(net); 89 struct net_device_context *net_device_ctx = netdev_priv(net);
90 struct hv_device *device_obj = net_device_ctx->device_ctx; 90 struct hv_device *device_obj = net_device_ctx->device_ctx;
91 struct netvsc_device *nvdev;
92 struct rndis_device *rdev;
91 int ret = 0; 93 int ret = 0;
92 94
95 netif_carrier_off(net);
96
93 /* Open up the device */ 97 /* Open up the device */
94 ret = rndis_filter_open(device_obj); 98 ret = rndis_filter_open(device_obj);
95 if (ret != 0) { 99 if (ret != 0) {
@@ -99,6 +103,11 @@ static int netvsc_open(struct net_device *net)
99 103
100 netif_start_queue(net); 104 netif_start_queue(net);
101 105
106 nvdev = hv_get_drvdata(device_obj);
107 rdev = nvdev->extension;
108 if (!rdev->link_state)
109 netif_carrier_on(net);
110
102 return ret; 111 return ret;
103} 112}
104 113
@@ -229,23 +238,24 @@ void netvsc_linkstatus_callback(struct hv_device *device_obj,
229 struct net_device *net; 238 struct net_device *net;
230 struct net_device_context *ndev_ctx; 239 struct net_device_context *ndev_ctx;
231 struct netvsc_device *net_device; 240 struct netvsc_device *net_device;
241 struct rndis_device *rdev;
232 242
233 net_device = hv_get_drvdata(device_obj); 243 net_device = hv_get_drvdata(device_obj);
244 rdev = net_device->extension;
245
246 rdev->link_state = status != 1;
247
234 net = net_device->ndev; 248 net = net_device->ndev;
235 249
236 if (!net) { 250 if (!net || net->reg_state != NETREG_REGISTERED)
237 netdev_err(net, "got link status but net device "
238 "not initialized yet\n");
239 return; 251 return;
240 }
241 252
253 ndev_ctx = netdev_priv(net);
242 if (status == 1) { 254 if (status == 1) {
243 netif_carrier_on(net);
244 ndev_ctx = netdev_priv(net);
245 schedule_delayed_work(&ndev_ctx->dwork, 0); 255 schedule_delayed_work(&ndev_ctx->dwork, 0);
246 schedule_delayed_work(&ndev_ctx->dwork, msecs_to_jiffies(20)); 256 schedule_delayed_work(&ndev_ctx->dwork, msecs_to_jiffies(20));
247 } else { 257 } else {
248 netif_carrier_off(net); 258 schedule_delayed_work(&ndev_ctx->dwork, 0);
249 } 259 }
250} 260}
251 261
@@ -388,17 +398,35 @@ static const struct net_device_ops device_ops = {
388 * current context when receiving RNDIS_STATUS_MEDIA_CONNECT event. So, add 398 * current context when receiving RNDIS_STATUS_MEDIA_CONNECT event. So, add
389 * another netif_notify_peers() into a delayed work, otherwise GARP packet 399 * another netif_notify_peers() into a delayed work, otherwise GARP packet
390 * will not be sent after quick migration, and cause network disconnection. 400 * will not be sent after quick migration, and cause network disconnection.
401 * Also, we update the carrier status here.
391 */ 402 */
392static void netvsc_send_garp(struct work_struct *w) 403static void netvsc_link_change(struct work_struct *w)
393{ 404{
394 struct net_device_context *ndev_ctx; 405 struct net_device_context *ndev_ctx;
395 struct net_device *net; 406 struct net_device *net;
396 struct netvsc_device *net_device; 407 struct netvsc_device *net_device;
408 struct rndis_device *rdev;
409 bool notify;
410
411 rtnl_lock();
397 412
398 ndev_ctx = container_of(w, struct net_device_context, dwork.work); 413 ndev_ctx = container_of(w, struct net_device_context, dwork.work);
399 net_device = hv_get_drvdata(ndev_ctx->device_ctx); 414 net_device = hv_get_drvdata(ndev_ctx->device_ctx);
415 rdev = net_device->extension;
400 net = net_device->ndev; 416 net = net_device->ndev;
401 netdev_notify_peers(net); 417
418 if (rdev->link_state) {
419 netif_carrier_off(net);
420 notify = false;
421 } else {
422 netif_carrier_on(net);
423 notify = true;
424 }
425
426 rtnl_unlock();
427
428 if (notify)
429 netdev_notify_peers(net);
402} 430}
403 431
404 432
@@ -414,13 +442,10 @@ static int netvsc_probe(struct hv_device *dev,
414 if (!net) 442 if (!net)
415 return -ENOMEM; 443 return -ENOMEM;
416 444
417 /* Set initial state */
418 netif_carrier_off(net);
419
420 net_device_ctx = netdev_priv(net); 445 net_device_ctx = netdev_priv(net);
421 net_device_ctx->device_ctx = dev; 446 net_device_ctx->device_ctx = dev;
422 hv_set_drvdata(dev, net); 447 hv_set_drvdata(dev, net);
423 INIT_DELAYED_WORK(&net_device_ctx->dwork, netvsc_send_garp); 448 INIT_DELAYED_WORK(&net_device_ctx->dwork, netvsc_link_change);
424 INIT_WORK(&net_device_ctx->work, do_set_multicast); 449 INIT_WORK(&net_device_ctx->work, do_set_multicast);
425 450
426 net->netdev_ops = &device_ops; 451 net->netdev_ops = &device_ops;
@@ -443,8 +468,6 @@ static int netvsc_probe(struct hv_device *dev,
443 } 468 }
444 memcpy(net->dev_addr, device_info.mac_adr, ETH_ALEN); 469 memcpy(net->dev_addr, device_info.mac_adr, ETH_ALEN);
445 470
446 netif_carrier_on(net);
447
448 ret = register_netdev(net); 471 ret = register_netdev(net);
449 if (ret != 0) { 472 if (ret != 0) {
450 pr_err("Unable to register netdev.\n"); 473 pr_err("Unable to register netdev.\n");
diff --git a/drivers/net/irda/irtty-sir.c b/drivers/net/irda/irtty-sir.c
index 177441afeb96..24b6dddd7f2f 100644
--- a/drivers/net/irda/irtty-sir.c
+++ b/drivers/net/irda/irtty-sir.c
@@ -522,7 +522,6 @@ static void irtty_close(struct tty_struct *tty)
522 sirdev_put_instance(priv->dev); 522 sirdev_put_instance(priv->dev);
523 523
524 /* Stop tty */ 524 /* Stop tty */
525 irtty_stop_receiver(tty, TRUE);
526 clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); 525 clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
527 if (tty->ops->stop) 526 if (tty->ops->stop)
528 tty->ops->stop(tty); 527 tty->ops->stop(tty);
diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index 8433de4509c7..a5d21893670d 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -879,14 +879,15 @@ int macvlan_common_newlink(struct net *src_net, struct net_device *dev,
879 dev->priv_flags |= IFF_MACVLAN; 879 dev->priv_flags |= IFF_MACVLAN;
880 err = netdev_upper_dev_link(lowerdev, dev); 880 err = netdev_upper_dev_link(lowerdev, dev);
881 if (err) 881 if (err)
882 goto destroy_port; 882 goto unregister_netdev;
883
884 883
885 list_add_tail_rcu(&vlan->list, &port->vlans); 884 list_add_tail_rcu(&vlan->list, &port->vlans);
886 netif_stacked_transfer_operstate(lowerdev, dev); 885 netif_stacked_transfer_operstate(lowerdev, dev);
887 886
888 return 0; 887 return 0;
889 888
889unregister_netdev:
890 unregister_netdevice(dev);
890destroy_port: 891destroy_port:
891 port->count -= 1; 892 port->count -= 1;
892 if (!port->count) 893 if (!port->count)
diff --git a/drivers/net/phy/dp83640.c b/drivers/net/phy/dp83640.c
index 9414fa272160..98e7cbf720a5 100644
--- a/drivers/net/phy/dp83640.c
+++ b/drivers/net/phy/dp83640.c
@@ -1006,11 +1006,6 @@ static int dp83640_probe(struct phy_device *phydev)
1006 } else 1006 } else
1007 list_add_tail(&dp83640->list, &clock->phylist); 1007 list_add_tail(&dp83640->list, &clock->phylist);
1008 1008
1009 if (clock->chosen && !list_empty(&clock->phylist))
1010 recalibrate(clock);
1011 else
1012 enable_broadcast(dp83640->phydev, clock->page, 1);
1013
1014 dp83640_clock_put(clock); 1009 dp83640_clock_put(clock);
1015 return 0; 1010 return 0;
1016 1011
@@ -1063,6 +1058,14 @@ static void dp83640_remove(struct phy_device *phydev)
1063 1058
1064static int dp83640_config_init(struct phy_device *phydev) 1059static int dp83640_config_init(struct phy_device *phydev)
1065{ 1060{
1061 struct dp83640_private *dp83640 = phydev->priv;
1062 struct dp83640_clock *clock = dp83640->clock;
1063
1064 if (clock->chosen && !list_empty(&clock->phylist))
1065 recalibrate(clock);
1066 else
1067 enable_broadcast(phydev, clock->page, 1);
1068
1066 enable_status_frames(phydev, true); 1069 enable_status_frames(phydev, true);
1067 ext_write(0, phydev, PAGE4, PTP_CTL, PTP_ENABLE); 1070 ext_write(0, phydev, PAGE4, PTP_CTL, PTP_ENABLE);
1068 return 0; 1071 return 0;
diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
index 28407426fd6f..c8624a8235ab 100644
--- a/drivers/net/team/team.c
+++ b/drivers/net/team/team.c
@@ -1648,7 +1648,7 @@ static netdev_tx_t team_xmit(struct sk_buff *skb, struct net_device *dev)
1648} 1648}
1649 1649
1650static u16 team_select_queue(struct net_device *dev, struct sk_buff *skb, 1650static u16 team_select_queue(struct net_device *dev, struct sk_buff *skb,
1651 void *accel_priv) 1651 void *accel_priv, select_queue_fallback_t fallback)
1652{ 1652{
1653 /* 1653 /*
1654 * This helper function exists to help dev_pick_tx get the correct 1654 * This helper function exists to help dev_pick_tx get the correct
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 44c4db8450f0..8fe9cb7d0f72 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -366,7 +366,7 @@ static inline void tun_flow_save_rps_rxhash(struct tun_flow_entry *e, u32 hash)
366 * hope the rxq no. may help here. 366 * hope the rxq no. may help here.
367 */ 367 */
368static u16 tun_select_queue(struct net_device *dev, struct sk_buff *skb, 368static u16 tun_select_queue(struct net_device *dev, struct sk_buff *skb,
369 void *accel_priv) 369 void *accel_priv, select_queue_fallback_t fallback)
370{ 370{
371 struct tun_struct *tun = netdev_priv(dev); 371 struct tun_struct *tun = netdev_priv(dev);
372 struct tun_flow_entry *e; 372 struct tun_flow_entry *e;
diff --git a/drivers/net/usb/Kconfig b/drivers/net/usb/Kconfig
index 409499fdb157..7e7269fd3707 100644
--- a/drivers/net/usb/Kconfig
+++ b/drivers/net/usb/Kconfig
@@ -296,7 +296,6 @@ config USB_NET_SR9800
296 tristate "CoreChip-sz SR9800 based USB 2.0 10/100 ethernet devices" 296 tristate "CoreChip-sz SR9800 based USB 2.0 10/100 ethernet devices"
297 depends on USB_USBNET 297 depends on USB_USBNET
298 select CRC32 298 select CRC32
299 default y
300 ---help--- 299 ---help---
301 Say Y if you want to use one of the following 100Mbps USB Ethernet 300 Say Y if you want to use one of the following 100Mbps USB Ethernet
302 device based on the CoreChip-sz SR9800 chip. 301 device based on the CoreChip-sz SR9800 chip.
diff --git a/drivers/net/usb/asix_devices.c b/drivers/net/usb/asix_devices.c
index 9765a7d4766d..5d194093f3e1 100644
--- a/drivers/net/usb/asix_devices.c
+++ b/drivers/net/usb/asix_devices.c
@@ -917,7 +917,8 @@ static const struct driver_info ax88178_info = {
917 .status = asix_status, 917 .status = asix_status,
918 .link_reset = ax88178_link_reset, 918 .link_reset = ax88178_link_reset,
919 .reset = ax88178_reset, 919 .reset = ax88178_reset,
920 .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_LINK_INTR, 920 .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_LINK_INTR |
921 FLAG_MULTI_PACKET,
921 .rx_fixup = asix_rx_fixup_common, 922 .rx_fixup = asix_rx_fixup_common,
922 .tx_fixup = asix_tx_fixup, 923 .tx_fixup = asix_tx_fixup,
923}; 924};
diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
index d6f64dad05bc..955df81a4358 100644
--- a/drivers/net/usb/ax88179_178a.c
+++ b/drivers/net/usb/ax88179_178a.c
@@ -1118,6 +1118,10 @@ static int ax88179_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
1118 u16 hdr_off; 1118 u16 hdr_off;
1119 u32 *pkt_hdr; 1119 u32 *pkt_hdr;
1120 1120
1121 /* This check is no longer done by usbnet */
1122 if (skb->len < dev->net->hard_header_len)
1123 return 0;
1124
1121 skb_trim(skb, skb->len - 4); 1125 skb_trim(skb, skb->len - 4);
1122 memcpy(&rx_hdr, skb_tail_pointer(skb), 4); 1126 memcpy(&rx_hdr, skb_tail_pointer(skb), 4);
1123 le32_to_cpus(&rx_hdr); 1127 le32_to_cpus(&rx_hdr);
diff --git a/drivers/net/usb/gl620a.c b/drivers/net/usb/gl620a.c
index e4a8a93fbaf7..1cc24e6f23e2 100644
--- a/drivers/net/usb/gl620a.c
+++ b/drivers/net/usb/gl620a.c
@@ -84,6 +84,10 @@ static int genelink_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
84 u32 size; 84 u32 size;
85 u32 count; 85 u32 count;
86 86
87 /* This check is no longer done by usbnet */
88 if (skb->len < dev->net->hard_header_len)
89 return 0;
90
87 header = (struct gl_header *) skb->data; 91 header = (struct gl_header *) skb->data;
88 92
89 // get the packet count of the received skb 93 // get the packet count of the received skb
diff --git a/drivers/net/usb/mcs7830.c b/drivers/net/usb/mcs7830.c
index a305a7b2dae6..82d844a8ebd0 100644
--- a/drivers/net/usb/mcs7830.c
+++ b/drivers/net/usb/mcs7830.c
@@ -526,8 +526,9 @@ static int mcs7830_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
526{ 526{
527 u8 status; 527 u8 status;
528 528
529 if (skb->len == 0) { 529 /* This check is no longer done by usbnet */
530 dev_err(&dev->udev->dev, "unexpected empty rx frame\n"); 530 if (skb->len < dev->net->hard_header_len) {
531 dev_err(&dev->udev->dev, "unexpected tiny rx frame\n");
531 return 0; 532 return 0;
532 } 533 }
533 534
diff --git a/drivers/net/usb/net1080.c b/drivers/net/usb/net1080.c
index 0a85d9227775..4cbdb1307f3e 100644
--- a/drivers/net/usb/net1080.c
+++ b/drivers/net/usb/net1080.c
@@ -364,6 +364,10 @@ static int net1080_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
364 struct nc_trailer *trailer; 364 struct nc_trailer *trailer;
365 u16 hdr_len, packet_len; 365 u16 hdr_len, packet_len;
366 366
367 /* This check is no longer done by usbnet */
368 if (skb->len < dev->net->hard_header_len)
369 return 0;
370
367 if (!(skb->len & 0x01)) { 371 if (!(skb->len & 0x01)) {
368 netdev_dbg(dev->net, "rx framesize %d range %d..%d mtu %d\n", 372 netdev_dbg(dev->net, "rx framesize %d range %d..%d mtu %d\n",
369 skb->len, dev->net->hard_header_len, dev->hard_mtu, 373 skb->len, dev->net->hard_header_len, dev->hard_mtu,
diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c
index ff5c87128ffe..313cb6cd4848 100644
--- a/drivers/net/usb/qmi_wwan.c
+++ b/drivers/net/usb/qmi_wwan.c
@@ -80,10 +80,10 @@ static int qmi_wwan_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
80{ 80{
81 __be16 proto; 81 __be16 proto;
82 82
83 /* usbnet rx_complete guarantees that skb->len is at least 83 /* This check is no longer done by usbnet */
84 * hard_header_len, so we can inspect the dest address without 84 if (skb->len < dev->net->hard_header_len)
85 * checking skb->len 85 return 0;
86 */ 86
87 switch (skb->data[0] & 0xf0) { 87 switch (skb->data[0] & 0xf0) {
88 case 0x40: 88 case 0x40:
89 proto = htons(ETH_P_IP); 89 proto = htons(ETH_P_IP);
@@ -732,6 +732,7 @@ static const struct usb_device_id products[] = {
732 {QMI_FIXED_INTF(0x1bc7, 0x1201, 2)}, /* Telit LE920 */ 732 {QMI_FIXED_INTF(0x1bc7, 0x1201, 2)}, /* Telit LE920 */
733 {QMI_FIXED_INTF(0x0b3c, 0xc005, 6)}, /* Olivetti Olicard 200 */ 733 {QMI_FIXED_INTF(0x0b3c, 0xc005, 6)}, /* Olivetti Olicard 200 */
734 {QMI_FIXED_INTF(0x1e2d, 0x0060, 4)}, /* Cinterion PLxx */ 734 {QMI_FIXED_INTF(0x1e2d, 0x0060, 4)}, /* Cinterion PLxx */
735 {QMI_FIXED_INTF(0x1e2d, 0x0053, 4)}, /* Cinterion PHxx,PXxx */
735 736
736 /* 4. Gobi 1000 devices */ 737 /* 4. Gobi 1000 devices */
737 {QMI_GOBI1K_DEVICE(0x05c6, 0x9212)}, /* Acer Gobi Modem Device */ 738 {QMI_GOBI1K_DEVICE(0x05c6, 0x9212)}, /* Acer Gobi Modem Device */
diff --git a/drivers/net/usb/rndis_host.c b/drivers/net/usb/rndis_host.c
index a48bc0f20c1a..524a47a28120 100644
--- a/drivers/net/usb/rndis_host.c
+++ b/drivers/net/usb/rndis_host.c
@@ -492,6 +492,10 @@ EXPORT_SYMBOL_GPL(rndis_unbind);
492 */ 492 */
493int rndis_rx_fixup(struct usbnet *dev, struct sk_buff *skb) 493int rndis_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
494{ 494{
495 /* This check is no longer done by usbnet */
496 if (skb->len < dev->net->hard_header_len)
497 return 0;
498
495 /* peripheral may have batched packets to us... */ 499 /* peripheral may have batched packets to us... */
496 while (likely(skb->len)) { 500 while (likely(skb->len)) {
497 struct rndis_data_hdr *hdr = (void *)skb->data; 501 struct rndis_data_hdr *hdr = (void *)skb->data;
diff --git a/drivers/net/usb/smsc75xx.c b/drivers/net/usb/smsc75xx.c
index f17b9e02dd34..d9e7892262fa 100644
--- a/drivers/net/usb/smsc75xx.c
+++ b/drivers/net/usb/smsc75xx.c
@@ -2106,6 +2106,10 @@ static void smsc75xx_rx_csum_offload(struct usbnet *dev, struct sk_buff *skb,
2106 2106
2107static int smsc75xx_rx_fixup(struct usbnet *dev, struct sk_buff *skb) 2107static int smsc75xx_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
2108{ 2108{
2109 /* This check is no longer done by usbnet */
2110 if (skb->len < dev->net->hard_header_len)
2111 return 0;
2112
2109 while (skb->len > 0) { 2113 while (skb->len > 0) {
2110 u32 rx_cmd_a, rx_cmd_b, align_count, size; 2114 u32 rx_cmd_a, rx_cmd_b, align_count, size;
2111 struct sk_buff *ax_skb; 2115 struct sk_buff *ax_skb;
diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c
index 8dd54a0f7b29..424db65e4396 100644
--- a/drivers/net/usb/smsc95xx.c
+++ b/drivers/net/usb/smsc95xx.c
@@ -1723,6 +1723,10 @@ static void smsc95xx_rx_csum_offload(struct sk_buff *skb)
1723 1723
1724static int smsc95xx_rx_fixup(struct usbnet *dev, struct sk_buff *skb) 1724static int smsc95xx_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
1725{ 1725{
1726 /* This check is no longer done by usbnet */
1727 if (skb->len < dev->net->hard_header_len)
1728 return 0;
1729
1726 while (skb->len > 0) { 1730 while (skb->len > 0) {
1727 u32 header, align_count; 1731 u32 header, align_count;
1728 struct sk_buff *ax_skb; 1732 struct sk_buff *ax_skb;
diff --git a/drivers/net/usb/sr9800.c b/drivers/net/usb/sr9800.c
index 4175eb9fdeca..b94a0fbb8b3b 100644
--- a/drivers/net/usb/sr9800.c
+++ b/drivers/net/usb/sr9800.c
@@ -63,6 +63,10 @@ static int sr_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
63{ 63{
64 int offset = 0; 64 int offset = 0;
65 65
66 /* This check is no longer done by usbnet */
67 if (skb->len < dev->net->hard_header_len)
68 return 0;
69
66 while (offset + sizeof(u32) < skb->len) { 70 while (offset + sizeof(u32) < skb->len) {
67 struct sk_buff *sr_skb; 71 struct sk_buff *sr_skb;
68 u16 size; 72 u16 size;
@@ -823,7 +827,7 @@ static int sr9800_bind(struct usbnet *dev, struct usb_interface *intf)
823 dev->rx_urb_size = 827 dev->rx_urb_size =
824 SR9800_BULKIN_SIZE[SR9800_MAX_BULKIN_2K].size; 828 SR9800_BULKIN_SIZE[SR9800_MAX_BULKIN_2K].size;
825 } 829 }
826 netdev_dbg(dev->net, "%s : setting rx_urb_size with : %ld\n", __func__, 830 netdev_dbg(dev->net, "%s : setting rx_urb_size with : %zu\n", __func__,
827 dev->rx_urb_size); 831 dev->rx_urb_size);
828 return 0; 832 return 0;
829 833
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 4671da755e7b..dd10d5817d2a 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -542,17 +542,19 @@ static inline void rx_process (struct usbnet *dev, struct sk_buff *skb)
542 } 542 }
543 // else network stack removes extra byte if we forced a short packet 543 // else network stack removes extra byte if we forced a short packet
544 544
545 if (skb->len) { 545 /* all data was already cloned from skb inside the driver */
546 /* all data was already cloned from skb inside the driver */ 546 if (dev->driver_info->flags & FLAG_MULTI_PACKET)
547 if (dev->driver_info->flags & FLAG_MULTI_PACKET) 547 goto done;
548 dev_kfree_skb_any(skb); 548
549 else 549 if (skb->len < ETH_HLEN) {
550 usbnet_skb_return(dev, skb); 550 dev->net->stats.rx_errors++;
551 dev->net->stats.rx_length_errors++;
552 netif_dbg(dev, rx_err, dev->net, "rx length %d\n", skb->len);
553 } else {
554 usbnet_skb_return(dev, skb);
551 return; 555 return;
552 } 556 }
553 557
554 netif_dbg(dev, rx_err, dev->net, "drop\n");
555 dev->net->stats.rx_errors++;
556done: 558done:
557 skb_queue_tail(&dev->done, skb); 559 skb_queue_tail(&dev->done, skb);
558} 560}
@@ -574,13 +576,6 @@ static void rx_complete (struct urb *urb)
574 switch (urb_status) { 576 switch (urb_status) {
575 /* success */ 577 /* success */
576 case 0: 578 case 0:
577 if (skb->len < dev->net->hard_header_len) {
578 state = rx_cleanup;
579 dev->net->stats.rx_errors++;
580 dev->net->stats.rx_length_errors++;
581 netif_dbg(dev, rx_err, dev->net,
582 "rx length %d\n", skb->len);
583 }
584 break; 579 break;
585 580
586 /* stalls need manual reset. this is rare ... except that 581 /* stalls need manual reset. this is rare ... except that
diff --git a/drivers/net/wireless/ath/ath5k/phy.c b/drivers/net/wireless/ath/ath5k/phy.c
index d6bc7cb61bfb..1a2973b7acf2 100644
--- a/drivers/net/wireless/ath/ath5k/phy.c
+++ b/drivers/net/wireless/ath/ath5k/phy.c
@@ -110,7 +110,7 @@ ath5k_hw_radio_revision(struct ath5k_hw *ah, enum ieee80211_band band)
110 ath5k_hw_reg_write(ah, 0x00010000, AR5K_PHY(0x20)); 110 ath5k_hw_reg_write(ah, 0x00010000, AR5K_PHY(0x20));
111 111
112 if (ah->ah_version == AR5K_AR5210) { 112 if (ah->ah_version == AR5K_AR5210) {
113 srev = ath5k_hw_reg_read(ah, AR5K_PHY(256) >> 28) & 0xf; 113 srev = (ath5k_hw_reg_read(ah, AR5K_PHY(256)) >> 28) & 0xf;
114 ret = (u16)ath5k_hw_bitswap(srev, 4) + 1; 114 ret = (u16)ath5k_hw_bitswap(srev, 4) + 1;
115 } else { 115 } else {
116 srev = (ath5k_hw_reg_read(ah, AR5K_PHY(0x100)) >> 24) & 0xff; 116 srev = (ath5k_hw_reg_read(ah, AR5K_PHY(0x100)) >> 24) & 0xff;
diff --git a/drivers/net/wireless/hostap/hostap_proc.c b/drivers/net/wireless/hostap/hostap_proc.c
index aa7ad3a7a69b..4e5c0f8c9496 100644
--- a/drivers/net/wireless/hostap/hostap_proc.c
+++ b/drivers/net/wireless/hostap/hostap_proc.c
@@ -496,7 +496,7 @@ void hostap_init_proc(local_info_t *local)
496 496
497void hostap_remove_proc(local_info_t *local) 497void hostap_remove_proc(local_info_t *local)
498{ 498{
499 remove_proc_subtree(local->ddev->name, hostap_proc); 499 proc_remove(local->proc);
500} 500}
501 501
502 502
diff --git a/drivers/net/wireless/iwlwifi/dvm/mac80211.c b/drivers/net/wireless/iwlwifi/dvm/mac80211.c
index c24d1d3d55f6..73086c1629ca 100644
--- a/drivers/net/wireless/iwlwifi/dvm/mac80211.c
+++ b/drivers/net/wireless/iwlwifi/dvm/mac80211.c
@@ -696,6 +696,24 @@ static int iwlagn_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
696 return ret; 696 return ret;
697} 697}
698 698
699static inline bool iwl_enable_rx_ampdu(const struct iwl_cfg *cfg)
700{
701 if (iwlwifi_mod_params.disable_11n & IWL_DISABLE_HT_RXAGG)
702 return false;
703 return true;
704}
705
706static inline bool iwl_enable_tx_ampdu(const struct iwl_cfg *cfg)
707{
708 if (iwlwifi_mod_params.disable_11n & IWL_DISABLE_HT_TXAGG)
709 return false;
710 if (iwlwifi_mod_params.disable_11n & IWL_ENABLE_HT_TXAGG)
711 return true;
712
713 /* disabled by default */
714 return false;
715}
716
699static int iwlagn_mac_ampdu_action(struct ieee80211_hw *hw, 717static int iwlagn_mac_ampdu_action(struct ieee80211_hw *hw,
700 struct ieee80211_vif *vif, 718 struct ieee80211_vif *vif,
701 enum ieee80211_ampdu_mlme_action action, 719 enum ieee80211_ampdu_mlme_action action,
@@ -717,7 +735,7 @@ static int iwlagn_mac_ampdu_action(struct ieee80211_hw *hw,
717 735
718 switch (action) { 736 switch (action) {
719 case IEEE80211_AMPDU_RX_START: 737 case IEEE80211_AMPDU_RX_START:
720 if (iwlwifi_mod_params.disable_11n & IWL_DISABLE_HT_RXAGG) 738 if (!iwl_enable_rx_ampdu(priv->cfg))
721 break; 739 break;
722 IWL_DEBUG_HT(priv, "start Rx\n"); 740 IWL_DEBUG_HT(priv, "start Rx\n");
723 ret = iwl_sta_rx_agg_start(priv, sta, tid, *ssn); 741 ret = iwl_sta_rx_agg_start(priv, sta, tid, *ssn);
@@ -729,7 +747,7 @@ static int iwlagn_mac_ampdu_action(struct ieee80211_hw *hw,
729 case IEEE80211_AMPDU_TX_START: 747 case IEEE80211_AMPDU_TX_START:
730 if (!priv->trans->ops->txq_enable) 748 if (!priv->trans->ops->txq_enable)
731 break; 749 break;
732 if (iwlwifi_mod_params.disable_11n & IWL_DISABLE_HT_TXAGG) 750 if (!iwl_enable_tx_ampdu(priv->cfg))
733 break; 751 break;
734 IWL_DEBUG_HT(priv, "start Tx\n"); 752 IWL_DEBUG_HT(priv, "start Tx\n");
735 ret = iwlagn_tx_agg_start(priv, vif, sta, tid, ssn); 753 ret = iwlagn_tx_agg_start(priv, vif, sta, tid, ssn);
diff --git a/drivers/net/wireless/iwlwifi/iwl-drv.c b/drivers/net/wireless/iwlwifi/iwl-drv.c
index c3728163be46..75103554cd63 100644
--- a/drivers/net/wireless/iwlwifi/iwl-drv.c
+++ b/drivers/net/wireless/iwlwifi/iwl-drv.c
@@ -1286,7 +1286,7 @@ module_param_named(swcrypto, iwlwifi_mod_params.sw_crypto, int, S_IRUGO);
1286MODULE_PARM_DESC(swcrypto, "using crypto in software (default 0 [hardware])"); 1286MODULE_PARM_DESC(swcrypto, "using crypto in software (default 0 [hardware])");
1287module_param_named(11n_disable, iwlwifi_mod_params.disable_11n, uint, S_IRUGO); 1287module_param_named(11n_disable, iwlwifi_mod_params.disable_11n, uint, S_IRUGO);
1288MODULE_PARM_DESC(11n_disable, 1288MODULE_PARM_DESC(11n_disable,
1289 "disable 11n functionality, bitmap: 1: full, 2: agg TX, 4: agg RX"); 1289 "disable 11n functionality, bitmap: 1: full, 2: disable agg TX, 4: disable agg RX, 8 enable agg TX");
1290module_param_named(amsdu_size_8K, iwlwifi_mod_params.amsdu_size_8K, 1290module_param_named(amsdu_size_8K, iwlwifi_mod_params.amsdu_size_8K,
1291 int, S_IRUGO); 1291 int, S_IRUGO);
1292MODULE_PARM_DESC(amsdu_size_8K, "enable 8K amsdu size (default 0)"); 1292MODULE_PARM_DESC(amsdu_size_8K, "enable 8K amsdu size (default 0)");
diff --git a/drivers/net/wireless/iwlwifi/iwl-modparams.h b/drivers/net/wireless/iwlwifi/iwl-modparams.h
index 0a84ade7edac..b29075c3da8e 100644
--- a/drivers/net/wireless/iwlwifi/iwl-modparams.h
+++ b/drivers/net/wireless/iwlwifi/iwl-modparams.h
@@ -79,9 +79,12 @@ enum iwl_power_level {
79 IWL_POWER_NUM 79 IWL_POWER_NUM
80}; 80};
81 81
82#define IWL_DISABLE_HT_ALL BIT(0) 82enum iwl_disable_11n {
83#define IWL_DISABLE_HT_TXAGG BIT(1) 83 IWL_DISABLE_HT_ALL = BIT(0),
84#define IWL_DISABLE_HT_RXAGG BIT(2) 84 IWL_DISABLE_HT_TXAGG = BIT(1),
85 IWL_DISABLE_HT_RXAGG = BIT(2),
86 IWL_ENABLE_HT_TXAGG = BIT(3),
87};
85 88
86/** 89/**
87 * struct iwl_mod_params 90 * struct iwl_mod_params
@@ -90,7 +93,7 @@ enum iwl_power_level {
90 * 93 *
91 * @sw_crypto: using hardware encryption, default = 0 94 * @sw_crypto: using hardware encryption, default = 0
92 * @disable_11n: disable 11n capabilities, default = 0, 95 * @disable_11n: disable 11n capabilities, default = 0,
93 * use IWL_DISABLE_HT_* constants 96 * use IWL_[DIS,EN]ABLE_HT_* constants
94 * @amsdu_size_8K: enable 8K amsdu size, default = 0 97 * @amsdu_size_8K: enable 8K amsdu size, default = 0
95 * @restart_fw: restart firmware, default = 1 98 * @restart_fw: restart firmware, default = 1
96 * @wd_disable: enable stuck queue check, default = 0 99 * @wd_disable: enable stuck queue check, default = 0
diff --git a/drivers/net/wireless/iwlwifi/mvm/mac80211.c b/drivers/net/wireless/iwlwifi/mvm/mac80211.c
index 6bf9766e5982..c35b8661b395 100644
--- a/drivers/net/wireless/iwlwifi/mvm/mac80211.c
+++ b/drivers/net/wireless/iwlwifi/mvm/mac80211.c
@@ -328,6 +328,24 @@ static void iwl_mvm_mac_tx(struct ieee80211_hw *hw,
328 ieee80211_free_txskb(hw, skb); 328 ieee80211_free_txskb(hw, skb);
329} 329}
330 330
331static inline bool iwl_enable_rx_ampdu(const struct iwl_cfg *cfg)
332{
333 if (iwlwifi_mod_params.disable_11n & IWL_DISABLE_HT_RXAGG)
334 return false;
335 return true;
336}
337
338static inline bool iwl_enable_tx_ampdu(const struct iwl_cfg *cfg)
339{
340 if (iwlwifi_mod_params.disable_11n & IWL_DISABLE_HT_TXAGG)
341 return false;
342 if (iwlwifi_mod_params.disable_11n & IWL_ENABLE_HT_TXAGG)
343 return true;
344
345 /* enabled by default */
346 return true;
347}
348
331static int iwl_mvm_mac_ampdu_action(struct ieee80211_hw *hw, 349static int iwl_mvm_mac_ampdu_action(struct ieee80211_hw *hw,
332 struct ieee80211_vif *vif, 350 struct ieee80211_vif *vif,
333 enum ieee80211_ampdu_mlme_action action, 351 enum ieee80211_ampdu_mlme_action action,
@@ -347,7 +365,7 @@ static int iwl_mvm_mac_ampdu_action(struct ieee80211_hw *hw,
347 365
348 switch (action) { 366 switch (action) {
349 case IEEE80211_AMPDU_RX_START: 367 case IEEE80211_AMPDU_RX_START:
350 if (iwlwifi_mod_params.disable_11n & IWL_DISABLE_HT_RXAGG) { 368 if (!iwl_enable_rx_ampdu(mvm->cfg)) {
351 ret = -EINVAL; 369 ret = -EINVAL;
352 break; 370 break;
353 } 371 }
@@ -357,7 +375,7 @@ static int iwl_mvm_mac_ampdu_action(struct ieee80211_hw *hw,
357 ret = iwl_mvm_sta_rx_agg(mvm, sta, tid, 0, false); 375 ret = iwl_mvm_sta_rx_agg(mvm, sta, tid, 0, false);
358 break; 376 break;
359 case IEEE80211_AMPDU_TX_START: 377 case IEEE80211_AMPDU_TX_START:
360 if (iwlwifi_mod_params.disable_11n & IWL_DISABLE_HT_TXAGG) { 378 if (!iwl_enable_tx_ampdu(mvm->cfg)) {
361 ret = -EINVAL; 379 ret = -EINVAL;
362 break; 380 break;
363 } 381 }
diff --git a/drivers/net/wireless/mwifiex/main.c b/drivers/net/wireless/mwifiex/main.c
index 4d79761b9c87..9d3d2758ec35 100644
--- a/drivers/net/wireless/mwifiex/main.c
+++ b/drivers/net/wireless/mwifiex/main.c
@@ -748,7 +748,7 @@ static struct net_device_stats *mwifiex_get_stats(struct net_device *dev)
748 748
749static u16 749static u16
750mwifiex_netdev_select_wmm_queue(struct net_device *dev, struct sk_buff *skb, 750mwifiex_netdev_select_wmm_queue(struct net_device *dev, struct sk_buff *skb,
751 void *accel_priv) 751 void *accel_priv, select_queue_fallback_t fallback)
752{ 752{
753 skb->priority = cfg80211_classify8021d(skb, NULL); 753 skb->priority = cfg80211_classify8021d(skb, NULL);
754 return mwifiex_1d_to_wmm_queue[skb->priority]; 754 return mwifiex_1d_to_wmm_queue[skb->priority];
diff --git a/drivers/net/wireless/rtl818x/rtl8187/rtl8187.h b/drivers/net/wireless/rtl818x/rtl8187/rtl8187.h
index 56aee067f324..a6ad79f61bf9 100644
--- a/drivers/net/wireless/rtl818x/rtl8187/rtl8187.h
+++ b/drivers/net/wireless/rtl818x/rtl8187/rtl8187.h
@@ -15,6 +15,8 @@
15#ifndef RTL8187_H 15#ifndef RTL8187_H
16#define RTL8187_H 16#define RTL8187_H
17 17
18#include <linux/cache.h>
19
18#include "rtl818x.h" 20#include "rtl818x.h"
19#include "leds.h" 21#include "leds.h"
20 22
@@ -139,7 +141,10 @@ struct rtl8187_priv {
139 u8 aifsn[4]; 141 u8 aifsn[4];
140 u8 rfkill_mask; 142 u8 rfkill_mask;
141 struct { 143 struct {
142 __le64 buf; 144 union {
145 __le64 buf;
146 u8 dummy1[L1_CACHE_BYTES];
147 } ____cacheline_aligned;
143 struct sk_buff_head queue; 148 struct sk_buff_head queue;
144 } b_tx_status; /* This queue is used by both -b and non-b devices */ 149 } b_tx_status; /* This queue is used by both -b and non-b devices */
145 struct mutex io_mutex; 150 struct mutex io_mutex;
@@ -147,7 +152,8 @@ struct rtl8187_priv {
147 u8 bits8; 152 u8 bits8;
148 __le16 bits16; 153 __le16 bits16;
149 __le32 bits32; 154 __le32 bits32;
150 } *io_dmabuf; 155 u8 dummy2[L1_CACHE_BYTES];
156 } *io_dmabuf ____cacheline_aligned;
151 bool rfkill_off; 157 bool rfkill_off;
152 u16 seqno; 158 u16 seqno;
153}; 159};
diff --git a/drivers/net/wireless/rtlwifi/ps.c b/drivers/net/wireless/rtlwifi/ps.c
index deedae3c5449..d1c0191a195b 100644
--- a/drivers/net/wireless/rtlwifi/ps.c
+++ b/drivers/net/wireless/rtlwifi/ps.c
@@ -48,7 +48,7 @@ bool rtl_ps_enable_nic(struct ieee80211_hw *hw)
48 48
49 /*<2> Enable Adapter */ 49 /*<2> Enable Adapter */
50 if (rtlpriv->cfg->ops->hw_init(hw)) 50 if (rtlpriv->cfg->ops->hw_init(hw))
51 return 1; 51 return false;
52 RT_CLEAR_PS_LEVEL(ppsc, RT_RF_OFF_LEVL_HALT_NIC); 52 RT_CLEAR_PS_LEVEL(ppsc, RT_RF_OFF_LEVL_HALT_NIC);
53 53
54 /*<3> Enable Interrupt */ 54 /*<3> Enable Interrupt */
diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c b/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c
index a82b30a1996c..2eb0b38384dd 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c
@@ -937,14 +937,26 @@ int rtl92ce_hw_init(struct ieee80211_hw *hw)
937 bool is92c; 937 bool is92c;
938 int err; 938 int err;
939 u8 tmp_u1b; 939 u8 tmp_u1b;
940 unsigned long flags;
940 941
941 rtlpci->being_init_adapter = true; 942 rtlpci->being_init_adapter = true;
943
944 /* Since this function can take a very long time (up to 350 ms)
945 * and can be called with irqs disabled, reenable the irqs
946 * to let the other devices continue being serviced.
947 *
948 * It is safe doing so since our own interrupts will only be enabled
949 * in a subsequent step.
950 */
951 local_save_flags(flags);
952 local_irq_enable();
953
942 rtlpriv->intf_ops->disable_aspm(hw); 954 rtlpriv->intf_ops->disable_aspm(hw);
943 rtstatus = _rtl92ce_init_mac(hw); 955 rtstatus = _rtl92ce_init_mac(hw);
944 if (!rtstatus) { 956 if (!rtstatus) {
945 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "Init MAC failed\n"); 957 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "Init MAC failed\n");
946 err = 1; 958 err = 1;
947 return err; 959 goto exit;
948 } 960 }
949 961
950 err = rtl92c_download_fw(hw); 962 err = rtl92c_download_fw(hw);
@@ -952,7 +964,7 @@ int rtl92ce_hw_init(struct ieee80211_hw *hw)
952 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, 964 RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
953 "Failed to download FW. Init HW without FW now..\n"); 965 "Failed to download FW. Init HW without FW now..\n");
954 err = 1; 966 err = 1;
955 return err; 967 goto exit;
956 } 968 }
957 969
958 rtlhal->last_hmeboxnum = 0; 970 rtlhal->last_hmeboxnum = 0;
@@ -1032,6 +1044,8 @@ int rtl92ce_hw_init(struct ieee80211_hw *hw)
1032 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, "under 1.5V\n"); 1044 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, "under 1.5V\n");
1033 } 1045 }
1034 rtl92c_dm_init(hw); 1046 rtl92c_dm_init(hw);
1047exit:
1048 local_irq_restore(flags);
1035 rtlpci->being_init_adapter = false; 1049 rtlpci->being_init_adapter = false;
1036 return err; 1050 return err;
1037} 1051}
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/of_mdio.c b/drivers/of/of_mdio.c
index 875b7b6f0d2a..5b3c24f3cde5 100644
--- a/drivers/of/of_mdio.c
+++ b/drivers/of/of_mdio.c
@@ -24,7 +24,11 @@ MODULE_LICENSE("GPL");
24 24
25static void of_set_phy_supported(struct phy_device *phydev, u32 max_speed) 25static void of_set_phy_supported(struct phy_device *phydev, u32 max_speed)
26{ 26{
27 phydev->supported |= PHY_DEFAULT_FEATURES; 27 /* The default values for phydev->supported are provided by the PHY
28 * driver "features" member, we want to reset to sane defaults fist
29 * before supporting higher speeds.
30 */
31 phydev->supported &= PHY_DEFAULT_FEATURES;
28 32
29 switch (max_speed) { 33 switch (max_speed) {
30 default: 34 default:
@@ -44,7 +48,7 @@ static int of_mdiobus_register_phy(struct mii_bus *mdio, struct device_node *chi
44{ 48{
45 struct phy_device *phy; 49 struct phy_device *phy;
46 bool is_c45; 50 bool is_c45;
47 int rc, prev_irq; 51 int rc;
48 u32 max_speed = 0; 52 u32 max_speed = 0;
49 53
50 is_c45 = of_device_is_compatible(child, 54 is_c45 = of_device_is_compatible(child,
@@ -54,12 +58,14 @@ static int of_mdiobus_register_phy(struct mii_bus *mdio, struct device_node *chi
54 if (!phy || IS_ERR(phy)) 58 if (!phy || IS_ERR(phy))
55 return 1; 59 return 1;
56 60
57 if (mdio->irq) { 61 rc = irq_of_parse_and_map(child, 0);
58 prev_irq = mdio->irq[addr]; 62 if (rc > 0) {
59 mdio->irq[addr] = 63 phy->irq = rc;
60 irq_of_parse_and_map(child, 0); 64 if (mdio->irq)
61 if (!mdio->irq[addr]) 65 mdio->irq[addr] = rc;
62 mdio->irq[addr] = prev_irq; 66 } else {
67 if (mdio->irq)
68 phy->irq = mdio->irq[addr];
63 } 69 }
64 70
65 /* Associate the OF node with the device structure so it 71 /* Associate the OF node with the device structure so it
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/regulator/core.c b/drivers/regulator/core.c
index 16a309e5c024..d1ac4caaf1b0 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1359,7 +1359,7 @@ static struct regulator *_regulator_get(struct device *dev, const char *id,
1359 goto found; 1359 goto found;
1360 /* Don't log an error when called from regulator_get_optional() */ 1360 /* Don't log an error when called from regulator_get_optional() */
1361 } else if (!have_full_constraints() || exclusive) { 1361 } else if (!have_full_constraints() || exclusive) {
1362 dev_err(dev, "dummy supplies not allowed\n"); 1362 dev_warn(dev, "dummy supplies not allowed\n");
1363 } 1363 }
1364 1364
1365 mutex_unlock(&regulator_list_mutex); 1365 mutex_unlock(&regulator_list_mutex);
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/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/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 7bd7f0d5f050..62ec84b42e31 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1684,7 +1684,7 @@ u64 scsi_calculate_bounce_limit(struct Scsi_Host *shost)
1684 1684
1685 host_dev = scsi_get_device(shost); 1685 host_dev = scsi_get_device(shost);
1686 if (host_dev && host_dev->dma_mask) 1686 if (host_dev && host_dev->dma_mask)
1687 bounce_limit = dma_max_pfn(host_dev) << PAGE_SHIFT; 1687 bounce_limit = (u64)dma_max_pfn(host_dev) << PAGE_SHIFT;
1688 1688
1689 return bounce_limit; 1689 return bounce_limit;
1690} 1690}
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/bcm/Bcmnet.c b/drivers/staging/bcm/Bcmnet.c
index 8dfdd2732bdc..95a2358267ba 100644
--- a/drivers/staging/bcm/Bcmnet.c
+++ b/drivers/staging/bcm/Bcmnet.c
@@ -40,7 +40,7 @@ static INT bcm_close(struct net_device *dev)
40} 40}
41 41
42static u16 bcm_select_queue(struct net_device *dev, struct sk_buff *skb, 42static u16 bcm_select_queue(struct net_device *dev, struct sk_buff *skb,
43 void *accel_priv) 43 void *accel_priv, select_queue_fallback_t fallback)
44{ 44{
45 return ClassifyPacket(netdev_priv(dev), skb); 45 return ClassifyPacket(netdev_priv(dev), skb);
46} 46}
diff --git a/drivers/staging/netlogic/xlr_net.c b/drivers/staging/netlogic/xlr_net.c
index d8ea25486a33..31b269a5fff7 100644
--- a/drivers/staging/netlogic/xlr_net.c
+++ b/drivers/staging/netlogic/xlr_net.c
@@ -307,7 +307,7 @@ static netdev_tx_t xlr_net_start_xmit(struct sk_buff *skb,
307} 307}
308 308
309static u16 xlr_net_select_queue(struct net_device *ndev, struct sk_buff *skb, 309static u16 xlr_net_select_queue(struct net_device *ndev, struct sk_buff *skb,
310 void *accel_priv) 310 void *accel_priv, select_queue_fallback_t fallback)
311{ 311{
312 return (u16)smp_processor_id(); 312 return (u16)smp_processor_id();
313} 313}
diff --git a/drivers/staging/rtl8188eu/os_dep/os_intfs.c b/drivers/staging/rtl8188eu/os_dep/os_intfs.c
index 68f98fa114d2..7c9ee58f47bb 100644
--- a/drivers/staging/rtl8188eu/os_dep/os_intfs.c
+++ b/drivers/staging/rtl8188eu/os_dep/os_intfs.c
@@ -653,7 +653,7 @@ static unsigned int rtw_classify8021d(struct sk_buff *skb)
653} 653}
654 654
655static u16 rtw_select_queue(struct net_device *dev, struct sk_buff *skb, 655static u16 rtw_select_queue(struct net_device *dev, struct sk_buff *skb,
656 void *accel_priv) 656 void *accel_priv, select_queue_fallback_t fallback)
657{ 657{
658 struct adapter *padapter = rtw_netdev_priv(dev); 658 struct adapter *padapter = rtw_netdev_priv(dev);
659 struct mlme_priv *pmlmepriv = &padapter->mlmepriv; 659 struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
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-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/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/vhost/net.c b/drivers/vhost/net.c
index 9a68409580d5..a0fa5de210cf 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -70,7 +70,12 @@ enum {
70}; 70};
71 71
72struct vhost_net_ubuf_ref { 72struct vhost_net_ubuf_ref {
73 struct kref kref; 73 /* refcount follows semantics similar to kref:
74 * 0: object is released
75 * 1: no outstanding ubufs
76 * >1: outstanding ubufs
77 */
78 atomic_t refcount;
74 wait_queue_head_t wait; 79 wait_queue_head_t wait;
75 struct vhost_virtqueue *vq; 80 struct vhost_virtqueue *vq;
76}; 81};
@@ -116,14 +121,6 @@ static void vhost_net_enable_zcopy(int vq)
116 vhost_net_zcopy_mask |= 0x1 << vq; 121 vhost_net_zcopy_mask |= 0x1 << vq;
117} 122}
118 123
119static void vhost_net_zerocopy_done_signal(struct kref *kref)
120{
121 struct vhost_net_ubuf_ref *ubufs;
122
123 ubufs = container_of(kref, struct vhost_net_ubuf_ref, kref);
124 wake_up(&ubufs->wait);
125}
126
127static struct vhost_net_ubuf_ref * 124static struct vhost_net_ubuf_ref *
128vhost_net_ubuf_alloc(struct vhost_virtqueue *vq, bool zcopy) 125vhost_net_ubuf_alloc(struct vhost_virtqueue *vq, bool zcopy)
129{ 126{
@@ -134,21 +131,24 @@ vhost_net_ubuf_alloc(struct vhost_virtqueue *vq, bool zcopy)
134 ubufs = kmalloc(sizeof(*ubufs), GFP_KERNEL); 131 ubufs = kmalloc(sizeof(*ubufs), GFP_KERNEL);
135 if (!ubufs) 132 if (!ubufs)
136 return ERR_PTR(-ENOMEM); 133 return ERR_PTR(-ENOMEM);
137 kref_init(&ubufs->kref); 134 atomic_set(&ubufs->refcount, 1);
138 init_waitqueue_head(&ubufs->wait); 135 init_waitqueue_head(&ubufs->wait);
139 ubufs->vq = vq; 136 ubufs->vq = vq;
140 return ubufs; 137 return ubufs;
141} 138}
142 139
143static void vhost_net_ubuf_put(struct vhost_net_ubuf_ref *ubufs) 140static int vhost_net_ubuf_put(struct vhost_net_ubuf_ref *ubufs)
144{ 141{
145 kref_put(&ubufs->kref, vhost_net_zerocopy_done_signal); 142 int r = atomic_sub_return(1, &ubufs->refcount);
143 if (unlikely(!r))
144 wake_up(&ubufs->wait);
145 return r;
146} 146}
147 147
148static void vhost_net_ubuf_put_and_wait(struct vhost_net_ubuf_ref *ubufs) 148static void vhost_net_ubuf_put_and_wait(struct vhost_net_ubuf_ref *ubufs)
149{ 149{
150 kref_put(&ubufs->kref, vhost_net_zerocopy_done_signal); 150 vhost_net_ubuf_put(ubufs);
151 wait_event(ubufs->wait, !atomic_read(&ubufs->kref.refcount)); 151 wait_event(ubufs->wait, !atomic_read(&ubufs->refcount));
152} 152}
153 153
154static void vhost_net_ubuf_put_wait_and_free(struct vhost_net_ubuf_ref *ubufs) 154static void vhost_net_ubuf_put_wait_and_free(struct vhost_net_ubuf_ref *ubufs)
@@ -306,23 +306,26 @@ static void vhost_zerocopy_callback(struct ubuf_info *ubuf, bool success)
306{ 306{
307 struct vhost_net_ubuf_ref *ubufs = ubuf->ctx; 307 struct vhost_net_ubuf_ref *ubufs = ubuf->ctx;
308 struct vhost_virtqueue *vq = ubufs->vq; 308 struct vhost_virtqueue *vq = ubufs->vq;
309 int cnt = atomic_read(&ubufs->kref.refcount); 309 int cnt;
310
311 rcu_read_lock_bh();
310 312
311 /* set len to mark this desc buffers done DMA */ 313 /* set len to mark this desc buffers done DMA */
312 vq->heads[ubuf->desc].len = success ? 314 vq->heads[ubuf->desc].len = success ?
313 VHOST_DMA_DONE_LEN : VHOST_DMA_FAILED_LEN; 315 VHOST_DMA_DONE_LEN : VHOST_DMA_FAILED_LEN;
314 vhost_net_ubuf_put(ubufs); 316 cnt = vhost_net_ubuf_put(ubufs);
315 317
316 /* 318 /*
317 * Trigger polling thread if guest stopped submitting new buffers: 319 * Trigger polling thread if guest stopped submitting new buffers:
318 * in this case, the refcount after decrement will eventually reach 1 320 * in this case, the refcount after decrement will eventually reach 1.
319 * so here it is 2.
320 * We also trigger polling periodically after each 16 packets 321 * We also trigger polling periodically after each 16 packets
321 * (the value 16 here is more or less arbitrary, it's tuned to trigger 322 * (the value 16 here is more or less arbitrary, it's tuned to trigger
322 * less than 10% of times). 323 * less than 10% of times).
323 */ 324 */
324 if (cnt <= 2 || !(cnt % 16)) 325 if (cnt <= 1 || !(cnt % 16))
325 vhost_poll_queue(&vq->poll); 326 vhost_poll_queue(&vq->poll);
327
328 rcu_read_unlock_bh();
326} 329}
327 330
328/* Expects to be always run from workqueue - which acts as 331/* Expects to be always run from workqueue - which acts as
@@ -420,7 +423,7 @@ static void handle_tx(struct vhost_net *net)
420 msg.msg_control = ubuf; 423 msg.msg_control = ubuf;
421 msg.msg_controllen = sizeof(ubuf); 424 msg.msg_controllen = sizeof(ubuf);
422 ubufs = nvq->ubufs; 425 ubufs = nvq->ubufs;
423 kref_get(&ubufs->kref); 426 atomic_inc(&ubufs->refcount);
424 nvq->upend_idx = (nvq->upend_idx + 1) % UIO_MAXIOV; 427 nvq->upend_idx = (nvq->upend_idx + 1) % UIO_MAXIOV;
425 } else { 428 } else {
426 msg.msg_control = NULL; 429 msg.msg_control = NULL;
@@ -780,7 +783,7 @@ static void vhost_net_flush(struct vhost_net *n)
780 vhost_net_ubuf_put_and_wait(n->vqs[VHOST_NET_VQ_TX].ubufs); 783 vhost_net_ubuf_put_and_wait(n->vqs[VHOST_NET_VQ_TX].ubufs);
781 mutex_lock(&n->vqs[VHOST_NET_VQ_TX].vq.mutex); 784 mutex_lock(&n->vqs[VHOST_NET_VQ_TX].vq.mutex);
782 n->tx_flush = false; 785 n->tx_flush = false;
783 kref_init(&n->vqs[VHOST_NET_VQ_TX].ubufs->kref); 786 atomic_set(&n->vqs[VHOST_NET_VQ_TX].ubufs->refcount, 1);
784 mutex_unlock(&n->vqs[VHOST_NET_VQ_TX].vq.mutex); 787 mutex_unlock(&n->vqs[VHOST_NET_VQ_TX].vq.mutex);
785 } 788 }
786} 789}
@@ -800,6 +803,8 @@ static int vhost_net_release(struct inode *inode, struct file *f)
800 fput(tx_sock->file); 803 fput(tx_sock->file);
801 if (rx_sock) 804 if (rx_sock)
802 fput(rx_sock->file); 805 fput(rx_sock->file);
806 /* Make sure no callbacks are outstanding */
807 synchronize_rcu_bh();
803 /* We do an extra flush before freeing memory, 808 /* We do an extra flush before freeing memory,
804 * since jobs can re-queue themselves. */ 809 * since jobs can re-queue themselves. */
805 vhost_net_flush(n); 810 vhost_net_flush(n);
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/ceph/acl.c b/fs/ceph/acl.c
index 4c2d452c4bfc..21887d63dad5 100644
--- a/fs/ceph/acl.c
+++ b/fs/ceph/acl.c
@@ -54,11 +54,6 @@ static inline struct posix_acl *ceph_get_cached_acl(struct inode *inode,
54 return acl; 54 return acl;
55} 55}
56 56
57void ceph_forget_all_cached_acls(struct inode *inode)
58{
59 forget_all_cached_acls(inode);
60}
61
62struct posix_acl *ceph_get_acl(struct inode *inode, int type) 57struct posix_acl *ceph_get_acl(struct inode *inode, int type)
63{ 58{
64 int size; 59 int size;
@@ -160,11 +155,7 @@ int ceph_set_acl(struct inode *inode, struct posix_acl *acl, int type)
160 goto out_dput; 155 goto out_dput;
161 } 156 }
162 157
163 if (value) 158 ret = __ceph_setxattr(dentry, name, value, size, 0);
164 ret = __ceph_setxattr(dentry, name, value, size, 0);
165 else
166 ret = __ceph_removexattr(dentry, name);
167
168 if (ret) { 159 if (ret) {
169 if (new_mode != old_mode) { 160 if (new_mode != old_mode) {
170 newattrs.ia_mode = old_mode; 161 newattrs.ia_mode = old_mode;
diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
index 6da4df84ba30..45eda6d7a40c 100644
--- a/fs/ceph/dir.c
+++ b/fs/ceph/dir.c
@@ -100,6 +100,14 @@ static unsigned fpos_off(loff_t p)
100 return p & 0xffffffff; 100 return p & 0xffffffff;
101} 101}
102 102
103static int fpos_cmp(loff_t l, loff_t r)
104{
105 int v = ceph_frag_compare(fpos_frag(l), fpos_frag(r));
106 if (v)
107 return v;
108 return (int)(fpos_off(l) - fpos_off(r));
109}
110
103/* 111/*
104 * When possible, we try to satisfy a readdir by peeking at the 112 * When possible, we try to satisfy a readdir by peeking at the
105 * dcache. We make this work by carefully ordering dentries on 113 * dcache. We make this work by carefully ordering dentries on
@@ -156,7 +164,7 @@ more:
156 if (!d_unhashed(dentry) && dentry->d_inode && 164 if (!d_unhashed(dentry) && dentry->d_inode &&
157 ceph_snap(dentry->d_inode) != CEPH_SNAPDIR && 165 ceph_snap(dentry->d_inode) != CEPH_SNAPDIR &&
158 ceph_ino(dentry->d_inode) != CEPH_INO_CEPH && 166 ceph_ino(dentry->d_inode) != CEPH_INO_CEPH &&
159 ctx->pos <= di->offset) 167 fpos_cmp(ctx->pos, di->offset) <= 0)
160 break; 168 break;
161 dout(" skipping %p %.*s at %llu (%llu)%s%s\n", dentry, 169 dout(" skipping %p %.*s at %llu (%llu)%s%s\n", dentry,
162 dentry->d_name.len, dentry->d_name.name, di->offset, 170 dentry->d_name.len, dentry->d_name.name, di->offset,
@@ -695,9 +703,8 @@ static int ceph_mknod(struct inode *dir, struct dentry *dentry,
695 ceph_mdsc_put_request(req); 703 ceph_mdsc_put_request(req);
696 704
697 if (!err) 705 if (!err)
698 err = ceph_init_acl(dentry, dentry->d_inode, dir); 706 ceph_init_acl(dentry, dentry->d_inode, dir);
699 707 else
700 if (err)
701 d_drop(dentry); 708 d_drop(dentry);
702 return err; 709 return err;
703} 710}
@@ -735,7 +742,9 @@ static int ceph_symlink(struct inode *dir, struct dentry *dentry,
735 if (!err && !req->r_reply_info.head->is_dentry) 742 if (!err && !req->r_reply_info.head->is_dentry)
736 err = ceph_handle_notrace_create(dir, dentry); 743 err = ceph_handle_notrace_create(dir, dentry);
737 ceph_mdsc_put_request(req); 744 ceph_mdsc_put_request(req);
738 if (err) 745 if (!err)
746 ceph_init_acl(dentry, dentry->d_inode, dir);
747 else
739 d_drop(dentry); 748 d_drop(dentry);
740 return err; 749 return err;
741} 750}
@@ -776,7 +785,9 @@ static int ceph_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
776 err = ceph_handle_notrace_create(dir, dentry); 785 err = ceph_handle_notrace_create(dir, dentry);
777 ceph_mdsc_put_request(req); 786 ceph_mdsc_put_request(req);
778out: 787out:
779 if (err < 0) 788 if (!err)
789 ceph_init_acl(dentry, dentry->d_inode, dir);
790 else
780 d_drop(dentry); 791 d_drop(dentry);
781 return err; 792 return err;
782} 793}
diff --git a/fs/ceph/file.c b/fs/ceph/file.c
index dfd2ce3419f8..09c7afe32e49 100644
--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -286,6 +286,7 @@ int ceph_atomic_open(struct inode *dir, struct dentry *dentry,
286 } else { 286 } else {
287 dout("atomic_open finish_open on dn %p\n", dn); 287 dout("atomic_open finish_open on dn %p\n", dn);
288 if (req->r_op == CEPH_MDS_OP_CREATE && req->r_reply_info.has_create_ino) { 288 if (req->r_op == CEPH_MDS_OP_CREATE && req->r_reply_info.has_create_ino) {
289 ceph_init_acl(dentry, dentry->d_inode, dir);
289 *opened |= FILE_CREATED; 290 *opened |= FILE_CREATED;
290 } 291 }
291 err = finish_open(file, dentry, ceph_open, opened); 292 err = finish_open(file, dentry, ceph_open, opened);
diff --git a/fs/ceph/super.c b/fs/ceph/super.c
index 2df963f1cf5a..10a4ccbf38da 100644
--- a/fs/ceph/super.c
+++ b/fs/ceph/super.c
@@ -144,7 +144,11 @@ enum {
144 Opt_ino32, 144 Opt_ino32,
145 Opt_noino32, 145 Opt_noino32,
146 Opt_fscache, 146 Opt_fscache,
147 Opt_nofscache 147 Opt_nofscache,
148#ifdef CONFIG_CEPH_FS_POSIX_ACL
149 Opt_acl,
150#endif
151 Opt_noacl
148}; 152};
149 153
150static match_table_t fsopt_tokens = { 154static match_table_t fsopt_tokens = {
@@ -172,6 +176,10 @@ static match_table_t fsopt_tokens = {
172 {Opt_noino32, "noino32"}, 176 {Opt_noino32, "noino32"},
173 {Opt_fscache, "fsc"}, 177 {Opt_fscache, "fsc"},
174 {Opt_nofscache, "nofsc"}, 178 {Opt_nofscache, "nofsc"},
179#ifdef CONFIG_CEPH_FS_POSIX_ACL
180 {Opt_acl, "acl"},
181#endif
182 {Opt_noacl, "noacl"},
175 {-1, NULL} 183 {-1, NULL}
176}; 184};
177 185
@@ -271,6 +279,14 @@ static int parse_fsopt_token(char *c, void *private)
271 case Opt_nofscache: 279 case Opt_nofscache:
272 fsopt->flags &= ~CEPH_MOUNT_OPT_FSCACHE; 280 fsopt->flags &= ~CEPH_MOUNT_OPT_FSCACHE;
273 break; 281 break;
282#ifdef CONFIG_CEPH_FS_POSIX_ACL
283 case Opt_acl:
284 fsopt->sb_flags |= MS_POSIXACL;
285 break;
286#endif
287 case Opt_noacl:
288 fsopt->sb_flags &= ~MS_POSIXACL;
289 break;
274 default: 290 default:
275 BUG_ON(token); 291 BUG_ON(token);
276 } 292 }
@@ -438,6 +454,13 @@ static int ceph_show_options(struct seq_file *m, struct dentry *root)
438 else 454 else
439 seq_puts(m, ",nofsc"); 455 seq_puts(m, ",nofsc");
440 456
457#ifdef CONFIG_CEPH_FS_POSIX_ACL
458 if (fsopt->sb_flags & MS_POSIXACL)
459 seq_puts(m, ",acl");
460 else
461 seq_puts(m, ",noacl");
462#endif
463
441 if (fsopt->wsize) 464 if (fsopt->wsize)
442 seq_printf(m, ",wsize=%d", fsopt->wsize); 465 seq_printf(m, ",wsize=%d", fsopt->wsize);
443 if (fsopt->rsize != CEPH_RSIZE_DEFAULT) 466 if (fsopt->rsize != CEPH_RSIZE_DEFAULT)
@@ -819,9 +842,6 @@ static int ceph_set_super(struct super_block *s, void *data)
819 842
820 s->s_flags = fsc->mount_options->sb_flags; 843 s->s_flags = fsc->mount_options->sb_flags;
821 s->s_maxbytes = 1ULL << 40; /* temp value until we get mdsmap */ 844 s->s_maxbytes = 1ULL << 40; /* temp value until we get mdsmap */
822#ifdef CONFIG_CEPH_FS_POSIX_ACL
823 s->s_flags |= MS_POSIXACL;
824#endif
825 845
826 s->s_xattr = ceph_xattr_handlers; 846 s->s_xattr = ceph_xattr_handlers;
827 s->s_fs_info = fsc; 847 s->s_fs_info = fsc;
@@ -911,6 +931,10 @@ static struct dentry *ceph_mount(struct file_system_type *fs_type,
911 struct ceph_options *opt = NULL; 931 struct ceph_options *opt = NULL;
912 932
913 dout("ceph_mount\n"); 933 dout("ceph_mount\n");
934
935#ifdef CONFIG_CEPH_FS_POSIX_ACL
936 flags |= MS_POSIXACL;
937#endif
914 err = parse_mount_options(&fsopt, &opt, flags, data, dev_name, &path); 938 err = parse_mount_options(&fsopt, &opt, flags, data, dev_name, &path);
915 if (err < 0) { 939 if (err < 0) {
916 res = ERR_PTR(err); 940 res = ERR_PTR(err);
diff --git a/fs/ceph/super.h b/fs/ceph/super.h
index 19793b56d0a7..d8801a95b685 100644
--- a/fs/ceph/super.h
+++ b/fs/ceph/super.h
@@ -13,6 +13,7 @@
13#include <linux/wait.h> 13#include <linux/wait.h>
14#include <linux/writeback.h> 14#include <linux/writeback.h>
15#include <linux/slab.h> 15#include <linux/slab.h>
16#include <linux/posix_acl.h>
16 17
17#include <linux/ceph/libceph.h> 18#include <linux/ceph/libceph.h>
18 19
@@ -743,7 +744,11 @@ extern const struct xattr_handler *ceph_xattr_handlers[];
743struct posix_acl *ceph_get_acl(struct inode *, int); 744struct posix_acl *ceph_get_acl(struct inode *, int);
744int ceph_set_acl(struct inode *inode, struct posix_acl *acl, int type); 745int ceph_set_acl(struct inode *inode, struct posix_acl *acl, int type);
745int ceph_init_acl(struct dentry *, struct inode *, struct inode *); 746int ceph_init_acl(struct dentry *, struct inode *, struct inode *);
746void ceph_forget_all_cached_acls(struct inode *inode); 747
748static inline void ceph_forget_all_cached_acls(struct inode *inode)
749{
750 forget_all_cached_acls(inode);
751}
747 752
748#else 753#else
749 754
diff --git a/fs/ceph/xattr.c b/fs/ceph/xattr.c
index 898b6565ad3e..a55ec37378c6 100644
--- a/fs/ceph/xattr.c
+++ b/fs/ceph/xattr.c
@@ -12,6 +12,9 @@
12#define XATTR_CEPH_PREFIX "ceph." 12#define XATTR_CEPH_PREFIX "ceph."
13#define XATTR_CEPH_PREFIX_LEN (sizeof (XATTR_CEPH_PREFIX) - 1) 13#define XATTR_CEPH_PREFIX_LEN (sizeof (XATTR_CEPH_PREFIX) - 1)
14 14
15static int __remove_xattr(struct ceph_inode_info *ci,
16 struct ceph_inode_xattr *xattr);
17
15/* 18/*
16 * List of handlers for synthetic system.* attributes. Other 19 * List of handlers for synthetic system.* attributes. Other
17 * attributes are handled directly. 20 * attributes are handled directly.
@@ -319,8 +322,7 @@ static struct ceph_vxattr *ceph_match_vxattr(struct inode *inode,
319static int __set_xattr(struct ceph_inode_info *ci, 322static int __set_xattr(struct ceph_inode_info *ci,
320 const char *name, int name_len, 323 const char *name, int name_len,
321 const char *val, int val_len, 324 const char *val, int val_len,
322 int dirty, 325 int flags, int update_xattr,
323 int should_free_name, int should_free_val,
324 struct ceph_inode_xattr **newxattr) 326 struct ceph_inode_xattr **newxattr)
325{ 327{
326 struct rb_node **p; 328 struct rb_node **p;
@@ -349,12 +351,31 @@ static int __set_xattr(struct ceph_inode_info *ci,
349 xattr = NULL; 351 xattr = NULL;
350 } 352 }
351 353
354 if (update_xattr) {
355 int err = 0;
356 if (xattr && (flags & XATTR_CREATE))
357 err = -EEXIST;
358 else if (!xattr && (flags & XATTR_REPLACE))
359 err = -ENODATA;
360 if (err) {
361 kfree(name);
362 kfree(val);
363 return err;
364 }
365 if (update_xattr < 0) {
366 if (xattr)
367 __remove_xattr(ci, xattr);
368 kfree(name);
369 return 0;
370 }
371 }
372
352 if (!xattr) { 373 if (!xattr) {
353 new = 1; 374 new = 1;
354 xattr = *newxattr; 375 xattr = *newxattr;
355 xattr->name = name; 376 xattr->name = name;
356 xattr->name_len = name_len; 377 xattr->name_len = name_len;
357 xattr->should_free_name = should_free_name; 378 xattr->should_free_name = update_xattr;
358 379
359 ci->i_xattrs.count++; 380 ci->i_xattrs.count++;
360 dout("__set_xattr count=%d\n", ci->i_xattrs.count); 381 dout("__set_xattr count=%d\n", ci->i_xattrs.count);
@@ -364,7 +385,7 @@ static int __set_xattr(struct ceph_inode_info *ci,
364 if (xattr->should_free_val) 385 if (xattr->should_free_val)
365 kfree((void *)xattr->val); 386 kfree((void *)xattr->val);
366 387
367 if (should_free_name) { 388 if (update_xattr) {
368 kfree((void *)name); 389 kfree((void *)name);
369 name = xattr->name; 390 name = xattr->name;
370 } 391 }
@@ -379,8 +400,8 @@ static int __set_xattr(struct ceph_inode_info *ci,
379 xattr->val = ""; 400 xattr->val = "";
380 401
381 xattr->val_len = val_len; 402 xattr->val_len = val_len;
382 xattr->dirty = dirty; 403 xattr->dirty = update_xattr;
383 xattr->should_free_val = (val && should_free_val); 404 xattr->should_free_val = (val && update_xattr);
384 405
385 if (new) { 406 if (new) {
386 rb_link_node(&xattr->node, parent, p); 407 rb_link_node(&xattr->node, parent, p);
@@ -442,7 +463,7 @@ static int __remove_xattr(struct ceph_inode_info *ci,
442 struct ceph_inode_xattr *xattr) 463 struct ceph_inode_xattr *xattr)
443{ 464{
444 if (!xattr) 465 if (!xattr)
445 return -EOPNOTSUPP; 466 return -ENODATA;
446 467
447 rb_erase(&xattr->node, &ci->i_xattrs.index); 468 rb_erase(&xattr->node, &ci->i_xattrs.index);
448 469
@@ -588,7 +609,7 @@ start:
588 p += len; 609 p += len;
589 610
590 err = __set_xattr(ci, name, namelen, val, len, 611 err = __set_xattr(ci, name, namelen, val, len,
591 0, 0, 0, &xattrs[numattr]); 612 0, 0, &xattrs[numattr]);
592 613
593 if (err < 0) 614 if (err < 0)
594 goto bad; 615 goto bad;
@@ -850,6 +871,9 @@ static int ceph_sync_setxattr(struct dentry *dentry, const char *name,
850 871
851 dout("setxattr value=%.*s\n", (int)size, value); 872 dout("setxattr value=%.*s\n", (int)size, value);
852 873
874 if (!value)
875 flags |= CEPH_XATTR_REMOVE;
876
853 /* do request */ 877 /* do request */
854 req = ceph_mdsc_create_request(mdsc, CEPH_MDS_OP_SETXATTR, 878 req = ceph_mdsc_create_request(mdsc, CEPH_MDS_OP_SETXATTR,
855 USE_AUTH_MDS); 879 USE_AUTH_MDS);
@@ -892,7 +916,7 @@ int __ceph_setxattr(struct dentry *dentry, const char *name,
892 struct ceph_inode_info *ci = ceph_inode(inode); 916 struct ceph_inode_info *ci = ceph_inode(inode);
893 int issued; 917 int issued;
894 int err; 918 int err;
895 int dirty; 919 int dirty = 0;
896 int name_len = strlen(name); 920 int name_len = strlen(name);
897 int val_len = size; 921 int val_len = size;
898 char *newname = NULL; 922 char *newname = NULL;
@@ -953,12 +977,14 @@ retry:
953 goto retry; 977 goto retry;
954 } 978 }
955 979
956 err = __set_xattr(ci, newname, name_len, newval, 980 err = __set_xattr(ci, newname, name_len, newval, val_len,
957 val_len, 1, 1, 1, &xattr); 981 flags, value ? 1 : -1, &xattr);
958 982
959 dirty = __ceph_mark_dirty_caps(ci, CEPH_CAP_XATTR_EXCL); 983 if (!err) {
960 ci->i_xattrs.dirty = true; 984 dirty = __ceph_mark_dirty_caps(ci, CEPH_CAP_XATTR_EXCL);
961 inode->i_ctime = CURRENT_TIME; 985 ci->i_xattrs.dirty = true;
986 inode->i_ctime = CURRENT_TIME;
987 }
962 988
963 spin_unlock(&ci->i_ceph_lock); 989 spin_unlock(&ci->i_ceph_lock);
964 if (dirty) 990 if (dirty)
diff --git a/fs/cifs/cifsacl.c b/fs/cifs/cifsacl.c
index c819b0bd491a..7ff866dbb89e 100644
--- a/fs/cifs/cifsacl.c
+++ b/fs/cifs/cifsacl.c
@@ -865,8 +865,8 @@ static int build_sec_desc(struct cifs_ntsd *pntsd, struct cifs_ntsd *pnntsd,
865 return rc; 865 return rc;
866} 866}
867 867
868static struct cifs_ntsd *get_cifs_acl_by_fid(struct cifs_sb_info *cifs_sb, 868struct cifs_ntsd *get_cifs_acl_by_fid(struct cifs_sb_info *cifs_sb,
869 __u16 fid, u32 *pacllen) 869 const struct cifs_fid *cifsfid, u32 *pacllen)
870{ 870{
871 struct cifs_ntsd *pntsd = NULL; 871 struct cifs_ntsd *pntsd = NULL;
872 unsigned int xid; 872 unsigned int xid;
@@ -877,7 +877,8 @@ static struct cifs_ntsd *get_cifs_acl_by_fid(struct cifs_sb_info *cifs_sb,
877 return ERR_CAST(tlink); 877 return ERR_CAST(tlink);
878 878
879 xid = get_xid(); 879 xid = get_xid();
880 rc = CIFSSMBGetCIFSACL(xid, tlink_tcon(tlink), fid, &pntsd, pacllen); 880 rc = CIFSSMBGetCIFSACL(xid, tlink_tcon(tlink), cifsfid->netfid, &pntsd,
881 pacllen);
881 free_xid(xid); 882 free_xid(xid);
882 883
883 cifs_put_tlink(tlink); 884 cifs_put_tlink(tlink);
@@ -946,7 +947,7 @@ struct cifs_ntsd *get_cifs_acl(struct cifs_sb_info *cifs_sb,
946 if (!open_file) 947 if (!open_file)
947 return get_cifs_acl_by_path(cifs_sb, path, pacllen); 948 return get_cifs_acl_by_path(cifs_sb, path, pacllen);
948 949
949 pntsd = get_cifs_acl_by_fid(cifs_sb, open_file->fid.netfid, pacllen); 950 pntsd = get_cifs_acl_by_fid(cifs_sb, &open_file->fid, pacllen);
950 cifsFileInfo_put(open_file); 951 cifsFileInfo_put(open_file);
951 return pntsd; 952 return pntsd;
952} 953}
@@ -1006,19 +1007,31 @@ out:
1006/* Translate the CIFS ACL (simlar to NTFS ACL) for a file into mode bits */ 1007/* Translate the CIFS ACL (simlar to NTFS ACL) for a file into mode bits */
1007int 1008int
1008cifs_acl_to_fattr(struct cifs_sb_info *cifs_sb, struct cifs_fattr *fattr, 1009cifs_acl_to_fattr(struct cifs_sb_info *cifs_sb, struct cifs_fattr *fattr,
1009 struct inode *inode, const char *path, const __u16 *pfid) 1010 struct inode *inode, const char *path,
1011 const struct cifs_fid *pfid)
1010{ 1012{
1011 struct cifs_ntsd *pntsd = NULL; 1013 struct cifs_ntsd *pntsd = NULL;
1012 u32 acllen = 0; 1014 u32 acllen = 0;
1013 int rc = 0; 1015 int rc = 0;
1016 struct tcon_link *tlink = cifs_sb_tlink(cifs_sb);
1017 struct cifs_tcon *tcon;
1014 1018
1015 cifs_dbg(NOISY, "converting ACL to mode for %s\n", path); 1019 cifs_dbg(NOISY, "converting ACL to mode for %s\n", path);
1016 1020
1017 if (pfid) 1021 if (IS_ERR(tlink))
1018 pntsd = get_cifs_acl_by_fid(cifs_sb, *pfid, &acllen); 1022 return PTR_ERR(tlink);
1019 else 1023 tcon = tlink_tcon(tlink);
1020 pntsd = get_cifs_acl(cifs_sb, inode, path, &acllen);
1021 1024
1025 if (pfid && (tcon->ses->server->ops->get_acl_by_fid))
1026 pntsd = tcon->ses->server->ops->get_acl_by_fid(cifs_sb, pfid,
1027 &acllen);
1028 else if (tcon->ses->server->ops->get_acl)
1029 pntsd = tcon->ses->server->ops->get_acl(cifs_sb, inode, path,
1030 &acllen);
1031 else {
1032 cifs_put_tlink(tlink);
1033 return -EOPNOTSUPP;
1034 }
1022 /* if we can retrieve the ACL, now parse Access Control Entries, ACEs */ 1035 /* if we can retrieve the ACL, now parse Access Control Entries, ACEs */
1023 if (IS_ERR(pntsd)) { 1036 if (IS_ERR(pntsd)) {
1024 rc = PTR_ERR(pntsd); 1037 rc = PTR_ERR(pntsd);
@@ -1030,6 +1043,8 @@ cifs_acl_to_fattr(struct cifs_sb_info *cifs_sb, struct cifs_fattr *fattr,
1030 cifs_dbg(VFS, "parse sec desc failed rc = %d\n", rc); 1043 cifs_dbg(VFS, "parse sec desc failed rc = %d\n", rc);
1031 } 1044 }
1032 1045
1046 cifs_put_tlink(tlink);
1047
1033 return rc; 1048 return rc;
1034} 1049}
1035 1050
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index 86dc28c7aa5c..cf32f0393369 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -398,6 +398,8 @@ struct smb_version_operations {
398 const struct nls_table *, int); 398 const struct nls_table *, int);
399 struct cifs_ntsd * (*get_acl)(struct cifs_sb_info *, struct inode *, 399 struct cifs_ntsd * (*get_acl)(struct cifs_sb_info *, struct inode *,
400 const char *, u32 *); 400 const char *, u32 *);
401 struct cifs_ntsd * (*get_acl_by_fid)(struct cifs_sb_info *,
402 const struct cifs_fid *, u32 *);
401 int (*set_acl)(struct cifs_ntsd *, __u32, struct inode *, const char *, 403 int (*set_acl)(struct cifs_ntsd *, __u32, struct inode *, const char *,
402 int); 404 int);
403}; 405};
diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h
index d00e09dfc452..acc4ee8ed075 100644
--- a/fs/cifs/cifsproto.h
+++ b/fs/cifs/cifsproto.h
@@ -151,7 +151,7 @@ extern struct inode *cifs_iget(struct super_block *sb,
151 151
152extern int cifs_get_inode_info(struct inode **inode, const char *full_path, 152extern int cifs_get_inode_info(struct inode **inode, const char *full_path,
153 FILE_ALL_INFO *data, struct super_block *sb, 153 FILE_ALL_INFO *data, struct super_block *sb,
154 int xid, const __u16 *fid); 154 int xid, const struct cifs_fid *fid);
155extern int cifs_get_inode_info_unix(struct inode **pinode, 155extern int cifs_get_inode_info_unix(struct inode **pinode,
156 const unsigned char *search_path, 156 const unsigned char *search_path,
157 struct super_block *sb, unsigned int xid); 157 struct super_block *sb, unsigned int xid);
@@ -162,11 +162,13 @@ extern int cifs_rename_pending_delete(const char *full_path,
162 const unsigned int xid); 162 const unsigned int xid);
163extern int cifs_acl_to_fattr(struct cifs_sb_info *cifs_sb, 163extern int cifs_acl_to_fattr(struct cifs_sb_info *cifs_sb,
164 struct cifs_fattr *fattr, struct inode *inode, 164 struct cifs_fattr *fattr, struct inode *inode,
165 const char *path, const __u16 *pfid); 165 const char *path, const struct cifs_fid *pfid);
166extern int id_mode_to_cifs_acl(struct inode *inode, const char *path, __u64, 166extern int id_mode_to_cifs_acl(struct inode *inode, const char *path, __u64,
167 kuid_t, kgid_t); 167 kuid_t, kgid_t);
168extern struct cifs_ntsd *get_cifs_acl(struct cifs_sb_info *, struct inode *, 168extern struct cifs_ntsd *get_cifs_acl(struct cifs_sb_info *, struct inode *,
169 const char *, u32 *); 169 const char *, u32 *);
170extern struct cifs_ntsd *get_cifs_acl_by_fid(struct cifs_sb_info *,
171 const struct cifs_fid *, u32 *);
170extern int set_cifs_acl(struct cifs_ntsd *, __u32, struct inode *, 172extern int set_cifs_acl(struct cifs_ntsd *, __u32, struct inode *,
171 const char *, int); 173 const char *, int);
172 174
diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c
index d3a6796caa5a..3db0c5fd9a11 100644
--- a/fs/cifs/dir.c
+++ b/fs/cifs/dir.c
@@ -378,7 +378,7 @@ cifs_create_get_file_info:
378 xid); 378 xid);
379 else { 379 else {
380 rc = cifs_get_inode_info(&newinode, full_path, buf, inode->i_sb, 380 rc = cifs_get_inode_info(&newinode, full_path, buf, inode->i_sb,
381 xid, &fid->netfid); 381 xid, fid);
382 if (newinode) { 382 if (newinode) {
383 if (server->ops->set_lease_key) 383 if (server->ops->set_lease_key)
384 server->ops->set_lease_key(newinode, fid); 384 server->ops->set_lease_key(newinode, fid);
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 755584684f6c..53c15074bb36 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -244,7 +244,7 @@ cifs_nt_open(char *full_path, struct inode *inode, struct cifs_sb_info *cifs_sb,
244 xid); 244 xid);
245 else 245 else
246 rc = cifs_get_inode_info(&inode, full_path, buf, inode->i_sb, 246 rc = cifs_get_inode_info(&inode, full_path, buf, inode->i_sb,
247 xid, &fid->netfid); 247 xid, fid);
248 248
249out: 249out:
250 kfree(buf); 250 kfree(buf);
@@ -2389,7 +2389,7 @@ cifs_iovec_write(struct file *file, const struct iovec *iov,
2389 unsigned long nr_segs, loff_t *poffset) 2389 unsigned long nr_segs, loff_t *poffset)
2390{ 2390{
2391 unsigned long nr_pages, i; 2391 unsigned long nr_pages, i;
2392 size_t copied, len, cur_len; 2392 size_t bytes, copied, len, cur_len;
2393 ssize_t total_written = 0; 2393 ssize_t total_written = 0;
2394 loff_t offset; 2394 loff_t offset;
2395 struct iov_iter it; 2395 struct iov_iter it;
@@ -2444,14 +2444,45 @@ cifs_iovec_write(struct file *file, const struct iovec *iov,
2444 2444
2445 save_len = cur_len; 2445 save_len = cur_len;
2446 for (i = 0; i < nr_pages; i++) { 2446 for (i = 0; i < nr_pages; i++) {
2447 copied = min_t(const size_t, cur_len, PAGE_SIZE); 2447 bytes = min_t(const size_t, cur_len, PAGE_SIZE);
2448 copied = iov_iter_copy_from_user(wdata->pages[i], &it, 2448 copied = iov_iter_copy_from_user(wdata->pages[i], &it,
2449 0, copied); 2449 0, bytes);
2450 cur_len -= copied; 2450 cur_len -= copied;
2451 iov_iter_advance(&it, copied); 2451 iov_iter_advance(&it, copied);
2452 /*
2453 * If we didn't copy as much as we expected, then that
2454 * may mean we trod into an unmapped area. Stop copying
2455 * at that point. On the next pass through the big
2456 * loop, we'll likely end up getting a zero-length
2457 * write and bailing out of it.
2458 */
2459 if (copied < bytes)
2460 break;
2452 } 2461 }
2453 cur_len = save_len - cur_len; 2462 cur_len = save_len - cur_len;
2454 2463
2464 /*
2465 * If we have no data to send, then that probably means that
2466 * the copy above failed altogether. That's most likely because
2467 * the address in the iovec was bogus. Set the rc to -EFAULT,
2468 * free anything we allocated and bail out.
2469 */
2470 if (!cur_len) {
2471 for (i = 0; i < nr_pages; i++)
2472 put_page(wdata->pages[i]);
2473 kfree(wdata);
2474 rc = -EFAULT;
2475 break;
2476 }
2477
2478 /*
2479 * i + 1 now represents the number of pages we actually used in
2480 * the copy phase above. Bring nr_pages down to that, and free
2481 * any pages that we didn't use.
2482 */
2483 for ( ; nr_pages > i + 1; nr_pages--)
2484 put_page(wdata->pages[nr_pages - 1]);
2485
2455 wdata->sync_mode = WB_SYNC_ALL; 2486 wdata->sync_mode = WB_SYNC_ALL;
2456 wdata->nr_pages = nr_pages; 2487 wdata->nr_pages = nr_pages;
2457 wdata->offset = (__u64)offset; 2488 wdata->offset = (__u64)offset;
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index be58b8fcdb3c..aadc2b68678b 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -677,7 +677,7 @@ cgfi_exit:
677int 677int
678cifs_get_inode_info(struct inode **inode, const char *full_path, 678cifs_get_inode_info(struct inode **inode, const char *full_path,
679 FILE_ALL_INFO *data, struct super_block *sb, int xid, 679 FILE_ALL_INFO *data, struct super_block *sb, int xid,
680 const __u16 *fid) 680 const struct cifs_fid *fid)
681{ 681{
682 bool validinum = false; 682 bool validinum = false;
683 __u16 srchflgs; 683 __u16 srchflgs;
diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
index bfd66d84831e..526fb89f9230 100644
--- a/fs/cifs/smb1ops.c
+++ b/fs/cifs/smb1ops.c
@@ -1073,6 +1073,7 @@ struct smb_version_operations smb1_operations = {
1073#endif /* CIFS_XATTR */ 1073#endif /* CIFS_XATTR */
1074#ifdef CONFIG_CIFS_ACL 1074#ifdef CONFIG_CIFS_ACL
1075 .get_acl = get_cifs_acl, 1075 .get_acl = get_cifs_acl,
1076 .get_acl_by_fid = get_cifs_acl_by_fid,
1076 .set_acl = set_cifs_acl, 1077 .set_acl = set_cifs_acl,
1077#endif /* CIFS_ACL */ 1078#endif /* CIFS_ACL */
1078}; 1079};
diff --git a/fs/cifs/smb2glob.h b/fs/cifs/smb2glob.h
index c38350851b08..bc0bb9c34f72 100644
--- a/fs/cifs/smb2glob.h
+++ b/fs/cifs/smb2glob.h
@@ -57,4 +57,7 @@
57#define SMB2_CMACAES_SIZE (16) 57#define SMB2_CMACAES_SIZE (16)
58#define SMB3_SIGNKEY_SIZE (16) 58#define SMB3_SIGNKEY_SIZE (16)
59 59
60/* Maximum buffer size value we can send with 1 credit */
61#define SMB2_MAX_BUFFER_SIZE 65536
62
60#endif /* _SMB2_GLOB_H */ 63#endif /* _SMB2_GLOB_H */
diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
index 757da3e54d3d..192f51a12cf1 100644
--- a/fs/cifs/smb2ops.c
+++ b/fs/cifs/smb2ops.c
@@ -182,11 +182,8 @@ smb2_negotiate_wsize(struct cifs_tcon *tcon, struct smb_vol *volume_info)
182 /* start with specified wsize, or default */ 182 /* start with specified wsize, or default */
183 wsize = volume_info->wsize ? volume_info->wsize : CIFS_DEFAULT_IOSIZE; 183 wsize = volume_info->wsize ? volume_info->wsize : CIFS_DEFAULT_IOSIZE;
184 wsize = min_t(unsigned int, wsize, server->max_write); 184 wsize = min_t(unsigned int, wsize, server->max_write);
185 /* 185 /* set it to the maximum buffer size value we can send with 1 credit */
186 * limit write size to 2 ** 16, because we don't support multicredit 186 wsize = min_t(unsigned int, wsize, SMB2_MAX_BUFFER_SIZE);
187 * requests now.
188 */
189 wsize = min_t(unsigned int, wsize, 2 << 15);
190 187
191 return wsize; 188 return wsize;
192} 189}
@@ -200,11 +197,8 @@ smb2_negotiate_rsize(struct cifs_tcon *tcon, struct smb_vol *volume_info)
200 /* start with specified rsize, or default */ 197 /* start with specified rsize, or default */
201 rsize = volume_info->rsize ? volume_info->rsize : CIFS_DEFAULT_IOSIZE; 198 rsize = volume_info->rsize ? volume_info->rsize : CIFS_DEFAULT_IOSIZE;
202 rsize = min_t(unsigned int, rsize, server->max_read); 199 rsize = min_t(unsigned int, rsize, server->max_read);
203 /* 200 /* set it to the maximum buffer size value we can send with 1 credit */
204 * limit write size to 2 ** 16, because we don't support multicredit 201 rsize = min_t(unsigned int, rsize, SMB2_MAX_BUFFER_SIZE);
205 * requests now.
206 */
207 rsize = min_t(unsigned int, rsize, 2 << 15);
208 202
209 return rsize; 203 return rsize;
210} 204}
diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
index a3f7a9c3cc69..860344701067 100644
--- a/fs/cifs/smb2pdu.c
+++ b/fs/cifs/smb2pdu.c
@@ -413,7 +413,9 @@ SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses)
413 413
414 /* SMB2 only has an extended negflavor */ 414 /* SMB2 only has an extended negflavor */
415 server->negflavor = CIFS_NEGFLAVOR_EXTENDED; 415 server->negflavor = CIFS_NEGFLAVOR_EXTENDED;
416 server->maxBuf = le32_to_cpu(rsp->MaxTransactSize); 416 /* set it to the maximum buffer size value we can send with 1 credit */
417 server->maxBuf = min_t(unsigned int, le32_to_cpu(rsp->MaxTransactSize),
418 SMB2_MAX_BUFFER_SIZE);
417 server->max_read = le32_to_cpu(rsp->MaxReadSize); 419 server->max_read = le32_to_cpu(rsp->MaxReadSize);
418 server->max_write = le32_to_cpu(rsp->MaxWriteSize); 420 server->max_write = le32_to_cpu(rsp->MaxWriteSize);
419 /* BB Do we need to validate the SecurityMode? */ 421 /* BB Do we need to validate the SecurityMode? */
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index ece55565b9cd..d3a534fdc5ff 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -771,6 +771,8 @@ do { \
771 if (EXT4_FITS_IN_INODE(raw_inode, einode, xtime)) \ 771 if (EXT4_FITS_IN_INODE(raw_inode, einode, xtime)) \
772 (einode)->xtime.tv_sec = \ 772 (einode)->xtime.tv_sec = \
773 (signed)le32_to_cpu((raw_inode)->xtime); \ 773 (signed)le32_to_cpu((raw_inode)->xtime); \
774 else \
775 (einode)->xtime.tv_sec = 0; \
774 if (EXT4_FITS_IN_INODE(raw_inode, einode, xtime ## _extra)) \ 776 if (EXT4_FITS_IN_INODE(raw_inode, einode, xtime ## _extra)) \
775 ext4_decode_extra_time(&(einode)->xtime, \ 777 ext4_decode_extra_time(&(einode)->xtime, \
776 raw_inode->xtime ## _extra); \ 778 raw_inode->xtime ## _extra); \
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 10cff4736b11..74bc2d549c58 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -3906,6 +3906,7 @@ ext4_ext_handle_uninitialized_extents(handle_t *handle, struct inode *inode,
3906 } else 3906 } else
3907 err = ret; 3907 err = ret;
3908 map->m_flags |= EXT4_MAP_MAPPED; 3908 map->m_flags |= EXT4_MAP_MAPPED;
3909 map->m_pblk = newblock;
3909 if (allocated > map->m_len) 3910 if (allocated > map->m_len)
3910 allocated = map->m_len; 3911 allocated = map->m_len;
3911 map->m_len = allocated; 3912 map->m_len = allocated;
diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
index 6bea80614d77..a2a837f00407 100644
--- a/fs/ext4/ioctl.c
+++ b/fs/ext4/ioctl.c
@@ -140,7 +140,7 @@ static long swap_inode_boot_loader(struct super_block *sb,
140 handle = ext4_journal_start(inode_bl, EXT4_HT_MOVE_EXTENTS, 2); 140 handle = ext4_journal_start(inode_bl, EXT4_HT_MOVE_EXTENTS, 2);
141 if (IS_ERR(handle)) { 141 if (IS_ERR(handle)) {
142 err = -EINVAL; 142 err = -EINVAL;
143 goto swap_boot_out; 143 goto journal_err_out;
144 } 144 }
145 145
146 /* Protect extent tree against block allocations via delalloc */ 146 /* Protect extent tree against block allocations via delalloc */
@@ -198,6 +198,7 @@ static long swap_inode_boot_loader(struct super_block *sb,
198 198
199 ext4_double_up_write_data_sem(inode, inode_bl); 199 ext4_double_up_write_data_sem(inode, inode_bl);
200 200
201journal_err_out:
201 ext4_inode_resume_unlocked_dio(inode); 202 ext4_inode_resume_unlocked_dio(inode);
202 ext4_inode_resume_unlocked_dio(inode_bl); 203 ext4_inode_resume_unlocked_dio(inode_bl);
203 204
diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
index c5adbb318a90..f3b84cd9de56 100644
--- a/fs/ext4/resize.c
+++ b/fs/ext4/resize.c
@@ -243,6 +243,7 @@ static int ext4_alloc_group_tables(struct super_block *sb,
243 ext4_group_t group; 243 ext4_group_t group;
244 ext4_group_t last_group; 244 ext4_group_t last_group;
245 unsigned overhead; 245 unsigned overhead;
246 __u16 uninit_mask = (flexbg_size > 1) ? ~EXT4_BG_BLOCK_UNINIT : ~0;
246 247
247 BUG_ON(flex_gd->count == 0 || group_data == NULL); 248 BUG_ON(flex_gd->count == 0 || group_data == NULL);
248 249
@@ -266,7 +267,7 @@ next_group:
266 src_group++; 267 src_group++;
267 for (; src_group <= last_group; src_group++) { 268 for (; src_group <= last_group; src_group++) {
268 overhead = ext4_group_overhead_blocks(sb, src_group); 269 overhead = ext4_group_overhead_blocks(sb, src_group);
269 if (overhead != 0) 270 if (overhead == 0)
270 last_blk += group_data[src_group - group].blocks_count; 271 last_blk += group_data[src_group - group].blocks_count;
271 else 272 else
272 break; 273 break;
@@ -280,8 +281,7 @@ next_group:
280 group = ext4_get_group_number(sb, start_blk - 1); 281 group = ext4_get_group_number(sb, start_blk - 1);
281 group -= group_data[0].group; 282 group -= group_data[0].group;
282 group_data[group].free_blocks_count--; 283 group_data[group].free_blocks_count--;
283 if (flexbg_size > 1) 284 flex_gd->bg_flags[group] &= uninit_mask;
284 flex_gd->bg_flags[group] &= ~EXT4_BG_BLOCK_UNINIT;
285 } 285 }
286 286
287 /* Allocate inode bitmaps */ 287 /* Allocate inode bitmaps */
@@ -292,22 +292,30 @@ next_group:
292 group = ext4_get_group_number(sb, start_blk - 1); 292 group = ext4_get_group_number(sb, start_blk - 1);
293 group -= group_data[0].group; 293 group -= group_data[0].group;
294 group_data[group].free_blocks_count--; 294 group_data[group].free_blocks_count--;
295 if (flexbg_size > 1) 295 flex_gd->bg_flags[group] &= uninit_mask;
296 flex_gd->bg_flags[group] &= ~EXT4_BG_BLOCK_UNINIT;
297 } 296 }
298 297
299 /* Allocate inode tables */ 298 /* Allocate inode tables */
300 for (; it_index < flex_gd->count; it_index++) { 299 for (; it_index < flex_gd->count; it_index++) {
301 if (start_blk + EXT4_SB(sb)->s_itb_per_group > last_blk) 300 unsigned int itb = EXT4_SB(sb)->s_itb_per_group;
301 ext4_fsblk_t next_group_start;
302
303 if (start_blk + itb > last_blk)
302 goto next_group; 304 goto next_group;
303 group_data[it_index].inode_table = start_blk; 305 group_data[it_index].inode_table = start_blk;
304 group = ext4_get_group_number(sb, start_blk - 1); 306 group = ext4_get_group_number(sb, start_blk);
307 next_group_start = ext4_group_first_block_no(sb, group + 1);
305 group -= group_data[0].group; 308 group -= group_data[0].group;
306 group_data[group].free_blocks_count -=
307 EXT4_SB(sb)->s_itb_per_group;
308 if (flexbg_size > 1)
309 flex_gd->bg_flags[group] &= ~EXT4_BG_BLOCK_UNINIT;
310 309
310 if (start_blk + itb > next_group_start) {
311 flex_gd->bg_flags[group + 1] &= uninit_mask;
312 overhead = start_blk + itb - next_group_start;
313 group_data[group + 1].free_blocks_count -= overhead;
314 itb -= overhead;
315 }
316
317 group_data[group].free_blocks_count -= itb;
318 flex_gd->bg_flags[group] &= uninit_mask;
311 start_blk += EXT4_SB(sb)->s_itb_per_group; 319 start_blk += EXT4_SB(sb)->s_itb_per_group;
312 } 320 }
313 321
@@ -401,7 +409,7 @@ static int set_flexbg_block_bitmap(struct super_block *sb, handle_t *handle,
401 start = ext4_group_first_block_no(sb, group); 409 start = ext4_group_first_block_no(sb, group);
402 group -= flex_gd->groups[0].group; 410 group -= flex_gd->groups[0].group;
403 411
404 count2 = sb->s_blocksize * 8 - (block - start); 412 count2 = EXT4_BLOCKS_PER_GROUP(sb) - (block - start);
405 if (count2 > count) 413 if (count2 > count)
406 count2 = count; 414 count2 = count;
407 415
@@ -620,7 +628,7 @@ handle_ib:
620 if (err) 628 if (err)
621 goto out; 629 goto out;
622 count = group_table_count[j]; 630 count = group_table_count[j];
623 start = group_data[i].block_bitmap; 631 start = (&group_data[i].block_bitmap)[j];
624 block = start; 632 block = start;
625 } 633 }
626 634
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 1f7784de05b6..710fed2377d4 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -3695,16 +3695,22 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
3695 for (i = 0; i < 4; i++) 3695 for (i = 0; i < 4; i++)
3696 sbi->s_hash_seed[i] = le32_to_cpu(es->s_hash_seed[i]); 3696 sbi->s_hash_seed[i] = le32_to_cpu(es->s_hash_seed[i]);
3697 sbi->s_def_hash_version = es->s_def_hash_version; 3697 sbi->s_def_hash_version = es->s_def_hash_version;
3698 i = le32_to_cpu(es->s_flags); 3698 if (EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_DIR_INDEX)) {
3699 if (i & EXT2_FLAGS_UNSIGNED_HASH) 3699 i = le32_to_cpu(es->s_flags);
3700 sbi->s_hash_unsigned = 3; 3700 if (i & EXT2_FLAGS_UNSIGNED_HASH)
3701 else if ((i & EXT2_FLAGS_SIGNED_HASH) == 0) { 3701 sbi->s_hash_unsigned = 3;
3702 else if ((i & EXT2_FLAGS_SIGNED_HASH) == 0) {
3702#ifdef __CHAR_UNSIGNED__ 3703#ifdef __CHAR_UNSIGNED__
3703 es->s_flags |= cpu_to_le32(EXT2_FLAGS_UNSIGNED_HASH); 3704 if (!(sb->s_flags & MS_RDONLY))
3704 sbi->s_hash_unsigned = 3; 3705 es->s_flags |=
3706 cpu_to_le32(EXT2_FLAGS_UNSIGNED_HASH);
3707 sbi->s_hash_unsigned = 3;
3705#else 3708#else
3706 es->s_flags |= cpu_to_le32(EXT2_FLAGS_SIGNED_HASH); 3709 if (!(sb->s_flags & MS_RDONLY))
3710 es->s_flags |=
3711 cpu_to_le32(EXT2_FLAGS_SIGNED_HASH);
3707#endif 3712#endif
3713 }
3708 } 3714 }
3709 3715
3710 /* Handle clustersize */ 3716 /* Handle clustersize */
diff --git a/fs/fscache/object-list.c b/fs/fscache/object-list.c
index e1959efad64f..b5ebc2d7d80d 100644
--- a/fs/fscache/object-list.c
+++ b/fs/fscache/object-list.c
@@ -50,6 +50,8 @@ void fscache_objlist_add(struct fscache_object *obj)
50 struct fscache_object *xobj; 50 struct fscache_object *xobj;
51 struct rb_node **p = &fscache_object_list.rb_node, *parent = NULL; 51 struct rb_node **p = &fscache_object_list.rb_node, *parent = NULL;
52 52
53 ASSERT(RB_EMPTY_NODE(&obj->objlist_link));
54
53 write_lock(&fscache_object_list_lock); 55 write_lock(&fscache_object_list_lock);
54 56
55 while (*p) { 57 while (*p) {
@@ -75,6 +77,9 @@ void fscache_objlist_add(struct fscache_object *obj)
75 */ 77 */
76void fscache_objlist_remove(struct fscache_object *obj) 78void fscache_objlist_remove(struct fscache_object *obj)
77{ 79{
80 if (RB_EMPTY_NODE(&obj->objlist_link))
81 return;
82
78 write_lock(&fscache_object_list_lock); 83 write_lock(&fscache_object_list_lock);
79 84
80 BUG_ON(RB_EMPTY_ROOT(&fscache_object_list)); 85 BUG_ON(RB_EMPTY_ROOT(&fscache_object_list));
diff --git a/fs/fscache/object.c b/fs/fscache/object.c
index 53d35c504240..d3b4539f1651 100644
--- a/fs/fscache/object.c
+++ b/fs/fscache/object.c
@@ -314,6 +314,9 @@ void fscache_object_init(struct fscache_object *object,
314 object->cache = cache; 314 object->cache = cache;
315 object->cookie = cookie; 315 object->cookie = cookie;
316 object->parent = NULL; 316 object->parent = NULL;
317#ifdef CONFIG_FSCACHE_OBJECT_LIST
318 RB_CLEAR_NODE(&object->objlist_link);
319#endif
317 320
318 object->oob_event_mask = 0; 321 object->oob_event_mask = 0;
319 for (t = object->oob_table; t->events; t++) 322 for (t = object->oob_table; t->events; t++)
diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c
index 8360674c85bc..60bb365f54a5 100644
--- a/fs/jbd2/transaction.c
+++ b/fs/jbd2/transaction.c
@@ -514,11 +514,13 @@ int jbd2_journal_start_reserved(handle_t *handle, unsigned int type,
514 * similarly constrained call sites 514 * similarly constrained call sites
515 */ 515 */
516 ret = start_this_handle(journal, handle, GFP_NOFS); 516 ret = start_this_handle(journal, handle, GFP_NOFS);
517 if (ret < 0) 517 if (ret < 0) {
518 jbd2_journal_free_reserved(handle); 518 jbd2_journal_free_reserved(handle);
519 return ret;
520 }
519 handle->h_type = type; 521 handle->h_type = type;
520 handle->h_line_no = line_no; 522 handle->h_line_no = line_no;
521 return ret; 523 return 0;
522} 524}
523EXPORT_SYMBOL(jbd2_journal_start_reserved); 525EXPORT_SYMBOL(jbd2_journal_start_reserved);
524 526
diff --git a/fs/jfs/acl.c b/fs/jfs/acl.c
index e973b85d6afd..5a8ea16eedbc 100644
--- a/fs/jfs/acl.c
+++ b/fs/jfs/acl.c
@@ -86,6 +86,8 @@ static int __jfs_set_acl(tid_t tid, struct inode *inode, int type,
86 rc = posix_acl_equiv_mode(acl, &inode->i_mode); 86 rc = posix_acl_equiv_mode(acl, &inode->i_mode);
87 if (rc < 0) 87 if (rc < 0)
88 return rc; 88 return rc;
89 inode->i_ctime = CURRENT_TIME;
90 mark_inode_dirty(inode);
89 if (rc == 0) 91 if (rc == 0)
90 acl = NULL; 92 acl = NULL;
91 break; 93 break;
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/reiserfs/do_balan.c b/fs/reiserfs/do_balan.c
index 2b7882b508db..9a3c68cf6026 100644
--- a/fs/reiserfs/do_balan.c
+++ b/fs/reiserfs/do_balan.c
@@ -324,23 +324,17 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h
324 switch (flag) { 324 switch (flag) {
325 case M_INSERT: /* insert item into L[0] */ 325 case M_INSERT: /* insert item into L[0] */
326 326
327 if (item_pos == tb->lnum[0] - 1 327 if (item_pos == tb->lnum[0] - 1 && tb->lbytes != -1) {
328 && tb->lbytes != -1) {
329 /* part of new item falls into L[0] */ 328 /* part of new item falls into L[0] */
330 int new_item_len; 329 int new_item_len;
331 int version; 330 int version;
332 331
333 ret_val = 332 ret_val = leaf_shift_left(tb, tb->lnum[0] - 1, -1);
334 leaf_shift_left(tb, tb->lnum[0] - 1,
335 -1);
336 333
337 /* Calculate item length to insert to S[0] */ 334 /* Calculate item length to insert to S[0] */
338 new_item_len = 335 new_item_len = ih_item_len(ih) - tb->lbytes;
339 ih_item_len(ih) - tb->lbytes;
340 /* Calculate and check item length to insert to L[0] */ 336 /* Calculate and check item length to insert to L[0] */
341 put_ih_item_len(ih, 337 put_ih_item_len(ih, ih_item_len(ih) - new_item_len);
342 ih_item_len(ih) -
343 new_item_len);
344 338
345 RFALSE(ih_item_len(ih) <= 0, 339 RFALSE(ih_item_len(ih) <= 0,
346 "PAP-12080: there is nothing to insert into L[0]: ih_item_len=%d", 340 "PAP-12080: there is nothing to insert into L[0]: ih_item_len=%d",
@@ -349,30 +343,18 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h
349 /* Insert new item into L[0] */ 343 /* Insert new item into L[0] */
350 buffer_info_init_left(tb, &bi); 344 buffer_info_init_left(tb, &bi);
351 leaf_insert_into_buf(&bi, 345 leaf_insert_into_buf(&bi,
352 n + item_pos - 346 n + item_pos - ret_val, ih, body,
353 ret_val, ih, body, 347 zeros_num > ih_item_len(ih) ? ih_item_len(ih) : zeros_num);
354 zeros_num >
355 ih_item_len(ih) ?
356 ih_item_len(ih) :
357 zeros_num);
358 348
359 version = ih_version(ih); 349 version = ih_version(ih);
360 350
361 /* Calculate key component, item length and body to insert into S[0] */ 351 /* Calculate key component, item length and body to insert into S[0] */
362 set_le_ih_k_offset(ih, 352 set_le_ih_k_offset(ih, le_ih_k_offset(ih) +
363 le_ih_k_offset(ih) + 353 (tb-> lbytes << (is_indirect_le_ih(ih) ? tb->tb_sb-> s_blocksize_bits - UNFM_P_SHIFT : 0)));
364 (tb->
365 lbytes <<
366 (is_indirect_le_ih
367 (ih) ? tb->tb_sb->
368 s_blocksize_bits -
369 UNFM_P_SHIFT :
370 0)));
371 354
372 put_ih_item_len(ih, new_item_len); 355 put_ih_item_len(ih, new_item_len);
373 if (tb->lbytes > zeros_num) { 356 if (tb->lbytes > zeros_num) {
374 body += 357 body += (tb->lbytes - zeros_num);
375 (tb->lbytes - zeros_num);
376 zeros_num = 0; 358 zeros_num = 0;
377 } else 359 } else
378 zeros_num -= tb->lbytes; 360 zeros_num -= tb->lbytes;
@@ -383,15 +365,10 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h
383 } else { 365 } else {
384 /* new item in whole falls into L[0] */ 366 /* new item in whole falls into L[0] */
385 /* Shift lnum[0]-1 items to L[0] */ 367 /* Shift lnum[0]-1 items to L[0] */
386 ret_val = 368 ret_val = leaf_shift_left(tb, tb->lnum[0] - 1, tb->lbytes);
387 leaf_shift_left(tb, tb->lnum[0] - 1,
388 tb->lbytes);
389 /* Insert new item into L[0] */ 369 /* Insert new item into L[0] */
390 buffer_info_init_left(tb, &bi); 370 buffer_info_init_left(tb, &bi);
391 leaf_insert_into_buf(&bi, 371 leaf_insert_into_buf(&bi, n + item_pos - ret_val, ih, body, zeros_num);
392 n + item_pos -
393 ret_val, ih, body,
394 zeros_num);
395 tb->insert_size[0] = 0; 372 tb->insert_size[0] = 0;
396 zeros_num = 0; 373 zeros_num = 0;
397 } 374 }
@@ -399,264 +376,117 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h
399 376
400 case M_PASTE: /* append item in L[0] */ 377 case M_PASTE: /* append item in L[0] */
401 378
402 if (item_pos == tb->lnum[0] - 1 379 if (item_pos == tb->lnum[0] - 1 && tb->lbytes != -1) {
403 && tb->lbytes != -1) {
404 /* we must shift the part of the appended item */ 380 /* we must shift the part of the appended item */
405 if (is_direntry_le_ih 381 if (is_direntry_le_ih(B_N_PITEM_HEAD(tbS0, item_pos))) {
406 (B_N_PITEM_HEAD(tbS0, item_pos))) {
407 382
408 RFALSE(zeros_num, 383 RFALSE(zeros_num,
409 "PAP-12090: invalid parameter in case of a directory"); 384 "PAP-12090: invalid parameter in case of a directory");
410 /* directory item */ 385 /* directory item */
411 if (tb->lbytes > pos_in_item) { 386 if (tb->lbytes > pos_in_item) {
412 /* new directory entry falls into L[0] */ 387 /* new directory entry falls into L[0] */
413 struct item_head 388 struct item_head *pasted;
414 *pasted; 389 int l_pos_in_item = pos_in_item;
415 int l_pos_in_item =
416 pos_in_item;
417 390
418 /* Shift lnum[0] - 1 items in whole. Shift lbytes - 1 entries from given directory item */ 391 /* Shift lnum[0] - 1 items in whole. Shift lbytes - 1 entries from given directory item */
419 ret_val = 392 ret_val = leaf_shift_left(tb, tb->lnum[0], tb->lbytes-1);
420 leaf_shift_left(tb, 393 if (ret_val && !item_pos) {
421 tb-> 394 pasted = B_N_PITEM_HEAD(tb->L[0], B_NR_ITEMS(tb->L[0]) - 1);
422 lnum 395 l_pos_in_item += I_ENTRY_COUNT(pasted) - (tb->lbytes -1);
423 [0],
424 tb->
425 lbytes
426 -
427 1);
428 if (ret_val
429 && !item_pos) {
430 pasted =
431 B_N_PITEM_HEAD
432 (tb->L[0],
433 B_NR_ITEMS
434 (tb->
435 L[0]) -
436 1);
437 l_pos_in_item +=
438 I_ENTRY_COUNT
439 (pasted) -
440 (tb->
441 lbytes -
442 1);
443 } 396 }
444 397
445 /* Append given directory entry to directory item */ 398 /* Append given directory entry to directory item */
446 buffer_info_init_left(tb, &bi); 399 buffer_info_init_left(tb, &bi);
447 leaf_paste_in_buffer 400 leaf_paste_in_buffer(&bi, n + item_pos - ret_val, l_pos_in_item, tb->insert_size[0], body, zeros_num);
448 (&bi,
449 n + item_pos -
450 ret_val,
451 l_pos_in_item,
452 tb->insert_size[0],
453 body, zeros_num);
454 401
455 /* previous string prepared space for pasting new entry, following string pastes this entry */ 402 /* previous string prepared space for pasting new entry, following string pastes this entry */
456 403
457 /* when we have merge directory item, pos_in_item has been changed too */ 404 /* when we have merge directory item, pos_in_item has been changed too */
458 405
459 /* paste new directory entry. 1 is entry number */ 406 /* paste new directory entry. 1 is entry number */
460 leaf_paste_entries(&bi, 407 leaf_paste_entries(&bi, n + item_pos - ret_val, l_pos_in_item,
461 n + 408 1, (struct reiserfs_de_head *) body,
462 item_pos 409 body + DEH_SIZE, tb->insert_size[0]);
463 -
464 ret_val,
465 l_pos_in_item,
466 1,
467 (struct
468 reiserfs_de_head
469 *)
470 body,
471 body
472 +
473 DEH_SIZE,
474 tb->
475 insert_size
476 [0]
477 );
478 tb->insert_size[0] = 0; 410 tb->insert_size[0] = 0;
479 } else { 411 } else {
480 /* new directory item doesn't fall into L[0] */ 412 /* new directory item doesn't fall into L[0] */
481 /* Shift lnum[0]-1 items in whole. Shift lbytes directory entries from directory item number lnum[0] */ 413 /* Shift lnum[0]-1 items in whole. Shift lbytes directory entries from directory item number lnum[0] */
482 leaf_shift_left(tb, 414 leaf_shift_left(tb, tb->lnum[0], tb->lbytes);
483 tb->
484 lnum[0],
485 tb->
486 lbytes);
487 } 415 }
488 /* Calculate new position to append in item body */ 416 /* Calculate new position to append in item body */
489 pos_in_item -= tb->lbytes; 417 pos_in_item -= tb->lbytes;
490 } else { 418 } else {
491 /* regular object */ 419 /* regular object */
492 RFALSE(tb->lbytes <= 0, 420 RFALSE(tb->lbytes <= 0, "PAP-12095: there is nothing to shift to L[0]. lbytes=%d", tb->lbytes);
493 "PAP-12095: there is nothing to shift to L[0]. lbytes=%d", 421 RFALSE(pos_in_item != ih_item_len(B_N_PITEM_HEAD(tbS0, item_pos)),
494 tb->lbytes);
495 RFALSE(pos_in_item !=
496 ih_item_len
497 (B_N_PITEM_HEAD
498 (tbS0, item_pos)),
499 "PAP-12100: incorrect position to paste: item_len=%d, pos_in_item=%d", 422 "PAP-12100: incorrect position to paste: item_len=%d, pos_in_item=%d",
500 ih_item_len 423 ih_item_len(B_N_PITEM_HEAD(tbS0, item_pos)),pos_in_item);
501 (B_N_PITEM_HEAD
502 (tbS0, item_pos)),
503 pos_in_item);
504 424
505 if (tb->lbytes >= pos_in_item) { 425 if (tb->lbytes >= pos_in_item) {
506 /* appended item will be in L[0] in whole */ 426 /* appended item will be in L[0] in whole */
507 int l_n; 427 int l_n;
508 428
509 /* this bytes number must be appended to the last item of L[h] */ 429 /* this bytes number must be appended to the last item of L[h] */
510 l_n = 430 l_n = tb->lbytes - pos_in_item;
511 tb->lbytes -
512 pos_in_item;
513 431
514 /* Calculate new insert_size[0] */ 432 /* Calculate new insert_size[0] */
515 tb->insert_size[0] -= 433 tb->insert_size[0] -= l_n;
516 l_n;
517 434
518 RFALSE(tb-> 435 RFALSE(tb->insert_size[0] <= 0,
519 insert_size[0] <=
520 0,
521 "PAP-12105: there is nothing to paste into L[0]. insert_size=%d", 436 "PAP-12105: there is nothing to paste into L[0]. insert_size=%d",
522 tb-> 437 tb->insert_size[0]);
523 insert_size[0]); 438 ret_val = leaf_shift_left(tb, tb->lnum[0], ih_item_len
524 ret_val = 439 (B_N_PITEM_HEAD(tbS0, item_pos)));
525 leaf_shift_left(tb,
526 tb->
527 lnum
528 [0],
529 ih_item_len
530 (B_N_PITEM_HEAD
531 (tbS0,
532 item_pos)));
533 /* Append to body of item in L[0] */ 440 /* Append to body of item in L[0] */
534 buffer_info_init_left(tb, &bi); 441 buffer_info_init_left(tb, &bi);
535 leaf_paste_in_buffer 442 leaf_paste_in_buffer
536 (&bi, 443 (&bi, n + item_pos - ret_val, ih_item_len
537 n + item_pos - 444 (B_N_PITEM_HEAD(tb->L[0], n + item_pos - ret_val)),
538 ret_val, 445 l_n, body,
539 ih_item_len 446 zeros_num > l_n ? l_n : zeros_num);
540 (B_N_PITEM_HEAD
541 (tb->L[0],
542 n + item_pos -
543 ret_val)), l_n,
544 body,
545 zeros_num >
546 l_n ? l_n :
547 zeros_num);
548 /* 0-th item in S0 can be only of DIRECT type when l_n != 0 */ 447 /* 0-th item in S0 can be only of DIRECT type when l_n != 0 */
549 { 448 {
550 int version; 449 int version;
551 int temp_l = 450 int temp_l = l_n;
552 l_n; 451
553 452 RFALSE(ih_item_len(B_N_PITEM_HEAD(tbS0, 0)),
554 RFALSE
555 (ih_item_len
556 (B_N_PITEM_HEAD
557 (tbS0,
558 0)),
559 "PAP-12106: item length must be 0"); 453 "PAP-12106: item length must be 0");
560 RFALSE 454 RFALSE(comp_short_le_keys(B_N_PKEY(tbS0, 0), B_N_PKEY
561 (comp_short_le_keys 455 (tb->L[0], n + item_pos - ret_val)),
562 (B_N_PKEY
563 (tbS0, 0),
564 B_N_PKEY
565 (tb->L[0],
566 n +
567 item_pos
568 -
569 ret_val)),
570 "PAP-12107: items must be of the same file"); 456 "PAP-12107: items must be of the same file");
571 if (is_indirect_le_ih(B_N_PITEM_HEAD(tb->L[0], n + item_pos - ret_val))) { 457 if (is_indirect_le_ih(B_N_PITEM_HEAD(tb->L[0], n + item_pos - ret_val))) {
572 temp_l = 458 temp_l = l_n << (tb->tb_sb-> s_blocksize_bits - UNFM_P_SHIFT);
573 l_n
574 <<
575 (tb->
576 tb_sb->
577 s_blocksize_bits
578 -
579 UNFM_P_SHIFT);
580 } 459 }
581 /* update key of first item in S0 */ 460 /* update key of first item in S0 */
582 version = 461 version = ih_version(B_N_PITEM_HEAD(tbS0, 0));
583 ih_version 462 set_le_key_k_offset(version, B_N_PKEY(tbS0, 0),
584 (B_N_PITEM_HEAD 463 le_key_k_offset(version,B_N_PKEY(tbS0, 0)) + temp_l);
585 (tbS0, 0));
586 set_le_key_k_offset
587 (version,
588 B_N_PKEY
589 (tbS0, 0),
590 le_key_k_offset
591 (version,
592 B_N_PKEY
593 (tbS0,
594 0)) +
595 temp_l);
596 /* update left delimiting key */ 464 /* update left delimiting key */
597 set_le_key_k_offset 465 set_le_key_k_offset(version, B_N_PDELIM_KEY(tb->CFL[0], tb->lkey[0]),
598 (version, 466 le_key_k_offset(version, B_N_PDELIM_KEY(tb->CFL[0], tb->lkey[0])) + temp_l);
599 B_N_PDELIM_KEY
600 (tb->
601 CFL[0],
602 tb->
603 lkey[0]),
604 le_key_k_offset
605 (version,
606 B_N_PDELIM_KEY
607 (tb->
608 CFL[0],
609 tb->
610 lkey[0]))
611 + temp_l);
612 } 467 }
613 468
614 /* Calculate new body, position in item and insert_size[0] */ 469 /* Calculate new body, position in item and insert_size[0] */
615 if (l_n > zeros_num) { 470 if (l_n > zeros_num) {
616 body += 471 body += (l_n - zeros_num);
617 (l_n -
618 zeros_num);
619 zeros_num = 0; 472 zeros_num = 0;
620 } else 473 } else
621 zeros_num -= 474 zeros_num -= l_n;
622 l_n;
623 pos_in_item = 0; 475 pos_in_item = 0;
624 476
625 RFALSE 477 RFALSE(comp_short_le_keys(B_N_PKEY(tbS0, 0), B_N_PKEY(tb->L[0], B_NR_ITEMS(tb->L[0]) - 1))
626 (comp_short_le_keys 478 || !op_is_left_mergeable(B_N_PKEY(tbS0, 0), tbS0->b_size)
627 (B_N_PKEY(tbS0, 0), 479 || !op_is_left_mergeable(B_N_PDELIM_KEY(tb->CFL[0], tb->lkey[0]), tbS0->b_size),
628 B_N_PKEY(tb->L[0],
629 B_NR_ITEMS
630 (tb->
631 L[0]) -
632 1))
633 ||
634 !op_is_left_mergeable
635 (B_N_PKEY(tbS0, 0),
636 tbS0->b_size)
637 ||
638 !op_is_left_mergeable
639 (B_N_PDELIM_KEY
640 (tb->CFL[0],
641 tb->lkey[0]),
642 tbS0->b_size),
643 "PAP-12120: item must be merge-able with left neighboring item"); 480 "PAP-12120: item must be merge-able with left neighboring item");
644 } else { /* only part of the appended item will be in L[0] */ 481 } else { /* only part of the appended item will be in L[0] */
645 482
646 /* Calculate position in item for append in S[0] */ 483 /* Calculate position in item for append in S[0] */
647 pos_in_item -= 484 pos_in_item -= tb->lbytes;
648 tb->lbytes;
649 485
650 RFALSE(pos_in_item <= 0, 486 RFALSE(pos_in_item <= 0, "PAP-12125: no place for paste. pos_in_item=%d", pos_in_item);
651 "PAP-12125: no place for paste. pos_in_item=%d",
652 pos_in_item);
653 487
654 /* Shift lnum[0] - 1 items in whole. Shift lbytes - 1 byte from item number lnum[0] */ 488 /* Shift lnum[0] - 1 items in whole. Shift lbytes - 1 byte from item number lnum[0] */
655 leaf_shift_left(tb, 489 leaf_shift_left(tb, tb->lnum[0], tb->lbytes);
656 tb->
657 lnum[0],
658 tb->
659 lbytes);
660 } 490 }
661 } 491 }
662 } else { /* appended item will be in L[0] in whole */ 492 } else { /* appended item will be in L[0] in whole */
@@ -665,52 +495,30 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h
665 495
666 if (!item_pos && op_is_left_mergeable(B_N_PKEY(tbS0, 0), tbS0->b_size)) { /* if we paste into first item of S[0] and it is left mergable */ 496 if (!item_pos && op_is_left_mergeable(B_N_PKEY(tbS0, 0), tbS0->b_size)) { /* if we paste into first item of S[0] and it is left mergable */
667 /* then increment pos_in_item by the size of the last item in L[0] */ 497 /* then increment pos_in_item by the size of the last item in L[0] */
668 pasted = 498 pasted = B_N_PITEM_HEAD(tb->L[0], n - 1);
669 B_N_PITEM_HEAD(tb->L[0],
670 n - 1);
671 if (is_direntry_le_ih(pasted)) 499 if (is_direntry_le_ih(pasted))
672 pos_in_item += 500 pos_in_item += ih_entry_count(pasted);
673 ih_entry_count
674 (pasted);
675 else 501 else
676 pos_in_item += 502 pos_in_item += ih_item_len(pasted);
677 ih_item_len(pasted);
678 } 503 }
679 504
680 /* Shift lnum[0] - 1 items in whole. Shift lbytes - 1 byte from item number lnum[0] */ 505 /* Shift lnum[0] - 1 items in whole. Shift lbytes - 1 byte from item number lnum[0] */
681 ret_val = 506 ret_val = leaf_shift_left(tb, tb->lnum[0], tb->lbytes);
682 leaf_shift_left(tb, tb->lnum[0],
683 tb->lbytes);
684 /* Append to body of item in L[0] */ 507 /* Append to body of item in L[0] */
685 buffer_info_init_left(tb, &bi); 508 buffer_info_init_left(tb, &bi);
686 leaf_paste_in_buffer(&bi, 509 leaf_paste_in_buffer(&bi, n + item_pos - ret_val,
687 n + item_pos -
688 ret_val,
689 pos_in_item, 510 pos_in_item,
690 tb->insert_size[0], 511 tb->insert_size[0],
691 body, zeros_num); 512 body, zeros_num);
692 513
693 /* if appended item is directory, paste entry */ 514 /* if appended item is directory, paste entry */
694 pasted = 515 pasted = B_N_PITEM_HEAD(tb->L[0], n + item_pos - ret_val);
695 B_N_PITEM_HEAD(tb->L[0],
696 n + item_pos -
697 ret_val);
698 if (is_direntry_le_ih(pasted)) 516 if (is_direntry_le_ih(pasted))
699 leaf_paste_entries(&bi, 517 leaf_paste_entries(&bi, n + item_pos - ret_val,
700 n + 518 pos_in_item, 1,
701 item_pos - 519 (struct reiserfs_de_head *) body,
702 ret_val, 520 body + DEH_SIZE,
703 pos_in_item, 521 tb->insert_size[0]);
704 1,
705 (struct
706 reiserfs_de_head
707 *)body,
708 body +
709 DEH_SIZE,
710 tb->
711 insert_size
712 [0]
713 );
714 /* if appended item is indirect item, put unformatted node into un list */ 522 /* if appended item is indirect item, put unformatted node into un list */
715 if (is_indirect_le_ih(pasted)) 523 if (is_indirect_le_ih(pasted))
716 set_ih_free_space(pasted, 0); 524 set_ih_free_space(pasted, 0);
@@ -722,13 +530,7 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h
722 reiserfs_panic(tb->tb_sb, "PAP-12130", 530 reiserfs_panic(tb->tb_sb, "PAP-12130",
723 "lnum > 0: unexpected mode: " 531 "lnum > 0: unexpected mode: "
724 " %s(%d)", 532 " %s(%d)",
725 (flag == 533 (flag == M_DELETE) ? "DELETE" : ((flag == M_CUT) ? "CUT" : "UNKNOWN"), flag);
726 M_DELETE) ? "DELETE" : ((flag ==
727 M_CUT)
728 ? "CUT"
729 :
730 "UNKNOWN"),
731 flag);
732 } 534 }
733 } else { 535 } else {
734 /* new item doesn't fall into L[0] */ 536 /* new item doesn't fall into L[0] */
@@ -748,14 +550,12 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h
748 case M_INSERT: /* insert item */ 550 case M_INSERT: /* insert item */
749 if (n - tb->rnum[0] < item_pos) { /* new item or its part falls to R[0] */ 551 if (n - tb->rnum[0] < item_pos) { /* new item or its part falls to R[0] */
750 if (item_pos == n - tb->rnum[0] + 1 && tb->rbytes != -1) { /* part of new item falls into R[0] */ 552 if (item_pos == n - tb->rnum[0] + 1 && tb->rbytes != -1) { /* part of new item falls into R[0] */
751 loff_t old_key_comp, old_len, 553 loff_t old_key_comp, old_len, r_zeros_number;
752 r_zeros_number;
753 const char *r_body; 554 const char *r_body;
754 int version; 555 int version;
755 loff_t offset; 556 loff_t offset;
756 557
757 leaf_shift_right(tb, tb->rnum[0] - 1, 558 leaf_shift_right(tb, tb->rnum[0] - 1, -1);
758 -1);
759 559
760 version = ih_version(ih); 560 version = ih_version(ih);
761 /* Remember key component and item length */ 561 /* Remember key component and item length */
@@ -763,29 +563,17 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h
763 old_len = ih_item_len(ih); 563 old_len = ih_item_len(ih);
764 564
765 /* Calculate key component and item length to insert into R[0] */ 565 /* Calculate key component and item length to insert into R[0] */
766 offset = 566 offset = le_ih_k_offset(ih) + ((old_len - tb->rbytes) << (is_indirect_le_ih(ih) ? tb->tb_sb->s_blocksize_bits - UNFM_P_SHIFT : 0));
767 le_ih_k_offset(ih) +
768 ((old_len -
769 tb->
770 rbytes) << (is_indirect_le_ih(ih)
771 ? tb->tb_sb->
772 s_blocksize_bits -
773 UNFM_P_SHIFT : 0));
774 set_le_ih_k_offset(ih, offset); 567 set_le_ih_k_offset(ih, offset);
775 put_ih_item_len(ih, tb->rbytes); 568 put_ih_item_len(ih, tb->rbytes);
776 /* Insert part of the item into R[0] */ 569 /* Insert part of the item into R[0] */
777 buffer_info_init_right(tb, &bi); 570 buffer_info_init_right(tb, &bi);
778 if ((old_len - tb->rbytes) > zeros_num) { 571 if ((old_len - tb->rbytes) > zeros_num) {
779 r_zeros_number = 0; 572 r_zeros_number = 0;
780 r_body = 573 r_body = body + (old_len - tb->rbytes) - zeros_num;
781 body + (old_len -
782 tb->rbytes) -
783 zeros_num;
784 } else { 574 } else {
785 r_body = body; 575 r_body = body;
786 r_zeros_number = 576 r_zeros_number = zeros_num - (old_len - tb->rbytes);
787 zeros_num - (old_len -
788 tb->rbytes);
789 zeros_num -= r_zeros_number; 577 zeros_num -= r_zeros_number;
790 } 578 }
791 579
@@ -798,25 +586,18 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h
798 586
799 /* Calculate key component and item length to insert into S[0] */ 587 /* Calculate key component and item length to insert into S[0] */
800 set_le_ih_k_offset(ih, old_key_comp); 588 set_le_ih_k_offset(ih, old_key_comp);
801 put_ih_item_len(ih, 589 put_ih_item_len(ih, old_len - tb->rbytes);
802 old_len - tb->rbytes);
803 590
804 tb->insert_size[0] -= tb->rbytes; 591 tb->insert_size[0] -= tb->rbytes;
805 592
806 } else { /* whole new item falls into R[0] */ 593 } else { /* whole new item falls into R[0] */
807 594
808 /* Shift rnum[0]-1 items to R[0] */ 595 /* Shift rnum[0]-1 items to R[0] */
809 ret_val = 596 ret_val = leaf_shift_right(tb, tb->rnum[0] - 1, tb->rbytes);
810 leaf_shift_right(tb,
811 tb->rnum[0] - 1,
812 tb->rbytes);
813 /* Insert new item into R[0] */ 597 /* Insert new item into R[0] */
814 buffer_info_init_right(tb, &bi); 598 buffer_info_init_right(tb, &bi);
815 leaf_insert_into_buf(&bi, 599 leaf_insert_into_buf(&bi, item_pos - n + tb->rnum[0] - 1,
816 item_pos - n + 600 ih, body, zeros_num);
817 tb->rnum[0] - 1,
818 ih, body,
819 zeros_num);
820 601
821 if (item_pos - n + tb->rnum[0] - 1 == 0) { 602 if (item_pos - n + tb->rnum[0] - 1 == 0) {
822 replace_key(tb, tb->CFR[0], 603 replace_key(tb, tb->CFR[0],
@@ -841,200 +622,97 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h
841 622
842 RFALSE(zeros_num, 623 RFALSE(zeros_num,
843 "PAP-12145: invalid parameter in case of a directory"); 624 "PAP-12145: invalid parameter in case of a directory");
844 entry_count = 625 entry_count = I_ENTRY_COUNT(B_N_PITEM_HEAD
845 I_ENTRY_COUNT(B_N_PITEM_HEAD 626 (tbS0, item_pos));
846 (tbS0,
847 item_pos));
848 if (entry_count - tb->rbytes < 627 if (entry_count - tb->rbytes <
849 pos_in_item) 628 pos_in_item)
850 /* new directory entry falls into R[0] */ 629 /* new directory entry falls into R[0] */
851 { 630 {
852 int paste_entry_position; 631 int paste_entry_position;
853 632
854 RFALSE(tb->rbytes - 1 >= 633 RFALSE(tb->rbytes - 1 >= entry_count || !tb-> insert_size[0],
855 entry_count
856 || !tb->
857 insert_size[0],
858 "PAP-12150: no enough of entries to shift to R[0]: rbytes=%d, entry_count=%d", 634 "PAP-12150: no enough of entries to shift to R[0]: rbytes=%d, entry_count=%d",
859 tb->rbytes, 635 tb->rbytes, entry_count);
860 entry_count);
861 /* Shift rnum[0]-1 items in whole. Shift rbytes-1 directory entries from directory item number rnum[0] */ 636 /* Shift rnum[0]-1 items in whole. Shift rbytes-1 directory entries from directory item number rnum[0] */
862 leaf_shift_right(tb, 637 leaf_shift_right(tb, tb->rnum[0], tb->rbytes - 1);
863 tb->
864 rnum
865 [0],
866 tb->
867 rbytes
868 - 1);
869 /* Paste given directory entry to directory item */ 638 /* Paste given directory entry to directory item */
870 paste_entry_position = 639 paste_entry_position = pos_in_item - entry_count + tb->rbytes - 1;
871 pos_in_item -
872 entry_count +
873 tb->rbytes - 1;
874 buffer_info_init_right(tb, &bi); 640 buffer_info_init_right(tb, &bi);
875 leaf_paste_in_buffer 641 leaf_paste_in_buffer(&bi, 0, paste_entry_position, tb->insert_size[0], body, zeros_num);
876 (&bi, 0,
877 paste_entry_position,
878 tb->insert_size[0],
879 body, zeros_num);
880 /* paste entry */ 642 /* paste entry */
881 leaf_paste_entries(&bi, 643 leaf_paste_entries(&bi, 0, paste_entry_position, 1,
882 0, 644 (struct reiserfs_de_head *) body,
883 paste_entry_position, 645 body + DEH_SIZE, tb->insert_size[0]);
884 1, 646
885 (struct 647 if (paste_entry_position == 0) {
886 reiserfs_de_head
887 *)
888 body,
889 body
890 +
891 DEH_SIZE,
892 tb->
893 insert_size
894 [0]
895 );
896
897 if (paste_entry_position
898 == 0) {
899 /* change delimiting keys */ 648 /* change delimiting keys */
900 replace_key(tb, 649 replace_key(tb, tb->CFR[0], tb->rkey[0], tb->R[0],0);
901 tb->
902 CFR
903 [0],
904 tb->
905 rkey
906 [0],
907 tb->
908 R
909 [0],
910 0);
911 } 650 }
912 651
913 tb->insert_size[0] = 0; 652 tb->insert_size[0] = 0;
914 pos_in_item++; 653 pos_in_item++;
915 } else { /* new directory entry doesn't fall into R[0] */ 654 } else { /* new directory entry doesn't fall into R[0] */
916 655
917 leaf_shift_right(tb, 656 leaf_shift_right(tb, tb->rnum[0], tb->rbytes);
918 tb->
919 rnum
920 [0],
921 tb->
922 rbytes);
923 } 657 }
924 } else { /* regular object */ 658 } else { /* regular object */
925 659
926 int n_shift, n_rem, 660 int n_shift, n_rem, r_zeros_number;
927 r_zeros_number;
928 const char *r_body; 661 const char *r_body;
929 662
930 /* Calculate number of bytes which must be shifted from appended item */ 663 /* Calculate number of bytes which must be shifted from appended item */
931 if ((n_shift = 664 if ((n_shift = tb->rbytes - tb->insert_size[0]) < 0)
932 tb->rbytes -
933 tb->insert_size[0]) < 0)
934 n_shift = 0; 665 n_shift = 0;
935 666
936 RFALSE(pos_in_item != 667 RFALSE(pos_in_item != ih_item_len
937 ih_item_len 668 (B_N_PITEM_HEAD(tbS0, item_pos)),
938 (B_N_PITEM_HEAD
939 (tbS0, item_pos)),
940 "PAP-12155: invalid position to paste. ih_item_len=%d, pos_in_item=%d", 669 "PAP-12155: invalid position to paste. ih_item_len=%d, pos_in_item=%d",
941 pos_in_item, 670 pos_in_item, ih_item_len
942 ih_item_len 671 (B_N_PITEM_HEAD(tbS0, item_pos)));
943 (B_N_PITEM_HEAD 672
944 (tbS0, item_pos))); 673 leaf_shift_right(tb, tb->rnum[0], n_shift);
945
946 leaf_shift_right(tb,
947 tb->rnum[0],
948 n_shift);
949 /* Calculate number of bytes which must remain in body after appending to R[0] */ 674 /* Calculate number of bytes which must remain in body after appending to R[0] */
950 if ((n_rem = 675 if ((n_rem = tb->insert_size[0] - tb->rbytes) < 0)
951 tb->insert_size[0] -
952 tb->rbytes) < 0)
953 n_rem = 0; 676 n_rem = 0;
954 677
955 { 678 {
956 int version; 679 int version;
957 unsigned long temp_rem = 680 unsigned long temp_rem = n_rem;
958 n_rem; 681
959 682 version = ih_version(B_N_PITEM_HEAD(tb->R[0], 0));
960 version = 683 if (is_indirect_le_key(version, B_N_PKEY(tb->R[0], 0))) {
961 ih_version 684 temp_rem = n_rem << (tb->tb_sb->s_blocksize_bits - UNFM_P_SHIFT);
962 (B_N_PITEM_HEAD
963 (tb->R[0], 0));
964 if (is_indirect_le_key
965 (version,
966 B_N_PKEY(tb->R[0],
967 0))) {
968 temp_rem =
969 n_rem <<
970 (tb->tb_sb->
971 s_blocksize_bits
972 -
973 UNFM_P_SHIFT);
974 } 685 }
975 set_le_key_k_offset 686 set_le_key_k_offset(version, B_N_PKEY(tb->R[0], 0),
976 (version, 687 le_key_k_offset(version, B_N_PKEY(tb->R[0], 0)) + temp_rem);
977 B_N_PKEY(tb->R[0], 688 set_le_key_k_offset(version, B_N_PDELIM_KEY(tb->CFR[0], tb->rkey[0]),
978 0), 689 le_key_k_offset(version, B_N_PDELIM_KEY(tb->CFR[0], tb->rkey[0])) + temp_rem);
979 le_key_k_offset
980 (version,
981 B_N_PKEY(tb->R[0],
982 0)) +
983 temp_rem);
984 set_le_key_k_offset
985 (version,
986 B_N_PDELIM_KEY(tb->
987 CFR
988 [0],
989 tb->
990 rkey
991 [0]),
992 le_key_k_offset
993 (version,
994 B_N_PDELIM_KEY
995 (tb->CFR[0],
996 tb->rkey[0])) +
997 temp_rem);
998 } 690 }
999/* k_offset (B_N_PKEY(tb->R[0],0)) += n_rem; 691/* k_offset (B_N_PKEY(tb->R[0],0)) += n_rem;
1000 k_offset (B_N_PDELIM_KEY(tb->CFR[0],tb->rkey[0])) += n_rem;*/ 692 k_offset (B_N_PDELIM_KEY(tb->CFR[0],tb->rkey[0])) += n_rem;*/
1001 do_balance_mark_internal_dirty 693 do_balance_mark_internal_dirty(tb, tb->CFR[0], 0);
1002 (tb, tb->CFR[0], 0);
1003 694
1004 /* Append part of body into R[0] */ 695 /* Append part of body into R[0] */
1005 buffer_info_init_right(tb, &bi); 696 buffer_info_init_right(tb, &bi);
1006 if (n_rem > zeros_num) { 697 if (n_rem > zeros_num) {
1007 r_zeros_number = 0; 698 r_zeros_number = 0;
1008 r_body = 699 r_body = body + n_rem - zeros_num;
1009 body + n_rem -
1010 zeros_num;
1011 } else { 700 } else {
1012 r_body = body; 701 r_body = body;
1013 r_zeros_number = 702 r_zeros_number = zeros_num - n_rem;
1014 zeros_num - n_rem; 703 zeros_num -= r_zeros_number;
1015 zeros_num -=
1016 r_zeros_number;
1017 } 704 }
1018 705
1019 leaf_paste_in_buffer(&bi, 0, 706 leaf_paste_in_buffer(&bi, 0, n_shift,
1020 n_shift, 707 tb->insert_size[0] - n_rem,
1021 tb-> 708 r_body, r_zeros_number);
1022 insert_size 709
1023 [0] - 710 if (is_indirect_le_ih(B_N_PITEM_HEAD(tb->R[0], 0))) {
1024 n_rem,
1025 r_body,
1026 r_zeros_number);
1027
1028 if (is_indirect_le_ih
1029 (B_N_PITEM_HEAD
1030 (tb->R[0], 0))) {
1031#if 0 711#if 0
1032 RFALSE(n_rem, 712 RFALSE(n_rem,
1033 "PAP-12160: paste more than one unformatted node pointer"); 713 "PAP-12160: paste more than one unformatted node pointer");
1034#endif 714#endif
1035 set_ih_free_space 715 set_ih_free_space(B_N_PITEM_HEAD(tb->R[0], 0), 0);
1036 (B_N_PITEM_HEAD
1037 (tb->R[0], 0), 0);
1038 } 716 }
1039 tb->insert_size[0] = n_rem; 717 tb->insert_size[0] = n_rem;
1040 if (!n_rem) 718 if (!n_rem)
@@ -1044,58 +722,28 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h
1044 722
1045 struct item_head *pasted; 723 struct item_head *pasted;
1046 724
1047 ret_val = 725 ret_val = leaf_shift_right(tb, tb->rnum[0], tb->rbytes);
1048 leaf_shift_right(tb, tb->rnum[0],
1049 tb->rbytes);
1050 /* append item in R[0] */ 726 /* append item in R[0] */
1051 if (pos_in_item >= 0) { 727 if (pos_in_item >= 0) {
1052 buffer_info_init_right(tb, &bi); 728 buffer_info_init_right(tb, &bi);
1053 leaf_paste_in_buffer(&bi, 729 leaf_paste_in_buffer(&bi, item_pos - n + tb->rnum[0], pos_in_item,
1054 item_pos - 730 tb->insert_size[0], body, zeros_num);
1055 n +
1056 tb->
1057 rnum[0],
1058 pos_in_item,
1059 tb->
1060 insert_size
1061 [0], body,
1062 zeros_num);
1063 } 731 }
1064 732
1065 /* paste new entry, if item is directory item */ 733 /* paste new entry, if item is directory item */
1066 pasted = 734 pasted = B_N_PITEM_HEAD(tb->R[0], item_pos - n + tb->rnum[0]);
1067 B_N_PITEM_HEAD(tb->R[0], 735 if (is_direntry_le_ih(pasted) && pos_in_item >= 0) {
1068 item_pos - n + 736 leaf_paste_entries(&bi, item_pos - n + tb->rnum[0],
1069 tb->rnum[0]); 737 pos_in_item, 1,
1070 if (is_direntry_le_ih(pasted) 738 (struct reiserfs_de_head *) body,
1071 && pos_in_item >= 0) { 739 body + DEH_SIZE, tb->insert_size[0]);
1072 leaf_paste_entries(&bi,
1073 item_pos -
1074 n +
1075 tb->rnum[0],
1076 pos_in_item,
1077 1,
1078 (struct
1079 reiserfs_de_head
1080 *)body,
1081 body +
1082 DEH_SIZE,
1083 tb->
1084 insert_size
1085 [0]
1086 );
1087 if (!pos_in_item) { 740 if (!pos_in_item) {
1088 741
1089 RFALSE(item_pos - n + 742 RFALSE(item_pos - n + tb->rnum[0],
1090 tb->rnum[0],
1091 "PAP-12165: directory item must be first item of node when pasting is in 0th position"); 743 "PAP-12165: directory item must be first item of node when pasting is in 0th position");
1092 744
1093 /* update delimiting keys */ 745 /* update delimiting keys */
1094 replace_key(tb, 746 replace_key(tb, tb->CFR[0], tb->rkey[0], tb->R[0], 0);
1095 tb->CFR[0],
1096 tb->rkey[0],
1097 tb->R[0],
1098 0);
1099 } 747 }
1100 } 748 }
1101 749
@@ -1111,22 +759,16 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h
1111 default: /* cases d and t */ 759 default: /* cases d and t */
1112 reiserfs_panic(tb->tb_sb, "PAP-12175", 760 reiserfs_panic(tb->tb_sb, "PAP-12175",
1113 "rnum > 0: unexpected mode: %s(%d)", 761 "rnum > 0: unexpected mode: %s(%d)",
1114 (flag == 762 (flag == M_DELETE) ? "DELETE" : ((flag == M_CUT) ? "CUT" : "UNKNOWN"), flag);
1115 M_DELETE) ? "DELETE" : ((flag ==
1116 M_CUT) ? "CUT"
1117 : "UNKNOWN"),
1118 flag);
1119 } 763 }
1120 764
1121 } 765 }
1122 766
1123 /* tb->rnum[0] > 0 */ 767 /* tb->rnum[0] > 0 */
1124 RFALSE(tb->blknum[0] > 3, 768 RFALSE(tb->blknum[0] > 3,
1125 "PAP-12180: blknum can not be %d. It must be <= 3", 769 "PAP-12180: blknum can not be %d. It must be <= 3", tb->blknum[0]);
1126 tb->blknum[0]);
1127 RFALSE(tb->blknum[0] < 0, 770 RFALSE(tb->blknum[0] < 0,
1128 "PAP-12185: blknum can not be %d. It must be >= 0", 771 "PAP-12185: blknum can not be %d. It must be >= 0", tb->blknum[0]);
1129 tb->blknum[0]);
1130 772
1131 /* if while adding to a node we discover that it is possible to split 773 /* if while adding to a node we discover that it is possible to split
1132 it in two, and merge the left part into the left neighbor and the 774 it in two, and merge the left part into the left neighbor and the
@@ -1177,8 +819,7 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h
1177 819
1178 if (n - snum[i] < item_pos) { /* new item or it's part falls to first new node S_new[i] */ 820 if (n - snum[i] < item_pos) { /* new item or it's part falls to first new node S_new[i] */
1179 if (item_pos == n - snum[i] + 1 && sbytes[i] != -1) { /* part of new item falls into S_new[i] */ 821 if (item_pos == n - snum[i] + 1 && sbytes[i] != -1) { /* part of new item falls into S_new[i] */
1180 int old_key_comp, old_len, 822 int old_key_comp, old_len, r_zeros_number;
1181 r_zeros_number;
1182 const char *r_body; 823 const char *r_body;
1183 int version; 824 int version;
1184 825
@@ -1192,15 +833,8 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h
1192 old_len = ih_item_len(ih); 833 old_len = ih_item_len(ih);
1193 834
1194 /* Calculate key component and item length to insert into S_new[i] */ 835 /* Calculate key component and item length to insert into S_new[i] */
1195 set_le_ih_k_offset(ih, 836 set_le_ih_k_offset(ih, le_ih_k_offset(ih) +
1196 le_ih_k_offset(ih) + 837 ((old_len - sbytes[i]) << (is_indirect_le_ih(ih) ? tb->tb_sb-> s_blocksize_bits - UNFM_P_SHIFT : 0)));
1197 ((old_len -
1198 sbytes[i]) <<
1199 (is_indirect_le_ih
1200 (ih) ? tb->tb_sb->
1201 s_blocksize_bits -
1202 UNFM_P_SHIFT :
1203 0)));
1204 838
1205 put_ih_item_len(ih, sbytes[i]); 839 put_ih_item_len(ih, sbytes[i]);
1206 840
@@ -1209,39 +843,29 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h
1209 843
1210 if ((old_len - sbytes[i]) > zeros_num) { 844 if ((old_len - sbytes[i]) > zeros_num) {
1211 r_zeros_number = 0; 845 r_zeros_number = 0;
1212 r_body = 846 r_body = body + (old_len - sbytes[i]) - zeros_num;
1213 body + (old_len -
1214 sbytes[i]) -
1215 zeros_num;
1216 } else { 847 } else {
1217 r_body = body; 848 r_body = body;
1218 r_zeros_number = 849 r_zeros_number = zeros_num - (old_len - sbytes[i]);
1219 zeros_num - (old_len -
1220 sbytes[i]);
1221 zeros_num -= r_zeros_number; 850 zeros_num -= r_zeros_number;
1222 } 851 }
1223 852
1224 leaf_insert_into_buf(&bi, 0, ih, r_body, 853 leaf_insert_into_buf(&bi, 0, ih, r_body, r_zeros_number);
1225 r_zeros_number);
1226 854
1227 /* Calculate key component and item length to insert into S[i] */ 855 /* Calculate key component and item length to insert into S[i] */
1228 set_le_ih_k_offset(ih, old_key_comp); 856 set_le_ih_k_offset(ih, old_key_comp);
1229 put_ih_item_len(ih, 857 put_ih_item_len(ih, old_len - sbytes[i]);
1230 old_len - sbytes[i]);
1231 tb->insert_size[0] -= sbytes[i]; 858 tb->insert_size[0] -= sbytes[i];
1232 } else { /* whole new item falls into S_new[i] */ 859 } else { /* whole new item falls into S_new[i] */
1233 860
1234 /* Shift snum[0] - 1 items to S_new[i] (sbytes[i] of split item) */ 861 /* Shift snum[0] - 1 items to S_new[i] (sbytes[i] of split item) */
1235 leaf_move_items(LEAF_FROM_S_TO_SNEW, tb, 862 leaf_move_items(LEAF_FROM_S_TO_SNEW, tb,
1236 snum[i] - 1, sbytes[i], 863 snum[i] - 1, sbytes[i], S_new[i]);
1237 S_new[i]);
1238 864
1239 /* Insert new item into S_new[i] */ 865 /* Insert new item into S_new[i] */
1240 buffer_info_init_bh(tb, &bi, S_new[i]); 866 buffer_info_init_bh(tb, &bi, S_new[i]);
1241 leaf_insert_into_buf(&bi, 867 leaf_insert_into_buf(&bi, item_pos - n + snum[i] - 1,
1242 item_pos - n + 868 ih, body, zeros_num);
1243 snum[i] - 1, ih,
1244 body, zeros_num);
1245 869
1246 zeros_num = tb->insert_size[0] = 0; 870 zeros_num = tb->insert_size[0] = 0;
1247 } 871 }
@@ -1268,150 +892,73 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h
1268 892
1269 int entry_count; 893 int entry_count;
1270 894
1271 entry_count = 895 entry_count = ih_entry_count(aux_ih);
1272 ih_entry_count(aux_ih);
1273 896
1274 if (entry_count - sbytes[i] < 897 if (entry_count - sbytes[i] < pos_in_item && pos_in_item <= entry_count) {
1275 pos_in_item
1276 && pos_in_item <=
1277 entry_count) {
1278 /* new directory entry falls into S_new[i] */ 898 /* new directory entry falls into S_new[i] */
1279 899
1280 RFALSE(!tb-> 900 RFALSE(!tb->insert_size[0], "PAP-12215: insert_size is already 0");
1281 insert_size[0], 901 RFALSE(sbytes[i] - 1 >= entry_count,
1282 "PAP-12215: insert_size is already 0");
1283 RFALSE(sbytes[i] - 1 >=
1284 entry_count,
1285 "PAP-12220: there are no so much entries (%d), only %d", 902 "PAP-12220: there are no so much entries (%d), only %d",
1286 sbytes[i] - 1, 903 sbytes[i] - 1, entry_count);
1287 entry_count);
1288 904
1289 /* Shift snum[i]-1 items in whole. Shift sbytes[i] directory entries from directory item number snum[i] */ 905 /* Shift snum[i]-1 items in whole. Shift sbytes[i] directory entries from directory item number snum[i] */
1290 leaf_move_items 906 leaf_move_items(LEAF_FROM_S_TO_SNEW, tb, snum[i], sbytes[i] - 1, S_new[i]);
1291 (LEAF_FROM_S_TO_SNEW,
1292 tb, snum[i],
1293 sbytes[i] - 1,
1294 S_new[i]);
1295 /* Paste given directory entry to directory item */ 907 /* Paste given directory entry to directory item */
1296 buffer_info_init_bh(tb, &bi, S_new[i]); 908 buffer_info_init_bh(tb, &bi, S_new[i]);
1297 leaf_paste_in_buffer 909 leaf_paste_in_buffer(&bi, 0, pos_in_item - entry_count + sbytes[i] - 1,
1298 (&bi, 0, 910 tb->insert_size[0], body, zeros_num);
1299 pos_in_item -
1300 entry_count +
1301 sbytes[i] - 1,
1302 tb->insert_size[0],
1303 body, zeros_num);
1304 /* paste new directory entry */ 911 /* paste new directory entry */
1305 leaf_paste_entries(&bi, 912 leaf_paste_entries(&bi, 0, pos_in_item - entry_count + sbytes[i] - 1, 1,
1306 0, 913 (struct reiserfs_de_head *) body,
1307 pos_in_item 914 body + DEH_SIZE, tb->insert_size[0]);
1308 -
1309 entry_count
1310 +
1311 sbytes
1312 [i] -
1313 1, 1,
1314 (struct
1315 reiserfs_de_head
1316 *)
1317 body,
1318 body
1319 +
1320 DEH_SIZE,
1321 tb->
1322 insert_size
1323 [0]
1324 );
1325 tb->insert_size[0] = 0; 915 tb->insert_size[0] = 0;
1326 pos_in_item++; 916 pos_in_item++;
1327 } else { /* new directory entry doesn't fall into S_new[i] */ 917 } else { /* new directory entry doesn't fall into S_new[i] */
1328 leaf_move_items 918 leaf_move_items(LEAF_FROM_S_TO_SNEW,tb, snum[i], sbytes[i], S_new[i]);
1329 (LEAF_FROM_S_TO_SNEW,
1330 tb, snum[i],
1331 sbytes[i],
1332 S_new[i]);
1333 } 919 }
1334 } else { /* regular object */ 920 } else { /* regular object */
1335 921
1336 int n_shift, n_rem, 922 int n_shift, n_rem, r_zeros_number;
1337 r_zeros_number;
1338 const char *r_body; 923 const char *r_body;
1339 924
1340 RFALSE(pos_in_item != 925 RFALSE(pos_in_item != ih_item_len(B_N_PITEM_HEAD(tbS0, item_pos)) || tb->insert_size[0] <= 0,
1341 ih_item_len
1342 (B_N_PITEM_HEAD
1343 (tbS0, item_pos))
1344 || tb->insert_size[0] <=
1345 0,
1346 "PAP-12225: item too short or insert_size <= 0"); 926 "PAP-12225: item too short or insert_size <= 0");
1347 927
1348 /* Calculate number of bytes which must be shifted from appended item */ 928 /* Calculate number of bytes which must be shifted from appended item */
1349 n_shift = 929 n_shift = sbytes[i] - tb->insert_size[0];
1350 sbytes[i] -
1351 tb->insert_size[0];
1352 if (n_shift < 0) 930 if (n_shift < 0)
1353 n_shift = 0; 931 n_shift = 0;
1354 leaf_move_items 932 leaf_move_items(LEAF_FROM_S_TO_SNEW, tb, snum[i], n_shift, S_new[i]);
1355 (LEAF_FROM_S_TO_SNEW, tb,
1356 snum[i], n_shift,
1357 S_new[i]);
1358 933
1359 /* Calculate number of bytes which must remain in body after append to S_new[i] */ 934 /* Calculate number of bytes which must remain in body after append to S_new[i] */
1360 n_rem = 935 n_rem = tb->insert_size[0] - sbytes[i];
1361 tb->insert_size[0] -
1362 sbytes[i];
1363 if (n_rem < 0) 936 if (n_rem < 0)
1364 n_rem = 0; 937 n_rem = 0;
1365 /* Append part of body into S_new[0] */ 938 /* Append part of body into S_new[0] */
1366 buffer_info_init_bh(tb, &bi, S_new[i]); 939 buffer_info_init_bh(tb, &bi, S_new[i]);
1367 if (n_rem > zeros_num) { 940 if (n_rem > zeros_num) {
1368 r_zeros_number = 0; 941 r_zeros_number = 0;
1369 r_body = 942 r_body = body + n_rem - zeros_num;
1370 body + n_rem -
1371 zeros_num;
1372 } else { 943 } else {
1373 r_body = body; 944 r_body = body;
1374 r_zeros_number = 945 r_zeros_number = zeros_num - n_rem;
1375 zeros_num - n_rem; 946 zeros_num -= r_zeros_number;
1376 zeros_num -=
1377 r_zeros_number;
1378 } 947 }
1379 948
1380 leaf_paste_in_buffer(&bi, 0, 949 leaf_paste_in_buffer(&bi, 0, n_shift,
1381 n_shift, 950 tb->insert_size[0] - n_rem,
1382 tb-> 951 r_body, r_zeros_number);
1383 insert_size
1384 [0] -
1385 n_rem,
1386 r_body,
1387 r_zeros_number);
1388 { 952 {
1389 struct item_head *tmp; 953 struct item_head *tmp;
1390 954
1391 tmp = 955 tmp = B_N_PITEM_HEAD(S_new[i], 0);
1392 B_N_PITEM_HEAD(S_new
1393 [i],
1394 0);
1395 if (is_indirect_le_ih 956 if (is_indirect_le_ih
1396 (tmp)) { 957 (tmp)) {
1397 set_ih_free_space 958 set_ih_free_space(tmp, 0);
1398 (tmp, 0); 959 set_le_ih_k_offset(tmp, le_ih_k_offset(tmp) + (n_rem << (tb->tb_sb->s_blocksize_bits - UNFM_P_SHIFT)));
1399 set_le_ih_k_offset
1400 (tmp,
1401 le_ih_k_offset
1402 (tmp) +
1403 (n_rem <<
1404 (tb->
1405 tb_sb->
1406 s_blocksize_bits
1407 -
1408 UNFM_P_SHIFT)));
1409 } else { 960 } else {
1410 set_le_ih_k_offset 961 set_le_ih_k_offset(tmp, le_ih_k_offset(tmp) + n_rem);
1411 (tmp,
1412 le_ih_k_offset
1413 (tmp) +
1414 n_rem);
1415 } 962 }
1416 } 963 }
1417 964
@@ -1426,8 +973,7 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h
1426 struct item_head *pasted; 973 struct item_head *pasted;
1427 974
1428#ifdef CONFIG_REISERFS_CHECK 975#ifdef CONFIG_REISERFS_CHECK
1429 struct item_head *ih_check = 976 struct item_head *ih_check = B_N_PITEM_HEAD(tbS0, item_pos);
1430 B_N_PITEM_HEAD(tbS0, item_pos);
1431 977
1432 if (!is_direntry_le_ih(ih_check) 978 if (!is_direntry_le_ih(ih_check)
1433 && (pos_in_item != ih_item_len(ih_check) 979 && (pos_in_item != ih_item_len(ih_check)
@@ -1439,8 +985,7 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h
1439 "to ih_item_len"); 985 "to ih_item_len");
1440#endif /* CONFIG_REISERFS_CHECK */ 986#endif /* CONFIG_REISERFS_CHECK */
1441 987
1442 leaf_mi = 988 leaf_mi = leaf_move_items(LEAF_FROM_S_TO_SNEW,
1443 leaf_move_items(LEAF_FROM_S_TO_SNEW,
1444 tb, snum[i], 989 tb, snum[i],
1445 sbytes[i], 990 sbytes[i],
1446 S_new[i]); 991 S_new[i]);
@@ -1452,30 +997,19 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h
1452 /* paste into item */ 997 /* paste into item */
1453 buffer_info_init_bh(tb, &bi, S_new[i]); 998 buffer_info_init_bh(tb, &bi, S_new[i]);
1454 leaf_paste_in_buffer(&bi, 999 leaf_paste_in_buffer(&bi,
1455 item_pos - n + 1000 item_pos - n + snum[i],
1456 snum[i],
1457 pos_in_item, 1001 pos_in_item,
1458 tb->insert_size[0], 1002 tb->insert_size[0],
1459 body, zeros_num); 1003 body, zeros_num);
1460 1004
1461 pasted = 1005 pasted = B_N_PITEM_HEAD(S_new[i], item_pos - n + snum[i]);
1462 B_N_PITEM_HEAD(S_new[i],
1463 item_pos - n +
1464 snum[i]);
1465 if (is_direntry_le_ih(pasted)) { 1006 if (is_direntry_le_ih(pasted)) {
1466 leaf_paste_entries(&bi, 1007 leaf_paste_entries(&bi,
1467 item_pos - 1008 item_pos - n + snum[i],
1468 n + snum[i], 1009 pos_in_item, 1,
1469 pos_in_item, 1010 (struct reiserfs_de_head *)body,
1470 1, 1011 body + DEH_SIZE,
1471 (struct 1012 tb->insert_size[0]
1472 reiserfs_de_head
1473 *)body,
1474 body +
1475 DEH_SIZE,
1476 tb->
1477 insert_size
1478 [0]
1479 ); 1013 );
1480 } 1014 }
1481 1015
@@ -1495,11 +1029,7 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h
1495 default: /* cases d and t */ 1029 default: /* cases d and t */
1496 reiserfs_panic(tb->tb_sb, "PAP-12245", 1030 reiserfs_panic(tb->tb_sb, "PAP-12245",
1497 "blknum > 2: unexpected mode: %s(%d)", 1031 "blknum > 2: unexpected mode: %s(%d)",
1498 (flag == 1032 (flag == M_DELETE) ? "DELETE" : ((flag == M_CUT) ? "CUT" : "UNKNOWN"), flag);
1499 M_DELETE) ? "DELETE" : ((flag ==
1500 M_CUT) ? "CUT"
1501 : "UNKNOWN"),
1502 flag);
1503 } 1033 }
1504 1034
1505 memcpy(insert_key + i, B_N_PKEY(S_new[i], 0), KEY_SIZE); 1035 memcpy(insert_key + i, B_N_PKEY(S_new[i], 0), KEY_SIZE);
@@ -1524,9 +1054,7 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h
1524 /* If we insert the first key change the delimiting key */ 1054 /* If we insert the first key change the delimiting key */
1525 if (item_pos == 0) { 1055 if (item_pos == 0) {
1526 if (tb->CFL[0]) /* can be 0 in reiserfsck */ 1056 if (tb->CFL[0]) /* can be 0 in reiserfsck */
1527 replace_key(tb, tb->CFL[0], tb->lkey[0], 1057 replace_key(tb, tb->CFL[0], tb->lkey[0], tbS0, 0);
1528 tbS0, 0);
1529
1530 } 1058 }
1531 break; 1059 break;
1532 1060
@@ -1536,53 +1064,27 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h
1536 pasted = B_N_PITEM_HEAD(tbS0, item_pos); 1064 pasted = B_N_PITEM_HEAD(tbS0, item_pos);
1537 /* when directory, may be new entry already pasted */ 1065 /* when directory, may be new entry already pasted */
1538 if (is_direntry_le_ih(pasted)) { 1066 if (is_direntry_le_ih(pasted)) {
1539 if (pos_in_item >= 0 && 1067 if (pos_in_item >= 0 && pos_in_item <= ih_entry_count(pasted)) {
1540 pos_in_item <=
1541 ih_entry_count(pasted)) {
1542 1068
1543 RFALSE(!tb->insert_size[0], 1069 RFALSE(!tb->insert_size[0],
1544 "PAP-12260: insert_size is 0 already"); 1070 "PAP-12260: insert_size is 0 already");
1545 1071
1546 /* prepare space */ 1072 /* prepare space */
1547 buffer_info_init_tbS0(tb, &bi); 1073 buffer_info_init_tbS0(tb, &bi);
1548 leaf_paste_in_buffer(&bi, 1074 leaf_paste_in_buffer(&bi, item_pos, pos_in_item,
1549 item_pos, 1075 tb->insert_size[0], body,
1550 pos_in_item,
1551 tb->
1552 insert_size
1553 [0], body,
1554 zeros_num); 1076 zeros_num);
1555 1077
1556 /* paste entry */ 1078 /* paste entry */
1557 leaf_paste_entries(&bi, 1079 leaf_paste_entries(&bi, item_pos, pos_in_item, 1,
1558 item_pos, 1080 (struct reiserfs_de_head *)body,
1559 pos_in_item, 1081 body + DEH_SIZE,
1560 1, 1082 tb->insert_size[0]);
1561 (struct
1562 reiserfs_de_head
1563 *)body,
1564 body +
1565 DEH_SIZE,
1566 tb->
1567 insert_size
1568 [0]
1569 );
1570 if (!item_pos && !pos_in_item) { 1083 if (!item_pos && !pos_in_item) {
1571 RFALSE(!tb->CFL[0] 1084 RFALSE(!tb->CFL[0] || !tb->L[0],
1572 || !tb->L[0],
1573 "PAP-12270: CFL[0]/L[0] must be specified"); 1085 "PAP-12270: CFL[0]/L[0] must be specified");
1574 if (tb->CFL[0]) { 1086 if (tb->CFL[0])
1575 replace_key(tb, 1087 replace_key(tb, tb->CFL[0], tb->lkey[0], tbS0, 0);
1576 tb->
1577 CFL
1578 [0],
1579 tb->
1580 lkey
1581 [0],
1582 tbS0,
1583 0);
1584
1585 }
1586 } 1088 }
1587 tb->insert_size[0] = 0; 1089 tb->insert_size[0] = 0;
1588 } 1090 }
@@ -1593,13 +1095,8 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h
1593 "PAP-12275: insert size must not be %d", 1095 "PAP-12275: insert size must not be %d",
1594 tb->insert_size[0]); 1096 tb->insert_size[0]);
1595 buffer_info_init_tbS0(tb, &bi); 1097 buffer_info_init_tbS0(tb, &bi);
1596 leaf_paste_in_buffer(&bi, 1098 leaf_paste_in_buffer(&bi, item_pos, pos_in_item,
1597 item_pos, 1099 tb->insert_size[0], body, zeros_num);
1598 pos_in_item,
1599 tb->
1600 insert_size
1601 [0], body,
1602 zeros_num);
1603 1100
1604 if (is_indirect_le_ih(pasted)) { 1101 if (is_indirect_le_ih(pasted)) {
1605#if 0 1102#if 0
@@ -1611,8 +1108,7 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h
1611 tb-> 1108 tb->
1612 insert_size[0]); 1109 insert_size[0]);
1613#endif 1110#endif
1614 set_ih_free_space 1111 set_ih_free_space(pasted, 0);
1615 (pasted, 0);
1616 } 1112 }
1617 tb->insert_size[0] = 0; 1113 tb->insert_size[0] = 0;
1618 } 1114 }
@@ -1620,8 +1116,7 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih, /* item h
1620 else { 1116 else {
1621 if (tb->insert_size[0]) { 1117 if (tb->insert_size[0]) {
1622 print_cur_tb("12285"); 1118 print_cur_tb("12285");
1623 reiserfs_panic(tb-> 1119 reiserfs_panic(tb->tb_sb,
1624 tb_sb,
1625 "PAP-12285", 1120 "PAP-12285",
1626 "insert_size " 1121 "insert_size "
1627 "must be 0 " 1122 "must be 0 "
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/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
index 8e4f41d9af4d..34c7bdc06014 100644
--- a/include/asm-generic/pgtable.h
+++ b/include/asm-generic/pgtable.h
@@ -701,6 +701,18 @@ static inline pte_t pte_mknuma(pte_t pte)
701} 701}
702#endif 702#endif
703 703
704#ifndef ptep_set_numa
705static inline void ptep_set_numa(struct mm_struct *mm, unsigned long addr,
706 pte_t *ptep)
707{
708 pte_t ptent = *ptep;
709
710 ptent = pte_mknuma(ptent);
711 set_pte_at(mm, addr, ptep, ptent);
712 return;
713}
714#endif
715
704#ifndef pmd_mknuma 716#ifndef pmd_mknuma
705static inline pmd_t pmd_mknuma(pmd_t pmd) 717static inline pmd_t pmd_mknuma(pmd_t pmd)
706{ 718{
@@ -708,6 +720,18 @@ static inline pmd_t pmd_mknuma(pmd_t pmd)
708 return pmd_clear_flags(pmd, _PAGE_PRESENT); 720 return pmd_clear_flags(pmd, _PAGE_PRESENT);
709} 721}
710#endif 722#endif
723
724#ifndef pmdp_set_numa
725static inline void pmdp_set_numa(struct mm_struct *mm, unsigned long addr,
726 pmd_t *pmdp)
727{
728 pmd_t pmd = *pmdp;
729
730 pmd = pmd_mknuma(pmd);
731 set_pmd_at(mm, addr, pmdp, pmd);
732 return;
733}
734#endif
711#else 735#else
712extern int pte_numa(pte_t pte); 736extern int pte_numa(pte_t pte);
713extern int pmd_numa(pmd_t pmd); 737extern int pmd_numa(pmd_t pmd);
@@ -715,6 +739,8 @@ extern pte_t pte_mknonnuma(pte_t pte);
715extern pmd_t pmd_mknonnuma(pmd_t pmd); 739extern pmd_t pmd_mknonnuma(pmd_t pmd);
716extern pte_t pte_mknuma(pte_t pte); 740extern pte_t pte_mknuma(pte_t pte);
717extern pmd_t pmd_mknuma(pmd_t pmd); 741extern pmd_t pmd_mknuma(pmd_t pmd);
742extern void ptep_set_numa(struct mm_struct *mm, unsigned long addr, pte_t *ptep);
743extern void pmdp_set_numa(struct mm_struct *mm, unsigned long addr, pmd_t *pmdp);
718#endif /* CONFIG_ARCH_USES_NUMA_PROT_NONE */ 744#endif /* CONFIG_ARCH_USES_NUMA_PROT_NONE */
719#else 745#else
720static inline int pmd_numa(pmd_t pmd) 746static inline int pmd_numa(pmd_t pmd)
@@ -742,10 +768,23 @@ static inline pte_t pte_mknuma(pte_t pte)
742 return pte; 768 return pte;
743} 769}
744 770
771static inline void ptep_set_numa(struct mm_struct *mm, unsigned long addr,
772 pte_t *ptep)
773{
774 return;
775}
776
777
745static inline pmd_t pmd_mknuma(pmd_t pmd) 778static inline pmd_t pmd_mknuma(pmd_t pmd)
746{ 779{
747 return pmd; 780 return pmd;
748} 781}
782
783static inline void pmdp_set_numa(struct mm_struct *mm, unsigned long addr,
784 pmd_t *pmdp)
785{
786 return ;
787}
749#endif /* CONFIG_NUMA_BALANCING */ 788#endif /* CONFIG_NUMA_BALANCING */
750 789
751#endif /* CONFIG_MMU */ 790#endif /* CONFIG_MMU */
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index 71727b6210ae..8f3dee097579 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -907,6 +907,9 @@ struct drm_mode_config {
907 907
908 /* whether async page flip is supported or not */ 908 /* whether async page flip is supported or not */
909 bool async_page_flip; 909 bool async_page_flip;
910
911 /* cursor size */
912 uint32_t cursor_width, cursor_height;
910}; 913};
911 914
912#define obj_to_crtc(x) container_of(x, struct drm_crtc, base) 915#define obj_to_crtc(x) container_of(x, struct drm_crtc, base)
diff --git a/include/drm/ttm/ttm_page_alloc.h b/include/drm/ttm/ttm_page_alloc.h
index d1f61bfe0ebe..49a828425fa2 100644
--- a/include/drm/ttm/ttm_page_alloc.h
+++ b/include/drm/ttm/ttm_page_alloc.h
@@ -29,6 +29,8 @@
29#include <drm/ttm/ttm_bo_driver.h> 29#include <drm/ttm/ttm_bo_driver.h>
30#include <drm/ttm/ttm_memory.h> 30#include <drm/ttm/ttm_memory.h>
31 31
32struct device;
33
32/** 34/**
33 * Initialize pool allocator. 35 * Initialize pool allocator.
34 */ 36 */
diff --git a/include/linux/ceph/ceph_fs.h b/include/linux/ceph/ceph_fs.h
index 2623cffc73a1..25bfb0eff772 100644
--- a/include/linux/ceph/ceph_fs.h
+++ b/include/linux/ceph/ceph_fs.h
@@ -373,8 +373,9 @@ extern const char *ceph_mds_op_name(int op);
373/* 373/*
374 * Ceph setxattr request flags. 374 * Ceph setxattr request flags.
375 */ 375 */
376#define CEPH_XATTR_CREATE 1 376#define CEPH_XATTR_CREATE (1 << 0)
377#define CEPH_XATTR_REPLACE 2 377#define CEPH_XATTR_REPLACE (1 << 1)
378#define CEPH_XATTR_REMOVE (1 << 31)
378 379
379union ceph_mds_request_args { 380union ceph_mds_request_args {
380 struct { 381 struct {
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/dma-buf.h b/include/linux/dma-buf.h
index dfac5ed31120..f886985a28b2 100644
--- a/include/linux/dma-buf.h
+++ b/include/linux/dma-buf.h
@@ -171,7 +171,7 @@ struct dma_buf *dma_buf_export_named(void *priv, const struct dma_buf_ops *ops,
171 size_t size, int flags, const char *); 171 size_t size, int flags, const char *);
172 172
173#define dma_buf_export(priv, ops, size, flags) \ 173#define dma_buf_export(priv, ops, size, flags) \
174 dma_buf_export_named(priv, ops, size, flags, __FILE__) 174 dma_buf_export_named(priv, ops, size, flags, KBUILD_MODNAME)
175 175
176int dma_buf_fd(struct dma_buf *dmabuf, int flags); 176int dma_buf_fd(struct dma_buf *dmabuf, int flags);
177struct dma_buf *dma_buf_get(int fd); 177struct dma_buf *dma_buf_get(int fd);
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/syscon/imx6q-iomuxc-gpr.h b/include/linux/mfd/syscon/imx6q-iomuxc-gpr.h
index 866e355fa409..ff44374a1a4e 100644
--- a/include/linux/mfd/syscon/imx6q-iomuxc-gpr.h
+++ b/include/linux/mfd/syscon/imx6q-iomuxc-gpr.h
@@ -242,6 +242,24 @@
242 242
243#define IMX6Q_GPR5_L2_CLK_STOP BIT(8) 243#define IMX6Q_GPR5_L2_CLK_STOP BIT(8)
244 244
245#define IMX6Q_GPR6_IPU1_ID00_WR_QOS_MASK (0xf << 0)
246#define IMX6Q_GPR6_IPU1_ID01_WR_QOS_MASK (0xf << 4)
247#define IMX6Q_GPR6_IPU1_ID10_WR_QOS_MASK (0xf << 8)
248#define IMX6Q_GPR6_IPU1_ID11_WR_QOS_MASK (0xf << 12)
249#define IMX6Q_GPR6_IPU1_ID00_RD_QOS_MASK (0xf << 16)
250#define IMX6Q_GPR6_IPU1_ID01_RD_QOS_MASK (0xf << 20)
251#define IMX6Q_GPR6_IPU1_ID10_RD_QOS_MASK (0xf << 24)
252#define IMX6Q_GPR6_IPU1_ID11_RD_QOS_MASK (0xf << 28)
253
254#define IMX6Q_GPR7_IPU2_ID00_WR_QOS_MASK (0xf << 0)
255#define IMX6Q_GPR7_IPU2_ID01_WR_QOS_MASK (0xf << 4)
256#define IMX6Q_GPR7_IPU2_ID10_WR_QOS_MASK (0xf << 8)
257#define IMX6Q_GPR7_IPU2_ID11_WR_QOS_MASK (0xf << 12)
258#define IMX6Q_GPR7_IPU2_ID00_RD_QOS_MASK (0xf << 16)
259#define IMX6Q_GPR7_IPU2_ID01_RD_QOS_MASK (0xf << 20)
260#define IMX6Q_GPR7_IPU2_ID10_RD_QOS_MASK (0xf << 24)
261#define IMX6Q_GPR7_IPU2_ID11_RD_QOS_MASK (0xf << 28)
262
245#define IMX6Q_GPR8_TX_SWING_LOW (0x7f << 25) 263#define IMX6Q_GPR8_TX_SWING_LOW (0x7f << 25)
246#define IMX6Q_GPR8_TX_SWING_FULL (0x7f << 18) 264#define IMX6Q_GPR8_TX_SWING_FULL (0x7f << 18)
247#define IMX6Q_GPR8_TX_DEEMPH_GEN2_6DB (0x3f << 12) 265#define IMX6Q_GPR8_TX_DEEMPH_GEN2_6DB (0x3f << 12)
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/netdevice.h b/include/linux/netdevice.h
index 440a02ee6f92..e8eeebd49a98 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -752,6 +752,9 @@ struct netdev_phys_port_id {
752 unsigned char id_len; 752 unsigned char id_len;
753}; 753};
754 754
755typedef u16 (*select_queue_fallback_t)(struct net_device *dev,
756 struct sk_buff *skb);
757
755/* 758/*
756 * This structure defines the management hooks for network devices. 759 * This structure defines the management hooks for network devices.
757 * The following hooks can be defined; unless noted otherwise, they are 760 * The following hooks can be defined; unless noted otherwise, they are
@@ -783,7 +786,7 @@ struct netdev_phys_port_id {
783 * Required can not be NULL. 786 * Required can not be NULL.
784 * 787 *
785 * u16 (*ndo_select_queue)(struct net_device *dev, struct sk_buff *skb, 788 * u16 (*ndo_select_queue)(struct net_device *dev, struct sk_buff *skb,
786 * void *accel_priv); 789 * void *accel_priv, select_queue_fallback_t fallback);
787 * Called to decide which queue to when device supports multiple 790 * Called to decide which queue to when device supports multiple
788 * transmit queues. 791 * transmit queues.
789 * 792 *
@@ -1005,7 +1008,8 @@ struct net_device_ops {
1005 struct net_device *dev); 1008 struct net_device *dev);
1006 u16 (*ndo_select_queue)(struct net_device *dev, 1009 u16 (*ndo_select_queue)(struct net_device *dev,
1007 struct sk_buff *skb, 1010 struct sk_buff *skb,
1008 void *accel_priv); 1011 void *accel_priv,
1012 select_queue_fallback_t fallback);
1009 void (*ndo_change_rx_flags)(struct net_device *dev, 1013 void (*ndo_change_rx_flags)(struct net_device *dev,
1010 int flags); 1014 int flags);
1011 void (*ndo_set_rx_mode)(struct net_device *dev); 1015 void (*ndo_set_rx_mode)(struct net_device *dev);
@@ -1551,7 +1555,6 @@ static inline void netdev_for_each_tx_queue(struct net_device *dev,
1551struct netdev_queue *netdev_pick_tx(struct net_device *dev, 1555struct netdev_queue *netdev_pick_tx(struct net_device *dev,
1552 struct sk_buff *skb, 1556 struct sk_buff *skb,
1553 void *accel_priv); 1557 void *accel_priv);
1554u16 __netdev_pick_tx(struct net_device *dev, struct sk_buff *skb);
1555 1558
1556/* 1559/*
1557 * Net namespace inlines 1560 * Net namespace inlines
@@ -2276,6 +2279,26 @@ static inline void netdev_reset_queue(struct net_device *dev_queue)
2276} 2279}
2277 2280
2278/** 2281/**
2282 * netdev_cap_txqueue - check if selected tx queue exceeds device queues
2283 * @dev: network device
2284 * @queue_index: given tx queue index
2285 *
2286 * Returns 0 if given tx queue index >= number of device tx queues,
2287 * otherwise returns the originally passed tx queue index.
2288 */
2289static inline u16 netdev_cap_txqueue(struct net_device *dev, u16 queue_index)
2290{
2291 if (unlikely(queue_index >= dev->real_num_tx_queues)) {
2292 net_warn_ratelimited("%s selects TX queue %d, but real number of TX queues is %d\n",
2293 dev->name, queue_index,
2294 dev->real_num_tx_queues);
2295 return 0;
2296 }
2297
2298 return queue_index;
2299}
2300
2301/**
2279 * netif_running - test if up 2302 * netif_running - test if up
2280 * @dev: network device 2303 * @dev: network device
2281 * 2304 *
@@ -3068,7 +3091,12 @@ void netdev_change_features(struct net_device *dev);
3068void netif_stacked_transfer_operstate(const struct net_device *rootdev, 3091void netif_stacked_transfer_operstate(const struct net_device *rootdev,
3069 struct net_device *dev); 3092 struct net_device *dev);
3070 3093
3071netdev_features_t netif_skb_features(struct sk_buff *skb); 3094netdev_features_t netif_skb_dev_features(struct sk_buff *skb,
3095 const struct net_device *dev);
3096static inline netdev_features_t netif_skb_features(struct sk_buff *skb)
3097{
3098 return netif_skb_dev_features(skb, skb->dev);
3099}
3072 3100
3073static inline bool net_gso_ok(netdev_features_t features, int gso_type) 3101static inline bool net_gso_ok(netdev_features_t features, int gso_type)
3074{ 3102{
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 f589c9af8cbf..3ebbbe7b6d05 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -2916,5 +2916,22 @@ static inline bool skb_head_is_locked(const struct sk_buff *skb)
2916{ 2916{
2917 return !skb->head_frag || skb_cloned(skb); 2917 return !skb->head_frag || skb_cloned(skb);
2918} 2918}
2919
2920/**
2921 * skb_gso_network_seglen - Return length of individual segments of a gso packet
2922 *
2923 * @skb: GSO skb
2924 *
2925 * skb_gso_network_seglen is used to determine the real size of the
2926 * individual segments, including Layer3 (IP, IPv6) and L4 headers (TCP/UDP).
2927 *
2928 * The MAC/L2 header is not accounted for.
2929 */
2930static inline unsigned int skb_gso_network_seglen(const struct sk_buff *skb)
2931{
2932 unsigned int hdr_len = skb_transport_header(skb) -
2933 skb_network_header(skb);
2934 return hdr_len + skb_gso_transport_seglen(skb);
2935}
2919#endif /* __KERNEL__ */ 2936#endif /* __KERNEL__ */
2920#endif /* _LINUX_SKBUFF_H */ 2937#endif /* _LINUX_SKBUFF_H */
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/net/sctp/structs.h b/include/net/sctp/structs.h
index d992ca3145fe..6ee76c804893 100644
--- a/include/net/sctp/structs.h
+++ b/include/net/sctp/structs.h
@@ -1653,17 +1653,6 @@ struct sctp_association {
1653 /* This is the last advertised value of rwnd over a SACK chunk. */ 1653 /* This is the last advertised value of rwnd over a SACK chunk. */
1654 __u32 a_rwnd; 1654 __u32 a_rwnd;
1655 1655
1656 /* Number of bytes by which the rwnd has slopped. The rwnd is allowed
1657 * to slop over a maximum of the association's frag_point.
1658 */
1659 __u32 rwnd_over;
1660
1661 /* Keeps treack of rwnd pressure. This happens when we have
1662 * a window, but not recevie buffer (i.e small packets). This one
1663 * is releases slowly (1 PMTU at a time ).
1664 */
1665 __u32 rwnd_press;
1666
1667 /* This is the sndbuf size in use for the association. 1656 /* This is the sndbuf size in use for the association.
1668 * This corresponds to the sndbuf size for the association, 1657 * This corresponds to the sndbuf size for the association,
1669 * as specified in the sk->sndbuf. 1658 * as specified in the sk->sndbuf.
@@ -1892,8 +1881,7 @@ void sctp_assoc_update(struct sctp_association *old,
1892__u32 sctp_association_get_next_tsn(struct sctp_association *); 1881__u32 sctp_association_get_next_tsn(struct sctp_association *);
1893 1882
1894void sctp_assoc_sync_pmtu(struct sock *, struct sctp_association *); 1883void sctp_assoc_sync_pmtu(struct sock *, struct sctp_association *);
1895void sctp_assoc_rwnd_increase(struct sctp_association *, unsigned int); 1884void sctp_assoc_rwnd_update(struct sctp_association *, bool);
1896void sctp_assoc_rwnd_decrease(struct sctp_association *, unsigned int);
1897void sctp_assoc_set_primary(struct sctp_association *, 1885void sctp_assoc_set_primary(struct sctp_association *,
1898 struct sctp_transport *); 1886 struct sctp_transport *);
1899void sctp_assoc_del_nonprimary_peers(struct sctp_association *, 1887void sctp_assoc_del_nonprimary_peers(struct sctp_association *,
diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h
index 3c9a833992e8..b06c8ed68707 100644
--- a/include/uapi/drm/drm.h
+++ b/include/uapi/drm/drm.h
@@ -619,6 +619,8 @@ struct drm_gem_open {
619#define DRM_PRIME_CAP_EXPORT 0x2 619#define DRM_PRIME_CAP_EXPORT 0x2
620#define DRM_CAP_TIMESTAMP_MONOTONIC 0x6 620#define DRM_CAP_TIMESTAMP_MONOTONIC 0x6
621#define DRM_CAP_ASYNC_PAGE_FLIP 0x7 621#define DRM_CAP_ASYNC_PAGE_FLIP 0x7
622#define DRM_CAP_CURSOR_WIDTH 0x8
623#define DRM_CAP_CURSOR_HEIGHT 0x9
622 624
623/** DRM_IOCTL_GET_CAP ioctl argument type */ 625/** DRM_IOCTL_GET_CAP ioctl argument type */
624struct drm_get_cap { 626struct drm_get_cap {
diff --git a/include/uapi/drm/vmwgfx_drm.h b/include/uapi/drm/vmwgfx_drm.h
index 9971c560ed9a..87792a5fee3b 100644
--- a/include/uapi/drm/vmwgfx_drm.h
+++ b/include/uapi/drm/vmwgfx_drm.h
@@ -87,6 +87,7 @@
87#define DRM_VMW_PARAM_MAX_SURF_MEMORY 7 87#define DRM_VMW_PARAM_MAX_SURF_MEMORY 7
88#define DRM_VMW_PARAM_3D_CAPS_SIZE 8 88#define DRM_VMW_PARAM_3D_CAPS_SIZE 8
89#define DRM_VMW_PARAM_MAX_MOB_MEMORY 9 89#define DRM_VMW_PARAM_MAX_MOB_MEMORY 9
90#define DRM_VMW_PARAM_MAX_MOB_SIZE 10
90 91
91/** 92/**
92 * struct drm_vmw_getparam_arg 93 * struct drm_vmw_getparam_arg
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/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/printk/printk.c b/kernel/printk/printk.c
index b1d255f04135..4dae9cbe9259 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -1076,7 +1076,6 @@ static int syslog_print_all(char __user *buf, int size, bool clear)
1076 next_seq = log_next_seq; 1076 next_seq = log_next_seq;
1077 1077
1078 len = 0; 1078 len = 0;
1079 prev = 0;
1080 while (len >= 0 && seq < next_seq) { 1079 while (len >= 0 && seq < next_seq) {
1081 struct printk_log *msg = log_from_idx(idx); 1080 struct printk_log *msg = log_from_idx(idx);
1082 int textlen; 1081 int textlen;
@@ -2788,7 +2787,6 @@ bool kmsg_dump_get_buffer(struct kmsg_dumper *dumper, bool syslog,
2788 next_idx = idx; 2787 next_idx = idx;
2789 2788
2790 l = 0; 2789 l = 0;
2791 prev = 0;
2792 while (seq < dumper->next_seq) { 2790 while (seq < dumper->next_seq) {
2793 struct printk_log *msg = log_from_idx(idx); 2791 struct printk_log *msg = log_from_idx(idx);
2794 2792
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..5b8838b56d1c 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(!cpu_present(idx) || idx == IDX_INVALID);
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(!cpu_present(best_cpu) && best_cpu != -1);
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..15cbc17fbf84 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;
@@ -137,7 +137,6 @@ static void inc_dl_migration(struct sched_dl_entity *dl_se, struct dl_rq *dl_rq)
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; 138 dl_rq = &rq_of_dl_rq(dl_rq)->dl;
139 139
140 dl_rq->dl_nr_total++;
141 if (p->nr_cpus_allowed > 1) 140 if (p->nr_cpus_allowed > 1)
142 dl_rq->dl_nr_migratory++; 141 dl_rq->dl_nr_migratory++;
143 142
@@ -149,7 +148,6 @@ static void dec_dl_migration(struct sched_dl_entity *dl_se, struct dl_rq *dl_rq)
149 struct task_struct *p = dl_task_of(dl_se); 148 struct task_struct *p = dl_task_of(dl_se);
150 dl_rq = &rq_of_dl_rq(dl_rq)->dl; 149 dl_rq = &rq_of_dl_rq(dl_rq)->dl;
151 150
152 dl_rq->dl_nr_total--;
153 if (p->nr_cpus_allowed > 1) 151 if (p->nr_cpus_allowed > 1)
154 dl_rq->dl_nr_migratory--; 152 dl_rq->dl_nr_migratory--;
155 153
@@ -717,6 +715,7 @@ void inc_dl_tasks(struct sched_dl_entity *dl_se, struct dl_rq *dl_rq)
717 715
718 WARN_ON(!dl_prio(prio)); 716 WARN_ON(!dl_prio(prio));
719 dl_rq->dl_nr_running++; 717 dl_rq->dl_nr_running++;
718 inc_nr_running(rq_of_dl_rq(dl_rq));
720 719
721 inc_dl_deadline(dl_rq, deadline); 720 inc_dl_deadline(dl_rq, deadline);
722 inc_dl_migration(dl_se, dl_rq); 721 inc_dl_migration(dl_se, dl_rq);
@@ -730,6 +729,7 @@ void dec_dl_tasks(struct sched_dl_entity *dl_se, struct dl_rq *dl_rq)
730 WARN_ON(!dl_prio(prio)); 729 WARN_ON(!dl_prio(prio));
731 WARN_ON(!dl_rq->dl_nr_running); 730 WARN_ON(!dl_rq->dl_nr_running);
732 dl_rq->dl_nr_running--; 731 dl_rq->dl_nr_running--;
732 dec_nr_running(rq_of_dl_rq(dl_rq));
733 733
734 dec_dl_deadline(dl_rq, dl_se->deadline); 734 dec_dl_deadline(dl_rq, dl_se->deadline);
735 dec_dl_migration(dl_se, dl_rq); 735 dec_dl_migration(dl_se, dl_rq);
@@ -836,8 +836,6 @@ static void enqueue_task_dl(struct rq *rq, struct task_struct *p, int flags)
836 836
837 if (!task_current(rq, p) && p->nr_cpus_allowed > 1) 837 if (!task_current(rq, p) && p->nr_cpus_allowed > 1)
838 enqueue_pushable_dl_task(rq, p); 838 enqueue_pushable_dl_task(rq, p);
839
840 inc_nr_running(rq);
841} 839}
842 840
843static void __dequeue_task_dl(struct rq *rq, struct task_struct *p, int flags) 841static void __dequeue_task_dl(struct rq *rq, struct task_struct *p, int flags)
@@ -850,8 +848,6 @@ static void dequeue_task_dl(struct rq *rq, struct task_struct *p, int flags)
850{ 848{
851 update_curr_dl(rq); 849 update_curr_dl(rq);
852 __dequeue_task_dl(rq, p, flags); 850 __dequeue_task_dl(rq, p, flags);
853
854 dec_nr_running(rq);
855} 851}
856 852
857/* 853/*
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 966cc2bfcb77..78157099b167 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
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/mm/huge_memory.c b/mm/huge_memory.c
index 82166bf974e1..da23eb96779f 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -1545,6 +1545,7 @@ int change_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd,
1545 entry = pmd_mknonnuma(entry); 1545 entry = pmd_mknonnuma(entry);
1546 entry = pmd_modify(entry, newprot); 1546 entry = pmd_modify(entry, newprot);
1547 ret = HPAGE_PMD_NR; 1547 ret = HPAGE_PMD_NR;
1548 set_pmd_at(mm, addr, pmd, entry);
1548 BUG_ON(pmd_write(entry)); 1549 BUG_ON(pmd_write(entry));
1549 } else { 1550 } else {
1550 struct page *page = pmd_page(*pmd); 1551 struct page *page = pmd_page(*pmd);
@@ -1557,16 +1558,10 @@ int change_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd,
1557 */ 1558 */
1558 if (!is_huge_zero_page(page) && 1559 if (!is_huge_zero_page(page) &&
1559 !pmd_numa(*pmd)) { 1560 !pmd_numa(*pmd)) {
1560 entry = *pmd; 1561 pmdp_set_numa(mm, addr, pmd);
1561 entry = pmd_mknuma(entry);
1562 ret = HPAGE_PMD_NR; 1562 ret = HPAGE_PMD_NR;
1563 } 1563 }
1564 } 1564 }
1565
1566 /* Set PMD if cleared earlier */
1567 if (ret == HPAGE_PMD_NR)
1568 set_pmd_at(mm, addr, pmd, entry);
1569
1570 spin_unlock(ptl); 1565 spin_unlock(ptl);
1571 } 1566 }
1572 1567
diff --git a/mm/mprotect.c b/mm/mprotect.c
index 7332c1785744..769a67a15803 100644
--- a/mm/mprotect.c
+++ b/mm/mprotect.c
@@ -58,36 +58,27 @@ static unsigned long change_pte_range(struct vm_area_struct *vma, pmd_t *pmd,
58 if (pte_numa(ptent)) 58 if (pte_numa(ptent))
59 ptent = pte_mknonnuma(ptent); 59 ptent = pte_mknonnuma(ptent);
60 ptent = pte_modify(ptent, newprot); 60 ptent = pte_modify(ptent, newprot);
61 /*
62 * Avoid taking write faults for pages we
63 * know to be dirty.
64 */
65 if (dirty_accountable && pte_dirty(ptent))
66 ptent = pte_mkwrite(ptent);
67 ptep_modify_prot_commit(mm, addr, pte, ptent);
61 updated = true; 68 updated = true;
62 } else { 69 } else {
63 struct page *page; 70 struct page *page;
64 71
65 ptent = *pte;
66 page = vm_normal_page(vma, addr, oldpte); 72 page = vm_normal_page(vma, addr, oldpte);
67 if (page && !PageKsm(page)) { 73 if (page && !PageKsm(page)) {
68 if (!pte_numa(oldpte)) { 74 if (!pte_numa(oldpte)) {
69 ptent = pte_mknuma(ptent); 75 ptep_set_numa(mm, addr, pte);
70 set_pte_at(mm, addr, pte, ptent);
71 updated = true; 76 updated = true;
72 } 77 }
73 } 78 }
74 } 79 }
75
76 /*
77 * Avoid taking write faults for pages we know to be
78 * dirty.
79 */
80 if (dirty_accountable && pte_dirty(ptent)) {
81 ptent = pte_mkwrite(ptent);
82 updated = true;
83 }
84
85 if (updated) 80 if (updated)
86 pages++; 81 pages++;
87
88 /* Only !prot_numa always clears the pte */
89 if (!prot_numa)
90 ptep_modify_prot_commit(mm, addr, pte, ptent);
91 } else if (IS_ENABLED(CONFIG_MIGRATION) && !pte_file(oldpte)) { 82 } else if (IS_ENABLED(CONFIG_MIGRATION) && !pte_file(oldpte)) {
92 swp_entry_t entry = pte_to_swp_entry(oldpte); 83 swp_entry_t entry = pte_to_swp_entry(oldpte);
93 84
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/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
index 512159bf607f..8323bced8e5b 100644
--- a/net/batman-adv/bat_iv_ogm.c
+++ b/net/batman-adv/bat_iv_ogm.c
@@ -241,19 +241,19 @@ batadv_iv_ogm_orig_get(struct batadv_priv *bat_priv, const uint8_t *addr)
241 size = bat_priv->num_ifaces * sizeof(uint8_t); 241 size = bat_priv->num_ifaces * sizeof(uint8_t);
242 orig_node->bat_iv.bcast_own_sum = kzalloc(size, GFP_ATOMIC); 242 orig_node->bat_iv.bcast_own_sum = kzalloc(size, GFP_ATOMIC);
243 if (!orig_node->bat_iv.bcast_own_sum) 243 if (!orig_node->bat_iv.bcast_own_sum)
244 goto free_bcast_own; 244 goto free_orig_node;
245 245
246 hash_added = batadv_hash_add(bat_priv->orig_hash, batadv_compare_orig, 246 hash_added = batadv_hash_add(bat_priv->orig_hash, batadv_compare_orig,
247 batadv_choose_orig, orig_node, 247 batadv_choose_orig, orig_node,
248 &orig_node->hash_entry); 248 &orig_node->hash_entry);
249 if (hash_added != 0) 249 if (hash_added != 0)
250 goto free_bcast_own; 250 goto free_orig_node;
251 251
252 return orig_node; 252 return orig_node;
253 253
254free_bcast_own:
255 kfree(orig_node->bat_iv.bcast_own);
256free_orig_node: 254free_orig_node:
255 /* free twice, as batadv_orig_node_new sets refcount to 2 */
256 batadv_orig_node_free_ref(orig_node);
257 batadv_orig_node_free_ref(orig_node); 257 batadv_orig_node_free_ref(orig_node);
258 258
259 return NULL; 259 return NULL;
@@ -266,7 +266,7 @@ batadv_iv_ogm_neigh_new(struct batadv_hard_iface *hard_iface,
266 struct batadv_orig_node *orig_neigh) 266 struct batadv_orig_node *orig_neigh)
267{ 267{
268 struct batadv_priv *bat_priv = netdev_priv(hard_iface->soft_iface); 268 struct batadv_priv *bat_priv = netdev_priv(hard_iface->soft_iface);
269 struct batadv_neigh_node *neigh_node; 269 struct batadv_neigh_node *neigh_node, *tmp_neigh_node;
270 270
271 neigh_node = batadv_neigh_node_new(hard_iface, neigh_addr, orig_node); 271 neigh_node = batadv_neigh_node_new(hard_iface, neigh_addr, orig_node);
272 if (!neigh_node) 272 if (!neigh_node)
@@ -281,14 +281,24 @@ batadv_iv_ogm_neigh_new(struct batadv_hard_iface *hard_iface,
281 neigh_node->orig_node = orig_neigh; 281 neigh_node->orig_node = orig_neigh;
282 neigh_node->if_incoming = hard_iface; 282 neigh_node->if_incoming = hard_iface;
283 283
284 batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
285 "Creating new neighbor %pM for orig_node %pM on interface %s\n",
286 neigh_addr, orig_node->orig, hard_iface->net_dev->name);
287
288 spin_lock_bh(&orig_node->neigh_list_lock); 284 spin_lock_bh(&orig_node->neigh_list_lock);
289 hlist_add_head_rcu(&neigh_node->list, &orig_node->neigh_list); 285 tmp_neigh_node = batadv_neigh_node_get(orig_node, hard_iface,
286 neigh_addr);
287 if (!tmp_neigh_node) {
288 hlist_add_head_rcu(&neigh_node->list, &orig_node->neigh_list);
289 } else {
290 kfree(neigh_node);
291 batadv_hardif_free_ref(hard_iface);
292 neigh_node = tmp_neigh_node;
293 }
290 spin_unlock_bh(&orig_node->neigh_list_lock); 294 spin_unlock_bh(&orig_node->neigh_list_lock);
291 295
296 if (!tmp_neigh_node)
297 batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
298 "Creating new neighbor %pM for orig_node %pM on interface %s\n",
299 neigh_addr, orig_node->orig,
300 hard_iface->net_dev->name);
301
292out: 302out:
293 return neigh_node; 303 return neigh_node;
294} 304}
diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
index 3d417d3641c6..b851cc580853 100644
--- a/net/batman-adv/hard-interface.c
+++ b/net/batman-adv/hard-interface.c
@@ -241,7 +241,7 @@ int batadv_hardif_min_mtu(struct net_device *soft_iface)
241{ 241{
242 struct batadv_priv *bat_priv = netdev_priv(soft_iface); 242 struct batadv_priv *bat_priv = netdev_priv(soft_iface);
243 const struct batadv_hard_iface *hard_iface; 243 const struct batadv_hard_iface *hard_iface;
244 int min_mtu = ETH_DATA_LEN; 244 int min_mtu = INT_MAX;
245 245
246 rcu_read_lock(); 246 rcu_read_lock();
247 list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) { 247 list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) {
@@ -256,8 +256,6 @@ int batadv_hardif_min_mtu(struct net_device *soft_iface)
256 } 256 }
257 rcu_read_unlock(); 257 rcu_read_unlock();
258 258
259 atomic_set(&bat_priv->packet_size_max, min_mtu);
260
261 if (atomic_read(&bat_priv->fragmentation) == 0) 259 if (atomic_read(&bat_priv->fragmentation) == 0)
262 goto out; 260 goto out;
263 261
@@ -268,13 +266,21 @@ int batadv_hardif_min_mtu(struct net_device *soft_iface)
268 min_mtu = min_t(int, min_mtu, BATADV_FRAG_MAX_FRAG_SIZE); 266 min_mtu = min_t(int, min_mtu, BATADV_FRAG_MAX_FRAG_SIZE);
269 min_mtu -= sizeof(struct batadv_frag_packet); 267 min_mtu -= sizeof(struct batadv_frag_packet);
270 min_mtu *= BATADV_FRAG_MAX_FRAGMENTS; 268 min_mtu *= BATADV_FRAG_MAX_FRAGMENTS;
271 atomic_set(&bat_priv->packet_size_max, min_mtu);
272
273 /* with fragmentation enabled we can fragment external packets easily */
274 min_mtu = min_t(int, min_mtu, ETH_DATA_LEN);
275 269
276out: 270out:
277 return min_mtu - batadv_max_header_len(); 271 /* report to the other components the maximum amount of bytes that
272 * batman-adv can send over the wire (without considering the payload
273 * overhead). For example, this value is used by TT to compute the
274 * maximum local table table size
275 */
276 atomic_set(&bat_priv->packet_size_max, min_mtu);
277
278 /* the real soft-interface MTU is computed by removing the payload
279 * overhead from the maximum amount of bytes that was just computed.
280 *
281 * However batman-adv does not support MTUs bigger than ETH_DATA_LEN
282 */
283 return min_t(int, min_mtu - batadv_max_header_len(), ETH_DATA_LEN);
278} 284}
279 285
280/* adjusts the MTU if a new interface with a smaller MTU appeared. */ 286/* adjusts the MTU if a new interface with a smaller MTU appeared. */
diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c
index 6df12a2e3605..853941629dc1 100644
--- a/net/batman-adv/originator.c
+++ b/net/batman-adv/originator.c
@@ -458,6 +458,42 @@ out:
458} 458}
459 459
460/** 460/**
461 * batadv_neigh_node_get - retrieve a neighbour from the list
462 * @orig_node: originator which the neighbour belongs to
463 * @hard_iface: the interface where this neighbour is connected to
464 * @addr: the address of the neighbour
465 *
466 * Looks for and possibly returns a neighbour belonging to this originator list
467 * which is connected through the provided hard interface.
468 * Returns NULL if the neighbour is not found.
469 */
470struct batadv_neigh_node *
471batadv_neigh_node_get(const struct batadv_orig_node *orig_node,
472 const struct batadv_hard_iface *hard_iface,
473 const uint8_t *addr)
474{
475 struct batadv_neigh_node *tmp_neigh_node, *res = NULL;
476
477 rcu_read_lock();
478 hlist_for_each_entry_rcu(tmp_neigh_node, &orig_node->neigh_list, list) {
479 if (!batadv_compare_eth(tmp_neigh_node->addr, addr))
480 continue;
481
482 if (tmp_neigh_node->if_incoming != hard_iface)
483 continue;
484
485 if (!atomic_inc_not_zero(&tmp_neigh_node->refcount))
486 continue;
487
488 res = tmp_neigh_node;
489 break;
490 }
491 rcu_read_unlock();
492
493 return res;
494}
495
496/**
461 * batadv_orig_ifinfo_free_rcu - free the orig_ifinfo object 497 * batadv_orig_ifinfo_free_rcu - free the orig_ifinfo object
462 * @rcu: rcu pointer of the orig_ifinfo object 498 * @rcu: rcu pointer of the orig_ifinfo object
463 */ 499 */
diff --git a/net/batman-adv/originator.h b/net/batman-adv/originator.h
index 37be290f63f6..db3a9ed734cb 100644
--- a/net/batman-adv/originator.h
+++ b/net/batman-adv/originator.h
@@ -29,6 +29,10 @@ void batadv_orig_node_free_ref_now(struct batadv_orig_node *orig_node);
29struct batadv_orig_node *batadv_orig_node_new(struct batadv_priv *bat_priv, 29struct batadv_orig_node *batadv_orig_node_new(struct batadv_priv *bat_priv,
30 const uint8_t *addr); 30 const uint8_t *addr);
31struct batadv_neigh_node * 31struct batadv_neigh_node *
32batadv_neigh_node_get(const struct batadv_orig_node *orig_node,
33 const struct batadv_hard_iface *hard_iface,
34 const uint8_t *addr);
35struct batadv_neigh_node *
32batadv_neigh_node_new(struct batadv_hard_iface *hard_iface, 36batadv_neigh_node_new(struct batadv_hard_iface *hard_iface,
33 const uint8_t *neigh_addr, 37 const uint8_t *neigh_addr,
34 struct batadv_orig_node *orig_node); 38 struct batadv_orig_node *orig_node);
diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c
index 1ed9f7c9ecea..a953d5b196a3 100644
--- a/net/batman-adv/routing.c
+++ b/net/batman-adv/routing.c
@@ -688,7 +688,7 @@ static int batadv_check_unicast_ttvn(struct batadv_priv *bat_priv,
688 int is_old_ttvn; 688 int is_old_ttvn;
689 689
690 /* check if there is enough data before accessing it */ 690 /* check if there is enough data before accessing it */
691 if (pskb_may_pull(skb, hdr_len + ETH_HLEN) < 0) 691 if (!pskb_may_pull(skb, hdr_len + ETH_HLEN))
692 return 0; 692 return 0;
693 693
694 /* create a copy of the skb (in case of for re-routing) to modify it. */ 694 /* create a copy of the skb (in case of for re-routing) to modify it. */
@@ -918,6 +918,8 @@ int batadv_recv_unicast_tvlv(struct sk_buff *skb,
918 918
919 if (ret != NET_RX_SUCCESS) 919 if (ret != NET_RX_SUCCESS)
920 ret = batadv_route_unicast_packet(skb, recv_if); 920 ret = batadv_route_unicast_packet(skb, recv_if);
921 else
922 consume_skb(skb);
921 923
922 return ret; 924 return ret;
923} 925}
diff --git a/net/batman-adv/send.c b/net/batman-adv/send.c
index 579f5f00a385..843febd1e519 100644
--- a/net/batman-adv/send.c
+++ b/net/batman-adv/send.c
@@ -254,9 +254,9 @@ static int batadv_send_skb_unicast(struct batadv_priv *bat_priv,
254 struct batadv_orig_node *orig_node, 254 struct batadv_orig_node *orig_node,
255 unsigned short vid) 255 unsigned short vid)
256{ 256{
257 struct ethhdr *ethhdr = (struct ethhdr *)skb->data; 257 struct ethhdr *ethhdr;
258 struct batadv_unicast_packet *unicast_packet; 258 struct batadv_unicast_packet *unicast_packet;
259 int ret = NET_XMIT_DROP; 259 int ret = NET_XMIT_DROP, hdr_size;
260 260
261 if (!orig_node) 261 if (!orig_node)
262 goto out; 262 goto out;
@@ -265,12 +265,16 @@ static int batadv_send_skb_unicast(struct batadv_priv *bat_priv,
265 case BATADV_UNICAST: 265 case BATADV_UNICAST:
266 if (!batadv_send_skb_prepare_unicast(skb, orig_node)) 266 if (!batadv_send_skb_prepare_unicast(skb, orig_node))
267 goto out; 267 goto out;
268
269 hdr_size = sizeof(*unicast_packet);
268 break; 270 break;
269 case BATADV_UNICAST_4ADDR: 271 case BATADV_UNICAST_4ADDR:
270 if (!batadv_send_skb_prepare_unicast_4addr(bat_priv, skb, 272 if (!batadv_send_skb_prepare_unicast_4addr(bat_priv, skb,
271 orig_node, 273 orig_node,
272 packet_subtype)) 274 packet_subtype))
273 goto out; 275 goto out;
276
277 hdr_size = sizeof(struct batadv_unicast_4addr_packet);
274 break; 278 break;
275 default: 279 default:
276 /* this function supports UNICAST and UNICAST_4ADDR only. It 280 /* this function supports UNICAST and UNICAST_4ADDR only. It
@@ -279,6 +283,7 @@ static int batadv_send_skb_unicast(struct batadv_priv *bat_priv,
279 goto out; 283 goto out;
280 } 284 }
281 285
286 ethhdr = (struct ethhdr *)(skb->data + hdr_size);
282 unicast_packet = (struct batadv_unicast_packet *)skb->data; 287 unicast_packet = (struct batadv_unicast_packet *)skb->data;
283 288
284 /* inform the destination node that we are still missing a correct route 289 /* inform the destination node that we are still missing a correct route
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index b6071f675a3e..959dde721c46 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -1975,6 +1975,7 @@ static uint32_t batadv_tt_global_crc(struct batadv_priv *bat_priv,
1975 struct hlist_head *head; 1975 struct hlist_head *head;
1976 uint32_t i, crc_tmp, crc = 0; 1976 uint32_t i, crc_tmp, crc = 0;
1977 uint8_t flags; 1977 uint8_t flags;
1978 __be16 tmp_vid;
1978 1979
1979 for (i = 0; i < hash->size; i++) { 1980 for (i = 0; i < hash->size; i++) {
1980 head = &hash->table[i]; 1981 head = &hash->table[i];
@@ -2011,8 +2012,11 @@ static uint32_t batadv_tt_global_crc(struct batadv_priv *bat_priv,
2011 orig_node)) 2012 orig_node))
2012 continue; 2013 continue;
2013 2014
2014 crc_tmp = crc32c(0, &tt_common->vid, 2015 /* use network order to read the VID: this ensures that
2015 sizeof(tt_common->vid)); 2016 * every node reads the bytes in the same order.
2017 */
2018 tmp_vid = htons(tt_common->vid);
2019 crc_tmp = crc32c(0, &tmp_vid, sizeof(tmp_vid));
2016 2020
2017 /* compute the CRC on flags that have to be kept in sync 2021 /* compute the CRC on flags that have to be kept in sync
2018 * among nodes 2022 * among nodes
@@ -2046,6 +2050,7 @@ static uint32_t batadv_tt_local_crc(struct batadv_priv *bat_priv,
2046 struct hlist_head *head; 2050 struct hlist_head *head;
2047 uint32_t i, crc_tmp, crc = 0; 2051 uint32_t i, crc_tmp, crc = 0;
2048 uint8_t flags; 2052 uint8_t flags;
2053 __be16 tmp_vid;
2049 2054
2050 for (i = 0; i < hash->size; i++) { 2055 for (i = 0; i < hash->size; i++) {
2051 head = &hash->table[i]; 2056 head = &hash->table[i];
@@ -2064,8 +2069,11 @@ static uint32_t batadv_tt_local_crc(struct batadv_priv *bat_priv,
2064 if (tt_common->flags & BATADV_TT_CLIENT_NEW) 2069 if (tt_common->flags & BATADV_TT_CLIENT_NEW)
2065 continue; 2070 continue;
2066 2071
2067 crc_tmp = crc32c(0, &tt_common->vid, 2072 /* use network order to read the VID: this ensures that
2068 sizeof(tt_common->vid)); 2073 * every node reads the bytes in the same order.
2074 */
2075 tmp_vid = htons(tt_common->vid);
2076 crc_tmp = crc32c(0, &tmp_vid, sizeof(tmp_vid));
2069 2077
2070 /* compute the CRC on flags that have to be kept in sync 2078 /* compute the CRC on flags that have to be kept in sync
2071 * among nodes 2079 * among nodes
@@ -2262,6 +2270,7 @@ static bool batadv_tt_global_check_crc(struct batadv_orig_node *orig_node,
2262{ 2270{
2263 struct batadv_tvlv_tt_vlan_data *tt_vlan_tmp; 2271 struct batadv_tvlv_tt_vlan_data *tt_vlan_tmp;
2264 struct batadv_orig_node_vlan *vlan; 2272 struct batadv_orig_node_vlan *vlan;
2273 uint32_t crc;
2265 int i; 2274 int i;
2266 2275
2267 /* check if each received CRC matches the locally stored one */ 2276 /* check if each received CRC matches the locally stored one */
@@ -2281,7 +2290,10 @@ static bool batadv_tt_global_check_crc(struct batadv_orig_node *orig_node,
2281 if (!vlan) 2290 if (!vlan)
2282 return false; 2291 return false;
2283 2292
2284 if (vlan->tt.crc != ntohl(tt_vlan_tmp->crc)) 2293 crc = vlan->tt.crc;
2294 batadv_orig_node_vlan_free_ref(vlan);
2295
2296 if (crc != ntohl(tt_vlan_tmp->crc))
2285 return false; 2297 return false;
2286 } 2298 }
2287 2299
@@ -3218,7 +3230,6 @@ static void batadv_tt_update_orig(struct batadv_priv *bat_priv,
3218 3230
3219 spin_lock_bh(&orig_node->tt_lock); 3231 spin_lock_bh(&orig_node->tt_lock);
3220 3232
3221 tt_change = (struct batadv_tvlv_tt_change *)tt_buff;
3222 batadv_tt_update_changes(bat_priv, orig_node, tt_num_changes, 3233 batadv_tt_update_changes(bat_priv, orig_node, tt_num_changes,
3223 ttvn, tt_change); 3234 ttvn, tt_change);
3224 3235
diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c
index 292e619db896..d9fb93451442 100644
--- a/net/bluetooth/hidp/core.c
+++ b/net/bluetooth/hidp/core.c
@@ -430,6 +430,16 @@ static void hidp_del_timer(struct hidp_session *session)
430 del_timer(&session->timer); 430 del_timer(&session->timer);
431} 431}
432 432
433static void hidp_process_report(struct hidp_session *session,
434 int type, const u8 *data, int len, int intr)
435{
436 if (len > HID_MAX_BUFFER_SIZE)
437 len = HID_MAX_BUFFER_SIZE;
438
439 memcpy(session->input_buf, data, len);
440 hid_input_report(session->hid, type, session->input_buf, len, intr);
441}
442
433static void hidp_process_handshake(struct hidp_session *session, 443static void hidp_process_handshake(struct hidp_session *session,
434 unsigned char param) 444 unsigned char param)
435{ 445{
@@ -502,7 +512,8 @@ static int hidp_process_data(struct hidp_session *session, struct sk_buff *skb,
502 hidp_input_report(session, skb); 512 hidp_input_report(session, skb);
503 513
504 if (session->hid) 514 if (session->hid)
505 hid_input_report(session->hid, HID_INPUT_REPORT, skb->data, skb->len, 0); 515 hidp_process_report(session, HID_INPUT_REPORT,
516 skb->data, skb->len, 0);
506 break; 517 break;
507 518
508 case HIDP_DATA_RTYPE_OTHER: 519 case HIDP_DATA_RTYPE_OTHER:
@@ -584,7 +595,8 @@ static void hidp_recv_intr_frame(struct hidp_session *session,
584 hidp_input_report(session, skb); 595 hidp_input_report(session, skb);
585 596
586 if (session->hid) { 597 if (session->hid) {
587 hid_input_report(session->hid, HID_INPUT_REPORT, skb->data, skb->len, 1); 598 hidp_process_report(session, HID_INPUT_REPORT,
599 skb->data, skb->len, 1);
588 BT_DBG("report len %d", skb->len); 600 BT_DBG("report len %d", skb->len);
589 } 601 }
590 } else { 602 } else {
diff --git a/net/bluetooth/hidp/hidp.h b/net/bluetooth/hidp/hidp.h
index ab5241400cf7..8798492a6e99 100644
--- a/net/bluetooth/hidp/hidp.h
+++ b/net/bluetooth/hidp/hidp.h
@@ -24,6 +24,7 @@
24#define __HIDP_H 24#define __HIDP_H
25 25
26#include <linux/types.h> 26#include <linux/types.h>
27#include <linux/hid.h>
27#include <linux/kref.h> 28#include <linux/kref.h>
28#include <net/bluetooth/bluetooth.h> 29#include <net/bluetooth/bluetooth.h>
29#include <net/bluetooth/l2cap.h> 30#include <net/bluetooth/l2cap.h>
@@ -179,6 +180,9 @@ struct hidp_session {
179 180
180 /* Used in hidp_output_raw_report() */ 181 /* Used in hidp_output_raw_report() */
181 int output_report_success; /* boolean */ 182 int output_report_success; /* boolean */
183
184 /* temporary input buffer */
185 u8 input_buf[HID_MAX_BUFFER_SIZE];
182}; 186};
183 187
184/* HIDP init defines */ 188/* HIDP init defines */
diff --git a/net/core/dev.c b/net/core/dev.c
index 4ad1b78c9c77..b1b0c8d4d7df 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -2420,7 +2420,7 @@ EXPORT_SYMBOL(netdev_rx_csum_fault);
2420 * 2. No high memory really exists on this machine. 2420 * 2. No high memory really exists on this machine.
2421 */ 2421 */
2422 2422
2423static int illegal_highdma(struct net_device *dev, struct sk_buff *skb) 2423static int illegal_highdma(const struct net_device *dev, struct sk_buff *skb)
2424{ 2424{
2425#ifdef CONFIG_HIGHMEM 2425#ifdef CONFIG_HIGHMEM
2426 int i; 2426 int i;
@@ -2495,34 +2495,36 @@ static int dev_gso_segment(struct sk_buff *skb, netdev_features_t features)
2495} 2495}
2496 2496
2497static netdev_features_t harmonize_features(struct sk_buff *skb, 2497static netdev_features_t harmonize_features(struct sk_buff *skb,
2498 netdev_features_t features) 2498 const struct net_device *dev,
2499 netdev_features_t features)
2499{ 2500{
2500 if (skb->ip_summed != CHECKSUM_NONE && 2501 if (skb->ip_summed != CHECKSUM_NONE &&
2501 !can_checksum_protocol(features, skb_network_protocol(skb))) { 2502 !can_checksum_protocol(features, skb_network_protocol(skb))) {
2502 features &= ~NETIF_F_ALL_CSUM; 2503 features &= ~NETIF_F_ALL_CSUM;
2503 } else if (illegal_highdma(skb->dev, skb)) { 2504 } else if (illegal_highdma(dev, skb)) {
2504 features &= ~NETIF_F_SG; 2505 features &= ~NETIF_F_SG;
2505 } 2506 }
2506 2507
2507 return features; 2508 return features;
2508} 2509}
2509 2510
2510netdev_features_t netif_skb_features(struct sk_buff *skb) 2511netdev_features_t netif_skb_dev_features(struct sk_buff *skb,
2512 const struct net_device *dev)
2511{ 2513{
2512 __be16 protocol = skb->protocol; 2514 __be16 protocol = skb->protocol;
2513 netdev_features_t features = skb->dev->features; 2515 netdev_features_t features = dev->features;
2514 2516
2515 if (skb_shinfo(skb)->gso_segs > skb->dev->gso_max_segs) 2517 if (skb_shinfo(skb)->gso_segs > dev->gso_max_segs)
2516 features &= ~NETIF_F_GSO_MASK; 2518 features &= ~NETIF_F_GSO_MASK;
2517 2519
2518 if (protocol == htons(ETH_P_8021Q) || protocol == htons(ETH_P_8021AD)) { 2520 if (protocol == htons(ETH_P_8021Q) || protocol == htons(ETH_P_8021AD)) {
2519 struct vlan_ethhdr *veh = (struct vlan_ethhdr *)skb->data; 2521 struct vlan_ethhdr *veh = (struct vlan_ethhdr *)skb->data;
2520 protocol = veh->h_vlan_encapsulated_proto; 2522 protocol = veh->h_vlan_encapsulated_proto;
2521 } else if (!vlan_tx_tag_present(skb)) { 2523 } else if (!vlan_tx_tag_present(skb)) {
2522 return harmonize_features(skb, features); 2524 return harmonize_features(skb, dev, features);
2523 } 2525 }
2524 2526
2525 features &= (skb->dev->vlan_features | NETIF_F_HW_VLAN_CTAG_TX | 2527 features &= (dev->vlan_features | NETIF_F_HW_VLAN_CTAG_TX |
2526 NETIF_F_HW_VLAN_STAG_TX); 2528 NETIF_F_HW_VLAN_STAG_TX);
2527 2529
2528 if (protocol == htons(ETH_P_8021Q) || protocol == htons(ETH_P_8021AD)) 2530 if (protocol == htons(ETH_P_8021Q) || protocol == htons(ETH_P_8021AD))
@@ -2530,9 +2532,9 @@ netdev_features_t netif_skb_features(struct sk_buff *skb)
2530 NETIF_F_GEN_CSUM | NETIF_F_HW_VLAN_CTAG_TX | 2532 NETIF_F_GEN_CSUM | NETIF_F_HW_VLAN_CTAG_TX |
2531 NETIF_F_HW_VLAN_STAG_TX; 2533 NETIF_F_HW_VLAN_STAG_TX;
2532 2534
2533 return harmonize_features(skb, features); 2535 return harmonize_features(skb, dev, features);
2534} 2536}
2535EXPORT_SYMBOL(netif_skb_features); 2537EXPORT_SYMBOL(netif_skb_dev_features);
2536 2538
2537int dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev, 2539int dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev,
2538 struct netdev_queue *txq) 2540 struct netdev_queue *txq)
diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c
index 87577d447554..e29e810663d7 100644
--- a/net/core/flow_dissector.c
+++ b/net/core/flow_dissector.c
@@ -323,17 +323,6 @@ u32 __skb_get_poff(const struct sk_buff *skb)
323 return poff; 323 return poff;
324} 324}
325 325
326static inline u16 dev_cap_txqueue(struct net_device *dev, u16 queue_index)
327{
328 if (unlikely(queue_index >= dev->real_num_tx_queues)) {
329 net_warn_ratelimited("%s selects TX queue %d, but real number of TX queues is %d\n",
330 dev->name, queue_index,
331 dev->real_num_tx_queues);
332 return 0;
333 }
334 return queue_index;
335}
336
337static inline int get_xps_queue(struct net_device *dev, struct sk_buff *skb) 326static inline int get_xps_queue(struct net_device *dev, struct sk_buff *skb)
338{ 327{
339#ifdef CONFIG_XPS 328#ifdef CONFIG_XPS
@@ -372,7 +361,7 @@ static inline int get_xps_queue(struct net_device *dev, struct sk_buff *skb)
372#endif 361#endif
373} 362}
374 363
375u16 __netdev_pick_tx(struct net_device *dev, struct sk_buff *skb) 364static u16 __netdev_pick_tx(struct net_device *dev, struct sk_buff *skb)
376{ 365{
377 struct sock *sk = skb->sk; 366 struct sock *sk = skb->sk;
378 int queue_index = sk_tx_queue_get(sk); 367 int queue_index = sk_tx_queue_get(sk);
@@ -392,7 +381,6 @@ u16 __netdev_pick_tx(struct net_device *dev, struct sk_buff *skb)
392 381
393 return queue_index; 382 return queue_index;
394} 383}
395EXPORT_SYMBOL(__netdev_pick_tx);
396 384
397struct netdev_queue *netdev_pick_tx(struct net_device *dev, 385struct netdev_queue *netdev_pick_tx(struct net_device *dev,
398 struct sk_buff *skb, 386 struct sk_buff *skb,
@@ -403,13 +391,13 @@ struct netdev_queue *netdev_pick_tx(struct net_device *dev,
403 if (dev->real_num_tx_queues != 1) { 391 if (dev->real_num_tx_queues != 1) {
404 const struct net_device_ops *ops = dev->netdev_ops; 392 const struct net_device_ops *ops = dev->netdev_ops;
405 if (ops->ndo_select_queue) 393 if (ops->ndo_select_queue)
406 queue_index = ops->ndo_select_queue(dev, skb, 394 queue_index = ops->ndo_select_queue(dev, skb, accel_priv,
407 accel_priv); 395 __netdev_pick_tx);
408 else 396 else
409 queue_index = __netdev_pick_tx(dev, skb); 397 queue_index = __netdev_pick_tx(dev, skb);
410 398
411 if (!accel_priv) 399 if (!accel_priv)
412 queue_index = dev_cap_txqueue(dev, queue_index); 400 queue_index = netdev_cap_txqueue(dev, queue_index);
413 } 401 }
414 402
415 skb_set_queue_mapping(skb, queue_index); 403 skb_set_queue_mapping(skb, queue_index);
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 048dc8d183aa..1a0dac2ef9ad 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -1963,16 +1963,21 @@ replay:
1963 1963
1964 dev->ifindex = ifm->ifi_index; 1964 dev->ifindex = ifm->ifi_index;
1965 1965
1966 if (ops->newlink) 1966 if (ops->newlink) {
1967 err = ops->newlink(net, dev, tb, data); 1967 err = ops->newlink(net, dev, tb, data);
1968 else 1968 /* Drivers should call free_netdev() in ->destructor
1969 * and unregister it on failure so that device could be
1970 * finally freed in rtnl_unlock.
1971 */
1972 if (err < 0)
1973 goto out;
1974 } else {
1969 err = register_netdevice(dev); 1975 err = register_netdevice(dev);
1970 1976 if (err < 0) {
1971 if (err < 0) { 1977 free_netdev(dev);
1972 free_netdev(dev); 1978 goto out;
1973 goto out; 1979 }
1974 } 1980 }
1975
1976 err = rtnl_configure_link(dev, ifm); 1981 err = rtnl_configure_link(dev, ifm);
1977 if (err < 0) 1982 if (err < 0)
1978 unregister_netdevice(dev); 1983 unregister_netdevice(dev);
diff --git a/net/dccp/ccids/lib/tfrc.c b/net/dccp/ccids/lib/tfrc.c
index c073b81a1f3e..62b5828acde0 100644
--- a/net/dccp/ccids/lib/tfrc.c
+++ b/net/dccp/ccids/lib/tfrc.c
@@ -8,7 +8,7 @@
8#include "tfrc.h" 8#include "tfrc.h"
9 9
10#ifdef CONFIG_IP_DCCP_TFRC_DEBUG 10#ifdef CONFIG_IP_DCCP_TFRC_DEBUG
11static bool tfrc_debug; 11bool tfrc_debug;
12module_param(tfrc_debug, bool, 0644); 12module_param(tfrc_debug, bool, 0644);
13MODULE_PARM_DESC(tfrc_debug, "Enable TFRC debug messages"); 13MODULE_PARM_DESC(tfrc_debug, "Enable TFRC debug messages");
14#endif 14#endif
diff --git a/net/dccp/ccids/lib/tfrc.h b/net/dccp/ccids/lib/tfrc.h
index a3d8f7c76ae0..40ee7d62b652 100644
--- a/net/dccp/ccids/lib/tfrc.h
+++ b/net/dccp/ccids/lib/tfrc.h
@@ -21,6 +21,7 @@
21#include "packet_history.h" 21#include "packet_history.h"
22 22
23#ifdef CONFIG_IP_DCCP_TFRC_DEBUG 23#ifdef CONFIG_IP_DCCP_TFRC_DEBUG
24extern bool tfrc_debug;
24#define tfrc_pr_debug(format, a...) DCCP_PR_DEBUG(tfrc_debug, format, ##a) 25#define tfrc_pr_debug(format, a...) DCCP_PR_DEBUG(tfrc_debug, format, ##a)
25#else 26#else
26#define tfrc_pr_debug(format, a...) 27#define tfrc_pr_debug(format, a...)
diff --git a/net/ipv4/ip_forward.c b/net/ipv4/ip_forward.c
index e9f1217a8afd..f3869c186d97 100644
--- a/net/ipv4/ip_forward.c
+++ b/net/ipv4/ip_forward.c
@@ -39,6 +39,71 @@
39#include <net/route.h> 39#include <net/route.h>
40#include <net/xfrm.h> 40#include <net/xfrm.h>
41 41
42static bool ip_may_fragment(const struct sk_buff *skb)
43{
44 return unlikely((ip_hdr(skb)->frag_off & htons(IP_DF)) == 0) ||
45 !skb->local_df;
46}
47
48static bool ip_exceeds_mtu(const struct sk_buff *skb, unsigned int mtu)
49{
50 if (skb->len <= mtu || skb->local_df)
51 return false;
52
53 if (skb_is_gso(skb) && skb_gso_network_seglen(skb) <= mtu)
54 return false;
55
56 return true;
57}
58
59static bool ip_gso_exceeds_dst_mtu(const struct sk_buff *skb)
60{
61 unsigned int mtu;
62
63 if (skb->local_df || !skb_is_gso(skb))
64 return false;
65
66 mtu = ip_dst_mtu_maybe_forward(skb_dst(skb), true);
67
68 /* if seglen > mtu, do software segmentation for IP fragmentation on
69 * output. DF bit cannot be set since ip_forward would have sent
70 * icmp error.
71 */
72 return skb_gso_network_seglen(skb) > mtu;
73}
74
75/* called if GSO skb needs to be fragmented on forward */
76static int ip_forward_finish_gso(struct sk_buff *skb)
77{
78 struct dst_entry *dst = skb_dst(skb);
79 netdev_features_t features;
80 struct sk_buff *segs;
81 int ret = 0;
82
83 features = netif_skb_dev_features(skb, dst->dev);
84 segs = skb_gso_segment(skb, features & ~NETIF_F_GSO_MASK);
85 if (IS_ERR(segs)) {
86 kfree_skb(skb);
87 return -ENOMEM;
88 }
89
90 consume_skb(skb);
91
92 do {
93 struct sk_buff *nskb = segs->next;
94 int err;
95
96 segs->next = NULL;
97 err = dst_output(segs);
98
99 if (err && ret == 0)
100 ret = err;
101 segs = nskb;
102 } while (segs);
103
104 return ret;
105}
106
42static int ip_forward_finish(struct sk_buff *skb) 107static int ip_forward_finish(struct sk_buff *skb)
43{ 108{
44 struct ip_options *opt = &(IPCB(skb)->opt); 109 struct ip_options *opt = &(IPCB(skb)->opt);
@@ -49,6 +114,9 @@ static int ip_forward_finish(struct sk_buff *skb)
49 if (unlikely(opt->optlen)) 114 if (unlikely(opt->optlen))
50 ip_forward_options(skb); 115 ip_forward_options(skb);
51 116
117 if (ip_gso_exceeds_dst_mtu(skb))
118 return ip_forward_finish_gso(skb);
119
52 return dst_output(skb); 120 return dst_output(skb);
53} 121}
54 122
@@ -91,8 +159,7 @@ int ip_forward(struct sk_buff *skb)
91 159
92 IPCB(skb)->flags |= IPSKB_FORWARDED; 160 IPCB(skb)->flags |= IPSKB_FORWARDED;
93 mtu = ip_dst_mtu_maybe_forward(&rt->dst, true); 161 mtu = ip_dst_mtu_maybe_forward(&rt->dst, true);
94 if (unlikely(skb->len > mtu && !skb_is_gso(skb) && 162 if (!ip_may_fragment(skb) && ip_exceeds_mtu(skb, mtu)) {
95 (ip_hdr(skb)->frag_off & htons(IP_DF))) && !skb->local_df) {
96 IP_INC_STATS(dev_net(rt->dst.dev), IPSTATS_MIB_FRAGFAILS); 163 IP_INC_STATS(dev_net(rt->dst.dev), IPSTATS_MIB_FRAGFAILS);
97 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED, 164 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED,
98 htonl(mtu)); 165 htonl(mtu));
diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
index efa1138fa523..b3e86ea7b71b 100644
--- a/net/ipv4/ipconfig.c
+++ b/net/ipv4/ipconfig.c
@@ -273,7 +273,7 @@ static int __init ic_open_devs(void)
273 273
274 msleep(1); 274 msleep(1);
275 275
276 if time_before(jiffies, next_msg) 276 if (time_before(jiffies, next_msg))
277 continue; 277 continue;
278 278
279 elapsed = jiffies_to_msecs(jiffies - start); 279 elapsed = jiffies_to_msecs(jiffies - start);
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 25071b48921c..4c011ec69ed4 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -1597,6 +1597,7 @@ static int __mkroute_input(struct sk_buff *skb,
1597 rth->rt_gateway = 0; 1597 rth->rt_gateway = 0;
1598 rth->rt_uses_gateway = 0; 1598 rth->rt_uses_gateway = 0;
1599 INIT_LIST_HEAD(&rth->rt_uncached); 1599 INIT_LIST_HEAD(&rth->rt_uncached);
1600 RT_CACHE_STAT_INC(in_slow_tot);
1600 1601
1601 rth->dst.input = ip_forward; 1602 rth->dst.input = ip_forward;
1602 rth->dst.output = ip_output; 1603 rth->dst.output = ip_output;
@@ -1695,10 +1696,11 @@ static int ip_route_input_slow(struct sk_buff *skb, __be32 daddr, __be32 saddr,
1695 fl4.daddr = daddr; 1696 fl4.daddr = daddr;
1696 fl4.saddr = saddr; 1697 fl4.saddr = saddr;
1697 err = fib_lookup(net, &fl4, &res); 1698 err = fib_lookup(net, &fl4, &res);
1698 if (err != 0) 1699 if (err != 0) {
1700 if (!IN_DEV_FORWARD(in_dev))
1701 err = -EHOSTUNREACH;
1699 goto no_route; 1702 goto no_route;
1700 1703 }
1701 RT_CACHE_STAT_INC(in_slow_tot);
1702 1704
1703 if (res.type == RTN_BROADCAST) 1705 if (res.type == RTN_BROADCAST)
1704 goto brd_input; 1706 goto brd_input;
@@ -1712,8 +1714,10 @@ static int ip_route_input_slow(struct sk_buff *skb, __be32 daddr, __be32 saddr,
1712 goto local_input; 1714 goto local_input;
1713 } 1715 }
1714 1716
1715 if (!IN_DEV_FORWARD(in_dev)) 1717 if (!IN_DEV_FORWARD(in_dev)) {
1718 err = -EHOSTUNREACH;
1716 goto no_route; 1719 goto no_route;
1720 }
1717 if (res.type != RTN_UNICAST) 1721 if (res.type != RTN_UNICAST)
1718 goto martian_destination; 1722 goto martian_destination;
1719 1723
@@ -1768,6 +1772,7 @@ local_input:
1768 rth->rt_gateway = 0; 1772 rth->rt_gateway = 0;
1769 rth->rt_uses_gateway = 0; 1773 rth->rt_uses_gateway = 0;
1770 INIT_LIST_HEAD(&rth->rt_uncached); 1774 INIT_LIST_HEAD(&rth->rt_uncached);
1775 RT_CACHE_STAT_INC(in_slow_tot);
1771 if (res.type == RTN_UNREACHABLE) { 1776 if (res.type == RTN_UNREACHABLE) {
1772 rth->dst.input= ip_error; 1777 rth->dst.input= ip_error;
1773 rth->dst.error= -err; 1778 rth->dst.error= -err;
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index ad235690684c..fdbfeca36d63 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -2783,6 +2783,8 @@ static void addrconf_gre_config(struct net_device *dev)
2783 ipv6_addr_set(&addr, htonl(0xFE800000), 0, 0, 0); 2783 ipv6_addr_set(&addr, htonl(0xFE800000), 0, 0, 0);
2784 if (!ipv6_generate_eui64(addr.s6_addr + 8, dev)) 2784 if (!ipv6_generate_eui64(addr.s6_addr + 8, dev))
2785 addrconf_add_linklocal(idev, &addr); 2785 addrconf_add_linklocal(idev, &addr);
2786 else
2787 addrconf_prefix_route(&addr, 64, dev, 0, 0);
2786} 2788}
2787#endif 2789#endif
2788 2790
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index ef02b26ccf81..070a2fae2375 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -342,6 +342,20 @@ static unsigned int ip6_dst_mtu_forward(const struct dst_entry *dst)
342 return mtu; 342 return mtu;
343} 343}
344 344
345static bool ip6_pkt_too_big(const struct sk_buff *skb, unsigned int mtu)
346{
347 if (skb->len <= mtu || skb->local_df)
348 return false;
349
350 if (IP6CB(skb)->frag_max_size && IP6CB(skb)->frag_max_size > mtu)
351 return true;
352
353 if (skb_is_gso(skb) && skb_gso_network_seglen(skb) <= mtu)
354 return false;
355
356 return true;
357}
358
345int ip6_forward(struct sk_buff *skb) 359int ip6_forward(struct sk_buff *skb)
346{ 360{
347 struct dst_entry *dst = skb_dst(skb); 361 struct dst_entry *dst = skb_dst(skb);
@@ -466,8 +480,7 @@ int ip6_forward(struct sk_buff *skb)
466 if (mtu < IPV6_MIN_MTU) 480 if (mtu < IPV6_MIN_MTU)
467 mtu = IPV6_MIN_MTU; 481 mtu = IPV6_MIN_MTU;
468 482
469 if ((!skb->local_df && skb->len > mtu && !skb_is_gso(skb)) || 483 if (ip6_pkt_too_big(skb, mtu)) {
470 (IP6CB(skb)->frag_max_size && IP6CB(skb)->frag_max_size > mtu)) {
471 /* Again, force OUTPUT device used as source address */ 484 /* Again, force OUTPUT device used as source address */
472 skb->dev = dst->dev; 485 skb->dev = dst->dev;
473 icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu); 486 icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu);
diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
index d6d1f1df9119..ce1c44370610 100644
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -1057,7 +1057,8 @@ static void ieee80211_uninit(struct net_device *dev)
1057 1057
1058static u16 ieee80211_netdev_select_queue(struct net_device *dev, 1058static u16 ieee80211_netdev_select_queue(struct net_device *dev,
1059 struct sk_buff *skb, 1059 struct sk_buff *skb,
1060 void *accel_priv) 1060 void *accel_priv,
1061 select_queue_fallback_t fallback)
1061{ 1062{
1062 return ieee80211_select_queue(IEEE80211_DEV_TO_SUB_IF(dev), skb); 1063 return ieee80211_select_queue(IEEE80211_DEV_TO_SUB_IF(dev), skb);
1063} 1064}
@@ -1075,7 +1076,8 @@ static const struct net_device_ops ieee80211_dataif_ops = {
1075 1076
1076static u16 ieee80211_monitor_select_queue(struct net_device *dev, 1077static u16 ieee80211_monitor_select_queue(struct net_device *dev,
1077 struct sk_buff *skb, 1078 struct sk_buff *skb,
1078 void *accel_priv) 1079 void *accel_priv,
1080 select_queue_fallback_t fallback)
1079{ 1081{
1080 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 1082 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
1081 struct ieee80211_local *local = sdata->local; 1083 struct ieee80211_local *local = sdata->local;
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 6a2bb37506c5..48a6a93db296 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -308,11 +308,27 @@ static bool packet_use_direct_xmit(const struct packet_sock *po)
308 return po->xmit == packet_direct_xmit; 308 return po->xmit == packet_direct_xmit;
309} 309}
310 310
311static u16 packet_pick_tx_queue(struct net_device *dev) 311static u16 __packet_pick_tx_queue(struct net_device *dev, struct sk_buff *skb)
312{ 312{
313 return (u16) raw_smp_processor_id() % dev->real_num_tx_queues; 313 return (u16) raw_smp_processor_id() % dev->real_num_tx_queues;
314} 314}
315 315
316static void packet_pick_tx_queue(struct net_device *dev, struct sk_buff *skb)
317{
318 const struct net_device_ops *ops = dev->netdev_ops;
319 u16 queue_index;
320
321 if (ops->ndo_select_queue) {
322 queue_index = ops->ndo_select_queue(dev, skb, NULL,
323 __packet_pick_tx_queue);
324 queue_index = netdev_cap_txqueue(dev, queue_index);
325 } else {
326 queue_index = __packet_pick_tx_queue(dev, skb);
327 }
328
329 skb_set_queue_mapping(skb, queue_index);
330}
331
316/* register_prot_hook must be invoked with the po->bind_lock held, 332/* register_prot_hook must be invoked with the po->bind_lock held,
317 * or from a context in which asynchronous accesses to the packet 333 * or from a context in which asynchronous accesses to the packet
318 * socket is not possible (packet_create()). 334 * socket is not possible (packet_create()).
@@ -2285,7 +2301,8 @@ static int tpacket_snd(struct packet_sock *po, struct msghdr *msg)
2285 } 2301 }
2286 } 2302 }
2287 2303
2288 skb_set_queue_mapping(skb, packet_pick_tx_queue(dev)); 2304 packet_pick_tx_queue(dev, skb);
2305
2289 skb->destructor = tpacket_destruct_skb; 2306 skb->destructor = tpacket_destruct_skb;
2290 __packet_set_status(po, ph, TP_STATUS_SENDING); 2307 __packet_set_status(po, ph, TP_STATUS_SENDING);
2291 packet_inc_pending(&po->tx_ring); 2308 packet_inc_pending(&po->tx_ring);
@@ -2499,7 +2516,8 @@ static int packet_snd(struct socket *sock, struct msghdr *msg, size_t len)
2499 skb->dev = dev; 2516 skb->dev = dev;
2500 skb->priority = sk->sk_priority; 2517 skb->priority = sk->sk_priority;
2501 skb->mark = sk->sk_mark; 2518 skb->mark = sk->sk_mark;
2502 skb_set_queue_mapping(skb, packet_pick_tx_queue(dev)); 2519
2520 packet_pick_tx_queue(dev, skb);
2503 2521
2504 if (po->has_vnet_hdr) { 2522 if (po->has_vnet_hdr) {
2505 if (vnet_hdr.flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) { 2523 if (vnet_hdr.flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) {
@@ -3786,7 +3804,7 @@ static int packet_set_ring(struct sock *sk, union tpacket_req_u *req_u,
3786 */ 3804 */
3787 if (!tx_ring) 3805 if (!tx_ring)
3788 init_prb_bdqc(po, rb, pg_vec, req_u, tx_ring); 3806 init_prb_bdqc(po, rb, pg_vec, req_u, tx_ring);
3789 break; 3807 break;
3790 default: 3808 default:
3791 break; 3809 break;
3792 } 3810 }
diff --git a/net/sched/sch_pie.c b/net/sched/sch_pie.c
index a255d0200a59..fefeeb73f15f 100644
--- a/net/sched/sch_pie.c
+++ b/net/sched/sch_pie.c
@@ -15,6 +15,11 @@
15 * 15 *
16 * ECN support is added by Naeem Khademi <naeemk@ifi.uio.no> 16 * ECN support is added by Naeem Khademi <naeemk@ifi.uio.no>
17 * University of Oslo, Norway. 17 * University of Oslo, Norway.
18 *
19 * References:
20 * IETF draft submission: http://tools.ietf.org/html/draft-pan-aqm-pie-00
21 * IEEE Conference on High Performance Switching and Routing 2013 :
22 * "PIE: A * Lightweight Control Scheme to Address the Bufferbloat Problem"
18 */ 23 */
19 24
20#include <linux/module.h> 25#include <linux/module.h>
@@ -36,7 +41,7 @@ struct pie_params {
36 psched_time_t target; /* user specified target delay in pschedtime */ 41 psched_time_t target; /* user specified target delay in pschedtime */
37 u32 tupdate; /* timer frequency (in jiffies) */ 42 u32 tupdate; /* timer frequency (in jiffies) */
38 u32 limit; /* number of packets that can be enqueued */ 43 u32 limit; /* number of packets that can be enqueued */
39 u32 alpha; /* alpha and beta are between -4 and 4 */ 44 u32 alpha; /* alpha and beta are between 0 and 32 */
40 u32 beta; /* and are used for shift relative to 1 */ 45 u32 beta; /* and are used for shift relative to 1 */
41 bool ecn; /* true if ecn is enabled */ 46 bool ecn; /* true if ecn is enabled */
42 bool bytemode; /* to scale drop early prob based on pkt size */ 47 bool bytemode; /* to scale drop early prob based on pkt size */
@@ -326,10 +331,16 @@ static void calculate_probability(struct Qdisc *sch)
326 if (qdelay == 0 && qlen != 0) 331 if (qdelay == 0 && qlen != 0)
327 update_prob = false; 332 update_prob = false;
328 333
329 /* Add ranges for alpha and beta, more aggressive for high dropping 334 /* In the algorithm, alpha and beta are between 0 and 2 with typical
330 * mode and gentle steps for light dropping mode 335 * value for alpha as 0.125. In this implementation, we use values 0-32
331 * In light dropping mode, take gentle steps; in medium dropping mode, 336 * passed from user space to represent this. Also, alpha and beta have
332 * take medium steps; in high dropping mode, take big steps. 337 * unit of HZ and need to be scaled before they can used to update
338 * probability. alpha/beta are updated locally below by 1) scaling them
339 * appropriately 2) scaling down by 16 to come to 0-2 range.
340 * Please see paper for details.
341 *
342 * We scale alpha and beta differently depending on whether we are in
343 * light, medium or high dropping mode.
333 */ 344 */
334 if (q->vars.prob < MAX_PROB / 100) { 345 if (q->vars.prob < MAX_PROB / 100) {
335 alpha = 346 alpha =
diff --git a/net/sctp/associola.c b/net/sctp/associola.c
index 5ae609200674..f558433537b8 100644
--- a/net/sctp/associola.c
+++ b/net/sctp/associola.c
@@ -1367,44 +1367,35 @@ static inline bool sctp_peer_needs_update(struct sctp_association *asoc)
1367 return false; 1367 return false;
1368} 1368}
1369 1369
1370/* Increase asoc's rwnd by len and send any window update SACK if needed. */ 1370/* Update asoc's rwnd for the approximated state in the buffer,
1371void sctp_assoc_rwnd_increase(struct sctp_association *asoc, unsigned int len) 1371 * and check whether SACK needs to be sent.
1372 */
1373void sctp_assoc_rwnd_update(struct sctp_association *asoc, bool update_peer)
1372{ 1374{
1375 int rx_count;
1373 struct sctp_chunk *sack; 1376 struct sctp_chunk *sack;
1374 struct timer_list *timer; 1377 struct timer_list *timer;
1375 1378
1376 if (asoc->rwnd_over) { 1379 if (asoc->ep->rcvbuf_policy)
1377 if (asoc->rwnd_over >= len) { 1380 rx_count = atomic_read(&asoc->rmem_alloc);
1378 asoc->rwnd_over -= len; 1381 else
1379 } else { 1382 rx_count = atomic_read(&asoc->base.sk->sk_rmem_alloc);
1380 asoc->rwnd += (len - asoc->rwnd_over);
1381 asoc->rwnd_over = 0;
1382 }
1383 } else {
1384 asoc->rwnd += len;
1385 }
1386 1383
1387 /* If we had window pressure, start recovering it 1384 if ((asoc->base.sk->sk_rcvbuf - rx_count) > 0)
1388 * once our rwnd had reached the accumulated pressure 1385 asoc->rwnd = (asoc->base.sk->sk_rcvbuf - rx_count) >> 1;
1389 * threshold. The idea is to recover slowly, but up 1386 else
1390 * to the initial advertised window. 1387 asoc->rwnd = 0;
1391 */
1392 if (asoc->rwnd_press && asoc->rwnd >= asoc->rwnd_press) {
1393 int change = min(asoc->pathmtu, asoc->rwnd_press);
1394 asoc->rwnd += change;
1395 asoc->rwnd_press -= change;
1396 }
1397 1388
1398 pr_debug("%s: asoc:%p rwnd increased by %d to (%u, %u) - %u\n", 1389 pr_debug("%s: asoc:%p rwnd=%u, rx_count=%d, sk_rcvbuf=%d\n",
1399 __func__, asoc, len, asoc->rwnd, asoc->rwnd_over, 1390 __func__, asoc, asoc->rwnd, rx_count,
1400 asoc->a_rwnd); 1391 asoc->base.sk->sk_rcvbuf);
1401 1392
1402 /* Send a window update SACK if the rwnd has increased by at least the 1393 /* Send a window update SACK if the rwnd has increased by at least the
1403 * minimum of the association's PMTU and half of the receive buffer. 1394 * minimum of the association's PMTU and half of the receive buffer.
1404 * The algorithm used is similar to the one described in 1395 * The algorithm used is similar to the one described in
1405 * Section 4.2.3.3 of RFC 1122. 1396 * Section 4.2.3.3 of RFC 1122.
1406 */ 1397 */
1407 if (sctp_peer_needs_update(asoc)) { 1398 if (update_peer && sctp_peer_needs_update(asoc)) {
1408 asoc->a_rwnd = asoc->rwnd; 1399 asoc->a_rwnd = asoc->rwnd;
1409 1400
1410 pr_debug("%s: sending window update SACK- asoc:%p rwnd:%u " 1401 pr_debug("%s: sending window update SACK- asoc:%p rwnd:%u "
@@ -1426,45 +1417,6 @@ void sctp_assoc_rwnd_increase(struct sctp_association *asoc, unsigned int len)
1426 } 1417 }
1427} 1418}
1428 1419
1429/* Decrease asoc's rwnd by len. */
1430void sctp_assoc_rwnd_decrease(struct sctp_association *asoc, unsigned int len)
1431{
1432 int rx_count;
1433 int over = 0;
1434
1435 if (unlikely(!asoc->rwnd || asoc->rwnd_over))
1436 pr_debug("%s: association:%p has asoc->rwnd:%u, "
1437 "asoc->rwnd_over:%u!\n", __func__, asoc,
1438 asoc->rwnd, asoc->rwnd_over);
1439
1440 if (asoc->ep->rcvbuf_policy)
1441 rx_count = atomic_read(&asoc->rmem_alloc);
1442 else
1443 rx_count = atomic_read(&asoc->base.sk->sk_rmem_alloc);
1444
1445 /* If we've reached or overflowed our receive buffer, announce
1446 * a 0 rwnd if rwnd would still be positive. Store the
1447 * the potential pressure overflow so that the window can be restored
1448 * back to original value.
1449 */
1450 if (rx_count >= asoc->base.sk->sk_rcvbuf)
1451 over = 1;
1452
1453 if (asoc->rwnd >= len) {
1454 asoc->rwnd -= len;
1455 if (over) {
1456 asoc->rwnd_press += asoc->rwnd;
1457 asoc->rwnd = 0;
1458 }
1459 } else {
1460 asoc->rwnd_over = len - asoc->rwnd;
1461 asoc->rwnd = 0;
1462 }
1463
1464 pr_debug("%s: asoc:%p rwnd decreased by %d to (%u, %u, %u)\n",
1465 __func__, asoc, len, asoc->rwnd, asoc->rwnd_over,
1466 asoc->rwnd_press);
1467}
1468 1420
1469/* Build the bind address list for the association based on info from the 1421/* Build the bind address list for the association based on info from the
1470 * local endpoint and the remote peer. 1422 * local endpoint and the remote peer.
diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c
index 483dcd71b3c5..591b44d3b7de 100644
--- a/net/sctp/sm_statefuns.c
+++ b/net/sctp/sm_statefuns.c
@@ -6176,7 +6176,7 @@ static int sctp_eat_data(const struct sctp_association *asoc,
6176 * PMTU. In cases, such as loopback, this might be a rather 6176 * PMTU. In cases, such as loopback, this might be a rather
6177 * large spill over. 6177 * large spill over.
6178 */ 6178 */
6179 if ((!chunk->data_accepted) && (!asoc->rwnd || asoc->rwnd_over || 6179 if ((!chunk->data_accepted) && (!asoc->rwnd ||
6180 (datalen > asoc->rwnd + asoc->frag_point))) { 6180 (datalen > asoc->rwnd + asoc->frag_point))) {
6181 6181
6182 /* If this is the next TSN, consider reneging to make 6182 /* If this is the next TSN, consider reneging to make
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 9e91d6e5df63..981aaf8b6ace 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -64,6 +64,7 @@
64#include <linux/crypto.h> 64#include <linux/crypto.h>
65#include <linux/slab.h> 65#include <linux/slab.h>
66#include <linux/file.h> 66#include <linux/file.h>
67#include <linux/compat.h>
67 68
68#include <net/ip.h> 69#include <net/ip.h>
69#include <net/icmp.h> 70#include <net/icmp.h>
@@ -1368,11 +1369,19 @@ static int sctp_setsockopt_connectx(struct sock *sk,
1368/* 1369/*
1369 * New (hopefully final) interface for the API. 1370 * New (hopefully final) interface for the API.
1370 * We use the sctp_getaddrs_old structure so that use-space library 1371 * We use the sctp_getaddrs_old structure so that use-space library
1371 * can avoid any unnecessary allocations. The only defferent part 1372 * can avoid any unnecessary allocations. The only different part
1372 * is that we store the actual length of the address buffer into the 1373 * is that we store the actual length of the address buffer into the
1373 * addrs_num structure member. That way we can re-use the existing 1374 * addrs_num structure member. That way we can re-use the existing
1374 * code. 1375 * code.
1375 */ 1376 */
1377#ifdef CONFIG_COMPAT
1378struct compat_sctp_getaddrs_old {
1379 sctp_assoc_t assoc_id;
1380 s32 addr_num;
1381 compat_uptr_t addrs; /* struct sockaddr * */
1382};
1383#endif
1384
1376static int sctp_getsockopt_connectx3(struct sock *sk, int len, 1385static int sctp_getsockopt_connectx3(struct sock *sk, int len,
1377 char __user *optval, 1386 char __user *optval,
1378 int __user *optlen) 1387 int __user *optlen)
@@ -1381,16 +1390,30 @@ static int sctp_getsockopt_connectx3(struct sock *sk, int len,
1381 sctp_assoc_t assoc_id = 0; 1390 sctp_assoc_t assoc_id = 0;
1382 int err = 0; 1391 int err = 0;
1383 1392
1384 if (len < sizeof(param)) 1393#ifdef CONFIG_COMPAT
1385 return -EINVAL; 1394 if (is_compat_task()) {
1395 struct compat_sctp_getaddrs_old param32;
1386 1396
1387 if (copy_from_user(&param, optval, sizeof(param))) 1397 if (len < sizeof(param32))
1388 return -EFAULT; 1398 return -EINVAL;
1399 if (copy_from_user(&param32, optval, sizeof(param32)))
1400 return -EFAULT;
1389 1401
1390 err = __sctp_setsockopt_connectx(sk, 1402 param.assoc_id = param32.assoc_id;
1391 (struct sockaddr __user *)param.addrs, 1403 param.addr_num = param32.addr_num;
1392 param.addr_num, &assoc_id); 1404 param.addrs = compat_ptr(param32.addrs);
1405 } else
1406#endif
1407 {
1408 if (len < sizeof(param))
1409 return -EINVAL;
1410 if (copy_from_user(&param, optval, sizeof(param)))
1411 return -EFAULT;
1412 }
1393 1413
1414 err = __sctp_setsockopt_connectx(sk, (struct sockaddr __user *)
1415 param.addrs, param.addr_num,
1416 &assoc_id);
1394 if (err == 0 || err == -EINPROGRESS) { 1417 if (err == 0 || err == -EINPROGRESS) {
1395 if (copy_to_user(optval, &assoc_id, sizeof(assoc_id))) 1418 if (copy_to_user(optval, &assoc_id, sizeof(assoc_id)))
1396 return -EFAULT; 1419 return -EFAULT;
@@ -2092,12 +2115,6 @@ static int sctp_recvmsg(struct kiocb *iocb, struct sock *sk,
2092 sctp_skb_pull(skb, copied); 2115 sctp_skb_pull(skb, copied);
2093 skb_queue_head(&sk->sk_receive_queue, skb); 2116 skb_queue_head(&sk->sk_receive_queue, skb);
2094 2117
2095 /* When only partial message is copied to the user, increase
2096 * rwnd by that amount. If all the data in the skb is read,
2097 * rwnd is updated when the event is freed.
2098 */
2099 if (!sctp_ulpevent_is_notification(event))
2100 sctp_assoc_rwnd_increase(event->asoc, copied);
2101 goto out; 2118 goto out;
2102 } else if ((event->msg_flags & MSG_NOTIFICATION) || 2119 } else if ((event->msg_flags & MSG_NOTIFICATION) ||
2103 (event->msg_flags & MSG_EOR)) 2120 (event->msg_flags & MSG_EOR))
diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
index 7135e617ab0f..35c8923b5554 100644
--- a/net/sctp/sysctl.c
+++ b/net/sctp/sysctl.c
@@ -151,6 +151,7 @@ static struct ctl_table sctp_net_table[] = {
151 }, 151 },
152 { 152 {
153 .procname = "cookie_hmac_alg", 153 .procname = "cookie_hmac_alg",
154 .data = &init_net.sctp.sctp_hmac_alg,
154 .maxlen = 8, 155 .maxlen = 8,
155 .mode = 0644, 156 .mode = 0644,
156 .proc_handler = proc_sctp_do_hmac_alg, 157 .proc_handler = proc_sctp_do_hmac_alg,
@@ -401,15 +402,18 @@ static int proc_sctp_do_rto_max(struct ctl_table *ctl, int write,
401 402
402int sctp_sysctl_net_register(struct net *net) 403int sctp_sysctl_net_register(struct net *net)
403{ 404{
404 struct ctl_table *table; 405 struct ctl_table *table = sctp_net_table;
405 int i; 406
407 if (!net_eq(net, &init_net)) {
408 int i;
406 409
407 table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL); 410 table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
408 if (!table) 411 if (!table)
409 return -ENOMEM; 412 return -ENOMEM;
410 413
411 for (i = 0; table[i].data; i++) 414 for (i = 0; table[i].data; i++)
412 table[i].data += (char *)(&net->sctp) - (char *)&init_net.sctp; 415 table[i].data += (char *)(&net->sctp) - (char *)&init_net.sctp;
416 }
413 417
414 net->sctp.sysctl_header = register_net_sysctl(net, "net/sctp", table); 418 net->sctp.sysctl_header = register_net_sysctl(net, "net/sctp", table);
415 return 0; 419 return 0;
diff --git a/net/sctp/ulpevent.c b/net/sctp/ulpevent.c
index 85c64658bd0b..8d198ae03606 100644
--- a/net/sctp/ulpevent.c
+++ b/net/sctp/ulpevent.c
@@ -989,7 +989,7 @@ static void sctp_ulpevent_receive_data(struct sctp_ulpevent *event,
989 skb = sctp_event2skb(event); 989 skb = sctp_event2skb(event);
990 /* Set the owner and charge rwnd for bytes received. */ 990 /* Set the owner and charge rwnd for bytes received. */
991 sctp_ulpevent_set_owner(event, asoc); 991 sctp_ulpevent_set_owner(event, asoc);
992 sctp_assoc_rwnd_decrease(asoc, skb_headlen(skb)); 992 sctp_assoc_rwnd_update(asoc, false);
993 993
994 if (!skb->data_len) 994 if (!skb->data_len)
995 return; 995 return;
@@ -1011,6 +1011,7 @@ static void sctp_ulpevent_release_data(struct sctp_ulpevent *event)
1011{ 1011{
1012 struct sk_buff *skb, *frag; 1012 struct sk_buff *skb, *frag;
1013 unsigned int len; 1013 unsigned int len;
1014 struct sctp_association *asoc;
1014 1015
1015 /* Current stack structures assume that the rcv buffer is 1016 /* Current stack structures assume that the rcv buffer is
1016 * per socket. For UDP style sockets this is not true as 1017 * per socket. For UDP style sockets this is not true as
@@ -1035,8 +1036,11 @@ static void sctp_ulpevent_release_data(struct sctp_ulpevent *event)
1035 } 1036 }
1036 1037
1037done: 1038done:
1038 sctp_assoc_rwnd_increase(event->asoc, len); 1039 asoc = event->asoc;
1040 sctp_association_hold(asoc);
1039 sctp_ulpevent_release_owner(event); 1041 sctp_ulpevent_release_owner(event);
1042 sctp_assoc_rwnd_update(asoc, true);
1043 sctp_association_put(asoc);
1040} 1044}
1041 1045
1042static void sctp_ulpevent_release_frag_data(struct sctp_ulpevent *event) 1046static void sctp_ulpevent_release_frag_data(struct sctp_ulpevent *event)
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/core.h b/net/tipc/core.h
index 1ff477b0450d..5569d96b4da3 100644
--- a/net/tipc/core.h
+++ b/net/tipc/core.h
@@ -192,6 +192,7 @@ static inline void k_term_timer(struct timer_list *timer)
192 192
193struct tipc_skb_cb { 193struct tipc_skb_cb {
194 void *handle; 194 void *handle;
195 bool deferred;
195}; 196};
196 197
197#define TIPC_SKB_CB(__skb) ((struct tipc_skb_cb *)&((__skb)->cb[0])) 198#define TIPC_SKB_CB(__skb) ((struct tipc_skb_cb *)&((__skb)->cb[0]))
diff --git a/net/tipc/link.c b/net/tipc/link.c
index d4b5de41b682..da6018beb6eb 100644
--- a/net/tipc/link.c
+++ b/net/tipc/link.c
@@ -1391,6 +1391,12 @@ static int link_recv_buf_validate(struct sk_buff *buf)
1391 u32 hdr_size; 1391 u32 hdr_size;
1392 u32 min_hdr_size; 1392 u32 min_hdr_size;
1393 1393
1394 /* If this packet comes from the defer queue, the skb has already
1395 * been validated
1396 */
1397 if (unlikely(TIPC_SKB_CB(buf)->deferred))
1398 return 1;
1399
1394 if (unlikely(buf->len < MIN_H_SIZE)) 1400 if (unlikely(buf->len < MIN_H_SIZE))
1395 return 0; 1401 return 0;
1396 1402
@@ -1703,6 +1709,7 @@ static void link_handle_out_of_seq_msg(struct tipc_link *l_ptr,
1703 &l_ptr->newest_deferred_in, buf)) { 1709 &l_ptr->newest_deferred_in, buf)) {
1704 l_ptr->deferred_inqueue_sz++; 1710 l_ptr->deferred_inqueue_sz++;
1705 l_ptr->stats.deferred_recv++; 1711 l_ptr->stats.deferred_recv++;
1712 TIPC_SKB_CB(buf)->deferred = true;
1706 if ((l_ptr->deferred_inqueue_sz % 16) == 1) 1713 if ((l_ptr->deferred_inqueue_sz % 16) == 1)
1707 tipc_link_send_proto_msg(l_ptr, STATE_MSG, 0, 0, 0, 0, 0); 1714 tipc_link_send_proto_msg(l_ptr, STATE_MSG, 0, 0, 0, 0, 0);
1708 } else 1715 } else
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/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..6eb903cc6237 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),
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
index 7311badf6a94..a2f11bf8155c 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
@@ -1795,6 +1796,12 @@ static const struct hda_pintbl intel_dg45id_pin_configs[] = {
1795 {} 1796 {}
1796}; 1797};
1797 1798
1799static const struct hda_pintbl stac92hd89xx_hp_front_jack_pin_configs[] = {
1800 { 0x0a, 0x02214030 },
1801 { 0x0b, 0x02A19010 },
1802 {}
1803};
1804
1798static void stac92hd73xx_fixup_ref(struct hda_codec *codec, 1805static void stac92hd73xx_fixup_ref(struct hda_codec *codec,
1799 const struct hda_fixup *fix, int action) 1806 const struct hda_fixup *fix, int action)
1800{ 1807{
@@ -1913,6 +1920,10 @@ static const struct hda_fixup stac92hd73xx_fixups[] = {
1913 [STAC_92HD73XX_NO_JD] = { 1920 [STAC_92HD73XX_NO_JD] = {
1914 .type = HDA_FIXUP_FUNC, 1921 .type = HDA_FIXUP_FUNC,
1915 .v.func = stac92hd73xx_fixup_no_jd, 1922 .v.func = stac92hd73xx_fixup_no_jd,
1923 },
1924 [STAC_92HD89XX_HP_FRONT_JACK] = {
1925 .type = HDA_FIXUP_PINS,
1926 .v.pins = stac92hd89xx_hp_front_jack_pin_configs,
1916 } 1927 }
1917}; 1928};
1918 1929
@@ -1973,6 +1984,8 @@ static const struct snd_pci_quirk stac92hd73xx_fixup_tbl[] = {
1973 "Alienware M17x", STAC_ALIENWARE_M17X), 1984 "Alienware M17x", STAC_ALIENWARE_M17X),
1974 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0490, 1985 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0490,
1975 "Alienware M17x R3", STAC_DELL_EQ), 1986 "Alienware M17x R3", STAC_DELL_EQ),
1987 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x2b17,
1988 "unknown HP", STAC_92HD89XX_HP_FRONT_JACK),
1976 {} /* terminator */ 1989 {} /* terminator */
1977}; 1990};
1978 1991
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/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/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/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/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/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/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/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);