aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/DocBook/media_api.tmpl4
-rw-r--r--Documentation/devicetree/bindings/i2c/i2c-mv64xxx.txt2
-rw-r--r--Documentation/devicetree/bindings/regulator/palmas-pmic.txt4
-rw-r--r--Documentation/kernel-parameters.txt57
-rw-r--r--Documentation/laptops/asus-laptop.txt8
-rw-r--r--Documentation/laptops/sony-laptop.txt8
-rw-r--r--Documentation/laptops/thinkpad-acpi.txt73
-rw-r--r--MAINTAINERS26
-rw-r--r--Makefile2
-rw-r--r--arch/Kconfig6
-rw-r--r--arch/arc/lib/strchr-700.S10
-rw-r--r--arch/arm/boot/dts/at91sam9n12ek.dts4
-rw-r--r--arch/arm/boot/dts/at91sam9x5ek.dtsi5
-rw-r--r--arch/arm/boot/dts/msm8960-cdp.dts4
-rw-r--r--arch/arm/boot/dts/omap5-uevm.dts78
-rw-r--r--arch/arm/boot/dts/stih41x.dtsi2
-rw-r--r--arch/arm/boot/dts/tegra20-colibri-512.dtsi1
-rw-r--r--arch/arm/boot/dts/tegra20-seaboard.dts2
-rw-r--r--arch/arm/boot/dts/tegra20-trimslice.dts2
-rw-r--r--arch/arm/boot/dts/tegra20-whistler.dts4
-rw-r--r--arch/arm/include/asm/smp_plat.h3
-rw-r--r--arch/arm/include/asm/spinlock.h51
-rw-r--r--arch/arm/include/asm/tlb.h7
-rw-r--r--arch/arm/kernel/entry-armv.S3
-rw-r--r--arch/arm/kernel/fiq.c9
-rw-r--r--arch/arm/kernel/machine_kexec.c21
-rw-r--r--arch/arm/kernel/perf_event.c10
-rw-r--r--arch/arm/kernel/process.c2
-rw-r--r--arch/arm/kernel/smp.c10
-rw-r--r--arch/arm/kvm/coproc.c26
-rw-r--r--arch/arm/kvm/coproc.h3
-rw-r--r--arch/arm/kvm/coproc_a15.c6
-rw-r--r--arch/arm/kvm/mmio.c3
-rw-r--r--arch/arm/kvm/mmu.c36
-rw-r--r--arch/arm/mach-at91/at91sam9x5.c2
-rw-r--r--arch/arm/mach-davinci/board-dm355-leopard.c1
-rw-r--r--arch/arm/mach-davinci/board-dm644x-evm.c1
-rw-r--r--arch/arm/mach-davinci/board-dm646x-evm.c1
-rw-r--r--arch/arm/mach-davinci/board-neuros-osd2.c1
-rw-r--r--arch/arm/mach-msm/Kconfig3
-rw-r--r--arch/arm/mach-msm/gpiomux-v1.c33
-rw-r--r--arch/arm/mach-msm/gpiomux.h10
-rw-r--r--arch/arm/mach-omap2/board-n8x0.c4
-rw-r--r--arch/arm/mach-omap2/board-rx51.c2
-rw-r--r--arch/arm/mach-omap2/dss-common.c2
-rw-r--r--arch/arm/mach-omap2/omap_device.c18
-rw-r--r--arch/arm/mach-omap2/omap_hwmod.c2
-rw-r--r--arch/arm/mach-omap2/omap_hwmod.h50
-rw-r--r--arch/arm/mach-omap2/omap_hwmod_2xxx_ipblock_data.c6
-rw-r--r--arch/arm/mach-omap2/omap_hwmod_33xx_data.c3
-rw-r--r--arch/arm/mach-omap2/omap_hwmod_3xxx_data.c9
-rw-r--r--arch/arm/mach-omap2/omap_hwmod_44xx_data.c5
-rw-r--r--arch/arm/mach-omap2/omap_hwmod_54xx_data.c3
-rw-r--r--arch/arm/mach-omap2/serial.c11
-rw-r--r--arch/arm/mach-omap2/usb-musb.c5
-rw-r--r--arch/arm/mach-shmobile/board-armadillo800eva.c3
-rw-r--r--arch/arm/mach-shmobile/board-bockw.c8
-rw-r--r--arch/arm/mach-shmobile/board-lager.c2
-rw-r--r--arch/arm/mach-sti/headsmp.S2
-rw-r--r--arch/arm/mm/Kconfig9
-rw-r--r--arch/arm/plat-samsung/init.c5
-rw-r--r--arch/arm/xen/enlighten.c1
-rw-r--r--arch/arm64/include/asm/kvm_asm.h17
-rw-r--r--arch/arm64/include/asm/kvm_host.h2
-rw-r--r--arch/arm64/include/asm/tlb.h7
-rw-r--r--arch/arm64/kernel/perf_event.c10
-rw-r--r--arch/arm64/kvm/hyp.S13
-rw-r--r--arch/arm64/kvm/sys_regs.c3
-rw-r--r--arch/avr32/boards/atngw100/mrmt.c1
-rw-r--r--arch/hexagon/Kconfig1
-rw-r--r--arch/ia64/include/asm/tlb.h9
-rw-r--r--arch/m68k/emu/natfeat.c23
-rw-r--r--arch/m68k/include/asm/div64.h9
-rw-r--r--arch/microblaze/Kconfig2
-rw-r--r--arch/mips/include/asm/cpu-features.h2
-rw-r--r--arch/mips/kernel/smp-bmips.c10
-rw-r--r--arch/mips/math-emu/cp1emu.c26
-rw-r--r--arch/mips/oprofile/op_model_mipsxx.c2
-rw-r--r--arch/mips/pnx833x/common/platform.c2
-rw-r--r--arch/openrisc/Kconfig1
-rw-r--r--arch/powerpc/Kconfig2
-rw-r--r--arch/powerpc/include/asm/processor.h4
-rw-r--r--arch/powerpc/include/asm/reg.h31
-rw-r--r--arch/powerpc/include/asm/switch_to.h9
-rw-r--r--arch/powerpc/kernel/asm-offsets.c3
-rw-r--r--arch/powerpc/kernel/eeh.c2
-rw-r--r--arch/powerpc/kernel/entry_64.S36
-rw-r--r--arch/powerpc/kernel/exceptions-64s.S5
-rw-r--r--arch/powerpc/kernel/process.c10
-rw-r--r--arch/powerpc/kernel/tm.S20
-rw-r--r--arch/powerpc/kernel/traps.c58
-rw-r--r--arch/powerpc/kvm/book3s_hv.c4
-rw-r--r--arch/powerpc/kvm/book3s_pr.c5
-rw-r--r--arch/powerpc/platforms/pseries/nvram.c80
-rw-r--r--arch/s390/Kconfig9
-rw-r--r--arch/s390/boot/compressed/Makefile9
-rw-r--r--arch/s390/boot/compressed/misc.c4
-rw-r--r--arch/s390/include/asm/bitops.h2
-rw-r--r--arch/s390/include/asm/tlb.h8
-rw-r--r--arch/s390/kernel/perf_event.c9
-rw-r--r--arch/s390/kernel/setup.c1
-rw-r--r--arch/s390/kvm/kvm-s390.c21
-rw-r--r--arch/s390/kvm/priv.c4
-rw-r--r--arch/s390/mm/init.c1
-rw-r--r--arch/s390/oprofile/init.c2
-rw-r--r--arch/score/Kconfig2
-rw-r--r--arch/sh/include/asm/tlb.h6
-rw-r--r--arch/um/include/asm/tlb.h6
-rw-r--r--arch/x86/boot/compressed/eboot.c2
-rw-r--r--arch/x86/include/asm/bootparam_utils.h4
-rw-r--r--arch/x86/include/asm/microcode_amd.h2
-rw-r--r--arch/x86/include/asm/pgtable-2level.h48
-rw-r--r--arch/x86/include/asm/pgtable-3level.h3
-rw-r--r--arch/x86/include/asm/pgtable.h30
-rw-r--r--arch/x86/include/asm/pgtable_types.h17
-rw-r--r--arch/x86/include/asm/spinlock.h4
-rw-r--r--arch/x86/kernel/cpu/amd.c20
-rw-r--r--arch/x86/kernel/cpu/perf_event_intel.c1
-rw-r--r--arch/x86/kernel/cpu/perf_event_intel_uncore.c4
-rw-r--r--arch/x86/kernel/early-quirks.c14
-rw-r--r--arch/x86/kernel/i387.c2
-rw-r--r--arch/x86/kernel/microcode_amd.c36
-rw-r--r--arch/x86/kernel/microcode_amd_early.c27
-rw-r--r--arch/x86/kernel/sys_x86_64.c2
-rw-r--r--arch/x86/kernel/tboot.c10
-rw-r--r--arch/x86/mm/mmap.c6
-rw-r--r--arch/x86/mm/srat.c11
-rw-r--r--arch/x86/pci/i386.c4
-rw-r--r--arch/x86/xen/setup.c22
-rw-r--r--arch/x86/xen/smp.c11
-rw-r--r--drivers/acpi/Kconfig18
-rw-r--r--drivers/acpi/ac.c1
-rw-r--r--drivers/acpi/acpi_pad.c1
-rw-r--r--drivers/acpi/acpi_platform.c24
-rw-r--r--drivers/acpi/acpica/acglobal.h7
-rw-r--r--drivers/acpi/acpica/aclocal.h4
-rw-r--r--drivers/acpi/acpica/acnamesp.h4
-rw-r--r--drivers/acpi/acpica/actables.h7
-rw-r--r--drivers/acpi/acpica/acutils.h4
-rw-r--r--drivers/acpi/acpica/evgpeinit.c11
-rw-r--r--drivers/acpi/acpica/exdump.c6
-rw-r--r--drivers/acpi/acpica/exoparg1.c48
-rw-r--r--drivers/acpi/acpica/hwesleep.c9
-rw-r--r--drivers/acpi/acpica/hwtimer.c13
-rw-r--r--drivers/acpi/acpica/nspredef.c16
-rw-r--r--drivers/acpi/acpica/nswalk.c26
-rw-r--r--drivers/acpi/acpica/nsxfeval.c16
-rw-r--r--drivers/acpi/acpica/nsxfname.c11
-rw-r--r--drivers/acpi/acpica/tbfadt.c4
-rw-r--r--drivers/acpi/acpica/tbxfroot.c12
-rw-r--r--drivers/acpi/acpica/uteval.c8
-rw-r--r--drivers/acpi/acpica/utglobal.c1
-rw-r--r--drivers/acpi/acpica/utosi.c77
-rw-r--r--drivers/acpi/acpica/utstring.c5
-rw-r--r--drivers/acpi/acpica/utxface.c29
-rw-r--r--drivers/acpi/battery.c21
-rw-r--r--drivers/acpi/bus.c142
-rw-r--r--drivers/acpi/button.c2
-rw-r--r--drivers/acpi/device_pm.c34
-rw-r--r--drivers/acpi/dock.c400
-rw-r--r--drivers/acpi/ec.c6
-rw-r--r--drivers/acpi/event.c106
-rw-r--r--drivers/acpi/fan.c4
-rw-r--r--drivers/acpi/internal.h1
-rw-r--r--drivers/acpi/numa.c2
-rw-r--r--drivers/acpi/osl.c86
-rw-r--r--drivers/acpi/pci_slot.c14
-rw-r--r--drivers/acpi/power.c6
-rw-r--r--drivers/acpi/processor_core.c2
-rw-r--r--drivers/acpi/processor_driver.c4
-rw-r--r--drivers/acpi/processor_perflib.c22
-rw-r--r--drivers/acpi/resource.c4
-rw-r--r--drivers/acpi/sbs.c15
-rw-r--r--drivers/acpi/scan.c223
-rw-r--r--drivers/acpi/sleep.c48
-rw-r--r--drivers/acpi/thermal.c37
-rw-r--r--drivers/acpi/utils.c70
-rw-r--r--drivers/acpi/video.c77
-rw-r--r--drivers/acpi/video_detect.c19
-rw-r--r--drivers/ata/libata-acpi.c4
-rw-r--r--drivers/ata/libata-pmp.c12
-rw-r--r--drivers/ata/pata_imx.c1
-rw-r--r--drivers/ata/sata_fsl.c5
-rw-r--r--drivers/ata/sata_highbank.c4
-rw-r--r--drivers/base/regmap/regcache.c3
-rw-r--r--drivers/block/aoe/aoecmd.c17
-rw-r--r--drivers/char/sonypi.c5
-rw-r--r--drivers/char/virtio_console.c70
-rw-r--r--drivers/clk/samsung/clk-exynos4.c64
-rw-r--r--drivers/clk/zynq/clkc.c13
-rw-r--r--drivers/dma/sh/shdma.c4
-rw-r--r--drivers/gpu/drm/ast/ast_ttm.c1
-rw-r--r--drivers/gpu/drm/cirrus/cirrus_ttm.c1
-rw-r--r--drivers/gpu/drm/drm_irq.c5
-rw-r--r--drivers/gpu/drm/gma500/psb_intel_sdvo.c3
-rw-r--r--drivers/gpu/drm/i915/i915_gem_dmabuf.c8
-rw-r--r--drivers/gpu/drm/i915/i915_reg.h14
-rw-r--r--drivers/gpu/drm/i915/intel_display.c90
-rw-r--r--drivers/gpu/drm/i915/intel_panel.c18
-rw-r--r--drivers/gpu/drm/i915/intel_pm.c18
-rw-r--r--drivers/gpu/drm/i915/intel_ringbuffer.c12
-rw-r--r--drivers/gpu/drm/mgag200/mgag200_ttm.c1
-rw-r--r--drivers/gpu/drm/nouveau/core/core/mm.c4
-rw-r--r--drivers/gpu/drm/nouveau/core/include/subdev/mc.h7
-rw-r--r--drivers/gpu/drm/nouveau/core/subdev/fb/ramnv49.c12
-rw-r--r--drivers/gpu/drm/nouveau/core/subdev/fb/ramnv4e.c4
-rw-r--r--drivers/gpu/drm/nouveau/core/subdev/ltcg/nvc0.c34
-rw-r--r--drivers/gpu/drm/nouveau/core/subdev/mc/base.c6
-rw-r--r--drivers/gpu/drm/nouveau/core/subdev/mc/nv04.c3
-rw-r--r--drivers/gpu/drm/nouveau/core/subdev/mc/nv44.c3
-rw-r--r--drivers/gpu/drm/nouveau/core/subdev/mc/nv50.c3
-rw-r--r--drivers/gpu/drm/nouveau/core/subdev/mc/nv98.c3
-rw-r--r--drivers/gpu/drm/nouveau/core/subdev/mc/nvc0.c3
-rw-r--r--drivers/gpu/drm/nouveau/dispnv04/crtc.c58
-rw-r--r--drivers/gpu/drm/nouveau/dispnv04/disp.h1
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_display.c3
-rw-r--r--drivers/gpu/drm/nouveau/nv40_pm.c2
-rw-r--r--drivers/gpu/drm/radeon/btc_dpm.c17
-rw-r--r--drivers/gpu/drm/radeon/cik.c18
-rw-r--r--drivers/gpu/drm/radeon/cypress_dpm.c17
-rw-r--r--drivers/gpu/drm/radeon/evergreen.c6
-rw-r--r--drivers/gpu/drm/radeon/evergreen_hdmi.c26
-rw-r--r--drivers/gpu/drm/radeon/evergreend.h3
-rw-r--r--drivers/gpu/drm/radeon/ni.c16
-rw-r--r--drivers/gpu/drm/radeon/ni_dpm.c17
-rw-r--r--drivers/gpu/drm/radeon/r600.c41
-rw-r--r--drivers/gpu/drm/radeon/r600_hdmi.c37
-rw-r--r--drivers/gpu/drm/radeon/r600d.h3
-rw-r--r--drivers/gpu/drm/radeon/radeon.h6
-rw-r--r--drivers/gpu/drm/radeon/radeon_asic.h2
-rw-r--r--drivers/gpu/drm/radeon/radeon_device.c3
-rw-r--r--drivers/gpu/drm/radeon/radeon_fence.c2
-rw-r--r--drivers/gpu/drm/radeon/radeon_gart.c1
-rw-r--r--drivers/gpu/drm/radeon/radeon_pm.c9
-rw-r--r--drivers/gpu/drm/radeon/radeon_uvd.c101
-rw-r--r--drivers/gpu/drm/radeon/rv6xx_dpm.c22
-rw-r--r--drivers/gpu/drm/radeon/rv770.c19
-rw-r--r--drivers/gpu/drm/radeon/rv770_dpm.c33
-rw-r--r--drivers/gpu/drm/radeon/rv770_dpm.h1
-rw-r--r--drivers/gpu/drm/radeon/si.c19
-rw-r--r--drivers/gpu/drm/radeon/si_dpm.c61
-rw-r--r--drivers/hid/hid-logitech-dj.c2
-rw-r--r--drivers/hwmon/adt7470.c2
-rw-r--r--drivers/i2c/busses/i2c-kempld.c4
-rw-r--r--drivers/i2c/busses/i2c-mxs.c2
-rw-r--r--drivers/ide/ide-acpi.c5
-rw-r--r--drivers/iio/adc/ti_am335x_adc.c30
-rw-r--r--drivers/iio/industrialio-trigger.c34
-rw-r--r--drivers/iio/light/adjd_s311.c3
-rw-r--r--drivers/md/dm-cache-policy-mq.c16
-rw-r--r--drivers/media/i2c/ml86v7667.c4
-rw-r--r--drivers/media/platform/coda.c2
-rw-r--r--drivers/media/platform/s5p-g2d/g2d.c1
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc_dec.c79
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc_enc.c46
-rw-r--r--drivers/media/usb/em28xx/em28xx-i2c.c2
-rw-r--r--drivers/media/usb/hdpvr/hdpvr-core.c11
-rw-r--r--drivers/media/usb/usbtv/Kconfig2
-rw-r--r--drivers/media/usb/usbtv/usbtv.c51
-rw-r--r--drivers/net/bonding/bond_main.c8
-rw-r--r--drivers/net/can/usb/peak_usb/pcan_usb.c2
-rw-r--r--drivers/net/ethernet/arc/emac_main.c2
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x.h7
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c53
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.h3
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h5
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c88
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c58
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c66
-rw-r--r--drivers/net/ethernet/broadcom/tg3.c13
-rw-r--r--drivers/net/ethernet/chelsio/cxgb3/sge.c107
-rw-r--r--drivers/net/ethernet/emulex/benet/be_cmds.c3
-rw-r--r--drivers/net/ethernet/emulex/benet/be_cmds.h6
-rw-r--r--drivers/net/ethernet/emulex/benet/be_main.c2
-rw-r--r--drivers/net/ethernet/marvell/skge.c68
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/cmd.c2
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/eq.c2
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/fw.c2
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/health.c29
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c58
-rw-r--r--drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c5
-rw-r--r--drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c3
-rw-r--r--drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c6
-rw-r--r--drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c6
-rw-r--r--drivers/net/ethernet/realtek/8139cp.c1
-rw-r--r--drivers/net/ethernet/realtek/r8169.c2
-rw-r--r--drivers/net/ethernet/sfc/filter.c2
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/ring_mode.c13
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_main.c111
-rw-r--r--drivers/net/ethernet/via/via-velocity.c4
-rw-r--r--drivers/net/irda/via-ircc.c6
-rw-r--r--drivers/net/macvlan.c4
-rw-r--r--drivers/net/macvtap.c30
-rw-r--r--drivers/net/phy/realtek.c4
-rw-r--r--drivers/net/tun.c6
-rw-r--r--drivers/net/usb/hso.c15
-rw-r--r--drivers/net/vxlan.c4
-rw-r--r--drivers/net/wireless/cw1200/sta.c7
-rw-r--r--drivers/net/wireless/hostap/hostap_ioctl.c4
-rw-r--r--drivers/net/wireless/iwlegacy/4965-mac.c16
-rw-r--r--drivers/net/wireless/iwlegacy/common.c1
-rw-r--r--drivers/net/wireless/iwlwifi/dvm/mac80211.c5
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-prph.h2
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/time-event.c33
-rw-r--r--drivers/net/wireless/iwlwifi/pcie/rx.c8
-rw-r--r--drivers/net/wireless/iwlwifi/pcie/trans.c10
-rw-r--r--drivers/net/wireless/zd1201.c4
-rw-r--r--drivers/of/fdt.c2
-rw-r--r--drivers/pci/hotplug/acpiphp.h55
-rw-r--r--drivers/pci/hotplug/acpiphp_core.c18
-rw-r--r--drivers/pci/hotplug/acpiphp_glue.c1035
-rw-r--r--drivers/pci/hotplug/acpiphp_ibm.c3
-rw-r--r--drivers/pci/pci-acpi.c18
-rw-r--r--drivers/pinctrl/pinctrl-sunxi.c66
-rw-r--r--drivers/pinctrl/pinctrl-sunxi.h2
-rw-r--r--drivers/platform/olpc/olpc-ec.c2
-rw-r--r--drivers/platform/x86/asus-laptop.c1
-rw-r--r--drivers/platform/x86/eeepc-laptop.c1
-rw-r--r--drivers/platform/x86/fujitsu-laptop.c4
-rw-r--r--drivers/platform/x86/hp-wmi.c16
-rw-r--r--drivers/platform/x86/panasonic-laptop.c3
-rw-r--r--drivers/platform/x86/sony-laptop.c12
-rw-r--r--drivers/platform/x86/thinkpad_acpi.c40
-rw-r--r--drivers/pnp/pnpacpi/core.c6
-rw-r--r--drivers/rtc/rtc-stmp3xxx.c35
-rw-r--r--drivers/s390/block/dasd.c6
-rw-r--r--drivers/s390/scsi/zfcp_erp.c29
-rw-r--r--drivers/s390/scsi/zfcp_qdio.c8
-rw-r--r--drivers/s390/scsi/zfcp_sysfs.c14
-rw-r--r--drivers/scsi/Kconfig1
-rw-r--r--drivers/scsi/fnic/fnic.h2
-rw-r--r--drivers/scsi/fnic/fnic_main.c22
-rw-r--r--drivers/scsi/megaraid/megaraid_sas_base.c20
-rw-r--r--drivers/scsi/scsi.c3
-rw-r--r--drivers/scsi/virtio_scsi.c2
-rw-r--r--drivers/spi/spi-davinci.c2
-rw-r--r--drivers/staging/comedi/drivers.c2
-rw-r--r--drivers/staging/zcache/zcache-main.c6
-rw-r--r--drivers/usb/class/usbtmc.c8
-rw-r--r--drivers/usb/core/hub.c5
-rw-r--r--drivers/usb/core/quirks.c6
-rw-r--r--drivers/usb/host/ehci-sched.c13
-rw-r--r--drivers/usb/host/ohci-pci.c5
-rw-r--r--drivers/usb/host/xhci-mem.c1
-rw-r--r--drivers/usb/host/xhci.c1
-rw-r--r--drivers/usb/misc/adutux.c2
-rw-r--r--drivers/usb/phy/phy-fsl-usb.h2
-rw-r--r--drivers/usb/phy/phy-fsm-usb.c2
-rw-r--r--drivers/usb/serial/keyspan.c2
-rw-r--r--drivers/usb/serial/mos7720.c21
-rw-r--r--drivers/usb/serial/mos7840.c2
-rw-r--r--drivers/usb/serial/ti_usb_3410_5052.c9
-rw-r--r--drivers/usb/serial/usb_wwan.c20
-rw-r--r--drivers/usb/wusbcore/wa-xfer.c9
-rw-r--r--drivers/video/mxsfb.c26
-rw-r--r--drivers/video/omap2/displays-new/connector-analog-tv.c18
-rw-r--r--drivers/xen/acpi.c41
-rw-r--r--drivers/xen/events.c13
-rw-r--r--fs/bfs/inode.c2
-rw-r--r--fs/bio.c20
-rw-r--r--fs/btrfs/backref.c48
-rw-r--r--fs/btrfs/ctree.c1
-rw-r--r--fs/btrfs/extent_io.c9
-rw-r--r--fs/btrfs/file.c62
-rw-r--r--fs/btrfs/inode.c52
-rw-r--r--fs/btrfs/transaction.c8
-rw-r--r--fs/btrfs/transaction.h2
-rw-r--r--fs/btrfs/tree-log.c5
-rw-r--r--fs/cifs/cifsencrypt.c14
-rw-r--r--fs/cifs/cifsfs.c11
-rw-r--r--fs/cifs/cifsglob.h4
-rw-r--r--fs/cifs/cifsproto.h4
-rw-r--r--fs/cifs/connect.c7
-rw-r--r--fs/cifs/file.c1
-rw-r--r--fs/cifs/link.c84
-rw-r--r--fs/cifs/readdir.c8
-rw-r--r--fs/cifs/sess.c6
-rw-r--r--fs/cifs/smb1ops.c1
-rw-r--r--fs/cifs/smb2transport.c9
-rw-r--r--fs/dcache.c11
-rw-r--r--fs/debugfs/inode.c69
-rw-r--r--fs/dlm/user.c1
-rw-r--r--fs/efs/inode.c2
-rw-r--r--fs/exec.c4
-rw-r--r--fs/ext4/ext4.h1
-rw-r--r--fs/ext4/ext4_jbd2.c8
-rw-r--r--fs/ext4/extents.c2
-rw-r--r--fs/ext4/file.c21
-rw-r--r--fs/ext4/ialloc.c10
-rw-r--r--fs/ext4/inode.c82
-rw-r--r--fs/ext4/ioctl.c6
-rw-r--r--fs/ext4/super.c20
-rw-r--r--fs/fcntl.c4
-rw-r--r--fs/gfs2/glock.c8
-rw-r--r--fs/gfs2/glops.c18
-rw-r--r--fs/gfs2/inode.c6
-rw-r--r--fs/gfs2/main.c2
-rw-r--r--fs/hugetlbfs/inode.c18
-rw-r--r--fs/lockd/clntlock.c13
-rw-r--r--fs/lockd/clntproc.c5
-rw-r--r--fs/namei.c10
-rw-r--r--fs/namespace.c2
-rw-r--r--fs/nfs/inode.c11
-rw-r--r--fs/nfs/nfs4proc.c8
-rw-r--r--fs/nfs/super.c4
-rw-r--r--fs/nfsd/nfs4proc.c2
-rw-r--r--fs/nfsd/nfs4state.c2
-rw-r--r--fs/nfsd/nfs4xdr.c5
-rw-r--r--fs/nilfs2/segbuf.c5
-rw-r--r--fs/ocfs2/aops.c2
-rw-r--r--fs/ocfs2/dir.c4
-rw-r--r--fs/ocfs2/file.c6
-rw-r--r--fs/ocfs2/journal.h2
-rw-r--r--fs/ocfs2/move_extents.c2
-rw-r--r--fs/ocfs2/refcounttree.c53
-rw-r--r--fs/ocfs2/refcounttree.h6
-rw-r--r--fs/open.c2
-rw-r--r--fs/proc/fd.c2
-rw-r--r--fs/proc/generic.c2
-rw-r--r--fs/proc/root.c4
-rw-r--r--fs/proc/task_mmu.c31
-rw-r--r--fs/reiserfs/procfs.c99
-rw-r--r--fs/reiserfs/super.c3
-rw-r--r--include/acpi/acpi_bus.h25
-rw-r--r--include/acpi/acpi_drivers.h14
-rw-r--r--include/acpi/acpixf.h8
-rw-r--r--include/acpi/actypes.h21
-rw-r--r--include/asm-generic/pgtable.h30
-rw-r--r--include/asm-generic/tlb.h2
-rw-r--r--include/linux/acpi.h7
-rw-r--r--include/linux/dcache.h1
-rw-r--r--include/linux/ftrace_event.h12
-rw-r--r--include/linux/iio/trigger.h3
-rw-r--r--include/linux/inetdevice.h34
-rw-r--r--include/linux/ipv6.h1
-rw-r--r--include/linux/kernel.h2
-rw-r--r--include/linux/mfd/ti_am335x_tscadc.h16
-rw-r--r--include/linux/mlx5/device.h22
-rw-r--r--include/linux/mlx5/driver.h7
-rw-r--r--include/linux/mm_types.h1
-rw-r--r--include/linux/pci-acpi.h10
-rw-r--r--include/linux/regmap.h1
-rw-r--r--include/linux/sched.h6
-rw-r--r--include/linux/spinlock.h14
-rw-r--r--include/linux/sunrpc/sched.h1
-rw-r--r--include/linux/swapops.h2
-rw-r--r--include/linux/syscalls.h5
-rw-r--r--include/linux/user_namespace.h1
-rw-r--r--include/linux/wait.h57
-rw-r--r--include/media/v4l2-ctrls.h1
-rw-r--r--include/net/busy_poll.h7
-rw-r--r--include/net/ip6_route.h2
-rw-r--r--include/net/ip_tunnels.h14
-rw-r--r--include/net/sch_generic.h9
-rw-r--r--include/uapi/linux/ip.h34
-rw-r--r--include/uapi/linux/pkt_sched.h10
-rw-r--r--include/uapi/linux/snmp.h2
-rw-r--r--include/xen/acpi.h8
-rw-r--r--include/xen/interface/platform.h7
-rw-r--r--init/Kconfig2
-rw-r--r--kernel/cgroup.c4
-rw-r--r--kernel/cpuset.c20
-rw-r--r--kernel/fork.c6
-rw-r--r--kernel/mutex.c4
-rw-r--r--kernel/power/qos.c20
-rw-r--r--kernel/printk/braille.c3
-rw-r--r--kernel/ptrace.c1
-rw-r--r--kernel/sched/core.c96
-rw-r--r--kernel/sched/cpupri.c4
-rw-r--r--kernel/sched/fair.c10
-rw-r--r--kernel/time/sched_clock.c2
-rw-r--r--kernel/time/tick-sched.c5
-rw-r--r--kernel/trace/ftrace.c87
-rw-r--r--kernel/trace/trace.c27
-rw-r--r--kernel/trace/trace_events.c200
-rw-r--r--kernel/trace/trace_events_filter.c17
-rw-r--r--kernel/trace/trace_kprobe.c21
-rw-r--r--kernel/trace/trace_uprobe.c51
-rw-r--r--kernel/user_namespace.c17
-rw-r--r--kernel/wait.c3
-rw-r--r--kernel/workqueue.c44
-rw-r--r--lib/earlycpio.c27
-rw-r--r--lib/lz4/lz4_compress.c4
-rw-r--r--lib/lz4/lz4_decompress.c6
-rw-r--r--lib/lz4/lz4hc_compress.c4
-rw-r--r--mm/fremap.c11
-rw-r--r--mm/hugetlb.c2
-rw-r--r--mm/memcontrol.c5
-rw-r--r--mm/memory.c49
-rw-r--r--mm/mmap.c4
-rw-r--r--mm/rmap.c14
-rw-r--r--mm/shmem.c8
-rw-r--r--mm/slub.c3
-rw-r--r--mm/swapfile.c19
-rw-r--r--net/8021q/vlan_core.c7
-rw-r--r--net/batman-adv/bridge_loop_avoidance.c2
-rw-r--r--net/batman-adv/gateway_client.c13
-rw-r--r--net/batman-adv/gateway_client.h3
-rw-r--r--net/batman-adv/soft-interface.c9
-rw-r--r--net/batman-adv/unicast.c23
-rw-r--r--net/bridge/br_fdb.c10
-rw-r--r--net/bridge/br_multicast.c2
-rw-r--r--net/bridge/br_netlink.c4
-rw-r--r--net/bridge/br_sysfs_br.c2
-rw-r--r--net/bridge/br_vlan.c4
-rw-r--r--net/core/flow_dissector.c1
-rw-r--r--net/core/neighbour.c10
-rw-r--r--net/core/rtnetlink.c4
-rw-r--r--net/ipv4/esp4.c2
-rw-r--r--net/ipv4/fib_trie.c5
-rw-r--r--net/ipv4/ip_gre.c2
-rw-r--r--net/ipv4/ip_tunnel_core.c4
-rw-r--r--net/ipv4/proc.c2
-rw-r--r--net/ipv4/tcp.c7
-rw-r--r--net/ipv4/tcp_cubic.c12
-rw-r--r--net/ipv6/addrconf.c10
-rw-r--r--net/ipv6/esp6.c2
-rw-r--r--net/ipv6/ip6_fib.c16
-rw-r--r--net/ipv6/ndisc.c4
-rw-r--r--net/ipv6/reassembly.c5
-rw-r--r--net/ipv6/route.c21
-rw-r--r--net/mac80211/mlme.c54
-rw-r--r--net/netfilter/nf_conntrack_proto_tcp.c12
-rw-r--r--net/netfilter/nfnetlink_log.c6
-rw-r--r--net/netfilter/nfnetlink_queue_core.c5
-rw-r--r--net/netfilter/xt_TCPMSS.c28
-rw-r--r--net/netfilter/xt_TCPOPTSTRIP.c10
-rw-r--r--net/openvswitch/actions.c1
-rw-r--r--net/openvswitch/datapath.c3
-rw-r--r--net/openvswitch/flow.c2
-rw-r--r--net/packet/af_packet.c2
-rw-r--r--net/sched/sch_api.c41
-rw-r--r--net/sched/sch_generic.c8
-rw-r--r--net/sched/sch_htb.c13
-rw-r--r--net/sctp/associola.c4
-rw-r--r--net/sctp/transport.c4
-rw-r--r--net/sunrpc/clnt.c4
-rw-r--r--net/sunrpc/netns.h1
-rw-r--r--net/sunrpc/rpcb_clnt.c48
-rw-r--r--net/tipc/bearer.c9
-rw-r--r--net/vmw_vsock/af_vsock.c2
-rw-r--r--net/wireless/core.c1
-rw-r--r--net/wireless/nl80211.c28
-rw-r--r--net/wireless/sme.c10
-rw-r--r--security/smack/smack_lsm.c24
-rw-r--r--sound/pci/hda/hda_generic.c6
-rw-r--r--sound/pci/hda/patch_realtek.c11
-rw-r--r--sound/soc/codecs/cs42l52.c5
-rw-r--r--sound/soc/codecs/sgtl5000.c18
-rw-r--r--sound/soc/soc-dapm.c7
-rw-r--r--sound/soc/tegra/tegra30_i2s.c2
-rw-r--r--sound/usb/6fire/comm.c38
-rw-r--r--sound/usb/6fire/comm.h2
-rw-r--r--sound/usb/6fire/midi.c16
-rw-r--r--sound/usb/6fire/midi.h6
-rw-r--r--sound/usb/6fire/pcm.c41
-rw-r--r--sound/usb/6fire/pcm.h2
-rw-r--r--sound/usb/endpoint.c13
-rw-r--r--sound/usb/mixer.c1
-rw-r--r--sound/usb/quirks.c6
560 files changed, 5596 insertions, 4224 deletions
diff --git a/Documentation/DocBook/media_api.tmpl b/Documentation/DocBook/media_api.tmpl
index 6a8b7158697f..9c92bb879b6d 100644
--- a/Documentation/DocBook/media_api.tmpl
+++ b/Documentation/DocBook/media_api.tmpl
@@ -1,6 +1,6 @@
1<?xml version="1.0"?> 1<?xml version="1.0"?>
2<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" 2<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [ 3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [
4<!ENTITY % media-entities SYSTEM "./media-entities.tmpl"> %media-entities; 4<!ENTITY % media-entities SYSTEM "./media-entities.tmpl"> %media-entities;
5<!ENTITY media-indices SYSTEM "./media-indices.tmpl"> 5<!ENTITY media-indices SYSTEM "./media-indices.tmpl">
6 6
diff --git a/Documentation/devicetree/bindings/i2c/i2c-mv64xxx.txt b/Documentation/devicetree/bindings/i2c/i2c-mv64xxx.txt
index a1ee681942cc..6113f9275f42 100644
--- a/Documentation/devicetree/bindings/i2c/i2c-mv64xxx.txt
+++ b/Documentation/devicetree/bindings/i2c/i2c-mv64xxx.txt
@@ -4,7 +4,7 @@
4Required properties : 4Required properties :
5 5
6 - reg : Offset and length of the register set for the device 6 - reg : Offset and length of the register set for the device
7 - compatible : Should be "marvell,mv64xxx-i2c" 7 - compatible : Should be "marvell,mv64xxx-i2c" or "allwinner,sun4i-i2c"
8 - interrupts : The interrupt number 8 - interrupts : The interrupt number
9 9
10Optional properties : 10Optional properties :
diff --git a/Documentation/devicetree/bindings/regulator/palmas-pmic.txt b/Documentation/devicetree/bindings/regulator/palmas-pmic.txt
index d5a308629c57..30b0581bb1ce 100644
--- a/Documentation/devicetree/bindings/regulator/palmas-pmic.txt
+++ b/Documentation/devicetree/bindings/regulator/palmas-pmic.txt
@@ -31,9 +31,8 @@ Optional nodes:
31 Optional sub-node properties: 31 Optional sub-node properties:
32 ti,warm-reset - maintain voltage during warm reset(boolean) 32 ti,warm-reset - maintain voltage during warm reset(boolean)
33 ti,roof-floor - control voltage selection by pin(boolean) 33 ti,roof-floor - control voltage selection by pin(boolean)
34 ti,sleep-mode - mode to adopt in pmic sleep 0 - off, 1 - auto, 34 ti,mode-sleep - mode to adopt in pmic sleep 0 - off, 1 - auto,
35 2 - eco, 3 - forced pwm 35 2 - eco, 3 - forced pwm
36 ti,tstep - slope control 0 - Jump, 1 10mV/us, 2 5mV/us, 3 2.5mV/us
37 ti,smps-range - OTP has the wrong range set for the hardware so override 36 ti,smps-range - OTP has the wrong range set for the hardware so override
38 0 - low range, 1 - high range. 37 0 - low range, 1 - high range.
39 38
@@ -59,7 +58,6 @@ pmic {
59 ti,warm-reset; 58 ti,warm-reset;
60 ti,roof-floor; 59 ti,roof-floor;
61 ti,mode-sleep = <0>; 60 ti,mode-sleep = <0>;
62 ti,tstep = <0>;
63 ti,smps-range = <1>; 61 ti,smps-range = <1>;
64 }; 62 };
65 63
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index 15356aca938c..03c196d90da3 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -235,10 +235,61 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
235 Format: To spoof as Windows 98: ="Microsoft Windows" 235 Format: To spoof as Windows 98: ="Microsoft Windows"
236 236
237 acpi_osi= [HW,ACPI] Modify list of supported OS interface strings 237 acpi_osi= [HW,ACPI] Modify list of supported OS interface strings
238 acpi_osi="string1" # add string1 -- only one string 238 acpi_osi="string1" # add string1
239 acpi_osi="!string2" # remove built-in string2 239 acpi_osi="!string2" # remove string2
240 acpi_osi=!* # remove all strings
241 acpi_osi=! # disable all built-in OS vendor
242 strings
240 acpi_osi= # disable all strings 243 acpi_osi= # disable all strings
241 244
245 'acpi_osi=!' can be used in combination with single or
246 multiple 'acpi_osi="string1"' to support specific OS
247 vendor string(s). Note that such command can only
248 affect the default state of the OS vendor strings, thus
249 it cannot affect the default state of the feature group
250 strings and the current state of the OS vendor strings,
251 specifying it multiple times through kernel command line
252 is meaningless. This command is useful when one do not
253 care about the state of the feature group strings which
254 should be controlled by the OSPM.
255 Examples:
256 1. 'acpi_osi=! acpi_osi="Windows 2000"' is equivalent
257 to 'acpi_osi="Windows 2000" acpi_osi=!', they all
258 can make '_OSI("Windows 2000")' TRUE.
259
260 'acpi_osi=' cannot be used in combination with other
261 'acpi_osi=' command lines, the _OSI method will not
262 exist in the ACPI namespace. NOTE that such command can
263 only affect the _OSI support state, thus specifying it
264 multiple times through kernel command line is also
265 meaningless.
266 Examples:
267 1. 'acpi_osi=' can make 'CondRefOf(_OSI, Local1)'
268 FALSE.
269
270 'acpi_osi=!*' can be used in combination with single or
271 multiple 'acpi_osi="string1"' to support specific
272 string(s). Note that such command can affect the
273 current state of both the OS vendor strings and the
274 feature group strings, thus specifying it multiple times
275 through kernel command line is meaningful. But it may
276 still not able to affect the final state of a string if
277 there are quirks related to this string. This command
278 is useful when one want to control the state of the
279 feature group strings to debug BIOS issues related to
280 the OSPM features.
281 Examples:
282 1. 'acpi_osi="Module Device" acpi_osi=!*' can make
283 '_OSI("Module Device")' FALSE.
284 2. 'acpi_osi=!* acpi_osi="Module Device"' can make
285 '_OSI("Module Device")' TRUE.
286 3. 'acpi_osi=! acpi_osi=!* acpi_osi="Windows 2000"' is
287 equivalent to
288 'acpi_osi=!* acpi_osi=! acpi_osi="Windows 2000"'
289 and
290 'acpi_osi=!* acpi_osi="Windows 2000" acpi_osi=!',
291 they all will make '_OSI("Windows 2000")' TRUE.
292
242 acpi_pm_good [X86] 293 acpi_pm_good [X86]
243 Override the pmtimer bug detection: force the kernel 294 Override the pmtimer bug detection: force the kernel
244 to assume that this machine's pmtimer latches its value 295 to assume that this machine's pmtimer latches its value
@@ -2953,7 +3004,7 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
2953 improve throughput, but will also increase the 3004 improve throughput, but will also increase the
2954 amount of memory reserved for use by the client. 3005 amount of memory reserved for use by the client.
2955 3006
2956 swapaccount[=0|1] 3007 swapaccount=[0|1]
2957 [KNL] Enable accounting of swap in memory resource 3008 [KNL] Enable accounting of swap in memory resource
2958 controller if no parameter or 1 is given or disable 3009 controller if no parameter or 1 is given or disable
2959 it if 0 is given (See Documentation/cgroups/memory.txt) 3010 it if 0 is given (See Documentation/cgroups/memory.txt)
diff --git a/Documentation/laptops/asus-laptop.txt b/Documentation/laptops/asus-laptop.txt
index 69f9fb3701e0..79a1bc675a8d 100644
--- a/Documentation/laptops/asus-laptop.txt
+++ b/Documentation/laptops/asus-laptop.txt
@@ -8,8 +8,8 @@ http://acpi4asus.sf.net/
8 8
9 This driver provides support for extra features of ACPI-compatible ASUS laptops. 9 This driver provides support for extra features of ACPI-compatible ASUS laptops.
10 It may also support some MEDION, JVC or VICTOR laptops (such as MEDION 9675 or 10 It may also support some MEDION, JVC or VICTOR laptops (such as MEDION 9675 or
11 VICTOR XP7210 for example). It makes all the extra buttons generate standard 11 VICTOR XP7210 for example). It makes all the extra buttons generate input
12 ACPI events that go through /proc/acpi/events and input events (like keyboards). 12 events (like keyboards).
13 On some models adds support for changing the display brightness and output, 13 On some models adds support for changing the display brightness and output,
14 switching the LCD backlight on and off, and most importantly, allows you to 14 switching the LCD backlight on and off, and most importantly, allows you to
15 blink those fancy LEDs intended for reporting mail and wireless status. 15 blink those fancy LEDs intended for reporting mail and wireless status.
@@ -55,8 +55,8 @@ Usage
55 DSDT) to me. 55 DSDT) to me.
56 56
57 That's all, now, all the events generated by the hotkeys of your laptop 57 That's all, now, all the events generated by the hotkeys of your laptop
58 should be reported in your /proc/acpi/event entry. You can check with 58 should be reported via netlink events. You can check with
59 "acpi_listen". 59 "acpi_genl monitor" (part of the acpica project).
60 60
61 Hotkeys are also reported as input keys (like keyboards) you can check 61 Hotkeys are also reported as input keys (like keyboards) you can check
62 which key are supported using "xev" under X11. 62 which key are supported using "xev" under X11.
diff --git a/Documentation/laptops/sony-laptop.txt b/Documentation/laptops/sony-laptop.txt
index 0d5ac7f5287e..978b1e615155 100644
--- a/Documentation/laptops/sony-laptop.txt
+++ b/Documentation/laptops/sony-laptop.txt
@@ -12,10 +12,10 @@ Fn keys (hotkeys):
12------------------ 12------------------
13Some models report hotkeys through the SNC or SPIC devices, such events are 13Some models report hotkeys through the SNC or SPIC devices, such events are
14reported both through the ACPI subsystem as acpi events and through the INPUT 14reported both through the ACPI subsystem as acpi events and through the INPUT
15subsystem. See the logs of acpid or /proc/acpi/event and 15subsystem. See the logs of /proc/bus/input/devices to find out what those
16/proc/bus/input/devices to find out what those events are and which input 16events are and which input devices are created by the driver.
17devices are created by the driver. Additionally, loading the driver with the 17Additionally, loading the driver with the debug option will report all events
18debug option will report all events in the kernel log. 18in the kernel log.
19 19
20The "scancodes" passed to the input system (that can be remapped with udev) 20The "scancodes" passed to the input system (that can be remapped with udev)
21are indexes to the table "sony_laptop_input_keycode_map" in the sony-laptop.c 21are indexes to the table "sony_laptop_input_keycode_map" in the sony-laptop.c
diff --git a/Documentation/laptops/thinkpad-acpi.txt b/Documentation/laptops/thinkpad-acpi.txt
index cf7bc6cb9719..86c52360ffe7 100644
--- a/Documentation/laptops/thinkpad-acpi.txt
+++ b/Documentation/laptops/thinkpad-acpi.txt
@@ -329,20 +329,6 @@ sysfs notes:
329 329
330 This attribute has poll()/select() support. 330 This attribute has poll()/select() support.
331 331
332 hotkey_report_mode:
333 Returns the state of the procfs ACPI event report mode
334 filter for hot keys. If it is set to 1 (the default),
335 all hot key presses are reported both through the input
336 layer and also as ACPI events through procfs (but not
337 through netlink). If it is set to 2, hot key presses
338 are reported only through the input layer.
339
340 This attribute is read-only in kernels 2.6.23 or later,
341 and read-write on earlier kernels.
342
343 May return -EPERM (write access locked out by module
344 parameter) or -EACCES (read-only).
345
346 wakeup_reason: 332 wakeup_reason:
347 Set to 1 if the system is waking up because the user 333 Set to 1 if the system is waking up because the user
348 requested a bay ejection. Set to 2 if the system is 334 requested a bay ejection. Set to 2 if the system is
@@ -518,24 +504,21 @@ SW_TABLET_MODE Tablet ThinkPads HKEY events 0x5009 and 0x500A
518Non hotkey ACPI HKEY event map: 504Non hotkey ACPI HKEY event map:
519------------------------------- 505-------------------------------
520 506
521Events that are not propagated by the driver, except for legacy
522compatibility purposes when hotkey_report_mode is set to 1:
523
5240x5001 Lid closed
5250x5002 Lid opened
5260x5009 Tablet swivel: switched to tablet mode
5270x500A Tablet swivel: switched to normal mode
5280x7000 Radio Switch may have changed state
529
530Events that are never propagated by the driver: 507Events that are never propagated by the driver:
531 508
5320x2304 System is waking up from suspend to undock 5090x2304 System is waking up from suspend to undock
5330x2305 System is waking up from suspend to eject bay 5100x2305 System is waking up from suspend to eject bay
5340x2404 System is waking up from hibernation to undock 5110x2404 System is waking up from hibernation to undock
5350x2405 System is waking up from hibernation to eject bay 5120x2405 System is waking up from hibernation to eject bay
5130x5001 Lid closed
5140x5002 Lid opened
5150x5009 Tablet swivel: switched to tablet mode
5160x500A Tablet swivel: switched to normal mode
5360x5010 Brightness level changed/control event 5170x5010 Brightness level changed/control event
5370x6000 KEYBOARD: Numlock key pressed 5180x6000 KEYBOARD: Numlock key pressed
5380x6005 KEYBOARD: Fn key pressed (TO BE VERIFIED) 5190x6005 KEYBOARD: Fn key pressed (TO BE VERIFIED)
5200x7000 Radio Switch may have changed state
521
539 522
540Events that are propagated by the driver to userspace: 523Events that are propagated by the driver to userspace:
541 524
@@ -574,50 +557,6 @@ operating system is to force either an immediate suspend or hibernate
574cycle, or a system shutdown. Obviously, something is very wrong if this 557cycle, or a system shutdown. Obviously, something is very wrong if this
575happens. 558happens.
576 559
577Compatibility notes:
578
579ibm-acpi and thinkpad-acpi 0.15 (mainline kernels before 2.6.23) never
580supported the input layer, and sent events over the procfs ACPI event
581interface.
582
583To avoid sending duplicate events over the input layer and the ACPI
584event interface, thinkpad-acpi 0.16 implements a module parameter
585(hotkey_report_mode), and also a sysfs device attribute with the same
586name.
587
588Make no mistake here: userspace is expected to switch to using the input
589layer interface of thinkpad-acpi, together with the ACPI netlink event
590interface in kernels 2.6.23 and later, or with the ACPI procfs event
591interface in kernels 2.6.22 and earlier.
592
593If no hotkey_report_mode module parameter is specified (or it is set to
594zero), the driver defaults to mode 1 (see below), and on kernels 2.6.22
595and earlier, also allows one to change the hotkey_report_mode through
596sysfs. In kernels 2.6.23 and later, where the netlink ACPI event
597interface is available, hotkey_report_mode cannot be changed through
598sysfs (it is read-only).
599
600If the hotkey_report_mode module parameter is set to 1 or 2, it cannot
601be changed later through sysfs (any writes will return -EPERM to signal
602that hotkey_report_mode was locked. On 2.6.23 and later, where
603hotkey_report_mode cannot be changed at all, writes will return -EACCES).
604
605hotkey_report_mode set to 1 makes the driver export through the procfs
606ACPI event interface all hot key presses (which are *also* sent to the
607input layer). This is a legacy compatibility behaviour, and it is also
608the default mode of operation for the driver.
609
610hotkey_report_mode set to 2 makes the driver filter out the hot key
611presses from the procfs ACPI event interface, so these events will only
612be sent through the input layer. Userspace that has been updated to use
613the thinkpad-acpi input layer interface should set hotkey_report_mode to
6142.
615
616Hot key press events are never sent to the ACPI netlink event interface.
617Really up-to-date userspace under kernel 2.6.23 and later is to use the
618netlink interface and the input layer interface, and don't bother at all
619with hotkey_report_mode.
620
621 560
622Brightness hotkey notes: 561Brightness hotkey notes:
623 562
diff --git a/MAINTAINERS b/MAINTAINERS
index defc05383f83..8197fbd70a3e 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -965,6 +965,12 @@ M: Lennert Buytenhek <kernel@wantstofly.org>
965L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) 965L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
966S: Maintained 966S: Maintained
967 967
968ARM/TEXAS INSTRUMENT KEYSTONE ARCHITECTURE
969M: Santosh Shilimkar <santosh.shilimkar@ti.com>
970L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
971S: Maintained
972F: arch/arm/mach-keystone/
973
968ARM/LOGICPD PXA270 MACHINE SUPPORT 974ARM/LOGICPD PXA270 MACHINE SUPPORT
969M: Lennert Buytenhek <kernel@wantstofly.org> 975M: Lennert Buytenhek <kernel@wantstofly.org>
970L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) 976L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
@@ -1259,7 +1265,6 @@ F: drivers/rtc/rtc-coh901331.c
1259T: git git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-stericsson.git 1265T: git git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-stericsson.git
1260 1266
1261ARM/Ux500 ARM ARCHITECTURE 1267ARM/Ux500 ARM ARCHITECTURE
1262M: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com>
1263M: Linus Walleij <linus.walleij@linaro.org> 1268M: Linus Walleij <linus.walleij@linaro.org>
1264L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) 1269L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
1265S: Maintained 1270S: Maintained
@@ -5576,9 +5581,9 @@ S: Maintained
5576F: drivers/media/tuners/mxl5007t.* 5581F: drivers/media/tuners/mxl5007t.*
5577 5582
5578MYRICOM MYRI-10G 10GbE DRIVER (MYRI10GE) 5583MYRICOM MYRI-10G 10GbE DRIVER (MYRI10GE)
5579M: Andrew Gallatin <gallatin@myri.com> 5584M: Hyong-Youb Kim <hykim@myri.com>
5580L: netdev@vger.kernel.org 5585L: netdev@vger.kernel.org
5581W: http://www.myri.com/scs/download-Myri10GE.html 5586W: https://www.myricom.com/support/downloads/myri10ge.html
5582S: Supported 5587S: Supported
5583F: drivers/net/ethernet/myricom/myri10ge/ 5588F: drivers/net/ethernet/myricom/myri10ge/
5584 5589
@@ -5879,7 +5884,7 @@ F: drivers/i2c/busses/i2c-omap.c
5879F: include/linux/i2c-omap.h 5884F: include/linux/i2c-omap.h
5880 5885
5881OMAP DEVICE TREE SUPPORT 5886OMAP DEVICE TREE SUPPORT
5882M: Benoît Cousson <b-cousson@ti.com> 5887M: Benoît Cousson <bcousson@baylibre.com>
5883M: Tony Lindgren <tony@atomide.com> 5888M: Tony Lindgren <tony@atomide.com>
5884L: linux-omap@vger.kernel.org 5889L: linux-omap@vger.kernel.org
5885L: devicetree@vger.kernel.org 5890L: devicetree@vger.kernel.org
@@ -5959,14 +5964,14 @@ S: Maintained
5959F: drivers/char/hw_random/omap-rng.c 5964F: drivers/char/hw_random/omap-rng.c
5960 5965
5961OMAP HWMOD SUPPORT 5966OMAP HWMOD SUPPORT
5962M: Benoît Cousson <b-cousson@ti.com> 5967M: Benoît Cousson <bcousson@baylibre.com>
5963M: Paul Walmsley <paul@pwsan.com> 5968M: Paul Walmsley <paul@pwsan.com>
5964L: linux-omap@vger.kernel.org 5969L: linux-omap@vger.kernel.org
5965S: Maintained 5970S: Maintained
5966F: arch/arm/mach-omap2/omap_hwmod.* 5971F: arch/arm/mach-omap2/omap_hwmod.*
5967 5972
5968OMAP HWMOD DATA FOR OMAP4-BASED DEVICES 5973OMAP HWMOD DATA FOR OMAP4-BASED DEVICES
5969M: Benoît Cousson <b-cousson@ti.com> 5974M: Benoît Cousson <bcousson@baylibre.com>
5970L: linux-omap@vger.kernel.org 5975L: linux-omap@vger.kernel.org
5971S: Maintained 5976S: Maintained
5972F: arch/arm/mach-omap2/omap_hwmod_44xx_data.c 5977F: arch/arm/mach-omap2/omap_hwmod_44xx_data.c
@@ -7361,7 +7366,6 @@ F: drivers/net/ethernet/sfc/
7361 7366
7362SGI GRU DRIVER 7367SGI GRU DRIVER
7363M: Dimitri Sivanich <sivanich@sgi.com> 7368M: Dimitri Sivanich <sivanich@sgi.com>
7364M: Robin Holt <holt@sgi.com>
7365S: Maintained 7369S: Maintained
7366F: drivers/misc/sgi-gru/ 7370F: drivers/misc/sgi-gru/
7367 7371
@@ -7381,7 +7385,8 @@ S: Maintained for 2.6.
7381F: Documentation/sgi-visws.txt 7385F: Documentation/sgi-visws.txt
7382 7386
7383SGI XP/XPC/XPNET DRIVER 7387SGI XP/XPC/XPNET DRIVER
7384M: Robin Holt <holt@sgi.com> 7388M: Cliff Whickman <cpw@sgi.com>
7389M: Robin Holt <robinmholt@gmail.com>
7385S: Maintained 7390S: Maintained
7386F: drivers/misc/sgi-xp/ 7391F: drivers/misc/sgi-xp/
7387 7392
@@ -8664,6 +8669,11 @@ T: git git://git.alsa-project.org/alsa-kernel.git
8664S: Maintained 8669S: Maintained
8665F: sound/usb/midi.* 8670F: sound/usb/midi.*
8666 8671
8672USB NETWORKING DRIVERS
8673L: linux-usb@vger.kernel.org
8674S: Odd Fixes
8675F: drivers/net/usb/
8676
8667USB OHCI DRIVER 8677USB OHCI DRIVER
8668M: Alan Stern <stern@rowland.harvard.edu> 8678M: Alan Stern <stern@rowland.harvard.edu>
8669L: linux-usb@vger.kernel.org 8679L: linux-usb@vger.kernel.org
diff --git a/Makefile b/Makefile
index f93d4f7a90c2..369882e4fc77 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
1VERSION = 3 1VERSION = 3
2PATCHLEVEL = 11 2PATCHLEVEL = 11
3SUBLEVEL = 0 3SUBLEVEL = 0
4EXTRAVERSION = -rc4 4EXTRAVERSION = -rc7
5NAME = Linux for Workgroups 5NAME = Linux for Workgroups
6 6
7# *DOCUMENTATION* 7# *DOCUMENTATION*
diff --git a/arch/Kconfig b/arch/Kconfig
index 8d2ae24b9f4a..1feb169274fe 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -407,6 +407,12 @@ config CLONE_BACKWARDS2
407 help 407 help
408 Architecture has the first two arguments of clone(2) swapped. 408 Architecture has the first two arguments of clone(2) swapped.
409 409
410config CLONE_BACKWARDS3
411 bool
412 help
413 Architecture has tls passed as the 3rd argument of clone(2),
414 not the 5th one.
415
410config ODD_RT_SIGACTION 416config ODD_RT_SIGACTION
411 bool 417 bool
412 help 418 help
diff --git a/arch/arc/lib/strchr-700.S b/arch/arc/lib/strchr-700.S
index 99c10475d477..9c548c7cf001 100644
--- a/arch/arc/lib/strchr-700.S
+++ b/arch/arc/lib/strchr-700.S
@@ -39,9 +39,18 @@ ARC_ENTRY strchr
39 ld.a r2,[r0,4] 39 ld.a r2,[r0,4]
40 sub r12,r6,r7 40 sub r12,r6,r7
41 bic r12,r12,r6 41 bic r12,r12,r6
42#ifdef __LITTLE_ENDIAN__
42 and r7,r12,r4 43 and r7,r12,r4
43 breq r7,0,.Loop ; For speed, we want this branch to be unaligned. 44 breq r7,0,.Loop ; For speed, we want this branch to be unaligned.
44 b .Lfound_char ; Likewise this one. 45 b .Lfound_char ; Likewise this one.
46#else
47 and r12,r12,r4
48 breq r12,0,.Loop ; For speed, we want this branch to be unaligned.
49 lsr_s r12,r12,7
50 bic r2,r7,r6
51 b.d .Lfound_char_b
52 and_s r2,r2,r12
53#endif
45; /* We require this code address to be unaligned for speed... */ 54; /* We require this code address to be unaligned for speed... */
46.Laligned: 55.Laligned:
47 ld_s r2,[r0] 56 ld_s r2,[r0]
@@ -95,6 +104,7 @@ ARC_ENTRY strchr
95 lsr r7,r7,7 104 lsr r7,r7,7
96 105
97 bic r2,r7,r6 106 bic r2,r7,r6
107.Lfound_char_b:
98 norm r2,r2 108 norm r2,r2
99 sub_s r0,r0,4 109 sub_s r0,r0,4
100 asr_s r2,r2,3 110 asr_s r2,r2,3
diff --git a/arch/arm/boot/dts/at91sam9n12ek.dts b/arch/arm/boot/dts/at91sam9n12ek.dts
index d59b70c6a6a0..3d77dbe406f4 100644
--- a/arch/arm/boot/dts/at91sam9n12ek.dts
+++ b/arch/arm/boot/dts/at91sam9n12ek.dts
@@ -14,11 +14,11 @@
14 compatible = "atmel,at91sam9n12ek", "atmel,at91sam9n12", "atmel,at91sam9"; 14 compatible = "atmel,at91sam9n12ek", "atmel,at91sam9n12", "atmel,at91sam9";
15 15
16 chosen { 16 chosen {
17 bootargs = "mem=128M console=ttyS0,115200 root=/dev/mtdblock1 rw rootfstype=jffs2"; 17 bootargs = "console=ttyS0,115200 root=/dev/mtdblock1 rw rootfstype=jffs2";
18 }; 18 };
19 19
20 memory { 20 memory {
21 reg = <0x20000000 0x10000000>; 21 reg = <0x20000000 0x8000000>;
22 }; 22 };
23 23
24 clocks { 24 clocks {
diff --git a/arch/arm/boot/dts/at91sam9x5ek.dtsi b/arch/arm/boot/dts/at91sam9x5ek.dtsi
index b753855b2058..49e3c45818c2 100644
--- a/arch/arm/boot/dts/at91sam9x5ek.dtsi
+++ b/arch/arm/boot/dts/at91sam9x5ek.dtsi
@@ -94,8 +94,9 @@
94 94
95 usb0: ohci@00600000 { 95 usb0: ohci@00600000 {
96 status = "okay"; 96 status = "okay";
97 num-ports = <2>; 97 num-ports = <3>;
98 atmel,vbus-gpio = <&pioD 19 GPIO_ACTIVE_LOW 98 atmel,vbus-gpio = <0 /* &pioD 18 GPIO_ACTIVE_LOW *//* Activate to have access to port A */
99 &pioD 19 GPIO_ACTIVE_LOW
99 &pioD 20 GPIO_ACTIVE_LOW 100 &pioD 20 GPIO_ACTIVE_LOW
100 >; 101 >;
101 }; 102 };
diff --git a/arch/arm/boot/dts/msm8960-cdp.dts b/arch/arm/boot/dts/msm8960-cdp.dts
index db2060c46540..9c1167b0459b 100644
--- a/arch/arm/boot/dts/msm8960-cdp.dts
+++ b/arch/arm/boot/dts/msm8960-cdp.dts
@@ -26,7 +26,7 @@
26 cpu-offset = <0x80000>; 26 cpu-offset = <0x80000>;
27 }; 27 };
28 28
29 msmgpio: gpio@fd510000 { 29 msmgpio: gpio@800000 {
30 compatible = "qcom,msm-gpio"; 30 compatible = "qcom,msm-gpio";
31 gpio-controller; 31 gpio-controller;
32 #gpio-cells = <2>; 32 #gpio-cells = <2>;
@@ -34,7 +34,7 @@
34 interrupts = <0 32 0x4>; 34 interrupts = <0 32 0x4>;
35 interrupt-controller; 35 interrupt-controller;
36 #interrupt-cells = <2>; 36 #interrupt-cells = <2>;
37 reg = <0xfd510000 0x4000>; 37 reg = <0x800000 0x4000>;
38 }; 38 };
39 39
40 serial@16440000 { 40 serial@16440000 {
diff --git a/arch/arm/boot/dts/omap5-uevm.dts b/arch/arm/boot/dts/omap5-uevm.dts
index 08b72678abff..65d7b601651c 100644
--- a/arch/arm/boot/dts/omap5-uevm.dts
+++ b/arch/arm/boot/dts/omap5-uevm.dts
@@ -235,7 +235,7 @@
235}; 235};
236 236
237&mmc1 { 237&mmc1 {
238 vmmc-supply = <&vmmcsd_fixed>; 238 vmmc-supply = <&ldo9_reg>;
239 bus-width = <4>; 239 bus-width = <4>;
240}; 240};
241 241
@@ -282,6 +282,7 @@
282 282
283 regulators { 283 regulators {
284 smps123_reg: smps123 { 284 smps123_reg: smps123 {
285 /* VDD_OPP_MPU */
285 regulator-name = "smps123"; 286 regulator-name = "smps123";
286 regulator-min-microvolt = < 600000>; 287 regulator-min-microvolt = < 600000>;
287 regulator-max-microvolt = <1500000>; 288 regulator-max-microvolt = <1500000>;
@@ -290,6 +291,7 @@
290 }; 291 };
291 292
292 smps45_reg: smps45 { 293 smps45_reg: smps45 {
294 /* VDD_OPP_MM */
293 regulator-name = "smps45"; 295 regulator-name = "smps45";
294 regulator-min-microvolt = < 600000>; 296 regulator-min-microvolt = < 600000>;
295 regulator-max-microvolt = <1310000>; 297 regulator-max-microvolt = <1310000>;
@@ -298,6 +300,7 @@
298 }; 300 };
299 301
300 smps6_reg: smps6 { 302 smps6_reg: smps6 {
303 /* VDD_DDR3 - over VDD_SMPS6 */
301 regulator-name = "smps6"; 304 regulator-name = "smps6";
302 regulator-min-microvolt = <1200000>; 305 regulator-min-microvolt = <1200000>;
303 regulator-max-microvolt = <1200000>; 306 regulator-max-microvolt = <1200000>;
@@ -306,6 +309,7 @@
306 }; 309 };
307 310
308 smps7_reg: smps7 { 311 smps7_reg: smps7 {
312 /* VDDS_1v8_OMAP over VDDS_1v8_MAIN */
309 regulator-name = "smps7"; 313 regulator-name = "smps7";
310 regulator-min-microvolt = <1800000>; 314 regulator-min-microvolt = <1800000>;
311 regulator-max-microvolt = <1800000>; 315 regulator-max-microvolt = <1800000>;
@@ -314,6 +318,7 @@
314 }; 318 };
315 319
316 smps8_reg: smps8 { 320 smps8_reg: smps8 {
321 /* VDD_OPP_CORE */
317 regulator-name = "smps8"; 322 regulator-name = "smps8";
318 regulator-min-microvolt = < 600000>; 323 regulator-min-microvolt = < 600000>;
319 regulator-max-microvolt = <1310000>; 324 regulator-max-microvolt = <1310000>;
@@ -322,15 +327,15 @@
322 }; 327 };
323 328
324 smps9_reg: smps9 { 329 smps9_reg: smps9 {
330 /* VDDA_2v1_AUD over VDD_2v1 */
325 regulator-name = "smps9"; 331 regulator-name = "smps9";
326 regulator-min-microvolt = <2100000>; 332 regulator-min-microvolt = <2100000>;
327 regulator-max-microvolt = <2100000>; 333 regulator-max-microvolt = <2100000>;
328 regulator-always-on;
329 regulator-boot-on;
330 ti,smps-range = <0x80>; 334 ti,smps-range = <0x80>;
331 }; 335 };
332 336
333 smps10_reg: smps10 { 337 smps10_reg: smps10 {
338 /* VBUS_5V_OTG */
334 regulator-name = "smps10"; 339 regulator-name = "smps10";
335 regulator-min-microvolt = <5000000>; 340 regulator-min-microvolt = <5000000>;
336 regulator-max-microvolt = <5000000>; 341 regulator-max-microvolt = <5000000>;
@@ -339,38 +344,40 @@
339 }; 344 };
340 345
341 ldo1_reg: ldo1 { 346 ldo1_reg: ldo1 {
347 /* VDDAPHY_CAM: vdda_csiport */
342 regulator-name = "ldo1"; 348 regulator-name = "ldo1";
343 regulator-min-microvolt = <2800000>; 349 regulator-min-microvolt = <1500000>;
344 regulator-max-microvolt = <2800000>; 350 regulator-max-microvolt = <1800000>;
345 regulator-always-on;
346 regulator-boot-on;
347 }; 351 };
348 352
349 ldo2_reg: ldo2 { 353 ldo2_reg: ldo2 {
354 /* VCC_2V8_DISP: Does not go anywhere */
350 regulator-name = "ldo2"; 355 regulator-name = "ldo2";
351 regulator-min-microvolt = <2900000>; 356 regulator-min-microvolt = <2800000>;
352 regulator-max-microvolt = <2900000>; 357 regulator-max-microvolt = <2800000>;
353 regulator-always-on; 358 /* Unused */
354 regulator-boot-on; 359 status = "disabled";
355 }; 360 };
356 361
357 ldo3_reg: ldo3 { 362 ldo3_reg: ldo3 {
363 /* VDDAPHY_MDM: vdda_lli */
358 regulator-name = "ldo3"; 364 regulator-name = "ldo3";
359 regulator-min-microvolt = <3000000>; 365 regulator-min-microvolt = <1500000>;
360 regulator-max-microvolt = <3000000>; 366 regulator-max-microvolt = <1500000>;
361 regulator-always-on;
362 regulator-boot-on; 367 regulator-boot-on;
368 /* Only if Modem is used */
369 status = "disabled";
363 }; 370 };
364 371
365 ldo4_reg: ldo4 { 372 ldo4_reg: ldo4 {
373 /* VDDAPHY_DISP: vdda_dsiport/hdmi */
366 regulator-name = "ldo4"; 374 regulator-name = "ldo4";
367 regulator-min-microvolt = <2200000>; 375 regulator-min-microvolt = <1500000>;
368 regulator-max-microvolt = <2200000>; 376 regulator-max-microvolt = <1800000>;
369 regulator-always-on;
370 regulator-boot-on;
371 }; 377 };
372 378
373 ldo5_reg: ldo5 { 379 ldo5_reg: ldo5 {
380 /* VDDA_1V8_PHY: usb/sata/hdmi.. */
374 regulator-name = "ldo5"; 381 regulator-name = "ldo5";
375 regulator-min-microvolt = <1800000>; 382 regulator-min-microvolt = <1800000>;
376 regulator-max-microvolt = <1800000>; 383 regulator-max-microvolt = <1800000>;
@@ -379,38 +386,43 @@
379 }; 386 };
380 387
381 ldo6_reg: ldo6 { 388 ldo6_reg: ldo6 {
389 /* VDDS_1V2_WKUP: hsic/ldo_emu_wkup */
382 regulator-name = "ldo6"; 390 regulator-name = "ldo6";
383 regulator-min-microvolt = <1500000>; 391 regulator-min-microvolt = <1200000>;
384 regulator-max-microvolt = <1500000>; 392 regulator-max-microvolt = <1200000>;
385 regulator-always-on; 393 regulator-always-on;
386 regulator-boot-on; 394 regulator-boot-on;
387 }; 395 };
388 396
389 ldo7_reg: ldo7 { 397 ldo7_reg: ldo7 {
398 /* VDD_VPP: vpp1 */
390 regulator-name = "ldo7"; 399 regulator-name = "ldo7";
391 regulator-min-microvolt = <1500000>; 400 regulator-min-microvolt = <2000000>;
392 regulator-max-microvolt = <1500000>; 401 regulator-max-microvolt = <2000000>;
393 regulator-always-on; 402 /* Only for efuse reprograming! */
394 regulator-boot-on; 403 status = "disabled";
395 }; 404 };
396 405
397 ldo8_reg: ldo8 { 406 ldo8_reg: ldo8 {
407 /* VDD_3v0: Does not go anywhere */
398 regulator-name = "ldo8"; 408 regulator-name = "ldo8";
399 regulator-min-microvolt = <1500000>; 409 regulator-min-microvolt = <3000000>;
400 regulator-max-microvolt = <1500000>; 410 regulator-max-microvolt = <3000000>;
401 regulator-always-on;
402 regulator-boot-on; 411 regulator-boot-on;
412 /* Unused */
413 status = "disabled";
403 }; 414 };
404 415
405 ldo9_reg: ldo9 { 416 ldo9_reg: ldo9 {
417 /* VCC_DV_SDIO: vdds_sdcard */
406 regulator-name = "ldo9"; 418 regulator-name = "ldo9";
407 regulator-min-microvolt = <1800000>; 419 regulator-min-microvolt = <1800000>;
408 regulator-max-microvolt = <3300000>; 420 regulator-max-microvolt = <3000000>;
409 regulator-always-on;
410 regulator-boot-on; 421 regulator-boot-on;
411 }; 422 };
412 423
413 ldoln_reg: ldoln { 424 ldoln_reg: ldoln {
425 /* VDDA_1v8_REF: vdds_osc/mm_l4per.. */
414 regulator-name = "ldoln"; 426 regulator-name = "ldoln";
415 regulator-min-microvolt = <1800000>; 427 regulator-min-microvolt = <1800000>;
416 regulator-max-microvolt = <1800000>; 428 regulator-max-microvolt = <1800000>;
@@ -419,12 +431,20 @@
419 }; 431 };
420 432
421 ldousb_reg: ldousb { 433 ldousb_reg: ldousb {
434 /* VDDA_3V_USB: VDDA_USBHS33 */
422 regulator-name = "ldousb"; 435 regulator-name = "ldousb";
423 regulator-min-microvolt = <3250000>; 436 regulator-min-microvolt = <3250000>;
424 regulator-max-microvolt = <3250000>; 437 regulator-max-microvolt = <3250000>;
425 regulator-always-on; 438 regulator-always-on;
426 regulator-boot-on; 439 regulator-boot-on;
427 }; 440 };
441
442 regen3_reg: regen3 {
443 /* REGEN3 controls LDO9 supply to card */
444 regulator-name = "regen3";
445 regulator-always-on;
446 regulator-boot-on;
447 };
428 }; 448 };
429 }; 449 };
430 }; 450 };
diff --git a/arch/arm/boot/dts/stih41x.dtsi b/arch/arm/boot/dts/stih41x.dtsi
index 7321403cab8a..f5b9898d9c6e 100644
--- a/arch/arm/boot/dts/stih41x.dtsi
+++ b/arch/arm/boot/dts/stih41x.dtsi
@@ -6,10 +6,12 @@
6 #address-cells = <1>; 6 #address-cells = <1>;
7 #size-cells = <0>; 7 #size-cells = <0>;
8 cpu@0 { 8 cpu@0 {
9 device_type = "cpu";
9 compatible = "arm,cortex-a9"; 10 compatible = "arm,cortex-a9";
10 reg = <0>; 11 reg = <0>;
11 }; 12 };
12 cpu@1 { 13 cpu@1 {
14 device_type = "cpu";
13 compatible = "arm,cortex-a9"; 15 compatible = "arm,cortex-a9";
14 reg = <1>; 16 reg = <1>;
15 }; 17 };
diff --git a/arch/arm/boot/dts/tegra20-colibri-512.dtsi b/arch/arm/boot/dts/tegra20-colibri-512.dtsi
index 2fcb3f2ca160..5592be6f2f7a 100644
--- a/arch/arm/boot/dts/tegra20-colibri-512.dtsi
+++ b/arch/arm/boot/dts/tegra20-colibri-512.dtsi
@@ -457,6 +457,7 @@
457 }; 457 };
458 458
459 usb-phy@c5004000 { 459 usb-phy@c5004000 {
460 status = "okay";
460 nvidia,phy-reset-gpio = <&gpio TEGRA_GPIO(V, 1) 461 nvidia,phy-reset-gpio = <&gpio TEGRA_GPIO(V, 1)
461 GPIO_ACTIVE_LOW>; 462 GPIO_ACTIVE_LOW>;
462 }; 463 };
diff --git a/arch/arm/boot/dts/tegra20-seaboard.dts b/arch/arm/boot/dts/tegra20-seaboard.dts
index 365760b33a26..40e6fb280333 100644
--- a/arch/arm/boot/dts/tegra20-seaboard.dts
+++ b/arch/arm/boot/dts/tegra20-seaboard.dts
@@ -830,6 +830,8 @@
830 regulator-max-microvolt = <5000000>; 830 regulator-max-microvolt = <5000000>;
831 enable-active-high; 831 enable-active-high;
832 gpio = <&gpio 24 0>; /* PD0 */ 832 gpio = <&gpio 24 0>; /* PD0 */
833 regulator-always-on;
834 regulator-boot-on;
833 }; 835 };
834 }; 836 };
835 837
diff --git a/arch/arm/boot/dts/tegra20-trimslice.dts b/arch/arm/boot/dts/tegra20-trimslice.dts
index ed4b901b0227..37c93d3c4812 100644
--- a/arch/arm/boot/dts/tegra20-trimslice.dts
+++ b/arch/arm/boot/dts/tegra20-trimslice.dts
@@ -412,6 +412,8 @@
412 regulator-max-microvolt = <5000000>; 412 regulator-max-microvolt = <5000000>;
413 enable-active-high; 413 enable-active-high;
414 gpio = <&gpio 170 0>; /* PV2 */ 414 gpio = <&gpio 170 0>; /* PV2 */
415 regulator-always-on;
416 regulator-boot-on;
415 }; 417 };
416 }; 418 };
417 419
diff --git a/arch/arm/boot/dts/tegra20-whistler.dts b/arch/arm/boot/dts/tegra20-whistler.dts
index ab67c94db280..a3d0ebad78a1 100644
--- a/arch/arm/boot/dts/tegra20-whistler.dts
+++ b/arch/arm/boot/dts/tegra20-whistler.dts
@@ -588,6 +588,8 @@
588 regulator-max-microvolt = <5000000>; 588 regulator-max-microvolt = <5000000>;
589 enable-active-high; 589 enable-active-high;
590 gpio = <&tca6416 0 0>; /* GPIO_PMU0 */ 590 gpio = <&tca6416 0 0>; /* GPIO_PMU0 */
591 regulator-always-on;
592 regulator-boot-on;
591 }; 593 };
592 594
593 vbus3_reg: regulator@3 { 595 vbus3_reg: regulator@3 {
@@ -598,6 +600,8 @@
598 regulator-max-microvolt = <5000000>; 600 regulator-max-microvolt = <5000000>;
599 enable-active-high; 601 enable-active-high;
600 gpio = <&tca6416 1 0>; /* GPIO_PMU1 */ 602 gpio = <&tca6416 1 0>; /* GPIO_PMU1 */
603 regulator-always-on;
604 regulator-boot-on;
601 }; 605 };
602 }; 606 };
603 607
diff --git a/arch/arm/include/asm/smp_plat.h b/arch/arm/include/asm/smp_plat.h
index 6462a721ebd4..a252c0bfacf5 100644
--- a/arch/arm/include/asm/smp_plat.h
+++ b/arch/arm/include/asm/smp_plat.h
@@ -88,4 +88,7 @@ static inline u32 mpidr_hash_size(void)
88{ 88{
89 return 1 << mpidr_hash.bits; 89 return 1 << mpidr_hash.bits;
90} 90}
91
92extern int platform_can_cpu_hotplug(void);
93
91#endif 94#endif
diff --git a/arch/arm/include/asm/spinlock.h b/arch/arm/include/asm/spinlock.h
index f8b8965666e9..b07c09e5a0ac 100644
--- a/arch/arm/include/asm/spinlock.h
+++ b/arch/arm/include/asm/spinlock.h
@@ -107,7 +107,7 @@ static inline int arch_spin_trylock(arch_spinlock_t *lock)
107 " subs %1, %0, %0, ror #16\n" 107 " subs %1, %0, %0, ror #16\n"
108 " addeq %0, %0, %4\n" 108 " addeq %0, %0, %4\n"
109 " strexeq %2, %0, [%3]" 109 " strexeq %2, %0, [%3]"
110 : "=&r" (slock), "=&r" (contended), "=r" (res) 110 : "=&r" (slock), "=&r" (contended), "=&r" (res)
111 : "r" (&lock->slock), "I" (1 << TICKET_SHIFT) 111 : "r" (&lock->slock), "I" (1 << TICKET_SHIFT)
112 : "cc"); 112 : "cc");
113 } while (res); 113 } while (res);
@@ -168,17 +168,20 @@ static inline void arch_write_lock(arch_rwlock_t *rw)
168 168
169static inline int arch_write_trylock(arch_rwlock_t *rw) 169static inline int arch_write_trylock(arch_rwlock_t *rw)
170{ 170{
171 unsigned long tmp; 171 unsigned long contended, res;
172 172
173 __asm__ __volatile__( 173 do {
174" ldrex %0, [%1]\n" 174 __asm__ __volatile__(
175" teq %0, #0\n" 175 " ldrex %0, [%2]\n"
176" strexeq %0, %2, [%1]" 176 " mov %1, #0\n"
177 : "=&r" (tmp) 177 " teq %0, #0\n"
178 : "r" (&rw->lock), "r" (0x80000000) 178 " strexeq %1, %3, [%2]"
179 : "cc"); 179 : "=&r" (contended), "=&r" (res)
180 : "r" (&rw->lock), "r" (0x80000000)
181 : "cc");
182 } while (res);
180 183
181 if (tmp == 0) { 184 if (!contended) {
182 smp_mb(); 185 smp_mb();
183 return 1; 186 return 1;
184 } else { 187 } else {
@@ -254,18 +257,26 @@ static inline void arch_read_unlock(arch_rwlock_t *rw)
254 257
255static inline int arch_read_trylock(arch_rwlock_t *rw) 258static inline int arch_read_trylock(arch_rwlock_t *rw)
256{ 259{
257 unsigned long tmp, tmp2 = 1; 260 unsigned long contended, res;
258 261
259 __asm__ __volatile__( 262 do {
260" ldrex %0, [%2]\n" 263 __asm__ __volatile__(
261" adds %0, %0, #1\n" 264 " ldrex %0, [%2]\n"
262" strexpl %1, %0, [%2]\n" 265 " mov %1, #0\n"
263 : "=&r" (tmp), "+r" (tmp2) 266 " adds %0, %0, #1\n"
264 : "r" (&rw->lock) 267 " strexpl %1, %0, [%2]"
265 : "cc"); 268 : "=&r" (contended), "=&r" (res)
269 : "r" (&rw->lock)
270 : "cc");
271 } while (res);
266 272
267 smp_mb(); 273 /* If the lock is negative, then it is already held for write. */
268 return tmp2 == 0; 274 if (contended < 0x80000000) {
275 smp_mb();
276 return 1;
277 } else {
278 return 0;
279 }
269} 280}
270 281
271/* read_can_lock - would read_trylock() succeed? */ 282/* read_can_lock - would read_trylock() succeed? */
diff --git a/arch/arm/include/asm/tlb.h b/arch/arm/include/asm/tlb.h
index 46e7cfb3e721..0baf7f0d9394 100644
--- a/arch/arm/include/asm/tlb.h
+++ b/arch/arm/include/asm/tlb.h
@@ -43,6 +43,7 @@ struct mmu_gather {
43 struct mm_struct *mm; 43 struct mm_struct *mm;
44 unsigned int fullmm; 44 unsigned int fullmm;
45 struct vm_area_struct *vma; 45 struct vm_area_struct *vma;
46 unsigned long start, end;
46 unsigned long range_start; 47 unsigned long range_start;
47 unsigned long range_end; 48 unsigned long range_end;
48 unsigned int nr; 49 unsigned int nr;
@@ -107,10 +108,12 @@ static inline void tlb_flush_mmu(struct mmu_gather *tlb)
107} 108}
108 109
109static inline void 110static inline void
110tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, unsigned int fullmm) 111tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, unsigned long start, unsigned long end)
111{ 112{
112 tlb->mm = mm; 113 tlb->mm = mm;
113 tlb->fullmm = fullmm; 114 tlb->fullmm = !(start | (end+1));
115 tlb->start = start;
116 tlb->end = end;
114 tlb->vma = NULL; 117 tlb->vma = NULL;
115 tlb->max = ARRAY_SIZE(tlb->local); 118 tlb->max = ARRAY_SIZE(tlb->local);
116 tlb->pages = tlb->local; 119 tlb->pages = tlb->local;
diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
index d40d0ef389db..9cbe70c8b0ef 100644
--- a/arch/arm/kernel/entry-armv.S
+++ b/arch/arm/kernel/entry-armv.S
@@ -357,7 +357,8 @@ ENDPROC(__pabt_svc)
357 .endm 357 .endm
358 358
359 .macro kuser_cmpxchg_check 359 .macro kuser_cmpxchg_check
360#if !defined(CONFIG_CPU_32v6K) && !defined(CONFIG_NEEDS_SYSCALL_FOR_CMPXCHG) 360#if !defined(CONFIG_CPU_32v6K) && defined(CONFIG_KUSER_HELPERS) && \
361 !defined(CONFIG_NEEDS_SYSCALL_FOR_CMPXCHG)
361#ifndef CONFIG_MMU 362#ifndef CONFIG_MMU
362#warning "NPTL on non MMU needs fixing" 363#warning "NPTL on non MMU needs fixing"
363#else 364#else
diff --git a/arch/arm/kernel/fiq.c b/arch/arm/kernel/fiq.c
index 25442f451148..918875d96d5d 100644
--- a/arch/arm/kernel/fiq.c
+++ b/arch/arm/kernel/fiq.c
@@ -84,17 +84,14 @@ int show_fiq_list(struct seq_file *p, int prec)
84 84
85void set_fiq_handler(void *start, unsigned int length) 85void set_fiq_handler(void *start, unsigned int length)
86{ 86{
87#if defined(CONFIG_CPU_USE_DOMAINS)
88 void *base = (void *)0xffff0000;
89#else
90 void *base = vectors_page; 87 void *base = vectors_page;
91#endif
92 unsigned offset = FIQ_OFFSET; 88 unsigned offset = FIQ_OFFSET;
93 89
94 memcpy(base + offset, start, length); 90 memcpy(base + offset, start, length);
91 if (!cache_is_vipt_nonaliasing())
92 flush_icache_range((unsigned long)base + offset, offset +
93 length);
95 flush_icache_range(0xffff0000 + offset, 0xffff0000 + offset + length); 94 flush_icache_range(0xffff0000 + offset, 0xffff0000 + offset + length);
96 if (!vectors_high())
97 flush_icache_range(offset, offset + length);
98} 95}
99 96
100int claim_fiq(struct fiq_handler *f) 97int claim_fiq(struct fiq_handler *f)
diff --git a/arch/arm/kernel/machine_kexec.c b/arch/arm/kernel/machine_kexec.c
index 4fb074c446bf..57221e349a7c 100644
--- a/arch/arm/kernel/machine_kexec.c
+++ b/arch/arm/kernel/machine_kexec.c
@@ -15,6 +15,7 @@
15#include <asm/mmu_context.h> 15#include <asm/mmu_context.h>
16#include <asm/cacheflush.h> 16#include <asm/cacheflush.h>
17#include <asm/mach-types.h> 17#include <asm/mach-types.h>
18#include <asm/smp_plat.h>
18#include <asm/system_misc.h> 19#include <asm/system_misc.h>
19 20
20extern const unsigned char relocate_new_kernel[]; 21extern const unsigned char relocate_new_kernel[];
@@ -39,6 +40,14 @@ int machine_kexec_prepare(struct kimage *image)
39 int i, err; 40 int i, err;
40 41
41 /* 42 /*
43 * Validate that if the current HW supports SMP, then the SW supports
44 * and implements CPU hotplug for the current HW. If not, we won't be
45 * able to kexec reliably, so fail the prepare operation.
46 */
47 if (num_possible_cpus() > 1 && !platform_can_cpu_hotplug())
48 return -EINVAL;
49
50 /*
42 * No segment at default ATAGs address. try to locate 51 * No segment at default ATAGs address. try to locate
43 * a dtb using magic. 52 * a dtb using magic.
44 */ 53 */
@@ -73,6 +82,7 @@ void machine_crash_nonpanic_core(void *unused)
73 crash_save_cpu(&regs, smp_processor_id()); 82 crash_save_cpu(&regs, smp_processor_id());
74 flush_cache_all(); 83 flush_cache_all();
75 84
85 set_cpu_online(smp_processor_id(), false);
76 atomic_dec(&waiting_for_crash_ipi); 86 atomic_dec(&waiting_for_crash_ipi);
77 while (1) 87 while (1)
78 cpu_relax(); 88 cpu_relax();
@@ -134,10 +144,13 @@ void machine_kexec(struct kimage *image)
134 unsigned long reboot_code_buffer_phys; 144 unsigned long reboot_code_buffer_phys;
135 void *reboot_code_buffer; 145 void *reboot_code_buffer;
136 146
137 if (num_online_cpus() > 1) { 147 /*
138 pr_err("kexec: error: multiple CPUs still online\n"); 148 * This can only happen if machine_shutdown() failed to disable some
139 return; 149 * CPU, and that can only happen if the checks in
140 } 150 * machine_kexec_prepare() were not correct. If this fails, we can't
151 * reliably kexec anyway, so BUG_ON is appropriate.
152 */
153 BUG_ON(num_online_cpus() > 1);
141 154
142 page_list = image->head & PAGE_MASK; 155 page_list = image->head & PAGE_MASK;
143 156
diff --git a/arch/arm/kernel/perf_event.c b/arch/arm/kernel/perf_event.c
index d9f5cd4e533f..e186ee1e63f6 100644
--- a/arch/arm/kernel/perf_event.c
+++ b/arch/arm/kernel/perf_event.c
@@ -53,7 +53,12 @@ armpmu_map_cache_event(const unsigned (*cache_map)
53static int 53static int
54armpmu_map_hw_event(const unsigned (*event_map)[PERF_COUNT_HW_MAX], u64 config) 54armpmu_map_hw_event(const unsigned (*event_map)[PERF_COUNT_HW_MAX], u64 config)
55{ 55{
56 int mapping = (*event_map)[config]; 56 int mapping;
57
58 if (config >= PERF_COUNT_HW_MAX)
59 return -EINVAL;
60
61 mapping = (*event_map)[config];
57 return mapping == HW_OP_UNSUPPORTED ? -ENOENT : mapping; 62 return mapping == HW_OP_UNSUPPORTED ? -ENOENT : mapping;
58} 63}
59 64
@@ -253,6 +258,9 @@ validate_event(struct pmu_hw_events *hw_events,
253 struct arm_pmu *armpmu = to_arm_pmu(event->pmu); 258 struct arm_pmu *armpmu = to_arm_pmu(event->pmu);
254 struct pmu *leader_pmu = event->group_leader->pmu; 259 struct pmu *leader_pmu = event->group_leader->pmu;
255 260
261 if (is_software_event(event))
262 return 1;
263
256 if (event->pmu != leader_pmu || event->state < PERF_EVENT_STATE_OFF) 264 if (event->pmu != leader_pmu || event->state < PERF_EVENT_STATE_OFF)
257 return 1; 265 return 1;
258 266
diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
index 536c85fe72a8..94f6b05f9e24 100644
--- a/arch/arm/kernel/process.c
+++ b/arch/arm/kernel/process.c
@@ -462,7 +462,7 @@ int in_gate_area_no_mm(unsigned long addr)
462{ 462{
463 return in_gate_area(NULL, addr); 463 return in_gate_area(NULL, addr);
464} 464}
465#define is_gate_vma(vma) ((vma) = &gate_vma) 465#define is_gate_vma(vma) ((vma) == &gate_vma)
466#else 466#else
467#define is_gate_vma(vma) 0 467#define is_gate_vma(vma) 0
468#endif 468#endif
diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
index c2b4f8f0be9a..2dc19349eb19 100644
--- a/arch/arm/kernel/smp.c
+++ b/arch/arm/kernel/smp.c
@@ -145,6 +145,16 @@ int boot_secondary(unsigned int cpu, struct task_struct *idle)
145 return -ENOSYS; 145 return -ENOSYS;
146} 146}
147 147
148int platform_can_cpu_hotplug(void)
149{
150#ifdef CONFIG_HOTPLUG_CPU
151 if (smp_ops.cpu_kill)
152 return 1;
153#endif
154
155 return 0;
156}
157
148#ifdef CONFIG_HOTPLUG_CPU 158#ifdef CONFIG_HOTPLUG_CPU
149static void percpu_timer_stop(void); 159static void percpu_timer_stop(void);
150 160
diff --git a/arch/arm/kvm/coproc.c b/arch/arm/kvm/coproc.c
index 4a5199070430..db9cf692d4dd 100644
--- a/arch/arm/kvm/coproc.c
+++ b/arch/arm/kvm/coproc.c
@@ -146,7 +146,11 @@ static bool pm_fake(struct kvm_vcpu *vcpu,
146#define access_pmintenclr pm_fake 146#define access_pmintenclr pm_fake
147 147
148/* Architected CP15 registers. 148/* Architected CP15 registers.
149 * Important: Must be sorted ascending by CRn, CRM, Op1, Op2 149 * CRn denotes the primary register number, but is copied to the CRm in the
150 * user space API for 64-bit register access in line with the terminology used
151 * in the ARM ARM.
152 * Important: Must be sorted ascending by CRn, CRM, Op1, Op2 and with 64-bit
153 * registers preceding 32-bit ones.
150 */ 154 */
151static const struct coproc_reg cp15_regs[] = { 155static const struct coproc_reg cp15_regs[] = {
152 /* CSSELR: swapped by interrupt.S. */ 156 /* CSSELR: swapped by interrupt.S. */
@@ -154,8 +158,8 @@ static const struct coproc_reg cp15_regs[] = {
154 NULL, reset_unknown, c0_CSSELR }, 158 NULL, reset_unknown, c0_CSSELR },
155 159
156 /* TTBR0/TTBR1: swapped by interrupt.S. */ 160 /* TTBR0/TTBR1: swapped by interrupt.S. */
157 { CRm( 2), Op1( 0), is64, NULL, reset_unknown64, c2_TTBR0 }, 161 { CRm64( 2), Op1( 0), is64, NULL, reset_unknown64, c2_TTBR0 },
158 { CRm( 2), Op1( 1), is64, NULL, reset_unknown64, c2_TTBR1 }, 162 { CRm64( 2), Op1( 1), is64, NULL, reset_unknown64, c2_TTBR1 },
159 163
160 /* TTBCR: swapped by interrupt.S. */ 164 /* TTBCR: swapped by interrupt.S. */
161 { CRn( 2), CRm( 0), Op1( 0), Op2( 2), is32, 165 { CRn( 2), CRm( 0), Op1( 0), Op2( 2), is32,
@@ -182,7 +186,7 @@ static const struct coproc_reg cp15_regs[] = {
182 NULL, reset_unknown, c6_IFAR }, 186 NULL, reset_unknown, c6_IFAR },
183 187
184 /* PAR swapped by interrupt.S */ 188 /* PAR swapped by interrupt.S */
185 { CRn( 7), Op1( 0), is64, NULL, reset_unknown64, c7_PAR }, 189 { CRm64( 7), Op1( 0), is64, NULL, reset_unknown64, c7_PAR },
186 190
187 /* 191 /*
188 * DC{C,I,CI}SW operations: 192 * DC{C,I,CI}SW operations:
@@ -399,12 +403,13 @@ static bool index_to_params(u64 id, struct coproc_params *params)
399 | KVM_REG_ARM_OPC1_MASK)) 403 | KVM_REG_ARM_OPC1_MASK))
400 return false; 404 return false;
401 params->is_64bit = true; 405 params->is_64bit = true;
402 params->CRm = ((id & KVM_REG_ARM_CRM_MASK) 406 /* CRm to CRn: see cp15_to_index for details */
407 params->CRn = ((id & KVM_REG_ARM_CRM_MASK)
403 >> KVM_REG_ARM_CRM_SHIFT); 408 >> KVM_REG_ARM_CRM_SHIFT);
404 params->Op1 = ((id & KVM_REG_ARM_OPC1_MASK) 409 params->Op1 = ((id & KVM_REG_ARM_OPC1_MASK)
405 >> KVM_REG_ARM_OPC1_SHIFT); 410 >> KVM_REG_ARM_OPC1_SHIFT);
406 params->Op2 = 0; 411 params->Op2 = 0;
407 params->CRn = 0; 412 params->CRm = 0;
408 return true; 413 return true;
409 default: 414 default:
410 return false; 415 return false;
@@ -898,7 +903,14 @@ static u64 cp15_to_index(const struct coproc_reg *reg)
898 if (reg->is_64) { 903 if (reg->is_64) {
899 val |= KVM_REG_SIZE_U64; 904 val |= KVM_REG_SIZE_U64;
900 val |= (reg->Op1 << KVM_REG_ARM_OPC1_SHIFT); 905 val |= (reg->Op1 << KVM_REG_ARM_OPC1_SHIFT);
901 val |= (reg->CRm << KVM_REG_ARM_CRM_SHIFT); 906 /*
907 * CRn always denotes the primary coproc. reg. nr. for the
908 * in-kernel representation, but the user space API uses the
909 * CRm for the encoding, because it is modelled after the
910 * MRRC/MCRR instructions: see the ARM ARM rev. c page
911 * B3-1445
912 */
913 val |= (reg->CRn << KVM_REG_ARM_CRM_SHIFT);
902 } else { 914 } else {
903 val |= KVM_REG_SIZE_U32; 915 val |= KVM_REG_SIZE_U32;
904 val |= (reg->Op1 << KVM_REG_ARM_OPC1_SHIFT); 916 val |= (reg->Op1 << KVM_REG_ARM_OPC1_SHIFT);
diff --git a/arch/arm/kvm/coproc.h b/arch/arm/kvm/coproc.h
index b7301d3e4799..0461d5c8d3de 100644
--- a/arch/arm/kvm/coproc.h
+++ b/arch/arm/kvm/coproc.h
@@ -135,6 +135,8 @@ static inline int cmp_reg(const struct coproc_reg *i1,
135 return -1; 135 return -1;
136 if (i1->CRn != i2->CRn) 136 if (i1->CRn != i2->CRn)
137 return i1->CRn - i2->CRn; 137 return i1->CRn - i2->CRn;
138 if (i1->is_64 != i2->is_64)
139 return i2->is_64 - i1->is_64;
138 if (i1->CRm != i2->CRm) 140 if (i1->CRm != i2->CRm)
139 return i1->CRm - i2->CRm; 141 return i1->CRm - i2->CRm;
140 if (i1->Op1 != i2->Op1) 142 if (i1->Op1 != i2->Op1)
@@ -145,6 +147,7 @@ static inline int cmp_reg(const struct coproc_reg *i1,
145 147
146#define CRn(_x) .CRn = _x 148#define CRn(_x) .CRn = _x
147#define CRm(_x) .CRm = _x 149#define CRm(_x) .CRm = _x
150#define CRm64(_x) .CRn = _x, .CRm = 0
148#define Op1(_x) .Op1 = _x 151#define Op1(_x) .Op1 = _x
149#define Op2(_x) .Op2 = _x 152#define Op2(_x) .Op2 = _x
150#define is64 .is_64 = true 153#define is64 .is_64 = true
diff --git a/arch/arm/kvm/coproc_a15.c b/arch/arm/kvm/coproc_a15.c
index 685063a6d0cf..cf93472b9dd6 100644
--- a/arch/arm/kvm/coproc_a15.c
+++ b/arch/arm/kvm/coproc_a15.c
@@ -114,7 +114,11 @@ static bool access_l2ectlr(struct kvm_vcpu *vcpu,
114 114
115/* 115/*
116 * A15-specific CP15 registers. 116 * A15-specific CP15 registers.
117 * Important: Must be sorted ascending by CRn, CRM, Op1, Op2 117 * CRn denotes the primary register number, but is copied to the CRm in the
118 * user space API for 64-bit register access in line with the terminology used
119 * in the ARM ARM.
120 * Important: Must be sorted ascending by CRn, CRM, Op1, Op2 and with 64-bit
121 * registers preceding 32-bit ones.
118 */ 122 */
119static const struct coproc_reg a15_regs[] = { 123static const struct coproc_reg a15_regs[] = {
120 /* MPIDR: we use VMPIDR for guest access. */ 124 /* MPIDR: we use VMPIDR for guest access. */
diff --git a/arch/arm/kvm/mmio.c b/arch/arm/kvm/mmio.c
index b8e06b7a2833..0c25d9487d53 100644
--- a/arch/arm/kvm/mmio.c
+++ b/arch/arm/kvm/mmio.c
@@ -63,7 +63,8 @@ int kvm_handle_mmio_return(struct kvm_vcpu *vcpu, struct kvm_run *run)
63static int decode_hsr(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa, 63static int decode_hsr(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
64 struct kvm_exit_mmio *mmio) 64 struct kvm_exit_mmio *mmio)
65{ 65{
66 unsigned long rt, len; 66 unsigned long rt;
67 int len;
67 bool is_write, sign_extend; 68 bool is_write, sign_extend;
68 69
69 if (kvm_vcpu_dabt_isextabt(vcpu)) { 70 if (kvm_vcpu_dabt_isextabt(vcpu)) {
diff --git a/arch/arm/kvm/mmu.c b/arch/arm/kvm/mmu.c
index ca6bea4859b4..0988d9e04dd4 100644
--- a/arch/arm/kvm/mmu.c
+++ b/arch/arm/kvm/mmu.c
@@ -85,6 +85,12 @@ static void *mmu_memory_cache_alloc(struct kvm_mmu_memory_cache *mc)
85 return p; 85 return p;
86} 86}
87 87
88static bool page_empty(void *ptr)
89{
90 struct page *ptr_page = virt_to_page(ptr);
91 return page_count(ptr_page) == 1;
92}
93
88static void clear_pud_entry(struct kvm *kvm, pud_t *pud, phys_addr_t addr) 94static void clear_pud_entry(struct kvm *kvm, pud_t *pud, phys_addr_t addr)
89{ 95{
90 pmd_t *pmd_table = pmd_offset(pud, 0); 96 pmd_t *pmd_table = pmd_offset(pud, 0);
@@ -103,12 +109,6 @@ static void clear_pmd_entry(struct kvm *kvm, pmd_t *pmd, phys_addr_t addr)
103 put_page(virt_to_page(pmd)); 109 put_page(virt_to_page(pmd));
104} 110}
105 111
106static bool pmd_empty(pmd_t *pmd)
107{
108 struct page *pmd_page = virt_to_page(pmd);
109 return page_count(pmd_page) == 1;
110}
111
112static void clear_pte_entry(struct kvm *kvm, pte_t *pte, phys_addr_t addr) 112static void clear_pte_entry(struct kvm *kvm, pte_t *pte, phys_addr_t addr)
113{ 113{
114 if (pte_present(*pte)) { 114 if (pte_present(*pte)) {
@@ -118,12 +118,6 @@ static void clear_pte_entry(struct kvm *kvm, pte_t *pte, phys_addr_t addr)
118 } 118 }
119} 119}
120 120
121static bool pte_empty(pte_t *pte)
122{
123 struct page *pte_page = virt_to_page(pte);
124 return page_count(pte_page) == 1;
125}
126
127static void unmap_range(struct kvm *kvm, pgd_t *pgdp, 121static void unmap_range(struct kvm *kvm, pgd_t *pgdp,
128 unsigned long long start, u64 size) 122 unsigned long long start, u64 size)
129{ 123{
@@ -132,37 +126,37 @@ static void unmap_range(struct kvm *kvm, pgd_t *pgdp,
132 pmd_t *pmd; 126 pmd_t *pmd;
133 pte_t *pte; 127 pte_t *pte;
134 unsigned long long addr = start, end = start + size; 128 unsigned long long addr = start, end = start + size;
135 u64 range; 129 u64 next;
136 130
137 while (addr < end) { 131 while (addr < end) {
138 pgd = pgdp + pgd_index(addr); 132 pgd = pgdp + pgd_index(addr);
139 pud = pud_offset(pgd, addr); 133 pud = pud_offset(pgd, addr);
140 if (pud_none(*pud)) { 134 if (pud_none(*pud)) {
141 addr += PUD_SIZE; 135 addr = pud_addr_end(addr, end);
142 continue; 136 continue;
143 } 137 }
144 138
145 pmd = pmd_offset(pud, addr); 139 pmd = pmd_offset(pud, addr);
146 if (pmd_none(*pmd)) { 140 if (pmd_none(*pmd)) {
147 addr += PMD_SIZE; 141 addr = pmd_addr_end(addr, end);
148 continue; 142 continue;
149 } 143 }
150 144
151 pte = pte_offset_kernel(pmd, addr); 145 pte = pte_offset_kernel(pmd, addr);
152 clear_pte_entry(kvm, pte, addr); 146 clear_pte_entry(kvm, pte, addr);
153 range = PAGE_SIZE; 147 next = addr + PAGE_SIZE;
154 148
155 /* If we emptied the pte, walk back up the ladder */ 149 /* If we emptied the pte, walk back up the ladder */
156 if (pte_empty(pte)) { 150 if (page_empty(pte)) {
157 clear_pmd_entry(kvm, pmd, addr); 151 clear_pmd_entry(kvm, pmd, addr);
158 range = PMD_SIZE; 152 next = pmd_addr_end(addr, end);
159 if (pmd_empty(pmd)) { 153 if (page_empty(pmd) && !page_empty(pud)) {
160 clear_pud_entry(kvm, pud, addr); 154 clear_pud_entry(kvm, pud, addr);
161 range = PUD_SIZE; 155 next = pud_addr_end(addr, end);
162 } 156 }
163 } 157 }
164 158
165 addr += range; 159 addr = next;
166 } 160 }
167} 161}
168 162
diff --git a/arch/arm/mach-at91/at91sam9x5.c b/arch/arm/mach-at91/at91sam9x5.c
index 2abee6626aac..916e5a142917 100644
--- a/arch/arm/mach-at91/at91sam9x5.c
+++ b/arch/arm/mach-at91/at91sam9x5.c
@@ -227,6 +227,8 @@ static struct clk_lookup periph_clocks_lookups[] = {
227 CLKDEV_CON_DEV_ID("usart", "f8020000.serial", &usart1_clk), 227 CLKDEV_CON_DEV_ID("usart", "f8020000.serial", &usart1_clk),
228 CLKDEV_CON_DEV_ID("usart", "f8024000.serial", &usart2_clk), 228 CLKDEV_CON_DEV_ID("usart", "f8024000.serial", &usart2_clk),
229 CLKDEV_CON_DEV_ID("usart", "f8028000.serial", &usart3_clk), 229 CLKDEV_CON_DEV_ID("usart", "f8028000.serial", &usart3_clk),
230 CLKDEV_CON_DEV_ID("usart", "f8040000.serial", &uart0_clk),
231 CLKDEV_CON_DEV_ID("usart", "f8044000.serial", &uart1_clk),
230 CLKDEV_CON_DEV_ID("t0_clk", "f8008000.timer", &tcb0_clk), 232 CLKDEV_CON_DEV_ID("t0_clk", "f8008000.timer", &tcb0_clk),
231 CLKDEV_CON_DEV_ID("t0_clk", "f800c000.timer", &tcb0_clk), 233 CLKDEV_CON_DEV_ID("t0_clk", "f800c000.timer", &tcb0_clk),
232 CLKDEV_CON_DEV_ID("mci_clk", "f0008000.mmc", &mmc0_clk), 234 CLKDEV_CON_DEV_ID("mci_clk", "f0008000.mmc", &mmc0_clk),
diff --git a/arch/arm/mach-davinci/board-dm355-leopard.c b/arch/arm/mach-davinci/board-dm355-leopard.c
index dff4ddc5ef81..139e42da25f0 100644
--- a/arch/arm/mach-davinci/board-dm355-leopard.c
+++ b/arch/arm/mach-davinci/board-dm355-leopard.c
@@ -75,6 +75,7 @@ static struct davinci_nand_pdata davinci_nand_data = {
75 .parts = davinci_nand_partitions, 75 .parts = davinci_nand_partitions,
76 .nr_parts = ARRAY_SIZE(davinci_nand_partitions), 76 .nr_parts = ARRAY_SIZE(davinci_nand_partitions),
77 .ecc_mode = NAND_ECC_HW_SYNDROME, 77 .ecc_mode = NAND_ECC_HW_SYNDROME,
78 .ecc_bits = 4,
78 .bbt_options = NAND_BBT_USE_FLASH, 79 .bbt_options = NAND_BBT_USE_FLASH,
79}; 80};
80 81
diff --git a/arch/arm/mach-davinci/board-dm644x-evm.c b/arch/arm/mach-davinci/board-dm644x-evm.c
index a33686a6fbb2..fa4bfaf952d8 100644
--- a/arch/arm/mach-davinci/board-dm644x-evm.c
+++ b/arch/arm/mach-davinci/board-dm644x-evm.c
@@ -153,6 +153,7 @@ static struct davinci_nand_pdata davinci_evm_nandflash_data = {
153 .parts = davinci_evm_nandflash_partition, 153 .parts = davinci_evm_nandflash_partition,
154 .nr_parts = ARRAY_SIZE(davinci_evm_nandflash_partition), 154 .nr_parts = ARRAY_SIZE(davinci_evm_nandflash_partition),
155 .ecc_mode = NAND_ECC_HW, 155 .ecc_mode = NAND_ECC_HW,
156 .ecc_bits = 1,
156 .bbt_options = NAND_BBT_USE_FLASH, 157 .bbt_options = NAND_BBT_USE_FLASH,
157 .timing = &davinci_evm_nandflash_timing, 158 .timing = &davinci_evm_nandflash_timing,
158}; 159};
diff --git a/arch/arm/mach-davinci/board-dm646x-evm.c b/arch/arm/mach-davinci/board-dm646x-evm.c
index fbb8e5ab1dc1..0c005e876cac 100644
--- a/arch/arm/mach-davinci/board-dm646x-evm.c
+++ b/arch/arm/mach-davinci/board-dm646x-evm.c
@@ -90,6 +90,7 @@ static struct davinci_nand_pdata davinci_nand_data = {
90 .parts = davinci_nand_partitions, 90 .parts = davinci_nand_partitions,
91 .nr_parts = ARRAY_SIZE(davinci_nand_partitions), 91 .nr_parts = ARRAY_SIZE(davinci_nand_partitions),
92 .ecc_mode = NAND_ECC_HW, 92 .ecc_mode = NAND_ECC_HW,
93 .ecc_bits = 1,
93 .options = 0, 94 .options = 0,
94}; 95};
95 96
diff --git a/arch/arm/mach-davinci/board-neuros-osd2.c b/arch/arm/mach-davinci/board-neuros-osd2.c
index 2bc112adf565..808233b60e3d 100644
--- a/arch/arm/mach-davinci/board-neuros-osd2.c
+++ b/arch/arm/mach-davinci/board-neuros-osd2.c
@@ -88,6 +88,7 @@ static struct davinci_nand_pdata davinci_ntosd2_nandflash_data = {
88 .parts = davinci_ntosd2_nandflash_partition, 88 .parts = davinci_ntosd2_nandflash_partition,
89 .nr_parts = ARRAY_SIZE(davinci_ntosd2_nandflash_partition), 89 .nr_parts = ARRAY_SIZE(davinci_ntosd2_nandflash_partition),
90 .ecc_mode = NAND_ECC_HW, 90 .ecc_mode = NAND_ECC_HW,
91 .ecc_bits = 1,
91 .bbt_options = NAND_BBT_USE_FLASH, 92 .bbt_options = NAND_BBT_USE_FLASH,
92}; 93};
93 94
diff --git a/arch/arm/mach-msm/Kconfig b/arch/arm/mach-msm/Kconfig
index 614e41e7881b..905efc8cac79 100644
--- a/arch/arm/mach-msm/Kconfig
+++ b/arch/arm/mach-msm/Kconfig
@@ -121,8 +121,7 @@ config MSM_SMD
121 bool 121 bool
122 122
123config MSM_GPIOMUX 123config MSM_GPIOMUX
124 depends on !(ARCH_MSM8X60 || ARCH_MSM8960) 124 bool
125 bool "MSM V1 TLMM GPIOMUX architecture"
126 help 125 help
127 Support for MSM V1 TLMM GPIOMUX architecture. 126 Support for MSM V1 TLMM GPIOMUX architecture.
128 127
diff --git a/arch/arm/mach-msm/gpiomux-v1.c b/arch/arm/mach-msm/gpiomux-v1.c
deleted file mode 100644
index 27de2abd7144..000000000000
--- a/arch/arm/mach-msm/gpiomux-v1.c
+++ /dev/null
@@ -1,33 +0,0 @@
1/* Copyright (c) 2010, Code Aurora Forum. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15 * 02110-1301, USA.
16 */
17#include <linux/kernel.h>
18#include "gpiomux.h"
19#include "proc_comm.h"
20
21void __msm_gpiomux_write(unsigned gpio, gpiomux_config_t val)
22{
23 unsigned tlmm_config = (val & ~GPIOMUX_CTL_MASK) |
24 ((gpio & 0x3ff) << 4);
25 unsigned tlmm_disable = 0;
26 int rc;
27
28 rc = msm_proc_comm(PCOM_RPC_GPIO_TLMM_CONFIG_EX,
29 &tlmm_config, &tlmm_disable);
30 if (rc)
31 pr_err("%s: unexpected proc_comm failure %d: %08x %08x\n",
32 __func__, rc, tlmm_config, tlmm_disable);
33}
diff --git a/arch/arm/mach-msm/gpiomux.h b/arch/arm/mach-msm/gpiomux.h
index 8e82f41a8923..4410d7766f93 100644
--- a/arch/arm/mach-msm/gpiomux.h
+++ b/arch/arm/mach-msm/gpiomux.h
@@ -73,16 +73,6 @@ extern struct msm_gpiomux_config msm_gpiomux_configs[GPIOMUX_NGPIOS];
73int msm_gpiomux_write(unsigned gpio, 73int msm_gpiomux_write(unsigned gpio,
74 gpiomux_config_t active, 74 gpiomux_config_t active,
75 gpiomux_config_t suspended); 75 gpiomux_config_t suspended);
76
77/* Architecture-internal function for use by the framework only.
78 * This function can assume the following:
79 * - the gpio value has passed a bounds-check
80 * - the gpiomux spinlock has been obtained
81 *
82 * This function is not for public consumption. External users
83 * should use msm_gpiomux_write.
84 */
85void __msm_gpiomux_write(unsigned gpio, gpiomux_config_t val);
86#else 76#else
87static inline int msm_gpiomux_write(unsigned gpio, 77static inline int msm_gpiomux_write(unsigned gpio,
88 gpiomux_config_t active, 78 gpiomux_config_t active,
diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
index f6eeb87e4e95..827d15009a86 100644
--- a/arch/arm/mach-omap2/board-n8x0.c
+++ b/arch/arm/mach-omap2/board-n8x0.c
@@ -122,11 +122,7 @@ static struct musb_hdrc_config musb_config = {
122}; 122};
123 123
124static struct musb_hdrc_platform_data tusb_data = { 124static struct musb_hdrc_platform_data tusb_data = {
125#ifdef CONFIG_USB_GADGET_MUSB_HDRC
126 .mode = MUSB_OTG, 125 .mode = MUSB_OTG,
127#else
128 .mode = MUSB_HOST,
129#endif
130 .set_power = tusb_set_power, 126 .set_power = tusb_set_power,
131 .min_power = 25, /* x2 = 50 mA drawn from VBUS as peripheral */ 127 .min_power = 25, /* x2 = 50 mA drawn from VBUS as peripheral */
132 .power = 100, /* Max 100 mA VBUS for host mode */ 128 .power = 100, /* Max 100 mA VBUS for host mode */
diff --git a/arch/arm/mach-omap2/board-rx51.c b/arch/arm/mach-omap2/board-rx51.c
index d2ea68ea678a..7735105561d8 100644
--- a/arch/arm/mach-omap2/board-rx51.c
+++ b/arch/arm/mach-omap2/board-rx51.c
@@ -85,7 +85,7 @@ static struct omap_board_mux board_mux[] __initdata = {
85 85
86static struct omap_musb_board_data musb_board_data = { 86static struct omap_musb_board_data musb_board_data = {
87 .interface_type = MUSB_INTERFACE_ULPI, 87 .interface_type = MUSB_INTERFACE_ULPI,
88 .mode = MUSB_PERIPHERAL, 88 .mode = MUSB_OTG,
89 .power = 0, 89 .power = 0,
90}; 90};
91 91
diff --git a/arch/arm/mach-omap2/dss-common.c b/arch/arm/mach-omap2/dss-common.c
index 393aeefaebb0..043e5705f2a6 100644
--- a/arch/arm/mach-omap2/dss-common.c
+++ b/arch/arm/mach-omap2/dss-common.c
@@ -42,7 +42,7 @@
42 42
43/* Using generic display panel */ 43/* Using generic display panel */
44static struct tfp410_platform_data omap4_dvi_panel = { 44static struct tfp410_platform_data omap4_dvi_panel = {
45 .i2c_bus_num = 3, 45 .i2c_bus_num = 2,
46 .power_down_gpio = PANDA_DVI_TFP410_POWER_DOWN_GPIO, 46 .power_down_gpio = PANDA_DVI_TFP410_POWER_DOWN_GPIO,
47}; 47};
48 48
diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c
index 5cc92874be7e..f99f68e1e85b 100644
--- a/arch/arm/mach-omap2/omap_device.c
+++ b/arch/arm/mach-omap2/omap_device.c
@@ -129,6 +129,7 @@ static int omap_device_build_from_dt(struct platform_device *pdev)
129 struct device_node *node = pdev->dev.of_node; 129 struct device_node *node = pdev->dev.of_node;
130 const char *oh_name; 130 const char *oh_name;
131 int oh_cnt, i, ret = 0; 131 int oh_cnt, i, ret = 0;
132 bool device_active = false;
132 133
133 oh_cnt = of_property_count_strings(node, "ti,hwmods"); 134 oh_cnt = of_property_count_strings(node, "ti,hwmods");
134 if (oh_cnt <= 0) { 135 if (oh_cnt <= 0) {
@@ -152,6 +153,8 @@ static int omap_device_build_from_dt(struct platform_device *pdev)
152 goto odbfd_exit1; 153 goto odbfd_exit1;
153 } 154 }
154 hwmods[i] = oh; 155 hwmods[i] = oh;
156 if (oh->flags & HWMOD_INIT_NO_IDLE)
157 device_active = true;
155 } 158 }
156 159
157 od = omap_device_alloc(pdev, hwmods, oh_cnt); 160 od = omap_device_alloc(pdev, hwmods, oh_cnt);
@@ -172,6 +175,11 @@ static int omap_device_build_from_dt(struct platform_device *pdev)
172 175
173 pdev->dev.pm_domain = &omap_device_pm_domain; 176 pdev->dev.pm_domain = &omap_device_pm_domain;
174 177
178 if (device_active) {
179 omap_device_enable(pdev);
180 pm_runtime_set_active(&pdev->dev);
181 }
182
175odbfd_exit1: 183odbfd_exit1:
176 kfree(hwmods); 184 kfree(hwmods);
177odbfd_exit: 185odbfd_exit:
@@ -842,6 +850,7 @@ static int __init omap_device_late_idle(struct device *dev, void *data)
842{ 850{
843 struct platform_device *pdev = to_platform_device(dev); 851 struct platform_device *pdev = to_platform_device(dev);
844 struct omap_device *od = to_omap_device(pdev); 852 struct omap_device *od = to_omap_device(pdev);
853 int i;
845 854
846 if (!od) 855 if (!od)
847 return 0; 856 return 0;
@@ -850,6 +859,15 @@ static int __init omap_device_late_idle(struct device *dev, void *data)
850 * If omap_device state is enabled, but has no driver bound, 859 * If omap_device state is enabled, but has no driver bound,
851 * idle it. 860 * idle it.
852 */ 861 */
862
863 /*
864 * Some devices (like memory controllers) are always kept
865 * enabled, and should not be idled even with no drivers.
866 */
867 for (i = 0; i < od->hwmods_cnt; i++)
868 if (od->hwmods[i]->flags & HWMOD_INIT_NO_IDLE)
869 return 0;
870
853 if (od->_driver_status != BUS_NOTIFY_BOUND_DRIVER) { 871 if (od->_driver_status != BUS_NOTIFY_BOUND_DRIVER) {
854 if (od->_state == OMAP_DEVICE_STATE_ENABLED) { 872 if (od->_state == OMAP_DEVICE_STATE_ENABLED) {
855 dev_warn(dev, "%s: enabled but no driver. Idling\n", 873 dev_warn(dev, "%s: enabled but no driver. Idling\n",
diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index 7341eff63f56..7f4db12b1459 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -2386,7 +2386,7 @@ static void __init _init_mpu_rt_base(struct omap_hwmod *oh, void *data)
2386 2386
2387 np = of_dev_hwmod_lookup(of_find_node_by_name(NULL, "ocp"), oh); 2387 np = of_dev_hwmod_lookup(of_find_node_by_name(NULL, "ocp"), oh);
2388 if (np) 2388 if (np)
2389 va_start = of_iomap(np, 0); 2389 va_start = of_iomap(np, oh->mpu_rt_idx);
2390 } else { 2390 } else {
2391 va_start = ioremap(mem->pa_start, mem->pa_end - mem->pa_start); 2391 va_start = ioremap(mem->pa_start, mem->pa_end - mem->pa_start);
2392 } 2392 }
diff --git a/arch/arm/mach-omap2/omap_hwmod.h b/arch/arm/mach-omap2/omap_hwmod.h
index aab33fd814c0..e1482a9b3bc2 100644
--- a/arch/arm/mach-omap2/omap_hwmod.h
+++ b/arch/arm/mach-omap2/omap_hwmod.h
@@ -95,6 +95,54 @@ extern struct omap_hwmod_sysc_fields omap_hwmod_sysc_type3;
95#define MODULEMODE_HWCTRL 1 95#define MODULEMODE_HWCTRL 1
96#define MODULEMODE_SWCTRL 2 96#define MODULEMODE_SWCTRL 2
97 97
98#define DEBUG_OMAP2UART1_FLAGS 0
99#define DEBUG_OMAP2UART2_FLAGS 0
100#define DEBUG_OMAP2UART3_FLAGS 0
101#define DEBUG_OMAP3UART3_FLAGS 0
102#define DEBUG_OMAP3UART4_FLAGS 0
103#define DEBUG_OMAP4UART3_FLAGS 0
104#define DEBUG_OMAP4UART4_FLAGS 0
105#define DEBUG_TI81XXUART1_FLAGS 0
106#define DEBUG_TI81XXUART2_FLAGS 0
107#define DEBUG_TI81XXUART3_FLAGS 0
108#define DEBUG_AM33XXUART1_FLAGS 0
109
110#define DEBUG_OMAPUART_FLAGS (HWMOD_INIT_NO_IDLE | HWMOD_INIT_NO_RESET)
111
112#if defined(CONFIG_DEBUG_OMAP2UART1)
113#undef DEBUG_OMAP2UART1_FLAGS
114#define DEBUG_OMAP2UART1_FLAGS DEBUG_OMAPUART_FLAGS
115#elif defined(CONFIG_DEBUG_OMAP2UART2)
116#undef DEBUG_OMAP2UART2_FLAGS
117#define DEBUG_OMAP2UART2_FLAGS DEBUG_OMAPUART_FLAGS
118#elif defined(CONFIG_DEBUG_OMAP2UART3)
119#undef DEBUG_OMAP2UART3_FLAGS
120#define DEBUG_OMAP2UART3_FLAGS DEBUG_OMAPUART_FLAGS
121#elif defined(CONFIG_DEBUG_OMAP3UART3)
122#undef DEBUG_OMAP3UART3_FLAGS
123#define DEBUG_OMAP3UART3_FLAGS DEBUG_OMAPUART_FLAGS
124#elif defined(CONFIG_DEBUG_OMAP3UART4)
125#undef DEBUG_OMAP3UART4_FLAGS
126#define DEBUG_OMAP3UART4_FLAGS DEBUG_OMAPUART_FLAGS
127#elif defined(CONFIG_DEBUG_OMAP4UART3)
128#undef DEBUG_OMAP4UART3_FLAGS
129#define DEBUG_OMAP4UART3_FLAGS DEBUG_OMAPUART_FLAGS
130#elif defined(CONFIG_DEBUG_OMAP4UART4)
131#undef DEBUG_OMAP4UART4_FLAGS
132#define DEBUG_OMAP4UART4_FLAGS DEBUG_OMAPUART_FLAGS
133#elif defined(CONFIG_DEBUG_TI81XXUART1)
134#undef DEBUG_TI81XXUART1_FLAGS
135#define DEBUG_TI81XXUART1_FLAGS DEBUG_OMAPUART_FLAGS
136#elif defined(CONFIG_DEBUG_TI81XXUART2)
137#undef DEBUG_TI81XXUART2_FLAGS
138#define DEBUG_TI81XXUART2_FLAGS DEBUG_OMAPUART_FLAGS
139#elif defined(CONFIG_DEBUG_TI81XXUART3)
140#undef DEBUG_TI81XXUART3_FLAGS
141#define DEBUG_TI81XXUART3_FLAGS DEBUG_OMAPUART_FLAGS
142#elif defined(CONFIG_DEBUG_AM33XXUART1)
143#undef DEBUG_AM33XXUART1_FLAGS
144#define DEBUG_AM33XXUART1_FLAGS DEBUG_OMAPUART_FLAGS
145#endif
98 146
99/** 147/**
100 * struct omap_hwmod_mux_info - hwmod specific mux configuration 148 * struct omap_hwmod_mux_info - hwmod specific mux configuration
@@ -568,6 +616,7 @@ struct omap_hwmod_link {
568 * @voltdm: pointer to voltage domain (filled in at runtime) 616 * @voltdm: pointer to voltage domain (filled in at runtime)
569 * @dev_attr: arbitrary device attributes that can be passed to the driver 617 * @dev_attr: arbitrary device attributes that can be passed to the driver
570 * @_sysc_cache: internal-use hwmod flags 618 * @_sysc_cache: internal-use hwmod flags
619 * @mpu_rt_idx: index of device address space for register target (for DT boot)
571 * @_mpu_rt_va: cached register target start address (internal use) 620 * @_mpu_rt_va: cached register target start address (internal use)
572 * @_mpu_port: cached MPU register target slave (internal use) 621 * @_mpu_port: cached MPU register target slave (internal use)
573 * @opt_clks_cnt: number of @opt_clks 622 * @opt_clks_cnt: number of @opt_clks
@@ -617,6 +666,7 @@ struct omap_hwmod {
617 struct list_head node; 666 struct list_head node;
618 struct omap_hwmod_ocp_if *_mpu_port; 667 struct omap_hwmod_ocp_if *_mpu_port;
619 u16 flags; 668 u16 flags;
669 u8 mpu_rt_idx;
620 u8 response_lat; 670 u8 response_lat;
621 u8 rst_lines_cnt; 671 u8 rst_lines_cnt;
622 u8 opt_clks_cnt; 672 u8 opt_clks_cnt;
diff --git a/arch/arm/mach-omap2/omap_hwmod_2xxx_ipblock_data.c b/arch/arm/mach-omap2/omap_hwmod_2xxx_ipblock_data.c
index d05fc7b54567..56cebb05509e 100644
--- a/arch/arm/mach-omap2/omap_hwmod_2xxx_ipblock_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_2xxx_ipblock_data.c
@@ -512,7 +512,7 @@ struct omap_hwmod omap2xxx_uart1_hwmod = {
512 .mpu_irqs = omap2_uart1_mpu_irqs, 512 .mpu_irqs = omap2_uart1_mpu_irqs,
513 .sdma_reqs = omap2_uart1_sdma_reqs, 513 .sdma_reqs = omap2_uart1_sdma_reqs,
514 .main_clk = "uart1_fck", 514 .main_clk = "uart1_fck",
515 .flags = HWMOD_SWSUP_SIDLE_ACT, 515 .flags = DEBUG_OMAP2UART1_FLAGS | HWMOD_SWSUP_SIDLE_ACT,
516 .prcm = { 516 .prcm = {
517 .omap2 = { 517 .omap2 = {
518 .module_offs = CORE_MOD, 518 .module_offs = CORE_MOD,
@@ -532,7 +532,7 @@ struct omap_hwmod omap2xxx_uart2_hwmod = {
532 .mpu_irqs = omap2_uart2_mpu_irqs, 532 .mpu_irqs = omap2_uart2_mpu_irqs,
533 .sdma_reqs = omap2_uart2_sdma_reqs, 533 .sdma_reqs = omap2_uart2_sdma_reqs,
534 .main_clk = "uart2_fck", 534 .main_clk = "uart2_fck",
535 .flags = HWMOD_SWSUP_SIDLE_ACT, 535 .flags = DEBUG_OMAP2UART2_FLAGS | HWMOD_SWSUP_SIDLE_ACT,
536 .prcm = { 536 .prcm = {
537 .omap2 = { 537 .omap2 = {
538 .module_offs = CORE_MOD, 538 .module_offs = CORE_MOD,
@@ -552,7 +552,7 @@ struct omap_hwmod omap2xxx_uart3_hwmod = {
552 .mpu_irqs = omap2_uart3_mpu_irqs, 552 .mpu_irqs = omap2_uart3_mpu_irqs,
553 .sdma_reqs = omap2_uart3_sdma_reqs, 553 .sdma_reqs = omap2_uart3_sdma_reqs,
554 .main_clk = "uart3_fck", 554 .main_clk = "uart3_fck",
555 .flags = HWMOD_SWSUP_SIDLE_ACT, 555 .flags = DEBUG_OMAP2UART3_FLAGS | HWMOD_SWSUP_SIDLE_ACT,
556 .prcm = { 556 .prcm = {
557 .omap2 = { 557 .omap2 = {
558 .module_offs = CORE_MOD, 558 .module_offs = CORE_MOD,
diff --git a/arch/arm/mach-omap2/omap_hwmod_33xx_data.c b/arch/arm/mach-omap2/omap_hwmod_33xx_data.c
index 28bbd56346a9..eb2f3b93b51c 100644
--- a/arch/arm/mach-omap2/omap_hwmod_33xx_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_33xx_data.c
@@ -562,6 +562,7 @@ static struct omap_hwmod am33xx_cpgmac0_hwmod = {
562 .clkdm_name = "cpsw_125mhz_clkdm", 562 .clkdm_name = "cpsw_125mhz_clkdm",
563 .flags = (HWMOD_SWSUP_SIDLE | HWMOD_SWSUP_MSTANDBY), 563 .flags = (HWMOD_SWSUP_SIDLE | HWMOD_SWSUP_MSTANDBY),
564 .main_clk = "cpsw_125mhz_gclk", 564 .main_clk = "cpsw_125mhz_gclk",
565 .mpu_rt_idx = 1,
565 .prcm = { 566 .prcm = {
566 .omap4 = { 567 .omap4 = {
567 .clkctrl_offs = AM33XX_CM_PER_CPGMAC0_CLKCTRL_OFFSET, 568 .clkctrl_offs = AM33XX_CM_PER_CPGMAC0_CLKCTRL_OFFSET,
@@ -1512,7 +1513,7 @@ static struct omap_hwmod am33xx_uart1_hwmod = {
1512 .name = "uart1", 1513 .name = "uart1",
1513 .class = &uart_class, 1514 .class = &uart_class,
1514 .clkdm_name = "l4_wkup_clkdm", 1515 .clkdm_name = "l4_wkup_clkdm",
1515 .flags = HWMOD_SWSUP_SIDLE_ACT, 1516 .flags = DEBUG_AM33XXUART1_FLAGS | HWMOD_SWSUP_SIDLE_ACT,
1516 .main_clk = "dpll_per_m2_div4_wkupdm_ck", 1517 .main_clk = "dpll_per_m2_div4_wkupdm_ck",
1517 .prcm = { 1518 .prcm = {
1518 .omap4 = { 1519 .omap4 = {
diff --git a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
index f7a3df2fb579..0c3a427da544 100644
--- a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
@@ -490,7 +490,7 @@ static struct omap_hwmod omap3xxx_uart1_hwmod = {
490 .mpu_irqs = omap2_uart1_mpu_irqs, 490 .mpu_irqs = omap2_uart1_mpu_irqs,
491 .sdma_reqs = omap2_uart1_sdma_reqs, 491 .sdma_reqs = omap2_uart1_sdma_reqs,
492 .main_clk = "uart1_fck", 492 .main_clk = "uart1_fck",
493 .flags = HWMOD_SWSUP_SIDLE_ACT, 493 .flags = DEBUG_TI81XXUART1_FLAGS | HWMOD_SWSUP_SIDLE_ACT,
494 .prcm = { 494 .prcm = {
495 .omap2 = { 495 .omap2 = {
496 .module_offs = CORE_MOD, 496 .module_offs = CORE_MOD,
@@ -509,7 +509,7 @@ static struct omap_hwmod omap3xxx_uart2_hwmod = {
509 .mpu_irqs = omap2_uart2_mpu_irqs, 509 .mpu_irqs = omap2_uart2_mpu_irqs,
510 .sdma_reqs = omap2_uart2_sdma_reqs, 510 .sdma_reqs = omap2_uart2_sdma_reqs,
511 .main_clk = "uart2_fck", 511 .main_clk = "uart2_fck",
512 .flags = HWMOD_SWSUP_SIDLE_ACT, 512 .flags = DEBUG_TI81XXUART2_FLAGS | HWMOD_SWSUP_SIDLE_ACT,
513 .prcm = { 513 .prcm = {
514 .omap2 = { 514 .omap2 = {
515 .module_offs = CORE_MOD, 515 .module_offs = CORE_MOD,
@@ -528,7 +528,8 @@ static struct omap_hwmod omap3xxx_uart3_hwmod = {
528 .mpu_irqs = omap2_uart3_mpu_irqs, 528 .mpu_irqs = omap2_uart3_mpu_irqs,
529 .sdma_reqs = omap2_uart3_sdma_reqs, 529 .sdma_reqs = omap2_uart3_sdma_reqs,
530 .main_clk = "uart3_fck", 530 .main_clk = "uart3_fck",
531 .flags = HWMOD_SWSUP_SIDLE_ACT, 531 .flags = DEBUG_OMAP3UART3_FLAGS | DEBUG_TI81XXUART3_FLAGS |
532 HWMOD_SWSUP_SIDLE_ACT,
532 .prcm = { 533 .prcm = {
533 .omap2 = { 534 .omap2 = {
534 .module_offs = OMAP3430_PER_MOD, 535 .module_offs = OMAP3430_PER_MOD,
@@ -558,7 +559,7 @@ static struct omap_hwmod omap36xx_uart4_hwmod = {
558 .mpu_irqs = uart4_mpu_irqs, 559 .mpu_irqs = uart4_mpu_irqs,
559 .sdma_reqs = uart4_sdma_reqs, 560 .sdma_reqs = uart4_sdma_reqs,
560 .main_clk = "uart4_fck", 561 .main_clk = "uart4_fck",
561 .flags = HWMOD_SWSUP_SIDLE_ACT, 562 .flags = DEBUG_OMAP3UART4_FLAGS | HWMOD_SWSUP_SIDLE_ACT,
562 .prcm = { 563 .prcm = {
563 .omap2 = { 564 .omap2 = {
564 .module_offs = OMAP3430_PER_MOD, 565 .module_offs = OMAP3430_PER_MOD,
diff --git a/arch/arm/mach-omap2/omap_hwmod_44xx_data.c b/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
index d04b5e60fdbe..9c3b504477d7 100644
--- a/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
@@ -2858,8 +2858,7 @@ static struct omap_hwmod omap44xx_uart3_hwmod = {
2858 .name = "uart3", 2858 .name = "uart3",
2859 .class = &omap44xx_uart_hwmod_class, 2859 .class = &omap44xx_uart_hwmod_class,
2860 .clkdm_name = "l4_per_clkdm", 2860 .clkdm_name = "l4_per_clkdm",
2861 .flags = HWMOD_INIT_NO_IDLE | HWMOD_INIT_NO_RESET | 2861 .flags = DEBUG_OMAP4UART3_FLAGS | HWMOD_SWSUP_SIDLE_ACT,
2862 HWMOD_SWSUP_SIDLE_ACT,
2863 .main_clk = "func_48m_fclk", 2862 .main_clk = "func_48m_fclk",
2864 .prcm = { 2863 .prcm = {
2865 .omap4 = { 2864 .omap4 = {
@@ -2875,7 +2874,7 @@ static struct omap_hwmod omap44xx_uart4_hwmod = {
2875 .name = "uart4", 2874 .name = "uart4",
2876 .class = &omap44xx_uart_hwmod_class, 2875 .class = &omap44xx_uart_hwmod_class,
2877 .clkdm_name = "l4_per_clkdm", 2876 .clkdm_name = "l4_per_clkdm",
2878 .flags = HWMOD_SWSUP_SIDLE_ACT, 2877 .flags = DEBUG_OMAP4UART4_FLAGS | HWMOD_SWSUP_SIDLE_ACT,
2879 .main_clk = "func_48m_fclk", 2878 .main_clk = "func_48m_fclk",
2880 .prcm = { 2879 .prcm = {
2881 .omap4 = { 2880 .omap4 = {
diff --git a/arch/arm/mach-omap2/omap_hwmod_54xx_data.c b/arch/arm/mach-omap2/omap_hwmod_54xx_data.c
index f37ae96b70a1..3c70f5c1860f 100644
--- a/arch/arm/mach-omap2/omap_hwmod_54xx_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_54xx_data.c
@@ -1375,7 +1375,7 @@ static struct omap_hwmod omap54xx_uart3_hwmod = {
1375 .name = "uart3", 1375 .name = "uart3",
1376 .class = &omap54xx_uart_hwmod_class, 1376 .class = &omap54xx_uart_hwmod_class,
1377 .clkdm_name = "l4per_clkdm", 1377 .clkdm_name = "l4per_clkdm",
1378 .flags = HWMOD_INIT_NO_IDLE | HWMOD_INIT_NO_RESET, 1378 .flags = DEBUG_OMAP4UART3_FLAGS,
1379 .main_clk = "func_48m_fclk", 1379 .main_clk = "func_48m_fclk",
1380 .prcm = { 1380 .prcm = {
1381 .omap4 = { 1381 .omap4 = {
@@ -1391,6 +1391,7 @@ static struct omap_hwmod omap54xx_uart4_hwmod = {
1391 .name = "uart4", 1391 .name = "uart4",
1392 .class = &omap54xx_uart_hwmod_class, 1392 .class = &omap54xx_uart_hwmod_class,
1393 .clkdm_name = "l4per_clkdm", 1393 .clkdm_name = "l4per_clkdm",
1394 .flags = DEBUG_OMAP4UART4_FLAGS,
1394 .main_clk = "func_48m_fclk", 1395 .main_clk = "func_48m_fclk",
1395 .prcm = { 1396 .prcm = {
1396 .omap4 = { 1397 .omap4 = {
diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index 3a674de6cb63..a388f8c1bcb3 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -208,17 +208,6 @@ static int __init omap_serial_early_init(void)
208 pr_info("%s used as console in debug mode: uart%d clocks will not be gated", 208 pr_info("%s used as console in debug mode: uart%d clocks will not be gated",
209 uart_name, uart->num); 209 uart_name, uart->num);
210 } 210 }
211
212 /*
213 * omap-uart can be used for earlyprintk logs
214 * So if omap-uart is used as console then prevent
215 * uart reset and idle to get logs from omap-uart
216 * until uart console driver is available to take
217 * care for console messages.
218 * Idling or resetting omap-uart while printing logs
219 * early boot logs can stall the boot-up.
220 */
221 oh->flags |= HWMOD_INIT_NO_IDLE | HWMOD_INIT_NO_RESET;
222 } 211 }
223 } while (1); 212 } while (1);
224 213
diff --git a/arch/arm/mach-omap2/usb-musb.c b/arch/arm/mach-omap2/usb-musb.c
index 8c4de2708cf2..bc897231bd10 100644
--- a/arch/arm/mach-omap2/usb-musb.c
+++ b/arch/arm/mach-omap2/usb-musb.c
@@ -38,11 +38,8 @@ static struct musb_hdrc_config musb_config = {
38}; 38};
39 39
40static struct musb_hdrc_platform_data musb_plat = { 40static struct musb_hdrc_platform_data musb_plat = {
41#ifdef CONFIG_USB_GADGET_MUSB_HDRC
42 .mode = MUSB_OTG, 41 .mode = MUSB_OTG,
43#else 42
44 .mode = MUSB_HOST,
45#endif
46 /* .clock is set dynamically */ 43 /* .clock is set dynamically */
47 .config = &musb_config, 44 .config = &musb_config,
48 45
diff --git a/arch/arm/mach-shmobile/board-armadillo800eva.c b/arch/arm/mach-shmobile/board-armadillo800eva.c
index e115f6742107..c5be60d85e4b 100644
--- a/arch/arm/mach-shmobile/board-armadillo800eva.c
+++ b/arch/arm/mach-shmobile/board-armadillo800eva.c
@@ -1162,9 +1162,6 @@ static void __init eva_init(void)
1162 gpio_request_one(61, GPIOF_OUT_INIT_HIGH, NULL); /* LCDDON */ 1162 gpio_request_one(61, GPIOF_OUT_INIT_HIGH, NULL); /* LCDDON */
1163 gpio_request_one(202, GPIOF_OUT_INIT_LOW, NULL); /* LCD0_LED_CONT */ 1163 gpio_request_one(202, GPIOF_OUT_INIT_LOW, NULL); /* LCD0_LED_CONT */
1164 1164
1165 /* Touchscreen */
1166 gpio_request_one(166, GPIOF_OUT_INIT_HIGH, NULL); /* TP_RST_B */
1167
1168 /* GETHER */ 1165 /* GETHER */
1169 gpio_request_one(18, GPIOF_OUT_INIT_HIGH, NULL); /* PHY_RST */ 1166 gpio_request_one(18, GPIOF_OUT_INIT_HIGH, NULL); /* PHY_RST */
1170 1167
diff --git a/arch/arm/mach-shmobile/board-bockw.c b/arch/arm/mach-shmobile/board-bockw.c
index d5554646916c..3354a85c90f7 100644
--- a/arch/arm/mach-shmobile/board-bockw.c
+++ b/arch/arm/mach-shmobile/board-bockw.c
@@ -167,7 +167,13 @@ static const struct pinctrl_map bockw_pinctrl_map[] = {
167 "usb1", "usb1"), 167 "usb1", "usb1"),
168 /* SDHI0 */ 168 /* SDHI0 */
169 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7778", 169 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7778",
170 "sdhi0", "sdhi0"), 170 "sdhi0_data4", "sdhi0"),
171 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7778",
172 "sdhi0_ctrl", "sdhi0"),
173 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7778",
174 "sdhi0_cd", "sdhi0"),
175 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7778",
176 "sdhi0_wp", "sdhi0"),
171}; 177};
172 178
173#define FPGA 0x18200000 179#define FPGA 0x18200000
diff --git a/arch/arm/mach-shmobile/board-lager.c b/arch/arm/mach-shmobile/board-lager.c
index d73e21d3ea8a..8d6bd5c5efb9 100644
--- a/arch/arm/mach-shmobile/board-lager.c
+++ b/arch/arm/mach-shmobile/board-lager.c
@@ -59,7 +59,7 @@ static __initdata struct gpio_led_platform_data lager_leds_pdata = {
59#define GPIO_KEY(c, g, d, ...) \ 59#define GPIO_KEY(c, g, d, ...) \
60 { .code = c, .gpio = g, .desc = d, .active_low = 1 } 60 { .code = c, .gpio = g, .desc = d, .active_low = 1 }
61 61
62static __initdata struct gpio_keys_button gpio_buttons[] = { 62static struct gpio_keys_button gpio_buttons[] = {
63 GPIO_KEY(KEY_4, RCAR_GP_PIN(1, 28), "SW2-pin4"), 63 GPIO_KEY(KEY_4, RCAR_GP_PIN(1, 28), "SW2-pin4"),
64 GPIO_KEY(KEY_3, RCAR_GP_PIN(1, 26), "SW2-pin3"), 64 GPIO_KEY(KEY_3, RCAR_GP_PIN(1, 26), "SW2-pin3"),
65 GPIO_KEY(KEY_2, RCAR_GP_PIN(1, 24), "SW2-pin2"), 65 GPIO_KEY(KEY_2, RCAR_GP_PIN(1, 24), "SW2-pin2"),
diff --git a/arch/arm/mach-sti/headsmp.S b/arch/arm/mach-sti/headsmp.S
index 78ebc7559f53..4c09bae86edf 100644
--- a/arch/arm/mach-sti/headsmp.S
+++ b/arch/arm/mach-sti/headsmp.S
@@ -16,8 +16,6 @@
16#include <linux/linkage.h> 16#include <linux/linkage.h>
17#include <linux/init.h> 17#include <linux/init.h>
18 18
19 __INIT
20
21/* 19/*
22 * ST specific entry point for secondary CPUs. This provides 20 * ST specific entry point for secondary CPUs. This provides
23 * a "holding pen" into which all secondary cores are held until we're 21 * a "holding pen" into which all secondary cores are held until we're
diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
index db5c2cab8fda..cd2c88e7a8f7 100644
--- a/arch/arm/mm/Kconfig
+++ b/arch/arm/mm/Kconfig
@@ -809,15 +809,18 @@ config KUSER_HELPERS
809 the CPU type fitted to the system. This permits binaries to be 809 the CPU type fitted to the system. This permits binaries to be
810 run on ARMv4 through to ARMv7 without modification. 810 run on ARMv4 through to ARMv7 without modification.
811 811
812 See Documentation/arm/kernel_user_helpers.txt for details.
813
812 However, the fixed address nature of these helpers can be used 814 However, the fixed address nature of these helpers can be used
813 by ROP (return orientated programming) authors when creating 815 by ROP (return orientated programming) authors when creating
814 exploits. 816 exploits.
815 817
816 If all of the binaries and libraries which run on your platform 818 If all of the binaries and libraries which run on your platform
817 are built specifically for your platform, and make no use of 819 are built specifically for your platform, and make no use of
818 these helpers, then you can turn this option off. However, 820 these helpers, then you can turn this option off to hinder
819 when such an binary or library is run, it will receive a SIGILL 821 such exploits. However, in that case, if a binary or library
820 signal, which will terminate the program. 822 relying on those helpers is run, it will receive a SIGILL signal,
823 which will terminate the program.
821 824
822 Say N here only if you are absolutely certain that you do not 825 Say N here only if you are absolutely certain that you do not
823 need these helpers; otherwise, the safe option is to say Y. 826 need these helpers; otherwise, the safe option is to say Y.
diff --git a/arch/arm/plat-samsung/init.c b/arch/arm/plat-samsung/init.c
index 3e5c4619caa5..50a3ea0037db 100644
--- a/arch/arm/plat-samsung/init.c
+++ b/arch/arm/plat-samsung/init.c
@@ -55,12 +55,13 @@ void __init s3c_init_cpu(unsigned long idcode,
55 55
56 printk("CPU %s (id 0x%08lx)\n", cpu->name, idcode); 56 printk("CPU %s (id 0x%08lx)\n", cpu->name, idcode);
57 57
58 if (cpu->map_io == NULL || cpu->init == NULL) { 58 if (cpu->init == NULL) {
59 printk(KERN_ERR "CPU %s support not enabled\n", cpu->name); 59 printk(KERN_ERR "CPU %s support not enabled\n", cpu->name);
60 panic("Unsupported Samsung CPU"); 60 panic("Unsupported Samsung CPU");
61 } 61 }
62 62
63 cpu->map_io(); 63 if (cpu->map_io)
64 cpu->map_io();
64} 65}
65 66
66/* s3c24xx_init_clocks 67/* s3c24xx_init_clocks
diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
index c9770ba5c7df..8a6295c86209 100644
--- a/arch/arm/xen/enlighten.c
+++ b/arch/arm/xen/enlighten.c
@@ -170,6 +170,7 @@ static void __init xen_percpu_init(void *unused)
170 per_cpu(xen_vcpu, cpu) = vcpup; 170 per_cpu(xen_vcpu, cpu) = vcpup;
171 171
172 enable_percpu_irq(xen_events_irq, 0); 172 enable_percpu_irq(xen_events_irq, 0);
173 put_cpu();
173} 174}
174 175
175static void xen_restart(enum reboot_mode reboot_mode, const char *cmd) 176static void xen_restart(enum reboot_mode reboot_mode, const char *cmd)
diff --git a/arch/arm64/include/asm/kvm_asm.h b/arch/arm64/include/asm/kvm_asm.h
index c92de4163eba..b25763bc0ec4 100644
--- a/arch/arm64/include/asm/kvm_asm.h
+++ b/arch/arm64/include/asm/kvm_asm.h
@@ -42,14 +42,15 @@
42#define TPIDR_EL1 18 /* Thread ID, Privileged */ 42#define TPIDR_EL1 18 /* Thread ID, Privileged */
43#define AMAIR_EL1 19 /* Aux Memory Attribute Indirection Register */ 43#define AMAIR_EL1 19 /* Aux Memory Attribute Indirection Register */
44#define CNTKCTL_EL1 20 /* Timer Control Register (EL1) */ 44#define CNTKCTL_EL1 20 /* Timer Control Register (EL1) */
45#define PAR_EL1 21 /* Physical Address Register */
45/* 32bit specific registers. Keep them at the end of the range */ 46/* 32bit specific registers. Keep them at the end of the range */
46#define DACR32_EL2 21 /* Domain Access Control Register */ 47#define DACR32_EL2 22 /* Domain Access Control Register */
47#define IFSR32_EL2 22 /* Instruction Fault Status Register */ 48#define IFSR32_EL2 23 /* Instruction Fault Status Register */
48#define FPEXC32_EL2 23 /* Floating-Point Exception Control Register */ 49#define FPEXC32_EL2 24 /* Floating-Point Exception Control Register */
49#define DBGVCR32_EL2 24 /* Debug Vector Catch Register */ 50#define DBGVCR32_EL2 25 /* Debug Vector Catch Register */
50#define TEECR32_EL1 25 /* ThumbEE Configuration Register */ 51#define TEECR32_EL1 26 /* ThumbEE Configuration Register */
51#define TEEHBR32_EL1 26 /* ThumbEE Handler Base Register */ 52#define TEEHBR32_EL1 27 /* ThumbEE Handler Base Register */
52#define NR_SYS_REGS 27 53#define NR_SYS_REGS 28
53 54
54/* 32bit mapping */ 55/* 32bit mapping */
55#define c0_MPIDR (MPIDR_EL1 * 2) /* MultiProcessor ID Register */ 56#define c0_MPIDR (MPIDR_EL1 * 2) /* MultiProcessor ID Register */
@@ -69,6 +70,8 @@
69#define c5_AIFSR (AFSR1_EL1 * 2) /* Auxiliary Instr Fault Status R */ 70#define c5_AIFSR (AFSR1_EL1 * 2) /* Auxiliary Instr Fault Status R */
70#define c6_DFAR (FAR_EL1 * 2) /* Data Fault Address Register */ 71#define c6_DFAR (FAR_EL1 * 2) /* Data Fault Address Register */
71#define c6_IFAR (c6_DFAR + 1) /* Instruction Fault Address Register */ 72#define c6_IFAR (c6_DFAR + 1) /* Instruction Fault Address Register */
73#define c7_PAR (PAR_EL1 * 2) /* Physical Address Register */
74#define c7_PAR_high (c7_PAR + 1) /* PAR top 32 bits */
72#define c10_PRRR (MAIR_EL1 * 2) /* Primary Region Remap Register */ 75#define c10_PRRR (MAIR_EL1 * 2) /* Primary Region Remap Register */
73#define c10_NMRR (c10_PRRR + 1) /* Normal Memory Remap Register */ 76#define c10_NMRR (c10_PRRR + 1) /* Normal Memory Remap Register */
74#define c12_VBAR (VBAR_EL1 * 2) /* Vector Base Address Register */ 77#define c12_VBAR (VBAR_EL1 * 2) /* Vector Base Address Register */
diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h
index 644d73956864..0859a4ddd1e7 100644
--- a/arch/arm64/include/asm/kvm_host.h
+++ b/arch/arm64/include/asm/kvm_host.h
@@ -129,7 +129,7 @@ struct kvm_vcpu_arch {
129 struct kvm_mmu_memory_cache mmu_page_cache; 129 struct kvm_mmu_memory_cache mmu_page_cache;
130 130
131 /* Target CPU and feature flags */ 131 /* Target CPU and feature flags */
132 u32 target; 132 int target;
133 DECLARE_BITMAP(features, KVM_VCPU_MAX_FEATURES); 133 DECLARE_BITMAP(features, KVM_VCPU_MAX_FEATURES);
134 134
135 /* Detect first run of a vcpu */ 135 /* Detect first run of a vcpu */
diff --git a/arch/arm64/include/asm/tlb.h b/arch/arm64/include/asm/tlb.h
index 46b3beb4b773..717031a762c2 100644
--- a/arch/arm64/include/asm/tlb.h
+++ b/arch/arm64/include/asm/tlb.h
@@ -35,6 +35,7 @@ struct mmu_gather {
35 struct mm_struct *mm; 35 struct mm_struct *mm;
36 unsigned int fullmm; 36 unsigned int fullmm;
37 struct vm_area_struct *vma; 37 struct vm_area_struct *vma;
38 unsigned long start, end;
38 unsigned long range_start; 39 unsigned long range_start;
39 unsigned long range_end; 40 unsigned long range_end;
40 unsigned int nr; 41 unsigned int nr;
@@ -97,10 +98,12 @@ static inline void tlb_flush_mmu(struct mmu_gather *tlb)
97} 98}
98 99
99static inline void 100static inline void
100tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, unsigned int fullmm) 101tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, unsigned long start, unsigned long end)
101{ 102{
102 tlb->mm = mm; 103 tlb->mm = mm;
103 tlb->fullmm = fullmm; 104 tlb->fullmm = !(start | (end+1));
105 tlb->start = start;
106 tlb->end = end;
104 tlb->vma = NULL; 107 tlb->vma = NULL;
105 tlb->max = ARRAY_SIZE(tlb->local); 108 tlb->max = ARRAY_SIZE(tlb->local);
106 tlb->pages = tlb->local; 109 tlb->pages = tlb->local;
diff --git a/arch/arm64/kernel/perf_event.c b/arch/arm64/kernel/perf_event.c
index 9ba33c40cdf8..12e6ccb88691 100644
--- a/arch/arm64/kernel/perf_event.c
+++ b/arch/arm64/kernel/perf_event.c
@@ -107,7 +107,12 @@ armpmu_map_cache_event(const unsigned (*cache_map)
107static int 107static int
108armpmu_map_event(const unsigned (*event_map)[PERF_COUNT_HW_MAX], u64 config) 108armpmu_map_event(const unsigned (*event_map)[PERF_COUNT_HW_MAX], u64 config)
109{ 109{
110 int mapping = (*event_map)[config]; 110 int mapping;
111
112 if (config >= PERF_COUNT_HW_MAX)
113 return -EINVAL;
114
115 mapping = (*event_map)[config];
111 return mapping == HW_OP_UNSUPPORTED ? -ENOENT : mapping; 116 return mapping == HW_OP_UNSUPPORTED ? -ENOENT : mapping;
112} 117}
113 118
@@ -317,6 +322,9 @@ validate_event(struct pmu_hw_events *hw_events,
317 struct hw_perf_event fake_event = event->hw; 322 struct hw_perf_event fake_event = event->hw;
318 struct pmu *leader_pmu = event->group_leader->pmu; 323 struct pmu *leader_pmu = event->group_leader->pmu;
319 324
325 if (is_software_event(event))
326 return 1;
327
320 if (event->pmu != leader_pmu || event->state <= PERF_EVENT_STATE_OFF) 328 if (event->pmu != leader_pmu || event->state <= PERF_EVENT_STATE_OFF)
321 return 1; 329 return 1;
322 330
diff --git a/arch/arm64/kvm/hyp.S b/arch/arm64/kvm/hyp.S
index ff985e3d8b72..1ac0bbbdddb2 100644
--- a/arch/arm64/kvm/hyp.S
+++ b/arch/arm64/kvm/hyp.S
@@ -214,6 +214,7 @@ __kvm_hyp_code_start:
214 mrs x21, tpidr_el1 214 mrs x21, tpidr_el1
215 mrs x22, amair_el1 215 mrs x22, amair_el1
216 mrs x23, cntkctl_el1 216 mrs x23, cntkctl_el1
217 mrs x24, par_el1
217 218
218 stp x4, x5, [x3] 219 stp x4, x5, [x3]
219 stp x6, x7, [x3, #16] 220 stp x6, x7, [x3, #16]
@@ -225,6 +226,7 @@ __kvm_hyp_code_start:
225 stp x18, x19, [x3, #112] 226 stp x18, x19, [x3, #112]
226 stp x20, x21, [x3, #128] 227 stp x20, x21, [x3, #128]
227 stp x22, x23, [x3, #144] 228 stp x22, x23, [x3, #144]
229 str x24, [x3, #160]
228.endm 230.endm
229 231
230.macro restore_sysregs 232.macro restore_sysregs
@@ -243,6 +245,7 @@ __kvm_hyp_code_start:
243 ldp x18, x19, [x3, #112] 245 ldp x18, x19, [x3, #112]
244 ldp x20, x21, [x3, #128] 246 ldp x20, x21, [x3, #128]
245 ldp x22, x23, [x3, #144] 247 ldp x22, x23, [x3, #144]
248 ldr x24, [x3, #160]
246 249
247 msr vmpidr_el2, x4 250 msr vmpidr_el2, x4
248 msr csselr_el1, x5 251 msr csselr_el1, x5
@@ -264,6 +267,7 @@ __kvm_hyp_code_start:
264 msr tpidr_el1, x21 267 msr tpidr_el1, x21
265 msr amair_el1, x22 268 msr amair_el1, x22
266 msr cntkctl_el1, x23 269 msr cntkctl_el1, x23
270 msr par_el1, x24
267.endm 271.endm
268 272
269.macro skip_32bit_state tmp, target 273.macro skip_32bit_state tmp, target
@@ -600,6 +604,8 @@ END(__kvm_vcpu_run)
600 604
601// void __kvm_tlb_flush_vmid_ipa(struct kvm *kvm, phys_addr_t ipa); 605// void __kvm_tlb_flush_vmid_ipa(struct kvm *kvm, phys_addr_t ipa);
602ENTRY(__kvm_tlb_flush_vmid_ipa) 606ENTRY(__kvm_tlb_flush_vmid_ipa)
607 dsb ishst
608
603 kern_hyp_va x0 609 kern_hyp_va x0
604 ldr x2, [x0, #KVM_VTTBR] 610 ldr x2, [x0, #KVM_VTTBR]
605 msr vttbr_el2, x2 611 msr vttbr_el2, x2
@@ -621,6 +627,7 @@ ENTRY(__kvm_tlb_flush_vmid_ipa)
621ENDPROC(__kvm_tlb_flush_vmid_ipa) 627ENDPROC(__kvm_tlb_flush_vmid_ipa)
622 628
623ENTRY(__kvm_flush_vm_context) 629ENTRY(__kvm_flush_vm_context)
630 dsb ishst
624 tlbi alle1is 631 tlbi alle1is
625 ic ialluis 632 ic ialluis
626 dsb sy 633 dsb sy
@@ -753,6 +760,10 @@ el1_trap:
753 */ 760 */
754 tbnz x1, #7, 1f // S1PTW is set 761 tbnz x1, #7, 1f // S1PTW is set
755 762
763 /* Preserve PAR_EL1 */
764 mrs x3, par_el1
765 push x3, xzr
766
756 /* 767 /*
757 * Permission fault, HPFAR_EL2 is invalid. 768 * Permission fault, HPFAR_EL2 is invalid.
758 * Resolve the IPA the hard way using the guest VA. 769 * Resolve the IPA the hard way using the guest VA.
@@ -766,6 +777,8 @@ el1_trap:
766 777
767 /* Read result */ 778 /* Read result */
768 mrs x3, par_el1 779 mrs x3, par_el1
780 pop x0, xzr // Restore PAR_EL1 from the stack
781 msr par_el1, x0
769 tbnz x3, #0, 3f // Bail out if we failed the translation 782 tbnz x3, #0, 3f // Bail out if we failed the translation
770 ubfx x3, x3, #12, #36 // Extract IPA 783 ubfx x3, x3, #12, #36 // Extract IPA
771 lsl x3, x3, #4 // and present it like HPFAR 784 lsl x3, x3, #4 // and present it like HPFAR
diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c
index 94923609753b..02e9d09e1d80 100644
--- a/arch/arm64/kvm/sys_regs.c
+++ b/arch/arm64/kvm/sys_regs.c
@@ -211,6 +211,9 @@ static const struct sys_reg_desc sys_reg_descs[] = {
211 /* FAR_EL1 */ 211 /* FAR_EL1 */
212 { Op0(0b11), Op1(0b000), CRn(0b0110), CRm(0b0000), Op2(0b000), 212 { Op0(0b11), Op1(0b000), CRn(0b0110), CRm(0b0000), Op2(0b000),
213 NULL, reset_unknown, FAR_EL1 }, 213 NULL, reset_unknown, FAR_EL1 },
214 /* PAR_EL1 */
215 { Op0(0b11), Op1(0b000), CRn(0b0111), CRm(0b0100), Op2(0b000),
216 NULL, reset_unknown, PAR_EL1 },
214 217
215 /* PMINTENSET_EL1 */ 218 /* PMINTENSET_EL1 */
216 { Op0(0b11), Op1(0b000), CRn(0b1001), CRm(0b1110), Op2(0b001), 219 { Op0(0b11), Op1(0b000), CRn(0b1001), CRm(0b1110), Op2(0b001),
diff --git a/arch/avr32/boards/atngw100/mrmt.c b/arch/avr32/boards/atngw100/mrmt.c
index f91431963452..7de083d19b7e 100644
--- a/arch/avr32/boards/atngw100/mrmt.c
+++ b/arch/avr32/boards/atngw100/mrmt.c
@@ -150,7 +150,6 @@ static struct ac97c_platform_data __initdata ac97c0_data = {
150static struct platform_device rmt_ts_device = { 150static struct platform_device rmt_ts_device = {
151 .name = "ucb1400_ts", 151 .name = "ucb1400_ts",
152 .id = -1, 152 .id = -1,
153 }
154}; 153};
155#endif 154#endif
156 155
diff --git a/arch/hexagon/Kconfig b/arch/hexagon/Kconfig
index 33a97929d055..77d442ab28c8 100644
--- a/arch/hexagon/Kconfig
+++ b/arch/hexagon/Kconfig
@@ -158,6 +158,7 @@ source "kernel/Kconfig.hz"
158endmenu 158endmenu
159 159
160source "init/Kconfig" 160source "init/Kconfig"
161source "kernel/Kconfig.freezer"
161source "drivers/Kconfig" 162source "drivers/Kconfig"
162source "fs/Kconfig" 163source "fs/Kconfig"
163 164
diff --git a/arch/ia64/include/asm/tlb.h b/arch/ia64/include/asm/tlb.h
index ef3a9de01954..bc5efc7c3f3f 100644
--- a/arch/ia64/include/asm/tlb.h
+++ b/arch/ia64/include/asm/tlb.h
@@ -22,7 +22,7 @@
22 * unmapping a portion of the virtual address space, these hooks are called according to 22 * unmapping a portion of the virtual address space, these hooks are called according to
23 * the following template: 23 * the following template:
24 * 24 *
25 * tlb <- tlb_gather_mmu(mm, full_mm_flush); // start unmap for address space MM 25 * tlb <- tlb_gather_mmu(mm, start, end); // start unmap for address space MM
26 * { 26 * {
27 * for each vma that needs a shootdown do { 27 * for each vma that needs a shootdown do {
28 * tlb_start_vma(tlb, vma); 28 * tlb_start_vma(tlb, vma);
@@ -58,6 +58,7 @@ struct mmu_gather {
58 unsigned int max; 58 unsigned int max;
59 unsigned char fullmm; /* non-zero means full mm flush */ 59 unsigned char fullmm; /* non-zero means full mm flush */
60 unsigned char need_flush; /* really unmapped some PTEs? */ 60 unsigned char need_flush; /* really unmapped some PTEs? */
61 unsigned long start, end;
61 unsigned long start_addr; 62 unsigned long start_addr;
62 unsigned long end_addr; 63 unsigned long end_addr;
63 struct page **pages; 64 struct page **pages;
@@ -155,13 +156,15 @@ static inline void __tlb_alloc_page(struct mmu_gather *tlb)
155 156
156 157
157static inline void 158static inline void
158tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, unsigned int full_mm_flush) 159tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, unsigned long start, unsigned long end)
159{ 160{
160 tlb->mm = mm; 161 tlb->mm = mm;
161 tlb->max = ARRAY_SIZE(tlb->local); 162 tlb->max = ARRAY_SIZE(tlb->local);
162 tlb->pages = tlb->local; 163 tlb->pages = tlb->local;
163 tlb->nr = 0; 164 tlb->nr = 0;
164 tlb->fullmm = full_mm_flush; 165 tlb->fullmm = !(start | (end+1));
166 tlb->start = start;
167 tlb->end = end;
165 tlb->start_addr = ~0UL; 168 tlb->start_addr = ~0UL;
166} 169}
167 170
diff --git a/arch/m68k/emu/natfeat.c b/arch/m68k/emu/natfeat.c
index 2291a7d69d49..fa277aecfb78 100644
--- a/arch/m68k/emu/natfeat.c
+++ b/arch/m68k/emu/natfeat.c
@@ -18,9 +18,11 @@
18#include <asm/machdep.h> 18#include <asm/machdep.h>
19#include <asm/natfeat.h> 19#include <asm/natfeat.h>
20 20
21extern long nf_get_id2(const char *feature_name);
22
21asm("\n" 23asm("\n"
22" .global nf_get_id,nf_call\n" 24" .global nf_get_id2,nf_call\n"
23"nf_get_id:\n" 25"nf_get_id2:\n"
24" .short 0x7300\n" 26" .short 0x7300\n"
25" rts\n" 27" rts\n"
26"nf_call:\n" 28"nf_call:\n"
@@ -29,12 +31,25 @@ asm("\n"
29"1: moveq.l #0,%d0\n" 31"1: moveq.l #0,%d0\n"
30" rts\n" 32" rts\n"
31" .section __ex_table,\"a\"\n" 33" .section __ex_table,\"a\"\n"
32" .long nf_get_id,1b\n" 34" .long nf_get_id2,1b\n"
33" .long nf_call,1b\n" 35" .long nf_call,1b\n"
34" .previous"); 36" .previous");
35EXPORT_SYMBOL_GPL(nf_get_id);
36EXPORT_SYMBOL_GPL(nf_call); 37EXPORT_SYMBOL_GPL(nf_call);
37 38
39long nf_get_id(const char *feature_name)
40{
41 /* feature_name may be in vmalloc()ed memory, so make a copy */
42 char name_copy[32];
43 size_t n;
44
45 n = strlcpy(name_copy, feature_name, sizeof(name_copy));
46 if (n >= sizeof(name_copy))
47 return 0;
48
49 return nf_get_id2(name_copy);
50}
51EXPORT_SYMBOL_GPL(nf_get_id);
52
38void nfprint(const char *fmt, ...) 53void nfprint(const char *fmt, ...)
39{ 54{
40 static char buf[256]; 55 static char buf[256];
diff --git a/arch/m68k/include/asm/div64.h b/arch/m68k/include/asm/div64.h
index 444ea8a09e9f..ef881cfbbca9 100644
--- a/arch/m68k/include/asm/div64.h
+++ b/arch/m68k/include/asm/div64.h
@@ -15,16 +15,17 @@
15 unsigned long long n64; \ 15 unsigned long long n64; \
16 } __n; \ 16 } __n; \
17 unsigned long __rem, __upper; \ 17 unsigned long __rem, __upper; \
18 unsigned long __base = (base); \
18 \ 19 \
19 __n.n64 = (n); \ 20 __n.n64 = (n); \
20 if ((__upper = __n.n32[0])) { \ 21 if ((__upper = __n.n32[0])) { \
21 asm ("divul.l %2,%1:%0" \ 22 asm ("divul.l %2,%1:%0" \
22 : "=d" (__n.n32[0]), "=d" (__upper) \ 23 : "=d" (__n.n32[0]), "=d" (__upper) \
23 : "d" (base), "0" (__n.n32[0])); \ 24 : "d" (__base), "0" (__n.n32[0])); \
24 } \ 25 } \
25 asm ("divu.l %2,%1:%0" \ 26 asm ("divu.l %2,%1:%0" \
26 : "=d" (__n.n32[1]), "=d" (__rem) \ 27 : "=d" (__n.n32[1]), "=d" (__rem) \
27 : "d" (base), "1" (__upper), "0" (__n.n32[1])); \ 28 : "d" (__base), "1" (__upper), "0" (__n.n32[1])); \
28 (n) = __n.n64; \ 29 (n) = __n.n64; \
29 __rem; \ 30 __rem; \
30}) 31})
diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig
index d22a4ecffff4..4fab52294d98 100644
--- a/arch/microblaze/Kconfig
+++ b/arch/microblaze/Kconfig
@@ -28,7 +28,7 @@ config MICROBLAZE
28 select GENERIC_CLOCKEVENTS 28 select GENERIC_CLOCKEVENTS
29 select GENERIC_IDLE_POLL_SETUP 29 select GENERIC_IDLE_POLL_SETUP
30 select MODULES_USE_ELF_RELA 30 select MODULES_USE_ELF_RELA
31 select CLONE_BACKWARDS 31 select CLONE_BACKWARDS3
32 32
33config SWAP 33config SWAP
34 def_bool n 34 def_bool n
diff --git a/arch/mips/include/asm/cpu-features.h b/arch/mips/include/asm/cpu-features.h
index 1dc086087a72..fa44f3ec5302 100644
--- a/arch/mips/include/asm/cpu-features.h
+++ b/arch/mips/include/asm/cpu-features.h
@@ -17,6 +17,8 @@
17#define current_cpu_type() current_cpu_data.cputype 17#define current_cpu_type() current_cpu_data.cputype
18#endif 18#endif
19 19
20#define boot_cpu_type() cpu_data[0].cputype
21
20/* 22/*
21 * SMP assumption: Options of CPU 0 are a superset of all processors. 23 * SMP assumption: Options of CPU 0 are a superset of all processors.
22 * This is true for all known MIPS systems. 24 * This is true for all known MIPS systems.
diff --git a/arch/mips/kernel/smp-bmips.c b/arch/mips/kernel/smp-bmips.c
index 159abc8842d2..126da74d4c55 100644
--- a/arch/mips/kernel/smp-bmips.c
+++ b/arch/mips/kernel/smp-bmips.c
@@ -66,6 +66,8 @@ static void __init bmips_smp_setup(void)
66 int i, cpu = 1, boot_cpu = 0; 66 int i, cpu = 1, boot_cpu = 0;
67 67
68#if defined(CONFIG_CPU_BMIPS4350) || defined(CONFIG_CPU_BMIPS4380) 68#if defined(CONFIG_CPU_BMIPS4350) || defined(CONFIG_CPU_BMIPS4380)
69 int cpu_hw_intr;
70
69 /* arbitration priority */ 71 /* arbitration priority */
70 clear_c0_brcm_cmt_ctrl(0x30); 72 clear_c0_brcm_cmt_ctrl(0x30);
71 73
@@ -80,8 +82,12 @@ static void __init bmips_smp_setup(void)
80 * MIPS interrupt 2 (HW INT 0) is the CPU0 L1 controller output 82 * MIPS interrupt 2 (HW INT 0) is the CPU0 L1 controller output
81 * MIPS interrupt 3 (HW INT 1) is the CPU1 L1 controller output 83 * MIPS interrupt 3 (HW INT 1) is the CPU1 L1 controller output
82 */ 84 */
83 change_c0_brcm_cmt_intr(0xf8018000, 85 if (boot_cpu == 0)
84 (0x02 << 27) | (0x03 << 15)); 86 cpu_hw_intr = 0x02;
87 else
88 cpu_hw_intr = 0x1d;
89
90 change_c0_brcm_cmt_intr(0xf8018000, (cpu_hw_intr << 27) | (0x03 << 15));
85 91
86 /* single core, 2 threads (2 pipelines) */ 92 /* single core, 2 threads (2 pipelines) */
87 max_cpus = 2; 93 max_cpus = 2;
diff --git a/arch/mips/math-emu/cp1emu.c b/arch/mips/math-emu/cp1emu.c
index e773659ccf9f..46048d24328c 100644
--- a/arch/mips/math-emu/cp1emu.c
+++ b/arch/mips/math-emu/cp1emu.c
@@ -803,6 +803,32 @@ static int isBranchInstr(struct pt_regs *regs, struct mm_decoded_insn dec_insn,
803 dec_insn.next_pc_inc; 803 dec_insn.next_pc_inc;
804 return 1; 804 return 1;
805 break; 805 break;
806#ifdef CONFIG_CPU_CAVIUM_OCTEON
807 case lwc2_op: /* This is bbit0 on Octeon */
808 if ((regs->regs[insn.i_format.rs] & (1ull<<insn.i_format.rt)) == 0)
809 *contpc = regs->cp0_epc + 4 + (insn.i_format.simmediate << 2);
810 else
811 *contpc = regs->cp0_epc + 8;
812 return 1;
813 case ldc2_op: /* This is bbit032 on Octeon */
814 if ((regs->regs[insn.i_format.rs] & (1ull<<(insn.i_format.rt + 32))) == 0)
815 *contpc = regs->cp0_epc + 4 + (insn.i_format.simmediate << 2);
816 else
817 *contpc = regs->cp0_epc + 8;
818 return 1;
819 case swc2_op: /* This is bbit1 on Octeon */
820 if (regs->regs[insn.i_format.rs] & (1ull<<insn.i_format.rt))
821 *contpc = regs->cp0_epc + 4 + (insn.i_format.simmediate << 2);
822 else
823 *contpc = regs->cp0_epc + 8;
824 return 1;
825 case sdc2_op: /* This is bbit132 on Octeon */
826 if (regs->regs[insn.i_format.rs] & (1ull<<(insn.i_format.rt + 32)))
827 *contpc = regs->cp0_epc + 4 + (insn.i_format.simmediate << 2);
828 else
829 *contpc = regs->cp0_epc + 8;
830 return 1;
831#endif
806 case cop0_op: 832 case cop0_op:
807 case cop1_op: 833 case cop1_op:
808 case cop2_op: 834 case cop2_op:
diff --git a/arch/mips/oprofile/op_model_mipsxx.c b/arch/mips/oprofile/op_model_mipsxx.c
index e4b1140cdae0..3a2b6e9f25cf 100644
--- a/arch/mips/oprofile/op_model_mipsxx.c
+++ b/arch/mips/oprofile/op_model_mipsxx.c
@@ -166,7 +166,7 @@ static void mipsxx_reg_setup(struct op_counter_config *ctr)
166 reg.control[i] |= M_PERFCTL_USER; 166 reg.control[i] |= M_PERFCTL_USER;
167 if (ctr[i].exl) 167 if (ctr[i].exl)
168 reg.control[i] |= M_PERFCTL_EXL; 168 reg.control[i] |= M_PERFCTL_EXL;
169 if (current_cpu_type() == CPU_XLR) 169 if (boot_cpu_type() == CPU_XLR)
170 reg.control[i] |= M_PERFCTL_COUNT_ALL_THREADS; 170 reg.control[i] |= M_PERFCTL_COUNT_ALL_THREADS;
171 reg.counter[i] = 0x80000000 - ctr[i].count; 171 reg.counter[i] = 0x80000000 - ctr[i].count;
172 } 172 }
diff --git a/arch/mips/pnx833x/common/platform.c b/arch/mips/pnx833x/common/platform.c
index d22dc0d6f289..2b7e837dc2e2 100644
--- a/arch/mips/pnx833x/common/platform.c
+++ b/arch/mips/pnx833x/common/platform.c
@@ -206,11 +206,13 @@ static struct resource pnx833x_ethernet_resources[] = {
206 .end = PNX8335_IP3902_PORTS_END, 206 .end = PNX8335_IP3902_PORTS_END,
207 .flags = IORESOURCE_MEM, 207 .flags = IORESOURCE_MEM,
208 }, 208 },
209#ifdef CONFIG_SOC_PNX8335
209 [1] = { 210 [1] = {
210 .start = PNX8335_PIC_ETHERNET_INT, 211 .start = PNX8335_PIC_ETHERNET_INT,
211 .end = PNX8335_PIC_ETHERNET_INT, 212 .end = PNX8335_PIC_ETHERNET_INT,
212 .flags = IORESOURCE_IRQ, 213 .flags = IORESOURCE_IRQ,
213 }, 214 },
215#endif
214}; 216};
215 217
216static struct platform_device pnx833x_ethernet_device = { 218static struct platform_device pnx833x_ethernet_device = {
diff --git a/arch/openrisc/Kconfig b/arch/openrisc/Kconfig
index 99dbab1c59ac..d60bf98fa5cf 100644
--- a/arch/openrisc/Kconfig
+++ b/arch/openrisc/Kconfig
@@ -55,6 +55,7 @@ config GENERIC_CSUM
55 55
56source "init/Kconfig" 56source "init/Kconfig"
57 57
58source "kernel/Kconfig.freezer"
58 59
59menu "Processor type and features" 60menu "Processor type and features"
60 61
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 3bf72cd2c8fc..dbd9d3c991e8 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -566,7 +566,7 @@ config SCHED_SMT
566config PPC_DENORMALISATION 566config PPC_DENORMALISATION
567 bool "PowerPC denormalisation exception handling" 567 bool "PowerPC denormalisation exception handling"
568 depends on PPC_BOOK3S_64 568 depends on PPC_BOOK3S_64
569 default "n" 569 default "y" if PPC_POWERNV
570 ---help--- 570 ---help---
571 Add support for handling denormalisation of single precision 571 Add support for handling denormalisation of single precision
572 values. Useful for bare metal only. If unsure say Y here. 572 values. Useful for bare metal only. If unsure say Y here.
diff --git a/arch/powerpc/include/asm/processor.h b/arch/powerpc/include/asm/processor.h
index 47a35b08b963..e378cccfca55 100644
--- a/arch/powerpc/include/asm/processor.h
+++ b/arch/powerpc/include/asm/processor.h
@@ -247,6 +247,10 @@ struct thread_struct {
247 unsigned long tm_orig_msr; /* Thread's MSR on ctx switch */ 247 unsigned long tm_orig_msr; /* Thread's MSR on ctx switch */
248 struct pt_regs ckpt_regs; /* Checkpointed registers */ 248 struct pt_regs ckpt_regs; /* Checkpointed registers */
249 249
250 unsigned long tm_tar;
251 unsigned long tm_ppr;
252 unsigned long tm_dscr;
253
250 /* 254 /*
251 * Transactional FP and VSX 0-31 register set. 255 * Transactional FP and VSX 0-31 register set.
252 * NOTE: the sense of these is the opposite of the integer ckpt_regs! 256 * NOTE: the sense of these is the opposite of the integer ckpt_regs!
diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
index a6840e4e24f7..99222e27f173 100644
--- a/arch/powerpc/include/asm/reg.h
+++ b/arch/powerpc/include/asm/reg.h
@@ -254,19 +254,28 @@
254#define SPRN_HRMOR 0x139 /* Real mode offset register */ 254#define SPRN_HRMOR 0x139 /* Real mode offset register */
255#define SPRN_HSRR0 0x13A /* Hypervisor Save/Restore 0 */ 255#define SPRN_HSRR0 0x13A /* Hypervisor Save/Restore 0 */
256#define SPRN_HSRR1 0x13B /* Hypervisor Save/Restore 1 */ 256#define SPRN_HSRR1 0x13B /* Hypervisor Save/Restore 1 */
257/* HFSCR and FSCR bit numbers are the same */
258#define FSCR_TAR_LG 8 /* Enable Target Address Register */
259#define FSCR_EBB_LG 7 /* Enable Event Based Branching */
260#define FSCR_TM_LG 5 /* Enable Transactional Memory */
261#define FSCR_PM_LG 4 /* Enable prob/priv access to PMU SPRs */
262#define FSCR_BHRB_LG 3 /* Enable Branch History Rolling Buffer*/
263#define FSCR_DSCR_LG 2 /* Enable Data Stream Control Register */
264#define FSCR_VECVSX_LG 1 /* Enable VMX/VSX */
265#define FSCR_FP_LG 0 /* Enable Floating Point */
257#define SPRN_FSCR 0x099 /* Facility Status & Control Register */ 266#define SPRN_FSCR 0x099 /* Facility Status & Control Register */
258#define FSCR_TAR (1 << (63-55)) /* Enable Target Address Register */ 267#define FSCR_TAR __MASK(FSCR_TAR_LG)
259#define FSCR_EBB (1 << (63-56)) /* Enable Event Based Branching */ 268#define FSCR_EBB __MASK(FSCR_EBB_LG)
260#define FSCR_DSCR (1 << (63-61)) /* Enable Data Stream Control Register */ 269#define FSCR_DSCR __MASK(FSCR_DSCR_LG)
261#define SPRN_HFSCR 0xbe /* HV=1 Facility Status & Control Register */ 270#define SPRN_HFSCR 0xbe /* HV=1 Facility Status & Control Register */
262#define HFSCR_TAR (1 << (63-55)) /* Enable Target Address Register */ 271#define HFSCR_TAR __MASK(FSCR_TAR_LG)
263#define HFSCR_EBB (1 << (63-56)) /* Enable Event Based Branching */ 272#define HFSCR_EBB __MASK(FSCR_EBB_LG)
264#define HFSCR_TM (1 << (63-58)) /* Enable Transactional Memory */ 273#define HFSCR_TM __MASK(FSCR_TM_LG)
265#define HFSCR_PM (1 << (63-60)) /* Enable prob/priv access to PMU SPRs */ 274#define HFSCR_PM __MASK(FSCR_PM_LG)
266#define HFSCR_BHRB (1 << (63-59)) /* Enable Branch History Rolling Buffer*/ 275#define HFSCR_BHRB __MASK(FSCR_BHRB_LG)
267#define HFSCR_DSCR (1 << (63-61)) /* Enable Data Stream Control Register */ 276#define HFSCR_DSCR __MASK(FSCR_DSCR_LG)
268#define HFSCR_VECVSX (1 << (63-62)) /* Enable VMX/VSX */ 277#define HFSCR_VECVSX __MASK(FSCR_VECVSX_LG)
269#define HFSCR_FP (1 << (63-63)) /* Enable Floating Point */ 278#define HFSCR_FP __MASK(FSCR_FP_LG)
270#define SPRN_TAR 0x32f /* Target Address Register */ 279#define SPRN_TAR 0x32f /* Target Address Register */
271#define SPRN_LPCR 0x13E /* LPAR Control Register */ 280#define SPRN_LPCR 0x13E /* LPAR Control Register */
272#define LPCR_VPM0 (1ul << (63-0)) 281#define LPCR_VPM0 (1ul << (63-0))
diff --git a/arch/powerpc/include/asm/switch_to.h b/arch/powerpc/include/asm/switch_to.h
index 49a13e0ef234..294c2cedcf7a 100644
--- a/arch/powerpc/include/asm/switch_to.h
+++ b/arch/powerpc/include/asm/switch_to.h
@@ -15,6 +15,15 @@ extern struct task_struct *__switch_to(struct task_struct *,
15struct thread_struct; 15struct thread_struct;
16extern struct task_struct *_switch(struct thread_struct *prev, 16extern struct task_struct *_switch(struct thread_struct *prev,
17 struct thread_struct *next); 17 struct thread_struct *next);
18#ifdef CONFIG_PPC_BOOK3S_64
19static inline void save_tar(struct thread_struct *prev)
20{
21 if (cpu_has_feature(CPU_FTR_ARCH_207S))
22 prev->tar = mfspr(SPRN_TAR);
23}
24#else
25static inline void save_tar(struct thread_struct *prev) {}
26#endif
18 27
19extern void giveup_fpu(struct task_struct *); 28extern void giveup_fpu(struct task_struct *);
20extern void load_up_fpu(void); 29extern void load_up_fpu(void);
diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c
index c7e8afc2ead0..8207459efe56 100644
--- a/arch/powerpc/kernel/asm-offsets.c
+++ b/arch/powerpc/kernel/asm-offsets.c
@@ -138,6 +138,9 @@ int main(void)
138 DEFINE(THREAD_TM_TFHAR, offsetof(struct thread_struct, tm_tfhar)); 138 DEFINE(THREAD_TM_TFHAR, offsetof(struct thread_struct, tm_tfhar));
139 DEFINE(THREAD_TM_TEXASR, offsetof(struct thread_struct, tm_texasr)); 139 DEFINE(THREAD_TM_TEXASR, offsetof(struct thread_struct, tm_texasr));
140 DEFINE(THREAD_TM_TFIAR, offsetof(struct thread_struct, tm_tfiar)); 140 DEFINE(THREAD_TM_TFIAR, offsetof(struct thread_struct, tm_tfiar));
141 DEFINE(THREAD_TM_TAR, offsetof(struct thread_struct, tm_tar));
142 DEFINE(THREAD_TM_PPR, offsetof(struct thread_struct, tm_ppr));
143 DEFINE(THREAD_TM_DSCR, offsetof(struct thread_struct, tm_dscr));
141 DEFINE(PT_CKPT_REGS, offsetof(struct thread_struct, ckpt_regs)); 144 DEFINE(PT_CKPT_REGS, offsetof(struct thread_struct, ckpt_regs));
142 DEFINE(THREAD_TRANSACT_VR0, offsetof(struct thread_struct, 145 DEFINE(THREAD_TRANSACT_VR0, offsetof(struct thread_struct,
143 transact_vr[0])); 146 transact_vr[0]));
diff --git a/arch/powerpc/kernel/eeh.c b/arch/powerpc/kernel/eeh.c
index ea9414c8088d..55593ee2d5aa 100644
--- a/arch/powerpc/kernel/eeh.c
+++ b/arch/powerpc/kernel/eeh.c
@@ -1061,7 +1061,7 @@ static const struct file_operations proc_eeh_operations = {
1061 1061
1062static int __init eeh_init_proc(void) 1062static int __init eeh_init_proc(void)
1063{ 1063{
1064 if (machine_is(pseries)) 1064 if (machine_is(pseries) || machine_is(powernv))
1065 proc_create("powerpc/eeh", 0, NULL, &proc_eeh_operations); 1065 proc_create("powerpc/eeh", 0, NULL, &proc_eeh_operations);
1066 return 0; 1066 return 0;
1067} 1067}
diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S
index ab15b8d057ad..2bd0b885b0fe 100644
--- a/arch/powerpc/kernel/entry_64.S
+++ b/arch/powerpc/kernel/entry_64.S
@@ -449,15 +449,6 @@ END_FTR_SECTION_IFSET(CPU_FTR_DSCR)
449 449
450#ifdef CONFIG_PPC_BOOK3S_64 450#ifdef CONFIG_PPC_BOOK3S_64
451BEGIN_FTR_SECTION 451BEGIN_FTR_SECTION
452 /*
453 * Back up the TAR across context switches. Note that the TAR is not
454 * available for use in the kernel. (To provide this, the TAR should
455 * be backed up/restored on exception entry/exit instead, and be in
456 * pt_regs. FIXME, this should be in pt_regs anyway (for debug).)
457 */
458 mfspr r0,SPRN_TAR
459 std r0,THREAD_TAR(r3)
460
461 /* Event based branch registers */ 452 /* Event based branch registers */
462 mfspr r0, SPRN_BESCR 453 mfspr r0, SPRN_BESCR
463 std r0, THREAD_BESCR(r3) 454 std r0, THREAD_BESCR(r3)
@@ -584,9 +575,34 @@ BEGIN_FTR_SECTION
584 ld r7,DSCR_DEFAULT@toc(2) 575 ld r7,DSCR_DEFAULT@toc(2)
585 ld r0,THREAD_DSCR(r4) 576 ld r0,THREAD_DSCR(r4)
586 cmpwi r6,0 577 cmpwi r6,0
578 li r8, FSCR_DSCR
587 bne 1f 579 bne 1f
588 ld r0,0(r7) 580 ld r0,0(r7)
5891: cmpd r0,r25 581 b 3f
5821:
583 BEGIN_FTR_SECTION_NESTED(70)
584 mfspr r6, SPRN_FSCR
585 or r6, r6, r8
586 mtspr SPRN_FSCR, r6
587 BEGIN_FTR_SECTION_NESTED(69)
588 mfspr r6, SPRN_HFSCR
589 or r6, r6, r8
590 mtspr SPRN_HFSCR, r6
591 END_FTR_SECTION_NESTED(CPU_FTR_HVMODE, CPU_FTR_HVMODE, 69)
592 b 4f
593 END_FTR_SECTION_NESTED(CPU_FTR_ARCH_207S, CPU_FTR_ARCH_207S, 70)
5943:
595 BEGIN_FTR_SECTION_NESTED(70)
596 mfspr r6, SPRN_FSCR
597 andc r6, r6, r8
598 mtspr SPRN_FSCR, r6
599 BEGIN_FTR_SECTION_NESTED(69)
600 mfspr r6, SPRN_HFSCR
601 andc r6, r6, r8
602 mtspr SPRN_HFSCR, r6
603 END_FTR_SECTION_NESTED(CPU_FTR_HVMODE, CPU_FTR_HVMODE, 69)
604 END_FTR_SECTION_NESTED(CPU_FTR_ARCH_207S, CPU_FTR_ARCH_207S, 70)
6054: cmpd r0,r25
590 beq 2f 606 beq 2f
591 mtspr SPRN_DSCR,r0 607 mtspr SPRN_DSCR,r0
5922: 6082:
diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
index 4e00d223b2e3..902ca3c6b4b6 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -848,7 +848,7 @@ hv_facility_unavailable_relon_trampoline:
848 . = 0x4f80 848 . = 0x4f80
849 SET_SCRATCH0(r13) 849 SET_SCRATCH0(r13)
850 EXCEPTION_PROLOG_0(PACA_EXGEN) 850 EXCEPTION_PROLOG_0(PACA_EXGEN)
851 b facility_unavailable_relon_hv 851 b hv_facility_unavailable_relon_hv
852 852
853 STD_RELON_EXCEPTION_PSERIES(0x5300, 0x1300, instruction_breakpoint) 853 STD_RELON_EXCEPTION_PSERIES(0x5300, 0x1300, instruction_breakpoint)
854#ifdef CONFIG_PPC_DENORMALISATION 854#ifdef CONFIG_PPC_DENORMALISATION
@@ -1175,6 +1175,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_VSX)
1175 b .ret_from_except 1175 b .ret_from_except
1176 1176
1177 STD_EXCEPTION_COMMON(0xf60, facility_unavailable, .facility_unavailable_exception) 1177 STD_EXCEPTION_COMMON(0xf60, facility_unavailable, .facility_unavailable_exception)
1178 STD_EXCEPTION_COMMON(0xf80, hv_facility_unavailable, .facility_unavailable_exception)
1178 1179
1179 .align 7 1180 .align 7
1180 .globl __end_handlers 1181 .globl __end_handlers
@@ -1188,7 +1189,7 @@ __end_handlers:
1188 STD_RELON_EXCEPTION_PSERIES_OOL(0xf20, altivec_unavailable) 1189 STD_RELON_EXCEPTION_PSERIES_OOL(0xf20, altivec_unavailable)
1189 STD_RELON_EXCEPTION_PSERIES_OOL(0xf40, vsx_unavailable) 1190 STD_RELON_EXCEPTION_PSERIES_OOL(0xf40, vsx_unavailable)
1190 STD_RELON_EXCEPTION_PSERIES_OOL(0xf60, facility_unavailable) 1191 STD_RELON_EXCEPTION_PSERIES_OOL(0xf60, facility_unavailable)
1191 STD_RELON_EXCEPTION_HV_OOL(0xf80, facility_unavailable) 1192 STD_RELON_EXCEPTION_HV_OOL(0xf80, hv_facility_unavailable)
1192 1193
1193#if defined(CONFIG_PPC_PSERIES) || defined(CONFIG_PPC_POWERNV) 1194#if defined(CONFIG_PPC_PSERIES) || defined(CONFIG_PPC_POWERNV)
1194/* 1195/*
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index c517dbe705fd..8083be20fe5e 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -600,6 +600,16 @@ struct task_struct *__switch_to(struct task_struct *prev,
600 struct ppc64_tlb_batch *batch; 600 struct ppc64_tlb_batch *batch;
601#endif 601#endif
602 602
603 /* Back up the TAR across context switches.
604 * Note that the TAR is not available for use in the kernel. (To
605 * provide this, the TAR should be backed up/restored on exception
606 * entry/exit instead, and be in pt_regs. FIXME, this should be in
607 * pt_regs anyway (for debug).)
608 * Save the TAR here before we do treclaim/trecheckpoint as these
609 * will change the TAR.
610 */
611 save_tar(&prev->thread);
612
603 __switch_to_tm(prev); 613 __switch_to_tm(prev);
604 614
605#ifdef CONFIG_SMP 615#ifdef CONFIG_SMP
diff --git a/arch/powerpc/kernel/tm.S b/arch/powerpc/kernel/tm.S
index 51be8fb24803..0554d1f6d70d 100644
--- a/arch/powerpc/kernel/tm.S
+++ b/arch/powerpc/kernel/tm.S
@@ -233,6 +233,16 @@ dont_backup_fp:
233 std r5, _CCR(r7) 233 std r5, _CCR(r7)
234 std r6, _XER(r7) 234 std r6, _XER(r7)
235 235
236
237 /* ******************** TAR, PPR, DSCR ********** */
238 mfspr r3, SPRN_TAR
239 mfspr r4, SPRN_PPR
240 mfspr r5, SPRN_DSCR
241
242 std r3, THREAD_TM_TAR(r12)
243 std r4, THREAD_TM_PPR(r12)
244 std r5, THREAD_TM_DSCR(r12)
245
236 /* MSR and flags: We don't change CRs, and we don't need to alter 246 /* MSR and flags: We don't change CRs, and we don't need to alter
237 * MSR. 247 * MSR.
238 */ 248 */
@@ -347,6 +357,16 @@ dont_restore_fp:
347 mtmsr r6 /* FP/Vec off again! */ 357 mtmsr r6 /* FP/Vec off again! */
348 358
349restore_gprs: 359restore_gprs:
360
361 /* ******************** TAR, PPR, DSCR ********** */
362 ld r4, THREAD_TM_TAR(r3)
363 ld r5, THREAD_TM_PPR(r3)
364 ld r6, THREAD_TM_DSCR(r3)
365
366 mtspr SPRN_TAR, r4
367 mtspr SPRN_PPR, r5
368 mtspr SPRN_DSCR, r6
369
350 /* ******************** CR,LR,CCR,MSR ********** */ 370 /* ******************** CR,LR,CCR,MSR ********** */
351 ld r3, _CTR(r7) 371 ld r3, _CTR(r7)
352 ld r4, _LINK(r7) 372 ld r4, _LINK(r7)
diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
index bf33c22e38a4..e435bc089ea3 100644
--- a/arch/powerpc/kernel/traps.c
+++ b/arch/powerpc/kernel/traps.c
@@ -44,9 +44,7 @@
44#include <asm/machdep.h> 44#include <asm/machdep.h>
45#include <asm/rtas.h> 45#include <asm/rtas.h>
46#include <asm/pmc.h> 46#include <asm/pmc.h>
47#ifdef CONFIG_PPC32
48#include <asm/reg.h> 47#include <asm/reg.h>
49#endif
50#ifdef CONFIG_PMAC_BACKLIGHT 48#ifdef CONFIG_PMAC_BACKLIGHT
51#include <asm/backlight.h> 49#include <asm/backlight.h>
52#endif 50#endif
@@ -1296,43 +1294,54 @@ void vsx_unavailable_exception(struct pt_regs *regs)
1296 die("Unrecoverable VSX Unavailable Exception", regs, SIGABRT); 1294 die("Unrecoverable VSX Unavailable Exception", regs, SIGABRT);
1297} 1295}
1298 1296
1297#ifdef CONFIG_PPC64
1299void facility_unavailable_exception(struct pt_regs *regs) 1298void facility_unavailable_exception(struct pt_regs *regs)
1300{ 1299{
1301 static char *facility_strings[] = { 1300 static char *facility_strings[] = {
1302 "FPU", 1301 [FSCR_FP_LG] = "FPU",
1303 "VMX/VSX", 1302 [FSCR_VECVSX_LG] = "VMX/VSX",
1304 "DSCR", 1303 [FSCR_DSCR_LG] = "DSCR",
1305 "PMU SPRs", 1304 [FSCR_PM_LG] = "PMU SPRs",
1306 "BHRB", 1305 [FSCR_BHRB_LG] = "BHRB",
1307 "TM", 1306 [FSCR_TM_LG] = "TM",
1308 "AT", 1307 [FSCR_EBB_LG] = "EBB",
1309 "EBB", 1308 [FSCR_TAR_LG] = "TAR",
1310 "TAR",
1311 }; 1309 };
1312 char *facility, *prefix; 1310 char *facility = "unknown";
1313 u64 value; 1311 u64 value;
1312 u8 status;
1313 bool hv;
1314 1314
1315 if (regs->trap == 0xf60) { 1315 hv = (regs->trap == 0xf80);
1316 value = mfspr(SPRN_FSCR); 1316 if (hv)
1317 prefix = "";
1318 } else {
1319 value = mfspr(SPRN_HFSCR); 1317 value = mfspr(SPRN_HFSCR);
1320 prefix = "Hypervisor "; 1318 else
1319 value = mfspr(SPRN_FSCR);
1320
1321 status = value >> 56;
1322 if (status == FSCR_DSCR_LG) {
1323 /* User is acessing the DSCR. Set the inherit bit and allow
1324 * the user to set it directly in future by setting via the
1325 * H/FSCR DSCR bit.
1326 */
1327 current->thread.dscr_inherit = 1;
1328 if (hv)
1329 mtspr(SPRN_HFSCR, value | HFSCR_DSCR);
1330 else
1331 mtspr(SPRN_FSCR, value | FSCR_DSCR);
1332 return;
1321 } 1333 }
1322 1334
1323 value = value >> 56; 1335 if ((status < ARRAY_SIZE(facility_strings)) &&
1336 facility_strings[status])
1337 facility = facility_strings[status];
1324 1338
1325 /* We restore the interrupt state now */ 1339 /* We restore the interrupt state now */
1326 if (!arch_irq_disabled_regs(regs)) 1340 if (!arch_irq_disabled_regs(regs))
1327 local_irq_enable(); 1341 local_irq_enable();
1328 1342
1329 if (value < ARRAY_SIZE(facility_strings))
1330 facility = facility_strings[value];
1331 else
1332 facility = "unknown";
1333
1334 pr_err("%sFacility '%s' unavailable, exception at 0x%lx, MSR=%lx\n", 1343 pr_err("%sFacility '%s' unavailable, exception at 0x%lx, MSR=%lx\n",
1335 prefix, facility, regs->nip, regs->msr); 1344 hv ? "Hypervisor " : "", facility, regs->nip, regs->msr);
1336 1345
1337 if (user_mode(regs)) { 1346 if (user_mode(regs)) {
1338 _exception(SIGILL, regs, ILL_ILLOPC, regs->nip); 1347 _exception(SIGILL, regs, ILL_ILLOPC, regs->nip);
@@ -1341,6 +1350,7 @@ void facility_unavailable_exception(struct pt_regs *regs)
1341 1350
1342 die("Unexpected facility unavailable exception", regs, SIGABRT); 1351 die("Unexpected facility unavailable exception", regs, SIGABRT);
1343} 1352}
1353#endif
1344 1354
1345#ifdef CONFIG_PPC_TRANSACTIONAL_MEM 1355#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
1346 1356
diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
index 2efa9dde741a..7629cd3eb91a 100644
--- a/arch/powerpc/kvm/book3s_hv.c
+++ b/arch/powerpc/kvm/book3s_hv.c
@@ -1809,7 +1809,7 @@ static int kvmppc_hv_setup_htab_rma(struct kvm_vcpu *vcpu)
1809 rma_size <<= PAGE_SHIFT; 1809 rma_size <<= PAGE_SHIFT;
1810 rmls = lpcr_rmls(rma_size); 1810 rmls = lpcr_rmls(rma_size);
1811 err = -EINVAL; 1811 err = -EINVAL;
1812 if (rmls < 0) { 1812 if ((long)rmls < 0) {
1813 pr_err("KVM: Can't use RMA of 0x%lx bytes\n", rma_size); 1813 pr_err("KVM: Can't use RMA of 0x%lx bytes\n", rma_size);
1814 goto out_srcu; 1814 goto out_srcu;
1815 } 1815 }
@@ -1874,7 +1874,7 @@ int kvmppc_core_init_vm(struct kvm *kvm)
1874 /* Allocate the guest's logical partition ID */ 1874 /* Allocate the guest's logical partition ID */
1875 1875
1876 lpid = kvmppc_alloc_lpid(); 1876 lpid = kvmppc_alloc_lpid();
1877 if (lpid < 0) 1877 if ((long)lpid < 0)
1878 return -ENOMEM; 1878 return -ENOMEM;
1879 kvm->arch.lpid = lpid; 1879 kvm->arch.lpid = lpid;
1880 1880
diff --git a/arch/powerpc/kvm/book3s_pr.c b/arch/powerpc/kvm/book3s_pr.c
index 19498a567a81..c6e13d9a9e15 100644
--- a/arch/powerpc/kvm/book3s_pr.c
+++ b/arch/powerpc/kvm/book3s_pr.c
@@ -1047,11 +1047,12 @@ struct kvm_vcpu *kvmppc_core_vcpu_create(struct kvm *kvm, unsigned int id)
1047 if (err) 1047 if (err)
1048 goto free_shadow_vcpu; 1048 goto free_shadow_vcpu;
1049 1049
1050 err = -ENOMEM;
1050 p = __get_free_page(GFP_KERNEL|__GFP_ZERO); 1051 p = __get_free_page(GFP_KERNEL|__GFP_ZERO);
1051 /* the real shared page fills the last 4k of our page */
1052 vcpu->arch.shared = (void*)(p + PAGE_SIZE - 4096);
1053 if (!p) 1052 if (!p)
1054 goto uninit_vcpu; 1053 goto uninit_vcpu;
1054 /* the real shared page fills the last 4k of our page */
1055 vcpu->arch.shared = (void *)(p + PAGE_SIZE - 4096);
1055 1056
1056#ifdef CONFIG_PPC_BOOK3S_64 1057#ifdef CONFIG_PPC_BOOK3S_64
1057 /* default to book3s_64 (970fx) */ 1058 /* default to book3s_64 (970fx) */
diff --git a/arch/powerpc/platforms/pseries/nvram.c b/arch/powerpc/platforms/pseries/nvram.c
index 9f8671a44551..6a5f2b1f32ca 100644
--- a/arch/powerpc/platforms/pseries/nvram.c
+++ b/arch/powerpc/platforms/pseries/nvram.c
@@ -569,35 +569,6 @@ error:
569 return ret; 569 return ret;
570} 570}
571 571
572static int unzip_oops(char *oops_buf, char *big_buf)
573{
574 struct oops_log_info *oops_hdr = (struct oops_log_info *)oops_buf;
575 u64 timestamp = oops_hdr->timestamp;
576 char *big_oops_data = NULL;
577 char *oops_data_buf = NULL;
578 size_t big_oops_data_sz;
579 int unzipped_len;
580
581 big_oops_data = big_buf + sizeof(struct oops_log_info);
582 big_oops_data_sz = big_oops_buf_sz - sizeof(struct oops_log_info);
583 oops_data_buf = oops_buf + sizeof(struct oops_log_info);
584
585 unzipped_len = nvram_decompress(oops_data_buf, big_oops_data,
586 oops_hdr->report_length,
587 big_oops_data_sz);
588
589 if (unzipped_len < 0) {
590 pr_err("nvram: decompression failed; returned %d\n",
591 unzipped_len);
592 return -1;
593 }
594 oops_hdr = (struct oops_log_info *)big_buf;
595 oops_hdr->version = OOPS_HDR_VERSION;
596 oops_hdr->report_length = (u16) unzipped_len;
597 oops_hdr->timestamp = timestamp;
598 return 0;
599}
600
601static int nvram_pstore_open(struct pstore_info *psi) 572static int nvram_pstore_open(struct pstore_info *psi)
602{ 573{
603 /* Reset the iterator to start reading partitions again */ 574 /* Reset the iterator to start reading partitions again */
@@ -685,10 +656,9 @@ static ssize_t nvram_pstore_read(u64 *id, enum pstore_type_id *type,
685 unsigned int err_type, id_no, size = 0; 656 unsigned int err_type, id_no, size = 0;
686 struct nvram_os_partition *part = NULL; 657 struct nvram_os_partition *part = NULL;
687 char *buff = NULL, *big_buff = NULL; 658 char *buff = NULL, *big_buff = NULL;
688 int rc, sig = 0; 659 int sig = 0;
689 loff_t p; 660 loff_t p;
690 661
691read_partition:
692 read_type++; 662 read_type++;
693 663
694 switch (nvram_type_ids[read_type]) { 664 switch (nvram_type_ids[read_type]) {
@@ -749,30 +719,46 @@ read_partition:
749 *id = id_no; 719 *id = id_no;
750 720
751 if (nvram_type_ids[read_type] == PSTORE_TYPE_DMESG) { 721 if (nvram_type_ids[read_type] == PSTORE_TYPE_DMESG) {
722 int length, unzipped_len;
723 size_t hdr_size;
724
752 oops_hdr = (struct oops_log_info *)buff; 725 oops_hdr = (struct oops_log_info *)buff;
753 *buf = buff + sizeof(*oops_hdr); 726 if (oops_hdr->version < OOPS_HDR_VERSION) {
727 /* Old format oops header had 2-byte record size */
728 hdr_size = sizeof(u16);
729 length = oops_hdr->version;
730 time->tv_sec = 0;
731 time->tv_nsec = 0;
732 } else {
733 hdr_size = sizeof(*oops_hdr);
734 length = oops_hdr->report_length;
735 time->tv_sec = oops_hdr->timestamp;
736 time->tv_nsec = 0;
737 }
738 *buf = kmalloc(length, GFP_KERNEL);
739 if (*buf == NULL)
740 return -ENOMEM;
741 memcpy(*buf, buff + hdr_size, length);
742 kfree(buff);
754 743
755 if (err_type == ERR_TYPE_KERNEL_PANIC_GZ) { 744 if (err_type == ERR_TYPE_KERNEL_PANIC_GZ) {
756 big_buff = kmalloc(big_oops_buf_sz, GFP_KERNEL); 745 big_buff = kmalloc(big_oops_buf_sz, GFP_KERNEL);
757 if (!big_buff) 746 if (!big_buff)
758 return -ENOMEM; 747 return -ENOMEM;
759 748
760 rc = unzip_oops(buff, big_buff); 749 unzipped_len = nvram_decompress(*buf, big_buff,
750 length, big_oops_buf_sz);
761 751
762 if (rc != 0) { 752 if (unzipped_len < 0) {
763 kfree(buff); 753 pr_err("nvram: decompression failed, returned "
754 "rc %d\n", unzipped_len);
764 kfree(big_buff); 755 kfree(big_buff);
765 goto read_partition; 756 } else {
757 *buf = big_buff;
758 length = unzipped_len;
766 } 759 }
767
768 oops_hdr = (struct oops_log_info *)big_buff;
769 *buf = big_buff + sizeof(*oops_hdr);
770 kfree(buff);
771 } 760 }
772 761 return length;
773 time->tv_sec = oops_hdr->timestamp;
774 time->tv_nsec = 0;
775 return oops_hdr->report_length;
776 } 762 }
777 763
778 *buf = buff; 764 *buf = buff;
@@ -816,6 +802,7 @@ static int nvram_pstore_init(void)
816static void __init nvram_init_oops_partition(int rtas_partition_exists) 802static void __init nvram_init_oops_partition(int rtas_partition_exists)
817{ 803{
818 int rc; 804 int rc;
805 size_t size;
819 806
820 rc = pseries_nvram_init_os_partition(&oops_log_partition); 807 rc = pseries_nvram_init_os_partition(&oops_log_partition);
821 if (rc != 0) { 808 if (rc != 0) {
@@ -844,8 +831,9 @@ static void __init nvram_init_oops_partition(int rtas_partition_exists)
844 big_oops_buf_sz = (oops_data_sz * 100) / 45; 831 big_oops_buf_sz = (oops_data_sz * 100) / 45;
845 big_oops_buf = kmalloc(big_oops_buf_sz, GFP_KERNEL); 832 big_oops_buf = kmalloc(big_oops_buf_sz, GFP_KERNEL);
846 if (big_oops_buf) { 833 if (big_oops_buf) {
847 stream.workspace = kmalloc(zlib_deflate_workspacesize( 834 size = max(zlib_deflate_workspacesize(WINDOW_BITS, MEM_LEVEL),
848 WINDOW_BITS, MEM_LEVEL), GFP_KERNEL); 835 zlib_inflate_workspacesize());
836 stream.workspace = kmalloc(size, GFP_KERNEL);
849 if (!stream.workspace) { 837 if (!stream.workspace) {
850 pr_err("nvram: No memory for compression workspace; " 838 pr_err("nvram: No memory for compression workspace; "
851 "skipping compression of %s partition data\n", 839 "skipping compression of %s partition data\n",
diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index 22f75b504f7f..8a4cae78f03c 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -118,6 +118,7 @@ config S390
118 select HAVE_FUNCTION_TRACE_MCOUNT_TEST 118 select HAVE_FUNCTION_TRACE_MCOUNT_TEST
119 select HAVE_KERNEL_BZIP2 119 select HAVE_KERNEL_BZIP2
120 select HAVE_KERNEL_GZIP 120 select HAVE_KERNEL_GZIP
121 select HAVE_KERNEL_LZ4
121 select HAVE_KERNEL_LZMA 122 select HAVE_KERNEL_LZMA
122 select HAVE_KERNEL_LZO 123 select HAVE_KERNEL_LZO
123 select HAVE_KERNEL_XZ 124 select HAVE_KERNEL_XZ
@@ -227,11 +228,12 @@ config MARCH_Z196
227 not work on older machines. 228 not work on older machines.
228 229
229config MARCH_ZEC12 230config MARCH_ZEC12
230 bool "IBM zEC12" 231 bool "IBM zBC12 and zEC12"
231 select HAVE_MARCH_ZEC12_FEATURES if 64BIT 232 select HAVE_MARCH_ZEC12_FEATURES if 64BIT
232 help 233 help
233 Select this to enable optimizations for IBM zEC12 (2827 series). The 234 Select this to enable optimizations for IBM zBC12 and zEC12 (2828 and
234 kernel will be slightly faster but will not work on older machines. 235 2827 series). The kernel will be slightly faster but will not work on
236 older machines.
235 237
236endchoice 238endchoice
237 239
@@ -709,6 +711,7 @@ config S390_GUEST
709 def_bool y 711 def_bool y
710 prompt "s390 support for virtio devices" 712 prompt "s390 support for virtio devices"
711 depends on 64BIT 713 depends on 64BIT
714 select TTY
712 select VIRTUALIZATION 715 select VIRTUALIZATION
713 select VIRTIO 716 select VIRTIO
714 select VIRTIO_CONSOLE 717 select VIRTIO_CONSOLE
diff --git a/arch/s390/boot/compressed/Makefile b/arch/s390/boot/compressed/Makefile
index 3ad8f61c9985..866ecbe670e4 100644
--- a/arch/s390/boot/compressed/Makefile
+++ b/arch/s390/boot/compressed/Makefile
@@ -6,9 +6,9 @@
6 6
7BITS := $(if $(CONFIG_64BIT),64,31) 7BITS := $(if $(CONFIG_64BIT),64,31)
8 8
9targets := vmlinux.lds vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 \ 9targets := vmlinux.lds vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2
10 vmlinux.bin.xz vmlinux.bin.lzma vmlinux.bin.lzo misc.o piggy.o \ 10targets += vmlinux.bin.xz vmlinux.bin.lzma vmlinux.bin.lzo vmlinux.bin.lz4
11 sizes.h head$(BITS).o 11targets += misc.o piggy.o sizes.h head$(BITS).o
12 12
13KBUILD_CFLAGS := -m$(BITS) -D__KERNEL__ $(LINUX_INCLUDE) -O2 13KBUILD_CFLAGS := -m$(BITS) -D__KERNEL__ $(LINUX_INCLUDE) -O2
14KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING 14KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING
@@ -48,6 +48,7 @@ vmlinux.bin.all-y := $(obj)/vmlinux.bin
48 48
49suffix-$(CONFIG_KERNEL_GZIP) := gz 49suffix-$(CONFIG_KERNEL_GZIP) := gz
50suffix-$(CONFIG_KERNEL_BZIP2) := bz2 50suffix-$(CONFIG_KERNEL_BZIP2) := bz2
51suffix-$(CONFIG_KERNEL_LZ4) := lz4
51suffix-$(CONFIG_KERNEL_LZMA) := lzma 52suffix-$(CONFIG_KERNEL_LZMA) := lzma
52suffix-$(CONFIG_KERNEL_LZO) := lzo 53suffix-$(CONFIG_KERNEL_LZO) := lzo
53suffix-$(CONFIG_KERNEL_XZ) := xz 54suffix-$(CONFIG_KERNEL_XZ) := xz
@@ -56,6 +57,8 @@ $(obj)/vmlinux.bin.gz: $(vmlinux.bin.all-y)
56 $(call if_changed,gzip) 57 $(call if_changed,gzip)
57$(obj)/vmlinux.bin.bz2: $(vmlinux.bin.all-y) 58$(obj)/vmlinux.bin.bz2: $(vmlinux.bin.all-y)
58 $(call if_changed,bzip2) 59 $(call if_changed,bzip2)
60$(obj)/vmlinux.bin.lz4: $(vmlinux.bin.all-y)
61 $(call if_changed,lz4)
59$(obj)/vmlinux.bin.lzma: $(vmlinux.bin.all-y) 62$(obj)/vmlinux.bin.lzma: $(vmlinux.bin.all-y)
60 $(call if_changed,lzma) 63 $(call if_changed,lzma)
61$(obj)/vmlinux.bin.lzo: $(vmlinux.bin.all-y) 64$(obj)/vmlinux.bin.lzo: $(vmlinux.bin.all-y)
diff --git a/arch/s390/boot/compressed/misc.c b/arch/s390/boot/compressed/misc.c
index c4c6a1cf221b..57cbaff1f397 100644
--- a/arch/s390/boot/compressed/misc.c
+++ b/arch/s390/boot/compressed/misc.c
@@ -47,6 +47,10 @@ static unsigned long free_mem_end_ptr;
47#include "../../../../lib/decompress_bunzip2.c" 47#include "../../../../lib/decompress_bunzip2.c"
48#endif 48#endif
49 49
50#ifdef CONFIG_KERNEL_LZ4
51#include "../../../../lib/decompress_unlz4.c"
52#endif
53
50#ifdef CONFIG_KERNEL_LZMA 54#ifdef CONFIG_KERNEL_LZMA
51#include "../../../../lib/decompress_unlzma.c" 55#include "../../../../lib/decompress_unlzma.c"
52#endif 56#endif
diff --git a/arch/s390/include/asm/bitops.h b/arch/s390/include/asm/bitops.h
index 4d8604e311f3..7d4676758733 100644
--- a/arch/s390/include/asm/bitops.h
+++ b/arch/s390/include/asm/bitops.h
@@ -693,7 +693,7 @@ static inline int find_next_bit_left(const unsigned long *addr,
693 size -= offset; 693 size -= offset;
694 p = addr + offset / BITS_PER_LONG; 694 p = addr + offset / BITS_PER_LONG;
695 if (bit) { 695 if (bit) {
696 set = __flo_word(0, *p & (~0UL << bit)); 696 set = __flo_word(0, *p & (~0UL >> bit));
697 if (set >= size) 697 if (set >= size)
698 return size + offset; 698 return size + offset;
699 if (set < BITS_PER_LONG) 699 if (set < BITS_PER_LONG)
diff --git a/arch/s390/include/asm/tlb.h b/arch/s390/include/asm/tlb.h
index b75d7d686684..6d6d92b4ea11 100644
--- a/arch/s390/include/asm/tlb.h
+++ b/arch/s390/include/asm/tlb.h
@@ -32,6 +32,7 @@ struct mmu_gather {
32 struct mm_struct *mm; 32 struct mm_struct *mm;
33 struct mmu_table_batch *batch; 33 struct mmu_table_batch *batch;
34 unsigned int fullmm; 34 unsigned int fullmm;
35 unsigned long start, end;
35}; 36};
36 37
37struct mmu_table_batch { 38struct mmu_table_batch {
@@ -48,10 +49,13 @@ extern void tlb_remove_table(struct mmu_gather *tlb, void *table);
48 49
49static inline void tlb_gather_mmu(struct mmu_gather *tlb, 50static inline void tlb_gather_mmu(struct mmu_gather *tlb,
50 struct mm_struct *mm, 51 struct mm_struct *mm,
51 unsigned int full_mm_flush) 52 unsigned long start,
53 unsigned long end)
52{ 54{
53 tlb->mm = mm; 55 tlb->mm = mm;
54 tlb->fullmm = full_mm_flush; 56 tlb->start = start;
57 tlb->end = end;
58 tlb->fullmm = !(start | (end+1));
55 tlb->batch = NULL; 59 tlb->batch = NULL;
56 if (tlb->fullmm) 60 if (tlb->fullmm)
57 __tlb_flush_mm(mm); 61 __tlb_flush_mm(mm);
diff --git a/arch/s390/kernel/perf_event.c b/arch/s390/kernel/perf_event.c
index a6fc037671b1..500aa1029bcb 100644
--- a/arch/s390/kernel/perf_event.c
+++ b/arch/s390/kernel/perf_event.c
@@ -52,12 +52,13 @@ static struct kvm_s390_sie_block *sie_block(struct pt_regs *regs)
52 52
53static bool is_in_guest(struct pt_regs *regs) 53static bool is_in_guest(struct pt_regs *regs)
54{ 54{
55 unsigned long ip = instruction_pointer(regs);
56
57 if (user_mode(regs)) 55 if (user_mode(regs))
58 return false; 56 return false;
59 57#if defined(CONFIG_KVM) || defined(CONFIG_KVM_MODULE)
60 return ip == (unsigned long) &sie_exit; 58 return instruction_pointer(regs) == (unsigned long) &sie_exit;
59#else
60 return false;
61#endif
61} 62}
62 63
63static unsigned long guest_is_user_mode(struct pt_regs *regs) 64static unsigned long guest_is_user_mode(struct pt_regs *regs)
diff --git a/arch/s390/kernel/setup.c b/arch/s390/kernel/setup.c
index 497451ec5e26..aeed8a61fa0d 100644
--- a/arch/s390/kernel/setup.c
+++ b/arch/s390/kernel/setup.c
@@ -994,6 +994,7 @@ static void __init setup_hwcaps(void)
994 strcpy(elf_platform, "z196"); 994 strcpy(elf_platform, "z196");
995 break; 995 break;
996 case 0x2827: 996 case 0x2827:
997 case 0x2828:
997 strcpy(elf_platform, "zEC12"); 998 strcpy(elf_platform, "zEC12");
998 break; 999 break;
999 } 1000 }
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index ba694d2ba51e..34c1c9a90be2 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -702,14 +702,25 @@ static int __vcpu_run(struct kvm_vcpu *vcpu)
702 return rc; 702 return rc;
703 703
704 vcpu->arch.sie_block->icptcode = 0; 704 vcpu->arch.sie_block->icptcode = 0;
705 preempt_disable();
706 kvm_guest_enter();
707 preempt_enable();
708 VCPU_EVENT(vcpu, 6, "entering sie flags %x", 705 VCPU_EVENT(vcpu, 6, "entering sie flags %x",
709 atomic_read(&vcpu->arch.sie_block->cpuflags)); 706 atomic_read(&vcpu->arch.sie_block->cpuflags));
710 trace_kvm_s390_sie_enter(vcpu, 707 trace_kvm_s390_sie_enter(vcpu,
711 atomic_read(&vcpu->arch.sie_block->cpuflags)); 708 atomic_read(&vcpu->arch.sie_block->cpuflags));
709
710 /*
711 * As PF_VCPU will be used in fault handler, between guest_enter
712 * and guest_exit should be no uaccess.
713 */
714 preempt_disable();
715 kvm_guest_enter();
716 preempt_enable();
712 rc = sie64a(vcpu->arch.sie_block, vcpu->run->s.regs.gprs); 717 rc = sie64a(vcpu->arch.sie_block, vcpu->run->s.regs.gprs);
718 kvm_guest_exit();
719
720 VCPU_EVENT(vcpu, 6, "exit sie icptcode %d",
721 vcpu->arch.sie_block->icptcode);
722 trace_kvm_s390_sie_exit(vcpu, vcpu->arch.sie_block->icptcode);
723
713 if (rc > 0) 724 if (rc > 0)
714 rc = 0; 725 rc = 0;
715 if (rc < 0) { 726 if (rc < 0) {
@@ -721,10 +732,6 @@ static int __vcpu_run(struct kvm_vcpu *vcpu)
721 rc = kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING); 732 rc = kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING);
722 } 733 }
723 } 734 }
724 VCPU_EVENT(vcpu, 6, "exit sie icptcode %d",
725 vcpu->arch.sie_block->icptcode);
726 trace_kvm_s390_sie_exit(vcpu, vcpu->arch.sie_block->icptcode);
727 kvm_guest_exit();
728 735
729 memcpy(&vcpu->run->s.regs.gprs[14], &vcpu->arch.sie_block->gg14, 16); 736 memcpy(&vcpu->run->s.regs.gprs[14], &vcpu->arch.sie_block->gg14, 16);
730 return rc; 737 return rc;
diff --git a/arch/s390/kvm/priv.c b/arch/s390/kvm/priv.c
index 0da3e6eb6be6..4cdc54e63ebc 100644
--- a/arch/s390/kvm/priv.c
+++ b/arch/s390/kvm/priv.c
@@ -16,6 +16,7 @@
16#include <linux/errno.h> 16#include <linux/errno.h>
17#include <linux/compat.h> 17#include <linux/compat.h>
18#include <asm/asm-offsets.h> 18#include <asm/asm-offsets.h>
19#include <asm/facility.h>
19#include <asm/current.h> 20#include <asm/current.h>
20#include <asm/debug.h> 21#include <asm/debug.h>
21#include <asm/ebcdic.h> 22#include <asm/ebcdic.h>
@@ -532,8 +533,7 @@ static int handle_pfmf(struct kvm_vcpu *vcpu)
532 return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION); 533 return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION);
533 534
534 /* Only provide non-quiescing support if the host supports it */ 535 /* Only provide non-quiescing support if the host supports it */
535 if (vcpu->run->s.regs.gprs[reg1] & PFMF_NQ && 536 if (vcpu->run->s.regs.gprs[reg1] & PFMF_NQ && !test_facility(14))
536 S390_lowcore.stfl_fac_list & 0x00020000)
537 return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION); 537 return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION);
538 538
539 /* No support for conditional-SSKE */ 539 /* No support for conditional-SSKE */
diff --git a/arch/s390/mm/init.c b/arch/s390/mm/init.c
index ce36ea80e4f9..ad446b0c55b6 100644
--- a/arch/s390/mm/init.c
+++ b/arch/s390/mm/init.c
@@ -69,6 +69,7 @@ static void __init setup_zero_pages(void)
69 order = 2; 69 order = 2;
70 break; 70 break;
71 case 0x2827: /* zEC12 */ 71 case 0x2827: /* zEC12 */
72 case 0x2828: /* zEC12 */
72 default: 73 default:
73 order = 5; 74 order = 5;
74 break; 75 break;
diff --git a/arch/s390/oprofile/init.c b/arch/s390/oprofile/init.c
index ffeb17ce7f31..930783d2c99b 100644
--- a/arch/s390/oprofile/init.c
+++ b/arch/s390/oprofile/init.c
@@ -440,7 +440,7 @@ static int oprofile_hwsampler_init(struct oprofile_operations *ops)
440 switch (id.machine) { 440 switch (id.machine) {
441 case 0x2097: case 0x2098: ops->cpu_type = "s390/z10"; break; 441 case 0x2097: case 0x2098: ops->cpu_type = "s390/z10"; break;
442 case 0x2817: case 0x2818: ops->cpu_type = "s390/z196"; break; 442 case 0x2817: case 0x2818: ops->cpu_type = "s390/z196"; break;
443 case 0x2827: ops->cpu_type = "s390/zEC12"; break; 443 case 0x2827: case 0x2828: ops->cpu_type = "s390/zEC12"; break;
444 default: return -ENODEV; 444 default: return -ENODEV;
445 } 445 }
446 } 446 }
diff --git a/arch/score/Kconfig b/arch/score/Kconfig
index c8def8bc9020..5fc237581caf 100644
--- a/arch/score/Kconfig
+++ b/arch/score/Kconfig
@@ -87,6 +87,8 @@ config STACKTRACE_SUPPORT
87 87
88source "init/Kconfig" 88source "init/Kconfig"
89 89
90source "kernel/Kconfig.freezer"
91
90config MMU 92config MMU
91 def_bool y 93 def_bool y
92 94
diff --git a/arch/sh/include/asm/tlb.h b/arch/sh/include/asm/tlb.h
index e61d43d9f689..362192ed12fe 100644
--- a/arch/sh/include/asm/tlb.h
+++ b/arch/sh/include/asm/tlb.h
@@ -36,10 +36,12 @@ static inline void init_tlb_gather(struct mmu_gather *tlb)
36} 36}
37 37
38static inline void 38static inline void
39tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, unsigned int full_mm_flush) 39tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, unsigned long start, unsigned long end)
40{ 40{
41 tlb->mm = mm; 41 tlb->mm = mm;
42 tlb->fullmm = full_mm_flush; 42 tlb->start = start;
43 tlb->end = end;
44 tlb->fullmm = !(start | (end+1));
43 45
44 init_tlb_gather(tlb); 46 init_tlb_gather(tlb);
45} 47}
diff --git a/arch/um/include/asm/tlb.h b/arch/um/include/asm/tlb.h
index 4febacd1a8a1..29b0301c18aa 100644
--- a/arch/um/include/asm/tlb.h
+++ b/arch/um/include/asm/tlb.h
@@ -45,10 +45,12 @@ static inline void init_tlb_gather(struct mmu_gather *tlb)
45} 45}
46 46
47static inline void 47static inline void
48tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, unsigned int full_mm_flush) 48tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, unsigned long start, unsigned long end)
49{ 49{
50 tlb->mm = mm; 50 tlb->mm = mm;
51 tlb->fullmm = full_mm_flush; 51 tlb->start = start;
52 tlb->end = end;
53 tlb->fullmm = !(start | (end+1));
52 54
53 init_tlb_gather(tlb); 55 init_tlb_gather(tlb);
54} 56}
diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
index d606463aa6d6..b7388a425f09 100644
--- a/arch/x86/boot/compressed/eboot.c
+++ b/arch/x86/boot/compressed/eboot.c
@@ -225,7 +225,7 @@ static void low_free(unsigned long size, unsigned long addr)
225 unsigned long nr_pages; 225 unsigned long nr_pages;
226 226
227 nr_pages = round_up(size, EFI_PAGE_SIZE) / EFI_PAGE_SIZE; 227 nr_pages = round_up(size, EFI_PAGE_SIZE) / EFI_PAGE_SIZE;
228 efi_call_phys2(sys_table->boottime->free_pages, addr, size); 228 efi_call_phys2(sys_table->boottime->free_pages, addr, nr_pages);
229} 229}
230 230
231static void find_bits(unsigned long mask, u8 *pos, u8 *size) 231static void find_bits(unsigned long mask, u8 *pos, u8 *size)
diff --git a/arch/x86/include/asm/bootparam_utils.h b/arch/x86/include/asm/bootparam_utils.h
index 653668d140f9..4a8cb8d7cbd5 100644
--- a/arch/x86/include/asm/bootparam_utils.h
+++ b/arch/x86/include/asm/bootparam_utils.h
@@ -35,9 +35,9 @@ static void sanitize_boot_params(struct boot_params *boot_params)
35 */ 35 */
36 if (boot_params->sentinel) { 36 if (boot_params->sentinel) {
37 /* fields in boot_params are left uninitialized, clear them */ 37 /* fields in boot_params are left uninitialized, clear them */
38 memset(&boot_params->olpc_ofw_header, 0, 38 memset(&boot_params->ext_ramdisk_image, 0,
39 (char *)&boot_params->efi_info - 39 (char *)&boot_params->efi_info -
40 (char *)&boot_params->olpc_ofw_header); 40 (char *)&boot_params->ext_ramdisk_image);
41 memset(&boot_params->kbd_status, 0, 41 memset(&boot_params->kbd_status, 0,
42 (char *)&boot_params->hdr - 42 (char *)&boot_params->hdr -
43 (char *)&boot_params->kbd_status); 43 (char *)&boot_params->kbd_status);
diff --git a/arch/x86/include/asm/microcode_amd.h b/arch/x86/include/asm/microcode_amd.h
index 50e5c58ced23..4c019179a57d 100644
--- a/arch/x86/include/asm/microcode_amd.h
+++ b/arch/x86/include/asm/microcode_amd.h
@@ -59,7 +59,7 @@ static inline u16 find_equiv_id(struct equiv_cpu_entry *equiv_cpu_table,
59 59
60extern int __apply_microcode_amd(struct microcode_amd *mc_amd); 60extern int __apply_microcode_amd(struct microcode_amd *mc_amd);
61extern int apply_microcode_amd(int cpu); 61extern int apply_microcode_amd(int cpu);
62extern enum ucode_state load_microcode_amd(int cpu, const u8 *data, size_t size); 62extern enum ucode_state load_microcode_amd(u8 family, const u8 *data, size_t size);
63 63
64#ifdef CONFIG_MICROCODE_AMD_EARLY 64#ifdef CONFIG_MICROCODE_AMD_EARLY
65#ifdef CONFIG_X86_32 65#ifdef CONFIG_X86_32
diff --git a/arch/x86/include/asm/pgtable-2level.h b/arch/x86/include/asm/pgtable-2level.h
index f2b489cf1602..3bf2dd0cf61f 100644
--- a/arch/x86/include/asm/pgtable-2level.h
+++ b/arch/x86/include/asm/pgtable-2level.h
@@ -55,9 +55,53 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *xp)
55#define native_pmdp_get_and_clear(xp) native_local_pmdp_get_and_clear(xp) 55#define native_pmdp_get_and_clear(xp) native_local_pmdp_get_and_clear(xp)
56#endif 56#endif
57 57
58#ifdef CONFIG_MEM_SOFT_DIRTY
59
60/*
61 * Bits _PAGE_BIT_PRESENT, _PAGE_BIT_FILE, _PAGE_BIT_SOFT_DIRTY and
62 * _PAGE_BIT_PROTNONE are taken, split up the 28 bits of offset
63 * into this range.
64 */
65#define PTE_FILE_MAX_BITS 28
66#define PTE_FILE_SHIFT1 (_PAGE_BIT_PRESENT + 1)
67#define PTE_FILE_SHIFT2 (_PAGE_BIT_FILE + 1)
68#define PTE_FILE_SHIFT3 (_PAGE_BIT_PROTNONE + 1)
69#define PTE_FILE_SHIFT4 (_PAGE_BIT_SOFT_DIRTY + 1)
70#define PTE_FILE_BITS1 (PTE_FILE_SHIFT2 - PTE_FILE_SHIFT1 - 1)
71#define PTE_FILE_BITS2 (PTE_FILE_SHIFT3 - PTE_FILE_SHIFT2 - 1)
72#define PTE_FILE_BITS3 (PTE_FILE_SHIFT4 - PTE_FILE_SHIFT3 - 1)
73
74#define pte_to_pgoff(pte) \
75 ((((pte).pte_low >> (PTE_FILE_SHIFT1)) \
76 & ((1U << PTE_FILE_BITS1) - 1))) \
77 + ((((pte).pte_low >> (PTE_FILE_SHIFT2)) \
78 & ((1U << PTE_FILE_BITS2) - 1)) \
79 << (PTE_FILE_BITS1)) \
80 + ((((pte).pte_low >> (PTE_FILE_SHIFT3)) \
81 & ((1U << PTE_FILE_BITS3) - 1)) \
82 << (PTE_FILE_BITS1 + PTE_FILE_BITS2)) \
83 + ((((pte).pte_low >> (PTE_FILE_SHIFT4))) \
84 << (PTE_FILE_BITS1 + PTE_FILE_BITS2 + PTE_FILE_BITS3))
85
86#define pgoff_to_pte(off) \
87 ((pte_t) { .pte_low = \
88 ((((off)) & ((1U << PTE_FILE_BITS1) - 1)) << PTE_FILE_SHIFT1) \
89 + ((((off) >> PTE_FILE_BITS1) \
90 & ((1U << PTE_FILE_BITS2) - 1)) \
91 << PTE_FILE_SHIFT2) \
92 + ((((off) >> (PTE_FILE_BITS1 + PTE_FILE_BITS2)) \
93 & ((1U << PTE_FILE_BITS3) - 1)) \
94 << PTE_FILE_SHIFT3) \
95 + ((((off) >> \
96 (PTE_FILE_BITS1 + PTE_FILE_BITS2 + PTE_FILE_BITS3))) \
97 << PTE_FILE_SHIFT4) \
98 + _PAGE_FILE })
99
100#else /* CONFIG_MEM_SOFT_DIRTY */
101
58/* 102/*
59 * Bits _PAGE_BIT_PRESENT, _PAGE_BIT_FILE and _PAGE_BIT_PROTNONE are taken, 103 * Bits _PAGE_BIT_PRESENT, _PAGE_BIT_FILE and _PAGE_BIT_PROTNONE are taken,
60 * split up the 29 bits of offset into this range: 104 * split up the 29 bits of offset into this range.
61 */ 105 */
62#define PTE_FILE_MAX_BITS 29 106#define PTE_FILE_MAX_BITS 29
63#define PTE_FILE_SHIFT1 (_PAGE_BIT_PRESENT + 1) 107#define PTE_FILE_SHIFT1 (_PAGE_BIT_PRESENT + 1)
@@ -88,6 +132,8 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *xp)
88 << PTE_FILE_SHIFT3) \ 132 << PTE_FILE_SHIFT3) \
89 + _PAGE_FILE }) 133 + _PAGE_FILE })
90 134
135#endif /* CONFIG_MEM_SOFT_DIRTY */
136
91/* Encode and de-code a swap entry */ 137/* Encode and de-code a swap entry */
92#if _PAGE_BIT_FILE < _PAGE_BIT_PROTNONE 138#if _PAGE_BIT_FILE < _PAGE_BIT_PROTNONE
93#define SWP_TYPE_BITS (_PAGE_BIT_FILE - _PAGE_BIT_PRESENT - 1) 139#define SWP_TYPE_BITS (_PAGE_BIT_FILE - _PAGE_BIT_PRESENT - 1)
diff --git a/arch/x86/include/asm/pgtable-3level.h b/arch/x86/include/asm/pgtable-3level.h
index 4cc9f2b7cdc3..81bb91b49a88 100644
--- a/arch/x86/include/asm/pgtable-3level.h
+++ b/arch/x86/include/asm/pgtable-3level.h
@@ -179,6 +179,9 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *pmdp)
179/* 179/*
180 * Bits 0, 6 and 7 are taken in the low part of the pte, 180 * Bits 0, 6 and 7 are taken in the low part of the pte,
181 * put the 32 bits of offset into the high part. 181 * put the 32 bits of offset into the high part.
182 *
183 * For soft-dirty tracking 11 bit is taken from
184 * the low part of pte as well.
182 */ 185 */
183#define pte_to_pgoff(pte) ((pte).pte_high) 186#define pte_to_pgoff(pte) ((pte).pte_high)
184#define pgoff_to_pte(off) \ 187#define pgoff_to_pte(off) \
diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
index 7dc305a46058..1c00631164c2 100644
--- a/arch/x86/include/asm/pgtable.h
+++ b/arch/x86/include/asm/pgtable.h
@@ -314,6 +314,36 @@ static inline pmd_t pmd_mksoft_dirty(pmd_t pmd)
314 return pmd_set_flags(pmd, _PAGE_SOFT_DIRTY); 314 return pmd_set_flags(pmd, _PAGE_SOFT_DIRTY);
315} 315}
316 316
317static inline pte_t pte_swp_mksoft_dirty(pte_t pte)
318{
319 return pte_set_flags(pte, _PAGE_SWP_SOFT_DIRTY);
320}
321
322static inline int pte_swp_soft_dirty(pte_t pte)
323{
324 return pte_flags(pte) & _PAGE_SWP_SOFT_DIRTY;
325}
326
327static inline pte_t pte_swp_clear_soft_dirty(pte_t pte)
328{
329 return pte_clear_flags(pte, _PAGE_SWP_SOFT_DIRTY);
330}
331
332static inline pte_t pte_file_clear_soft_dirty(pte_t pte)
333{
334 return pte_clear_flags(pte, _PAGE_SOFT_DIRTY);
335}
336
337static inline pte_t pte_file_mksoft_dirty(pte_t pte)
338{
339 return pte_set_flags(pte, _PAGE_SOFT_DIRTY);
340}
341
342static inline int pte_file_soft_dirty(pte_t pte)
343{
344 return pte_flags(pte) & _PAGE_SOFT_DIRTY;
345}
346
317/* 347/*
318 * Mask out unsupported bits in a present pgprot. Non-present pgprots 348 * Mask out unsupported bits in a present pgprot. Non-present pgprots
319 * can use those bits for other purposes, so leave them be. 349 * can use those bits for other purposes, so leave them be.
diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h
index c98ac63aae48..f4843e031131 100644
--- a/arch/x86/include/asm/pgtable_types.h
+++ b/arch/x86/include/asm/pgtable_types.h
@@ -61,12 +61,27 @@
61 * they do not conflict with each other. 61 * they do not conflict with each other.
62 */ 62 */
63 63
64#define _PAGE_BIT_SOFT_DIRTY _PAGE_BIT_HIDDEN
65
64#ifdef CONFIG_MEM_SOFT_DIRTY 66#ifdef CONFIG_MEM_SOFT_DIRTY
65#define _PAGE_SOFT_DIRTY (_AT(pteval_t, 1) << _PAGE_BIT_HIDDEN) 67#define _PAGE_SOFT_DIRTY (_AT(pteval_t, 1) << _PAGE_BIT_SOFT_DIRTY)
66#else 68#else
67#define _PAGE_SOFT_DIRTY (_AT(pteval_t, 0)) 69#define _PAGE_SOFT_DIRTY (_AT(pteval_t, 0))
68#endif 70#endif
69 71
72/*
73 * Tracking soft dirty bit when a page goes to a swap is tricky.
74 * We need a bit which can be stored in pte _and_ not conflict
75 * with swap entry format. On x86 bits 6 and 7 are *not* involved
76 * into swap entry computation, but bit 6 is used for nonlinear
77 * file mapping, so we borrow bit 7 for soft dirty tracking.
78 */
79#ifdef CONFIG_MEM_SOFT_DIRTY
80#define _PAGE_SWP_SOFT_DIRTY _PAGE_PSE
81#else
82#define _PAGE_SWP_SOFT_DIRTY (_AT(pteval_t, 0))
83#endif
84
70#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE) 85#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
71#define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX) 86#define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX)
72#else 87#else
diff --git a/arch/x86/include/asm/spinlock.h b/arch/x86/include/asm/spinlock.h
index 33692eaabab5..e3ddd7db723f 100644
--- a/arch/x86/include/asm/spinlock.h
+++ b/arch/x86/include/asm/spinlock.h
@@ -233,8 +233,4 @@ static inline void arch_write_unlock(arch_rwlock_t *rw)
233#define arch_read_relax(lock) cpu_relax() 233#define arch_read_relax(lock) cpu_relax()
234#define arch_write_relax(lock) cpu_relax() 234#define arch_write_relax(lock) cpu_relax()
235 235
236/* The {read|write|spin}_lock() on x86 are full memory barriers. */
237static inline void smp_mb__after_lock(void) { }
238#define ARCH_HAS_SMP_MB_AFTER_LOCK
239
240#endif /* _ASM_X86_SPINLOCK_H */ 236#endif /* _ASM_X86_SPINLOCK_H */
diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index f654ecefea5b..08a089043ccf 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -512,7 +512,7 @@ static void early_init_amd(struct cpuinfo_x86 *c)
512 512
513static const int amd_erratum_383[]; 513static const int amd_erratum_383[];
514static const int amd_erratum_400[]; 514static const int amd_erratum_400[];
515static bool cpu_has_amd_erratum(const int *erratum); 515static bool cpu_has_amd_erratum(struct cpuinfo_x86 *cpu, const int *erratum);
516 516
517static void init_amd(struct cpuinfo_x86 *c) 517static void init_amd(struct cpuinfo_x86 *c)
518{ 518{
@@ -729,11 +729,11 @@ static void init_amd(struct cpuinfo_x86 *c)
729 value &= ~(1ULL << 24); 729 value &= ~(1ULL << 24);
730 wrmsrl_safe(MSR_AMD64_BU_CFG2, value); 730 wrmsrl_safe(MSR_AMD64_BU_CFG2, value);
731 731
732 if (cpu_has_amd_erratum(amd_erratum_383)) 732 if (cpu_has_amd_erratum(c, amd_erratum_383))
733 set_cpu_bug(c, X86_BUG_AMD_TLB_MMATCH); 733 set_cpu_bug(c, X86_BUG_AMD_TLB_MMATCH);
734 } 734 }
735 735
736 if (cpu_has_amd_erratum(amd_erratum_400)) 736 if (cpu_has_amd_erratum(c, amd_erratum_400))
737 set_cpu_bug(c, X86_BUG_AMD_APIC_C1E); 737 set_cpu_bug(c, X86_BUG_AMD_APIC_C1E);
738 738
739 rdmsr_safe(MSR_AMD64_PATCH_LEVEL, &c->microcode, &dummy); 739 rdmsr_safe(MSR_AMD64_PATCH_LEVEL, &c->microcode, &dummy);
@@ -878,23 +878,13 @@ static const int amd_erratum_400[] =
878static const int amd_erratum_383[] = 878static const int amd_erratum_383[] =
879 AMD_OSVW_ERRATUM(3, AMD_MODEL_RANGE(0x10, 0, 0, 0xff, 0xf)); 879 AMD_OSVW_ERRATUM(3, AMD_MODEL_RANGE(0x10, 0, 0, 0xff, 0xf));
880 880
881static bool cpu_has_amd_erratum(const int *erratum) 881
882static bool cpu_has_amd_erratum(struct cpuinfo_x86 *cpu, const int *erratum)
882{ 883{
883 struct cpuinfo_x86 *cpu = __this_cpu_ptr(&cpu_info);
884 int osvw_id = *erratum++; 884 int osvw_id = *erratum++;
885 u32 range; 885 u32 range;
886 u32 ms; 886 u32 ms;
887 887
888 /*
889 * If called early enough that current_cpu_data hasn't been initialized
890 * yet, fall back to boot_cpu_data.
891 */
892 if (cpu->x86 == 0)
893 cpu = &boot_cpu_data;
894
895 if (cpu->x86_vendor != X86_VENDOR_AMD)
896 return false;
897
898 if (osvw_id >= 0 && osvw_id < 65536 && 888 if (osvw_id >= 0 && osvw_id < 65536 &&
899 cpu_has(cpu, X86_FEATURE_OSVW)) { 889 cpu_has(cpu, X86_FEATURE_OSVW)) {
900 u64 osvw_len; 890 u64 osvw_len;
diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
index fbc9210b45bc..a45d8d4ace10 100644
--- a/arch/x86/kernel/cpu/perf_event_intel.c
+++ b/arch/x86/kernel/cpu/perf_event_intel.c
@@ -2270,6 +2270,7 @@ __init int intel_pmu_init(void)
2270 case 70: 2270 case 70:
2271 case 71: 2271 case 71:
2272 case 63: 2272 case 63:
2273 case 69:
2273 x86_pmu.late_ack = true; 2274 x86_pmu.late_ack = true;
2274 memcpy(hw_cache_event_ids, snb_hw_cache_event_ids, sizeof(hw_cache_event_ids)); 2275 memcpy(hw_cache_event_ids, snb_hw_cache_event_ids, sizeof(hw_cache_event_ids));
2275 memcpy(hw_cache_extra_regs, snb_hw_cache_extra_regs, sizeof(hw_cache_extra_regs)); 2276 memcpy(hw_cache_extra_regs, snb_hw_cache_extra_regs, sizeof(hw_cache_extra_regs));
diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
index cad791dbde95..1fb6c72717bd 100644
--- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
+++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
@@ -314,8 +314,8 @@ static struct uncore_event_desc snbep_uncore_imc_events[] = {
314static struct uncore_event_desc snbep_uncore_qpi_events[] = { 314static struct uncore_event_desc snbep_uncore_qpi_events[] = {
315 INTEL_UNCORE_EVENT_DESC(clockticks, "event=0x14"), 315 INTEL_UNCORE_EVENT_DESC(clockticks, "event=0x14"),
316 INTEL_UNCORE_EVENT_DESC(txl_flits_active, "event=0x00,umask=0x06"), 316 INTEL_UNCORE_EVENT_DESC(txl_flits_active, "event=0x00,umask=0x06"),
317 INTEL_UNCORE_EVENT_DESC(drs_data, "event=0x02,umask=0x08"), 317 INTEL_UNCORE_EVENT_DESC(drs_data, "event=0x102,umask=0x08"),
318 INTEL_UNCORE_EVENT_DESC(ncb_data, "event=0x03,umask=0x04"), 318 INTEL_UNCORE_EVENT_DESC(ncb_data, "event=0x103,umask=0x04"),
319 { /* end: all zeroes */ }, 319 { /* end: all zeroes */ },
320}; 320};
321 321
diff --git a/arch/x86/kernel/early-quirks.c b/arch/x86/kernel/early-quirks.c
index 94ab6b90dd3f..63bdb29b2549 100644
--- a/arch/x86/kernel/early-quirks.c
+++ b/arch/x86/kernel/early-quirks.c
@@ -196,15 +196,23 @@ static void __init ati_bugs_contd(int num, int slot, int func)
196static void __init intel_remapping_check(int num, int slot, int func) 196static void __init intel_remapping_check(int num, int slot, int func)
197{ 197{
198 u8 revision; 198 u8 revision;
199 u16 device;
199 200
201 device = read_pci_config_16(num, slot, func, PCI_DEVICE_ID);
200 revision = read_pci_config_byte(num, slot, func, PCI_REVISION_ID); 202 revision = read_pci_config_byte(num, slot, func, PCI_REVISION_ID);
201 203
202 /* 204 /*
203 * Revision 0x13 of this chipset supports irq remapping 205 * Revision 13 of all triggering devices id in this quirk have
204 * but has an erratum that breaks its behavior, flag it as such 206 * a problem draining interrupts when irq remapping is enabled,
207 * and should be flagged as broken. Additionally revisions 0x12
208 * and 0x22 of device id 0x3405 has this problem.
205 */ 209 */
206 if (revision == 0x13) 210 if (revision == 0x13)
207 set_irq_remapping_broken(); 211 set_irq_remapping_broken();
212 else if ((device == 0x3405) &&
213 ((revision == 0x12) ||
214 (revision == 0x22)))
215 set_irq_remapping_broken();
208 216
209} 217}
210 218
@@ -239,6 +247,8 @@ static struct chipset early_qrk[] __initdata = {
239 PCI_CLASS_SERIAL_SMBUS, PCI_ANY_ID, 0, ati_bugs_contd }, 247 PCI_CLASS_SERIAL_SMBUS, PCI_ANY_ID, 0, ati_bugs_contd },
240 { PCI_VENDOR_ID_INTEL, 0x3403, PCI_CLASS_BRIDGE_HOST, 248 { PCI_VENDOR_ID_INTEL, 0x3403, PCI_CLASS_BRIDGE_HOST,
241 PCI_BASE_CLASS_BRIDGE, 0, intel_remapping_check }, 249 PCI_BASE_CLASS_BRIDGE, 0, intel_remapping_check },
250 { PCI_VENDOR_ID_INTEL, 0x3405, PCI_CLASS_BRIDGE_HOST,
251 PCI_BASE_CLASS_BRIDGE, 0, intel_remapping_check },
242 { PCI_VENDOR_ID_INTEL, 0x3406, PCI_CLASS_BRIDGE_HOST, 252 { PCI_VENDOR_ID_INTEL, 0x3406, PCI_CLASS_BRIDGE_HOST,
243 PCI_BASE_CLASS_BRIDGE, 0, intel_remapping_check }, 253 PCI_BASE_CLASS_BRIDGE, 0, intel_remapping_check },
244 {} 254 {}
diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
index 202d24f0f7e7..5d576ab34403 100644
--- a/arch/x86/kernel/i387.c
+++ b/arch/x86/kernel/i387.c
@@ -116,7 +116,7 @@ static void mxcsr_feature_mask_init(void)
116 116
117 if (cpu_has_fxsr) { 117 if (cpu_has_fxsr) {
118 memset(&fx_scratch, 0, sizeof(struct i387_fxsave_struct)); 118 memset(&fx_scratch, 0, sizeof(struct i387_fxsave_struct));
119 asm volatile("fxsave %0" : : "m" (fx_scratch)); 119 asm volatile("fxsave %0" : "+m" (fx_scratch));
120 mask = fx_scratch.mxcsr_mask; 120 mask = fx_scratch.mxcsr_mask;
121 if (mask == 0) 121 if (mask == 0)
122 mask = 0x0000ffbf; 122 mask = 0x0000ffbf;
diff --git a/arch/x86/kernel/microcode_amd.c b/arch/x86/kernel/microcode_amd.c
index 47ebb1dbfbcb..7123b5df479d 100644
--- a/arch/x86/kernel/microcode_amd.c
+++ b/arch/x86/kernel/microcode_amd.c
@@ -145,10 +145,9 @@ static int collect_cpu_info_amd(int cpu, struct cpu_signature *csig)
145 return 0; 145 return 0;
146} 146}
147 147
148static unsigned int verify_patch_size(int cpu, u32 patch_size, 148static unsigned int verify_patch_size(u8 family, u32 patch_size,
149 unsigned int size) 149 unsigned int size)
150{ 150{
151 struct cpuinfo_x86 *c = &cpu_data(cpu);
152 u32 max_size; 151 u32 max_size;
153 152
154#define F1XH_MPB_MAX_SIZE 2048 153#define F1XH_MPB_MAX_SIZE 2048
@@ -156,7 +155,7 @@ static unsigned int verify_patch_size(int cpu, u32 patch_size,
156#define F15H_MPB_MAX_SIZE 4096 155#define F15H_MPB_MAX_SIZE 4096
157#define F16H_MPB_MAX_SIZE 3458 156#define F16H_MPB_MAX_SIZE 3458
158 157
159 switch (c->x86) { 158 switch (family) {
160 case 0x14: 159 case 0x14:
161 max_size = F14H_MPB_MAX_SIZE; 160 max_size = F14H_MPB_MAX_SIZE;
162 break; 161 break;
@@ -220,12 +219,13 @@ int apply_microcode_amd(int cpu)
220 return 0; 219 return 0;
221 } 220 }
222 221
223 if (__apply_microcode_amd(mc_amd)) 222 if (__apply_microcode_amd(mc_amd)) {
224 pr_err("CPU%d: update failed for patch_level=0x%08x\n", 223 pr_err("CPU%d: update failed for patch_level=0x%08x\n",
225 cpu, mc_amd->hdr.patch_id); 224 cpu, mc_amd->hdr.patch_id);
226 else 225 return -1;
227 pr_info("CPU%d: new patch_level=0x%08x\n", cpu, 226 }
228 mc_amd->hdr.patch_id); 227 pr_info("CPU%d: new patch_level=0x%08x\n", cpu,
228 mc_amd->hdr.patch_id);
229 229
230 uci->cpu_sig.rev = mc_amd->hdr.patch_id; 230 uci->cpu_sig.rev = mc_amd->hdr.patch_id;
231 c->microcode = mc_amd->hdr.patch_id; 231 c->microcode = mc_amd->hdr.patch_id;
@@ -276,9 +276,8 @@ static void cleanup(void)
276 * driver cannot continue functioning normally. In such cases, we tear 276 * driver cannot continue functioning normally. In such cases, we tear
277 * down everything we've used up so far and exit. 277 * down everything we've used up so far and exit.
278 */ 278 */
279static int verify_and_add_patch(unsigned int cpu, u8 *fw, unsigned int leftover) 279static int verify_and_add_patch(u8 family, u8 *fw, unsigned int leftover)
280{ 280{
281 struct cpuinfo_x86 *c = &cpu_data(cpu);
282 struct microcode_header_amd *mc_hdr; 281 struct microcode_header_amd *mc_hdr;
283 struct ucode_patch *patch; 282 struct ucode_patch *patch;
284 unsigned int patch_size, crnt_size, ret; 283 unsigned int patch_size, crnt_size, ret;
@@ -298,7 +297,7 @@ static int verify_and_add_patch(unsigned int cpu, u8 *fw, unsigned int leftover)
298 297
299 /* check if patch is for the current family */ 298 /* check if patch is for the current family */
300 proc_fam = ((proc_fam >> 8) & 0xf) + ((proc_fam >> 20) & 0xff); 299 proc_fam = ((proc_fam >> 8) & 0xf) + ((proc_fam >> 20) & 0xff);
301 if (proc_fam != c->x86) 300 if (proc_fam != family)
302 return crnt_size; 301 return crnt_size;
303 302
304 if (mc_hdr->nb_dev_id || mc_hdr->sb_dev_id) { 303 if (mc_hdr->nb_dev_id || mc_hdr->sb_dev_id) {
@@ -307,7 +306,7 @@ static int verify_and_add_patch(unsigned int cpu, u8 *fw, unsigned int leftover)
307 return crnt_size; 306 return crnt_size;
308 } 307 }
309 308
310 ret = verify_patch_size(cpu, patch_size, leftover); 309 ret = verify_patch_size(family, patch_size, leftover);
311 if (!ret) { 310 if (!ret) {
312 pr_err("Patch-ID 0x%08x: size mismatch.\n", mc_hdr->patch_id); 311 pr_err("Patch-ID 0x%08x: size mismatch.\n", mc_hdr->patch_id);
313 return crnt_size; 312 return crnt_size;
@@ -338,7 +337,8 @@ static int verify_and_add_patch(unsigned int cpu, u8 *fw, unsigned int leftover)
338 return crnt_size; 337 return crnt_size;
339} 338}
340 339
341static enum ucode_state __load_microcode_amd(int cpu, const u8 *data, size_t size) 340static enum ucode_state __load_microcode_amd(u8 family, const u8 *data,
341 size_t size)
342{ 342{
343 enum ucode_state ret = UCODE_ERROR; 343 enum ucode_state ret = UCODE_ERROR;
344 unsigned int leftover; 344 unsigned int leftover;
@@ -361,7 +361,7 @@ static enum ucode_state __load_microcode_amd(int cpu, const u8 *data, size_t siz
361 } 361 }
362 362
363 while (leftover) { 363 while (leftover) {
364 crnt_size = verify_and_add_patch(cpu, fw, leftover); 364 crnt_size = verify_and_add_patch(family, fw, leftover);
365 if (crnt_size < 0) 365 if (crnt_size < 0)
366 return ret; 366 return ret;
367 367
@@ -372,22 +372,22 @@ static enum ucode_state __load_microcode_amd(int cpu, const u8 *data, size_t siz
372 return UCODE_OK; 372 return UCODE_OK;
373} 373}
374 374
375enum ucode_state load_microcode_amd(int cpu, const u8 *data, size_t size) 375enum ucode_state load_microcode_amd(u8 family, const u8 *data, size_t size)
376{ 376{
377 enum ucode_state ret; 377 enum ucode_state ret;
378 378
379 /* free old equiv table */ 379 /* free old equiv table */
380 free_equiv_cpu_table(); 380 free_equiv_cpu_table();
381 381
382 ret = __load_microcode_amd(cpu, data, size); 382 ret = __load_microcode_amd(family, data, size);
383 383
384 if (ret != UCODE_OK) 384 if (ret != UCODE_OK)
385 cleanup(); 385 cleanup();
386 386
387#if defined(CONFIG_MICROCODE_AMD_EARLY) && defined(CONFIG_X86_32) 387#if defined(CONFIG_MICROCODE_AMD_EARLY) && defined(CONFIG_X86_32)
388 /* save BSP's matching patch for early load */ 388 /* save BSP's matching patch for early load */
389 if (cpu_data(cpu).cpu_index == boot_cpu_data.cpu_index) { 389 if (cpu_data(smp_processor_id()).cpu_index == boot_cpu_data.cpu_index) {
390 struct ucode_patch *p = find_patch(cpu); 390 struct ucode_patch *p = find_patch(smp_processor_id());
391 if (p) { 391 if (p) {
392 memset(amd_bsp_mpb, 0, MPB_MAX_SIZE); 392 memset(amd_bsp_mpb, 0, MPB_MAX_SIZE);
393 memcpy(amd_bsp_mpb, p->data, min_t(u32, ksize(p->data), 393 memcpy(amd_bsp_mpb, p->data, min_t(u32, ksize(p->data),
@@ -440,7 +440,7 @@ static enum ucode_state request_microcode_amd(int cpu, struct device *device,
440 goto fw_release; 440 goto fw_release;
441 } 441 }
442 442
443 ret = load_microcode_amd(cpu, fw->data, fw->size); 443 ret = load_microcode_amd(c->x86, fw->data, fw->size);
444 444
445 fw_release: 445 fw_release:
446 release_firmware(fw); 446 release_firmware(fw);
diff --git a/arch/x86/kernel/microcode_amd_early.c b/arch/x86/kernel/microcode_amd_early.c
index 1d14ffee5749..6073104ccaa3 100644
--- a/arch/x86/kernel/microcode_amd_early.c
+++ b/arch/x86/kernel/microcode_amd_early.c
@@ -238,25 +238,17 @@ static void __init collect_cpu_sig_on_bsp(void *arg)
238 uci->cpu_sig.sig = cpuid_eax(0x00000001); 238 uci->cpu_sig.sig = cpuid_eax(0x00000001);
239} 239}
240#else 240#else
241static void collect_cpu_info_amd_early(struct cpuinfo_x86 *c, 241void load_ucode_amd_ap(void)
242 struct ucode_cpu_info *uci)
243{ 242{
243 unsigned int cpu = smp_processor_id();
244 struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
244 u32 rev, eax; 245 u32 rev, eax;
245 246
246 rdmsr(MSR_AMD64_PATCH_LEVEL, rev, eax); 247 rdmsr(MSR_AMD64_PATCH_LEVEL, rev, eax);
247 eax = cpuid_eax(0x00000001); 248 eax = cpuid_eax(0x00000001);
248 249
249 uci->cpu_sig.sig = eax;
250 uci->cpu_sig.rev = rev; 250 uci->cpu_sig.rev = rev;
251 c->microcode = rev; 251 uci->cpu_sig.sig = eax;
252 c->x86 = ((eax >> 8) & 0xf) + ((eax >> 20) & 0xff);
253}
254
255void load_ucode_amd_ap(void)
256{
257 unsigned int cpu = smp_processor_id();
258
259 collect_cpu_info_amd_early(&cpu_data(cpu), ucode_cpu_info + cpu);
260 252
261 if (cpu && !ucode_loaded) { 253 if (cpu && !ucode_loaded) {
262 void *ucode; 254 void *ucode;
@@ -265,8 +257,10 @@ void load_ucode_amd_ap(void)
265 return; 257 return;
266 258
267 ucode = (void *)(initrd_start + ucode_offset); 259 ucode = (void *)(initrd_start + ucode_offset);
268 if (load_microcode_amd(0, ucode, ucode_size) != UCODE_OK) 260 eax = ((eax >> 8) & 0xf) + ((eax >> 20) & 0xff);
261 if (load_microcode_amd(eax, ucode, ucode_size) != UCODE_OK)
269 return; 262 return;
263
270 ucode_loaded = true; 264 ucode_loaded = true;
271 } 265 }
272 266
@@ -278,6 +272,8 @@ int __init save_microcode_in_initrd_amd(void)
278{ 272{
279 enum ucode_state ret; 273 enum ucode_state ret;
280 void *ucode; 274 void *ucode;
275 u32 eax;
276
281#ifdef CONFIG_X86_32 277#ifdef CONFIG_X86_32
282 unsigned int bsp = boot_cpu_data.cpu_index; 278 unsigned int bsp = boot_cpu_data.cpu_index;
283 struct ucode_cpu_info *uci = ucode_cpu_info + bsp; 279 struct ucode_cpu_info *uci = ucode_cpu_info + bsp;
@@ -293,7 +289,10 @@ int __init save_microcode_in_initrd_amd(void)
293 return 0; 289 return 0;
294 290
295 ucode = (void *)(initrd_start + ucode_offset); 291 ucode = (void *)(initrd_start + ucode_offset);
296 ret = load_microcode_amd(0, ucode, ucode_size); 292 eax = cpuid_eax(0x00000001);
293 eax = ((eax >> 8) & 0xf) + ((eax >> 20) & 0xff);
294
295 ret = load_microcode_amd(eax, ucode, ucode_size);
297 if (ret != UCODE_OK) 296 if (ret != UCODE_OK)
298 return -EINVAL; 297 return -EINVAL;
299 298
diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
index dbded5aedb81..30277e27431a 100644
--- a/arch/x86/kernel/sys_x86_64.c
+++ b/arch/x86/kernel/sys_x86_64.c
@@ -101,7 +101,7 @@ static void find_start_end(unsigned long flags, unsigned long *begin,
101 *begin = new_begin; 101 *begin = new_begin;
102 } 102 }
103 } else { 103 } else {
104 *begin = TASK_UNMAPPED_BASE; 104 *begin = current->mm->mmap_legacy_base;
105 *end = TASK_SIZE; 105 *end = TASK_SIZE;
106 } 106 }
107} 107}
diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c
index addf7b58f4e8..91a4496db434 100644
--- a/arch/x86/kernel/tboot.c
+++ b/arch/x86/kernel/tboot.c
@@ -301,6 +301,15 @@ static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control)
301 return 0; 301 return 0;
302} 302}
303 303
304static int tboot_extended_sleep(u8 sleep_state, u32 val_a, u32 val_b)
305{
306 if (!tboot_enabled())
307 return 0;
308
309 pr_warning("tboot is not able to suspend on platforms with reduced hardware sleep (ACPIv5)");
310 return -ENODEV;
311}
312
304static atomic_t ap_wfs_count; 313static atomic_t ap_wfs_count;
305 314
306static int tboot_wait_for_aps(int num_aps) 315static int tboot_wait_for_aps(int num_aps)
@@ -422,6 +431,7 @@ static __init int tboot_late_init(void)
422#endif 431#endif
423 432
424 acpi_os_set_prepare_sleep(&tboot_sleep); 433 acpi_os_set_prepare_sleep(&tboot_sleep);
434 acpi_os_set_prepare_extended_sleep(&tboot_extended_sleep);
425 return 0; 435 return 0;
426} 436}
427 437
diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
index 62c29a5bfe26..25e7e1372bb2 100644
--- a/arch/x86/mm/mmap.c
+++ b/arch/x86/mm/mmap.c
@@ -112,11 +112,13 @@ static unsigned long mmap_legacy_base(void)
112 */ 112 */
113void arch_pick_mmap_layout(struct mm_struct *mm) 113void arch_pick_mmap_layout(struct mm_struct *mm)
114{ 114{
115 mm->mmap_legacy_base = mmap_legacy_base();
116 mm->mmap_base = mmap_base();
117
115 if (mmap_is_legacy()) { 118 if (mmap_is_legacy()) {
116 mm->mmap_base = mmap_legacy_base(); 119 mm->mmap_base = mm->mmap_legacy_base;
117 mm->get_unmapped_area = arch_get_unmapped_area; 120 mm->get_unmapped_area = arch_get_unmapped_area;
118 } else { 121 } else {
119 mm->mmap_base = mmap_base();
120 mm->get_unmapped_area = arch_get_unmapped_area_topdown; 122 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
121 } 123 }
122} 124}
diff --git a/arch/x86/mm/srat.c b/arch/x86/mm/srat.c
index cdd0da9dd530..266ca912f62e 100644
--- a/arch/x86/mm/srat.c
+++ b/arch/x86/mm/srat.c
@@ -146,6 +146,7 @@ int __init
146acpi_numa_memory_affinity_init(struct acpi_srat_mem_affinity *ma) 146acpi_numa_memory_affinity_init(struct acpi_srat_mem_affinity *ma)
147{ 147{
148 u64 start, end; 148 u64 start, end;
149 u32 hotpluggable;
149 int node, pxm; 150 int node, pxm;
150 151
151 if (srat_disabled()) 152 if (srat_disabled())
@@ -154,7 +155,8 @@ acpi_numa_memory_affinity_init(struct acpi_srat_mem_affinity *ma)
154 goto out_err_bad_srat; 155 goto out_err_bad_srat;
155 if ((ma->flags & ACPI_SRAT_MEM_ENABLED) == 0) 156 if ((ma->flags & ACPI_SRAT_MEM_ENABLED) == 0)
156 goto out_err; 157 goto out_err;
157 if ((ma->flags & ACPI_SRAT_MEM_HOT_PLUGGABLE) && !save_add_info()) 158 hotpluggable = ma->flags & ACPI_SRAT_MEM_HOT_PLUGGABLE;
159 if (hotpluggable && !save_add_info())
158 goto out_err; 160 goto out_err;
159 161
160 start = ma->base_address; 162 start = ma->base_address;
@@ -174,9 +176,10 @@ acpi_numa_memory_affinity_init(struct acpi_srat_mem_affinity *ma)
174 176
175 node_set(node, numa_nodes_parsed); 177 node_set(node, numa_nodes_parsed);
176 178
177 printk(KERN_INFO "SRAT: Node %u PXM %u [mem %#010Lx-%#010Lx]\n", 179 pr_info("SRAT: Node %u PXM %u [mem %#010Lx-%#010Lx]%s\n",
178 node, pxm, 180 node, pxm,
179 (unsigned long long) start, (unsigned long long) end - 1); 181 (unsigned long long) start, (unsigned long long) end - 1,
182 hotpluggable ? " hotplug" : "");
180 183
181 return 0; 184 return 0;
182out_err_bad_srat: 185out_err_bad_srat:
diff --git a/arch/x86/pci/i386.c b/arch/x86/pci/i386.c
index 94919e307f8e..db6b1ab43255 100644
--- a/arch/x86/pci/i386.c
+++ b/arch/x86/pci/i386.c
@@ -210,6 +210,8 @@ static void pcibios_allocate_bridge_resources(struct pci_dev *dev)
210 r = &dev->resource[idx]; 210 r = &dev->resource[idx];
211 if (!r->flags) 211 if (!r->flags)
212 continue; 212 continue;
213 if (r->parent) /* Already allocated */
214 continue;
213 if (!r->start || pci_claim_resource(dev, idx) < 0) { 215 if (!r->start || pci_claim_resource(dev, idx) < 0) {
214 /* 216 /*
215 * Something is wrong with the region. 217 * Something is wrong with the region.
@@ -318,6 +320,8 @@ static void pcibios_allocate_dev_rom_resource(struct pci_dev *dev)
318 r = &dev->resource[PCI_ROM_RESOURCE]; 320 r = &dev->resource[PCI_ROM_RESOURCE];
319 if (!r->flags || !r->start) 321 if (!r->flags || !r->start)
320 return; 322 return;
323 if (r->parent) /* Already allocated */
324 return;
321 325
322 if (pci_claim_resource(dev, PCI_ROM_RESOURCE) < 0) { 326 if (pci_claim_resource(dev, PCI_ROM_RESOURCE) < 0) {
323 r->end -= r->start; 327 r->end -= r->start;
diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c
index 056d11faef21..8f3eea6b80c5 100644
--- a/arch/x86/xen/setup.c
+++ b/arch/x86/xen/setup.c
@@ -313,6 +313,17 @@ static void xen_align_and_add_e820_region(u64 start, u64 size, int type)
313 e820_add_region(start, end - start, type); 313 e820_add_region(start, end - start, type);
314} 314}
315 315
316void xen_ignore_unusable(struct e820entry *list, size_t map_size)
317{
318 struct e820entry *entry;
319 unsigned int i;
320
321 for (i = 0, entry = list; i < map_size; i++, entry++) {
322 if (entry->type == E820_UNUSABLE)
323 entry->type = E820_RAM;
324 }
325}
326
316/** 327/**
317 * machine_specific_memory_setup - Hook for machine specific memory setup. 328 * machine_specific_memory_setup - Hook for machine specific memory setup.
318 **/ 329 **/
@@ -353,6 +364,17 @@ char * __init xen_memory_setup(void)
353 } 364 }
354 BUG_ON(rc); 365 BUG_ON(rc);
355 366
367 /*
368 * Xen won't allow a 1:1 mapping to be created to UNUSABLE
369 * regions, so if we're using the machine memory map leave the
370 * region as RAM as it is in the pseudo-physical map.
371 *
372 * UNUSABLE regions in domUs are not handled and will need
373 * a patch in the future.
374 */
375 if (xen_initial_domain())
376 xen_ignore_unusable(map, memmap.nr_entries);
377
356 /* Make sure the Xen-supplied memory map is well-ordered. */ 378 /* Make sure the Xen-supplied memory map is well-ordered. */
357 sanitize_e820_map(map, memmap.nr_entries, &memmap.nr_entries); 379 sanitize_e820_map(map, memmap.nr_entries, &memmap.nr_entries);
358 380
diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
index ca92754eb846..b81c88e51daa 100644
--- a/arch/x86/xen/smp.c
+++ b/arch/x86/xen/smp.c
@@ -694,8 +694,15 @@ static void __init xen_hvm_smp_prepare_cpus(unsigned int max_cpus)
694static int xen_hvm_cpu_up(unsigned int cpu, struct task_struct *tidle) 694static int xen_hvm_cpu_up(unsigned int cpu, struct task_struct *tidle)
695{ 695{
696 int rc; 696 int rc;
697 rc = native_cpu_up(cpu, tidle); 697 /*
698 WARN_ON (xen_smp_intr_init(cpu)); 698 * xen_smp_intr_init() needs to run before native_cpu_up()
699 * so that IPI vectors are set up on the booting CPU before
700 * it is marked online in native_cpu_up().
701 */
702 rc = xen_smp_intr_init(cpu);
703 WARN_ON(rc);
704 if (!rc)
705 rc = native_cpu_up(cpu, tidle);
699 return rc; 706 return rc;
700} 707}
701 708
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index 100bd724f648..3278a210c435 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -91,24 +91,6 @@ config ACPI_EC_DEBUGFS
91 Thus this option is a debug option that helps to write ACPI drivers 91 Thus this option is a debug option that helps to write ACPI drivers
92 and can be used to identify ACPI code or EC firmware bugs. 92 and can be used to identify ACPI code or EC firmware bugs.
93 93
94config ACPI_PROC_EVENT
95 bool "Deprecated /proc/acpi/event support"
96 depends on PROC_FS
97 default y
98 help
99 A user-space daemon, acpid, typically reads /proc/acpi/event
100 and handles all ACPI-generated events.
101
102 These events are now delivered to user-space either
103 via the input layer or as netlink events.
104
105 This build option enables the old code for legacy
106 user-space implementation. After some time, this will
107 be moved under CONFIG_ACPI_PROCFS, and then deleted.
108
109 Say Y here to retain the old behaviour. Say N if your
110 user-space is newer than kernel 2.6.23 (September 2007).
111
112config ACPI_AC 94config ACPI_AC
113 tristate "AC Adapter" 95 tristate "AC Adapter"
114 depends on X86 96 depends on X86
diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c
index 4f4e741d34b2..f37beaa32750 100644
--- a/drivers/acpi/ac.c
+++ b/drivers/acpi/ac.c
@@ -267,7 +267,6 @@ static void acpi_ac_notify(struct acpi_device *device, u32 event)
267 msleep(ac_sleep_before_get_state_ms); 267 msleep(ac_sleep_before_get_state_ms);
268 268
269 acpi_ac_get_state(ac); 269 acpi_ac_get_state(ac);
270 acpi_bus_generate_proc_event(device, event, (u32) ac->state);
271 acpi_bus_generate_netlink_event(device->pnp.device_class, 270 acpi_bus_generate_netlink_event(device->pnp.device_class,
272 dev_name(&device->dev), event, 271 dev_name(&device->dev), event,
273 (u32) ac->state); 272 (u32) ac->state);
diff --git a/drivers/acpi/acpi_pad.c b/drivers/acpi/acpi_pad.c
index 27bb6a91de5f..6230637054c6 100644
--- a/drivers/acpi/acpi_pad.c
+++ b/drivers/acpi/acpi_pad.c
@@ -452,7 +452,6 @@ static void acpi_pad_notify(acpi_handle handle, u32 event,
452 switch (event) { 452 switch (event) {
453 case ACPI_PROCESSOR_AGGREGATOR_NOTIFY: 453 case ACPI_PROCESSOR_AGGREGATOR_NOTIFY:
454 acpi_pad_handle_notify(handle); 454 acpi_pad_handle_notify(handle);
455 acpi_bus_generate_proc_event(device, event, 0);
456 acpi_bus_generate_netlink_event(device->pnp.device_class, 455 acpi_bus_generate_netlink_event(device->pnp.device_class,
457 dev_name(&device->dev), event, 0); 456 dev_name(&device->dev), event, 0);
458 break; 457 break;
diff --git a/drivers/acpi/acpi_platform.c b/drivers/acpi/acpi_platform.c
index fafec5ddf17f..1bde12708f9e 100644
--- a/drivers/acpi/acpi_platform.c
+++ b/drivers/acpi/acpi_platform.c
@@ -52,7 +52,7 @@ int acpi_create_platform_device(struct acpi_device *adev,
52 struct platform_device_info pdevinfo; 52 struct platform_device_info pdevinfo;
53 struct resource_list_entry *rentry; 53 struct resource_list_entry *rentry;
54 struct list_head resource_list; 54 struct list_head resource_list;
55 struct resource *resources; 55 struct resource *resources = NULL;
56 int count; 56 int count;
57 57
58 /* If the ACPI node already has a physical device attached, skip it. */ 58 /* If the ACPI node already has a physical device attached, skip it. */
@@ -61,20 +61,22 @@ int acpi_create_platform_device(struct acpi_device *adev,
61 61
62 INIT_LIST_HEAD(&resource_list); 62 INIT_LIST_HEAD(&resource_list);
63 count = acpi_dev_get_resources(adev, &resource_list, NULL, NULL); 63 count = acpi_dev_get_resources(adev, &resource_list, NULL, NULL);
64 if (count <= 0) 64 if (count < 0) {
65 return 0; 65 return 0;
66 } else if (count > 0) {
67 resources = kmalloc(count * sizeof(struct resource),
68 GFP_KERNEL);
69 if (!resources) {
70 dev_err(&adev->dev, "No memory for resources\n");
71 acpi_dev_free_resource_list(&resource_list);
72 return -ENOMEM;
73 }
74 count = 0;
75 list_for_each_entry(rentry, &resource_list, node)
76 resources[count++] = rentry->res;
66 77
67 resources = kmalloc(count * sizeof(struct resource), GFP_KERNEL);
68 if (!resources) {
69 dev_err(&adev->dev, "No memory for resources\n");
70 acpi_dev_free_resource_list(&resource_list); 78 acpi_dev_free_resource_list(&resource_list);
71 return -ENOMEM;
72 } 79 }
73 count = 0;
74 list_for_each_entry(rentry, &resource_list, node)
75 resources[count++] = rentry->res;
76
77 acpi_dev_free_resource_list(&resource_list);
78 80
79 memset(&pdevinfo, 0, sizeof(pdevinfo)); 81 memset(&pdevinfo, 0, sizeof(pdevinfo));
80 /* 82 /*
diff --git a/drivers/acpi/acpica/acglobal.h b/drivers/acpi/acpica/acglobal.h
index b8d38117a20c..90e846f985fa 100644
--- a/drivers/acpi/acpica/acglobal.h
+++ b/drivers/acpi/acpica/acglobal.h
@@ -138,6 +138,12 @@ u8 ACPI_INIT_GLOBAL(acpi_gbl_disable_auto_repair, FALSE);
138 */ 138 */
139u8 ACPI_INIT_GLOBAL(acpi_gbl_disable_ssdt_table_load, FALSE); 139u8 ACPI_INIT_GLOBAL(acpi_gbl_disable_ssdt_table_load, FALSE);
140 140
141/*
142 * We keep track of the latest version of Windows that has been requested by
143 * the BIOS.
144 */
145u8 ACPI_INIT_GLOBAL(acpi_gbl_osi_data, 0);
146
141/* acpi_gbl_FADT is a local copy of the FADT, converted to a common format. */ 147/* acpi_gbl_FADT is a local copy of the FADT, converted to a common format. */
142 148
143struct acpi_table_fadt acpi_gbl_FADT; 149struct acpi_table_fadt acpi_gbl_FADT;
@@ -285,7 +291,6 @@ ACPI_EXTERN u8 acpi_gbl_debugger_configuration;
285ACPI_EXTERN u8 acpi_gbl_step_to_next_call; 291ACPI_EXTERN u8 acpi_gbl_step_to_next_call;
286ACPI_EXTERN u8 acpi_gbl_acpi_hardware_present; 292ACPI_EXTERN u8 acpi_gbl_acpi_hardware_present;
287ACPI_EXTERN u8 acpi_gbl_events_initialized; 293ACPI_EXTERN u8 acpi_gbl_events_initialized;
288ACPI_EXTERN u8 acpi_gbl_osi_data;
289ACPI_EXTERN struct acpi_interface_info *acpi_gbl_supported_interfaces; 294ACPI_EXTERN struct acpi_interface_info *acpi_gbl_supported_interfaces;
290ACPI_EXTERN struct acpi_address_range 295ACPI_EXTERN struct acpi_address_range
291 *acpi_gbl_address_range_list[ACPI_ADDRESS_RANGE_MAX]; 296 *acpi_gbl_address_range_list[ACPI_ADDRESS_RANGE_MAX];
diff --git a/drivers/acpi/acpica/aclocal.h b/drivers/acpi/acpica/aclocal.h
index d4a4901637cd..0ed00669cd21 100644
--- a/drivers/acpi/acpica/aclocal.h
+++ b/drivers/acpi/acpica/aclocal.h
@@ -942,6 +942,9 @@ struct acpi_interface_info {
942 942
943#define ACPI_OSI_INVALID 0x01 943#define ACPI_OSI_INVALID 0x01
944#define ACPI_OSI_DYNAMIC 0x02 944#define ACPI_OSI_DYNAMIC 0x02
945#define ACPI_OSI_FEATURE 0x04
946#define ACPI_OSI_DEFAULT_INVALID 0x08
947#define ACPI_OSI_OPTIONAL_FEATURE (ACPI_OSI_FEATURE | ACPI_OSI_DEFAULT_INVALID | ACPI_OSI_INVALID)
945 948
946struct acpi_port_info { 949struct acpi_port_info {
947 char *name; 950 char *name;
@@ -1030,6 +1033,7 @@ struct acpi_external_list {
1030 u8 type; 1033 u8 type;
1031 u8 flags; 1034 u8 flags;
1032 u8 resolved; 1035 u8 resolved;
1036 u8 emitted;
1033}; 1037};
1034 1038
1035/* Values for Flags field above */ 1039/* Values for Flags field above */
diff --git a/drivers/acpi/acpica/acnamesp.h b/drivers/acpi/acpica/acnamesp.h
index b83dc32a5ae0..40b04bd5579e 100644
--- a/drivers/acpi/acpica/acnamesp.h
+++ b/drivers/acpi/acpica/acnamesp.h
@@ -104,8 +104,8 @@ acpi_ns_walk_namespace(acpi_object_type type,
104 acpi_handle start_object, 104 acpi_handle start_object,
105 u32 max_depth, 105 u32 max_depth,
106 u32 flags, 106 u32 flags,
107 acpi_walk_callback pre_order_visit, 107 acpi_walk_callback descending_callback,
108 acpi_walk_callback post_order_visit, 108 acpi_walk_callback ascending_callback,
109 void *context, void **return_value); 109 void *context, void **return_value);
110 110
111struct acpi_namespace_node *acpi_ns_get_next_node(struct acpi_namespace_node 111struct acpi_namespace_node *acpi_ns_get_next_node(struct acpi_namespace_node
diff --git a/drivers/acpi/acpica/actables.h b/drivers/acpi/acpica/actables.h
index 7755e915a007..c54f42c64fe2 100644
--- a/drivers/acpi/acpica/actables.h
+++ b/drivers/acpi/acpica/actables.h
@@ -47,6 +47,13 @@
47acpi_status acpi_allocate_root_table(u32 initial_table_count); 47acpi_status acpi_allocate_root_table(u32 initial_table_count);
48 48
49/* 49/*
50 * tbxfroot - Root pointer utilities
51 */
52acpi_status acpi_tb_validate_rsdp(struct acpi_table_rsdp *rsdp);
53
54u8 *acpi_tb_scan_memory_for_rsdp(u8 *start_address, u32 length);
55
56/*
50 * tbfadt - FADT parse/convert/validate 57 * tbfadt - FADT parse/convert/validate
51 */ 58 */
52void acpi_tb_parse_fadt(u32 table_index); 59void acpi_tb_parse_fadt(u32 table_index);
diff --git a/drivers/acpi/acpica/acutils.h b/drivers/acpi/acpica/acutils.h
index 3c76edea6803..d5a62a6182bb 100644
--- a/drivers/acpi/acpica/acutils.h
+++ b/drivers/acpi/acpica/acutils.h
@@ -470,6 +470,8 @@ acpi_status acpi_ut_install_interface(acpi_string interface_name);
470 470
471acpi_status acpi_ut_remove_interface(acpi_string interface_name); 471acpi_status acpi_ut_remove_interface(acpi_string interface_name);
472 472
473acpi_status acpi_ut_update_interfaces(u8 action);
474
473struct acpi_interface_info *acpi_ut_get_interface(acpi_string interface_name); 475struct acpi_interface_info *acpi_ut_get_interface(acpi_string interface_name);
474 476
475acpi_status acpi_ut_osi_implementation(struct acpi_walk_state *walk_state); 477acpi_status acpi_ut_osi_implementation(struct acpi_walk_state *walk_state);
@@ -616,7 +618,7 @@ int acpi_ut_stricmp(char *string1, char *string2);
616 618
617acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 *ret_integer); 619acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 *ret_integer);
618 620
619void acpi_ut_print_string(char *string, u8 max_length); 621void acpi_ut_print_string(char *string, u16 max_length);
620 622
621void ut_convert_backslashes(char *pathname); 623void ut_convert_backslashes(char *pathname);
622 624
diff --git a/drivers/acpi/acpica/evgpeinit.c b/drivers/acpi/acpica/evgpeinit.c
index 9037f17c9608..7842700346a4 100644
--- a/drivers/acpi/acpica/evgpeinit.c
+++ b/drivers/acpi/acpica/evgpeinit.c
@@ -125,7 +125,6 @@ acpi_status acpi_ev_gpe_initialize(void)
125 /* GPE block 0 exists (has both length and address > 0) */ 125 /* GPE block 0 exists (has both length and address > 0) */
126 126
127 register_count0 = (u16)(acpi_gbl_FADT.gpe0_block_length / 2); 127 register_count0 = (u16)(acpi_gbl_FADT.gpe0_block_length / 2);
128
129 gpe_number_max = 128 gpe_number_max =
130 (register_count0 * ACPI_GPE_REGISTER_WIDTH) - 1; 129 (register_count0 * ACPI_GPE_REGISTER_WIDTH) - 1;
131 130
@@ -204,16 +203,6 @@ acpi_status acpi_ev_gpe_initialize(void)
204 goto cleanup; 203 goto cleanup;
205 } 204 }
206 205
207 /* Check for Max GPE number out-of-range */
208
209 if (gpe_number_max > ACPI_GPE_MAX) {
210 ACPI_ERROR((AE_INFO,
211 "Maximum GPE number from FADT is too large: 0x%X",
212 gpe_number_max));
213 status = AE_BAD_VALUE;
214 goto cleanup;
215 }
216
217 cleanup: 206 cleanup:
218 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); 207 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
219 return_ACPI_STATUS(AE_OK); 208 return_ACPI_STATUS(AE_OK);
diff --git a/drivers/acpi/acpica/exdump.c b/drivers/acpi/acpica/exdump.c
index c740f24e3101..4d046faac48c 100644
--- a/drivers/acpi/acpica/exdump.c
+++ b/drivers/acpi/acpica/exdump.c
@@ -338,6 +338,7 @@ acpi_ex_dump_object(union acpi_operand_object *obj_desc,
338{ 338{
339 u8 *target; 339 u8 *target;
340 char *name; 340 char *name;
341 const char *reference_name;
341 u8 count; 342 u8 count;
342 343
343 if (!info) { 344 if (!info) {
@@ -426,10 +427,9 @@ acpi_ex_dump_object(union acpi_operand_object *obj_desc,
426 427
427 case ACPI_EXD_REFERENCE: 428 case ACPI_EXD_REFERENCE:
428 429
430 reference_name = acpi_ut_get_reference_name(obj_desc);
429 acpi_ex_out_string("Class Name", 431 acpi_ex_out_string("Class Name",
430 ACPI_CAST_PTR(char, 432 ACPI_CAST_PTR(char, reference_name));
431 acpi_ut_get_reference_name
432 (obj_desc)));
433 acpi_ex_dump_reference_obj(obj_desc); 433 acpi_ex_dump_reference_obj(obj_desc);
434 break; 434 break;
435 435
diff --git a/drivers/acpi/acpica/exoparg1.c b/drivers/acpi/acpica/exoparg1.c
index 814b4a3d656a..2cdd41d8ade6 100644
--- a/drivers/acpi/acpica/exoparg1.c
+++ b/drivers/acpi/acpica/exoparg1.c
@@ -962,10 +962,17 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
962 */ 962 */
963 return_desc = 963 return_desc =
964 *(operand[0]->reference.where); 964 *(operand[0]->reference.where);
965 if (return_desc) { 965 if (!return_desc) {
966 acpi_ut_add_reference 966 /*
967 (return_desc); 967 * Element is NULL, do not allow the dereference.
968 * This provides compatibility with other ACPI
969 * implementations.
970 */
971 return_ACPI_STATUS
972 (AE_AML_UNINITIALIZED_ELEMENT);
968 } 973 }
974
975 acpi_ut_add_reference(return_desc);
969 break; 976 break;
970 977
971 default: 978 default:
@@ -990,11 +997,40 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
990 acpi_namespace_node 997 acpi_namespace_node
991 *) 998 *)
992 return_desc); 999 return_desc);
993 } 1000 if (!return_desc) {
1001 break;
1002 }
994 1003
995 /* Add another reference to the object! */ 1004 /*
1005 * June 2013:
1006 * buffer_fields/field_units require additional resolution
1007 */
1008 switch (return_desc->common.type) {
1009 case ACPI_TYPE_BUFFER_FIELD:
1010 case ACPI_TYPE_LOCAL_REGION_FIELD:
1011 case ACPI_TYPE_LOCAL_BANK_FIELD:
1012 case ACPI_TYPE_LOCAL_INDEX_FIELD:
996 1013
997 acpi_ut_add_reference(return_desc); 1014 status =
1015 acpi_ex_read_data_from_field
1016 (walk_state, return_desc,
1017 &temp_desc);
1018 if (ACPI_FAILURE(status)) {
1019 goto cleanup;
1020 }
1021
1022 return_desc = temp_desc;
1023 break;
1024
1025 default:
1026
1027 /* Add another reference to the object */
1028
1029 acpi_ut_add_reference
1030 (return_desc);
1031 break;
1032 }
1033 }
998 break; 1034 break;
999 1035
1000 default: 1036 default:
diff --git a/drivers/acpi/acpica/hwesleep.c b/drivers/acpi/acpica/hwesleep.c
index 5e5f76230f5e..414076818d40 100644
--- a/drivers/acpi/acpica/hwesleep.c
+++ b/drivers/acpi/acpica/hwesleep.c
@@ -43,6 +43,7 @@
43 */ 43 */
44 44
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include <linux/acpi.h>
46#include "accommon.h" 47#include "accommon.h"
47 48
48#define _COMPONENT ACPI_HARDWARE 49#define _COMPONENT ACPI_HARDWARE
@@ -128,6 +129,14 @@ acpi_status acpi_hw_extended_sleep(u8 sleep_state)
128 129
129 ACPI_FLUSH_CPU_CACHE(); 130 ACPI_FLUSH_CPU_CACHE();
130 131
132 status = acpi_os_prepare_extended_sleep(sleep_state,
133 acpi_gbl_sleep_type_a,
134 acpi_gbl_sleep_type_b);
135 if (ACPI_SKIP(status))
136 return_ACPI_STATUS(AE_OK);
137 if (ACPI_FAILURE(status))
138 return_ACPI_STATUS(status);
139
131 /* 140 /*
132 * Set the SLP_TYP and SLP_EN bits. 141 * Set the SLP_TYP and SLP_EN bits.
133 * 142 *
diff --git a/drivers/acpi/acpica/hwtimer.c b/drivers/acpi/acpica/hwtimer.c
index 0c1a8bbd05d6..2d7d22ebc782 100644
--- a/drivers/acpi/acpica/hwtimer.c
+++ b/drivers/acpi/acpica/hwtimer.c
@@ -100,8 +100,13 @@ acpi_status acpi_get_timer(u32 * ticks)
100 return_ACPI_STATUS(AE_BAD_PARAMETER); 100 return_ACPI_STATUS(AE_BAD_PARAMETER);
101 } 101 }
102 102
103 status = acpi_hw_read(ticks, &acpi_gbl_FADT.xpm_timer_block); 103 /* ACPI 5.0A: PM Timer is optional */
104
105 if (!acpi_gbl_FADT.xpm_timer_block.address) {
106 return_ACPI_STATUS(AE_SUPPORT);
107 }
104 108
109 status = acpi_hw_read(ticks, &acpi_gbl_FADT.xpm_timer_block);
105 return_ACPI_STATUS(status); 110 return_ACPI_STATUS(status);
106} 111}
107 112
@@ -148,6 +153,12 @@ acpi_get_timer_duration(u32 start_ticks, u32 end_ticks, u32 * time_elapsed)
148 return_ACPI_STATUS(AE_BAD_PARAMETER); 153 return_ACPI_STATUS(AE_BAD_PARAMETER);
149 } 154 }
150 155
156 /* ACPI 5.0A: PM Timer is optional */
157
158 if (!acpi_gbl_FADT.xpm_timer_block.address) {
159 return_ACPI_STATUS(AE_SUPPORT);
160 }
161
151 /* 162 /*
152 * Compute Tick Delta: 163 * Compute Tick Delta:
153 * Handle (max one) timer rollovers on 24-bit versus 32-bit timers. 164 * Handle (max one) timer rollovers on 24-bit versus 32-bit timers.
diff --git a/drivers/acpi/acpica/nspredef.c b/drivers/acpi/acpica/nspredef.c
index 24b71a01bf93..098e7666cbc9 100644
--- a/drivers/acpi/acpica/nspredef.c
+++ b/drivers/acpi/acpica/nspredef.c
@@ -151,6 +151,15 @@ acpi_ns_check_return_value(struct acpi_namespace_node *node,
151 } 151 }
152 152
153 /* 153 /*
154 *
155 * 4) If there is no return value and it is optional, just return
156 * AE_OK (_WAK).
157 */
158 if (!(*return_object_ptr)) {
159 goto exit;
160 }
161
162 /*
154 * For returned Package objects, check the type of all sub-objects. 163 * For returned Package objects, check the type of all sub-objects.
155 * Note: Package may have been newly created by call above. 164 * Note: Package may have been newly created by call above.
156 */ 165 */
@@ -268,7 +277,12 @@ acpi_ns_check_object_type(struct acpi_evaluate_info *info,
268 277
269 acpi_ut_get_expected_return_types(type_buffer, expected_btypes); 278 acpi_ut_get_expected_return_types(type_buffer, expected_btypes);
270 279
271 if (package_index == ACPI_NOT_PACKAGE_ELEMENT) { 280 if (!return_object) {
281 ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname,
282 info->node_flags,
283 "Expected return object of type %s",
284 type_buffer));
285 } else if (package_index == ACPI_NOT_PACKAGE_ELEMENT) {
272 ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname, 286 ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname,
273 info->node_flags, 287 info->node_flags,
274 "Return type mismatch - found %s, expected %s", 288 "Return type mismatch - found %s, expected %s",
diff --git a/drivers/acpi/acpica/nswalk.c b/drivers/acpi/acpica/nswalk.c
index e70911a9e441..e81f15ef659a 100644
--- a/drivers/acpi/acpica/nswalk.c
+++ b/drivers/acpi/acpica/nswalk.c
@@ -156,9 +156,9 @@ struct acpi_namespace_node *acpi_ns_get_next_node_typed(acpi_object_type type,
156 * max_depth - Depth to which search is to reach 156 * max_depth - Depth to which search is to reach
157 * flags - Whether to unlock the NS before invoking 157 * flags - Whether to unlock the NS before invoking
158 * the callback routine 158 * the callback routine
159 * pre_order_visit - Called during tree pre-order visit 159 * descending_callback - Called during tree descent
160 * when an object of "Type" is found 160 * when an object of "Type" is found
161 * post_order_visit - Called during tree post-order visit 161 * ascending_callback - Called during tree ascent
162 * when an object of "Type" is found 162 * when an object of "Type" is found
163 * context - Passed to user function(s) above 163 * context - Passed to user function(s) above
164 * return_value - from the user_function if terminated 164 * return_value - from the user_function if terminated
@@ -185,8 +185,8 @@ acpi_ns_walk_namespace(acpi_object_type type,
185 acpi_handle start_node, 185 acpi_handle start_node,
186 u32 max_depth, 186 u32 max_depth,
187 u32 flags, 187 u32 flags,
188 acpi_walk_callback pre_order_visit, 188 acpi_walk_callback descending_callback,
189 acpi_walk_callback post_order_visit, 189 acpi_walk_callback ascending_callback,
190 void *context, void **return_value) 190 void *context, void **return_value)
191{ 191{
192 acpi_status status; 192 acpi_status status;
@@ -255,22 +255,22 @@ acpi_ns_walk_namespace(acpi_object_type type,
255 } 255 }
256 256
257 /* 257 /*
258 * Invoke the user function, either pre-order or post-order 258 * Invoke the user function, either descending, ascending,
259 * or both. 259 * or both.
260 */ 260 */
261 if (!node_previously_visited) { 261 if (!node_previously_visited) {
262 if (pre_order_visit) { 262 if (descending_callback) {
263 status = 263 status =
264 pre_order_visit(child_node, level, 264 descending_callback(child_node,
265 context, 265 level, context,
266 return_value); 266 return_value);
267 } 267 }
268 } else { 268 } else {
269 if (post_order_visit) { 269 if (ascending_callback) {
270 status = 270 status =
271 post_order_visit(child_node, level, 271 ascending_callback(child_node,
272 context, 272 level, context,
273 return_value); 273 return_value);
274 } 274 }
275 } 275 }
276 276
diff --git a/drivers/acpi/acpica/nsxfeval.c b/drivers/acpi/acpica/nsxfeval.c
index f553cfdb71dd..b38b4b07f86e 100644
--- a/drivers/acpi/acpica/nsxfeval.c
+++ b/drivers/acpi/acpica/nsxfeval.c
@@ -533,9 +533,9 @@ static void acpi_ns_resolve_references(struct acpi_evaluate_info *info)
533 * PARAMETERS: type - acpi_object_type to search for 533 * PARAMETERS: type - acpi_object_type to search for
534 * start_object - Handle in namespace where search begins 534 * start_object - Handle in namespace where search begins
535 * max_depth - Depth to which search is to reach 535 * max_depth - Depth to which search is to reach
536 * pre_order_visit - Called during tree pre-order visit 536 * descending_callback - Called during tree descent
537 * when an object of "Type" is found 537 * when an object of "Type" is found
538 * post_order_visit - Called during tree post-order visit 538 * ascending_callback - Called during tree ascent
539 * when an object of "Type" is found 539 * when an object of "Type" is found
540 * context - Passed to user function(s) above 540 * context - Passed to user function(s) above
541 * return_value - Location where return value of 541 * return_value - Location where return value of
@@ -563,8 +563,8 @@ acpi_status
563acpi_walk_namespace(acpi_object_type type, 563acpi_walk_namespace(acpi_object_type type,
564 acpi_handle start_object, 564 acpi_handle start_object,
565 u32 max_depth, 565 u32 max_depth,
566 acpi_walk_callback pre_order_visit, 566 acpi_walk_callback descending_callback,
567 acpi_walk_callback post_order_visit, 567 acpi_walk_callback ascending_callback,
568 void *context, void **return_value) 568 void *context, void **return_value)
569{ 569{
570 acpi_status status; 570 acpi_status status;
@@ -574,7 +574,7 @@ acpi_walk_namespace(acpi_object_type type,
574 /* Parameter validation */ 574 /* Parameter validation */
575 575
576 if ((type > ACPI_TYPE_LOCAL_MAX) || 576 if ((type > ACPI_TYPE_LOCAL_MAX) ||
577 (!max_depth) || (!pre_order_visit && !post_order_visit)) { 577 (!max_depth) || (!descending_callback && !ascending_callback)) {
578 return_ACPI_STATUS(AE_BAD_PARAMETER); 578 return_ACPI_STATUS(AE_BAD_PARAMETER);
579 } 579 }
580 580
@@ -606,9 +606,9 @@ acpi_walk_namespace(acpi_object_type type,
606 } 606 }
607 607
608 status = acpi_ns_walk_namespace(type, start_object, max_depth, 608 status = acpi_ns_walk_namespace(type, start_object, max_depth,
609 ACPI_NS_WALK_UNLOCK, pre_order_visit, 609 ACPI_NS_WALK_UNLOCK,
610 post_order_visit, context, 610 descending_callback, ascending_callback,
611 return_value); 611 context, return_value);
612 612
613 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); 613 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
614 614
diff --git a/drivers/acpi/acpica/nsxfname.c b/drivers/acpi/acpica/nsxfname.c
index f3a4d95899f7..83c164434580 100644
--- a/drivers/acpi/acpica/nsxfname.c
+++ b/drivers/acpi/acpica/nsxfname.c
@@ -158,6 +158,7 @@ acpi_get_name(acpi_handle handle, u32 name_type, struct acpi_buffer * buffer)
158{ 158{
159 acpi_status status; 159 acpi_status status;
160 struct acpi_namespace_node *node; 160 struct acpi_namespace_node *node;
161 char *node_name;
161 162
162 /* Parameter validation */ 163 /* Parameter validation */
163 164
@@ -202,7 +203,8 @@ acpi_get_name(acpi_handle handle, u32 name_type, struct acpi_buffer * buffer)
202 203
203 /* Just copy the ACPI name from the Node and zero terminate it */ 204 /* Just copy the ACPI name from the Node and zero terminate it */
204 205
205 ACPI_MOVE_NAME(buffer->pointer, acpi_ut_get_node_name(node)); 206 node_name = acpi_ut_get_node_name(node);
207 ACPI_MOVE_NAME(buffer->pointer, node_name);
206 ((char *)buffer->pointer)[ACPI_NAME_SIZE] = 0; 208 ((char *)buffer->pointer)[ACPI_NAME_SIZE] = 0;
207 status = AE_OK; 209 status = AE_OK;
208 210
@@ -379,9 +381,14 @@ acpi_get_object_info(acpi_handle handle,
379 * Get extra info for ACPI Device/Processor objects only: 381 * Get extra info for ACPI Device/Processor objects only:
380 * Run the _STA, _ADR and, sx_w, and _sx_d methods. 382 * Run the _STA, _ADR and, sx_w, and _sx_d methods.
381 * 383 *
382 * Note: none of these methods are required, so they may or may 384 * Notes: none of these methods are required, so they may or may
383 * not be present for this device. The Info->Valid bitfield is used 385 * not be present for this device. The Info->Valid bitfield is used
384 * to indicate which methods were found and run successfully. 386 * to indicate which methods were found and run successfully.
387 *
388 * For _STA, if the method does not exist, then (as per the ACPI
389 * specification), the returned current_status flags will indicate
390 * that the device is present/functional/enabled. Otherwise, the
391 * current_status flags reflect the value returned from _STA.
385 */ 392 */
386 393
387 /* Execute the Device._STA method */ 394 /* Execute the Device._STA method */
diff --git a/drivers/acpi/acpica/tbfadt.c b/drivers/acpi/acpica/tbfadt.c
index 33b00d22300a..9d99f2189693 100644
--- a/drivers/acpi/acpica/tbfadt.c
+++ b/drivers/acpi/acpica/tbfadt.c
@@ -117,7 +117,7 @@ static struct acpi_fadt_info fadt_info_table[] = {
117 ACPI_FADT_OFFSET(pm_timer_block), 117 ACPI_FADT_OFFSET(pm_timer_block),
118 ACPI_FADT_OFFSET(pm_timer_length), 118 ACPI_FADT_OFFSET(pm_timer_length),
119 ACPI_PM_TIMER_WIDTH, 119 ACPI_PM_TIMER_WIDTH,
120 ACPI_FADT_REQUIRED}, 120 ACPI_FADT_SEPARATE_LENGTH}, /* ACPI 5.0A: Timer is optional */
121 121
122 {"Gpe0Block", 122 {"Gpe0Block",
123 ACPI_FADT_OFFSET(xgpe0_block), 123 ACPI_FADT_OFFSET(xgpe0_block),
@@ -574,7 +574,7 @@ static void acpi_tb_validate_fadt(void)
574 574
575 if (fadt_info_table[i].type & ACPI_FADT_REQUIRED) { 575 if (fadt_info_table[i].type & ACPI_FADT_REQUIRED) {
576 /* 576 /*
577 * Field is required (Pm1a_event, Pm1a_control, pm_timer). 577 * Field is required (Pm1a_event, Pm1a_control).
578 * Both the address and length must be non-zero. 578 * Both the address and length must be non-zero.
579 */ 579 */
580 if (!address64->address || !length) { 580 if (!address64->address || !length) {
diff --git a/drivers/acpi/acpica/tbxfroot.c b/drivers/acpi/acpica/tbxfroot.c
index 7c2ecfb7c2c3..948c95e80d44 100644
--- a/drivers/acpi/acpica/tbxfroot.c
+++ b/drivers/acpi/acpica/tbxfroot.c
@@ -48,11 +48,6 @@
48#define _COMPONENT ACPI_TABLES 48#define _COMPONENT ACPI_TABLES
49ACPI_MODULE_NAME("tbxfroot") 49ACPI_MODULE_NAME("tbxfroot")
50 50
51/* Local prototypes */
52static u8 *acpi_tb_scan_memory_for_rsdp(u8 * start_address, u32 length);
53
54static acpi_status acpi_tb_validate_rsdp(struct acpi_table_rsdp *rsdp);
55
56/******************************************************************************* 51/*******************************************************************************
57 * 52 *
58 * FUNCTION: acpi_tb_validate_rsdp 53 * FUNCTION: acpi_tb_validate_rsdp
@@ -64,8 +59,7 @@ static acpi_status acpi_tb_validate_rsdp(struct acpi_table_rsdp *rsdp);
64 * DESCRIPTION: Validate the RSDP (ptr) 59 * DESCRIPTION: Validate the RSDP (ptr)
65 * 60 *
66 ******************************************************************************/ 61 ******************************************************************************/
67 62acpi_status acpi_tb_validate_rsdp(struct acpi_table_rsdp *rsdp)
68static acpi_status acpi_tb_validate_rsdp(struct acpi_table_rsdp *rsdp)
69{ 63{
70 64
71 /* 65 /*
@@ -74,7 +68,7 @@ static acpi_status acpi_tb_validate_rsdp(struct acpi_table_rsdp *rsdp)
74 * Note: Sometimes there exists more than one RSDP in memory; the valid 68 * Note: Sometimes there exists more than one RSDP in memory; the valid
75 * RSDP has a valid checksum, all others have an invalid checksum. 69 * RSDP has a valid checksum, all others have an invalid checksum.
76 */ 70 */
77 if (ACPI_STRNCMP((char *)rsdp, ACPI_SIG_RSDP, 71 if (ACPI_STRNCMP((char *)rsdp->signature, ACPI_SIG_RSDP,
78 sizeof(ACPI_SIG_RSDP) - 1) != 0) { 72 sizeof(ACPI_SIG_RSDP) - 1) != 0) {
79 73
80 /* Nope, BAD Signature */ 74 /* Nope, BAD Signature */
@@ -231,7 +225,7 @@ acpi_status acpi_find_root_pointer(acpi_size *table_address)
231 * DESCRIPTION: Search a block of memory for the RSDP signature 225 * DESCRIPTION: Search a block of memory for the RSDP signature
232 * 226 *
233 ******************************************************************************/ 227 ******************************************************************************/
234static u8 *acpi_tb_scan_memory_for_rsdp(u8 * start_address, u32 length) 228u8 *acpi_tb_scan_memory_for_rsdp(u8 *start_address, u32 length)
235{ 229{
236 acpi_status status; 230 acpi_status status;
237 u8 *mem_rover; 231 u8 *mem_rover;
diff --git a/drivers/acpi/acpica/uteval.c b/drivers/acpi/acpica/uteval.c
index ee83adb97b1e..4fd68971019b 100644
--- a/drivers/acpi/acpica/uteval.c
+++ b/drivers/acpi/acpica/uteval.c
@@ -239,7 +239,8 @@ acpi_ut_evaluate_numeric_object(char *object_name,
239 * RETURN: Status 239 * RETURN: Status
240 * 240 *
241 * DESCRIPTION: Executes _STA for selected device and stores results in 241 * DESCRIPTION: Executes _STA for selected device and stores results in
242 * *Flags. 242 * *Flags. If _STA does not exist, then the device is assumed
243 * to be present/functional/enabled (as per the ACPI spec).
243 * 244 *
244 * NOTE: Internal function, no parameter validation 245 * NOTE: Internal function, no parameter validation
245 * 246 *
@@ -257,6 +258,11 @@ acpi_ut_execute_STA(struct acpi_namespace_node *device_node, u32 * flags)
257 ACPI_BTYPE_INTEGER, &obj_desc); 258 ACPI_BTYPE_INTEGER, &obj_desc);
258 if (ACPI_FAILURE(status)) { 259 if (ACPI_FAILURE(status)) {
259 if (AE_NOT_FOUND == status) { 260 if (AE_NOT_FOUND == status) {
261 /*
262 * if _STA does not exist, then (as per the ACPI specification),
263 * the returned flags will indicate that the device is present,
264 * functional, and enabled.
265 */
260 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, 266 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
261 "_STA on %4.4s was not found, assuming device is present\n", 267 "_STA on %4.4s was not found, assuming device is present\n",
262 acpi_ut_get_node_name(device_node))); 268 acpi_ut_get_node_name(device_node)));
diff --git a/drivers/acpi/acpica/utglobal.c b/drivers/acpi/acpica/utglobal.c
index f736448a8606..d6f26bf8a062 100644
--- a/drivers/acpi/acpica/utglobal.c
+++ b/drivers/acpi/acpica/utglobal.c
@@ -336,7 +336,6 @@ acpi_status acpi_ut_init_globals(void)
336 acpi_gbl_trace_dbg_layer = 0; 336 acpi_gbl_trace_dbg_layer = 0;
337 acpi_gbl_debugger_configuration = DEBUGGER_THREADING; 337 acpi_gbl_debugger_configuration = DEBUGGER_THREADING;
338 acpi_gbl_db_output_flags = ACPI_DB_CONSOLE_OUTPUT; 338 acpi_gbl_db_output_flags = ACPI_DB_CONSOLE_OUTPUT;
339 acpi_gbl_osi_data = 0;
340 acpi_gbl_osi_mutex = NULL; 339 acpi_gbl_osi_mutex = NULL;
341 acpi_gbl_reg_methods_executed = FALSE; 340 acpi_gbl_reg_methods_executed = FALSE;
342 341
diff --git a/drivers/acpi/acpica/utosi.c b/drivers/acpi/acpica/utosi.c
index 7e807725c636..8856bd37bc76 100644
--- a/drivers/acpi/acpica/utosi.c
+++ b/drivers/acpi/acpica/utosi.c
@@ -77,21 +77,20 @@ static struct acpi_interface_info acpi_default_supported_interfaces[] = {
77 77
78 /* Feature Group Strings */ 78 /* Feature Group Strings */
79 79
80 {"Extended Address Space Descriptor", NULL, 0, 0} 80 {"Extended Address Space Descriptor", NULL, ACPI_OSI_FEATURE, 0},
81 81
82 /* 82 /*
83 * All "optional" feature group strings (features that are implemented 83 * All "optional" feature group strings (features that are implemented
84 * by the host) should be dynamically added by the host via 84 * by the host) should be dynamically modified to VALID by the host via
85 * acpi_install_interface and should not be manually added here. 85 * acpi_install_interface or acpi_update_interfaces. Such optional feature
86 * 86 * group strings are set as INVALID by default here.
87 * Examples of optional feature group strings:
88 *
89 * "Module Device"
90 * "Processor Device"
91 * "3.0 Thermal Model"
92 * "3.0 _SCP Extensions"
93 * "Processor Aggregator Device"
94 */ 87 */
88
89 {"Module Device", NULL, ACPI_OSI_OPTIONAL_FEATURE, 0},
90 {"Processor Device", NULL, ACPI_OSI_OPTIONAL_FEATURE, 0},
91 {"3.0 Thermal Model", NULL, ACPI_OSI_OPTIONAL_FEATURE, 0},
92 {"3.0 _SCP Extensions", NULL, ACPI_OSI_OPTIONAL_FEATURE, 0},
93 {"Processor Aggregator Device", NULL, ACPI_OSI_OPTIONAL_FEATURE, 0}
95}; 94};
96 95
97/******************************************************************************* 96/*******************************************************************************
@@ -158,11 +157,20 @@ acpi_status acpi_ut_interface_terminate(void)
158 while (next_interface) { 157 while (next_interface) {
159 acpi_gbl_supported_interfaces = next_interface->next; 158 acpi_gbl_supported_interfaces = next_interface->next;
160 159
161 /* Only interfaces added at runtime can be freed */
162
163 if (next_interface->flags & ACPI_OSI_DYNAMIC) { 160 if (next_interface->flags & ACPI_OSI_DYNAMIC) {
161
162 /* Only interfaces added at runtime can be freed */
163
164 ACPI_FREE(next_interface->name); 164 ACPI_FREE(next_interface->name);
165 ACPI_FREE(next_interface); 165 ACPI_FREE(next_interface);
166 } else {
167 /* Interface is in static list. Reset it to invalid or valid. */
168
169 if (next_interface->flags & ACPI_OSI_DEFAULT_INVALID) {
170 next_interface->flags |= ACPI_OSI_INVALID;
171 } else {
172 next_interface->flags &= ~ACPI_OSI_INVALID;
173 }
166 } 174 }
167 175
168 next_interface = acpi_gbl_supported_interfaces; 176 next_interface = acpi_gbl_supported_interfaces;
@@ -278,6 +286,49 @@ acpi_status acpi_ut_remove_interface(acpi_string interface_name)
278 286
279/******************************************************************************* 287/*******************************************************************************
280 * 288 *
289 * FUNCTION: acpi_ut_update_interfaces
290 *
291 * PARAMETERS: action - Actions to be performed during the
292 * update
293 *
294 * RETURN: Status
295 *
296 * DESCRIPTION: Update _OSI interface strings, disabling or enabling OS vendor
297 * strings or/and feature group strings.
298 * Caller MUST hold acpi_gbl_osi_mutex
299 *
300 ******************************************************************************/
301
302acpi_status acpi_ut_update_interfaces(u8 action)
303{
304 struct acpi_interface_info *next_interface;
305
306 next_interface = acpi_gbl_supported_interfaces;
307 while (next_interface) {
308 if (((next_interface->flags & ACPI_OSI_FEATURE) &&
309 (action & ACPI_FEATURE_STRINGS)) ||
310 (!(next_interface->flags & ACPI_OSI_FEATURE) &&
311 (action & ACPI_VENDOR_STRINGS))) {
312 if (action & ACPI_DISABLE_INTERFACES) {
313
314 /* Mark the interfaces as invalid */
315
316 next_interface->flags |= ACPI_OSI_INVALID;
317 } else {
318 /* Mark the interfaces as valid */
319
320 next_interface->flags &= ~ACPI_OSI_INVALID;
321 }
322 }
323
324 next_interface = next_interface->next;
325 }
326
327 return (AE_OK);
328}
329
330/*******************************************************************************
331 *
281 * FUNCTION: acpi_ut_get_interface 332 * FUNCTION: acpi_ut_get_interface
282 * 333 *
283 * PARAMETERS: interface_name - The interface to find 334 * PARAMETERS: interface_name - The interface to find
diff --git a/drivers/acpi/acpica/utstring.c b/drivers/acpi/acpica/utstring.c
index c53759b76a3f..cb1e9cc32d5f 100644
--- a/drivers/acpi/acpica/utstring.c
+++ b/drivers/acpi/acpica/utstring.c
@@ -333,7 +333,8 @@ acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 *ret_integer)
333 * FUNCTION: acpi_ut_print_string 333 * FUNCTION: acpi_ut_print_string
334 * 334 *
335 * PARAMETERS: string - Null terminated ASCII string 335 * PARAMETERS: string - Null terminated ASCII string
336 * max_length - Maximum output length 336 * max_length - Maximum output length. Used to constrain the
337 * length of strings during debug output only.
337 * 338 *
338 * RETURN: None 339 * RETURN: None
339 * 340 *
@@ -342,7 +343,7 @@ acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 *ret_integer)
342 * 343 *
343 ******************************************************************************/ 344 ******************************************************************************/
344 345
345void acpi_ut_print_string(char *string, u8 max_length) 346void acpi_ut_print_string(char *string, u16 max_length)
346{ 347{
347 u32 i; 348 u32 i;
348 349
diff --git a/drivers/acpi/acpica/utxface.c b/drivers/acpi/acpica/utxface.c
index 6505774f223e..03a211e6e26a 100644
--- a/drivers/acpi/acpica/utxface.c
+++ b/drivers/acpi/acpica/utxface.c
@@ -389,6 +389,34 @@ ACPI_EXPORT_SYMBOL(acpi_install_interface_handler)
389 389
390/***************************************************************************** 390/*****************************************************************************
391 * 391 *
392 * FUNCTION: acpi_update_interfaces
393 *
394 * PARAMETERS: action - Actions to be performed during the
395 * update
396 *
397 * RETURN: Status
398 *
399 * DESCRIPTION: Update _OSI interface strings, disabling or enabling OS vendor
400 * string or/and feature group strings.
401 *
402 ****************************************************************************/
403acpi_status acpi_update_interfaces(u8 action)
404{
405 acpi_status status;
406
407 status = acpi_os_acquire_mutex(acpi_gbl_osi_mutex, ACPI_WAIT_FOREVER);
408 if (ACPI_FAILURE(status)) {
409 return (status);
410 }
411
412 status = acpi_ut_update_interfaces(action);
413
414 acpi_os_release_mutex(acpi_gbl_osi_mutex);
415 return (status);
416}
417
418/*****************************************************************************
419 *
392 * FUNCTION: acpi_check_address_range 420 * FUNCTION: acpi_check_address_range
393 * 421 *
394 * PARAMETERS: space_id - Address space ID 422 * PARAMETERS: space_id - Address space ID
@@ -402,6 +430,7 @@ ACPI_EXPORT_SYMBOL(acpi_install_interface_handler)
402 * ASL operation region address ranges. 430 * ASL operation region address ranges.
403 * 431 *
404 ****************************************************************************/ 432 ****************************************************************************/
433
405u32 434u32
406acpi_check_address_range(acpi_adr_space_type space_id, 435acpi_check_address_range(acpi_adr_space_type space_id,
407 acpi_physical_address address, 436 acpi_physical_address address,
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index d405fbad406a..2c9958cd7a43 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -527,18 +527,14 @@ static int acpi_battery_get_state(struct acpi_battery *battery)
527static int acpi_battery_set_alarm(struct acpi_battery *battery) 527static int acpi_battery_set_alarm(struct acpi_battery *battery)
528{ 528{
529 acpi_status status = 0; 529 acpi_status status = 0;
530 union acpi_object arg0 = { .type = ACPI_TYPE_INTEGER };
531 struct acpi_object_list arg_list = { 1, &arg0 };
532 530
533 if (!acpi_battery_present(battery) || 531 if (!acpi_battery_present(battery) ||
534 !test_bit(ACPI_BATTERY_ALARM_PRESENT, &battery->flags)) 532 !test_bit(ACPI_BATTERY_ALARM_PRESENT, &battery->flags))
535 return -ENODEV; 533 return -ENODEV;
536 534
537 arg0.integer.value = battery->alarm;
538
539 mutex_lock(&battery->lock); 535 mutex_lock(&battery->lock);
540 status = acpi_evaluate_object(battery->device->handle, "_BTP", 536 status = acpi_execute_simple_method(battery->device->handle, "_BTP",
541 &arg_list, NULL); 537 battery->alarm);
542 mutex_unlock(&battery->lock); 538 mutex_unlock(&battery->lock);
543 539
544 if (ACPI_FAILURE(status)) 540 if (ACPI_FAILURE(status))
@@ -550,12 +546,8 @@ static int acpi_battery_set_alarm(struct acpi_battery *battery)
550 546
551static int acpi_battery_init_alarm(struct acpi_battery *battery) 547static int acpi_battery_init_alarm(struct acpi_battery *battery)
552{ 548{
553 acpi_status status = AE_OK;
554 acpi_handle handle = NULL;
555
556 /* See if alarms are supported, and if so, set default */ 549 /* See if alarms are supported, and if so, set default */
557 status = acpi_get_handle(battery->device->handle, "_BTP", &handle); 550 if (!acpi_has_method(battery->device->handle, "_BTP")) {
558 if (ACPI_FAILURE(status)) {
559 clear_bit(ACPI_BATTERY_ALARM_PRESENT, &battery->flags); 551 clear_bit(ACPI_BATTERY_ALARM_PRESENT, &battery->flags);
560 return 0; 552 return 0;
561 } 553 }
@@ -1036,8 +1028,6 @@ static void acpi_battery_notify(struct acpi_device *device, u32 event)
1036 if (event == ACPI_BATTERY_NOTIFY_INFO) 1028 if (event == ACPI_BATTERY_NOTIFY_INFO)
1037 acpi_battery_refresh(battery); 1029 acpi_battery_refresh(battery);
1038 acpi_battery_update(battery); 1030 acpi_battery_update(battery);
1039 acpi_bus_generate_proc_event(device, event,
1040 acpi_battery_present(battery));
1041 acpi_bus_generate_netlink_event(device->pnp.device_class, 1031 acpi_bus_generate_netlink_event(device->pnp.device_class,
1042 dev_name(&device->dev), event, 1032 dev_name(&device->dev), event,
1043 acpi_battery_present(battery)); 1033 acpi_battery_present(battery));
@@ -1068,7 +1058,7 @@ static int acpi_battery_add(struct acpi_device *device)
1068{ 1058{
1069 int result = 0; 1059 int result = 0;
1070 struct acpi_battery *battery = NULL; 1060 struct acpi_battery *battery = NULL;
1071 acpi_handle handle; 1061
1072 if (!device) 1062 if (!device)
1073 return -EINVAL; 1063 return -EINVAL;
1074 battery = kzalloc(sizeof(struct acpi_battery), GFP_KERNEL); 1064 battery = kzalloc(sizeof(struct acpi_battery), GFP_KERNEL);
@@ -1080,8 +1070,7 @@ static int acpi_battery_add(struct acpi_device *device)
1080 device->driver_data = battery; 1070 device->driver_data = battery;
1081 mutex_init(&battery->lock); 1071 mutex_init(&battery->lock);
1082 mutex_init(&battery->sysfs_lock); 1072 mutex_init(&battery->sysfs_lock);
1083 if (ACPI_SUCCESS(acpi_get_handle(battery->device->handle, 1073 if (acpi_has_method(battery->device->handle, "_BIX"))
1084 "_BIX", &handle)))
1085 set_bit(ACPI_BATTERY_XINFO_PRESENT, &battery->flags); 1074 set_bit(ACPI_BATTERY_XINFO_PRESENT, &battery->flags);
1086 result = acpi_battery_update(battery); 1075 result = acpi_battery_update(battery);
1087 if (result) 1076 if (result)
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index a5bb33bab448..b587ec8257b2 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -89,27 +89,6 @@ static struct dmi_system_id dsdt_dmi_table[] __initdata = {
89 Device Management 89 Device Management
90 -------------------------------------------------------------------------- */ 90 -------------------------------------------------------------------------- */
91 91
92int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device)
93{
94 acpi_status status;
95
96 if (!device)
97 return -EINVAL;
98
99 /* TBD: Support fixed-feature devices */
100
101 status = acpi_get_data(handle, acpi_bus_data_handler, (void **)device);
102 if (ACPI_FAILURE(status) || !*device) {
103 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No context for object [%p]\n",
104 handle));
105 return -ENODEV;
106 }
107
108 return 0;
109}
110
111EXPORT_SYMBOL(acpi_bus_get_device);
112
113acpi_status acpi_bus_get_status_handle(acpi_handle handle, 92acpi_status acpi_bus_get_status_handle(acpi_handle handle,
114 unsigned long long *sta) 93 unsigned long long *sta)
115{ 94{
@@ -346,104 +325,6 @@ static void acpi_bus_osc_support(void)
346} 325}
347 326
348/* -------------------------------------------------------------------------- 327/* --------------------------------------------------------------------------
349 Event Management
350 -------------------------------------------------------------------------- */
351
352#ifdef CONFIG_ACPI_PROC_EVENT
353static DEFINE_SPINLOCK(acpi_bus_event_lock);
354
355LIST_HEAD(acpi_bus_event_list);
356DECLARE_WAIT_QUEUE_HEAD(acpi_bus_event_queue);
357
358extern int event_is_open;
359
360int acpi_bus_generate_proc_event4(const char *device_class, const char *bus_id, u8 type, int data)
361{
362 struct acpi_bus_event *event;
363 unsigned long flags;
364
365 /* drop event on the floor if no one's listening */
366 if (!event_is_open)
367 return 0;
368
369 event = kzalloc(sizeof(struct acpi_bus_event), GFP_ATOMIC);
370 if (!event)
371 return -ENOMEM;
372
373 strcpy(event->device_class, device_class);
374 strcpy(event->bus_id, bus_id);
375 event->type = type;
376 event->data = data;
377
378 spin_lock_irqsave(&acpi_bus_event_lock, flags);
379 list_add_tail(&event->node, &acpi_bus_event_list);
380 spin_unlock_irqrestore(&acpi_bus_event_lock, flags);
381
382 wake_up_interruptible(&acpi_bus_event_queue);
383
384 return 0;
385
386}
387
388EXPORT_SYMBOL_GPL(acpi_bus_generate_proc_event4);
389
390int acpi_bus_generate_proc_event(struct acpi_device *device, u8 type, int data)
391{
392 if (!device)
393 return -EINVAL;
394 return acpi_bus_generate_proc_event4(device->pnp.device_class,
395 device->pnp.bus_id, type, data);
396}
397
398EXPORT_SYMBOL(acpi_bus_generate_proc_event);
399
400int acpi_bus_receive_event(struct acpi_bus_event *event)
401{
402 unsigned long flags;
403 struct acpi_bus_event *entry = NULL;
404
405 DECLARE_WAITQUEUE(wait, current);
406
407
408 if (!event)
409 return -EINVAL;
410
411 if (list_empty(&acpi_bus_event_list)) {
412
413 set_current_state(TASK_INTERRUPTIBLE);
414 add_wait_queue(&acpi_bus_event_queue, &wait);
415
416 if (list_empty(&acpi_bus_event_list))
417 schedule();
418
419 remove_wait_queue(&acpi_bus_event_queue, &wait);
420 set_current_state(TASK_RUNNING);
421
422 if (signal_pending(current))
423 return -ERESTARTSYS;
424 }
425
426 spin_lock_irqsave(&acpi_bus_event_lock, flags);
427 if (!list_empty(&acpi_bus_event_list)) {
428 entry = list_entry(acpi_bus_event_list.next,
429 struct acpi_bus_event, node);
430 list_del(&entry->node);
431 }
432 spin_unlock_irqrestore(&acpi_bus_event_lock, flags);
433
434 if (!entry)
435 return -ENODEV;
436
437 memcpy(event, entry, sizeof(struct acpi_bus_event));
438
439 kfree(entry);
440
441 return 0;
442}
443
444#endif /* CONFIG_ACPI_PROC_EVENT */
445
446/* --------------------------------------------------------------------------
447 Notification Handling 328 Notification Handling
448 -------------------------------------------------------------------------- */ 329 -------------------------------------------------------------------------- */
449 330
@@ -499,19 +380,6 @@ static void acpi_bus_check_scope(acpi_handle handle)
499 */ 380 */
500} 381}
501 382
502static BLOCKING_NOTIFIER_HEAD(acpi_bus_notify_list);
503int register_acpi_bus_notifier(struct notifier_block *nb)
504{
505 return blocking_notifier_chain_register(&acpi_bus_notify_list, nb);
506}
507EXPORT_SYMBOL_GPL(register_acpi_bus_notifier);
508
509void unregister_acpi_bus_notifier(struct notifier_block *nb)
510{
511 blocking_notifier_chain_unregister(&acpi_bus_notify_list, nb);
512}
513EXPORT_SYMBOL_GPL(unregister_acpi_bus_notifier);
514
515/** 383/**
516 * acpi_bus_notify 384 * acpi_bus_notify
517 * --------------- 385 * ---------------
@@ -525,9 +393,6 @@ static void acpi_bus_notify(acpi_handle handle, u32 type, void *data)
525 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Notification %#02x to handle %p\n", 393 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Notification %#02x to handle %p\n",
526 type, handle)); 394 type, handle));
527 395
528 blocking_notifier_call_chain(&acpi_bus_notify_list,
529 type, (void *)handle);
530
531 switch (type) { 396 switch (type) {
532 397
533 case ACPI_NOTIFY_BUS_CHECK: 398 case ACPI_NOTIFY_BUS_CHECK:
@@ -593,8 +458,6 @@ static void acpi_bus_notify(acpi_handle handle, u32 type, void *data)
593static int __init acpi_bus_init_irq(void) 458static int __init acpi_bus_init_irq(void)
594{ 459{
595 acpi_status status; 460 acpi_status status;
596 union acpi_object arg = { ACPI_TYPE_INTEGER };
597 struct acpi_object_list arg_list = { 1, &arg };
598 char *message = NULL; 461 char *message = NULL;
599 462
600 463
@@ -623,9 +486,7 @@ static int __init acpi_bus_init_irq(void)
623 486
624 printk(KERN_INFO PREFIX "Using %s for interrupt routing\n", message); 487 printk(KERN_INFO PREFIX "Using %s for interrupt routing\n", message);
625 488
626 arg.integer.value = acpi_irq_model; 489 status = acpi_execute_simple_method(NULL, "\\_PIC", acpi_irq_model);
627
628 status = acpi_evaluate_object(NULL, "\\_PIC", &arg_list, NULL);
629 if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) { 490 if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) {
630 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PIC")); 491 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PIC"));
631 return -ENODEV; 492 return -ENODEV;
@@ -715,7 +576,6 @@ static int __init acpi_bus_init(void)
715{ 576{
716 int result; 577 int result;
717 acpi_status status; 578 acpi_status status;
718 extern acpi_status acpi_os_initialize1(void);
719 579
720 acpi_os_initialize1(); 580 acpi_os_initialize1();
721 581
diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c
index d2e617b5b3f6..a55773801c5f 100644
--- a/drivers/acpi/button.c
+++ b/drivers/acpi/button.c
@@ -303,8 +303,6 @@ static void acpi_button_notify(struct acpi_device *device, u32 event)
303 303
304 pm_wakeup_event(&device->dev, 0); 304 pm_wakeup_event(&device->dev, 0);
305 } 305 }
306
307 acpi_bus_generate_proc_event(device, event, ++button->pushed);
308 break; 306 break;
309 default: 307 default:
310 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 308 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c
index 4ab807dc8518..59d3202f6b36 100644
--- a/drivers/acpi/device_pm.c
+++ b/drivers/acpi/device_pm.c
@@ -159,26 +159,29 @@ int acpi_device_set_power(struct acpi_device *device, int state)
159 int result = 0; 159 int result = 0;
160 bool cut_power = false; 160 bool cut_power = false;
161 161
162 if (!device || (state < ACPI_STATE_D0) || (state > ACPI_STATE_D3_COLD)) 162 if (!device || !device->flags.power_manageable
163 || (state < ACPI_STATE_D0) || (state > ACPI_STATE_D3_COLD))
163 return -EINVAL; 164 return -EINVAL;
164 165
165 /* Make sure this is a valid target state */ 166 /* Make sure this is a valid target state */
166 167
167 if (state == device->power.state) { 168 if (state == device->power.state) {
168 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device is already at %s\n", 169 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] already in %s\n",
170 device->pnp.bus_id,
169 acpi_power_state_string(state))); 171 acpi_power_state_string(state)));
170 return 0; 172 return 0;
171 } 173 }
172 174
173 if (!device->power.states[state].flags.valid) { 175 if (!device->power.states[state].flags.valid) {
174 printk(KERN_WARNING PREFIX "Device does not support %s\n", 176 dev_warn(&device->dev, "Power state %s not supported\n",
175 acpi_power_state_string(state)); 177 acpi_power_state_string(state));
176 return -ENODEV; 178 return -ENODEV;
177 } 179 }
178 if (device->parent && (state < device->parent->power.state)) { 180 if (device->parent && (state < device->parent->power.state)) {
179 printk(KERN_WARNING PREFIX 181 dev_warn(&device->dev,
180 "Cannot set device to a higher-powered" 182 "Cannot transition to power state %s for parent in %s\n",
181 " state than parent\n"); 183 acpi_power_state_string(state),
184 acpi_power_state_string(device->parent->power.state));
182 return -ENODEV; 185 return -ENODEV;
183 } 186 }
184 187
@@ -191,8 +194,8 @@ int acpi_device_set_power(struct acpi_device *device, int state)
191 194
192 if (state < device->power.state && state != ACPI_STATE_D0 195 if (state < device->power.state && state != ACPI_STATE_D0
193 && device->power.state >= ACPI_STATE_D3_HOT) { 196 && device->power.state >= ACPI_STATE_D3_HOT) {
194 printk(KERN_WARNING PREFIX 197 dev_warn(&device->dev,
195 "Cannot transition to non-D0 state from D3\n"); 198 "Cannot transition to non-D0 state from D3\n");
196 return -ENODEV; 199 return -ENODEV;
197 } 200 }
198 201
@@ -219,10 +222,8 @@ int acpi_device_set_power(struct acpi_device *device, int state)
219 222
220 end: 223 end:
221 if (result) { 224 if (result) {
222 printk(KERN_WARNING PREFIX 225 dev_warn(&device->dev, "Failed to change power state to %s\n",
223 "Device [%s] failed to transition to %s\n", 226 acpi_power_state_string(state));
224 device->pnp.bus_id,
225 acpi_power_state_string(state));
226 } else { 227 } else {
227 device->power.state = state; 228 device->power.state = state;
228 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 229 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
@@ -244,13 +245,6 @@ int acpi_bus_set_power(acpi_handle handle, int state)
244 if (result) 245 if (result)
245 return result; 246 return result;
246 247
247 if (!device->flags.power_manageable) {
248 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
249 "Device [%s] is not power manageable\n",
250 dev_name(&device->dev)));
251 return -ENODEV;
252 }
253
254 return acpi_device_set_power(device, state); 248 return acpi_device_set_power(device, state);
255} 249}
256EXPORT_SYMBOL(acpi_bus_set_power); 250EXPORT_SYMBOL(acpi_bus_set_power);
diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c
index 826560753389..05ea4be01a83 100644
--- a/drivers/acpi/dock.c
+++ b/drivers/acpi/dock.c
@@ -51,8 +51,6 @@ MODULE_PARM_DESC(immediate_undock, "1 (default) will cause the driver to "
51 " the driver to wait for userspace to write the undock sysfs file " 51 " the driver to wait for userspace to write the undock sysfs file "
52 " before undocking"); 52 " before undocking");
53 53
54static struct atomic_notifier_head dock_notifier_list;
55
56static const struct acpi_device_id dock_device_ids[] = { 54static const struct acpi_device_id dock_device_ids[] = {
57 {"LNXDOCK", 0}, 55 {"LNXDOCK", 0},
58 {"", 0}, 56 {"", 0},
@@ -63,8 +61,6 @@ struct dock_station {
63 acpi_handle handle; 61 acpi_handle handle;
64 unsigned long last_dock_time; 62 unsigned long last_dock_time;
65 u32 flags; 63 u32 flags;
66 spinlock_t dd_lock;
67 struct mutex hp_lock;
68 struct list_head dependent_devices; 64 struct list_head dependent_devices;
69 65
70 struct list_head sibling; 66 struct list_head sibling;
@@ -91,6 +87,12 @@ struct dock_dependent_device {
91#define DOCK_EVENT 3 87#define DOCK_EVENT 3
92#define UNDOCK_EVENT 2 88#define UNDOCK_EVENT 2
93 89
90enum dock_callback_type {
91 DOCK_CALL_HANDLER,
92 DOCK_CALL_FIXUP,
93 DOCK_CALL_UEVENT,
94};
95
94/***************************************************************************** 96/*****************************************************************************
95 * Dock Dependent device functions * 97 * Dock Dependent device functions *
96 *****************************************************************************/ 98 *****************************************************************************/
@@ -101,7 +103,7 @@ struct dock_dependent_device {
101 * 103 *
102 * Add the dependent device to the dock's dependent device list. 104 * Add the dependent device to the dock's dependent device list.
103 */ 105 */
104static int 106static int __init
105add_dock_dependent_device(struct dock_station *ds, acpi_handle handle) 107add_dock_dependent_device(struct dock_station *ds, acpi_handle handle)
106{ 108{
107 struct dock_dependent_device *dd; 109 struct dock_dependent_device *dd;
@@ -112,14 +114,21 @@ add_dock_dependent_device(struct dock_station *ds, acpi_handle handle)
112 114
113 dd->handle = handle; 115 dd->handle = handle;
114 INIT_LIST_HEAD(&dd->list); 116 INIT_LIST_HEAD(&dd->list);
115
116 spin_lock(&ds->dd_lock);
117 list_add_tail(&dd->list, &ds->dependent_devices); 117 list_add_tail(&dd->list, &ds->dependent_devices);
118 spin_unlock(&ds->dd_lock);
119 118
120 return 0; 119 return 0;
121} 120}
122 121
122static void remove_dock_dependent_devices(struct dock_station *ds)
123{
124 struct dock_dependent_device *dd, *aux;
125
126 list_for_each_entry_safe(dd, aux, &ds->dependent_devices, list) {
127 list_del(&dd->list);
128 kfree(dd);
129 }
130}
131
123/** 132/**
124 * dock_init_hotplug - Initialize a hotplug device on a docking station. 133 * dock_init_hotplug - Initialize a hotplug device on a docking station.
125 * @dd: Dock-dependent device. 134 * @dd: Dock-dependent device.
@@ -135,19 +144,16 @@ static int dock_init_hotplug(struct dock_dependent_device *dd,
135 int ret = 0; 144 int ret = 0;
136 145
137 mutex_lock(&hotplug_lock); 146 mutex_lock(&hotplug_lock);
138 147 if (WARN_ON(dd->hp_context)) {
139 if (dd->hp_context) {
140 ret = -EEXIST; 148 ret = -EEXIST;
141 } else { 149 } else {
142 dd->hp_refcount = 1; 150 dd->hp_refcount = 1;
143 dd->hp_ops = ops; 151 dd->hp_ops = ops;
144 dd->hp_context = context; 152 dd->hp_context = context;
145 dd->hp_release = release; 153 dd->hp_release = release;
154 if (init)
155 init(context);
146 } 156 }
147
148 if (!WARN_ON(ret) && init)
149 init(context);
150
151 mutex_unlock(&hotplug_lock); 157 mutex_unlock(&hotplug_lock);
152 return ret; 158 return ret;
153} 159}
@@ -162,27 +168,22 @@ static int dock_init_hotplug(struct dock_dependent_device *dd,
162 */ 168 */
163static void dock_release_hotplug(struct dock_dependent_device *dd) 169static void dock_release_hotplug(struct dock_dependent_device *dd)
164{ 170{
165 void (*release)(void *) = NULL;
166 void *context = NULL;
167
168 mutex_lock(&hotplug_lock); 171 mutex_lock(&hotplug_lock);
169
170 if (dd->hp_context && !--dd->hp_refcount) { 172 if (dd->hp_context && !--dd->hp_refcount) {
173 void (*release)(void *) = dd->hp_release;
174 void *context = dd->hp_context;
175
171 dd->hp_ops = NULL; 176 dd->hp_ops = NULL;
172 context = dd->hp_context;
173 dd->hp_context = NULL; 177 dd->hp_context = NULL;
174 release = dd->hp_release;
175 dd->hp_release = NULL; 178 dd->hp_release = NULL;
179 if (release)
180 release(context);
176 } 181 }
177
178 if (release && context)
179 release(context);
180
181 mutex_unlock(&hotplug_lock); 182 mutex_unlock(&hotplug_lock);
182} 183}
183 184
184static void dock_hotplug_event(struct dock_dependent_device *dd, u32 event, 185static void dock_hotplug_event(struct dock_dependent_device *dd, u32 event,
185 bool uevent) 186 enum dock_callback_type cb_type)
186{ 187{
187 acpi_notify_handler cb = NULL; 188 acpi_notify_handler cb = NULL;
188 bool run = false; 189 bool run = false;
@@ -192,8 +193,18 @@ static void dock_hotplug_event(struct dock_dependent_device *dd, u32 event,
192 if (dd->hp_context) { 193 if (dd->hp_context) {
193 run = true; 194 run = true;
194 dd->hp_refcount++; 195 dd->hp_refcount++;
195 if (dd->hp_ops) 196 if (dd->hp_ops) {
196 cb = uevent ? dd->hp_ops->uevent : dd->hp_ops->handler; 197 switch (cb_type) {
198 case DOCK_CALL_FIXUP:
199 cb = dd->hp_ops->fixup;
200 break;
201 case DOCK_CALL_UEVENT:
202 cb = dd->hp_ops->uevent;
203 break;
204 default:
205 cb = dd->hp_ops->handler;
206 }
207 }
197 } 208 }
198 209
199 mutex_unlock(&hotplug_lock); 210 mutex_unlock(&hotplug_lock);
@@ -220,63 +231,17 @@ find_dock_dependent_device(struct dock_station *ds, acpi_handle handle)
220{ 231{
221 struct dock_dependent_device *dd; 232 struct dock_dependent_device *dd;
222 233
223 spin_lock(&ds->dd_lock); 234 list_for_each_entry(dd, &ds->dependent_devices, list)
224 list_for_each_entry(dd, &ds->dependent_devices, list) { 235 if (handle == dd->handle)
225 if (handle == dd->handle) {
226 spin_unlock(&ds->dd_lock);
227 return dd; 236 return dd;
228 } 237
229 }
230 spin_unlock(&ds->dd_lock);
231 return NULL; 238 return NULL;
232} 239}
233 240
234/***************************************************************************** 241/*****************************************************************************
235 * Dock functions * 242 * Dock functions *
236 *****************************************************************************/ 243 *****************************************************************************/
237/** 244static int __init is_battery(acpi_handle handle)
238 * is_dock - see if a device is a dock station
239 * @handle: acpi handle of the device
240 *
241 * If an acpi object has a _DCK method, then it is by definition a dock
242 * station, so return true.
243 */
244static int is_dock(acpi_handle handle)
245{
246 acpi_status status;
247 acpi_handle tmp;
248
249 status = acpi_get_handle(handle, "_DCK", &tmp);
250 if (ACPI_FAILURE(status))
251 return 0;
252 return 1;
253}
254
255static int is_ejectable(acpi_handle handle)
256{
257 acpi_status status;
258 acpi_handle tmp;
259
260 status = acpi_get_handle(handle, "_EJ0", &tmp);
261 if (ACPI_FAILURE(status))
262 return 0;
263 return 1;
264}
265
266static int is_ata(acpi_handle handle)
267{
268 acpi_handle tmp;
269
270 if ((ACPI_SUCCESS(acpi_get_handle(handle, "_GTF", &tmp))) ||
271 (ACPI_SUCCESS(acpi_get_handle(handle, "_GTM", &tmp))) ||
272 (ACPI_SUCCESS(acpi_get_handle(handle, "_STM", &tmp))) ||
273 (ACPI_SUCCESS(acpi_get_handle(handle, "_SDD", &tmp))))
274 return 1;
275
276 return 0;
277}
278
279static int is_battery(acpi_handle handle)
280{ 245{
281 struct acpi_device_info *info; 246 struct acpi_device_info *info;
282 int ret = 1; 247 int ret = 1;
@@ -292,17 +257,13 @@ static int is_battery(acpi_handle handle)
292 return ret; 257 return ret;
293} 258}
294 259
295static int is_ejectable_bay(acpi_handle handle) 260/* Check whether ACPI object is an ejectable battery or disk bay */
261static bool __init is_ejectable_bay(acpi_handle handle)
296{ 262{
297 acpi_handle phandle; 263 if (acpi_has_method(handle, "_EJ0") && is_battery(handle))
264 return true;
298 265
299 if (!is_ejectable(handle)) 266 return acpi_bay_match(handle);
300 return 0;
301 if (is_battery(handle) || is_ata(handle))
302 return 1;
303 if (!acpi_get_parent(handle, &phandle) && is_ata(phandle))
304 return 1;
305 return 0;
306} 267}
307 268
308/** 269/**
@@ -320,7 +281,7 @@ int is_dock_device(acpi_handle handle)
320 if (!dock_station_count) 281 if (!dock_station_count)
321 return 0; 282 return 0;
322 283
323 if (is_dock(handle)) 284 if (acpi_dock_match(handle))
324 return 1; 285 return 1;
325 286
326 list_for_each_entry(dock_station, &dock_stations, sibling) 287 list_for_each_entry(dock_station, &dock_stations, sibling)
@@ -359,10 +320,8 @@ static int dock_present(struct dock_station *ds)
359 * handle if one does not exist already. This should cause 320 * handle if one does not exist already. This should cause
360 * acpi to scan for drivers for the given devices, and call 321 * acpi to scan for drivers for the given devices, and call
361 * matching driver's add routine. 322 * matching driver's add routine.
362 *
363 * Returns a pointer to the acpi_device corresponding to the handle.
364 */ 323 */
365static struct acpi_device * dock_create_acpi_device(acpi_handle handle) 324static void dock_create_acpi_device(acpi_handle handle)
366{ 325{
367 struct acpi_device *device; 326 struct acpi_device *device;
368 int ret; 327 int ret;
@@ -375,10 +334,7 @@ static struct acpi_device * dock_create_acpi_device(acpi_handle handle)
375 ret = acpi_bus_scan(handle); 334 ret = acpi_bus_scan(handle);
376 if (ret) 335 if (ret)
377 pr_debug("error adding bus, %x\n", -ret); 336 pr_debug("error adding bus, %x\n", -ret);
378
379 acpi_bus_get_device(handle, &device);
380 } 337 }
381 return device;
382} 338}
383 339
384/** 340/**
@@ -397,9 +353,29 @@ static void dock_remove_acpi_device(acpi_handle handle)
397} 353}
398 354
399/** 355/**
400 * hotplug_dock_devices - insert or remove devices on the dock station 356 * hot_remove_dock_devices - Remove dock station devices.
357 * @ds: Dock station.
358 */
359static void hot_remove_dock_devices(struct dock_station *ds)
360{
361 struct dock_dependent_device *dd;
362
363 /*
364 * Walk the list in reverse order so that devices that have been added
365 * last are removed first (in case there are some indirect dependencies
366 * between them).
367 */
368 list_for_each_entry_reverse(dd, &ds->dependent_devices, list)
369 dock_hotplug_event(dd, ACPI_NOTIFY_EJECT_REQUEST, false);
370
371 list_for_each_entry_reverse(dd, &ds->dependent_devices, list)
372 dock_remove_acpi_device(dd->handle);
373}
374
375/**
376 * hotplug_dock_devices - Insert devices on a dock station.
401 * @ds: the dock station 377 * @ds: the dock station
402 * @event: either bus check or eject request 378 * @event: either bus check or device check request
403 * 379 *
404 * Some devices on the dock station need to have drivers called 380 * Some devices on the dock station need to have drivers called
405 * to perform hotplug operations after a dock event has occurred. 381 * to perform hotplug operations after a dock event has occurred.
@@ -410,27 +386,21 @@ static void hotplug_dock_devices(struct dock_station *ds, u32 event)
410{ 386{
411 struct dock_dependent_device *dd; 387 struct dock_dependent_device *dd;
412 388
413 mutex_lock(&ds->hp_lock); 389 /* Call driver specific post-dock fixups. */
390 list_for_each_entry(dd, &ds->dependent_devices, list)
391 dock_hotplug_event(dd, event, DOCK_CALL_FIXUP);
414 392
415 /* 393 /* Call driver specific hotplug functions. */
416 * First call driver specific hotplug functions
417 */
418 list_for_each_entry(dd, &ds->dependent_devices, list) 394 list_for_each_entry(dd, &ds->dependent_devices, list)
419 dock_hotplug_event(dd, event, false); 395 dock_hotplug_event(dd, event, DOCK_CALL_HANDLER);
420 396
421 /* 397 /*
422 * Now make sure that an acpi_device is created for each 398 * Now make sure that an acpi_device is created for each dependent
423 * dependent device, or removed if this is an eject request. 399 * device. That will cause scan handlers to be attached to device
424 * This will cause acpi_drivers to be stopped/started if they 400 * objects or acpi_drivers to be stopped/started if they are present.
425 * exist
426 */ 401 */
427 list_for_each_entry(dd, &ds->dependent_devices, list) { 402 list_for_each_entry(dd, &ds->dependent_devices, list)
428 if (event == ACPI_NOTIFY_EJECT_REQUEST) 403 dock_create_acpi_device(dd->handle);
429 dock_remove_acpi_device(dd->handle);
430 else
431 dock_create_acpi_device(dd->handle);
432 }
433 mutex_unlock(&ds->hp_lock);
434} 404}
435 405
436static void dock_event(struct dock_station *ds, u32 event, int num) 406static void dock_event(struct dock_station *ds, u32 event, int num)
@@ -453,44 +423,13 @@ static void dock_event(struct dock_station *ds, u32 event, int num)
453 kobject_uevent_env(&dev->kobj, KOBJ_CHANGE, envp); 423 kobject_uevent_env(&dev->kobj, KOBJ_CHANGE, envp);
454 424
455 list_for_each_entry(dd, &ds->dependent_devices, list) 425 list_for_each_entry(dd, &ds->dependent_devices, list)
456 dock_hotplug_event(dd, event, true); 426 dock_hotplug_event(dd, event, DOCK_CALL_UEVENT);
457 427
458 if (num != DOCK_EVENT) 428 if (num != DOCK_EVENT)
459 kobject_uevent_env(&dev->kobj, KOBJ_CHANGE, envp); 429 kobject_uevent_env(&dev->kobj, KOBJ_CHANGE, envp);
460} 430}
461 431
462/** 432/**
463 * eject_dock - respond to a dock eject request
464 * @ds: the dock station
465 *
466 * This is called after _DCK is called, to execute the dock station's
467 * _EJ0 method.
468 */
469static void eject_dock(struct dock_station *ds)
470{
471 struct acpi_object_list arg_list;
472 union acpi_object arg;
473 acpi_status status;
474 acpi_handle tmp;
475
476 /* all dock devices should have _EJ0, but check anyway */
477 status = acpi_get_handle(ds->handle, "_EJ0", &tmp);
478 if (ACPI_FAILURE(status)) {
479 pr_debug("No _EJ0 support for dock device\n");
480 return;
481 }
482
483 arg_list.count = 1;
484 arg_list.pointer = &arg;
485 arg.type = ACPI_TYPE_INTEGER;
486 arg.integer.value = 1;
487
488 status = acpi_evaluate_object(ds->handle, "_EJ0", &arg_list, NULL);
489 if (ACPI_FAILURE(status))
490 pr_debug("Failed to evaluate _EJ0!\n");
491}
492
493/**
494 * handle_dock - handle a dock event 433 * handle_dock - handle a dock event
495 * @ds: the dock station 434 * @ds: the dock station
496 * @dock: to dock, or undock - that is the question 435 * @dock: to dock, or undock - that is the question
@@ -550,27 +489,6 @@ static inline void complete_undock(struct dock_station *ds)
550 ds->flags &= ~(DOCK_UNDOCKING); 489 ds->flags &= ~(DOCK_UNDOCKING);
551} 490}
552 491
553static void dock_lock(struct dock_station *ds, int lock)
554{
555 struct acpi_object_list arg_list;
556 union acpi_object arg;
557 acpi_status status;
558
559 arg_list.count = 1;
560 arg_list.pointer = &arg;
561 arg.type = ACPI_TYPE_INTEGER;
562 arg.integer.value = !!lock;
563 status = acpi_evaluate_object(ds->handle, "_LCK", &arg_list, NULL);
564 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
565 if (lock)
566 acpi_handle_warn(ds->handle,
567 "Locking device failed (0x%x)\n", status);
568 else
569 acpi_handle_warn(ds->handle,
570 "Unlocking device failed (0x%x)\n", status);
571 }
572}
573
574/** 492/**
575 * dock_in_progress - see if we are in the middle of handling a dock event 493 * dock_in_progress - see if we are in the middle of handling a dock event
576 * @ds: the dock station 494 * @ds: the dock station
@@ -588,37 +506,6 @@ static int dock_in_progress(struct dock_station *ds)
588} 506}
589 507
590/** 508/**
591 * register_dock_notifier - add yourself to the dock notifier list
592 * @nb: the callers notifier block
593 *
594 * If a driver wishes to be notified about dock events, they can
595 * use this function to put a notifier block on the dock notifier list.
596 * this notifier call chain will be called after a dock event, but
597 * before hotplugging any new devices.
598 */
599int register_dock_notifier(struct notifier_block *nb)
600{
601 if (!dock_station_count)
602 return -ENODEV;
603
604 return atomic_notifier_chain_register(&dock_notifier_list, nb);
605}
606EXPORT_SYMBOL_GPL(register_dock_notifier);
607
608/**
609 * unregister_dock_notifier - remove yourself from the dock notifier list
610 * @nb: the callers notifier block
611 */
612void unregister_dock_notifier(struct notifier_block *nb)
613{
614 if (!dock_station_count)
615 return;
616
617 atomic_notifier_chain_unregister(&dock_notifier_list, nb);
618}
619EXPORT_SYMBOL_GPL(unregister_dock_notifier);
620
621/**
622 * register_hotplug_dock_device - register a hotplug function 509 * register_hotplug_dock_device - register a hotplug function
623 * @handle: the handle of the device 510 * @handle: the handle of the device
624 * @ops: handlers to call after docking 511 * @ops: handlers to call after docking
@@ -703,10 +590,10 @@ static int handle_eject_request(struct dock_station *ds, u32 event)
703 */ 590 */
704 dock_event(ds, event, UNDOCK_EVENT); 591 dock_event(ds, event, UNDOCK_EVENT);
705 592
706 hotplug_dock_devices(ds, ACPI_NOTIFY_EJECT_REQUEST); 593 hot_remove_dock_devices(ds);
707 undock(ds); 594 undock(ds);
708 dock_lock(ds, 0); 595 acpi_evaluate_lck(ds->handle, 0);
709 eject_dock(ds); 596 acpi_evaluate_ej0(ds->handle);
710 if (dock_present(ds)) { 597 if (dock_present(ds)) {
711 acpi_handle_err(ds->handle, "Unable to undock!\n"); 598 acpi_handle_err(ds->handle, "Unable to undock!\n");
712 return -EBUSY; 599 return -EBUSY;
@@ -717,18 +604,17 @@ static int handle_eject_request(struct dock_station *ds, u32 event)
717 604
718/** 605/**
719 * dock_notify - act upon an acpi dock notification 606 * dock_notify - act upon an acpi dock notification
720 * @handle: the dock station handle 607 * @ds: dock station
721 * @event: the acpi event 608 * @event: the acpi event
722 * @data: our driver data struct
723 * 609 *
724 * If we are notified to dock, then check to see if the dock is 610 * If we are notified to dock, then check to see if the dock is
725 * present and then dock. Notify all drivers of the dock event, 611 * present and then dock. Notify all drivers of the dock event,
726 * and then hotplug and devices that may need hotplugging. 612 * and then hotplug and devices that may need hotplugging.
727 */ 613 */
728static void dock_notify(acpi_handle handle, u32 event, void *data) 614static void dock_notify(struct dock_station *ds, u32 event)
729{ 615{
730 struct dock_station *ds = data; 616 acpi_handle handle = ds->handle;
731 struct acpi_device *tmp; 617 struct acpi_device *ad;
732 int surprise_removal = 0; 618 int surprise_removal = 0;
733 619
734 /* 620 /*
@@ -751,8 +637,7 @@ static void dock_notify(acpi_handle handle, u32 event, void *data)
751 switch (event) { 637 switch (event) {
752 case ACPI_NOTIFY_BUS_CHECK: 638 case ACPI_NOTIFY_BUS_CHECK:
753 case ACPI_NOTIFY_DEVICE_CHECK: 639 case ACPI_NOTIFY_DEVICE_CHECK:
754 if (!dock_in_progress(ds) && acpi_bus_get_device(ds->handle, 640 if (!dock_in_progress(ds) && acpi_bus_get_device(handle, &ad)) {
755 &tmp)) {
756 begin_dock(ds); 641 begin_dock(ds);
757 dock(ds); 642 dock(ds);
758 if (!dock_present(ds)) { 643 if (!dock_present(ds)) {
@@ -760,12 +645,10 @@ static void dock_notify(acpi_handle handle, u32 event, void *data)
760 complete_dock(ds); 645 complete_dock(ds);
761 break; 646 break;
762 } 647 }
763 atomic_notifier_call_chain(&dock_notifier_list,
764 event, NULL);
765 hotplug_dock_devices(ds, event); 648 hotplug_dock_devices(ds, event);
766 complete_dock(ds); 649 complete_dock(ds);
767 dock_event(ds, event, DOCK_EVENT); 650 dock_event(ds, event, DOCK_EVENT);
768 dock_lock(ds, 1); 651 acpi_evaluate_lck(ds->handle, 1);
769 acpi_update_all_gpes(); 652 acpi_update_all_gpes();
770 break; 653 break;
771 } 654 }
@@ -789,9 +672,8 @@ static void dock_notify(acpi_handle handle, u32 event, void *data)
789} 672}
790 673
791struct dock_data { 674struct dock_data {
792 acpi_handle handle;
793 unsigned long event;
794 struct dock_station *ds; 675 struct dock_station *ds;
676 u32 event;
795}; 677};
796 678
797static void acpi_dock_deferred_cb(void *context) 679static void acpi_dock_deferred_cb(void *context)
@@ -799,52 +681,31 @@ static void acpi_dock_deferred_cb(void *context)
799 struct dock_data *data = context; 681 struct dock_data *data = context;
800 682
801 acpi_scan_lock_acquire(); 683 acpi_scan_lock_acquire();
802 dock_notify(data->handle, data->event, data->ds); 684 dock_notify(data->ds, data->event);
803 acpi_scan_lock_release(); 685 acpi_scan_lock_release();
804 kfree(data); 686 kfree(data);
805} 687}
806 688
807static int acpi_dock_notifier_call(struct notifier_block *this, 689static void dock_notify_handler(acpi_handle handle, u32 event, void *data)
808 unsigned long event, void *data)
809{ 690{
810 struct dock_station *dock_station; 691 struct dock_data *dd;
811 acpi_handle handle = data;
812 692
813 if (event != ACPI_NOTIFY_BUS_CHECK && event != ACPI_NOTIFY_DEVICE_CHECK 693 if (event != ACPI_NOTIFY_BUS_CHECK && event != ACPI_NOTIFY_DEVICE_CHECK
814 && event != ACPI_NOTIFY_EJECT_REQUEST) 694 && event != ACPI_NOTIFY_EJECT_REQUEST)
815 return 0; 695 return;
816
817 acpi_scan_lock_acquire();
818
819 list_for_each_entry(dock_station, &dock_stations, sibling) {
820 if (dock_station->handle == handle) {
821 struct dock_data *dd;
822 acpi_status status;
823
824 dd = kmalloc(sizeof(*dd), GFP_KERNEL);
825 if (!dd)
826 break;
827 696
828 dd->handle = handle; 697 dd = kmalloc(sizeof(*dd), GFP_KERNEL);
829 dd->event = event; 698 if (dd) {
830 dd->ds = dock_station; 699 acpi_status status;
831 status = acpi_os_hotplug_execute(acpi_dock_deferred_cb,
832 dd);
833 if (ACPI_FAILURE(status))
834 kfree(dd);
835 700
836 break; 701 dd->ds = data;
837 } 702 dd->event = event;
703 status = acpi_os_hotplug_execute(acpi_dock_deferred_cb, dd);
704 if (ACPI_FAILURE(status))
705 kfree(dd);
838 } 706 }
839
840 acpi_scan_lock_release();
841 return 0;
842} 707}
843 708
844static struct notifier_block dock_acpi_notifier = {
845 .notifier_call = acpi_dock_notifier_call,
846};
847
848/** 709/**
849 * find_dock_devices - find devices on the dock station 710 * find_dock_devices - find devices on the dock station
850 * @handle: the handle of the device we are examining 711 * @handle: the handle of the device we are examining
@@ -856,29 +717,16 @@ static struct notifier_block dock_acpi_notifier = {
856 * check to see if an object has an _EJD method. If it does, then it 717 * check to see if an object has an _EJD method. If it does, then it
857 * will see if it is dependent on the dock station. 718 * will see if it is dependent on the dock station.
858 */ 719 */
859static acpi_status 720static acpi_status __init find_dock_devices(acpi_handle handle, u32 lvl,
860find_dock_devices(acpi_handle handle, u32 lvl, void *context, void **rv) 721 void *context, void **rv)
861{ 722{
862 acpi_status status;
863 acpi_handle tmp, parent;
864 struct dock_station *ds = context; 723 struct dock_station *ds = context;
724 acpi_handle ejd = NULL;
865 725
866 status = acpi_bus_get_ejd(handle, &tmp); 726 acpi_bus_get_ejd(handle, &ejd);
867 if (ACPI_FAILURE(status)) { 727 if (ejd == ds->handle)
868 /* try the parent device as well */
869 status = acpi_get_parent(handle, &parent);
870 if (ACPI_FAILURE(status))
871 goto fdd_out;
872 /* see if parent is dependent on dock */
873 status = acpi_bus_get_ejd(parent, &tmp);
874 if (ACPI_FAILURE(status))
875 goto fdd_out;
876 }
877
878 if (tmp == ds->handle)
879 add_dock_dependent_device(ds, handle); 728 add_dock_dependent_device(ds, handle);
880 729
881fdd_out:
882 return AE_OK; 730 return AE_OK;
883} 731}
884 732
@@ -988,13 +836,13 @@ static struct attribute_group dock_attribute_group = {
988 */ 836 */
989static int __init dock_add(acpi_handle handle) 837static int __init dock_add(acpi_handle handle)
990{ 838{
991 int ret, id; 839 struct dock_station *dock_station, ds = { NULL, };
992 struct dock_station ds, *dock_station;
993 struct platform_device *dd; 840 struct platform_device *dd;
841 acpi_status status;
842 int ret;
994 843
995 id = dock_station_count; 844 dd = platform_device_register_data(NULL, "dock", dock_station_count,
996 memset(&ds, 0, sizeof(ds)); 845 &ds, sizeof(ds));
997 dd = platform_device_register_data(NULL, "dock", id, &ds, sizeof(ds));
998 if (IS_ERR(dd)) 846 if (IS_ERR(dd))
999 return PTR_ERR(dd); 847 return PTR_ERR(dd);
1000 848
@@ -1004,18 +852,15 @@ static int __init dock_add(acpi_handle handle)
1004 dock_station->dock_device = dd; 852 dock_station->dock_device = dd;
1005 dock_station->last_dock_time = jiffies - HZ; 853 dock_station->last_dock_time = jiffies - HZ;
1006 854
1007 mutex_init(&dock_station->hp_lock);
1008 spin_lock_init(&dock_station->dd_lock);
1009 INIT_LIST_HEAD(&dock_station->sibling); 855 INIT_LIST_HEAD(&dock_station->sibling);
1010 ATOMIC_INIT_NOTIFIER_HEAD(&dock_notifier_list);
1011 INIT_LIST_HEAD(&dock_station->dependent_devices); 856 INIT_LIST_HEAD(&dock_station->dependent_devices);
1012 857
1013 /* we want the dock device to send uevents */ 858 /* we want the dock device to send uevents */
1014 dev_set_uevent_suppress(&dd->dev, 0); 859 dev_set_uevent_suppress(&dd->dev, 0);
1015 860
1016 if (is_dock(handle)) 861 if (acpi_dock_match(handle))
1017 dock_station->flags |= DOCK_IS_DOCK; 862 dock_station->flags |= DOCK_IS_DOCK;
1018 if (is_ata(handle)) 863 if (acpi_ata_match(handle))
1019 dock_station->flags |= DOCK_IS_ATA; 864 dock_station->flags |= DOCK_IS_ATA;
1020 if (is_battery(handle)) 865 if (is_battery(handle))
1021 dock_station->flags |= DOCK_IS_BAT; 866 dock_station->flags |= DOCK_IS_BAT;
@@ -1034,11 +879,19 @@ static int __init dock_add(acpi_handle handle)
1034 if (ret) 879 if (ret)
1035 goto err_rmgroup; 880 goto err_rmgroup;
1036 881
882 status = acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
883 dock_notify_handler, dock_station);
884 if (ACPI_FAILURE(status)) {
885 ret = -ENODEV;
886 goto err_rmgroup;
887 }
888
1037 dock_station_count++; 889 dock_station_count++;
1038 list_add(&dock_station->sibling, &dock_stations); 890 list_add(&dock_station->sibling, &dock_stations);
1039 return 0; 891 return 0;
1040 892
1041err_rmgroup: 893err_rmgroup:
894 remove_dock_dependent_devices(dock_station);
1042 sysfs_remove_group(&dd->dev.kobj, &dock_attribute_group); 895 sysfs_remove_group(&dd->dev.kobj, &dock_attribute_group);
1043err_unregister: 896err_unregister:
1044 platform_device_unregister(dd); 897 platform_device_unregister(dd);
@@ -1055,10 +908,10 @@ err_unregister:
1055 * 908 *
1056 * This is called by acpi_walk_namespace to look for dock stations and bays. 909 * This is called by acpi_walk_namespace to look for dock stations and bays.
1057 */ 910 */
1058static __init acpi_status 911static acpi_status __init
1059find_dock_and_bay(acpi_handle handle, u32 lvl, void *context, void **rv) 912find_dock_and_bay(acpi_handle handle, u32 lvl, void *context, void **rv)
1060{ 913{
1061 if (is_dock(handle) || is_ejectable_bay(handle)) 914 if (acpi_dock_match(handle) || is_ejectable_bay(handle))
1062 dock_add(handle); 915 dock_add(handle);
1063 916
1064 return AE_OK; 917 return AE_OK;
@@ -1078,7 +931,6 @@ void __init acpi_dock_init(void)
1078 return; 931 return;
1079 } 932 }
1080 933
1081 register_acpi_bus_notifier(&dock_acpi_notifier);
1082 pr_info(PREFIX "%s: %d docks/bays found\n", 934 pr_info(PREFIX "%s: %d docks/bays found\n",
1083 ACPI_DOCK_DRIVER_DESCRIPTION, dock_station_count); 935 ACPI_DOCK_DRIVER_DESCRIPTION, dock_station_count);
1084} 936}
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index 80403c1a89f8..8dd2d4dce7c3 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -948,7 +948,7 @@ static int ec_enlarge_storm_threshold(const struct dmi_system_id *id)
948 return 0; 948 return 0;
949} 949}
950 950
951static struct dmi_system_id __initdata ec_dmi_table[] = { 951static struct dmi_system_id ec_dmi_table[] __initdata = {
952 { 952 {
953 ec_skip_dsdt_scan, "Compal JFL92", { 953 ec_skip_dsdt_scan, "Compal JFL92", {
954 DMI_MATCH(DMI_BIOS_VENDOR, "COMPAL"), 954 DMI_MATCH(DMI_BIOS_VENDOR, "COMPAL"),
@@ -1049,10 +1049,8 @@ int __init acpi_ec_ecdt_probe(void)
1049 * which needs it, has fake EC._INI method, so use it as flag. 1049 * which needs it, has fake EC._INI method, so use it as flag.
1050 * Keep boot_ec struct as it will be needed soon. 1050 * Keep boot_ec struct as it will be needed soon.
1051 */ 1051 */
1052 acpi_handle dummy;
1053 if (!dmi_name_in_vendors("ASUS") || 1052 if (!dmi_name_in_vendors("ASUS") ||
1054 ACPI_FAILURE(acpi_get_handle(boot_ec->handle, "_INI", 1053 !acpi_has_method(boot_ec->handle, "_INI"))
1055 &dummy)))
1056 return -ENODEV; 1054 return -ENODEV;
1057 } 1055 }
1058install: 1056install:
diff --git a/drivers/acpi/event.c b/drivers/acpi/event.c
index 1442737cedec..8247fcdde079 100644
--- a/drivers/acpi/event.c
+++ b/drivers/acpi/event.c
@@ -21,100 +21,6 @@
21#define _COMPONENT ACPI_SYSTEM_COMPONENT 21#define _COMPONENT ACPI_SYSTEM_COMPONENT
22ACPI_MODULE_NAME("event"); 22ACPI_MODULE_NAME("event");
23 23
24#ifdef CONFIG_ACPI_PROC_EVENT
25/* Global vars for handling event proc entry */
26static DEFINE_SPINLOCK(acpi_system_event_lock);
27int event_is_open = 0;
28extern struct list_head acpi_bus_event_list;
29extern wait_queue_head_t acpi_bus_event_queue;
30
31static int acpi_system_open_event(struct inode *inode, struct file *file)
32{
33 spin_lock_irq(&acpi_system_event_lock);
34
35 if (event_is_open)
36 goto out_busy;
37
38 event_is_open = 1;
39
40 spin_unlock_irq(&acpi_system_event_lock);
41 return 0;
42
43 out_busy:
44 spin_unlock_irq(&acpi_system_event_lock);
45 return -EBUSY;
46}
47
48static ssize_t
49acpi_system_read_event(struct file *file, char __user * buffer, size_t count,
50 loff_t * ppos)
51{
52 int result = 0;
53 struct acpi_bus_event event;
54 static char str[ACPI_MAX_STRING];
55 static int chars_remaining = 0;
56 static char *ptr;
57
58 if (!chars_remaining) {
59 memset(&event, 0, sizeof(struct acpi_bus_event));
60
61 if ((file->f_flags & O_NONBLOCK)
62 && (list_empty(&acpi_bus_event_list)))
63 return -EAGAIN;
64
65 result = acpi_bus_receive_event(&event);
66 if (result)
67 return result;
68
69 chars_remaining = sprintf(str, "%s %s %08x %08x\n",
70 event.device_class ? event.
71 device_class : "<unknown>",
72 event.bus_id ? event.
73 bus_id : "<unknown>", event.type,
74 event.data);
75 ptr = str;
76 }
77
78 if (chars_remaining < count) {
79 count = chars_remaining;
80 }
81
82 if (copy_to_user(buffer, ptr, count))
83 return -EFAULT;
84
85 *ppos += count;
86 chars_remaining -= count;
87 ptr += count;
88
89 return count;
90}
91
92static int acpi_system_close_event(struct inode *inode, struct file *file)
93{
94 spin_lock_irq(&acpi_system_event_lock);
95 event_is_open = 0;
96 spin_unlock_irq(&acpi_system_event_lock);
97 return 0;
98}
99
100static unsigned int acpi_system_poll_event(struct file *file, poll_table * wait)
101{
102 poll_wait(file, &acpi_bus_event_queue, wait);
103 if (!list_empty(&acpi_bus_event_list))
104 return POLLIN | POLLRDNORM;
105 return 0;
106}
107
108static const struct file_operations acpi_system_event_ops = {
109 .owner = THIS_MODULE,
110 .open = acpi_system_open_event,
111 .read = acpi_system_read_event,
112 .release = acpi_system_close_event,
113 .poll = acpi_system_poll_event,
114 .llseek = default_llseek,
115};
116#endif /* CONFIG_ACPI_PROC_EVENT */
117
118/* ACPI notifier chain */ 24/* ACPI notifier chain */
119static BLOCKING_NOTIFIER_HEAD(acpi_chain_head); 25static BLOCKING_NOTIFIER_HEAD(acpi_chain_head);
120 26
@@ -280,9 +186,6 @@ static int acpi_event_genetlink_init(void)
280 186
281static int __init acpi_event_init(void) 187static int __init acpi_event_init(void)
282{ 188{
283#ifdef CONFIG_ACPI_PROC_EVENT
284 struct proc_dir_entry *entry;
285#endif
286 int error = 0; 189 int error = 0;
287 190
288 if (acpi_disabled) 191 if (acpi_disabled)
@@ -293,15 +196,6 @@ static int __init acpi_event_init(void)
293 if (error) 196 if (error)
294 printk(KERN_WARNING PREFIX 197 printk(KERN_WARNING PREFIX
295 "Failed to create genetlink family for ACPI event\n"); 198 "Failed to create genetlink family for ACPI event\n");
296
297#ifdef CONFIG_ACPI_PROC_EVENT
298 /* 'event' [R] */
299 entry = proc_create("event", S_IRUSR, acpi_root_dir,
300 &acpi_system_event_ops);
301 if (!entry)
302 return -ENODEV;
303#endif
304
305 return 0; 199 return 0;
306} 200}
307 201
diff --git a/drivers/acpi/fan.c b/drivers/acpi/fan.c
index 5b02a0aa540c..41ade6570bc0 100644
--- a/drivers/acpi/fan.c
+++ b/drivers/acpi/fan.c
@@ -93,7 +93,7 @@ static int fan_get_cur_state(struct thermal_cooling_device *cdev, unsigned long
93 if (result) 93 if (result)
94 return result; 94 return result;
95 95
96 *state = (acpi_state == ACPI_STATE_D3 ? 0 : 96 *state = (acpi_state == ACPI_STATE_D3_COLD ? 0 :
97 (acpi_state == ACPI_STATE_D0 ? 1 : -1)); 97 (acpi_state == ACPI_STATE_D0 ? 1 : -1));
98 return 0; 98 return 0;
99} 99}
@@ -108,7 +108,7 @@ fan_set_cur_state(struct thermal_cooling_device *cdev, unsigned long state)
108 return -EINVAL; 108 return -EINVAL;
109 109
110 result = acpi_bus_set_power(device->handle, 110 result = acpi_bus_set_power(device->handle,
111 state ? ACPI_STATE_D0 : ACPI_STATE_D3); 111 state ? ACPI_STATE_D0 : ACPI_STATE_D3_COLD);
112 112
113 return result; 113 return result;
114} 114}
diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h
index 5da44e81dd4d..20f423337e1f 100644
--- a/drivers/acpi/internal.h
+++ b/drivers/acpi/internal.h
@@ -23,6 +23,7 @@
23 23
24#define PREFIX "ACPI: " 24#define PREFIX "ACPI: "
25 25
26acpi_status acpi_os_initialize1(void);
26int init_acpi_device_notify(void); 27int init_acpi_device_notify(void);
27int acpi_scan_init(void); 28int acpi_scan_init(void);
28#ifdef CONFIG_ACPI_PCI_SLOT 29#ifdef CONFIG_ACPI_PCI_SLOT
diff --git a/drivers/acpi/numa.c b/drivers/acpi/numa.c
index 33e609f63585..2e82e5d76930 100644
--- a/drivers/acpi/numa.c
+++ b/drivers/acpi/numa.c
@@ -159,7 +159,7 @@ acpi_table_print_srat_entry(struct acpi_subtable_header *header)
159 * distance than the others. 159 * distance than the others.
160 * Do some quick checks here and only use the SLIT if it passes. 160 * Do some quick checks here and only use the SLIT if it passes.
161 */ 161 */
162static __init int slit_valid(struct acpi_table_slit *slit) 162static int __init slit_valid(struct acpi_table_slit *slit)
163{ 163{
164 int i, j; 164 int i, j;
165 int d = slit->locality_count; 165 int d = slit->locality_count;
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index 6ab2c3505520..e5f416c7f66e 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -52,6 +52,7 @@
52#include <acpi/acpi.h> 52#include <acpi/acpi.h>
53#include <acpi/acpi_bus.h> 53#include <acpi/acpi_bus.h>
54#include <acpi/processor.h> 54#include <acpi/processor.h>
55#include "internal.h"
55 56
56#define _COMPONENT ACPI_OS_SERVICES 57#define _COMPONENT ACPI_OS_SERVICES
57ACPI_MODULE_NAME("osl"); 58ACPI_MODULE_NAME("osl");
@@ -79,6 +80,8 @@ extern char line_buf[80];
79 80
80static int (*__acpi_os_prepare_sleep)(u8 sleep_state, u32 pm1a_ctrl, 81static int (*__acpi_os_prepare_sleep)(u8 sleep_state, u32 pm1a_ctrl,
81 u32 pm1b_ctrl); 82 u32 pm1b_ctrl);
83static int (*__acpi_os_prepare_extended_sleep)(u8 sleep_state, u32 val_a,
84 u32 val_b);
82 85
83static acpi_osd_handler acpi_irq_handler; 86static acpi_osd_handler acpi_irq_handler;
84static void *acpi_irq_context; 87static void *acpi_irq_context;
@@ -140,7 +143,8 @@ static struct osi_linux {
140 unsigned int enable:1; 143 unsigned int enable:1;
141 unsigned int dmi:1; 144 unsigned int dmi:1;
142 unsigned int cmdline:1; 145 unsigned int cmdline:1;
143} osi_linux = {0, 0, 0}; 146 unsigned int default_disabling:1;
147} osi_linux = {0, 0, 0, 0};
144 148
145static u32 acpi_osi_handler(acpi_string interface, u32 supported) 149static u32 acpi_osi_handler(acpi_string interface, u32 supported)
146{ 150{
@@ -563,10 +567,6 @@ static const char * const table_sigs[] = {
563 ACPI_SIG_WDRT, ACPI_SIG_DSDT, ACPI_SIG_FADT, ACPI_SIG_PSDT, 567 ACPI_SIG_WDRT, ACPI_SIG_DSDT, ACPI_SIG_FADT, ACPI_SIG_PSDT,
564 ACPI_SIG_RSDT, ACPI_SIG_XSDT, ACPI_SIG_SSDT, NULL }; 568 ACPI_SIG_RSDT, ACPI_SIG_XSDT, ACPI_SIG_SSDT, NULL };
565 569
566/* Non-fatal errors: Affected tables/files are ignored */
567#define INVALID_TABLE(x, path, name) \
568 { pr_err("ACPI OVERRIDE: " x " [%s%s]\n", path, name); continue; }
569
570#define ACPI_HEADER_SIZE sizeof(struct acpi_table_header) 570#define ACPI_HEADER_SIZE sizeof(struct acpi_table_header)
571 571
572/* Must not increase 10 or needs code modification below */ 572/* Must not increase 10 or needs code modification below */
@@ -593,9 +593,11 @@ void __init acpi_initrd_override(void *data, size_t size)
593 data += offset; 593 data += offset;
594 size -= offset; 594 size -= offset;
595 595
596 if (file.size < sizeof(struct acpi_table_header)) 596 if (file.size < sizeof(struct acpi_table_header)) {
597 INVALID_TABLE("Table smaller than ACPI header", 597 pr_err("ACPI OVERRIDE: Table smaller than ACPI header [%s%s]\n",
598 cpio_path, file.name); 598 cpio_path, file.name);
599 continue;
600 }
599 601
600 table = file.data; 602 table = file.data;
601 603
@@ -603,15 +605,21 @@ void __init acpi_initrd_override(void *data, size_t size)
603 if (!memcmp(table->signature, table_sigs[sig], 4)) 605 if (!memcmp(table->signature, table_sigs[sig], 4))
604 break; 606 break;
605 607
606 if (!table_sigs[sig]) 608 if (!table_sigs[sig]) {
607 INVALID_TABLE("Unknown signature", 609 pr_err("ACPI OVERRIDE: Unknown signature [%s%s]\n",
608 cpio_path, file.name); 610 cpio_path, file.name);
609 if (file.size != table->length) 611 continue;
610 INVALID_TABLE("File length does not match table length", 612 }
611 cpio_path, file.name); 613 if (file.size != table->length) {
612 if (acpi_table_checksum(file.data, table->length)) 614 pr_err("ACPI OVERRIDE: File length does not match table length [%s%s]\n",
613 INVALID_TABLE("Bad table checksum", 615 cpio_path, file.name);
614 cpio_path, file.name); 616 continue;
617 }
618 if (acpi_table_checksum(file.data, table->length)) {
619 pr_err("ACPI OVERRIDE: Bad table checksum [%s%s]\n",
620 cpio_path, file.name);
621 continue;
622 }
615 623
616 pr_info("%4.4s ACPI table found in initrd [%s%s][0x%x]\n", 624 pr_info("%4.4s ACPI table found in initrd [%s%s][0x%x]\n",
617 table->signature, cpio_path, file.name, table->length); 625 table->signature, cpio_path, file.name, table->length);
@@ -1351,8 +1359,8 @@ struct osi_setup_entry {
1351 bool enable; 1359 bool enable;
1352}; 1360};
1353 1361
1354static struct osi_setup_entry __initdata 1362static struct osi_setup_entry
1355 osi_setup_entries[OSI_STRING_ENTRIES_MAX] = { 1363 osi_setup_entries[OSI_STRING_ENTRIES_MAX] __initdata = {
1356 {"Module Device", true}, 1364 {"Module Device", true},
1357 {"Processor Device", true}, 1365 {"Processor Device", true},
1358 {"3.0 _SCP Extensions", true}, 1366 {"3.0 _SCP Extensions", true},
@@ -1376,6 +1384,17 @@ void __init acpi_osi_setup(char *str)
1376 1384
1377 if (*str == '!') { 1385 if (*str == '!') {
1378 str++; 1386 str++;
1387 if (*str == '\0') {
1388 osi_linux.default_disabling = 1;
1389 return;
1390 } else if (*str == '*') {
1391 acpi_update_interfaces(ACPI_DISABLE_ALL_STRINGS);
1392 for (i = 0; i < OSI_STRING_ENTRIES_MAX; i++) {
1393 osi = &osi_setup_entries[i];
1394 osi->enable = false;
1395 }
1396 return;
1397 }
1379 enable = false; 1398 enable = false;
1380 } 1399 }
1381 1400
@@ -1441,6 +1460,13 @@ static void __init acpi_osi_setup_late(void)
1441 int i; 1460 int i;
1442 acpi_status status; 1461 acpi_status status;
1443 1462
1463 if (osi_linux.default_disabling) {
1464 status = acpi_update_interfaces(ACPI_DISABLE_ALL_VENDOR_STRINGS);
1465
1466 if (ACPI_SUCCESS(status))
1467 printk(KERN_INFO PREFIX "Disabled all _OSI OS vendors\n");
1468 }
1469
1444 for (i = 0; i < OSI_STRING_ENTRIES_MAX; i++) { 1470 for (i = 0; i < OSI_STRING_ENTRIES_MAX; i++) {
1445 osi = &osi_setup_entries[i]; 1471 osi = &osi_setup_entries[i];
1446 str = osi->string; 1472 str = osi->string;
@@ -1779,6 +1805,28 @@ void acpi_os_set_prepare_sleep(int (*func)(u8 sleep_state,
1779 __acpi_os_prepare_sleep = func; 1805 __acpi_os_prepare_sleep = func;
1780} 1806}
1781 1807
1808acpi_status acpi_os_prepare_extended_sleep(u8 sleep_state, u32 val_a,
1809 u32 val_b)
1810{
1811 int rc = 0;
1812 if (__acpi_os_prepare_extended_sleep)
1813 rc = __acpi_os_prepare_extended_sleep(sleep_state,
1814 val_a, val_b);
1815 if (rc < 0)
1816 return AE_ERROR;
1817 else if (rc > 0)
1818 return AE_CTRL_SKIP;
1819
1820 return AE_OK;
1821}
1822
1823void acpi_os_set_prepare_extended_sleep(int (*func)(u8 sleep_state,
1824 u32 val_a, u32 val_b))
1825{
1826 __acpi_os_prepare_extended_sleep = func;
1827}
1828
1829
1782void alloc_acpi_hp_work(acpi_handle handle, u32 type, void *context, 1830void alloc_acpi_hp_work(acpi_handle handle, u32 type, void *context,
1783 void (*func)(struct work_struct *work)) 1831 void (*func)(struct work_struct *work))
1784{ 1832{
diff --git a/drivers/acpi/pci_slot.c b/drivers/acpi/pci_slot.c
index 033d1179bdb5..d678a180ca2a 100644
--- a/drivers/acpi/pci_slot.c
+++ b/drivers/acpi/pci_slot.c
@@ -159,12 +159,16 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv)
159 return AE_OK; 159 return AE_OK;
160} 160}
161 161
162void acpi_pci_slot_enumerate(struct pci_bus *bus, acpi_handle handle) 162void acpi_pci_slot_enumerate(struct pci_bus *bus)
163{ 163{
164 mutex_lock(&slot_list_lock); 164 acpi_handle handle = ACPI_HANDLE(bus->bridge);
165 acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, 1, 165
166 register_slot, NULL, bus, NULL); 166 if (handle) {
167 mutex_unlock(&slot_list_lock); 167 mutex_lock(&slot_list_lock);
168 acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, 1,
169 register_slot, NULL, bus, NULL);
170 mutex_unlock(&slot_list_lock);
171 }
168} 172}
169 173
170void acpi_pci_slot_remove(struct pci_bus *bus) 174void acpi_pci_slot_remove(struct pci_bus *bus)
diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c
index 5c28c894c0fc..0dbe5cdf3396 100644
--- a/drivers/acpi/power.c
+++ b/drivers/acpi/power.c
@@ -637,9 +637,7 @@ int acpi_device_sleep_wake(struct acpi_device *dev,
637 } 637 }
638 638
639 /* Execute _PSW */ 639 /* Execute _PSW */
640 arg_list.count = 1; 640 status = acpi_execute_simple_method(dev->handle, "_PSW", enable);
641 in_arg[0].integer.value = enable;
642 status = acpi_evaluate_object(dev->handle, "_PSW", &arg_list, NULL);
643 if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) { 641 if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) {
644 printk(KERN_ERR PREFIX "_PSW execution failed\n"); 642 printk(KERN_ERR PREFIX "_PSW execution failed\n");
645 dev->wakeup.flags.valid = 0; 643 dev->wakeup.flags.valid = 0;
@@ -786,7 +784,7 @@ int acpi_power_get_inferred_state(struct acpi_device *device, int *state)
786 } 784 }
787 } 785 }
788 786
789 *state = ACPI_STATE_D3; 787 *state = ACPI_STATE_D3_COLD;
790 return 0; 788 return 0;
791} 789}
792 790
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
index a5e9f4a5b281..cf34d903f4fb 100644
--- a/drivers/acpi/processor_core.c
+++ b/drivers/acpi/processor_core.c
@@ -28,7 +28,7 @@ static int __init set_no_mwait(const struct dmi_system_id *id)
28 return 0; 28 return 0;
29} 29}
30 30
31static struct dmi_system_id __initdata processor_idle_dmi_table[] = { 31static struct dmi_system_id processor_idle_dmi_table[] __initdata = {
32 { 32 {
33 set_no_mwait, "Extensa 5220", { 33 set_no_mwait, "Extensa 5220", {
34 DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"), 34 DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"),
diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c
index 870eaf5fa547..bd11ef93b0ce 100644
--- a/drivers/acpi/processor_driver.c
+++ b/drivers/acpi/processor_driver.c
@@ -91,21 +91,17 @@ static void acpi_processor_notify(acpi_handle handle, u32 event, void *data)
91 acpi_processor_ppc_has_changed(pr, 1); 91 acpi_processor_ppc_has_changed(pr, 1);
92 if (saved == pr->performance_platform_limit) 92 if (saved == pr->performance_platform_limit)
93 break; 93 break;
94 acpi_bus_generate_proc_event(device, event,
95 pr->performance_platform_limit);
96 acpi_bus_generate_netlink_event(device->pnp.device_class, 94 acpi_bus_generate_netlink_event(device->pnp.device_class,
97 dev_name(&device->dev), event, 95 dev_name(&device->dev), event,
98 pr->performance_platform_limit); 96 pr->performance_platform_limit);
99 break; 97 break;
100 case ACPI_PROCESSOR_NOTIFY_POWER: 98 case ACPI_PROCESSOR_NOTIFY_POWER:
101 acpi_processor_cst_has_changed(pr); 99 acpi_processor_cst_has_changed(pr);
102 acpi_bus_generate_proc_event(device, event, 0);
103 acpi_bus_generate_netlink_event(device->pnp.device_class, 100 acpi_bus_generate_netlink_event(device->pnp.device_class,
104 dev_name(&device->dev), event, 0); 101 dev_name(&device->dev), event, 0);
105 break; 102 break;
106 case ACPI_PROCESSOR_NOTIFY_THROTTLING: 103 case ACPI_PROCESSOR_NOTIFY_THROTTLING:
107 acpi_processor_tstate_has_changed(pr); 104 acpi_processor_tstate_has_changed(pr);
108 acpi_bus_generate_proc_event(device, event, 0);
109 acpi_bus_generate_netlink_event(device->pnp.device_class, 105 acpi_bus_generate_netlink_event(device->pnp.device_class,
110 dev_name(&device->dev), event, 0); 106 dev_name(&device->dev), event, 0);
111 break; 107 break;
diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c
index 1e9732d809bf..51d7948611da 100644
--- a/drivers/acpi/processor_perflib.c
+++ b/drivers/acpi/processor_perflib.c
@@ -164,17 +164,12 @@ static void acpi_processor_ppc_ost(acpi_handle handle, int status)
164 {.type = ACPI_TYPE_INTEGER,}, 164 {.type = ACPI_TYPE_INTEGER,},
165 }; 165 };
166 struct acpi_object_list arg_list = {2, params}; 166 struct acpi_object_list arg_list = {2, params};
167 acpi_handle temp;
168 167
169 params[0].integer.value = ACPI_PROCESSOR_NOTIFY_PERFORMANCE; 168 if (acpi_has_method(handle, "_OST")) {
170 params[1].integer.value = status; 169 params[0].integer.value = ACPI_PROCESSOR_NOTIFY_PERFORMANCE;
171 170 params[1].integer.value = status;
172 /* when there is no _OST , skip it */ 171 acpi_evaluate_object(handle, "_OST", &arg_list, NULL);
173 if (ACPI_FAILURE(acpi_get_handle(handle, "_OST", &temp))) 172 }
174 return;
175
176 acpi_evaluate_object(handle, "_OST", &arg_list, NULL);
177 return;
178} 173}
179 174
180int acpi_processor_ppc_has_changed(struct acpi_processor *pr, int event_flag) 175int acpi_processor_ppc_has_changed(struct acpi_processor *pr, int event_flag)
@@ -468,14 +463,11 @@ static int acpi_processor_get_performance_states(struct acpi_processor *pr)
468int acpi_processor_get_performance_info(struct acpi_processor *pr) 463int acpi_processor_get_performance_info(struct acpi_processor *pr)
469{ 464{
470 int result = 0; 465 int result = 0;
471 acpi_status status = AE_OK;
472 acpi_handle handle = NULL;
473 466
474 if (!pr || !pr->performance || !pr->handle) 467 if (!pr || !pr->performance || !pr->handle)
475 return -EINVAL; 468 return -EINVAL;
476 469
477 status = acpi_get_handle(pr->handle, "_PCT", &handle); 470 if (!acpi_has_method(pr->handle, "_PCT")) {
478 if (ACPI_FAILURE(status)) {
479 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 471 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
480 "ACPI-based processor performance control unavailable\n")); 472 "ACPI-based processor performance control unavailable\n"));
481 return -ENODEV; 473 return -ENODEV;
@@ -501,7 +493,7 @@ int acpi_processor_get_performance_info(struct acpi_processor *pr)
501 */ 493 */
502 update_bios: 494 update_bios:
503#ifdef CONFIG_X86 495#ifdef CONFIG_X86
504 if (ACPI_SUCCESS(acpi_get_handle(pr->handle, "_PPC", &handle))){ 496 if (acpi_has_method(pr->handle, "_PPC")) {
505 if(boot_cpu_has(X86_FEATURE_EST)) 497 if(boot_cpu_has(X86_FEATURE_EST))
506 printk(KERN_WARNING FW_BUG "BIOS needs update for CPU " 498 printk(KERN_WARNING FW_BUG "BIOS needs update for CPU "
507 "frequency support\n"); 499 "frequency support\n");
diff --git a/drivers/acpi/resource.c b/drivers/acpi/resource.c
index 3322b47ab7ca..b7201fc6f1e1 100644
--- a/drivers/acpi/resource.c
+++ b/drivers/acpi/resource.c
@@ -505,14 +505,12 @@ int acpi_dev_get_resources(struct acpi_device *adev, struct list_head *list,
505 void *preproc_data) 505 void *preproc_data)
506{ 506{
507 struct res_proc_context c; 507 struct res_proc_context c;
508 acpi_handle not_used;
509 acpi_status status; 508 acpi_status status;
510 509
511 if (!adev || !adev->handle || !list_empty(list)) 510 if (!adev || !adev->handle || !list_empty(list))
512 return -EINVAL; 511 return -EINVAL;
513 512
514 status = acpi_get_handle(adev->handle, METHOD_NAME__CRS, &not_used); 513 if (!acpi_has_method(adev->handle, METHOD_NAME__CRS))
515 if (ACPI_FAILURE(status))
516 return 0; 514 return 0;
517 515
518 c.list = list; 516 c.list = list;
diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c
index b6241eeb1132..aef7e1cd1e5d 100644
--- a/drivers/acpi/sbs.c
+++ b/drivers/acpi/sbs.c
@@ -873,14 +873,9 @@ static void acpi_sbs_callback(void *context)
873 u8 saved_charger_state = sbs->charger_present; 873 u8 saved_charger_state = sbs->charger_present;
874 u8 saved_battery_state; 874 u8 saved_battery_state;
875 acpi_ac_get_present(sbs); 875 acpi_ac_get_present(sbs);
876 if (sbs->charger_present != saved_charger_state) { 876 if (sbs->charger_present != saved_charger_state)
877#ifdef CONFIG_ACPI_PROC_EVENT
878 acpi_bus_generate_proc_event4(ACPI_AC_CLASS, ACPI_AC_DIR_NAME,
879 ACPI_SBS_NOTIFY_STATUS,
880 sbs->charger_present);
881#endif
882 kobject_uevent(&sbs->charger.dev->kobj, KOBJ_CHANGE); 877 kobject_uevent(&sbs->charger.dev->kobj, KOBJ_CHANGE);
883 } 878
884 if (sbs->manager_present) { 879 if (sbs->manager_present) {
885 for (id = 0; id < MAX_SBS_BAT; ++id) { 880 for (id = 0; id < MAX_SBS_BAT; ++id) {
886 if (!(sbs->batteries_supported & (1 << id))) 881 if (!(sbs->batteries_supported & (1 << id)))
@@ -890,12 +885,6 @@ static void acpi_sbs_callback(void *context)
890 acpi_battery_read(bat); 885 acpi_battery_read(bat);
891 if (saved_battery_state == bat->present) 886 if (saved_battery_state == bat->present)
892 continue; 887 continue;
893#ifdef CONFIG_ACPI_PROC_EVENT
894 acpi_bus_generate_proc_event4(ACPI_BATTERY_CLASS,
895 bat->name,
896 ACPI_SBS_NOTIFY_STATUS,
897 bat->present);
898#endif
899 kobject_uevent(&bat->bat.dev->kobj, KOBJ_CHANGE); 888 kobject_uevent(&bat->bat.dev->kobj, KOBJ_CHANGE);
900 } 889 }
901 } 890 }
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 8a46c924effd..e76365136ba3 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -193,9 +193,6 @@ static acpi_status acpi_bus_online_companions(acpi_handle handle, u32 lvl,
193static int acpi_scan_hot_remove(struct acpi_device *device) 193static int acpi_scan_hot_remove(struct acpi_device *device)
194{ 194{
195 acpi_handle handle = device->handle; 195 acpi_handle handle = device->handle;
196 acpi_handle not_used;
197 struct acpi_object_list arg_list;
198 union acpi_object arg;
199 struct device *errdev; 196 struct device *errdev;
200 acpi_status status; 197 acpi_status status;
201 unsigned long long sta; 198 unsigned long long sta;
@@ -258,32 +255,15 @@ static int acpi_scan_hot_remove(struct acpi_device *device)
258 put_device(&device->dev); 255 put_device(&device->dev);
259 device = NULL; 256 device = NULL;
260 257
261 if (ACPI_SUCCESS(acpi_get_handle(handle, "_LCK", &not_used))) { 258 acpi_evaluate_lck(handle, 0);
262 arg_list.count = 1;
263 arg_list.pointer = &arg;
264 arg.type = ACPI_TYPE_INTEGER;
265 arg.integer.value = 0;
266 acpi_evaluate_object(handle, "_LCK", &arg_list, NULL);
267 }
268
269 arg_list.count = 1;
270 arg_list.pointer = &arg;
271 arg.type = ACPI_TYPE_INTEGER;
272 arg.integer.value = 1;
273
274 /* 259 /*
275 * TBD: _EJD support. 260 * TBD: _EJD support.
276 */ 261 */
277 status = acpi_evaluate_object(handle, "_EJ0", &arg_list, NULL); 262 status = acpi_evaluate_ej0(handle);
278 if (ACPI_FAILURE(status)) { 263 if (status == AE_NOT_FOUND)
279 if (status == AE_NOT_FOUND) { 264 return -ENODEV;
280 return -ENODEV; 265 else if (ACPI_FAILURE(status))
281 } else { 266 return -EIO;
282 acpi_handle_warn(handle, "Eject failed (0x%x)\n",
283 status);
284 return -EIO;
285 }
286 }
287 267
288 /* 268 /*
289 * Verify if eject was indeed successful. If not, log an error 269 * Verify if eject was indeed successful. If not, log an error
@@ -654,7 +634,6 @@ static int acpi_device_setup_files(struct acpi_device *dev)
654{ 634{
655 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; 635 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
656 acpi_status status; 636 acpi_status status;
657 acpi_handle temp;
658 unsigned long long sun; 637 unsigned long long sun;
659 int result = 0; 638 int result = 0;
660 639
@@ -680,8 +659,7 @@ static int acpi_device_setup_files(struct acpi_device *dev)
680 /* 659 /*
681 * If device has _STR, 'description' file is created 660 * If device has _STR, 'description' file is created
682 */ 661 */
683 status = acpi_get_handle(dev->handle, "_STR", &temp); 662 if (acpi_has_method(dev->handle, "_STR")) {
684 if (ACPI_SUCCESS(status)) {
685 status = acpi_evaluate_object(dev->handle, "_STR", 663 status = acpi_evaluate_object(dev->handle, "_STR",
686 NULL, &buffer); 664 NULL, &buffer);
687 if (ACPI_FAILURE(status)) 665 if (ACPI_FAILURE(status))
@@ -711,8 +689,7 @@ static int acpi_device_setup_files(struct acpi_device *dev)
711 * If device has _EJ0, 'eject' file is created that is used to trigger 689 * If device has _EJ0, 'eject' file is created that is used to trigger
712 * hot-removal function from userland. 690 * hot-removal function from userland.
713 */ 691 */
714 status = acpi_get_handle(dev->handle, "_EJ0", &temp); 692 if (acpi_has_method(dev->handle, "_EJ0")) {
715 if (ACPI_SUCCESS(status)) {
716 result = device_create_file(&dev->dev, &dev_attr_eject); 693 result = device_create_file(&dev->dev, &dev_attr_eject);
717 if (result) 694 if (result)
718 return result; 695 return result;
@@ -734,9 +711,6 @@ end:
734 711
735static void acpi_device_remove_files(struct acpi_device *dev) 712static void acpi_device_remove_files(struct acpi_device *dev)
736{ 713{
737 acpi_status status;
738 acpi_handle temp;
739
740 if (dev->flags.power_manageable) { 714 if (dev->flags.power_manageable) {
741 device_remove_file(&dev->dev, &dev_attr_power_state); 715 device_remove_file(&dev->dev, &dev_attr_power_state);
742 if (dev->power.flags.power_resources) 716 if (dev->power.flags.power_resources)
@@ -747,20 +721,17 @@ static void acpi_device_remove_files(struct acpi_device *dev)
747 /* 721 /*
748 * If device has _STR, remove 'description' file 722 * If device has _STR, remove 'description' file
749 */ 723 */
750 status = acpi_get_handle(dev->handle, "_STR", &temp); 724 if (acpi_has_method(dev->handle, "_STR")) {
751 if (ACPI_SUCCESS(status)) {
752 kfree(dev->pnp.str_obj); 725 kfree(dev->pnp.str_obj);
753 device_remove_file(&dev->dev, &dev_attr_description); 726 device_remove_file(&dev->dev, &dev_attr_description);
754 } 727 }
755 /* 728 /*
756 * If device has _EJ0, remove 'eject' file. 729 * If device has _EJ0, remove 'eject' file.
757 */ 730 */
758 status = acpi_get_handle(dev->handle, "_EJ0", &temp); 731 if (acpi_has_method(dev->handle, "_EJ0"))
759 if (ACPI_SUCCESS(status))
760 device_remove_file(&dev->dev, &dev_attr_eject); 732 device_remove_file(&dev->dev, &dev_attr_eject);
761 733
762 status = acpi_get_handle(dev->handle, "_SUN", &temp); 734 if (acpi_has_method(dev->handle, "_SUN"))
763 if (ACPI_SUCCESS(status))
764 device_remove_file(&dev->dev, &dev_attr_sun); 735 device_remove_file(&dev->dev, &dev_attr_sun);
765 736
766 if (dev->pnp.unique_id) 737 if (dev->pnp.unique_id)
@@ -999,6 +970,28 @@ struct bus_type acpi_bus_type = {
999 .uevent = acpi_device_uevent, 970 .uevent = acpi_device_uevent,
1000}; 971};
1001 972
973static void acpi_bus_data_handler(acpi_handle handle, void *context)
974{
975 /* Intentionally empty. */
976}
977
978int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device)
979{
980 acpi_status status;
981
982 if (!device)
983 return -EINVAL;
984
985 status = acpi_get_data(handle, acpi_bus_data_handler, (void **)device);
986 if (ACPI_FAILURE(status) || !*device) {
987 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No context for object [%p]\n",
988 handle));
989 return -ENODEV;
990 }
991 return 0;
992}
993EXPORT_SYMBOL_GPL(acpi_bus_get_device);
994
1002int acpi_device_add(struct acpi_device *device, 995int acpi_device_add(struct acpi_device *device,
1003 void (*release)(struct device *)) 996 void (*release)(struct device *))
1004{ 997{
@@ -1210,14 +1203,6 @@ acpi_bus_get_ejd(acpi_handle handle, acpi_handle *ejd)
1210} 1203}
1211EXPORT_SYMBOL_GPL(acpi_bus_get_ejd); 1204EXPORT_SYMBOL_GPL(acpi_bus_get_ejd);
1212 1205
1213void acpi_bus_data_handler(acpi_handle handle, void *context)
1214{
1215
1216 /* TBD */
1217
1218 return;
1219}
1220
1221static int acpi_bus_extract_wakeup_device_power_package(acpi_handle handle, 1206static int acpi_bus_extract_wakeup_device_power_package(acpi_handle handle,
1222 struct acpi_device_wakeup *wakeup) 1207 struct acpi_device_wakeup *wakeup)
1223{ 1208{
@@ -1336,13 +1321,10 @@ static void acpi_bus_set_run_wake_flags(struct acpi_device *device)
1336 1321
1337static void acpi_bus_get_wakeup_device_flags(struct acpi_device *device) 1322static void acpi_bus_get_wakeup_device_flags(struct acpi_device *device)
1338{ 1323{
1339 acpi_handle temp;
1340 acpi_status status = 0;
1341 int err; 1324 int err;
1342 1325
1343 /* Presence of _PRW indicates wake capable */ 1326 /* Presence of _PRW indicates wake capable */
1344 status = acpi_get_handle(device->handle, "_PRW", &temp); 1327 if (!acpi_has_method(device->handle, "_PRW"))
1345 if (ACPI_FAILURE(status))
1346 return; 1328 return;
1347 1329
1348 err = acpi_bus_extract_wakeup_device_power_package(device->handle, 1330 err = acpi_bus_extract_wakeup_device_power_package(device->handle,
@@ -1372,7 +1354,6 @@ static void acpi_bus_init_power_state(struct acpi_device *device, int state)
1372 struct acpi_device_power_state *ps = &device->power.states[state]; 1354 struct acpi_device_power_state *ps = &device->power.states[state];
1373 char pathname[5] = { '_', 'P', 'R', '0' + state, '\0' }; 1355 char pathname[5] = { '_', 'P', 'R', '0' + state, '\0' };
1374 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 1356 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
1375 acpi_handle handle;
1376 acpi_status status; 1357 acpi_status status;
1377 1358
1378 INIT_LIST_HEAD(&ps->resources); 1359 INIT_LIST_HEAD(&ps->resources);
@@ -1395,8 +1376,7 @@ static void acpi_bus_init_power_state(struct acpi_device *device, int state)
1395 1376
1396 /* Evaluate "_PSx" to see if we can do explicit sets */ 1377 /* Evaluate "_PSx" to see if we can do explicit sets */
1397 pathname[2] = 'S'; 1378 pathname[2] = 'S';
1398 status = acpi_get_handle(device->handle, pathname, &handle); 1379 if (acpi_has_method(device->handle, pathname))
1399 if (ACPI_SUCCESS(status))
1400 ps->flags.explicit_set = 1; 1380 ps->flags.explicit_set = 1;
1401 1381
1402 /* 1382 /*
@@ -1415,28 +1395,21 @@ static void acpi_bus_init_power_state(struct acpi_device *device, int state)
1415 1395
1416static void acpi_bus_get_power_flags(struct acpi_device *device) 1396static void acpi_bus_get_power_flags(struct acpi_device *device)
1417{ 1397{
1418 acpi_status status;
1419 acpi_handle handle;
1420 u32 i; 1398 u32 i;
1421 1399
1422 /* Presence of _PS0|_PR0 indicates 'power manageable' */ 1400 /* Presence of _PS0|_PR0 indicates 'power manageable' */
1423 status = acpi_get_handle(device->handle, "_PS0", &handle); 1401 if (!acpi_has_method(device->handle, "_PS0") &&
1424 if (ACPI_FAILURE(status)) { 1402 !acpi_has_method(device->handle, "_PR0"))
1425 status = acpi_get_handle(device->handle, "_PR0", &handle); 1403 return;
1426 if (ACPI_FAILURE(status))
1427 return;
1428 }
1429 1404
1430 device->flags.power_manageable = 1; 1405 device->flags.power_manageable = 1;
1431 1406
1432 /* 1407 /*
1433 * Power Management Flags 1408 * Power Management Flags
1434 */ 1409 */
1435 status = acpi_get_handle(device->handle, "_PSC", &handle); 1410 if (acpi_has_method(device->handle, "_PSC"))
1436 if (ACPI_SUCCESS(status))
1437 device->power.flags.explicit_get = 1; 1411 device->power.flags.explicit_get = 1;
1438 status = acpi_get_handle(device->handle, "_IRC", &handle); 1412 if (acpi_has_method(device->handle, "_IRC"))
1439 if (ACPI_SUCCESS(status))
1440 device->power.flags.inrush_current = 1; 1413 device->power.flags.inrush_current = 1;
1441 1414
1442 /* 1415 /*
@@ -1450,8 +1423,8 @@ static void acpi_bus_get_power_flags(struct acpi_device *device)
1450 /* Set defaults for D0 and D3 states (always valid) */ 1423 /* Set defaults for D0 and D3 states (always valid) */
1451 device->power.states[ACPI_STATE_D0].flags.valid = 1; 1424 device->power.states[ACPI_STATE_D0].flags.valid = 1;
1452 device->power.states[ACPI_STATE_D0].power = 100; 1425 device->power.states[ACPI_STATE_D0].power = 100;
1453 device->power.states[ACPI_STATE_D3].flags.valid = 1; 1426 device->power.states[ACPI_STATE_D3_COLD].flags.valid = 1;
1454 device->power.states[ACPI_STATE_D3].power = 0; 1427 device->power.states[ACPI_STATE_D3_COLD].power = 0;
1455 1428
1456 /* Set D3cold's explicit_set flag if _PS3 exists. */ 1429 /* Set D3cold's explicit_set flag if _PS3 exists. */
1457 if (device->power.states[ACPI_STATE_D3_HOT].flags.explicit_set) 1430 if (device->power.states[ACPI_STATE_D3_HOT].flags.explicit_set)
@@ -1470,28 +1443,18 @@ static void acpi_bus_get_power_flags(struct acpi_device *device)
1470 1443
1471static void acpi_bus_get_flags(struct acpi_device *device) 1444static void acpi_bus_get_flags(struct acpi_device *device)
1472{ 1445{
1473 acpi_status status = AE_OK;
1474 acpi_handle temp = NULL;
1475
1476 /* Presence of _STA indicates 'dynamic_status' */ 1446 /* Presence of _STA indicates 'dynamic_status' */
1477 status = acpi_get_handle(device->handle, "_STA", &temp); 1447 if (acpi_has_method(device->handle, "_STA"))
1478 if (ACPI_SUCCESS(status))
1479 device->flags.dynamic_status = 1; 1448 device->flags.dynamic_status = 1;
1480 1449
1481 /* Presence of _RMV indicates 'removable' */ 1450 /* Presence of _RMV indicates 'removable' */
1482 status = acpi_get_handle(device->handle, "_RMV", &temp); 1451 if (acpi_has_method(device->handle, "_RMV"))
1483 if (ACPI_SUCCESS(status))
1484 device->flags.removable = 1; 1452 device->flags.removable = 1;
1485 1453
1486 /* Presence of _EJD|_EJ0 indicates 'ejectable' */ 1454 /* Presence of _EJD|_EJ0 indicates 'ejectable' */
1487 status = acpi_get_handle(device->handle, "_EJD", &temp); 1455 if (acpi_has_method(device->handle, "_EJD") ||
1488 if (ACPI_SUCCESS(status)) 1456 acpi_has_method(device->handle, "_EJ0"))
1489 device->flags.ejectable = 1; 1457 device->flags.ejectable = 1;
1490 else {
1491 status = acpi_get_handle(device->handle, "_EJ0", &temp);
1492 if (ACPI_SUCCESS(status))
1493 device->flags.ejectable = 1;
1494 }
1495} 1458}
1496 1459
1497static void acpi_device_get_busid(struct acpi_device *device) 1460static void acpi_device_get_busid(struct acpi_device *device)
@@ -1533,46 +1496,45 @@ static void acpi_device_get_busid(struct acpi_device *device)
1533} 1496}
1534 1497
1535/* 1498/*
1499 * acpi_ata_match - see if an acpi object is an ATA device
1500 *
1501 * If an acpi object has one of the ACPI ATA methods defined,
1502 * then we can safely call it an ATA device.
1503 */
1504bool acpi_ata_match(acpi_handle handle)
1505{
1506 return acpi_has_method(handle, "_GTF") ||
1507 acpi_has_method(handle, "_GTM") ||
1508 acpi_has_method(handle, "_STM") ||
1509 acpi_has_method(handle, "_SDD");
1510}
1511
1512/*
1536 * acpi_bay_match - see if an acpi object is an ejectable driver bay 1513 * acpi_bay_match - see if an acpi object is an ejectable driver bay
1537 * 1514 *
1538 * If an acpi object is ejectable and has one of the ACPI ATA methods defined, 1515 * If an acpi object is ejectable and has one of the ACPI ATA methods defined,
1539 * then we can safely call it an ejectable drive bay 1516 * then we can safely call it an ejectable drive bay
1540 */ 1517 */
1541static int acpi_bay_match(acpi_handle handle) 1518bool acpi_bay_match(acpi_handle handle)
1542{ 1519{
1543 acpi_status status;
1544 acpi_handle tmp;
1545 acpi_handle phandle; 1520 acpi_handle phandle;
1546 1521
1547 status = acpi_get_handle(handle, "_EJ0", &tmp); 1522 if (!acpi_has_method(handle, "_EJ0"))
1548 if (ACPI_FAILURE(status)) 1523 return false;
1549 return -ENODEV; 1524 if (acpi_ata_match(handle))
1550 1525 return true;
1551 if ((ACPI_SUCCESS(acpi_get_handle(handle, "_GTF", &tmp))) || 1526 if (ACPI_FAILURE(acpi_get_parent(handle, &phandle)))
1552 (ACPI_SUCCESS(acpi_get_handle(handle, "_GTM", &tmp))) || 1527 return false;
1553 (ACPI_SUCCESS(acpi_get_handle(handle, "_STM", &tmp))) ||
1554 (ACPI_SUCCESS(acpi_get_handle(handle, "_SDD", &tmp))))
1555 return 0;
1556 1528
1557 if (acpi_get_parent(handle, &phandle)) 1529 return acpi_ata_match(phandle);
1558 return -ENODEV;
1559
1560 if ((ACPI_SUCCESS(acpi_get_handle(phandle, "_GTF", &tmp))) ||
1561 (ACPI_SUCCESS(acpi_get_handle(phandle, "_GTM", &tmp))) ||
1562 (ACPI_SUCCESS(acpi_get_handle(phandle, "_STM", &tmp))) ||
1563 (ACPI_SUCCESS(acpi_get_handle(phandle, "_SDD", &tmp))))
1564 return 0;
1565
1566 return -ENODEV;
1567} 1530}
1568 1531
1569/* 1532/*
1570 * acpi_dock_match - see if an acpi object has a _DCK method 1533 * acpi_dock_match - see if an acpi object has a _DCK method
1571 */ 1534 */
1572static int acpi_dock_match(acpi_handle handle) 1535bool acpi_dock_match(acpi_handle handle)
1573{ 1536{
1574 acpi_handle tmp; 1537 return acpi_has_method(handle, "_DCK");
1575 return acpi_get_handle(handle, "_DCK", &tmp);
1576} 1538}
1577 1539
1578const char *acpi_device_hid(struct acpi_device *device) 1540const char *acpi_device_hid(struct acpi_device *device)
@@ -1610,34 +1572,26 @@ static void acpi_add_id(struct acpi_device_pnp *pnp, const char *dev_id)
1610 * lacks the SMBUS01 HID and the methods do not have the necessary "_" 1572 * lacks the SMBUS01 HID and the methods do not have the necessary "_"
1611 * prefix. Work around this. 1573 * prefix. Work around this.
1612 */ 1574 */
1613static int acpi_ibm_smbus_match(acpi_handle handle) 1575static bool acpi_ibm_smbus_match(acpi_handle handle)
1614{ 1576{
1615 acpi_handle h_dummy; 1577 char node_name[ACPI_PATH_SEGMENT_LENGTH];
1616 struct acpi_buffer path = {ACPI_ALLOCATE_BUFFER, NULL}; 1578 struct acpi_buffer path = { sizeof(node_name), node_name };
1617 int result;
1618 1579
1619 if (!dmi_name_in_vendors("IBM")) 1580 if (!dmi_name_in_vendors("IBM"))
1620 return -ENODEV; 1581 return false;
1621 1582
1622 /* Look for SMBS object */ 1583 /* Look for SMBS object */
1623 result = acpi_get_name(handle, ACPI_SINGLE_NAME, &path); 1584 if (ACPI_FAILURE(acpi_get_name(handle, ACPI_SINGLE_NAME, &path)) ||
1624 if (result) 1585 strcmp("SMBS", path.pointer))
1625 return result; 1586 return false;
1626
1627 if (strcmp("SMBS", path.pointer)) {
1628 result = -ENODEV;
1629 goto out;
1630 }
1631 1587
1632 /* Does it have the necessary (but misnamed) methods? */ 1588 /* Does it have the necessary (but misnamed) methods? */
1633 result = -ENODEV; 1589 if (acpi_has_method(handle, "SBI") &&
1634 if (ACPI_SUCCESS(acpi_get_handle(handle, "SBI", &h_dummy)) && 1590 acpi_has_method(handle, "SBR") &&
1635 ACPI_SUCCESS(acpi_get_handle(handle, "SBR", &h_dummy)) && 1591 acpi_has_method(handle, "SBW"))
1636 ACPI_SUCCESS(acpi_get_handle(handle, "SBW", &h_dummy))) 1592 return true;
1637 result = 0; 1593
1638out: 1594 return false;
1639 kfree(path.pointer);
1640 return result;
1641} 1595}
1642 1596
1643static void acpi_set_pnp_ids(acpi_handle handle, struct acpi_device_pnp *pnp, 1597static void acpi_set_pnp_ids(acpi_handle handle, struct acpi_device_pnp *pnp,
@@ -1685,11 +1639,11 @@ static void acpi_set_pnp_ids(acpi_handle handle, struct acpi_device_pnp *pnp,
1685 */ 1639 */
1686 if (acpi_is_video_device(handle)) 1640 if (acpi_is_video_device(handle))
1687 acpi_add_id(pnp, ACPI_VIDEO_HID); 1641 acpi_add_id(pnp, ACPI_VIDEO_HID);
1688 else if (ACPI_SUCCESS(acpi_bay_match(handle))) 1642 else if (acpi_bay_match(handle))
1689 acpi_add_id(pnp, ACPI_BAY_HID); 1643 acpi_add_id(pnp, ACPI_BAY_HID);
1690 else if (ACPI_SUCCESS(acpi_dock_match(handle))) 1644 else if (acpi_dock_match(handle))
1691 acpi_add_id(pnp, ACPI_DOCK_HID); 1645 acpi_add_id(pnp, ACPI_DOCK_HID);
1692 else if (!acpi_ibm_smbus_match(handle)) 1646 else if (acpi_ibm_smbus_match(handle))
1693 acpi_add_id(pnp, ACPI_SMBUS_IBM_HID); 1647 acpi_add_id(pnp, ACPI_SMBUS_IBM_HID);
1694 else if (list_empty(&pnp->ids) && handle == ACPI_ROOT_OBJECT) { 1648 else if (list_empty(&pnp->ids) && handle == ACPI_ROOT_OBJECT) {
1695 acpi_add_id(pnp, ACPI_BUS_HID); /* \_SB, LNXSYBUS */ 1649 acpi_add_id(pnp, ACPI_BUS_HID); /* \_SB, LNXSYBUS */
@@ -1900,7 +1854,6 @@ static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl_not_used,
1900 struct acpi_device *device = NULL; 1854 struct acpi_device *device = NULL;
1901 int type; 1855 int type;
1902 unsigned long long sta; 1856 unsigned long long sta;
1903 acpi_status status;
1904 int result; 1857 int result;
1905 1858
1906 acpi_bus_get_device(handle, &device); 1859 acpi_bus_get_device(handle, &device);
@@ -1921,10 +1874,8 @@ static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl_not_used,
1921 if (!(sta & ACPI_STA_DEVICE_PRESENT) && 1874 if (!(sta & ACPI_STA_DEVICE_PRESENT) &&
1922 !(sta & ACPI_STA_DEVICE_FUNCTIONING)) { 1875 !(sta & ACPI_STA_DEVICE_FUNCTIONING)) {
1923 struct acpi_device_wakeup wakeup; 1876 struct acpi_device_wakeup wakeup;
1924 acpi_handle temp;
1925 1877
1926 status = acpi_get_handle(handle, "_PRW", &temp); 1878 if (acpi_has_method(handle, "_PRW")) {
1927 if (ACPI_SUCCESS(status)) {
1928 acpi_bus_extract_wakeup_device_power_package(handle, 1879 acpi_bus_extract_wakeup_device_power_package(handle,
1929 &wakeup); 1880 &wakeup);
1930 acpi_power_resources_list_free(&wakeup.resources); 1881 acpi_power_resources_list_free(&wakeup.resources);
diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
index 187ab61889e6..14df30580e15 100644
--- a/drivers/acpi/sleep.c
+++ b/drivers/acpi/sleep.c
@@ -31,12 +31,9 @@ static u8 sleep_states[ACPI_S_STATE_COUNT];
31 31
32static void acpi_sleep_tts_switch(u32 acpi_state) 32static void acpi_sleep_tts_switch(u32 acpi_state)
33{ 33{
34 union acpi_object in_arg = { ACPI_TYPE_INTEGER }; 34 acpi_status status;
35 struct acpi_object_list arg_list = { 1, &in_arg };
36 acpi_status status = AE_OK;
37 35
38 in_arg.integer.value = acpi_state; 36 status = acpi_execute_simple_method(NULL, "\\_TTS", acpi_state);
39 status = acpi_evaluate_object(NULL, "\\_TTS", &arg_list, NULL);
40 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { 37 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
41 /* 38 /*
42 * OS can't evaluate the _TTS object correctly. Some warning 39 * OS can't evaluate the _TTS object correctly. Some warning
@@ -141,7 +138,7 @@ static int __init init_nvs_nosave(const struct dmi_system_id *d)
141 return 0; 138 return 0;
142} 139}
143 140
144static struct dmi_system_id __initdata acpisleep_dmi_table[] = { 141static struct dmi_system_id acpisleep_dmi_table[] __initdata = {
145 { 142 {
146 .callback = init_old_suspend_ordering, 143 .callback = init_old_suspend_ordering,
147 .ident = "Abit KN9 (nForce4 variant)", 144 .ident = "Abit KN9 (nForce4 variant)",
@@ -423,10 +420,21 @@ static void acpi_pm_finish(void)
423} 420}
424 421
425/** 422/**
426 * acpi_pm_end - Finish up suspend sequence. 423 * acpi_pm_start - Start system PM transition.
424 */
425static void acpi_pm_start(u32 acpi_state)
426{
427 acpi_target_sleep_state = acpi_state;
428 acpi_sleep_tts_switch(acpi_target_sleep_state);
429 acpi_scan_lock_acquire();
430}
431
432/**
433 * acpi_pm_end - Finish up system PM transition.
427 */ 434 */
428static void acpi_pm_end(void) 435static void acpi_pm_end(void)
429{ 436{
437 acpi_scan_lock_release();
430 /* 438 /*
431 * This is necessary in case acpi_pm_finish() is not called during a 439 * This is necessary in case acpi_pm_finish() is not called during a
432 * failing transition to a sleep state. 440 * failing transition to a sleep state.
@@ -454,21 +462,19 @@ static u32 acpi_suspend_states[] = {
454static int acpi_suspend_begin(suspend_state_t pm_state) 462static int acpi_suspend_begin(suspend_state_t pm_state)
455{ 463{
456 u32 acpi_state = acpi_suspend_states[pm_state]; 464 u32 acpi_state = acpi_suspend_states[pm_state];
457 int error = 0; 465 int error;
458 466
459 error = (nvs_nosave || nvs_nosave_s3) ? 0 : suspend_nvs_alloc(); 467 error = (nvs_nosave || nvs_nosave_s3) ? 0 : suspend_nvs_alloc();
460 if (error) 468 if (error)
461 return error; 469 return error;
462 470
463 if (sleep_states[acpi_state]) { 471 if (!sleep_states[acpi_state]) {
464 acpi_target_sleep_state = acpi_state; 472 pr_err("ACPI does not support sleep state S%u\n", acpi_state);
465 acpi_sleep_tts_switch(acpi_target_sleep_state); 473 return -ENOSYS;
466 } else {
467 printk(KERN_ERR "ACPI does not support this state: %d\n",
468 pm_state);
469 error = -ENOSYS;
470 } 474 }
471 return error; 475
476 acpi_pm_start(acpi_state);
477 return 0;
472} 478}
473 479
474/** 480/**
@@ -634,10 +640,8 @@ static int acpi_hibernation_begin(void)
634 int error; 640 int error;
635 641
636 error = nvs_nosave ? 0 : suspend_nvs_alloc(); 642 error = nvs_nosave ? 0 : suspend_nvs_alloc();
637 if (!error) { 643 if (!error)
638 acpi_target_sleep_state = ACPI_STATE_S4; 644 acpi_pm_start(ACPI_STATE_S4);
639 acpi_sleep_tts_switch(acpi_target_sleep_state);
640 }
641 645
642 return error; 646 return error;
643} 647}
@@ -716,8 +720,10 @@ static int acpi_hibernation_begin_old(void)
716 if (!error) { 720 if (!error) {
717 if (!nvs_nosave) 721 if (!nvs_nosave)
718 error = suspend_nvs_alloc(); 722 error = suspend_nvs_alloc();
719 if (!error) 723 if (!error) {
720 acpi_target_sleep_state = ACPI_STATE_S4; 724 acpi_target_sleep_state = ACPI_STATE_S4;
725 acpi_scan_lock_acquire();
726 }
721 } 727 }
722 return error; 728 return error;
723} 729}
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index a33821ca3895..9063239e0b13 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -50,11 +50,6 @@
50 50
51#define ACPI_THERMAL_CLASS "thermal_zone" 51#define ACPI_THERMAL_CLASS "thermal_zone"
52#define ACPI_THERMAL_DEVICE_NAME "Thermal Zone" 52#define ACPI_THERMAL_DEVICE_NAME "Thermal Zone"
53#define ACPI_THERMAL_FILE_STATE "state"
54#define ACPI_THERMAL_FILE_TEMPERATURE "temperature"
55#define ACPI_THERMAL_FILE_TRIP_POINTS "trip_points"
56#define ACPI_THERMAL_FILE_COOLING_MODE "cooling_mode"
57#define ACPI_THERMAL_FILE_POLLING_FREQ "polling_frequency"
58#define ACPI_THERMAL_NOTIFY_TEMPERATURE 0x80 53#define ACPI_THERMAL_NOTIFY_TEMPERATURE 0x80
59#define ACPI_THERMAL_NOTIFY_THRESHOLDS 0x81 54#define ACPI_THERMAL_NOTIFY_THRESHOLDS 0x81
60#define ACPI_THERMAL_NOTIFY_DEVICES 0x82 55#define ACPI_THERMAL_NOTIFY_DEVICES 0x82
@@ -190,7 +185,6 @@ struct acpi_thermal {
190 struct thermal_zone_device *thermal_zone; 185 struct thermal_zone_device *thermal_zone;
191 int tz_enabled; 186 int tz_enabled;
192 int kelvin_offset; 187 int kelvin_offset;
193 struct mutex lock;
194}; 188};
195 189
196/* -------------------------------------------------------------------------- 190/* --------------------------------------------------------------------------
@@ -239,26 +233,16 @@ static int acpi_thermal_get_polling_frequency(struct acpi_thermal *tz)
239 233
240static int acpi_thermal_set_cooling_mode(struct acpi_thermal *tz, int mode) 234static int acpi_thermal_set_cooling_mode(struct acpi_thermal *tz, int mode)
241{ 235{
242 acpi_status status = AE_OK;
243 union acpi_object arg0 = { ACPI_TYPE_INTEGER };
244 struct acpi_object_list arg_list = { 1, &arg0 };
245 acpi_handle handle = NULL;
246
247
248 if (!tz) 236 if (!tz)
249 return -EINVAL; 237 return -EINVAL;
250 238
251 status = acpi_get_handle(tz->device->handle, "_SCP", &handle); 239 if (!acpi_has_method(tz->device->handle, "_SCP")) {
252 if (ACPI_FAILURE(status)) {
253 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "_SCP not present\n")); 240 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "_SCP not present\n"));
254 return -ENODEV; 241 return -ENODEV;
255 } 242 } else if (ACPI_FAILURE(acpi_execute_simple_method(tz->device->handle,
256 243 "_SCP", mode))) {
257 arg0.integer.value = mode;
258
259 status = acpi_evaluate_object(handle, NULL, &arg_list, NULL);
260 if (ACPI_FAILURE(status))
261 return -ENODEV; 244 return -ENODEV;
245 }
262 246
263 return 0; 247 return 0;
264} 248}
@@ -769,7 +753,6 @@ static int thermal_notify(struct thermal_zone_device *thermal, int trip,
769 else 753 else
770 return 0; 754 return 0;
771 755
772 acpi_bus_generate_proc_event(tz->device, type, 1);
773 acpi_bus_generate_netlink_event(tz->device->pnp.device_class, 756 acpi_bus_generate_netlink_event(tz->device->pnp.device_class,
774 dev_name(&tz->device->dev), type, 1); 757 dev_name(&tz->device->dev), type, 1);
775 758
@@ -850,12 +833,13 @@ static int acpi_thermal_cooling_device_cb(struct thermal_zone_device *thermal,
850 if (ACPI_SUCCESS(status) && (dev == device)) { 833 if (ACPI_SUCCESS(status) && (dev == device)) {
851 if (bind) 834 if (bind)
852 result = thermal_zone_bind_cooling_device 835 result = thermal_zone_bind_cooling_device
853 (thermal, -1, cdev, 836 (thermal, THERMAL_TRIPS_NONE,
854 THERMAL_NO_LIMIT, 837 cdev, THERMAL_NO_LIMIT,
855 THERMAL_NO_LIMIT); 838 THERMAL_NO_LIMIT);
856 else 839 else
857 result = thermal_zone_unbind_cooling_device 840 result = thermal_zone_unbind_cooling_device
858 (thermal, -1, cdev); 841 (thermal, THERMAL_TRIPS_NONE,
842 cdev);
859 if (result) 843 if (result)
860 goto failed; 844 goto failed;
861 } 845 }
@@ -980,14 +964,12 @@ static void acpi_thermal_notify(struct acpi_device *device, u32 event)
980 case ACPI_THERMAL_NOTIFY_THRESHOLDS: 964 case ACPI_THERMAL_NOTIFY_THRESHOLDS:
981 acpi_thermal_trips_update(tz, ACPI_TRIPS_REFRESH_THRESHOLDS); 965 acpi_thermal_trips_update(tz, ACPI_TRIPS_REFRESH_THRESHOLDS);
982 acpi_thermal_check(tz); 966 acpi_thermal_check(tz);
983 acpi_bus_generate_proc_event(device, event, 0);
984 acpi_bus_generate_netlink_event(device->pnp.device_class, 967 acpi_bus_generate_netlink_event(device->pnp.device_class,
985 dev_name(&device->dev), event, 0); 968 dev_name(&device->dev), event, 0);
986 break; 969 break;
987 case ACPI_THERMAL_NOTIFY_DEVICES: 970 case ACPI_THERMAL_NOTIFY_DEVICES:
988 acpi_thermal_trips_update(tz, ACPI_TRIPS_REFRESH_DEVICES); 971 acpi_thermal_trips_update(tz, ACPI_TRIPS_REFRESH_DEVICES);
989 acpi_thermal_check(tz); 972 acpi_thermal_check(tz);
990 acpi_bus_generate_proc_event(device, event, 0);
991 acpi_bus_generate_netlink_event(device->pnp.device_class, 973 acpi_bus_generate_netlink_event(device->pnp.device_class,
992 dev_name(&device->dev), event, 0); 974 dev_name(&device->dev), event, 0);
993 break; 975 break;
@@ -1101,8 +1083,6 @@ static int acpi_thermal_add(struct acpi_device *device)
1101 strcpy(acpi_device_name(device), ACPI_THERMAL_DEVICE_NAME); 1083 strcpy(acpi_device_name(device), ACPI_THERMAL_DEVICE_NAME);
1102 strcpy(acpi_device_class(device), ACPI_THERMAL_CLASS); 1084 strcpy(acpi_device_class(device), ACPI_THERMAL_CLASS);
1103 device->driver_data = tz; 1085 device->driver_data = tz;
1104 mutex_init(&tz->lock);
1105
1106 1086
1107 result = acpi_thermal_get_info(tz); 1087 result = acpi_thermal_get_info(tz);
1108 if (result) 1088 if (result)
@@ -1135,7 +1115,6 @@ static int acpi_thermal_remove(struct acpi_device *device)
1135 tz = acpi_driver_data(device); 1115 tz = acpi_driver_data(device);
1136 1116
1137 acpi_thermal_unregister_thermal_zone(tz); 1117 acpi_thermal_unregister_thermal_zone(tz);
1138 mutex_destroy(&tz->lock);
1139 kfree(tz); 1118 kfree(tz);
1140 return 0; 1119 return 0;
1141} 1120}
diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c
index 744371304313..552248b0005b 100644
--- a/drivers/acpi/utils.c
+++ b/drivers/acpi/utils.c
@@ -495,3 +495,73 @@ acpi_handle_printk(const char *level, acpi_handle handle, const char *fmt, ...)
495 kfree(buffer.pointer); 495 kfree(buffer.pointer);
496} 496}
497EXPORT_SYMBOL(acpi_handle_printk); 497EXPORT_SYMBOL(acpi_handle_printk);
498
499/**
500 * acpi_has_method: Check whether @handle has a method named @name
501 * @handle: ACPI device handle
502 * @name: name of object or method
503 *
504 * Check whether @handle has a method named @name.
505 */
506bool acpi_has_method(acpi_handle handle, char *name)
507{
508 acpi_handle tmp;
509
510 return ACPI_SUCCESS(acpi_get_handle(handle, name, &tmp));
511}
512EXPORT_SYMBOL(acpi_has_method);
513
514acpi_status acpi_execute_simple_method(acpi_handle handle, char *method,
515 u64 arg)
516{
517 union acpi_object obj = { .type = ACPI_TYPE_INTEGER };
518 struct acpi_object_list arg_list = { .count = 1, .pointer = &obj, };
519
520 obj.integer.value = arg;
521
522 return acpi_evaluate_object(handle, method, &arg_list, NULL);
523}
524EXPORT_SYMBOL(acpi_execute_simple_method);
525
526/**
527 * acpi_evaluate_ej0: Evaluate _EJ0 method for hotplug operations
528 * @handle: ACPI device handle
529 *
530 * Evaluate device's _EJ0 method for hotplug operations.
531 */
532acpi_status acpi_evaluate_ej0(acpi_handle handle)
533{
534 acpi_status status;
535
536 status = acpi_execute_simple_method(handle, "_EJ0", 1);
537 if (status == AE_NOT_FOUND)
538 acpi_handle_warn(handle, "No _EJ0 support for device\n");
539 else if (ACPI_FAILURE(status))
540 acpi_handle_warn(handle, "Eject failed (0x%x)\n", status);
541
542 return status;
543}
544
545/**
546 * acpi_evaluate_lck: Evaluate _LCK method to lock/unlock device
547 * @handle: ACPI device handle
548 * @lock: lock device if non-zero, otherwise unlock device
549 *
550 * Evaluate device's _LCK method if present to lock/unlock device
551 */
552acpi_status acpi_evaluate_lck(acpi_handle handle, int lock)
553{
554 acpi_status status;
555
556 status = acpi_execute_simple_method(handle, "_LCK", !!lock);
557 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
558 if (lock)
559 acpi_handle_warn(handle,
560 "Locking device failed (0x%x)\n", status);
561 else
562 acpi_handle_warn(handle,
563 "Unlocking device failed (0x%x)\n", status);
564 }
565
566 return status;
567}
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index e1284b8dc6ee..c86fc0c70ff6 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -355,14 +355,10 @@ static int
355acpi_video_device_lcd_set_level(struct acpi_video_device *device, int level) 355acpi_video_device_lcd_set_level(struct acpi_video_device *device, int level)
356{ 356{
357 int status; 357 int status;
358 union acpi_object arg0 = { ACPI_TYPE_INTEGER };
359 struct acpi_object_list args = { 1, &arg0 };
360 int state; 358 int state;
361 359
362 arg0.integer.value = level; 360 status = acpi_execute_simple_method(device->dev->handle,
363 361 "_BCM", level);
364 status = acpi_evaluate_object(device->dev->handle, "_BCM",
365 &args, NULL);
366 if (ACPI_FAILURE(status)) { 362 if (ACPI_FAILURE(status)) {
367 ACPI_ERROR((AE_INFO, "Evaluating _BCM failed")); 363 ACPI_ERROR((AE_INFO, "Evaluating _BCM failed"));
368 return -EIO; 364 return -EIO;
@@ -638,18 +634,15 @@ static int
638acpi_video_bus_DOS(struct acpi_video_bus *video, int bios_flag, int lcd_flag) 634acpi_video_bus_DOS(struct acpi_video_bus *video, int bios_flag, int lcd_flag)
639{ 635{
640 acpi_status status; 636 acpi_status status;
641 union acpi_object arg0 = { ACPI_TYPE_INTEGER };
642 struct acpi_object_list args = { 1, &arg0 };
643 637
644 if (!video->cap._DOS) 638 if (!video->cap._DOS)
645 return 0; 639 return 0;
646 640
647 if (bios_flag < 0 || bios_flag > 3 || lcd_flag < 0 || lcd_flag > 1) 641 if (bios_flag < 0 || bios_flag > 3 || lcd_flag < 0 || lcd_flag > 1)
648 return -EINVAL; 642 return -EINVAL;
649 arg0.integer.value = (lcd_flag << 2) | bios_flag; 643 video->dos_setting = (lcd_flag << 2) | bios_flag;
650 video->dos_setting = arg0.integer.value; 644 status = acpi_execute_simple_method(video->device->handle, "_DOS",
651 status = acpi_evaluate_object(video->device->handle, "_DOS", 645 (lcd_flag << 2) | bios_flag);
652 &args, NULL);
653 if (ACPI_FAILURE(status)) 646 if (ACPI_FAILURE(status))
654 return -EIO; 647 return -EIO;
655 648
@@ -885,31 +878,21 @@ out:
885 878
886static void acpi_video_device_find_cap(struct acpi_video_device *device) 879static void acpi_video_device_find_cap(struct acpi_video_device *device)
887{ 880{
888 acpi_handle h_dummy1; 881 if (acpi_has_method(device->dev->handle, "_ADR"))
889
890 if (ACPI_SUCCESS(acpi_get_handle(device->dev->handle, "_ADR", &h_dummy1))) {
891 device->cap._ADR = 1; 882 device->cap._ADR = 1;
892 } 883 if (acpi_has_method(device->dev->handle, "_BCL"))
893 if (ACPI_SUCCESS(acpi_get_handle(device->dev->handle, "_BCL", &h_dummy1))) {
894 device->cap._BCL = 1; 884 device->cap._BCL = 1;
895 } 885 if (acpi_has_method(device->dev->handle, "_BCM"))
896 if (ACPI_SUCCESS(acpi_get_handle(device->dev->handle, "_BCM", &h_dummy1))) {
897 device->cap._BCM = 1; 886 device->cap._BCM = 1;
898 } 887 if (acpi_has_method(device->dev->handle, "_BQC")) {
899 if (ACPI_SUCCESS(acpi_get_handle(device->dev->handle,"_BQC",&h_dummy1)))
900 device->cap._BQC = 1; 888 device->cap._BQC = 1;
901 else if (ACPI_SUCCESS(acpi_get_handle(device->dev->handle, "_BCQ", 889 } else if (acpi_has_method(device->dev->handle, "_BCQ")) {
902 &h_dummy1))) {
903 printk(KERN_WARNING FW_BUG "_BCQ is used instead of _BQC\n"); 890 printk(KERN_WARNING FW_BUG "_BCQ is used instead of _BQC\n");
904 device->cap._BCQ = 1; 891 device->cap._BCQ = 1;
905 } 892 }
906 893
907 if (ACPI_SUCCESS(acpi_get_handle(device->dev->handle, "_DDC", &h_dummy1))) { 894 if (acpi_has_method(device->dev->handle, "_DDC"))
908 device->cap._DDC = 1; 895 device->cap._DDC = 1;
909 }
910
911 if (acpi_video_init_brightness(device))
912 return;
913 896
914 if (acpi_video_backlight_support()) { 897 if (acpi_video_backlight_support()) {
915 struct backlight_properties props; 898 struct backlight_properties props;
@@ -920,6 +903,9 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device)
920 static int count = 0; 903 static int count = 0;
921 char *name; 904 char *name;
922 905
906 result = acpi_video_init_brightness(device);
907 if (result)
908 return;
923 name = kasprintf(GFP_KERNEL, "acpi_video%d", count); 909 name = kasprintf(GFP_KERNEL, "acpi_video%d", count);
924 if (!name) 910 if (!name)
925 return; 911 return;
@@ -979,11 +965,6 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device)
979 if (result) 965 if (result)
980 printk(KERN_ERR PREFIX "Create sysfs link\n"); 966 printk(KERN_ERR PREFIX "Create sysfs link\n");
981 967
982 } else {
983 /* Remove the brightness object. */
984 kfree(device->brightness->levels);
985 kfree(device->brightness);
986 device->brightness = NULL;
987 } 968 }
988} 969}
989 970
@@ -999,26 +980,18 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device)
999 980
1000static void acpi_video_bus_find_cap(struct acpi_video_bus *video) 981static void acpi_video_bus_find_cap(struct acpi_video_bus *video)
1001{ 982{
1002 acpi_handle h_dummy1; 983 if (acpi_has_method(video->device->handle, "_DOS"))
1003
1004 if (ACPI_SUCCESS(acpi_get_handle(video->device->handle, "_DOS", &h_dummy1))) {
1005 video->cap._DOS = 1; 984 video->cap._DOS = 1;
1006 } 985 if (acpi_has_method(video->device->handle, "_DOD"))
1007 if (ACPI_SUCCESS(acpi_get_handle(video->device->handle, "_DOD", &h_dummy1))) {
1008 video->cap._DOD = 1; 986 video->cap._DOD = 1;
1009 } 987 if (acpi_has_method(video->device->handle, "_ROM"))
1010 if (ACPI_SUCCESS(acpi_get_handle(video->device->handle, "_ROM", &h_dummy1))) {
1011 video->cap._ROM = 1; 988 video->cap._ROM = 1;
1012 } 989 if (acpi_has_method(video->device->handle, "_GPD"))
1013 if (ACPI_SUCCESS(acpi_get_handle(video->device->handle, "_GPD", &h_dummy1))) {
1014 video->cap._GPD = 1; 990 video->cap._GPD = 1;
1015 } 991 if (acpi_has_method(video->device->handle, "_SPD"))
1016 if (ACPI_SUCCESS(acpi_get_handle(video->device->handle, "_SPD", &h_dummy1))) {
1017 video->cap._SPD = 1; 992 video->cap._SPD = 1;
1018 } 993 if (acpi_has_method(video->device->handle, "_VPO"))
1019 if (ACPI_SUCCESS(acpi_get_handle(video->device->handle, "_VPO", &h_dummy1))) {
1020 video->cap._VPO = 1; 994 video->cap._VPO = 1;
1021 }
1022} 995}
1023 996
1024/* 997/*
@@ -1577,7 +1550,6 @@ static void acpi_video_bus_notify(struct acpi_device *device, u32 event)
1577 switch (event) { 1550 switch (event) {
1578 case ACPI_VIDEO_NOTIFY_SWITCH: /* User requested a switch, 1551 case ACPI_VIDEO_NOTIFY_SWITCH: /* User requested a switch,
1579 * most likely via hotkey. */ 1552 * most likely via hotkey. */
1580 acpi_bus_generate_proc_event(device, event, 0);
1581 keycode = KEY_SWITCHVIDEOMODE; 1553 keycode = KEY_SWITCHVIDEOMODE;
1582 break; 1554 break;
1583 1555
@@ -1585,20 +1557,16 @@ static void acpi_video_bus_notify(struct acpi_device *device, u32 event)
1585 * connector. */ 1557 * connector. */
1586 acpi_video_device_enumerate(video); 1558 acpi_video_device_enumerate(video);
1587 acpi_video_device_rebind(video); 1559 acpi_video_device_rebind(video);
1588 acpi_bus_generate_proc_event(device, event, 0);
1589 keycode = KEY_SWITCHVIDEOMODE; 1560 keycode = KEY_SWITCHVIDEOMODE;
1590 break; 1561 break;
1591 1562
1592 case ACPI_VIDEO_NOTIFY_CYCLE: /* Cycle Display output hotkey pressed. */ 1563 case ACPI_VIDEO_NOTIFY_CYCLE: /* Cycle Display output hotkey pressed. */
1593 acpi_bus_generate_proc_event(device, event, 0);
1594 keycode = KEY_SWITCHVIDEOMODE; 1564 keycode = KEY_SWITCHVIDEOMODE;
1595 break; 1565 break;
1596 case ACPI_VIDEO_NOTIFY_NEXT_OUTPUT: /* Next Display output hotkey pressed. */ 1566 case ACPI_VIDEO_NOTIFY_NEXT_OUTPUT: /* Next Display output hotkey pressed. */
1597 acpi_bus_generate_proc_event(device, event, 0);
1598 keycode = KEY_VIDEO_NEXT; 1567 keycode = KEY_VIDEO_NEXT;
1599 break; 1568 break;
1600 case ACPI_VIDEO_NOTIFY_PREV_OUTPUT: /* previous Display output hotkey pressed. */ 1569 case ACPI_VIDEO_NOTIFY_PREV_OUTPUT: /* previous Display output hotkey pressed. */
1601 acpi_bus_generate_proc_event(device, event, 0);
1602 keycode = KEY_VIDEO_PREV; 1570 keycode = KEY_VIDEO_PREV;
1603 break; 1571 break;
1604 1572
@@ -1641,31 +1609,26 @@ static void acpi_video_device_notify(acpi_handle handle, u32 event, void *data)
1641 case ACPI_VIDEO_NOTIFY_CYCLE_BRIGHTNESS: /* Cycle brightness */ 1609 case ACPI_VIDEO_NOTIFY_CYCLE_BRIGHTNESS: /* Cycle brightness */
1642 if (brightness_switch_enabled) 1610 if (brightness_switch_enabled)
1643 acpi_video_switch_brightness(video_device, event); 1611 acpi_video_switch_brightness(video_device, event);
1644 acpi_bus_generate_proc_event(device, event, 0);
1645 keycode = KEY_BRIGHTNESS_CYCLE; 1612 keycode = KEY_BRIGHTNESS_CYCLE;
1646 break; 1613 break;
1647 case ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS: /* Increase brightness */ 1614 case ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS: /* Increase brightness */
1648 if (brightness_switch_enabled) 1615 if (brightness_switch_enabled)
1649 acpi_video_switch_brightness(video_device, event); 1616 acpi_video_switch_brightness(video_device, event);
1650 acpi_bus_generate_proc_event(device, event, 0);
1651 keycode = KEY_BRIGHTNESSUP; 1617 keycode = KEY_BRIGHTNESSUP;
1652 break; 1618 break;
1653 case ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS: /* Decrease brightness */ 1619 case ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS: /* Decrease brightness */
1654 if (brightness_switch_enabled) 1620 if (brightness_switch_enabled)
1655 acpi_video_switch_brightness(video_device, event); 1621 acpi_video_switch_brightness(video_device, event);
1656 acpi_bus_generate_proc_event(device, event, 0);
1657 keycode = KEY_BRIGHTNESSDOWN; 1622 keycode = KEY_BRIGHTNESSDOWN;
1658 break; 1623 break;
1659 case ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS: /* zero brightness */ 1624 case ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS: /* zero brightness */
1660 if (brightness_switch_enabled) 1625 if (brightness_switch_enabled)
1661 acpi_video_switch_brightness(video_device, event); 1626 acpi_video_switch_brightness(video_device, event);
1662 acpi_bus_generate_proc_event(device, event, 0);
1663 keycode = KEY_BRIGHTNESS_ZERO; 1627 keycode = KEY_BRIGHTNESS_ZERO;
1664 break; 1628 break;
1665 case ACPI_VIDEO_NOTIFY_DISPLAY_OFF: /* display device off */ 1629 case ACPI_VIDEO_NOTIFY_DISPLAY_OFF: /* display device off */
1666 if (brightness_switch_enabled) 1630 if (brightness_switch_enabled)
1667 acpi_video_switch_brightness(video_device, event); 1631 acpi_video_switch_brightness(video_device, event);
1668 acpi_bus_generate_proc_event(device, event, 0);
1669 keycode = KEY_DISPLAY_OFF; 1632 keycode = KEY_DISPLAY_OFF;
1670 break; 1633 break;
1671 default: 1634 default:
diff --git a/drivers/acpi/video_detect.c b/drivers/acpi/video_detect.c
index c3397748ba46..940edbf2fe8f 100644
--- a/drivers/acpi/video_detect.c
+++ b/drivers/acpi/video_detect.c
@@ -53,14 +53,13 @@ acpi_backlight_cap_match(acpi_handle handle, u32 level, void *context,
53 void **retyurn_value) 53 void **retyurn_value)
54{ 54{
55 long *cap = context; 55 long *cap = context;
56 acpi_handle h_dummy;
57 56
58 if (ACPI_SUCCESS(acpi_get_handle(handle, "_BCM", &h_dummy)) && 57 if (acpi_has_method(handle, "_BCM") &&
59 ACPI_SUCCESS(acpi_get_handle(handle, "_BCL", &h_dummy))) { 58 acpi_has_method(handle, "_BCL")) {
60 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found generic backlight " 59 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found generic backlight "
61 "support\n")); 60 "support\n"));
62 *cap |= ACPI_VIDEO_BACKLIGHT; 61 *cap |= ACPI_VIDEO_BACKLIGHT;
63 if (ACPI_FAILURE(acpi_get_handle(handle, "_BQC", &h_dummy))) 62 if (!acpi_has_method(handle, "_BQC"))
64 printk(KERN_WARNING FW_BUG PREFIX "No _BQC method, " 63 printk(KERN_WARNING FW_BUG PREFIX "No _BQC method, "
65 "cannot determine initial brightness\n"); 64 "cannot determine initial brightness\n");
66 /* We have backlight support, no need to scan further */ 65 /* We have backlight support, no need to scan further */
@@ -79,22 +78,20 @@ acpi_backlight_cap_match(acpi_handle handle, u32 level, void *context,
79 */ 78 */
80long acpi_is_video_device(acpi_handle handle) 79long acpi_is_video_device(acpi_handle handle)
81{ 80{
82 acpi_handle h_dummy;
83 long video_caps = 0; 81 long video_caps = 0;
84 82
85 /* Is this device able to support video switching ? */ 83 /* Is this device able to support video switching ? */
86 if (ACPI_SUCCESS(acpi_get_handle(handle, "_DOD", &h_dummy)) || 84 if (acpi_has_method(handle, "_DOD") || acpi_has_method(handle, "_DOS"))
87 ACPI_SUCCESS(acpi_get_handle(handle, "_DOS", &h_dummy)))
88 video_caps |= ACPI_VIDEO_OUTPUT_SWITCHING; 85 video_caps |= ACPI_VIDEO_OUTPUT_SWITCHING;
89 86
90 /* Is this device able to retrieve a video ROM ? */ 87 /* Is this device able to retrieve a video ROM ? */
91 if (ACPI_SUCCESS(acpi_get_handle(handle, "_ROM", &h_dummy))) 88 if (acpi_has_method(handle, "_ROM"))
92 video_caps |= ACPI_VIDEO_ROM_AVAILABLE; 89 video_caps |= ACPI_VIDEO_ROM_AVAILABLE;
93 90
94 /* Is this device able to configure which video head to be POSTed ? */ 91 /* Is this device able to configure which video head to be POSTed ? */
95 if (ACPI_SUCCESS(acpi_get_handle(handle, "_VPO", &h_dummy)) && 92 if (acpi_has_method(handle, "_VPO") &&
96 ACPI_SUCCESS(acpi_get_handle(handle, "_GPD", &h_dummy)) && 93 acpi_has_method(handle, "_GPD") &&
97 ACPI_SUCCESS(acpi_get_handle(handle, "_SPD", &h_dummy))) 94 acpi_has_method(handle, "_SPD"))
98 video_caps |= ACPI_VIDEO_DEVICE_POSTING; 95 video_caps |= ACPI_VIDEO_DEVICE_POSTING;
99 96
100 /* Only check for backlight functionality if one of the above hit. */ 97 /* Only check for backlight functionality if one of the above hit. */
diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c
index cf4e7020adac..da8170dfc90f 100644
--- a/drivers/ata/libata-acpi.c
+++ b/drivers/ata/libata-acpi.c
@@ -947,11 +947,11 @@ static void pata_acpi_set_state(struct ata_port *ap, pm_message_t state)
947 continue; 947 continue;
948 948
949 acpi_bus_set_power(dev_handle, state.event & PM_EVENT_RESUME ? 949 acpi_bus_set_power(dev_handle, state.event & PM_EVENT_RESUME ?
950 ACPI_STATE_D0 : ACPI_STATE_D3); 950 ACPI_STATE_D0 : ACPI_STATE_D3_COLD);
951 } 951 }
952 952
953 if (!(state.event & PM_EVENT_RESUME)) 953 if (!(state.event & PM_EVENT_RESUME))
954 acpi_bus_set_power(port_handle, ACPI_STATE_D3); 954 acpi_bus_set_power(port_handle, ACPI_STATE_D3_COLD);
955} 955}
956 956
957/** 957/**
diff --git a/drivers/ata/libata-pmp.c b/drivers/ata/libata-pmp.c
index 1c41722bb7e2..20fd337a5731 100644
--- a/drivers/ata/libata-pmp.c
+++ b/drivers/ata/libata-pmp.c
@@ -289,24 +289,24 @@ static int sata_pmp_configure(struct ata_device *dev, int print_info)
289 289
290 /* Disable sending Early R_OK. 290 /* Disable sending Early R_OK.
291 * With "cached read" HDD testing and multiple ports busy on a SATA 291 * With "cached read" HDD testing and multiple ports busy on a SATA
292 * host controller, 3726 PMP will very rarely drop a deferred 292 * host controller, 3x26 PMP will very rarely drop a deferred
293 * R_OK that was intended for the host. Symptom will be all 293 * R_OK that was intended for the host. Symptom will be all
294 * 5 drives under test will timeout, get reset, and recover. 294 * 5 drives under test will timeout, get reset, and recover.
295 */ 295 */
296 if (vendor == 0x1095 && devid == 0x3726) { 296 if (vendor == 0x1095 && (devid == 0x3726 || devid == 0x3826)) {
297 u32 reg; 297 u32 reg;
298 298
299 err_mask = sata_pmp_read(&ap->link, PMP_GSCR_SII_POL, &reg); 299 err_mask = sata_pmp_read(&ap->link, PMP_GSCR_SII_POL, &reg);
300 if (err_mask) { 300 if (err_mask) {
301 rc = -EIO; 301 rc = -EIO;
302 reason = "failed to read Sil3726 Private Register"; 302 reason = "failed to read Sil3x26 Private Register";
303 goto fail; 303 goto fail;
304 } 304 }
305 reg &= ~0x1; 305 reg &= ~0x1;
306 err_mask = sata_pmp_write(&ap->link, PMP_GSCR_SII_POL, reg); 306 err_mask = sata_pmp_write(&ap->link, PMP_GSCR_SII_POL, reg);
307 if (err_mask) { 307 if (err_mask) {
308 rc = -EIO; 308 rc = -EIO;
309 reason = "failed to write Sil3726 Private Register"; 309 reason = "failed to write Sil3x26 Private Register";
310 goto fail; 310 goto fail;
311 } 311 }
312 } 312 }
@@ -383,8 +383,8 @@ static void sata_pmp_quirks(struct ata_port *ap)
383 u16 devid = sata_pmp_gscr_devid(gscr); 383 u16 devid = sata_pmp_gscr_devid(gscr);
384 struct ata_link *link; 384 struct ata_link *link;
385 385
386 if (vendor == 0x1095 && devid == 0x3726) { 386 if (vendor == 0x1095 && (devid == 0x3726 || devid == 0x3826)) {
387 /* sil3726 quirks */ 387 /* sil3x26 quirks */
388 ata_for_each_link(link, ap, EDGE) { 388 ata_for_each_link(link, ap, EDGE) {
389 /* link reports offline after LPM */ 389 /* link reports offline after LPM */
390 link->flags |= ATA_LFLAG_NO_LPM; 390 link->flags |= ATA_LFLAG_NO_LPM;
diff --git a/drivers/ata/pata_imx.c b/drivers/ata/pata_imx.c
index 4ec7c04b3f82..26386f0b89a8 100644
--- a/drivers/ata/pata_imx.c
+++ b/drivers/ata/pata_imx.c
@@ -237,6 +237,7 @@ static const struct of_device_id imx_pata_dt_ids[] = {
237 /* sentinel */ 237 /* sentinel */
238 } 238 }
239}; 239};
240MODULE_DEVICE_TABLE(of, imx_pata_dt_ids);
240 241
241static struct platform_driver pata_imx_driver = { 242static struct platform_driver pata_imx_driver = {
242 .probe = pata_imx_probe, 243 .probe = pata_imx_probe,
diff --git a/drivers/ata/sata_fsl.c b/drivers/ata/sata_fsl.c
index 19720a0a4a65..851bd3f43ac6 100644
--- a/drivers/ata/sata_fsl.c
+++ b/drivers/ata/sata_fsl.c
@@ -293,6 +293,7 @@ static void fsl_sata_set_irq_coalescing(struct ata_host *host,
293{ 293{
294 struct sata_fsl_host_priv *host_priv = host->private_data; 294 struct sata_fsl_host_priv *host_priv = host->private_data;
295 void __iomem *hcr_base = host_priv->hcr_base; 295 void __iomem *hcr_base = host_priv->hcr_base;
296 unsigned long flags;
296 297
297 if (count > ICC_MAX_INT_COUNT_THRESHOLD) 298 if (count > ICC_MAX_INT_COUNT_THRESHOLD)
298 count = ICC_MAX_INT_COUNT_THRESHOLD; 299 count = ICC_MAX_INT_COUNT_THRESHOLD;
@@ -305,12 +306,12 @@ static void fsl_sata_set_irq_coalescing(struct ata_host *host,
305 (count > ICC_MIN_INT_COUNT_THRESHOLD)) 306 (count > ICC_MIN_INT_COUNT_THRESHOLD))
306 ticks = ICC_SAFE_INT_TICKS; 307 ticks = ICC_SAFE_INT_TICKS;
307 308
308 spin_lock(&host->lock); 309 spin_lock_irqsave(&host->lock, flags);
309 iowrite32((count << 24 | ticks), hcr_base + ICC); 310 iowrite32((count << 24 | ticks), hcr_base + ICC);
310 311
311 intr_coalescing_count = count; 312 intr_coalescing_count = count;
312 intr_coalescing_ticks = ticks; 313 intr_coalescing_ticks = ticks;
313 spin_unlock(&host->lock); 314 spin_unlock_irqrestore(&host->lock, flags);
314 315
315 DPRINTK("interrupt coalescing, count = 0x%x, ticks = %x\n", 316 DPRINTK("interrupt coalescing, count = 0x%x, ticks = %x\n",
316 intr_coalescing_count, intr_coalescing_ticks); 317 intr_coalescing_count, intr_coalescing_ticks);
diff --git a/drivers/ata/sata_highbank.c b/drivers/ata/sata_highbank.c
index d047d92a456f..e9a4f46d962e 100644
--- a/drivers/ata/sata_highbank.c
+++ b/drivers/ata/sata_highbank.c
@@ -86,11 +86,11 @@ struct ecx_plat_data {
86 86
87#define SGPIO_SIGNALS 3 87#define SGPIO_SIGNALS 3
88#define ECX_ACTIVITY_BITS 0x300000 88#define ECX_ACTIVITY_BITS 0x300000
89#define ECX_ACTIVITY_SHIFT 2 89#define ECX_ACTIVITY_SHIFT 0
90#define ECX_LOCATE_BITS 0x80000 90#define ECX_LOCATE_BITS 0x80000
91#define ECX_LOCATE_SHIFT 1 91#define ECX_LOCATE_SHIFT 1
92#define ECX_FAULT_BITS 0x400000 92#define ECX_FAULT_BITS 0x400000
93#define ECX_FAULT_SHIFT 0 93#define ECX_FAULT_SHIFT 2
94static inline int sgpio_bit_shift(struct ecx_plat_data *pdata, u32 port, 94static inline int sgpio_bit_shift(struct ecx_plat_data *pdata, u32 port,
95 u32 shift) 95 u32 shift)
96{ 96{
diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c
index e69102696533..3455f833e473 100644
--- a/drivers/base/regmap/regcache.c
+++ b/drivers/base/regmap/regcache.c
@@ -719,7 +719,8 @@ static int regcache_sync_block_raw(struct regmap *map, void *block,
719 } 719 }
720 } 720 }
721 721
722 return regcache_sync_block_raw_flush(map, &data, base, regtmp); 722 return regcache_sync_block_raw_flush(map, &data, base, regtmp +
723 map->reg_stride);
723} 724}
724 725
725int regcache_sync_block(struct regmap *map, void *block, 726int regcache_sync_block(struct regmap *map, void *block,
diff --git a/drivers/block/aoe/aoecmd.c b/drivers/block/aoe/aoecmd.c
index 99cb944a002d..4d45dba7fb8f 100644
--- a/drivers/block/aoe/aoecmd.c
+++ b/drivers/block/aoe/aoecmd.c
@@ -906,16 +906,10 @@ bio_pageinc(struct bio *bio)
906 int i; 906 int i;
907 907
908 bio_for_each_segment(bv, bio, i) { 908 bio_for_each_segment(bv, bio, i) {
909 page = bv->bv_page;
910 /* Non-zero page count for non-head members of 909 /* Non-zero page count for non-head members of
911 * compound pages is no longer allowed by the kernel, 910 * compound pages is no longer allowed by the kernel.
912 * but this has never been seen here.
913 */ 911 */
914 if (unlikely(PageCompound(page))) 912 page = compound_trans_head(bv->bv_page);
915 if (compound_trans_head(page) != page) {
916 pr_crit("page tail used for block I/O\n");
917 BUG();
918 }
919 atomic_inc(&page->_count); 913 atomic_inc(&page->_count);
920 } 914 }
921} 915}
@@ -924,10 +918,13 @@ static void
924bio_pagedec(struct bio *bio) 918bio_pagedec(struct bio *bio)
925{ 919{
926 struct bio_vec *bv; 920 struct bio_vec *bv;
921 struct page *page;
927 int i; 922 int i;
928 923
929 bio_for_each_segment(bv, bio, i) 924 bio_for_each_segment(bv, bio, i) {
930 atomic_dec(&bv->bv_page->_count); 925 page = compound_trans_head(bv->bv_page);
926 atomic_dec(&page->_count);
927 }
931} 928}
932 929
933static void 930static void
diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
index bf2349dbbf7f..7cc1fe2241fd 100644
--- a/drivers/char/sonypi.c
+++ b/drivers/char/sonypi.c
@@ -876,11 +876,6 @@ found:
876 if (useinput) 876 if (useinput)
877 sonypi_report_input_event(event); 877 sonypi_report_input_event(event);
878 878
879#ifdef CONFIG_ACPI
880 if (sonypi_acpi_device)
881 acpi_bus_generate_proc_event(sonypi_acpi_device, 1, event);
882#endif
883
884 kfifo_in_locked(&sonypi_device.fifo, (unsigned char *)&event, 879 kfifo_in_locked(&sonypi_device.fifo, (unsigned char *)&event,
885 sizeof(event), &sonypi_device.fifo_lock); 880 sizeof(event), &sonypi_device.fifo_lock);
886 kill_fasync(&sonypi_device.fifo_async, SIGIO, POLL_IN); 881 kill_fasync(&sonypi_device.fifo_async, SIGIO, POLL_IN);
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index 1b456fe9b87a..fc45567ad3ac 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -272,9 +272,12 @@ static struct port *find_port_by_devt_in_portdev(struct ports_device *portdev,
272 unsigned long flags; 272 unsigned long flags;
273 273
274 spin_lock_irqsave(&portdev->ports_lock, flags); 274 spin_lock_irqsave(&portdev->ports_lock, flags);
275 list_for_each_entry(port, &portdev->ports, list) 275 list_for_each_entry(port, &portdev->ports, list) {
276 if (port->cdev->dev == dev) 276 if (port->cdev->dev == dev) {
277 kref_get(&port->kref);
277 goto out; 278 goto out;
279 }
280 }
278 port = NULL; 281 port = NULL;
279out: 282out:
280 spin_unlock_irqrestore(&portdev->ports_lock, flags); 283 spin_unlock_irqrestore(&portdev->ports_lock, flags);
@@ -746,6 +749,10 @@ static ssize_t port_fops_read(struct file *filp, char __user *ubuf,
746 749
747 port = filp->private_data; 750 port = filp->private_data;
748 751
752 /* Port is hot-unplugged. */
753 if (!port->guest_connected)
754 return -ENODEV;
755
749 if (!port_has_data(port)) { 756 if (!port_has_data(port)) {
750 /* 757 /*
751 * If nothing's connected on the host just return 0 in 758 * If nothing's connected on the host just return 0 in
@@ -762,7 +769,7 @@ static ssize_t port_fops_read(struct file *filp, char __user *ubuf,
762 if (ret < 0) 769 if (ret < 0)
763 return ret; 770 return ret;
764 } 771 }
765 /* Port got hot-unplugged. */ 772 /* Port got hot-unplugged while we were waiting above. */
766 if (!port->guest_connected) 773 if (!port->guest_connected)
767 return -ENODEV; 774 return -ENODEV;
768 /* 775 /*
@@ -932,13 +939,25 @@ static ssize_t port_fops_splice_write(struct pipe_inode_info *pipe,
932 if (is_rproc_serial(port->out_vq->vdev)) 939 if (is_rproc_serial(port->out_vq->vdev))
933 return -EINVAL; 940 return -EINVAL;
934 941
942 /*
943 * pipe->nrbufs == 0 means there are no data to transfer,
944 * so this returns just 0 for no data.
945 */
946 pipe_lock(pipe);
947 if (!pipe->nrbufs) {
948 ret = 0;
949 goto error_out;
950 }
951
935 ret = wait_port_writable(port, filp->f_flags & O_NONBLOCK); 952 ret = wait_port_writable(port, filp->f_flags & O_NONBLOCK);
936 if (ret < 0) 953 if (ret < 0)
937 return ret; 954 goto error_out;
938 955
939 buf = alloc_buf(port->out_vq, 0, pipe->nrbufs); 956 buf = alloc_buf(port->out_vq, 0, pipe->nrbufs);
940 if (!buf) 957 if (!buf) {
941 return -ENOMEM; 958 ret = -ENOMEM;
959 goto error_out;
960 }
942 961
943 sgl.n = 0; 962 sgl.n = 0;
944 sgl.len = 0; 963 sgl.len = 0;
@@ -946,12 +965,17 @@ static ssize_t port_fops_splice_write(struct pipe_inode_info *pipe,
946 sgl.sg = buf->sg; 965 sgl.sg = buf->sg;
947 sg_init_table(sgl.sg, sgl.size); 966 sg_init_table(sgl.sg, sgl.size);
948 ret = __splice_from_pipe(pipe, &sd, pipe_to_sg); 967 ret = __splice_from_pipe(pipe, &sd, pipe_to_sg);
968 pipe_unlock(pipe);
949 if (likely(ret > 0)) 969 if (likely(ret > 0))
950 ret = __send_to_port(port, buf->sg, sgl.n, sgl.len, buf, true); 970 ret = __send_to_port(port, buf->sg, sgl.n, sgl.len, buf, true);
951 971
952 if (unlikely(ret <= 0)) 972 if (unlikely(ret <= 0))
953 free_buf(buf, true); 973 free_buf(buf, true);
954 return ret; 974 return ret;
975
976error_out:
977 pipe_unlock(pipe);
978 return ret;
955} 979}
956 980
957static unsigned int port_fops_poll(struct file *filp, poll_table *wait) 981static unsigned int port_fops_poll(struct file *filp, poll_table *wait)
@@ -1019,14 +1043,14 @@ static int port_fops_open(struct inode *inode, struct file *filp)
1019 struct port *port; 1043 struct port *port;
1020 int ret; 1044 int ret;
1021 1045
1046 /* We get the port with a kref here */
1022 port = find_port_by_devt(cdev->dev); 1047 port = find_port_by_devt(cdev->dev);
1048 if (!port) {
1049 /* Port was unplugged before we could proceed */
1050 return -ENXIO;
1051 }
1023 filp->private_data = port; 1052 filp->private_data = port;
1024 1053
1025 /* Prevent against a port getting hot-unplugged at the same time */
1026 spin_lock_irq(&port->portdev->ports_lock);
1027 kref_get(&port->kref);
1028 spin_unlock_irq(&port->portdev->ports_lock);
1029
1030 /* 1054 /*
1031 * Don't allow opening of console port devices -- that's done 1055 * Don't allow opening of console port devices -- that's done
1032 * via /dev/hvc 1056 * via /dev/hvc
@@ -1498,14 +1522,6 @@ static void remove_port(struct kref *kref)
1498 1522
1499 port = container_of(kref, struct port, kref); 1523 port = container_of(kref, struct port, kref);
1500 1524
1501 sysfs_remove_group(&port->dev->kobj, &port_attribute_group);
1502 device_destroy(pdrvdata.class, port->dev->devt);
1503 cdev_del(port->cdev);
1504
1505 kfree(port->name);
1506
1507 debugfs_remove(port->debugfs_file);
1508
1509 kfree(port); 1525 kfree(port);
1510} 1526}
1511 1527
@@ -1539,12 +1555,14 @@ static void unplug_port(struct port *port)
1539 spin_unlock_irq(&port->portdev->ports_lock); 1555 spin_unlock_irq(&port->portdev->ports_lock);
1540 1556
1541 if (port->guest_connected) { 1557 if (port->guest_connected) {
1558 /* Let the app know the port is going down. */
1559 send_sigio_to_port(port);
1560
1561 /* Do this after sigio is actually sent */
1542 port->guest_connected = false; 1562 port->guest_connected = false;
1543 port->host_connected = false; 1563 port->host_connected = false;
1544 wake_up_interruptible(&port->waitqueue);
1545 1564
1546 /* Let the app know the port is going down. */ 1565 wake_up_interruptible(&port->waitqueue);
1547 send_sigio_to_port(port);
1548 } 1566 }
1549 1567
1550 if (is_console_port(port)) { 1568 if (is_console_port(port)) {
@@ -1563,6 +1581,14 @@ static void unplug_port(struct port *port)
1563 */ 1581 */
1564 port->portdev = NULL; 1582 port->portdev = NULL;
1565 1583
1584 sysfs_remove_group(&port->dev->kobj, &port_attribute_group);
1585 device_destroy(pdrvdata.class, port->dev->devt);
1586 cdev_del(port->cdev);
1587
1588 kfree(port->name);
1589
1590 debugfs_remove(port->debugfs_file);
1591
1566 /* 1592 /*
1567 * Locks around here are not necessary - a port can't be 1593 * Locks around here are not necessary - a port can't be
1568 * opened after we removed the port struct from ports_list 1594 * opened after we removed the port struct from ports_list
diff --git a/drivers/clk/samsung/clk-exynos4.c b/drivers/clk/samsung/clk-exynos4.c
index 1bdb882c845b..4e5739773c33 100644
--- a/drivers/clk/samsung/clk-exynos4.c
+++ b/drivers/clk/samsung/clk-exynos4.c
@@ -581,11 +581,15 @@ struct samsung_div_clock exynos4x12_div_clks[] __initdata = {
581 DIV(none, "div_spi1_isp", "mout_spi1_isp", E4X12_DIV_ISP, 16, 4), 581 DIV(none, "div_spi1_isp", "mout_spi1_isp", E4X12_DIV_ISP, 16, 4),
582 DIV(none, "div_spi1_isp_pre", "div_spi1_isp", E4X12_DIV_ISP, 20, 8), 582 DIV(none, "div_spi1_isp_pre", "div_spi1_isp", E4X12_DIV_ISP, 20, 8),
583 DIV(none, "div_uart_isp", "mout_uart_isp", E4X12_DIV_ISP, 28, 4), 583 DIV(none, "div_uart_isp", "mout_uart_isp", E4X12_DIV_ISP, 28, 4),
584 DIV(div_isp0, "div_isp0", "aclk200", E4X12_DIV_ISP0, 0, 3), 584 DIV_F(div_isp0, "div_isp0", "aclk200", E4X12_DIV_ISP0, 0, 3,
585 DIV(div_isp1, "div_isp1", "aclk200", E4X12_DIV_ISP0, 4, 3), 585 CLK_GET_RATE_NOCACHE, 0),
586 DIV_F(div_isp1, "div_isp1", "aclk200", E4X12_DIV_ISP0, 4, 3,
587 CLK_GET_RATE_NOCACHE, 0),
586 DIV(none, "div_mpwm", "div_isp1", E4X12_DIV_ISP1, 0, 3), 588 DIV(none, "div_mpwm", "div_isp1", E4X12_DIV_ISP1, 0, 3),
587 DIV(div_mcuisp0, "div_mcuisp0", "aclk400_mcuisp", E4X12_DIV_ISP1, 4, 3), 589 DIV_F(div_mcuisp0, "div_mcuisp0", "aclk400_mcuisp", E4X12_DIV_ISP1,
588 DIV(div_mcuisp1, "div_mcuisp1", "div_mcuisp0", E4X12_DIV_ISP1, 8, 3), 590 4, 3, CLK_GET_RATE_NOCACHE, 0),
591 DIV_F(div_mcuisp1, "div_mcuisp1", "div_mcuisp0", E4X12_DIV_ISP1,
592 8, 3, CLK_GET_RATE_NOCACHE, 0),
589 DIV(sclk_fimg2d, "sclk_fimg2d", "mout_g2d", DIV_DMC1, 0, 4), 593 DIV(sclk_fimg2d, "sclk_fimg2d", "mout_g2d", DIV_DMC1, 0, 4),
590}; 594};
591 595
@@ -863,57 +867,57 @@ struct samsung_gate_clock exynos4x12_gate_clks[] __initdata = {
863 GATE_DA(i2s0, "samsung-i2s.0", "i2s0", "aclk100", 867 GATE_DA(i2s0, "samsung-i2s.0", "i2s0", "aclk100",
864 E4X12_GATE_IP_MAUDIO, 3, 0, 0, "iis"), 868 E4X12_GATE_IP_MAUDIO, 3, 0, 0, "iis"),
865 GATE(fimc_isp, "isp", "aclk200", E4X12_GATE_ISP0, 0, 869 GATE(fimc_isp, "isp", "aclk200", E4X12_GATE_ISP0, 0,
866 CLK_IGNORE_UNUSED, 0), 870 CLK_IGNORE_UNUSED | CLK_GET_RATE_NOCACHE, 0),
867 GATE(fimc_drc, "drc", "aclk200", E4X12_GATE_ISP0, 1, 871 GATE(fimc_drc, "drc", "aclk200", E4X12_GATE_ISP0, 1,
868 CLK_IGNORE_UNUSED, 0), 872 CLK_IGNORE_UNUSED | CLK_GET_RATE_NOCACHE, 0),
869 GATE(fimc_fd, "fd", "aclk200", E4X12_GATE_ISP0, 2, 873 GATE(fimc_fd, "fd", "aclk200", E4X12_GATE_ISP0, 2,
870 CLK_IGNORE_UNUSED, 0), 874 CLK_IGNORE_UNUSED | CLK_GET_RATE_NOCACHE, 0),
871 GATE(fimc_lite0, "lite0", "aclk200", E4X12_GATE_ISP0, 3, 875 GATE(fimc_lite0, "lite0", "aclk200", E4X12_GATE_ISP0, 3,
872 CLK_IGNORE_UNUSED, 0), 876 CLK_IGNORE_UNUSED | CLK_GET_RATE_NOCACHE, 0),
873 GATE(fimc_lite1, "lite1", "aclk200", E4X12_GATE_ISP0, 4, 877 GATE(fimc_lite1, "lite1", "aclk200", E4X12_GATE_ISP0, 4,
874 CLK_IGNORE_UNUSED, 0), 878 CLK_IGNORE_UNUSED | CLK_GET_RATE_NOCACHE, 0),
875 GATE(mcuisp, "mcuisp", "aclk200", E4X12_GATE_ISP0, 5, 879 GATE(mcuisp, "mcuisp", "aclk200", E4X12_GATE_ISP0, 5,
876 CLK_IGNORE_UNUSED, 0), 880 CLK_IGNORE_UNUSED | CLK_GET_RATE_NOCACHE, 0),
877 GATE(gicisp, "gicisp", "aclk200", E4X12_GATE_ISP0, 7, 881 GATE(gicisp, "gicisp", "aclk200", E4X12_GATE_ISP0, 7,
878 CLK_IGNORE_UNUSED, 0), 882 CLK_IGNORE_UNUSED | CLK_GET_RATE_NOCACHE, 0),
879 GATE(smmu_isp, "smmu_isp", "aclk200", E4X12_GATE_ISP0, 8, 883 GATE(smmu_isp, "smmu_isp", "aclk200", E4X12_GATE_ISP0, 8,
880 CLK_IGNORE_UNUSED, 0), 884 CLK_IGNORE_UNUSED | CLK_GET_RATE_NOCACHE, 0),
881 GATE(smmu_drc, "smmu_drc", "aclk200", E4X12_GATE_ISP0, 9, 885 GATE(smmu_drc, "smmu_drc", "aclk200", E4X12_GATE_ISP0, 9,
882 CLK_IGNORE_UNUSED, 0), 886 CLK_IGNORE_UNUSED | CLK_GET_RATE_NOCACHE, 0),
883 GATE(smmu_fd, "smmu_fd", "aclk200", E4X12_GATE_ISP0, 10, 887 GATE(smmu_fd, "smmu_fd", "aclk200", E4X12_GATE_ISP0, 10,
884 CLK_IGNORE_UNUSED, 0), 888 CLK_IGNORE_UNUSED | CLK_GET_RATE_NOCACHE, 0),
885 GATE(smmu_lite0, "smmu_lite0", "aclk200", E4X12_GATE_ISP0, 11, 889 GATE(smmu_lite0, "smmu_lite0", "aclk200", E4X12_GATE_ISP0, 11,
886 CLK_IGNORE_UNUSED, 0), 890 CLK_IGNORE_UNUSED | CLK_GET_RATE_NOCACHE, 0),
887 GATE(smmu_lite1, "smmu_lite1", "aclk200", E4X12_GATE_ISP0, 12, 891 GATE(smmu_lite1, "smmu_lite1", "aclk200", E4X12_GATE_ISP0, 12,
888 CLK_IGNORE_UNUSED, 0), 892 CLK_IGNORE_UNUSED | CLK_GET_RATE_NOCACHE, 0),
889 GATE(ppmuispmx, "ppmuispmx", "aclk200", E4X12_GATE_ISP0, 20, 893 GATE(ppmuispmx, "ppmuispmx", "aclk200", E4X12_GATE_ISP0, 20,
890 CLK_IGNORE_UNUSED, 0), 894 CLK_IGNORE_UNUSED | CLK_GET_RATE_NOCACHE, 0),
891 GATE(ppmuispx, "ppmuispx", "aclk200", E4X12_GATE_ISP0, 21, 895 GATE(ppmuispx, "ppmuispx", "aclk200", E4X12_GATE_ISP0, 21,
892 CLK_IGNORE_UNUSED, 0), 896 CLK_IGNORE_UNUSED | CLK_GET_RATE_NOCACHE, 0),
893 GATE(mcuctl_isp, "mcuctl_isp", "aclk200", E4X12_GATE_ISP0, 23, 897 GATE(mcuctl_isp, "mcuctl_isp", "aclk200", E4X12_GATE_ISP0, 23,
894 CLK_IGNORE_UNUSED, 0), 898 CLK_IGNORE_UNUSED | CLK_GET_RATE_NOCACHE, 0),
895 GATE(mpwm_isp, "mpwm_isp", "aclk200", E4X12_GATE_ISP0, 24, 899 GATE(mpwm_isp, "mpwm_isp", "aclk200", E4X12_GATE_ISP0, 24,
896 CLK_IGNORE_UNUSED, 0), 900 CLK_IGNORE_UNUSED | CLK_GET_RATE_NOCACHE, 0),
897 GATE(i2c0_isp, "i2c0_isp", "aclk200", E4X12_GATE_ISP0, 25, 901 GATE(i2c0_isp, "i2c0_isp", "aclk200", E4X12_GATE_ISP0, 25,
898 CLK_IGNORE_UNUSED, 0), 902 CLK_IGNORE_UNUSED | CLK_GET_RATE_NOCACHE, 0),
899 GATE(i2c1_isp, "i2c1_isp", "aclk200", E4X12_GATE_ISP0, 26, 903 GATE(i2c1_isp, "i2c1_isp", "aclk200", E4X12_GATE_ISP0, 26,
900 CLK_IGNORE_UNUSED, 0), 904 CLK_IGNORE_UNUSED | CLK_GET_RATE_NOCACHE, 0),
901 GATE(mtcadc_isp, "mtcadc_isp", "aclk200", E4X12_GATE_ISP0, 27, 905 GATE(mtcadc_isp, "mtcadc_isp", "aclk200", E4X12_GATE_ISP0, 27,
902 CLK_IGNORE_UNUSED, 0), 906 CLK_IGNORE_UNUSED | CLK_GET_RATE_NOCACHE, 0),
903 GATE(pwm_isp, "pwm_isp", "aclk200", E4X12_GATE_ISP0, 28, 907 GATE(pwm_isp, "pwm_isp", "aclk200", E4X12_GATE_ISP0, 28,
904 CLK_IGNORE_UNUSED, 0), 908 CLK_IGNORE_UNUSED | CLK_GET_RATE_NOCACHE, 0),
905 GATE(wdt_isp, "wdt_isp", "aclk200", E4X12_GATE_ISP0, 30, 909 GATE(wdt_isp, "wdt_isp", "aclk200", E4X12_GATE_ISP0, 30,
906 CLK_IGNORE_UNUSED, 0), 910 CLK_IGNORE_UNUSED | CLK_GET_RATE_NOCACHE, 0),
907 GATE(uart_isp, "uart_isp", "aclk200", E4X12_GATE_ISP0, 31, 911 GATE(uart_isp, "uart_isp", "aclk200", E4X12_GATE_ISP0, 31,
908 CLK_IGNORE_UNUSED, 0), 912 CLK_IGNORE_UNUSED | CLK_GET_RATE_NOCACHE, 0),
909 GATE(asyncaxim, "asyncaxim", "aclk200", E4X12_GATE_ISP1, 0, 913 GATE(asyncaxim, "asyncaxim", "aclk200", E4X12_GATE_ISP1, 0,
910 CLK_IGNORE_UNUSED, 0), 914 CLK_IGNORE_UNUSED | CLK_GET_RATE_NOCACHE, 0),
911 GATE(smmu_ispcx, "smmu_ispcx", "aclk200", E4X12_GATE_ISP1, 4, 915 GATE(smmu_ispcx, "smmu_ispcx", "aclk200", E4X12_GATE_ISP1, 4,
912 CLK_IGNORE_UNUSED, 0), 916 CLK_IGNORE_UNUSED | CLK_GET_RATE_NOCACHE, 0),
913 GATE(spi0_isp, "spi0_isp", "aclk200", E4X12_GATE_ISP1, 12, 917 GATE(spi0_isp, "spi0_isp", "aclk200", E4X12_GATE_ISP1, 12,
914 CLK_IGNORE_UNUSED, 0), 918 CLK_IGNORE_UNUSED | CLK_GET_RATE_NOCACHE, 0),
915 GATE(spi1_isp, "spi1_isp", "aclk200", E4X12_GATE_ISP1, 13, 919 GATE(spi1_isp, "spi1_isp", "aclk200", E4X12_GATE_ISP1, 13,
916 CLK_IGNORE_UNUSED, 0), 920 CLK_IGNORE_UNUSED | CLK_GET_RATE_NOCACHE, 0),
917 GATE(g2d, "g2d", "aclk200", GATE_IP_DMC, 23, 0, 0), 921 GATE(g2d, "g2d", "aclk200", GATE_IP_DMC, 23, 0, 0),
918}; 922};
919 923
diff --git a/drivers/clk/zynq/clkc.c b/drivers/clk/zynq/clkc.c
index 5c205b60a82a..089d3e30e221 100644
--- a/drivers/clk/zynq/clkc.c
+++ b/drivers/clk/zynq/clkc.c
@@ -71,6 +71,7 @@ static DEFINE_SPINLOCK(armpll_lock);
71static DEFINE_SPINLOCK(ddrpll_lock); 71static DEFINE_SPINLOCK(ddrpll_lock);
72static DEFINE_SPINLOCK(iopll_lock); 72static DEFINE_SPINLOCK(iopll_lock);
73static DEFINE_SPINLOCK(armclk_lock); 73static DEFINE_SPINLOCK(armclk_lock);
74static DEFINE_SPINLOCK(swdtclk_lock);
74static DEFINE_SPINLOCK(ddrclk_lock); 75static DEFINE_SPINLOCK(ddrclk_lock);
75static DEFINE_SPINLOCK(dciclk_lock); 76static DEFINE_SPINLOCK(dciclk_lock);
76static DEFINE_SPINLOCK(gem0clk_lock); 77static DEFINE_SPINLOCK(gem0clk_lock);
@@ -293,7 +294,7 @@ static void __init zynq_clk_setup(struct device_node *np)
293 } 294 }
294 clks[swdt] = clk_register_mux(NULL, clk_output_name[swdt], 295 clks[swdt] = clk_register_mux(NULL, clk_output_name[swdt],
295 swdt_ext_clk_mux_parents, 2, CLK_SET_RATE_PARENT, 296 swdt_ext_clk_mux_parents, 2, CLK_SET_RATE_PARENT,
296 SLCR_SWDT_CLK_SEL, 0, 1, 0, &gem0clk_lock); 297 SLCR_SWDT_CLK_SEL, 0, 1, 0, &swdtclk_lock);
297 298
298 /* DDR clocks */ 299 /* DDR clocks */
299 clk = clk_register_divider(NULL, "ddr2x_div", "ddrpll", 0, 300 clk = clk_register_divider(NULL, "ddr2x_div", "ddrpll", 0,
@@ -364,8 +365,9 @@ static void __init zynq_clk_setup(struct device_node *np)
364 CLK_SET_RATE_PARENT, SLCR_GEM0_CLK_CTRL, 20, 6, 365 CLK_SET_RATE_PARENT, SLCR_GEM0_CLK_CTRL, 20, 6,
365 CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO, 366 CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
366 &gem0clk_lock); 367 &gem0clk_lock);
367 clk = clk_register_mux(NULL, "gem0_emio_mux", gem0_mux_parents, 2, 0, 368 clk = clk_register_mux(NULL, "gem0_emio_mux", gem0_mux_parents, 2,
368 SLCR_GEM0_CLK_CTRL, 6, 1, 0, &gem0clk_lock); 369 CLK_SET_RATE_PARENT, SLCR_GEM0_CLK_CTRL, 6, 1, 0,
370 &gem0clk_lock);
369 clks[gem0] = clk_register_gate(NULL, clk_output_name[gem0], 371 clks[gem0] = clk_register_gate(NULL, clk_output_name[gem0],
370 "gem0_emio_mux", CLK_SET_RATE_PARENT, 372 "gem0_emio_mux", CLK_SET_RATE_PARENT,
371 SLCR_GEM0_CLK_CTRL, 0, 0, &gem0clk_lock); 373 SLCR_GEM0_CLK_CTRL, 0, 0, &gem0clk_lock);
@@ -386,8 +388,9 @@ static void __init zynq_clk_setup(struct device_node *np)
386 CLK_SET_RATE_PARENT, SLCR_GEM1_CLK_CTRL, 20, 6, 388 CLK_SET_RATE_PARENT, SLCR_GEM1_CLK_CTRL, 20, 6,
387 CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO, 389 CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
388 &gem1clk_lock); 390 &gem1clk_lock);
389 clk = clk_register_mux(NULL, "gem1_emio_mux", gem1_mux_parents, 2, 0, 391 clk = clk_register_mux(NULL, "gem1_emio_mux", gem1_mux_parents, 2,
390 SLCR_GEM1_CLK_CTRL, 6, 1, 0, &gem1clk_lock); 392 CLK_SET_RATE_PARENT, SLCR_GEM1_CLK_CTRL, 6, 1, 0,
393 &gem1clk_lock);
391 clks[gem1] = clk_register_gate(NULL, clk_output_name[gem1], 394 clks[gem1] = clk_register_gate(NULL, clk_output_name[gem1],
392 "gem1_emio_mux", CLK_SET_RATE_PARENT, 395 "gem1_emio_mux", CLK_SET_RATE_PARENT,
393 SLCR_GEM1_CLK_CTRL, 0, 0, &gem1clk_lock); 396 SLCR_GEM1_CLK_CTRL, 0, 0, &gem1clk_lock);
diff --git a/drivers/dma/sh/shdma.c b/drivers/dma/sh/shdma.c
index b67f45f5c271..5039fbc88254 100644
--- a/drivers/dma/sh/shdma.c
+++ b/drivers/dma/sh/shdma.c
@@ -400,8 +400,8 @@ static size_t sh_dmae_get_partial(struct shdma_chan *schan,
400 shdma_chan); 400 shdma_chan);
401 struct sh_dmae_desc *sh_desc = container_of(sdesc, 401 struct sh_dmae_desc *sh_desc = container_of(sdesc,
402 struct sh_dmae_desc, shdma_desc); 402 struct sh_dmae_desc, shdma_desc);
403 return (sh_desc->hw.tcr - sh_dmae_readl(sh_chan, TCR)) << 403 return sh_desc->hw.tcr -
404 sh_chan->xmit_shift; 404 (sh_dmae_readl(sh_chan, TCR) << sh_chan->xmit_shift);
405} 405}
406 406
407/* Called from error IRQ or NMI */ 407/* Called from error IRQ or NMI */
diff --git a/drivers/gpu/drm/ast/ast_ttm.c b/drivers/gpu/drm/ast/ast_ttm.c
index 98d670825a1a..6e8887fe6c1b 100644
--- a/drivers/gpu/drm/ast/ast_ttm.c
+++ b/drivers/gpu/drm/ast/ast_ttm.c
@@ -323,6 +323,7 @@ int ast_bo_create(struct drm_device *dev, int size, int align,
323 323
324 astbo->gem.driver_private = NULL; 324 astbo->gem.driver_private = NULL;
325 astbo->bo.bdev = &ast->ttm.bdev; 325 astbo->bo.bdev = &ast->ttm.bdev;
326 astbo->bo.bdev->dev_mapping = dev->dev_mapping;
326 327
327 ast_ttm_placement(astbo, TTM_PL_FLAG_VRAM | TTM_PL_FLAG_SYSTEM); 328 ast_ttm_placement(astbo, TTM_PL_FLAG_VRAM | TTM_PL_FLAG_SYSTEM);
328 329
diff --git a/drivers/gpu/drm/cirrus/cirrus_ttm.c b/drivers/gpu/drm/cirrus/cirrus_ttm.c
index 0047012045c2..69fd8f1ac8df 100644
--- a/drivers/gpu/drm/cirrus/cirrus_ttm.c
+++ b/drivers/gpu/drm/cirrus/cirrus_ttm.c
@@ -328,6 +328,7 @@ int cirrus_bo_create(struct drm_device *dev, int size, int align,
328 328
329 cirrusbo->gem.driver_private = NULL; 329 cirrusbo->gem.driver_private = NULL;
330 cirrusbo->bo.bdev = &cirrus->ttm.bdev; 330 cirrusbo->bo.bdev = &cirrus->ttm.bdev;
331 cirrusbo->bo.bdev->dev_mapping = dev->dev_mapping;
331 332
332 cirrus_ttm_placement(cirrusbo, TTM_PL_FLAG_VRAM | TTM_PL_FLAG_SYSTEM); 333 cirrus_ttm_placement(cirrusbo, TTM_PL_FLAG_VRAM | TTM_PL_FLAG_SYSTEM);
333 334
diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index 8bcce7866d36..f92da0a32f0d 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -708,7 +708,10 @@ int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev, int crtc,
708 /* Subtract time delta from raw timestamp to get final 708 /* Subtract time delta from raw timestamp to get final
709 * vblank_time timestamp for end of vblank. 709 * vblank_time timestamp for end of vblank.
710 */ 710 */
711 etime = ktime_sub_ns(etime, delta_ns); 711 if (delta_ns < 0)
712 etime = ktime_add_ns(etime, -delta_ns);
713 else
714 etime = ktime_sub_ns(etime, delta_ns);
712 *vblank_time = ktime_to_timeval(etime); 715 *vblank_time = ktime_to_timeval(etime);
713 716
714 DRM_DEBUG("crtc %d : v %d p(%d,%d)@ %ld.%ld -> %ld.%ld [e %d us, %d rep]\n", 717 DRM_DEBUG("crtc %d : v %d p(%d,%d)@ %ld.%ld -> %ld.%ld [e %d us, %d rep]\n",
diff --git a/drivers/gpu/drm/gma500/psb_intel_sdvo.c b/drivers/gpu/drm/gma500/psb_intel_sdvo.c
index 19e36603b23b..3bc8414533c9 100644
--- a/drivers/gpu/drm/gma500/psb_intel_sdvo.c
+++ b/drivers/gpu/drm/gma500/psb_intel_sdvo.c
@@ -500,7 +500,8 @@ static bool psb_intel_sdvo_read_response(struct psb_intel_sdvo *psb_intel_sdvo,
500 &status)) 500 &status))
501 goto log_fail; 501 goto log_fail;
502 502
503 while (status == SDVO_CMD_STATUS_PENDING && retry--) { 503 while ((status == SDVO_CMD_STATUS_PENDING ||
504 status == SDVO_CMD_STATUS_TARGET_NOT_SPECIFIED) && retry--) {
504 udelay(15); 505 udelay(15);
505 if (!psb_intel_sdvo_read_byte(psb_intel_sdvo, 506 if (!psb_intel_sdvo_read_byte(psb_intel_sdvo,
506 SDVO_I2C_CMD_STATUS, 507 SDVO_I2C_CMD_STATUS,
diff --git a/drivers/gpu/drm/i915/i915_gem_dmabuf.c b/drivers/gpu/drm/i915/i915_gem_dmabuf.c
index dc53a527126b..9e6578330801 100644
--- a/drivers/gpu/drm/i915/i915_gem_dmabuf.c
+++ b/drivers/gpu/drm/i915/i915_gem_dmabuf.c
@@ -85,9 +85,17 @@ static void i915_gem_unmap_dma_buf(struct dma_buf_attachment *attachment,
85 struct sg_table *sg, 85 struct sg_table *sg,
86 enum dma_data_direction dir) 86 enum dma_data_direction dir)
87{ 87{
88 struct drm_i915_gem_object *obj = attachment->dmabuf->priv;
89
90 mutex_lock(&obj->base.dev->struct_mutex);
91
88 dma_unmap_sg(attachment->dev, sg->sgl, sg->nents, dir); 92 dma_unmap_sg(attachment->dev, sg->sgl, sg->nents, dir);
89 sg_free_table(sg); 93 sg_free_table(sg);
90 kfree(sg); 94 kfree(sg);
95
96 i915_gem_object_unpin_pages(obj);
97
98 mutex_unlock(&obj->base.dev->struct_mutex);
91} 99}
92 100
93static void i915_gem_dmabuf_release(struct dma_buf *dma_buf) 101static void i915_gem_dmabuf_release(struct dma_buf *dma_buf)
diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index f2326fc60ac9..53cddd985406 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -752,6 +752,8 @@
752 will not assert AGPBUSY# and will only 752 will not assert AGPBUSY# and will only
753 be delivered when out of C3. */ 753 be delivered when out of C3. */
754#define INSTPM_FORCE_ORDERING (1<<7) /* GEN6+ */ 754#define INSTPM_FORCE_ORDERING (1<<7) /* GEN6+ */
755#define INSTPM_TLB_INVALIDATE (1<<9)
756#define INSTPM_SYNC_FLUSH (1<<5)
755#define ACTHD 0x020c8 757#define ACTHD 0x020c8
756#define FW_BLC 0x020d8 758#define FW_BLC 0x020d8
757#define FW_BLC2 0x020dc 759#define FW_BLC2 0x020dc
@@ -1856,10 +1858,16 @@
1856#define CRT_HOTPLUG_DETECT_VOLTAGE_475MV (1 << 2) 1858#define CRT_HOTPLUG_DETECT_VOLTAGE_475MV (1 << 2)
1857 1859
1858#define PORT_HOTPLUG_STAT (dev_priv->info->display_mmio_offset + 0x61114) 1860#define PORT_HOTPLUG_STAT (dev_priv->info->display_mmio_offset + 0x61114)
1859/* HDMI/DP bits are gen4+ */ 1861/*
1860#define PORTB_HOTPLUG_LIVE_STATUS (1 << 29) 1862 * HDMI/DP bits are gen4+
1863 *
1864 * WARNING: Bspec for hpd status bits on gen4 seems to be completely confused.
1865 * Please check the detailed lore in the commit message for for experimental
1866 * evidence.
1867 */
1868#define PORTD_HOTPLUG_LIVE_STATUS (1 << 29)
1861#define PORTC_HOTPLUG_LIVE_STATUS (1 << 28) 1869#define PORTC_HOTPLUG_LIVE_STATUS (1 << 28)
1862#define PORTD_HOTPLUG_LIVE_STATUS (1 << 27) 1870#define PORTB_HOTPLUG_LIVE_STATUS (1 << 27)
1863#define PORTD_HOTPLUG_INT_STATUS (3 << 21) 1871#define PORTD_HOTPLUG_INT_STATUS (3 << 21)
1864#define PORTC_HOTPLUG_INT_STATUS (3 << 19) 1872#define PORTC_HOTPLUG_INT_STATUS (3 << 19)
1865#define PORTB_HOTPLUG_INT_STATUS (3 << 17) 1873#define PORTB_HOTPLUG_INT_STATUS (3 << 17)
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 5fb305840db8..be79f477a38f 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -8269,9 +8269,11 @@ check_crtc_state(struct drm_device *dev)
8269 8269
8270 list_for_each_entry(encoder, &dev->mode_config.encoder_list, 8270 list_for_each_entry(encoder, &dev->mode_config.encoder_list,
8271 base.head) { 8271 base.head) {
8272 enum pipe pipe;
8272 if (encoder->base.crtc != &crtc->base) 8273 if (encoder->base.crtc != &crtc->base)
8273 continue; 8274 continue;
8274 if (encoder->get_config) 8275 if (encoder->get_config &&
8276 encoder->get_hw_state(encoder, &pipe))
8275 encoder->get_config(encoder, &pipe_config); 8277 encoder->get_config(encoder, &pipe_config);
8276 } 8278 }
8277 8279
@@ -10040,6 +10042,8 @@ struct intel_display_error_state {
10040 10042
10041 u32 power_well_driver; 10043 u32 power_well_driver;
10042 10044
10045 int num_transcoders;
10046
10043 struct intel_cursor_error_state { 10047 struct intel_cursor_error_state {
10044 u32 control; 10048 u32 control;
10045 u32 position; 10049 u32 position;
@@ -10048,16 +10052,7 @@ struct intel_display_error_state {
10048 } cursor[I915_MAX_PIPES]; 10052 } cursor[I915_MAX_PIPES];
10049 10053
10050 struct intel_pipe_error_state { 10054 struct intel_pipe_error_state {
10051 enum transcoder cpu_transcoder;
10052 u32 conf;
10053 u32 source; 10055 u32 source;
10054
10055 u32 htotal;
10056 u32 hblank;
10057 u32 hsync;
10058 u32 vtotal;
10059 u32 vblank;
10060 u32 vsync;
10061 } pipe[I915_MAX_PIPES]; 10056 } pipe[I915_MAX_PIPES];
10062 10057
10063 struct intel_plane_error_state { 10058 struct intel_plane_error_state {
@@ -10069,6 +10064,19 @@ struct intel_display_error_state {
10069 u32 surface; 10064 u32 surface;
10070 u32 tile_offset; 10065 u32 tile_offset;
10071 } plane[I915_MAX_PIPES]; 10066 } plane[I915_MAX_PIPES];
10067
10068 struct intel_transcoder_error_state {
10069 enum transcoder cpu_transcoder;
10070
10071 u32 conf;
10072
10073 u32 htotal;
10074 u32 hblank;
10075 u32 hsync;
10076 u32 vtotal;
10077 u32 vblank;
10078 u32 vsync;
10079 } transcoder[4];
10072}; 10080};
10073 10081
10074struct intel_display_error_state * 10082struct intel_display_error_state *
@@ -10076,9 +10084,17 @@ intel_display_capture_error_state(struct drm_device *dev)
10076{ 10084{
10077 drm_i915_private_t *dev_priv = dev->dev_private; 10085 drm_i915_private_t *dev_priv = dev->dev_private;
10078 struct intel_display_error_state *error; 10086 struct intel_display_error_state *error;
10079 enum transcoder cpu_transcoder; 10087 int transcoders[] = {
10088 TRANSCODER_A,
10089 TRANSCODER_B,
10090 TRANSCODER_C,
10091 TRANSCODER_EDP,
10092 };
10080 int i; 10093 int i;
10081 10094
10095 if (INTEL_INFO(dev)->num_pipes == 0)
10096 return NULL;
10097
10082 error = kmalloc(sizeof(*error), GFP_ATOMIC); 10098 error = kmalloc(sizeof(*error), GFP_ATOMIC);
10083 if (error == NULL) 10099 if (error == NULL)
10084 return NULL; 10100 return NULL;
@@ -10087,9 +10103,6 @@ intel_display_capture_error_state(struct drm_device *dev)
10087 error->power_well_driver = I915_READ(HSW_PWR_WELL_DRIVER); 10103 error->power_well_driver = I915_READ(HSW_PWR_WELL_DRIVER);
10088 10104
10089 for_each_pipe(i) { 10105 for_each_pipe(i) {
10090 cpu_transcoder = intel_pipe_to_cpu_transcoder(dev_priv, i);
10091 error->pipe[i].cpu_transcoder = cpu_transcoder;
10092
10093 if (INTEL_INFO(dev)->gen <= 6 || IS_VALLEYVIEW(dev)) { 10106 if (INTEL_INFO(dev)->gen <= 6 || IS_VALLEYVIEW(dev)) {
10094 error->cursor[i].control = I915_READ(CURCNTR(i)); 10107 error->cursor[i].control = I915_READ(CURCNTR(i));
10095 error->cursor[i].position = I915_READ(CURPOS(i)); 10108 error->cursor[i].position = I915_READ(CURPOS(i));
@@ -10113,14 +10126,25 @@ intel_display_capture_error_state(struct drm_device *dev)
10113 error->plane[i].tile_offset = I915_READ(DSPTILEOFF(i)); 10126 error->plane[i].tile_offset = I915_READ(DSPTILEOFF(i));
10114 } 10127 }
10115 10128
10116 error->pipe[i].conf = I915_READ(PIPECONF(cpu_transcoder));
10117 error->pipe[i].source = I915_READ(PIPESRC(i)); 10129 error->pipe[i].source = I915_READ(PIPESRC(i));
10118 error->pipe[i].htotal = I915_READ(HTOTAL(cpu_transcoder)); 10130 }
10119 error->pipe[i].hblank = I915_READ(HBLANK(cpu_transcoder)); 10131
10120 error->pipe[i].hsync = I915_READ(HSYNC(cpu_transcoder)); 10132 error->num_transcoders = INTEL_INFO(dev)->num_pipes;
10121 error->pipe[i].vtotal = I915_READ(VTOTAL(cpu_transcoder)); 10133 if (HAS_DDI(dev_priv->dev))
10122 error->pipe[i].vblank = I915_READ(VBLANK(cpu_transcoder)); 10134 error->num_transcoders++; /* Account for eDP. */
10123 error->pipe[i].vsync = I915_READ(VSYNC(cpu_transcoder)); 10135
10136 for (i = 0; i < error->num_transcoders; i++) {
10137 enum transcoder cpu_transcoder = transcoders[i];
10138
10139 error->transcoder[i].cpu_transcoder = cpu_transcoder;
10140
10141 error->transcoder[i].conf = I915_READ(PIPECONF(cpu_transcoder));
10142 error->transcoder[i].htotal = I915_READ(HTOTAL(cpu_transcoder));
10143 error->transcoder[i].hblank = I915_READ(HBLANK(cpu_transcoder));
10144 error->transcoder[i].hsync = I915_READ(HSYNC(cpu_transcoder));
10145 error->transcoder[i].vtotal = I915_READ(VTOTAL(cpu_transcoder));
10146 error->transcoder[i].vblank = I915_READ(VBLANK(cpu_transcoder));
10147 error->transcoder[i].vsync = I915_READ(VSYNC(cpu_transcoder));
10124 } 10148 }
10125 10149
10126 /* In the code above we read the registers without checking if the power 10150 /* In the code above we read the registers without checking if the power
@@ -10142,22 +10166,16 @@ intel_display_print_error_state(struct drm_i915_error_state_buf *m,
10142{ 10166{
10143 int i; 10167 int i;
10144 10168
10169 if (!error)
10170 return;
10171
10145 err_printf(m, "Num Pipes: %d\n", INTEL_INFO(dev)->num_pipes); 10172 err_printf(m, "Num Pipes: %d\n", INTEL_INFO(dev)->num_pipes);
10146 if (HAS_POWER_WELL(dev)) 10173 if (HAS_POWER_WELL(dev))
10147 err_printf(m, "PWR_WELL_CTL2: %08x\n", 10174 err_printf(m, "PWR_WELL_CTL2: %08x\n",
10148 error->power_well_driver); 10175 error->power_well_driver);
10149 for_each_pipe(i) { 10176 for_each_pipe(i) {
10150 err_printf(m, "Pipe [%d]:\n", i); 10177 err_printf(m, "Pipe [%d]:\n", i);
10151 err_printf(m, " CPU transcoder: %c\n",
10152 transcoder_name(error->pipe[i].cpu_transcoder));
10153 err_printf(m, " CONF: %08x\n", error->pipe[i].conf);
10154 err_printf(m, " SRC: %08x\n", error->pipe[i].source); 10178 err_printf(m, " SRC: %08x\n", error->pipe[i].source);
10155 err_printf(m, " HTOTAL: %08x\n", error->pipe[i].htotal);
10156 err_printf(m, " HBLANK: %08x\n", error->pipe[i].hblank);
10157 err_printf(m, " HSYNC: %08x\n", error->pipe[i].hsync);
10158 err_printf(m, " VTOTAL: %08x\n", error->pipe[i].vtotal);
10159 err_printf(m, " VBLANK: %08x\n", error->pipe[i].vblank);
10160 err_printf(m, " VSYNC: %08x\n", error->pipe[i].vsync);
10161 10179
10162 err_printf(m, "Plane [%d]:\n", i); 10180 err_printf(m, "Plane [%d]:\n", i);
10163 err_printf(m, " CNTR: %08x\n", error->plane[i].control); 10181 err_printf(m, " CNTR: %08x\n", error->plane[i].control);
@@ -10178,5 +10196,17 @@ intel_display_print_error_state(struct drm_i915_error_state_buf *m,
10178 err_printf(m, " POS: %08x\n", error->cursor[i].position); 10196 err_printf(m, " POS: %08x\n", error->cursor[i].position);
10179 err_printf(m, " BASE: %08x\n", error->cursor[i].base); 10197 err_printf(m, " BASE: %08x\n", error->cursor[i].base);
10180 } 10198 }
10199
10200 for (i = 0; i < error->num_transcoders; i++) {
10201 err_printf(m, " CPU transcoder: %c\n",
10202 transcoder_name(error->transcoder[i].cpu_transcoder));
10203 err_printf(m, " CONF: %08x\n", error->transcoder[i].conf);
10204 err_printf(m, " HTOTAL: %08x\n", error->transcoder[i].htotal);
10205 err_printf(m, " HBLANK: %08x\n", error->transcoder[i].hblank);
10206 err_printf(m, " HSYNC: %08x\n", error->transcoder[i].hsync);
10207 err_printf(m, " VTOTAL: %08x\n", error->transcoder[i].vtotal);
10208 err_printf(m, " VBLANK: %08x\n", error->transcoder[i].vblank);
10209 err_printf(m, " VSYNC: %08x\n", error->transcoder[i].vsync);
10210 }
10181} 10211}
10182#endif 10212#endif
diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c
index 67e2c1f1c9a8..5950888ae1d0 100644
--- a/drivers/gpu/drm/i915/intel_panel.c
+++ b/drivers/gpu/drm/i915/intel_panel.c
@@ -497,8 +497,11 @@ void intel_panel_set_backlight(struct drm_device *dev, u32 level, u32 max)
497 goto out; 497 goto out;
498 } 498 }
499 499
500 /* scale to hardware */ 500 /* scale to hardware, but be careful to not overflow */
501 level = level * freq / max; 501 if (freq < max)
502 level = level * freq / max;
503 else
504 level = freq / max * level;
502 505
503 dev_priv->backlight.level = level; 506 dev_priv->backlight.level = level;
504 if (dev_priv->backlight.device) 507 if (dev_priv->backlight.device)
@@ -515,6 +518,17 @@ void intel_panel_disable_backlight(struct drm_device *dev)
515 struct drm_i915_private *dev_priv = dev->dev_private; 518 struct drm_i915_private *dev_priv = dev->dev_private;
516 unsigned long flags; 519 unsigned long flags;
517 520
521 /*
522 * Do not disable backlight on the vgaswitcheroo path. When switching
523 * away from i915, the other client may depend on i915 to handle the
524 * backlight. This will leave the backlight on unnecessarily when
525 * another client is not activated.
526 */
527 if (dev->switch_power_state == DRM_SWITCH_POWER_CHANGING) {
528 DRM_DEBUG_DRIVER("Skipping backlight disable on vga switch\n");
529 return;
530 }
531
518 spin_lock_irqsave(&dev_priv->backlight.lock, flags); 532 spin_lock_irqsave(&dev_priv->backlight.lock, flags);
519 533
520 dev_priv->backlight.enabled = false; 534 dev_priv->backlight.enabled = false;
diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
index f895d1508df8..b0e4a0bd1313 100644
--- a/drivers/gpu/drm/i915/intel_pm.c
+++ b/drivers/gpu/drm/i915/intel_pm.c
@@ -5063,8 +5063,26 @@ static void __intel_set_power_well(struct drm_device *dev, bool enable)
5063 } 5063 }
5064 } else { 5064 } else {
5065 if (enable_requested) { 5065 if (enable_requested) {
5066 unsigned long irqflags;
5067 enum pipe p;
5068
5066 I915_WRITE(HSW_PWR_WELL_DRIVER, 0); 5069 I915_WRITE(HSW_PWR_WELL_DRIVER, 0);
5070 POSTING_READ(HSW_PWR_WELL_DRIVER);
5067 DRM_DEBUG_KMS("Requesting to disable the power well\n"); 5071 DRM_DEBUG_KMS("Requesting to disable the power well\n");
5072
5073 /*
5074 * After this, the registers on the pipes that are part
5075 * of the power well will become zero, so we have to
5076 * adjust our counters according to that.
5077 *
5078 * FIXME: Should we do this in general in
5079 * drm_vblank_post_modeset?
5080 */
5081 spin_lock_irqsave(&dev->vbl_lock, irqflags);
5082 for_each_pipe(p)
5083 if (p != PIPE_A)
5084 dev->last_vblank[p] = 0;
5085 spin_unlock_irqrestore(&dev->vbl_lock, irqflags);
5068 } 5086 }
5069 } 5087 }
5070} 5088}
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
index 664118d8c1d6..079ef0129e74 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.c
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
@@ -968,6 +968,18 @@ void intel_ring_setup_status_page(struct intel_ring_buffer *ring)
968 968
969 I915_WRITE(mmio, (u32)ring->status_page.gfx_addr); 969 I915_WRITE(mmio, (u32)ring->status_page.gfx_addr);
970 POSTING_READ(mmio); 970 POSTING_READ(mmio);
971
972 /* Flush the TLB for this page */
973 if (INTEL_INFO(dev)->gen >= 6) {
974 u32 reg = RING_INSTPM(ring->mmio_base);
975 I915_WRITE(reg,
976 _MASKED_BIT_ENABLE(INSTPM_TLB_INVALIDATE |
977 INSTPM_SYNC_FLUSH));
978 if (wait_for((I915_READ(reg) & INSTPM_SYNC_FLUSH) == 0,
979 1000))
980 DRM_ERROR("%s: wait for SyncFlush to complete for TLB invalidation timed out\n",
981 ring->name);
982 }
971} 983}
972 984
973static int 985static int
diff --git a/drivers/gpu/drm/mgag200/mgag200_ttm.c b/drivers/gpu/drm/mgag200/mgag200_ttm.c
index 13878d5de063..d70e4a92773b 100644
--- a/drivers/gpu/drm/mgag200/mgag200_ttm.c
+++ b/drivers/gpu/drm/mgag200/mgag200_ttm.c
@@ -323,6 +323,7 @@ int mgag200_bo_create(struct drm_device *dev, int size, int align,
323 323
324 mgabo->gem.driver_private = NULL; 324 mgabo->gem.driver_private = NULL;
325 mgabo->bo.bdev = &mdev->ttm.bdev; 325 mgabo->bo.bdev = &mdev->ttm.bdev;
326 mgabo->bo.bdev->dev_mapping = dev->dev_mapping;
326 327
327 mgag200_ttm_placement(mgabo, TTM_PL_FLAG_VRAM | TTM_PL_FLAG_SYSTEM); 328 mgag200_ttm_placement(mgabo, TTM_PL_FLAG_VRAM | TTM_PL_FLAG_SYSTEM);
328 329
diff --git a/drivers/gpu/drm/nouveau/core/core/mm.c b/drivers/gpu/drm/nouveau/core/core/mm.c
index d8291724dbd4..7a4e0891c5f8 100644
--- a/drivers/gpu/drm/nouveau/core/core/mm.c
+++ b/drivers/gpu/drm/nouveau/core/core/mm.c
@@ -98,6 +98,8 @@ nouveau_mm_head(struct nouveau_mm *mm, u8 type, u32 size_max, u32 size_min,
98 u32 splitoff; 98 u32 splitoff;
99 u32 s, e; 99 u32 s, e;
100 100
101 BUG_ON(!type);
102
101 list_for_each_entry(this, &mm->free, fl_entry) { 103 list_for_each_entry(this, &mm->free, fl_entry) {
102 e = this->offset + this->length; 104 e = this->offset + this->length;
103 s = this->offset; 105 s = this->offset;
@@ -162,6 +164,8 @@ nouveau_mm_tail(struct nouveau_mm *mm, u8 type, u32 size_max, u32 size_min,
162 struct nouveau_mm_node *prev, *this, *next; 164 struct nouveau_mm_node *prev, *this, *next;
163 u32 mask = align - 1; 165 u32 mask = align - 1;
164 166
167 BUG_ON(!type);
168
165 list_for_each_entry_reverse(this, &mm->free, fl_entry) { 169 list_for_each_entry_reverse(this, &mm->free, fl_entry) {
166 u32 e = this->offset + this->length; 170 u32 e = this->offset + this->length;
167 u32 s = this->offset; 171 u32 s = this->offset;
diff --git a/drivers/gpu/drm/nouveau/core/include/subdev/mc.h b/drivers/gpu/drm/nouveau/core/include/subdev/mc.h
index d5502267c30f..9d2cd2006250 100644
--- a/drivers/gpu/drm/nouveau/core/include/subdev/mc.h
+++ b/drivers/gpu/drm/nouveau/core/include/subdev/mc.h
@@ -20,8 +20,8 @@ nouveau_mc(void *obj)
20 return (void *)nv_device(obj)->subdev[NVDEV_SUBDEV_MC]; 20 return (void *)nv_device(obj)->subdev[NVDEV_SUBDEV_MC];
21} 21}
22 22
23#define nouveau_mc_create(p,e,o,d) \ 23#define nouveau_mc_create(p,e,o,m,d) \
24 nouveau_mc_create_((p), (e), (o), sizeof(**d), (void **)d) 24 nouveau_mc_create_((p), (e), (o), (m), sizeof(**d), (void **)d)
25#define nouveau_mc_destroy(p) ({ \ 25#define nouveau_mc_destroy(p) ({ \
26 struct nouveau_mc *pmc = (p); _nouveau_mc_dtor(nv_object(pmc)); \ 26 struct nouveau_mc *pmc = (p); _nouveau_mc_dtor(nv_object(pmc)); \
27}) 27})
@@ -33,7 +33,8 @@ nouveau_mc(void *obj)
33}) 33})
34 34
35int nouveau_mc_create_(struct nouveau_object *, struct nouveau_object *, 35int nouveau_mc_create_(struct nouveau_object *, struct nouveau_object *,
36 struct nouveau_oclass *, int, void **); 36 struct nouveau_oclass *, const struct nouveau_mc_intr *,
37 int, void **);
37void _nouveau_mc_dtor(struct nouveau_object *); 38void _nouveau_mc_dtor(struct nouveau_object *);
38int _nouveau_mc_init(struct nouveau_object *); 39int _nouveau_mc_init(struct nouveau_object *);
39int _nouveau_mc_fini(struct nouveau_object *, bool); 40int _nouveau_mc_fini(struct nouveau_object *, bool);
diff --git a/drivers/gpu/drm/nouveau/core/subdev/fb/ramnv49.c b/drivers/gpu/drm/nouveau/core/subdev/fb/ramnv49.c
index 19e3a9a63a02..ab7ef0ac9e34 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/fb/ramnv49.c
+++ b/drivers/gpu/drm/nouveau/core/subdev/fb/ramnv49.c
@@ -40,15 +40,15 @@ nv49_ram_create(struct nouveau_object *parent, struct nouveau_object *engine,
40 return ret; 40 return ret;
41 41
42 switch (pfb914 & 0x00000003) { 42 switch (pfb914 & 0x00000003) {
43 case 0x00000000: pfb->ram->type = NV_MEM_TYPE_DDR1; break; 43 case 0x00000000: ram->type = NV_MEM_TYPE_DDR1; break;
44 case 0x00000001: pfb->ram->type = NV_MEM_TYPE_DDR2; break; 44 case 0x00000001: ram->type = NV_MEM_TYPE_DDR2; break;
45 case 0x00000002: pfb->ram->type = NV_MEM_TYPE_GDDR3; break; 45 case 0x00000002: ram->type = NV_MEM_TYPE_GDDR3; break;
46 case 0x00000003: break; 46 case 0x00000003: break;
47 } 47 }
48 48
49 pfb->ram->size = nv_rd32(pfb, 0x10020c) & 0xff000000; 49 ram->size = nv_rd32(pfb, 0x10020c) & 0xff000000;
50 pfb->ram->parts = (nv_rd32(pfb, 0x100200) & 0x00000003) + 1; 50 ram->parts = (nv_rd32(pfb, 0x100200) & 0x00000003) + 1;
51 pfb->ram->tags = nv_rd32(pfb, 0x100320); 51 ram->tags = nv_rd32(pfb, 0x100320);
52 return 0; 52 return 0;
53} 53}
54 54
diff --git a/drivers/gpu/drm/nouveau/core/subdev/fb/ramnv4e.c b/drivers/gpu/drm/nouveau/core/subdev/fb/ramnv4e.c
index 7192aa6e5577..63a6aab86028 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/fb/ramnv4e.c
+++ b/drivers/gpu/drm/nouveau/core/subdev/fb/ramnv4e.c
@@ -38,8 +38,8 @@ nv4e_ram_create(struct nouveau_object *parent, struct nouveau_object *engine,
38 if (ret) 38 if (ret)
39 return ret; 39 return ret;
40 40
41 pfb->ram->size = nv_rd32(pfb, 0x10020c) & 0xff000000; 41 ram->size = nv_rd32(pfb, 0x10020c) & 0xff000000;
42 pfb->ram->type = NV_MEM_TYPE_STOLEN; 42 ram->type = NV_MEM_TYPE_STOLEN;
43 return 0; 43 return 0;
44} 44}
45 45
diff --git a/drivers/gpu/drm/nouveau/core/subdev/ltcg/nvc0.c b/drivers/gpu/drm/nouveau/core/subdev/ltcg/nvc0.c
index bcca883018f4..cce65cc56514 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/ltcg/nvc0.c
+++ b/drivers/gpu/drm/nouveau/core/subdev/ltcg/nvc0.c
@@ -30,8 +30,9 @@ struct nvc0_ltcg_priv {
30 struct nouveau_ltcg base; 30 struct nouveau_ltcg base;
31 u32 part_nr; 31 u32 part_nr;
32 u32 subp_nr; 32 u32 subp_nr;
33 struct nouveau_mm tags;
34 u32 num_tags; 33 u32 num_tags;
34 u32 tag_base;
35 struct nouveau_mm tags;
35 struct nouveau_mm_node *tag_ram; 36 struct nouveau_mm_node *tag_ram;
36}; 37};
37 38
@@ -117,10 +118,6 @@ nvc0_ltcg_init_tag_ram(struct nouveau_fb *pfb, struct nvc0_ltcg_priv *priv)
117 u32 tag_size, tag_margin, tag_align; 118 u32 tag_size, tag_margin, tag_align;
118 int ret; 119 int ret;
119 120
120 nv_wr32(priv, 0x17e8d8, priv->part_nr);
121 if (nv_device(pfb)->card_type >= NV_E0)
122 nv_wr32(priv, 0x17e000, priv->part_nr);
123
124 /* tags for 1/4 of VRAM should be enough (8192/4 per GiB of VRAM) */ 121 /* tags for 1/4 of VRAM should be enough (8192/4 per GiB of VRAM) */
125 priv->num_tags = (pfb->ram->size >> 17) / 4; 122 priv->num_tags = (pfb->ram->size >> 17) / 4;
126 if (priv->num_tags > (1 << 17)) 123 if (priv->num_tags > (1 << 17))
@@ -142,7 +139,7 @@ nvc0_ltcg_init_tag_ram(struct nouveau_fb *pfb, struct nvc0_ltcg_priv *priv)
142 tag_size += tag_align; 139 tag_size += tag_align;
143 tag_size = (tag_size + 0xfff) >> 12; /* round up */ 140 tag_size = (tag_size + 0xfff) >> 12; /* round up */
144 141
145 ret = nouveau_mm_tail(&pfb->vram, 0, tag_size, tag_size, 1, 142 ret = nouveau_mm_tail(&pfb->vram, 1, tag_size, tag_size, 1,
146 &priv->tag_ram); 143 &priv->tag_ram);
147 if (ret) { 144 if (ret) {
148 priv->num_tags = 0; 145 priv->num_tags = 0;
@@ -152,7 +149,7 @@ nvc0_ltcg_init_tag_ram(struct nouveau_fb *pfb, struct nvc0_ltcg_priv *priv)
152 tag_base += tag_align - 1; 149 tag_base += tag_align - 1;
153 ret = do_div(tag_base, tag_align); 150 ret = do_div(tag_base, tag_align);
154 151
155 nv_wr32(priv, 0x17e8d4, tag_base); 152 priv->tag_base = tag_base;
156 } 153 }
157 ret = nouveau_mm_init(&priv->tags, 0, priv->num_tags, 1); 154 ret = nouveau_mm_init(&priv->tags, 0, priv->num_tags, 1);
158 155
@@ -182,8 +179,6 @@ nvc0_ltcg_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
182 } 179 }
183 priv->subp_nr = nv_rd32(priv, 0x17e8dc) >> 28; 180 priv->subp_nr = nv_rd32(priv, 0x17e8dc) >> 28;
184 181
185 nv_mask(priv, 0x17e820, 0x00100000, 0x00000000); /* INTR_EN &= ~0x10 */
186
187 ret = nvc0_ltcg_init_tag_ram(pfb, priv); 182 ret = nvc0_ltcg_init_tag_ram(pfb, priv);
188 if (ret) 183 if (ret)
189 return ret; 184 return ret;
@@ -209,13 +204,32 @@ nvc0_ltcg_dtor(struct nouveau_object *object)
209 nouveau_ltcg_destroy(ltcg); 204 nouveau_ltcg_destroy(ltcg);
210} 205}
211 206
207static int
208nvc0_ltcg_init(struct nouveau_object *object)
209{
210 struct nouveau_ltcg *ltcg = (struct nouveau_ltcg *)object;
211 struct nvc0_ltcg_priv *priv = (struct nvc0_ltcg_priv *)ltcg;
212 int ret;
213
214 ret = nouveau_ltcg_init(ltcg);
215 if (ret)
216 return ret;
217
218 nv_mask(priv, 0x17e820, 0x00100000, 0x00000000); /* INTR_EN &= ~0x10 */
219 nv_wr32(priv, 0x17e8d8, priv->part_nr);
220 if (nv_device(ltcg)->card_type >= NV_E0)
221 nv_wr32(priv, 0x17e000, priv->part_nr);
222 nv_wr32(priv, 0x17e8d4, priv->tag_base);
223 return 0;
224}
225
212struct nouveau_oclass 226struct nouveau_oclass
213nvc0_ltcg_oclass = { 227nvc0_ltcg_oclass = {
214 .handle = NV_SUBDEV(LTCG, 0xc0), 228 .handle = NV_SUBDEV(LTCG, 0xc0),
215 .ofuncs = &(struct nouveau_ofuncs) { 229 .ofuncs = &(struct nouveau_ofuncs) {
216 .ctor = nvc0_ltcg_ctor, 230 .ctor = nvc0_ltcg_ctor,
217 .dtor = nvc0_ltcg_dtor, 231 .dtor = nvc0_ltcg_dtor,
218 .init = _nouveau_ltcg_init, 232 .init = nvc0_ltcg_init,
219 .fini = _nouveau_ltcg_fini, 233 .fini = _nouveau_ltcg_fini,
220 }, 234 },
221}; 235};
diff --git a/drivers/gpu/drm/nouveau/core/subdev/mc/base.c b/drivers/gpu/drm/nouveau/core/subdev/mc/base.c
index 1c0330b8c9a4..ec9cd6f10f91 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/mc/base.c
+++ b/drivers/gpu/drm/nouveau/core/subdev/mc/base.c
@@ -80,7 +80,9 @@ _nouveau_mc_dtor(struct nouveau_object *object)
80 80
81int 81int
82nouveau_mc_create_(struct nouveau_object *parent, struct nouveau_object *engine, 82nouveau_mc_create_(struct nouveau_object *parent, struct nouveau_object *engine,
83 struct nouveau_oclass *oclass, int length, void **pobject) 83 struct nouveau_oclass *oclass,
84 const struct nouveau_mc_intr *intr_map,
85 int length, void **pobject)
84{ 86{
85 struct nouveau_device *device = nv_device(parent); 87 struct nouveau_device *device = nv_device(parent);
86 struct nouveau_mc *pmc; 88 struct nouveau_mc *pmc;
@@ -92,6 +94,8 @@ nouveau_mc_create_(struct nouveau_object *parent, struct nouveau_object *engine,
92 if (ret) 94 if (ret)
93 return ret; 95 return ret;
94 96
97 pmc->intr_map = intr_map;
98
95 ret = request_irq(device->pdev->irq, nouveau_mc_intr, 99 ret = request_irq(device->pdev->irq, nouveau_mc_intr,
96 IRQF_SHARED, "nouveau", pmc); 100 IRQF_SHARED, "nouveau", pmc);
97 if (ret < 0) 101 if (ret < 0)
diff --git a/drivers/gpu/drm/nouveau/core/subdev/mc/nv04.c b/drivers/gpu/drm/nouveau/core/subdev/mc/nv04.c
index 8c769715227b..64aa4edb0d9d 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/mc/nv04.c
+++ b/drivers/gpu/drm/nouveau/core/subdev/mc/nv04.c
@@ -50,12 +50,11 @@ nv04_mc_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
50 struct nv04_mc_priv *priv; 50 struct nv04_mc_priv *priv;
51 int ret; 51 int ret;
52 52
53 ret = nouveau_mc_create(parent, engine, oclass, &priv); 53 ret = nouveau_mc_create(parent, engine, oclass, nv04_mc_intr, &priv);
54 *pobject = nv_object(priv); 54 *pobject = nv_object(priv);
55 if (ret) 55 if (ret)
56 return ret; 56 return ret;
57 57
58 priv->base.intr_map = nv04_mc_intr;
59 return 0; 58 return 0;
60} 59}
61 60
diff --git a/drivers/gpu/drm/nouveau/core/subdev/mc/nv44.c b/drivers/gpu/drm/nouveau/core/subdev/mc/nv44.c
index 51919371810f..d9891782bf28 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/mc/nv44.c
+++ b/drivers/gpu/drm/nouveau/core/subdev/mc/nv44.c
@@ -36,12 +36,11 @@ nv44_mc_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
36 struct nv44_mc_priv *priv; 36 struct nv44_mc_priv *priv;
37 int ret; 37 int ret;
38 38
39 ret = nouveau_mc_create(parent, engine, oclass, &priv); 39 ret = nouveau_mc_create(parent, engine, oclass, nv04_mc_intr, &priv);
40 *pobject = nv_object(priv); 40 *pobject = nv_object(priv);
41 if (ret) 41 if (ret)
42 return ret; 42 return ret;
43 43
44 priv->base.intr_map = nv04_mc_intr;
45 return 0; 44 return 0;
46} 45}
47 46
diff --git a/drivers/gpu/drm/nouveau/core/subdev/mc/nv50.c b/drivers/gpu/drm/nouveau/core/subdev/mc/nv50.c
index f25fc5fc7dd1..2b1afe225db8 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/mc/nv50.c
+++ b/drivers/gpu/drm/nouveau/core/subdev/mc/nv50.c
@@ -53,12 +53,11 @@ nv50_mc_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
53 struct nv50_mc_priv *priv; 53 struct nv50_mc_priv *priv;
54 int ret; 54 int ret;
55 55
56 ret = nouveau_mc_create(parent, engine, oclass, &priv); 56 ret = nouveau_mc_create(parent, engine, oclass, nv50_mc_intr, &priv);
57 *pobject = nv_object(priv); 57 *pobject = nv_object(priv);
58 if (ret) 58 if (ret)
59 return ret; 59 return ret;
60 60
61 priv->base.intr_map = nv50_mc_intr;
62 return 0; 61 return 0;
63} 62}
64 63
diff --git a/drivers/gpu/drm/nouveau/core/subdev/mc/nv98.c b/drivers/gpu/drm/nouveau/core/subdev/mc/nv98.c
index e82fd21b5041..0d57b4d3e001 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/mc/nv98.c
+++ b/drivers/gpu/drm/nouveau/core/subdev/mc/nv98.c
@@ -54,12 +54,11 @@ nv98_mc_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
54 struct nv98_mc_priv *priv; 54 struct nv98_mc_priv *priv;
55 int ret; 55 int ret;
56 56
57 ret = nouveau_mc_create(parent, engine, oclass, &priv); 57 ret = nouveau_mc_create(parent, engine, oclass, nv98_mc_intr, &priv);
58 *pobject = nv_object(priv); 58 *pobject = nv_object(priv);
59 if (ret) 59 if (ret)
60 return ret; 60 return ret;
61 61
62 priv->base.intr_map = nv98_mc_intr;
63 return 0; 62 return 0;
64} 63}
65 64
diff --git a/drivers/gpu/drm/nouveau/core/subdev/mc/nvc0.c b/drivers/gpu/drm/nouveau/core/subdev/mc/nvc0.c
index c5da3babbc62..104175c5a2dd 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/mc/nvc0.c
+++ b/drivers/gpu/drm/nouveau/core/subdev/mc/nvc0.c
@@ -57,12 +57,11 @@ nvc0_mc_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
57 struct nvc0_mc_priv *priv; 57 struct nvc0_mc_priv *priv;
58 int ret; 58 int ret;
59 59
60 ret = nouveau_mc_create(parent, engine, oclass, &priv); 60 ret = nouveau_mc_create(parent, engine, oclass, nvc0_mc_intr, &priv);
61 *pobject = nv_object(priv); 61 *pobject = nv_object(priv);
62 if (ret) 62 if (ret)
63 return ret; 63 return ret;
64 64
65 priv->base.intr_map = nvc0_mc_intr;
66 return 0; 65 return 0;
67} 66}
68 67
diff --git a/drivers/gpu/drm/nouveau/dispnv04/crtc.c b/drivers/gpu/drm/nouveau/dispnv04/crtc.c
index 0782bd2f1e04..6a13ffb53bdb 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/crtc.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/crtc.c
@@ -606,6 +606,24 @@ nv_crtc_mode_set_regs(struct drm_crtc *crtc, struct drm_display_mode * mode)
606 regp->ramdac_a34 = 0x1; 606 regp->ramdac_a34 = 0x1;
607} 607}
608 608
609static int
610nv_crtc_swap_fbs(struct drm_crtc *crtc, struct drm_framebuffer *old_fb)
611{
612 struct nv04_display *disp = nv04_display(crtc->dev);
613 struct nouveau_framebuffer *nvfb = nouveau_framebuffer(crtc->fb);
614 struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
615 int ret;
616
617 ret = nouveau_bo_pin(nvfb->nvbo, TTM_PL_FLAG_VRAM);
618 if (ret == 0) {
619 if (disp->image[nv_crtc->index])
620 nouveau_bo_unpin(disp->image[nv_crtc->index]);
621 nouveau_bo_ref(nvfb->nvbo, &disp->image[nv_crtc->index]);
622 }
623
624 return ret;
625}
626
609/** 627/**
610 * Sets up registers for the given mode/adjusted_mode pair. 628 * Sets up registers for the given mode/adjusted_mode pair.
611 * 629 *
@@ -622,10 +640,15 @@ nv_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mode,
622 struct drm_device *dev = crtc->dev; 640 struct drm_device *dev = crtc->dev;
623 struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); 641 struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
624 struct nouveau_drm *drm = nouveau_drm(dev); 642 struct nouveau_drm *drm = nouveau_drm(dev);
643 int ret;
625 644
626 NV_DEBUG(drm, "CTRC mode on CRTC %d:\n", nv_crtc->index); 645 NV_DEBUG(drm, "CTRC mode on CRTC %d:\n", nv_crtc->index);
627 drm_mode_debug_printmodeline(adjusted_mode); 646 drm_mode_debug_printmodeline(adjusted_mode);
628 647
648 ret = nv_crtc_swap_fbs(crtc, old_fb);
649 if (ret)
650 return ret;
651
629 /* unlock must come after turning off FP_TG_CONTROL in output_prepare */ 652 /* unlock must come after turning off FP_TG_CONTROL in output_prepare */
630 nv_lock_vga_crtc_shadow(dev, nv_crtc->index, -1); 653 nv_lock_vga_crtc_shadow(dev, nv_crtc->index, -1);
631 654
@@ -722,6 +745,7 @@ static void nv_crtc_commit(struct drm_crtc *crtc)
722 745
723static void nv_crtc_destroy(struct drm_crtc *crtc) 746static void nv_crtc_destroy(struct drm_crtc *crtc)
724{ 747{
748 struct nv04_display *disp = nv04_display(crtc->dev);
725 struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); 749 struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
726 750
727 if (!nv_crtc) 751 if (!nv_crtc)
@@ -729,6 +753,10 @@ static void nv_crtc_destroy(struct drm_crtc *crtc)
729 753
730 drm_crtc_cleanup(crtc); 754 drm_crtc_cleanup(crtc);
731 755
756 if (disp->image[nv_crtc->index])
757 nouveau_bo_unpin(disp->image[nv_crtc->index]);
758 nouveau_bo_ref(NULL, &disp->image[nv_crtc->index]);
759
732 nouveau_bo_unmap(nv_crtc->cursor.nvbo); 760 nouveau_bo_unmap(nv_crtc->cursor.nvbo);
733 nouveau_bo_unpin(nv_crtc->cursor.nvbo); 761 nouveau_bo_unpin(nv_crtc->cursor.nvbo);
734 nouveau_bo_ref(NULL, &nv_crtc->cursor.nvbo); 762 nouveau_bo_ref(NULL, &nv_crtc->cursor.nvbo);
@@ -754,6 +782,16 @@ nv_crtc_gamma_load(struct drm_crtc *crtc)
754} 782}
755 783
756static void 784static void
785nv_crtc_disable(struct drm_crtc *crtc)
786{
787 struct nv04_display *disp = nv04_display(crtc->dev);
788 struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
789 if (disp->image[nv_crtc->index])
790 nouveau_bo_unpin(disp->image[nv_crtc->index]);
791 nouveau_bo_ref(NULL, &disp->image[nv_crtc->index]);
792}
793
794static void
757nv_crtc_gamma_set(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b, uint32_t start, 795nv_crtc_gamma_set(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b, uint32_t start,
758 uint32_t size) 796 uint32_t size)
759{ 797{
@@ -791,7 +829,6 @@ nv04_crtc_do_mode_set_base(struct drm_crtc *crtc,
791 struct drm_framebuffer *drm_fb; 829 struct drm_framebuffer *drm_fb;
792 struct nouveau_framebuffer *fb; 830 struct nouveau_framebuffer *fb;
793 int arb_burst, arb_lwm; 831 int arb_burst, arb_lwm;
794 int ret;
795 832
796 NV_DEBUG(drm, "index %d\n", nv_crtc->index); 833 NV_DEBUG(drm, "index %d\n", nv_crtc->index);
797 834
@@ -801,10 +838,8 @@ nv04_crtc_do_mode_set_base(struct drm_crtc *crtc,
801 return 0; 838 return 0;
802 } 839 }
803 840
804
805 /* If atomic, we want to switch to the fb we were passed, so 841 /* If atomic, we want to switch to the fb we were passed, so
806 * now we update pointers to do that. (We don't pin; just 842 * now we update pointers to do that.
807 * assume we're already pinned and update the base address.)
808 */ 843 */
809 if (atomic) { 844 if (atomic) {
810 drm_fb = passed_fb; 845 drm_fb = passed_fb;
@@ -812,17 +847,6 @@ nv04_crtc_do_mode_set_base(struct drm_crtc *crtc,
812 } else { 847 } else {
813 drm_fb = crtc->fb; 848 drm_fb = crtc->fb;
814 fb = nouveau_framebuffer(crtc->fb); 849 fb = nouveau_framebuffer(crtc->fb);
815 /* If not atomic, we can go ahead and pin, and unpin the
816 * old fb we were passed.
817 */
818 ret = nouveau_bo_pin(fb->nvbo, TTM_PL_FLAG_VRAM);
819 if (ret)
820 return ret;
821
822 if (passed_fb) {
823 struct nouveau_framebuffer *ofb = nouveau_framebuffer(passed_fb);
824 nouveau_bo_unpin(ofb->nvbo);
825 }
826 } 850 }
827 851
828 nv_crtc->fb.offset = fb->nvbo->bo.offset; 852 nv_crtc->fb.offset = fb->nvbo->bo.offset;
@@ -877,6 +901,9 @@ static int
877nv04_crtc_mode_set_base(struct drm_crtc *crtc, int x, int y, 901nv04_crtc_mode_set_base(struct drm_crtc *crtc, int x, int y,
878 struct drm_framebuffer *old_fb) 902 struct drm_framebuffer *old_fb)
879{ 903{
904 int ret = nv_crtc_swap_fbs(crtc, old_fb);
905 if (ret)
906 return ret;
880 return nv04_crtc_do_mode_set_base(crtc, old_fb, x, y, false); 907 return nv04_crtc_do_mode_set_base(crtc, old_fb, x, y, false);
881} 908}
882 909
@@ -1027,6 +1054,7 @@ static const struct drm_crtc_helper_funcs nv04_crtc_helper_funcs = {
1027 .mode_set_base = nv04_crtc_mode_set_base, 1054 .mode_set_base = nv04_crtc_mode_set_base,
1028 .mode_set_base_atomic = nv04_crtc_mode_set_base_atomic, 1055 .mode_set_base_atomic = nv04_crtc_mode_set_base_atomic,
1029 .load_lut = nv_crtc_gamma_load, 1056 .load_lut = nv_crtc_gamma_load,
1057 .disable = nv_crtc_disable,
1030}; 1058};
1031 1059
1032int 1060int
diff --git a/drivers/gpu/drm/nouveau/dispnv04/disp.h b/drivers/gpu/drm/nouveau/dispnv04/disp.h
index a0a031dad13f..9928187f0a7d 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/disp.h
+++ b/drivers/gpu/drm/nouveau/dispnv04/disp.h
@@ -81,6 +81,7 @@ struct nv04_display {
81 uint32_t saved_vga_font[4][16384]; 81 uint32_t saved_vga_font[4][16384];
82 uint32_t dac_users[4]; 82 uint32_t dac_users[4];
83 struct nouveau_object *core; 83 struct nouveau_object *core;
84 struct nouveau_bo *image[2];
84}; 85};
85 86
86static inline struct nv04_display * 87static inline struct nv04_display *
diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c b/drivers/gpu/drm/nouveau/nouveau_display.c
index 907d20ef6d4d..a03e75deacaf 100644
--- a/drivers/gpu/drm/nouveau/nouveau_display.c
+++ b/drivers/gpu/drm/nouveau/nouveau_display.c
@@ -577,6 +577,9 @@ nouveau_crtc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb,
577 ret = nv50_display_flip_next(crtc, fb, chan, 0); 577 ret = nv50_display_flip_next(crtc, fb, chan, 0);
578 if (ret) 578 if (ret)
579 goto fail_unreserve; 579 goto fail_unreserve;
580 } else {
581 struct nv04_display *dispnv04 = nv04_display(dev);
582 nouveau_bo_ref(new_bo, &dispnv04->image[nouveau_crtc(crtc)->index]);
580 } 583 }
581 584
582 ret = nouveau_page_flip_emit(chan, old_bo, new_bo, s, &fence); 585 ret = nouveau_page_flip_emit(chan, old_bo, new_bo, s, &fence);
diff --git a/drivers/gpu/drm/nouveau/nv40_pm.c b/drivers/gpu/drm/nouveau/nv40_pm.c
index 3af5bcd0b203..625f80d53dc2 100644
--- a/drivers/gpu/drm/nouveau/nv40_pm.c
+++ b/drivers/gpu/drm/nouveau/nv40_pm.c
@@ -131,7 +131,7 @@ nv40_calc_pll(struct drm_device *dev, u32 reg, struct nvbios_pll *pll,
131 if (clk < pll->vco1.max_freq) 131 if (clk < pll->vco1.max_freq)
132 pll->vco2.max_freq = 0; 132 pll->vco2.max_freq = 0;
133 133
134 pclk->pll_calc(pclk, pll, clk, &coef); 134 ret = pclk->pll_calc(pclk, pll, clk, &coef);
135 if (ret == 0) 135 if (ret == 0)
136 return -ERANGE; 136 return -ERANGE;
137 137
diff --git a/drivers/gpu/drm/radeon/btc_dpm.c b/drivers/gpu/drm/radeon/btc_dpm.c
index 0bfd55e08820..9953e1fbc46d 100644
--- a/drivers/gpu/drm/radeon/btc_dpm.c
+++ b/drivers/gpu/drm/radeon/btc_dpm.c
@@ -2548,9 +2548,6 @@ int btc_dpm_init(struct radeon_device *rdev)
2548{ 2548{
2549 struct rv7xx_power_info *pi; 2549 struct rv7xx_power_info *pi;
2550 struct evergreen_power_info *eg_pi; 2550 struct evergreen_power_info *eg_pi;
2551 int index = GetIndexIntoMasterTable(DATA, ASIC_InternalSS_Info);
2552 u16 data_offset, size;
2553 u8 frev, crev;
2554 struct atom_clock_dividers dividers; 2551 struct atom_clock_dividers dividers;
2555 int ret; 2552 int ret;
2556 2553
@@ -2633,16 +2630,7 @@ int btc_dpm_init(struct radeon_device *rdev)
2633 eg_pi->vddci_control = 2630 eg_pi->vddci_control =
2634 radeon_atom_is_voltage_gpio(rdev, SET_VOLTAGE_TYPE_ASIC_VDDCI, 0); 2631 radeon_atom_is_voltage_gpio(rdev, SET_VOLTAGE_TYPE_ASIC_VDDCI, 0);
2635 2632
2636 if (atom_parse_data_header(rdev->mode_info.atom_context, index, &size, 2633 rv770_get_engine_memory_ss(rdev);
2637 &frev, &crev, &data_offset)) {
2638 pi->sclk_ss = true;
2639 pi->mclk_ss = true;
2640 pi->dynamic_ss = true;
2641 } else {
2642 pi->sclk_ss = false;
2643 pi->mclk_ss = false;
2644 pi->dynamic_ss = true;
2645 }
2646 2634
2647 pi->asi = RV770_ASI_DFLT; 2635 pi->asi = RV770_ASI_DFLT;
2648 pi->pasi = CYPRESS_HASI_DFLT; 2636 pi->pasi = CYPRESS_HASI_DFLT;
@@ -2659,8 +2647,7 @@ int btc_dpm_init(struct radeon_device *rdev)
2659 2647
2660 pi->dynamic_pcie_gen2 = true; 2648 pi->dynamic_pcie_gen2 = true;
2661 2649
2662 if (pi->gfx_clock_gating && 2650 if (rdev->pm.int_thermal_type != THERMAL_TYPE_NONE)
2663 (rdev->pm.int_thermal_type != THERMAL_TYPE_NONE))
2664 pi->thermal_protection = true; 2651 pi->thermal_protection = true;
2665 else 2652 else
2666 pi->thermal_protection = false; 2653 pi->thermal_protection = false;
diff --git a/drivers/gpu/drm/radeon/cik.c b/drivers/gpu/drm/radeon/cik.c
index 6dacec4e2090..8928bd109c16 100644
--- a/drivers/gpu/drm/radeon/cik.c
+++ b/drivers/gpu/drm/radeon/cik.c
@@ -2587,9 +2587,11 @@ u32 cik_compute_ring_get_rptr(struct radeon_device *rdev,
2587 if (rdev->wb.enabled) { 2587 if (rdev->wb.enabled) {
2588 rptr = le32_to_cpu(rdev->wb.wb[ring->rptr_offs/4]); 2588 rptr = le32_to_cpu(rdev->wb.wb[ring->rptr_offs/4]);
2589 } else { 2589 } else {
2590 mutex_lock(&rdev->srbm_mutex);
2590 cik_srbm_select(rdev, ring->me, ring->pipe, ring->queue, 0); 2591 cik_srbm_select(rdev, ring->me, ring->pipe, ring->queue, 0);
2591 rptr = RREG32(CP_HQD_PQ_RPTR); 2592 rptr = RREG32(CP_HQD_PQ_RPTR);
2592 cik_srbm_select(rdev, 0, 0, 0, 0); 2593 cik_srbm_select(rdev, 0, 0, 0, 0);
2594 mutex_unlock(&rdev->srbm_mutex);
2593 } 2595 }
2594 rptr = (rptr & ring->ptr_reg_mask) >> ring->ptr_reg_shift; 2596 rptr = (rptr & ring->ptr_reg_mask) >> ring->ptr_reg_shift;
2595 2597
@@ -2604,9 +2606,11 @@ u32 cik_compute_ring_get_wptr(struct radeon_device *rdev,
2604 if (rdev->wb.enabled) { 2606 if (rdev->wb.enabled) {
2605 wptr = le32_to_cpu(rdev->wb.wb[ring->wptr_offs/4]); 2607 wptr = le32_to_cpu(rdev->wb.wb[ring->wptr_offs/4]);
2606 } else { 2608 } else {
2609 mutex_lock(&rdev->srbm_mutex);
2607 cik_srbm_select(rdev, ring->me, ring->pipe, ring->queue, 0); 2610 cik_srbm_select(rdev, ring->me, ring->pipe, ring->queue, 0);
2608 wptr = RREG32(CP_HQD_PQ_WPTR); 2611 wptr = RREG32(CP_HQD_PQ_WPTR);
2609 cik_srbm_select(rdev, 0, 0, 0, 0); 2612 cik_srbm_select(rdev, 0, 0, 0, 0);
2613 mutex_unlock(&rdev->srbm_mutex);
2610 } 2614 }
2611 wptr = (wptr & ring->ptr_reg_mask) >> ring->ptr_reg_shift; 2615 wptr = (wptr & ring->ptr_reg_mask) >> ring->ptr_reg_shift;
2612 2616
@@ -2897,6 +2901,7 @@ static int cik_cp_compute_resume(struct radeon_device *rdev)
2897 WREG32(CP_CPF_DEBUG, tmp); 2901 WREG32(CP_CPF_DEBUG, tmp);
2898 2902
2899 /* init the pipes */ 2903 /* init the pipes */
2904 mutex_lock(&rdev->srbm_mutex);
2900 for (i = 0; i < (rdev->mec.num_pipe * rdev->mec.num_mec); i++) { 2905 for (i = 0; i < (rdev->mec.num_pipe * rdev->mec.num_mec); i++) {
2901 int me = (i < 4) ? 1 : 2; 2906 int me = (i < 4) ? 1 : 2;
2902 int pipe = (i < 4) ? i : (i - 4); 2907 int pipe = (i < 4) ? i : (i - 4);
@@ -2919,6 +2924,7 @@ static int cik_cp_compute_resume(struct radeon_device *rdev)
2919 WREG32(CP_HPD_EOP_CONTROL, tmp); 2924 WREG32(CP_HPD_EOP_CONTROL, tmp);
2920 } 2925 }
2921 cik_srbm_select(rdev, 0, 0, 0, 0); 2926 cik_srbm_select(rdev, 0, 0, 0, 0);
2927 mutex_unlock(&rdev->srbm_mutex);
2922 2928
2923 /* init the queues. Just two for now. */ 2929 /* init the queues. Just two for now. */
2924 for (i = 0; i < 2; i++) { 2930 for (i = 0; i < 2; i++) {
@@ -2972,6 +2978,7 @@ static int cik_cp_compute_resume(struct radeon_device *rdev)
2972 mqd->static_thread_mgmt23[0] = 0xffffffff; 2978 mqd->static_thread_mgmt23[0] = 0xffffffff;
2973 mqd->static_thread_mgmt23[1] = 0xffffffff; 2979 mqd->static_thread_mgmt23[1] = 0xffffffff;
2974 2980
2981 mutex_lock(&rdev->srbm_mutex);
2975 cik_srbm_select(rdev, rdev->ring[idx].me, 2982 cik_srbm_select(rdev, rdev->ring[idx].me,
2976 rdev->ring[idx].pipe, 2983 rdev->ring[idx].pipe,
2977 rdev->ring[idx].queue, 0); 2984 rdev->ring[idx].queue, 0);
@@ -3099,6 +3106,7 @@ static int cik_cp_compute_resume(struct radeon_device *rdev)
3099 WREG32(CP_HQD_ACTIVE, mqd->queue_state.cp_hqd_active); 3106 WREG32(CP_HQD_ACTIVE, mqd->queue_state.cp_hqd_active);
3100 3107
3101 cik_srbm_select(rdev, 0, 0, 0, 0); 3108 cik_srbm_select(rdev, 0, 0, 0, 0);
3109 mutex_unlock(&rdev->srbm_mutex);
3102 3110
3103 radeon_bo_kunmap(rdev->ring[idx].mqd_obj); 3111 radeon_bo_kunmap(rdev->ring[idx].mqd_obj);
3104 radeon_bo_unreserve(rdev->ring[idx].mqd_obj); 3112 radeon_bo_unreserve(rdev->ring[idx].mqd_obj);
@@ -4320,6 +4328,7 @@ static int cik_pcie_gart_enable(struct radeon_device *rdev)
4320 4328
4321 /* XXX SH_MEM regs */ 4329 /* XXX SH_MEM regs */
4322 /* where to put LDS, scratch, GPUVM in FSA64 space */ 4330 /* where to put LDS, scratch, GPUVM in FSA64 space */
4331 mutex_lock(&rdev->srbm_mutex);
4323 for (i = 0; i < 16; i++) { 4332 for (i = 0; i < 16; i++) {
4324 cik_srbm_select(rdev, 0, 0, 0, i); 4333 cik_srbm_select(rdev, 0, 0, 0, i);
4325 /* CP and shaders */ 4334 /* CP and shaders */
@@ -4335,6 +4344,7 @@ static int cik_pcie_gart_enable(struct radeon_device *rdev)
4335 /* XXX SDMA RLC - todo */ 4344 /* XXX SDMA RLC - todo */
4336 } 4345 }
4337 cik_srbm_select(rdev, 0, 0, 0, 0); 4346 cik_srbm_select(rdev, 0, 0, 0, 0);
4347 mutex_unlock(&rdev->srbm_mutex);
4338 4348
4339 cik_pcie_gart_tlb_flush(rdev); 4349 cik_pcie_gart_tlb_flush(rdev);
4340 DRM_INFO("PCIE GART of %uM enabled (table at 0x%016llX).\n", 4350 DRM_INFO("PCIE GART of %uM enabled (table at 0x%016llX).\n",
@@ -5954,6 +5964,8 @@ static int cik_startup(struct radeon_device *rdev)
5954 struct radeon_ring *ring; 5964 struct radeon_ring *ring;
5955 int r; 5965 int r;
5956 5966
5967 cik_mc_program(rdev);
5968
5957 if (rdev->flags & RADEON_IS_IGP) { 5969 if (rdev->flags & RADEON_IS_IGP) {
5958 if (!rdev->me_fw || !rdev->pfp_fw || !rdev->ce_fw || 5970 if (!rdev->me_fw || !rdev->pfp_fw || !rdev->ce_fw ||
5959 !rdev->mec_fw || !rdev->sdma_fw || !rdev->rlc_fw) { 5971 !rdev->mec_fw || !rdev->sdma_fw || !rdev->rlc_fw) {
@@ -5985,7 +5997,6 @@ static int cik_startup(struct radeon_device *rdev)
5985 if (r) 5997 if (r)
5986 return r; 5998 return r;
5987 5999
5988 cik_mc_program(rdev);
5989 r = cik_pcie_gart_enable(rdev); 6000 r = cik_pcie_gart_enable(rdev);
5990 if (r) 6001 if (r)
5991 return r; 6002 return r;
@@ -6194,7 +6205,7 @@ int cik_suspend(struct radeon_device *rdev)
6194 radeon_vm_manager_fini(rdev); 6205 radeon_vm_manager_fini(rdev);
6195 cik_cp_enable(rdev, false); 6206 cik_cp_enable(rdev, false);
6196 cik_sdma_enable(rdev, false); 6207 cik_sdma_enable(rdev, false);
6197 r600_uvd_rbc_stop(rdev); 6208 r600_uvd_stop(rdev);
6198 radeon_uvd_suspend(rdev); 6209 radeon_uvd_suspend(rdev);
6199 cik_irq_suspend(rdev); 6210 cik_irq_suspend(rdev);
6200 radeon_wb_disable(rdev); 6211 radeon_wb_disable(rdev);
@@ -6358,6 +6369,7 @@ void cik_fini(struct radeon_device *rdev)
6358 radeon_vm_manager_fini(rdev); 6369 radeon_vm_manager_fini(rdev);
6359 radeon_ib_pool_fini(rdev); 6370 radeon_ib_pool_fini(rdev);
6360 radeon_irq_kms_fini(rdev); 6371 radeon_irq_kms_fini(rdev);
6372 r600_uvd_stop(rdev);
6361 radeon_uvd_fini(rdev); 6373 radeon_uvd_fini(rdev);
6362 cik_pcie_gart_fini(rdev); 6374 cik_pcie_gart_fini(rdev);
6363 r600_vram_scratch_fini(rdev); 6375 r600_vram_scratch_fini(rdev);
@@ -6978,7 +6990,7 @@ int cik_uvd_resume(struct radeon_device *rdev)
6978 6990
6979 /* programm the VCPU memory controller bits 0-27 */ 6991 /* programm the VCPU memory controller bits 0-27 */
6980 addr = rdev->uvd.gpu_addr >> 3; 6992 addr = rdev->uvd.gpu_addr >> 3;
6981 size = RADEON_GPU_PAGE_ALIGN(rdev->uvd.fw_size + 4) >> 3; 6993 size = RADEON_GPU_PAGE_ALIGN(rdev->uvd_fw->size + 4) >> 3;
6982 WREG32(UVD_VCPU_CACHE_OFFSET0, addr); 6994 WREG32(UVD_VCPU_CACHE_OFFSET0, addr);
6983 WREG32(UVD_VCPU_CACHE_SIZE0, size); 6995 WREG32(UVD_VCPU_CACHE_SIZE0, size);
6984 6996
diff --git a/drivers/gpu/drm/radeon/cypress_dpm.c b/drivers/gpu/drm/radeon/cypress_dpm.c
index 9bcdd174780f..7e5d0b570a30 100644
--- a/drivers/gpu/drm/radeon/cypress_dpm.c
+++ b/drivers/gpu/drm/radeon/cypress_dpm.c
@@ -2038,9 +2038,6 @@ int cypress_dpm_init(struct radeon_device *rdev)
2038{ 2038{
2039 struct rv7xx_power_info *pi; 2039 struct rv7xx_power_info *pi;
2040 struct evergreen_power_info *eg_pi; 2040 struct evergreen_power_info *eg_pi;
2041 int index = GetIndexIntoMasterTable(DATA, ASIC_InternalSS_Info);
2042 uint16_t data_offset, size;
2043 uint8_t frev, crev;
2044 struct atom_clock_dividers dividers; 2041 struct atom_clock_dividers dividers;
2045 int ret; 2042 int ret;
2046 2043
@@ -2092,16 +2089,7 @@ int cypress_dpm_init(struct radeon_device *rdev)
2092 eg_pi->vddci_control = 2089 eg_pi->vddci_control =
2093 radeon_atom_is_voltage_gpio(rdev, SET_VOLTAGE_TYPE_ASIC_VDDCI, 0); 2090 radeon_atom_is_voltage_gpio(rdev, SET_VOLTAGE_TYPE_ASIC_VDDCI, 0);
2094 2091
2095 if (atom_parse_data_header(rdev->mode_info.atom_context, index, &size, 2092 rv770_get_engine_memory_ss(rdev);
2096 &frev, &crev, &data_offset)) {
2097 pi->sclk_ss = true;
2098 pi->mclk_ss = true;
2099 pi->dynamic_ss = true;
2100 } else {
2101 pi->sclk_ss = false;
2102 pi->mclk_ss = false;
2103 pi->dynamic_ss = true;
2104 }
2105 2093
2106 pi->asi = RV770_ASI_DFLT; 2094 pi->asi = RV770_ASI_DFLT;
2107 pi->pasi = CYPRESS_HASI_DFLT; 2095 pi->pasi = CYPRESS_HASI_DFLT;
@@ -2122,8 +2110,7 @@ int cypress_dpm_init(struct radeon_device *rdev)
2122 2110
2123 pi->dynamic_pcie_gen2 = true; 2111 pi->dynamic_pcie_gen2 = true;
2124 2112
2125 if (pi->gfx_clock_gating && 2113 if (rdev->pm.int_thermal_type != THERMAL_TYPE_NONE)
2126 (rdev->pm.int_thermal_type != THERMAL_TYPE_NONE))
2127 pi->thermal_protection = true; 2114 pi->thermal_protection = true;
2128 else 2115 else
2129 pi->thermal_protection = false; 2116 pi->thermal_protection = false;
diff --git a/drivers/gpu/drm/radeon/evergreen.c b/drivers/gpu/drm/radeon/evergreen.c
index 038dcac7670c..d5b49e33315e 100644
--- a/drivers/gpu/drm/radeon/evergreen.c
+++ b/drivers/gpu/drm/radeon/evergreen.c
@@ -5106,6 +5106,8 @@ static int evergreen_startup(struct radeon_device *rdev)
5106 /* enable aspm */ 5106 /* enable aspm */
5107 evergreen_program_aspm(rdev); 5107 evergreen_program_aspm(rdev);
5108 5108
5109 evergreen_mc_program(rdev);
5110
5109 if (ASIC_IS_DCE5(rdev)) { 5111 if (ASIC_IS_DCE5(rdev)) {
5110 if (!rdev->me_fw || !rdev->pfp_fw || !rdev->rlc_fw || !rdev->mc_fw) { 5112 if (!rdev->me_fw || !rdev->pfp_fw || !rdev->rlc_fw || !rdev->mc_fw) {
5111 r = ni_init_microcode(rdev); 5113 r = ni_init_microcode(rdev);
@@ -5133,7 +5135,6 @@ static int evergreen_startup(struct radeon_device *rdev)
5133 if (r) 5135 if (r)
5134 return r; 5136 return r;
5135 5137
5136 evergreen_mc_program(rdev);
5137 if (rdev->flags & RADEON_IS_AGP) { 5138 if (rdev->flags & RADEON_IS_AGP) {
5138 evergreen_agp_enable(rdev); 5139 evergreen_agp_enable(rdev);
5139 } else { 5140 } else {
@@ -5291,10 +5292,10 @@ int evergreen_resume(struct radeon_device *rdev)
5291int evergreen_suspend(struct radeon_device *rdev) 5292int evergreen_suspend(struct radeon_device *rdev)
5292{ 5293{
5293 r600_audio_fini(rdev); 5294 r600_audio_fini(rdev);
5295 r600_uvd_stop(rdev);
5294 radeon_uvd_suspend(rdev); 5296 radeon_uvd_suspend(rdev);
5295 r700_cp_stop(rdev); 5297 r700_cp_stop(rdev);
5296 r600_dma_stop(rdev); 5298 r600_dma_stop(rdev);
5297 r600_uvd_rbc_stop(rdev);
5298 evergreen_irq_suspend(rdev); 5299 evergreen_irq_suspend(rdev);
5299 radeon_wb_disable(rdev); 5300 radeon_wb_disable(rdev);
5300 evergreen_pcie_gart_disable(rdev); 5301 evergreen_pcie_gart_disable(rdev);
@@ -5429,6 +5430,7 @@ void evergreen_fini(struct radeon_device *rdev)
5429 radeon_ib_pool_fini(rdev); 5430 radeon_ib_pool_fini(rdev);
5430 radeon_irq_kms_fini(rdev); 5431 radeon_irq_kms_fini(rdev);
5431 evergreen_pcie_gart_fini(rdev); 5432 evergreen_pcie_gart_fini(rdev);
5433 r600_uvd_stop(rdev);
5432 radeon_uvd_fini(rdev); 5434 radeon_uvd_fini(rdev);
5433 r600_vram_scratch_fini(rdev); 5435 r600_vram_scratch_fini(rdev);
5434 radeon_gem_fini(rdev); 5436 radeon_gem_fini(rdev);
diff --git a/drivers/gpu/drm/radeon/evergreen_hdmi.c b/drivers/gpu/drm/radeon/evergreen_hdmi.c
index bb9ea3641312..b0e280058b9b 100644
--- a/drivers/gpu/drm/radeon/evergreen_hdmi.c
+++ b/drivers/gpu/drm/radeon/evergreen_hdmi.c
@@ -148,18 +148,40 @@ static void evergreen_audio_set_dto(struct drm_encoder *encoder, u32 clock)
148 struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv; 148 struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
149 struct radeon_crtc *radeon_crtc = to_radeon_crtc(encoder->crtc); 149 struct radeon_crtc *radeon_crtc = to_radeon_crtc(encoder->crtc);
150 u32 base_rate = 24000; 150 u32 base_rate = 24000;
151 u32 max_ratio = clock / base_rate;
152 u32 dto_phase;
153 u32 dto_modulo = clock;
154 u32 wallclock_ratio;
155 u32 dto_cntl;
151 156
152 if (!dig || !dig->afmt) 157 if (!dig || !dig->afmt)
153 return; 158 return;
154 159
160 if (max_ratio >= 8) {
161 dto_phase = 192 * 1000;
162 wallclock_ratio = 3;
163 } else if (max_ratio >= 4) {
164 dto_phase = 96 * 1000;
165 wallclock_ratio = 2;
166 } else if (max_ratio >= 2) {
167 dto_phase = 48 * 1000;
168 wallclock_ratio = 1;
169 } else {
170 dto_phase = 24 * 1000;
171 wallclock_ratio = 0;
172 }
173 dto_cntl = RREG32(DCCG_AUDIO_DTO0_CNTL) & ~DCCG_AUDIO_DTO_WALLCLOCK_RATIO_MASK;
174 dto_cntl |= DCCG_AUDIO_DTO_WALLCLOCK_RATIO(wallclock_ratio);
175 WREG32(DCCG_AUDIO_DTO0_CNTL, dto_cntl);
176
155 /* XXX two dtos; generally use dto0 for hdmi */ 177 /* XXX two dtos; generally use dto0 for hdmi */
156 /* Express [24MHz / target pixel clock] as an exact rational 178 /* Express [24MHz / target pixel clock] as an exact rational
157 * number (coefficient of two integer numbers. DCCG_AUDIO_DTOx_PHASE 179 * number (coefficient of two integer numbers. DCCG_AUDIO_DTOx_PHASE
158 * is the numerator, DCCG_AUDIO_DTOx_MODULE is the denominator 180 * is the numerator, DCCG_AUDIO_DTOx_MODULE is the denominator
159 */ 181 */
160 WREG32(DCCG_AUDIO_DTO_SOURCE, DCCG_AUDIO_DTO0_SOURCE_SEL(radeon_crtc->crtc_id)); 182 WREG32(DCCG_AUDIO_DTO_SOURCE, DCCG_AUDIO_DTO0_SOURCE_SEL(radeon_crtc->crtc_id));
161 WREG32(DCCG_AUDIO_DTO0_PHASE, base_rate * 100); 183 WREG32(DCCG_AUDIO_DTO0_PHASE, dto_phase);
162 WREG32(DCCG_AUDIO_DTO0_MODULE, clock * 100); 184 WREG32(DCCG_AUDIO_DTO0_MODULE, dto_modulo);
163} 185}
164 186
165 187
diff --git a/drivers/gpu/drm/radeon/evergreend.h b/drivers/gpu/drm/radeon/evergreend.h
index a7baf67aef6c..0d582ac1dc31 100644
--- a/drivers/gpu/drm/radeon/evergreend.h
+++ b/drivers/gpu/drm/radeon/evergreend.h
@@ -497,6 +497,9 @@
497#define DCCG_AUDIO_DTO0_MODULE 0x05b4 497#define DCCG_AUDIO_DTO0_MODULE 0x05b4
498#define DCCG_AUDIO_DTO0_LOAD 0x05b8 498#define DCCG_AUDIO_DTO0_LOAD 0x05b8
499#define DCCG_AUDIO_DTO0_CNTL 0x05bc 499#define DCCG_AUDIO_DTO0_CNTL 0x05bc
500# define DCCG_AUDIO_DTO_WALLCLOCK_RATIO(x) (((x) & 7) << 0)
501# define DCCG_AUDIO_DTO_WALLCLOCK_RATIO_MASK 7
502# define DCCG_AUDIO_DTO_WALLCLOCK_RATIO_SHIFT 0
500 503
501#define DCCG_AUDIO_DTO1_PHASE 0x05c0 504#define DCCG_AUDIO_DTO1_PHASE 0x05c0
502#define DCCG_AUDIO_DTO1_MODULE 0x05c4 505#define DCCG_AUDIO_DTO1_MODULE 0x05c4
diff --git a/drivers/gpu/drm/radeon/ni.c b/drivers/gpu/drm/radeon/ni.c
index 56bd4f3be4fe..ccb4f8b54852 100644
--- a/drivers/gpu/drm/radeon/ni.c
+++ b/drivers/gpu/drm/radeon/ni.c
@@ -794,9 +794,13 @@ int ni_init_microcode(struct radeon_device *rdev)
794 if ((rdev->family >= CHIP_BARTS) && (rdev->family <= CHIP_CAYMAN)) { 794 if ((rdev->family >= CHIP_BARTS) && (rdev->family <= CHIP_CAYMAN)) {
795 snprintf(fw_name, sizeof(fw_name), "radeon/%s_smc.bin", chip_name); 795 snprintf(fw_name, sizeof(fw_name), "radeon/%s_smc.bin", chip_name);
796 err = request_firmware(&rdev->smc_fw, fw_name, rdev->dev); 796 err = request_firmware(&rdev->smc_fw, fw_name, rdev->dev);
797 if (err) 797 if (err) {
798 goto out; 798 printk(KERN_ERR
799 if (rdev->smc_fw->size != smc_req_size) { 799 "smc: error loading firmware \"%s\"\n",
800 fw_name);
801 release_firmware(rdev->smc_fw);
802 rdev->smc_fw = NULL;
803 } else if (rdev->smc_fw->size != smc_req_size) {
800 printk(KERN_ERR 804 printk(KERN_ERR
801 "ni_mc: Bogus length %zu in firmware \"%s\"\n", 805 "ni_mc: Bogus length %zu in firmware \"%s\"\n",
802 rdev->mc_fw->size, fw_name); 806 rdev->mc_fw->size, fw_name);
@@ -2079,6 +2083,8 @@ static int cayman_startup(struct radeon_device *rdev)
2079 /* enable aspm */ 2083 /* enable aspm */
2080 evergreen_program_aspm(rdev); 2084 evergreen_program_aspm(rdev);
2081 2085
2086 evergreen_mc_program(rdev);
2087
2082 if (rdev->flags & RADEON_IS_IGP) { 2088 if (rdev->flags & RADEON_IS_IGP) {
2083 if (!rdev->me_fw || !rdev->pfp_fw || !rdev->rlc_fw) { 2089 if (!rdev->me_fw || !rdev->pfp_fw || !rdev->rlc_fw) {
2084 r = ni_init_microcode(rdev); 2090 r = ni_init_microcode(rdev);
@@ -2107,7 +2113,6 @@ static int cayman_startup(struct radeon_device *rdev)
2107 if (r) 2113 if (r)
2108 return r; 2114 return r;
2109 2115
2110 evergreen_mc_program(rdev);
2111 r = cayman_pcie_gart_enable(rdev); 2116 r = cayman_pcie_gart_enable(rdev);
2112 if (r) 2117 if (r)
2113 return r; 2118 return r;
@@ -2286,7 +2291,7 @@ int cayman_suspend(struct radeon_device *rdev)
2286 radeon_vm_manager_fini(rdev); 2291 radeon_vm_manager_fini(rdev);
2287 cayman_cp_enable(rdev, false); 2292 cayman_cp_enable(rdev, false);
2288 cayman_dma_stop(rdev); 2293 cayman_dma_stop(rdev);
2289 r600_uvd_rbc_stop(rdev); 2294 r600_uvd_stop(rdev);
2290 radeon_uvd_suspend(rdev); 2295 radeon_uvd_suspend(rdev);
2291 evergreen_irq_suspend(rdev); 2296 evergreen_irq_suspend(rdev);
2292 radeon_wb_disable(rdev); 2297 radeon_wb_disable(rdev);
@@ -2418,6 +2423,7 @@ void cayman_fini(struct radeon_device *rdev)
2418 radeon_vm_manager_fini(rdev); 2423 radeon_vm_manager_fini(rdev);
2419 radeon_ib_pool_fini(rdev); 2424 radeon_ib_pool_fini(rdev);
2420 radeon_irq_kms_fini(rdev); 2425 radeon_irq_kms_fini(rdev);
2426 r600_uvd_stop(rdev);
2421 radeon_uvd_fini(rdev); 2427 radeon_uvd_fini(rdev);
2422 cayman_pcie_gart_fini(rdev); 2428 cayman_pcie_gart_fini(rdev);
2423 r600_vram_scratch_fini(rdev); 2429 r600_vram_scratch_fini(rdev);
diff --git a/drivers/gpu/drm/radeon/ni_dpm.c b/drivers/gpu/drm/radeon/ni_dpm.c
index 4f9b9bc20daa..f0f5f748938a 100644
--- a/drivers/gpu/drm/radeon/ni_dpm.c
+++ b/drivers/gpu/drm/radeon/ni_dpm.c
@@ -4067,9 +4067,6 @@ int ni_dpm_init(struct radeon_device *rdev)
4067 struct rv7xx_power_info *pi; 4067 struct rv7xx_power_info *pi;
4068 struct evergreen_power_info *eg_pi; 4068 struct evergreen_power_info *eg_pi;
4069 struct ni_power_info *ni_pi; 4069 struct ni_power_info *ni_pi;
4070 int index = GetIndexIntoMasterTable(DATA, ASIC_InternalSS_Info);
4071 u16 data_offset, size;
4072 u8 frev, crev;
4073 struct atom_clock_dividers dividers; 4070 struct atom_clock_dividers dividers;
4074 int ret; 4071 int ret;
4075 4072
@@ -4162,16 +4159,7 @@ int ni_dpm_init(struct radeon_device *rdev)
4162 eg_pi->vddci_control = 4159 eg_pi->vddci_control =
4163 radeon_atom_is_voltage_gpio(rdev, SET_VOLTAGE_TYPE_ASIC_VDDCI, 0); 4160 radeon_atom_is_voltage_gpio(rdev, SET_VOLTAGE_TYPE_ASIC_VDDCI, 0);
4164 4161
4165 if (atom_parse_data_header(rdev->mode_info.atom_context, index, &size, 4162 rv770_get_engine_memory_ss(rdev);
4166 &frev, &crev, &data_offset)) {
4167 pi->sclk_ss = true;
4168 pi->mclk_ss = true;
4169 pi->dynamic_ss = true;
4170 } else {
4171 pi->sclk_ss = false;
4172 pi->mclk_ss = false;
4173 pi->dynamic_ss = true;
4174 }
4175 4163
4176 pi->asi = RV770_ASI_DFLT; 4164 pi->asi = RV770_ASI_DFLT;
4177 pi->pasi = CYPRESS_HASI_DFLT; 4165 pi->pasi = CYPRESS_HASI_DFLT;
@@ -4188,8 +4176,7 @@ int ni_dpm_init(struct radeon_device *rdev)
4188 4176
4189 pi->dynamic_pcie_gen2 = true; 4177 pi->dynamic_pcie_gen2 = true;
4190 4178
4191 if (pi->gfx_clock_gating && 4179 if (rdev->pm.int_thermal_type != THERMAL_TYPE_NONE)
4192 (rdev->pm.int_thermal_type != THERMAL_TYPE_NONE))
4193 pi->thermal_protection = true; 4180 pi->thermal_protection = true;
4194 else 4181 else
4195 pi->thermal_protection = false; 4182 pi->thermal_protection = false;
diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c
index 10f712e37003..e66e72077350 100644
--- a/drivers/gpu/drm/radeon/r600.c
+++ b/drivers/gpu/drm/radeon/r600.c
@@ -2299,9 +2299,13 @@ int r600_init_microcode(struct radeon_device *rdev)
2299 if ((rdev->family >= CHIP_RV770) && (rdev->family <= CHIP_HEMLOCK)) { 2299 if ((rdev->family >= CHIP_RV770) && (rdev->family <= CHIP_HEMLOCK)) {
2300 snprintf(fw_name, sizeof(fw_name), "radeon/%s_smc.bin", smc_chip_name); 2300 snprintf(fw_name, sizeof(fw_name), "radeon/%s_smc.bin", smc_chip_name);
2301 err = request_firmware(&rdev->smc_fw, fw_name, rdev->dev); 2301 err = request_firmware(&rdev->smc_fw, fw_name, rdev->dev);
2302 if (err) 2302 if (err) {
2303 goto out; 2303 printk(KERN_ERR
2304 if (rdev->smc_fw->size != smc_req_size) { 2304 "smc: error loading firmware \"%s\"\n",
2305 fw_name);
2306 release_firmware(rdev->smc_fw);
2307 rdev->smc_fw = NULL;
2308 } else if (rdev->smc_fw->size != smc_req_size) {
2305 printk(KERN_ERR 2309 printk(KERN_ERR
2306 "smc: Bogus length %zu in firmware \"%s\"\n", 2310 "smc: Bogus length %zu in firmware \"%s\"\n",
2307 rdev->smc_fw->size, fw_name); 2311 rdev->smc_fw->size, fw_name);
@@ -2697,12 +2701,29 @@ int r600_uvd_rbc_start(struct radeon_device *rdev)
2697 return 0; 2701 return 0;
2698} 2702}
2699 2703
2700void r600_uvd_rbc_stop(struct radeon_device *rdev) 2704void r600_uvd_stop(struct radeon_device *rdev)
2701{ 2705{
2702 struct radeon_ring *ring = &rdev->ring[R600_RING_TYPE_UVD_INDEX]; 2706 struct radeon_ring *ring = &rdev->ring[R600_RING_TYPE_UVD_INDEX];
2703 2707
2704 /* force RBC into idle state */ 2708 /* force RBC into idle state */
2705 WREG32(UVD_RBC_RB_CNTL, 0x11010101); 2709 WREG32(UVD_RBC_RB_CNTL, 0x11010101);
2710
2711 /* Stall UMC and register bus before resetting VCPU */
2712 WREG32_P(UVD_LMI_CTRL2, 1 << 8, ~(1 << 8));
2713 WREG32_P(UVD_RB_ARB_CTRL, 1 << 3, ~(1 << 3));
2714 mdelay(1);
2715
2716 /* put VCPU into reset */
2717 WREG32(UVD_SOFT_RESET, VCPU_SOFT_RESET);
2718 mdelay(5);
2719
2720 /* disable VCPU clock */
2721 WREG32(UVD_VCPU_CNTL, 0x0);
2722
2723 /* Unstall UMC and register bus */
2724 WREG32_P(UVD_LMI_CTRL2, 0, ~(1 << 8));
2725 WREG32_P(UVD_RB_ARB_CTRL, 0, ~(1 << 3));
2726
2706 ring->ready = false; 2727 ring->ready = false;
2707} 2728}
2708 2729
@@ -2722,6 +2743,11 @@ int r600_uvd_init(struct radeon_device *rdev)
2722 /* disable interupt */ 2743 /* disable interupt */
2723 WREG32_P(UVD_MASTINT_EN, 0, ~(1 << 1)); 2744 WREG32_P(UVD_MASTINT_EN, 0, ~(1 << 1));
2724 2745
2746 /* Stall UMC and register bus before resetting VCPU */
2747 WREG32_P(UVD_LMI_CTRL2, 1 << 8, ~(1 << 8));
2748 WREG32_P(UVD_RB_ARB_CTRL, 1 << 3, ~(1 << 3));
2749 mdelay(1);
2750
2725 /* put LMI, VCPU, RBC etc... into reset */ 2751 /* put LMI, VCPU, RBC etc... into reset */
2726 WREG32(UVD_SOFT_RESET, LMI_SOFT_RESET | VCPU_SOFT_RESET | 2752 WREG32(UVD_SOFT_RESET, LMI_SOFT_RESET | VCPU_SOFT_RESET |
2727 LBSI_SOFT_RESET | RBC_SOFT_RESET | CSM_SOFT_RESET | 2753 LBSI_SOFT_RESET | RBC_SOFT_RESET | CSM_SOFT_RESET |
@@ -2751,10 +2777,6 @@ int r600_uvd_init(struct radeon_device *rdev)
2751 WREG32(UVD_MPC_SET_ALU, 0); 2777 WREG32(UVD_MPC_SET_ALU, 0);
2752 WREG32(UVD_MPC_SET_MUX, 0x88); 2778 WREG32(UVD_MPC_SET_MUX, 0x88);
2753 2779
2754 /* Stall UMC */
2755 WREG32_P(UVD_LMI_CTRL2, 1 << 8, ~(1 << 8));
2756 WREG32_P(UVD_RB_ARB_CTRL, 1 << 3, ~(1 << 3));
2757
2758 /* take all subblocks out of reset, except VCPU */ 2780 /* take all subblocks out of reset, except VCPU */
2759 WREG32(UVD_SOFT_RESET, VCPU_SOFT_RESET); 2781 WREG32(UVD_SOFT_RESET, VCPU_SOFT_RESET);
2760 mdelay(5); 2782 mdelay(5);
@@ -3312,6 +3334,8 @@ static int r600_startup(struct radeon_device *rdev)
3312 /* enable pcie gen2 link */ 3334 /* enable pcie gen2 link */
3313 r600_pcie_gen2_enable(rdev); 3335 r600_pcie_gen2_enable(rdev);
3314 3336
3337 r600_mc_program(rdev);
3338
3315 if (!rdev->me_fw || !rdev->pfp_fw || !rdev->rlc_fw) { 3339 if (!rdev->me_fw || !rdev->pfp_fw || !rdev->rlc_fw) {
3316 r = r600_init_microcode(rdev); 3340 r = r600_init_microcode(rdev);
3317 if (r) { 3341 if (r) {
@@ -3324,7 +3348,6 @@ static int r600_startup(struct radeon_device *rdev)
3324 if (r) 3348 if (r)
3325 return r; 3349 return r;
3326 3350
3327 r600_mc_program(rdev);
3328 if (rdev->flags & RADEON_IS_AGP) { 3351 if (rdev->flags & RADEON_IS_AGP) {
3329 r600_agp_enable(rdev); 3352 r600_agp_enable(rdev);
3330 } else { 3353 } else {
diff --git a/drivers/gpu/drm/radeon/r600_hdmi.c b/drivers/gpu/drm/radeon/r600_hdmi.c
index f48240bb8c56..f264df5470f7 100644
--- a/drivers/gpu/drm/radeon/r600_hdmi.c
+++ b/drivers/gpu/drm/radeon/r600_hdmi.c
@@ -226,10 +226,29 @@ void r600_audio_set_dto(struct drm_encoder *encoder, u32 clock)
226 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 226 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
227 struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv; 227 struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
228 u32 base_rate = 24000; 228 u32 base_rate = 24000;
229 u32 max_ratio = clock / base_rate;
230 u32 dto_phase;
231 u32 dto_modulo = clock;
232 u32 wallclock_ratio;
233 u32 dto_cntl;
229 234
230 if (!dig || !dig->afmt) 235 if (!dig || !dig->afmt)
231 return; 236 return;
232 237
238 if (max_ratio >= 8) {
239 dto_phase = 192 * 1000;
240 wallclock_ratio = 3;
241 } else if (max_ratio >= 4) {
242 dto_phase = 96 * 1000;
243 wallclock_ratio = 2;
244 } else if (max_ratio >= 2) {
245 dto_phase = 48 * 1000;
246 wallclock_ratio = 1;
247 } else {
248 dto_phase = 24 * 1000;
249 wallclock_ratio = 0;
250 }
251
233 /* there are two DTOs selected by DCCG_AUDIO_DTO_SELECT. 252 /* there are two DTOs selected by DCCG_AUDIO_DTO_SELECT.
234 * doesn't matter which one you use. Just use the first one. 253 * doesn't matter which one you use. Just use the first one.
235 */ 254 */
@@ -242,9 +261,21 @@ void r600_audio_set_dto(struct drm_encoder *encoder, u32 clock)
242 /* according to the reg specs, this should DCE3.2 only, but in 261 /* according to the reg specs, this should DCE3.2 only, but in
243 * practice it seems to cover DCE3.0 as well. 262 * practice it seems to cover DCE3.0 as well.
244 */ 263 */
245 WREG32(DCCG_AUDIO_DTO0_PHASE, base_rate * 100); 264 if (dig->dig_encoder == 0) {
246 WREG32(DCCG_AUDIO_DTO0_MODULE, clock * 100); 265 dto_cntl = RREG32(DCCG_AUDIO_DTO0_CNTL) & ~DCCG_AUDIO_DTO_WALLCLOCK_RATIO_MASK;
247 WREG32(DCCG_AUDIO_DTO_SELECT, 0); /* select DTO0 */ 266 dto_cntl |= DCCG_AUDIO_DTO_WALLCLOCK_RATIO(wallclock_ratio);
267 WREG32(DCCG_AUDIO_DTO0_CNTL, dto_cntl);
268 WREG32(DCCG_AUDIO_DTO0_PHASE, dto_phase);
269 WREG32(DCCG_AUDIO_DTO0_MODULE, dto_modulo);
270 WREG32(DCCG_AUDIO_DTO_SELECT, 0); /* select DTO0 */
271 } else {
272 dto_cntl = RREG32(DCCG_AUDIO_DTO1_CNTL) & ~DCCG_AUDIO_DTO_WALLCLOCK_RATIO_MASK;
273 dto_cntl |= DCCG_AUDIO_DTO_WALLCLOCK_RATIO(wallclock_ratio);
274 WREG32(DCCG_AUDIO_DTO1_CNTL, dto_cntl);
275 WREG32(DCCG_AUDIO_DTO1_PHASE, dto_phase);
276 WREG32(DCCG_AUDIO_DTO1_MODULE, dto_modulo);
277 WREG32(DCCG_AUDIO_DTO_SELECT, 1); /* select DTO1 */
278 }
248 } else { 279 } else {
249 /* according to the reg specs, this should be DCE2.0 and DCE3.0 */ 280 /* according to the reg specs, this should be DCE2.0 and DCE3.0 */
250 WREG32(AUDIO_DTO, AUDIO_DTO_PHASE(base_rate / 10) | 281 WREG32(AUDIO_DTO, AUDIO_DTO_PHASE(base_rate / 10) |
diff --git a/drivers/gpu/drm/radeon/r600d.h b/drivers/gpu/drm/radeon/r600d.h
index 8e3fe815edab..7c780839a7f4 100644
--- a/drivers/gpu/drm/radeon/r600d.h
+++ b/drivers/gpu/drm/radeon/r600d.h
@@ -933,6 +933,9 @@
933#define DCCG_AUDIO_DTO0_LOAD 0x051c 933#define DCCG_AUDIO_DTO0_LOAD 0x051c
934# define DTO_LOAD (1 << 31) 934# define DTO_LOAD (1 << 31)
935#define DCCG_AUDIO_DTO0_CNTL 0x0520 935#define DCCG_AUDIO_DTO0_CNTL 0x0520
936# define DCCG_AUDIO_DTO_WALLCLOCK_RATIO(x) (((x) & 7) << 0)
937# define DCCG_AUDIO_DTO_WALLCLOCK_RATIO_MASK 7
938# define DCCG_AUDIO_DTO_WALLCLOCK_RATIO_SHIFT 0
936 939
937#define DCCG_AUDIO_DTO1_PHASE 0x0524 940#define DCCG_AUDIO_DTO1_PHASE 0x0524
938#define DCCG_AUDIO_DTO1_MODULE 0x0528 941#define DCCG_AUDIO_DTO1_MODULE 0x0528
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index 2f08219c39b6..9f19259667df 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -1468,7 +1468,6 @@ struct radeon_uvd {
1468 void *cpu_addr; 1468 void *cpu_addr;
1469 uint64_t gpu_addr; 1469 uint64_t gpu_addr;
1470 void *saved_bo; 1470 void *saved_bo;
1471 unsigned fw_size;
1472 atomic_t handles[RADEON_MAX_UVD_HANDLES]; 1471 atomic_t handles[RADEON_MAX_UVD_HANDLES];
1473 struct drm_file *filp[RADEON_MAX_UVD_HANDLES]; 1472 struct drm_file *filp[RADEON_MAX_UVD_HANDLES];
1474 struct delayed_work idle_work; 1473 struct delayed_work idle_work;
@@ -2066,6 +2065,7 @@ struct radeon_device {
2066 const struct firmware *mec_fw; /* CIK MEC firmware */ 2065 const struct firmware *mec_fw; /* CIK MEC firmware */
2067 const struct firmware *sdma_fw; /* CIK SDMA firmware */ 2066 const struct firmware *sdma_fw; /* CIK SDMA firmware */
2068 const struct firmware *smc_fw; /* SMC firmware */ 2067 const struct firmware *smc_fw; /* SMC firmware */
2068 const struct firmware *uvd_fw; /* UVD firmware */
2069 struct r600_blit r600_blit; 2069 struct r600_blit r600_blit;
2070 struct r600_vram_scratch vram_scratch; 2070 struct r600_vram_scratch vram_scratch;
2071 int msi_enabled; /* msi enabled */ 2071 int msi_enabled; /* msi enabled */
@@ -2095,6 +2095,8 @@ struct radeon_device {
2095 /* ACPI interface */ 2095 /* ACPI interface */
2096 struct radeon_atif atif; 2096 struct radeon_atif atif;
2097 struct radeon_atcs atcs; 2097 struct radeon_atcs atcs;
2098 /* srbm instance registers */
2099 struct mutex srbm_mutex;
2098}; 2100};
2099 2101
2100int radeon_device_init(struct radeon_device *rdev, 2102int radeon_device_init(struct radeon_device *rdev,
@@ -2161,7 +2163,7 @@ void cik_mm_wdoorbell(struct radeon_device *rdev, u32 offset, u32 v);
2161 WREG32(reg, tmp_); \ 2163 WREG32(reg, tmp_); \
2162 } while (0) 2164 } while (0)
2163#define WREG32_AND(reg, and) WREG32_P(reg, 0, and) 2165#define WREG32_AND(reg, and) WREG32_P(reg, 0, and)
2164#define WREG32_OR(reg, or) WREG32_P(reg, or, ~or) 2166#define WREG32_OR(reg, or) WREG32_P(reg, or, ~(or))
2165#define WREG32_PLL_P(reg, val, mask) \ 2167#define WREG32_PLL_P(reg, val, mask) \
2166 do { \ 2168 do { \
2167 uint32_t tmp_ = RREG32_PLL(reg); \ 2169 uint32_t tmp_ = RREG32_PLL(reg); \
diff --git a/drivers/gpu/drm/radeon/radeon_asic.h b/drivers/gpu/drm/radeon/radeon_asic.h
index 902479fa737f..3d61d5aac18f 100644
--- a/drivers/gpu/drm/radeon/radeon_asic.h
+++ b/drivers/gpu/drm/radeon/radeon_asic.h
@@ -441,7 +441,7 @@ void rs780_dpm_debugfs_print_current_performance_level(struct radeon_device *rde
441/* uvd */ 441/* uvd */
442int r600_uvd_init(struct radeon_device *rdev); 442int r600_uvd_init(struct radeon_device *rdev);
443int r600_uvd_rbc_start(struct radeon_device *rdev); 443int r600_uvd_rbc_start(struct radeon_device *rdev);
444void r600_uvd_rbc_stop(struct radeon_device *rdev); 444void r600_uvd_stop(struct radeon_device *rdev);
445int r600_uvd_ib_test(struct radeon_device *rdev, struct radeon_ring *ring); 445int r600_uvd_ib_test(struct radeon_device *rdev, struct radeon_ring *ring);
446void r600_uvd_fence_emit(struct radeon_device *rdev, 446void r600_uvd_fence_emit(struct radeon_device *rdev,
447 struct radeon_fence *fence); 447 struct radeon_fence *fence);
diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
index 82335e38ec4f..63398ae1dbf5 100644
--- a/drivers/gpu/drm/radeon/radeon_device.c
+++ b/drivers/gpu/drm/radeon/radeon_device.c
@@ -1163,6 +1163,7 @@ int radeon_device_init(struct radeon_device *rdev,
1163 mutex_init(&rdev->gem.mutex); 1163 mutex_init(&rdev->gem.mutex);
1164 mutex_init(&rdev->pm.mutex); 1164 mutex_init(&rdev->pm.mutex);
1165 mutex_init(&rdev->gpu_clock_mutex); 1165 mutex_init(&rdev->gpu_clock_mutex);
1166 mutex_init(&rdev->srbm_mutex);
1166 init_rwsem(&rdev->pm.mclk_lock); 1167 init_rwsem(&rdev->pm.mclk_lock);
1167 init_rwsem(&rdev->exclusive_lock); 1168 init_rwsem(&rdev->exclusive_lock);
1168 init_waitqueue_head(&rdev->irq.vblank_queue); 1169 init_waitqueue_head(&rdev->irq.vblank_queue);
@@ -1519,6 +1520,7 @@ int radeon_gpu_reset(struct radeon_device *rdev)
1519 radeon_save_bios_scratch_regs(rdev); 1520 radeon_save_bios_scratch_regs(rdev);
1520 /* block TTM */ 1521 /* block TTM */
1521 resched = ttm_bo_lock_delayed_workqueue(&rdev->mman.bdev); 1522 resched = ttm_bo_lock_delayed_workqueue(&rdev->mman.bdev);
1523 radeon_pm_suspend(rdev);
1522 radeon_suspend(rdev); 1524 radeon_suspend(rdev);
1523 1525
1524 for (i = 0; i < RADEON_NUM_RINGS; ++i) { 1526 for (i = 0; i < RADEON_NUM_RINGS; ++i) {
@@ -1564,6 +1566,7 @@ retry:
1564 } 1566 }
1565 } 1567 }
1566 1568
1569 radeon_pm_resume(rdev);
1567 drm_helper_resume_force_mode(rdev->ddev); 1570 drm_helper_resume_force_mode(rdev->ddev);
1568 1571
1569 ttm_bo_unlock_delayed_workqueue(&rdev->mman.bdev, resched); 1572 ttm_bo_unlock_delayed_workqueue(&rdev->mman.bdev, resched);
diff --git a/drivers/gpu/drm/radeon/radeon_fence.c b/drivers/gpu/drm/radeon/radeon_fence.c
index 7ddb0efe2408..ddb8f8e04eb5 100644
--- a/drivers/gpu/drm/radeon/radeon_fence.c
+++ b/drivers/gpu/drm/radeon/radeon_fence.c
@@ -782,7 +782,7 @@ int radeon_fence_driver_start_ring(struct radeon_device *rdev, int ring)
782 782
783 } else { 783 } else {
784 /* put fence directly behind firmware */ 784 /* put fence directly behind firmware */
785 index = ALIGN(rdev->uvd.fw_size, 8); 785 index = ALIGN(rdev->uvd_fw->size, 8);
786 rdev->fence_drv[ring].cpu_addr = rdev->uvd.cpu_addr + index; 786 rdev->fence_drv[ring].cpu_addr = rdev->uvd.cpu_addr + index;
787 rdev->fence_drv[ring].gpu_addr = rdev->uvd.gpu_addr + index; 787 rdev->fence_drv[ring].gpu_addr = rdev->uvd.gpu_addr + index;
788 } 788 }
diff --git a/drivers/gpu/drm/radeon/radeon_gart.c b/drivers/gpu/drm/radeon/radeon_gart.c
index 6a51d943ccf4..b990b1a2bd50 100644
--- a/drivers/gpu/drm/radeon/radeon_gart.c
+++ b/drivers/gpu/drm/radeon/radeon_gart.c
@@ -207,7 +207,6 @@ void radeon_gart_table_vram_free(struct radeon_device *rdev)
207 if (rdev->gart.robj == NULL) { 207 if (rdev->gart.robj == NULL) {
208 return; 208 return;
209 } 209 }
210 radeon_gart_table_vram_unpin(rdev);
211 radeon_bo_unref(&rdev->gart.robj); 210 radeon_bo_unref(&rdev->gart.robj);
212} 211}
213 212
diff --git a/drivers/gpu/drm/radeon/radeon_pm.c b/drivers/gpu/drm/radeon/radeon_pm.c
index f374c467aaca..c557850cd345 100644
--- a/drivers/gpu/drm/radeon/radeon_pm.c
+++ b/drivers/gpu/drm/radeon/radeon_pm.c
@@ -1176,7 +1176,14 @@ int radeon_pm_init(struct radeon_device *rdev)
1176 case CHIP_VERDE: 1176 case CHIP_VERDE:
1177 case CHIP_OLAND: 1177 case CHIP_OLAND:
1178 case CHIP_HAINAN: 1178 case CHIP_HAINAN:
1179 if (radeon_dpm == 1) 1179 /* DPM requires the RLC, RV770+ dGPU requires SMC */
1180 if (!rdev->rlc_fw)
1181 rdev->pm.pm_method = PM_METHOD_PROFILE;
1182 else if ((rdev->family >= CHIP_RV770) &&
1183 (!(rdev->flags & RADEON_IS_IGP)) &&
1184 (!rdev->smc_fw))
1185 rdev->pm.pm_method = PM_METHOD_PROFILE;
1186 else if (radeon_dpm == 1)
1180 rdev->pm.pm_method = PM_METHOD_DPM; 1187 rdev->pm.pm_method = PM_METHOD_DPM;
1181 else 1188 else
1182 rdev->pm.pm_method = PM_METHOD_PROFILE; 1189 rdev->pm.pm_method = PM_METHOD_PROFILE;
diff --git a/drivers/gpu/drm/radeon/radeon_uvd.c b/drivers/gpu/drm/radeon/radeon_uvd.c
index 414fd145d20e..b79f4f5cdd62 100644
--- a/drivers/gpu/drm/radeon/radeon_uvd.c
+++ b/drivers/gpu/drm/radeon/radeon_uvd.c
@@ -56,7 +56,6 @@ static void radeon_uvd_idle_work_handler(struct work_struct *work);
56 56
57int radeon_uvd_init(struct radeon_device *rdev) 57int radeon_uvd_init(struct radeon_device *rdev)
58{ 58{
59 const struct firmware *fw;
60 unsigned long bo_size; 59 unsigned long bo_size;
61 const char *fw_name; 60 const char *fw_name;
62 int i, r; 61 int i, r;
@@ -105,14 +104,14 @@ int radeon_uvd_init(struct radeon_device *rdev)
105 return -EINVAL; 104 return -EINVAL;
106 } 105 }
107 106
108 r = request_firmware(&fw, fw_name, rdev->dev); 107 r = request_firmware(&rdev->uvd_fw, fw_name, rdev->dev);
109 if (r) { 108 if (r) {
110 dev_err(rdev->dev, "radeon_uvd: Can't load firmware \"%s\"\n", 109 dev_err(rdev->dev, "radeon_uvd: Can't load firmware \"%s\"\n",
111 fw_name); 110 fw_name);
112 return r; 111 return r;
113 } 112 }
114 113
115 bo_size = RADEON_GPU_PAGE_ALIGN(fw->size + 8) + 114 bo_size = RADEON_GPU_PAGE_ALIGN(rdev->uvd_fw->size + 8) +
116 RADEON_UVD_STACK_SIZE + RADEON_UVD_HEAP_SIZE; 115 RADEON_UVD_STACK_SIZE + RADEON_UVD_HEAP_SIZE;
117 r = radeon_bo_create(rdev, bo_size, PAGE_SIZE, true, 116 r = radeon_bo_create(rdev, bo_size, PAGE_SIZE, true,
118 RADEON_GEM_DOMAIN_VRAM, NULL, &rdev->uvd.vcpu_bo); 117 RADEON_GEM_DOMAIN_VRAM, NULL, &rdev->uvd.vcpu_bo);
@@ -145,12 +144,6 @@ int radeon_uvd_init(struct radeon_device *rdev)
145 144
146 radeon_bo_unreserve(rdev->uvd.vcpu_bo); 145 radeon_bo_unreserve(rdev->uvd.vcpu_bo);
147 146
148 rdev->uvd.fw_size = fw->size;
149 memset(rdev->uvd.cpu_addr, 0, bo_size);
150 memcpy(rdev->uvd.cpu_addr, fw->data, fw->size);
151
152 release_firmware(fw);
153
154 for (i = 0; i < RADEON_MAX_UVD_HANDLES; ++i) { 147 for (i = 0; i < RADEON_MAX_UVD_HANDLES; ++i) {
155 atomic_set(&rdev->uvd.handles[i], 0); 148 atomic_set(&rdev->uvd.handles[i], 0);
156 rdev->uvd.filp[i] = NULL; 149 rdev->uvd.filp[i] = NULL;
@@ -174,33 +167,60 @@ void radeon_uvd_fini(struct radeon_device *rdev)
174 } 167 }
175 168
176 radeon_bo_unref(&rdev->uvd.vcpu_bo); 169 radeon_bo_unref(&rdev->uvd.vcpu_bo);
170
171 release_firmware(rdev->uvd_fw);
177} 172}
178 173
179int radeon_uvd_suspend(struct radeon_device *rdev) 174int radeon_uvd_suspend(struct radeon_device *rdev)
180{ 175{
181 unsigned size; 176 unsigned size;
177 void *ptr;
178 int i;
182 179
183 if (rdev->uvd.vcpu_bo == NULL) 180 if (rdev->uvd.vcpu_bo == NULL)
184 return 0; 181 return 0;
185 182
183 for (i = 0; i < RADEON_MAX_UVD_HANDLES; ++i)
184 if (atomic_read(&rdev->uvd.handles[i]))
185 break;
186
187 if (i == RADEON_MAX_UVD_HANDLES)
188 return 0;
189
186 size = radeon_bo_size(rdev->uvd.vcpu_bo); 190 size = radeon_bo_size(rdev->uvd.vcpu_bo);
191 size -= rdev->uvd_fw->size;
192
193 ptr = rdev->uvd.cpu_addr;
194 ptr += rdev->uvd_fw->size;
195
187 rdev->uvd.saved_bo = kmalloc(size, GFP_KERNEL); 196 rdev->uvd.saved_bo = kmalloc(size, GFP_KERNEL);
188 memcpy(rdev->uvd.saved_bo, rdev->uvd.cpu_addr, size); 197 memcpy(rdev->uvd.saved_bo, ptr, size);
189 198
190 return 0; 199 return 0;
191} 200}
192 201
193int radeon_uvd_resume(struct radeon_device *rdev) 202int radeon_uvd_resume(struct radeon_device *rdev)
194{ 203{
204 unsigned size;
205 void *ptr;
206
195 if (rdev->uvd.vcpu_bo == NULL) 207 if (rdev->uvd.vcpu_bo == NULL)
196 return -EINVAL; 208 return -EINVAL;
197 209
210 memcpy(rdev->uvd.cpu_addr, rdev->uvd_fw->data, rdev->uvd_fw->size);
211
212 size = radeon_bo_size(rdev->uvd.vcpu_bo);
213 size -= rdev->uvd_fw->size;
214
215 ptr = rdev->uvd.cpu_addr;
216 ptr += rdev->uvd_fw->size;
217
198 if (rdev->uvd.saved_bo != NULL) { 218 if (rdev->uvd.saved_bo != NULL) {
199 unsigned size = radeon_bo_size(rdev->uvd.vcpu_bo); 219 memcpy(ptr, rdev->uvd.saved_bo, size);
200 memcpy(rdev->uvd.cpu_addr, rdev->uvd.saved_bo, size);
201 kfree(rdev->uvd.saved_bo); 220 kfree(rdev->uvd.saved_bo);
202 rdev->uvd.saved_bo = NULL; 221 rdev->uvd.saved_bo = NULL;
203 } 222 } else
223 memset(ptr, 0, size);
204 224
205 return 0; 225 return 0;
206} 226}
@@ -215,8 +235,8 @@ void radeon_uvd_free_handles(struct radeon_device *rdev, struct drm_file *filp)
215{ 235{
216 int i, r; 236 int i, r;
217 for (i = 0; i < RADEON_MAX_UVD_HANDLES; ++i) { 237 for (i = 0; i < RADEON_MAX_UVD_HANDLES; ++i) {
218 if (rdev->uvd.filp[i] == filp) { 238 uint32_t handle = atomic_read(&rdev->uvd.handles[i]);
219 uint32_t handle = atomic_read(&rdev->uvd.handles[i]); 239 if (handle != 0 && rdev->uvd.filp[i] == filp) {
220 struct radeon_fence *fence; 240 struct radeon_fence *fence;
221 241
222 r = radeon_uvd_get_destroy_msg(rdev, 242 r = radeon_uvd_get_destroy_msg(rdev,
@@ -336,9 +356,19 @@ static int radeon_uvd_cs_msg(struct radeon_cs_parser *p, struct radeon_bo *bo,
336 return -EINVAL; 356 return -EINVAL;
337 } 357 }
338 358
359 if (bo->tbo.sync_obj) {
360 r = radeon_fence_wait(bo->tbo.sync_obj, false);
361 if (r) {
362 DRM_ERROR("Failed waiting for UVD message (%d)!\n", r);
363 return r;
364 }
365 }
366
339 r = radeon_bo_kmap(bo, &ptr); 367 r = radeon_bo_kmap(bo, &ptr);
340 if (r) 368 if (r) {
369 DRM_ERROR("Failed mapping the UVD message (%d)!\n", r);
341 return r; 370 return r;
371 }
342 372
343 msg = ptr + offset; 373 msg = ptr + offset;
344 374
@@ -364,8 +394,14 @@ static int radeon_uvd_cs_msg(struct radeon_cs_parser *p, struct radeon_bo *bo,
364 radeon_bo_kunmap(bo); 394 radeon_bo_kunmap(bo);
365 return 0; 395 return 0;
366 } else { 396 } else {
367 /* it's a create msg, no special handling needed */
368 radeon_bo_kunmap(bo); 397 radeon_bo_kunmap(bo);
398
399 if (msg_type != 0) {
400 DRM_ERROR("Illegal UVD message type (%d)!\n", msg_type);
401 return -EINVAL;
402 }
403
404 /* it's a create msg, no special handling needed */
369 } 405 }
370 406
371 /* create or decode, validate the handle */ 407 /* create or decode, validate the handle */
@@ -388,7 +424,7 @@ static int radeon_uvd_cs_msg(struct radeon_cs_parser *p, struct radeon_bo *bo,
388 424
389static int radeon_uvd_cs_reloc(struct radeon_cs_parser *p, 425static int radeon_uvd_cs_reloc(struct radeon_cs_parser *p,
390 int data0, int data1, 426 int data0, int data1,
391 unsigned buf_sizes[]) 427 unsigned buf_sizes[], bool *has_msg_cmd)
392{ 428{
393 struct radeon_cs_chunk *relocs_chunk; 429 struct radeon_cs_chunk *relocs_chunk;
394 struct radeon_cs_reloc *reloc; 430 struct radeon_cs_reloc *reloc;
@@ -417,7 +453,7 @@ static int radeon_uvd_cs_reloc(struct radeon_cs_parser *p,
417 453
418 if (cmd < 0x4) { 454 if (cmd < 0x4) {
419 if ((end - start) < buf_sizes[cmd]) { 455 if ((end - start) < buf_sizes[cmd]) {
420 DRM_ERROR("buffer to small (%d / %d)!\n", 456 DRM_ERROR("buffer (%d) to small (%d / %d)!\n", cmd,
421 (unsigned)(end - start), buf_sizes[cmd]); 457 (unsigned)(end - start), buf_sizes[cmd]);
422 return -EINVAL; 458 return -EINVAL;
423 } 459 }
@@ -442,9 +478,17 @@ static int radeon_uvd_cs_reloc(struct radeon_cs_parser *p,
442 } 478 }
443 479
444 if (cmd == 0) { 480 if (cmd == 0) {
481 if (*has_msg_cmd) {
482 DRM_ERROR("More than one message in a UVD-IB!\n");
483 return -EINVAL;
484 }
485 *has_msg_cmd = true;
445 r = radeon_uvd_cs_msg(p, reloc->robj, offset, buf_sizes); 486 r = radeon_uvd_cs_msg(p, reloc->robj, offset, buf_sizes);
446 if (r) 487 if (r)
447 return r; 488 return r;
489 } else if (!*has_msg_cmd) {
490 DRM_ERROR("Message needed before other commands are send!\n");
491 return -EINVAL;
448 } 492 }
449 493
450 return 0; 494 return 0;
@@ -453,7 +497,8 @@ static int radeon_uvd_cs_reloc(struct radeon_cs_parser *p,
453static int radeon_uvd_cs_reg(struct radeon_cs_parser *p, 497static int radeon_uvd_cs_reg(struct radeon_cs_parser *p,
454 struct radeon_cs_packet *pkt, 498 struct radeon_cs_packet *pkt,
455 int *data0, int *data1, 499 int *data0, int *data1,
456 unsigned buf_sizes[]) 500 unsigned buf_sizes[],
501 bool *has_msg_cmd)
457{ 502{
458 int i, r; 503 int i, r;
459 504
@@ -467,7 +512,8 @@ static int radeon_uvd_cs_reg(struct radeon_cs_parser *p,
467 *data1 = p->idx; 512 *data1 = p->idx;
468 break; 513 break;
469 case UVD_GPCOM_VCPU_CMD: 514 case UVD_GPCOM_VCPU_CMD:
470 r = radeon_uvd_cs_reloc(p, *data0, *data1, buf_sizes); 515 r = radeon_uvd_cs_reloc(p, *data0, *data1,
516 buf_sizes, has_msg_cmd);
471 if (r) 517 if (r)
472 return r; 518 return r;
473 break; 519 break;
@@ -488,6 +534,9 @@ int radeon_uvd_cs_parse(struct radeon_cs_parser *p)
488 struct radeon_cs_packet pkt; 534 struct radeon_cs_packet pkt;
489 int r, data0 = 0, data1 = 0; 535 int r, data0 = 0, data1 = 0;
490 536
537 /* does the IB has a msg command */
538 bool has_msg_cmd = false;
539
491 /* minimum buffer sizes */ 540 /* minimum buffer sizes */
492 unsigned buf_sizes[] = { 541 unsigned buf_sizes[] = {
493 [0x00000000] = 2048, 542 [0x00000000] = 2048,
@@ -514,8 +563,8 @@ int radeon_uvd_cs_parse(struct radeon_cs_parser *p)
514 return r; 563 return r;
515 switch (pkt.type) { 564 switch (pkt.type) {
516 case RADEON_PACKET_TYPE0: 565 case RADEON_PACKET_TYPE0:
517 r = radeon_uvd_cs_reg(p, &pkt, &data0, 566 r = radeon_uvd_cs_reg(p, &pkt, &data0, &data1,
518 &data1, buf_sizes); 567 buf_sizes, &has_msg_cmd);
519 if (r) 568 if (r)
520 return r; 569 return r;
521 break; 570 break;
@@ -527,6 +576,12 @@ int radeon_uvd_cs_parse(struct radeon_cs_parser *p)
527 return -EINVAL; 576 return -EINVAL;
528 } 577 }
529 } while (p->idx < p->chunks[p->chunk_ib_idx].length_dw); 578 } while (p->idx < p->chunks[p->chunk_ib_idx].length_dw);
579
580 if (!has_msg_cmd) {
581 DRM_ERROR("UVD-IBs need a msg command!\n");
582 return -EINVAL;
583 }
584
530 return 0; 585 return 0;
531} 586}
532 587
diff --git a/drivers/gpu/drm/radeon/rv6xx_dpm.c b/drivers/gpu/drm/radeon/rv6xx_dpm.c
index 363018c60412..bdd888b4db2b 100644
--- a/drivers/gpu/drm/radeon/rv6xx_dpm.c
+++ b/drivers/gpu/drm/radeon/rv6xx_dpm.c
@@ -1944,9 +1944,7 @@ static int rv6xx_parse_power_table(struct radeon_device *rdev)
1944 1944
1945int rv6xx_dpm_init(struct radeon_device *rdev) 1945int rv6xx_dpm_init(struct radeon_device *rdev)
1946{ 1946{
1947 int index = GetIndexIntoMasterTable(DATA, ASIC_InternalSS_Info); 1947 struct radeon_atom_ss ss;
1948 uint16_t data_offset, size;
1949 uint8_t frev, crev;
1950 struct atom_clock_dividers dividers; 1948 struct atom_clock_dividers dividers;
1951 struct rv6xx_power_info *pi; 1949 struct rv6xx_power_info *pi;
1952 int ret; 1950 int ret;
@@ -1989,16 +1987,18 @@ int rv6xx_dpm_init(struct radeon_device *rdev)
1989 1987
1990 pi->gfx_clock_gating = true; 1988 pi->gfx_clock_gating = true;
1991 1989
1992 if (atom_parse_data_header(rdev->mode_info.atom_context, index, &size, 1990 pi->sclk_ss = radeon_atombios_get_asic_ss_info(rdev, &ss,
1993 &frev, &crev, &data_offset)) { 1991 ASIC_INTERNAL_ENGINE_SS, 0);
1994 pi->sclk_ss = true; 1992 pi->mclk_ss = radeon_atombios_get_asic_ss_info(rdev, &ss,
1995 pi->mclk_ss = true; 1993 ASIC_INTERNAL_MEMORY_SS, 0);
1994
1995 /* Disable sclk ss, causes hangs on a lot of systems */
1996 pi->sclk_ss = false;
1997
1998 if (pi->sclk_ss || pi->mclk_ss)
1996 pi->dynamic_ss = true; 1999 pi->dynamic_ss = true;
1997 } else { 2000 else
1998 pi->sclk_ss = false;
1999 pi->mclk_ss = false;
2000 pi->dynamic_ss = false; 2001 pi->dynamic_ss = false;
2001 }
2002 2002
2003 pi->dynamic_pcie_gen2 = true; 2003 pi->dynamic_pcie_gen2 = true;
2004 2004
diff --git a/drivers/gpu/drm/radeon/rv770.c b/drivers/gpu/drm/radeon/rv770.c
index 30ea14e8854c..f5e92cfcc140 100644
--- a/drivers/gpu/drm/radeon/rv770.c
+++ b/drivers/gpu/drm/radeon/rv770.c
@@ -744,10 +744,10 @@ static void rv770_init_golden_registers(struct radeon_device *rdev)
744 (const u32)ARRAY_SIZE(r7xx_golden_dyn_gpr_registers)); 744 (const u32)ARRAY_SIZE(r7xx_golden_dyn_gpr_registers));
745 radeon_program_register_sequence(rdev, 745 radeon_program_register_sequence(rdev,
746 rv730_golden_registers, 746 rv730_golden_registers,
747 (const u32)ARRAY_SIZE(rv770_golden_registers)); 747 (const u32)ARRAY_SIZE(rv730_golden_registers));
748 radeon_program_register_sequence(rdev, 748 radeon_program_register_sequence(rdev,
749 rv730_mgcg_init, 749 rv730_mgcg_init,
750 (const u32)ARRAY_SIZE(rv770_mgcg_init)); 750 (const u32)ARRAY_SIZE(rv730_mgcg_init));
751 break; 751 break;
752 case CHIP_RV710: 752 case CHIP_RV710:
753 radeon_program_register_sequence(rdev, 753 radeon_program_register_sequence(rdev,
@@ -758,18 +758,18 @@ static void rv770_init_golden_registers(struct radeon_device *rdev)
758 (const u32)ARRAY_SIZE(r7xx_golden_dyn_gpr_registers)); 758 (const u32)ARRAY_SIZE(r7xx_golden_dyn_gpr_registers));
759 radeon_program_register_sequence(rdev, 759 radeon_program_register_sequence(rdev,
760 rv710_golden_registers, 760 rv710_golden_registers,
761 (const u32)ARRAY_SIZE(rv770_golden_registers)); 761 (const u32)ARRAY_SIZE(rv710_golden_registers));
762 radeon_program_register_sequence(rdev, 762 radeon_program_register_sequence(rdev,
763 rv710_mgcg_init, 763 rv710_mgcg_init,
764 (const u32)ARRAY_SIZE(rv770_mgcg_init)); 764 (const u32)ARRAY_SIZE(rv710_mgcg_init));
765 break; 765 break;
766 case CHIP_RV740: 766 case CHIP_RV740:
767 radeon_program_register_sequence(rdev, 767 radeon_program_register_sequence(rdev,
768 rv740_golden_registers, 768 rv740_golden_registers,
769 (const u32)ARRAY_SIZE(rv770_golden_registers)); 769 (const u32)ARRAY_SIZE(rv740_golden_registers));
770 radeon_program_register_sequence(rdev, 770 radeon_program_register_sequence(rdev,
771 rv740_mgcg_init, 771 rv740_mgcg_init,
772 (const u32)ARRAY_SIZE(rv770_mgcg_init)); 772 (const u32)ARRAY_SIZE(rv740_mgcg_init));
773 break; 773 break;
774 default: 774 default:
775 break; 775 break;
@@ -813,7 +813,7 @@ int rv770_uvd_resume(struct radeon_device *rdev)
813 813
814 /* programm the VCPU memory controller bits 0-27 */ 814 /* programm the VCPU memory controller bits 0-27 */
815 addr = rdev->uvd.gpu_addr >> 3; 815 addr = rdev->uvd.gpu_addr >> 3;
816 size = RADEON_GPU_PAGE_ALIGN(rdev->uvd.fw_size + 4) >> 3; 816 size = RADEON_GPU_PAGE_ALIGN(rdev->uvd_fw->size + 4) >> 3;
817 WREG32(UVD_VCPU_CACHE_OFFSET0, addr); 817 WREG32(UVD_VCPU_CACHE_OFFSET0, addr);
818 WREG32(UVD_VCPU_CACHE_SIZE0, size); 818 WREG32(UVD_VCPU_CACHE_SIZE0, size);
819 819
@@ -1829,6 +1829,8 @@ static int rv770_startup(struct radeon_device *rdev)
1829 /* enable pcie gen2 link */ 1829 /* enable pcie gen2 link */
1830 rv770_pcie_gen2_enable(rdev); 1830 rv770_pcie_gen2_enable(rdev);
1831 1831
1832 rv770_mc_program(rdev);
1833
1832 if (!rdev->me_fw || !rdev->pfp_fw || !rdev->rlc_fw) { 1834 if (!rdev->me_fw || !rdev->pfp_fw || !rdev->rlc_fw) {
1833 r = r600_init_microcode(rdev); 1835 r = r600_init_microcode(rdev);
1834 if (r) { 1836 if (r) {
@@ -1841,7 +1843,6 @@ static int rv770_startup(struct radeon_device *rdev)
1841 if (r) 1843 if (r)
1842 return r; 1844 return r;
1843 1845
1844 rv770_mc_program(rdev);
1845 if (rdev->flags & RADEON_IS_AGP) { 1846 if (rdev->flags & RADEON_IS_AGP) {
1846 rv770_agp_enable(rdev); 1847 rv770_agp_enable(rdev);
1847 } else { 1848 } else {
@@ -1983,6 +1984,7 @@ int rv770_resume(struct radeon_device *rdev)
1983int rv770_suspend(struct radeon_device *rdev) 1984int rv770_suspend(struct radeon_device *rdev)
1984{ 1985{
1985 r600_audio_fini(rdev); 1986 r600_audio_fini(rdev);
1987 r600_uvd_stop(rdev);
1986 radeon_uvd_suspend(rdev); 1988 radeon_uvd_suspend(rdev);
1987 r700_cp_stop(rdev); 1989 r700_cp_stop(rdev);
1988 r600_dma_stop(rdev); 1990 r600_dma_stop(rdev);
@@ -2098,6 +2100,7 @@ void rv770_fini(struct radeon_device *rdev)
2098 radeon_ib_pool_fini(rdev); 2100 radeon_ib_pool_fini(rdev);
2099 radeon_irq_kms_fini(rdev); 2101 radeon_irq_kms_fini(rdev);
2100 rv770_pcie_gart_fini(rdev); 2102 rv770_pcie_gart_fini(rdev);
2103 r600_uvd_stop(rdev);
2101 radeon_uvd_fini(rdev); 2104 radeon_uvd_fini(rdev);
2102 r600_vram_scratch_fini(rdev); 2105 r600_vram_scratch_fini(rdev);
2103 radeon_gem_fini(rdev); 2106 radeon_gem_fini(rdev);
diff --git a/drivers/gpu/drm/radeon/rv770_dpm.c b/drivers/gpu/drm/radeon/rv770_dpm.c
index 2d347925f77d..094c67a29d0d 100644
--- a/drivers/gpu/drm/radeon/rv770_dpm.c
+++ b/drivers/gpu/drm/radeon/rv770_dpm.c
@@ -2319,12 +2319,25 @@ int rv7xx_parse_power_table(struct radeon_device *rdev)
2319 return 0; 2319 return 0;
2320} 2320}
2321 2321
2322void rv770_get_engine_memory_ss(struct radeon_device *rdev)
2323{
2324 struct rv7xx_power_info *pi = rv770_get_pi(rdev);
2325 struct radeon_atom_ss ss;
2326
2327 pi->sclk_ss = radeon_atombios_get_asic_ss_info(rdev, &ss,
2328 ASIC_INTERNAL_ENGINE_SS, 0);
2329 pi->mclk_ss = radeon_atombios_get_asic_ss_info(rdev, &ss,
2330 ASIC_INTERNAL_MEMORY_SS, 0);
2331
2332 if (pi->sclk_ss || pi->mclk_ss)
2333 pi->dynamic_ss = true;
2334 else
2335 pi->dynamic_ss = false;
2336}
2337
2322int rv770_dpm_init(struct radeon_device *rdev) 2338int rv770_dpm_init(struct radeon_device *rdev)
2323{ 2339{
2324 struct rv7xx_power_info *pi; 2340 struct rv7xx_power_info *pi;
2325 int index = GetIndexIntoMasterTable(DATA, ASIC_InternalSS_Info);
2326 uint16_t data_offset, size;
2327 uint8_t frev, crev;
2328 struct atom_clock_dividers dividers; 2341 struct atom_clock_dividers dividers;
2329 int ret; 2342 int ret;
2330 2343
@@ -2369,16 +2382,7 @@ int rv770_dpm_init(struct radeon_device *rdev)
2369 pi->mvdd_control = 2382 pi->mvdd_control =
2370 radeon_atom_is_voltage_gpio(rdev, SET_VOLTAGE_TYPE_ASIC_MVDDC, 0); 2383 radeon_atom_is_voltage_gpio(rdev, SET_VOLTAGE_TYPE_ASIC_MVDDC, 0);
2371 2384
2372 if (atom_parse_data_header(rdev->mode_info.atom_context, index, &size, 2385 rv770_get_engine_memory_ss(rdev);
2373 &frev, &crev, &data_offset)) {
2374 pi->sclk_ss = true;
2375 pi->mclk_ss = true;
2376 pi->dynamic_ss = true;
2377 } else {
2378 pi->sclk_ss = false;
2379 pi->mclk_ss = false;
2380 pi->dynamic_ss = false;
2381 }
2382 2386
2383 pi->asi = RV770_ASI_DFLT; 2387 pi->asi = RV770_ASI_DFLT;
2384 pi->pasi = RV770_HASI_DFLT; 2388 pi->pasi = RV770_HASI_DFLT;
@@ -2393,8 +2397,7 @@ int rv770_dpm_init(struct radeon_device *rdev)
2393 2397
2394 pi->dynamic_pcie_gen2 = true; 2398 pi->dynamic_pcie_gen2 = true;
2395 2399
2396 if (pi->gfx_clock_gating && 2400 if (rdev->pm.int_thermal_type != THERMAL_TYPE_NONE)
2397 (rdev->pm.int_thermal_type != THERMAL_TYPE_NONE))
2398 pi->thermal_protection = true; 2401 pi->thermal_protection = true;
2399 else 2402 else
2400 pi->thermal_protection = false; 2403 pi->thermal_protection = false;
diff --git a/drivers/gpu/drm/radeon/rv770_dpm.h b/drivers/gpu/drm/radeon/rv770_dpm.h
index 96b1b2a62a8a..9244effc6b59 100644
--- a/drivers/gpu/drm/radeon/rv770_dpm.h
+++ b/drivers/gpu/drm/radeon/rv770_dpm.h
@@ -275,6 +275,7 @@ void rv770_set_uvd_clock_before_set_eng_clock(struct radeon_device *rdev,
275void rv770_set_uvd_clock_after_set_eng_clock(struct radeon_device *rdev, 275void rv770_set_uvd_clock_after_set_eng_clock(struct radeon_device *rdev,
276 struct radeon_ps *new_ps, 276 struct radeon_ps *new_ps,
277 struct radeon_ps *old_ps); 277 struct radeon_ps *old_ps);
278void rv770_get_engine_memory_ss(struct radeon_device *rdev);
278 279
279/* smc */ 280/* smc */
280int rv770_read_smc_soft_register(struct radeon_device *rdev, 281int rv770_read_smc_soft_register(struct radeon_device *rdev,
diff --git a/drivers/gpu/drm/radeon/si.c b/drivers/gpu/drm/radeon/si.c
index 6ca904673a4f..daa8d2df8ec5 100644
--- a/drivers/gpu/drm/radeon/si.c
+++ b/drivers/gpu/drm/radeon/si.c
@@ -1663,9 +1663,13 @@ static int si_init_microcode(struct radeon_device *rdev)
1663 1663
1664 snprintf(fw_name, sizeof(fw_name), "radeon/%s_smc.bin", chip_name); 1664 snprintf(fw_name, sizeof(fw_name), "radeon/%s_smc.bin", chip_name);
1665 err = request_firmware(&rdev->smc_fw, fw_name, rdev->dev); 1665 err = request_firmware(&rdev->smc_fw, fw_name, rdev->dev);
1666 if (err) 1666 if (err) {
1667 goto out; 1667 printk(KERN_ERR
1668 if (rdev->smc_fw->size != smc_req_size) { 1668 "smc: error loading firmware \"%s\"\n",
1669 fw_name);
1670 release_firmware(rdev->smc_fw);
1671 rdev->smc_fw = NULL;
1672 } else if (rdev->smc_fw->size != smc_req_size) {
1669 printk(KERN_ERR 1673 printk(KERN_ERR
1670 "si_smc: Bogus length %zu in firmware \"%s\"\n", 1674 "si_smc: Bogus length %zu in firmware \"%s\"\n",
1671 rdev->smc_fw->size, fw_name); 1675 rdev->smc_fw->size, fw_name);
@@ -6418,6 +6422,8 @@ static int si_startup(struct radeon_device *rdev)
6418 /* enable aspm */ 6422 /* enable aspm */
6419 si_program_aspm(rdev); 6423 si_program_aspm(rdev);
6420 6424
6425 si_mc_program(rdev);
6426
6421 if (!rdev->me_fw || !rdev->pfp_fw || !rdev->ce_fw || 6427 if (!rdev->me_fw || !rdev->pfp_fw || !rdev->ce_fw ||
6422 !rdev->rlc_fw || !rdev->mc_fw) { 6428 !rdev->rlc_fw || !rdev->mc_fw) {
6423 r = si_init_microcode(rdev); 6429 r = si_init_microcode(rdev);
@@ -6437,7 +6443,6 @@ static int si_startup(struct radeon_device *rdev)
6437 if (r) 6443 if (r)
6438 return r; 6444 return r;
6439 6445
6440 si_mc_program(rdev);
6441 r = si_pcie_gart_enable(rdev); 6446 r = si_pcie_gart_enable(rdev);
6442 if (r) 6447 if (r)
6443 return r; 6448 return r;
@@ -6621,7 +6626,7 @@ int si_suspend(struct radeon_device *rdev)
6621 si_cp_enable(rdev, false); 6626 si_cp_enable(rdev, false);
6622 cayman_dma_stop(rdev); 6627 cayman_dma_stop(rdev);
6623 if (rdev->has_uvd) { 6628 if (rdev->has_uvd) {
6624 r600_uvd_rbc_stop(rdev); 6629 r600_uvd_stop(rdev);
6625 radeon_uvd_suspend(rdev); 6630 radeon_uvd_suspend(rdev);
6626 } 6631 }
6627 si_irq_suspend(rdev); 6632 si_irq_suspend(rdev);
@@ -6763,8 +6768,10 @@ void si_fini(struct radeon_device *rdev)
6763 radeon_vm_manager_fini(rdev); 6768 radeon_vm_manager_fini(rdev);
6764 radeon_ib_pool_fini(rdev); 6769 radeon_ib_pool_fini(rdev);
6765 radeon_irq_kms_fini(rdev); 6770 radeon_irq_kms_fini(rdev);
6766 if (rdev->has_uvd) 6771 if (rdev->has_uvd) {
6772 r600_uvd_stop(rdev);
6767 radeon_uvd_fini(rdev); 6773 radeon_uvd_fini(rdev);
6774 }
6768 si_pcie_gart_fini(rdev); 6775 si_pcie_gart_fini(rdev);
6769 r600_vram_scratch_fini(rdev); 6776 r600_vram_scratch_fini(rdev);
6770 radeon_gem_fini(rdev); 6777 radeon_gem_fini(rdev);
diff --git a/drivers/gpu/drm/radeon/si_dpm.c b/drivers/gpu/drm/radeon/si_dpm.c
index 41825575b403..88699e3cd868 100644
--- a/drivers/gpu/drm/radeon/si_dpm.c
+++ b/drivers/gpu/drm/radeon/si_dpm.c
@@ -2903,7 +2903,8 @@ static void si_apply_state_adjust_rules(struct radeon_device *rdev,
2903{ 2903{
2904 struct ni_ps *ps = ni_get_ps(rps); 2904 struct ni_ps *ps = ni_get_ps(rps);
2905 struct radeon_clock_and_voltage_limits *max_limits; 2905 struct radeon_clock_and_voltage_limits *max_limits;
2906 bool disable_mclk_switching; 2906 bool disable_mclk_switching = false;
2907 bool disable_sclk_switching = false;
2907 u32 mclk, sclk; 2908 u32 mclk, sclk;
2908 u16 vddc, vddci; 2909 u16 vddc, vddci;
2909 int i; 2910 int i;
@@ -2911,8 +2912,11 @@ static void si_apply_state_adjust_rules(struct radeon_device *rdev,
2911 if ((rdev->pm.dpm.new_active_crtc_count > 1) || 2912 if ((rdev->pm.dpm.new_active_crtc_count > 1) ||
2912 ni_dpm_vblank_too_short(rdev)) 2913 ni_dpm_vblank_too_short(rdev))
2913 disable_mclk_switching = true; 2914 disable_mclk_switching = true;
2914 else 2915
2915 disable_mclk_switching = false; 2916 if (rps->vclk || rps->dclk) {
2917 disable_mclk_switching = true;
2918 disable_sclk_switching = true;
2919 }
2916 2920
2917 if (rdev->pm.dpm.ac_power) 2921 if (rdev->pm.dpm.ac_power)
2918 max_limits = &rdev->pm.dpm.dyn_state.max_clock_voltage_on_ac; 2922 max_limits = &rdev->pm.dpm.dyn_state.max_clock_voltage_on_ac;
@@ -2940,27 +2944,43 @@ static void si_apply_state_adjust_rules(struct radeon_device *rdev,
2940 2944
2941 if (disable_mclk_switching) { 2945 if (disable_mclk_switching) {
2942 mclk = ps->performance_levels[ps->performance_level_count - 1].mclk; 2946 mclk = ps->performance_levels[ps->performance_level_count - 1].mclk;
2943 sclk = ps->performance_levels[0].sclk;
2944 vddc = ps->performance_levels[0].vddc;
2945 vddci = ps->performance_levels[ps->performance_level_count - 1].vddci; 2947 vddci = ps->performance_levels[ps->performance_level_count - 1].vddci;
2946 } else { 2948 } else {
2947 sclk = ps->performance_levels[0].sclk;
2948 mclk = ps->performance_levels[0].mclk; 2949 mclk = ps->performance_levels[0].mclk;
2949 vddc = ps->performance_levels[0].vddc;
2950 vddci = ps->performance_levels[0].vddci; 2950 vddci = ps->performance_levels[0].vddci;
2951 } 2951 }
2952 2952
2953 if (disable_sclk_switching) {
2954 sclk = ps->performance_levels[ps->performance_level_count - 1].sclk;
2955 vddc = ps->performance_levels[ps->performance_level_count - 1].vddc;
2956 } else {
2957 sclk = ps->performance_levels[0].sclk;
2958 vddc = ps->performance_levels[0].vddc;
2959 }
2960
2953 /* adjusted low state */ 2961 /* adjusted low state */
2954 ps->performance_levels[0].sclk = sclk; 2962 ps->performance_levels[0].sclk = sclk;
2955 ps->performance_levels[0].mclk = mclk; 2963 ps->performance_levels[0].mclk = mclk;
2956 ps->performance_levels[0].vddc = vddc; 2964 ps->performance_levels[0].vddc = vddc;
2957 ps->performance_levels[0].vddci = vddci; 2965 ps->performance_levels[0].vddci = vddci;
2958 2966
2959 for (i = 1; i < ps->performance_level_count; i++) { 2967 if (disable_sclk_switching) {
2960 if (ps->performance_levels[i].sclk < ps->performance_levels[i - 1].sclk) 2968 sclk = ps->performance_levels[0].sclk;
2961 ps->performance_levels[i].sclk = ps->performance_levels[i - 1].sclk; 2969 for (i = 1; i < ps->performance_level_count; i++) {
2962 if (ps->performance_levels[i].vddc < ps->performance_levels[i - 1].vddc) 2970 if (sclk < ps->performance_levels[i].sclk)
2963 ps->performance_levels[i].vddc = ps->performance_levels[i - 1].vddc; 2971 sclk = ps->performance_levels[i].sclk;
2972 }
2973 for (i = 0; i < ps->performance_level_count; i++) {
2974 ps->performance_levels[i].sclk = sclk;
2975 ps->performance_levels[i].vddc = vddc;
2976 }
2977 } else {
2978 for (i = 1; i < ps->performance_level_count; i++) {
2979 if (ps->performance_levels[i].sclk < ps->performance_levels[i - 1].sclk)
2980 ps->performance_levels[i].sclk = ps->performance_levels[i - 1].sclk;
2981 if (ps->performance_levels[i].vddc < ps->performance_levels[i - 1].vddc)
2982 ps->performance_levels[i].vddc = ps->performance_levels[i - 1].vddc;
2983 }
2964 } 2984 }
2965 2985
2966 if (disable_mclk_switching) { 2986 if (disable_mclk_switching) {
@@ -6253,9 +6273,6 @@ int si_dpm_init(struct radeon_device *rdev)
6253 struct evergreen_power_info *eg_pi; 6273 struct evergreen_power_info *eg_pi;
6254 struct ni_power_info *ni_pi; 6274 struct ni_power_info *ni_pi;
6255 struct si_power_info *si_pi; 6275 struct si_power_info *si_pi;
6256 int index = GetIndexIntoMasterTable(DATA, ASIC_InternalSS_Info);
6257 u16 data_offset, size;
6258 u8 frev, crev;
6259 struct atom_clock_dividers dividers; 6276 struct atom_clock_dividers dividers;
6260 int ret; 6277 int ret;
6261 u32 mask; 6278 u32 mask;
@@ -6346,16 +6363,7 @@ int si_dpm_init(struct radeon_device *rdev)
6346 si_pi->vddc_phase_shed_control = 6363 si_pi->vddc_phase_shed_control =
6347 radeon_atom_is_voltage_gpio(rdev, SET_VOLTAGE_TYPE_ASIC_VDDC, VOLTAGE_OBJ_PHASE_LUT); 6364 radeon_atom_is_voltage_gpio(rdev, SET_VOLTAGE_TYPE_ASIC_VDDC, VOLTAGE_OBJ_PHASE_LUT);
6348 6365
6349 if (atom_parse_data_header(rdev->mode_info.atom_context, index, &size, 6366 rv770_get_engine_memory_ss(rdev);
6350 &frev, &crev, &data_offset)) {
6351 pi->sclk_ss = true;
6352 pi->mclk_ss = true;
6353 pi->dynamic_ss = true;
6354 } else {
6355 pi->sclk_ss = false;
6356 pi->mclk_ss = false;
6357 pi->dynamic_ss = true;
6358 }
6359 6367
6360 pi->asi = RV770_ASI_DFLT; 6368 pi->asi = RV770_ASI_DFLT;
6361 pi->pasi = CYPRESS_HASI_DFLT; 6369 pi->pasi = CYPRESS_HASI_DFLT;
@@ -6366,8 +6374,7 @@ int si_dpm_init(struct radeon_device *rdev)
6366 eg_pi->sclk_deep_sleep = true; 6374 eg_pi->sclk_deep_sleep = true;
6367 si_pi->sclk_deep_sleep_above_low = false; 6375 si_pi->sclk_deep_sleep_above_low = false;
6368 6376
6369 if (pi->gfx_clock_gating && 6377 if (rdev->pm.int_thermal_type != THERMAL_TYPE_NONE)
6370 (rdev->pm.int_thermal_type != THERMAL_TYPE_NONE))
6371 pi->thermal_protection = true; 6378 pi->thermal_protection = true;
6372 else 6379 else
6373 pi->thermal_protection = false; 6380 pi->thermal_protection = false;
diff --git a/drivers/hid/hid-logitech-dj.c b/drivers/hid/hid-logitech-dj.c
index 7a5764843bfb..cd33084c7860 100644
--- a/drivers/hid/hid-logitech-dj.c
+++ b/drivers/hid/hid-logitech-dj.c
@@ -488,8 +488,6 @@ static int logi_dj_recv_query_paired_devices(struct dj_receiver_dev *djrcv_dev)
488 if (djrcv_dev->querying_devices) 488 if (djrcv_dev->querying_devices)
489 return 0; 489 return 0;
490 490
491 djrcv_dev->querying_devices = true;
492
493 dj_report = kzalloc(sizeof(struct dj_report), GFP_KERNEL); 491 dj_report = kzalloc(sizeof(struct dj_report), GFP_KERNEL);
494 if (!dj_report) 492 if (!dj_report)
495 return -ENOMEM; 493 return -ENOMEM;
diff --git a/drivers/hwmon/adt7470.c b/drivers/hwmon/adt7470.c
index 0f34bca9f5e5..6099f50b28aa 100644
--- a/drivers/hwmon/adt7470.c
+++ b/drivers/hwmon/adt7470.c
@@ -215,7 +215,7 @@ static inline int adt7470_write_word_data(struct i2c_client *client, u8 reg,
215 u16 value) 215 u16 value)
216{ 216{
217 return i2c_smbus_write_byte_data(client, reg, value & 0xFF) 217 return i2c_smbus_write_byte_data(client, reg, value & 0xFF)
218 && i2c_smbus_write_byte_data(client, reg + 1, value >> 8); 218 || i2c_smbus_write_byte_data(client, reg + 1, value >> 8);
219} 219}
220 220
221static void adt7470_init_client(struct i2c_client *client) 221static void adt7470_init_client(struct i2c_client *client)
diff --git a/drivers/i2c/busses/i2c-kempld.c b/drivers/i2c/busses/i2c-kempld.c
index ccec916bc3eb..af8f65fb1c05 100644
--- a/drivers/i2c/busses/i2c-kempld.c
+++ b/drivers/i2c/busses/i2c-kempld.c
@@ -246,9 +246,9 @@ static void kempld_i2c_device_init(struct kempld_i2c_data *i2c)
246 bus_frequency = KEMPLD_I2C_FREQ_MAX; 246 bus_frequency = KEMPLD_I2C_FREQ_MAX;
247 247
248 if (pld->info.spec_major == 1) 248 if (pld->info.spec_major == 1)
249 prescale = pld->pld_clock / bus_frequency * 5 - 1000; 249 prescale = pld->pld_clock / (bus_frequency * 5) - 1000;
250 else 250 else
251 prescale = pld->pld_clock / bus_frequency * 4 - 3000; 251 prescale = pld->pld_clock / (bus_frequency * 4) - 3000;
252 252
253 if (prescale < 0) 253 if (prescale < 0)
254 prescale = 0; 254 prescale = 0;
diff --git a/drivers/i2c/busses/i2c-mxs.c b/drivers/i2c/busses/i2c-mxs.c
index df8ff5aea5b5..e2e9a0dade96 100644
--- a/drivers/i2c/busses/i2c-mxs.c
+++ b/drivers/i2c/busses/i2c-mxs.c
@@ -493,7 +493,7 @@ static int mxs_i2c_xfer_msg(struct i2c_adapter *adap, struct i2c_msg *msg,
493 * based on this empirical measurement and a lot of previous frobbing. 493 * based on this empirical measurement and a lot of previous frobbing.
494 */ 494 */
495 i2c->cmd_err = 0; 495 i2c->cmd_err = 0;
496 if (msg->len < 8) { 496 if (0) { /* disable PIO mode until a proper fix is made */
497 ret = mxs_i2c_pio_setup_xfer(adap, msg, flags); 497 ret = mxs_i2c_pio_setup_xfer(adap, msg, flags);
498 if (ret) 498 if (ret)
499 mxs_i2c_reset(i2c); 499 mxs_i2c_reset(i2c);
diff --git a/drivers/ide/ide-acpi.c b/drivers/ide/ide-acpi.c
index f1a6796b165c..140c8ef50529 100644
--- a/drivers/ide/ide-acpi.c
+++ b/drivers/ide/ide-acpi.c
@@ -520,11 +520,12 @@ void ide_acpi_set_state(ide_hwif_t *hwif, int on)
520 ide_port_for_each_present_dev(i, drive, hwif) { 520 ide_port_for_each_present_dev(i, drive, hwif) {
521 if (drive->acpidata->obj_handle) 521 if (drive->acpidata->obj_handle)
522 acpi_bus_set_power(drive->acpidata->obj_handle, 522 acpi_bus_set_power(drive->acpidata->obj_handle,
523 on ? ACPI_STATE_D0 : ACPI_STATE_D3); 523 on ? ACPI_STATE_D0 : ACPI_STATE_D3_COLD);
524 } 524 }
525 525
526 if (!on) 526 if (!on)
527 acpi_bus_set_power(hwif->acpidata->obj_handle, ACPI_STATE_D3); 527 acpi_bus_set_power(hwif->acpidata->obj_handle,
528 ACPI_STATE_D3_COLD);
528} 529}
529 530
530/** 531/**
diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c
index 0ad208a69c29..3ceac3e91dde 100644
--- a/drivers/iio/adc/ti_am335x_adc.c
+++ b/drivers/iio/adc/ti_am335x_adc.c
@@ -60,7 +60,6 @@ static void tiadc_step_config(struct tiadc_device *adc_dev)
60{ 60{
61 unsigned int stepconfig; 61 unsigned int stepconfig;
62 int i, steps; 62 int i, steps;
63 u32 step_en;
64 63
65 /* 64 /*
66 * There are 16 configurable steps and 8 analog input 65 * There are 16 configurable steps and 8 analog input
@@ -86,8 +85,7 @@ static void tiadc_step_config(struct tiadc_device *adc_dev)
86 adc_dev->channel_step[i] = steps; 85 adc_dev->channel_step[i] = steps;
87 steps++; 86 steps++;
88 } 87 }
89 step_en = get_adc_step_mask(adc_dev); 88
90 am335x_tsc_se_set(adc_dev->mfd_tscadc, step_en);
91} 89}
92 90
93static const char * const chan_name_ain[] = { 91static const char * const chan_name_ain[] = {
@@ -142,10 +140,22 @@ static int tiadc_read_raw(struct iio_dev *indio_dev,
142 int *val, int *val2, long mask) 140 int *val, int *val2, long mask)
143{ 141{
144 struct tiadc_device *adc_dev = iio_priv(indio_dev); 142 struct tiadc_device *adc_dev = iio_priv(indio_dev);
145 int i; 143 int i, map_val;
146 unsigned int fifo1count, read; 144 unsigned int fifo1count, read, stepid;
147 u32 step = UINT_MAX; 145 u32 step = UINT_MAX;
148 bool found = false; 146 bool found = false;
147 u32 step_en;
148 unsigned long timeout = jiffies + usecs_to_jiffies
149 (IDLE_TIMEOUT * adc_dev->channels);
150 step_en = get_adc_step_mask(adc_dev);
151 am335x_tsc_se_set(adc_dev->mfd_tscadc, step_en);
152
153 /* Wait for ADC sequencer to complete sampling */
154 while (tiadc_readl(adc_dev, REG_ADCFSM) & SEQ_STATUS) {
155 if (time_after(jiffies, timeout))
156 return -EAGAIN;
157 }
158 map_val = chan->channel + TOTAL_CHANNELS;
149 159
150 /* 160 /*
151 * When the sub-system is first enabled, 161 * When the sub-system is first enabled,
@@ -170,12 +180,16 @@ static int tiadc_read_raw(struct iio_dev *indio_dev,
170 fifo1count = tiadc_readl(adc_dev, REG_FIFO1CNT); 180 fifo1count = tiadc_readl(adc_dev, REG_FIFO1CNT);
171 for (i = 0; i < fifo1count; i++) { 181 for (i = 0; i < fifo1count; i++) {
172 read = tiadc_readl(adc_dev, REG_FIFO1); 182 read = tiadc_readl(adc_dev, REG_FIFO1);
173 if (read >> 16 == step) { 183 stepid = read & FIFOREAD_CHNLID_MASK;
174 *val = read & 0xfff; 184 stepid = stepid >> 0x10;
185
186 if (stepid == map_val) {
187 read = read & FIFOREAD_DATA_MASK;
175 found = true; 188 found = true;
189 *val = read;
176 } 190 }
177 } 191 }
178 am335x_tsc_se_update(adc_dev->mfd_tscadc); 192
179 if (found == false) 193 if (found == false)
180 return -EBUSY; 194 return -EBUSY;
181 return IIO_VAL_INT; 195 return IIO_VAL_INT;
diff --git a/drivers/iio/industrialio-trigger.c b/drivers/iio/industrialio-trigger.c
index ea8a4146620d..0dd9bb873130 100644
--- a/drivers/iio/industrialio-trigger.c
+++ b/drivers/iio/industrialio-trigger.c
@@ -127,12 +127,17 @@ static struct iio_trigger *iio_trigger_find_by_name(const char *name,
127void iio_trigger_poll(struct iio_trigger *trig, s64 time) 127void iio_trigger_poll(struct iio_trigger *trig, s64 time)
128{ 128{
129 int i; 129 int i;
130 if (!trig->use_count) 130
131 for (i = 0; i < CONFIG_IIO_CONSUMERS_PER_TRIGGER; i++) 131 if (!atomic_read(&trig->use_count)) {
132 if (trig->subirqs[i].enabled) { 132 atomic_set(&trig->use_count, CONFIG_IIO_CONSUMERS_PER_TRIGGER);
133 trig->use_count++; 133
134 for (i = 0; i < CONFIG_IIO_CONSUMERS_PER_TRIGGER; i++) {
135 if (trig->subirqs[i].enabled)
134 generic_handle_irq(trig->subirq_base + i); 136 generic_handle_irq(trig->subirq_base + i);
135 } 137 else
138 iio_trigger_notify_done(trig);
139 }
140 }
136} 141}
137EXPORT_SYMBOL(iio_trigger_poll); 142EXPORT_SYMBOL(iio_trigger_poll);
138 143
@@ -146,19 +151,24 @@ EXPORT_SYMBOL(iio_trigger_generic_data_rdy_poll);
146void iio_trigger_poll_chained(struct iio_trigger *trig, s64 time) 151void iio_trigger_poll_chained(struct iio_trigger *trig, s64 time)
147{ 152{
148 int i; 153 int i;
149 if (!trig->use_count) 154
150 for (i = 0; i < CONFIG_IIO_CONSUMERS_PER_TRIGGER; i++) 155 if (!atomic_read(&trig->use_count)) {
151 if (trig->subirqs[i].enabled) { 156 atomic_set(&trig->use_count, CONFIG_IIO_CONSUMERS_PER_TRIGGER);
152 trig->use_count++; 157
158 for (i = 0; i < CONFIG_IIO_CONSUMERS_PER_TRIGGER; i++) {
159 if (trig->subirqs[i].enabled)
153 handle_nested_irq(trig->subirq_base + i); 160 handle_nested_irq(trig->subirq_base + i);
154 } 161 else
162 iio_trigger_notify_done(trig);
163 }
164 }
155} 165}
156EXPORT_SYMBOL(iio_trigger_poll_chained); 166EXPORT_SYMBOL(iio_trigger_poll_chained);
157 167
158void iio_trigger_notify_done(struct iio_trigger *trig) 168void iio_trigger_notify_done(struct iio_trigger *trig)
159{ 169{
160 trig->use_count--; 170 if (atomic_dec_and_test(&trig->use_count) && trig->ops &&
161 if (trig->use_count == 0 && trig->ops && trig->ops->try_reenable) 171 trig->ops->try_reenable)
162 if (trig->ops->try_reenable(trig)) 172 if (trig->ops->try_reenable(trig))
163 /* Missed an interrupt so launch new poll now */ 173 /* Missed an interrupt so launch new poll now */
164 iio_trigger_poll(trig, 0); 174 iio_trigger_poll(trig, 0);
diff --git a/drivers/iio/light/adjd_s311.c b/drivers/iio/light/adjd_s311.c
index 5f4749e60b04..c1cd5698b8ae 100644
--- a/drivers/iio/light/adjd_s311.c
+++ b/drivers/iio/light/adjd_s311.c
@@ -232,7 +232,8 @@ static int adjd_s311_read_raw(struct iio_dev *indio_dev,
232 232
233 switch (mask) { 233 switch (mask) {
234 case IIO_CHAN_INFO_RAW: 234 case IIO_CHAN_INFO_RAW:
235 ret = adjd_s311_read_data(indio_dev, chan->address, val); 235 ret = adjd_s311_read_data(indio_dev,
236 ADJD_S311_DATA_REG(chan->address), val);
236 if (ret < 0) 237 if (ret < 0)
237 return ret; 238 return ret;
238 return IIO_VAL_INT; 239 return IIO_VAL_INT;
diff --git a/drivers/md/dm-cache-policy-mq.c b/drivers/md/dm-cache-policy-mq.c
index dc112a7137fe..4296155090b2 100644
--- a/drivers/md/dm-cache-policy-mq.c
+++ b/drivers/md/dm-cache-policy-mq.c
@@ -959,23 +959,21 @@ out:
959 return r; 959 return r;
960} 960}
961 961
962static void remove_mapping(struct mq_policy *mq, dm_oblock_t oblock) 962static void mq_remove_mapping(struct dm_cache_policy *p, dm_oblock_t oblock)
963{ 963{
964 struct entry *e = hash_lookup(mq, oblock); 964 struct mq_policy *mq = to_mq_policy(p);
965 struct entry *e;
966
967 mutex_lock(&mq->lock);
968
969 e = hash_lookup(mq, oblock);
965 970
966 BUG_ON(!e || !e->in_cache); 971 BUG_ON(!e || !e->in_cache);
967 972
968 del(mq, e); 973 del(mq, e);
969 e->in_cache = false; 974 e->in_cache = false;
970 push(mq, e); 975 push(mq, e);
971}
972 976
973static void mq_remove_mapping(struct dm_cache_policy *p, dm_oblock_t oblock)
974{
975 struct mq_policy *mq = to_mq_policy(p);
976
977 mutex_lock(&mq->lock);
978 remove_mapping(mq, oblock);
979 mutex_unlock(&mq->lock); 977 mutex_unlock(&mq->lock);
980} 978}
981 979
diff --git a/drivers/media/i2c/ml86v7667.c b/drivers/media/i2c/ml86v7667.c
index efdc873e58d1..a9857022f71d 100644
--- a/drivers/media/i2c/ml86v7667.c
+++ b/drivers/media/i2c/ml86v7667.c
@@ -117,7 +117,7 @@ static int ml86v7667_s_ctrl(struct v4l2_ctrl *ctrl)
117{ 117{
118 struct v4l2_subdev *sd = to_sd(ctrl); 118 struct v4l2_subdev *sd = to_sd(ctrl);
119 struct i2c_client *client = v4l2_get_subdevdata(sd); 119 struct i2c_client *client = v4l2_get_subdevdata(sd);
120 int ret; 120 int ret = -EINVAL;
121 121
122 switch (ctrl->id) { 122 switch (ctrl->id) {
123 case V4L2_CID_BRIGHTNESS: 123 case V4L2_CID_BRIGHTNESS:
@@ -157,7 +157,7 @@ static int ml86v7667_s_ctrl(struct v4l2_ctrl *ctrl)
157 break; 157 break;
158 } 158 }
159 159
160 return 0; 160 return ret;
161} 161}
162 162
163static int ml86v7667_querystd(struct v4l2_subdev *sd, v4l2_std_id *std) 163static int ml86v7667_querystd(struct v4l2_subdev *sd, v4l2_std_id *std)
diff --git a/drivers/media/platform/coda.c b/drivers/media/platform/coda.c
index df4ada880e42..bd9405df1bd6 100644
--- a/drivers/media/platform/coda.c
+++ b/drivers/media/platform/coda.c
@@ -1987,7 +1987,7 @@ MODULE_DEVICE_TABLE(platform, coda_platform_ids);
1987 1987
1988#ifdef CONFIG_OF 1988#ifdef CONFIG_OF
1989static const struct of_device_id coda_dt_ids[] = { 1989static const struct of_device_id coda_dt_ids[] = {
1990 { .compatible = "fsl,imx27-vpu", .data = &coda_platform_ids[CODA_IMX27] }, 1990 { .compatible = "fsl,imx27-vpu", .data = &coda_devdata[CODA_IMX27] },
1991 { .compatible = "fsl,imx53-vpu", .data = &coda_devdata[CODA_IMX53] }, 1991 { .compatible = "fsl,imx53-vpu", .data = &coda_devdata[CODA_IMX53] },
1992 { /* sentinel */ } 1992 { /* sentinel */ }
1993}; 1993};
diff --git a/drivers/media/platform/s5p-g2d/g2d.c b/drivers/media/platform/s5p-g2d/g2d.c
index 553d87e5ceab..fd6289d60cde 100644
--- a/drivers/media/platform/s5p-g2d/g2d.c
+++ b/drivers/media/platform/s5p-g2d/g2d.c
@@ -784,6 +784,7 @@ static int g2d_probe(struct platform_device *pdev)
784 } 784 }
785 *vfd = g2d_videodev; 785 *vfd = g2d_videodev;
786 vfd->lock = &dev->mutex; 786 vfd->lock = &dev->mutex;
787 vfd->v4l2_dev = &dev->v4l2_dev;
787 ret = video_register_device(vfd, VFL_TYPE_GRABBER, 0); 788 ret = video_register_device(vfd, VFL_TYPE_GRABBER, 0);
788 if (ret) { 789 if (ret) {
789 v4l2_err(&dev->v4l2_dev, "Failed to register video device\n"); 790 v4l2_err(&dev->v4l2_dev, "Failed to register video device\n");
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
index 5296385153d5..4f6dd42c9adb 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
@@ -344,7 +344,7 @@ static int vidioc_g_fmt(struct file *file, void *priv, struct v4l2_format *f)
344 pix_mp->num_planes = 2; 344 pix_mp->num_planes = 2;
345 /* Set pixelformat to the format in which MFC 345 /* Set pixelformat to the format in which MFC
346 outputs the decoded frame */ 346 outputs the decoded frame */
347 pix_mp->pixelformat = V4L2_PIX_FMT_NV12MT; 347 pix_mp->pixelformat = ctx->dst_fmt->fourcc;
348 pix_mp->plane_fmt[0].bytesperline = ctx->buf_width; 348 pix_mp->plane_fmt[0].bytesperline = ctx->buf_width;
349 pix_mp->plane_fmt[0].sizeimage = ctx->luma_size; 349 pix_mp->plane_fmt[0].sizeimage = ctx->luma_size;
350 pix_mp->plane_fmt[1].bytesperline = ctx->buf_width; 350 pix_mp->plane_fmt[1].bytesperline = ctx->buf_width;
@@ -382,10 +382,16 @@ static int vidioc_try_fmt(struct file *file, void *priv, struct v4l2_format *f)
382 mfc_err("Unsupported format for source.\n"); 382 mfc_err("Unsupported format for source.\n");
383 return -EINVAL; 383 return -EINVAL;
384 } 384 }
385 if (!IS_MFCV6(dev) && (fmt->fourcc == V4L2_PIX_FMT_VP8)) { 385 if (fmt->codec_mode == S5P_FIMV_CODEC_NONE) {
386 mfc_err("Not supported format.\n"); 386 mfc_err("Unknown codec\n");
387 return -EINVAL; 387 return -EINVAL;
388 } 388 }
389 if (!IS_MFCV6(dev)) {
390 if (fmt->fourcc == V4L2_PIX_FMT_VP8) {
391 mfc_err("Not supported format.\n");
392 return -EINVAL;
393 }
394 }
389 } else if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) { 395 } else if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
390 fmt = find_format(f, MFC_FMT_RAW); 396 fmt = find_format(f, MFC_FMT_RAW);
391 if (!fmt) { 397 if (!fmt) {
@@ -411,7 +417,6 @@ static int vidioc_s_fmt(struct file *file, void *priv, struct v4l2_format *f)
411 struct s5p_mfc_dev *dev = video_drvdata(file); 417 struct s5p_mfc_dev *dev = video_drvdata(file);
412 struct s5p_mfc_ctx *ctx = fh_to_ctx(priv); 418 struct s5p_mfc_ctx *ctx = fh_to_ctx(priv);
413 int ret = 0; 419 int ret = 0;
414 struct s5p_mfc_fmt *fmt;
415 struct v4l2_pix_format_mplane *pix_mp; 420 struct v4l2_pix_format_mplane *pix_mp;
416 421
417 mfc_debug_enter(); 422 mfc_debug_enter();
@@ -425,54 +430,32 @@ static int vidioc_s_fmt(struct file *file, void *priv, struct v4l2_format *f)
425 goto out; 430 goto out;
426 } 431 }
427 if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) { 432 if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
428 fmt = find_format(f, MFC_FMT_RAW); 433 /* dst_fmt is validated by call to vidioc_try_fmt */
429 if (!fmt) { 434 ctx->dst_fmt = find_format(f, MFC_FMT_RAW);
430 mfc_err("Unsupported format for source.\n"); 435 ret = 0;
431 return -EINVAL;
432 }
433 if (!IS_MFCV6(dev) && (fmt->fourcc != V4L2_PIX_FMT_NV12MT)) {
434 mfc_err("Not supported format.\n");
435 return -EINVAL;
436 } else if (IS_MFCV6(dev) &&
437 (fmt->fourcc == V4L2_PIX_FMT_NV12MT)) {
438 mfc_err("Not supported format.\n");
439 return -EINVAL;
440 }
441 ctx->dst_fmt = fmt;
442 mfc_debug_leave();
443 return ret;
444 } else if (f->type != V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
445 mfc_err("Wrong type error for S_FMT : %d", f->type);
446 return -EINVAL;
447 }
448 fmt = find_format(f, MFC_FMT_DEC);
449 if (!fmt || fmt->codec_mode == S5P_MFC_CODEC_NONE) {
450 mfc_err("Unknown codec\n");
451 ret = -EINVAL;
452 goto out; 436 goto out;
453 } 437 } else if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
454 if (fmt->type != MFC_FMT_DEC) { 438 /* src_fmt is validated by call to vidioc_try_fmt */
455 mfc_err("Wrong format selected, you should choose " 439 ctx->src_fmt = find_format(f, MFC_FMT_DEC);
456 "format for decoding\n"); 440 ctx->codec_mode = ctx->src_fmt->codec_mode;
441 mfc_debug(2, "The codec number is: %d\n", ctx->codec_mode);
442 pix_mp->height = 0;
443 pix_mp->width = 0;
444 if (pix_mp->plane_fmt[0].sizeimage)
445 ctx->dec_src_buf_size = pix_mp->plane_fmt[0].sizeimage;
446 else
447 pix_mp->plane_fmt[0].sizeimage = ctx->dec_src_buf_size =
448 DEF_CPB_SIZE;
449 pix_mp->plane_fmt[0].bytesperline = 0;
450 ctx->state = MFCINST_INIT;
451 ret = 0;
452 goto out;
453 } else {
454 mfc_err("Wrong type error for S_FMT : %d", f->type);
457 ret = -EINVAL; 455 ret = -EINVAL;
458 goto out; 456 goto out;
459 } 457 }
460 if (!IS_MFCV6(dev) && (fmt->fourcc == V4L2_PIX_FMT_VP8)) { 458
461 mfc_err("Not supported format.\n");
462 return -EINVAL;
463 }
464 ctx->src_fmt = fmt;
465 ctx->codec_mode = fmt->codec_mode;
466 mfc_debug(2, "The codec number is: %d\n", ctx->codec_mode);
467 pix_mp->height = 0;
468 pix_mp->width = 0;
469 if (pix_mp->plane_fmt[0].sizeimage)
470 ctx->dec_src_buf_size = pix_mp->plane_fmt[0].sizeimage;
471 else
472 pix_mp->plane_fmt[0].sizeimage = ctx->dec_src_buf_size =
473 DEF_CPB_SIZE;
474 pix_mp->plane_fmt[0].bytesperline = 0;
475 ctx->state = MFCINST_INIT;
476out: 459out:
477 mfc_debug_leave(); 460 mfc_debug_leave();
478 return ret; 461 return ret;
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
index 2549967b2f85..59e56f4c8ce3 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
@@ -906,6 +906,7 @@ static int vidioc_g_fmt(struct file *file, void *priv, struct v4l2_format *f)
906 906
907static int vidioc_try_fmt(struct file *file, void *priv, struct v4l2_format *f) 907static int vidioc_try_fmt(struct file *file, void *priv, struct v4l2_format *f)
908{ 908{
909 struct s5p_mfc_dev *dev = video_drvdata(file);
909 struct s5p_mfc_fmt *fmt; 910 struct s5p_mfc_fmt *fmt;
910 struct v4l2_pix_format_mplane *pix_fmt_mp = &f->fmt.pix_mp; 911 struct v4l2_pix_format_mplane *pix_fmt_mp = &f->fmt.pix_mp;
911 912
@@ -930,6 +931,18 @@ static int vidioc_try_fmt(struct file *file, void *priv, struct v4l2_format *f)
930 return -EINVAL; 931 return -EINVAL;
931 } 932 }
932 933
934 if (!IS_MFCV6(dev)) {
935 if (fmt->fourcc == V4L2_PIX_FMT_NV12MT_16X16) {
936 mfc_err("Not supported format.\n");
937 return -EINVAL;
938 }
939 } else if (IS_MFCV6(dev)) {
940 if (fmt->fourcc == V4L2_PIX_FMT_NV12MT) {
941 mfc_err("Not supported format.\n");
942 return -EINVAL;
943 }
944 }
945
933 if (fmt->num_planes != pix_fmt_mp->num_planes) { 946 if (fmt->num_planes != pix_fmt_mp->num_planes) {
934 mfc_err("failed to try output format\n"); 947 mfc_err("failed to try output format\n");
935 return -EINVAL; 948 return -EINVAL;
@@ -947,7 +960,6 @@ static int vidioc_s_fmt(struct file *file, void *priv, struct v4l2_format *f)
947{ 960{
948 struct s5p_mfc_dev *dev = video_drvdata(file); 961 struct s5p_mfc_dev *dev = video_drvdata(file);
949 struct s5p_mfc_ctx *ctx = fh_to_ctx(priv); 962 struct s5p_mfc_ctx *ctx = fh_to_ctx(priv);
950 struct s5p_mfc_fmt *fmt;
951 struct v4l2_pix_format_mplane *pix_fmt_mp = &f->fmt.pix_mp; 963 struct v4l2_pix_format_mplane *pix_fmt_mp = &f->fmt.pix_mp;
952 int ret = 0; 964 int ret = 0;
953 965
@@ -960,13 +972,9 @@ static int vidioc_s_fmt(struct file *file, void *priv, struct v4l2_format *f)
960 goto out; 972 goto out;
961 } 973 }
962 if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) { 974 if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
963 fmt = find_format(f, MFC_FMT_ENC); 975 /* dst_fmt is validated by call to vidioc_try_fmt */
964 if (!fmt) { 976 ctx->dst_fmt = find_format(f, MFC_FMT_ENC);
965 mfc_err("failed to set capture format\n");
966 return -EINVAL;
967 }
968 ctx->state = MFCINST_INIT; 977 ctx->state = MFCINST_INIT;
969 ctx->dst_fmt = fmt;
970 ctx->codec_mode = ctx->dst_fmt->codec_mode; 978 ctx->codec_mode = ctx->dst_fmt->codec_mode;
971 ctx->enc_dst_buf_size = pix_fmt_mp->plane_fmt[0].sizeimage; 979 ctx->enc_dst_buf_size = pix_fmt_mp->plane_fmt[0].sizeimage;
972 pix_fmt_mp->plane_fmt[0].bytesperline = 0; 980 pix_fmt_mp->plane_fmt[0].bytesperline = 0;
@@ -987,28 +995,8 @@ static int vidioc_s_fmt(struct file *file, void *priv, struct v4l2_format *f)
987 } 995 }
988 mfc_debug(2, "Got instance number: %d\n", ctx->inst_no); 996 mfc_debug(2, "Got instance number: %d\n", ctx->inst_no);
989 } else if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) { 997 } else if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
990 fmt = find_format(f, MFC_FMT_RAW); 998 /* src_fmt is validated by call to vidioc_try_fmt */
991 if (!fmt) { 999 ctx->src_fmt = find_format(f, MFC_FMT_RAW);
992 mfc_err("failed to set output format\n");
993 return -EINVAL;
994 }
995
996 if (!IS_MFCV6(dev) &&
997 (fmt->fourcc == V4L2_PIX_FMT_NV12MT_16X16)) {
998 mfc_err("Not supported format.\n");
999 return -EINVAL;
1000 } else if (IS_MFCV6(dev) &&
1001 (fmt->fourcc == V4L2_PIX_FMT_NV12MT)) {
1002 mfc_err("Not supported format.\n");
1003 return -EINVAL;
1004 }
1005
1006 if (fmt->num_planes != pix_fmt_mp->num_planes) {
1007 mfc_err("failed to set output format\n");
1008 ret = -EINVAL;
1009 goto out;
1010 }
1011 ctx->src_fmt = fmt;
1012 ctx->img_width = pix_fmt_mp->width; 1000 ctx->img_width = pix_fmt_mp->width;
1013 ctx->img_height = pix_fmt_mp->height; 1001 ctx->img_height = pix_fmt_mp->height;
1014 mfc_debug(2, "codec number: %d\n", ctx->src_fmt->codec_mode); 1002 mfc_debug(2, "codec number: %d\n", ctx->src_fmt->codec_mode);
diff --git a/drivers/media/usb/em28xx/em28xx-i2c.c b/drivers/media/usb/em28xx/em28xx-i2c.c
index 4851cc2e4a4d..c4ff9739a7ae 100644
--- a/drivers/media/usb/em28xx/em28xx-i2c.c
+++ b/drivers/media/usb/em28xx/em28xx-i2c.c
@@ -726,7 +726,7 @@ static int em28xx_i2c_eeprom(struct em28xx *dev, unsigned bus,
726 726
727 *eedata = data; 727 *eedata = data;
728 *eedata_len = len; 728 *eedata_len = len;
729 dev_config = (void *)eedata; 729 dev_config = (void *)*eedata;
730 730
731 switch (le16_to_cpu(dev_config->chip_conf) >> 4 & 0x3) { 731 switch (le16_to_cpu(dev_config->chip_conf) >> 4 & 0x3) {
732 case 0: 732 case 0:
diff --git a/drivers/media/usb/hdpvr/hdpvr-core.c b/drivers/media/usb/hdpvr/hdpvr-core.c
index cb694055ba7d..6e5070774dc2 100644
--- a/drivers/media/usb/hdpvr/hdpvr-core.c
+++ b/drivers/media/usb/hdpvr/hdpvr-core.c
@@ -303,6 +303,11 @@ static int hdpvr_probe(struct usb_interface *interface,
303 303
304 dev->workqueue = 0; 304 dev->workqueue = 0;
305 305
306 /* init video transfer queues first of all */
307 /* to prevent oops in hdpvr_delete() on error paths */
308 INIT_LIST_HEAD(&dev->free_buff_list);
309 INIT_LIST_HEAD(&dev->rec_buff_list);
310
306 /* register v4l2_device early so it can be used for printks */ 311 /* register v4l2_device early so it can be used for printks */
307 if (v4l2_device_register(&interface->dev, &dev->v4l2_dev)) { 312 if (v4l2_device_register(&interface->dev, &dev->v4l2_dev)) {
308 dev_err(&interface->dev, "v4l2_device_register failed\n"); 313 dev_err(&interface->dev, "v4l2_device_register failed\n");
@@ -325,10 +330,6 @@ static int hdpvr_probe(struct usb_interface *interface,
325 if (!dev->workqueue) 330 if (!dev->workqueue)
326 goto error; 331 goto error;
327 332
328 /* init video transfer queues */
329 INIT_LIST_HEAD(&dev->free_buff_list);
330 INIT_LIST_HEAD(&dev->rec_buff_list);
331
332 dev->options = hdpvr_default_options; 333 dev->options = hdpvr_default_options;
333 334
334 if (default_video_input < HDPVR_VIDEO_INPUTS) 335 if (default_video_input < HDPVR_VIDEO_INPUTS)
@@ -405,7 +406,7 @@ static int hdpvr_probe(struct usb_interface *interface,
405 video_nr[atomic_inc_return(&dev_nr)]); 406 video_nr[atomic_inc_return(&dev_nr)]);
406 if (retval < 0) { 407 if (retval < 0) {
407 v4l2_err(&dev->v4l2_dev, "registering videodev failed\n"); 408 v4l2_err(&dev->v4l2_dev, "registering videodev failed\n");
408 goto error; 409 goto reg_fail;
409 } 410 }
410 411
411 /* let the user know what node this device is now attached to */ 412 /* let the user know what node this device is now attached to */
diff --git a/drivers/media/usb/usbtv/Kconfig b/drivers/media/usb/usbtv/Kconfig
index 8864436464bf..7c5b86006ee6 100644
--- a/drivers/media/usb/usbtv/Kconfig
+++ b/drivers/media/usb/usbtv/Kconfig
@@ -1,6 +1,6 @@
1config VIDEO_USBTV 1config VIDEO_USBTV
2 tristate "USBTV007 video capture support" 2 tristate "USBTV007 video capture support"
3 depends on VIDEO_DEV 3 depends on VIDEO_V4L2
4 select VIDEOBUF2_VMALLOC 4 select VIDEOBUF2_VMALLOC
5 5
6 ---help--- 6 ---help---
diff --git a/drivers/media/usb/usbtv/usbtv.c b/drivers/media/usb/usbtv/usbtv.c
index bf43f874685e..91650173941a 100644
--- a/drivers/media/usb/usbtv/usbtv.c
+++ b/drivers/media/usb/usbtv/usbtv.c
@@ -57,7 +57,7 @@
57#define USBTV_CHUNK_SIZE 256 57#define USBTV_CHUNK_SIZE 256
58#define USBTV_CHUNK 240 58#define USBTV_CHUNK 240
59#define USBTV_CHUNKS (USBTV_WIDTH * USBTV_HEIGHT \ 59#define USBTV_CHUNKS (USBTV_WIDTH * USBTV_HEIGHT \
60 / 2 / USBTV_CHUNK) 60 / 4 / USBTV_CHUNK)
61 61
62/* Chunk header. */ 62/* Chunk header. */
63#define USBTV_MAGIC_OK(chunk) ((be32_to_cpu(chunk[0]) & 0xff000000) \ 63#define USBTV_MAGIC_OK(chunk) ((be32_to_cpu(chunk[0]) & 0xff000000) \
@@ -89,6 +89,7 @@ struct usbtv {
89 /* Number of currently processed frame, useful find 89 /* Number of currently processed frame, useful find
90 * out when a new one begins. */ 90 * out when a new one begins. */
91 u32 frame_id; 91 u32 frame_id;
92 int chunks_done;
92 93
93 int iso_size; 94 int iso_size;
94 unsigned int sequence; 95 unsigned int sequence;
@@ -202,6 +203,26 @@ static int usbtv_setup_capture(struct usbtv *usbtv)
202 return 0; 203 return 0;
203} 204}
204 205
206/* Copy data from chunk into a frame buffer, deinterlacing the data
207 * into every second line. Unfortunately, they don't align nicely into
208 * 720 pixel lines, as the chunk is 240 words long, which is 480 pixels.
209 * Therefore, we break down the chunk into two halves before copyting,
210 * so that we can interleave a line if needed. */
211static void usbtv_chunk_to_vbuf(u32 *frame, u32 *src, int chunk_no, int odd)
212{
213 int half;
214
215 for (half = 0; half < 2; half++) {
216 int part_no = chunk_no * 2 + half;
217 int line = part_no / 3;
218 int part_index = (line * 2 + !odd) * 3 + (part_no % 3);
219
220 u32 *dst = &frame[part_index * USBTV_CHUNK/2];
221 memcpy(dst, src, USBTV_CHUNK/2 * sizeof(*src));
222 src += USBTV_CHUNK/2;
223 }
224}
225
205/* Called for each 256-byte image chunk. 226/* Called for each 256-byte image chunk.
206 * First word identifies the chunk, followed by 240 words of image 227 * First word identifies the chunk, followed by 240 words of image
207 * data and padding. */ 228 * data and padding. */
@@ -218,17 +239,17 @@ static void usbtv_image_chunk(struct usbtv *usbtv, u32 *chunk)
218 frame_id = USBTV_FRAME_ID(chunk); 239 frame_id = USBTV_FRAME_ID(chunk);
219 odd = USBTV_ODD(chunk); 240 odd = USBTV_ODD(chunk);
220 chunk_no = USBTV_CHUNK_NO(chunk); 241 chunk_no = USBTV_CHUNK_NO(chunk);
221
222 /* Deinterlace. TODO: Use interlaced frame format. */
223 chunk_no = (chunk_no - chunk_no % 3) * 2 + chunk_no % 3;
224 chunk_no += !odd * 3;
225
226 if (chunk_no >= USBTV_CHUNKS) 242 if (chunk_no >= USBTV_CHUNKS)
227 return; 243 return;
228 244
229 /* Beginning of a frame. */ 245 /* Beginning of a frame. */
230 if (chunk_no == 0) 246 if (chunk_no == 0) {
231 usbtv->frame_id = frame_id; 247 usbtv->frame_id = frame_id;
248 usbtv->chunks_done = 0;
249 }
250
251 if (usbtv->frame_id != frame_id)
252 return;
232 253
233 spin_lock_irqsave(&usbtv->buflock, flags); 254 spin_lock_irqsave(&usbtv->buflock, flags);
234 if (list_empty(&usbtv->bufs)) { 255 if (list_empty(&usbtv->bufs)) {
@@ -241,19 +262,23 @@ static void usbtv_image_chunk(struct usbtv *usbtv, u32 *chunk)
241 buf = list_first_entry(&usbtv->bufs, struct usbtv_buf, list); 262 buf = list_first_entry(&usbtv->bufs, struct usbtv_buf, list);
242 frame = vb2_plane_vaddr(&buf->vb, 0); 263 frame = vb2_plane_vaddr(&buf->vb, 0);
243 264
244 /* Copy the chunk. */ 265 /* Copy the chunk data. */
245 memcpy(&frame[chunk_no * USBTV_CHUNK], &chunk[1], 266 usbtv_chunk_to_vbuf(frame, &chunk[1], chunk_no, odd);
246 USBTV_CHUNK * sizeof(chunk[1])); 267 usbtv->chunks_done++;
247 268
248 /* Last chunk in a frame, signalling an end */ 269 /* Last chunk in a frame, signalling an end */
249 if (usbtv->frame_id && chunk_no == USBTV_CHUNKS-1) { 270 if (odd && chunk_no == USBTV_CHUNKS-1) {
250 int size = vb2_plane_size(&buf->vb, 0); 271 int size = vb2_plane_size(&buf->vb, 0);
272 enum vb2_buffer_state state = usbtv->chunks_done ==
273 USBTV_CHUNKS ?
274 VB2_BUF_STATE_DONE :
275 VB2_BUF_STATE_ERROR;
251 276
252 buf->vb.v4l2_buf.field = V4L2_FIELD_INTERLACED; 277 buf->vb.v4l2_buf.field = V4L2_FIELD_INTERLACED;
253 buf->vb.v4l2_buf.sequence = usbtv->sequence++; 278 buf->vb.v4l2_buf.sequence = usbtv->sequence++;
254 v4l2_get_timestamp(&buf->vb.v4l2_buf.timestamp); 279 v4l2_get_timestamp(&buf->vb.v4l2_buf.timestamp);
255 vb2_set_plane_payload(&buf->vb, 0, size); 280 vb2_set_plane_payload(&buf->vb, 0, size);
256 vb2_buffer_done(&buf->vb, VB2_BUF_STATE_DONE); 281 vb2_buffer_done(&buf->vb, state);
257 list_del(&buf->list); 282 list_del(&buf->list);
258 } 283 }
259 284
@@ -518,7 +543,7 @@ static int usbtv_queue_setup(struct vb2_queue *vq,
518 if (*nbuffers < 2) 543 if (*nbuffers < 2)
519 *nbuffers = 2; 544 *nbuffers = 2;
520 *nplanes = 1; 545 *nplanes = 1;
521 sizes[0] = USBTV_CHUNK * USBTV_CHUNKS * sizeof(u32); 546 sizes[0] = USBTV_WIDTH * USBTV_HEIGHT / 2 * sizeof(u32);
522 547
523 return 0; 548 return 0;
524} 549}
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 07f257d44a1e..e48cb339c0c6 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -3714,11 +3714,17 @@ static int bond_neigh_init(struct neighbour *n)
3714 * The bonding ndo_neigh_setup is called at init time beofre any 3714 * The bonding ndo_neigh_setup is called at init time beofre any
3715 * slave exists. So we must declare proxy setup function which will 3715 * slave exists. So we must declare proxy setup function which will
3716 * be used at run time to resolve the actual slave neigh param setup. 3716 * be used at run time to resolve the actual slave neigh param setup.
3717 *
3718 * It's also called by master devices (such as vlans) to setup their
3719 * underlying devices. In that case - do nothing, we're already set up from
3720 * our init.
3717 */ 3721 */
3718static int bond_neigh_setup(struct net_device *dev, 3722static int bond_neigh_setup(struct net_device *dev,
3719 struct neigh_parms *parms) 3723 struct neigh_parms *parms)
3720{ 3724{
3721 parms->neigh_setup = bond_neigh_init; 3725 /* modify only our neigh_parms */
3726 if (parms->dev == dev)
3727 parms->neigh_setup = bond_neigh_init;
3722 3728
3723 return 0; 3729 return 0;
3724} 3730}
diff --git a/drivers/net/can/usb/peak_usb/pcan_usb.c b/drivers/net/can/usb/peak_usb/pcan_usb.c
index 25723d8ee201..925ab8ec9329 100644
--- a/drivers/net/can/usb/peak_usb/pcan_usb.c
+++ b/drivers/net/can/usb/peak_usb/pcan_usb.c
@@ -649,7 +649,7 @@ static int pcan_usb_decode_data(struct pcan_usb_msg_context *mc, u8 status_len)
649 if ((mc->ptr + rec_len) > mc->end) 649 if ((mc->ptr + rec_len) > mc->end)
650 goto decode_failed; 650 goto decode_failed;
651 651
652 memcpy(cf->data, mc->ptr, rec_len); 652 memcpy(cf->data, mc->ptr, cf->can_dlc);
653 mc->ptr += rec_len; 653 mc->ptr += rec_len;
654 } 654 }
655 655
diff --git a/drivers/net/ethernet/arc/emac_main.c b/drivers/net/ethernet/arc/emac_main.c
index f1b121ee5525..55d79cb53a79 100644
--- a/drivers/net/ethernet/arc/emac_main.c
+++ b/drivers/net/ethernet/arc/emac_main.c
@@ -199,7 +199,7 @@ static int arc_emac_rx(struct net_device *ndev, int budget)
199 struct arc_emac_priv *priv = netdev_priv(ndev); 199 struct arc_emac_priv *priv = netdev_priv(ndev);
200 unsigned int work_done; 200 unsigned int work_done;
201 201
202 for (work_done = 0; work_done <= budget; work_done++) { 202 for (work_done = 0; work_done < budget; work_done++) {
203 unsigned int *last_rx_bd = &priv->last_rx_bd; 203 unsigned int *last_rx_bd = &priv->last_rx_bd;
204 struct net_device_stats *stats = &priv->stats; 204 struct net_device_stats *stats = &priv->stats;
205 struct buffer_state *rx_buff = &priv->rx_buff[*last_rx_bd]; 205 struct buffer_state *rx_buff = &priv->rx_buff[*last_rx_bd];
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
index d80e34b8285f..00b88cbfde25 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
@@ -1333,6 +1333,8 @@ enum {
1333 BNX2X_SP_RTNL_VFPF_CHANNEL_DOWN, 1333 BNX2X_SP_RTNL_VFPF_CHANNEL_DOWN,
1334 BNX2X_SP_RTNL_VFPF_STORM_RX_MODE, 1334 BNX2X_SP_RTNL_VFPF_STORM_RX_MODE,
1335 BNX2X_SP_RTNL_HYPERVISOR_VLAN, 1335 BNX2X_SP_RTNL_HYPERVISOR_VLAN,
1336 BNX2X_SP_RTNL_TX_STOP,
1337 BNX2X_SP_RTNL_TX_RESUME,
1336}; 1338};
1337 1339
1338struct bnx2x_prev_path_list { 1340struct bnx2x_prev_path_list {
@@ -1502,6 +1504,7 @@ struct bnx2x {
1502#define BC_SUPPORTS_DCBX_MSG_NON_PMF (1 << 21) 1504#define BC_SUPPORTS_DCBX_MSG_NON_PMF (1 << 21)
1503#define IS_VF_FLAG (1 << 22) 1505#define IS_VF_FLAG (1 << 22)
1504#define INTERRUPTS_ENABLED_FLAG (1 << 23) 1506#define INTERRUPTS_ENABLED_FLAG (1 << 23)
1507#define BC_SUPPORTS_RMMOD_CMD (1 << 24)
1505 1508
1506#define BP_NOMCP(bp) ((bp)->flags & NO_MCP_FLAG) 1509#define BP_NOMCP(bp) ((bp)->flags & NO_MCP_FLAG)
1507 1510
@@ -1830,6 +1833,8 @@ struct bnx2x {
1830 1833
1831 int fp_array_size; 1834 int fp_array_size;
1832 u32 dump_preset_idx; 1835 u32 dump_preset_idx;
1836 bool stats_started;
1837 struct semaphore stats_sema;
1833}; 1838};
1834 1839
1835/* Tx queues may be less or equal to Rx queues */ 1840/* Tx queues may be less or equal to Rx queues */
@@ -2451,4 +2456,6 @@ enum bnx2x_pci_bus_speed {
2451 BNX2X_PCI_LINK_SPEED_5000 = 5000, 2456 BNX2X_PCI_LINK_SPEED_5000 = 5000,
2452 BNX2X_PCI_LINK_SPEED_8000 = 8000 2457 BNX2X_PCI_LINK_SPEED_8000 = 8000
2453}; 2458};
2459
2460void bnx2x_set_local_cmng(struct bnx2x *bp);
2454#endif /* bnx2x.h */ 2461#endif /* bnx2x.h */
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c
index 0c94df47e0e8..fcf2761d8828 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c
@@ -30,10 +30,8 @@
30#include "bnx2x_dcb.h" 30#include "bnx2x_dcb.h"
31 31
32/* forward declarations of dcbx related functions */ 32/* forward declarations of dcbx related functions */
33static int bnx2x_dcbx_stop_hw_tx(struct bnx2x *bp);
34static void bnx2x_pfc_set_pfc(struct bnx2x *bp); 33static void bnx2x_pfc_set_pfc(struct bnx2x *bp);
35static void bnx2x_dcbx_update_ets_params(struct bnx2x *bp); 34static void bnx2x_dcbx_update_ets_params(struct bnx2x *bp);
36static int bnx2x_dcbx_resume_hw_tx(struct bnx2x *bp);
37static void bnx2x_dcbx_get_ets_pri_pg_tbl(struct bnx2x *bp, 35static void bnx2x_dcbx_get_ets_pri_pg_tbl(struct bnx2x *bp,
38 u32 *set_configuration_ets_pg, 36 u32 *set_configuration_ets_pg,
39 u32 *pri_pg_tbl); 37 u32 *pri_pg_tbl);
@@ -425,30 +423,52 @@ static void bnx2x_pfc_set_pfc(struct bnx2x *bp)
425 bnx2x_pfc_clear(bp); 423 bnx2x_pfc_clear(bp);
426} 424}
427 425
428static int bnx2x_dcbx_stop_hw_tx(struct bnx2x *bp) 426int bnx2x_dcbx_stop_hw_tx(struct bnx2x *bp)
429{ 427{
430 struct bnx2x_func_state_params func_params = {NULL}; 428 struct bnx2x_func_state_params func_params = {NULL};
429 int rc;
431 430
432 func_params.f_obj = &bp->func_obj; 431 func_params.f_obj = &bp->func_obj;
433 func_params.cmd = BNX2X_F_CMD_TX_STOP; 432 func_params.cmd = BNX2X_F_CMD_TX_STOP;
434 433
434 __set_bit(RAMROD_COMP_WAIT, &func_params.ramrod_flags);
435 __set_bit(RAMROD_RETRY, &func_params.ramrod_flags);
436
435 DP(BNX2X_MSG_DCB, "STOP TRAFFIC\n"); 437 DP(BNX2X_MSG_DCB, "STOP TRAFFIC\n");
436 return bnx2x_func_state_change(bp, &func_params); 438
439 rc = bnx2x_func_state_change(bp, &func_params);
440 if (rc) {
441 BNX2X_ERR("Unable to hold traffic for HW configuration\n");
442 bnx2x_panic();
443 }
444
445 return rc;
437} 446}
438 447
439static int bnx2x_dcbx_resume_hw_tx(struct bnx2x *bp) 448int bnx2x_dcbx_resume_hw_tx(struct bnx2x *bp)
440{ 449{
441 struct bnx2x_func_state_params func_params = {NULL}; 450 struct bnx2x_func_state_params func_params = {NULL};
442 struct bnx2x_func_tx_start_params *tx_params = 451 struct bnx2x_func_tx_start_params *tx_params =
443 &func_params.params.tx_start; 452 &func_params.params.tx_start;
453 int rc;
444 454
445 func_params.f_obj = &bp->func_obj; 455 func_params.f_obj = &bp->func_obj;
446 func_params.cmd = BNX2X_F_CMD_TX_START; 456 func_params.cmd = BNX2X_F_CMD_TX_START;
447 457
458 __set_bit(RAMROD_COMP_WAIT, &func_params.ramrod_flags);
459 __set_bit(RAMROD_RETRY, &func_params.ramrod_flags);
460
448 bnx2x_dcbx_fw_struct(bp, tx_params); 461 bnx2x_dcbx_fw_struct(bp, tx_params);
449 462
450 DP(BNX2X_MSG_DCB, "START TRAFFIC\n"); 463 DP(BNX2X_MSG_DCB, "START TRAFFIC\n");
451 return bnx2x_func_state_change(bp, &func_params); 464
465 rc = bnx2x_func_state_change(bp, &func_params);
466 if (rc) {
467 BNX2X_ERR("Unable to resume traffic after HW configuration\n");
468 bnx2x_panic();
469 }
470
471 return rc;
452} 472}
453 473
454static void bnx2x_dcbx_2cos_limit_update_ets_config(struct bnx2x *bp) 474static void bnx2x_dcbx_2cos_limit_update_ets_config(struct bnx2x *bp)
@@ -744,7 +764,9 @@ void bnx2x_dcbx_set_params(struct bnx2x *bp, u32 state)
744 if (IS_MF(bp)) 764 if (IS_MF(bp))
745 bnx2x_link_sync_notify(bp); 765 bnx2x_link_sync_notify(bp);
746 766
747 bnx2x_dcbx_stop_hw_tx(bp); 767 set_bit(BNX2X_SP_RTNL_TX_STOP, &bp->sp_rtnl_state);
768
769 schedule_delayed_work(&bp->sp_rtnl_task, 0);
748 770
749 return; 771 return;
750 } 772 }
@@ -753,7 +775,13 @@ void bnx2x_dcbx_set_params(struct bnx2x *bp, u32 state)
753 bnx2x_pfc_set_pfc(bp); 775 bnx2x_pfc_set_pfc(bp);
754 776
755 bnx2x_dcbx_update_ets_params(bp); 777 bnx2x_dcbx_update_ets_params(bp);
756 bnx2x_dcbx_resume_hw_tx(bp); 778
779 /* ets may affect cmng configuration: reinit it in hw */
780 bnx2x_set_local_cmng(bp);
781
782 set_bit(BNX2X_SP_RTNL_TX_RESUME, &bp->sp_rtnl_state);
783
784 schedule_delayed_work(&bp->sp_rtnl_task, 0);
757 785
758 return; 786 return;
759 case BNX2X_DCBX_STATE_TX_RELEASED: 787 case BNX2X_DCBX_STATE_TX_RELEASED:
@@ -2363,21 +2391,24 @@ static u8 bnx2x_dcbnl_get_featcfg(struct net_device *netdev, int featid,
2363 case DCB_FEATCFG_ATTR_PG: 2391 case DCB_FEATCFG_ATTR_PG:
2364 if (bp->dcbx_local_feat.ets.enabled) 2392 if (bp->dcbx_local_feat.ets.enabled)
2365 *flags |= DCB_FEATCFG_ENABLE; 2393 *flags |= DCB_FEATCFG_ENABLE;
2366 if (bp->dcbx_error & DCBX_LOCAL_ETS_ERROR) 2394 if (bp->dcbx_error & (DCBX_LOCAL_ETS_ERROR |
2395 DCBX_REMOTE_MIB_ERROR))
2367 *flags |= DCB_FEATCFG_ERROR; 2396 *flags |= DCB_FEATCFG_ERROR;
2368 break; 2397 break;
2369 case DCB_FEATCFG_ATTR_PFC: 2398 case DCB_FEATCFG_ATTR_PFC:
2370 if (bp->dcbx_local_feat.pfc.enabled) 2399 if (bp->dcbx_local_feat.pfc.enabled)
2371 *flags |= DCB_FEATCFG_ENABLE; 2400 *flags |= DCB_FEATCFG_ENABLE;
2372 if (bp->dcbx_error & (DCBX_LOCAL_PFC_ERROR | 2401 if (bp->dcbx_error & (DCBX_LOCAL_PFC_ERROR |
2373 DCBX_LOCAL_PFC_MISMATCH)) 2402 DCBX_LOCAL_PFC_MISMATCH |
2403 DCBX_REMOTE_MIB_ERROR))
2374 *flags |= DCB_FEATCFG_ERROR; 2404 *flags |= DCB_FEATCFG_ERROR;
2375 break; 2405 break;
2376 case DCB_FEATCFG_ATTR_APP: 2406 case DCB_FEATCFG_ATTR_APP:
2377 if (bp->dcbx_local_feat.app.enabled) 2407 if (bp->dcbx_local_feat.app.enabled)
2378 *flags |= DCB_FEATCFG_ENABLE; 2408 *flags |= DCB_FEATCFG_ENABLE;
2379 if (bp->dcbx_error & (DCBX_LOCAL_APP_ERROR | 2409 if (bp->dcbx_error & (DCBX_LOCAL_APP_ERROR |
2380 DCBX_LOCAL_APP_MISMATCH)) 2410 DCBX_LOCAL_APP_MISMATCH |
2411 DCBX_REMOTE_MIB_ERROR))
2381 *flags |= DCB_FEATCFG_ERROR; 2412 *flags |= DCB_FEATCFG_ERROR;
2382 break; 2413 break;
2383 default: 2414 default:
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.h
index 125bd1b6586f..804b8f64463e 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.h
@@ -199,4 +199,7 @@ extern const struct dcbnl_rtnl_ops bnx2x_dcbnl_ops;
199int bnx2x_dcbnl_update_applist(struct bnx2x *bp, bool delall); 199int bnx2x_dcbnl_update_applist(struct bnx2x *bp, bool delall);
200#endif /* BCM_DCBNL */ 200#endif /* BCM_DCBNL */
201 201
202int bnx2x_dcbx_stop_hw_tx(struct bnx2x *bp);
203int bnx2x_dcbx_resume_hw_tx(struct bnx2x *bp);
204
202#endif /* BNX2X_DCB_H */ 205#endif /* BNX2X_DCB_H */
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h
index 5018e52ae2ad..32767f6aa33f 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h
@@ -1300,6 +1300,9 @@ struct drv_func_mb {
1300 1300
1301 #define DRV_MSG_CODE_EEE_RESULTS_ACK 0xda000000 1301 #define DRV_MSG_CODE_EEE_RESULTS_ACK 0xda000000
1302 1302
1303 #define DRV_MSG_CODE_RMMOD 0xdb000000
1304 #define REQ_BC_VER_4_RMMOD_CMD 0x0007080f
1305
1303 #define DRV_MSG_CODE_SET_MF_BW 0xe0000000 1306 #define DRV_MSG_CODE_SET_MF_BW 0xe0000000
1304 #define REQ_BC_VER_4_SET_MF_BW 0x00060202 1307 #define REQ_BC_VER_4_SET_MF_BW 0x00060202
1305 #define DRV_MSG_CODE_SET_MF_BW_ACK 0xe1000000 1308 #define DRV_MSG_CODE_SET_MF_BW_ACK 0xe1000000
@@ -1372,6 +1375,8 @@ struct drv_func_mb {
1372 1375
1373 #define FW_MSG_CODE_EEE_RESULS_ACK 0xda100000 1376 #define FW_MSG_CODE_EEE_RESULS_ACK 0xda100000
1374 1377
1378 #define FW_MSG_CODE_RMMOD_ACK 0xdb100000
1379
1375 #define FW_MSG_CODE_SET_MF_BW_SENT 0xe0000000 1380 #define FW_MSG_CODE_SET_MF_BW_SENT 0xe0000000
1376 #define FW_MSG_CODE_SET_MF_BW_DONE 0xe1000000 1381 #define FW_MSG_CODE_SET_MF_BW_DONE 0xe1000000
1377 1382
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index e06186c305d8..8bdc8b973007 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -2261,6 +2261,23 @@ static void bnx2x_set_requested_fc(struct bnx2x *bp)
2261 bp->link_params.req_fc_auto_adv = BNX2X_FLOW_CTRL_BOTH; 2261 bp->link_params.req_fc_auto_adv = BNX2X_FLOW_CTRL_BOTH;
2262} 2262}
2263 2263
2264static void bnx2x_init_dropless_fc(struct bnx2x *bp)
2265{
2266 u32 pause_enabled = 0;
2267
2268 if (!CHIP_IS_E1(bp) && bp->dropless_fc && bp->link_vars.link_up) {
2269 if (bp->link_vars.flow_ctrl & BNX2X_FLOW_CTRL_TX)
2270 pause_enabled = 1;
2271
2272 REG_WR(bp, BAR_USTRORM_INTMEM +
2273 USTORM_ETH_PAUSE_ENABLED_OFFSET(BP_PORT(bp)),
2274 pause_enabled);
2275 }
2276
2277 DP(NETIF_MSG_IFUP | NETIF_MSG_LINK, "dropless_fc is %s\n",
2278 pause_enabled ? "enabled" : "disabled");
2279}
2280
2264int bnx2x_initial_phy_init(struct bnx2x *bp, int load_mode) 2281int bnx2x_initial_phy_init(struct bnx2x *bp, int load_mode)
2265{ 2282{
2266 int rc, cfx_idx = bnx2x_get_link_cfg_idx(bp); 2283 int rc, cfx_idx = bnx2x_get_link_cfg_idx(bp);
@@ -2294,6 +2311,8 @@ int bnx2x_initial_phy_init(struct bnx2x *bp, int load_mode)
2294 2311
2295 bnx2x_release_phy_lock(bp); 2312 bnx2x_release_phy_lock(bp);
2296 2313
2314 bnx2x_init_dropless_fc(bp);
2315
2297 bnx2x_calc_fc_adv(bp); 2316 bnx2x_calc_fc_adv(bp);
2298 2317
2299 if (bp->link_vars.link_up) { 2318 if (bp->link_vars.link_up) {
@@ -2315,6 +2334,8 @@ void bnx2x_link_set(struct bnx2x *bp)
2315 bnx2x_phy_init(&bp->link_params, &bp->link_vars); 2334 bnx2x_phy_init(&bp->link_params, &bp->link_vars);
2316 bnx2x_release_phy_lock(bp); 2335 bnx2x_release_phy_lock(bp);
2317 2336
2337 bnx2x_init_dropless_fc(bp);
2338
2318 bnx2x_calc_fc_adv(bp); 2339 bnx2x_calc_fc_adv(bp);
2319 } else 2340 } else
2320 BNX2X_ERR("Bootcode is missing - can not set link\n"); 2341 BNX2X_ERR("Bootcode is missing - can not set link\n");
@@ -2476,7 +2497,7 @@ static void bnx2x_cmng_fns_init(struct bnx2x *bp, u8 read_cfg, u8 cmng_type)
2476 2497
2477 input.port_rate = bp->link_vars.line_speed; 2498 input.port_rate = bp->link_vars.line_speed;
2478 2499
2479 if (cmng_type == CMNG_FNS_MINMAX) { 2500 if (cmng_type == CMNG_FNS_MINMAX && input.port_rate) {
2480 int vn; 2501 int vn;
2481 2502
2482 /* read mf conf from shmem */ 2503 /* read mf conf from shmem */
@@ -2533,6 +2554,21 @@ static void storm_memset_cmng(struct bnx2x *bp,
2533 } 2554 }
2534} 2555}
2535 2556
2557/* init cmng mode in HW according to local configuration */
2558void bnx2x_set_local_cmng(struct bnx2x *bp)
2559{
2560 int cmng_fns = bnx2x_get_cmng_fns_mode(bp);
2561
2562 if (cmng_fns != CMNG_FNS_NONE) {
2563 bnx2x_cmng_fns_init(bp, false, cmng_fns);
2564 storm_memset_cmng(bp, &bp->cmng, BP_PORT(bp));
2565 } else {
2566 /* rate shaping and fairness are disabled */
2567 DP(NETIF_MSG_IFUP,
2568 "single function mode without fairness\n");
2569 }
2570}
2571
2536/* This function is called upon link interrupt */ 2572/* This function is called upon link interrupt */
2537static void bnx2x_link_attn(struct bnx2x *bp) 2573static void bnx2x_link_attn(struct bnx2x *bp)
2538{ 2574{
@@ -2541,20 +2577,9 @@ static void bnx2x_link_attn(struct bnx2x *bp)
2541 2577
2542 bnx2x_link_update(&bp->link_params, &bp->link_vars); 2578 bnx2x_link_update(&bp->link_params, &bp->link_vars);
2543 2579
2544 if (bp->link_vars.link_up) { 2580 bnx2x_init_dropless_fc(bp);
2545 2581
2546 /* dropless flow control */ 2582 if (bp->link_vars.link_up) {
2547 if (!CHIP_IS_E1(bp) && bp->dropless_fc) {
2548 int port = BP_PORT(bp);
2549 u32 pause_enabled = 0;
2550
2551 if (bp->link_vars.flow_ctrl & BNX2X_FLOW_CTRL_TX)
2552 pause_enabled = 1;
2553
2554 REG_WR(bp, BAR_USTRORM_INTMEM +
2555 USTORM_ETH_PAUSE_ENABLED_OFFSET(port),
2556 pause_enabled);
2557 }
2558 2583
2559 if (bp->link_vars.mac_type != MAC_TYPE_EMAC) { 2584 if (bp->link_vars.mac_type != MAC_TYPE_EMAC) {
2560 struct host_port_stats *pstats; 2585 struct host_port_stats *pstats;
@@ -2568,17 +2593,8 @@ static void bnx2x_link_attn(struct bnx2x *bp)
2568 bnx2x_stats_handle(bp, STATS_EVENT_LINK_UP); 2593 bnx2x_stats_handle(bp, STATS_EVENT_LINK_UP);
2569 } 2594 }
2570 2595
2571 if (bp->link_vars.link_up && bp->link_vars.line_speed) { 2596 if (bp->link_vars.link_up && bp->link_vars.line_speed)
2572 int cmng_fns = bnx2x_get_cmng_fns_mode(bp); 2597 bnx2x_set_local_cmng(bp);
2573
2574 if (cmng_fns != CMNG_FNS_NONE) {
2575 bnx2x_cmng_fns_init(bp, false, cmng_fns);
2576 storm_memset_cmng(bp, &bp->cmng, BP_PORT(bp));
2577 } else
2578 /* rate shaping and fairness are disabled */
2579 DP(NETIF_MSG_IFUP,
2580 "single function mode without fairness\n");
2581 }
2582 2598
2583 __bnx2x_link_report(bp); 2599 __bnx2x_link_report(bp);
2584 2600
@@ -9639,6 +9655,12 @@ sp_rtnl_not_reset:
9639 &bp->sp_rtnl_state)) 9655 &bp->sp_rtnl_state))
9640 bnx2x_pf_set_vfs_vlan(bp); 9656 bnx2x_pf_set_vfs_vlan(bp);
9641 9657
9658 if (test_and_clear_bit(BNX2X_SP_RTNL_TX_STOP, &bp->sp_rtnl_state))
9659 bnx2x_dcbx_stop_hw_tx(bp);
9660
9661 if (test_and_clear_bit(BNX2X_SP_RTNL_TX_RESUME, &bp->sp_rtnl_state))
9662 bnx2x_dcbx_resume_hw_tx(bp);
9663
9642 /* work which needs rtnl lock not-taken (as it takes the lock itself and 9664 /* work which needs rtnl lock not-taken (as it takes the lock itself and
9643 * can be called from other contexts as well) 9665 * can be called from other contexts as well)
9644 */ 9666 */
@@ -10362,6 +10384,10 @@ static void bnx2x_get_common_hwinfo(struct bnx2x *bp)
10362 10384
10363 bp->flags |= (val >= REQ_BC_VER_4_DCBX_ADMIN_MSG_NON_PMF) ? 10385 bp->flags |= (val >= REQ_BC_VER_4_DCBX_ADMIN_MSG_NON_PMF) ?
10364 BC_SUPPORTS_DCBX_MSG_NON_PMF : 0; 10386 BC_SUPPORTS_DCBX_MSG_NON_PMF : 0;
10387
10388 bp->flags |= (val >= REQ_BC_VER_4_RMMOD_CMD) ?
10389 BC_SUPPORTS_RMMOD_CMD : 0;
10390
10365 boot_mode = SHMEM_RD(bp, 10391 boot_mode = SHMEM_RD(bp,
10366 dev_info.port_feature_config[BP_PORT(bp)].mba_config) & 10392 dev_info.port_feature_config[BP_PORT(bp)].mba_config) &
10367 PORT_FEATURE_MBA_BOOT_AGENT_TYPE_MASK; 10393 PORT_FEATURE_MBA_BOOT_AGENT_TYPE_MASK;
@@ -11137,6 +11163,9 @@ static bool bnx2x_get_dropless_info(struct bnx2x *bp)
11137 int tmp; 11163 int tmp;
11138 u32 cfg; 11164 u32 cfg;
11139 11165
11166 if (IS_VF(bp))
11167 return 0;
11168
11140 if (IS_MF(bp) && !CHIP_IS_E1x(bp)) { 11169 if (IS_MF(bp) && !CHIP_IS_E1x(bp)) {
11141 /* Take function: tmp = func */ 11170 /* Take function: tmp = func */
11142 tmp = BP_ABS_FUNC(bp); 11171 tmp = BP_ABS_FUNC(bp);
@@ -11524,6 +11553,7 @@ static int bnx2x_init_bp(struct bnx2x *bp)
11524 mutex_init(&bp->port.phy_mutex); 11553 mutex_init(&bp->port.phy_mutex);
11525 mutex_init(&bp->fw_mb_mutex); 11554 mutex_init(&bp->fw_mb_mutex);
11526 spin_lock_init(&bp->stats_lock); 11555 spin_lock_init(&bp->stats_lock);
11556 sema_init(&bp->stats_sema, 1);
11527 11557
11528 INIT_DELAYED_WORK(&bp->sp_task, bnx2x_sp_task); 11558 INIT_DELAYED_WORK(&bp->sp_task, bnx2x_sp_task);
11529 INIT_DELAYED_WORK(&bp->sp_rtnl_task, bnx2x_sp_rtnl_task); 11559 INIT_DELAYED_WORK(&bp->sp_rtnl_task, bnx2x_sp_rtnl_task);
@@ -12817,13 +12847,17 @@ static void __bnx2x_remove(struct pci_dev *pdev,
12817 bnx2x_dcbnl_update_applist(bp, true); 12847 bnx2x_dcbnl_update_applist(bp, true);
12818#endif 12848#endif
12819 12849
12850 if (IS_PF(bp) &&
12851 !BP_NOMCP(bp) &&
12852 (bp->flags & BC_SUPPORTS_RMMOD_CMD))
12853 bnx2x_fw_command(bp, DRV_MSG_CODE_RMMOD, 0);
12854
12820 /* Close the interface - either directly or implicitly */ 12855 /* Close the interface - either directly or implicitly */
12821 if (remove_netdev) { 12856 if (remove_netdev) {
12822 unregister_netdev(dev); 12857 unregister_netdev(dev);
12823 } else { 12858 } else {
12824 rtnl_lock(); 12859 rtnl_lock();
12825 if (netif_running(dev)) 12860 dev_close(dev);
12826 bnx2x_close(dev);
12827 rtnl_unlock(); 12861 rtnl_unlock();
12828 } 12862 }
12829 12863
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
index 95861efb5051..ad83f4b48777 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
@@ -1747,11 +1747,8 @@ void bnx2x_iov_init_dq(struct bnx2x *bp)
1747 1747
1748void bnx2x_iov_init_dmae(struct bnx2x *bp) 1748void bnx2x_iov_init_dmae(struct bnx2x *bp)
1749{ 1749{
1750 DP(BNX2X_MSG_IOV, "SRIOV is %s\n", IS_SRIOV(bp) ? "ON" : "OFF"); 1750 if (pci_find_ext_capability(bp->pdev, PCI_EXT_CAP_ID_SRIOV))
1751 if (!IS_SRIOV(bp)) 1751 REG_WR(bp, DMAE_REG_BACKWARD_COMP_EN, 0);
1752 return;
1753
1754 REG_WR(bp, DMAE_REG_BACKWARD_COMP_EN, 0);
1755} 1752}
1756 1753
1757static int bnx2x_vf_bus(struct bnx2x *bp, int vfid) 1754static int bnx2x_vf_bus(struct bnx2x *bp, int vfid)
@@ -3084,8 +3081,9 @@ void bnx2x_disable_sriov(struct bnx2x *bp)
3084 pci_disable_sriov(bp->pdev); 3081 pci_disable_sriov(bp->pdev);
3085} 3082}
3086 3083
3087static int bnx2x_vf_ndo_sanity(struct bnx2x *bp, int vfidx, 3084static int bnx2x_vf_ndo_prep(struct bnx2x *bp, int vfidx,
3088 struct bnx2x_virtf *vf) 3085 struct bnx2x_virtf **vf,
3086 struct pf_vf_bulletin_content **bulletin)
3089{ 3087{
3090 if (bp->state != BNX2X_STATE_OPEN) { 3088 if (bp->state != BNX2X_STATE_OPEN) {
3091 BNX2X_ERR("vf ndo called though PF is down\n"); 3089 BNX2X_ERR("vf ndo called though PF is down\n");
@@ -3103,12 +3101,22 @@ static int bnx2x_vf_ndo_sanity(struct bnx2x *bp, int vfidx,
3103 return -EINVAL; 3101 return -EINVAL;
3104 } 3102 }
3105 3103
3106 if (!vf) { 3104 /* init members */
3105 *vf = BP_VF(bp, vfidx);
3106 *bulletin = BP_VF_BULLETIN(bp, vfidx);
3107
3108 if (!*vf) {
3107 BNX2X_ERR("vf ndo called but vf was null. vfidx was %d\n", 3109 BNX2X_ERR("vf ndo called but vf was null. vfidx was %d\n",
3108 vfidx); 3110 vfidx);
3109 return -EINVAL; 3111 return -EINVAL;
3110 } 3112 }
3111 3113
3114 if (!*bulletin) {
3115 BNX2X_ERR("vf ndo called but Bulletin Board struct is null. vfidx was %d\n",
3116 vfidx);
3117 return -EINVAL;
3118 }
3119
3112 return 0; 3120 return 0;
3113} 3121}
3114 3122
@@ -3116,17 +3124,19 @@ int bnx2x_get_vf_config(struct net_device *dev, int vfidx,
3116 struct ifla_vf_info *ivi) 3124 struct ifla_vf_info *ivi)
3117{ 3125{
3118 struct bnx2x *bp = netdev_priv(dev); 3126 struct bnx2x *bp = netdev_priv(dev);
3119 struct bnx2x_virtf *vf = BP_VF(bp, vfidx); 3127 struct bnx2x_virtf *vf = NULL;
3120 struct bnx2x_vlan_mac_obj *mac_obj = &bnx2x_vfq(vf, 0, mac_obj); 3128 struct pf_vf_bulletin_content *bulletin = NULL;
3121 struct bnx2x_vlan_mac_obj *vlan_obj = &bnx2x_vfq(vf, 0, vlan_obj); 3129 struct bnx2x_vlan_mac_obj *mac_obj;
3122 struct pf_vf_bulletin_content *bulletin = BP_VF_BULLETIN(bp, vfidx); 3130 struct bnx2x_vlan_mac_obj *vlan_obj;
3123 int rc; 3131 int rc;
3124 3132
3125 /* sanity */ 3133 /* sanity and init */
3126 rc = bnx2x_vf_ndo_sanity(bp, vfidx, vf); 3134 rc = bnx2x_vf_ndo_prep(bp, vfidx, &vf, &bulletin);
3127 if (rc) 3135 if (rc)
3128 return rc; 3136 return rc;
3129 if (!mac_obj || !vlan_obj || !bulletin) { 3137 mac_obj = &bnx2x_vfq(vf, 0, mac_obj);
3138 vlan_obj = &bnx2x_vfq(vf, 0, vlan_obj);
3139 if (!mac_obj || !vlan_obj) {
3130 BNX2X_ERR("VF partially initialized\n"); 3140 BNX2X_ERR("VF partially initialized\n");
3131 return -EINVAL; 3141 return -EINVAL;
3132 } 3142 }
@@ -3183,11 +3193,11 @@ int bnx2x_set_vf_mac(struct net_device *dev, int vfidx, u8 *mac)
3183{ 3193{
3184 struct bnx2x *bp = netdev_priv(dev); 3194 struct bnx2x *bp = netdev_priv(dev);
3185 int rc, q_logical_state; 3195 int rc, q_logical_state;
3186 struct bnx2x_virtf *vf = BP_VF(bp, vfidx); 3196 struct bnx2x_virtf *vf = NULL;
3187 struct pf_vf_bulletin_content *bulletin = BP_VF_BULLETIN(bp, vfidx); 3197 struct pf_vf_bulletin_content *bulletin = NULL;
3188 3198
3189 /* sanity */ 3199 /* sanity and init */
3190 rc = bnx2x_vf_ndo_sanity(bp, vfidx, vf); 3200 rc = bnx2x_vf_ndo_prep(bp, vfidx, &vf, &bulletin);
3191 if (rc) 3201 if (rc)
3192 return rc; 3202 return rc;
3193 if (!is_valid_ether_addr(mac)) { 3203 if (!is_valid_ether_addr(mac)) {
@@ -3249,11 +3259,11 @@ int bnx2x_set_vf_vlan(struct net_device *dev, int vfidx, u16 vlan, u8 qos)
3249{ 3259{
3250 struct bnx2x *bp = netdev_priv(dev); 3260 struct bnx2x *bp = netdev_priv(dev);
3251 int rc, q_logical_state; 3261 int rc, q_logical_state;
3252 struct bnx2x_virtf *vf = BP_VF(bp, vfidx); 3262 struct bnx2x_virtf *vf = NULL;
3253 struct pf_vf_bulletin_content *bulletin = BP_VF_BULLETIN(bp, vfidx); 3263 struct pf_vf_bulletin_content *bulletin = NULL;
3254 3264
3255 /* sanity */ 3265 /* sanity and init */
3256 rc = bnx2x_vf_ndo_sanity(bp, vfidx, vf); 3266 rc = bnx2x_vf_ndo_prep(bp, vfidx, &vf, &bulletin);
3257 if (rc) 3267 if (rc)
3258 return rc; 3268 return rc;
3259 3269
@@ -3463,7 +3473,7 @@ int bnx2x_vf_pci_alloc(struct bnx2x *bp)
3463alloc_mem_err: 3473alloc_mem_err:
3464 BNX2X_PCI_FREE(bp->vf2pf_mbox, bp->vf2pf_mbox_mapping, 3474 BNX2X_PCI_FREE(bp->vf2pf_mbox, bp->vf2pf_mbox_mapping,
3465 sizeof(struct bnx2x_vf_mbx_msg)); 3475 sizeof(struct bnx2x_vf_mbx_msg));
3466 BNX2X_PCI_FREE(bp->vf2pf_mbox, bp->vf2pf_mbox_mapping, 3476 BNX2X_PCI_FREE(bp->vf2pf_mbox, bp->pf2vf_bulletin_mapping,
3467 sizeof(union pf_vf_bulletin)); 3477 sizeof(union pf_vf_bulletin));
3468 return -ENOMEM; 3478 return -ENOMEM;
3469} 3479}
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c
index 98366abd02bd..d63d1327b051 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c
@@ -221,7 +221,8 @@ static int bnx2x_stats_comp(struct bnx2x *bp)
221 * Statistics service functions 221 * Statistics service functions
222 */ 222 */
223 223
224static void bnx2x_stats_pmf_update(struct bnx2x *bp) 224/* should be called under stats_sema */
225static void __bnx2x_stats_pmf_update(struct bnx2x *bp)
225{ 226{
226 struct dmae_command *dmae; 227 struct dmae_command *dmae;
227 u32 opcode; 228 u32 opcode;
@@ -518,7 +519,8 @@ static void bnx2x_func_stats_init(struct bnx2x *bp)
518 *stats_comp = 0; 519 *stats_comp = 0;
519} 520}
520 521
521static void bnx2x_stats_start(struct bnx2x *bp) 522/* should be called under stats_sema */
523static void __bnx2x_stats_start(struct bnx2x *bp)
522{ 524{
523 /* vfs travel through here as part of the statistics FSM, but no action 525 /* vfs travel through here as part of the statistics FSM, but no action
524 * is required 526 * is required
@@ -534,13 +536,34 @@ static void bnx2x_stats_start(struct bnx2x *bp)
534 536
535 bnx2x_hw_stats_post(bp); 537 bnx2x_hw_stats_post(bp);
536 bnx2x_storm_stats_post(bp); 538 bnx2x_storm_stats_post(bp);
539
540 bp->stats_started = true;
541}
542
543static void bnx2x_stats_start(struct bnx2x *bp)
544{
545 if (down_timeout(&bp->stats_sema, HZ/10))
546 BNX2X_ERR("Unable to acquire stats lock\n");
547 __bnx2x_stats_start(bp);
548 up(&bp->stats_sema);
537} 549}
538 550
539static void bnx2x_stats_pmf_start(struct bnx2x *bp) 551static void bnx2x_stats_pmf_start(struct bnx2x *bp)
540{ 552{
553 if (down_timeout(&bp->stats_sema, HZ/10))
554 BNX2X_ERR("Unable to acquire stats lock\n");
541 bnx2x_stats_comp(bp); 555 bnx2x_stats_comp(bp);
542 bnx2x_stats_pmf_update(bp); 556 __bnx2x_stats_pmf_update(bp);
543 bnx2x_stats_start(bp); 557 __bnx2x_stats_start(bp);
558 up(&bp->stats_sema);
559}
560
561static void bnx2x_stats_pmf_update(struct bnx2x *bp)
562{
563 if (down_timeout(&bp->stats_sema, HZ/10))
564 BNX2X_ERR("Unable to acquire stats lock\n");
565 __bnx2x_stats_pmf_update(bp);
566 up(&bp->stats_sema);
544} 567}
545 568
546static void bnx2x_stats_restart(struct bnx2x *bp) 569static void bnx2x_stats_restart(struct bnx2x *bp)
@@ -550,8 +573,11 @@ static void bnx2x_stats_restart(struct bnx2x *bp)
550 */ 573 */
551 if (IS_VF(bp)) 574 if (IS_VF(bp))
552 return; 575 return;
576 if (down_timeout(&bp->stats_sema, HZ/10))
577 BNX2X_ERR("Unable to acquire stats lock\n");
553 bnx2x_stats_comp(bp); 578 bnx2x_stats_comp(bp);
554 bnx2x_stats_start(bp); 579 __bnx2x_stats_start(bp);
580 up(&bp->stats_sema);
555} 581}
556 582
557static void bnx2x_bmac_stats_update(struct bnx2x *bp) 583static void bnx2x_bmac_stats_update(struct bnx2x *bp)
@@ -888,9 +914,7 @@ static int bnx2x_storm_stats_validate_counters(struct bnx2x *bp)
888 /* Make sure we use the value of the counter 914 /* Make sure we use the value of the counter
889 * used for sending the last stats ramrod. 915 * used for sending the last stats ramrod.
890 */ 916 */
891 spin_lock_bh(&bp->stats_lock);
892 cur_stats_counter = bp->stats_counter - 1; 917 cur_stats_counter = bp->stats_counter - 1;
893 spin_unlock_bh(&bp->stats_lock);
894 918
895 /* are storm stats valid? */ 919 /* are storm stats valid? */
896 if (le16_to_cpu(counters->xstats_counter) != cur_stats_counter) { 920 if (le16_to_cpu(counters->xstats_counter) != cur_stats_counter) {
@@ -1227,12 +1251,18 @@ static void bnx2x_stats_update(struct bnx2x *bp)
1227{ 1251{
1228 u32 *stats_comp = bnx2x_sp(bp, stats_comp); 1252 u32 *stats_comp = bnx2x_sp(bp, stats_comp);
1229 1253
1230 if (bnx2x_edebug_stats_stopped(bp)) 1254 /* we run update from timer context, so give up
1255 * if somebody is in the middle of transition
1256 */
1257 if (down_trylock(&bp->stats_sema))
1231 return; 1258 return;
1232 1259
1260 if (bnx2x_edebug_stats_stopped(bp) || !bp->stats_started)
1261 goto out;
1262
1233 if (IS_PF(bp)) { 1263 if (IS_PF(bp)) {
1234 if (*stats_comp != DMAE_COMP_VAL) 1264 if (*stats_comp != DMAE_COMP_VAL)
1235 return; 1265 goto out;
1236 1266
1237 if (bp->port.pmf) 1267 if (bp->port.pmf)
1238 bnx2x_hw_stats_update(bp); 1268 bnx2x_hw_stats_update(bp);
@@ -1242,7 +1272,7 @@ static void bnx2x_stats_update(struct bnx2x *bp)
1242 BNX2X_ERR("storm stats were not updated for 3 times\n"); 1272 BNX2X_ERR("storm stats were not updated for 3 times\n");
1243 bnx2x_panic(); 1273 bnx2x_panic();
1244 } 1274 }
1245 return; 1275 goto out;
1246 } 1276 }
1247 } else { 1277 } else {
1248 /* vf doesn't collect HW statistics, and doesn't get completions 1278 /* vf doesn't collect HW statistics, and doesn't get completions
@@ -1256,7 +1286,7 @@ static void bnx2x_stats_update(struct bnx2x *bp)
1256 1286
1257 /* vf is done */ 1287 /* vf is done */
1258 if (IS_VF(bp)) 1288 if (IS_VF(bp))
1259 return; 1289 goto out;
1260 1290
1261 if (netif_msg_timer(bp)) { 1291 if (netif_msg_timer(bp)) {
1262 struct bnx2x_eth_stats *estats = &bp->eth_stats; 1292 struct bnx2x_eth_stats *estats = &bp->eth_stats;
@@ -1267,6 +1297,9 @@ static void bnx2x_stats_update(struct bnx2x *bp)
1267 1297
1268 bnx2x_hw_stats_post(bp); 1298 bnx2x_hw_stats_post(bp);
1269 bnx2x_storm_stats_post(bp); 1299 bnx2x_storm_stats_post(bp);
1300
1301out:
1302 up(&bp->stats_sema);
1270} 1303}
1271 1304
1272static void bnx2x_port_stats_stop(struct bnx2x *bp) 1305static void bnx2x_port_stats_stop(struct bnx2x *bp)
@@ -1332,6 +1365,11 @@ static void bnx2x_stats_stop(struct bnx2x *bp)
1332{ 1365{
1333 int update = 0; 1366 int update = 0;
1334 1367
1368 if (down_timeout(&bp->stats_sema, HZ/10))
1369 BNX2X_ERR("Unable to acquire stats lock\n");
1370
1371 bp->stats_started = false;
1372
1335 bnx2x_stats_comp(bp); 1373 bnx2x_stats_comp(bp);
1336 1374
1337 if (bp->port.pmf) 1375 if (bp->port.pmf)
@@ -1348,6 +1386,8 @@ static void bnx2x_stats_stop(struct bnx2x *bp)
1348 bnx2x_hw_stats_post(bp); 1386 bnx2x_hw_stats_post(bp);
1349 bnx2x_stats_comp(bp); 1387 bnx2x_stats_comp(bp);
1350 } 1388 }
1389
1390 up(&bp->stats_sema);
1351} 1391}
1352 1392
1353static void bnx2x_stats_do_nothing(struct bnx2x *bp) 1393static void bnx2x_stats_do_nothing(struct bnx2x *bp)
@@ -1376,15 +1416,17 @@ static const struct {
1376void bnx2x_stats_handle(struct bnx2x *bp, enum bnx2x_stats_event event) 1416void bnx2x_stats_handle(struct bnx2x *bp, enum bnx2x_stats_event event)
1377{ 1417{
1378 enum bnx2x_stats_state state; 1418 enum bnx2x_stats_state state;
1419 void (*action)(struct bnx2x *bp);
1379 if (unlikely(bp->panic)) 1420 if (unlikely(bp->panic))
1380 return; 1421 return;
1381 1422
1382 spin_lock_bh(&bp->stats_lock); 1423 spin_lock_bh(&bp->stats_lock);
1383 state = bp->stats_state; 1424 state = bp->stats_state;
1384 bp->stats_state = bnx2x_stats_stm[state][event].next_state; 1425 bp->stats_state = bnx2x_stats_stm[state][event].next_state;
1426 action = bnx2x_stats_stm[state][event].action;
1385 spin_unlock_bh(&bp->stats_lock); 1427 spin_unlock_bh(&bp->stats_lock);
1386 1428
1387 bnx2x_stats_stm[state][event].action(bp); 1429 action(bp);
1388 1430
1389 if ((event != STATS_EVENT_UPDATE) || netif_msg_timer(bp)) 1431 if ((event != STATS_EVENT_UPDATE) || netif_msg_timer(bp))
1390 DP(BNX2X_MSG_STATS, "state %d -> event %d -> state %d\n", 1432 DP(BNX2X_MSG_STATS, "state %d -> event %d -> state %d\n",
diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index ddebc7a5dda0..0da2214ef1b9 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -17796,8 +17796,10 @@ static pci_ers_result_t tg3_io_error_detected(struct pci_dev *pdev,
17796 17796
17797done: 17797done:
17798 if (state == pci_channel_io_perm_failure) { 17798 if (state == pci_channel_io_perm_failure) {
17799 tg3_napi_enable(tp); 17799 if (netdev) {
17800 dev_close(netdev); 17800 tg3_napi_enable(tp);
17801 dev_close(netdev);
17802 }
17801 err = PCI_ERS_RESULT_DISCONNECT; 17803 err = PCI_ERS_RESULT_DISCONNECT;
17802 } else { 17804 } else {
17803 pci_disable_device(pdev); 17805 pci_disable_device(pdev);
@@ -17827,7 +17829,8 @@ static pci_ers_result_t tg3_io_slot_reset(struct pci_dev *pdev)
17827 rtnl_lock(); 17829 rtnl_lock();
17828 17830
17829 if (pci_enable_device(pdev)) { 17831 if (pci_enable_device(pdev)) {
17830 netdev_err(netdev, "Cannot re-enable PCI device after reset.\n"); 17832 dev_err(&pdev->dev,
17833 "Cannot re-enable PCI device after reset.\n");
17831 goto done; 17834 goto done;
17832 } 17835 }
17833 17836
@@ -17835,7 +17838,7 @@ static pci_ers_result_t tg3_io_slot_reset(struct pci_dev *pdev)
17835 pci_restore_state(pdev); 17838 pci_restore_state(pdev);
17836 pci_save_state(pdev); 17839 pci_save_state(pdev);
17837 17840
17838 if (!netif_running(netdev)) { 17841 if (!netdev || !netif_running(netdev)) {
17839 rc = PCI_ERS_RESULT_RECOVERED; 17842 rc = PCI_ERS_RESULT_RECOVERED;
17840 goto done; 17843 goto done;
17841 } 17844 }
@@ -17847,7 +17850,7 @@ static pci_ers_result_t tg3_io_slot_reset(struct pci_dev *pdev)
17847 rc = PCI_ERS_RESULT_RECOVERED; 17850 rc = PCI_ERS_RESULT_RECOVERED;
17848 17851
17849done: 17852done:
17850 if (rc != PCI_ERS_RESULT_RECOVERED && netif_running(netdev)) { 17853 if (rc != PCI_ERS_RESULT_RECOVERED && netdev && netif_running(netdev)) {
17851 tg3_napi_enable(tp); 17854 tg3_napi_enable(tp);
17852 dev_close(netdev); 17855 dev_close(netdev);
17853 } 17856 }
diff --git a/drivers/net/ethernet/chelsio/cxgb3/sge.c b/drivers/net/ethernet/chelsio/cxgb3/sge.c
index 687ec4a8bb48..9c89dc8fe105 100644
--- a/drivers/net/ethernet/chelsio/cxgb3/sge.c
+++ b/drivers/net/ethernet/chelsio/cxgb3/sge.c
@@ -455,11 +455,6 @@ static int alloc_pg_chunk(struct adapter *adapter, struct sge_fl *q,
455 q->pg_chunk.offset = 0; 455 q->pg_chunk.offset = 0;
456 mapping = pci_map_page(adapter->pdev, q->pg_chunk.page, 456 mapping = pci_map_page(adapter->pdev, q->pg_chunk.page,
457 0, q->alloc_size, PCI_DMA_FROMDEVICE); 457 0, q->alloc_size, PCI_DMA_FROMDEVICE);
458 if (unlikely(pci_dma_mapping_error(adapter->pdev, mapping))) {
459 __free_pages(q->pg_chunk.page, order);
460 q->pg_chunk.page = NULL;
461 return -EIO;
462 }
463 q->pg_chunk.mapping = mapping; 458 q->pg_chunk.mapping = mapping;
464 } 459 }
465 sd->pg_chunk = q->pg_chunk; 460 sd->pg_chunk = q->pg_chunk;
@@ -954,75 +949,40 @@ static inline unsigned int calc_tx_descs(const struct sk_buff *skb)
954 return flits_to_desc(flits); 949 return flits_to_desc(flits);
955} 950}
956 951
957
958/* map_skb - map a packet main body and its page fragments
959 * @pdev: the PCI device
960 * @skb: the packet
961 * @addr: placeholder to save the mapped addresses
962 *
963 * map the main body of an sk_buff and its page fragments, if any.
964 */
965static int map_skb(struct pci_dev *pdev, const struct sk_buff *skb,
966 dma_addr_t *addr)
967{
968 const skb_frag_t *fp, *end;
969 const struct skb_shared_info *si;
970
971 *addr = pci_map_single(pdev, skb->data, skb_headlen(skb),
972 PCI_DMA_TODEVICE);
973 if (pci_dma_mapping_error(pdev, *addr))
974 goto out_err;
975
976 si = skb_shinfo(skb);
977 end = &si->frags[si->nr_frags];
978
979 for (fp = si->frags; fp < end; fp++) {
980 *++addr = skb_frag_dma_map(&pdev->dev, fp, 0, skb_frag_size(fp),
981 DMA_TO_DEVICE);
982 if (pci_dma_mapping_error(pdev, *addr))
983 goto unwind;
984 }
985 return 0;
986
987unwind:
988 while (fp-- > si->frags)
989 dma_unmap_page(&pdev->dev, *--addr, skb_frag_size(fp),
990 DMA_TO_DEVICE);
991
992 pci_unmap_single(pdev, addr[-1], skb_headlen(skb), PCI_DMA_TODEVICE);
993out_err:
994 return -ENOMEM;
995}
996
997/** 952/**
998 * write_sgl - populate a scatter/gather list for a packet 953 * make_sgl - populate a scatter/gather list for a packet
999 * @skb: the packet 954 * @skb: the packet
1000 * @sgp: the SGL to populate 955 * @sgp: the SGL to populate
1001 * @start: start address of skb main body data to include in the SGL 956 * @start: start address of skb main body data to include in the SGL
1002 * @len: length of skb main body data to include in the SGL 957 * @len: length of skb main body data to include in the SGL
1003 * @addr: the list of the mapped addresses 958 * @pdev: the PCI device
1004 * 959 *
1005 * Copies the scatter/gather list for the buffers that make up a packet 960 * Generates a scatter/gather list for the buffers that make up a packet
1006 * and returns the SGL size in 8-byte words. The caller must size the SGL 961 * and returns the SGL size in 8-byte words. The caller must size the SGL
1007 * appropriately. 962 * appropriately.
1008 */ 963 */
1009static inline unsigned int write_sgl(const struct sk_buff *skb, 964static inline unsigned int make_sgl(const struct sk_buff *skb,
1010 struct sg_ent *sgp, unsigned char *start, 965 struct sg_ent *sgp, unsigned char *start,
1011 unsigned int len, const dma_addr_t *addr) 966 unsigned int len, struct pci_dev *pdev)
1012{ 967{
1013 unsigned int i, j = 0, k = 0, nfrags; 968 dma_addr_t mapping;
969 unsigned int i, j = 0, nfrags;
1014 970
1015 if (len) { 971 if (len) {
972 mapping = pci_map_single(pdev, start, len, PCI_DMA_TODEVICE);
1016 sgp->len[0] = cpu_to_be32(len); 973 sgp->len[0] = cpu_to_be32(len);
1017 sgp->addr[j++] = cpu_to_be64(addr[k++]); 974 sgp->addr[0] = cpu_to_be64(mapping);
975 j = 1;
1018 } 976 }
1019 977
1020 nfrags = skb_shinfo(skb)->nr_frags; 978 nfrags = skb_shinfo(skb)->nr_frags;
1021 for (i = 0; i < nfrags; i++) { 979 for (i = 0; i < nfrags; i++) {
1022 const skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; 980 const skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
1023 981
982 mapping = skb_frag_dma_map(&pdev->dev, frag, 0, skb_frag_size(frag),
983 DMA_TO_DEVICE);
1024 sgp->len[j] = cpu_to_be32(skb_frag_size(frag)); 984 sgp->len[j] = cpu_to_be32(skb_frag_size(frag));
1025 sgp->addr[j] = cpu_to_be64(addr[k++]); 985 sgp->addr[j] = cpu_to_be64(mapping);
1026 j ^= 1; 986 j ^= 1;
1027 if (j == 0) 987 if (j == 0)
1028 ++sgp; 988 ++sgp;
@@ -1178,7 +1138,7 @@ static void write_tx_pkt_wr(struct adapter *adap, struct sk_buff *skb,
1178 const struct port_info *pi, 1138 const struct port_info *pi,
1179 unsigned int pidx, unsigned int gen, 1139 unsigned int pidx, unsigned int gen,
1180 struct sge_txq *q, unsigned int ndesc, 1140 struct sge_txq *q, unsigned int ndesc,
1181 unsigned int compl, const dma_addr_t *addr) 1141 unsigned int compl)
1182{ 1142{
1183 unsigned int flits, sgl_flits, cntrl, tso_info; 1143 unsigned int flits, sgl_flits, cntrl, tso_info;
1184 struct sg_ent *sgp, sgl[MAX_SKB_FRAGS / 2 + 1]; 1144 struct sg_ent *sgp, sgl[MAX_SKB_FRAGS / 2 + 1];
@@ -1236,7 +1196,7 @@ static void write_tx_pkt_wr(struct adapter *adap, struct sk_buff *skb,
1236 } 1196 }
1237 1197
1238 sgp = ndesc == 1 ? (struct sg_ent *)&d->flit[flits] : sgl; 1198 sgp = ndesc == 1 ? (struct sg_ent *)&d->flit[flits] : sgl;
1239 sgl_flits = write_sgl(skb, sgp, skb->data, skb_headlen(skb), addr); 1199 sgl_flits = make_sgl(skb, sgp, skb->data, skb_headlen(skb), adap->pdev);
1240 1200
1241 write_wr_hdr_sgl(ndesc, skb, d, pidx, q, sgl, flits, sgl_flits, gen, 1201 write_wr_hdr_sgl(ndesc, skb, d, pidx, q, sgl, flits, sgl_flits, gen,
1242 htonl(V_WR_OP(FW_WROPCODE_TUNNEL_TX_PKT) | compl), 1202 htonl(V_WR_OP(FW_WROPCODE_TUNNEL_TX_PKT) | compl),
@@ -1267,7 +1227,6 @@ netdev_tx_t t3_eth_xmit(struct sk_buff *skb, struct net_device *dev)
1267 struct netdev_queue *txq; 1227 struct netdev_queue *txq;
1268 struct sge_qset *qs; 1228 struct sge_qset *qs;
1269 struct sge_txq *q; 1229 struct sge_txq *q;
1270 dma_addr_t addr[MAX_SKB_FRAGS + 1];
1271 1230
1272 /* 1231 /*
1273 * The chip min packet length is 9 octets but play safe and reject 1232 * The chip min packet length is 9 octets but play safe and reject
@@ -1296,11 +1255,6 @@ netdev_tx_t t3_eth_xmit(struct sk_buff *skb, struct net_device *dev)
1296 return NETDEV_TX_BUSY; 1255 return NETDEV_TX_BUSY;
1297 } 1256 }
1298 1257
1299 if (unlikely(map_skb(adap->pdev, skb, addr) < 0)) {
1300 dev_kfree_skb(skb);
1301 return NETDEV_TX_OK;
1302 }
1303
1304 q->in_use += ndesc; 1258 q->in_use += ndesc;
1305 if (unlikely(credits - ndesc < q->stop_thres)) { 1259 if (unlikely(credits - ndesc < q->stop_thres)) {
1306 t3_stop_tx_queue(txq, qs, q); 1260 t3_stop_tx_queue(txq, qs, q);
@@ -1358,7 +1312,7 @@ netdev_tx_t t3_eth_xmit(struct sk_buff *skb, struct net_device *dev)
1358 if (likely(!skb_shared(skb))) 1312 if (likely(!skb_shared(skb)))
1359 skb_orphan(skb); 1313 skb_orphan(skb);
1360 1314
1361 write_tx_pkt_wr(adap, skb, pi, pidx, gen, q, ndesc, compl, addr); 1315 write_tx_pkt_wr(adap, skb, pi, pidx, gen, q, ndesc, compl);
1362 check_ring_tx_db(adap, q); 1316 check_ring_tx_db(adap, q);
1363 return NETDEV_TX_OK; 1317 return NETDEV_TX_OK;
1364} 1318}
@@ -1623,8 +1577,7 @@ static void setup_deferred_unmapping(struct sk_buff *skb, struct pci_dev *pdev,
1623 */ 1577 */
1624static void write_ofld_wr(struct adapter *adap, struct sk_buff *skb, 1578static void write_ofld_wr(struct adapter *adap, struct sk_buff *skb,
1625 struct sge_txq *q, unsigned int pidx, 1579 struct sge_txq *q, unsigned int pidx,
1626 unsigned int gen, unsigned int ndesc, 1580 unsigned int gen, unsigned int ndesc)
1627 const dma_addr_t *addr)
1628{ 1581{
1629 unsigned int sgl_flits, flits; 1582 unsigned int sgl_flits, flits;
1630 struct work_request_hdr *from; 1583 struct work_request_hdr *from;
@@ -1645,9 +1598,9 @@ static void write_ofld_wr(struct adapter *adap, struct sk_buff *skb,
1645 1598
1646 flits = skb_transport_offset(skb) / 8; 1599 flits = skb_transport_offset(skb) / 8;
1647 sgp = ndesc == 1 ? (struct sg_ent *)&d->flit[flits] : sgl; 1600 sgp = ndesc == 1 ? (struct sg_ent *)&d->flit[flits] : sgl;
1648 sgl_flits = write_sgl(skb, sgp, skb_transport_header(skb), 1601 sgl_flits = make_sgl(skb, sgp, skb_transport_header(skb),
1649 skb_tail_pointer(skb) - 1602 skb->tail - skb->transport_header,
1650 skb_transport_header(skb), addr); 1603 adap->pdev);
1651 if (need_skb_unmap()) { 1604 if (need_skb_unmap()) {
1652 setup_deferred_unmapping(skb, adap->pdev, sgp, sgl_flits); 1605 setup_deferred_unmapping(skb, adap->pdev, sgp, sgl_flits);
1653 skb->destructor = deferred_unmap_destructor; 1606 skb->destructor = deferred_unmap_destructor;
@@ -1705,11 +1658,6 @@ again: reclaim_completed_tx(adap, q, TX_RECLAIM_CHUNK);
1705 goto again; 1658 goto again;
1706 } 1659 }
1707 1660
1708 if (map_skb(adap->pdev, skb, (dma_addr_t *)skb->head)) {
1709 spin_unlock(&q->lock);
1710 return NET_XMIT_SUCCESS;
1711 }
1712
1713 gen = q->gen; 1661 gen = q->gen;
1714 q->in_use += ndesc; 1662 q->in_use += ndesc;
1715 pidx = q->pidx; 1663 pidx = q->pidx;
@@ -1720,7 +1668,7 @@ again: reclaim_completed_tx(adap, q, TX_RECLAIM_CHUNK);
1720 } 1668 }
1721 spin_unlock(&q->lock); 1669 spin_unlock(&q->lock);
1722 1670
1723 write_ofld_wr(adap, skb, q, pidx, gen, ndesc, (dma_addr_t *)skb->head); 1671 write_ofld_wr(adap, skb, q, pidx, gen, ndesc);
1724 check_ring_tx_db(adap, q); 1672 check_ring_tx_db(adap, q);
1725 return NET_XMIT_SUCCESS; 1673 return NET_XMIT_SUCCESS;
1726} 1674}
@@ -1738,7 +1686,6 @@ static void restart_offloadq(unsigned long data)
1738 struct sge_txq *q = &qs->txq[TXQ_OFLD]; 1686 struct sge_txq *q = &qs->txq[TXQ_OFLD];
1739 const struct port_info *pi = netdev_priv(qs->netdev); 1687 const struct port_info *pi = netdev_priv(qs->netdev);
1740 struct adapter *adap = pi->adapter; 1688 struct adapter *adap = pi->adapter;
1741 unsigned int written = 0;
1742 1689
1743 spin_lock(&q->lock); 1690 spin_lock(&q->lock);
1744again: reclaim_completed_tx(adap, q, TX_RECLAIM_CHUNK); 1691again: reclaim_completed_tx(adap, q, TX_RECLAIM_CHUNK);
@@ -1758,14 +1705,10 @@ again: reclaim_completed_tx(adap, q, TX_RECLAIM_CHUNK);
1758 break; 1705 break;
1759 } 1706 }
1760 1707
1761 if (map_skb(adap->pdev, skb, (dma_addr_t *)skb->head))
1762 break;
1763
1764 gen = q->gen; 1708 gen = q->gen;
1765 q->in_use += ndesc; 1709 q->in_use += ndesc;
1766 pidx = q->pidx; 1710 pidx = q->pidx;
1767 q->pidx += ndesc; 1711 q->pidx += ndesc;
1768 written += ndesc;
1769 if (q->pidx >= q->size) { 1712 if (q->pidx >= q->size) {
1770 q->pidx -= q->size; 1713 q->pidx -= q->size;
1771 q->gen ^= 1; 1714 q->gen ^= 1;
@@ -1773,8 +1716,7 @@ again: reclaim_completed_tx(adap, q, TX_RECLAIM_CHUNK);
1773 __skb_unlink(skb, &q->sendq); 1716 __skb_unlink(skb, &q->sendq);
1774 spin_unlock(&q->lock); 1717 spin_unlock(&q->lock);
1775 1718
1776 write_ofld_wr(adap, skb, q, pidx, gen, ndesc, 1719 write_ofld_wr(adap, skb, q, pidx, gen, ndesc);
1777 (dma_addr_t *)skb->head);
1778 spin_lock(&q->lock); 1720 spin_lock(&q->lock);
1779 } 1721 }
1780 spin_unlock(&q->lock); 1722 spin_unlock(&q->lock);
@@ -1784,9 +1726,8 @@ again: reclaim_completed_tx(adap, q, TX_RECLAIM_CHUNK);
1784 set_bit(TXQ_LAST_PKT_DB, &q->flags); 1726 set_bit(TXQ_LAST_PKT_DB, &q->flags);
1785#endif 1727#endif
1786 wmb(); 1728 wmb();
1787 if (likely(written)) 1729 t3_write_reg(adap, A_SG_KDOORBELL,
1788 t3_write_reg(adap, A_SG_KDOORBELL, 1730 F_SELEGRCNTX | V_EGRCNTX(q->cntxt_id));
1789 F_SELEGRCNTX | V_EGRCNTX(q->cntxt_id));
1790} 1731}
1791 1732
1792/** 1733/**
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c b/drivers/net/ethernet/emulex/benet/be_cmds.c
index 6e6e0a117ee2..8ec5d74ad44d 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.c
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.c
@@ -3048,6 +3048,9 @@ int be_cmd_get_func_config(struct be_adapter *adapter)
3048 3048
3049 adapter->max_event_queues = le16_to_cpu(desc->eq_count); 3049 adapter->max_event_queues = le16_to_cpu(desc->eq_count);
3050 adapter->if_cap_flags = le32_to_cpu(desc->cap_flags); 3050 adapter->if_cap_flags = le32_to_cpu(desc->cap_flags);
3051
3052 /* Clear flags that driver is not interested in */
3053 adapter->if_cap_flags &= BE_IF_CAP_FLAGS_WANT;
3051 } 3054 }
3052err: 3055err:
3053 mutex_unlock(&adapter->mbox_lock); 3056 mutex_unlock(&adapter->mbox_lock);
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.h b/drivers/net/ethernet/emulex/benet/be_cmds.h
index 5228d88c5a02..1b3b9e886412 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.h
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.h
@@ -563,6 +563,12 @@ enum be_if_flags {
563 BE_IF_FLAGS_MULTICAST = 0x1000 563 BE_IF_FLAGS_MULTICAST = 0x1000
564}; 564};
565 565
566#define BE_IF_CAP_FLAGS_WANT (BE_IF_FLAGS_RSS | BE_IF_FLAGS_PROMISCUOUS |\
567 BE_IF_FLAGS_BROADCAST | BE_IF_FLAGS_VLAN_PROMISCUOUS |\
568 BE_IF_FLAGS_VLAN | BE_IF_FLAGS_MCAST_PROMISCUOUS |\
569 BE_IF_FLAGS_PASS_L3L4_ERRORS | BE_IF_FLAGS_MULTICAST |\
570 BE_IF_FLAGS_UNTAGGED)
571
566/* An RX interface is an object with one or more MAC addresses and 572/* An RX interface is an object with one or more MAC addresses and
567 * filtering capabilities. */ 573 * filtering capabilities. */
568struct be_cmd_req_if_create { 574struct be_cmd_req_if_create {
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
index 181edb522450..4559c35eea13 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -2563,8 +2563,8 @@ static int be_close(struct net_device *netdev)
2563 /* Wait for all pending tx completions to arrive so that 2563 /* Wait for all pending tx completions to arrive so that
2564 * all tx skbs are freed. 2564 * all tx skbs are freed.
2565 */ 2565 */
2566 be_tx_compl_clean(adapter);
2567 netif_tx_disable(netdev); 2566 netif_tx_disable(netdev);
2567 be_tx_compl_clean(adapter);
2568 2568
2569 be_rx_qs_destroy(adapter); 2569 be_rx_qs_destroy(adapter);
2570 2570
diff --git a/drivers/net/ethernet/marvell/skge.c b/drivers/net/ethernet/marvell/skge.c
index c896079728e1..ef94a591f9e5 100644
--- a/drivers/net/ethernet/marvell/skge.c
+++ b/drivers/net/ethernet/marvell/skge.c
@@ -931,17 +931,20 @@ static int skge_ring_alloc(struct skge_ring *ring, void *vaddr, u32 base)
931} 931}
932 932
933/* Allocate and setup a new buffer for receiving */ 933/* Allocate and setup a new buffer for receiving */
934static void skge_rx_setup(struct skge_port *skge, struct skge_element *e, 934static int skge_rx_setup(struct skge_port *skge, struct skge_element *e,
935 struct sk_buff *skb, unsigned int bufsize) 935 struct sk_buff *skb, unsigned int bufsize)
936{ 936{
937 struct skge_rx_desc *rd = e->desc; 937 struct skge_rx_desc *rd = e->desc;
938 u64 map; 938 dma_addr_t map;
939 939
940 map = pci_map_single(skge->hw->pdev, skb->data, bufsize, 940 map = pci_map_single(skge->hw->pdev, skb->data, bufsize,
941 PCI_DMA_FROMDEVICE); 941 PCI_DMA_FROMDEVICE);
942 942
943 rd->dma_lo = map; 943 if (pci_dma_mapping_error(skge->hw->pdev, map))
944 rd->dma_hi = map >> 32; 944 return -1;
945
946 rd->dma_lo = lower_32_bits(map);
947 rd->dma_hi = upper_32_bits(map);
945 e->skb = skb; 948 e->skb = skb;
946 rd->csum1_start = ETH_HLEN; 949 rd->csum1_start = ETH_HLEN;
947 rd->csum2_start = ETH_HLEN; 950 rd->csum2_start = ETH_HLEN;
@@ -953,6 +956,7 @@ static void skge_rx_setup(struct skge_port *skge, struct skge_element *e,
953 rd->control = BMU_OWN | BMU_STF | BMU_IRQ_EOF | BMU_TCP_CHECK | bufsize; 956 rd->control = BMU_OWN | BMU_STF | BMU_IRQ_EOF | BMU_TCP_CHECK | bufsize;
954 dma_unmap_addr_set(e, mapaddr, map); 957 dma_unmap_addr_set(e, mapaddr, map);
955 dma_unmap_len_set(e, maplen, bufsize); 958 dma_unmap_len_set(e, maplen, bufsize);
959 return 0;
956} 960}
957 961
958/* Resume receiving using existing skb, 962/* Resume receiving using existing skb,
@@ -1014,7 +1018,10 @@ static int skge_rx_fill(struct net_device *dev)
1014 return -ENOMEM; 1018 return -ENOMEM;
1015 1019
1016 skb_reserve(skb, NET_IP_ALIGN); 1020 skb_reserve(skb, NET_IP_ALIGN);
1017 skge_rx_setup(skge, e, skb, skge->rx_buf_size); 1021 if (skge_rx_setup(skge, e, skb, skge->rx_buf_size) < 0) {
1022 dev_kfree_skb(skb);
1023 return -EIO;
1024 }
1018 } while ((e = e->next) != ring->start); 1025 } while ((e = e->next) != ring->start);
1019 1026
1020 ring->to_clean = ring->start; 1027 ring->to_clean = ring->start;
@@ -2544,7 +2551,7 @@ static int skge_up(struct net_device *dev)
2544 2551
2545 BUG_ON(skge->dma & 7); 2552 BUG_ON(skge->dma & 7);
2546 2553
2547 if ((u64)skge->dma >> 32 != ((u64) skge->dma + skge->mem_size) >> 32) { 2554 if (upper_32_bits(skge->dma) != upper_32_bits(skge->dma + skge->mem_size)) {
2548 dev_err(&hw->pdev->dev, "pci_alloc_consistent region crosses 4G boundary\n"); 2555 dev_err(&hw->pdev->dev, "pci_alloc_consistent region crosses 4G boundary\n");
2549 err = -EINVAL; 2556 err = -EINVAL;
2550 goto free_pci_mem; 2557 goto free_pci_mem;
@@ -2729,7 +2736,7 @@ static netdev_tx_t skge_xmit_frame(struct sk_buff *skb,
2729 struct skge_tx_desc *td; 2736 struct skge_tx_desc *td;
2730 int i; 2737 int i;
2731 u32 control, len; 2738 u32 control, len;
2732 u64 map; 2739 dma_addr_t map;
2733 2740
2734 if (skb_padto(skb, ETH_ZLEN)) 2741 if (skb_padto(skb, ETH_ZLEN))
2735 return NETDEV_TX_OK; 2742 return NETDEV_TX_OK;
@@ -2743,11 +2750,14 @@ static netdev_tx_t skge_xmit_frame(struct sk_buff *skb,
2743 e->skb = skb; 2750 e->skb = skb;
2744 len = skb_headlen(skb); 2751 len = skb_headlen(skb);
2745 map = pci_map_single(hw->pdev, skb->data, len, PCI_DMA_TODEVICE); 2752 map = pci_map_single(hw->pdev, skb->data, len, PCI_DMA_TODEVICE);
2753 if (pci_dma_mapping_error(hw->pdev, map))
2754 goto mapping_error;
2755
2746 dma_unmap_addr_set(e, mapaddr, map); 2756 dma_unmap_addr_set(e, mapaddr, map);
2747 dma_unmap_len_set(e, maplen, len); 2757 dma_unmap_len_set(e, maplen, len);
2748 2758
2749 td->dma_lo = map; 2759 td->dma_lo = lower_32_bits(map);
2750 td->dma_hi = map >> 32; 2760 td->dma_hi = upper_32_bits(map);
2751 2761
2752 if (skb->ip_summed == CHECKSUM_PARTIAL) { 2762 if (skb->ip_summed == CHECKSUM_PARTIAL) {
2753 const int offset = skb_checksum_start_offset(skb); 2763 const int offset = skb_checksum_start_offset(skb);
@@ -2778,14 +2788,16 @@ static netdev_tx_t skge_xmit_frame(struct sk_buff *skb,
2778 2788
2779 map = skb_frag_dma_map(&hw->pdev->dev, frag, 0, 2789 map = skb_frag_dma_map(&hw->pdev->dev, frag, 0,
2780 skb_frag_size(frag), DMA_TO_DEVICE); 2790 skb_frag_size(frag), DMA_TO_DEVICE);
2791 if (dma_mapping_error(&hw->pdev->dev, map))
2792 goto mapping_unwind;
2781 2793
2782 e = e->next; 2794 e = e->next;
2783 e->skb = skb; 2795 e->skb = skb;
2784 tf = e->desc; 2796 tf = e->desc;
2785 BUG_ON(tf->control & BMU_OWN); 2797 BUG_ON(tf->control & BMU_OWN);
2786 2798
2787 tf->dma_lo = map; 2799 tf->dma_lo = lower_32_bits(map);
2788 tf->dma_hi = (u64) map >> 32; 2800 tf->dma_hi = upper_32_bits(map);
2789 dma_unmap_addr_set(e, mapaddr, map); 2801 dma_unmap_addr_set(e, mapaddr, map);
2790 dma_unmap_len_set(e, maplen, skb_frag_size(frag)); 2802 dma_unmap_len_set(e, maplen, skb_frag_size(frag));
2791 2803
@@ -2815,6 +2827,26 @@ static netdev_tx_t skge_xmit_frame(struct sk_buff *skb,
2815 } 2827 }
2816 2828
2817 return NETDEV_TX_OK; 2829 return NETDEV_TX_OK;
2830
2831mapping_unwind:
2832 e = skge->tx_ring.to_use;
2833 pci_unmap_single(hw->pdev,
2834 dma_unmap_addr(e, mapaddr),
2835 dma_unmap_len(e, maplen),
2836 PCI_DMA_TODEVICE);
2837 while (i-- > 0) {
2838 e = e->next;
2839 pci_unmap_page(hw->pdev,
2840 dma_unmap_addr(e, mapaddr),
2841 dma_unmap_len(e, maplen),
2842 PCI_DMA_TODEVICE);
2843 }
2844
2845mapping_error:
2846 if (net_ratelimit())
2847 dev_warn(&hw->pdev->dev, "%s: tx mapping error\n", dev->name);
2848 dev_kfree_skb(skb);
2849 return NETDEV_TX_OK;
2818} 2850}
2819 2851
2820 2852
@@ -3045,11 +3077,13 @@ static struct sk_buff *skge_rx_get(struct net_device *dev,
3045 3077
3046 pci_dma_sync_single_for_cpu(skge->hw->pdev, 3078 pci_dma_sync_single_for_cpu(skge->hw->pdev,
3047 dma_unmap_addr(e, mapaddr), 3079 dma_unmap_addr(e, mapaddr),
3048 len, PCI_DMA_FROMDEVICE); 3080 dma_unmap_len(e, maplen),
3081 PCI_DMA_FROMDEVICE);
3049 skb_copy_from_linear_data(e->skb, skb->data, len); 3082 skb_copy_from_linear_data(e->skb, skb->data, len);
3050 pci_dma_sync_single_for_device(skge->hw->pdev, 3083 pci_dma_sync_single_for_device(skge->hw->pdev,
3051 dma_unmap_addr(e, mapaddr), 3084 dma_unmap_addr(e, mapaddr),
3052 len, PCI_DMA_FROMDEVICE); 3085 dma_unmap_len(e, maplen),
3086 PCI_DMA_FROMDEVICE);
3053 skge_rx_reuse(e, skge->rx_buf_size); 3087 skge_rx_reuse(e, skge->rx_buf_size);
3054 } else { 3088 } else {
3055 struct sk_buff *nskb; 3089 struct sk_buff *nskb;
@@ -3058,13 +3092,17 @@ static struct sk_buff *skge_rx_get(struct net_device *dev,
3058 if (!nskb) 3092 if (!nskb)
3059 goto resubmit; 3093 goto resubmit;
3060 3094
3095 if (skge_rx_setup(skge, e, nskb, skge->rx_buf_size) < 0) {
3096 dev_kfree_skb(nskb);
3097 goto resubmit;
3098 }
3099
3061 pci_unmap_single(skge->hw->pdev, 3100 pci_unmap_single(skge->hw->pdev,
3062 dma_unmap_addr(e, mapaddr), 3101 dma_unmap_addr(e, mapaddr),
3063 dma_unmap_len(e, maplen), 3102 dma_unmap_len(e, maplen),
3064 PCI_DMA_FROMDEVICE); 3103 PCI_DMA_FROMDEVICE);
3065 skb = e->skb; 3104 skb = e->skb;
3066 prefetch(skb->data); 3105 prefetch(skb->data);
3067 skge_rx_setup(skge, e, nskb, skge->rx_buf_size);
3068 } 3106 }
3069 3107
3070 skb_put(skb, len); 3108 skb_put(skb, len);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
index c571de85d0f9..5472cbd34028 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
@@ -46,7 +46,7 @@
46#include "mlx5_core.h" 46#include "mlx5_core.h"
47 47
48enum { 48enum {
49 CMD_IF_REV = 4, 49 CMD_IF_REV = 5,
50}; 50};
51 51
52enum { 52enum {
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eq.c b/drivers/net/ethernet/mellanox/mlx5/core/eq.c
index c02cbcfd0fb8..443cc4d7b024 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eq.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eq.c
@@ -268,7 +268,7 @@ static int mlx5_eq_int(struct mlx5_core_dev *dev, struct mlx5_eq *eq)
268 case MLX5_EVENT_TYPE_PAGE_REQUEST: 268 case MLX5_EVENT_TYPE_PAGE_REQUEST:
269 { 269 {
270 u16 func_id = be16_to_cpu(eqe->data.req_pages.func_id); 270 u16 func_id = be16_to_cpu(eqe->data.req_pages.func_id);
271 s16 npages = be16_to_cpu(eqe->data.req_pages.num_pages); 271 s32 npages = be32_to_cpu(eqe->data.req_pages.num_pages);
272 272
273 mlx5_core_dbg(dev, "page request for func 0x%x, napges %d\n", func_id, npages); 273 mlx5_core_dbg(dev, "page request for func 0x%x, napges %d\n", func_id, npages);
274 mlx5_core_req_pages_handler(dev, func_id, npages); 274 mlx5_core_req_pages_handler(dev, func_id, npages);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fw.c b/drivers/net/ethernet/mellanox/mlx5/core/fw.c
index 72a5222447f5..f012658b6a92 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/fw.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/fw.c
@@ -113,7 +113,7 @@ int mlx5_cmd_query_hca_cap(struct mlx5_core_dev *dev,
113 caps->log_max_srq = out->hca_cap.log_max_srqs & 0x1f; 113 caps->log_max_srq = out->hca_cap.log_max_srqs & 0x1f;
114 caps->local_ca_ack_delay = out->hca_cap.local_ca_ack_delay & 0x1f; 114 caps->local_ca_ack_delay = out->hca_cap.local_ca_ack_delay & 0x1f;
115 caps->log_max_mcg = out->hca_cap.log_max_mcg; 115 caps->log_max_mcg = out->hca_cap.log_max_mcg;
116 caps->max_qp_mcg = be16_to_cpu(out->hca_cap.max_qp_mcg); 116 caps->max_qp_mcg = be32_to_cpu(out->hca_cap.max_qp_mcg) & 0xffffff;
117 caps->max_ra_res_qp = 1 << (out->hca_cap.log_max_ra_res_qp & 0x3f); 117 caps->max_ra_res_qp = 1 << (out->hca_cap.log_max_ra_res_qp & 0x3f);
118 caps->max_ra_req_qp = 1 << (out->hca_cap.log_max_ra_req_qp & 0x3f); 118 caps->max_ra_req_qp = 1 << (out->hca_cap.log_max_ra_req_qp & 0x3f);
119 caps->max_srq_wqes = 1 << out->hca_cap.log_max_srq_sz; 119 caps->max_srq_wqes = 1 << out->hca_cap.log_max_srq_sz;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/health.c b/drivers/net/ethernet/mellanox/mlx5/core/health.c
index 748f10a155c4..3e6670c4a7cd 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/health.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/health.c
@@ -55,33 +55,9 @@ enum {
55}; 55};
56 56
57static DEFINE_SPINLOCK(health_lock); 57static DEFINE_SPINLOCK(health_lock);
58
59static LIST_HEAD(health_list); 58static LIST_HEAD(health_list);
60static struct work_struct health_work; 59static struct work_struct health_work;
61 60
62static health_handler_t reg_handler;
63int mlx5_register_health_report_handler(health_handler_t handler)
64{
65 spin_lock_irq(&health_lock);
66 if (reg_handler) {
67 spin_unlock_irq(&health_lock);
68 return -EEXIST;
69 }
70 reg_handler = handler;
71 spin_unlock_irq(&health_lock);
72
73 return 0;
74}
75EXPORT_SYMBOL(mlx5_register_health_report_handler);
76
77void mlx5_unregister_health_report_handler(void)
78{
79 spin_lock_irq(&health_lock);
80 reg_handler = NULL;
81 spin_unlock_irq(&health_lock);
82}
83EXPORT_SYMBOL(mlx5_unregister_health_report_handler);
84
85static void health_care(struct work_struct *work) 61static void health_care(struct work_struct *work)
86{ 62{
87 struct mlx5_core_health *health, *n; 63 struct mlx5_core_health *health, *n;
@@ -98,11 +74,8 @@ static void health_care(struct work_struct *work)
98 priv = container_of(health, struct mlx5_priv, health); 74 priv = container_of(health, struct mlx5_priv, health);
99 dev = container_of(priv, struct mlx5_core_dev, priv); 75 dev = container_of(priv, struct mlx5_core_dev, priv);
100 mlx5_core_warn(dev, "handling bad device here\n"); 76 mlx5_core_warn(dev, "handling bad device here\n");
77 /* nothing yet */
101 spin_lock_irq(&health_lock); 78 spin_lock_irq(&health_lock);
102 if (reg_handler)
103 reg_handler(dev->pdev, health->health,
104 sizeof(health->health));
105
106 list_del_init(&health->list); 79 list_del_init(&health->list);
107 spin_unlock_irq(&health_lock); 80 spin_unlock_irq(&health_lock);
108 } 81 }
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c b/drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c
index 4a3e137931a3..3a2408d44820 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c
@@ -43,10 +43,16 @@ enum {
43 MLX5_PAGES_TAKE = 2 43 MLX5_PAGES_TAKE = 2
44}; 44};
45 45
46enum {
47 MLX5_BOOT_PAGES = 1,
48 MLX5_INIT_PAGES = 2,
49 MLX5_POST_INIT_PAGES = 3
50};
51
46struct mlx5_pages_req { 52struct mlx5_pages_req {
47 struct mlx5_core_dev *dev; 53 struct mlx5_core_dev *dev;
48 u32 func_id; 54 u32 func_id;
49 s16 npages; 55 s32 npages;
50 struct work_struct work; 56 struct work_struct work;
51}; 57};
52 58
@@ -64,27 +70,23 @@ struct mlx5_query_pages_inbox {
64 70
65struct mlx5_query_pages_outbox { 71struct mlx5_query_pages_outbox {
66 struct mlx5_outbox_hdr hdr; 72 struct mlx5_outbox_hdr hdr;
67 __be16 num_boot_pages; 73 __be16 rsvd;
68 __be16 func_id; 74 __be16 func_id;
69 __be16 init_pages; 75 __be32 num_pages;
70 __be16 num_pages;
71}; 76};
72 77
73struct mlx5_manage_pages_inbox { 78struct mlx5_manage_pages_inbox {
74 struct mlx5_inbox_hdr hdr; 79 struct mlx5_inbox_hdr hdr;
75 __be16 rsvd0; 80 __be16 rsvd;
76 __be16 func_id; 81 __be16 func_id;
77 __be16 rsvd1; 82 __be32 num_entries;
78 __be16 num_entries;
79 u8 rsvd2[16];
80 __be64 pas[0]; 83 __be64 pas[0];
81}; 84};
82 85
83struct mlx5_manage_pages_outbox { 86struct mlx5_manage_pages_outbox {
84 struct mlx5_outbox_hdr hdr; 87 struct mlx5_outbox_hdr hdr;
85 u8 rsvd0[2]; 88 __be32 num_entries;
86 __be16 num_entries; 89 u8 rsvd[4];
87 u8 rsvd1[20];
88 __be64 pas[0]; 90 __be64 pas[0];
89}; 91};
90 92
@@ -146,7 +148,7 @@ static struct page *remove_page(struct mlx5_core_dev *dev, u64 addr)
146} 148}
147 149
148static int mlx5_cmd_query_pages(struct mlx5_core_dev *dev, u16 *func_id, 150static int mlx5_cmd_query_pages(struct mlx5_core_dev *dev, u16 *func_id,
149 s16 *pages, s16 *init_pages, u16 *boot_pages) 151 s32 *npages, int boot)
150{ 152{
151 struct mlx5_query_pages_inbox in; 153 struct mlx5_query_pages_inbox in;
152 struct mlx5_query_pages_outbox out; 154 struct mlx5_query_pages_outbox out;
@@ -155,6 +157,8 @@ static int mlx5_cmd_query_pages(struct mlx5_core_dev *dev, u16 *func_id,
155 memset(&in, 0, sizeof(in)); 157 memset(&in, 0, sizeof(in));
156 memset(&out, 0, sizeof(out)); 158 memset(&out, 0, sizeof(out));
157 in.hdr.opcode = cpu_to_be16(MLX5_CMD_OP_QUERY_PAGES); 159 in.hdr.opcode = cpu_to_be16(MLX5_CMD_OP_QUERY_PAGES);
160 in.hdr.opmod = boot ? cpu_to_be16(MLX5_BOOT_PAGES) : cpu_to_be16(MLX5_INIT_PAGES);
161
158 err = mlx5_cmd_exec(dev, &in, sizeof(in), &out, sizeof(out)); 162 err = mlx5_cmd_exec(dev, &in, sizeof(in), &out, sizeof(out));
159 if (err) 163 if (err)
160 return err; 164 return err;
@@ -162,15 +166,7 @@ static int mlx5_cmd_query_pages(struct mlx5_core_dev *dev, u16 *func_id,
162 if (out.hdr.status) 166 if (out.hdr.status)
163 return mlx5_cmd_status_to_err(&out.hdr); 167 return mlx5_cmd_status_to_err(&out.hdr);
164 168
165 if (pages) 169 *npages = be32_to_cpu(out.num_pages);
166 *pages = be16_to_cpu(out.num_pages);
167
168 if (init_pages)
169 *init_pages = be16_to_cpu(out.init_pages);
170
171 if (boot_pages)
172 *boot_pages = be16_to_cpu(out.num_boot_pages);
173
174 *func_id = be16_to_cpu(out.func_id); 170 *func_id = be16_to_cpu(out.func_id);
175 171
176 return err; 172 return err;
@@ -224,7 +220,7 @@ static int give_pages(struct mlx5_core_dev *dev, u16 func_id, int npages,
224 in->hdr.opcode = cpu_to_be16(MLX5_CMD_OP_MANAGE_PAGES); 220 in->hdr.opcode = cpu_to_be16(MLX5_CMD_OP_MANAGE_PAGES);
225 in->hdr.opmod = cpu_to_be16(MLX5_PAGES_GIVE); 221 in->hdr.opmod = cpu_to_be16(MLX5_PAGES_GIVE);
226 in->func_id = cpu_to_be16(func_id); 222 in->func_id = cpu_to_be16(func_id);
227 in->num_entries = cpu_to_be16(npages); 223 in->num_entries = cpu_to_be32(npages);
228 err = mlx5_cmd_exec(dev, in, inlen, &out, sizeof(out)); 224 err = mlx5_cmd_exec(dev, in, inlen, &out, sizeof(out));
229 mlx5_core_dbg(dev, "err %d\n", err); 225 mlx5_core_dbg(dev, "err %d\n", err);
230 if (err) { 226 if (err) {
@@ -292,7 +288,7 @@ static int reclaim_pages(struct mlx5_core_dev *dev, u32 func_id, int npages,
292 in.hdr.opcode = cpu_to_be16(MLX5_CMD_OP_MANAGE_PAGES); 288 in.hdr.opcode = cpu_to_be16(MLX5_CMD_OP_MANAGE_PAGES);
293 in.hdr.opmod = cpu_to_be16(MLX5_PAGES_TAKE); 289 in.hdr.opmod = cpu_to_be16(MLX5_PAGES_TAKE);
294 in.func_id = cpu_to_be16(func_id); 290 in.func_id = cpu_to_be16(func_id);
295 in.num_entries = cpu_to_be16(npages); 291 in.num_entries = cpu_to_be32(npages);
296 mlx5_core_dbg(dev, "npages %d, outlen %d\n", npages, outlen); 292 mlx5_core_dbg(dev, "npages %d, outlen %d\n", npages, outlen);
297 err = mlx5_cmd_exec(dev, &in, sizeof(in), out, outlen); 293 err = mlx5_cmd_exec(dev, &in, sizeof(in), out, outlen);
298 if (err) { 294 if (err) {
@@ -306,7 +302,7 @@ static int reclaim_pages(struct mlx5_core_dev *dev, u32 func_id, int npages,
306 goto out_free; 302 goto out_free;
307 } 303 }
308 304
309 num_claimed = be16_to_cpu(out->num_entries); 305 num_claimed = be32_to_cpu(out->num_entries);
310 if (nclaimed) 306 if (nclaimed)
311 *nclaimed = num_claimed; 307 *nclaimed = num_claimed;
312 308
@@ -345,7 +341,7 @@ static void pages_work_handler(struct work_struct *work)
345} 341}
346 342
347void mlx5_core_req_pages_handler(struct mlx5_core_dev *dev, u16 func_id, 343void mlx5_core_req_pages_handler(struct mlx5_core_dev *dev, u16 func_id,
348 s16 npages) 344 s32 npages)
349{ 345{
350 struct mlx5_pages_req *req; 346 struct mlx5_pages_req *req;
351 347
@@ -364,20 +360,18 @@ void mlx5_core_req_pages_handler(struct mlx5_core_dev *dev, u16 func_id,
364 360
365int mlx5_satisfy_startup_pages(struct mlx5_core_dev *dev, int boot) 361int mlx5_satisfy_startup_pages(struct mlx5_core_dev *dev, int boot)
366{ 362{
367 u16 uninitialized_var(boot_pages);
368 s16 uninitialized_var(init_pages);
369 u16 uninitialized_var(func_id); 363 u16 uninitialized_var(func_id);
364 s32 uninitialized_var(npages);
370 int err; 365 int err;
371 366
372 err = mlx5_cmd_query_pages(dev, &func_id, NULL, &init_pages, 367 err = mlx5_cmd_query_pages(dev, &func_id, &npages, boot);
373 &boot_pages);
374 if (err) 368 if (err)
375 return err; 369 return err;
376 370
371 mlx5_core_dbg(dev, "requested %d %s pages for func_id 0x%x\n",
372 npages, boot ? "boot" : "init", func_id);
377 373
378 mlx5_core_dbg(dev, "requested %d init pages and %d boot pages for func_id 0x%x\n", 374 return give_pages(dev, func_id, npages, 0);
379 init_pages, boot_pages, func_id);
380 return give_pages(dev, func_id, boot ? boot_pages : init_pages, 0);
381} 375}
382 376
383static int optimal_reclaimed_pages(void) 377static int optimal_reclaimed_pages(void)
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c
index 92da9980a0a0..9d4bb7f83904 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c
@@ -3266,6 +3266,11 @@ int qlcnic_83xx_interrupt_test(struct net_device *netdev)
3266 u8 val; 3266 u8 val;
3267 int ret, max_sds_rings = adapter->max_sds_rings; 3267 int ret, max_sds_rings = adapter->max_sds_rings;
3268 3268
3269 if (test_bit(__QLCNIC_RESETTING, &adapter->state)) {
3270 netdev_info(netdev, "Device is resetting\n");
3271 return -EBUSY;
3272 }
3273
3269 if (qlcnic_get_diag_lock(adapter)) { 3274 if (qlcnic_get_diag_lock(adapter)) {
3270 netdev_info(netdev, "Device in diagnostics mode\n"); 3275 netdev_info(netdev, "Device in diagnostics mode\n");
3271 return -EBUSY; 3276 return -EBUSY;
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
index 9f4b8d5f0865..345d987aede4 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
@@ -629,7 +629,8 @@ int qlcnic_83xx_idc_reattach_driver(struct qlcnic_adapter *adapter)
629 return -EIO; 629 return -EIO;
630 } 630 }
631 631
632 qlcnic_set_drv_version(adapter); 632 if (adapter->portnum == 0)
633 qlcnic_set_drv_version(adapter);
633 qlcnic_83xx_idc_attach_driver(adapter); 634 qlcnic_83xx_idc_attach_driver(adapter);
634 635
635 return 0; 636 return 0;
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
index ee013fcc3322..bc05d016c859 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
@@ -2165,7 +2165,8 @@ qlcnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
2165 if (err) 2165 if (err)
2166 goto err_out_disable_mbx_intr; 2166 goto err_out_disable_mbx_intr;
2167 2167
2168 qlcnic_set_drv_version(adapter); 2168 if (adapter->portnum == 0)
2169 qlcnic_set_drv_version(adapter);
2169 2170
2170 pci_set_drvdata(pdev, adapter); 2171 pci_set_drvdata(pdev, adapter);
2171 2172
@@ -3085,7 +3086,8 @@ done:
3085 adapter->fw_fail_cnt = 0; 3086 adapter->fw_fail_cnt = 0;
3086 adapter->flags &= ~QLCNIC_FW_HANG; 3087 adapter->flags &= ~QLCNIC_FW_HANG;
3087 clear_bit(__QLCNIC_RESETTING, &adapter->state); 3088 clear_bit(__QLCNIC_RESETTING, &adapter->state);
3088 qlcnic_set_drv_version(adapter); 3089 if (adapter->portnum == 0)
3090 qlcnic_set_drv_version(adapter);
3089 3091
3090 if (!qlcnic_clr_drv_state(adapter)) 3092 if (!qlcnic_clr_drv_state(adapter))
3091 qlcnic_schedule_work(adapter, qlcnic_fw_poll_work, 3093 qlcnic_schedule_work(adapter, qlcnic_fw_poll_work,
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c
index 10ed82b3baca..660c3f5b2237 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c
@@ -170,9 +170,9 @@ static int qlcnic_82xx_store_beacon(struct qlcnic_adapter *adapter,
170 170
171 if (ahw->extra_capability[0] & QLCNIC_FW_CAPABILITY_2_BEACON) { 171 if (ahw->extra_capability[0] & QLCNIC_FW_CAPABILITY_2_BEACON) {
172 err = qlcnic_get_beacon_state(adapter, &h_beacon_state); 172 err = qlcnic_get_beacon_state(adapter, &h_beacon_state);
173 if (!err) { 173 if (err) {
174 dev_info(&adapter->pdev->dev, 174 netdev_err(adapter->netdev,
175 "Failed to get current beacon state\n"); 175 "Failed to get current beacon state\n");
176 } else { 176 } else {
177 if (h_beacon_state == QLCNIC_BEACON_DISABLE) 177 if (h_beacon_state == QLCNIC_BEACON_DISABLE)
178 ahw->beacon_state = 0; 178 ahw->beacon_state = 0;
diff --git a/drivers/net/ethernet/realtek/8139cp.c b/drivers/net/ethernet/realtek/8139cp.c
index 6f35f8404d68..d2e591955bdd 100644
--- a/drivers/net/ethernet/realtek/8139cp.c
+++ b/drivers/net/ethernet/realtek/8139cp.c
@@ -524,6 +524,7 @@ rx_status_loop:
524 PCI_DMA_FROMDEVICE); 524 PCI_DMA_FROMDEVICE);
525 if (dma_mapping_error(&cp->pdev->dev, new_mapping)) { 525 if (dma_mapping_error(&cp->pdev->dev, new_mapping)) {
526 dev->stats.rx_dropped++; 526 dev->stats.rx_dropped++;
527 kfree_skb(new_skb);
527 goto rx_next; 528 goto rx_next;
528 } 529 }
529 530
diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
index b5eb4195fc99..85e5c97191dd 100644
--- a/drivers/net/ethernet/realtek/r8169.c
+++ b/drivers/net/ethernet/realtek/r8169.c
@@ -7088,7 +7088,7 @@ rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
7088 7088
7089 RTL_W8(Cfg9346, Cfg9346_Unlock); 7089 RTL_W8(Cfg9346, Cfg9346_Unlock);
7090 RTL_W8(Config1, RTL_R8(Config1) | PMEnable); 7090 RTL_W8(Config1, RTL_R8(Config1) | PMEnable);
7091 RTL_W8(Config5, RTL_R8(Config5) & PMEStatus); 7091 RTL_W8(Config5, RTL_R8(Config5) & (BWF | MWF | UWF | LanWake | PMEStatus));
7092 if ((RTL_R8(Config3) & (LinkUp | MagicPacket)) != 0) 7092 if ((RTL_R8(Config3) & (LinkUp | MagicPacket)) != 0)
7093 tp->features |= RTL_FEATURE_WOL; 7093 tp->features |= RTL_FEATURE_WOL;
7094 if ((RTL_R8(Config5) & (UWF | BWF | MWF)) != 0) 7094 if ((RTL_R8(Config5) & (UWF | BWF | MWF)) != 0)
diff --git a/drivers/net/ethernet/sfc/filter.c b/drivers/net/ethernet/sfc/filter.c
index 2a469b27a506..30d744235d27 100644
--- a/drivers/net/ethernet/sfc/filter.c
+++ b/drivers/net/ethernet/sfc/filter.c
@@ -675,7 +675,7 @@ s32 efx_filter_insert_filter(struct efx_nic *efx, struct efx_filter_spec *spec,
675 BUILD_BUG_ON(EFX_FILTER_INDEX_UC_DEF != 0); 675 BUILD_BUG_ON(EFX_FILTER_INDEX_UC_DEF != 0);
676 BUILD_BUG_ON(EFX_FILTER_INDEX_MC_DEF != 676 BUILD_BUG_ON(EFX_FILTER_INDEX_MC_DEF !=
677 EFX_FILTER_MC_DEF - EFX_FILTER_UC_DEF); 677 EFX_FILTER_MC_DEF - EFX_FILTER_UC_DEF);
678 rep_index = spec->type - EFX_FILTER_INDEX_UC_DEF; 678 rep_index = spec->type - EFX_FILTER_UC_DEF;
679 ins_index = rep_index; 679 ins_index = rep_index;
680 680
681 spin_lock_bh(&state->lock); 681 spin_lock_bh(&state->lock);
diff --git a/drivers/net/ethernet/stmicro/stmmac/ring_mode.c b/drivers/net/ethernet/stmicro/stmmac/ring_mode.c
index c9d942a5c335..1ef9d8a555aa 100644
--- a/drivers/net/ethernet/stmicro/stmmac/ring_mode.c
+++ b/drivers/net/ethernet/stmicro/stmmac/ring_mode.c
@@ -33,10 +33,15 @@ static unsigned int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum)
33 struct stmmac_priv *priv = (struct stmmac_priv *)p; 33 struct stmmac_priv *priv = (struct stmmac_priv *)p;
34 unsigned int txsize = priv->dma_tx_size; 34 unsigned int txsize = priv->dma_tx_size;
35 unsigned int entry = priv->cur_tx % txsize; 35 unsigned int entry = priv->cur_tx % txsize;
36 struct dma_desc *desc = priv->dma_tx + entry; 36 struct dma_desc *desc;
37 unsigned int nopaged_len = skb_headlen(skb); 37 unsigned int nopaged_len = skb_headlen(skb);
38 unsigned int bmax, len; 38 unsigned int bmax, len;
39 39
40 if (priv->extend_desc)
41 desc = (struct dma_desc *)(priv->dma_etx + entry);
42 else
43 desc = priv->dma_tx + entry;
44
40 if (priv->plat->enh_desc) 45 if (priv->plat->enh_desc)
41 bmax = BUF_SIZE_8KiB; 46 bmax = BUF_SIZE_8KiB;
42 else 47 else
@@ -54,7 +59,11 @@ static unsigned int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum)
54 STMMAC_RING_MODE); 59 STMMAC_RING_MODE);
55 wmb(); 60 wmb();
56 entry = (++priv->cur_tx) % txsize; 61 entry = (++priv->cur_tx) % txsize;
57 desc = priv->dma_tx + entry; 62
63 if (priv->extend_desc)
64 desc = (struct dma_desc *)(priv->dma_etx + entry);
65 else
66 desc = priv->dma_tx + entry;
58 67
59 desc->des2 = dma_map_single(priv->device, skb->data + bmax, 68 desc->des2 = dma_map_single(priv->device, skb->data + bmax,
60 len, DMA_TO_DEVICE); 69 len, DMA_TO_DEVICE);
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index f2ccb36e8685..0a9bb9d30c3f 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -939,15 +939,20 @@ static int stmmac_init_rx_buffers(struct stmmac_priv *priv, struct dma_desc *p,
939 939
940 skb = __netdev_alloc_skb(priv->dev, priv->dma_buf_sz + NET_IP_ALIGN, 940 skb = __netdev_alloc_skb(priv->dev, priv->dma_buf_sz + NET_IP_ALIGN,
941 GFP_KERNEL); 941 GFP_KERNEL);
942 if (unlikely(skb == NULL)) { 942 if (!skb) {
943 pr_err("%s: Rx init fails; skb is NULL\n", __func__); 943 pr_err("%s: Rx init fails; skb is NULL\n", __func__);
944 return 1; 944 return -ENOMEM;
945 } 945 }
946 skb_reserve(skb, NET_IP_ALIGN); 946 skb_reserve(skb, NET_IP_ALIGN);
947 priv->rx_skbuff[i] = skb; 947 priv->rx_skbuff[i] = skb;
948 priv->rx_skbuff_dma[i] = dma_map_single(priv->device, skb->data, 948 priv->rx_skbuff_dma[i] = dma_map_single(priv->device, skb->data,
949 priv->dma_buf_sz, 949 priv->dma_buf_sz,
950 DMA_FROM_DEVICE); 950 DMA_FROM_DEVICE);
951 if (dma_mapping_error(priv->device, priv->rx_skbuff_dma[i])) {
952 pr_err("%s: DMA mapping error\n", __func__);
953 dev_kfree_skb_any(skb);
954 return -EINVAL;
955 }
951 956
952 p->des2 = priv->rx_skbuff_dma[i]; 957 p->des2 = priv->rx_skbuff_dma[i];
953 958
@@ -958,6 +963,16 @@ static int stmmac_init_rx_buffers(struct stmmac_priv *priv, struct dma_desc *p,
958 return 0; 963 return 0;
959} 964}
960 965
966static void stmmac_free_rx_buffers(struct stmmac_priv *priv, int i)
967{
968 if (priv->rx_skbuff[i]) {
969 dma_unmap_single(priv->device, priv->rx_skbuff_dma[i],
970 priv->dma_buf_sz, DMA_FROM_DEVICE);
971 dev_kfree_skb_any(priv->rx_skbuff[i]);
972 }
973 priv->rx_skbuff[i] = NULL;
974}
975
961/** 976/**
962 * init_dma_desc_rings - init the RX/TX descriptor rings 977 * init_dma_desc_rings - init the RX/TX descriptor rings
963 * @dev: net device structure 978 * @dev: net device structure
@@ -965,13 +980,14 @@ static int stmmac_init_rx_buffers(struct stmmac_priv *priv, struct dma_desc *p,
965 * and allocates the socket buffers. It suppors the chained and ring 980 * and allocates the socket buffers. It suppors the chained and ring
966 * modes. 981 * modes.
967 */ 982 */
968static void init_dma_desc_rings(struct net_device *dev) 983static int init_dma_desc_rings(struct net_device *dev)
969{ 984{
970 int i; 985 int i;
971 struct stmmac_priv *priv = netdev_priv(dev); 986 struct stmmac_priv *priv = netdev_priv(dev);
972 unsigned int txsize = priv->dma_tx_size; 987 unsigned int txsize = priv->dma_tx_size;
973 unsigned int rxsize = priv->dma_rx_size; 988 unsigned int rxsize = priv->dma_rx_size;
974 unsigned int bfsize = 0; 989 unsigned int bfsize = 0;
990 int ret = -ENOMEM;
975 991
976 /* Set the max buffer size according to the DESC mode 992 /* Set the max buffer size according to the DESC mode
977 * and the MTU. Note that RING mode allows 16KiB bsize. 993 * and the MTU. Note that RING mode allows 16KiB bsize.
@@ -992,34 +1008,60 @@ static void init_dma_desc_rings(struct net_device *dev)
992 dma_extended_desc), 1008 dma_extended_desc),
993 &priv->dma_rx_phy, 1009 &priv->dma_rx_phy,
994 GFP_KERNEL); 1010 GFP_KERNEL);
1011 if (!priv->dma_erx)
1012 goto err_dma;
1013
995 priv->dma_etx = dma_alloc_coherent(priv->device, txsize * 1014 priv->dma_etx = dma_alloc_coherent(priv->device, txsize *
996 sizeof(struct 1015 sizeof(struct
997 dma_extended_desc), 1016 dma_extended_desc),
998 &priv->dma_tx_phy, 1017 &priv->dma_tx_phy,
999 GFP_KERNEL); 1018 GFP_KERNEL);
1000 if ((!priv->dma_erx) || (!priv->dma_etx)) 1019 if (!priv->dma_etx) {
1001 return; 1020 dma_free_coherent(priv->device, priv->dma_rx_size *
1021 sizeof(struct dma_extended_desc),
1022 priv->dma_erx, priv->dma_rx_phy);
1023 goto err_dma;
1024 }
1002 } else { 1025 } else {
1003 priv->dma_rx = dma_alloc_coherent(priv->device, rxsize * 1026 priv->dma_rx = dma_alloc_coherent(priv->device, rxsize *
1004 sizeof(struct dma_desc), 1027 sizeof(struct dma_desc),
1005 &priv->dma_rx_phy, 1028 &priv->dma_rx_phy,
1006 GFP_KERNEL); 1029 GFP_KERNEL);
1030 if (!priv->dma_rx)
1031 goto err_dma;
1032
1007 priv->dma_tx = dma_alloc_coherent(priv->device, txsize * 1033 priv->dma_tx = dma_alloc_coherent(priv->device, txsize *
1008 sizeof(struct dma_desc), 1034 sizeof(struct dma_desc),
1009 &priv->dma_tx_phy, 1035 &priv->dma_tx_phy,
1010 GFP_KERNEL); 1036 GFP_KERNEL);
1011 if ((!priv->dma_rx) || (!priv->dma_tx)) 1037 if (!priv->dma_tx) {
1012 return; 1038 dma_free_coherent(priv->device, priv->dma_rx_size *
1039 sizeof(struct dma_desc),
1040 priv->dma_rx, priv->dma_rx_phy);
1041 goto err_dma;
1042 }
1013 } 1043 }
1014 1044
1015 priv->rx_skbuff_dma = kmalloc_array(rxsize, sizeof(dma_addr_t), 1045 priv->rx_skbuff_dma = kmalloc_array(rxsize, sizeof(dma_addr_t),
1016 GFP_KERNEL); 1046 GFP_KERNEL);
1047 if (!priv->rx_skbuff_dma)
1048 goto err_rx_skbuff_dma;
1049
1017 priv->rx_skbuff = kmalloc_array(rxsize, sizeof(struct sk_buff *), 1050 priv->rx_skbuff = kmalloc_array(rxsize, sizeof(struct sk_buff *),
1018 GFP_KERNEL); 1051 GFP_KERNEL);
1052 if (!priv->rx_skbuff)
1053 goto err_rx_skbuff;
1054
1019 priv->tx_skbuff_dma = kmalloc_array(txsize, sizeof(dma_addr_t), 1055 priv->tx_skbuff_dma = kmalloc_array(txsize, sizeof(dma_addr_t),
1020 GFP_KERNEL); 1056 GFP_KERNEL);
1057 if (!priv->tx_skbuff_dma)
1058 goto err_tx_skbuff_dma;
1059
1021 priv->tx_skbuff = kmalloc_array(txsize, sizeof(struct sk_buff *), 1060 priv->tx_skbuff = kmalloc_array(txsize, sizeof(struct sk_buff *),
1022 GFP_KERNEL); 1061 GFP_KERNEL);
1062 if (!priv->tx_skbuff)
1063 goto err_tx_skbuff;
1064
1023 if (netif_msg_probe(priv)) { 1065 if (netif_msg_probe(priv)) {
1024 pr_debug("(%s) dma_rx_phy=0x%08x dma_tx_phy=0x%08x\n", __func__, 1066 pr_debug("(%s) dma_rx_phy=0x%08x dma_tx_phy=0x%08x\n", __func__,
1025 (u32) priv->dma_rx_phy, (u32) priv->dma_tx_phy); 1067 (u32) priv->dma_rx_phy, (u32) priv->dma_tx_phy);
@@ -1034,8 +1076,9 @@ static void init_dma_desc_rings(struct net_device *dev)
1034 else 1076 else
1035 p = priv->dma_rx + i; 1077 p = priv->dma_rx + i;
1036 1078
1037 if (stmmac_init_rx_buffers(priv, p, i)) 1079 ret = stmmac_init_rx_buffers(priv, p, i);
1038 break; 1080 if (ret)
1081 goto err_init_rx_buffers;
1039 1082
1040 if (netif_msg_probe(priv)) 1083 if (netif_msg_probe(priv))
1041 pr_debug("[%p]\t[%p]\t[%x]\n", priv->rx_skbuff[i], 1084 pr_debug("[%p]\t[%p]\t[%x]\n", priv->rx_skbuff[i],
@@ -1081,20 +1124,44 @@ static void init_dma_desc_rings(struct net_device *dev)
1081 1124
1082 if (netif_msg_hw(priv)) 1125 if (netif_msg_hw(priv))
1083 stmmac_display_rings(priv); 1126 stmmac_display_rings(priv);
1127
1128 return 0;
1129err_init_rx_buffers:
1130 while (--i >= 0)
1131 stmmac_free_rx_buffers(priv, i);
1132 kfree(priv->tx_skbuff);
1133err_tx_skbuff:
1134 kfree(priv->tx_skbuff_dma);
1135err_tx_skbuff_dma:
1136 kfree(priv->rx_skbuff);
1137err_rx_skbuff:
1138 kfree(priv->rx_skbuff_dma);
1139err_rx_skbuff_dma:
1140 if (priv->extend_desc) {
1141 dma_free_coherent(priv->device, priv->dma_tx_size *
1142 sizeof(struct dma_extended_desc),
1143 priv->dma_etx, priv->dma_tx_phy);
1144 dma_free_coherent(priv->device, priv->dma_rx_size *
1145 sizeof(struct dma_extended_desc),
1146 priv->dma_erx, priv->dma_rx_phy);
1147 } else {
1148 dma_free_coherent(priv->device,
1149 priv->dma_tx_size * sizeof(struct dma_desc),
1150 priv->dma_tx, priv->dma_tx_phy);
1151 dma_free_coherent(priv->device,
1152 priv->dma_rx_size * sizeof(struct dma_desc),
1153 priv->dma_rx, priv->dma_rx_phy);
1154 }
1155err_dma:
1156 return ret;
1084} 1157}
1085 1158
1086static void dma_free_rx_skbufs(struct stmmac_priv *priv) 1159static void dma_free_rx_skbufs(struct stmmac_priv *priv)
1087{ 1160{
1088 int i; 1161 int i;
1089 1162
1090 for (i = 0; i < priv->dma_rx_size; i++) { 1163 for (i = 0; i < priv->dma_rx_size; i++)
1091 if (priv->rx_skbuff[i]) { 1164 stmmac_free_rx_buffers(priv, i);
1092 dma_unmap_single(priv->device, priv->rx_skbuff_dma[i],
1093 priv->dma_buf_sz, DMA_FROM_DEVICE);
1094 dev_kfree_skb_any(priv->rx_skbuff[i]);
1095 }
1096 priv->rx_skbuff[i] = NULL;
1097 }
1098} 1165}
1099 1166
1100static void dma_free_tx_skbufs(struct stmmac_priv *priv) 1167static void dma_free_tx_skbufs(struct stmmac_priv *priv)
@@ -1560,12 +1627,17 @@ static int stmmac_open(struct net_device *dev)
1560 priv->dma_tx_size = STMMAC_ALIGN(dma_txsize); 1627 priv->dma_tx_size = STMMAC_ALIGN(dma_txsize);
1561 priv->dma_rx_size = STMMAC_ALIGN(dma_rxsize); 1628 priv->dma_rx_size = STMMAC_ALIGN(dma_rxsize);
1562 priv->dma_buf_sz = STMMAC_ALIGN(buf_sz); 1629 priv->dma_buf_sz = STMMAC_ALIGN(buf_sz);
1563 init_dma_desc_rings(dev); 1630
1631 ret = init_dma_desc_rings(dev);
1632 if (ret < 0) {
1633 pr_err("%s: DMA descriptors initialization failed\n", __func__);
1634 goto dma_desc_error;
1635 }
1564 1636
1565 /* DMA initialization and SW reset */ 1637 /* DMA initialization and SW reset */
1566 ret = stmmac_init_dma_engine(priv); 1638 ret = stmmac_init_dma_engine(priv);
1567 if (ret < 0) { 1639 if (ret < 0) {
1568 pr_err("%s: DMA initialization failed\n", __func__); 1640 pr_err("%s: DMA engine initialization failed\n", __func__);
1569 goto init_error; 1641 goto init_error;
1570 } 1642 }
1571 1643
@@ -1672,6 +1744,7 @@ wolirq_error:
1672 1744
1673init_error: 1745init_error:
1674 free_dma_desc_resources(priv); 1746 free_dma_desc_resources(priv);
1747dma_desc_error:
1675 if (priv->phydev) 1748 if (priv->phydev)
1676 phy_disconnect(priv->phydev); 1749 phy_disconnect(priv->phydev);
1677phy_error: 1750phy_error:
diff --git a/drivers/net/ethernet/via/via-velocity.c b/drivers/net/ethernet/via/via-velocity.c
index 1d6dc41f755d..d01cacf8a7c2 100644
--- a/drivers/net/ethernet/via/via-velocity.c
+++ b/drivers/net/ethernet/via/via-velocity.c
@@ -2100,7 +2100,7 @@ static int velocity_receive_frame(struct velocity_info *vptr, int idx)
2100 2100
2101 __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), vid); 2101 __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), vid);
2102 } 2102 }
2103 netif_rx(skb); 2103 netif_receive_skb(skb);
2104 2104
2105 stats->rx_bytes += pkt_len; 2105 stats->rx_bytes += pkt_len;
2106 stats->rx_packets++; 2106 stats->rx_packets++;
@@ -2884,6 +2884,7 @@ out:
2884 return ret; 2884 return ret;
2885 2885
2886err_iounmap: 2886err_iounmap:
2887 netif_napi_del(&vptr->napi);
2887 iounmap(regs); 2888 iounmap(regs);
2888err_free_dev: 2889err_free_dev:
2889 free_netdev(netdev); 2890 free_netdev(netdev);
@@ -2904,6 +2905,7 @@ static int velocity_remove(struct device *dev)
2904 struct velocity_info *vptr = netdev_priv(netdev); 2905 struct velocity_info *vptr = netdev_priv(netdev);
2905 2906
2906 unregister_netdev(netdev); 2907 unregister_netdev(netdev);
2908 netif_napi_del(&vptr->napi);
2907 iounmap(vptr->mac_regs); 2909 iounmap(vptr->mac_regs);
2908 free_netdev(netdev); 2910 free_netdev(netdev);
2909 velocity_nics--; 2911 velocity_nics--;
diff --git a/drivers/net/irda/via-ircc.c b/drivers/net/irda/via-ircc.c
index 51f2bc376101..2dcc60fb37f1 100644
--- a/drivers/net/irda/via-ircc.c
+++ b/drivers/net/irda/via-ircc.c
@@ -210,8 +210,7 @@ static int via_init_one(struct pci_dev *pcidev, const struct pci_device_id *id)
210 pci_write_config_byte(pcidev,0x42,(bTmp | 0xf0)); 210 pci_write_config_byte(pcidev,0x42,(bTmp | 0xf0));
211 pci_write_config_byte(pcidev,0x5a,0xc0); 211 pci_write_config_byte(pcidev,0x5a,0xc0);
212 WriteLPCReg(0x28, 0x70 ); 212 WriteLPCReg(0x28, 0x70 );
213 if (via_ircc_open(pcidev, &info, 0x3076) == 0) 213 rc = via_ircc_open(pcidev, &info, 0x3076);
214 rc=0;
215 } else 214 } else
216 rc = -ENODEV; //IR not turn on 215 rc = -ENODEV; //IR not turn on
217 } else { //Not VT1211 216 } else { //Not VT1211
@@ -249,8 +248,7 @@ static int via_init_one(struct pci_dev *pcidev, const struct pci_device_id *id)
249 info.irq=FirIRQ; 248 info.irq=FirIRQ;
250 info.dma=FirDRQ1; 249 info.dma=FirDRQ1;
251 info.dma2=FirDRQ0; 250 info.dma2=FirDRQ0;
252 if (via_ircc_open(pcidev, &info, 0x3096) == 0) 251 rc = via_ircc_open(pcidev, &info, 0x3096);
253 rc=0;
254 } else 252 } else
255 rc = -ENODEV; //IR not turn on !!!!! 253 rc = -ENODEV; //IR not turn on !!!!!
256 }//Not VT1211 254 }//Not VT1211
diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index d0f9c2fd1d4f..16b43bf544b7 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -739,6 +739,10 @@ static int macvlan_validate(struct nlattr *tb[], struct nlattr *data[])
739 return -EADDRNOTAVAIL; 739 return -EADDRNOTAVAIL;
740 } 740 }
741 741
742 if (data && data[IFLA_MACVLAN_FLAGS] &&
743 nla_get_u16(data[IFLA_MACVLAN_FLAGS]) & ~MACVLAN_FLAG_NOPROMISC)
744 return -EINVAL;
745
742 if (data && data[IFLA_MACVLAN_MODE]) { 746 if (data && data[IFLA_MACVLAN_MODE]) {
743 switch (nla_get_u32(data[IFLA_MACVLAN_MODE])) { 747 switch (nla_get_u32(data[IFLA_MACVLAN_MODE])) {
744 case MACVLAN_MODE_PRIVATE: 748 case MACVLAN_MODE_PRIVATE:
diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
index a98fb0ed6aef..ea53abb20988 100644
--- a/drivers/net/macvtap.c
+++ b/drivers/net/macvtap.c
@@ -68,6 +68,8 @@ static const struct proto_ops macvtap_socket_ops;
68#define TUN_OFFLOADS (NETIF_F_HW_CSUM | NETIF_F_TSO_ECN | NETIF_F_TSO | \ 68#define TUN_OFFLOADS (NETIF_F_HW_CSUM | NETIF_F_TSO_ECN | NETIF_F_TSO | \
69 NETIF_F_TSO6 | NETIF_F_UFO) 69 NETIF_F_TSO6 | NETIF_F_UFO)
70#define RX_OFFLOADS (NETIF_F_GRO | NETIF_F_LRO) 70#define RX_OFFLOADS (NETIF_F_GRO | NETIF_F_LRO)
71#define TAP_FEATURES (NETIF_F_GSO | NETIF_F_SG)
72
71/* 73/*
72 * RCU usage: 74 * RCU usage:
73 * The macvtap_queue and the macvlan_dev are loosely coupled, the 75 * The macvtap_queue and the macvlan_dev are loosely coupled, the
@@ -278,7 +280,8 @@ static int macvtap_forward(struct net_device *dev, struct sk_buff *skb)
278{ 280{
279 struct macvlan_dev *vlan = netdev_priv(dev); 281 struct macvlan_dev *vlan = netdev_priv(dev);
280 struct macvtap_queue *q = macvtap_get_queue(dev, skb); 282 struct macvtap_queue *q = macvtap_get_queue(dev, skb);
281 netdev_features_t features; 283 netdev_features_t features = TAP_FEATURES;
284
282 if (!q) 285 if (!q)
283 goto drop; 286 goto drop;
284 287
@@ -287,9 +290,11 @@ static int macvtap_forward(struct net_device *dev, struct sk_buff *skb)
287 290
288 skb->dev = dev; 291 skb->dev = dev;
289 /* Apply the forward feature mask so that we perform segmentation 292 /* Apply the forward feature mask so that we perform segmentation
290 * according to users wishes. 293 * according to users wishes. This only works if VNET_HDR is
294 * enabled.
291 */ 295 */
292 features = netif_skb_features(skb) & vlan->tap_features; 296 if (q->flags & IFF_VNET_HDR)
297 features |= vlan->tap_features;
293 if (netif_needs_gso(skb, features)) { 298 if (netif_needs_gso(skb, features)) {
294 struct sk_buff *segs = __skb_gso_segment(skb, features, false); 299 struct sk_buff *segs = __skb_gso_segment(skb, features, false);
295 300
@@ -818,10 +823,13 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m,
818 skb_shinfo(skb)->tx_flags |= SKBTX_DEV_ZEROCOPY; 823 skb_shinfo(skb)->tx_flags |= SKBTX_DEV_ZEROCOPY;
819 skb_shinfo(skb)->tx_flags |= SKBTX_SHARED_FRAG; 824 skb_shinfo(skb)->tx_flags |= SKBTX_SHARED_FRAG;
820 } 825 }
821 if (vlan) 826 if (vlan) {
827 local_bh_disable();
822 macvlan_start_xmit(skb, vlan->dev); 828 macvlan_start_xmit(skb, vlan->dev);
823 else 829 local_bh_enable();
830 } else {
824 kfree_skb(skb); 831 kfree_skb(skb);
832 }
825 rcu_read_unlock(); 833 rcu_read_unlock();
826 834
827 return total_len; 835 return total_len;
@@ -912,8 +920,11 @@ static ssize_t macvtap_put_user(struct macvtap_queue *q,
912done: 920done:
913 rcu_read_lock(); 921 rcu_read_lock();
914 vlan = rcu_dereference(q->vlan); 922 vlan = rcu_dereference(q->vlan);
915 if (vlan) 923 if (vlan) {
924 preempt_disable();
916 macvlan_count_rx(vlan, copied - vnet_hdr_len, ret == 0, 0); 925 macvlan_count_rx(vlan, copied - vnet_hdr_len, ret == 0, 0);
926 preempt_enable();
927 }
917 rcu_read_unlock(); 928 rcu_read_unlock();
918 929
919 return ret ? ret : copied; 930 return ret ? ret : copied;
@@ -1058,8 +1069,7 @@ static int set_offload(struct macvtap_queue *q, unsigned long arg)
1058 /* tap_features are the same as features on tun/tap and 1069 /* tap_features are the same as features on tun/tap and
1059 * reflect user expectations. 1070 * reflect user expectations.
1060 */ 1071 */
1061 vlan->tap_features = vlan->dev->features & 1072 vlan->tap_features = feature_mask;
1062 (feature_mask | ~TUN_OFFLOADS);
1063 vlan->set_features = features; 1073 vlan->set_features = features;
1064 netdev_update_features(vlan->dev); 1074 netdev_update_features(vlan->dev);
1065 1075
@@ -1155,10 +1165,6 @@ static long macvtap_ioctl(struct file *file, unsigned int cmd,
1155 TUN_F_TSO_ECN | TUN_F_UFO)) 1165 TUN_F_TSO_ECN | TUN_F_UFO))
1156 return -EINVAL; 1166 return -EINVAL;
1157 1167
1158 /* TODO: only accept frames with the features that
1159 got enabled for forwarded frames */
1160 if (!(q->flags & IFF_VNET_HDR))
1161 return -EINVAL;
1162 rtnl_lock(); 1168 rtnl_lock();
1163 ret = set_offload(q, arg); 1169 ret = set_offload(q, arg);
1164 rtnl_unlock(); 1170 rtnl_unlock();
diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c
index 8e7af8354342..138de837977f 100644
--- a/drivers/net/phy/realtek.c
+++ b/drivers/net/phy/realtek.c
@@ -23,7 +23,7 @@
23#define RTL821x_INER_INIT 0x6400 23#define RTL821x_INER_INIT 0x6400
24#define RTL821x_INSR 0x13 24#define RTL821x_INSR 0x13
25 25
26#define RTL8211E_INER_LINK_STAT 0x10 26#define RTL8211E_INER_LINK_STATUS 0x400
27 27
28MODULE_DESCRIPTION("Realtek PHY driver"); 28MODULE_DESCRIPTION("Realtek PHY driver");
29MODULE_AUTHOR("Johnson Leung"); 29MODULE_AUTHOR("Johnson Leung");
@@ -57,7 +57,7 @@ static int rtl8211e_config_intr(struct phy_device *phydev)
57 57
58 if (phydev->interrupts == PHY_INTERRUPT_ENABLED) 58 if (phydev->interrupts == PHY_INTERRUPT_ENABLED)
59 err = phy_write(phydev, RTL821x_INER, 59 err = phy_write(phydev, RTL821x_INER,
60 RTL8211E_INER_LINK_STAT); 60 RTL8211E_INER_LINK_STATUS);
61 else 61 else
62 err = phy_write(phydev, RTL821x_INER, 0); 62 err = phy_write(phydev, RTL821x_INER, 0);
63 63
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index db690a372260..71af122edf2d 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -1074,8 +1074,9 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
1074 u32 rxhash; 1074 u32 rxhash;
1075 1075
1076 if (!(tun->flags & TUN_NO_PI)) { 1076 if (!(tun->flags & TUN_NO_PI)) {
1077 if ((len -= sizeof(pi)) > total_len) 1077 if (len < sizeof(pi))
1078 return -EINVAL; 1078 return -EINVAL;
1079 len -= sizeof(pi);
1079 1080
1080 if (memcpy_fromiovecend((void *)&pi, iv, 0, sizeof(pi))) 1081 if (memcpy_fromiovecend((void *)&pi, iv, 0, sizeof(pi)))
1081 return -EFAULT; 1082 return -EFAULT;
@@ -1083,8 +1084,9 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
1083 } 1084 }
1084 1085
1085 if (tun->flags & TUN_VNET_HDR) { 1086 if (tun->flags & TUN_VNET_HDR) {
1086 if ((len -= tun->vnet_hdr_sz) > total_len) 1087 if (len < tun->vnet_hdr_sz)
1087 return -EINVAL; 1088 return -EINVAL;
1089 len -= tun->vnet_hdr_sz;
1088 1090
1089 if (memcpy_fromiovecend((void *)&gso, iv, offset, sizeof(gso))) 1091 if (memcpy_fromiovecend((void *)&gso, iv, offset, sizeof(gso)))
1090 return -EFAULT; 1092 return -EFAULT;
diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
index cba1d46e672e..86292e6aaf49 100644
--- a/drivers/net/usb/hso.c
+++ b/drivers/net/usb/hso.c
@@ -2816,13 +2816,16 @@ exit:
2816static int hso_get_config_data(struct usb_interface *interface) 2816static int hso_get_config_data(struct usb_interface *interface)
2817{ 2817{
2818 struct usb_device *usbdev = interface_to_usbdev(interface); 2818 struct usb_device *usbdev = interface_to_usbdev(interface);
2819 u8 config_data[17]; 2819 u8 *config_data = kmalloc(17, GFP_KERNEL);
2820 u32 if_num = interface->altsetting->desc.bInterfaceNumber; 2820 u32 if_num = interface->altsetting->desc.bInterfaceNumber;
2821 s32 result; 2821 s32 result;
2822 2822
2823 if (!config_data)
2824 return -ENOMEM;
2823 if (usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0), 2825 if (usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0),
2824 0x86, 0xC0, 0, 0, config_data, 17, 2826 0x86, 0xC0, 0, 0, config_data, 17,
2825 USB_CTRL_SET_TIMEOUT) != 0x11) { 2827 USB_CTRL_SET_TIMEOUT) != 0x11) {
2828 kfree(config_data);
2826 return -EIO; 2829 return -EIO;
2827 } 2830 }
2828 2831
@@ -2873,6 +2876,7 @@ static int hso_get_config_data(struct usb_interface *interface)
2873 if (config_data[16] & 0x1) 2876 if (config_data[16] & 0x1)
2874 result |= HSO_INFO_CRC_BUG; 2877 result |= HSO_INFO_CRC_BUG;
2875 2878
2879 kfree(config_data);
2876 return result; 2880 return result;
2877} 2881}
2878 2882
@@ -2886,6 +2890,11 @@ static int hso_probe(struct usb_interface *interface,
2886 struct hso_shared_int *shared_int; 2890 struct hso_shared_int *shared_int;
2887 struct hso_device *tmp_dev = NULL; 2891 struct hso_device *tmp_dev = NULL;
2888 2892
2893 if (interface->cur_altsetting->desc.bInterfaceClass != 0xFF) {
2894 dev_err(&interface->dev, "Not our interface\n");
2895 return -ENODEV;
2896 }
2897
2889 if_num = interface->altsetting->desc.bInterfaceNumber; 2898 if_num = interface->altsetting->desc.bInterfaceNumber;
2890 2899
2891 /* Get the interface/port specification from either driver_info or from 2900 /* Get the interface/port specification from either driver_info or from
@@ -2895,10 +2904,6 @@ static int hso_probe(struct usb_interface *interface,
2895 else 2904 else
2896 port_spec = hso_get_config_data(interface); 2905 port_spec = hso_get_config_data(interface);
2897 2906
2898 if (interface->cur_altsetting->desc.bInterfaceClass != 0xFF) {
2899 dev_err(&interface->dev, "Not our interface\n");
2900 return -ENODEV;
2901 }
2902 /* Check if we need to switch to alt interfaces prior to port 2907 /* Check if we need to switch to alt interfaces prior to port
2903 * configuration */ 2908 * configuration */
2904 if (interface->num_altsetting > 1) 2909 if (interface->num_altsetting > 1)
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index f4c6db419ddb..767f7af3bd40 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -1386,7 +1386,7 @@ static int vxlan_open(struct net_device *dev)
1386 return -ENOTCONN; 1386 return -ENOTCONN;
1387 1387
1388 if (IN_MULTICAST(ntohl(vxlan->default_dst.remote_ip)) && 1388 if (IN_MULTICAST(ntohl(vxlan->default_dst.remote_ip)) &&
1389 ! vxlan_group_used(vn, vxlan->default_dst.remote_ip)) { 1389 vxlan_group_used(vn, vxlan->default_dst.remote_ip)) {
1390 vxlan_sock_hold(vs); 1390 vxlan_sock_hold(vs);
1391 dev_hold(dev); 1391 dev_hold(dev);
1392 queue_work(vxlan_wq, &vxlan->igmp_join); 1392 queue_work(vxlan_wq, &vxlan->igmp_join);
@@ -1793,8 +1793,6 @@ static void vxlan_dellink(struct net_device *dev, struct list_head *head)
1793 struct vxlan_net *vn = net_generic(dev_net(dev), vxlan_net_id); 1793 struct vxlan_net *vn = net_generic(dev_net(dev), vxlan_net_id);
1794 struct vxlan_dev *vxlan = netdev_priv(dev); 1794 struct vxlan_dev *vxlan = netdev_priv(dev);
1795 1795
1796 flush_workqueue(vxlan_wq);
1797
1798 spin_lock(&vn->sock_lock); 1796 spin_lock(&vn->sock_lock);
1799 hlist_del_rcu(&vxlan->hlist); 1797 hlist_del_rcu(&vxlan->hlist);
1800 spin_unlock(&vn->sock_lock); 1798 spin_unlock(&vn->sock_lock);
diff --git a/drivers/net/wireless/cw1200/sta.c b/drivers/net/wireless/cw1200/sta.c
index 7365674366f4..010b252be584 100644
--- a/drivers/net/wireless/cw1200/sta.c
+++ b/drivers/net/wireless/cw1200/sta.c
@@ -1406,11 +1406,8 @@ static void cw1200_do_unjoin(struct cw1200_common *priv)
1406 if (!priv->join_status) 1406 if (!priv->join_status)
1407 goto done; 1407 goto done;
1408 1408
1409 if (priv->join_status > CW1200_JOIN_STATUS_IBSS) { 1409 if (priv->join_status == CW1200_JOIN_STATUS_AP)
1410 wiphy_err(priv->hw->wiphy, "Unexpected: join status: %d\n", 1410 goto done;
1411 priv->join_status);
1412 BUG_ON(1);
1413 }
1414 1411
1415 cancel_work_sync(&priv->update_filtering_work); 1412 cancel_work_sync(&priv->update_filtering_work);
1416 cancel_work_sync(&priv->set_beacon_wakeup_period_work); 1413 cancel_work_sync(&priv->set_beacon_wakeup_period_work);
diff --git a/drivers/net/wireless/hostap/hostap_ioctl.c b/drivers/net/wireless/hostap/hostap_ioctl.c
index ac074731335a..e5090309824e 100644
--- a/drivers/net/wireless/hostap/hostap_ioctl.c
+++ b/drivers/net/wireless/hostap/hostap_ioctl.c
@@ -523,9 +523,9 @@ static int prism2_ioctl_giwaplist(struct net_device *dev,
523 523
524 data->length = prism2_ap_get_sta_qual(local, addr, qual, IW_MAX_AP, 1); 524 data->length = prism2_ap_get_sta_qual(local, addr, qual, IW_MAX_AP, 1);
525 525
526 memcpy(extra, &addr, sizeof(struct sockaddr) * data->length); 526 memcpy(extra, addr, sizeof(struct sockaddr) * data->length);
527 data->flags = 1; /* has quality information */ 527 data->flags = 1; /* has quality information */
528 memcpy(extra + sizeof(struct sockaddr) * data->length, &qual, 528 memcpy(extra + sizeof(struct sockaddr) * data->length, qual,
529 sizeof(struct iw_quality) * data->length); 529 sizeof(struct iw_quality) * data->length);
530 530
531 kfree(addr); 531 kfree(addr);
diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c
index b9b2bb51e605..f2ed62e37340 100644
--- a/drivers/net/wireless/iwlegacy/4965-mac.c
+++ b/drivers/net/wireless/iwlegacy/4965-mac.c
@@ -4460,12 +4460,12 @@ il4965_irq_tasklet(struct il_priv *il)
4460 * is killed. Hence update the killswitch state here. The 4460 * is killed. Hence update the killswitch state here. The
4461 * rfkill handler will care about restarting if needed. 4461 * rfkill handler will care about restarting if needed.
4462 */ 4462 */
4463 if (!test_bit(S_ALIVE, &il->status)) { 4463 if (hw_rf_kill) {
4464 if (hw_rf_kill) 4464 set_bit(S_RFKILL, &il->status);
4465 set_bit(S_RFKILL, &il->status); 4465 } else {
4466 else 4466 clear_bit(S_RFKILL, &il->status);
4467 clear_bit(S_RFKILL, &il->status);
4468 wiphy_rfkill_set_hw_state(il->hw->wiphy, hw_rf_kill); 4467 wiphy_rfkill_set_hw_state(il->hw->wiphy, hw_rf_kill);
4468 il_force_reset(il, true);
4469 } 4469 }
4470 4470
4471 handled |= CSR_INT_BIT_RF_KILL; 4471 handled |= CSR_INT_BIT_RF_KILL;
@@ -5334,6 +5334,9 @@ il4965_alive_start(struct il_priv *il)
5334 5334
5335 il->active_rate = RATES_MASK; 5335 il->active_rate = RATES_MASK;
5336 5336
5337 il_power_update_mode(il, true);
5338 D_INFO("Updated power mode\n");
5339
5337 if (il_is_associated(il)) { 5340 if (il_is_associated(il)) {
5338 struct il_rxon_cmd *active_rxon = 5341 struct il_rxon_cmd *active_rxon =
5339 (struct il_rxon_cmd *)&il->active; 5342 (struct il_rxon_cmd *)&il->active;
@@ -5364,9 +5367,6 @@ il4965_alive_start(struct il_priv *il)
5364 D_INFO("ALIVE processing complete.\n"); 5367 D_INFO("ALIVE processing complete.\n");
5365 wake_up(&il->wait_command_queue); 5368 wake_up(&il->wait_command_queue);
5366 5369
5367 il_power_update_mode(il, true);
5368 D_INFO("Updated power mode\n");
5369
5370 return; 5370 return;
5371 5371
5372restart: 5372restart:
diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c
index 3195aad440dd..b03e22ef5462 100644
--- a/drivers/net/wireless/iwlegacy/common.c
+++ b/drivers/net/wireless/iwlegacy/common.c
@@ -4660,6 +4660,7 @@ il_force_reset(struct il_priv *il, bool external)
4660 4660
4661 return 0; 4661 return 0;
4662} 4662}
4663EXPORT_SYMBOL(il_force_reset);
4663 4664
4664int 4665int
4665il_mac_change_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif, 4666il_mac_change_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
diff --git a/drivers/net/wireless/iwlwifi/dvm/mac80211.c b/drivers/net/wireless/iwlwifi/dvm/mac80211.c
index 822f1a00efbb..319387263e12 100644
--- a/drivers/net/wireless/iwlwifi/dvm/mac80211.c
+++ b/drivers/net/wireless/iwlwifi/dvm/mac80211.c
@@ -1068,7 +1068,10 @@ void iwl_chswitch_done(struct iwl_priv *priv, bool is_success)
1068 if (test_bit(STATUS_EXIT_PENDING, &priv->status)) 1068 if (test_bit(STATUS_EXIT_PENDING, &priv->status))
1069 return; 1069 return;
1070 1070
1071 if (test_and_clear_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->status)) 1071 if (!test_and_clear_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->status))
1072 return;
1073
1074 if (ctx->vif)
1072 ieee80211_chswitch_done(ctx->vif, is_success); 1075 ieee80211_chswitch_done(ctx->vif, is_success);
1073} 1076}
1074 1077
diff --git a/drivers/net/wireless/iwlwifi/iwl-prph.h b/drivers/net/wireless/iwlwifi/iwl-prph.h
index a70c7b9d9bad..ff8cc75c189d 100644
--- a/drivers/net/wireless/iwlwifi/iwl-prph.h
+++ b/drivers/net/wireless/iwlwifi/iwl-prph.h
@@ -97,8 +97,6 @@
97 97
98#define APMG_PCIDEV_STT_VAL_L1_ACT_DIS (0x00000800) 98#define APMG_PCIDEV_STT_VAL_L1_ACT_DIS (0x00000800)
99 99
100#define APMG_RTC_INT_STT_RFKILL (0x10000000)
101
102/* Device system time */ 100/* Device system time */
103#define DEVICE_SYSTEM_TIME_REG 0xA0206C 101#define DEVICE_SYSTEM_TIME_REG 0xA0206C
104 102
diff --git a/drivers/net/wireless/iwlwifi/mvm/time-event.c b/drivers/net/wireless/iwlwifi/mvm/time-event.c
index ad9bbca99213..7fd6fbfbc1b3 100644
--- a/drivers/net/wireless/iwlwifi/mvm/time-event.c
+++ b/drivers/net/wireless/iwlwifi/mvm/time-event.c
@@ -138,6 +138,20 @@ static void iwl_mvm_roc_finished(struct iwl_mvm *mvm)
138 schedule_work(&mvm->roc_done_wk); 138 schedule_work(&mvm->roc_done_wk);
139} 139}
140 140
141static bool iwl_mvm_te_check_disconnect(struct iwl_mvm *mvm,
142 struct ieee80211_vif *vif,
143 const char *errmsg)
144{
145 if (vif->type != NL80211_IFTYPE_STATION)
146 return false;
147 if (vif->bss_conf.assoc && vif->bss_conf.dtim_period)
148 return false;
149 if (errmsg)
150 IWL_ERR(mvm, "%s\n", errmsg);
151 ieee80211_connection_loss(vif);
152 return true;
153}
154
141/* 155/*
142 * Handles a FW notification for an event that is known to the driver. 156 * Handles a FW notification for an event that is known to the driver.
143 * 157 *
@@ -163,8 +177,13 @@ static void iwl_mvm_te_handle_notif(struct iwl_mvm *mvm,
163 * P2P Device discoveribility, while there are other higher priority 177 * P2P Device discoveribility, while there are other higher priority
164 * events in the system). 178 * events in the system).
165 */ 179 */
166 WARN_ONCE(!le32_to_cpu(notif->status), 180 if (WARN_ONCE(!le32_to_cpu(notif->status),
167 "Failed to schedule time event\n"); 181 "Failed to schedule time event\n")) {
182 if (iwl_mvm_te_check_disconnect(mvm, te_data->vif, NULL)) {
183 iwl_mvm_te_clear_data(mvm, te_data);
184 return;
185 }
186 }
168 187
169 if (le32_to_cpu(notif->action) & TE_NOTIF_HOST_EVENT_END) { 188 if (le32_to_cpu(notif->action) & TE_NOTIF_HOST_EVENT_END) {
170 IWL_DEBUG_TE(mvm, 189 IWL_DEBUG_TE(mvm,
@@ -180,14 +199,8 @@ static void iwl_mvm_te_handle_notif(struct iwl_mvm *mvm,
180 * By now, we should have finished association 199 * By now, we should have finished association
181 * and know the dtim period. 200 * and know the dtim period.
182 */ 201 */
183 if (te_data->vif->type == NL80211_IFTYPE_STATION && 202 iwl_mvm_te_check_disconnect(mvm, te_data->vif,
184 (!te_data->vif->bss_conf.assoc || 203 "No assocation and the time event is over already...");
185 !te_data->vif->bss_conf.dtim_period)) {
186 IWL_ERR(mvm,
187 "No assocation and the time event is over already...\n");
188 ieee80211_connection_loss(te_data->vif);
189 }
190
191 iwl_mvm_te_clear_data(mvm, te_data); 204 iwl_mvm_te_clear_data(mvm, te_data);
192 } else if (le32_to_cpu(notif->action) & TE_NOTIF_HOST_EVENT_START) { 205 } else if (le32_to_cpu(notif->action) & TE_NOTIF_HOST_EVENT_START) {
193 te_data->running = true; 206 te_data->running = true;
diff --git a/drivers/net/wireless/iwlwifi/pcie/rx.c b/drivers/net/wireless/iwlwifi/pcie/rx.c
index f600e68a410a..fd848cd1583e 100644
--- a/drivers/net/wireless/iwlwifi/pcie/rx.c
+++ b/drivers/net/wireless/iwlwifi/pcie/rx.c
@@ -888,14 +888,6 @@ irqreturn_t iwl_pcie_irq_handler(int irq, void *dev_id)
888 888
889 iwl_op_mode_hw_rf_kill(trans->op_mode, hw_rfkill); 889 iwl_op_mode_hw_rf_kill(trans->op_mode, hw_rfkill);
890 if (hw_rfkill) { 890 if (hw_rfkill) {
891 /*
892 * Clear the interrupt in APMG if the NIC is going down.
893 * Note that when the NIC exits RFkill (else branch), we
894 * can't access prph and the NIC will be reset in
895 * start_hw anyway.
896 */
897 iwl_write_prph(trans, APMG_RTC_INT_STT_REG,
898 APMG_RTC_INT_STT_RFKILL);
899 set_bit(STATUS_RFKILL, &trans_pcie->status); 891 set_bit(STATUS_RFKILL, &trans_pcie->status);
900 if (test_and_clear_bit(STATUS_HCMD_ACTIVE, 892 if (test_and_clear_bit(STATUS_HCMD_ACTIVE,
901 &trans_pcie->status)) 893 &trans_pcie->status))
diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
index 96cfcdd39079..390e2f058aff 100644
--- a/drivers/net/wireless/iwlwifi/pcie/trans.c
+++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
@@ -1502,16 +1502,16 @@ struct iwl_trans *iwl_trans_pcie_alloc(struct pci_dev *pdev,
1502 spin_lock_init(&trans_pcie->reg_lock); 1502 spin_lock_init(&trans_pcie->reg_lock);
1503 init_waitqueue_head(&trans_pcie->ucode_write_waitq); 1503 init_waitqueue_head(&trans_pcie->ucode_write_waitq);
1504 1504
1505 /* W/A - seems to solve weird behavior. We need to remove this if we
1506 * don't want to stay in L1 all the time. This wastes a lot of power */
1507 pci_disable_link_state(pdev, PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1 |
1508 PCIE_LINK_STATE_CLKPM);
1509
1510 if (pci_enable_device(pdev)) { 1505 if (pci_enable_device(pdev)) {
1511 err = -ENODEV; 1506 err = -ENODEV;
1512 goto out_no_pci; 1507 goto out_no_pci;
1513 } 1508 }
1514 1509
1510 /* W/A - seems to solve weird behavior. We need to remove this if we
1511 * don't want to stay in L1 all the time. This wastes a lot of power */
1512 pci_disable_link_state(pdev, PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1 |
1513 PCIE_LINK_STATE_CLKPM);
1514
1515 pci_set_master(pdev); 1515 pci_set_master(pdev);
1516 1516
1517 err = pci_set_dma_mask(pdev, DMA_BIT_MASK(36)); 1517 err = pci_set_dma_mask(pdev, DMA_BIT_MASK(36));
diff --git a/drivers/net/wireless/zd1201.c b/drivers/net/wireless/zd1201.c
index 4941f201d6c8..b8ba1f925e75 100644
--- a/drivers/net/wireless/zd1201.c
+++ b/drivers/net/wireless/zd1201.c
@@ -98,10 +98,12 @@ static int zd1201_fw_upload(struct usb_device *dev, int apfw)
98 goto exit; 98 goto exit;
99 99
100 err = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), 0x4, 100 err = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), 0x4,
101 USB_DIR_IN | 0x40, 0,0, &ret, sizeof(ret), ZD1201_FW_TIMEOUT); 101 USB_DIR_IN | 0x40, 0, 0, buf, sizeof(ret), ZD1201_FW_TIMEOUT);
102 if (err < 0) 102 if (err < 0)
103 goto exit; 103 goto exit;
104 104
105 memcpy(&ret, buf, sizeof(ret));
106
105 if (ret & 0x80) { 107 if (ret & 0x80) {
106 err = -EIO; 108 err = -EIO;
107 goto exit; 109 goto exit;
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 6bb7cf2de556..b10ba00cc3e6 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -392,6 +392,8 @@ static void __unflatten_device_tree(struct boot_param_header *blob,
392 mem = (unsigned long) 392 mem = (unsigned long)
393 dt_alloc(size + 4, __alignof__(struct device_node)); 393 dt_alloc(size + 4, __alignof__(struct device_node));
394 394
395 memset((void *)mem, 0, size);
396
395 ((__be32 *)mem)[size / 4] = cpu_to_be32(0xdeadbeef); 397 ((__be32 *)mem)[size / 4] = cpu_to_be32(0xdeadbeef);
396 398
397 pr_debug(" unflattening %lx...\n", mem); 399 pr_debug(" unflattening %lx...\n", mem);
diff --git a/drivers/pci/hotplug/acpiphp.h b/drivers/pci/hotplug/acpiphp.h
index 6fdd49c6f0b9..f4e028924667 100644
--- a/drivers/pci/hotplug/acpiphp.h
+++ b/drivers/pci/hotplug/acpiphp.h
@@ -49,6 +49,7 @@
49#define info(format, arg...) printk(KERN_INFO "%s: " format, MY_NAME , ## arg) 49#define info(format, arg...) printk(KERN_INFO "%s: " format, MY_NAME , ## arg)
50#define warn(format, arg...) printk(KERN_WARNING "%s: " format, MY_NAME , ## arg) 50#define warn(format, arg...) printk(KERN_WARNING "%s: " format, MY_NAME , ## arg)
51 51
52struct acpiphp_context;
52struct acpiphp_bridge; 53struct acpiphp_bridge;
53struct acpiphp_slot; 54struct acpiphp_slot;
54 55
@@ -59,6 +60,7 @@ struct slot {
59 struct hotplug_slot *hotplug_slot; 60 struct hotplug_slot *hotplug_slot;
60 struct acpiphp_slot *acpi_slot; 61 struct acpiphp_slot *acpi_slot;
61 struct hotplug_slot_info info; 62 struct hotplug_slot_info info;
63 unsigned int sun; /* ACPI _SUN (Slot User Number) value */
62}; 64};
63 65
64static inline const char *slot_name(struct slot *slot) 66static inline const char *slot_name(struct slot *slot)
@@ -75,15 +77,11 @@ struct acpiphp_bridge {
75 struct list_head list; 77 struct list_head list;
76 struct list_head slots; 78 struct list_head slots;
77 struct kref ref; 79 struct kref ref;
78 acpi_handle handle;
79 80
80 /* Ejectable PCI-to-PCI bridge (PCI bridge and PCI function) */ 81 struct acpiphp_context *context;
81 struct acpiphp_func *func;
82 82
83 int nr_slots; 83 int nr_slots;
84 84
85 u32 flags;
86
87 /* This bus (host bridge) or Secondary bus (PCI-to-PCI bridge) */ 85 /* This bus (host bridge) or Secondary bus (PCI-to-PCI bridge) */
88 struct pci_bus *pci_bus; 86 struct pci_bus *pci_bus;
89 87
@@ -99,15 +97,13 @@ struct acpiphp_bridge {
99 */ 97 */
100struct acpiphp_slot { 98struct acpiphp_slot {
101 struct list_head node; 99 struct list_head node;
102 struct acpiphp_bridge *bridge; /* parent */ 100 struct pci_bus *bus;
103 struct list_head funcs; /* one slot may have different 101 struct list_head funcs; /* one slot may have different
104 objects (i.e. for each function) */ 102 objects (i.e. for each function) */
105 struct slot *slot; 103 struct slot *slot;
106 struct mutex crit_sect; 104 struct mutex crit_sect;
107 105
108 u8 device; /* pci device# */ 106 u8 device; /* pci device# */
109
110 unsigned long long sun; /* ACPI _SUN (slot unique number) */
111 u32 flags; /* see below */ 107 u32 flags; /* see below */
112}; 108};
113 109
@@ -119,16 +115,32 @@ struct acpiphp_slot {
119 * typically 8 objects per slot (i.e. for each PCI function) 115 * typically 8 objects per slot (i.e. for each PCI function)
120 */ 116 */
121struct acpiphp_func { 117struct acpiphp_func {
122 struct acpiphp_slot *slot; /* parent */ 118 struct acpiphp_bridge *parent;
119 struct acpiphp_slot *slot;
123 120
124 struct list_head sibling; 121 struct list_head sibling;
125 struct notifier_block nb;
126 acpi_handle handle;
127 122
128 u8 function; /* pci function# */ 123 u8 function; /* pci function# */
129 u32 flags; /* see below */ 124 u32 flags; /* see below */
130}; 125};
131 126
127struct acpiphp_context {
128 acpi_handle handle;
129 struct acpiphp_func func;
130 struct acpiphp_bridge *bridge;
131 unsigned int refcount;
132};
133
134static inline struct acpiphp_context *func_to_context(struct acpiphp_func *func)
135{
136 return container_of(func, struct acpiphp_context, func);
137}
138
139static inline acpi_handle func_to_handle(struct acpiphp_func *func)
140{
141 return func_to_context(func)->handle;
142}
143
132/* 144/*
133 * struct acpiphp_attention_info - device specific attention registration 145 * struct acpiphp_attention_info - device specific attention registration
134 * 146 *
@@ -142,45 +154,32 @@ struct acpiphp_attention_info
142 struct module *owner; 154 struct module *owner;
143}; 155};
144 156
145/* PCI bus bridge HID */
146#define ACPI_PCI_HOST_HID "PNP0A03"
147
148/* ACPI _STA method value (ignore bit 4; battery present) */ 157/* ACPI _STA method value (ignore bit 4; battery present) */
149#define ACPI_STA_ALL (0x0000000f) 158#define ACPI_STA_ALL (0x0000000f)
150 159
151/* bridge flags */
152#define BRIDGE_HAS_EJ0 (0x00000001)
153
154/* slot flags */ 160/* slot flags */
155 161
156#define SLOT_POWEREDON (0x00000001) 162#define SLOT_ENABLED (0x00000001)
157#define SLOT_ENABLED (0x00000002)
158#define SLOT_MULTIFUNCTION (0x00000004)
159 163
160/* function flags */ 164/* function flags */
161 165
162#define FUNC_HAS_STA (0x00000001) 166#define FUNC_HAS_STA (0x00000001)
163#define FUNC_HAS_EJ0 (0x00000002) 167#define FUNC_HAS_EJ0 (0x00000002)
164#define FUNC_HAS_PS0 (0x00000010) 168#define FUNC_HAS_DCK (0x00000004)
165#define FUNC_HAS_PS1 (0x00000020)
166#define FUNC_HAS_PS2 (0x00000040)
167#define FUNC_HAS_PS3 (0x00000080)
168#define FUNC_HAS_DCK (0x00000100)
169 169
170/* function prototypes */ 170/* function prototypes */
171 171
172/* acpiphp_core.c */ 172/* acpiphp_core.c */
173int acpiphp_register_attention(struct acpiphp_attention_info*info); 173int acpiphp_register_attention(struct acpiphp_attention_info*info);
174int acpiphp_unregister_attention(struct acpiphp_attention_info *info); 174int acpiphp_unregister_attention(struct acpiphp_attention_info *info);
175int acpiphp_register_hotplug_slot(struct acpiphp_slot *slot); 175int acpiphp_register_hotplug_slot(struct acpiphp_slot *slot, unsigned int sun);
176void acpiphp_unregister_hotplug_slot(struct acpiphp_slot *slot); 176void acpiphp_unregister_hotplug_slot(struct acpiphp_slot *slot);
177 177
178/* acpiphp_glue.c */ 178/* acpiphp_glue.c */
179typedef int (*acpiphp_callback)(struct acpiphp_slot *slot, void *data); 179typedef int (*acpiphp_callback)(struct acpiphp_slot *slot, void *data);
180 180
181int acpiphp_enable_slot(struct acpiphp_slot *slot); 181int acpiphp_enable_slot(struct acpiphp_slot *slot);
182int acpiphp_disable_slot(struct acpiphp_slot *slot); 182int acpiphp_disable_and_eject_slot(struct acpiphp_slot *slot);
183int acpiphp_eject_slot(struct acpiphp_slot *slot);
184u8 acpiphp_get_power_status(struct acpiphp_slot *slot); 183u8 acpiphp_get_power_status(struct acpiphp_slot *slot);
185u8 acpiphp_get_attention_status(struct acpiphp_slot *slot); 184u8 acpiphp_get_attention_status(struct acpiphp_slot *slot);
186u8 acpiphp_get_latch_status(struct acpiphp_slot *slot); 185u8 acpiphp_get_latch_status(struct acpiphp_slot *slot);
diff --git a/drivers/pci/hotplug/acpiphp_core.c b/drivers/pci/hotplug/acpiphp_core.c
index ca8127950fcd..bf2203ef1308 100644
--- a/drivers/pci/hotplug/acpiphp_core.c
+++ b/drivers/pci/hotplug/acpiphp_core.c
@@ -155,15 +155,11 @@ static int enable_slot(struct hotplug_slot *hotplug_slot)
155static int disable_slot(struct hotplug_slot *hotplug_slot) 155static int disable_slot(struct hotplug_slot *hotplug_slot)
156{ 156{
157 struct slot *slot = hotplug_slot->private; 157 struct slot *slot = hotplug_slot->private;
158 int retval;
159 158
160 dbg("%s - physical_slot = %s\n", __func__, slot_name(slot)); 159 dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
161 160
162 /* disable the specified slot */ 161 /* disable the specified slot */
163 retval = acpiphp_disable_slot(slot->acpi_slot); 162 return acpiphp_disable_and_eject_slot(slot->acpi_slot);
164 if (!retval)
165 retval = acpiphp_eject_slot(slot->acpi_slot);
166 return retval;
167} 163}
168 164
169 165
@@ -290,7 +286,8 @@ static void release_slot(struct hotplug_slot *hotplug_slot)
290} 286}
291 287
292/* callback routine to initialize 'struct slot' for each slot */ 288/* callback routine to initialize 'struct slot' for each slot */
293int acpiphp_register_hotplug_slot(struct acpiphp_slot *acpiphp_slot) 289int acpiphp_register_hotplug_slot(struct acpiphp_slot *acpiphp_slot,
290 unsigned int sun)
294{ 291{
295 struct slot *slot; 292 struct slot *slot;
296 int retval = -ENOMEM; 293 int retval = -ENOMEM;
@@ -317,12 +314,11 @@ int acpiphp_register_hotplug_slot(struct acpiphp_slot *acpiphp_slot)
317 slot->hotplug_slot->info->adapter_status = acpiphp_get_adapter_status(slot->acpi_slot); 314 slot->hotplug_slot->info->adapter_status = acpiphp_get_adapter_status(slot->acpi_slot);
318 315
319 acpiphp_slot->slot = slot; 316 acpiphp_slot->slot = slot;
320 snprintf(name, SLOT_NAME_SIZE, "%llu", slot->acpi_slot->sun); 317 slot->sun = sun;
318 snprintf(name, SLOT_NAME_SIZE, "%u", sun);
321 319
322 retval = pci_hp_register(slot->hotplug_slot, 320 retval = pci_hp_register(slot->hotplug_slot, acpiphp_slot->bus,
323 acpiphp_slot->bridge->pci_bus, 321 acpiphp_slot->device, name);
324 acpiphp_slot->device,
325 name);
326 if (retval == -EBUSY) 322 if (retval == -EBUSY)
327 goto error_hpslot; 323 goto error_hpslot;
328 if (retval) { 324 if (retval) {
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
index 59df8575a48c..8054ddcdaed0 100644
--- a/drivers/pci/hotplug/acpiphp_glue.c
+++ b/drivers/pci/hotplug/acpiphp_glue.c
@@ -46,6 +46,7 @@
46#include <linux/pci.h> 46#include <linux/pci.h>
47#include <linux/pci_hotplug.h> 47#include <linux/pci_hotplug.h>
48#include <linux/pci-acpi.h> 48#include <linux/pci-acpi.h>
49#include <linux/pm_runtime.h>
49#include <linux/mutex.h> 50#include <linux/mutex.h>
50#include <linux/slab.h> 51#include <linux/slab.h>
51#include <linux/acpi.h> 52#include <linux/acpi.h>
@@ -55,28 +56,82 @@
55 56
56static LIST_HEAD(bridge_list); 57static LIST_HEAD(bridge_list);
57static DEFINE_MUTEX(bridge_mutex); 58static DEFINE_MUTEX(bridge_mutex);
59static DEFINE_MUTEX(acpiphp_context_lock);
58 60
59#define MY_NAME "acpiphp_glue" 61#define MY_NAME "acpiphp_glue"
60 62
61static void handle_hotplug_event_bridge (acpi_handle, u32, void *); 63static void handle_hotplug_event(acpi_handle handle, u32 type, void *data);
62static void acpiphp_sanitize_bus(struct pci_bus *bus); 64static void acpiphp_sanitize_bus(struct pci_bus *bus);
63static void acpiphp_set_hpp_values(struct pci_bus *bus); 65static void acpiphp_set_hpp_values(struct pci_bus *bus);
64static void hotplug_event_func(acpi_handle handle, u32 type, void *context); 66static void hotplug_event(acpi_handle handle, u32 type, void *data);
65static void handle_hotplug_event_func(acpi_handle handle, u32 type, void *context);
66static void free_bridge(struct kref *kref); 67static void free_bridge(struct kref *kref);
67 68
68/* callback routine to check for the existence of a pci dock device */ 69static void acpiphp_context_handler(acpi_handle handle, void *context)
69static acpi_status
70is_pci_dock_device(acpi_handle handle, u32 lvl, void *context, void **rv)
71{ 70{
72 int *count = (int *)context; 71 /* Intentionally empty. */
72}
73 73
74 if (is_dock_device(handle)) { 74/**
75 (*count)++; 75 * acpiphp_init_context - Create hotplug context and grab a reference to it.
76 return AE_CTRL_TERMINATE; 76 * @handle: ACPI object handle to create the context for.
77 } else { 77 *
78 return AE_OK; 78 * Call under acpiphp_context_lock.
79 */
80static struct acpiphp_context *acpiphp_init_context(acpi_handle handle)
81{
82 struct acpiphp_context *context;
83 acpi_status status;
84
85 context = kzalloc(sizeof(*context), GFP_KERNEL);
86 if (!context)
87 return NULL;
88
89 context->handle = handle;
90 context->refcount = 1;
91 status = acpi_attach_data(handle, acpiphp_context_handler, context);
92 if (ACPI_FAILURE(status)) {
93 kfree(context);
94 return NULL;
79 } 95 }
96 return context;
97}
98
99/**
100 * acpiphp_get_context - Get hotplug context and grab a reference to it.
101 * @handle: ACPI object handle to get the context for.
102 *
103 * Call under acpiphp_context_lock.
104 */
105static struct acpiphp_context *acpiphp_get_context(acpi_handle handle)
106{
107 struct acpiphp_context *context = NULL;
108 acpi_status status;
109 void *data;
110
111 status = acpi_get_data(handle, acpiphp_context_handler, &data);
112 if (ACPI_SUCCESS(status)) {
113 context = data;
114 context->refcount++;
115 }
116 return context;
117}
118
119/**
120 * acpiphp_put_context - Drop a reference to ACPI hotplug context.
121 * @handle: ACPI object handle to put the context for.
122 *
123 * The context object is removed if there are no more references to it.
124 *
125 * Call under acpiphp_context_lock.
126 */
127static void acpiphp_put_context(struct acpiphp_context *context)
128{
129 if (--context->refcount)
130 return;
131
132 WARN_ON(context->bridge);
133 acpi_detach_data(context->handle, acpiphp_context_handler);
134 kfree(context);
80} 135}
81 136
82static inline void get_bridge(struct acpiphp_bridge *bridge) 137static inline void get_bridge(struct acpiphp_bridge *bridge)
@@ -91,25 +146,36 @@ static inline void put_bridge(struct acpiphp_bridge *bridge)
91 146
92static void free_bridge(struct kref *kref) 147static void free_bridge(struct kref *kref)
93{ 148{
149 struct acpiphp_context *context;
94 struct acpiphp_bridge *bridge; 150 struct acpiphp_bridge *bridge;
95 struct acpiphp_slot *slot, *next; 151 struct acpiphp_slot *slot, *next;
96 struct acpiphp_func *func, *tmp; 152 struct acpiphp_func *func, *tmp;
97 153
154 mutex_lock(&acpiphp_context_lock);
155
98 bridge = container_of(kref, struct acpiphp_bridge, ref); 156 bridge = container_of(kref, struct acpiphp_bridge, ref);
99 157
100 list_for_each_entry_safe(slot, next, &bridge->slots, node) { 158 list_for_each_entry_safe(slot, next, &bridge->slots, node) {
101 list_for_each_entry_safe(func, tmp, &slot->funcs, sibling) { 159 list_for_each_entry_safe(func, tmp, &slot->funcs, sibling)
102 kfree(func); 160 acpiphp_put_context(func_to_context(func));
103 } 161
104 kfree(slot); 162 kfree(slot);
105 } 163 }
106 164
107 /* Release reference acquired by acpiphp_bridge_handle_to_function() */ 165 context = bridge->context;
108 if ((bridge->flags & BRIDGE_HAS_EJ0) && bridge->func) 166 /* Root bridges will not have hotplug context. */
109 put_bridge(bridge->func->slot->bridge); 167 if (context) {
168 /* Release the reference taken by acpiphp_enumerate_slots(). */
169 put_bridge(context->func.parent);
170 context->bridge = NULL;
171 acpiphp_put_context(context);
172 }
173
110 put_device(&bridge->pci_bus->dev); 174 put_device(&bridge->pci_bus->dev);
111 pci_dev_put(bridge->pci_dev); 175 pci_dev_put(bridge->pci_dev);
112 kfree(bridge); 176 kfree(bridge);
177
178 mutex_unlock(&acpiphp_context_lock);
113} 179}
114 180
115/* 181/*
@@ -119,15 +185,14 @@ static void free_bridge(struct kref *kref)
119 * TBD - figure out a way to only call fixups for 185 * TBD - figure out a way to only call fixups for
120 * systems that require them. 186 * systems that require them.
121 */ 187 */
122static int post_dock_fixups(struct notifier_block *nb, unsigned long val, 188static void post_dock_fixups(acpi_handle not_used, u32 event, void *data)
123 void *v)
124{ 189{
125 struct acpiphp_func *func = container_of(nb, struct acpiphp_func, nb); 190 struct acpiphp_context *context = data;
126 struct pci_bus *bus = func->slot->bridge->pci_bus; 191 struct pci_bus *bus = context->func.slot->bus;
127 u32 buses; 192 u32 buses;
128 193
129 if (!bus->self) 194 if (!bus->self)
130 return NOTIFY_OK; 195 return;
131 196
132 /* fixup bad _DCK function that rewrites 197 /* fixup bad _DCK function that rewrites
133 * secondary bridge on slot 198 * secondary bridge on slot
@@ -143,12 +208,12 @@ static int post_dock_fixups(struct notifier_block *nb, unsigned long val,
143 | ((unsigned int)(bus->busn_res.end) << 16); 208 | ((unsigned int)(bus->busn_res.end) << 16);
144 pci_write_config_dword(bus->self, PCI_PRIMARY_BUS, buses); 209 pci_write_config_dword(bus->self, PCI_PRIMARY_BUS, buses);
145 } 210 }
146 return NOTIFY_OK;
147} 211}
148 212
149 213
150static const struct acpi_dock_ops acpiphp_dock_ops = { 214static const struct acpi_dock_ops acpiphp_dock_ops = {
151 .handler = hotplug_event_func, 215 .fixup = post_dock_fixups,
216 .handler = hotplug_event,
152}; 217};
153 218
154/* Check whether the PCI device is managed by native PCIe hotplug driver */ 219/* Check whether the PCI device is managed by native PCIe hotplug driver */
@@ -182,129 +247,118 @@ static bool device_is_managed_by_native_pciehp(struct pci_dev *pdev)
182 247
183static void acpiphp_dock_init(void *data) 248static void acpiphp_dock_init(void *data)
184{ 249{
185 struct acpiphp_func *func = data; 250 struct acpiphp_context *context = data;
186 251
187 get_bridge(func->slot->bridge); 252 get_bridge(context->func.parent);
188} 253}
189 254
190static void acpiphp_dock_release(void *data) 255static void acpiphp_dock_release(void *data)
191{ 256{
192 struct acpiphp_func *func = data; 257 struct acpiphp_context *context = data;
193 258
194 put_bridge(func->slot->bridge); 259 put_bridge(context->func.parent);
195} 260}
196 261
197/* callback routine to register each ACPI PCI slot object */ 262/* callback routine to register each ACPI PCI slot object */
198static acpi_status 263static acpi_status register_slot(acpi_handle handle, u32 lvl, void *data,
199register_slot(acpi_handle handle, u32 lvl, void *context, void **rv) 264 void **rv)
200{ 265{
201 struct acpiphp_bridge *bridge = (struct acpiphp_bridge *)context; 266 struct acpiphp_bridge *bridge = data;
267 struct acpiphp_context *context;
202 struct acpiphp_slot *slot; 268 struct acpiphp_slot *slot;
203 struct acpiphp_func *newfunc; 269 struct acpiphp_func *newfunc;
204 acpi_handle tmp;
205 acpi_status status = AE_OK; 270 acpi_status status = AE_OK;
206 unsigned long long adr, sun; 271 unsigned long long adr;
207 int device, function, retval, found = 0; 272 int device, function;
208 struct pci_bus *pbus = bridge->pci_bus; 273 struct pci_bus *pbus = bridge->pci_bus;
209 struct pci_dev *pdev; 274 struct pci_dev *pdev = bridge->pci_dev;
210 u32 val; 275 u32 val;
211 276
212 if (!acpi_pci_check_ejectable(pbus, handle) && !is_dock_device(handle)) 277 if (pdev && device_is_managed_by_native_pciehp(pdev))
213 return AE_OK; 278 return AE_OK;
214 279
215 status = acpi_evaluate_integer(handle, "_ADR", NULL, &adr); 280 status = acpi_evaluate_integer(handle, "_ADR", NULL, &adr);
216 if (ACPI_FAILURE(status)) { 281 if (ACPI_FAILURE(status)) {
217 warn("can't evaluate _ADR (%#x)\n", status); 282 acpi_handle_warn(handle, "can't evaluate _ADR (%#x)\n", status);
218 return AE_OK; 283 return AE_OK;
219 } 284 }
220 285
221 device = (adr >> 16) & 0xffff; 286 device = (adr >> 16) & 0xffff;
222 function = adr & 0xffff; 287 function = adr & 0xffff;
223 288
224 pdev = bridge->pci_dev; 289 mutex_lock(&acpiphp_context_lock);
225 if (pdev && device_is_managed_by_native_pciehp(pdev)) 290 context = acpiphp_init_context(handle);
226 return AE_OK; 291 if (!context) {
227 292 mutex_unlock(&acpiphp_context_lock);
228 newfunc = kzalloc(sizeof(struct acpiphp_func), GFP_KERNEL); 293 acpi_handle_err(handle, "No hotplug context\n");
229 if (!newfunc) 294 return AE_NOT_EXIST;
230 return AE_NO_MEMORY; 295 }
231 296 newfunc = &context->func;
232 newfunc->handle = handle;
233 newfunc->function = function; 297 newfunc->function = function;
298 newfunc->parent = bridge;
299 mutex_unlock(&acpiphp_context_lock);
234 300
235 if (ACPI_SUCCESS(acpi_get_handle(handle, "_EJ0", &tmp))) 301 if (acpi_has_method(handle, "_EJ0"))
236 newfunc->flags = FUNC_HAS_EJ0; 302 newfunc->flags = FUNC_HAS_EJ0;
237 303
238 if (ACPI_SUCCESS(acpi_get_handle(handle, "_STA", &tmp))) 304 if (acpi_has_method(handle, "_STA"))
239 newfunc->flags |= FUNC_HAS_STA; 305 newfunc->flags |= FUNC_HAS_STA;
240 306
241 if (ACPI_SUCCESS(acpi_get_handle(handle, "_PS0", &tmp))) 307 if (acpi_has_method(handle, "_DCK"))
242 newfunc->flags |= FUNC_HAS_PS0;
243
244 if (ACPI_SUCCESS(acpi_get_handle(handle, "_PS3", &tmp)))
245 newfunc->flags |= FUNC_HAS_PS3;
246
247 if (ACPI_SUCCESS(acpi_get_handle(handle, "_DCK", &tmp)))
248 newfunc->flags |= FUNC_HAS_DCK; 308 newfunc->flags |= FUNC_HAS_DCK;
249 309
250 status = acpi_evaluate_integer(handle, "_SUN", NULL, &sun);
251 if (ACPI_FAILURE(status)) {
252 /*
253 * use the count of the number of slots we've found
254 * for the number of the slot
255 */
256 sun = bridge->nr_slots+1;
257 }
258
259 /* search for objects that share the same slot */ 310 /* search for objects that share the same slot */
260 list_for_each_entry(slot, &bridge->slots, node) 311 list_for_each_entry(slot, &bridge->slots, node)
261 if (slot->device == device) { 312 if (slot->device == device)
262 if (slot->sun != sun) 313 goto slot_found;
263 warn("sibling found, but _SUN doesn't match!\n");
264 found = 1;
265 break;
266 }
267 314
268 if (!found) { 315 slot = kzalloc(sizeof(struct acpiphp_slot), GFP_KERNEL);
269 slot = kzalloc(sizeof(struct acpiphp_slot), GFP_KERNEL); 316 if (!slot) {
270 if (!slot) { 317 status = AE_NO_MEMORY;
271 kfree(newfunc); 318 goto err;
272 return AE_NO_MEMORY; 319 }
273 }
274 320
275 slot->bridge = bridge; 321 slot->bus = bridge->pci_bus;
276 slot->device = device; 322 slot->device = device;
277 slot->sun = sun; 323 INIT_LIST_HEAD(&slot->funcs);
278 INIT_LIST_HEAD(&slot->funcs); 324 mutex_init(&slot->crit_sect);
279 mutex_init(&slot->crit_sect); 325
326 list_add_tail(&slot->node, &bridge->slots);
327
328 /* Register slots for ejectable funtions only. */
329 if (acpi_pci_check_ejectable(pbus, handle) || is_dock_device(handle)) {
330 unsigned long long sun;
331 int retval;
280 332
281 mutex_lock(&bridge_mutex);
282 list_add_tail(&slot->node, &bridge->slots);
283 mutex_unlock(&bridge_mutex);
284 bridge->nr_slots++; 333 bridge->nr_slots++;
334 status = acpi_evaluate_integer(handle, "_SUN", NULL, &sun);
335 if (ACPI_FAILURE(status))
336 sun = bridge->nr_slots;
285 337
286 dbg("found ACPI PCI Hotplug slot %llu at PCI %04x:%02x:%02x\n", 338 dbg("found ACPI PCI Hotplug slot %llu at PCI %04x:%02x:%02x\n",
287 slot->sun, pci_domain_nr(pbus), pbus->number, device); 339 sun, pci_domain_nr(pbus), pbus->number, device);
288 retval = acpiphp_register_hotplug_slot(slot); 340
341 retval = acpiphp_register_hotplug_slot(slot, sun);
289 if (retval) { 342 if (retval) {
343 slot->slot = NULL;
344 bridge->nr_slots--;
290 if (retval == -EBUSY) 345 if (retval == -EBUSY)
291 warn("Slot %llu already registered by another " 346 warn("Slot %llu already registered by another "
292 "hotplug driver\n", slot->sun); 347 "hotplug driver\n", sun);
293 else 348 else
294 warn("acpiphp_register_hotplug_slot failed " 349 warn("acpiphp_register_hotplug_slot failed "
295 "(err code = 0x%x)\n", retval); 350 "(err code = 0x%x)\n", retval);
296 goto err_exit;
297 } 351 }
352 /* Even if the slot registration fails, we can still use it. */
298 } 353 }
299 354
355 slot_found:
300 newfunc->slot = slot; 356 newfunc->slot = slot;
301 mutex_lock(&bridge_mutex);
302 list_add_tail(&newfunc->sibling, &slot->funcs); 357 list_add_tail(&newfunc->sibling, &slot->funcs);
303 mutex_unlock(&bridge_mutex);
304 358
305 if (pci_bus_read_dev_vendor_id(pbus, PCI_DEVFN(device, function), 359 if (pci_bus_read_dev_vendor_id(pbus, PCI_DEVFN(device, function),
306 &val, 60*1000)) 360 &val, 60*1000))
307 slot->flags |= (SLOT_ENABLED | SLOT_POWEREDON); 361 slot->flags |= SLOT_ENABLED;
308 362
309 if (is_dock_device(handle)) { 363 if (is_dock_device(handle)) {
310 /* we don't want to call this device's _EJ0 364 /* we don't want to call this device's _EJ0
@@ -313,136 +367,46 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv)
313 */ 367 */
314 newfunc->flags &= ~FUNC_HAS_EJ0; 368 newfunc->flags &= ~FUNC_HAS_EJ0;
315 if (register_hotplug_dock_device(handle, 369 if (register_hotplug_dock_device(handle,
316 &acpiphp_dock_ops, newfunc, 370 &acpiphp_dock_ops, context,
317 acpiphp_dock_init, acpiphp_dock_release)) 371 acpiphp_dock_init, acpiphp_dock_release))
318 dbg("failed to register dock device\n"); 372 dbg("failed to register dock device\n");
319
320 /* we need to be notified when dock events happen
321 * outside of the hotplug operation, since we may
322 * need to do fixups before we can hotplug.
323 */
324 newfunc->nb.notifier_call = post_dock_fixups;
325 if (register_dock_notifier(&newfunc->nb))
326 dbg("failed to register a dock notifier");
327 } 373 }
328 374
329 /* install notify handler */ 375 /* install notify handler */
330 if (!(newfunc->flags & FUNC_HAS_DCK)) { 376 if (!(newfunc->flags & FUNC_HAS_DCK)) {
331 status = acpi_install_notify_handler(handle, 377 status = acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
332 ACPI_SYSTEM_NOTIFY, 378 handle_hotplug_event,
333 handle_hotplug_event_func, 379 context);
334 newfunc);
335
336 if (ACPI_FAILURE(status)) 380 if (ACPI_FAILURE(status))
337 err("failed to register interrupt notify handler\n"); 381 acpi_handle_err(handle,
338 } else 382 "failed to install notify handler\n");
339 status = AE_OK;
340
341 return status;
342
343 err_exit:
344 bridge->nr_slots--;
345 mutex_lock(&bridge_mutex);
346 list_del(&slot->node);
347 mutex_unlock(&bridge_mutex);
348 kfree(slot);
349 kfree(newfunc);
350
351 return AE_OK;
352}
353
354
355/* see if it's worth looking at this bridge */
356static int detect_ejectable_slots(acpi_handle handle)
357{
358 int found = acpi_pci_detect_ejectable(handle);
359 if (!found) {
360 acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, (u32)1,
361 is_pci_dock_device, NULL, (void *)&found, NULL);
362 }
363 return found;
364}
365
366/* initialize miscellaneous stuff for both root and PCI-to-PCI bridge */
367static void init_bridge_misc(struct acpiphp_bridge *bridge)
368{
369 acpi_status status;
370
371 /* must be added to the list prior to calling register_slot */
372 mutex_lock(&bridge_mutex);
373 list_add(&bridge->list, &bridge_list);
374 mutex_unlock(&bridge_mutex);
375
376 /* register all slot objects under this bridge */
377 status = acpi_walk_namespace(ACPI_TYPE_DEVICE, bridge->handle, (u32)1,
378 register_slot, NULL, bridge, NULL);
379 if (ACPI_FAILURE(status)) {
380 mutex_lock(&bridge_mutex);
381 list_del(&bridge->list);
382 mutex_unlock(&bridge_mutex);
383 return;
384 } 383 }
385 384
386 /* install notify handler for P2P bridges */ 385 return AE_OK;
387 if (!pci_is_root_bus(bridge->pci_bus)) {
388 if ((bridge->flags & BRIDGE_HAS_EJ0) && bridge->func) {
389 status = acpi_remove_notify_handler(bridge->func->handle,
390 ACPI_SYSTEM_NOTIFY,
391 handle_hotplug_event_func);
392 if (ACPI_FAILURE(status))
393 err("failed to remove notify handler\n");
394 }
395 status = acpi_install_notify_handler(bridge->handle,
396 ACPI_SYSTEM_NOTIFY,
397 handle_hotplug_event_bridge,
398 bridge);
399
400 if (ACPI_FAILURE(status)) {
401 err("failed to register interrupt notify handler\n");
402 }
403 }
404}
405
406
407/* find acpiphp_func from acpiphp_bridge */
408static struct acpiphp_func *acpiphp_bridge_handle_to_function(acpi_handle handle)
409{
410 struct acpiphp_bridge *bridge;
411 struct acpiphp_slot *slot;
412 struct acpiphp_func *func = NULL;
413
414 mutex_lock(&bridge_mutex);
415 list_for_each_entry(bridge, &bridge_list, list) {
416 list_for_each_entry(slot, &bridge->slots, node) {
417 list_for_each_entry(func, &slot->funcs, sibling) {
418 if (func->handle == handle) {
419 get_bridge(func->slot->bridge);
420 mutex_unlock(&bridge_mutex);
421 return func;
422 }
423 }
424 }
425 }
426 mutex_unlock(&bridge_mutex);
427 386
428 return NULL; 387 err:
388 mutex_lock(&acpiphp_context_lock);
389 acpiphp_put_context(context);
390 mutex_unlock(&acpiphp_context_lock);
391 return status;
429} 392}
430 393
431
432static struct acpiphp_bridge *acpiphp_handle_to_bridge(acpi_handle handle) 394static struct acpiphp_bridge *acpiphp_handle_to_bridge(acpi_handle handle)
433{ 395{
434 struct acpiphp_bridge *bridge; 396 struct acpiphp_context *context;
435 397 struct acpiphp_bridge *bridge = NULL;
436 mutex_lock(&bridge_mutex); 398
437 list_for_each_entry(bridge, &bridge_list, list) 399 mutex_lock(&acpiphp_context_lock);
438 if (bridge->handle == handle) { 400 context = acpiphp_get_context(handle);
401 if (context) {
402 bridge = context->bridge;
403 if (bridge)
439 get_bridge(bridge); 404 get_bridge(bridge);
440 mutex_unlock(&bridge_mutex);
441 return bridge;
442 }
443 mutex_unlock(&bridge_mutex);
444 405
445 return NULL; 406 acpiphp_put_context(context);
407 }
408 mutex_unlock(&acpiphp_context_lock);
409 return bridge;
446} 410}
447 411
448static void cleanup_bridge(struct acpiphp_bridge *bridge) 412static void cleanup_bridge(struct acpiphp_bridge *bridge)
@@ -450,40 +414,24 @@ static void cleanup_bridge(struct acpiphp_bridge *bridge)
450 struct acpiphp_slot *slot; 414 struct acpiphp_slot *slot;
451 struct acpiphp_func *func; 415 struct acpiphp_func *func;
452 acpi_status status; 416 acpi_status status;
453 acpi_handle handle = bridge->handle;
454
455 if (!pci_is_root_bus(bridge->pci_bus)) {
456 status = acpi_remove_notify_handler(handle,
457 ACPI_SYSTEM_NOTIFY,
458 handle_hotplug_event_bridge);
459 if (ACPI_FAILURE(status))
460 err("failed to remove notify handler\n");
461 }
462
463 if ((bridge->flags & BRIDGE_HAS_EJ0) && bridge->func) {
464 status = acpi_install_notify_handler(bridge->func->handle,
465 ACPI_SYSTEM_NOTIFY,
466 handle_hotplug_event_func,
467 bridge->func);
468 if (ACPI_FAILURE(status))
469 err("failed to install interrupt notify handler\n");
470 }
471 417
472 list_for_each_entry(slot, &bridge->slots, node) { 418 list_for_each_entry(slot, &bridge->slots, node) {
473 list_for_each_entry(func, &slot->funcs, sibling) { 419 list_for_each_entry(func, &slot->funcs, sibling) {
474 if (is_dock_device(func->handle)) { 420 acpi_handle handle = func_to_handle(func);
475 unregister_hotplug_dock_device(func->handle); 421
476 unregister_dock_notifier(&func->nb); 422 if (is_dock_device(handle))
477 } 423 unregister_hotplug_dock_device(handle);
424
478 if (!(func->flags & FUNC_HAS_DCK)) { 425 if (!(func->flags & FUNC_HAS_DCK)) {
479 status = acpi_remove_notify_handler(func->handle, 426 status = acpi_remove_notify_handler(handle,
480 ACPI_SYSTEM_NOTIFY, 427 ACPI_SYSTEM_NOTIFY,
481 handle_hotplug_event_func); 428 handle_hotplug_event);
482 if (ACPI_FAILURE(status)) 429 if (ACPI_FAILURE(status))
483 err("failed to remove notify handler\n"); 430 err("failed to remove notify handler\n");
484 } 431 }
485 } 432 }
486 acpiphp_unregister_hotplug_slot(slot); 433 if (slot->slot)
434 acpiphp_unregister_hotplug_slot(slot);
487 } 435 }
488 436
489 mutex_lock(&bridge_mutex); 437 mutex_lock(&bridge_mutex);
@@ -491,71 +439,6 @@ static void cleanup_bridge(struct acpiphp_bridge *bridge)
491 mutex_unlock(&bridge_mutex); 439 mutex_unlock(&bridge_mutex);
492} 440}
493 441
494static int power_on_slot(struct acpiphp_slot *slot)
495{
496 acpi_status status;
497 struct acpiphp_func *func;
498 int retval = 0;
499
500 /* if already enabled, just skip */
501 if (slot->flags & SLOT_POWEREDON)
502 goto err_exit;
503
504 list_for_each_entry(func, &slot->funcs, sibling) {
505 if (func->flags & FUNC_HAS_PS0) {
506 dbg("%s: executing _PS0\n", __func__);
507 status = acpi_evaluate_object(func->handle, "_PS0", NULL, NULL);
508 if (ACPI_FAILURE(status)) {
509 warn("%s: _PS0 failed\n", __func__);
510 retval = -1;
511 goto err_exit;
512 } else
513 break;
514 }
515 }
516
517 /* TBD: evaluate _STA to check if the slot is enabled */
518
519 slot->flags |= SLOT_POWEREDON;
520
521 err_exit:
522 return retval;
523}
524
525
526static int power_off_slot(struct acpiphp_slot *slot)
527{
528 acpi_status status;
529 struct acpiphp_func *func;
530
531 int retval = 0;
532
533 /* if already disabled, just skip */
534 if ((slot->flags & SLOT_POWEREDON) == 0)
535 goto err_exit;
536
537 list_for_each_entry(func, &slot->funcs, sibling) {
538 if (func->flags & FUNC_HAS_PS3) {
539 status = acpi_evaluate_object(func->handle, "_PS3", NULL, NULL);
540 if (ACPI_FAILURE(status)) {
541 warn("%s: _PS3 failed\n", __func__);
542 retval = -1;
543 goto err_exit;
544 } else
545 break;
546 }
547 }
548
549 /* TBD: evaluate _STA to check if the slot is disabled */
550
551 slot->flags &= (~SLOT_POWEREDON);
552
553 err_exit:
554 return retval;
555}
556
557
558
559/** 442/**
560 * acpiphp_max_busnr - return the highest reserved bus number under the given bus. 443 * acpiphp_max_busnr - return the highest reserved bus number under the given bus.
561 * @bus: bus to start search with 444 * @bus: bus to start search with
@@ -583,52 +466,32 @@ static unsigned char acpiphp_max_busnr(struct pci_bus *bus)
583 return max; 466 return max;
584} 467}
585 468
586
587/** 469/**
588 * acpiphp_bus_add - add a new bus to acpi subsystem 470 * acpiphp_bus_trim - Trim device objects in an ACPI namespace subtree.
589 * @func: acpiphp_func of the bridge 471 * @handle: ACPI device object handle to start from.
590 */ 472 */
591static int acpiphp_bus_add(struct acpiphp_func *func) 473static void acpiphp_bus_trim(acpi_handle handle)
592{ 474{
593 struct acpi_device *device; 475 struct acpi_device *adev = NULL;
594 int ret_val;
595
596 if (!acpi_bus_get_device(func->handle, &device)) {
597 dbg("bus exists... trim\n");
598 /* this shouldn't be in here, so remove
599 * the bus then re-add it...
600 */
601 acpi_bus_trim(device);
602 }
603
604 ret_val = acpi_bus_scan(func->handle);
605 if (!ret_val)
606 ret_val = acpi_bus_get_device(func->handle, &device);
607
608 if (ret_val)
609 dbg("error adding bus, %x\n", -ret_val);
610 476
611 return ret_val; 477 acpi_bus_get_device(handle, &adev);
478 if (adev)
479 acpi_bus_trim(adev);
612} 480}
613 481
614
615/** 482/**
616 * acpiphp_bus_trim - trim a bus from acpi subsystem 483 * acpiphp_bus_add - Scan ACPI namespace subtree.
617 * @handle: handle to acpi namespace 484 * @handle: ACPI object handle to start the scan from.
618 */ 485 */
619static int acpiphp_bus_trim(acpi_handle handle) 486static void acpiphp_bus_add(acpi_handle handle)
620{ 487{
621 struct acpi_device *device; 488 struct acpi_device *adev = NULL;
622 int retval;
623
624 retval = acpi_bus_get_device(handle, &device);
625 if (retval) {
626 dbg("acpi_device not found\n");
627 return retval;
628 }
629 489
630 acpi_bus_trim(device); 490 acpiphp_bus_trim(handle);
631 return 0; 491 acpi_bus_scan(handle);
492 acpi_bus_get_device(handle, &adev);
493 if (adev)
494 acpi_device_set_power(adev, ACPI_STATE_D0);
632} 495}
633 496
634static void acpiphp_set_acpi_region(struct acpiphp_slot *slot) 497static void acpiphp_set_acpi_region(struct acpiphp_slot *slot)
@@ -645,7 +508,8 @@ static void acpiphp_set_acpi_region(struct acpiphp_slot *slot)
645 params[1].type = ACPI_TYPE_INTEGER; 508 params[1].type = ACPI_TYPE_INTEGER;
646 params[1].integer.value = 1; 509 params[1].integer.value = 1;
647 /* _REG is optional, we don't care about if there is failure */ 510 /* _REG is optional, we don't care about if there is failure */
648 acpi_evaluate_object(func->handle, "_REG", &arg_list, NULL); 511 acpi_evaluate_object(func_to_handle(func), "_REG", &arg_list,
512 NULL);
649 } 513 }
650} 514}
651 515
@@ -653,59 +517,44 @@ static void check_hotplug_bridge(struct acpiphp_slot *slot, struct pci_dev *dev)
653{ 517{
654 struct acpiphp_func *func; 518 struct acpiphp_func *func;
655 519
656 if (!dev->subordinate)
657 return;
658
659 /* quirk, or pcie could set it already */ 520 /* quirk, or pcie could set it already */
660 if (dev->is_hotplug_bridge) 521 if (dev->is_hotplug_bridge)
661 return; 522 return;
662 523
663 if (PCI_SLOT(dev->devfn) != slot->device)
664 return;
665
666 list_for_each_entry(func, &slot->funcs, sibling) { 524 list_for_each_entry(func, &slot->funcs, sibling) {
667 if (PCI_FUNC(dev->devfn) == func->function) { 525 if (PCI_FUNC(dev->devfn) == func->function) {
668 /* check if this bridge has ejectable slots */ 526 dev->is_hotplug_bridge = 1;
669 if ((detect_ejectable_slots(func->handle) > 0))
670 dev->is_hotplug_bridge = 1;
671 break; 527 break;
672 } 528 }
673 } 529 }
674} 530}
675 531
676/** 532/**
677 * enable_device - enable, configure a slot 533 * enable_slot - enable, configure a slot
678 * @slot: slot to be enabled 534 * @slot: slot to be enabled
679 * 535 *
680 * This function should be called per *physical slot*, 536 * This function should be called per *physical slot*,
681 * not per each slot object in ACPI namespace. 537 * not per each slot object in ACPI namespace.
682 */ 538 */
683static int __ref enable_device(struct acpiphp_slot *slot) 539static void __ref enable_slot(struct acpiphp_slot *slot)
684{ 540{
685 struct pci_dev *dev; 541 struct pci_dev *dev;
686 struct pci_bus *bus = slot->bridge->pci_bus; 542 struct pci_bus *bus = slot->bus;
687 struct acpiphp_func *func; 543 struct acpiphp_func *func;
688 int num, max, pass; 544 int max, pass;
689 LIST_HEAD(add_list); 545 LIST_HEAD(add_list);
690 546
691 if (slot->flags & SLOT_ENABLED)
692 goto err_exit;
693
694 list_for_each_entry(func, &slot->funcs, sibling) 547 list_for_each_entry(func, &slot->funcs, sibling)
695 acpiphp_bus_add(func); 548 acpiphp_bus_add(func_to_handle(func));
696 549
697 num = pci_scan_slot(bus, PCI_DEVFN(slot->device, 0)); 550 pci_scan_slot(bus, PCI_DEVFN(slot->device, 0));
698 if (num == 0) {
699 /* Maybe only part of funcs are added. */
700 dbg("No new device found\n");
701 goto err_exit;
702 }
703 551
704 max = acpiphp_max_busnr(bus); 552 max = acpiphp_max_busnr(bus);
705 for (pass = 0; pass < 2; pass++) { 553 for (pass = 0; pass < 2; pass++) {
706 list_for_each_entry(dev, &bus->devices, bus_list) { 554 list_for_each_entry(dev, &bus->devices, bus_list) {
707 if (PCI_SLOT(dev->devfn) != slot->device) 555 if (PCI_SLOT(dev->devfn) != slot->device)
708 continue; 556 continue;
557
709 if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE || 558 if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE ||
710 dev->hdr_type == PCI_HEADER_TYPE_CARDBUS) { 559 dev->hdr_type == PCI_HEADER_TYPE_CARDBUS) {
711 max = pci_scan_bridge(bus, dev, max, pass); 560 max = pci_scan_bridge(bus, dev, max, pass);
@@ -744,16 +593,12 @@ static int __ref enable_device(struct acpiphp_slot *slot)
744 continue; 593 continue;
745 } 594 }
746 } 595 }
747
748
749 err_exit:
750 return 0;
751} 596}
752 597
753/* return first device in slot, acquiring a reference on it */ 598/* return first device in slot, acquiring a reference on it */
754static struct pci_dev *dev_in_slot(struct acpiphp_slot *slot) 599static struct pci_dev *dev_in_slot(struct acpiphp_slot *slot)
755{ 600{
756 struct pci_bus *bus = slot->bridge->pci_bus; 601 struct pci_bus *bus = slot->bus;
757 struct pci_dev *dev; 602 struct pci_dev *dev;
758 struct pci_dev *ret = NULL; 603 struct pci_dev *ret = NULL;
759 604
@@ -769,16 +614,16 @@ static struct pci_dev *dev_in_slot(struct acpiphp_slot *slot)
769} 614}
770 615
771/** 616/**
772 * disable_device - disable a slot 617 * disable_slot - disable a slot
773 * @slot: ACPI PHP slot 618 * @slot: ACPI PHP slot
774 */ 619 */
775static int disable_device(struct acpiphp_slot *slot) 620static void disable_slot(struct acpiphp_slot *slot)
776{ 621{
777 struct acpiphp_func *func; 622 struct acpiphp_func *func;
778 struct pci_dev *pdev; 623 struct pci_dev *pdev;
779 624
780 /* 625 /*
781 * enable_device() enumerates all functions in this device via 626 * enable_slot() enumerates all functions in this device via
782 * pci_scan_slot(), whether they have associated ACPI hotplug 627 * pci_scan_slot(), whether they have associated ACPI hotplug
783 * methods (_EJ0, etc.) or not. Therefore, we remove all functions 628 * methods (_EJ0, etc.) or not. Therefore, we remove all functions
784 * here. 629 * here.
@@ -788,13 +633,10 @@ static int disable_device(struct acpiphp_slot *slot)
788 pci_dev_put(pdev); 633 pci_dev_put(pdev);
789 } 634 }
790 635
791 list_for_each_entry(func, &slot->funcs, sibling) { 636 list_for_each_entry(func, &slot->funcs, sibling)
792 acpiphp_bus_trim(func->handle); 637 acpiphp_bus_trim(func_to_handle(func));
793 }
794 638
795 slot->flags &= (~SLOT_ENABLED); 639 slot->flags &= (~SLOT_ENABLED);
796
797 return 0;
798} 640}
799 641
800 642
@@ -812,18 +654,21 @@ static int disable_device(struct acpiphp_slot *slot)
812 */ 654 */
813static unsigned int get_slot_status(struct acpiphp_slot *slot) 655static unsigned int get_slot_status(struct acpiphp_slot *slot)
814{ 656{
815 acpi_status status;
816 unsigned long long sta = 0; 657 unsigned long long sta = 0;
817 u32 dvid;
818 struct acpiphp_func *func; 658 struct acpiphp_func *func;
819 659
820 list_for_each_entry(func, &slot->funcs, sibling) { 660 list_for_each_entry(func, &slot->funcs, sibling) {
821 if (func->flags & FUNC_HAS_STA) { 661 if (func->flags & FUNC_HAS_STA) {
822 status = acpi_evaluate_integer(func->handle, "_STA", NULL, &sta); 662 acpi_status status;
663
664 status = acpi_evaluate_integer(func_to_handle(func),
665 "_STA", NULL, &sta);
823 if (ACPI_SUCCESS(status) && sta) 666 if (ACPI_SUCCESS(status) && sta)
824 break; 667 break;
825 } else { 668 } else {
826 pci_bus_read_config_dword(slot->bridge->pci_bus, 669 u32 dvid;
670
671 pci_bus_read_config_dword(slot->bus,
827 PCI_DEVFN(slot->device, 672 PCI_DEVFN(slot->device,
828 func->function), 673 func->function),
829 PCI_VENDOR_ID, &dvid); 674 PCI_VENDOR_ID, &dvid);
@@ -838,34 +683,42 @@ static unsigned int get_slot_status(struct acpiphp_slot *slot)
838} 683}
839 684
840/** 685/**
841 * acpiphp_eject_slot - physically eject the slot 686 * trim_stale_devices - remove PCI devices that are not responding.
842 * @slot: ACPI PHP slot 687 * @dev: PCI device to start walking the hierarchy from.
843 */ 688 */
844int acpiphp_eject_slot(struct acpiphp_slot *slot) 689static void trim_stale_devices(struct pci_dev *dev)
845{ 690{
846 acpi_status status; 691 acpi_handle handle = ACPI_HANDLE(&dev->dev);
847 struct acpiphp_func *func; 692 struct pci_bus *bus = dev->subordinate;
848 struct acpi_object_list arg_list; 693 bool alive = false;
849 union acpi_object arg;
850 694
851 list_for_each_entry(func, &slot->funcs, sibling) { 695 if (handle) {
852 /* We don't want to call _EJ0 on non-existing functions. */ 696 acpi_status status;
853 if ((func->flags & FUNC_HAS_EJ0)) { 697 unsigned long long sta;
854 /* _EJ0 method take one argument */ 698
855 arg_list.count = 1; 699 status = acpi_evaluate_integer(handle, "_STA", NULL, &sta);
856 arg_list.pointer = &arg; 700 alive = ACPI_SUCCESS(status) && sta == ACPI_STA_ALL;
857 arg.type = ACPI_TYPE_INTEGER; 701 }
858 arg.integer.value = 1; 702 if (!alive) {
859 703 u32 v;
860 status = acpi_evaluate_object(func->handle, "_EJ0", &arg_list, NULL); 704
861 if (ACPI_FAILURE(status)) { 705 /* Check if the device responds. */
862 warn("%s: _EJ0 failed\n", __func__); 706 alive = pci_bus_read_dev_vendor_id(dev->bus, dev->devfn, &v, 0);
863 return -1; 707 }
864 } else 708 if (!alive) {
865 break; 709 pci_stop_and_remove_bus_device(dev);
866 } 710 if (handle)
711 acpiphp_bus_trim(handle);
712 } else if (bus) {
713 struct pci_dev *child, *tmp;
714
715 /* The device is a bridge. so check the bus below it. */
716 pm_runtime_get_sync(&dev->dev);
717 list_for_each_entry_safe(child, tmp, &bus->devices, bus_list)
718 trim_stale_devices(child);
719
720 pm_runtime_put(&dev->dev);
867 } 721 }
868 return 0;
869} 722}
870 723
871/** 724/**
@@ -875,43 +728,30 @@ int acpiphp_eject_slot(struct acpiphp_slot *slot)
875 * Iterate over all slots under this bridge and make sure that if a 728 * Iterate over all slots under this bridge and make sure that if a
876 * card is present they are enabled, and if not they are disabled. 729 * card is present they are enabled, and if not they are disabled.
877 */ 730 */
878static int acpiphp_check_bridge(struct acpiphp_bridge *bridge) 731static void acpiphp_check_bridge(struct acpiphp_bridge *bridge)
879{ 732{
880 struct acpiphp_slot *slot; 733 struct acpiphp_slot *slot;
881 int retval = 0;
882 int enabled, disabled;
883
884 enabled = disabled = 0;
885 734
886 list_for_each_entry(slot, &bridge->slots, node) { 735 list_for_each_entry(slot, &bridge->slots, node) {
887 unsigned int status = get_slot_status(slot); 736 struct pci_bus *bus = slot->bus;
888 if (slot->flags & SLOT_ENABLED) { 737 struct pci_dev *dev, *tmp;
889 if (status == ACPI_STA_ALL) 738
890 continue; 739 mutex_lock(&slot->crit_sect);
891 retval = acpiphp_disable_slot(slot); 740 /* wake up all functions */
892 if (retval) { 741 if (get_slot_status(slot) == ACPI_STA_ALL) {
893 err("Error occurred in disabling\n"); 742 /* remove stale devices if any */
894 goto err_exit; 743 list_for_each_entry_safe(dev, tmp, &bus->devices,
895 } else { 744 bus_list)
896 acpiphp_eject_slot(slot); 745 if (PCI_SLOT(dev->devfn) == slot->device)
897 } 746 trim_stale_devices(dev);
898 disabled++; 747
748 /* configure all functions */
749 enable_slot(slot);
899 } else { 750 } else {
900 if (status != ACPI_STA_ALL) 751 disable_slot(slot);
901 continue;
902 retval = acpiphp_enable_slot(slot);
903 if (retval) {
904 err("Error occurred in enabling\n");
905 goto err_exit;
906 }
907 enabled++;
908 } 752 }
753 mutex_unlock(&slot->crit_sect);
909 } 754 }
910
911 dbg("%s: %d enabled, %d disabled\n", __func__, enabled, disabled);
912
913 err_exit:
914 return retval;
915} 755}
916 756
917static void acpiphp_set_hpp_values(struct pci_bus *bus) 757static void acpiphp_set_hpp_values(struct pci_bus *bus)
@@ -950,25 +790,6 @@ static void acpiphp_sanitize_bus(struct pci_bus *bus)
950 * ACPI event handlers 790 * ACPI event handlers
951 */ 791 */
952 792
953static acpi_status
954check_sub_bridges(acpi_handle handle, u32 lvl, void *context, void **rv)
955{
956 struct acpiphp_bridge *bridge;
957 char objname[64];
958 struct acpi_buffer buffer = { .length = sizeof(objname),
959 .pointer = objname };
960
961 bridge = acpiphp_handle_to_bridge(handle);
962 if (bridge) {
963 acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
964 dbg("%s: re-enumerating slots under %s\n",
965 __func__, objname);
966 acpiphp_check_bridge(bridge);
967 put_bridge(bridge);
968 }
969 return AE_OK ;
970}
971
972void acpiphp_check_host_bridge(acpi_handle handle) 793void acpiphp_check_host_bridge(acpi_handle handle)
973{ 794{
974 struct acpiphp_bridge *bridge; 795 struct acpiphp_bridge *bridge;
@@ -978,27 +799,23 @@ void acpiphp_check_host_bridge(acpi_handle handle)
978 acpiphp_check_bridge(bridge); 799 acpiphp_check_bridge(bridge);
979 put_bridge(bridge); 800 put_bridge(bridge);
980 } 801 }
981
982 acpi_walk_namespace(ACPI_TYPE_DEVICE, handle,
983 ACPI_UINT32_MAX, check_sub_bridges, NULL, NULL, NULL);
984} 802}
985 803
986static void _handle_hotplug_event_bridge(struct work_struct *work) 804static void hotplug_event(acpi_handle handle, u32 type, void *data)
987{ 805{
806 struct acpiphp_context *context = data;
807 struct acpiphp_func *func = &context->func;
988 struct acpiphp_bridge *bridge; 808 struct acpiphp_bridge *bridge;
989 char objname[64]; 809 char objname[64];
990 struct acpi_buffer buffer = { .length = sizeof(objname), 810 struct acpi_buffer buffer = { .length = sizeof(objname),
991 .pointer = objname }; 811 .pointer = objname };
992 struct acpi_hp_work *hp_work;
993 acpi_handle handle;
994 u32 type;
995 812
996 hp_work = container_of(work, struct acpi_hp_work, work); 813 mutex_lock(&acpiphp_context_lock);
997 handle = hp_work->handle; 814 bridge = context->bridge;
998 type = hp_work->type; 815 if (bridge)
999 bridge = (struct acpiphp_bridge *)hp_work->context; 816 get_bridge(bridge);
1000 817
1001 acpi_scan_lock_acquire(); 818 mutex_unlock(&acpiphp_context_lock);
1002 819
1003 acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer); 820 acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
1004 821
@@ -1007,188 +824,129 @@ static void _handle_hotplug_event_bridge(struct work_struct *work)
1007 /* bus re-enumerate */ 824 /* bus re-enumerate */
1008 dbg("%s: Bus check notify on %s\n", __func__, objname); 825 dbg("%s: Bus check notify on %s\n", __func__, objname);
1009 dbg("%s: re-enumerating slots under %s\n", __func__, objname); 826 dbg("%s: re-enumerating slots under %s\n", __func__, objname);
1010 acpiphp_check_bridge(bridge); 827 if (bridge) {
1011 acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, 828 acpiphp_check_bridge(bridge);
1012 ACPI_UINT32_MAX, check_sub_bridges, NULL, NULL, NULL); 829 } else {
830 struct acpiphp_slot *slot = func->slot;
831
832 mutex_lock(&slot->crit_sect);
833 enable_slot(slot);
834 mutex_unlock(&slot->crit_sect);
835 }
1013 break; 836 break;
1014 837
1015 case ACPI_NOTIFY_DEVICE_CHECK: 838 case ACPI_NOTIFY_DEVICE_CHECK:
1016 /* device check */ 839 /* device check */
1017 dbg("%s: Device check notify on %s\n", __func__, objname); 840 dbg("%s: Device check notify on %s\n", __func__, objname);
1018 acpiphp_check_bridge(bridge); 841 if (bridge)
1019 break; 842 acpiphp_check_bridge(bridge);
843 else
844 acpiphp_check_bridge(func->parent);
1020 845
1021 case ACPI_NOTIFY_DEVICE_WAKE:
1022 /* wake event */
1023 dbg("%s: Device wake notify on %s\n", __func__, objname);
1024 break; 846 break;
1025 847
1026 case ACPI_NOTIFY_EJECT_REQUEST: 848 case ACPI_NOTIFY_EJECT_REQUEST:
1027 /* request device eject */ 849 /* request device eject */
1028 dbg("%s: Device eject notify on %s\n", __func__, objname); 850 dbg("%s: Device eject notify on %s\n", __func__, objname);
1029 if ((bridge->flags & BRIDGE_HAS_EJ0) && bridge->func) { 851 acpiphp_disable_and_eject_slot(func->slot);
1030 struct acpiphp_slot *slot;
1031 slot = bridge->func->slot;
1032 if (!acpiphp_disable_slot(slot))
1033 acpiphp_eject_slot(slot);
1034 }
1035 break; 852 break;
853 }
1036 854
1037 case ACPI_NOTIFY_FREQUENCY_MISMATCH: 855 if (bridge)
1038 printk(KERN_ERR "Device %s cannot be configured due" 856 put_bridge(bridge);
1039 " to a frequency mismatch\n", objname); 857}
1040 break;
1041 858
1042 case ACPI_NOTIFY_BUS_MODE_MISMATCH: 859static void hotplug_event_work(struct work_struct *work)
1043 printk(KERN_ERR "Device %s cannot be configured due" 860{
1044 " to a bus mode mismatch\n", objname); 861 struct acpiphp_context *context;
1045 break; 862 struct acpi_hp_work *hp_work;
1046 863
1047 case ACPI_NOTIFY_POWER_FAULT: 864 hp_work = container_of(work, struct acpi_hp_work, work);
1048 printk(KERN_ERR "Device %s has suffered a power fault\n", 865 context = hp_work->context;
1049 objname); 866 acpi_scan_lock_acquire();
1050 break;
1051 867
1052 default: 868 hotplug_event(hp_work->handle, hp_work->type, context);
1053 warn("notify_handler: unknown event type 0x%x for %s\n", type, objname);
1054 break;
1055 }
1056 869
1057 acpi_scan_lock_release(); 870 acpi_scan_lock_release();
1058 kfree(hp_work); /* allocated in handle_hotplug_event_bridge */ 871 kfree(hp_work); /* allocated in handle_hotplug_event() */
1059 put_bridge(bridge); 872 put_bridge(context->func.parent);
1060} 873}
1061 874
1062/** 875/**
1063 * handle_hotplug_event_bridge - handle ACPI event on bridges 876 * handle_hotplug_event - handle ACPI hotplug event
1064 * @handle: Notify()'ed acpi_handle 877 * @handle: Notify()'ed acpi_handle
1065 * @type: Notify code 878 * @type: Notify code
1066 * @context: pointer to acpiphp_bridge structure 879 * @data: pointer to acpiphp_context structure
1067 * 880 *
1068 * Handles ACPI event notification on {host,p2p} bridges. 881 * Handles ACPI event notification on slots.
1069 */ 882 */
1070static void handle_hotplug_event_bridge(acpi_handle handle, u32 type, 883static void handle_hotplug_event(acpi_handle handle, u32 type, void *data)
1071 void *context)
1072{ 884{
1073 struct acpiphp_bridge *bridge = context; 885 struct acpiphp_context *context;
1074
1075 /*
1076 * Currently the code adds all hotplug events to the kacpid_wq
1077 * queue when it should add hotplug events to the kacpi_hotplug_wq.
1078 * The proper way to fix this is to reorganize the code so that
1079 * drivers (dock, etc.) do not call acpi_os_execute(), etc.
1080 * For now just re-add this work to the kacpi_hotplug_wq so we
1081 * don't deadlock on hotplug actions.
1082 */
1083 get_bridge(bridge);
1084 alloc_acpi_hp_work(handle, type, context, _handle_hotplug_event_bridge);
1085}
1086
1087static void hotplug_event_func(acpi_handle handle, u32 type, void *context)
1088{
1089 struct acpiphp_func *func = context;
1090 char objname[64];
1091 struct acpi_buffer buffer = { .length = sizeof(objname),
1092 .pointer = objname };
1093
1094 acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
1095 886
1096 switch (type) { 887 switch (type) {
1097 case ACPI_NOTIFY_BUS_CHECK: 888 case ACPI_NOTIFY_BUS_CHECK:
1098 /* bus re-enumerate */
1099 dbg("%s: Bus check notify on %s\n", __func__, objname);
1100 acpiphp_enable_slot(func->slot);
1101 break;
1102
1103 case ACPI_NOTIFY_DEVICE_CHECK: 889 case ACPI_NOTIFY_DEVICE_CHECK:
1104 /* device check : re-enumerate from parent bus */
1105 dbg("%s: Device check notify on %s\n", __func__, objname);
1106 acpiphp_check_bridge(func->slot->bridge);
1107 break;
1108
1109 case ACPI_NOTIFY_DEVICE_WAKE:
1110 /* wake event */
1111 dbg("%s: Device wake notify on %s\n", __func__, objname);
1112 break;
1113
1114 case ACPI_NOTIFY_EJECT_REQUEST: 890 case ACPI_NOTIFY_EJECT_REQUEST:
1115 /* request device eject */
1116 dbg("%s: Device eject notify on %s\n", __func__, objname);
1117 if (!(acpiphp_disable_slot(func->slot)))
1118 acpiphp_eject_slot(func->slot);
1119 break; 891 break;
1120 892
1121 default: 893 case ACPI_NOTIFY_DEVICE_WAKE:
1122 warn("notify_handler: unknown event type 0x%x for %s\n", type, objname); 894 return;
1123 break;
1124 }
1125}
1126
1127static void _handle_hotplug_event_func(struct work_struct *work)
1128{
1129 struct acpi_hp_work *hp_work;
1130 struct acpiphp_func *func;
1131 895
1132 hp_work = container_of(work, struct acpi_hp_work, work); 896 case ACPI_NOTIFY_FREQUENCY_MISMATCH:
1133 func = hp_work->context; 897 acpi_handle_err(handle, "Device cannot be configured due "
1134 acpi_scan_lock_acquire(); 898 "to a frequency mismatch\n");
899 return;
1135 900
1136 hotplug_event_func(hp_work->handle, hp_work->type, func); 901 case ACPI_NOTIFY_BUS_MODE_MISMATCH:
902 acpi_handle_err(handle, "Device cannot be configured due "
903 "to a bus mode mismatch\n");
904 return;
1137 905
1138 acpi_scan_lock_release(); 906 case ACPI_NOTIFY_POWER_FAULT:
1139 kfree(hp_work); /* allocated in handle_hotplug_event_func */ 907 acpi_handle_err(handle, "Device has suffered a power fault\n");
1140 put_bridge(func->slot->bridge); 908 return;
1141}
1142 909
1143/** 910 default:
1144 * handle_hotplug_event_func - handle ACPI event on functions (i.e. slots) 911 acpi_handle_warn(handle, "Unsupported event type 0x%x\n", type);
1145 * @handle: Notify()'ed acpi_handle 912 return;
1146 * @type: Notify code 913 }
1147 * @context: pointer to acpiphp_func structure
1148 *
1149 * Handles ACPI event notification on slots.
1150 */
1151static void handle_hotplug_event_func(acpi_handle handle, u32 type,
1152 void *context)
1153{
1154 struct acpiphp_func *func = context;
1155 914
1156 /* 915 mutex_lock(&acpiphp_context_lock);
1157 * Currently the code adds all hotplug events to the kacpid_wq 916 context = acpiphp_get_context(handle);
1158 * queue when it should add hotplug events to the kacpi_hotplug_wq. 917 if (context) {
1159 * The proper way to fix this is to reorganize the code so that 918 get_bridge(context->func.parent);
1160 * drivers (dock, etc.) do not call acpi_os_execute(), etc. 919 acpiphp_put_context(context);
1161 * For now just re-add this work to the kacpi_hotplug_wq so we 920 alloc_acpi_hp_work(handle, type, context, hotplug_event_work);
1162 * don't deadlock on hotplug actions. 921 }
1163 */ 922 mutex_unlock(&acpiphp_context_lock);
1164 get_bridge(func->slot->bridge);
1165 alloc_acpi_hp_work(handle, type, context, _handle_hotplug_event_func);
1166} 923}
1167 924
1168/* 925/*
1169 * Create hotplug slots for the PCI bus. 926 * Create hotplug slots for the PCI bus.
1170 * It should always return 0 to avoid skipping following notifiers. 927 * It should always return 0 to avoid skipping following notifiers.
1171 */ 928 */
1172void acpiphp_enumerate_slots(struct pci_bus *bus, acpi_handle handle) 929void acpiphp_enumerate_slots(struct pci_bus *bus)
1173{ 930{
1174 acpi_handle dummy_handle;
1175 struct acpiphp_bridge *bridge; 931 struct acpiphp_bridge *bridge;
932 acpi_handle handle;
933 acpi_status status;
1176 934
1177 if (acpiphp_disabled) 935 if (acpiphp_disabled)
1178 return; 936 return;
1179 937
1180 if (detect_ejectable_slots(handle) <= 0) 938 handle = ACPI_HANDLE(bus->bridge);
939 if (!handle)
1181 return; 940 return;
1182 941
1183 bridge = kzalloc(sizeof(struct acpiphp_bridge), GFP_KERNEL); 942 bridge = kzalloc(sizeof(struct acpiphp_bridge), GFP_KERNEL);
1184 if (bridge == NULL) { 943 if (!bridge) {
1185 err("out of memory\n"); 944 acpi_handle_err(handle, "No memory for bridge object\n");
1186 return; 945 return;
1187 } 946 }
1188 947
1189 INIT_LIST_HEAD(&bridge->slots); 948 INIT_LIST_HEAD(&bridge->slots);
1190 kref_init(&bridge->ref); 949 kref_init(&bridge->ref);
1191 bridge->handle = handle;
1192 bridge->pci_dev = pci_dev_get(bus->self); 950 bridge->pci_dev = pci_dev_get(bus->self);
1193 bridge->pci_bus = bus; 951 bridge->pci_bus = bus;
1194 952
@@ -1199,31 +957,62 @@ void acpiphp_enumerate_slots(struct pci_bus *bus, acpi_handle handle)
1199 */ 957 */
1200 get_device(&bus->dev); 958 get_device(&bus->dev);
1201 959
1202 if (!pci_is_root_bus(bridge->pci_bus) && 960 if (!pci_is_root_bus(bridge->pci_bus)) {
1203 ACPI_SUCCESS(acpi_get_handle(bridge->handle, 961 struct acpiphp_context *context;
1204 "_EJ0", &dummy_handle))) { 962
1205 dbg("found ejectable p2p bridge\n"); 963 /*
1206 bridge->flags |= BRIDGE_HAS_EJ0; 964 * This bridge should have been registered as a hotplug function
1207 bridge->func = acpiphp_bridge_handle_to_function(handle); 965 * under its parent, so the context has to be there. If not, we
966 * are in deep goo.
967 */
968 mutex_lock(&acpiphp_context_lock);
969 context = acpiphp_get_context(handle);
970 if (WARN_ON(!context)) {
971 mutex_unlock(&acpiphp_context_lock);
972 put_device(&bus->dev);
973 kfree(bridge);
974 return;
975 }
976 bridge->context = context;
977 context->bridge = bridge;
978 /* Get a reference to the parent bridge. */
979 get_bridge(context->func.parent);
980 mutex_unlock(&acpiphp_context_lock);
1208 } 981 }
1209 982
1210 init_bridge_misc(bridge); 983 /* must be added to the list prior to calling register_slot */
984 mutex_lock(&bridge_mutex);
985 list_add(&bridge->list, &bridge_list);
986 mutex_unlock(&bridge_mutex);
987
988 /* register all slot objects under this bridge */
989 status = acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, 1,
990 register_slot, NULL, bridge, NULL);
991 if (ACPI_FAILURE(status)) {
992 acpi_handle_err(handle, "failed to register slots\n");
993 cleanup_bridge(bridge);
994 put_bridge(bridge);
995 }
1211} 996}
1212 997
1213/* Destroy hotplug slots associated with the PCI bus */ 998/* Destroy hotplug slots associated with the PCI bus */
1214void acpiphp_remove_slots(struct pci_bus *bus) 999void acpiphp_remove_slots(struct pci_bus *bus)
1215{ 1000{
1216 struct acpiphp_bridge *bridge, *tmp; 1001 struct acpiphp_bridge *bridge;
1217 1002
1218 if (acpiphp_disabled) 1003 if (acpiphp_disabled)
1219 return; 1004 return;
1220 1005
1221 list_for_each_entry_safe(bridge, tmp, &bridge_list, list) 1006 mutex_lock(&bridge_mutex);
1007 list_for_each_entry(bridge, &bridge_list, list)
1222 if (bridge->pci_bus == bus) { 1008 if (bridge->pci_bus == bus) {
1009 mutex_unlock(&bridge_mutex);
1223 cleanup_bridge(bridge); 1010 cleanup_bridge(bridge);
1224 put_bridge(bridge); 1011 put_bridge(bridge);
1225 break; 1012 return;
1226 } 1013 }
1014
1015 mutex_unlock(&bridge_mutex);
1227} 1016}
1228 1017
1229/** 1018/**
@@ -1232,51 +1021,39 @@ void acpiphp_remove_slots(struct pci_bus *bus)
1232 */ 1021 */
1233int acpiphp_enable_slot(struct acpiphp_slot *slot) 1022int acpiphp_enable_slot(struct acpiphp_slot *slot)
1234{ 1023{
1235 int retval;
1236
1237 mutex_lock(&slot->crit_sect); 1024 mutex_lock(&slot->crit_sect);
1025 /* configure all functions */
1026 if (!(slot->flags & SLOT_ENABLED))
1027 enable_slot(slot);
1238 1028
1239 /* wake up all functions */
1240 retval = power_on_slot(slot);
1241 if (retval)
1242 goto err_exit;
1243
1244 if (get_slot_status(slot) == ACPI_STA_ALL) {
1245 /* configure all functions */
1246 retval = enable_device(slot);
1247 if (retval)
1248 power_off_slot(slot);
1249 } else {
1250 dbg("%s: Slot status is not ACPI_STA_ALL\n", __func__);
1251 power_off_slot(slot);
1252 }
1253
1254 err_exit:
1255 mutex_unlock(&slot->crit_sect); 1029 mutex_unlock(&slot->crit_sect);
1256 return retval; 1030 return 0;
1257} 1031}
1258 1032
1259/** 1033/**
1260 * acpiphp_disable_slot - power off slot 1034 * acpiphp_disable_and_eject_slot - power off and eject slot
1261 * @slot: ACPI PHP slot 1035 * @slot: ACPI PHP slot
1262 */ 1036 */
1263int acpiphp_disable_slot(struct acpiphp_slot *slot) 1037int acpiphp_disable_and_eject_slot(struct acpiphp_slot *slot)
1264{ 1038{
1039 struct acpiphp_func *func;
1265 int retval = 0; 1040 int retval = 0;
1266 1041
1267 mutex_lock(&slot->crit_sect); 1042 mutex_lock(&slot->crit_sect);
1268 1043
1269 /* unconfigure all functions */ 1044 /* unconfigure all functions */
1270 retval = disable_device(slot); 1045 disable_slot(slot);
1271 if (retval) 1046
1272 goto err_exit; 1047 list_for_each_entry(func, &slot->funcs, sibling)
1048 if (func->flags & FUNC_HAS_EJ0) {
1049 acpi_handle handle = func_to_handle(func);
1273 1050
1274 /* power off all functions */ 1051 if (ACPI_FAILURE(acpi_evaluate_ej0(handle)))
1275 retval = power_off_slot(slot); 1052 acpi_handle_err(handle, "_EJ0 failed\n");
1276 if (retval) 1053
1277 goto err_exit; 1054 break;
1055 }
1278 1056
1279 err_exit:
1280 mutex_unlock(&slot->crit_sect); 1057 mutex_unlock(&slot->crit_sect);
1281 return retval; 1058 return retval;
1282} 1059}
@@ -1288,7 +1065,7 @@ int acpiphp_disable_slot(struct acpiphp_slot *slot)
1288 */ 1065 */
1289u8 acpiphp_get_power_status(struct acpiphp_slot *slot) 1066u8 acpiphp_get_power_status(struct acpiphp_slot *slot)
1290{ 1067{
1291 return (slot->flags & SLOT_POWEREDON); 1068 return (slot->flags & SLOT_ENABLED);
1292} 1069}
1293 1070
1294 1071
@@ -1298,11 +1075,7 @@ u8 acpiphp_get_power_status(struct acpiphp_slot *slot)
1298 */ 1075 */
1299u8 acpiphp_get_latch_status(struct acpiphp_slot *slot) 1076u8 acpiphp_get_latch_status(struct acpiphp_slot *slot)
1300{ 1077{
1301 unsigned int sta; 1078 return !(get_slot_status(slot) & ACPI_STA_DEVICE_UI);
1302
1303 sta = get_slot_status(slot);
1304
1305 return (sta & ACPI_STA_DEVICE_UI) ? 0 : 1;
1306} 1079}
1307 1080
1308 1081
@@ -1312,9 +1085,5 @@ u8 acpiphp_get_latch_status(struct acpiphp_slot *slot)
1312 */ 1085 */
1313u8 acpiphp_get_adapter_status(struct acpiphp_slot *slot) 1086u8 acpiphp_get_adapter_status(struct acpiphp_slot *slot)
1314{ 1087{
1315 unsigned int sta; 1088 return !!get_slot_status(slot);
1316
1317 sta = get_slot_status(slot);
1318
1319 return (sta == 0) ? 0 : 1;
1320} 1089}
diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
index c35e8ad6db01..2f5786c8522c 100644
--- a/drivers/pci/hotplug/acpiphp_ibm.c
+++ b/drivers/pci/hotplug/acpiphp_ibm.c
@@ -66,7 +66,7 @@ do { \
66#define IBM_HARDWARE_ID1 "IBM37D0" 66#define IBM_HARDWARE_ID1 "IBM37D0"
67#define IBM_HARDWARE_ID2 "IBM37D4" 67#define IBM_HARDWARE_ID2 "IBM37D4"
68 68
69#define hpslot_to_sun(A) (((struct slot *)((A)->private))->acpi_slot->sun) 69#define hpslot_to_sun(A) (((struct slot *)((A)->private))->sun)
70 70
71/* union apci_descriptor - allows access to the 71/* union apci_descriptor - allows access to the
72 * various device descriptors that are embedded in the 72 * various device descriptors that are embedded in the
@@ -270,7 +270,6 @@ static void ibm_handle_events(acpi_handle handle, u32 event, void *context)
270 270
271 if (subevent == 0x80) { 271 if (subevent == 0x80) {
272 dbg("%s: generationg bus event\n", __func__); 272 dbg("%s: generationg bus event\n", __func__);
273 acpi_bus_generate_proc_event(note->device, note->event, detail);
274 acpi_bus_generate_netlink_event(note->device->pnp.device_class, 273 acpi_bus_generate_netlink_event(note->device->pnp.device_class,
275 dev_name(&note->device->dev), 274 dev_name(&note->device->dev),
276 note->event, detail); 275 note->event, detail);
diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
index 01e264fb50e0..7c29ee4ed0ae 100644
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -210,7 +210,7 @@ static int acpi_pci_set_power_state(struct pci_dev *dev, pci_power_t state)
210 } 210 }
211 211
212 if (!error) 212 if (!error)
213 dev_info(&dev->dev, "power state changed by ACPI to %s\n", 213 dev_dbg(&dev->dev, "power state changed by ACPI to %s\n",
214 acpi_power_state_string(state_conv[state])); 214 acpi_power_state_string(state_conv[state]));
215 215
216 return error; 216 return error;
@@ -290,24 +290,16 @@ static struct pci_platform_pm_ops acpi_pci_platform_pm = {
290 290
291void acpi_pci_add_bus(struct pci_bus *bus) 291void acpi_pci_add_bus(struct pci_bus *bus)
292{ 292{
293 acpi_handle handle = NULL; 293 if (acpi_pci_disabled || !bus->bridge)
294
295 if (bus->bridge)
296 handle = ACPI_HANDLE(bus->bridge);
297 if (acpi_pci_disabled || handle == NULL)
298 return; 294 return;
299 295
300 acpi_pci_slot_enumerate(bus, handle); 296 acpi_pci_slot_enumerate(bus);
301 acpiphp_enumerate_slots(bus, handle); 297 acpiphp_enumerate_slots(bus);
302} 298}
303 299
304void acpi_pci_remove_bus(struct pci_bus *bus) 300void acpi_pci_remove_bus(struct pci_bus *bus)
305{ 301{
306 /* 302 if (acpi_pci_disabled || !bus->bridge)
307 * bus->bridge->acpi_node.handle has already been reset to NULL
308 * when acpi_pci_remove_bus() is called, so don't check ACPI handle.
309 */
310 if (acpi_pci_disabled)
311 return; 303 return;
312 304
313 acpiphp_remove_slots(bus); 305 acpiphp_remove_slots(bus);
diff --git a/drivers/pinctrl/pinctrl-sunxi.c b/drivers/pinctrl/pinctrl-sunxi.c
index c47fd1e5450b..94716c779800 100644
--- a/drivers/pinctrl/pinctrl-sunxi.c
+++ b/drivers/pinctrl/pinctrl-sunxi.c
@@ -278,6 +278,7 @@ static int sunxi_pconf_group_set(struct pinctrl_dev *pctldev,
278{ 278{
279 struct sunxi_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev); 279 struct sunxi_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
280 struct sunxi_pinctrl_group *g = &pctl->groups[group]; 280 struct sunxi_pinctrl_group *g = &pctl->groups[group];
281 unsigned long flags;
281 u32 val, mask; 282 u32 val, mask;
282 u16 strength; 283 u16 strength;
283 u8 dlevel; 284 u8 dlevel;
@@ -295,22 +296,35 @@ static int sunxi_pconf_group_set(struct pinctrl_dev *pctldev,
295 * 3: 40mA 296 * 3: 40mA
296 */ 297 */
297 dlevel = strength / 10 - 1; 298 dlevel = strength / 10 - 1;
299
300 spin_lock_irqsave(&pctl->lock, flags);
301
298 val = readl(pctl->membase + sunxi_dlevel_reg(g->pin)); 302 val = readl(pctl->membase + sunxi_dlevel_reg(g->pin));
299 mask = DLEVEL_PINS_MASK << sunxi_dlevel_offset(g->pin); 303 mask = DLEVEL_PINS_MASK << sunxi_dlevel_offset(g->pin);
300 writel((val & ~mask) | dlevel << sunxi_dlevel_offset(g->pin), 304 writel((val & ~mask) | dlevel << sunxi_dlevel_offset(g->pin),
301 pctl->membase + sunxi_dlevel_reg(g->pin)); 305 pctl->membase + sunxi_dlevel_reg(g->pin));
306
307 spin_unlock_irqrestore(&pctl->lock, flags);
302 break; 308 break;
303 case PIN_CONFIG_BIAS_PULL_UP: 309 case PIN_CONFIG_BIAS_PULL_UP:
310 spin_lock_irqsave(&pctl->lock, flags);
311
304 val = readl(pctl->membase + sunxi_pull_reg(g->pin)); 312 val = readl(pctl->membase + sunxi_pull_reg(g->pin));
305 mask = PULL_PINS_MASK << sunxi_pull_offset(g->pin); 313 mask = PULL_PINS_MASK << sunxi_pull_offset(g->pin);
306 writel((val & ~mask) | 1 << sunxi_pull_offset(g->pin), 314 writel((val & ~mask) | 1 << sunxi_pull_offset(g->pin),
307 pctl->membase + sunxi_pull_reg(g->pin)); 315 pctl->membase + sunxi_pull_reg(g->pin));
316
317 spin_unlock_irqrestore(&pctl->lock, flags);
308 break; 318 break;
309 case PIN_CONFIG_BIAS_PULL_DOWN: 319 case PIN_CONFIG_BIAS_PULL_DOWN:
320 spin_lock_irqsave(&pctl->lock, flags);
321
310 val = readl(pctl->membase + sunxi_pull_reg(g->pin)); 322 val = readl(pctl->membase + sunxi_pull_reg(g->pin));
311 mask = PULL_PINS_MASK << sunxi_pull_offset(g->pin); 323 mask = PULL_PINS_MASK << sunxi_pull_offset(g->pin);
312 writel((val & ~mask) | 2 << sunxi_pull_offset(g->pin), 324 writel((val & ~mask) | 2 << sunxi_pull_offset(g->pin),
313 pctl->membase + sunxi_pull_reg(g->pin)); 325 pctl->membase + sunxi_pull_reg(g->pin));
326
327 spin_unlock_irqrestore(&pctl->lock, flags);
314 break; 328 break;
315 default: 329 default:
316 break; 330 break;
@@ -360,11 +374,17 @@ static void sunxi_pmx_set(struct pinctrl_dev *pctldev,
360 u8 config) 374 u8 config)
361{ 375{
362 struct sunxi_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev); 376 struct sunxi_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
377 unsigned long flags;
378 u32 val, mask;
379
380 spin_lock_irqsave(&pctl->lock, flags);
363 381
364 u32 val = readl(pctl->membase + sunxi_mux_reg(pin)); 382 val = readl(pctl->membase + sunxi_mux_reg(pin));
365 u32 mask = MUX_PINS_MASK << sunxi_mux_offset(pin); 383 mask = MUX_PINS_MASK << sunxi_mux_offset(pin);
366 writel((val & ~mask) | config << sunxi_mux_offset(pin), 384 writel((val & ~mask) | config << sunxi_mux_offset(pin),
367 pctl->membase + sunxi_mux_reg(pin)); 385 pctl->membase + sunxi_mux_reg(pin));
386
387 spin_unlock_irqrestore(&pctl->lock, flags);
368} 388}
369 389
370static int sunxi_pmx_enable(struct pinctrl_dev *pctldev, 390static int sunxi_pmx_enable(struct pinctrl_dev *pctldev,
@@ -464,8 +484,21 @@ static void sunxi_pinctrl_gpio_set(struct gpio_chip *chip,
464 struct sunxi_pinctrl *pctl = dev_get_drvdata(chip->dev); 484 struct sunxi_pinctrl *pctl = dev_get_drvdata(chip->dev);
465 u32 reg = sunxi_data_reg(offset); 485 u32 reg = sunxi_data_reg(offset);
466 u8 index = sunxi_data_offset(offset); 486 u8 index = sunxi_data_offset(offset);
487 unsigned long flags;
488 u32 regval;
489
490 spin_lock_irqsave(&pctl->lock, flags);
491
492 regval = readl(pctl->membase + reg);
467 493
468 writel((value & DATA_PINS_MASK) << index, pctl->membase + reg); 494 if (value)
495 regval |= BIT(index);
496 else
497 regval &= ~(BIT(index));
498
499 writel(regval, pctl->membase + reg);
500
501 spin_unlock_irqrestore(&pctl->lock, flags);
469} 502}
470 503
471static int sunxi_pinctrl_gpio_of_xlate(struct gpio_chip *gc, 504static int sunxi_pinctrl_gpio_of_xlate(struct gpio_chip *gc,
@@ -526,6 +559,8 @@ static int sunxi_pinctrl_irq_set_type(struct irq_data *d,
526 struct sunxi_pinctrl *pctl = irq_data_get_irq_chip_data(d); 559 struct sunxi_pinctrl *pctl = irq_data_get_irq_chip_data(d);
527 u32 reg = sunxi_irq_cfg_reg(d->hwirq); 560 u32 reg = sunxi_irq_cfg_reg(d->hwirq);
528 u8 index = sunxi_irq_cfg_offset(d->hwirq); 561 u8 index = sunxi_irq_cfg_offset(d->hwirq);
562 unsigned long flags;
563 u32 regval;
529 u8 mode; 564 u8 mode;
530 565
531 switch (type) { 566 switch (type) {
@@ -548,7 +583,13 @@ static int sunxi_pinctrl_irq_set_type(struct irq_data *d,
548 return -EINVAL; 583 return -EINVAL;
549 } 584 }
550 585
551 writel((mode & IRQ_CFG_IRQ_MASK) << index, pctl->membase + reg); 586 spin_lock_irqsave(&pctl->lock, flags);
587
588 regval = readl(pctl->membase + reg);
589 regval &= ~IRQ_CFG_IRQ_MASK;
590 writel(regval | (mode << index), pctl->membase + reg);
591
592 spin_unlock_irqrestore(&pctl->lock, flags);
552 593
553 return 0; 594 return 0;
554} 595}
@@ -560,14 +601,19 @@ static void sunxi_pinctrl_irq_mask_ack(struct irq_data *d)
560 u8 ctrl_idx = sunxi_irq_ctrl_offset(d->hwirq); 601 u8 ctrl_idx = sunxi_irq_ctrl_offset(d->hwirq);
561 u32 status_reg = sunxi_irq_status_reg(d->hwirq); 602 u32 status_reg = sunxi_irq_status_reg(d->hwirq);
562 u8 status_idx = sunxi_irq_status_offset(d->hwirq); 603 u8 status_idx = sunxi_irq_status_offset(d->hwirq);
604 unsigned long flags;
563 u32 val; 605 u32 val;
564 606
607 spin_lock_irqsave(&pctl->lock, flags);
608
565 /* Mask the IRQ */ 609 /* Mask the IRQ */
566 val = readl(pctl->membase + ctrl_reg); 610 val = readl(pctl->membase + ctrl_reg);
567 writel(val & ~(1 << ctrl_idx), pctl->membase + ctrl_reg); 611 writel(val & ~(1 << ctrl_idx), pctl->membase + ctrl_reg);
568 612
569 /* Clear the IRQ */ 613 /* Clear the IRQ */
570 writel(1 << status_idx, pctl->membase + status_reg); 614 writel(1 << status_idx, pctl->membase + status_reg);
615
616 spin_unlock_irqrestore(&pctl->lock, flags);
571} 617}
572 618
573static void sunxi_pinctrl_irq_mask(struct irq_data *d) 619static void sunxi_pinctrl_irq_mask(struct irq_data *d)
@@ -575,11 +621,16 @@ static void sunxi_pinctrl_irq_mask(struct irq_data *d)
575 struct sunxi_pinctrl *pctl = irq_data_get_irq_chip_data(d); 621 struct sunxi_pinctrl *pctl = irq_data_get_irq_chip_data(d);
576 u32 reg = sunxi_irq_ctrl_reg(d->hwirq); 622 u32 reg = sunxi_irq_ctrl_reg(d->hwirq);
577 u8 idx = sunxi_irq_ctrl_offset(d->hwirq); 623 u8 idx = sunxi_irq_ctrl_offset(d->hwirq);
624 unsigned long flags;
578 u32 val; 625 u32 val;
579 626
627 spin_lock_irqsave(&pctl->lock, flags);
628
580 /* Mask the IRQ */ 629 /* Mask the IRQ */
581 val = readl(pctl->membase + reg); 630 val = readl(pctl->membase + reg);
582 writel(val & ~(1 << idx), pctl->membase + reg); 631 writel(val & ~(1 << idx), pctl->membase + reg);
632
633 spin_unlock_irqrestore(&pctl->lock, flags);
583} 634}
584 635
585static void sunxi_pinctrl_irq_unmask(struct irq_data *d) 636static void sunxi_pinctrl_irq_unmask(struct irq_data *d)
@@ -588,6 +639,7 @@ static void sunxi_pinctrl_irq_unmask(struct irq_data *d)
588 struct sunxi_desc_function *func; 639 struct sunxi_desc_function *func;
589 u32 reg = sunxi_irq_ctrl_reg(d->hwirq); 640 u32 reg = sunxi_irq_ctrl_reg(d->hwirq);
590 u8 idx = sunxi_irq_ctrl_offset(d->hwirq); 641 u8 idx = sunxi_irq_ctrl_offset(d->hwirq);
642 unsigned long flags;
591 u32 val; 643 u32 val;
592 644
593 func = sunxi_pinctrl_desc_find_function_by_pin(pctl, 645 func = sunxi_pinctrl_desc_find_function_by_pin(pctl,
@@ -597,9 +649,13 @@ static void sunxi_pinctrl_irq_unmask(struct irq_data *d)
597 /* Change muxing to INT mode */ 649 /* Change muxing to INT mode */
598 sunxi_pmx_set(pctl->pctl_dev, pctl->irq_array[d->hwirq], func->muxval); 650 sunxi_pmx_set(pctl->pctl_dev, pctl->irq_array[d->hwirq], func->muxval);
599 651
652 spin_lock_irqsave(&pctl->lock, flags);
653
600 /* Unmask the IRQ */ 654 /* Unmask the IRQ */
601 val = readl(pctl->membase + reg); 655 val = readl(pctl->membase + reg);
602 writel(val | (1 << idx), pctl->membase + reg); 656 writel(val | (1 << idx), pctl->membase + reg);
657
658 spin_unlock_irqrestore(&pctl->lock, flags);
603} 659}
604 660
605static struct irq_chip sunxi_pinctrl_irq_chip = { 661static struct irq_chip sunxi_pinctrl_irq_chip = {
@@ -752,6 +808,8 @@ static int sunxi_pinctrl_probe(struct platform_device *pdev)
752 return -ENOMEM; 808 return -ENOMEM;
753 platform_set_drvdata(pdev, pctl); 809 platform_set_drvdata(pdev, pctl);
754 810
811 spin_lock_init(&pctl->lock);
812
755 pctl->membase = of_iomap(node, 0); 813 pctl->membase = of_iomap(node, 0);
756 if (!pctl->membase) 814 if (!pctl->membase)
757 return -ENOMEM; 815 return -ENOMEM;
diff --git a/drivers/pinctrl/pinctrl-sunxi.h b/drivers/pinctrl/pinctrl-sunxi.h
index d68047d8f699..01c494f8a14f 100644
--- a/drivers/pinctrl/pinctrl-sunxi.h
+++ b/drivers/pinctrl/pinctrl-sunxi.h
@@ -14,6 +14,7 @@
14#define __PINCTRL_SUNXI_H 14#define __PINCTRL_SUNXI_H
15 15
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/spinlock.h>
17 18
18#define PA_BASE 0 19#define PA_BASE 0
19#define PB_BASE 32 20#define PB_BASE 32
@@ -407,6 +408,7 @@ struct sunxi_pinctrl {
407 unsigned ngroups; 408 unsigned ngroups;
408 int irq; 409 int irq;
409 int irq_array[SUNXI_IRQ_NUMBER]; 410 int irq_array[SUNXI_IRQ_NUMBER];
411 spinlock_t lock;
410 struct pinctrl_dev *pctl_dev; 412 struct pinctrl_dev *pctl_dev;
411}; 413};
412 414
diff --git a/drivers/platform/olpc/olpc-ec.c b/drivers/platform/olpc/olpc-ec.c
index 0f9f8596b300..f9119525f557 100644
--- a/drivers/platform/olpc/olpc-ec.c
+++ b/drivers/platform/olpc/olpc-ec.c
@@ -330,7 +330,7 @@ static int __init olpc_ec_init_module(void)
330 return platform_driver_register(&olpc_ec_plat_driver); 330 return platform_driver_register(&olpc_ec_plat_driver);
331} 331}
332 332
333module_init(olpc_ec_init_module); 333arch_initcall(olpc_ec_init_module);
334 334
335MODULE_AUTHOR("Andres Salomon <dilinger@queued.net>"); 335MODULE_AUTHOR("Andres Salomon <dilinger@queued.net>");
336MODULE_LICENSE("GPL"); 336MODULE_LICENSE("GPL");
diff --git a/drivers/platform/x86/asus-laptop.c b/drivers/platform/x86/asus-laptop.c
index 8e268da6fdbd..0e9c169b42f8 100644
--- a/drivers/platform/x86/asus-laptop.c
+++ b/drivers/platform/x86/asus-laptop.c
@@ -1543,7 +1543,6 @@ static void asus_acpi_notify(struct acpi_device *device, u32 event)
1543 1543
1544 /* TODO Find a better way to handle events count. */ 1544 /* TODO Find a better way to handle events count. */
1545 count = asus->event_count[event % 128]++; 1545 count = asus->event_count[event % 128]++;
1546 acpi_bus_generate_proc_event(asus->device, event, count);
1547 acpi_bus_generate_netlink_event(asus->device->pnp.device_class, 1546 acpi_bus_generate_netlink_event(asus->device->pnp.device_class,
1548 dev_name(&asus->device->dev), event, 1547 dev_name(&asus->device->dev), event,
1549 count); 1548 count);
diff --git a/drivers/platform/x86/eeepc-laptop.c b/drivers/platform/x86/eeepc-laptop.c
index 5d26e70bed6c..a6afd4108beb 100644
--- a/drivers/platform/x86/eeepc-laptop.c
+++ b/drivers/platform/x86/eeepc-laptop.c
@@ -1269,7 +1269,6 @@ static void eeepc_acpi_notify(struct acpi_device *device, u32 event)
1269 if (event > ACPI_MAX_SYS_NOTIFY) 1269 if (event > ACPI_MAX_SYS_NOTIFY)
1270 return; 1270 return;
1271 count = eeepc->event_count[event % 128]++; 1271 count = eeepc->event_count[event % 128]++;
1272 acpi_bus_generate_proc_event(device, event, count);
1273 acpi_bus_generate_netlink_event(device->pnp.device_class, 1272 acpi_bus_generate_netlink_event(device->pnp.device_class,
1274 dev_name(&device->dev), event, 1273 dev_name(&device->dev), event,
1275 count); 1274 count);
diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c
index 1c9386e7c58c..52b8a97efde1 100644
--- a/drivers/platform/x86/fujitsu-laptop.c
+++ b/drivers/platform/x86/fujitsu-laptop.c
@@ -773,8 +773,6 @@ static void acpi_fujitsu_notify(struct acpi_device *device, u32 event)
773 else 773 else
774 set_lcd_level(newb); 774 set_lcd_level(newb);
775 } 775 }
776 acpi_bus_generate_proc_event(fujitsu->dev,
777 ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS, 0);
778 keycode = KEY_BRIGHTNESSUP; 776 keycode = KEY_BRIGHTNESSUP;
779 } else if (oldb > newb) { 777 } else if (oldb > newb) {
780 if (disable_brightness_adjust != 1) { 778 if (disable_brightness_adjust != 1) {
@@ -783,8 +781,6 @@ static void acpi_fujitsu_notify(struct acpi_device *device, u32 event)
783 else 781 else
784 set_lcd_level(newb); 782 set_lcd_level(newb);
785 } 783 }
786 acpi_bus_generate_proc_event(fujitsu->dev,
787 ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS, 0);
788 keycode = KEY_BRIGHTNESSDOWN; 784 keycode = KEY_BRIGHTNESSDOWN;
789 } 785 }
790 break; 786 break;
diff --git a/drivers/platform/x86/hp-wmi.c b/drivers/platform/x86/hp-wmi.c
index 97bb05edcb5a..d6970f47ae72 100644
--- a/drivers/platform/x86/hp-wmi.c
+++ b/drivers/platform/x86/hp-wmi.c
@@ -53,7 +53,6 @@ MODULE_ALIAS("wmi:5FB7F034-2C63-45e9-BE91-3D44E2C707E4");
53#define HPWMI_ALS_QUERY 0x3 53#define HPWMI_ALS_QUERY 0x3
54#define HPWMI_HARDWARE_QUERY 0x4 54#define HPWMI_HARDWARE_QUERY 0x4
55#define HPWMI_WIRELESS_QUERY 0x5 55#define HPWMI_WIRELESS_QUERY 0x5
56#define HPWMI_BIOS_QUERY 0x9
57#define HPWMI_HOTKEY_QUERY 0xc 56#define HPWMI_HOTKEY_QUERY 0xc
58#define HPWMI_WIRELESS2_QUERY 0x1b 57#define HPWMI_WIRELESS2_QUERY 0x1b
59#define HPWMI_POSTCODEERROR_QUERY 0x2a 58#define HPWMI_POSTCODEERROR_QUERY 0x2a
@@ -293,19 +292,6 @@ static int hp_wmi_tablet_state(void)
293 return (state & 0x4) ? 1 : 0; 292 return (state & 0x4) ? 1 : 0;
294} 293}
295 294
296static int hp_wmi_enable_hotkeys(void)
297{
298 int ret;
299 int query = 0x6e;
300
301 ret = hp_wmi_perform_query(HPWMI_BIOS_QUERY, 1, &query, sizeof(query),
302 0);
303
304 if (ret)
305 return -EINVAL;
306 return 0;
307}
308
309static int hp_wmi_set_block(void *data, bool blocked) 295static int hp_wmi_set_block(void *data, bool blocked)
310{ 296{
311 enum hp_wmi_radio r = (enum hp_wmi_radio) data; 297 enum hp_wmi_radio r = (enum hp_wmi_radio) data;
@@ -1009,8 +995,6 @@ static int __init hp_wmi_init(void)
1009 err = hp_wmi_input_setup(); 995 err = hp_wmi_input_setup();
1010 if (err) 996 if (err)
1011 return err; 997 return err;
1012
1013 hp_wmi_enable_hotkeys();
1014 } 998 }
1015 999
1016 if (bios_capable) { 1000 if (bios_capable) {
diff --git a/drivers/platform/x86/panasonic-laptop.c b/drivers/platform/x86/panasonic-laptop.c
index 4add9a31bf60..984253da365d 100644
--- a/drivers/platform/x86/panasonic-laptop.c
+++ b/drivers/platform/x86/panasonic-laptop.c
@@ -464,9 +464,6 @@ static void acpi_pcc_generate_keyinput(struct pcc_acpi *pcc)
464 "error getting hotkey status\n")); 464 "error getting hotkey status\n"));
465 return; 465 return;
466 } 466 }
467
468 acpi_bus_generate_proc_event(pcc->device, HKEY_NOTIFY, result);
469
470 if (!sparse_keymap_report_event(hotk_input_dev, 467 if (!sparse_keymap_report_event(hotk_input_dev,
471 result & 0xf, result & 0x80, false)) 468 result & 0xf, result & 0x80, false))
472 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 469 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
index 2ac045f27f10..d3fd52036fd6 100644
--- a/drivers/platform/x86/sony-laptop.c
+++ b/drivers/platform/x86/sony-laptop.c
@@ -1275,9 +1275,6 @@ static void sony_nc_notify(struct acpi_device *device, u32 event)
1275 ev_type = HOTKEY; 1275 ev_type = HOTKEY;
1276 sony_laptop_report_input_event(real_ev); 1276 sony_laptop_report_input_event(real_ev);
1277 } 1277 }
1278
1279 acpi_bus_generate_proc_event(sony_nc_acpi_device, ev_type, real_ev);
1280
1281 acpi_bus_generate_netlink_event(sony_nc_acpi_device->pnp.device_class, 1278 acpi_bus_generate_netlink_event(sony_nc_acpi_device->pnp.device_class,
1282 dev_name(&sony_nc_acpi_device->dev), ev_type, real_ev); 1279 dev_name(&sony_nc_acpi_device->dev), ev_type, real_ev);
1283} 1280}
@@ -2440,7 +2437,10 @@ static ssize_t sony_nc_gfx_switch_status_show(struct device *dev,
2440 if (pos < 0) 2437 if (pos < 0)
2441 return pos; 2438 return pos;
2442 2439
2443 return snprintf(buffer, PAGE_SIZE, "%s\n", pos ? "speed" : "stamina"); 2440 return snprintf(buffer, PAGE_SIZE, "%s\n",
2441 pos == SPEED ? "speed" :
2442 pos == STAMINA ? "stamina" :
2443 pos == AUTO ? "auto" : "unknown");
2444} 2444}
2445 2445
2446static int sony_nc_gfx_switch_setup(struct platform_device *pd, 2446static int sony_nc_gfx_switch_setup(struct platform_device *pd,
@@ -4243,7 +4243,6 @@ static irqreturn_t sony_pic_irq(int irq, void *dev_id)
4243 4243
4244found: 4244found:
4245 sony_laptop_report_input_event(device_event); 4245 sony_laptop_report_input_event(device_event);
4246 acpi_bus_generate_proc_event(dev->acpi_dev, 1, device_event);
4247 sonypi_compat_report_event(device_event); 4246 sonypi_compat_report_event(device_event);
4248 return IRQ_HANDLED; 4247 return IRQ_HANDLED;
4249} 4248}
@@ -4320,7 +4319,8 @@ static int sony_pic_add(struct acpi_device *device)
4320 goto err_free_resources; 4319 goto err_free_resources;
4321 } 4320 }
4322 4321
4323 if (sonypi_compat_init()) 4322 result = sonypi_compat_init();
4323 if (result)
4324 goto err_remove_input; 4324 goto err_remove_input;
4325 4325
4326 /* request io port */ 4326 /* request io port */
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index 54d31c0a9840..be67e5e28d18 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -2022,8 +2022,6 @@ static u32 hotkey_driver_mask; /* events needed by the driver */
2022static u32 hotkey_user_mask; /* events visible to userspace */ 2022static u32 hotkey_user_mask; /* events visible to userspace */
2023static u32 hotkey_acpi_mask; /* events enabled in firmware */ 2023static u32 hotkey_acpi_mask; /* events enabled in firmware */
2024 2024
2025static unsigned int hotkey_report_mode;
2026
2027static u16 *hotkey_keycode_map; 2025static u16 *hotkey_keycode_map;
2028 2026
2029static struct attribute_set *hotkey_dev_attributes; 2027static struct attribute_set *hotkey_dev_attributes;
@@ -2282,10 +2280,6 @@ static struct tp_acpi_drv_struct ibm_hotkey_acpidriver;
2282static void tpacpi_hotkey_send_key(unsigned int scancode) 2280static void tpacpi_hotkey_send_key(unsigned int scancode)
2283{ 2281{
2284 tpacpi_input_send_key_masked(scancode); 2282 tpacpi_input_send_key_masked(scancode);
2285 if (hotkey_report_mode < 2) {
2286 acpi_bus_generate_proc_event(ibm_hotkey_acpidriver.device,
2287 0x80, TP_HKEY_EV_HOTKEY_BASE + scancode);
2288 }
2289} 2283}
2290 2284
2291static void hotkey_read_nvram(struct tp_nvram_state *n, const u32 m) 2285static void hotkey_read_nvram(struct tp_nvram_state *n, const u32 m)
@@ -2882,18 +2876,6 @@ static void hotkey_tablet_mode_notify_change(void)
2882 "hotkey_tablet_mode"); 2876 "hotkey_tablet_mode");
2883} 2877}
2884 2878
2885/* sysfs hotkey report_mode -------------------------------------------- */
2886static ssize_t hotkey_report_mode_show(struct device *dev,
2887 struct device_attribute *attr,
2888 char *buf)
2889{
2890 return snprintf(buf, PAGE_SIZE, "%d\n",
2891 (hotkey_report_mode != 0) ? hotkey_report_mode : 1);
2892}
2893
2894static struct device_attribute dev_attr_hotkey_report_mode =
2895 __ATTR(hotkey_report_mode, S_IRUGO, hotkey_report_mode_show, NULL);
2896
2897/* sysfs wakeup reason (pollable) -------------------------------------- */ 2879/* sysfs wakeup reason (pollable) -------------------------------------- */
2898static ssize_t hotkey_wakeup_reason_show(struct device *dev, 2880static ssize_t hotkey_wakeup_reason_show(struct device *dev,
2899 struct device_attribute *attr, 2881 struct device_attribute *attr,
@@ -2935,7 +2917,6 @@ static struct attribute *hotkey_attributes[] __initdata = {
2935 &dev_attr_hotkey_enable.attr, 2917 &dev_attr_hotkey_enable.attr,
2936 &dev_attr_hotkey_bios_enabled.attr, 2918 &dev_attr_hotkey_bios_enabled.attr,
2937 &dev_attr_hotkey_bios_mask.attr, 2919 &dev_attr_hotkey_bios_mask.attr,
2938 &dev_attr_hotkey_report_mode.attr,
2939 &dev_attr_hotkey_wakeup_reason.attr, 2920 &dev_attr_hotkey_wakeup_reason.attr,
2940 &dev_attr_hotkey_wakeup_hotunplug_complete.attr, 2921 &dev_attr_hotkey_wakeup_hotunplug_complete.attr,
2941 &dev_attr_hotkey_mask.attr, 2922 &dev_attr_hotkey_mask.attr,
@@ -3439,11 +3420,6 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
3439 "initial masks: user=0x%08x, fw=0x%08x, poll=0x%08x\n", 3420 "initial masks: user=0x%08x, fw=0x%08x, poll=0x%08x\n",
3440 hotkey_user_mask, hotkey_acpi_mask, hotkey_source_mask); 3421 hotkey_user_mask, hotkey_acpi_mask, hotkey_source_mask);
3441 3422
3442 dbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_HKEY,
3443 "legacy ibm/hotkey event reporting over procfs %s\n",
3444 (hotkey_report_mode < 2) ?
3445 "enabled" : "disabled");
3446
3447 tpacpi_inputdev->open = &hotkey_inputdev_open; 3423 tpacpi_inputdev->open = &hotkey_inputdev_open;
3448 tpacpi_inputdev->close = &hotkey_inputdev_close; 3424 tpacpi_inputdev->close = &hotkey_inputdev_close;
3449 3425
@@ -3737,13 +3713,6 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event)
3737 "event happened to %s\n", TPACPI_MAIL); 3713 "event happened to %s\n", TPACPI_MAIL);
3738 } 3714 }
3739 3715
3740 /* Legacy events */
3741 if (!ignore_acpi_ev &&
3742 (send_acpi_ev || hotkey_report_mode < 2)) {
3743 acpi_bus_generate_proc_event(ibm->acpi->device,
3744 event, hkey);
3745 }
3746
3747 /* netlink events */ 3716 /* netlink events */
3748 if (!ignore_acpi_ev && send_acpi_ev) { 3717 if (!ignore_acpi_ev && send_acpi_ev) {
3749 acpi_bus_generate_netlink_event( 3718 acpi_bus_generate_netlink_event(
@@ -8840,11 +8809,6 @@ module_param(brightness_enable, uint, 0444);
8840MODULE_PARM_DESC(brightness_enable, 8809MODULE_PARM_DESC(brightness_enable,
8841 "Enables backlight control when 1, disables when 0"); 8810 "Enables backlight control when 1, disables when 0");
8842 8811
8843module_param(hotkey_report_mode, uint, 0444);
8844MODULE_PARM_DESC(hotkey_report_mode,
8845 "used for backwards compatibility with userspace, "
8846 "see documentation");
8847
8848#ifdef CONFIG_THINKPAD_ACPI_ALSA_SUPPORT 8812#ifdef CONFIG_THINKPAD_ACPI_ALSA_SUPPORT
8849module_param_named(volume_mode, volume_mode, uint, 0444); 8813module_param_named(volume_mode, volume_mode, uint, 0444);
8850MODULE_PARM_DESC(volume_mode, 8814MODULE_PARM_DESC(volume_mode,
@@ -8975,10 +8939,6 @@ static int __init thinkpad_acpi_module_init(void)
8975 8939
8976 tpacpi_lifecycle = TPACPI_LIFE_INIT; 8940 tpacpi_lifecycle = TPACPI_LIFE_INIT;
8977 8941
8978 /* Parameter checking */
8979 if (hotkey_report_mode > 2)
8980 return -EINVAL;
8981
8982 /* Driver-level probe */ 8942 /* Driver-level probe */
8983 8943
8984 ret = get_thinkpad_model_data(&thinkpad_id); 8944 ret = get_thinkpad_model_data(&thinkpad_id);
diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c
index 55cd459a3908..34049b0b4c73 100644
--- a/drivers/pnp/pnpacpi/core.c
+++ b/drivers/pnp/pnpacpi/core.c
@@ -131,7 +131,7 @@ static int pnpacpi_disable_resources(struct pnp_dev *dev)
131 /* acpi_unregister_gsi(pnp_irq(dev, 0)); */ 131 /* acpi_unregister_gsi(pnp_irq(dev, 0)); */
132 ret = 0; 132 ret = 0;
133 if (acpi_bus_power_manageable(handle)) 133 if (acpi_bus_power_manageable(handle))
134 acpi_bus_set_power(handle, ACPI_STATE_D3); 134 acpi_bus_set_power(handle, ACPI_STATE_D3_COLD);
135 /* continue even if acpi_bus_set_power() fails */ 135 /* continue even if acpi_bus_set_power() fails */
136 if (ACPI_FAILURE(acpi_evaluate_object(handle, "_DIS", NULL, NULL))) 136 if (ACPI_FAILURE(acpi_evaluate_object(handle, "_DIS", NULL, NULL)))
137 ret = -ENODEV; 137 ret = -ENODEV;
@@ -174,10 +174,10 @@ static int pnpacpi_suspend(struct pnp_dev *dev, pm_message_t state)
174 174
175 if (acpi_bus_power_manageable(handle)) { 175 if (acpi_bus_power_manageable(handle)) {
176 int power_state = acpi_pm_device_sleep_state(&dev->dev, NULL, 176 int power_state = acpi_pm_device_sleep_state(&dev->dev, NULL,
177 ACPI_STATE_D3); 177 ACPI_STATE_D3_COLD);
178 if (power_state < 0) 178 if (power_state < 0)
179 power_state = (state.event == PM_EVENT_ON) ? 179 power_state = (state.event == PM_EVENT_ON) ?
180 ACPI_STATE_D0 : ACPI_STATE_D3; 180 ACPI_STATE_D0 : ACPI_STATE_D3_COLD;
181 181
182 /* 182 /*
183 * acpi_bus_set_power() often fails (keyboard port can't be 183 * acpi_bus_set_power() often fails (keyboard port can't be
diff --git a/drivers/rtc/rtc-stmp3xxx.c b/drivers/rtc/rtc-stmp3xxx.c
index 767fee2ab340..26019531db15 100644
--- a/drivers/rtc/rtc-stmp3xxx.c
+++ b/drivers/rtc/rtc-stmp3xxx.c
@@ -23,6 +23,7 @@
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/platform_device.h> 24#include <linux/platform_device.h>
25#include <linux/interrupt.h> 25#include <linux/interrupt.h>
26#include <linux/delay.h>
26#include <linux/rtc.h> 27#include <linux/rtc.h>
27#include <linux/slab.h> 28#include <linux/slab.h>
28#include <linux/of_device.h> 29#include <linux/of_device.h>
@@ -119,24 +120,39 @@ static void stmp3xxx_wdt_register(struct platform_device *rtc_pdev)
119} 120}
120#endif /* CONFIG_STMP3XXX_RTC_WATCHDOG */ 121#endif /* CONFIG_STMP3XXX_RTC_WATCHDOG */
121 122
122static void stmp3xxx_wait_time(struct stmp3xxx_rtc_data *rtc_data) 123static int stmp3xxx_wait_time(struct stmp3xxx_rtc_data *rtc_data)
123{ 124{
125 int timeout = 5000; /* 3ms according to i.MX28 Ref Manual */
124 /* 126 /*
125 * The datasheet doesn't say which way round the 127 * The i.MX28 Applications Processor Reference Manual, Rev. 1, 2010
126 * NEW_REGS/STALE_REGS bitfields go. In fact it's 0x1=P0, 128 * states:
127 * 0x2=P1, .., 0x20=P5, 0x40=ALARM, 0x80=SECONDS 129 * | The order in which registers are updated is
130 * | Persistent 0, 1, 2, 3, 4, 5, Alarm, Seconds.
131 * | (This list is in bitfield order, from LSB to MSB, as they would
132 * | appear in the STALE_REGS and NEW_REGS bitfields of the HW_RTC_STAT
133 * | register. For example, the Seconds register corresponds to
134 * | STALE_REGS or NEW_REGS containing 0x80.)
128 */ 135 */
129 while (readl(rtc_data->io + STMP3XXX_RTC_STAT) & 136 do {
130 (0x80 << STMP3XXX_RTC_STAT_STALE_SHIFT)) 137 if (!(readl(rtc_data->io + STMP3XXX_RTC_STAT) &
131 cpu_relax(); 138 (0x80 << STMP3XXX_RTC_STAT_STALE_SHIFT)))
139 return 0;
140 udelay(1);
141 } while (--timeout > 0);
142 return (readl(rtc_data->io + STMP3XXX_RTC_STAT) &
143 (0x80 << STMP3XXX_RTC_STAT_STALE_SHIFT)) ? -ETIME : 0;
132} 144}
133 145
134/* Time read/write */ 146/* Time read/write */
135static int stmp3xxx_rtc_gettime(struct device *dev, struct rtc_time *rtc_tm) 147static int stmp3xxx_rtc_gettime(struct device *dev, struct rtc_time *rtc_tm)
136{ 148{
149 int ret;
137 struct stmp3xxx_rtc_data *rtc_data = dev_get_drvdata(dev); 150 struct stmp3xxx_rtc_data *rtc_data = dev_get_drvdata(dev);
138 151
139 stmp3xxx_wait_time(rtc_data); 152 ret = stmp3xxx_wait_time(rtc_data);
153 if (ret)
154 return ret;
155
140 rtc_time_to_tm(readl(rtc_data->io + STMP3XXX_RTC_SECONDS), rtc_tm); 156 rtc_time_to_tm(readl(rtc_data->io + STMP3XXX_RTC_SECONDS), rtc_tm);
141 return 0; 157 return 0;
142} 158}
@@ -146,8 +162,7 @@ static int stmp3xxx_rtc_set_mmss(struct device *dev, unsigned long t)
146 struct stmp3xxx_rtc_data *rtc_data = dev_get_drvdata(dev); 162 struct stmp3xxx_rtc_data *rtc_data = dev_get_drvdata(dev);
147 163
148 writel(t, rtc_data->io + STMP3XXX_RTC_SECONDS); 164 writel(t, rtc_data->io + STMP3XXX_RTC_SECONDS);
149 stmp3xxx_wait_time(rtc_data); 165 return stmp3xxx_wait_time(rtc_data);
150 return 0;
151} 166}
152 167
153/* interrupt(s) handler */ 168/* interrupt(s) handler */
diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c
index 17150a778984..451bf99582ff 100644
--- a/drivers/s390/block/dasd.c
+++ b/drivers/s390/block/dasd.c
@@ -2392,6 +2392,12 @@ int dasd_sleep_on_immediatly(struct dasd_ccw_req *cqr)
2392 rc = cqr->intrc; 2392 rc = cqr->intrc;
2393 else 2393 else
2394 rc = -EIO; 2394 rc = -EIO;
2395
2396 /* kick tasklets */
2397 dasd_schedule_device_bh(device);
2398 if (device->block)
2399 dasd_schedule_block_bh(device->block);
2400
2395 return rc; 2401 return rc;
2396} 2402}
2397 2403
diff --git a/drivers/s390/scsi/zfcp_erp.c b/drivers/s390/scsi/zfcp_erp.c
index 1d4c8fe72752..c82fe65c4128 100644
--- a/drivers/s390/scsi/zfcp_erp.c
+++ b/drivers/s390/scsi/zfcp_erp.c
@@ -102,10 +102,13 @@ static void zfcp_erp_action_dismiss_port(struct zfcp_port *port)
102 102
103 if (atomic_read(&port->status) & ZFCP_STATUS_COMMON_ERP_INUSE) 103 if (atomic_read(&port->status) & ZFCP_STATUS_COMMON_ERP_INUSE)
104 zfcp_erp_action_dismiss(&port->erp_action); 104 zfcp_erp_action_dismiss(&port->erp_action);
105 else 105 else {
106 shost_for_each_device(sdev, port->adapter->scsi_host) 106 spin_lock(port->adapter->scsi_host->host_lock);
107 __shost_for_each_device(sdev, port->adapter->scsi_host)
107 if (sdev_to_zfcp(sdev)->port == port) 108 if (sdev_to_zfcp(sdev)->port == port)
108 zfcp_erp_action_dismiss_lun(sdev); 109 zfcp_erp_action_dismiss_lun(sdev);
110 spin_unlock(port->adapter->scsi_host->host_lock);
111 }
109} 112}
110 113
111static void zfcp_erp_action_dismiss_adapter(struct zfcp_adapter *adapter) 114static void zfcp_erp_action_dismiss_adapter(struct zfcp_adapter *adapter)
@@ -592,9 +595,11 @@ static void _zfcp_erp_lun_reopen_all(struct zfcp_port *port, int clear,
592{ 595{
593 struct scsi_device *sdev; 596 struct scsi_device *sdev;
594 597
595 shost_for_each_device(sdev, port->adapter->scsi_host) 598 spin_lock(port->adapter->scsi_host->host_lock);
599 __shost_for_each_device(sdev, port->adapter->scsi_host)
596 if (sdev_to_zfcp(sdev)->port == port) 600 if (sdev_to_zfcp(sdev)->port == port)
597 _zfcp_erp_lun_reopen(sdev, clear, id, 0); 601 _zfcp_erp_lun_reopen(sdev, clear, id, 0);
602 spin_unlock(port->adapter->scsi_host->host_lock);
598} 603}
599 604
600static void zfcp_erp_strategy_followup_failed(struct zfcp_erp_action *act) 605static void zfcp_erp_strategy_followup_failed(struct zfcp_erp_action *act)
@@ -1434,8 +1439,10 @@ void zfcp_erp_set_adapter_status(struct zfcp_adapter *adapter, u32 mask)
1434 atomic_set_mask(common_mask, &port->status); 1439 atomic_set_mask(common_mask, &port->status);
1435 read_unlock_irqrestore(&adapter->port_list_lock, flags); 1440 read_unlock_irqrestore(&adapter->port_list_lock, flags);
1436 1441
1437 shost_for_each_device(sdev, adapter->scsi_host) 1442 spin_lock_irqsave(adapter->scsi_host->host_lock, flags);
1443 __shost_for_each_device(sdev, adapter->scsi_host)
1438 atomic_set_mask(common_mask, &sdev_to_zfcp(sdev)->status); 1444 atomic_set_mask(common_mask, &sdev_to_zfcp(sdev)->status);
1445 spin_unlock_irqrestore(adapter->scsi_host->host_lock, flags);
1439} 1446}
1440 1447
1441/** 1448/**
@@ -1469,11 +1476,13 @@ void zfcp_erp_clear_adapter_status(struct zfcp_adapter *adapter, u32 mask)
1469 } 1476 }
1470 read_unlock_irqrestore(&adapter->port_list_lock, flags); 1477 read_unlock_irqrestore(&adapter->port_list_lock, flags);
1471 1478
1472 shost_for_each_device(sdev, adapter->scsi_host) { 1479 spin_lock_irqsave(adapter->scsi_host->host_lock, flags);
1480 __shost_for_each_device(sdev, adapter->scsi_host) {
1473 atomic_clear_mask(common_mask, &sdev_to_zfcp(sdev)->status); 1481 atomic_clear_mask(common_mask, &sdev_to_zfcp(sdev)->status);
1474 if (clear_counter) 1482 if (clear_counter)
1475 atomic_set(&sdev_to_zfcp(sdev)->erp_counter, 0); 1483 atomic_set(&sdev_to_zfcp(sdev)->erp_counter, 0);
1476 } 1484 }
1485 spin_unlock_irqrestore(adapter->scsi_host->host_lock, flags);
1477} 1486}
1478 1487
1479/** 1488/**
@@ -1487,16 +1496,19 @@ void zfcp_erp_set_port_status(struct zfcp_port *port, u32 mask)
1487{ 1496{
1488 struct scsi_device *sdev; 1497 struct scsi_device *sdev;
1489 u32 common_mask = mask & ZFCP_COMMON_FLAGS; 1498 u32 common_mask = mask & ZFCP_COMMON_FLAGS;
1499 unsigned long flags;
1490 1500
1491 atomic_set_mask(mask, &port->status); 1501 atomic_set_mask(mask, &port->status);
1492 1502
1493 if (!common_mask) 1503 if (!common_mask)
1494 return; 1504 return;
1495 1505
1496 shost_for_each_device(sdev, port->adapter->scsi_host) 1506 spin_lock_irqsave(port->adapter->scsi_host->host_lock, flags);
1507 __shost_for_each_device(sdev, port->adapter->scsi_host)
1497 if (sdev_to_zfcp(sdev)->port == port) 1508 if (sdev_to_zfcp(sdev)->port == port)
1498 atomic_set_mask(common_mask, 1509 atomic_set_mask(common_mask,
1499 &sdev_to_zfcp(sdev)->status); 1510 &sdev_to_zfcp(sdev)->status);
1511 spin_unlock_irqrestore(port->adapter->scsi_host->host_lock, flags);
1500} 1512}
1501 1513
1502/** 1514/**
@@ -1511,6 +1523,7 @@ void zfcp_erp_clear_port_status(struct zfcp_port *port, u32 mask)
1511 struct scsi_device *sdev; 1523 struct scsi_device *sdev;
1512 u32 common_mask = mask & ZFCP_COMMON_FLAGS; 1524 u32 common_mask = mask & ZFCP_COMMON_FLAGS;
1513 u32 clear_counter = mask & ZFCP_STATUS_COMMON_ERP_FAILED; 1525 u32 clear_counter = mask & ZFCP_STATUS_COMMON_ERP_FAILED;
1526 unsigned long flags;
1514 1527
1515 atomic_clear_mask(mask, &port->status); 1528 atomic_clear_mask(mask, &port->status);
1516 1529
@@ -1520,13 +1533,15 @@ void zfcp_erp_clear_port_status(struct zfcp_port *port, u32 mask)
1520 if (clear_counter) 1533 if (clear_counter)
1521 atomic_set(&port->erp_counter, 0); 1534 atomic_set(&port->erp_counter, 0);
1522 1535
1523 shost_for_each_device(sdev, port->adapter->scsi_host) 1536 spin_lock_irqsave(port->adapter->scsi_host->host_lock, flags);
1537 __shost_for_each_device(sdev, port->adapter->scsi_host)
1524 if (sdev_to_zfcp(sdev)->port == port) { 1538 if (sdev_to_zfcp(sdev)->port == port) {
1525 atomic_clear_mask(common_mask, 1539 atomic_clear_mask(common_mask,
1526 &sdev_to_zfcp(sdev)->status); 1540 &sdev_to_zfcp(sdev)->status);
1527 if (clear_counter) 1541 if (clear_counter)
1528 atomic_set(&sdev_to_zfcp(sdev)->erp_counter, 0); 1542 atomic_set(&sdev_to_zfcp(sdev)->erp_counter, 0);
1529 } 1543 }
1544 spin_unlock_irqrestore(port->adapter->scsi_host->host_lock, flags);
1530} 1545}
1531 1546
1532/** 1547/**
diff --git a/drivers/s390/scsi/zfcp_qdio.c b/drivers/s390/scsi/zfcp_qdio.c
index 665e3cfaaf85..de0598eaacd2 100644
--- a/drivers/s390/scsi/zfcp_qdio.c
+++ b/drivers/s390/scsi/zfcp_qdio.c
@@ -224,11 +224,9 @@ int zfcp_qdio_sbals_from_sg(struct zfcp_qdio *qdio, struct zfcp_qdio_req *q_req,
224 224
225static int zfcp_qdio_sbal_check(struct zfcp_qdio *qdio) 225static int zfcp_qdio_sbal_check(struct zfcp_qdio *qdio)
226{ 226{
227 spin_lock_irq(&qdio->req_q_lock);
228 if (atomic_read(&qdio->req_q_free) || 227 if (atomic_read(&qdio->req_q_free) ||
229 !(atomic_read(&qdio->adapter->status) & ZFCP_STATUS_ADAPTER_QDIOUP)) 228 !(atomic_read(&qdio->adapter->status) & ZFCP_STATUS_ADAPTER_QDIOUP))
230 return 1; 229 return 1;
231 spin_unlock_irq(&qdio->req_q_lock);
232 return 0; 230 return 0;
233} 231}
234 232
@@ -246,9 +244,8 @@ int zfcp_qdio_sbal_get(struct zfcp_qdio *qdio)
246{ 244{
247 long ret; 245 long ret;
248 246
249 spin_unlock_irq(&qdio->req_q_lock); 247 ret = wait_event_interruptible_lock_irq_timeout(qdio->req_q_wq,
250 ret = wait_event_interruptible_timeout(qdio->req_q_wq, 248 zfcp_qdio_sbal_check(qdio), qdio->req_q_lock, 5 * HZ);
251 zfcp_qdio_sbal_check(qdio), 5 * HZ);
252 249
253 if (!(atomic_read(&qdio->adapter->status) & ZFCP_STATUS_ADAPTER_QDIOUP)) 250 if (!(atomic_read(&qdio->adapter->status) & ZFCP_STATUS_ADAPTER_QDIOUP))
254 return -EIO; 251 return -EIO;
@@ -262,7 +259,6 @@ int zfcp_qdio_sbal_get(struct zfcp_qdio *qdio)
262 zfcp_erp_adapter_reopen(qdio->adapter, 0, "qdsbg_1"); 259 zfcp_erp_adapter_reopen(qdio->adapter, 0, "qdsbg_1");
263 } 260 }
264 261
265 spin_lock_irq(&qdio->req_q_lock);
266 return -EIO; 262 return -EIO;
267} 263}
268 264
diff --git a/drivers/s390/scsi/zfcp_sysfs.c b/drivers/s390/scsi/zfcp_sysfs.c
index 3f01bbf0609f..890639274bcf 100644
--- a/drivers/s390/scsi/zfcp_sysfs.c
+++ b/drivers/s390/scsi/zfcp_sysfs.c
@@ -27,6 +27,16 @@ static ssize_t zfcp_sysfs_##_feat##_##_name##_show(struct device *dev, \
27static ZFCP_DEV_ATTR(_feat, _name, S_IRUGO, \ 27static ZFCP_DEV_ATTR(_feat, _name, S_IRUGO, \
28 zfcp_sysfs_##_feat##_##_name##_show, NULL); 28 zfcp_sysfs_##_feat##_##_name##_show, NULL);
29 29
30#define ZFCP_DEFINE_ATTR_CONST(_feat, _name, _format, _value) \
31static ssize_t zfcp_sysfs_##_feat##_##_name##_show(struct device *dev, \
32 struct device_attribute *at,\
33 char *buf) \
34{ \
35 return sprintf(buf, _format, _value); \
36} \
37static ZFCP_DEV_ATTR(_feat, _name, S_IRUGO, \
38 zfcp_sysfs_##_feat##_##_name##_show, NULL);
39
30#define ZFCP_DEFINE_A_ATTR(_name, _format, _value) \ 40#define ZFCP_DEFINE_A_ATTR(_name, _format, _value) \
31static ssize_t zfcp_sysfs_adapter_##_name##_show(struct device *dev, \ 41static ssize_t zfcp_sysfs_adapter_##_name##_show(struct device *dev, \
32 struct device_attribute *at,\ 42 struct device_attribute *at,\
@@ -75,6 +85,8 @@ ZFCP_DEFINE_ATTR(zfcp_unit, unit, in_recovery, "%d\n",
75ZFCP_DEFINE_ATTR(zfcp_unit, unit, access_denied, "%d\n", 85ZFCP_DEFINE_ATTR(zfcp_unit, unit, access_denied, "%d\n",
76 (zfcp_unit_sdev_status(unit) & 86 (zfcp_unit_sdev_status(unit) &
77 ZFCP_STATUS_COMMON_ACCESS_DENIED) != 0); 87 ZFCP_STATUS_COMMON_ACCESS_DENIED) != 0);
88ZFCP_DEFINE_ATTR_CONST(unit, access_shared, "%d\n", 0);
89ZFCP_DEFINE_ATTR_CONST(unit, access_readonly, "%d\n", 0);
78 90
79static ssize_t zfcp_sysfs_port_failed_show(struct device *dev, 91static ssize_t zfcp_sysfs_port_failed_show(struct device *dev,
80 struct device_attribute *attr, 92 struct device_attribute *attr,
@@ -347,6 +359,8 @@ static struct attribute *zfcp_unit_attrs[] = {
347 &dev_attr_unit_in_recovery.attr, 359 &dev_attr_unit_in_recovery.attr,
348 &dev_attr_unit_status.attr, 360 &dev_attr_unit_status.attr,
349 &dev_attr_unit_access_denied.attr, 361 &dev_attr_unit_access_denied.attr,
362 &dev_attr_unit_access_shared.attr,
363 &dev_attr_unit_access_readonly.attr,
350 NULL 364 NULL
351}; 365};
352static struct attribute_group zfcp_unit_attr_group = { 366static struct attribute_group zfcp_unit_attr_group = {
diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index 48b2918e0d65..92ff027746f2 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -1353,7 +1353,6 @@ config SCSI_LPFC
1353 tristate "Emulex LightPulse Fibre Channel Support" 1353 tristate "Emulex LightPulse Fibre Channel Support"
1354 depends on PCI && SCSI 1354 depends on PCI && SCSI
1355 select SCSI_FC_ATTRS 1355 select SCSI_FC_ATTRS
1356 select GENERIC_CSUM
1357 select CRC_T10DIF 1356 select CRC_T10DIF
1358 help 1357 help
1359 This lpfc driver supports the Emulex LightPulse 1358 This lpfc driver supports the Emulex LightPulse
diff --git a/drivers/scsi/fnic/fnic.h b/drivers/scsi/fnic/fnic.h
index b6d1f92ed33c..c18c68150e9f 100644
--- a/drivers/scsi/fnic/fnic.h
+++ b/drivers/scsi/fnic/fnic.h
@@ -38,7 +38,7 @@
38 38
39#define DRV_NAME "fnic" 39#define DRV_NAME "fnic"
40#define DRV_DESCRIPTION "Cisco FCoE HBA Driver" 40#define DRV_DESCRIPTION "Cisco FCoE HBA Driver"
41#define DRV_VERSION "1.5.0.22" 41#define DRV_VERSION "1.5.0.23"
42#define PFX DRV_NAME ": " 42#define PFX DRV_NAME ": "
43#define DFX DRV_NAME "%d: " 43#define DFX DRV_NAME "%d: "
44 44
diff --git a/drivers/scsi/fnic/fnic_main.c b/drivers/scsi/fnic/fnic_main.c
index 5f09d1814d26..42e15ee6e1bb 100644
--- a/drivers/scsi/fnic/fnic_main.c
+++ b/drivers/scsi/fnic/fnic_main.c
@@ -642,19 +642,6 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
642 INIT_WORK(&fnic->fip_frame_work, fnic_handle_fip_frame); 642 INIT_WORK(&fnic->fip_frame_work, fnic_handle_fip_frame);
643 INIT_WORK(&fnic->event_work, fnic_handle_event); 643 INIT_WORK(&fnic->event_work, fnic_handle_event);
644 skb_queue_head_init(&fnic->fip_frame_queue); 644 skb_queue_head_init(&fnic->fip_frame_queue);
645 spin_lock_irqsave(&fnic_list_lock, flags);
646 if (!fnic_fip_queue) {
647 fnic_fip_queue =
648 create_singlethread_workqueue("fnic_fip_q");
649 if (!fnic_fip_queue) {
650 spin_unlock_irqrestore(&fnic_list_lock, flags);
651 printk(KERN_ERR PFX "fnic FIP work queue "
652 "create failed\n");
653 err = -ENOMEM;
654 goto err_out_free_max_pool;
655 }
656 }
657 spin_unlock_irqrestore(&fnic_list_lock, flags);
658 INIT_LIST_HEAD(&fnic->evlist); 645 INIT_LIST_HEAD(&fnic->evlist);
659 INIT_LIST_HEAD(&fnic->vlans); 646 INIT_LIST_HEAD(&fnic->vlans);
660 } else { 647 } else {
@@ -960,6 +947,13 @@ static int __init fnic_init_module(void)
960 spin_lock_init(&fnic_list_lock); 947 spin_lock_init(&fnic_list_lock);
961 INIT_LIST_HEAD(&fnic_list); 948 INIT_LIST_HEAD(&fnic_list);
962 949
950 fnic_fip_queue = create_singlethread_workqueue("fnic_fip_q");
951 if (!fnic_fip_queue) {
952 printk(KERN_ERR PFX "fnic FIP work queue create failed\n");
953 err = -ENOMEM;
954 goto err_create_fip_workq;
955 }
956
963 fnic_fc_transport = fc_attach_transport(&fnic_fc_functions); 957 fnic_fc_transport = fc_attach_transport(&fnic_fc_functions);
964 if (!fnic_fc_transport) { 958 if (!fnic_fc_transport) {
965 printk(KERN_ERR PFX "fc_attach_transport error\n"); 959 printk(KERN_ERR PFX "fc_attach_transport error\n");
@@ -978,6 +972,8 @@ static int __init fnic_init_module(void)
978err_pci_register: 972err_pci_register:
979 fc_release_transport(fnic_fc_transport); 973 fc_release_transport(fnic_fc_transport);
980err_fc_transport: 974err_fc_transport:
975 destroy_workqueue(fnic_fip_queue);
976err_create_fip_workq:
981 destroy_workqueue(fnic_event_queue); 977 destroy_workqueue(fnic_event_queue);
982err_create_fnic_workq: 978err_create_fnic_workq:
983 kmem_cache_destroy(fnic_io_req_cache); 979 kmem_cache_destroy(fnic_io_req_cache);
diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
index 0177295599e0..1f0ca68409d4 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -3547,11 +3547,21 @@ static int megasas_init_fw(struct megasas_instance *instance)
3547 break; 3547 break;
3548 } 3548 }
3549 3549
3550 /* 3550 if (megasas_transition_to_ready(instance, 0)) {
3551 * We expect the FW state to be READY 3551 atomic_set(&instance->fw_reset_no_pci_access, 1);
3552 */ 3552 instance->instancet->adp_reset
3553 if (megasas_transition_to_ready(instance, 0)) 3553 (instance, instance->reg_set);
3554 goto fail_ready_state; 3554 atomic_set(&instance->fw_reset_no_pci_access, 0);
3555 dev_info(&instance->pdev->dev,
3556 "megasas: FW restarted successfully from %s!\n",
3557 __func__);
3558
3559 /*waitting for about 30 second before retry*/
3560 ssleep(30);
3561
3562 if (megasas_transition_to_ready(instance, 0))
3563 goto fail_ready_state;
3564 }
3555 3565
3556 /* 3566 /*
3557 * MSI-X host index 0 is common for all adapter. 3567 * MSI-X host index 0 is common for all adapter.
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index 3b1ea34e1f5a..eaa808e6ba91 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -1031,6 +1031,9 @@ int scsi_get_vpd_page(struct scsi_device *sdev, u8 page, unsigned char *buf,
1031{ 1031{
1032 int i, result; 1032 int i, result;
1033 1033
1034 if (sdev->skip_vpd_pages)
1035 goto fail;
1036
1034 /* Ask for all the pages supported by this device */ 1037 /* Ask for all the pages supported by this device */
1035 result = scsi_vpd_inquiry(sdev, buf, 0, buf_len); 1038 result = scsi_vpd_inquiry(sdev, buf, 0, buf_len);
1036 if (result) 1039 if (result)
diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
index 2168258fb2c3..74b88efde6ad 100644
--- a/drivers/scsi/virtio_scsi.c
+++ b/drivers/scsi/virtio_scsi.c
@@ -751,7 +751,7 @@ static void __virtscsi_set_affinity(struct virtio_scsi *vscsi, bool affinity)
751 751
752 vscsi->affinity_hint_set = true; 752 vscsi->affinity_hint_set = true;
753 } else { 753 } else {
754 for (i = 0; i < vscsi->num_queues - VIRTIO_SCSI_VQ_BASE; i++) 754 for (i = 0; i < vscsi->num_queues; i++)
755 virtqueue_set_affinity(vscsi->req_vqs[i].vq, -1); 755 virtqueue_set_affinity(vscsi->req_vqs[i].vq, -1);
756 756
757 vscsi->affinity_hint_set = false; 757 vscsi->affinity_hint_set = false;
diff --git a/drivers/spi/spi-davinci.c b/drivers/spi/spi-davinci.c
index 222d3e37fc28..707966bd5610 100644
--- a/drivers/spi/spi-davinci.c
+++ b/drivers/spi/spi-davinci.c
@@ -609,7 +609,7 @@ static int davinci_spi_bufs(struct spi_device *spi, struct spi_transfer *t)
609 else 609 else
610 buf = (void *)t->tx_buf; 610 buf = (void *)t->tx_buf;
611 t->tx_dma = dma_map_single(&spi->dev, buf, 611 t->tx_dma = dma_map_single(&spi->dev, buf,
612 t->len, DMA_FROM_DEVICE); 612 t->len, DMA_TO_DEVICE);
613 if (!t->tx_dma) { 613 if (!t->tx_dma) {
614 ret = -EFAULT; 614 ret = -EFAULT;
615 goto err_tx_map; 615 goto err_tx_map;
diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c
index e25eba5713c1..b3b5125faa72 100644
--- a/drivers/staging/comedi/drivers.c
+++ b/drivers/staging/comedi/drivers.c
@@ -482,7 +482,7 @@ int comedi_device_attach(struct comedi_device *dev, struct comedi_devconfig *it)
482 ret = comedi_device_postconfig(dev); 482 ret = comedi_device_postconfig(dev);
483 if (ret < 0) { 483 if (ret < 0) {
484 comedi_device_detach(dev); 484 comedi_device_detach(dev);
485 module_put(dev->driver->module); 485 module_put(driv->module);
486 } 486 }
487 /* On success, the driver module count has been incremented. */ 487 /* On success, the driver module count has been incremented. */
488 return ret; 488 return ret;
diff --git a/drivers/staging/zcache/zcache-main.c b/drivers/staging/zcache/zcache-main.c
index dcceed29d31a..81972fa47beb 100644
--- a/drivers/staging/zcache/zcache-main.c
+++ b/drivers/staging/zcache/zcache-main.c
@@ -1811,10 +1811,12 @@ static int zcache_comp_init(void)
1811#else 1811#else
1812 if (*zcache_comp_name != '\0') { 1812 if (*zcache_comp_name != '\0') {
1813 ret = crypto_has_comp(zcache_comp_name, 0, 0); 1813 ret = crypto_has_comp(zcache_comp_name, 0, 0);
1814 if (!ret) 1814 if (!ret) {
1815 pr_info("zcache: %s not supported\n", 1815 pr_info("zcache: %s not supported\n",
1816 zcache_comp_name); 1816 zcache_comp_name);
1817 goto out; 1817 ret = 1;
1818 goto out;
1819 }
1818 } 1820 }
1819 if (!ret) 1821 if (!ret)
1820 strcpy(zcache_comp_name, "lzo"); 1822 strcpy(zcache_comp_name, "lzo");
diff --git a/drivers/usb/class/usbtmc.c b/drivers/usb/class/usbtmc.c
index 609dbc2f7151..83b4ef4dfcf8 100644
--- a/drivers/usb/class/usbtmc.c
+++ b/drivers/usb/class/usbtmc.c
@@ -1119,11 +1119,11 @@ static int usbtmc_probe(struct usb_interface *intf,
1119 /* Determine if it is a Rigol or not */ 1119 /* Determine if it is a Rigol or not */
1120 data->rigol_quirk = 0; 1120 data->rigol_quirk = 0;
1121 dev_dbg(&intf->dev, "Trying to find if device Vendor 0x%04X Product 0x%04X has the RIGOL quirk\n", 1121 dev_dbg(&intf->dev, "Trying to find if device Vendor 0x%04X Product 0x%04X has the RIGOL quirk\n",
1122 data->usb_dev->descriptor.idVendor, 1122 le16_to_cpu(data->usb_dev->descriptor.idVendor),
1123 data->usb_dev->descriptor.idProduct); 1123 le16_to_cpu(data->usb_dev->descriptor.idProduct));
1124 for(n = 0; usbtmc_id_quirk[n].idVendor > 0; n++) { 1124 for(n = 0; usbtmc_id_quirk[n].idVendor > 0; n++) {
1125 if ((usbtmc_id_quirk[n].idVendor == data->usb_dev->descriptor.idVendor) && 1125 if ((usbtmc_id_quirk[n].idVendor == le16_to_cpu(data->usb_dev->descriptor.idVendor)) &&
1126 (usbtmc_id_quirk[n].idProduct == data->usb_dev->descriptor.idProduct)) { 1126 (usbtmc_id_quirk[n].idProduct == le16_to_cpu(data->usb_dev->descriptor.idProduct))) {
1127 dev_dbg(&intf->dev, "Setting this device as having the RIGOL quirk\n"); 1127 dev_dbg(&intf->dev, "Setting this device as having the RIGOL quirk\n");
1128 data->rigol_quirk = 1; 1128 data->rigol_quirk = 1;
1129 break; 1129 break;
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 4a8a1d68002c..558313de4911 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -4798,7 +4798,8 @@ static void hub_events(void)
4798 hub->ports[i - 1]->child; 4798 hub->ports[i - 1]->child;
4799 4799
4800 dev_dbg(hub_dev, "warm reset port %d\n", i); 4800 dev_dbg(hub_dev, "warm reset port %d\n", i);
4801 if (!udev) { 4801 if (!udev || !(portstatus &
4802 USB_PORT_STAT_CONNECTION)) {
4802 status = hub_port_reset(hub, i, 4803 status = hub_port_reset(hub, i,
4803 NULL, HUB_BH_RESET_TIME, 4804 NULL, HUB_BH_RESET_TIME,
4804 true); 4805 true);
@@ -4808,8 +4809,8 @@ static void hub_events(void)
4808 usb_lock_device(udev); 4809 usb_lock_device(udev);
4809 status = usb_reset_device(udev); 4810 status = usb_reset_device(udev);
4810 usb_unlock_device(udev); 4811 usb_unlock_device(udev);
4812 connect_change = 0;
4811 } 4813 }
4812 connect_change = 0;
4813 } 4814 }
4814 4815
4815 if (connect_change) 4816 if (connect_change)
diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
index a63598895077..5b44cd47da5b 100644
--- a/drivers/usb/core/quirks.c
+++ b/drivers/usb/core/quirks.c
@@ -78,6 +78,12 @@ static const struct usb_device_id usb_quirk_list[] = {
78 { USB_DEVICE(0x04d8, 0x000c), .driver_info = 78 { USB_DEVICE(0x04d8, 0x000c), .driver_info =
79 USB_QUIRK_CONFIG_INTF_STRINGS }, 79 USB_QUIRK_CONFIG_INTF_STRINGS },
80 80
81 /* CarrolTouch 4000U */
82 { USB_DEVICE(0x04e7, 0x0009), .driver_info = USB_QUIRK_RESET_RESUME },
83
84 /* CarrolTouch 4500U */
85 { USB_DEVICE(0x04e7, 0x0030), .driver_info = USB_QUIRK_RESET_RESUME },
86
81 /* Samsung Android phone modem - ID conflict with SPH-I500 */ 87 /* Samsung Android phone modem - ID conflict with SPH-I500 */
82 { USB_DEVICE(0x04e8, 0x6601), .driver_info = 88 { USB_DEVICE(0x04e8, 0x6601), .driver_info =
83 USB_QUIRK_CONFIG_INTF_STRINGS }, 89 USB_QUIRK_CONFIG_INTF_STRINGS },
diff --git a/drivers/usb/host/ehci-sched.c b/drivers/usb/host/ehci-sched.c
index f80d0330d548..8e3c878f38cf 100644
--- a/drivers/usb/host/ehci-sched.c
+++ b/drivers/usb/host/ehci-sched.c
@@ -1391,21 +1391,20 @@ iso_stream_schedule (
1391 1391
1392 /* Behind the scheduling threshold? */ 1392 /* Behind the scheduling threshold? */
1393 if (unlikely(start < next)) { 1393 if (unlikely(start < next)) {
1394 unsigned now2 = (now - base) & (mod - 1);
1394 1395
1395 /* USB_ISO_ASAP: Round up to the first available slot */ 1396 /* USB_ISO_ASAP: Round up to the first available slot */
1396 if (urb->transfer_flags & URB_ISO_ASAP) 1397 if (urb->transfer_flags & URB_ISO_ASAP)
1397 start += (next - start + period - 1) & -period; 1398 start += (next - start + period - 1) & -period;
1398 1399
1399 /* 1400 /*
1400 * Not ASAP: Use the next slot in the stream. If 1401 * Not ASAP: Use the next slot in the stream,
1401 * the entire URB falls before the threshold, fail. 1402 * no matter what.
1402 */ 1403 */
1403 else if (start + span - period < next) { 1404 else if (start + span - period < now2) {
1404 ehci_dbg(ehci, "iso urb late %p (%u+%u < %u)\n", 1405 ehci_dbg(ehci, "iso underrun %p (%u+%u < %u)\n",
1405 urb, start + base, 1406 urb, start + base,
1406 span - period, next + base); 1407 span - period, now2 + base);
1407 status = -EXDEV;
1408 goto fail;
1409 } 1408 }
1410 } 1409 }
1411 1410
diff --git a/drivers/usb/host/ohci-pci.c b/drivers/usb/host/ohci-pci.c
index 08613e241894..0f1d193fef02 100644
--- a/drivers/usb/host/ohci-pci.c
+++ b/drivers/usb/host/ohci-pci.c
@@ -304,6 +304,11 @@ static int __init ohci_pci_init(void)
304 pr_info("%s: " DRIVER_DESC "\n", hcd_name); 304 pr_info("%s: " DRIVER_DESC "\n", hcd_name);
305 305
306 ohci_init_driver(&ohci_pci_hc_driver, &pci_overrides); 306 ohci_init_driver(&ohci_pci_hc_driver, &pci_overrides);
307
308 /* Entries for the PCI suspend/resume callbacks are special */
309 ohci_pci_hc_driver.pci_suspend = ohci_suspend;
310 ohci_pci_hc_driver.pci_resume = ohci_resume;
311
307 return pci_register_driver(&ohci_pci_driver); 312 return pci_register_driver(&ohci_pci_driver);
308} 313}
309module_init(ohci_pci_init); 314module_init(ohci_pci_init);
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index df6978abd7e6..6f8c2fd47675 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -24,6 +24,7 @@
24#include <linux/pci.h> 24#include <linux/pci.h>
25#include <linux/slab.h> 25#include <linux/slab.h>
26#include <linux/dmapool.h> 26#include <linux/dmapool.h>
27#include <linux/dma-mapping.h>
27 28
28#include "xhci.h" 29#include "xhci.h"
29 30
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 41eb4fc33453..9478caa2f71f 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -27,6 +27,7 @@
27#include <linux/moduleparam.h> 27#include <linux/moduleparam.h>
28#include <linux/slab.h> 28#include <linux/slab.h>
29#include <linux/dmi.h> 29#include <linux/dmi.h>
30#include <linux/dma-mapping.h>
30 31
31#include "xhci.h" 32#include "xhci.h"
32 33
diff --git a/drivers/usb/misc/adutux.c b/drivers/usb/misc/adutux.c
index eb3c8c142fa9..eeb27208c0d1 100644
--- a/drivers/usb/misc/adutux.c
+++ b/drivers/usb/misc/adutux.c
@@ -830,7 +830,7 @@ static int adu_probe(struct usb_interface *interface,
830 830
831 /* let the user know what node this device is now attached to */ 831 /* let the user know what node this device is now attached to */
832 dev_info(&interface->dev, "ADU%d %s now attached to /dev/usb/adutux%d\n", 832 dev_info(&interface->dev, "ADU%d %s now attached to /dev/usb/adutux%d\n",
833 udev->descriptor.idProduct, dev->serial_number, 833 le16_to_cpu(udev->descriptor.idProduct), dev->serial_number,
834 (dev->minor - ADU_MINOR_BASE)); 834 (dev->minor - ADU_MINOR_BASE));
835exit: 835exit:
836 dbg(2, " %s : leave, return value %p (dev)", __func__, dev); 836 dbg(2, " %s : leave, return value %p (dev)", __func__, dev);
diff --git a/drivers/usb/phy/phy-fsl-usb.h b/drivers/usb/phy/phy-fsl-usb.h
index ca266280895d..e1859b8ef567 100644
--- a/drivers/usb/phy/phy-fsl-usb.h
+++ b/drivers/usb/phy/phy-fsl-usb.h
@@ -15,7 +15,7 @@
15 * 675 Mass Ave, Cambridge, MA 02139, USA. 15 * 675 Mass Ave, Cambridge, MA 02139, USA.
16 */ 16 */
17 17
18#include "otg_fsm.h" 18#include "phy-fsm-usb.h"
19#include <linux/usb/otg.h> 19#include <linux/usb/otg.h>
20#include <linux/ioctl.h> 20#include <linux/ioctl.h>
21 21
diff --git a/drivers/usb/phy/phy-fsm-usb.c b/drivers/usb/phy/phy-fsm-usb.c
index c520b3548e7c..7f4596606e18 100644
--- a/drivers/usb/phy/phy-fsm-usb.c
+++ b/drivers/usb/phy/phy-fsm-usb.c
@@ -29,7 +29,7 @@
29#include <linux/usb/gadget.h> 29#include <linux/usb/gadget.h>
30#include <linux/usb/otg.h> 30#include <linux/usb/otg.h>
31 31
32#include "phy-otg-fsm.h" 32#include "phy-fsm-usb.h"
33 33
34/* Change USB protocol when there is a protocol change */ 34/* Change USB protocol when there is a protocol change */
35static int otg_set_protocol(struct otg_fsm *fsm, int protocol) 35static int otg_set_protocol(struct otg_fsm *fsm, int protocol)
diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c
index 5a979729f8ec..58c17fdc85eb 100644
--- a/drivers/usb/serial/keyspan.c
+++ b/drivers/usb/serial/keyspan.c
@@ -2303,7 +2303,7 @@ static int keyspan_startup(struct usb_serial *serial)
2303 if (d_details == NULL) { 2303 if (d_details == NULL) {
2304 dev_err(&serial->dev->dev, "%s - unknown product id %x\n", 2304 dev_err(&serial->dev->dev, "%s - unknown product id %x\n",
2305 __func__, le16_to_cpu(serial->dev->descriptor.idProduct)); 2305 __func__, le16_to_cpu(serial->dev->descriptor.idProduct));
2306 return 1; 2306 return -ENODEV;
2307 } 2307 }
2308 2308
2309 /* Setup private data for serial driver */ 2309 /* Setup private data for serial driver */
diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c
index 51da424327b0..b01300164fc0 100644
--- a/drivers/usb/serial/mos7720.c
+++ b/drivers/usb/serial/mos7720.c
@@ -90,6 +90,7 @@ struct urbtracker {
90 struct list_head urblist_entry; 90 struct list_head urblist_entry;
91 struct kref ref_count; 91 struct kref ref_count;
92 struct urb *urb; 92 struct urb *urb;
93 struct usb_ctrlrequest *setup;
93}; 94};
94 95
95enum mos7715_pp_modes { 96enum mos7715_pp_modes {
@@ -271,6 +272,7 @@ static void destroy_urbtracker(struct kref *kref)
271 struct mos7715_parport *mos_parport = urbtrack->mos_parport; 272 struct mos7715_parport *mos_parport = urbtrack->mos_parport;
272 273
273 usb_free_urb(urbtrack->urb); 274 usb_free_urb(urbtrack->urb);
275 kfree(urbtrack->setup);
274 kfree(urbtrack); 276 kfree(urbtrack);
275 kref_put(&mos_parport->ref_count, destroy_mos_parport); 277 kref_put(&mos_parport->ref_count, destroy_mos_parport);
276} 278}
@@ -355,7 +357,6 @@ static int write_parport_reg_nonblock(struct mos7715_parport *mos_parport,
355 struct urbtracker *urbtrack; 357 struct urbtracker *urbtrack;
356 int ret_val; 358 int ret_val;
357 unsigned long flags; 359 unsigned long flags;
358 struct usb_ctrlrequest setup;
359 struct usb_serial *serial = mos_parport->serial; 360 struct usb_serial *serial = mos_parport->serial;
360 struct usb_device *usbdev = serial->dev; 361 struct usb_device *usbdev = serial->dev;
361 362
@@ -373,14 +374,20 @@ static int write_parport_reg_nonblock(struct mos7715_parport *mos_parport,
373 kfree(urbtrack); 374 kfree(urbtrack);
374 return -ENOMEM; 375 return -ENOMEM;
375 } 376 }
376 setup.bRequestType = (__u8)0x40; 377 urbtrack->setup = kmalloc(sizeof(*urbtrack->setup), GFP_KERNEL);
377 setup.bRequest = (__u8)0x0e; 378 if (!urbtrack->setup) {
378 setup.wValue = get_reg_value(reg, dummy); 379 usb_free_urb(urbtrack->urb);
379 setup.wIndex = get_reg_index(reg); 380 kfree(urbtrack);
380 setup.wLength = 0; 381 return -ENOMEM;
382 }
383 urbtrack->setup->bRequestType = (__u8)0x40;
384 urbtrack->setup->bRequest = (__u8)0x0e;
385 urbtrack->setup->wValue = get_reg_value(reg, dummy);
386 urbtrack->setup->wIndex = get_reg_index(reg);
387 urbtrack->setup->wLength = 0;
381 usb_fill_control_urb(urbtrack->urb, usbdev, 388 usb_fill_control_urb(urbtrack->urb, usbdev,
382 usb_sndctrlpipe(usbdev, 0), 389 usb_sndctrlpipe(usbdev, 0),
383 (unsigned char *)&setup, 390 (unsigned char *)urbtrack->setup,
384 NULL, 0, async_complete, urbtrack); 391 NULL, 0, async_complete, urbtrack);
385 kref_init(&urbtrack->ref_count); 392 kref_init(&urbtrack->ref_count);
386 INIT_LIST_HEAD(&urbtrack->urblist_entry); 393 INIT_LIST_HEAD(&urbtrack->urblist_entry);
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
index d953d674f222..3bac4693c038 100644
--- a/drivers/usb/serial/mos7840.c
+++ b/drivers/usb/serial/mos7840.c
@@ -2193,7 +2193,7 @@ static int mos7810_check(struct usb_serial *serial)
2193static int mos7840_probe(struct usb_serial *serial, 2193static int mos7840_probe(struct usb_serial *serial,
2194 const struct usb_device_id *id) 2194 const struct usb_device_id *id)
2195{ 2195{
2196 u16 product = serial->dev->descriptor.idProduct; 2196 u16 product = le16_to_cpu(serial->dev->descriptor.idProduct);
2197 u8 *buf; 2197 u8 *buf;
2198 int device_type; 2198 int device_type;
2199 2199
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c
index 375b5a400b6f..5c9f9b1d7736 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.c
+++ b/drivers/usb/serial/ti_usb_3410_5052.c
@@ -1536,14 +1536,15 @@ static int ti_download_firmware(struct ti_device *tdev)
1536 char buf[32]; 1536 char buf[32];
1537 1537
1538 /* try ID specific firmware first, then try generic firmware */ 1538 /* try ID specific firmware first, then try generic firmware */
1539 sprintf(buf, "ti_usb-v%04x-p%04x.fw", dev->descriptor.idVendor, 1539 sprintf(buf, "ti_usb-v%04x-p%04x.fw",
1540 dev->descriptor.idProduct); 1540 le16_to_cpu(dev->descriptor.idVendor),
1541 le16_to_cpu(dev->descriptor.idProduct));
1541 status = request_firmware(&fw_p, buf, &dev->dev); 1542 status = request_firmware(&fw_p, buf, &dev->dev);
1542 1543
1543 if (status != 0) { 1544 if (status != 0) {
1544 buf[0] = '\0'; 1545 buf[0] = '\0';
1545 if (dev->descriptor.idVendor == MTS_VENDOR_ID) { 1546 if (le16_to_cpu(dev->descriptor.idVendor) == MTS_VENDOR_ID) {
1546 switch (dev->descriptor.idProduct) { 1547 switch (le16_to_cpu(dev->descriptor.idProduct)) {
1547 case MTS_CDMA_PRODUCT_ID: 1548 case MTS_CDMA_PRODUCT_ID:
1548 strcpy(buf, "mts_cdma.fw"); 1549 strcpy(buf, "mts_cdma.fw");
1549 break; 1550 break;
diff --git a/drivers/usb/serial/usb_wwan.c b/drivers/usb/serial/usb_wwan.c
index 8257d30c4072..85365784040b 100644
--- a/drivers/usb/serial/usb_wwan.c
+++ b/drivers/usb/serial/usb_wwan.c
@@ -291,18 +291,18 @@ static void usb_wwan_indat_callback(struct urb *urb)
291 tty_flip_buffer_push(&port->port); 291 tty_flip_buffer_push(&port->port);
292 } else 292 } else
293 dev_dbg(dev, "%s: empty read urb received\n", __func__); 293 dev_dbg(dev, "%s: empty read urb received\n", __func__);
294 294 }
295 /* Resubmit urb so we continue receiving */ 295 /* Resubmit urb so we continue receiving */
296 err = usb_submit_urb(urb, GFP_ATOMIC); 296 err = usb_submit_urb(urb, GFP_ATOMIC);
297 if (err) { 297 if (err) {
298 if (err != -EPERM) { 298 if (err != -EPERM) {
299 dev_err(dev, "%s: resubmit read urb failed. (%d)\n", __func__, err); 299 dev_err(dev, "%s: resubmit read urb failed. (%d)\n",
300 /* busy also in error unless we are killed */ 300 __func__, err);
301 usb_mark_last_busy(port->serial->dev); 301 /* busy also in error unless we are killed */
302 }
303 } else {
304 usb_mark_last_busy(port->serial->dev); 302 usb_mark_last_busy(port->serial->dev);
305 } 303 }
304 } else {
305 usb_mark_last_busy(port->serial->dev);
306 } 306 }
307} 307}
308 308
diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c
index 16968c899493..d3493ca0525d 100644
--- a/drivers/usb/wusbcore/wa-xfer.c
+++ b/drivers/usb/wusbcore/wa-xfer.c
@@ -1226,6 +1226,12 @@ int wa_urb_dequeue(struct wahc *wa, struct urb *urb)
1226 } 1226 }
1227 spin_lock_irqsave(&xfer->lock, flags); 1227 spin_lock_irqsave(&xfer->lock, flags);
1228 rpipe = xfer->ep->hcpriv; 1228 rpipe = xfer->ep->hcpriv;
1229 if (rpipe == NULL) {
1230 pr_debug("%s: xfer id 0x%08X has no RPIPE. %s",
1231 __func__, wa_xfer_id(xfer),
1232 "Probably already aborted.\n" );
1233 goto out_unlock;
1234 }
1229 /* Check the delayed list -> if there, release and complete */ 1235 /* Check the delayed list -> if there, release and complete */
1230 spin_lock_irqsave(&wa->xfer_list_lock, flags2); 1236 spin_lock_irqsave(&wa->xfer_list_lock, flags2);
1231 if (!list_empty(&xfer->list_node) && xfer->seg == NULL) 1237 if (!list_empty(&xfer->list_node) && xfer->seg == NULL)
@@ -1644,8 +1650,7 @@ static void wa_xfer_result_cb(struct urb *urb)
1644 break; 1650 break;
1645 } 1651 }
1646 usb_status = xfer_result->bTransferStatus & 0x3f; 1652 usb_status = xfer_result->bTransferStatus & 0x3f;
1647 if (usb_status == WA_XFER_STATUS_ABORTED 1653 if (usb_status == WA_XFER_STATUS_NOT_FOUND)
1648 || usb_status == WA_XFER_STATUS_NOT_FOUND)
1649 /* taken care of already */ 1654 /* taken care of already */
1650 break; 1655 break;
1651 xfer_id = xfer_result->dwTransferID; 1656 xfer_id = xfer_result->dwTransferID;
diff --git a/drivers/video/mxsfb.c b/drivers/video/mxsfb.c
index 3ba37713b1f9..dc09ebe4aba5 100644
--- a/drivers/video/mxsfb.c
+++ b/drivers/video/mxsfb.c
@@ -239,24 +239,6 @@ static const struct fb_bitfield def_rgb565[] = {
239 } 239 }
240}; 240};
241 241
242static const struct fb_bitfield def_rgb666[] = {
243 [RED] = {
244 .offset = 16,
245 .length = 6,
246 },
247 [GREEN] = {
248 .offset = 8,
249 .length = 6,
250 },
251 [BLUE] = {
252 .offset = 0,
253 .length = 6,
254 },
255 [TRANSP] = { /* no support for transparency */
256 .length = 0,
257 }
258};
259
260static const struct fb_bitfield def_rgb888[] = { 242static const struct fb_bitfield def_rgb888[] = {
261 [RED] = { 243 [RED] = {
262 .offset = 16, 244 .offset = 16,
@@ -309,9 +291,6 @@ static int mxsfb_check_var(struct fb_var_screeninfo *var,
309 break; 291 break;
310 case STMLCDIF_16BIT: 292 case STMLCDIF_16BIT:
311 case STMLCDIF_18BIT: 293 case STMLCDIF_18BIT:
312 /* 24 bit to 18 bit mapping */
313 rgb = def_rgb666;
314 break;
315 case STMLCDIF_24BIT: 294 case STMLCDIF_24BIT:
316 /* real 24 bit */ 295 /* real 24 bit */
317 rgb = def_rgb888; 296 rgb = def_rgb888;
@@ -453,11 +432,6 @@ static int mxsfb_set_par(struct fb_info *fb_info)
453 return -EINVAL; 432 return -EINVAL;
454 case STMLCDIF_16BIT: 433 case STMLCDIF_16BIT:
455 case STMLCDIF_18BIT: 434 case STMLCDIF_18BIT:
456 /* 24 bit to 18 bit mapping */
457 ctrl |= CTRL_DF24; /* ignore the upper 2 bits in
458 * each colour component
459 */
460 break;
461 case STMLCDIF_24BIT: 435 case STMLCDIF_24BIT:
462 /* real 24 bit */ 436 /* real 24 bit */
463 break; 437 break;
diff --git a/drivers/video/omap2/displays-new/connector-analog-tv.c b/drivers/video/omap2/displays-new/connector-analog-tv.c
index 5338f362293b..1b60698f141e 100644
--- a/drivers/video/omap2/displays-new/connector-analog-tv.c
+++ b/drivers/video/omap2/displays-new/connector-analog-tv.c
@@ -28,6 +28,20 @@ struct panel_drv_data {
28 bool invert_polarity; 28 bool invert_polarity;
29}; 29};
30 30
31static const struct omap_video_timings tvc_pal_timings = {
32 .x_res = 720,
33 .y_res = 574,
34 .pixel_clock = 13500,
35 .hsw = 64,
36 .hfp = 12,
37 .hbp = 68,
38 .vsw = 5,
39 .vfp = 5,
40 .vbp = 41,
41
42 .interlace = true,
43};
44
31#define to_panel_data(x) container_of(x, struct panel_drv_data, dssdev) 45#define to_panel_data(x) container_of(x, struct panel_drv_data, dssdev)
32 46
33static int tvc_connect(struct omap_dss_device *dssdev) 47static int tvc_connect(struct omap_dss_device *dssdev)
@@ -212,14 +226,14 @@ static int tvc_probe(struct platform_device *pdev)
212 return -ENODEV; 226 return -ENODEV;
213 } 227 }
214 228
215 ddata->timings = omap_dss_pal_timings; 229 ddata->timings = tvc_pal_timings;
216 230
217 dssdev = &ddata->dssdev; 231 dssdev = &ddata->dssdev;
218 dssdev->driver = &tvc_driver; 232 dssdev->driver = &tvc_driver;
219 dssdev->dev = &pdev->dev; 233 dssdev->dev = &pdev->dev;
220 dssdev->type = OMAP_DISPLAY_TYPE_VENC; 234 dssdev->type = OMAP_DISPLAY_TYPE_VENC;
221 dssdev->owner = THIS_MODULE; 235 dssdev->owner = THIS_MODULE;
222 dssdev->panel.timings = omap_dss_pal_timings; 236 dssdev->panel.timings = tvc_pal_timings;
223 237
224 r = omapdss_register_display(dssdev); 238 r = omapdss_register_display(dssdev);
225 if (r) { 239 if (r) {
diff --git a/drivers/xen/acpi.c b/drivers/xen/acpi.c
index 119d42a2bf57..90307c0b630c 100644
--- a/drivers/xen/acpi.c
+++ b/drivers/xen/acpi.c
@@ -35,28 +35,43 @@
35#include <asm/xen/hypercall.h> 35#include <asm/xen/hypercall.h>
36#include <asm/xen/hypervisor.h> 36#include <asm/xen/hypervisor.h>
37 37
38int xen_acpi_notify_hypervisor_state(u8 sleep_state, 38static int xen_acpi_notify_hypervisor_state(u8 sleep_state,
39 u32 pm1a_cnt, u32 pm1b_cnt) 39 u32 val_a, u32 val_b,
40 bool extended)
40{ 41{
42 unsigned int bits = extended ? 8 : 16;
43
41 struct xen_platform_op op = { 44 struct xen_platform_op op = {
42 .cmd = XENPF_enter_acpi_sleep, 45 .cmd = XENPF_enter_acpi_sleep,
43 .interface_version = XENPF_INTERFACE_VERSION, 46 .interface_version = XENPF_INTERFACE_VERSION,
44 .u = { 47 .u.enter_acpi_sleep = {
45 .enter_acpi_sleep = { 48 .val_a = (u16)val_a,
46 .pm1a_cnt_val = (u16)pm1a_cnt, 49 .val_b = (u16)val_b,
47 .pm1b_cnt_val = (u16)pm1b_cnt, 50 .sleep_state = sleep_state,
48 .sleep_state = sleep_state, 51 .flags = extended ? XENPF_ACPI_SLEEP_EXTENDED : 0,
49 },
50 }, 52 },
51 }; 53 };
52 54
53 if ((pm1a_cnt & 0xffff0000) || (pm1b_cnt & 0xffff0000)) { 55 if (WARN((val_a & (~0 << bits)) || (val_b & (~0 << bits)),
54 WARN(1, "Using more than 16bits of PM1A/B 0x%x/0x%x!" 56 "Using more than %u bits of sleep control values %#x/%#x!"
55 "Email xen-devel@lists.xensource.com Thank you.\n", \ 57 "Email xen-devel@lists.xen.org - Thank you.\n", \
56 pm1a_cnt, pm1b_cnt); 58 bits, val_a, val_b))
57 return -1; 59 return -1;
58 }
59 60
60 HYPERVISOR_dom0_op(&op); 61 HYPERVISOR_dom0_op(&op);
61 return 1; 62 return 1;
62} 63}
64
65int xen_acpi_notify_hypervisor_sleep(u8 sleep_state,
66 u32 pm1a_cnt, u32 pm1b_cnt)
67{
68 return xen_acpi_notify_hypervisor_state(sleep_state, pm1a_cnt,
69 pm1b_cnt, false);
70}
71
72int xen_acpi_notify_hypervisor_extended_sleep(u8 sleep_state,
73 u32 val_a, u32 val_b)
74{
75 return xen_acpi_notify_hypervisor_state(sleep_state, val_a,
76 val_b, true);
77}
diff --git a/drivers/xen/events.c b/drivers/xen/events.c
index a58ac435a9a4..5e8be462aed5 100644
--- a/drivers/xen/events.c
+++ b/drivers/xen/events.c
@@ -348,7 +348,7 @@ static void init_evtchn_cpu_bindings(void)
348 348
349 for_each_possible_cpu(i) 349 for_each_possible_cpu(i)
350 memset(per_cpu(cpu_evtchn_mask, i), 350 memset(per_cpu(cpu_evtchn_mask, i),
351 (i == 0) ? ~0 : 0, sizeof(*per_cpu(cpu_evtchn_mask, i))); 351 (i == 0) ? ~0 : 0, NR_EVENT_CHANNELS/8);
352} 352}
353 353
354static inline void clear_evtchn(int port) 354static inline void clear_evtchn(int port)
@@ -1493,8 +1493,10 @@ void rebind_evtchn_irq(int evtchn, int irq)
1493/* Rebind an evtchn so that it gets delivered to a specific cpu */ 1493/* Rebind an evtchn so that it gets delivered to a specific cpu */
1494static int rebind_irq_to_cpu(unsigned irq, unsigned tcpu) 1494static int rebind_irq_to_cpu(unsigned irq, unsigned tcpu)
1495{ 1495{
1496 struct shared_info *s = HYPERVISOR_shared_info;
1496 struct evtchn_bind_vcpu bind_vcpu; 1497 struct evtchn_bind_vcpu bind_vcpu;
1497 int evtchn = evtchn_from_irq(irq); 1498 int evtchn = evtchn_from_irq(irq);
1499 int masked;
1498 1500
1499 if (!VALID_EVTCHN(evtchn)) 1501 if (!VALID_EVTCHN(evtchn))
1500 return -1; 1502 return -1;
@@ -1511,6 +1513,12 @@ static int rebind_irq_to_cpu(unsigned irq, unsigned tcpu)
1511 bind_vcpu.vcpu = tcpu; 1513 bind_vcpu.vcpu = tcpu;
1512 1514
1513 /* 1515 /*
1516 * Mask the event while changing the VCPU binding to prevent
1517 * it being delivered on an unexpected VCPU.
1518 */
1519 masked = sync_test_and_set_bit(evtchn, BM(s->evtchn_mask));
1520
1521 /*
1514 * If this fails, it usually just indicates that we're dealing with a 1522 * If this fails, it usually just indicates that we're dealing with a
1515 * virq or IPI channel, which don't actually need to be rebound. Ignore 1523 * virq or IPI channel, which don't actually need to be rebound. Ignore
1516 * it, but don't do the xenlinux-level rebind in that case. 1524 * it, but don't do the xenlinux-level rebind in that case.
@@ -1518,6 +1526,9 @@ static int rebind_irq_to_cpu(unsigned irq, unsigned tcpu)
1518 if (HYPERVISOR_event_channel_op(EVTCHNOP_bind_vcpu, &bind_vcpu) >= 0) 1526 if (HYPERVISOR_event_channel_op(EVTCHNOP_bind_vcpu, &bind_vcpu) >= 0)
1519 bind_evtchn_to_cpu(evtchn, tcpu); 1527 bind_evtchn_to_cpu(evtchn, tcpu);
1520 1528
1529 if (!masked)
1530 unmask_evtchn(evtchn);
1531
1521 return 0; 1532 return 0;
1522} 1533}
1523 1534
diff --git a/fs/bfs/inode.c b/fs/bfs/inode.c
index 5e376bb93419..8defc6b3f9a2 100644
--- a/fs/bfs/inode.c
+++ b/fs/bfs/inode.c
@@ -40,7 +40,7 @@ struct inode *bfs_iget(struct super_block *sb, unsigned long ino)
40 int block, off; 40 int block, off;
41 41
42 inode = iget_locked(sb, ino); 42 inode = iget_locked(sb, ino);
43 if (IS_ERR(inode)) 43 if (!inode)
44 return ERR_PTR(-ENOMEM); 44 return ERR_PTR(-ENOMEM);
45 if (!(inode->i_state & I_NEW)) 45 if (!(inode->i_state & I_NEW))
46 return inode; 46 return inode;
diff --git a/fs/bio.c b/fs/bio.c
index 94bbc04dba77..c5eae7251490 100644
--- a/fs/bio.c
+++ b/fs/bio.c
@@ -1045,12 +1045,22 @@ static int __bio_copy_iov(struct bio *bio, struct bio_vec *iovecs,
1045int bio_uncopy_user(struct bio *bio) 1045int bio_uncopy_user(struct bio *bio)
1046{ 1046{
1047 struct bio_map_data *bmd = bio->bi_private; 1047 struct bio_map_data *bmd = bio->bi_private;
1048 int ret = 0; 1048 struct bio_vec *bvec;
1049 int ret = 0, i;
1049 1050
1050 if (!bio_flagged(bio, BIO_NULL_MAPPED)) 1051 if (!bio_flagged(bio, BIO_NULL_MAPPED)) {
1051 ret = __bio_copy_iov(bio, bmd->iovecs, bmd->sgvecs, 1052 /*
1052 bmd->nr_sgvecs, bio_data_dir(bio) == READ, 1053 * if we're in a workqueue, the request is orphaned, so
1053 0, bmd->is_our_pages); 1054 * don't copy into a random user address space, just free.
1055 */
1056 if (current->mm)
1057 ret = __bio_copy_iov(bio, bmd->iovecs, bmd->sgvecs,
1058 bmd->nr_sgvecs, bio_data_dir(bio) == READ,
1059 0, bmd->is_our_pages);
1060 else if (bmd->is_our_pages)
1061 bio_for_each_segment_all(bvec, bio, i)
1062 __free_page(bvec->bv_page);
1063 }
1054 bio_free_map_data(bmd); 1064 bio_free_map_data(bmd);
1055 bio_put(bio); 1065 bio_put(bio);
1056 return ret; 1066 return ret;
diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c
index eaf133384a8f..8bc5e8ccb091 100644
--- a/fs/btrfs/backref.c
+++ b/fs/btrfs/backref.c
@@ -36,16 +36,23 @@ static int check_extent_in_eb(struct btrfs_key *key, struct extent_buffer *eb,
36 u64 extent_item_pos, 36 u64 extent_item_pos,
37 struct extent_inode_elem **eie) 37 struct extent_inode_elem **eie)
38{ 38{
39 u64 data_offset; 39 u64 offset = 0;
40 u64 data_len;
41 struct extent_inode_elem *e; 40 struct extent_inode_elem *e;
42 41
43 data_offset = btrfs_file_extent_offset(eb, fi); 42 if (!btrfs_file_extent_compression(eb, fi) &&
44 data_len = btrfs_file_extent_num_bytes(eb, fi); 43 !btrfs_file_extent_encryption(eb, fi) &&
44 !btrfs_file_extent_other_encoding(eb, fi)) {
45 u64 data_offset;
46 u64 data_len;
45 47
46 if (extent_item_pos < data_offset || 48 data_offset = btrfs_file_extent_offset(eb, fi);
47 extent_item_pos >= data_offset + data_len) 49 data_len = btrfs_file_extent_num_bytes(eb, fi);
48 return 1; 50
51 if (extent_item_pos < data_offset ||
52 extent_item_pos >= data_offset + data_len)
53 return 1;
54 offset = extent_item_pos - data_offset;
55 }
49 56
50 e = kmalloc(sizeof(*e), GFP_NOFS); 57 e = kmalloc(sizeof(*e), GFP_NOFS);
51 if (!e) 58 if (!e)
@@ -53,7 +60,7 @@ static int check_extent_in_eb(struct btrfs_key *key, struct extent_buffer *eb,
53 60
54 e->next = *eie; 61 e->next = *eie;
55 e->inum = key->objectid; 62 e->inum = key->objectid;
56 e->offset = key->offset + (extent_item_pos - data_offset); 63 e->offset = key->offset + offset;
57 *eie = e; 64 *eie = e;
58 65
59 return 0; 66 return 0;
@@ -189,7 +196,7 @@ static int add_all_parents(struct btrfs_root *root, struct btrfs_path *path,
189 struct extent_buffer *eb; 196 struct extent_buffer *eb;
190 struct btrfs_key key; 197 struct btrfs_key key;
191 struct btrfs_file_extent_item *fi; 198 struct btrfs_file_extent_item *fi;
192 struct extent_inode_elem *eie = NULL; 199 struct extent_inode_elem *eie = NULL, *old = NULL;
193 u64 disk_byte; 200 u64 disk_byte;
194 201
195 if (level != 0) { 202 if (level != 0) {
@@ -223,6 +230,7 @@ static int add_all_parents(struct btrfs_root *root, struct btrfs_path *path,
223 230
224 if (disk_byte == wanted_disk_byte) { 231 if (disk_byte == wanted_disk_byte) {
225 eie = NULL; 232 eie = NULL;
233 old = NULL;
226 if (extent_item_pos) { 234 if (extent_item_pos) {
227 ret = check_extent_in_eb(&key, eb, fi, 235 ret = check_extent_in_eb(&key, eb, fi,
228 *extent_item_pos, 236 *extent_item_pos,
@@ -230,18 +238,20 @@ static int add_all_parents(struct btrfs_root *root, struct btrfs_path *path,
230 if (ret < 0) 238 if (ret < 0)
231 break; 239 break;
232 } 240 }
233 if (!ret) { 241 if (ret > 0)
234 ret = ulist_add(parents, eb->start, 242 goto next;
235 (uintptr_t)eie, GFP_NOFS); 243 ret = ulist_add_merge(parents, eb->start,
236 if (ret < 0) 244 (uintptr_t)eie,
237 break; 245 (u64 *)&old, GFP_NOFS);
238 if (!extent_item_pos) { 246 if (ret < 0)
239 ret = btrfs_next_old_leaf(root, path, 247 break;
240 time_seq); 248 if (!ret && extent_item_pos) {
241 continue; 249 while (old->next)
242 } 250 old = old->next;
251 old->next = eie;
243 } 252 }
244 } 253 }
254next:
245 ret = btrfs_next_old_item(root, path, time_seq); 255 ret = btrfs_next_old_item(root, path, time_seq);
246 } 256 }
247 257
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index 5bf4c39e2ad6..ed504607d8ec 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -1271,7 +1271,6 @@ tree_mod_log_rewind(struct btrfs_fs_info *fs_info, struct extent_buffer *eb,
1271 BUG_ON(!eb_rewin); 1271 BUG_ON(!eb_rewin);
1272 } 1272 }
1273 1273
1274 extent_buffer_get(eb_rewin);
1275 btrfs_tree_read_unlock(eb); 1274 btrfs_tree_read_unlock(eb);
1276 free_extent_buffer(eb); 1275 free_extent_buffer(eb);
1277 1276
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 583d98bd065e..fe443fece851 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -4048,7 +4048,7 @@ int extent_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
4048 } 4048 }
4049 4049
4050 while (!end) { 4050 while (!end) {
4051 u64 offset_in_extent; 4051 u64 offset_in_extent = 0;
4052 4052
4053 /* break if the extent we found is outside the range */ 4053 /* break if the extent we found is outside the range */
4054 if (em->start >= max || extent_map_end(em) < off) 4054 if (em->start >= max || extent_map_end(em) < off)
@@ -4064,9 +4064,12 @@ int extent_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
4064 4064
4065 /* 4065 /*
4066 * record the offset from the start of the extent 4066 * record the offset from the start of the extent
4067 * for adjusting the disk offset below 4067 * for adjusting the disk offset below. Only do this if the
4068 * extent isn't compressed since our in ram offset may be past
4069 * what we have actually allocated on disk.
4068 */ 4070 */
4069 offset_in_extent = em_start - em->start; 4071 if (!test_bit(EXTENT_FLAG_COMPRESSED, &em->flags))
4072 offset_in_extent = em_start - em->start;
4070 em_end = extent_map_end(em); 4073 em_end = extent_map_end(em);
4071 em_len = em_end - em_start; 4074 em_len = em_end - em_start;
4072 emflags = em->flags; 4075 emflags = em->flags;
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index a005fe2c072a..8e686a427ce2 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -596,20 +596,29 @@ void btrfs_drop_extent_cache(struct inode *inode, u64 start, u64 end,
596 if (no_splits) 596 if (no_splits)
597 goto next; 597 goto next;
598 598
599 if (em->block_start < EXTENT_MAP_LAST_BYTE && 599 if (em->start < start) {
600 em->start < start) {
601 split->start = em->start; 600 split->start = em->start;
602 split->len = start - em->start; 601 split->len = start - em->start;
603 split->orig_start = em->orig_start;
604 split->block_start = em->block_start;
605 602
606 if (compressed) 603 if (em->block_start < EXTENT_MAP_LAST_BYTE) {
607 split->block_len = em->block_len; 604 split->orig_start = em->orig_start;
608 else 605 split->block_start = em->block_start;
609 split->block_len = split->len; 606
610 split->ram_bytes = em->ram_bytes; 607 if (compressed)
611 split->orig_block_len = max(split->block_len, 608 split->block_len = em->block_len;
612 em->orig_block_len); 609 else
610 split->block_len = split->len;
611 split->orig_block_len = max(split->block_len,
612 em->orig_block_len);
613 split->ram_bytes = em->ram_bytes;
614 } else {
615 split->orig_start = split->start;
616 split->block_len = 0;
617 split->block_start = em->block_start;
618 split->orig_block_len = 0;
619 split->ram_bytes = split->len;
620 }
621
613 split->generation = gen; 622 split->generation = gen;
614 split->bdev = em->bdev; 623 split->bdev = em->bdev;
615 split->flags = flags; 624 split->flags = flags;
@@ -620,8 +629,7 @@ void btrfs_drop_extent_cache(struct inode *inode, u64 start, u64 end,
620 split = split2; 629 split = split2;
621 split2 = NULL; 630 split2 = NULL;
622 } 631 }
623 if (em->block_start < EXTENT_MAP_LAST_BYTE && 632 if (testend && em->start + em->len > start + len) {
624 testend && em->start + em->len > start + len) {
625 u64 diff = start + len - em->start; 633 u64 diff = start + len - em->start;
626 634
627 split->start = start + len; 635 split->start = start + len;
@@ -630,18 +638,28 @@ void btrfs_drop_extent_cache(struct inode *inode, u64 start, u64 end,
630 split->flags = flags; 638 split->flags = flags;
631 split->compress_type = em->compress_type; 639 split->compress_type = em->compress_type;
632 split->generation = gen; 640 split->generation = gen;
633 split->orig_block_len = max(em->block_len, 641
642 if (em->block_start < EXTENT_MAP_LAST_BYTE) {
643 split->orig_block_len = max(em->block_len,
634 em->orig_block_len); 644 em->orig_block_len);
635 split->ram_bytes = em->ram_bytes;
636 645
637 if (compressed) { 646 split->ram_bytes = em->ram_bytes;
638 split->block_len = em->block_len; 647 if (compressed) {
639 split->block_start = em->block_start; 648 split->block_len = em->block_len;
640 split->orig_start = em->orig_start; 649 split->block_start = em->block_start;
650 split->orig_start = em->orig_start;
651 } else {
652 split->block_len = split->len;
653 split->block_start = em->block_start
654 + diff;
655 split->orig_start = em->orig_start;
656 }
641 } else { 657 } else {
642 split->block_len = split->len; 658 split->ram_bytes = split->len;
643 split->block_start = em->block_start + diff; 659 split->orig_start = split->start;
644 split->orig_start = em->orig_start; 660 split->block_len = 0;
661 split->block_start = em->block_start;
662 split->orig_block_len = 0;
645 } 663 }
646 664
647 ret = add_extent_mapping(em_tree, split, modified); 665 ret = add_extent_mapping(em_tree, split, modified);
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 6d1b93c8aafb..021694c08181 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -2166,16 +2166,23 @@ static noinline int record_one_backref(u64 inum, u64 offset, u64 root_id,
2166 if (btrfs_file_extent_disk_bytenr(leaf, extent) != old->bytenr) 2166 if (btrfs_file_extent_disk_bytenr(leaf, extent) != old->bytenr)
2167 continue; 2167 continue;
2168 2168
2169 extent_offset = btrfs_file_extent_offset(leaf, extent); 2169 /*
2170 if (key.offset - extent_offset != offset) 2170 * 'offset' refers to the exact key.offset,
2171 * NOT the 'offset' field in btrfs_extent_data_ref, ie.
2172 * (key.offset - extent_offset).
2173 */
2174 if (key.offset != offset)
2171 continue; 2175 continue;
2172 2176
2177 extent_offset = btrfs_file_extent_offset(leaf, extent);
2173 num_bytes = btrfs_file_extent_num_bytes(leaf, extent); 2178 num_bytes = btrfs_file_extent_num_bytes(leaf, extent);
2179
2174 if (extent_offset >= old->extent_offset + old->offset + 2180 if (extent_offset >= old->extent_offset + old->offset +
2175 old->len || extent_offset + num_bytes <= 2181 old->len || extent_offset + num_bytes <=
2176 old->extent_offset + old->offset) 2182 old->extent_offset + old->offset)
2177 continue; 2183 continue;
2178 2184
2185 ret = 0;
2179 break; 2186 break;
2180 } 2187 }
2181 2188
@@ -2187,7 +2194,7 @@ static noinline int record_one_backref(u64 inum, u64 offset, u64 root_id,
2187 2194
2188 backref->root_id = root_id; 2195 backref->root_id = root_id;
2189 backref->inum = inum; 2196 backref->inum = inum;
2190 backref->file_pos = offset + extent_offset; 2197 backref->file_pos = offset;
2191 backref->num_bytes = num_bytes; 2198 backref->num_bytes = num_bytes;
2192 backref->extent_offset = extent_offset; 2199 backref->extent_offset = extent_offset;
2193 backref->generation = btrfs_file_extent_generation(leaf, extent); 2200 backref->generation = btrfs_file_extent_generation(leaf, extent);
@@ -2210,7 +2217,8 @@ static noinline bool record_extent_backrefs(struct btrfs_path *path,
2210 new->path = path; 2217 new->path = path;
2211 2218
2212 list_for_each_entry_safe(old, tmp, &new->head, list) { 2219 list_for_each_entry_safe(old, tmp, &new->head, list) {
2213 ret = iterate_inodes_from_logical(old->bytenr, fs_info, 2220 ret = iterate_inodes_from_logical(old->bytenr +
2221 old->extent_offset, fs_info,
2214 path, record_one_backref, 2222 path, record_one_backref,
2215 old); 2223 old);
2216 BUG_ON(ret < 0 && ret != -ENOENT); 2224 BUG_ON(ret < 0 && ret != -ENOENT);
@@ -4391,9 +4399,6 @@ static int btrfs_setsize(struct inode *inode, struct iattr *attr)
4391 int mask = attr->ia_valid; 4399 int mask = attr->ia_valid;
4392 int ret; 4400 int ret;
4393 4401
4394 if (newsize == oldsize)
4395 return 0;
4396
4397 /* 4402 /*
4398 * The regular truncate() case without ATTR_CTIME and ATTR_MTIME is a 4403 * The regular truncate() case without ATTR_CTIME and ATTR_MTIME is a
4399 * special case where we need to update the times despite not having 4404 * special case where we need to update the times despite not having
@@ -5165,14 +5170,31 @@ next:
5165 } 5170 }
5166 5171
5167 /* Reached end of directory/root. Bump pos past the last item. */ 5172 /* Reached end of directory/root. Bump pos past the last item. */
5168 if (key_type == BTRFS_DIR_INDEX_KEY) 5173 ctx->pos++;
5169 /* 5174
5170 * 32-bit glibc will use getdents64, but then strtol - 5175 /*
5171 * so the last number we can serve is this. 5176 * Stop new entries from being returned after we return the last
5172 */ 5177 * entry.
5173 ctx->pos = 0x7fffffff; 5178 *
5174 else 5179 * New directory entries are assigned a strictly increasing
5175 ctx->pos++; 5180 * offset. This means that new entries created during readdir
5181 * are *guaranteed* to be seen in the future by that readdir.
5182 * This has broken buggy programs which operate on names as
5183 * they're returned by readdir. Until we re-use freed offsets
5184 * we have this hack to stop new entries from being returned
5185 * under the assumption that they'll never reach this huge
5186 * offset.
5187 *
5188 * This is being careful not to overflow 32bit loff_t unless the
5189 * last entry requires it because doing so has broken 32bit apps
5190 * in the past.
5191 */
5192 if (key_type == BTRFS_DIR_INDEX_KEY) {
5193 if (ctx->pos >= INT_MAX)
5194 ctx->pos = LLONG_MAX;
5195 else
5196 ctx->pos = INT_MAX;
5197 }
5176nopos: 5198nopos:
5177 ret = 0; 5199 ret = 0;
5178err: 5200err:
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index d58cce77fc6c..af1931a5960d 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -983,12 +983,12 @@ static noinline int commit_cowonly_roots(struct btrfs_trans_handle *trans,
983 * a dirty root struct and adds it into the list of dead roots that need to 983 * a dirty root struct and adds it into the list of dead roots that need to
984 * be deleted 984 * be deleted
985 */ 985 */
986int btrfs_add_dead_root(struct btrfs_root *root) 986void btrfs_add_dead_root(struct btrfs_root *root)
987{ 987{
988 spin_lock(&root->fs_info->trans_lock); 988 spin_lock(&root->fs_info->trans_lock);
989 list_add_tail(&root->root_list, &root->fs_info->dead_roots); 989 if (list_empty(&root->root_list))
990 list_add_tail(&root->root_list, &root->fs_info->dead_roots);
990 spin_unlock(&root->fs_info->trans_lock); 991 spin_unlock(&root->fs_info->trans_lock);
991 return 0;
992} 992}
993 993
994/* 994/*
@@ -1925,7 +1925,7 @@ int btrfs_clean_one_deleted_snapshot(struct btrfs_root *root)
1925 } 1925 }
1926 root = list_first_entry(&fs_info->dead_roots, 1926 root = list_first_entry(&fs_info->dead_roots,
1927 struct btrfs_root, root_list); 1927 struct btrfs_root, root_list);
1928 list_del(&root->root_list); 1928 list_del_init(&root->root_list);
1929 spin_unlock(&fs_info->trans_lock); 1929 spin_unlock(&fs_info->trans_lock);
1930 1930
1931 pr_debug("btrfs: cleaner removing %llu\n", 1931 pr_debug("btrfs: cleaner removing %llu\n",
diff --git a/fs/btrfs/transaction.h b/fs/btrfs/transaction.h
index 005b0375d18c..defbc4269897 100644
--- a/fs/btrfs/transaction.h
+++ b/fs/btrfs/transaction.h
@@ -143,7 +143,7 @@ int btrfs_wait_for_commit(struct btrfs_root *root, u64 transid);
143int btrfs_write_and_wait_transaction(struct btrfs_trans_handle *trans, 143int btrfs_write_and_wait_transaction(struct btrfs_trans_handle *trans,
144 struct btrfs_root *root); 144 struct btrfs_root *root);
145 145
146int btrfs_add_dead_root(struct btrfs_root *root); 146void btrfs_add_dead_root(struct btrfs_root *root);
147int btrfs_defrag_root(struct btrfs_root *root); 147int btrfs_defrag_root(struct btrfs_root *root);
148int btrfs_clean_one_deleted_snapshot(struct btrfs_root *root); 148int btrfs_clean_one_deleted_snapshot(struct btrfs_root *root);
149int btrfs_commit_transaction(struct btrfs_trans_handle *trans, 149int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index 2c6791493637..ff60d8978ae2 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -3746,8 +3746,9 @@ next_slot:
3746 } 3746 }
3747 3747
3748log_extents: 3748log_extents:
3749 btrfs_release_path(path);
3750 btrfs_release_path(dst_path);
3749 if (fast_search) { 3751 if (fast_search) {
3750 btrfs_release_path(dst_path);
3751 ret = btrfs_log_changed_extents(trans, root, inode, dst_path); 3752 ret = btrfs_log_changed_extents(trans, root, inode, dst_path);
3752 if (ret) { 3753 if (ret) {
3753 err = ret; 3754 err = ret;
@@ -3764,8 +3765,6 @@ log_extents:
3764 } 3765 }
3765 3766
3766 if (inode_only == LOG_INODE_ALL && S_ISDIR(inode->i_mode)) { 3767 if (inode_only == LOG_INODE_ALL && S_ISDIR(inode->i_mode)) {
3767 btrfs_release_path(path);
3768 btrfs_release_path(dst_path);
3769 ret = log_directory_changes(trans, root, inode, path, dst_path); 3768 ret = log_directory_changes(trans, root, inode, path, dst_path);
3770 if (ret) { 3769 if (ret) {
3771 err = ret; 3770 err = ret;
diff --git a/fs/cifs/cifsencrypt.c b/fs/cifs/cifsencrypt.c
index 45e57cc38200..fc6f4f3a1a9d 100644
--- a/fs/cifs/cifsencrypt.c
+++ b/fs/cifs/cifsencrypt.c
@@ -43,17 +43,18 @@ cifs_crypto_shash_md5_allocate(struct TCP_Server_Info *server)
43 server->secmech.md5 = crypto_alloc_shash("md5", 0, 0); 43 server->secmech.md5 = crypto_alloc_shash("md5", 0, 0);
44 if (IS_ERR(server->secmech.md5)) { 44 if (IS_ERR(server->secmech.md5)) {
45 cifs_dbg(VFS, "could not allocate crypto md5\n"); 45 cifs_dbg(VFS, "could not allocate crypto md5\n");
46 return PTR_ERR(server->secmech.md5); 46 rc = PTR_ERR(server->secmech.md5);
47 server->secmech.md5 = NULL;
48 return rc;
47 } 49 }
48 50
49 size = sizeof(struct shash_desc) + 51 size = sizeof(struct shash_desc) +
50 crypto_shash_descsize(server->secmech.md5); 52 crypto_shash_descsize(server->secmech.md5);
51 server->secmech.sdescmd5 = kmalloc(size, GFP_KERNEL); 53 server->secmech.sdescmd5 = kmalloc(size, GFP_KERNEL);
52 if (!server->secmech.sdescmd5) { 54 if (!server->secmech.sdescmd5) {
53 rc = -ENOMEM;
54 crypto_free_shash(server->secmech.md5); 55 crypto_free_shash(server->secmech.md5);
55 server->secmech.md5 = NULL; 56 server->secmech.md5 = NULL;
56 return rc; 57 return -ENOMEM;
57 } 58 }
58 server->secmech.sdescmd5->shash.tfm = server->secmech.md5; 59 server->secmech.sdescmd5->shash.tfm = server->secmech.md5;
59 server->secmech.sdescmd5->shash.flags = 0x0; 60 server->secmech.sdescmd5->shash.flags = 0x0;
@@ -421,7 +422,7 @@ find_domain_name(struct cifs_ses *ses, const struct nls_table *nls_cp)
421 if (blobptr + attrsize > blobend) 422 if (blobptr + attrsize > blobend)
422 break; 423 break;
423 if (type == NTLMSSP_AV_NB_DOMAIN_NAME) { 424 if (type == NTLMSSP_AV_NB_DOMAIN_NAME) {
424 if (!attrsize) 425 if (!attrsize || attrsize >= CIFS_MAX_DOMAINNAME_LEN)
425 break; 426 break;
426 if (!ses->domainName) { 427 if (!ses->domainName) {
427 ses->domainName = 428 ses->domainName =
@@ -591,6 +592,7 @@ CalcNTLMv2_response(const struct cifs_ses *ses, char *ntlmv2_hash)
591 592
592static int crypto_hmacmd5_alloc(struct TCP_Server_Info *server) 593static int crypto_hmacmd5_alloc(struct TCP_Server_Info *server)
593{ 594{
595 int rc;
594 unsigned int size; 596 unsigned int size;
595 597
596 /* check if already allocated */ 598 /* check if already allocated */
@@ -600,7 +602,9 @@ static int crypto_hmacmd5_alloc(struct TCP_Server_Info *server)
600 server->secmech.hmacmd5 = crypto_alloc_shash("hmac(md5)", 0, 0); 602 server->secmech.hmacmd5 = crypto_alloc_shash("hmac(md5)", 0, 0);
601 if (IS_ERR(server->secmech.hmacmd5)) { 603 if (IS_ERR(server->secmech.hmacmd5)) {
602 cifs_dbg(VFS, "could not allocate crypto hmacmd5\n"); 604 cifs_dbg(VFS, "could not allocate crypto hmacmd5\n");
603 return PTR_ERR(server->secmech.hmacmd5); 605 rc = PTR_ERR(server->secmech.hmacmd5);
606 server->secmech.hmacmd5 = NULL;
607 return rc;
604 } 608 }
605 609
606 size = sizeof(struct shash_desc) + 610 size = sizeof(struct shash_desc) +
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 4bdd547dbf6f..85ea98d139fc 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -147,18 +147,17 @@ cifs_read_super(struct super_block *sb)
147 goto out_no_root; 147 goto out_no_root;
148 } 148 }
149 149
150 if (cifs_sb_master_tcon(cifs_sb)->nocase)
151 sb->s_d_op = &cifs_ci_dentry_ops;
152 else
153 sb->s_d_op = &cifs_dentry_ops;
154
150 sb->s_root = d_make_root(inode); 155 sb->s_root = d_make_root(inode);
151 if (!sb->s_root) { 156 if (!sb->s_root) {
152 rc = -ENOMEM; 157 rc = -ENOMEM;
153 goto out_no_root; 158 goto out_no_root;
154 } 159 }
155 160
156 /* do that *after* d_make_root() - we want NULL ->d_op for root here */
157 if (cifs_sb_master_tcon(cifs_sb)->nocase)
158 sb->s_d_op = &cifs_ci_dentry_ops;
159 else
160 sb->s_d_op = &cifs_dentry_ops;
161
162#ifdef CONFIG_CIFS_NFSD_EXPORT 161#ifdef CONFIG_CIFS_NFSD_EXPORT
163 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) { 162 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) {
164 cifs_dbg(FYI, "export ops supported\n"); 163 cifs_dbg(FYI, "export ops supported\n");
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index 1fdc37041057..52ca861ed35e 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -44,6 +44,7 @@
44#define MAX_TREE_SIZE (2 + MAX_SERVER_SIZE + 1 + MAX_SHARE_SIZE + 1) 44#define MAX_TREE_SIZE (2 + MAX_SERVER_SIZE + 1 + MAX_SHARE_SIZE + 1)
45#define MAX_SERVER_SIZE 15 45#define MAX_SERVER_SIZE 15
46#define MAX_SHARE_SIZE 80 46#define MAX_SHARE_SIZE 80
47#define CIFS_MAX_DOMAINNAME_LEN 256 /* max domain name length */
47#define MAX_USERNAME_SIZE 256 /* reasonable maximum for current servers */ 48#define MAX_USERNAME_SIZE 256 /* reasonable maximum for current servers */
48#define MAX_PASSWORD_SIZE 512 /* max for windows seems to be 256 wide chars */ 49#define MAX_PASSWORD_SIZE 512 /* max for windows seems to be 256 wide chars */
49 50
@@ -369,6 +370,9 @@ struct smb_version_operations {
369 void (*generate_signingkey)(struct TCP_Server_Info *server); 370 void (*generate_signingkey)(struct TCP_Server_Info *server);
370 int (*calc_signature)(struct smb_rqst *rqst, 371 int (*calc_signature)(struct smb_rqst *rqst,
371 struct TCP_Server_Info *server); 372 struct TCP_Server_Info *server);
373 int (*query_mf_symlink)(const unsigned char *path, char *pbuf,
374 unsigned int *pbytes_read, struct cifs_sb_info *cifs_sb,
375 unsigned int xid);
372}; 376};
373 377
374struct smb_version_values { 378struct smb_version_values {
diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h
index f7e584d047e2..b29a012bed33 100644
--- a/fs/cifs/cifsproto.h
+++ b/fs/cifs/cifsproto.h
@@ -497,5 +497,7 @@ void cifs_writev_complete(struct work_struct *work);
497struct cifs_writedata *cifs_writedata_alloc(unsigned int nr_pages, 497struct cifs_writedata *cifs_writedata_alloc(unsigned int nr_pages,
498 work_func_t complete); 498 work_func_t complete);
499void cifs_writedata_release(struct kref *refcount); 499void cifs_writedata_release(struct kref *refcount);
500 500int open_query_close_cifs_symlink(const unsigned char *path, char *pbuf,
501 unsigned int *pbytes_read, struct cifs_sb_info *cifs_sb,
502 unsigned int xid);
501#endif /* _CIFSPROTO_H */ 503#endif /* _CIFSPROTO_H */
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index fa68813396b5..d67c550c4980 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -1675,7 +1675,8 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
1675 if (string == NULL) 1675 if (string == NULL)
1676 goto out_nomem; 1676 goto out_nomem;
1677 1677
1678 if (strnlen(string, 256) == 256) { 1678 if (strnlen(string, CIFS_MAX_DOMAINNAME_LEN)
1679 == CIFS_MAX_DOMAINNAME_LEN) {
1679 printk(KERN_WARNING "CIFS: domain name too" 1680 printk(KERN_WARNING "CIFS: domain name too"
1680 " long\n"); 1681 " long\n");
1681 goto cifs_parse_mount_err; 1682 goto cifs_parse_mount_err;
@@ -2276,8 +2277,8 @@ cifs_put_smb_ses(struct cifs_ses *ses)
2276 2277
2277#ifdef CONFIG_KEYS 2278#ifdef CONFIG_KEYS
2278 2279
2279/* strlen("cifs:a:") + INET6_ADDRSTRLEN + 1 */ 2280/* strlen("cifs:a:") + CIFS_MAX_DOMAINNAME_LEN + 1 */
2280#define CIFSCREDS_DESC_SIZE (7 + INET6_ADDRSTRLEN + 1) 2281#define CIFSCREDS_DESC_SIZE (7 + CIFS_MAX_DOMAINNAME_LEN + 1)
2281 2282
2282/* Populate username and pw fields from keyring if possible */ 2283/* Populate username and pw fields from keyring if possible */
2283static int 2284static int
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 1e57f36ea1b2..7e36ae34e947 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -647,6 +647,7 @@ cifs_reopen_file(struct cifsFileInfo *cfile, bool can_flush)
647 oflags, &oplock, &cfile->fid.netfid, xid); 647 oflags, &oplock, &cfile->fid.netfid, xid);
648 if (rc == 0) { 648 if (rc == 0) {
649 cifs_dbg(FYI, "posix reopen succeeded\n"); 649 cifs_dbg(FYI, "posix reopen succeeded\n");
650 oparms.reconnect = true;
650 goto reopen_success; 651 goto reopen_success;
651 } 652 }
652 /* 653 /*
diff --git a/fs/cifs/link.c b/fs/cifs/link.c
index b83c3f5646bd..562044f700e5 100644
--- a/fs/cifs/link.c
+++ b/fs/cifs/link.c
@@ -305,67 +305,89 @@ CIFSCouldBeMFSymlink(const struct cifs_fattr *fattr)
305} 305}
306 306
307int 307int
308CIFSCheckMFSymlink(struct cifs_fattr *fattr, 308open_query_close_cifs_symlink(const unsigned char *path, char *pbuf,
309 const unsigned char *path, 309 unsigned int *pbytes_read, struct cifs_sb_info *cifs_sb,
310 struct cifs_sb_info *cifs_sb, unsigned int xid) 310 unsigned int xid)
311{ 311{
312 int rc; 312 int rc;
313 int oplock = 0; 313 int oplock = 0;
314 __u16 netfid = 0; 314 __u16 netfid = 0;
315 struct tcon_link *tlink; 315 struct tcon_link *tlink;
316 struct cifs_tcon *pTcon; 316 struct cifs_tcon *ptcon;
317 struct cifs_io_parms io_parms; 317 struct cifs_io_parms io_parms;
318 u8 *buf;
319 char *pbuf;
320 unsigned int bytes_read = 0;
321 int buf_type = CIFS_NO_BUFFER; 318 int buf_type = CIFS_NO_BUFFER;
322 unsigned int link_len = 0;
323 FILE_ALL_INFO file_info; 319 FILE_ALL_INFO file_info;
324 320
325 if (!CIFSCouldBeMFSymlink(fattr))
326 /* it's not a symlink */
327 return 0;
328
329 tlink = cifs_sb_tlink(cifs_sb); 321 tlink = cifs_sb_tlink(cifs_sb);
330 if (IS_ERR(tlink)) 322 if (IS_ERR(tlink))
331 return PTR_ERR(tlink); 323 return PTR_ERR(tlink);
332 pTcon = tlink_tcon(tlink); 324 ptcon = tlink_tcon(tlink);
333 325
334 rc = CIFSSMBOpen(xid, pTcon, path, FILE_OPEN, GENERIC_READ, 326 rc = CIFSSMBOpen(xid, ptcon, path, FILE_OPEN, GENERIC_READ,
335 CREATE_NOT_DIR, &netfid, &oplock, &file_info, 327 CREATE_NOT_DIR, &netfid, &oplock, &file_info,
336 cifs_sb->local_nls, 328 cifs_sb->local_nls,
337 cifs_sb->mnt_cifs_flags & 329 cifs_sb->mnt_cifs_flags &
338 CIFS_MOUNT_MAP_SPECIAL_CHR); 330 CIFS_MOUNT_MAP_SPECIAL_CHR);
339 if (rc != 0) 331 if (rc != 0) {
340 goto out; 332 cifs_put_tlink(tlink);
333 return rc;
334 }
341 335
342 if (file_info.EndOfFile != cpu_to_le64(CIFS_MF_SYMLINK_FILE_SIZE)) { 336 if (file_info.EndOfFile != cpu_to_le64(CIFS_MF_SYMLINK_FILE_SIZE)) {
343 CIFSSMBClose(xid, pTcon, netfid); 337 CIFSSMBClose(xid, ptcon, netfid);
338 cifs_put_tlink(tlink);
344 /* it's not a symlink */ 339 /* it's not a symlink */
345 goto out; 340 return rc;
346 } 341 }
347 342
348 buf = kmalloc(CIFS_MF_SYMLINK_FILE_SIZE, GFP_KERNEL);
349 if (!buf) {
350 rc = -ENOMEM;
351 goto out;
352 }
353 pbuf = buf;
354 io_parms.netfid = netfid; 343 io_parms.netfid = netfid;
355 io_parms.pid = current->tgid; 344 io_parms.pid = current->tgid;
356 io_parms.tcon = pTcon; 345 io_parms.tcon = ptcon;
357 io_parms.offset = 0; 346 io_parms.offset = 0;
358 io_parms.length = CIFS_MF_SYMLINK_FILE_SIZE; 347 io_parms.length = CIFS_MF_SYMLINK_FILE_SIZE;
359 348
360 rc = CIFSSMBRead(xid, &io_parms, &bytes_read, &pbuf, &buf_type); 349 rc = CIFSSMBRead(xid, &io_parms, pbytes_read, &pbuf, &buf_type);
361 CIFSSMBClose(xid, pTcon, netfid); 350 CIFSSMBClose(xid, ptcon, netfid);
362 if (rc != 0) { 351 cifs_put_tlink(tlink);
363 kfree(buf); 352 return rc;
353}
354
355
356int
357CIFSCheckMFSymlink(struct cifs_fattr *fattr,
358 const unsigned char *path,
359 struct cifs_sb_info *cifs_sb, unsigned int xid)
360{
361 int rc = 0;
362 u8 *buf = NULL;
363 unsigned int link_len = 0;
364 unsigned int bytes_read = 0;
365 struct cifs_tcon *ptcon;
366
367 if (!CIFSCouldBeMFSymlink(fattr))
368 /* it's not a symlink */
369 return 0;
370
371 buf = kmalloc(CIFS_MF_SYMLINK_FILE_SIZE, GFP_KERNEL);
372 if (!buf) {
373 rc = -ENOMEM;
364 goto out; 374 goto out;
365 } 375 }
366 376
377 ptcon = tlink_tcon(cifs_sb_tlink(cifs_sb));
378 if ((ptcon->ses) && (ptcon->ses->server->ops->query_mf_symlink))
379 rc = ptcon->ses->server->ops->query_mf_symlink(path, buf,
380 &bytes_read, cifs_sb, xid);
381 else
382 goto out;
383
384 if (rc != 0)
385 goto out;
386
387 if (bytes_read == 0) /* not a symlink */
388 goto out;
389
367 rc = CIFSParseMFSymlink(buf, bytes_read, &link_len, NULL); 390 rc = CIFSParseMFSymlink(buf, bytes_read, &link_len, NULL);
368 kfree(buf);
369 if (rc == -EINVAL) { 391 if (rc == -EINVAL) {
370 /* it's not a symlink */ 392 /* it's not a symlink */
371 rc = 0; 393 rc = 0;
@@ -381,7 +403,7 @@ CIFSCheckMFSymlink(struct cifs_fattr *fattr,
381 fattr->cf_mode |= S_IFLNK | S_IRWXU | S_IRWXG | S_IRWXO; 403 fattr->cf_mode |= S_IFLNK | S_IRWXU | S_IRWXG | S_IRWXO;
382 fattr->cf_dtype = DT_LNK; 404 fattr->cf_dtype = DT_LNK;
383out: 405out:
384 cifs_put_tlink(tlink); 406 kfree(buf);
385 return rc; 407 return rc;
386} 408}
387 409
diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c
index ab8778469394..69d2c826a23b 100644
--- a/fs/cifs/readdir.c
+++ b/fs/cifs/readdir.c
@@ -111,6 +111,14 @@ cifs_prime_dcache(struct dentry *parent, struct qstr *name,
111 return; 111 return;
112 } 112 }
113 113
114 /*
115 * If we know that the inode will need to be revalidated immediately,
116 * then don't create a new dentry for it. We'll end up doing an on
117 * the wire call either way and this spares us an invalidation.
118 */
119 if (fattr->cf_flags & CIFS_FATTR_NEED_REVAL)
120 return;
121
114 dentry = d_alloc(parent, name); 122 dentry = d_alloc(parent, name);
115 if (!dentry) 123 if (!dentry)
116 return; 124 return;
diff --git a/fs/cifs/sess.c b/fs/cifs/sess.c
index 79358e341fd2..08dd37bb23aa 100644
--- a/fs/cifs/sess.c
+++ b/fs/cifs/sess.c
@@ -197,7 +197,7 @@ static void unicode_domain_string(char **pbcc_area, struct cifs_ses *ses,
197 bytes_ret = 0; 197 bytes_ret = 0;
198 } else 198 } else
199 bytes_ret = cifs_strtoUTF16((__le16 *) bcc_ptr, ses->domainName, 199 bytes_ret = cifs_strtoUTF16((__le16 *) bcc_ptr, ses->domainName,
200 256, nls_cp); 200 CIFS_MAX_DOMAINNAME_LEN, nls_cp);
201 bcc_ptr += 2 * bytes_ret; 201 bcc_ptr += 2 * bytes_ret;
202 bcc_ptr += 2; /* account for null terminator */ 202 bcc_ptr += 2; /* account for null terminator */
203 203
@@ -255,8 +255,8 @@ static void ascii_ssetup_strings(char **pbcc_area, struct cifs_ses *ses,
255 255
256 /* copy domain */ 256 /* copy domain */
257 if (ses->domainName != NULL) { 257 if (ses->domainName != NULL) {
258 strncpy(bcc_ptr, ses->domainName, 256); 258 strncpy(bcc_ptr, ses->domainName, CIFS_MAX_DOMAINNAME_LEN);
259 bcc_ptr += strnlen(ses->domainName, 256); 259 bcc_ptr += strnlen(ses->domainName, CIFS_MAX_DOMAINNAME_LEN);
260 } /* else we will send a null domain name 260 } /* else we will send a null domain name
261 so the server will default to its own domain */ 261 so the server will default to its own domain */
262 *bcc_ptr = 0; 262 *bcc_ptr = 0;
diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
index 6457690731a2..60943978aec3 100644
--- a/fs/cifs/smb1ops.c
+++ b/fs/cifs/smb1ops.c
@@ -944,6 +944,7 @@ struct smb_version_operations smb1_operations = {
944 .mand_lock = cifs_mand_lock, 944 .mand_lock = cifs_mand_lock,
945 .mand_unlock_range = cifs_unlock_range, 945 .mand_unlock_range = cifs_unlock_range,
946 .push_mand_locks = cifs_push_mandatory_locks, 946 .push_mand_locks = cifs_push_mandatory_locks,
947 .query_mf_symlink = open_query_close_cifs_symlink,
947}; 948};
948 949
949struct smb_version_values smb1_values = { 950struct smb_version_values smb1_values = {
diff --git a/fs/cifs/smb2transport.c b/fs/cifs/smb2transport.c
index 301b191270b9..4f2300d020c7 100644
--- a/fs/cifs/smb2transport.c
+++ b/fs/cifs/smb2transport.c
@@ -42,6 +42,7 @@
42static int 42static int
43smb2_crypto_shash_allocate(struct TCP_Server_Info *server) 43smb2_crypto_shash_allocate(struct TCP_Server_Info *server)
44{ 44{
45 int rc;
45 unsigned int size; 46 unsigned int size;
46 47
47 if (server->secmech.sdeschmacsha256 != NULL) 48 if (server->secmech.sdeschmacsha256 != NULL)
@@ -50,7 +51,9 @@ smb2_crypto_shash_allocate(struct TCP_Server_Info *server)
50 server->secmech.hmacsha256 = crypto_alloc_shash("hmac(sha256)", 0, 0); 51 server->secmech.hmacsha256 = crypto_alloc_shash("hmac(sha256)", 0, 0);
51 if (IS_ERR(server->secmech.hmacsha256)) { 52 if (IS_ERR(server->secmech.hmacsha256)) {
52 cifs_dbg(VFS, "could not allocate crypto hmacsha256\n"); 53 cifs_dbg(VFS, "could not allocate crypto hmacsha256\n");
53 return PTR_ERR(server->secmech.hmacsha256); 54 rc = PTR_ERR(server->secmech.hmacsha256);
55 server->secmech.hmacsha256 = NULL;
56 return rc;
54 } 57 }
55 58
56 size = sizeof(struct shash_desc) + 59 size = sizeof(struct shash_desc) +
@@ -87,7 +90,9 @@ smb3_crypto_shash_allocate(struct TCP_Server_Info *server)
87 server->secmech.sdeschmacsha256 = NULL; 90 server->secmech.sdeschmacsha256 = NULL;
88 crypto_free_shash(server->secmech.hmacsha256); 91 crypto_free_shash(server->secmech.hmacsha256);
89 server->secmech.hmacsha256 = NULL; 92 server->secmech.hmacsha256 = NULL;
90 return PTR_ERR(server->secmech.cmacaes); 93 rc = PTR_ERR(server->secmech.cmacaes);
94 server->secmech.cmacaes = NULL;
95 return rc;
91 } 96 }
92 97
93 size = sizeof(struct shash_desc) + 98 size = sizeof(struct shash_desc) +
diff --git a/fs/dcache.c b/fs/dcache.c
index 87bdb5329c3c..83cfb834db03 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -2724,6 +2724,17 @@ char *dynamic_dname(struct dentry *dentry, char *buffer, int buflen,
2724 return memcpy(buffer, temp, sz); 2724 return memcpy(buffer, temp, sz);
2725} 2725}
2726 2726
2727char *simple_dname(struct dentry *dentry, char *buffer, int buflen)
2728{
2729 char *end = buffer + buflen;
2730 /* these dentries are never renamed, so d_lock is not needed */
2731 if (prepend(&end, &buflen, " (deleted)", 11) ||
2732 prepend_name(&end, &buflen, &dentry->d_name) ||
2733 prepend(&end, &buflen, "/", 1))
2734 end = ERR_PTR(-ENAMETOOLONG);
2735 return end;
2736}
2737
2727/* 2738/*
2728 * Write full pathname from the root of the filesystem into the buffer. 2739 * Write full pathname from the root of the filesystem into the buffer.
2729 */ 2740 */
diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
index 4888cb3fdef7..c7c83ff0f752 100644
--- a/fs/debugfs/inode.c
+++ b/fs/debugfs/inode.c
@@ -533,8 +533,7 @@ EXPORT_SYMBOL_GPL(debugfs_remove);
533 */ 533 */
534void debugfs_remove_recursive(struct dentry *dentry) 534void debugfs_remove_recursive(struct dentry *dentry)
535{ 535{
536 struct dentry *child; 536 struct dentry *child, *next, *parent;
537 struct dentry *parent;
538 537
539 if (IS_ERR_OR_NULL(dentry)) 538 if (IS_ERR_OR_NULL(dentry))
540 return; 539 return;
@@ -544,61 +543,37 @@ void debugfs_remove_recursive(struct dentry *dentry)
544 return; 543 return;
545 544
546 parent = dentry; 545 parent = dentry;
546 down:
547 mutex_lock(&parent->d_inode->i_mutex); 547 mutex_lock(&parent->d_inode->i_mutex);
548 list_for_each_entry_safe(child, next, &parent->d_subdirs, d_u.d_child) {
549 if (!debugfs_positive(child))
550 continue;
548 551
549 while (1) { 552 /* perhaps simple_empty(child) makes more sense */
550 /*
551 * When all dentries under "parent" has been removed,
552 * walk up the tree until we reach our starting point.
553 */
554 if (list_empty(&parent->d_subdirs)) {
555 mutex_unlock(&parent->d_inode->i_mutex);
556 if (parent == dentry)
557 break;
558 parent = parent->d_parent;
559 mutex_lock(&parent->d_inode->i_mutex);
560 }
561 child = list_entry(parent->d_subdirs.next, struct dentry,
562 d_u.d_child);
563 next_sibling:
564
565 /*
566 * If "child" isn't empty, walk down the tree and
567 * remove all its descendants first.
568 */
569 if (!list_empty(&child->d_subdirs)) { 553 if (!list_empty(&child->d_subdirs)) {
570 mutex_unlock(&parent->d_inode->i_mutex); 554 mutex_unlock(&parent->d_inode->i_mutex);
571 parent = child; 555 parent = child;
572 mutex_lock(&parent->d_inode->i_mutex); 556 goto down;
573 continue;
574 } 557 }
575 __debugfs_remove(child, parent); 558 up:
576 if (parent->d_subdirs.next == &child->d_u.d_child) { 559 if (!__debugfs_remove(child, parent))
577 /* 560 simple_release_fs(&debugfs_mount, &debugfs_mount_count);
578 * Try the next sibling.
579 */
580 if (child->d_u.d_child.next != &parent->d_subdirs) {
581 child = list_entry(child->d_u.d_child.next,
582 struct dentry,
583 d_u.d_child);
584 goto next_sibling;
585 }
586
587 /*
588 * Avoid infinite loop if we fail to remove
589 * one dentry.
590 */
591 mutex_unlock(&parent->d_inode->i_mutex);
592 break;
593 }
594 simple_release_fs(&debugfs_mount, &debugfs_mount_count);
595 } 561 }
596 562
597 parent = dentry->d_parent; 563 mutex_unlock(&parent->d_inode->i_mutex);
564 child = parent;
565 parent = parent->d_parent;
598 mutex_lock(&parent->d_inode->i_mutex); 566 mutex_lock(&parent->d_inode->i_mutex);
599 __debugfs_remove(dentry, parent); 567
568 if (child != dentry) {
569 next = list_entry(child->d_u.d_child.next, struct dentry,
570 d_u.d_child);
571 goto up;
572 }
573
574 if (!__debugfs_remove(child, parent))
575 simple_release_fs(&debugfs_mount, &debugfs_mount_count);
600 mutex_unlock(&parent->d_inode->i_mutex); 576 mutex_unlock(&parent->d_inode->i_mutex);
601 simple_release_fs(&debugfs_mount, &debugfs_mount_count);
602} 577}
603EXPORT_SYMBOL_GPL(debugfs_remove_recursive); 578EXPORT_SYMBOL_GPL(debugfs_remove_recursive);
604 579
diff --git a/fs/dlm/user.c b/fs/dlm/user.c
index 911649a47dd5..812149119fa3 100644
--- a/fs/dlm/user.c
+++ b/fs/dlm/user.c
@@ -686,7 +686,6 @@ static int device_close(struct inode *inode, struct file *file)
686 device_remove_lockspace() */ 686 device_remove_lockspace() */
687 687
688 sigprocmask(SIG_SETMASK, &tmpsig, NULL); 688 sigprocmask(SIG_SETMASK, &tmpsig, NULL);
689 recalc_sigpending();
690 689
691 return 0; 690 return 0;
692} 691}
diff --git a/fs/efs/inode.c b/fs/efs/inode.c
index f3913eb2c474..d15ccf20f1b3 100644
--- a/fs/efs/inode.c
+++ b/fs/efs/inode.c
@@ -57,7 +57,7 @@ struct inode *efs_iget(struct super_block *super, unsigned long ino)
57 struct inode *inode; 57 struct inode *inode;
58 58
59 inode = iget_locked(super, ino); 59 inode = iget_locked(super, ino);
60 if (IS_ERR(inode)) 60 if (!inode)
61 return ERR_PTR(-ENOMEM); 61 return ERR_PTR(-ENOMEM);
62 if (!(inode->i_state & I_NEW)) 62 if (!(inode->i_state & I_NEW))
63 return inode; 63 return inode;
diff --git a/fs/exec.c b/fs/exec.c
index 9c73def87642..fd774c7cb483 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -608,7 +608,7 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
608 return -ENOMEM; 608 return -ENOMEM;
609 609
610 lru_add_drain(); 610 lru_add_drain();
611 tlb_gather_mmu(&tlb, mm, 0); 611 tlb_gather_mmu(&tlb, mm, old_start, old_end);
612 if (new_end > old_start) { 612 if (new_end > old_start) {
613 /* 613 /*
614 * when the old and new regions overlap clear from new_end. 614 * when the old and new regions overlap clear from new_end.
@@ -625,7 +625,7 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
625 free_pgd_range(&tlb, old_start, old_end, new_end, 625 free_pgd_range(&tlb, old_start, old_end, new_end,
626 vma->vm_next ? vma->vm_next->vm_start : USER_PGTABLES_CEILING); 626 vma->vm_next ? vma->vm_next->vm_start : USER_PGTABLES_CEILING);
627 } 627 }
628 tlb_finish_mmu(&tlb, new_end, old_end); 628 tlb_finish_mmu(&tlb, old_start, old_end);
629 629
630 /* 630 /*
631 * Shrink the vma to just the new range. Always succeeds. 631 * Shrink the vma to just the new range. Always succeeds.
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index b577e45425b0..0ab26fbf3380 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -2086,6 +2086,7 @@ extern int ext4_sync_inode(handle_t *, struct inode *);
2086extern void ext4_dirty_inode(struct inode *, int); 2086extern void ext4_dirty_inode(struct inode *, int);
2087extern int ext4_change_inode_journal_flag(struct inode *, int); 2087extern int ext4_change_inode_journal_flag(struct inode *, int);
2088extern int ext4_get_inode_loc(struct inode *, struct ext4_iloc *); 2088extern int ext4_get_inode_loc(struct inode *, struct ext4_iloc *);
2089extern int ext4_inode_attach_jinode(struct inode *inode);
2089extern int ext4_can_truncate(struct inode *inode); 2090extern int ext4_can_truncate(struct inode *inode);
2090extern void ext4_truncate(struct inode *); 2091extern void ext4_truncate(struct inode *);
2091extern int ext4_punch_hole(struct inode *inode, loff_t offset, loff_t length); 2092extern int ext4_punch_hole(struct inode *inode, loff_t offset, loff_t length);
diff --git a/fs/ext4/ext4_jbd2.c b/fs/ext4/ext4_jbd2.c
index 72a3600aedbd..17ac112ab101 100644
--- a/fs/ext4/ext4_jbd2.c
+++ b/fs/ext4/ext4_jbd2.c
@@ -255,10 +255,10 @@ int __ext4_handle_dirty_metadata(const char *where, unsigned int line,
255 set_buffer_prio(bh); 255 set_buffer_prio(bh);
256 if (ext4_handle_valid(handle)) { 256 if (ext4_handle_valid(handle)) {
257 err = jbd2_journal_dirty_metadata(handle, bh); 257 err = jbd2_journal_dirty_metadata(handle, bh);
258 if (err) { 258 /* Errors can only happen if there is a bug */
259 /* Errors can only happen if there is a bug */ 259 if (WARN_ON_ONCE(err)) {
260 handle->h_err = err; 260 ext4_journal_abort_handle(where, line, __func__, bh,
261 __ext4_journal_stop(where, line, handle); 261 handle, err);
262 } 262 }
263 } else { 263 } else {
264 if (inode) 264 if (inode)
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index a61873808f76..72ba4705d4fa 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -4412,7 +4412,7 @@ void ext4_ext_truncate(handle_t *handle, struct inode *inode)
4412retry: 4412retry:
4413 err = ext4_es_remove_extent(inode, last_block, 4413 err = ext4_es_remove_extent(inode, last_block,
4414 EXT_MAX_BLOCKS - last_block); 4414 EXT_MAX_BLOCKS - last_block);
4415 if (err == ENOMEM) { 4415 if (err == -ENOMEM) {
4416 cond_resched(); 4416 cond_resched();
4417 congestion_wait(BLK_RW_ASYNC, HZ/50); 4417 congestion_wait(BLK_RW_ASYNC, HZ/50);
4418 goto retry; 4418 goto retry;
diff --git a/fs/ext4/file.c b/fs/ext4/file.c
index 6f4cc567c382..319c9d26279a 100644
--- a/fs/ext4/file.c
+++ b/fs/ext4/file.c
@@ -219,7 +219,6 @@ static int ext4_file_open(struct inode * inode, struct file * filp)
219{ 219{
220 struct super_block *sb = inode->i_sb; 220 struct super_block *sb = inode->i_sb;
221 struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); 221 struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
222 struct ext4_inode_info *ei = EXT4_I(inode);
223 struct vfsmount *mnt = filp->f_path.mnt; 222 struct vfsmount *mnt = filp->f_path.mnt;
224 struct path path; 223 struct path path;
225 char buf[64], *cp; 224 char buf[64], *cp;
@@ -259,22 +258,10 @@ static int ext4_file_open(struct inode * inode, struct file * filp)
259 * Set up the jbd2_inode if we are opening the inode for 258 * Set up the jbd2_inode if we are opening the inode for
260 * writing and the journal is present 259 * writing and the journal is present
261 */ 260 */
262 if (sbi->s_journal && !ei->jinode && (filp->f_mode & FMODE_WRITE)) { 261 if (filp->f_mode & FMODE_WRITE) {
263 struct jbd2_inode *jinode = jbd2_alloc_inode(GFP_KERNEL); 262 int ret = ext4_inode_attach_jinode(inode);
264 263 if (ret < 0)
265 spin_lock(&inode->i_lock); 264 return ret;
266 if (!ei->jinode) {
267 if (!jinode) {
268 spin_unlock(&inode->i_lock);
269 return -ENOMEM;
270 }
271 ei->jinode = jinode;
272 jbd2_journal_init_jbd_inode(ei->jinode, inode);
273 jinode = NULL;
274 }
275 spin_unlock(&inode->i_lock);
276 if (unlikely(jinode != NULL))
277 jbd2_free_inode(jinode);
278 } 265 }
279 return dquot_file_open(inode, filp); 266 return dquot_file_open(inode, filp);
280} 267}
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
index f03598c6ffd3..8bf5999875ee 100644
--- a/fs/ext4/ialloc.c
+++ b/fs/ext4/ialloc.c
@@ -734,11 +734,8 @@ repeat_in_this_group:
734 ino = ext4_find_next_zero_bit((unsigned long *) 734 ino = ext4_find_next_zero_bit((unsigned long *)
735 inode_bitmap_bh->b_data, 735 inode_bitmap_bh->b_data,
736 EXT4_INODES_PER_GROUP(sb), ino); 736 EXT4_INODES_PER_GROUP(sb), ino);
737 if (ino >= EXT4_INODES_PER_GROUP(sb)) { 737 if (ino >= EXT4_INODES_PER_GROUP(sb))
738 if (++group == ngroups) 738 goto next_group;
739 group = 0;
740 continue;
741 }
742 if (group == 0 && (ino+1) < EXT4_FIRST_INO(sb)) { 739 if (group == 0 && (ino+1) < EXT4_FIRST_INO(sb)) {
743 ext4_error(sb, "reserved inode found cleared - " 740 ext4_error(sb, "reserved inode found cleared - "
744 "inode=%lu", ino + 1); 741 "inode=%lu", ino + 1);
@@ -769,6 +766,9 @@ repeat_in_this_group:
769 goto got; /* we grabbed the inode! */ 766 goto got; /* we grabbed the inode! */
770 if (ino < EXT4_INODES_PER_GROUP(sb)) 767 if (ino < EXT4_INODES_PER_GROUP(sb))
771 goto repeat_in_this_group; 768 goto repeat_in_this_group;
769next_group:
770 if (++group == ngroups)
771 group = 0;
772 } 772 }
773 err = -ENOSPC; 773 err = -ENOSPC;
774 goto out; 774 goto out;
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index ba33c67d6e48..c2ca04e67a4f 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -555,14 +555,13 @@ int ext4_map_blocks(handle_t *handle, struct inode *inode,
555 int ret; 555 int ret;
556 unsigned long long status; 556 unsigned long long status;
557 557
558#ifdef ES_AGGRESSIVE_TEST 558 if (unlikely(retval != map->m_len)) {
559 if (retval != map->m_len) { 559 ext4_warning(inode->i_sb,
560 printk("ES len assertion failed for inode: %lu " 560 "ES len assertion failed for inode "
561 "retval %d != map->m_len %d " 561 "%lu: retval %d != map->m_len %d",
562 "in %s (lookup)\n", inode->i_ino, retval, 562 inode->i_ino, retval, map->m_len);
563 map->m_len, __func__); 563 WARN_ON(1);
564 } 564 }
565#endif
566 565
567 status = map->m_flags & EXT4_MAP_UNWRITTEN ? 566 status = map->m_flags & EXT4_MAP_UNWRITTEN ?
568 EXTENT_STATUS_UNWRITTEN : EXTENT_STATUS_WRITTEN; 567 EXTENT_STATUS_UNWRITTEN : EXTENT_STATUS_WRITTEN;
@@ -656,14 +655,13 @@ found:
656 int ret; 655 int ret;
657 unsigned long long status; 656 unsigned long long status;
658 657
659#ifdef ES_AGGRESSIVE_TEST 658 if (unlikely(retval != map->m_len)) {
660 if (retval != map->m_len) { 659 ext4_warning(inode->i_sb,
661 printk("ES len assertion failed for inode: %lu " 660 "ES len assertion failed for inode "
662 "retval %d != map->m_len %d " 661 "%lu: retval %d != map->m_len %d",
663 "in %s (allocation)\n", inode->i_ino, retval, 662 inode->i_ino, retval, map->m_len);
664 map->m_len, __func__); 663 WARN_ON(1);
665 } 664 }
666#endif
667 665
668 /* 666 /*
669 * If the extent has been zeroed out, we don't need to update 667 * If the extent has been zeroed out, we don't need to update
@@ -1637,14 +1635,13 @@ add_delayed:
1637 int ret; 1635 int ret;
1638 unsigned long long status; 1636 unsigned long long status;
1639 1637
1640#ifdef ES_AGGRESSIVE_TEST 1638 if (unlikely(retval != map->m_len)) {
1641 if (retval != map->m_len) { 1639 ext4_warning(inode->i_sb,
1642 printk("ES len assertion failed for inode: %lu " 1640 "ES len assertion failed for inode "
1643 "retval %d != map->m_len %d " 1641 "%lu: retval %d != map->m_len %d",
1644 "in %s (lookup)\n", inode->i_ino, retval, 1642 inode->i_ino, retval, map->m_len);
1645 map->m_len, __func__); 1643 WARN_ON(1);
1646 } 1644 }
1647#endif
1648 1645
1649 status = map->m_flags & EXT4_MAP_UNWRITTEN ? 1646 status = map->m_flags & EXT4_MAP_UNWRITTEN ?
1650 EXTENT_STATUS_UNWRITTEN : EXTENT_STATUS_WRITTEN; 1647 EXTENT_STATUS_UNWRITTEN : EXTENT_STATUS_WRITTEN;
@@ -3536,6 +3533,18 @@ int ext4_punch_hole(struct inode *inode, loff_t offset, loff_t length)
3536 offset; 3533 offset;
3537 } 3534 }
3538 3535
3536 if (offset & (sb->s_blocksize - 1) ||
3537 (offset + length) & (sb->s_blocksize - 1)) {
3538 /*
3539 * Attach jinode to inode for jbd2 if we do any zeroing of
3540 * partial block
3541 */
3542 ret = ext4_inode_attach_jinode(inode);
3543 if (ret < 0)
3544 goto out_mutex;
3545
3546 }
3547
3539 first_block_offset = round_up(offset, sb->s_blocksize); 3548 first_block_offset = round_up(offset, sb->s_blocksize);
3540 last_block_offset = round_down((offset + length), sb->s_blocksize) - 1; 3549 last_block_offset = round_down((offset + length), sb->s_blocksize) - 1;
3541 3550
@@ -3604,6 +3613,31 @@ out_mutex:
3604 return ret; 3613 return ret;
3605} 3614}
3606 3615
3616int ext4_inode_attach_jinode(struct inode *inode)
3617{
3618 struct ext4_inode_info *ei = EXT4_I(inode);
3619 struct jbd2_inode *jinode;
3620
3621 if (ei->jinode || !EXT4_SB(inode->i_sb)->s_journal)
3622 return 0;
3623
3624 jinode = jbd2_alloc_inode(GFP_KERNEL);
3625 spin_lock(&inode->i_lock);
3626 if (!ei->jinode) {
3627 if (!jinode) {
3628 spin_unlock(&inode->i_lock);
3629 return -ENOMEM;
3630 }
3631 ei->jinode = jinode;
3632 jbd2_journal_init_jbd_inode(ei->jinode, inode);
3633 jinode = NULL;
3634 }
3635 spin_unlock(&inode->i_lock);
3636 if (unlikely(jinode != NULL))
3637 jbd2_free_inode(jinode);
3638 return 0;
3639}
3640
3607/* 3641/*
3608 * ext4_truncate() 3642 * ext4_truncate()
3609 * 3643 *
@@ -3664,6 +3698,12 @@ void ext4_truncate(struct inode *inode)
3664 return; 3698 return;
3665 } 3699 }
3666 3700
3701 /* If we zero-out tail of the page, we have to create jinode for jbd2 */
3702 if (inode->i_size & (inode->i_sb->s_blocksize - 1)) {
3703 if (ext4_inode_attach_jinode(inode) < 0)
3704 return;
3705 }
3706
3667 if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)) 3707 if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))
3668 credits = ext4_writepage_trans_blocks(inode); 3708 credits = ext4_writepage_trans_blocks(inode);
3669 else 3709 else
diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
index 9491ac0590f7..c0427e2f6648 100644
--- a/fs/ext4/ioctl.c
+++ b/fs/ext4/ioctl.c
@@ -77,8 +77,10 @@ static void swap_inode_data(struct inode *inode1, struct inode *inode2)
77 memswap(ei1->i_data, ei2->i_data, sizeof(ei1->i_data)); 77 memswap(ei1->i_data, ei2->i_data, sizeof(ei1->i_data));
78 memswap(&ei1->i_flags, &ei2->i_flags, sizeof(ei1->i_flags)); 78 memswap(&ei1->i_flags, &ei2->i_flags, sizeof(ei1->i_flags));
79 memswap(&ei1->i_disksize, &ei2->i_disksize, sizeof(ei1->i_disksize)); 79 memswap(&ei1->i_disksize, &ei2->i_disksize, sizeof(ei1->i_disksize));
80 memswap(&ei1->i_es_tree, &ei2->i_es_tree, sizeof(ei1->i_es_tree)); 80 ext4_es_remove_extent(inode1, 0, EXT_MAX_BLOCKS);
81 memswap(&ei1->i_es_lru_nr, &ei2->i_es_lru_nr, sizeof(ei1->i_es_lru_nr)); 81 ext4_es_remove_extent(inode2, 0, EXT_MAX_BLOCKS);
82 ext4_es_lru_del(inode1);
83 ext4_es_lru_del(inode2);
82 84
83 isize = i_size_read(inode1); 85 isize = i_size_read(inode1);
84 i_size_write(inode1, i_size_read(inode2)); 86 i_size_write(inode1, i_size_read(inode2));
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index bca26f34edf4..b59373b625e9 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -1359,7 +1359,7 @@ static const struct mount_opts {
1359 {Opt_delalloc, EXT4_MOUNT_DELALLOC, 1359 {Opt_delalloc, EXT4_MOUNT_DELALLOC,
1360 MOPT_EXT4_ONLY | MOPT_SET | MOPT_EXPLICIT}, 1360 MOPT_EXT4_ONLY | MOPT_SET | MOPT_EXPLICIT},
1361 {Opt_nodelalloc, EXT4_MOUNT_DELALLOC, 1361 {Opt_nodelalloc, EXT4_MOUNT_DELALLOC,
1362 MOPT_EXT4_ONLY | MOPT_CLEAR | MOPT_EXPLICIT}, 1362 MOPT_EXT4_ONLY | MOPT_CLEAR},
1363 {Opt_journal_checksum, EXT4_MOUNT_JOURNAL_CHECKSUM, 1363 {Opt_journal_checksum, EXT4_MOUNT_JOURNAL_CHECKSUM,
1364 MOPT_EXT4_ONLY | MOPT_SET}, 1364 MOPT_EXT4_ONLY | MOPT_SET},
1365 {Opt_journal_async_commit, (EXT4_MOUNT_JOURNAL_ASYNC_COMMIT | 1365 {Opt_journal_async_commit, (EXT4_MOUNT_JOURNAL_ASYNC_COMMIT |
@@ -3483,7 +3483,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
3483 } 3483 }
3484 if (test_opt(sb, DIOREAD_NOLOCK)) { 3484 if (test_opt(sb, DIOREAD_NOLOCK)) {
3485 ext4_msg(sb, KERN_ERR, "can't mount with " 3485 ext4_msg(sb, KERN_ERR, "can't mount with "
3486 "both data=journal and delalloc"); 3486 "both data=journal and dioread_nolock");
3487 goto failed_mount; 3487 goto failed_mount;
3488 } 3488 }
3489 if (test_opt(sb, DELALLOC)) 3489 if (test_opt(sb, DELALLOC))
@@ -4727,6 +4727,21 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
4727 goto restore_opts; 4727 goto restore_opts;
4728 } 4728 }
4729 4729
4730 if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA) {
4731 if (test_opt2(sb, EXPLICIT_DELALLOC)) {
4732 ext4_msg(sb, KERN_ERR, "can't mount with "
4733 "both data=journal and delalloc");
4734 err = -EINVAL;
4735 goto restore_opts;
4736 }
4737 if (test_opt(sb, DIOREAD_NOLOCK)) {
4738 ext4_msg(sb, KERN_ERR, "can't mount with "
4739 "both data=journal and dioread_nolock");
4740 err = -EINVAL;
4741 goto restore_opts;
4742 }
4743 }
4744
4730 if (sbi->s_mount_flags & EXT4_MF_FS_ABORTED) 4745 if (sbi->s_mount_flags & EXT4_MF_FS_ABORTED)
4731 ext4_abort(sb, "Abort forced by user"); 4746 ext4_abort(sb, "Abort forced by user");
4732 4747
@@ -5481,6 +5496,7 @@ static void __exit ext4_exit_fs(void)
5481 kset_unregister(ext4_kset); 5496 kset_unregister(ext4_kset);
5482 ext4_exit_system_zone(); 5497 ext4_exit_system_zone();
5483 ext4_exit_pageio(); 5498 ext4_exit_pageio();
5499 ext4_exit_es();
5484} 5500}
5485 5501
5486MODULE_AUTHOR("Remy Card, Stephen Tweedie, Andrew Morton, Andreas Dilger, Theodore Ts'o and others"); 5502MODULE_AUTHOR("Remy Card, Stephen Tweedie, Andrew Morton, Andreas Dilger, Theodore Ts'o and others");
diff --git a/fs/fcntl.c b/fs/fcntl.c
index 6599222536eb..65343c3741ff 100644
--- a/fs/fcntl.c
+++ b/fs/fcntl.c
@@ -730,14 +730,14 @@ static int __init fcntl_init(void)
730 * Exceptions: O_NONBLOCK is a two bit define on parisc; O_NDELAY 730 * Exceptions: O_NONBLOCK is a two bit define on parisc; O_NDELAY
731 * is defined as O_NONBLOCK on some platforms and not on others. 731 * is defined as O_NONBLOCK on some platforms and not on others.
732 */ 732 */
733 BUILD_BUG_ON(19 - 1 /* for O_RDONLY being 0 */ != HWEIGHT32( 733 BUILD_BUG_ON(20 - 1 /* for O_RDONLY being 0 */ != HWEIGHT32(
734 O_RDONLY | O_WRONLY | O_RDWR | 734 O_RDONLY | O_WRONLY | O_RDWR |
735 O_CREAT | O_EXCL | O_NOCTTY | 735 O_CREAT | O_EXCL | O_NOCTTY |
736 O_TRUNC | O_APPEND | /* O_NONBLOCK | */ 736 O_TRUNC | O_APPEND | /* O_NONBLOCK | */
737 __O_SYNC | O_DSYNC | FASYNC | 737 __O_SYNC | O_DSYNC | FASYNC |
738 O_DIRECT | O_LARGEFILE | O_DIRECTORY | 738 O_DIRECT | O_LARGEFILE | O_DIRECTORY |
739 O_NOFOLLOW | O_NOATIME | O_CLOEXEC | 739 O_NOFOLLOW | O_NOATIME | O_CLOEXEC |
740 __FMODE_EXEC | O_PATH 740 __FMODE_EXEC | O_PATH | __O_TMPFILE
741 )); 741 ));
742 742
743 fasync_cache = kmem_cache_create("fasync_cache", 743 fasync_cache = kmem_cache_create("fasync_cache",
diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c
index 9435384562a2..544a809819c3 100644
--- a/fs/gfs2/glock.c
+++ b/fs/gfs2/glock.c
@@ -1838,14 +1838,14 @@ int __init gfs2_glock_init(void)
1838 1838
1839 glock_workqueue = alloc_workqueue("glock_workqueue", WQ_MEM_RECLAIM | 1839 glock_workqueue = alloc_workqueue("glock_workqueue", WQ_MEM_RECLAIM |
1840 WQ_HIGHPRI | WQ_FREEZABLE, 0); 1840 WQ_HIGHPRI | WQ_FREEZABLE, 0);
1841 if (IS_ERR(glock_workqueue)) 1841 if (!glock_workqueue)
1842 return PTR_ERR(glock_workqueue); 1842 return -ENOMEM;
1843 gfs2_delete_workqueue = alloc_workqueue("delete_workqueue", 1843 gfs2_delete_workqueue = alloc_workqueue("delete_workqueue",
1844 WQ_MEM_RECLAIM | WQ_FREEZABLE, 1844 WQ_MEM_RECLAIM | WQ_FREEZABLE,
1845 0); 1845 0);
1846 if (IS_ERR(gfs2_delete_workqueue)) { 1846 if (!gfs2_delete_workqueue) {
1847 destroy_workqueue(glock_workqueue); 1847 destroy_workqueue(glock_workqueue);
1848 return PTR_ERR(gfs2_delete_workqueue); 1848 return -ENOMEM;
1849 } 1849 }
1850 1850
1851 register_shrinker(&glock_shrinker); 1851 register_shrinker(&glock_shrinker);
diff --git a/fs/gfs2/glops.c b/fs/gfs2/glops.c
index 5f2e5224c51c..e2e0a90396e7 100644
--- a/fs/gfs2/glops.c
+++ b/fs/gfs2/glops.c
@@ -47,7 +47,8 @@ static void gfs2_ail_error(struct gfs2_glock *gl, const struct buffer_head *bh)
47 * None of the buffers should be dirty, locked, or pinned. 47 * None of the buffers should be dirty, locked, or pinned.
48 */ 48 */
49 49
50static void __gfs2_ail_flush(struct gfs2_glock *gl, bool fsync) 50static void __gfs2_ail_flush(struct gfs2_glock *gl, bool fsync,
51 unsigned int nr_revokes)
51{ 52{
52 struct gfs2_sbd *sdp = gl->gl_sbd; 53 struct gfs2_sbd *sdp = gl->gl_sbd;
53 struct list_head *head = &gl->gl_ail_list; 54 struct list_head *head = &gl->gl_ail_list;
@@ -57,7 +58,9 @@ static void __gfs2_ail_flush(struct gfs2_glock *gl, bool fsync)
57 58
58 gfs2_log_lock(sdp); 59 gfs2_log_lock(sdp);
59 spin_lock(&sdp->sd_ail_lock); 60 spin_lock(&sdp->sd_ail_lock);
60 list_for_each_entry_safe(bd, tmp, head, bd_ail_gl_list) { 61 list_for_each_entry_safe_reverse(bd, tmp, head, bd_ail_gl_list) {
62 if (nr_revokes == 0)
63 break;
61 bh = bd->bd_bh; 64 bh = bd->bd_bh;
62 if (bh->b_state & b_state) { 65 if (bh->b_state & b_state) {
63 if (fsync) 66 if (fsync)
@@ -65,6 +68,7 @@ static void __gfs2_ail_flush(struct gfs2_glock *gl, bool fsync)
65 gfs2_ail_error(gl, bh); 68 gfs2_ail_error(gl, bh);
66 } 69 }
67 gfs2_trans_add_revoke(sdp, bd); 70 gfs2_trans_add_revoke(sdp, bd);
71 nr_revokes--;
68 } 72 }
69 GLOCK_BUG_ON(gl, !fsync && atomic_read(&gl->gl_ail_count)); 73 GLOCK_BUG_ON(gl, !fsync && atomic_read(&gl->gl_ail_count));
70 spin_unlock(&sdp->sd_ail_lock); 74 spin_unlock(&sdp->sd_ail_lock);
@@ -91,7 +95,7 @@ static void gfs2_ail_empty_gl(struct gfs2_glock *gl)
91 WARN_ON_ONCE(current->journal_info); 95 WARN_ON_ONCE(current->journal_info);
92 current->journal_info = &tr; 96 current->journal_info = &tr;
93 97
94 __gfs2_ail_flush(gl, 0); 98 __gfs2_ail_flush(gl, 0, tr.tr_revokes);
95 99
96 gfs2_trans_end(sdp); 100 gfs2_trans_end(sdp);
97 gfs2_log_flush(sdp, NULL); 101 gfs2_log_flush(sdp, NULL);
@@ -101,15 +105,19 @@ void gfs2_ail_flush(struct gfs2_glock *gl, bool fsync)
101{ 105{
102 struct gfs2_sbd *sdp = gl->gl_sbd; 106 struct gfs2_sbd *sdp = gl->gl_sbd;
103 unsigned int revokes = atomic_read(&gl->gl_ail_count); 107 unsigned int revokes = atomic_read(&gl->gl_ail_count);
108 unsigned int max_revokes = (sdp->sd_sb.sb_bsize - sizeof(struct gfs2_log_descriptor)) / sizeof(u64);
104 int ret; 109 int ret;
105 110
106 if (!revokes) 111 if (!revokes)
107 return; 112 return;
108 113
109 ret = gfs2_trans_begin(sdp, 0, revokes); 114 while (revokes > max_revokes)
115 max_revokes += (sdp->sd_sb.sb_bsize - sizeof(struct gfs2_meta_header)) / sizeof(u64);
116
117 ret = gfs2_trans_begin(sdp, 0, max_revokes);
110 if (ret) 118 if (ret)
111 return; 119 return;
112 __gfs2_ail_flush(gl, fsync); 120 __gfs2_ail_flush(gl, fsync, max_revokes);
113 gfs2_trans_end(sdp); 121 gfs2_trans_end(sdp);
114 gfs2_log_flush(sdp, NULL); 122 gfs2_log_flush(sdp, NULL);
115} 123}
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index bbb2715171cd..64915eeae5a7 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -594,7 +594,7 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
594 } 594 }
595 gfs2_glock_dq_uninit(ghs); 595 gfs2_glock_dq_uninit(ghs);
596 if (IS_ERR(d)) 596 if (IS_ERR(d))
597 return PTR_RET(d); 597 return PTR_ERR(d);
598 return error; 598 return error;
599 } else if (error != -ENOENT) { 599 } else if (error != -ENOENT) {
600 goto fail_gunlock; 600 goto fail_gunlock;
@@ -1750,6 +1750,10 @@ static ssize_t gfs2_getxattr(struct dentry *dentry, const char *name,
1750 struct gfs2_holder gh; 1750 struct gfs2_holder gh;
1751 int ret; 1751 int ret;
1752 1752
1753 /* For selinux during lookup */
1754 if (gfs2_glock_is_locked_by_me(ip->i_gl))
1755 return generic_getxattr(dentry, name, data, size);
1756
1753 gfs2_holder_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY, &gh); 1757 gfs2_holder_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY, &gh);
1754 ret = gfs2_glock_nq(&gh); 1758 ret = gfs2_glock_nq(&gh);
1755 if (ret == 0) { 1759 if (ret == 0) {
diff --git a/fs/gfs2/main.c b/fs/gfs2/main.c
index e04d0e09ee7b..7b0f5043cf24 100644
--- a/fs/gfs2/main.c
+++ b/fs/gfs2/main.c
@@ -155,7 +155,7 @@ static int __init init_gfs2_fs(void)
155 goto fail_wq; 155 goto fail_wq;
156 156
157 gfs2_control_wq = alloc_workqueue("gfs2_control", 157 gfs2_control_wq = alloc_workqueue("gfs2_control",
158 WQ_NON_REENTRANT | WQ_UNBOUND | WQ_FREEZABLE, 0); 158 WQ_UNBOUND | WQ_FREEZABLE, 0);
159 if (!gfs2_control_wq) 159 if (!gfs2_control_wq)
160 goto fail_recovery; 160 goto fail_recovery;
161 161
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index a3f868ae3fd4..d19b30ababf1 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -463,6 +463,14 @@ static struct inode *hugetlbfs_get_root(struct super_block *sb,
463 return inode; 463 return inode;
464} 464}
465 465
466/*
467 * Hugetlbfs is not reclaimable; therefore its i_mmap_mutex will never
468 * be taken from reclaim -- unlike regular filesystems. This needs an
469 * annotation because huge_pmd_share() does an allocation under
470 * i_mmap_mutex.
471 */
472struct lock_class_key hugetlbfs_i_mmap_mutex_key;
473
466static struct inode *hugetlbfs_get_inode(struct super_block *sb, 474static struct inode *hugetlbfs_get_inode(struct super_block *sb,
467 struct inode *dir, 475 struct inode *dir,
468 umode_t mode, dev_t dev) 476 umode_t mode, dev_t dev)
@@ -474,6 +482,8 @@ static struct inode *hugetlbfs_get_inode(struct super_block *sb,
474 struct hugetlbfs_inode_info *info; 482 struct hugetlbfs_inode_info *info;
475 inode->i_ino = get_next_ino(); 483 inode->i_ino = get_next_ino();
476 inode_init_owner(inode, dir, mode); 484 inode_init_owner(inode, dir, mode);
485 lockdep_set_class(&inode->i_mapping->i_mmap_mutex,
486 &hugetlbfs_i_mmap_mutex_key);
477 inode->i_mapping->a_ops = &hugetlbfs_aops; 487 inode->i_mapping->a_ops = &hugetlbfs_aops;
478 inode->i_mapping->backing_dev_info =&hugetlbfs_backing_dev_info; 488 inode->i_mapping->backing_dev_info =&hugetlbfs_backing_dev_info;
479 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; 489 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
@@ -916,14 +926,8 @@ static int get_hstate_idx(int page_size_log)
916 return h - hstates; 926 return h - hstates;
917} 927}
918 928
919static char *hugetlb_dname(struct dentry *dentry, char *buffer, int buflen)
920{
921 return dynamic_dname(dentry, buffer, buflen, "/%s (deleted)",
922 dentry->d_name.name);
923}
924
925static struct dentry_operations anon_ops = { 929static struct dentry_operations anon_ops = {
926 .d_dname = hugetlb_dname 930 .d_dname = simple_dname
927}; 931};
928 932
929/* 933/*
diff --git a/fs/lockd/clntlock.c b/fs/lockd/clntlock.c
index 01bfe7662751..41e491b8e5d7 100644
--- a/fs/lockd/clntlock.c
+++ b/fs/lockd/clntlock.c
@@ -64,12 +64,17 @@ struct nlm_host *nlmclnt_init(const struct nlmclnt_initdata *nlm_init)
64 nlm_init->protocol, nlm_version, 64 nlm_init->protocol, nlm_version,
65 nlm_init->hostname, nlm_init->noresvport, 65 nlm_init->hostname, nlm_init->noresvport,
66 nlm_init->net); 66 nlm_init->net);
67 if (host == NULL) { 67 if (host == NULL)
68 lockd_down(nlm_init->net); 68 goto out_nohost;
69 return ERR_PTR(-ENOLCK); 69 if (host->h_rpcclnt == NULL && nlm_bind_host(host) == NULL)
70 } 70 goto out_nobind;
71 71
72 return host; 72 return host;
73out_nobind:
74 nlmclnt_release_host(host);
75out_nohost:
76 lockd_down(nlm_init->net);
77 return ERR_PTR(-ENOLCK);
73} 78}
74EXPORT_SYMBOL_GPL(nlmclnt_init); 79EXPORT_SYMBOL_GPL(nlmclnt_init);
75 80
diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
index 9760ecb9b60f..acd394716349 100644
--- a/fs/lockd/clntproc.c
+++ b/fs/lockd/clntproc.c
@@ -125,14 +125,15 @@ static void nlmclnt_setlockargs(struct nlm_rqst *req, struct file_lock *fl)
125{ 125{
126 struct nlm_args *argp = &req->a_args; 126 struct nlm_args *argp = &req->a_args;
127 struct nlm_lock *lock = &argp->lock; 127 struct nlm_lock *lock = &argp->lock;
128 char *nodename = req->a_host->h_rpcclnt->cl_nodename;
128 129
129 nlmclnt_next_cookie(&argp->cookie); 130 nlmclnt_next_cookie(&argp->cookie);
130 memcpy(&lock->fh, NFS_FH(file_inode(fl->fl_file)), sizeof(struct nfs_fh)); 131 memcpy(&lock->fh, NFS_FH(file_inode(fl->fl_file)), sizeof(struct nfs_fh));
131 lock->caller = utsname()->nodename; 132 lock->caller = nodename;
132 lock->oh.data = req->a_owner; 133 lock->oh.data = req->a_owner;
133 lock->oh.len = snprintf(req->a_owner, sizeof(req->a_owner), "%u@%s", 134 lock->oh.len = snprintf(req->a_owner, sizeof(req->a_owner), "%u@%s",
134 (unsigned int)fl->fl_u.nfs_fl.owner->pid, 135 (unsigned int)fl->fl_u.nfs_fl.owner->pid,
135 utsname()->nodename); 136 nodename);
136 lock->svid = fl->fl_u.nfs_fl.owner->pid; 137 lock->svid = fl->fl_u.nfs_fl.owner->pid;
137 lock->fl.fl_start = fl->fl_start; 138 lock->fl.fl_start = fl->fl_start;
138 lock->fl.fl_end = fl->fl_end; 139 lock->fl.fl_end = fl->fl_end;
diff --git a/fs/namei.c b/fs/namei.c
index 8b61d103a8a7..89a612e392eb 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -3671,15 +3671,11 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,
3671 if ((flags & ~(AT_SYMLINK_FOLLOW | AT_EMPTY_PATH)) != 0) 3671 if ((flags & ~(AT_SYMLINK_FOLLOW | AT_EMPTY_PATH)) != 0)
3672 return -EINVAL; 3672 return -EINVAL;
3673 /* 3673 /*
3674 * To use null names we require CAP_DAC_READ_SEARCH 3674 * Using empty names is equivalent to using AT_SYMLINK_FOLLOW
3675 * This ensures that not everyone will be able to create 3675 * on /proc/self/fd/<fd>.
3676 * handlink using the passed filedescriptor.
3677 */ 3676 */
3678 if (flags & AT_EMPTY_PATH) { 3677 if (flags & AT_EMPTY_PATH)
3679 if (!capable(CAP_DAC_READ_SEARCH))
3680 return -ENOENT;
3681 how = LOOKUP_EMPTY; 3678 how = LOOKUP_EMPTY;
3682 }
3683 3679
3684 if (flags & AT_SYMLINK_FOLLOW) 3680 if (flags & AT_SYMLINK_FOLLOW)
3685 how |= LOOKUP_FOLLOW; 3681 how |= LOOKUP_FOLLOW;
diff --git a/fs/namespace.c b/fs/namespace.c
index 7b1ca9ba0b0a..a45ba4f267fe 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -1429,7 +1429,7 @@ struct vfsmount *collect_mounts(struct path *path)
1429 CL_COPY_ALL | CL_PRIVATE); 1429 CL_COPY_ALL | CL_PRIVATE);
1430 namespace_unlock(); 1430 namespace_unlock();
1431 if (IS_ERR(tree)) 1431 if (IS_ERR(tree))
1432 return NULL; 1432 return ERR_CAST(tree);
1433 return &tree->mnt; 1433 return &tree->mnt;
1434} 1434}
1435 1435
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index af6e806044d7..941246f2b43d 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -463,7 +463,6 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr, st
463 unlock_new_inode(inode); 463 unlock_new_inode(inode);
464 } else 464 } else
465 nfs_refresh_inode(inode, fattr); 465 nfs_refresh_inode(inode, fattr);
466 nfs_setsecurity(inode, fattr, label);
467 dprintk("NFS: nfs_fhget(%s/%Ld fh_crc=0x%08x ct=%d)\n", 466 dprintk("NFS: nfs_fhget(%s/%Ld fh_crc=0x%08x ct=%d)\n",
468 inode->i_sb->s_id, 467 inode->i_sb->s_id,
469 (long long)NFS_FILEID(inode), 468 (long long)NFS_FILEID(inode),
@@ -963,9 +962,15 @@ EXPORT_SYMBOL_GPL(nfs_revalidate_inode);
963static int nfs_invalidate_mapping(struct inode *inode, struct address_space *mapping) 962static int nfs_invalidate_mapping(struct inode *inode, struct address_space *mapping)
964{ 963{
965 struct nfs_inode *nfsi = NFS_I(inode); 964 struct nfs_inode *nfsi = NFS_I(inode);
966 965 int ret;
966
967 if (mapping->nrpages != 0) { 967 if (mapping->nrpages != 0) {
968 int ret = invalidate_inode_pages2(mapping); 968 if (S_ISREG(inode->i_mode)) {
969 ret = nfs_sync_mapping(mapping);
970 if (ret < 0)
971 return ret;
972 }
973 ret = invalidate_inode_pages2(mapping);
969 if (ret < 0) 974 if (ret < 0)
970 return ret; 975 return ret;
971 } 976 }
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index cf11799297c4..108a774095f7 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -3071,15 +3071,13 @@ struct rpc_clnt *
3071nfs4_proc_lookup_mountpoint(struct inode *dir, struct qstr *name, 3071nfs4_proc_lookup_mountpoint(struct inode *dir, struct qstr *name,
3072 struct nfs_fh *fhandle, struct nfs_fattr *fattr) 3072 struct nfs_fh *fhandle, struct nfs_fattr *fattr)
3073{ 3073{
3074 struct rpc_clnt *client = NFS_CLIENT(dir);
3074 int status; 3075 int status;
3075 struct rpc_clnt *client = rpc_clone_client(NFS_CLIENT(dir));
3076 3076
3077 status = nfs4_proc_lookup_common(&client, dir, name, fhandle, fattr, NULL); 3077 status = nfs4_proc_lookup_common(&client, dir, name, fhandle, fattr, NULL);
3078 if (status < 0) { 3078 if (status < 0)
3079 rpc_shutdown_client(client);
3080 return ERR_PTR(status); 3079 return ERR_PTR(status);
3081 } 3080 return (client == NFS_CLIENT(dir)) ? rpc_clone_client(client) : client;
3082 return client;
3083} 3081}
3084 3082
3085static int _nfs4_proc_access(struct inode *inode, struct nfs_access_entry *entry) 3083static int _nfs4_proc_access(struct inode *inode, struct nfs_access_entry *entry)
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index 71fdc0dfa0d2..f6db66d8f647 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -2478,6 +2478,10 @@ struct dentry *nfs_fs_mount_common(struct nfs_server *server,
2478 if (server->flags & NFS_MOUNT_NOAC) 2478 if (server->flags & NFS_MOUNT_NOAC)
2479 sb_mntdata.mntflags |= MS_SYNCHRONOUS; 2479 sb_mntdata.mntflags |= MS_SYNCHRONOUS;
2480 2480
2481 if (mount_info->cloned != NULL && mount_info->cloned->sb != NULL)
2482 if (mount_info->cloned->sb->s_flags & MS_SYNCHRONOUS)
2483 sb_mntdata.mntflags |= MS_SYNCHRONOUS;
2484
2481 /* Get a superblock - note that we may end up sharing one that already exists */ 2485 /* Get a superblock - note that we may end up sharing one that already exists */
2482 s = sget(nfs_mod->nfs_fs, compare_super, nfs_set_super, flags, &sb_mntdata); 2486 s = sget(nfs_mod->nfs_fs, compare_super, nfs_set_super, flags, &sb_mntdata);
2483 if (IS_ERR(s)) { 2487 if (IS_ERR(s)) {
diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
index 0d4c410e4589..419572f33b72 100644
--- a/fs/nfsd/nfs4proc.c
+++ b/fs/nfsd/nfs4proc.c
@@ -1524,7 +1524,7 @@ static inline u32 nfsd4_write_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op)
1524static inline u32 nfsd4_exchange_id_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op) 1524static inline u32 nfsd4_exchange_id_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op)
1525{ 1525{
1526 return (op_encode_hdr_size + 2 + 1 + /* eir_clientid, eir_sequenceid */\ 1526 return (op_encode_hdr_size + 2 + 1 + /* eir_clientid, eir_sequenceid */\
1527 1 + 1 + 0 + /* eir_flags, spr_how, SP4_NONE (for now) */\ 1527 1 + 1 + 2 + /* eir_flags, spr_how, spo_must_enforce & _allow */\
1528 2 + /*eir_server_owner.so_minor_id */\ 1528 2 + /*eir_server_owner.so_minor_id */\
1529 /* eir_server_owner.so_major_id<> */\ 1529 /* eir_server_owner.so_major_id<> */\
1530 XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + 1 +\ 1530 XDR_QUADLEN(NFS4_OPAQUE_LIMIT) + 1 +\
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 280acef6f0dc..43f42290e5df 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -1264,6 +1264,8 @@ static bool svc_rqst_integrity_protected(struct svc_rqst *rqstp)
1264 struct svc_cred *cr = &rqstp->rq_cred; 1264 struct svc_cred *cr = &rqstp->rq_cred;
1265 u32 service; 1265 u32 service;
1266 1266
1267 if (!cr->cr_gss_mech)
1268 return false;
1267 service = gss_pseudoflavor_to_service(cr->cr_gss_mech, cr->cr_flavor); 1269 service = gss_pseudoflavor_to_service(cr->cr_gss_mech, cr->cr_flavor);
1268 return service == RPC_GSS_SVC_INTEGRITY || 1270 return service == RPC_GSS_SVC_INTEGRITY ||
1269 service == RPC_GSS_SVC_PRIVACY; 1271 service == RPC_GSS_SVC_PRIVACY;
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index 0c0f3ea90de5..c2a4701d7286 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -3360,7 +3360,8 @@ nfsd4_encode_exchange_id(struct nfsd4_compoundres *resp, __be32 nfserr,
3360 8 /* eir_clientid */ + 3360 8 /* eir_clientid */ +
3361 4 /* eir_sequenceid */ + 3361 4 /* eir_sequenceid */ +
3362 4 /* eir_flags */ + 3362 4 /* eir_flags */ +
3363 4 /* spr_how (SP4_NONE) */ + 3363 4 /* spr_how */ +
3364 8 /* spo_must_enforce, spo_must_allow */ +
3364 8 /* so_minor_id */ + 3365 8 /* so_minor_id */ +
3365 4 /* so_major_id.len */ + 3366 4 /* so_major_id.len */ +
3366 (XDR_QUADLEN(major_id_sz) * 4) + 3367 (XDR_QUADLEN(major_id_sz) * 4) +
@@ -3372,8 +3373,6 @@ nfsd4_encode_exchange_id(struct nfsd4_compoundres *resp, __be32 nfserr,
3372 WRITE32(exid->seqid); 3373 WRITE32(exid->seqid);
3373 WRITE32(exid->flags); 3374 WRITE32(exid->flags);
3374 3375
3375 /* state_protect4_r. Currently only support SP4_NONE */
3376 BUG_ON(exid->spa_how != SP4_NONE);
3377 WRITE32(exid->spa_how); 3376 WRITE32(exid->spa_how);
3378 switch (exid->spa_how) { 3377 switch (exid->spa_how) {
3379 case SP4_NONE: 3378 case SP4_NONE:
diff --git a/fs/nilfs2/segbuf.c b/fs/nilfs2/segbuf.c
index dc9a913784ab..2d8be51f90dc 100644
--- a/fs/nilfs2/segbuf.c
+++ b/fs/nilfs2/segbuf.c
@@ -345,8 +345,7 @@ static void nilfs_end_bio_write(struct bio *bio, int err)
345 345
346 if (err == -EOPNOTSUPP) { 346 if (err == -EOPNOTSUPP) {
347 set_bit(BIO_EOPNOTSUPP, &bio->bi_flags); 347 set_bit(BIO_EOPNOTSUPP, &bio->bi_flags);
348 bio_put(bio); 348 /* to be detected by nilfs_segbuf_submit_bio() */
349 /* to be detected by submit_seg_bio() */
350 } 349 }
351 350
352 if (!uptodate) 351 if (!uptodate)
@@ -377,12 +376,12 @@ static int nilfs_segbuf_submit_bio(struct nilfs_segment_buffer *segbuf,
377 bio->bi_private = segbuf; 376 bio->bi_private = segbuf;
378 bio_get(bio); 377 bio_get(bio);
379 submit_bio(mode, bio); 378 submit_bio(mode, bio);
379 segbuf->sb_nbio++;
380 if (bio_flagged(bio, BIO_EOPNOTSUPP)) { 380 if (bio_flagged(bio, BIO_EOPNOTSUPP)) {
381 bio_put(bio); 381 bio_put(bio);
382 err = -EOPNOTSUPP; 382 err = -EOPNOTSUPP;
383 goto failed; 383 goto failed;
384 } 384 }
385 segbuf->sb_nbio++;
386 bio_put(bio); 385 bio_put(bio);
387 386
388 wi->bio = NULL; 387 wi->bio = NULL;
diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c
index 79736a28d84f..2abf97b2a592 100644
--- a/fs/ocfs2/aops.c
+++ b/fs/ocfs2/aops.c
@@ -1757,7 +1757,7 @@ try_again:
1757 goto out; 1757 goto out;
1758 } else if (ret == 1) { 1758 } else if (ret == 1) {
1759 clusters_need = wc->w_clen; 1759 clusters_need = wc->w_clen;
1760 ret = ocfs2_refcount_cow(inode, filp, di_bh, 1760 ret = ocfs2_refcount_cow(inode, di_bh,
1761 wc->w_cpos, wc->w_clen, UINT_MAX); 1761 wc->w_cpos, wc->w_clen, UINT_MAX);
1762 if (ret) { 1762 if (ret) {
1763 mlog_errno(ret); 1763 mlog_errno(ret);
diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c
index eb760d8acd50..30544ce8e9f7 100644
--- a/fs/ocfs2/dir.c
+++ b/fs/ocfs2/dir.c
@@ -2153,11 +2153,9 @@ int ocfs2_empty_dir(struct inode *inode)
2153{ 2153{
2154 int ret; 2154 int ret;
2155 struct ocfs2_empty_dir_priv priv = { 2155 struct ocfs2_empty_dir_priv priv = {
2156 .ctx.actor = ocfs2_empty_dir_filldir 2156 .ctx.actor = ocfs2_empty_dir_filldir,
2157 }; 2157 };
2158 2158
2159 memset(&priv, 0, sizeof(priv));
2160
2161 if (ocfs2_dir_indexed(inode)) { 2159 if (ocfs2_dir_indexed(inode)) {
2162 ret = ocfs2_empty_dir_dx(inode, &priv); 2160 ret = ocfs2_empty_dir_dx(inode, &priv);
2163 if (ret) 2161 if (ret)
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index 41000f223ca4..3261d71319ee 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -370,7 +370,7 @@ static int ocfs2_cow_file_pos(struct inode *inode,
370 if (!(ext_flags & OCFS2_EXT_REFCOUNTED)) 370 if (!(ext_flags & OCFS2_EXT_REFCOUNTED))
371 goto out; 371 goto out;
372 372
373 return ocfs2_refcount_cow(inode, NULL, fe_bh, cpos, 1, cpos+1); 373 return ocfs2_refcount_cow(inode, fe_bh, cpos, 1, cpos+1);
374 374
375out: 375out:
376 return status; 376 return status;
@@ -899,7 +899,7 @@ static int ocfs2_zero_extend_get_range(struct inode *inode,
899 zero_clusters = last_cpos - zero_cpos; 899 zero_clusters = last_cpos - zero_cpos;
900 900
901 if (needs_cow) { 901 if (needs_cow) {
902 rc = ocfs2_refcount_cow(inode, NULL, di_bh, zero_cpos, 902 rc = ocfs2_refcount_cow(inode, di_bh, zero_cpos,
903 zero_clusters, UINT_MAX); 903 zero_clusters, UINT_MAX);
904 if (rc) { 904 if (rc) {
905 mlog_errno(rc); 905 mlog_errno(rc);
@@ -2078,7 +2078,7 @@ static int ocfs2_prepare_inode_for_refcount(struct inode *inode,
2078 2078
2079 *meta_level = 1; 2079 *meta_level = 1;
2080 2080
2081 ret = ocfs2_refcount_cow(inode, file, di_bh, cpos, clusters, UINT_MAX); 2081 ret = ocfs2_refcount_cow(inode, di_bh, cpos, clusters, UINT_MAX);
2082 if (ret) 2082 if (ret)
2083 mlog_errno(ret); 2083 mlog_errno(ret);
2084out: 2084out:
diff --git a/fs/ocfs2/journal.h b/fs/ocfs2/journal.h
index 96f9ac237e86..0a992737dcaf 100644
--- a/fs/ocfs2/journal.h
+++ b/fs/ocfs2/journal.h
@@ -537,7 +537,7 @@ static inline int ocfs2_calc_extend_credits(struct super_block *sb,
537 extent_blocks = 1 + 1 + le16_to_cpu(root_el->l_tree_depth); 537 extent_blocks = 1 + 1 + le16_to_cpu(root_el->l_tree_depth);
538 538
539 return bitmap_blocks + sysfile_bitmap_blocks + extent_blocks + 539 return bitmap_blocks + sysfile_bitmap_blocks + extent_blocks +
540 ocfs2_quota_trans_credits(sb) + bits_wanted; 540 ocfs2_quota_trans_credits(sb);
541} 541}
542 542
543static inline int ocfs2_calc_symlink_credits(struct super_block *sb) 543static inline int ocfs2_calc_symlink_credits(struct super_block *sb)
diff --git a/fs/ocfs2/move_extents.c b/fs/ocfs2/move_extents.c
index f1fc172175b6..452068b45749 100644
--- a/fs/ocfs2/move_extents.c
+++ b/fs/ocfs2/move_extents.c
@@ -69,7 +69,7 @@ static int __ocfs2_move_extent(handle_t *handle,
69 u64 ino = ocfs2_metadata_cache_owner(context->et.et_ci); 69 u64 ino = ocfs2_metadata_cache_owner(context->et.et_ci);
70 u64 old_blkno = ocfs2_clusters_to_blocks(inode->i_sb, p_cpos); 70 u64 old_blkno = ocfs2_clusters_to_blocks(inode->i_sb, p_cpos);
71 71
72 ret = ocfs2_duplicate_clusters_by_page(handle, context->file, cpos, 72 ret = ocfs2_duplicate_clusters_by_page(handle, inode, cpos,
73 p_cpos, new_p_cpos, len); 73 p_cpos, new_p_cpos, len);
74 if (ret) { 74 if (ret) {
75 mlog_errno(ret); 75 mlog_errno(ret);
diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c
index 9f6b96a09615..a70d604593b6 100644
--- a/fs/ocfs2/refcounttree.c
+++ b/fs/ocfs2/refcounttree.c
@@ -49,7 +49,6 @@
49 49
50struct ocfs2_cow_context { 50struct ocfs2_cow_context {
51 struct inode *inode; 51 struct inode *inode;
52 struct file *file;
53 u32 cow_start; 52 u32 cow_start;
54 u32 cow_len; 53 u32 cow_len;
55 struct ocfs2_extent_tree data_et; 54 struct ocfs2_extent_tree data_et;
@@ -66,7 +65,7 @@ struct ocfs2_cow_context {
66 u32 *num_clusters, 65 u32 *num_clusters,
67 unsigned int *extent_flags); 66 unsigned int *extent_flags);
68 int (*cow_duplicate_clusters)(handle_t *handle, 67 int (*cow_duplicate_clusters)(handle_t *handle,
69 struct file *file, 68 struct inode *inode,
70 u32 cpos, u32 old_cluster, 69 u32 cpos, u32 old_cluster,
71 u32 new_cluster, u32 new_len); 70 u32 new_cluster, u32 new_len);
72}; 71};
@@ -2922,14 +2921,12 @@ static int ocfs2_clear_cow_buffer(handle_t *handle, struct buffer_head *bh)
2922} 2921}
2923 2922
2924int ocfs2_duplicate_clusters_by_page(handle_t *handle, 2923int ocfs2_duplicate_clusters_by_page(handle_t *handle,
2925 struct file *file, 2924 struct inode *inode,
2926 u32 cpos, u32 old_cluster, 2925 u32 cpos, u32 old_cluster,
2927 u32 new_cluster, u32 new_len) 2926 u32 new_cluster, u32 new_len)
2928{ 2927{
2929 int ret = 0, partial; 2928 int ret = 0, partial;
2930 struct inode *inode = file_inode(file); 2929 struct super_block *sb = inode->i_sb;
2931 struct ocfs2_caching_info *ci = INODE_CACHE(inode);
2932 struct super_block *sb = ocfs2_metadata_cache_get_super(ci);
2933 u64 new_block = ocfs2_clusters_to_blocks(sb, new_cluster); 2930 u64 new_block = ocfs2_clusters_to_blocks(sb, new_cluster);
2934 struct page *page; 2931 struct page *page;
2935 pgoff_t page_index; 2932 pgoff_t page_index;
@@ -2978,13 +2975,6 @@ int ocfs2_duplicate_clusters_by_page(handle_t *handle,
2978 if (PAGE_CACHE_SIZE <= OCFS2_SB(sb)->s_clustersize) 2975 if (PAGE_CACHE_SIZE <= OCFS2_SB(sb)->s_clustersize)
2979 BUG_ON(PageDirty(page)); 2976 BUG_ON(PageDirty(page));
2980 2977
2981 if (PageReadahead(page)) {
2982 page_cache_async_readahead(mapping,
2983 &file->f_ra, file,
2984 page, page_index,
2985 readahead_pages);
2986 }
2987
2988 if (!PageUptodate(page)) { 2978 if (!PageUptodate(page)) {
2989 ret = block_read_full_page(page, ocfs2_get_block); 2979 ret = block_read_full_page(page, ocfs2_get_block);
2990 if (ret) { 2980 if (ret) {
@@ -3004,7 +2994,8 @@ int ocfs2_duplicate_clusters_by_page(handle_t *handle,
3004 } 2994 }
3005 } 2995 }
3006 2996
3007 ocfs2_map_and_dirty_page(inode, handle, from, to, 2997 ocfs2_map_and_dirty_page(inode,
2998 handle, from, to,
3008 page, 0, &new_block); 2999 page, 0, &new_block);
3009 mark_page_accessed(page); 3000 mark_page_accessed(page);
3010unlock: 3001unlock:
@@ -3020,12 +3011,11 @@ unlock:
3020} 3011}
3021 3012
3022int ocfs2_duplicate_clusters_by_jbd(handle_t *handle, 3013int ocfs2_duplicate_clusters_by_jbd(handle_t *handle,
3023 struct file *file, 3014 struct inode *inode,
3024 u32 cpos, u32 old_cluster, 3015 u32 cpos, u32 old_cluster,
3025 u32 new_cluster, u32 new_len) 3016 u32 new_cluster, u32 new_len)
3026{ 3017{
3027 int ret = 0; 3018 int ret = 0;
3028 struct inode *inode = file_inode(file);
3029 struct super_block *sb = inode->i_sb; 3019 struct super_block *sb = inode->i_sb;
3030 struct ocfs2_caching_info *ci = INODE_CACHE(inode); 3020 struct ocfs2_caching_info *ci = INODE_CACHE(inode);
3031 int i, blocks = ocfs2_clusters_to_blocks(sb, new_len); 3021 int i, blocks = ocfs2_clusters_to_blocks(sb, new_len);
@@ -3150,7 +3140,7 @@ static int ocfs2_replace_clusters(handle_t *handle,
3150 3140
3151 /*If the old clusters is unwritten, no need to duplicate. */ 3141 /*If the old clusters is unwritten, no need to duplicate. */
3152 if (!(ext_flags & OCFS2_EXT_UNWRITTEN)) { 3142 if (!(ext_flags & OCFS2_EXT_UNWRITTEN)) {
3153 ret = context->cow_duplicate_clusters(handle, context->file, 3143 ret = context->cow_duplicate_clusters(handle, context->inode,
3154 cpos, old, new, len); 3144 cpos, old, new, len);
3155 if (ret) { 3145 if (ret) {
3156 mlog_errno(ret); 3146 mlog_errno(ret);
@@ -3428,35 +3418,12 @@ static int ocfs2_replace_cow(struct ocfs2_cow_context *context)
3428 return ret; 3418 return ret;
3429} 3419}
3430 3420
3431static void ocfs2_readahead_for_cow(struct inode *inode,
3432 struct file *file,
3433 u32 start, u32 len)
3434{
3435 struct address_space *mapping;
3436 pgoff_t index;
3437 unsigned long num_pages;
3438 int cs_bits = OCFS2_SB(inode->i_sb)->s_clustersize_bits;
3439
3440 if (!file)
3441 return;
3442
3443 mapping = file->f_mapping;
3444 num_pages = (len << cs_bits) >> PAGE_CACHE_SHIFT;
3445 if (!num_pages)
3446 num_pages = 1;
3447
3448 index = ((loff_t)start << cs_bits) >> PAGE_CACHE_SHIFT;
3449 page_cache_sync_readahead(mapping, &file->f_ra, file,
3450 index, num_pages);
3451}
3452
3453/* 3421/*
3454 * Starting at cpos, try to CoW write_len clusters. Don't CoW 3422 * Starting at cpos, try to CoW write_len clusters. Don't CoW
3455 * past max_cpos. This will stop when it runs into a hole or an 3423 * past max_cpos. This will stop when it runs into a hole or an
3456 * unrefcounted extent. 3424 * unrefcounted extent.
3457 */ 3425 */
3458static int ocfs2_refcount_cow_hunk(struct inode *inode, 3426static int ocfs2_refcount_cow_hunk(struct inode *inode,
3459 struct file *file,
3460 struct buffer_head *di_bh, 3427 struct buffer_head *di_bh,
3461 u32 cpos, u32 write_len, u32 max_cpos) 3428 u32 cpos, u32 write_len, u32 max_cpos)
3462{ 3429{
@@ -3485,8 +3452,6 @@ static int ocfs2_refcount_cow_hunk(struct inode *inode,
3485 3452
3486 BUG_ON(cow_len == 0); 3453 BUG_ON(cow_len == 0);
3487 3454
3488 ocfs2_readahead_for_cow(inode, file, cow_start, cow_len);
3489
3490 context = kzalloc(sizeof(struct ocfs2_cow_context), GFP_NOFS); 3455 context = kzalloc(sizeof(struct ocfs2_cow_context), GFP_NOFS);
3491 if (!context) { 3456 if (!context) {
3492 ret = -ENOMEM; 3457 ret = -ENOMEM;
@@ -3508,7 +3473,6 @@ static int ocfs2_refcount_cow_hunk(struct inode *inode,
3508 context->ref_root_bh = ref_root_bh; 3473 context->ref_root_bh = ref_root_bh;
3509 context->cow_duplicate_clusters = ocfs2_duplicate_clusters_by_page; 3474 context->cow_duplicate_clusters = ocfs2_duplicate_clusters_by_page;
3510 context->get_clusters = ocfs2_di_get_clusters; 3475 context->get_clusters = ocfs2_di_get_clusters;
3511 context->file = file;
3512 3476
3513 ocfs2_init_dinode_extent_tree(&context->data_et, 3477 ocfs2_init_dinode_extent_tree(&context->data_et,
3514 INODE_CACHE(inode), di_bh); 3478 INODE_CACHE(inode), di_bh);
@@ -3537,7 +3501,6 @@ out:
3537 * clusters between cpos and cpos+write_len are safe to modify. 3501 * clusters between cpos and cpos+write_len are safe to modify.
3538 */ 3502 */
3539int ocfs2_refcount_cow(struct inode *inode, 3503int ocfs2_refcount_cow(struct inode *inode,
3540 struct file *file,
3541 struct buffer_head *di_bh, 3504 struct buffer_head *di_bh,
3542 u32 cpos, u32 write_len, u32 max_cpos) 3505 u32 cpos, u32 write_len, u32 max_cpos)
3543{ 3506{
@@ -3557,7 +3520,7 @@ int ocfs2_refcount_cow(struct inode *inode,
3557 num_clusters = write_len; 3520 num_clusters = write_len;
3558 3521
3559 if (ext_flags & OCFS2_EXT_REFCOUNTED) { 3522 if (ext_flags & OCFS2_EXT_REFCOUNTED) {
3560 ret = ocfs2_refcount_cow_hunk(inode, file, di_bh, cpos, 3523 ret = ocfs2_refcount_cow_hunk(inode, di_bh, cpos,
3561 num_clusters, max_cpos); 3524 num_clusters, max_cpos);
3562 if (ret) { 3525 if (ret) {
3563 mlog_errno(ret); 3526 mlog_errno(ret);
diff --git a/fs/ocfs2/refcounttree.h b/fs/ocfs2/refcounttree.h
index 7754608c83a4..6422bbcdb525 100644
--- a/fs/ocfs2/refcounttree.h
+++ b/fs/ocfs2/refcounttree.h
@@ -53,7 +53,7 @@ int ocfs2_prepare_refcount_change_for_del(struct inode *inode,
53 int *credits, 53 int *credits,
54 int *ref_blocks); 54 int *ref_blocks);
55int ocfs2_refcount_cow(struct inode *inode, 55int ocfs2_refcount_cow(struct inode *inode,
56 struct file *filep, struct buffer_head *di_bh, 56 struct buffer_head *di_bh,
57 u32 cpos, u32 write_len, u32 max_cpos); 57 u32 cpos, u32 write_len, u32 max_cpos);
58 58
59typedef int (ocfs2_post_refcount_func)(struct inode *inode, 59typedef int (ocfs2_post_refcount_func)(struct inode *inode,
@@ -85,11 +85,11 @@ int ocfs2_refcount_cow_xattr(struct inode *inode,
85 u32 cpos, u32 write_len, 85 u32 cpos, u32 write_len,
86 struct ocfs2_post_refcount *post); 86 struct ocfs2_post_refcount *post);
87int ocfs2_duplicate_clusters_by_page(handle_t *handle, 87int ocfs2_duplicate_clusters_by_page(handle_t *handle,
88 struct file *file, 88 struct inode *inode,
89 u32 cpos, u32 old_cluster, 89 u32 cpos, u32 old_cluster,
90 u32 new_cluster, u32 new_len); 90 u32 new_cluster, u32 new_len);
91int ocfs2_duplicate_clusters_by_jbd(handle_t *handle, 91int ocfs2_duplicate_clusters_by_jbd(handle_t *handle,
92 struct file *file, 92 struct inode *inode,
93 u32 cpos, u32 old_cluster, 93 u32 cpos, u32 old_cluster,
94 u32 new_cluster, u32 new_len); 94 u32 new_cluster, u32 new_len);
95int ocfs2_cow_sync_writeback(struct super_block *sb, 95int ocfs2_cow_sync_writeback(struct super_block *sb,
diff --git a/fs/open.c b/fs/open.c
index d53e29895082..7931f76acc2b 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -823,7 +823,7 @@ static inline int build_open_flags(int flags, umode_t mode, struct open_flags *o
823 int lookup_flags = 0; 823 int lookup_flags = 0;
824 int acc_mode; 824 int acc_mode;
825 825
826 if (flags & O_CREAT) 826 if (flags & (O_CREAT | __O_TMPFILE))
827 op->mode = (mode & S_IALLUGO) | S_IFREG; 827 op->mode = (mode & S_IALLUGO) | S_IFREG;
828 else 828 else
829 op->mode = 0; 829 op->mode = 0;
diff --git a/fs/proc/fd.c b/fs/proc/fd.c
index 75f2890abbd8..0ff80f9b930f 100644
--- a/fs/proc/fd.c
+++ b/fs/proc/fd.c
@@ -230,8 +230,6 @@ static int proc_readfd_common(struct file *file, struct dir_context *ctx,
230 230
231 if (!dir_emit_dots(file, ctx)) 231 if (!dir_emit_dots(file, ctx))
232 goto out; 232 goto out;
233 if (!dir_emit_dots(file, ctx))
234 goto out;
235 files = get_files_struct(p); 233 files = get_files_struct(p);
236 if (!files) 234 if (!files)
237 goto out; 235 goto out;
diff --git a/fs/proc/generic.c b/fs/proc/generic.c
index 94441a407337..737e15615b04 100644
--- a/fs/proc/generic.c
+++ b/fs/proc/generic.c
@@ -271,7 +271,7 @@ int proc_readdir_de(struct proc_dir_entry *de, struct file *file,
271 de = next; 271 de = next;
272 } while (de); 272 } while (de);
273 spin_unlock(&proc_subdir_lock); 273 spin_unlock(&proc_subdir_lock);
274 return 0; 274 return 1;
275} 275}
276 276
277int proc_readdir(struct file *file, struct dir_context *ctx) 277int proc_readdir(struct file *file, struct dir_context *ctx)
diff --git a/fs/proc/root.c b/fs/proc/root.c
index 229e366598da..e0a790da726d 100644
--- a/fs/proc/root.c
+++ b/fs/proc/root.c
@@ -205,7 +205,9 @@ static struct dentry *proc_root_lookup(struct inode * dir, struct dentry * dentr
205static int proc_root_readdir(struct file *file, struct dir_context *ctx) 205static int proc_root_readdir(struct file *file, struct dir_context *ctx)
206{ 206{
207 if (ctx->pos < FIRST_PROCESS_ENTRY) { 207 if (ctx->pos < FIRST_PROCESS_ENTRY) {
208 proc_readdir(file, ctx); 208 int error = proc_readdir(file, ctx);
209 if (unlikely(error <= 0))
210 return error;
209 ctx->pos = FIRST_PROCESS_ENTRY; 211 ctx->pos = FIRST_PROCESS_ENTRY;
210 } 212 }
211 213
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index dbf61f6174f0..107d026f5d6e 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -730,8 +730,16 @@ static inline void clear_soft_dirty(struct vm_area_struct *vma,
730 * of how soft-dirty works. 730 * of how soft-dirty works.
731 */ 731 */
732 pte_t ptent = *pte; 732 pte_t ptent = *pte;
733 ptent = pte_wrprotect(ptent); 733
734 ptent = pte_clear_flags(ptent, _PAGE_SOFT_DIRTY); 734 if (pte_present(ptent)) {
735 ptent = pte_wrprotect(ptent);
736 ptent = pte_clear_flags(ptent, _PAGE_SOFT_DIRTY);
737 } else if (is_swap_pte(ptent)) {
738 ptent = pte_swp_clear_soft_dirty(ptent);
739 } else if (pte_file(ptent)) {
740 ptent = pte_file_clear_soft_dirty(ptent);
741 }
742
735 set_pte_at(vma->vm_mm, addr, pte, ptent); 743 set_pte_at(vma->vm_mm, addr, pte, ptent);
736#endif 744#endif
737} 745}
@@ -752,14 +760,15 @@ static int clear_refs_pte_range(pmd_t *pmd, unsigned long addr,
752 pte = pte_offset_map_lock(vma->vm_mm, pmd, addr, &ptl); 760 pte = pte_offset_map_lock(vma->vm_mm, pmd, addr, &ptl);
753 for (; addr != end; pte++, addr += PAGE_SIZE) { 761 for (; addr != end; pte++, addr += PAGE_SIZE) {
754 ptent = *pte; 762 ptent = *pte;
755 if (!pte_present(ptent))
756 continue;
757 763
758 if (cp->type == CLEAR_REFS_SOFT_DIRTY) { 764 if (cp->type == CLEAR_REFS_SOFT_DIRTY) {
759 clear_soft_dirty(vma, addr, pte); 765 clear_soft_dirty(vma, addr, pte);
760 continue; 766 continue;
761 } 767 }
762 768
769 if (!pte_present(ptent))
770 continue;
771
763 page = vm_normal_page(vma, addr, ptent); 772 page = vm_normal_page(vma, addr, ptent);
764 if (!page) 773 if (!page)
765 continue; 774 continue;
@@ -859,7 +868,7 @@ typedef struct {
859} pagemap_entry_t; 868} pagemap_entry_t;
860 869
861struct pagemapread { 870struct pagemapread {
862 int pos, len; 871 int pos, len; /* units: PM_ENTRY_BYTES, not bytes */
863 pagemap_entry_t *buffer; 872 pagemap_entry_t *buffer;
864 bool v2; 873 bool v2;
865}; 874};
@@ -867,7 +876,7 @@ struct pagemapread {
867#define PAGEMAP_WALK_SIZE (PMD_SIZE) 876#define PAGEMAP_WALK_SIZE (PMD_SIZE)
868#define PAGEMAP_WALK_MASK (PMD_MASK) 877#define PAGEMAP_WALK_MASK (PMD_MASK)
869 878
870#define PM_ENTRY_BYTES sizeof(u64) 879#define PM_ENTRY_BYTES sizeof(pagemap_entry_t)
871#define PM_STATUS_BITS 3 880#define PM_STATUS_BITS 3
872#define PM_STATUS_OFFSET (64 - PM_STATUS_BITS) 881#define PM_STATUS_OFFSET (64 - PM_STATUS_BITS)
873#define PM_STATUS_MASK (((1LL << PM_STATUS_BITS) - 1) << PM_STATUS_OFFSET) 882#define PM_STATUS_MASK (((1LL << PM_STATUS_BITS) - 1) << PM_STATUS_OFFSET)
@@ -930,8 +939,10 @@ static void pte_to_pagemap_entry(pagemap_entry_t *pme, struct pagemapread *pm,
930 flags = PM_PRESENT; 939 flags = PM_PRESENT;
931 page = vm_normal_page(vma, addr, pte); 940 page = vm_normal_page(vma, addr, pte);
932 } else if (is_swap_pte(pte)) { 941 } else if (is_swap_pte(pte)) {
933 swp_entry_t entry = pte_to_swp_entry(pte); 942 swp_entry_t entry;
934 943 if (pte_swp_soft_dirty(pte))
944 flags2 |= __PM_SOFT_DIRTY;
945 entry = pte_to_swp_entry(pte);
935 frame = swp_type(entry) | 946 frame = swp_type(entry) |
936 (swp_offset(entry) << MAX_SWAPFILES_SHIFT); 947 (swp_offset(entry) << MAX_SWAPFILES_SHIFT);
937 flags = PM_SWAP; 948 flags = PM_SWAP;
@@ -1116,8 +1127,8 @@ static ssize_t pagemap_read(struct file *file, char __user *buf,
1116 goto out_task; 1127 goto out_task;
1117 1128
1118 pm.v2 = soft_dirty_cleared; 1129 pm.v2 = soft_dirty_cleared;
1119 pm.len = PM_ENTRY_BYTES * (PAGEMAP_WALK_SIZE >> PAGE_SHIFT); 1130 pm.len = (PAGEMAP_WALK_SIZE >> PAGE_SHIFT);
1120 pm.buffer = kmalloc(pm.len, GFP_TEMPORARY); 1131 pm.buffer = kmalloc(pm.len * PM_ENTRY_BYTES, GFP_TEMPORARY);
1121 ret = -ENOMEM; 1132 ret = -ENOMEM;
1122 if (!pm.buffer) 1133 if (!pm.buffer)
1123 goto out_task; 1134 goto out_task;
diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c
index 33532f79b4f7..a958444a75fc 100644
--- a/fs/reiserfs/procfs.c
+++ b/fs/reiserfs/procfs.c
@@ -19,12 +19,13 @@
19/* 19/*
20 * LOCKING: 20 * LOCKING:
21 * 21 *
22 * We rely on new Alexander Viro's super-block locking. 22 * These guys are evicted from procfs as the very first step in ->kill_sb().
23 * 23 *
24 */ 24 */
25 25
26static int show_version(struct seq_file *m, struct super_block *sb) 26static int show_version(struct seq_file *m, void *unused)
27{ 27{
28 struct super_block *sb = m->private;
28 char *format; 29 char *format;
29 30
30 if (REISERFS_SB(sb)->s_properties & (1 << REISERFS_3_6)) { 31 if (REISERFS_SB(sb)->s_properties & (1 << REISERFS_3_6)) {
@@ -66,8 +67,9 @@ static int show_version(struct seq_file *m, struct super_block *sb)
66#define DJP( x ) le32_to_cpu( jp -> x ) 67#define DJP( x ) le32_to_cpu( jp -> x )
67#define JF( x ) ( r -> s_journal -> x ) 68#define JF( x ) ( r -> s_journal -> x )
68 69
69static int show_super(struct seq_file *m, struct super_block *sb) 70static int show_super(struct seq_file *m, void *unused)
70{ 71{
72 struct super_block *sb = m->private;
71 struct reiserfs_sb_info *r = REISERFS_SB(sb); 73 struct reiserfs_sb_info *r = REISERFS_SB(sb);
72 74
73 seq_printf(m, "state: \t%s\n" 75 seq_printf(m, "state: \t%s\n"
@@ -128,8 +130,9 @@ static int show_super(struct seq_file *m, struct super_block *sb)
128 return 0; 130 return 0;
129} 131}
130 132
131static int show_per_level(struct seq_file *m, struct super_block *sb) 133static int show_per_level(struct seq_file *m, void *unused)
132{ 134{
135 struct super_block *sb = m->private;
133 struct reiserfs_sb_info *r = REISERFS_SB(sb); 136 struct reiserfs_sb_info *r = REISERFS_SB(sb);
134 int level; 137 int level;
135 138
@@ -186,8 +189,9 @@ static int show_per_level(struct seq_file *m, struct super_block *sb)
186 return 0; 189 return 0;
187} 190}
188 191
189static int show_bitmap(struct seq_file *m, struct super_block *sb) 192static int show_bitmap(struct seq_file *m, void *unused)
190{ 193{
194 struct super_block *sb = m->private;
191 struct reiserfs_sb_info *r = REISERFS_SB(sb); 195 struct reiserfs_sb_info *r = REISERFS_SB(sb);
192 196
193 seq_printf(m, "free_block: %lu\n" 197 seq_printf(m, "free_block: %lu\n"
@@ -218,8 +222,9 @@ static int show_bitmap(struct seq_file *m, struct super_block *sb)
218 return 0; 222 return 0;
219} 223}
220 224
221static int show_on_disk_super(struct seq_file *m, struct super_block *sb) 225static int show_on_disk_super(struct seq_file *m, void *unused)
222{ 226{
227 struct super_block *sb = m->private;
223 struct reiserfs_sb_info *sb_info = REISERFS_SB(sb); 228 struct reiserfs_sb_info *sb_info = REISERFS_SB(sb);
224 struct reiserfs_super_block *rs = sb_info->s_rs; 229 struct reiserfs_super_block *rs = sb_info->s_rs;
225 int hash_code = DFL(s_hash_function_code); 230 int hash_code = DFL(s_hash_function_code);
@@ -261,8 +266,9 @@ static int show_on_disk_super(struct seq_file *m, struct super_block *sb)
261 return 0; 266 return 0;
262} 267}
263 268
264static int show_oidmap(struct seq_file *m, struct super_block *sb) 269static int show_oidmap(struct seq_file *m, void *unused)
265{ 270{
271 struct super_block *sb = m->private;
266 struct reiserfs_sb_info *sb_info = REISERFS_SB(sb); 272 struct reiserfs_sb_info *sb_info = REISERFS_SB(sb);
267 struct reiserfs_super_block *rs = sb_info->s_rs; 273 struct reiserfs_super_block *rs = sb_info->s_rs;
268 unsigned int mapsize = le16_to_cpu(rs->s_v1.s_oid_cursize); 274 unsigned int mapsize = le16_to_cpu(rs->s_v1.s_oid_cursize);
@@ -291,8 +297,9 @@ static int show_oidmap(struct seq_file *m, struct super_block *sb)
291 return 0; 297 return 0;
292} 298}
293 299
294static int show_journal(struct seq_file *m, struct super_block *sb) 300static int show_journal(struct seq_file *m, void *unused)
295{ 301{
302 struct super_block *sb = m->private;
296 struct reiserfs_sb_info *r = REISERFS_SB(sb); 303 struct reiserfs_sb_info *r = REISERFS_SB(sb);
297 struct reiserfs_super_block *rs = r->s_rs; 304 struct reiserfs_super_block *rs = r->s_rs;
298 struct journal_params *jp = &rs->s_v1.s_journal; 305 struct journal_params *jp = &rs->s_v1.s_journal;
@@ -383,92 +390,24 @@ static int show_journal(struct seq_file *m, struct super_block *sb)
383 return 0; 390 return 0;
384} 391}
385 392
386/* iterator */
387static int test_sb(struct super_block *sb, void *data)
388{
389 return data == sb;
390}
391
392static int set_sb(struct super_block *sb, void *data)
393{
394 return -ENOENT;
395}
396
397struct reiserfs_seq_private {
398 struct super_block *sb;
399 int (*show) (struct seq_file *, struct super_block *);
400};
401
402static void *r_start(struct seq_file *m, loff_t * pos)
403{
404 struct reiserfs_seq_private *priv = m->private;
405 loff_t l = *pos;
406
407 if (l)
408 return NULL;
409
410 if (IS_ERR(sget(&reiserfs_fs_type, test_sb, set_sb, 0, priv->sb)))
411 return NULL;
412
413 up_write(&priv->sb->s_umount);
414 return priv->sb;
415}
416
417static void *r_next(struct seq_file *m, void *v, loff_t * pos)
418{
419 ++*pos;
420 if (v)
421 deactivate_super(v);
422 return NULL;
423}
424
425static void r_stop(struct seq_file *m, void *v)
426{
427 if (v)
428 deactivate_super(v);
429}
430
431static int r_show(struct seq_file *m, void *v)
432{
433 struct reiserfs_seq_private *priv = m->private;
434 return priv->show(m, v);
435}
436
437static const struct seq_operations r_ops = {
438 .start = r_start,
439 .next = r_next,
440 .stop = r_stop,
441 .show = r_show,
442};
443
444static int r_open(struct inode *inode, struct file *file) 393static int r_open(struct inode *inode, struct file *file)
445{ 394{
446 struct reiserfs_seq_private *priv; 395 return single_open(file, PDE_DATA(inode),
447 int ret = seq_open_private(file, &r_ops, 396 proc_get_parent_data(inode));
448 sizeof(struct reiserfs_seq_private));
449
450 if (!ret) {
451 struct seq_file *m = file->private_data;
452 priv = m->private;
453 priv->sb = proc_get_parent_data(inode);
454 priv->show = PDE_DATA(inode);
455 }
456 return ret;
457} 397}
458 398
459static const struct file_operations r_file_operations = { 399static const struct file_operations r_file_operations = {
460 .open = r_open, 400 .open = r_open,
461 .read = seq_read, 401 .read = seq_read,
462 .llseek = seq_lseek, 402 .llseek = seq_lseek,
463 .release = seq_release_private, 403 .release = single_release,
464 .owner = THIS_MODULE,
465}; 404};
466 405
467static struct proc_dir_entry *proc_info_root = NULL; 406static struct proc_dir_entry *proc_info_root = NULL;
468static const char proc_info_root_name[] = "fs/reiserfs"; 407static const char proc_info_root_name[] = "fs/reiserfs";
469 408
470static void add_file(struct super_block *sb, char *name, 409static void add_file(struct super_block *sb, char *name,
471 int (*func) (struct seq_file *, struct super_block *)) 410 int (*func) (struct seq_file *, void *))
472{ 411{
473 proc_create_data(name, 0, REISERFS_SB(sb)->procdir, 412 proc_create_data(name, 0, REISERFS_SB(sb)->procdir,
474 &r_file_operations, func); 413 &r_file_operations, func);
diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c
index f8a23c3078f8..e2e202a07b31 100644
--- a/fs/reiserfs/super.c
+++ b/fs/reiserfs/super.c
@@ -499,6 +499,7 @@ int remove_save_link(struct inode *inode, int truncate)
499static void reiserfs_kill_sb(struct super_block *s) 499static void reiserfs_kill_sb(struct super_block *s)
500{ 500{
501 if (REISERFS_SB(s)) { 501 if (REISERFS_SB(s)) {
502 reiserfs_proc_info_done(s);
502 /* 503 /*
503 * Force any pending inode evictions to occur now. Any 504 * Force any pending inode evictions to occur now. Any
504 * inodes to be removed that have extended attributes 505 * inodes to be removed that have extended attributes
@@ -554,8 +555,6 @@ static void reiserfs_put_super(struct super_block *s)
554 REISERFS_SB(s)->reserved_blocks); 555 REISERFS_SB(s)->reserved_blocks);
555 } 556 }
556 557
557 reiserfs_proc_info_done(s);
558
559 reiserfs_write_unlock(s); 558 reiserfs_write_unlock(s);
560 mutex_destroy(&REISERFS_SB(s)->lock); 559 mutex_destroy(&REISERFS_SB(s)->lock);
561 kfree(s->s_fs_info); 560 kfree(s->s_fs_info);
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index 94383a70c1a3..22650cd9e72a 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -56,6 +56,16 @@ acpi_evaluate_hotplug_ost(acpi_handle handle, u32 source_event,
56 56
57acpi_status 57acpi_status
58acpi_get_physical_device_location(acpi_handle handle, struct acpi_pld_info **pld); 58acpi_get_physical_device_location(acpi_handle handle, struct acpi_pld_info **pld);
59
60bool acpi_has_method(acpi_handle handle, char *name);
61acpi_status acpi_execute_simple_method(acpi_handle handle, char *method,
62 u64 arg);
63acpi_status acpi_evaluate_ej0(acpi_handle handle);
64acpi_status acpi_evaluate_lck(acpi_handle handle, int lock);
65bool acpi_ata_match(acpi_handle handle);
66bool acpi_bay_match(acpi_handle handle);
67bool acpi_dock_match(acpi_handle handle);
68
59#ifdef CONFIG_ACPI 69#ifdef CONFIG_ACPI
60 70
61#include <linux/proc_fs.h> 71#include <linux/proc_fs.h>
@@ -352,14 +362,11 @@ extern int acpi_notifier_call_chain(struct acpi_device *, u32, u32);
352extern int register_acpi_notifier(struct notifier_block *); 362extern int register_acpi_notifier(struct notifier_block *);
353extern int unregister_acpi_notifier(struct notifier_block *); 363extern int unregister_acpi_notifier(struct notifier_block *);
354 364
355extern int register_acpi_bus_notifier(struct notifier_block *nb);
356extern void unregister_acpi_bus_notifier(struct notifier_block *nb);
357/* 365/*
358 * External Functions 366 * External Functions
359 */ 367 */
360 368
361int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device); 369int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device);
362void acpi_bus_data_handler(acpi_handle handle, void *context);
363acpi_status acpi_bus_get_status_handle(acpi_handle handle, 370acpi_status acpi_bus_get_status_handle(acpi_handle handle,
364 unsigned long long *sta); 371 unsigned long long *sta);
365int acpi_bus_get_status(struct acpi_device *device); 372int acpi_bus_get_status(struct acpi_device *device);
@@ -379,15 +386,6 @@ bool acpi_bus_can_wakeup(acpi_handle handle);
379static inline bool acpi_bus_can_wakeup(acpi_handle handle) { return false; } 386static inline bool acpi_bus_can_wakeup(acpi_handle handle) { return false; }
380#endif 387#endif
381 388
382#ifdef CONFIG_ACPI_PROC_EVENT
383int acpi_bus_generate_proc_event(struct acpi_device *device, u8 type, int data);
384int acpi_bus_generate_proc_event4(const char *class, const char *bid, u8 type, int data);
385int acpi_bus_receive_event(struct acpi_bus_event *event);
386#else
387static inline int acpi_bus_generate_proc_event(struct acpi_device *device, u8 type, int data)
388 { return 0; }
389#endif
390
391void acpi_scan_lock_acquire(void); 389void acpi_scan_lock_acquire(void);
392void acpi_scan_lock_release(void); 390void acpi_scan_lock_release(void);
393int acpi_scan_add_handler(struct acpi_scan_handler *handler); 391int acpi_scan_add_handler(struct acpi_scan_handler *handler);
@@ -478,7 +476,8 @@ static inline int acpi_pm_device_sleep_state(struct device *d, int *p, int m)
478 if (p) 476 if (p)
479 *p = ACPI_STATE_D0; 477 *p = ACPI_STATE_D0;
480 478
481 return (m >= ACPI_STATE_D0 && m <= ACPI_STATE_D3) ? m : ACPI_STATE_D0; 479 return (m >= ACPI_STATE_D0 && m <= ACPI_STATE_D3_COLD) ?
480 m : ACPI_STATE_D0;
482} 481}
483static inline void acpi_dev_pm_add_dependent(acpi_handle handle, 482static inline void acpi_dev_pm_add_dependent(acpi_handle handle,
484 struct device *depdev) {} 483 struct device *depdev) {}
diff --git a/include/acpi/acpi_drivers.h b/include/acpi/acpi_drivers.h
index b420939f5eb5..1cedfcb1bd88 100644
--- a/include/acpi/acpi_drivers.h
+++ b/include/acpi/acpi_drivers.h
@@ -113,14 +113,13 @@ void pci_acpi_crs_quirks(void);
113 Dock Station 113 Dock Station
114 -------------------------------------------------------------------------- */ 114 -------------------------------------------------------------------------- */
115struct acpi_dock_ops { 115struct acpi_dock_ops {
116 acpi_notify_handler fixup;
116 acpi_notify_handler handler; 117 acpi_notify_handler handler;
117 acpi_notify_handler uevent; 118 acpi_notify_handler uevent;
118}; 119};
119 120
120#if defined(CONFIG_ACPI_DOCK) || defined(CONFIG_ACPI_DOCK_MODULE) 121#ifdef CONFIG_ACPI_DOCK
121extern int is_dock_device(acpi_handle handle); 122extern int is_dock_device(acpi_handle handle);
122extern int register_dock_notifier(struct notifier_block *nb);
123extern void unregister_dock_notifier(struct notifier_block *nb);
124extern int register_hotplug_dock_device(acpi_handle handle, 123extern int register_hotplug_dock_device(acpi_handle handle,
125 const struct acpi_dock_ops *ops, 124 const struct acpi_dock_ops *ops,
126 void *context, 125 void *context,
@@ -132,13 +131,6 @@ static inline int is_dock_device(acpi_handle handle)
132{ 131{
133 return 0; 132 return 0;
134} 133}
135static inline int register_dock_notifier(struct notifier_block *nb)
136{
137 return -ENODEV;
138}
139static inline void unregister_dock_notifier(struct notifier_block *nb)
140{
141}
142static inline int register_hotplug_dock_device(acpi_handle handle, 134static inline int register_hotplug_dock_device(acpi_handle handle,
143 const struct acpi_dock_ops *ops, 135 const struct acpi_dock_ops *ops,
144 void *context, 136 void *context,
@@ -150,6 +142,6 @@ static inline int register_hotplug_dock_device(acpi_handle handle,
150static inline void unregister_hotplug_dock_device(acpi_handle handle) 142static inline void unregister_hotplug_dock_device(acpi_handle handle)
151{ 143{
152} 144}
153#endif 145#endif /* CONFIG_ACPI_DOCK */
154 146
155#endif /*__ACPI_DRIVERS_H__*/ 147#endif /*__ACPI_DRIVERS_H__*/
diff --git a/include/acpi/acpixf.h b/include/acpi/acpixf.h
index 22d497ee6ef9..85bfdbe17805 100644
--- a/include/acpi/acpixf.h
+++ b/include/acpi/acpixf.h
@@ -46,7 +46,7 @@
46 46
47/* Current ACPICA subsystem version in YYYYMMDD format */ 47/* Current ACPICA subsystem version in YYYYMMDD format */
48 48
49#define ACPI_CA_VERSION 0x20130517 49#define ACPI_CA_VERSION 0x20130725
50 50
51#include <acpi/acconfig.h> 51#include <acpi/acconfig.h>
52#include <acpi/actypes.h> 52#include <acpi/actypes.h>
@@ -147,6 +147,8 @@ acpi_status acpi_install_interface(acpi_string interface_name);
147 147
148acpi_status acpi_remove_interface(acpi_string interface_name); 148acpi_status acpi_remove_interface(acpi_string interface_name);
149 149
150acpi_status acpi_update_interfaces(u8 action);
151
150u32 152u32
151acpi_check_address_range(acpi_adr_space_type space_id, 153acpi_check_address_range(acpi_adr_space_type space_id,
152 acpi_physical_address address, 154 acpi_physical_address address,
@@ -210,8 +212,8 @@ acpi_status
210acpi_walk_namespace(acpi_object_type type, 212acpi_walk_namespace(acpi_object_type type,
211 acpi_handle start_object, 213 acpi_handle start_object,
212 u32 max_depth, 214 u32 max_depth,
213 acpi_walk_callback pre_order_visit, 215 acpi_walk_callback descending_callback,
214 acpi_walk_callback post_order_visit, 216 acpi_walk_callback ascending_callback,
215 void *context, void **return_value); 217 void *context, void **return_value);
216 218
217acpi_status 219acpi_status
diff --git a/include/acpi/actypes.h b/include/acpi/actypes.h
index 22b03c9286e9..b748aefce929 100644
--- a/include/acpi/actypes.h
+++ b/include/acpi/actypes.h
@@ -668,13 +668,6 @@ typedef u32 acpi_event_status;
668#define ACPI_EVENT_FLAG_SET (acpi_event_status) 0x04 668#define ACPI_EVENT_FLAG_SET (acpi_event_status) 0x04
669#define ACPI_EVENT_FLAG_HANDLE (acpi_event_status) 0x08 669#define ACPI_EVENT_FLAG_HANDLE (acpi_event_status) 0x08
670 670
671/*
672 * General Purpose Events (GPE)
673 */
674#define ACPI_GPE_INVALID 0xFF
675#define ACPI_GPE_MAX 0xFF
676#define ACPI_NUM_GPE 256
677
678/* Actions for acpi_set_gpe, acpi_gpe_wakeup, acpi_hw_low_set_gpe */ 671/* Actions for acpi_set_gpe, acpi_gpe_wakeup, acpi_hw_low_set_gpe */
679 672
680#define ACPI_GPE_ENABLE 0 673#define ACPI_GPE_ENABLE 0
@@ -1144,7 +1137,19 @@ struct acpi_memory_list {
1144#endif 1137#endif
1145}; 1138};
1146 1139
1147/* Definitions for _OSI support */ 1140/* Definitions of _OSI support */
1141
1142#define ACPI_VENDOR_STRINGS 0x01
1143#define ACPI_FEATURE_STRINGS 0x02
1144#define ACPI_ENABLE_INTERFACES 0x00
1145#define ACPI_DISABLE_INTERFACES 0x04
1146
1147#define ACPI_DISABLE_ALL_VENDOR_STRINGS (ACPI_DISABLE_INTERFACES | ACPI_VENDOR_STRINGS)
1148#define ACPI_DISABLE_ALL_FEATURE_STRINGS (ACPI_DISABLE_INTERFACES | ACPI_FEATURE_STRINGS)
1149#define ACPI_DISABLE_ALL_STRINGS (ACPI_DISABLE_INTERFACES | ACPI_VENDOR_STRINGS | ACPI_FEATURE_STRINGS)
1150#define ACPI_ENABLE_ALL_VENDOR_STRINGS (ACPI_ENABLE_INTERFACES | ACPI_VENDOR_STRINGS)
1151#define ACPI_ENABLE_ALL_FEATURE_STRINGS (ACPI_ENABLE_INTERFACES | ACPI_FEATURE_STRINGS)
1152#define ACPI_ENABLE_ALL_STRINGS (ACPI_ENABLE_INTERFACES | ACPI_VENDOR_STRINGS | ACPI_FEATURE_STRINGS)
1148 1153
1149#define ACPI_OSI_WIN_2000 0x01 1154#define ACPI_OSI_WIN_2000 0x01
1150#define ACPI_OSI_WIN_XP 0x02 1155#define ACPI_OSI_WIN_XP 0x02
diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
index 2f47ade1b567..0807ddf97b05 100644
--- a/include/asm-generic/pgtable.h
+++ b/include/asm-generic/pgtable.h
@@ -417,6 +417,36 @@ static inline pmd_t pmd_mksoft_dirty(pmd_t pmd)
417{ 417{
418 return pmd; 418 return pmd;
419} 419}
420
421static inline pte_t pte_swp_mksoft_dirty(pte_t pte)
422{
423 return pte;
424}
425
426static inline int pte_swp_soft_dirty(pte_t pte)
427{
428 return 0;
429}
430
431static inline pte_t pte_swp_clear_soft_dirty(pte_t pte)
432{
433 return pte;
434}
435
436static inline pte_t pte_file_clear_soft_dirty(pte_t pte)
437{
438 return pte;
439}
440
441static inline pte_t pte_file_mksoft_dirty(pte_t pte)
442{
443 return pte;
444}
445
446static inline int pte_file_soft_dirty(pte_t pte)
447{
448 return 0;
449}
420#endif 450#endif
421 451
422#ifndef __HAVE_PFNMAP_TRACKING 452#ifndef __HAVE_PFNMAP_TRACKING
diff --git a/include/asm-generic/tlb.h b/include/asm-generic/tlb.h
index 13821c339a41..5672d7ea1fa0 100644
--- a/include/asm-generic/tlb.h
+++ b/include/asm-generic/tlb.h
@@ -112,7 +112,7 @@ struct mmu_gather {
112 112
113#define HAVE_GENERIC_MMU_GATHER 113#define HAVE_GENERIC_MMU_GATHER
114 114
115void tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, bool fullmm); 115void tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, unsigned long start, unsigned long end);
116void tlb_flush_mmu(struct mmu_gather *tlb); 116void tlb_flush_mmu(struct mmu_gather *tlb);
117void tlb_finish_mmu(struct mmu_gather *tlb, unsigned long start, 117void tlb_finish_mmu(struct mmu_gather *tlb, unsigned long start,
118 unsigned long end); 118 unsigned long end);
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 353ba256f368..a5db4aeefa36 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -481,6 +481,13 @@ void acpi_os_set_prepare_sleep(int (*func)(u8 sleep_state,
481 481
482acpi_status acpi_os_prepare_sleep(u8 sleep_state, 482acpi_status acpi_os_prepare_sleep(u8 sleep_state,
483 u32 pm1a_control, u32 pm1b_control); 483 u32 pm1a_control, u32 pm1b_control);
484
485void acpi_os_set_prepare_extended_sleep(int (*func)(u8 sleep_state,
486 u32 val_a, u32 val_b));
487
488acpi_status acpi_os_prepare_extended_sleep(u8 sleep_state,
489 u32 val_a, u32 val_b);
490
484#ifdef CONFIG_X86 491#ifdef CONFIG_X86
485void arch_reserve_mem_area(acpi_physical_address addr, size_t size); 492void arch_reserve_mem_area(acpi_physical_address addr, size_t size);
486#else 493#else
diff --git a/include/linux/dcache.h b/include/linux/dcache.h
index b90337c9d468..4a12532da8c4 100644
--- a/include/linux/dcache.h
+++ b/include/linux/dcache.h
@@ -336,6 +336,7 @@ extern int d_validate(struct dentry *, struct dentry *);
336 * helper function for dentry_operations.d_dname() members 336 * helper function for dentry_operations.d_dname() members
337 */ 337 */
338extern char *dynamic_dname(struct dentry *, char *, int, const char *, ...); 338extern char *dynamic_dname(struct dentry *, char *, int, const char *, ...);
339extern char *simple_dname(struct dentry *, char *, int);
339 340
340extern char *__d_path(const struct path *, const struct path *, char *, int); 341extern char *__d_path(const struct path *, const struct path *, char *, int);
341extern char *d_absolute_path(const struct path *, char *, int); 342extern char *d_absolute_path(const struct path *, char *, int);
diff --git a/include/linux/ftrace_event.h b/include/linux/ftrace_event.h
index 4372658c73ae..120d57a1c3a5 100644
--- a/include/linux/ftrace_event.h
+++ b/include/linux/ftrace_event.h
@@ -78,6 +78,11 @@ struct trace_iterator {
78 /* trace_seq for __print_flags() and __print_symbolic() etc. */ 78 /* trace_seq for __print_flags() and __print_symbolic() etc. */
79 struct trace_seq tmp_seq; 79 struct trace_seq tmp_seq;
80 80
81 cpumask_var_t started;
82
83 /* it's true when current open file is snapshot */
84 bool snapshot;
85
81 /* The below is zeroed out in pipe_read */ 86 /* The below is zeroed out in pipe_read */
82 struct trace_seq seq; 87 struct trace_seq seq;
83 struct trace_entry *ent; 88 struct trace_entry *ent;
@@ -90,10 +95,7 @@ struct trace_iterator {
90 loff_t pos; 95 loff_t pos;
91 long idx; 96 long idx;
92 97
93 cpumask_var_t started; 98 /* All new field here will be zeroed out in pipe_read */
94
95 /* it's true when current open file is snapshot */
96 bool snapshot;
97}; 99};
98 100
99enum trace_iter_flags { 101enum trace_iter_flags {
@@ -332,7 +334,7 @@ extern int trace_define_field(struct ftrace_event_call *call, const char *type,
332 const char *name, int offset, int size, 334 const char *name, int offset, int size,
333 int is_signed, int filter_type); 335 int is_signed, int filter_type);
334extern int trace_add_event_call(struct ftrace_event_call *call); 336extern int trace_add_event_call(struct ftrace_event_call *call);
335extern void trace_remove_event_call(struct ftrace_event_call *call); 337extern int trace_remove_event_call(struct ftrace_event_call *call);
336 338
337#define is_signed_type(type) (((type)(-1)) < (type)1) 339#define is_signed_type(type) (((type)(-1)) < (type)1)
338 340
diff --git a/include/linux/iio/trigger.h b/include/linux/iio/trigger.h
index 3869c525b052..369cf2cd5144 100644
--- a/include/linux/iio/trigger.h
+++ b/include/linux/iio/trigger.h
@@ -8,6 +8,7 @@
8 */ 8 */
9#include <linux/irq.h> 9#include <linux/irq.h>
10#include <linux/module.h> 10#include <linux/module.h>
11#include <linux/atomic.h>
11 12
12#ifndef _IIO_TRIGGER_H_ 13#ifndef _IIO_TRIGGER_H_
13#define _IIO_TRIGGER_H_ 14#define _IIO_TRIGGER_H_
@@ -61,7 +62,7 @@ struct iio_trigger {
61 62
62 struct list_head list; 63 struct list_head list;
63 struct list_head alloc_list; 64 struct list_head alloc_list;
64 int use_count; 65 atomic_t use_count;
65 66
66 struct irq_chip subirq_chip; 67 struct irq_chip subirq_chip;
67 int subirq_base; 68 int subirq_base;
diff --git a/include/linux/inetdevice.h b/include/linux/inetdevice.h
index b99cd23f3474..79640e015a86 100644
--- a/include/linux/inetdevice.h
+++ b/include/linux/inetdevice.h
@@ -5,45 +5,13 @@
5 5
6#include <linux/bitmap.h> 6#include <linux/bitmap.h>
7#include <linux/if.h> 7#include <linux/if.h>
8#include <linux/ip.h>
8#include <linux/netdevice.h> 9#include <linux/netdevice.h>
9#include <linux/rcupdate.h> 10#include <linux/rcupdate.h>
10#include <linux/timer.h> 11#include <linux/timer.h>
11#include <linux/sysctl.h> 12#include <linux/sysctl.h>
12#include <linux/rtnetlink.h> 13#include <linux/rtnetlink.h>
13 14
14enum
15{
16 IPV4_DEVCONF_FORWARDING=1,
17 IPV4_DEVCONF_MC_FORWARDING,
18 IPV4_DEVCONF_PROXY_ARP,
19 IPV4_DEVCONF_ACCEPT_REDIRECTS,
20 IPV4_DEVCONF_SECURE_REDIRECTS,
21 IPV4_DEVCONF_SEND_REDIRECTS,
22 IPV4_DEVCONF_SHARED_MEDIA,
23 IPV4_DEVCONF_RP_FILTER,
24 IPV4_DEVCONF_ACCEPT_SOURCE_ROUTE,
25 IPV4_DEVCONF_BOOTP_RELAY,
26 IPV4_DEVCONF_LOG_MARTIANS,
27 IPV4_DEVCONF_TAG,
28 IPV4_DEVCONF_ARPFILTER,
29 IPV4_DEVCONF_MEDIUM_ID,
30 IPV4_DEVCONF_NOXFRM,
31 IPV4_DEVCONF_NOPOLICY,
32 IPV4_DEVCONF_FORCE_IGMP_VERSION,
33 IPV4_DEVCONF_ARP_ANNOUNCE,
34 IPV4_DEVCONF_ARP_IGNORE,
35 IPV4_DEVCONF_PROMOTE_SECONDARIES,
36 IPV4_DEVCONF_ARP_ACCEPT,
37 IPV4_DEVCONF_ARP_NOTIFY,
38 IPV4_DEVCONF_ACCEPT_LOCAL,
39 IPV4_DEVCONF_SRC_VMARK,
40 IPV4_DEVCONF_PROXY_ARP_PVLAN,
41 IPV4_DEVCONF_ROUTE_LOCALNET,
42 __IPV4_DEVCONF_MAX
43};
44
45#define IPV4_DEVCONF_MAX (__IPV4_DEVCONF_MAX - 1)
46
47struct ipv4_devconf { 15struct ipv4_devconf {
48 void *sysctl; 16 void *sysctl;
49 int data[IPV4_DEVCONF_MAX]; 17 int data[IPV4_DEVCONF_MAX];
diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h
index 850e95bc766c..b8b7dc755752 100644
--- a/include/linux/ipv6.h
+++ b/include/linux/ipv6.h
@@ -101,6 +101,7 @@ struct inet6_skb_parm {
101#define IP6SKB_FORWARDED 2 101#define IP6SKB_FORWARDED 2
102#define IP6SKB_REROUTED 4 102#define IP6SKB_REROUTED 4
103#define IP6SKB_ROUTERALERT 8 103#define IP6SKB_ROUTERALERT 8
104#define IP6SKB_FRAGMENTED 16
104}; 105};
105 106
106#define IP6CB(skb) ((struct inet6_skb_parm*)((skb)->cb)) 107#define IP6CB(skb) ((struct inet6_skb_parm*)((skb)->cb))
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 3bef14c6586b..482ad2d84a32 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -629,7 +629,7 @@ extern void ftrace_dump(enum ftrace_dump_mode oops_dump_mode);
629static inline void tracing_start(void) { } 629static inline void tracing_start(void) { }
630static inline void tracing_stop(void) { } 630static inline void tracing_stop(void) { }
631static inline void ftrace_off_permanent(void) { } 631static inline void ftrace_off_permanent(void) { }
632static inline void trace_dump_stack(void) { } 632static inline void trace_dump_stack(int skip) { }
633 633
634static inline void tracing_on(void) { } 634static inline void tracing_on(void) { }
635static inline void tracing_off(void) { } 635static inline void tracing_off(void) { }
diff --git a/include/linux/mfd/ti_am335x_tscadc.h b/include/linux/mfd/ti_am335x_tscadc.h
index 8d73fe29796a..db1791bb997a 100644
--- a/include/linux/mfd/ti_am335x_tscadc.h
+++ b/include/linux/mfd/ti_am335x_tscadc.h
@@ -113,11 +113,27 @@
113#define CNTRLREG_8WIRE CNTRLREG_AFE_CTRL(3) 113#define CNTRLREG_8WIRE CNTRLREG_AFE_CTRL(3)
114#define CNTRLREG_TSCENB BIT(7) 114#define CNTRLREG_TSCENB BIT(7)
115 115
116/* FIFO READ Register */
117#define FIFOREAD_DATA_MASK (0xfff << 0)
118#define FIFOREAD_CHNLID_MASK (0xf << 16)
119
120/* Sequencer Status */
121#define SEQ_STATUS BIT(5)
122
116#define ADC_CLK 3000000 123#define ADC_CLK 3000000
117#define MAX_CLK_DIV 7 124#define MAX_CLK_DIV 7
118#define TOTAL_STEPS 16 125#define TOTAL_STEPS 16
119#define TOTAL_CHANNELS 8 126#define TOTAL_CHANNELS 8
120 127
128/*
129* ADC runs at 3MHz, and it takes
130* 15 cycles to latch one data output.
131* Hence the idle time for ADC to
132* process one sample data would be
133* around 5 micro seconds.
134*/
135#define IDLE_TIMEOUT 5 /* microsec */
136
121#define TSCADC_CELLS 2 137#define TSCADC_CELLS 2
122 138
123struct ti_tscadc_dev { 139struct ti_tscadc_dev {
diff --git a/include/linux/mlx5/device.h b/include/linux/mlx5/device.h
index 737685e9e852..68029b30c3dc 100644
--- a/include/linux/mlx5/device.h
+++ b/include/linux/mlx5/device.h
@@ -309,21 +309,20 @@ struct mlx5_hca_cap {
309 __be16 max_desc_sz_rq; 309 __be16 max_desc_sz_rq;
310 u8 rsvd21[2]; 310 u8 rsvd21[2];
311 __be16 max_desc_sz_sq_dc; 311 __be16 max_desc_sz_sq_dc;
312 u8 rsvd22[4]; 312 __be32 max_qp_mcg;
313 __be16 max_qp_mcg; 313 u8 rsvd22[3];
314 u8 rsvd23;
315 u8 log_max_mcg; 314 u8 log_max_mcg;
316 u8 rsvd24; 315 u8 rsvd23;
317 u8 log_max_pd; 316 u8 log_max_pd;
318 u8 rsvd25; 317 u8 rsvd24;
319 u8 log_max_xrcd; 318 u8 log_max_xrcd;
320 u8 rsvd26[42]; 319 u8 rsvd25[42];
321 __be16 log_uar_page_sz; 320 __be16 log_uar_page_sz;
322 u8 rsvd27[28]; 321 u8 rsvd26[28];
323 u8 log_msx_atomic_size_qp; 322 u8 log_msx_atomic_size_qp;
324 u8 rsvd28[2]; 323 u8 rsvd27[2];
325 u8 log_msx_atomic_size_dc; 324 u8 log_msx_atomic_size_dc;
326 u8 rsvd29[76]; 325 u8 rsvd28[76];
327}; 326};
328 327
329 328
@@ -472,9 +471,8 @@ struct mlx5_eqe_cmd {
472struct mlx5_eqe_page_req { 471struct mlx5_eqe_page_req {
473 u8 rsvd0[2]; 472 u8 rsvd0[2];
474 __be16 func_id; 473 __be16 func_id;
475 u8 rsvd1[2]; 474 __be32 num_pages;
476 __be16 num_pages; 475 __be32 rsvd1[5];
477 __be32 rsvd2[5];
478}; 476};
479 477
480union ev_data { 478union ev_data {
diff --git a/include/linux/mlx5/driver.h b/include/linux/mlx5/driver.h
index 2aa258b0ced1..8888381fc150 100644
--- a/include/linux/mlx5/driver.h
+++ b/include/linux/mlx5/driver.h
@@ -358,7 +358,7 @@ struct mlx5_caps {
358 u32 reserved_lkey; 358 u32 reserved_lkey;
359 u8 local_ca_ack_delay; 359 u8 local_ca_ack_delay;
360 u8 log_max_mcg; 360 u8 log_max_mcg;
361 u16 max_qp_mcg; 361 u32 max_qp_mcg;
362 int min_page_sz; 362 int min_page_sz;
363}; 363};
364 364
@@ -691,7 +691,7 @@ void mlx5_pagealloc_cleanup(struct mlx5_core_dev *dev);
691int mlx5_pagealloc_start(struct mlx5_core_dev *dev); 691int mlx5_pagealloc_start(struct mlx5_core_dev *dev);
692void mlx5_pagealloc_stop(struct mlx5_core_dev *dev); 692void mlx5_pagealloc_stop(struct mlx5_core_dev *dev);
693void mlx5_core_req_pages_handler(struct mlx5_core_dev *dev, u16 func_id, 693void mlx5_core_req_pages_handler(struct mlx5_core_dev *dev, u16 func_id,
694 s16 npages); 694 s32 npages);
695int mlx5_satisfy_startup_pages(struct mlx5_core_dev *dev, int boot); 695int mlx5_satisfy_startup_pages(struct mlx5_core_dev *dev, int boot);
696int mlx5_reclaim_startup_pages(struct mlx5_core_dev *dev); 696int mlx5_reclaim_startup_pages(struct mlx5_core_dev *dev);
697void mlx5_register_debugfs(void); 697void mlx5_register_debugfs(void);
@@ -731,9 +731,6 @@ void mlx5_cq_debugfs_cleanup(struct mlx5_core_dev *dev);
731int mlx5_db_alloc(struct mlx5_core_dev *dev, struct mlx5_db *db); 731int mlx5_db_alloc(struct mlx5_core_dev *dev, struct mlx5_db *db);
732void mlx5_db_free(struct mlx5_core_dev *dev, struct mlx5_db *db); 732void mlx5_db_free(struct mlx5_core_dev *dev, struct mlx5_db *db);
733 733
734typedef void (*health_handler_t)(struct pci_dev *pdev, struct health_buffer __iomem *buf, int size);
735int mlx5_register_health_report_handler(health_handler_t handler);
736void mlx5_unregister_health_report_handler(void);
737const char *mlx5_command_str(int command); 734const char *mlx5_command_str(int command);
738int mlx5_cmdif_debugfs_init(struct mlx5_core_dev *dev); 735int mlx5_cmdif_debugfs_init(struct mlx5_core_dev *dev);
739void mlx5_cmdif_debugfs_cleanup(struct mlx5_core_dev *dev); 736void mlx5_cmdif_debugfs_cleanup(struct mlx5_core_dev *dev);
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index fb425aa16c01..faf4b7c1ad12 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -332,6 +332,7 @@ struct mm_struct {
332 unsigned long pgoff, unsigned long flags); 332 unsigned long pgoff, unsigned long flags);
333#endif 333#endif
334 unsigned long mmap_base; /* base of mmap area */ 334 unsigned long mmap_base; /* base of mmap area */
335 unsigned long mmap_legacy_base; /* base of mmap area in bottom-up allocations */
335 unsigned long task_size; /* size of task vm space */ 336 unsigned long task_size; /* size of task vm space */
336 unsigned long highest_vm_end; /* highest vma end address */ 337 unsigned long highest_vm_end; /* highest vma end address */
337 pgd_t * pgd; 338 pgd_t * pgd;
diff --git a/include/linux/pci-acpi.h b/include/linux/pci-acpi.h
index 170447977278..d006f0ca60f4 100644
--- a/include/linux/pci-acpi.h
+++ b/include/linux/pci-acpi.h
@@ -47,24 +47,22 @@ void acpi_pci_remove_bus(struct pci_bus *bus);
47 47
48#ifdef CONFIG_ACPI_PCI_SLOT 48#ifdef CONFIG_ACPI_PCI_SLOT
49void acpi_pci_slot_init(void); 49void acpi_pci_slot_init(void);
50void acpi_pci_slot_enumerate(struct pci_bus *bus, acpi_handle handle); 50void acpi_pci_slot_enumerate(struct pci_bus *bus);
51void acpi_pci_slot_remove(struct pci_bus *bus); 51void acpi_pci_slot_remove(struct pci_bus *bus);
52#else 52#else
53static inline void acpi_pci_slot_init(void) { } 53static inline void acpi_pci_slot_init(void) { }
54static inline void acpi_pci_slot_enumerate(struct pci_bus *bus, 54static inline void acpi_pci_slot_enumerate(struct pci_bus *bus) { }
55 acpi_handle handle) { }
56static inline void acpi_pci_slot_remove(struct pci_bus *bus) { } 55static inline void acpi_pci_slot_remove(struct pci_bus *bus) { }
57#endif 56#endif
58 57
59#ifdef CONFIG_HOTPLUG_PCI_ACPI 58#ifdef CONFIG_HOTPLUG_PCI_ACPI
60void acpiphp_init(void); 59void acpiphp_init(void);
61void acpiphp_enumerate_slots(struct pci_bus *bus, acpi_handle handle); 60void acpiphp_enumerate_slots(struct pci_bus *bus);
62void acpiphp_remove_slots(struct pci_bus *bus); 61void acpiphp_remove_slots(struct pci_bus *bus);
63void acpiphp_check_host_bridge(acpi_handle handle); 62void acpiphp_check_host_bridge(acpi_handle handle);
64#else 63#else
65static inline void acpiphp_init(void) { } 64static inline void acpiphp_init(void) { }
66static inline void acpiphp_enumerate_slots(struct pci_bus *bus, 65static inline void acpiphp_enumerate_slots(struct pci_bus *bus) { }
67 acpi_handle handle) { }
68static inline void acpiphp_remove_slots(struct pci_bus *bus) { } 66static inline void acpiphp_remove_slots(struct pci_bus *bus) { }
69static inline void acpiphp_check_host_bridge(acpi_handle handle) { } 67static inline void acpiphp_check_host_bridge(acpi_handle handle) { }
70#endif 68#endif
diff --git a/include/linux/regmap.h b/include/linux/regmap.h
index 75981d0b57dc..580a5320cc96 100644
--- a/include/linux/regmap.h
+++ b/include/linux/regmap.h
@@ -15,6 +15,7 @@
15 15
16#include <linux/list.h> 16#include <linux/list.h>
17#include <linux/rbtree.h> 17#include <linux/rbtree.h>
18#include <linux/err.h>
18 19
19struct module; 20struct module;
20struct device; 21struct device;
diff --git a/include/linux/sched.h b/include/linux/sched.h
index d722490da030..078066daffd4 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1532,6 +1532,8 @@ static inline pid_t task_pgrp_nr(struct task_struct *tsk)
1532 * Test if a process is not yet dead (at most zombie state) 1532 * Test if a process is not yet dead (at most zombie state)
1533 * If pid_alive fails, then pointers within the task structure 1533 * If pid_alive fails, then pointers within the task structure
1534 * can be stale and must not be dereferenced. 1534 * can be stale and must not be dereferenced.
1535 *
1536 * Return: 1 if the process is alive. 0 otherwise.
1535 */ 1537 */
1536static inline int pid_alive(struct task_struct *p) 1538static inline int pid_alive(struct task_struct *p)
1537{ 1539{
@@ -1543,6 +1545,8 @@ static inline int pid_alive(struct task_struct *p)
1543 * @tsk: Task structure to be checked. 1545 * @tsk: Task structure to be checked.
1544 * 1546 *
1545 * Check if a task structure is the first user space task the kernel created. 1547 * Check if a task structure is the first user space task the kernel created.
1548 *
1549 * Return: 1 if the task structure is init. 0 otherwise.
1546 */ 1550 */
1547static inline int is_global_init(struct task_struct *tsk) 1551static inline int is_global_init(struct task_struct *tsk)
1548{ 1552{
@@ -1894,6 +1898,8 @@ extern struct task_struct *idle_task(int cpu);
1894/** 1898/**
1895 * is_idle_task - is the specified task an idle task? 1899 * is_idle_task - is the specified task an idle task?
1896 * @p: the task in question. 1900 * @p: the task in question.
1901 *
1902 * Return: 1 if @p is an idle task. 0 otherwise.
1897 */ 1903 */
1898static inline bool is_idle_task(const struct task_struct *p) 1904static inline bool is_idle_task(const struct task_struct *p)
1899{ 1905{
diff --git a/include/linux/spinlock.h b/include/linux/spinlock.h
index 7d537ced949a..75f34949d9ab 100644
--- a/include/linux/spinlock.h
+++ b/include/linux/spinlock.h
@@ -117,9 +117,17 @@ do { \
117#endif /*arch_spin_is_contended*/ 117#endif /*arch_spin_is_contended*/
118#endif 118#endif
119 119
120/* The lock does not imply full memory barrier. */ 120/*
121#ifndef ARCH_HAS_SMP_MB_AFTER_LOCK 121 * Despite its name it doesn't necessarily has to be a full barrier.
122static inline void smp_mb__after_lock(void) { smp_mb(); } 122 * It should only guarantee that a STORE before the critical section
123 * can not be reordered with a LOAD inside this section.
124 * spin_lock() is the one-way barrier, this LOAD can not escape out
125 * of the region. So the default implementation simply ensures that
126 * a STORE can not move into the critical section, smp_wmb() should
127 * serialize it with another STORE done by spin_lock().
128 */
129#ifndef smp_mb__before_spinlock
130#define smp_mb__before_spinlock() smp_wmb()
123#endif 131#endif
124 132
125/** 133/**
diff --git a/include/linux/sunrpc/sched.h b/include/linux/sunrpc/sched.h
index 6d870353674a..1821445708d6 100644
--- a/include/linux/sunrpc/sched.h
+++ b/include/linux/sunrpc/sched.h
@@ -121,6 +121,7 @@ struct rpc_task_setup {
121#define RPC_TASK_SOFTCONN 0x0400 /* Fail if can't connect */ 121#define RPC_TASK_SOFTCONN 0x0400 /* Fail if can't connect */
122#define RPC_TASK_SENT 0x0800 /* message was sent */ 122#define RPC_TASK_SENT 0x0800 /* message was sent */
123#define RPC_TASK_TIMEOUT 0x1000 /* fail with ETIMEDOUT on timeout */ 123#define RPC_TASK_TIMEOUT 0x1000 /* fail with ETIMEDOUT on timeout */
124#define RPC_TASK_NOCONNECT 0x2000 /* return ENOTCONN if not connected */
124 125
125#define RPC_IS_ASYNC(t) ((t)->tk_flags & RPC_TASK_ASYNC) 126#define RPC_IS_ASYNC(t) ((t)->tk_flags & RPC_TASK_ASYNC)
126#define RPC_IS_SWAPPER(t) ((t)->tk_flags & RPC_TASK_SWAPPER) 127#define RPC_IS_SWAPPER(t) ((t)->tk_flags & RPC_TASK_SWAPPER)
diff --git a/include/linux/swapops.h b/include/linux/swapops.h
index c5fd30d2a415..8d4fa82bfb91 100644
--- a/include/linux/swapops.h
+++ b/include/linux/swapops.h
@@ -67,6 +67,8 @@ static inline swp_entry_t pte_to_swp_entry(pte_t pte)
67 swp_entry_t arch_entry; 67 swp_entry_t arch_entry;
68 68
69 BUG_ON(pte_file(pte)); 69 BUG_ON(pte_file(pte));
70 if (pte_swp_soft_dirty(pte))
71 pte = pte_swp_clear_soft_dirty(pte);
70 arch_entry = __pte_to_swp_entry(pte); 72 arch_entry = __pte_to_swp_entry(pte);
71 return swp_entry(__swp_type(arch_entry), __swp_offset(arch_entry)); 73 return swp_entry(__swp_type(arch_entry), __swp_offset(arch_entry));
72} 74}
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index 4147d700a293..84662ecc7b51 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -802,9 +802,14 @@ asmlinkage long sys_vfork(void);
802asmlinkage long sys_clone(unsigned long, unsigned long, int __user *, int, 802asmlinkage long sys_clone(unsigned long, unsigned long, int __user *, int,
803 int __user *); 803 int __user *);
804#else 804#else
805#ifdef CONFIG_CLONE_BACKWARDS3
806asmlinkage long sys_clone(unsigned long, unsigned long, int, int __user *,
807 int __user *, int);
808#else
805asmlinkage long sys_clone(unsigned long, unsigned long, int __user *, 809asmlinkage long sys_clone(unsigned long, unsigned long, int __user *,
806 int __user *, int); 810 int __user *, int);
807#endif 811#endif
812#endif
808 813
809asmlinkage long sys_execve(const char __user *filename, 814asmlinkage long sys_execve(const char __user *filename,
810 const char __user *const __user *argv, 815 const char __user *const __user *argv,
diff --git a/include/linux/user_namespace.h b/include/linux/user_namespace.h
index b6b215f13b45..14105c26a836 100644
--- a/include/linux/user_namespace.h
+++ b/include/linux/user_namespace.h
@@ -23,6 +23,7 @@ struct user_namespace {
23 struct uid_gid_map projid_map; 23 struct uid_gid_map projid_map;
24 atomic_t count; 24 atomic_t count;
25 struct user_namespace *parent; 25 struct user_namespace *parent;
26 int level;
26 kuid_t owner; 27 kuid_t owner;
27 kgid_t group; 28 kgid_t group;
28 unsigned int proc_inum; 29 unsigned int proc_inum;
diff --git a/include/linux/wait.h b/include/linux/wait.h
index f487a4750b7f..a67fc1635592 100644
--- a/include/linux/wait.h
+++ b/include/linux/wait.h
@@ -811,6 +811,63 @@ do { \
811 __ret; \ 811 __ret; \
812}) 812})
813 813
814#define __wait_event_interruptible_lock_irq_timeout(wq, condition, \
815 lock, ret) \
816do { \
817 DEFINE_WAIT(__wait); \
818 \
819 for (;;) { \
820 prepare_to_wait(&wq, &__wait, TASK_INTERRUPTIBLE); \
821 if (condition) \
822 break; \
823 if (signal_pending(current)) { \
824 ret = -ERESTARTSYS; \
825 break; \
826 } \
827 spin_unlock_irq(&lock); \
828 ret = schedule_timeout(ret); \
829 spin_lock_irq(&lock); \
830 if (!ret) \
831 break; \
832 } \
833 finish_wait(&wq, &__wait); \
834} while (0)
835
836/**
837 * wait_event_interruptible_lock_irq_timeout - sleep until a condition gets true or a timeout elapses.
838 * The condition is checked under the lock. This is expected
839 * to be called with the lock taken.
840 * @wq: the waitqueue to wait on
841 * @condition: a C expression for the event to wait for
842 * @lock: a locked spinlock_t, which will be released before schedule()
843 * and reacquired afterwards.
844 * @timeout: timeout, in jiffies
845 *
846 * The process is put to sleep (TASK_INTERRUPTIBLE) until the
847 * @condition evaluates to true or signal is received. The @condition is
848 * checked each time the waitqueue @wq is woken up.
849 *
850 * wake_up() has to be called after changing any variable that could
851 * change the result of the wait condition.
852 *
853 * This is supposed to be called while holding the lock. The lock is
854 * dropped before going to sleep and is reacquired afterwards.
855 *
856 * The function returns 0 if the @timeout elapsed, -ERESTARTSYS if it
857 * was interrupted by a signal, and the remaining jiffies otherwise
858 * if the condition evaluated to true before the timeout elapsed.
859 */
860#define wait_event_interruptible_lock_irq_timeout(wq, condition, lock, \
861 timeout) \
862({ \
863 int __ret = timeout; \
864 \
865 if (!(condition)) \
866 __wait_event_interruptible_lock_irq_timeout( \
867 wq, condition, lock, __ret); \
868 __ret; \
869})
870
814 871
815/* 872/*
816 * These are the old interfaces to sleep waiting for an event. 873 * These are the old interfaces to sleep waiting for an event.
diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h
index 7343a27fe819..47ada23345a1 100644
--- a/include/media/v4l2-ctrls.h
+++ b/include/media/v4l2-ctrls.h
@@ -22,6 +22,7 @@
22#define _V4L2_CTRLS_H 22#define _V4L2_CTRLS_H
23 23
24#include <linux/list.h> 24#include <linux/list.h>
25#include <linux/mutex.h>
25#include <linux/videodev2.h> 26#include <linux/videodev2.h>
26 27
27/* forward references */ 28/* forward references */
diff --git a/include/net/busy_poll.h b/include/net/busy_poll.h
index f18b91966d3d..8a358a2c97e6 100644
--- a/include/net/busy_poll.h
+++ b/include/net/busy_poll.h
@@ -122,7 +122,7 @@ static inline bool sk_busy_loop(struct sock *sk, int nonblock)
122 if (rc > 0) 122 if (rc > 0)
123 /* local bh are disabled so it is ok to use _BH */ 123 /* local bh are disabled so it is ok to use _BH */
124 NET_ADD_STATS_BH(sock_net(sk), 124 NET_ADD_STATS_BH(sock_net(sk),
125 LINUX_MIB_LOWLATENCYRXPACKETS, rc); 125 LINUX_MIB_BUSYPOLLRXPACKETS, rc);
126 126
127 } while (!nonblock && skb_queue_empty(&sk->sk_receive_queue) && 127 } while (!nonblock && skb_queue_empty(&sk->sk_receive_queue) &&
128 !need_resched() && !busy_loop_timeout(end_time)); 128 !need_resched() && !busy_loop_timeout(end_time));
@@ -162,11 +162,6 @@ static inline bool sk_can_busy_loop(struct sock *sk)
162 return false; 162 return false;
163} 163}
164 164
165static inline bool sk_busy_poll(struct sock *sk, int nonblock)
166{
167 return false;
168}
169
170static inline void skb_mark_napi_id(struct sk_buff *skb, 165static inline void skb_mark_napi_id(struct sk_buff *skb,
171 struct napi_struct *napi) 166 struct napi_struct *napi)
172{ 167{
diff --git a/include/net/ip6_route.h b/include/net/ip6_route.h
index 260f83f16bcf..f667248202b6 100644
--- a/include/net/ip6_route.h
+++ b/include/net/ip6_route.h
@@ -135,6 +135,8 @@ extern void ip6_update_pmtu(struct sk_buff *skb, struct net *net, __be32 mtu,
135extern void ip6_sk_update_pmtu(struct sk_buff *skb, struct sock *sk, 135extern void ip6_sk_update_pmtu(struct sk_buff *skb, struct sock *sk,
136 __be32 mtu); 136 __be32 mtu);
137extern void ip6_redirect(struct sk_buff *skb, struct net *net, int oif, u32 mark); 137extern void ip6_redirect(struct sk_buff *skb, struct net *net, int oif, u32 mark);
138extern void ip6_redirect_no_header(struct sk_buff *skb, struct net *net, int oif,
139 u32 mark);
138extern void ip6_sk_redirect(struct sk_buff *skb, struct sock *sk); 140extern void ip6_sk_redirect(struct sk_buff *skb, struct sock *sk);
139 141
140struct netlink_callback; 142struct netlink_callback;
diff --git a/include/net/ip_tunnels.h b/include/net/ip_tunnels.h
index 781b3cf86a2f..a354db5b7662 100644
--- a/include/net/ip_tunnels.h
+++ b/include/net/ip_tunnels.h
@@ -145,20 +145,6 @@ static inline u8 ip_tunnel_ecn_encap(u8 tos, const struct iphdr *iph,
145 return INET_ECN_encapsulate(tos, inner); 145 return INET_ECN_encapsulate(tos, inner);
146} 146}
147 147
148static inline void tunnel_ip_select_ident(struct sk_buff *skb,
149 const struct iphdr *old_iph,
150 struct dst_entry *dst)
151{
152 struct iphdr *iph = ip_hdr(skb);
153
154 /* Use inner packet iph-id if possible. */
155 if (skb->protocol == htons(ETH_P_IP) && old_iph->id)
156 iph->id = old_iph->id;
157 else
158 __ip_select_ident(iph, dst,
159 (skb_shinfo(skb)->gso_segs ?: 1) - 1);
160}
161
162int iptunnel_pull_header(struct sk_buff *skb, int hdr_len, __be16 inner_proto); 148int iptunnel_pull_header(struct sk_buff *skb, int hdr_len, __be16 inner_proto);
163int iptunnel_xmit(struct net *net, struct rtable *rt, 149int iptunnel_xmit(struct net *net, struct rtable *rt,
164 struct sk_buff *skb, 150 struct sk_buff *skb,
diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h
index 6eab63363e59..e5ae0c50fa9c 100644
--- a/include/net/sch_generic.h
+++ b/include/net/sch_generic.h
@@ -683,13 +683,19 @@ struct psched_ratecfg {
683 u64 rate_bytes_ps; /* bytes per second */ 683 u64 rate_bytes_ps; /* bytes per second */
684 u32 mult; 684 u32 mult;
685 u16 overhead; 685 u16 overhead;
686 u8 linklayer;
686 u8 shift; 687 u8 shift;
687}; 688};
688 689
689static inline u64 psched_l2t_ns(const struct psched_ratecfg *r, 690static inline u64 psched_l2t_ns(const struct psched_ratecfg *r,
690 unsigned int len) 691 unsigned int len)
691{ 692{
692 return ((u64)(len + r->overhead) * r->mult) >> r->shift; 693 len += r->overhead;
694
695 if (unlikely(r->linklayer == TC_LINKLAYER_ATM))
696 return ((u64)(DIV_ROUND_UP(len,48)*53) * r->mult) >> r->shift;
697
698 return ((u64)len * r->mult) >> r->shift;
693} 699}
694 700
695extern void psched_ratecfg_precompute(struct psched_ratecfg *r, const struct tc_ratespec *conf); 701extern void psched_ratecfg_precompute(struct psched_ratecfg *r, const struct tc_ratespec *conf);
@@ -700,6 +706,7 @@ static inline void psched_ratecfg_getrate(struct tc_ratespec *res,
700 memset(res, 0, sizeof(*res)); 706 memset(res, 0, sizeof(*res));
701 res->rate = r->rate_bytes_ps; 707 res->rate = r->rate_bytes_ps;
702 res->overhead = r->overhead; 708 res->overhead = r->overhead;
709 res->linklayer = (r->linklayer & TC_LINKLAYER_MASK);
703} 710}
704 711
705#endif 712#endif
diff --git a/include/uapi/linux/ip.h b/include/uapi/linux/ip.h
index 6cf06bfd841b..2fee45bdec0a 100644
--- a/include/uapi/linux/ip.h
+++ b/include/uapi/linux/ip.h
@@ -133,4 +133,38 @@ struct ip_beet_phdr {
133 __u8 reserved; 133 __u8 reserved;
134}; 134};
135 135
136/* index values for the variables in ipv4_devconf */
137enum
138{
139 IPV4_DEVCONF_FORWARDING=1,
140 IPV4_DEVCONF_MC_FORWARDING,
141 IPV4_DEVCONF_PROXY_ARP,
142 IPV4_DEVCONF_ACCEPT_REDIRECTS,
143 IPV4_DEVCONF_SECURE_REDIRECTS,
144 IPV4_DEVCONF_SEND_REDIRECTS,
145 IPV4_DEVCONF_SHARED_MEDIA,
146 IPV4_DEVCONF_RP_FILTER,
147 IPV4_DEVCONF_ACCEPT_SOURCE_ROUTE,
148 IPV4_DEVCONF_BOOTP_RELAY,
149 IPV4_DEVCONF_LOG_MARTIANS,
150 IPV4_DEVCONF_TAG,
151 IPV4_DEVCONF_ARPFILTER,
152 IPV4_DEVCONF_MEDIUM_ID,
153 IPV4_DEVCONF_NOXFRM,
154 IPV4_DEVCONF_NOPOLICY,
155 IPV4_DEVCONF_FORCE_IGMP_VERSION,
156 IPV4_DEVCONF_ARP_ANNOUNCE,
157 IPV4_DEVCONF_ARP_IGNORE,
158 IPV4_DEVCONF_PROMOTE_SECONDARIES,
159 IPV4_DEVCONF_ARP_ACCEPT,
160 IPV4_DEVCONF_ARP_NOTIFY,
161 IPV4_DEVCONF_ACCEPT_LOCAL,
162 IPV4_DEVCONF_SRC_VMARK,
163 IPV4_DEVCONF_PROXY_ARP_PVLAN,
164 IPV4_DEVCONF_ROUTE_LOCALNET,
165 __IPV4_DEVCONF_MAX
166};
167
168#define IPV4_DEVCONF_MAX (__IPV4_DEVCONF_MAX - 1)
169
136#endif /* _UAPI_LINUX_IP_H */ 170#endif /* _UAPI_LINUX_IP_H */
diff --git a/include/uapi/linux/pkt_sched.h b/include/uapi/linux/pkt_sched.h
index dbd71b0c7d8c..09d62b9228ff 100644
--- a/include/uapi/linux/pkt_sched.h
+++ b/include/uapi/linux/pkt_sched.h
@@ -73,9 +73,17 @@ struct tc_estimator {
73#define TC_H_ROOT (0xFFFFFFFFU) 73#define TC_H_ROOT (0xFFFFFFFFU)
74#define TC_H_INGRESS (0xFFFFFFF1U) 74#define TC_H_INGRESS (0xFFFFFFF1U)
75 75
76/* Need to corrospond to iproute2 tc/tc_core.h "enum link_layer" */
77enum tc_link_layer {
78 TC_LINKLAYER_UNAWARE, /* Indicate unaware old iproute2 util */
79 TC_LINKLAYER_ETHERNET,
80 TC_LINKLAYER_ATM,
81};
82#define TC_LINKLAYER_MASK 0x0F /* limit use to lower 4 bits */
83
76struct tc_ratespec { 84struct tc_ratespec {
77 unsigned char cell_log; 85 unsigned char cell_log;
78 unsigned char __reserved; 86 __u8 linklayer; /* lower 4 bits */
79 unsigned short overhead; 87 unsigned short overhead;
80 short cell_align; 88 short cell_align;
81 unsigned short mpu; 89 unsigned short mpu;
diff --git a/include/uapi/linux/snmp.h b/include/uapi/linux/snmp.h
index af0a674cc677..a1356d3b54df 100644
--- a/include/uapi/linux/snmp.h
+++ b/include/uapi/linux/snmp.h
@@ -253,7 +253,7 @@ enum
253 LINUX_MIB_TCPFASTOPENLISTENOVERFLOW, /* TCPFastOpenListenOverflow */ 253 LINUX_MIB_TCPFASTOPENLISTENOVERFLOW, /* TCPFastOpenListenOverflow */
254 LINUX_MIB_TCPFASTOPENCOOKIEREQD, /* TCPFastOpenCookieReqd */ 254 LINUX_MIB_TCPFASTOPENCOOKIEREQD, /* TCPFastOpenCookieReqd */
255 LINUX_MIB_TCPSPURIOUS_RTX_HOSTQUEUES, /* TCPSpuriousRtxHostQueues */ 255 LINUX_MIB_TCPSPURIOUS_RTX_HOSTQUEUES, /* TCPSpuriousRtxHostQueues */
256 LINUX_MIB_LOWLATENCYRXPACKETS, /* LowLatencyRxPackets */ 256 LINUX_MIB_BUSYPOLLRXPACKETS, /* BusyPollRxPackets */
257 __LINUX_MIB_MAX 257 __LINUX_MIB_MAX
258}; 258};
259 259
diff --git a/include/xen/acpi.h b/include/xen/acpi.h
index 46aa3d1c1654..4ddd7dc4a61e 100644
--- a/include/xen/acpi.h
+++ b/include/xen/acpi.h
@@ -75,8 +75,10 @@ static inline int xen_acpi_get_pxm(acpi_handle h)
75 return -ENXIO; 75 return -ENXIO;
76} 76}
77 77
78int xen_acpi_notify_hypervisor_state(u8 sleep_state, 78int xen_acpi_notify_hypervisor_sleep(u8 sleep_state,
79 u32 pm1a_cnt, u32 pm1b_cnd); 79 u32 pm1a_cnt, u32 pm1b_cnd);
80int xen_acpi_notify_hypervisor_extended_sleep(u8 sleep_state,
81 u32 val_a, u32 val_b);
80 82
81static inline int xen_acpi_suspend_lowlevel(void) 83static inline int xen_acpi_suspend_lowlevel(void)
82{ 84{
@@ -93,7 +95,9 @@ static inline void xen_acpi_sleep_register(void)
93{ 95{
94 if (xen_initial_domain()) { 96 if (xen_initial_domain()) {
95 acpi_os_set_prepare_sleep( 97 acpi_os_set_prepare_sleep(
96 &xen_acpi_notify_hypervisor_state); 98 &xen_acpi_notify_hypervisor_sleep);
99 acpi_os_set_prepare_extended_sleep(
100 &xen_acpi_notify_hypervisor_extended_sleep);
97 101
98 acpi_suspend_lowlevel = xen_acpi_suspend_lowlevel; 102 acpi_suspend_lowlevel = xen_acpi_suspend_lowlevel;
99 } 103 }
diff --git a/include/xen/interface/platform.h b/include/xen/interface/platform.h
index c57d5f67f702..f1331e3e7271 100644
--- a/include/xen/interface/platform.h
+++ b/include/xen/interface/platform.h
@@ -152,10 +152,11 @@ DEFINE_GUEST_HANDLE_STRUCT(xenpf_firmware_info_t);
152#define XENPF_enter_acpi_sleep 51 152#define XENPF_enter_acpi_sleep 51
153struct xenpf_enter_acpi_sleep { 153struct xenpf_enter_acpi_sleep {
154 /* IN variables */ 154 /* IN variables */
155 uint16_t pm1a_cnt_val; /* PM1a control value. */ 155 uint16_t val_a; /* PM1a control / sleep type A. */
156 uint16_t pm1b_cnt_val; /* PM1b control value. */ 156 uint16_t val_b; /* PM1b control / sleep type B. */
157 uint32_t sleep_state; /* Which state to enter (Sn). */ 157 uint32_t sleep_state; /* Which state to enter (Sn). */
158 uint32_t flags; /* Must be zero. */ 158#define XENPF_ACPI_SLEEP_EXTENDED 0x00000001
159 uint32_t flags; /* XENPF_ACPI_SLEEP_*. */
159}; 160};
160DEFINE_GUEST_HANDLE_STRUCT(xenpf_enter_acpi_sleep_t); 161DEFINE_GUEST_HANDLE_STRUCT(xenpf_enter_acpi_sleep_t);
161 162
diff --git a/init/Kconfig b/init/Kconfig
index 247084be0590..fed81b576f29 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -955,7 +955,7 @@ config MEMCG_SWAP_ENABLED
955 Memory Resource Controller Swap Extension comes with its price in 955 Memory Resource Controller Swap Extension comes with its price in
956 a bigger memory consumption. General purpose distribution kernels 956 a bigger memory consumption. General purpose distribution kernels
957 which want to enable the feature but keep it disabled by default 957 which want to enable the feature but keep it disabled by default
958 and let the user enable it by swapaccount boot command line 958 and let the user enable it by swapaccount=1 boot command line
959 parameter should have this option unselected. 959 parameter should have this option unselected.
960 For those who want to have the feature enabled by default should 960 For those who want to have the feature enabled by default should
961 select this option (if, for some reason, they need to disable it 961 select this option (if, for some reason, they need to disable it
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 789ec4683db3..781845a013ab 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -4335,8 +4335,10 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry,
4335 } 4335 }
4336 4336
4337 err = percpu_ref_init(&css->refcnt, css_release); 4337 err = percpu_ref_init(&css->refcnt, css_release);
4338 if (err) 4338 if (err) {
4339 ss->css_free(cgrp);
4339 goto err_free_all; 4340 goto err_free_all;
4341 }
4340 4342
4341 init_cgroup_css(css, ss, cgrp); 4343 init_cgroup_css(css, ss, cgrp);
4342 4344
diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index e5657788fedd..ea1966db34f2 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -475,13 +475,17 @@ static int validate_change(const struct cpuset *cur, const struct cpuset *trial)
475 475
476 /* 476 /*
477 * Cpusets with tasks - existing or newly being attached - can't 477 * Cpusets with tasks - existing or newly being attached - can't
478 * have empty cpus_allowed or mems_allowed. 478 * be changed to have empty cpus_allowed or mems_allowed.
479 */ 479 */
480 ret = -ENOSPC; 480 ret = -ENOSPC;
481 if ((cgroup_task_count(cur->css.cgroup) || cur->attach_in_progress) && 481 if ((cgroup_task_count(cur->css.cgroup) || cur->attach_in_progress)) {
482 (cpumask_empty(trial->cpus_allowed) && 482 if (!cpumask_empty(cur->cpus_allowed) &&
483 nodes_empty(trial->mems_allowed))) 483 cpumask_empty(trial->cpus_allowed))
484 goto out; 484 goto out;
485 if (!nodes_empty(cur->mems_allowed) &&
486 nodes_empty(trial->mems_allowed))
487 goto out;
488 }
485 489
486 ret = 0; 490 ret = 0;
487out: 491out:
@@ -1608,11 +1612,13 @@ static int cpuset_write_u64(struct cgroup *cgrp, struct cftype *cft, u64 val)
1608{ 1612{
1609 struct cpuset *cs = cgroup_cs(cgrp); 1613 struct cpuset *cs = cgroup_cs(cgrp);
1610 cpuset_filetype_t type = cft->private; 1614 cpuset_filetype_t type = cft->private;
1611 int retval = -ENODEV; 1615 int retval = 0;
1612 1616
1613 mutex_lock(&cpuset_mutex); 1617 mutex_lock(&cpuset_mutex);
1614 if (!is_cpuset_online(cs)) 1618 if (!is_cpuset_online(cs)) {
1619 retval = -ENODEV;
1615 goto out_unlock; 1620 goto out_unlock;
1621 }
1616 1622
1617 switch (type) { 1623 switch (type) {
1618 case FILE_CPU_EXCLUSIVE: 1624 case FILE_CPU_EXCLUSIVE:
diff --git a/kernel/fork.c b/kernel/fork.c
index 403d2bb8a968..e23bb19e2a3e 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -1679,6 +1679,12 @@ SYSCALL_DEFINE5(clone, unsigned long, newsp, unsigned long, clone_flags,
1679 int __user *, parent_tidptr, 1679 int __user *, parent_tidptr,
1680 int __user *, child_tidptr, 1680 int __user *, child_tidptr,
1681 int, tls_val) 1681 int, tls_val)
1682#elif defined(CONFIG_CLONE_BACKWARDS3)
1683SYSCALL_DEFINE6(clone, unsigned long, clone_flags, unsigned long, newsp,
1684 int, stack_size,
1685 int __user *, parent_tidptr,
1686 int __user *, child_tidptr,
1687 int, tls_val)
1682#else 1688#else
1683SYSCALL_DEFINE5(clone, unsigned long, clone_flags, unsigned long, newsp, 1689SYSCALL_DEFINE5(clone, unsigned long, clone_flags, unsigned long, newsp,
1684 int __user *, parent_tidptr, 1690 int __user *, parent_tidptr,
diff --git a/kernel/mutex.c b/kernel/mutex.c
index ff05f4bd86eb..a52ee7bb830d 100644
--- a/kernel/mutex.c
+++ b/kernel/mutex.c
@@ -686,7 +686,7 @@ __ww_mutex_lock(struct ww_mutex *lock, struct ww_acquire_ctx *ctx)
686 might_sleep(); 686 might_sleep();
687 ret = __mutex_lock_common(&lock->base, TASK_UNINTERRUPTIBLE, 687 ret = __mutex_lock_common(&lock->base, TASK_UNINTERRUPTIBLE,
688 0, &ctx->dep_map, _RET_IP_, ctx); 688 0, &ctx->dep_map, _RET_IP_, ctx);
689 if (!ret && ctx->acquired > 0) 689 if (!ret && ctx->acquired > 1)
690 return ww_mutex_deadlock_injection(lock, ctx); 690 return ww_mutex_deadlock_injection(lock, ctx);
691 691
692 return ret; 692 return ret;
@@ -702,7 +702,7 @@ __ww_mutex_lock_interruptible(struct ww_mutex *lock, struct ww_acquire_ctx *ctx)
702 ret = __mutex_lock_common(&lock->base, TASK_INTERRUPTIBLE, 702 ret = __mutex_lock_common(&lock->base, TASK_INTERRUPTIBLE,
703 0, &ctx->dep_map, _RET_IP_, ctx); 703 0, &ctx->dep_map, _RET_IP_, ctx);
704 704
705 if (!ret && ctx->acquired > 0) 705 if (!ret && ctx->acquired > 1)
706 return ww_mutex_deadlock_injection(lock, ctx); 706 return ww_mutex_deadlock_injection(lock, ctx);
707 707
708 return ret; 708 return ret;
diff --git a/kernel/power/qos.c b/kernel/power/qos.c
index 06fe28589e9c..a394297f8b2f 100644
--- a/kernel/power/qos.c
+++ b/kernel/power/qos.c
@@ -296,6 +296,17 @@ int pm_qos_request_active(struct pm_qos_request *req)
296} 296}
297EXPORT_SYMBOL_GPL(pm_qos_request_active); 297EXPORT_SYMBOL_GPL(pm_qos_request_active);
298 298
299static void __pm_qos_update_request(struct pm_qos_request *req,
300 s32 new_value)
301{
302 trace_pm_qos_update_request(req->pm_qos_class, new_value);
303
304 if (new_value != req->node.prio)
305 pm_qos_update_target(
306 pm_qos_array[req->pm_qos_class]->constraints,
307 &req->node, PM_QOS_UPDATE_REQ, new_value);
308}
309
299/** 310/**
300 * pm_qos_work_fn - the timeout handler of pm_qos_update_request_timeout 311 * pm_qos_work_fn - the timeout handler of pm_qos_update_request_timeout
301 * @work: work struct for the delayed work (timeout) 312 * @work: work struct for the delayed work (timeout)
@@ -308,7 +319,7 @@ static void pm_qos_work_fn(struct work_struct *work)
308 struct pm_qos_request, 319 struct pm_qos_request,
309 work); 320 work);
310 321
311 pm_qos_update_request(req, PM_QOS_DEFAULT_VALUE); 322 __pm_qos_update_request(req, PM_QOS_DEFAULT_VALUE);
312} 323}
313 324
314/** 325/**
@@ -364,12 +375,7 @@ void pm_qos_update_request(struct pm_qos_request *req,
364 } 375 }
365 376
366 cancel_delayed_work_sync(&req->work); 377 cancel_delayed_work_sync(&req->work);
367 378 __pm_qos_update_request(req, new_value);
368 trace_pm_qos_update_request(req->pm_qos_class, new_value);
369 if (new_value != req->node.prio)
370 pm_qos_update_target(
371 pm_qos_array[req->pm_qos_class]->constraints,
372 &req->node, PM_QOS_UPDATE_REQ, new_value);
373} 379}
374EXPORT_SYMBOL_GPL(pm_qos_update_request); 380EXPORT_SYMBOL_GPL(pm_qos_update_request);
375 381
diff --git a/kernel/printk/braille.c b/kernel/printk/braille.c
index b51087fb9ace..276762f3a460 100644
--- a/kernel/printk/braille.c
+++ b/kernel/printk/braille.c
@@ -19,7 +19,8 @@ char *_braille_console_setup(char **str, char **brl_options)
19 pr_err("need port name after brl=\n"); 19 pr_err("need port name after brl=\n");
20 else 20 else
21 *((*str)++) = 0; 21 *((*str)++) = 0;
22 } 22 } else
23 return NULL;
23 24
24 return *str; 25 return *str;
25} 26}
diff --git a/kernel/ptrace.c b/kernel/ptrace.c
index 4041f5747e73..a146ee327f6a 100644
--- a/kernel/ptrace.c
+++ b/kernel/ptrace.c
@@ -469,7 +469,6 @@ static int ptrace_detach(struct task_struct *child, unsigned int data)
469 /* Architecture-specific hardware disable .. */ 469 /* Architecture-specific hardware disable .. */
470 ptrace_disable(child); 470 ptrace_disable(child);
471 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE); 471 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
472 flush_ptrace_hw_breakpoint(child);
473 472
474 write_lock_irq(&tasklist_lock); 473 write_lock_irq(&tasklist_lock);
475 /* 474 /*
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index b7c32cb7bfeb..05c39f030314 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -933,6 +933,8 @@ static int effective_prio(struct task_struct *p)
933/** 933/**
934 * task_curr - is this task currently executing on a CPU? 934 * task_curr - is this task currently executing on a CPU?
935 * @p: the task in question. 935 * @p: the task in question.
936 *
937 * Return: 1 if the task is currently executing. 0 otherwise.
936 */ 938 */
937inline int task_curr(const struct task_struct *p) 939inline int task_curr(const struct task_struct *p)
938{ 940{
@@ -1482,7 +1484,7 @@ static void ttwu_queue(struct task_struct *p, int cpu)
1482 * the simpler "current->state = TASK_RUNNING" to mark yourself 1484 * the simpler "current->state = TASK_RUNNING" to mark yourself
1483 * runnable without the overhead of this. 1485 * runnable without the overhead of this.
1484 * 1486 *
1485 * Returns %true if @p was woken up, %false if it was already running 1487 * Return: %true if @p was woken up, %false if it was already running.
1486 * or @state didn't match @p's state. 1488 * or @state didn't match @p's state.
1487 */ 1489 */
1488static int 1490static int
@@ -1491,7 +1493,13 @@ try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags)
1491 unsigned long flags; 1493 unsigned long flags;
1492 int cpu, success = 0; 1494 int cpu, success = 0;
1493 1495
1494 smp_wmb(); 1496 /*
1497 * If we are going to wake up a thread waiting for CONDITION we
1498 * need to ensure that CONDITION=1 done by the caller can not be
1499 * reordered with p->state check below. This pairs with mb() in
1500 * set_current_state() the waiting thread does.
1501 */
1502 smp_mb__before_spinlock();
1495 raw_spin_lock_irqsave(&p->pi_lock, flags); 1503 raw_spin_lock_irqsave(&p->pi_lock, flags);
1496 if (!(p->state & state)) 1504 if (!(p->state & state))
1497 goto out; 1505 goto out;
@@ -1577,8 +1585,9 @@ out:
1577 * @p: The process to be woken up. 1585 * @p: The process to be woken up.
1578 * 1586 *
1579 * Attempt to wake up the nominated process and move it to the set of runnable 1587 * Attempt to wake up the nominated process and move it to the set of runnable
1580 * processes. Returns 1 if the process was woken up, 0 if it was already 1588 * processes.
1581 * running. 1589 *
1590 * Return: 1 if the process was woken up, 0 if it was already running.
1582 * 1591 *
1583 * It may be assumed that this function implies a write memory barrier before 1592 * It may be assumed that this function implies a write memory barrier before
1584 * changing the task state if and only if any tasks are woken up. 1593 * changing the task state if and only if any tasks are woken up.
@@ -2191,6 +2200,8 @@ void scheduler_tick(void)
2191 * This makes sure that uptime, CFS vruntime, load 2200 * This makes sure that uptime, CFS vruntime, load
2192 * balancing, etc... continue to move forward, even 2201 * balancing, etc... continue to move forward, even
2193 * with a very low granularity. 2202 * with a very low granularity.
2203 *
2204 * Return: Maximum deferment in nanoseconds.
2194 */ 2205 */
2195u64 scheduler_tick_max_deferment(void) 2206u64 scheduler_tick_max_deferment(void)
2196{ 2207{
@@ -2394,6 +2405,12 @@ need_resched:
2394 if (sched_feat(HRTICK)) 2405 if (sched_feat(HRTICK))
2395 hrtick_clear(rq); 2406 hrtick_clear(rq);
2396 2407
2408 /*
2409 * Make sure that signal_pending_state()->signal_pending() below
2410 * can't be reordered with __set_current_state(TASK_INTERRUPTIBLE)
2411 * done by the caller to avoid the race with signal_wake_up().
2412 */
2413 smp_mb__before_spinlock();
2397 raw_spin_lock_irq(&rq->lock); 2414 raw_spin_lock_irq(&rq->lock);
2398 2415
2399 switch_count = &prev->nivcsw; 2416 switch_count = &prev->nivcsw;
@@ -2796,8 +2813,8 @@ EXPORT_SYMBOL(wait_for_completion);
2796 * specified timeout to expire. The timeout is in jiffies. It is not 2813 * specified timeout to expire. The timeout is in jiffies. It is not
2797 * interruptible. 2814 * interruptible.
2798 * 2815 *
2799 * The return value is 0 if timed out, and positive (at least 1, or number of 2816 * Return: 0 if timed out, and positive (at least 1, or number of jiffies left
2800 * jiffies left till timeout) if completed. 2817 * till timeout) if completed.
2801 */ 2818 */
2802unsigned long __sched 2819unsigned long __sched
2803wait_for_completion_timeout(struct completion *x, unsigned long timeout) 2820wait_for_completion_timeout(struct completion *x, unsigned long timeout)
@@ -2829,8 +2846,8 @@ EXPORT_SYMBOL(wait_for_completion_io);
2829 * specified timeout to expire. The timeout is in jiffies. It is not 2846 * specified timeout to expire. The timeout is in jiffies. It is not
2830 * interruptible. The caller is accounted as waiting for IO. 2847 * interruptible. The caller is accounted as waiting for IO.
2831 * 2848 *
2832 * The return value is 0 if timed out, and positive (at least 1, or number of 2849 * Return: 0 if timed out, and positive (at least 1, or number of jiffies left
2833 * jiffies left till timeout) if completed. 2850 * till timeout) if completed.
2834 */ 2851 */
2835unsigned long __sched 2852unsigned long __sched
2836wait_for_completion_io_timeout(struct completion *x, unsigned long timeout) 2853wait_for_completion_io_timeout(struct completion *x, unsigned long timeout)
@@ -2846,7 +2863,7 @@ EXPORT_SYMBOL(wait_for_completion_io_timeout);
2846 * This waits for completion of a specific task to be signaled. It is 2863 * This waits for completion of a specific task to be signaled. It is
2847 * interruptible. 2864 * interruptible.
2848 * 2865 *
2849 * The return value is -ERESTARTSYS if interrupted, 0 if completed. 2866 * Return: -ERESTARTSYS if interrupted, 0 if completed.
2850 */ 2867 */
2851int __sched wait_for_completion_interruptible(struct completion *x) 2868int __sched wait_for_completion_interruptible(struct completion *x)
2852{ 2869{
@@ -2865,8 +2882,8 @@ EXPORT_SYMBOL(wait_for_completion_interruptible);
2865 * This waits for either a completion of a specific task to be signaled or for a 2882 * This waits for either a completion of a specific task to be signaled or for a
2866 * specified timeout to expire. It is interruptible. The timeout is in jiffies. 2883 * specified timeout to expire. It is interruptible. The timeout is in jiffies.
2867 * 2884 *
2868 * The return value is -ERESTARTSYS if interrupted, 0 if timed out, 2885 * Return: -ERESTARTSYS if interrupted, 0 if timed out, positive (at least 1,
2869 * positive (at least 1, or number of jiffies left till timeout) if completed. 2886 * or number of jiffies left till timeout) if completed.
2870 */ 2887 */
2871long __sched 2888long __sched
2872wait_for_completion_interruptible_timeout(struct completion *x, 2889wait_for_completion_interruptible_timeout(struct completion *x,
@@ -2883,7 +2900,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible_timeout);
2883 * This waits to be signaled for completion of a specific task. It can be 2900 * This waits to be signaled for completion of a specific task. It can be
2884 * interrupted by a kill signal. 2901 * interrupted by a kill signal.
2885 * 2902 *
2886 * The return value is -ERESTARTSYS if interrupted, 0 if completed. 2903 * Return: -ERESTARTSYS if interrupted, 0 if completed.
2887 */ 2904 */
2888int __sched wait_for_completion_killable(struct completion *x) 2905int __sched wait_for_completion_killable(struct completion *x)
2889{ 2906{
@@ -2903,8 +2920,8 @@ EXPORT_SYMBOL(wait_for_completion_killable);
2903 * signaled or for a specified timeout to expire. It can be 2920 * signaled or for a specified timeout to expire. It can be
2904 * interrupted by a kill signal. The timeout is in jiffies. 2921 * interrupted by a kill signal. The timeout is in jiffies.
2905 * 2922 *
2906 * The return value is -ERESTARTSYS if interrupted, 0 if timed out, 2923 * Return: -ERESTARTSYS if interrupted, 0 if timed out, positive (at least 1,
2907 * positive (at least 1, or number of jiffies left till timeout) if completed. 2924 * or number of jiffies left till timeout) if completed.
2908 */ 2925 */
2909long __sched 2926long __sched
2910wait_for_completion_killable_timeout(struct completion *x, 2927wait_for_completion_killable_timeout(struct completion *x,
@@ -2918,7 +2935,7 @@ EXPORT_SYMBOL(wait_for_completion_killable_timeout);
2918 * try_wait_for_completion - try to decrement a completion without blocking 2935 * try_wait_for_completion - try to decrement a completion without blocking
2919 * @x: completion structure 2936 * @x: completion structure
2920 * 2937 *
2921 * Returns: 0 if a decrement cannot be done without blocking 2938 * Return: 0 if a decrement cannot be done without blocking
2922 * 1 if a decrement succeeded. 2939 * 1 if a decrement succeeded.
2923 * 2940 *
2924 * If a completion is being used as a counting completion, 2941 * If a completion is being used as a counting completion,
@@ -2945,7 +2962,7 @@ EXPORT_SYMBOL(try_wait_for_completion);
2945 * completion_done - Test to see if a completion has any waiters 2962 * completion_done - Test to see if a completion has any waiters
2946 * @x: completion structure 2963 * @x: completion structure
2947 * 2964 *
2948 * Returns: 0 if there are waiters (wait_for_completion() in progress) 2965 * Return: 0 if there are waiters (wait_for_completion() in progress)
2949 * 1 if there are no waiters. 2966 * 1 if there are no waiters.
2950 * 2967 *
2951 */ 2968 */
@@ -3182,7 +3199,7 @@ SYSCALL_DEFINE1(nice, int, increment)
3182 * task_prio - return the priority value of a given task. 3199 * task_prio - return the priority value of a given task.
3183 * @p: the task in question. 3200 * @p: the task in question.
3184 * 3201 *
3185 * This is the priority value as seen by users in /proc. 3202 * Return: The priority value as seen by users in /proc.
3186 * RT tasks are offset by -200. Normal tasks are centered 3203 * RT tasks are offset by -200. Normal tasks are centered
3187 * around 0, value goes from -16 to +15. 3204 * around 0, value goes from -16 to +15.
3188 */ 3205 */
@@ -3194,6 +3211,8 @@ int task_prio(const struct task_struct *p)
3194/** 3211/**
3195 * task_nice - return the nice value of a given task. 3212 * task_nice - return the nice value of a given task.
3196 * @p: the task in question. 3213 * @p: the task in question.
3214 *
3215 * Return: The nice value [ -20 ... 0 ... 19 ].
3197 */ 3216 */
3198int task_nice(const struct task_struct *p) 3217int task_nice(const struct task_struct *p)
3199{ 3218{
@@ -3204,6 +3223,8 @@ EXPORT_SYMBOL(task_nice);
3204/** 3223/**
3205 * idle_cpu - is a given cpu idle currently? 3224 * idle_cpu - is a given cpu idle currently?
3206 * @cpu: the processor in question. 3225 * @cpu: the processor in question.
3226 *
3227 * Return: 1 if the CPU is currently idle. 0 otherwise.
3207 */ 3228 */
3208int idle_cpu(int cpu) 3229int idle_cpu(int cpu)
3209{ 3230{
@@ -3226,6 +3247,8 @@ int idle_cpu(int cpu)
3226/** 3247/**
3227 * idle_task - return the idle task for a given cpu. 3248 * idle_task - return the idle task for a given cpu.
3228 * @cpu: the processor in question. 3249 * @cpu: the processor in question.
3250 *
3251 * Return: The idle task for the cpu @cpu.
3229 */ 3252 */
3230struct task_struct *idle_task(int cpu) 3253struct task_struct *idle_task(int cpu)
3231{ 3254{
@@ -3235,6 +3258,8 @@ struct task_struct *idle_task(int cpu)
3235/** 3258/**
3236 * find_process_by_pid - find a process with a matching PID value. 3259 * find_process_by_pid - find a process with a matching PID value.
3237 * @pid: the pid in question. 3260 * @pid: the pid in question.
3261 *
3262 * The task of @pid, if found. %NULL otherwise.
3238 */ 3263 */
3239static struct task_struct *find_process_by_pid(pid_t pid) 3264static struct task_struct *find_process_by_pid(pid_t pid)
3240{ 3265{
@@ -3432,6 +3457,8 @@ recheck:
3432 * @policy: new policy. 3457 * @policy: new policy.
3433 * @param: structure containing the new RT priority. 3458 * @param: structure containing the new RT priority.
3434 * 3459 *
3460 * Return: 0 on success. An error code otherwise.
3461 *
3435 * NOTE that the task may be already dead. 3462 * NOTE that the task may be already dead.
3436 */ 3463 */
3437int sched_setscheduler(struct task_struct *p, int policy, 3464int sched_setscheduler(struct task_struct *p, int policy,
@@ -3451,6 +3478,8 @@ EXPORT_SYMBOL_GPL(sched_setscheduler);
3451 * current context has permission. For example, this is needed in 3478 * current context has permission. For example, this is needed in
3452 * stop_machine(): we create temporary high priority worker threads, 3479 * stop_machine(): we create temporary high priority worker threads,
3453 * but our caller might not have that capability. 3480 * but our caller might not have that capability.
3481 *
3482 * Return: 0 on success. An error code otherwise.
3454 */ 3483 */
3455int sched_setscheduler_nocheck(struct task_struct *p, int policy, 3484int sched_setscheduler_nocheck(struct task_struct *p, int policy,
3456 const struct sched_param *param) 3485 const struct sched_param *param)
@@ -3485,6 +3514,8 @@ do_sched_setscheduler(pid_t pid, int policy, struct sched_param __user *param)
3485 * @pid: the pid in question. 3514 * @pid: the pid in question.
3486 * @policy: new policy. 3515 * @policy: new policy.
3487 * @param: structure containing the new RT priority. 3516 * @param: structure containing the new RT priority.
3517 *
3518 * Return: 0 on success. An error code otherwise.
3488 */ 3519 */
3489SYSCALL_DEFINE3(sched_setscheduler, pid_t, pid, int, policy, 3520SYSCALL_DEFINE3(sched_setscheduler, pid_t, pid, int, policy,
3490 struct sched_param __user *, param) 3521 struct sched_param __user *, param)
@@ -3500,6 +3531,8 @@ SYSCALL_DEFINE3(sched_setscheduler, pid_t, pid, int, policy,
3500 * sys_sched_setparam - set/change the RT priority of a thread 3531 * sys_sched_setparam - set/change the RT priority of a thread
3501 * @pid: the pid in question. 3532 * @pid: the pid in question.
3502 * @param: structure containing the new RT priority. 3533 * @param: structure containing the new RT priority.
3534 *
3535 * Return: 0 on success. An error code otherwise.
3503 */ 3536 */
3504SYSCALL_DEFINE2(sched_setparam, pid_t, pid, struct sched_param __user *, param) 3537SYSCALL_DEFINE2(sched_setparam, pid_t, pid, struct sched_param __user *, param)
3505{ 3538{
@@ -3509,6 +3542,9 @@ SYSCALL_DEFINE2(sched_setparam, pid_t, pid, struct sched_param __user *, param)
3509/** 3542/**
3510 * sys_sched_getscheduler - get the policy (scheduling class) of a thread 3543 * sys_sched_getscheduler - get the policy (scheduling class) of a thread
3511 * @pid: the pid in question. 3544 * @pid: the pid in question.
3545 *
3546 * Return: On success, the policy of the thread. Otherwise, a negative error
3547 * code.
3512 */ 3548 */
3513SYSCALL_DEFINE1(sched_getscheduler, pid_t, pid) 3549SYSCALL_DEFINE1(sched_getscheduler, pid_t, pid)
3514{ 3550{
@@ -3535,6 +3571,9 @@ SYSCALL_DEFINE1(sched_getscheduler, pid_t, pid)
3535 * sys_sched_getparam - get the RT priority of a thread 3571 * sys_sched_getparam - get the RT priority of a thread
3536 * @pid: the pid in question. 3572 * @pid: the pid in question.
3537 * @param: structure containing the RT priority. 3573 * @param: structure containing the RT priority.
3574 *
3575 * Return: On success, 0 and the RT priority is in @param. Otherwise, an error
3576 * code.
3538 */ 3577 */
3539SYSCALL_DEFINE2(sched_getparam, pid_t, pid, struct sched_param __user *, param) 3578SYSCALL_DEFINE2(sched_getparam, pid_t, pid, struct sched_param __user *, param)
3540{ 3579{
@@ -3659,6 +3698,8 @@ static int get_user_cpu_mask(unsigned long __user *user_mask_ptr, unsigned len,
3659 * @pid: pid of the process 3698 * @pid: pid of the process
3660 * @len: length in bytes of the bitmask pointed to by user_mask_ptr 3699 * @len: length in bytes of the bitmask pointed to by user_mask_ptr
3661 * @user_mask_ptr: user-space pointer to the new cpu mask 3700 * @user_mask_ptr: user-space pointer to the new cpu mask
3701 *
3702 * Return: 0 on success. An error code otherwise.
3662 */ 3703 */
3663SYSCALL_DEFINE3(sched_setaffinity, pid_t, pid, unsigned int, len, 3704SYSCALL_DEFINE3(sched_setaffinity, pid_t, pid, unsigned int, len,
3664 unsigned long __user *, user_mask_ptr) 3705 unsigned long __user *, user_mask_ptr)
@@ -3710,6 +3751,8 @@ out_unlock:
3710 * @pid: pid of the process 3751 * @pid: pid of the process
3711 * @len: length in bytes of the bitmask pointed to by user_mask_ptr 3752 * @len: length in bytes of the bitmask pointed to by user_mask_ptr
3712 * @user_mask_ptr: user-space pointer to hold the current cpu mask 3753 * @user_mask_ptr: user-space pointer to hold the current cpu mask
3754 *
3755 * Return: 0 on success. An error code otherwise.
3713 */ 3756 */
3714SYSCALL_DEFINE3(sched_getaffinity, pid_t, pid, unsigned int, len, 3757SYSCALL_DEFINE3(sched_getaffinity, pid_t, pid, unsigned int, len,
3715 unsigned long __user *, user_mask_ptr) 3758 unsigned long __user *, user_mask_ptr)
@@ -3744,6 +3787,8 @@ SYSCALL_DEFINE3(sched_getaffinity, pid_t, pid, unsigned int, len,
3744 * 3787 *
3745 * This function yields the current CPU to other tasks. If there are no 3788 * This function yields the current CPU to other tasks. If there are no
3746 * other threads running on this CPU then this function will return. 3789 * other threads running on this CPU then this function will return.
3790 *
3791 * Return: 0.
3747 */ 3792 */
3748SYSCALL_DEFINE0(sched_yield) 3793SYSCALL_DEFINE0(sched_yield)
3749{ 3794{
@@ -3869,7 +3914,7 @@ EXPORT_SYMBOL(yield);
3869 * It's the caller's job to ensure that the target task struct 3914 * It's the caller's job to ensure that the target task struct
3870 * can't go away on us before we can do any checks. 3915 * can't go away on us before we can do any checks.
3871 * 3916 *
3872 * Returns: 3917 * Return:
3873 * true (>0) if we indeed boosted the target task. 3918 * true (>0) if we indeed boosted the target task.
3874 * false (0) if we failed to boost the target. 3919 * false (0) if we failed to boost the target.
3875 * -ESRCH if there's no task to yield to. 3920 * -ESRCH if there's no task to yield to.
@@ -3972,8 +4017,9 @@ long __sched io_schedule_timeout(long timeout)
3972 * sys_sched_get_priority_max - return maximum RT priority. 4017 * sys_sched_get_priority_max - return maximum RT priority.
3973 * @policy: scheduling class. 4018 * @policy: scheduling class.
3974 * 4019 *
3975 * this syscall returns the maximum rt_priority that can be used 4020 * Return: On success, this syscall returns the maximum
3976 * by a given scheduling class. 4021 * rt_priority that can be used by a given scheduling class.
4022 * On failure, a negative error code is returned.
3977 */ 4023 */
3978SYSCALL_DEFINE1(sched_get_priority_max, int, policy) 4024SYSCALL_DEFINE1(sched_get_priority_max, int, policy)
3979{ 4025{
@@ -3997,8 +4043,9 @@ SYSCALL_DEFINE1(sched_get_priority_max, int, policy)
3997 * sys_sched_get_priority_min - return minimum RT priority. 4043 * sys_sched_get_priority_min - return minimum RT priority.
3998 * @policy: scheduling class. 4044 * @policy: scheduling class.
3999 * 4045 *
4000 * this syscall returns the minimum rt_priority that can be used 4046 * Return: On success, this syscall returns the minimum
4001 * by a given scheduling class. 4047 * rt_priority that can be used by a given scheduling class.
4048 * On failure, a negative error code is returned.
4002 */ 4049 */
4003SYSCALL_DEFINE1(sched_get_priority_min, int, policy) 4050SYSCALL_DEFINE1(sched_get_priority_min, int, policy)
4004{ 4051{
@@ -4024,6 +4071,9 @@ SYSCALL_DEFINE1(sched_get_priority_min, int, policy)
4024 * 4071 *
4025 * this syscall writes the default timeslice value of a given process 4072 * this syscall writes the default timeslice value of a given process
4026 * into the user-space timespec buffer. A value of '0' means infinity. 4073 * into the user-space timespec buffer. A value of '0' means infinity.
4074 *
4075 * Return: On success, 0 and the timeslice is in @interval. Otherwise,
4076 * an error code.
4027 */ 4077 */
4028SYSCALL_DEFINE2(sched_rr_get_interval, pid_t, pid, 4078SYSCALL_DEFINE2(sched_rr_get_interval, pid_t, pid,
4029 struct timespec __user *, interval) 4079 struct timespec __user *, interval)
@@ -6632,6 +6682,8 @@ void normalize_rt_tasks(void)
6632 * @cpu: the processor in question. 6682 * @cpu: the processor in question.
6633 * 6683 *
6634 * ONLY VALID WHEN THE WHOLE SYSTEM IS STOPPED! 6684 * ONLY VALID WHEN THE WHOLE SYSTEM IS STOPPED!
6685 *
6686 * Return: The current task for @cpu.
6635 */ 6687 */
6636struct task_struct *curr_task(int cpu) 6688struct task_struct *curr_task(int cpu)
6637{ 6689{
diff --git a/kernel/sched/cpupri.c b/kernel/sched/cpupri.c
index 1095e878a46f..8b836b376d91 100644
--- a/kernel/sched/cpupri.c
+++ b/kernel/sched/cpupri.c
@@ -62,7 +62,7 @@ static int convert_prio(int prio)
62 * any discrepancies created by racing against the uncertainty of the current 62 * any discrepancies created by racing against the uncertainty of the current
63 * priority configuration. 63 * priority configuration.
64 * 64 *
65 * Returns: (int)bool - CPUs were found 65 * Return: (int)bool - CPUs were found
66 */ 66 */
67int cpupri_find(struct cpupri *cp, struct task_struct *p, 67int cpupri_find(struct cpupri *cp, struct task_struct *p,
68 struct cpumask *lowest_mask) 68 struct cpumask *lowest_mask)
@@ -203,7 +203,7 @@ void cpupri_set(struct cpupri *cp, int cpu, int newpri)
203 * cpupri_init - initialize the cpupri structure 203 * cpupri_init - initialize the cpupri structure
204 * @cp: The cpupri context 204 * @cp: The cpupri context
205 * 205 *
206 * Returns: -ENOMEM if memory fails. 206 * Return: -ENOMEM on memory allocation failure.
207 */ 207 */
208int cpupri_init(struct cpupri *cp) 208int cpupri_init(struct cpupri *cp)
209{ 209{
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 9565645e3202..68f1609ca149 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -2032,6 +2032,7 @@ entity_tick(struct cfs_rq *cfs_rq, struct sched_entity *curr, int queued)
2032 */ 2032 */
2033 update_entity_load_avg(curr, 1); 2033 update_entity_load_avg(curr, 1);
2034 update_cfs_rq_blocked_load(cfs_rq, 1); 2034 update_cfs_rq_blocked_load(cfs_rq, 1);
2035 update_cfs_shares(cfs_rq);
2035 2036
2036#ifdef CONFIG_SCHED_HRTICK 2037#ifdef CONFIG_SCHED_HRTICK
2037 /* 2038 /*
@@ -4280,6 +4281,8 @@ struct sg_lb_stats {
4280 * get_sd_load_idx - Obtain the load index for a given sched domain. 4281 * get_sd_load_idx - Obtain the load index for a given sched domain.
4281 * @sd: The sched_domain whose load_idx is to be obtained. 4282 * @sd: The sched_domain whose load_idx is to be obtained.
4282 * @idle: The Idle status of the CPU for whose sd load_icx is obtained. 4283 * @idle: The Idle status of the CPU for whose sd load_icx is obtained.
4284 *
4285 * Return: The load index.
4283 */ 4286 */
4284static inline int get_sd_load_idx(struct sched_domain *sd, 4287static inline int get_sd_load_idx(struct sched_domain *sd,
4285 enum cpu_idle_type idle) 4288 enum cpu_idle_type idle)
@@ -4574,6 +4577,9 @@ static inline void update_sg_lb_stats(struct lb_env *env,
4574 * 4577 *
4575 * Determine if @sg is a busier group than the previously selected 4578 * Determine if @sg is a busier group than the previously selected
4576 * busiest group. 4579 * busiest group.
4580 *
4581 * Return: %true if @sg is a busier group than the previously selected
4582 * busiest group. %false otherwise.
4577 */ 4583 */
4578static bool update_sd_pick_busiest(struct lb_env *env, 4584static bool update_sd_pick_busiest(struct lb_env *env,
4579 struct sd_lb_stats *sds, 4585 struct sd_lb_stats *sds,
@@ -4691,7 +4697,7 @@ static inline void update_sd_lb_stats(struct lb_env *env,
4691 * assuming lower CPU number will be equivalent to lower a SMT thread 4697 * assuming lower CPU number will be equivalent to lower a SMT thread
4692 * number. 4698 * number.
4693 * 4699 *
4694 * Returns 1 when packing is required and a task should be moved to 4700 * Return: 1 when packing is required and a task should be moved to
4695 * this CPU. The amount of the imbalance is returned in *imbalance. 4701 * this CPU. The amount of the imbalance is returned in *imbalance.
4696 * 4702 *
4697 * @env: The load balancing environment. 4703 * @env: The load balancing environment.
@@ -4869,7 +4875,7 @@ static inline void calculate_imbalance(struct lb_env *env, struct sd_lb_stats *s
4869 * @balance: Pointer to a variable indicating if this_cpu 4875 * @balance: Pointer to a variable indicating if this_cpu
4870 * is the appropriate cpu to perform load balancing at this_level. 4876 * is the appropriate cpu to perform load balancing at this_level.
4871 * 4877 *
4872 * Returns: - the busiest group if imbalance exists. 4878 * Return: - The busiest group if imbalance exists.
4873 * - If no imbalance and user has opted for power-savings balance, 4879 * - If no imbalance and user has opted for power-savings balance,
4874 * return the least loaded group whose CPUs can be 4880 * return the least loaded group whose CPUs can be
4875 * put to idle by rebalancing its tasks onto our group. 4881 * put to idle by rebalancing its tasks onto our group.
diff --git a/kernel/time/sched_clock.c b/kernel/time/sched_clock.c
index a326f27d7f09..0b479a6a22bb 100644
--- a/kernel/time/sched_clock.c
+++ b/kernel/time/sched_clock.c
@@ -121,7 +121,7 @@ void __init setup_sched_clock(u32 (*read)(void), int bits, unsigned long rate)
121 BUG_ON(bits > 32); 121 BUG_ON(bits > 32);
122 WARN_ON(!irqs_disabled()); 122 WARN_ON(!irqs_disabled());
123 read_sched_clock = read; 123 read_sched_clock = read;
124 sched_clock_mask = (1 << bits) - 1; 124 sched_clock_mask = (1ULL << bits) - 1;
125 cd.rate = rate; 125 cd.rate = rate;
126 126
127 /* calculate the mult/shift to convert counter ticks to ns. */ 127 /* calculate the mult/shift to convert counter ticks to ns. */
diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index e77edc97e036..e8a1516cc0a3 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -182,7 +182,8 @@ static bool can_stop_full_tick(void)
182 * Don't allow the user to think they can get 182 * Don't allow the user to think they can get
183 * full NO_HZ with this machine. 183 * full NO_HZ with this machine.
184 */ 184 */
185 WARN_ONCE(1, "NO_HZ FULL will not work with unstable sched clock"); 185 WARN_ONCE(have_nohz_full_mask,
186 "NO_HZ FULL will not work with unstable sched clock");
186 return false; 187 return false;
187 } 188 }
188#endif 189#endif
@@ -343,8 +344,6 @@ static int tick_nohz_init_all(void)
343 344
344void __init tick_nohz_init(void) 345void __init tick_nohz_init(void)
345{ 346{
346 int cpu;
347
348 if (!have_nohz_full_mask) { 347 if (!have_nohz_full_mask) {
349 if (tick_nohz_init_all() < 0) 348 if (tick_nohz_init_all() < 0)
350 return; 349 return;
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 8ce9eefc5bb4..a6d098c6df3f 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -2169,12 +2169,57 @@ static cycle_t ftrace_update_time;
2169static unsigned long ftrace_update_cnt; 2169static unsigned long ftrace_update_cnt;
2170unsigned long ftrace_update_tot_cnt; 2170unsigned long ftrace_update_tot_cnt;
2171 2171
2172static int ops_traces_mod(struct ftrace_ops *ops) 2172static inline int ops_traces_mod(struct ftrace_ops *ops)
2173{ 2173{
2174 struct ftrace_hash *hash; 2174 /*
2175 * Filter_hash being empty will default to trace module.
2176 * But notrace hash requires a test of individual module functions.
2177 */
2178 return ftrace_hash_empty(ops->filter_hash) &&
2179 ftrace_hash_empty(ops->notrace_hash);
2180}
2181
2182/*
2183 * Check if the current ops references the record.
2184 *
2185 * If the ops traces all functions, then it was already accounted for.
2186 * If the ops does not trace the current record function, skip it.
2187 * If the ops ignores the function via notrace filter, skip it.
2188 */
2189static inline bool
2190ops_references_rec(struct ftrace_ops *ops, struct dyn_ftrace *rec)
2191{
2192 /* If ops isn't enabled, ignore it */
2193 if (!(ops->flags & FTRACE_OPS_FL_ENABLED))
2194 return 0;
2195
2196 /* If ops traces all mods, we already accounted for it */
2197 if (ops_traces_mod(ops))
2198 return 0;
2199
2200 /* The function must be in the filter */
2201 if (!ftrace_hash_empty(ops->filter_hash) &&
2202 !ftrace_lookup_ip(ops->filter_hash, rec->ip))
2203 return 0;
2204
2205 /* If in notrace hash, we ignore it too */
2206 if (ftrace_lookup_ip(ops->notrace_hash, rec->ip))
2207 return 0;
2208
2209 return 1;
2210}
2211
2212static int referenced_filters(struct dyn_ftrace *rec)
2213{
2214 struct ftrace_ops *ops;
2215 int cnt = 0;
2175 2216
2176 hash = ops->filter_hash; 2217 for (ops = ftrace_ops_list; ops != &ftrace_list_end; ops = ops->next) {
2177 return ftrace_hash_empty(hash); 2218 if (ops_references_rec(ops, rec))
2219 cnt++;
2220 }
2221
2222 return cnt;
2178} 2223}
2179 2224
2180static int ftrace_update_code(struct module *mod) 2225static int ftrace_update_code(struct module *mod)
@@ -2183,6 +2228,7 @@ static int ftrace_update_code(struct module *mod)
2183 struct dyn_ftrace *p; 2228 struct dyn_ftrace *p;
2184 cycle_t start, stop; 2229 cycle_t start, stop;
2185 unsigned long ref = 0; 2230 unsigned long ref = 0;
2231 bool test = false;
2186 int i; 2232 int i;
2187 2233
2188 /* 2234 /*
@@ -2196,9 +2242,12 @@ static int ftrace_update_code(struct module *mod)
2196 2242
2197 for (ops = ftrace_ops_list; 2243 for (ops = ftrace_ops_list;
2198 ops != &ftrace_list_end; ops = ops->next) { 2244 ops != &ftrace_list_end; ops = ops->next) {
2199 if (ops->flags & FTRACE_OPS_FL_ENABLED && 2245 if (ops->flags & FTRACE_OPS_FL_ENABLED) {
2200 ops_traces_mod(ops)) 2246 if (ops_traces_mod(ops))
2201 ref++; 2247 ref++;
2248 else
2249 test = true;
2250 }
2202 } 2251 }
2203 } 2252 }
2204 2253
@@ -2208,12 +2257,16 @@ static int ftrace_update_code(struct module *mod)
2208 for (pg = ftrace_new_pgs; pg; pg = pg->next) { 2257 for (pg = ftrace_new_pgs; pg; pg = pg->next) {
2209 2258
2210 for (i = 0; i < pg->index; i++) { 2259 for (i = 0; i < pg->index; i++) {
2260 int cnt = ref;
2261
2211 /* If something went wrong, bail without enabling anything */ 2262 /* If something went wrong, bail without enabling anything */
2212 if (unlikely(ftrace_disabled)) 2263 if (unlikely(ftrace_disabled))
2213 return -1; 2264 return -1;
2214 2265
2215 p = &pg->records[i]; 2266 p = &pg->records[i];
2216 p->flags = ref; 2267 if (test)
2268 cnt += referenced_filters(p);
2269 p->flags = cnt;
2217 2270
2218 /* 2271 /*
2219 * Do the initial record conversion from mcount jump 2272 * Do the initial record conversion from mcount jump
@@ -2233,7 +2286,7 @@ static int ftrace_update_code(struct module *mod)
2233 * conversion puts the module to the correct state, thus 2286 * conversion puts the module to the correct state, thus
2234 * passing the ftrace_make_call check. 2287 * passing the ftrace_make_call check.
2235 */ 2288 */
2236 if (ftrace_start_up && ref) { 2289 if (ftrace_start_up && cnt) {
2237 int failed = __ftrace_replace_code(p, 1); 2290 int failed = __ftrace_replace_code(p, 1);
2238 if (failed) 2291 if (failed)
2239 ftrace_bug(failed, p->ip); 2292 ftrace_bug(failed, p->ip);
@@ -3384,6 +3437,12 @@ ftrace_match_addr(struct ftrace_hash *hash, unsigned long ip, int remove)
3384 return add_hash_entry(hash, ip); 3437 return add_hash_entry(hash, ip);
3385} 3438}
3386 3439
3440static void ftrace_ops_update_code(struct ftrace_ops *ops)
3441{
3442 if (ops->flags & FTRACE_OPS_FL_ENABLED && ftrace_enabled)
3443 ftrace_run_update_code(FTRACE_UPDATE_CALLS);
3444}
3445
3387static int 3446static int
3388ftrace_set_hash(struct ftrace_ops *ops, unsigned char *buf, int len, 3447ftrace_set_hash(struct ftrace_ops *ops, unsigned char *buf, int len,
3389 unsigned long ip, int remove, int reset, int enable) 3448 unsigned long ip, int remove, int reset, int enable)
@@ -3426,9 +3485,8 @@ ftrace_set_hash(struct ftrace_ops *ops, unsigned char *buf, int len,
3426 3485
3427 mutex_lock(&ftrace_lock); 3486 mutex_lock(&ftrace_lock);
3428 ret = ftrace_hash_move(ops, enable, orig_hash, hash); 3487 ret = ftrace_hash_move(ops, enable, orig_hash, hash);
3429 if (!ret && ops->flags & FTRACE_OPS_FL_ENABLED 3488 if (!ret)
3430 && ftrace_enabled) 3489 ftrace_ops_update_code(ops);
3431 ftrace_run_update_code(FTRACE_UPDATE_CALLS);
3432 3490
3433 mutex_unlock(&ftrace_lock); 3491 mutex_unlock(&ftrace_lock);
3434 3492
@@ -3655,9 +3713,8 @@ int ftrace_regex_release(struct inode *inode, struct file *file)
3655 mutex_lock(&ftrace_lock); 3713 mutex_lock(&ftrace_lock);
3656 ret = ftrace_hash_move(iter->ops, filter_hash, 3714 ret = ftrace_hash_move(iter->ops, filter_hash,
3657 orig_hash, iter->hash); 3715 orig_hash, iter->hash);
3658 if (!ret && (iter->ops->flags & FTRACE_OPS_FL_ENABLED) 3716 if (!ret)
3659 && ftrace_enabled) 3717 ftrace_ops_update_code(iter->ops);
3660 ftrace_run_update_code(FTRACE_UPDATE_CALLS);
3661 3718
3662 mutex_unlock(&ftrace_lock); 3719 mutex_unlock(&ftrace_lock);
3663 } 3720 }
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 882ec1dd1515..496f94d57698 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -243,20 +243,25 @@ int filter_current_check_discard(struct ring_buffer *buffer,
243} 243}
244EXPORT_SYMBOL_GPL(filter_current_check_discard); 244EXPORT_SYMBOL_GPL(filter_current_check_discard);
245 245
246cycle_t ftrace_now(int cpu) 246cycle_t buffer_ftrace_now(struct trace_buffer *buf, int cpu)
247{ 247{
248 u64 ts; 248 u64 ts;
249 249
250 /* Early boot up does not have a buffer yet */ 250 /* Early boot up does not have a buffer yet */
251 if (!global_trace.trace_buffer.buffer) 251 if (!buf->buffer)
252 return trace_clock_local(); 252 return trace_clock_local();
253 253
254 ts = ring_buffer_time_stamp(global_trace.trace_buffer.buffer, cpu); 254 ts = ring_buffer_time_stamp(buf->buffer, cpu);
255 ring_buffer_normalize_time_stamp(global_trace.trace_buffer.buffer, cpu, &ts); 255 ring_buffer_normalize_time_stamp(buf->buffer, cpu, &ts);
256 256
257 return ts; 257 return ts;
258} 258}
259 259
260cycle_t ftrace_now(int cpu)
261{
262 return buffer_ftrace_now(&global_trace.trace_buffer, cpu);
263}
264
260/** 265/**
261 * tracing_is_enabled - Show if global_trace has been disabled 266 * tracing_is_enabled - Show if global_trace has been disabled
262 * 267 *
@@ -1211,7 +1216,7 @@ void tracing_reset_online_cpus(struct trace_buffer *buf)
1211 /* Make sure all commits have finished */ 1216 /* Make sure all commits have finished */
1212 synchronize_sched(); 1217 synchronize_sched();
1213 1218
1214 buf->time_start = ftrace_now(buf->cpu); 1219 buf->time_start = buffer_ftrace_now(buf, buf->cpu);
1215 1220
1216 for_each_online_cpu(cpu) 1221 for_each_online_cpu(cpu)
1217 ring_buffer_reset_cpu(buffer, cpu); 1222 ring_buffer_reset_cpu(buffer, cpu);
@@ -1219,11 +1224,6 @@ void tracing_reset_online_cpus(struct trace_buffer *buf)
1219 ring_buffer_record_enable(buffer); 1224 ring_buffer_record_enable(buffer);
1220} 1225}
1221 1226
1222void tracing_reset_current(int cpu)
1223{
1224 tracing_reset(&global_trace.trace_buffer, cpu);
1225}
1226
1227/* Must have trace_types_lock held */ 1227/* Must have trace_types_lock held */
1228void tracing_reset_all_online_cpus(void) 1228void tracing_reset_all_online_cpus(void)
1229{ 1229{
@@ -4151,6 +4151,7 @@ waitagain:
4151 memset(&iter->seq, 0, 4151 memset(&iter->seq, 0,
4152 sizeof(struct trace_iterator) - 4152 sizeof(struct trace_iterator) -
4153 offsetof(struct trace_iterator, seq)); 4153 offsetof(struct trace_iterator, seq));
4154 cpumask_clear(iter->started);
4154 iter->pos = -1; 4155 iter->pos = -1;
4155 4156
4156 trace_event_read_lock(); 4157 trace_event_read_lock();
@@ -4468,7 +4469,7 @@ tracing_free_buffer_release(struct inode *inode, struct file *filp)
4468 4469
4469 /* disable tracing ? */ 4470 /* disable tracing ? */
4470 if (trace_flags & TRACE_ITER_STOP_ON_FREE) 4471 if (trace_flags & TRACE_ITER_STOP_ON_FREE)
4471 tracing_off(); 4472 tracer_tracing_off(tr);
4472 /* resize the ring buffer to 0 */ 4473 /* resize the ring buffer to 0 */
4473 tracing_resize_ring_buffer(tr, 0, RING_BUFFER_ALL_CPUS); 4474 tracing_resize_ring_buffer(tr, 0, RING_BUFFER_ALL_CPUS);
4474 4475
@@ -4633,12 +4634,12 @@ static ssize_t tracing_clock_write(struct file *filp, const char __user *ubuf,
4633 * New clock may not be consistent with the previous clock. 4634 * New clock may not be consistent with the previous clock.
4634 * Reset the buffer so that it doesn't have incomparable timestamps. 4635 * Reset the buffer so that it doesn't have incomparable timestamps.
4635 */ 4636 */
4636 tracing_reset_online_cpus(&global_trace.trace_buffer); 4637 tracing_reset_online_cpus(&tr->trace_buffer);
4637 4638
4638#ifdef CONFIG_TRACER_MAX_TRACE 4639#ifdef CONFIG_TRACER_MAX_TRACE
4639 if (tr->flags & TRACE_ARRAY_FL_GLOBAL && tr->max_buffer.buffer) 4640 if (tr->flags & TRACE_ARRAY_FL_GLOBAL && tr->max_buffer.buffer)
4640 ring_buffer_set_clock(tr->max_buffer.buffer, trace_clocks[i].func); 4641 ring_buffer_set_clock(tr->max_buffer.buffer, trace_clocks[i].func);
4641 tracing_reset_online_cpus(&global_trace.max_buffer); 4642 tracing_reset_online_cpus(&tr->max_buffer);
4642#endif 4643#endif
4643 4644
4644 mutex_unlock(&trace_types_lock); 4645 mutex_unlock(&trace_types_lock);
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index 898f868833f2..29a7ebcfb426 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -409,33 +409,42 @@ static void put_system(struct ftrace_subsystem_dir *dir)
409 mutex_unlock(&event_mutex); 409 mutex_unlock(&event_mutex);
410} 410}
411 411
412/* 412static void remove_subsystem(struct ftrace_subsystem_dir *dir)
413 * Open and update trace_array ref count.
414 * Must have the current trace_array passed to it.
415 */
416static int tracing_open_generic_file(struct inode *inode, struct file *filp)
417{ 413{
418 struct ftrace_event_file *file = inode->i_private; 414 if (!dir)
419 struct trace_array *tr = file->tr; 415 return;
420 int ret;
421 416
422 if (trace_array_get(tr) < 0) 417 if (!--dir->nr_events) {
423 return -ENODEV; 418 debugfs_remove_recursive(dir->entry);
419 list_del(&dir->list);
420 __put_system_dir(dir);
421 }
422}
424 423
425 ret = tracing_open_generic(inode, filp); 424static void *event_file_data(struct file *filp)
426 if (ret < 0) 425{
427 trace_array_put(tr); 426 return ACCESS_ONCE(file_inode(filp)->i_private);
428 return ret;
429} 427}
430 428
431static int tracing_release_generic_file(struct inode *inode, struct file *filp) 429static void remove_event_file_dir(struct ftrace_event_file *file)
432{ 430{
433 struct ftrace_event_file *file = inode->i_private; 431 struct dentry *dir = file->dir;
434 struct trace_array *tr = file->tr; 432 struct dentry *child;
435 433
436 trace_array_put(tr); 434 if (dir) {
435 spin_lock(&dir->d_lock); /* probably unneeded */
436 list_for_each_entry(child, &dir->d_subdirs, d_u.d_child) {
437 if (child->d_inode) /* probably unneeded */
438 child->d_inode->i_private = NULL;
439 }
440 spin_unlock(&dir->d_lock);
437 441
438 return 0; 442 debugfs_remove_recursive(dir);
443 }
444
445 list_del(&file->list);
446 remove_subsystem(file->system);
447 kmem_cache_free(file_cachep, file);
439} 448}
440 449
441/* 450/*
@@ -679,15 +688,25 @@ static ssize_t
679event_enable_read(struct file *filp, char __user *ubuf, size_t cnt, 688event_enable_read(struct file *filp, char __user *ubuf, size_t cnt,
680 loff_t *ppos) 689 loff_t *ppos)
681{ 690{
682 struct ftrace_event_file *file = filp->private_data; 691 struct ftrace_event_file *file;
692 unsigned long flags;
683 char buf[4] = "0"; 693 char buf[4] = "0";
684 694
685 if (file->flags & FTRACE_EVENT_FL_ENABLED && 695 mutex_lock(&event_mutex);
686 !(file->flags & FTRACE_EVENT_FL_SOFT_DISABLED)) 696 file = event_file_data(filp);
697 if (likely(file))
698 flags = file->flags;
699 mutex_unlock(&event_mutex);
700
701 if (!file)
702 return -ENODEV;
703
704 if (flags & FTRACE_EVENT_FL_ENABLED &&
705 !(flags & FTRACE_EVENT_FL_SOFT_DISABLED))
687 strcpy(buf, "1"); 706 strcpy(buf, "1");
688 707
689 if (file->flags & FTRACE_EVENT_FL_SOFT_DISABLED || 708 if (flags & FTRACE_EVENT_FL_SOFT_DISABLED ||
690 file->flags & FTRACE_EVENT_FL_SOFT_MODE) 709 flags & FTRACE_EVENT_FL_SOFT_MODE)
691 strcat(buf, "*"); 710 strcat(buf, "*");
692 711
693 strcat(buf, "\n"); 712 strcat(buf, "\n");
@@ -699,13 +718,10 @@ static ssize_t
699event_enable_write(struct file *filp, const char __user *ubuf, size_t cnt, 718event_enable_write(struct file *filp, const char __user *ubuf, size_t cnt,
700 loff_t *ppos) 719 loff_t *ppos)
701{ 720{
702 struct ftrace_event_file *file = filp->private_data; 721 struct ftrace_event_file *file;
703 unsigned long val; 722 unsigned long val;
704 int ret; 723 int ret;
705 724
706 if (!file)
707 return -EINVAL;
708
709 ret = kstrtoul_from_user(ubuf, cnt, 10, &val); 725 ret = kstrtoul_from_user(ubuf, cnt, 10, &val);
710 if (ret) 726 if (ret)
711 return ret; 727 return ret;
@@ -717,8 +733,11 @@ event_enable_write(struct file *filp, const char __user *ubuf, size_t cnt,
717 switch (val) { 733 switch (val) {
718 case 0: 734 case 0:
719 case 1: 735 case 1:
736 ret = -ENODEV;
720 mutex_lock(&event_mutex); 737 mutex_lock(&event_mutex);
721 ret = ftrace_event_enable_disable(file, val); 738 file = event_file_data(filp);
739 if (likely(file))
740 ret = ftrace_event_enable_disable(file, val);
722 mutex_unlock(&event_mutex); 741 mutex_unlock(&event_mutex);
723 break; 742 break;
724 743
@@ -825,7 +844,7 @@ enum {
825 844
826static void *f_next(struct seq_file *m, void *v, loff_t *pos) 845static void *f_next(struct seq_file *m, void *v, loff_t *pos)
827{ 846{
828 struct ftrace_event_call *call = m->private; 847 struct ftrace_event_call *call = event_file_data(m->private);
829 struct list_head *common_head = &ftrace_common_fields; 848 struct list_head *common_head = &ftrace_common_fields;
830 struct list_head *head = trace_get_fields(call); 849 struct list_head *head = trace_get_fields(call);
831 struct list_head *node = v; 850 struct list_head *node = v;
@@ -857,7 +876,7 @@ static void *f_next(struct seq_file *m, void *v, loff_t *pos)
857 876
858static int f_show(struct seq_file *m, void *v) 877static int f_show(struct seq_file *m, void *v)
859{ 878{
860 struct ftrace_event_call *call = m->private; 879 struct ftrace_event_call *call = event_file_data(m->private);
861 struct ftrace_event_field *field; 880 struct ftrace_event_field *field;
862 const char *array_descriptor; 881 const char *array_descriptor;
863 882
@@ -910,6 +929,11 @@ static void *f_start(struct seq_file *m, loff_t *pos)
910 void *p = (void *)FORMAT_HEADER; 929 void *p = (void *)FORMAT_HEADER;
911 loff_t l = 0; 930 loff_t l = 0;
912 931
932 /* ->stop() is called even if ->start() fails */
933 mutex_lock(&event_mutex);
934 if (!event_file_data(m->private))
935 return ERR_PTR(-ENODEV);
936
913 while (l < *pos && p) 937 while (l < *pos && p)
914 p = f_next(m, p, &l); 938 p = f_next(m, p, &l);
915 939
@@ -918,6 +942,7 @@ static void *f_start(struct seq_file *m, loff_t *pos)
918 942
919static void f_stop(struct seq_file *m, void *p) 943static void f_stop(struct seq_file *m, void *p)
920{ 944{
945 mutex_unlock(&event_mutex);
921} 946}
922 947
923static const struct seq_operations trace_format_seq_ops = { 948static const struct seq_operations trace_format_seq_ops = {
@@ -929,7 +954,6 @@ static const struct seq_operations trace_format_seq_ops = {
929 954
930static int trace_format_open(struct inode *inode, struct file *file) 955static int trace_format_open(struct inode *inode, struct file *file)
931{ 956{
932 struct ftrace_event_call *call = inode->i_private;
933 struct seq_file *m; 957 struct seq_file *m;
934 int ret; 958 int ret;
935 959
@@ -938,7 +962,7 @@ static int trace_format_open(struct inode *inode, struct file *file)
938 return ret; 962 return ret;
939 963
940 m = file->private_data; 964 m = file->private_data;
941 m->private = call; 965 m->private = file;
942 966
943 return 0; 967 return 0;
944} 968}
@@ -946,14 +970,18 @@ static int trace_format_open(struct inode *inode, struct file *file)
946static ssize_t 970static ssize_t
947event_id_read(struct file *filp, char __user *ubuf, size_t cnt, loff_t *ppos) 971event_id_read(struct file *filp, char __user *ubuf, size_t cnt, loff_t *ppos)
948{ 972{
949 struct ftrace_event_call *call = filp->private_data; 973 int id = (long)event_file_data(filp);
950 char buf[32]; 974 char buf[32];
951 int len; 975 int len;
952 976
953 if (*ppos) 977 if (*ppos)
954 return 0; 978 return 0;
955 979
956 len = sprintf(buf, "%d\n", call->event.type); 980 if (unlikely(!id))
981 return -ENODEV;
982
983 len = sprintf(buf, "%d\n", id);
984
957 return simple_read_from_buffer(ubuf, cnt, ppos, buf, len); 985 return simple_read_from_buffer(ubuf, cnt, ppos, buf, len);
958} 986}
959 987
@@ -961,21 +989,28 @@ static ssize_t
961event_filter_read(struct file *filp, char __user *ubuf, size_t cnt, 989event_filter_read(struct file *filp, char __user *ubuf, size_t cnt,
962 loff_t *ppos) 990 loff_t *ppos)
963{ 991{
964 struct ftrace_event_call *call = filp->private_data; 992 struct ftrace_event_call *call;
965 struct trace_seq *s; 993 struct trace_seq *s;
966 int r; 994 int r = -ENODEV;
967 995
968 if (*ppos) 996 if (*ppos)
969 return 0; 997 return 0;
970 998
971 s = kmalloc(sizeof(*s), GFP_KERNEL); 999 s = kmalloc(sizeof(*s), GFP_KERNEL);
1000
972 if (!s) 1001 if (!s)
973 return -ENOMEM; 1002 return -ENOMEM;
974 1003
975 trace_seq_init(s); 1004 trace_seq_init(s);
976 1005
977 print_event_filter(call, s); 1006 mutex_lock(&event_mutex);
978 r = simple_read_from_buffer(ubuf, cnt, ppos, s->buffer, s->len); 1007 call = event_file_data(filp);
1008 if (call)
1009 print_event_filter(call, s);
1010 mutex_unlock(&event_mutex);
1011
1012 if (call)
1013 r = simple_read_from_buffer(ubuf, cnt, ppos, s->buffer, s->len);
979 1014
980 kfree(s); 1015 kfree(s);
981 1016
@@ -986,9 +1021,9 @@ static ssize_t
986event_filter_write(struct file *filp, const char __user *ubuf, size_t cnt, 1021event_filter_write(struct file *filp, const char __user *ubuf, size_t cnt,
987 loff_t *ppos) 1022 loff_t *ppos)
988{ 1023{
989 struct ftrace_event_call *call = filp->private_data; 1024 struct ftrace_event_call *call;
990 char *buf; 1025 char *buf;
991 int err; 1026 int err = -ENODEV;
992 1027
993 if (cnt >= PAGE_SIZE) 1028 if (cnt >= PAGE_SIZE)
994 return -EINVAL; 1029 return -EINVAL;
@@ -1003,7 +1038,12 @@ event_filter_write(struct file *filp, const char __user *ubuf, size_t cnt,
1003 } 1038 }
1004 buf[cnt] = '\0'; 1039 buf[cnt] = '\0';
1005 1040
1006 err = apply_event_filter(call, buf); 1041 mutex_lock(&event_mutex);
1042 call = event_file_data(filp);
1043 if (call)
1044 err = apply_event_filter(call, buf);
1045 mutex_unlock(&event_mutex);
1046
1007 free_page((unsigned long) buf); 1047 free_page((unsigned long) buf);
1008 if (err < 0) 1048 if (err < 0)
1009 return err; 1049 return err;
@@ -1225,10 +1265,9 @@ static const struct file_operations ftrace_set_event_fops = {
1225}; 1265};
1226 1266
1227static const struct file_operations ftrace_enable_fops = { 1267static const struct file_operations ftrace_enable_fops = {
1228 .open = tracing_open_generic_file, 1268 .open = tracing_open_generic,
1229 .read = event_enable_read, 1269 .read = event_enable_read,
1230 .write = event_enable_write, 1270 .write = event_enable_write,
1231 .release = tracing_release_generic_file,
1232 .llseek = default_llseek, 1271 .llseek = default_llseek,
1233}; 1272};
1234 1273
@@ -1240,7 +1279,6 @@ static const struct file_operations ftrace_event_format_fops = {
1240}; 1279};
1241 1280
1242static const struct file_operations ftrace_event_id_fops = { 1281static const struct file_operations ftrace_event_id_fops = {
1243 .open = tracing_open_generic,
1244 .read = event_id_read, 1282 .read = event_id_read,
1245 .llseek = default_llseek, 1283 .llseek = default_llseek,
1246}; 1284};
@@ -1488,8 +1526,8 @@ event_create_dir(struct dentry *parent,
1488 1526
1489#ifdef CONFIG_PERF_EVENTS 1527#ifdef CONFIG_PERF_EVENTS
1490 if (call->event.type && call->class->reg) 1528 if (call->event.type && call->class->reg)
1491 trace_create_file("id", 0444, file->dir, call, 1529 trace_create_file("id", 0444, file->dir,
1492 id); 1530 (void *)(long)call->event.type, id);
1493#endif 1531#endif
1494 1532
1495 /* 1533 /*
@@ -1514,33 +1552,16 @@ event_create_dir(struct dentry *parent,
1514 return 0; 1552 return 0;
1515} 1553}
1516 1554
1517static void remove_subsystem(struct ftrace_subsystem_dir *dir)
1518{
1519 if (!dir)
1520 return;
1521
1522 if (!--dir->nr_events) {
1523 debugfs_remove_recursive(dir->entry);
1524 list_del(&dir->list);
1525 __put_system_dir(dir);
1526 }
1527}
1528
1529static void remove_event_from_tracers(struct ftrace_event_call *call) 1555static void remove_event_from_tracers(struct ftrace_event_call *call)
1530{ 1556{
1531 struct ftrace_event_file *file; 1557 struct ftrace_event_file *file;
1532 struct trace_array *tr; 1558 struct trace_array *tr;
1533 1559
1534 do_for_each_event_file_safe(tr, file) { 1560 do_for_each_event_file_safe(tr, file) {
1535
1536 if (file->event_call != call) 1561 if (file->event_call != call)
1537 continue; 1562 continue;
1538 1563
1539 list_del(&file->list); 1564 remove_event_file_dir(file);
1540 debugfs_remove_recursive(file->dir);
1541 remove_subsystem(file->system);
1542 kmem_cache_free(file_cachep, file);
1543
1544 /* 1565 /*
1545 * The do_for_each_event_file_safe() is 1566 * The do_for_each_event_file_safe() is
1546 * a double loop. After finding the call for this 1567 * a double loop. After finding the call for this
@@ -1692,16 +1713,53 @@ static void __trace_remove_event_call(struct ftrace_event_call *call)
1692 destroy_preds(call); 1713 destroy_preds(call);
1693} 1714}
1694 1715
1716static int probe_remove_event_call(struct ftrace_event_call *call)
1717{
1718 struct trace_array *tr;
1719 struct ftrace_event_file *file;
1720
1721#ifdef CONFIG_PERF_EVENTS
1722 if (call->perf_refcount)
1723 return -EBUSY;
1724#endif
1725 do_for_each_event_file(tr, file) {
1726 if (file->event_call != call)
1727 continue;
1728 /*
1729 * We can't rely on ftrace_event_enable_disable(enable => 0)
1730 * we are going to do, FTRACE_EVENT_FL_SOFT_MODE can suppress
1731 * TRACE_REG_UNREGISTER.
1732 */
1733 if (file->flags & FTRACE_EVENT_FL_ENABLED)
1734 return -EBUSY;
1735 /*
1736 * The do_for_each_event_file_safe() is
1737 * a double loop. After finding the call for this
1738 * trace_array, we use break to jump to the next
1739 * trace_array.
1740 */
1741 break;
1742 } while_for_each_event_file();
1743
1744 __trace_remove_event_call(call);
1745
1746 return 0;
1747}
1748
1695/* Remove an event_call */ 1749/* Remove an event_call */
1696void trace_remove_event_call(struct ftrace_event_call *call) 1750int trace_remove_event_call(struct ftrace_event_call *call)
1697{ 1751{
1752 int ret;
1753
1698 mutex_lock(&trace_types_lock); 1754 mutex_lock(&trace_types_lock);
1699 mutex_lock(&event_mutex); 1755 mutex_lock(&event_mutex);
1700 down_write(&trace_event_sem); 1756 down_write(&trace_event_sem);
1701 __trace_remove_event_call(call); 1757 ret = probe_remove_event_call(call);
1702 up_write(&trace_event_sem); 1758 up_write(&trace_event_sem);
1703 mutex_unlock(&event_mutex); 1759 mutex_unlock(&event_mutex);
1704 mutex_unlock(&trace_types_lock); 1760 mutex_unlock(&trace_types_lock);
1761
1762 return ret;
1705} 1763}
1706 1764
1707#define for_each_event(event, start, end) \ 1765#define for_each_event(event, start, end) \
@@ -2270,12 +2328,8 @@ __trace_remove_event_dirs(struct trace_array *tr)
2270{ 2328{
2271 struct ftrace_event_file *file, *next; 2329 struct ftrace_event_file *file, *next;
2272 2330
2273 list_for_each_entry_safe(file, next, &tr->events, list) { 2331 list_for_each_entry_safe(file, next, &tr->events, list)
2274 list_del(&file->list); 2332 remove_event_file_dir(file);
2275 debugfs_remove_recursive(file->dir);
2276 remove_subsystem(file->system);
2277 kmem_cache_free(file_cachep, file);
2278 }
2279} 2333}
2280 2334
2281static void 2335static void
diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c
index 0c7b75a8acc8..97daa8cf958d 100644
--- a/kernel/trace/trace_events_filter.c
+++ b/kernel/trace/trace_events_filter.c
@@ -637,17 +637,15 @@ static void append_filter_err(struct filter_parse_state *ps,
637 free_page((unsigned long) buf); 637 free_page((unsigned long) buf);
638} 638}
639 639
640/* caller must hold event_mutex */
640void print_event_filter(struct ftrace_event_call *call, struct trace_seq *s) 641void print_event_filter(struct ftrace_event_call *call, struct trace_seq *s)
641{ 642{
642 struct event_filter *filter; 643 struct event_filter *filter = call->filter;
643 644
644 mutex_lock(&event_mutex);
645 filter = call->filter;
646 if (filter && filter->filter_string) 645 if (filter && filter->filter_string)
647 trace_seq_printf(s, "%s\n", filter->filter_string); 646 trace_seq_printf(s, "%s\n", filter->filter_string);
648 else 647 else
649 trace_seq_puts(s, "none\n"); 648 trace_seq_puts(s, "none\n");
650 mutex_unlock(&event_mutex);
651} 649}
652 650
653void print_subsystem_event_filter(struct event_subsystem *system, 651void print_subsystem_event_filter(struct event_subsystem *system,
@@ -1841,23 +1839,22 @@ static int create_system_filter(struct event_subsystem *system,
1841 return err; 1839 return err;
1842} 1840}
1843 1841
1842/* caller must hold event_mutex */
1844int apply_event_filter(struct ftrace_event_call *call, char *filter_string) 1843int apply_event_filter(struct ftrace_event_call *call, char *filter_string)
1845{ 1844{
1846 struct event_filter *filter; 1845 struct event_filter *filter;
1847 int err = 0; 1846 int err;
1848
1849 mutex_lock(&event_mutex);
1850 1847
1851 if (!strcmp(strstrip(filter_string), "0")) { 1848 if (!strcmp(strstrip(filter_string), "0")) {
1852 filter_disable(call); 1849 filter_disable(call);
1853 filter = call->filter; 1850 filter = call->filter;
1854 if (!filter) 1851 if (!filter)
1855 goto out_unlock; 1852 return 0;
1856 RCU_INIT_POINTER(call->filter, NULL); 1853 RCU_INIT_POINTER(call->filter, NULL);
1857 /* Make sure the filter is not being used */ 1854 /* Make sure the filter is not being used */
1858 synchronize_sched(); 1855 synchronize_sched();
1859 __free_filter(filter); 1856 __free_filter(filter);
1860 goto out_unlock; 1857 return 0;
1861 } 1858 }
1862 1859
1863 err = create_filter(call, filter_string, true, &filter); 1860 err = create_filter(call, filter_string, true, &filter);
@@ -1884,8 +1881,6 @@ int apply_event_filter(struct ftrace_event_call *call, char *filter_string)
1884 __free_filter(tmp); 1881 __free_filter(tmp);
1885 } 1882 }
1886 } 1883 }
1887out_unlock:
1888 mutex_unlock(&event_mutex);
1889 1884
1890 return err; 1885 return err;
1891} 1886}
diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
index 3811487e7a7a..243f6834d026 100644
--- a/kernel/trace/trace_kprobe.c
+++ b/kernel/trace/trace_kprobe.c
@@ -95,7 +95,7 @@ static __kprobes bool trace_probe_is_on_module(struct trace_probe *tp)
95} 95}
96 96
97static int register_probe_event(struct trace_probe *tp); 97static int register_probe_event(struct trace_probe *tp);
98static void unregister_probe_event(struct trace_probe *tp); 98static int unregister_probe_event(struct trace_probe *tp);
99 99
100static DEFINE_MUTEX(probe_lock); 100static DEFINE_MUTEX(probe_lock);
101static LIST_HEAD(probe_list); 101static LIST_HEAD(probe_list);
@@ -351,9 +351,12 @@ static int unregister_trace_probe(struct trace_probe *tp)
351 if (trace_probe_is_enabled(tp)) 351 if (trace_probe_is_enabled(tp))
352 return -EBUSY; 352 return -EBUSY;
353 353
354 /* Will fail if probe is being used by ftrace or perf */
355 if (unregister_probe_event(tp))
356 return -EBUSY;
357
354 __unregister_trace_probe(tp); 358 __unregister_trace_probe(tp);
355 list_del(&tp->list); 359 list_del(&tp->list);
356 unregister_probe_event(tp);
357 360
358 return 0; 361 return 0;
359} 362}
@@ -632,7 +635,9 @@ static int release_all_trace_probes(void)
632 /* TODO: Use batch unregistration */ 635 /* TODO: Use batch unregistration */
633 while (!list_empty(&probe_list)) { 636 while (!list_empty(&probe_list)) {
634 tp = list_entry(probe_list.next, struct trace_probe, list); 637 tp = list_entry(probe_list.next, struct trace_probe, list);
635 unregister_trace_probe(tp); 638 ret = unregister_trace_probe(tp);
639 if (ret)
640 goto end;
636 free_trace_probe(tp); 641 free_trace_probe(tp);
637 } 642 }
638 643
@@ -1247,11 +1252,15 @@ static int register_probe_event(struct trace_probe *tp)
1247 return ret; 1252 return ret;
1248} 1253}
1249 1254
1250static void unregister_probe_event(struct trace_probe *tp) 1255static int unregister_probe_event(struct trace_probe *tp)
1251{ 1256{
1257 int ret;
1258
1252 /* tp->event is unregistered in trace_remove_event_call() */ 1259 /* tp->event is unregistered in trace_remove_event_call() */
1253 trace_remove_event_call(&tp->call); 1260 ret = trace_remove_event_call(&tp->call);
1254 kfree(tp->call.print_fmt); 1261 if (!ret)
1262 kfree(tp->call.print_fmt);
1263 return ret;
1255} 1264}
1256 1265
1257/* Make a debugfs interface for controlling probe points */ 1266/* Make a debugfs interface for controlling probe points */
diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c
index a23d2d71188e..272261b5f94f 100644
--- a/kernel/trace/trace_uprobe.c
+++ b/kernel/trace/trace_uprobe.c
@@ -70,7 +70,7 @@ struct trace_uprobe {
70 (sizeof(struct probe_arg) * (n))) 70 (sizeof(struct probe_arg) * (n)))
71 71
72static int register_uprobe_event(struct trace_uprobe *tu); 72static int register_uprobe_event(struct trace_uprobe *tu);
73static void unregister_uprobe_event(struct trace_uprobe *tu); 73static int unregister_uprobe_event(struct trace_uprobe *tu);
74 74
75static DEFINE_MUTEX(uprobe_lock); 75static DEFINE_MUTEX(uprobe_lock);
76static LIST_HEAD(uprobe_list); 76static LIST_HEAD(uprobe_list);
@@ -164,11 +164,17 @@ static struct trace_uprobe *find_probe_event(const char *event, const char *grou
164} 164}
165 165
166/* Unregister a trace_uprobe and probe_event: call with locking uprobe_lock */ 166/* Unregister a trace_uprobe and probe_event: call with locking uprobe_lock */
167static void unregister_trace_uprobe(struct trace_uprobe *tu) 167static int unregister_trace_uprobe(struct trace_uprobe *tu)
168{ 168{
169 int ret;
170
171 ret = unregister_uprobe_event(tu);
172 if (ret)
173 return ret;
174
169 list_del(&tu->list); 175 list_del(&tu->list);
170 unregister_uprobe_event(tu);
171 free_trace_uprobe(tu); 176 free_trace_uprobe(tu);
177 return 0;
172} 178}
173 179
174/* Register a trace_uprobe and probe_event */ 180/* Register a trace_uprobe and probe_event */
@@ -181,9 +187,12 @@ static int register_trace_uprobe(struct trace_uprobe *tu)
181 187
182 /* register as an event */ 188 /* register as an event */
183 old_tp = find_probe_event(tu->call.name, tu->call.class->system); 189 old_tp = find_probe_event(tu->call.name, tu->call.class->system);
184 if (old_tp) 190 if (old_tp) {
185 /* delete old event */ 191 /* delete old event */
186 unregister_trace_uprobe(old_tp); 192 ret = unregister_trace_uprobe(old_tp);
193 if (ret)
194 goto end;
195 }
187 196
188 ret = register_uprobe_event(tu); 197 ret = register_uprobe_event(tu);
189 if (ret) { 198 if (ret) {
@@ -256,6 +265,8 @@ static int create_trace_uprobe(int argc, char **argv)
256 group = UPROBE_EVENT_SYSTEM; 265 group = UPROBE_EVENT_SYSTEM;
257 266
258 if (is_delete) { 267 if (is_delete) {
268 int ret;
269
259 if (!event) { 270 if (!event) {
260 pr_info("Delete command needs an event name.\n"); 271 pr_info("Delete command needs an event name.\n");
261 return -EINVAL; 272 return -EINVAL;
@@ -269,9 +280,9 @@ static int create_trace_uprobe(int argc, char **argv)
269 return -ENOENT; 280 return -ENOENT;
270 } 281 }
271 /* delete an event */ 282 /* delete an event */
272 unregister_trace_uprobe(tu); 283 ret = unregister_trace_uprobe(tu);
273 mutex_unlock(&uprobe_lock); 284 mutex_unlock(&uprobe_lock);
274 return 0; 285 return ret;
275 } 286 }
276 287
277 if (argc < 2) { 288 if (argc < 2) {
@@ -408,16 +419,20 @@ fail_address_parse:
408 return ret; 419 return ret;
409} 420}
410 421
411static void cleanup_all_probes(void) 422static int cleanup_all_probes(void)
412{ 423{
413 struct trace_uprobe *tu; 424 struct trace_uprobe *tu;
425 int ret = 0;
414 426
415 mutex_lock(&uprobe_lock); 427 mutex_lock(&uprobe_lock);
416 while (!list_empty(&uprobe_list)) { 428 while (!list_empty(&uprobe_list)) {
417 tu = list_entry(uprobe_list.next, struct trace_uprobe, list); 429 tu = list_entry(uprobe_list.next, struct trace_uprobe, list);
418 unregister_trace_uprobe(tu); 430 ret = unregister_trace_uprobe(tu);
431 if (ret)
432 break;
419 } 433 }
420 mutex_unlock(&uprobe_lock); 434 mutex_unlock(&uprobe_lock);
435 return ret;
421} 436}
422 437
423/* Probes listing interfaces */ 438/* Probes listing interfaces */
@@ -462,8 +477,13 @@ static const struct seq_operations probes_seq_op = {
462 477
463static int probes_open(struct inode *inode, struct file *file) 478static int probes_open(struct inode *inode, struct file *file)
464{ 479{
465 if ((file->f_mode & FMODE_WRITE) && (file->f_flags & O_TRUNC)) 480 int ret;
466 cleanup_all_probes(); 481
482 if ((file->f_mode & FMODE_WRITE) && (file->f_flags & O_TRUNC)) {
483 ret = cleanup_all_probes();
484 if (ret)
485 return ret;
486 }
467 487
468 return seq_open(file, &probes_seq_op); 488 return seq_open(file, &probes_seq_op);
469} 489}
@@ -968,12 +988,17 @@ static int register_uprobe_event(struct trace_uprobe *tu)
968 return ret; 988 return ret;
969} 989}
970 990
971static void unregister_uprobe_event(struct trace_uprobe *tu) 991static int unregister_uprobe_event(struct trace_uprobe *tu)
972{ 992{
993 int ret;
994
973 /* tu->event is unregistered in trace_remove_event_call() */ 995 /* tu->event is unregistered in trace_remove_event_call() */
974 trace_remove_event_call(&tu->call); 996 ret = trace_remove_event_call(&tu->call);
997 if (ret)
998 return ret;
975 kfree(tu->call.print_fmt); 999 kfree(tu->call.print_fmt);
976 tu->call.print_fmt = NULL; 1000 tu->call.print_fmt = NULL;
1001 return 0;
977} 1002}
978 1003
979/* Make a trace interface for controling probe points */ 1004/* Make a trace interface for controling probe points */
diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
index d8c30db06c5b..9064b919a406 100644
--- a/kernel/user_namespace.c
+++ b/kernel/user_namespace.c
@@ -62,6 +62,9 @@ int create_user_ns(struct cred *new)
62 kgid_t group = new->egid; 62 kgid_t group = new->egid;
63 int ret; 63 int ret;
64 64
65 if (parent_ns->level > 32)
66 return -EUSERS;
67
65 /* 68 /*
66 * Verify that we can not violate the policy of which files 69 * Verify that we can not violate the policy of which files
67 * may be accessed that is specified by the root directory, 70 * may be accessed that is specified by the root directory,
@@ -92,6 +95,7 @@ int create_user_ns(struct cred *new)
92 atomic_set(&ns->count, 1); 95 atomic_set(&ns->count, 1);
93 /* Leave the new->user_ns reference with the new user namespace. */ 96 /* Leave the new->user_ns reference with the new user namespace. */
94 ns->parent = parent_ns; 97 ns->parent = parent_ns;
98 ns->level = parent_ns->level + 1;
95 ns->owner = owner; 99 ns->owner = owner;
96 ns->group = group; 100 ns->group = group;
97 101
@@ -105,16 +109,21 @@ int create_user_ns(struct cred *new)
105int unshare_userns(unsigned long unshare_flags, struct cred **new_cred) 109int unshare_userns(unsigned long unshare_flags, struct cred **new_cred)
106{ 110{
107 struct cred *cred; 111 struct cred *cred;
112 int err = -ENOMEM;
108 113
109 if (!(unshare_flags & CLONE_NEWUSER)) 114 if (!(unshare_flags & CLONE_NEWUSER))
110 return 0; 115 return 0;
111 116
112 cred = prepare_creds(); 117 cred = prepare_creds();
113 if (!cred) 118 if (cred) {
114 return -ENOMEM; 119 err = create_user_ns(cred);
120 if (err)
121 put_cred(cred);
122 else
123 *new_cred = cred;
124 }
115 125
116 *new_cred = cred; 126 return err;
117 return create_user_ns(cred);
118} 127}
119 128
120void free_user_ns(struct user_namespace *ns) 129void free_user_ns(struct user_namespace *ns)
diff --git a/kernel/wait.c b/kernel/wait.c
index dec68bd4e9d8..d550920e040c 100644
--- a/kernel/wait.c
+++ b/kernel/wait.c
@@ -363,8 +363,7 @@ EXPORT_SYMBOL(out_of_line_wait_on_atomic_t);
363 363
364/** 364/**
365 * wake_up_atomic_t - Wake up a waiter on a atomic_t 365 * wake_up_atomic_t - Wake up a waiter on a atomic_t
366 * @word: The word being waited on, a kernel virtual address 366 * @p: The atomic_t being waited on, a kernel virtual address
367 * @bit: The bit of the word being waited on
368 * 367 *
369 * Wake up anyone waiting for the atomic_t to go to zero. 368 * Wake up anyone waiting for the atomic_t to go to zero.
370 * 369 *
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 0b72e816b8d0..7f5d4be22034 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -2817,6 +2817,19 @@ already_gone:
2817 return false; 2817 return false;
2818} 2818}
2819 2819
2820static bool __flush_work(struct work_struct *work)
2821{
2822 struct wq_barrier barr;
2823
2824 if (start_flush_work(work, &barr)) {
2825 wait_for_completion(&barr.done);
2826 destroy_work_on_stack(&barr.work);
2827 return true;
2828 } else {
2829 return false;
2830 }
2831}
2832
2820/** 2833/**
2821 * flush_work - wait for a work to finish executing the last queueing instance 2834 * flush_work - wait for a work to finish executing the last queueing instance
2822 * @work: the work to flush 2835 * @work: the work to flush
@@ -2830,18 +2843,10 @@ already_gone:
2830 */ 2843 */
2831bool flush_work(struct work_struct *work) 2844bool flush_work(struct work_struct *work)
2832{ 2845{
2833 struct wq_barrier barr;
2834
2835 lock_map_acquire(&work->lockdep_map); 2846 lock_map_acquire(&work->lockdep_map);
2836 lock_map_release(&work->lockdep_map); 2847 lock_map_release(&work->lockdep_map);
2837 2848
2838 if (start_flush_work(work, &barr)) { 2849 return __flush_work(work);
2839 wait_for_completion(&barr.done);
2840 destroy_work_on_stack(&barr.work);
2841 return true;
2842 } else {
2843 return false;
2844 }
2845} 2850}
2846EXPORT_SYMBOL_GPL(flush_work); 2851EXPORT_SYMBOL_GPL(flush_work);
2847 2852
@@ -3411,6 +3416,12 @@ static void copy_workqueue_attrs(struct workqueue_attrs *to,
3411{ 3416{
3412 to->nice = from->nice; 3417 to->nice = from->nice;
3413 cpumask_copy(to->cpumask, from->cpumask); 3418 cpumask_copy(to->cpumask, from->cpumask);
3419 /*
3420 * Unlike hash and equality test, this function doesn't ignore
3421 * ->no_numa as it is used for both pool and wq attrs. Instead,
3422 * get_unbound_pool() explicitly clears ->no_numa after copying.
3423 */
3424 to->no_numa = from->no_numa;
3414} 3425}
3415 3426
3416/* hash value of the content of @attr */ 3427/* hash value of the content of @attr */
@@ -3578,6 +3589,12 @@ static struct worker_pool *get_unbound_pool(const struct workqueue_attrs *attrs)
3578 lockdep_set_subclass(&pool->lock, 1); /* see put_pwq() */ 3589 lockdep_set_subclass(&pool->lock, 1); /* see put_pwq() */
3579 copy_workqueue_attrs(pool->attrs, attrs); 3590 copy_workqueue_attrs(pool->attrs, attrs);
3580 3591
3592 /*
3593 * no_numa isn't a worker_pool attribute, always clear it. See
3594 * 'struct workqueue_attrs' comments for detail.
3595 */
3596 pool->attrs->no_numa = false;
3597
3581 /* if cpumask is contained inside a NUMA node, we belong to that node */ 3598 /* if cpumask is contained inside a NUMA node, we belong to that node */
3582 if (wq_numa_enabled) { 3599 if (wq_numa_enabled) {
3583 for_each_node(node) { 3600 for_each_node(node) {
@@ -4756,7 +4773,14 @@ long work_on_cpu(int cpu, long (*fn)(void *), void *arg)
4756 4773
4757 INIT_WORK_ONSTACK(&wfc.work, work_for_cpu_fn); 4774 INIT_WORK_ONSTACK(&wfc.work, work_for_cpu_fn);
4758 schedule_work_on(cpu, &wfc.work); 4775 schedule_work_on(cpu, &wfc.work);
4759 flush_work(&wfc.work); 4776
4777 /*
4778 * The work item is on-stack and can't lead to deadlock through
4779 * flushing. Use __flush_work() to avoid spurious lockdep warnings
4780 * when work_on_cpu()s are nested.
4781 */
4782 __flush_work(&wfc.work);
4783
4760 return wfc.ret; 4784 return wfc.ret;
4761} 4785}
4762EXPORT_SYMBOL_GPL(work_on_cpu); 4786EXPORT_SYMBOL_GPL(work_on_cpu);
diff --git a/lib/earlycpio.c b/lib/earlycpio.c
index 7aa7ce250c94..3eb3e4722b8e 100644
--- a/lib/earlycpio.c
+++ b/lib/earlycpio.c
@@ -49,22 +49,23 @@ enum cpio_fields {
49 49
50/** 50/**
51 * cpio_data find_cpio_data - Search for files in an uncompressed cpio 51 * cpio_data find_cpio_data - Search for files in an uncompressed cpio
52 * @path: The directory to search for, including a slash at the end 52 * @path: The directory to search for, including a slash at the end
53 * @data: Pointer to the the cpio archive or a header inside 53 * @data: Pointer to the the cpio archive or a header inside
54 * @len: Remaining length of the cpio based on data pointer 54 * @len: Remaining length of the cpio based on data pointer
55 * @offset: When a matching file is found, this is the offset to the 55 * @nextoff: When a matching file is found, this is the offset from the
56 * beginning of the cpio. It can be used to iterate through 56 * beginning of the cpio to the beginning of the next file, not the
57 * the cpio to find all files inside of a directory path 57 * matching file itself. It can be used to iterate through the cpio
58 * to find all files inside of a directory path.
58 * 59 *
59 * @return: struct cpio_data containing the address, length and 60 * @return: struct cpio_data containing the address, length and
60 * filename (with the directory path cut off) of the found file. 61 * filename (with the directory path cut off) of the found file.
61 * If you search for a filename and not for files in a directory, 62 * If you search for a filename and not for files in a directory,
62 * pass the absolute path of the filename in the cpio and make sure 63 * pass the absolute path of the filename in the cpio and make sure
63 * the match returned an empty filename string. 64 * the match returned an empty filename string.
64 */ 65 */
65 66
66struct cpio_data find_cpio_data(const char *path, void *data, 67struct cpio_data find_cpio_data(const char *path, void *data,
67 size_t len, long *offset) 68 size_t len, long *nextoff)
68{ 69{
69 const size_t cpio_header_len = 8*C_NFIELDS - 2; 70 const size_t cpio_header_len = 8*C_NFIELDS - 2;
70 struct cpio_data cd = { NULL, 0, "" }; 71 struct cpio_data cd = { NULL, 0, "" };
@@ -124,7 +125,7 @@ struct cpio_data find_cpio_data(const char *path, void *data,
124 if ((ch[C_MODE] & 0170000) == 0100000 && 125 if ((ch[C_MODE] & 0170000) == 0100000 &&
125 ch[C_NAMESIZE] >= mypathsize && 126 ch[C_NAMESIZE] >= mypathsize &&
126 !memcmp(p, path, mypathsize)) { 127 !memcmp(p, path, mypathsize)) {
127 *offset = (long)nptr - (long)data; 128 *nextoff = (long)nptr - (long)data;
128 if (ch[C_NAMESIZE] - mypathsize >= MAX_CPIO_FILE_NAME) { 129 if (ch[C_NAMESIZE] - mypathsize >= MAX_CPIO_FILE_NAME) {
129 pr_warn( 130 pr_warn(
130 "File %s exceeding MAX_CPIO_FILE_NAME [%d]\n", 131 "File %s exceeding MAX_CPIO_FILE_NAME [%d]\n",
diff --git a/lib/lz4/lz4_compress.c b/lib/lz4/lz4_compress.c
index fd94058bd7f9..28321d8f75ef 100644
--- a/lib/lz4/lz4_compress.c
+++ b/lib/lz4/lz4_compress.c
@@ -437,7 +437,7 @@ int lz4_compress(const unsigned char *src, size_t src_len,
437exit: 437exit:
438 return ret; 438 return ret;
439} 439}
440EXPORT_SYMBOL_GPL(lz4_compress); 440EXPORT_SYMBOL(lz4_compress);
441 441
442MODULE_LICENSE("GPL"); 442MODULE_LICENSE("Dual BSD/GPL");
443MODULE_DESCRIPTION("LZ4 compressor"); 443MODULE_DESCRIPTION("LZ4 compressor");
diff --git a/lib/lz4/lz4_decompress.c b/lib/lz4/lz4_decompress.c
index d3414eae73a1..411be80ddb46 100644
--- a/lib/lz4/lz4_decompress.c
+++ b/lib/lz4/lz4_decompress.c
@@ -299,7 +299,7 @@ exit_0:
299 return ret; 299 return ret;
300} 300}
301#ifndef STATIC 301#ifndef STATIC
302EXPORT_SYMBOL_GPL(lz4_decompress); 302EXPORT_SYMBOL(lz4_decompress);
303#endif 303#endif
304 304
305int lz4_decompress_unknownoutputsize(const char *src, size_t src_len, 305int lz4_decompress_unknownoutputsize(const char *src, size_t src_len,
@@ -319,8 +319,8 @@ exit_0:
319 return ret; 319 return ret;
320} 320}
321#ifndef STATIC 321#ifndef STATIC
322EXPORT_SYMBOL_GPL(lz4_decompress_unknownoutputsize); 322EXPORT_SYMBOL(lz4_decompress_unknownoutputsize);
323 323
324MODULE_LICENSE("GPL"); 324MODULE_LICENSE("Dual BSD/GPL");
325MODULE_DESCRIPTION("LZ4 Decompressor"); 325MODULE_DESCRIPTION("LZ4 Decompressor");
326#endif 326#endif
diff --git a/lib/lz4/lz4hc_compress.c b/lib/lz4/lz4hc_compress.c
index eb1a74f5e368..f344f76b6559 100644
--- a/lib/lz4/lz4hc_compress.c
+++ b/lib/lz4/lz4hc_compress.c
@@ -533,7 +533,7 @@ int lz4hc_compress(const unsigned char *src, size_t src_len,
533exit: 533exit:
534 return ret; 534 return ret;
535} 535}
536EXPORT_SYMBOL_GPL(lz4hc_compress); 536EXPORT_SYMBOL(lz4hc_compress);
537 537
538MODULE_LICENSE("GPL"); 538MODULE_LICENSE("Dual BSD/GPL");
539MODULE_DESCRIPTION("LZ4HC compressor"); 539MODULE_DESCRIPTION("LZ4HC compressor");
diff --git a/mm/fremap.c b/mm/fremap.c
index 87da3590c61e..5bff08147768 100644
--- a/mm/fremap.c
+++ b/mm/fremap.c
@@ -57,17 +57,22 @@ static int install_file_pte(struct mm_struct *mm, struct vm_area_struct *vma,
57 unsigned long addr, unsigned long pgoff, pgprot_t prot) 57 unsigned long addr, unsigned long pgoff, pgprot_t prot)
58{ 58{
59 int err = -ENOMEM; 59 int err = -ENOMEM;
60 pte_t *pte; 60 pte_t *pte, ptfile;
61 spinlock_t *ptl; 61 spinlock_t *ptl;
62 62
63 pte = get_locked_pte(mm, addr, &ptl); 63 pte = get_locked_pte(mm, addr, &ptl);
64 if (!pte) 64 if (!pte)
65 goto out; 65 goto out;
66 66
67 if (!pte_none(*pte)) 67 ptfile = pgoff_to_pte(pgoff);
68
69 if (!pte_none(*pte)) {
70 if (pte_present(*pte) && pte_soft_dirty(*pte))
71 pte_file_mksoft_dirty(ptfile);
68 zap_pte(mm, vma, addr, pte); 72 zap_pte(mm, vma, addr, pte);
73 }
69 74
70 set_pte_at(mm, addr, pte, pgoff_to_pte(pgoff)); 75 set_pte_at(mm, addr, pte, ptfile);
71 /* 76 /*
72 * We don't need to run update_mmu_cache() here because the "file pte" 77 * We don't need to run update_mmu_cache() here because the "file pte"
73 * being installed by install_file_pte() is not a real pte - it's a 78 * being installed by install_file_pte() is not a real pte - it's a
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 83aff0a4d093..b60f33080a28 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -2490,7 +2490,7 @@ void unmap_hugepage_range(struct vm_area_struct *vma, unsigned long start,
2490 2490
2491 mm = vma->vm_mm; 2491 mm = vma->vm_mm;
2492 2492
2493 tlb_gather_mmu(&tlb, mm, 0); 2493 tlb_gather_mmu(&tlb, mm, start, end);
2494 __unmap_hugepage_range(&tlb, vma, start, end, ref_page); 2494 __unmap_hugepage_range(&tlb, vma, start, end, ref_page);
2495 tlb_finish_mmu(&tlb, start, end); 2495 tlb_finish_mmu(&tlb, start, end);
2496} 2496}
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index c290a1cf3862..0878ff7c26a9 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -3195,11 +3195,11 @@ int memcg_register_cache(struct mem_cgroup *memcg, struct kmem_cache *s,
3195 if (!s->memcg_params) 3195 if (!s->memcg_params)
3196 return -ENOMEM; 3196 return -ENOMEM;
3197 3197
3198 INIT_WORK(&s->memcg_params->destroy,
3199 kmem_cache_destroy_work_func);
3200 if (memcg) { 3198 if (memcg) {
3201 s->memcg_params->memcg = memcg; 3199 s->memcg_params->memcg = memcg;
3202 s->memcg_params->root_cache = root_cache; 3200 s->memcg_params->root_cache = root_cache;
3201 INIT_WORK(&s->memcg_params->destroy,
3202 kmem_cache_destroy_work_func);
3203 } else 3203 } else
3204 s->memcg_params->is_root_cache = true; 3204 s->memcg_params->is_root_cache = true;
3205 3205
@@ -6969,7 +6969,6 @@ struct cgroup_subsys mem_cgroup_subsys = {
6969#ifdef CONFIG_MEMCG_SWAP 6969#ifdef CONFIG_MEMCG_SWAP
6970static int __init enable_swap_account(char *s) 6970static int __init enable_swap_account(char *s)
6971{ 6971{
6972 /* consider enabled if no parameter or 1 is given */
6973 if (!strcmp(s, "1")) 6972 if (!strcmp(s, "1"))
6974 really_do_swap_account = 1; 6973 really_do_swap_account = 1;
6975 else if (!strcmp(s, "0")) 6974 else if (!strcmp(s, "0"))
diff --git a/mm/memory.c b/mm/memory.c
index 1ce2e2a734fc..af84bc0ec17c 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -209,14 +209,15 @@ static int tlb_next_batch(struct mmu_gather *tlb)
209 * tear-down from @mm. The @fullmm argument is used when @mm is without 209 * tear-down from @mm. The @fullmm argument is used when @mm is without
210 * users and we're going to destroy the full address space (exit/execve). 210 * users and we're going to destroy the full address space (exit/execve).
211 */ 211 */
212void tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, bool fullmm) 212void tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, unsigned long start, unsigned long end)
213{ 213{
214 tlb->mm = mm; 214 tlb->mm = mm;
215 215
216 tlb->fullmm = fullmm; 216 /* Is it from 0 to ~0? */
217 tlb->fullmm = !(start | (end+1));
217 tlb->need_flush_all = 0; 218 tlb->need_flush_all = 0;
218 tlb->start = -1UL; 219 tlb->start = start;
219 tlb->end = 0; 220 tlb->end = end;
220 tlb->need_flush = 0; 221 tlb->need_flush = 0;
221 tlb->local.next = NULL; 222 tlb->local.next = NULL;
222 tlb->local.nr = 0; 223 tlb->local.nr = 0;
@@ -256,8 +257,6 @@ void tlb_finish_mmu(struct mmu_gather *tlb, unsigned long start, unsigned long e
256{ 257{
257 struct mmu_gather_batch *batch, *next; 258 struct mmu_gather_batch *batch, *next;
258 259
259 tlb->start = start;
260 tlb->end = end;
261 tlb_flush_mmu(tlb); 260 tlb_flush_mmu(tlb);
262 261
263 /* keep the page table cache within bounds */ 262 /* keep the page table cache within bounds */
@@ -1099,7 +1098,6 @@ static unsigned long zap_pte_range(struct mmu_gather *tlb,
1099 spinlock_t *ptl; 1098 spinlock_t *ptl;
1100 pte_t *start_pte; 1099 pte_t *start_pte;
1101 pte_t *pte; 1100 pte_t *pte;
1102 unsigned long range_start = addr;
1103 1101
1104again: 1102again:
1105 init_rss_vec(rss); 1103 init_rss_vec(rss);
@@ -1141,9 +1139,12 @@ again:
1141 continue; 1139 continue;
1142 if (unlikely(details) && details->nonlinear_vma 1140 if (unlikely(details) && details->nonlinear_vma
1143 && linear_page_index(details->nonlinear_vma, 1141 && linear_page_index(details->nonlinear_vma,
1144 addr) != page->index) 1142 addr) != page->index) {
1145 set_pte_at(mm, addr, pte, 1143 pte_t ptfile = pgoff_to_pte(page->index);
1146 pgoff_to_pte(page->index)); 1144 if (pte_soft_dirty(ptent))
1145 pte_file_mksoft_dirty(ptfile);
1146 set_pte_at(mm, addr, pte, ptfile);
1147 }
1147 if (PageAnon(page)) 1148 if (PageAnon(page))
1148 rss[MM_ANONPAGES]--; 1149 rss[MM_ANONPAGES]--;
1149 else { 1150 else {
@@ -1202,17 +1203,25 @@ again:
1202 * and page-free while holding it. 1203 * and page-free while holding it.
1203 */ 1204 */
1204 if (force_flush) { 1205 if (force_flush) {
1206 unsigned long old_end;
1207
1205 force_flush = 0; 1208 force_flush = 0;
1206 1209
1207#ifdef HAVE_GENERIC_MMU_GATHER 1210 /*
1208 tlb->start = range_start; 1211 * Flush the TLB just for the previous segment,
1212 * then update the range to be the remaining
1213 * TLB range.
1214 */
1215 old_end = tlb->end;
1209 tlb->end = addr; 1216 tlb->end = addr;
1210#endif 1217
1211 tlb_flush_mmu(tlb); 1218 tlb_flush_mmu(tlb);
1212 if (addr != end) { 1219
1213 range_start = addr; 1220 tlb->start = addr;
1221 tlb->end = old_end;
1222
1223 if (addr != end)
1214 goto again; 1224 goto again;
1215 }
1216 } 1225 }
1217 1226
1218 return addr; 1227 return addr;
@@ -1397,7 +1406,7 @@ void zap_page_range(struct vm_area_struct *vma, unsigned long start,
1397 unsigned long end = start + size; 1406 unsigned long end = start + size;
1398 1407
1399 lru_add_drain(); 1408 lru_add_drain();
1400 tlb_gather_mmu(&tlb, mm, 0); 1409 tlb_gather_mmu(&tlb, mm, start, end);
1401 update_hiwater_rss(mm); 1410 update_hiwater_rss(mm);
1402 mmu_notifier_invalidate_range_start(mm, start, end); 1411 mmu_notifier_invalidate_range_start(mm, start, end);
1403 for ( ; vma && vma->vm_start < end; vma = vma->vm_next) 1412 for ( ; vma && vma->vm_start < end; vma = vma->vm_next)
@@ -1423,7 +1432,7 @@ static void zap_page_range_single(struct vm_area_struct *vma, unsigned long addr
1423 unsigned long end = address + size; 1432 unsigned long end = address + size;
1424 1433
1425 lru_add_drain(); 1434 lru_add_drain();
1426 tlb_gather_mmu(&tlb, mm, 0); 1435 tlb_gather_mmu(&tlb, mm, address, end);
1427 update_hiwater_rss(mm); 1436 update_hiwater_rss(mm);
1428 mmu_notifier_invalidate_range_start(mm, address, end); 1437 mmu_notifier_invalidate_range_start(mm, address, end);
1429 unmap_single_vma(&tlb, vma, address, end, details); 1438 unmap_single_vma(&tlb, vma, address, end, details);
@@ -3115,6 +3124,8 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
3115 exclusive = 1; 3124 exclusive = 1;
3116 } 3125 }
3117 flush_icache_page(vma, page); 3126 flush_icache_page(vma, page);
3127 if (pte_swp_soft_dirty(orig_pte))
3128 pte = pte_mksoft_dirty(pte);
3118 set_pte_at(mm, address, page_table, pte); 3129 set_pte_at(mm, address, page_table, pte);
3119 if (page == swapcache) 3130 if (page == swapcache)
3120 do_page_add_anon_rmap(page, vma, address, exclusive); 3131 do_page_add_anon_rmap(page, vma, address, exclusive);
@@ -3408,6 +3419,8 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
3408 entry = mk_pte(page, vma->vm_page_prot); 3419 entry = mk_pte(page, vma->vm_page_prot);
3409 if (flags & FAULT_FLAG_WRITE) 3420 if (flags & FAULT_FLAG_WRITE)
3410 entry = maybe_mkwrite(pte_mkdirty(entry), vma); 3421 entry = maybe_mkwrite(pte_mkdirty(entry), vma);
3422 else if (pte_file(orig_pte) && pte_file_soft_dirty(orig_pte))
3423 pte_mksoft_dirty(entry);
3411 if (anon) { 3424 if (anon) {
3412 inc_mm_counter_fast(mm, MM_ANONPAGES); 3425 inc_mm_counter_fast(mm, MM_ANONPAGES);
3413 page_add_new_anon_rmap(page, vma, address); 3426 page_add_new_anon_rmap(page, vma, address);
diff --git a/mm/mmap.c b/mm/mmap.c
index 1edbaa3136c3..f9c97d10b873 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -2336,7 +2336,7 @@ static void unmap_region(struct mm_struct *mm,
2336 struct mmu_gather tlb; 2336 struct mmu_gather tlb;
2337 2337
2338 lru_add_drain(); 2338 lru_add_drain();
2339 tlb_gather_mmu(&tlb, mm, 0); 2339 tlb_gather_mmu(&tlb, mm, start, end);
2340 update_hiwater_rss(mm); 2340 update_hiwater_rss(mm);
2341 unmap_vmas(&tlb, vma, start, end); 2341 unmap_vmas(&tlb, vma, start, end);
2342 free_pgtables(&tlb, vma, prev ? prev->vm_end : FIRST_USER_ADDRESS, 2342 free_pgtables(&tlb, vma, prev ? prev->vm_end : FIRST_USER_ADDRESS,
@@ -2709,7 +2709,7 @@ void exit_mmap(struct mm_struct *mm)
2709 2709
2710 lru_add_drain(); 2710 lru_add_drain();
2711 flush_cache_mm(mm); 2711 flush_cache_mm(mm);
2712 tlb_gather_mmu(&tlb, mm, 1); 2712 tlb_gather_mmu(&tlb, mm, 0, -1);
2713 /* update_hiwater_rss(mm) here? but nobody should be looking */ 2713 /* update_hiwater_rss(mm) here? but nobody should be looking */
2714 /* Use -1 here to ensure all VMAs in the mm are unmapped */ 2714 /* Use -1 here to ensure all VMAs in the mm are unmapped */
2715 unmap_vmas(&tlb, vma, 0, -1); 2715 unmap_vmas(&tlb, vma, 0, -1);
diff --git a/mm/rmap.c b/mm/rmap.c
index cd356df4f71a..b2e29acd7e3d 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -1236,6 +1236,7 @@ int try_to_unmap_one(struct page *page, struct vm_area_struct *vma,
1236 swp_entry_to_pte(make_hwpoison_entry(page))); 1236 swp_entry_to_pte(make_hwpoison_entry(page)));
1237 } else if (PageAnon(page)) { 1237 } else if (PageAnon(page)) {
1238 swp_entry_t entry = { .val = page_private(page) }; 1238 swp_entry_t entry = { .val = page_private(page) };
1239 pte_t swp_pte;
1239 1240
1240 if (PageSwapCache(page)) { 1241 if (PageSwapCache(page)) {
1241 /* 1242 /*
@@ -1264,7 +1265,10 @@ int try_to_unmap_one(struct page *page, struct vm_area_struct *vma,
1264 BUG_ON(TTU_ACTION(flags) != TTU_MIGRATION); 1265 BUG_ON(TTU_ACTION(flags) != TTU_MIGRATION);
1265 entry = make_migration_entry(page, pte_write(pteval)); 1266 entry = make_migration_entry(page, pte_write(pteval));
1266 } 1267 }
1267 set_pte_at(mm, address, pte, swp_entry_to_pte(entry)); 1268 swp_pte = swp_entry_to_pte(entry);
1269 if (pte_soft_dirty(pteval))
1270 swp_pte = pte_swp_mksoft_dirty(swp_pte);
1271 set_pte_at(mm, address, pte, swp_pte);
1268 BUG_ON(pte_file(*pte)); 1272 BUG_ON(pte_file(*pte));
1269 } else if (IS_ENABLED(CONFIG_MIGRATION) && 1273 } else if (IS_ENABLED(CONFIG_MIGRATION) &&
1270 (TTU_ACTION(flags) == TTU_MIGRATION)) { 1274 (TTU_ACTION(flags) == TTU_MIGRATION)) {
@@ -1401,8 +1405,12 @@ static int try_to_unmap_cluster(unsigned long cursor, unsigned int *mapcount,
1401 pteval = ptep_clear_flush(vma, address, pte); 1405 pteval = ptep_clear_flush(vma, address, pte);
1402 1406
1403 /* If nonlinear, store the file page offset in the pte. */ 1407 /* If nonlinear, store the file page offset in the pte. */
1404 if (page->index != linear_page_index(vma, address)) 1408 if (page->index != linear_page_index(vma, address)) {
1405 set_pte_at(mm, address, pte, pgoff_to_pte(page->index)); 1409 pte_t ptfile = pgoff_to_pte(page->index);
1410 if (pte_soft_dirty(pteval))
1411 pte_file_mksoft_dirty(ptfile);
1412 set_pte_at(mm, address, pte, ptfile);
1413 }
1406 1414
1407 /* Move the dirty bit to the physical page now the pte is gone. */ 1415 /* Move the dirty bit to the physical page now the pte is gone. */
1408 if (pte_dirty(pteval)) 1416 if (pte_dirty(pteval))
diff --git a/mm/shmem.c b/mm/shmem.c
index 8335dbd3fc35..e43dc555069d 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -2909,14 +2909,8 @@ EXPORT_SYMBOL_GPL(shmem_truncate_range);
2909 2909
2910/* common code */ 2910/* common code */
2911 2911
2912static char *shmem_dname(struct dentry *dentry, char *buffer, int buflen)
2913{
2914 return dynamic_dname(dentry, buffer, buflen, "/%s (deleted)",
2915 dentry->d_name.name);
2916}
2917
2918static struct dentry_operations anon_ops = { 2912static struct dentry_operations anon_ops = {
2919 .d_dname = shmem_dname 2913 .d_dname = simple_dname
2920}; 2914};
2921 2915
2922/** 2916/**
diff --git a/mm/slub.c b/mm/slub.c
index 2b02d666bf63..e3ba1f2cf60c 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -1968,9 +1968,6 @@ static void put_cpu_partial(struct kmem_cache *s, struct page *page, int drain)
1968 int pages; 1968 int pages;
1969 int pobjects; 1969 int pobjects;
1970 1970
1971 if (!s->cpu_partial)
1972 return;
1973
1974 do { 1971 do {
1975 pages = 0; 1972 pages = 0;
1976 pobjects = 0; 1973 pobjects = 0;
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 36af6eeaa67e..6cf2e60983b7 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -866,6 +866,21 @@ unsigned int count_swap_pages(int type, int free)
866} 866}
867#endif /* CONFIG_HIBERNATION */ 867#endif /* CONFIG_HIBERNATION */
868 868
869static inline int maybe_same_pte(pte_t pte, pte_t swp_pte)
870{
871#ifdef CONFIG_MEM_SOFT_DIRTY
872 /*
873 * When pte keeps soft dirty bit the pte generated
874 * from swap entry does not has it, still it's same
875 * pte from logical point of view.
876 */
877 pte_t swp_pte_dirty = pte_swp_mksoft_dirty(swp_pte);
878 return pte_same(pte, swp_pte) || pte_same(pte, swp_pte_dirty);
879#else
880 return pte_same(pte, swp_pte);
881#endif
882}
883
869/* 884/*
870 * No need to decide whether this PTE shares the swap entry with others, 885 * No need to decide whether this PTE shares the swap entry with others,
871 * just let do_wp_page work it out if a write is requested later - to 886 * just let do_wp_page work it out if a write is requested later - to
@@ -892,7 +907,7 @@ static int unuse_pte(struct vm_area_struct *vma, pmd_t *pmd,
892 } 907 }
893 908
894 pte = pte_offset_map_lock(vma->vm_mm, pmd, addr, &ptl); 909 pte = pte_offset_map_lock(vma->vm_mm, pmd, addr, &ptl);
895 if (unlikely(!pte_same(*pte, swp_entry_to_pte(entry)))) { 910 if (unlikely(!maybe_same_pte(*pte, swp_entry_to_pte(entry)))) {
896 mem_cgroup_cancel_charge_swapin(memcg); 911 mem_cgroup_cancel_charge_swapin(memcg);
897 ret = 0; 912 ret = 0;
898 goto out; 913 goto out;
@@ -947,7 +962,7 @@ static int unuse_pte_range(struct vm_area_struct *vma, pmd_t *pmd,
947 * swapoff spends a _lot_ of time in this loop! 962 * swapoff spends a _lot_ of time in this loop!
948 * Test inline before going to call unuse_pte. 963 * Test inline before going to call unuse_pte.
949 */ 964 */
950 if (unlikely(pte_same(*pte, swp_pte))) { 965 if (unlikely(maybe_same_pte(*pte, swp_pte))) {
951 pte_unmap(pte); 966 pte_unmap(pte);
952 ret = unuse_pte(vma, pmd, addr, entry, page); 967 ret = unuse_pte(vma, pmd, addr, entry, page);
953 if (ret) 968 if (ret)
diff --git a/net/8021q/vlan_core.c b/net/8021q/vlan_core.c
index 4a78c4de9f20..6ee48aac776f 100644
--- a/net/8021q/vlan_core.c
+++ b/net/8021q/vlan_core.c
@@ -91,7 +91,12 @@ EXPORT_SYMBOL(__vlan_find_dev_deep);
91 91
92struct net_device *vlan_dev_real_dev(const struct net_device *dev) 92struct net_device *vlan_dev_real_dev(const struct net_device *dev)
93{ 93{
94 return vlan_dev_priv(dev)->real_dev; 94 struct net_device *ret = vlan_dev_priv(dev)->real_dev;
95
96 while (is_vlan_dev(ret))
97 ret = vlan_dev_priv(ret)->real_dev;
98
99 return ret;
95} 100}
96EXPORT_SYMBOL(vlan_dev_real_dev); 101EXPORT_SYMBOL(vlan_dev_real_dev);
97 102
diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c
index e14531f1ce1c..264de88db320 100644
--- a/net/batman-adv/bridge_loop_avoidance.c
+++ b/net/batman-adv/bridge_loop_avoidance.c
@@ -1529,6 +1529,8 @@ out:
1529 * in these cases, the skb is further handled by this function and 1529 * in these cases, the skb is further handled by this function and
1530 * returns 1, otherwise it returns 0 and the caller shall further 1530 * returns 1, otherwise it returns 0 and the caller shall further
1531 * process the skb. 1531 * process the skb.
1532 *
1533 * This call might reallocate skb data.
1532 */ 1534 */
1533int batadv_bla_tx(struct batadv_priv *bat_priv, struct sk_buff *skb, 1535int batadv_bla_tx(struct batadv_priv *bat_priv, struct sk_buff *skb,
1534 unsigned short vid) 1536 unsigned short vid)
diff --git a/net/batman-adv/gateway_client.c b/net/batman-adv/gateway_client.c
index f105219f4a4b..7614af31daff 100644
--- a/net/batman-adv/gateway_client.c
+++ b/net/batman-adv/gateway_client.c
@@ -508,6 +508,7 @@ out:
508 return 0; 508 return 0;
509} 509}
510 510
511/* this call might reallocate skb data */
511static bool batadv_is_type_dhcprequest(struct sk_buff *skb, int header_len) 512static bool batadv_is_type_dhcprequest(struct sk_buff *skb, int header_len)
512{ 513{
513 int ret = false; 514 int ret = false;
@@ -568,6 +569,7 @@ out:
568 return ret; 569 return ret;
569} 570}
570 571
572/* this call might reallocate skb data */
571bool batadv_gw_is_dhcp_target(struct sk_buff *skb, unsigned int *header_len) 573bool batadv_gw_is_dhcp_target(struct sk_buff *skb, unsigned int *header_len)
572{ 574{
573 struct ethhdr *ethhdr; 575 struct ethhdr *ethhdr;
@@ -619,6 +621,12 @@ bool batadv_gw_is_dhcp_target(struct sk_buff *skb, unsigned int *header_len)
619 621
620 if (!pskb_may_pull(skb, *header_len + sizeof(*udphdr))) 622 if (!pskb_may_pull(skb, *header_len + sizeof(*udphdr)))
621 return false; 623 return false;
624
625 /* skb->data might have been reallocated by pskb_may_pull() */
626 ethhdr = (struct ethhdr *)skb->data;
627 if (ntohs(ethhdr->h_proto) == ETH_P_8021Q)
628 ethhdr = (struct ethhdr *)(skb->data + VLAN_HLEN);
629
622 udphdr = (struct udphdr *)(skb->data + *header_len); 630 udphdr = (struct udphdr *)(skb->data + *header_len);
623 *header_len += sizeof(*udphdr); 631 *header_len += sizeof(*udphdr);
624 632
@@ -634,12 +642,14 @@ bool batadv_gw_is_dhcp_target(struct sk_buff *skb, unsigned int *header_len)
634 return true; 642 return true;
635} 643}
636 644
645/* this call might reallocate skb data */
637bool batadv_gw_out_of_range(struct batadv_priv *bat_priv, 646bool batadv_gw_out_of_range(struct batadv_priv *bat_priv,
638 struct sk_buff *skb, struct ethhdr *ethhdr) 647 struct sk_buff *skb)
639{ 648{
640 struct batadv_neigh_node *neigh_curr = NULL, *neigh_old = NULL; 649 struct batadv_neigh_node *neigh_curr = NULL, *neigh_old = NULL;
641 struct batadv_orig_node *orig_dst_node = NULL; 650 struct batadv_orig_node *orig_dst_node = NULL;
642 struct batadv_gw_node *curr_gw = NULL; 651 struct batadv_gw_node *curr_gw = NULL;
652 struct ethhdr *ethhdr;
643 bool ret, out_of_range = false; 653 bool ret, out_of_range = false;
644 unsigned int header_len = 0; 654 unsigned int header_len = 0;
645 uint8_t curr_tq_avg; 655 uint8_t curr_tq_avg;
@@ -648,6 +658,7 @@ bool batadv_gw_out_of_range(struct batadv_priv *bat_priv,
648 if (!ret) 658 if (!ret)
649 goto out; 659 goto out;
650 660
661 ethhdr = (struct ethhdr *)skb->data;
651 orig_dst_node = batadv_transtable_search(bat_priv, ethhdr->h_source, 662 orig_dst_node = batadv_transtable_search(bat_priv, ethhdr->h_source,
652 ethhdr->h_dest); 663 ethhdr->h_dest);
653 if (!orig_dst_node) 664 if (!orig_dst_node)
diff --git a/net/batman-adv/gateway_client.h b/net/batman-adv/gateway_client.h
index 039902dca4a6..1037d75da51f 100644
--- a/net/batman-adv/gateway_client.h
+++ b/net/batman-adv/gateway_client.h
@@ -34,7 +34,6 @@ void batadv_gw_node_delete(struct batadv_priv *bat_priv,
34void batadv_gw_node_purge(struct batadv_priv *bat_priv); 34void batadv_gw_node_purge(struct batadv_priv *bat_priv);
35int batadv_gw_client_seq_print_text(struct seq_file *seq, void *offset); 35int batadv_gw_client_seq_print_text(struct seq_file *seq, void *offset);
36bool batadv_gw_is_dhcp_target(struct sk_buff *skb, unsigned int *header_len); 36bool batadv_gw_is_dhcp_target(struct sk_buff *skb, unsigned int *header_len);
37bool batadv_gw_out_of_range(struct batadv_priv *bat_priv, 37bool batadv_gw_out_of_range(struct batadv_priv *bat_priv, struct sk_buff *skb);
38 struct sk_buff *skb, struct ethhdr *ethhdr);
39 38
40#endif /* _NET_BATMAN_ADV_GATEWAY_CLIENT_H_ */ 39#endif /* _NET_BATMAN_ADV_GATEWAY_CLIENT_H_ */
diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
index 700d0b49742d..0f04e1c302b4 100644
--- a/net/batman-adv/soft-interface.c
+++ b/net/batman-adv/soft-interface.c
@@ -180,6 +180,9 @@ static int batadv_interface_tx(struct sk_buff *skb,
180 if (batadv_bla_tx(bat_priv, skb, vid)) 180 if (batadv_bla_tx(bat_priv, skb, vid))
181 goto dropped; 181 goto dropped;
182 182
183 /* skb->data might have been reallocated by batadv_bla_tx() */
184 ethhdr = (struct ethhdr *)skb->data;
185
183 /* Register the client MAC in the transtable */ 186 /* Register the client MAC in the transtable */
184 if (!is_multicast_ether_addr(ethhdr->h_source)) 187 if (!is_multicast_ether_addr(ethhdr->h_source))
185 batadv_tt_local_add(soft_iface, ethhdr->h_source, skb->skb_iif); 188 batadv_tt_local_add(soft_iface, ethhdr->h_source, skb->skb_iif);
@@ -220,6 +223,10 @@ static int batadv_interface_tx(struct sk_buff *skb,
220 default: 223 default:
221 break; 224 break;
222 } 225 }
226
227 /* reminder: ethhdr might have become unusable from here on
228 * (batadv_gw_is_dhcp_target() might have reallocated skb data)
229 */
223 } 230 }
224 231
225 /* ethernet packet should be broadcasted */ 232 /* ethernet packet should be broadcasted */
@@ -266,7 +273,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
266 /* unicast packet */ 273 /* unicast packet */
267 } else { 274 } else {
268 if (atomic_read(&bat_priv->gw_mode) != BATADV_GW_MODE_OFF) { 275 if (atomic_read(&bat_priv->gw_mode) != BATADV_GW_MODE_OFF) {
269 ret = batadv_gw_out_of_range(bat_priv, skb, ethhdr); 276 ret = batadv_gw_out_of_range(bat_priv, skb);
270 if (ret) 277 if (ret)
271 goto dropped; 278 goto dropped;
272 } 279 }
diff --git a/net/batman-adv/unicast.c b/net/batman-adv/unicast.c
index dc8b5d4dd636..857e1b8349ee 100644
--- a/net/batman-adv/unicast.c
+++ b/net/batman-adv/unicast.c
@@ -326,7 +326,9 @@ static bool batadv_unicast_push_and_fill_skb(struct sk_buff *skb, int hdr_size,
326 * @skb: the skb containing the payload to encapsulate 326 * @skb: the skb containing the payload to encapsulate
327 * @orig_node: the destination node 327 * @orig_node: the destination node
328 * 328 *
329 * Returns false if the payload could not be encapsulated or true otherwise 329 * Returns false if the payload could not be encapsulated or true otherwise.
330 *
331 * This call might reallocate skb data.
330 */ 332 */
331static bool batadv_unicast_prepare_skb(struct sk_buff *skb, 333static bool batadv_unicast_prepare_skb(struct sk_buff *skb,
332 struct batadv_orig_node *orig_node) 334 struct batadv_orig_node *orig_node)
@@ -343,7 +345,9 @@ static bool batadv_unicast_prepare_skb(struct sk_buff *skb,
343 * @orig_node: the destination node 345 * @orig_node: the destination node
344 * @packet_subtype: the batman 4addr packet subtype to use 346 * @packet_subtype: the batman 4addr packet subtype to use
345 * 347 *
346 * Returns false if the payload could not be encapsulated or true otherwise 348 * Returns false if the payload could not be encapsulated or true otherwise.
349 *
350 * This call might reallocate skb data.
347 */ 351 */
348bool batadv_unicast_4addr_prepare_skb(struct batadv_priv *bat_priv, 352bool batadv_unicast_4addr_prepare_skb(struct batadv_priv *bat_priv,
349 struct sk_buff *skb, 353 struct sk_buff *skb,
@@ -401,7 +405,7 @@ int batadv_unicast_generic_send_skb(struct batadv_priv *bat_priv,
401 struct batadv_neigh_node *neigh_node; 405 struct batadv_neigh_node *neigh_node;
402 int data_len = skb->len; 406 int data_len = skb->len;
403 int ret = NET_RX_DROP; 407 int ret = NET_RX_DROP;
404 unsigned int dev_mtu; 408 unsigned int dev_mtu, header_len;
405 409
406 /* get routing information */ 410 /* get routing information */
407 if (is_multicast_ether_addr(ethhdr->h_dest)) { 411 if (is_multicast_ether_addr(ethhdr->h_dest)) {
@@ -428,11 +432,17 @@ find_router:
428 432
429 switch (packet_type) { 433 switch (packet_type) {
430 case BATADV_UNICAST: 434 case BATADV_UNICAST:
431 batadv_unicast_prepare_skb(skb, orig_node); 435 if (!batadv_unicast_prepare_skb(skb, orig_node))
436 goto out;
437
438 header_len = sizeof(struct batadv_unicast_packet);
432 break; 439 break;
433 case BATADV_UNICAST_4ADDR: 440 case BATADV_UNICAST_4ADDR:
434 batadv_unicast_4addr_prepare_skb(bat_priv, skb, orig_node, 441 if (!batadv_unicast_4addr_prepare_skb(bat_priv, skb, orig_node,
435 packet_subtype); 442 packet_subtype))
443 goto out;
444
445 header_len = sizeof(struct batadv_unicast_4addr_packet);
436 break; 446 break;
437 default: 447 default:
438 /* this function supports UNICAST and UNICAST_4ADDR only. It 448 /* this function supports UNICAST and UNICAST_4ADDR only. It
@@ -441,6 +451,7 @@ find_router:
441 goto out; 451 goto out;
442 } 452 }
443 453
454 ethhdr = (struct ethhdr *)(skb->data + header_len);
444 unicast_packet = (struct batadv_unicast_packet *)skb->data; 455 unicast_packet = (struct batadv_unicast_packet *)skb->data;
445 456
446 /* inform the destination node that we are still missing a correct route 457 /* inform the destination node that we are still missing a correct route
diff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c
index 60aca9109a50..ffd5874f2592 100644
--- a/net/bridge/br_fdb.c
+++ b/net/bridge/br_fdb.c
@@ -161,7 +161,7 @@ void br_fdb_change_mac_address(struct net_bridge *br, const u8 *newaddr)
161 if (!pv) 161 if (!pv)
162 return; 162 return;
163 163
164 for_each_set_bit_from(vid, pv->vlan_bitmap, BR_VLAN_BITMAP_LEN) { 164 for_each_set_bit_from(vid, pv->vlan_bitmap, VLAN_N_VID) {
165 f = __br_fdb_get(br, br->dev->dev_addr, vid); 165 f = __br_fdb_get(br, br->dev->dev_addr, vid);
166 if (f && f->is_local && !f->dst) 166 if (f && f->is_local && !f->dst)
167 fdb_delete(br, f); 167 fdb_delete(br, f);
@@ -730,7 +730,7 @@ int br_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
730 /* VID was specified, so use it. */ 730 /* VID was specified, so use it. */
731 err = __br_fdb_add(ndm, p, addr, nlh_flags, vid); 731 err = __br_fdb_add(ndm, p, addr, nlh_flags, vid);
732 } else { 732 } else {
733 if (!pv || bitmap_empty(pv->vlan_bitmap, BR_VLAN_BITMAP_LEN)) { 733 if (!pv || bitmap_empty(pv->vlan_bitmap, VLAN_N_VID)) {
734 err = __br_fdb_add(ndm, p, addr, nlh_flags, 0); 734 err = __br_fdb_add(ndm, p, addr, nlh_flags, 0);
735 goto out; 735 goto out;
736 } 736 }
@@ -739,7 +739,7 @@ int br_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
739 * specify a VLAN. To be nice, add/update entry for every 739 * specify a VLAN. To be nice, add/update entry for every
740 * vlan on this port. 740 * vlan on this port.
741 */ 741 */
742 for_each_set_bit(vid, pv->vlan_bitmap, BR_VLAN_BITMAP_LEN) { 742 for_each_set_bit(vid, pv->vlan_bitmap, VLAN_N_VID) {
743 err = __br_fdb_add(ndm, p, addr, nlh_flags, vid); 743 err = __br_fdb_add(ndm, p, addr, nlh_flags, vid);
744 if (err) 744 if (err)
745 goto out; 745 goto out;
@@ -817,7 +817,7 @@ int br_fdb_delete(struct ndmsg *ndm, struct nlattr *tb[],
817 817
818 err = __br_fdb_delete(p, addr, vid); 818 err = __br_fdb_delete(p, addr, vid);
819 } else { 819 } else {
820 if (!pv || bitmap_empty(pv->vlan_bitmap, BR_VLAN_BITMAP_LEN)) { 820 if (!pv || bitmap_empty(pv->vlan_bitmap, VLAN_N_VID)) {
821 err = __br_fdb_delete(p, addr, 0); 821 err = __br_fdb_delete(p, addr, 0);
822 goto out; 822 goto out;
823 } 823 }
@@ -827,7 +827,7 @@ int br_fdb_delete(struct ndmsg *ndm, struct nlattr *tb[],
827 * vlan on this port. 827 * vlan on this port.
828 */ 828 */
829 err = -ENOENT; 829 err = -ENOENT;
830 for_each_set_bit(vid, pv->vlan_bitmap, BR_VLAN_BITMAP_LEN) { 830 for_each_set_bit(vid, pv->vlan_bitmap, VLAN_N_VID) {
831 err &= __br_fdb_delete(p, addr, vid); 831 err &= __br_fdb_delete(p, addr, vid);
832 } 832 }
833 } 833 }
diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c
index 61c5e819380e..08e576ada0b2 100644
--- a/net/bridge/br_multicast.c
+++ b/net/bridge/br_multicast.c
@@ -1195,7 +1195,7 @@ static int br_ip6_multicast_query(struct net_bridge *br,
1195 max_delay = msecs_to_jiffies(ntohs(mld->mld_maxdelay)); 1195 max_delay = msecs_to_jiffies(ntohs(mld->mld_maxdelay));
1196 if (max_delay) 1196 if (max_delay)
1197 group = &mld->mld_mca; 1197 group = &mld->mld_mca;
1198 } else if (skb->len >= sizeof(*mld2q)) { 1198 } else {
1199 if (!pskb_may_pull(skb, sizeof(*mld2q))) { 1199 if (!pskb_may_pull(skb, sizeof(*mld2q))) {
1200 err = -EINVAL; 1200 err = -EINVAL;
1201 goto out; 1201 goto out;
diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c
index 1fc30abd3a52..b9259efa636e 100644
--- a/net/bridge/br_netlink.c
+++ b/net/bridge/br_netlink.c
@@ -132,7 +132,7 @@ static int br_fill_ifinfo(struct sk_buff *skb,
132 else 132 else
133 pv = br_get_vlan_info(br); 133 pv = br_get_vlan_info(br);
134 134
135 if (!pv || bitmap_empty(pv->vlan_bitmap, BR_VLAN_BITMAP_LEN)) 135 if (!pv || bitmap_empty(pv->vlan_bitmap, VLAN_N_VID))
136 goto done; 136 goto done;
137 137
138 af = nla_nest_start(skb, IFLA_AF_SPEC); 138 af = nla_nest_start(skb, IFLA_AF_SPEC);
@@ -140,7 +140,7 @@ static int br_fill_ifinfo(struct sk_buff *skb,
140 goto nla_put_failure; 140 goto nla_put_failure;
141 141
142 pvid = br_get_pvid(pv); 142 pvid = br_get_pvid(pv);
143 for_each_set_bit(vid, pv->vlan_bitmap, BR_VLAN_BITMAP_LEN) { 143 for_each_set_bit(vid, pv->vlan_bitmap, VLAN_N_VID) {
144 vinfo.vid = vid; 144 vinfo.vid = vid;
145 vinfo.flags = 0; 145 vinfo.flags = 0;
146 if (vid == pvid) 146 if (vid == pvid)
diff --git a/net/bridge/br_sysfs_br.c b/net/bridge/br_sysfs_br.c
index 394bb96b6087..3b9637fb7939 100644
--- a/net/bridge/br_sysfs_br.c
+++ b/net/bridge/br_sysfs_br.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Sysfs attributes of bridge ports 2 * Sysfs attributes of bridge
3 * Linux ethernet bridge 3 * Linux ethernet bridge
4 * 4 *
5 * Authors: 5 * Authors:
diff --git a/net/bridge/br_vlan.c b/net/bridge/br_vlan.c
index bd58b45f5f90..9a9ffe7e4019 100644
--- a/net/bridge/br_vlan.c
+++ b/net/bridge/br_vlan.c
@@ -108,7 +108,7 @@ static int __vlan_del(struct net_port_vlans *v, u16 vid)
108 108
109 clear_bit(vid, v->vlan_bitmap); 109 clear_bit(vid, v->vlan_bitmap);
110 v->num_vlans--; 110 v->num_vlans--;
111 if (bitmap_empty(v->vlan_bitmap, BR_VLAN_BITMAP_LEN)) { 111 if (bitmap_empty(v->vlan_bitmap, VLAN_N_VID)) {
112 if (v->port_idx) 112 if (v->port_idx)
113 rcu_assign_pointer(v->parent.port->vlan_info, NULL); 113 rcu_assign_pointer(v->parent.port->vlan_info, NULL);
114 else 114 else
@@ -122,7 +122,7 @@ static void __vlan_flush(struct net_port_vlans *v)
122{ 122{
123 smp_wmb(); 123 smp_wmb();
124 v->pvid = 0; 124 v->pvid = 0;
125 bitmap_zero(v->vlan_bitmap, BR_VLAN_BITMAP_LEN); 125 bitmap_zero(v->vlan_bitmap, VLAN_N_VID);
126 if (v->port_idx) 126 if (v->port_idx)
127 rcu_assign_pointer(v->parent.port->vlan_info, NULL); 127 rcu_assign_pointer(v->parent.port->vlan_info, NULL);
128 else 128 else
diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c
index 00ee068efc1c..b84a1b155bc1 100644
--- a/net/core/flow_dissector.c
+++ b/net/core/flow_dissector.c
@@ -65,6 +65,7 @@ ipv6:
65 nhoff += sizeof(struct ipv6hdr); 65 nhoff += sizeof(struct ipv6hdr);
66 break; 66 break;
67 } 67 }
68 case __constant_htons(ETH_P_8021AD):
68 case __constant_htons(ETH_P_8021Q): { 69 case __constant_htons(ETH_P_8021Q): {
69 const struct vlan_hdr *vlan; 70 const struct vlan_hdr *vlan;
70 struct vlan_hdr _vlan; 71 struct vlan_hdr _vlan;
diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index 9232c68941ab..60533db8b72d 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -1441,16 +1441,18 @@ struct neigh_parms *neigh_parms_alloc(struct net_device *dev,
1441 atomic_set(&p->refcnt, 1); 1441 atomic_set(&p->refcnt, 1);
1442 p->reachable_time = 1442 p->reachable_time =
1443 neigh_rand_reach_time(p->base_reachable_time); 1443 neigh_rand_reach_time(p->base_reachable_time);
1444 dev_hold(dev);
1445 p->dev = dev;
1446 write_pnet(&p->net, hold_net(net));
1447 p->sysctl_table = NULL;
1444 1448
1445 if (ops->ndo_neigh_setup && ops->ndo_neigh_setup(dev, p)) { 1449 if (ops->ndo_neigh_setup && ops->ndo_neigh_setup(dev, p)) {
1450 release_net(net);
1451 dev_put(dev);
1446 kfree(p); 1452 kfree(p);
1447 return NULL; 1453 return NULL;
1448 } 1454 }
1449 1455
1450 dev_hold(dev);
1451 p->dev = dev;
1452 write_pnet(&p->net, hold_net(net));
1453 p->sysctl_table = NULL;
1454 write_lock_bh(&tbl->lock); 1456 write_lock_bh(&tbl->lock);
1455 p->next = tbl->parms.next; 1457 p->next = tbl->parms.next;
1456 tbl->parms.next = p; 1458 tbl->parms.next = p;
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 3de740834d1f..ca198c1d1d30 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -2156,7 +2156,7 @@ int ndo_dflt_fdb_del(struct ndmsg *ndm,
2156 /* If aging addresses are supported device will need to 2156 /* If aging addresses are supported device will need to
2157 * implement its own handler for this. 2157 * implement its own handler for this.
2158 */ 2158 */
2159 if (ndm->ndm_state & NUD_PERMANENT) { 2159 if (!(ndm->ndm_state & NUD_PERMANENT)) {
2160 pr_info("%s: FDB only supports static addresses\n", dev->name); 2160 pr_info("%s: FDB only supports static addresses\n", dev->name);
2161 return -EINVAL; 2161 return -EINVAL;
2162 } 2162 }
@@ -2384,7 +2384,7 @@ static int rtnl_bridge_getlink(struct sk_buff *skb, struct netlink_callback *cb)
2384 struct nlattr *extfilt; 2384 struct nlattr *extfilt;
2385 u32 filter_mask = 0; 2385 u32 filter_mask = 0;
2386 2386
2387 extfilt = nlmsg_find_attr(cb->nlh, sizeof(struct rtgenmsg), 2387 extfilt = nlmsg_find_attr(cb->nlh, sizeof(struct ifinfomsg),
2388 IFLA_EXT_MASK); 2388 IFLA_EXT_MASK);
2389 if (extfilt) 2389 if (extfilt)
2390 filter_mask = nla_get_u32(extfilt); 2390 filter_mask = nla_get_u32(extfilt);
diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c
index ab3d814bc80a..109ee89f123e 100644
--- a/net/ipv4/esp4.c
+++ b/net/ipv4/esp4.c
@@ -477,7 +477,7 @@ static u32 esp4_get_mtu(struct xfrm_state *x, int mtu)
477 } 477 }
478 478
479 return ((mtu - x->props.header_len - crypto_aead_authsize(esp->aead) - 479 return ((mtu - x->props.header_len - crypto_aead_authsize(esp->aead) -
480 net_adj) & ~(align - 1)) + (net_adj - 2); 480 net_adj) & ~(align - 1)) + net_adj - 2;
481} 481}
482 482
483static void esp4_err(struct sk_buff *skb, u32 info) 483static void esp4_err(struct sk_buff *skb, u32 info)
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index 108a1e9c9eac..3df6d3edb2a1 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -71,7 +71,6 @@
71#include <linux/init.h> 71#include <linux/init.h>
72#include <linux/list.h> 72#include <linux/list.h>
73#include <linux/slab.h> 73#include <linux/slab.h>
74#include <linux/prefetch.h>
75#include <linux/export.h> 74#include <linux/export.h>
76#include <net/net_namespace.h> 75#include <net/net_namespace.h>
77#include <net/ip.h> 76#include <net/ip.h>
@@ -1761,10 +1760,8 @@ static struct leaf *leaf_walk_rcu(struct tnode *p, struct rt_trie_node *c)
1761 if (!c) 1760 if (!c)
1762 continue; 1761 continue;
1763 1762
1764 if (IS_LEAF(c)) { 1763 if (IS_LEAF(c))
1765 prefetch(rcu_dereference_rtnl(p->child[idx]));
1766 return (struct leaf *) c; 1764 return (struct leaf *) c;
1767 }
1768 1765
1769 /* Rescan start scanning in new node */ 1766 /* Rescan start scanning in new node */
1770 p = (struct tnode *) c; 1767 p = (struct tnode *) c;
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index 1f6eab66f7ce..8d6939eeb492 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -383,7 +383,7 @@ static int ipgre_header(struct sk_buff *skb, struct net_device *dev,
383 if (daddr) 383 if (daddr)
384 memcpy(&iph->daddr, daddr, 4); 384 memcpy(&iph->daddr, daddr, 4);
385 if (iph->daddr) 385 if (iph->daddr)
386 return t->hlen; 386 return t->hlen + sizeof(*iph);
387 387
388 return -(t->hlen + sizeof(*iph)); 388 return -(t->hlen + sizeof(*iph));
389} 389}
diff --git a/net/ipv4/ip_tunnel_core.c b/net/ipv4/ip_tunnel_core.c
index 7167b08977df..850525b34899 100644
--- a/net/ipv4/ip_tunnel_core.c
+++ b/net/ipv4/ip_tunnel_core.c
@@ -76,9 +76,7 @@ int iptunnel_xmit(struct net *net, struct rtable *rt,
76 iph->daddr = dst; 76 iph->daddr = dst;
77 iph->saddr = src; 77 iph->saddr = src;
78 iph->ttl = ttl; 78 iph->ttl = ttl;
79 tunnel_ip_select_ident(skb, 79 __ip_select_ident(iph, &rt->dst, (skb_shinfo(skb)->gso_segs ?: 1) - 1);
80 (const struct iphdr *)skb_inner_network_header(skb),
81 &rt->dst);
82 80
83 err = ip_local_out(skb); 81 err = ip_local_out(skb);
84 if (unlikely(net_xmit_eval(err))) 82 if (unlikely(net_xmit_eval(err)))
diff --git a/net/ipv4/proc.c b/net/ipv4/proc.c
index 6577a1149a47..463bd1273346 100644
--- a/net/ipv4/proc.c
+++ b/net/ipv4/proc.c
@@ -273,7 +273,7 @@ static const struct snmp_mib snmp4_net_list[] = {
273 SNMP_MIB_ITEM("TCPFastOpenListenOverflow", LINUX_MIB_TCPFASTOPENLISTENOVERFLOW), 273 SNMP_MIB_ITEM("TCPFastOpenListenOverflow", LINUX_MIB_TCPFASTOPENLISTENOVERFLOW),
274 SNMP_MIB_ITEM("TCPFastOpenCookieReqd", LINUX_MIB_TCPFASTOPENCOOKIEREQD), 274 SNMP_MIB_ITEM("TCPFastOpenCookieReqd", LINUX_MIB_TCPFASTOPENCOOKIEREQD),
275 SNMP_MIB_ITEM("TCPSpuriousRtxHostQueues", LINUX_MIB_TCPSPURIOUS_RTX_HOSTQUEUES), 275 SNMP_MIB_ITEM("TCPSpuriousRtxHostQueues", LINUX_MIB_TCPSPURIOUS_RTX_HOSTQUEUES),
276 SNMP_MIB_ITEM("LowLatencyRxPackets", LINUX_MIB_LOWLATENCYRXPACKETS), 276 SNMP_MIB_ITEM("BusyPollRxPackets", LINUX_MIB_BUSYPOLLRXPACKETS),
277 SNMP_MIB_SENTINEL 277 SNMP_MIB_SENTINEL
278}; 278};
279 279
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 5423223e93c2..b2f6c74861af 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -1121,6 +1121,13 @@ new_segment:
1121 goto wait_for_memory; 1121 goto wait_for_memory;
1122 1122
1123 /* 1123 /*
1124 * All packets are restored as if they have
1125 * already been sent.
1126 */
1127 if (tp->repair)
1128 TCP_SKB_CB(skb)->when = tcp_time_stamp;
1129
1130 /*
1124 * Check whether we can use HW checksum. 1131 * Check whether we can use HW checksum.
1125 */ 1132 */
1126 if (sk->sk_route_caps & NETIF_F_ALL_CSUM) 1133 if (sk->sk_route_caps & NETIF_F_ALL_CSUM)
diff --git a/net/ipv4/tcp_cubic.c b/net/ipv4/tcp_cubic.c
index a9077f441cb2..b6ae92a51f58 100644
--- a/net/ipv4/tcp_cubic.c
+++ b/net/ipv4/tcp_cubic.c
@@ -206,8 +206,8 @@ static u32 cubic_root(u64 a)
206 */ 206 */
207static inline void bictcp_update(struct bictcp *ca, u32 cwnd) 207static inline void bictcp_update(struct bictcp *ca, u32 cwnd)
208{ 208{
209 u64 offs; 209 u32 delta, bic_target, max_cnt;
210 u32 delta, t, bic_target, max_cnt; 210 u64 offs, t;
211 211
212 ca->ack_cnt++; /* count the number of ACKs */ 212 ca->ack_cnt++; /* count the number of ACKs */
213 213
@@ -250,9 +250,11 @@ static inline void bictcp_update(struct bictcp *ca, u32 cwnd)
250 * if the cwnd < 1 million packets !!! 250 * if the cwnd < 1 million packets !!!
251 */ 251 */
252 252
253 t = (s32)(tcp_time_stamp - ca->epoch_start);
254 t += msecs_to_jiffies(ca->delay_min >> 3);
253 /* change the unit from HZ to bictcp_HZ */ 255 /* change the unit from HZ to bictcp_HZ */
254 t = ((tcp_time_stamp + msecs_to_jiffies(ca->delay_min>>3) 256 t <<= BICTCP_HZ;
255 - ca->epoch_start) << BICTCP_HZ) / HZ; 257 do_div(t, HZ);
256 258
257 if (t < ca->bic_K) /* t - K */ 259 if (t < ca->bic_K) /* t - K */
258 offs = ca->bic_K - t; 260 offs = ca->bic_K - t;
@@ -414,7 +416,7 @@ static void bictcp_acked(struct sock *sk, u32 cnt, s32 rtt_us)
414 return; 416 return;
415 417
416 /* Discard delay samples right after fast recovery */ 418 /* Discard delay samples right after fast recovery */
417 if ((s32)(tcp_time_stamp - ca->epoch_start) < HZ) 419 if (ca->epoch_start && (s32)(tcp_time_stamp - ca->epoch_start) < HZ)
418 return; 420 return;
419 421
420 delay = (rtt_us << 3) / USEC_PER_MSEC; 422 delay = (rtt_us << 3) / USEC_PER_MSEC;
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index da4241c8c7da..498ea99194af 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -1126,12 +1126,10 @@ retry:
1126 if (ifp->flags & IFA_F_OPTIMISTIC) 1126 if (ifp->flags & IFA_F_OPTIMISTIC)
1127 addr_flags |= IFA_F_OPTIMISTIC; 1127 addr_flags |= IFA_F_OPTIMISTIC;
1128 1128
1129 ift = !max_addresses || 1129 ift = ipv6_add_addr(idev, &addr, NULL, tmp_plen,
1130 ipv6_count_addresses(idev) < max_addresses ? 1130 ipv6_addr_scope(&addr), addr_flags,
1131 ipv6_add_addr(idev, &addr, NULL, tmp_plen, 1131 tmp_valid_lft, tmp_prefered_lft);
1132 ipv6_addr_scope(&addr), addr_flags, 1132 if (IS_ERR(ift)) {
1133 tmp_valid_lft, tmp_prefered_lft) : NULL;
1134 if (IS_ERR_OR_NULL(ift)) {
1135 in6_ifa_put(ifp); 1133 in6_ifa_put(ifp);
1136 in6_dev_put(idev); 1134 in6_dev_put(idev);
1137 pr_info("%s: retry temporary address regeneration\n", __func__); 1135 pr_info("%s: retry temporary address regeneration\n", __func__);
diff --git a/net/ipv6/esp6.c b/net/ipv6/esp6.c
index 40ffd72243a4..aeac0dc3635d 100644
--- a/net/ipv6/esp6.c
+++ b/net/ipv6/esp6.c
@@ -425,7 +425,7 @@ static u32 esp6_get_mtu(struct xfrm_state *x, int mtu)
425 net_adj = 0; 425 net_adj = 0;
426 426
427 return ((mtu - x->props.header_len - crypto_aead_authsize(esp->aead) - 427 return ((mtu - x->props.header_len - crypto_aead_authsize(esp->aead) -
428 net_adj) & ~(align - 1)) + (net_adj - 2); 428 net_adj) & ~(align - 1)) + net_adj - 2;
429} 429}
430 430
431static void esp6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, 431static void esp6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
index bff3d821c7eb..c4ff5bbb45c4 100644
--- a/net/ipv6/ip6_fib.c
+++ b/net/ipv6/ip6_fib.c
@@ -993,14 +993,22 @@ static struct fib6_node * fib6_lookup_1(struct fib6_node *root,
993 993
994 if (ipv6_prefix_equal(&key->addr, args->addr, key->plen)) { 994 if (ipv6_prefix_equal(&key->addr, args->addr, key->plen)) {
995#ifdef CONFIG_IPV6_SUBTREES 995#ifdef CONFIG_IPV6_SUBTREES
996 if (fn->subtree) 996 if (fn->subtree) {
997 fn = fib6_lookup_1(fn->subtree, args + 1); 997 struct fib6_node *sfn;
998 sfn = fib6_lookup_1(fn->subtree,
999 args + 1);
1000 if (!sfn)
1001 goto backtrack;
1002 fn = sfn;
1003 }
998#endif 1004#endif
999 if (!fn || fn->fn_flags & RTN_RTINFO) 1005 if (fn->fn_flags & RTN_RTINFO)
1000 return fn; 1006 return fn;
1001 } 1007 }
1002 } 1008 }
1003 1009#ifdef CONFIG_IPV6_SUBTREES
1010backtrack:
1011#endif
1004 if (fn->fn_flags & RTN_ROOT) 1012 if (fn->fn_flags & RTN_ROOT)
1005 break; 1013 break;
1006 1014
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index 79aa9652ed86..04d31c2fbef1 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -1369,8 +1369,10 @@ static void ndisc_redirect_rcv(struct sk_buff *skb)
1369 if (!ndisc_parse_options(msg->opt, ndoptlen, &ndopts)) 1369 if (!ndisc_parse_options(msg->opt, ndoptlen, &ndopts))
1370 return; 1370 return;
1371 1371
1372 if (!ndopts.nd_opts_rh) 1372 if (!ndopts.nd_opts_rh) {
1373 ip6_redirect_no_header(skb, dev_net(skb->dev), 0, 0);
1373 return; 1374 return;
1375 }
1374 1376
1375 hdr = (u8 *)ndopts.nd_opts_rh; 1377 hdr = (u8 *)ndopts.nd_opts_rh;
1376 hdr += 8; 1378 hdr += 8;
diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
index 790d9f4b8b0b..1aeb473b2cc6 100644
--- a/net/ipv6/reassembly.c
+++ b/net/ipv6/reassembly.c
@@ -490,6 +490,7 @@ static int ip6_frag_reasm(struct frag_queue *fq, struct sk_buff *prev,
490 ipv6_hdr(head)->payload_len = htons(payload_len); 490 ipv6_hdr(head)->payload_len = htons(payload_len);
491 ipv6_change_dsfield(ipv6_hdr(head), 0xff, ecn); 491 ipv6_change_dsfield(ipv6_hdr(head), 0xff, ecn);
492 IP6CB(head)->nhoff = nhoff; 492 IP6CB(head)->nhoff = nhoff;
493 IP6CB(head)->flags |= IP6SKB_FRAGMENTED;
493 494
494 /* Yes, and fold redundant checksum back. 8) */ 495 /* Yes, and fold redundant checksum back. 8) */
495 if (head->ip_summed == CHECKSUM_COMPLETE) 496 if (head->ip_summed == CHECKSUM_COMPLETE)
@@ -524,6 +525,9 @@ static int ipv6_frag_rcv(struct sk_buff *skb)
524 struct net *net = dev_net(skb_dst(skb)->dev); 525 struct net *net = dev_net(skb_dst(skb)->dev);
525 int evicted; 526 int evicted;
526 527
528 if (IP6CB(skb)->flags & IP6SKB_FRAGMENTED)
529 goto fail_hdr;
530
527 IP6_INC_STATS_BH(net, ip6_dst_idev(skb_dst(skb)), IPSTATS_MIB_REASMREQDS); 531 IP6_INC_STATS_BH(net, ip6_dst_idev(skb_dst(skb)), IPSTATS_MIB_REASMREQDS);
528 532
529 /* Jumbo payload inhibits frag. header */ 533 /* Jumbo payload inhibits frag. header */
@@ -544,6 +548,7 @@ static int ipv6_frag_rcv(struct sk_buff *skb)
544 ip6_dst_idev(skb_dst(skb)), IPSTATS_MIB_REASMOKS); 548 ip6_dst_idev(skb_dst(skb)), IPSTATS_MIB_REASMOKS);
545 549
546 IP6CB(skb)->nhoff = (u8 *)fhdr - skb_network_header(skb); 550 IP6CB(skb)->nhoff = (u8 *)fhdr - skb_network_header(skb);
551 IP6CB(skb)->flags |= IP6SKB_FRAGMENTED;
547 return 1; 552 return 1;
548 } 553 }
549 554
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index b70f8979003b..8d9a93ed9c59 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -1178,6 +1178,27 @@ void ip6_redirect(struct sk_buff *skb, struct net *net, int oif, u32 mark)
1178} 1178}
1179EXPORT_SYMBOL_GPL(ip6_redirect); 1179EXPORT_SYMBOL_GPL(ip6_redirect);
1180 1180
1181void ip6_redirect_no_header(struct sk_buff *skb, struct net *net, int oif,
1182 u32 mark)
1183{
1184 const struct ipv6hdr *iph = ipv6_hdr(skb);
1185 const struct rd_msg *msg = (struct rd_msg *)icmp6_hdr(skb);
1186 struct dst_entry *dst;
1187 struct flowi6 fl6;
1188
1189 memset(&fl6, 0, sizeof(fl6));
1190 fl6.flowi6_oif = oif;
1191 fl6.flowi6_mark = mark;
1192 fl6.flowi6_flags = 0;
1193 fl6.daddr = msg->dest;
1194 fl6.saddr = iph->daddr;
1195
1196 dst = ip6_route_output(net, NULL, &fl6);
1197 if (!dst->error)
1198 rt6_do_redirect(dst, NULL, skb);
1199 dst_release(dst);
1200}
1201
1181void ip6_sk_redirect(struct sk_buff *skb, struct sock *sk) 1202void ip6_sk_redirect(struct sk_buff *skb, struct sock *sk)
1182{ 1203{
1183 ip6_redirect(skb, sock_net(sk), sk->sk_bound_dev_if, sk->sk_mark); 1204 ip6_redirect(skb, sock_net(sk), sk->sk_bound_dev_if, sk->sk_mark);
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index ae31968d42d3..cc9e02d79b55 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -31,10 +31,12 @@
31#include "led.h" 31#include "led.h"
32 32
33#define IEEE80211_AUTH_TIMEOUT (HZ / 5) 33#define IEEE80211_AUTH_TIMEOUT (HZ / 5)
34#define IEEE80211_AUTH_TIMEOUT_LONG (HZ / 2)
34#define IEEE80211_AUTH_TIMEOUT_SHORT (HZ / 10) 35#define IEEE80211_AUTH_TIMEOUT_SHORT (HZ / 10)
35#define IEEE80211_AUTH_MAX_TRIES 3 36#define IEEE80211_AUTH_MAX_TRIES 3
36#define IEEE80211_AUTH_WAIT_ASSOC (HZ * 5) 37#define IEEE80211_AUTH_WAIT_ASSOC (HZ * 5)
37#define IEEE80211_ASSOC_TIMEOUT (HZ / 5) 38#define IEEE80211_ASSOC_TIMEOUT (HZ / 5)
39#define IEEE80211_ASSOC_TIMEOUT_LONG (HZ / 2)
38#define IEEE80211_ASSOC_TIMEOUT_SHORT (HZ / 10) 40#define IEEE80211_ASSOC_TIMEOUT_SHORT (HZ / 10)
39#define IEEE80211_ASSOC_MAX_TRIES 3 41#define IEEE80211_ASSOC_MAX_TRIES 3
40 42
@@ -209,8 +211,9 @@ ieee80211_determine_chantype(struct ieee80211_sub_if_data *sdata,
209 struct ieee80211_channel *channel, 211 struct ieee80211_channel *channel,
210 const struct ieee80211_ht_operation *ht_oper, 212 const struct ieee80211_ht_operation *ht_oper,
211 const struct ieee80211_vht_operation *vht_oper, 213 const struct ieee80211_vht_operation *vht_oper,
212 struct cfg80211_chan_def *chandef, bool verbose) 214 struct cfg80211_chan_def *chandef, bool tracking)
213{ 215{
216 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
214 struct cfg80211_chan_def vht_chandef; 217 struct cfg80211_chan_def vht_chandef;
215 u32 ht_cfreq, ret; 218 u32 ht_cfreq, ret;
216 219
@@ -229,7 +232,7 @@ ieee80211_determine_chantype(struct ieee80211_sub_if_data *sdata,
229 ht_cfreq = ieee80211_channel_to_frequency(ht_oper->primary_chan, 232 ht_cfreq = ieee80211_channel_to_frequency(ht_oper->primary_chan,
230 channel->band); 233 channel->band);
231 /* check that channel matches the right operating channel */ 234 /* check that channel matches the right operating channel */
232 if (channel->center_freq != ht_cfreq) { 235 if (!tracking && channel->center_freq != ht_cfreq) {
233 /* 236 /*
234 * It's possible that some APs are confused here; 237 * It's possible that some APs are confused here;
235 * Netgear WNDR3700 sometimes reports 4 higher than 238 * Netgear WNDR3700 sometimes reports 4 higher than
@@ -237,11 +240,10 @@ ieee80211_determine_chantype(struct ieee80211_sub_if_data *sdata,
237 * since we look at probe response/beacon data here 240 * since we look at probe response/beacon data here
238 * it should be OK. 241 * it should be OK.
239 */ 242 */
240 if (verbose) 243 sdata_info(sdata,
241 sdata_info(sdata, 244 "Wrong control channel: center-freq: %d ht-cfreq: %d ht->primary_chan: %d band: %d - Disabling HT\n",
242 "Wrong control channel: center-freq: %d ht-cfreq: %d ht->primary_chan: %d band: %d - Disabling HT\n", 245 channel->center_freq, ht_cfreq,
243 channel->center_freq, ht_cfreq, 246 ht_oper->primary_chan, channel->band);
244 ht_oper->primary_chan, channel->band);
245 ret = IEEE80211_STA_DISABLE_HT | IEEE80211_STA_DISABLE_VHT; 247 ret = IEEE80211_STA_DISABLE_HT | IEEE80211_STA_DISABLE_VHT;
246 goto out; 248 goto out;
247 } 249 }
@@ -295,7 +297,7 @@ ieee80211_determine_chantype(struct ieee80211_sub_if_data *sdata,
295 channel->band); 297 channel->band);
296 break; 298 break;
297 default: 299 default:
298 if (verbose) 300 if (!(ifmgd->flags & IEEE80211_STA_DISABLE_VHT))
299 sdata_info(sdata, 301 sdata_info(sdata,
300 "AP VHT operation IE has invalid channel width (%d), disable VHT\n", 302 "AP VHT operation IE has invalid channel width (%d), disable VHT\n",
301 vht_oper->chan_width); 303 vht_oper->chan_width);
@@ -304,7 +306,7 @@ ieee80211_determine_chantype(struct ieee80211_sub_if_data *sdata,
304 } 306 }
305 307
306 if (!cfg80211_chandef_valid(&vht_chandef)) { 308 if (!cfg80211_chandef_valid(&vht_chandef)) {
307 if (verbose) 309 if (!(ifmgd->flags & IEEE80211_STA_DISABLE_VHT))
308 sdata_info(sdata, 310 sdata_info(sdata,
309 "AP VHT information is invalid, disable VHT\n"); 311 "AP VHT information is invalid, disable VHT\n");
310 ret = IEEE80211_STA_DISABLE_VHT; 312 ret = IEEE80211_STA_DISABLE_VHT;
@@ -317,7 +319,7 @@ ieee80211_determine_chantype(struct ieee80211_sub_if_data *sdata,
317 } 319 }
318 320
319 if (!cfg80211_chandef_compatible(chandef, &vht_chandef)) { 321 if (!cfg80211_chandef_compatible(chandef, &vht_chandef)) {
320 if (verbose) 322 if (!(ifmgd->flags & IEEE80211_STA_DISABLE_VHT))
321 sdata_info(sdata, 323 sdata_info(sdata,
322 "AP VHT information doesn't match HT, disable VHT\n"); 324 "AP VHT information doesn't match HT, disable VHT\n");
323 ret = IEEE80211_STA_DISABLE_VHT; 325 ret = IEEE80211_STA_DISABLE_VHT;
@@ -333,18 +335,27 @@ out:
333 if (ret & IEEE80211_STA_DISABLE_VHT) 335 if (ret & IEEE80211_STA_DISABLE_VHT)
334 vht_chandef = *chandef; 336 vht_chandef = *chandef;
335 337
338 /*
339 * Ignore the DISABLED flag when we're already connected and only
340 * tracking the APs beacon for bandwidth changes - otherwise we
341 * might get disconnected here if we connect to an AP, update our
342 * regulatory information based on the AP's country IE and the
343 * information we have is wrong/outdated and disables the channel
344 * that we're actually using for the connection to the AP.
345 */
336 while (!cfg80211_chandef_usable(sdata->local->hw.wiphy, chandef, 346 while (!cfg80211_chandef_usable(sdata->local->hw.wiphy, chandef,
337 IEEE80211_CHAN_DISABLED)) { 347 tracking ? 0 :
348 IEEE80211_CHAN_DISABLED)) {
338 if (WARN_ON(chandef->width == NL80211_CHAN_WIDTH_20_NOHT)) { 349 if (WARN_ON(chandef->width == NL80211_CHAN_WIDTH_20_NOHT)) {
339 ret = IEEE80211_STA_DISABLE_HT | 350 ret = IEEE80211_STA_DISABLE_HT |
340 IEEE80211_STA_DISABLE_VHT; 351 IEEE80211_STA_DISABLE_VHT;
341 goto out; 352 break;
342 } 353 }
343 354
344 ret |= chandef_downgrade(chandef); 355 ret |= chandef_downgrade(chandef);
345 } 356 }
346 357
347 if (chandef->width != vht_chandef.width && verbose) 358 if (chandef->width != vht_chandef.width && !tracking)
348 sdata_info(sdata, 359 sdata_info(sdata,
349 "capabilities/regulatory prevented using AP HT/VHT configuration, downgraded\n"); 360 "capabilities/regulatory prevented using AP HT/VHT configuration, downgraded\n");
350 361
@@ -384,7 +395,7 @@ static int ieee80211_config_bw(struct ieee80211_sub_if_data *sdata,
384 395
385 /* calculate new channel (type) based on HT/VHT operation IEs */ 396 /* calculate new channel (type) based on HT/VHT operation IEs */
386 flags = ieee80211_determine_chantype(sdata, sband, chan, ht_oper, 397 flags = ieee80211_determine_chantype(sdata, sband, chan, ht_oper,
387 vht_oper, &chandef, false); 398 vht_oper, &chandef, true);
388 399
389 /* 400 /*
390 * Downgrade the new channel if we associated with restricted 401 * Downgrade the new channel if we associated with restricted
@@ -3394,10 +3405,13 @@ static int ieee80211_probe_auth(struct ieee80211_sub_if_data *sdata)
3394 3405
3395 if (tx_flags == 0) { 3406 if (tx_flags == 0) {
3396 auth_data->timeout = jiffies + IEEE80211_AUTH_TIMEOUT; 3407 auth_data->timeout = jiffies + IEEE80211_AUTH_TIMEOUT;
3397 ifmgd->auth_data->timeout_started = true; 3408 auth_data->timeout_started = true;
3398 run_again(sdata, auth_data->timeout); 3409 run_again(sdata, auth_data->timeout);
3399 } else { 3410 } else {
3400 auth_data->timeout_started = false; 3411 auth_data->timeout =
3412 round_jiffies_up(jiffies + IEEE80211_AUTH_TIMEOUT_LONG);
3413 auth_data->timeout_started = true;
3414 run_again(sdata, auth_data->timeout);
3401 } 3415 }
3402 3416
3403 return 0; 3417 return 0;
@@ -3434,7 +3448,11 @@ static int ieee80211_do_assoc(struct ieee80211_sub_if_data *sdata)
3434 assoc_data->timeout_started = true; 3448 assoc_data->timeout_started = true;
3435 run_again(sdata, assoc_data->timeout); 3449 run_again(sdata, assoc_data->timeout);
3436 } else { 3450 } else {
3437 assoc_data->timeout_started = false; 3451 assoc_data->timeout =
3452 round_jiffies_up(jiffies +
3453 IEEE80211_ASSOC_TIMEOUT_LONG);
3454 assoc_data->timeout_started = true;
3455 run_again(sdata, assoc_data->timeout);
3438 } 3456 }
3439 3457
3440 return 0; 3458 return 0;
@@ -3829,7 +3847,7 @@ static int ieee80211_prep_channel(struct ieee80211_sub_if_data *sdata,
3829 ifmgd->flags |= ieee80211_determine_chantype(sdata, sband, 3847 ifmgd->flags |= ieee80211_determine_chantype(sdata, sband,
3830 cbss->channel, 3848 cbss->channel,
3831 ht_oper, vht_oper, 3849 ht_oper, vht_oper,
3832 &chandef, true); 3850 &chandef, false);
3833 3851
3834 sdata->needed_rx_chains = min(ieee80211_ht_vht_rx_chains(sdata, cbss), 3852 sdata->needed_rx_chains = min(ieee80211_ht_vht_rx_chains(sdata, cbss),
3835 local->rx_chains); 3853 local->rx_chains);
diff --git a/net/netfilter/nf_conntrack_proto_tcp.c b/net/netfilter/nf_conntrack_proto_tcp.c
index 7dcc376eea5f..2f8010707d01 100644
--- a/net/netfilter/nf_conntrack_proto_tcp.c
+++ b/net/netfilter/nf_conntrack_proto_tcp.c
@@ -526,7 +526,7 @@ static bool tcp_in_window(const struct nf_conn *ct,
526 const struct nf_conntrack_tuple *tuple = &ct->tuplehash[dir].tuple; 526 const struct nf_conntrack_tuple *tuple = &ct->tuplehash[dir].tuple;
527 __u32 seq, ack, sack, end, win, swin; 527 __u32 seq, ack, sack, end, win, swin;
528 s16 receiver_offset; 528 s16 receiver_offset;
529 bool res; 529 bool res, in_recv_win;
530 530
531 /* 531 /*
532 * Get the required data from the packet. 532 * Get the required data from the packet.
@@ -649,14 +649,18 @@ static bool tcp_in_window(const struct nf_conn *ct,
649 receiver->td_end, receiver->td_maxend, receiver->td_maxwin, 649 receiver->td_end, receiver->td_maxend, receiver->td_maxwin,
650 receiver->td_scale); 650 receiver->td_scale);
651 651
652 /* Is the ending sequence in the receive window (if available)? */
653 in_recv_win = !receiver->td_maxwin ||
654 after(end, sender->td_end - receiver->td_maxwin - 1);
655
652 pr_debug("tcp_in_window: I=%i II=%i III=%i IV=%i\n", 656 pr_debug("tcp_in_window: I=%i II=%i III=%i IV=%i\n",
653 before(seq, sender->td_maxend + 1), 657 before(seq, sender->td_maxend + 1),
654 after(end, sender->td_end - receiver->td_maxwin - 1), 658 (in_recv_win ? 1 : 0),
655 before(sack, receiver->td_end + 1), 659 before(sack, receiver->td_end + 1),
656 after(sack, receiver->td_end - MAXACKWINDOW(sender) - 1)); 660 after(sack, receiver->td_end - MAXACKWINDOW(sender) - 1));
657 661
658 if (before(seq, sender->td_maxend + 1) && 662 if (before(seq, sender->td_maxend + 1) &&
659 after(end, sender->td_end - receiver->td_maxwin - 1) && 663 in_recv_win &&
660 before(sack, receiver->td_end + 1) && 664 before(sack, receiver->td_end + 1) &&
661 after(sack, receiver->td_end - MAXACKWINDOW(sender) - 1)) { 665 after(sack, receiver->td_end - MAXACKWINDOW(sender) - 1)) {
662 /* 666 /*
@@ -725,7 +729,7 @@ static bool tcp_in_window(const struct nf_conn *ct,
725 nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL, 729 nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL,
726 "nf_ct_tcp: %s ", 730 "nf_ct_tcp: %s ",
727 before(seq, sender->td_maxend + 1) ? 731 before(seq, sender->td_maxend + 1) ?
728 after(end, sender->td_end - receiver->td_maxwin - 1) ? 732 in_recv_win ?
729 before(sack, receiver->td_end + 1) ? 733 before(sack, receiver->td_end + 1) ?
730 after(sack, receiver->td_end - MAXACKWINDOW(sender) - 1) ? "BUG" 734 after(sack, receiver->td_end - MAXACKWINDOW(sender) - 1) ? "BUG"
731 : "ACK is under the lower bound (possible overly delayed ACK)" 735 : "ACK is under the lower bound (possible overly delayed ACK)"
diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
index 962e9792e317..d92cc317bf8b 100644
--- a/net/netfilter/nfnetlink_log.c
+++ b/net/netfilter/nfnetlink_log.c
@@ -419,6 +419,7 @@ __build_packet_message(struct nfnl_log_net *log,
419 nfmsg->version = NFNETLINK_V0; 419 nfmsg->version = NFNETLINK_V0;
420 nfmsg->res_id = htons(inst->group_num); 420 nfmsg->res_id = htons(inst->group_num);
421 421
422 memset(&pmsg, 0, sizeof(pmsg));
422 pmsg.hw_protocol = skb->protocol; 423 pmsg.hw_protocol = skb->protocol;
423 pmsg.hook = hooknum; 424 pmsg.hook = hooknum;
424 425
@@ -498,7 +499,10 @@ __build_packet_message(struct nfnl_log_net *log,
498 if (indev && skb->dev && 499 if (indev && skb->dev &&
499 skb->mac_header != skb->network_header) { 500 skb->mac_header != skb->network_header) {
500 struct nfulnl_msg_packet_hw phw; 501 struct nfulnl_msg_packet_hw phw;
501 int len = dev_parse_header(skb, phw.hw_addr); 502 int len;
503
504 memset(&phw, 0, sizeof(phw));
505 len = dev_parse_header(skb, phw.hw_addr);
502 if (len > 0) { 506 if (len > 0) {
503 phw.hw_addrlen = htons(len); 507 phw.hw_addrlen = htons(len);
504 if (nla_put(inst->skb, NFULA_HWADDR, sizeof(phw), &phw)) 508 if (nla_put(inst->skb, NFULA_HWADDR, sizeof(phw), &phw))
diff --git a/net/netfilter/nfnetlink_queue_core.c b/net/netfilter/nfnetlink_queue_core.c
index 971ea145ab3e..8a703c3dd318 100644
--- a/net/netfilter/nfnetlink_queue_core.c
+++ b/net/netfilter/nfnetlink_queue_core.c
@@ -463,7 +463,10 @@ nfqnl_build_packet_message(struct nfqnl_instance *queue,
463 if (indev && entskb->dev && 463 if (indev && entskb->dev &&
464 entskb->mac_header != entskb->network_header) { 464 entskb->mac_header != entskb->network_header) {
465 struct nfqnl_msg_packet_hw phw; 465 struct nfqnl_msg_packet_hw phw;
466 int len = dev_parse_header(entskb, phw.hw_addr); 466 int len;
467
468 memset(&phw, 0, sizeof(phw));
469 len = dev_parse_header(entskb, phw.hw_addr);
467 if (len) { 470 if (len) {
468 phw.hw_addrlen = htons(len); 471 phw.hw_addrlen = htons(len);
469 if (nla_put(skb, NFQA_HWADDR, sizeof(phw), &phw)) 472 if (nla_put(skb, NFQA_HWADDR, sizeof(phw), &phw))
diff --git a/net/netfilter/xt_TCPMSS.c b/net/netfilter/xt_TCPMSS.c
index 7011c71646f0..6113cc7efffc 100644
--- a/net/netfilter/xt_TCPMSS.c
+++ b/net/netfilter/xt_TCPMSS.c
@@ -52,7 +52,8 @@ tcpmss_mangle_packet(struct sk_buff *skb,
52{ 52{
53 const struct xt_tcpmss_info *info = par->targinfo; 53 const struct xt_tcpmss_info *info = par->targinfo;
54 struct tcphdr *tcph; 54 struct tcphdr *tcph;
55 unsigned int tcplen, i; 55 int len, tcp_hdrlen;
56 unsigned int i;
56 __be16 oldval; 57 __be16 oldval;
57 u16 newmss; 58 u16 newmss;
58 u8 *opt; 59 u8 *opt;
@@ -64,11 +65,14 @@ tcpmss_mangle_packet(struct sk_buff *skb,
64 if (!skb_make_writable(skb, skb->len)) 65 if (!skb_make_writable(skb, skb->len))
65 return -1; 66 return -1;
66 67
67 tcplen = skb->len - tcphoff; 68 len = skb->len - tcphoff;
69 if (len < (int)sizeof(struct tcphdr))
70 return -1;
71
68 tcph = (struct tcphdr *)(skb_network_header(skb) + tcphoff); 72 tcph = (struct tcphdr *)(skb_network_header(skb) + tcphoff);
73 tcp_hdrlen = tcph->doff * 4;
69 74
70 /* Header cannot be larger than the packet */ 75 if (len < tcp_hdrlen)
71 if (tcplen < tcph->doff*4)
72 return -1; 76 return -1;
73 77
74 if (info->mss == XT_TCPMSS_CLAMP_PMTU) { 78 if (info->mss == XT_TCPMSS_CLAMP_PMTU) {
@@ -87,9 +91,8 @@ tcpmss_mangle_packet(struct sk_buff *skb,
87 newmss = info->mss; 91 newmss = info->mss;
88 92
89 opt = (u_int8_t *)tcph; 93 opt = (u_int8_t *)tcph;
90 for (i = sizeof(struct tcphdr); i < tcph->doff*4; i += optlen(opt, i)) { 94 for (i = sizeof(struct tcphdr); i <= tcp_hdrlen - TCPOLEN_MSS; i += optlen(opt, i)) {
91 if (opt[i] == TCPOPT_MSS && tcph->doff*4 - i >= TCPOLEN_MSS && 95 if (opt[i] == TCPOPT_MSS && opt[i+1] == TCPOLEN_MSS) {
92 opt[i+1] == TCPOLEN_MSS) {
93 u_int16_t oldmss; 96 u_int16_t oldmss;
94 97
95 oldmss = (opt[i+2] << 8) | opt[i+3]; 98 oldmss = (opt[i+2] << 8) | opt[i+3];
@@ -112,9 +115,10 @@ tcpmss_mangle_packet(struct sk_buff *skb,
112 } 115 }
113 116
114 /* There is data after the header so the option can't be added 117 /* There is data after the header so the option can't be added
115 without moving it, and doing so may make the SYN packet 118 * without moving it, and doing so may make the SYN packet
116 itself too large. Accept the packet unmodified instead. */ 119 * itself too large. Accept the packet unmodified instead.
117 if (tcplen > tcph->doff*4) 120 */
121 if (len > tcp_hdrlen)
118 return 0; 122 return 0;
119 123
120 /* 124 /*
@@ -143,10 +147,10 @@ tcpmss_mangle_packet(struct sk_buff *skb,
143 newmss = min(newmss, (u16)1220); 147 newmss = min(newmss, (u16)1220);
144 148
145 opt = (u_int8_t *)tcph + sizeof(struct tcphdr); 149 opt = (u_int8_t *)tcph + sizeof(struct tcphdr);
146 memmove(opt + TCPOLEN_MSS, opt, tcplen - sizeof(struct tcphdr)); 150 memmove(opt + TCPOLEN_MSS, opt, len - sizeof(struct tcphdr));
147 151
148 inet_proto_csum_replace2(&tcph->check, skb, 152 inet_proto_csum_replace2(&tcph->check, skb,
149 htons(tcplen), htons(tcplen + TCPOLEN_MSS), 1); 153 htons(len), htons(len + TCPOLEN_MSS), 1);
150 opt[0] = TCPOPT_MSS; 154 opt[0] = TCPOPT_MSS;
151 opt[1] = TCPOLEN_MSS; 155 opt[1] = TCPOLEN_MSS;
152 opt[2] = (newmss & 0xff00) >> 8; 156 opt[2] = (newmss & 0xff00) >> 8;
diff --git a/net/netfilter/xt_TCPOPTSTRIP.c b/net/netfilter/xt_TCPOPTSTRIP.c
index b68fa191710f..625fa1d636a0 100644
--- a/net/netfilter/xt_TCPOPTSTRIP.c
+++ b/net/netfilter/xt_TCPOPTSTRIP.c
@@ -38,7 +38,7 @@ tcpoptstrip_mangle_packet(struct sk_buff *skb,
38 struct tcphdr *tcph; 38 struct tcphdr *tcph;
39 u_int16_t n, o; 39 u_int16_t n, o;
40 u_int8_t *opt; 40 u_int8_t *opt;
41 int len; 41 int len, tcp_hdrlen;
42 42
43 /* This is a fragment, no TCP header is available */ 43 /* This is a fragment, no TCP header is available */
44 if (par->fragoff != 0) 44 if (par->fragoff != 0)
@@ -52,7 +52,9 @@ tcpoptstrip_mangle_packet(struct sk_buff *skb,
52 return NF_DROP; 52 return NF_DROP;
53 53
54 tcph = (struct tcphdr *)(skb_network_header(skb) + tcphoff); 54 tcph = (struct tcphdr *)(skb_network_header(skb) + tcphoff);
55 if (tcph->doff * 4 > len) 55 tcp_hdrlen = tcph->doff * 4;
56
57 if (len < tcp_hdrlen)
56 return NF_DROP; 58 return NF_DROP;
57 59
58 opt = (u_int8_t *)tcph; 60 opt = (u_int8_t *)tcph;
@@ -61,10 +63,10 @@ tcpoptstrip_mangle_packet(struct sk_buff *skb,
61 * Walk through all TCP options - if we find some option to remove, 63 * Walk through all TCP options - if we find some option to remove,
62 * set all octets to %TCPOPT_NOP and adjust checksum. 64 * set all octets to %TCPOPT_NOP and adjust checksum.
63 */ 65 */
64 for (i = sizeof(struct tcphdr); i < tcp_hdrlen(skb); i += optl) { 66 for (i = sizeof(struct tcphdr); i < tcp_hdrlen - 1; i += optl) {
65 optl = optlen(opt, i); 67 optl = optlen(opt, i);
66 68
67 if (i + optl > tcp_hdrlen(skb)) 69 if (i + optl > tcp_hdrlen)
68 break; 70 break;
69 71
70 if (!tcpoptstrip_test_bit(info->strip_bmap, opt[i])) 72 if (!tcpoptstrip_test_bit(info->strip_bmap, opt[i]))
diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c
index 22c5f399f1cf..ab101f715447 100644
--- a/net/openvswitch/actions.c
+++ b/net/openvswitch/actions.c
@@ -535,6 +535,7 @@ int ovs_execute_actions(struct datapath *dp, struct sk_buff *skb)
535{ 535{
536 struct sw_flow_actions *acts = rcu_dereference(OVS_CB(skb)->flow->sf_acts); 536 struct sw_flow_actions *acts = rcu_dereference(OVS_CB(skb)->flow->sf_acts);
537 537
538 OVS_CB(skb)->tun_key = NULL;
538 return do_execute_actions(dp, skb, acts->actions, 539 return do_execute_actions(dp, skb, acts->actions,
539 acts->actions_len, false); 540 acts->actions_len, false);
540} 541}
diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
index f7e3a0d84c40..f2ed7600084e 100644
--- a/net/openvswitch/datapath.c
+++ b/net/openvswitch/datapath.c
@@ -2076,9 +2076,6 @@ static int ovs_vport_cmd_set(struct sk_buff *skb, struct genl_info *info)
2076 ovs_notify(reply, info, &ovs_dp_vport_multicast_group); 2076 ovs_notify(reply, info, &ovs_dp_vport_multicast_group);
2077 return 0; 2077 return 0;
2078 2078
2079 rtnl_unlock();
2080 return 0;
2081
2082exit_free: 2079exit_free:
2083 kfree_skb(reply); 2080 kfree_skb(reply);
2084exit_unlock: 2081exit_unlock:
diff --git a/net/openvswitch/flow.c b/net/openvswitch/flow.c
index 5c519b121e1b..1aa84dc58777 100644
--- a/net/openvswitch/flow.c
+++ b/net/openvswitch/flow.c
@@ -240,7 +240,7 @@ static struct flex_array *alloc_buckets(unsigned int n_buckets)
240 struct flex_array *buckets; 240 struct flex_array *buckets;
241 int i, err; 241 int i, err;
242 242
243 buckets = flex_array_alloc(sizeof(struct hlist_head *), 243 buckets = flex_array_alloc(sizeof(struct hlist_head),
244 n_buckets, GFP_KERNEL); 244 n_buckets, GFP_KERNEL);
245 if (!buckets) 245 if (!buckets)
246 return NULL; 246 return NULL;
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 4b66c752eae5..75c8bbf598c8 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -3259,9 +3259,11 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
3259 3259
3260 if (po->tp_version == TPACKET_V3) { 3260 if (po->tp_version == TPACKET_V3) {
3261 lv = sizeof(struct tpacket_stats_v3); 3261 lv = sizeof(struct tpacket_stats_v3);
3262 st.stats3.tp_packets += st.stats3.tp_drops;
3262 data = &st.stats3; 3263 data = &st.stats3;
3263 } else { 3264 } else {
3264 lv = sizeof(struct tpacket_stats); 3265 lv = sizeof(struct tpacket_stats);
3266 st.stats1.tp_packets += st.stats1.tp_drops;
3265 data = &st.stats1; 3267 data = &st.stats1;
3266 } 3268 }
3267 3269
diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
index 281c1bded1f6..51b968d3febb 100644
--- a/net/sched/sch_api.c
+++ b/net/sched/sch_api.c
@@ -285,6 +285,45 @@ static struct Qdisc_ops *qdisc_lookup_ops(struct nlattr *kind)
285 return q; 285 return q;
286} 286}
287 287
288/* The linklayer setting were not transferred from iproute2, in older
289 * versions, and the rate tables lookup systems have been dropped in
290 * the kernel. To keep backward compatible with older iproute2 tc
291 * utils, we detect the linklayer setting by detecting if the rate
292 * table were modified.
293 *
294 * For linklayer ATM table entries, the rate table will be aligned to
295 * 48 bytes, thus some table entries will contain the same value. The
296 * mpu (min packet unit) is also encoded into the old rate table, thus
297 * starting from the mpu, we find low and high table entries for
298 * mapping this cell. If these entries contain the same value, when
299 * the rate tables have been modified for linklayer ATM.
300 *
301 * This is done by rounding mpu to the nearest 48 bytes cell/entry,
302 * and then roundup to the next cell, calc the table entry one below,
303 * and compare.
304 */
305static __u8 __detect_linklayer(struct tc_ratespec *r, __u32 *rtab)
306{
307 int low = roundup(r->mpu, 48);
308 int high = roundup(low+1, 48);
309 int cell_low = low >> r->cell_log;
310 int cell_high = (high >> r->cell_log) - 1;
311
312 /* rtab is too inaccurate at rates > 100Mbit/s */
313 if ((r->rate > (100000000/8)) || (rtab[0] == 0)) {
314 pr_debug("TC linklayer: Giving up ATM detection\n");
315 return TC_LINKLAYER_ETHERNET;
316 }
317
318 if ((cell_high > cell_low) && (cell_high < 256)
319 && (rtab[cell_low] == rtab[cell_high])) {
320 pr_debug("TC linklayer: Detected ATM, low(%d)=high(%d)=%u\n",
321 cell_low, cell_high, rtab[cell_high]);
322 return TC_LINKLAYER_ATM;
323 }
324 return TC_LINKLAYER_ETHERNET;
325}
326
288static struct qdisc_rate_table *qdisc_rtab_list; 327static struct qdisc_rate_table *qdisc_rtab_list;
289 328
290struct qdisc_rate_table *qdisc_get_rtab(struct tc_ratespec *r, struct nlattr *tab) 329struct qdisc_rate_table *qdisc_get_rtab(struct tc_ratespec *r, struct nlattr *tab)
@@ -308,6 +347,8 @@ struct qdisc_rate_table *qdisc_get_rtab(struct tc_ratespec *r, struct nlattr *ta
308 rtab->rate = *r; 347 rtab->rate = *r;
309 rtab->refcnt = 1; 348 rtab->refcnt = 1;
310 memcpy(rtab->data, nla_data(tab), 1024); 349 memcpy(rtab->data, nla_data(tab), 1024);
350 if (r->linklayer == TC_LINKLAYER_UNAWARE)
351 r->linklayer = __detect_linklayer(r, rtab->data);
311 rtab->next = qdisc_rtab_list; 352 rtab->next = qdisc_rtab_list;
312 qdisc_rtab_list = rtab; 353 qdisc_rtab_list = rtab;
313 } 354 }
diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
index 4626cef4b76e..48be3d5c0d92 100644
--- a/net/sched/sch_generic.c
+++ b/net/sched/sch_generic.c
@@ -25,6 +25,7 @@
25#include <linux/rcupdate.h> 25#include <linux/rcupdate.h>
26#include <linux/list.h> 26#include <linux/list.h>
27#include <linux/slab.h> 27#include <linux/slab.h>
28#include <linux/if_vlan.h>
28#include <net/sch_generic.h> 29#include <net/sch_generic.h>
29#include <net/pkt_sched.h> 30#include <net/pkt_sched.h>
30#include <net/dst.h> 31#include <net/dst.h>
@@ -207,15 +208,19 @@ void __qdisc_run(struct Qdisc *q)
207 208
208unsigned long dev_trans_start(struct net_device *dev) 209unsigned long dev_trans_start(struct net_device *dev)
209{ 210{
210 unsigned long val, res = dev->trans_start; 211 unsigned long val, res;
211 unsigned int i; 212 unsigned int i;
212 213
214 if (is_vlan_dev(dev))
215 dev = vlan_dev_real_dev(dev);
216 res = dev->trans_start;
213 for (i = 0; i < dev->num_tx_queues; i++) { 217 for (i = 0; i < dev->num_tx_queues; i++) {
214 val = netdev_get_tx_queue(dev, i)->trans_start; 218 val = netdev_get_tx_queue(dev, i)->trans_start;
215 if (val && time_after(val, res)) 219 if (val && time_after(val, res))
216 res = val; 220 res = val;
217 } 221 }
218 dev->trans_start = res; 222 dev->trans_start = res;
223
219 return res; 224 return res;
220} 225}
221EXPORT_SYMBOL(dev_trans_start); 226EXPORT_SYMBOL(dev_trans_start);
@@ -904,6 +909,7 @@ void psched_ratecfg_precompute(struct psched_ratecfg *r,
904 memset(r, 0, sizeof(*r)); 909 memset(r, 0, sizeof(*r));
905 r->overhead = conf->overhead; 910 r->overhead = conf->overhead;
906 r->rate_bytes_ps = conf->rate; 911 r->rate_bytes_ps = conf->rate;
912 r->linklayer = (conf->linklayer & TC_LINKLAYER_MASK);
907 r->mult = 1; 913 r->mult = 1;
908 /* 914 /*
909 * The deal here is to replace a divide by a reciprocal one 915 * The deal here is to replace a divide by a reciprocal one
diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c
index 45e751527dfc..c2178b15ca6e 100644
--- a/net/sched/sch_htb.c
+++ b/net/sched/sch_htb.c
@@ -1329,6 +1329,7 @@ static int htb_change_class(struct Qdisc *sch, u32 classid,
1329 struct htb_sched *q = qdisc_priv(sch); 1329 struct htb_sched *q = qdisc_priv(sch);
1330 struct htb_class *cl = (struct htb_class *)*arg, *parent; 1330 struct htb_class *cl = (struct htb_class *)*arg, *parent;
1331 struct nlattr *opt = tca[TCA_OPTIONS]; 1331 struct nlattr *opt = tca[TCA_OPTIONS];
1332 struct qdisc_rate_table *rtab = NULL, *ctab = NULL;
1332 struct nlattr *tb[TCA_HTB_MAX + 1]; 1333 struct nlattr *tb[TCA_HTB_MAX + 1];
1333 struct tc_htb_opt *hopt; 1334 struct tc_htb_opt *hopt;
1334 1335
@@ -1350,6 +1351,18 @@ static int htb_change_class(struct Qdisc *sch, u32 classid,
1350 if (!hopt->rate.rate || !hopt->ceil.rate) 1351 if (!hopt->rate.rate || !hopt->ceil.rate)
1351 goto failure; 1352 goto failure;
1352 1353
1354 /* Keeping backward compatible with rate_table based iproute2 tc */
1355 if (hopt->rate.linklayer == TC_LINKLAYER_UNAWARE) {
1356 rtab = qdisc_get_rtab(&hopt->rate, tb[TCA_HTB_RTAB]);
1357 if (rtab)
1358 qdisc_put_rtab(rtab);
1359 }
1360 if (hopt->ceil.linklayer == TC_LINKLAYER_UNAWARE) {
1361 ctab = qdisc_get_rtab(&hopt->ceil, tb[TCA_HTB_CTAB]);
1362 if (ctab)
1363 qdisc_put_rtab(ctab);
1364 }
1365
1353 if (!cl) { /* new class */ 1366 if (!cl) { /* new class */
1354 struct Qdisc *new_q; 1367 struct Qdisc *new_q;
1355 int prio; 1368 int prio;
diff --git a/net/sctp/associola.c b/net/sctp/associola.c
index bce5b79662a6..ab67efc64b24 100644
--- a/net/sctp/associola.c
+++ b/net/sctp/associola.c
@@ -846,12 +846,12 @@ void sctp_assoc_control_transport(struct sctp_association *asoc,
846 else 846 else
847 spc_state = SCTP_ADDR_AVAILABLE; 847 spc_state = SCTP_ADDR_AVAILABLE;
848 /* Don't inform ULP about transition from PF to 848 /* Don't inform ULP about transition from PF to
849 * active state and set cwnd to 1, see SCTP 849 * active state and set cwnd to 1 MTU, see SCTP
850 * Quick failover draft section 5.1, point 5 850 * Quick failover draft section 5.1, point 5
851 */ 851 */
852 if (transport->state == SCTP_PF) { 852 if (transport->state == SCTP_PF) {
853 ulp_notify = false; 853 ulp_notify = false;
854 transport->cwnd = 1; 854 transport->cwnd = asoc->pathmtu;
855 } 855 }
856 transport->state = SCTP_ACTIVE; 856 transport->state = SCTP_ACTIVE;
857 break; 857 break;
diff --git a/net/sctp/transport.c b/net/sctp/transport.c
index bdbbc3fd7c14..8fdd16046d66 100644
--- a/net/sctp/transport.c
+++ b/net/sctp/transport.c
@@ -181,12 +181,12 @@ static void sctp_transport_destroy(struct sctp_transport *transport)
181 return; 181 return;
182 } 182 }
183 183
184 call_rcu(&transport->rcu, sctp_transport_destroy_rcu);
185
186 sctp_packet_free(&transport->packet); 184 sctp_packet_free(&transport->packet);
187 185
188 if (transport->asoc) 186 if (transport->asoc)
189 sctp_association_put(transport->asoc); 187 sctp_association_put(transport->asoc);
188
189 call_rcu(&transport->rcu, sctp_transport_destroy_rcu);
190} 190}
191 191
192/* Start T3_rtx timer if it is not already running and update the heartbeat 192/* Start T3_rtx timer if it is not already running and update the heartbeat
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
index 74f6a704e374..ecbc4e3d83ad 100644
--- a/net/sunrpc/clnt.c
+++ b/net/sunrpc/clnt.c
@@ -1660,6 +1660,10 @@ call_connect(struct rpc_task *task)
1660 task->tk_action = call_connect_status; 1660 task->tk_action = call_connect_status;
1661 if (task->tk_status < 0) 1661 if (task->tk_status < 0)
1662 return; 1662 return;
1663 if (task->tk_flags & RPC_TASK_NOCONNECT) {
1664 rpc_exit(task, -ENOTCONN);
1665 return;
1666 }
1663 xprt_connect(task); 1667 xprt_connect(task);
1664 } 1668 }
1665} 1669}
diff --git a/net/sunrpc/netns.h b/net/sunrpc/netns.h
index 74d948f5d5a1..779742cfc1ff 100644
--- a/net/sunrpc/netns.h
+++ b/net/sunrpc/netns.h
@@ -23,6 +23,7 @@ struct sunrpc_net {
23 struct rpc_clnt *rpcb_local_clnt4; 23 struct rpc_clnt *rpcb_local_clnt4;
24 spinlock_t rpcb_clnt_lock; 24 spinlock_t rpcb_clnt_lock;
25 unsigned int rpcb_users; 25 unsigned int rpcb_users;
26 unsigned int rpcb_is_af_local : 1;
26 27
27 struct mutex gssp_lock; 28 struct mutex gssp_lock;
28 wait_queue_head_t gssp_wq; 29 wait_queue_head_t gssp_wq;
diff --git a/net/sunrpc/rpcb_clnt.c b/net/sunrpc/rpcb_clnt.c
index 3df764dc330c..1891a1022c17 100644
--- a/net/sunrpc/rpcb_clnt.c
+++ b/net/sunrpc/rpcb_clnt.c
@@ -204,13 +204,15 @@ void rpcb_put_local(struct net *net)
204} 204}
205 205
206static void rpcb_set_local(struct net *net, struct rpc_clnt *clnt, 206static void rpcb_set_local(struct net *net, struct rpc_clnt *clnt,
207 struct rpc_clnt *clnt4) 207 struct rpc_clnt *clnt4,
208 bool is_af_local)
208{ 209{
209 struct sunrpc_net *sn = net_generic(net, sunrpc_net_id); 210 struct sunrpc_net *sn = net_generic(net, sunrpc_net_id);
210 211
211 /* Protected by rpcb_create_local_mutex */ 212 /* Protected by rpcb_create_local_mutex */
212 sn->rpcb_local_clnt = clnt; 213 sn->rpcb_local_clnt = clnt;
213 sn->rpcb_local_clnt4 = clnt4; 214 sn->rpcb_local_clnt4 = clnt4;
215 sn->rpcb_is_af_local = is_af_local ? 1 : 0;
214 smp_wmb(); 216 smp_wmb();
215 sn->rpcb_users = 1; 217 sn->rpcb_users = 1;
216 dprintk("RPC: created new rpcb local clients (rpcb_local_clnt: " 218 dprintk("RPC: created new rpcb local clients (rpcb_local_clnt: "
@@ -238,6 +240,14 @@ static int rpcb_create_local_unix(struct net *net)
238 .program = &rpcb_program, 240 .program = &rpcb_program,
239 .version = RPCBVERS_2, 241 .version = RPCBVERS_2,
240 .authflavor = RPC_AUTH_NULL, 242 .authflavor = RPC_AUTH_NULL,
243 /*
244 * We turn off the idle timeout to prevent the kernel
245 * from automatically disconnecting the socket.
246 * Otherwise, we'd have to cache the mount namespace
247 * of the caller and somehow pass that to the socket
248 * reconnect code.
249 */
250 .flags = RPC_CLNT_CREATE_NO_IDLE_TIMEOUT,
241 }; 251 };
242 struct rpc_clnt *clnt, *clnt4; 252 struct rpc_clnt *clnt, *clnt4;
243 int result = 0; 253 int result = 0;
@@ -263,7 +273,7 @@ static int rpcb_create_local_unix(struct net *net)
263 clnt4 = NULL; 273 clnt4 = NULL;
264 } 274 }
265 275
266 rpcb_set_local(net, clnt, clnt4); 276 rpcb_set_local(net, clnt, clnt4, true);
267 277
268out: 278out:
269 return result; 279 return result;
@@ -315,7 +325,7 @@ static int rpcb_create_local_net(struct net *net)
315 clnt4 = NULL; 325 clnt4 = NULL;
316 } 326 }
317 327
318 rpcb_set_local(net, clnt, clnt4); 328 rpcb_set_local(net, clnt, clnt4, false);
319 329
320out: 330out:
321 return result; 331 return result;
@@ -376,13 +386,16 @@ static struct rpc_clnt *rpcb_create(struct net *net, const char *hostname,
376 return rpc_create(&args); 386 return rpc_create(&args);
377} 387}
378 388
379static int rpcb_register_call(struct rpc_clnt *clnt, struct rpc_message *msg) 389static int rpcb_register_call(struct sunrpc_net *sn, struct rpc_clnt *clnt, struct rpc_message *msg, bool is_set)
380{ 390{
381 int result, error = 0; 391 int flags = RPC_TASK_NOCONNECT;
392 int error, result = 0;
382 393
394 if (is_set || !sn->rpcb_is_af_local)
395 flags = RPC_TASK_SOFTCONN;
383 msg->rpc_resp = &result; 396 msg->rpc_resp = &result;
384 397
385 error = rpc_call_sync(clnt, msg, RPC_TASK_SOFTCONN); 398 error = rpc_call_sync(clnt, msg, flags);
386 if (error < 0) { 399 if (error < 0) {
387 dprintk("RPC: failed to contact local rpcbind " 400 dprintk("RPC: failed to contact local rpcbind "
388 "server (errno %d).\n", -error); 401 "server (errno %d).\n", -error);
@@ -439,16 +452,19 @@ int rpcb_register(struct net *net, u32 prog, u32 vers, int prot, unsigned short
439 .rpc_argp = &map, 452 .rpc_argp = &map,
440 }; 453 };
441 struct sunrpc_net *sn = net_generic(net, sunrpc_net_id); 454 struct sunrpc_net *sn = net_generic(net, sunrpc_net_id);
455 bool is_set = false;
442 456
443 dprintk("RPC: %sregistering (%u, %u, %d, %u) with local " 457 dprintk("RPC: %sregistering (%u, %u, %d, %u) with local "
444 "rpcbind\n", (port ? "" : "un"), 458 "rpcbind\n", (port ? "" : "un"),
445 prog, vers, prot, port); 459 prog, vers, prot, port);
446 460
447 msg.rpc_proc = &rpcb_procedures2[RPCBPROC_UNSET]; 461 msg.rpc_proc = &rpcb_procedures2[RPCBPROC_UNSET];
448 if (port) 462 if (port != 0) {
449 msg.rpc_proc = &rpcb_procedures2[RPCBPROC_SET]; 463 msg.rpc_proc = &rpcb_procedures2[RPCBPROC_SET];
464 is_set = true;
465 }
450 466
451 return rpcb_register_call(sn->rpcb_local_clnt, &msg); 467 return rpcb_register_call(sn, sn->rpcb_local_clnt, &msg, is_set);
452} 468}
453 469
454/* 470/*
@@ -461,6 +477,7 @@ static int rpcb_register_inet4(struct sunrpc_net *sn,
461 const struct sockaddr_in *sin = (const struct sockaddr_in *)sap; 477 const struct sockaddr_in *sin = (const struct sockaddr_in *)sap;
462 struct rpcbind_args *map = msg->rpc_argp; 478 struct rpcbind_args *map = msg->rpc_argp;
463 unsigned short port = ntohs(sin->sin_port); 479 unsigned short port = ntohs(sin->sin_port);
480 bool is_set = false;
464 int result; 481 int result;
465 482
466 map->r_addr = rpc_sockaddr2uaddr(sap, GFP_KERNEL); 483 map->r_addr = rpc_sockaddr2uaddr(sap, GFP_KERNEL);
@@ -471,10 +488,12 @@ static int rpcb_register_inet4(struct sunrpc_net *sn,
471 map->r_addr, map->r_netid); 488 map->r_addr, map->r_netid);
472 489
473 msg->rpc_proc = &rpcb_procedures4[RPCBPROC_UNSET]; 490 msg->rpc_proc = &rpcb_procedures4[RPCBPROC_UNSET];
474 if (port) 491 if (port != 0) {
475 msg->rpc_proc = &rpcb_procedures4[RPCBPROC_SET]; 492 msg->rpc_proc = &rpcb_procedures4[RPCBPROC_SET];
493 is_set = true;
494 }
476 495
477 result = rpcb_register_call(sn->rpcb_local_clnt4, msg); 496 result = rpcb_register_call(sn, sn->rpcb_local_clnt4, msg, is_set);
478 kfree(map->r_addr); 497 kfree(map->r_addr);
479 return result; 498 return result;
480} 499}
@@ -489,6 +508,7 @@ static int rpcb_register_inet6(struct sunrpc_net *sn,
489 const struct sockaddr_in6 *sin6 = (const struct sockaddr_in6 *)sap; 508 const struct sockaddr_in6 *sin6 = (const struct sockaddr_in6 *)sap;
490 struct rpcbind_args *map = msg->rpc_argp; 509 struct rpcbind_args *map = msg->rpc_argp;
491 unsigned short port = ntohs(sin6->sin6_port); 510 unsigned short port = ntohs(sin6->sin6_port);
511 bool is_set = false;
492 int result; 512 int result;
493 513
494 map->r_addr = rpc_sockaddr2uaddr(sap, GFP_KERNEL); 514 map->r_addr = rpc_sockaddr2uaddr(sap, GFP_KERNEL);
@@ -499,10 +519,12 @@ static int rpcb_register_inet6(struct sunrpc_net *sn,
499 map->r_addr, map->r_netid); 519 map->r_addr, map->r_netid);
500 520
501 msg->rpc_proc = &rpcb_procedures4[RPCBPROC_UNSET]; 521 msg->rpc_proc = &rpcb_procedures4[RPCBPROC_UNSET];
502 if (port) 522 if (port != 0) {
503 msg->rpc_proc = &rpcb_procedures4[RPCBPROC_SET]; 523 msg->rpc_proc = &rpcb_procedures4[RPCBPROC_SET];
524 is_set = true;
525 }
504 526
505 result = rpcb_register_call(sn->rpcb_local_clnt4, msg); 527 result = rpcb_register_call(sn, sn->rpcb_local_clnt4, msg, is_set);
506 kfree(map->r_addr); 528 kfree(map->r_addr);
507 return result; 529 return result;
508} 530}
@@ -519,7 +541,7 @@ static int rpcb_unregister_all_protofamilies(struct sunrpc_net *sn,
519 map->r_addr = ""; 541 map->r_addr = "";
520 msg->rpc_proc = &rpcb_procedures4[RPCBPROC_UNSET]; 542 msg->rpc_proc = &rpcb_procedures4[RPCBPROC_UNSET];
521 543
522 return rpcb_register_call(sn->rpcb_local_clnt4, msg); 544 return rpcb_register_call(sn, sn->rpcb_local_clnt4, msg, false);
523} 545}
524 546
525/** 547/**
diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c
index cb29ef7ba2f0..609c30c80816 100644
--- a/net/tipc/bearer.c
+++ b/net/tipc/bearer.c
@@ -460,6 +460,7 @@ static void bearer_disable(struct tipc_bearer *b_ptr)
460{ 460{
461 struct tipc_link *l_ptr; 461 struct tipc_link *l_ptr;
462 struct tipc_link *temp_l_ptr; 462 struct tipc_link *temp_l_ptr;
463 struct tipc_link_req *temp_req;
463 464
464 pr_info("Disabling bearer <%s>\n", b_ptr->name); 465 pr_info("Disabling bearer <%s>\n", b_ptr->name);
465 spin_lock_bh(&b_ptr->lock); 466 spin_lock_bh(&b_ptr->lock);
@@ -468,9 +469,13 @@ static void bearer_disable(struct tipc_bearer *b_ptr)
468 list_for_each_entry_safe(l_ptr, temp_l_ptr, &b_ptr->links, link_list) { 469 list_for_each_entry_safe(l_ptr, temp_l_ptr, &b_ptr->links, link_list) {
469 tipc_link_delete(l_ptr); 470 tipc_link_delete(l_ptr);
470 } 471 }
471 if (b_ptr->link_req) 472 temp_req = b_ptr->link_req;
472 tipc_disc_delete(b_ptr->link_req); 473 b_ptr->link_req = NULL;
473 spin_unlock_bh(&b_ptr->lock); 474 spin_unlock_bh(&b_ptr->lock);
475
476 if (temp_req)
477 tipc_disc_delete(temp_req);
478
474 memset(b_ptr, 0, sizeof(struct tipc_bearer)); 479 memset(b_ptr, 0, sizeof(struct tipc_bearer));
475} 480}
476 481
diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
index 593071dabd1c..4d9334683f84 100644
--- a/net/vmw_vsock/af_vsock.c
+++ b/net/vmw_vsock/af_vsock.c
@@ -347,7 +347,7 @@ void vsock_for_each_connected_socket(void (*fn)(struct sock *sk))
347 for (i = 0; i < ARRAY_SIZE(vsock_connected_table); i++) { 347 for (i = 0; i < ARRAY_SIZE(vsock_connected_table); i++) {
348 struct vsock_sock *vsk; 348 struct vsock_sock *vsk;
349 list_for_each_entry(vsk, &vsock_connected_table[i], 349 list_for_each_entry(vsk, &vsock_connected_table[i],
350 connected_table); 350 connected_table)
351 fn(sk_vsock(vsk)); 351 fn(sk_vsock(vsk));
352 } 352 }
353 353
diff --git a/net/wireless/core.c b/net/wireless/core.c
index 4f9f216665e9..a8c29fa4f1b3 100644
--- a/net/wireless/core.c
+++ b/net/wireless/core.c
@@ -765,6 +765,7 @@ void cfg80211_leave(struct cfg80211_registered_device *rdev,
765 cfg80211_leave_mesh(rdev, dev); 765 cfg80211_leave_mesh(rdev, dev);
766 break; 766 break;
767 case NL80211_IFTYPE_AP: 767 case NL80211_IFTYPE_AP:
768 case NL80211_IFTYPE_P2P_GO:
768 cfg80211_stop_ap(rdev, dev); 769 cfg80211_stop_ap(rdev, dev);
769 break; 770 break;
770 default: 771 default:
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 25d217d90807..5f6e982cdcf4 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -441,10 +441,12 @@ static int nl80211_prepare_wdev_dump(struct sk_buff *skb,
441 goto out_unlock; 441 goto out_unlock;
442 } 442 }
443 *rdev = wiphy_to_dev((*wdev)->wiphy); 443 *rdev = wiphy_to_dev((*wdev)->wiphy);
444 cb->args[0] = (*rdev)->wiphy_idx; 444 /* 0 is the first index - add 1 to parse only once */
445 cb->args[0] = (*rdev)->wiphy_idx + 1;
445 cb->args[1] = (*wdev)->identifier; 446 cb->args[1] = (*wdev)->identifier;
446 } else { 447 } else {
447 struct wiphy *wiphy = wiphy_idx_to_wiphy(cb->args[0]); 448 /* subtract the 1 again here */
449 struct wiphy *wiphy = wiphy_idx_to_wiphy(cb->args[0] - 1);
448 struct wireless_dev *tmp; 450 struct wireless_dev *tmp;
449 451
450 if (!wiphy) { 452 if (!wiphy) {
@@ -2620,8 +2622,8 @@ static int nl80211_get_key(struct sk_buff *skb, struct genl_info *info)
2620 2622
2621 hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0, 2623 hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0,
2622 NL80211_CMD_NEW_KEY); 2624 NL80211_CMD_NEW_KEY);
2623 if (IS_ERR(hdr)) 2625 if (!hdr)
2624 return PTR_ERR(hdr); 2626 return -ENOBUFS;
2625 2627
2626 cookie.msg = msg; 2628 cookie.msg = msg;
2627 cookie.idx = key_idx; 2629 cookie.idx = key_idx;
@@ -6505,6 +6507,9 @@ static int nl80211_testmode_dump(struct sk_buff *skb,
6505 NL80211_CMD_TESTMODE); 6507 NL80211_CMD_TESTMODE);
6506 struct nlattr *tmdata; 6508 struct nlattr *tmdata;
6507 6509
6510 if (!hdr)
6511 break;
6512
6508 if (nla_put_u32(skb, NL80211_ATTR_WIPHY, phy_idx)) { 6513 if (nla_put_u32(skb, NL80211_ATTR_WIPHY, phy_idx)) {
6509 genlmsg_cancel(skb, hdr); 6514 genlmsg_cancel(skb, hdr);
6510 break; 6515 break;
@@ -6949,9 +6954,8 @@ static int nl80211_remain_on_channel(struct sk_buff *skb,
6949 6954
6950 hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0, 6955 hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0,
6951 NL80211_CMD_REMAIN_ON_CHANNEL); 6956 NL80211_CMD_REMAIN_ON_CHANNEL);
6952 6957 if (!hdr) {
6953 if (IS_ERR(hdr)) { 6958 err = -ENOBUFS;
6954 err = PTR_ERR(hdr);
6955 goto free_msg; 6959 goto free_msg;
6956 } 6960 }
6957 6961
@@ -7249,9 +7253,8 @@ static int nl80211_tx_mgmt(struct sk_buff *skb, struct genl_info *info)
7249 7253
7250 hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0, 7254 hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0,
7251 NL80211_CMD_FRAME); 7255 NL80211_CMD_FRAME);
7252 7256 if (!hdr) {
7253 if (IS_ERR(hdr)) { 7257 err = -ENOBUFS;
7254 err = PTR_ERR(hdr);
7255 goto free_msg; 7258 goto free_msg;
7256 } 7259 }
7257 } 7260 }
@@ -8130,9 +8133,8 @@ static int nl80211_probe_client(struct sk_buff *skb,
8130 8133
8131 hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0, 8134 hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0,
8132 NL80211_CMD_PROBE_CLIENT); 8135 NL80211_CMD_PROBE_CLIENT);
8133 8136 if (!hdr) {
8134 if (IS_ERR(hdr)) { 8137 err = -ENOBUFS;
8135 err = PTR_ERR(hdr);
8136 goto free_msg; 8138 goto free_msg;
8137 } 8139 }
8138 8140
diff --git a/net/wireless/sme.c b/net/wireless/sme.c
index 81c8a10d743c..20e86a95dc4e 100644
--- a/net/wireless/sme.c
+++ b/net/wireless/sme.c
@@ -976,21 +976,19 @@ int cfg80211_disconnect(struct cfg80211_registered_device *rdev,
976 struct net_device *dev, u16 reason, bool wextev) 976 struct net_device *dev, u16 reason, bool wextev)
977{ 977{
978 struct wireless_dev *wdev = dev->ieee80211_ptr; 978 struct wireless_dev *wdev = dev->ieee80211_ptr;
979 int err; 979 int err = 0;
980 980
981 ASSERT_WDEV_LOCK(wdev); 981 ASSERT_WDEV_LOCK(wdev);
982 982
983 kfree(wdev->connect_keys); 983 kfree(wdev->connect_keys);
984 wdev->connect_keys = NULL; 984 wdev->connect_keys = NULL;
985 985
986 if (wdev->conn) { 986 if (wdev->conn)
987 err = cfg80211_sme_disconnect(wdev, reason); 987 err = cfg80211_sme_disconnect(wdev, reason);
988 } else if (!rdev->ops->disconnect) { 988 else if (!rdev->ops->disconnect)
989 cfg80211_mlme_down(rdev, dev); 989 cfg80211_mlme_down(rdev, dev);
990 err = 0; 990 else if (wdev->current_bss)
991 } else {
992 err = rdev_disconnect(rdev, dev, reason); 991 err = rdev_disconnect(rdev, dev, reason);
993 }
994 992
995 return err; 993 return err;
996} 994}
diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
index 3f7682a387b7..eefbd10e408f 100644
--- a/security/smack/smack_lsm.c
+++ b/security/smack/smack_lsm.c
@@ -1998,12 +1998,11 @@ static void smk_ipv6_port_label(struct socket *sock, struct sockaddr *address)
1998 * 1998 *
1999 * Create or update the port list entry 1999 * Create or update the port list entry
2000 */ 2000 */
2001static int smk_ipv6_port_check(struct sock *sk, struct sockaddr *address, 2001static int smk_ipv6_port_check(struct sock *sk, struct sockaddr_in6 *address,
2002 int act) 2002 int act)
2003{ 2003{
2004 __be16 *bep; 2004 __be16 *bep;
2005 __be32 *be32p; 2005 __be32 *be32p;
2006 struct sockaddr_in6 *addr6;
2007 struct smk_port_label *spp; 2006 struct smk_port_label *spp;
2008 struct socket_smack *ssp = sk->sk_security; 2007 struct socket_smack *ssp = sk->sk_security;
2009 struct smack_known *skp; 2008 struct smack_known *skp;
@@ -2025,10 +2024,9 @@ static int smk_ipv6_port_check(struct sock *sk, struct sockaddr *address,
2025 /* 2024 /*
2026 * Get the IP address and port from the address. 2025 * Get the IP address and port from the address.
2027 */ 2026 */
2028 addr6 = (struct sockaddr_in6 *)address; 2027 port = ntohs(address->sin6_port);
2029 port = ntohs(addr6->sin6_port); 2028 bep = (__be16 *)(&address->sin6_addr);
2030 bep = (__be16 *)(&addr6->sin6_addr); 2029 be32p = (__be32 *)(&address->sin6_addr);
2031 be32p = (__be32 *)(&addr6->sin6_addr);
2032 2030
2033 /* 2031 /*
2034 * It's remote, so port lookup does no good. 2032 * It's remote, so port lookup does no good.
@@ -2060,9 +2058,9 @@ auditout:
2060 ad.a.u.net->family = sk->sk_family; 2058 ad.a.u.net->family = sk->sk_family;
2061 ad.a.u.net->dport = port; 2059 ad.a.u.net->dport = port;
2062 if (act == SMK_RECEIVING) 2060 if (act == SMK_RECEIVING)
2063 ad.a.u.net->v6info.saddr = addr6->sin6_addr; 2061 ad.a.u.net->v6info.saddr = address->sin6_addr;
2064 else 2062 else
2065 ad.a.u.net->v6info.daddr = addr6->sin6_addr; 2063 ad.a.u.net->v6info.daddr = address->sin6_addr;
2066#endif 2064#endif
2067 return smk_access(skp, object, MAY_WRITE, &ad); 2065 return smk_access(skp, object, MAY_WRITE, &ad);
2068} 2066}
@@ -2201,7 +2199,8 @@ static int smack_socket_connect(struct socket *sock, struct sockaddr *sap,
2201 case PF_INET6: 2199 case PF_INET6:
2202 if (addrlen < sizeof(struct sockaddr_in6)) 2200 if (addrlen < sizeof(struct sockaddr_in6))
2203 return -EINVAL; 2201 return -EINVAL;
2204 rc = smk_ipv6_port_check(sock->sk, sap, SMK_CONNECTING); 2202 rc = smk_ipv6_port_check(sock->sk, (struct sockaddr_in6 *)sap,
2203 SMK_CONNECTING);
2205 break; 2204 break;
2206 } 2205 }
2207 return rc; 2206 return rc;
@@ -3034,7 +3033,7 @@ static int smack_socket_sendmsg(struct socket *sock, struct msghdr *msg,
3034 int size) 3033 int size)
3035{ 3034{
3036 struct sockaddr_in *sip = (struct sockaddr_in *) msg->msg_name; 3035 struct sockaddr_in *sip = (struct sockaddr_in *) msg->msg_name;
3037 struct sockaddr *sap = (struct sockaddr *) msg->msg_name; 3036 struct sockaddr_in6 *sap = (struct sockaddr_in6 *) msg->msg_name;
3038 int rc = 0; 3037 int rc = 0;
3039 3038
3040 /* 3039 /*
@@ -3121,9 +3120,8 @@ static struct smack_known *smack_from_secattr(struct netlbl_lsm_secattr *sap,
3121 return smack_net_ambient; 3120 return smack_net_ambient;
3122} 3121}
3123 3122
3124static int smk_skb_to_addr_ipv6(struct sk_buff *skb, struct sockaddr *sap) 3123static int smk_skb_to_addr_ipv6(struct sk_buff *skb, struct sockaddr_in6 *sip)
3125{ 3124{
3126 struct sockaddr_in6 *sip = (struct sockaddr_in6 *)sap;
3127 u8 nexthdr; 3125 u8 nexthdr;
3128 int offset; 3126 int offset;
3129 int proto = -EINVAL; 3127 int proto = -EINVAL;
@@ -3181,7 +3179,7 @@ static int smack_socket_sock_rcv_skb(struct sock *sk, struct sk_buff *skb)
3181 struct netlbl_lsm_secattr secattr; 3179 struct netlbl_lsm_secattr secattr;
3182 struct socket_smack *ssp = sk->sk_security; 3180 struct socket_smack *ssp = sk->sk_security;
3183 struct smack_known *skp; 3181 struct smack_known *skp;
3184 struct sockaddr sadd; 3182 struct sockaddr_in6 sadd;
3185 int rc = 0; 3183 int rc = 0;
3186 struct smk_audit_info ad; 3184 struct smk_audit_info ad;
3187#ifdef CONFIG_AUDIT 3185#ifdef CONFIG_AUDIT
diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c
index 8e77cbbad871..e3c7ba8d7582 100644
--- a/sound/pci/hda/hda_generic.c
+++ b/sound/pci/hda/hda_generic.c
@@ -522,7 +522,7 @@ static bool same_amp_caps(struct hda_codec *codec, hda_nid_t nid1,
522} 522}
523 523
524#define nid_has_mute(codec, nid, dir) \ 524#define nid_has_mute(codec, nid, dir) \
525 check_amp_caps(codec, nid, dir, AC_AMPCAP_MUTE) 525 check_amp_caps(codec, nid, dir, (AC_AMPCAP_MUTE | AC_AMPCAP_MIN_MUTE))
526#define nid_has_volume(codec, nid, dir) \ 526#define nid_has_volume(codec, nid, dir) \
527 check_amp_caps(codec, nid, dir, AC_AMPCAP_NUM_STEPS) 527 check_amp_caps(codec, nid, dir, AC_AMPCAP_NUM_STEPS)
528 528
@@ -624,7 +624,7 @@ static int get_amp_val_to_activate(struct hda_codec *codec, hda_nid_t nid,
624 if (enable) 624 if (enable)
625 val = (caps & AC_AMPCAP_OFFSET) >> AC_AMPCAP_OFFSET_SHIFT; 625 val = (caps & AC_AMPCAP_OFFSET) >> AC_AMPCAP_OFFSET_SHIFT;
626 } 626 }
627 if (caps & AC_AMPCAP_MUTE) { 627 if (caps & (AC_AMPCAP_MUTE | AC_AMPCAP_MIN_MUTE)) {
628 if (!enable) 628 if (!enable)
629 val |= HDA_AMP_MUTE; 629 val |= HDA_AMP_MUTE;
630 } 630 }
@@ -648,7 +648,7 @@ static unsigned int get_amp_mask_to_modify(struct hda_codec *codec,
648{ 648{
649 unsigned int mask = 0xff; 649 unsigned int mask = 0xff;
650 650
651 if (caps & AC_AMPCAP_MUTE) { 651 if (caps & (AC_AMPCAP_MUTE | AC_AMPCAP_MIN_MUTE)) {
652 if (is_ctl_associated(codec, nid, dir, idx, NID_PATH_MUTE_CTL)) 652 if (is_ctl_associated(codec, nid, dir, idx, NID_PATH_MUTE_CTL))
653 mask &= ~0x80; 653 mask &= ~0x80;
654 } 654 }
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 8bd226149868..f303cd898515 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -1031,6 +1031,7 @@ enum {
1031 ALC880_FIXUP_GPIO2, 1031 ALC880_FIXUP_GPIO2,
1032 ALC880_FIXUP_MEDION_RIM, 1032 ALC880_FIXUP_MEDION_RIM,
1033 ALC880_FIXUP_LG, 1033 ALC880_FIXUP_LG,
1034 ALC880_FIXUP_LG_LW25,
1034 ALC880_FIXUP_W810, 1035 ALC880_FIXUP_W810,
1035 ALC880_FIXUP_EAPD_COEF, 1036 ALC880_FIXUP_EAPD_COEF,
1036 ALC880_FIXUP_TCL_S700, 1037 ALC880_FIXUP_TCL_S700,
@@ -1089,6 +1090,14 @@ static const struct hda_fixup alc880_fixups[] = {
1089 { } 1090 { }
1090 } 1091 }
1091 }, 1092 },
1093 [ALC880_FIXUP_LG_LW25] = {
1094 .type = HDA_FIXUP_PINS,
1095 .v.pins = (const struct hda_pintbl[]) {
1096 { 0x1a, 0x0181344f }, /* line-in */
1097 { 0x1b, 0x0321403f }, /* headphone */
1098 { }
1099 }
1100 },
1092 [ALC880_FIXUP_W810] = { 1101 [ALC880_FIXUP_W810] = {
1093 .type = HDA_FIXUP_PINS, 1102 .type = HDA_FIXUP_PINS,
1094 .v.pins = (const struct hda_pintbl[]) { 1103 .v.pins = (const struct hda_pintbl[]) {
@@ -1341,6 +1350,7 @@ static const struct snd_pci_quirk alc880_fixup_tbl[] = {
1341 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_FIXUP_LG), 1350 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_FIXUP_LG),
1342 SND_PCI_QUIRK(0x1854, 0x005f, "LG P1 Express", ALC880_FIXUP_LG), 1351 SND_PCI_QUIRK(0x1854, 0x005f, "LG P1 Express", ALC880_FIXUP_LG),
1343 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_FIXUP_LG), 1352 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_FIXUP_LG),
1353 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_FIXUP_LG_LW25),
1344 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_FIXUP_TCL_S700), 1354 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_FIXUP_TCL_S700),
1345 1355
1346 /* Below is the copied entries from alc880_quirks.c. 1356 /* Below is the copied entries from alc880_quirks.c.
@@ -4329,6 +4339,7 @@ static const struct snd_pci_quirk alc662_fixup_tbl[] = {
4329 SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE), 4339 SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE),
4330 SND_PCI_QUIRK(0x1025, 0x031c, "Gateway NV79", ALC662_FIXUP_SKU_IGNORE), 4340 SND_PCI_QUIRK(0x1025, 0x031c, "Gateway NV79", ALC662_FIXUP_SKU_IGNORE),
4331 SND_PCI_QUIRK(0x1025, 0x0349, "eMachines eM250", ALC662_FIXUP_INV_DMIC), 4341 SND_PCI_QUIRK(0x1025, 0x0349, "eMachines eM250", ALC662_FIXUP_INV_DMIC),
4342 SND_PCI_QUIRK(0x1025, 0x034a, "Gateway LT27", ALC662_FIXUP_INV_DMIC),
4332 SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE), 4343 SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE),
4333 SND_PCI_QUIRK(0x1028, 0x05d8, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE), 4344 SND_PCI_QUIRK(0x1028, 0x05d8, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
4334 SND_PCI_QUIRK(0x1028, 0x05db, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE), 4345 SND_PCI_QUIRK(0x1028, 0x05db, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
diff --git a/sound/soc/codecs/cs42l52.c b/sound/soc/codecs/cs42l52.c
index 987f728718c5..be2ba1b6fe4a 100644
--- a/sound/soc/codecs/cs42l52.c
+++ b/sound/soc/codecs/cs42l52.c
@@ -195,6 +195,8 @@ static DECLARE_TLV_DB_SCALE(pga_tlv, -600, 50, 0);
195 195
196static DECLARE_TLV_DB_SCALE(mix_tlv, -50, 50, 0); 196static DECLARE_TLV_DB_SCALE(mix_tlv, -50, 50, 0);
197 197
198static DECLARE_TLV_DB_SCALE(beep_tlv, -56, 200, 0);
199
198static const unsigned int limiter_tlv[] = { 200static const unsigned int limiter_tlv[] = {
199 TLV_DB_RANGE_HEAD(2), 201 TLV_DB_RANGE_HEAD(2),
200 0, 2, TLV_DB_SCALE_ITEM(-3000, 600, 0), 202 0, 2, TLV_DB_SCALE_ITEM(-3000, 600, 0),
@@ -451,7 +453,8 @@ static const struct snd_kcontrol_new cs42l52_snd_controls[] = {
451 SOC_ENUM("Beep Pitch", beep_pitch_enum), 453 SOC_ENUM("Beep Pitch", beep_pitch_enum),
452 SOC_ENUM("Beep on Time", beep_ontime_enum), 454 SOC_ENUM("Beep on Time", beep_ontime_enum),
453 SOC_ENUM("Beep off Time", beep_offtime_enum), 455 SOC_ENUM("Beep off Time", beep_offtime_enum),
454 SOC_SINGLE_TLV("Beep Volume", CS42L52_BEEP_VOL, 0, 0x1f, 0x07, hl_tlv), 456 SOC_SINGLE_SX_TLV("Beep Volume", CS42L52_BEEP_VOL,
457 0, 0x07, 0x1f, beep_tlv),
455 SOC_SINGLE("Beep Mixer Switch", CS42L52_BEEP_TONE_CTL, 5, 1, 1), 458 SOC_SINGLE("Beep Mixer Switch", CS42L52_BEEP_TONE_CTL, 5, 1, 1),
456 SOC_ENUM("Beep Treble Corner Freq", beep_treble_enum), 459 SOC_ENUM("Beep Treble Corner Freq", beep_treble_enum),
457 SOC_ENUM("Beep Bass Corner Freq", beep_bass_enum), 460 SOC_ENUM("Beep Bass Corner Freq", beep_bass_enum),
diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c
index 6c8a9e7bee25..760e8bfeacaa 100644
--- a/sound/soc/codecs/sgtl5000.c
+++ b/sound/soc/codecs/sgtl5000.c
@@ -153,6 +153,8 @@ static int mic_bias_event(struct snd_soc_dapm_widget *w,
153static int power_vag_event(struct snd_soc_dapm_widget *w, 153static int power_vag_event(struct snd_soc_dapm_widget *w,
154 struct snd_kcontrol *kcontrol, int event) 154 struct snd_kcontrol *kcontrol, int event)
155{ 155{
156 const u32 mask = SGTL5000_DAC_POWERUP | SGTL5000_ADC_POWERUP;
157
156 switch (event) { 158 switch (event) {
157 case SND_SOC_DAPM_POST_PMU: 159 case SND_SOC_DAPM_POST_PMU:
158 snd_soc_update_bits(w->codec, SGTL5000_CHIP_ANA_POWER, 160 snd_soc_update_bits(w->codec, SGTL5000_CHIP_ANA_POWER,
@@ -160,9 +162,17 @@ static int power_vag_event(struct snd_soc_dapm_widget *w,
160 break; 162 break;
161 163
162 case SND_SOC_DAPM_PRE_PMD: 164 case SND_SOC_DAPM_PRE_PMD:
163 snd_soc_update_bits(w->codec, SGTL5000_CHIP_ANA_POWER, 165 /*
164 SGTL5000_VAG_POWERUP, 0); 166 * Don't clear VAG_POWERUP, when both DAC and ADC are
165 msleep(400); 167 * operational to prevent inadvertently starving the
168 * other one of them.
169 */
170 if ((snd_soc_read(w->codec, SGTL5000_CHIP_ANA_POWER) &
171 mask) != mask) {
172 snd_soc_update_bits(w->codec, SGTL5000_CHIP_ANA_POWER,
173 SGTL5000_VAG_POWERUP, 0);
174 msleep(400);
175 }
166 break; 176 break;
167 default: 177 default:
168 break; 178 break;
@@ -388,7 +398,7 @@ static const struct snd_kcontrol_new sgtl5000_snd_controls[] = {
388 SOC_DOUBLE("Capture Volume", SGTL5000_CHIP_ANA_ADC_CTRL, 0, 4, 0xf, 0), 398 SOC_DOUBLE("Capture Volume", SGTL5000_CHIP_ANA_ADC_CTRL, 0, 4, 0xf, 0),
389 SOC_SINGLE_TLV("Capture Attenuate Switch (-6dB)", 399 SOC_SINGLE_TLV("Capture Attenuate Switch (-6dB)",
390 SGTL5000_CHIP_ANA_ADC_CTRL, 400 SGTL5000_CHIP_ANA_ADC_CTRL,
391 8, 2, 0, capture_6db_attenuate), 401 8, 1, 0, capture_6db_attenuate),
392 SOC_SINGLE("Capture ZC Switch", SGTL5000_CHIP_ANA_CTRL, 1, 1, 0), 402 SOC_SINGLE("Capture ZC Switch", SGTL5000_CHIP_ANA_CTRL, 1, 1, 0),
393 403
394 SOC_DOUBLE_TLV("Headphone Playback Volume", 404 SOC_DOUBLE_TLV("Headphone Playback Volume",
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index bd16010441cc..4375c9f2b791 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -679,13 +679,14 @@ static int dapm_new_mux(struct snd_soc_dapm_widget *w)
679 return -EINVAL; 679 return -EINVAL;
680 } 680 }
681 681
682 path = list_first_entry(&w->sources, struct snd_soc_dapm_path, 682 if (list_empty(&w->sources)) {
683 list_sink);
684 if (!path) {
685 dev_err(dapm->dev, "ASoC: mux %s has no paths\n", w->name); 683 dev_err(dapm->dev, "ASoC: mux %s has no paths\n", w->name);
686 return -EINVAL; 684 return -EINVAL;
687 } 685 }
688 686
687 path = list_first_entry(&w->sources, struct snd_soc_dapm_path,
688 list_sink);
689
689 ret = dapm_create_or_share_mixmux_kcontrol(w, 0, path); 690 ret = dapm_create_or_share_mixmux_kcontrol(w, 0, path);
690 if (ret < 0) 691 if (ret < 0)
691 return ret; 692 return ret;
diff --git a/sound/soc/tegra/tegra30_i2s.c b/sound/soc/tegra/tegra30_i2s.c
index d04146cad61f..47565fd04505 100644
--- a/sound/soc/tegra/tegra30_i2s.c
+++ b/sound/soc/tegra/tegra30_i2s.c
@@ -228,7 +228,7 @@ static int tegra30_i2s_hw_params(struct snd_pcm_substream *substream,
228 reg = TEGRA30_I2S_CIF_RX_CTRL; 228 reg = TEGRA30_I2S_CIF_RX_CTRL;
229 } else { 229 } else {
230 val |= TEGRA30_AUDIOCIF_CTRL_DIRECTION_TX; 230 val |= TEGRA30_AUDIOCIF_CTRL_DIRECTION_TX;
231 reg = TEGRA30_I2S_CIF_RX_CTRL; 231 reg = TEGRA30_I2S_CIF_TX_CTRL;
232 } 232 }
233 233
234 regmap_write(i2s->regmap, reg, val); 234 regmap_write(i2s->regmap, reg, val);
diff --git a/sound/usb/6fire/comm.c b/sound/usb/6fire/comm.c
index 9e6e3ffd86bb..23452ee617e1 100644
--- a/sound/usb/6fire/comm.c
+++ b/sound/usb/6fire/comm.c
@@ -110,19 +110,37 @@ static int usb6fire_comm_send_buffer(u8 *buffer, struct usb_device *dev)
110static int usb6fire_comm_write8(struct comm_runtime *rt, u8 request, 110static int usb6fire_comm_write8(struct comm_runtime *rt, u8 request,
111 u8 reg, u8 value) 111 u8 reg, u8 value)
112{ 112{
113 u8 buffer[13]; /* 13: maximum length of message */ 113 u8 *buffer;
114 int ret;
115
116 /* 13: maximum length of message */
117 buffer = kmalloc(13, GFP_KERNEL);
118 if (!buffer)
119 return -ENOMEM;
114 120
115 usb6fire_comm_init_buffer(buffer, 0x00, request, reg, value, 0x00); 121 usb6fire_comm_init_buffer(buffer, 0x00, request, reg, value, 0x00);
116 return usb6fire_comm_send_buffer(buffer, rt->chip->dev); 122 ret = usb6fire_comm_send_buffer(buffer, rt->chip->dev);
123
124 kfree(buffer);
125 return ret;
117} 126}
118 127
119static int usb6fire_comm_write16(struct comm_runtime *rt, u8 request, 128static int usb6fire_comm_write16(struct comm_runtime *rt, u8 request,
120 u8 reg, u8 vl, u8 vh) 129 u8 reg, u8 vl, u8 vh)
121{ 130{
122 u8 buffer[13]; /* 13: maximum length of message */ 131 u8 *buffer;
132 int ret;
133
134 /* 13: maximum length of message */
135 buffer = kmalloc(13, GFP_KERNEL);
136 if (!buffer)
137 return -ENOMEM;
123 138
124 usb6fire_comm_init_buffer(buffer, 0x00, request, reg, vl, vh); 139 usb6fire_comm_init_buffer(buffer, 0x00, request, reg, vl, vh);
125 return usb6fire_comm_send_buffer(buffer, rt->chip->dev); 140 ret = usb6fire_comm_send_buffer(buffer, rt->chip->dev);
141
142 kfree(buffer);
143 return ret;
126} 144}
127 145
128int usb6fire_comm_init(struct sfire_chip *chip) 146int usb6fire_comm_init(struct sfire_chip *chip)
@@ -135,6 +153,12 @@ int usb6fire_comm_init(struct sfire_chip *chip)
135 if (!rt) 153 if (!rt)
136 return -ENOMEM; 154 return -ENOMEM;
137 155
156 rt->receiver_buffer = kzalloc(COMM_RECEIVER_BUFSIZE, GFP_KERNEL);
157 if (!rt->receiver_buffer) {
158 kfree(rt);
159 return -ENOMEM;
160 }
161
138 urb = &rt->receiver; 162 urb = &rt->receiver;
139 rt->serial = 1; 163 rt->serial = 1;
140 rt->chip = chip; 164 rt->chip = chip;
@@ -153,6 +177,7 @@ int usb6fire_comm_init(struct sfire_chip *chip)
153 urb->interval = 1; 177 urb->interval = 1;
154 ret = usb_submit_urb(urb, GFP_KERNEL); 178 ret = usb_submit_urb(urb, GFP_KERNEL);
155 if (ret < 0) { 179 if (ret < 0) {
180 kfree(rt->receiver_buffer);
156 kfree(rt); 181 kfree(rt);
157 snd_printk(KERN_ERR PREFIX "cannot create comm data receiver."); 182 snd_printk(KERN_ERR PREFIX "cannot create comm data receiver.");
158 return ret; 183 return ret;
@@ -171,6 +196,9 @@ void usb6fire_comm_abort(struct sfire_chip *chip)
171 196
172void usb6fire_comm_destroy(struct sfire_chip *chip) 197void usb6fire_comm_destroy(struct sfire_chip *chip)
173{ 198{
174 kfree(chip->comm); 199 struct comm_runtime *rt = chip->comm;
200
201 kfree(rt->receiver_buffer);
202 kfree(rt);
175 chip->comm = NULL; 203 chip->comm = NULL;
176} 204}
diff --git a/sound/usb/6fire/comm.h b/sound/usb/6fire/comm.h
index 6a0840b0dcff..780d5ed8e5d8 100644
--- a/sound/usb/6fire/comm.h
+++ b/sound/usb/6fire/comm.h
@@ -24,7 +24,7 @@ struct comm_runtime {
24 struct sfire_chip *chip; 24 struct sfire_chip *chip;
25 25
26 struct urb receiver; 26 struct urb receiver;
27 u8 receiver_buffer[COMM_RECEIVER_BUFSIZE]; 27 u8 *receiver_buffer;
28 28
29 u8 serial; /* urb serial */ 29 u8 serial; /* urb serial */
30 30
diff --git a/sound/usb/6fire/midi.c b/sound/usb/6fire/midi.c
index 26722423330d..f3dd7266c391 100644
--- a/sound/usb/6fire/midi.c
+++ b/sound/usb/6fire/midi.c
@@ -19,6 +19,10 @@
19#include "chip.h" 19#include "chip.h"
20#include "comm.h" 20#include "comm.h"
21 21
22enum {
23 MIDI_BUFSIZE = 64
24};
25
22static void usb6fire_midi_out_handler(struct urb *urb) 26static void usb6fire_midi_out_handler(struct urb *urb)
23{ 27{
24 struct midi_runtime *rt = urb->context; 28 struct midi_runtime *rt = urb->context;
@@ -156,6 +160,12 @@ int usb6fire_midi_init(struct sfire_chip *chip)
156 if (!rt) 160 if (!rt)
157 return -ENOMEM; 161 return -ENOMEM;
158 162
163 rt->out_buffer = kzalloc(MIDI_BUFSIZE, GFP_KERNEL);
164 if (!rt->out_buffer) {
165 kfree(rt);
166 return -ENOMEM;
167 }
168
159 rt->chip = chip; 169 rt->chip = chip;
160 rt->in_received = usb6fire_midi_in_received; 170 rt->in_received = usb6fire_midi_in_received;
161 rt->out_buffer[0] = 0x80; /* 'send midi' command */ 171 rt->out_buffer[0] = 0x80; /* 'send midi' command */
@@ -169,6 +179,7 @@ int usb6fire_midi_init(struct sfire_chip *chip)
169 179
170 ret = snd_rawmidi_new(chip->card, "6FireUSB", 0, 1, 1, &rt->instance); 180 ret = snd_rawmidi_new(chip->card, "6FireUSB", 0, 1, 1, &rt->instance);
171 if (ret < 0) { 181 if (ret < 0) {
182 kfree(rt->out_buffer);
172 kfree(rt); 183 kfree(rt);
173 snd_printk(KERN_ERR PREFIX "unable to create midi.\n"); 184 snd_printk(KERN_ERR PREFIX "unable to create midi.\n");
174 return ret; 185 return ret;
@@ -197,6 +208,9 @@ void usb6fire_midi_abort(struct sfire_chip *chip)
197 208
198void usb6fire_midi_destroy(struct sfire_chip *chip) 209void usb6fire_midi_destroy(struct sfire_chip *chip)
199{ 210{
200 kfree(chip->midi); 211 struct midi_runtime *rt = chip->midi;
212
213 kfree(rt->out_buffer);
214 kfree(rt);
201 chip->midi = NULL; 215 chip->midi = NULL;
202} 216}
diff --git a/sound/usb/6fire/midi.h b/sound/usb/6fire/midi.h
index c321006e5430..84851b9f5559 100644
--- a/sound/usb/6fire/midi.h
+++ b/sound/usb/6fire/midi.h
@@ -16,10 +16,6 @@
16 16
17#include "common.h" 17#include "common.h"
18 18
19enum {
20 MIDI_BUFSIZE = 64
21};
22
23struct midi_runtime { 19struct midi_runtime {
24 struct sfire_chip *chip; 20 struct sfire_chip *chip;
25 struct snd_rawmidi *instance; 21 struct snd_rawmidi *instance;
@@ -32,7 +28,7 @@ struct midi_runtime {
32 struct snd_rawmidi_substream *out; 28 struct snd_rawmidi_substream *out;
33 struct urb out_urb; 29 struct urb out_urb;
34 u8 out_serial; /* serial number of out packet */ 30 u8 out_serial; /* serial number of out packet */
35 u8 out_buffer[MIDI_BUFSIZE]; 31 u8 *out_buffer;
36 int buffer_offset; 32 int buffer_offset;
37 33
38 void (*in_received)(struct midi_runtime *rt, u8 *data, int length); 34 void (*in_received)(struct midi_runtime *rt, u8 *data, int length);
diff --git a/sound/usb/6fire/pcm.c b/sound/usb/6fire/pcm.c
index 3d2551cc10f2..b5eb97fdc842 100644
--- a/sound/usb/6fire/pcm.c
+++ b/sound/usb/6fire/pcm.c
@@ -582,6 +582,33 @@ static void usb6fire_pcm_init_urb(struct pcm_urb *urb,
582 urb->instance.number_of_packets = PCM_N_PACKETS_PER_URB; 582 urb->instance.number_of_packets = PCM_N_PACKETS_PER_URB;
583} 583}
584 584
585static int usb6fire_pcm_buffers_init(struct pcm_runtime *rt)
586{
587 int i;
588
589 for (i = 0; i < PCM_N_URBS; i++) {
590 rt->out_urbs[i].buffer = kzalloc(PCM_N_PACKETS_PER_URB
591 * PCM_MAX_PACKET_SIZE, GFP_KERNEL);
592 if (!rt->out_urbs[i].buffer)
593 return -ENOMEM;
594 rt->in_urbs[i].buffer = kzalloc(PCM_N_PACKETS_PER_URB
595 * PCM_MAX_PACKET_SIZE, GFP_KERNEL);
596 if (!rt->in_urbs[i].buffer)
597 return -ENOMEM;
598 }
599 return 0;
600}
601
602static void usb6fire_pcm_buffers_destroy(struct pcm_runtime *rt)
603{
604 int i;
605
606 for (i = 0; i < PCM_N_URBS; i++) {
607 kfree(rt->out_urbs[i].buffer);
608 kfree(rt->in_urbs[i].buffer);
609 }
610}
611
585int usb6fire_pcm_init(struct sfire_chip *chip) 612int usb6fire_pcm_init(struct sfire_chip *chip)
586{ 613{
587 int i; 614 int i;
@@ -593,6 +620,13 @@ int usb6fire_pcm_init(struct sfire_chip *chip)
593 if (!rt) 620 if (!rt)
594 return -ENOMEM; 621 return -ENOMEM;
595 622
623 ret = usb6fire_pcm_buffers_init(rt);
624 if (ret) {
625 usb6fire_pcm_buffers_destroy(rt);
626 kfree(rt);
627 return ret;
628 }
629
596 rt->chip = chip; 630 rt->chip = chip;
597 rt->stream_state = STREAM_DISABLED; 631 rt->stream_state = STREAM_DISABLED;
598 rt->rate = ARRAY_SIZE(rates); 632 rt->rate = ARRAY_SIZE(rates);
@@ -614,6 +648,7 @@ int usb6fire_pcm_init(struct sfire_chip *chip)
614 648
615 ret = snd_pcm_new(chip->card, "DMX6FireUSB", 0, 1, 1, &pcm); 649 ret = snd_pcm_new(chip->card, "DMX6FireUSB", 0, 1, 1, &pcm);
616 if (ret < 0) { 650 if (ret < 0) {
651 usb6fire_pcm_buffers_destroy(rt);
617 kfree(rt); 652 kfree(rt);
618 snd_printk(KERN_ERR PREFIX "cannot create pcm instance.\n"); 653 snd_printk(KERN_ERR PREFIX "cannot create pcm instance.\n");
619 return ret; 654 return ret;
@@ -625,6 +660,7 @@ int usb6fire_pcm_init(struct sfire_chip *chip)
625 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &pcm_ops); 660 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &pcm_ops);
626 661
627 if (ret) { 662 if (ret) {
663 usb6fire_pcm_buffers_destroy(rt);
628 kfree(rt); 664 kfree(rt);
629 snd_printk(KERN_ERR PREFIX 665 snd_printk(KERN_ERR PREFIX
630 "error preallocating pcm buffers.\n"); 666 "error preallocating pcm buffers.\n");
@@ -669,6 +705,9 @@ void usb6fire_pcm_abort(struct sfire_chip *chip)
669 705
670void usb6fire_pcm_destroy(struct sfire_chip *chip) 706void usb6fire_pcm_destroy(struct sfire_chip *chip)
671{ 707{
672 kfree(chip->pcm); 708 struct pcm_runtime *rt = chip->pcm;
709
710 usb6fire_pcm_buffers_destroy(rt);
711 kfree(rt);
673 chip->pcm = NULL; 712 chip->pcm = NULL;
674} 713}
diff --git a/sound/usb/6fire/pcm.h b/sound/usb/6fire/pcm.h
index 9b01133ee3fe..f5779d6182c6 100644
--- a/sound/usb/6fire/pcm.h
+++ b/sound/usb/6fire/pcm.h
@@ -32,7 +32,7 @@ struct pcm_urb {
32 struct urb instance; 32 struct urb instance;
33 struct usb_iso_packet_descriptor packets[PCM_N_PACKETS_PER_URB]; 33 struct usb_iso_packet_descriptor packets[PCM_N_PACKETS_PER_URB];
34 /* END DO NOT SEPARATE */ 34 /* END DO NOT SEPARATE */
35 u8 buffer[PCM_N_PACKETS_PER_URB * PCM_MAX_PACKET_SIZE]; 35 u8 *buffer;
36 36
37 struct pcm_urb *peer; 37 struct pcm_urb *peer;
38}; 38};
diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c
index 7a444b5501d9..659950e5b94f 100644
--- a/sound/usb/endpoint.c
+++ b/sound/usb/endpoint.c
@@ -591,17 +591,16 @@ static int data_ep_set_params(struct snd_usb_endpoint *ep,
591 ep->stride = frame_bits >> 3; 591 ep->stride = frame_bits >> 3;
592 ep->silence_value = pcm_format == SNDRV_PCM_FORMAT_U8 ? 0x80 : 0; 592 ep->silence_value = pcm_format == SNDRV_PCM_FORMAT_U8 ? 0x80 : 0;
593 593
594 /* calculate max. frequency */ 594 /* assume max. frequency is 25% higher than nominal */
595 if (ep->maxpacksize) { 595 ep->freqmax = ep->freqn + (ep->freqn >> 2);
596 maxsize = ((ep->freqmax + 0xffff) * (frame_bits >> 3))
597 >> (16 - ep->datainterval);
598 /* but wMaxPacketSize might reduce this */
599 if (ep->maxpacksize && ep->maxpacksize < maxsize) {
596 /* whatever fits into a max. size packet */ 600 /* whatever fits into a max. size packet */
597 maxsize = ep->maxpacksize; 601 maxsize = ep->maxpacksize;
598 ep->freqmax = (maxsize / (frame_bits >> 3)) 602 ep->freqmax = (maxsize / (frame_bits >> 3))
599 << (16 - ep->datainterval); 603 << (16 - ep->datainterval);
600 } else {
601 /* no max. packet size: just take 25% higher than nominal */
602 ep->freqmax = ep->freqn + (ep->freqn >> 2);
603 maxsize = ((ep->freqmax + 0xffff) * (frame_bits >> 3))
604 >> (16 - ep->datainterval);
605 } 604 }
606 605
607 if (ep->fill_max) 606 if (ep->fill_max)
diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
index d5438083fd6a..95558ef4a7a0 100644
--- a/sound/usb/mixer.c
+++ b/sound/usb/mixer.c
@@ -888,6 +888,7 @@ static void volume_control_quirks(struct usb_mixer_elem_info *cval,
888 case USB_ID(0x046d, 0x081b): /* HD Webcam c310 */ 888 case USB_ID(0x046d, 0x081b): /* HD Webcam c310 */
889 case USB_ID(0x046d, 0x081d): /* HD Webcam c510 */ 889 case USB_ID(0x046d, 0x081d): /* HD Webcam c510 */
890 case USB_ID(0x046d, 0x0825): /* HD Webcam c270 */ 890 case USB_ID(0x046d, 0x0825): /* HD Webcam c270 */
891 case USB_ID(0x046d, 0x0826): /* HD Webcam c525 */
891 case USB_ID(0x046d, 0x0991): 892 case USB_ID(0x046d, 0x0991):
892 /* Most audio usb devices lie about volume resolution. 893 /* Most audio usb devices lie about volume resolution.
893 * Most Logitech webcams have res = 384. 894 * Most Logitech webcams have res = 384.
diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c
index 1bc45e71f1fe..0df9ede99dfd 100644
--- a/sound/usb/quirks.c
+++ b/sound/usb/quirks.c
@@ -319,19 +319,19 @@ static int create_auto_midi_quirk(struct snd_usb_audio *chip,
319 if (altsd->bNumEndpoints < 1) 319 if (altsd->bNumEndpoints < 1)
320 return -ENODEV; 320 return -ENODEV;
321 epd = get_endpoint(alts, 0); 321 epd = get_endpoint(alts, 0);
322 if (!usb_endpoint_xfer_bulk(epd) || 322 if (!usb_endpoint_xfer_bulk(epd) &&
323 !usb_endpoint_xfer_int(epd)) 323 !usb_endpoint_xfer_int(epd))
324 return -ENODEV; 324 return -ENODEV;
325 325
326 switch (USB_ID_VENDOR(chip->usb_id)) { 326 switch (USB_ID_VENDOR(chip->usb_id)) {
327 case 0x0499: /* Yamaha */ 327 case 0x0499: /* Yamaha */
328 err = create_yamaha_midi_quirk(chip, iface, driver, alts); 328 err = create_yamaha_midi_quirk(chip, iface, driver, alts);
329 if (err < 0 && err != -ENODEV) 329 if (err != -ENODEV)
330 return err; 330 return err;
331 break; 331 break;
332 case 0x0582: /* Roland */ 332 case 0x0582: /* Roland */
333 err = create_roland_midi_quirk(chip, iface, driver, alts); 333 err = create_roland_midi_quirk(chip, iface, driver, alts);
334 if (err < 0 && err != -ENODEV) 334 if (err != -ENODEV)
335 return err; 335 return err;
336 break; 336 break;
337 } 337 }