aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Molnar <mingo@kernel.org>2014-11-16 04:50:25 -0500
committerIngo Molnar <mingo@kernel.org>2014-11-16 04:50:25 -0500
commite9ac5f0fa8549dffe2a15870217a9c2e7cd557ec (patch)
tree863e0e108f7b7ba2dffc7575bbdfc2d454fc2017
parent44dba3d5d6a10685fb15bd1954e62016334825e0 (diff)
parent6e998916dfe327e785e7c2447959b2c1a3ea4930 (diff)
Merge branch 'sched/urgent' into sched/core, to pick up fixes before applying more changes
Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r--Documentation/ABI/testing/sysfs-ibft2
-rw-r--r--Documentation/DocBook/media/Makefile2
-rw-r--r--Documentation/DocBook/media/v4l/compat.xml4
-rw-r--r--Documentation/HOWTO1
-rw-r--r--Documentation/SubmittingPatches10
-rw-r--r--Documentation/development-process/2.Process4
-rw-r--r--Documentation/development-process/8.Conclusion4
-rw-r--r--Documentation/devicetree/bindings/net/smsc-lan91c111.txt2
-rw-r--r--Documentation/devicetree/bindings/sound/sgtl5000.txt10
-rw-r--r--Documentation/devicetree/bindings/submitting-patches.txt3
-rw-r--r--Documentation/kernel-parameters.txt16
-rw-r--r--Documentation/kmemleak.txt4
-rw-r--r--Documentation/prctl/Makefile2
-rw-r--r--Documentation/ptp/testptp.mk33
-rw-r--r--Documentation/vDSO/Makefile3
-rw-r--r--Documentation/vDSO/vdso_standalone_test_x86.c2
-rw-r--r--Documentation/vm/hugetlbpage.txt2
-rw-r--r--MAINTAINERS15
-rw-r--r--Makefile4
-rw-r--r--arch/arm/Kconfig.debug2
-rw-r--r--arch/arm/boot/dts/omap3-n900.dts2
-rw-r--r--arch/arm/configs/multi_v7_defconfig2
-rw-r--r--arch/arm/configs/omap2plus_defconfig4
-rw-r--r--arch/arm/configs/socfpga_defconfig71
-rw-r--r--arch/arm/include/uapi/asm/unistd.h1
-rw-r--r--arch/arm/kernel/asm-offsets.c12
-rw-r--r--arch/arm/kernel/calls.S1
-rw-r--r--arch/arm/mach-ixp4xx/include/mach/io.h4
-rw-r--r--arch/arm/mach-omap2/omap_device.c4
-rw-r--r--arch/arm/mach-omap2/pdata-quirks.c3
-rw-r--r--arch/arm/mach-pxa/include/mach/addr-map.h5
-rw-r--r--arch/arm/mm/cache-l2x0.c26
-rw-r--r--arch/arm/mm/dma-mapping.c1
-rw-r--r--arch/arm/mm/highmem.c3
-rw-r--r--arch/arm/mm/init.c8
-rw-r--r--arch/m68k/include/asm/unistd.h2
-rw-r--r--arch/m68k/include/uapi/asm/unistd.h1
-rw-r--r--arch/m68k/kernel/syscalltable.S1
-rw-r--r--arch/microblaze/Kconfig4
-rw-r--r--arch/microblaze/include/asm/unistd.h2
-rw-r--r--arch/microblaze/include/uapi/asm/unistd.h1
-rw-r--r--arch/microblaze/kernel/syscall_table.S1
-rw-r--r--arch/microblaze/pci/pci-common.c9
-rw-r--r--arch/powerpc/include/asm/hugetlb.h2
-rw-r--r--arch/powerpc/include/asm/systbl.h1
-rw-r--r--arch/powerpc/include/asm/unistd.h2
-rw-r--r--arch/powerpc/include/uapi/asm/unistd.h1
-rw-r--r--arch/powerpc/mm/copro_fault.c3
-rw-r--r--arch/powerpc/mm/numa.c7
-rw-r--r--arch/powerpc/mm/slice.c3
-rw-r--r--arch/powerpc/perf/hv-24x7.c6
-rw-r--r--arch/powerpc/perf/hv-gpci.c6
-rw-r--r--arch/powerpc/platforms/powernv/opal-lpc.c4
-rw-r--r--arch/powerpc/platforms/powernv/opal-wrappers.S2
-rw-r--r--arch/s390/kernel/perf_cpum_sf.c6
-rw-r--r--arch/sh/kernel/cpu/sh3/setup-sh770x.c6
-rw-r--r--arch/sparc/include/uapi/asm/unistd.h3
-rw-r--r--arch/sparc/kernel/systbls_32.S2
-rw-r--r--arch/sparc/kernel/systbls_64.S4
-rw-r--r--arch/x86/Kconfig4
-rw-r--r--arch/x86/ia32/ia32entry.S2
-rw-r--r--arch/x86/kernel/acpi/boot.c16
-rw-r--r--arch/x86/kernel/apb_timer.c2
-rw-r--r--arch/x86/kernel/apic/apic.c4
-rw-r--r--arch/x86/kernel/cpu/Makefile7
-rw-r--r--arch/x86/kernel/cpu/intel.c5
-rw-r--r--arch/x86/kernel/cpu/perf_event.c14
-rw-r--r--arch/x86/kernel/cpu/perf_event.h1
-rw-r--r--arch/x86/kernel/cpu/perf_event_intel.c173
-rw-r--r--arch/x86/kernel/entry_32.S15
-rw-r--r--arch/x86/kernel/i8259.c3
-rw-r--r--arch/x86/kernel/irqinit.c3
-rw-r--r--arch/x86/kernel/setup.c2
-rw-r--r--arch/x86/kernel/smpboot.c4
-rw-r--r--arch/x86/kernel/tsc.c5
-rw-r--r--arch/x86/kvm/emulate.c55
-rw-r--r--arch/x86/kvm/vmx.c6
-rw-r--r--arch/x86/mm/pageattr.c2
-rw-r--r--arch/x86/platform/intel-mid/sfi.c2
-rw-r--r--block/blk-merge.c5
-rw-r--r--block/elevator.c4
-rw-r--r--block/scsi_ioctl.c3
-rw-r--r--drivers/acpi/ec.c31
-rw-r--r--drivers/acpi/scan.c70
-rw-r--r--drivers/base/dma-contiguous.c3
-rw-r--r--drivers/base/power/main.c2
-rw-r--r--drivers/bcma/host_pci.c5
-rw-r--r--drivers/bcma/main.c2
-rw-r--r--drivers/block/null_blk.c14
-rw-r--r--drivers/block/rbd.c35
-rw-r--r--drivers/block/sunvdc.c9
-rw-r--r--drivers/block/zram/zram_drv.c10
-rw-r--r--drivers/char/raw.c2
-rw-r--r--drivers/clocksource/arm_arch_timer.c6
-rw-r--r--drivers/cpufreq/cpufreq-dt.c68
-rw-r--r--drivers/edac/cpc925_edac.c2
-rw-r--r--drivers/edac/e7xxx_edac.c2
-rw-r--r--drivers/edac/i3200_edac.c4
-rw-r--r--drivers/edac/i82860_edac.c2
-rw-r--r--drivers/gpu/drm/armada/armada_crtc.c21
-rw-r--r--drivers/gpu/drm/armada/armada_drv.c3
-rw-r--r--drivers/gpu/drm/exynos/exynos_dp_core.c5
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_crtc.c5
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_dpi.c4
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_drv.c43
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_dsi.c4
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_vidi.c4
-rw-r--r--drivers/gpu/drm/exynos/exynos_hdmi.c6
-rw-r--r--drivers/gpu/drm/i915/intel_display.c5
-rw-r--r--drivers/gpu/drm/i915/intel_dp.c24
-rw-r--r--drivers/gpu/drm/radeon/evergreen.c4
-rw-r--r--drivers/gpu/drm/radeon/kv_dpm.c19
-rw-r--r--drivers/gpu/drm/radeon/radeon_bios.c6
-rw-r--r--drivers/gpu/drm/radeon/radeon_cs.c2
-rw-r--r--drivers/gpu/drm/radeon/radeon_ring.c4
-rw-r--r--drivers/gpu/drm/radeon/radeon_vm.c4
-rw-r--r--drivers/gpu/drm/radeon/si_dpm.c2
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c3
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_drv.c6
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_kms.c24
-rw-r--r--drivers/hid/hid-debug.c6
-rw-r--r--drivers/hid/hid-ids.h2
-rw-r--r--drivers/hid/hid-input.c12
-rw-r--r--drivers/hid/usbhid/hid-quirks.c2
-rw-r--r--drivers/iio/common/st_sensors/st_sensors_buffer.c2
-rw-r--r--drivers/infiniband/hw/mlx4/main.c10
-rw-r--r--drivers/input/keyboard/opencores-kbd.c2
-rw-r--r--drivers/input/keyboard/stmpe-keypad.c2
-rw-r--r--drivers/input/misc/ims-pcu.c2
-rw-r--r--drivers/input/misc/max77693-haptic.c5
-rw-r--r--drivers/input/misc/soc_button_array.c2
-rw-r--r--drivers/input/mouse/psmouse-base.c7
-rw-r--r--drivers/input/mouse/vsxxxaa.c2
-rw-r--r--drivers/input/serio/altera_ps2.c4
-rw-r--r--drivers/input/serio/i8042-x86ia64io.h297
-rw-r--r--drivers/input/serio/i8042.c2
-rw-r--r--drivers/input/touchscreen/wm97xx-core.c4
-rw-r--r--drivers/media/common/saa7146/saa7146_core.c6
-rw-r--r--drivers/media/pci/cx23885/cx23885-dvb.c3
-rw-r--r--drivers/media/pci/tw68/Kconfig1
-rw-r--r--drivers/media/pci/tw68/tw68-core.c2
-rw-r--r--drivers/media/platform/Kconfig6
-rw-r--r--drivers/media/platform/exynos4-is/Kconfig2
-rw-r--r--drivers/media/platform/exynos4-is/fimc-core.c2
-rw-r--r--drivers/media/platform/s5p-jpeg/jpeg-core.c6
-rw-r--r--drivers/media/platform/s5p-tv/Kconfig2
-rw-r--r--drivers/media/platform/vivid/Kconfig5
-rw-r--r--drivers/media/platform/vivid/vivid-tpg.c2
-rw-r--r--drivers/media/radio/wl128x/fmdrv_common.c2
-rw-r--r--drivers/media/tuners/xc5000.c2
-rw-r--r--drivers/media/usb/dvb-usb-v2/af9035.c6
-rw-r--r--drivers/media/usb/dvb-usb-v2/anysee.c6
-rw-r--r--drivers/media/usb/em28xx/em28xx-core.c2
-rw-r--r--drivers/media/usb/em28xx/em28xx-input.c4
-rw-r--r--drivers/media/usb/hackrf/hackrf.c2
-rw-r--r--drivers/media/usb/usbvision/usbvision-video.c2
-rw-r--r--drivers/media/usb/uvc/uvc_v4l2.c1
-rw-r--r--drivers/media/usb/uvc/uvc_video.c2
-rw-r--r--drivers/media/usb/uvc/uvcvideo.h1
-rw-r--r--drivers/media/v4l2-core/videobuf-dma-contig.c9
-rw-r--r--drivers/misc/cxl/fault.c74
-rw-r--r--drivers/misc/cxl/native.c4
-rw-r--r--drivers/mtd/chips/cfi_cmdset_0001.c2
-rw-r--r--drivers/mtd/devices/m25p80.c64
-rw-r--r--drivers/mtd/nand/omap_elm.c2
-rw-r--r--drivers/mtd/spi-nor/fsl-quadspi.c7
-rw-r--r--drivers/mtd/spi-nor/spi-nor.c16
-rw-r--r--drivers/net/Kconfig2
-rw-r--r--drivers/net/dsa/mv88e6171.c2
-rw-r--r--drivers/net/ethernet/amd/xgbe/xgbe-drv.c22
-rw-r--r--drivers/net/ethernet/apm/xgene/xgene_enet_sgmac.c16
-rw-r--r--drivers/net/ethernet/broadcom/bcmsysport.c11
-rw-r--r--drivers/net/ethernet/broadcom/cnic.c5
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.c55
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c7
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c16
-rw-r--r--drivers/net/ethernet/cisco/enic/enic_clsf.c12
-rw-r--r--drivers/net/ethernet/cisco/enic/enic_main.c4
-rw-r--r--drivers/net/ethernet/freescale/fec_main.c3
-rw-r--r--drivers/net/ethernet/freescale/fs_enet/mac-fec.c3
-rw-r--r--drivers/net/ethernet/freescale/fs_enet/mac-scc.c3
-rw-r--r--drivers/net/ethernet/intel/e1000/e1000_main.c5
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_main.c4
-rw-r--r--drivers/net/ethernet/intel/igb/igb_main.c6
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c4
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_main.c2
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_tx.c7
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/eq.c1
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/mcg.c4
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/eq.c1
-rw-r--r--drivers/net/ethernet/sfc/tx.c4
-rw-r--r--drivers/net/ethernet/smsc/smc91x.c58
-rw-r--r--drivers/net/ethernet/smsc/smc91x.h3
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c7
-rw-r--r--drivers/net/ethernet/ti/cpsw.c48
-rw-r--r--drivers/net/ethernet/ti/cpsw_ale.c29
-rw-r--r--drivers/net/ethernet/ti/cpsw_ale.h2
-rw-r--r--drivers/net/hyperv/netvsc_drv.c1
-rw-r--r--drivers/net/macvlan.c10
-rw-r--r--drivers/net/macvtap.c16
-rw-r--r--drivers/net/phy/marvell.c19
-rw-r--r--drivers/net/tun.c25
-rw-r--r--drivers/net/usb/ax88179_178a.c7
-rw-r--r--drivers/net/usb/cdc_ether.c47
-rw-r--r--drivers/net/usb/r8152.c17
-rw-r--r--drivers/net/usb/usbnet.c20
-rw-r--r--drivers/net/virtio_net.c24
-rw-r--r--drivers/net/wireless/ath/ath.h1
-rw-r--r--drivers/net/wireless/ath/ath9k/common.c8
-rw-r--r--drivers/net/wireless/ath/ath9k/debug.c2
-rw-r--r--drivers/net/wireless/ath/ath9k/init.c55
-rw-r--r--drivers/net/wireless/ath/ath9k/main.c3
-rw-r--r--drivers/net/wireless/ath/ath9k/xmit.c10
-rw-r--r--drivers/net/wireless/ath/regd.c14
-rw-r--r--drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c25
-rw-r--r--drivers/net/wireless/iwlwifi/dvm/mac80211.c24
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-8000.c3
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-trans.h2
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/coex.c4
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/coex_legacy.c4
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/fw-api-power.h35
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/fw-api.h1
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/fw.c9
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/mac80211.c32
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/ops.c1
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/scan.c3
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/time-event.c2
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/tx.c8
-rw-r--r--drivers/net/wireless/iwlwifi/pcie/trans.c22
-rw-r--r--drivers/net/wireless/mwifiex/11n_rxreorder.c52
-rw-r--r--drivers/net/wireless/mwifiex/11n_rxreorder.h2
-rw-r--r--drivers/net/wireless/mwifiex/main.h1
-rw-r--r--drivers/net/wireless/rt2x00/rt2800usb.c1
-rw-r--r--drivers/net/wireless/rtlwifi/base.c2
-rw-r--r--drivers/net/wireless/rtlwifi/core.c6
-rw-r--r--drivers/net/wireless/rtlwifi/core.h1
-rw-r--r--drivers/net/wireless/rtlwifi/pci.c3
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c8
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192c/fw_common.h4
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192ce/def.h2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192ce/hw.c2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192ce/sw.c1
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192ce/trx.c3
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192cu/hw.c17
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192cu/hw.h1
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192cu/sw.c7
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192de/sw.c1
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192ee/hw.c8
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192se/def.h2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192se/sw.c22
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192se/trx.c3
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8821ae/phy.c15
-rw-r--r--drivers/net/wireless/rtlwifi/usb.c11
-rw-r--r--drivers/net/xen-netback/common.h39
-rw-r--r--drivers/net/xen-netback/interface.c74
-rw-r--r--drivers/net/xen-netback/netback.c319
-rw-r--r--drivers/net/xen-netback/xenbus.c22
-rw-r--r--drivers/of/of_reserved_mem.c14
-rw-r--r--drivers/pci/host/pci-imx6.c13
-rw-r--r--drivers/pci/hotplug/pciehp_core.c7
-rw-r--r--drivers/pci/pci-sysfs.c8
-rw-r--r--drivers/pinctrl/pinctrl-baytrail.c8
-rw-r--r--drivers/regulator/rk808-regulator.c2
-rw-r--r--drivers/rtc/Kconfig2
-rw-r--r--drivers/rtc/rtc-bq32k.c2
-rw-r--r--drivers/rtc/rtc-pm8xxx.c222
-rw-r--r--drivers/rtc/rtc-s3c.c14
-rw-r--r--drivers/scsi/cxgbi/libcxgbi.c42
-rw-r--r--drivers/scsi/cxgbi/libcxgbi.h5
-rw-r--r--drivers/scsi/scsi_lib.c5
-rw-r--r--drivers/soc/versatile/soc-realview.c1
-rw-r--r--drivers/spi/spi-dw.c1
-rw-r--r--drivers/spi/spi-orion.c2
-rw-r--r--drivers/spi/spi-pl022.c2
-rw-r--r--drivers/spi/spi-rockchip.c50
-rw-r--r--drivers/spi/spidev.c79
-rw-r--r--drivers/staging/android/logger.c13
-rw-r--r--drivers/staging/comedi/Kconfig2
-rw-r--r--drivers/staging/comedi/comedi_fops.c26
-rw-r--r--drivers/staging/iio/adc/mxs-lradc.c12
-rw-r--r--drivers/staging/iio/impedance-analyzer/ad5933.c15
-rw-r--r--drivers/staging/rtl8723au/include/rtw_eeprom.h2
-rw-r--r--drivers/usb/chipidea/core.c1
-rw-r--r--drivers/usb/dwc2/core.h2
-rw-r--r--drivers/usb/dwc2/gadget.c14
-rw-r--r--drivers/usb/dwc3/dwc3-omap.c15
-rw-r--r--drivers/usb/dwc3/dwc3-pci.c2
-rw-r--r--drivers/usb/dwc3/ep0.c48
-rw-r--r--drivers/usb/dwc3/gadget.c39
-rw-r--r--drivers/usb/dwc3/gadget.h3
-rw-r--r--drivers/usb/dwc3/trace.h53
-rw-r--r--drivers/usb/gadget/composite.c2
-rw-r--r--drivers/usb/gadget/function/f_acm.c8
-rw-r--r--drivers/usb/gadget/function/f_eem.c1
-rw-r--r--drivers/usb/gadget/function/f_fs.c42
-rw-r--r--drivers/usb/gadget/function/f_hid.c5
-rw-r--r--drivers/usb/gadget/function/f_loopback.c87
-rw-r--r--drivers/usb/gadget/function/f_ncm.c1
-rw-r--r--drivers/usb/gadget/function/f_obex.c9
-rw-r--r--drivers/usb/gadget/function/f_phonet.c2
-rw-r--r--drivers/usb/gadget/function/f_rndis.c9
-rw-r--r--drivers/usb/gadget/function/f_subset.c1
-rw-r--r--drivers/usb/gadget/function/f_uac2.c23
-rw-r--r--drivers/usb/gadget/function/f_uvc.c54
-rw-r--r--drivers/usb/gadget/function/uvc_video.c3
-rw-r--r--drivers/usb/gadget/udc/Kconfig1
-rw-r--r--drivers/usb/gadget/udc/udc-core.c5
-rw-r--r--drivers/usb/musb/musb_cppi41.c3
-rw-r--r--drivers/usb/musb/musb_dsps.c18
-rw-r--r--drivers/usb/serial/cp210x.c1
-rw-r--r--drivers/usb/serial/ftdi_sio.c3
-rw-r--r--drivers/usb/serial/ftdi_sio_ids.h12
-rw-r--r--drivers/usb/serial/kobil_sct.c15
-rw-r--r--drivers/usb/serial/option.c10
-rw-r--r--drivers/video/console/fbcon.c19
-rw-r--r--drivers/video/console/vgacon.c24
-rw-r--r--drivers/video/fbdev/atmel_lcdfb.c1
-rw-r--r--drivers/video/fbdev/omap2/displays-new/connector-analog-tv.c3
-rw-r--r--drivers/video/fbdev/omap2/displays-new/connector-dvi.c1
-rw-r--r--drivers/video/fbdev/omap2/displays-new/connector-hdmi.c1
-rw-r--r--drivers/video/fbdev/omap2/displays-new/encoder-tfp410.c1
-rw-r--r--drivers/video/fbdev/omap2/displays-new/encoder-tpd12s015.c1
-rw-r--r--drivers/video/fbdev/omap2/displays-new/panel-dpi.c1
-rw-r--r--drivers/video/fbdev/omap2/displays-new/panel-dsi-cm.c1
-rw-r--r--drivers/video/fbdev/omap2/displays-new/panel-lgphilips-lb035q02.c1
-rw-r--r--drivers/video/fbdev/omap2/displays-new/panel-nec-nl8048hl11.c1
-rw-r--r--drivers/video/fbdev/omap2/displays-new/panel-sharp-ls037v7dw01.c1
-rw-r--r--drivers/video/fbdev/omap2/displays-new/panel-sony-acx565akm.c1
-rw-r--r--drivers/video/fbdev/omap2/displays-new/panel-tpo-td028ttec1.c1
-rw-r--r--drivers/video/fbdev/omap2/displays-new/panel-tpo-td043mtea1.c1
-rw-r--r--drivers/video/fbdev/omap2/dss/apply.c2
-rw-r--r--drivers/video/fbdev/omap2/dss/dispc.c8
-rw-r--r--drivers/video/fbdev/omap2/dss/dispc.h3
-rw-r--r--drivers/video/fbdev/omap2/dss/dpi.c1
-rw-r--r--drivers/video/fbdev/omap2/dss/dsi.c3
-rw-r--r--drivers/video/fbdev/omap2/dss/dss.c1
-rw-r--r--drivers/video/fbdev/omap2/dss/hdmi4.c1
-rw-r--r--drivers/video/fbdev/omap2/dss/hdmi5.c1
-rw-r--r--drivers/video/fbdev/omap2/dss/hdmi_pll.c13
-rw-r--r--drivers/video/fbdev/omap2/dss/rfbi.c1
-rw-r--r--drivers/video/fbdev/omap2/dss/sdi.c1
-rw-r--r--drivers/video/fbdev/omap2/dss/venc.c1
-rw-r--r--drivers/video/fbdev/omap2/omapfb/omapfb-main.c18
-rw-r--r--fs/block_dev.c3
-rw-r--r--fs/btrfs/ctree.h2
-rw-r--r--fs/btrfs/disk-io.c43
-rw-r--r--fs/btrfs/extent-tree.c18
-rw-r--r--fs/btrfs/super.c1
-rw-r--r--fs/btrfs/tree-log.c2
-rw-r--r--fs/buffer.c38
-rw-r--r--fs/ext3/super.c7
-rw-r--r--fs/ext4/extents.c9
-rw-r--r--fs/ext4/file.c2
-rw-r--r--fs/ext4/ialloc.c4
-rw-r--r--fs/ext4/inode.c7
-rw-r--r--fs/ext4/namei.c28
-rw-r--r--fs/ext4/resize.c2
-rw-r--r--fs/ext4/super.c17
-rw-r--r--fs/isofs/inode.c24
-rw-r--r--fs/isofs/namei.c22
-rw-r--r--fs/jbd/revoke.c7
-rw-r--r--fs/jbd2/revoke.c10
-rw-r--r--fs/namei.c5
-rw-r--r--fs/nfsd/nfs4proc.c7
-rw-r--r--fs/notify/inode_mark.c17
-rw-r--r--fs/ocfs2/namei.c2
-rw-r--r--fs/overlayfs/readdir.c17
-rw-r--r--fs/quota/dquot.c2
-rw-r--r--include/drm/drm_pciids.h1
-rw-r--r--include/linux/blkdev.h7
-rw-r--r--include/linux/cma.h8
-rw-r--r--include/linux/compiler-gcc4.h1
-rw-r--r--include/linux/compiler-gcc5.h1
-rw-r--r--include/linux/fs.h10
-rw-r--r--include/linux/kernel_stat.h5
-rw-r--r--include/linux/khugepaged.h17
-rw-r--r--include/linux/memcontrol.h58
-rw-r--r--include/linux/mm.h1
-rw-r--r--include/linux/mtd/spi-nor.h21
-rw-r--r--include/linux/of_reserved_mem.h9
-rw-r--r--include/linux/rcupdate.h15
-rw-r--r--include/linux/regulator/consumer.h2
-rw-r--r--include/linux/skbuff.h12
-rw-r--r--include/linux/usb/usbnet.h4
-rw-r--r--include/net/ipv6.h2
-rw-r--r--include/net/netfilter/ipv4/nf_reject.h10
-rw-r--r--include/net/netfilter/ipv6/nf_reject.h10
-rw-r--r--include/net/netfilter/nf_tables.h3
-rw-r--r--include/net/netfilter/nft_masq.h3
-rw-r--r--include/scsi/scsi_tcq.h8
-rw-r--r--include/trace/events/rcu.h18
-rw-r--r--include/uapi/linux/input.h7
-rw-r--r--include/uapi/linux/perf_event.h14
-rw-r--r--include/uapi/linux/v4l2-dv-timings.h9
-rw-r--r--init/Kconfig14
-rw-r--r--kernel/Makefile2
-rw-r--r--kernel/bpf/Makefile6
-rw-r--r--kernel/bpf/core.c9
-rw-r--r--kernel/bpf/verifier.c3
-rw-r--r--kernel/cpu.c14
-rw-r--r--kernel/events/core.c15
-rw-r--r--kernel/events/hw_breakpoint.c7
-rw-r--r--kernel/futex.c36
-rw-r--r--kernel/gcov/Kconfig2
-rw-r--r--kernel/kmod.c76
-rw-r--r--kernel/power/hibernate.c8
-rw-r--r--kernel/rcu/tree.c15
-rw-r--r--kernel/rcu/tree.h1
-rw-r--r--kernel/rcu/tree_plugin.h33
-rw-r--r--kernel/sched/core.c63
-rw-r--r--kernel/sched/deadline.c2
-rw-r--r--kernel/sched/fair.c14
-rw-r--r--kernel/sched/rt.c2
-rw-r--r--kernel/sched/sched.h2
-rw-r--r--kernel/time/clockevents.c2
-rw-r--r--kernel/time/posix-cpu-timers.c2
-rw-r--r--kernel/time/posix-timers.c1
-rw-r--r--kernel/trace/ftrace.c54
-rw-r--r--kernel/trace/trace_syscalls.c8
-rw-r--r--lib/bitmap.c8
-rw-r--r--lib/scatterlist.c6
-rw-r--r--mm/balloon_compaction.c2
-rw-r--r--mm/cma.c68
-rw-r--r--mm/compaction.c3
-rw-r--r--mm/huge_memory.c15
-rw-r--r--mm/memcontrol.c105
-rw-r--r--mm/memory.c1
-rw-r--r--mm/memory_hotplug.c5
-rw-r--r--mm/mmap.c8
-rw-r--r--mm/page-writeback.c43
-rw-r--r--mm/page_cgroup.c1
-rw-r--r--mm/rmap.c88
-rw-r--r--mm/slab_common.c10
-rw-r--r--net/Kconfig2
-rw-r--r--net/bridge/br_forward.c1
-rw-r--r--net/bridge/br_netfilter.c24
-rw-r--r--net/bridge/netfilter/nf_tables_bridge.c6
-rw-r--r--net/bridge/netfilter/nft_reject_bridge.c296
-rw-r--r--net/ceph/auth_x.c25
-rw-r--r--net/ceph/messenger.c10
-rw-r--r--net/core/dev.c4
-rw-r--r--net/core/ethtool.c6
-rw-r--r--net/core/skbuff.c13
-rw-r--r--net/core/tso.c3
-rw-r--r--net/dsa/dsa.c5
-rw-r--r--net/ipv4/af_inet.c2
-rw-r--r--net/ipv4/gre_offload.c4
-rw-r--r--net/ipv4/inet_fragment.c4
-rw-r--r--net/ipv4/ip_output.c2
-rw-r--r--net/ipv4/netfilter/nf_reject_ipv4.c91
-rw-r--r--net/ipv4/netfilter/nft_masq_ipv4.c1
-rw-r--r--net/ipv4/route.c1
-rw-r--r--net/ipv4/tcp.c59
-rw-r--r--net/ipv4/tcp_ipv4.c4
-rw-r--r--net/ipv4/tcp_output.c2
-rw-r--r--net/ipv4/udp_offload.c2
-rw-r--r--net/ipv6/addrconf.c1
-rw-r--r--net/ipv6/ip6_offload.c2
-rw-r--r--net/ipv6/netfilter/nf_reject_ipv6.c179
-rw-r--r--net/ipv6/netfilter/nft_masq_ipv6.c1
-rw-r--r--net/ipv6/output_core.c34
-rw-r--r--net/ipv6/tcp_ipv6.c4
-rw-r--r--net/ipv6/xfrm6_policy.c11
-rw-r--r--net/irda/af_irda.c2
-rw-r--r--net/mac80211/cfg.c2
-rw-r--r--net/mac80211/rate.c2
-rw-r--r--net/mac80211/rc80211_minstrel_debugfs.c12
-rw-r--r--net/mac80211/rc80211_minstrel_ht_debugfs.c13
-rw-r--r--net/mac80211/sta_info.h1
-rw-r--r--net/mpls/Makefile2
-rw-r--r--net/mpls/mpls_gso.c5
-rw-r--r--net/netfilter/ipset/ip_set_core.c2
-rw-r--r--net/netfilter/ipvs/ip_vs_xmit.c4
-rw-r--r--net/netfilter/nf_conntrack_proto_tcp.c4
-rw-r--r--net/netfilter/nf_tables_api.c18
-rw-r--r--net/netfilter/nfnetlink_log.c31
-rw-r--r--net/netfilter/nfnetlink_queue_core.c2
-rw-r--r--net/netfilter/nft_compat.c81
-rw-r--r--net/netfilter/nft_masq.c12
-rw-r--r--net/netfilter/nft_nat.c86
-rw-r--r--net/netlink/af_netlink.c37
-rw-r--r--net/openvswitch/datapath.c2
-rw-r--r--net/sched/sch_api.c2
-rw-r--r--net/sched/sch_pie.c2
-rw-r--r--net/tipc/node.c46
-rw-r--r--net/tipc/node.h7
-rw-r--r--net/tipc/socket.c6
-rw-r--r--net/wireless/nl80211.c10
-rw-r--r--net/xfrm/xfrm_output.c2
-rw-r--r--net/xfrm/xfrm_policy.c2
-rw-r--r--samples/bpf/test_verifier.c11
-rw-r--r--security/integrity/evm/evm_main.c9
-rw-r--r--security/integrity/ima/ima_appraise.c2
-rw-r--r--security/integrity/integrity.h1
-rw-r--r--sound/core/pcm_compat.c2
-rw-r--r--sound/firewire/bebob/bebob_focusrite.c62
-rw-r--r--sound/firewire/bebob/bebob_stream.c18
-rw-r--r--sound/firewire/bebob/bebob_terratec.c7
-rw-r--r--sound/pci/ad1889.c8
-rw-r--r--sound/pci/hda/hda_intel.c4
-rw-r--r--sound/pci/hda/patch_realtek.c6
-rw-r--r--sound/soc/Kconfig1
-rw-r--r--sound/soc/Makefile1
-rw-r--r--sound/soc/codecs/adau1761.c4
-rw-r--r--sound/soc/fsl/fsl_asrc.c2
-rw-r--r--sound/soc/fsl/fsl_esai.c2
-rw-r--r--sound/soc/intel/sst-haswell-pcm.c4
-rw-r--r--sound/soc/s6000/Kconfig26
-rw-r--r--sound/soc/s6000/Makefile11
-rw-r--r--sound/soc/s6000/s6000-i2s.c617
-rw-r--r--sound/soc/s6000/s6000-i2s.h23
-rw-r--r--sound/soc/s6000/s6000-pcm.c521
-rw-r--r--sound/soc/s6000/s6000-pcm.h33
-rw-r--r--sound/soc/s6000/s6105-ipcam.c221
-rw-r--r--tools/perf/builtin-diff.c5
-rw-r--r--tools/perf/builtin-probe.c2
-rw-r--r--tools/perf/perf-sys.h30
-rw-r--r--tools/perf/util/header.c27
-rw-r--r--tools/perf/util/sort.c102
-rw-r--r--tools/perf/util/thread.c3
-rw-r--r--tools/perf/util/unwind-libunwind.c12
-rw-r--r--tools/perf/util/unwind.h3
522 files changed, 4607 insertions, 4017 deletions
diff --git a/Documentation/ABI/testing/sysfs-ibft b/Documentation/ABI/testing/sysfs-ibft
index c2b7d1154bec..cac3930bdb04 100644
--- a/Documentation/ABI/testing/sysfs-ibft
+++ b/Documentation/ABI/testing/sysfs-ibft
@@ -20,4 +20,4 @@ Date: November 2007
20Contact: Konrad Rzeszutek <ketuzsezr@darnok.org> 20Contact: Konrad Rzeszutek <ketuzsezr@darnok.org>
21Description: The /sys/firmware/ibft/ethernetX directory will contain 21Description: The /sys/firmware/ibft/ethernetX directory will contain
22 files that expose the iSCSI Boot Firmware Table NIC data. 22 files that expose the iSCSI Boot Firmware Table NIC data.
23 This can this can the IP address, MAC, and gateway of the NIC. 23 Usually this contains the IP address, MAC, and gateway of the NIC.
diff --git a/Documentation/DocBook/media/Makefile b/Documentation/DocBook/media/Makefile
index df2962d9e11e..8bf7c6191296 100644
--- a/Documentation/DocBook/media/Makefile
+++ b/Documentation/DocBook/media/Makefile
@@ -25,7 +25,7 @@ GENFILES := $(addprefix $(MEDIA_OBJ_DIR)/, $(MEDIA_TEMP))
25PHONY += cleanmediadocs 25PHONY += cleanmediadocs
26 26
27cleanmediadocs: 27cleanmediadocs:
28 -@rm `find $(MEDIA_OBJ_DIR) -type l` $(GENFILES) $(OBJIMGFILES) 2>/dev/null 28 -@rm -f `find $(MEDIA_OBJ_DIR) -type l` $(GENFILES) $(OBJIMGFILES) 2>/dev/null
29 29
30$(obj)/media_api.xml: $(GENFILES) FORCE 30$(obj)/media_api.xml: $(GENFILES) FORCE
31 31
diff --git a/Documentation/DocBook/media/v4l/compat.xml b/Documentation/DocBook/media/v4l/compat.xml
index 07ffc76553ba..0a2debfa68f6 100644
--- a/Documentation/DocBook/media/v4l/compat.xml
+++ b/Documentation/DocBook/media/v4l/compat.xml
@@ -2566,6 +2566,10 @@ fields changed from _s32 to _u32.
2566 <para>Added compound control types and &VIDIOC-QUERY-EXT-CTRL;. 2566 <para>Added compound control types and &VIDIOC-QUERY-EXT-CTRL;.
2567 </para> 2567 </para>
2568 </listitem> 2568 </listitem>
2569 </orderedlist>
2570 </section>
2571
2572 <section>
2569 <title>V4L2 in Linux 3.18</title> 2573 <title>V4L2 in Linux 3.18</title>
2570 <orderedlist> 2574 <orderedlist>
2571 <listitem> 2575 <listitem>
diff --git a/Documentation/HOWTO b/Documentation/HOWTO
index 57cf5efb044d..93aa8604630e 100644
--- a/Documentation/HOWTO
+++ b/Documentation/HOWTO
@@ -324,7 +324,6 @@ tree, they need to be integration-tested. For this purpose, a special
324testing repository exists into which virtually all subsystem trees are 324testing repository exists into which virtually all subsystem trees are
325pulled on an almost daily basis: 325pulled on an almost daily basis:
326 http://git.kernel.org/?p=linux/kernel/git/next/linux-next.git 326 http://git.kernel.org/?p=linux/kernel/git/next/linux-next.git
327 http://linux.f-seidel.de/linux-next/pmwiki/
328 327
329This way, the -next kernel gives a summary outlook onto what will be 328This way, the -next kernel gives a summary outlook onto what will be
330expected to go into the mainline kernel at the next merge period. 329expected to go into the mainline kernel at the next merge period.
diff --git a/Documentation/SubmittingPatches b/Documentation/SubmittingPatches
index 482c74947de0..1fa1caa198eb 100644
--- a/Documentation/SubmittingPatches
+++ b/Documentation/SubmittingPatches
@@ -483,12 +483,10 @@ have been included in the discussion
483 483
48414) Using Reported-by:, Tested-by:, Reviewed-by:, Suggested-by: and Fixes: 48414) Using Reported-by:, Tested-by:, Reviewed-by:, Suggested-by: and Fixes:
485 485
486If this patch fixes a problem reported by somebody else, consider adding a 486The Reported-by tag gives credit to people who find bugs and report them and it
487Reported-by: tag to credit the reporter for their contribution. Please 487hopefully inspires them to help us again in the future. Please note that if
488note that this tag should not be added without the reporter's permission, 488the bug was reported in private, then ask for permission first before using the
489especially if the problem was not reported in a public forum. That said, 489Reported-by tag.
490if we diligently credit our bug reporters, they will, hopefully, be
491inspired to help us again in the future.
492 490
493A Tested-by: tag indicates that the patch has been successfully tested (in 491A Tested-by: tag indicates that the patch has been successfully tested (in
494some environment) by the person named. This tag informs maintainers that 492some environment) by the person named. This tag informs maintainers that
diff --git a/Documentation/development-process/2.Process b/Documentation/development-process/2.Process
index 2e0617936e8f..c24e156a6118 100644
--- a/Documentation/development-process/2.Process
+++ b/Documentation/development-process/2.Process
@@ -289,10 +289,6 @@ lists when they are assembled; they can be downloaded from:
289 289
290 http://www.kernel.org/pub/linux/kernel/next/ 290 http://www.kernel.org/pub/linux/kernel/next/
291 291
292Some information about linux-next has been gathered at:
293
294 http://linux.f-seidel.de/linux-next/pmwiki/
295
296Linux-next has become an integral part of the kernel development process; 292Linux-next has become an integral part of the kernel development process;
297all patches merged during a given merge window should really have found 293all patches merged during a given merge window should really have found
298their way into linux-next some time before the merge window opens. 294their way into linux-next some time before the merge window opens.
diff --git a/Documentation/development-process/8.Conclusion b/Documentation/development-process/8.Conclusion
index 1990ab4b4949..caef69022e9c 100644
--- a/Documentation/development-process/8.Conclusion
+++ b/Documentation/development-process/8.Conclusion
@@ -22,10 +22,6 @@ Beyond that, a valuable resource for kernel developers is:
22 22
23 http://kernelnewbies.org/ 23 http://kernelnewbies.org/
24 24
25Information about the linux-next tree gathers at:
26
27 http://linux.f-seidel.de/linux-next/pmwiki/
28
29And, of course, one should not forget http://kernel.org/, the definitive 25And, of course, one should not forget http://kernel.org/, the definitive
30location for kernel release information. 26location for kernel release information.
31 27
diff --git a/Documentation/devicetree/bindings/net/smsc-lan91c111.txt b/Documentation/devicetree/bindings/net/smsc-lan91c111.txt
index 0f8487b88822..e77e167593db 100644
--- a/Documentation/devicetree/bindings/net/smsc-lan91c111.txt
+++ b/Documentation/devicetree/bindings/net/smsc-lan91c111.txt
@@ -11,3 +11,5 @@ Optional properties:
11 are supported on the device. Valid value for SMSC LAN91c111 are 11 are supported on the device. Valid value for SMSC LAN91c111 are
12 1, 2 or 4. If it's omitted or invalid, the size would be 2 meaning 12 1, 2 or 4. If it's omitted or invalid, the size would be 2 meaning
13 16-bit access only. 13 16-bit access only.
14- power-gpios: GPIO to control the PWRDWN pin
15- reset-gpios: GPIO to control the RESET pin
diff --git a/Documentation/devicetree/bindings/sound/sgtl5000.txt b/Documentation/devicetree/bindings/sound/sgtl5000.txt
index 955df60a118c..d556dcb8816b 100644
--- a/Documentation/devicetree/bindings/sound/sgtl5000.txt
+++ b/Documentation/devicetree/bindings/sound/sgtl5000.txt
@@ -7,10 +7,20 @@ Required properties:
7 7
8- clocks : the clock provider of SYS_MCLK 8- clocks : the clock provider of SYS_MCLK
9 9
10- VDDA-supply : the regulator provider of VDDA
11
12- VDDIO-supply: the regulator provider of VDDIO
13
14Optional properties:
15
16- VDDD-supply : the regulator provider of VDDD
17
10Example: 18Example:
11 19
12codec: sgtl5000@0a { 20codec: sgtl5000@0a {
13 compatible = "fsl,sgtl5000"; 21 compatible = "fsl,sgtl5000";
14 reg = <0x0a>; 22 reg = <0x0a>;
15 clocks = <&clks 150>; 23 clocks = <&clks 150>;
24 VDDA-supply = <&reg_3p3v>;
25 VDDIO-supply = <&reg_3p3v>;
16}; 26};
diff --git a/Documentation/devicetree/bindings/submitting-patches.txt b/Documentation/devicetree/bindings/submitting-patches.txt
index 042a0273b8ba..b7ba01ad1426 100644
--- a/Documentation/devicetree/bindings/submitting-patches.txt
+++ b/Documentation/devicetree/bindings/submitting-patches.txt
@@ -12,6 +12,9 @@ I. For patch submitters
12 12
13 devicetree@vger.kernel.org 13 devicetree@vger.kernel.org
14 14
15 3) The Documentation/ portion of the patch should come in the series before
16 the code implementing the binding.
17
15II. For kernel maintainers 18II. For kernel maintainers
16 19
17 1) If you aren't comfortable reviewing a given binding, reply to it and ask 20 1) If you aren't comfortable reviewing a given binding, reply to it and ask
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index 74339c57b914..4c81a860cc2b 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -1264,7 +1264,7 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
1264 i8042.noloop [HW] Disable the AUX Loopback command while probing 1264 i8042.noloop [HW] Disable the AUX Loopback command while probing
1265 for the AUX port 1265 for the AUX port
1266 i8042.nomux [HW] Don't check presence of an active multiplexing 1266 i8042.nomux [HW] Don't check presence of an active multiplexing
1267 controller. Default: true. 1267 controller
1268 i8042.nopnp [HW] Don't use ACPIPnP / PnPBIOS to discover KBD/AUX 1268 i8042.nopnp [HW] Don't use ACPIPnP / PnPBIOS to discover KBD/AUX
1269 controllers 1269 controllers
1270 i8042.notimeout [HW] Ignore timeout condition signalled by controller 1270 i8042.notimeout [HW] Ignore timeout condition signalled by controller
@@ -1307,6 +1307,18 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
1307 .cdrom .chs .ignore_cable are additional options 1307 .cdrom .chs .ignore_cable are additional options
1308 See Documentation/ide/ide.txt. 1308 See Documentation/ide/ide.txt.
1309 1309
1310 ide-generic.probe-mask= [HW] (E)IDE subsystem
1311 Format: <int>
1312 Probe mask for legacy ISA IDE ports. Depending on
1313 platform up to 6 ports are supported, enabled by
1314 setting corresponding bits in the mask to 1. The
1315 default value is 0x0, which has a special meaning.
1316 On systems that have PCI, it triggers scanning the
1317 PCI bus for the first and the second port, which
1318 are then probed. On systems without PCI the value
1319 of 0x0 enables probing the two first ports as if it
1320 was 0x3.
1321
1310 ide-pci-generic.all-generic-ide [HW] (E)IDE subsystem 1322 ide-pci-generic.all-generic-ide [HW] (E)IDE subsystem
1311 Claim all unknown PCI IDE storage controllers. 1323 Claim all unknown PCI IDE storage controllers.
1312 1324
@@ -1587,6 +1599,8 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
1587 kmemleak= [KNL] Boot-time kmemleak enable/disable 1599 kmemleak= [KNL] Boot-time kmemleak enable/disable
1588 Valid arguments: on, off 1600 Valid arguments: on, off
1589 Default: on 1601 Default: on
1602 Built with CONFIG_DEBUG_KMEMLEAK_DEFAULT_OFF=y,
1603 the default is off.
1590 1604
1591 kmemcheck= [X86] Boot-time kmemcheck enable/disable/one-shot mode 1605 kmemcheck= [X86] Boot-time kmemcheck enable/disable/one-shot mode
1592 Valid arguments: 0, 1, 2 1606 Valid arguments: 0, 1, 2
diff --git a/Documentation/kmemleak.txt b/Documentation/kmemleak.txt
index f4f033c8d856..45e777f4e41d 100644
--- a/Documentation/kmemleak.txt
+++ b/Documentation/kmemleak.txt
@@ -62,6 +62,10 @@ Memory may be allocated or freed before kmemleak is initialised and
62these actions are stored in an early log buffer. The size of this buffer 62these actions are stored in an early log buffer. The size of this buffer
63is configured via the CONFIG_DEBUG_KMEMLEAK_EARLY_LOG_SIZE option. 63is configured via the CONFIG_DEBUG_KMEMLEAK_EARLY_LOG_SIZE option.
64 64
65If CONFIG_DEBUG_KMEMLEAK_DEFAULT_OFF are enabled, the kmemleak is
66disabled by default. Passing "kmemleak=on" on the kernel command
67line enables the function.
68
65Basic Algorithm 69Basic Algorithm
66--------------- 70---------------
67 71
diff --git a/Documentation/prctl/Makefile b/Documentation/prctl/Makefile
index 3e3232dcb2b8..2948b7b124b9 100644
--- a/Documentation/prctl/Makefile
+++ b/Documentation/prctl/Makefile
@@ -1,5 +1,5 @@
1# List of programs to build 1# List of programs to build
2hostprogs-y := disable-tsc-ctxt-sw-stress-test disable-tsc-on-off-stress-test disable-tsc-test 2hostprogs-$(CONFIG_X86) := disable-tsc-ctxt-sw-stress-test disable-tsc-on-off-stress-test disable-tsc-test
3# Tell kbuild to always build the programs 3# Tell kbuild to always build the programs
4always := $(hostprogs-y) 4always := $(hostprogs-y)
5 5
diff --git a/Documentation/ptp/testptp.mk b/Documentation/ptp/testptp.mk
new file mode 100644
index 000000000000..4ef2d9755421
--- /dev/null
+++ b/Documentation/ptp/testptp.mk
@@ -0,0 +1,33 @@
1# PTP 1588 clock support - User space test program
2#
3# Copyright (C) 2010 OMICRON electronics GmbH
4#
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 2 of the License, or
8# (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program; if not, write to the Free Software
17# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
19CC = $(CROSS_COMPILE)gcc
20INC = -I$(KBUILD_OUTPUT)/usr/include
21CFLAGS = -Wall $(INC)
22LDLIBS = -lrt
23PROGS = testptp
24
25all: $(PROGS)
26
27testptp: testptp.o
28
29clean:
30 rm -f testptp.o
31
32distclean: clean
33 rm -f $(PROGS)
diff --git a/Documentation/vDSO/Makefile b/Documentation/vDSO/Makefile
index 2b99e57207c1..ee075c3d2124 100644
--- a/Documentation/vDSO/Makefile
+++ b/Documentation/vDSO/Makefile
@@ -10,3 +10,6 @@ always := $(hostprogs-y)
10HOSTCFLAGS := -I$(objtree)/usr/include -std=gnu99 10HOSTCFLAGS := -I$(objtree)/usr/include -std=gnu99
11HOSTCFLAGS_vdso_standalone_test_x86.o := -fno-asynchronous-unwind-tables -fno-stack-protector 11HOSTCFLAGS_vdso_standalone_test_x86.o := -fno-asynchronous-unwind-tables -fno-stack-protector
12HOSTLOADLIBES_vdso_standalone_test_x86 := -nostdlib 12HOSTLOADLIBES_vdso_standalone_test_x86 := -nostdlib
13ifeq ($(CONFIG_X86_32),y)
14HOSTLOADLIBES_vdso_standalone_test_x86 += -lgcc_s
15endif
diff --git a/Documentation/vDSO/vdso_standalone_test_x86.c b/Documentation/vDSO/vdso_standalone_test_x86.c
index d46240265c50..93b0ebf8cc38 100644
--- a/Documentation/vDSO/vdso_standalone_test_x86.c
+++ b/Documentation/vDSO/vdso_standalone_test_x86.c
@@ -63,7 +63,7 @@ static inline void linux_exit(int code)
63 x86_syscall3(__NR_exit, code, 0, 0); 63 x86_syscall3(__NR_exit, code, 0, 0);
64} 64}
65 65
66void to_base10(char *lastdig, uint64_t n) 66void to_base10(char *lastdig, time_t n)
67{ 67{
68 while (n) { 68 while (n) {
69 *lastdig = (n % 10) + '0'; 69 *lastdig = (n % 10) + '0';
diff --git a/Documentation/vm/hugetlbpage.txt b/Documentation/vm/hugetlbpage.txt
index bdd4bb97fff7..b64e0af9cc56 100644
--- a/Documentation/vm/hugetlbpage.txt
+++ b/Documentation/vm/hugetlbpage.txt
@@ -274,7 +274,7 @@ This command mounts a (pseudo) filesystem of type hugetlbfs on the directory
274/mnt/huge. Any files created on /mnt/huge uses huge pages. The uid and gid 274/mnt/huge. Any files created on /mnt/huge uses huge pages. The uid and gid
275options sets the owner and group of the root of the file system. By default 275options sets the owner and group of the root of the file system. By default
276the uid and gid of the current process are taken. The mode option sets the 276the uid and gid of the current process are taken. The mode option sets the
277mode of root of file system to value & 0777. This value is given in octal. 277mode of root of file system to value & 01777. This value is given in octal.
278By default the value 0755 is picked. The size option sets the maximum value of 278By default the value 0755 is picked. The size option sets the maximum value of
279memory (huge pages) allowed for that filesystem (/mnt/huge). The size is 279memory (huge pages) allowed for that filesystem (/mnt/huge). The size is
280rounded down to HPAGE_SIZE. The option nr_inodes sets the maximum number of 280rounded down to HPAGE_SIZE. The option nr_inodes sets the maximum number of
diff --git a/MAINTAINERS b/MAINTAINERS
index dab92a78d1d5..5d6136b8959e 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1543,6 +1543,7 @@ F: arch/arm/mach-pxa/include/mach/z2.h
1543 1543
1544ARM/ZYNQ ARCHITECTURE 1544ARM/ZYNQ ARCHITECTURE
1545M: Michal Simek <michal.simek@xilinx.com> 1545M: Michal Simek <michal.simek@xilinx.com>
1546R: Sören Brinkmann <soren.brinkmann@xilinx.com>
1546L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) 1547L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
1547W: http://wiki.xilinx.com 1548W: http://wiki.xilinx.com
1548T: git git://git.xilinx.com/linux-xlnx.git 1549T: git git://git.xilinx.com/linux-xlnx.git
@@ -4312,8 +4313,10 @@ F: Documentation/blockdev/cpqarray.txt
4312F: drivers/block/cpqarray.* 4313F: drivers/block/cpqarray.*
4313 4314
4314HEWLETT-PACKARD SMART ARRAY RAID DRIVER (hpsa) 4315HEWLETT-PACKARD SMART ARRAY RAID DRIVER (hpsa)
4315M: "Stephen M. Cameron" <scameron@beardog.cce.hp.com> 4316M: Don Brace <don.brace@pmcs.com>
4316L: iss_storagedev@hp.com 4317L: iss_storagedev@hp.com
4318L: storagedev@pmcs.com
4319L: linux-scsi@vger.kernel.org
4317S: Supported 4320S: Supported
4318F: Documentation/scsi/hpsa.txt 4321F: Documentation/scsi/hpsa.txt
4319F: drivers/scsi/hpsa*.[ch] 4322F: drivers/scsi/hpsa*.[ch]
@@ -4321,8 +4324,10 @@ F: include/linux/cciss*.h
4321F: include/uapi/linux/cciss*.h 4324F: include/uapi/linux/cciss*.h
4322 4325
4323HEWLETT-PACKARD SMART CISS RAID DRIVER (cciss) 4326HEWLETT-PACKARD SMART CISS RAID DRIVER (cciss)
4324M: Mike Miller <mike.miller@hp.com> 4327M: Don Brace <don.brace@pmcs.com>
4325L: iss_storagedev@hp.com 4328L: iss_storagedev@hp.com
4329L: storagedev@pmcs.com
4330L: linux-scsi@vger.kernel.org
4326S: Supported 4331S: Supported
4327F: Documentation/blockdev/cciss.txt 4332F: Documentation/blockdev/cciss.txt
4328F: drivers/block/cciss* 4333F: drivers/block/cciss*
@@ -4608,7 +4613,7 @@ S: Supported
4608F: drivers/crypto/nx/ 4613F: drivers/crypto/nx/
4609 4614
4610IBM Power 842 compression accelerator 4615IBM Power 842 compression accelerator
4611M: Nathan Fontenot <nfont@linux.vnet.ibm.com> 4616M: Dan Streetman <ddstreet@us.ibm.com>
4612S: Supported 4617S: Supported
4613F: drivers/crypto/nx/nx-842.c 4618F: drivers/crypto/nx/nx-842.c
4614F: include/linux/nx842.h 4619F: include/linux/nx842.h
@@ -7175,6 +7180,7 @@ F: drivers/crypto/picoxcell*
7175 7180
7176PIN CONTROL SUBSYSTEM 7181PIN CONTROL SUBSYSTEM
7177M: Linus Walleij <linus.walleij@linaro.org> 7182M: Linus Walleij <linus.walleij@linaro.org>
7183L: linux-gpio@vger.kernel.org
7178S: Maintained 7184S: Maintained
7179F: drivers/pinctrl/ 7185F: drivers/pinctrl/
7180F: include/linux/pinctrl/ 7186F: include/linux/pinctrl/
@@ -8479,7 +8485,6 @@ F: arch/arm/mach-s3c24xx/bast-irq.c
8479TI DAVINCI MACHINE SUPPORT 8485TI DAVINCI MACHINE SUPPORT
8480M: Sekhar Nori <nsekhar@ti.com> 8486M: Sekhar Nori <nsekhar@ti.com>
8481M: Kevin Hilman <khilman@deeprootsystems.com> 8487M: Kevin Hilman <khilman@deeprootsystems.com>
8482L: davinci-linux-open-source@linux.davincidsp.com (moderated for non-subscribers)
8483T: git git://gitorious.org/linux-davinci/linux-davinci.git 8488T: git git://gitorious.org/linux-davinci/linux-davinci.git
8484Q: http://patchwork.kernel.org/project/linux-davinci/list/ 8489Q: http://patchwork.kernel.org/project/linux-davinci/list/
8485S: Supported 8490S: Supported
@@ -8489,7 +8494,6 @@ F: drivers/i2c/busses/i2c-davinci.c
8489TI DAVINCI SERIES MEDIA DRIVER 8494TI DAVINCI SERIES MEDIA DRIVER
8490M: Lad, Prabhakar <prabhakar.csengg@gmail.com> 8495M: Lad, Prabhakar <prabhakar.csengg@gmail.com>
8491L: linux-media@vger.kernel.org 8496L: linux-media@vger.kernel.org
8492L: davinci-linux-open-source@linux.davincidsp.com (moderated for non-subscribers)
8493W: http://linuxtv.org/ 8497W: http://linuxtv.org/
8494Q: http://patchwork.linuxtv.org/project/linux-media/list/ 8498Q: http://patchwork.linuxtv.org/project/linux-media/list/
8495T: git git://linuxtv.org/mhadli/v4l-dvb-davinci_devices.git 8499T: git git://linuxtv.org/mhadli/v4l-dvb-davinci_devices.git
@@ -9606,7 +9610,6 @@ F: drivers/staging/unisys/
9606 9610
9607UNIVERSAL FLASH STORAGE HOST CONTROLLER DRIVER 9611UNIVERSAL FLASH STORAGE HOST CONTROLLER DRIVER
9608M: Vinayak Holikatti <vinholikatti@gmail.com> 9612M: Vinayak Holikatti <vinholikatti@gmail.com>
9609M: Santosh Y <santoshsy@gmail.com>
9610L: linux-scsi@vger.kernel.org 9613L: linux-scsi@vger.kernel.org
9611S: Supported 9614S: Supported
9612F: Documentation/scsi/ufs.txt 9615F: Documentation/scsi/ufs.txt
diff --git a/Makefile b/Makefile
index 52c129725270..ffc1ce2b0345 100644
--- a/Makefile
+++ b/Makefile
@@ -1,8 +1,8 @@
1VERSION = 3 1VERSION = 3
2PATCHLEVEL = 18 2PATCHLEVEL = 18
3SUBLEVEL = 0 3SUBLEVEL = 0
4EXTRAVERSION = -rc2 4EXTRAVERSION = -rc3
5NAME = Shuffling Zombie Juror 5NAME = Diseased Newt
6 6
7# *DOCUMENTATION* 7# *DOCUMENTATION*
8# To see a list of typical targets execute "make help" 8# To see a list of typical targets execute "make help"
diff --git a/arch/arm/Kconfig.debug b/arch/arm/Kconfig.debug
index 03dc4c1a8736..d8f6a2ec3d4e 100644
--- a/arch/arm/Kconfig.debug
+++ b/arch/arm/Kconfig.debug
@@ -1187,7 +1187,7 @@ config DEBUG_UART_VIRT
1187 default 0xf1c28000 if DEBUG_SUNXI_UART0 1187 default 0xf1c28000 if DEBUG_SUNXI_UART0
1188 default 0xf1c28400 if DEBUG_SUNXI_UART1 1188 default 0xf1c28400 if DEBUG_SUNXI_UART1
1189 default 0xf1f02800 if DEBUG_SUNXI_R_UART 1189 default 0xf1f02800 if DEBUG_SUNXI_R_UART
1190 default 0xf2100000 if DEBUG_PXA_UART1 1190 default 0xf6200000 if DEBUG_PXA_UART1
1191 default 0xf4090000 if ARCH_LPC32XX 1191 default 0xf4090000 if ARCH_LPC32XX
1192 default 0xf4200000 if ARCH_GEMINI 1192 default 0xf4200000 if ARCH_GEMINI
1193 default 0xf7000000 if DEBUG_S3C24XX_UART && (DEBUG_S3C_UART0 || \ 1193 default 0xf7000000 if DEBUG_S3C24XX_UART && (DEBUG_S3C_UART0 || \
diff --git a/arch/arm/boot/dts/omap3-n900.dts b/arch/arm/boot/dts/omap3-n900.dts
index 739fcf29c643..bc82a12d4c2c 100644
--- a/arch/arm/boot/dts/omap3-n900.dts
+++ b/arch/arm/boot/dts/omap3-n900.dts
@@ -668,6 +668,8 @@
668 bank-width = <2>; 668 bank-width = <2>;
669 pinctrl-names = "default"; 669 pinctrl-names = "default";
670 pinctrl-0 = <&ethernet_pins>; 670 pinctrl-0 = <&ethernet_pins>;
671 power-gpios = <&gpio3 22 GPIO_ACTIVE_HIGH>; /* gpio86 */
672 reset-gpios = <&gpio6 4 GPIO_ACTIVE_HIGH>; /* gpio164 */
671 gpmc,device-width = <2>; 673 gpmc,device-width = <2>;
672 gpmc,sync-clk-ps = <0>; 674 gpmc,sync-clk-ps = <0>;
673 gpmc,cs-on-ns = <0>; 675 gpmc,cs-on-ns = <0>;
diff --git a/arch/arm/configs/multi_v7_defconfig b/arch/arm/configs/multi_v7_defconfig
index f1dc7fc668f3..3487046d8a78 100644
--- a/arch/arm/configs/multi_v7_defconfig
+++ b/arch/arm/configs/multi_v7_defconfig
@@ -235,6 +235,7 @@ CONFIG_SPI_TEGRA20_SLINK=y
235CONFIG_SPI_XILINX=y 235CONFIG_SPI_XILINX=y
236CONFIG_PINCTRL_AS3722=y 236CONFIG_PINCTRL_AS3722=y
237CONFIG_PINCTRL_PALMAS=y 237CONFIG_PINCTRL_PALMAS=y
238CONFIG_PINCTRL_APQ8084=y
238CONFIG_GPIO_SYSFS=y 239CONFIG_GPIO_SYSFS=y
239CONFIG_GPIO_GENERIC_PLATFORM=y 240CONFIG_GPIO_GENERIC_PLATFORM=y
240CONFIG_GPIO_DWAPB=y 241CONFIG_GPIO_DWAPB=y
@@ -411,6 +412,7 @@ CONFIG_NVEC_POWER=y
411CONFIG_NVEC_PAZ00=y 412CONFIG_NVEC_PAZ00=y
412CONFIG_QCOM_GSBI=y 413CONFIG_QCOM_GSBI=y
413CONFIG_COMMON_CLK_QCOM=y 414CONFIG_COMMON_CLK_QCOM=y
415CONFIG_APQ_MMCC_8084=y
414CONFIG_MSM_GCC_8660=y 416CONFIG_MSM_GCC_8660=y
415CONFIG_MSM_MMCC_8960=y 417CONFIG_MSM_MMCC_8960=y
416CONFIG_MSM_MMCC_8974=y 418CONFIG_MSM_MMCC_8974=y
diff --git a/arch/arm/configs/omap2plus_defconfig b/arch/arm/configs/omap2plus_defconfig
index 16e719c268dd..b3f86670d2eb 100644
--- a/arch/arm/configs/omap2plus_defconfig
+++ b/arch/arm/configs/omap2plus_defconfig
@@ -86,7 +86,6 @@ CONFIG_IP_PNP_DHCP=y
86CONFIG_IP_PNP_BOOTP=y 86CONFIG_IP_PNP_BOOTP=y
87CONFIG_IP_PNP_RARP=y 87CONFIG_IP_PNP_RARP=y
88# CONFIG_INET_LRO is not set 88# CONFIG_INET_LRO is not set
89CONFIG_IPV6=y
90CONFIG_NETFILTER=y 89CONFIG_NETFILTER=y
91CONFIG_CAN=m 90CONFIG_CAN=m
92CONFIG_CAN_C_CAN=m 91CONFIG_CAN_C_CAN=m
@@ -112,6 +111,7 @@ CONFIG_MTD_OOPS=y
112CONFIG_MTD_CFI=y 111CONFIG_MTD_CFI=y
113CONFIG_MTD_CFI_INTELEXT=y 112CONFIG_MTD_CFI_INTELEXT=y
114CONFIG_MTD_NAND=y 113CONFIG_MTD_NAND=y
114CONFIG_MTD_NAND_ECC_BCH=y
115CONFIG_MTD_NAND_OMAP2=y 115CONFIG_MTD_NAND_OMAP2=y
116CONFIG_MTD_ONENAND=y 116CONFIG_MTD_ONENAND=y
117CONFIG_MTD_ONENAND_VERIFY_WRITE=y 117CONFIG_MTD_ONENAND_VERIFY_WRITE=y
@@ -317,7 +317,7 @@ CONFIG_EXT4_FS=y
317CONFIG_FANOTIFY=y 317CONFIG_FANOTIFY=y
318CONFIG_QUOTA=y 318CONFIG_QUOTA=y
319CONFIG_QFMT_V2=y 319CONFIG_QFMT_V2=y
320CONFIG_AUTOFS4_FS=y 320CONFIG_AUTOFS4_FS=m
321CONFIG_MSDOS_FS=y 321CONFIG_MSDOS_FS=y
322CONFIG_VFAT_FS=y 322CONFIG_VFAT_FS=y
323CONFIG_TMPFS=y 323CONFIG_TMPFS=y
diff --git a/arch/arm/configs/socfpga_defconfig b/arch/arm/configs/socfpga_defconfig
index d7a5855a5db8..a2956c3112f1 100644
--- a/arch/arm/configs/socfpga_defconfig
+++ b/arch/arm/configs/socfpga_defconfig
@@ -1,5 +1,6 @@
1CONFIG_EXPERIMENTAL=y
2CONFIG_SYSVIPC=y 1CONFIG_SYSVIPC=y
2CONFIG_FHANDLE=y
3CONFIG_HIGH_RES_TIMERS=y
3CONFIG_IKCONFIG=y 4CONFIG_IKCONFIG=y
4CONFIG_IKCONFIG_PROC=y 5CONFIG_IKCONFIG_PROC=y
5CONFIG_LOG_BUF_SHIFT=14 6CONFIG_LOG_BUF_SHIFT=14
@@ -11,23 +12,17 @@ CONFIG_PROFILING=y
11CONFIG_OPROFILE=y 12CONFIG_OPROFILE=y
12CONFIG_MODULES=y 13CONFIG_MODULES=y
13CONFIG_MODULE_UNLOAD=y 14CONFIG_MODULE_UNLOAD=y
14CONFIG_HOTPLUG=y
15# CONFIG_LBDAF is not set 15# CONFIG_LBDAF is not set
16# CONFIG_BLK_DEV_BSG is not set 16# CONFIG_BLK_DEV_BSG is not set
17# CONFIG_IOSCHED_DEADLINE is not set 17# CONFIG_IOSCHED_DEADLINE is not set
18# CONFIG_IOSCHED_CFQ is not set 18# CONFIG_IOSCHED_CFQ is not set
19CONFIG_ARCH_SOCFPGA=y 19CONFIG_ARCH_SOCFPGA=y
20CONFIG_MACH_SOCFPGA_CYCLONE5=y
21CONFIG_ARM_THUMBEE=y 20CONFIG_ARM_THUMBEE=y
22# CONFIG_ARCH_VEXPRESS_CORTEX_A5_A9_ERRATA is not set
23# CONFIG_CACHE_L2X0 is not set
24CONFIG_HIGH_RES_TIMERS=y
25CONFIG_SMP=y 21CONFIG_SMP=y
26CONFIG_NR_CPUS=2 22CONFIG_NR_CPUS=2
27CONFIG_AEABI=y 23CONFIG_AEABI=y
28CONFIG_ZBOOT_ROM_TEXT=0x0 24CONFIG_ZBOOT_ROM_TEXT=0x0
29CONFIG_ZBOOT_ROM_BSS=0x0 25CONFIG_ZBOOT_ROM_BSS=0x0
30CONFIG_CMDLINE=""
31CONFIG_VFP=y 26CONFIG_VFP=y
32CONFIG_NEON=y 27CONFIG_NEON=y
33CONFIG_NET=y 28CONFIG_NET=y
@@ -41,38 +36,30 @@ CONFIG_IP_PNP=y
41CONFIG_IP_PNP_DHCP=y 36CONFIG_IP_PNP_DHCP=y
42CONFIG_IP_PNP_BOOTP=y 37CONFIG_IP_PNP_BOOTP=y
43CONFIG_IP_PNP_RARP=y 38CONFIG_IP_PNP_RARP=y
39CONFIG_IPV6=y
40CONFIG_NETWORK_PHY_TIMESTAMPING=y
41CONFIG_VLAN_8021Q=y
42CONFIG_VLAN_8021Q_GVRP=y
44CONFIG_CAN=y 43CONFIG_CAN=y
45CONFIG_CAN_RAW=y
46CONFIG_CAN_BCM=y
47CONFIG_CAN_GW=y
48CONFIG_CAN_DEV=y
49CONFIG_CAN_CALC_BITTIMING=y
50CONFIG_CAN_C_CAN=y 44CONFIG_CAN_C_CAN=y
51CONFIG_CAN_C_CAN_PLATFORM=y 45CONFIG_CAN_C_CAN_PLATFORM=y
52CONFIG_CAN_DEBUG_DEVICES=y 46CONFIG_CAN_DEBUG_DEVICES=y
53CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 47CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
54CONFIG_DEVTMPFS=y 48CONFIG_DEVTMPFS=y
55CONFIG_PROC_DEVICETREE=y 49CONFIG_DEVTMPFS_MOUNT=y
56CONFIG_BLK_DEV_RAM=y 50CONFIG_BLK_DEV_RAM=y
57CONFIG_BLK_DEV_RAM_COUNT=2 51CONFIG_BLK_DEV_RAM_COUNT=2
58CONFIG_BLK_DEV_RAM_SIZE=8192 52CONFIG_BLK_DEV_RAM_SIZE=8192
53CONFIG_SRAM=y
59CONFIG_SCSI=y 54CONFIG_SCSI=y
60# CONFIG_SCSI_PROC_FS is not set 55# CONFIG_SCSI_PROC_FS is not set
61CONFIG_BLK_DEV_SD=y 56CONFIG_BLK_DEV_SD=y
62# CONFIG_SCSI_LOWLEVEL is not set 57# CONFIG_SCSI_LOWLEVEL is not set
63CONFIG_NETDEVICES=y 58CONFIG_NETDEVICES=y
64CONFIG_STMMAC_ETH=y 59CONFIG_STMMAC_ETH=y
60CONFIG_DWMAC_SOCFPGA=y
65CONFIG_MICREL_PHY=y 61CONFIG_MICREL_PHY=y
66# CONFIG_STMMAC_PHY_ID_ZERO_WORKAROUND is not set
67CONFIG_INPUT_EVDEV=y 62CONFIG_INPUT_EVDEV=y
68CONFIG_DWMAC_SOCFPGA=y
69CONFIG_PPS=y
70CONFIG_NETWORK_PHY_TIMESTAMPING=y
71CONFIG_PTP_1588_CLOCK=y
72CONFIG_VLAN_8021Q=y
73CONFIG_VLAN_8021Q_GVRP=y
74CONFIG_GARP=y
75CONFIG_IPV6=y
76# CONFIG_SERIO_SERPORT is not set 63# CONFIG_SERIO_SERPORT is not set
77CONFIG_SERIO_AMBAKMI=y 64CONFIG_SERIO_AMBAKMI=y
78CONFIG_LEGACY_PTY_COUNT=16 65CONFIG_LEGACY_PTY_COUNT=16
@@ -81,45 +68,43 @@ CONFIG_SERIAL_8250_CONSOLE=y
81CONFIG_SERIAL_8250_NR_UARTS=2 68CONFIG_SERIAL_8250_NR_UARTS=2
82CONFIG_SERIAL_8250_RUNTIME_UARTS=2 69CONFIG_SERIAL_8250_RUNTIME_UARTS=2
83CONFIG_SERIAL_8250_DW=y 70CONFIG_SERIAL_8250_DW=y
71CONFIG_I2C=y
72CONFIG_I2C_CHARDEV=y
73CONFIG_I2C_DESIGNWARE_PLATFORM=y
84CONFIG_GPIOLIB=y 74CONFIG_GPIOLIB=y
85CONFIG_GPIO_SYSFS=y 75CONFIG_GPIO_SYSFS=y
86CONFIG_GPIO_DWAPB=y 76CONFIG_GPIO_DWAPB=y
87# CONFIG_RTC_HCTOSYS is not set 77CONFIG_PMBUS=y
78CONFIG_SENSORS_LTC2978=y
79CONFIG_SENSORS_LTC2978_REGULATOR=y
88CONFIG_WATCHDOG=y 80CONFIG_WATCHDOG=y
89CONFIG_DW_WATCHDOG=y 81CONFIG_DW_WATCHDOG=y
82CONFIG_REGULATOR=y
83CONFIG_REGULATOR_FIXED_VOLTAGE=y
84CONFIG_USB=y
85CONFIG_USB_DWC2=y
86CONFIG_USB_DWC2_HOST=y
87CONFIG_MMC=y
88CONFIG_MMC_DW=y
90CONFIG_EXT2_FS=y 89CONFIG_EXT2_FS=y
91CONFIG_EXT2_FS_XATTR=y 90CONFIG_EXT2_FS_XATTR=y
92CONFIG_EXT2_FS_POSIX_ACL=y 91CONFIG_EXT2_FS_POSIX_ACL=y
93CONFIG_EXT3_FS=y 92CONFIG_EXT3_FS=y
94CONFIG_NFS_FS=y 93CONFIG_EXT4_FS=y
95CONFIG_ROOT_NFS=y
96# CONFIG_DNOTIFY is not set
97# CONFIG_INOTIFY_USER is not set
98CONFIG_FHANDLE=y
99CONFIG_VFAT_FS=y 94CONFIG_VFAT_FS=y
100CONFIG_NTFS_FS=y 95CONFIG_NTFS_FS=y
101CONFIG_NTFS_RW=y 96CONFIG_NTFS_RW=y
102CONFIG_TMPFS=y 97CONFIG_TMPFS=y
103CONFIG_JFFS2_FS=y 98CONFIG_CONFIGFS_FS=y
99CONFIG_NFS_FS=y
100CONFIG_ROOT_NFS=y
104CONFIG_NLS_CODEPAGE_437=y 101CONFIG_NLS_CODEPAGE_437=y
105CONFIG_NLS_ISO8859_1=y 102CONFIG_NLS_ISO8859_1=y
103CONFIG_PRINTK_TIME=y
104CONFIG_DEBUG_INFO=y
106CONFIG_MAGIC_SYSRQ=y 105CONFIG_MAGIC_SYSRQ=y
107CONFIG_DETECT_HUNG_TASK=y 106CONFIG_DETECT_HUNG_TASK=y
108# CONFIG_SCHED_DEBUG is not set 107# CONFIG_SCHED_DEBUG is not set
109CONFIG_DEBUG_INFO=y
110CONFIG_ENABLE_DEFAULT_TRACERS=y 108CONFIG_ENABLE_DEFAULT_TRACERS=y
111CONFIG_DEBUG_USER=y 109CONFIG_DEBUG_USER=y
112CONFIG_XZ_DEC=y 110CONFIG_XZ_DEC=y
113CONFIG_I2C=y
114CONFIG_I2C_DESIGNWARE_CORE=y
115CONFIG_I2C_DESIGNWARE_PLATFORM=y
116CONFIG_I2C_CHARDEV=y
117CONFIG_MMC=y
118CONFIG_MMC_DW=y
119CONFIG_PM=y
120CONFIG_SUSPEND=y
121CONFIG_MMC_UNSAFE_RESUME=y
122CONFIG_USB=y
123CONFIG_USB_DWC2=y
124CONFIG_USB_DWC2_HOST=y
125CONFIG_USB_DWC2_PLATFORM=y
diff --git a/arch/arm/include/uapi/asm/unistd.h b/arch/arm/include/uapi/asm/unistd.h
index 3aaa75cae90c..705bb7620673 100644
--- a/arch/arm/include/uapi/asm/unistd.h
+++ b/arch/arm/include/uapi/asm/unistd.h
@@ -412,6 +412,7 @@
412#define __NR_seccomp (__NR_SYSCALL_BASE+383) 412#define __NR_seccomp (__NR_SYSCALL_BASE+383)
413#define __NR_getrandom (__NR_SYSCALL_BASE+384) 413#define __NR_getrandom (__NR_SYSCALL_BASE+384)
414#define __NR_memfd_create (__NR_SYSCALL_BASE+385) 414#define __NR_memfd_create (__NR_SYSCALL_BASE+385)
415#define __NR_bpf (__NR_SYSCALL_BASE+386)
415 416
416/* 417/*
417 * The following SWIs are ARM private. 418 * The following SWIs are ARM private.
diff --git a/arch/arm/kernel/asm-offsets.c b/arch/arm/kernel/asm-offsets.c
index 713e807621d2..2d2d6087b9b1 100644
--- a/arch/arm/kernel/asm-offsets.c
+++ b/arch/arm/kernel/asm-offsets.c
@@ -10,6 +10,7 @@
10 * it under the terms of the GNU General Public License version 2 as 10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation. 11 * published by the Free Software Foundation.
12 */ 12 */
13#include <linux/compiler.h>
13#include <linux/sched.h> 14#include <linux/sched.h>
14#include <linux/mm.h> 15#include <linux/mm.h>
15#include <linux/dma-mapping.h> 16#include <linux/dma-mapping.h>
@@ -39,10 +40,19 @@
39 * GCC 3.2.x: miscompiles NEW_AUX_ENT in fs/binfmt_elf.c 40 * GCC 3.2.x: miscompiles NEW_AUX_ENT in fs/binfmt_elf.c
40 * (http://gcc.gnu.org/PR8896) and incorrect structure 41 * (http://gcc.gnu.org/PR8896) and incorrect structure
41 * initialisation in fs/jffs2/erase.c 42 * initialisation in fs/jffs2/erase.c
43 * GCC 4.8.0-4.8.2: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58854
44 * miscompiles find_get_entry(), and can result in EXT3 and EXT4
45 * filesystem corruption (possibly other FS too).
42 */ 46 */
47#ifdef __GNUC__
43#if (__GNUC__ == 3 && __GNUC_MINOR__ < 3) 48#if (__GNUC__ == 3 && __GNUC_MINOR__ < 3)
44#error Your compiler is too buggy; it is known to miscompile kernels. 49#error Your compiler is too buggy; it is known to miscompile kernels.
45#error Known good compilers: 3.3 50#error Known good compilers: 3.3, 4.x
51#endif
52#if GCC_VERSION >= 40800 && GCC_VERSION < 40803
53#error Your compiler is too buggy; it is known to miscompile kernels
54#error and result in filesystem corruption and oopses.
55#endif
46#endif 56#endif
47 57
48int main(void) 58int main(void)
diff --git a/arch/arm/kernel/calls.S b/arch/arm/kernel/calls.S
index 9f899d8fdcca..e51833f8cc38 100644
--- a/arch/arm/kernel/calls.S
+++ b/arch/arm/kernel/calls.S
@@ -395,6 +395,7 @@
395 CALL(sys_seccomp) 395 CALL(sys_seccomp)
396 CALL(sys_getrandom) 396 CALL(sys_getrandom)
397/* 385 */ CALL(sys_memfd_create) 397/* 385 */ CALL(sys_memfd_create)
398 CALL(sys_bpf)
398#ifndef syscalls_counted 399#ifndef syscalls_counted
399.equ syscalls_padding, ((NR_syscalls + 3) & ~3) - NR_syscalls 400.equ syscalls_padding, ((NR_syscalls + 3) & ~3) - NR_syscalls
400#define syscalls_counted 401#define syscalls_counted
diff --git a/arch/arm/mach-ixp4xx/include/mach/io.h b/arch/arm/mach-ixp4xx/include/mach/io.h
index 559c69a47731..7d11979da030 100644
--- a/arch/arm/mach-ixp4xx/include/mach/io.h
+++ b/arch/arm/mach-ixp4xx/include/mach/io.h
@@ -76,7 +76,7 @@ static inline void __indirect_writeb(u8 value, volatile void __iomem *p)
76 u32 n, byte_enables, data; 76 u32 n, byte_enables, data;
77 77
78 if (!is_pci_memory(addr)) { 78 if (!is_pci_memory(addr)) {
79 __raw_writeb(value, addr); 79 __raw_writeb(value, p);
80 return; 80 return;
81 } 81 }
82 82
@@ -141,7 +141,7 @@ static inline unsigned char __indirect_readb(const volatile void __iomem *p)
141 u32 n, byte_enables, data; 141 u32 n, byte_enables, data;
142 142
143 if (!is_pci_memory(addr)) 143 if (!is_pci_memory(addr))
144 return __raw_readb(addr); 144 return __raw_readb(p);
145 145
146 n = addr % 4; 146 n = addr % 4;
147 byte_enables = (0xf & ~BIT(n)) << IXP4XX_PCI_NP_CBE_BESL; 147 byte_enables = (0xf & ~BIT(n)) << IXP4XX_PCI_NP_CBE_BESL;
diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c
index d22c30d3ccfa..8c58b71c2727 100644
--- a/arch/arm/mach-omap2/omap_device.c
+++ b/arch/arm/mach-omap2/omap_device.c
@@ -917,6 +917,10 @@ static int __init omap_device_late_idle(struct device *dev, void *data)
917static int __init omap_device_late_init(void) 917static int __init omap_device_late_init(void)
918{ 918{
919 bus_for_each_dev(&platform_bus_type, NULL, NULL, omap_device_late_idle); 919 bus_for_each_dev(&platform_bus_type, NULL, NULL, omap_device_late_idle);
920
921 WARN(!of_have_populated_dt(),
922 "legacy booting deprecated, please update to boot with .dts\n");
923
920 return 0; 924 return 0;
921} 925}
922omap_late_initcall_sync(omap_device_late_init); 926omap_late_initcall_sync(omap_device_late_init);
diff --git a/arch/arm/mach-omap2/pdata-quirks.c b/arch/arm/mach-omap2/pdata-quirks.c
index c95346c94829..cec9d6c6442c 100644
--- a/arch/arm/mach-omap2/pdata-quirks.c
+++ b/arch/arm/mach-omap2/pdata-quirks.c
@@ -252,9 +252,6 @@ static void __init nokia_n900_legacy_init(void)
252 platform_device_register(&omap3_rom_rng_device); 252 platform_device_register(&omap3_rom_rng_device);
253 253
254 } 254 }
255
256 /* Only on some development boards */
257 gpio_request_one(164, GPIOF_OUT_INIT_LOW, "smc91x reset");
258} 255}
259 256
260static void __init omap3_tao3530_legacy_init(void) 257static void __init omap3_tao3530_legacy_init(void)
diff --git a/arch/arm/mach-pxa/include/mach/addr-map.h b/arch/arm/mach-pxa/include/mach/addr-map.h
index bbf9df37ad4b..d28fe291233a 100644
--- a/arch/arm/mach-pxa/include/mach/addr-map.h
+++ b/arch/arm/mach-pxa/include/mach/addr-map.h
@@ -39,6 +39,11 @@
39#define DMEMC_SIZE 0x00100000 39#define DMEMC_SIZE 0x00100000
40 40
41/* 41/*
42 * Reserved space for low level debug virtual addresses within
43 * 0xf6200000..0xf6201000
44 */
45
46/*
42 * Internal Memory Controller (PXA27x and later) 47 * Internal Memory Controller (PXA27x and later)
43 */ 48 */
44#define IMEMC_PHYS 0x58000000 49#define IMEMC_PHYS 0x58000000
diff --git a/arch/arm/mm/cache-l2x0.c b/arch/arm/mm/cache-l2x0.c
index 55f9d6e0cc88..5e65ca8dea62 100644
--- a/arch/arm/mm/cache-l2x0.c
+++ b/arch/arm/mm/cache-l2x0.c
@@ -956,7 +956,7 @@ static u32 cache_id_part_number_from_dt;
956 * @associativity: variable to return the calculated associativity in 956 * @associativity: variable to return the calculated associativity in
957 * @max_way_size: the maximum size in bytes for the cache ways 957 * @max_way_size: the maximum size in bytes for the cache ways
958 */ 958 */
959static void __init l2x0_cache_size_of_parse(const struct device_node *np, 959static int __init l2x0_cache_size_of_parse(const struct device_node *np,
960 u32 *aux_val, u32 *aux_mask, 960 u32 *aux_val, u32 *aux_mask,
961 u32 *associativity, 961 u32 *associativity,
962 u32 max_way_size) 962 u32 max_way_size)
@@ -974,7 +974,7 @@ static void __init l2x0_cache_size_of_parse(const struct device_node *np,
974 of_property_read_u32(np, "cache-line-size", &line_size); 974 of_property_read_u32(np, "cache-line-size", &line_size);
975 975
976 if (!cache_size || !sets) 976 if (!cache_size || !sets)
977 return; 977 return -ENODEV;
978 978
979 /* All these l2 caches have the same line = block size actually */ 979 /* All these l2 caches have the same line = block size actually */
980 if (!line_size) { 980 if (!line_size) {
@@ -1009,7 +1009,7 @@ static void __init l2x0_cache_size_of_parse(const struct device_node *np,
1009 1009
1010 if (way_size > max_way_size) { 1010 if (way_size > max_way_size) {
1011 pr_err("L2C OF: set size %dKB is too large\n", way_size); 1011 pr_err("L2C OF: set size %dKB is too large\n", way_size);
1012 return; 1012 return -EINVAL;
1013 } 1013 }
1014 1014
1015 pr_info("L2C OF: override cache size: %d bytes (%dKB)\n", 1015 pr_info("L2C OF: override cache size: %d bytes (%dKB)\n",
@@ -1027,7 +1027,7 @@ static void __init l2x0_cache_size_of_parse(const struct device_node *np,
1027 if (way_size_bits < 1 || way_size_bits > 6) { 1027 if (way_size_bits < 1 || way_size_bits > 6) {
1028 pr_err("L2C OF: cache way size illegal: %dKB is not mapped\n", 1028 pr_err("L2C OF: cache way size illegal: %dKB is not mapped\n",
1029 way_size); 1029 way_size);
1030 return; 1030 return -EINVAL;
1031 } 1031 }
1032 1032
1033 mask |= L2C_AUX_CTRL_WAY_SIZE_MASK; 1033 mask |= L2C_AUX_CTRL_WAY_SIZE_MASK;
@@ -1036,6 +1036,8 @@ static void __init l2x0_cache_size_of_parse(const struct device_node *np,
1036 *aux_val &= ~mask; 1036 *aux_val &= ~mask;
1037 *aux_val |= val; 1037 *aux_val |= val;
1038 *aux_mask &= ~mask; 1038 *aux_mask &= ~mask;
1039
1040 return 0;
1039} 1041}
1040 1042
1041static void __init l2x0_of_parse(const struct device_node *np, 1043static void __init l2x0_of_parse(const struct device_node *np,
@@ -1046,6 +1048,7 @@ static void __init l2x0_of_parse(const struct device_node *np,
1046 u32 dirty = 0; 1048 u32 dirty = 0;
1047 u32 val = 0, mask = 0; 1049 u32 val = 0, mask = 0;
1048 u32 assoc; 1050 u32 assoc;
1051 int ret;
1049 1052
1050 of_property_read_u32(np, "arm,tag-latency", &tag); 1053 of_property_read_u32(np, "arm,tag-latency", &tag);
1051 if (tag) { 1054 if (tag) {
@@ -1068,7 +1071,10 @@ static void __init l2x0_of_parse(const struct device_node *np,
1068 val |= (dirty - 1) << L2X0_AUX_CTRL_DIRTY_LATENCY_SHIFT; 1071 val |= (dirty - 1) << L2X0_AUX_CTRL_DIRTY_LATENCY_SHIFT;
1069 } 1072 }
1070 1073
1071 l2x0_cache_size_of_parse(np, aux_val, aux_mask, &assoc, SZ_256K); 1074 ret = l2x0_cache_size_of_parse(np, aux_val, aux_mask, &assoc, SZ_256K);
1075 if (ret)
1076 return;
1077
1072 if (assoc > 8) { 1078 if (assoc > 8) {
1073 pr_err("l2x0 of: cache setting yield too high associativity\n"); 1079 pr_err("l2x0 of: cache setting yield too high associativity\n");
1074 pr_err("l2x0 of: %d calculated, max 8\n", assoc); 1080 pr_err("l2x0 of: %d calculated, max 8\n", assoc);
@@ -1125,6 +1131,7 @@ static void __init l2c310_of_parse(const struct device_node *np,
1125 u32 tag[3] = { 0, 0, 0 }; 1131 u32 tag[3] = { 0, 0, 0 };
1126 u32 filter[2] = { 0, 0 }; 1132 u32 filter[2] = { 0, 0 };
1127 u32 assoc; 1133 u32 assoc;
1134 int ret;
1128 1135
1129 of_property_read_u32_array(np, "arm,tag-latency", tag, ARRAY_SIZE(tag)); 1136 of_property_read_u32_array(np, "arm,tag-latency", tag, ARRAY_SIZE(tag));
1130 if (tag[0] && tag[1] && tag[2]) 1137 if (tag[0] && tag[1] && tag[2])
@@ -1152,7 +1159,10 @@ static void __init l2c310_of_parse(const struct device_node *np,
1152 l2x0_base + L310_ADDR_FILTER_START); 1159 l2x0_base + L310_ADDR_FILTER_START);
1153 } 1160 }
1154 1161
1155 l2x0_cache_size_of_parse(np, aux_val, aux_mask, &assoc, SZ_512K); 1162 ret = l2x0_cache_size_of_parse(np, aux_val, aux_mask, &assoc, SZ_512K);
1163 if (ret)
1164 return;
1165
1156 switch (assoc) { 1166 switch (assoc) {
1157 case 16: 1167 case 16:
1158 *aux_val &= ~L2X0_AUX_CTRL_ASSOC_MASK; 1168 *aux_val &= ~L2X0_AUX_CTRL_ASSOC_MASK;
@@ -1164,8 +1174,8 @@ static void __init l2c310_of_parse(const struct device_node *np,
1164 *aux_mask &= ~L2X0_AUX_CTRL_ASSOC_MASK; 1174 *aux_mask &= ~L2X0_AUX_CTRL_ASSOC_MASK;
1165 break; 1175 break;
1166 default: 1176 default:
1167 pr_err("PL310 OF: cache setting yield illegal associativity\n"); 1177 pr_err("L2C-310 OF cache associativity %d invalid, only 8 or 16 permitted\n",
1168 pr_err("PL310 OF: %d calculated, only 8 and 16 legal\n", assoc); 1178 assoc);
1169 break; 1179 break;
1170 } 1180 }
1171} 1181}
diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
index c245d903927f..e8907117861e 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -1198,7 +1198,6 @@ __iommu_alloc_remap(struct page **pages, size_t size, gfp_t gfp, pgprot_t prot,
1198{ 1198{
1199 return dma_common_pages_remap(pages, size, 1199 return dma_common_pages_remap(pages, size,
1200 VM_ARM_DMA_CONSISTENT | VM_USERMAP, prot, caller); 1200 VM_ARM_DMA_CONSISTENT | VM_USERMAP, prot, caller);
1201 return NULL;
1202} 1201}
1203 1202
1204/* 1203/*
diff --git a/arch/arm/mm/highmem.c b/arch/arm/mm/highmem.c
index 45aeaaca9052..e17ed00828d7 100644
--- a/arch/arm/mm/highmem.c
+++ b/arch/arm/mm/highmem.c
@@ -127,8 +127,11 @@ void *kmap_atomic_pfn(unsigned long pfn)
127{ 127{
128 unsigned long vaddr; 128 unsigned long vaddr;
129 int idx, type; 129 int idx, type;
130 struct page *page = pfn_to_page(pfn);
130 131
131 pagefault_disable(); 132 pagefault_disable();
133 if (!PageHighMem(page))
134 return page_address(page);
132 135
133 type = kmap_atomic_idx_push(); 136 type = kmap_atomic_idx_push();
134 idx = type + KM_TYPE_NR * smp_processor_id(); 137 idx = type + KM_TYPE_NR * smp_processor_id();
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index 92bba32d9230..9481f85c56e6 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -559,10 +559,10 @@ void __init mem_init(void)
559#ifdef CONFIG_MODULES 559#ifdef CONFIG_MODULES
560 " modules : 0x%08lx - 0x%08lx (%4ld MB)\n" 560 " modules : 0x%08lx - 0x%08lx (%4ld MB)\n"
561#endif 561#endif
562 " .text : 0x%p" " - 0x%p" " (%4d kB)\n" 562 " .text : 0x%p" " - 0x%p" " (%4td kB)\n"
563 " .init : 0x%p" " - 0x%p" " (%4d kB)\n" 563 " .init : 0x%p" " - 0x%p" " (%4td kB)\n"
564 " .data : 0x%p" " - 0x%p" " (%4d kB)\n" 564 " .data : 0x%p" " - 0x%p" " (%4td kB)\n"
565 " .bss : 0x%p" " - 0x%p" " (%4d kB)\n", 565 " .bss : 0x%p" " - 0x%p" " (%4td kB)\n",
566 566
567 MLK(UL(CONFIG_VECTORS_BASE), UL(CONFIG_VECTORS_BASE) + 567 MLK(UL(CONFIG_VECTORS_BASE), UL(CONFIG_VECTORS_BASE) +
568 (PAGE_SIZE)), 568 (PAGE_SIZE)),
diff --git a/arch/m68k/include/asm/unistd.h b/arch/m68k/include/asm/unistd.h
index 4ef7a54813e6..75e75d7b1702 100644
--- a/arch/m68k/include/asm/unistd.h
+++ b/arch/m68k/include/asm/unistd.h
@@ -4,7 +4,7 @@
4#include <uapi/asm/unistd.h> 4#include <uapi/asm/unistd.h>
5 5
6 6
7#define NR_syscalls 354 7#define NR_syscalls 355
8 8
9#define __ARCH_WANT_OLD_READDIR 9#define __ARCH_WANT_OLD_READDIR
10#define __ARCH_WANT_OLD_STAT 10#define __ARCH_WANT_OLD_STAT
diff --git a/arch/m68k/include/uapi/asm/unistd.h b/arch/m68k/include/uapi/asm/unistd.h
index b419c6b7ac37..2c1bec9a14b6 100644
--- a/arch/m68k/include/uapi/asm/unistd.h
+++ b/arch/m68k/include/uapi/asm/unistd.h
@@ -359,5 +359,6 @@
359#define __NR_renameat2 351 359#define __NR_renameat2 351
360#define __NR_getrandom 352 360#define __NR_getrandom 352
361#define __NR_memfd_create 353 361#define __NR_memfd_create 353
362#define __NR_bpf 354
362 363
363#endif /* _UAPI_ASM_M68K_UNISTD_H_ */ 364#endif /* _UAPI_ASM_M68K_UNISTD_H_ */
diff --git a/arch/m68k/kernel/syscalltable.S b/arch/m68k/kernel/syscalltable.S
index 05b46c2b08b8..2ca219e184cd 100644
--- a/arch/m68k/kernel/syscalltable.S
+++ b/arch/m68k/kernel/syscalltable.S
@@ -374,4 +374,5 @@ ENTRY(sys_call_table)
374 .long sys_renameat2 374 .long sys_renameat2
375 .long sys_getrandom 375 .long sys_getrandom
376 .long sys_memfd_create 376 .long sys_memfd_create
377 .long sys_bpf
377 378
diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig
index 6feded3b0c4c..a7736fa0580c 100644
--- a/arch/microblaze/Kconfig
+++ b/arch/microblaze/Kconfig
@@ -129,6 +129,10 @@ endmenu
129 129
130menu "Kernel features" 130menu "Kernel features"
131 131
132config NR_CPUS
133 int
134 default "1"
135
132config ADVANCED_OPTIONS 136config ADVANCED_OPTIONS
133 bool "Prompt for advanced kernel configuration options" 137 bool "Prompt for advanced kernel configuration options"
134 help 138 help
diff --git a/arch/microblaze/include/asm/unistd.h b/arch/microblaze/include/asm/unistd.h
index ea4b233647c1..0a53362d5548 100644
--- a/arch/microblaze/include/asm/unistd.h
+++ b/arch/microblaze/include/asm/unistd.h
@@ -38,6 +38,6 @@
38 38
39#endif /* __ASSEMBLY__ */ 39#endif /* __ASSEMBLY__ */
40 40
41#define __NR_syscalls 387 41#define __NR_syscalls 388
42 42
43#endif /* _ASM_MICROBLAZE_UNISTD_H */ 43#endif /* _ASM_MICROBLAZE_UNISTD_H */
diff --git a/arch/microblaze/include/uapi/asm/unistd.h b/arch/microblaze/include/uapi/asm/unistd.h
index 1c2380bf8fe6..c712677f8a2a 100644
--- a/arch/microblaze/include/uapi/asm/unistd.h
+++ b/arch/microblaze/include/uapi/asm/unistd.h
@@ -402,5 +402,6 @@
402#define __NR_seccomp 384 402#define __NR_seccomp 384
403#define __NR_getrandom 385 403#define __NR_getrandom 385
404#define __NR_memfd_create 386 404#define __NR_memfd_create 386
405#define __NR_bpf 387
405 406
406#endif /* _UAPI_ASM_MICROBLAZE_UNISTD_H */ 407#endif /* _UAPI_ASM_MICROBLAZE_UNISTD_H */
diff --git a/arch/microblaze/kernel/syscall_table.S b/arch/microblaze/kernel/syscall_table.S
index de59ee1d7010..0166e890486c 100644
--- a/arch/microblaze/kernel/syscall_table.S
+++ b/arch/microblaze/kernel/syscall_table.S
@@ -387,3 +387,4 @@ ENTRY(sys_call_table)
387 .long sys_seccomp 387 .long sys_seccomp
388 .long sys_getrandom /* 385 */ 388 .long sys_getrandom /* 385 */
389 .long sys_memfd_create 389 .long sys_memfd_create
390 .long sys_bpf
diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
index 9037914f6985..b30e41c0c033 100644
--- a/arch/microblaze/pci/pci-common.c
+++ b/arch/microblaze/pci/pci-common.c
@@ -660,8 +660,13 @@ void pci_process_bridge_OF_ranges(struct pci_controller *hose,
660 res = &hose->mem_resources[memno++]; 660 res = &hose->mem_resources[memno++];
661 break; 661 break;
662 } 662 }
663 if (res != NULL) 663 if (res != NULL) {
664 of_pci_range_to_resource(&range, dev, res); 664 res->name = dev->full_name;
665 res->flags = range.flags;
666 res->start = range.cpu_addr;
667 res->end = range.cpu_addr + range.size - 1;
668 res->parent = res->child = res->sibling = NULL;
669 }
665 } 670 }
666 671
667 /* If there's an ISA hole and the pci_mem_offset is -not- matching 672 /* If there's an ISA hole and the pci_mem_offset is -not- matching
diff --git a/arch/powerpc/include/asm/hugetlb.h b/arch/powerpc/include/asm/hugetlb.h
index 623f2971ce0e..766b77d527ac 100644
--- a/arch/powerpc/include/asm/hugetlb.h
+++ b/arch/powerpc/include/asm/hugetlb.h
@@ -71,7 +71,7 @@ pte_t *huge_pte_offset_and_shift(struct mm_struct *mm,
71 71
72void flush_dcache_icache_hugepage(struct page *page); 72void flush_dcache_icache_hugepage(struct page *page);
73 73
74#if defined(CONFIG_PPC_MM_SLICES) || defined(CONFIG_PPC_SUBPAGE_PROT) 74#if defined(CONFIG_PPC_MM_SLICES)
75int is_hugepage_only_range(struct mm_struct *mm, unsigned long addr, 75int is_hugepage_only_range(struct mm_struct *mm, unsigned long addr,
76 unsigned long len); 76 unsigned long len);
77#else 77#else
diff --git a/arch/powerpc/include/asm/systbl.h b/arch/powerpc/include/asm/systbl.h
index 7d8a60068805..ce9577d693be 100644
--- a/arch/powerpc/include/asm/systbl.h
+++ b/arch/powerpc/include/asm/systbl.h
@@ -365,3 +365,4 @@ SYSCALL_SPU(renameat2)
365SYSCALL_SPU(seccomp) 365SYSCALL_SPU(seccomp)
366SYSCALL_SPU(getrandom) 366SYSCALL_SPU(getrandom)
367SYSCALL_SPU(memfd_create) 367SYSCALL_SPU(memfd_create)
368SYSCALL_SPU(bpf)
diff --git a/arch/powerpc/include/asm/unistd.h b/arch/powerpc/include/asm/unistd.h
index 4e9af3fd43e7..e0da021caa00 100644
--- a/arch/powerpc/include/asm/unistd.h
+++ b/arch/powerpc/include/asm/unistd.h
@@ -12,7 +12,7 @@
12#include <uapi/asm/unistd.h> 12#include <uapi/asm/unistd.h>
13 13
14 14
15#define __NR_syscalls 361 15#define __NR_syscalls 362
16 16
17#define __NR__exit __NR_exit 17#define __NR__exit __NR_exit
18#define NR_syscalls __NR_syscalls 18#define NR_syscalls __NR_syscalls
diff --git a/arch/powerpc/include/uapi/asm/unistd.h b/arch/powerpc/include/uapi/asm/unistd.h
index 0688fc06e183..f55351f2e66e 100644
--- a/arch/powerpc/include/uapi/asm/unistd.h
+++ b/arch/powerpc/include/uapi/asm/unistd.h
@@ -383,5 +383,6 @@
383#define __NR_seccomp 358 383#define __NR_seccomp 358
384#define __NR_getrandom 359 384#define __NR_getrandom 359
385#define __NR_memfd_create 360 385#define __NR_memfd_create 360
386#define __NR_bpf 361
386 387
387#endif /* _UAPI_ASM_POWERPC_UNISTD_H_ */ 388#endif /* _UAPI_ASM_POWERPC_UNISTD_H_ */
diff --git a/arch/powerpc/mm/copro_fault.c b/arch/powerpc/mm/copro_fault.c
index 0f9939e693df..5a236f082c78 100644
--- a/arch/powerpc/mm/copro_fault.c
+++ b/arch/powerpc/mm/copro_fault.c
@@ -99,8 +99,6 @@ int copro_calculate_slb(struct mm_struct *mm, u64 ea, struct copro_slb *slb)
99 u64 vsid; 99 u64 vsid;
100 int psize, ssize; 100 int psize, ssize;
101 101
102 slb->esid = (ea & ESID_MASK) | SLB_ESID_V;
103
104 switch (REGION_ID(ea)) { 102 switch (REGION_ID(ea)) {
105 case USER_REGION_ID: 103 case USER_REGION_ID:
106 pr_devel("%s: 0x%llx -- USER_REGION_ID\n", __func__, ea); 104 pr_devel("%s: 0x%llx -- USER_REGION_ID\n", __func__, ea);
@@ -133,6 +131,7 @@ int copro_calculate_slb(struct mm_struct *mm, u64 ea, struct copro_slb *slb)
133 vsid |= mmu_psize_defs[psize].sllp | 131 vsid |= mmu_psize_defs[psize].sllp |
134 ((ssize == MMU_SEGSIZE_1T) ? SLB_VSID_B_1T : 0); 132 ((ssize == MMU_SEGSIZE_1T) ? SLB_VSID_B_1T : 0);
135 133
134 slb->esid = (ea & (ssize == MMU_SEGSIZE_1T ? ESID_MASK_1T : ESID_MASK)) | SLB_ESID_V;
136 slb->vsid = vsid; 135 slb->vsid = vsid;
137 136
138 return 0; 137 return 0;
diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
index e5236c24dc07..b9d1dfdbe5bb 100644
--- a/arch/powerpc/mm/numa.c
+++ b/arch/powerpc/mm/numa.c
@@ -1509,11 +1509,14 @@ static int update_cpu_topology(void *data)
1509 cpu = smp_processor_id(); 1509 cpu = smp_processor_id();
1510 1510
1511 for (update = data; update; update = update->next) { 1511 for (update = data; update; update = update->next) {
1512 int new_nid = update->new_nid;
1512 if (cpu != update->cpu) 1513 if (cpu != update->cpu)
1513 continue; 1514 continue;
1514 1515
1515 unmap_cpu_from_node(update->cpu); 1516 unmap_cpu_from_node(cpu);
1516 map_cpu_to_node(update->cpu, update->new_nid); 1517 map_cpu_to_node(cpu, new_nid);
1518 set_cpu_numa_node(cpu, new_nid);
1519 set_cpu_numa_mem(cpu, local_memory_node(new_nid));
1517 vdso_getcpu_init(); 1520 vdso_getcpu_init();
1518 } 1521 }
1519 1522
diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c
index 8d7bda94d196..ded0ea1afde4 100644
--- a/arch/powerpc/mm/slice.c
+++ b/arch/powerpc/mm/slice.c
@@ -682,6 +682,7 @@ void slice_set_range_psize(struct mm_struct *mm, unsigned long start,
682 slice_convert(mm, mask, psize); 682 slice_convert(mm, mask, psize);
683} 683}
684 684
685#ifdef CONFIG_HUGETLB_PAGE
685/* 686/*
686 * is_hugepage_only_range() is used by generic code to verify whether 687 * is_hugepage_only_range() is used by generic code to verify whether
687 * a normal mmap mapping (non hugetlbfs) is valid on a given area. 688 * a normal mmap mapping (non hugetlbfs) is valid on a given area.
@@ -726,4 +727,4 @@ int is_hugepage_only_range(struct mm_struct *mm, unsigned long addr,
726#endif 727#endif
727 return !slice_check_fit(mask, available); 728 return !slice_check_fit(mask, available);
728} 729}
729 730#endif
diff --git a/arch/powerpc/perf/hv-24x7.c b/arch/powerpc/perf/hv-24x7.c
index 6c8710dd90c9..dba34088da28 100644
--- a/arch/powerpc/perf/hv-24x7.c
+++ b/arch/powerpc/perf/hv-24x7.c
@@ -417,11 +417,6 @@ static int h_24x7_event_add(struct perf_event *event, int flags)
417 return 0; 417 return 0;
418} 418}
419 419
420static int h_24x7_event_idx(struct perf_event *event)
421{
422 return 0;
423}
424
425static struct pmu h_24x7_pmu = { 420static struct pmu h_24x7_pmu = {
426 .task_ctx_nr = perf_invalid_context, 421 .task_ctx_nr = perf_invalid_context,
427 422
@@ -433,7 +428,6 @@ static struct pmu h_24x7_pmu = {
433 .start = h_24x7_event_start, 428 .start = h_24x7_event_start,
434 .stop = h_24x7_event_stop, 429 .stop = h_24x7_event_stop,
435 .read = h_24x7_event_update, 430 .read = h_24x7_event_update,
436 .event_idx = h_24x7_event_idx,
437}; 431};
438 432
439static int hv_24x7_init(void) 433static int hv_24x7_init(void)
diff --git a/arch/powerpc/perf/hv-gpci.c b/arch/powerpc/perf/hv-gpci.c
index 15fc76c93022..a051fe946c63 100644
--- a/arch/powerpc/perf/hv-gpci.c
+++ b/arch/powerpc/perf/hv-gpci.c
@@ -246,11 +246,6 @@ static int h_gpci_event_init(struct perf_event *event)
246 return 0; 246 return 0;
247} 247}
248 248
249static int h_gpci_event_idx(struct perf_event *event)
250{
251 return 0;
252}
253
254static struct pmu h_gpci_pmu = { 249static struct pmu h_gpci_pmu = {
255 .task_ctx_nr = perf_invalid_context, 250 .task_ctx_nr = perf_invalid_context,
256 251
@@ -262,7 +257,6 @@ static struct pmu h_gpci_pmu = {
262 .start = h_gpci_event_start, 257 .start = h_gpci_event_start,
263 .stop = h_gpci_event_stop, 258 .stop = h_gpci_event_stop,
264 .read = h_gpci_event_update, 259 .read = h_gpci_event_update,
265 .event_idx = h_gpci_event_idx,
266}; 260};
267 261
268static int hv_gpci_init(void) 262static int hv_gpci_init(void)
diff --git a/arch/powerpc/platforms/powernv/opal-lpc.c b/arch/powerpc/platforms/powernv/opal-lpc.c
index dd2c285ad170..ad4b31df779a 100644
--- a/arch/powerpc/platforms/powernv/opal-lpc.c
+++ b/arch/powerpc/platforms/powernv/opal-lpc.c
@@ -191,7 +191,6 @@ static ssize_t lpc_debug_read(struct file *filp, char __user *ubuf,
191{ 191{
192 struct lpc_debugfs_entry *lpc = filp->private_data; 192 struct lpc_debugfs_entry *lpc = filp->private_data;
193 u32 data, pos, len, todo; 193 u32 data, pos, len, todo;
194 __be32 bedata;
195 int rc; 194 int rc;
196 195
197 if (!access_ok(VERIFY_WRITE, ubuf, count)) 196 if (!access_ok(VERIFY_WRITE, ubuf, count))
@@ -214,10 +213,9 @@ static ssize_t lpc_debug_read(struct file *filp, char __user *ubuf,
214 len = 2; 213 len = 2;
215 } 214 }
216 rc = opal_lpc_read(opal_lpc_chip_id, lpc->lpc_type, pos, 215 rc = opal_lpc_read(opal_lpc_chip_id, lpc->lpc_type, pos,
217 &bedata, len); 216 &data, len);
218 if (rc) 217 if (rc)
219 return -ENXIO; 218 return -ENXIO;
220 data = be32_to_cpu(bedata);
221 switch(len) { 219 switch(len) {
222 case 4: 220 case 4:
223 rc = __put_user((u32)data, (u32 __user *)ubuf); 221 rc = __put_user((u32)data, (u32 __user *)ubuf);
diff --git a/arch/powerpc/platforms/powernv/opal-wrappers.S b/arch/powerpc/platforms/powernv/opal-wrappers.S
index e9e2450c1fdd..feb549aa3eea 100644
--- a/arch/powerpc/platforms/powernv/opal-wrappers.S
+++ b/arch/powerpc/platforms/powernv/opal-wrappers.S
@@ -58,7 +58,7 @@ END_FTR_SECTION(0, 1); \
58 */ 58 */
59 59
60#define OPAL_CALL(name, token) \ 60#define OPAL_CALL(name, token) \
61 _GLOBAL(name); \ 61 _GLOBAL_TOC(name); \
62 mflr r0; \ 62 mflr r0; \
63 std r0,16(r1); \ 63 std r0,16(r1); \
64 li r0,token; \ 64 li r0,token; \
diff --git a/arch/s390/kernel/perf_cpum_sf.c b/arch/s390/kernel/perf_cpum_sf.c
index 08e761318c17..b878f12a9597 100644
--- a/arch/s390/kernel/perf_cpum_sf.c
+++ b/arch/s390/kernel/perf_cpum_sf.c
@@ -1411,11 +1411,6 @@ static void cpumsf_pmu_del(struct perf_event *event, int flags)
1411 perf_pmu_enable(event->pmu); 1411 perf_pmu_enable(event->pmu);
1412} 1412}
1413 1413
1414static int cpumsf_pmu_event_idx(struct perf_event *event)
1415{
1416 return event->hw.idx;
1417}
1418
1419CPUMF_EVENT_ATTR(SF, SF_CYCLES_BASIC, PERF_EVENT_CPUM_SF); 1414CPUMF_EVENT_ATTR(SF, SF_CYCLES_BASIC, PERF_EVENT_CPUM_SF);
1420CPUMF_EVENT_ATTR(SF, SF_CYCLES_BASIC_DIAG, PERF_EVENT_CPUM_SF_DIAG); 1415CPUMF_EVENT_ATTR(SF, SF_CYCLES_BASIC_DIAG, PERF_EVENT_CPUM_SF_DIAG);
1421 1416
@@ -1458,7 +1453,6 @@ static struct pmu cpumf_sampling = {
1458 .stop = cpumsf_pmu_stop, 1453 .stop = cpumsf_pmu_stop,
1459 .read = cpumsf_pmu_read, 1454 .read = cpumsf_pmu_read,
1460 1455
1461 .event_idx = cpumsf_pmu_event_idx,
1462 .attr_groups = cpumsf_pmu_attr_groups, 1456 .attr_groups = cpumsf_pmu_attr_groups,
1463}; 1457};
1464 1458
diff --git a/arch/sh/kernel/cpu/sh3/setup-sh770x.c b/arch/sh/kernel/cpu/sh3/setup-sh770x.c
index 9139d14b9c53..538c10db3537 100644
--- a/arch/sh/kernel/cpu/sh3/setup-sh770x.c
+++ b/arch/sh/kernel/cpu/sh3/setup-sh770x.c
@@ -118,7 +118,7 @@ static struct plat_sci_port scif0_platform_data = {
118}; 118};
119 119
120static struct resource scif0_resources[] = { 120static struct resource scif0_resources[] = {
121 DEFINE_RES_MEM(0xfffffe80, 0x100), 121 DEFINE_RES_MEM(0xfffffe80, 0x10),
122 DEFINE_RES_IRQ(evt2irq(0x4e0)), 122 DEFINE_RES_IRQ(evt2irq(0x4e0)),
123}; 123};
124 124
@@ -143,7 +143,7 @@ static struct plat_sci_port scif1_platform_data = {
143}; 143};
144 144
145static struct resource scif1_resources[] = { 145static struct resource scif1_resources[] = {
146 DEFINE_RES_MEM(0xa4000150, 0x100), 146 DEFINE_RES_MEM(0xa4000150, 0x10),
147 DEFINE_RES_IRQ(evt2irq(0x900)), 147 DEFINE_RES_IRQ(evt2irq(0x900)),
148}; 148};
149 149
@@ -169,7 +169,7 @@ static struct plat_sci_port scif2_platform_data = {
169}; 169};
170 170
171static struct resource scif2_resources[] = { 171static struct resource scif2_resources[] = {
172 DEFINE_RES_MEM(0xa4000140, 0x100), 172 DEFINE_RES_MEM(0xa4000140, 0x10),
173 DEFINE_RES_IRQ(evt2irq(0x880)), 173 DEFINE_RES_IRQ(evt2irq(0x880)),
174}; 174};
175 175
diff --git a/arch/sparc/include/uapi/asm/unistd.h b/arch/sparc/include/uapi/asm/unistd.h
index c842a89b1190..46d83842eddc 100644
--- a/arch/sparc/include/uapi/asm/unistd.h
+++ b/arch/sparc/include/uapi/asm/unistd.h
@@ -414,8 +414,9 @@
414#define __NR_seccomp 346 414#define __NR_seccomp 346
415#define __NR_getrandom 347 415#define __NR_getrandom 347
416#define __NR_memfd_create 348 416#define __NR_memfd_create 348
417#define __NR_bpf 349
417 418
418#define NR_syscalls 349 419#define NR_syscalls 350
419 420
420/* Bitmask values returned from kern_features system call. */ 421/* Bitmask values returned from kern_features system call. */
421#define KERN_FEATURE_MIXED_MODE_STACK 0x00000001 422#define KERN_FEATURE_MIXED_MODE_STACK 0x00000001
diff --git a/arch/sparc/kernel/systbls_32.S b/arch/sparc/kernel/systbls_32.S
index 6a873c344bc0..ad0cdf497b78 100644
--- a/arch/sparc/kernel/systbls_32.S
+++ b/arch/sparc/kernel/systbls_32.S
@@ -86,4 +86,4 @@ sys_call_table:
86/*330*/ .long sys_fanotify_mark, sys_prlimit64, sys_name_to_handle_at, sys_open_by_handle_at, sys_clock_adjtime 86/*330*/ .long sys_fanotify_mark, sys_prlimit64, sys_name_to_handle_at, sys_open_by_handle_at, sys_clock_adjtime
87/*335*/ .long sys_syncfs, sys_sendmmsg, sys_setns, sys_process_vm_readv, sys_process_vm_writev 87/*335*/ .long sys_syncfs, sys_sendmmsg, sys_setns, sys_process_vm_readv, sys_process_vm_writev
88/*340*/ .long sys_ni_syscall, sys_kcmp, sys_finit_module, sys_sched_setattr, sys_sched_getattr 88/*340*/ .long sys_ni_syscall, sys_kcmp, sys_finit_module, sys_sched_setattr, sys_sched_getattr
89/*345*/ .long sys_renameat2, sys_seccomp, sys_getrandom, sys_memfd_create 89/*345*/ .long sys_renameat2, sys_seccomp, sys_getrandom, sys_memfd_create, sys_bpf
diff --git a/arch/sparc/kernel/systbls_64.S b/arch/sparc/kernel/systbls_64.S
index d9151b6490d8..580cde9370c9 100644
--- a/arch/sparc/kernel/systbls_64.S
+++ b/arch/sparc/kernel/systbls_64.S
@@ -87,7 +87,7 @@ sys_call_table32:
87/*330*/ .word compat_sys_fanotify_mark, sys_prlimit64, sys_name_to_handle_at, compat_sys_open_by_handle_at, compat_sys_clock_adjtime 87/*330*/ .word compat_sys_fanotify_mark, sys_prlimit64, sys_name_to_handle_at, compat_sys_open_by_handle_at, compat_sys_clock_adjtime
88 .word sys_syncfs, compat_sys_sendmmsg, sys_setns, compat_sys_process_vm_readv, compat_sys_process_vm_writev 88 .word sys_syncfs, compat_sys_sendmmsg, sys_setns, compat_sys_process_vm_readv, compat_sys_process_vm_writev
89/*340*/ .word sys_kern_features, sys_kcmp, sys_finit_module, sys_sched_setattr, sys_sched_getattr 89/*340*/ .word sys_kern_features, sys_kcmp, sys_finit_module, sys_sched_setattr, sys_sched_getattr
90 .word sys32_renameat2, sys_seccomp, sys_getrandom, sys_memfd_create 90 .word sys32_renameat2, sys_seccomp, sys_getrandom, sys_memfd_create, sys_bpf
91 91
92#endif /* CONFIG_COMPAT */ 92#endif /* CONFIG_COMPAT */
93 93
@@ -166,4 +166,4 @@ sys_call_table:
166/*330*/ .word sys_fanotify_mark, sys_prlimit64, sys_name_to_handle_at, sys_open_by_handle_at, sys_clock_adjtime 166/*330*/ .word sys_fanotify_mark, sys_prlimit64, sys_name_to_handle_at, sys_open_by_handle_at, sys_clock_adjtime
167 .word sys_syncfs, sys_sendmmsg, sys_setns, sys_process_vm_readv, sys_process_vm_writev 167 .word sys_syncfs, sys_sendmmsg, sys_setns, sys_process_vm_readv, sys_process_vm_writev
168/*340*/ .word sys_kern_features, sys_kcmp, sys_finit_module, sys_sched_setattr, sys_sched_getattr 168/*340*/ .word sys_kern_features, sys_kcmp, sys_finit_module, sys_sched_setattr, sys_sched_getattr
169 .word sys_renameat2, sys_seccomp, sys_getrandom, sys_memfd_create 169 .word sys_renameat2, sys_seccomp, sys_getrandom, sys_memfd_create, sys_bpf
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index f2327e88e07c..ded8a6774ac9 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -142,6 +142,10 @@ config INSTRUCTION_DECODER
142 def_bool y 142 def_bool y
143 depends on KPROBES || PERF_EVENTS || UPROBES 143 depends on KPROBES || PERF_EVENTS || UPROBES
144 144
145config PERF_EVENTS_INTEL_UNCORE
146 def_bool y
147 depends on PERF_EVENTS && SUP_SUP_INTEL && PCI
148
145config OUTPUT_FORMAT 149config OUTPUT_FORMAT
146 string 150 string
147 default "elf32-i386" if X86_32 151 default "elf32-i386" if X86_32
diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
index 8ffba18395c8..ffe71228fc10 100644
--- a/arch/x86/ia32/ia32entry.S
+++ b/arch/x86/ia32/ia32entry.S
@@ -157,7 +157,7 @@ ENTRY(ia32_sysenter_target)
157 * ourselves. To save a few cycles, we can check whether 157 * ourselves. To save a few cycles, we can check whether
158 * NT was set instead of doing an unconditional popfq. 158 * NT was set instead of doing an unconditional popfq.
159 */ 159 */
160 testl $X86_EFLAGS_NT,EFLAGS(%rsp) /* saved EFLAGS match cpu */ 160 testl $X86_EFLAGS_NT,EFLAGS-ARGOFFSET(%rsp)
161 jnz sysenter_fix_flags 161 jnz sysenter_fix_flags
162sysenter_flags_fixed: 162sysenter_flags_fixed:
163 163
diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index b436fc735aa4..a142e77693e1 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -397,7 +397,7 @@ static int mp_register_gsi(struct device *dev, u32 gsi, int trigger,
397 397
398 /* Don't set up the ACPI SCI because it's already set up */ 398 /* Don't set up the ACPI SCI because it's already set up */
399 if (acpi_gbl_FADT.sci_interrupt == gsi) 399 if (acpi_gbl_FADT.sci_interrupt == gsi)
400 return gsi; 400 return mp_map_gsi_to_irq(gsi, IOAPIC_MAP_ALLOC);
401 401
402 trigger = trigger == ACPI_EDGE_SENSITIVE ? 0 : 1; 402 trigger = trigger == ACPI_EDGE_SENSITIVE ? 0 : 1;
403 polarity = polarity == ACPI_ACTIVE_HIGH ? 0 : 1; 403 polarity = polarity == ACPI_ACTIVE_HIGH ? 0 : 1;
@@ -604,14 +604,18 @@ void __init acpi_pic_sci_set_trigger(unsigned int irq, u16 trigger)
604 604
605int acpi_gsi_to_irq(u32 gsi, unsigned int *irqp) 605int acpi_gsi_to_irq(u32 gsi, unsigned int *irqp)
606{ 606{
607 int irq = mp_map_gsi_to_irq(gsi, IOAPIC_MAP_ALLOC | IOAPIC_MAP_CHECK); 607 int irq;
608 608
609 if (irq >= 0) { 609 if (acpi_irq_model == ACPI_IRQ_MODEL_PIC) {
610 *irqp = gsi;
611 } else {
612 irq = mp_map_gsi_to_irq(gsi,
613 IOAPIC_MAP_ALLOC | IOAPIC_MAP_CHECK);
614 if (irq < 0)
615 return -1;
610 *irqp = irq; 616 *irqp = irq;
611 return 0;
612 } 617 }
613 618 return 0;
614 return -1;
615} 619}
616EXPORT_SYMBOL_GPL(acpi_gsi_to_irq); 620EXPORT_SYMBOL_GPL(acpi_gsi_to_irq);
617 621
diff --git a/arch/x86/kernel/apb_timer.c b/arch/x86/kernel/apb_timer.c
index 5972b108f15a..b708738d016e 100644
--- a/arch/x86/kernel/apb_timer.c
+++ b/arch/x86/kernel/apb_timer.c
@@ -185,8 +185,6 @@ static void apbt_setup_irq(struct apbt_dev *adev)
185 185
186 irq_modify_status(adev->irq, 0, IRQ_MOVE_PCNTXT); 186 irq_modify_status(adev->irq, 0, IRQ_MOVE_PCNTXT);
187 irq_set_affinity(adev->irq, cpumask_of(adev->cpu)); 187 irq_set_affinity(adev->irq, cpumask_of(adev->cpu));
188 /* APB timer irqs are set up as mp_irqs, timer is edge type */
189 __irq_set_handler(adev->irq, handle_edge_irq, 0, "edge");
190} 188}
191 189
192/* Should be called with per cpu */ 190/* Should be called with per cpu */
diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index 00853b254ab0..ba6cc041edb1 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -1297,7 +1297,7 @@ void setup_local_APIC(void)
1297 unsigned int value, queued; 1297 unsigned int value, queued;
1298 int i, j, acked = 0; 1298 int i, j, acked = 0;
1299 unsigned long long tsc = 0, ntsc; 1299 unsigned long long tsc = 0, ntsc;
1300 long long max_loops = cpu_khz; 1300 long long max_loops = cpu_khz ? cpu_khz : 1000000;
1301 1301
1302 if (cpu_has_tsc) 1302 if (cpu_has_tsc)
1303 rdtscll(tsc); 1303 rdtscll(tsc);
@@ -1383,7 +1383,7 @@ void setup_local_APIC(void)
1383 break; 1383 break;
1384 } 1384 }
1385 if (queued) { 1385 if (queued) {
1386 if (cpu_has_tsc) { 1386 if (cpu_has_tsc && cpu_khz) {
1387 rdtscll(ntsc); 1387 rdtscll(ntsc);
1388 max_loops = (cpu_khz << 10) - (ntsc - tsc); 1388 max_loops = (cpu_khz << 10) - (ntsc - tsc);
1389 } else 1389 } else
diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
index 01d5453b5502..e27b49d7c922 100644
--- a/arch/x86/kernel/cpu/Makefile
+++ b/arch/x86/kernel/cpu/Makefile
@@ -39,9 +39,12 @@ obj-$(CONFIG_CPU_SUP_AMD) += perf_event_amd_iommu.o
39endif 39endif
40obj-$(CONFIG_CPU_SUP_INTEL) += perf_event_p6.o perf_event_knc.o perf_event_p4.o 40obj-$(CONFIG_CPU_SUP_INTEL) += perf_event_p6.o perf_event_knc.o perf_event_p4.o
41obj-$(CONFIG_CPU_SUP_INTEL) += perf_event_intel_lbr.o perf_event_intel_ds.o perf_event_intel.o 41obj-$(CONFIG_CPU_SUP_INTEL) += perf_event_intel_lbr.o perf_event_intel_ds.o perf_event_intel.o
42obj-$(CONFIG_CPU_SUP_INTEL) += perf_event_intel_uncore.o perf_event_intel_uncore_snb.o
43obj-$(CONFIG_CPU_SUP_INTEL) += perf_event_intel_uncore_snbep.o perf_event_intel_uncore_nhmex.o
44obj-$(CONFIG_CPU_SUP_INTEL) += perf_event_intel_rapl.o 42obj-$(CONFIG_CPU_SUP_INTEL) += perf_event_intel_rapl.o
43
44obj-$(CONFIG_PERF_EVENTS_INTEL_UNCORE) += perf_event_intel_uncore.o \
45 perf_event_intel_uncore_snb.o \
46 perf_event_intel_uncore_snbep.o \
47 perf_event_intel_uncore_nhmex.o
45endif 48endif
46 49
47 50
diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
index 1ef456273172..9cc6b6f25f42 100644
--- a/arch/x86/kernel/cpu/intel.c
+++ b/arch/x86/kernel/cpu/intel.c
@@ -213,12 +213,13 @@ static void intel_workarounds(struct cpuinfo_x86 *c)
213{ 213{
214#ifdef CONFIG_X86_F00F_BUG 214#ifdef CONFIG_X86_F00F_BUG
215 /* 215 /*
216 * All current models of Pentium and Pentium with MMX technology CPUs 216 * All models of Pentium and Pentium with MMX technology CPUs
217 * have the F0 0F bug, which lets nonprivileged users lock up the 217 * have the F0 0F bug, which lets nonprivileged users lock up the
218 * system. Announce that the fault handler will be checking for it. 218 * system. Announce that the fault handler will be checking for it.
219 * The Quark is also family 5, but does not have the same bug.
219 */ 220 */
220 clear_cpu_bug(c, X86_BUG_F00F); 221 clear_cpu_bug(c, X86_BUG_F00F);
221 if (!paravirt_enabled() && c->x86 == 5) { 222 if (!paravirt_enabled() && c->x86 == 5 && c->x86_model < 9) {
222 static int f00f_workaround_enabled; 223 static int f00f_workaround_enabled;
223 224
224 set_cpu_bug(c, X86_BUG_F00F); 225 set_cpu_bug(c, X86_BUG_F00F);
diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
index 1b8299dd3d91..143e5f5dc855 100644
--- a/arch/x86/kernel/cpu/perf_event.c
+++ b/arch/x86/kernel/cpu/perf_event.c
@@ -243,8 +243,9 @@ static bool check_hw_exists(void)
243 243
244msr_fail: 244msr_fail:
245 printk(KERN_CONT "Broken PMU hardware detected, using software events only.\n"); 245 printk(KERN_CONT "Broken PMU hardware detected, using software events only.\n");
246 printk(boot_cpu_has(X86_FEATURE_HYPERVISOR) ? KERN_INFO : KERN_ERR 246 printk("%sFailed to access perfctr msr (MSR %x is %Lx)\n",
247 "Failed to access perfctr msr (MSR %x is %Lx)\n", reg, val_new); 247 boot_cpu_has(X86_FEATURE_HYPERVISOR) ? KERN_INFO : KERN_ERR,
248 reg, val_new);
248 249
249 return false; 250 return false;
250} 251}
@@ -444,12 +445,6 @@ int x86_pmu_hw_config(struct perf_event *event)
444 if (event->attr.type == PERF_TYPE_RAW) 445 if (event->attr.type == PERF_TYPE_RAW)
445 event->hw.config |= event->attr.config & X86_RAW_EVENT_MASK; 446 event->hw.config |= event->attr.config & X86_RAW_EVENT_MASK;
446 447
447 if (event->attr.sample_period && x86_pmu.limit_period) {
448 if (x86_pmu.limit_period(event, event->attr.sample_period) >
449 event->attr.sample_period)
450 return -EINVAL;
451 }
452
453 return x86_setup_perfctr(event); 448 return x86_setup_perfctr(event);
454} 449}
455 450
@@ -987,9 +982,6 @@ int x86_perf_event_set_period(struct perf_event *event)
987 if (left > x86_pmu.max_period) 982 if (left > x86_pmu.max_period)
988 left = x86_pmu.max_period; 983 left = x86_pmu.max_period;
989 984
990 if (x86_pmu.limit_period)
991 left = x86_pmu.limit_period(event, left);
992
993 per_cpu(pmc_prev_left[idx], smp_processor_id()) = left; 985 per_cpu(pmc_prev_left[idx], smp_processor_id()) = left;
994 986
995 /* 987 /*
diff --git a/arch/x86/kernel/cpu/perf_event.h b/arch/x86/kernel/cpu/perf_event.h
index d98a34d435d7..fc5eb390b368 100644
--- a/arch/x86/kernel/cpu/perf_event.h
+++ b/arch/x86/kernel/cpu/perf_event.h
@@ -445,7 +445,6 @@ struct x86_pmu {
445 struct x86_pmu_quirk *quirks; 445 struct x86_pmu_quirk *quirks;
446 int perfctr_second_write; 446 int perfctr_second_write;
447 bool late_ack; 447 bool late_ack;
448 unsigned (*limit_period)(struct perf_event *event, unsigned l);
449 448
450 /* 449 /*
451 * sysfs attrs 450 * sysfs attrs
diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
index a73947c53b65..944bf019b74f 100644
--- a/arch/x86/kernel/cpu/perf_event_intel.c
+++ b/arch/x86/kernel/cpu/perf_event_intel.c
@@ -220,15 +220,6 @@ static struct event_constraint intel_hsw_event_constraints[] = {
220 EVENT_CONSTRAINT_END 220 EVENT_CONSTRAINT_END
221}; 221};
222 222
223static struct event_constraint intel_bdw_event_constraints[] = {
224 FIXED_EVENT_CONSTRAINT(0x00c0, 0), /* INST_RETIRED.ANY */
225 FIXED_EVENT_CONSTRAINT(0x003c, 1), /* CPU_CLK_UNHALTED.CORE */
226 FIXED_EVENT_CONSTRAINT(0x0300, 2), /* CPU_CLK_UNHALTED.REF */
227 INTEL_UEVENT_CONSTRAINT(0x148, 0x4), /* L1D_PEND_MISS.PENDING */
228 INTEL_EVENT_CONSTRAINT(0xa3, 0x4), /* CYCLE_ACTIVITY.* */
229 EVENT_CONSTRAINT_END
230};
231
232static u64 intel_pmu_event_map(int hw_event) 223static u64 intel_pmu_event_map(int hw_event)
233{ 224{
234 return intel_perfmon_event_map[hw_event]; 225 return intel_perfmon_event_map[hw_event];
@@ -424,126 +415,6 @@ static __initconst const u64 snb_hw_cache_event_ids
424 415
425}; 416};
426 417
427static __initconst const u64 hsw_hw_cache_event_ids
428 [PERF_COUNT_HW_CACHE_MAX]
429 [PERF_COUNT_HW_CACHE_OP_MAX]
430 [PERF_COUNT_HW_CACHE_RESULT_MAX] =
431{
432 [ C(L1D ) ] = {
433 [ C(OP_READ) ] = {
434 [ C(RESULT_ACCESS) ] = 0x81d0, /* MEM_UOPS_RETIRED.ALL_LOADS */
435 [ C(RESULT_MISS) ] = 0x151, /* L1D.REPLACEMENT */
436 },
437 [ C(OP_WRITE) ] = {
438 [ C(RESULT_ACCESS) ] = 0x82d0, /* MEM_UOPS_RETIRED.ALL_STORES */
439 [ C(RESULT_MISS) ] = 0x0,
440 },
441 [ C(OP_PREFETCH) ] = {
442 [ C(RESULT_ACCESS) ] = 0x0,
443 [ C(RESULT_MISS) ] = 0x0,
444 },
445 },
446 [ C(L1I ) ] = {
447 [ C(OP_READ) ] = {
448 [ C(RESULT_ACCESS) ] = 0x0,
449 [ C(RESULT_MISS) ] = 0x280, /* ICACHE.MISSES */
450 },
451 [ C(OP_WRITE) ] = {
452 [ C(RESULT_ACCESS) ] = -1,
453 [ C(RESULT_MISS) ] = -1,
454 },
455 [ C(OP_PREFETCH) ] = {
456 [ C(RESULT_ACCESS) ] = 0x0,
457 [ C(RESULT_MISS) ] = 0x0,
458 },
459 },
460 [ C(LL ) ] = {
461 [ C(OP_READ) ] = {
462 /* OFFCORE_RESPONSE:ALL_DATA_RD|ALL_CODE_RD */
463 [ C(RESULT_ACCESS) ] = 0x1b7,
464 /* OFFCORE_RESPONSE:ALL_DATA_RD|ALL_CODE_RD|SUPPLIER_NONE|
465 L3_MISS|ANY_SNOOP */
466 [ C(RESULT_MISS) ] = 0x1b7,
467 },
468 [ C(OP_WRITE) ] = {
469 [ C(RESULT_ACCESS) ] = 0x1b7, /* OFFCORE_RESPONSE:ALL_RFO */
470 /* OFFCORE_RESPONSE:ALL_RFO|SUPPLIER_NONE|L3_MISS|ANY_SNOOP */
471 [ C(RESULT_MISS) ] = 0x1b7,
472 },
473 [ C(OP_PREFETCH) ] = {
474 [ C(RESULT_ACCESS) ] = 0x0,
475 [ C(RESULT_MISS) ] = 0x0,
476 },
477 },
478 [ C(DTLB) ] = {
479 [ C(OP_READ) ] = {
480 [ C(RESULT_ACCESS) ] = 0x81d0, /* MEM_UOPS_RETIRED.ALL_LOADS */
481 [ C(RESULT_MISS) ] = 0x108, /* DTLB_LOAD_MISSES.MISS_CAUSES_A_WALK */
482 },
483 [ C(OP_WRITE) ] = {
484 [ C(RESULT_ACCESS) ] = 0x82d0, /* MEM_UOPS_RETIRED.ALL_STORES */
485 [ C(RESULT_MISS) ] = 0x149, /* DTLB_STORE_MISSES.MISS_CAUSES_A_WALK */
486 },
487 [ C(OP_PREFETCH) ] = {
488 [ C(RESULT_ACCESS) ] = 0x0,
489 [ C(RESULT_MISS) ] = 0x0,
490 },
491 },
492 [ C(ITLB) ] = {
493 [ C(OP_READ) ] = {
494 [ C(RESULT_ACCESS) ] = 0x6085, /* ITLB_MISSES.STLB_HIT */
495 [ C(RESULT_MISS) ] = 0x185, /* ITLB_MISSES.MISS_CAUSES_A_WALK */
496 },
497 [ C(OP_WRITE) ] = {
498 [ C(RESULT_ACCESS) ] = -1,
499 [ C(RESULT_MISS) ] = -1,
500 },
501 [ C(OP_PREFETCH) ] = {
502 [ C(RESULT_ACCESS) ] = -1,
503 [ C(RESULT_MISS) ] = -1,
504 },
505 },
506 [ C(BPU ) ] = {
507 [ C(OP_READ) ] = {
508 [ C(RESULT_ACCESS) ] = 0xc4, /* BR_INST_RETIRED.ALL_BRANCHES */
509 [ C(RESULT_MISS) ] = 0xc5, /* BR_MISP_RETIRED.ALL_BRANCHES */
510 },
511 [ C(OP_WRITE) ] = {
512 [ C(RESULT_ACCESS) ] = -1,
513 [ C(RESULT_MISS) ] = -1,
514 },
515 [ C(OP_PREFETCH) ] = {
516 [ C(RESULT_ACCESS) ] = -1,
517 [ C(RESULT_MISS) ] = -1,
518 },
519 },
520};
521
522static __initconst const u64 hsw_hw_cache_extra_regs
523 [PERF_COUNT_HW_CACHE_MAX]
524 [PERF_COUNT_HW_CACHE_OP_MAX]
525 [PERF_COUNT_HW_CACHE_RESULT_MAX] =
526{
527 [ C(LL ) ] = {
528 [ C(OP_READ) ] = {
529 /* OFFCORE_RESPONSE:ALL_DATA_RD|ALL_CODE_RD */
530 [ C(RESULT_ACCESS) ] = 0x2d5,
531 /* OFFCORE_RESPONSE:ALL_DATA_RD|ALL_CODE_RD|SUPPLIER_NONE|
532 L3_MISS|ANY_SNOOP */
533 [ C(RESULT_MISS) ] = 0x3fbc0202d5ull,
534 },
535 [ C(OP_WRITE) ] = {
536 [ C(RESULT_ACCESS) ] = 0x122, /* OFFCORE_RESPONSE:ALL_RFO */
537 /* OFFCORE_RESPONSE:ALL_RFO|SUPPLIER_NONE|L3_MISS|ANY_SNOOP */
538 [ C(RESULT_MISS) ] = 0x3fbc020122ull,
539 },
540 [ C(OP_PREFETCH) ] = {
541 [ C(RESULT_ACCESS) ] = 0x0,
542 [ C(RESULT_MISS) ] = 0x0,
543 },
544 },
545};
546
547static __initconst const u64 westmere_hw_cache_event_ids 418static __initconst const u64 westmere_hw_cache_event_ids
548 [PERF_COUNT_HW_CACHE_MAX] 419 [PERF_COUNT_HW_CACHE_MAX]
549 [PERF_COUNT_HW_CACHE_OP_MAX] 420 [PERF_COUNT_HW_CACHE_OP_MAX]
@@ -2034,24 +1905,6 @@ hsw_get_event_constraints(struct cpu_hw_events *cpuc, struct perf_event *event)
2034 return c; 1905 return c;
2035} 1906}
2036 1907
2037/*
2038 * Broadwell:
2039 * The INST_RETIRED.ALL period always needs to have lowest
2040 * 6bits cleared (BDM57). It shall not use a period smaller
2041 * than 100 (BDM11). We combine the two to enforce
2042 * a min-period of 128.
2043 */
2044static unsigned bdw_limit_period(struct perf_event *event, unsigned left)
2045{
2046 if ((event->hw.config & INTEL_ARCH_EVENT_MASK) ==
2047 X86_CONFIG(.event=0xc0, .umask=0x01)) {
2048 if (left < 128)
2049 left = 128;
2050 left &= ~0x3fu;
2051 }
2052 return left;
2053}
2054
2055PMU_FORMAT_ATTR(event, "config:0-7" ); 1908PMU_FORMAT_ATTR(event, "config:0-7" );
2056PMU_FORMAT_ATTR(umask, "config:8-15" ); 1909PMU_FORMAT_ATTR(umask, "config:8-15" );
2057PMU_FORMAT_ATTR(edge, "config:18" ); 1910PMU_FORMAT_ATTR(edge, "config:18" );
@@ -2692,8 +2545,8 @@ __init int intel_pmu_init(void)
2692 case 69: /* 22nm Haswell ULT */ 2545 case 69: /* 22nm Haswell ULT */
2693 case 70: /* 22nm Haswell + GT3e (Intel Iris Pro graphics) */ 2546 case 70: /* 22nm Haswell + GT3e (Intel Iris Pro graphics) */
2694 x86_pmu.late_ack = true; 2547 x86_pmu.late_ack = true;
2695 memcpy(hw_cache_event_ids, hsw_hw_cache_event_ids, sizeof(hw_cache_event_ids)); 2548 memcpy(hw_cache_event_ids, snb_hw_cache_event_ids, sizeof(hw_cache_event_ids));
2696 memcpy(hw_cache_extra_regs, hsw_hw_cache_extra_regs, sizeof(hw_cache_extra_regs)); 2549 memcpy(hw_cache_extra_regs, snb_hw_cache_extra_regs, sizeof(hw_cache_extra_regs));
2697 2550
2698 intel_pmu_lbr_init_snb(); 2551 intel_pmu_lbr_init_snb();
2699 2552
@@ -2712,28 +2565,6 @@ __init int intel_pmu_init(void)
2712 pr_cont("Haswell events, "); 2565 pr_cont("Haswell events, ");
2713 break; 2566 break;
2714 2567
2715 case 61: /* 14nm Broadwell Core-M */
2716 x86_pmu.late_ack = true;
2717 memcpy(hw_cache_event_ids, hsw_hw_cache_event_ids, sizeof(hw_cache_event_ids));
2718 memcpy(hw_cache_extra_regs, hsw_hw_cache_extra_regs, sizeof(hw_cache_extra_regs));
2719
2720 intel_pmu_lbr_init_snb();
2721
2722 x86_pmu.event_constraints = intel_bdw_event_constraints;
2723 x86_pmu.pebs_constraints = intel_hsw_pebs_event_constraints;
2724 x86_pmu.extra_regs = intel_snbep_extra_regs;
2725 x86_pmu.pebs_aliases = intel_pebs_aliases_snb;
2726 /* all extra regs are per-cpu when HT is on */
2727 x86_pmu.er_flags |= ERF_HAS_RSP_1;
2728 x86_pmu.er_flags |= ERF_NO_HT_SHARING;
2729
2730 x86_pmu.hw_config = hsw_hw_config;
2731 x86_pmu.get_event_constraints = hsw_get_event_constraints;
2732 x86_pmu.cpu_events = hsw_events_attrs;
2733 x86_pmu.limit_period = bdw_limit_period;
2734 pr_cont("Broadwell events, ");
2735 break;
2736
2737 default: 2568 default:
2738 switch (x86_pmu.version) { 2569 switch (x86_pmu.version) {
2739 case 1: 2570 case 1:
diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
index b553ed89e5f5..344b63f18d14 100644
--- a/arch/x86/kernel/entry_32.S
+++ b/arch/x86/kernel/entry_32.S
@@ -447,15 +447,14 @@ sysenter_exit:
447sysenter_audit: 447sysenter_audit:
448 testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%ebp) 448 testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%ebp)
449 jnz syscall_trace_entry 449 jnz syscall_trace_entry
450 addl $4,%esp 450 /* movl PT_EAX(%esp), %eax already set, syscall number: 1st arg to audit */
451 CFI_ADJUST_CFA_OFFSET -4 451 movl PT_EBX(%esp), %edx /* ebx/a0: 2nd arg to audit */
452 movl %esi,4(%esp) /* 5th arg: 4th syscall arg */ 452 /* movl PT_ECX(%esp), %ecx already set, a1: 3nd arg to audit */
453 movl %edx,(%esp) /* 4th arg: 3rd syscall arg */ 453 pushl_cfi PT_ESI(%esp) /* a3: 5th arg */
454 /* %ecx already in %ecx 3rd arg: 2nd syscall arg */ 454 pushl_cfi PT_EDX+4(%esp) /* a2: 4th arg */
455 movl %ebx,%edx /* 2nd arg: 1st syscall arg */
456 /* %eax already in %eax 1st arg: syscall number */
457 call __audit_syscall_entry 455 call __audit_syscall_entry
458 pushl_cfi %ebx 456 popl_cfi %ecx /* get that remapped edx off the stack */
457 popl_cfi %ecx /* get that remapped esi off the stack */
459 movl PT_EAX(%esp),%eax /* reload syscall number */ 458 movl PT_EAX(%esp),%eax /* reload syscall number */
460 jmp sysenter_do_call 459 jmp sysenter_do_call
461 460
diff --git a/arch/x86/kernel/i8259.c b/arch/x86/kernel/i8259.c
index 8af817105e29..e7cc5370cd2f 100644
--- a/arch/x86/kernel/i8259.c
+++ b/arch/x86/kernel/i8259.c
@@ -111,8 +111,7 @@ static void make_8259A_irq(unsigned int irq)
111{ 111{
112 disable_irq_nosync(irq); 112 disable_irq_nosync(irq);
113 io_apic_irqs &= ~(1<<irq); 113 io_apic_irqs &= ~(1<<irq);
114 irq_set_chip_and_handler_name(irq, &i8259A_chip, handle_level_irq, 114 irq_set_chip_and_handler(irq, &i8259A_chip, handle_level_irq);
115 i8259A_chip.name);
116 enable_irq(irq); 115 enable_irq(irq);
117} 116}
118 117
diff --git a/arch/x86/kernel/irqinit.c b/arch/x86/kernel/irqinit.c
index 44f1ed42fdf2..4de73ee78361 100644
--- a/arch/x86/kernel/irqinit.c
+++ b/arch/x86/kernel/irqinit.c
@@ -70,7 +70,6 @@ int vector_used_by_percpu_irq(unsigned int vector)
70void __init init_ISA_irqs(void) 70void __init init_ISA_irqs(void)
71{ 71{
72 struct irq_chip *chip = legacy_pic->chip; 72 struct irq_chip *chip = legacy_pic->chip;
73 const char *name = chip->name;
74 int i; 73 int i;
75 74
76#if defined(CONFIG_X86_64) || defined(CONFIG_X86_LOCAL_APIC) 75#if defined(CONFIG_X86_64) || defined(CONFIG_X86_LOCAL_APIC)
@@ -79,7 +78,7 @@ void __init init_ISA_irqs(void)
79 legacy_pic->init(0); 78 legacy_pic->init(0);
80 79
81 for (i = 0; i < nr_legacy_irqs(); i++) 80 for (i = 0; i < nr_legacy_irqs(); i++)
82 irq_set_chip_and_handler_name(i, chip, handle_level_irq, name); 81 irq_set_chip_and_handler(i, chip, handle_level_irq);
83} 82}
84 83
85void __init init_IRQ(void) 84void __init init_IRQ(void)
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index 235cfd39e0d7..ab08aa2276fb 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -1128,7 +1128,6 @@ void __init setup_arch(char **cmdline_p)
1128 setup_real_mode(); 1128 setup_real_mode();
1129 1129
1130 memblock_set_current_limit(get_max_mapped()); 1130 memblock_set_current_limit(get_max_mapped());
1131 dma_contiguous_reserve(max_pfn_mapped << PAGE_SHIFT);
1132 1131
1133 /* 1132 /*
1134 * NOTE: On x86-32, only from this point on, fixmaps are ready for use. 1133 * NOTE: On x86-32, only from this point on, fixmaps are ready for use.
@@ -1159,6 +1158,7 @@ void __init setup_arch(char **cmdline_p)
1159 early_acpi_boot_init(); 1158 early_acpi_boot_init();
1160 1159
1161 initmem_init(); 1160 initmem_init();
1161 dma_contiguous_reserve(max_pfn_mapped << PAGE_SHIFT);
1162 1162
1163 /* 1163 /*
1164 * Reserve memory for crash kernel after SRAT is parsed so that it 1164 * Reserve memory for crash kernel after SRAT is parsed so that it
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index 2d5200e56357..4d2128ac70bd 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -102,8 +102,6 @@ DEFINE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_llc_shared_map);
102DEFINE_PER_CPU_SHARED_ALIGNED(struct cpuinfo_x86, cpu_info); 102DEFINE_PER_CPU_SHARED_ALIGNED(struct cpuinfo_x86, cpu_info);
103EXPORT_PER_CPU_SYMBOL(cpu_info); 103EXPORT_PER_CPU_SYMBOL(cpu_info);
104 104
105static DEFINE_PER_CPU(struct completion, die_complete);
106
107atomic_t init_deasserted; 105atomic_t init_deasserted;
108 106
109/* 107/*
@@ -1318,6 +1316,8 @@ void cpu_disable_common(void)
1318 fixup_irqs(); 1316 fixup_irqs();
1319} 1317}
1320 1318
1319static DEFINE_PER_CPU(struct completion, die_complete);
1320
1321int native_cpu_disable(void) 1321int native_cpu_disable(void)
1322{ 1322{
1323 int ret; 1323 int ret;
diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
index b6025f9e36c6..b7e50bba3bbb 100644
--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -1166,14 +1166,17 @@ void __init tsc_init(void)
1166 1166
1167 x86_init.timers.tsc_pre_init(); 1167 x86_init.timers.tsc_pre_init();
1168 1168
1169 if (!cpu_has_tsc) 1169 if (!cpu_has_tsc) {
1170 setup_clear_cpu_cap(X86_FEATURE_TSC_DEADLINE_TIMER);
1170 return; 1171 return;
1172 }
1171 1173
1172 tsc_khz = x86_platform.calibrate_tsc(); 1174 tsc_khz = x86_platform.calibrate_tsc();
1173 cpu_khz = tsc_khz; 1175 cpu_khz = tsc_khz;
1174 1176
1175 if (!tsc_khz) { 1177 if (!tsc_khz) {
1176 mark_tsc_unstable("could not calculate TSC khz"); 1178 mark_tsc_unstable("could not calculate TSC khz");
1179 setup_clear_cpu_cap(X86_FEATURE_TSC_DEADLINE_TIMER);
1177 return; 1180 return;
1178 } 1181 }
1179 1182
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 749f9fa38254..5edf088ca51e 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -574,12 +574,14 @@ static inline int assign_eip_far(struct x86_emulate_ctxt *ctxt, ulong dst,
574 case 4: 574 case 4:
575 ctxt->_eip = (u32)dst; 575 ctxt->_eip = (u32)dst;
576 break; 576 break;
577#ifdef CONFIG_X86_64
577 case 8: 578 case 8:
578 if ((cs_l && is_noncanonical_address(dst)) || 579 if ((cs_l && is_noncanonical_address(dst)) ||
579 (!cs_l && (dst & ~(u32)-1))) 580 (!cs_l && (dst >> 32) != 0))
580 return emulate_gp(ctxt, 0); 581 return emulate_gp(ctxt, 0);
581 ctxt->_eip = dst; 582 ctxt->_eip = dst;
582 break; 583 break;
584#endif
583 default: 585 default:
584 WARN(1, "unsupported eip assignment size\n"); 586 WARN(1, "unsupported eip assignment size\n");
585 } 587 }
@@ -641,7 +643,8 @@ static bool insn_aligned(struct x86_emulate_ctxt *ctxt, unsigned size)
641 643
642static int __linearize(struct x86_emulate_ctxt *ctxt, 644static int __linearize(struct x86_emulate_ctxt *ctxt,
643 struct segmented_address addr, 645 struct segmented_address addr,
644 unsigned size, bool write, bool fetch, 646 unsigned *max_size, unsigned size,
647 bool write, bool fetch,
645 ulong *linear) 648 ulong *linear)
646{ 649{
647 struct desc_struct desc; 650 struct desc_struct desc;
@@ -652,10 +655,15 @@ static int __linearize(struct x86_emulate_ctxt *ctxt,
652 unsigned cpl; 655 unsigned cpl;
653 656
654 la = seg_base(ctxt, addr.seg) + addr.ea; 657 la = seg_base(ctxt, addr.seg) + addr.ea;
658 *max_size = 0;
655 switch (ctxt->mode) { 659 switch (ctxt->mode) {
656 case X86EMUL_MODE_PROT64: 660 case X86EMUL_MODE_PROT64:
657 if (((signed long)la << 16) >> 16 != la) 661 if (((signed long)la << 16) >> 16 != la)
658 return emulate_gp(ctxt, 0); 662 return emulate_gp(ctxt, 0);
663
664 *max_size = min_t(u64, ~0u, (1ull << 48) - la);
665 if (size > *max_size)
666 goto bad;
659 break; 667 break;
660 default: 668 default:
661 usable = ctxt->ops->get_segment(ctxt, &sel, &desc, NULL, 669 usable = ctxt->ops->get_segment(ctxt, &sel, &desc, NULL,
@@ -673,20 +681,25 @@ static int __linearize(struct x86_emulate_ctxt *ctxt,
673 if ((ctxt->mode == X86EMUL_MODE_REAL) && !fetch && 681 if ((ctxt->mode == X86EMUL_MODE_REAL) && !fetch &&
674 (ctxt->d & NoBigReal)) { 682 (ctxt->d & NoBigReal)) {
675 /* la is between zero and 0xffff */ 683 /* la is between zero and 0xffff */
676 if (la > 0xffff || (u32)(la + size - 1) > 0xffff) 684 if (la > 0xffff)
677 goto bad; 685 goto bad;
686 *max_size = 0x10000 - la;
678 } else if ((desc.type & 8) || !(desc.type & 4)) { 687 } else if ((desc.type & 8) || !(desc.type & 4)) {
679 /* expand-up segment */ 688 /* expand-up segment */
680 if (addr.ea > lim || (u32)(addr.ea + size - 1) > lim) 689 if (addr.ea > lim)
681 goto bad; 690 goto bad;
691 *max_size = min_t(u64, ~0u, (u64)lim + 1 - addr.ea);
682 } else { 692 } else {
683 /* expand-down segment */ 693 /* expand-down segment */
684 if (addr.ea <= lim || (u32)(addr.ea + size - 1) <= lim) 694 if (addr.ea <= lim)
685 goto bad; 695 goto bad;
686 lim = desc.d ? 0xffffffff : 0xffff; 696 lim = desc.d ? 0xffffffff : 0xffff;
687 if (addr.ea > lim || (u32)(addr.ea + size - 1) > lim) 697 if (addr.ea > lim)
688 goto bad; 698 goto bad;
699 *max_size = min_t(u64, ~0u, (u64)lim + 1 - addr.ea);
689 } 700 }
701 if (size > *max_size)
702 goto bad;
690 cpl = ctxt->ops->cpl(ctxt); 703 cpl = ctxt->ops->cpl(ctxt);
691 if (!(desc.type & 8)) { 704 if (!(desc.type & 8)) {
692 /* data segment */ 705 /* data segment */
@@ -711,9 +724,9 @@ static int __linearize(struct x86_emulate_ctxt *ctxt,
711 return X86EMUL_CONTINUE; 724 return X86EMUL_CONTINUE;
712bad: 725bad:
713 if (addr.seg == VCPU_SREG_SS) 726 if (addr.seg == VCPU_SREG_SS)
714 return emulate_ss(ctxt, sel); 727 return emulate_ss(ctxt, 0);
715 else 728 else
716 return emulate_gp(ctxt, sel); 729 return emulate_gp(ctxt, 0);
717} 730}
718 731
719static int linearize(struct x86_emulate_ctxt *ctxt, 732static int linearize(struct x86_emulate_ctxt *ctxt,
@@ -721,7 +734,8 @@ static int linearize(struct x86_emulate_ctxt *ctxt,
721 unsigned size, bool write, 734 unsigned size, bool write,
722 ulong *linear) 735 ulong *linear)
723{ 736{
724 return __linearize(ctxt, addr, size, write, false, linear); 737 unsigned max_size;
738 return __linearize(ctxt, addr, &max_size, size, write, false, linear);
725} 739}
726 740
727 741
@@ -746,17 +760,27 @@ static int segmented_read_std(struct x86_emulate_ctxt *ctxt,
746static int __do_insn_fetch_bytes(struct x86_emulate_ctxt *ctxt, int op_size) 760static int __do_insn_fetch_bytes(struct x86_emulate_ctxt *ctxt, int op_size)
747{ 761{
748 int rc; 762 int rc;
749 unsigned size; 763 unsigned size, max_size;
750 unsigned long linear; 764 unsigned long linear;
751 int cur_size = ctxt->fetch.end - ctxt->fetch.data; 765 int cur_size = ctxt->fetch.end - ctxt->fetch.data;
752 struct segmented_address addr = { .seg = VCPU_SREG_CS, 766 struct segmented_address addr = { .seg = VCPU_SREG_CS,
753 .ea = ctxt->eip + cur_size }; 767 .ea = ctxt->eip + cur_size };
754 768
755 size = 15UL ^ cur_size; 769 /*
756 rc = __linearize(ctxt, addr, size, false, true, &linear); 770 * We do not know exactly how many bytes will be needed, and
771 * __linearize is expensive, so fetch as much as possible. We
772 * just have to avoid going beyond the 15 byte limit, the end
773 * of the segment, or the end of the page.
774 *
775 * __linearize is called with size 0 so that it does not do any
776 * boundary check itself. Instead, we use max_size to check
777 * against op_size.
778 */
779 rc = __linearize(ctxt, addr, &max_size, 0, false, true, &linear);
757 if (unlikely(rc != X86EMUL_CONTINUE)) 780 if (unlikely(rc != X86EMUL_CONTINUE))
758 return rc; 781 return rc;
759 782
783 size = min_t(unsigned, 15UL ^ cur_size, max_size);
760 size = min_t(unsigned, size, PAGE_SIZE - offset_in_page(linear)); 784 size = min_t(unsigned, size, PAGE_SIZE - offset_in_page(linear));
761 785
762 /* 786 /*
@@ -766,7 +790,8 @@ static int __do_insn_fetch_bytes(struct x86_emulate_ctxt *ctxt, int op_size)
766 * still, we must have hit the 15-byte boundary. 790 * still, we must have hit the 15-byte boundary.
767 */ 791 */
768 if (unlikely(size < op_size)) 792 if (unlikely(size < op_size))
769 return X86EMUL_UNHANDLEABLE; 793 return emulate_gp(ctxt, 0);
794
770 rc = ctxt->ops->fetch(ctxt, linear, ctxt->fetch.end, 795 rc = ctxt->ops->fetch(ctxt, linear, ctxt->fetch.end,
771 size, &ctxt->exception); 796 size, &ctxt->exception);
772 if (unlikely(rc != X86EMUL_CONTINUE)) 797 if (unlikely(rc != X86EMUL_CONTINUE))
@@ -2012,7 +2037,7 @@ static int em_jmp_far(struct x86_emulate_ctxt *ctxt)
2012 2037
2013 rc = assign_eip_far(ctxt, ctxt->src.val, new_desc.l); 2038 rc = assign_eip_far(ctxt, ctxt->src.val, new_desc.l);
2014 if (rc != X86EMUL_CONTINUE) { 2039 if (rc != X86EMUL_CONTINUE) {
2015 WARN_ON(!ctxt->mode != X86EMUL_MODE_PROT64); 2040 WARN_ON(ctxt->mode != X86EMUL_MODE_PROT64);
2016 /* assigning eip failed; restore the old cs */ 2041 /* assigning eip failed; restore the old cs */
2017 ops->set_segment(ctxt, old_sel, &old_desc, 0, VCPU_SREG_CS); 2042 ops->set_segment(ctxt, old_sel, &old_desc, 0, VCPU_SREG_CS);
2018 return rc; 2043 return rc;
@@ -2109,7 +2134,7 @@ static int em_ret_far(struct x86_emulate_ctxt *ctxt)
2109 return rc; 2134 return rc;
2110 rc = assign_eip_far(ctxt, eip, new_desc.l); 2135 rc = assign_eip_far(ctxt, eip, new_desc.l);
2111 if (rc != X86EMUL_CONTINUE) { 2136 if (rc != X86EMUL_CONTINUE) {
2112 WARN_ON(!ctxt->mode != X86EMUL_MODE_PROT64); 2137 WARN_ON(ctxt->mode != X86EMUL_MODE_PROT64);
2113 ops->set_segment(ctxt, old_cs, &old_desc, 0, VCPU_SREG_CS); 2138 ops->set_segment(ctxt, old_cs, &old_desc, 0, VCPU_SREG_CS);
2114 } 2139 }
2115 return rc; 2140 return rc;
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index a8b76c4c95e2..3e556c68351b 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -4579,7 +4579,7 @@ static void vmx_vcpu_reset(struct kvm_vcpu *vcpu)
4579 vmcs_write32(TPR_THRESHOLD, 0); 4579 vmcs_write32(TPR_THRESHOLD, 0);
4580 } 4580 }
4581 4581
4582 kvm_vcpu_reload_apic_access_page(vcpu); 4582 kvm_make_request(KVM_REQ_APIC_PAGE_RELOAD, vcpu);
4583 4583
4584 if (vmx_vm_has_apicv(vcpu->kvm)) 4584 if (vmx_vm_has_apicv(vcpu->kvm))
4585 memset(&vmx->pi_desc, 0, sizeof(struct pi_desc)); 4585 memset(&vmx->pi_desc, 0, sizeof(struct pi_desc));
@@ -6426,6 +6426,8 @@ static void copy_shadow_to_vmcs12(struct vcpu_vmx *vmx)
6426 const unsigned long *fields = shadow_read_write_fields; 6426 const unsigned long *fields = shadow_read_write_fields;
6427 const int num_fields = max_shadow_read_write_fields; 6427 const int num_fields = max_shadow_read_write_fields;
6428 6428
6429 preempt_disable();
6430
6429 vmcs_load(shadow_vmcs); 6431 vmcs_load(shadow_vmcs);
6430 6432
6431 for (i = 0; i < num_fields; i++) { 6433 for (i = 0; i < num_fields; i++) {
@@ -6449,6 +6451,8 @@ static void copy_shadow_to_vmcs12(struct vcpu_vmx *vmx)
6449 6451
6450 vmcs_clear(shadow_vmcs); 6452 vmcs_clear(shadow_vmcs);
6451 vmcs_load(vmx->loaded_vmcs->vmcs); 6453 vmcs_load(vmx->loaded_vmcs->vmcs);
6454
6455 preempt_enable();
6452} 6456}
6453 6457
6454static void copy_vmcs12_to_shadow(struct vcpu_vmx *vmx) 6458static void copy_vmcs12_to_shadow(struct vcpu_vmx *vmx)
diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
index ae242a7c11c7..36de293caf25 100644
--- a/arch/x86/mm/pageattr.c
+++ b/arch/x86/mm/pageattr.c
@@ -409,7 +409,7 @@ phys_addr_t slow_virt_to_phys(void *__virt_addr)
409 psize = page_level_size(level); 409 psize = page_level_size(level);
410 pmask = page_level_mask(level); 410 pmask = page_level_mask(level);
411 offset = virt_addr & ~pmask; 411 offset = virt_addr & ~pmask;
412 phys_addr = pte_pfn(*pte) << PAGE_SHIFT; 412 phys_addr = (phys_addr_t)pte_pfn(*pte) << PAGE_SHIFT;
413 return (phys_addr | offset); 413 return (phys_addr | offset);
414} 414}
415EXPORT_SYMBOL_GPL(slow_virt_to_phys); 415EXPORT_SYMBOL_GPL(slow_virt_to_phys);
diff --git a/arch/x86/platform/intel-mid/sfi.c b/arch/x86/platform/intel-mid/sfi.c
index 3c53a90fdb18..c14ad34776c4 100644
--- a/arch/x86/platform/intel-mid/sfi.c
+++ b/arch/x86/platform/intel-mid/sfi.c
@@ -106,6 +106,7 @@ int __init sfi_parse_mtmr(struct sfi_table_header *table)
106 mp_irq.dstapic = MP_APIC_ALL; 106 mp_irq.dstapic = MP_APIC_ALL;
107 mp_irq.dstirq = pentry->irq; 107 mp_irq.dstirq = pentry->irq;
108 mp_save_irq(&mp_irq); 108 mp_save_irq(&mp_irq);
109 mp_map_gsi_to_irq(pentry->irq, IOAPIC_MAP_ALLOC);
109 } 110 }
110 111
111 return 0; 112 return 0;
@@ -176,6 +177,7 @@ int __init sfi_parse_mrtc(struct sfi_table_header *table)
176 mp_irq.dstapic = MP_APIC_ALL; 177 mp_irq.dstapic = MP_APIC_ALL;
177 mp_irq.dstirq = pentry->irq; 178 mp_irq.dstirq = pentry->irq;
178 mp_save_irq(&mp_irq); 179 mp_save_irq(&mp_irq);
180 mp_map_gsi_to_irq(pentry->irq, IOAPIC_MAP_ALLOC);
179 } 181 }
180 return 0; 182 return 0;
181} 183}
diff --git a/block/blk-merge.c b/block/blk-merge.c
index ba99351c0f58..b3ac40aef46b 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -99,16 +99,17 @@ void blk_recount_segments(struct request_queue *q, struct bio *bio)
99{ 99{
100 bool no_sg_merge = !!test_bit(QUEUE_FLAG_NO_SG_MERGE, 100 bool no_sg_merge = !!test_bit(QUEUE_FLAG_NO_SG_MERGE,
101 &q->queue_flags); 101 &q->queue_flags);
102 bool merge_not_need = bio->bi_vcnt < queue_max_segments(q);
102 103
103 if (no_sg_merge && !bio_flagged(bio, BIO_CLONED) && 104 if (no_sg_merge && !bio_flagged(bio, BIO_CLONED) &&
104 bio->bi_vcnt < queue_max_segments(q)) 105 merge_not_need)
105 bio->bi_phys_segments = bio->bi_vcnt; 106 bio->bi_phys_segments = bio->bi_vcnt;
106 else { 107 else {
107 struct bio *nxt = bio->bi_next; 108 struct bio *nxt = bio->bi_next;
108 109
109 bio->bi_next = NULL; 110 bio->bi_next = NULL;
110 bio->bi_phys_segments = __blk_recalc_rq_segments(q, bio, 111 bio->bi_phys_segments = __blk_recalc_rq_segments(q, bio,
111 no_sg_merge); 112 no_sg_merge && merge_not_need);
112 bio->bi_next = nxt; 113 bio->bi_next = nxt;
113 } 114 }
114 115
diff --git a/block/elevator.c b/block/elevator.c
index 24c28b659bb3..afa3b037a17c 100644
--- a/block/elevator.c
+++ b/block/elevator.c
@@ -229,7 +229,9 @@ int elevator_init(struct request_queue *q, char *name)
229 } 229 }
230 230
231 err = e->ops.elevator_init_fn(q, e); 231 err = e->ops.elevator_init_fn(q, e);
232 return 0; 232 if (err)
233 elevator_put(e);
234 return err;
233} 235}
234EXPORT_SYMBOL(elevator_init); 236EXPORT_SYMBOL(elevator_init);
235 237
diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
index abb2e65b24cc..1e053d911240 100644
--- a/block/scsi_ioctl.c
+++ b/block/scsi_ioctl.c
@@ -508,7 +508,7 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
508 508
509 if (bytes && blk_rq_map_kern(q, rq, buffer, bytes, __GFP_WAIT)) { 509 if (bytes && blk_rq_map_kern(q, rq, buffer, bytes, __GFP_WAIT)) {
510 err = DRIVER_ERROR << 24; 510 err = DRIVER_ERROR << 24;
511 goto out; 511 goto error;
512 } 512 }
513 513
514 memset(sense, 0, sizeof(sense)); 514 memset(sense, 0, sizeof(sense));
@@ -517,7 +517,6 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
517 517
518 blk_execute_rq(q, disk, rq, 0); 518 blk_execute_rq(q, disk, rq, 0);
519 519
520out:
521 err = rq->errors & 0xff; /* only 8 bit SCSI status */ 520 err = rq->errors & 0xff; /* only 8 bit SCSI status */
522 if (err) { 521 if (err) {
523 if (rq->sense_len && rq->sense) { 522 if (rq->sense_len && rq->sense) {
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index 3d304ff7f095..5f9b74b9b71f 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -126,6 +126,7 @@ static int EC_FLAGS_MSI; /* Out-of-spec MSI controller */
126static int EC_FLAGS_VALIDATE_ECDT; /* ASUStec ECDTs need to be validated */ 126static int EC_FLAGS_VALIDATE_ECDT; /* ASUStec ECDTs need to be validated */
127static int EC_FLAGS_SKIP_DSDT_SCAN; /* Not all BIOS survive early DSDT scan */ 127static int EC_FLAGS_SKIP_DSDT_SCAN; /* Not all BIOS survive early DSDT scan */
128static int EC_FLAGS_CLEAR_ON_RESUME; /* Needs acpi_ec_clear() on boot/resume */ 128static int EC_FLAGS_CLEAR_ON_RESUME; /* Needs acpi_ec_clear() on boot/resume */
129static int EC_FLAGS_QUERY_HANDSHAKE; /* Needs QR_EC issued when SCI_EVT set */
129 130
130/* -------------------------------------------------------------------------- 131/* --------------------------------------------------------------------------
131 * Transaction Management 132 * Transaction Management
@@ -236,13 +237,8 @@ static bool advance_transaction(struct acpi_ec *ec)
236 } 237 }
237 return wakeup; 238 return wakeup;
238 } else { 239 } else {
239 /* 240 if (EC_FLAGS_QUERY_HANDSHAKE &&
240 * There is firmware refusing to respond QR_EC when SCI_EVT 241 !(status & ACPI_EC_FLAG_SCI) &&
241 * is not set, for which case, we complete the QR_EC
242 * without issuing it to the firmware.
243 * https://bugzilla.kernel.org/show_bug.cgi?id=86211
244 */
245 if (!(status & ACPI_EC_FLAG_SCI) &&
246 (t->command == ACPI_EC_COMMAND_QUERY)) { 242 (t->command == ACPI_EC_COMMAND_QUERY)) {
247 t->flags |= ACPI_EC_COMMAND_POLL; 243 t->flags |= ACPI_EC_COMMAND_POLL;
248 t->rdata[t->ri++] = 0x00; 244 t->rdata[t->ri++] = 0x00;
@@ -334,13 +330,13 @@ static int acpi_ec_transaction_unlocked(struct acpi_ec *ec,
334 pr_debug("***** Command(%s) started *****\n", 330 pr_debug("***** Command(%s) started *****\n",
335 acpi_ec_cmd_string(t->command)); 331 acpi_ec_cmd_string(t->command));
336 start_transaction(ec); 332 start_transaction(ec);
337 spin_unlock_irqrestore(&ec->lock, tmp);
338 ret = ec_poll(ec);
339 spin_lock_irqsave(&ec->lock, tmp);
340 if (ec->curr->command == ACPI_EC_COMMAND_QUERY) { 333 if (ec->curr->command == ACPI_EC_COMMAND_QUERY) {
341 clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags); 334 clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags);
342 pr_debug("***** Event stopped *****\n"); 335 pr_debug("***** Event stopped *****\n");
343 } 336 }
337 spin_unlock_irqrestore(&ec->lock, tmp);
338 ret = ec_poll(ec);
339 spin_lock_irqsave(&ec->lock, tmp);
344 pr_debug("***** Command(%s) stopped *****\n", 340 pr_debug("***** Command(%s) stopped *****\n",
345 acpi_ec_cmd_string(t->command)); 341 acpi_ec_cmd_string(t->command));
346 ec->curr = NULL; 342 ec->curr = NULL;
@@ -1012,6 +1008,18 @@ static int ec_enlarge_storm_threshold(const struct dmi_system_id *id)
1012} 1008}
1013 1009
1014/* 1010/*
1011 * Acer EC firmware refuses to respond QR_EC when SCI_EVT is not set, for
1012 * which case, we complete the QR_EC without issuing it to the firmware.
1013 * https://bugzilla.kernel.org/show_bug.cgi?id=86211
1014 */
1015static int ec_flag_query_handshake(const struct dmi_system_id *id)
1016{
1017 pr_debug("Detected the EC firmware requiring QR_EC issued when SCI_EVT set\n");
1018 EC_FLAGS_QUERY_HANDSHAKE = 1;
1019 return 0;
1020}
1021
1022/*
1015 * On some hardware it is necessary to clear events accumulated by the EC during 1023 * On some hardware it is necessary to clear events accumulated by the EC during
1016 * sleep. These ECs stop reporting GPEs until they are manually polled, if too 1024 * sleep. These ECs stop reporting GPEs until they are manually polled, if too
1017 * many events are accumulated. (e.g. Samsung Series 5/9 notebooks) 1025 * many events are accumulated. (e.g. Samsung Series 5/9 notebooks)
@@ -1085,6 +1093,9 @@ static struct dmi_system_id ec_dmi_table[] __initdata = {
1085 { 1093 {
1086 ec_clear_on_resume, "Samsung hardware", { 1094 ec_clear_on_resume, "Samsung hardware", {
1087 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD.")}, NULL}, 1095 DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD.")}, NULL},
1096 {
1097 ec_flag_query_handshake, "Acer hardware", {
1098 DMI_MATCH(DMI_SYS_VENDOR, "Acer"), }, NULL},
1088 {}, 1099 {},
1089}; 1100};
1090 1101
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index d670158a26c5..0476e90b2091 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -142,6 +142,53 @@ static int create_modalias(struct acpi_device *acpi_dev, char *modalias,
142} 142}
143 143
144/* 144/*
145 * acpi_companion_match() - Can we match via ACPI companion device
146 * @dev: Device in question
147 *
148 * Check if the given device has an ACPI companion and if that companion has
149 * a valid list of PNP IDs, and if the device is the first (primary) physical
150 * device associated with it.
151 *
152 * If multiple physical devices are attached to a single ACPI companion, we need
153 * to be careful. The usage scenario for this kind of relationship is that all
154 * of the physical devices in question use resources provided by the ACPI
155 * companion. A typical case is an MFD device where all the sub-devices share
156 * the parent's ACPI companion. In such cases we can only allow the primary
157 * (first) physical device to be matched with the help of the companion's PNP
158 * IDs.
159 *
160 * Additional physical devices sharing the ACPI companion can still use
161 * resources available from it but they will be matched normally using functions
162 * provided by their bus types (and analogously for their modalias).
163 */
164static bool acpi_companion_match(const struct device *dev)
165{
166 struct acpi_device *adev;
167 bool ret;
168
169 adev = ACPI_COMPANION(dev);
170 if (!adev)
171 return false;
172
173 if (list_empty(&adev->pnp.ids))
174 return false;
175
176 mutex_lock(&adev->physical_node_lock);
177 if (list_empty(&adev->physical_node_list)) {
178 ret = false;
179 } else {
180 const struct acpi_device_physical_node *node;
181
182 node = list_first_entry(&adev->physical_node_list,
183 struct acpi_device_physical_node, node);
184 ret = node->dev == dev;
185 }
186 mutex_unlock(&adev->physical_node_lock);
187
188 return ret;
189}
190
191/*
145 * Creates uevent modalias field for ACPI enumerated devices. 192 * Creates uevent modalias field for ACPI enumerated devices.
146 * Because the other buses does not support ACPI HIDs & CIDs. 193 * Because the other buses does not support ACPI HIDs & CIDs.
147 * e.g. for a device with hid:IBM0001 and cid:ACPI0001 you get: 194 * e.g. for a device with hid:IBM0001 and cid:ACPI0001 you get:
@@ -149,20 +196,14 @@ static int create_modalias(struct acpi_device *acpi_dev, char *modalias,
149 */ 196 */
150int acpi_device_uevent_modalias(struct device *dev, struct kobj_uevent_env *env) 197int acpi_device_uevent_modalias(struct device *dev, struct kobj_uevent_env *env)
151{ 198{
152 struct acpi_device *acpi_dev;
153 int len; 199 int len;
154 200
155 acpi_dev = ACPI_COMPANION(dev); 201 if (!acpi_companion_match(dev))
156 if (!acpi_dev)
157 return -ENODEV;
158
159 /* Fall back to bus specific way of modalias exporting */
160 if (list_empty(&acpi_dev->pnp.ids))
161 return -ENODEV; 202 return -ENODEV;
162 203
163 if (add_uevent_var(env, "MODALIAS=")) 204 if (add_uevent_var(env, "MODALIAS="))
164 return -ENOMEM; 205 return -ENOMEM;
165 len = create_modalias(acpi_dev, &env->buf[env->buflen - 1], 206 len = create_modalias(ACPI_COMPANION(dev), &env->buf[env->buflen - 1],
166 sizeof(env->buf) - env->buflen); 207 sizeof(env->buf) - env->buflen);
167 if (len <= 0) 208 if (len <= 0)
168 return len; 209 return len;
@@ -179,18 +220,12 @@ EXPORT_SYMBOL_GPL(acpi_device_uevent_modalias);
179 */ 220 */
180int acpi_device_modalias(struct device *dev, char *buf, int size) 221int acpi_device_modalias(struct device *dev, char *buf, int size)
181{ 222{
182 struct acpi_device *acpi_dev;
183 int len; 223 int len;
184 224
185 acpi_dev = ACPI_COMPANION(dev); 225 if (!acpi_companion_match(dev))
186 if (!acpi_dev)
187 return -ENODEV; 226 return -ENODEV;
188 227
189 /* Fall back to bus specific way of modalias exporting */ 228 len = create_modalias(ACPI_COMPANION(dev), buf, size -1);
190 if (list_empty(&acpi_dev->pnp.ids))
191 return -ENODEV;
192
193 len = create_modalias(acpi_dev, buf, size -1);
194 if (len <= 0) 229 if (len <= 0)
195 return len; 230 return len;
196 buf[len++] = '\n'; 231 buf[len++] = '\n';
@@ -853,6 +888,9 @@ const struct acpi_device_id *acpi_match_device(const struct acpi_device_id *ids,
853 if (!ids || !handle || acpi_bus_get_device(handle, &adev)) 888 if (!ids || !handle || acpi_bus_get_device(handle, &adev))
854 return NULL; 889 return NULL;
855 890
891 if (!acpi_companion_match(dev))
892 return NULL;
893
856 return __acpi_match_device(adev, ids); 894 return __acpi_match_device(adev, ids);
857} 895}
858EXPORT_SYMBOL_GPL(acpi_match_device); 896EXPORT_SYMBOL_GPL(acpi_match_device);
diff --git a/drivers/base/dma-contiguous.c b/drivers/base/dma-contiguous.c
index 473ff4892401..950fff9ce453 100644
--- a/drivers/base/dma-contiguous.c
+++ b/drivers/base/dma-contiguous.c
@@ -223,9 +223,10 @@ bool dma_release_from_contiguous(struct device *dev, struct page *pages,
223#undef pr_fmt 223#undef pr_fmt
224#define pr_fmt(fmt) fmt 224#define pr_fmt(fmt) fmt
225 225
226static void rmem_cma_device_init(struct reserved_mem *rmem, struct device *dev) 226static int rmem_cma_device_init(struct reserved_mem *rmem, struct device *dev)
227{ 227{
228 dev_set_cma_area(dev, rmem->priv); 228 dev_set_cma_area(dev, rmem->priv);
229 return 0;
229} 230}
230 231
231static void rmem_cma_device_release(struct reserved_mem *rmem, 232static void rmem_cma_device_release(struct reserved_mem *rmem,
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index 44973196d3fd..9717d5f20139 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -1266,6 +1266,8 @@ int dpm_suspend_late(pm_message_t state)
1266 } 1266 }
1267 mutex_unlock(&dpm_list_mtx); 1267 mutex_unlock(&dpm_list_mtx);
1268 async_synchronize_full(); 1268 async_synchronize_full();
1269 if (!error)
1270 error = async_error;
1269 if (error) { 1271 if (error) {
1270 suspend_stats.failed_suspend_late++; 1272 suspend_stats.failed_suspend_late++;
1271 dpm_save_failed_step(SUSPEND_SUSPEND_LATE); 1273 dpm_save_failed_step(SUSPEND_SUSPEND_LATE);
diff --git a/drivers/bcma/host_pci.c b/drivers/bcma/host_pci.c
index 1e5ac0a79696..cd9161a8b3a1 100644
--- a/drivers/bcma/host_pci.c
+++ b/drivers/bcma/host_pci.c
@@ -275,7 +275,7 @@ static SIMPLE_DEV_PM_OPS(bcma_pm_ops, bcma_host_pci_suspend,
275static const struct pci_device_id bcma_pci_bridge_tbl[] = { 275static const struct pci_device_id bcma_pci_bridge_tbl[] = {
276 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x0576) }, 276 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x0576) },
277 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4313) }, 277 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4313) },
278 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 43224) }, 278 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 43224) }, /* 0xa8d8 */
279 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4331) }, 279 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4331) },
280 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4353) }, 280 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4353) },
281 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4357) }, 281 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4357) },
@@ -285,7 +285,8 @@ static const struct pci_device_id bcma_pci_bridge_tbl[] = {
285 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x43a9) }, 285 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x43a9) },
286 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x43aa) }, 286 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x43aa) },
287 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4727) }, 287 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4727) },
288 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 43227) }, /* 0xA8DB */ 288 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 43227) }, /* 0xa8db, BCM43217 (sic!) */
289 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 43228) }, /* 0xa8dc */
289 { 0, }, 290 { 0, },
290}; 291};
291MODULE_DEVICE_TABLE(pci, bcma_pci_bridge_tbl); 292MODULE_DEVICE_TABLE(pci, bcma_pci_bridge_tbl);
diff --git a/drivers/bcma/main.c b/drivers/bcma/main.c
index d1656c2f70af..1000955ce09d 100644
--- a/drivers/bcma/main.c
+++ b/drivers/bcma/main.c
@@ -132,7 +132,7 @@ static bool bcma_is_core_needed_early(u16 core_id)
132 return false; 132 return false;
133} 133}
134 134
135#ifdef CONFIG_OF 135#if defined(CONFIG_OF) && defined(CONFIG_OF_ADDRESS)
136static struct device_node *bcma_of_find_child_device(struct platform_device *parent, 136static struct device_node *bcma_of_find_child_device(struct platform_device *parent,
137 struct bcma_device *core) 137 struct bcma_device *core)
138{ 138{
diff --git a/drivers/block/null_blk.c b/drivers/block/null_blk.c
index 2671a3f02f0c..8001e812018b 100644
--- a/drivers/block/null_blk.c
+++ b/drivers/block/null_blk.c
@@ -450,14 +450,10 @@ static int init_driver_queues(struct nullb *nullb)
450 450
451 ret = setup_commands(nq); 451 ret = setup_commands(nq);
452 if (ret) 452 if (ret)
453 goto err_queue; 453 return ret;
454 nullb->nr_queues++; 454 nullb->nr_queues++;
455 } 455 }
456
457 return 0; 456 return 0;
458err_queue:
459 cleanup_queues(nullb);
460 return ret;
461} 457}
462 458
463static int null_add_dev(void) 459static int null_add_dev(void)
@@ -507,7 +503,9 @@ static int null_add_dev(void)
507 goto out_cleanup_queues; 503 goto out_cleanup_queues;
508 } 504 }
509 blk_queue_make_request(nullb->q, null_queue_bio); 505 blk_queue_make_request(nullb->q, null_queue_bio);
510 init_driver_queues(nullb); 506 rv = init_driver_queues(nullb);
507 if (rv)
508 goto out_cleanup_blk_queue;
511 } else { 509 } else {
512 nullb->q = blk_init_queue_node(null_request_fn, &nullb->lock, home_node); 510 nullb->q = blk_init_queue_node(null_request_fn, &nullb->lock, home_node);
513 if (!nullb->q) { 511 if (!nullb->q) {
@@ -516,7 +514,9 @@ static int null_add_dev(void)
516 } 514 }
517 blk_queue_prep_rq(nullb->q, null_rq_prep_fn); 515 blk_queue_prep_rq(nullb->q, null_rq_prep_fn);
518 blk_queue_softirq_done(nullb->q, null_softirq_done_fn); 516 blk_queue_softirq_done(nullb->q, null_softirq_done_fn);
519 init_driver_queues(nullb); 517 rv = init_driver_queues(nullb);
518 if (rv)
519 goto out_cleanup_blk_queue;
520 } 520 }
521 521
522 nullb->q->queuedata = nullb; 522 nullb->q->queuedata = nullb;
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 0a54c588e433..27b71a0b72d0 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -342,7 +342,6 @@ struct rbd_device {
342 342
343 struct list_head rq_queue; /* incoming rq queue */ 343 struct list_head rq_queue; /* incoming rq queue */
344 spinlock_t lock; /* queue, flags, open_count */ 344 spinlock_t lock; /* queue, flags, open_count */
345 struct workqueue_struct *rq_wq;
346 struct work_struct rq_work; 345 struct work_struct rq_work;
347 346
348 struct rbd_image_header header; 347 struct rbd_image_header header;
@@ -402,6 +401,8 @@ static struct kmem_cache *rbd_segment_name_cache;
402static int rbd_major; 401static int rbd_major;
403static DEFINE_IDA(rbd_dev_id_ida); 402static DEFINE_IDA(rbd_dev_id_ida);
404 403
404static struct workqueue_struct *rbd_wq;
405
405/* 406/*
406 * Default to false for now, as single-major requires >= 0.75 version of 407 * Default to false for now, as single-major requires >= 0.75 version of
407 * userspace rbd utility. 408 * userspace rbd utility.
@@ -3452,7 +3453,7 @@ static void rbd_request_fn(struct request_queue *q)
3452 } 3453 }
3453 3454
3454 if (queued) 3455 if (queued)
3455 queue_work(rbd_dev->rq_wq, &rbd_dev->rq_work); 3456 queue_work(rbd_wq, &rbd_dev->rq_work);
3456} 3457}
3457 3458
3458/* 3459/*
@@ -3532,7 +3533,7 @@ static int rbd_obj_read_sync(struct rbd_device *rbd_dev,
3532 page_count = (u32) calc_pages_for(offset, length); 3533 page_count = (u32) calc_pages_for(offset, length);
3533 pages = ceph_alloc_page_vector(page_count, GFP_KERNEL); 3534 pages = ceph_alloc_page_vector(page_count, GFP_KERNEL);
3534 if (IS_ERR(pages)) 3535 if (IS_ERR(pages))
3535 ret = PTR_ERR(pages); 3536 return PTR_ERR(pages);
3536 3537
3537 ret = -ENOMEM; 3538 ret = -ENOMEM;
3538 obj_request = rbd_obj_request_create(object_name, offset, length, 3539 obj_request = rbd_obj_request_create(object_name, offset, length,
@@ -5242,16 +5243,9 @@ static int rbd_dev_device_setup(struct rbd_device *rbd_dev)
5242 set_capacity(rbd_dev->disk, rbd_dev->mapping.size / SECTOR_SIZE); 5243 set_capacity(rbd_dev->disk, rbd_dev->mapping.size / SECTOR_SIZE);
5243 set_disk_ro(rbd_dev->disk, rbd_dev->mapping.read_only); 5244 set_disk_ro(rbd_dev->disk, rbd_dev->mapping.read_only);
5244 5245
5245 rbd_dev->rq_wq = alloc_workqueue("%s", WQ_MEM_RECLAIM, 0,
5246 rbd_dev->disk->disk_name);
5247 if (!rbd_dev->rq_wq) {
5248 ret = -ENOMEM;
5249 goto err_out_mapping;
5250 }
5251
5252 ret = rbd_bus_add_dev(rbd_dev); 5246 ret = rbd_bus_add_dev(rbd_dev);
5253 if (ret) 5247 if (ret)
5254 goto err_out_workqueue; 5248 goto err_out_mapping;
5255 5249
5256 /* Everything's ready. Announce the disk to the world. */ 5250 /* Everything's ready. Announce the disk to the world. */
5257 5251
@@ -5263,9 +5257,6 @@ static int rbd_dev_device_setup(struct rbd_device *rbd_dev)
5263 5257
5264 return ret; 5258 return ret;
5265 5259
5266err_out_workqueue:
5267 destroy_workqueue(rbd_dev->rq_wq);
5268 rbd_dev->rq_wq = NULL;
5269err_out_mapping: 5260err_out_mapping:
5270 rbd_dev_mapping_clear(rbd_dev); 5261 rbd_dev_mapping_clear(rbd_dev);
5271err_out_disk: 5262err_out_disk:
@@ -5512,7 +5503,6 @@ static void rbd_dev_device_release(struct device *dev)
5512{ 5503{
5513 struct rbd_device *rbd_dev = dev_to_rbd_dev(dev); 5504 struct rbd_device *rbd_dev = dev_to_rbd_dev(dev);
5514 5505
5515 destroy_workqueue(rbd_dev->rq_wq);
5516 rbd_free_disk(rbd_dev); 5506 rbd_free_disk(rbd_dev);
5517 clear_bit(RBD_DEV_FLAG_EXISTS, &rbd_dev->flags); 5507 clear_bit(RBD_DEV_FLAG_EXISTS, &rbd_dev->flags);
5518 rbd_dev_mapping_clear(rbd_dev); 5508 rbd_dev_mapping_clear(rbd_dev);
@@ -5716,11 +5706,21 @@ static int __init rbd_init(void)
5716 if (rc) 5706 if (rc)
5717 return rc; 5707 return rc;
5718 5708
5709 /*
5710 * The number of active work items is limited by the number of
5711 * rbd devices, so leave @max_active at default.
5712 */
5713 rbd_wq = alloc_workqueue(RBD_DRV_NAME, WQ_MEM_RECLAIM, 0);
5714 if (!rbd_wq) {
5715 rc = -ENOMEM;
5716 goto err_out_slab;
5717 }
5718
5719 if (single_major) { 5719 if (single_major) {
5720 rbd_major = register_blkdev(0, RBD_DRV_NAME); 5720 rbd_major = register_blkdev(0, RBD_DRV_NAME);
5721 if (rbd_major < 0) { 5721 if (rbd_major < 0) {
5722 rc = rbd_major; 5722 rc = rbd_major;
5723 goto err_out_slab; 5723 goto err_out_wq;
5724 } 5724 }
5725 } 5725 }
5726 5726
@@ -5738,6 +5738,8 @@ static int __init rbd_init(void)
5738err_out_blkdev: 5738err_out_blkdev:
5739 if (single_major) 5739 if (single_major)
5740 unregister_blkdev(rbd_major, RBD_DRV_NAME); 5740 unregister_blkdev(rbd_major, RBD_DRV_NAME);
5741err_out_wq:
5742 destroy_workqueue(rbd_wq);
5741err_out_slab: 5743err_out_slab:
5742 rbd_slab_exit(); 5744 rbd_slab_exit();
5743 return rc; 5745 return rc;
@@ -5749,6 +5751,7 @@ static void __exit rbd_exit(void)
5749 rbd_sysfs_cleanup(); 5751 rbd_sysfs_cleanup();
5750 if (single_major) 5752 if (single_major)
5751 unregister_blkdev(rbd_major, RBD_DRV_NAME); 5753 unregister_blkdev(rbd_major, RBD_DRV_NAME);
5754 destroy_workqueue(rbd_wq);
5752 rbd_slab_exit(); 5755 rbd_slab_exit();
5753} 5756}
5754 5757
diff --git a/drivers/block/sunvdc.c b/drivers/block/sunvdc.c
index 756b8ec00f16..0ebadf93b6c5 100644
--- a/drivers/block/sunvdc.c
+++ b/drivers/block/sunvdc.c
@@ -69,8 +69,6 @@ struct vdc_port {
69 u8 vdisk_mtype; 69 u8 vdisk_mtype;
70 70
71 char disk_name[32]; 71 char disk_name[32];
72
73 struct vio_disk_vtoc label;
74}; 72};
75 73
76static inline struct vdc_port *to_vdc_port(struct vio_driver_state *vio) 74static inline struct vdc_port *to_vdc_port(struct vio_driver_state *vio)
@@ -710,13 +708,6 @@ static int probe_disk(struct vdc_port *port)
710 if (comp.err) 708 if (comp.err)
711 return comp.err; 709 return comp.err;
712 710
713 err = generic_request(port, VD_OP_GET_VTOC,
714 &port->label, sizeof(port->label));
715 if (err < 0) {
716 printk(KERN_ERR PFX "VD_OP_GET_VTOC returns error %d\n", err);
717 return err;
718 }
719
720 if (vdc_version_supported(port, 1, 1)) { 711 if (vdc_version_supported(port, 1, 1)) {
721 /* vdisk_size should be set during the handshake, if it wasn't 712 /* vdisk_size should be set during the handshake, if it wasn't
722 * then the underlying disk is reserved by another system 713 * then the underlying disk is reserved by another system
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index 0e63e8aa8279..2ad0b5bce44b 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -99,11 +99,12 @@ static ssize_t mem_used_total_show(struct device *dev,
99{ 99{
100 u64 val = 0; 100 u64 val = 0;
101 struct zram *zram = dev_to_zram(dev); 101 struct zram *zram = dev_to_zram(dev);
102 struct zram_meta *meta = zram->meta;
103 102
104 down_read(&zram->init_lock); 103 down_read(&zram->init_lock);
105 if (init_done(zram)) 104 if (init_done(zram)) {
105 struct zram_meta *meta = zram->meta;
106 val = zs_get_total_pages(meta->mem_pool); 106 val = zs_get_total_pages(meta->mem_pool);
107 }
107 up_read(&zram->init_lock); 108 up_read(&zram->init_lock);
108 109
109 return scnprintf(buf, PAGE_SIZE, "%llu\n", val << PAGE_SHIFT); 110 return scnprintf(buf, PAGE_SIZE, "%llu\n", val << PAGE_SHIFT);
@@ -173,16 +174,17 @@ static ssize_t mem_used_max_store(struct device *dev,
173 int err; 174 int err;
174 unsigned long val; 175 unsigned long val;
175 struct zram *zram = dev_to_zram(dev); 176 struct zram *zram = dev_to_zram(dev);
176 struct zram_meta *meta = zram->meta;
177 177
178 err = kstrtoul(buf, 10, &val); 178 err = kstrtoul(buf, 10, &val);
179 if (err || val != 0) 179 if (err || val != 0)
180 return -EINVAL; 180 return -EINVAL;
181 181
182 down_read(&zram->init_lock); 182 down_read(&zram->init_lock);
183 if (init_done(zram)) 183 if (init_done(zram)) {
184 struct zram_meta *meta = zram->meta;
184 atomic_long_set(&zram->stats.max_used_pages, 185 atomic_long_set(&zram->stats.max_used_pages,
185 zs_get_total_pages(meta->mem_pool)); 186 zs_get_total_pages(meta->mem_pool));
187 }
186 up_read(&zram->init_lock); 188 up_read(&zram->init_lock);
187 189
188 return len; 190 return len;
diff --git a/drivers/char/raw.c b/drivers/char/raw.c
index 0102dc788608..a24891b97547 100644
--- a/drivers/char/raw.c
+++ b/drivers/char/raw.c
@@ -285,7 +285,7 @@ static long raw_ctl_compat_ioctl(struct file *file, unsigned int cmd,
285 285
286static const struct file_operations raw_fops = { 286static const struct file_operations raw_fops = {
287 .read = new_sync_read, 287 .read = new_sync_read,
288 .read_iter = generic_file_read_iter, 288 .read_iter = blkdev_read_iter,
289 .write = new_sync_write, 289 .write = new_sync_write,
290 .write_iter = blkdev_write_iter, 290 .write_iter = blkdev_write_iter,
291 .fsync = blkdev_fsync, 291 .fsync = blkdev_fsync,
diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
index 2133f9d59d06..43005d4d3348 100644
--- a/drivers/clocksource/arm_arch_timer.c
+++ b/drivers/clocksource/arm_arch_timer.c
@@ -660,11 +660,11 @@ static bool __init
660arch_timer_probed(int type, const struct of_device_id *matches) 660arch_timer_probed(int type, const struct of_device_id *matches)
661{ 661{
662 struct device_node *dn; 662 struct device_node *dn;
663 bool probed = false; 663 bool probed = true;
664 664
665 dn = of_find_matching_node(NULL, matches); 665 dn = of_find_matching_node(NULL, matches);
666 if (dn && of_device_is_available(dn) && (arch_timers_present & type)) 666 if (dn && of_device_is_available(dn) && !(arch_timers_present & type))
667 probed = true; 667 probed = false;
668 of_node_put(dn); 668 of_node_put(dn);
669 669
670 return probed; 670 return probed;
diff --git a/drivers/cpufreq/cpufreq-dt.c b/drivers/cpufreq/cpufreq-dt.c
index 92c162af5045..23aaf40cf37f 100644
--- a/drivers/cpufreq/cpufreq-dt.c
+++ b/drivers/cpufreq/cpufreq-dt.c
@@ -187,6 +187,7 @@ static int cpufreq_init(struct cpufreq_policy *policy)
187 struct device *cpu_dev; 187 struct device *cpu_dev;
188 struct regulator *cpu_reg; 188 struct regulator *cpu_reg;
189 struct clk *cpu_clk; 189 struct clk *cpu_clk;
190 unsigned long min_uV = ~0, max_uV = 0;
190 unsigned int transition_latency; 191 unsigned int transition_latency;
191 int ret; 192 int ret;
192 193
@@ -206,16 +207,10 @@ static int cpufreq_init(struct cpufreq_policy *policy)
206 /* OPPs might be populated at runtime, don't check for error here */ 207 /* OPPs might be populated at runtime, don't check for error here */
207 of_init_opp_table(cpu_dev); 208 of_init_opp_table(cpu_dev);
208 209
209 ret = dev_pm_opp_init_cpufreq_table(cpu_dev, &freq_table);
210 if (ret) {
211 dev_err(cpu_dev, "failed to init cpufreq table: %d\n", ret);
212 goto out_put_node;
213 }
214
215 priv = kzalloc(sizeof(*priv), GFP_KERNEL); 210 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
216 if (!priv) { 211 if (!priv) {
217 ret = -ENOMEM; 212 ret = -ENOMEM;
218 goto out_free_table; 213 goto out_put_node;
219 } 214 }
220 215
221 of_property_read_u32(np, "voltage-tolerance", &priv->voltage_tolerance); 216 of_property_read_u32(np, "voltage-tolerance", &priv->voltage_tolerance);
@@ -224,30 +219,51 @@ static int cpufreq_init(struct cpufreq_policy *policy)
224 transition_latency = CPUFREQ_ETERNAL; 219 transition_latency = CPUFREQ_ETERNAL;
225 220
226 if (!IS_ERR(cpu_reg)) { 221 if (!IS_ERR(cpu_reg)) {
227 struct dev_pm_opp *opp; 222 unsigned long opp_freq = 0;
228 unsigned long min_uV, max_uV;
229 int i;
230 223
231 /* 224 /*
232 * OPP is maintained in order of increasing frequency, and 225 * Disable any OPPs where the connected regulator isn't able to
233 * freq_table initialised from OPP is therefore sorted in the 226 * provide the specified voltage and record minimum and maximum
234 * same order. 227 * voltage levels.
235 */ 228 */
236 for (i = 0; freq_table[i].frequency != CPUFREQ_TABLE_END; i++) 229 while (1) {
237 ; 230 struct dev_pm_opp *opp;
238 rcu_read_lock(); 231 unsigned long opp_uV, tol_uV;
239 opp = dev_pm_opp_find_freq_exact(cpu_dev, 232
240 freq_table[0].frequency * 1000, true); 233 rcu_read_lock();
241 min_uV = dev_pm_opp_get_voltage(opp); 234 opp = dev_pm_opp_find_freq_ceil(cpu_dev, &opp_freq);
242 opp = dev_pm_opp_find_freq_exact(cpu_dev, 235 if (IS_ERR(opp)) {
243 freq_table[i-1].frequency * 1000, true); 236 rcu_read_unlock();
244 max_uV = dev_pm_opp_get_voltage(opp); 237 break;
245 rcu_read_unlock(); 238 }
239 opp_uV = dev_pm_opp_get_voltage(opp);
240 rcu_read_unlock();
241
242 tol_uV = opp_uV * priv->voltage_tolerance / 100;
243 if (regulator_is_supported_voltage(cpu_reg, opp_uV,
244 opp_uV + tol_uV)) {
245 if (opp_uV < min_uV)
246 min_uV = opp_uV;
247 if (opp_uV > max_uV)
248 max_uV = opp_uV;
249 } else {
250 dev_pm_opp_disable(cpu_dev, opp_freq);
251 }
252
253 opp_freq++;
254 }
255
246 ret = regulator_set_voltage_time(cpu_reg, min_uV, max_uV); 256 ret = regulator_set_voltage_time(cpu_reg, min_uV, max_uV);
247 if (ret > 0) 257 if (ret > 0)
248 transition_latency += ret * 1000; 258 transition_latency += ret * 1000;
249 } 259 }
250 260
261 ret = dev_pm_opp_init_cpufreq_table(cpu_dev, &freq_table);
262 if (ret) {
263 pr_err("failed to init cpufreq table: %d\n", ret);
264 goto out_free_priv;
265 }
266
251 /* 267 /*
252 * For now, just loading the cooling device; 268 * For now, just loading the cooling device;
253 * thermal DT code takes care of matching them. 269 * thermal DT code takes care of matching them.
@@ -277,7 +293,7 @@ static int cpufreq_init(struct cpufreq_policy *policy)
277 policy->cpuinfo.transition_latency = transition_latency; 293 policy->cpuinfo.transition_latency = transition_latency;
278 294
279 pd = cpufreq_get_driver_data(); 295 pd = cpufreq_get_driver_data();
280 if (pd && !pd->independent_clocks) 296 if (!pd || !pd->independent_clocks)
281 cpumask_setall(policy->cpus); 297 cpumask_setall(policy->cpus);
282 298
283 of_node_put(np); 299 of_node_put(np);
@@ -286,9 +302,9 @@ static int cpufreq_init(struct cpufreq_policy *policy)
286 302
287out_cooling_unregister: 303out_cooling_unregister:
288 cpufreq_cooling_unregister(priv->cdev); 304 cpufreq_cooling_unregister(priv->cdev);
289 kfree(priv);
290out_free_table:
291 dev_pm_opp_free_cpufreq_table(cpu_dev, &freq_table); 305 dev_pm_opp_free_cpufreq_table(cpu_dev, &freq_table);
306out_free_priv:
307 kfree(priv);
292out_put_node: 308out_put_node:
293 of_node_put(np); 309 of_node_put(np);
294out_put_reg_clk: 310out_put_reg_clk:
diff --git a/drivers/edac/cpc925_edac.c b/drivers/edac/cpc925_edac.c
index df6575f1430d..682288ced4ac 100644
--- a/drivers/edac/cpc925_edac.c
+++ b/drivers/edac/cpc925_edac.c
@@ -562,7 +562,7 @@ static void cpc925_mc_check(struct mem_ctl_info *mci)
562 562
563 if (apiexcp & UECC_EXCP_DETECTED) { 563 if (apiexcp & UECC_EXCP_DETECTED) {
564 cpc925_mc_printk(mci, KERN_INFO, "DRAM UECC Fault\n"); 564 cpc925_mc_printk(mci, KERN_INFO, "DRAM UECC Fault\n");
565 edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 1, 565 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 1,
566 pfn, offset, 0, 566 pfn, offset, 0,
567 csrow, -1, -1, 567 csrow, -1, -1,
568 mci->ctl_name, ""); 568 mci->ctl_name, "");
diff --git a/drivers/edac/e7xxx_edac.c b/drivers/edac/e7xxx_edac.c
index 3cda79bc8b00..ece3aef16bb1 100644
--- a/drivers/edac/e7xxx_edac.c
+++ b/drivers/edac/e7xxx_edac.c
@@ -226,7 +226,7 @@ static void process_ce(struct mem_ctl_info *mci, struct e7xxx_error_info *info)
226static void process_ce_no_info(struct mem_ctl_info *mci) 226static void process_ce_no_info(struct mem_ctl_info *mci)
227{ 227{
228 edac_dbg(3, "\n"); 228 edac_dbg(3, "\n");
229 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 1, 0, 0, 0, -1, -1, -1, 229 edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 1, 0, 0, 0, -1, -1, -1,
230 "e7xxx CE log register overflow", ""); 230 "e7xxx CE log register overflow", "");
231} 231}
232 232
diff --git a/drivers/edac/i3200_edac.c b/drivers/edac/i3200_edac.c
index 022a70273ada..aa98b136f5d0 100644
--- a/drivers/edac/i3200_edac.c
+++ b/drivers/edac/i3200_edac.c
@@ -242,11 +242,11 @@ static void i3200_process_error_info(struct mem_ctl_info *mci,
242 -1, -1, 242 -1, -1,
243 "i3000 UE", ""); 243 "i3000 UE", "");
244 } else if (log & I3200_ECCERRLOG_CE) { 244 } else if (log & I3200_ECCERRLOG_CE) {
245 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 1, 245 edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 1,
246 0, 0, eccerrlog_syndrome(log), 246 0, 0, eccerrlog_syndrome(log),
247 eccerrlog_row(channel, log), 247 eccerrlog_row(channel, log),
248 -1, -1, 248 -1, -1,
249 "i3000 UE", ""); 249 "i3000 CE", "");
250 } 250 }
251 } 251 }
252} 252}
diff --git a/drivers/edac/i82860_edac.c b/drivers/edac/i82860_edac.c
index 3382f6344e42..4382343a7c60 100644
--- a/drivers/edac/i82860_edac.c
+++ b/drivers/edac/i82860_edac.c
@@ -124,7 +124,7 @@ static int i82860_process_error_info(struct mem_ctl_info *mci,
124 dimm->location[0], dimm->location[1], -1, 124 dimm->location[0], dimm->location[1], -1,
125 "i82860 UE", ""); 125 "i82860 UE", "");
126 else 126 else
127 edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 1, 127 edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 1,
128 info->eap, 0, info->derrsyn, 128 info->eap, 0, info->derrsyn,
129 dimm->location[0], dimm->location[1], -1, 129 dimm->location[0], dimm->location[1], -1,
130 "i82860 CE", ""); 130 "i82860 CE", "");
diff --git a/drivers/gpu/drm/armada/armada_crtc.c b/drivers/gpu/drm/armada/armada_crtc.c
index 9a0cc09e6653..e4a1490b42c2 100644
--- a/drivers/gpu/drm/armada/armada_crtc.c
+++ b/drivers/gpu/drm/armada/armada_crtc.c
@@ -260,7 +260,7 @@ static void armada_drm_vblank_off(struct armada_crtc *dcrtc)
260 * Tell the DRM core that vblank IRQs aren't going to happen for 260 * Tell the DRM core that vblank IRQs aren't going to happen for
261 * a while. This cleans up any pending vblank events for us. 261 * a while. This cleans up any pending vblank events for us.
262 */ 262 */
263 drm_vblank_off(dev, dcrtc->num); 263 drm_crtc_vblank_off(&dcrtc->crtc);
264 264
265 /* Handle any pending flip event. */ 265 /* Handle any pending flip event. */
266 spin_lock_irq(&dev->event_lock); 266 spin_lock_irq(&dev->event_lock);
@@ -289,6 +289,8 @@ static void armada_drm_crtc_dpms(struct drm_crtc *crtc, int dpms)
289 armada_drm_crtc_update(dcrtc); 289 armada_drm_crtc_update(dcrtc);
290 if (dpms_blanked(dpms)) 290 if (dpms_blanked(dpms))
291 armada_drm_vblank_off(dcrtc); 291 armada_drm_vblank_off(dcrtc);
292 else
293 drm_crtc_vblank_on(&dcrtc->crtc);
292 } 294 }
293} 295}
294 296
@@ -526,7 +528,7 @@ static int armada_drm_crtc_mode_set(struct drm_crtc *crtc,
526 /* Wait for pending flips to complete */ 528 /* Wait for pending flips to complete */
527 wait_event(dcrtc->frame_wait, !dcrtc->frame_work); 529 wait_event(dcrtc->frame_wait, !dcrtc->frame_work);
528 530
529 drm_vblank_pre_modeset(crtc->dev, dcrtc->num); 531 drm_crtc_vblank_off(crtc);
530 532
531 crtc->mode = *adj; 533 crtc->mode = *adj;
532 534
@@ -617,7 +619,7 @@ static int armada_drm_crtc_mode_set(struct drm_crtc *crtc,
617 619
618 armada_drm_crtc_update(dcrtc); 620 armada_drm_crtc_update(dcrtc);
619 621
620 drm_vblank_post_modeset(crtc->dev, dcrtc->num); 622 drm_crtc_vblank_on(crtc);
621 armada_drm_crtc_finish_fb(dcrtc, old_fb, dpms_blanked(dcrtc->dpms)); 623 armada_drm_crtc_finish_fb(dcrtc, old_fb, dpms_blanked(dcrtc->dpms));
622 624
623 return 0; 625 return 0;
@@ -945,18 +947,15 @@ static int armada_drm_crtc_page_flip(struct drm_crtc *crtc,
945 armada_reg_queue_end(work->regs, i); 947 armada_reg_queue_end(work->regs, i);
946 948
947 /* 949 /*
948 * Hold the old framebuffer for the work - DRM appears to drop our 950 * Ensure that we hold a reference on the new framebuffer.
949 * reference to the old framebuffer in drm_mode_page_flip_ioctl(). 951 * This has to match the behaviour in mode_set.
950 */ 952 */
951 drm_framebuffer_reference(work->old_fb); 953 drm_framebuffer_reference(fb);
952 954
953 ret = armada_drm_crtc_queue_frame_work(dcrtc, work); 955 ret = armada_drm_crtc_queue_frame_work(dcrtc, work);
954 if (ret) { 956 if (ret) {
955 /* 957 /* Undo our reference above */
956 * Undo our reference above; DRM does not drop the reference 958 drm_framebuffer_unreference(fb);
957 * to this object on error, so that's okay.
958 */
959 drm_framebuffer_unreference(work->old_fb);
960 kfree(work); 959 kfree(work);
961 return ret; 960 return ret;
962 } 961 }
diff --git a/drivers/gpu/drm/armada/armada_drv.c b/drivers/gpu/drm/armada/armada_drv.c
index f672e6ad8afa..908e5316eac4 100644
--- a/drivers/gpu/drm/armada/armada_drv.c
+++ b/drivers/gpu/drm/armada/armada_drv.c
@@ -190,6 +190,7 @@ static int armada_drm_load(struct drm_device *dev, unsigned long flags)
190 if (ret) 190 if (ret)
191 goto err_comp; 191 goto err_comp;
192 192
193 dev->irq_enabled = true;
193 dev->vblank_disable_allowed = 1; 194 dev->vblank_disable_allowed = 1;
194 195
195 ret = armada_fbdev_init(dev); 196 ret = armada_fbdev_init(dev);
@@ -331,7 +332,7 @@ static struct drm_driver armada_drm_driver = {
331 .desc = "Armada SoC DRM", 332 .desc = "Armada SoC DRM",
332 .date = "20120730", 333 .date = "20120730",
333 .driver_features = DRIVER_GEM | DRIVER_MODESET | 334 .driver_features = DRIVER_GEM | DRIVER_MODESET |
334 DRIVER_PRIME, 335 DRIVER_HAVE_IRQ | DRIVER_PRIME,
335 .ioctls = armada_ioctls, 336 .ioctls = armada_ioctls,
336 .fops = &armada_drm_fops, 337 .fops = &armada_drm_fops,
337}; 338};
diff --git a/drivers/gpu/drm/exynos/exynos_dp_core.c b/drivers/gpu/drm/exynos/exynos_dp_core.c
index cd50ece31601..6adb1e5cfb08 100644
--- a/drivers/gpu/drm/exynos/exynos_dp_core.c
+++ b/drivers/gpu/drm/exynos/exynos_dp_core.c
@@ -1355,13 +1355,8 @@ static void exynos_dp_unbind(struct device *dev, struct device *master,
1355 void *data) 1355 void *data)
1356{ 1356{
1357 struct exynos_drm_display *display = dev_get_drvdata(dev); 1357 struct exynos_drm_display *display = dev_get_drvdata(dev);
1358 struct exynos_dp_device *dp = display->ctx;
1359 struct drm_encoder *encoder = dp->encoder;
1360 1358
1361 exynos_dp_dpms(display, DRM_MODE_DPMS_OFF); 1359 exynos_dp_dpms(display, DRM_MODE_DPMS_OFF);
1362
1363 exynos_dp_connector_destroy(&dp->connector);
1364 encoder->funcs->destroy(encoder);
1365} 1360}
1366 1361
1367static const struct component_ops exynos_dp_ops = { 1362static const struct component_ops exynos_dp_ops = {
diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.c b/drivers/gpu/drm/exynos/exynos_drm_crtc.c
index 8e38e9f8e542..45026e693225 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_crtc.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.c
@@ -71,13 +71,16 @@ static void exynos_drm_crtc_dpms(struct drm_crtc *crtc, int mode)
71 !atomic_read(&exynos_crtc->pending_flip), 71 !atomic_read(&exynos_crtc->pending_flip),
72 HZ/20)) 72 HZ/20))
73 atomic_set(&exynos_crtc->pending_flip, 0); 73 atomic_set(&exynos_crtc->pending_flip, 0);
74 drm_vblank_off(crtc->dev, exynos_crtc->pipe); 74 drm_crtc_vblank_off(crtc);
75 } 75 }
76 76
77 if (manager->ops->dpms) 77 if (manager->ops->dpms)
78 manager->ops->dpms(manager, mode); 78 manager->ops->dpms(manager, mode);
79 79
80 exynos_crtc->dpms = mode; 80 exynos_crtc->dpms = mode;
81
82 if (mode == DRM_MODE_DPMS_ON)
83 drm_crtc_vblank_on(crtc);
81} 84}
82 85
83static void exynos_drm_crtc_prepare(struct drm_crtc *crtc) 86static void exynos_drm_crtc_prepare(struct drm_crtc *crtc)
diff --git a/drivers/gpu/drm/exynos/exynos_drm_dpi.c b/drivers/gpu/drm/exynos/exynos_drm_dpi.c
index 96c87db388fb..3dc678ed9949 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_dpi.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_dpi.c
@@ -338,14 +338,10 @@ err_del_component:
338 338
339int exynos_dpi_remove(struct device *dev) 339int exynos_dpi_remove(struct device *dev)
340{ 340{
341 struct drm_encoder *encoder = exynos_dpi_display.encoder;
342 struct exynos_dpi *ctx = exynos_dpi_display.ctx; 341 struct exynos_dpi *ctx = exynos_dpi_display.ctx;
343 342
344 exynos_dpi_dpms(&exynos_dpi_display, DRM_MODE_DPMS_OFF); 343 exynos_dpi_dpms(&exynos_dpi_display, DRM_MODE_DPMS_OFF);
345 344
346 exynos_dpi_connector_destroy(&ctx->connector);
347 encoder->funcs->destroy(encoder);
348
349 if (ctx->panel) 345 if (ctx->panel)
350 drm_panel_detach(ctx->panel); 346 drm_panel_detach(ctx->panel);
351 347
diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c b/drivers/gpu/drm/exynos/exynos_drm_drv.c
index 443a2069858a..c57466edf45b 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
@@ -87,16 +87,12 @@ static int exynos_drm_load(struct drm_device *dev, unsigned long flags)
87 87
88 plane = exynos_plane_init(dev, possible_crtcs, 88 plane = exynos_plane_init(dev, possible_crtcs,
89 DRM_PLANE_TYPE_OVERLAY); 89 DRM_PLANE_TYPE_OVERLAY);
90 if (IS_ERR(plane)) 90 if (!IS_ERR(plane))
91 goto err_mode_config_cleanup; 91 continue;
92 }
93
94 /* init kms poll for handling hpd */
95 drm_kms_helper_poll_init(dev);
96 92
97 ret = drm_vblank_init(dev, MAX_CRTC); 93 ret = PTR_ERR(plane);
98 if (ret)
99 goto err_mode_config_cleanup; 94 goto err_mode_config_cleanup;
95 }
100 96
101 /* setup possible_clones. */ 97 /* setup possible_clones. */
102 exynos_drm_encoder_setup(dev); 98 exynos_drm_encoder_setup(dev);
@@ -106,15 +102,16 @@ static int exynos_drm_load(struct drm_device *dev, unsigned long flags)
106 /* Try to bind all sub drivers. */ 102 /* Try to bind all sub drivers. */
107 ret = component_bind_all(dev->dev, dev); 103 ret = component_bind_all(dev->dev, dev);
108 if (ret) 104 if (ret)
109 goto err_cleanup_vblank; 105 goto err_mode_config_cleanup;
110 106
111 /* Probe non kms sub drivers and virtual display driver. */ 107 ret = drm_vblank_init(dev, dev->mode_config.num_crtc);
112 ret = exynos_drm_device_subdrv_probe(dev);
113 if (ret) 108 if (ret)
114 goto err_unbind_all; 109 goto err_unbind_all;
115 110
116 /* force connectors detection */ 111 /* Probe non kms sub drivers and virtual display driver. */
117 drm_helper_hpd_irq_event(dev); 112 ret = exynos_drm_device_subdrv_probe(dev);
113 if (ret)
114 goto err_cleanup_vblank;
118 115
119 /* 116 /*
120 * enable drm irq mode. 117 * enable drm irq mode.
@@ -133,12 +130,18 @@ static int exynos_drm_load(struct drm_device *dev, unsigned long flags)
133 */ 130 */
134 dev->vblank_disable_allowed = true; 131 dev->vblank_disable_allowed = true;
135 132
133 /* init kms poll for handling hpd */
134 drm_kms_helper_poll_init(dev);
135
136 /* force connectors detection */
137 drm_helper_hpd_irq_event(dev);
138
136 return 0; 139 return 0;
137 140
138err_unbind_all:
139 component_unbind_all(dev->dev, dev);
140err_cleanup_vblank: 141err_cleanup_vblank:
141 drm_vblank_cleanup(dev); 142 drm_vblank_cleanup(dev);
143err_unbind_all:
144 component_unbind_all(dev->dev, dev);
142err_mode_config_cleanup: 145err_mode_config_cleanup:
143 drm_mode_config_cleanup(dev); 146 drm_mode_config_cleanup(dev);
144 drm_release_iommu_mapping(dev); 147 drm_release_iommu_mapping(dev);
@@ -155,8 +158,8 @@ static int exynos_drm_unload(struct drm_device *dev)
155 exynos_drm_fbdev_fini(dev); 158 exynos_drm_fbdev_fini(dev);
156 drm_kms_helper_poll_fini(dev); 159 drm_kms_helper_poll_fini(dev);
157 160
158 component_unbind_all(dev->dev, dev);
159 drm_vblank_cleanup(dev); 161 drm_vblank_cleanup(dev);
162 component_unbind_all(dev->dev, dev);
160 drm_mode_config_cleanup(dev); 163 drm_mode_config_cleanup(dev);
161 drm_release_iommu_mapping(dev); 164 drm_release_iommu_mapping(dev);
162 165
@@ -191,8 +194,12 @@ static int exynos_drm_resume(struct drm_device *dev)
191 194
192 drm_modeset_lock_all(dev); 195 drm_modeset_lock_all(dev);
193 list_for_each_entry(connector, &dev->mode_config.connector_list, head) { 196 list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
194 if (connector->funcs->dpms) 197 if (connector->funcs->dpms) {
195 connector->funcs->dpms(connector, connector->dpms); 198 int dpms = connector->dpms;
199
200 connector->dpms = DRM_MODE_DPMS_OFF;
201 connector->funcs->dpms(connector, dpms);
202 }
196 } 203 }
197 drm_modeset_unlock_all(dev); 204 drm_modeset_unlock_all(dev);
198 205
diff --git a/drivers/gpu/drm/exynos/exynos_drm_dsi.c b/drivers/gpu/drm/exynos/exynos_drm_dsi.c
index 24741d8758e8..acf7e9e39dcd 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_dsi.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_dsi.c
@@ -1660,13 +1660,9 @@ static void exynos_dsi_unbind(struct device *dev, struct device *master,
1660 void *data) 1660 void *data)
1661{ 1661{
1662 struct exynos_dsi *dsi = exynos_dsi_display.ctx; 1662 struct exynos_dsi *dsi = exynos_dsi_display.ctx;
1663 struct drm_encoder *encoder = dsi->encoder;
1664 1663
1665 exynos_dsi_dpms(&exynos_dsi_display, DRM_MODE_DPMS_OFF); 1664 exynos_dsi_dpms(&exynos_dsi_display, DRM_MODE_DPMS_OFF);
1666 1665
1667 exynos_dsi_connector_destroy(&dsi->connector);
1668 encoder->funcs->destroy(encoder);
1669
1670 mipi_dsi_host_unregister(&dsi->dsi_host); 1666 mipi_dsi_host_unregister(&dsi->dsi_host);
1671} 1667}
1672 1668
diff --git a/drivers/gpu/drm/exynos/exynos_drm_vidi.c b/drivers/gpu/drm/exynos/exynos_drm_vidi.c
index d565207040a2..50faf913e574 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_vidi.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_vidi.c
@@ -630,7 +630,6 @@ static int vidi_remove(struct platform_device *pdev)
630{ 630{
631 struct exynos_drm_manager *mgr = platform_get_drvdata(pdev); 631 struct exynos_drm_manager *mgr = platform_get_drvdata(pdev);
632 struct vidi_context *ctx = mgr->ctx; 632 struct vidi_context *ctx = mgr->ctx;
633 struct drm_encoder *encoder = ctx->encoder;
634 633
635 if (ctx->raw_edid != (struct edid *)fake_edid_info) { 634 if (ctx->raw_edid != (struct edid *)fake_edid_info) {
636 kfree(ctx->raw_edid); 635 kfree(ctx->raw_edid);
@@ -639,9 +638,6 @@ static int vidi_remove(struct platform_device *pdev)
639 return -EINVAL; 638 return -EINVAL;
640 } 639 }
641 640
642 encoder->funcs->destroy(encoder);
643 drm_connector_cleanup(&ctx->connector);
644
645 return 0; 641 return 0;
646} 642}
647 643
diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c b/drivers/gpu/drm/exynos/exynos_hdmi.c
index 7910fb37d9bb..563a19e62eb2 100644
--- a/drivers/gpu/drm/exynos/exynos_hdmi.c
+++ b/drivers/gpu/drm/exynos/exynos_hdmi.c
@@ -2312,12 +2312,6 @@ static int hdmi_bind(struct device *dev, struct device *master, void *data)
2312 2312
2313static void hdmi_unbind(struct device *dev, struct device *master, void *data) 2313static void hdmi_unbind(struct device *dev, struct device *master, void *data)
2314{ 2314{
2315 struct exynos_drm_display *display = get_hdmi_display(dev);
2316 struct drm_encoder *encoder = display->encoder;
2317 struct hdmi_context *hdata = display->ctx;
2318
2319 hdmi_connector_destroy(&hdata->connector);
2320 encoder->funcs->destroy(encoder);
2321} 2315}
2322 2316
2323static const struct component_ops hdmi_component_ops = { 2317static const struct component_ops hdmi_component_ops = {
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index c9e220963a78..f0a1a56406eb 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -4585,7 +4585,7 @@ static void vlv_update_cdclk(struct drm_device *dev)
4585 * BSpec erroneously claims we should aim for 4MHz, but 4585 * BSpec erroneously claims we should aim for 4MHz, but
4586 * in fact 1MHz is the correct frequency. 4586 * in fact 1MHz is the correct frequency.
4587 */ 4587 */
4588 I915_WRITE(GMBUSFREQ_VLV, dev_priv->vlv_cdclk_freq); 4588 I915_WRITE(GMBUSFREQ_VLV, DIV_ROUND_UP(dev_priv->vlv_cdclk_freq, 1000));
4589} 4589}
4590 4590
4591/* Adjust CDclk dividers to allow high res or save power if possible */ 4591/* Adjust CDclk dividers to allow high res or save power if possible */
@@ -12885,6 +12885,9 @@ static struct intel_quirk intel_quirks[] = {
12885 /* Acer C720 Chromebook (Core i3 4005U) */ 12885 /* Acer C720 Chromebook (Core i3 4005U) */
12886 { 0x0a16, 0x1025, 0x0a11, quirk_backlight_present }, 12886 { 0x0a16, 0x1025, 0x0a11, quirk_backlight_present },
12887 12887
12888 /* Apple Macbook 2,1 (Core 2 T7400) */
12889 { 0x27a2, 0x8086, 0x7270, quirk_backlight_present },
12890
12888 /* Toshiba CB35 Chromebook (Celeron 2955U) */ 12891 /* Toshiba CB35 Chromebook (Celeron 2955U) */
12889 { 0x0a06, 0x1179, 0x0a88, quirk_backlight_present }, 12892 { 0x0a06, 0x1179, 0x0a88, quirk_backlight_present },
12890 12893
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index f6a3fdd5589e..5ad45bfff3fe 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -2806,6 +2806,13 @@ intel_dp_dpcd_read_wake(struct drm_dp_aux *aux, unsigned int offset,
2806 ssize_t ret; 2806 ssize_t ret;
2807 int i; 2807 int i;
2808 2808
2809 /*
2810 * Sometime we just get the same incorrect byte repeated
2811 * over the entire buffer. Doing just one throw away read
2812 * initially seems to "solve" it.
2813 */
2814 drm_dp_dpcd_read(aux, DP_DPCD_REV, buffer, 1);
2815
2809 for (i = 0; i < 3; i++) { 2816 for (i = 0; i < 3; i++) {
2810 ret = drm_dp_dpcd_read(aux, offset, buffer, size); 2817 ret = drm_dp_dpcd_read(aux, offset, buffer, size);
2811 if (ret == size) 2818 if (ret == size)
@@ -3724,9 +3731,10 @@ intel_dp_get_dpcd(struct intel_dp *intel_dp)
3724 } 3731 }
3725 } 3732 }
3726 3733
3727 /* Training Pattern 3 support */ 3734 /* Training Pattern 3 support, both source and sink */
3728 if (intel_dp->dpcd[DP_DPCD_REV] >= 0x12 && 3735 if (intel_dp->dpcd[DP_DPCD_REV] >= 0x12 &&
3729 intel_dp->dpcd[DP_MAX_LANE_COUNT] & DP_TPS3_SUPPORTED) { 3736 intel_dp->dpcd[DP_MAX_LANE_COUNT] & DP_TPS3_SUPPORTED &&
3737 (IS_HASWELL(dev_priv) || INTEL_INFO(dev_priv)->gen >= 8)) {
3730 intel_dp->use_tps3 = true; 3738 intel_dp->use_tps3 = true;
3731 DRM_DEBUG_KMS("Displayport TPS3 supported\n"); 3739 DRM_DEBUG_KMS("Displayport TPS3 supported\n");
3732 } else 3740 } else
@@ -4491,6 +4499,18 @@ intel_dp_hpd_pulse(struct intel_digital_port *intel_dig_port, bool long_hpd)
4491 if (intel_dig_port->base.type != INTEL_OUTPUT_EDP) 4499 if (intel_dig_port->base.type != INTEL_OUTPUT_EDP)
4492 intel_dig_port->base.type = INTEL_OUTPUT_DISPLAYPORT; 4500 intel_dig_port->base.type = INTEL_OUTPUT_DISPLAYPORT;
4493 4501
4502 if (long_hpd && intel_dig_port->base.type == INTEL_OUTPUT_EDP) {
4503 /*
4504 * vdd off can generate a long pulse on eDP which
4505 * would require vdd on to handle it, and thus we
4506 * would end up in an endless cycle of
4507 * "vdd off -> long hpd -> vdd on -> detect -> vdd off -> ..."
4508 */
4509 DRM_DEBUG_KMS("ignoring long hpd on eDP port %c\n",
4510 port_name(intel_dig_port->port));
4511 return false;
4512 }
4513
4494 DRM_DEBUG_KMS("got hpd irq on port %c - %s\n", 4514 DRM_DEBUG_KMS("got hpd irq on port %c - %s\n",
4495 port_name(intel_dig_port->port), 4515 port_name(intel_dig_port->port),
4496 long_hpd ? "long" : "short"); 4516 long_hpd ? "long" : "short");
diff --git a/drivers/gpu/drm/radeon/evergreen.c b/drivers/gpu/drm/radeon/evergreen.c
index a31f1ca40c6a..f37d39d2bbbc 100644
--- a/drivers/gpu/drm/radeon/evergreen.c
+++ b/drivers/gpu/drm/radeon/evergreen.c
@@ -3005,7 +3005,7 @@ static void evergreen_gpu_init(struct radeon_device *rdev)
3005 u32 vgt_cache_invalidation; 3005 u32 vgt_cache_invalidation;
3006 u32 hdp_host_path_cntl, tmp; 3006 u32 hdp_host_path_cntl, tmp;
3007 u32 disabled_rb_mask; 3007 u32 disabled_rb_mask;
3008 int i, j, num_shader_engines, ps_thread_count; 3008 int i, j, ps_thread_count;
3009 3009
3010 switch (rdev->family) { 3010 switch (rdev->family) {
3011 case CHIP_CYPRESS: 3011 case CHIP_CYPRESS:
@@ -3303,8 +3303,6 @@ static void evergreen_gpu_init(struct radeon_device *rdev)
3303 rdev->config.evergreen.tile_config |= 3303 rdev->config.evergreen.tile_config |=
3304 ((gb_addr_config & 0x30000000) >> 28) << 12; 3304 ((gb_addr_config & 0x30000000) >> 28) << 12;
3305 3305
3306 num_shader_engines = (gb_addr_config & NUM_SHADER_ENGINES(3) >> 12) + 1;
3307
3308 if ((rdev->family >= CHIP_CEDAR) && (rdev->family <= CHIP_HEMLOCK)) { 3306 if ((rdev->family >= CHIP_CEDAR) && (rdev->family <= CHIP_HEMLOCK)) {
3309 u32 efuse_straps_4; 3307 u32 efuse_straps_4;
3310 u32 efuse_straps_3; 3308 u32 efuse_straps_3;
diff --git a/drivers/gpu/drm/radeon/kv_dpm.c b/drivers/gpu/drm/radeon/kv_dpm.c
index 1dd976f447fa..9b42001295ba 100644
--- a/drivers/gpu/drm/radeon/kv_dpm.c
+++ b/drivers/gpu/drm/radeon/kv_dpm.c
@@ -2725,7 +2725,11 @@ int kv_dpm_init(struct radeon_device *rdev)
2725 2725
2726 pi->sram_end = SMC_RAM_END; 2726 pi->sram_end = SMC_RAM_END;
2727 2727
2728 pi->enable_nb_dpm = true; 2728 /* Enabling nb dpm on an asrock system prevents dpm from working */
2729 if (rdev->pdev->subsystem_vendor == 0x1849)
2730 pi->enable_nb_dpm = false;
2731 else
2732 pi->enable_nb_dpm = true;
2729 2733
2730 pi->caps_power_containment = true; 2734 pi->caps_power_containment = true;
2731 pi->caps_cac = true; 2735 pi->caps_cac = true;
@@ -2740,10 +2744,19 @@ int kv_dpm_init(struct radeon_device *rdev)
2740 pi->caps_sclk_ds = true; 2744 pi->caps_sclk_ds = true;
2741 pi->enable_auto_thermal_throttling = true; 2745 pi->enable_auto_thermal_throttling = true;
2742 pi->disable_nb_ps3_in_battery = false; 2746 pi->disable_nb_ps3_in_battery = false;
2743 if (radeon_bapm == 0) 2747 if (radeon_bapm == -1) {
2748 /* There are stability issues reported on with
2749 * bapm enabled on an asrock system.
2750 */
2751 if (rdev->pdev->subsystem_vendor == 0x1849)
2752 pi->bapm_enable = false;
2753 else
2754 pi->bapm_enable = true;
2755 } else if (radeon_bapm == 0) {
2744 pi->bapm_enable = false; 2756 pi->bapm_enable = false;
2745 else 2757 } else {
2746 pi->bapm_enable = true; 2758 pi->bapm_enable = true;
2759 }
2747 pi->voltage_drop_t = 0; 2760 pi->voltage_drop_t = 0;
2748 pi->caps_sclk_throttle_low_notification = false; 2761 pi->caps_sclk_throttle_low_notification = false;
2749 pi->caps_fps = false; /* true? */ 2762 pi->caps_fps = false; /* true? */
diff --git a/drivers/gpu/drm/radeon/radeon_bios.c b/drivers/gpu/drm/radeon/radeon_bios.c
index 6a03624fadaa..63ccb8fa799c 100644
--- a/drivers/gpu/drm/radeon/radeon_bios.c
+++ b/drivers/gpu/drm/radeon/radeon_bios.c
@@ -658,12 +658,10 @@ bool radeon_get_bios(struct radeon_device *rdev)
658 r = igp_read_bios_from_vram(rdev); 658 r = igp_read_bios_from_vram(rdev);
659 if (r == false) 659 if (r == false)
660 r = radeon_read_bios(rdev); 660 r = radeon_read_bios(rdev);
661 if (r == false) { 661 if (r == false)
662 r = radeon_read_disabled_bios(rdev); 662 r = radeon_read_disabled_bios(rdev);
663 } 663 if (r == false)
664 if (r == false) {
665 r = radeon_read_platform_bios(rdev); 664 r = radeon_read_platform_bios(rdev);
666 }
667 if (r == false || rdev->bios == NULL) { 665 if (r == false || rdev->bios == NULL) {
668 DRM_ERROR("Unable to locate a BIOS ROM\n"); 666 DRM_ERROR("Unable to locate a BIOS ROM\n");
669 rdev->bios = NULL; 667 rdev->bios = NULL;
diff --git a/drivers/gpu/drm/radeon/radeon_cs.c b/drivers/gpu/drm/radeon/radeon_cs.c
index 1c893447d7cd..a3e7aed7e680 100644
--- a/drivers/gpu/drm/radeon/radeon_cs.c
+++ b/drivers/gpu/drm/radeon/radeon_cs.c
@@ -450,7 +450,7 @@ static void radeon_cs_parser_fini(struct radeon_cs_parser *parser, int error, bo
450 kfree(parser->track); 450 kfree(parser->track);
451 kfree(parser->relocs); 451 kfree(parser->relocs);
452 kfree(parser->relocs_ptr); 452 kfree(parser->relocs_ptr);
453 kfree(parser->vm_bos); 453 drm_free_large(parser->vm_bos);
454 for (i = 0; i < parser->nchunks; i++) 454 for (i = 0; i < parser->nchunks; i++)
455 drm_free_large(parser->chunks[i].kdata); 455 drm_free_large(parser->chunks[i].kdata);
456 kfree(parser->chunks); 456 kfree(parser->chunks);
diff --git a/drivers/gpu/drm/radeon/radeon_ring.c b/drivers/gpu/drm/radeon/radeon_ring.c
index 3d17af34afa7..2456f69efd23 100644
--- a/drivers/gpu/drm/radeon/radeon_ring.c
+++ b/drivers/gpu/drm/radeon/radeon_ring.c
@@ -314,7 +314,7 @@ unsigned radeon_ring_backup(struct radeon_device *rdev, struct radeon_ring *ring
314 } 314 }
315 315
316 /* and then save the content of the ring */ 316 /* and then save the content of the ring */
317 *data = kmalloc_array(size, sizeof(uint32_t), GFP_KERNEL); 317 *data = drm_malloc_ab(size, sizeof(uint32_t));
318 if (!*data) { 318 if (!*data) {
319 mutex_unlock(&rdev->ring_lock); 319 mutex_unlock(&rdev->ring_lock);
320 return 0; 320 return 0;
@@ -356,7 +356,7 @@ int radeon_ring_restore(struct radeon_device *rdev, struct radeon_ring *ring,
356 } 356 }
357 357
358 radeon_ring_unlock_commit(rdev, ring, false); 358 radeon_ring_unlock_commit(rdev, ring, false);
359 kfree(data); 359 drm_free_large(data);
360 return 0; 360 return 0;
361} 361}
362 362
diff --git a/drivers/gpu/drm/radeon/radeon_vm.c b/drivers/gpu/drm/radeon/radeon_vm.c
index 4532cc76a0a6..dfde266529e2 100644
--- a/drivers/gpu/drm/radeon/radeon_vm.c
+++ b/drivers/gpu/drm/radeon/radeon_vm.c
@@ -132,8 +132,8 @@ struct radeon_cs_reloc *radeon_vm_get_bos(struct radeon_device *rdev,
132 struct radeon_cs_reloc *list; 132 struct radeon_cs_reloc *list;
133 unsigned i, idx; 133 unsigned i, idx;
134 134
135 list = kmalloc_array(vm->max_pde_used + 2, 135 list = drm_malloc_ab(vm->max_pde_used + 2,
136 sizeof(struct radeon_cs_reloc), GFP_KERNEL); 136 sizeof(struct radeon_cs_reloc));
137 if (!list) 137 if (!list)
138 return NULL; 138 return NULL;
139 139
diff --git a/drivers/gpu/drm/radeon/si_dpm.c b/drivers/gpu/drm/radeon/si_dpm.c
index a53c2e79d9cb..676e6c2ba90a 100644
--- a/drivers/gpu/drm/radeon/si_dpm.c
+++ b/drivers/gpu/drm/radeon/si_dpm.c
@@ -6256,7 +6256,7 @@ static void si_parse_pplib_clock_info(struct radeon_device *rdev,
6256 if ((rps->class2 & ATOM_PPLIB_CLASSIFICATION2_ULV) && 6256 if ((rps->class2 & ATOM_PPLIB_CLASSIFICATION2_ULV) &&
6257 index == 0) { 6257 index == 0) {
6258 /* XXX disable for A0 tahiti */ 6258 /* XXX disable for A0 tahiti */
6259 si_pi->ulv.supported = true; 6259 si_pi->ulv.supported = false;
6260 si_pi->ulv.pl = *pl; 6260 si_pi->ulv.pl = *pl;
6261 si_pi->ulv.one_pcie_lane_in_ulv = false; 6261 si_pi->ulv.one_pcie_lane_in_ulv = false;
6262 si_pi->ulv.volt_change_delay = SISLANDS_ULVVOLTAGECHANGEDELAY_DFLT; 6262 si_pi->ulv.volt_change_delay = SISLANDS_ULVVOLTAGECHANGEDELAY_DFLT;
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c b/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c
index bfeb4b1f2acf..21e9b7f8dad0 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c
@@ -246,7 +246,8 @@ int vmw_cmdbuf_res_remove(struct vmw_cmdbuf_res_manager *man,
246 struct drm_hash_item *hash; 246 struct drm_hash_item *hash;
247 int ret; 247 int ret;
248 248
249 ret = drm_ht_find_item(&man->resources, user_key, &hash); 249 ret = drm_ht_find_item(&man->resources, user_key | (res_type << 24),
250 &hash);
250 if (likely(ret != 0)) 251 if (likely(ret != 0))
251 return -EINVAL; 252 return -EINVAL;
252 253
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
index 7197af157313..25f3c250fd98 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
@@ -688,7 +688,11 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset)
688 goto out_err0; 688 goto out_err0;
689 } 689 }
690 690
691 if (unlikely(dev_priv->prim_bb_mem < dev_priv->vram_size)) 691 /*
692 * Limit back buffer size to VRAM size. Remove this once
693 * screen targets are implemented.
694 */
695 if (dev_priv->prim_bb_mem > dev_priv->vram_size)
692 dev_priv->prim_bb_mem = dev_priv->vram_size; 696 dev_priv->prim_bb_mem = dev_priv->vram_size;
693 697
694 mutex_unlock(&dev_priv->hw_mutex); 698 mutex_unlock(&dev_priv->hw_mutex);
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
index d2bc2b03d4c6..941a7bc0b791 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
@@ -187,7 +187,7 @@ int vmw_du_crtc_cursor_set(struct drm_crtc *crtc, struct drm_file *file_priv,
187 * can do this since the caller in the drm core doesn't check anything 187 * can do this since the caller in the drm core doesn't check anything
188 * which is protected by any looks. 188 * which is protected by any looks.
189 */ 189 */
190 drm_modeset_unlock(&crtc->mutex); 190 drm_modeset_unlock_crtc(crtc);
191 drm_modeset_lock_all(dev_priv->dev); 191 drm_modeset_lock_all(dev_priv->dev);
192 192
193 /* A lot of the code assumes this */ 193 /* A lot of the code assumes this */
@@ -252,7 +252,7 @@ int vmw_du_crtc_cursor_set(struct drm_crtc *crtc, struct drm_file *file_priv,
252 ret = 0; 252 ret = 0;
253out: 253out:
254 drm_modeset_unlock_all(dev_priv->dev); 254 drm_modeset_unlock_all(dev_priv->dev);
255 drm_modeset_lock(&crtc->mutex, NULL); 255 drm_modeset_lock_crtc(crtc);
256 256
257 return ret; 257 return ret;
258} 258}
@@ -273,7 +273,7 @@ int vmw_du_crtc_cursor_move(struct drm_crtc *crtc, int x, int y)
273 * can do this since the caller in the drm core doesn't check anything 273 * can do this since the caller in the drm core doesn't check anything
274 * which is protected by any looks. 274 * which is protected by any looks.
275 */ 275 */
276 drm_modeset_unlock(&crtc->mutex); 276 drm_modeset_unlock_crtc(crtc);
277 drm_modeset_lock_all(dev_priv->dev); 277 drm_modeset_lock_all(dev_priv->dev);
278 278
279 vmw_cursor_update_position(dev_priv, shown, 279 vmw_cursor_update_position(dev_priv, shown,
@@ -281,7 +281,7 @@ int vmw_du_crtc_cursor_move(struct drm_crtc *crtc, int x, int y)
281 du->cursor_y + du->hotspot_y); 281 du->cursor_y + du->hotspot_y);
282 282
283 drm_modeset_unlock_all(dev_priv->dev); 283 drm_modeset_unlock_all(dev_priv->dev);
284 drm_modeset_lock(&crtc->mutex, NULL); 284 drm_modeset_lock_crtc(crtc);
285 285
286 return 0; 286 return 0;
287} 287}
@@ -1950,6 +1950,14 @@ int vmw_du_connector_fill_modes(struct drm_connector *connector,
1950 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) 1950 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC)
1951 }; 1951 };
1952 int i; 1952 int i;
1953 u32 assumed_bpp = 2;
1954
1955 /*
1956 * If using screen objects, then assume 32-bpp because that's what the
1957 * SVGA device is assuming
1958 */
1959 if (dev_priv->sou_priv)
1960 assumed_bpp = 4;
1953 1961
1954 /* Add preferred mode */ 1962 /* Add preferred mode */
1955 { 1963 {
@@ -1960,8 +1968,9 @@ int vmw_du_connector_fill_modes(struct drm_connector *connector,
1960 mode->vdisplay = du->pref_height; 1968 mode->vdisplay = du->pref_height;
1961 vmw_guess_mode_timing(mode); 1969 vmw_guess_mode_timing(mode);
1962 1970
1963 if (vmw_kms_validate_mode_vram(dev_priv, mode->hdisplay * 2, 1971 if (vmw_kms_validate_mode_vram(dev_priv,
1964 mode->vdisplay)) { 1972 mode->hdisplay * assumed_bpp,
1973 mode->vdisplay)) {
1965 drm_mode_probed_add(connector, mode); 1974 drm_mode_probed_add(connector, mode);
1966 } else { 1975 } else {
1967 drm_mode_destroy(dev, mode); 1976 drm_mode_destroy(dev, mode);
@@ -1983,7 +1992,8 @@ int vmw_du_connector_fill_modes(struct drm_connector *connector,
1983 bmode->vdisplay > max_height) 1992 bmode->vdisplay > max_height)
1984 continue; 1993 continue;
1985 1994
1986 if (!vmw_kms_validate_mode_vram(dev_priv, bmode->hdisplay * 2, 1995 if (!vmw_kms_validate_mode_vram(dev_priv,
1996 bmode->hdisplay * assumed_bpp,
1987 bmode->vdisplay)) 1997 bmode->vdisplay))
1988 continue; 1998 continue;
1989 1999
diff --git a/drivers/hid/hid-debug.c b/drivers/hid/hid-debug.c
index 84c3cb15ccdd..8bf61d295ffd 100644
--- a/drivers/hid/hid-debug.c
+++ b/drivers/hid/hid-debug.c
@@ -946,6 +946,12 @@ static const char *keys[KEY_MAX + 1] = {
946 [KEY_BRIGHTNESS_MIN] = "BrightnessMin", 946 [KEY_BRIGHTNESS_MIN] = "BrightnessMin",
947 [KEY_BRIGHTNESS_MAX] = "BrightnessMax", 947 [KEY_BRIGHTNESS_MAX] = "BrightnessMax",
948 [KEY_BRIGHTNESS_AUTO] = "BrightnessAuto", 948 [KEY_BRIGHTNESS_AUTO] = "BrightnessAuto",
949 [KEY_KBDINPUTASSIST_PREV] = "KbdInputAssistPrev",
950 [KEY_KBDINPUTASSIST_NEXT] = "KbdInputAssistNext",
951 [KEY_KBDINPUTASSIST_PREVGROUP] = "KbdInputAssistPrevGroup",
952 [KEY_KBDINPUTASSIST_NEXTGROUP] = "KbdInputAssistNextGroup",
953 [KEY_KBDINPUTASSIST_ACCEPT] = "KbdInputAssistAccept",
954 [KEY_KBDINPUTASSIST_CANCEL] = "KbdInputAssistCancel",
949}; 955};
950 956
951static const char *relatives[REL_MAX + 1] = { 957static const char *relatives[REL_MAX + 1] = {
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index cd9c9e96cf0e..e23ab8b30626 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -298,6 +298,8 @@
298 298
299#define USB_VENDOR_ID_ELAN 0x04f3 299#define USB_VENDOR_ID_ELAN 0x04f3
300#define USB_DEVICE_ID_ELAN_TOUCHSCREEN 0x0089 300#define USB_DEVICE_ID_ELAN_TOUCHSCREEN 0x0089
301#define USB_DEVICE_ID_ELAN_TOUCHSCREEN_009B 0x009b
302#define USB_DEVICE_ID_ELAN_TOUCHSCREEN_016F 0x016f
301 303
302#define USB_VENDOR_ID_ELECOM 0x056e 304#define USB_VENDOR_ID_ELECOM 0x056e
303#define USB_DEVICE_ID_ELECOM_BM084 0x0061 305#define USB_DEVICE_ID_ELECOM_BM084 0x0061
diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
index 2df7fddbd119..725f22ca47fc 100644
--- a/drivers/hid/hid-input.c
+++ b/drivers/hid/hid-input.c
@@ -695,7 +695,10 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
695 break; 695 break;
696 696
697 case 0x5b: /* TransducerSerialNumber */ 697 case 0x5b: /* TransducerSerialNumber */
698 set_bit(MSC_SERIAL, input->mscbit); 698 usage->type = EV_MSC;
699 usage->code = MSC_SERIAL;
700 bit = input->mscbit;
701 max = MSC_MAX;
699 break; 702 break;
700 703
701 default: goto unknown; 704 default: goto unknown;
@@ -862,6 +865,13 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
862 case 0x28b: map_key_clear(KEY_FORWARDMAIL); break; 865 case 0x28b: map_key_clear(KEY_FORWARDMAIL); break;
863 case 0x28c: map_key_clear(KEY_SEND); break; 866 case 0x28c: map_key_clear(KEY_SEND); break;
864 867
868 case 0x2c7: map_key_clear(KEY_KBDINPUTASSIST_PREV); break;
869 case 0x2c8: map_key_clear(KEY_KBDINPUTASSIST_NEXT); break;
870 case 0x2c9: map_key_clear(KEY_KBDINPUTASSIST_PREVGROUP); break;
871 case 0x2ca: map_key_clear(KEY_KBDINPUTASSIST_NEXTGROUP); break;
872 case 0x2cb: map_key_clear(KEY_KBDINPUTASSIST_ACCEPT); break;
873 case 0x2cc: map_key_clear(KEY_KBDINPUTASSIST_CANCEL); break;
874
865 default: goto ignore; 875 default: goto ignore;
866 } 876 }
867 break; 877 break;
diff --git a/drivers/hid/usbhid/hid-quirks.c b/drivers/hid/usbhid/hid-quirks.c
index f3cb5b0a4345..5014bb567b29 100644
--- a/drivers/hid/usbhid/hid-quirks.c
+++ b/drivers/hid/usbhid/hid-quirks.c
@@ -71,6 +71,8 @@ static const struct hid_blacklist {
71 { USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_AXIS_295, HID_QUIRK_NOGET }, 71 { USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_AXIS_295, HID_QUIRK_NOGET },
72 { USB_VENDOR_ID_DMI, USB_DEVICE_ID_DMI_ENC, HID_QUIRK_NOGET }, 72 { USB_VENDOR_ID_DMI, USB_DEVICE_ID_DMI_ENC, HID_QUIRK_NOGET },
73 { USB_VENDOR_ID_ELAN, USB_DEVICE_ID_ELAN_TOUCHSCREEN, HID_QUIRK_ALWAYS_POLL }, 73 { USB_VENDOR_ID_ELAN, USB_DEVICE_ID_ELAN_TOUCHSCREEN, HID_QUIRK_ALWAYS_POLL },
74 { USB_VENDOR_ID_ELAN, USB_DEVICE_ID_ELAN_TOUCHSCREEN_009B, HID_QUIRK_ALWAYS_POLL },
75 { USB_VENDOR_ID_ELAN, USB_DEVICE_ID_ELAN_TOUCHSCREEN_016F, HID_QUIRK_ALWAYS_POLL },
74 { USB_VENDOR_ID_ELO, USB_DEVICE_ID_ELO_TS2700, HID_QUIRK_NOGET }, 76 { USB_VENDOR_ID_ELO, USB_DEVICE_ID_ELO_TS2700, HID_QUIRK_NOGET },
75 { USB_VENDOR_ID_FORMOSA, USB_DEVICE_ID_FORMOSA_IR_RECEIVER, HID_QUIRK_NO_INIT_REPORTS }, 77 { USB_VENDOR_ID_FORMOSA, USB_DEVICE_ID_FORMOSA_IR_RECEIVER, HID_QUIRK_NO_INIT_REPORTS },
76 { USB_VENDOR_ID_FREESCALE, USB_DEVICE_ID_FREESCALE_MX28, HID_QUIRK_NOGET }, 78 { USB_VENDOR_ID_FREESCALE, USB_DEVICE_ID_FREESCALE_MX28, HID_QUIRK_NOGET },
diff --git a/drivers/iio/common/st_sensors/st_sensors_buffer.c b/drivers/iio/common/st_sensors/st_sensors_buffer.c
index 1665c8e4b62b..e18bc6782256 100644
--- a/drivers/iio/common/st_sensors/st_sensors_buffer.c
+++ b/drivers/iio/common/st_sensors/st_sensors_buffer.c
@@ -71,7 +71,7 @@ int st_sensors_get_buffer_element(struct iio_dev *indio_dev, u8 *buf)
71 goto st_sensors_free_memory; 71 goto st_sensors_free_memory;
72 } 72 }
73 73
74 for (i = 0; i < n * num_data_channels; i++) { 74 for (i = 0; i < n * byte_for_channel; i++) {
75 if (i < n) 75 if (i < n)
76 buf[i] = rx_array[i]; 76 buf[i] = rx_array[i];
77 else 77 else
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index bda5994ceb68..8b72cf392b34 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -1173,18 +1173,24 @@ static struct ib_flow *mlx4_ib_create_flow(struct ib_qp *qp,
1173 err = __mlx4_ib_create_flow(qp, flow_attr, domain, type[i], 1173 err = __mlx4_ib_create_flow(qp, flow_attr, domain, type[i],
1174 &mflow->reg_id[i]); 1174 &mflow->reg_id[i]);
1175 if (err) 1175 if (err)
1176 goto err_free; 1176 goto err_create_flow;
1177 i++; 1177 i++;
1178 } 1178 }
1179 1179
1180 if (i < ARRAY_SIZE(type) && flow_attr->type == IB_FLOW_ATTR_NORMAL) { 1180 if (i < ARRAY_SIZE(type) && flow_attr->type == IB_FLOW_ATTR_NORMAL) {
1181 err = mlx4_ib_tunnel_steer_add(qp, flow_attr, &mflow->reg_id[i]); 1181 err = mlx4_ib_tunnel_steer_add(qp, flow_attr, &mflow->reg_id[i]);
1182 if (err) 1182 if (err)
1183 goto err_free; 1183 goto err_create_flow;
1184 i++;
1184 } 1185 }
1185 1186
1186 return &mflow->ibflow; 1187 return &mflow->ibflow;
1187 1188
1189err_create_flow:
1190 while (i) {
1191 (void)__mlx4_ib_destroy_flow(to_mdev(qp->device)->dev, mflow->reg_id[i]);
1192 i--;
1193 }
1188err_free: 1194err_free:
1189 kfree(mflow); 1195 kfree(mflow);
1190 return ERR_PTR(err); 1196 return ERR_PTR(err);
diff --git a/drivers/input/keyboard/opencores-kbd.c b/drivers/input/keyboard/opencores-kbd.c
index 62abe2c16670..f8502bb29176 100644
--- a/drivers/input/keyboard/opencores-kbd.c
+++ b/drivers/input/keyboard/opencores-kbd.c
@@ -70,7 +70,7 @@ static int opencores_kbd_probe(struct platform_device *pdev)
70 70
71 opencores_kbd->addr = devm_ioremap_resource(&pdev->dev, res); 71 opencores_kbd->addr = devm_ioremap_resource(&pdev->dev, res);
72 if (IS_ERR(opencores_kbd->addr)) 72 if (IS_ERR(opencores_kbd->addr))
73 error = PTR_ERR(opencores_kbd->addr); 73 return PTR_ERR(opencores_kbd->addr);
74 74
75 input->name = pdev->name; 75 input->name = pdev->name;
76 input->phys = "opencores-kbd/input0"; 76 input->phys = "opencores-kbd/input0";
diff --git a/drivers/input/keyboard/stmpe-keypad.c b/drivers/input/keyboard/stmpe-keypad.c
index c6727dda68f2..ef5e67fb567e 100644
--- a/drivers/input/keyboard/stmpe-keypad.c
+++ b/drivers/input/keyboard/stmpe-keypad.c
@@ -86,7 +86,7 @@ static const struct stmpe_keypad_variant stmpe_keypad_variants[] = {
86 .max_cols = 8, 86 .max_cols = 8,
87 .max_rows = 12, 87 .max_rows = 12,
88 .col_gpios = 0x0000ff, /* GPIO 0 - 7*/ 88 .col_gpios = 0x0000ff, /* GPIO 0 - 7*/
89 .row_gpios = 0x1fef00, /* GPIO 8-14, 16-20 */ 89 .row_gpios = 0x1f7f00, /* GPIO 8-14, 16-20 */
90 }, 90 },
91 [STMPE2403] = { 91 [STMPE2403] = {
92 .auto_increment = true, 92 .auto_increment = true,
diff --git a/drivers/input/misc/ims-pcu.c b/drivers/input/misc/ims-pcu.c
index 719410feb84b..afed8e2b2f94 100644
--- a/drivers/input/misc/ims-pcu.c
+++ b/drivers/input/misc/ims-pcu.c
@@ -1381,7 +1381,7 @@ static ssize_t ims_pcu_ofn_reg_addr_store(struct device *dev,
1381 pcu->ofn_reg_addr = value; 1381 pcu->ofn_reg_addr = value;
1382 mutex_unlock(&pcu->cmd_mutex); 1382 mutex_unlock(&pcu->cmd_mutex);
1383 1383
1384 return error ?: count; 1384 return count;
1385} 1385}
1386 1386
1387static DEVICE_ATTR(reg_addr, S_IRUGO | S_IWUSR, 1387static DEVICE_ATTR(reg_addr, S_IRUGO | S_IWUSR,
diff --git a/drivers/input/misc/max77693-haptic.c b/drivers/input/misc/max77693-haptic.c
index 7b1fde93799e..ef6a9d650d69 100644
--- a/drivers/input/misc/max77693-haptic.c
+++ b/drivers/input/misc/max77693-haptic.c
@@ -194,7 +194,7 @@ static int max77693_haptic_play_effect(struct input_dev *dev, void *data,
194 struct ff_effect *effect) 194 struct ff_effect *effect)
195{ 195{
196 struct max77693_haptic *haptic = input_get_drvdata(dev); 196 struct max77693_haptic *haptic = input_get_drvdata(dev);
197 uint64_t period_mag_multi; 197 u64 period_mag_multi;
198 198
199 haptic->magnitude = effect->u.rumble.strong_magnitude; 199 haptic->magnitude = effect->u.rumble.strong_magnitude;
200 if (!haptic->magnitude) 200 if (!haptic->magnitude)
@@ -205,8 +205,7 @@ static int max77693_haptic_play_effect(struct input_dev *dev, void *data,
205 * The formula to convert magnitude to pwm_duty as follows: 205 * The formula to convert magnitude to pwm_duty as follows:
206 * - pwm_duty = (magnitude * pwm_period) / MAX_MAGNITUDE(0xFFFF) 206 * - pwm_duty = (magnitude * pwm_period) / MAX_MAGNITUDE(0xFFFF)
207 */ 207 */
208 period_mag_multi = (int64_t)(haptic->pwm_dev->period * 208 period_mag_multi = (u64)haptic->pwm_dev->period * haptic->magnitude;
209 haptic->magnitude);
210 haptic->pwm_duty = (unsigned int)(period_mag_multi >> 209 haptic->pwm_duty = (unsigned int)(period_mag_multi >>
211 MAX_MAGNITUDE_SHIFT); 210 MAX_MAGNITUDE_SHIFT);
212 211
diff --git a/drivers/input/misc/soc_button_array.c b/drivers/input/misc/soc_button_array.c
index 735604753568..e097f1ab427f 100644
--- a/drivers/input/misc/soc_button_array.c
+++ b/drivers/input/misc/soc_button_array.c
@@ -55,7 +55,7 @@ static int soc_button_lookup_gpio(struct device *dev, int acpi_index)
55 struct gpio_desc *desc; 55 struct gpio_desc *desc;
56 int gpio; 56 int gpio;
57 57
58 desc = gpiod_get_index(dev, KBUILD_MODNAME, acpi_index); 58 desc = gpiod_get_index(dev, KBUILD_MODNAME, acpi_index, GPIOD_ASIS);
59 if (IS_ERR(desc)) 59 if (IS_ERR(desc))
60 return PTR_ERR(desc); 60 return PTR_ERR(desc);
61 61
diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
index 26994f6a2b2a..95a3a6e2faf6 100644
--- a/drivers/input/mouse/psmouse-base.c
+++ b/drivers/input/mouse/psmouse-base.c
@@ -1536,16 +1536,9 @@ static int psmouse_reconnect(struct serio *serio)
1536{ 1536{
1537 struct psmouse *psmouse = serio_get_drvdata(serio); 1537 struct psmouse *psmouse = serio_get_drvdata(serio);
1538 struct psmouse *parent = NULL; 1538 struct psmouse *parent = NULL;
1539 struct serio_driver *drv = serio->drv;
1540 unsigned char type; 1539 unsigned char type;
1541 int rc = -1; 1540 int rc = -1;
1542 1541
1543 if (!drv || !psmouse) {
1544 psmouse_dbg(psmouse,
1545 "reconnect request, but serio is disconnected, ignoring...\n");
1546 return -1;
1547 }
1548
1549 mutex_lock(&psmouse_mutex); 1542 mutex_lock(&psmouse_mutex);
1550 1543
1551 if (serio->parent && serio->id.type == SERIO_PS_PSTHRU) { 1544 if (serio->parent && serio->id.type == SERIO_PS_PSTHRU) {
diff --git a/drivers/input/mouse/vsxxxaa.c b/drivers/input/mouse/vsxxxaa.c
index 38298232124f..abd494411e69 100644
--- a/drivers/input/mouse/vsxxxaa.c
+++ b/drivers/input/mouse/vsxxxaa.c
@@ -128,7 +128,7 @@ static void vsxxxaa_drop_bytes(struct vsxxxaa *mouse, int num)
128 if (num >= mouse->count) { 128 if (num >= mouse->count) {
129 mouse->count = 0; 129 mouse->count = 0;
130 } else { 130 } else {
131 memmove(mouse->buf, mouse->buf + num - 1, BUFLEN - num); 131 memmove(mouse->buf, mouse->buf + num, BUFLEN - num);
132 mouse->count -= num; 132 mouse->count -= num;
133 } 133 }
134} 134}
diff --git a/drivers/input/serio/altera_ps2.c b/drivers/input/serio/altera_ps2.c
index cce69d6b9587..58781c8a8aec 100644
--- a/drivers/input/serio/altera_ps2.c
+++ b/drivers/input/serio/altera_ps2.c
@@ -37,7 +37,7 @@ static irqreturn_t altera_ps2_rxint(int irq, void *dev_id)
37{ 37{
38 struct ps2if *ps2if = dev_id; 38 struct ps2if *ps2if = dev_id;
39 unsigned int status; 39 unsigned int status;
40 int handled = IRQ_NONE; 40 irqreturn_t handled = IRQ_NONE;
41 41
42 while ((status = readl(ps2if->base)) & 0xffff0000) { 42 while ((status = readl(ps2if->base)) & 0xffff0000) {
43 serio_interrupt(ps2if->io, status & 0xff, 0); 43 serio_interrupt(ps2if->io, status & 0xff, 0);
@@ -74,7 +74,7 @@ static void altera_ps2_close(struct serio *io)
74{ 74{
75 struct ps2if *ps2if = io->port_data; 75 struct ps2if *ps2if = io->port_data;
76 76
77 writel(0, ps2if->base); /* disable rx irq */ 77 writel(0, ps2if->base + 4); /* disable rx irq */
78} 78}
79 79
80/* 80/*
diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h
index a0bcbb64d06d..faeeb1372462 100644
--- a/drivers/input/serio/i8042-x86ia64io.h
+++ b/drivers/input/serio/i8042-x86ia64io.h
@@ -207,17 +207,282 @@ static const struct dmi_system_id __initconst i8042_dmi_noloop_table[] = {
207}; 207};
208 208
209/* 209/*
210 * Some laptops do implement active multiplexing mode correctly; 210 * Some Fujitsu notebooks are having trouble with touchpads if
211 * unfortunately they are in minority. 211 * active multiplexing mode is activated. Luckily they don't have
212 * external PS/2 ports so we can safely disable it.
213 * ... apparently some Toshibas don't like MUX mode either and
214 * die horrible death on reboot.
212 */ 215 */
213static const struct dmi_system_id __initconst i8042_dmi_mux_table[] = { 216static const struct dmi_system_id __initconst i8042_dmi_nomux_table[] = {
217 {
218 /* Fujitsu Lifebook P7010/P7010D */
219 .matches = {
220 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
221 DMI_MATCH(DMI_PRODUCT_NAME, "P7010"),
222 },
223 },
224 {
225 /* Fujitsu Lifebook P7010 */
226 .matches = {
227 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
228 DMI_MATCH(DMI_PRODUCT_NAME, "0000000000"),
229 },
230 },
231 {
232 /* Fujitsu Lifebook P5020D */
233 .matches = {
234 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
235 DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook P Series"),
236 },
237 },
238 {
239 /* Fujitsu Lifebook S2000 */
240 .matches = {
241 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
242 DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook S Series"),
243 },
244 },
245 {
246 /* Fujitsu Lifebook S6230 */
247 .matches = {
248 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
249 DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook S6230"),
250 },
251 },
252 {
253 /* Fujitsu T70H */
254 .matches = {
255 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
256 DMI_MATCH(DMI_PRODUCT_NAME, "FMVLT70H"),
257 },
258 },
259 {
260 /* Fujitsu-Siemens Lifebook T3010 */
261 .matches = {
262 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
263 DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK T3010"),
264 },
265 },
266 {
267 /* Fujitsu-Siemens Lifebook E4010 */
268 .matches = {
269 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
270 DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK E4010"),
271 },
272 },
273 {
274 /* Fujitsu-Siemens Amilo Pro 2010 */
275 .matches = {
276 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
277 DMI_MATCH(DMI_PRODUCT_NAME, "AMILO Pro V2010"),
278 },
279 },
280 {
281 /* Fujitsu-Siemens Amilo Pro 2030 */
282 .matches = {
283 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
284 DMI_MATCH(DMI_PRODUCT_NAME, "AMILO PRO V2030"),
285 },
286 },
287 {
288 /*
289 * No data is coming from the touchscreen unless KBC
290 * is in legacy mode.
291 */
292 /* Panasonic CF-29 */
293 .matches = {
294 DMI_MATCH(DMI_SYS_VENDOR, "Matsushita"),
295 DMI_MATCH(DMI_PRODUCT_NAME, "CF-29"),
296 },
297 },
298 {
299 /*
300 * HP Pavilion DV4017EA -
301 * errors on MUX ports are reported without raising AUXDATA
302 * causing "spurious NAK" messages.
303 */
304 .matches = {
305 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
306 DMI_MATCH(DMI_PRODUCT_NAME, "Pavilion dv4000 (EA032EA#ABF)"),
307 },
308 },
309 {
310 /*
311 * HP Pavilion ZT1000 -
312 * like DV4017EA does not raise AUXERR for errors on MUX ports.
313 */
314 .matches = {
315 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
316 DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion Notebook PC"),
317 DMI_MATCH(DMI_PRODUCT_VERSION, "HP Pavilion Notebook ZT1000"),
318 },
319 },
320 {
321 /*
322 * HP Pavilion DV4270ca -
323 * like DV4017EA does not raise AUXERR for errors on MUX ports.
324 */
325 .matches = {
326 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
327 DMI_MATCH(DMI_PRODUCT_NAME, "Pavilion dv4000 (EH476UA#ABL)"),
328 },
329 },
330 {
331 .matches = {
332 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
333 DMI_MATCH(DMI_PRODUCT_NAME, "Satellite P10"),
334 },
335 },
336 {
337 .matches = {
338 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
339 DMI_MATCH(DMI_PRODUCT_NAME, "EQUIUM A110"),
340 },
341 },
342 {
343 .matches = {
344 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
345 DMI_MATCH(DMI_PRODUCT_NAME, "SATELLITE C850D"),
346 },
347 },
348 {
349 .matches = {
350 DMI_MATCH(DMI_SYS_VENDOR, "ALIENWARE"),
351 DMI_MATCH(DMI_PRODUCT_NAME, "Sentia"),
352 },
353 },
354 {
355 /* Sharp Actius MM20 */
356 .matches = {
357 DMI_MATCH(DMI_SYS_VENDOR, "SHARP"),
358 DMI_MATCH(DMI_PRODUCT_NAME, "PC-MM20 Series"),
359 },
360 },
361 {
362 /* Sony Vaio FS-115b */
363 .matches = {
364 DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
365 DMI_MATCH(DMI_PRODUCT_NAME, "VGN-FS115B"),
366 },
367 },
368 {
369 /*
370 * Sony Vaio FZ-240E -
371 * reset and GET ID commands issued via KBD port are
372 * sometimes being delivered to AUX3.
373 */
374 .matches = {
375 DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
376 DMI_MATCH(DMI_PRODUCT_NAME, "VGN-FZ240E"),
377 },
378 },
214 { 379 {
215 /* 380 /*
216 * Panasonic CF-18 needs to be in MUX mode since the 381 * Most (all?) VAIOs do not have external PS/2 ports nor
217 * touchscreen is on serio3 and it also has touchpad. 382 * they implement active multiplexing properly, and
383 * MUX discovery usually messes up keyboard/touchpad.
218 */ 384 */
219 .matches = { 385 .matches = {
220 DMI_MATCH(DMI_PRODUCT_NAME, "CF-18"), 386 DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
387 DMI_MATCH(DMI_BOARD_NAME, "VAIO"),
388 },
389 },
390 {
391 /* Amoi M636/A737 */
392 .matches = {
393 DMI_MATCH(DMI_SYS_VENDOR, "Amoi Electronics CO.,LTD."),
394 DMI_MATCH(DMI_PRODUCT_NAME, "M636/A737 platform"),
395 },
396 },
397 {
398 /* Lenovo 3000 n100 */
399 .matches = {
400 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
401 DMI_MATCH(DMI_PRODUCT_NAME, "076804U"),
402 },
403 },
404 {
405 .matches = {
406 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
407 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 1360"),
408 },
409 },
410 {
411 /* Acer Aspire 5710 */
412 .matches = {
413 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
414 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5710"),
415 },
416 },
417 {
418 /* Gericom Bellagio */
419 .matches = {
420 DMI_MATCH(DMI_SYS_VENDOR, "Gericom"),
421 DMI_MATCH(DMI_PRODUCT_NAME, "N34AS6"),
422 },
423 },
424 {
425 /* IBM 2656 */
426 .matches = {
427 DMI_MATCH(DMI_SYS_VENDOR, "IBM"),
428 DMI_MATCH(DMI_PRODUCT_NAME, "2656"),
429 },
430 },
431 {
432 /* Dell XPS M1530 */
433 .matches = {
434 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
435 DMI_MATCH(DMI_PRODUCT_NAME, "XPS M1530"),
436 },
437 },
438 {
439 /* Compal HEL80I */
440 .matches = {
441 DMI_MATCH(DMI_SYS_VENDOR, "COMPAL"),
442 DMI_MATCH(DMI_PRODUCT_NAME, "HEL80I"),
443 },
444 },
445 {
446 /* Dell Vostro 1510 */
447 .matches = {
448 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
449 DMI_MATCH(DMI_PRODUCT_NAME, "Vostro1510"),
450 },
451 },
452 {
453 /* Acer Aspire 5536 */
454 .matches = {
455 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
456 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5536"),
457 DMI_MATCH(DMI_PRODUCT_VERSION, "0100"),
458 },
459 },
460 {
461 /* Dell Vostro V13 */
462 .matches = {
463 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
464 DMI_MATCH(DMI_PRODUCT_NAME, "Vostro V13"),
465 },
466 },
467 {
468 /* Newer HP Pavilion dv4 models */
469 .matches = {
470 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
471 DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion dv4 Notebook PC"),
472 },
473 },
474 {
475 /* Asus X450LCP */
476 .matches = {
477 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
478 DMI_MATCH(DMI_PRODUCT_NAME, "X450LCP"),
479 },
480 },
481 {
482 /* Avatar AVIU-145A6 */
483 .matches = {
484 DMI_MATCH(DMI_SYS_VENDOR, "Intel"),
485 DMI_MATCH(DMI_PRODUCT_NAME, "IC4I"),
221 }, 486 },
222 }, 487 },
223 { } 488 { }
@@ -364,6 +629,22 @@ static const struct dmi_system_id __initconst i8042_dmi_notimeout_table[] = {
364 }, 629 },
365 }, 630 },
366 { 631 {
632 /* Fujitsu A544 laptop */
633 /* https://bugzilla.redhat.com/show_bug.cgi?id=1111138 */
634 .matches = {
635 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
636 DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK A544"),
637 },
638 },
639 {
640 /* Fujitsu AH544 laptop */
641 /* https://bugzilla.kernel.org/show_bug.cgi?id=69731 */
642 .matches = {
643 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
644 DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK AH544"),
645 },
646 },
647 {
367 /* Fujitsu U574 laptop */ 648 /* Fujitsu U574 laptop */
368 /* https://bugzilla.kernel.org/show_bug.cgi?id=69731 */ 649 /* https://bugzilla.kernel.org/show_bug.cgi?id=69731 */
369 .matches = { 650 .matches = {
@@ -740,8 +1021,8 @@ static int __init i8042_platform_init(void)
740 if (dmi_check_system(i8042_dmi_noloop_table)) 1021 if (dmi_check_system(i8042_dmi_noloop_table))
741 i8042_noloop = true; 1022 i8042_noloop = true;
742 1023
743 if (dmi_check_system(i8042_dmi_mux_table)) 1024 if (dmi_check_system(i8042_dmi_nomux_table))
744 i8042_nomux = false; 1025 i8042_nomux = true;
745 1026
746 if (dmi_check_system(i8042_dmi_notimeout_table)) 1027 if (dmi_check_system(i8042_dmi_notimeout_table))
747 i8042_notimeout = true; 1028 i8042_notimeout = true;
diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c
index 9a97c2b10926..f5a98af3b325 100644
--- a/drivers/input/serio/i8042.c
+++ b/drivers/input/serio/i8042.c
@@ -39,7 +39,7 @@ static bool i8042_noaux;
39module_param_named(noaux, i8042_noaux, bool, 0); 39module_param_named(noaux, i8042_noaux, bool, 0);
40MODULE_PARM_DESC(noaux, "Do not probe or use AUX (mouse) port."); 40MODULE_PARM_DESC(noaux, "Do not probe or use AUX (mouse) port.");
41 41
42static bool i8042_nomux = true; 42static bool i8042_nomux;
43module_param_named(nomux, i8042_nomux, bool, 0); 43module_param_named(nomux, i8042_nomux, bool, 0);
44MODULE_PARM_DESC(nomux, "Do not check whether an active multiplexing controller is present."); 44MODULE_PARM_DESC(nomux, "Do not check whether an active multiplexing controller is present.");
45 45
diff --git a/drivers/input/touchscreen/wm97xx-core.c b/drivers/input/touchscreen/wm97xx-core.c
index d0ef91fc87d1..b1ae77995968 100644
--- a/drivers/input/touchscreen/wm97xx-core.c
+++ b/drivers/input/touchscreen/wm97xx-core.c
@@ -70,11 +70,11 @@
70 * Documentation/input/input-programming.txt for more details. 70 * Documentation/input/input-programming.txt for more details.
71 */ 71 */
72 72
73static int abs_x[3] = {350, 3900, 5}; 73static int abs_x[3] = {150, 4000, 5};
74module_param_array(abs_x, int, NULL, 0); 74module_param_array(abs_x, int, NULL, 0);
75MODULE_PARM_DESC(abs_x, "Touchscreen absolute X min, max, fuzz"); 75MODULE_PARM_DESC(abs_x, "Touchscreen absolute X min, max, fuzz");
76 76
77static int abs_y[3] = {320, 3750, 40}; 77static int abs_y[3] = {200, 4000, 40};
78module_param_array(abs_y, int, NULL, 0); 78module_param_array(abs_y, int, NULL, 0);
79MODULE_PARM_DESC(abs_y, "Touchscreen absolute Y min, max, fuzz"); 79MODULE_PARM_DESC(abs_y, "Touchscreen absolute Y min, max, fuzz");
80 80
diff --git a/drivers/media/common/saa7146/saa7146_core.c b/drivers/media/common/saa7146/saa7146_core.c
index 97afee672d07..4418119cf707 100644
--- a/drivers/media/common/saa7146/saa7146_core.c
+++ b/drivers/media/common/saa7146/saa7146_core.c
@@ -364,6 +364,9 @@ static int saa7146_init_one(struct pci_dev *pci, const struct pci_device_id *ent
364 goto out; 364 goto out;
365 } 365 }
366 366
367 /* create a nice device name */
368 sprintf(dev->name, "saa7146 (%d)", saa7146_num);
369
367 DEB_EE("pci:%p\n", pci); 370 DEB_EE("pci:%p\n", pci);
368 371
369 err = pci_enable_device(pci); 372 err = pci_enable_device(pci);
@@ -438,9 +441,6 @@ static int saa7146_init_one(struct pci_dev *pci, const struct pci_device_id *ent
438 441
439 /* the rest + print status message */ 442 /* the rest + print status message */
440 443
441 /* create a nice device name */
442 sprintf(dev->name, "saa7146 (%d)", saa7146_num);
443
444 pr_info("found saa7146 @ mem %p (revision %d, irq %d) (0x%04x,0x%04x)\n", 444 pr_info("found saa7146 @ mem %p (revision %d, irq %d) (0x%04x,0x%04x)\n",
445 dev->mem, dev->revision, pci->irq, 445 dev->mem, dev->revision, pci->irq,
446 pci->subsystem_vendor, pci->subsystem_device); 446 pci->subsystem_vendor, pci->subsystem_device);
diff --git a/drivers/media/pci/cx23885/cx23885-dvb.c b/drivers/media/pci/cx23885/cx23885-dvb.c
index 13734b8c7917..4cb90317ff45 100644
--- a/drivers/media/pci/cx23885/cx23885-dvb.c
+++ b/drivers/media/pci/cx23885/cx23885-dvb.c
@@ -1600,6 +1600,7 @@ static int dvb_register(struct cx23885_tsport *port)
1600 break; 1600 break;
1601 1601
1602 /* attach tuner */ 1602 /* attach tuner */
1603 memset(&m88ts2022_config, 0, sizeof(m88ts2022_config));
1603 m88ts2022_config.fe = fe0->dvb.frontend; 1604 m88ts2022_config.fe = fe0->dvb.frontend;
1604 m88ts2022_config.clock = 27000000; 1605 m88ts2022_config.clock = 27000000;
1605 memset(&info, 0, sizeof(struct i2c_board_info)); 1606 memset(&info, 0, sizeof(struct i2c_board_info));
@@ -1635,6 +1636,7 @@ static int dvb_register(struct cx23885_tsport *port)
1635 /* port c - terrestrial/cable */ 1636 /* port c - terrestrial/cable */
1636 case 2: 1637 case 2:
1637 /* attach frontend */ 1638 /* attach frontend */
1639 memset(&si2168_config, 0, sizeof(si2168_config));
1638 si2168_config.i2c_adapter = &adapter; 1640 si2168_config.i2c_adapter = &adapter;
1639 si2168_config.fe = &fe0->dvb.frontend; 1641 si2168_config.fe = &fe0->dvb.frontend;
1640 si2168_config.ts_mode = SI2168_TS_SERIAL; 1642 si2168_config.ts_mode = SI2168_TS_SERIAL;
@@ -1654,6 +1656,7 @@ static int dvb_register(struct cx23885_tsport *port)
1654 port->i2c_client_demod = client_demod; 1656 port->i2c_client_demod = client_demod;
1655 1657
1656 /* attach tuner */ 1658 /* attach tuner */
1659 memset(&si2157_config, 0, sizeof(si2157_config));
1657 si2157_config.fe = fe0->dvb.frontend; 1660 si2157_config.fe = fe0->dvb.frontend;
1658 memset(&info, 0, sizeof(struct i2c_board_info)); 1661 memset(&info, 0, sizeof(struct i2c_board_info));
1659 strlcpy(info.type, "si2157", I2C_NAME_SIZE); 1662 strlcpy(info.type, "si2157", I2C_NAME_SIZE);
diff --git a/drivers/media/pci/tw68/Kconfig b/drivers/media/pci/tw68/Kconfig
index 5425ba1e320d..95d5d5202048 100644
--- a/drivers/media/pci/tw68/Kconfig
+++ b/drivers/media/pci/tw68/Kconfig
@@ -1,7 +1,6 @@
1config VIDEO_TW68 1config VIDEO_TW68
2 tristate "Techwell tw68x Video For Linux" 2 tristate "Techwell tw68x Video For Linux"
3 depends on VIDEO_DEV && PCI && VIDEO_V4L2 3 depends on VIDEO_DEV && PCI && VIDEO_V4L2
4 select I2C_ALGOBIT
5 select VIDEOBUF2_DMA_SG 4 select VIDEOBUF2_DMA_SG
6 ---help--- 5 ---help---
7 Support for Techwell tw68xx based frame grabber boards. 6 Support for Techwell tw68xx based frame grabber boards.
diff --git a/drivers/media/pci/tw68/tw68-core.c b/drivers/media/pci/tw68/tw68-core.c
index a6fb48cf7aae..63f0b64057cb 100644
--- a/drivers/media/pci/tw68/tw68-core.c
+++ b/drivers/media/pci/tw68/tw68-core.c
@@ -306,7 +306,7 @@ static int tw68_initdev(struct pci_dev *pci_dev,
306 306
307 /* get irq */ 307 /* get irq */
308 err = devm_request_irq(&pci_dev->dev, pci_dev->irq, tw68_irq, 308 err = devm_request_irq(&pci_dev->dev, pci_dev->irq, tw68_irq,
309 IRQF_SHARED | IRQF_DISABLED, dev->name, dev); 309 IRQF_SHARED, dev->name, dev);
310 if (err < 0) { 310 if (err < 0) {
311 pr_err("%s: can't get IRQ %d\n", 311 pr_err("%s: can't get IRQ %d\n",
312 dev->name, pci_dev->irq); 312 dev->name, pci_dev->irq);
diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index bee9074ebc13..3aac88f1d54a 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -166,7 +166,7 @@ config VIDEO_MEM2MEM_DEINTERLACE
166config VIDEO_SAMSUNG_S5P_G2D 166config VIDEO_SAMSUNG_S5P_G2D
167 tristate "Samsung S5P and EXYNOS4 G2D 2d graphics accelerator driver" 167 tristate "Samsung S5P and EXYNOS4 G2D 2d graphics accelerator driver"
168 depends on VIDEO_DEV && VIDEO_V4L2 168 depends on VIDEO_DEV && VIDEO_V4L2
169 depends on PLAT_S5P || ARCH_EXYNOS || COMPILE_TEST 169 depends on ARCH_S5PV210 || ARCH_EXYNOS || COMPILE_TEST
170 depends on HAS_DMA 170 depends on HAS_DMA
171 select VIDEOBUF2_DMA_CONTIG 171 select VIDEOBUF2_DMA_CONTIG
172 select V4L2_MEM2MEM_DEV 172 select V4L2_MEM2MEM_DEV
@@ -178,7 +178,7 @@ config VIDEO_SAMSUNG_S5P_G2D
178config VIDEO_SAMSUNG_S5P_JPEG 178config VIDEO_SAMSUNG_S5P_JPEG
179 tristate "Samsung S5P/Exynos3250/Exynos4 JPEG codec driver" 179 tristate "Samsung S5P/Exynos3250/Exynos4 JPEG codec driver"
180 depends on VIDEO_DEV && VIDEO_V4L2 180 depends on VIDEO_DEV && VIDEO_V4L2
181 depends on PLAT_S5P || ARCH_EXYNOS || COMPILE_TEST 181 depends on ARCH_S5PV210 || ARCH_EXYNOS || COMPILE_TEST
182 depends on HAS_DMA 182 depends on HAS_DMA
183 select VIDEOBUF2_DMA_CONTIG 183 select VIDEOBUF2_DMA_CONTIG
184 select V4L2_MEM2MEM_DEV 184 select V4L2_MEM2MEM_DEV
@@ -189,7 +189,7 @@ config VIDEO_SAMSUNG_S5P_JPEG
189config VIDEO_SAMSUNG_S5P_MFC 189config VIDEO_SAMSUNG_S5P_MFC
190 tristate "Samsung S5P MFC Video Codec" 190 tristate "Samsung S5P MFC Video Codec"
191 depends on VIDEO_DEV && VIDEO_V4L2 191 depends on VIDEO_DEV && VIDEO_V4L2
192 depends on PLAT_S5P || ARCH_EXYNOS || COMPILE_TEST 192 depends on ARCH_S5PV210 || ARCH_EXYNOS || COMPILE_TEST
193 depends on HAS_DMA 193 depends on HAS_DMA
194 select VIDEOBUF2_DMA_CONTIG 194 select VIDEOBUF2_DMA_CONTIG
195 default n 195 default n
diff --git a/drivers/media/platform/exynos4-is/Kconfig b/drivers/media/platform/exynos4-is/Kconfig
index 77c951237744..b7b2e472240a 100644
--- a/drivers/media/platform/exynos4-is/Kconfig
+++ b/drivers/media/platform/exynos4-is/Kconfig
@@ -2,7 +2,7 @@
2config VIDEO_SAMSUNG_EXYNOS4_IS 2config VIDEO_SAMSUNG_EXYNOS4_IS
3 bool "Samsung S5P/EXYNOS4 SoC series Camera Subsystem driver" 3 bool "Samsung S5P/EXYNOS4 SoC series Camera Subsystem driver"
4 depends on VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API 4 depends on VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API
5 depends on (PLAT_S5P || ARCH_EXYNOS || COMPILE_TEST) 5 depends on ARCH_S5PV210 || ARCH_EXYNOS || COMPILE_TEST
6 depends on OF && COMMON_CLK 6 depends on OF && COMMON_CLK
7 help 7 help
8 Say Y here to enable camera host interface devices for 8 Say Y here to enable camera host interface devices for
diff --git a/drivers/media/platform/exynos4-is/fimc-core.c b/drivers/media/platform/exynos4-is/fimc-core.c
index b70fd996d794..aee92d908e49 100644
--- a/drivers/media/platform/exynos4-is/fimc-core.c
+++ b/drivers/media/platform/exynos4-is/fimc-core.c
@@ -832,6 +832,7 @@ err:
832 return -ENXIO; 832 return -ENXIO;
833} 833}
834 834
835#if defined(CONFIG_PM_RUNTIME) || defined(CONFIG_PM_SLEEP)
835static int fimc_m2m_suspend(struct fimc_dev *fimc) 836static int fimc_m2m_suspend(struct fimc_dev *fimc)
836{ 837{
837 unsigned long flags; 838 unsigned long flags;
@@ -870,6 +871,7 @@ static int fimc_m2m_resume(struct fimc_dev *fimc)
870 871
871 return 0; 872 return 0;
872} 873}
874#endif /* CONFIG_PM_RUNTIME || CONFIG_PM_SLEEP */
873 875
874static const struct of_device_id fimc_of_match[]; 876static const struct of_device_id fimc_of_match[];
875 877
diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c
index e525a7c8d885..6fcc7f072ace 100644
--- a/drivers/media/platform/s5p-jpeg/jpeg-core.c
+++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c
@@ -893,7 +893,7 @@ static bool s5p_jpeg_parse_hdr(struct s5p_jpeg_q_data *result,
893 unsigned long buffer, unsigned long size, 893 unsigned long buffer, unsigned long size,
894 struct s5p_jpeg_ctx *ctx) 894 struct s5p_jpeg_ctx *ctx)
895{ 895{
896 int c, components, notfound; 896 int c, components = 0, notfound;
897 unsigned int height, width, word, subsampling = 0; 897 unsigned int height, width, word, subsampling = 0;
898 long length; 898 long length;
899 struct s5p_jpeg_buffer jpeg_buffer; 899 struct s5p_jpeg_buffer jpeg_buffer;
@@ -2632,6 +2632,7 @@ static int s5p_jpeg_remove(struct platform_device *pdev)
2632 return 0; 2632 return 0;
2633} 2633}
2634 2634
2635#if defined(CONFIG_PM_RUNTIME) || defined(CONFIG_PM_SLEEP)
2635static int s5p_jpeg_runtime_suspend(struct device *dev) 2636static int s5p_jpeg_runtime_suspend(struct device *dev)
2636{ 2637{
2637 struct s5p_jpeg *jpeg = dev_get_drvdata(dev); 2638 struct s5p_jpeg *jpeg = dev_get_drvdata(dev);
@@ -2681,7 +2682,9 @@ static int s5p_jpeg_runtime_resume(struct device *dev)
2681 2682
2682 return 0; 2683 return 0;
2683} 2684}
2685#endif /* CONFIG_PM_RUNTIME || CONFIG_PM_SLEEP */
2684 2686
2687#ifdef CONFIG_PM_SLEEP
2685static int s5p_jpeg_suspend(struct device *dev) 2688static int s5p_jpeg_suspend(struct device *dev)
2686{ 2689{
2687 if (pm_runtime_suspended(dev)) 2690 if (pm_runtime_suspended(dev))
@@ -2697,6 +2700,7 @@ static int s5p_jpeg_resume(struct device *dev)
2697 2700
2698 return s5p_jpeg_runtime_resume(dev); 2701 return s5p_jpeg_runtime_resume(dev);
2699} 2702}
2703#endif
2700 2704
2701static const struct dev_pm_ops s5p_jpeg_pm_ops = { 2705static const struct dev_pm_ops s5p_jpeg_pm_ops = {
2702 SET_SYSTEM_SLEEP_PM_OPS(s5p_jpeg_suspend, s5p_jpeg_resume) 2706 SET_SYSTEM_SLEEP_PM_OPS(s5p_jpeg_suspend, s5p_jpeg_resume)
diff --git a/drivers/media/platform/s5p-tv/Kconfig b/drivers/media/platform/s5p-tv/Kconfig
index a9d56f8936b4..beb180e71ba0 100644
--- a/drivers/media/platform/s5p-tv/Kconfig
+++ b/drivers/media/platform/s5p-tv/Kconfig
@@ -9,7 +9,7 @@
9config VIDEO_SAMSUNG_S5P_TV 9config VIDEO_SAMSUNG_S5P_TV
10 bool "Samsung TV driver for S5P platform" 10 bool "Samsung TV driver for S5P platform"
11 depends on PM_RUNTIME 11 depends on PM_RUNTIME
12 depends on PLAT_S5P || ARCH_EXYNOS || COMPILE_TEST 12 depends on ARCH_S5PV210 || ARCH_EXYNOS || COMPILE_TEST
13 default n 13 default n
14 ---help--- 14 ---help---
15 Say Y here to enable selecting the TV output devices for 15 Say Y here to enable selecting the TV output devices for
diff --git a/drivers/media/platform/vivid/Kconfig b/drivers/media/platform/vivid/Kconfig
index d71139a2ae00..c3090932f06d 100644
--- a/drivers/media/platform/vivid/Kconfig
+++ b/drivers/media/platform/vivid/Kconfig
@@ -1,8 +1,11 @@
1config VIDEO_VIVID 1config VIDEO_VIVID
2 tristate "Virtual Video Test Driver" 2 tristate "Virtual Video Test Driver"
3 depends on VIDEO_DEV && VIDEO_V4L2 && !SPARC32 && !SPARC64 3 depends on VIDEO_DEV && VIDEO_V4L2 && !SPARC32 && !SPARC64 && FB
4 select FONT_SUPPORT 4 select FONT_SUPPORT
5 select FONT_8x16 5 select FONT_8x16
6 select FB_CFB_FILLRECT
7 select FB_CFB_COPYAREA
8 select FB_CFB_IMAGEBLIT
6 select VIDEOBUF2_VMALLOC 9 select VIDEOBUF2_VMALLOC
7 default n 10 default n
8 ---help--- 11 ---help---
diff --git a/drivers/media/platform/vivid/vivid-tpg.c b/drivers/media/platform/vivid/vivid-tpg.c
index 0c6fa53fa646..cbcd6250e7b2 100644
--- a/drivers/media/platform/vivid/vivid-tpg.c
+++ b/drivers/media/platform/vivid/vivid-tpg.c
@@ -136,7 +136,7 @@ int tpg_alloc(struct tpg_data *tpg, unsigned max_w)
136 tpg->black_line[plane] = vzalloc(max_w * pixelsz); 136 tpg->black_line[plane] = vzalloc(max_w * pixelsz);
137 if (!tpg->black_line[plane]) 137 if (!tpg->black_line[plane])
138 return -ENOMEM; 138 return -ENOMEM;
139 tpg->random_line[plane] = vzalloc(max_w * pixelsz); 139 tpg->random_line[plane] = vzalloc(max_w * 2 * pixelsz);
140 if (!tpg->random_line[plane]) 140 if (!tpg->random_line[plane])
141 return -ENOMEM; 141 return -ENOMEM;
142 } 142 }
diff --git a/drivers/media/radio/wl128x/fmdrv_common.c b/drivers/media/radio/wl128x/fmdrv_common.c
index 6f28f6e02ea5..704397f3c106 100644
--- a/drivers/media/radio/wl128x/fmdrv_common.c
+++ b/drivers/media/radio/wl128x/fmdrv_common.c
@@ -1256,7 +1256,7 @@ static int fm_download_firmware(struct fmdev *fmdev, const u8 *fw_name)
1256 fmerr("Unable to read firmware(%s) content\n", fw_name); 1256 fmerr("Unable to read firmware(%s) content\n", fw_name);
1257 return ret; 1257 return ret;
1258 } 1258 }
1259 fmdbg("Firmware(%s) length : %d bytes\n", fw_name, fw_entry->size); 1259 fmdbg("Firmware(%s) length : %zu bytes\n", fw_name, fw_entry->size);
1260 1260
1261 fw_data = (void *)fw_entry->data; 1261 fw_data = (void *)fw_entry->data;
1262 fw_len = fw_entry->size; 1262 fw_len = fw_entry->size;
diff --git a/drivers/media/tuners/xc5000.c b/drivers/media/tuners/xc5000.c
index e44c8aba6074..803a0e63d47e 100644
--- a/drivers/media/tuners/xc5000.c
+++ b/drivers/media/tuners/xc5000.c
@@ -1333,9 +1333,9 @@ static int xc5000_release(struct dvb_frontend *fe)
1333 1333
1334 if (priv) { 1334 if (priv) {
1335 cancel_delayed_work(&priv->timer_sleep); 1335 cancel_delayed_work(&priv->timer_sleep);
1336 hybrid_tuner_release_state(priv);
1337 if (priv->firmware) 1336 if (priv->firmware)
1338 release_firmware(priv->firmware); 1337 release_firmware(priv->firmware);
1338 hybrid_tuner_release_state(priv);
1339 } 1339 }
1340 1340
1341 mutex_unlock(&xc5000_list_mutex); 1341 mutex_unlock(&xc5000_list_mutex);
diff --git a/drivers/media/usb/dvb-usb-v2/af9035.c b/drivers/media/usb/dvb-usb-v2/af9035.c
index 00758c83eec7..1896ab218b11 100644
--- a/drivers/media/usb/dvb-usb-v2/af9035.c
+++ b/drivers/media/usb/dvb-usb-v2/af9035.c
@@ -193,8 +193,8 @@ static int af9035_wr_reg_mask(struct dvb_usb_device *d, u32 reg, u8 val,
193 return af9035_wr_regs(d, reg, &val, 1); 193 return af9035_wr_regs(d, reg, &val, 1);
194} 194}
195 195
196static int af9035_add_i2c_dev(struct dvb_usb_device *d, char *type, u8 addr, 196static int af9035_add_i2c_dev(struct dvb_usb_device *d, const char *type,
197 void *platform_data, struct i2c_adapter *adapter) 197 u8 addr, void *platform_data, struct i2c_adapter *adapter)
198{ 198{
199 int ret, num; 199 int ret, num;
200 struct state *state = d_to_priv(d); 200 struct state *state = d_to_priv(d);
@@ -221,7 +221,7 @@ static int af9035_add_i2c_dev(struct dvb_usb_device *d, char *type, u8 addr,
221 goto err; 221 goto err;
222 } 222 }
223 223
224 request_module(board_info.type); 224 request_module("%s", board_info.type);
225 225
226 /* register I2C device */ 226 /* register I2C device */
227 client = i2c_new_device(adapter, &board_info); 227 client = i2c_new_device(adapter, &board_info);
diff --git a/drivers/media/usb/dvb-usb-v2/anysee.c b/drivers/media/usb/dvb-usb-v2/anysee.c
index d3c5f230e97a..ae917c042a52 100644
--- a/drivers/media/usb/dvb-usb-v2/anysee.c
+++ b/drivers/media/usb/dvb-usb-v2/anysee.c
@@ -630,8 +630,8 @@ error:
630 return ret; 630 return ret;
631} 631}
632 632
633static int anysee_add_i2c_dev(struct dvb_usb_device *d, char *type, u8 addr, 633static int anysee_add_i2c_dev(struct dvb_usb_device *d, const char *type,
634 void *platform_data) 634 u8 addr, void *platform_data)
635{ 635{
636 int ret, num; 636 int ret, num;
637 struct anysee_state *state = d_to_priv(d); 637 struct anysee_state *state = d_to_priv(d);
@@ -659,7 +659,7 @@ static int anysee_add_i2c_dev(struct dvb_usb_device *d, char *type, u8 addr,
659 goto err; 659 goto err;
660 } 660 }
661 661
662 request_module(board_info.type); 662 request_module("%s", board_info.type);
663 663
664 /* register I2C device */ 664 /* register I2C device */
665 client = i2c_new_device(adapter, &board_info); 665 client = i2c_new_device(adapter, &board_info);
diff --git a/drivers/media/usb/em28xx/em28xx-core.c b/drivers/media/usb/em28xx/em28xx-core.c
index b5e52fe7957a..901cf2b952d7 100644
--- a/drivers/media/usb/em28xx/em28xx-core.c
+++ b/drivers/media/usb/em28xx/em28xx-core.c
@@ -504,7 +504,7 @@ EXPORT_SYMBOL_GPL(em28xx_audio_analog_set);
504int em28xx_audio_setup(struct em28xx *dev) 504int em28xx_audio_setup(struct em28xx *dev)
505{ 505{
506 int vid1, vid2, feat, cfg; 506 int vid1, vid2, feat, cfg;
507 u32 vid; 507 u32 vid = 0;
508 u8 i2s_samplerates; 508 u8 i2s_samplerates;
509 509
510 if (dev->chip_id == CHIP_ID_EM2870 || 510 if (dev->chip_id == CHIP_ID_EM2870 ||
diff --git a/drivers/media/usb/em28xx/em28xx-input.c b/drivers/media/usb/em28xx/em28xx-input.c
index 581f6dad4ca9..23f8f6afa2e0 100644
--- a/drivers/media/usb/em28xx/em28xx-input.c
+++ b/drivers/media/usb/em28xx/em28xx-input.c
@@ -712,8 +712,10 @@ static int em28xx_ir_init(struct em28xx *dev)
712 em28xx_info("Registering input extension\n"); 712 em28xx_info("Registering input extension\n");
713 713
714 ir = kzalloc(sizeof(*ir), GFP_KERNEL); 714 ir = kzalloc(sizeof(*ir), GFP_KERNEL);
715 if (!ir)
716 return -ENOMEM;
715 rc = rc_allocate_device(); 717 rc = rc_allocate_device();
716 if (!ir || !rc) 718 if (!rc)
717 goto error; 719 goto error;
718 720
719 /* record handles to ourself */ 721 /* record handles to ourself */
diff --git a/drivers/media/usb/hackrf/hackrf.c b/drivers/media/usb/hackrf/hackrf.c
index 328b5ba47a0a..fd1fa412e094 100644
--- a/drivers/media/usb/hackrf/hackrf.c
+++ b/drivers/media/usb/hackrf/hackrf.c
@@ -932,7 +932,7 @@ static int hackrf_set_bandwidth(struct hackrf_dev *dev)
932 dev->bandwidth->val = bandwidth; 932 dev->bandwidth->val = bandwidth;
933 dev->bandwidth->cur.val = bandwidth; 933 dev->bandwidth->cur.val = bandwidth;
934 934
935 dev_dbg(dev->dev, "bandwidth selected=%d\n", bandwidth_lut[i].freq); 935 dev_dbg(dev->dev, "bandwidth selected=%d\n", bandwidth);
936 936
937 u16tmp = 0; 937 u16tmp = 0;
938 u16tmp |= ((bandwidth >> 0) & 0xff) << 0; 938 u16tmp |= ((bandwidth >> 0) & 0xff) << 0;
diff --git a/drivers/media/usb/usbvision/usbvision-video.c b/drivers/media/usb/usbvision/usbvision-video.c
index 68bc9615660e..9bfa041e3316 100644
--- a/drivers/media/usb/usbvision/usbvision-video.c
+++ b/drivers/media/usb/usbvision/usbvision-video.c
@@ -446,6 +446,7 @@ static int usbvision_v4l2_close(struct file *file)
446 if (usbvision->remove_pending) { 446 if (usbvision->remove_pending) {
447 printk(KERN_INFO "%s: Final disconnect\n", __func__); 447 printk(KERN_INFO "%s: Final disconnect\n", __func__);
448 usbvision_release(usbvision); 448 usbvision_release(usbvision);
449 return 0;
449 } 450 }
450 mutex_unlock(&usbvision->v4l2_lock); 451 mutex_unlock(&usbvision->v4l2_lock);
451 452
@@ -1221,6 +1222,7 @@ static int usbvision_radio_close(struct file *file)
1221 if (usbvision->remove_pending) { 1222 if (usbvision->remove_pending) {
1222 printk(KERN_INFO "%s: Final disconnect\n", __func__); 1223 printk(KERN_INFO "%s: Final disconnect\n", __func__);
1223 usbvision_release(usbvision); 1224 usbvision_release(usbvision);
1225 return err_code;
1224 } 1226 }
1225 1227
1226 mutex_unlock(&usbvision->v4l2_lock); 1228 mutex_unlock(&usbvision->v4l2_lock);
diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c
index 60a8e2c3631e..378ae02e593b 100644
--- a/drivers/media/usb/uvc/uvc_v4l2.c
+++ b/drivers/media/usb/uvc/uvc_v4l2.c
@@ -318,7 +318,6 @@ static int uvc_v4l2_set_format(struct uvc_streaming *stream,
318 stream->ctrl = probe; 318 stream->ctrl = probe;
319 stream->cur_format = format; 319 stream->cur_format = format;
320 stream->cur_frame = frame; 320 stream->cur_frame = frame;
321 stream->frame_size = fmt->fmt.pix.sizeimage;
322 321
323done: 322done:
324 mutex_unlock(&stream->mutex); 323 mutex_unlock(&stream->mutex);
diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c
index 9ace520bb079..df81b9c4faf1 100644
--- a/drivers/media/usb/uvc/uvc_video.c
+++ b/drivers/media/usb/uvc/uvc_video.c
@@ -1143,7 +1143,7 @@ static int uvc_video_encode_data(struct uvc_streaming *stream,
1143static void uvc_video_validate_buffer(const struct uvc_streaming *stream, 1143static void uvc_video_validate_buffer(const struct uvc_streaming *stream,
1144 struct uvc_buffer *buf) 1144 struct uvc_buffer *buf)
1145{ 1145{
1146 if (stream->frame_size != buf->bytesused && 1146 if (stream->ctrl.dwMaxVideoFrameSize != buf->bytesused &&
1147 !(stream->cur_format->flags & UVC_FMT_FLAG_COMPRESSED)) 1147 !(stream->cur_format->flags & UVC_FMT_FLAG_COMPRESSED))
1148 buf->error = 1; 1148 buf->error = 1;
1149} 1149}
diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h
index 6f676c29ec09..864ada740360 100644
--- a/drivers/media/usb/uvc/uvcvideo.h
+++ b/drivers/media/usb/uvc/uvcvideo.h
@@ -457,7 +457,6 @@ struct uvc_streaming {
457 struct uvc_format *def_format; 457 struct uvc_format *def_format;
458 struct uvc_format *cur_format; 458 struct uvc_format *cur_format;
459 struct uvc_frame *cur_frame; 459 struct uvc_frame *cur_frame;
460 size_t frame_size;
461 460
462 /* Protect access to ctrl, cur_format, cur_frame and hardware video 461 /* Protect access to ctrl, cur_format, cur_frame and hardware video
463 * probe control. 462 * probe control.
diff --git a/drivers/media/v4l2-core/videobuf-dma-contig.c b/drivers/media/v4l2-core/videobuf-dma-contig.c
index bf80f0f7dfb8..e02353e340dd 100644
--- a/drivers/media/v4l2-core/videobuf-dma-contig.c
+++ b/drivers/media/v4l2-core/videobuf-dma-contig.c
@@ -305,6 +305,15 @@ static int __videobuf_mmap_mapper(struct videobuf_queue *q,
305 /* Try to remap memory */ 305 /* Try to remap memory */
306 size = vma->vm_end - vma->vm_start; 306 size = vma->vm_end - vma->vm_start;
307 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); 307 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
308
309 /* the "vm_pgoff" is just used in v4l2 to find the
310 * corresponding buffer data structure which is allocated
311 * earlier and it does not mean the offset from the physical
312 * buffer start address as usual. So set it to 0 to pass
313 * the sanity check in vm_iomap_memory().
314 */
315 vma->vm_pgoff = 0;
316
308 retval = vm_iomap_memory(vma, mem->dma_handle, size); 317 retval = vm_iomap_memory(vma, mem->dma_handle, size);
309 if (retval) { 318 if (retval) {
310 dev_err(q->dev, "mmap: remap failed with error %d. ", 319 dev_err(q->dev, "mmap: remap failed with error %d. ",
diff --git a/drivers/misc/cxl/fault.c b/drivers/misc/cxl/fault.c
index 69506ebd4d07..c99e896604ee 100644
--- a/drivers/misc/cxl/fault.c
+++ b/drivers/misc/cxl/fault.c
@@ -21,60 +21,64 @@
21 21
22#include "cxl.h" 22#include "cxl.h"
23 23
24static struct cxl_sste* find_free_sste(struct cxl_sste *primary_group, 24static bool sste_matches(struct cxl_sste *sste, struct copro_slb *slb)
25 bool sec_hash,
26 struct cxl_sste *secondary_group,
27 unsigned int *lru)
28{ 25{
29 unsigned int i, entry; 26 return ((sste->vsid_data == cpu_to_be64(slb->vsid)) &&
30 struct cxl_sste *sste, *group = primary_group; 27 (sste->esid_data == cpu_to_be64(slb->esid)));
31 28}
32 for (i = 0; i < 2; i++) { 29
33 for (entry = 0; entry < 8; entry++) { 30/*
34 sste = group + entry; 31 * This finds a free SSTE for the given SLB, or returns NULL if it's already in
35 if (!(be64_to_cpu(sste->esid_data) & SLB_ESID_V)) 32 * the segment table.
36 return sste; 33 */
37 } 34static struct cxl_sste* find_free_sste(struct cxl_context *ctx,
38 if (!sec_hash) 35 struct copro_slb *slb)
39 break; 36{
40 group = secondary_group; 37 struct cxl_sste *primary, *sste, *ret = NULL;
38 unsigned int mask = (ctx->sst_size >> 7) - 1; /* SSTP0[SegTableSize] */
39 unsigned int entry;
40 unsigned int hash;
41
42 if (slb->vsid & SLB_VSID_B_1T)
43 hash = (slb->esid >> SID_SHIFT_1T) & mask;
44 else /* 256M */
45 hash = (slb->esid >> SID_SHIFT) & mask;
46
47 primary = ctx->sstp + (hash << 3);
48
49 for (entry = 0, sste = primary; entry < 8; entry++, sste++) {
50 if (!ret && !(be64_to_cpu(sste->esid_data) & SLB_ESID_V))
51 ret = sste;
52 if (sste_matches(sste, slb))
53 return NULL;
41 } 54 }
55 if (ret)
56 return ret;
57
42 /* Nothing free, select an entry to cast out */ 58 /* Nothing free, select an entry to cast out */
43 if (sec_hash && (*lru & 0x8)) 59 ret = primary + ctx->sst_lru;
44 sste = secondary_group + (*lru & 0x7); 60 ctx->sst_lru = (ctx->sst_lru + 1) & 0x7;
45 else
46 sste = primary_group + (*lru & 0x7);
47 *lru = (*lru + 1) & 0xf;
48 61
49 return sste; 62 return ret;
50} 63}
51 64
52static void cxl_load_segment(struct cxl_context *ctx, struct copro_slb *slb) 65static void cxl_load_segment(struct cxl_context *ctx, struct copro_slb *slb)
53{ 66{
54 /* mask is the group index, we search primary and secondary here. */ 67 /* mask is the group index, we search primary and secondary here. */
55 unsigned int mask = (ctx->sst_size >> 7)-1; /* SSTP0[SegTableSize] */
56 bool sec_hash = 1;
57 struct cxl_sste *sste; 68 struct cxl_sste *sste;
58 unsigned int hash;
59 unsigned long flags; 69 unsigned long flags;
60 70
61
62 sec_hash = !!(cxl_p1n_read(ctx->afu, CXL_PSL_SR_An) & CXL_PSL_SR_An_SC);
63
64 if (slb->vsid & SLB_VSID_B_1T)
65 hash = (slb->esid >> SID_SHIFT_1T) & mask;
66 else /* 256M */
67 hash = (slb->esid >> SID_SHIFT) & mask;
68
69 spin_lock_irqsave(&ctx->sste_lock, flags); 71 spin_lock_irqsave(&ctx->sste_lock, flags);
70 sste = find_free_sste(ctx->sstp + (hash << 3), sec_hash, 72 sste = find_free_sste(ctx, slb);
71 ctx->sstp + ((~hash & mask) << 3), &ctx->sst_lru); 73 if (!sste)
74 goto out_unlock;
72 75
73 pr_devel("CXL Populating SST[%li]: %#llx %#llx\n", 76 pr_devel("CXL Populating SST[%li]: %#llx %#llx\n",
74 sste - ctx->sstp, slb->vsid, slb->esid); 77 sste - ctx->sstp, slb->vsid, slb->esid);
75 78
76 sste->vsid_data = cpu_to_be64(slb->vsid); 79 sste->vsid_data = cpu_to_be64(slb->vsid);
77 sste->esid_data = cpu_to_be64(slb->esid); 80 sste->esid_data = cpu_to_be64(slb->esid);
81out_unlock:
78 spin_unlock_irqrestore(&ctx->sste_lock, flags); 82 spin_unlock_irqrestore(&ctx->sste_lock, flags);
79} 83}
80 84
diff --git a/drivers/misc/cxl/native.c b/drivers/misc/cxl/native.c
index 623286a77114..d47532e8f4f1 100644
--- a/drivers/misc/cxl/native.c
+++ b/drivers/misc/cxl/native.c
@@ -417,7 +417,7 @@ static int attach_afu_directed(struct cxl_context *ctx, u64 wed, u64 amr)
417 ctx->elem->haurp = 0; /* disable */ 417 ctx->elem->haurp = 0; /* disable */
418 ctx->elem->sdr = cpu_to_be64(mfspr(SPRN_SDR1)); 418 ctx->elem->sdr = cpu_to_be64(mfspr(SPRN_SDR1));
419 419
420 sr = CXL_PSL_SR_An_SC; 420 sr = 0;
421 if (ctx->master) 421 if (ctx->master)
422 sr |= CXL_PSL_SR_An_MP; 422 sr |= CXL_PSL_SR_An_MP;
423 if (mfspr(SPRN_LPCR) & LPCR_TC) 423 if (mfspr(SPRN_LPCR) & LPCR_TC)
@@ -508,7 +508,7 @@ static int attach_dedicated(struct cxl_context *ctx, u64 wed, u64 amr)
508 u64 sr; 508 u64 sr;
509 int rc; 509 int rc;
510 510
511 sr = CXL_PSL_SR_An_SC; 511 sr = 0;
512 set_endian(sr); 512 set_endian(sr);
513 if (ctx->master) 513 if (ctx->master)
514 sr |= CXL_PSL_SR_An_MP; 514 sr |= CXL_PSL_SR_An_MP;
diff --git a/drivers/mtd/chips/cfi_cmdset_0001.c b/drivers/mtd/chips/cfi_cmdset_0001.c
index a7543ba3e190..3096f3ded3ad 100644
--- a/drivers/mtd/chips/cfi_cmdset_0001.c
+++ b/drivers/mtd/chips/cfi_cmdset_0001.c
@@ -2590,6 +2590,8 @@ static void cfi_intelext_resume(struct mtd_info *mtd)
2590 2590
2591 /* Go to known state. Chip may have been power cycled */ 2591 /* Go to known state. Chip may have been power cycled */
2592 if (chip->state == FL_PM_SUSPENDED) { 2592 if (chip->state == FL_PM_SUSPENDED) {
2593 /* Refresh LH28F640BF Partition Config. Register */
2594 fixup_LH28F640BF(mtd);
2593 map_write(map, CMD(0xFF), cfi->chips[i].start); 2595 map_write(map, CMD(0xFF), cfi->chips[i].start);
2594 chip->oldstate = chip->state = FL_READY; 2596 chip->oldstate = chip->state = FL_READY;
2595 wake_up(&chip->wq); 2597 wake_up(&chip->wq);
diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index dcda6287228d..ed827cf894e4 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -193,10 +193,10 @@ static int m25p_probe(struct spi_device *spi)
193{ 193{
194 struct mtd_part_parser_data ppdata; 194 struct mtd_part_parser_data ppdata;
195 struct flash_platform_data *data; 195 struct flash_platform_data *data;
196 const struct spi_device_id *id = NULL;
197 struct m25p *flash; 196 struct m25p *flash;
198 struct spi_nor *nor; 197 struct spi_nor *nor;
199 enum read_mode mode = SPI_NOR_NORMAL; 198 enum read_mode mode = SPI_NOR_NORMAL;
199 char *flash_name = NULL;
200 int ret; 200 int ret;
201 201
202 data = dev_get_platdata(&spi->dev); 202 data = dev_get_platdata(&spi->dev);
@@ -236,13 +236,11 @@ static int m25p_probe(struct spi_device *spi)
236 * If that's the case, respect "type" and ignore a "name". 236 * If that's the case, respect "type" and ignore a "name".
237 */ 237 */
238 if (data && data->type) 238 if (data && data->type)
239 id = spi_nor_match_id(data->type); 239 flash_name = data->type;
240 else
241 flash_name = spi->modalias;
240 242
241 /* If we didn't get name from platform, simply use "modalias". */ 243 ret = spi_nor_scan(nor, flash_name, mode);
242 if (!id)
243 id = spi_get_device_id(spi);
244
245 ret = spi_nor_scan(nor, id, mode);
246 if (ret) 244 if (ret)
247 return ret; 245 return ret;
248 246
@@ -263,12 +261,62 @@ static int m25p_remove(struct spi_device *spi)
263} 261}
264 262
265 263
264/*
265 * XXX This needs to be kept in sync with spi_nor_ids. We can't share
266 * it with spi-nor, because if this is built as a module then modpost
267 * won't be able to read it and add appropriate aliases.
268 */
269static const struct spi_device_id m25p_ids[] = {
270 {"at25fs010"}, {"at25fs040"}, {"at25df041a"}, {"at25df321a"},
271 {"at25df641"}, {"at26f004"}, {"at26df081a"}, {"at26df161a"},
272 {"at26df321"}, {"at45db081d"},
273 {"en25f32"}, {"en25p32"}, {"en25q32b"}, {"en25p64"},
274 {"en25q64"}, {"en25qh128"}, {"en25qh256"},
275 {"f25l32pa"},
276 {"mr25h256"}, {"mr25h10"},
277 {"gd25q32"}, {"gd25q64"},
278 {"160s33b"}, {"320s33b"}, {"640s33b"},
279 {"mx25l2005a"}, {"mx25l4005a"}, {"mx25l8005"}, {"mx25l1606e"},
280 {"mx25l3205d"}, {"mx25l3255e"}, {"mx25l6405d"}, {"mx25l12805d"},
281 {"mx25l12855e"},{"mx25l25635e"},{"mx25l25655e"},{"mx66l51235l"},
282 {"mx66l1g55g"},
283 {"n25q064"}, {"n25q128a11"}, {"n25q128a13"}, {"n25q256a"},
284 {"n25q512a"}, {"n25q512ax3"}, {"n25q00"},
285 {"pm25lv512"}, {"pm25lv010"}, {"pm25lq032"},
286 {"s25sl032p"}, {"s25sl064p"}, {"s25fl256s0"}, {"s25fl256s1"},
287 {"s25fl512s"}, {"s70fl01gs"}, {"s25sl12800"}, {"s25sl12801"},
288 {"s25fl129p0"}, {"s25fl129p1"}, {"s25sl004a"}, {"s25sl008a"},
289 {"s25sl016a"}, {"s25sl032a"}, {"s25sl064a"}, {"s25fl008k"},
290 {"s25fl016k"}, {"s25fl064k"},
291 {"sst25vf040b"},{"sst25vf080b"},{"sst25vf016b"},{"sst25vf032b"},
292 {"sst25vf064c"},{"sst25wf512"}, {"sst25wf010"}, {"sst25wf020"},
293 {"sst25wf040"},
294 {"m25p05"}, {"m25p10"}, {"m25p20"}, {"m25p40"},
295 {"m25p80"}, {"m25p16"}, {"m25p32"}, {"m25p64"},
296 {"m25p128"}, {"n25q032"},
297 {"m25p05-nonjedec"}, {"m25p10-nonjedec"}, {"m25p20-nonjedec"},
298 {"m25p40-nonjedec"}, {"m25p80-nonjedec"}, {"m25p16-nonjedec"},
299 {"m25p32-nonjedec"}, {"m25p64-nonjedec"}, {"m25p128-nonjedec"},
300 {"m45pe10"}, {"m45pe80"}, {"m45pe16"},
301 {"m25pe20"}, {"m25pe80"}, {"m25pe16"},
302 {"m25px16"}, {"m25px32"}, {"m25px32-s0"}, {"m25px32-s1"},
303 {"m25px64"},
304 {"w25x10"}, {"w25x20"}, {"w25x40"}, {"w25x80"},
305 {"w25x16"}, {"w25x32"}, {"w25q32"}, {"w25q32dw"},
306 {"w25x64"}, {"w25q64"}, {"w25q128"}, {"w25q80"},
307 {"w25q80bl"}, {"w25q128"}, {"w25q256"}, {"cat25c11"},
308 {"cat25c03"}, {"cat25c09"}, {"cat25c17"}, {"cat25128"},
309 { },
310};
311MODULE_DEVICE_TABLE(spi, m25p_ids);
312
313
266static struct spi_driver m25p80_driver = { 314static struct spi_driver m25p80_driver = {
267 .driver = { 315 .driver = {
268 .name = "m25p80", 316 .name = "m25p80",
269 .owner = THIS_MODULE, 317 .owner = THIS_MODULE,
270 }, 318 },
271 .id_table = spi_nor_ids, 319 .id_table = m25p_ids,
272 .probe = m25p_probe, 320 .probe = m25p_probe,
273 .remove = m25p_remove, 321 .remove = m25p_remove,
274 322
diff --git a/drivers/mtd/nand/omap_elm.c b/drivers/mtd/nand/omap_elm.c
index b4f61c7fc161..058531044ceb 100644
--- a/drivers/mtd/nand/omap_elm.c
+++ b/drivers/mtd/nand/omap_elm.c
@@ -115,7 +115,7 @@ int elm_config(struct device *dev, enum bch_ecc bch_type,
115 115
116 if (!info) { 116 if (!info) {
117 dev_err(dev, "Unable to configure elm - device not probed?\n"); 117 dev_err(dev, "Unable to configure elm - device not probed?\n");
118 return -ENODEV; 118 return -EPROBE_DEFER;
119 } 119 }
120 /* ELM cannot detect ECC errors for chunks > 1KB */ 120 /* ELM cannot detect ECC errors for chunks > 1KB */
121 if (ecc_step_size > ((ELM_ECC_SIZE + 1) / 2)) { 121 if (ecc_step_size > ((ELM_ECC_SIZE + 1) / 2)) {
diff --git a/drivers/mtd/spi-nor/fsl-quadspi.c b/drivers/mtd/spi-nor/fsl-quadspi.c
index 8d659a2888d5..d5269a26c839 100644
--- a/drivers/mtd/spi-nor/fsl-quadspi.c
+++ b/drivers/mtd/spi-nor/fsl-quadspi.c
@@ -881,7 +881,6 @@ static int fsl_qspi_probe(struct platform_device *pdev)
881 881
882 /* iterate the subnodes. */ 882 /* iterate the subnodes. */
883 for_each_available_child_of_node(dev->of_node, np) { 883 for_each_available_child_of_node(dev->of_node, np) {
884 const struct spi_device_id *id;
885 char modalias[40]; 884 char modalias[40];
886 885
887 /* skip the holes */ 886 /* skip the holes */
@@ -909,10 +908,6 @@ static int fsl_qspi_probe(struct platform_device *pdev)
909 if (of_modalias_node(np, modalias, sizeof(modalias)) < 0) 908 if (of_modalias_node(np, modalias, sizeof(modalias)) < 0)
910 goto map_failed; 909 goto map_failed;
911 910
912 id = spi_nor_match_id(modalias);
913 if (!id)
914 goto map_failed;
915
916 ret = of_property_read_u32(np, "spi-max-frequency", 911 ret = of_property_read_u32(np, "spi-max-frequency",
917 &q->clk_rate); 912 &q->clk_rate);
918 if (ret < 0) 913 if (ret < 0)
@@ -921,7 +916,7 @@ static int fsl_qspi_probe(struct platform_device *pdev)
921 /* set the chip address for READID */ 916 /* set the chip address for READID */
922 fsl_qspi_set_base_addr(q, nor); 917 fsl_qspi_set_base_addr(q, nor);
923 918
924 ret = spi_nor_scan(nor, id, SPI_NOR_QUAD); 919 ret = spi_nor_scan(nor, modalias, SPI_NOR_QUAD);
925 if (ret) 920 if (ret)
926 goto map_failed; 921 goto map_failed;
927 922
diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index ae16aa2f6885..c51ee52386a7 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -28,6 +28,8 @@
28 28
29#define JEDEC_MFR(_jedec_id) ((_jedec_id) >> 16) 29#define JEDEC_MFR(_jedec_id) ((_jedec_id) >> 16)
30 30
31static const struct spi_device_id *spi_nor_match_id(const char *name);
32
31/* 33/*
32 * Read the status register, returning its value in the location 34 * Read the status register, returning its value in the location
33 * Return the status register value. 35 * Return the status register value.
@@ -473,7 +475,7 @@ struct flash_info {
473 * more nor chips. This current list focusses on newer chips, which 475 * more nor chips. This current list focusses on newer chips, which
474 * have been converging on command sets which including JEDEC ID. 476 * have been converging on command sets which including JEDEC ID.
475 */ 477 */
476const struct spi_device_id spi_nor_ids[] = { 478static const struct spi_device_id spi_nor_ids[] = {
477 /* Atmel -- some are (confusingly) marketed as "DataFlash" */ 479 /* Atmel -- some are (confusingly) marketed as "DataFlash" */
478 { "at25fs010", INFO(0x1f6601, 0, 32 * 1024, 4, SECT_4K) }, 480 { "at25fs010", INFO(0x1f6601, 0, 32 * 1024, 4, SECT_4K) },
479 { "at25fs040", INFO(0x1f6604, 0, 64 * 1024, 8, SECT_4K) }, 481 { "at25fs040", INFO(0x1f6604, 0, 64 * 1024, 8, SECT_4K) },
@@ -637,7 +639,6 @@ const struct spi_device_id spi_nor_ids[] = {
637 { "cat25128", CAT25_INFO(2048, 8, 64, 2, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR) }, 639 { "cat25128", CAT25_INFO(2048, 8, 64, 2, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR) },
638 { }, 640 { },
639}; 641};
640EXPORT_SYMBOL_GPL(spi_nor_ids);
641 642
642static const struct spi_device_id *spi_nor_read_id(struct spi_nor *nor) 643static const struct spi_device_id *spi_nor_read_id(struct spi_nor *nor)
643{ 644{
@@ -911,9 +912,9 @@ static int spi_nor_check(struct spi_nor *nor)
911 return 0; 912 return 0;
912} 913}
913 914
914int spi_nor_scan(struct spi_nor *nor, const struct spi_device_id *id, 915int spi_nor_scan(struct spi_nor *nor, const char *name, enum read_mode mode)
915 enum read_mode mode)
916{ 916{
917 const struct spi_device_id *id = NULL;
917 struct flash_info *info; 918 struct flash_info *info;
918 struct device *dev = nor->dev; 919 struct device *dev = nor->dev;
919 struct mtd_info *mtd = nor->mtd; 920 struct mtd_info *mtd = nor->mtd;
@@ -925,6 +926,10 @@ int spi_nor_scan(struct spi_nor *nor, const struct spi_device_id *id,
925 if (ret) 926 if (ret)
926 return ret; 927 return ret;
927 928
929 id = spi_nor_match_id(name);
930 if (!id)
931 return -ENOENT;
932
928 info = (void *)id->driver_data; 933 info = (void *)id->driver_data;
929 934
930 if (info->jedec_id) { 935 if (info->jedec_id) {
@@ -1113,7 +1118,7 @@ int spi_nor_scan(struct spi_nor *nor, const struct spi_device_id *id,
1113} 1118}
1114EXPORT_SYMBOL_GPL(spi_nor_scan); 1119EXPORT_SYMBOL_GPL(spi_nor_scan);
1115 1120
1116const struct spi_device_id *spi_nor_match_id(char *name) 1121static const struct spi_device_id *spi_nor_match_id(const char *name)
1117{ 1122{
1118 const struct spi_device_id *id = spi_nor_ids; 1123 const struct spi_device_id *id = spi_nor_ids;
1119 1124
@@ -1124,7 +1129,6 @@ const struct spi_device_id *spi_nor_match_id(char *name)
1124 } 1129 }
1125 return NULL; 1130 return NULL;
1126} 1131}
1127EXPORT_SYMBOL_GPL(spi_nor_match_id);
1128 1132
1129MODULE_LICENSE("GPL"); 1133MODULE_LICENSE("GPL");
1130MODULE_AUTHOR("Huang Shijie <shijie8@gmail.com>"); 1134MODULE_AUTHOR("Huang Shijie <shijie8@gmail.com>");
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 4706386b7d34..f9009be3f307 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -135,6 +135,7 @@ config MACVLAN
135config MACVTAP 135config MACVTAP
136 tristate "MAC-VLAN based tap driver" 136 tristate "MAC-VLAN based tap driver"
137 depends on MACVLAN 137 depends on MACVLAN
138 depends on INET
138 help 139 help
139 This adds a specialized tap character device driver that is based 140 This adds a specialized tap character device driver that is based
140 on the MAC-VLAN network interface, called macvtap. A macvtap device 141 on the MAC-VLAN network interface, called macvtap. A macvtap device
@@ -200,6 +201,7 @@ config RIONET_RX_SIZE
200 201
201config TUN 202config TUN
202 tristate "Universal TUN/TAP device driver support" 203 tristate "Universal TUN/TAP device driver support"
204 depends on INET
203 select CRC32 205 select CRC32
204 ---help--- 206 ---help---
205 TUN/TAP provides packet reception and transmission for user space 207 TUN/TAP provides packet reception and transmission for user space
diff --git a/drivers/net/dsa/mv88e6171.c b/drivers/net/dsa/mv88e6171.c
index 1020a7af67cf..78d8e876f3aa 100644
--- a/drivers/net/dsa/mv88e6171.c
+++ b/drivers/net/dsa/mv88e6171.c
@@ -395,7 +395,7 @@ static int mv88e6171_get_sset_count(struct dsa_switch *ds)
395} 395}
396 396
397struct dsa_switch_driver mv88e6171_switch_driver = { 397struct dsa_switch_driver mv88e6171_switch_driver = {
398 .tag_protocol = DSA_TAG_PROTO_DSA, 398 .tag_protocol = DSA_TAG_PROTO_EDSA,
399 .priv_size = sizeof(struct mv88e6xxx_priv_state), 399 .priv_size = sizeof(struct mv88e6xxx_priv_state),
400 .probe = mv88e6171_probe, 400 .probe = mv88e6171_probe,
401 .setup = mv88e6171_setup, 401 .setup = mv88e6171_setup,
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
index 29554992215a..2349ea970255 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
@@ -1465,7 +1465,7 @@ static int xgbe_set_features(struct net_device *netdev,
1465{ 1465{
1466 struct xgbe_prv_data *pdata = netdev_priv(netdev); 1466 struct xgbe_prv_data *pdata = netdev_priv(netdev);
1467 struct xgbe_hw_if *hw_if = &pdata->hw_if; 1467 struct xgbe_hw_if *hw_if = &pdata->hw_if;
1468 unsigned int rxcsum, rxvlan, rxvlan_filter; 1468 netdev_features_t rxcsum, rxvlan, rxvlan_filter;
1469 1469
1470 rxcsum = pdata->netdev_features & NETIF_F_RXCSUM; 1470 rxcsum = pdata->netdev_features & NETIF_F_RXCSUM;
1471 rxvlan = pdata->netdev_features & NETIF_F_HW_VLAN_CTAG_RX; 1471 rxvlan = pdata->netdev_features & NETIF_F_HW_VLAN_CTAG_RX;
@@ -1598,7 +1598,8 @@ static int xgbe_rx_poll(struct xgbe_channel *channel, int budget)
1598 struct skb_shared_hwtstamps *hwtstamps; 1598 struct skb_shared_hwtstamps *hwtstamps;
1599 unsigned int incomplete, error, context_next, context; 1599 unsigned int incomplete, error, context_next, context;
1600 unsigned int len, put_len, max_len; 1600 unsigned int len, put_len, max_len;
1601 int received = 0; 1601 unsigned int received = 0;
1602 int packet_count = 0;
1602 1603
1603 DBGPR("-->xgbe_rx_poll: budget=%d\n", budget); 1604 DBGPR("-->xgbe_rx_poll: budget=%d\n", budget);
1604 1605
@@ -1608,7 +1609,7 @@ static int xgbe_rx_poll(struct xgbe_channel *channel, int budget)
1608 1609
1609 rdata = XGBE_GET_DESC_DATA(ring, ring->cur); 1610 rdata = XGBE_GET_DESC_DATA(ring, ring->cur);
1610 packet = &ring->packet_data; 1611 packet = &ring->packet_data;
1611 while (received < budget) { 1612 while (packet_count < budget) {
1612 DBGPR(" cur = %d\n", ring->cur); 1613 DBGPR(" cur = %d\n", ring->cur);
1613 1614
1614 /* First time in loop see if we need to restore state */ 1615 /* First time in loop see if we need to restore state */
@@ -1662,7 +1663,7 @@ read_again:
1662 if (packet->errors) 1663 if (packet->errors)
1663 DBGPR("Error in received packet\n"); 1664 DBGPR("Error in received packet\n");
1664 dev_kfree_skb(skb); 1665 dev_kfree_skb(skb);
1665 continue; 1666 goto next_packet;
1666 } 1667 }
1667 1668
1668 if (!context) { 1669 if (!context) {
@@ -1677,7 +1678,7 @@ read_again:
1677 } 1678 }
1678 1679
1679 dev_kfree_skb(skb); 1680 dev_kfree_skb(skb);
1680 continue; 1681 goto next_packet;
1681 } 1682 }
1682 memcpy(skb_tail_pointer(skb), rdata->skb->data, 1683 memcpy(skb_tail_pointer(skb), rdata->skb->data,
1683 put_len); 1684 put_len);
@@ -1694,7 +1695,7 @@ read_again:
1694 1695
1695 /* Stray Context Descriptor? */ 1696 /* Stray Context Descriptor? */
1696 if (!skb) 1697 if (!skb)
1697 continue; 1698 goto next_packet;
1698 1699
1699 /* Be sure we don't exceed the configured MTU */ 1700 /* Be sure we don't exceed the configured MTU */
1700 max_len = netdev->mtu + ETH_HLEN; 1701 max_len = netdev->mtu + ETH_HLEN;
@@ -1705,7 +1706,7 @@ read_again:
1705 if (skb->len > max_len) { 1706 if (skb->len > max_len) {
1706 DBGPR("packet length exceeds configured MTU\n"); 1707 DBGPR("packet length exceeds configured MTU\n");
1707 dev_kfree_skb(skb); 1708 dev_kfree_skb(skb);
1708 continue; 1709 goto next_packet;
1709 } 1710 }
1710 1711
1711#ifdef XGMAC_ENABLE_RX_PKT_DUMP 1712#ifdef XGMAC_ENABLE_RX_PKT_DUMP
@@ -1739,6 +1740,9 @@ read_again:
1739 1740
1740 netdev->last_rx = jiffies; 1741 netdev->last_rx = jiffies;
1741 napi_gro_receive(&pdata->napi, skb); 1742 napi_gro_receive(&pdata->napi, skb);
1743
1744next_packet:
1745 packet_count++;
1742 } 1746 }
1743 1747
1744 /* Check if we need to save state before leaving */ 1748 /* Check if we need to save state before leaving */
@@ -1752,9 +1756,9 @@ read_again:
1752 rdata->state.error = error; 1756 rdata->state.error = error;
1753 } 1757 }
1754 1758
1755 DBGPR("<--xgbe_rx_poll: received = %d\n", received); 1759 DBGPR("<--xgbe_rx_poll: packet_count = %d\n", packet_count);
1756 1760
1757 return received; 1761 return packet_count;
1758} 1762}
1759 1763
1760static int xgbe_poll(struct napi_struct *napi, int budget) 1764static int xgbe_poll(struct napi_struct *napi, int budget)
diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_sgmac.c b/drivers/net/ethernet/apm/xgene/xgene_enet_sgmac.c
index e6d24c210198..c22f32622fa9 100644
--- a/drivers/net/ethernet/apm/xgene/xgene_enet_sgmac.c
+++ b/drivers/net/ethernet/apm/xgene/xgene_enet_sgmac.c
@@ -124,20 +124,18 @@ static int xgene_enet_ecc_init(struct xgene_enet_pdata *p)
124{ 124{
125 struct net_device *ndev = p->ndev; 125 struct net_device *ndev = p->ndev;
126 u32 data; 126 u32 data;
127 int i; 127 int i = 0;
128 128
129 xgene_enet_wr_diag_csr(p, ENET_CFG_MEM_RAM_SHUTDOWN_ADDR, 0); 129 xgene_enet_wr_diag_csr(p, ENET_CFG_MEM_RAM_SHUTDOWN_ADDR, 0);
130 for (i = 0; i < 10 && data != ~0U ; i++) { 130 do {
131 usleep_range(100, 110); 131 usleep_range(100, 110);
132 data = xgene_enet_rd_diag_csr(p, ENET_BLOCK_MEM_RDY_ADDR); 132 data = xgene_enet_rd_diag_csr(p, ENET_BLOCK_MEM_RDY_ADDR);
133 } 133 if (data == ~0U)
134 return 0;
135 } while (++i < 10);
134 136
135 if (data != ~0U) { 137 netdev_err(ndev, "Failed to release memory from shutdown\n");
136 netdev_err(ndev, "Failed to release memory from shutdown\n"); 138 return -ENODEV;
137 return -ENODEV;
138 }
139
140 return 0;
141} 139}
142 140
143static void xgene_enet_config_ring_if_assoc(struct xgene_enet_pdata *p) 141static void xgene_enet_config_ring_if_assoc(struct xgene_enet_pdata *p)
diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c
index 9ae36979bdee..3a6778a667f4 100644
--- a/drivers/net/ethernet/broadcom/bcmsysport.c
+++ b/drivers/net/ethernet/broadcom/bcmsysport.c
@@ -1397,6 +1397,9 @@ static void bcm_sysport_netif_start(struct net_device *dev)
1397 /* Enable NAPI */ 1397 /* Enable NAPI */
1398 napi_enable(&priv->napi); 1398 napi_enable(&priv->napi);
1399 1399
1400 /* Enable RX interrupt and TX ring full interrupt */
1401 intrl2_0_mask_clear(priv, INTRL2_0_RDMA_MBDONE | INTRL2_0_TX_RING_FULL);
1402
1400 phy_start(priv->phydev); 1403 phy_start(priv->phydev);
1401 1404
1402 /* Enable TX interrupts for the 32 TXQs */ 1405 /* Enable TX interrupts for the 32 TXQs */
@@ -1499,9 +1502,6 @@ static int bcm_sysport_open(struct net_device *dev)
1499 if (ret) 1502 if (ret)
1500 goto out_free_rx_ring; 1503 goto out_free_rx_ring;
1501 1504
1502 /* Enable RX interrupt and TX ring full interrupt */
1503 intrl2_0_mask_clear(priv, INTRL2_0_RDMA_MBDONE | INTRL2_0_TX_RING_FULL);
1504
1505 /* Turn on TDMA */ 1505 /* Turn on TDMA */
1506 ret = tdma_enable_set(priv, 1); 1506 ret = tdma_enable_set(priv, 1);
1507 if (ret) 1507 if (ret)
@@ -1858,6 +1858,8 @@ static int bcm_sysport_resume(struct device *d)
1858 if (!netif_running(dev)) 1858 if (!netif_running(dev))
1859 return 0; 1859 return 0;
1860 1860
1861 umac_reset(priv);
1862
1861 /* We may have been suspended and never received a WOL event that 1863 /* We may have been suspended and never received a WOL event that
1862 * would turn off MPD detection, take care of that now 1864 * would turn off MPD detection, take care of that now
1863 */ 1865 */
@@ -1885,9 +1887,6 @@ static int bcm_sysport_resume(struct device *d)
1885 1887
1886 netif_device_attach(dev); 1888 netif_device_attach(dev);
1887 1889
1888 /* Enable RX interrupt and TX ring full interrupt */
1889 intrl2_0_mask_clear(priv, INTRL2_0_RDMA_MBDONE | INTRL2_0_TX_RING_FULL);
1890
1891 /* RX pipe enable */ 1890 /* RX pipe enable */
1892 topctrl_writel(priv, 0, RX_FLUSH_CNTL); 1891 topctrl_writel(priv, 0, RX_FLUSH_CNTL);
1893 1892
diff --git a/drivers/net/ethernet/broadcom/cnic.c b/drivers/net/ethernet/broadcom/cnic.c
index 23f23c97c2ad..f05fab65d78a 100644
--- a/drivers/net/ethernet/broadcom/cnic.c
+++ b/drivers/net/ethernet/broadcom/cnic.c
@@ -382,10 +382,8 @@ static int cnic_iscsi_nl_msg_recv(struct cnic_dev *dev, u32 msg_type,
382 if (l5_cid >= MAX_CM_SK_TBL_SZ) 382 if (l5_cid >= MAX_CM_SK_TBL_SZ)
383 break; 383 break;
384 384
385 rcu_read_lock();
386 if (!rcu_access_pointer(cp->ulp_ops[CNIC_ULP_L4])) { 385 if (!rcu_access_pointer(cp->ulp_ops[CNIC_ULP_L4])) {
387 rc = -ENODEV; 386 rc = -ENODEV;
388 rcu_read_unlock();
389 break; 387 break;
390 } 388 }
391 csk = &cp->csk_tbl[l5_cid]; 389 csk = &cp->csk_tbl[l5_cid];
@@ -414,7 +412,6 @@ static int cnic_iscsi_nl_msg_recv(struct cnic_dev *dev, u32 msg_type,
414 } 412 }
415 } 413 }
416 csk_put(csk); 414 csk_put(csk);
417 rcu_read_unlock();
418 rc = 0; 415 rc = 0;
419 } 416 }
420 } 417 }
@@ -615,7 +612,7 @@ static int cnic_unregister_device(struct cnic_dev *dev, int ulp_type)
615 cnic_send_nlmsg(cp, ISCSI_KEVENT_IF_DOWN, NULL); 612 cnic_send_nlmsg(cp, ISCSI_KEVENT_IF_DOWN, NULL);
616 613
617 mutex_lock(&cnic_lock); 614 mutex_lock(&cnic_lock);
618 if (rcu_dereference(cp->ulp_ops[ulp_type])) { 615 if (rcu_access_pointer(cp->ulp_ops[ulp_type])) {
619 RCU_INIT_POINTER(cp->ulp_ops[ulp_type], NULL); 616 RCU_INIT_POINTER(cp->ulp_ops[ulp_type], NULL);
620 cnic_put(dev); 617 cnic_put(dev);
621 } else { 618 } else {
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.c
index 8edf0f5bd679..6fe300e316c3 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.c
@@ -60,6 +60,42 @@ void cxgb4_dcb_version_init(struct net_device *dev)
60 dcb->dcb_version = FW_PORT_DCB_VER_AUTO; 60 dcb->dcb_version = FW_PORT_DCB_VER_AUTO;
61} 61}
62 62
63static void cxgb4_dcb_cleanup_apps(struct net_device *dev)
64{
65 struct port_info *pi = netdev2pinfo(dev);
66 struct adapter *adap = pi->adapter;
67 struct port_dcb_info *dcb = &pi->dcb;
68 struct dcb_app app;
69 int i, err;
70
71 /* zero priority implies remove */
72 app.priority = 0;
73
74 for (i = 0; i < CXGB4_MAX_DCBX_APP_SUPPORTED; i++) {
75 /* Check if app list is exhausted */
76 if (!dcb->app_priority[i].protocolid)
77 break;
78
79 app.protocol = dcb->app_priority[i].protocolid;
80
81 if (dcb->dcb_version == FW_PORT_DCB_VER_IEEE) {
82 app.selector = dcb->app_priority[i].sel_field + 1;
83 err = dcb_ieee_setapp(dev, &app);
84 } else {
85 app.selector = !!(dcb->app_priority[i].sel_field);
86 err = dcb_setapp(dev, &app);
87 }
88
89 if (err) {
90 dev_err(adap->pdev_dev,
91 "Failed DCB Clear %s Application Priority: sel=%d, prot=%d, , err=%d\n",
92 dcb_ver_array[dcb->dcb_version], app.selector,
93 app.protocol, -err);
94 break;
95 }
96 }
97}
98
63/* Finite State machine for Data Center Bridging. 99/* Finite State machine for Data Center Bridging.
64 */ 100 */
65void cxgb4_dcb_state_fsm(struct net_device *dev, 101void cxgb4_dcb_state_fsm(struct net_device *dev,
@@ -80,7 +116,6 @@ void cxgb4_dcb_state_fsm(struct net_device *dev,
80 /* we're going to use Host DCB */ 116 /* we're going to use Host DCB */
81 dcb->state = CXGB4_DCB_STATE_HOST; 117 dcb->state = CXGB4_DCB_STATE_HOST;
82 dcb->supported = CXGB4_DCBX_HOST_SUPPORT; 118 dcb->supported = CXGB4_DCBX_HOST_SUPPORT;
83 dcb->enabled = 1;
84 break; 119 break;
85 } 120 }
86 121
@@ -145,6 +180,7 @@ void cxgb4_dcb_state_fsm(struct net_device *dev,
145 * state. We need to reset back to a ground state 180 * state. We need to reset back to a ground state
146 * of incomplete. 181 * of incomplete.
147 */ 182 */
183 cxgb4_dcb_cleanup_apps(dev);
148 cxgb4_dcb_state_init(dev); 184 cxgb4_dcb_state_init(dev);
149 dcb->state = CXGB4_DCB_STATE_FW_INCOMPLETE; 185 dcb->state = CXGB4_DCB_STATE_FW_INCOMPLETE;
150 dcb->supported = CXGB4_DCBX_FW_SUPPORT; 186 dcb->supported = CXGB4_DCBX_FW_SUPPORT;
@@ -349,6 +385,12 @@ static u8 cxgb4_setstate(struct net_device *dev, u8 enabled)
349{ 385{
350 struct port_info *pi = netdev2pinfo(dev); 386 struct port_info *pi = netdev2pinfo(dev);
351 387
388 /* If DCBx is host-managed, dcb is enabled by outside lldp agents */
389 if (pi->dcb.state == CXGB4_DCB_STATE_HOST) {
390 pi->dcb.enabled = enabled;
391 return 0;
392 }
393
352 /* Firmware doesn't provide any mechanism to control the DCB state. 394 /* Firmware doesn't provide any mechanism to control the DCB state.
353 */ 395 */
354 if (enabled != (pi->dcb.state == CXGB4_DCB_STATE_FW_ALLSYNCED)) 396 if (enabled != (pi->dcb.state == CXGB4_DCB_STATE_FW_ALLSYNCED))
@@ -833,11 +875,16 @@ static int cxgb4_setapp(struct net_device *dev, u8 app_idtype, u16 app_id,
833 875
834/* Return whether IEEE Data Center Bridging has been negotiated. 876/* Return whether IEEE Data Center Bridging has been negotiated.
835 */ 877 */
836static inline int cxgb4_ieee_negotiation_complete(struct net_device *dev) 878static inline int
879cxgb4_ieee_negotiation_complete(struct net_device *dev,
880 enum cxgb4_dcb_fw_msgs dcb_subtype)
837{ 881{
838 struct port_info *pi = netdev2pinfo(dev); 882 struct port_info *pi = netdev2pinfo(dev);
839 struct port_dcb_info *dcb = &pi->dcb; 883 struct port_dcb_info *dcb = &pi->dcb;
840 884
885 if (dcb_subtype && !(dcb->msgs & dcb_subtype))
886 return 0;
887
841 return (dcb->state == CXGB4_DCB_STATE_FW_ALLSYNCED && 888 return (dcb->state == CXGB4_DCB_STATE_FW_ALLSYNCED &&
842 (dcb->supported & DCB_CAP_DCBX_VER_IEEE)); 889 (dcb->supported & DCB_CAP_DCBX_VER_IEEE));
843} 890}
@@ -850,7 +897,7 @@ static int cxgb4_ieee_getapp(struct net_device *dev, struct dcb_app *app)
850{ 897{
851 int prio; 898 int prio;
852 899
853 if (!cxgb4_ieee_negotiation_complete(dev)) 900 if (!cxgb4_ieee_negotiation_complete(dev, CXGB4_DCB_FW_APP_ID))
854 return -EINVAL; 901 return -EINVAL;
855 if (!(app->selector && app->protocol)) 902 if (!(app->selector && app->protocol))
856 return -EINVAL; 903 return -EINVAL;
@@ -872,7 +919,7 @@ static int cxgb4_ieee_setapp(struct net_device *dev, struct dcb_app *app)
872{ 919{
873 int ret; 920 int ret;
874 921
875 if (!cxgb4_ieee_negotiation_complete(dev)) 922 if (!cxgb4_ieee_negotiation_complete(dev, CXGB4_DCB_FW_APP_ID))
876 return -EINVAL; 923 return -EINVAL;
877 if (!(app->selector && app->protocol)) 924 if (!(app->selector && app->protocol))
878 return -EINVAL; 925 return -EINVAL;
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 3f60070f2519..8520d5529df8 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -694,7 +694,11 @@ int cxgb4_dcb_enabled(const struct net_device *dev)
694#ifdef CONFIG_CHELSIO_T4_DCB 694#ifdef CONFIG_CHELSIO_T4_DCB
695 struct port_info *pi = netdev_priv(dev); 695 struct port_info *pi = netdev_priv(dev);
696 696
697 return pi->dcb.state == CXGB4_DCB_STATE_FW_ALLSYNCED; 697 if (!pi->dcb.enabled)
698 return 0;
699
700 return ((pi->dcb.state == CXGB4_DCB_STATE_FW_ALLSYNCED) ||
701 (pi->dcb.state == CXGB4_DCB_STATE_HOST));
698#else 702#else
699 return 0; 703 return 0;
700#endif 704#endif
@@ -6610,6 +6614,7 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
6610 6614
6611 spin_lock_init(&adapter->stats_lock); 6615 spin_lock_init(&adapter->stats_lock);
6612 spin_lock_init(&adapter->tid_release_lock); 6616 spin_lock_init(&adapter->tid_release_lock);
6617 spin_lock_init(&adapter->win0_lock);
6613 6618
6614 INIT_WORK(&adapter->tid_release_task, process_tid_release_list); 6619 INIT_WORK(&adapter->tid_release_task, process_tid_release_list);
6615 INIT_WORK(&adapter->db_full_task, process_db_full); 6620 INIT_WORK(&adapter->db_full_task, process_db_full);
diff --git a/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c b/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
index bfa398d91826..0b42bddaf284 100644
--- a/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
@@ -2929,14 +2929,14 @@ static const struct pci_device_id cxgb4vf_pci_tbl[] = {
2929 CH_DEVICE(0x480d), /* T480-cr */ 2929 CH_DEVICE(0x480d), /* T480-cr */
2930 CH_DEVICE(0x480e), /* T440-lp-cr */ 2930 CH_DEVICE(0x480e), /* T440-lp-cr */
2931 CH_DEVICE(0x4880), 2931 CH_DEVICE(0x4880),
2932 CH_DEVICE(0x4880), 2932 CH_DEVICE(0x4881),
2933 CH_DEVICE(0x4880), 2933 CH_DEVICE(0x4882),
2934 CH_DEVICE(0x4880), 2934 CH_DEVICE(0x4883),
2935 CH_DEVICE(0x4880), 2935 CH_DEVICE(0x4884),
2936 CH_DEVICE(0x4880), 2936 CH_DEVICE(0x4885),
2937 CH_DEVICE(0x4880), 2937 CH_DEVICE(0x4886),
2938 CH_DEVICE(0x4880), 2938 CH_DEVICE(0x4887),
2939 CH_DEVICE(0x4880), 2939 CH_DEVICE(0x4888),
2940 CH_DEVICE(0x5801), /* T520-cr */ 2940 CH_DEVICE(0x5801), /* T520-cr */
2941 CH_DEVICE(0x5802), /* T522-cr */ 2941 CH_DEVICE(0x5802), /* T522-cr */
2942 CH_DEVICE(0x5803), /* T540-cr */ 2942 CH_DEVICE(0x5803), /* T540-cr */
diff --git a/drivers/net/ethernet/cisco/enic/enic_clsf.c b/drivers/net/ethernet/cisco/enic/enic_clsf.c
index 69dfd3c9e529..0be6850be8a2 100644
--- a/drivers/net/ethernet/cisco/enic/enic_clsf.c
+++ b/drivers/net/ethernet/cisco/enic/enic_clsf.c
@@ -86,7 +86,7 @@ void enic_rfs_flw_tbl_free(struct enic *enic)
86 int i; 86 int i;
87 87
88 enic_rfs_timer_stop(enic); 88 enic_rfs_timer_stop(enic);
89 spin_lock(&enic->rfs_h.lock); 89 spin_lock_bh(&enic->rfs_h.lock);
90 enic->rfs_h.free = 0; 90 enic->rfs_h.free = 0;
91 for (i = 0; i < (1 << ENIC_RFS_FLW_BITSHIFT); i++) { 91 for (i = 0; i < (1 << ENIC_RFS_FLW_BITSHIFT); i++) {
92 struct hlist_head *hhead; 92 struct hlist_head *hhead;
@@ -100,7 +100,7 @@ void enic_rfs_flw_tbl_free(struct enic *enic)
100 kfree(n); 100 kfree(n);
101 } 101 }
102 } 102 }
103 spin_unlock(&enic->rfs_h.lock); 103 spin_unlock_bh(&enic->rfs_h.lock);
104} 104}
105 105
106struct enic_rfs_fltr_node *htbl_fltr_search(struct enic *enic, u16 fltr_id) 106struct enic_rfs_fltr_node *htbl_fltr_search(struct enic *enic, u16 fltr_id)
@@ -128,7 +128,7 @@ void enic_flow_may_expire(unsigned long data)
128 bool res; 128 bool res;
129 int j; 129 int j;
130 130
131 spin_lock(&enic->rfs_h.lock); 131 spin_lock_bh(&enic->rfs_h.lock);
132 for (j = 0; j < ENIC_CLSF_EXPIRE_COUNT; j++) { 132 for (j = 0; j < ENIC_CLSF_EXPIRE_COUNT; j++) {
133 struct hlist_head *hhead; 133 struct hlist_head *hhead;
134 struct hlist_node *tmp; 134 struct hlist_node *tmp;
@@ -148,7 +148,7 @@ void enic_flow_may_expire(unsigned long data)
148 } 148 }
149 } 149 }
150 } 150 }
151 spin_unlock(&enic->rfs_h.lock); 151 spin_unlock_bh(&enic->rfs_h.lock);
152 mod_timer(&enic->rfs_h.rfs_may_expire, jiffies + HZ/4); 152 mod_timer(&enic->rfs_h.rfs_may_expire, jiffies + HZ/4);
153} 153}
154 154
@@ -183,7 +183,7 @@ int enic_rx_flow_steer(struct net_device *dev, const struct sk_buff *skb,
183 return -EPROTONOSUPPORT; 183 return -EPROTONOSUPPORT;
184 184
185 tbl_idx = skb_get_hash_raw(skb) & ENIC_RFS_FLW_MASK; 185 tbl_idx = skb_get_hash_raw(skb) & ENIC_RFS_FLW_MASK;
186 spin_lock(&enic->rfs_h.lock); 186 spin_lock_bh(&enic->rfs_h.lock);
187 n = htbl_key_search(&enic->rfs_h.ht_head[tbl_idx], &keys); 187 n = htbl_key_search(&enic->rfs_h.ht_head[tbl_idx], &keys);
188 188
189 if (n) { /* entry already present */ 189 if (n) { /* entry already present */
@@ -277,7 +277,7 @@ int enic_rx_flow_steer(struct net_device *dev, const struct sk_buff *skb,
277 } 277 }
278 278
279ret_unlock: 279ret_unlock:
280 spin_unlock(&enic->rfs_h.lock); 280 spin_unlock_bh(&enic->rfs_h.lock);
281 return res; 281 return res;
282} 282}
283 283
diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c
index 929bfe70080a..180e53fa628f 100644
--- a/drivers/net/ethernet/cisco/enic/enic_main.c
+++ b/drivers/net/ethernet/cisco/enic/enic_main.c
@@ -1674,13 +1674,13 @@ static int enic_stop(struct net_device *netdev)
1674 1674
1675 enic_dev_disable(enic); 1675 enic_dev_disable(enic);
1676 1676
1677 local_bh_disable();
1678 for (i = 0; i < enic->rq_count; i++) { 1677 for (i = 0; i < enic->rq_count; i++) {
1679 napi_disable(&enic->napi[i]); 1678 napi_disable(&enic->napi[i]);
1679 local_bh_disable();
1680 while (!enic_poll_lock_napi(&enic->rq[i])) 1680 while (!enic_poll_lock_napi(&enic->rq[i]))
1681 mdelay(1); 1681 mdelay(1);
1682 local_bh_enable();
1682 } 1683 }
1683 local_bh_enable();
1684 1684
1685 netif_carrier_off(netdev); 1685 netif_carrier_off(netdev);
1686 netif_tx_disable(netdev); 1686 netif_tx_disable(netdev);
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index 81b96cf87574..50a851db2852 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -1581,7 +1581,8 @@ fec_enet_interrupt(int irq, void *dev_id)
1581 complete(&fep->mdio_done); 1581 complete(&fep->mdio_done);
1582 } 1582 }
1583 1583
1584 fec_ptp_check_pps_event(fep); 1584 if (fep->ptp_clock)
1585 fec_ptp_check_pps_event(fep);
1585 1586
1586 return ret; 1587 return ret;
1587} 1588}
diff --git a/drivers/net/ethernet/freescale/fs_enet/mac-fec.c b/drivers/net/ethernet/freescale/fs_enet/mac-fec.c
index 3d4e08be1709..b34214e2df5f 100644
--- a/drivers/net/ethernet/freescale/fs_enet/mac-fec.c
+++ b/drivers/net/ethernet/freescale/fs_enet/mac-fec.c
@@ -341,6 +341,9 @@ static void restart(struct net_device *dev)
341 FC(fecp, x_cntrl, FEC_TCNTRL_FDEN); /* FD disable */ 341 FC(fecp, x_cntrl, FEC_TCNTRL_FDEN); /* FD disable */
342 } 342 }
343 343
344 /* Restore multicast and promiscuous settings */
345 set_multicast_list(dev);
346
344 /* 347 /*
345 * Enable interrupts we wish to service. 348 * Enable interrupts we wish to service.
346 */ 349 */
diff --git a/drivers/net/ethernet/freescale/fs_enet/mac-scc.c b/drivers/net/ethernet/freescale/fs_enet/mac-scc.c
index f30411f0701f..7a184e8816a4 100644
--- a/drivers/net/ethernet/freescale/fs_enet/mac-scc.c
+++ b/drivers/net/ethernet/freescale/fs_enet/mac-scc.c
@@ -355,6 +355,9 @@ static void restart(struct net_device *dev)
355 if (fep->phydev->duplex) 355 if (fep->phydev->duplex)
356 S16(sccp, scc_psmr, SCC_PSMR_LPB | SCC_PSMR_FDE); 356 S16(sccp, scc_psmr, SCC_PSMR_LPB | SCC_PSMR_FDE);
357 357
358 /* Restore multicast and promiscuous settings */
359 set_multicast_list(dev);
360
358 S32(sccp, scc_gsmrl, SCC_GSMRL_ENR | SCC_GSMRL_ENT); 361 S32(sccp, scc_gsmrl, SCC_GSMRL_ENR | SCC_GSMRL_ENT);
359} 362}
360 363
diff --git a/drivers/net/ethernet/intel/e1000/e1000_main.c b/drivers/net/ethernet/intel/e1000/e1000_main.c
index 5f6aded512f5..24f3986cfae2 100644
--- a/drivers/net/ethernet/intel/e1000/e1000_main.c
+++ b/drivers/net/ethernet/intel/e1000/e1000_main.c
@@ -1075,7 +1075,10 @@ static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1075 NETIF_F_HW_CSUM | 1075 NETIF_F_HW_CSUM |
1076 NETIF_F_SG); 1076 NETIF_F_SG);
1077 1077
1078 netdev->priv_flags |= IFF_UNICAST_FLT; 1078 /* Do not set IFF_UNICAST_FLT for VMWare's 82545EM */
1079 if (hw->device_id != E1000_DEV_ID_82545EM_COPPER ||
1080 hw->subsystem_vendor_id != PCI_VENDOR_ID_VMWARE)
1081 netdev->priv_flags |= IFF_UNICAST_FLT;
1079 1082
1080 adapter->en_mng_pt = e1000_enable_mng_pass_thru(hw); 1083 adapter->en_mng_pt = e1000_enable_mng_pass_thru(hw);
1081 1084
diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
index ed5f1c15fb0f..c3a7f4a4b775 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -6151,7 +6151,7 @@ static void i40e_handle_mdd_event(struct i40e_pf *pf)
6151 I40E_GL_MDET_TX_PF_NUM_SHIFT; 6151 I40E_GL_MDET_TX_PF_NUM_SHIFT;
6152 u8 vf_num = (reg & I40E_GL_MDET_TX_VF_NUM_MASK) >> 6152 u8 vf_num = (reg & I40E_GL_MDET_TX_VF_NUM_MASK) >>
6153 I40E_GL_MDET_TX_VF_NUM_SHIFT; 6153 I40E_GL_MDET_TX_VF_NUM_SHIFT;
6154 u8 event = (reg & I40E_GL_MDET_TX_EVENT_SHIFT) >> 6154 u8 event = (reg & I40E_GL_MDET_TX_EVENT_MASK) >>
6155 I40E_GL_MDET_TX_EVENT_SHIFT; 6155 I40E_GL_MDET_TX_EVENT_SHIFT;
6156 u8 queue = (reg & I40E_GL_MDET_TX_QUEUE_MASK) >> 6156 u8 queue = (reg & I40E_GL_MDET_TX_QUEUE_MASK) >>
6157 I40E_GL_MDET_TX_QUEUE_SHIFT; 6157 I40E_GL_MDET_TX_QUEUE_SHIFT;
@@ -6165,7 +6165,7 @@ static void i40e_handle_mdd_event(struct i40e_pf *pf)
6165 if (reg & I40E_GL_MDET_RX_VALID_MASK) { 6165 if (reg & I40E_GL_MDET_RX_VALID_MASK) {
6166 u8 func = (reg & I40E_GL_MDET_RX_FUNCTION_MASK) >> 6166 u8 func = (reg & I40E_GL_MDET_RX_FUNCTION_MASK) >>
6167 I40E_GL_MDET_RX_FUNCTION_SHIFT; 6167 I40E_GL_MDET_RX_FUNCTION_SHIFT;
6168 u8 event = (reg & I40E_GL_MDET_RX_EVENT_SHIFT) >> 6168 u8 event = (reg & I40E_GL_MDET_RX_EVENT_MASK) >>
6169 I40E_GL_MDET_RX_EVENT_SHIFT; 6169 I40E_GL_MDET_RX_EVENT_SHIFT;
6170 u8 queue = (reg & I40E_GL_MDET_RX_QUEUE_MASK) >> 6170 u8 queue = (reg & I40E_GL_MDET_RX_QUEUE_MASK) >>
6171 I40E_GL_MDET_RX_QUEUE_SHIFT; 6171 I40E_GL_MDET_RX_QUEUE_SHIFT;
diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
index a21b14495ebd..a2d72a87cbde 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -6537,6 +6537,9 @@ static bool igb_can_reuse_rx_page(struct igb_rx_buffer *rx_buffer,
6537 if (unlikely(page_to_nid(page) != numa_node_id())) 6537 if (unlikely(page_to_nid(page) != numa_node_id()))
6538 return false; 6538 return false;
6539 6539
6540 if (unlikely(page->pfmemalloc))
6541 return false;
6542
6540#if (PAGE_SIZE < 8192) 6543#if (PAGE_SIZE < 8192)
6541 /* if we are only owner of page we can reuse it */ 6544 /* if we are only owner of page we can reuse it */
6542 if (unlikely(page_count(page) != 1)) 6545 if (unlikely(page_count(page) != 1))
@@ -6603,7 +6606,8 @@ static bool igb_add_rx_frag(struct igb_ring *rx_ring,
6603 memcpy(__skb_put(skb, size), va, ALIGN(size, sizeof(long))); 6606 memcpy(__skb_put(skb, size), va, ALIGN(size, sizeof(long)));
6604 6607
6605 /* we can reuse buffer as-is, just make sure it is local */ 6608 /* we can reuse buffer as-is, just make sure it is local */
6606 if (likely(page_to_nid(page) == numa_node_id())) 6609 if (likely((page_to_nid(page) == numa_node_id()) &&
6610 !page->pfmemalloc))
6607 return true; 6611 return true;
6608 6612
6609 /* this page cannot be reused so discard it */ 6613 /* this page cannot be reused so discard it */
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
index 3ce4a258f945..0ae038b9af90 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
@@ -342,12 +342,16 @@ static int ixgbe_set_settings(struct net_device *netdev,
342 if (old == advertised) 342 if (old == advertised)
343 return err; 343 return err;
344 /* this sets the link speed and restarts auto-neg */ 344 /* this sets the link speed and restarts auto-neg */
345 while (test_and_set_bit(__IXGBE_IN_SFP_INIT, &adapter->state))
346 usleep_range(1000, 2000);
347
345 hw->mac.autotry_restart = true; 348 hw->mac.autotry_restart = true;
346 err = hw->mac.ops.setup_link(hw, advertised, true); 349 err = hw->mac.ops.setup_link(hw, advertised, true);
347 if (err) { 350 if (err) {
348 e_info(probe, "setup link failed with code %d\n", err); 351 e_info(probe, "setup link failed with code %d\n", err);
349 hw->mac.ops.setup_link(hw, old, true); 352 hw->mac.ops.setup_link(hw, old, true);
350 } 353 }
354 clear_bit(__IXGBE_IN_SFP_INIT, &adapter->state);
351 } else { 355 } else {
352 /* in this case we currently only support 10Gb/FULL */ 356 /* in this case we currently only support 10Gb/FULL */
353 u32 speed = ethtool_cmd_speed(ecmd); 357 u32 speed = ethtool_cmd_speed(ecmd);
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index fec5212d4337..d2df4e3d1032 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -4321,8 +4321,8 @@ static void ixgbe_clean_rx_ring(struct ixgbe_ring *rx_ring)
4321 IXGBE_CB(skb)->page_released = false; 4321 IXGBE_CB(skb)->page_released = false;
4322 } 4322 }
4323 dev_kfree_skb(skb); 4323 dev_kfree_skb(skb);
4324 rx_buffer->skb = NULL;
4324 } 4325 }
4325 rx_buffer->skb = NULL;
4326 if (rx_buffer->dma) 4326 if (rx_buffer->dma)
4327 dma_unmap_page(dev, rx_buffer->dma, 4327 dma_unmap_page(dev, rx_buffer->dma,
4328 ixgbe_rx_pg_size(rx_ring), 4328 ixgbe_rx_pg_size(rx_ring),
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_tx.c b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
index 34c137878545..454d9fea640e 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
@@ -836,8 +836,11 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev)
836 * whether LSO is used */ 836 * whether LSO is used */
837 tx_desc->ctrl.srcrb_flags = priv->ctrl_flags; 837 tx_desc->ctrl.srcrb_flags = priv->ctrl_flags;
838 if (likely(skb->ip_summed == CHECKSUM_PARTIAL)) { 838 if (likely(skb->ip_summed == CHECKSUM_PARTIAL)) {
839 tx_desc->ctrl.srcrb_flags |= cpu_to_be32(MLX4_WQE_CTRL_IP_CSUM | 839 if (!skb->encapsulation)
840 MLX4_WQE_CTRL_TCP_UDP_CSUM); 840 tx_desc->ctrl.srcrb_flags |= cpu_to_be32(MLX4_WQE_CTRL_IP_CSUM |
841 MLX4_WQE_CTRL_TCP_UDP_CSUM);
842 else
843 tx_desc->ctrl.srcrb_flags |= cpu_to_be32(MLX4_WQE_CTRL_IP_CSUM);
841 ring->tx_csum++; 844 ring->tx_csum++;
842 } 845 }
843 846
diff --git a/drivers/net/ethernet/mellanox/mlx4/eq.c b/drivers/net/ethernet/mellanox/mlx4/eq.c
index a49c9d11d8a5..49290a405903 100644
--- a/drivers/net/ethernet/mellanox/mlx4/eq.c
+++ b/drivers/net/ethernet/mellanox/mlx4/eq.c
@@ -1026,6 +1026,7 @@ static void mlx4_free_eq(struct mlx4_dev *dev,
1026 pr_cont("\n"); 1026 pr_cont("\n");
1027 } 1027 }
1028 } 1028 }
1029 synchronize_irq(eq->irq);
1029 1030
1030 mlx4_mtt_cleanup(dev, &eq->mtt); 1031 mlx4_mtt_cleanup(dev, &eq->mtt);
1031 for (i = 0; i < npages; ++i) 1032 for (i = 0; i < npages; ++i)
diff --git a/drivers/net/ethernet/mellanox/mlx4/mcg.c b/drivers/net/ethernet/mellanox/mlx4/mcg.c
index ca0f98c95105..872843179f44 100644
--- a/drivers/net/ethernet/mellanox/mlx4/mcg.c
+++ b/drivers/net/ethernet/mellanox/mlx4/mcg.c
@@ -955,6 +955,10 @@ static void mlx4_err_rule(struct mlx4_dev *dev, char *str,
955 cur->ib.dst_gid_msk); 955 cur->ib.dst_gid_msk);
956 break; 956 break;
957 957
958 case MLX4_NET_TRANS_RULE_ID_VXLAN:
959 len += snprintf(buf + len, BUF_SIZE - len,
960 "VNID = %d ", be32_to_cpu(cur->vxlan.vni));
961 break;
958 case MLX4_NET_TRANS_RULE_ID_IPV6: 962 case MLX4_NET_TRANS_RULE_ID_IPV6:
959 break; 963 break;
960 964
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eq.c b/drivers/net/ethernet/mellanox/mlx5/core/eq.c
index ed53291468f3..a278238a2db6 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eq.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eq.c
@@ -420,6 +420,7 @@ int mlx5_destroy_unmap_eq(struct mlx5_core_dev *dev, struct mlx5_eq *eq)
420 if (err) 420 if (err)
421 mlx5_core_warn(dev, "failed to destroy a previously created eq: eqn %d\n", 421 mlx5_core_warn(dev, "failed to destroy a previously created eq: eqn %d\n",
422 eq->eqn); 422 eq->eqn);
423 synchronize_irq(table->msix_arr[eq->irqn].vector);
423 mlx5_buf_free(dev, &eq->buf); 424 mlx5_buf_free(dev, &eq->buf);
424 425
425 return err; 426 return err;
diff --git a/drivers/net/ethernet/sfc/tx.c b/drivers/net/ethernet/sfc/tx.c
index ee84a90e371c..aaf2987512b5 100644
--- a/drivers/net/ethernet/sfc/tx.c
+++ b/drivers/net/ethernet/sfc/tx.c
@@ -343,8 +343,6 @@ netdev_tx_t efx_enqueue_skb(struct efx_tx_queue *tx_queue, struct sk_buff *skb)
343 unsigned short dma_flags; 343 unsigned short dma_flags;
344 int i = 0; 344 int i = 0;
345 345
346 EFX_BUG_ON_PARANOID(tx_queue->write_count > tx_queue->insert_count);
347
348 if (skb_shinfo(skb)->gso_size) 346 if (skb_shinfo(skb)->gso_size)
349 return efx_enqueue_skb_tso(tx_queue, skb); 347 return efx_enqueue_skb_tso(tx_queue, skb);
350 348
@@ -1258,8 +1256,6 @@ static int efx_enqueue_skb_tso(struct efx_tx_queue *tx_queue,
1258 /* Find the packet protocol and sanity-check it */ 1256 /* Find the packet protocol and sanity-check it */
1259 state.protocol = efx_tso_check_protocol(skb); 1257 state.protocol = efx_tso_check_protocol(skb);
1260 1258
1261 EFX_BUG_ON_PARANOID(tx_queue->write_count > tx_queue->insert_count);
1262
1263 rc = tso_start(&state, efx, skb); 1259 rc = tso_start(&state, efx, skb);
1264 if (rc) 1260 if (rc)
1265 goto mem_err; 1261 goto mem_err;
diff --git a/drivers/net/ethernet/smsc/smc91x.c b/drivers/net/ethernet/smsc/smc91x.c
index 5e94d00b96b3..2c62208077fe 100644
--- a/drivers/net/ethernet/smsc/smc91x.c
+++ b/drivers/net/ethernet/smsc/smc91x.c
@@ -81,6 +81,7 @@ static const char version[] =
81#include <linux/workqueue.h> 81#include <linux/workqueue.h>
82#include <linux/of.h> 82#include <linux/of.h>
83#include <linux/of_device.h> 83#include <linux/of_device.h>
84#include <linux/of_gpio.h>
84 85
85#include <linux/netdevice.h> 86#include <linux/netdevice.h>
86#include <linux/etherdevice.h> 87#include <linux/etherdevice.h>
@@ -2188,6 +2189,41 @@ static const struct of_device_id smc91x_match[] = {
2188 {}, 2189 {},
2189}; 2190};
2190MODULE_DEVICE_TABLE(of, smc91x_match); 2191MODULE_DEVICE_TABLE(of, smc91x_match);
2192
2193/**
2194 * of_try_set_control_gpio - configure a gpio if it exists
2195 */
2196static int try_toggle_control_gpio(struct device *dev,
2197 struct gpio_desc **desc,
2198 const char *name, int index,
2199 int value, unsigned int nsdelay)
2200{
2201 struct gpio_desc *gpio = *desc;
2202 int res;
2203
2204 gpio = devm_gpiod_get_index(dev, name, index);
2205 if (IS_ERR(gpio)) {
2206 if (PTR_ERR(gpio) == -ENOENT) {
2207 *desc = NULL;
2208 return 0;
2209 }
2210
2211 return PTR_ERR(gpio);
2212 }
2213 res = gpiod_direction_output(gpio, !value);
2214 if (res) {
2215 dev_err(dev, "unable to toggle gpio %s: %i\n", name, res);
2216 devm_gpiod_put(dev, gpio);
2217 gpio = NULL;
2218 return res;
2219 }
2220 if (nsdelay)
2221 usleep_range(nsdelay, 2 * nsdelay);
2222 gpiod_set_value_cansleep(gpio, value);
2223 *desc = gpio;
2224
2225 return 0;
2226}
2191#endif 2227#endif
2192 2228
2193/* 2229/*
@@ -2237,6 +2273,28 @@ static int smc_drv_probe(struct platform_device *pdev)
2237 struct device_node *np = pdev->dev.of_node; 2273 struct device_node *np = pdev->dev.of_node;
2238 u32 val; 2274 u32 val;
2239 2275
2276 /* Optional pwrdwn GPIO configured? */
2277 ret = try_toggle_control_gpio(&pdev->dev, &lp->power_gpio,
2278 "power", 0, 0, 100);
2279 if (ret)
2280 return ret;
2281
2282 /*
2283 * Optional reset GPIO configured? Minimum 100 ns reset needed
2284 * according to LAN91C96 datasheet page 14.
2285 */
2286 ret = try_toggle_control_gpio(&pdev->dev, &lp->reset_gpio,
2287 "reset", 0, 0, 100);
2288 if (ret)
2289 return ret;
2290
2291 /*
2292 * Need to wait for optional EEPROM to load, max 750 us according
2293 * to LAN91C96 datasheet page 55.
2294 */
2295 if (lp->reset_gpio)
2296 usleep_range(750, 1000);
2297
2240 /* Combination of IO widths supported, default to 16-bit */ 2298 /* Combination of IO widths supported, default to 16-bit */
2241 if (!of_property_read_u32(np, "reg-io-width", &val)) { 2299 if (!of_property_read_u32(np, "reg-io-width", &val)) {
2242 if (val & 1) 2300 if (val & 1)
diff --git a/drivers/net/ethernet/smsc/smc91x.h b/drivers/net/ethernet/smsc/smc91x.h
index 47dce918eb0f..2a38dacbbd27 100644
--- a/drivers/net/ethernet/smsc/smc91x.h
+++ b/drivers/net/ethernet/smsc/smc91x.h
@@ -298,6 +298,9 @@ struct smc_local {
298 struct sk_buff *pending_tx_skb; 298 struct sk_buff *pending_tx_skb;
299 struct tasklet_struct tx_task; 299 struct tasklet_struct tx_task;
300 300
301 struct gpio_desc *power_gpio;
302 struct gpio_desc *reset_gpio;
303
301 /* version/revision of the SMC91x chip */ 304 /* version/revision of the SMC91x chip */
302 int version; 305 int version;
303 306
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
index 655a23bbc451..e17a970eaf2b 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
@@ -33,6 +33,7 @@ static struct stmmac_dma_cfg dma_cfg;
33static void stmmac_default_data(void) 33static void stmmac_default_data(void)
34{ 34{
35 memset(&plat_dat, 0, sizeof(struct plat_stmmacenet_data)); 35 memset(&plat_dat, 0, sizeof(struct plat_stmmacenet_data));
36
36 plat_dat.bus_id = 1; 37 plat_dat.bus_id = 1;
37 plat_dat.phy_addr = 0; 38 plat_dat.phy_addr = 0;
38 plat_dat.interface = PHY_INTERFACE_MODE_GMII; 39 plat_dat.interface = PHY_INTERFACE_MODE_GMII;
@@ -47,6 +48,12 @@ static void stmmac_default_data(void)
47 dma_cfg.pbl = 32; 48 dma_cfg.pbl = 32;
48 dma_cfg.burst_len = DMA_AXI_BLEN_256; 49 dma_cfg.burst_len = DMA_AXI_BLEN_256;
49 plat_dat.dma_cfg = &dma_cfg; 50 plat_dat.dma_cfg = &dma_cfg;
51
52 /* Set default value for multicast hash bins */
53 plat_dat.multicast_filter_bins = HASH_TABLE_SIZE;
54
55 /* Set default value for unicast filter entries */
56 plat_dat.unicast_filter_entries = 1;
50} 57}
51 58
52/** 59/**
diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index 952e1e4764b7..d8794488f80a 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -591,8 +591,8 @@ static void cpsw_set_promiscious(struct net_device *ndev, bool enable)
591 if (enable) { 591 if (enable) {
592 unsigned long timeout = jiffies + HZ; 592 unsigned long timeout = jiffies + HZ;
593 593
594 /* Disable Learn for all ports */ 594 /* Disable Learn for all ports (host is port 0 and slaves are port 1 and up */
595 for (i = 0; i < priv->data.slaves; i++) { 595 for (i = 0; i <= priv->data.slaves; i++) {
596 cpsw_ale_control_set(ale, i, 596 cpsw_ale_control_set(ale, i,
597 ALE_PORT_NOLEARN, 1); 597 ALE_PORT_NOLEARN, 1);
598 cpsw_ale_control_set(ale, i, 598 cpsw_ale_control_set(ale, i,
@@ -616,11 +616,11 @@ static void cpsw_set_promiscious(struct net_device *ndev, bool enable)
616 cpsw_ale_control_set(ale, 0, ALE_P0_UNI_FLOOD, 1); 616 cpsw_ale_control_set(ale, 0, ALE_P0_UNI_FLOOD, 1);
617 dev_dbg(&ndev->dev, "promiscuity enabled\n"); 617 dev_dbg(&ndev->dev, "promiscuity enabled\n");
618 } else { 618 } else {
619 /* Flood All Unicast Packets to Host port */ 619 /* Don't Flood All Unicast Packets to Host port */
620 cpsw_ale_control_set(ale, 0, ALE_P0_UNI_FLOOD, 0); 620 cpsw_ale_control_set(ale, 0, ALE_P0_UNI_FLOOD, 0);
621 621
622 /* Enable Learn for all ports */ 622 /* Enable Learn for all ports (host is port 0 and slaves are port 1 and up */
623 for (i = 0; i < priv->data.slaves; i++) { 623 for (i = 0; i <= priv->data.slaves; i++) {
624 cpsw_ale_control_set(ale, i, 624 cpsw_ale_control_set(ale, i,
625 ALE_PORT_NOLEARN, 0); 625 ALE_PORT_NOLEARN, 0);
626 cpsw_ale_control_set(ale, i, 626 cpsw_ale_control_set(ale, i,
@@ -638,12 +638,16 @@ static void cpsw_ndo_set_rx_mode(struct net_device *ndev)
638 if (ndev->flags & IFF_PROMISC) { 638 if (ndev->flags & IFF_PROMISC) {
639 /* Enable promiscuous mode */ 639 /* Enable promiscuous mode */
640 cpsw_set_promiscious(ndev, true); 640 cpsw_set_promiscious(ndev, true);
641 cpsw_ale_set_allmulti(priv->ale, IFF_ALLMULTI);
641 return; 642 return;
642 } else { 643 } else {
643 /* Disable promiscuous mode */ 644 /* Disable promiscuous mode */
644 cpsw_set_promiscious(ndev, false); 645 cpsw_set_promiscious(ndev, false);
645 } 646 }
646 647
648 /* Restore allmulti on vlans if necessary */
649 cpsw_ale_set_allmulti(priv->ale, priv->ndev->flags & IFF_ALLMULTI);
650
647 /* Clear all mcast from ALE */ 651 /* Clear all mcast from ALE */
648 cpsw_ale_flush_multicast(priv->ale, ALE_ALL_PORTS << priv->host_port); 652 cpsw_ale_flush_multicast(priv->ale, ALE_ALL_PORTS << priv->host_port);
649 653
@@ -1149,6 +1153,7 @@ static inline void cpsw_add_default_vlan(struct cpsw_priv *priv)
1149 const int port = priv->host_port; 1153 const int port = priv->host_port;
1150 u32 reg; 1154 u32 reg;
1151 int i; 1155 int i;
1156 int unreg_mcast_mask;
1152 1157
1153 reg = (priv->version == CPSW_VERSION_1) ? CPSW1_PORT_VLAN : 1158 reg = (priv->version == CPSW_VERSION_1) ? CPSW1_PORT_VLAN :
1154 CPSW2_PORT_VLAN; 1159 CPSW2_PORT_VLAN;
@@ -1158,9 +1163,14 @@ static inline void cpsw_add_default_vlan(struct cpsw_priv *priv)
1158 for (i = 0; i < priv->data.slaves; i++) 1163 for (i = 0; i < priv->data.slaves; i++)
1159 slave_write(priv->slaves + i, vlan, reg); 1164 slave_write(priv->slaves + i, vlan, reg);
1160 1165
1166 if (priv->ndev->flags & IFF_ALLMULTI)
1167 unreg_mcast_mask = ALE_ALL_PORTS;
1168 else
1169 unreg_mcast_mask = ALE_PORT_1 | ALE_PORT_2;
1170
1161 cpsw_ale_add_vlan(priv->ale, vlan, ALE_ALL_PORTS << port, 1171 cpsw_ale_add_vlan(priv->ale, vlan, ALE_ALL_PORTS << port,
1162 ALE_ALL_PORTS << port, ALE_ALL_PORTS << port, 1172 ALE_ALL_PORTS << port, ALE_ALL_PORTS << port,
1163 (ALE_PORT_1 | ALE_PORT_2) << port); 1173 unreg_mcast_mask << port);
1164} 1174}
1165 1175
1166static void cpsw_init_host_port(struct cpsw_priv *priv) 1176static void cpsw_init_host_port(struct cpsw_priv *priv)
@@ -1620,11 +1630,17 @@ static inline int cpsw_add_vlan_ale_entry(struct cpsw_priv *priv,
1620 unsigned short vid) 1630 unsigned short vid)
1621{ 1631{
1622 int ret; 1632 int ret;
1633 int unreg_mcast_mask;
1634
1635 if (priv->ndev->flags & IFF_ALLMULTI)
1636 unreg_mcast_mask = ALE_ALL_PORTS;
1637 else
1638 unreg_mcast_mask = ALE_PORT_1 | ALE_PORT_2;
1623 1639
1624 ret = cpsw_ale_add_vlan(priv->ale, vid, 1640 ret = cpsw_ale_add_vlan(priv->ale, vid,
1625 ALE_ALL_PORTS << priv->host_port, 1641 ALE_ALL_PORTS << priv->host_port,
1626 0, ALE_ALL_PORTS << priv->host_port, 1642 0, ALE_ALL_PORTS << priv->host_port,
1627 (ALE_PORT_1 | ALE_PORT_2) << priv->host_port); 1643 unreg_mcast_mask << priv->host_port);
1628 if (ret != 0) 1644 if (ret != 0)
1629 return ret; 1645 return ret;
1630 1646
@@ -2006,7 +2022,7 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data,
2006 parp = of_get_property(slave_node, "phy_id", &lenp); 2022 parp = of_get_property(slave_node, "phy_id", &lenp);
2007 if ((parp == NULL) || (lenp != (sizeof(void *) * 2))) { 2023 if ((parp == NULL) || (lenp != (sizeof(void *) * 2))) {
2008 dev_err(&pdev->dev, "Missing slave[%d] phy_id property\n", i); 2024 dev_err(&pdev->dev, "Missing slave[%d] phy_id property\n", i);
2009 return -EINVAL; 2025 goto no_phy_slave;
2010 } 2026 }
2011 mdio_node = of_find_node_by_phandle(be32_to_cpup(parp)); 2027 mdio_node = of_find_node_by_phandle(be32_to_cpup(parp));
2012 phyid = be32_to_cpup(parp+1); 2028 phyid = be32_to_cpup(parp+1);
@@ -2019,6 +2035,14 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data,
2019 snprintf(slave_data->phy_id, sizeof(slave_data->phy_id), 2035 snprintf(slave_data->phy_id, sizeof(slave_data->phy_id),
2020 PHY_ID_FMT, mdio->name, phyid); 2036 PHY_ID_FMT, mdio->name, phyid);
2021 2037
2038 slave_data->phy_if = of_get_phy_mode(slave_node);
2039 if (slave_data->phy_if < 0) {
2040 dev_err(&pdev->dev, "Missing or malformed slave[%d] phy-mode property\n",
2041 i);
2042 return slave_data->phy_if;
2043 }
2044
2045no_phy_slave:
2022 mac_addr = of_get_mac_address(slave_node); 2046 mac_addr = of_get_mac_address(slave_node);
2023 if (mac_addr) { 2047 if (mac_addr) {
2024 memcpy(slave_data->mac_addr, mac_addr, ETH_ALEN); 2048 memcpy(slave_data->mac_addr, mac_addr, ETH_ALEN);
@@ -2030,14 +2054,6 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data,
2030 return ret; 2054 return ret;
2031 } 2055 }
2032 } 2056 }
2033
2034 slave_data->phy_if = of_get_phy_mode(slave_node);
2035 if (slave_data->phy_if < 0) {
2036 dev_err(&pdev->dev, "Missing or malformed slave[%d] phy-mode property\n",
2037 i);
2038 return slave_data->phy_if;
2039 }
2040
2041 if (data->dual_emac) { 2057 if (data->dual_emac) {
2042 if (of_property_read_u32(slave_node, "dual_emac_res_vlan", 2058 if (of_property_read_u32(slave_node, "dual_emac_res_vlan",
2043 &prop)) { 2059 &prop)) {
diff --git a/drivers/net/ethernet/ti/cpsw_ale.c b/drivers/net/ethernet/ti/cpsw_ale.c
index 0579b2243bb6..3ae83879a75f 100644
--- a/drivers/net/ethernet/ti/cpsw_ale.c
+++ b/drivers/net/ethernet/ti/cpsw_ale.c
@@ -443,6 +443,35 @@ int cpsw_ale_del_vlan(struct cpsw_ale *ale, u16 vid, int port_mask)
443 return 0; 443 return 0;
444} 444}
445 445
446void cpsw_ale_set_allmulti(struct cpsw_ale *ale, int allmulti)
447{
448 u32 ale_entry[ALE_ENTRY_WORDS];
449 int type, idx;
450 int unreg_mcast = 0;
451
452 /* Only bother doing the work if the setting is actually changing */
453 if (ale->allmulti == allmulti)
454 return;
455
456 /* Remember the new setting to check against next time */
457 ale->allmulti = allmulti;
458
459 for (idx = 0; idx < ale->params.ale_entries; idx++) {
460 cpsw_ale_read(ale, idx, ale_entry);
461 type = cpsw_ale_get_entry_type(ale_entry);
462 if (type != ALE_TYPE_VLAN)
463 continue;
464
465 unreg_mcast = cpsw_ale_get_vlan_unreg_mcast(ale_entry);
466 if (allmulti)
467 unreg_mcast |= 1;
468 else
469 unreg_mcast &= ~1;
470 cpsw_ale_set_vlan_unreg_mcast(ale_entry, unreg_mcast);
471 cpsw_ale_write(ale, idx, ale_entry);
472 }
473}
474
446struct ale_control_info { 475struct ale_control_info {
447 const char *name; 476 const char *name;
448 int offset, port_offset; 477 int offset, port_offset;
diff --git a/drivers/net/ethernet/ti/cpsw_ale.h b/drivers/net/ethernet/ti/cpsw_ale.h
index 31cf43cab42e..c0d4127aa549 100644
--- a/drivers/net/ethernet/ti/cpsw_ale.h
+++ b/drivers/net/ethernet/ti/cpsw_ale.h
@@ -27,6 +27,7 @@ struct cpsw_ale {
27 struct cpsw_ale_params params; 27 struct cpsw_ale_params params;
28 struct timer_list timer; 28 struct timer_list timer;
29 unsigned long ageout; 29 unsigned long ageout;
30 int allmulti;
30}; 31};
31 32
32enum cpsw_ale_control { 33enum cpsw_ale_control {
@@ -103,6 +104,7 @@ int cpsw_ale_del_mcast(struct cpsw_ale *ale, u8 *addr, int port_mask,
103int cpsw_ale_add_vlan(struct cpsw_ale *ale, u16 vid, int port, int untag, 104int cpsw_ale_add_vlan(struct cpsw_ale *ale, u16 vid, int port, int untag,
104 int reg_mcast, int unreg_mcast); 105 int reg_mcast, int unreg_mcast);
105int cpsw_ale_del_vlan(struct cpsw_ale *ale, u16 vid, int port); 106int cpsw_ale_del_vlan(struct cpsw_ale *ale, u16 vid, int port);
107void cpsw_ale_set_allmulti(struct cpsw_ale *ale, int allmulti);
106 108
107int cpsw_ale_control_get(struct cpsw_ale *ale, int port, int control); 109int cpsw_ale_control_get(struct cpsw_ale *ale, int port, int control);
108int cpsw_ale_control_set(struct cpsw_ale *ale, int port, 110int cpsw_ale_control_set(struct cpsw_ale *ale, int port,
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 9e17d1a91e71..78ec33f5100b 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -550,6 +550,7 @@ do_lso:
550do_send: 550do_send:
551 /* Start filling in the page buffers with the rndis hdr */ 551 /* Start filling in the page buffers with the rndis hdr */
552 rndis_msg->msg_len += rndis_msg_size; 552 rndis_msg->msg_len += rndis_msg_size;
553 packet->total_data_buflen = rndis_msg->msg_len;
553 packet->page_buf_cnt = init_page_array(rndis_msg, rndis_msg_size, 554 packet->page_buf_cnt = init_page_array(rndis_msg, rndis_msg_size,
554 skb, &packet->page_buf[0]); 555 skb, &packet->page_buf[0]);
555 556
diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index 29b3bb410781..bfb0b6ec8c56 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -272,7 +272,7 @@ static void macvlan_process_broadcast(struct work_struct *w)
272 struct sk_buff *skb; 272 struct sk_buff *skb;
273 struct sk_buff_head list; 273 struct sk_buff_head list;
274 274
275 skb_queue_head_init(&list); 275 __skb_queue_head_init(&list);
276 276
277 spin_lock_bh(&port->bc_queue.lock); 277 spin_lock_bh(&port->bc_queue.lock);
278 skb_queue_splice_tail_init(&port->bc_queue, &list); 278 skb_queue_splice_tail_init(&port->bc_queue, &list);
@@ -1082,9 +1082,15 @@ static void macvlan_port_destroy(struct net_device *dev)
1082{ 1082{
1083 struct macvlan_port *port = macvlan_port_get_rtnl(dev); 1083 struct macvlan_port *port = macvlan_port_get_rtnl(dev);
1084 1084
1085 cancel_work_sync(&port->bc_work);
1086 dev->priv_flags &= ~IFF_MACVLAN_PORT; 1085 dev->priv_flags &= ~IFF_MACVLAN_PORT;
1087 netdev_rx_handler_unregister(dev); 1086 netdev_rx_handler_unregister(dev);
1087
1088 /* After this point, no packet can schedule bc_work anymore,
1089 * but we need to cancel it and purge left skbs if any.
1090 */
1091 cancel_work_sync(&port->bc_work);
1092 __skb_queue_purge(&port->bc_queue);
1093
1088 kfree_rcu(port, rcu); 1094 kfree_rcu(port, rcu);
1089} 1095}
1090 1096
diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
index 65e2892342bd..6f226de655a4 100644
--- a/drivers/net/macvtap.c
+++ b/drivers/net/macvtap.c
@@ -16,6 +16,7 @@
16#include <linux/idr.h> 16#include <linux/idr.h>
17#include <linux/fs.h> 17#include <linux/fs.h>
18 18
19#include <net/ipv6.h>
19#include <net/net_namespace.h> 20#include <net/net_namespace.h>
20#include <net/rtnetlink.h> 21#include <net/rtnetlink.h>
21#include <net/sock.h> 22#include <net/sock.h>
@@ -65,7 +66,7 @@ static struct cdev macvtap_cdev;
65static const struct proto_ops macvtap_socket_ops; 66static const struct proto_ops macvtap_socket_ops;
66 67
67#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 | \
68 NETIF_F_TSO6 | NETIF_F_UFO) 69 NETIF_F_TSO6)
69#define RX_OFFLOADS (NETIF_F_GRO | NETIF_F_LRO) 70#define RX_OFFLOADS (NETIF_F_GRO | NETIF_F_LRO)
70#define TAP_FEATURES (NETIF_F_GSO | NETIF_F_SG) 71#define TAP_FEATURES (NETIF_F_GSO | NETIF_F_SG)
71 72
@@ -569,7 +570,11 @@ static int macvtap_skb_from_vnet_hdr(struct sk_buff *skb,
569 gso_type = SKB_GSO_TCPV6; 570 gso_type = SKB_GSO_TCPV6;
570 break; 571 break;
571 case VIRTIO_NET_HDR_GSO_UDP: 572 case VIRTIO_NET_HDR_GSO_UDP:
573 pr_warn_once("macvtap: %s: using disabled UFO feature; please fix this program\n",
574 current->comm);
572 gso_type = SKB_GSO_UDP; 575 gso_type = SKB_GSO_UDP;
576 if (skb->protocol == htons(ETH_P_IPV6))
577 ipv6_proxy_select_ident(skb);
573 break; 578 break;
574 default: 579 default:
575 return -EINVAL; 580 return -EINVAL;
@@ -614,8 +619,6 @@ static void macvtap_skb_to_vnet_hdr(const struct sk_buff *skb,
614 vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV4; 619 vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
615 else if (sinfo->gso_type & SKB_GSO_TCPV6) 620 else if (sinfo->gso_type & SKB_GSO_TCPV6)
616 vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV6; 621 vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
617 else if (sinfo->gso_type & SKB_GSO_UDP)
618 vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_UDP;
619 else 622 else
620 BUG(); 623 BUG();
621 if (sinfo->gso_type & SKB_GSO_TCP_ECN) 624 if (sinfo->gso_type & SKB_GSO_TCP_ECN)
@@ -950,9 +953,6 @@ static int set_offload(struct macvtap_queue *q, unsigned long arg)
950 if (arg & TUN_F_TSO6) 953 if (arg & TUN_F_TSO6)
951 feature_mask |= NETIF_F_TSO6; 954 feature_mask |= NETIF_F_TSO6;
952 } 955 }
953
954 if (arg & TUN_F_UFO)
955 feature_mask |= NETIF_F_UFO;
956 } 956 }
957 957
958 /* tun/tap driver inverts the usage for TSO offloads, where 958 /* tun/tap driver inverts the usage for TSO offloads, where
@@ -963,7 +963,7 @@ static int set_offload(struct macvtap_queue *q, unsigned long arg)
963 * When user space turns off TSO, we turn off GSO/LRO so that 963 * When user space turns off TSO, we turn off GSO/LRO so that
964 * user-space will not receive TSO frames. 964 * user-space will not receive TSO frames.
965 */ 965 */
966 if (feature_mask & (NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_UFO)) 966 if (feature_mask & (NETIF_F_TSO | NETIF_F_TSO6))
967 features |= RX_OFFLOADS; 967 features |= RX_OFFLOADS;
968 else 968 else
969 features &= ~RX_OFFLOADS; 969 features &= ~RX_OFFLOADS;
@@ -1064,7 +1064,7 @@ static long macvtap_ioctl(struct file *file, unsigned int cmd,
1064 case TUNSETOFFLOAD: 1064 case TUNSETOFFLOAD:
1065 /* let the user check for future flags */ 1065 /* let the user check for future flags */
1066 if (arg & ~(TUN_F_CSUM | TUN_F_TSO4 | TUN_F_TSO6 | 1066 if (arg & ~(TUN_F_CSUM | TUN_F_TSO4 | TUN_F_TSO6 |
1067 TUN_F_TSO_ECN | TUN_F_UFO)) 1067 TUN_F_TSO_ECN))
1068 return -EINVAL; 1068 return -EINVAL;
1069 1069
1070 rtnl_lock(); 1070 rtnl_lock();
diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
index bd37e45c89c0..225c033b08f3 100644
--- a/drivers/net/phy/marvell.c
+++ b/drivers/net/phy/marvell.c
@@ -50,10 +50,15 @@
50#define MII_M1011_PHY_SCR 0x10 50#define MII_M1011_PHY_SCR 0x10
51#define MII_M1011_PHY_SCR_AUTO_CROSS 0x0060 51#define MII_M1011_PHY_SCR_AUTO_CROSS 0x0060
52 52
53#define MII_M1145_PHY_EXT_SR 0x1b
53#define MII_M1145_PHY_EXT_CR 0x14 54#define MII_M1145_PHY_EXT_CR 0x14
54#define MII_M1145_RGMII_RX_DELAY 0x0080 55#define MII_M1145_RGMII_RX_DELAY 0x0080
55#define MII_M1145_RGMII_TX_DELAY 0x0002 56#define MII_M1145_RGMII_TX_DELAY 0x0002
56 57
58#define MII_M1145_HWCFG_MODE_SGMII_NO_CLK 0x4
59#define MII_M1145_HWCFG_MODE_MASK 0xf
60#define MII_M1145_HWCFG_FIBER_COPPER_AUTO 0x8000
61
57#define MII_M1111_PHY_LED_CONTROL 0x18 62#define MII_M1111_PHY_LED_CONTROL 0x18
58#define MII_M1111_PHY_LED_DIRECT 0x4100 63#define MII_M1111_PHY_LED_DIRECT 0x4100
59#define MII_M1111_PHY_LED_COMBINE 0x411c 64#define MII_M1111_PHY_LED_COMBINE 0x411c
@@ -676,6 +681,20 @@ static int m88e1145_config_init(struct phy_device *phydev)
676 } 681 }
677 } 682 }
678 683
684 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) {
685 int temp = phy_read(phydev, MII_M1145_PHY_EXT_SR);
686 if (temp < 0)
687 return temp;
688
689 temp &= ~MII_M1145_HWCFG_MODE_MASK;
690 temp |= MII_M1145_HWCFG_MODE_SGMII_NO_CLK;
691 temp |= MII_M1145_HWCFG_FIBER_COPPER_AUTO;
692
693 err = phy_write(phydev, MII_M1145_PHY_EXT_SR, temp);
694 if (err < 0)
695 return err;
696 }
697
679 err = marvell_of_reg_init(phydev); 698 err = marvell_of_reg_init(phydev);
680 if (err < 0) 699 if (err < 0)
681 return err; 700 return err;
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 186ce541c657..7302398f0b1f 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -65,6 +65,7 @@
65#include <linux/nsproxy.h> 65#include <linux/nsproxy.h>
66#include <linux/virtio_net.h> 66#include <linux/virtio_net.h>
67#include <linux/rcupdate.h> 67#include <linux/rcupdate.h>
68#include <net/ipv6.h>
68#include <net/net_namespace.h> 69#include <net/net_namespace.h>
69#include <net/netns/generic.h> 70#include <net/netns/generic.h>
70#include <net/rtnetlink.h> 71#include <net/rtnetlink.h>
@@ -174,7 +175,7 @@ struct tun_struct {
174 struct net_device *dev; 175 struct net_device *dev;
175 netdev_features_t set_features; 176 netdev_features_t set_features;
176#define TUN_USER_FEATURES (NETIF_F_HW_CSUM|NETIF_F_TSO_ECN|NETIF_F_TSO| \ 177#define TUN_USER_FEATURES (NETIF_F_HW_CSUM|NETIF_F_TSO_ECN|NETIF_F_TSO| \
177 NETIF_F_TSO6|NETIF_F_UFO) 178 NETIF_F_TSO6)
178 179
179 int vnet_hdr_sz; 180 int vnet_hdr_sz;
180 int sndbuf; 181 int sndbuf;
@@ -1139,6 +1140,8 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
1139 break; 1140 break;
1140 } 1141 }
1141 1142
1143 skb_reset_network_header(skb);
1144
1142 if (gso.gso_type != VIRTIO_NET_HDR_GSO_NONE) { 1145 if (gso.gso_type != VIRTIO_NET_HDR_GSO_NONE) {
1143 pr_debug("GSO!\n"); 1146 pr_debug("GSO!\n");
1144 switch (gso.gso_type & ~VIRTIO_NET_HDR_GSO_ECN) { 1147 switch (gso.gso_type & ~VIRTIO_NET_HDR_GSO_ECN) {
@@ -1149,8 +1152,20 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
1149 skb_shinfo(skb)->gso_type = SKB_GSO_TCPV6; 1152 skb_shinfo(skb)->gso_type = SKB_GSO_TCPV6;
1150 break; 1153 break;
1151 case VIRTIO_NET_HDR_GSO_UDP: 1154 case VIRTIO_NET_HDR_GSO_UDP:
1155 {
1156 static bool warned;
1157
1158 if (!warned) {
1159 warned = true;
1160 netdev_warn(tun->dev,
1161 "%s: using disabled UFO feature; please fix this program\n",
1162 current->comm);
1163 }
1152 skb_shinfo(skb)->gso_type = SKB_GSO_UDP; 1164 skb_shinfo(skb)->gso_type = SKB_GSO_UDP;
1165 if (skb->protocol == htons(ETH_P_IPV6))
1166 ipv6_proxy_select_ident(skb);
1153 break; 1167 break;
1168 }
1154 default: 1169 default:
1155 tun->dev->stats.rx_frame_errors++; 1170 tun->dev->stats.rx_frame_errors++;
1156 kfree_skb(skb); 1171 kfree_skb(skb);
@@ -1179,7 +1194,6 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
1179 skb_shinfo(skb)->tx_flags |= SKBTX_SHARED_FRAG; 1194 skb_shinfo(skb)->tx_flags |= SKBTX_SHARED_FRAG;
1180 } 1195 }
1181 1196
1182 skb_reset_network_header(skb);
1183 skb_probe_transport_header(skb, 0); 1197 skb_probe_transport_header(skb, 0);
1184 1198
1185 rxhash = skb_get_hash(skb); 1199 rxhash = skb_get_hash(skb);
@@ -1251,8 +1265,6 @@ static ssize_t tun_put_user(struct tun_struct *tun,
1251 gso.gso_type = VIRTIO_NET_HDR_GSO_TCPV4; 1265 gso.gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
1252 else if (sinfo->gso_type & SKB_GSO_TCPV6) 1266 else if (sinfo->gso_type & SKB_GSO_TCPV6)
1253 gso.gso_type = VIRTIO_NET_HDR_GSO_TCPV6; 1267 gso.gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
1254 else if (sinfo->gso_type & SKB_GSO_UDP)
1255 gso.gso_type = VIRTIO_NET_HDR_GSO_UDP;
1256 else { 1268 else {
1257 pr_err("unexpected GSO type: " 1269 pr_err("unexpected GSO type: "
1258 "0x%x, gso_size %d, hdr_len %d\n", 1270 "0x%x, gso_size %d, hdr_len %d\n",
@@ -1762,11 +1774,6 @@ static int set_offload(struct tun_struct *tun, unsigned long arg)
1762 features |= NETIF_F_TSO6; 1774 features |= NETIF_F_TSO6;
1763 arg &= ~(TUN_F_TSO4|TUN_F_TSO6); 1775 arg &= ~(TUN_F_TSO4|TUN_F_TSO6);
1764 } 1776 }
1765
1766 if (arg & TUN_F_UFO) {
1767 features |= NETIF_F_UFO;
1768 arg &= ~TUN_F_UFO;
1769 }
1770 } 1777 }
1771 1778
1772 /* This gives the user a way to test for new features in future by 1779 /* This gives the user a way to test for new features in future by
diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
index be4275721039..e6338c16081a 100644
--- a/drivers/net/usb/ax88179_178a.c
+++ b/drivers/net/usb/ax88179_178a.c
@@ -937,6 +937,7 @@ static int ax88179_set_mac_addr(struct net_device *net, void *p)
937{ 937{
938 struct usbnet *dev = netdev_priv(net); 938 struct usbnet *dev = netdev_priv(net);
939 struct sockaddr *addr = p; 939 struct sockaddr *addr = p;
940 int ret;
940 941
941 if (netif_running(net)) 942 if (netif_running(net))
942 return -EBUSY; 943 return -EBUSY;
@@ -946,8 +947,12 @@ static int ax88179_set_mac_addr(struct net_device *net, void *p)
946 memcpy(net->dev_addr, addr->sa_data, ETH_ALEN); 947 memcpy(net->dev_addr, addr->sa_data, ETH_ALEN);
947 948
948 /* Set the MAC address */ 949 /* Set the MAC address */
949 return ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_NODE_ID, ETH_ALEN, 950 ret = ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_NODE_ID, ETH_ALEN,
950 ETH_ALEN, net->dev_addr); 951 ETH_ALEN, net->dev_addr);
952 if (ret < 0)
953 return ret;
954
955 return 0;
951} 956}
952 957
953static const struct net_device_ops ax88179_netdev_ops = { 958static const struct net_device_ops ax88179_netdev_ops = {
diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c
index 2a32d9167d3b..d3920b54a92c 100644
--- a/drivers/net/usb/cdc_ether.c
+++ b/drivers/net/usb/cdc_ether.c
@@ -67,6 +67,35 @@ static const u8 mbm_guid[16] = {
67 0xa6, 0x07, 0xc0, 0xff, 0xcb, 0x7e, 0x39, 0x2a, 67 0xa6, 0x07, 0xc0, 0xff, 0xcb, 0x7e, 0x39, 0x2a,
68}; 68};
69 69
70static void usbnet_cdc_update_filter(struct usbnet *dev)
71{
72 struct cdc_state *info = (void *) &dev->data;
73 struct usb_interface *intf = info->control;
74
75 u16 cdc_filter =
76 USB_CDC_PACKET_TYPE_ALL_MULTICAST | USB_CDC_PACKET_TYPE_DIRECTED |
77 USB_CDC_PACKET_TYPE_BROADCAST;
78
79 if (dev->net->flags & IFF_PROMISC)
80 cdc_filter |= USB_CDC_PACKET_TYPE_PROMISCUOUS;
81
82 /* FIXME cdc-ether has some multicast code too, though it complains
83 * in routine cases. info->ether describes the multicast support.
84 * Implement that here, manipulating the cdc filter as needed.
85 */
86
87 usb_control_msg(dev->udev,
88 usb_sndctrlpipe(dev->udev, 0),
89 USB_CDC_SET_ETHERNET_PACKET_FILTER,
90 USB_TYPE_CLASS | USB_RECIP_INTERFACE,
91 cdc_filter,
92 intf->cur_altsetting->desc.bInterfaceNumber,
93 NULL,
94 0,
95 USB_CTRL_SET_TIMEOUT
96 );
97}
98
70/* probes control interface, claims data interface, collects the bulk 99/* probes control interface, claims data interface, collects the bulk
71 * endpoints, activates data interface (if needed), maybe sets MTU. 100 * endpoints, activates data interface (if needed), maybe sets MTU.
72 * all pure cdc, except for certain firmware workarounds, and knowing 101 * all pure cdc, except for certain firmware workarounds, and knowing
@@ -347,16 +376,8 @@ next_desc:
347 * don't do reset all the way. So the packet filter should 376 * don't do reset all the way. So the packet filter should
348 * be set to a sane initial value. 377 * be set to a sane initial value.
349 */ 378 */
350 usb_control_msg(dev->udev, 379 usbnet_cdc_update_filter(dev);
351 usb_sndctrlpipe(dev->udev, 0), 380
352 USB_CDC_SET_ETHERNET_PACKET_FILTER,
353 USB_TYPE_CLASS | USB_RECIP_INTERFACE,
354 USB_CDC_PACKET_TYPE_ALL_MULTICAST | USB_CDC_PACKET_TYPE_DIRECTED | USB_CDC_PACKET_TYPE_BROADCAST,
355 intf->cur_altsetting->desc.bInterfaceNumber,
356 NULL,
357 0,
358 USB_CTRL_SET_TIMEOUT
359 );
360 return 0; 381 return 0;
361 382
362bad_desc: 383bad_desc:
@@ -468,10 +489,6 @@ int usbnet_cdc_bind(struct usbnet *dev, struct usb_interface *intf)
468 return status; 489 return status;
469 } 490 }
470 491
471 /* FIXME cdc-ether has some multicast code too, though it complains
472 * in routine cases. info->ether describes the multicast support.
473 * Implement that here, manipulating the cdc filter as needed.
474 */
475 return 0; 492 return 0;
476} 493}
477EXPORT_SYMBOL_GPL(usbnet_cdc_bind); 494EXPORT_SYMBOL_GPL(usbnet_cdc_bind);
@@ -482,6 +499,7 @@ static const struct driver_info cdc_info = {
482 .bind = usbnet_cdc_bind, 499 .bind = usbnet_cdc_bind,
483 .unbind = usbnet_cdc_unbind, 500 .unbind = usbnet_cdc_unbind,
484 .status = usbnet_cdc_status, 501 .status = usbnet_cdc_status,
502 .set_rx_mode = usbnet_cdc_update_filter,
485 .manage_power = usbnet_manage_power, 503 .manage_power = usbnet_manage_power,
486}; 504};
487 505
@@ -491,6 +509,7 @@ static const struct driver_info wwan_info = {
491 .bind = usbnet_cdc_bind, 509 .bind = usbnet_cdc_bind,
492 .unbind = usbnet_cdc_unbind, 510 .unbind = usbnet_cdc_unbind,
493 .status = usbnet_cdc_status, 511 .status = usbnet_cdc_status,
512 .set_rx_mode = usbnet_cdc_update_filter,
494 .manage_power = usbnet_manage_power, 513 .manage_power = usbnet_manage_power,
495}; 514};
496 515
diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index e3d84c322e4e..c6554c7a8147 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -1162,6 +1162,9 @@ static void intr_callback(struct urb *urb)
1162 case -ESHUTDOWN: 1162 case -ESHUTDOWN:
1163 netif_device_detach(tp->netdev); 1163 netif_device_detach(tp->netdev);
1164 case -ENOENT: 1164 case -ENOENT:
1165 case -EPROTO:
1166 netif_info(tp, intr, tp->netdev,
1167 "Stop submitting intr, status %d\n", status);
1165 return; 1168 return;
1166 case -EOVERFLOW: 1169 case -EOVERFLOW:
1167 netif_info(tp, intr, tp->netdev, "intr status -EOVERFLOW\n"); 1170 netif_info(tp, intr, tp->netdev, "intr status -EOVERFLOW\n");
@@ -2891,6 +2894,9 @@ static int rtl8152_open(struct net_device *netdev)
2891 if (res) 2894 if (res)
2892 goto out; 2895 goto out;
2893 2896
2897 /* set speed to 0 to avoid autoresume try to submit rx */
2898 tp->speed = 0;
2899
2894 res = usb_autopm_get_interface(tp->intf); 2900 res = usb_autopm_get_interface(tp->intf);
2895 if (res < 0) { 2901 if (res < 0) {
2896 free_all_mem(tp); 2902 free_all_mem(tp);
@@ -2904,6 +2910,8 @@ static int rtl8152_open(struct net_device *netdev)
2904 clear_bit(WORK_ENABLE, &tp->flags); 2910 clear_bit(WORK_ENABLE, &tp->flags);
2905 usb_kill_urb(tp->intr_urb); 2911 usb_kill_urb(tp->intr_urb);
2906 cancel_delayed_work_sync(&tp->schedule); 2912 cancel_delayed_work_sync(&tp->schedule);
2913
2914 /* disable the tx/rx, if the workqueue has enabled them. */
2907 if (tp->speed & LINK_STATUS) 2915 if (tp->speed & LINK_STATUS)
2908 tp->rtl_ops.disable(tp); 2916 tp->rtl_ops.disable(tp);
2909 } 2917 }
@@ -2955,10 +2963,7 @@ static int rtl8152_close(struct net_device *netdev)
2955 * be disable when autoresume occurs, because the 2963 * be disable when autoresume occurs, because the
2956 * netif_running() would be false. 2964 * netif_running() would be false.
2957 */ 2965 */
2958 if (test_bit(SELECTIVE_SUSPEND, &tp->flags)) { 2966 rtl_runtime_suspend_enable(tp, false);
2959 rtl_runtime_suspend_enable(tp, false);
2960 clear_bit(SELECTIVE_SUSPEND, &tp->flags);
2961 }
2962 2967
2963 tasklet_disable(&tp->tl); 2968 tasklet_disable(&tp->tl);
2964 tp->rtl_ops.down(tp); 2969 tp->rtl_ops.down(tp);
@@ -3205,7 +3210,7 @@ static int rtl8152_suspend(struct usb_interface *intf, pm_message_t message)
3205 netif_device_detach(netdev); 3210 netif_device_detach(netdev);
3206 } 3211 }
3207 3212
3208 if (netif_running(netdev)) { 3213 if (netif_running(netdev) && test_bit(WORK_ENABLE, &tp->flags)) {
3209 clear_bit(WORK_ENABLE, &tp->flags); 3214 clear_bit(WORK_ENABLE, &tp->flags);
3210 usb_kill_urb(tp->intr_urb); 3215 usb_kill_urb(tp->intr_urb);
3211 tasklet_disable(&tp->tl); 3216 tasklet_disable(&tp->tl);
@@ -3253,6 +3258,8 @@ static int rtl8152_resume(struct usb_interface *intf)
3253 set_bit(WORK_ENABLE, &tp->flags); 3258 set_bit(WORK_ENABLE, &tp->flags);
3254 } 3259 }
3255 usb_submit_urb(tp->intr_urb, GFP_KERNEL); 3260 usb_submit_urb(tp->intr_urb, GFP_KERNEL);
3261 } else if (test_bit(SELECTIVE_SUSPEND, &tp->flags)) {
3262 clear_bit(SELECTIVE_SUSPEND, &tp->flags);
3256 } 3263 }
3257 3264
3258 mutex_unlock(&tp->control); 3265 mutex_unlock(&tp->control);
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 20615bbd693b..3a6770a65d78 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -1052,6 +1052,21 @@ static void __handle_link_change(struct usbnet *dev)
1052 clear_bit(EVENT_LINK_CHANGE, &dev->flags); 1052 clear_bit(EVENT_LINK_CHANGE, &dev->flags);
1053} 1053}
1054 1054
1055static void usbnet_set_rx_mode(struct net_device *net)
1056{
1057 struct usbnet *dev = netdev_priv(net);
1058
1059 usbnet_defer_kevent(dev, EVENT_SET_RX_MODE);
1060}
1061
1062static void __handle_set_rx_mode(struct usbnet *dev)
1063{
1064 if (dev->driver_info->set_rx_mode)
1065 (dev->driver_info->set_rx_mode)(dev);
1066
1067 clear_bit(EVENT_SET_RX_MODE, &dev->flags);
1068}
1069
1055/* work that cannot be done in interrupt context uses keventd. 1070/* work that cannot be done in interrupt context uses keventd.
1056 * 1071 *
1057 * NOTE: with 2.5 we could do more of this using completion callbacks, 1072 * NOTE: with 2.5 we could do more of this using completion callbacks,
@@ -1157,6 +1172,10 @@ skip_reset:
1157 if (test_bit (EVENT_LINK_CHANGE, &dev->flags)) 1172 if (test_bit (EVENT_LINK_CHANGE, &dev->flags))
1158 __handle_link_change(dev); 1173 __handle_link_change(dev);
1159 1174
1175 if (test_bit (EVENT_SET_RX_MODE, &dev->flags))
1176 __handle_set_rx_mode(dev);
1177
1178
1160 if (dev->flags) 1179 if (dev->flags)
1161 netdev_dbg(dev->net, "kevent done, flags = 0x%lx\n", dev->flags); 1180 netdev_dbg(dev->net, "kevent done, flags = 0x%lx\n", dev->flags);
1162} 1181}
@@ -1525,6 +1544,7 @@ static const struct net_device_ops usbnet_netdev_ops = {
1525 .ndo_stop = usbnet_stop, 1544 .ndo_stop = usbnet_stop,
1526 .ndo_start_xmit = usbnet_start_xmit, 1545 .ndo_start_xmit = usbnet_start_xmit,
1527 .ndo_tx_timeout = usbnet_tx_timeout, 1546 .ndo_tx_timeout = usbnet_tx_timeout,
1547 .ndo_set_rx_mode = usbnet_set_rx_mode,
1528 .ndo_change_mtu = usbnet_change_mtu, 1548 .ndo_change_mtu = usbnet_change_mtu,
1529 .ndo_set_mac_address = eth_mac_addr, 1549 .ndo_set_mac_address = eth_mac_addr,
1530 .ndo_validate_addr = eth_validate_addr, 1550 .ndo_validate_addr = eth_validate_addr,
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index d75256bd1a6a..ec2a8b41ed41 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -491,8 +491,17 @@ static void receive_buf(struct receive_queue *rq, void *buf, unsigned int len)
491 skb_shinfo(skb)->gso_type = SKB_GSO_TCPV4; 491 skb_shinfo(skb)->gso_type = SKB_GSO_TCPV4;
492 break; 492 break;
493 case VIRTIO_NET_HDR_GSO_UDP: 493 case VIRTIO_NET_HDR_GSO_UDP:
494 {
495 static bool warned;
496
497 if (!warned) {
498 warned = true;
499 netdev_warn(dev,
500 "host using disabled UFO feature; please fix it\n");
501 }
494 skb_shinfo(skb)->gso_type = SKB_GSO_UDP; 502 skb_shinfo(skb)->gso_type = SKB_GSO_UDP;
495 break; 503 break;
504 }
496 case VIRTIO_NET_HDR_GSO_TCPV6: 505 case VIRTIO_NET_HDR_GSO_TCPV6:
497 skb_shinfo(skb)->gso_type = SKB_GSO_TCPV6; 506 skb_shinfo(skb)->gso_type = SKB_GSO_TCPV6;
498 break; 507 break;
@@ -881,8 +890,6 @@ static int xmit_skb(struct send_queue *sq, struct sk_buff *skb)
881 hdr->hdr.gso_type = VIRTIO_NET_HDR_GSO_TCPV4; 890 hdr->hdr.gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
882 else if (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV6) 891 else if (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV6)
883 hdr->hdr.gso_type = VIRTIO_NET_HDR_GSO_TCPV6; 892 hdr->hdr.gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
884 else if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP)
885 hdr->hdr.gso_type = VIRTIO_NET_HDR_GSO_UDP;
886 else 893 else
887 BUG(); 894 BUG();
888 if (skb_shinfo(skb)->gso_type & SKB_GSO_TCP_ECN) 895 if (skb_shinfo(skb)->gso_type & SKB_GSO_TCP_ECN)
@@ -1705,7 +1712,7 @@ static int virtnet_probe(struct virtio_device *vdev)
1705 dev->features |= NETIF_F_HW_CSUM|NETIF_F_SG|NETIF_F_FRAGLIST; 1712 dev->features |= NETIF_F_HW_CSUM|NETIF_F_SG|NETIF_F_FRAGLIST;
1706 1713
1707 if (virtio_has_feature(vdev, VIRTIO_NET_F_GSO)) { 1714 if (virtio_has_feature(vdev, VIRTIO_NET_F_GSO)) {
1708 dev->hw_features |= NETIF_F_TSO | NETIF_F_UFO 1715 dev->hw_features |= NETIF_F_TSO
1709 | NETIF_F_TSO_ECN | NETIF_F_TSO6; 1716 | NETIF_F_TSO_ECN | NETIF_F_TSO6;
1710 } 1717 }
1711 /* Individual feature bits: what can host handle? */ 1718 /* Individual feature bits: what can host handle? */
@@ -1715,11 +1722,9 @@ static int virtnet_probe(struct virtio_device *vdev)
1715 dev->hw_features |= NETIF_F_TSO6; 1722 dev->hw_features |= NETIF_F_TSO6;
1716 if (virtio_has_feature(vdev, VIRTIO_NET_F_HOST_ECN)) 1723 if (virtio_has_feature(vdev, VIRTIO_NET_F_HOST_ECN))
1717 dev->hw_features |= NETIF_F_TSO_ECN; 1724 dev->hw_features |= NETIF_F_TSO_ECN;
1718 if (virtio_has_feature(vdev, VIRTIO_NET_F_HOST_UFO))
1719 dev->hw_features |= NETIF_F_UFO;
1720 1725
1721 if (gso) 1726 if (gso)
1722 dev->features |= dev->hw_features & (NETIF_F_ALL_TSO|NETIF_F_UFO); 1727 dev->features |= dev->hw_features & NETIF_F_ALL_TSO;
1723 /* (!csum && gso) case will be fixed by register_netdev() */ 1728 /* (!csum && gso) case will be fixed by register_netdev() */
1724 } 1729 }
1725 if (virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_CSUM)) 1730 if (virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_CSUM))
@@ -1757,8 +1762,7 @@ static int virtnet_probe(struct virtio_device *vdev)
1757 /* If we can receive ANY GSO packets, we must allocate large ones. */ 1762 /* If we can receive ANY GSO packets, we must allocate large ones. */
1758 if (virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO4) || 1763 if (virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO4) ||
1759 virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO6) || 1764 virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO6) ||
1760 virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_ECN) || 1765 virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_ECN))
1761 virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_UFO))
1762 vi->big_packets = true; 1766 vi->big_packets = true;
1763 1767
1764 if (virtio_has_feature(vdev, VIRTIO_NET_F_MRG_RXBUF)) 1768 if (virtio_has_feature(vdev, VIRTIO_NET_F_MRG_RXBUF))
@@ -1952,9 +1956,9 @@ static struct virtio_device_id id_table[] = {
1952static unsigned int features[] = { 1956static unsigned int features[] = {
1953 VIRTIO_NET_F_CSUM, VIRTIO_NET_F_GUEST_CSUM, 1957 VIRTIO_NET_F_CSUM, VIRTIO_NET_F_GUEST_CSUM,
1954 VIRTIO_NET_F_GSO, VIRTIO_NET_F_MAC, 1958 VIRTIO_NET_F_GSO, VIRTIO_NET_F_MAC,
1955 VIRTIO_NET_F_HOST_TSO4, VIRTIO_NET_F_HOST_UFO, VIRTIO_NET_F_HOST_TSO6, 1959 VIRTIO_NET_F_HOST_TSO4, VIRTIO_NET_F_HOST_TSO6,
1956 VIRTIO_NET_F_HOST_ECN, VIRTIO_NET_F_GUEST_TSO4, VIRTIO_NET_F_GUEST_TSO6, 1960 VIRTIO_NET_F_HOST_ECN, VIRTIO_NET_F_GUEST_TSO4, VIRTIO_NET_F_GUEST_TSO6,
1957 VIRTIO_NET_F_GUEST_ECN, VIRTIO_NET_F_GUEST_UFO, 1961 VIRTIO_NET_F_GUEST_ECN,
1958 VIRTIO_NET_F_MRG_RXBUF, VIRTIO_NET_F_STATUS, VIRTIO_NET_F_CTRL_VQ, 1962 VIRTIO_NET_F_MRG_RXBUF, VIRTIO_NET_F_STATUS, VIRTIO_NET_F_CTRL_VQ,
1959 VIRTIO_NET_F_CTRL_RX, VIRTIO_NET_F_CTRL_VLAN, 1963 VIRTIO_NET_F_CTRL_RX, VIRTIO_NET_F_CTRL_VLAN,
1960 VIRTIO_NET_F_GUEST_ANNOUNCE, VIRTIO_NET_F_MQ, 1964 VIRTIO_NET_F_GUEST_ANNOUNCE, VIRTIO_NET_F_MQ,
diff --git a/drivers/net/wireless/ath/ath.h b/drivers/net/wireless/ath/ath.h
index e5ba6faf3281..86907e5ba6ca 100644
--- a/drivers/net/wireless/ath/ath.h
+++ b/drivers/net/wireless/ath/ath.h
@@ -80,6 +80,7 @@ struct reg_dmn_pair_mapping {
80 80
81struct ath_regulatory { 81struct ath_regulatory {
82 char alpha2[2]; 82 char alpha2[2];
83 enum nl80211_dfs_regions region;
83 u16 country_code; 84 u16 country_code;
84 u16 max_power_level; 85 u16 max_power_level;
85 u16 current_rd; 86 u16 current_rd;
diff --git a/drivers/net/wireless/ath/ath9k/common.c b/drivers/net/wireless/ath/ath9k/common.c
index c6dd7f1fed65..33b0c7aef2ea 100644
--- a/drivers/net/wireless/ath/ath9k/common.c
+++ b/drivers/net/wireless/ath/ath9k/common.c
@@ -368,11 +368,11 @@ void ath9k_cmn_update_txpow(struct ath_hw *ah, u16 cur_txpow,
368{ 368{
369 struct ath_regulatory *reg = ath9k_hw_regulatory(ah); 369 struct ath_regulatory *reg = ath9k_hw_regulatory(ah);
370 370
371 if (reg->power_limit != new_txpow) { 371 if (reg->power_limit != new_txpow)
372 ath9k_hw_set_txpowerlimit(ah, new_txpow, false); 372 ath9k_hw_set_txpowerlimit(ah, new_txpow, false);
373 /* read back in case value is clamped */ 373
374 *txpower = reg->max_power_level; 374 /* read back in case value is clamped */
375 } 375 *txpower = reg->max_power_level;
376} 376}
377EXPORT_SYMBOL(ath9k_cmn_update_txpow); 377EXPORT_SYMBOL(ath9k_cmn_update_txpow);
378 378
diff --git a/drivers/net/wireless/ath/ath9k/debug.c b/drivers/net/wireless/ath/ath9k/debug.c
index 46f20a309b5f..5c45e787814e 100644
--- a/drivers/net/wireless/ath/ath9k/debug.c
+++ b/drivers/net/wireless/ath/ath9k/debug.c
@@ -455,7 +455,7 @@ static ssize_t read_file_dma(struct file *file, char __user *user_buf,
455 "%2d %2x %1x %2x %2x\n", 455 "%2d %2x %1x %2x %2x\n",
456 i, (*qcuBase & (0x7 << qcuOffset)) >> qcuOffset, 456 i, (*qcuBase & (0x7 << qcuOffset)) >> qcuOffset,
457 (*qcuBase & (0x8 << qcuOffset)) >> (qcuOffset + 3), 457 (*qcuBase & (0x8 << qcuOffset)) >> (qcuOffset + 3),
458 val[2] & (0x7 << (i * 3)) >> (i * 3), 458 (val[2] & (0x7 << (i * 3))) >> (i * 3),
459 (*dcuBase & (0x1f << dcuOffset)) >> dcuOffset); 459 (*dcuBase & (0x1f << dcuOffset)) >> dcuOffset);
460 } 460 }
461 461
diff --git a/drivers/net/wireless/ath/ath9k/init.c b/drivers/net/wireless/ath/ath9k/init.c
index 156a944134dc..3bd030494986 100644
--- a/drivers/net/wireless/ath/ath9k/init.c
+++ b/drivers/net/wireless/ath/ath9k/init.c
@@ -734,6 +734,32 @@ static const struct ieee80211_iface_combination if_comb[] = {
734#endif 734#endif
735}; 735};
736 736
737#ifdef CONFIG_ATH9K_CHANNEL_CONTEXT
738static void ath9k_set_mcc_capab(struct ath_softc *sc, struct ieee80211_hw *hw)
739{
740 struct ath_hw *ah = sc->sc_ah;
741 struct ath_common *common = ath9k_hw_common(ah);
742
743 if (!ath9k_is_chanctx_enabled())
744 return;
745
746 hw->flags |= IEEE80211_HW_QUEUE_CONTROL;
747 hw->queues = ATH9K_NUM_TX_QUEUES;
748 hw->offchannel_tx_hw_queue = hw->queues - 1;
749 hw->wiphy->interface_modes &= ~ BIT(NL80211_IFTYPE_WDS);
750 hw->wiphy->iface_combinations = if_comb_multi;
751 hw->wiphy->n_iface_combinations = ARRAY_SIZE(if_comb_multi);
752 hw->wiphy->max_scan_ssids = 255;
753 hw->wiphy->max_scan_ie_len = IEEE80211_MAX_DATA_LEN;
754 hw->wiphy->max_remain_on_channel_duration = 10000;
755 hw->chanctx_data_size = sizeof(void *);
756 hw->extra_beacon_tailroom =
757 sizeof(struct ieee80211_p2p_noa_attr) + 9;
758
759 ath_dbg(common, CHAN_CTX, "Use channel contexts\n");
760}
761#endif /* CONFIG_ATH9K_CHANNEL_CONTEXT */
762
737static void ath9k_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw) 763static void ath9k_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw)
738{ 764{
739 struct ath_hw *ah = sc->sc_ah; 765 struct ath_hw *ah = sc->sc_ah;
@@ -746,7 +772,6 @@ static void ath9k_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw)
746 IEEE80211_HW_SPECTRUM_MGMT | 772 IEEE80211_HW_SPECTRUM_MGMT |
747 IEEE80211_HW_REPORTS_TX_ACK_STATUS | 773 IEEE80211_HW_REPORTS_TX_ACK_STATUS |
748 IEEE80211_HW_SUPPORTS_RC_TABLE | 774 IEEE80211_HW_SUPPORTS_RC_TABLE |
749 IEEE80211_HW_QUEUE_CONTROL |
750 IEEE80211_HW_SUPPORTS_HT_CCK_RATES; 775 IEEE80211_HW_SUPPORTS_HT_CCK_RATES;
751 776
752 if (ath9k_ps_enable) 777 if (ath9k_ps_enable)
@@ -781,24 +806,6 @@ static void ath9k_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw)
781 hw->wiphy->n_iface_combinations = ARRAY_SIZE(if_comb); 806 hw->wiphy->n_iface_combinations = ARRAY_SIZE(if_comb);
782 } 807 }
783 808
784#ifdef CONFIG_ATH9K_CHANNEL_CONTEXT
785
786 if (ath9k_is_chanctx_enabled()) {
787 hw->wiphy->interface_modes &= ~ BIT(NL80211_IFTYPE_WDS);
788 hw->wiphy->iface_combinations = if_comb_multi;
789 hw->wiphy->n_iface_combinations = ARRAY_SIZE(if_comb_multi);
790 hw->wiphy->max_scan_ssids = 255;
791 hw->wiphy->max_scan_ie_len = IEEE80211_MAX_DATA_LEN;
792 hw->wiphy->max_remain_on_channel_duration = 10000;
793 hw->chanctx_data_size = sizeof(void *);
794 hw->extra_beacon_tailroom =
795 sizeof(struct ieee80211_p2p_noa_attr) + 9;
796
797 ath_dbg(common, CHAN_CTX, "Use channel contexts\n");
798 }
799
800#endif /* CONFIG_ATH9K_CHANNEL_CONTEXT */
801
802 hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT; 809 hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT;
803 810
804 hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN; 811 hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN;
@@ -808,12 +815,7 @@ static void ath9k_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw)
808 hw->wiphy->flags |= WIPHY_FLAG_HAS_CHANNEL_SWITCH; 815 hw->wiphy->flags |= WIPHY_FLAG_HAS_CHANNEL_SWITCH;
809 hw->wiphy->flags |= WIPHY_FLAG_AP_UAPSD; 816 hw->wiphy->flags |= WIPHY_FLAG_AP_UAPSD;
810 817
811 /* allow 4 queues per channel context + 818 hw->queues = 4;
812 * 1 cab queue + 1 offchannel tx queue
813 */
814 hw->queues = ATH9K_NUM_TX_QUEUES;
815 /* last queue for offchannel */
816 hw->offchannel_tx_hw_queue = hw->queues - 1;
817 hw->max_rates = 4; 819 hw->max_rates = 4;
818 hw->max_listen_interval = 10; 820 hw->max_listen_interval = 10;
819 hw->max_rate_tries = 10; 821 hw->max_rate_tries = 10;
@@ -837,6 +839,9 @@ static void ath9k_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw)
837 hw->wiphy->bands[IEEE80211_BAND_5GHZ] = 839 hw->wiphy->bands[IEEE80211_BAND_5GHZ] =
838 &common->sbands[IEEE80211_BAND_5GHZ]; 840 &common->sbands[IEEE80211_BAND_5GHZ];
839 841
842#ifdef CONFIG_ATH9K_CHANNEL_CONTEXT
843 ath9k_set_mcc_capab(sc, hw);
844#endif
840 ath9k_init_wow(hw); 845 ath9k_init_wow(hw);
841 ath9k_cmn_reload_chainmask(ah); 846 ath9k_cmn_reload_chainmask(ah);
842 847
diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
index 6f6a974f7fdb..30c66dfcd7a0 100644
--- a/drivers/net/wireless/ath/ath9k/main.c
+++ b/drivers/net/wireless/ath/ath9k/main.c
@@ -1162,6 +1162,9 @@ static void ath9k_assign_hw_queues(struct ieee80211_hw *hw,
1162{ 1162{
1163 int i; 1163 int i;
1164 1164
1165 if (!ath9k_is_chanctx_enabled())
1166 return;
1167
1165 for (i = 0; i < IEEE80211_NUM_ACS; i++) 1168 for (i = 0; i < IEEE80211_NUM_ACS; i++)
1166 vif->hw_queue[i] = i; 1169 vif->hw_queue[i] = i;
1167 1170
diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c
index 493a183d0aaf..d6e54a3c88f6 100644
--- a/drivers/net/wireless/ath/ath9k/xmit.c
+++ b/drivers/net/wireless/ath/ath9k/xmit.c
@@ -169,7 +169,10 @@ static void ath_txq_skb_done(struct ath_softc *sc, struct ath_txq *txq,
169 169
170 if (txq->stopped && 170 if (txq->stopped &&
171 txq->pending_frames < sc->tx.txq_max_pending[q]) { 171 txq->pending_frames < sc->tx.txq_max_pending[q]) {
172 ieee80211_wake_queue(sc->hw, info->hw_queue); 172 if (ath9k_is_chanctx_enabled())
173 ieee80211_wake_queue(sc->hw, info->hw_queue);
174 else
175 ieee80211_wake_queue(sc->hw, q);
173 txq->stopped = false; 176 txq->stopped = false;
174 } 177 }
175} 178}
@@ -2247,7 +2250,10 @@ int ath_tx_start(struct ieee80211_hw *hw, struct sk_buff *skb,
2247 fi->txq = q; 2250 fi->txq = q;
2248 if (++txq->pending_frames > sc->tx.txq_max_pending[q] && 2251 if (++txq->pending_frames > sc->tx.txq_max_pending[q] &&
2249 !txq->stopped) { 2252 !txq->stopped) {
2250 ieee80211_stop_queue(sc->hw, info->hw_queue); 2253 if (ath9k_is_chanctx_enabled())
2254 ieee80211_stop_queue(sc->hw, info->hw_queue);
2255 else
2256 ieee80211_stop_queue(sc->hw, q);
2251 txq->stopped = true; 2257 txq->stopped = true;
2252 } 2258 }
2253 } 2259 }
diff --git a/drivers/net/wireless/ath/regd.c b/drivers/net/wireless/ath/regd.c
index 415393dfb6fc..06ea6cc9e30a 100644
--- a/drivers/net/wireless/ath/regd.c
+++ b/drivers/net/wireless/ath/regd.c
@@ -515,6 +515,7 @@ void ath_reg_notifier_apply(struct wiphy *wiphy,
515 if (!request) 515 if (!request)
516 return; 516 return;
517 517
518 reg->region = request->dfs_region;
518 switch (request->initiator) { 519 switch (request->initiator) {
519 case NL80211_REGDOM_SET_BY_CORE: 520 case NL80211_REGDOM_SET_BY_CORE:
520 /* 521 /*
@@ -779,6 +780,19 @@ u32 ath_regd_get_band_ctl(struct ath_regulatory *reg,
779 return SD_NO_CTL; 780 return SD_NO_CTL;
780 } 781 }
781 782
783 if (ath_regd_get_eepromRD(reg) == CTRY_DEFAULT) {
784 switch (reg->region) {
785 case NL80211_DFS_FCC:
786 return CTL_FCC;
787 case NL80211_DFS_ETSI:
788 return CTL_ETSI;
789 case NL80211_DFS_JP:
790 return CTL_MKK;
791 default:
792 break;
793 }
794 }
795
782 switch (band) { 796 switch (band) {
783 case IEEE80211_BAND_2GHZ: 797 case IEEE80211_BAND_2GHZ:
784 return reg->regpair->reg_2ghz_ctl; 798 return reg->regpair->reg_2ghz_ctl;
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
index f55f625fd06b..d20d4e6f391a 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
@@ -670,7 +670,6 @@ static int brcmf_sdio_get_fwnames(struct brcmf_chip *ci,
670 struct brcmf_sdio_dev *sdiodev) 670 struct brcmf_sdio_dev *sdiodev)
671{ 671{
672 int i; 672 int i;
673 uint fw_len, nv_len;
674 char end; 673 char end;
675 674
676 for (i = 0; i < ARRAY_SIZE(brcmf_fwname_data); i++) { 675 for (i = 0; i < ARRAY_SIZE(brcmf_fwname_data); i++) {
@@ -684,25 +683,25 @@ static int brcmf_sdio_get_fwnames(struct brcmf_chip *ci,
684 return -ENODEV; 683 return -ENODEV;
685 } 684 }
686 685
687 fw_len = sizeof(sdiodev->fw_name) - 1;
688 nv_len = sizeof(sdiodev->nvram_name) - 1;
689 /* check if firmware path is provided by module parameter */ 686 /* check if firmware path is provided by module parameter */
690 if (brcmf_firmware_path[0] != '\0') { 687 if (brcmf_firmware_path[0] != '\0') {
691 strncpy(sdiodev->fw_name, brcmf_firmware_path, fw_len); 688 strlcpy(sdiodev->fw_name, brcmf_firmware_path,
692 strncpy(sdiodev->nvram_name, brcmf_firmware_path, nv_len); 689 sizeof(sdiodev->fw_name));
693 fw_len -= strlen(sdiodev->fw_name); 690 strlcpy(sdiodev->nvram_name, brcmf_firmware_path,
694 nv_len -= strlen(sdiodev->nvram_name); 691 sizeof(sdiodev->nvram_name));
695 692
696 end = brcmf_firmware_path[strlen(brcmf_firmware_path) - 1]; 693 end = brcmf_firmware_path[strlen(brcmf_firmware_path) - 1];
697 if (end != '/') { 694 if (end != '/') {
698 strncat(sdiodev->fw_name, "/", fw_len); 695 strlcat(sdiodev->fw_name, "/",
699 strncat(sdiodev->nvram_name, "/", nv_len); 696 sizeof(sdiodev->fw_name));
700 fw_len--; 697 strlcat(sdiodev->nvram_name, "/",
701 nv_len--; 698 sizeof(sdiodev->nvram_name));
702 } 699 }
703 } 700 }
704 strncat(sdiodev->fw_name, brcmf_fwname_data[i].bin, fw_len); 701 strlcat(sdiodev->fw_name, brcmf_fwname_data[i].bin,
705 strncat(sdiodev->nvram_name, brcmf_fwname_data[i].nv, nv_len); 702 sizeof(sdiodev->fw_name));
703 strlcat(sdiodev->nvram_name, brcmf_fwname_data[i].nv,
704 sizeof(sdiodev->nvram_name));
706 705
707 return 0; 706 return 0;
708} 707}
diff --git a/drivers/net/wireless/iwlwifi/dvm/mac80211.c b/drivers/net/wireless/iwlwifi/dvm/mac80211.c
index 2364a3c09b9e..cae692ff1013 100644
--- a/drivers/net/wireless/iwlwifi/dvm/mac80211.c
+++ b/drivers/net/wireless/iwlwifi/dvm/mac80211.c
@@ -1095,6 +1095,7 @@ static void iwlagn_mac_flush(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
1095 u32 queues, bool drop) 1095 u32 queues, bool drop)
1096{ 1096{
1097 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw); 1097 struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
1098 u32 scd_queues;
1098 1099
1099 mutex_lock(&priv->mutex); 1100 mutex_lock(&priv->mutex);
1100 IWL_DEBUG_MAC80211(priv, "enter\n"); 1101 IWL_DEBUG_MAC80211(priv, "enter\n");
@@ -1108,18 +1109,19 @@ static void iwlagn_mac_flush(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
1108 goto done; 1109 goto done;
1109 } 1110 }
1110 1111
1111 /* 1112 scd_queues = BIT(priv->cfg->base_params->num_of_queues) - 1;
1112 * mac80211 will not push any more frames for transmit 1113 scd_queues &= ~(BIT(IWL_IPAN_CMD_QUEUE_NUM) |
1113 * until the flush is completed 1114 BIT(IWL_DEFAULT_CMD_QUEUE_NUM));
1114 */ 1115
1115 if (drop) { 1116 if (vif)
1116 IWL_DEBUG_MAC80211(priv, "send flush command\n"); 1117 scd_queues &= ~BIT(vif->hw_queue[IEEE80211_AC_VO]);
1117 if (iwlagn_txfifo_flush(priv, 0)) { 1118
1118 IWL_ERR(priv, "flush request fail\n"); 1119 IWL_DEBUG_TX_QUEUES(priv, "Flushing SCD queues: 0x%x\n", scd_queues);
1119 goto done; 1120 if (iwlagn_txfifo_flush(priv, scd_queues)) {
1120 } 1121 IWL_ERR(priv, "flush request fail\n");
1122 goto done;
1121 } 1123 }
1122 IWL_DEBUG_MAC80211(priv, "wait transmit/flush all frames\n"); 1124 IWL_DEBUG_TX_QUEUES(priv, "wait transmit/flush all frames\n");
1123 iwl_trans_wait_tx_queue_empty(priv->trans, 0xffffffff); 1125 iwl_trans_wait_tx_queue_empty(priv->trans, 0xffffffff);
1124done: 1126done:
1125 mutex_unlock(&priv->mutex); 1127 mutex_unlock(&priv->mutex);
diff --git a/drivers/net/wireless/iwlwifi/iwl-8000.c b/drivers/net/wireless/iwlwifi/iwl-8000.c
index e4351487ca72..d2b7234b1c73 100644
--- a/drivers/net/wireless/iwlwifi/iwl-8000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-8000.c
@@ -82,7 +82,8 @@
82#define IWL8000_TX_POWER_VERSION 0xffff /* meaningless */ 82#define IWL8000_TX_POWER_VERSION 0xffff /* meaningless */
83 83
84#define IWL8000_FW_PRE "iwlwifi-8000" 84#define IWL8000_FW_PRE "iwlwifi-8000"
85#define IWL8000_MODULE_FIRMWARE(api) IWL8000_FW_PRE __stringify(api) ".ucode" 85#define IWL8000_MODULE_FIRMWARE(api) \
86 IWL8000_FW_PRE "-" __stringify(api) ".ucode"
86 87
87#define NVM_HW_SECTION_NUM_FAMILY_8000 10 88#define NVM_HW_SECTION_NUM_FAMILY_8000 10
88#define DEFAULT_NVM_FILE_FAMILY_8000 "iwl_nvm_8000.bin" 89#define DEFAULT_NVM_FILE_FAMILY_8000 "iwl_nvm_8000.bin"
diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h
index 9eb85249e89c..d8fc548c0d6c 100644
--- a/drivers/net/wireless/iwlwifi/iwl-trans.h
+++ b/drivers/net/wireless/iwlwifi/iwl-trans.h
@@ -563,6 +563,7 @@ enum iwl_trans_state {
563 * Set during transport allocation. 563 * Set during transport allocation.
564 * @hw_id_str: a string with info about HW ID. Set during transport allocation. 564 * @hw_id_str: a string with info about HW ID. Set during transport allocation.
565 * @pm_support: set to true in start_hw if link pm is supported 565 * @pm_support: set to true in start_hw if link pm is supported
566 * @ltr_enabled: set to true if the LTR is enabled
566 * @dev_cmd_pool: pool for Tx cmd allocation - for internal use only. 567 * @dev_cmd_pool: pool for Tx cmd allocation - for internal use only.
567 * The user should use iwl_trans_{alloc,free}_tx_cmd. 568 * The user should use iwl_trans_{alloc,free}_tx_cmd.
568 * @dev_cmd_headroom: room needed for the transport's private use before the 569 * @dev_cmd_headroom: room needed for the transport's private use before the
@@ -589,6 +590,7 @@ struct iwl_trans {
589 u8 rx_mpdu_cmd, rx_mpdu_cmd_hdr_size; 590 u8 rx_mpdu_cmd, rx_mpdu_cmd_hdr_size;
590 591
591 bool pm_support; 592 bool pm_support;
593 bool ltr_enabled;
592 594
593 /* The following fields are internal only */ 595 /* The following fields are internal only */
594 struct kmem_cache *dev_cmd_pool; 596 struct kmem_cache *dev_cmd_pool;
diff --git a/drivers/net/wireless/iwlwifi/mvm/coex.c b/drivers/net/wireless/iwlwifi/mvm/coex.c
index 8df2021f9856..da2ffb785194 100644
--- a/drivers/net/wireless/iwlwifi/mvm/coex.c
+++ b/drivers/net/wireless/iwlwifi/mvm/coex.c
@@ -303,8 +303,8 @@ static const __le64 iwl_ci_mask[][3] = {
303}; 303};
304 304
305static const __le32 iwl_bt_mprio_lut[BT_COEX_MULTI_PRIO_LUT_SIZE] = { 305static const __le32 iwl_bt_mprio_lut[BT_COEX_MULTI_PRIO_LUT_SIZE] = {
306 cpu_to_le32(0x28412201), 306 cpu_to_le32(0x2e402280),
307 cpu_to_le32(0x11118451), 307 cpu_to_le32(0x7711a751),
308}; 308};
309 309
310struct corunning_block_luts { 310struct corunning_block_luts {
diff --git a/drivers/net/wireless/iwlwifi/mvm/coex_legacy.c b/drivers/net/wireless/iwlwifi/mvm/coex_legacy.c
index 585c0ab4a3ec..8a1d2f33d5b7 100644
--- a/drivers/net/wireless/iwlwifi/mvm/coex_legacy.c
+++ b/drivers/net/wireless/iwlwifi/mvm/coex_legacy.c
@@ -291,8 +291,8 @@ static const __le64 iwl_ci_mask[][3] = {
291}; 291};
292 292
293static const __le32 iwl_bt_mprio_lut[BT_COEX_MULTI_PRIO_LUT_SIZE] = { 293static const __le32 iwl_bt_mprio_lut[BT_COEX_MULTI_PRIO_LUT_SIZE] = {
294 cpu_to_le32(0x28412201), 294 cpu_to_le32(0x2e402280),
295 cpu_to_le32(0x11118451), 295 cpu_to_le32(0x7711a751),
296}; 296};
297 297
298struct corunning_block_luts { 298struct corunning_block_luts {
diff --git a/drivers/net/wireless/iwlwifi/mvm/fw-api-power.h b/drivers/net/wireless/iwlwifi/mvm/fw-api-power.h
index 27dd86395b39..2fd8ad4633e0 100644
--- a/drivers/net/wireless/iwlwifi/mvm/fw-api-power.h
+++ b/drivers/net/wireless/iwlwifi/mvm/fw-api-power.h
@@ -68,13 +68,46 @@
68 68
69/* Power Management Commands, Responses, Notifications */ 69/* Power Management Commands, Responses, Notifications */
70 70
71/**
72 * enum iwl_ltr_config_flags - masks for LTR config command flags
73 * @LTR_CFG_FLAG_FEATURE_ENABLE: Feature operational status
74 * @LTR_CFG_FLAG_HW_DIS_ON_SHADOW_REG_ACCESS: allow LTR change on shadow
75 * memory access
76 * @LTR_CFG_FLAG_HW_EN_SHRT_WR_THROUGH: allow LTR msg send on ANY LTR
77 * reg change
78 * @LTR_CFG_FLAG_HW_DIS_ON_D0_2_D3: allow LTR msg send on transition from
79 * D0 to D3
80 * @LTR_CFG_FLAG_SW_SET_SHORT: fixed static short LTR register
81 * @LTR_CFG_FLAG_SW_SET_LONG: fixed static short LONG register
82 * @LTR_CFG_FLAG_DENIE_C10_ON_PD: allow going into C10 on PD
83 */
84enum iwl_ltr_config_flags {
85 LTR_CFG_FLAG_FEATURE_ENABLE = BIT(0),
86 LTR_CFG_FLAG_HW_DIS_ON_SHADOW_REG_ACCESS = BIT(1),
87 LTR_CFG_FLAG_HW_EN_SHRT_WR_THROUGH = BIT(2),
88 LTR_CFG_FLAG_HW_DIS_ON_D0_2_D3 = BIT(3),
89 LTR_CFG_FLAG_SW_SET_SHORT = BIT(4),
90 LTR_CFG_FLAG_SW_SET_LONG = BIT(5),
91 LTR_CFG_FLAG_DENIE_C10_ON_PD = BIT(6),
92};
93
94/**
95 * struct iwl_ltr_config_cmd - configures the LTR
96 * @flags: See %enum iwl_ltr_config_flags
97 */
98struct iwl_ltr_config_cmd {
99 __le32 flags;
100 __le32 static_long;
101 __le32 static_short;
102} __packed;
103
71/* Radio LP RX Energy Threshold measured in dBm */ 104/* Radio LP RX Energy Threshold measured in dBm */
72#define POWER_LPRX_RSSI_THRESHOLD 75 105#define POWER_LPRX_RSSI_THRESHOLD 75
73#define POWER_LPRX_RSSI_THRESHOLD_MAX 94 106#define POWER_LPRX_RSSI_THRESHOLD_MAX 94
74#define POWER_LPRX_RSSI_THRESHOLD_MIN 30 107#define POWER_LPRX_RSSI_THRESHOLD_MIN 30
75 108
76/** 109/**
77 * enum iwl_scan_flags - masks for power table command flags 110 * enum iwl_power_flags - masks for power table command flags
78 * @POWER_FLAGS_POWER_SAVE_ENA_MSK: '1' Allow to save power by turning off 111 * @POWER_FLAGS_POWER_SAVE_ENA_MSK: '1' Allow to save power by turning off
79 * receiver and transmitter. '0' - does not allow. 112 * receiver and transmitter. '0' - does not allow.
80 * @POWER_FLAGS_POWER_MANAGEMENT_ENA_MSK: '0' Driver disables power management, 113 * @POWER_FLAGS_POWER_MANAGEMENT_ENA_MSK: '0' Driver disables power management,
diff --git a/drivers/net/wireless/iwlwifi/mvm/fw-api.h b/drivers/net/wireless/iwlwifi/mvm/fw-api.h
index 667a92274c87..c62575d86bcd 100644
--- a/drivers/net/wireless/iwlwifi/mvm/fw-api.h
+++ b/drivers/net/wireless/iwlwifi/mvm/fw-api.h
@@ -157,6 +157,7 @@ enum {
157 /* Power - legacy power table command */ 157 /* Power - legacy power table command */
158 POWER_TABLE_CMD = 0x77, 158 POWER_TABLE_CMD = 0x77,
159 PSM_UAPSD_AP_MISBEHAVING_NOTIFICATION = 0x78, 159 PSM_UAPSD_AP_MISBEHAVING_NOTIFICATION = 0x78,
160 LTR_CONFIG = 0xee,
160 161
161 /* Thermal Throttling*/ 162 /* Thermal Throttling*/
162 REPLY_THERMAL_MNG_BACKOFF = 0x7e, 163 REPLY_THERMAL_MNG_BACKOFF = 0x7e,
diff --git a/drivers/net/wireless/iwlwifi/mvm/fw.c b/drivers/net/wireless/iwlwifi/mvm/fw.c
index 23fd711a67e4..e0d9f19650b0 100644
--- a/drivers/net/wireless/iwlwifi/mvm/fw.c
+++ b/drivers/net/wireless/iwlwifi/mvm/fw.c
@@ -480,6 +480,15 @@ int iwl_mvm_up(struct iwl_mvm *mvm)
480 /* Initialize tx backoffs to the minimal possible */ 480 /* Initialize tx backoffs to the minimal possible */
481 iwl_mvm_tt_tx_backoff(mvm, 0); 481 iwl_mvm_tt_tx_backoff(mvm, 0);
482 482
483 if (mvm->trans->ltr_enabled) {
484 struct iwl_ltr_config_cmd cmd = {
485 .flags = cpu_to_le32(LTR_CFG_FLAG_FEATURE_ENABLE),
486 };
487
488 WARN_ON(iwl_mvm_send_cmd_pdu(mvm, LTR_CONFIG, 0,
489 sizeof(cmd), &cmd));
490 }
491
483 ret = iwl_mvm_power_update_device(mvm); 492 ret = iwl_mvm_power_update_device(mvm);
484 if (ret) 493 if (ret)
485 goto error; 494 goto error;
diff --git a/drivers/net/wireless/iwlwifi/mvm/mac80211.c b/drivers/net/wireless/iwlwifi/mvm/mac80211.c
index c7a73c68bdab..585fe5b7100f 100644
--- a/drivers/net/wireless/iwlwifi/mvm/mac80211.c
+++ b/drivers/net/wireless/iwlwifi/mvm/mac80211.c
@@ -526,7 +526,8 @@ static void iwl_mvm_mac_tx(struct ieee80211_hw *hw,
526 } 526 }
527 527
528 if (IEEE80211_SKB_CB(skb)->hw_queue == IWL_MVM_OFFCHANNEL_QUEUE && 528 if (IEEE80211_SKB_CB(skb)->hw_queue == IWL_MVM_OFFCHANNEL_QUEUE &&
529 !test_bit(IWL_MVM_STATUS_ROC_RUNNING, &mvm->status)) 529 !test_bit(IWL_MVM_STATUS_ROC_RUNNING, &mvm->status) &&
530 !test_bit(IWL_MVM_STATUS_ROC_AUX_RUNNING, &mvm->status))
530 goto drop; 531 goto drop;
531 532
532 /* treat non-bufferable MMPDUs as broadcast if sta is sleeping */ 533 /* treat non-bufferable MMPDUs as broadcast if sta is sleeping */
@@ -1734,6 +1735,13 @@ iwl_mvm_bss_info_changed_ap_ibss(struct iwl_mvm *mvm,
1734 if (changes & BSS_CHANGED_BEACON && 1735 if (changes & BSS_CHANGED_BEACON &&
1735 iwl_mvm_mac_ctxt_beacon_changed(mvm, vif)) 1736 iwl_mvm_mac_ctxt_beacon_changed(mvm, vif))
1736 IWL_WARN(mvm, "Failed updating beacon data\n"); 1737 IWL_WARN(mvm, "Failed updating beacon data\n");
1738
1739 if (changes & BSS_CHANGED_TXPOWER) {
1740 IWL_DEBUG_CALIB(mvm, "Changing TX Power to %d\n",
1741 bss_conf->txpower);
1742 iwl_mvm_set_tx_power(mvm, vif, bss_conf->txpower);
1743 }
1744
1737} 1745}
1738 1746
1739static void iwl_mvm_bss_info_changed(struct ieee80211_hw *hw, 1747static void iwl_mvm_bss_info_changed(struct ieee80211_hw *hw,
@@ -2367,14 +2375,19 @@ static int iwl_mvm_send_aux_roc_cmd(struct iwl_mvm *mvm,
2367 /* Set the node address */ 2375 /* Set the node address */
2368 memcpy(aux_roc_req.node_addr, vif->addr, ETH_ALEN); 2376 memcpy(aux_roc_req.node_addr, vif->addr, ETH_ALEN);
2369 2377
2378 lockdep_assert_held(&mvm->mutex);
2379
2380 spin_lock_bh(&mvm->time_event_lock);
2381
2382 if (WARN_ON(te_data->id == HOT_SPOT_CMD)) {
2383 spin_unlock_bh(&mvm->time_event_lock);
2384 return -EIO;
2385 }
2386
2370 te_data->vif = vif; 2387 te_data->vif = vif;
2371 te_data->duration = duration; 2388 te_data->duration = duration;
2372 te_data->id = HOT_SPOT_CMD; 2389 te_data->id = HOT_SPOT_CMD;
2373 2390
2374 lockdep_assert_held(&mvm->mutex);
2375
2376 spin_lock_bh(&mvm->time_event_lock);
2377 list_add_tail(&te_data->list, &mvm->time_event_list);
2378 spin_unlock_bh(&mvm->time_event_lock); 2391 spin_unlock_bh(&mvm->time_event_lock);
2379 2392
2380 /* 2393 /*
@@ -2430,22 +2443,23 @@ static int iwl_mvm_roc(struct ieee80211_hw *hw,
2430 IWL_DEBUG_MAC80211(mvm, "enter (%d, %d, %d)\n", channel->hw_value, 2443 IWL_DEBUG_MAC80211(mvm, "enter (%d, %d, %d)\n", channel->hw_value,
2431 duration, type); 2444 duration, type);
2432 2445
2446 mutex_lock(&mvm->mutex);
2447
2433 switch (vif->type) { 2448 switch (vif->type) {
2434 case NL80211_IFTYPE_STATION: 2449 case NL80211_IFTYPE_STATION:
2435 /* Use aux roc framework (HS20) */ 2450 /* Use aux roc framework (HS20) */
2436 ret = iwl_mvm_send_aux_roc_cmd(mvm, channel, 2451 ret = iwl_mvm_send_aux_roc_cmd(mvm, channel,
2437 vif, duration); 2452 vif, duration);
2438 return ret; 2453 goto out_unlock;
2439 case NL80211_IFTYPE_P2P_DEVICE: 2454 case NL80211_IFTYPE_P2P_DEVICE:
2440 /* handle below */ 2455 /* handle below */
2441 break; 2456 break;
2442 default: 2457 default:
2443 IWL_ERR(mvm, "vif isn't P2P_DEVICE: %d\n", vif->type); 2458 IWL_ERR(mvm, "vif isn't P2P_DEVICE: %d\n", vif->type);
2444 return -EINVAL; 2459 ret = -EINVAL;
2460 goto out_unlock;
2445 } 2461 }
2446 2462
2447 mutex_lock(&mvm->mutex);
2448
2449 for (i = 0; i < NUM_PHY_CTX; i++) { 2463 for (i = 0; i < NUM_PHY_CTX; i++) {
2450 phy_ctxt = &mvm->phy_ctxts[i]; 2464 phy_ctxt = &mvm->phy_ctxts[i];
2451 if (phy_ctxt->ref == 0 || mvmvif->phy_ctxt == phy_ctxt) 2465 if (phy_ctxt->ref == 0 || mvmvif->phy_ctxt == phy_ctxt)
diff --git a/drivers/net/wireless/iwlwifi/mvm/ops.c b/drivers/net/wireless/iwlwifi/mvm/ops.c
index 15aa298ee79c..48cb25a93591 100644
--- a/drivers/net/wireless/iwlwifi/mvm/ops.c
+++ b/drivers/net/wireless/iwlwifi/mvm/ops.c
@@ -336,6 +336,7 @@ static const char *const iwl_mvm_cmd_strings[REPLY_MAX] = {
336 CMD(DTS_MEASUREMENT_NOTIFICATION), 336 CMD(DTS_MEASUREMENT_NOTIFICATION),
337 CMD(REPLY_THERMAL_MNG_BACKOFF), 337 CMD(REPLY_THERMAL_MNG_BACKOFF),
338 CMD(MAC_PM_POWER_TABLE), 338 CMD(MAC_PM_POWER_TABLE),
339 CMD(LTR_CONFIG),
339 CMD(BT_COEX_CI), 340 CMD(BT_COEX_CI),
340 CMD(BT_COEX_UPDATE_SW_BOOST), 341 CMD(BT_COEX_UPDATE_SW_BOOST),
341 CMD(BT_COEX_UPDATE_CORUN_LUT), 342 CMD(BT_COEX_UPDATE_CORUN_LUT),
diff --git a/drivers/net/wireless/iwlwifi/mvm/scan.c b/drivers/net/wireless/iwlwifi/mvm/scan.c
index cb85e63c20aa..b280d5d87127 100644
--- a/drivers/net/wireless/iwlwifi/mvm/scan.c
+++ b/drivers/net/wireless/iwlwifi/mvm/scan.c
@@ -459,7 +459,8 @@ int iwl_mvm_scan_request(struct iwl_mvm *mvm,
459 basic_ssid ? 1 : 0); 459 basic_ssid ? 1 : 0);
460 460
461 cmd->tx_cmd.tx_flags = cpu_to_le32(TX_CMD_FLG_SEQ_CTL | 461 cmd->tx_cmd.tx_flags = cpu_to_le32(TX_CMD_FLG_SEQ_CTL |
462 TX_CMD_FLG_BT_DIS); 462 3 << TX_CMD_FLG_BT_PRIO_POS);
463
463 cmd->tx_cmd.sta_id = mvm->aux_sta.sta_id; 464 cmd->tx_cmd.sta_id = mvm->aux_sta.sta_id;
464 cmd->tx_cmd.life_time = cpu_to_le32(TX_CMD_LIFE_TIME_INFINITE); 465 cmd->tx_cmd.life_time = cpu_to_le32(TX_CMD_LIFE_TIME_INFINITE);
465 cmd->tx_cmd.rate_n_flags = 466 cmd->tx_cmd.rate_n_flags =
diff --git a/drivers/net/wireless/iwlwifi/mvm/time-event.c b/drivers/net/wireless/iwlwifi/mvm/time-event.c
index b7f9e61d14e2..6dfad230be5e 100644
--- a/drivers/net/wireless/iwlwifi/mvm/time-event.c
+++ b/drivers/net/wireless/iwlwifi/mvm/time-event.c
@@ -305,8 +305,8 @@ static int iwl_mvm_aux_roc_te_handle_notif(struct iwl_mvm *mvm,
305 te_data->running = false; 305 te_data->running = false;
306 te_data->vif = NULL; 306 te_data->vif = NULL;
307 te_data->uid = 0; 307 te_data->uid = 0;
308 te_data->id = TE_MAX;
308 } else if (le32_to_cpu(notif->action) == TE_V2_NOTIF_HOST_EVENT_START) { 309 } else if (le32_to_cpu(notif->action) == TE_V2_NOTIF_HOST_EVENT_START) {
309 set_bit(IWL_MVM_STATUS_ROC_RUNNING, &mvm->status);
310 set_bit(IWL_MVM_STATUS_ROC_AUX_RUNNING, &mvm->status); 310 set_bit(IWL_MVM_STATUS_ROC_AUX_RUNNING, &mvm->status);
311 te_data->running = true; 311 te_data->running = true;
312 ieee80211_ready_on_channel(mvm->hw); /* Start TE */ 312 ieee80211_ready_on_channel(mvm->hw); /* Start TE */
diff --git a/drivers/net/wireless/iwlwifi/mvm/tx.c b/drivers/net/wireless/iwlwifi/mvm/tx.c
index 1cb793a498ac..c6a517c771df 100644
--- a/drivers/net/wireless/iwlwifi/mvm/tx.c
+++ b/drivers/net/wireless/iwlwifi/mvm/tx.c
@@ -175,14 +175,10 @@ static void iwl_mvm_set_tx_cmd_rate(struct iwl_mvm *mvm,
175 175
176 /* 176 /*
177 * for data packets, rate info comes from the table inside the fw. This 177 * for data packets, rate info comes from the table inside the fw. This
178 * table is controlled by LINK_QUALITY commands. Exclude ctrl port 178 * table is controlled by LINK_QUALITY commands
179 * frames like EAPOLs which should be treated as mgmt frames. This
180 * avoids them being sent initially in high rates which increases the
181 * chances for completion of the 4-Way handshake.
182 */ 179 */
183 180
184 if (ieee80211_is_data(fc) && sta && 181 if (ieee80211_is_data(fc) && sta) {
185 !(info->control.flags & IEEE80211_TX_CTRL_PORT_CTRL_PROTO)) {
186 tx_cmd->initial_rate_index = 0; 182 tx_cmd->initial_rate_index = 0;
187 tx_cmd->tx_flags |= cpu_to_le32(TX_CMD_FLG_STA_RATE); 183 tx_cmd->tx_flags |= cpu_to_le32(TX_CMD_FLG_STA_RATE);
188 return; 184 return;
diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
index 1393bac0025c..3781b029e54a 100644
--- a/drivers/net/wireless/iwlwifi/pcie/trans.c
+++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
@@ -174,6 +174,7 @@ static void iwl_pcie_apm_config(struct iwl_trans *trans)
174{ 174{
175 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 175 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
176 u16 lctl; 176 u16 lctl;
177 u16 cap;
177 178
178 /* 179 /*
179 * HW bug W/A for instability in PCIe bus L0S->L1 transition. 180 * HW bug W/A for instability in PCIe bus L0S->L1 transition.
@@ -184,16 +185,17 @@ static void iwl_pcie_apm_config(struct iwl_trans *trans)
184 * power savings, even without L1. 185 * power savings, even without L1.
185 */ 186 */
186 pcie_capability_read_word(trans_pcie->pci_dev, PCI_EXP_LNKCTL, &lctl); 187 pcie_capability_read_word(trans_pcie->pci_dev, PCI_EXP_LNKCTL, &lctl);
187 if (lctl & PCI_EXP_LNKCTL_ASPM_L1) { 188 if (lctl & PCI_EXP_LNKCTL_ASPM_L1)
188 /* L1-ASPM enabled; disable(!) L0S */
189 iwl_set_bit(trans, CSR_GIO_REG, CSR_GIO_REG_VAL_L0S_ENABLED); 189 iwl_set_bit(trans, CSR_GIO_REG, CSR_GIO_REG_VAL_L0S_ENABLED);
190 dev_info(trans->dev, "L1 Enabled; Disabling L0S\n"); 190 else
191 } else {
192 /* L1-ASPM disabled; enable(!) L0S */
193 iwl_clear_bit(trans, CSR_GIO_REG, CSR_GIO_REG_VAL_L0S_ENABLED); 191 iwl_clear_bit(trans, CSR_GIO_REG, CSR_GIO_REG_VAL_L0S_ENABLED);
194 dev_info(trans->dev, "L1 Disabled; Enabling L0S\n");
195 }
196 trans->pm_support = !(lctl & PCI_EXP_LNKCTL_ASPM_L0S); 192 trans->pm_support = !(lctl & PCI_EXP_LNKCTL_ASPM_L0S);
193
194 pcie_capability_read_word(trans_pcie->pci_dev, PCI_EXP_DEVCTL2, &cap);
195 trans->ltr_enabled = cap & PCI_EXP_DEVCTL2_LTR_EN;
196 dev_info(trans->dev, "L1 %sabled - LTR %sabled\n",
197 (lctl & PCI_EXP_LNKCTL_ASPM_L1) ? "En" : "Dis",
198 trans->ltr_enabled ? "En" : "Dis");
197} 199}
198 200
199/* 201/*
@@ -428,7 +430,7 @@ static int iwl_pcie_apm_stop_master(struct iwl_trans *trans)
428 ret = iwl_poll_bit(trans, CSR_RESET, 430 ret = iwl_poll_bit(trans, CSR_RESET,
429 CSR_RESET_REG_FLAG_MASTER_DISABLED, 431 CSR_RESET_REG_FLAG_MASTER_DISABLED,
430 CSR_RESET_REG_FLAG_MASTER_DISABLED, 100); 432 CSR_RESET_REG_FLAG_MASTER_DISABLED, 100);
431 if (ret) 433 if (ret < 0)
432 IWL_WARN(trans, "Master Disable Timed Out, 100 usec\n"); 434 IWL_WARN(trans, "Master Disable Timed Out, 100 usec\n");
433 435
434 IWL_DEBUG_INFO(trans, "stop master\n"); 436 IWL_DEBUG_INFO(trans, "stop master\n");
@@ -544,7 +546,7 @@ static int iwl_pcie_prepare_card_hw(struct iwl_trans *trans)
544 msleep(25); 546 msleep(25);
545 } 547 }
546 548
547 IWL_DEBUG_INFO(trans, "got NIC after %d iterations\n", iter); 549 IWL_ERR(trans, "Couldn't prepare the card\n");
548 550
549 return ret; 551 return ret;
550} 552}
@@ -1043,7 +1045,7 @@ static int iwl_trans_pcie_d3_resume(struct iwl_trans *trans,
1043 CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 1045 CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY,
1044 CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 1046 CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY,
1045 25000); 1047 25000);
1046 if (ret) { 1048 if (ret < 0) {
1047 IWL_ERR(trans, "Failed to resume the device (mac ready)\n"); 1049 IWL_ERR(trans, "Failed to resume the device (mac ready)\n");
1048 return ret; 1050 return ret;
1049 } 1051 }
diff --git a/drivers/net/wireless/mwifiex/11n_rxreorder.c b/drivers/net/wireless/mwifiex/11n_rxreorder.c
index 40057079ffb9..5ef5a0eeba50 100644
--- a/drivers/net/wireless/mwifiex/11n_rxreorder.c
+++ b/drivers/net/wireless/mwifiex/11n_rxreorder.c
@@ -196,6 +196,7 @@ mwifiex_del_rx_reorder_entry(struct mwifiex_private *priv,
196 mwifiex_11n_dispatch_pkt_until_start_win(priv, tbl, start_win); 196 mwifiex_11n_dispatch_pkt_until_start_win(priv, tbl, start_win);
197 197
198 del_timer_sync(&tbl->timer_context.timer); 198 del_timer_sync(&tbl->timer_context.timer);
199 tbl->timer_context.timer_is_set = false;
199 200
200 spin_lock_irqsave(&priv->rx_reorder_tbl_lock, flags); 201 spin_lock_irqsave(&priv->rx_reorder_tbl_lock, flags);
201 list_del(&tbl->list); 202 list_del(&tbl->list);
@@ -297,6 +298,7 @@ mwifiex_flush_data(unsigned long context)
297 (struct reorder_tmr_cnxt *) context; 298 (struct reorder_tmr_cnxt *) context;
298 int start_win, seq_num; 299 int start_win, seq_num;
299 300
301 ctx->timer_is_set = false;
300 seq_num = mwifiex_11n_find_last_seq_num(ctx); 302 seq_num = mwifiex_11n_find_last_seq_num(ctx);
301 303
302 if (seq_num < 0) 304 if (seq_num < 0)
@@ -385,6 +387,7 @@ mwifiex_11n_create_rx_reorder_tbl(struct mwifiex_private *priv, u8 *ta,
385 387
386 new_node->timer_context.ptr = new_node; 388 new_node->timer_context.ptr = new_node;
387 new_node->timer_context.priv = priv; 389 new_node->timer_context.priv = priv;
390 new_node->timer_context.timer_is_set = false;
388 391
389 init_timer(&new_node->timer_context.timer); 392 init_timer(&new_node->timer_context.timer);
390 new_node->timer_context.timer.function = mwifiex_flush_data; 393 new_node->timer_context.timer.function = mwifiex_flush_data;
@@ -399,6 +402,22 @@ mwifiex_11n_create_rx_reorder_tbl(struct mwifiex_private *priv, u8 *ta,
399 spin_unlock_irqrestore(&priv->rx_reorder_tbl_lock, flags); 402 spin_unlock_irqrestore(&priv->rx_reorder_tbl_lock, flags);
400} 403}
401 404
405static void
406mwifiex_11n_rxreorder_timer_restart(struct mwifiex_rx_reorder_tbl *tbl)
407{
408 u32 min_flush_time;
409
410 if (tbl->win_size >= MWIFIEX_BA_WIN_SIZE_32)
411 min_flush_time = MIN_FLUSH_TIMER_15_MS;
412 else
413 min_flush_time = MIN_FLUSH_TIMER_MS;
414
415 mod_timer(&tbl->timer_context.timer,
416 jiffies + msecs_to_jiffies(min_flush_time * tbl->win_size));
417
418 tbl->timer_context.timer_is_set = true;
419}
420
402/* 421/*
403 * This function prepares command for adding a BA request. 422 * This function prepares command for adding a BA request.
404 * 423 *
@@ -523,31 +542,31 @@ int mwifiex_11n_rx_reorder_pkt(struct mwifiex_private *priv,
523 u8 *ta, u8 pkt_type, void *payload) 542 u8 *ta, u8 pkt_type, void *payload)
524{ 543{
525 struct mwifiex_rx_reorder_tbl *tbl; 544 struct mwifiex_rx_reorder_tbl *tbl;
526 int start_win, end_win, win_size; 545 int prev_start_win, start_win, end_win, win_size;
527 u16 pkt_index; 546 u16 pkt_index;
528 bool init_window_shift = false; 547 bool init_window_shift = false;
548 int ret = 0;
529 549
530 tbl = mwifiex_11n_get_rx_reorder_tbl(priv, tid, ta); 550 tbl = mwifiex_11n_get_rx_reorder_tbl(priv, tid, ta);
531 if (!tbl) { 551 if (!tbl) {
532 if (pkt_type != PKT_TYPE_BAR) 552 if (pkt_type != PKT_TYPE_BAR)
533 mwifiex_11n_dispatch_pkt(priv, payload); 553 mwifiex_11n_dispatch_pkt(priv, payload);
534 return 0; 554 return ret;
535 } 555 }
536 556
537 if ((pkt_type == PKT_TYPE_AMSDU) && !tbl->amsdu) { 557 if ((pkt_type == PKT_TYPE_AMSDU) && !tbl->amsdu) {
538 mwifiex_11n_dispatch_pkt(priv, payload); 558 mwifiex_11n_dispatch_pkt(priv, payload);
539 return 0; 559 return ret;
540 } 560 }
541 561
542 start_win = tbl->start_win; 562 start_win = tbl->start_win;
563 prev_start_win = start_win;
543 win_size = tbl->win_size; 564 win_size = tbl->win_size;
544 end_win = ((start_win + win_size) - 1) & (MAX_TID_VALUE - 1); 565 end_win = ((start_win + win_size) - 1) & (MAX_TID_VALUE - 1);
545 if (tbl->flags & RXREOR_INIT_WINDOW_SHIFT) { 566 if (tbl->flags & RXREOR_INIT_WINDOW_SHIFT) {
546 init_window_shift = true; 567 init_window_shift = true;
547 tbl->flags &= ~RXREOR_INIT_WINDOW_SHIFT; 568 tbl->flags &= ~RXREOR_INIT_WINDOW_SHIFT;
548 } 569 }
549 mod_timer(&tbl->timer_context.timer,
550 jiffies + msecs_to_jiffies(MIN_FLUSH_TIMER_MS * win_size));
551 570
552 if (tbl->flags & RXREOR_FORCE_NO_DROP) { 571 if (tbl->flags & RXREOR_FORCE_NO_DROP) {
553 dev_dbg(priv->adapter->dev, 572 dev_dbg(priv->adapter->dev,
@@ -568,11 +587,14 @@ int mwifiex_11n_rx_reorder_pkt(struct mwifiex_private *priv,
568 if ((start_win + TWOPOW11) > (MAX_TID_VALUE - 1)) { 587 if ((start_win + TWOPOW11) > (MAX_TID_VALUE - 1)) {
569 if (seq_num >= ((start_win + TWOPOW11) & 588 if (seq_num >= ((start_win + TWOPOW11) &
570 (MAX_TID_VALUE - 1)) && 589 (MAX_TID_VALUE - 1)) &&
571 seq_num < start_win) 590 seq_num < start_win) {
572 return -1; 591 ret = -1;
592 goto done;
593 }
573 } else if ((seq_num < start_win) || 594 } else if ((seq_num < start_win) ||
574 (seq_num > (start_win + TWOPOW11))) { 595 (seq_num >= (start_win + TWOPOW11))) {
575 return -1; 596 ret = -1;
597 goto done;
576 } 598 }
577 } 599 }
578 600
@@ -601,8 +623,10 @@ int mwifiex_11n_rx_reorder_pkt(struct mwifiex_private *priv,
601 else 623 else
602 pkt_index = (seq_num+MAX_TID_VALUE) - start_win; 624 pkt_index = (seq_num+MAX_TID_VALUE) - start_win;
603 625
604 if (tbl->rx_reorder_ptr[pkt_index]) 626 if (tbl->rx_reorder_ptr[pkt_index]) {
605 return -1; 627 ret = -1;
628 goto done;
629 }
606 630
607 tbl->rx_reorder_ptr[pkt_index] = payload; 631 tbl->rx_reorder_ptr[pkt_index] = payload;
608 } 632 }
@@ -613,7 +637,11 @@ int mwifiex_11n_rx_reorder_pkt(struct mwifiex_private *priv,
613 */ 637 */
614 mwifiex_11n_scan_and_dispatch(priv, tbl); 638 mwifiex_11n_scan_and_dispatch(priv, tbl);
615 639
616 return 0; 640done:
641 if (!tbl->timer_context.timer_is_set ||
642 prev_start_win != tbl->start_win)
643 mwifiex_11n_rxreorder_timer_restart(tbl);
644 return ret;
617} 645}
618 646
619/* 647/*
diff --git a/drivers/net/wireless/mwifiex/11n_rxreorder.h b/drivers/net/wireless/mwifiex/11n_rxreorder.h
index 3a87bb0e3a62..63ecea89b4ab 100644
--- a/drivers/net/wireless/mwifiex/11n_rxreorder.h
+++ b/drivers/net/wireless/mwifiex/11n_rxreorder.h
@@ -21,6 +21,8 @@
21#define _MWIFIEX_11N_RXREORDER_H_ 21#define _MWIFIEX_11N_RXREORDER_H_
22 22
23#define MIN_FLUSH_TIMER_MS 50 23#define MIN_FLUSH_TIMER_MS 50
24#define MIN_FLUSH_TIMER_15_MS 15
25#define MWIFIEX_BA_WIN_SIZE_32 32
24 26
25#define PKT_TYPE_BAR 0xE7 27#define PKT_TYPE_BAR 0xE7
26#define MAX_TID_VALUE (2 << 11) 28#define MAX_TID_VALUE (2 << 11)
diff --git a/drivers/net/wireless/mwifiex/main.h b/drivers/net/wireless/mwifiex/main.h
index e2635747d966..f55658d15c60 100644
--- a/drivers/net/wireless/mwifiex/main.h
+++ b/drivers/net/wireless/mwifiex/main.h
@@ -592,6 +592,7 @@ struct reorder_tmr_cnxt {
592 struct timer_list timer; 592 struct timer_list timer;
593 struct mwifiex_rx_reorder_tbl *ptr; 593 struct mwifiex_rx_reorder_tbl *ptr;
594 struct mwifiex_private *priv; 594 struct mwifiex_private *priv;
595 u8 timer_is_set;
595}; 596};
596 597
597struct mwifiex_rx_reorder_tbl { 598struct mwifiex_rx_reorder_tbl {
diff --git a/drivers/net/wireless/rt2x00/rt2800usb.c b/drivers/net/wireless/rt2x00/rt2800usb.c
index 573897b8e878..8444313eabe2 100644
--- a/drivers/net/wireless/rt2x00/rt2800usb.c
+++ b/drivers/net/wireless/rt2x00/rt2800usb.c
@@ -1111,6 +1111,7 @@ static struct usb_device_id rt2800usb_device_table[] = {
1111 /* Ovislink */ 1111 /* Ovislink */
1112 { USB_DEVICE(0x1b75, 0x3071) }, 1112 { USB_DEVICE(0x1b75, 0x3071) },
1113 { USB_DEVICE(0x1b75, 0x3072) }, 1113 { USB_DEVICE(0x1b75, 0x3072) },
1114 { USB_DEVICE(0x1b75, 0xa200) },
1114 /* Para */ 1115 /* Para */
1115 { USB_DEVICE(0x20b8, 0x8888) }, 1116 { USB_DEVICE(0x20b8, 0x8888) },
1116 /* Pegatron */ 1117 /* Pegatron */
diff --git a/drivers/net/wireless/rtlwifi/base.c b/drivers/net/wireless/rtlwifi/base.c
index 58ba71830886..40b6d1d006d7 100644
--- a/drivers/net/wireless/rtlwifi/base.c
+++ b/drivers/net/wireless/rtlwifi/base.c
@@ -467,7 +467,7 @@ static void _rtl_init_deferred_work(struct ieee80211_hw *hw)
467 rtl_easy_concurrent_retrytimer_callback, (unsigned long)hw); 467 rtl_easy_concurrent_retrytimer_callback, (unsigned long)hw);
468 /* <2> work queue */ 468 /* <2> work queue */
469 rtlpriv->works.hw = hw; 469 rtlpriv->works.hw = hw;
470 rtlpriv->works.rtl_wq = alloc_workqueue(rtlpriv->cfg->name, 0, 0); 470 rtlpriv->works.rtl_wq = alloc_workqueue("%s", 0, 0, rtlpriv->cfg->name);
471 INIT_DELAYED_WORK(&rtlpriv->works.watchdog_wq, 471 INIT_DELAYED_WORK(&rtlpriv->works.watchdog_wq,
472 (void *)rtl_watchdog_wq_callback); 472 (void *)rtl_watchdog_wq_callback);
473 INIT_DELAYED_WORK(&rtlpriv->works.ips_nic_off_wq, 473 INIT_DELAYED_WORK(&rtlpriv->works.ips_nic_off_wq,
diff --git a/drivers/net/wireless/rtlwifi/core.c b/drivers/net/wireless/rtlwifi/core.c
index f6179bc06086..07dae0d44abc 100644
--- a/drivers/net/wireless/rtlwifi/core.c
+++ b/drivers/net/wireless/rtlwifi/core.c
@@ -1828,3 +1828,9 @@ const struct ieee80211_ops rtl_ops = {
1828 .flush = rtl_op_flush, 1828 .flush = rtl_op_flush,
1829}; 1829};
1830EXPORT_SYMBOL_GPL(rtl_ops); 1830EXPORT_SYMBOL_GPL(rtl_ops);
1831
1832bool rtl_btc_status_false(void)
1833{
1834 return false;
1835}
1836EXPORT_SYMBOL_GPL(rtl_btc_status_false);
diff --git a/drivers/net/wireless/rtlwifi/core.h b/drivers/net/wireless/rtlwifi/core.h
index 59cd3b9dca25..624e1dc16d31 100644
--- a/drivers/net/wireless/rtlwifi/core.h
+++ b/drivers/net/wireless/rtlwifi/core.h
@@ -42,5 +42,6 @@ void rtl_rfreg_delay(struct ieee80211_hw *hw, enum radio_path rfpath, u32 addr,
42 u32 mask, u32 data); 42 u32 mask, u32 data);
43void rtl_bb_delay(struct ieee80211_hw *hw, u32 addr, u32 data); 43void rtl_bb_delay(struct ieee80211_hw *hw, u32 addr, u32 data);
44bool rtl_cmd_send_packet(struct ieee80211_hw *hw, struct sk_buff *skb); 44bool rtl_cmd_send_packet(struct ieee80211_hw *hw, struct sk_buff *skb);
45bool rtl_btc_status_false(void);
45 46
46#endif 47#endif
diff --git a/drivers/net/wireless/rtlwifi/pci.c b/drivers/net/wireless/rtlwifi/pci.c
index 667aba81246c..25daa8715219 100644
--- a/drivers/net/wireless/rtlwifi/pci.c
+++ b/drivers/net/wireless/rtlwifi/pci.c
@@ -1796,7 +1796,8 @@ static int rtl_pci_start(struct ieee80211_hw *hw)
1796 rtl_pci_reset_trx_ring(hw); 1796 rtl_pci_reset_trx_ring(hw);
1797 1797
1798 rtlpci->driver_is_goingto_unload = false; 1798 rtlpci->driver_is_goingto_unload = false;
1799 if (rtlpriv->cfg->ops->get_btc_status()) { 1799 if (rtlpriv->cfg->ops->get_btc_status &&
1800 rtlpriv->cfg->ops->get_btc_status()) {
1800 rtlpriv->btcoexist.btc_ops->btc_init_variables(rtlpriv); 1801 rtlpriv->btcoexist.btc_ops->btc_init_variables(rtlpriv);
1801 rtlpriv->btcoexist.btc_ops->btc_init_hal_vars(rtlpriv); 1802 rtlpriv->btcoexist.btc_ops->btc_init_hal_vars(rtlpriv);
1802 } 1803 }
diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c b/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c
index a00861b26ece..29983bc96a89 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c
@@ -656,7 +656,8 @@ static u8 reserved_page_packet[TOTAL_RESERVED_PKT_LEN] = {
656 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 656 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
657}; 657};
658 658
659void rtl92c_set_fw_rsvdpagepkt(struct ieee80211_hw *hw, bool b_dl_finished) 659void rtl92c_set_fw_rsvdpagepkt(struct ieee80211_hw *hw,
660 bool (*cmd_send_packet)(struct ieee80211_hw *, struct sk_buff *))
660{ 661{
661 struct rtl_priv *rtlpriv = rtl_priv(hw); 662 struct rtl_priv *rtlpriv = rtl_priv(hw);
662 struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); 663 struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
@@ -722,7 +723,10 @@ void rtl92c_set_fw_rsvdpagepkt(struct ieee80211_hw *hw, bool b_dl_finished)
722 memcpy((u8 *)skb_put(skb, totalpacketlen), 723 memcpy((u8 *)skb_put(skb, totalpacketlen),
723 &reserved_page_packet, totalpacketlen); 724 &reserved_page_packet, totalpacketlen);
724 725
725 rtstatus = rtl_cmd_send_packet(hw, skb); 726 if (cmd_send_packet)
727 rtstatus = cmd_send_packet(hw, skb);
728 else
729 rtstatus = rtl_cmd_send_packet(hw, skb);
726 730
727 if (rtstatus) 731 if (rtstatus)
728 b_dlok = true; 732 b_dlok = true;
diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.h b/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.h
index a815bd6273da..b64ae45dc674 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.h
@@ -109,7 +109,9 @@ void rtl92c_fill_h2c_cmd(struct ieee80211_hw *hw, u8 element_id,
109 u32 cmd_len, u8 *p_cmdbuffer); 109 u32 cmd_len, u8 *p_cmdbuffer);
110void rtl92c_firmware_selfreset(struct ieee80211_hw *hw); 110void rtl92c_firmware_selfreset(struct ieee80211_hw *hw);
111void rtl92c_set_fw_pwrmode_cmd(struct ieee80211_hw *hw, u8 mode); 111void rtl92c_set_fw_pwrmode_cmd(struct ieee80211_hw *hw, u8 mode);
112void rtl92c_set_fw_rsvdpagepkt(struct ieee80211_hw *hw, bool b_dl_finished); 112void rtl92c_set_fw_rsvdpagepkt
113 (struct ieee80211_hw *hw,
114 bool (*cmd_send_packet)(struct ieee80211_hw *, struct sk_buff *));
113void rtl92c_set_fw_joinbss_report_cmd(struct ieee80211_hw *hw, u8 mstatus); 115void rtl92c_set_fw_joinbss_report_cmd(struct ieee80211_hw *hw, u8 mstatus);
114void usb_writeN_async(struct rtl_priv *rtlpriv, u32 addr, void *data, u16 len); 116void usb_writeN_async(struct rtl_priv *rtlpriv, u32 addr, void *data, u16 len);
115void rtl92c_set_p2p_ps_offload_cmd(struct ieee80211_hw *hw, u8 p2p_ps_state); 117void rtl92c_set_p2p_ps_offload_cmd(struct ieee80211_hw *hw, u8 p2p_ps_state);
diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/def.h b/drivers/net/wireless/rtlwifi/rtl8192ce/def.h
index 831df101d7b7..9b660df6fd71 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192ce/def.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192ce/def.h
@@ -114,6 +114,8 @@
114 LE_BITS_TO_4BYTE(((__pcmdfbhdr) + 4), 16, 4) 114 LE_BITS_TO_4BYTE(((__pcmdfbhdr) + 4), 16, 4)
115#define GET_C2H_CMD_FEEDBACK_CCX_SEQ(__pcmdfbhdr) \ 115#define GET_C2H_CMD_FEEDBACK_CCX_SEQ(__pcmdfbhdr) \
116 LE_BITS_TO_4BYTE(((__pcmdfbhdr) + 4), 20, 12) 116 LE_BITS_TO_4BYTE(((__pcmdfbhdr) + 4), 20, 12)
117#define GET_RX_STATUS_DESC_BUFF_ADDR(__pdesc) \
118 SHIFT_AND_MASK_LE(__pdesc + 24, 0, 32)
117 119
118#define CHIP_VER_B BIT(4) 120#define CHIP_VER_B BIT(4)
119#define CHIP_BONDING_IDENTIFIER(_value) (((_value) >> 22) & 0x3) 121#define CHIP_BONDING_IDENTIFIER(_value) (((_value) >> 22) & 0x3)
diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c b/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c
index 8ec0f031f48a..55357d69397a 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c
@@ -459,7 +459,7 @@ void rtl92ce_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
459 rtl_write_byte(rtlpriv, REG_FWHW_TXQ_CTRL + 2, 459 rtl_write_byte(rtlpriv, REG_FWHW_TXQ_CTRL + 2,
460 tmp_reg422 & (~BIT(6))); 460 tmp_reg422 & (~BIT(6)));
461 461
462 rtl92c_set_fw_rsvdpagepkt(hw, 0); 462 rtl92c_set_fw_rsvdpagepkt(hw, NULL);
463 463
464 _rtl92ce_set_bcn_ctrl_reg(hw, BIT(3), 0); 464 _rtl92ce_set_bcn_ctrl_reg(hw, BIT(3), 0);
465 _rtl92ce_set_bcn_ctrl_reg(hw, 0, BIT(4)); 465 _rtl92ce_set_bcn_ctrl_reg(hw, 0, BIT(4));
diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c b/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c
index d86b5b566444..46ea07605eb4 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c
@@ -244,6 +244,7 @@ static struct rtl_hal_ops rtl8192ce_hal_ops = {
244 .phy_lc_calibrate = _rtl92ce_phy_lc_calibrate, 244 .phy_lc_calibrate = _rtl92ce_phy_lc_calibrate,
245 .phy_set_bw_mode_callback = rtl92ce_phy_set_bw_mode_callback, 245 .phy_set_bw_mode_callback = rtl92ce_phy_set_bw_mode_callback,
246 .dm_dynamic_txpower = rtl92ce_dm_dynamic_txpower, 246 .dm_dynamic_txpower = rtl92ce_dm_dynamic_txpower,
247 .get_btc_status = rtl_btc_status_false,
247}; 248};
248 249
249static struct rtl_mod_params rtl92ce_mod_params = { 250static struct rtl_mod_params rtl92ce_mod_params = {
diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c b/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
index 2fb9c7acb76a..dc3d20b17a26 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
@@ -728,6 +728,9 @@ u32 rtl92ce_get_desc(u8 *p_desc, bool istx, u8 desc_name)
728 case HW_DESC_RXPKT_LEN: 728 case HW_DESC_RXPKT_LEN:
729 ret = GET_RX_DESC_PKT_LEN(pdesc); 729 ret = GET_RX_DESC_PKT_LEN(pdesc);
730 break; 730 break;
731 case HW_DESC_RXBUFF_ADDR:
732 ret = GET_RX_STATUS_DESC_BUFF_ADDR(pdesc);
733 break;
731 default: 734 default:
732 RT_ASSERT(false, "ERR rxdesc :%d not process\n", 735 RT_ASSERT(false, "ERR rxdesc :%d not process\n",
733 desc_name); 736 desc_name);
diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c b/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c
index 04aa0b5f5b3d..873363acbacf 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c
@@ -1592,6 +1592,20 @@ void rtl92cu_get_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
1592 } 1592 }
1593} 1593}
1594 1594
1595bool usb_cmd_send_packet(struct ieee80211_hw *hw, struct sk_buff *skb)
1596{
1597 /* Currently nothing happens here.
1598 * Traffic stops after some seconds in WPA2 802.11n mode.
1599 * Maybe because rtl8192cu chip should be set from here?
1600 * If I understand correctly, the realtek vendor driver sends some urbs
1601 * if its "here".
1602 *
1603 * This is maybe necessary:
1604 * rtlpriv->cfg->ops->fill_tx_cmddesc(hw, buffer, 1, 1, skb);
1605 */
1606 return true;
1607}
1608
1595void rtl92cu_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val) 1609void rtl92cu_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
1596{ 1610{
1597 struct rtl_priv *rtlpriv = rtl_priv(hw); 1611 struct rtl_priv *rtlpriv = rtl_priv(hw);
@@ -1939,7 +1953,8 @@ void rtl92cu_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
1939 recover = true; 1953 recover = true;
1940 rtl_write_byte(rtlpriv, REG_FWHW_TXQ_CTRL + 2, 1954 rtl_write_byte(rtlpriv, REG_FWHW_TXQ_CTRL + 2,
1941 tmp_reg422 & (~BIT(6))); 1955 tmp_reg422 & (~BIT(6)));
1942 rtl92c_set_fw_rsvdpagepkt(hw, 0); 1956 rtl92c_set_fw_rsvdpagepkt(hw,
1957 &usb_cmd_send_packet);
1943 _rtl92cu_set_bcn_ctrl_reg(hw, BIT(3), 0); 1958 _rtl92cu_set_bcn_ctrl_reg(hw, BIT(3), 0);
1944 _rtl92cu_set_bcn_ctrl_reg(hw, 0, BIT(4)); 1959 _rtl92cu_set_bcn_ctrl_reg(hw, 0, BIT(4));
1945 if (recover) 1960 if (recover)
diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/hw.h b/drivers/net/wireless/rtlwifi/rtl8192cu/hw.h
index 0f7812e0c8aa..c1e33b0228c0 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192cu/hw.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192cu/hw.h
@@ -104,7 +104,6 @@ bool rtl92cu_gpio_radio_on_off_checking(struct ieee80211_hw *hw, u8 * valid);
104void rtl92cu_set_check_bssid(struct ieee80211_hw *hw, bool check_bssid); 104void rtl92cu_set_check_bssid(struct ieee80211_hw *hw, bool check_bssid);
105int rtl92c_download_fw(struct ieee80211_hw *hw); 105int rtl92c_download_fw(struct ieee80211_hw *hw);
106void rtl92c_set_fw_pwrmode_cmd(struct ieee80211_hw *hw, u8 mode); 106void rtl92c_set_fw_pwrmode_cmd(struct ieee80211_hw *hw, u8 mode);
107void rtl92c_set_fw_rsvdpagepkt(struct ieee80211_hw *hw, bool dl_finished);
108void rtl92c_set_fw_joinbss_report_cmd(struct ieee80211_hw *hw, u8 mstatus); 107void rtl92c_set_fw_joinbss_report_cmd(struct ieee80211_hw *hw, u8 mstatus);
109void rtl92c_fill_h2c_cmd(struct ieee80211_hw *hw, 108void rtl92c_fill_h2c_cmd(struct ieee80211_hw *hw,
110 u8 element_id, u32 cmd_len, u8 *p_cmdbuffer); 109 u8 element_id, u32 cmd_len, u8 *p_cmdbuffer);
diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c b/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c
index 7c5fbaf5fee0..e06bafee37f9 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c
@@ -101,6 +101,12 @@ static void rtl92cu_deinit_sw_vars(struct ieee80211_hw *hw)
101 } 101 }
102} 102}
103 103
104/* get bt coexist status */
105static bool rtl92cu_get_btc_status(void)
106{
107 return false;
108}
109
104static struct rtl_hal_ops rtl8192cu_hal_ops = { 110static struct rtl_hal_ops rtl8192cu_hal_ops = {
105 .init_sw_vars = rtl92cu_init_sw_vars, 111 .init_sw_vars = rtl92cu_init_sw_vars,
106 .deinit_sw_vars = rtl92cu_deinit_sw_vars, 112 .deinit_sw_vars = rtl92cu_deinit_sw_vars,
@@ -148,6 +154,7 @@ static struct rtl_hal_ops rtl8192cu_hal_ops = {
148 .phy_set_bw_mode_callback = rtl92cu_phy_set_bw_mode_callback, 154 .phy_set_bw_mode_callback = rtl92cu_phy_set_bw_mode_callback,
149 .dm_dynamic_txpower = rtl92cu_dm_dynamic_txpower, 155 .dm_dynamic_txpower = rtl92cu_dm_dynamic_txpower,
150 .fill_h2c_cmd = rtl92c_fill_h2c_cmd, 156 .fill_h2c_cmd = rtl92c_fill_h2c_cmd,
157 .get_btc_status = rtl92cu_get_btc_status,
151}; 158};
152 159
153static struct rtl_mod_params rtl92cu_mod_params = { 160static struct rtl_mod_params rtl92cu_mod_params = {
diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/sw.c b/drivers/net/wireless/rtlwifi/rtl8192de/sw.c
index edab5a5351b5..a0aba088259a 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192de/sw.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192de/sw.c
@@ -251,6 +251,7 @@ static struct rtl_hal_ops rtl8192de_hal_ops = {
251 .get_rfreg = rtl92d_phy_query_rf_reg, 251 .get_rfreg = rtl92d_phy_query_rf_reg,
252 .set_rfreg = rtl92d_phy_set_rf_reg, 252 .set_rfreg = rtl92d_phy_set_rf_reg,
253 .linked_set_reg = rtl92d_linked_set_reg, 253 .linked_set_reg = rtl92d_linked_set_reg,
254 .get_btc_status = rtl_btc_status_false,
254}; 255};
255 256
256static struct rtl_mod_params rtl92de_mod_params = { 257static struct rtl_mod_params rtl92de_mod_params = {
diff --git a/drivers/net/wireless/rtlwifi/rtl8192ee/hw.c b/drivers/net/wireless/rtlwifi/rtl8192ee/hw.c
index dfdc9b20e4ad..1a87edca2c3f 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192ee/hw.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192ee/hw.c
@@ -362,7 +362,7 @@ void rtl92ee_get_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
362 } 362 }
363 break; 363 break;
364 default: 364 default:
365 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 365 RT_TRACE(rtlpriv, COMP_ERR, DBG_DMESG,
366 "switch case not process %x\n", variable); 366 "switch case not process %x\n", variable);
367 break; 367 break;
368 } 368 }
@@ -591,7 +591,7 @@ void rtl92ee_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
591 acm_ctrl &= (~ACMHW_BEQEN); 591 acm_ctrl &= (~ACMHW_BEQEN);
592 break; 592 break;
593 default: 593 default:
594 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 594 RT_TRACE(rtlpriv, COMP_ERR, DBG_DMESG,
595 "switch case not process\n"); 595 "switch case not process\n");
596 break; 596 break;
597 } 597 }
@@ -710,7 +710,7 @@ void rtl92ee_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
710 } 710 }
711 break; 711 break;
712 default: 712 default:
713 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 713 RT_TRACE(rtlpriv, COMP_ERR, DBG_DMESG,
714 "switch case not process %x\n", variable); 714 "switch case not process %x\n", variable);
715 break; 715 break;
716 } 716 }
@@ -2424,7 +2424,7 @@ void rtl92ee_set_key(struct ieee80211_hw *hw, u32 key_index,
2424 enc_algo = CAM_AES; 2424 enc_algo = CAM_AES;
2425 break; 2425 break;
2426 default: 2426 default:
2427 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 2427 RT_TRACE(rtlpriv, COMP_ERR, DBG_DMESG,
2428 "switch case not process\n"); 2428 "switch case not process\n");
2429 enc_algo = CAM_TKIP; 2429 enc_algo = CAM_TKIP;
2430 break; 2430 break;
diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/def.h b/drivers/net/wireless/rtlwifi/rtl8192se/def.h
index 83c98674bfd3..6e7a70b43949 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192se/def.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192se/def.h
@@ -446,6 +446,8 @@
446/* DWORD 6 */ 446/* DWORD 6 */
447#define SET_RX_STATUS__DESC_BUFF_ADDR(__pdesc, __val) \ 447#define SET_RX_STATUS__DESC_BUFF_ADDR(__pdesc, __val) \
448 SET_BITS_OFFSET_LE(__pdesc + 24, 0, 32, __val) 448 SET_BITS_OFFSET_LE(__pdesc + 24, 0, 32, __val)
449#define GET_RX_STATUS_DESC_BUFF_ADDR(__pdesc) \
450 SHIFT_AND_MASK_LE(__pdesc + 24, 0, 32)
449 451
450#define SE_RX_HAL_IS_CCK_RATE(_pdesc)\ 452#define SE_RX_HAL_IS_CCK_RATE(_pdesc)\
451 (GET_RX_STATUS_DESC_RX_MCS(_pdesc) == DESC92_RATE1M || \ 453 (GET_RX_STATUS_DESC_RX_MCS(_pdesc) == DESC92_RATE1M || \
diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/sw.c b/drivers/net/wireless/rtlwifi/rtl8192se/sw.c
index 1bff2a0f7600..aadba29c167a 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192se/sw.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192se/sw.c
@@ -87,11 +87,8 @@ static void rtl92s_init_aspm_vars(struct ieee80211_hw *hw)
87static void rtl92se_fw_cb(const struct firmware *firmware, void *context) 87static void rtl92se_fw_cb(const struct firmware *firmware, void *context)
88{ 88{
89 struct ieee80211_hw *hw = context; 89 struct ieee80211_hw *hw = context;
90 struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw);
91 struct rtl_priv *rtlpriv = rtl_priv(hw); 90 struct rtl_priv *rtlpriv = rtl_priv(hw);
92 struct rtl_pci *rtlpci = rtl_pcidev(pcipriv);
93 struct rt_firmware *pfirmware = NULL; 91 struct rt_firmware *pfirmware = NULL;
94 int err;
95 92
96 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD, 93 RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
97 "Firmware callback routine entered!\n"); 94 "Firmware callback routine entered!\n");
@@ -112,20 +109,6 @@ static void rtl92se_fw_cb(const struct firmware *firmware, void *context)
112 memcpy(pfirmware->sz_fw_tmpbuffer, firmware->data, firmware->size); 109 memcpy(pfirmware->sz_fw_tmpbuffer, firmware->data, firmware->size);
113 pfirmware->sz_fw_tmpbufferlen = firmware->size; 110 pfirmware->sz_fw_tmpbufferlen = firmware->size;
114 release_firmware(firmware); 111 release_firmware(firmware);
115
116 err = ieee80211_register_hw(hw);
117 if (err) {
118 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
119 "Can't register mac80211 hw\n");
120 return;
121 } else {
122 rtlpriv->mac80211.mac80211_registered = 1;
123 }
124 rtlpci->irq_alloc = 1;
125 set_bit(RTL_STATUS_INTERFACE_START, &rtlpriv->status);
126
127 /*init rfkill */
128 rtl_init_rfkill(hw);
129} 112}
130 113
131static int rtl92s_init_sw_vars(struct ieee80211_hw *hw) 114static int rtl92s_init_sw_vars(struct ieee80211_hw *hw)
@@ -226,8 +209,8 @@ static int rtl92s_init_sw_vars(struct ieee80211_hw *hw)
226 if (!rtlpriv->rtlhal.pfirmware) 209 if (!rtlpriv->rtlhal.pfirmware)
227 return 1; 210 return 1;
228 211
229 rtlpriv->max_fw_size = RTL8190_MAX_RAW_FIRMWARE_CODE_SIZE; 212 rtlpriv->max_fw_size = RTL8190_MAX_FIRMWARE_CODE_SIZE*2 +
230 213 sizeof(struct fw_hdr);
231 pr_info("Driver for Realtek RTL8192SE/RTL8191SE\n" 214 pr_info("Driver for Realtek RTL8192SE/RTL8191SE\n"
232 "Loading firmware %s\n", rtlpriv->cfg->fw_name); 215 "Loading firmware %s\n", rtlpriv->cfg->fw_name);
233 /* request fw */ 216 /* request fw */
@@ -294,6 +277,7 @@ static struct rtl_hal_ops rtl8192se_hal_ops = {
294 .set_bbreg = rtl92s_phy_set_bb_reg, 277 .set_bbreg = rtl92s_phy_set_bb_reg,
295 .get_rfreg = rtl92s_phy_query_rf_reg, 278 .get_rfreg = rtl92s_phy_query_rf_reg,
296 .set_rfreg = rtl92s_phy_set_rf_reg, 279 .set_rfreg = rtl92s_phy_set_rf_reg,
280 .get_btc_status = rtl_btc_status_false,
297}; 281};
298 282
299static struct rtl_mod_params rtl92se_mod_params = { 283static struct rtl_mod_params rtl92se_mod_params = {
diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/trx.c b/drivers/net/wireless/rtlwifi/rtl8192se/trx.c
index b358ebce8942..672fd3b02835 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192se/trx.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192se/trx.c
@@ -640,6 +640,9 @@ u32 rtl92se_get_desc(u8 *desc, bool istx, u8 desc_name)
640 case HW_DESC_RXPKT_LEN: 640 case HW_DESC_RXPKT_LEN:
641 ret = GET_RX_STATUS_DESC_PKT_LEN(desc); 641 ret = GET_RX_STATUS_DESC_PKT_LEN(desc);
642 break; 642 break;
643 case HW_DESC_RXBUFF_ADDR:
644 ret = GET_RX_STATUS_DESC_BUFF_ADDR(desc);
645 break;
643 default: 646 default:
644 RT_ASSERT(false, "ERR rxdesc :%d not process\n", 647 RT_ASSERT(false, "ERR rxdesc :%d not process\n",
645 desc_name); 648 desc_name);
diff --git a/drivers/net/wireless/rtlwifi/rtl8821ae/phy.c b/drivers/net/wireless/rtlwifi/rtl8821ae/phy.c
index 9786313dc62f..1e9570fa874f 100644
--- a/drivers/net/wireless/rtlwifi/rtl8821ae/phy.c
+++ b/drivers/net/wireless/rtlwifi/rtl8821ae/phy.c
@@ -1889,15 +1889,18 @@ static void _rtl8821ae_store_tx_power_by_rate(struct ieee80211_hw *hw,
1889 struct rtl_phy *rtlphy = &rtlpriv->phy; 1889 struct rtl_phy *rtlphy = &rtlpriv->phy;
1890 u8 rate_section = _rtl8821ae_get_rate_section_index(regaddr); 1890 u8 rate_section = _rtl8821ae_get_rate_section_index(regaddr);
1891 1891
1892 if (band != BAND_ON_2_4G && band != BAND_ON_5G) 1892 if (band != BAND_ON_2_4G && band != BAND_ON_5G) {
1893 RT_TRACE(rtlpriv, COMP_INIT, DBG_WARNING, "Invalid Band %d\n", band); 1893 RT_TRACE(rtlpriv, COMP_INIT, DBG_WARNING, "Invalid Band %d\n", band);
1894 1894 band = BAND_ON_2_4G;
1895 if (rfpath >= MAX_RF_PATH) 1895 }
1896 if (rfpath >= MAX_RF_PATH) {
1896 RT_TRACE(rtlpriv, COMP_INIT, DBG_WARNING, "Invalid RfPath %d\n", rfpath); 1897 RT_TRACE(rtlpriv, COMP_INIT, DBG_WARNING, "Invalid RfPath %d\n", rfpath);
1897 1898 rfpath = MAX_RF_PATH - 1;
1898 if (txnum >= MAX_RF_PATH) 1899 }
1900 if (txnum >= MAX_RF_PATH) {
1899 RT_TRACE(rtlpriv, COMP_INIT, DBG_WARNING, "Invalid TxNum %d\n", txnum); 1901 RT_TRACE(rtlpriv, COMP_INIT, DBG_WARNING, "Invalid TxNum %d\n", txnum);
1900 1902 txnum = MAX_RF_PATH - 1;
1903 }
1901 rtlphy->tx_power_by_rate_offset[band][rfpath][txnum][rate_section] = data; 1904 rtlphy->tx_power_by_rate_offset[band][rfpath][txnum][rate_section] = data;
1902 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, 1905 RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
1903 "TxPwrByRateOffset[Band %d][RfPath %d][TxNum %d][RateSection %d] = 0x%x\n", 1906 "TxPwrByRateOffset[Band %d][RfPath %d][TxNum %d][RateSection %d] = 0x%x\n",
diff --git a/drivers/net/wireless/rtlwifi/usb.c b/drivers/net/wireless/rtlwifi/usb.c
index 10cf69c4bc42..46ee956d0235 100644
--- a/drivers/net/wireless/rtlwifi/usb.c
+++ b/drivers/net/wireless/rtlwifi/usb.c
@@ -1117,7 +1117,18 @@ int rtl_usb_probe(struct usb_interface *intf,
1117 } 1117 }
1118 rtlpriv->cfg->ops->init_sw_leds(hw); 1118 rtlpriv->cfg->ops->init_sw_leds(hw);
1119 1119
1120 err = ieee80211_register_hw(hw);
1121 if (err) {
1122 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
1123 "Can't register mac80211 hw.\n");
1124 err = -ENODEV;
1125 goto error_out;
1126 }
1127 rtlpriv->mac80211.mac80211_registered = 1;
1128
1129 set_bit(RTL_STATUS_INTERFACE_START, &rtlpriv->status);
1120 return 0; 1130 return 0;
1131
1121error_out: 1132error_out:
1122 rtl_deinit_core(hw); 1133 rtl_deinit_core(hw);
1123 _rtl_usb_io_handler_release(hw); 1134 _rtl_usb_io_handler_release(hw);
diff --git a/drivers/net/xen-netback/common.h b/drivers/net/xen-netback/common.h
index d4eb8d2e9cb7..083ecc93fe5e 100644
--- a/drivers/net/xen-netback/common.h
+++ b/drivers/net/xen-netback/common.h
@@ -176,10 +176,11 @@ struct xenvif_queue { /* Per-queue data for xenvif */
176 char rx_irq_name[IRQ_NAME_SIZE]; /* DEVNAME-qN-rx */ 176 char rx_irq_name[IRQ_NAME_SIZE]; /* DEVNAME-qN-rx */
177 struct xen_netif_rx_back_ring rx; 177 struct xen_netif_rx_back_ring rx;
178 struct sk_buff_head rx_queue; 178 struct sk_buff_head rx_queue;
179 RING_IDX rx_last_skb_slots;
180 unsigned long status;
181 179
182 struct timer_list rx_stalled; 180 unsigned int rx_queue_max;
181 unsigned int rx_queue_len;
182 unsigned long last_rx_time;
183 bool stalled;
183 184
184 struct gnttab_copy grant_copy_op[MAX_GRANT_COPY_OPS]; 185 struct gnttab_copy grant_copy_op[MAX_GRANT_COPY_OPS];
185 186
@@ -199,18 +200,14 @@ struct xenvif_queue { /* Per-queue data for xenvif */
199 struct xenvif_stats stats; 200 struct xenvif_stats stats;
200}; 201};
201 202
203/* Maximum number of Rx slots a to-guest packet may use, including the
204 * slot needed for GSO meta-data.
205 */
206#define XEN_NETBK_RX_SLOTS_MAX (MAX_SKB_FRAGS + 1)
207
202enum state_bit_shift { 208enum state_bit_shift {
203 /* This bit marks that the vif is connected */ 209 /* This bit marks that the vif is connected */
204 VIF_STATUS_CONNECTED, 210 VIF_STATUS_CONNECTED,
205 /* This bit signals the RX thread that queuing was stopped (in
206 * start_xmit), and either the timer fired or an RX interrupt came
207 */
208 QUEUE_STATUS_RX_PURGE_EVENT,
209 /* This bit tells the interrupt handler that this queue was the reason
210 * for the carrier off, so it should kick the thread. Only queues which
211 * brought it down can turn on the carrier.
212 */
213 QUEUE_STATUS_RX_STALLED
214}; 211};
215 212
216struct xenvif { 213struct xenvif {
@@ -228,9 +225,6 @@ struct xenvif {
228 u8 ip_csum:1; 225 u8 ip_csum:1;
229 u8 ipv6_csum:1; 226 u8 ipv6_csum:1;
230 227
231 /* Internal feature information. */
232 u8 can_queue:1; /* can queue packets for receiver? */
233
234 /* Is this interface disabled? True when backend discovers 228 /* Is this interface disabled? True when backend discovers
235 * frontend is rogue. 229 * frontend is rogue.
236 */ 230 */
@@ -240,6 +234,9 @@ struct xenvif {
240 /* Queues */ 234 /* Queues */
241 struct xenvif_queue *queues; 235 struct xenvif_queue *queues;
242 unsigned int num_queues; /* active queues, resource allocated */ 236 unsigned int num_queues; /* active queues, resource allocated */
237 unsigned int stalled_queues;
238
239 spinlock_t lock;
243 240
244#ifdef CONFIG_DEBUG_FS 241#ifdef CONFIG_DEBUG_FS
245 struct dentry *xenvif_dbg_root; 242 struct dentry *xenvif_dbg_root;
@@ -249,6 +246,14 @@ struct xenvif {
249 struct net_device *dev; 246 struct net_device *dev;
250}; 247};
251 248
249struct xenvif_rx_cb {
250 unsigned long expires;
251 int meta_slots_used;
252 bool full_coalesce;
253};
254
255#define XENVIF_RX_CB(skb) ((struct xenvif_rx_cb *)(skb)->cb)
256
252static inline struct xenbus_device *xenvif_to_xenbus_device(struct xenvif *vif) 257static inline struct xenbus_device *xenvif_to_xenbus_device(struct xenvif *vif)
253{ 258{
254 return to_xenbus_device(vif->dev->dev.parent); 259 return to_xenbus_device(vif->dev->dev.parent);
@@ -272,8 +277,6 @@ void xenvif_xenbus_fini(void);
272 277
273int xenvif_schedulable(struct xenvif *vif); 278int xenvif_schedulable(struct xenvif *vif);
274 279
275int xenvif_must_stop_queue(struct xenvif_queue *queue);
276
277int xenvif_queue_stopped(struct xenvif_queue *queue); 280int xenvif_queue_stopped(struct xenvif_queue *queue);
278void xenvif_wake_queue(struct xenvif_queue *queue); 281void xenvif_wake_queue(struct xenvif_queue *queue);
279 282
@@ -296,6 +299,8 @@ void xenvif_kick_thread(struct xenvif_queue *queue);
296 299
297int xenvif_dealloc_kthread(void *data); 300int xenvif_dealloc_kthread(void *data);
298 301
302void xenvif_rx_queue_tail(struct xenvif_queue *queue, struct sk_buff *skb);
303
299/* Determine whether the needed number of slots (req) are available, 304/* Determine whether the needed number of slots (req) are available,
300 * and set req_event if not. 305 * and set req_event if not.
301 */ 306 */
diff --git a/drivers/net/xen-netback/interface.c b/drivers/net/xen-netback/interface.c
index f379689dde30..895fe84011e7 100644
--- a/drivers/net/xen-netback/interface.c
+++ b/drivers/net/xen-netback/interface.c
@@ -43,6 +43,9 @@
43#define XENVIF_QUEUE_LENGTH 32 43#define XENVIF_QUEUE_LENGTH 32
44#define XENVIF_NAPI_WEIGHT 64 44#define XENVIF_NAPI_WEIGHT 64
45 45
46/* Number of bytes allowed on the internal guest Rx queue. */
47#define XENVIF_RX_QUEUE_BYTES (XEN_NETIF_RX_RING_SIZE/2 * PAGE_SIZE)
48
46/* This function is used to set SKBTX_DEV_ZEROCOPY as well as 49/* This function is used to set SKBTX_DEV_ZEROCOPY as well as
47 * increasing the inflight counter. We need to increase the inflight 50 * increasing the inflight counter. We need to increase the inflight
48 * counter because core driver calls into xenvif_zerocopy_callback 51 * counter because core driver calls into xenvif_zerocopy_callback
@@ -60,20 +63,11 @@ void xenvif_skb_zerocopy_complete(struct xenvif_queue *queue)
60 atomic_dec(&queue->inflight_packets); 63 atomic_dec(&queue->inflight_packets);
61} 64}
62 65
63static inline void xenvif_stop_queue(struct xenvif_queue *queue)
64{
65 struct net_device *dev = queue->vif->dev;
66
67 if (!queue->vif->can_queue)
68 return;
69
70 netif_tx_stop_queue(netdev_get_tx_queue(dev, queue->id));
71}
72
73int xenvif_schedulable(struct xenvif *vif) 66int xenvif_schedulable(struct xenvif *vif)
74{ 67{
75 return netif_running(vif->dev) && 68 return netif_running(vif->dev) &&
76 test_bit(VIF_STATUS_CONNECTED, &vif->status); 69 test_bit(VIF_STATUS_CONNECTED, &vif->status) &&
70 !vif->disabled;
77} 71}
78 72
79static irqreturn_t xenvif_tx_interrupt(int irq, void *dev_id) 73static irqreturn_t xenvif_tx_interrupt(int irq, void *dev_id)
@@ -114,16 +108,7 @@ int xenvif_poll(struct napi_struct *napi, int budget)
114static irqreturn_t xenvif_rx_interrupt(int irq, void *dev_id) 108static irqreturn_t xenvif_rx_interrupt(int irq, void *dev_id)
115{ 109{
116 struct xenvif_queue *queue = dev_id; 110 struct xenvif_queue *queue = dev_id;
117 struct netdev_queue *net_queue =
118 netdev_get_tx_queue(queue->vif->dev, queue->id);
119 111
120 /* QUEUE_STATUS_RX_PURGE_EVENT is only set if either QDisc was off OR
121 * the carrier went down and this queue was previously blocked
122 */
123 if (unlikely(netif_tx_queue_stopped(net_queue) ||
124 (!netif_carrier_ok(queue->vif->dev) &&
125 test_bit(QUEUE_STATUS_RX_STALLED, &queue->status))))
126 set_bit(QUEUE_STATUS_RX_PURGE_EVENT, &queue->status);
127 xenvif_kick_thread(queue); 112 xenvif_kick_thread(queue);
128 113
129 return IRQ_HANDLED; 114 return IRQ_HANDLED;
@@ -151,24 +136,13 @@ void xenvif_wake_queue(struct xenvif_queue *queue)
151 netif_tx_wake_queue(netdev_get_tx_queue(dev, id)); 136 netif_tx_wake_queue(netdev_get_tx_queue(dev, id));
152} 137}
153 138
154/* Callback to wake the queue's thread and turn the carrier off on timeout */
155static void xenvif_rx_stalled(unsigned long data)
156{
157 struct xenvif_queue *queue = (struct xenvif_queue *)data;
158
159 if (xenvif_queue_stopped(queue)) {
160 set_bit(QUEUE_STATUS_RX_PURGE_EVENT, &queue->status);
161 xenvif_kick_thread(queue);
162 }
163}
164
165static int xenvif_start_xmit(struct sk_buff *skb, struct net_device *dev) 139static int xenvif_start_xmit(struct sk_buff *skb, struct net_device *dev)
166{ 140{
167 struct xenvif *vif = netdev_priv(dev); 141 struct xenvif *vif = netdev_priv(dev);
168 struct xenvif_queue *queue = NULL; 142 struct xenvif_queue *queue = NULL;
169 unsigned int num_queues = vif->num_queues; 143 unsigned int num_queues = vif->num_queues;
170 u16 index; 144 u16 index;
171 int min_slots_needed; 145 struct xenvif_rx_cb *cb;
172 146
173 BUG_ON(skb->dev != dev); 147 BUG_ON(skb->dev != dev);
174 148
@@ -191,30 +165,10 @@ static int xenvif_start_xmit(struct sk_buff *skb, struct net_device *dev)
191 !xenvif_schedulable(vif)) 165 !xenvif_schedulable(vif))
192 goto drop; 166 goto drop;
193 167
194 /* At best we'll need one slot for the header and one for each 168 cb = XENVIF_RX_CB(skb);
195 * frag. 169 cb->expires = jiffies + rx_drain_timeout_jiffies;
196 */
197 min_slots_needed = 1 + skb_shinfo(skb)->nr_frags;
198
199 /* If the skb is GSO then we'll also need an extra slot for the
200 * metadata.
201 */
202 if (skb_is_gso(skb))
203 min_slots_needed++;
204 170
205 /* If the skb can't possibly fit in the remaining slots 171 xenvif_rx_queue_tail(queue, skb);
206 * then turn off the queue to give the ring a chance to
207 * drain.
208 */
209 if (!xenvif_rx_ring_slots_available(queue, min_slots_needed)) {
210 queue->rx_stalled.function = xenvif_rx_stalled;
211 queue->rx_stalled.data = (unsigned long)queue;
212 xenvif_stop_queue(queue);
213 mod_timer(&queue->rx_stalled,
214 jiffies + rx_drain_timeout_jiffies);
215 }
216
217 skb_queue_tail(&queue->rx_queue, skb);
218 xenvif_kick_thread(queue); 172 xenvif_kick_thread(queue);
219 173
220 return NETDEV_TX_OK; 174 return NETDEV_TX_OK;
@@ -465,6 +419,8 @@ struct xenvif *xenvif_alloc(struct device *parent, domid_t domid,
465 vif->queues = NULL; 419 vif->queues = NULL;
466 vif->num_queues = 0; 420 vif->num_queues = 0;
467 421
422 spin_lock_init(&vif->lock);
423
468 dev->netdev_ops = &xenvif_netdev_ops; 424 dev->netdev_ops = &xenvif_netdev_ops;
469 dev->hw_features = NETIF_F_SG | 425 dev->hw_features = NETIF_F_SG |
470 NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | 426 NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM |
@@ -508,6 +464,8 @@ int xenvif_init_queue(struct xenvif_queue *queue)
508 init_timer(&queue->credit_timeout); 464 init_timer(&queue->credit_timeout);
509 queue->credit_window_start = get_jiffies_64(); 465 queue->credit_window_start = get_jiffies_64();
510 466
467 queue->rx_queue_max = XENVIF_RX_QUEUE_BYTES;
468
511 skb_queue_head_init(&queue->rx_queue); 469 skb_queue_head_init(&queue->rx_queue);
512 skb_queue_head_init(&queue->tx_queue); 470 skb_queue_head_init(&queue->tx_queue);
513 471
@@ -539,8 +497,6 @@ int xenvif_init_queue(struct xenvif_queue *queue)
539 queue->grant_tx_handle[i] = NETBACK_INVALID_HANDLE; 497 queue->grant_tx_handle[i] = NETBACK_INVALID_HANDLE;
540 } 498 }
541 499
542 init_timer(&queue->rx_stalled);
543
544 return 0; 500 return 0;
545} 501}
546 502
@@ -551,7 +507,6 @@ void xenvif_carrier_on(struct xenvif *vif)
551 dev_set_mtu(vif->dev, ETH_DATA_LEN); 507 dev_set_mtu(vif->dev, ETH_DATA_LEN);
552 netdev_update_features(vif->dev); 508 netdev_update_features(vif->dev);
553 set_bit(VIF_STATUS_CONNECTED, &vif->status); 509 set_bit(VIF_STATUS_CONNECTED, &vif->status);
554 netif_carrier_on(vif->dev);
555 if (netif_running(vif->dev)) 510 if (netif_running(vif->dev))
556 xenvif_up(vif); 511 xenvif_up(vif);
557 rtnl_unlock(); 512 rtnl_unlock();
@@ -611,6 +566,8 @@ int xenvif_connect(struct xenvif_queue *queue, unsigned long tx_ring_ref,
611 disable_irq(queue->rx_irq); 566 disable_irq(queue->rx_irq);
612 } 567 }
613 568
569 queue->stalled = true;
570
614 task = kthread_create(xenvif_kthread_guest_rx, 571 task = kthread_create(xenvif_kthread_guest_rx,
615 (void *)queue, "%s-guest-rx", queue->name); 572 (void *)queue, "%s-guest-rx", queue->name);
616 if (IS_ERR(task)) { 573 if (IS_ERR(task)) {
@@ -674,7 +631,6 @@ void xenvif_disconnect(struct xenvif *vif)
674 netif_napi_del(&queue->napi); 631 netif_napi_del(&queue->napi);
675 632
676 if (queue->task) { 633 if (queue->task) {
677 del_timer_sync(&queue->rx_stalled);
678 kthread_stop(queue->task); 634 kthread_stop(queue->task);
679 queue->task = NULL; 635 queue->task = NULL;
680 } 636 }
diff --git a/drivers/net/xen-netback/netback.c b/drivers/net/xen-netback/netback.c
index 08f65996534c..6563f0713fc0 100644
--- a/drivers/net/xen-netback/netback.c
+++ b/drivers/net/xen-netback/netback.c
@@ -55,13 +55,20 @@
55bool separate_tx_rx_irq = 1; 55bool separate_tx_rx_irq = 1;
56module_param(separate_tx_rx_irq, bool, 0644); 56module_param(separate_tx_rx_irq, bool, 0644);
57 57
58/* When guest ring is filled up, qdisc queues the packets for us, but we have 58/* The time that packets can stay on the guest Rx internal queue
59 * to timeout them, otherwise other guests' packets can get stuck there 59 * before they are dropped.
60 */ 60 */
61unsigned int rx_drain_timeout_msecs = 10000; 61unsigned int rx_drain_timeout_msecs = 10000;
62module_param(rx_drain_timeout_msecs, uint, 0444); 62module_param(rx_drain_timeout_msecs, uint, 0444);
63unsigned int rx_drain_timeout_jiffies; 63unsigned int rx_drain_timeout_jiffies;
64 64
65/* The length of time before the frontend is considered unresponsive
66 * because it isn't providing Rx slots.
67 */
68static unsigned int rx_stall_timeout_msecs = 60000;
69module_param(rx_stall_timeout_msecs, uint, 0444);
70static unsigned int rx_stall_timeout_jiffies;
71
65unsigned int xenvif_max_queues; 72unsigned int xenvif_max_queues;
66module_param_named(max_queues, xenvif_max_queues, uint, 0644); 73module_param_named(max_queues, xenvif_max_queues, uint, 0644);
67MODULE_PARM_DESC(max_queues, 74MODULE_PARM_DESC(max_queues,
@@ -83,7 +90,6 @@ static void make_tx_response(struct xenvif_queue *queue,
83 s8 st); 90 s8 st);
84 91
85static inline int tx_work_todo(struct xenvif_queue *queue); 92static inline int tx_work_todo(struct xenvif_queue *queue);
86static inline int rx_work_todo(struct xenvif_queue *queue);
87 93
88static struct xen_netif_rx_response *make_rx_response(struct xenvif_queue *queue, 94static struct xen_netif_rx_response *make_rx_response(struct xenvif_queue *queue,
89 u16 id, 95 u16 id,
@@ -163,6 +169,69 @@ bool xenvif_rx_ring_slots_available(struct xenvif_queue *queue, int needed)
163 return false; 169 return false;
164} 170}
165 171
172void xenvif_rx_queue_tail(struct xenvif_queue *queue, struct sk_buff *skb)
173{
174 unsigned long flags;
175
176 spin_lock_irqsave(&queue->rx_queue.lock, flags);
177
178 __skb_queue_tail(&queue->rx_queue, skb);
179
180 queue->rx_queue_len += skb->len;
181 if (queue->rx_queue_len > queue->rx_queue_max)
182 netif_tx_stop_queue(netdev_get_tx_queue(queue->vif->dev, queue->id));
183
184 spin_unlock_irqrestore(&queue->rx_queue.lock, flags);
185}
186
187static struct sk_buff *xenvif_rx_dequeue(struct xenvif_queue *queue)
188{
189 struct sk_buff *skb;
190
191 spin_lock_irq(&queue->rx_queue.lock);
192
193 skb = __skb_dequeue(&queue->rx_queue);
194 if (skb)
195 queue->rx_queue_len -= skb->len;
196
197 spin_unlock_irq(&queue->rx_queue.lock);
198
199 return skb;
200}
201
202static void xenvif_rx_queue_maybe_wake(struct xenvif_queue *queue)
203{
204 spin_lock_irq(&queue->rx_queue.lock);
205
206 if (queue->rx_queue_len < queue->rx_queue_max)
207 netif_tx_wake_queue(netdev_get_tx_queue(queue->vif->dev, queue->id));
208
209 spin_unlock_irq(&queue->rx_queue.lock);
210}
211
212
213static void xenvif_rx_queue_purge(struct xenvif_queue *queue)
214{
215 struct sk_buff *skb;
216 while ((skb = xenvif_rx_dequeue(queue)) != NULL)
217 kfree_skb(skb);
218}
219
220static void xenvif_rx_queue_drop_expired(struct xenvif_queue *queue)
221{
222 struct sk_buff *skb;
223
224 for(;;) {
225 skb = skb_peek(&queue->rx_queue);
226 if (!skb)
227 break;
228 if (time_before(jiffies, XENVIF_RX_CB(skb)->expires))
229 break;
230 xenvif_rx_dequeue(queue);
231 kfree_skb(skb);
232 }
233}
234
166/* 235/*
167 * Returns true if we should start a new receive buffer instead of 236 * Returns true if we should start a new receive buffer instead of
168 * adding 'size' bytes to a buffer which currently contains 'offset' 237 * adding 'size' bytes to a buffer which currently contains 'offset'
@@ -237,13 +306,6 @@ static struct xenvif_rx_meta *get_next_rx_buffer(struct xenvif_queue *queue,
237 return meta; 306 return meta;
238} 307}
239 308
240struct xenvif_rx_cb {
241 int meta_slots_used;
242 bool full_coalesce;
243};
244
245#define XENVIF_RX_CB(skb) ((struct xenvif_rx_cb *)(skb)->cb)
246
247/* 309/*
248 * Set up the grant operations for this fragment. If it's a flipping 310 * Set up the grant operations for this fragment. If it's a flipping
249 * interface, we also set up the unmap request from here. 311 * interface, we also set up the unmap request from here.
@@ -587,12 +649,15 @@ static void xenvif_rx_action(struct xenvif_queue *queue)
587 649
588 skb_queue_head_init(&rxq); 650 skb_queue_head_init(&rxq);
589 651
590 while ((skb = skb_dequeue(&queue->rx_queue)) != NULL) { 652 while (xenvif_rx_ring_slots_available(queue, XEN_NETBK_RX_SLOTS_MAX)
653 && (skb = xenvif_rx_dequeue(queue)) != NULL) {
591 RING_IDX max_slots_needed; 654 RING_IDX max_slots_needed;
592 RING_IDX old_req_cons; 655 RING_IDX old_req_cons;
593 RING_IDX ring_slots_used; 656 RING_IDX ring_slots_used;
594 int i; 657 int i;
595 658
659 queue->last_rx_time = jiffies;
660
596 /* We need a cheap worse case estimate for the number of 661 /* We need a cheap worse case estimate for the number of
597 * slots we'll use. 662 * slots we'll use.
598 */ 663 */
@@ -634,15 +699,6 @@ static void xenvif_rx_action(struct xenvif_queue *queue)
634 skb_shinfo(skb)->gso_type & SKB_GSO_TCPV6)) 699 skb_shinfo(skb)->gso_type & SKB_GSO_TCPV6))
635 max_slots_needed++; 700 max_slots_needed++;
636 701
637 /* If the skb may not fit then bail out now */
638 if (!xenvif_rx_ring_slots_available(queue, max_slots_needed)) {
639 skb_queue_head(&queue->rx_queue, skb);
640 need_to_notify = true;
641 queue->rx_last_skb_slots = max_slots_needed;
642 break;
643 } else
644 queue->rx_last_skb_slots = 0;
645
646 old_req_cons = queue->rx.req_cons; 702 old_req_cons = queue->rx.req_cons;
647 XENVIF_RX_CB(skb)->meta_slots_used = xenvif_gop_skb(skb, &npo, queue); 703 XENVIF_RX_CB(skb)->meta_slots_used = xenvif_gop_skb(skb, &npo, queue);
648 ring_slots_used = queue->rx.req_cons - old_req_cons; 704 ring_slots_used = queue->rx.req_cons - old_req_cons;
@@ -1869,12 +1925,6 @@ void xenvif_idx_unmap(struct xenvif_queue *queue, u16 pending_idx)
1869 } 1925 }
1870} 1926}
1871 1927
1872static inline int rx_work_todo(struct xenvif_queue *queue)
1873{
1874 return (!skb_queue_empty(&queue->rx_queue) &&
1875 xenvif_rx_ring_slots_available(queue, queue->rx_last_skb_slots));
1876}
1877
1878static inline int tx_work_todo(struct xenvif_queue *queue) 1928static inline int tx_work_todo(struct xenvif_queue *queue)
1879{ 1929{
1880 if (likely(RING_HAS_UNCONSUMED_REQUESTS(&queue->tx))) 1930 if (likely(RING_HAS_UNCONSUMED_REQUESTS(&queue->tx)))
@@ -1931,92 +1981,121 @@ err:
1931 return err; 1981 return err;
1932} 1982}
1933 1983
1934static void xenvif_start_queue(struct xenvif_queue *queue) 1984static void xenvif_queue_carrier_off(struct xenvif_queue *queue)
1935{ 1985{
1936 if (xenvif_schedulable(queue->vif)) 1986 struct xenvif *vif = queue->vif;
1937 xenvif_wake_queue(queue); 1987
1988 queue->stalled = true;
1989
1990 /* At least one queue has stalled? Disable the carrier. */
1991 spin_lock(&vif->lock);
1992 if (vif->stalled_queues++ == 0) {
1993 netdev_info(vif->dev, "Guest Rx stalled");
1994 netif_carrier_off(vif->dev);
1995 }
1996 spin_unlock(&vif->lock);
1938} 1997}
1939 1998
1940/* Only called from the queue's thread, it handles the situation when the guest 1999static void xenvif_queue_carrier_on(struct xenvif_queue *queue)
1941 * doesn't post enough requests on the receiving ring.
1942 * First xenvif_start_xmit disables QDisc and start a timer, and then either the
1943 * timer fires, or the guest send an interrupt after posting new request. If it
1944 * is the timer, the carrier is turned off here.
1945 * */
1946static void xenvif_rx_purge_event(struct xenvif_queue *queue)
1947{ 2000{
1948 /* Either the last unsuccesful skb or at least 1 slot should fit */ 2001 struct xenvif *vif = queue->vif;
1949 int needed = queue->rx_last_skb_slots ?
1950 queue->rx_last_skb_slots : 1;
1951 2002
1952 /* It is assumed that if the guest post new slots after this, the RX 2003 queue->last_rx_time = jiffies; /* Reset Rx stall detection. */
1953 * interrupt will set the QUEUE_STATUS_RX_PURGE_EVENT bit and wake up 2004 queue->stalled = false;
1954 * the thread again
1955 */
1956 set_bit(QUEUE_STATUS_RX_STALLED, &queue->status);
1957 if (!xenvif_rx_ring_slots_available(queue, needed)) {
1958 rtnl_lock();
1959 if (netif_carrier_ok(queue->vif->dev)) {
1960 /* Timer fired and there are still no slots. Turn off
1961 * everything except the interrupts
1962 */
1963 netif_carrier_off(queue->vif->dev);
1964 skb_queue_purge(&queue->rx_queue);
1965 queue->rx_last_skb_slots = 0;
1966 if (net_ratelimit())
1967 netdev_err(queue->vif->dev, "Carrier off due to lack of guest response on queue %d\n", queue->id);
1968 } else {
1969 /* Probably an another queue already turned the carrier
1970 * off, make sure nothing is stucked in the internal
1971 * queue of this queue
1972 */
1973 skb_queue_purge(&queue->rx_queue);
1974 queue->rx_last_skb_slots = 0;
1975 }
1976 rtnl_unlock();
1977 } else if (!netif_carrier_ok(queue->vif->dev)) {
1978 unsigned int num_queues = queue->vif->num_queues;
1979 unsigned int i;
1980 /* The carrier was down, but an interrupt kicked
1981 * the thread again after new requests were
1982 * posted
1983 */
1984 clear_bit(QUEUE_STATUS_RX_STALLED,
1985 &queue->status);
1986 rtnl_lock();
1987 netif_carrier_on(queue->vif->dev);
1988 netif_tx_wake_all_queues(queue->vif->dev);
1989 rtnl_unlock();
1990 2005
1991 for (i = 0; i < num_queues; i++) { 2006 /* All queues are ready? Enable the carrier. */
1992 struct xenvif_queue *temp = &queue->vif->queues[i]; 2007 spin_lock(&vif->lock);
2008 if (--vif->stalled_queues == 0) {
2009 netdev_info(vif->dev, "Guest Rx ready");
2010 netif_carrier_on(vif->dev);
2011 }
2012 spin_unlock(&vif->lock);
2013}
1993 2014
1994 xenvif_napi_schedule_or_enable_events(temp); 2015static bool xenvif_rx_queue_stalled(struct xenvif_queue *queue)
1995 } 2016{
1996 if (net_ratelimit()) 2017 RING_IDX prod, cons;
1997 netdev_err(queue->vif->dev, "Carrier on again\n"); 2018
1998 } else { 2019 prod = queue->rx.sring->req_prod;
1999 /* Queuing were stopped, but the guest posted 2020 cons = queue->rx.req_cons;
2000 * new requests and sent an interrupt 2021
2001 */ 2022 return !queue->stalled
2002 clear_bit(QUEUE_STATUS_RX_STALLED, 2023 && prod - cons < XEN_NETBK_RX_SLOTS_MAX
2003 &queue->status); 2024 && time_after(jiffies,
2004 del_timer_sync(&queue->rx_stalled); 2025 queue->last_rx_time + rx_stall_timeout_jiffies);
2005 xenvif_start_queue(queue); 2026}
2027
2028static bool xenvif_rx_queue_ready(struct xenvif_queue *queue)
2029{
2030 RING_IDX prod, cons;
2031
2032 prod = queue->rx.sring->req_prod;
2033 cons = queue->rx.req_cons;
2034
2035 return queue->stalled
2036 && prod - cons >= XEN_NETBK_RX_SLOTS_MAX;
2037}
2038
2039static bool xenvif_have_rx_work(struct xenvif_queue *queue)
2040{
2041 return (!skb_queue_empty(&queue->rx_queue)
2042 && xenvif_rx_ring_slots_available(queue, XEN_NETBK_RX_SLOTS_MAX))
2043 || xenvif_rx_queue_stalled(queue)
2044 || xenvif_rx_queue_ready(queue)
2045 || kthread_should_stop()
2046 || queue->vif->disabled;
2047}
2048
2049static long xenvif_rx_queue_timeout(struct xenvif_queue *queue)
2050{
2051 struct sk_buff *skb;
2052 long timeout;
2053
2054 skb = skb_peek(&queue->rx_queue);
2055 if (!skb)
2056 return MAX_SCHEDULE_TIMEOUT;
2057
2058 timeout = XENVIF_RX_CB(skb)->expires - jiffies;
2059 return timeout < 0 ? 0 : timeout;
2060}
2061
2062/* Wait until the guest Rx thread has work.
2063 *
2064 * The timeout needs to be adjusted based on the current head of the
2065 * queue (and not just the head at the beginning). In particular, if
2066 * the queue is initially empty an infinite timeout is used and this
2067 * needs to be reduced when a skb is queued.
2068 *
2069 * This cannot be done with wait_event_timeout() because it only
2070 * calculates the timeout once.
2071 */
2072static void xenvif_wait_for_rx_work(struct xenvif_queue *queue)
2073{
2074 DEFINE_WAIT(wait);
2075
2076 if (xenvif_have_rx_work(queue))
2077 return;
2078
2079 for (;;) {
2080 long ret;
2081
2082 prepare_to_wait(&queue->wq, &wait, TASK_INTERRUPTIBLE);
2083 if (xenvif_have_rx_work(queue))
2084 break;
2085 ret = schedule_timeout(xenvif_rx_queue_timeout(queue));
2086 if (!ret)
2087 break;
2006 } 2088 }
2089 finish_wait(&queue->wq, &wait);
2007} 2090}
2008 2091
2009int xenvif_kthread_guest_rx(void *data) 2092int xenvif_kthread_guest_rx(void *data)
2010{ 2093{
2011 struct xenvif_queue *queue = data; 2094 struct xenvif_queue *queue = data;
2012 struct sk_buff *skb; 2095 struct xenvif *vif = queue->vif;
2013 2096
2014 while (!kthread_should_stop()) { 2097 for (;;) {
2015 wait_event_interruptible(queue->wq, 2098 xenvif_wait_for_rx_work(queue);
2016 rx_work_todo(queue) ||
2017 queue->vif->disabled ||
2018 test_bit(QUEUE_STATUS_RX_PURGE_EVENT, &queue->status) ||
2019 kthread_should_stop());
2020 2099
2021 if (kthread_should_stop()) 2100 if (kthread_should_stop())
2022 break; 2101 break;
@@ -2028,35 +2107,38 @@ int xenvif_kthread_guest_rx(void *data)
2028 * context so we defer it here, if this thread is 2107 * context so we defer it here, if this thread is
2029 * associated with queue 0. 2108 * associated with queue 0.
2030 */ 2109 */
2031 if (unlikely(queue->vif->disabled && queue->id == 0)) { 2110 if (unlikely(vif->disabled && queue->id == 0)) {
2032 xenvif_carrier_off(queue->vif); 2111 xenvif_carrier_off(vif);
2033 } else if (unlikely(queue->vif->disabled)) { 2112 xenvif_rx_queue_purge(queue);
2034 /* kthread_stop() would be called upon this thread soon, 2113 continue;
2035 * be a bit proactive
2036 */
2037 skb_queue_purge(&queue->rx_queue);
2038 queue->rx_last_skb_slots = 0;
2039 } else if (unlikely(test_and_clear_bit(QUEUE_STATUS_RX_PURGE_EVENT,
2040 &queue->status))) {
2041 xenvif_rx_purge_event(queue);
2042 } else if (!netif_carrier_ok(queue->vif->dev)) {
2043 /* Another queue stalled and turned the carrier off, so
2044 * purge the internal queue of queues which were not
2045 * blocked
2046 */
2047 skb_queue_purge(&queue->rx_queue);
2048 queue->rx_last_skb_slots = 0;
2049 } 2114 }
2050 2115
2051 if (!skb_queue_empty(&queue->rx_queue)) 2116 if (!skb_queue_empty(&queue->rx_queue))
2052 xenvif_rx_action(queue); 2117 xenvif_rx_action(queue);
2053 2118
2119 /* If the guest hasn't provided any Rx slots for a
2120 * while it's probably not responsive, drop the
2121 * carrier so packets are dropped earlier.
2122 */
2123 if (xenvif_rx_queue_stalled(queue))
2124 xenvif_queue_carrier_off(queue);
2125 else if (xenvif_rx_queue_ready(queue))
2126 xenvif_queue_carrier_on(queue);
2127
2128 /* Queued packets may have foreign pages from other
2129 * domains. These cannot be queued indefinitely as
2130 * this would starve guests of grant refs and transmit
2131 * slots.
2132 */
2133 xenvif_rx_queue_drop_expired(queue);
2134
2135 xenvif_rx_queue_maybe_wake(queue);
2136
2054 cond_resched(); 2137 cond_resched();
2055 } 2138 }
2056 2139
2057 /* Bin any remaining skbs */ 2140 /* Bin any remaining skbs */
2058 while ((skb = skb_dequeue(&queue->rx_queue)) != NULL) 2141 xenvif_rx_queue_purge(queue);
2059 dev_kfree_skb(skb);
2060 2142
2061 return 0; 2143 return 0;
2062} 2144}
@@ -2113,6 +2195,7 @@ static int __init netback_init(void)
2113 goto failed_init; 2195 goto failed_init;
2114 2196
2115 rx_drain_timeout_jiffies = msecs_to_jiffies(rx_drain_timeout_msecs); 2197 rx_drain_timeout_jiffies = msecs_to_jiffies(rx_drain_timeout_msecs);
2198 rx_stall_timeout_jiffies = msecs_to_jiffies(rx_stall_timeout_msecs);
2116 2199
2117#ifdef CONFIG_DEBUG_FS 2200#ifdef CONFIG_DEBUG_FS
2118 xen_netback_dbg_root = debugfs_create_dir("xen-netback", NULL); 2201 xen_netback_dbg_root = debugfs_create_dir("xen-netback", NULL);
diff --git a/drivers/net/xen-netback/xenbus.c b/drivers/net/xen-netback/xenbus.c
index 8079c31ac5e6..4e56a27f9689 100644
--- a/drivers/net/xen-netback/xenbus.c
+++ b/drivers/net/xen-netback/xenbus.c
@@ -52,6 +52,7 @@ static int xenvif_read_io_ring(struct seq_file *m, void *v)
52 struct xenvif_queue *queue = m->private; 52 struct xenvif_queue *queue = m->private;
53 struct xen_netif_tx_back_ring *tx_ring = &queue->tx; 53 struct xen_netif_tx_back_ring *tx_ring = &queue->tx;
54 struct xen_netif_rx_back_ring *rx_ring = &queue->rx; 54 struct xen_netif_rx_back_ring *rx_ring = &queue->rx;
55 struct netdev_queue *dev_queue;
55 56
56 if (tx_ring->sring) { 57 if (tx_ring->sring) {
57 struct xen_netif_tx_sring *sring = tx_ring->sring; 58 struct xen_netif_tx_sring *sring = tx_ring->sring;
@@ -112,6 +113,13 @@ static int xenvif_read_io_ring(struct seq_file *m, void *v)
112 queue->credit_timeout.expires, 113 queue->credit_timeout.expires,
113 jiffies); 114 jiffies);
114 115
116 dev_queue = netdev_get_tx_queue(queue->vif->dev, queue->id);
117
118 seq_printf(m, "\nRx internal queue: len %u max %u pkts %u %s\n",
119 queue->rx_queue_len, queue->rx_queue_max,
120 skb_queue_len(&queue->rx_queue),
121 netif_tx_queue_stopped(dev_queue) ? "stopped" : "running");
122
115 return 0; 123 return 0;
116} 124}
117 125
@@ -703,6 +711,7 @@ static void connect(struct backend_info *be)
703 be->vif->queues = vzalloc(requested_num_queues * 711 be->vif->queues = vzalloc(requested_num_queues *
704 sizeof(struct xenvif_queue)); 712 sizeof(struct xenvif_queue));
705 be->vif->num_queues = requested_num_queues; 713 be->vif->num_queues = requested_num_queues;
714 be->vif->stalled_queues = requested_num_queues;
706 715
707 for (queue_index = 0; queue_index < requested_num_queues; ++queue_index) { 716 for (queue_index = 0; queue_index < requested_num_queues; ++queue_index) {
708 queue = &be->vif->queues[queue_index]; 717 queue = &be->vif->queues[queue_index];
@@ -873,15 +882,10 @@ static int read_xenbus_vif_flags(struct backend_info *be)
873 if (!rx_copy) 882 if (!rx_copy)
874 return -EOPNOTSUPP; 883 return -EOPNOTSUPP;
875 884
876 if (vif->dev->tx_queue_len != 0) { 885 if (xenbus_scanf(XBT_NIL, dev->otherend,
877 if (xenbus_scanf(XBT_NIL, dev->otherend, 886 "feature-rx-notify", "%d", &val) < 0 || val == 0) {
878 "feature-rx-notify", "%d", &val) < 0) 887 xenbus_dev_fatal(dev, -EINVAL, "feature-rx-notify is mandatory");
879 val = 0; 888 return -EINVAL;
880 if (val)
881 vif->can_queue = 1;
882 else
883 /* Must be non-zero for pfifo_fast to work. */
884 vif->dev->tx_queue_len = 1;
885 } 889 }
886 890
887 if (xenbus_scanf(XBT_NIL, dev->otherend, "feature-sg", 891 if (xenbus_scanf(XBT_NIL, dev->otherend, "feature-sg",
diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
index 59fb12e84e6b..dc566b38645f 100644
--- a/drivers/of/of_reserved_mem.c
+++ b/drivers/of/of_reserved_mem.c
@@ -243,23 +243,27 @@ static inline struct reserved_mem *__find_rmem(struct device_node *node)
243 * This function assign memory region pointed by "memory-region" device tree 243 * This function assign memory region pointed by "memory-region" device tree
244 * property to the given device. 244 * property to the given device.
245 */ 245 */
246void of_reserved_mem_device_init(struct device *dev) 246int of_reserved_mem_device_init(struct device *dev)
247{ 247{
248 struct reserved_mem *rmem; 248 struct reserved_mem *rmem;
249 struct device_node *np; 249 struct device_node *np;
250 int ret;
250 251
251 np = of_parse_phandle(dev->of_node, "memory-region", 0); 252 np = of_parse_phandle(dev->of_node, "memory-region", 0);
252 if (!np) 253 if (!np)
253 return; 254 return -ENODEV;
254 255
255 rmem = __find_rmem(np); 256 rmem = __find_rmem(np);
256 of_node_put(np); 257 of_node_put(np);
257 258
258 if (!rmem || !rmem->ops || !rmem->ops->device_init) 259 if (!rmem || !rmem->ops || !rmem->ops->device_init)
259 return; 260 return -EINVAL;
261
262 ret = rmem->ops->device_init(rmem, dev);
263 if (ret == 0)
264 dev_info(dev, "assigned reserved memory node %s\n", rmem->name);
260 265
261 rmem->ops->device_init(rmem, dev); 266 return ret;
262 dev_info(dev, "assigned reserved memory node %s\n", rmem->name);
263} 267}
264 268
265/** 269/**
diff --git a/drivers/pci/host/pci-imx6.c b/drivers/pci/host/pci-imx6.c
index 233fe8a88264..69202d1eb8fb 100644
--- a/drivers/pci/host/pci-imx6.c
+++ b/drivers/pci/host/pci-imx6.c
@@ -275,15 +275,22 @@ static int imx6_pcie_deassert_core_reset(struct pcie_port *pp)
275 goto err_pcie; 275 goto err_pcie;
276 } 276 }
277 277
278 /* allow the clocks to stabilize */
279 usleep_range(200, 500);
280
281 /* power up core phy and enable ref clock */ 278 /* power up core phy and enable ref clock */
282 regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR1, 279 regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR1,
283 IMX6Q_GPR1_PCIE_TEST_PD, 0 << 18); 280 IMX6Q_GPR1_PCIE_TEST_PD, 0 << 18);
281 /*
282 * the async reset input need ref clock to sync internally,
283 * when the ref clock comes after reset, internal synced
284 * reset time is too short, cannot meet the requirement.
285 * add one ~10us delay here.
286 */
287 udelay(10);
284 regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR1, 288 regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR1,
285 IMX6Q_GPR1_PCIE_REF_CLK_EN, 1 << 16); 289 IMX6Q_GPR1_PCIE_REF_CLK_EN, 1 << 16);
286 290
291 /* allow the clocks to stabilize */
292 usleep_range(200, 500);
293
287 /* Some boards don't have PCIe reset GPIO. */ 294 /* Some boards don't have PCIe reset GPIO. */
288 if (gpio_is_valid(imx6_pcie->reset_gpio)) { 295 if (gpio_is_valid(imx6_pcie->reset_gpio)) {
289 gpio_set_value(imx6_pcie->reset_gpio, 0); 296 gpio_set_value(imx6_pcie->reset_gpio, 0);
diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
index 3a5e7e28b874..07aa722bb12c 100644
--- a/drivers/pci/hotplug/pciehp_core.c
+++ b/drivers/pci/hotplug/pciehp_core.c
@@ -262,13 +262,6 @@ static int pciehp_probe(struct pcie_device *dev)
262 goto err_out_none; 262 goto err_out_none;
263 } 263 }
264 264
265 if (!dev->port->subordinate) {
266 /* Can happen if we run out of bus numbers during probe */
267 dev_err(&dev->device,
268 "Hotplug bridge without secondary bus, ignoring\n");
269 goto err_out_none;
270 }
271
272 ctrl = pcie_init(dev); 265 ctrl = pcie_init(dev);
273 if (!ctrl) { 266 if (!ctrl) {
274 dev_err(&dev->device, "Controller initialization failed\n"); 267 dev_err(&dev->device, "Controller initialization failed\n");
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 92b6d9ab00e4..2c6643fdc0cf 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -185,7 +185,7 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
185} 185}
186static DEVICE_ATTR_RO(modalias); 186static DEVICE_ATTR_RO(modalias);
187 187
188static ssize_t enabled_store(struct device *dev, struct device_attribute *attr, 188static ssize_t enable_store(struct device *dev, struct device_attribute *attr,
189 const char *buf, size_t count) 189 const char *buf, size_t count)
190{ 190{
191 struct pci_dev *pdev = to_pci_dev(dev); 191 struct pci_dev *pdev = to_pci_dev(dev);
@@ -210,7 +210,7 @@ static ssize_t enabled_store(struct device *dev, struct device_attribute *attr,
210 return result < 0 ? result : count; 210 return result < 0 ? result : count;
211} 211}
212 212
213static ssize_t enabled_show(struct device *dev, struct device_attribute *attr, 213static ssize_t enable_show(struct device *dev, struct device_attribute *attr,
214 char *buf) 214 char *buf)
215{ 215{
216 struct pci_dev *pdev; 216 struct pci_dev *pdev;
@@ -218,7 +218,7 @@ static ssize_t enabled_show(struct device *dev, struct device_attribute *attr,
218 pdev = to_pci_dev(dev); 218 pdev = to_pci_dev(dev);
219 return sprintf(buf, "%u\n", atomic_read(&pdev->enable_cnt)); 219 return sprintf(buf, "%u\n", atomic_read(&pdev->enable_cnt));
220} 220}
221static DEVICE_ATTR_RW(enabled); 221static DEVICE_ATTR_RW(enable);
222 222
223#ifdef CONFIG_NUMA 223#ifdef CONFIG_NUMA
224static ssize_t numa_node_show(struct device *dev, struct device_attribute *attr, 224static ssize_t numa_node_show(struct device *dev, struct device_attribute *attr,
@@ -563,7 +563,7 @@ static struct attribute *pci_dev_attrs[] = {
563#endif 563#endif
564 &dev_attr_dma_mask_bits.attr, 564 &dev_attr_dma_mask_bits.attr,
565 &dev_attr_consistent_dma_mask_bits.attr, 565 &dev_attr_consistent_dma_mask_bits.attr,
566 &dev_attr_enabled.attr, 566 &dev_attr_enable.attr,
567 &dev_attr_broken_parity_status.attr, 567 &dev_attr_broken_parity_status.attr,
568 &dev_attr_msi_bus.attr, 568 &dev_attr_msi_bus.attr,
569#if defined(CONFIG_PM_RUNTIME) && defined(CONFIG_ACPI) 569#if defined(CONFIG_PM_RUNTIME) && defined(CONFIG_ACPI)
diff --git a/drivers/pinctrl/pinctrl-baytrail.c b/drivers/pinctrl/pinctrl-baytrail.c
index e12e5b07f6d7..9dc38140194b 100644
--- a/drivers/pinctrl/pinctrl-baytrail.c
+++ b/drivers/pinctrl/pinctrl-baytrail.c
@@ -227,10 +227,14 @@ static int byt_irq_type(struct irq_data *d, unsigned type)
227 spin_lock_irqsave(&vg->lock, flags); 227 spin_lock_irqsave(&vg->lock, flags);
228 value = readl(reg); 228 value = readl(reg);
229 229
230 WARN(value & BYT_DIRECT_IRQ_EN,
231 "Bad pad config for io mode, force direct_irq_en bit clearing");
232
230 /* For level trigges the BYT_TRIG_POS and BYT_TRIG_NEG bits 233 /* For level trigges the BYT_TRIG_POS and BYT_TRIG_NEG bits
231 * are used to indicate high and low level triggering 234 * are used to indicate high and low level triggering
232 */ 235 */
233 value &= ~(BYT_TRIG_POS | BYT_TRIG_NEG | BYT_TRIG_LVL); 236 value &= ~(BYT_DIRECT_IRQ_EN | BYT_TRIG_POS | BYT_TRIG_NEG |
237 BYT_TRIG_LVL);
234 238
235 switch (type) { 239 switch (type) {
236 case IRQ_TYPE_LEVEL_HIGH: 240 case IRQ_TYPE_LEVEL_HIGH:
@@ -318,7 +322,7 @@ static int byt_gpio_direction_output(struct gpio_chip *chip,
318 "Potential Error: Setting GPIO with direct_irq_en to output"); 322 "Potential Error: Setting GPIO with direct_irq_en to output");
319 323
320 reg_val = readl(reg) | BYT_DIR_MASK; 324 reg_val = readl(reg) | BYT_DIR_MASK;
321 reg_val &= ~BYT_OUTPUT_EN; 325 reg_val &= ~(BYT_OUTPUT_EN | BYT_INPUT_EN);
322 326
323 if (value) 327 if (value)
324 writel(reg_val | BYT_LEVEL, reg); 328 writel(reg_val | BYT_LEVEL, reg);
diff --git a/drivers/regulator/rk808-regulator.c b/drivers/regulator/rk808-regulator.c
index e305416d7697..196a5c8838c4 100644
--- a/drivers/regulator/rk808-regulator.c
+++ b/drivers/regulator/rk808-regulator.c
@@ -44,7 +44,7 @@ static const int rk808_buck_config_regs[] = {
44}; 44};
45 45
46static const struct regulator_linear_range rk808_buck_voltage_ranges[] = { 46static const struct regulator_linear_range rk808_buck_voltage_ranges[] = {
47 REGULATOR_LINEAR_RANGE(700000, 0, 63, 12500), 47 REGULATOR_LINEAR_RANGE(712500, 0, 63, 12500),
48}; 48};
49 49
50static const struct regulator_linear_range rk808_buck4_voltage_ranges[] = { 50static const struct regulator_linear_range rk808_buck4_voltage_ranges[] = {
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index 94ae1798d48a..6dd12ddbabc6 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -1320,7 +1320,7 @@ config RTC_DRV_LPC32XX
1320 1320
1321config RTC_DRV_PM8XXX 1321config RTC_DRV_PM8XXX
1322 tristate "Qualcomm PMIC8XXX RTC" 1322 tristate "Qualcomm PMIC8XXX RTC"
1323 depends on MFD_PM8XXX 1323 depends on MFD_PM8XXX || MFD_SPMI_PMIC
1324 help 1324 help
1325 If you say yes here you get support for the 1325 If you say yes here you get support for the
1326 Qualcomm PMIC8XXX RTC. 1326 Qualcomm PMIC8XXX RTC.
diff --git a/drivers/rtc/rtc-bq32k.c b/drivers/rtc/rtc-bq32k.c
index 314129e66d6e..92679df6d6e2 100644
--- a/drivers/rtc/rtc-bq32k.c
+++ b/drivers/rtc/rtc-bq32k.c
@@ -160,7 +160,7 @@ static int trickle_charger_of_init(struct device *dev, struct device_node *node)
160 dev_err(dev, "bq32k: diode and resistor mismatch\n"); 160 dev_err(dev, "bq32k: diode and resistor mismatch\n");
161 return -EINVAL; 161 return -EINVAL;
162 } 162 }
163 reg = 0x25; 163 reg = 0x45;
164 break; 164 break;
165 165
166 default: 166 default:
diff --git a/drivers/rtc/rtc-pm8xxx.c b/drivers/rtc/rtc-pm8xxx.c
index 197699f358c7..5adcf111fc14 100644
--- a/drivers/rtc/rtc-pm8xxx.c
+++ b/drivers/rtc/rtc-pm8xxx.c
@@ -27,21 +27,36 @@
27 27
28/* RTC_CTRL register bit fields */ 28/* RTC_CTRL register bit fields */
29#define PM8xxx_RTC_ENABLE BIT(7) 29#define PM8xxx_RTC_ENABLE BIT(7)
30#define PM8xxx_RTC_ALARM_ENABLE BIT(1)
31#define PM8xxx_RTC_ALARM_CLEAR BIT(0) 30#define PM8xxx_RTC_ALARM_CLEAR BIT(0)
32 31
33#define NUM_8_BIT_RTC_REGS 0x4 32#define NUM_8_BIT_RTC_REGS 0x4
34 33
35/** 34/**
35 * struct pm8xxx_rtc_regs - describe RTC registers per PMIC versions
36 * @ctrl: base address of control register
37 * @write: base address of write register
38 * @read: base address of read register
39 * @alarm_ctrl: base address of alarm control register
40 * @alarm_ctrl2: base address of alarm control2 register
41 * @alarm_rw: base address of alarm read-write register
42 * @alarm_en: alarm enable mask
43 */
44struct pm8xxx_rtc_regs {
45 unsigned int ctrl;
46 unsigned int write;
47 unsigned int read;
48 unsigned int alarm_ctrl;
49 unsigned int alarm_ctrl2;
50 unsigned int alarm_rw;
51 unsigned int alarm_en;
52};
53
54/**
36 * struct pm8xxx_rtc - rtc driver internal structure 55 * struct pm8xxx_rtc - rtc driver internal structure
37 * @rtc: rtc device for this driver. 56 * @rtc: rtc device for this driver.
38 * @regmap: regmap used to access RTC registers 57 * @regmap: regmap used to access RTC registers
39 * @allow_set_time: indicates whether writing to the RTC is allowed 58 * @allow_set_time: indicates whether writing to the RTC is allowed
40 * @rtc_alarm_irq: rtc alarm irq number. 59 * @rtc_alarm_irq: rtc alarm irq number.
41 * @rtc_base: address of rtc control register.
42 * @rtc_read_base: base address of read registers.
43 * @rtc_write_base: base address of write registers.
44 * @alarm_rw_base: base address of alarm registers.
45 * @ctrl_reg: rtc control register. 60 * @ctrl_reg: rtc control register.
46 * @rtc_dev: device structure. 61 * @rtc_dev: device structure.
47 * @ctrl_reg_lock: spinlock protecting access to ctrl_reg. 62 * @ctrl_reg_lock: spinlock protecting access to ctrl_reg.
@@ -51,11 +66,7 @@ struct pm8xxx_rtc {
51 struct regmap *regmap; 66 struct regmap *regmap;
52 bool allow_set_time; 67 bool allow_set_time;
53 int rtc_alarm_irq; 68 int rtc_alarm_irq;
54 int rtc_base; 69 const struct pm8xxx_rtc_regs *regs;
55 int rtc_read_base;
56 int rtc_write_base;
57 int alarm_rw_base;
58 u8 ctrl_reg;
59 struct device *rtc_dev; 70 struct device *rtc_dev;
60 spinlock_t ctrl_reg_lock; 71 spinlock_t ctrl_reg_lock;
61}; 72};
@@ -71,8 +82,10 @@ static int pm8xxx_rtc_set_time(struct device *dev, struct rtc_time *tm)
71{ 82{
72 int rc, i; 83 int rc, i;
73 unsigned long secs, irq_flags; 84 unsigned long secs, irq_flags;
74 u8 value[NUM_8_BIT_RTC_REGS], alarm_enabled = 0, ctrl_reg; 85 u8 value[NUM_8_BIT_RTC_REGS], alarm_enabled = 0;
86 unsigned int ctrl_reg;
75 struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev); 87 struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev);
88 const struct pm8xxx_rtc_regs *regs = rtc_dd->regs;
76 89
77 if (!rtc_dd->allow_set_time) 90 if (!rtc_dd->allow_set_time)
78 return -EACCES; 91 return -EACCES;
@@ -87,30 +100,30 @@ static int pm8xxx_rtc_set_time(struct device *dev, struct rtc_time *tm)
87 dev_dbg(dev, "Seconds value to be written to RTC = %lu\n", secs); 100 dev_dbg(dev, "Seconds value to be written to RTC = %lu\n", secs);
88 101
89 spin_lock_irqsave(&rtc_dd->ctrl_reg_lock, irq_flags); 102 spin_lock_irqsave(&rtc_dd->ctrl_reg_lock, irq_flags);
90 ctrl_reg = rtc_dd->ctrl_reg;
91 103
92 if (ctrl_reg & PM8xxx_RTC_ALARM_ENABLE) { 104 rc = regmap_read(rtc_dd->regmap, regs->ctrl, &ctrl_reg);
105 if (rc)
106 goto rtc_rw_fail;
107
108 if (ctrl_reg & regs->alarm_en) {
93 alarm_enabled = 1; 109 alarm_enabled = 1;
94 ctrl_reg &= ~PM8xxx_RTC_ALARM_ENABLE; 110 ctrl_reg &= ~regs->alarm_en;
95 rc = regmap_write(rtc_dd->regmap, rtc_dd->rtc_base, ctrl_reg); 111 rc = regmap_write(rtc_dd->regmap, regs->ctrl, ctrl_reg);
96 if (rc) { 112 if (rc) {
97 dev_err(dev, "Write to RTC control register failed\n"); 113 dev_err(dev, "Write to RTC control register failed\n");
98 goto rtc_rw_fail; 114 goto rtc_rw_fail;
99 } 115 }
100 rtc_dd->ctrl_reg = ctrl_reg;
101 } else {
102 spin_unlock_irqrestore(&rtc_dd->ctrl_reg_lock, irq_flags);
103 } 116 }
104 117
105 /* Write 0 to Byte[0] */ 118 /* Write 0 to Byte[0] */
106 rc = regmap_write(rtc_dd->regmap, rtc_dd->rtc_write_base, 0); 119 rc = regmap_write(rtc_dd->regmap, regs->write, 0);
107 if (rc) { 120 if (rc) {
108 dev_err(dev, "Write to RTC write data register failed\n"); 121 dev_err(dev, "Write to RTC write data register failed\n");
109 goto rtc_rw_fail; 122 goto rtc_rw_fail;
110 } 123 }
111 124
112 /* Write Byte[1], Byte[2], Byte[3] */ 125 /* Write Byte[1], Byte[2], Byte[3] */
113 rc = regmap_bulk_write(rtc_dd->regmap, rtc_dd->rtc_write_base + 1, 126 rc = regmap_bulk_write(rtc_dd->regmap, regs->write + 1,
114 &value[1], sizeof(value) - 1); 127 &value[1], sizeof(value) - 1);
115 if (rc) { 128 if (rc) {
116 dev_err(dev, "Write to RTC write data register failed\n"); 129 dev_err(dev, "Write to RTC write data register failed\n");
@@ -118,25 +131,23 @@ static int pm8xxx_rtc_set_time(struct device *dev, struct rtc_time *tm)
118 } 131 }
119 132
120 /* Write Byte[0] */ 133 /* Write Byte[0] */
121 rc = regmap_write(rtc_dd->regmap, rtc_dd->rtc_write_base, value[0]); 134 rc = regmap_write(rtc_dd->regmap, regs->write, value[0]);
122 if (rc) { 135 if (rc) {
123 dev_err(dev, "Write to RTC write data register failed\n"); 136 dev_err(dev, "Write to RTC write data register failed\n");
124 goto rtc_rw_fail; 137 goto rtc_rw_fail;
125 } 138 }
126 139
127 if (alarm_enabled) { 140 if (alarm_enabled) {
128 ctrl_reg |= PM8xxx_RTC_ALARM_ENABLE; 141 ctrl_reg |= regs->alarm_en;
129 rc = regmap_write(rtc_dd->regmap, rtc_dd->rtc_base, ctrl_reg); 142 rc = regmap_write(rtc_dd->regmap, regs->ctrl, ctrl_reg);
130 if (rc) { 143 if (rc) {
131 dev_err(dev, "Write to RTC control register failed\n"); 144 dev_err(dev, "Write to RTC control register failed\n");
132 goto rtc_rw_fail; 145 goto rtc_rw_fail;
133 } 146 }
134 rtc_dd->ctrl_reg = ctrl_reg;
135 } 147 }
136 148
137rtc_rw_fail: 149rtc_rw_fail:
138 if (alarm_enabled) 150 spin_unlock_irqrestore(&rtc_dd->ctrl_reg_lock, irq_flags);
139 spin_unlock_irqrestore(&rtc_dd->ctrl_reg_lock, irq_flags);
140 151
141 return rc; 152 return rc;
142} 153}
@@ -148,9 +159,9 @@ static int pm8xxx_rtc_read_time(struct device *dev, struct rtc_time *tm)
148 unsigned long secs; 159 unsigned long secs;
149 unsigned int reg; 160 unsigned int reg;
150 struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev); 161 struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev);
162 const struct pm8xxx_rtc_regs *regs = rtc_dd->regs;
151 163
152 rc = regmap_bulk_read(rtc_dd->regmap, rtc_dd->rtc_read_base, 164 rc = regmap_bulk_read(rtc_dd->regmap, regs->read, value, sizeof(value));
153 value, sizeof(value));
154 if (rc) { 165 if (rc) {
155 dev_err(dev, "RTC read data register failed\n"); 166 dev_err(dev, "RTC read data register failed\n");
156 return rc; 167 return rc;
@@ -160,14 +171,14 @@ static int pm8xxx_rtc_read_time(struct device *dev, struct rtc_time *tm)
160 * Read the LSB again and check if there has been a carry over. 171 * Read the LSB again and check if there has been a carry over.
161 * If there is, redo the read operation. 172 * If there is, redo the read operation.
162 */ 173 */
163 rc = regmap_read(rtc_dd->regmap, rtc_dd->rtc_read_base, &reg); 174 rc = regmap_read(rtc_dd->regmap, regs->read, &reg);
164 if (rc < 0) { 175 if (rc < 0) {
165 dev_err(dev, "RTC read data register failed\n"); 176 dev_err(dev, "RTC read data register failed\n");
166 return rc; 177 return rc;
167 } 178 }
168 179
169 if (unlikely(reg < value[0])) { 180 if (unlikely(reg < value[0])) {
170 rc = regmap_bulk_read(rtc_dd->regmap, rtc_dd->rtc_read_base, 181 rc = regmap_bulk_read(rtc_dd->regmap, regs->read,
171 value, sizeof(value)); 182 value, sizeof(value));
172 if (rc) { 183 if (rc) {
173 dev_err(dev, "RTC read data register failed\n"); 184 dev_err(dev, "RTC read data register failed\n");
@@ -195,9 +206,11 @@ static int pm8xxx_rtc_read_time(struct device *dev, struct rtc_time *tm)
195static int pm8xxx_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm) 206static int pm8xxx_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
196{ 207{
197 int rc, i; 208 int rc, i;
198 u8 value[NUM_8_BIT_RTC_REGS], ctrl_reg; 209 u8 value[NUM_8_BIT_RTC_REGS];
210 unsigned int ctrl_reg;
199 unsigned long secs, irq_flags; 211 unsigned long secs, irq_flags;
200 struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev); 212 struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev);
213 const struct pm8xxx_rtc_regs *regs = rtc_dd->regs;
201 214
202 rtc_tm_to_time(&alarm->time, &secs); 215 rtc_tm_to_time(&alarm->time, &secs);
203 216
@@ -208,28 +221,28 @@ static int pm8xxx_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
208 221
209 spin_lock_irqsave(&rtc_dd->ctrl_reg_lock, irq_flags); 222 spin_lock_irqsave(&rtc_dd->ctrl_reg_lock, irq_flags);
210 223
211 rc = regmap_bulk_write(rtc_dd->regmap, rtc_dd->alarm_rw_base, value, 224 rc = regmap_bulk_write(rtc_dd->regmap, regs->alarm_rw, value,
212 sizeof(value)); 225 sizeof(value));
213 if (rc) { 226 if (rc) {
214 dev_err(dev, "Write to RTC ALARM register failed\n"); 227 dev_err(dev, "Write to RTC ALARM register failed\n");
215 goto rtc_rw_fail; 228 goto rtc_rw_fail;
216 } 229 }
217 230
218 ctrl_reg = rtc_dd->ctrl_reg; 231 rc = regmap_read(rtc_dd->regmap, regs->alarm_ctrl, &ctrl_reg);
232 if (rc)
233 goto rtc_rw_fail;
219 234
220 if (alarm->enabled) 235 if (alarm->enabled)
221 ctrl_reg |= PM8xxx_RTC_ALARM_ENABLE; 236 ctrl_reg |= regs->alarm_en;
222 else 237 else
223 ctrl_reg &= ~PM8xxx_RTC_ALARM_ENABLE; 238 ctrl_reg &= ~regs->alarm_en;
224 239
225 rc = regmap_write(rtc_dd->regmap, rtc_dd->rtc_base, ctrl_reg); 240 rc = regmap_write(rtc_dd->regmap, regs->alarm_ctrl, ctrl_reg);
226 if (rc) { 241 if (rc) {
227 dev_err(dev, "Write to RTC control register failed\n"); 242 dev_err(dev, "Write to RTC alarm control register failed\n");
228 goto rtc_rw_fail; 243 goto rtc_rw_fail;
229 } 244 }
230 245
231 rtc_dd->ctrl_reg = ctrl_reg;
232
233 dev_dbg(dev, "Alarm Set for h:r:s=%d:%d:%d, d/m/y=%d/%d/%d\n", 246 dev_dbg(dev, "Alarm Set for h:r:s=%d:%d:%d, d/m/y=%d/%d/%d\n",
234 alarm->time.tm_hour, alarm->time.tm_min, 247 alarm->time.tm_hour, alarm->time.tm_min,
235 alarm->time.tm_sec, alarm->time.tm_mday, 248 alarm->time.tm_sec, alarm->time.tm_mday,
@@ -245,8 +258,9 @@ static int pm8xxx_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm)
245 u8 value[NUM_8_BIT_RTC_REGS]; 258 u8 value[NUM_8_BIT_RTC_REGS];
246 unsigned long secs; 259 unsigned long secs;
247 struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev); 260 struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev);
261 const struct pm8xxx_rtc_regs *regs = rtc_dd->regs;
248 262
249 rc = regmap_bulk_read(rtc_dd->regmap, rtc_dd->alarm_rw_base, value, 263 rc = regmap_bulk_read(rtc_dd->regmap, regs->alarm_rw, value,
250 sizeof(value)); 264 sizeof(value));
251 if (rc) { 265 if (rc) {
252 dev_err(dev, "RTC alarm time read failed\n"); 266 dev_err(dev, "RTC alarm time read failed\n");
@@ -276,25 +290,26 @@ static int pm8xxx_rtc_alarm_irq_enable(struct device *dev, unsigned int enable)
276 int rc; 290 int rc;
277 unsigned long irq_flags; 291 unsigned long irq_flags;
278 struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev); 292 struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev);
279 u8 ctrl_reg; 293 const struct pm8xxx_rtc_regs *regs = rtc_dd->regs;
294 unsigned int ctrl_reg;
280 295
281 spin_lock_irqsave(&rtc_dd->ctrl_reg_lock, irq_flags); 296 spin_lock_irqsave(&rtc_dd->ctrl_reg_lock, irq_flags);
282 297
283 ctrl_reg = rtc_dd->ctrl_reg; 298 rc = regmap_read(rtc_dd->regmap, regs->alarm_ctrl, &ctrl_reg);
299 if (rc)
300 goto rtc_rw_fail;
284 301
285 if (enable) 302 if (enable)
286 ctrl_reg |= PM8xxx_RTC_ALARM_ENABLE; 303 ctrl_reg |= regs->alarm_en;
287 else 304 else
288 ctrl_reg &= ~PM8xxx_RTC_ALARM_ENABLE; 305 ctrl_reg &= ~regs->alarm_en;
289 306
290 rc = regmap_write(rtc_dd->regmap, rtc_dd->rtc_base, ctrl_reg); 307 rc = regmap_write(rtc_dd->regmap, regs->alarm_ctrl, ctrl_reg);
291 if (rc) { 308 if (rc) {
292 dev_err(dev, "Write to RTC control register failed\n"); 309 dev_err(dev, "Write to RTC control register failed\n");
293 goto rtc_rw_fail; 310 goto rtc_rw_fail;
294 } 311 }
295 312
296 rtc_dd->ctrl_reg = ctrl_reg;
297
298rtc_rw_fail: 313rtc_rw_fail:
299 spin_unlock_irqrestore(&rtc_dd->ctrl_reg_lock, irq_flags); 314 spin_unlock_irqrestore(&rtc_dd->ctrl_reg_lock, irq_flags);
300 return rc; 315 return rc;
@@ -311,6 +326,7 @@ static const struct rtc_class_ops pm8xxx_rtc_ops = {
311static irqreturn_t pm8xxx_alarm_trigger(int irq, void *dev_id) 326static irqreturn_t pm8xxx_alarm_trigger(int irq, void *dev_id)
312{ 327{
313 struct pm8xxx_rtc *rtc_dd = dev_id; 328 struct pm8xxx_rtc *rtc_dd = dev_id;
329 const struct pm8xxx_rtc_regs *regs = rtc_dd->regs;
314 unsigned int ctrl_reg; 330 unsigned int ctrl_reg;
315 int rc; 331 int rc;
316 unsigned long irq_flags; 332 unsigned long irq_flags;
@@ -320,48 +336,100 @@ static irqreturn_t pm8xxx_alarm_trigger(int irq, void *dev_id)
320 spin_lock_irqsave(&rtc_dd->ctrl_reg_lock, irq_flags); 336 spin_lock_irqsave(&rtc_dd->ctrl_reg_lock, irq_flags);
321 337
322 /* Clear the alarm enable bit */ 338 /* Clear the alarm enable bit */
323 ctrl_reg = rtc_dd->ctrl_reg; 339 rc = regmap_read(rtc_dd->regmap, regs->alarm_ctrl, &ctrl_reg);
324 ctrl_reg &= ~PM8xxx_RTC_ALARM_ENABLE; 340 if (rc) {
341 spin_unlock_irqrestore(&rtc_dd->ctrl_reg_lock, irq_flags);
342 goto rtc_alarm_handled;
343 }
344
345 ctrl_reg &= ~regs->alarm_en;
325 346
326 rc = regmap_write(rtc_dd->regmap, rtc_dd->rtc_base, ctrl_reg); 347 rc = regmap_write(rtc_dd->regmap, regs->alarm_ctrl, ctrl_reg);
327 if (rc) { 348 if (rc) {
328 spin_unlock_irqrestore(&rtc_dd->ctrl_reg_lock, irq_flags); 349 spin_unlock_irqrestore(&rtc_dd->ctrl_reg_lock, irq_flags);
329 dev_err(rtc_dd->rtc_dev, 350 dev_err(rtc_dd->rtc_dev,
330 "Write to RTC control register failed\n"); 351 "Write to alarm control register failed\n");
331 goto rtc_alarm_handled; 352 goto rtc_alarm_handled;
332 } 353 }
333 354
334 rtc_dd->ctrl_reg = ctrl_reg;
335 spin_unlock_irqrestore(&rtc_dd->ctrl_reg_lock, irq_flags); 355 spin_unlock_irqrestore(&rtc_dd->ctrl_reg_lock, irq_flags);
336 356
337 /* Clear RTC alarm register */ 357 /* Clear RTC alarm register */
338 rc = regmap_read(rtc_dd->regmap, 358 rc = regmap_read(rtc_dd->regmap, regs->alarm_ctrl2, &ctrl_reg);
339 rtc_dd->rtc_base + PM8XXX_ALARM_CTRL_OFFSET,
340 &ctrl_reg);
341 if (rc) { 359 if (rc) {
342 dev_err(rtc_dd->rtc_dev, 360 dev_err(rtc_dd->rtc_dev,
343 "RTC Alarm control register read failed\n"); 361 "RTC Alarm control2 register read failed\n");
344 goto rtc_alarm_handled; 362 goto rtc_alarm_handled;
345 } 363 }
346 364
347 ctrl_reg &= ~PM8xxx_RTC_ALARM_CLEAR; 365 ctrl_reg |= PM8xxx_RTC_ALARM_CLEAR;
348 rc = regmap_write(rtc_dd->regmap, 366 rc = regmap_write(rtc_dd->regmap, regs->alarm_ctrl2, ctrl_reg);
349 rtc_dd->rtc_base + PM8XXX_ALARM_CTRL_OFFSET,
350 ctrl_reg);
351 if (rc) 367 if (rc)
352 dev_err(rtc_dd->rtc_dev, 368 dev_err(rtc_dd->rtc_dev,
353 "Write to RTC Alarm control register failed\n"); 369 "Write to RTC Alarm control2 register failed\n");
354 370
355rtc_alarm_handled: 371rtc_alarm_handled:
356 return IRQ_HANDLED; 372 return IRQ_HANDLED;
357} 373}
358 374
375static int pm8xxx_rtc_enable(struct pm8xxx_rtc *rtc_dd)
376{
377 const struct pm8xxx_rtc_regs *regs = rtc_dd->regs;
378 unsigned int ctrl_reg;
379 int rc;
380
381 /* Check if the RTC is on, else turn it on */
382 rc = regmap_read(rtc_dd->regmap, regs->ctrl, &ctrl_reg);
383 if (rc)
384 return rc;
385
386 if (!(ctrl_reg & PM8xxx_RTC_ENABLE)) {
387 ctrl_reg |= PM8xxx_RTC_ENABLE;
388 rc = regmap_write(rtc_dd->regmap, regs->ctrl, ctrl_reg);
389 if (rc)
390 return rc;
391 }
392
393 return 0;
394}
395
396static const struct pm8xxx_rtc_regs pm8921_regs = {
397 .ctrl = 0x11d,
398 .write = 0x11f,
399 .read = 0x123,
400 .alarm_rw = 0x127,
401 .alarm_ctrl = 0x11d,
402 .alarm_ctrl2 = 0x11e,
403 .alarm_en = BIT(1),
404};
405
406static const struct pm8xxx_rtc_regs pm8058_regs = {
407 .ctrl = 0x1e8,
408 .write = 0x1ea,
409 .read = 0x1ee,
410 .alarm_rw = 0x1f2,
411 .alarm_ctrl = 0x1e8,
412 .alarm_ctrl2 = 0x1e9,
413 .alarm_en = BIT(1),
414};
415
416static const struct pm8xxx_rtc_regs pm8941_regs = {
417 .ctrl = 0x6046,
418 .write = 0x6040,
419 .read = 0x6048,
420 .alarm_rw = 0x6140,
421 .alarm_ctrl = 0x6146,
422 .alarm_ctrl2 = 0x6148,
423 .alarm_en = BIT(7),
424};
425
359/* 426/*
360 * Hardcoded RTC bases until IORESOURCE_REG mapping is figured out 427 * Hardcoded RTC bases until IORESOURCE_REG mapping is figured out
361 */ 428 */
362static const struct of_device_id pm8xxx_id_table[] = { 429static const struct of_device_id pm8xxx_id_table[] = {
363 { .compatible = "qcom,pm8921-rtc", .data = (void *) 0x11D }, 430 { .compatible = "qcom,pm8921-rtc", .data = &pm8921_regs },
364 { .compatible = "qcom,pm8058-rtc", .data = (void *) 0x1E8 }, 431 { .compatible = "qcom,pm8058-rtc", .data = &pm8058_regs },
432 { .compatible = "qcom,pm8941-rtc", .data = &pm8941_regs },
365 { }, 433 { },
366}; 434};
367MODULE_DEVICE_TABLE(of, pm8xxx_id_table); 435MODULE_DEVICE_TABLE(of, pm8xxx_id_table);
@@ -369,7 +437,6 @@ MODULE_DEVICE_TABLE(of, pm8xxx_id_table);
369static int pm8xxx_rtc_probe(struct platform_device *pdev) 437static int pm8xxx_rtc_probe(struct platform_device *pdev)
370{ 438{
371 int rc; 439 int rc;
372 unsigned int ctrl_reg;
373 struct pm8xxx_rtc *rtc_dd; 440 struct pm8xxx_rtc *rtc_dd;
374 const struct of_device_id *match; 441 const struct of_device_id *match;
375 442
@@ -399,33 +466,12 @@ static int pm8xxx_rtc_probe(struct platform_device *pdev)
399 rtc_dd->allow_set_time = of_property_read_bool(pdev->dev.of_node, 466 rtc_dd->allow_set_time = of_property_read_bool(pdev->dev.of_node,
400 "allow-set-time"); 467 "allow-set-time");
401 468
402 rtc_dd->rtc_base = (long) match->data; 469 rtc_dd->regs = match->data;
403
404 /* Setup RTC register addresses */
405 rtc_dd->rtc_write_base = rtc_dd->rtc_base + PM8XXX_RTC_WRITE_OFFSET;
406 rtc_dd->rtc_read_base = rtc_dd->rtc_base + PM8XXX_RTC_READ_OFFSET;
407 rtc_dd->alarm_rw_base = rtc_dd->rtc_base + PM8XXX_ALARM_RW_OFFSET;
408
409 rtc_dd->rtc_dev = &pdev->dev; 470 rtc_dd->rtc_dev = &pdev->dev;
410 471
411 /* Check if the RTC is on, else turn it on */ 472 rc = pm8xxx_rtc_enable(rtc_dd);
412 rc = regmap_read(rtc_dd->regmap, rtc_dd->rtc_base, &ctrl_reg); 473 if (rc)
413 if (rc) {
414 dev_err(&pdev->dev, "RTC control register read failed!\n");
415 return rc; 474 return rc;
416 }
417
418 if (!(ctrl_reg & PM8xxx_RTC_ENABLE)) {
419 ctrl_reg |= PM8xxx_RTC_ENABLE;
420 rc = regmap_write(rtc_dd->regmap, rtc_dd->rtc_base, ctrl_reg);
421 if (rc) {
422 dev_err(&pdev->dev,
423 "Write to RTC control register failed\n");
424 return rc;
425 }
426 }
427
428 rtc_dd->ctrl_reg = ctrl_reg;
429 475
430 platform_set_drvdata(pdev, rtc_dd); 476 platform_set_drvdata(pdev, rtc_dd);
431 477
diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c
index a6b1252c9941..806072238c00 100644
--- a/drivers/rtc/rtc-s3c.c
+++ b/drivers/rtc/rtc-s3c.c
@@ -535,13 +535,15 @@ static int s3c_rtc_probe(struct platform_device *pdev)
535 } 535 }
536 clk_prepare_enable(info->rtc_clk); 536 clk_prepare_enable(info->rtc_clk);
537 537
538 info->rtc_src_clk = devm_clk_get(&pdev->dev, "rtc_src"); 538 if (info->data->needs_src_clk) {
539 if (IS_ERR(info->rtc_src_clk)) { 539 info->rtc_src_clk = devm_clk_get(&pdev->dev, "rtc_src");
540 dev_err(&pdev->dev, "failed to find rtc source clock\n"); 540 if (IS_ERR(info->rtc_src_clk)) {
541 return PTR_ERR(info->rtc_src_clk); 541 dev_err(&pdev->dev,
542 "failed to find rtc source clock\n");
543 return PTR_ERR(info->rtc_src_clk);
544 }
545 clk_prepare_enable(info->rtc_src_clk);
542 } 546 }
543 clk_prepare_enable(info->rtc_src_clk);
544
545 547
546 /* check to see if everything is setup correctly */ 548 /* check to see if everything is setup correctly */
547 if (info->data->enable) 549 if (info->data->enable)
diff --git a/drivers/scsi/cxgbi/libcxgbi.c b/drivers/scsi/cxgbi/libcxgbi.c
index 54fa6e0bc1bb..674d498b46ab 100644
--- a/drivers/scsi/cxgbi/libcxgbi.c
+++ b/drivers/scsi/cxgbi/libcxgbi.c
@@ -399,6 +399,35 @@ EXPORT_SYMBOL_GPL(cxgbi_hbas_add);
399 * If the source port is outside our allocation range, the caller is 399 * If the source port is outside our allocation range, the caller is
400 * responsible for keeping track of their port usage. 400 * responsible for keeping track of their port usage.
401 */ 401 */
402
403static struct cxgbi_sock *find_sock_on_port(struct cxgbi_device *cdev,
404 unsigned char port_id)
405{
406 struct cxgbi_ports_map *pmap = &cdev->pmap;
407 unsigned int i;
408 unsigned int used;
409
410 if (!pmap->max_connect || !pmap->used)
411 return NULL;
412
413 spin_lock_bh(&pmap->lock);
414 used = pmap->used;
415 for (i = 0; used && i < pmap->max_connect; i++) {
416 struct cxgbi_sock *csk = pmap->port_csk[i];
417
418 if (csk) {
419 if (csk->port_id == port_id) {
420 spin_unlock_bh(&pmap->lock);
421 return csk;
422 }
423 used--;
424 }
425 }
426 spin_unlock_bh(&pmap->lock);
427
428 return NULL;
429}
430
402static int sock_get_port(struct cxgbi_sock *csk) 431static int sock_get_port(struct cxgbi_sock *csk)
403{ 432{
404 struct cxgbi_device *cdev = csk->cdev; 433 struct cxgbi_device *cdev = csk->cdev;
@@ -749,6 +778,7 @@ static struct cxgbi_sock *cxgbi_check_route6(struct sockaddr *dst_addr)
749 csk->daddr6.sin6_addr = daddr6->sin6_addr; 778 csk->daddr6.sin6_addr = daddr6->sin6_addr;
750 csk->daddr6.sin6_port = daddr6->sin6_port; 779 csk->daddr6.sin6_port = daddr6->sin6_port;
751 csk->daddr6.sin6_family = daddr6->sin6_family; 780 csk->daddr6.sin6_family = daddr6->sin6_family;
781 csk->saddr6.sin6_family = daddr6->sin6_family;
752 csk->saddr6.sin6_addr = pref_saddr; 782 csk->saddr6.sin6_addr = pref_saddr;
753 783
754 neigh_release(n); 784 neigh_release(n);
@@ -2647,12 +2677,14 @@ int cxgbi_get_host_param(struct Scsi_Host *shost, enum iscsi_host_param param,
2647 break; 2677 break;
2648 case ISCSI_HOST_PARAM_IPADDRESS: 2678 case ISCSI_HOST_PARAM_IPADDRESS:
2649 { 2679 {
2650 __be32 addr; 2680 struct cxgbi_sock *csk = find_sock_on_port(chba->cdev,
2651 2681 chba->port_id);
2652 addr = cxgbi_get_iscsi_ipv4(chba); 2682 if (csk) {
2653 len = sprintf(buf, "%pI4", &addr); 2683 len = sprintf(buf, "%pIS",
2684 (struct sockaddr *)&csk->saddr);
2685 }
2654 log_debug(1 << CXGBI_DBG_ISCSI, 2686 log_debug(1 << CXGBI_DBG_ISCSI,
2655 "hba %s, ipv4 %pI4.\n", chba->ndev->name, &addr); 2687 "hba %s, addr %s.\n", chba->ndev->name, buf);
2656 break; 2688 break;
2657 } 2689 }
2658 default: 2690 default:
diff --git a/drivers/scsi/cxgbi/libcxgbi.h b/drivers/scsi/cxgbi/libcxgbi.h
index 1d98fad6a0ab..2c7cb1c0c453 100644
--- a/drivers/scsi/cxgbi/libcxgbi.h
+++ b/drivers/scsi/cxgbi/libcxgbi.h
@@ -700,11 +700,6 @@ static inline void cxgbi_set_iscsi_ipv4(struct cxgbi_hba *chba, __be32 ipaddr)
700 chba->ndev->name); 700 chba->ndev->name);
701} 701}
702 702
703static inline __be32 cxgbi_get_iscsi_ipv4(struct cxgbi_hba *chba)
704{
705 return chba->ipv4addr;
706}
707
708struct cxgbi_device *cxgbi_device_register(unsigned int, unsigned int); 703struct cxgbi_device *cxgbi_device_register(unsigned int, unsigned int);
709void cxgbi_device_unregister(struct cxgbi_device *); 704void cxgbi_device_unregister(struct cxgbi_device *);
710void cxgbi_device_unregister_all(unsigned int flag); 705void cxgbi_device_unregister_all(unsigned int flag);
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 9eff8a375132..50a6e1ac8d9c 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1893,6 +1893,11 @@ static int scsi_queue_rq(struct blk_mq_hw_ctx *hctx, struct request *req,
1893 blk_mq_start_request(req); 1893 blk_mq_start_request(req);
1894 } 1894 }
1895 1895
1896 if (blk_queue_tagged(q))
1897 req->cmd_flags |= REQ_QUEUED;
1898 else
1899 req->cmd_flags &= ~REQ_QUEUED;
1900
1896 scsi_init_cmd_errh(cmd); 1901 scsi_init_cmd_errh(cmd);
1897 cmd->scsi_done = scsi_mq_done; 1902 cmd->scsi_done = scsi_mq_done;
1898 1903
diff --git a/drivers/soc/versatile/soc-realview.c b/drivers/soc/versatile/soc-realview.c
index cea8ea3491d2..1a07bf540fec 100644
--- a/drivers/soc/versatile/soc-realview.c
+++ b/drivers/soc/versatile/soc-realview.c
@@ -26,6 +26,7 @@ static const struct of_device_id realview_soc_of_match[] = {
26 { .compatible = "arm,realview-pb11mp-soc", }, 26 { .compatible = "arm,realview-pb11mp-soc", },
27 { .compatible = "arm,realview-pba8-soc", }, 27 { .compatible = "arm,realview-pba8-soc", },
28 { .compatible = "arm,realview-pbx-soc", }, 28 { .compatible = "arm,realview-pbx-soc", },
29 { }
29}; 30};
30 31
31static u32 realview_coreid; 32static u32 realview_coreid;
diff --git a/drivers/spi/spi-dw.c b/drivers/spi/spi-dw.c
index 729215885250..72e12bad14b9 100644
--- a/drivers/spi/spi-dw.c
+++ b/drivers/spi/spi-dw.c
@@ -669,6 +669,7 @@ int dw_spi_add_host(struct device *dev, struct dw_spi *dws)
669 master->cleanup = dw_spi_cleanup; 669 master->cleanup = dw_spi_cleanup;
670 master->transfer_one_message = dw_spi_transfer_one_message; 670 master->transfer_one_message = dw_spi_transfer_one_message;
671 master->max_speed_hz = dws->max_freq; 671 master->max_speed_hz = dws->max_freq;
672 master->dev.of_node = dev->of_node;
672 673
673 /* Basic HW init */ 674 /* Basic HW init */
674 spi_hw_init(dws); 675 spi_hw_init(dws);
diff --git a/drivers/spi/spi-orion.c b/drivers/spi/spi-orion.c
index 835cdda6f4f5..c76b7d7879df 100644
--- a/drivers/spi/spi-orion.c
+++ b/drivers/spi/spi-orion.c
@@ -454,7 +454,7 @@ static int orion_spi_probe(struct platform_device *pdev)
454 spi->master = master; 454 spi->master = master;
455 455
456 of_id = of_match_device(orion_spi_of_match_table, &pdev->dev); 456 of_id = of_match_device(orion_spi_of_match_table, &pdev->dev);
457 devdata = of_id->data; 457 devdata = (of_id) ? of_id->data : &orion_spi_dev_data;
458 spi->devdata = devdata; 458 spi->devdata = devdata;
459 459
460 spi->clk = devm_clk_get(&pdev->dev, NULL); 460 spi->clk = devm_clk_get(&pdev->dev, NULL);
diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c
index f35f723816ea..fc2dd8441608 100644
--- a/drivers/spi/spi-pl022.c
+++ b/drivers/spi/spi-pl022.c
@@ -1106,7 +1106,7 @@ err_rxdesc:
1106 pl022->sgt_tx.nents, DMA_TO_DEVICE); 1106 pl022->sgt_tx.nents, DMA_TO_DEVICE);
1107err_tx_sgmap: 1107err_tx_sgmap:
1108 dma_unmap_sg(rxchan->device->dev, pl022->sgt_rx.sgl, 1108 dma_unmap_sg(rxchan->device->dev, pl022->sgt_rx.sgl,
1109 pl022->sgt_tx.nents, DMA_FROM_DEVICE); 1109 pl022->sgt_rx.nents, DMA_FROM_DEVICE);
1110err_rx_sgmap: 1110err_rx_sgmap:
1111 sg_free_table(&pl022->sgt_tx); 1111 sg_free_table(&pl022->sgt_tx);
1112err_alloc_tx_sg: 1112err_alloc_tx_sg:
diff --git a/drivers/spi/spi-rockchip.c b/drivers/spi/spi-rockchip.c
index f96ea8a38d64..87bc16f491f0 100644
--- a/drivers/spi/spi-rockchip.c
+++ b/drivers/spi/spi-rockchip.c
@@ -145,6 +145,9 @@
145#define RXBUSY (1 << 0) 145#define RXBUSY (1 << 0)
146#define TXBUSY (1 << 1) 146#define TXBUSY (1 << 1)
147 147
148/* sclk_out: spi master internal logic in rk3x can support 50Mhz */
149#define MAX_SCLK_OUT 50000000
150
148enum rockchip_ssi_type { 151enum rockchip_ssi_type {
149 SSI_MOTO_SPI = 0, 152 SSI_MOTO_SPI = 0,
150 SSI_TI_SSP, 153 SSI_TI_SSP,
@@ -325,6 +328,8 @@ static int rockchip_spi_unprepare_message(struct spi_master *master,
325 328
326 spin_unlock_irqrestore(&rs->lock, flags); 329 spin_unlock_irqrestore(&rs->lock, flags);
327 330
331 spi_enable_chip(rs, 0);
332
328 return 0; 333 return 0;
329} 334}
330 335
@@ -381,6 +386,8 @@ static int rockchip_spi_pio_transfer(struct rockchip_spi *rs)
381 if (rs->tx) 386 if (rs->tx)
382 wait_for_idle(rs); 387 wait_for_idle(rs);
383 388
389 spi_enable_chip(rs, 0);
390
384 return 0; 391 return 0;
385} 392}
386 393
@@ -392,8 +399,10 @@ static void rockchip_spi_dma_rxcb(void *data)
392 spin_lock_irqsave(&rs->lock, flags); 399 spin_lock_irqsave(&rs->lock, flags);
393 400
394 rs->state &= ~RXBUSY; 401 rs->state &= ~RXBUSY;
395 if (!(rs->state & TXBUSY)) 402 if (!(rs->state & TXBUSY)) {
403 spi_enable_chip(rs, 0);
396 spi_finalize_current_transfer(rs->master); 404 spi_finalize_current_transfer(rs->master);
405 }
397 406
398 spin_unlock_irqrestore(&rs->lock, flags); 407 spin_unlock_irqrestore(&rs->lock, flags);
399} 408}
@@ -409,8 +418,10 @@ static void rockchip_spi_dma_txcb(void *data)
409 spin_lock_irqsave(&rs->lock, flags); 418 spin_lock_irqsave(&rs->lock, flags);
410 419
411 rs->state &= ~TXBUSY; 420 rs->state &= ~TXBUSY;
412 if (!(rs->state & RXBUSY)) 421 if (!(rs->state & RXBUSY)) {
422 spi_enable_chip(rs, 0);
413 spi_finalize_current_transfer(rs->master); 423 spi_finalize_current_transfer(rs->master);
424 }
414 425
415 spin_unlock_irqrestore(&rs->lock, flags); 426 spin_unlock_irqrestore(&rs->lock, flags);
416} 427}
@@ -496,12 +507,19 @@ static void rockchip_spi_config(struct rockchip_spi *rs)
496 dmacr |= RF_DMA_EN; 507 dmacr |= RF_DMA_EN;
497 } 508 }
498 509
510 if (WARN_ON(rs->speed > MAX_SCLK_OUT))
511 rs->speed = MAX_SCLK_OUT;
512
513 /* the minimum divsor is 2 */
514 if (rs->max_freq < 2 * rs->speed) {
515 clk_set_rate(rs->spiclk, 2 * rs->speed);
516 rs->max_freq = clk_get_rate(rs->spiclk);
517 }
518
499 /* div doesn't support odd number */ 519 /* div doesn't support odd number */
500 div = max_t(u32, rs->max_freq / rs->speed, 1); 520 div = max_t(u32, rs->max_freq / rs->speed, 1);
501 div = (div + 1) & 0xfffe; 521 div = (div + 1) & 0xfffe;
502 522
503 spi_enable_chip(rs, 0);
504
505 writel_relaxed(cr0, rs->regs + ROCKCHIP_SPI_CTRLR0); 523 writel_relaxed(cr0, rs->regs + ROCKCHIP_SPI_CTRLR0);
506 524
507 writel_relaxed(rs->len - 1, rs->regs + ROCKCHIP_SPI_CTRLR1); 525 writel_relaxed(rs->len - 1, rs->regs + ROCKCHIP_SPI_CTRLR1);
@@ -515,8 +533,6 @@ static void rockchip_spi_config(struct rockchip_spi *rs)
515 spi_set_clk(rs, div); 533 spi_set_clk(rs, div);
516 534
517 dev_dbg(rs->dev, "cr0 0x%x, div %d\n", cr0, div); 535 dev_dbg(rs->dev, "cr0 0x%x, div %d\n", cr0, div);
518
519 spi_enable_chip(rs, 1);
520} 536}
521 537
522static int rockchip_spi_transfer_one( 538static int rockchip_spi_transfer_one(
@@ -524,7 +540,7 @@ static int rockchip_spi_transfer_one(
524 struct spi_device *spi, 540 struct spi_device *spi,
525 struct spi_transfer *xfer) 541 struct spi_transfer *xfer)
526{ 542{
527 int ret = 0; 543 int ret = 1;
528 struct rockchip_spi *rs = spi_master_get_devdata(master); 544 struct rockchip_spi *rs = spi_master_get_devdata(master);
529 545
530 WARN_ON(readl_relaxed(rs->regs + ROCKCHIP_SPI_SSIENR) && 546 WARN_ON(readl_relaxed(rs->regs + ROCKCHIP_SPI_SSIENR) &&
@@ -556,17 +572,27 @@ static int rockchip_spi_transfer_one(
556 rs->tmode = CR0_XFM_RO; 572 rs->tmode = CR0_XFM_RO;
557 573
558 /* we need prepare dma before spi was enabled */ 574 /* we need prepare dma before spi was enabled */
559 if (master->can_dma && master->can_dma(master, spi, xfer)) { 575 if (master->can_dma && master->can_dma(master, spi, xfer))
560 rs->use_dma = 1; 576 rs->use_dma = 1;
561 rockchip_spi_prepare_dma(rs); 577 else
562 } else {
563 rs->use_dma = 0; 578 rs->use_dma = 0;
564 }
565 579
566 rockchip_spi_config(rs); 580 rockchip_spi_config(rs);
567 581
568 if (!rs->use_dma) 582 if (rs->use_dma) {
583 if (rs->tmode == CR0_XFM_RO) {
584 /* rx: dma must be prepared first */
585 rockchip_spi_prepare_dma(rs);
586 spi_enable_chip(rs, 1);
587 } else {
588 /* tx or tr: spi must be enabled first */
589 spi_enable_chip(rs, 1);
590 rockchip_spi_prepare_dma(rs);
591 }
592 } else {
593 spi_enable_chip(rs, 1);
569 ret = rockchip_spi_pio_transfer(rs); 594 ret = rockchip_spi_pio_transfer(rs);
595 }
570 596
571 return ret; 597 return ret;
572} 598}
diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c
index e3bc23bb5883..e50039fb1474 100644
--- a/drivers/spi/spidev.c
+++ b/drivers/spi/spidev.c
@@ -82,10 +82,11 @@ struct spidev_data {
82 struct spi_device *spi; 82 struct spi_device *spi;
83 struct list_head device_entry; 83 struct list_head device_entry;
84 84
85 /* buffer is NULL unless this device is open (users > 0) */ 85 /* TX/RX buffers are NULL unless this device is open (users > 0) */
86 struct mutex buf_lock; 86 struct mutex buf_lock;
87 unsigned users; 87 unsigned users;
88 u8 *buffer; 88 u8 *tx_buffer;
89 u8 *rx_buffer;
89}; 90};
90 91
91static LIST_HEAD(device_list); 92static LIST_HEAD(device_list);
@@ -135,7 +136,7 @@ static inline ssize_t
135spidev_sync_write(struct spidev_data *spidev, size_t len) 136spidev_sync_write(struct spidev_data *spidev, size_t len)
136{ 137{
137 struct spi_transfer t = { 138 struct spi_transfer t = {
138 .tx_buf = spidev->buffer, 139 .tx_buf = spidev->tx_buffer,
139 .len = len, 140 .len = len,
140 }; 141 };
141 struct spi_message m; 142 struct spi_message m;
@@ -149,7 +150,7 @@ static inline ssize_t
149spidev_sync_read(struct spidev_data *spidev, size_t len) 150spidev_sync_read(struct spidev_data *spidev, size_t len)
150{ 151{
151 struct spi_transfer t = { 152 struct spi_transfer t = {
152 .rx_buf = spidev->buffer, 153 .rx_buf = spidev->rx_buffer,
153 .len = len, 154 .len = len,
154 }; 155 };
155 struct spi_message m; 156 struct spi_message m;
@@ -179,7 +180,7 @@ spidev_read(struct file *filp, char __user *buf, size_t count, loff_t *f_pos)
179 if (status > 0) { 180 if (status > 0) {
180 unsigned long missing; 181 unsigned long missing;
181 182
182 missing = copy_to_user(buf, spidev->buffer, status); 183 missing = copy_to_user(buf, spidev->rx_buffer, status);
183 if (missing == status) 184 if (missing == status)
184 status = -EFAULT; 185 status = -EFAULT;
185 else 186 else
@@ -206,7 +207,7 @@ spidev_write(struct file *filp, const char __user *buf,
206 spidev = filp->private_data; 207 spidev = filp->private_data;
207 208
208 mutex_lock(&spidev->buf_lock); 209 mutex_lock(&spidev->buf_lock);
209 missing = copy_from_user(spidev->buffer, buf, count); 210 missing = copy_from_user(spidev->tx_buffer, buf, count);
210 if (missing == 0) 211 if (missing == 0)
211 status = spidev_sync_write(spidev, count); 212 status = spidev_sync_write(spidev, count);
212 else 213 else
@@ -224,7 +225,7 @@ static int spidev_message(struct spidev_data *spidev,
224 struct spi_transfer *k_tmp; 225 struct spi_transfer *k_tmp;
225 struct spi_ioc_transfer *u_tmp; 226 struct spi_ioc_transfer *u_tmp;
226 unsigned n, total; 227 unsigned n, total;
227 u8 *buf; 228 u8 *tx_buf, *rx_buf;
228 int status = -EFAULT; 229 int status = -EFAULT;
229 230
230 spi_message_init(&msg); 231 spi_message_init(&msg);
@@ -236,7 +237,8 @@ static int spidev_message(struct spidev_data *spidev,
236 * We walk the array of user-provided transfers, using each one 237 * We walk the array of user-provided transfers, using each one
237 * to initialize a kernel version of the same transfer. 238 * to initialize a kernel version of the same transfer.
238 */ 239 */
239 buf = spidev->buffer; 240 tx_buf = spidev->tx_buffer;
241 rx_buf = spidev->rx_buffer;
240 total = 0; 242 total = 0;
241 for (n = n_xfers, k_tmp = k_xfers, u_tmp = u_xfers; 243 for (n = n_xfers, k_tmp = k_xfers, u_tmp = u_xfers;
242 n; 244 n;
@@ -250,20 +252,21 @@ static int spidev_message(struct spidev_data *spidev,
250 } 252 }
251 253
252 if (u_tmp->rx_buf) { 254 if (u_tmp->rx_buf) {
253 k_tmp->rx_buf = buf; 255 k_tmp->rx_buf = rx_buf;
254 if (!access_ok(VERIFY_WRITE, (u8 __user *) 256 if (!access_ok(VERIFY_WRITE, (u8 __user *)
255 (uintptr_t) u_tmp->rx_buf, 257 (uintptr_t) u_tmp->rx_buf,
256 u_tmp->len)) 258 u_tmp->len))
257 goto done; 259 goto done;
258 } 260 }
259 if (u_tmp->tx_buf) { 261 if (u_tmp->tx_buf) {
260 k_tmp->tx_buf = buf; 262 k_tmp->tx_buf = tx_buf;
261 if (copy_from_user(buf, (const u8 __user *) 263 if (copy_from_user(tx_buf, (const u8 __user *)
262 (uintptr_t) u_tmp->tx_buf, 264 (uintptr_t) u_tmp->tx_buf,
263 u_tmp->len)) 265 u_tmp->len))
264 goto done; 266 goto done;
265 } 267 }
266 buf += k_tmp->len; 268 tx_buf += k_tmp->len;
269 rx_buf += k_tmp->len;
267 270
268 k_tmp->cs_change = !!u_tmp->cs_change; 271 k_tmp->cs_change = !!u_tmp->cs_change;
269 k_tmp->tx_nbits = u_tmp->tx_nbits; 272 k_tmp->tx_nbits = u_tmp->tx_nbits;
@@ -290,17 +293,17 @@ static int spidev_message(struct spidev_data *spidev,
290 goto done; 293 goto done;
291 294
292 /* copy any rx data out of bounce buffer */ 295 /* copy any rx data out of bounce buffer */
293 buf = spidev->buffer; 296 rx_buf = spidev->rx_buffer;
294 for (n = n_xfers, u_tmp = u_xfers; n; n--, u_tmp++) { 297 for (n = n_xfers, u_tmp = u_xfers; n; n--, u_tmp++) {
295 if (u_tmp->rx_buf) { 298 if (u_tmp->rx_buf) {
296 if (__copy_to_user((u8 __user *) 299 if (__copy_to_user((u8 __user *)
297 (uintptr_t) u_tmp->rx_buf, buf, 300 (uintptr_t) u_tmp->rx_buf, rx_buf,
298 u_tmp->len)) { 301 u_tmp->len)) {
299 status = -EFAULT; 302 status = -EFAULT;
300 goto done; 303 goto done;
301 } 304 }
302 } 305 }
303 buf += u_tmp->len; 306 rx_buf += u_tmp->len;
304 } 307 }
305 status = total; 308 status = total;
306 309
@@ -508,22 +511,41 @@ static int spidev_open(struct inode *inode, struct file *filp)
508 break; 511 break;
509 } 512 }
510 } 513 }
511 if (status == 0) { 514
512 if (!spidev->buffer) { 515 if (status) {
513 spidev->buffer = kmalloc(bufsiz, GFP_KERNEL); 516 pr_debug("spidev: nothing for minor %d\n", iminor(inode));
514 if (!spidev->buffer) { 517 goto err_find_dev;
518 }
519
520 if (!spidev->tx_buffer) {
521 spidev->tx_buffer = kmalloc(bufsiz, GFP_KERNEL);
522 if (!spidev->tx_buffer) {
515 dev_dbg(&spidev->spi->dev, "open/ENOMEM\n"); 523 dev_dbg(&spidev->spi->dev, "open/ENOMEM\n");
516 status = -ENOMEM; 524 status = -ENOMEM;
525 goto err_find_dev;
517 } 526 }
518 } 527 }
519 if (status == 0) { 528
520 spidev->users++; 529 if (!spidev->rx_buffer) {
521 filp->private_data = spidev; 530 spidev->rx_buffer = kmalloc(bufsiz, GFP_KERNEL);
522 nonseekable_open(inode, filp); 531 if (!spidev->rx_buffer) {
532 dev_dbg(&spidev->spi->dev, "open/ENOMEM\n");
533 status = -ENOMEM;
534 goto err_alloc_rx_buf;
523 } 535 }
524 } else 536 }
525 pr_debug("spidev: nothing for minor %d\n", iminor(inode)); 537
538 spidev->users++;
539 filp->private_data = spidev;
540 nonseekable_open(inode, filp);
541
542 mutex_unlock(&device_list_lock);
543 return 0;
526 544
545err_alloc_rx_buf:
546 kfree(spidev->tx_buffer);
547 spidev->tx_buffer = NULL;
548err_find_dev:
527 mutex_unlock(&device_list_lock); 549 mutex_unlock(&device_list_lock);
528 return status; 550 return status;
529} 551}
@@ -542,8 +564,11 @@ static int spidev_release(struct inode *inode, struct file *filp)
542 if (!spidev->users) { 564 if (!spidev->users) {
543 int dofree; 565 int dofree;
544 566
545 kfree(spidev->buffer); 567 kfree(spidev->tx_buffer);
546 spidev->buffer = NULL; 568 spidev->tx_buffer = NULL;
569
570 kfree(spidev->rx_buffer);
571 spidev->rx_buffer = NULL;
547 572
548 /* ... after we unbound from the underlying device? */ 573 /* ... after we unbound from the underlying device? */
549 spin_lock_irq(&spidev->spi_lock); 574 spin_lock_irq(&spidev->spi_lock);
diff --git a/drivers/staging/android/logger.c b/drivers/staging/android/logger.c
index 28b93d39a94e..a673ffa34aa3 100644
--- a/drivers/staging/android/logger.c
+++ b/drivers/staging/android/logger.c
@@ -420,7 +420,7 @@ static ssize_t logger_write_iter(struct kiocb *iocb, struct iov_iter *from)
420 struct logger_log *log = file_get_log(iocb->ki_filp); 420 struct logger_log *log = file_get_log(iocb->ki_filp);
421 struct logger_entry header; 421 struct logger_entry header;
422 struct timespec now; 422 struct timespec now;
423 size_t len, count; 423 size_t len, count, w_off;
424 424
425 count = min_t(size_t, iocb->ki_nbytes, LOGGER_ENTRY_MAX_PAYLOAD); 425 count = min_t(size_t, iocb->ki_nbytes, LOGGER_ENTRY_MAX_PAYLOAD);
426 426
@@ -452,11 +452,14 @@ static ssize_t logger_write_iter(struct kiocb *iocb, struct iov_iter *from)
452 memcpy(log->buffer + log->w_off, &header, len); 452 memcpy(log->buffer + log->w_off, &header, len);
453 memcpy(log->buffer, (char *)&header + len, sizeof(header) - len); 453 memcpy(log->buffer, (char *)&header + len, sizeof(header) - len);
454 454
455 len = min(count, log->size - log->w_off); 455 /* Work with a copy until we are ready to commit the whole entry */
456 w_off = logger_offset(log, log->w_off + sizeof(struct logger_entry));
456 457
457 if (copy_from_iter(log->buffer + log->w_off, len, from) != len) { 458 len = min(count, log->size - w_off);
459
460 if (copy_from_iter(log->buffer + w_off, len, from) != len) {
458 /* 461 /*
459 * Note that by not updating w_off, this abandons the 462 * Note that by not updating log->w_off, this abandons the
460 * portion of the new entry that *was* successfully 463 * portion of the new entry that *was* successfully
461 * copied, just above. This is intentional to avoid 464 * copied, just above. This is intentional to avoid
462 * message corruption from missing fragments. 465 * message corruption from missing fragments.
@@ -470,7 +473,7 @@ static ssize_t logger_write_iter(struct kiocb *iocb, struct iov_iter *from)
470 return -EFAULT; 473 return -EFAULT;
471 } 474 }
472 475
473 log->w_off = logger_offset(log, log->w_off + count); 476 log->w_off = logger_offset(log, w_off + count);
474 mutex_unlock(&log->mutex); 477 mutex_unlock(&log->mutex);
475 478
476 /* wake up any blocked readers */ 479 /* wake up any blocked readers */
diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig
index a8bc2b567789..152f4c12ea43 100644
--- a/drivers/staging/comedi/Kconfig
+++ b/drivers/staging/comedi/Kconfig
@@ -426,6 +426,7 @@ config COMEDI_AIO_IIRO_16
426 426
427config COMEDI_II_PCI20KC 427config COMEDI_II_PCI20KC
428 tristate "Intelligent Instruments PCI-20001C carrier support" 428 tristate "Intelligent Instruments PCI-20001C carrier support"
429 depends on HAS_IOMEM
429 ---help--- 430 ---help---
430 Enable support for Intelligent Instruments PCI-20001C carrier 431 Enable support for Intelligent Instruments PCI-20001C carrier
431 PCI-20001, PCI-20006 and PCI-20341 432 PCI-20001, PCI-20006 and PCI-20341
@@ -667,7 +668,6 @@ config COMEDI_ADDI_APCI_2200
667config COMEDI_ADDI_APCI_3120 668config COMEDI_ADDI_APCI_3120
668 tristate "ADDI-DATA APCI_3120/3001 support" 669 tristate "ADDI-DATA APCI_3120/3001 support"
669 depends on HAS_DMA 670 depends on HAS_DMA
670 depends on VIRT_TO_BUS
671 ---help--- 671 ---help---
672 Enable support for ADDI-DATA APCI_3120/3001 cards 672 Enable support for ADDI-DATA APCI_3120/3001 cards
673 673
diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c
index 495969f46e76..9c32f0276009 100644
--- a/drivers/staging/comedi/comedi_fops.c
+++ b/drivers/staging/comedi/comedi_fops.c
@@ -1462,10 +1462,7 @@ static int __comedi_get_user_chanlist(struct comedi_device *dev,
1462 unsigned int *chanlist; 1462 unsigned int *chanlist;
1463 int ret; 1463 int ret;
1464 1464
1465 /* user_chanlist could be NULL for do_cmdtest ioctls */ 1465 cmd->chanlist = NULL;
1466 if (!user_chanlist)
1467 return 0;
1468
1469 chanlist = memdup_user(user_chanlist, 1466 chanlist = memdup_user(user_chanlist,
1470 cmd->chanlist_len * sizeof(unsigned int)); 1467 cmd->chanlist_len * sizeof(unsigned int));
1471 if (IS_ERR(chanlist)) 1468 if (IS_ERR(chanlist))
@@ -1609,13 +1606,18 @@ static int do_cmdtest_ioctl(struct comedi_device *dev,
1609 1606
1610 s = &dev->subdevices[cmd.subdev]; 1607 s = &dev->subdevices[cmd.subdev];
1611 1608
1612 /* load channel/gain list */ 1609 /* user_chanlist can be NULL for COMEDI_CMDTEST ioctl */
1613 ret = __comedi_get_user_chanlist(dev, s, user_chanlist, &cmd); 1610 if (user_chanlist) {
1614 if (ret) 1611 /* load channel/gain list */
1615 return ret; 1612 ret = __comedi_get_user_chanlist(dev, s, user_chanlist, &cmd);
1613 if (ret)
1614 return ret;
1615 }
1616 1616
1617 ret = s->do_cmdtest(dev, s, &cmd); 1617 ret = s->do_cmdtest(dev, s, &cmd);
1618 1618
1619 kfree(cmd.chanlist); /* free kernel copy of user chanlist */
1620
1619 /* restore chanlist pointer before copying back */ 1621 /* restore chanlist pointer before copying back */
1620 cmd.chanlist = (unsigned int __force *)user_chanlist; 1622 cmd.chanlist = (unsigned int __force *)user_chanlist;
1621 1623
@@ -1642,7 +1644,7 @@ static int do_cmdtest_ioctl(struct comedi_device *dev,
1642 1644
1643*/ 1645*/
1644 1646
1645static int do_lock_ioctl(struct comedi_device *dev, unsigned int arg, 1647static int do_lock_ioctl(struct comedi_device *dev, unsigned long arg,
1646 void *file) 1648 void *file)
1647{ 1649{
1648 int ret = 0; 1650 int ret = 0;
@@ -1679,7 +1681,7 @@ static int do_lock_ioctl(struct comedi_device *dev, unsigned int arg,
1679 This function isn't protected by the semaphore, since 1681 This function isn't protected by the semaphore, since
1680 we already own the lock. 1682 we already own the lock.
1681*/ 1683*/
1682static int do_unlock_ioctl(struct comedi_device *dev, unsigned int arg, 1684static int do_unlock_ioctl(struct comedi_device *dev, unsigned long arg,
1683 void *file) 1685 void *file)
1684{ 1686{
1685 struct comedi_subdevice *s; 1687 struct comedi_subdevice *s;
@@ -1714,7 +1716,7 @@ static int do_unlock_ioctl(struct comedi_device *dev, unsigned int arg,
1714 nothing 1716 nothing
1715 1717
1716*/ 1718*/
1717static int do_cancel_ioctl(struct comedi_device *dev, unsigned int arg, 1719static int do_cancel_ioctl(struct comedi_device *dev, unsigned long arg,
1718 void *file) 1720 void *file)
1719{ 1721{
1720 struct comedi_subdevice *s; 1722 struct comedi_subdevice *s;
@@ -1751,7 +1753,7 @@ static int do_cancel_ioctl(struct comedi_device *dev, unsigned int arg,
1751 nothing 1753 nothing
1752 1754
1753*/ 1755*/
1754static int do_poll_ioctl(struct comedi_device *dev, unsigned int arg, 1756static int do_poll_ioctl(struct comedi_device *dev, unsigned long arg,
1755 void *file) 1757 void *file)
1756{ 1758{
1757 struct comedi_subdevice *s; 1759 struct comedi_subdevice *s;
diff --git a/drivers/staging/iio/adc/mxs-lradc.c b/drivers/staging/iio/adc/mxs-lradc.c
index 32a19264a170..2a29b9baec0d 100644
--- a/drivers/staging/iio/adc/mxs-lradc.c
+++ b/drivers/staging/iio/adc/mxs-lradc.c
@@ -1559,14 +1559,16 @@ static int mxs_lradc_probe(struct platform_device *pdev)
1559 /* Grab all IRQ sources */ 1559 /* Grab all IRQ sources */
1560 for (i = 0; i < of_cfg->irq_count; i++) { 1560 for (i = 0; i < of_cfg->irq_count; i++) {
1561 lradc->irq[i] = platform_get_irq(pdev, i); 1561 lradc->irq[i] = platform_get_irq(pdev, i);
1562 if (lradc->irq[i] < 0) 1562 if (lradc->irq[i] < 0) {
1563 return lradc->irq[i]; 1563 ret = lradc->irq[i];
1564 goto err_clk;
1565 }
1564 1566
1565 ret = devm_request_irq(dev, lradc->irq[i], 1567 ret = devm_request_irq(dev, lradc->irq[i],
1566 mxs_lradc_handle_irq, 0, 1568 mxs_lradc_handle_irq, 0,
1567 of_cfg->irq_name[i], iio); 1569 of_cfg->irq_name[i], iio);
1568 if (ret) 1570 if (ret)
1569 return ret; 1571 goto err_clk;
1570 } 1572 }
1571 1573
1572 lradc->vref_mv = of_cfg->vref_mv; 1574 lradc->vref_mv = of_cfg->vref_mv;
@@ -1588,7 +1590,7 @@ static int mxs_lradc_probe(struct platform_device *pdev)
1588 &mxs_lradc_trigger_handler, 1590 &mxs_lradc_trigger_handler,
1589 &mxs_lradc_buffer_ops); 1591 &mxs_lradc_buffer_ops);
1590 if (ret) 1592 if (ret)
1591 return ret; 1593 goto err_clk;
1592 1594
1593 ret = mxs_lradc_trigger_init(iio); 1595 ret = mxs_lradc_trigger_init(iio);
1594 if (ret) 1596 if (ret)
@@ -1643,6 +1645,8 @@ err_dev:
1643 mxs_lradc_trigger_remove(iio); 1645 mxs_lradc_trigger_remove(iio);
1644err_trig: 1646err_trig:
1645 iio_triggered_buffer_cleanup(iio); 1647 iio_triggered_buffer_cleanup(iio);
1648err_clk:
1649 clk_disable_unprepare(lradc->clk);
1646 return ret; 1650 return ret;
1647} 1651}
1648 1652
diff --git a/drivers/staging/iio/impedance-analyzer/ad5933.c b/drivers/staging/iio/impedance-analyzer/ad5933.c
index d0c89d0457de..b6bd609c3655 100644
--- a/drivers/staging/iio/impedance-analyzer/ad5933.c
+++ b/drivers/staging/iio/impedance-analyzer/ad5933.c
@@ -115,6 +115,7 @@ static const struct iio_chan_spec ad5933_channels[] = {
115 .channel = 0, 115 .channel = 0,
116 .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED), 116 .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED),
117 .address = AD5933_REG_TEMP_DATA, 117 .address = AD5933_REG_TEMP_DATA,
118 .scan_index = -1,
118 .scan_type = { 119 .scan_type = {
119 .sign = 's', 120 .sign = 's',
120 .realbits = 14, 121 .realbits = 14,
@@ -124,9 +125,7 @@ static const struct iio_chan_spec ad5933_channels[] = {
124 .type = IIO_VOLTAGE, 125 .type = IIO_VOLTAGE,
125 .indexed = 1, 126 .indexed = 1,
126 .channel = 0, 127 .channel = 0,
127 .extend_name = "real_raw", 128 .extend_name = "real",
128 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
129 BIT(IIO_CHAN_INFO_SCALE),
130 .address = AD5933_REG_REAL_DATA, 129 .address = AD5933_REG_REAL_DATA,
131 .scan_index = 0, 130 .scan_index = 0,
132 .scan_type = { 131 .scan_type = {
@@ -138,9 +137,7 @@ static const struct iio_chan_spec ad5933_channels[] = {
138 .type = IIO_VOLTAGE, 137 .type = IIO_VOLTAGE,
139 .indexed = 1, 138 .indexed = 1,
140 .channel = 0, 139 .channel = 0,
141 .extend_name = "imag_raw", 140 .extend_name = "imag",
142 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
143 BIT(IIO_CHAN_INFO_SCALE),
144 .address = AD5933_REG_IMAG_DATA, 141 .address = AD5933_REG_IMAG_DATA,
145 .scan_index = 1, 142 .scan_index = 1,
146 .scan_type = { 143 .scan_type = {
@@ -749,14 +746,14 @@ static int ad5933_probe(struct i2c_client *client,
749 indio_dev->name = id->name; 746 indio_dev->name = id->name;
750 indio_dev->modes = INDIO_DIRECT_MODE; 747 indio_dev->modes = INDIO_DIRECT_MODE;
751 indio_dev->channels = ad5933_channels; 748 indio_dev->channels = ad5933_channels;
752 indio_dev->num_channels = 1; /* only register temp0_input */ 749 indio_dev->num_channels = ARRAY_SIZE(ad5933_channels);
753 750
754 ret = ad5933_register_ring_funcs_and_init(indio_dev); 751 ret = ad5933_register_ring_funcs_and_init(indio_dev);
755 if (ret) 752 if (ret)
756 goto error_disable_reg; 753 goto error_disable_reg;
757 754
758 /* skip temp0_input, register in0_(real|imag)_raw */ 755 ret = iio_buffer_register(indio_dev, ad5933_channels,
759 ret = iio_buffer_register(indio_dev, &ad5933_channels[1], 2); 756 ARRAY_SIZE(ad5933_channels));
760 if (ret) 757 if (ret)
761 goto error_unreg_ring; 758 goto error_unreg_ring;
762 759
diff --git a/drivers/staging/rtl8723au/include/rtw_eeprom.h b/drivers/staging/rtl8723au/include/rtw_eeprom.h
index e5121a2a64b4..a86f36e49dd1 100644
--- a/drivers/staging/rtl8723au/include/rtw_eeprom.h
+++ b/drivers/staging/rtl8723au/include/rtw_eeprom.h
@@ -107,12 +107,12 @@ enum rt_customer_id
107}; 107};
108 108
109struct eeprom_priv { 109struct eeprom_priv {
110 u8 mac_addr[6]; /* PermanentAddress */
110 u8 bautoload_fail_flag; 111 u8 bautoload_fail_flag;
111 u8 bloadfile_fail_flag; 112 u8 bloadfile_fail_flag;
112 u8 bloadmac_fail_flag; 113 u8 bloadmac_fail_flag;
113 /* u8 bempty; */ 114 /* u8 bempty; */
114 /* u8 sys_config; */ 115 /* u8 sys_config; */
115 u8 mac_addr[6]; /* PermanentAddress */
116 /* u8 config0; */ 116 /* u8 config0; */
117 u16 channel_plan; 117 u16 channel_plan;
118 /* u8 country_string[3]; */ 118 /* u8 country_string[3]; */
diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 3df5005c554d..9bdc6bd73432 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -742,7 +742,6 @@ static int ci_hdrc_remove(struct platform_device *pdev)
742 ci_role_destroy(ci); 742 ci_role_destroy(ci);
743 ci_hdrc_enter_lpm(ci, true); 743 ci_hdrc_enter_lpm(ci, true);
744 usb_phy_shutdown(ci->transceiver); 744 usb_phy_shutdown(ci->transceiver);
745 kfree(ci->hw_bank.regmap);
746 745
747 return 0; 746 return 0;
748} 747}
diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index bf015ab3b44c..55c90c53f2d6 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -619,7 +619,7 @@ struct dwc2_hsotg {
619 unsigned port_suspend_change:1; 619 unsigned port_suspend_change:1;
620 unsigned port_over_current_change:1; 620 unsigned port_over_current_change:1;
621 unsigned port_l1_change:1; 621 unsigned port_l1_change:1;
622 unsigned reserved:26; 622 unsigned reserved:25;
623 } b; 623 } b;
624 } flags; 624 } flags;
625 625
diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 7b5856fadd93..eee87098bb8b 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -2561,8 +2561,10 @@ static int s3c_hsotg_ep_enable(struct usb_ep *ep,
2561 hs_ep->fifo_size = val; 2561 hs_ep->fifo_size = val;
2562 break; 2562 break;
2563 } 2563 }
2564 if (i == 8) 2564 if (i == 8) {
2565 return -ENOMEM; 2565 ret = -ENOMEM;
2566 goto error;
2567 }
2566 } 2568 }
2567 2569
2568 /* for non control endpoints, set PID to D0 */ 2570 /* for non control endpoints, set PID to D0 */
@@ -2579,6 +2581,7 @@ static int s3c_hsotg_ep_enable(struct usb_ep *ep,
2579 /* enable the endpoint interrupt */ 2581 /* enable the endpoint interrupt */
2580 s3c_hsotg_ctrl_epint(hsotg, index, dir_in, 1); 2582 s3c_hsotg_ctrl_epint(hsotg, index, dir_in, 1);
2581 2583
2584error:
2582 spin_unlock_irqrestore(&hsotg->lock, flags); 2585 spin_unlock_irqrestore(&hsotg->lock, flags);
2583 return ret; 2586 return ret;
2584} 2587}
@@ -2934,9 +2937,7 @@ static int s3c_hsotg_udc_stop(struct usb_gadget *gadget,
2934 2937
2935 spin_lock_irqsave(&hsotg->lock, flags); 2938 spin_lock_irqsave(&hsotg->lock, flags);
2936 2939
2937 if (!driver) 2940 hsotg->driver = NULL;
2938 hsotg->driver = NULL;
2939
2940 hsotg->gadget.speed = USB_SPEED_UNKNOWN; 2941 hsotg->gadget.speed = USB_SPEED_UNKNOWN;
2941 2942
2942 spin_unlock_irqrestore(&hsotg->lock, flags); 2943 spin_unlock_irqrestore(&hsotg->lock, flags);
@@ -3567,6 +3568,7 @@ static int s3c_hsotg_probe(struct platform_device *pdev)
3567 s3c_hsotg_initep(hsotg, &hsotg->eps[epnum], epnum); 3568 s3c_hsotg_initep(hsotg, &hsotg->eps[epnum], epnum);
3568 3569
3569 /* disable power and clock */ 3570 /* disable power and clock */
3571 s3c_hsotg_phy_disable(hsotg);
3570 3572
3571 ret = regulator_bulk_disable(ARRAY_SIZE(hsotg->supplies), 3573 ret = regulator_bulk_disable(ARRAY_SIZE(hsotg->supplies),
3572 hsotg->supplies); 3574 hsotg->supplies);
@@ -3575,8 +3577,6 @@ static int s3c_hsotg_probe(struct platform_device *pdev)
3575 goto err_ep_mem; 3577 goto err_ep_mem;
3576 } 3578 }
3577 3579
3578 s3c_hsotg_phy_disable(hsotg);
3579
3580 ret = usb_add_gadget_udc(&pdev->dev, &hsotg->gadget); 3580 ret = usb_add_gadget_udc(&pdev->dev, &hsotg->gadget);
3581 if (ret) 3581 if (ret)
3582 goto err_ep_mem; 3582 goto err_ep_mem;
diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c
index 2f537d588225..a0aa9f3da441 100644
--- a/drivers/usb/dwc3/dwc3-omap.c
+++ b/drivers/usb/dwc3/dwc3-omap.c
@@ -597,7 +597,7 @@ static int dwc3_omap_prepare(struct device *dev)
597{ 597{
598 struct dwc3_omap *omap = dev_get_drvdata(dev); 598 struct dwc3_omap *omap = dev_get_drvdata(dev);
599 599
600 dwc3_omap_write_irqmisc_set(omap, 0x00); 600 dwc3_omap_disable_irqs(omap);
601 601
602 return 0; 602 return 0;
603} 603}
@@ -605,19 +605,8 @@ static int dwc3_omap_prepare(struct device *dev)
605static void dwc3_omap_complete(struct device *dev) 605static void dwc3_omap_complete(struct device *dev)
606{ 606{
607 struct dwc3_omap *omap = dev_get_drvdata(dev); 607 struct dwc3_omap *omap = dev_get_drvdata(dev);
608 u32 reg;
609 608
610 reg = (USBOTGSS_IRQMISC_OEVT | 609 dwc3_omap_enable_irqs(omap);
611 USBOTGSS_IRQMISC_DRVVBUS_RISE |
612 USBOTGSS_IRQMISC_CHRGVBUS_RISE |
613 USBOTGSS_IRQMISC_DISCHRGVBUS_RISE |
614 USBOTGSS_IRQMISC_IDPULLUP_RISE |
615 USBOTGSS_IRQMISC_DRVVBUS_FALL |
616 USBOTGSS_IRQMISC_CHRGVBUS_FALL |
617 USBOTGSS_IRQMISC_DISCHRGVBUS_FALL |
618 USBOTGSS_IRQMISC_IDPULLUP_FALL);
619
620 dwc3_omap_write_irqmisc_set(omap, reg);
621} 610}
622 611
623static int dwc3_omap_suspend(struct device *dev) 612static int dwc3_omap_suspend(struct device *dev)
diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c
index 436fb08c40b8..a36cf66302fb 100644
--- a/drivers/usb/dwc3/dwc3-pci.c
+++ b/drivers/usb/dwc3/dwc3-pci.c
@@ -30,6 +30,7 @@
30#define PCI_DEVICE_ID_SYNOPSYS_HAPSUSB3 0xabcd 30#define PCI_DEVICE_ID_SYNOPSYS_HAPSUSB3 0xabcd
31#define PCI_DEVICE_ID_INTEL_BYT 0x0f37 31#define PCI_DEVICE_ID_INTEL_BYT 0x0f37
32#define PCI_DEVICE_ID_INTEL_MRFLD 0x119e 32#define PCI_DEVICE_ID_INTEL_MRFLD 0x119e
33#define PCI_DEVICE_ID_INTEL_BSW 0x22B7
33 34
34struct dwc3_pci { 35struct dwc3_pci {
35 struct device *dev; 36 struct device *dev;
@@ -181,6 +182,7 @@ static const struct pci_device_id dwc3_pci_id_table[] = {
181 PCI_DEVICE(PCI_VENDOR_ID_SYNOPSYS, 182 PCI_DEVICE(PCI_VENDOR_ID_SYNOPSYS,
182 PCI_DEVICE_ID_SYNOPSYS_HAPSUSB3), 183 PCI_DEVICE_ID_SYNOPSYS_HAPSUSB3),
183 }, 184 },
185 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BSW), },
184 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BYT), }, 186 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BYT), },
185 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_MRFLD), }, 187 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_MRFLD), },
186 { } /* Terminating Entry */ 188 { } /* Terminating Entry */
diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c
index b35938777dde..711b23019d54 100644
--- a/drivers/usb/dwc3/ep0.c
+++ b/drivers/usb/dwc3/ep0.c
@@ -256,7 +256,7 @@ static void dwc3_ep0_stall_and_restart(struct dwc3 *dwc)
256 256
257 /* stall is always issued on EP0 */ 257 /* stall is always issued on EP0 */
258 dep = dwc->eps[0]; 258 dep = dwc->eps[0];
259 __dwc3_gadget_ep_set_halt(dep, 1); 259 __dwc3_gadget_ep_set_halt(dep, 1, false);
260 dep->flags = DWC3_EP_ENABLED; 260 dep->flags = DWC3_EP_ENABLED;
261 dwc->delayed_status = false; 261 dwc->delayed_status = false;
262 262
@@ -271,7 +271,7 @@ static void dwc3_ep0_stall_and_restart(struct dwc3 *dwc)
271 dwc3_ep0_out_start(dwc); 271 dwc3_ep0_out_start(dwc);
272} 272}
273 273
274int dwc3_gadget_ep0_set_halt(struct usb_ep *ep, int value) 274int __dwc3_gadget_ep0_set_halt(struct usb_ep *ep, int value)
275{ 275{
276 struct dwc3_ep *dep = to_dwc3_ep(ep); 276 struct dwc3_ep *dep = to_dwc3_ep(ep);
277 struct dwc3 *dwc = dep->dwc; 277 struct dwc3 *dwc = dep->dwc;
@@ -281,6 +281,20 @@ int dwc3_gadget_ep0_set_halt(struct usb_ep *ep, int value)
281 return 0; 281 return 0;
282} 282}
283 283
284int dwc3_gadget_ep0_set_halt(struct usb_ep *ep, int value)
285{
286 struct dwc3_ep *dep = to_dwc3_ep(ep);
287 struct dwc3 *dwc = dep->dwc;
288 unsigned long flags;
289 int ret;
290
291 spin_lock_irqsave(&dwc->lock, flags);
292 ret = __dwc3_gadget_ep0_set_halt(ep, value);
293 spin_unlock_irqrestore(&dwc->lock, flags);
294
295 return ret;
296}
297
284void dwc3_ep0_out_start(struct dwc3 *dwc) 298void dwc3_ep0_out_start(struct dwc3 *dwc)
285{ 299{
286 int ret; 300 int ret;
@@ -466,7 +480,7 @@ static int dwc3_ep0_handle_feature(struct dwc3 *dwc,
466 return -EINVAL; 480 return -EINVAL;
467 if (set == 0 && (dep->flags & DWC3_EP_WEDGE)) 481 if (set == 0 && (dep->flags & DWC3_EP_WEDGE))
468 break; 482 break;
469 ret = __dwc3_gadget_ep_set_halt(dep, set); 483 ret = __dwc3_gadget_ep_set_halt(dep, set, true);
470 if (ret) 484 if (ret)
471 return -EINVAL; 485 return -EINVAL;
472 break; 486 break;
@@ -775,9 +789,6 @@ static void dwc3_ep0_complete_data(struct dwc3 *dwc,
775 789
776 dwc->ep0_next_event = DWC3_EP0_NRDY_STATUS; 790 dwc->ep0_next_event = DWC3_EP0_NRDY_STATUS;
777 791
778 r = next_request(&ep0->request_list);
779 ur = &r->request;
780
781 trb = dwc->ep0_trb; 792 trb = dwc->ep0_trb;
782 793
783 status = DWC3_TRB_SIZE_TRBSTS(trb->size); 794 status = DWC3_TRB_SIZE_TRBSTS(trb->size);
@@ -790,6 +801,12 @@ static void dwc3_ep0_complete_data(struct dwc3 *dwc,
790 return; 801 return;
791 } 802 }
792 803
804 r = next_request(&ep0->request_list);
805 if (!r)
806 return;
807
808 ur = &r->request;
809
793 length = trb->size & DWC3_TRB_SIZE_MASK; 810 length = trb->size & DWC3_TRB_SIZE_MASK;
794 811
795 if (dwc->ep0_bounced) { 812 if (dwc->ep0_bounced) {
@@ -811,12 +828,19 @@ static void dwc3_ep0_complete_data(struct dwc3 *dwc,
811 828
812 dwc3_ep0_stall_and_restart(dwc); 829 dwc3_ep0_stall_and_restart(dwc);
813 } else { 830 } else {
814 /* 831 dwc3_gadget_giveback(ep0, r, 0);
815 * handle the case where we have to send a zero packet. This 832
816 * seems to be case when req.length > maxpacket. Could it be? 833 if (IS_ALIGNED(ur->length, ep0->endpoint.maxpacket) &&
817 */ 834 ur->length && ur->zero) {
818 if (r) 835 int ret;
819 dwc3_gadget_giveback(ep0, r, 0); 836
837 dwc->ep0_next_event = DWC3_EP0_COMPLETE;
838
839 ret = dwc3_ep0_start_trans(dwc, epnum,
840 dwc->ctrl_req_addr, 0,
841 DWC3_TRBCTL_CONTROL_DATA);
842 WARN_ON(ret < 0);
843 }
820 } 844 }
821} 845}
822 846
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 3818b26bfc05..546ea5431b8c 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -525,12 +525,11 @@ static int __dwc3_gadget_ep_enable(struct dwc3_ep *dep,
525 if (!usb_endpoint_xfer_isoc(desc)) 525 if (!usb_endpoint_xfer_isoc(desc))
526 return 0; 526 return 0;
527 527
528 memset(&trb_link, 0, sizeof(trb_link));
529
530 /* Link TRB for ISOC. The HWO bit is never reset */ 528 /* Link TRB for ISOC. The HWO bit is never reset */
531 trb_st_hw = &dep->trb_pool[0]; 529 trb_st_hw = &dep->trb_pool[0];
532 530
533 trb_link = &dep->trb_pool[DWC3_TRB_NUM - 1]; 531 trb_link = &dep->trb_pool[DWC3_TRB_NUM - 1];
532 memset(trb_link, 0, sizeof(*trb_link));
534 533
535 trb_link->bpl = lower_32_bits(dwc3_trb_dma_offset(dep, trb_st_hw)); 534 trb_link->bpl = lower_32_bits(dwc3_trb_dma_offset(dep, trb_st_hw));
536 trb_link->bph = upper_32_bits(dwc3_trb_dma_offset(dep, trb_st_hw)); 535 trb_link->bph = upper_32_bits(dwc3_trb_dma_offset(dep, trb_st_hw));
@@ -581,7 +580,7 @@ static int __dwc3_gadget_ep_disable(struct dwc3_ep *dep)
581 580
582 /* make sure HW endpoint isn't stalled */ 581 /* make sure HW endpoint isn't stalled */
583 if (dep->flags & DWC3_EP_STALL) 582 if (dep->flags & DWC3_EP_STALL)
584 __dwc3_gadget_ep_set_halt(dep, 0); 583 __dwc3_gadget_ep_set_halt(dep, 0, false);
585 584
586 reg = dwc3_readl(dwc->regs, DWC3_DALEPENA); 585 reg = dwc3_readl(dwc->regs, DWC3_DALEPENA);
587 reg &= ~DWC3_DALEPENA_EP(dep->number); 586 reg &= ~DWC3_DALEPENA_EP(dep->number);
@@ -1202,15 +1201,28 @@ out0:
1202 return ret; 1201 return ret;
1203} 1202}
1204 1203
1205int __dwc3_gadget_ep_set_halt(struct dwc3_ep *dep, int value) 1204int __dwc3_gadget_ep_set_halt(struct dwc3_ep *dep, int value, int protocol)
1206{ 1205{
1207 struct dwc3_gadget_ep_cmd_params params; 1206 struct dwc3_gadget_ep_cmd_params params;
1208 struct dwc3 *dwc = dep->dwc; 1207 struct dwc3 *dwc = dep->dwc;
1209 int ret; 1208 int ret;
1210 1209
1210 if (usb_endpoint_xfer_isoc(dep->endpoint.desc)) {
1211 dev_err(dwc->dev, "%s is of Isochronous type\n", dep->name);
1212 return -EINVAL;
1213 }
1214
1211 memset(&params, 0x00, sizeof(params)); 1215 memset(&params, 0x00, sizeof(params));
1212 1216
1213 if (value) { 1217 if (value) {
1218 if (!protocol && ((dep->direction && dep->flags & DWC3_EP_BUSY) ||
1219 (!list_empty(&dep->req_queued) ||
1220 !list_empty(&dep->request_list)))) {
1221 dev_dbg(dwc->dev, "%s: pending request, cannot halt\n",
1222 dep->name);
1223 return -EAGAIN;
1224 }
1225
1214 ret = dwc3_send_gadget_ep_cmd(dwc, dep->number, 1226 ret = dwc3_send_gadget_ep_cmd(dwc, dep->number,
1215 DWC3_DEPCMD_SETSTALL, &params); 1227 DWC3_DEPCMD_SETSTALL, &params);
1216 if (ret) 1228 if (ret)
@@ -1241,15 +1253,7 @@ static int dwc3_gadget_ep_set_halt(struct usb_ep *ep, int value)
1241 int ret; 1253 int ret;
1242 1254
1243 spin_lock_irqsave(&dwc->lock, flags); 1255 spin_lock_irqsave(&dwc->lock, flags);
1244 1256 ret = __dwc3_gadget_ep_set_halt(dep, value, false);
1245 if (usb_endpoint_xfer_isoc(dep->endpoint.desc)) {
1246 dev_err(dwc->dev, "%s is of Isochronous type\n", dep->name);
1247 ret = -EINVAL;
1248 goto out;
1249 }
1250
1251 ret = __dwc3_gadget_ep_set_halt(dep, value);
1252out:
1253 spin_unlock_irqrestore(&dwc->lock, flags); 1257 spin_unlock_irqrestore(&dwc->lock, flags);
1254 1258
1255 return ret; 1259 return ret;
@@ -1260,15 +1264,18 @@ static int dwc3_gadget_ep_set_wedge(struct usb_ep *ep)
1260 struct dwc3_ep *dep = to_dwc3_ep(ep); 1264 struct dwc3_ep *dep = to_dwc3_ep(ep);
1261 struct dwc3 *dwc = dep->dwc; 1265 struct dwc3 *dwc = dep->dwc;
1262 unsigned long flags; 1266 unsigned long flags;
1267 int ret;
1263 1268
1264 spin_lock_irqsave(&dwc->lock, flags); 1269 spin_lock_irqsave(&dwc->lock, flags);
1265 dep->flags |= DWC3_EP_WEDGE; 1270 dep->flags |= DWC3_EP_WEDGE;
1266 spin_unlock_irqrestore(&dwc->lock, flags);
1267 1271
1268 if (dep->number == 0 || dep->number == 1) 1272 if (dep->number == 0 || dep->number == 1)
1269 return dwc3_gadget_ep0_set_halt(ep, 1); 1273 ret = __dwc3_gadget_ep0_set_halt(ep, 1);
1270 else 1274 else
1271 return dwc3_gadget_ep_set_halt(ep, 1); 1275 ret = __dwc3_gadget_ep_set_halt(dep, 1, false);
1276 spin_unlock_irqrestore(&dwc->lock, flags);
1277
1278 return ret;
1272} 1279}
1273 1280
1274/* -------------------------------------------------------------------------- */ 1281/* -------------------------------------------------------------------------- */
diff --git a/drivers/usb/dwc3/gadget.h b/drivers/usb/dwc3/gadget.h
index 178ad8982206..18ae3eaa8b6f 100644
--- a/drivers/usb/dwc3/gadget.h
+++ b/drivers/usb/dwc3/gadget.h
@@ -82,10 +82,11 @@ void dwc3_gadget_giveback(struct dwc3_ep *dep, struct dwc3_request *req,
82void dwc3_ep0_interrupt(struct dwc3 *dwc, 82void dwc3_ep0_interrupt(struct dwc3 *dwc,
83 const struct dwc3_event_depevt *event); 83 const struct dwc3_event_depevt *event);
84void dwc3_ep0_out_start(struct dwc3 *dwc); 84void dwc3_ep0_out_start(struct dwc3 *dwc);
85int __dwc3_gadget_ep0_set_halt(struct usb_ep *ep, int value);
85int dwc3_gadget_ep0_set_halt(struct usb_ep *ep, int value); 86int dwc3_gadget_ep0_set_halt(struct usb_ep *ep, int value);
86int dwc3_gadget_ep0_queue(struct usb_ep *ep, struct usb_request *request, 87int dwc3_gadget_ep0_queue(struct usb_ep *ep, struct usb_request *request,
87 gfp_t gfp_flags); 88 gfp_t gfp_flags);
88int __dwc3_gadget_ep_set_halt(struct dwc3_ep *dep, int value); 89int __dwc3_gadget_ep_set_halt(struct dwc3_ep *dep, int value, int protocol);
89 90
90/** 91/**
91 * dwc3_gadget_ep_get_transfer_index - Gets transfer index from HW 92 * dwc3_gadget_ep_get_transfer_index - Gets transfer index from HW
diff --git a/drivers/usb/dwc3/trace.h b/drivers/usb/dwc3/trace.h
index 78aff1da089a..60b0f41eafc4 100644
--- a/drivers/usb/dwc3/trace.h
+++ b/drivers/usb/dwc3/trace.h
@@ -73,15 +73,23 @@ DECLARE_EVENT_CLASS(dwc3_log_ctrl,
73 TP_PROTO(struct usb_ctrlrequest *ctrl), 73 TP_PROTO(struct usb_ctrlrequest *ctrl),
74 TP_ARGS(ctrl), 74 TP_ARGS(ctrl),
75 TP_STRUCT__entry( 75 TP_STRUCT__entry(
76 __field(struct usb_ctrlrequest *, ctrl) 76 __field(__u8, bRequestType)
77 __field(__u8, bRequest)
78 __field(__le16, wValue)
79 __field(__le16, wIndex)
80 __field(__le16, wLength)
77 ), 81 ),
78 TP_fast_assign( 82 TP_fast_assign(
79 __entry->ctrl = ctrl; 83 __entry->bRequestType = ctrl->bRequestType;
84 __entry->bRequest = ctrl->bRequest;
85 __entry->wValue = ctrl->wValue;
86 __entry->wIndex = ctrl->wIndex;
87 __entry->wLength = ctrl->wLength;
80 ), 88 ),
81 TP_printk("bRequestType %02x bRequest %02x wValue %04x wIndex %04x wLength %d", 89 TP_printk("bRequestType %02x bRequest %02x wValue %04x wIndex %04x wLength %d",
82 __entry->ctrl->bRequestType, __entry->ctrl->bRequest, 90 __entry->bRequestType, __entry->bRequest,
83 le16_to_cpu(__entry->ctrl->wValue), le16_to_cpu(__entry->ctrl->wIndex), 91 le16_to_cpu(__entry->wValue), le16_to_cpu(__entry->wIndex),
84 le16_to_cpu(__entry->ctrl->wLength) 92 le16_to_cpu(__entry->wLength)
85 ) 93 )
86); 94);
87 95
@@ -94,15 +102,22 @@ DECLARE_EVENT_CLASS(dwc3_log_request,
94 TP_PROTO(struct dwc3_request *req), 102 TP_PROTO(struct dwc3_request *req),
95 TP_ARGS(req), 103 TP_ARGS(req),
96 TP_STRUCT__entry( 104 TP_STRUCT__entry(
105 __dynamic_array(char, name, DWC3_MSG_MAX)
97 __field(struct dwc3_request *, req) 106 __field(struct dwc3_request *, req)
107 __field(unsigned, actual)
108 __field(unsigned, length)
109 __field(int, status)
98 ), 110 ),
99 TP_fast_assign( 111 TP_fast_assign(
112 snprintf(__get_str(name), DWC3_MSG_MAX, "%s", req->dep->name);
100 __entry->req = req; 113 __entry->req = req;
114 __entry->actual = req->request.actual;
115 __entry->length = req->request.length;
116 __entry->status = req->request.status;
101 ), 117 ),
102 TP_printk("%s: req %p length %u/%u ==> %d", 118 TP_printk("%s: req %p length %u/%u ==> %d",
103 __entry->req->dep->name, __entry->req, 119 __get_str(name), __entry->req, __entry->actual, __entry->length,
104 __entry->req->request.actual, __entry->req->request.length, 120 __entry->status
105 __entry->req->request.status
106 ) 121 )
107); 122);
108 123
@@ -158,17 +173,17 @@ DECLARE_EVENT_CLASS(dwc3_log_gadget_ep_cmd,
158 struct dwc3_gadget_ep_cmd_params *params), 173 struct dwc3_gadget_ep_cmd_params *params),
159 TP_ARGS(dep, cmd, params), 174 TP_ARGS(dep, cmd, params),
160 TP_STRUCT__entry( 175 TP_STRUCT__entry(
161 __field(struct dwc3_ep *, dep) 176 __dynamic_array(char, name, DWC3_MSG_MAX)
162 __field(unsigned int, cmd) 177 __field(unsigned int, cmd)
163 __field(struct dwc3_gadget_ep_cmd_params *, params) 178 __field(struct dwc3_gadget_ep_cmd_params *, params)
164 ), 179 ),
165 TP_fast_assign( 180 TP_fast_assign(
166 __entry->dep = dep; 181 snprintf(__get_str(name), DWC3_MSG_MAX, "%s", dep->name);
167 __entry->cmd = cmd; 182 __entry->cmd = cmd;
168 __entry->params = params; 183 __entry->params = params;
169 ), 184 ),
170 TP_printk("%s: cmd '%s' [%d] params %08x %08x %08x\n", 185 TP_printk("%s: cmd '%s' [%d] params %08x %08x %08x\n",
171 __entry->dep->name, dwc3_gadget_ep_cmd_string(__entry->cmd), 186 __get_str(name), dwc3_gadget_ep_cmd_string(__entry->cmd),
172 __entry->cmd, __entry->params->param0, 187 __entry->cmd, __entry->params->param0,
173 __entry->params->param1, __entry->params->param2 188 __entry->params->param1, __entry->params->param2
174 ) 189 )
@@ -184,16 +199,24 @@ DECLARE_EVENT_CLASS(dwc3_log_trb,
184 TP_PROTO(struct dwc3_ep *dep, struct dwc3_trb *trb), 199 TP_PROTO(struct dwc3_ep *dep, struct dwc3_trb *trb),
185 TP_ARGS(dep, trb), 200 TP_ARGS(dep, trb),
186 TP_STRUCT__entry( 201 TP_STRUCT__entry(
187 __field(struct dwc3_ep *, dep) 202 __dynamic_array(char, name, DWC3_MSG_MAX)
188 __field(struct dwc3_trb *, trb) 203 __field(struct dwc3_trb *, trb)
204 __field(u32, bpl)
205 __field(u32, bph)
206 __field(u32, size)
207 __field(u32, ctrl)
189 ), 208 ),
190 TP_fast_assign( 209 TP_fast_assign(
191 __entry->dep = dep; 210 snprintf(__get_str(name), DWC3_MSG_MAX, "%s", dep->name);
192 __entry->trb = trb; 211 __entry->trb = trb;
212 __entry->bpl = trb->bpl;
213 __entry->bph = trb->bph;
214 __entry->size = trb->size;
215 __entry->ctrl = trb->ctrl;
193 ), 216 ),
194 TP_printk("%s: trb %p bph %08x bpl %08x size %08x ctrl %08x\n", 217 TP_printk("%s: trb %p bph %08x bpl %08x size %08x ctrl %08x\n",
195 __entry->dep->name, __entry->trb, __entry->trb->bph, 218 __get_str(name), __entry->trb, __entry->bph, __entry->bpl,
196 __entry->trb->bpl, __entry->trb->size, __entry->trb->ctrl 219 __entry->size, __entry->ctrl
197 ) 220 )
198); 221);
199 222
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index a8c18df171c3..f6a51fddd5b5 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -560,7 +560,7 @@ static int bos_desc(struct usb_composite_dev *cdev)
560 usb_ext->bLength = USB_DT_USB_EXT_CAP_SIZE; 560 usb_ext->bLength = USB_DT_USB_EXT_CAP_SIZE;
561 usb_ext->bDescriptorType = USB_DT_DEVICE_CAPABILITY; 561 usb_ext->bDescriptorType = USB_DT_DEVICE_CAPABILITY;
562 usb_ext->bDevCapabilityType = USB_CAP_TYPE_EXT; 562 usb_ext->bDevCapabilityType = USB_CAP_TYPE_EXT;
563 usb_ext->bmAttributes = cpu_to_le32(USB_LPM_SUPPORT); 563 usb_ext->bmAttributes = cpu_to_le32(USB_LPM_SUPPORT | USB_BESL_SUPPORT);
564 564
565 /* 565 /*
566 * The Superspeed USB Capability descriptor shall be implemented by all 566 * The Superspeed USB Capability descriptor shall be implemented by all
diff --git a/drivers/usb/gadget/function/f_acm.c b/drivers/usb/gadget/function/f_acm.c
index 6da4685490ef..aad8165e98ef 100644
--- a/drivers/usb/gadget/function/f_acm.c
+++ b/drivers/usb/gadget/function/f_acm.c
@@ -433,12 +433,12 @@ static int acm_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
433 dev_vdbg(&cdev->gadget->dev, 433 dev_vdbg(&cdev->gadget->dev,
434 "reset acm control interface %d\n", intf); 434 "reset acm control interface %d\n", intf);
435 usb_ep_disable(acm->notify); 435 usb_ep_disable(acm->notify);
436 } else { 436 }
437 dev_vdbg(&cdev->gadget->dev, 437
438 "init acm ctrl interface %d\n", intf); 438 if (!acm->notify->desc)
439 if (config_ep_by_speed(cdev->gadget, f, acm->notify)) 439 if (config_ep_by_speed(cdev->gadget, f, acm->notify))
440 return -EINVAL; 440 return -EINVAL;
441 } 441
442 usb_ep_enable(acm->notify); 442 usb_ep_enable(acm->notify);
443 acm->notify->driver_data = acm; 443 acm->notify->driver_data = acm;
444 444
diff --git a/drivers/usb/gadget/function/f_eem.c b/drivers/usb/gadget/function/f_eem.c
index 4d8b236ea608..c9e90de5bdd9 100644
--- a/drivers/usb/gadget/function/f_eem.c
+++ b/drivers/usb/gadget/function/f_eem.c
@@ -325,7 +325,6 @@ static int eem_bind(struct usb_configuration *c, struct usb_function *f)
325 return 0; 325 return 0;
326 326
327fail: 327fail:
328 usb_free_all_descriptors(f);
329 if (eem->port.out_ep) 328 if (eem->port.out_ep)
330 eem->port.out_ep->driver_data = NULL; 329 eem->port.out_ep->driver_data = NULL;
331 if (eem->port.in_ep) 330 if (eem->port.in_ep)
diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
index 7c6771d027a2..63314ede7ba6 100644
--- a/drivers/usb/gadget/function/f_fs.c
+++ b/drivers/usb/gadget/function/f_fs.c
@@ -647,15 +647,26 @@ static void ffs_user_copy_worker(struct work_struct *work)
647 if (io_data->read && ret > 0) { 647 if (io_data->read && ret > 0) {
648 int i; 648 int i;
649 size_t pos = 0; 649 size_t pos = 0;
650
651 /*
652 * Since req->length may be bigger than io_data->len (after
653 * being rounded up to maxpacketsize), we may end up with more
654 * data then user space has space for.
655 */
656 ret = min_t(int, ret, io_data->len);
657
650 use_mm(io_data->mm); 658 use_mm(io_data->mm);
651 for (i = 0; i < io_data->nr_segs; i++) { 659 for (i = 0; i < io_data->nr_segs; i++) {
660 size_t len = min_t(size_t, ret - pos,
661 io_data->iovec[i].iov_len);
662 if (!len)
663 break;
652 if (unlikely(copy_to_user(io_data->iovec[i].iov_base, 664 if (unlikely(copy_to_user(io_data->iovec[i].iov_base,
653 &io_data->buf[pos], 665 &io_data->buf[pos], len))) {
654 io_data->iovec[i].iov_len))) {
655 ret = -EFAULT; 666 ret = -EFAULT;
656 break; 667 break;
657 } 668 }
658 pos += io_data->iovec[i].iov_len; 669 pos += len;
659 } 670 }
660 unuse_mm(io_data->mm); 671 unuse_mm(io_data->mm);
661 } 672 }
@@ -687,7 +698,7 @@ static ssize_t ffs_epfile_io(struct file *file, struct ffs_io_data *io_data)
687 struct ffs_epfile *epfile = file->private_data; 698 struct ffs_epfile *epfile = file->private_data;
688 struct ffs_ep *ep; 699 struct ffs_ep *ep;
689 char *data = NULL; 700 char *data = NULL;
690 ssize_t ret, data_len; 701 ssize_t ret, data_len = -EINVAL;
691 int halt; 702 int halt;
692 703
693 /* Are we still active? */ 704 /* Are we still active? */
@@ -787,13 +798,30 @@ static ssize_t ffs_epfile_io(struct file *file, struct ffs_io_data *io_data)
787 /* Fire the request */ 798 /* Fire the request */
788 struct usb_request *req; 799 struct usb_request *req;
789 800
801 /*
802 * Sanity Check: even though data_len can't be used
803 * uninitialized at the time I write this comment, some
804 * compilers complain about this situation.
805 * In order to keep the code clean from warnings, data_len is
806 * being initialized to -EINVAL during its declaration, which
807 * means we can't rely on compiler anymore to warn no future
808 * changes won't result in data_len being used uninitialized.
809 * For such reason, we're adding this redundant sanity check
810 * here.
811 */
812 if (unlikely(data_len == -EINVAL)) {
813 WARN(1, "%s: data_len == -EINVAL\n", __func__);
814 ret = -EINVAL;
815 goto error_lock;
816 }
817
790 if (io_data->aio) { 818 if (io_data->aio) {
791 req = usb_ep_alloc_request(ep->ep, GFP_KERNEL); 819 req = usb_ep_alloc_request(ep->ep, GFP_KERNEL);
792 if (unlikely(!req)) 820 if (unlikely(!req))
793 goto error_lock; 821 goto error_lock;
794 822
795 req->buf = data; 823 req->buf = data;
796 req->length = io_data->len; 824 req->length = data_len;
797 825
798 io_data->buf = data; 826 io_data->buf = data;
799 io_data->ep = ep->ep; 827 io_data->ep = ep->ep;
@@ -815,7 +843,7 @@ static ssize_t ffs_epfile_io(struct file *file, struct ffs_io_data *io_data)
815 843
816 req = ep->req; 844 req = ep->req;
817 req->buf = data; 845 req->buf = data;
818 req->length = io_data->len; 846 req->length = data_len;
819 847
820 req->context = &done; 848 req->context = &done;
821 req->complete = ffs_epfile_io_complete; 849 req->complete = ffs_epfile_io_complete;
@@ -2663,8 +2691,6 @@ static inline struct f_fs_opts *ffs_do_functionfs_bind(struct usb_function *f,
2663 func->conf = c; 2691 func->conf = c;
2664 func->gadget = c->cdev->gadget; 2692 func->gadget = c->cdev->gadget;
2665 2693
2666 ffs_data_get(func->ffs);
2667
2668 /* 2694 /*
2669 * in drivers/usb/gadget/configfs.c:configfs_composite_bind() 2695 * in drivers/usb/gadget/configfs.c:configfs_composite_bind()
2670 * configurations are bound in sequence with list_for_each_entry, 2696 * configurations are bound in sequence with list_for_each_entry,
diff --git a/drivers/usb/gadget/function/f_hid.c b/drivers/usb/gadget/function/f_hid.c
index a95290a1289f..59ab62c92b66 100644
--- a/drivers/usb/gadget/function/f_hid.c
+++ b/drivers/usb/gadget/function/f_hid.c
@@ -621,12 +621,14 @@ static int __init hidg_bind(struct usb_configuration *c, struct usb_function *f)
621 dev = MKDEV(major, hidg->minor); 621 dev = MKDEV(major, hidg->minor);
622 status = cdev_add(&hidg->cdev, dev, 1); 622 status = cdev_add(&hidg->cdev, dev, 1);
623 if (status) 623 if (status)
624 goto fail; 624 goto fail_free_descs;
625 625
626 device_create(hidg_class, NULL, dev, NULL, "%s%d", "hidg", hidg->minor); 626 device_create(hidg_class, NULL, dev, NULL, "%s%d", "hidg", hidg->minor);
627 627
628 return 0; 628 return 0;
629 629
630fail_free_descs:
631 usb_free_all_descriptors(f);
630fail: 632fail:
631 ERROR(f->config->cdev, "hidg_bind FAILED\n"); 633 ERROR(f->config->cdev, "hidg_bind FAILED\n");
632 if (hidg->req != NULL) { 634 if (hidg->req != NULL) {
@@ -635,7 +637,6 @@ fail:
635 usb_ep_free_request(hidg->in_ep, hidg->req); 637 usb_ep_free_request(hidg->in_ep, hidg->req);
636 } 638 }
637 639
638 usb_free_all_descriptors(f);
639 return status; 640 return status;
640} 641}
641 642
diff --git a/drivers/usb/gadget/function/f_loopback.c b/drivers/usb/gadget/function/f_loopback.c
index bf04389137e6..298b46112b1a 100644
--- a/drivers/usb/gadget/function/f_loopback.c
+++ b/drivers/usb/gadget/function/f_loopback.c
@@ -253,22 +253,13 @@ static void loopback_complete(struct usb_ep *ep, struct usb_request *req)
253 253
254 case 0: /* normal completion? */ 254 case 0: /* normal completion? */
255 if (ep == loop->out_ep) { 255 if (ep == loop->out_ep) {
256 /* loop this OUT packet back IN to the host */
257 req->zero = (req->actual < req->length); 256 req->zero = (req->actual < req->length);
258 req->length = req->actual; 257 req->length = req->actual;
259 status = usb_ep_queue(loop->in_ep, req, GFP_ATOMIC);
260 if (status == 0)
261 return;
262
263 /* "should never get here" */
264 ERROR(cdev, "can't loop %s to %s: %d\n",
265 ep->name, loop->in_ep->name,
266 status);
267 } 258 }
268 259
269 /* queue the buffer for some later OUT packet */ 260 /* queue the buffer for some later OUT packet */
270 req->length = buflen; 261 req->length = buflen;
271 status = usb_ep_queue(loop->out_ep, req, GFP_ATOMIC); 262 status = usb_ep_queue(ep, req, GFP_ATOMIC);
272 if (status == 0) 263 if (status == 0)
273 return; 264 return;
274 265
@@ -308,60 +299,66 @@ static inline struct usb_request *lb_alloc_ep_req(struct usb_ep *ep, int len)
308 return alloc_ep_req(ep, len, buflen); 299 return alloc_ep_req(ep, len, buflen);
309} 300}
310 301
311static int 302static int enable_endpoint(struct usb_composite_dev *cdev, struct f_loopback *loop,
312enable_loopback(struct usb_composite_dev *cdev, struct f_loopback *loop) 303 struct usb_ep *ep)
313{ 304{
314 int result = 0;
315 struct usb_ep *ep;
316 struct usb_request *req; 305 struct usb_request *req;
317 unsigned i; 306 unsigned i;
307 int result;
318 308
319 /* one endpoint writes data back IN to the host */ 309 /*
320 ep = loop->in_ep; 310 * one endpoint writes data back IN to the host while another endpoint
311 * just reads OUT packets
312 */
321 result = config_ep_by_speed(cdev->gadget, &(loop->function), ep); 313 result = config_ep_by_speed(cdev->gadget, &(loop->function), ep);
322 if (result) 314 if (result)
323 return result; 315 goto fail0;
324 result = usb_ep_enable(ep); 316 result = usb_ep_enable(ep);
325 if (result < 0) 317 if (result < 0)
326 return result;
327 ep->driver_data = loop;
328
329 /* one endpoint just reads OUT packets */
330 ep = loop->out_ep;
331 result = config_ep_by_speed(cdev->gadget, &(loop->function), ep);
332 if (result)
333 goto fail0; 318 goto fail0;
334
335 result = usb_ep_enable(ep);
336 if (result < 0) {
337fail0:
338 ep = loop->in_ep;
339 usb_ep_disable(ep);
340 ep->driver_data = NULL;
341 return result;
342 }
343 ep->driver_data = loop; 319 ep->driver_data = loop;
344 320
345 /* allocate a bunch of read buffers and queue them all at once. 321 /*
322 * allocate a bunch of read buffers and queue them all at once.
346 * we buffer at most 'qlen' transfers; fewer if any need more 323 * we buffer at most 'qlen' transfers; fewer if any need more
347 * than 'buflen' bytes each. 324 * than 'buflen' bytes each.
348 */ 325 */
349 for (i = 0; i < qlen && result == 0; i++) { 326 for (i = 0; i < qlen && result == 0; i++) {
350 req = lb_alloc_ep_req(ep, 0); 327 req = lb_alloc_ep_req(ep, 0);
351 if (req) { 328 if (!req)
352 req->complete = loopback_complete; 329 goto fail1;
353 result = usb_ep_queue(ep, req, GFP_ATOMIC); 330
354 if (result) 331 req->complete = loopback_complete;
355 ERROR(cdev, "%s queue req --> %d\n", 332 result = usb_ep_queue(ep, req, GFP_ATOMIC);
356 ep->name, result); 333 if (result) {
357 } else { 334 ERROR(cdev, "%s queue req --> %d\n",
358 usb_ep_disable(ep); 335 ep->name, result);
359 ep->driver_data = NULL; 336 goto fail1;
360 result = -ENOMEM;
361 goto fail0;
362 } 337 }
363 } 338 }
364 339
340 return 0;
341
342fail1:
343 usb_ep_disable(ep);
344
345fail0:
346 return result;
347}
348
349static int
350enable_loopback(struct usb_composite_dev *cdev, struct f_loopback *loop)
351{
352 int result = 0;
353
354 result = enable_endpoint(cdev, loop, loop->in_ep);
355 if (result)
356 return result;
357
358 result = enable_endpoint(cdev, loop, loop->out_ep);
359 if (result)
360 return result;
361
365 DBG(cdev, "%s enabled\n", loop->function.name); 362 DBG(cdev, "%s enabled\n", loop->function.name);
366 return result; 363 return result;
367} 364}
diff --git a/drivers/usb/gadget/function/f_ncm.c b/drivers/usb/gadget/function/f_ncm.c
index 146f48cc65d7..16361b0a8b46 100644
--- a/drivers/usb/gadget/function/f_ncm.c
+++ b/drivers/usb/gadget/function/f_ncm.c
@@ -1461,7 +1461,6 @@ static int ncm_bind(struct usb_configuration *c, struct usb_function *f)
1461 return 0; 1461 return 0;
1462 1462
1463fail: 1463fail:
1464 usb_free_all_descriptors(f);
1465 if (ncm->notify_req) { 1464 if (ncm->notify_req) {
1466 kfree(ncm->notify_req->buf); 1465 kfree(ncm->notify_req->buf);
1467 usb_ep_free_request(ncm->notify, ncm->notify_req); 1466 usb_ep_free_request(ncm->notify, ncm->notify_req);
diff --git a/drivers/usb/gadget/function/f_obex.c b/drivers/usb/gadget/function/f_obex.c
index 5f40080c92cc..a1b79c53499c 100644
--- a/drivers/usb/gadget/function/f_obex.c
+++ b/drivers/usb/gadget/function/f_obex.c
@@ -35,6 +35,7 @@ struct f_obex {
35 struct gserial port; 35 struct gserial port;
36 u8 ctrl_id; 36 u8 ctrl_id;
37 u8 data_id; 37 u8 data_id;
38 u8 cur_alt;
38 u8 port_num; 39 u8 port_num;
39 u8 can_activate; 40 u8 can_activate;
40}; 41};
@@ -235,6 +236,8 @@ static int obex_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
235 } else 236 } else
236 goto fail; 237 goto fail;
237 238
239 obex->cur_alt = alt;
240
238 return 0; 241 return 0;
239 242
240fail: 243fail:
@@ -245,10 +248,7 @@ static int obex_get_alt(struct usb_function *f, unsigned intf)
245{ 248{
246 struct f_obex *obex = func_to_obex(f); 249 struct f_obex *obex = func_to_obex(f);
247 250
248 if (intf == obex->ctrl_id) 251 return obex->cur_alt;
249 return 0;
250
251 return obex->port.in->driver_data ? 1 : 0;
252} 252}
253 253
254static void obex_disable(struct usb_function *f) 254static void obex_disable(struct usb_function *f)
@@ -397,7 +397,6 @@ static int obex_bind(struct usb_configuration *c, struct usb_function *f)
397 return 0; 397 return 0;
398 398
399fail: 399fail:
400 usb_free_all_descriptors(f);
401 /* we might as well release our claims on endpoints */ 400 /* we might as well release our claims on endpoints */
402 if (obex->port.out) 401 if (obex->port.out)
403 obex->port.out->driver_data = NULL; 402 obex->port.out->driver_data = NULL;
diff --git a/drivers/usb/gadget/function/f_phonet.c b/drivers/usb/gadget/function/f_phonet.c
index b9cfc1571d71..1ec8b7ffdccd 100644
--- a/drivers/usb/gadget/function/f_phonet.c
+++ b/drivers/usb/gadget/function/f_phonet.c
@@ -570,8 +570,8 @@ static int pn_bind(struct usb_configuration *c, struct usb_function *f)
570err_req: 570err_req:
571 for (i = 0; i < phonet_rxq_size && fp->out_reqv[i]; i++) 571 for (i = 0; i < phonet_rxq_size && fp->out_reqv[i]; i++)
572 usb_ep_free_request(fp->out_ep, fp->out_reqv[i]); 572 usb_ep_free_request(fp->out_ep, fp->out_reqv[i]);
573err:
574 usb_free_all_descriptors(f); 573 usb_free_all_descriptors(f);
574err:
575 if (fp->out_ep) 575 if (fp->out_ep)
576 fp->out_ep->driver_data = NULL; 576 fp->out_ep->driver_data = NULL;
577 if (fp->in_ep) 577 if (fp->in_ep)
diff --git a/drivers/usb/gadget/function/f_rndis.c b/drivers/usb/gadget/function/f_rndis.c
index ddb09dc6d1f2..f13fc6a58565 100644
--- a/drivers/usb/gadget/function/f_rndis.c
+++ b/drivers/usb/gadget/function/f_rndis.c
@@ -802,8 +802,10 @@ rndis_bind(struct usb_configuration *c, struct usb_function *f)
802 802
803 if (rndis->manufacturer && rndis->vendorID && 803 if (rndis->manufacturer && rndis->vendorID &&
804 rndis_set_param_vendor(rndis->config, rndis->vendorID, 804 rndis_set_param_vendor(rndis->config, rndis->vendorID,
805 rndis->manufacturer)) 805 rndis->manufacturer)) {
806 goto fail; 806 status = -EINVAL;
807 goto fail_free_descs;
808 }
807 809
808 /* NOTE: all that is done without knowing or caring about 810 /* NOTE: all that is done without knowing or caring about
809 * the network link ... which is unavailable to this code 811 * the network link ... which is unavailable to this code
@@ -817,10 +819,11 @@ rndis_bind(struct usb_configuration *c, struct usb_function *f)
817 rndis->notify->name); 819 rndis->notify->name);
818 return 0; 820 return 0;
819 821
822fail_free_descs:
823 usb_free_all_descriptors(f);
820fail: 824fail:
821 kfree(f->os_desc_table); 825 kfree(f->os_desc_table);
822 f->os_desc_n = 0; 826 f->os_desc_n = 0;
823 usb_free_all_descriptors(f);
824 827
825 if (rndis->notify_req) { 828 if (rndis->notify_req) {
826 kfree(rndis->notify_req->buf); 829 kfree(rndis->notify_req->buf);
diff --git a/drivers/usb/gadget/function/f_subset.c b/drivers/usb/gadget/function/f_subset.c
index 1ea8baf33333..e3dfa675ff06 100644
--- a/drivers/usb/gadget/function/f_subset.c
+++ b/drivers/usb/gadget/function/f_subset.c
@@ -380,7 +380,6 @@ geth_bind(struct usb_configuration *c, struct usb_function *f)
380 return 0; 380 return 0;
381 381
382fail: 382fail:
383 usb_free_all_descriptors(f);
384 /* we might as well release our claims on endpoints */ 383 /* we might as well release our claims on endpoints */
385 if (geth->port.out_ep) 384 if (geth->port.out_ep)
386 geth->port.out_ep->driver_data = NULL; 385 geth->port.out_ep->driver_data = NULL;
diff --git a/drivers/usb/gadget/function/f_uac2.c b/drivers/usb/gadget/function/f_uac2.c
index a5a27a504d67..33e16658e5cf 100644
--- a/drivers/usb/gadget/function/f_uac2.c
+++ b/drivers/usb/gadget/function/f_uac2.c
@@ -512,6 +512,11 @@ static int snd_uac2_remove(struct platform_device *pdev)
512 return 0; 512 return 0;
513} 513}
514 514
515static void snd_uac2_release(struct device *dev)
516{
517 dev_dbg(dev, "releasing '%s'\n", dev_name(dev));
518}
519
515static int alsa_uac2_init(struct audio_dev *agdev) 520static int alsa_uac2_init(struct audio_dev *agdev)
516{ 521{
517 struct snd_uac2_chip *uac2 = &agdev->uac2; 522 struct snd_uac2_chip *uac2 = &agdev->uac2;
@@ -523,6 +528,7 @@ static int alsa_uac2_init(struct audio_dev *agdev)
523 528
524 uac2->pdev.id = 0; 529 uac2->pdev.id = 0;
525 uac2->pdev.name = uac2_name; 530 uac2->pdev.name = uac2_name;
531 uac2->pdev.dev.release = snd_uac2_release;
526 532
527 /* Register snd_uac2 driver */ 533 /* Register snd_uac2 driver */
528 err = platform_driver_register(&uac2->pdrv); 534 err = platform_driver_register(&uac2->pdrv);
@@ -772,6 +778,7 @@ struct usb_endpoint_descriptor fs_epout_desc = {
772 778
773 .bEndpointAddress = USB_DIR_OUT, 779 .bEndpointAddress = USB_DIR_OUT,
774 .bmAttributes = USB_ENDPOINT_XFER_ISOC | USB_ENDPOINT_SYNC_ASYNC, 780 .bmAttributes = USB_ENDPOINT_XFER_ISOC | USB_ENDPOINT_SYNC_ASYNC,
781 .wMaxPacketSize = cpu_to_le16(1023),
775 .bInterval = 1, 782 .bInterval = 1,
776}; 783};
777 784
@@ -780,6 +787,7 @@ struct usb_endpoint_descriptor hs_epout_desc = {
780 .bDescriptorType = USB_DT_ENDPOINT, 787 .bDescriptorType = USB_DT_ENDPOINT,
781 788
782 .bmAttributes = USB_ENDPOINT_XFER_ISOC | USB_ENDPOINT_SYNC_ASYNC, 789 .bmAttributes = USB_ENDPOINT_XFER_ISOC | USB_ENDPOINT_SYNC_ASYNC,
790 .wMaxPacketSize = cpu_to_le16(1024),
783 .bInterval = 4, 791 .bInterval = 4,
784}; 792};
785 793
@@ -847,6 +855,7 @@ struct usb_endpoint_descriptor fs_epin_desc = {
847 855
848 .bEndpointAddress = USB_DIR_IN, 856 .bEndpointAddress = USB_DIR_IN,
849 .bmAttributes = USB_ENDPOINT_XFER_ISOC | USB_ENDPOINT_SYNC_ASYNC, 857 .bmAttributes = USB_ENDPOINT_XFER_ISOC | USB_ENDPOINT_SYNC_ASYNC,
858 .wMaxPacketSize = cpu_to_le16(1023),
850 .bInterval = 1, 859 .bInterval = 1,
851}; 860};
852 861
@@ -855,6 +864,7 @@ struct usb_endpoint_descriptor hs_epin_desc = {
855 .bDescriptorType = USB_DT_ENDPOINT, 864 .bDescriptorType = USB_DT_ENDPOINT,
856 865
857 .bmAttributes = USB_ENDPOINT_XFER_ISOC | USB_ENDPOINT_SYNC_ASYNC, 866 .bmAttributes = USB_ENDPOINT_XFER_ISOC | USB_ENDPOINT_SYNC_ASYNC,
867 .wMaxPacketSize = cpu_to_le16(1024),
858 .bInterval = 4, 868 .bInterval = 4,
859}; 869};
860 870
@@ -947,6 +957,9 @@ free_ep(struct uac2_rtd_params *prm, struct usb_ep *ep)
947 struct snd_uac2_chip *uac2 = prm->uac2; 957 struct snd_uac2_chip *uac2 = prm->uac2;
948 int i; 958 int i;
949 959
960 if (!prm->ep_enabled)
961 return;
962
950 prm->ep_enabled = false; 963 prm->ep_enabled = false;
951 964
952 for (i = 0; i < USB_XFERS; i++) { 965 for (i = 0; i < USB_XFERS; i++) {
@@ -1071,7 +1084,7 @@ afunc_bind(struct usb_configuration *cfg, struct usb_function *fn)
1071 prm->rbuf = kzalloc(prm->max_psize * USB_XFERS, GFP_KERNEL); 1084 prm->rbuf = kzalloc(prm->max_psize * USB_XFERS, GFP_KERNEL);
1072 if (!prm->rbuf) { 1085 if (!prm->rbuf) {
1073 prm->max_psize = 0; 1086 prm->max_psize = 0;
1074 goto err; 1087 goto err_free_descs;
1075 } 1088 }
1076 1089
1077 prm = &agdev->uac2.p_prm; 1090 prm = &agdev->uac2.p_prm;
@@ -1079,17 +1092,19 @@ afunc_bind(struct usb_configuration *cfg, struct usb_function *fn)
1079 prm->rbuf = kzalloc(prm->max_psize * USB_XFERS, GFP_KERNEL); 1092 prm->rbuf = kzalloc(prm->max_psize * USB_XFERS, GFP_KERNEL);
1080 if (!prm->rbuf) { 1093 if (!prm->rbuf) {
1081 prm->max_psize = 0; 1094 prm->max_psize = 0;
1082 goto err; 1095 goto err_free_descs;
1083 } 1096 }
1084 1097
1085 ret = alsa_uac2_init(agdev); 1098 ret = alsa_uac2_init(agdev);
1086 if (ret) 1099 if (ret)
1087 goto err; 1100 goto err_free_descs;
1088 return 0; 1101 return 0;
1102
1103err_free_descs:
1104 usb_free_all_descriptors(fn);
1089err: 1105err:
1090 kfree(agdev->uac2.p_prm.rbuf); 1106 kfree(agdev->uac2.p_prm.rbuf);
1091 kfree(agdev->uac2.c_prm.rbuf); 1107 kfree(agdev->uac2.c_prm.rbuf);
1092 usb_free_all_descriptors(fn);
1093 if (agdev->in_ep) 1108 if (agdev->in_ep)
1094 agdev->in_ep->driver_data = NULL; 1109 agdev->in_ep->driver_data = NULL;
1095 if (agdev->out_ep) 1110 if (agdev->out_ep)
diff --git a/drivers/usb/gadget/function/f_uvc.c b/drivers/usb/gadget/function/f_uvc.c
index e126439e4b65..945b3bd2ca98 100644
--- a/drivers/usb/gadget/function/f_uvc.c
+++ b/drivers/usb/gadget/function/f_uvc.c
@@ -279,27 +279,41 @@ uvc_function_get_alt(struct usb_function *f, unsigned interface)
279 else if (interface != uvc->streaming_intf) 279 else if (interface != uvc->streaming_intf)
280 return -EINVAL; 280 return -EINVAL;
281 else 281 else
282 return uvc->state == UVC_STATE_STREAMING ? 1 : 0; 282 return uvc->video.ep->driver_data ? 1 : 0;
283} 283}
284 284
285static int 285static int
286uvc_function_set_alt(struct usb_function *f, unsigned interface, unsigned alt) 286uvc_function_set_alt(struct usb_function *f, unsigned interface, unsigned alt)
287{ 287{
288 struct uvc_device *uvc = to_uvc(f); 288 struct uvc_device *uvc = to_uvc(f);
289 struct usb_composite_dev *cdev = f->config->cdev;
289 struct v4l2_event v4l2_event; 290 struct v4l2_event v4l2_event;
290 struct uvc_event *uvc_event = (void *)&v4l2_event.u.data; 291 struct uvc_event *uvc_event = (void *)&v4l2_event.u.data;
291 int ret; 292 int ret;
292 293
293 INFO(f->config->cdev, "uvc_function_set_alt(%u, %u)\n", interface, alt); 294 INFO(cdev, "uvc_function_set_alt(%u, %u)\n", interface, alt);
294 295
295 if (interface == uvc->control_intf) { 296 if (interface == uvc->control_intf) {
296 if (alt) 297 if (alt)
297 return -EINVAL; 298 return -EINVAL;
298 299
300 if (uvc->control_ep->driver_data) {
301 INFO(cdev, "reset UVC Control\n");
302 usb_ep_disable(uvc->control_ep);
303 uvc->control_ep->driver_data = NULL;
304 }
305
306 if (!uvc->control_ep->desc)
307 if (config_ep_by_speed(cdev->gadget, f, uvc->control_ep))
308 return -EINVAL;
309
310 usb_ep_enable(uvc->control_ep);
311 uvc->control_ep->driver_data = uvc;
312
299 if (uvc->state == UVC_STATE_DISCONNECTED) { 313 if (uvc->state == UVC_STATE_DISCONNECTED) {
300 memset(&v4l2_event, 0, sizeof(v4l2_event)); 314 memset(&v4l2_event, 0, sizeof(v4l2_event));
301 v4l2_event.type = UVC_EVENT_CONNECT; 315 v4l2_event.type = UVC_EVENT_CONNECT;
302 uvc_event->speed = f->config->cdev->gadget->speed; 316 uvc_event->speed = cdev->gadget->speed;
303 v4l2_event_queue(uvc->vdev, &v4l2_event); 317 v4l2_event_queue(uvc->vdev, &v4l2_event);
304 318
305 uvc->state = UVC_STATE_CONNECTED; 319 uvc->state = UVC_STATE_CONNECTED;
@@ -321,8 +335,10 @@ uvc_function_set_alt(struct usb_function *f, unsigned interface, unsigned alt)
321 if (uvc->state != UVC_STATE_STREAMING) 335 if (uvc->state != UVC_STATE_STREAMING)
322 return 0; 336 return 0;
323 337
324 if (uvc->video.ep) 338 if (uvc->video.ep) {
325 usb_ep_disable(uvc->video.ep); 339 usb_ep_disable(uvc->video.ep);
340 uvc->video.ep->driver_data = NULL;
341 }
326 342
327 memset(&v4l2_event, 0, sizeof(v4l2_event)); 343 memset(&v4l2_event, 0, sizeof(v4l2_event));
328 v4l2_event.type = UVC_EVENT_STREAMOFF; 344 v4l2_event.type = UVC_EVENT_STREAMOFF;
@@ -335,14 +351,22 @@ uvc_function_set_alt(struct usb_function *f, unsigned interface, unsigned alt)
335 if (uvc->state != UVC_STATE_CONNECTED) 351 if (uvc->state != UVC_STATE_CONNECTED)
336 return 0; 352 return 0;
337 353
338 if (uvc->video.ep) { 354 if (!uvc->video.ep)
339 ret = config_ep_by_speed(f->config->cdev->gadget, 355 return -EINVAL;
340 &(uvc->func), uvc->video.ep); 356
341 if (ret) 357 if (uvc->video.ep->driver_data) {
342 return ret; 358 INFO(cdev, "reset UVC\n");
343 usb_ep_enable(uvc->video.ep); 359 usb_ep_disable(uvc->video.ep);
360 uvc->video.ep->driver_data = NULL;
344 } 361 }
345 362
363 ret = config_ep_by_speed(f->config->cdev->gadget,
364 &(uvc->func), uvc->video.ep);
365 if (ret)
366 return ret;
367 usb_ep_enable(uvc->video.ep);
368 uvc->video.ep->driver_data = uvc;
369
346 memset(&v4l2_event, 0, sizeof(v4l2_event)); 370 memset(&v4l2_event, 0, sizeof(v4l2_event));
347 v4l2_event.type = UVC_EVENT_STREAMON; 371 v4l2_event.type = UVC_EVENT_STREAMON;
348 v4l2_event_queue(uvc->vdev, &v4l2_event); 372 v4l2_event_queue(uvc->vdev, &v4l2_event);
@@ -366,6 +390,16 @@ uvc_function_disable(struct usb_function *f)
366 v4l2_event_queue(uvc->vdev, &v4l2_event); 390 v4l2_event_queue(uvc->vdev, &v4l2_event);
367 391
368 uvc->state = UVC_STATE_DISCONNECTED; 392 uvc->state = UVC_STATE_DISCONNECTED;
393
394 if (uvc->video.ep->driver_data) {
395 usb_ep_disable(uvc->video.ep);
396 uvc->video.ep->driver_data = NULL;
397 }
398
399 if (uvc->control_ep->driver_data) {
400 usb_ep_disable(uvc->control_ep);
401 uvc->control_ep->driver_data = NULL;
402 }
369} 403}
370 404
371/* -------------------------------------------------------------------------- 405/* --------------------------------------------------------------------------
diff --git a/drivers/usb/gadget/function/uvc_video.c b/drivers/usb/gadget/function/uvc_video.c
index c3e1f27dbbef..9cb86bc1a9a5 100644
--- a/drivers/usb/gadget/function/uvc_video.c
+++ b/drivers/usb/gadget/function/uvc_video.c
@@ -352,7 +352,8 @@ int uvcg_video_enable(struct uvc_video *video, int enable)
352 352
353 if (!enable) { 353 if (!enable) {
354 for (i = 0; i < UVC_NUM_REQUESTS; ++i) 354 for (i = 0; i < UVC_NUM_REQUESTS; ++i)
355 usb_ep_dequeue(video->ep, video->req[i]); 355 if (video->req[i])
356 usb_ep_dequeue(video->ep, video->req[i]);
356 357
357 uvc_video_free_requests(video); 358 uvc_video_free_requests(video);
358 uvcg_queue_enable(&video->queue, 0); 359 uvcg_queue_enable(&video->queue, 0);
diff --git a/drivers/usb/gadget/udc/Kconfig b/drivers/usb/gadget/udc/Kconfig
index 3ea287b0e448..217365d35a25 100644
--- a/drivers/usb/gadget/udc/Kconfig
+++ b/drivers/usb/gadget/udc/Kconfig
@@ -357,6 +357,7 @@ config USB_EG20T
357 357
358config USB_GADGET_XILINX 358config USB_GADGET_XILINX
359 tristate "Xilinx USB Driver" 359 tristate "Xilinx USB Driver"
360 depends on HAS_DMA
360 depends on OF || COMPILE_TEST 361 depends on OF || COMPILE_TEST
361 help 362 help
362 USB peripheral controller driver for Xilinx USB2 device. 363 USB peripheral controller driver for Xilinx USB2 device.
diff --git a/drivers/usb/gadget/udc/udc-core.c b/drivers/usb/gadget/udc/udc-core.c
index f107bb60a5ab..f2054659f25b 100644
--- a/drivers/usb/gadget/udc/udc-core.c
+++ b/drivers/usb/gadget/udc/udc-core.c
@@ -507,6 +507,11 @@ static ssize_t usb_udc_softconn_store(struct device *dev,
507{ 507{
508 struct usb_udc *udc = container_of(dev, struct usb_udc, dev); 508 struct usb_udc *udc = container_of(dev, struct usb_udc, dev);
509 509
510 if (!udc->driver) {
511 dev_err(dev, "soft-connect without a gadget driver\n");
512 return -EOPNOTSUPP;
513 }
514
510 if (sysfs_streq(buf, "connect")) { 515 if (sysfs_streq(buf, "connect")) {
511 usb_gadget_udc_start(udc->gadget, udc->driver); 516 usb_gadget_udc_start(udc->gadget, udc->driver);
512 usb_gadget_connect(udc->gadget); 517 usb_gadget_connect(udc->gadget);
diff --git a/drivers/usb/musb/musb_cppi41.c b/drivers/usb/musb/musb_cppi41.c
index acdfb3e68a90..5a9b977fbc19 100644
--- a/drivers/usb/musb/musb_cppi41.c
+++ b/drivers/usb/musb/musb_cppi41.c
@@ -209,7 +209,8 @@ static enum hrtimer_restart cppi41_recheck_tx_req(struct hrtimer *timer)
209 } 209 }
210 } 210 }
211 211
212 if (!list_empty(&controller->early_tx_list)) { 212 if (!list_empty(&controller->early_tx_list) &&
213 !hrtimer_is_queued(&controller->early_tx)) {
213 ret = HRTIMER_RESTART; 214 ret = HRTIMER_RESTART;
214 hrtimer_forward_now(&controller->early_tx, 215 hrtimer_forward_now(&controller->early_tx,
215 ktime_set(0, 20 * NSEC_PER_USEC)); 216 ktime_set(0, 20 * NSEC_PER_USEC));
diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
index 154bcf1b5dfa..48bc09e7b83b 100644
--- a/drivers/usb/musb/musb_dsps.c
+++ b/drivers/usb/musb/musb_dsps.c
@@ -868,9 +868,15 @@ static int dsps_suspend(struct device *dev)
868 struct dsps_glue *glue = dev_get_drvdata(dev); 868 struct dsps_glue *glue = dev_get_drvdata(dev);
869 const struct dsps_musb_wrapper *wrp = glue->wrp; 869 const struct dsps_musb_wrapper *wrp = glue->wrp;
870 struct musb *musb = platform_get_drvdata(glue->musb); 870 struct musb *musb = platform_get_drvdata(glue->musb);
871 void __iomem *mbase = musb->ctrl_base; 871 void __iomem *mbase;
872 872
873 del_timer_sync(&glue->timer); 873 del_timer_sync(&glue->timer);
874
875 if (!musb)
876 /* This can happen if the musb device is in -EPROBE_DEFER */
877 return 0;
878
879 mbase = musb->ctrl_base;
874 glue->context.control = dsps_readl(mbase, wrp->control); 880 glue->context.control = dsps_readl(mbase, wrp->control);
875 glue->context.epintr = dsps_readl(mbase, wrp->epintr_set); 881 glue->context.epintr = dsps_readl(mbase, wrp->epintr_set);
876 glue->context.coreintr = dsps_readl(mbase, wrp->coreintr_set); 882 glue->context.coreintr = dsps_readl(mbase, wrp->coreintr_set);
@@ -887,8 +893,12 @@ static int dsps_resume(struct device *dev)
887 struct dsps_glue *glue = dev_get_drvdata(dev); 893 struct dsps_glue *glue = dev_get_drvdata(dev);
888 const struct dsps_musb_wrapper *wrp = glue->wrp; 894 const struct dsps_musb_wrapper *wrp = glue->wrp;
889 struct musb *musb = platform_get_drvdata(glue->musb); 895 struct musb *musb = platform_get_drvdata(glue->musb);
890 void __iomem *mbase = musb->ctrl_base; 896 void __iomem *mbase;
897
898 if (!musb)
899 return 0;
891 900
901 mbase = musb->ctrl_base;
892 dsps_writel(mbase, wrp->control, glue->context.control); 902 dsps_writel(mbase, wrp->control, glue->context.control);
893 dsps_writel(mbase, wrp->epintr_set, glue->context.epintr); 903 dsps_writel(mbase, wrp->epintr_set, glue->context.epintr);
894 dsps_writel(mbase, wrp->coreintr_set, glue->context.coreintr); 904 dsps_writel(mbase, wrp->coreintr_set, glue->context.coreintr);
@@ -896,7 +906,9 @@ static int dsps_resume(struct device *dev)
896 dsps_writel(mbase, wrp->mode, glue->context.mode); 906 dsps_writel(mbase, wrp->mode, glue->context.mode);
897 dsps_writel(mbase, wrp->tx_mode, glue->context.tx_mode); 907 dsps_writel(mbase, wrp->tx_mode, glue->context.tx_mode);
898 dsps_writel(mbase, wrp->rx_mode, glue->context.rx_mode); 908 dsps_writel(mbase, wrp->rx_mode, glue->context.rx_mode);
899 setup_timer(&glue->timer, otg_timer, (unsigned long) musb); 909 if (musb->xceiv->state == OTG_STATE_B_IDLE &&
910 musb->port_mode == MUSB_PORT_MODE_DUAL_ROLE)
911 mod_timer(&glue->timer, jiffies + wrp->poll_seconds * HZ);
900 912
901 return 0; 913 return 0;
902} 914}
diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
index eca1747ca8c7..cfd009dc4018 100644
--- a/drivers/usb/serial/cp210x.c
+++ b/drivers/usb/serial/cp210x.c
@@ -155,6 +155,7 @@ static const struct usb_device_id id_table[] = {
155 { USB_DEVICE(0x18EF, 0xE00F) }, /* ELV USB-I2C-Interface */ 155 { USB_DEVICE(0x18EF, 0xE00F) }, /* ELV USB-I2C-Interface */
156 { USB_DEVICE(0x1ADB, 0x0001) }, /* Schweitzer Engineering C662 Cable */ 156 { USB_DEVICE(0x1ADB, 0x0001) }, /* Schweitzer Engineering C662 Cable */
157 { USB_DEVICE(0x1B1C, 0x1C00) }, /* Corsair USB Dongle */ 157 { USB_DEVICE(0x1B1C, 0x1C00) }, /* Corsair USB Dongle */
158 { USB_DEVICE(0x1BA4, 0x0002) }, /* Silicon Labs 358x factory default */
158 { USB_DEVICE(0x1BE3, 0x07A6) }, /* WAGO 750-923 USB Service Cable */ 159 { USB_DEVICE(0x1BE3, 0x07A6) }, /* WAGO 750-923 USB Service Cable */
159 { USB_DEVICE(0x1D6F, 0x0010) }, /* Seluxit ApS RF Dongle */ 160 { USB_DEVICE(0x1D6F, 0x0010) }, /* Seluxit ApS RF Dongle */
160 { USB_DEVICE(0x1E29, 0x0102) }, /* Festo CPX-USB */ 161 { USB_DEVICE(0x1E29, 0x0102) }, /* Festo CPX-USB */
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index dc72b924c399..0dad8ce5a609 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -140,6 +140,7 @@ static struct ftdi_sio_quirk ftdi_8u2232c_quirk = {
140 * /sys/bus/usb-serial/drivers/ftdi_sio/new_id and send a patch or report. 140 * /sys/bus/usb-serial/drivers/ftdi_sio/new_id and send a patch or report.
141 */ 141 */
142static const struct usb_device_id id_table_combined[] = { 142static const struct usb_device_id id_table_combined[] = {
143 { USB_DEVICE(FTDI_VID, FTDI_BRICK_PID) },
143 { USB_DEVICE(FTDI_VID, FTDI_ZEITCONTROL_TAGTRACE_MIFARE_PID) }, 144 { USB_DEVICE(FTDI_VID, FTDI_ZEITCONTROL_TAGTRACE_MIFARE_PID) },
144 { USB_DEVICE(FTDI_VID, FTDI_CTI_MINI_PID) }, 145 { USB_DEVICE(FTDI_VID, FTDI_CTI_MINI_PID) },
145 { USB_DEVICE(FTDI_VID, FTDI_CTI_NANO_PID) }, 146 { USB_DEVICE(FTDI_VID, FTDI_CTI_NANO_PID) },
@@ -661,6 +662,8 @@ static const struct usb_device_id id_table_combined[] = {
661 { USB_DEVICE(FTDI_VID, XSENS_CONVERTER_5_PID) }, 662 { USB_DEVICE(FTDI_VID, XSENS_CONVERTER_5_PID) },
662 { USB_DEVICE(FTDI_VID, XSENS_CONVERTER_6_PID) }, 663 { USB_DEVICE(FTDI_VID, XSENS_CONVERTER_6_PID) },
663 { USB_DEVICE(FTDI_VID, XSENS_CONVERTER_7_PID) }, 664 { USB_DEVICE(FTDI_VID, XSENS_CONVERTER_7_PID) },
665 { USB_DEVICE(XSENS_VID, XSENS_AWINDA_DONGLE_PID) },
666 { USB_DEVICE(XSENS_VID, XSENS_AWINDA_STATION_PID) },
664 { USB_DEVICE(XSENS_VID, XSENS_CONVERTER_PID) }, 667 { USB_DEVICE(XSENS_VID, XSENS_CONVERTER_PID) },
665 { USB_DEVICE(XSENS_VID, XSENS_MTW_PID) }, 668 { USB_DEVICE(XSENS_VID, XSENS_MTW_PID) },
666 { USB_DEVICE(FTDI_VID, FTDI_OMNI1509) }, 669 { USB_DEVICE(FTDI_VID, FTDI_OMNI1509) },
diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h
index 5937b2d242f2..6786b705ccf6 100644
--- a/drivers/usb/serial/ftdi_sio_ids.h
+++ b/drivers/usb/serial/ftdi_sio_ids.h
@@ -30,6 +30,12 @@
30 30
31/*** third-party PIDs (using FTDI_VID) ***/ 31/*** third-party PIDs (using FTDI_VID) ***/
32 32
33/*
34 * Certain versions of the official Windows FTDI driver reprogrammed
35 * counterfeit FTDI devices to PID 0. Support these devices anyway.
36 */
37#define FTDI_BRICK_PID 0x0000
38
33#define FTDI_LUMEL_PD12_PID 0x6002 39#define FTDI_LUMEL_PD12_PID 0x6002
34 40
35/* 41/*
@@ -143,8 +149,12 @@
143 * Xsens Technologies BV products (http://www.xsens.com). 149 * Xsens Technologies BV products (http://www.xsens.com).
144 */ 150 */
145#define XSENS_VID 0x2639 151#define XSENS_VID 0x2639
146#define XSENS_CONVERTER_PID 0xD00D /* Xsens USB-serial converter */ 152#define XSENS_AWINDA_STATION_PID 0x0101
153#define XSENS_AWINDA_DONGLE_PID 0x0102
147#define XSENS_MTW_PID 0x0200 /* Xsens MTw */ 154#define XSENS_MTW_PID 0x0200 /* Xsens MTw */
155#define XSENS_CONVERTER_PID 0xD00D /* Xsens USB-serial converter */
156
157/* Xsens devices using FTDI VID */
148#define XSENS_CONVERTER_0_PID 0xD388 /* Xsens USB converter */ 158#define XSENS_CONVERTER_0_PID 0xD388 /* Xsens USB converter */
149#define XSENS_CONVERTER_1_PID 0xD389 /* Xsens Wireless Receiver */ 159#define XSENS_CONVERTER_1_PID 0xD389 /* Xsens Wireless Receiver */
150#define XSENS_CONVERTER_2_PID 0xD38A 160#define XSENS_CONVERTER_2_PID 0xD38A
diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c
index 078f9ed419c8..3d2bd65df0fc 100644
--- a/drivers/usb/serial/kobil_sct.c
+++ b/drivers/usb/serial/kobil_sct.c
@@ -414,8 +414,6 @@ static int kobil_tiocmset(struct tty_struct *tty,
414 int result; 414 int result;
415 int dtr = 0; 415 int dtr = 0;
416 int rts = 0; 416 int rts = 0;
417 unsigned char *transfer_buffer;
418 int transfer_buffer_length = 8;
419 417
420 /* FIXME: locking ? */ 418 /* FIXME: locking ? */
421 priv = usb_get_serial_port_data(port); 419 priv = usb_get_serial_port_data(port);
@@ -425,11 +423,6 @@ static int kobil_tiocmset(struct tty_struct *tty,
425 return -EINVAL; 423 return -EINVAL;
426 } 424 }
427 425
428 /* allocate memory for transfer buffer */
429 transfer_buffer = kzalloc(transfer_buffer_length, GFP_KERNEL);
430 if (!transfer_buffer)
431 return -ENOMEM;
432
433 if (set & TIOCM_RTS) 426 if (set & TIOCM_RTS)
434 rts = 1; 427 rts = 1;
435 if (set & TIOCM_DTR) 428 if (set & TIOCM_DTR)
@@ -469,7 +462,6 @@ static int kobil_tiocmset(struct tty_struct *tty,
469 KOBIL_TIMEOUT); 462 KOBIL_TIMEOUT);
470 } 463 }
471 dev_dbg(dev, "%s - Send set_status_line URB returns: %i\n", __func__, result); 464 dev_dbg(dev, "%s - Send set_status_line URB returns: %i\n", __func__, result);
472 kfree(transfer_buffer);
473 return (result < 0) ? result : 0; 465 return (result < 0) ? result : 0;
474} 466}
475 467
@@ -530,8 +522,6 @@ static int kobil_ioctl(struct tty_struct *tty,
530{ 522{
531 struct usb_serial_port *port = tty->driver_data; 523 struct usb_serial_port *port = tty->driver_data;
532 struct kobil_private *priv = usb_get_serial_port_data(port); 524 struct kobil_private *priv = usb_get_serial_port_data(port);
533 unsigned char *transfer_buffer;
534 int transfer_buffer_length = 8;
535 int result; 525 int result;
536 526
537 if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID || 527 if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID ||
@@ -541,10 +531,6 @@ static int kobil_ioctl(struct tty_struct *tty,
541 531
542 switch (cmd) { 532 switch (cmd) {
543 case TCFLSH: 533 case TCFLSH:
544 transfer_buffer = kmalloc(transfer_buffer_length, GFP_KERNEL);
545 if (!transfer_buffer)
546 return -ENOBUFS;
547
548 result = usb_control_msg(port->serial->dev, 534 result = usb_control_msg(port->serial->dev,
549 usb_sndctrlpipe(port->serial->dev, 0), 535 usb_sndctrlpipe(port->serial->dev, 0),
550 SUSBCRequest_Misc, 536 SUSBCRequest_Misc,
@@ -559,7 +545,6 @@ static int kobil_ioctl(struct tty_struct *tty,
559 dev_dbg(&port->dev, 545 dev_dbg(&port->dev,
560 "%s - Send reset_all_queues (FLUSH) URB returns: %i\n", 546 "%s - Send reset_all_queues (FLUSH) URB returns: %i\n",
561 __func__, result); 547 __func__, result);
562 kfree(transfer_buffer);
563 return (result < 0) ? -EIO: 0; 548 return (result < 0) ? -EIO: 0;
564 default: 549 default:
565 return -ENOIOCTLCMD; 550 return -ENOIOCTLCMD;
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index d1a3f6044c8a..7a4c21b4f676 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -269,6 +269,7 @@ static void option_instat_callback(struct urb *urb);
269#define TELIT_PRODUCT_DE910_DUAL 0x1010 269#define TELIT_PRODUCT_DE910_DUAL 0x1010
270#define TELIT_PRODUCT_UE910_V2 0x1012 270#define TELIT_PRODUCT_UE910_V2 0x1012
271#define TELIT_PRODUCT_LE920 0x1200 271#define TELIT_PRODUCT_LE920 0x1200
272#define TELIT_PRODUCT_LE910 0x1201
272 273
273/* ZTE PRODUCTS */ 274/* ZTE PRODUCTS */
274#define ZTE_VENDOR_ID 0x19d2 275#define ZTE_VENDOR_ID 0x19d2
@@ -362,6 +363,7 @@ static void option_instat_callback(struct urb *urb);
362 363
363/* Haier products */ 364/* Haier products */
364#define HAIER_VENDOR_ID 0x201e 365#define HAIER_VENDOR_ID 0x201e
366#define HAIER_PRODUCT_CE81B 0x10f8
365#define HAIER_PRODUCT_CE100 0x2009 367#define HAIER_PRODUCT_CE100 0x2009
366 368
367/* Cinterion (formerly Siemens) products */ 369/* Cinterion (formerly Siemens) products */
@@ -589,6 +591,11 @@ static const struct option_blacklist_info zte_1255_blacklist = {
589 .reserved = BIT(3) | BIT(4), 591 .reserved = BIT(3) | BIT(4),
590}; 592};
591 593
594static const struct option_blacklist_info telit_le910_blacklist = {
595 .sendsetup = BIT(0),
596 .reserved = BIT(1) | BIT(2),
597};
598
592static const struct option_blacklist_info telit_le920_blacklist = { 599static const struct option_blacklist_info telit_le920_blacklist = {
593 .sendsetup = BIT(0), 600 .sendsetup = BIT(0),
594 .reserved = BIT(1) | BIT(5), 601 .reserved = BIT(1) | BIT(5),
@@ -1138,6 +1145,8 @@ static const struct usb_device_id option_ids[] = {
1138 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_CC864_SINGLE) }, 1145 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_CC864_SINGLE) },
1139 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_DE910_DUAL) }, 1146 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_DE910_DUAL) },
1140 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_UE910_V2) }, 1147 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_UE910_V2) },
1148 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE910),
1149 .driver_info = (kernel_ulong_t)&telit_le910_blacklist },
1141 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE920), 1150 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE920),
1142 .driver_info = (kernel_ulong_t)&telit_le920_blacklist }, 1151 .driver_info = (kernel_ulong_t)&telit_le920_blacklist },
1143 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_MF622, 0xff, 0xff, 0xff) }, /* ZTE WCDMA products */ 1152 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_MF622, 0xff, 0xff, 0xff) }, /* ZTE WCDMA products */
@@ -1621,6 +1630,7 @@ static const struct usb_device_id option_ids[] = {
1621 { USB_DEVICE(LONGCHEER_VENDOR_ID, ZOOM_PRODUCT_4597) }, 1630 { USB_DEVICE(LONGCHEER_VENDOR_ID, ZOOM_PRODUCT_4597) },
1622 { USB_DEVICE(LONGCHEER_VENDOR_ID, IBALL_3_5G_CONNECT) }, 1631 { USB_DEVICE(LONGCHEER_VENDOR_ID, IBALL_3_5G_CONNECT) },
1623 { USB_DEVICE(HAIER_VENDOR_ID, HAIER_PRODUCT_CE100) }, 1632 { USB_DEVICE(HAIER_VENDOR_ID, HAIER_PRODUCT_CE100) },
1633 { USB_DEVICE_AND_INTERFACE_INFO(HAIER_VENDOR_ID, HAIER_PRODUCT_CE81B, 0xff, 0xff, 0xff) },
1624 /* Pirelli */ 1634 /* Pirelli */
1625 { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_C100_1, 0xff) }, 1635 { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_C100_1, 0xff) },
1626 { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_C100_2, 0xff) }, 1636 { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_C100_2, 0xff) },
diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
index 57b1d44acbfe..eb976ee3a02f 100644
--- a/drivers/video/console/fbcon.c
+++ b/drivers/video/console/fbcon.c
@@ -448,8 +448,10 @@ static int __init fb_console_setup(char *this_opt)
448 return 1; 448 return 1;
449 449
450 while ((options = strsep(&this_opt, ",")) != NULL) { 450 while ((options = strsep(&this_opt, ",")) != NULL) {
451 if (!strncmp(options, "font:", 5)) 451 if (!strncmp(options, "font:", 5)) {
452 strlcpy(fontname, options + 5, sizeof(fontname)); 452 strlcpy(fontname, options + 5, sizeof(fontname));
453 continue;
454 }
453 455
454 if (!strncmp(options, "scrollback:", 11)) { 456 if (!strncmp(options, "scrollback:", 11)) {
455 options += 11; 457 options += 11;
@@ -457,13 +459,9 @@ static int __init fb_console_setup(char *this_opt)
457 fbcon_softback_size = simple_strtoul(options, &options, 0); 459 fbcon_softback_size = simple_strtoul(options, &options, 0);
458 if (*options == 'k' || *options == 'K') { 460 if (*options == 'k' || *options == 'K') {
459 fbcon_softback_size *= 1024; 461 fbcon_softback_size *= 1024;
460 options++;
461 } 462 }
462 if (*options != ',') 463 }
463 return 1; 464 continue;
464 options++;
465 } else
466 return 1;
467 } 465 }
468 466
469 if (!strncmp(options, "map:", 4)) { 467 if (!strncmp(options, "map:", 4)) {
@@ -478,8 +476,7 @@ static int __init fb_console_setup(char *this_opt)
478 476
479 fbcon_map_override(); 477 fbcon_map_override();
480 } 478 }
481 479 continue;
482 return 1;
483 } 480 }
484 481
485 if (!strncmp(options, "vc:", 3)) { 482 if (!strncmp(options, "vc:", 3)) {
@@ -491,7 +488,8 @@ static int __init fb_console_setup(char *this_opt)
491 if (*options++ == '-') 488 if (*options++ == '-')
492 last_fb_vc = simple_strtoul(options, &options, 10) - 1; 489 last_fb_vc = simple_strtoul(options, &options, 10) - 1;
493 fbcon_is_default = 0; 490 fbcon_is_default = 0;
494 } 491 continue;
492 }
495 493
496 if (!strncmp(options, "rotate:", 7)) { 494 if (!strncmp(options, "rotate:", 7)) {
497 options += 7; 495 options += 7;
@@ -499,6 +497,7 @@ static int __init fb_console_setup(char *this_opt)
499 initial_rotation = simple_strtoul(options, &options, 0); 497 initial_rotation = simple_strtoul(options, &options, 0);
500 if (initial_rotation > 3) 498 if (initial_rotation > 3)
501 initial_rotation = 0; 499 initial_rotation = 0;
500 continue;
502 } 501 }
503 } 502 }
504 return 1; 503 return 1;
diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c
index 6e6aa704fe84..517f565b65d7 100644
--- a/drivers/video/console/vgacon.c
+++ b/drivers/video/console/vgacon.c
@@ -56,7 +56,7 @@ static int cursor_size_lastfrom;
56static int cursor_size_lastto; 56static int cursor_size_lastto;
57static u32 vgacon_xres; 57static u32 vgacon_xres;
58static u32 vgacon_yres; 58static u32 vgacon_yres;
59static struct vgastate state; 59static struct vgastate vgastate;
60 60
61#define BLANK 0x0020 61#define BLANK 0x0020
62 62
@@ -400,7 +400,7 @@ static const char *vgacon_startup(void)
400 400
401 vga_video_num_lines = screen_info.orig_video_lines; 401 vga_video_num_lines = screen_info.orig_video_lines;
402 vga_video_num_columns = screen_info.orig_video_cols; 402 vga_video_num_columns = screen_info.orig_video_cols;
403 state.vgabase = NULL; 403 vgastate.vgabase = NULL;
404 404
405 if (screen_info.orig_video_mode == 7) { 405 if (screen_info.orig_video_mode == 7) {
406 /* Monochrome display */ 406 /* Monochrome display */
@@ -851,12 +851,12 @@ static void vga_set_palette(struct vc_data *vc, unsigned char *table)
851{ 851{
852 int i, j; 852 int i, j;
853 853
854 vga_w(state.vgabase, VGA_PEL_MSK, 0xff); 854 vga_w(vgastate.vgabase, VGA_PEL_MSK, 0xff);
855 for (i = j = 0; i < 16; i++) { 855 for (i = j = 0; i < 16; i++) {
856 vga_w(state.vgabase, VGA_PEL_IW, table[i]); 856 vga_w(vgastate.vgabase, VGA_PEL_IW, table[i]);
857 vga_w(state.vgabase, VGA_PEL_D, vc->vc_palette[j++] >> 2); 857 vga_w(vgastate.vgabase, VGA_PEL_D, vc->vc_palette[j++] >> 2);
858 vga_w(state.vgabase, VGA_PEL_D, vc->vc_palette[j++] >> 2); 858 vga_w(vgastate.vgabase, VGA_PEL_D, vc->vc_palette[j++] >> 2);
859 vga_w(state.vgabase, VGA_PEL_D, vc->vc_palette[j++] >> 2); 859 vga_w(vgastate.vgabase, VGA_PEL_D, vc->vc_palette[j++] >> 2);
860 } 860 }
861} 861}
862 862
@@ -1008,7 +1008,7 @@ static int vgacon_blank(struct vc_data *c, int blank, int mode_switch)
1008 switch (blank) { 1008 switch (blank) {
1009 case 0: /* Unblank */ 1009 case 0: /* Unblank */
1010 if (vga_vesa_blanked) { 1010 if (vga_vesa_blanked) {
1011 vga_vesa_unblank(&state); 1011 vga_vesa_unblank(&vgastate);
1012 vga_vesa_blanked = 0; 1012 vga_vesa_blanked = 0;
1013 } 1013 }
1014 if (vga_palette_blanked) { 1014 if (vga_palette_blanked) {
@@ -1022,7 +1022,7 @@ static int vgacon_blank(struct vc_data *c, int blank, int mode_switch)
1022 case 1: /* Normal blanking */ 1022 case 1: /* Normal blanking */
1023 case -1: /* Obsolete */ 1023 case -1: /* Obsolete */
1024 if (!mode_switch && vga_video_type == VIDEO_TYPE_VGAC) { 1024 if (!mode_switch && vga_video_type == VIDEO_TYPE_VGAC) {
1025 vga_pal_blank(&state); 1025 vga_pal_blank(&vgastate);
1026 vga_palette_blanked = 1; 1026 vga_palette_blanked = 1;
1027 return 0; 1027 return 0;
1028 } 1028 }
@@ -1034,7 +1034,7 @@ static int vgacon_blank(struct vc_data *c, int blank, int mode_switch)
1034 return 1; 1034 return 1;
1035 default: /* VESA blanking */ 1035 default: /* VESA blanking */
1036 if (vga_video_type == VIDEO_TYPE_VGAC) { 1036 if (vga_video_type == VIDEO_TYPE_VGAC) {
1037 vga_vesa_blank(&state, blank - 1); 1037 vga_vesa_blank(&vgastate, blank - 1);
1038 vga_vesa_blanked = blank; 1038 vga_vesa_blanked = blank;
1039 } 1039 }
1040 return 0; 1040 return 0;
@@ -1280,7 +1280,7 @@ static int vgacon_font_set(struct vc_data *c, struct console_font *font, unsigne
1280 (charcount != 256 && charcount != 512)) 1280 (charcount != 256 && charcount != 512))
1281 return -EINVAL; 1281 return -EINVAL;
1282 1282
1283 rc = vgacon_do_font_op(&state, font->data, 1, charcount == 512); 1283 rc = vgacon_do_font_op(&vgastate, font->data, 1, charcount == 512);
1284 if (rc) 1284 if (rc)
1285 return rc; 1285 return rc;
1286 1286
@@ -1299,7 +1299,7 @@ static int vgacon_font_get(struct vc_data *c, struct console_font *font)
1299 font->charcount = vga_512_chars ? 512 : 256; 1299 font->charcount = vga_512_chars ? 512 : 256;
1300 if (!font->data) 1300 if (!font->data)
1301 return 0; 1301 return 0;
1302 return vgacon_do_font_op(&state, font->data, 0, vga_512_chars); 1302 return vgacon_do_font_op(&vgastate, font->data, 0, vga_512_chars);
1303} 1303}
1304 1304
1305#else 1305#else
diff --git a/drivers/video/fbdev/atmel_lcdfb.c b/drivers/video/fbdev/atmel_lcdfb.c
index 3bf403150a2d..9ec81d46fc57 100644
--- a/drivers/video/fbdev/atmel_lcdfb.c
+++ b/drivers/video/fbdev/atmel_lcdfb.c
@@ -27,7 +27,6 @@
27#include <linux/regulator/consumer.h> 27#include <linux/regulator/consumer.h>
28#include <video/videomode.h> 28#include <video/videomode.h>
29 29
30#include <mach/cpu.h>
31#include <asm/gpio.h> 30#include <asm/gpio.h>
32 31
33#include <video/atmel_lcdc.h> 32#include <video/atmel_lcdc.h>
diff --git a/drivers/video/fbdev/omap2/displays-new/connector-analog-tv.c b/drivers/video/fbdev/omap2/displays-new/connector-analog-tv.c
index 5ee3b5505f7f..91921665b98b 100644
--- a/drivers/video/fbdev/omap2/displays-new/connector-analog-tv.c
+++ b/drivers/video/fbdev/omap2/displays-new/connector-analog-tv.c
@@ -301,6 +301,8 @@ static const struct of_device_id tvc_of_match[] = {
301 {}, 301 {},
302}; 302};
303 303
304MODULE_DEVICE_TABLE(of, tvc_of_match);
305
304static struct platform_driver tvc_connector_driver = { 306static struct platform_driver tvc_connector_driver = {
305 .probe = tvc_probe, 307 .probe = tvc_probe,
306 .remove = __exit_p(tvc_remove), 308 .remove = __exit_p(tvc_remove),
@@ -308,6 +310,7 @@ static struct platform_driver tvc_connector_driver = {
308 .name = "connector-analog-tv", 310 .name = "connector-analog-tv",
309 .owner = THIS_MODULE, 311 .owner = THIS_MODULE,
310 .of_match_table = tvc_of_match, 312 .of_match_table = tvc_of_match,
313 .suppress_bind_attrs = true,
311 }, 314 },
312}; 315};
313 316
diff --git a/drivers/video/fbdev/omap2/displays-new/connector-dvi.c b/drivers/video/fbdev/omap2/displays-new/connector-dvi.c
index 74de2bc50c4f..2dfb6e5ff0cc 100644
--- a/drivers/video/fbdev/omap2/displays-new/connector-dvi.c
+++ b/drivers/video/fbdev/omap2/displays-new/connector-dvi.c
@@ -391,6 +391,7 @@ static struct platform_driver dvi_connector_driver = {
391 .name = "connector-dvi", 391 .name = "connector-dvi",
392 .owner = THIS_MODULE, 392 .owner = THIS_MODULE,
393 .of_match_table = dvic_of_match, 393 .of_match_table = dvic_of_match,
394 .suppress_bind_attrs = true,
394 }, 395 },
395}; 396};
396 397
diff --git a/drivers/video/fbdev/omap2/displays-new/connector-hdmi.c b/drivers/video/fbdev/omap2/displays-new/connector-hdmi.c
index 131c6e260898..7b25967a91eb 100644
--- a/drivers/video/fbdev/omap2/displays-new/connector-hdmi.c
+++ b/drivers/video/fbdev/omap2/displays-new/connector-hdmi.c
@@ -437,6 +437,7 @@ static struct platform_driver hdmi_connector_driver = {
437 .name = "connector-hdmi", 437 .name = "connector-hdmi",
438 .owner = THIS_MODULE, 438 .owner = THIS_MODULE,
439 .of_match_table = hdmic_of_match, 439 .of_match_table = hdmic_of_match,
440 .suppress_bind_attrs = true,
440 }, 441 },
441}; 442};
442 443
diff --git a/drivers/video/fbdev/omap2/displays-new/encoder-tfp410.c b/drivers/video/fbdev/omap2/displays-new/encoder-tfp410.c
index b4e9a42a79e6..47ee7cdee1c5 100644
--- a/drivers/video/fbdev/omap2/displays-new/encoder-tfp410.c
+++ b/drivers/video/fbdev/omap2/displays-new/encoder-tfp410.c
@@ -298,6 +298,7 @@ static struct platform_driver tfp410_driver = {
298 .name = "tfp410", 298 .name = "tfp410",
299 .owner = THIS_MODULE, 299 .owner = THIS_MODULE,
300 .of_match_table = tfp410_of_match, 300 .of_match_table = tfp410_of_match,
301 .suppress_bind_attrs = true,
301 }, 302 },
302}; 303};
303 304
diff --git a/drivers/video/fbdev/omap2/displays-new/encoder-tpd12s015.c b/drivers/video/fbdev/omap2/displays-new/encoder-tpd12s015.c
index c891d8f84cb2..c4abd56dd846 100644
--- a/drivers/video/fbdev/omap2/displays-new/encoder-tpd12s015.c
+++ b/drivers/video/fbdev/omap2/displays-new/encoder-tpd12s015.c
@@ -461,6 +461,7 @@ static struct platform_driver tpd_driver = {
461 .name = "tpd12s015", 461 .name = "tpd12s015",
462 .owner = THIS_MODULE, 462 .owner = THIS_MODULE,
463 .of_match_table = tpd_of_match, 463 .of_match_table = tpd_of_match,
464 .suppress_bind_attrs = true,
464 }, 465 },
465}; 466};
466 467
diff --git a/drivers/video/fbdev/omap2/displays-new/panel-dpi.c b/drivers/video/fbdev/omap2/displays-new/panel-dpi.c
index 3636b61dc9b4..a9c3dcf0f6b5 100644
--- a/drivers/video/fbdev/omap2/displays-new/panel-dpi.c
+++ b/drivers/video/fbdev/omap2/displays-new/panel-dpi.c
@@ -327,6 +327,7 @@ static struct platform_driver panel_dpi_driver = {
327 .name = "panel-dpi", 327 .name = "panel-dpi",
328 .owner = THIS_MODULE, 328 .owner = THIS_MODULE,
329 .of_match_table = panel_dpi_of_match, 329 .of_match_table = panel_dpi_of_match,
330 .suppress_bind_attrs = true,
330 }, 331 },
331}; 332};
332 333
diff --git a/drivers/video/fbdev/omap2/displays-new/panel-dsi-cm.c b/drivers/video/fbdev/omap2/displays-new/panel-dsi-cm.c
index d6f14e8717e8..899cb1ab523d 100644
--- a/drivers/video/fbdev/omap2/displays-new/panel-dsi-cm.c
+++ b/drivers/video/fbdev/omap2/displays-new/panel-dsi-cm.c
@@ -1378,6 +1378,7 @@ static struct platform_driver dsicm_driver = {
1378 .name = "panel-dsi-cm", 1378 .name = "panel-dsi-cm",
1379 .owner = THIS_MODULE, 1379 .owner = THIS_MODULE,
1380 .of_match_table = dsicm_of_match, 1380 .of_match_table = dsicm_of_match,
1381 .suppress_bind_attrs = true,
1381 }, 1382 },
1382}; 1383};
1383 1384
diff --git a/drivers/video/fbdev/omap2/displays-new/panel-lgphilips-lb035q02.c b/drivers/video/fbdev/omap2/displays-new/panel-lgphilips-lb035q02.c
index cc5b5124e0b4..27d4fcfa1824 100644
--- a/drivers/video/fbdev/omap2/displays-new/panel-lgphilips-lb035q02.c
+++ b/drivers/video/fbdev/omap2/displays-new/panel-lgphilips-lb035q02.c
@@ -394,6 +394,7 @@ static struct spi_driver lb035q02_spi_driver = {
394 .name = "panel_lgphilips_lb035q02", 394 .name = "panel_lgphilips_lb035q02",
395 .owner = THIS_MODULE, 395 .owner = THIS_MODULE,
396 .of_match_table = lb035q02_of_match, 396 .of_match_table = lb035q02_of_match,
397 .suppress_bind_attrs = true,
397 }, 398 },
398}; 399};
399 400
diff --git a/drivers/video/fbdev/omap2/displays-new/panel-nec-nl8048hl11.c b/drivers/video/fbdev/omap2/displays-new/panel-nec-nl8048hl11.c
index 3595f111aa35..ccf3f4f3c703 100644
--- a/drivers/video/fbdev/omap2/displays-new/panel-nec-nl8048hl11.c
+++ b/drivers/video/fbdev/omap2/displays-new/panel-nec-nl8048hl11.c
@@ -424,6 +424,7 @@ static struct spi_driver nec_8048_driver = {
424 .owner = THIS_MODULE, 424 .owner = THIS_MODULE,
425 .pm = NEC_8048_PM_OPS, 425 .pm = NEC_8048_PM_OPS,
426 .of_match_table = nec_8048_of_match, 426 .of_match_table = nec_8048_of_match,
427 .suppress_bind_attrs = true,
427 }, 428 },
428 .probe = nec_8048_probe, 429 .probe = nec_8048_probe,
429 .remove = nec_8048_remove, 430 .remove = nec_8048_remove,
diff --git a/drivers/video/fbdev/omap2/displays-new/panel-sharp-ls037v7dw01.c b/drivers/video/fbdev/omap2/displays-new/panel-sharp-ls037v7dw01.c
index f1f72ce50a17..234142cc3764 100644
--- a/drivers/video/fbdev/omap2/displays-new/panel-sharp-ls037v7dw01.c
+++ b/drivers/video/fbdev/omap2/displays-new/panel-sharp-ls037v7dw01.c
@@ -410,6 +410,7 @@ static struct platform_driver sharp_ls_driver = {
410 .name = "panel-sharp-ls037v7dw01", 410 .name = "panel-sharp-ls037v7dw01",
411 .owner = THIS_MODULE, 411 .owner = THIS_MODULE,
412 .of_match_table = sharp_ls_of_match, 412 .of_match_table = sharp_ls_of_match,
413 .suppress_bind_attrs = true,
413 }, 414 },
414}; 415};
415 416
diff --git a/drivers/video/fbdev/omap2/displays-new/panel-sony-acx565akm.c b/drivers/video/fbdev/omap2/displays-new/panel-sony-acx565akm.c
index 617f8d2f5127..337ccc5c0f5e 100644
--- a/drivers/video/fbdev/omap2/displays-new/panel-sony-acx565akm.c
+++ b/drivers/video/fbdev/omap2/displays-new/panel-sony-acx565akm.c
@@ -904,6 +904,7 @@ static struct spi_driver acx565akm_driver = {
904 .name = "acx565akm", 904 .name = "acx565akm",
905 .owner = THIS_MODULE, 905 .owner = THIS_MODULE,
906 .of_match_table = acx565akm_of_match, 906 .of_match_table = acx565akm_of_match,
907 .suppress_bind_attrs = true,
907 }, 908 },
908 .probe = acx565akm_probe, 909 .probe = acx565akm_probe,
909 .remove = acx565akm_remove, 910 .remove = acx565akm_remove,
diff --git a/drivers/video/fbdev/omap2/displays-new/panel-tpo-td028ttec1.c b/drivers/video/fbdev/omap2/displays-new/panel-tpo-td028ttec1.c
index 728808bcceeb..fbba0b8ca871 100644
--- a/drivers/video/fbdev/omap2/displays-new/panel-tpo-td028ttec1.c
+++ b/drivers/video/fbdev/omap2/displays-new/panel-tpo-td028ttec1.c
@@ -500,6 +500,7 @@ static struct spi_driver td028ttec1_spi_driver = {
500 .name = "panel-tpo-td028ttec1", 500 .name = "panel-tpo-td028ttec1",
501 .owner = THIS_MODULE, 501 .owner = THIS_MODULE,
502 .of_match_table = td028ttec1_of_match, 502 .of_match_table = td028ttec1_of_match,
503 .suppress_bind_attrs = true,
503 }, 504 },
504}; 505};
505 506
diff --git a/drivers/video/fbdev/omap2/displays-new/panel-tpo-td043mtea1.c b/drivers/video/fbdev/omap2/displays-new/panel-tpo-td043mtea1.c
index de78ab0caaa8..5aba76bca25a 100644
--- a/drivers/video/fbdev/omap2/displays-new/panel-tpo-td043mtea1.c
+++ b/drivers/video/fbdev/omap2/displays-new/panel-tpo-td043mtea1.c
@@ -673,6 +673,7 @@ static struct spi_driver tpo_td043_spi_driver = {
673 .owner = THIS_MODULE, 673 .owner = THIS_MODULE,
674 .pm = &tpo_td043_spi_pm, 674 .pm = &tpo_td043_spi_pm,
675 .of_match_table = tpo_td043_of_match, 675 .of_match_table = tpo_td043_of_match,
676 .suppress_bind_attrs = true,
676 }, 677 },
677 .probe = tpo_td043_probe, 678 .probe = tpo_td043_probe,
678 .remove = tpo_td043_remove, 679 .remove = tpo_td043_remove,
diff --git a/drivers/video/fbdev/omap2/dss/apply.c b/drivers/video/fbdev/omap2/dss/apply.c
index 0a0b084ce65d..663ccc3bf4e5 100644
--- a/drivers/video/fbdev/omap2/dss/apply.c
+++ b/drivers/video/fbdev/omap2/dss/apply.c
@@ -1132,6 +1132,8 @@ static void dss_mgr_disable_compat(struct omap_overlay_manager *mgr)
1132 if (!mp->enabled) 1132 if (!mp->enabled)
1133 goto out; 1133 goto out;
1134 1134
1135 wait_pending_extra_info_updates();
1136
1135 if (!mgr_manual_update(mgr)) 1137 if (!mgr_manual_update(mgr))
1136 dispc_mgr_disable_sync(mgr->id); 1138 dispc_mgr_disable_sync(mgr->id);
1137 1139
diff --git a/drivers/video/fbdev/omap2/dss/dispc.c b/drivers/video/fbdev/omap2/dss/dispc.c
index be053aa80880..0e9a74bb9fc2 100644
--- a/drivers/video/fbdev/omap2/dss/dispc.c
+++ b/drivers/video/fbdev/omap2/dss/dispc.c
@@ -3290,8 +3290,11 @@ static void dispc_dump_regs(struct seq_file *s)
3290 DUMPREG(i, DISPC_OVL_FIFO_SIZE_STATUS); 3290 DUMPREG(i, DISPC_OVL_FIFO_SIZE_STATUS);
3291 DUMPREG(i, DISPC_OVL_ROW_INC); 3291 DUMPREG(i, DISPC_OVL_ROW_INC);
3292 DUMPREG(i, DISPC_OVL_PIXEL_INC); 3292 DUMPREG(i, DISPC_OVL_PIXEL_INC);
3293
3293 if (dss_has_feature(FEAT_PRELOAD)) 3294 if (dss_has_feature(FEAT_PRELOAD))
3294 DUMPREG(i, DISPC_OVL_PRELOAD); 3295 DUMPREG(i, DISPC_OVL_PRELOAD);
3296 if (dss_has_feature(FEAT_MFLAG))
3297 DUMPREG(i, DISPC_OVL_MFLAG_THRESHOLD);
3295 3298
3296 if (i == OMAP_DSS_GFX) { 3299 if (i == OMAP_DSS_GFX) {
3297 DUMPREG(i, DISPC_OVL_WINDOW_SKIP); 3300 DUMPREG(i, DISPC_OVL_WINDOW_SKIP);
@@ -3312,10 +3315,6 @@ static void dispc_dump_regs(struct seq_file *s)
3312 } 3315 }
3313 if (dss_has_feature(FEAT_ATTR2)) 3316 if (dss_has_feature(FEAT_ATTR2))
3314 DUMPREG(i, DISPC_OVL_ATTRIBUTES2); 3317 DUMPREG(i, DISPC_OVL_ATTRIBUTES2);
3315 if (dss_has_feature(FEAT_PRELOAD))
3316 DUMPREG(i, DISPC_OVL_PRELOAD);
3317 if (dss_has_feature(FEAT_MFLAG))
3318 DUMPREG(i, DISPC_OVL_MFLAG_THRESHOLD);
3319 } 3318 }
3320 3319
3321#undef DISPC_REG 3320#undef DISPC_REG
@@ -3843,6 +3842,7 @@ static struct platform_driver omap_dispchw_driver = {
3843 .owner = THIS_MODULE, 3842 .owner = THIS_MODULE,
3844 .pm = &dispc_pm_ops, 3843 .pm = &dispc_pm_ops,
3845 .of_match_table = dispc_of_match, 3844 .of_match_table = dispc_of_match,
3845 .suppress_bind_attrs = true,
3846 }, 3846 },
3847}; 3847};
3848 3848
diff --git a/drivers/video/fbdev/omap2/dss/dispc.h b/drivers/video/fbdev/omap2/dss/dispc.h
index 78edb449c763..3043d6e0a5f9 100644
--- a/drivers/video/fbdev/omap2/dss/dispc.h
+++ b/drivers/video/fbdev/omap2/dss/dispc.h
@@ -101,8 +101,7 @@
101 DISPC_FIR_COEF_V2_OFFSET(n, i)) 101 DISPC_FIR_COEF_V2_OFFSET(n, i))
102#define DISPC_OVL_PRELOAD(n) (DISPC_OVL_BASE(n) + \ 102#define DISPC_OVL_PRELOAD(n) (DISPC_OVL_BASE(n) + \
103 DISPC_PRELOAD_OFFSET(n)) 103 DISPC_PRELOAD_OFFSET(n))
104#define DISPC_OVL_MFLAG_THRESHOLD(n) (DISPC_OVL_BASE(n) + \ 104#define DISPC_OVL_MFLAG_THRESHOLD(n) DISPC_MFLAG_THRESHOLD_OFFSET(n)
105 DISPC_MFLAG_THRESHOLD_OFFSET(n))
106 105
107/* DISPC up/downsampling FIR filter coefficient structure */ 106/* DISPC up/downsampling FIR filter coefficient structure */
108struct dispc_coef { 107struct dispc_coef {
diff --git a/drivers/video/fbdev/omap2/dss/dpi.c b/drivers/video/fbdev/omap2/dss/dpi.c
index 9368972d6962..4a3363dae74a 100644
--- a/drivers/video/fbdev/omap2/dss/dpi.c
+++ b/drivers/video/fbdev/omap2/dss/dpi.c
@@ -720,6 +720,7 @@ static struct platform_driver omap_dpi_driver = {
720 .driver = { 720 .driver = {
721 .name = "omapdss_dpi", 721 .name = "omapdss_dpi",
722 .owner = THIS_MODULE, 722 .owner = THIS_MODULE,
723 .suppress_bind_attrs = true,
723 }, 724 },
724}; 725};
725 726
diff --git a/drivers/video/fbdev/omap2/dss/dsi.c b/drivers/video/fbdev/omap2/dss/dsi.c
index b6f6ae1d4664..0793bc67a275 100644
--- a/drivers/video/fbdev/omap2/dss/dsi.c
+++ b/drivers/video/fbdev/omap2/dss/dsi.c
@@ -1603,7 +1603,7 @@ int dsi_pll_set_clock_div(struct platform_device *dsidev,
1603 } else if (dss_has_feature(FEAT_DSI_PLL_SELFREQDCO)) { 1603 } else if (dss_has_feature(FEAT_DSI_PLL_SELFREQDCO)) {
1604 f = cinfo->clkin4ddr < 1000000000 ? 0x2 : 0x4; 1604 f = cinfo->clkin4ddr < 1000000000 ? 0x2 : 0x4;
1605 1605
1606 l = FLD_MOD(l, f, 4, 1); /* PLL_SELFREQDCO */ 1606 l = FLD_MOD(l, f, 3, 1); /* PLL_SELFREQDCO */
1607 } 1607 }
1608 1608
1609 l = FLD_MOD(l, 1, 13, 13); /* DSI_PLL_REFEN */ 1609 l = FLD_MOD(l, 1, 13, 13); /* DSI_PLL_REFEN */
@@ -5754,6 +5754,7 @@ static struct platform_driver omap_dsihw_driver = {
5754 .owner = THIS_MODULE, 5754 .owner = THIS_MODULE,
5755 .pm = &dsi_pm_ops, 5755 .pm = &dsi_pm_ops,
5756 .of_match_table = dsi_of_match, 5756 .of_match_table = dsi_of_match,
5757 .suppress_bind_attrs = true,
5757 }, 5758 },
5758}; 5759};
5759 5760
diff --git a/drivers/video/fbdev/omap2/dss/dss.c b/drivers/video/fbdev/omap2/dss/dss.c
index 6daeb7ed44c6..14bcd6c43f72 100644
--- a/drivers/video/fbdev/omap2/dss/dss.c
+++ b/drivers/video/fbdev/omap2/dss/dss.c
@@ -966,6 +966,7 @@ static struct platform_driver omap_dsshw_driver = {
966 .owner = THIS_MODULE, 966 .owner = THIS_MODULE,
967 .pm = &dss_pm_ops, 967 .pm = &dss_pm_ops,
968 .of_match_table = dss_of_match, 968 .of_match_table = dss_of_match,
969 .suppress_bind_attrs = true,
969 }, 970 },
970}; 971};
971 972
diff --git a/drivers/video/fbdev/omap2/dss/hdmi4.c b/drivers/video/fbdev/omap2/dss/hdmi4.c
index 6a8550cf43e5..9a8713ca090c 100644
--- a/drivers/video/fbdev/omap2/dss/hdmi4.c
+++ b/drivers/video/fbdev/omap2/dss/hdmi4.c
@@ -781,6 +781,7 @@ static struct platform_driver omapdss_hdmihw_driver = {
781 .owner = THIS_MODULE, 781 .owner = THIS_MODULE,
782 .pm = &hdmi_pm_ops, 782 .pm = &hdmi_pm_ops,
783 .of_match_table = hdmi_of_match, 783 .of_match_table = hdmi_of_match,
784 .suppress_bind_attrs = true,
784 }, 785 },
785}; 786};
786 787
diff --git a/drivers/video/fbdev/omap2/dss/hdmi5.c b/drivers/video/fbdev/omap2/dss/hdmi5.c
index 32d02ec34d23..169b764bb9d4 100644
--- a/drivers/video/fbdev/omap2/dss/hdmi5.c
+++ b/drivers/video/fbdev/omap2/dss/hdmi5.c
@@ -806,6 +806,7 @@ static struct platform_driver omapdss_hdmihw_driver = {
806 .owner = THIS_MODULE, 806 .owner = THIS_MODULE,
807 .pm = &hdmi_pm_ops, 807 .pm = &hdmi_pm_ops,
808 .of_match_table = hdmi_of_match, 808 .of_match_table = hdmi_of_match,
809 .suppress_bind_attrs = true,
809 }, 810 },
810}; 811};
811 812
diff --git a/drivers/video/fbdev/omap2/dss/hdmi_pll.c b/drivers/video/fbdev/omap2/dss/hdmi_pll.c
index 54df12a8d744..6d92bb32fe51 100644
--- a/drivers/video/fbdev/omap2/dss/hdmi_pll.c
+++ b/drivers/video/fbdev/omap2/dss/hdmi_pll.c
@@ -124,16 +124,15 @@ static int hdmi_pll_config(struct hdmi_pll_data *pll)
124 r = FLD_MOD(r, 0x0, 14, 14); /* PHY_CLKINEN de-assert during locking */ 124 r = FLD_MOD(r, 0x0, 14, 14); /* PHY_CLKINEN de-assert during locking */
125 r = FLD_MOD(r, fmt->refsel, 22, 21); /* REFSEL */ 125 r = FLD_MOD(r, fmt->refsel, 22, 21); /* REFSEL */
126 126
127 if (fmt->dcofreq) { 127 if (fmt->dcofreq)
128 /* divider programming for frequency beyond 1000Mhz */
129 REG_FLD_MOD(pll->base, PLLCTRL_CFG3, fmt->regsd, 17, 10);
130 r = FLD_MOD(r, 0x4, 3, 1); /* 1000MHz and 2000MHz */ 128 r = FLD_MOD(r, 0x4, 3, 1); /* 1000MHz and 2000MHz */
131 } else { 129 else
132 r = FLD_MOD(r, 0x2, 3, 1); /* 500MHz and 1000MHz */ 130 r = FLD_MOD(r, 0x2, 3, 1); /* 500MHz and 1000MHz */
133 }
134 131
135 hdmi_write_reg(pll->base, PLLCTRL_CFG2, r); 132 hdmi_write_reg(pll->base, PLLCTRL_CFG2, r);
136 133
134 REG_FLD_MOD(pll->base, PLLCTRL_CFG3, fmt->regsd, 17, 10);
135
137 r = hdmi_read_reg(pll->base, PLLCTRL_CFG4); 136 r = hdmi_read_reg(pll->base, PLLCTRL_CFG4);
138 r = FLD_MOD(r, fmt->regm2, 24, 18); 137 r = FLD_MOD(r, fmt->regm2, 24, 18);
139 r = FLD_MOD(r, fmt->regmf, 17, 0); 138 r = FLD_MOD(r, fmt->regmf, 17, 0);
@@ -144,8 +143,8 @@ static int hdmi_pll_config(struct hdmi_pll_data *pll)
144 143
145 /* wait for bit change */ 144 /* wait for bit change */
146 if (hdmi_wait_for_bit_change(pll->base, PLLCTRL_PLL_GO, 145 if (hdmi_wait_for_bit_change(pll->base, PLLCTRL_PLL_GO,
147 0, 0, 1) != 1) { 146 0, 0, 0) != 0) {
148 DSSERR("PLL GO bit not set\n"); 147 DSSERR("PLL GO bit not clearing\n");
149 return -ETIMEDOUT; 148 return -ETIMEDOUT;
150 } 149 }
151 150
diff --git a/drivers/video/fbdev/omap2/dss/rfbi.c b/drivers/video/fbdev/omap2/dss/rfbi.c
index c8a81a2b879c..878273f58839 100644
--- a/drivers/video/fbdev/omap2/dss/rfbi.c
+++ b/drivers/video/fbdev/omap2/dss/rfbi.c
@@ -1044,6 +1044,7 @@ static struct platform_driver omap_rfbihw_driver = {
1044 .name = "omapdss_rfbi", 1044 .name = "omapdss_rfbi",
1045 .owner = THIS_MODULE, 1045 .owner = THIS_MODULE,
1046 .pm = &rfbi_pm_ops, 1046 .pm = &rfbi_pm_ops,
1047 .suppress_bind_attrs = true,
1047 }, 1048 },
1048}; 1049};
1049 1050
diff --git a/drivers/video/fbdev/omap2/dss/sdi.c b/drivers/video/fbdev/omap2/dss/sdi.c
index 911dcc9173a6..4c9c46d4ea60 100644
--- a/drivers/video/fbdev/omap2/dss/sdi.c
+++ b/drivers/video/fbdev/omap2/dss/sdi.c
@@ -377,6 +377,7 @@ static struct platform_driver omap_sdi_driver = {
377 .driver = { 377 .driver = {
378 .name = "omapdss_sdi", 378 .name = "omapdss_sdi",
379 .owner = THIS_MODULE, 379 .owner = THIS_MODULE,
380 .suppress_bind_attrs = true,
380 }, 381 },
381}; 382};
382 383
diff --git a/drivers/video/fbdev/omap2/dss/venc.c b/drivers/video/fbdev/omap2/dss/venc.c
index 21d81113962b..d077d8a75ddc 100644
--- a/drivers/video/fbdev/omap2/dss/venc.c
+++ b/drivers/video/fbdev/omap2/dss/venc.c
@@ -966,6 +966,7 @@ static struct platform_driver omap_venchw_driver = {
966 .owner = THIS_MODULE, 966 .owner = THIS_MODULE,
967 .pm = &venc_pm_ops, 967 .pm = &venc_pm_ops,
968 .of_match_table = venc_of_match, 968 .of_match_table = venc_of_match,
969 .suppress_bind_attrs = true,
969 }, 970 },
970}; 971};
971 972
diff --git a/drivers/video/fbdev/omap2/omapfb/omapfb-main.c b/drivers/video/fbdev/omap2/omapfb/omapfb-main.c
index 15872433e0c6..ce8a70570756 100644
--- a/drivers/video/fbdev/omap2/omapfb/omapfb-main.c
+++ b/drivers/video/fbdev/omap2/omapfb/omapfb-main.c
@@ -1833,14 +1833,13 @@ static void omapfb_free_resources(struct omapfb2_device *fbdev)
1833 if (fbdev == NULL) 1833 if (fbdev == NULL)
1834 return; 1834 return;
1835 1835
1836 for (i = 0; i < fbdev->num_fbs; i++) { 1836 for (i = 0; i < fbdev->num_overlays; i++) {
1837 struct omapfb_info *ofbi = FB2OFB(fbdev->fbs[i]); 1837 struct omap_overlay *ovl = fbdev->overlays[i];
1838 int j;
1839 1838
1840 for (j = 0; j < ofbi->num_overlays; j++) { 1839 ovl->disable(ovl);
1841 struct omap_overlay *ovl = ofbi->overlays[j]; 1840
1842 ovl->disable(ovl); 1841 if (ovl->manager)
1843 } 1842 ovl->unset_manager(ovl);
1844 } 1843 }
1845 1844
1846 for (i = 0; i < fbdev->num_fbs; i++) 1845 for (i = 0; i < fbdev->num_fbs; i++)
@@ -2619,7 +2618,7 @@ err0:
2619 return r; 2618 return r;
2620} 2619}
2621 2620
2622static int __exit omapfb_remove(struct platform_device *pdev) 2621static int omapfb_remove(struct platform_device *pdev)
2623{ 2622{
2624 struct omapfb2_device *fbdev = platform_get_drvdata(pdev); 2623 struct omapfb2_device *fbdev = platform_get_drvdata(pdev);
2625 2624
@@ -2636,7 +2635,7 @@ static int __exit omapfb_remove(struct platform_device *pdev)
2636 2635
2637static struct platform_driver omapfb_driver = { 2636static struct platform_driver omapfb_driver = {
2638 .probe = omapfb_probe, 2637 .probe = omapfb_probe,
2639 .remove = __exit_p(omapfb_remove), 2638 .remove = omapfb_remove,
2640 .driver = { 2639 .driver = {
2641 .name = "omapfb", 2640 .name = "omapfb",
2642 .owner = THIS_MODULE, 2641 .owner = THIS_MODULE,
@@ -2651,6 +2650,7 @@ module_param_named(mirror, def_mirror, bool, 0);
2651 2650
2652module_platform_driver(omapfb_driver); 2651module_platform_driver(omapfb_driver);
2653 2652
2653MODULE_ALIAS("platform:omapfb");
2654MODULE_AUTHOR("Tomi Valkeinen <tomi.valkeinen@nokia.com>"); 2654MODULE_AUTHOR("Tomi Valkeinen <tomi.valkeinen@nokia.com>");
2655MODULE_DESCRIPTION("OMAP2/3 Framebuffer"); 2655MODULE_DESCRIPTION("OMAP2/3 Framebuffer");
2656MODULE_LICENSE("GPL v2"); 2656MODULE_LICENSE("GPL v2");
diff --git a/fs/block_dev.c b/fs/block_dev.c
index cc9d4114cda0..1d9c9f3754f8 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -1585,7 +1585,7 @@ ssize_t blkdev_write_iter(struct kiocb *iocb, struct iov_iter *from)
1585} 1585}
1586EXPORT_SYMBOL_GPL(blkdev_write_iter); 1586EXPORT_SYMBOL_GPL(blkdev_write_iter);
1587 1587
1588static ssize_t blkdev_read_iter(struct kiocb *iocb, struct iov_iter *to) 1588ssize_t blkdev_read_iter(struct kiocb *iocb, struct iov_iter *to)
1589{ 1589{
1590 struct file *file = iocb->ki_filp; 1590 struct file *file = iocb->ki_filp;
1591 struct inode *bd_inode = file->f_mapping->host; 1591 struct inode *bd_inode = file->f_mapping->host;
@@ -1599,6 +1599,7 @@ static ssize_t blkdev_read_iter(struct kiocb *iocb, struct iov_iter *to)
1599 iov_iter_truncate(to, size); 1599 iov_iter_truncate(to, size);
1600 return generic_file_read_iter(iocb, to); 1600 return generic_file_read_iter(iocb, to);
1601} 1601}
1602EXPORT_SYMBOL_GPL(blkdev_read_iter);
1602 1603
1603/* 1604/*
1604 * Try to release a page associated with block device when the system 1605 * Try to release a page associated with block device when the system
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index d557264ee974..fe69edda11fb 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -3276,7 +3276,7 @@ int btrfs_run_delayed_refs(struct btrfs_trans_handle *trans,
3276 struct btrfs_root *root, unsigned long count); 3276 struct btrfs_root *root, unsigned long count);
3277int btrfs_async_run_delayed_refs(struct btrfs_root *root, 3277int btrfs_async_run_delayed_refs(struct btrfs_root *root,
3278 unsigned long count, int wait); 3278 unsigned long count, int wait);
3279int btrfs_lookup_extent(struct btrfs_root *root, u64 start, u64 len); 3279int btrfs_lookup_data_extent(struct btrfs_root *root, u64 start, u64 len);
3280int btrfs_lookup_extent_info(struct btrfs_trans_handle *trans, 3280int btrfs_lookup_extent_info(struct btrfs_trans_handle *trans,
3281 struct btrfs_root *root, u64 bytenr, 3281 struct btrfs_root *root, u64 bytenr,
3282 u64 offset, int metadata, u64 *refs, u64 *flags); 3282 u64 offset, int metadata, u64 *refs, u64 *flags);
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 1ad0f47ac850..1bf9f897065d 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -3817,19 +3817,19 @@ static int btrfs_check_super_valid(struct btrfs_fs_info *fs_info,
3817 struct btrfs_super_block *sb = fs_info->super_copy; 3817 struct btrfs_super_block *sb = fs_info->super_copy;
3818 int ret = 0; 3818 int ret = 0;
3819 3819
3820 if (sb->root_level > BTRFS_MAX_LEVEL) { 3820 if (btrfs_super_root_level(sb) >= BTRFS_MAX_LEVEL) {
3821 printk(KERN_ERR "BTRFS: tree_root level too big: %d > %d\n", 3821 printk(KERN_ERR "BTRFS: tree_root level too big: %d >= %d\n",
3822 sb->root_level, BTRFS_MAX_LEVEL); 3822 btrfs_super_root_level(sb), BTRFS_MAX_LEVEL);
3823 ret = -EINVAL; 3823 ret = -EINVAL;
3824 } 3824 }
3825 if (sb->chunk_root_level > BTRFS_MAX_LEVEL) { 3825 if (btrfs_super_chunk_root_level(sb) >= BTRFS_MAX_LEVEL) {
3826 printk(KERN_ERR "BTRFS: chunk_root level too big: %d > %d\n", 3826 printk(KERN_ERR "BTRFS: chunk_root level too big: %d >= %d\n",
3827 sb->chunk_root_level, BTRFS_MAX_LEVEL); 3827 btrfs_super_chunk_root_level(sb), BTRFS_MAX_LEVEL);
3828 ret = -EINVAL; 3828 ret = -EINVAL;
3829 } 3829 }
3830 if (sb->log_root_level > BTRFS_MAX_LEVEL) { 3830 if (btrfs_super_log_root_level(sb) >= BTRFS_MAX_LEVEL) {
3831 printk(KERN_ERR "BTRFS: log_root level too big: %d > %d\n", 3831 printk(KERN_ERR "BTRFS: log_root level too big: %d >= %d\n",
3832 sb->log_root_level, BTRFS_MAX_LEVEL); 3832 btrfs_super_log_root_level(sb), BTRFS_MAX_LEVEL);
3833 ret = -EINVAL; 3833 ret = -EINVAL;
3834 } 3834 }
3835 3835
@@ -3837,15 +3837,15 @@ static int btrfs_check_super_valid(struct btrfs_fs_info *fs_info,
3837 * The common minimum, we don't know if we can trust the nodesize/sectorsize 3837 * The common minimum, we don't know if we can trust the nodesize/sectorsize
3838 * items yet, they'll be verified later. Issue just a warning. 3838 * items yet, they'll be verified later. Issue just a warning.
3839 */ 3839 */
3840 if (!IS_ALIGNED(sb->root, 4096)) 3840 if (!IS_ALIGNED(btrfs_super_root(sb), 4096))
3841 printk(KERN_WARNING "BTRFS: tree_root block unaligned: %llu\n", 3841 printk(KERN_WARNING "BTRFS: tree_root block unaligned: %llu\n",
3842 sb->root); 3842 sb->root);
3843 if (!IS_ALIGNED(sb->chunk_root, 4096)) 3843 if (!IS_ALIGNED(btrfs_super_chunk_root(sb), 4096))
3844 printk(KERN_WARNING "BTRFS: tree_root block unaligned: %llu\n", 3844 printk(KERN_WARNING "BTRFS: tree_root block unaligned: %llu\n",
3845 sb->chunk_root); 3845 sb->chunk_root);
3846 if (!IS_ALIGNED(sb->log_root, 4096)) 3846 if (!IS_ALIGNED(btrfs_super_log_root(sb), 4096))
3847 printk(KERN_WARNING "BTRFS: tree_root block unaligned: %llu\n", 3847 printk(KERN_WARNING "BTRFS: tree_root block unaligned: %llu\n",
3848 sb->log_root); 3848 btrfs_super_log_root(sb));
3849 3849
3850 if (memcmp(fs_info->fsid, sb->dev_item.fsid, BTRFS_UUID_SIZE) != 0) { 3850 if (memcmp(fs_info->fsid, sb->dev_item.fsid, BTRFS_UUID_SIZE) != 0) {
3851 printk(KERN_ERR "BTRFS: dev_item UUID does not match fsid: %pU != %pU\n", 3851 printk(KERN_ERR "BTRFS: dev_item UUID does not match fsid: %pU != %pU\n",
@@ -3857,13 +3857,13 @@ static int btrfs_check_super_valid(struct btrfs_fs_info *fs_info,
3857 * Hint to catch really bogus numbers, bitflips or so, more exact checks are 3857 * Hint to catch really bogus numbers, bitflips or so, more exact checks are
3858 * done later 3858 * done later
3859 */ 3859 */
3860 if (sb->num_devices > (1UL << 31)) 3860 if (btrfs_super_num_devices(sb) > (1UL << 31))
3861 printk(KERN_WARNING "BTRFS: suspicious number of devices: %llu\n", 3861 printk(KERN_WARNING "BTRFS: suspicious number of devices: %llu\n",
3862 sb->num_devices); 3862 btrfs_super_num_devices(sb));
3863 3863
3864 if (sb->bytenr != BTRFS_SUPER_INFO_OFFSET) { 3864 if (btrfs_super_bytenr(sb) != BTRFS_SUPER_INFO_OFFSET) {
3865 printk(KERN_ERR "BTRFS: super offset mismatch %llu != %u\n", 3865 printk(KERN_ERR "BTRFS: super offset mismatch %llu != %u\n",
3866 sb->bytenr, BTRFS_SUPER_INFO_OFFSET); 3866 btrfs_super_bytenr(sb), BTRFS_SUPER_INFO_OFFSET);
3867 ret = -EINVAL; 3867 ret = -EINVAL;
3868 } 3868 }
3869 3869
@@ -3871,14 +3871,15 @@ static int btrfs_check_super_valid(struct btrfs_fs_info *fs_info,
3871 * The generation is a global counter, we'll trust it more than the others 3871 * The generation is a global counter, we'll trust it more than the others
3872 * but it's still possible that it's the one that's wrong. 3872 * but it's still possible that it's the one that's wrong.
3873 */ 3873 */
3874 if (sb->generation < sb->chunk_root_generation) 3874 if (btrfs_super_generation(sb) < btrfs_super_chunk_root_generation(sb))
3875 printk(KERN_WARNING 3875 printk(KERN_WARNING
3876 "BTRFS: suspicious: generation < chunk_root_generation: %llu < %llu\n", 3876 "BTRFS: suspicious: generation < chunk_root_generation: %llu < %llu\n",
3877 sb->generation, sb->chunk_root_generation); 3877 btrfs_super_generation(sb), btrfs_super_chunk_root_generation(sb));
3878 if (sb->generation < sb->cache_generation && sb->cache_generation != (u64)-1) 3878 if (btrfs_super_generation(sb) < btrfs_super_cache_generation(sb)
3879 && btrfs_super_cache_generation(sb) != (u64)-1)
3879 printk(KERN_WARNING 3880 printk(KERN_WARNING
3880 "BTRFS: suspicious: generation < cache_generation: %llu < %llu\n", 3881 "BTRFS: suspicious: generation < cache_generation: %llu < %llu\n",
3881 sb->generation, sb->cache_generation); 3882 btrfs_super_generation(sb), btrfs_super_cache_generation(sb));
3882 3883
3883 return ret; 3884 return ret;
3884} 3885}
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index d56589571012..47c1ba141082 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -710,8 +710,8 @@ void btrfs_clear_space_info_full(struct btrfs_fs_info *info)
710 rcu_read_unlock(); 710 rcu_read_unlock();
711} 711}
712 712
713/* simple helper to search for an existing extent at a given offset */ 713/* simple helper to search for an existing data extent at a given offset */
714int btrfs_lookup_extent(struct btrfs_root *root, u64 start, u64 len) 714int btrfs_lookup_data_extent(struct btrfs_root *root, u64 start, u64 len)
715{ 715{
716 int ret; 716 int ret;
717 struct btrfs_key key; 717 struct btrfs_key key;
@@ -726,12 +726,6 @@ int btrfs_lookup_extent(struct btrfs_root *root, u64 start, u64 len)
726 key.type = BTRFS_EXTENT_ITEM_KEY; 726 key.type = BTRFS_EXTENT_ITEM_KEY;
727 ret = btrfs_search_slot(NULL, root->fs_info->extent_root, &key, path, 727 ret = btrfs_search_slot(NULL, root->fs_info->extent_root, &key, path,
728 0, 0); 728 0, 0);
729 if (ret > 0) {
730 btrfs_item_key_to_cpu(path->nodes[0], &key, path->slots[0]);
731 if (key.objectid == start &&
732 key.type == BTRFS_METADATA_ITEM_KEY)
733 ret = 0;
734 }
735 btrfs_free_path(path); 729 btrfs_free_path(path);
736 return ret; 730 return ret;
737} 731}
@@ -786,7 +780,6 @@ search_again:
786 else 780 else
787 key.type = BTRFS_EXTENT_ITEM_KEY; 781 key.type = BTRFS_EXTENT_ITEM_KEY;
788 782
789again:
790 ret = btrfs_search_slot(trans, root->fs_info->extent_root, 783 ret = btrfs_search_slot(trans, root->fs_info->extent_root,
791 &key, path, 0, 0); 784 &key, path, 0, 0);
792 if (ret < 0) 785 if (ret < 0)
@@ -802,13 +795,6 @@ again:
802 key.offset == root->nodesize) 795 key.offset == root->nodesize)
803 ret = 0; 796 ret = 0;
804 } 797 }
805 if (ret) {
806 key.objectid = bytenr;
807 key.type = BTRFS_EXTENT_ITEM_KEY;
808 key.offset = root->nodesize;
809 btrfs_release_path(path);
810 goto again;
811 }
812 } 798 }
813 799
814 if (ret == 0) { 800 if (ret == 0) {
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index a2b97ef10317..54bd91ece35b 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -2151,6 +2151,7 @@ static void __exit exit_btrfs_fs(void)
2151 extent_map_exit(); 2151 extent_map_exit();
2152 extent_io_exit(); 2152 extent_io_exit();
2153 btrfs_interface_exit(); 2153 btrfs_interface_exit();
2154 btrfs_end_io_wq_exit();
2154 unregister_filesystem(&btrfs_fs_type); 2155 unregister_filesystem(&btrfs_fs_type);
2155 btrfs_exit_sysfs(); 2156 btrfs_exit_sysfs();
2156 btrfs_cleanup_fs_uuids(); 2157 btrfs_cleanup_fs_uuids();
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index 1475979e5718..286213cec861 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -672,7 +672,7 @@ static noinline int replay_one_extent(struct btrfs_trans_handle *trans,
672 * is this extent already allocated in the extent 672 * is this extent already allocated in the extent
673 * allocation tree? If so, just add a reference 673 * allocation tree? If so, just add a reference
674 */ 674 */
675 ret = btrfs_lookup_extent(root, ins.objectid, 675 ret = btrfs_lookup_data_extent(root, ins.objectid,
676 ins.offset); 676 ins.offset);
677 if (ret == 0) { 677 if (ret == 0) {
678 ret = btrfs_inc_extent_ref(trans, root, 678 ret = btrfs_inc_extent_ref(trans, root,
diff --git a/fs/buffer.c b/fs/buffer.c
index 6c48f20eddd4..20805db2c987 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -128,21 +128,15 @@ __clear_page_buffers(struct page *page)
128 page_cache_release(page); 128 page_cache_release(page);
129} 129}
130 130
131 131static void buffer_io_error(struct buffer_head *bh, char *msg)
132static int quiet_error(struct buffer_head *bh)
133{
134 if (!test_bit(BH_Quiet, &bh->b_state) && printk_ratelimit())
135 return 0;
136 return 1;
137}
138
139
140static void buffer_io_error(struct buffer_head *bh)
141{ 132{
142 char b[BDEVNAME_SIZE]; 133 char b[BDEVNAME_SIZE];
143 printk(KERN_ERR "Buffer I/O error on device %s, logical block %Lu\n", 134
135 if (!test_bit(BH_Quiet, &bh->b_state))
136 printk_ratelimited(KERN_ERR
137 "Buffer I/O error on dev %s, logical block %llu%s\n",
144 bdevname(bh->b_bdev, b), 138 bdevname(bh->b_bdev, b),
145 (unsigned long long)bh->b_blocknr); 139 (unsigned long long)bh->b_blocknr, msg);
146} 140}
147 141
148/* 142/*
@@ -177,17 +171,10 @@ EXPORT_SYMBOL(end_buffer_read_sync);
177 171
178void end_buffer_write_sync(struct buffer_head *bh, int uptodate) 172void end_buffer_write_sync(struct buffer_head *bh, int uptodate)
179{ 173{
180 char b[BDEVNAME_SIZE];
181
182 if (uptodate) { 174 if (uptodate) {
183 set_buffer_uptodate(bh); 175 set_buffer_uptodate(bh);
184 } else { 176 } else {
185 if (!quiet_error(bh)) { 177 buffer_io_error(bh, ", lost sync page write");
186 buffer_io_error(bh);
187 printk(KERN_WARNING "lost page write due to "
188 "I/O error on %s\n",
189 bdevname(bh->b_bdev, b));
190 }
191 set_buffer_write_io_error(bh); 178 set_buffer_write_io_error(bh);
192 clear_buffer_uptodate(bh); 179 clear_buffer_uptodate(bh);
193 } 180 }
@@ -304,8 +291,7 @@ static void end_buffer_async_read(struct buffer_head *bh, int uptodate)
304 set_buffer_uptodate(bh); 291 set_buffer_uptodate(bh);
305 } else { 292 } else {
306 clear_buffer_uptodate(bh); 293 clear_buffer_uptodate(bh);
307 if (!quiet_error(bh)) 294 buffer_io_error(bh, ", async page read");
308 buffer_io_error(bh);
309 SetPageError(page); 295 SetPageError(page);
310 } 296 }
311 297
@@ -353,7 +339,6 @@ still_busy:
353 */ 339 */
354void end_buffer_async_write(struct buffer_head *bh, int uptodate) 340void end_buffer_async_write(struct buffer_head *bh, int uptodate)
355{ 341{
356 char b[BDEVNAME_SIZE];
357 unsigned long flags; 342 unsigned long flags;
358 struct buffer_head *first; 343 struct buffer_head *first;
359 struct buffer_head *tmp; 344 struct buffer_head *tmp;
@@ -365,12 +350,7 @@ void end_buffer_async_write(struct buffer_head *bh, int uptodate)
365 if (uptodate) { 350 if (uptodate) {
366 set_buffer_uptodate(bh); 351 set_buffer_uptodate(bh);
367 } else { 352 } else {
368 if (!quiet_error(bh)) { 353 buffer_io_error(bh, ", lost async page write");
369 buffer_io_error(bh);
370 printk(KERN_WARNING "lost page write due to "
371 "I/O error on %s\n",
372 bdevname(bh->b_bdev, b));
373 }
374 set_bit(AS_EIO, &page->mapping->flags); 354 set_bit(AS_EIO, &page->mapping->flags);
375 set_buffer_write_io_error(bh); 355 set_buffer_write_io_error(bh);
376 clear_buffer_uptodate(bh); 356 clear_buffer_uptodate(bh);
diff --git a/fs/ext3/super.c b/fs/ext3/super.c
index 7015db0bafd1..eb742d0e67ff 100644
--- a/fs/ext3/super.c
+++ b/fs/ext3/super.c
@@ -1354,13 +1354,6 @@ set_qf_format:
1354 "not specified."); 1354 "not specified.");
1355 return 0; 1355 return 0;
1356 } 1356 }
1357 } else {
1358 if (sbi->s_jquota_fmt) {
1359 ext3_msg(sb, KERN_ERR, "error: journaled quota format "
1360 "specified with no journaling "
1361 "enabled.");
1362 return 0;
1363 }
1364 } 1357 }
1365#endif 1358#endif
1366 return 1; 1359 return 1;
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 37043d0b2be8..0b16fb4c06d3 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -3603,11 +3603,10 @@ static int ext4_ext_convert_to_initialized(handle_t *handle,
3603 } 3603 }
3604 } 3604 }
3605 3605
3606 allocated = ext4_split_extent(handle, inode, ppath, 3606 err = ext4_split_extent(handle, inode, ppath, &split_map, split_flag,
3607 &split_map, split_flag, flags); 3607 flags);
3608 if (allocated < 0) 3608 if (err > 0)
3609 err = allocated; 3609 err = 0;
3610
3611out: 3610out:
3612 /* If we have gotten a failure, don't zero out status tree */ 3611 /* If we have gotten a failure, don't zero out status tree */
3613 if (!err) 3612 if (!err)
diff --git a/fs/ext4/file.c b/fs/ext4/file.c
index aca7b24a4432..8131be8c0af3 100644
--- a/fs/ext4/file.c
+++ b/fs/ext4/file.c
@@ -137,10 +137,10 @@ ext4_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
137 iov_iter_truncate(from, sbi->s_bitmap_maxbytes - pos); 137 iov_iter_truncate(from, sbi->s_bitmap_maxbytes - pos);
138 } 138 }
139 139
140 iocb->private = &overwrite;
140 if (o_direct) { 141 if (o_direct) {
141 blk_start_plug(&plug); 142 blk_start_plug(&plug);
142 143
143 iocb->private = &overwrite;
144 144
145 /* check whether we do a DIO overwrite or not */ 145 /* check whether we do a DIO overwrite or not */
146 if (ext4_should_dioread_nolock(inode) && !aio_mutex && 146 if (ext4_should_dioread_nolock(inode) && !aio_mutex &&
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
index 8012a5daf401..ac644c31ca67 100644
--- a/fs/ext4/ialloc.c
+++ b/fs/ext4/ialloc.c
@@ -887,6 +887,10 @@ got:
887 struct buffer_head *block_bitmap_bh; 887 struct buffer_head *block_bitmap_bh;
888 888
889 block_bitmap_bh = ext4_read_block_bitmap(sb, group); 889 block_bitmap_bh = ext4_read_block_bitmap(sb, group);
890 if (!block_bitmap_bh) {
891 err = -EIO;
892 goto out;
893 }
890 BUFFER_TRACE(block_bitmap_bh, "get block bitmap access"); 894 BUFFER_TRACE(block_bitmap_bh, "get block bitmap access");
891 err = ext4_journal_get_write_access(handle, block_bitmap_bh); 895 err = ext4_journal_get_write_access(handle, block_bitmap_bh);
892 if (err) { 896 if (err) {
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index e9777f93cf05..3356ab5395f4 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -4959,7 +4959,12 @@ int ext4_change_inode_journal_flag(struct inode *inode, int val)
4959 if (val) 4959 if (val)
4960 ext4_set_inode_flag(inode, EXT4_INODE_JOURNAL_DATA); 4960 ext4_set_inode_flag(inode, EXT4_INODE_JOURNAL_DATA);
4961 else { 4961 else {
4962 jbd2_journal_flush(journal); 4962 err = jbd2_journal_flush(journal);
4963 if (err < 0) {
4964 jbd2_journal_unlock_updates(journal);
4965 ext4_inode_resume_unlocked_dio(inode);
4966 return err;
4967 }
4963 ext4_clear_inode_flag(inode, EXT4_INODE_JOURNAL_DATA); 4968 ext4_clear_inode_flag(inode, EXT4_INODE_JOURNAL_DATA);
4964 } 4969 }
4965 ext4_set_aops(inode); 4970 ext4_set_aops(inode);
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index 123798c5ac31..426211882f72 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -1816,31 +1816,39 @@ static int make_indexed_dir(handle_t *handle, struct dentry *dentry,
1816 hinfo.hash_version += EXT4_SB(dir->i_sb)->s_hash_unsigned; 1816 hinfo.hash_version += EXT4_SB(dir->i_sb)->s_hash_unsigned;
1817 hinfo.seed = EXT4_SB(dir->i_sb)->s_hash_seed; 1817 hinfo.seed = EXT4_SB(dir->i_sb)->s_hash_seed;
1818 ext4fs_dirhash(name, namelen, &hinfo); 1818 ext4fs_dirhash(name, namelen, &hinfo);
1819 memset(frames, 0, sizeof(frames));
1819 frame = frames; 1820 frame = frames;
1820 frame->entries = entries; 1821 frame->entries = entries;
1821 frame->at = entries; 1822 frame->at = entries;
1822 frame->bh = bh; 1823 frame->bh = bh;
1823 bh = bh2; 1824 bh = bh2;
1824 1825
1825 ext4_handle_dirty_dx_node(handle, dir, frame->bh); 1826 retval = ext4_handle_dirty_dx_node(handle, dir, frame->bh);
1826 ext4_handle_dirty_dirent_node(handle, dir, bh); 1827 if (retval)
1828 goto out_frames;
1829 retval = ext4_handle_dirty_dirent_node(handle, dir, bh);
1830 if (retval)
1831 goto out_frames;
1827 1832
1828 de = do_split(handle,dir, &bh, frame, &hinfo); 1833 de = do_split(handle,dir, &bh, frame, &hinfo);
1829 if (IS_ERR(de)) { 1834 if (IS_ERR(de)) {
1830 /* 1835 retval = PTR_ERR(de);
1831 * Even if the block split failed, we have to properly write 1836 goto out_frames;
1832 * out all the changes we did so far. Otherwise we can end up
1833 * with corrupted filesystem.
1834 */
1835 ext4_mark_inode_dirty(handle, dir);
1836 dx_release(frames);
1837 return PTR_ERR(de);
1838 } 1837 }
1839 dx_release(frames); 1838 dx_release(frames);
1840 1839
1841 retval = add_dirent_to_buf(handle, dentry, inode, de, bh); 1840 retval = add_dirent_to_buf(handle, dentry, inode, de, bh);
1842 brelse(bh); 1841 brelse(bh);
1843 return retval; 1842 return retval;
1843out_frames:
1844 /*
1845 * Even if the block split failed, we have to properly write
1846 * out all the changes we did so far. Otherwise we can end up
1847 * with corrupted filesystem.
1848 */
1849 ext4_mark_inode_dirty(handle, dir);
1850 dx_release(frames);
1851 return retval;
1844} 1852}
1845 1853
1846/* 1854/*
diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
index f298c60f907d..ca4588388fc3 100644
--- a/fs/ext4/resize.c
+++ b/fs/ext4/resize.c
@@ -1081,7 +1081,7 @@ static void update_backups(struct super_block *sb, int blk_off, char *data,
1081 break; 1081 break;
1082 1082
1083 if (meta_bg == 0) 1083 if (meta_bg == 0)
1084 backup_block = group * bpg + blk_off; 1084 backup_block = ((ext4_fsblk_t)group) * bpg + blk_off;
1085 else 1085 else
1086 backup_block = (ext4_group_first_block_no(sb, group) + 1086 backup_block = (ext4_group_first_block_no(sb, group) +
1087 ext4_bg_has_super(sb, group)); 1087 ext4_bg_has_super(sb, group));
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 1eda6ab0ef9d..2c9e6864abd9 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -3526,6 +3526,10 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
3526#ifdef CONFIG_EXT4_FS_POSIX_ACL 3526#ifdef CONFIG_EXT4_FS_POSIX_ACL
3527 set_opt(sb, POSIX_ACL); 3527 set_opt(sb, POSIX_ACL);
3528#endif 3528#endif
3529 /* don't forget to enable journal_csum when metadata_csum is enabled. */
3530 if (ext4_has_metadata_csum(sb))
3531 set_opt(sb, JOURNAL_CHECKSUM);
3532
3529 if ((def_mount_opts & EXT4_DEFM_JMODE) == EXT4_DEFM_JMODE_DATA) 3533 if ((def_mount_opts & EXT4_DEFM_JMODE) == EXT4_DEFM_JMODE_DATA)
3530 set_opt(sb, JOURNAL_DATA); 3534 set_opt(sb, JOURNAL_DATA);
3531 else if ((def_mount_opts & EXT4_DEFM_JMODE) == EXT4_DEFM_JMODE_ORDERED) 3535 else if ((def_mount_opts & EXT4_DEFM_JMODE) == EXT4_DEFM_JMODE_ORDERED)
@@ -3943,7 +3947,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
3943 if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_MMP) && 3947 if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_MMP) &&
3944 !(sb->s_flags & MS_RDONLY)) 3948 !(sb->s_flags & MS_RDONLY))
3945 if (ext4_multi_mount_protect(sb, le64_to_cpu(es->s_mmp_block))) 3949 if (ext4_multi_mount_protect(sb, le64_to_cpu(es->s_mmp_block)))
3946 goto failed_mount3; 3950 goto failed_mount3a;
3947 3951
3948 /* 3952 /*
3949 * The first inode we look at is the journal inode. Don't try 3953 * The first inode we look at is the journal inode. Don't try
@@ -3952,7 +3956,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
3952 if (!test_opt(sb, NOLOAD) && 3956 if (!test_opt(sb, NOLOAD) &&
3953 EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL)) { 3957 EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL)) {
3954 if (ext4_load_journal(sb, es, journal_devnum)) 3958 if (ext4_load_journal(sb, es, journal_devnum))
3955 goto failed_mount3; 3959 goto failed_mount3a;
3956 } else if (test_opt(sb, NOLOAD) && !(sb->s_flags & MS_RDONLY) && 3960 } else if (test_opt(sb, NOLOAD) && !(sb->s_flags & MS_RDONLY) &&
3957 EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER)) { 3961 EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER)) {
3958 ext4_msg(sb, KERN_ERR, "required journal recovery " 3962 ext4_msg(sb, KERN_ERR, "required journal recovery "
@@ -4240,6 +4244,7 @@ failed_mount_wq:
4240 jbd2_journal_destroy(sbi->s_journal); 4244 jbd2_journal_destroy(sbi->s_journal);
4241 sbi->s_journal = NULL; 4245 sbi->s_journal = NULL;
4242 } 4246 }
4247failed_mount3a:
4243 ext4_es_unregister_shrinker(sbi); 4248 ext4_es_unregister_shrinker(sbi);
4244failed_mount3: 4249failed_mount3:
4245 del_timer_sync(&sbi->s_err_report); 4250 del_timer_sync(&sbi->s_err_report);
@@ -4841,6 +4846,14 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
4841 goto restore_opts; 4846 goto restore_opts;
4842 } 4847 }
4843 4848
4849 if ((old_opts.s_mount_opt & EXT4_MOUNT_JOURNAL_CHECKSUM) ^
4850 test_opt(sb, JOURNAL_CHECKSUM)) {
4851 ext4_msg(sb, KERN_ERR, "changing journal_checksum "
4852 "during remount not supported");
4853 err = -EINVAL;
4854 goto restore_opts;
4855 }
4856
4844 if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA) { 4857 if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA) {
4845 if (test_opt2(sb, EXPLICIT_DELALLOC)) { 4858 if (test_opt2(sb, EXPLICIT_DELALLOC)) {
4846 ext4_msg(sb, KERN_ERR, "can't mount with " 4859 ext4_msg(sb, KERN_ERR, "can't mount with "
diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c
index 881b3bd0143f..fe839b915116 100644
--- a/fs/isofs/inode.c
+++ b/fs/isofs/inode.c
@@ -29,13 +29,9 @@
29#define BEQUIET 29#define BEQUIET
30 30
31static int isofs_hashi(const struct dentry *parent, struct qstr *qstr); 31static int isofs_hashi(const struct dentry *parent, struct qstr *qstr);
32static int isofs_hash(const struct dentry *parent, struct qstr *qstr);
33static int isofs_dentry_cmpi(const struct dentry *parent, 32static int isofs_dentry_cmpi(const struct dentry *parent,
34 const struct dentry *dentry, 33 const struct dentry *dentry,
35 unsigned int len, const char *str, const struct qstr *name); 34 unsigned int len, const char *str, const struct qstr *name);
36static int isofs_dentry_cmp(const struct dentry *parent,
37 const struct dentry *dentry,
38 unsigned int len, const char *str, const struct qstr *name);
39 35
40#ifdef CONFIG_JOLIET 36#ifdef CONFIG_JOLIET
41static int isofs_hashi_ms(const struct dentry *parent, struct qstr *qstr); 37static int isofs_hashi_ms(const struct dentry *parent, struct qstr *qstr);
@@ -135,10 +131,6 @@ static const struct super_operations isofs_sops = {
135 131
136static const struct dentry_operations isofs_dentry_ops[] = { 132static const struct dentry_operations isofs_dentry_ops[] = {
137 { 133 {
138 .d_hash = isofs_hash,
139 .d_compare = isofs_dentry_cmp,
140 },
141 {
142 .d_hash = isofs_hashi, 134 .d_hash = isofs_hashi,
143 .d_compare = isofs_dentry_cmpi, 135 .d_compare = isofs_dentry_cmpi,
144 }, 136 },
@@ -258,25 +250,12 @@ static int isofs_dentry_cmp_common(
258} 250}
259 251
260static int 252static int
261isofs_hash(const struct dentry *dentry, struct qstr *qstr)
262{
263 return isofs_hash_common(qstr, 0);
264}
265
266static int
267isofs_hashi(const struct dentry *dentry, struct qstr *qstr) 253isofs_hashi(const struct dentry *dentry, struct qstr *qstr)
268{ 254{
269 return isofs_hashi_common(qstr, 0); 255 return isofs_hashi_common(qstr, 0);
270} 256}
271 257
272static int 258static int
273isofs_dentry_cmp(const struct dentry *parent, const struct dentry *dentry,
274 unsigned int len, const char *str, const struct qstr *name)
275{
276 return isofs_dentry_cmp_common(len, str, name, 0, 0);
277}
278
279static int
280isofs_dentry_cmpi(const struct dentry *parent, const struct dentry *dentry, 259isofs_dentry_cmpi(const struct dentry *parent, const struct dentry *dentry,
281 unsigned int len, const char *str, const struct qstr *name) 260 unsigned int len, const char *str, const struct qstr *name)
282{ 261{
@@ -930,7 +909,8 @@ root_found:
930 if (opt.check == 'r') 909 if (opt.check == 'r')
931 table++; 910 table++;
932 911
933 s->s_d_op = &isofs_dentry_ops[table]; 912 if (table)
913 s->s_d_op = &isofs_dentry_ops[table - 1];
934 914
935 /* get the root dentry */ 915 /* get the root dentry */
936 s->s_root = d_make_root(inode); 916 s->s_root = d_make_root(inode);
diff --git a/fs/isofs/namei.c b/fs/isofs/namei.c
index 95295640d9c8..7b543e6b6526 100644
--- a/fs/isofs/namei.c
+++ b/fs/isofs/namei.c
@@ -18,25 +18,10 @@ static int
18isofs_cmp(struct dentry *dentry, const char *compare, int dlen) 18isofs_cmp(struct dentry *dentry, const char *compare, int dlen)
19{ 19{
20 struct qstr qstr; 20 struct qstr qstr;
21
22 if (!compare)
23 return 1;
24
25 /* check special "." and ".." files */
26 if (dlen == 1) {
27 /* "." */
28 if (compare[0] == 0) {
29 if (!dentry->d_name.len)
30 return 0;
31 compare = ".";
32 } else if (compare[0] == 1) {
33 compare = "..";
34 dlen = 2;
35 }
36 }
37
38 qstr.name = compare; 21 qstr.name = compare;
39 qstr.len = dlen; 22 qstr.len = dlen;
23 if (likely(!dentry->d_op))
24 return dentry->d_name.len != dlen || memcmp(dentry->d_name.name, compare, dlen);
40 return dentry->d_op->d_compare(NULL, NULL, dentry->d_name.len, dentry->d_name.name, &qstr); 25 return dentry->d_op->d_compare(NULL, NULL, dentry->d_name.len, dentry->d_name.name, &qstr);
41} 26}
42 27
@@ -146,7 +131,8 @@ isofs_find_entry(struct inode *dir, struct dentry *dentry,
146 (!(de->flags[-sbi->s_high_sierra] & 1))) && 131 (!(de->flags[-sbi->s_high_sierra] & 1))) &&
147 (sbi->s_showassoc || 132 (sbi->s_showassoc ||
148 (!(de->flags[-sbi->s_high_sierra] & 4)))) { 133 (!(de->flags[-sbi->s_high_sierra] & 4)))) {
149 match = (isofs_cmp(dentry, dpnt, dlen) == 0); 134 if (dpnt && (dlen > 1 || dpnt[0] > 1))
135 match = (isofs_cmp(dentry, dpnt, dlen) == 0);
150 } 136 }
151 if (match) { 137 if (match) {
152 isofs_normalize_block_and_offset(de, 138 isofs_normalize_block_and_offset(de,
diff --git a/fs/jbd/revoke.c b/fs/jbd/revoke.c
index 8898bbd2b61e..dcead636c33b 100644
--- a/fs/jbd/revoke.c
+++ b/fs/jbd/revoke.c
@@ -93,6 +93,7 @@
93#include <linux/bio.h> 93#include <linux/bio.h>
94#endif 94#endif
95#include <linux/log2.h> 95#include <linux/log2.h>
96#include <linux/hash.h>
96 97
97static struct kmem_cache *revoke_record_cache; 98static struct kmem_cache *revoke_record_cache;
98static struct kmem_cache *revoke_table_cache; 99static struct kmem_cache *revoke_table_cache;
@@ -129,15 +130,11 @@ static void flush_descriptor(journal_t *, struct journal_head *, int, int);
129 130
130/* Utility functions to maintain the revoke table */ 131/* Utility functions to maintain the revoke table */
131 132
132/* Borrowed from buffer.c: this is a tried and tested block hash function */
133static inline int hash(journal_t *journal, unsigned int block) 133static inline int hash(journal_t *journal, unsigned int block)
134{ 134{
135 struct jbd_revoke_table_s *table = journal->j_revoke; 135 struct jbd_revoke_table_s *table = journal->j_revoke;
136 int hash_shift = table->hash_shift;
137 136
138 return ((block << (hash_shift - 6)) ^ 137 return hash_32(block, table->hash_shift);
139 (block >> 13) ^
140 (block << (hash_shift - 12))) & (table->hash_size - 1);
141} 138}
142 139
143static int insert_revoke_hash(journal_t *journal, unsigned int blocknr, 140static int insert_revoke_hash(journal_t *journal, unsigned int blocknr,
diff --git a/fs/jbd2/revoke.c b/fs/jbd2/revoke.c
index d5e95a175c92..c6cbaef2bda1 100644
--- a/fs/jbd2/revoke.c
+++ b/fs/jbd2/revoke.c
@@ -92,6 +92,7 @@
92#include <linux/init.h> 92#include <linux/init.h>
93#include <linux/bio.h> 93#include <linux/bio.h>
94#include <linux/log2.h> 94#include <linux/log2.h>
95#include <linux/hash.h>
95#endif 96#endif
96 97
97static struct kmem_cache *jbd2_revoke_record_cache; 98static struct kmem_cache *jbd2_revoke_record_cache;
@@ -130,16 +131,9 @@ static void flush_descriptor(journal_t *, struct buffer_head *, int, int);
130 131
131/* Utility functions to maintain the revoke table */ 132/* Utility functions to maintain the revoke table */
132 133
133/* Borrowed from buffer.c: this is a tried and tested block hash function */
134static inline int hash(journal_t *journal, unsigned long long block) 134static inline int hash(journal_t *journal, unsigned long long block)
135{ 135{
136 struct jbd2_revoke_table_s *table = journal->j_revoke; 136 return hash_64(block, journal->j_revoke->hash_shift);
137 int hash_shift = table->hash_shift;
138 int hash = (int)block ^ (int)((block >> 31) >> 1);
139
140 return ((hash << (hash_shift - 6)) ^
141 (hash >> 13) ^
142 (hash << (hash_shift - 12))) & (table->hash_size - 1);
143} 137}
144 138
145static int insert_revoke_hash(journal_t *journal, unsigned long long blocknr, 139static int insert_revoke_hash(journal_t *journal, unsigned long long blocknr,
diff --git a/fs/namei.c b/fs/namei.c
index 42df664e95e5..db5fe86319e6 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -2497,7 +2497,7 @@ struct dentry *lock_rename(struct dentry *p1, struct dentry *p2)
2497 } 2497 }
2498 2498
2499 mutex_lock_nested(&p1->d_inode->i_mutex, I_MUTEX_PARENT); 2499 mutex_lock_nested(&p1->d_inode->i_mutex, I_MUTEX_PARENT);
2500 mutex_lock_nested(&p2->d_inode->i_mutex, I_MUTEX_CHILD); 2500 mutex_lock_nested(&p2->d_inode->i_mutex, I_MUTEX_PARENT2);
2501 return NULL; 2501 return NULL;
2502} 2502}
2503EXPORT_SYMBOL(lock_rename); 2503EXPORT_SYMBOL(lock_rename);
@@ -3154,7 +3154,8 @@ static int do_tmpfile(int dfd, struct filename *pathname,
3154 if (error) 3154 if (error)
3155 goto out2; 3155 goto out2;
3156 audit_inode(pathname, nd->path.dentry, 0); 3156 audit_inode(pathname, nd->path.dentry, 0);
3157 error = may_open(&nd->path, op->acc_mode, op->open_flag); 3157 /* Don't check for other permissions, the inode was just created */
3158 error = may_open(&nd->path, MAY_OPEN, op->open_flag);
3158 if (error) 3159 if (error)
3159 goto out2; 3160 goto out2;
3160 file->f_path.mnt = nd->path.mnt; 3161 file->f_path.mnt = nd->path.mnt;
diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
index cdeb3cfd6f32..0beb023f25ac 100644
--- a/fs/nfsd/nfs4proc.c
+++ b/fs/nfsd/nfs4proc.c
@@ -1272,7 +1272,8 @@ static bool need_wrongsec_check(struct svc_rqst *rqstp)
1272 */ 1272 */
1273 if (argp->opcnt == resp->opcnt) 1273 if (argp->opcnt == resp->opcnt)
1274 return false; 1274 return false;
1275 1275 if (next->opnum == OP_ILLEGAL)
1276 return false;
1276 nextd = OPDESC(next); 1277 nextd = OPDESC(next);
1277 /* 1278 /*
1278 * Rest of 2.6.3.1.1: certain operations will return WRONGSEC 1279 * Rest of 2.6.3.1.1: certain operations will return WRONGSEC
@@ -1589,7 +1590,8 @@ static inline u32 nfsd4_rename_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op
1589static inline u32 nfsd4_sequence_rsize(struct svc_rqst *rqstp, 1590static inline u32 nfsd4_sequence_rsize(struct svc_rqst *rqstp,
1590 struct nfsd4_op *op) 1591 struct nfsd4_op *op)
1591{ 1592{
1592 return NFS4_MAX_SESSIONID_LEN + 20; 1593 return (op_encode_hdr_size
1594 + XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + 5) * sizeof(__be32);
1593} 1595}
1594 1596
1595static inline u32 nfsd4_setattr_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op) 1597static inline u32 nfsd4_setattr_rsize(struct svc_rqst *rqstp, struct nfsd4_op *op)
@@ -1893,6 +1895,7 @@ static struct nfsd4_operation nfsd4_ops[] = {
1893 .op_func = (nfsd4op_func)nfsd4_sequence, 1895 .op_func = (nfsd4op_func)nfsd4_sequence,
1894 .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_AS_FIRST_OP, 1896 .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_AS_FIRST_OP,
1895 .op_name = "OP_SEQUENCE", 1897 .op_name = "OP_SEQUENCE",
1898 .op_rsize_bop = (nfsd4op_rsize)nfsd4_sequence_rsize,
1896 }, 1899 },
1897 [OP_DESTROY_CLIENTID] = { 1900 [OP_DESTROY_CLIENTID] = {
1898 .op_func = (nfsd4op_func)nfsd4_destroy_clientid, 1901 .op_func = (nfsd4op_func)nfsd4_destroy_clientid,
diff --git a/fs/notify/inode_mark.c b/fs/notify/inode_mark.c
index 9ce062218de9..e8497144b323 100644
--- a/fs/notify/inode_mark.c
+++ b/fs/notify/inode_mark.c
@@ -288,20 +288,25 @@ void fsnotify_unmount_inodes(struct list_head *list)
288 spin_unlock(&inode->i_lock); 288 spin_unlock(&inode->i_lock);
289 289
290 /* In case the dropping of a reference would nuke next_i. */ 290 /* In case the dropping of a reference would nuke next_i. */
291 if ((&next_i->i_sb_list != list) && 291 while (&next_i->i_sb_list != list) {
292 atomic_read(&next_i->i_count)) {
293 spin_lock(&next_i->i_lock); 292 spin_lock(&next_i->i_lock);
294 if (!(next_i->i_state & (I_FREEING | I_WILL_FREE))) { 293 if (!(next_i->i_state & (I_FREEING | I_WILL_FREE)) &&
294 atomic_read(&next_i->i_count)) {
295 __iget(next_i); 295 __iget(next_i);
296 need_iput = next_i; 296 need_iput = next_i;
297 spin_unlock(&next_i->i_lock);
298 break;
297 } 299 }
298 spin_unlock(&next_i->i_lock); 300 spin_unlock(&next_i->i_lock);
301 next_i = list_entry(next_i->i_sb_list.next,
302 struct inode, i_sb_list);
299 } 303 }
300 304
301 /* 305 /*
302 * We can safely drop inode_sb_list_lock here because we hold 306 * We can safely drop inode_sb_list_lock here because either
303 * references on both inode and next_i. Also no new inodes 307 * we actually hold references on both inode and next_i or
304 * will be added since the umount has begun. 308 * end of list. Also no new inodes will be added since the
309 * umount has begun.
305 */ 310 */
306 spin_unlock(&inode_sb_list_lock); 311 spin_unlock(&inode_sb_list_lock);
307 312
diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
index 8add6f1030d7..b931e04e3388 100644
--- a/fs/ocfs2/namei.c
+++ b/fs/ocfs2/namei.c
@@ -158,7 +158,7 @@ bail_add:
158 * NOTE: This dentry already has ->d_op set from 158 * NOTE: This dentry already has ->d_op set from
159 * ocfs2_get_parent() and ocfs2_get_dentry() 159 * ocfs2_get_parent() and ocfs2_get_dentry()
160 */ 160 */
161 if (ret) 161 if (!IS_ERR_OR_NULL(ret))
162 dentry = ret; 162 dentry = ret;
163 163
164 status = ocfs2_dentry_attach_lock(dentry, inode, 164 status = ocfs2_dentry_attach_lock(dentry, inode,
diff --git a/fs/overlayfs/readdir.c b/fs/overlayfs/readdir.c
index 910553f37aca..4e9d7c1fea52 100644
--- a/fs/overlayfs/readdir.c
+++ b/fs/overlayfs/readdir.c
@@ -21,9 +21,10 @@ struct ovl_cache_entry {
21 unsigned int len; 21 unsigned int len;
22 unsigned int type; 22 unsigned int type;
23 u64 ino; 23 u64 ino;
24 bool is_whiteout;
25 struct list_head l_node; 24 struct list_head l_node;
26 struct rb_node node; 25 struct rb_node node;
26 bool is_whiteout;
27 bool is_cursor;
27 char name[]; 28 char name[];
28}; 29};
29 30
@@ -92,6 +93,7 @@ static struct ovl_cache_entry *ovl_cache_entry_new(const char *name, int len,
92 p->type = d_type; 93 p->type = d_type;
93 p->ino = ino; 94 p->ino = ino;
94 p->is_whiteout = false; 95 p->is_whiteout = false;
96 p->is_cursor = false;
95 } 97 }
96 98
97 return p; 99 return p;
@@ -251,7 +253,7 @@ static int ovl_dir_mark_whiteouts(struct dentry *dir,
251 253
252 mutex_lock(&dir->d_inode->i_mutex); 254 mutex_lock(&dir->d_inode->i_mutex);
253 list_for_each_entry(p, rdd->list, l_node) { 255 list_for_each_entry(p, rdd->list, l_node) {
254 if (!p->name) 256 if (p->is_cursor)
255 continue; 257 continue;
256 258
257 if (p->type != DT_CHR) 259 if (p->type != DT_CHR)
@@ -307,7 +309,6 @@ static inline int ovl_dir_read_merged(struct path *upperpath,
307 } 309 }
308out: 310out:
309 return err; 311 return err;
310
311} 312}
312 313
313static void ovl_seek_cursor(struct ovl_dir_file *od, loff_t pos) 314static void ovl_seek_cursor(struct ovl_dir_file *od, loff_t pos)
@@ -316,7 +317,7 @@ static void ovl_seek_cursor(struct ovl_dir_file *od, loff_t pos)
316 loff_t off = 0; 317 loff_t off = 0;
317 318
318 list_for_each_entry(p, &od->cache->entries, l_node) { 319 list_for_each_entry(p, &od->cache->entries, l_node) {
319 if (!p->name) 320 if (p->is_cursor)
320 continue; 321 continue;
321 if (off >= pos) 322 if (off >= pos)
322 break; 323 break;
@@ -389,7 +390,7 @@ static int ovl_iterate(struct file *file, struct dir_context *ctx)
389 390
390 p = list_entry(od->cursor.l_node.next, struct ovl_cache_entry, l_node); 391 p = list_entry(od->cursor.l_node.next, struct ovl_cache_entry, l_node);
391 /* Skip cursors */ 392 /* Skip cursors */
392 if (p->name) { 393 if (!p->is_cursor) {
393 if (!p->is_whiteout) { 394 if (!p->is_whiteout) {
394 if (!dir_emit(ctx, p->name, p->len, p->ino, p->type)) 395 if (!dir_emit(ctx, p->name, p->len, p->ino, p->type))
395 break; 396 break;
@@ -454,12 +455,13 @@ static int ovl_dir_fsync(struct file *file, loff_t start, loff_t end,
454 if (!od->is_upper && ovl_path_type(dentry) == OVL_PATH_MERGE) { 455 if (!od->is_upper && ovl_path_type(dentry) == OVL_PATH_MERGE) {
455 struct inode *inode = file_inode(file); 456 struct inode *inode = file_inode(file);
456 457
457 realfile = od->upperfile; 458 realfile =lockless_dereference(od->upperfile);
458 if (!realfile) { 459 if (!realfile) {
459 struct path upperpath; 460 struct path upperpath;
460 461
461 ovl_path_upper(dentry, &upperpath); 462 ovl_path_upper(dentry, &upperpath);
462 realfile = ovl_path_open(&upperpath, O_RDONLY); 463 realfile = ovl_path_open(&upperpath, O_RDONLY);
464 smp_mb__before_spinlock();
463 mutex_lock(&inode->i_mutex); 465 mutex_lock(&inode->i_mutex);
464 if (!od->upperfile) { 466 if (!od->upperfile) {
465 if (IS_ERR(realfile)) { 467 if (IS_ERR(realfile)) {
@@ -518,6 +520,7 @@ static int ovl_dir_open(struct inode *inode, struct file *file)
518 od->realfile = realfile; 520 od->realfile = realfile;
519 od->is_real = (type != OVL_PATH_MERGE); 521 od->is_real = (type != OVL_PATH_MERGE);
520 od->is_upper = (type != OVL_PATH_LOWER); 522 od->is_upper = (type != OVL_PATH_LOWER);
523 od->cursor.is_cursor = true;
521 file->private_data = od; 524 file->private_data = od;
522 525
523 return 0; 526 return 0;
@@ -569,7 +572,7 @@ void ovl_cleanup_whiteouts(struct dentry *upper, struct list_head *list)
569{ 572{
570 struct ovl_cache_entry *p; 573 struct ovl_cache_entry *p;
571 574
572 mutex_lock_nested(&upper->d_inode->i_mutex, I_MUTEX_PARENT); 575 mutex_lock_nested(&upper->d_inode->i_mutex, I_MUTEX_CHILD);
573 list_for_each_entry(p, list, l_node) { 576 list_for_each_entry(p, list, l_node) {
574 struct dentry *dentry; 577 struct dentry *dentry;
575 578
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
index 8b663b2d9562..6b4527216a7f 100644
--- a/fs/quota/dquot.c
+++ b/fs/quota/dquot.c
@@ -634,7 +634,7 @@ int dquot_writeback_dquots(struct super_block *sb, int type)
634 dqstats_inc(DQST_LOOKUPS); 634 dqstats_inc(DQST_LOOKUPS);
635 err = sb->dq_op->write_dquot(dquot); 635 err = sb->dq_op->write_dquot(dquot);
636 if (!ret && err) 636 if (!ret && err)
637 err = ret; 637 ret = err;
638 dqput(dquot); 638 dqput(dquot);
639 spin_lock(&dq_list_lock); 639 spin_lock(&dq_list_lock);
640 } 640 }
diff --git a/include/drm/drm_pciids.h b/include/drm/drm_pciids.h
index e973540cd15b..2dd405c9be78 100644
--- a/include/drm/drm_pciids.h
+++ b/include/drm/drm_pciids.h
@@ -74,7 +74,6 @@
74 {0x1002, 0x4C64, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV250|RADEON_IS_MOBILITY}, \ 74 {0x1002, 0x4C64, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV250|RADEON_IS_MOBILITY}, \
75 {0x1002, 0x4C66, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV250|RADEON_IS_MOBILITY}, \ 75 {0x1002, 0x4C66, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV250|RADEON_IS_MOBILITY}, \
76 {0x1002, 0x4C67, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV250|RADEON_IS_MOBILITY}, \ 76 {0x1002, 0x4C67, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV250|RADEON_IS_MOBILITY}, \
77 {0x1002, 0x4C6E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV280|RADEON_IS_MOBILITY}, \
78 {0x1002, 0x4E44, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R300}, \ 77 {0x1002, 0x4E44, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R300}, \
79 {0x1002, 0x4E45, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R300}, \ 78 {0x1002, 0x4E45, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R300}, \
80 {0x1002, 0x4E46, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R300}, \ 79 {0x1002, 0x4E46, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R300}, \
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 0207a78a8d82..aac0f9ea952a 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1136,8 +1136,7 @@ static inline bool blk_needs_flush_plug(struct task_struct *tsk)
1136/* 1136/*
1137 * tag stuff 1137 * tag stuff
1138 */ 1138 */
1139#define blk_rq_tagged(rq) \ 1139#define blk_rq_tagged(rq) ((rq)->cmd_flags & REQ_QUEUED)
1140 ((rq)->mq_ctx || ((rq)->cmd_flags & REQ_QUEUED))
1141extern int blk_queue_start_tag(struct request_queue *, struct request *); 1140extern int blk_queue_start_tag(struct request_queue *, struct request *);
1142extern struct request *blk_queue_find_tag(struct request_queue *, int); 1141extern struct request *blk_queue_find_tag(struct request_queue *, int);
1143extern void blk_queue_end_tag(struct request_queue *, struct request *); 1142extern void blk_queue_end_tag(struct request_queue *, struct request *);
@@ -1583,13 +1582,13 @@ static inline bool blk_integrity_merge_rq(struct request_queue *rq,
1583 struct request *r1, 1582 struct request *r1,
1584 struct request *r2) 1583 struct request *r2)
1585{ 1584{
1586 return 0; 1585 return true;
1587} 1586}
1588static inline bool blk_integrity_merge_bio(struct request_queue *rq, 1587static inline bool blk_integrity_merge_bio(struct request_queue *rq,
1589 struct request *r, 1588 struct request *r,
1590 struct bio *b) 1589 struct bio *b)
1591{ 1590{
1592 return 0; 1591 return true;
1593} 1592}
1594static inline bool blk_integrity_is_initialized(struct gendisk *g) 1593static inline bool blk_integrity_is_initialized(struct gendisk *g)
1595{ 1594{
diff --git a/include/linux/cma.h b/include/linux/cma.h
index 0430ed05d3b9..a93438beb33c 100644
--- a/include/linux/cma.h
+++ b/include/linux/cma.h
@@ -18,12 +18,12 @@ struct cma;
18extern phys_addr_t cma_get_base(struct cma *cma); 18extern phys_addr_t cma_get_base(struct cma *cma);
19extern unsigned long cma_get_size(struct cma *cma); 19extern unsigned long cma_get_size(struct cma *cma);
20 20
21extern int __init cma_declare_contiguous(phys_addr_t size, 21extern int __init cma_declare_contiguous(phys_addr_t base,
22 phys_addr_t base, phys_addr_t limit, 22 phys_addr_t size, phys_addr_t limit,
23 phys_addr_t alignment, unsigned int order_per_bit, 23 phys_addr_t alignment, unsigned int order_per_bit,
24 bool fixed, struct cma **res_cma); 24 bool fixed, struct cma **res_cma);
25extern int cma_init_reserved_mem(phys_addr_t size, 25extern int cma_init_reserved_mem(phys_addr_t base,
26 phys_addr_t base, int order_per_bit, 26 phys_addr_t size, int order_per_bit,
27 struct cma **res_cma); 27 struct cma **res_cma);
28extern struct page *cma_alloc(struct cma *cma, int count, unsigned int align); 28extern struct page *cma_alloc(struct cma *cma, int count, unsigned int align);
29extern bool cma_release(struct cma *cma, struct page *pages, int count); 29extern bool cma_release(struct cma *cma, struct page *pages, int count);
diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
index 2507fd2a1eb4..d1a558239b1a 100644
--- a/include/linux/compiler-gcc4.h
+++ b/include/linux/compiler-gcc4.h
@@ -71,7 +71,6 @@
71 * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58670 71 * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58670
72 * 72 *
73 * Work it around via a compiler barrier quirk suggested by Jakub Jelinek. 73 * Work it around via a compiler barrier quirk suggested by Jakub Jelinek.
74 * Fixed in GCC 4.8.2 and later versions.
75 * 74 *
76 * (asm goto is automatically volatile - the naming reflects this.) 75 * (asm goto is automatically volatile - the naming reflects this.)
77 */ 76 */
diff --git a/include/linux/compiler-gcc5.h b/include/linux/compiler-gcc5.h
index cdd1cc202d51..c8c565952548 100644
--- a/include/linux/compiler-gcc5.h
+++ b/include/linux/compiler-gcc5.h
@@ -53,7 +53,6 @@
53 * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58670 53 * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58670
54 * 54 *
55 * Work it around via a compiler barrier quirk suggested by Jakub Jelinek. 55 * Work it around via a compiler barrier quirk suggested by Jakub Jelinek.
56 * Fixed in GCC 4.8.2 and later versions.
57 * 56 *
58 * (asm goto is automatically volatile - the naming reflects this.) 57 * (asm goto is automatically volatile - the naming reflects this.)
59 */ 58 */
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 4e41a4a331bb..9ab779e8a63c 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -639,11 +639,13 @@ static inline int inode_unhashed(struct inode *inode)
639 * 2: child/target 639 * 2: child/target
640 * 3: xattr 640 * 3: xattr
641 * 4: second non-directory 641 * 4: second non-directory
642 * The last is for certain operations (such as rename) which lock two 642 * 5: second parent (when locking independent directories in rename)
643 *
644 * I_MUTEX_NONDIR2 is for certain operations (such as rename) which lock two
643 * non-directories at once. 645 * non-directories at once.
644 * 646 *
645 * The locking order between these classes is 647 * The locking order between these classes is
646 * parent -> child -> normal -> xattr -> second non-directory 648 * parent[2] -> child -> grandchild -> normal -> xattr -> second non-directory
647 */ 649 */
648enum inode_i_mutex_lock_class 650enum inode_i_mutex_lock_class
649{ 651{
@@ -651,7 +653,8 @@ enum inode_i_mutex_lock_class
651 I_MUTEX_PARENT, 653 I_MUTEX_PARENT,
652 I_MUTEX_CHILD, 654 I_MUTEX_CHILD,
653 I_MUTEX_XATTR, 655 I_MUTEX_XATTR,
654 I_MUTEX_NONDIR2 656 I_MUTEX_NONDIR2,
657 I_MUTEX_PARENT2,
655}; 658};
656 659
657void lock_two_nondirectories(struct inode *, struct inode*); 660void lock_two_nondirectories(struct inode *, struct inode*);
@@ -2466,6 +2469,7 @@ extern ssize_t new_sync_read(struct file *filp, char __user *buf, size_t len, lo
2466extern ssize_t new_sync_write(struct file *filp, const char __user *buf, size_t len, loff_t *ppos); 2469extern ssize_t new_sync_write(struct file *filp, const char __user *buf, size_t len, loff_t *ppos);
2467 2470
2468/* fs/block_dev.c */ 2471/* fs/block_dev.c */
2472extern ssize_t blkdev_read_iter(struct kiocb *iocb, struct iov_iter *to);
2469extern ssize_t blkdev_write_iter(struct kiocb *iocb, struct iov_iter *from); 2473extern ssize_t blkdev_write_iter(struct kiocb *iocb, struct iov_iter *from);
2470extern int blkdev_fsync(struct file *filp, loff_t start, loff_t end, 2474extern int blkdev_fsync(struct file *filp, loff_t start, loff_t end,
2471 int datasync); 2475 int datasync);
diff --git a/include/linux/kernel_stat.h b/include/linux/kernel_stat.h
index 8422b4ed6882..b9376cd5a187 100644
--- a/include/linux/kernel_stat.h
+++ b/include/linux/kernel_stat.h
@@ -77,11 +77,6 @@ static inline unsigned int kstat_cpu_irqs_sum(unsigned int cpu)
77 return kstat_cpu(cpu).irqs_sum; 77 return kstat_cpu(cpu).irqs_sum;
78} 78}
79 79
80/*
81 * Lock/unlock the current runqueue - to extract task statistics:
82 */
83extern unsigned long long task_delta_exec(struct task_struct *);
84
85extern void account_user_time(struct task_struct *, cputime_t, cputime_t); 80extern void account_user_time(struct task_struct *, cputime_t, cputime_t);
86extern void account_system_time(struct task_struct *, int, cputime_t, cputime_t); 81extern void account_system_time(struct task_struct *, int, cputime_t, cputime_t);
87extern void account_steal_time(cputime_t); 82extern void account_steal_time(cputime_t);
diff --git a/include/linux/khugepaged.h b/include/linux/khugepaged.h
index 6b394f0b5148..eeb307985715 100644
--- a/include/linux/khugepaged.h
+++ b/include/linux/khugepaged.h
@@ -6,7 +6,8 @@
6#ifdef CONFIG_TRANSPARENT_HUGEPAGE 6#ifdef CONFIG_TRANSPARENT_HUGEPAGE
7extern int __khugepaged_enter(struct mm_struct *mm); 7extern int __khugepaged_enter(struct mm_struct *mm);
8extern void __khugepaged_exit(struct mm_struct *mm); 8extern void __khugepaged_exit(struct mm_struct *mm);
9extern int khugepaged_enter_vma_merge(struct vm_area_struct *vma); 9extern int khugepaged_enter_vma_merge(struct vm_area_struct *vma,
10 unsigned long vm_flags);
10 11
11#define khugepaged_enabled() \ 12#define khugepaged_enabled() \
12 (transparent_hugepage_flags & \ 13 (transparent_hugepage_flags & \
@@ -35,13 +36,13 @@ static inline void khugepaged_exit(struct mm_struct *mm)
35 __khugepaged_exit(mm); 36 __khugepaged_exit(mm);
36} 37}
37 38
38static inline int khugepaged_enter(struct vm_area_struct *vma) 39static inline int khugepaged_enter(struct vm_area_struct *vma,
40 unsigned long vm_flags)
39{ 41{
40 if (!test_bit(MMF_VM_HUGEPAGE, &vma->vm_mm->flags)) 42 if (!test_bit(MMF_VM_HUGEPAGE, &vma->vm_mm->flags))
41 if ((khugepaged_always() || 43 if ((khugepaged_always() ||
42 (khugepaged_req_madv() && 44 (khugepaged_req_madv() && (vm_flags & VM_HUGEPAGE))) &&
43 vma->vm_flags & VM_HUGEPAGE)) && 45 !(vm_flags & VM_NOHUGEPAGE))
44 !(vma->vm_flags & VM_NOHUGEPAGE))
45 if (__khugepaged_enter(vma->vm_mm)) 46 if (__khugepaged_enter(vma->vm_mm))
46 return -ENOMEM; 47 return -ENOMEM;
47 return 0; 48 return 0;
@@ -54,11 +55,13 @@ static inline int khugepaged_fork(struct mm_struct *mm, struct mm_struct *oldmm)
54static inline void khugepaged_exit(struct mm_struct *mm) 55static inline void khugepaged_exit(struct mm_struct *mm)
55{ 56{
56} 57}
57static inline int khugepaged_enter(struct vm_area_struct *vma) 58static inline int khugepaged_enter(struct vm_area_struct *vma,
59 unsigned long vm_flags)
58{ 60{
59 return 0; 61 return 0;
60} 62}
61static inline int khugepaged_enter_vma_merge(struct vm_area_struct *vma) 63static inline int khugepaged_enter_vma_merge(struct vm_area_struct *vma,
64 unsigned long vm_flags)
62{ 65{
63 return 0; 66 return 0;
64} 67}
diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index 19df5d857411..6b75640ef5ab 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -139,48 +139,23 @@ static inline bool mem_cgroup_disabled(void)
139 return false; 139 return false;
140} 140}
141 141
142void __mem_cgroup_begin_update_page_stat(struct page *page, bool *locked, 142struct mem_cgroup *mem_cgroup_begin_page_stat(struct page *page, bool *locked,
143 unsigned long *flags); 143 unsigned long *flags);
144 144void mem_cgroup_end_page_stat(struct mem_cgroup *memcg, bool locked,
145extern atomic_t memcg_moving; 145 unsigned long flags);
146 146void mem_cgroup_update_page_stat(struct mem_cgroup *memcg,
147static inline void mem_cgroup_begin_update_page_stat(struct page *page, 147 enum mem_cgroup_stat_index idx, int val);
148 bool *locked, unsigned long *flags) 148
149{ 149static inline void mem_cgroup_inc_page_stat(struct mem_cgroup *memcg,
150 if (mem_cgroup_disabled())
151 return;
152 rcu_read_lock();
153 *locked = false;
154 if (atomic_read(&memcg_moving))
155 __mem_cgroup_begin_update_page_stat(page, locked, flags);
156}
157
158void __mem_cgroup_end_update_page_stat(struct page *page,
159 unsigned long *flags);
160static inline void mem_cgroup_end_update_page_stat(struct page *page,
161 bool *locked, unsigned long *flags)
162{
163 if (mem_cgroup_disabled())
164 return;
165 if (*locked)
166 __mem_cgroup_end_update_page_stat(page, flags);
167 rcu_read_unlock();
168}
169
170void mem_cgroup_update_page_stat(struct page *page,
171 enum mem_cgroup_stat_index idx,
172 int val);
173
174static inline void mem_cgroup_inc_page_stat(struct page *page,
175 enum mem_cgroup_stat_index idx) 150 enum mem_cgroup_stat_index idx)
176{ 151{
177 mem_cgroup_update_page_stat(page, idx, 1); 152 mem_cgroup_update_page_stat(memcg, idx, 1);
178} 153}
179 154
180static inline void mem_cgroup_dec_page_stat(struct page *page, 155static inline void mem_cgroup_dec_page_stat(struct mem_cgroup *memcg,
181 enum mem_cgroup_stat_index idx) 156 enum mem_cgroup_stat_index idx)
182{ 157{
183 mem_cgroup_update_page_stat(page, idx, -1); 158 mem_cgroup_update_page_stat(memcg, idx, -1);
184} 159}
185 160
186unsigned long mem_cgroup_soft_limit_reclaim(struct zone *zone, int order, 161unsigned long mem_cgroup_soft_limit_reclaim(struct zone *zone, int order,
@@ -315,13 +290,14 @@ mem_cgroup_print_oom_info(struct mem_cgroup *memcg, struct task_struct *p)
315{ 290{
316} 291}
317 292
318static inline void mem_cgroup_begin_update_page_stat(struct page *page, 293static inline struct mem_cgroup *mem_cgroup_begin_page_stat(struct page *page,
319 bool *locked, unsigned long *flags) 294 bool *locked, unsigned long *flags)
320{ 295{
296 return NULL;
321} 297}
322 298
323static inline void mem_cgroup_end_update_page_stat(struct page *page, 299static inline void mem_cgroup_end_page_stat(struct mem_cgroup *memcg,
324 bool *locked, unsigned long *flags) 300 bool locked, unsigned long flags)
325{ 301{
326} 302}
327 303
@@ -343,12 +319,12 @@ static inline bool mem_cgroup_oom_synchronize(bool wait)
343 return false; 319 return false;
344} 320}
345 321
346static inline void mem_cgroup_inc_page_stat(struct page *page, 322static inline void mem_cgroup_inc_page_stat(struct mem_cgroup *memcg,
347 enum mem_cgroup_stat_index idx) 323 enum mem_cgroup_stat_index idx)
348{ 324{
349} 325}
350 326
351static inline void mem_cgroup_dec_page_stat(struct page *page, 327static inline void mem_cgroup_dec_page_stat(struct mem_cgroup *memcg,
352 enum mem_cgroup_stat_index idx) 328 enum mem_cgroup_stat_index idx)
353{ 329{
354} 330}
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 27eb1bfbe704..b46461116cd2 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1235,7 +1235,6 @@ int __set_page_dirty_no_writeback(struct page *page);
1235int redirty_page_for_writepage(struct writeback_control *wbc, 1235int redirty_page_for_writepage(struct writeback_control *wbc,
1236 struct page *page); 1236 struct page *page);
1237void account_page_dirtied(struct page *page, struct address_space *mapping); 1237void account_page_dirtied(struct page *page, struct address_space *mapping);
1238void account_page_writeback(struct page *page);
1239int set_page_dirty(struct page *page); 1238int set_page_dirty(struct page *page);
1240int set_page_dirty_lock(struct page *page); 1239int set_page_dirty_lock(struct page *page);
1241int clear_page_dirty_for_io(struct page *page); 1240int clear_page_dirty_for_io(struct page *page);
diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h
index 9e6294f32ba8..046a0a2e4c4e 100644
--- a/include/linux/mtd/spi-nor.h
+++ b/include/linux/mtd/spi-nor.h
@@ -187,32 +187,17 @@ struct spi_nor {
187/** 187/**
188 * spi_nor_scan() - scan the SPI NOR 188 * spi_nor_scan() - scan the SPI NOR
189 * @nor: the spi_nor structure 189 * @nor: the spi_nor structure
190 * @id: the spi_device_id provided by the driver 190 * @name: the chip type name
191 * @mode: the read mode supported by the driver 191 * @mode: the read mode supported by the driver
192 * 192 *
193 * The drivers can use this fuction to scan the SPI NOR. 193 * The drivers can use this fuction to scan the SPI NOR.
194 * In the scanning, it will try to get all the necessary information to 194 * In the scanning, it will try to get all the necessary information to
195 * fill the mtd_info{} and the spi_nor{}. 195 * fill the mtd_info{} and the spi_nor{}.
196 * 196 *
197 * The board may assigns a spi_device_id with @id which be used to compared with 197 * The chip type name can be provided through the @name parameter.
198 * the spi_device_id detected by the scanning.
199 * 198 *
200 * Return: 0 for success, others for failure. 199 * Return: 0 for success, others for failure.
201 */ 200 */
202int spi_nor_scan(struct spi_nor *nor, const struct spi_device_id *id, 201int spi_nor_scan(struct spi_nor *nor, const char *name, enum read_mode mode);
203 enum read_mode mode);
204extern const struct spi_device_id spi_nor_ids[];
205
206/**
207 * spi_nor_match_id() - find the spi_device_id by the name
208 * @name: the name of the spi_device_id
209 *
210 * The drivers use this function to find the spi_device_id
211 * specified by the @name.
212 *
213 * Return: returns the right spi_device_id pointer on success,
214 * and returns NULL on failure.
215 */
216const struct spi_device_id *spi_nor_match_id(char *name);
217 202
218#endif 203#endif
diff --git a/include/linux/of_reserved_mem.h b/include/linux/of_reserved_mem.h
index 5b5efae09135..ad2f67054372 100644
--- a/include/linux/of_reserved_mem.h
+++ b/include/linux/of_reserved_mem.h
@@ -16,7 +16,7 @@ struct reserved_mem {
16}; 16};
17 17
18struct reserved_mem_ops { 18struct reserved_mem_ops {
19 void (*device_init)(struct reserved_mem *rmem, 19 int (*device_init)(struct reserved_mem *rmem,
20 struct device *dev); 20 struct device *dev);
21 void (*device_release)(struct reserved_mem *rmem, 21 void (*device_release)(struct reserved_mem *rmem,
22 struct device *dev); 22 struct device *dev);
@@ -28,14 +28,17 @@ typedef int (*reservedmem_of_init_fn)(struct reserved_mem *rmem);
28 _OF_DECLARE(reservedmem, name, compat, init, reservedmem_of_init_fn) 28 _OF_DECLARE(reservedmem, name, compat, init, reservedmem_of_init_fn)
29 29
30#ifdef CONFIG_OF_RESERVED_MEM 30#ifdef CONFIG_OF_RESERVED_MEM
31void of_reserved_mem_device_init(struct device *dev); 31int of_reserved_mem_device_init(struct device *dev);
32void of_reserved_mem_device_release(struct device *dev); 32void of_reserved_mem_device_release(struct device *dev);
33 33
34void fdt_init_reserved_mem(void); 34void fdt_init_reserved_mem(void);
35void fdt_reserved_mem_save_node(unsigned long node, const char *uname, 35void fdt_reserved_mem_save_node(unsigned long node, const char *uname,
36 phys_addr_t base, phys_addr_t size); 36 phys_addr_t base, phys_addr_t size);
37#else 37#else
38static inline void of_reserved_mem_device_init(struct device *dev) { } 38static inline int of_reserved_mem_device_init(struct device *dev)
39{
40 return -ENOSYS;
41}
39static inline void of_reserved_mem_device_release(struct device *pdev) { } 42static inline void of_reserved_mem_device_release(struct device *pdev) { }
40 43
41static inline void fdt_init_reserved_mem(void) { } 44static inline void fdt_init_reserved_mem(void) { }
diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
index a4a819ffb2d1..53ff1a752d7e 100644
--- a/include/linux/rcupdate.h
+++ b/include/linux/rcupdate.h
@@ -617,6 +617,21 @@ static inline void rcu_preempt_sleep_check(void)
617#define RCU_INITIALIZER(v) (typeof(*(v)) __force __rcu *)(v) 617#define RCU_INITIALIZER(v) (typeof(*(v)) __force __rcu *)(v)
618 618
619/** 619/**
620 * lockless_dereference() - safely load a pointer for later dereference
621 * @p: The pointer to load
622 *
623 * Similar to rcu_dereference(), but for situations where the pointed-to
624 * object's lifetime is managed by something other than RCU. That
625 * "something other" might be reference counting or simple immortality.
626 */
627#define lockless_dereference(p) \
628({ \
629 typeof(p) _________p1 = ACCESS_ONCE(p); \
630 smp_read_barrier_depends(); /* Dependency order vs. p above. */ \
631 (_________p1); \
632})
633
634/**
620 * rcu_assign_pointer() - assign to RCU-protected pointer 635 * rcu_assign_pointer() - assign to RCU-protected pointer
621 * @p: pointer to assign to 636 * @p: pointer to assign to
622 * @v: value to assign (publish) 637 * @v: value to assign (publish)
diff --git a/include/linux/regulator/consumer.h b/include/linux/regulator/consumer.h
index d347c805f923..f540b1496e2f 100644
--- a/include/linux/regulator/consumer.h
+++ b/include/linux/regulator/consumer.h
@@ -35,6 +35,8 @@
35#ifndef __LINUX_REGULATOR_CONSUMER_H_ 35#ifndef __LINUX_REGULATOR_CONSUMER_H_
36#define __LINUX_REGULATOR_CONSUMER_H_ 36#define __LINUX_REGULATOR_CONSUMER_H_
37 37
38#include <linux/err.h>
39
38struct device; 40struct device;
39struct notifier_block; 41struct notifier_block;
40struct regmap; 42struct regmap;
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index a59d9343c25b..6c8b6f604e76 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -557,7 +557,9 @@ struct sk_buff {
557 /* fields enclosed in headers_start/headers_end are copied 557 /* fields enclosed in headers_start/headers_end are copied
558 * using a single memcpy() in __copy_skb_header() 558 * using a single memcpy() in __copy_skb_header()
559 */ 559 */
560 /* private: */
560 __u32 headers_start[0]; 561 __u32 headers_start[0];
562 /* public: */
561 563
562/* if you move pkt_type around you also must adapt those constants */ 564/* if you move pkt_type around you also must adapt those constants */
563#ifdef __BIG_ENDIAN_BITFIELD 565#ifdef __BIG_ENDIAN_BITFIELD
@@ -642,7 +644,9 @@ struct sk_buff {
642 __u16 network_header; 644 __u16 network_header;
643 __u16 mac_header; 645 __u16 mac_header;
644 646
647 /* private: */
645 __u32 headers_end[0]; 648 __u32 headers_end[0];
649 /* public: */
646 650
647 /* These elements must be at the end, see alloc_skb() for details. */ 651 /* These elements must be at the end, see alloc_skb() for details. */
648 sk_buff_data_t tail; 652 sk_buff_data_t tail;
@@ -795,15 +799,19 @@ struct sk_buff_fclones {
795 * @skb: buffer 799 * @skb: buffer
796 * 800 *
797 * Returns true is skb is a fast clone, and its clone is not freed. 801 * Returns true is skb is a fast clone, and its clone is not freed.
802 * Some drivers call skb_orphan() in their ndo_start_xmit(),
803 * so we also check that this didnt happen.
798 */ 804 */
799static inline bool skb_fclone_busy(const struct sk_buff *skb) 805static inline bool skb_fclone_busy(const struct sock *sk,
806 const struct sk_buff *skb)
800{ 807{
801 const struct sk_buff_fclones *fclones; 808 const struct sk_buff_fclones *fclones;
802 809
803 fclones = container_of(skb, struct sk_buff_fclones, skb1); 810 fclones = container_of(skb, struct sk_buff_fclones, skb1);
804 811
805 return skb->fclone == SKB_FCLONE_ORIG && 812 return skb->fclone == SKB_FCLONE_ORIG &&
806 fclones->skb2.fclone == SKB_FCLONE_CLONE; 813 fclones->skb2.fclone == SKB_FCLONE_CLONE &&
814 fclones->skb2.sk == sk;
807} 815}
808 816
809static inline struct sk_buff *alloc_skb_fclone(unsigned int size, 817static inline struct sk_buff *alloc_skb_fclone(unsigned int size,
diff --git a/include/linux/usb/usbnet.h b/include/linux/usb/usbnet.h
index 26088feb6608..d9a4905e01d0 100644
--- a/include/linux/usb/usbnet.h
+++ b/include/linux/usb/usbnet.h
@@ -78,6 +78,7 @@ struct usbnet {
78# define EVENT_NO_RUNTIME_PM 9 78# define EVENT_NO_RUNTIME_PM 9
79# define EVENT_RX_KILL 10 79# define EVENT_RX_KILL 10
80# define EVENT_LINK_CHANGE 11 80# define EVENT_LINK_CHANGE 11
81# define EVENT_SET_RX_MODE 12
81}; 82};
82 83
83static inline struct usb_driver *driver_of(struct usb_interface *intf) 84static inline struct usb_driver *driver_of(struct usb_interface *intf)
@@ -159,6 +160,9 @@ struct driver_info {
159 /* called by minidriver when receiving indication */ 160 /* called by minidriver when receiving indication */
160 void (*indication)(struct usbnet *dev, void *ind, int indlen); 161 void (*indication)(struct usbnet *dev, void *ind, int indlen);
161 162
163 /* rx mode change (device changes address list filtering) */
164 void (*set_rx_mode)(struct usbnet *dev);
165
162 /* for new devices, use the descriptor-reading code instead */ 166 /* for new devices, use the descriptor-reading code instead */
163 int in; /* rx endpoint */ 167 int in; /* rx endpoint */
164 int out; /* tx endpoint */ 168 int out; /* tx endpoint */
diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index 97f472012438..4292929392b0 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -671,6 +671,8 @@ static inline int ipv6_addr_diff(const struct in6_addr *a1, const struct in6_add
671 return __ipv6_addr_diff(a1, a2, sizeof(struct in6_addr)); 671 return __ipv6_addr_diff(a1, a2, sizeof(struct in6_addr));
672} 672}
673 673
674void ipv6_proxy_select_ident(struct sk_buff *skb);
675
674int ip6_dst_hoplimit(struct dst_entry *dst); 676int ip6_dst_hoplimit(struct dst_entry *dst);
675 677
676static inline int ip6_sk_dst_hoplimit(struct ipv6_pinfo *np, struct flowi6 *fl6, 678static inline int ip6_sk_dst_hoplimit(struct ipv6_pinfo *np, struct flowi6 *fl6,
diff --git a/include/net/netfilter/ipv4/nf_reject.h b/include/net/netfilter/ipv4/nf_reject.h
index e8427193c777..03e928a55229 100644
--- a/include/net/netfilter/ipv4/nf_reject.h
+++ b/include/net/netfilter/ipv4/nf_reject.h
@@ -1,6 +1,8 @@
1#ifndef _IPV4_NF_REJECT_H 1#ifndef _IPV4_NF_REJECT_H
2#define _IPV4_NF_REJECT_H 2#define _IPV4_NF_REJECT_H
3 3
4#include <linux/skbuff.h>
5#include <net/ip.h>
4#include <net/icmp.h> 6#include <net/icmp.h>
5 7
6static inline void nf_send_unreach(struct sk_buff *skb_in, int code) 8static inline void nf_send_unreach(struct sk_buff *skb_in, int code)
@@ -10,4 +12,12 @@ static inline void nf_send_unreach(struct sk_buff *skb_in, int code)
10 12
11void nf_send_reset(struct sk_buff *oldskb, int hook); 13void nf_send_reset(struct sk_buff *oldskb, int hook);
12 14
15const struct tcphdr *nf_reject_ip_tcphdr_get(struct sk_buff *oldskb,
16 struct tcphdr *_oth, int hook);
17struct iphdr *nf_reject_iphdr_put(struct sk_buff *nskb,
18 const struct sk_buff *oldskb,
19 __be16 protocol, int ttl);
20void nf_reject_ip_tcphdr_put(struct sk_buff *nskb, const struct sk_buff *oldskb,
21 const struct tcphdr *oth);
22
13#endif /* _IPV4_NF_REJECT_H */ 23#endif /* _IPV4_NF_REJECT_H */
diff --git a/include/net/netfilter/ipv6/nf_reject.h b/include/net/netfilter/ipv6/nf_reject.h
index 48e18810a9be..23216d48abf9 100644
--- a/include/net/netfilter/ipv6/nf_reject.h
+++ b/include/net/netfilter/ipv6/nf_reject.h
@@ -15,4 +15,14 @@ nf_send_unreach6(struct net *net, struct sk_buff *skb_in, unsigned char code,
15 15
16void nf_send_reset6(struct net *net, struct sk_buff *oldskb, int hook); 16void nf_send_reset6(struct net *net, struct sk_buff *oldskb, int hook);
17 17
18const struct tcphdr *nf_reject_ip6_tcphdr_get(struct sk_buff *oldskb,
19 struct tcphdr *otcph,
20 unsigned int *otcplen, int hook);
21struct ipv6hdr *nf_reject_ip6hdr_put(struct sk_buff *nskb,
22 const struct sk_buff *oldskb,
23 __be16 protocol, int hoplimit);
24void nf_reject_ip6_tcphdr_put(struct sk_buff *nskb,
25 const struct sk_buff *oldskb,
26 const struct tcphdr *oth, unsigned int otcplen);
27
18#endif /* _IPV6_NF_REJECT_H */ 28#endif /* _IPV6_NF_REJECT_H */
diff --git a/include/net/netfilter/nf_tables.h b/include/net/netfilter/nf_tables.h
index 3d7292392fac..845c596bf594 100644
--- a/include/net/netfilter/nf_tables.h
+++ b/include/net/netfilter/nf_tables.h
@@ -530,6 +530,9 @@ enum nft_chain_type {
530 NFT_CHAIN_T_MAX 530 NFT_CHAIN_T_MAX
531}; 531};
532 532
533int nft_chain_validate_dependency(const struct nft_chain *chain,
534 enum nft_chain_type type);
535
533struct nft_stats { 536struct nft_stats {
534 u64 bytes; 537 u64 bytes;
535 u64 pkts; 538 u64 pkts;
diff --git a/include/net/netfilter/nft_masq.h b/include/net/netfilter/nft_masq.h
index c72729f954f4..e2a518b60e19 100644
--- a/include/net/netfilter/nft_masq.h
+++ b/include/net/netfilter/nft_masq.h
@@ -13,4 +13,7 @@ int nft_masq_init(const struct nft_ctx *ctx,
13 13
14int nft_masq_dump(struct sk_buff *skb, const struct nft_expr *expr); 14int nft_masq_dump(struct sk_buff *skb, const struct nft_expr *expr);
15 15
16int nft_masq_validate(const struct nft_ctx *ctx, const struct nft_expr *expr,
17 const struct nft_data **data);
18
16#endif /* _NFT_MASQ_H_ */ 19#endif /* _NFT_MASQ_H_ */
diff --git a/include/scsi/scsi_tcq.h b/include/scsi/scsi_tcq.h
index e64583560701..56ed843969ca 100644
--- a/include/scsi/scsi_tcq.h
+++ b/include/scsi/scsi_tcq.h
@@ -67,8 +67,9 @@ static inline void scsi_activate_tcq(struct scsi_device *sdev, int depth)
67 if (!sdev->tagged_supported) 67 if (!sdev->tagged_supported)
68 return; 68 return;
69 69
70 if (!shost_use_blk_mq(sdev->host) && 70 if (shost_use_blk_mq(sdev->host))
71 !blk_queue_tagged(sdev->request_queue)) 71 queue_flag_set_unlocked(QUEUE_FLAG_QUEUED, sdev->request_queue);
72 else if (!blk_queue_tagged(sdev->request_queue))
72 blk_queue_init_tags(sdev->request_queue, depth, 73 blk_queue_init_tags(sdev->request_queue, depth,
73 sdev->host->bqt); 74 sdev->host->bqt);
74 75
@@ -81,8 +82,7 @@ static inline void scsi_activate_tcq(struct scsi_device *sdev, int depth)
81 **/ 82 **/
82static inline void scsi_deactivate_tcq(struct scsi_device *sdev, int depth) 83static inline void scsi_deactivate_tcq(struct scsi_device *sdev, int depth)
83{ 84{
84 if (!shost_use_blk_mq(sdev->host) && 85 if (blk_queue_tagged(sdev->request_queue))
85 blk_queue_tagged(sdev->request_queue))
86 blk_queue_free_tags(sdev->request_queue); 86 blk_queue_free_tags(sdev->request_queue);
87 scsi_adjust_queue_depth(sdev, 0, depth); 87 scsi_adjust_queue_depth(sdev, 0, depth);
88} 88}
diff --git a/include/trace/events/rcu.h b/include/trace/events/rcu.h
index 9b56f37148cf..e335e7d8c6c2 100644
--- a/include/trace/events/rcu.h
+++ b/include/trace/events/rcu.h
@@ -660,18 +660,18 @@ TRACE_EVENT(rcu_torture_read,
660/* 660/*
661 * Tracepoint for _rcu_barrier() execution. The string "s" describes 661 * Tracepoint for _rcu_barrier() execution. The string "s" describes
662 * the _rcu_barrier phase: 662 * the _rcu_barrier phase:
663 * "Begin": rcu_barrier_callback() started. 663 * "Begin": _rcu_barrier() started.
664 * "Check": rcu_barrier_callback() checking for piggybacking. 664 * "Check": _rcu_barrier() checking for piggybacking.
665 * "EarlyExit": rcu_barrier_callback() piggybacked, thus early exit. 665 * "EarlyExit": _rcu_barrier() piggybacked, thus early exit.
666 * "Inc1": rcu_barrier_callback() piggyback check counter incremented. 666 * "Inc1": _rcu_barrier() piggyback check counter incremented.
667 * "Offline": rcu_barrier_callback() found offline CPU 667 * "OfflineNoCB": _rcu_barrier() found callback on never-online CPU
668 * "OnlineNoCB": rcu_barrier_callback() found online no-CBs CPU. 668 * "OnlineNoCB": _rcu_barrier() found online no-CBs CPU.
669 * "OnlineQ": rcu_barrier_callback() found online CPU with callbacks. 669 * "OnlineQ": _rcu_barrier() found online CPU with callbacks.
670 * "OnlineNQ": rcu_barrier_callback() found online CPU, no callbacks. 670 * "OnlineNQ": _rcu_barrier() found online CPU, no callbacks.
671 * "IRQ": An rcu_barrier_callback() callback posted on remote CPU. 671 * "IRQ": An rcu_barrier_callback() callback posted on remote CPU.
672 * "CB": An rcu_barrier_callback() invoked a callback, not the last. 672 * "CB": An rcu_barrier_callback() invoked a callback, not the last.
673 * "LastCB": An rcu_barrier_callback() invoked the last callback. 673 * "LastCB": An rcu_barrier_callback() invoked the last callback.
674 * "Inc2": rcu_barrier_callback() piggyback check counter incremented. 674 * "Inc2": _rcu_barrier() piggyback check counter incremented.
675 * The "cpu" argument is the CPU or -1 if meaningless, the "cnt" argument 675 * The "cpu" argument is the CPU or -1 if meaningless, the "cnt" argument
676 * is the count of remaining callbacks, and "done" is the piggybacking count. 676 * is the count of remaining callbacks, and "done" is the piggybacking count.
677 */ 677 */
diff --git a/include/uapi/linux/input.h b/include/uapi/linux/input.h
index 1874ebe9ac1e..a1d7e931ab72 100644
--- a/include/uapi/linux/input.h
+++ b/include/uapi/linux/input.h
@@ -739,6 +739,13 @@ struct input_keymap_entry {
739#define KEY_BRIGHTNESS_MIN 0x250 /* Set Brightness to Minimum */ 739#define KEY_BRIGHTNESS_MIN 0x250 /* Set Brightness to Minimum */
740#define KEY_BRIGHTNESS_MAX 0x251 /* Set Brightness to Maximum */ 740#define KEY_BRIGHTNESS_MAX 0x251 /* Set Brightness to Maximum */
741 741
742#define KEY_KBDINPUTASSIST_PREV 0x260
743#define KEY_KBDINPUTASSIST_NEXT 0x261
744#define KEY_KBDINPUTASSIST_PREVGROUP 0x262
745#define KEY_KBDINPUTASSIST_NEXTGROUP 0x263
746#define KEY_KBDINPUTASSIST_ACCEPT 0x264
747#define KEY_KBDINPUTASSIST_CANCEL 0x265
748
742#define BTN_TRIGGER_HAPPY 0x2c0 749#define BTN_TRIGGER_HAPPY 0x2c0
743#define BTN_TRIGGER_HAPPY1 0x2c0 750#define BTN_TRIGGER_HAPPY1 0x2c0
744#define BTN_TRIGGER_HAPPY2 0x2c1 751#define BTN_TRIGGER_HAPPY2 0x2c1
diff --git a/include/uapi/linux/perf_event.h b/include/uapi/linux/perf_event.h
index 9269de254874..9d845404d875 100644
--- a/include/uapi/linux/perf_event.h
+++ b/include/uapi/linux/perf_event.h
@@ -364,7 +364,7 @@ struct perf_event_mmap_page {
364 /* 364 /*
365 * Bits needed to read the hw events in user-space. 365 * Bits needed to read the hw events in user-space.
366 * 366 *
367 * u32 seq, time_mult, time_shift, idx, width; 367 * u32 seq, time_mult, time_shift, index, width;
368 * u64 count, enabled, running; 368 * u64 count, enabled, running;
369 * u64 cyc, time_offset; 369 * u64 cyc, time_offset;
370 * s64 pmc = 0; 370 * s64 pmc = 0;
@@ -383,11 +383,11 @@ struct perf_event_mmap_page {
383 * time_shift = pc->time_shift; 383 * time_shift = pc->time_shift;
384 * } 384 * }
385 * 385 *
386 * idx = pc->index; 386 * index = pc->index;
387 * count = pc->offset; 387 * count = pc->offset;
388 * if (pc->cap_usr_rdpmc && idx) { 388 * if (pc->cap_user_rdpmc && index) {
389 * width = pc->pmc_width; 389 * width = pc->pmc_width;
390 * pmc = rdpmc(idx - 1); 390 * pmc = rdpmc(index - 1);
391 * } 391 * }
392 * 392 *
393 * barrier(); 393 * barrier();
@@ -415,7 +415,7 @@ struct perf_event_mmap_page {
415 }; 415 };
416 416
417 /* 417 /*
418 * If cap_usr_rdpmc this field provides the bit-width of the value 418 * If cap_user_rdpmc this field provides the bit-width of the value
419 * read using the rdpmc() or equivalent instruction. This can be used 419 * read using the rdpmc() or equivalent instruction. This can be used
420 * to sign extend the result like: 420 * to sign extend the result like:
421 * 421 *
@@ -439,10 +439,10 @@ struct perf_event_mmap_page {
439 * 439 *
440 * Where time_offset,time_mult,time_shift and cyc are read in the 440 * Where time_offset,time_mult,time_shift and cyc are read in the
441 * seqcount loop described above. This delta can then be added to 441 * seqcount loop described above. This delta can then be added to
442 * enabled and possible running (if idx), improving the scaling: 442 * enabled and possible running (if index), improving the scaling:
443 * 443 *
444 * enabled += delta; 444 * enabled += delta;
445 * if (idx) 445 * if (index)
446 * running += delta; 446 * running += delta;
447 * 447 *
448 * quot = count / running; 448 * quot = count / running;
diff --git a/include/uapi/linux/v4l2-dv-timings.h b/include/uapi/linux/v4l2-dv-timings.h
index 6a0764c89fcb..6c8f159e416e 100644
--- a/include/uapi/linux/v4l2-dv-timings.h
+++ b/include/uapi/linux/v4l2-dv-timings.h
@@ -21,8 +21,17 @@
21#ifndef _V4L2_DV_TIMINGS_H 21#ifndef _V4L2_DV_TIMINGS_H
22#define _V4L2_DV_TIMINGS_H 22#define _V4L2_DV_TIMINGS_H
23 23
24#if __GNUC__ < 4 || (__GNUC__ == 4 && (__GNUC_MINOR__ < 6))
25/* Sadly gcc versions older than 4.6 have a bug in how they initialize
26 anonymous unions where they require additional curly brackets.
27 This violates the C1x standard. This workaround adds the curly brackets
28 if needed. */
24#define V4L2_INIT_BT_TIMINGS(_width, args...) \ 29#define V4L2_INIT_BT_TIMINGS(_width, args...) \
25 { .bt = { _width , ## args } } 30 { .bt = { _width , ## args } }
31#else
32#define V4L2_INIT_BT_TIMINGS(_width, args...) \
33 .bt = { _width , ## args }
34#endif
26 35
27/* CEA-861-E timings (i.e. standard HDTV timings) */ 36/* CEA-861-E timings (i.e. standard HDTV timings) */
28 37
diff --git a/init/Kconfig b/init/Kconfig
index 3ee28ae02cc8..2081a4d3d917 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1341,6 +1341,10 @@ config SYSCTL_ARCH_UNALIGN_ALLOW
1341config HAVE_PCSPKR_PLATFORM 1341config HAVE_PCSPKR_PLATFORM
1342 bool 1342 bool
1343 1343
1344# interpreter that classic socket filters depend on
1345config BPF
1346 bool
1347
1344menuconfig EXPERT 1348menuconfig EXPERT
1345 bool "Configure standard kernel features (expert users)" 1349 bool "Configure standard kernel features (expert users)"
1346 # Unhide debug options, to make the on-by-default options visible 1350 # Unhide debug options, to make the on-by-default options visible
@@ -1521,6 +1525,16 @@ config EVENTFD
1521 1525
1522 If unsure, say Y. 1526 If unsure, say Y.
1523 1527
1528# syscall, maps, verifier
1529config BPF_SYSCALL
1530 bool "Enable bpf() system call" if EXPERT
1531 select ANON_INODES
1532 select BPF
1533 default n
1534 help
1535 Enable the bpf() system call that allows to manipulate eBPF
1536 programs and maps via file descriptors.
1537
1524config SHMEM 1538config SHMEM
1525 bool "Use full shmem filesystem" if EXPERT 1539 bool "Use full shmem filesystem" if EXPERT
1526 default y 1540 default y
diff --git a/kernel/Makefile b/kernel/Makefile
index dc5c77544fd6..17ea6d4a9a24 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -86,7 +86,7 @@ obj-$(CONFIG_RING_BUFFER) += trace/
86obj-$(CONFIG_TRACEPOINTS) += trace/ 86obj-$(CONFIG_TRACEPOINTS) += trace/
87obj-$(CONFIG_IRQ_WORK) += irq_work.o 87obj-$(CONFIG_IRQ_WORK) += irq_work.o
88obj-$(CONFIG_CPU_PM) += cpu_pm.o 88obj-$(CONFIG_CPU_PM) += cpu_pm.o
89obj-$(CONFIG_NET) += bpf/ 89obj-$(CONFIG_BPF) += bpf/
90 90
91obj-$(CONFIG_PERF_EVENTS) += events/ 91obj-$(CONFIG_PERF_EVENTS) += events/
92 92
diff --git a/kernel/bpf/Makefile b/kernel/bpf/Makefile
index 45427239f375..0daf7f6ae7df 100644
--- a/kernel/bpf/Makefile
+++ b/kernel/bpf/Makefile
@@ -1,5 +1,5 @@
1obj-y := core.o syscall.o verifier.o 1obj-y := core.o
2 2obj-$(CONFIG_BPF_SYSCALL) += syscall.o verifier.o
3ifdef CONFIG_TEST_BPF 3ifdef CONFIG_TEST_BPF
4obj-y += test_stub.o 4obj-$(CONFIG_BPF_SYSCALL) += test_stub.o
5endif 5endif
diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
index f0c30c59b317..d6594e457a25 100644
--- a/kernel/bpf/core.c
+++ b/kernel/bpf/core.c
@@ -655,3 +655,12 @@ void bpf_prog_free(struct bpf_prog *fp)
655 schedule_work(&aux->work); 655 schedule_work(&aux->work);
656} 656}
657EXPORT_SYMBOL_GPL(bpf_prog_free); 657EXPORT_SYMBOL_GPL(bpf_prog_free);
658
659/* To execute LD_ABS/LD_IND instructions __bpf_prog_run() may call
660 * skb_copy_bits(), so provide a weak definition of it for NET-less config.
661 */
662int __weak skb_copy_bits(const struct sk_buff *skb, int offset, void *to,
663 int len)
664{
665 return -EFAULT;
666}
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 801f5f3b9307..9f81818f2941 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -1409,7 +1409,8 @@ static bool states_equal(struct verifier_state *old, struct verifier_state *cur)
1409 if (memcmp(&old->regs[i], &cur->regs[i], 1409 if (memcmp(&old->regs[i], &cur->regs[i],
1410 sizeof(old->regs[0])) != 0) { 1410 sizeof(old->regs[0])) != 0) {
1411 if (old->regs[i].type == NOT_INIT || 1411 if (old->regs[i].type == NOT_INIT ||
1412 old->regs[i].type == UNKNOWN_VALUE) 1412 (old->regs[i].type == UNKNOWN_VALUE &&
1413 cur->regs[i].type != NOT_INIT))
1413 continue; 1414 continue;
1414 return false; 1415 return false;
1415 } 1416 }
diff --git a/kernel/cpu.c b/kernel/cpu.c
index 356450f09c1f..90a3d017b90c 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -64,6 +64,8 @@ static struct {
64 * an ongoing cpu hotplug operation. 64 * an ongoing cpu hotplug operation.
65 */ 65 */
66 int refcount; 66 int refcount;
67 /* And allows lockless put_online_cpus(). */
68 atomic_t puts_pending;
67 69
68#ifdef CONFIG_DEBUG_LOCK_ALLOC 70#ifdef CONFIG_DEBUG_LOCK_ALLOC
69 struct lockdep_map dep_map; 71 struct lockdep_map dep_map;
@@ -113,7 +115,11 @@ void put_online_cpus(void)
113{ 115{
114 if (cpu_hotplug.active_writer == current) 116 if (cpu_hotplug.active_writer == current)
115 return; 117 return;
116 mutex_lock(&cpu_hotplug.lock); 118 if (!mutex_trylock(&cpu_hotplug.lock)) {
119 atomic_inc(&cpu_hotplug.puts_pending);
120 cpuhp_lock_release();
121 return;
122 }
117 123
118 if (WARN_ON(!cpu_hotplug.refcount)) 124 if (WARN_ON(!cpu_hotplug.refcount))
119 cpu_hotplug.refcount++; /* try to fix things up */ 125 cpu_hotplug.refcount++; /* try to fix things up */
@@ -155,6 +161,12 @@ void cpu_hotplug_begin(void)
155 cpuhp_lock_acquire(); 161 cpuhp_lock_acquire();
156 for (;;) { 162 for (;;) {
157 mutex_lock(&cpu_hotplug.lock); 163 mutex_lock(&cpu_hotplug.lock);
164 if (atomic_read(&cpu_hotplug.puts_pending)) {
165 int delta;
166
167 delta = atomic_xchg(&cpu_hotplug.puts_pending, 0);
168 cpu_hotplug.refcount -= delta;
169 }
158 if (likely(!cpu_hotplug.refcount)) 170 if (likely(!cpu_hotplug.refcount))
159 break; 171 break;
160 __set_current_state(TASK_UNINTERRUPTIBLE); 172 __set_current_state(TASK_UNINTERRUPTIBLE);
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 1425d07018de..2b02c9fda790 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -6071,11 +6071,6 @@ static int perf_swevent_init(struct perf_event *event)
6071 return 0; 6071 return 0;
6072} 6072}
6073 6073
6074static int perf_swevent_event_idx(struct perf_event *event)
6075{
6076 return 0;
6077}
6078
6079static struct pmu perf_swevent = { 6074static struct pmu perf_swevent = {
6080 .task_ctx_nr = perf_sw_context, 6075 .task_ctx_nr = perf_sw_context,
6081 6076
@@ -6085,8 +6080,6 @@ static struct pmu perf_swevent = {
6085 .start = perf_swevent_start, 6080 .start = perf_swevent_start,
6086 .stop = perf_swevent_stop, 6081 .stop = perf_swevent_stop,
6087 .read = perf_swevent_read, 6082 .read = perf_swevent_read,
6088
6089 .event_idx = perf_swevent_event_idx,
6090}; 6083};
6091 6084
6092#ifdef CONFIG_EVENT_TRACING 6085#ifdef CONFIG_EVENT_TRACING
@@ -6204,8 +6197,6 @@ static struct pmu perf_tracepoint = {
6204 .start = perf_swevent_start, 6197 .start = perf_swevent_start,
6205 .stop = perf_swevent_stop, 6198 .stop = perf_swevent_stop,
6206 .read = perf_swevent_read, 6199 .read = perf_swevent_read,
6207
6208 .event_idx = perf_swevent_event_idx,
6209}; 6200};
6210 6201
6211static inline void perf_tp_register(void) 6202static inline void perf_tp_register(void)
@@ -6431,8 +6422,6 @@ static struct pmu perf_cpu_clock = {
6431 .start = cpu_clock_event_start, 6422 .start = cpu_clock_event_start,
6432 .stop = cpu_clock_event_stop, 6423 .stop = cpu_clock_event_stop,
6433 .read = cpu_clock_event_read, 6424 .read = cpu_clock_event_read,
6434
6435 .event_idx = perf_swevent_event_idx,
6436}; 6425};
6437 6426
6438/* 6427/*
@@ -6511,8 +6500,6 @@ static struct pmu perf_task_clock = {
6511 .start = task_clock_event_start, 6500 .start = task_clock_event_start,
6512 .stop = task_clock_event_stop, 6501 .stop = task_clock_event_stop,
6513 .read = task_clock_event_read, 6502 .read = task_clock_event_read,
6514
6515 .event_idx = perf_swevent_event_idx,
6516}; 6503};
6517 6504
6518static void perf_pmu_nop_void(struct pmu *pmu) 6505static void perf_pmu_nop_void(struct pmu *pmu)
@@ -6542,7 +6529,7 @@ static void perf_pmu_cancel_txn(struct pmu *pmu)
6542 6529
6543static int perf_event_idx_default(struct perf_event *event) 6530static int perf_event_idx_default(struct perf_event *event)
6544{ 6531{
6545 return event->hw.idx + 1; 6532 return 0;
6546} 6533}
6547 6534
6548/* 6535/*
diff --git a/kernel/events/hw_breakpoint.c b/kernel/events/hw_breakpoint.c
index 1559fb0b9296..9803a6600d49 100644
--- a/kernel/events/hw_breakpoint.c
+++ b/kernel/events/hw_breakpoint.c
@@ -605,11 +605,6 @@ static void hw_breakpoint_stop(struct perf_event *bp, int flags)
605 bp->hw.state = PERF_HES_STOPPED; 605 bp->hw.state = PERF_HES_STOPPED;
606} 606}
607 607
608static int hw_breakpoint_event_idx(struct perf_event *bp)
609{
610 return 0;
611}
612
613static struct pmu perf_breakpoint = { 608static struct pmu perf_breakpoint = {
614 .task_ctx_nr = perf_sw_context, /* could eventually get its own */ 609 .task_ctx_nr = perf_sw_context, /* could eventually get its own */
615 610
@@ -619,8 +614,6 @@ static struct pmu perf_breakpoint = {
619 .start = hw_breakpoint_start, 614 .start = hw_breakpoint_start,
620 .stop = hw_breakpoint_stop, 615 .stop = hw_breakpoint_stop,
621 .read = hw_breakpoint_pmu_read, 616 .read = hw_breakpoint_pmu_read,
622
623 .event_idx = hw_breakpoint_event_idx,
624}; 617};
625 618
626int __init init_hw_breakpoint(void) 619int __init init_hw_breakpoint(void)
diff --git a/kernel/futex.c b/kernel/futex.c
index f3a3a071283c..63678b573d61 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -143,9 +143,8 @@
143 * 143 *
144 * Where (A) orders the waiters increment and the futex value read through 144 * Where (A) orders the waiters increment and the futex value read through
145 * atomic operations (see hb_waiters_inc) and where (B) orders the write 145 * atomic operations (see hb_waiters_inc) and where (B) orders the write
146 * to futex and the waiters read -- this is done by the barriers in 146 * to futex and the waiters read -- this is done by the barriers for both
147 * get_futex_key_refs(), through either ihold or atomic_inc, depending on the 147 * shared and private futexes in get_futex_key_refs().
148 * futex type.
149 * 148 *
150 * This yields the following case (where X:=waiters, Y:=futex): 149 * This yields the following case (where X:=waiters, Y:=futex):
151 * 150 *
@@ -344,13 +343,20 @@ static void get_futex_key_refs(union futex_key *key)
344 futex_get_mm(key); /* implies MB (B) */ 343 futex_get_mm(key); /* implies MB (B) */
345 break; 344 break;
346 default: 345 default:
346 /*
347 * Private futexes do not hold reference on an inode or
348 * mm, therefore the only purpose of calling get_futex_key_refs
349 * is because we need the barrier for the lockless waiter check.
350 */
347 smp_mb(); /* explicit MB (B) */ 351 smp_mb(); /* explicit MB (B) */
348 } 352 }
349} 353}
350 354
351/* 355/*
352 * Drop a reference to the resource addressed by a key. 356 * Drop a reference to the resource addressed by a key.
353 * The hash bucket spinlock must not be held. 357 * The hash bucket spinlock must not be held. This is
358 * a no-op for private futexes, see comment in the get
359 * counterpart.
354 */ 360 */
355static void drop_futex_key_refs(union futex_key *key) 361static void drop_futex_key_refs(union futex_key *key)
356{ 362{
@@ -641,8 +647,14 @@ static struct futex_pi_state * alloc_pi_state(void)
641 return pi_state; 647 return pi_state;
642} 648}
643 649
650/*
651 * Must be called with the hb lock held.
652 */
644static void free_pi_state(struct futex_pi_state *pi_state) 653static void free_pi_state(struct futex_pi_state *pi_state)
645{ 654{
655 if (!pi_state)
656 return;
657
646 if (!atomic_dec_and_test(&pi_state->refcount)) 658 if (!atomic_dec_and_test(&pi_state->refcount))
647 return; 659 return;
648 660
@@ -1521,15 +1533,6 @@ static int futex_requeue(u32 __user *uaddr1, unsigned int flags,
1521 } 1533 }
1522 1534
1523retry: 1535retry:
1524 if (pi_state != NULL) {
1525 /*
1526 * We will have to lookup the pi_state again, so free this one
1527 * to keep the accounting correct.
1528 */
1529 free_pi_state(pi_state);
1530 pi_state = NULL;
1531 }
1532
1533 ret = get_futex_key(uaddr1, flags & FLAGS_SHARED, &key1, VERIFY_READ); 1536 ret = get_futex_key(uaddr1, flags & FLAGS_SHARED, &key1, VERIFY_READ);
1534 if (unlikely(ret != 0)) 1537 if (unlikely(ret != 0))
1535 goto out; 1538 goto out;
@@ -1619,6 +1622,8 @@ retry_private:
1619 case 0: 1622 case 0:
1620 break; 1623 break;
1621 case -EFAULT: 1624 case -EFAULT:
1625 free_pi_state(pi_state);
1626 pi_state = NULL;
1622 double_unlock_hb(hb1, hb2); 1627 double_unlock_hb(hb1, hb2);
1623 hb_waiters_dec(hb2); 1628 hb_waiters_dec(hb2);
1624 put_futex_key(&key2); 1629 put_futex_key(&key2);
@@ -1634,6 +1639,8 @@ retry_private:
1634 * exit to complete. 1639 * exit to complete.
1635 * - The user space value changed. 1640 * - The user space value changed.
1636 */ 1641 */
1642 free_pi_state(pi_state);
1643 pi_state = NULL;
1637 double_unlock_hb(hb1, hb2); 1644 double_unlock_hb(hb1, hb2);
1638 hb_waiters_dec(hb2); 1645 hb_waiters_dec(hb2);
1639 put_futex_key(&key2); 1646 put_futex_key(&key2);
@@ -1710,6 +1717,7 @@ retry_private:
1710 } 1717 }
1711 1718
1712out_unlock: 1719out_unlock:
1720 free_pi_state(pi_state);
1713 double_unlock_hb(hb1, hb2); 1721 double_unlock_hb(hb1, hb2);
1714 hb_waiters_dec(hb2); 1722 hb_waiters_dec(hb2);
1715 1723
@@ -1727,8 +1735,6 @@ out_put_keys:
1727out_put_key1: 1735out_put_key1:
1728 put_futex_key(&key1); 1736 put_futex_key(&key1);
1729out: 1737out:
1730 if (pi_state != NULL)
1731 free_pi_state(pi_state);
1732 return ret ? ret : task_count; 1738 return ret ? ret : task_count;
1733} 1739}
1734 1740
diff --git a/kernel/gcov/Kconfig b/kernel/gcov/Kconfig
index cf66c5c8458e..3b7408759bdf 100644
--- a/kernel/gcov/Kconfig
+++ b/kernel/gcov/Kconfig
@@ -35,7 +35,7 @@ config GCOV_KERNEL
35config GCOV_PROFILE_ALL 35config GCOV_PROFILE_ALL
36 bool "Profile entire Kernel" 36 bool "Profile entire Kernel"
37 depends on GCOV_KERNEL 37 depends on GCOV_KERNEL
38 depends on SUPERH || S390 || X86 || PPC || MICROBLAZE || ARM 38 depends on SUPERH || S390 || X86 || PPC || MICROBLAZE || ARM || ARM64
39 default n 39 default n
40 ---help--- 40 ---help---
41 This options activates profiling for the entire kernel. 41 This options activates profiling for the entire kernel.
diff --git a/kernel/kmod.c b/kernel/kmod.c
index 8637e041a247..80f7a6d00519 100644
--- a/kernel/kmod.c
+++ b/kernel/kmod.c
@@ -196,12 +196,34 @@ int __request_module(bool wait, const char *fmt, ...)
196EXPORT_SYMBOL(__request_module); 196EXPORT_SYMBOL(__request_module);
197#endif /* CONFIG_MODULES */ 197#endif /* CONFIG_MODULES */
198 198
199static void call_usermodehelper_freeinfo(struct subprocess_info *info)
200{
201 if (info->cleanup)
202 (*info->cleanup)(info);
203 kfree(info);
204}
205
206static void umh_complete(struct subprocess_info *sub_info)
207{
208 struct completion *comp = xchg(&sub_info->complete, NULL);
209 /*
210 * See call_usermodehelper_exec(). If xchg() returns NULL
211 * we own sub_info, the UMH_KILLABLE caller has gone away
212 * or the caller used UMH_NO_WAIT.
213 */
214 if (comp)
215 complete(comp);
216 else
217 call_usermodehelper_freeinfo(sub_info);
218}
219
199/* 220/*
200 * This is the task which runs the usermode application 221 * This is the task which runs the usermode application
201 */ 222 */
202static int ____call_usermodehelper(void *data) 223static int ____call_usermodehelper(void *data)
203{ 224{
204 struct subprocess_info *sub_info = data; 225 struct subprocess_info *sub_info = data;
226 int wait = sub_info->wait & ~UMH_KILLABLE;
205 struct cred *new; 227 struct cred *new;
206 int retval; 228 int retval;
207 229
@@ -221,7 +243,7 @@ static int ____call_usermodehelper(void *data)
221 retval = -ENOMEM; 243 retval = -ENOMEM;
222 new = prepare_kernel_cred(current); 244 new = prepare_kernel_cred(current);
223 if (!new) 245 if (!new)
224 goto fail; 246 goto out;
225 247
226 spin_lock(&umh_sysctl_lock); 248 spin_lock(&umh_sysctl_lock);
227 new->cap_bset = cap_intersect(usermodehelper_bset, new->cap_bset); 249 new->cap_bset = cap_intersect(usermodehelper_bset, new->cap_bset);
@@ -233,7 +255,7 @@ static int ____call_usermodehelper(void *data)
233 retval = sub_info->init(sub_info, new); 255 retval = sub_info->init(sub_info, new);
234 if (retval) { 256 if (retval) {
235 abort_creds(new); 257 abort_creds(new);
236 goto fail; 258 goto out;
237 } 259 }
238 } 260 }
239 261
@@ -242,12 +264,13 @@ static int ____call_usermodehelper(void *data)
242 retval = do_execve(getname_kernel(sub_info->path), 264 retval = do_execve(getname_kernel(sub_info->path),
243 (const char __user *const __user *)sub_info->argv, 265 (const char __user *const __user *)sub_info->argv,
244 (const char __user *const __user *)sub_info->envp); 266 (const char __user *const __user *)sub_info->envp);
267out:
268 sub_info->retval = retval;
269 /* wait_for_helper() will call umh_complete if UHM_WAIT_PROC. */
270 if (wait != UMH_WAIT_PROC)
271 umh_complete(sub_info);
245 if (!retval) 272 if (!retval)
246 return 0; 273 return 0;
247
248 /* Exec failed? */
249fail:
250 sub_info->retval = retval;
251 do_exit(0); 274 do_exit(0);
252} 275}
253 276
@@ -258,26 +281,6 @@ static int call_helper(void *data)
258 return ____call_usermodehelper(data); 281 return ____call_usermodehelper(data);
259} 282}
260 283
261static void call_usermodehelper_freeinfo(struct subprocess_info *info)
262{
263 if (info->cleanup)
264 (*info->cleanup)(info);
265 kfree(info);
266}
267
268static void umh_complete(struct subprocess_info *sub_info)
269{
270 struct completion *comp = xchg(&sub_info->complete, NULL);
271 /*
272 * See call_usermodehelper_exec(). If xchg() returns NULL
273 * we own sub_info, the UMH_KILLABLE caller has gone away.
274 */
275 if (comp)
276 complete(comp);
277 else
278 call_usermodehelper_freeinfo(sub_info);
279}
280
281/* Keventd can't block, but this (a child) can. */ 284/* Keventd can't block, but this (a child) can. */
282static int wait_for_helper(void *data) 285static int wait_for_helper(void *data)
283{ 286{
@@ -336,18 +339,8 @@ static void __call_usermodehelper(struct work_struct *work)
336 kmod_thread_locker = NULL; 339 kmod_thread_locker = NULL;
337 } 340 }
338 341
339 switch (wait) { 342 if (pid < 0) {
340 case UMH_NO_WAIT: 343 sub_info->retval = pid;
341 call_usermodehelper_freeinfo(sub_info);
342 break;
343
344 case UMH_WAIT_PROC:
345 if (pid > 0)
346 break;
347 /* FALLTHROUGH */
348 case UMH_WAIT_EXEC:
349 if (pid < 0)
350 sub_info->retval = pid;
351 umh_complete(sub_info); 344 umh_complete(sub_info);
352 } 345 }
353} 346}
@@ -588,7 +581,12 @@ int call_usermodehelper_exec(struct subprocess_info *sub_info, int wait)
588 goto out; 581 goto out;
589 } 582 }
590 583
591 sub_info->complete = &done; 584 /*
585 * Set the completion pointer only if there is a waiter.
586 * This makes it possible to use umh_complete to free
587 * the data structure in case of UMH_NO_WAIT.
588 */
589 sub_info->complete = (wait == UMH_NO_WAIT) ? NULL : &done;
592 sub_info->wait = wait; 590 sub_info->wait = wait;
593 591
594 queue_work(khelper_wq, &sub_info->work); 592 queue_work(khelper_wq, &sub_info->work);
diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
index a9dfa79b6bab..1f35a3478f3c 100644
--- a/kernel/power/hibernate.c
+++ b/kernel/power/hibernate.c
@@ -502,8 +502,14 @@ int hibernation_restore(int platform_mode)
502 error = dpm_suspend_start(PMSG_QUIESCE); 502 error = dpm_suspend_start(PMSG_QUIESCE);
503 if (!error) { 503 if (!error) {
504 error = resume_target_kernel(platform_mode); 504 error = resume_target_kernel(platform_mode);
505 dpm_resume_end(PMSG_RECOVER); 505 /*
506 * The above should either succeed and jump to the new kernel,
507 * or return with an error. Otherwise things are just
508 * undefined, so let's be paranoid.
509 */
510 BUG_ON(!error);
506 } 511 }
512 dpm_resume_end(PMSG_RECOVER);
507 pm_restore_gfp_mask(); 513 pm_restore_gfp_mask();
508 resume_console(); 514 resume_console();
509 pm_restore_console(); 515 pm_restore_console();
diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index 133e47223095..9815447d22e0 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -3299,11 +3299,16 @@ static void _rcu_barrier(struct rcu_state *rsp)
3299 continue; 3299 continue;
3300 rdp = per_cpu_ptr(rsp->rda, cpu); 3300 rdp = per_cpu_ptr(rsp->rda, cpu);
3301 if (rcu_is_nocb_cpu(cpu)) { 3301 if (rcu_is_nocb_cpu(cpu)) {
3302 _rcu_barrier_trace(rsp, "OnlineNoCB", cpu, 3302 if (!rcu_nocb_cpu_needs_barrier(rsp, cpu)) {
3303 rsp->n_barrier_done); 3303 _rcu_barrier_trace(rsp, "OfflineNoCB", cpu,
3304 atomic_inc(&rsp->barrier_cpu_count); 3304 rsp->n_barrier_done);
3305 __call_rcu(&rdp->barrier_head, rcu_barrier_callback, 3305 } else {
3306 rsp, cpu, 0); 3306 _rcu_barrier_trace(rsp, "OnlineNoCB", cpu,
3307 rsp->n_barrier_done);
3308 atomic_inc(&rsp->barrier_cpu_count);
3309 __call_rcu(&rdp->barrier_head,
3310 rcu_barrier_callback, rsp, cpu, 0);
3311 }
3307 } else if (ACCESS_ONCE(rdp->qlen)) { 3312 } else if (ACCESS_ONCE(rdp->qlen)) {
3308 _rcu_barrier_trace(rsp, "OnlineQ", cpu, 3313 _rcu_barrier_trace(rsp, "OnlineQ", cpu,
3309 rsp->n_barrier_done); 3314 rsp->n_barrier_done);
diff --git a/kernel/rcu/tree.h b/kernel/rcu/tree.h
index d03764652d91..bbdc45d8d74f 100644
--- a/kernel/rcu/tree.h
+++ b/kernel/rcu/tree.h
@@ -587,6 +587,7 @@ static void print_cpu_stall_info(struct rcu_state *rsp, int cpu);
587static void print_cpu_stall_info_end(void); 587static void print_cpu_stall_info_end(void);
588static void zero_cpu_stall_ticks(struct rcu_data *rdp); 588static void zero_cpu_stall_ticks(struct rcu_data *rdp);
589static void increment_cpu_stall_ticks(void); 589static void increment_cpu_stall_ticks(void);
590static bool rcu_nocb_cpu_needs_barrier(struct rcu_state *rsp, int cpu);
590static void rcu_nocb_gp_set(struct rcu_node *rnp, int nrq); 591static void rcu_nocb_gp_set(struct rcu_node *rnp, int nrq);
591static void rcu_nocb_gp_cleanup(struct rcu_state *rsp, struct rcu_node *rnp); 592static void rcu_nocb_gp_cleanup(struct rcu_state *rsp, struct rcu_node *rnp);
592static void rcu_init_one_nocb(struct rcu_node *rnp); 593static void rcu_init_one_nocb(struct rcu_node *rnp);
diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h
index 387dd4599344..c1d7f27bd38f 100644
--- a/kernel/rcu/tree_plugin.h
+++ b/kernel/rcu/tree_plugin.h
@@ -2050,6 +2050,33 @@ static void wake_nocb_leader(struct rcu_data *rdp, bool force)
2050} 2050}
2051 2051
2052/* 2052/*
2053 * Does the specified CPU need an RCU callback for the specified flavor
2054 * of rcu_barrier()?
2055 */
2056static bool rcu_nocb_cpu_needs_barrier(struct rcu_state *rsp, int cpu)
2057{
2058 struct rcu_data *rdp = per_cpu_ptr(rsp->rda, cpu);
2059 struct rcu_head *rhp;
2060
2061 /* No-CBs CPUs might have callbacks on any of three lists. */
2062 rhp = ACCESS_ONCE(rdp->nocb_head);
2063 if (!rhp)
2064 rhp = ACCESS_ONCE(rdp->nocb_gp_head);
2065 if (!rhp)
2066 rhp = ACCESS_ONCE(rdp->nocb_follower_head);
2067
2068 /* Having no rcuo kthread but CBs after scheduler starts is bad! */
2069 if (!ACCESS_ONCE(rdp->nocb_kthread) && rhp) {
2070 /* RCU callback enqueued before CPU first came online??? */
2071 pr_err("RCU: Never-onlined no-CBs CPU %d has CB %p\n",
2072 cpu, rhp->func);
2073 WARN_ON_ONCE(1);
2074 }
2075
2076 return !!rhp;
2077}
2078
2079/*
2053 * Enqueue the specified string of rcu_head structures onto the specified 2080 * Enqueue the specified string of rcu_head structures onto the specified
2054 * CPU's no-CBs lists. The CPU is specified by rdp, the head of the 2081 * CPU's no-CBs lists. The CPU is specified by rdp, the head of the
2055 * string by rhp, and the tail of the string by rhtp. The non-lazy/lazy 2082 * string by rhp, and the tail of the string by rhtp. The non-lazy/lazy
@@ -2642,6 +2669,12 @@ static bool init_nocb_callback_list(struct rcu_data *rdp)
2642 2669
2643#else /* #ifdef CONFIG_RCU_NOCB_CPU */ 2670#else /* #ifdef CONFIG_RCU_NOCB_CPU */
2644 2671
2672static bool rcu_nocb_cpu_needs_barrier(struct rcu_state *rsp, int cpu)
2673{
2674 WARN_ON_ONCE(1); /* Should be dead code. */
2675 return false;
2676}
2677
2645static void rcu_nocb_gp_cleanup(struct rcu_state *rsp, struct rcu_node *rnp) 2678static void rcu_nocb_gp_cleanup(struct rcu_state *rsp, struct rcu_node *rnp)
2646{ 2679{
2647} 2680}
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 72d9d926a034..960f70402ecc 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -2457,44 +2457,6 @@ EXPORT_PER_CPU_SYMBOL(kstat);
2457EXPORT_PER_CPU_SYMBOL(kernel_cpustat); 2457EXPORT_PER_CPU_SYMBOL(kernel_cpustat);
2458 2458
2459/* 2459/*
2460 * Return any ns on the sched_clock that have not yet been accounted in
2461 * @p in case that task is currently running.
2462 *
2463 * Called with task_rq_lock() held on @rq.
2464 */
2465static u64 do_task_delta_exec(struct task_struct *p, struct rq *rq)
2466{
2467 u64 ns = 0;
2468
2469 /*
2470 * Must be ->curr _and_ ->on_rq. If dequeued, we would
2471 * project cycles that may never be accounted to this
2472 * thread, breaking clock_gettime().
2473 */
2474 if (task_current(rq, p) && task_on_rq_queued(p)) {
2475 update_rq_clock(rq);
2476 ns = rq_clock_task(rq) - p->se.exec_start;
2477 if ((s64)ns < 0)
2478 ns = 0;
2479 }
2480
2481 return ns;
2482}
2483
2484unsigned long long task_delta_exec(struct task_struct *p)
2485{
2486 unsigned long flags;
2487 struct rq *rq;
2488 u64 ns = 0;
2489
2490 rq = task_rq_lock(p, &flags);
2491 ns = do_task_delta_exec(p, rq);
2492 task_rq_unlock(rq, p, &flags);
2493
2494 return ns;
2495}
2496
2497/*
2498 * Return accounted runtime for the task. 2460 * Return accounted runtime for the task.
2499 * In case the task is currently running, return the runtime plus current's 2461 * In case the task is currently running, return the runtime plus current's
2500 * pending runtime that have not been accounted yet. 2462 * pending runtime that have not been accounted yet.
@@ -2503,7 +2465,7 @@ unsigned long long task_sched_runtime(struct task_struct *p)
2503{ 2465{
2504 unsigned long flags; 2466 unsigned long flags;
2505 struct rq *rq; 2467 struct rq *rq;
2506 u64 ns = 0; 2468 u64 ns;
2507 2469
2508#if defined(CONFIG_64BIT) && defined(CONFIG_SMP) 2470#if defined(CONFIG_64BIT) && defined(CONFIG_SMP)
2509 /* 2471 /*
@@ -2522,7 +2484,16 @@ unsigned long long task_sched_runtime(struct task_struct *p)
2522#endif 2484#endif
2523 2485
2524 rq = task_rq_lock(p, &flags); 2486 rq = task_rq_lock(p, &flags);
2525 ns = p->se.sum_exec_runtime + do_task_delta_exec(p, rq); 2487 /*
2488 * Must be ->curr _and_ ->on_rq. If dequeued, we would
2489 * project cycles that may never be accounted to this
2490 * thread, breaking clock_gettime().
2491 */
2492 if (task_current(rq, p) && task_on_rq_queued(p)) {
2493 update_rq_clock(rq);
2494 p->sched_class->update_curr(rq);
2495 }
2496 ns = p->se.sum_exec_runtime;
2526 task_rq_unlock(rq, p, &flags); 2497 task_rq_unlock(rq, p, &flags);
2527 2498
2528 return ns; 2499 return ns;
@@ -6470,6 +6441,10 @@ static void sched_init_numa(void)
6470 if (!sched_debug()) 6441 if (!sched_debug())
6471 break; 6442 break;
6472 } 6443 }
6444
6445 if (!level)
6446 return;
6447
6473 /* 6448 /*
6474 * 'level' contains the number of unique distances, excluding the 6449 * 'level' contains the number of unique distances, excluding the
6475 * identity distance node_distance(i,i). 6450 * identity distance node_distance(i,i).
@@ -7568,8 +7543,12 @@ void sched_move_task(struct task_struct *tsk)
7568 if (unlikely(running)) 7543 if (unlikely(running))
7569 put_prev_task(rq, tsk); 7544 put_prev_task(rq, tsk);
7570 7545
7571 tg = container_of(task_css_check(tsk, cpu_cgrp_id, 7546 /*
7572 lockdep_is_held(&tsk->sighand->siglock)), 7547 * All callers are synchronized by task_rq_lock(); we do not use RCU
7548 * which is pointless here. Thus, we pass "true" to task_css_check()
7549 * to prevent lockdep warnings.
7550 */
7551 tg = container_of(task_css_check(tsk, cpu_cgrp_id, true),
7573 struct task_group, css); 7552 struct task_group, css);
7574 tg = autogroup_task_group(tsk, tg); 7553 tg = autogroup_task_group(tsk, tg);
7575 tsk->sched_task_group = tg; 7554 tsk->sched_task_group = tg;
diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
index f3d7776656ee..b0911797422f 100644
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -1747,6 +1747,8 @@ const struct sched_class dl_sched_class = {
1747 .prio_changed = prio_changed_dl, 1747 .prio_changed = prio_changed_dl,
1748 .switched_from = switched_from_dl, 1748 .switched_from = switched_from_dl,
1749 .switched_to = switched_to_dl, 1749 .switched_to = switched_to_dl,
1750
1751 .update_curr = update_curr_dl,
1750}; 1752};
1751 1753
1752#ifdef CONFIG_SCHED_DEBUG 1754#ifdef CONFIG_SCHED_DEBUG
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 826fdf326683..cf80643eb04d 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -726,6 +726,11 @@ static void update_curr(struct cfs_rq *cfs_rq)
726 account_cfs_rq_runtime(cfs_rq, delta_exec); 726 account_cfs_rq_runtime(cfs_rq, delta_exec);
727} 727}
728 728
729static void update_curr_fair(struct rq *rq)
730{
731 update_curr(cfs_rq_of(&rq->curr->se));
732}
733
729static inline void 734static inline void
730update_stats_wait_start(struct cfs_rq *cfs_rq, struct sched_entity *se) 735update_stats_wait_start(struct cfs_rq *cfs_rq, struct sched_entity *se)
731{ 736{
@@ -1268,6 +1273,13 @@ static void task_numa_compare(struct task_numa_env *env,
1268 raw_spin_unlock_irq(&dst_rq->lock); 1273 raw_spin_unlock_irq(&dst_rq->lock);
1269 1274
1270 /* 1275 /*
1276 * Because we have preemption enabled we can get migrated around and
1277 * end try selecting ourselves (current == env->p) as a swap candidate.
1278 */
1279 if (cur == env->p)
1280 goto unlock;
1281
1282 /*
1271 * "imp" is the fault differential for the source task between the 1283 * "imp" is the fault differential for the source task between the
1272 * source and destination node. Calculate the total differential for 1284 * source and destination node. Calculate the total differential for
1273 * the source task and potential destination task. The more negative 1285 * the source task and potential destination task. The more negative
@@ -8137,6 +8149,8 @@ const struct sched_class fair_sched_class = {
8137 8149
8138 .get_rr_interval = get_rr_interval_fair, 8150 .get_rr_interval = get_rr_interval_fair,
8139 8151
8152 .update_curr = update_curr_fair,
8153
8140#ifdef CONFIG_FAIR_GROUP_SCHED 8154#ifdef CONFIG_FAIR_GROUP_SCHED
8141 .task_move_group = task_move_group_fair, 8155 .task_move_group = task_move_group_fair,
8142#endif 8156#endif
diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
index 3d14312db7ea..f1bb92fcc532 100644
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -2134,6 +2134,8 @@ const struct sched_class rt_sched_class = {
2134 2134
2135 .prio_changed = prio_changed_rt, 2135 .prio_changed = prio_changed_rt,
2136 .switched_to = switched_to_rt, 2136 .switched_to = switched_to_rt,
2137
2138 .update_curr = update_curr_rt,
2137}; 2139};
2138 2140
2139#ifdef CONFIG_SCHED_DEBUG 2141#ifdef CONFIG_SCHED_DEBUG
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 31f1e4d2996a..9a2a45c970e7 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -1177,6 +1177,8 @@ struct sched_class {
1177 unsigned int (*get_rr_interval) (struct rq *rq, 1177 unsigned int (*get_rr_interval) (struct rq *rq,
1178 struct task_struct *task); 1178 struct task_struct *task);
1179 1179
1180 void (*update_curr) (struct rq *rq);
1181
1180#ifdef CONFIG_FAIR_GROUP_SCHED 1182#ifdef CONFIG_FAIR_GROUP_SCHED
1181 void (*task_move_group) (struct task_struct *p, int on_rq); 1183 void (*task_move_group) (struct task_struct *p, int on_rq);
1182#endif 1184#endif
diff --git a/kernel/time/clockevents.c b/kernel/time/clockevents.c
index 9c94c19f1305..55449909f114 100644
--- a/kernel/time/clockevents.c
+++ b/kernel/time/clockevents.c
@@ -72,7 +72,7 @@ static u64 cev_delta2ns(unsigned long latch, struct clock_event_device *evt,
72 * Also omit the add if it would overflow the u64 boundary. 72 * Also omit the add if it would overflow the u64 boundary.
73 */ 73 */
74 if ((~0ULL - clc > rnd) && 74 if ((~0ULL - clc > rnd) &&
75 (!ismax || evt->mult <= (1U << evt->shift))) 75 (!ismax || evt->mult <= (1ULL << evt->shift)))
76 clc += rnd; 76 clc += rnd;
77 77
78 do_div(clc, evt->mult); 78 do_div(clc, evt->mult);
diff --git a/kernel/time/posix-cpu-timers.c b/kernel/time/posix-cpu-timers.c
index 492b986195d5..a16b67859e2a 100644
--- a/kernel/time/posix-cpu-timers.c
+++ b/kernel/time/posix-cpu-timers.c
@@ -553,7 +553,7 @@ static int cpu_timer_sample_group(const clockid_t which_clock,
553 *sample = cputime_to_expires(cputime.utime); 553 *sample = cputime_to_expires(cputime.utime);
554 break; 554 break;
555 case CPUCLOCK_SCHED: 555 case CPUCLOCK_SCHED:
556 *sample = cputime.sum_exec_runtime + task_delta_exec(p); 556 *sample = cputime.sum_exec_runtime;
557 break; 557 break;
558 } 558 }
559 return 0; 559 return 0;
diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
index 42b463ad90f2..31ea01f42e1f 100644
--- a/kernel/time/posix-timers.c
+++ b/kernel/time/posix-timers.c
@@ -636,6 +636,7 @@ SYSCALL_DEFINE3(timer_create, const clockid_t, which_clock,
636 goto out; 636 goto out;
637 } 637 }
638 } else { 638 } else {
639 memset(&event.sigev_value, 0, sizeof(event.sigev_value));
639 event.sigev_notify = SIGEV_SIGNAL; 640 event.sigev_notify = SIGEV_SIGNAL;
640 event.sigev_signo = SIGALRM; 641 event.sigev_signo = SIGALRM;
641 event.sigev_value.sival_int = new_timer->it_id; 642 event.sigev_value.sival_int = new_timer->it_id;
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index fb186b9ddf51..31c90fec4158 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -1925,8 +1925,16 @@ ftrace_find_tramp_ops_curr(struct dyn_ftrace *rec)
1925 * when we are adding another op to the rec or removing the 1925 * when we are adding another op to the rec or removing the
1926 * current one. Thus, if the op is being added, we can 1926 * current one. Thus, if the op is being added, we can
1927 * ignore it because it hasn't attached itself to the rec 1927 * ignore it because it hasn't attached itself to the rec
1928 * yet. That means we just need to find the op that has a 1928 * yet.
1929 * trampoline and is not beeing added. 1929 *
1930 * If an ops is being modified (hooking to different functions)
1931 * then we don't care about the new functions that are being
1932 * added, just the old ones (that are probably being removed).
1933 *
1934 * If we are adding an ops to a function that already is using
1935 * a trampoline, it needs to be removed (trampolines are only
1936 * for single ops connected), then an ops that is not being
1937 * modified also needs to be checked.
1930 */ 1938 */
1931 do_for_each_ftrace_op(op, ftrace_ops_list) { 1939 do_for_each_ftrace_op(op, ftrace_ops_list) {
1932 1940
@@ -1940,17 +1948,23 @@ ftrace_find_tramp_ops_curr(struct dyn_ftrace *rec)
1940 if (op->flags & FTRACE_OPS_FL_ADDING) 1948 if (op->flags & FTRACE_OPS_FL_ADDING)
1941 continue; 1949 continue;
1942 1950
1951
1943 /* 1952 /*
1944 * If the ops is not being added and has a trampoline, 1953 * If the ops is being modified and is in the old
1945 * then it must be the one that we want! 1954 * hash, then it is probably being removed from this
1955 * function.
1946 */ 1956 */
1947 if (hash_contains_ip(ip, op->func_hash))
1948 return op;
1949
1950 /* If the ops is being modified, it may be in the old hash. */
1951 if ((op->flags & FTRACE_OPS_FL_MODIFYING) && 1957 if ((op->flags & FTRACE_OPS_FL_MODIFYING) &&
1952 hash_contains_ip(ip, &op->old_hash)) 1958 hash_contains_ip(ip, &op->old_hash))
1953 return op; 1959 return op;
1960 /*
1961 * If the ops is not being added or modified, and it's
1962 * in its normal filter hash, then this must be the one
1963 * we want!
1964 */
1965 if (!(op->flags & FTRACE_OPS_FL_MODIFYING) &&
1966 hash_contains_ip(ip, op->func_hash))
1967 return op;
1954 1968
1955 } while_for_each_ftrace_op(op); 1969 } while_for_each_ftrace_op(op);
1956 1970
@@ -2293,10 +2307,13 @@ static void ftrace_run_update_code(int command)
2293 FTRACE_WARN_ON(ret); 2307 FTRACE_WARN_ON(ret);
2294} 2308}
2295 2309
2296static void ftrace_run_modify_code(struct ftrace_ops *ops, int command) 2310static void ftrace_run_modify_code(struct ftrace_ops *ops, int command,
2311 struct ftrace_hash *old_hash)
2297{ 2312{
2298 ops->flags |= FTRACE_OPS_FL_MODIFYING; 2313 ops->flags |= FTRACE_OPS_FL_MODIFYING;
2314 ops->old_hash.filter_hash = old_hash;
2299 ftrace_run_update_code(command); 2315 ftrace_run_update_code(command);
2316 ops->old_hash.filter_hash = NULL;
2300 ops->flags &= ~FTRACE_OPS_FL_MODIFYING; 2317 ops->flags &= ~FTRACE_OPS_FL_MODIFYING;
2301} 2318}
2302 2319
@@ -3340,7 +3357,7 @@ static struct ftrace_ops trace_probe_ops __read_mostly =
3340 3357
3341static int ftrace_probe_registered; 3358static int ftrace_probe_registered;
3342 3359
3343static void __enable_ftrace_function_probe(void) 3360static void __enable_ftrace_function_probe(struct ftrace_hash *old_hash)
3344{ 3361{
3345 int ret; 3362 int ret;
3346 int i; 3363 int i;
@@ -3348,7 +3365,8 @@ static void __enable_ftrace_function_probe(void)
3348 if (ftrace_probe_registered) { 3365 if (ftrace_probe_registered) {
3349 /* still need to update the function call sites */ 3366 /* still need to update the function call sites */
3350 if (ftrace_enabled) 3367 if (ftrace_enabled)
3351 ftrace_run_modify_code(&trace_probe_ops, FTRACE_UPDATE_CALLS); 3368 ftrace_run_modify_code(&trace_probe_ops, FTRACE_UPDATE_CALLS,
3369 old_hash);
3352 return; 3370 return;
3353 } 3371 }
3354 3372
@@ -3477,13 +3495,14 @@ register_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops,
3477 } while_for_each_ftrace_rec(); 3495 } while_for_each_ftrace_rec();
3478 3496
3479 ret = ftrace_hash_move(&trace_probe_ops, 1, orig_hash, hash); 3497 ret = ftrace_hash_move(&trace_probe_ops, 1, orig_hash, hash);
3498
3499 __enable_ftrace_function_probe(old_hash);
3500
3480 if (!ret) 3501 if (!ret)
3481 free_ftrace_hash_rcu(old_hash); 3502 free_ftrace_hash_rcu(old_hash);
3482 else 3503 else
3483 count = ret; 3504 count = ret;
3484 3505
3485 __enable_ftrace_function_probe();
3486
3487 out_unlock: 3506 out_unlock:
3488 mutex_unlock(&ftrace_lock); 3507 mutex_unlock(&ftrace_lock);
3489 out: 3508 out:
@@ -3764,10 +3783,11 @@ ftrace_match_addr(struct ftrace_hash *hash, unsigned long ip, int remove)
3764 return add_hash_entry(hash, ip); 3783 return add_hash_entry(hash, ip);
3765} 3784}
3766 3785
3767static void ftrace_ops_update_code(struct ftrace_ops *ops) 3786static void ftrace_ops_update_code(struct ftrace_ops *ops,
3787 struct ftrace_hash *old_hash)
3768{ 3788{
3769 if (ops->flags & FTRACE_OPS_FL_ENABLED && ftrace_enabled) 3789 if (ops->flags & FTRACE_OPS_FL_ENABLED && ftrace_enabled)
3770 ftrace_run_modify_code(ops, FTRACE_UPDATE_CALLS); 3790 ftrace_run_modify_code(ops, FTRACE_UPDATE_CALLS, old_hash);
3771} 3791}
3772 3792
3773static int 3793static int
@@ -3813,7 +3833,7 @@ ftrace_set_hash(struct ftrace_ops *ops, unsigned char *buf, int len,
3813 old_hash = *orig_hash; 3833 old_hash = *orig_hash;
3814 ret = ftrace_hash_move(ops, enable, orig_hash, hash); 3834 ret = ftrace_hash_move(ops, enable, orig_hash, hash);
3815 if (!ret) { 3835 if (!ret) {
3816 ftrace_ops_update_code(ops); 3836 ftrace_ops_update_code(ops, old_hash);
3817 free_ftrace_hash_rcu(old_hash); 3837 free_ftrace_hash_rcu(old_hash);
3818 } 3838 }
3819 mutex_unlock(&ftrace_lock); 3839 mutex_unlock(&ftrace_lock);
@@ -4058,7 +4078,7 @@ int ftrace_regex_release(struct inode *inode, struct file *file)
4058 ret = ftrace_hash_move(iter->ops, filter_hash, 4078 ret = ftrace_hash_move(iter->ops, filter_hash,
4059 orig_hash, iter->hash); 4079 orig_hash, iter->hash);
4060 if (!ret) { 4080 if (!ret) {
4061 ftrace_ops_update_code(iter->ops); 4081 ftrace_ops_update_code(iter->ops, old_hash);
4062 free_ftrace_hash_rcu(old_hash); 4082 free_ftrace_hash_rcu(old_hash);
4063 } 4083 }
4064 mutex_unlock(&ftrace_lock); 4084 mutex_unlock(&ftrace_lock);
diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
index 4dc8b79c5f75..29228c4d5696 100644
--- a/kernel/trace/trace_syscalls.c
+++ b/kernel/trace/trace_syscalls.c
@@ -313,7 +313,7 @@ static void ftrace_syscall_enter(void *data, struct pt_regs *regs, long id)
313 int size; 313 int size;
314 314
315 syscall_nr = trace_get_syscall_nr(current, regs); 315 syscall_nr = trace_get_syscall_nr(current, regs);
316 if (syscall_nr < 0) 316 if (syscall_nr < 0 || syscall_nr >= NR_syscalls)
317 return; 317 return;
318 318
319 /* Here we're inside tp handler's rcu_read_lock_sched (__DO_TRACE) */ 319 /* Here we're inside tp handler's rcu_read_lock_sched (__DO_TRACE) */
@@ -360,7 +360,7 @@ static void ftrace_syscall_exit(void *data, struct pt_regs *regs, long ret)
360 int syscall_nr; 360 int syscall_nr;
361 361
362 syscall_nr = trace_get_syscall_nr(current, regs); 362 syscall_nr = trace_get_syscall_nr(current, regs);
363 if (syscall_nr < 0) 363 if (syscall_nr < 0 || syscall_nr >= NR_syscalls)
364 return; 364 return;
365 365
366 /* Here we're inside tp handler's rcu_read_lock_sched (__DO_TRACE()) */ 366 /* Here we're inside tp handler's rcu_read_lock_sched (__DO_TRACE()) */
@@ -567,7 +567,7 @@ static void perf_syscall_enter(void *ignore, struct pt_regs *regs, long id)
567 int size; 567 int size;
568 568
569 syscall_nr = trace_get_syscall_nr(current, regs); 569 syscall_nr = trace_get_syscall_nr(current, regs);
570 if (syscall_nr < 0) 570 if (syscall_nr < 0 || syscall_nr >= NR_syscalls)
571 return; 571 return;
572 if (!test_bit(syscall_nr, enabled_perf_enter_syscalls)) 572 if (!test_bit(syscall_nr, enabled_perf_enter_syscalls))
573 return; 573 return;
@@ -641,7 +641,7 @@ static void perf_syscall_exit(void *ignore, struct pt_regs *regs, long ret)
641 int size; 641 int size;
642 642
643 syscall_nr = trace_get_syscall_nr(current, regs); 643 syscall_nr = trace_get_syscall_nr(current, regs);
644 if (syscall_nr < 0) 644 if (syscall_nr < 0 || syscall_nr >= NR_syscalls)
645 return; 645 return;
646 if (!test_bit(syscall_nr, enabled_perf_exit_syscalls)) 646 if (!test_bit(syscall_nr, enabled_perf_exit_syscalls))
647 return; 647 return;
diff --git a/lib/bitmap.c b/lib/bitmap.c
index cd250a2e14cb..b499ab6ada29 100644
--- a/lib/bitmap.c
+++ b/lib/bitmap.c
@@ -131,7 +131,9 @@ void __bitmap_shift_right(unsigned long *dst,
131 lower = src[off + k]; 131 lower = src[off + k];
132 if (left && off + k == lim - 1) 132 if (left && off + k == lim - 1)
133 lower &= mask; 133 lower &= mask;
134 dst[k] = upper << (BITS_PER_LONG - rem) | lower >> rem; 134 dst[k] = lower >> rem;
135 if (rem)
136 dst[k] |= upper << (BITS_PER_LONG - rem);
135 if (left && k == lim - 1) 137 if (left && k == lim - 1)
136 dst[k] &= mask; 138 dst[k] &= mask;
137 } 139 }
@@ -172,7 +174,9 @@ void __bitmap_shift_left(unsigned long *dst,
172 upper = src[k]; 174 upper = src[k];
173 if (left && k == lim - 1) 175 if (left && k == lim - 1)
174 upper &= (1UL << left) - 1; 176 upper &= (1UL << left) - 1;
175 dst[k + off] = lower >> (BITS_PER_LONG - rem) | upper << rem; 177 dst[k + off] = upper << rem;
178 if (rem)
179 dst[k + off] |= lower >> (BITS_PER_LONG - rem);
176 if (left && k + off == lim - 1) 180 if (left && k + off == lim - 1)
177 dst[k + off] &= (1UL << left) - 1; 181 dst[k + off] &= (1UL << left) - 1;
178 } 182 }
diff --git a/lib/scatterlist.c b/lib/scatterlist.c
index 9cdf62f8accd..c9f2e8c6ccc9 100644
--- a/lib/scatterlist.c
+++ b/lib/scatterlist.c
@@ -203,10 +203,10 @@ void __sg_free_table(struct sg_table *table, unsigned int max_ents,
203 } 203 }
204 204
205 table->orig_nents -= sg_size; 205 table->orig_nents -= sg_size;
206 if (!skip_first_chunk) { 206 if (skip_first_chunk)
207 free_fn(sgl, alloc_size);
208 skip_first_chunk = false; 207 skip_first_chunk = false;
209 } 208 else
209 free_fn(sgl, alloc_size);
210 sgl = next; 210 sgl = next;
211 } 211 }
212 212
diff --git a/mm/balloon_compaction.c b/mm/balloon_compaction.c
index b3cbe19f71b5..fcad8322ef36 100644
--- a/mm/balloon_compaction.c
+++ b/mm/balloon_compaction.c
@@ -68,11 +68,13 @@ struct page *balloon_page_dequeue(struct balloon_dev_info *b_dev_info)
68 * to be released by the balloon driver. 68 * to be released by the balloon driver.
69 */ 69 */
70 if (trylock_page(page)) { 70 if (trylock_page(page)) {
71#ifdef CONFIG_BALLOON_COMPACTION
71 if (!PagePrivate(page)) { 72 if (!PagePrivate(page)) {
72 /* raced with isolation */ 73 /* raced with isolation */
73 unlock_page(page); 74 unlock_page(page);
74 continue; 75 continue;
75 } 76 }
77#endif
76 spin_lock_irqsave(&b_dev_info->pages_lock, flags); 78 spin_lock_irqsave(&b_dev_info->pages_lock, flags);
77 balloon_page_delete(page); 79 balloon_page_delete(page);
78 __count_vm_event(BALLOON_DEFLATE); 80 __count_vm_event(BALLOON_DEFLATE);
diff --git a/mm/cma.c b/mm/cma.c
index 963bc4add9af..fde706e1284f 100644
--- a/mm/cma.c
+++ b/mm/cma.c
@@ -124,6 +124,7 @@ static int __init cma_activate_area(struct cma *cma)
124 124
125err: 125err:
126 kfree(cma->bitmap); 126 kfree(cma->bitmap);
127 cma->count = 0;
127 return -EINVAL; 128 return -EINVAL;
128} 129}
129 130
@@ -217,9 +218,8 @@ int __init cma_declare_contiguous(phys_addr_t base,
217 phys_addr_t highmem_start = __pa(high_memory); 218 phys_addr_t highmem_start = __pa(high_memory);
218 int ret = 0; 219 int ret = 0;
219 220
220 pr_debug("%s(size %lx, base %08lx, limit %08lx alignment %08lx)\n", 221 pr_debug("%s(size %pa, base %pa, limit %pa alignment %pa)\n",
221 __func__, (unsigned long)size, (unsigned long)base, 222 __func__, &size, &base, &limit, &alignment);
222 (unsigned long)limit, (unsigned long)alignment);
223 223
224 if (cma_area_count == ARRAY_SIZE(cma_areas)) { 224 if (cma_area_count == ARRAY_SIZE(cma_areas)) {
225 pr_err("Not enough slots for CMA reserved regions!\n"); 225 pr_err("Not enough slots for CMA reserved regions!\n");
@@ -244,52 +244,72 @@ int __init cma_declare_contiguous(phys_addr_t base,
244 size = ALIGN(size, alignment); 244 size = ALIGN(size, alignment);
245 limit &= ~(alignment - 1); 245 limit &= ~(alignment - 1);
246 246
247 if (!base)
248 fixed = false;
249
247 /* size should be aligned with order_per_bit */ 250 /* size should be aligned with order_per_bit */
248 if (!IS_ALIGNED(size >> PAGE_SHIFT, 1 << order_per_bit)) 251 if (!IS_ALIGNED(size >> PAGE_SHIFT, 1 << order_per_bit))
249 return -EINVAL; 252 return -EINVAL;
250 253
251 /* 254 /*
252 * adjust limit to avoid crossing low/high memory boundary for 255 * If allocating at a fixed base the request region must not cross the
253 * automatically allocated regions 256 * low/high memory boundary.
254 */ 257 */
255 if (((limit == 0 || limit > memblock_end) && 258 if (fixed && base < highmem_start && base + size > highmem_start) {
256 (memblock_end - size < highmem_start &&
257 memblock_end > highmem_start)) ||
258 (!fixed && limit > highmem_start && limit - size < highmem_start)) {
259 limit = highmem_start;
260 }
261
262 if (fixed && base < highmem_start && base+size > highmem_start) {
263 ret = -EINVAL; 259 ret = -EINVAL;
264 pr_err("Region at %08lx defined on low/high memory boundary (%08lx)\n", 260 pr_err("Region at %pa defined on low/high memory boundary (%pa)\n",
265 (unsigned long)base, (unsigned long)highmem_start); 261 &base, &highmem_start);
266 goto err; 262 goto err;
267 } 263 }
268 264
265 /*
266 * If the limit is unspecified or above the memblock end, its effective
267 * value will be the memblock end. Set it explicitly to simplify further
268 * checks.
269 */
270 if (limit == 0 || limit > memblock_end)
271 limit = memblock_end;
272
269 /* Reserve memory */ 273 /* Reserve memory */
270 if (base && fixed) { 274 if (fixed) {
271 if (memblock_is_region_reserved(base, size) || 275 if (memblock_is_region_reserved(base, size) ||
272 memblock_reserve(base, size) < 0) { 276 memblock_reserve(base, size) < 0) {
273 ret = -EBUSY; 277 ret = -EBUSY;
274 goto err; 278 goto err;
275 } 279 }
276 } else { 280 } else {
277 phys_addr_t addr = memblock_alloc_range(size, alignment, base, 281 phys_addr_t addr = 0;
278 limit); 282
283 /*
284 * All pages in the reserved area must come from the same zone.
285 * If the requested region crosses the low/high memory boundary,
286 * try allocating from high memory first and fall back to low
287 * memory in case of failure.
288 */
289 if (base < highmem_start && limit > highmem_start) {
290 addr = memblock_alloc_range(size, alignment,
291 highmem_start, limit);
292 limit = highmem_start;
293 }
294
279 if (!addr) { 295 if (!addr) {
280 ret = -ENOMEM; 296 addr = memblock_alloc_range(size, alignment, base,
281 goto err; 297 limit);
282 } else { 298 if (!addr) {
283 base = addr; 299 ret = -ENOMEM;
300 goto err;
301 }
284 } 302 }
303
304 base = addr;
285 } 305 }
286 306
287 ret = cma_init_reserved_mem(base, size, order_per_bit, res_cma); 307 ret = cma_init_reserved_mem(base, size, order_per_bit, res_cma);
288 if (ret) 308 if (ret)
289 goto err; 309 goto err;
290 310
291 pr_info("Reserved %ld MiB at %08lx\n", (unsigned long)size / SZ_1M, 311 pr_info("Reserved %ld MiB at %pa\n", (unsigned long)size / SZ_1M,
292 (unsigned long)base); 312 &base);
293 return 0; 313 return 0;
294 314
295err: 315err:
diff --git a/mm/compaction.c b/mm/compaction.c
index edba18aed173..ec74cf0123ef 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -784,6 +784,9 @@ isolate_migratepages_range(struct compact_control *cc, unsigned long start_pfn,
784 cc->nr_migratepages = 0; 784 cc->nr_migratepages = 0;
785 break; 785 break;
786 } 786 }
787
788 if (cc->nr_migratepages == COMPACT_CLUSTER_MAX)
789 break;
787 } 790 }
788 acct_isolated(cc->zone, cc); 791 acct_isolated(cc->zone, cc);
789 792
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 74c78aa8bc2f..de984159cf0b 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -200,7 +200,7 @@ retry:
200 preempt_disable(); 200 preempt_disable();
201 if (cmpxchg(&huge_zero_page, NULL, zero_page)) { 201 if (cmpxchg(&huge_zero_page, NULL, zero_page)) {
202 preempt_enable(); 202 preempt_enable();
203 __free_page(zero_page); 203 __free_pages(zero_page, compound_order(zero_page));
204 goto retry; 204 goto retry;
205 } 205 }
206 206
@@ -232,7 +232,7 @@ static unsigned long shrink_huge_zero_page_scan(struct shrinker *shrink,
232 if (atomic_cmpxchg(&huge_zero_refcount, 1, 0) == 1) { 232 if (atomic_cmpxchg(&huge_zero_refcount, 1, 0) == 1) {
233 struct page *zero_page = xchg(&huge_zero_page, NULL); 233 struct page *zero_page = xchg(&huge_zero_page, NULL);
234 BUG_ON(zero_page == NULL); 234 BUG_ON(zero_page == NULL);
235 __free_page(zero_page); 235 __free_pages(zero_page, compound_order(zero_page));
236 return HPAGE_PMD_NR; 236 return HPAGE_PMD_NR;
237 } 237 }
238 238
@@ -803,7 +803,7 @@ int do_huge_pmd_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
803 return VM_FAULT_FALLBACK; 803 return VM_FAULT_FALLBACK;
804 if (unlikely(anon_vma_prepare(vma))) 804 if (unlikely(anon_vma_prepare(vma)))
805 return VM_FAULT_OOM; 805 return VM_FAULT_OOM;
806 if (unlikely(khugepaged_enter(vma))) 806 if (unlikely(khugepaged_enter(vma, vma->vm_flags)))
807 return VM_FAULT_OOM; 807 return VM_FAULT_OOM;
808 if (!(flags & FAULT_FLAG_WRITE) && 808 if (!(flags & FAULT_FLAG_WRITE) &&
809 transparent_hugepage_use_zero_page()) { 809 transparent_hugepage_use_zero_page()) {
@@ -1970,7 +1970,7 @@ int hugepage_madvise(struct vm_area_struct *vma,
1970 * register it here without waiting a page fault that 1970 * register it here without waiting a page fault that
1971 * may not happen any time soon. 1971 * may not happen any time soon.
1972 */ 1972 */
1973 if (unlikely(khugepaged_enter_vma_merge(vma))) 1973 if (unlikely(khugepaged_enter_vma_merge(vma, *vm_flags)))
1974 return -ENOMEM; 1974 return -ENOMEM;
1975 break; 1975 break;
1976 case MADV_NOHUGEPAGE: 1976 case MADV_NOHUGEPAGE:
@@ -2071,7 +2071,8 @@ int __khugepaged_enter(struct mm_struct *mm)
2071 return 0; 2071 return 0;
2072} 2072}
2073 2073
2074int khugepaged_enter_vma_merge(struct vm_area_struct *vma) 2074int khugepaged_enter_vma_merge(struct vm_area_struct *vma,
2075 unsigned long vm_flags)
2075{ 2076{
2076 unsigned long hstart, hend; 2077 unsigned long hstart, hend;
2077 if (!vma->anon_vma) 2078 if (!vma->anon_vma)
@@ -2083,11 +2084,11 @@ int khugepaged_enter_vma_merge(struct vm_area_struct *vma)
2083 if (vma->vm_ops) 2084 if (vma->vm_ops)
2084 /* khugepaged not yet working on file or special mappings */ 2085 /* khugepaged not yet working on file or special mappings */
2085 return 0; 2086 return 0;
2086 VM_BUG_ON_VMA(vma->vm_flags & VM_NO_THP, vma); 2087 VM_BUG_ON_VMA(vm_flags & VM_NO_THP, vma);
2087 hstart = (vma->vm_start + ~HPAGE_PMD_MASK) & HPAGE_PMD_MASK; 2088 hstart = (vma->vm_start + ~HPAGE_PMD_MASK) & HPAGE_PMD_MASK;
2088 hend = vma->vm_end & HPAGE_PMD_MASK; 2089 hend = vma->vm_end & HPAGE_PMD_MASK;
2089 if (hstart < hend) 2090 if (hstart < hend)
2090 return khugepaged_enter(vma); 2091 return khugepaged_enter(vma, vm_flags);
2091 return 0; 2092 return 0;
2092} 2093}
2093 2094
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 23976fd885fd..d6ac0e33e150 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1536,12 +1536,8 @@ int mem_cgroup_swappiness(struct mem_cgroup *memcg)
1536 * start move here. 1536 * start move here.
1537 */ 1537 */
1538 1538
1539/* for quick checking without looking up memcg */
1540atomic_t memcg_moving __read_mostly;
1541
1542static void mem_cgroup_start_move(struct mem_cgroup *memcg) 1539static void mem_cgroup_start_move(struct mem_cgroup *memcg)
1543{ 1540{
1544 atomic_inc(&memcg_moving);
1545 atomic_inc(&memcg->moving_account); 1541 atomic_inc(&memcg->moving_account);
1546 synchronize_rcu(); 1542 synchronize_rcu();
1547} 1543}
@@ -1552,10 +1548,8 @@ static void mem_cgroup_end_move(struct mem_cgroup *memcg)
1552 * Now, mem_cgroup_clear_mc() may call this function with NULL. 1548 * Now, mem_cgroup_clear_mc() may call this function with NULL.
1553 * We check NULL in callee rather than caller. 1549 * We check NULL in callee rather than caller.
1554 */ 1550 */
1555 if (memcg) { 1551 if (memcg)
1556 atomic_dec(&memcg_moving);
1557 atomic_dec(&memcg->moving_account); 1552 atomic_dec(&memcg->moving_account);
1558 }
1559} 1553}
1560 1554
1561/* 1555/*
@@ -2204,41 +2198,52 @@ cleanup:
2204 return true; 2198 return true;
2205} 2199}
2206 2200
2207/* 2201/**
2208 * Used to update mapped file or writeback or other statistics. 2202 * mem_cgroup_begin_page_stat - begin a page state statistics transaction
2203 * @page: page that is going to change accounted state
2204 * @locked: &memcg->move_lock slowpath was taken
2205 * @flags: IRQ-state flags for &memcg->move_lock
2209 * 2206 *
2210 * Notes: Race condition 2207 * This function must mark the beginning of an accounted page state
2208 * change to prevent double accounting when the page is concurrently
2209 * being moved to another memcg:
2211 * 2210 *
2212 * Charging occurs during page instantiation, while the page is 2211 * memcg = mem_cgroup_begin_page_stat(page, &locked, &flags);
2213 * unmapped and locked in page migration, or while the page table is 2212 * if (TestClearPageState(page))
2214 * locked in THP migration. No race is possible. 2213 * mem_cgroup_update_page_stat(memcg, state, -1);
2214 * mem_cgroup_end_page_stat(memcg, locked, flags);
2215 * 2215 *
2216 * Uncharge happens to pages with zero references, no race possible. 2216 * The RCU lock is held throughout the transaction. The fast path can
2217 * get away without acquiring the memcg->move_lock (@locked is false)
2218 * because page moving starts with an RCU grace period.
2217 * 2219 *
2218 * Charge moving between groups is protected by checking mm->moving 2220 * The RCU lock also protects the memcg from being freed when the page
2219 * account and taking the move_lock in the slowpath. 2221 * state that is going to change is the only thing preventing the page
2222 * from being uncharged. E.g. end-writeback clearing PageWriteback(),
2223 * which allows migration to go ahead and uncharge the page before the
2224 * account transaction might be complete.
2220 */ 2225 */
2221 2226struct mem_cgroup *mem_cgroup_begin_page_stat(struct page *page,
2222void __mem_cgroup_begin_update_page_stat(struct page *page, 2227 bool *locked,
2223 bool *locked, unsigned long *flags) 2228 unsigned long *flags)
2224{ 2229{
2225 struct mem_cgroup *memcg; 2230 struct mem_cgroup *memcg;
2226 struct page_cgroup *pc; 2231 struct page_cgroup *pc;
2227 2232
2233 rcu_read_lock();
2234
2235 if (mem_cgroup_disabled())
2236 return NULL;
2237
2228 pc = lookup_page_cgroup(page); 2238 pc = lookup_page_cgroup(page);
2229again: 2239again:
2230 memcg = pc->mem_cgroup; 2240 memcg = pc->mem_cgroup;
2231 if (unlikely(!memcg || !PageCgroupUsed(pc))) 2241 if (unlikely(!memcg || !PageCgroupUsed(pc)))
2232 return; 2242 return NULL;
2233 /* 2243
2234 * If this memory cgroup is not under account moving, we don't 2244 *locked = false;
2235 * need to take move_lock_mem_cgroup(). Because we already hold
2236 * rcu_read_lock(), any calls to move_account will be delayed until
2237 * rcu_read_unlock().
2238 */
2239 VM_BUG_ON(!rcu_read_lock_held());
2240 if (atomic_read(&memcg->moving_account) <= 0) 2245 if (atomic_read(&memcg->moving_account) <= 0)
2241 return; 2246 return memcg;
2242 2247
2243 move_lock_mem_cgroup(memcg, flags); 2248 move_lock_mem_cgroup(memcg, flags);
2244 if (memcg != pc->mem_cgroup || !PageCgroupUsed(pc)) { 2249 if (memcg != pc->mem_cgroup || !PageCgroupUsed(pc)) {
@@ -2246,36 +2251,40 @@ again:
2246 goto again; 2251 goto again;
2247 } 2252 }
2248 *locked = true; 2253 *locked = true;
2254
2255 return memcg;
2249} 2256}
2250 2257
2251void __mem_cgroup_end_update_page_stat(struct page *page, unsigned long *flags) 2258/**
2259 * mem_cgroup_end_page_stat - finish a page state statistics transaction
2260 * @memcg: the memcg that was accounted against
2261 * @locked: value received from mem_cgroup_begin_page_stat()
2262 * @flags: value received from mem_cgroup_begin_page_stat()
2263 */
2264void mem_cgroup_end_page_stat(struct mem_cgroup *memcg, bool locked,
2265 unsigned long flags)
2252{ 2266{
2253 struct page_cgroup *pc = lookup_page_cgroup(page); 2267 if (memcg && locked)
2268 move_unlock_mem_cgroup(memcg, &flags);
2254 2269
2255 /* 2270 rcu_read_unlock();
2256 * It's guaranteed that pc->mem_cgroup never changes while
2257 * lock is held because a routine modifies pc->mem_cgroup
2258 * should take move_lock_mem_cgroup().
2259 */
2260 move_unlock_mem_cgroup(pc->mem_cgroup, flags);
2261} 2271}
2262 2272
2263void mem_cgroup_update_page_stat(struct page *page, 2273/**
2274 * mem_cgroup_update_page_stat - update page state statistics
2275 * @memcg: memcg to account against
2276 * @idx: page state item to account
2277 * @val: number of pages (positive or negative)
2278 *
2279 * See mem_cgroup_begin_page_stat() for locking requirements.
2280 */
2281void mem_cgroup_update_page_stat(struct mem_cgroup *memcg,
2264 enum mem_cgroup_stat_index idx, int val) 2282 enum mem_cgroup_stat_index idx, int val)
2265{ 2283{
2266 struct mem_cgroup *memcg;
2267 struct page_cgroup *pc = lookup_page_cgroup(page);
2268 unsigned long uninitialized_var(flags);
2269
2270 if (mem_cgroup_disabled())
2271 return;
2272
2273 VM_BUG_ON(!rcu_read_lock_held()); 2284 VM_BUG_ON(!rcu_read_lock_held());
2274 memcg = pc->mem_cgroup;
2275 if (unlikely(!memcg || !PageCgroupUsed(pc)))
2276 return;
2277 2285
2278 this_cpu_add(memcg->stat->count[idx], val); 2286 if (memcg)
2287 this_cpu_add(memcg->stat->count[idx], val);
2279} 2288}
2280 2289
2281/* 2290/*
diff --git a/mm/memory.c b/mm/memory.c
index 1cc6bfbd872e..3e503831e042 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -1147,6 +1147,7 @@ again:
1147 print_bad_pte(vma, addr, ptent, page); 1147 print_bad_pte(vma, addr, ptent, page);
1148 if (unlikely(!__tlb_remove_page(tlb, page))) { 1148 if (unlikely(!__tlb_remove_page(tlb, page))) {
1149 force_flush = 1; 1149 force_flush = 1;
1150 addr += PAGE_SIZE;
1150 break; 1151 break;
1151 } 1152 }
1152 continue; 1153 continue;
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index 29d8693d0c61..252e1dbbed86 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -1912,7 +1912,6 @@ void try_offline_node(int nid)
1912 unsigned long start_pfn = pgdat->node_start_pfn; 1912 unsigned long start_pfn = pgdat->node_start_pfn;
1913 unsigned long end_pfn = start_pfn + pgdat->node_spanned_pages; 1913 unsigned long end_pfn = start_pfn + pgdat->node_spanned_pages;
1914 unsigned long pfn; 1914 unsigned long pfn;
1915 struct page *pgdat_page = virt_to_page(pgdat);
1916 int i; 1915 int i;
1917 1916
1918 for (pfn = start_pfn; pfn < end_pfn; pfn += PAGES_PER_SECTION) { 1917 for (pfn = start_pfn; pfn < end_pfn; pfn += PAGES_PER_SECTION) {
@@ -1941,10 +1940,6 @@ void try_offline_node(int nid)
1941 node_set_offline(nid); 1940 node_set_offline(nid);
1942 unregister_one_node(nid); 1941 unregister_one_node(nid);
1943 1942
1944 if (!PageSlab(pgdat_page) && !PageCompound(pgdat_page))
1945 /* node data is allocated from boot memory */
1946 return;
1947
1948 /* free waittable in each zone */ 1943 /* free waittable in each zone */
1949 for (i = 0; i < MAX_NR_ZONES; i++) { 1944 for (i = 0; i < MAX_NR_ZONES; i++) {
1950 struct zone *zone = pgdat->node_zones + i; 1945 struct zone *zone = pgdat->node_zones + i;
diff --git a/mm/mmap.c b/mm/mmap.c
index 7f855206e7fb..87e82b38453c 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -1080,7 +1080,7 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
1080 end, prev->vm_pgoff, NULL); 1080 end, prev->vm_pgoff, NULL);
1081 if (err) 1081 if (err)
1082 return NULL; 1082 return NULL;
1083 khugepaged_enter_vma_merge(prev); 1083 khugepaged_enter_vma_merge(prev, vm_flags);
1084 return prev; 1084 return prev;
1085 } 1085 }
1086 1086
@@ -1099,7 +1099,7 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
1099 next->vm_pgoff - pglen, NULL); 1099 next->vm_pgoff - pglen, NULL);
1100 if (err) 1100 if (err)
1101 return NULL; 1101 return NULL;
1102 khugepaged_enter_vma_merge(area); 1102 khugepaged_enter_vma_merge(area, vm_flags);
1103 return area; 1103 return area;
1104 } 1104 }
1105 1105
@@ -2208,7 +2208,7 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
2208 } 2208 }
2209 } 2209 }
2210 vma_unlock_anon_vma(vma); 2210 vma_unlock_anon_vma(vma);
2211 khugepaged_enter_vma_merge(vma); 2211 khugepaged_enter_vma_merge(vma, vma->vm_flags);
2212 validate_mm(vma->vm_mm); 2212 validate_mm(vma->vm_mm);
2213 return error; 2213 return error;
2214} 2214}
@@ -2277,7 +2277,7 @@ int expand_downwards(struct vm_area_struct *vma,
2277 } 2277 }
2278 } 2278 }
2279 vma_unlock_anon_vma(vma); 2279 vma_unlock_anon_vma(vma);
2280 khugepaged_enter_vma_merge(vma); 2280 khugepaged_enter_vma_merge(vma, vma->vm_flags);
2281 validate_mm(vma->vm_mm); 2281 validate_mm(vma->vm_mm);
2282 return error; 2282 return error;
2283} 2283}
diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index ff24c9d83112..19ceae87522d 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -2116,23 +2116,6 @@ void account_page_dirtied(struct page *page, struct address_space *mapping)
2116EXPORT_SYMBOL(account_page_dirtied); 2116EXPORT_SYMBOL(account_page_dirtied);
2117 2117
2118/* 2118/*
2119 * Helper function for set_page_writeback family.
2120 *
2121 * The caller must hold mem_cgroup_begin/end_update_page_stat() lock
2122 * while calling this function.
2123 * See test_set_page_writeback for example.
2124 *
2125 * NOTE: Unlike account_page_dirtied this does not rely on being atomic
2126 * wrt interrupts.
2127 */
2128void account_page_writeback(struct page *page)
2129{
2130 mem_cgroup_inc_page_stat(page, MEM_CGROUP_STAT_WRITEBACK);
2131 inc_zone_page_state(page, NR_WRITEBACK);
2132}
2133EXPORT_SYMBOL(account_page_writeback);
2134
2135/*
2136 * For address_spaces which do not use buffers. Just tag the page as dirty in 2119 * For address_spaces which do not use buffers. Just tag the page as dirty in
2137 * its radix tree. 2120 * its radix tree.
2138 * 2121 *
@@ -2344,11 +2327,12 @@ EXPORT_SYMBOL(clear_page_dirty_for_io);
2344int test_clear_page_writeback(struct page *page) 2327int test_clear_page_writeback(struct page *page)
2345{ 2328{
2346 struct address_space *mapping = page_mapping(page); 2329 struct address_space *mapping = page_mapping(page);
2347 int ret;
2348 bool locked;
2349 unsigned long memcg_flags; 2330 unsigned long memcg_flags;
2331 struct mem_cgroup *memcg;
2332 bool locked;
2333 int ret;
2350 2334
2351 mem_cgroup_begin_update_page_stat(page, &locked, &memcg_flags); 2335 memcg = mem_cgroup_begin_page_stat(page, &locked, &memcg_flags);
2352 if (mapping) { 2336 if (mapping) {
2353 struct backing_dev_info *bdi = mapping->backing_dev_info; 2337 struct backing_dev_info *bdi = mapping->backing_dev_info;
2354 unsigned long flags; 2338 unsigned long flags;
@@ -2369,22 +2353,23 @@ int test_clear_page_writeback(struct page *page)
2369 ret = TestClearPageWriteback(page); 2353 ret = TestClearPageWriteback(page);
2370 } 2354 }
2371 if (ret) { 2355 if (ret) {
2372 mem_cgroup_dec_page_stat(page, MEM_CGROUP_STAT_WRITEBACK); 2356 mem_cgroup_dec_page_stat(memcg, MEM_CGROUP_STAT_WRITEBACK);
2373 dec_zone_page_state(page, NR_WRITEBACK); 2357 dec_zone_page_state(page, NR_WRITEBACK);
2374 inc_zone_page_state(page, NR_WRITTEN); 2358 inc_zone_page_state(page, NR_WRITTEN);
2375 } 2359 }
2376 mem_cgroup_end_update_page_stat(page, &locked, &memcg_flags); 2360 mem_cgroup_end_page_stat(memcg, locked, memcg_flags);
2377 return ret; 2361 return ret;
2378} 2362}
2379 2363
2380int __test_set_page_writeback(struct page *page, bool keep_write) 2364int __test_set_page_writeback(struct page *page, bool keep_write)
2381{ 2365{
2382 struct address_space *mapping = page_mapping(page); 2366 struct address_space *mapping = page_mapping(page);
2383 int ret;
2384 bool locked;
2385 unsigned long memcg_flags; 2367 unsigned long memcg_flags;
2368 struct mem_cgroup *memcg;
2369 bool locked;
2370 int ret;
2386 2371
2387 mem_cgroup_begin_update_page_stat(page, &locked, &memcg_flags); 2372 memcg = mem_cgroup_begin_page_stat(page, &locked, &memcg_flags);
2388 if (mapping) { 2373 if (mapping) {
2389 struct backing_dev_info *bdi = mapping->backing_dev_info; 2374 struct backing_dev_info *bdi = mapping->backing_dev_info;
2390 unsigned long flags; 2375 unsigned long flags;
@@ -2410,9 +2395,11 @@ int __test_set_page_writeback(struct page *page, bool keep_write)
2410 } else { 2395 } else {
2411 ret = TestSetPageWriteback(page); 2396 ret = TestSetPageWriteback(page);
2412 } 2397 }
2413 if (!ret) 2398 if (!ret) {
2414 account_page_writeback(page); 2399 mem_cgroup_inc_page_stat(memcg, MEM_CGROUP_STAT_WRITEBACK);
2415 mem_cgroup_end_update_page_stat(page, &locked, &memcg_flags); 2400 inc_zone_page_state(page, NR_WRITEBACK);
2401 }
2402 mem_cgroup_end_page_stat(memcg, locked, memcg_flags);
2416 return ret; 2403 return ret;
2417 2404
2418} 2405}
diff --git a/mm/page_cgroup.c b/mm/page_cgroup.c
index 3708264d2833..5331c2bd85a2 100644
--- a/mm/page_cgroup.c
+++ b/mm/page_cgroup.c
@@ -171,6 +171,7 @@ static void free_page_cgroup(void *addr)
171 sizeof(struct page_cgroup) * PAGES_PER_SECTION; 171 sizeof(struct page_cgroup) * PAGES_PER_SECTION;
172 172
173 BUG_ON(PageReserved(page)); 173 BUG_ON(PageReserved(page));
174 kmemleak_free(addr);
174 free_pages_exact(addr, table_size); 175 free_pages_exact(addr, table_size);
175 } 176 }
176} 177}
diff --git a/mm/rmap.c b/mm/rmap.c
index 116a5053415b..19886fb2f13a 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -1042,15 +1042,46 @@ void page_add_new_anon_rmap(struct page *page,
1042 */ 1042 */
1043void page_add_file_rmap(struct page *page) 1043void page_add_file_rmap(struct page *page)
1044{ 1044{
1045 bool locked; 1045 struct mem_cgroup *memcg;
1046 unsigned long flags; 1046 unsigned long flags;
1047 bool locked;
1047 1048
1048 mem_cgroup_begin_update_page_stat(page, &locked, &flags); 1049 memcg = mem_cgroup_begin_page_stat(page, &locked, &flags);
1049 if (atomic_inc_and_test(&page->_mapcount)) { 1050 if (atomic_inc_and_test(&page->_mapcount)) {
1050 __inc_zone_page_state(page, NR_FILE_MAPPED); 1051 __inc_zone_page_state(page, NR_FILE_MAPPED);
1051 mem_cgroup_inc_page_stat(page, MEM_CGROUP_STAT_FILE_MAPPED); 1052 mem_cgroup_inc_page_stat(memcg, MEM_CGROUP_STAT_FILE_MAPPED);
1052 } 1053 }
1053 mem_cgroup_end_update_page_stat(page, &locked, &flags); 1054 mem_cgroup_end_page_stat(memcg, locked, flags);
1055}
1056
1057static void page_remove_file_rmap(struct page *page)
1058{
1059 struct mem_cgroup *memcg;
1060 unsigned long flags;
1061 bool locked;
1062
1063 memcg = mem_cgroup_begin_page_stat(page, &locked, &flags);
1064
1065 /* page still mapped by someone else? */
1066 if (!atomic_add_negative(-1, &page->_mapcount))
1067 goto out;
1068
1069 /* Hugepages are not counted in NR_FILE_MAPPED for now. */
1070 if (unlikely(PageHuge(page)))
1071 goto out;
1072
1073 /*
1074 * We use the irq-unsafe __{inc|mod}_zone_page_stat because
1075 * these counters are not modified in interrupt context, and
1076 * pte lock(a spinlock) is held, which implies preemption disabled.
1077 */
1078 __dec_zone_page_state(page, NR_FILE_MAPPED);
1079 mem_cgroup_dec_page_stat(memcg, MEM_CGROUP_STAT_FILE_MAPPED);
1080
1081 if (unlikely(PageMlocked(page)))
1082 clear_page_mlock(page);
1083out:
1084 mem_cgroup_end_page_stat(memcg, locked, flags);
1054} 1085}
1055 1086
1056/** 1087/**
@@ -1061,46 +1092,33 @@ void page_add_file_rmap(struct page *page)
1061 */ 1092 */
1062void page_remove_rmap(struct page *page) 1093void page_remove_rmap(struct page *page)
1063{ 1094{
1064 bool anon = PageAnon(page); 1095 if (!PageAnon(page)) {
1065 bool locked; 1096 page_remove_file_rmap(page);
1066 unsigned long flags; 1097 return;
1067 1098 }
1068 /*
1069 * The anon case has no mem_cgroup page_stat to update; but may
1070 * uncharge_page() below, where the lock ordering can deadlock if
1071 * we hold the lock against page_stat move: so avoid it on anon.
1072 */
1073 if (!anon)
1074 mem_cgroup_begin_update_page_stat(page, &locked, &flags);
1075 1099
1076 /* page still mapped by someone else? */ 1100 /* page still mapped by someone else? */
1077 if (!atomic_add_negative(-1, &page->_mapcount)) 1101 if (!atomic_add_negative(-1, &page->_mapcount))
1078 goto out; 1102 return;
1103
1104 /* Hugepages are not counted in NR_ANON_PAGES for now. */
1105 if (unlikely(PageHuge(page)))
1106 return;
1079 1107
1080 /* 1108 /*
1081 * Hugepages are not counted in NR_ANON_PAGES nor NR_FILE_MAPPED
1082 * and not charged by memcg for now.
1083 *
1084 * We use the irq-unsafe __{inc|mod}_zone_page_stat because 1109 * We use the irq-unsafe __{inc|mod}_zone_page_stat because
1085 * these counters are not modified in interrupt context, and 1110 * these counters are not modified in interrupt context, and
1086 * these counters are not modified in interrupt context, and
1087 * pte lock(a spinlock) is held, which implies preemption disabled. 1111 * pte lock(a spinlock) is held, which implies preemption disabled.
1088 */ 1112 */
1089 if (unlikely(PageHuge(page))) 1113 if (PageTransHuge(page))
1090 goto out; 1114 __dec_zone_page_state(page, NR_ANON_TRANSPARENT_HUGEPAGES);
1091 if (anon) { 1115
1092 if (PageTransHuge(page)) 1116 __mod_zone_page_state(page_zone(page), NR_ANON_PAGES,
1093 __dec_zone_page_state(page, 1117 -hpage_nr_pages(page));
1094 NR_ANON_TRANSPARENT_HUGEPAGES); 1118
1095 __mod_zone_page_state(page_zone(page), NR_ANON_PAGES,
1096 -hpage_nr_pages(page));
1097 } else {
1098 __dec_zone_page_state(page, NR_FILE_MAPPED);
1099 mem_cgroup_dec_page_stat(page, MEM_CGROUP_STAT_FILE_MAPPED);
1100 mem_cgroup_end_update_page_stat(page, &locked, &flags);
1101 }
1102 if (unlikely(PageMlocked(page))) 1119 if (unlikely(PageMlocked(page)))
1103 clear_page_mlock(page); 1120 clear_page_mlock(page);
1121
1104 /* 1122 /*
1105 * It would be tidy to reset the PageAnon mapping here, 1123 * It would be tidy to reset the PageAnon mapping here,
1106 * but that might overwrite a racing page_add_anon_rmap 1124 * but that might overwrite a racing page_add_anon_rmap
@@ -1110,10 +1128,6 @@ void page_remove_rmap(struct page *page)
1110 * Leaving it set also helps swapoff to reinstate ptes 1128 * Leaving it set also helps swapoff to reinstate ptes
1111 * faster for those pages still in swapcache. 1129 * faster for those pages still in swapcache.
1112 */ 1130 */
1113 return;
1114out:
1115 if (!anon)
1116 mem_cgroup_end_update_page_stat(page, &locked, &flags);
1117} 1131}
1118 1132
1119/* 1133/*
diff --git a/mm/slab_common.c b/mm/slab_common.c
index 3a6e0cfdf03a..406944207b61 100644
--- a/mm/slab_common.c
+++ b/mm/slab_common.c
@@ -93,16 +93,6 @@ static int kmem_cache_sanity_check(const char *name, size_t size)
93 s->object_size); 93 s->object_size);
94 continue; 94 continue;
95 } 95 }
96
97#if !defined(CONFIG_SLUB)
98 if (!strcmp(s->name, name)) {
99 pr_err("%s (%s): Cache name already exists.\n",
100 __func__, name);
101 dump_stack();
102 s = NULL;
103 return -EINVAL;
104 }
105#endif
106 } 96 }
107 97
108 WARN_ON(strchr(name, ' ')); /* It confuses parsers */ 98 WARN_ON(strchr(name, ' ')); /* It confuses parsers */
diff --git a/net/Kconfig b/net/Kconfig
index 6272420a721b..99815b5454bf 100644
--- a/net/Kconfig
+++ b/net/Kconfig
@@ -6,7 +6,7 @@ menuconfig NET
6 bool "Networking support" 6 bool "Networking support"
7 select NLATTR 7 select NLATTR
8 select GENERIC_NET_UTILS 8 select GENERIC_NET_UTILS
9 select ANON_INODES 9 select BPF
10 ---help--- 10 ---help---
11 Unless you really know what you are doing, you should say Y here. 11 Unless you really know what you are doing, you should say Y here.
12 The reason is that some programs need kernel networking support even 12 The reason is that some programs need kernel networking support even
diff --git a/net/bridge/br_forward.c b/net/bridge/br_forward.c
index 992ec49a96aa..44cb786b925a 100644
--- a/net/bridge/br_forward.c
+++ b/net/bridge/br_forward.c
@@ -112,6 +112,7 @@ void br_deliver(const struct net_bridge_port *to, struct sk_buff *skb)
112 112
113 kfree_skb(skb); 113 kfree_skb(skb);
114} 114}
115EXPORT_SYMBOL_GPL(br_deliver);
115 116
116/* called with rcu_read_lock */ 117/* called with rcu_read_lock */
117void br_forward(const struct net_bridge_port *to, struct sk_buff *skb, struct sk_buff *skb0) 118void br_forward(const struct net_bridge_port *to, struct sk_buff *skb, struct sk_buff *skb0)
diff --git a/net/bridge/br_netfilter.c b/net/bridge/br_netfilter.c
index 1bada53bb195..1a4f32c09ad5 100644
--- a/net/bridge/br_netfilter.c
+++ b/net/bridge/br_netfilter.c
@@ -192,7 +192,6 @@ static inline void nf_bridge_save_header(struct sk_buff *skb)
192 192
193static int br_parse_ip_options(struct sk_buff *skb) 193static int br_parse_ip_options(struct sk_buff *skb)
194{ 194{
195 struct ip_options *opt;
196 const struct iphdr *iph; 195 const struct iphdr *iph;
197 struct net_device *dev = skb->dev; 196 struct net_device *dev = skb->dev;
198 u32 len; 197 u32 len;
@@ -201,7 +200,6 @@ static int br_parse_ip_options(struct sk_buff *skb)
201 goto inhdr_error; 200 goto inhdr_error;
202 201
203 iph = ip_hdr(skb); 202 iph = ip_hdr(skb);
204 opt = &(IPCB(skb)->opt);
205 203
206 /* Basic sanity checks */ 204 /* Basic sanity checks */
207 if (iph->ihl < 5 || iph->version != 4) 205 if (iph->ihl < 5 || iph->version != 4)
@@ -227,23 +225,11 @@ static int br_parse_ip_options(struct sk_buff *skb)
227 } 225 }
228 226
229 memset(IPCB(skb), 0, sizeof(struct inet_skb_parm)); 227 memset(IPCB(skb), 0, sizeof(struct inet_skb_parm));
230 if (iph->ihl == 5) 228 /* We should really parse IP options here but until
231 return 0; 229 * somebody who actually uses IP options complains to
232 230 * us we'll just silently ignore the options because
233 opt->optlen = iph->ihl*4 - sizeof(struct iphdr); 231 * we're lazy!
234 if (ip_options_compile(dev_net(dev), opt, skb)) 232 */
235 goto inhdr_error;
236
237 /* Check correct handling of SRR option */
238 if (unlikely(opt->srr)) {
239 struct in_device *in_dev = __in_dev_get_rcu(dev);
240 if (in_dev && !IN_DEV_SOURCE_ROUTE(in_dev))
241 goto drop;
242
243 if (ip_options_rcv_srr(skb))
244 goto drop;
245 }
246
247 return 0; 233 return 0;
248 234
249inhdr_error: 235inhdr_error:
diff --git a/net/bridge/netfilter/nf_tables_bridge.c b/net/bridge/netfilter/nf_tables_bridge.c
index da17a5eab8b4..074c557ab505 100644
--- a/net/bridge/netfilter/nf_tables_bridge.c
+++ b/net/bridge/netfilter/nf_tables_bridge.c
@@ -75,9 +75,11 @@ static const struct nf_chain_type filter_bridge = {
75 .type = NFT_CHAIN_T_DEFAULT, 75 .type = NFT_CHAIN_T_DEFAULT,
76 .family = NFPROTO_BRIDGE, 76 .family = NFPROTO_BRIDGE,
77 .owner = THIS_MODULE, 77 .owner = THIS_MODULE,
78 .hook_mask = (1 << NF_BR_LOCAL_IN) | 78 .hook_mask = (1 << NF_BR_PRE_ROUTING) |
79 (1 << NF_BR_LOCAL_IN) |
79 (1 << NF_BR_FORWARD) | 80 (1 << NF_BR_FORWARD) |
80 (1 << NF_BR_LOCAL_OUT), 81 (1 << NF_BR_LOCAL_OUT) |
82 (1 << NF_BR_POST_ROUTING),
81}; 83};
82 84
83static int __init nf_tables_bridge_init(void) 85static int __init nf_tables_bridge_init(void)
diff --git a/net/bridge/netfilter/nft_reject_bridge.c b/net/bridge/netfilter/nft_reject_bridge.c
index a76479535df2..654c9018e3e7 100644
--- a/net/bridge/netfilter/nft_reject_bridge.c
+++ b/net/bridge/netfilter/nft_reject_bridge.c
@@ -16,6 +16,238 @@
16#include <net/netfilter/nft_reject.h> 16#include <net/netfilter/nft_reject.h>
17#include <net/netfilter/ipv4/nf_reject.h> 17#include <net/netfilter/ipv4/nf_reject.h>
18#include <net/netfilter/ipv6/nf_reject.h> 18#include <net/netfilter/ipv6/nf_reject.h>
19#include <linux/ip.h>
20#include <net/ip.h>
21#include <linux/netfilter_bridge.h>
22#include "../br_private.h"
23
24static void nft_reject_br_push_etherhdr(struct sk_buff *oldskb,
25 struct sk_buff *nskb)
26{
27 struct ethhdr *eth;
28
29 eth = (struct ethhdr *)skb_push(nskb, ETH_HLEN);
30 skb_reset_mac_header(nskb);
31 ether_addr_copy(eth->h_source, eth_hdr(oldskb)->h_dest);
32 ether_addr_copy(eth->h_dest, eth_hdr(oldskb)->h_source);
33 eth->h_proto = eth_hdr(oldskb)->h_proto;
34 skb_pull(nskb, ETH_HLEN);
35}
36
37static int nft_reject_iphdr_validate(struct sk_buff *oldskb)
38{
39 struct iphdr *iph;
40 u32 len;
41
42 if (!pskb_may_pull(oldskb, sizeof(struct iphdr)))
43 return 0;
44
45 iph = ip_hdr(oldskb);
46 if (iph->ihl < 5 || iph->version != 4)
47 return 0;
48
49 len = ntohs(iph->tot_len);
50 if (oldskb->len < len)
51 return 0;
52 else if (len < (iph->ihl*4))
53 return 0;
54
55 if (!pskb_may_pull(oldskb, iph->ihl*4))
56 return 0;
57
58 return 1;
59}
60
61static void nft_reject_br_send_v4_tcp_reset(struct sk_buff *oldskb, int hook)
62{
63 struct sk_buff *nskb;
64 struct iphdr *niph;
65 const struct tcphdr *oth;
66 struct tcphdr _oth;
67
68 if (!nft_reject_iphdr_validate(oldskb))
69 return;
70
71 oth = nf_reject_ip_tcphdr_get(oldskb, &_oth, hook);
72 if (!oth)
73 return;
74
75 nskb = alloc_skb(sizeof(struct iphdr) + sizeof(struct tcphdr) +
76 LL_MAX_HEADER, GFP_ATOMIC);
77 if (!nskb)
78 return;
79
80 skb_reserve(nskb, LL_MAX_HEADER);
81 niph = nf_reject_iphdr_put(nskb, oldskb, IPPROTO_TCP,
82 sysctl_ip_default_ttl);
83 nf_reject_ip_tcphdr_put(nskb, oldskb, oth);
84 niph->ttl = sysctl_ip_default_ttl;
85 niph->tot_len = htons(nskb->len);
86 ip_send_check(niph);
87
88 nft_reject_br_push_etherhdr(oldskb, nskb);
89
90 br_deliver(br_port_get_rcu(oldskb->dev), nskb);
91}
92
93static void nft_reject_br_send_v4_unreach(struct sk_buff *oldskb, int hook,
94 u8 code)
95{
96 struct sk_buff *nskb;
97 struct iphdr *niph;
98 struct icmphdr *icmph;
99 unsigned int len;
100 void *payload;
101 __wsum csum;
102
103 if (!nft_reject_iphdr_validate(oldskb))
104 return;
105
106 /* IP header checks: fragment. */
107 if (ip_hdr(oldskb)->frag_off & htons(IP_OFFSET))
108 return;
109
110 /* RFC says return as much as we can without exceeding 576 bytes. */
111 len = min_t(unsigned int, 536, oldskb->len);
112
113 if (!pskb_may_pull(oldskb, len))
114 return;
115
116 if (nf_ip_checksum(oldskb, hook, ip_hdrlen(oldskb), 0))
117 return;
118
119 nskb = alloc_skb(sizeof(struct iphdr) + sizeof(struct icmphdr) +
120 LL_MAX_HEADER + len, GFP_ATOMIC);
121 if (!nskb)
122 return;
123
124 skb_reserve(nskb, LL_MAX_HEADER);
125 niph = nf_reject_iphdr_put(nskb, oldskb, IPPROTO_ICMP,
126 sysctl_ip_default_ttl);
127
128 skb_reset_transport_header(nskb);
129 icmph = (struct icmphdr *)skb_put(nskb, sizeof(struct icmphdr));
130 memset(icmph, 0, sizeof(*icmph));
131 icmph->type = ICMP_DEST_UNREACH;
132 icmph->code = code;
133
134 payload = skb_put(nskb, len);
135 memcpy(payload, skb_network_header(oldskb), len);
136
137 csum = csum_partial((void *)icmph, len + sizeof(struct icmphdr), 0);
138 icmph->checksum = csum_fold(csum);
139
140 niph->tot_len = htons(nskb->len);
141 ip_send_check(niph);
142
143 nft_reject_br_push_etherhdr(oldskb, nskb);
144
145 br_deliver(br_port_get_rcu(oldskb->dev), nskb);
146}
147
148static int nft_reject_ip6hdr_validate(struct sk_buff *oldskb)
149{
150 struct ipv6hdr *hdr;
151 u32 pkt_len;
152
153 if (!pskb_may_pull(oldskb, sizeof(struct ipv6hdr)))
154 return 0;
155
156 hdr = ipv6_hdr(oldskb);
157 if (hdr->version != 6)
158 return 0;
159
160 pkt_len = ntohs(hdr->payload_len);
161 if (pkt_len + sizeof(struct ipv6hdr) > oldskb->len)
162 return 0;
163
164 return 1;
165}
166
167static void nft_reject_br_send_v6_tcp_reset(struct net *net,
168 struct sk_buff *oldskb, int hook)
169{
170 struct sk_buff *nskb;
171 const struct tcphdr *oth;
172 struct tcphdr _oth;
173 unsigned int otcplen;
174 struct ipv6hdr *nip6h;
175
176 if (!nft_reject_ip6hdr_validate(oldskb))
177 return;
178
179 oth = nf_reject_ip6_tcphdr_get(oldskb, &_oth, &otcplen, hook);
180 if (!oth)
181 return;
182
183 nskb = alloc_skb(sizeof(struct ipv6hdr) + sizeof(struct tcphdr) +
184 LL_MAX_HEADER, GFP_ATOMIC);
185 if (!nskb)
186 return;
187
188 skb_reserve(nskb, LL_MAX_HEADER);
189 nip6h = nf_reject_ip6hdr_put(nskb, oldskb, IPPROTO_TCP,
190 net->ipv6.devconf_all->hop_limit);
191 nf_reject_ip6_tcphdr_put(nskb, oldskb, oth, otcplen);
192 nip6h->payload_len = htons(nskb->len - sizeof(struct ipv6hdr));
193
194 nft_reject_br_push_etherhdr(oldskb, nskb);
195
196 br_deliver(br_port_get_rcu(oldskb->dev), nskb);
197}
198
199static void nft_reject_br_send_v6_unreach(struct net *net,
200 struct sk_buff *oldskb, int hook,
201 u8 code)
202{
203 struct sk_buff *nskb;
204 struct ipv6hdr *nip6h;
205 struct icmp6hdr *icmp6h;
206 unsigned int len;
207 void *payload;
208
209 if (!nft_reject_ip6hdr_validate(oldskb))
210 return;
211
212 /* Include "As much of invoking packet as possible without the ICMPv6
213 * packet exceeding the minimum IPv6 MTU" in the ICMP payload.
214 */
215 len = min_t(unsigned int, 1220, oldskb->len);
216
217 if (!pskb_may_pull(oldskb, len))
218 return;
219
220 nskb = alloc_skb(sizeof(struct iphdr) + sizeof(struct icmp6hdr) +
221 LL_MAX_HEADER + len, GFP_ATOMIC);
222 if (!nskb)
223 return;
224
225 skb_reserve(nskb, LL_MAX_HEADER);
226 nip6h = nf_reject_ip6hdr_put(nskb, oldskb, IPPROTO_ICMPV6,
227 net->ipv6.devconf_all->hop_limit);
228
229 skb_reset_transport_header(nskb);
230 icmp6h = (struct icmp6hdr *)skb_put(nskb, sizeof(struct icmp6hdr));
231 memset(icmp6h, 0, sizeof(*icmp6h));
232 icmp6h->icmp6_type = ICMPV6_DEST_UNREACH;
233 icmp6h->icmp6_code = code;
234
235 payload = skb_put(nskb, len);
236 memcpy(payload, skb_network_header(oldskb), len);
237 nip6h->payload_len = htons(nskb->len - sizeof(struct ipv6hdr));
238
239 icmp6h->icmp6_cksum =
240 csum_ipv6_magic(&nip6h->saddr, &nip6h->daddr,
241 nskb->len - sizeof(struct ipv6hdr),
242 IPPROTO_ICMPV6,
243 csum_partial(icmp6h,
244 nskb->len - sizeof(struct ipv6hdr),
245 0));
246
247 nft_reject_br_push_etherhdr(oldskb, nskb);
248
249 br_deliver(br_port_get_rcu(oldskb->dev), nskb);
250}
19 251
20static void nft_reject_bridge_eval(const struct nft_expr *expr, 252static void nft_reject_bridge_eval(const struct nft_expr *expr,
21 struct nft_data data[NFT_REG_MAX + 1], 253 struct nft_data data[NFT_REG_MAX + 1],
@@ -23,35 +255,46 @@ static void nft_reject_bridge_eval(const struct nft_expr *expr,
23{ 255{
24 struct nft_reject *priv = nft_expr_priv(expr); 256 struct nft_reject *priv = nft_expr_priv(expr);
25 struct net *net = dev_net((pkt->in != NULL) ? pkt->in : pkt->out); 257 struct net *net = dev_net((pkt->in != NULL) ? pkt->in : pkt->out);
258 const unsigned char *dest = eth_hdr(pkt->skb)->h_dest;
259
260 if (is_broadcast_ether_addr(dest) ||
261 is_multicast_ether_addr(dest))
262 goto out;
26 263
27 switch (eth_hdr(pkt->skb)->h_proto) { 264 switch (eth_hdr(pkt->skb)->h_proto) {
28 case htons(ETH_P_IP): 265 case htons(ETH_P_IP):
29 switch (priv->type) { 266 switch (priv->type) {
30 case NFT_REJECT_ICMP_UNREACH: 267 case NFT_REJECT_ICMP_UNREACH:
31 nf_send_unreach(pkt->skb, priv->icmp_code); 268 nft_reject_br_send_v4_unreach(pkt->skb,
269 pkt->ops->hooknum,
270 priv->icmp_code);
32 break; 271 break;
33 case NFT_REJECT_TCP_RST: 272 case NFT_REJECT_TCP_RST:
34 nf_send_reset(pkt->skb, pkt->ops->hooknum); 273 nft_reject_br_send_v4_tcp_reset(pkt->skb,
274 pkt->ops->hooknum);
35 break; 275 break;
36 case NFT_REJECT_ICMPX_UNREACH: 276 case NFT_REJECT_ICMPX_UNREACH:
37 nf_send_unreach(pkt->skb, 277 nft_reject_br_send_v4_unreach(pkt->skb,
38 nft_reject_icmp_code(priv->icmp_code)); 278 pkt->ops->hooknum,
279 nft_reject_icmp_code(priv->icmp_code));
39 break; 280 break;
40 } 281 }
41 break; 282 break;
42 case htons(ETH_P_IPV6): 283 case htons(ETH_P_IPV6):
43 switch (priv->type) { 284 switch (priv->type) {
44 case NFT_REJECT_ICMP_UNREACH: 285 case NFT_REJECT_ICMP_UNREACH:
45 nf_send_unreach6(net, pkt->skb, priv->icmp_code, 286 nft_reject_br_send_v6_unreach(net, pkt->skb,
46 pkt->ops->hooknum); 287 pkt->ops->hooknum,
288 priv->icmp_code);
47 break; 289 break;
48 case NFT_REJECT_TCP_RST: 290 case NFT_REJECT_TCP_RST:
49 nf_send_reset6(net, pkt->skb, pkt->ops->hooknum); 291 nft_reject_br_send_v6_tcp_reset(net, pkt->skb,
292 pkt->ops->hooknum);
50 break; 293 break;
51 case NFT_REJECT_ICMPX_UNREACH: 294 case NFT_REJECT_ICMPX_UNREACH:
52 nf_send_unreach6(net, pkt->skb, 295 nft_reject_br_send_v6_unreach(net, pkt->skb,
53 nft_reject_icmpv6_code(priv->icmp_code), 296 pkt->ops->hooknum,
54 pkt->ops->hooknum); 297 nft_reject_icmpv6_code(priv->icmp_code));
55 break; 298 break;
56 } 299 }
57 break; 300 break;
@@ -59,15 +302,38 @@ static void nft_reject_bridge_eval(const struct nft_expr *expr,
59 /* No explicit way to reject this protocol, drop it. */ 302 /* No explicit way to reject this protocol, drop it. */
60 break; 303 break;
61 } 304 }
305out:
62 data[NFT_REG_VERDICT].verdict = NF_DROP; 306 data[NFT_REG_VERDICT].verdict = NF_DROP;
63} 307}
64 308
309static int nft_reject_bridge_validate_hooks(const struct nft_chain *chain)
310{
311 struct nft_base_chain *basechain;
312
313 if (chain->flags & NFT_BASE_CHAIN) {
314 basechain = nft_base_chain(chain);
315
316 switch (basechain->ops[0].hooknum) {
317 case NF_BR_PRE_ROUTING:
318 case NF_BR_LOCAL_IN:
319 break;
320 default:
321 return -EOPNOTSUPP;
322 }
323 }
324 return 0;
325}
326
65static int nft_reject_bridge_init(const struct nft_ctx *ctx, 327static int nft_reject_bridge_init(const struct nft_ctx *ctx,
66 const struct nft_expr *expr, 328 const struct nft_expr *expr,
67 const struct nlattr * const tb[]) 329 const struct nlattr * const tb[])
68{ 330{
69 struct nft_reject *priv = nft_expr_priv(expr); 331 struct nft_reject *priv = nft_expr_priv(expr);
70 int icmp_code; 332 int icmp_code, err;
333
334 err = nft_reject_bridge_validate_hooks(ctx->chain);
335 if (err < 0)
336 return err;
71 337
72 if (tb[NFTA_REJECT_TYPE] == NULL) 338 if (tb[NFTA_REJECT_TYPE] == NULL)
73 return -EINVAL; 339 return -EINVAL;
@@ -116,6 +382,13 @@ nla_put_failure:
116 return -1; 382 return -1;
117} 383}
118 384
385static int nft_reject_bridge_validate(const struct nft_ctx *ctx,
386 const struct nft_expr *expr,
387 const struct nft_data **data)
388{
389 return nft_reject_bridge_validate_hooks(ctx->chain);
390}
391
119static struct nft_expr_type nft_reject_bridge_type; 392static struct nft_expr_type nft_reject_bridge_type;
120static const struct nft_expr_ops nft_reject_bridge_ops = { 393static const struct nft_expr_ops nft_reject_bridge_ops = {
121 .type = &nft_reject_bridge_type, 394 .type = &nft_reject_bridge_type,
@@ -123,6 +396,7 @@ static const struct nft_expr_ops nft_reject_bridge_ops = {
123 .eval = nft_reject_bridge_eval, 396 .eval = nft_reject_bridge_eval,
124 .init = nft_reject_bridge_init, 397 .init = nft_reject_bridge_init,
125 .dump = nft_reject_bridge_dump, 398 .dump = nft_reject_bridge_dump,
399 .validate = nft_reject_bridge_validate,
126}; 400};
127 401
128static struct nft_expr_type nft_reject_bridge_type __read_mostly = { 402static struct nft_expr_type nft_reject_bridge_type __read_mostly = {
diff --git a/net/ceph/auth_x.c b/net/ceph/auth_x.c
index de6662b14e1f..7e38b729696a 100644
--- a/net/ceph/auth_x.c
+++ b/net/ceph/auth_x.c
@@ -149,6 +149,7 @@ static int process_one_ticket(struct ceph_auth_client *ac,
149 struct ceph_crypto_key old_key; 149 struct ceph_crypto_key old_key;
150 void *ticket_buf = NULL; 150 void *ticket_buf = NULL;
151 void *tp, *tpend; 151 void *tp, *tpend;
152 void **ptp;
152 struct ceph_timespec new_validity; 153 struct ceph_timespec new_validity;
153 struct ceph_crypto_key new_session_key; 154 struct ceph_crypto_key new_session_key;
154 struct ceph_buffer *new_ticket_blob; 155 struct ceph_buffer *new_ticket_blob;
@@ -208,25 +209,19 @@ static int process_one_ticket(struct ceph_auth_client *ac,
208 goto out; 209 goto out;
209 } 210 }
210 tp = ticket_buf; 211 tp = ticket_buf;
211 dlen = ceph_decode_32(&tp); 212 ptp = &tp;
213 tpend = *ptp + dlen;
212 } else { 214 } else {
213 /* unencrypted */ 215 /* unencrypted */
214 ceph_decode_32_safe(p, end, dlen, bad); 216 ptp = p;
215 ticket_buf = kmalloc(dlen, GFP_NOFS); 217 tpend = end;
216 if (!ticket_buf) {
217 ret = -ENOMEM;
218 goto out;
219 }
220 tp = ticket_buf;
221 ceph_decode_need(p, end, dlen, bad);
222 ceph_decode_copy(p, ticket_buf, dlen);
223 } 218 }
224 tpend = tp + dlen; 219 ceph_decode_32_safe(ptp, tpend, dlen, bad);
225 dout(" ticket blob is %d bytes\n", dlen); 220 dout(" ticket blob is %d bytes\n", dlen);
226 ceph_decode_need(&tp, tpend, 1 + sizeof(u64), bad); 221 ceph_decode_need(ptp, tpend, 1 + sizeof(u64), bad);
227 blob_struct_v = ceph_decode_8(&tp); 222 blob_struct_v = ceph_decode_8(ptp);
228 new_secret_id = ceph_decode_64(&tp); 223 new_secret_id = ceph_decode_64(ptp);
229 ret = ceph_decode_buffer(&new_ticket_blob, &tp, tpend); 224 ret = ceph_decode_buffer(&new_ticket_blob, ptp, tpend);
230 if (ret) 225 if (ret)
231 goto out; 226 goto out;
232 227
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index 559c9f619c20..8d1653caffdb 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -484,7 +484,7 @@ static int ceph_tcp_connect(struct ceph_connection *con)
484 IPPROTO_TCP, &sock); 484 IPPROTO_TCP, &sock);
485 if (ret) 485 if (ret)
486 return ret; 486 return ret;
487 sock->sk->sk_allocation = GFP_NOFS; 487 sock->sk->sk_allocation = GFP_NOFS | __GFP_MEMALLOC;
488 488
489#ifdef CONFIG_LOCKDEP 489#ifdef CONFIG_LOCKDEP
490 lockdep_set_class(&sock->sk->sk_lock, &socket_class); 490 lockdep_set_class(&sock->sk->sk_lock, &socket_class);
@@ -509,6 +509,9 @@ static int ceph_tcp_connect(struct ceph_connection *con)
509 509
510 return ret; 510 return ret;
511 } 511 }
512
513 sk_set_memalloc(sock->sk);
514
512 con->sock = sock; 515 con->sock = sock;
513 return 0; 516 return 0;
514} 517}
@@ -2769,8 +2772,11 @@ static void con_work(struct work_struct *work)
2769{ 2772{
2770 struct ceph_connection *con = container_of(work, struct ceph_connection, 2773 struct ceph_connection *con = container_of(work, struct ceph_connection,
2771 work.work); 2774 work.work);
2775 unsigned long pflags = current->flags;
2772 bool fault; 2776 bool fault;
2773 2777
2778 current->flags |= PF_MEMALLOC;
2779
2774 mutex_lock(&con->mutex); 2780 mutex_lock(&con->mutex);
2775 while (true) { 2781 while (true) {
2776 int ret; 2782 int ret;
@@ -2824,6 +2830,8 @@ static void con_work(struct work_struct *work)
2824 con_fault_finish(con); 2830 con_fault_finish(con);
2825 2831
2826 con->ops->put(con); 2832 con->ops->put(con);
2833
2834 tsk_restore_flags(current, pflags, PF_MEMALLOC);
2827} 2835}
2828 2836
2829/* 2837/*
diff --git a/net/core/dev.c b/net/core/dev.c
index c5a9d73147a6..3acff0974560 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -4157,6 +4157,10 @@ EXPORT_SYMBOL(napi_gro_receive);
4157 4157
4158static void napi_reuse_skb(struct napi_struct *napi, struct sk_buff *skb) 4158static void napi_reuse_skb(struct napi_struct *napi, struct sk_buff *skb)
4159{ 4159{
4160 if (unlikely(skb->pfmemalloc)) {
4161 consume_skb(skb);
4162 return;
4163 }
4160 __skb_pull(skb, skb_headlen(skb)); 4164 __skb_pull(skb, skb_headlen(skb));
4161 /* restore the reserve we had after netdev_alloc_skb_ip_align() */ 4165 /* restore the reserve we had after netdev_alloc_skb_ip_align() */
4162 skb_reserve(skb, NET_SKB_PAD + NET_IP_ALIGN - skb_headroom(skb)); 4166 skb_reserve(skb, NET_SKB_PAD + NET_IP_ALIGN - skb_headroom(skb));
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index 1600aa24d36b..06dfb293e5aa 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -1036,7 +1036,8 @@ static int ethtool_get_eeprom(struct net_device *dev, void __user *useraddr)
1036{ 1036{
1037 const struct ethtool_ops *ops = dev->ethtool_ops; 1037 const struct ethtool_ops *ops = dev->ethtool_ops;
1038 1038
1039 if (!ops->get_eeprom || !ops->get_eeprom_len) 1039 if (!ops->get_eeprom || !ops->get_eeprom_len ||
1040 !ops->get_eeprom_len(dev))
1040 return -EOPNOTSUPP; 1041 return -EOPNOTSUPP;
1041 1042
1042 return ethtool_get_any_eeprom(dev, useraddr, ops->get_eeprom, 1043 return ethtool_get_any_eeprom(dev, useraddr, ops->get_eeprom,
@@ -1052,7 +1053,8 @@ static int ethtool_set_eeprom(struct net_device *dev, void __user *useraddr)
1052 u8 *data; 1053 u8 *data;
1053 int ret = 0; 1054 int ret = 0;
1054 1055
1055 if (!ops->set_eeprom || !ops->get_eeprom_len) 1056 if (!ops->set_eeprom || !ops->get_eeprom_len ||
1057 !ops->get_eeprom_len(dev))
1056 return -EOPNOTSUPP; 1058 return -EOPNOTSUPP;
1057 1059
1058 if (copy_from_user(&eeprom, useraddr, sizeof(eeprom))) 1060 if (copy_from_user(&eeprom, useraddr, sizeof(eeprom)))
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 61059a05ec95..c16615bfb61e 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -4070,15 +4070,22 @@ EXPORT_SYMBOL_GPL(skb_scrub_packet);
4070unsigned int skb_gso_transport_seglen(const struct sk_buff *skb) 4070unsigned int skb_gso_transport_seglen(const struct sk_buff *skb)
4071{ 4071{
4072 const struct skb_shared_info *shinfo = skb_shinfo(skb); 4072 const struct skb_shared_info *shinfo = skb_shinfo(skb);
4073 unsigned int thlen = 0;
4073 4074
4074 if (likely(shinfo->gso_type & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6))) 4075 if (skb->encapsulation) {
4075 return tcp_hdrlen(skb) + shinfo->gso_size; 4076 thlen = skb_inner_transport_header(skb) -
4077 skb_transport_header(skb);
4076 4078
4079 if (likely(shinfo->gso_type & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6)))
4080 thlen += inner_tcp_hdrlen(skb);
4081 } else if (likely(shinfo->gso_type & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6))) {
4082 thlen = tcp_hdrlen(skb);
4083 }
4077 /* UFO sets gso_size to the size of the fragmentation 4084 /* UFO sets gso_size to the size of the fragmentation
4078 * payload, i.e. the size of the L4 (UDP) header is already 4085 * payload, i.e. the size of the L4 (UDP) header is already
4079 * accounted for. 4086 * accounted for.
4080 */ 4087 */
4081 return shinfo->gso_size; 4088 return thlen + shinfo->gso_size;
4082} 4089}
4083EXPORT_SYMBOL_GPL(skb_gso_transport_seglen); 4090EXPORT_SYMBOL_GPL(skb_gso_transport_seglen);
4084 4091
diff --git a/net/core/tso.c b/net/core/tso.c
index 8c3203c585b0..630b30b4fb53 100644
--- a/net/core/tso.c
+++ b/net/core/tso.c
@@ -1,6 +1,7 @@
1#include <linux/export.h> 1#include <linux/export.h>
2#include <net/ip.h> 2#include <net/ip.h>
3#include <net/tso.h> 3#include <net/tso.h>
4#include <asm/unaligned.h>
4 5
5/* Calculate expected number of TX descriptors */ 6/* Calculate expected number of TX descriptors */
6int tso_count_descs(struct sk_buff *skb) 7int tso_count_descs(struct sk_buff *skb)
@@ -23,7 +24,7 @@ void tso_build_hdr(struct sk_buff *skb, char *hdr, struct tso_t *tso,
23 iph->id = htons(tso->ip_id); 24 iph->id = htons(tso->ip_id);
24 iph->tot_len = htons(size + hdr_len - mac_hdr_len); 25 iph->tot_len = htons(size + hdr_len - mac_hdr_len);
25 tcph = (struct tcphdr *)(hdr + skb_transport_offset(skb)); 26 tcph = (struct tcphdr *)(hdr + skb_transport_offset(skb));
26 tcph->seq = htonl(tso->tcp_seq); 27 put_unaligned_be32(tso->tcp_seq, &tcph->seq);
27 tso->ip_id++; 28 tso->ip_id++;
28 29
29 if (!is_last) { 30 if (!is_last) {
diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index 22f34cf4cb27..6317b41c99b0 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -174,8 +174,11 @@ dsa_switch_setup(struct dsa_switch_tree *dst, int index,
174 dst->rcv = brcm_netdev_ops.rcv; 174 dst->rcv = brcm_netdev_ops.rcv;
175 break; 175 break;
176#endif 176#endif
177 default: 177 case DSA_TAG_PROTO_NONE:
178 break; 178 break;
179 default:
180 ret = -ENOPROTOOPT;
181 goto out;
179 } 182 }
180 183
181 dst->tag_protocol = drv->tag_protocol; 184 dst->tag_protocol = drv->tag_protocol;
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index 92db7a69f2b9..8b7fe5b03906 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -1246,7 +1246,7 @@ static struct sk_buff *inet_gso_segment(struct sk_buff *skb,
1246 1246
1247 encap = SKB_GSO_CB(skb)->encap_level > 0; 1247 encap = SKB_GSO_CB(skb)->encap_level > 0;
1248 if (encap) 1248 if (encap)
1249 features = skb->dev->hw_enc_features & netif_skb_features(skb); 1249 features &= skb->dev->hw_enc_features;
1250 SKB_GSO_CB(skb)->encap_level += ihl; 1250 SKB_GSO_CB(skb)->encap_level += ihl;
1251 1251
1252 skb_reset_transport_header(skb); 1252 skb_reset_transport_header(skb);
diff --git a/net/ipv4/gre_offload.c b/net/ipv4/gre_offload.c
index ccda09628de7..bb5947b0ce2d 100644
--- a/net/ipv4/gre_offload.c
+++ b/net/ipv4/gre_offload.c
@@ -47,7 +47,7 @@ static struct sk_buff *gre_gso_segment(struct sk_buff *skb,
47 47
48 greh = (struct gre_base_hdr *)skb_transport_header(skb); 48 greh = (struct gre_base_hdr *)skb_transport_header(skb);
49 49
50 ghl = skb_inner_network_header(skb) - skb_transport_header(skb); 50 ghl = skb_inner_mac_header(skb) - skb_transport_header(skb);
51 if (unlikely(ghl < sizeof(*greh))) 51 if (unlikely(ghl < sizeof(*greh)))
52 goto out; 52 goto out;
53 53
@@ -68,7 +68,7 @@ static struct sk_buff *gre_gso_segment(struct sk_buff *skb,
68 skb->mac_len = skb_inner_network_offset(skb); 68 skb->mac_len = skb_inner_network_offset(skb);
69 69
70 /* segment inner packet. */ 70 /* segment inner packet. */
71 enc_features = skb->dev->hw_enc_features & netif_skb_features(skb); 71 enc_features = skb->dev->hw_enc_features & features;
72 segs = skb_mac_gso_segment(skb, enc_features); 72 segs = skb_mac_gso_segment(skb, enc_features);
73 if (IS_ERR_OR_NULL(segs)) { 73 if (IS_ERR_OR_NULL(segs)) {
74 skb_gso_error_unwind(skb, protocol, ghl, mac_offset, mac_len); 74 skb_gso_error_unwind(skb, protocol, ghl, mac_offset, mac_len);
diff --git a/net/ipv4/inet_fragment.c b/net/ipv4/inet_fragment.c
index 9eb89f3f0ee4..19419b60cb37 100644
--- a/net/ipv4/inet_fragment.c
+++ b/net/ipv4/inet_fragment.c
@@ -146,7 +146,6 @@ evict_again:
146 atomic_inc(&fq->refcnt); 146 atomic_inc(&fq->refcnt);
147 spin_unlock(&hb->chain_lock); 147 spin_unlock(&hb->chain_lock);
148 del_timer_sync(&fq->timer); 148 del_timer_sync(&fq->timer);
149 WARN_ON(atomic_read(&fq->refcnt) != 1);
150 inet_frag_put(fq, f); 149 inet_frag_put(fq, f);
151 goto evict_again; 150 goto evict_again;
152 } 151 }
@@ -285,7 +284,8 @@ static inline void fq_unlink(struct inet_frag_queue *fq, struct inet_frags *f)
285 struct inet_frag_bucket *hb; 284 struct inet_frag_bucket *hb;
286 285
287 hb = get_frag_bucket_locked(fq, f); 286 hb = get_frag_bucket_locked(fq, f);
288 hlist_del(&fq->list); 287 if (!(fq->flags & INET_FRAG_EVICTED))
288 hlist_del(&fq->list);
289 spin_unlock(&hb->chain_lock); 289 spin_unlock(&hb->chain_lock);
290} 290}
291 291
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index 88e5ef2c7f51..bc6471d4abcd 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -231,7 +231,7 @@ static int ip_finish_output_gso(struct sk_buff *skb)
231 */ 231 */
232 features = netif_skb_features(skb); 232 features = netif_skb_features(skb);
233 segs = skb_gso_segment(skb, features & ~NETIF_F_GSO_MASK); 233 segs = skb_gso_segment(skb, features & ~NETIF_F_GSO_MASK);
234 if (IS_ERR(segs)) { 234 if (IS_ERR_OR_NULL(segs)) {
235 kfree_skb(skb); 235 kfree_skb(skb);
236 return -ENOMEM; 236 return -ENOMEM;
237 } 237 }
diff --git a/net/ipv4/netfilter/nf_reject_ipv4.c b/net/ipv4/netfilter/nf_reject_ipv4.c
index b023b4eb1a96..1baaa83dfe5c 100644
--- a/net/ipv4/netfilter/nf_reject_ipv4.c
+++ b/net/ipv4/netfilter/nf_reject_ipv4.c
@@ -6,48 +6,45 @@
6 * published by the Free Software Foundation. 6 * published by the Free Software Foundation.
7 */ 7 */
8 8
9#include <linux/module.h>
9#include <net/ip.h> 10#include <net/ip.h>
10#include <net/tcp.h> 11#include <net/tcp.h>
11#include <net/route.h> 12#include <net/route.h>
12#include <net/dst.h> 13#include <net/dst.h>
13#include <linux/netfilter_ipv4.h> 14#include <linux/netfilter_ipv4.h>
15#include <net/netfilter/ipv4/nf_reject.h>
14 16
15/* Send RST reply */ 17const struct tcphdr *nf_reject_ip_tcphdr_get(struct sk_buff *oldskb,
16void nf_send_reset(struct sk_buff *oldskb, int hook) 18 struct tcphdr *_oth, int hook)
17{ 19{
18 struct sk_buff *nskb;
19 const struct iphdr *oiph;
20 struct iphdr *niph;
21 const struct tcphdr *oth; 20 const struct tcphdr *oth;
22 struct tcphdr _otcph, *tcph;
23 21
24 /* IP header checks: fragment. */ 22 /* IP header checks: fragment. */
25 if (ip_hdr(oldskb)->frag_off & htons(IP_OFFSET)) 23 if (ip_hdr(oldskb)->frag_off & htons(IP_OFFSET))
26 return; 24 return NULL;
27 25
28 oth = skb_header_pointer(oldskb, ip_hdrlen(oldskb), 26 oth = skb_header_pointer(oldskb, ip_hdrlen(oldskb),
29 sizeof(_otcph), &_otcph); 27 sizeof(struct tcphdr), _oth);
30 if (oth == NULL) 28 if (oth == NULL)
31 return; 29 return NULL;
32 30
33 /* No RST for RST. */ 31 /* No RST for RST. */
34 if (oth->rst) 32 if (oth->rst)
35 return; 33 return NULL;
36
37 if (skb_rtable(oldskb)->rt_flags & (RTCF_BROADCAST | RTCF_MULTICAST))
38 return;
39 34
40 /* Check checksum */ 35 /* Check checksum */
41 if (nf_ip_checksum(oldskb, hook, ip_hdrlen(oldskb), IPPROTO_TCP)) 36 if (nf_ip_checksum(oldskb, hook, ip_hdrlen(oldskb), IPPROTO_TCP))
42 return; 37 return NULL;
43 oiph = ip_hdr(oldskb);
44 38
45 nskb = alloc_skb(sizeof(struct iphdr) + sizeof(struct tcphdr) + 39 return oth;
46 LL_MAX_HEADER, GFP_ATOMIC); 40}
47 if (!nskb) 41EXPORT_SYMBOL_GPL(nf_reject_ip_tcphdr_get);
48 return;
49 42
50 skb_reserve(nskb, LL_MAX_HEADER); 43struct iphdr *nf_reject_iphdr_put(struct sk_buff *nskb,
44 const struct sk_buff *oldskb,
45 __be16 protocol, int ttl)
46{
47 struct iphdr *niph, *oiph = ip_hdr(oldskb);
51 48
52 skb_reset_network_header(nskb); 49 skb_reset_network_header(nskb);
53 niph = (struct iphdr *)skb_put(nskb, sizeof(struct iphdr)); 50 niph = (struct iphdr *)skb_put(nskb, sizeof(struct iphdr));
@@ -56,10 +53,23 @@ void nf_send_reset(struct sk_buff *oldskb, int hook)
56 niph->tos = 0; 53 niph->tos = 0;
57 niph->id = 0; 54 niph->id = 0;
58 niph->frag_off = htons(IP_DF); 55 niph->frag_off = htons(IP_DF);
59 niph->protocol = IPPROTO_TCP; 56 niph->protocol = protocol;
60 niph->check = 0; 57 niph->check = 0;
61 niph->saddr = oiph->daddr; 58 niph->saddr = oiph->daddr;
62 niph->daddr = oiph->saddr; 59 niph->daddr = oiph->saddr;
60 niph->ttl = ttl;
61
62 nskb->protocol = htons(ETH_P_IP);
63
64 return niph;
65}
66EXPORT_SYMBOL_GPL(nf_reject_iphdr_put);
67
68void nf_reject_ip_tcphdr_put(struct sk_buff *nskb, const struct sk_buff *oldskb,
69 const struct tcphdr *oth)
70{
71 struct iphdr *niph = ip_hdr(nskb);
72 struct tcphdr *tcph;
63 73
64 skb_reset_transport_header(nskb); 74 skb_reset_transport_header(nskb);
65 tcph = (struct tcphdr *)skb_put(nskb, sizeof(struct tcphdr)); 75 tcph = (struct tcphdr *)skb_put(nskb, sizeof(struct tcphdr));
@@ -68,9 +78,9 @@ void nf_send_reset(struct sk_buff *oldskb, int hook)
68 tcph->dest = oth->source; 78 tcph->dest = oth->source;
69 tcph->doff = sizeof(struct tcphdr) / 4; 79 tcph->doff = sizeof(struct tcphdr) / 4;
70 80
71 if (oth->ack) 81 if (oth->ack) {
72 tcph->seq = oth->ack_seq; 82 tcph->seq = oth->ack_seq;
73 else { 83 } else {
74 tcph->ack_seq = htonl(ntohl(oth->seq) + oth->syn + oth->fin + 84 tcph->ack_seq = htonl(ntohl(oth->seq) + oth->syn + oth->fin +
75 oldskb->len - ip_hdrlen(oldskb) - 85 oldskb->len - ip_hdrlen(oldskb) -
76 (oth->doff << 2)); 86 (oth->doff << 2));
@@ -83,16 +93,43 @@ void nf_send_reset(struct sk_buff *oldskb, int hook)
83 nskb->ip_summed = CHECKSUM_PARTIAL; 93 nskb->ip_summed = CHECKSUM_PARTIAL;
84 nskb->csum_start = (unsigned char *)tcph - nskb->head; 94 nskb->csum_start = (unsigned char *)tcph - nskb->head;
85 nskb->csum_offset = offsetof(struct tcphdr, check); 95 nskb->csum_offset = offsetof(struct tcphdr, check);
96}
97EXPORT_SYMBOL_GPL(nf_reject_ip_tcphdr_put);
98
99/* Send RST reply */
100void nf_send_reset(struct sk_buff *oldskb, int hook)
101{
102 struct sk_buff *nskb;
103 const struct iphdr *oiph;
104 struct iphdr *niph;
105 const struct tcphdr *oth;
106 struct tcphdr _oth;
107
108 oth = nf_reject_ip_tcphdr_get(oldskb, &_oth, hook);
109 if (!oth)
110 return;
111
112 if (skb_rtable(oldskb)->rt_flags & (RTCF_BROADCAST | RTCF_MULTICAST))
113 return;
114
115 oiph = ip_hdr(oldskb);
116
117 nskb = alloc_skb(sizeof(struct iphdr) + sizeof(struct tcphdr) +
118 LL_MAX_HEADER, GFP_ATOMIC);
119 if (!nskb)
120 return;
86 121
87 /* ip_route_me_harder expects skb->dst to be set */ 122 /* ip_route_me_harder expects skb->dst to be set */
88 skb_dst_set_noref(nskb, skb_dst(oldskb)); 123 skb_dst_set_noref(nskb, skb_dst(oldskb));
89 124
90 nskb->protocol = htons(ETH_P_IP); 125 skb_reserve(nskb, LL_MAX_HEADER);
126 niph = nf_reject_iphdr_put(nskb, oldskb, IPPROTO_TCP,
127 ip4_dst_hoplimit(skb_dst(nskb)));
128 nf_reject_ip_tcphdr_put(nskb, oldskb, oth);
129
91 if (ip_route_me_harder(nskb, RTN_UNSPEC)) 130 if (ip_route_me_harder(nskb, RTN_UNSPEC))
92 goto free_nskb; 131 goto free_nskb;
93 132
94 niph->ttl = ip4_dst_hoplimit(skb_dst(nskb));
95
96 /* "Never happens" */ 133 /* "Never happens" */
97 if (nskb->len > dst_mtu(skb_dst(nskb))) 134 if (nskb->len > dst_mtu(skb_dst(nskb)))
98 goto free_nskb; 135 goto free_nskb;
@@ -125,3 +162,5 @@ void nf_send_reset(struct sk_buff *oldskb, int hook)
125 kfree_skb(nskb); 162 kfree_skb(nskb);
126} 163}
127EXPORT_SYMBOL_GPL(nf_send_reset); 164EXPORT_SYMBOL_GPL(nf_send_reset);
165
166MODULE_LICENSE("GPL");
diff --git a/net/ipv4/netfilter/nft_masq_ipv4.c b/net/ipv4/netfilter/nft_masq_ipv4.c
index 1c636d6b5b50..c1023c445920 100644
--- a/net/ipv4/netfilter/nft_masq_ipv4.c
+++ b/net/ipv4/netfilter/nft_masq_ipv4.c
@@ -39,6 +39,7 @@ static const struct nft_expr_ops nft_masq_ipv4_ops = {
39 .eval = nft_masq_ipv4_eval, 39 .eval = nft_masq_ipv4_eval,
40 .init = nft_masq_init, 40 .init = nft_masq_init,
41 .dump = nft_masq_dump, 41 .dump = nft_masq_dump,
42 .validate = nft_masq_validate,
42}; 43};
43 44
44static struct nft_expr_type nft_masq_ipv4_type __read_mostly = { 45static struct nft_expr_type nft_masq_ipv4_type __read_mostly = {
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 2d4ae469b471..6a2155b02602 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -1798,6 +1798,7 @@ local_input:
1798no_route: 1798no_route:
1799 RT_CACHE_STAT_INC(in_no_route); 1799 RT_CACHE_STAT_INC(in_no_route);
1800 res.type = RTN_UNREACHABLE; 1800 res.type = RTN_UNREACHABLE;
1801 res.fi = NULL;
1801 goto local_input; 1802 goto local_input;
1802 1803
1803 /* 1804 /*
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 1bec4e76d88c..39ec0c379545 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -2868,61 +2868,42 @@ EXPORT_SYMBOL(compat_tcp_getsockopt);
2868#endif 2868#endif
2869 2869
2870#ifdef CONFIG_TCP_MD5SIG 2870#ifdef CONFIG_TCP_MD5SIG
2871static struct tcp_md5sig_pool __percpu *tcp_md5sig_pool __read_mostly; 2871static DEFINE_PER_CPU(struct tcp_md5sig_pool, tcp_md5sig_pool);
2872static DEFINE_MUTEX(tcp_md5sig_mutex); 2872static DEFINE_MUTEX(tcp_md5sig_mutex);
2873 2873static bool tcp_md5sig_pool_populated = false;
2874static void __tcp_free_md5sig_pool(struct tcp_md5sig_pool __percpu *pool)
2875{
2876 int cpu;
2877
2878 for_each_possible_cpu(cpu) {
2879 struct tcp_md5sig_pool *p = per_cpu_ptr(pool, cpu);
2880
2881 if (p->md5_desc.tfm)
2882 crypto_free_hash(p->md5_desc.tfm);
2883 }
2884 free_percpu(pool);
2885}
2886 2874
2887static void __tcp_alloc_md5sig_pool(void) 2875static void __tcp_alloc_md5sig_pool(void)
2888{ 2876{
2889 int cpu; 2877 int cpu;
2890 struct tcp_md5sig_pool __percpu *pool;
2891
2892 pool = alloc_percpu(struct tcp_md5sig_pool);
2893 if (!pool)
2894 return;
2895 2878
2896 for_each_possible_cpu(cpu) { 2879 for_each_possible_cpu(cpu) {
2897 struct crypto_hash *hash; 2880 if (!per_cpu(tcp_md5sig_pool, cpu).md5_desc.tfm) {
2898 2881 struct crypto_hash *hash;
2899 hash = crypto_alloc_hash("md5", 0, CRYPTO_ALG_ASYNC);
2900 if (IS_ERR_OR_NULL(hash))
2901 goto out_free;
2902 2882
2903 per_cpu_ptr(pool, cpu)->md5_desc.tfm = hash; 2883 hash = crypto_alloc_hash("md5", 0, CRYPTO_ALG_ASYNC);
2884 if (IS_ERR_OR_NULL(hash))
2885 return;
2886 per_cpu(tcp_md5sig_pool, cpu).md5_desc.tfm = hash;
2887 }
2904 } 2888 }
2905 /* before setting tcp_md5sig_pool, we must commit all writes 2889 /* before setting tcp_md5sig_pool_populated, we must commit all writes
2906 * to memory. See ACCESS_ONCE() in tcp_get_md5sig_pool() 2890 * to memory. See smp_rmb() in tcp_get_md5sig_pool()
2907 */ 2891 */
2908 smp_wmb(); 2892 smp_wmb();
2909 tcp_md5sig_pool = pool; 2893 tcp_md5sig_pool_populated = true;
2910 return;
2911out_free:
2912 __tcp_free_md5sig_pool(pool);
2913} 2894}
2914 2895
2915bool tcp_alloc_md5sig_pool(void) 2896bool tcp_alloc_md5sig_pool(void)
2916{ 2897{
2917 if (unlikely(!tcp_md5sig_pool)) { 2898 if (unlikely(!tcp_md5sig_pool_populated)) {
2918 mutex_lock(&tcp_md5sig_mutex); 2899 mutex_lock(&tcp_md5sig_mutex);
2919 2900
2920 if (!tcp_md5sig_pool) 2901 if (!tcp_md5sig_pool_populated)
2921 __tcp_alloc_md5sig_pool(); 2902 __tcp_alloc_md5sig_pool();
2922 2903
2923 mutex_unlock(&tcp_md5sig_mutex); 2904 mutex_unlock(&tcp_md5sig_mutex);
2924 } 2905 }
2925 return tcp_md5sig_pool != NULL; 2906 return tcp_md5sig_pool_populated;
2926} 2907}
2927EXPORT_SYMBOL(tcp_alloc_md5sig_pool); 2908EXPORT_SYMBOL(tcp_alloc_md5sig_pool);
2928 2909
@@ -2936,13 +2917,13 @@ EXPORT_SYMBOL(tcp_alloc_md5sig_pool);
2936 */ 2917 */
2937struct tcp_md5sig_pool *tcp_get_md5sig_pool(void) 2918struct tcp_md5sig_pool *tcp_get_md5sig_pool(void)
2938{ 2919{
2939 struct tcp_md5sig_pool __percpu *p;
2940
2941 local_bh_disable(); 2920 local_bh_disable();
2942 p = ACCESS_ONCE(tcp_md5sig_pool);
2943 if (p)
2944 return raw_cpu_ptr(p);
2945 2921
2922 if (tcp_md5sig_pool_populated) {
2923 /* coupled with smp_wmb() in __tcp_alloc_md5sig_pool() */
2924 smp_rmb();
2925 return this_cpu_ptr(&tcp_md5sig_pool);
2926 }
2946 local_bh_enable(); 2927 local_bh_enable();
2947 return NULL; 2928 return NULL;
2948} 2929}
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 94d1a7757ff7..9c7d7621466b 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -206,8 +206,6 @@ int tcp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
206 inet->inet_dport = usin->sin_port; 206 inet->inet_dport = usin->sin_port;
207 inet->inet_daddr = daddr; 207 inet->inet_daddr = daddr;
208 208
209 inet_set_txhash(sk);
210
211 inet_csk(sk)->icsk_ext_hdr_len = 0; 209 inet_csk(sk)->icsk_ext_hdr_len = 0;
212 if (inet_opt) 210 if (inet_opt)
213 inet_csk(sk)->icsk_ext_hdr_len = inet_opt->opt.optlen; 211 inet_csk(sk)->icsk_ext_hdr_len = inet_opt->opt.optlen;
@@ -224,6 +222,8 @@ int tcp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
224 if (err) 222 if (err)
225 goto failure; 223 goto failure;
226 224
225 inet_set_txhash(sk);
226
227 rt = ip_route_newports(fl4, rt, orig_sport, orig_dport, 227 rt = ip_route_newports(fl4, rt, orig_sport, orig_dport,
228 inet->inet_sport, inet->inet_dport, sk); 228 inet->inet_sport, inet->inet_dport, sk);
229 if (IS_ERR(rt)) { 229 if (IS_ERR(rt)) {
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 3af21296d967..a3d453b94747 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -2126,7 +2126,7 @@ bool tcp_schedule_loss_probe(struct sock *sk)
2126static bool skb_still_in_host_queue(const struct sock *sk, 2126static bool skb_still_in_host_queue(const struct sock *sk,
2127 const struct sk_buff *skb) 2127 const struct sk_buff *skb)
2128{ 2128{
2129 if (unlikely(skb_fclone_busy(skb))) { 2129 if (unlikely(skb_fclone_busy(sk, skb))) {
2130 NET_INC_STATS_BH(sock_net(sk), 2130 NET_INC_STATS_BH(sock_net(sk),
2131 LINUX_MIB_TCPSPURIOUS_RTX_HOSTQUEUES); 2131 LINUX_MIB_TCPSPURIOUS_RTX_HOSTQUEUES);
2132 return true; 2132 return true;
diff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c
index 507310ef4b56..6480cea7aa53 100644
--- a/net/ipv4/udp_offload.c
+++ b/net/ipv4/udp_offload.c
@@ -58,7 +58,7 @@ static struct sk_buff *__skb_udp_tunnel_segment(struct sk_buff *skb,
58 skb->encap_hdr_csum = 1; 58 skb->encap_hdr_csum = 1;
59 59
60 /* segment inner packet. */ 60 /* segment inner packet. */
61 enc_features = skb->dev->hw_enc_features & netif_skb_features(skb); 61 enc_features = skb->dev->hw_enc_features & features;
62 segs = gso_inner_segment(skb, enc_features); 62 segs = gso_inner_segment(skb, enc_features);
63 if (IS_ERR_OR_NULL(segs)) { 63 if (IS_ERR_OR_NULL(segs)) {
64 skb_gso_error_unwind(skb, protocol, tnl_hlen, mac_offset, 64 skb_gso_error_unwind(skb, protocol, tnl_hlen, mac_offset,
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 725c763270a0..0169ccf5aa4f 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -4531,6 +4531,7 @@ static int inet6_set_iftoken(struct inet6_dev *idev, struct in6_addr *token)
4531 } 4531 }
4532 4532
4533 write_unlock_bh(&idev->lock); 4533 write_unlock_bh(&idev->lock);
4534 inet6_ifinfo_notify(RTM_NEWLINK, idev);
4534 addrconf_verify_rtnl(); 4535 addrconf_verify_rtnl();
4535 return 0; 4536 return 0;
4536} 4537}
diff --git a/net/ipv6/ip6_offload.c b/net/ipv6/ip6_offload.c
index 91014d32488d..a071563a7e6e 100644
--- a/net/ipv6/ip6_offload.c
+++ b/net/ipv6/ip6_offload.c
@@ -90,7 +90,7 @@ static struct sk_buff *ipv6_gso_segment(struct sk_buff *skb,
90 90
91 encap = SKB_GSO_CB(skb)->encap_level > 0; 91 encap = SKB_GSO_CB(skb)->encap_level > 0;
92 if (encap) 92 if (encap)
93 features = skb->dev->hw_enc_features & netif_skb_features(skb); 93 features &= skb->dev->hw_enc_features;
94 SKB_GSO_CB(skb)->encap_level += sizeof(*ipv6h); 94 SKB_GSO_CB(skb)->encap_level += sizeof(*ipv6h);
95 95
96 ipv6h = ipv6_hdr(skb); 96 ipv6h = ipv6_hdr(skb);
diff --git a/net/ipv6/netfilter/nf_reject_ipv6.c b/net/ipv6/netfilter/nf_reject_ipv6.c
index 5f5f0438d74d..015eb8a80766 100644
--- a/net/ipv6/netfilter/nf_reject_ipv6.c
+++ b/net/ipv6/netfilter/nf_reject_ipv6.c
@@ -5,121 +5,109 @@
5 * it under the terms of the GNU General Public License version 2 as 5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation. 6 * published by the Free Software Foundation.
7 */ 7 */
8
9#include <linux/module.h>
8#include <net/ipv6.h> 10#include <net/ipv6.h>
9#include <net/ip6_route.h> 11#include <net/ip6_route.h>
10#include <net/ip6_fib.h> 12#include <net/ip6_fib.h>
11#include <net/ip6_checksum.h> 13#include <net/ip6_checksum.h>
12#include <linux/netfilter_ipv6.h> 14#include <linux/netfilter_ipv6.h>
15#include <net/netfilter/ipv6/nf_reject.h>
13 16
14void nf_send_reset6(struct net *net, struct sk_buff *oldskb, int hook) 17const struct tcphdr *nf_reject_ip6_tcphdr_get(struct sk_buff *oldskb,
18 struct tcphdr *otcph,
19 unsigned int *otcplen, int hook)
15{ 20{
16 struct sk_buff *nskb;
17 struct tcphdr otcph, *tcph;
18 unsigned int otcplen, hh_len;
19 int tcphoff, needs_ack;
20 const struct ipv6hdr *oip6h = ipv6_hdr(oldskb); 21 const struct ipv6hdr *oip6h = ipv6_hdr(oldskb);
21 struct ipv6hdr *ip6h;
22#define DEFAULT_TOS_VALUE 0x0U
23 const __u8 tclass = DEFAULT_TOS_VALUE;
24 struct dst_entry *dst = NULL;
25 u8 proto; 22 u8 proto;
26 __be16 frag_off; 23 __be16 frag_off;
27 struct flowi6 fl6; 24 int tcphoff;
28
29 if ((!(ipv6_addr_type(&oip6h->saddr) & IPV6_ADDR_UNICAST)) ||
30 (!(ipv6_addr_type(&oip6h->daddr) & IPV6_ADDR_UNICAST))) {
31 pr_debug("addr is not unicast.\n");
32 return;
33 }
34 25
35 proto = oip6h->nexthdr; 26 proto = oip6h->nexthdr;
36 tcphoff = ipv6_skip_exthdr(oldskb, ((u8*)(oip6h+1) - oldskb->data), &proto, &frag_off); 27 tcphoff = ipv6_skip_exthdr(oldskb, ((u8*)(oip6h+1) - oldskb->data),
28 &proto, &frag_off);
37 29
38 if ((tcphoff < 0) || (tcphoff > oldskb->len)) { 30 if ((tcphoff < 0) || (tcphoff > oldskb->len)) {
39 pr_debug("Cannot get TCP header.\n"); 31 pr_debug("Cannot get TCP header.\n");
40 return; 32 return NULL;
41 } 33 }
42 34
43 otcplen = oldskb->len - tcphoff; 35 *otcplen = oldskb->len - tcphoff;
44 36
45 /* IP header checks: fragment, too short. */ 37 /* IP header checks: fragment, too short. */
46 if (proto != IPPROTO_TCP || otcplen < sizeof(struct tcphdr)) { 38 if (proto != IPPROTO_TCP || *otcplen < sizeof(struct tcphdr)) {
47 pr_debug("proto(%d) != IPPROTO_TCP, " 39 pr_debug("proto(%d) != IPPROTO_TCP or too short (len = %d)\n",
48 "or too short. otcplen = %d\n", 40 proto, *otcplen);
49 proto, otcplen); 41 return NULL;
50 return;
51 } 42 }
52 43
53 if (skb_copy_bits(oldskb, tcphoff, &otcph, sizeof(struct tcphdr))) 44 otcph = skb_header_pointer(oldskb, tcphoff, sizeof(struct tcphdr),
54 BUG(); 45 otcph);
46 if (otcph == NULL)
47 return NULL;
55 48
56 /* No RST for RST. */ 49 /* No RST for RST. */
57 if (otcph.rst) { 50 if (otcph->rst) {
58 pr_debug("RST is set\n"); 51 pr_debug("RST is set\n");
59 return; 52 return NULL;
60 } 53 }
61 54
62 /* Check checksum. */ 55 /* Check checksum. */
63 if (nf_ip6_checksum(oldskb, hook, tcphoff, IPPROTO_TCP)) { 56 if (nf_ip6_checksum(oldskb, hook, tcphoff, IPPROTO_TCP)) {
64 pr_debug("TCP checksum is invalid\n"); 57 pr_debug("TCP checksum is invalid\n");
65 return; 58 return NULL;
66 } 59 }
67 60
68 memset(&fl6, 0, sizeof(fl6)); 61 return otcph;
69 fl6.flowi6_proto = IPPROTO_TCP; 62}
70 fl6.saddr = oip6h->daddr; 63EXPORT_SYMBOL_GPL(nf_reject_ip6_tcphdr_get);
71 fl6.daddr = oip6h->saddr;
72 fl6.fl6_sport = otcph.dest;
73 fl6.fl6_dport = otcph.source;
74 security_skb_classify_flow(oldskb, flowi6_to_flowi(&fl6));
75 dst = ip6_route_output(net, NULL, &fl6);
76 if (dst == NULL || dst->error) {
77 dst_release(dst);
78 return;
79 }
80 dst = xfrm_lookup(net, dst, flowi6_to_flowi(&fl6), NULL, 0);
81 if (IS_ERR(dst))
82 return;
83
84 hh_len = (dst->dev->hard_header_len + 15)&~15;
85 nskb = alloc_skb(hh_len + 15 + dst->header_len + sizeof(struct ipv6hdr)
86 + sizeof(struct tcphdr) + dst->trailer_len,
87 GFP_ATOMIC);
88
89 if (!nskb) {
90 net_dbg_ratelimited("cannot alloc skb\n");
91 dst_release(dst);
92 return;
93 }
94
95 skb_dst_set(nskb, dst);
96 64
97 skb_reserve(nskb, hh_len + dst->header_len); 65struct ipv6hdr *nf_reject_ip6hdr_put(struct sk_buff *nskb,
66 const struct sk_buff *oldskb,
67 __be16 protocol, int hoplimit)
68{
69 struct ipv6hdr *ip6h;
70 const struct ipv6hdr *oip6h = ipv6_hdr(oldskb);
71#define DEFAULT_TOS_VALUE 0x0U
72 const __u8 tclass = DEFAULT_TOS_VALUE;
98 73
99 skb_put(nskb, sizeof(struct ipv6hdr)); 74 skb_put(nskb, sizeof(struct ipv6hdr));
100 skb_reset_network_header(nskb); 75 skb_reset_network_header(nskb);
101 ip6h = ipv6_hdr(nskb); 76 ip6h = ipv6_hdr(nskb);
102 ip6_flow_hdr(ip6h, tclass, 0); 77 ip6_flow_hdr(ip6h, tclass, 0);
103 ip6h->hop_limit = ip6_dst_hoplimit(dst); 78 ip6h->hop_limit = hoplimit;
104 ip6h->nexthdr = IPPROTO_TCP; 79 ip6h->nexthdr = protocol;
105 ip6h->saddr = oip6h->daddr; 80 ip6h->saddr = oip6h->daddr;
106 ip6h->daddr = oip6h->saddr; 81 ip6h->daddr = oip6h->saddr;
107 82
83 nskb->protocol = htons(ETH_P_IPV6);
84
85 return ip6h;
86}
87EXPORT_SYMBOL_GPL(nf_reject_ip6hdr_put);
88
89void nf_reject_ip6_tcphdr_put(struct sk_buff *nskb,
90 const struct sk_buff *oldskb,
91 const struct tcphdr *oth, unsigned int otcplen)
92{
93 struct tcphdr *tcph;
94 int needs_ack;
95
108 skb_reset_transport_header(nskb); 96 skb_reset_transport_header(nskb);
109 tcph = (struct tcphdr *)skb_put(nskb, sizeof(struct tcphdr)); 97 tcph = (struct tcphdr *)skb_put(nskb, sizeof(struct tcphdr));
110 /* Truncate to length (no data) */ 98 /* Truncate to length (no data) */
111 tcph->doff = sizeof(struct tcphdr)/4; 99 tcph->doff = sizeof(struct tcphdr)/4;
112 tcph->source = otcph.dest; 100 tcph->source = oth->dest;
113 tcph->dest = otcph.source; 101 tcph->dest = oth->source;
114 102
115 if (otcph.ack) { 103 if (oth->ack) {
116 needs_ack = 0; 104 needs_ack = 0;
117 tcph->seq = otcph.ack_seq; 105 tcph->seq = oth->ack_seq;
118 tcph->ack_seq = 0; 106 tcph->ack_seq = 0;
119 } else { 107 } else {
120 needs_ack = 1; 108 needs_ack = 1;
121 tcph->ack_seq = htonl(ntohl(otcph.seq) + otcph.syn + otcph.fin 109 tcph->ack_seq = htonl(ntohl(oth->seq) + oth->syn + oth->fin +
122 + otcplen - (otcph.doff<<2)); 110 otcplen - (oth->doff<<2));
123 tcph->seq = 0; 111 tcph->seq = 0;
124 } 112 }
125 113
@@ -137,6 +125,63 @@ void nf_send_reset6(struct net *net, struct sk_buff *oldskb, int hook)
137 sizeof(struct tcphdr), IPPROTO_TCP, 125 sizeof(struct tcphdr), IPPROTO_TCP,
138 csum_partial(tcph, 126 csum_partial(tcph,
139 sizeof(struct tcphdr), 0)); 127 sizeof(struct tcphdr), 0));
128}
129EXPORT_SYMBOL_GPL(nf_reject_ip6_tcphdr_put);
130
131void nf_send_reset6(struct net *net, struct sk_buff *oldskb, int hook)
132{
133 struct sk_buff *nskb;
134 struct tcphdr _otcph;
135 const struct tcphdr *otcph;
136 unsigned int otcplen, hh_len;
137 const struct ipv6hdr *oip6h = ipv6_hdr(oldskb);
138 struct ipv6hdr *ip6h;
139 struct dst_entry *dst = NULL;
140 struct flowi6 fl6;
141
142 if ((!(ipv6_addr_type(&oip6h->saddr) & IPV6_ADDR_UNICAST)) ||
143 (!(ipv6_addr_type(&oip6h->daddr) & IPV6_ADDR_UNICAST))) {
144 pr_debug("addr is not unicast.\n");
145 return;
146 }
147
148 otcph = nf_reject_ip6_tcphdr_get(oldskb, &_otcph, &otcplen, hook);
149 if (!otcph)
150 return;
151
152 memset(&fl6, 0, sizeof(fl6));
153 fl6.flowi6_proto = IPPROTO_TCP;
154 fl6.saddr = oip6h->daddr;
155 fl6.daddr = oip6h->saddr;
156 fl6.fl6_sport = otcph->dest;
157 fl6.fl6_dport = otcph->source;
158 security_skb_classify_flow(oldskb, flowi6_to_flowi(&fl6));
159 dst = ip6_route_output(net, NULL, &fl6);
160 if (dst == NULL || dst->error) {
161 dst_release(dst);
162 return;
163 }
164 dst = xfrm_lookup(net, dst, flowi6_to_flowi(&fl6), NULL, 0);
165 if (IS_ERR(dst))
166 return;
167
168 hh_len = (dst->dev->hard_header_len + 15)&~15;
169 nskb = alloc_skb(hh_len + 15 + dst->header_len + sizeof(struct ipv6hdr)
170 + sizeof(struct tcphdr) + dst->trailer_len,
171 GFP_ATOMIC);
172
173 if (!nskb) {
174 net_dbg_ratelimited("cannot alloc skb\n");
175 dst_release(dst);
176 return;
177 }
178
179 skb_dst_set(nskb, dst);
180
181 skb_reserve(nskb, hh_len + dst->header_len);
182 ip6h = nf_reject_ip6hdr_put(nskb, oldskb, IPPROTO_TCP,
183 ip6_dst_hoplimit(dst));
184 nf_reject_ip6_tcphdr_put(nskb, oldskb, otcph, otcplen);
140 185
141 nf_ct_attach(nskb, oldskb); 186 nf_ct_attach(nskb, oldskb);
142 187
@@ -161,3 +206,5 @@ void nf_send_reset6(struct net *net, struct sk_buff *oldskb, int hook)
161 ip6_local_out(nskb); 206 ip6_local_out(nskb);
162} 207}
163EXPORT_SYMBOL_GPL(nf_send_reset6); 208EXPORT_SYMBOL_GPL(nf_send_reset6);
209
210MODULE_LICENSE("GPL");
diff --git a/net/ipv6/netfilter/nft_masq_ipv6.c b/net/ipv6/netfilter/nft_masq_ipv6.c
index 556262f40761..8a7ac685076d 100644
--- a/net/ipv6/netfilter/nft_masq_ipv6.c
+++ b/net/ipv6/netfilter/nft_masq_ipv6.c
@@ -39,6 +39,7 @@ static const struct nft_expr_ops nft_masq_ipv6_ops = {
39 .eval = nft_masq_ipv6_eval, 39 .eval = nft_masq_ipv6_eval,
40 .init = nft_masq_init, 40 .init = nft_masq_init,
41 .dump = nft_masq_dump, 41 .dump = nft_masq_dump,
42 .validate = nft_masq_validate,
42}; 43};
43 44
44static struct nft_expr_type nft_masq_ipv6_type __read_mostly = { 45static struct nft_expr_type nft_masq_ipv6_type __read_mostly = {
diff --git a/net/ipv6/output_core.c b/net/ipv6/output_core.c
index fc24c390af05..97f41a3e68d9 100644
--- a/net/ipv6/output_core.c
+++ b/net/ipv6/output_core.c
@@ -3,11 +3,45 @@
3 * not configured or static. These functions are needed by GSO/GRO implementation. 3 * not configured or static. These functions are needed by GSO/GRO implementation.
4 */ 4 */
5#include <linux/export.h> 5#include <linux/export.h>
6#include <net/ip.h>
6#include <net/ipv6.h> 7#include <net/ipv6.h>
7#include <net/ip6_fib.h> 8#include <net/ip6_fib.h>
8#include <net/addrconf.h> 9#include <net/addrconf.h>
9#include <net/secure_seq.h> 10#include <net/secure_seq.h>
10 11
12/* This function exists only for tap drivers that must support broken
13 * clients requesting UFO without specifying an IPv6 fragment ID.
14 *
15 * This is similar to ipv6_select_ident() but we use an independent hash
16 * seed to limit information leakage.
17 *
18 * The network header must be set before calling this.
19 */
20void ipv6_proxy_select_ident(struct sk_buff *skb)
21{
22 static u32 ip6_proxy_idents_hashrnd __read_mostly;
23 struct in6_addr buf[2];
24 struct in6_addr *addrs;
25 u32 hash, id;
26
27 addrs = skb_header_pointer(skb,
28 skb_network_offset(skb) +
29 offsetof(struct ipv6hdr, saddr),
30 sizeof(buf), buf);
31 if (!addrs)
32 return;
33
34 net_get_random_once(&ip6_proxy_idents_hashrnd,
35 sizeof(ip6_proxy_idents_hashrnd));
36
37 hash = __ipv6_addr_jhash(&addrs[1], ip6_proxy_idents_hashrnd);
38 hash = __ipv6_addr_jhash(&addrs[0], hash);
39
40 id = ip_idents_reserve(hash, 1);
41 skb_shinfo(skb)->ip6_frag_id = htonl(id);
42}
43EXPORT_SYMBOL_GPL(ipv6_proxy_select_ident);
44
11int ip6_find_1stfragopt(struct sk_buff *skb, u8 **nexthdr) 45int ip6_find_1stfragopt(struct sk_buff *skb, u8 **nexthdr)
12{ 46{
13 u16 offset = sizeof(struct ipv6hdr); 47 u16 offset = sizeof(struct ipv6hdr);
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 831495529b82..ace29b60813c 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -200,8 +200,6 @@ static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
200 sk->sk_v6_daddr = usin->sin6_addr; 200 sk->sk_v6_daddr = usin->sin6_addr;
201 np->flow_label = fl6.flowlabel; 201 np->flow_label = fl6.flowlabel;
202 202
203 ip6_set_txhash(sk);
204
205 /* 203 /*
206 * TCP over IPv4 204 * TCP over IPv4
207 */ 205 */
@@ -297,6 +295,8 @@ static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
297 if (err) 295 if (err)
298 goto late_failure; 296 goto late_failure;
299 297
298 ip6_set_txhash(sk);
299
300 if (!tp->write_seq && likely(!tp->repair)) 300 if (!tp->write_seq && likely(!tp->repair))
301 tp->write_seq = secure_tcpv6_sequence_number(np->saddr.s6_addr32, 301 tp->write_seq = secure_tcpv6_sequence_number(np->saddr.s6_addr32,
302 sk->sk_v6_daddr.s6_addr32, 302 sk->sk_v6_daddr.s6_addr32,
diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
index ac49f84fe2c3..5f983644373a 100644
--- a/net/ipv6/xfrm6_policy.c
+++ b/net/ipv6/xfrm6_policy.c
@@ -170,8 +170,10 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse)
170 case IPPROTO_DCCP: 170 case IPPROTO_DCCP:
171 if (!onlyproto && (nh + offset + 4 < skb->data || 171 if (!onlyproto && (nh + offset + 4 < skb->data ||
172 pskb_may_pull(skb, nh + offset + 4 - skb->data))) { 172 pskb_may_pull(skb, nh + offset + 4 - skb->data))) {
173 __be16 *ports = (__be16 *)exthdr; 173 __be16 *ports;
174 174
175 nh = skb_network_header(skb);
176 ports = (__be16 *)(nh + offset);
175 fl6->fl6_sport = ports[!!reverse]; 177 fl6->fl6_sport = ports[!!reverse];
176 fl6->fl6_dport = ports[!reverse]; 178 fl6->fl6_dport = ports[!reverse];
177 } 179 }
@@ -180,8 +182,10 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse)
180 182
181 case IPPROTO_ICMPV6: 183 case IPPROTO_ICMPV6:
182 if (!onlyproto && pskb_may_pull(skb, nh + offset + 2 - skb->data)) { 184 if (!onlyproto && pskb_may_pull(skb, nh + offset + 2 - skb->data)) {
183 u8 *icmp = (u8 *)exthdr; 185 u8 *icmp;
184 186
187 nh = skb_network_header(skb);
188 icmp = (u8 *)(nh + offset);
185 fl6->fl6_icmp_type = icmp[0]; 189 fl6->fl6_icmp_type = icmp[0];
186 fl6->fl6_icmp_code = icmp[1]; 190 fl6->fl6_icmp_code = icmp[1];
187 } 191 }
@@ -192,8 +196,9 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse)
192 case IPPROTO_MH: 196 case IPPROTO_MH:
193 if (!onlyproto && pskb_may_pull(skb, nh + offset + 3 - skb->data)) { 197 if (!onlyproto && pskb_may_pull(skb, nh + offset + 3 - skb->data)) {
194 struct ip6_mh *mh; 198 struct ip6_mh *mh;
195 mh = (struct ip6_mh *)exthdr;
196 199
200 nh = skb_network_header(skb);
201 mh = (struct ip6_mh *)(nh + offset);
197 fl6->fl6_mh_type = mh->ip6mh_type; 202 fl6->fl6_mh_type = mh->ip6mh_type;
198 } 203 }
199 fl6->flowi6_proto = nexthdr; 204 fl6->flowi6_proto = nexthdr;
diff --git a/net/irda/af_irda.c b/net/irda/af_irda.c
index 92fafd485deb..3f3a6cbdceb7 100644
--- a/net/irda/af_irda.c
+++ b/net/irda/af_irda.c
@@ -1064,8 +1064,6 @@ static int irda_connect(struct socket *sock, struct sockaddr *uaddr,
1064 1064
1065 if (sk->sk_state != TCP_ESTABLISHED) { 1065 if (sk->sk_state != TCP_ESTABLISHED) {
1066 sock->state = SS_UNCONNECTED; 1066 sock->state = SS_UNCONNECTED;
1067 if (sk->sk_prot->disconnect(sk, flags))
1068 sock->state = SS_DISCONNECTING;
1069 err = sock_error(sk); 1067 err = sock_error(sk);
1070 if (!err) 1068 if (!err)
1071 err = -ECONNRESET; 1069 err = -ECONNRESET;
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index fb6a1502b6df..343da1e35025 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -3458,7 +3458,7 @@ static int ieee80211_cfg_get_channel(struct wiphy *wiphy,
3458 rcu_read_lock(); 3458 rcu_read_lock();
3459 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf); 3459 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
3460 if (chanctx_conf) { 3460 if (chanctx_conf) {
3461 *chandef = chanctx_conf->def; 3461 *chandef = sdata->vif.bss_conf.chandef;
3462 ret = 0; 3462 ret = 0;
3463 } else if (local->open_count > 0 && 3463 } else if (local->open_count > 0 &&
3464 local->open_count == local->monitors && 3464 local->open_count == local->monitors &&
diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
index 8fdadfd94ba8..6081329784dd 100644
--- a/net/mac80211/rate.c
+++ b/net/mac80211/rate.c
@@ -448,7 +448,7 @@ static void rate_fixup_ratelist(struct ieee80211_vif *vif,
448 */ 448 */
449 if (!(rates[0].flags & IEEE80211_TX_RC_MCS)) { 449 if (!(rates[0].flags & IEEE80211_TX_RC_MCS)) {
450 u32 basic_rates = vif->bss_conf.basic_rates; 450 u32 basic_rates = vif->bss_conf.basic_rates;
451 s8 baserate = basic_rates ? ffs(basic_rates - 1) : 0; 451 s8 baserate = basic_rates ? ffs(basic_rates) - 1 : 0;
452 452
453 rate = &sband->bitrates[rates[0].idx]; 453 rate = &sband->bitrates[rates[0].idx];
454 454
diff --git a/net/mac80211/rc80211_minstrel_debugfs.c b/net/mac80211/rc80211_minstrel_debugfs.c
index edde723f9f00..2acab1bcaa4b 100644
--- a/net/mac80211/rc80211_minstrel_debugfs.c
+++ b/net/mac80211/rc80211_minstrel_debugfs.c
@@ -62,14 +62,14 @@ minstrel_stats_open(struct inode *inode, struct file *file)
62 unsigned int i, tp, prob, eprob; 62 unsigned int i, tp, prob, eprob;
63 char *p; 63 char *p;
64 64
65 ms = kmalloc(sizeof(*ms) + 4096, GFP_KERNEL); 65 ms = kmalloc(2048, GFP_KERNEL);
66 if (!ms) 66 if (!ms)
67 return -ENOMEM; 67 return -ENOMEM;
68 68
69 file->private_data = ms; 69 file->private_data = ms;
70 p = ms->buf; 70 p = ms->buf;
71 p += sprintf(p, "rate throughput ewma prob this prob " 71 p += sprintf(p, "rate tpt eprob *prob"
72 "this succ/attempt success attempts\n"); 72 " *ok(*cum) ok( cum)\n");
73 for (i = 0; i < mi->n_rates; i++) { 73 for (i = 0; i < mi->n_rates; i++) {
74 struct minstrel_rate *mr = &mi->r[i]; 74 struct minstrel_rate *mr = &mi->r[i];
75 struct minstrel_rate_stats *mrs = &mi->r[i].stats; 75 struct minstrel_rate_stats *mrs = &mi->r[i].stats;
@@ -86,8 +86,8 @@ minstrel_stats_open(struct inode *inode, struct file *file)
86 prob = MINSTREL_TRUNC(mrs->cur_prob * 1000); 86 prob = MINSTREL_TRUNC(mrs->cur_prob * 1000);
87 eprob = MINSTREL_TRUNC(mrs->probability * 1000); 87 eprob = MINSTREL_TRUNC(mrs->probability * 1000);
88 88
89 p += sprintf(p, " %6u.%1u %6u.%1u %6u.%1u " 89 p += sprintf(p, " %4u.%1u %3u.%1u %3u.%1u"
90 " %3u(%3u) %8llu %8llu\n", 90 " %4u(%4u) %9llu(%9llu)\n",
91 tp / 10, tp % 10, 91 tp / 10, tp % 10,
92 eprob / 10, eprob % 10, 92 eprob / 10, eprob % 10,
93 prob / 10, prob % 10, 93 prob / 10, prob % 10,
@@ -102,6 +102,8 @@ minstrel_stats_open(struct inode *inode, struct file *file)
102 mi->sample_packets); 102 mi->sample_packets);
103 ms->len = p - ms->buf; 103 ms->len = p - ms->buf;
104 104
105 WARN_ON(ms->len + sizeof(*ms) > 2048);
106
105 return 0; 107 return 0;
106} 108}
107 109
diff --git a/net/mac80211/rc80211_minstrel_ht_debugfs.c b/net/mac80211/rc80211_minstrel_ht_debugfs.c
index a72ad46f2a04..d537bec93754 100644
--- a/net/mac80211/rc80211_minstrel_ht_debugfs.c
+++ b/net/mac80211/rc80211_minstrel_ht_debugfs.c
@@ -63,8 +63,8 @@ minstrel_ht_stats_dump(struct minstrel_ht_sta *mi, int i, char *p)
63 prob = MINSTREL_TRUNC(mr->cur_prob * 1000); 63 prob = MINSTREL_TRUNC(mr->cur_prob * 1000);
64 eprob = MINSTREL_TRUNC(mr->probability * 1000); 64 eprob = MINSTREL_TRUNC(mr->probability * 1000);
65 65
66 p += sprintf(p, " %6u.%1u %6u.%1u %6u.%1u " 66 p += sprintf(p, " %4u.%1u %3u.%1u %3u.%1u "
67 "%3u %3u(%3u) %8llu %8llu\n", 67 "%3u %4u(%4u) %9llu(%9llu)\n",
68 tp / 10, tp % 10, 68 tp / 10, tp % 10,
69 eprob / 10, eprob % 10, 69 eprob / 10, eprob % 10,
70 prob / 10, prob % 10, 70 prob / 10, prob % 10,
@@ -96,14 +96,15 @@ minstrel_ht_stats_open(struct inode *inode, struct file *file)
96 return ret; 96 return ret;
97 } 97 }
98 98
99 ms = kmalloc(sizeof(*ms) + 8192, GFP_KERNEL); 99 ms = kmalloc(8192, GFP_KERNEL);
100 if (!ms) 100 if (!ms)
101 return -ENOMEM; 101 return -ENOMEM;
102 102
103 file->private_data = ms; 103 file->private_data = ms;
104 p = ms->buf; 104 p = ms->buf;
105 p += sprintf(p, "type rate throughput ewma prob " 105 p += sprintf(p, "type rate tpt eprob *prob "
106 "this prob retry this succ/attempt success attempts\n"); 106 "ret *ok(*cum) ok( cum)\n");
107
107 108
108 p = minstrel_ht_stats_dump(mi, max_mcs, p); 109 p = minstrel_ht_stats_dump(mi, max_mcs, p);
109 for (i = 0; i < max_mcs; i++) 110 for (i = 0; i < max_mcs; i++)
@@ -118,6 +119,8 @@ minstrel_ht_stats_open(struct inode *inode, struct file *file)
118 MINSTREL_TRUNC(mi->avg_ampdu_len * 10) % 10); 119 MINSTREL_TRUNC(mi->avg_ampdu_len * 10) % 10);
119 ms->len = p - ms->buf; 120 ms->len = p - ms->buf;
120 121
122 WARN_ON(ms->len + sizeof(*ms) > 8192);
123
121 return nonseekable_open(inode, file); 124 return nonseekable_open(inode, file);
122} 125}
123 126
diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h
index 42f68cb8957e..bcda2ac7d844 100644
--- a/net/mac80211/sta_info.h
+++ b/net/mac80211/sta_info.h
@@ -336,6 +336,7 @@ struct ieee80211_tx_latency_stat {
336 * @known_smps_mode: the smps_mode the client thinks we are in. Relevant for 336 * @known_smps_mode: the smps_mode the client thinks we are in. Relevant for
337 * AP only. 337 * AP only.
338 * @cipher_scheme: optional cipher scheme for this station 338 * @cipher_scheme: optional cipher scheme for this station
339 * @last_tdls_pkt_time: holds the time in jiffies of last TDLS pkt ACKed
339 */ 340 */
340struct sta_info { 341struct sta_info {
341 /* General information, mostly static */ 342 /* General information, mostly static */
diff --git a/net/mpls/Makefile b/net/mpls/Makefile
index 0a3c171be537..6dec088c2d0f 100644
--- a/net/mpls/Makefile
+++ b/net/mpls/Makefile
@@ -1,4 +1,4 @@
1# 1#
2# Makefile for MPLS. 2# Makefile for MPLS.
3# 3#
4obj-y += mpls_gso.o 4obj-$(CONFIG_NET_MPLS_GSO) += mpls_gso.o
diff --git a/net/mpls/mpls_gso.c b/net/mpls/mpls_gso.c
index e28ed2ef5b06..e3545f21a099 100644
--- a/net/mpls/mpls_gso.c
+++ b/net/mpls/mpls_gso.c
@@ -48,7 +48,7 @@ static struct sk_buff *mpls_gso_segment(struct sk_buff *skb,
48 __skb_push(skb, skb->mac_len); 48 __skb_push(skb, skb->mac_len);
49 49
50 /* Segment inner packet. */ 50 /* Segment inner packet. */
51 mpls_features = skb->dev->mpls_features & netif_skb_features(skb); 51 mpls_features = skb->dev->mpls_features & features;
52 segs = skb_mac_gso_segment(skb, mpls_features); 52 segs = skb_mac_gso_segment(skb, mpls_features);
53 53
54 54
@@ -59,8 +59,7 @@ static struct sk_buff *mpls_gso_segment(struct sk_buff *skb,
59 * above pulled. It will be re-pushed after returning 59 * above pulled. It will be re-pushed after returning
60 * skb_mac_gso_segment(), an indirect caller of this function. 60 * skb_mac_gso_segment(), an indirect caller of this function.
61 */ 61 */
62 __skb_push(skb, skb->data - skb_mac_header(skb)); 62 __skb_pull(skb, skb->data - skb_mac_header(skb));
63
64out: 63out:
65 return segs; 64 return segs;
66} 65}
diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
index 912e5a05b79d..86f9d76b1464 100644
--- a/net/netfilter/ipset/ip_set_core.c
+++ b/net/netfilter/ipset/ip_set_core.c
@@ -659,7 +659,7 @@ ip_set_nfnl_get_byindex(struct net *net, ip_set_id_t index)
659 struct ip_set *set; 659 struct ip_set *set;
660 struct ip_set_net *inst = ip_set_pernet(net); 660 struct ip_set_net *inst = ip_set_pernet(net);
661 661
662 if (index > inst->ip_set_max) 662 if (index >= inst->ip_set_max)
663 return IPSET_INVALID_ID; 663 return IPSET_INVALID_ID;
664 664
665 nfnl_lock(NFNL_SUBSYS_IPSET); 665 nfnl_lock(NFNL_SUBSYS_IPSET);
diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
index 91f17c1eb8a2..437a3663ad03 100644
--- a/net/netfilter/ipvs/ip_vs_xmit.c
+++ b/net/netfilter/ipvs/ip_vs_xmit.c
@@ -316,7 +316,7 @@ __ip_vs_get_out_rt(int skb_af, struct sk_buff *skb, struct ip_vs_dest *dest,
316 if (unlikely(crosses_local_route_boundary(skb_af, skb, rt_mode, 316 if (unlikely(crosses_local_route_boundary(skb_af, skb, rt_mode,
317 local))) { 317 local))) {
318 IP_VS_DBG_RL("We are crossing local and non-local addresses" 318 IP_VS_DBG_RL("We are crossing local and non-local addresses"
319 " daddr=%pI4\n", &dest->addr.ip); 319 " daddr=%pI4\n", &daddr);
320 goto err_put; 320 goto err_put;
321 } 321 }
322 322
@@ -458,7 +458,7 @@ __ip_vs_get_out_rt_v6(int skb_af, struct sk_buff *skb, struct ip_vs_dest *dest,
458 if (unlikely(crosses_local_route_boundary(skb_af, skb, rt_mode, 458 if (unlikely(crosses_local_route_boundary(skb_af, skb, rt_mode,
459 local))) { 459 local))) {
460 IP_VS_DBG_RL("We are crossing local and non-local addresses" 460 IP_VS_DBG_RL("We are crossing local and non-local addresses"
461 " daddr=%pI6\n", &dest->addr.in6); 461 " daddr=%pI6\n", daddr);
462 goto err_put; 462 goto err_put;
463 } 463 }
464 464
diff --git a/net/netfilter/nf_conntrack_proto_tcp.c b/net/netfilter/nf_conntrack_proto_tcp.c
index 44d1ea32570a..d87b6423ffb2 100644
--- a/net/netfilter/nf_conntrack_proto_tcp.c
+++ b/net/netfilter/nf_conntrack_proto_tcp.c
@@ -213,7 +213,7 @@ static const u8 tcp_conntracks[2][6][TCP_CONNTRACK_MAX] = {
213 { 213 {
214/* REPLY */ 214/* REPLY */
215/* sNO, sSS, sSR, sES, sFW, sCW, sLA, sTW, sCL, sS2 */ 215/* sNO, sSS, sSR, sES, sFW, sCW, sLA, sTW, sCL, sS2 */
216/*syn*/ { sIV, sS2, sIV, sIV, sIV, sIV, sIV, sIV, sIV, sS2 }, 216/*syn*/ { sIV, sS2, sIV, sIV, sIV, sIV, sIV, sSS, sIV, sS2 },
217/* 217/*
218 * sNO -> sIV Never reached. 218 * sNO -> sIV Never reached.
219 * sSS -> sS2 Simultaneous open 219 * sSS -> sS2 Simultaneous open
@@ -223,7 +223,7 @@ static const u8 tcp_conntracks[2][6][TCP_CONNTRACK_MAX] = {
223 * sFW -> sIV 223 * sFW -> sIV
224 * sCW -> sIV 224 * sCW -> sIV
225 * sLA -> sIV 225 * sLA -> sIV
226 * sTW -> sIV Reopened connection, but server may not do it. 226 * sTW -> sSS Reopened connection, but server may have switched role
227 * sCL -> sIV 227 * sCL -> sIV
228 */ 228 */
229/* sNO, sSS, sSR, sES, sFW, sCW, sLA, sTW, sCL, sS2 */ 229/* sNO, sSS, sSR, sES, sFW, sCW, sLA, sTW, sCL, sS2 */
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index 556a0dfa4abc..11ab4b078f3b 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -1328,10 +1328,10 @@ static int nf_tables_newchain(struct sock *nlsk, struct sk_buff *skb,
1328 basechain->stats = stats; 1328 basechain->stats = stats;
1329 } else { 1329 } else {
1330 stats = netdev_alloc_pcpu_stats(struct nft_stats); 1330 stats = netdev_alloc_pcpu_stats(struct nft_stats);
1331 if (IS_ERR(stats)) { 1331 if (stats == NULL) {
1332 module_put(type->owner); 1332 module_put(type->owner);
1333 kfree(basechain); 1333 kfree(basechain);
1334 return PTR_ERR(stats); 1334 return -ENOMEM;
1335 } 1335 }
1336 rcu_assign_pointer(basechain->stats, stats); 1336 rcu_assign_pointer(basechain->stats, stats);
1337 } 1337 }
@@ -3744,6 +3744,20 @@ static const struct nfnetlink_subsystem nf_tables_subsys = {
3744 .abort = nf_tables_abort, 3744 .abort = nf_tables_abort,
3745}; 3745};
3746 3746
3747int nft_chain_validate_dependency(const struct nft_chain *chain,
3748 enum nft_chain_type type)
3749{
3750 const struct nft_base_chain *basechain;
3751
3752 if (chain->flags & NFT_BASE_CHAIN) {
3753 basechain = nft_base_chain(chain);
3754 if (basechain->type->type != type)
3755 return -EOPNOTSUPP;
3756 }
3757 return 0;
3758}
3759EXPORT_SYMBOL_GPL(nft_chain_validate_dependency);
3760
3747/* 3761/*
3748 * Loop detection - walk through the ruleset beginning at the destination chain 3762 * Loop detection - walk through the ruleset beginning at the destination chain
3749 * of a new jump until either the source chain is reached (loop) or all 3763 * of a new jump until either the source chain is reached (loop) or all
diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
index b1e3a0579416..5f1be5ba3559 100644
--- a/net/netfilter/nfnetlink_log.c
+++ b/net/netfilter/nfnetlink_log.c
@@ -43,7 +43,8 @@
43#define NFULNL_NLBUFSIZ_DEFAULT NLMSG_GOODSIZE 43#define NFULNL_NLBUFSIZ_DEFAULT NLMSG_GOODSIZE
44#define NFULNL_TIMEOUT_DEFAULT 100 /* every second */ 44#define NFULNL_TIMEOUT_DEFAULT 100 /* every second */
45#define NFULNL_QTHRESH_DEFAULT 100 /* 100 packets */ 45#define NFULNL_QTHRESH_DEFAULT 100 /* 100 packets */
46#define NFULNL_COPY_RANGE_MAX 0xFFFF /* max packet size is limited by 16-bit struct nfattr nfa_len field */ 46/* max packet size is limited by 16-bit struct nfattr nfa_len field */
47#define NFULNL_COPY_RANGE_MAX (0xFFFF - NLA_HDRLEN)
47 48
48#define PRINTR(x, args...) do { if (net_ratelimit()) \ 49#define PRINTR(x, args...) do { if (net_ratelimit()) \
49 printk(x, ## args); } while (0); 50 printk(x, ## args); } while (0);
@@ -252,6 +253,8 @@ nfulnl_set_mode(struct nfulnl_instance *inst, u_int8_t mode,
252 253
253 case NFULNL_COPY_PACKET: 254 case NFULNL_COPY_PACKET:
254 inst->copy_mode = mode; 255 inst->copy_mode = mode;
256 if (range == 0)
257 range = NFULNL_COPY_RANGE_MAX;
255 inst->copy_range = min_t(unsigned int, 258 inst->copy_range = min_t(unsigned int,
256 range, NFULNL_COPY_RANGE_MAX); 259 range, NFULNL_COPY_RANGE_MAX);
257 break; 260 break;
@@ -343,26 +346,25 @@ nfulnl_alloc_skb(struct net *net, u32 peer_portid, unsigned int inst_size,
343 return skb; 346 return skb;
344} 347}
345 348
346static int 349static void
347__nfulnl_send(struct nfulnl_instance *inst) 350__nfulnl_send(struct nfulnl_instance *inst)
348{ 351{
349 int status = -1;
350
351 if (inst->qlen > 1) { 352 if (inst->qlen > 1) {
352 struct nlmsghdr *nlh = nlmsg_put(inst->skb, 0, 0, 353 struct nlmsghdr *nlh = nlmsg_put(inst->skb, 0, 0,
353 NLMSG_DONE, 354 NLMSG_DONE,
354 sizeof(struct nfgenmsg), 355 sizeof(struct nfgenmsg),
355 0); 356 0);
356 if (!nlh) 357 if (WARN_ONCE(!nlh, "bad nlskb size: %u, tailroom %d\n",
358 inst->skb->len, skb_tailroom(inst->skb))) {
359 kfree_skb(inst->skb);
357 goto out; 360 goto out;
361 }
358 } 362 }
359 status = nfnetlink_unicast(inst->skb, inst->net, inst->peer_portid, 363 nfnetlink_unicast(inst->skb, inst->net, inst->peer_portid,
360 MSG_DONTWAIT); 364 MSG_DONTWAIT);
361 365out:
362 inst->qlen = 0; 366 inst->qlen = 0;
363 inst->skb = NULL; 367 inst->skb = NULL;
364out:
365 return status;
366} 368}
367 369
368static void 370static void
@@ -649,7 +651,8 @@ nfulnl_log_packet(struct net *net,
649 + nla_total_size(sizeof(u_int32_t)) /* gid */ 651 + nla_total_size(sizeof(u_int32_t)) /* gid */
650 + nla_total_size(plen) /* prefix */ 652 + nla_total_size(plen) /* prefix */
651 + nla_total_size(sizeof(struct nfulnl_msg_packet_hw)) 653 + nla_total_size(sizeof(struct nfulnl_msg_packet_hw))
652 + nla_total_size(sizeof(struct nfulnl_msg_packet_timestamp)); 654 + nla_total_size(sizeof(struct nfulnl_msg_packet_timestamp))
655 + nla_total_size(sizeof(struct nfgenmsg)); /* NLMSG_DONE */
653 656
654 if (in && skb_mac_header_was_set(skb)) { 657 if (in && skb_mac_header_was_set(skb)) {
655 size += nla_total_size(skb->dev->hard_header_len) 658 size += nla_total_size(skb->dev->hard_header_len)
@@ -678,8 +681,7 @@ nfulnl_log_packet(struct net *net,
678 break; 681 break;
679 682
680 case NFULNL_COPY_PACKET: 683 case NFULNL_COPY_PACKET:
681 if (inst->copy_range == 0 684 if (inst->copy_range > skb->len)
682 || inst->copy_range > skb->len)
683 data_len = skb->len; 685 data_len = skb->len;
684 else 686 else
685 data_len = inst->copy_range; 687 data_len = inst->copy_range;
@@ -692,8 +694,7 @@ nfulnl_log_packet(struct net *net,
692 goto unlock_and_release; 694 goto unlock_and_release;
693 } 695 }
694 696
695 if (inst->skb && 697 if (inst->skb && size > skb_tailroom(inst->skb)) {
696 size > skb_tailroom(inst->skb) - sizeof(struct nfgenmsg)) {
697 /* either the queue len is too high or we don't have 698 /* either the queue len is too high or we don't have
698 * enough room in the skb left. flush to userspace. */ 699 * enough room in the skb left. flush to userspace. */
699 __nfulnl_flush(inst); 700 __nfulnl_flush(inst);
diff --git a/net/netfilter/nfnetlink_queue_core.c b/net/netfilter/nfnetlink_queue_core.c
index a82077d9f59b..7c60ccd61a3e 100644
--- a/net/netfilter/nfnetlink_queue_core.c
+++ b/net/netfilter/nfnetlink_queue_core.c
@@ -665,7 +665,7 @@ nfqnl_enqueue_packet(struct nf_queue_entry *entry, unsigned int queuenum)
665 * returned by nf_queue. For instance, callers rely on -ECANCELED to 665 * returned by nf_queue. For instance, callers rely on -ECANCELED to
666 * mean 'ignore this hook'. 666 * mean 'ignore this hook'.
667 */ 667 */
668 if (IS_ERR(segs)) 668 if (IS_ERR_OR_NULL(segs))
669 goto out_err; 669 goto out_err;
670 queued = 0; 670 queued = 0;
671 err = 0; 671 err = 0;
diff --git a/net/netfilter/nft_compat.c b/net/netfilter/nft_compat.c
index 7e2683c8a44a..9d6d6f60a80f 100644
--- a/net/netfilter/nft_compat.c
+++ b/net/netfilter/nft_compat.c
@@ -19,9 +19,52 @@
19#include <linux/netfilter/x_tables.h> 19#include <linux/netfilter/x_tables.h>
20#include <linux/netfilter_ipv4/ip_tables.h> 20#include <linux/netfilter_ipv4/ip_tables.h>
21#include <linux/netfilter_ipv6/ip6_tables.h> 21#include <linux/netfilter_ipv6/ip6_tables.h>
22#include <asm/uaccess.h> /* for set_fs */
23#include <net/netfilter/nf_tables.h> 22#include <net/netfilter/nf_tables.h>
24 23
24static const struct {
25 const char *name;
26 u8 type;
27} table_to_chaintype[] = {
28 { "filter", NFT_CHAIN_T_DEFAULT },
29 { "raw", NFT_CHAIN_T_DEFAULT },
30 { "security", NFT_CHAIN_T_DEFAULT },
31 { "mangle", NFT_CHAIN_T_ROUTE },
32 { "nat", NFT_CHAIN_T_NAT },
33 { },
34};
35
36static int nft_compat_table_to_chaintype(const char *table)
37{
38 int i;
39
40 for (i = 0; table_to_chaintype[i].name != NULL; i++) {
41 if (strcmp(table_to_chaintype[i].name, table) == 0)
42 return table_to_chaintype[i].type;
43 }
44
45 return -1;
46}
47
48static int nft_compat_chain_validate_dependency(const char *tablename,
49 const struct nft_chain *chain)
50{
51 enum nft_chain_type type;
52 const struct nft_base_chain *basechain;
53
54 if (!tablename || !(chain->flags & NFT_BASE_CHAIN))
55 return 0;
56
57 type = nft_compat_table_to_chaintype(tablename);
58 if (type < 0)
59 return -EINVAL;
60
61 basechain = nft_base_chain(chain);
62 if (basechain->type->type != type)
63 return -EINVAL;
64
65 return 0;
66}
67
25union nft_entry { 68union nft_entry {
26 struct ipt_entry e4; 69 struct ipt_entry e4;
27 struct ip6t_entry e6; 70 struct ip6t_entry e6;
@@ -95,6 +138,8 @@ nft_target_set_tgchk_param(struct xt_tgchk_param *par,
95 const struct nf_hook_ops *ops = &basechain->ops[0]; 138 const struct nf_hook_ops *ops = &basechain->ops[0];
96 139
97 par->hook_mask = 1 << ops->hooknum; 140 par->hook_mask = 1 << ops->hooknum;
141 } else {
142 par->hook_mask = 0;
98 } 143 }
99 par->family = ctx->afi->family; 144 par->family = ctx->afi->family;
100} 145}
@@ -151,6 +196,10 @@ nft_target_init(const struct nft_ctx *ctx, const struct nft_expr *expr,
151 union nft_entry e = {}; 196 union nft_entry e = {};
152 int ret; 197 int ret;
153 198
199 ret = nft_compat_chain_validate_dependency(target->table, ctx->chain);
200 if (ret < 0)
201 goto err;
202
154 target_compat_from_user(target, nla_data(tb[NFTA_TARGET_INFO]), info); 203 target_compat_from_user(target, nla_data(tb[NFTA_TARGET_INFO]), info);
155 204
156 if (ctx->nla[NFTA_RULE_COMPAT]) { 205 if (ctx->nla[NFTA_RULE_COMPAT]) {
@@ -216,6 +265,7 @@ static int nft_target_validate(const struct nft_ctx *ctx,
216{ 265{
217 struct xt_target *target = expr->ops->data; 266 struct xt_target *target = expr->ops->data;
218 unsigned int hook_mask = 0; 267 unsigned int hook_mask = 0;
268 int ret;
219 269
220 if (ctx->chain->flags & NFT_BASE_CHAIN) { 270 if (ctx->chain->flags & NFT_BASE_CHAIN) {
221 const struct nft_base_chain *basechain = 271 const struct nft_base_chain *basechain =
@@ -223,11 +273,13 @@ static int nft_target_validate(const struct nft_ctx *ctx,
223 const struct nf_hook_ops *ops = &basechain->ops[0]; 273 const struct nf_hook_ops *ops = &basechain->ops[0];
224 274
225 hook_mask = 1 << ops->hooknum; 275 hook_mask = 1 << ops->hooknum;
226 if (hook_mask & target->hooks) 276 if (!(hook_mask & target->hooks))
227 return 0; 277 return -EINVAL;
228 278
229 /* This target is being called from an invalid chain */ 279 ret = nft_compat_chain_validate_dependency(target->table,
230 return -EINVAL; 280 ctx->chain);
281 if (ret < 0)
282 return ret;
231 } 283 }
232 return 0; 284 return 0;
233} 285}
@@ -293,6 +345,8 @@ nft_match_set_mtchk_param(struct xt_mtchk_param *par, const struct nft_ctx *ctx,
293 const struct nf_hook_ops *ops = &basechain->ops[0]; 345 const struct nf_hook_ops *ops = &basechain->ops[0];
294 346
295 par->hook_mask = 1 << ops->hooknum; 347 par->hook_mask = 1 << ops->hooknum;
348 } else {
349 par->hook_mask = 0;
296 } 350 }
297 par->family = ctx->afi->family; 351 par->family = ctx->afi->family;
298} 352}
@@ -320,6 +374,10 @@ nft_match_init(const struct nft_ctx *ctx, const struct nft_expr *expr,
320 union nft_entry e = {}; 374 union nft_entry e = {};
321 int ret; 375 int ret;
322 376
377 ret = nft_compat_chain_validate_dependency(match->name, ctx->chain);
378 if (ret < 0)
379 goto err;
380
323 match_compat_from_user(match, nla_data(tb[NFTA_MATCH_INFO]), info); 381 match_compat_from_user(match, nla_data(tb[NFTA_MATCH_INFO]), info);
324 382
325 if (ctx->nla[NFTA_RULE_COMPAT]) { 383 if (ctx->nla[NFTA_RULE_COMPAT]) {
@@ -379,6 +437,7 @@ static int nft_match_validate(const struct nft_ctx *ctx,
379{ 437{
380 struct xt_match *match = expr->ops->data; 438 struct xt_match *match = expr->ops->data;
381 unsigned int hook_mask = 0; 439 unsigned int hook_mask = 0;
440 int ret;
382 441
383 if (ctx->chain->flags & NFT_BASE_CHAIN) { 442 if (ctx->chain->flags & NFT_BASE_CHAIN) {
384 const struct nft_base_chain *basechain = 443 const struct nft_base_chain *basechain =
@@ -386,11 +445,13 @@ static int nft_match_validate(const struct nft_ctx *ctx,
386 const struct nf_hook_ops *ops = &basechain->ops[0]; 445 const struct nf_hook_ops *ops = &basechain->ops[0];
387 446
388 hook_mask = 1 << ops->hooknum; 447 hook_mask = 1 << ops->hooknum;
389 if (hook_mask & match->hooks) 448 if (!(hook_mask & match->hooks))
390 return 0; 449 return -EINVAL;
391 450
392 /* This match is being called from an invalid chain */ 451 ret = nft_compat_chain_validate_dependency(match->name,
393 return -EINVAL; 452 ctx->chain);
453 if (ret < 0)
454 return ret;
394 } 455 }
395 return 0; 456 return 0;
396} 457}
@@ -611,7 +672,7 @@ nft_target_select_ops(const struct nft_ctx *ctx,
611 family = ctx->afi->family; 672 family = ctx->afi->family;
612 673
613 /* Re-use the existing target if it's already loaded. */ 674 /* Re-use the existing target if it's already loaded. */
614 list_for_each_entry(nft_target, &nft_match_list, head) { 675 list_for_each_entry(nft_target, &nft_target_list, head) {
615 struct xt_target *target = nft_target->ops.data; 676 struct xt_target *target = nft_target->ops.data;
616 677
617 if (strcmp(target->name, tg_name) == 0 && 678 if (strcmp(target->name, tg_name) == 0 &&
diff --git a/net/netfilter/nft_masq.c b/net/netfilter/nft_masq.c
index 6637bab00567..d1ffd5eb3a9b 100644
--- a/net/netfilter/nft_masq.c
+++ b/net/netfilter/nft_masq.c
@@ -26,6 +26,11 @@ int nft_masq_init(const struct nft_ctx *ctx,
26 const struct nlattr * const tb[]) 26 const struct nlattr * const tb[])
27{ 27{
28 struct nft_masq *priv = nft_expr_priv(expr); 28 struct nft_masq *priv = nft_expr_priv(expr);
29 int err;
30
31 err = nft_chain_validate_dependency(ctx->chain, NFT_CHAIN_T_NAT);
32 if (err < 0)
33 return err;
29 34
30 if (tb[NFTA_MASQ_FLAGS] == NULL) 35 if (tb[NFTA_MASQ_FLAGS] == NULL)
31 return 0; 36 return 0;
@@ -55,5 +60,12 @@ nla_put_failure:
55} 60}
56EXPORT_SYMBOL_GPL(nft_masq_dump); 61EXPORT_SYMBOL_GPL(nft_masq_dump);
57 62
63int nft_masq_validate(const struct nft_ctx *ctx, const struct nft_expr *expr,
64 const struct nft_data **data)
65{
66 return nft_chain_validate_dependency(ctx->chain, NFT_CHAIN_T_NAT);
67}
68EXPORT_SYMBOL_GPL(nft_masq_validate);
69
58MODULE_LICENSE("GPL"); 70MODULE_LICENSE("GPL");
59MODULE_AUTHOR("Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>"); 71MODULE_AUTHOR("Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>");
diff --git a/net/netfilter/nft_nat.c b/net/netfilter/nft_nat.c
index 799550b476fb..afe2b0b45ec4 100644
--- a/net/netfilter/nft_nat.c
+++ b/net/netfilter/nft_nat.c
@@ -95,7 +95,13 @@ static int nft_nat_init(const struct nft_ctx *ctx, const struct nft_expr *expr,
95 u32 family; 95 u32 family;
96 int err; 96 int err;
97 97
98 if (tb[NFTA_NAT_TYPE] == NULL) 98 err = nft_chain_validate_dependency(ctx->chain, NFT_CHAIN_T_NAT);
99 if (err < 0)
100 return err;
101
102 if (tb[NFTA_NAT_TYPE] == NULL ||
103 (tb[NFTA_NAT_REG_ADDR_MIN] == NULL &&
104 tb[NFTA_NAT_REG_PROTO_MIN] == NULL))
99 return -EINVAL; 105 return -EINVAL;
100 106
101 switch (ntohl(nla_get_be32(tb[NFTA_NAT_TYPE]))) { 107 switch (ntohl(nla_get_be32(tb[NFTA_NAT_TYPE]))) {
@@ -120,38 +126,44 @@ static int nft_nat_init(const struct nft_ctx *ctx, const struct nft_expr *expr,
120 priv->family = family; 126 priv->family = family;
121 127
122 if (tb[NFTA_NAT_REG_ADDR_MIN]) { 128 if (tb[NFTA_NAT_REG_ADDR_MIN]) {
123 priv->sreg_addr_min = ntohl(nla_get_be32( 129 priv->sreg_addr_min =
124 tb[NFTA_NAT_REG_ADDR_MIN])); 130 ntohl(nla_get_be32(tb[NFTA_NAT_REG_ADDR_MIN]));
131
125 err = nft_validate_input_register(priv->sreg_addr_min); 132 err = nft_validate_input_register(priv->sreg_addr_min);
126 if (err < 0) 133 if (err < 0)
127 return err; 134 return err;
128 }
129 135
130 if (tb[NFTA_NAT_REG_ADDR_MAX]) { 136 if (tb[NFTA_NAT_REG_ADDR_MAX]) {
131 priv->sreg_addr_max = ntohl(nla_get_be32( 137 priv->sreg_addr_max =
132 tb[NFTA_NAT_REG_ADDR_MAX])); 138 ntohl(nla_get_be32(tb[NFTA_NAT_REG_ADDR_MAX]));
133 err = nft_validate_input_register(priv->sreg_addr_max); 139
134 if (err < 0) 140 err = nft_validate_input_register(priv->sreg_addr_max);
135 return err; 141 if (err < 0)
136 } else 142 return err;
137 priv->sreg_addr_max = priv->sreg_addr_min; 143 } else {
144 priv->sreg_addr_max = priv->sreg_addr_min;
145 }
146 }
138 147
139 if (tb[NFTA_NAT_REG_PROTO_MIN]) { 148 if (tb[NFTA_NAT_REG_PROTO_MIN]) {
140 priv->sreg_proto_min = ntohl(nla_get_be32( 149 priv->sreg_proto_min =
141 tb[NFTA_NAT_REG_PROTO_MIN])); 150 ntohl(nla_get_be32(tb[NFTA_NAT_REG_PROTO_MIN]));
151
142 err = nft_validate_input_register(priv->sreg_proto_min); 152 err = nft_validate_input_register(priv->sreg_proto_min);
143 if (err < 0) 153 if (err < 0)
144 return err; 154 return err;
145 }
146 155
147 if (tb[NFTA_NAT_REG_PROTO_MAX]) { 156 if (tb[NFTA_NAT_REG_PROTO_MAX]) {
148 priv->sreg_proto_max = ntohl(nla_get_be32( 157 priv->sreg_proto_max =
149 tb[NFTA_NAT_REG_PROTO_MAX])); 158 ntohl(nla_get_be32(tb[NFTA_NAT_REG_PROTO_MAX]));
150 err = nft_validate_input_register(priv->sreg_proto_max); 159
151 if (err < 0) 160 err = nft_validate_input_register(priv->sreg_proto_max);
152 return err; 161 if (err < 0)
153 } else 162 return err;
154 priv->sreg_proto_max = priv->sreg_proto_min; 163 } else {
164 priv->sreg_proto_max = priv->sreg_proto_min;
165 }
166 }
155 167
156 if (tb[NFTA_NAT_FLAGS]) { 168 if (tb[NFTA_NAT_FLAGS]) {
157 priv->flags = ntohl(nla_get_be32(tb[NFTA_NAT_FLAGS])); 169 priv->flags = ntohl(nla_get_be32(tb[NFTA_NAT_FLAGS]));
@@ -179,17 +191,19 @@ static int nft_nat_dump(struct sk_buff *skb, const struct nft_expr *expr)
179 191
180 if (nla_put_be32(skb, NFTA_NAT_FAMILY, htonl(priv->family))) 192 if (nla_put_be32(skb, NFTA_NAT_FAMILY, htonl(priv->family)))
181 goto nla_put_failure; 193 goto nla_put_failure;
182 if (nla_put_be32(skb, 194
183 NFTA_NAT_REG_ADDR_MIN, htonl(priv->sreg_addr_min))) 195 if (priv->sreg_addr_min) {
184 goto nla_put_failure; 196 if (nla_put_be32(skb, NFTA_NAT_REG_ADDR_MIN,
185 if (nla_put_be32(skb, 197 htonl(priv->sreg_addr_min)) ||
186 NFTA_NAT_REG_ADDR_MAX, htonl(priv->sreg_addr_max))) 198 nla_put_be32(skb, NFTA_NAT_REG_ADDR_MAX,
187 goto nla_put_failure; 199 htonl(priv->sreg_addr_max)))
200 goto nla_put_failure;
201 }
202
188 if (priv->sreg_proto_min) { 203 if (priv->sreg_proto_min) {
189 if (nla_put_be32(skb, NFTA_NAT_REG_PROTO_MIN, 204 if (nla_put_be32(skb, NFTA_NAT_REG_PROTO_MIN,
190 htonl(priv->sreg_proto_min))) 205 htonl(priv->sreg_proto_min)) ||
191 goto nla_put_failure; 206 nla_put_be32(skb, NFTA_NAT_REG_PROTO_MAX,
192 if (nla_put_be32(skb, NFTA_NAT_REG_PROTO_MAX,
193 htonl(priv->sreg_proto_max))) 207 htonl(priv->sreg_proto_max)))
194 goto nla_put_failure; 208 goto nla_put_failure;
195 } 209 }
@@ -205,6 +219,13 @@ nla_put_failure:
205 return -1; 219 return -1;
206} 220}
207 221
222static int nft_nat_validate(const struct nft_ctx *ctx,
223 const struct nft_expr *expr,
224 const struct nft_data **data)
225{
226 return nft_chain_validate_dependency(ctx->chain, NFT_CHAIN_T_NAT);
227}
228
208static struct nft_expr_type nft_nat_type; 229static struct nft_expr_type nft_nat_type;
209static const struct nft_expr_ops nft_nat_ops = { 230static const struct nft_expr_ops nft_nat_ops = {
210 .type = &nft_nat_type, 231 .type = &nft_nat_type,
@@ -212,6 +233,7 @@ static const struct nft_expr_ops nft_nat_ops = {
212 .eval = nft_nat_eval, 233 .eval = nft_nat_eval,
213 .init = nft_nat_init, 234 .init = nft_nat_init,
214 .dump = nft_nat_dump, 235 .dump = nft_nat_dump,
236 .validate = nft_nat_validate,
215}; 237};
216 238
217static struct nft_expr_type nft_nat_type __read_mostly = { 239static struct nft_expr_type nft_nat_type __read_mostly = {
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 7a186e74b1b3..f1de72de273e 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -96,6 +96,14 @@ static DECLARE_WAIT_QUEUE_HEAD(nl_table_wait);
96static int netlink_dump(struct sock *sk); 96static int netlink_dump(struct sock *sk);
97static void netlink_skb_destructor(struct sk_buff *skb); 97static void netlink_skb_destructor(struct sk_buff *skb);
98 98
99/* nl_table locking explained:
100 * Lookup and traversal are protected with nl_sk_hash_lock or nl_table_lock
101 * combined with an RCU read-side lock. Insertion and removal are protected
102 * with nl_sk_hash_lock while using RCU list modification primitives and may
103 * run in parallel to nl_table_lock protected lookups. Destruction of the
104 * Netlink socket may only occur *after* nl_table_lock has been acquired
105 * either during or after the socket has been removed from the list.
106 */
99DEFINE_RWLOCK(nl_table_lock); 107DEFINE_RWLOCK(nl_table_lock);
100EXPORT_SYMBOL_GPL(nl_table_lock); 108EXPORT_SYMBOL_GPL(nl_table_lock);
101static atomic_t nl_table_users = ATOMIC_INIT(0); 109static atomic_t nl_table_users = ATOMIC_INIT(0);
@@ -109,10 +117,10 @@ EXPORT_SYMBOL_GPL(nl_sk_hash_lock);
109static int lockdep_nl_sk_hash_is_held(void) 117static int lockdep_nl_sk_hash_is_held(void)
110{ 118{
111#ifdef CONFIG_LOCKDEP 119#ifdef CONFIG_LOCKDEP
112 return (debug_locks) ? lockdep_is_held(&nl_sk_hash_lock) : 1; 120 if (debug_locks)
113#else 121 return lockdep_is_held(&nl_sk_hash_lock) || lockdep_is_held(&nl_table_lock);
114 return 1;
115#endif 122#endif
123 return 1;
116} 124}
117 125
118static ATOMIC_NOTIFIER_HEAD(netlink_chain); 126static ATOMIC_NOTIFIER_HEAD(netlink_chain);
@@ -1028,11 +1036,13 @@ static struct sock *netlink_lookup(struct net *net, int protocol, u32 portid)
1028 struct netlink_table *table = &nl_table[protocol]; 1036 struct netlink_table *table = &nl_table[protocol];
1029 struct sock *sk; 1037 struct sock *sk;
1030 1038
1039 read_lock(&nl_table_lock);
1031 rcu_read_lock(); 1040 rcu_read_lock();
1032 sk = __netlink_lookup(table, portid, net); 1041 sk = __netlink_lookup(table, portid, net);
1033 if (sk) 1042 if (sk)
1034 sock_hold(sk); 1043 sock_hold(sk);
1035 rcu_read_unlock(); 1044 rcu_read_unlock();
1045 read_unlock(&nl_table_lock);
1036 1046
1037 return sk; 1047 return sk;
1038} 1048}
@@ -1257,9 +1267,6 @@ static int netlink_release(struct socket *sock)
1257 } 1267 }
1258 netlink_table_ungrab(); 1268 netlink_table_ungrab();
1259 1269
1260 /* Wait for readers to complete */
1261 synchronize_net();
1262
1263 kfree(nlk->groups); 1270 kfree(nlk->groups);
1264 nlk->groups = NULL; 1271 nlk->groups = NULL;
1265 1272
@@ -1281,6 +1288,7 @@ static int netlink_autobind(struct socket *sock)
1281 1288
1282retry: 1289retry:
1283 cond_resched(); 1290 cond_resched();
1291 netlink_table_grab();
1284 rcu_read_lock(); 1292 rcu_read_lock();
1285 if (__netlink_lookup(table, portid, net)) { 1293 if (__netlink_lookup(table, portid, net)) {
1286 /* Bind collision, search negative portid values. */ 1294 /* Bind collision, search negative portid values. */
@@ -1288,9 +1296,11 @@ retry:
1288 if (rover > -4097) 1296 if (rover > -4097)
1289 rover = -4097; 1297 rover = -4097;
1290 rcu_read_unlock(); 1298 rcu_read_unlock();
1299 netlink_table_ungrab();
1291 goto retry; 1300 goto retry;
1292 } 1301 }
1293 rcu_read_unlock(); 1302 rcu_read_unlock();
1303 netlink_table_ungrab();
1294 1304
1295 err = netlink_insert(sk, net, portid); 1305 err = netlink_insert(sk, net, portid);
1296 if (err == -EADDRINUSE) 1306 if (err == -EADDRINUSE)
@@ -2921,14 +2931,16 @@ static struct sock *netlink_seq_socket_idx(struct seq_file *seq, loff_t pos)
2921} 2931}
2922 2932
2923static void *netlink_seq_start(struct seq_file *seq, loff_t *pos) 2933static void *netlink_seq_start(struct seq_file *seq, loff_t *pos)
2924 __acquires(RCU) 2934 __acquires(nl_table_lock) __acquires(RCU)
2925{ 2935{
2936 read_lock(&nl_table_lock);
2926 rcu_read_lock(); 2937 rcu_read_lock();
2927 return *pos ? netlink_seq_socket_idx(seq, *pos - 1) : SEQ_START_TOKEN; 2938 return *pos ? netlink_seq_socket_idx(seq, *pos - 1) : SEQ_START_TOKEN;
2928} 2939}
2929 2940
2930static void *netlink_seq_next(struct seq_file *seq, void *v, loff_t *pos) 2941static void *netlink_seq_next(struct seq_file *seq, void *v, loff_t *pos)
2931{ 2942{
2943 struct rhashtable *ht;
2932 struct netlink_sock *nlk; 2944 struct netlink_sock *nlk;
2933 struct nl_seq_iter *iter; 2945 struct nl_seq_iter *iter;
2934 struct net *net; 2946 struct net *net;
@@ -2943,19 +2955,19 @@ static void *netlink_seq_next(struct seq_file *seq, void *v, loff_t *pos)
2943 iter = seq->private; 2955 iter = seq->private;
2944 nlk = v; 2956 nlk = v;
2945 2957
2946 rht_for_each_entry_rcu(nlk, nlk->node.next, node) 2958 i = iter->link;
2959 ht = &nl_table[i].hash;
2960 rht_for_each_entry(nlk, nlk->node.next, ht, node)
2947 if (net_eq(sock_net((struct sock *)nlk), net)) 2961 if (net_eq(sock_net((struct sock *)nlk), net))
2948 return nlk; 2962 return nlk;
2949 2963
2950 i = iter->link;
2951 j = iter->hash_idx + 1; 2964 j = iter->hash_idx + 1;
2952 2965
2953 do { 2966 do {
2954 struct rhashtable *ht = &nl_table[i].hash;
2955 const struct bucket_table *tbl = rht_dereference_rcu(ht->tbl, ht); 2967 const struct bucket_table *tbl = rht_dereference_rcu(ht->tbl, ht);
2956 2968
2957 for (; j < tbl->size; j++) { 2969 for (; j < tbl->size; j++) {
2958 rht_for_each_entry_rcu(nlk, tbl->buckets[j], node) { 2970 rht_for_each_entry(nlk, tbl->buckets[j], ht, node) {
2959 if (net_eq(sock_net((struct sock *)nlk), net)) { 2971 if (net_eq(sock_net((struct sock *)nlk), net)) {
2960 iter->link = i; 2972 iter->link = i;
2961 iter->hash_idx = j; 2973 iter->hash_idx = j;
@@ -2971,9 +2983,10 @@ static void *netlink_seq_next(struct seq_file *seq, void *v, loff_t *pos)
2971} 2983}
2972 2984
2973static void netlink_seq_stop(struct seq_file *seq, void *v) 2985static void netlink_seq_stop(struct seq_file *seq, void *v)
2974 __releases(RCU) 2986 __releases(RCU) __releases(nl_table_lock)
2975{ 2987{
2976 rcu_read_unlock(); 2988 rcu_read_unlock();
2989 read_unlock(&nl_table_lock);
2977} 2990}
2978 2991
2979 2992
diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
index 2e31d9e7f4dc..e6d7255183eb 100644
--- a/net/openvswitch/datapath.c
+++ b/net/openvswitch/datapath.c
@@ -324,6 +324,8 @@ static int queue_gso_packets(struct datapath *dp, struct sk_buff *skb,
324 segs = __skb_gso_segment(skb, NETIF_F_SG, false); 324 segs = __skb_gso_segment(skb, NETIF_F_SG, false);
325 if (IS_ERR(segs)) 325 if (IS_ERR(segs))
326 return PTR_ERR(segs); 326 return PTR_ERR(segs);
327 if (segs == NULL)
328 return -EINVAL;
327 329
328 /* Queue all of the segments. */ 330 /* Queue all of the segments. */
329 skb = segs; 331 skb = segs;
diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
index 2cf61b3e633c..76f402e05bd6 100644
--- a/net/sched/sch_api.c
+++ b/net/sched/sch_api.c
@@ -947,7 +947,7 @@ qdisc_create(struct net_device *dev, struct netdev_queue *dev_queue,
947 if (!ops->init || (err = ops->init(sch, tca[TCA_OPTIONS])) == 0) { 947 if (!ops->init || (err = ops->init(sch, tca[TCA_OPTIONS])) == 0) {
948 if (qdisc_is_percpu_stats(sch)) { 948 if (qdisc_is_percpu_stats(sch)) {
949 sch->cpu_bstats = 949 sch->cpu_bstats =
950 alloc_percpu(struct gnet_stats_basic_cpu); 950 netdev_alloc_pcpu_stats(struct gnet_stats_basic_cpu);
951 if (!sch->cpu_bstats) 951 if (!sch->cpu_bstats)
952 goto err_out4; 952 goto err_out4;
953 953
diff --git a/net/sched/sch_pie.c b/net/sched/sch_pie.c
index 33d7a98a7a97..b783a446d884 100644
--- a/net/sched/sch_pie.c
+++ b/net/sched/sch_pie.c
@@ -445,7 +445,6 @@ static int pie_init(struct Qdisc *sch, struct nlattr *opt)
445 sch->limit = q->params.limit; 445 sch->limit = q->params.limit;
446 446
447 setup_timer(&q->adapt_timer, pie_timer, (unsigned long)sch); 447 setup_timer(&q->adapt_timer, pie_timer, (unsigned long)sch);
448 mod_timer(&q->adapt_timer, jiffies + HZ / 2);
449 448
450 if (opt) { 449 if (opt) {
451 int err = pie_change(sch, opt); 450 int err = pie_change(sch, opt);
@@ -454,6 +453,7 @@ static int pie_init(struct Qdisc *sch, struct nlattr *opt)
454 return err; 453 return err;
455 } 454 }
456 455
456 mod_timer(&q->adapt_timer, jiffies + HZ / 2);
457 return 0; 457 return 0;
458} 458}
459 459
diff --git a/net/tipc/node.c b/net/tipc/node.c
index 90cee4a6fce4..5781634e957d 100644
--- a/net/tipc/node.c
+++ b/net/tipc/node.c
@@ -219,11 +219,11 @@ void tipc_node_abort_sock_conns(struct list_head *conns)
219void tipc_node_link_up(struct tipc_node *n_ptr, struct tipc_link *l_ptr) 219void tipc_node_link_up(struct tipc_node *n_ptr, struct tipc_link *l_ptr)
220{ 220{
221 struct tipc_link **active = &n_ptr->active_links[0]; 221 struct tipc_link **active = &n_ptr->active_links[0];
222 u32 addr = n_ptr->addr;
223 222
224 n_ptr->working_links++; 223 n_ptr->working_links++;
225 tipc_nametbl_publish(TIPC_LINK_STATE, addr, addr, TIPC_NODE_SCOPE, 224 n_ptr->action_flags |= TIPC_NOTIFY_LINK_UP;
226 l_ptr->bearer_id, addr); 225 n_ptr->link_id = l_ptr->peer_bearer_id << 16 | l_ptr->bearer_id;
226
227 pr_info("Established link <%s> on network plane %c\n", 227 pr_info("Established link <%s> on network plane %c\n",
228 l_ptr->name, l_ptr->net_plane); 228 l_ptr->name, l_ptr->net_plane);
229 229
@@ -284,10 +284,10 @@ static void node_select_active_links(struct tipc_node *n_ptr)
284void tipc_node_link_down(struct tipc_node *n_ptr, struct tipc_link *l_ptr) 284void tipc_node_link_down(struct tipc_node *n_ptr, struct tipc_link *l_ptr)
285{ 285{
286 struct tipc_link **active; 286 struct tipc_link **active;
287 u32 addr = n_ptr->addr;
288 287
289 n_ptr->working_links--; 288 n_ptr->working_links--;
290 tipc_nametbl_withdraw(TIPC_LINK_STATE, addr, l_ptr->bearer_id, addr); 289 n_ptr->action_flags |= TIPC_NOTIFY_LINK_DOWN;
290 n_ptr->link_id = l_ptr->peer_bearer_id << 16 | l_ptr->bearer_id;
291 291
292 if (!tipc_link_is_active(l_ptr)) { 292 if (!tipc_link_is_active(l_ptr)) {
293 pr_info("Lost standby link <%s> on network plane %c\n", 293 pr_info("Lost standby link <%s> on network plane %c\n",
@@ -552,28 +552,30 @@ void tipc_node_unlock(struct tipc_node *node)
552 LIST_HEAD(conn_sks); 552 LIST_HEAD(conn_sks);
553 struct sk_buff_head waiting_sks; 553 struct sk_buff_head waiting_sks;
554 u32 addr = 0; 554 u32 addr = 0;
555 unsigned int flags = node->action_flags; 555 int flags = node->action_flags;
556 u32 link_id = 0;
556 557
557 if (likely(!node->action_flags)) { 558 if (likely(!flags)) {
558 spin_unlock_bh(&node->lock); 559 spin_unlock_bh(&node->lock);
559 return; 560 return;
560 } 561 }
561 562
563 addr = node->addr;
564 link_id = node->link_id;
562 __skb_queue_head_init(&waiting_sks); 565 __skb_queue_head_init(&waiting_sks);
563 if (node->action_flags & TIPC_WAKEUP_USERS) { 566
567 if (flags & TIPC_WAKEUP_USERS)
564 skb_queue_splice_init(&node->waiting_sks, &waiting_sks); 568 skb_queue_splice_init(&node->waiting_sks, &waiting_sks);
565 node->action_flags &= ~TIPC_WAKEUP_USERS; 569
566 } 570 if (flags & TIPC_NOTIFY_NODE_DOWN) {
567 if (node->action_flags & TIPC_NOTIFY_NODE_DOWN) {
568 list_replace_init(&node->nsub, &nsub_list); 571 list_replace_init(&node->nsub, &nsub_list);
569 list_replace_init(&node->conn_sks, &conn_sks); 572 list_replace_init(&node->conn_sks, &conn_sks);
570 node->action_flags &= ~TIPC_NOTIFY_NODE_DOWN;
571 } 573 }
572 if (node->action_flags & TIPC_NOTIFY_NODE_UP) { 574 node->action_flags &= ~(TIPC_WAKEUP_USERS | TIPC_NOTIFY_NODE_DOWN |
573 node->action_flags &= ~TIPC_NOTIFY_NODE_UP; 575 TIPC_NOTIFY_NODE_UP | TIPC_NOTIFY_LINK_UP |
574 addr = node->addr; 576 TIPC_NOTIFY_LINK_DOWN |
575 } 577 TIPC_WAKEUP_BCAST_USERS);
576 node->action_flags &= ~TIPC_WAKEUP_BCAST_USERS; 578
577 spin_unlock_bh(&node->lock); 579 spin_unlock_bh(&node->lock);
578 580
579 while (!skb_queue_empty(&waiting_sks)) 581 while (!skb_queue_empty(&waiting_sks))
@@ -588,6 +590,14 @@ void tipc_node_unlock(struct tipc_node *node)
588 if (flags & TIPC_WAKEUP_BCAST_USERS) 590 if (flags & TIPC_WAKEUP_BCAST_USERS)
589 tipc_bclink_wakeup_users(); 591 tipc_bclink_wakeup_users();
590 592
591 if (addr) 593 if (flags & TIPC_NOTIFY_NODE_UP)
592 tipc_named_node_up(addr); 594 tipc_named_node_up(addr);
595
596 if (flags & TIPC_NOTIFY_LINK_UP)
597 tipc_nametbl_publish(TIPC_LINK_STATE, addr, addr,
598 TIPC_NODE_SCOPE, link_id, addr);
599
600 if (flags & TIPC_NOTIFY_LINK_DOWN)
601 tipc_nametbl_withdraw(TIPC_LINK_STATE, addr,
602 link_id, addr);
593} 603}
diff --git a/net/tipc/node.h b/net/tipc/node.h
index 67513c3c852c..04e91458bb29 100644
--- a/net/tipc/node.h
+++ b/net/tipc/node.h
@@ -53,6 +53,7 @@
53 * TIPC_WAIT_OWN_LINKS_DOWN: wait until peer node is declared down 53 * TIPC_WAIT_OWN_LINKS_DOWN: wait until peer node is declared down
54 * TIPC_NOTIFY_NODE_DOWN: notify node is down 54 * TIPC_NOTIFY_NODE_DOWN: notify node is down
55 * TIPC_NOTIFY_NODE_UP: notify node is up 55 * TIPC_NOTIFY_NODE_UP: notify node is up
56 * TIPC_DISTRIBUTE_NAME: publish or withdraw link state name type
56 */ 57 */
57enum { 58enum {
58 TIPC_WAIT_PEER_LINKS_DOWN = (1 << 1), 59 TIPC_WAIT_PEER_LINKS_DOWN = (1 << 1),
@@ -60,7 +61,9 @@ enum {
60 TIPC_NOTIFY_NODE_DOWN = (1 << 3), 61 TIPC_NOTIFY_NODE_DOWN = (1 << 3),
61 TIPC_NOTIFY_NODE_UP = (1 << 4), 62 TIPC_NOTIFY_NODE_UP = (1 << 4),
62 TIPC_WAKEUP_USERS = (1 << 5), 63 TIPC_WAKEUP_USERS = (1 << 5),
63 TIPC_WAKEUP_BCAST_USERS = (1 << 6) 64 TIPC_WAKEUP_BCAST_USERS = (1 << 6),
65 TIPC_NOTIFY_LINK_UP = (1 << 7),
66 TIPC_NOTIFY_LINK_DOWN = (1 << 8)
64}; 67};
65 68
66/** 69/**
@@ -100,6 +103,7 @@ struct tipc_node_bclink {
100 * @working_links: number of working links to node (both active and standby) 103 * @working_links: number of working links to node (both active and standby)
101 * @link_cnt: number of links to node 104 * @link_cnt: number of links to node
102 * @signature: node instance identifier 105 * @signature: node instance identifier
106 * @link_id: local and remote bearer ids of changing link, if any
103 * @nsub: list of "node down" subscriptions monitoring node 107 * @nsub: list of "node down" subscriptions monitoring node
104 * @rcu: rcu struct for tipc_node 108 * @rcu: rcu struct for tipc_node
105 */ 109 */
@@ -116,6 +120,7 @@ struct tipc_node {
116 int link_cnt; 120 int link_cnt;
117 int working_links; 121 int working_links;
118 u32 signature; 122 u32 signature;
123 u32 link_id;
119 struct list_head nsub; 124 struct list_head nsub;
120 struct sk_buff_head waiting_sks; 125 struct sk_buff_head waiting_sks;
121 struct list_head conn_sks; 126 struct list_head conn_sks;
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index 75275c5cf929..51bddc236a15 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -1776,7 +1776,7 @@ int tipc_sk_rcv(struct sk_buff *buf)
1776 sk = &tsk->sk; 1776 sk = &tsk->sk;
1777 1777
1778 /* Queue message */ 1778 /* Queue message */
1779 bh_lock_sock(sk); 1779 spin_lock_bh(&sk->sk_lock.slock);
1780 1780
1781 if (!sock_owned_by_user(sk)) { 1781 if (!sock_owned_by_user(sk)) {
1782 rc = filter_rcv(sk, buf); 1782 rc = filter_rcv(sk, buf);
@@ -1787,7 +1787,7 @@ int tipc_sk_rcv(struct sk_buff *buf)
1787 if (sk_add_backlog(sk, buf, limit)) 1787 if (sk_add_backlog(sk, buf, limit))
1788 rc = -TIPC_ERR_OVERLOAD; 1788 rc = -TIPC_ERR_OVERLOAD;
1789 } 1789 }
1790 bh_unlock_sock(sk); 1790 spin_unlock_bh(&sk->sk_lock.slock);
1791 tipc_sk_put(tsk); 1791 tipc_sk_put(tsk);
1792 if (likely(!rc)) 1792 if (likely(!rc))
1793 return 0; 1793 return 0;
@@ -2673,7 +2673,7 @@ static int tipc_ioctl(struct socket *sk, unsigned int cmd, unsigned long arg)
2673 case SIOCGETLINKNAME: 2673 case SIOCGETLINKNAME:
2674 if (copy_from_user(&lnr, argp, sizeof(lnr))) 2674 if (copy_from_user(&lnr, argp, sizeof(lnr)))
2675 return -EFAULT; 2675 return -EFAULT;
2676 if (!tipc_node_get_linkname(lnr.bearer_id, lnr.peer, 2676 if (!tipc_node_get_linkname(lnr.bearer_id & 0xffff, lnr.peer,
2677 lnr.linkname, TIPC_MAX_LINK_NAME)) { 2677 lnr.linkname, TIPC_MAX_LINK_NAME)) {
2678 if (copy_to_user(argp, &lnr, sizeof(lnr))) 2678 if (copy_to_user(argp, &lnr, sizeof(lnr)))
2679 return -EFAULT; 2679 return -EFAULT;
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index cb9f5a44ffad..5839c85075f1 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -5927,6 +5927,7 @@ static int nl80211_channel_switch(struct sk_buff *skb, struct genl_info *info)
5927 int err; 5927 int err;
5928 bool need_new_beacon = false; 5928 bool need_new_beacon = false;
5929 int len, i; 5929 int len, i;
5930 u32 cs_count;
5930 5931
5931 if (!rdev->ops->channel_switch || 5932 if (!rdev->ops->channel_switch ||
5932 !(rdev->wiphy.flags & WIPHY_FLAG_HAS_CHANNEL_SWITCH)) 5933 !(rdev->wiphy.flags & WIPHY_FLAG_HAS_CHANNEL_SWITCH))
@@ -5963,7 +5964,14 @@ static int nl80211_channel_switch(struct sk_buff *skb, struct genl_info *info)
5963 if (need_new_beacon && !info->attrs[NL80211_ATTR_CSA_IES]) 5964 if (need_new_beacon && !info->attrs[NL80211_ATTR_CSA_IES])
5964 return -EINVAL; 5965 return -EINVAL;
5965 5966
5966 params.count = nla_get_u32(info->attrs[NL80211_ATTR_CH_SWITCH_COUNT]); 5967 /* Even though the attribute is u32, the specification says
5968 * u8, so let's make sure we don't overflow.
5969 */
5970 cs_count = nla_get_u32(info->attrs[NL80211_ATTR_CH_SWITCH_COUNT]);
5971 if (cs_count > 255)
5972 return -EINVAL;
5973
5974 params.count = cs_count;
5967 5975
5968 if (!need_new_beacon) 5976 if (!need_new_beacon)
5969 goto skip_beacons; 5977 goto skip_beacons;
diff --git a/net/xfrm/xfrm_output.c b/net/xfrm/xfrm_output.c
index 499d6c18a8ce..7c532856b398 100644
--- a/net/xfrm/xfrm_output.c
+++ b/net/xfrm/xfrm_output.c
@@ -157,6 +157,8 @@ static int xfrm_output_gso(struct sk_buff *skb)
157 kfree_skb(skb); 157 kfree_skb(skb);
158 if (IS_ERR(segs)) 158 if (IS_ERR(segs))
159 return PTR_ERR(segs); 159 return PTR_ERR(segs);
160 if (segs == NULL)
161 return -EINVAL;
160 162
161 do { 163 do {
162 struct sk_buff *nskb = segs->next; 164 struct sk_buff *nskb = segs->next;
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index 4c4e457e7888..88bf289abdc9 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -1962,7 +1962,7 @@ static int xdst_queue_output(struct sock *sk, struct sk_buff *skb)
1962 struct xfrm_policy *pol = xdst->pols[0]; 1962 struct xfrm_policy *pol = xdst->pols[0];
1963 struct xfrm_policy_queue *pq = &pol->polq; 1963 struct xfrm_policy_queue *pq = &pol->polq;
1964 1964
1965 if (unlikely(skb_fclone_busy(skb))) { 1965 if (unlikely(skb_fclone_busy(sk, skb))) {
1966 kfree_skb(skb); 1966 kfree_skb(skb);
1967 return 0; 1967 return 0;
1968 } 1968 }
diff --git a/samples/bpf/test_verifier.c b/samples/bpf/test_verifier.c
index f44ef11f65a7..eb4bec0ad8af 100644
--- a/samples/bpf/test_verifier.c
+++ b/samples/bpf/test_verifier.c
@@ -209,6 +209,17 @@ static struct bpf_test tests[] = {
209 .result = REJECT, 209 .result = REJECT,
210 }, 210 },
211 { 211 {
212 "program doesn't init R0 before exit in all branches",
213 .insns = {
214 BPF_JMP_IMM(BPF_JGE, BPF_REG_1, 0, 2),
215 BPF_MOV64_IMM(BPF_REG_0, 1),
216 BPF_ALU64_IMM(BPF_ADD, BPF_REG_0, 2),
217 BPF_EXIT_INSN(),
218 },
219 .errstr = "R0 !read_ok",
220 .result = REJECT,
221 },
222 {
212 "stack out of bounds", 223 "stack out of bounds",
213 .insns = { 224 .insns = {
214 BPF_ST_MEM(BPF_DW, BPF_REG_10, 8, 0), 225 BPF_ST_MEM(BPF_DW, BPF_REG_10, 8, 0),
diff --git a/security/integrity/evm/evm_main.c b/security/integrity/evm/evm_main.c
index 9685af330de5..c5ee1a7c5e8a 100644
--- a/security/integrity/evm/evm_main.c
+++ b/security/integrity/evm/evm_main.c
@@ -319,9 +319,12 @@ int evm_inode_setxattr(struct dentry *dentry, const char *xattr_name,
319{ 319{
320 const struct evm_ima_xattr_data *xattr_data = xattr_value; 320 const struct evm_ima_xattr_data *xattr_data = xattr_value;
321 321
322 if ((strcmp(xattr_name, XATTR_NAME_EVM) == 0) 322 if (strcmp(xattr_name, XATTR_NAME_EVM) == 0) {
323 && (xattr_data->type == EVM_XATTR_HMAC)) 323 if (!xattr_value_len)
324 return -EPERM; 324 return -EINVAL;
325 if (xattr_data->type != EVM_IMA_XATTR_DIGSIG)
326 return -EPERM;
327 }
325 return evm_protect_xattr(dentry, xattr_name, xattr_value, 328 return evm_protect_xattr(dentry, xattr_name, xattr_value,
326 xattr_value_len); 329 xattr_value_len);
327} 330}
diff --git a/security/integrity/ima/ima_appraise.c b/security/integrity/ima/ima_appraise.c
index 922685483bd3..7c8f41e618b6 100644
--- a/security/integrity/ima/ima_appraise.c
+++ b/security/integrity/ima/ima_appraise.c
@@ -378,6 +378,8 @@ int ima_inode_setxattr(struct dentry *dentry, const char *xattr_name,
378 result = ima_protect_xattr(dentry, xattr_name, xattr_value, 378 result = ima_protect_xattr(dentry, xattr_name, xattr_value,
379 xattr_value_len); 379 xattr_value_len);
380 if (result == 1) { 380 if (result == 1) {
381 if (!xattr_value_len || (xvalue->type >= IMA_XATTR_LAST))
382 return -EINVAL;
381 ima_reset_appraise_flags(dentry->d_inode, 383 ima_reset_appraise_flags(dentry->d_inode,
382 (xvalue->type == EVM_IMA_XATTR_DIGSIG) ? 1 : 0); 384 (xvalue->type == EVM_IMA_XATTR_DIGSIG) ? 1 : 0);
383 result = 0; 385 result = 0;
diff --git a/security/integrity/integrity.h b/security/integrity/integrity.h
index c0379d13dbe1..9d1c2ebfe12a 100644
--- a/security/integrity/integrity.h
+++ b/security/integrity/integrity.h
@@ -61,6 +61,7 @@ enum evm_ima_xattr_type {
61 EVM_XATTR_HMAC, 61 EVM_XATTR_HMAC,
62 EVM_IMA_XATTR_DIGSIG, 62 EVM_IMA_XATTR_DIGSIG,
63 IMA_XATTR_DIGEST_NG, 63 IMA_XATTR_DIGEST_NG,
64 IMA_XATTR_LAST
64}; 65};
65 66
66struct evm_ima_xattr_data { 67struct evm_ima_xattr_data {
diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c
index 102e8fd1d450..2d957ba63557 100644
--- a/sound/core/pcm_compat.c
+++ b/sound/core/pcm_compat.c
@@ -210,6 +210,8 @@ static int snd_pcm_status_user_compat(struct snd_pcm_substream *substream,
210 if (err < 0) 210 if (err < 0)
211 return err; 211 return err;
212 212
213 if (clear_user(src, sizeof(*src)))
214 return -EFAULT;
213 if (put_user(status.state, &src->state) || 215 if (put_user(status.state, &src->state) ||
214 compat_put_timespec(&status.trigger_tstamp, &src->trigger_tstamp) || 216 compat_put_timespec(&status.trigger_tstamp, &src->trigger_tstamp) ||
215 compat_put_timespec(&status.tstamp, &src->tstamp) || 217 compat_put_timespec(&status.tstamp, &src->tstamp) ||
diff --git a/sound/firewire/bebob/bebob_focusrite.c b/sound/firewire/bebob/bebob_focusrite.c
index 45a0eed6d5b1..3b052ed0fbf5 100644
--- a/sound/firewire/bebob/bebob_focusrite.c
+++ b/sound/firewire/bebob/bebob_focusrite.c
@@ -27,12 +27,14 @@
27#define SAFFIRE_CLOCK_SOURCE_INTERNAL 0 27#define SAFFIRE_CLOCK_SOURCE_INTERNAL 0
28#define SAFFIRE_CLOCK_SOURCE_SPDIF 1 28#define SAFFIRE_CLOCK_SOURCE_SPDIF 1
29 29
30/* '1' is absent, why... */ 30/* clock sources as returned from register of Saffire Pro 10 and 26 */
31#define SAFFIREPRO_CLOCK_SOURCE_INTERNAL 0 31#define SAFFIREPRO_CLOCK_SOURCE_INTERNAL 0
32#define SAFFIREPRO_CLOCK_SOURCE_SKIP 1 /* never used on hardware */
32#define SAFFIREPRO_CLOCK_SOURCE_SPDIF 2 33#define SAFFIREPRO_CLOCK_SOURCE_SPDIF 2
33#define SAFFIREPRO_CLOCK_SOURCE_ADAT1 3 34#define SAFFIREPRO_CLOCK_SOURCE_ADAT1 3 /* not used on s.pro. 10 */
34#define SAFFIREPRO_CLOCK_SOURCE_ADAT2 4 35#define SAFFIREPRO_CLOCK_SOURCE_ADAT2 4 /* not used on s.pro. 10 */
35#define SAFFIREPRO_CLOCK_SOURCE_WORDCLOCK 5 36#define SAFFIREPRO_CLOCK_SOURCE_WORDCLOCK 5
37#define SAFFIREPRO_CLOCK_SOURCE_COUNT 6
36 38
37/* S/PDIF, ADAT1, ADAT2 is enabled or not. three quadlets */ 39/* S/PDIF, ADAT1, ADAT2 is enabled or not. three quadlets */
38#define SAFFIREPRO_ENABLE_DIG_IFACES 0x01a4 40#define SAFFIREPRO_ENABLE_DIG_IFACES 0x01a4
@@ -101,13 +103,34 @@ saffire_write_quad(struct snd_bebob *bebob, u64 offset, u32 value)
101 &data, sizeof(__be32), 0); 103 &data, sizeof(__be32), 0);
102} 104}
103 105
106static char *const saffirepro_10_clk_src_labels[] = {
107 SND_BEBOB_CLOCK_INTERNAL, "S/PDIF", "Word Clock"
108};
104static char *const saffirepro_26_clk_src_labels[] = { 109static char *const saffirepro_26_clk_src_labels[] = {
105 SND_BEBOB_CLOCK_INTERNAL, "S/PDIF", "ADAT1", "ADAT2", "Word Clock" 110 SND_BEBOB_CLOCK_INTERNAL, "S/PDIF", "ADAT1", "ADAT2", "Word Clock"
106}; 111};
107 112/* Value maps between registers and labels for SaffirePro 10/26. */
108static char *const saffirepro_10_clk_src_labels[] = { 113static const signed char saffirepro_clk_maps[][SAFFIREPRO_CLOCK_SOURCE_COUNT] = {
109 SND_BEBOB_CLOCK_INTERNAL, "S/PDIF", "Word Clock" 114 /* SaffirePro 10 */
115 [0] = {
116 [SAFFIREPRO_CLOCK_SOURCE_INTERNAL] = 0,
117 [SAFFIREPRO_CLOCK_SOURCE_SKIP] = -1, /* not supported */
118 [SAFFIREPRO_CLOCK_SOURCE_SPDIF] = 1,
119 [SAFFIREPRO_CLOCK_SOURCE_ADAT1] = -1, /* not supported */
120 [SAFFIREPRO_CLOCK_SOURCE_ADAT2] = -1, /* not supported */
121 [SAFFIREPRO_CLOCK_SOURCE_WORDCLOCK] = 2,
122 },
123 /* SaffirePro 26 */
124 [1] = {
125 [SAFFIREPRO_CLOCK_SOURCE_INTERNAL] = 0,
126 [SAFFIREPRO_CLOCK_SOURCE_SKIP] = -1, /* not supported */
127 [SAFFIREPRO_CLOCK_SOURCE_SPDIF] = 1,
128 [SAFFIREPRO_CLOCK_SOURCE_ADAT1] = 2,
129 [SAFFIREPRO_CLOCK_SOURCE_ADAT2] = 3,
130 [SAFFIREPRO_CLOCK_SOURCE_WORDCLOCK] = 4,
131 }
110}; 132};
133
111static int 134static int
112saffirepro_both_clk_freq_get(struct snd_bebob *bebob, unsigned int *rate) 135saffirepro_both_clk_freq_get(struct snd_bebob *bebob, unsigned int *rate)
113{ 136{
@@ -138,24 +161,35 @@ saffirepro_both_clk_freq_set(struct snd_bebob *bebob, unsigned int rate)
138 161
139 return saffire_write_quad(bebob, SAFFIREPRO_RATE_NOREBOOT, id); 162 return saffire_write_quad(bebob, SAFFIREPRO_RATE_NOREBOOT, id);
140} 163}
164
165/*
166 * query hardware for current clock source, return our internally
167 * used clock index in *id, depending on hardware.
168 */
141static int 169static int
142saffirepro_both_clk_src_get(struct snd_bebob *bebob, unsigned int *id) 170saffirepro_both_clk_src_get(struct snd_bebob *bebob, unsigned int *id)
143{ 171{
144 int err; 172 int err;
145 u32 value; 173 u32 value; /* clock source read from hw register */
174 const signed char *map;
146 175
147 err = saffire_read_quad(bebob, SAFFIREPRO_OFFSET_CLOCK_SOURCE, &value); 176 err = saffire_read_quad(bebob, SAFFIREPRO_OFFSET_CLOCK_SOURCE, &value);
148 if (err < 0) 177 if (err < 0)
149 goto end; 178 goto end;
150 179
151 if (bebob->spec->clock->labels == saffirepro_10_clk_src_labels) { 180 /* depending on hardware, use a different mapping */
152 if (value == SAFFIREPRO_CLOCK_SOURCE_WORDCLOCK) 181 if (bebob->spec->clock->labels == saffirepro_10_clk_src_labels)
153 *id = 2; 182 map = saffirepro_clk_maps[0];
154 else if (value == SAFFIREPRO_CLOCK_SOURCE_SPDIF) 183 else
155 *id = 1; 184 map = saffirepro_clk_maps[1];
156 } else if (value > 1) { 185
157 *id = value - 1; 186 /* In a case that this driver cannot handle the value of register. */
187 if (value >= SAFFIREPRO_CLOCK_SOURCE_COUNT || map[value] < 0) {
188 err = -EIO;
189 goto end;
158 } 190 }
191
192 *id = (unsigned int)map[value];
159end: 193end:
160 return err; 194 return err;
161} 195}
diff --git a/sound/firewire/bebob/bebob_stream.c b/sound/firewire/bebob/bebob_stream.c
index ef4d0c9f6578..1aab0a32870c 100644
--- a/sound/firewire/bebob/bebob_stream.c
+++ b/sound/firewire/bebob/bebob_stream.c
@@ -129,12 +129,24 @@ snd_bebob_stream_check_internal_clock(struct snd_bebob *bebob, bool *internal)
129 /* 1.The device has its own operation to switch source of clock */ 129 /* 1.The device has its own operation to switch source of clock */
130 if (clk_spec) { 130 if (clk_spec) {
131 err = clk_spec->get(bebob, &id); 131 err = clk_spec->get(bebob, &id);
132 if (err < 0) 132 if (err < 0) {
133 dev_err(&bebob->unit->device, 133 dev_err(&bebob->unit->device,
134 "fail to get clock source: %d\n", err); 134 "fail to get clock source: %d\n", err);
135 else if (strncmp(clk_spec->labels[id], SND_BEBOB_CLOCK_INTERNAL, 135 goto end;
136 strlen(SND_BEBOB_CLOCK_INTERNAL)) == 0) 136 }
137
138 if (id >= clk_spec->num) {
139 dev_err(&bebob->unit->device,
140 "clock source %d out of range 0..%d\n",
141 id, clk_spec->num - 1);
142 err = -EIO;
143 goto end;
144 }
145
146 if (strncmp(clk_spec->labels[id], SND_BEBOB_CLOCK_INTERNAL,
147 strlen(SND_BEBOB_CLOCK_INTERNAL)) == 0)
137 *internal = true; 148 *internal = true;
149
138 goto end; 150 goto end;
139 } 151 }
140 152
diff --git a/sound/firewire/bebob/bebob_terratec.c b/sound/firewire/bebob/bebob_terratec.c
index 0e4c0bfc463b..9940611f2e1b 100644
--- a/sound/firewire/bebob/bebob_terratec.c
+++ b/sound/firewire/bebob/bebob_terratec.c
@@ -24,7 +24,12 @@ phase88_rack_clk_src_get(struct snd_bebob *bebob, unsigned int *id)
24 if (err < 0) 24 if (err < 0)
25 goto end; 25 goto end;
26 26
27 *id = (enable_ext & 0x01) | ((enable_word & 0x01) << 1); 27 if (enable_ext == 0)
28 *id = 0;
29 else if (enable_word == 0)
30 *id = 1;
31 else
32 *id = 2;
28end: 33end:
29 return err; 34 return err;
30} 35}
diff --git a/sound/pci/ad1889.c b/sound/pci/ad1889.c
index 7bfdf9c51416..1610c38337af 100644
--- a/sound/pci/ad1889.c
+++ b/sound/pci/ad1889.c
@@ -681,7 +681,7 @@ snd_ad1889_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffe
681 681
682 /* WARQ is at offset 12 */ 682 /* WARQ is at offset 12 */
683 tmp = (reg & AD_DS_WSMC_WARQ) ? 683 tmp = (reg & AD_DS_WSMC_WARQ) ?
684 (((reg & AD_DS_WSMC_WARQ >> 12) & 0x01) ? 12 : 18) : 4; 684 ((((reg & AD_DS_WSMC_WARQ) >> 12) & 0x01) ? 12 : 18) : 4;
685 tmp /= (reg & AD_DS_WSMC_WAST) ? 2 : 1; 685 tmp /= (reg & AD_DS_WSMC_WAST) ? 2 : 1;
686 686
687 snd_iprintf(buffer, "Wave FIFO: %d %s words\n\n", tmp, 687 snd_iprintf(buffer, "Wave FIFO: %d %s words\n\n", tmp,
@@ -693,7 +693,7 @@ snd_ad1889_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffe
693 693
694 /* SYRQ is at offset 4 */ 694 /* SYRQ is at offset 4 */
695 tmp = (reg & AD_DS_WSMC_SYRQ) ? 695 tmp = (reg & AD_DS_WSMC_SYRQ) ?
696 (((reg & AD_DS_WSMC_SYRQ >> 4) & 0x01) ? 12 : 18) : 4; 696 ((((reg & AD_DS_WSMC_SYRQ) >> 4) & 0x01) ? 12 : 18) : 4;
697 tmp /= (reg & AD_DS_WSMC_WAST) ? 2 : 1; 697 tmp /= (reg & AD_DS_WSMC_WAST) ? 2 : 1;
698 698
699 snd_iprintf(buffer, "Synthesis FIFO: %d %s words\n\n", tmp, 699 snd_iprintf(buffer, "Synthesis FIFO: %d %s words\n\n", tmp,
@@ -709,7 +709,7 @@ snd_ad1889_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffe
709 709
710 /* ACRQ is at offset 4 */ 710 /* ACRQ is at offset 4 */
711 tmp = (reg & AD_DS_RAMC_ACRQ) ? 711 tmp = (reg & AD_DS_RAMC_ACRQ) ?
712 (((reg & AD_DS_RAMC_ACRQ >> 4) & 0x01) ? 12 : 18) : 4; 712 ((((reg & AD_DS_RAMC_ACRQ) >> 4) & 0x01) ? 12 : 18) : 4;
713 tmp /= (reg & AD_DS_RAMC_ADST) ? 2 : 1; 713 tmp /= (reg & AD_DS_RAMC_ADST) ? 2 : 1;
714 714
715 snd_iprintf(buffer, "ADC FIFO: %d %s words\n\n", tmp, 715 snd_iprintf(buffer, "ADC FIFO: %d %s words\n\n", tmp,
@@ -720,7 +720,7 @@ snd_ad1889_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffe
720 720
721 /* RERQ is at offset 12 */ 721 /* RERQ is at offset 12 */
722 tmp = (reg & AD_DS_RAMC_RERQ) ? 722 tmp = (reg & AD_DS_RAMC_RERQ) ?
723 (((reg & AD_DS_RAMC_RERQ >> 12) & 0x01) ? 12 : 18) : 4; 723 ((((reg & AD_DS_RAMC_RERQ) >> 12) & 0x01) ? 12 : 18) : 4;
724 tmp /= (reg & AD_DS_RAMC_ADST) ? 2 : 1; 724 tmp /= (reg & AD_DS_RAMC_ADST) ? 2 : 1;
725 725
726 snd_iprintf(buffer, "Resampler FIFO: %d %s words\n\n", tmp, 726 snd_iprintf(buffer, "Resampler FIFO: %d %s words\n\n", tmp,
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index cfcca4c30d4d..9ab1e631cb32 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -374,6 +374,8 @@ static void __mark_pages_wc(struct azx *chip, struct snd_dma_buffer *dmab, bool
374#ifdef CONFIG_SND_DMA_SGBUF 374#ifdef CONFIG_SND_DMA_SGBUF
375 if (dmab->dev.type == SNDRV_DMA_TYPE_DEV_SG) { 375 if (dmab->dev.type == SNDRV_DMA_TYPE_DEV_SG) {
376 struct snd_sg_buf *sgbuf = dmab->private_data; 376 struct snd_sg_buf *sgbuf = dmab->private_data;
377 if (chip->driver_type == AZX_DRIVER_CMEDIA)
378 return; /* deal with only CORB/RIRB buffers */
377 if (on) 379 if (on)
378 set_pages_array_wc(sgbuf->page_table, sgbuf->pages); 380 set_pages_array_wc(sgbuf->page_table, sgbuf->pages);
379 else 381 else
@@ -1769,7 +1771,7 @@ static void pcm_mmap_prepare(struct snd_pcm_substream *substream,
1769#ifdef CONFIG_X86 1771#ifdef CONFIG_X86
1770 struct azx_pcm *apcm = snd_pcm_substream_chip(substream); 1772 struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
1771 struct azx *chip = apcm->chip; 1773 struct azx *chip = apcm->chip;
1772 if (!azx_snoop(chip)) 1774 if (!azx_snoop(chip) && chip->driver_type != AZX_DRIVER_CMEDIA)
1773 area->vm_page_prot = pgprot_writecombine(area->vm_page_prot); 1775 area->vm_page_prot = pgprot_writecombine(area->vm_page_prot);
1774#endif 1776#endif
1775} 1777}
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 34b7bdb510c7..c9cf248ce8ec 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -2675,7 +2675,7 @@ static void alc269_shutup(struct hda_codec *codec)
2675 2675
2676static struct coef_fw alc282_coefs[] = { 2676static struct coef_fw alc282_coefs[] = {
2677 WRITE_COEF(0x03, 0x0002), /* Power Down Control */ 2677 WRITE_COEF(0x03, 0x0002), /* Power Down Control */
2678 WRITE_COEF(0x05, 0x0700), /* FIFO and filter clock */ 2678 UPDATE_COEF(0x05, 0xff3f, 0x0700), /* FIFO and filter clock */
2679 WRITE_COEF(0x07, 0x0200), /* DMIC control */ 2679 WRITE_COEF(0x07, 0x0200), /* DMIC control */
2680 UPDATE_COEF(0x06, 0x00f0, 0), /* Analog clock */ 2680 UPDATE_COEF(0x06, 0x00f0, 0), /* Analog clock */
2681 UPDATE_COEF(0x08, 0xfffc, 0x0c2c), /* JD */ 2681 UPDATE_COEF(0x08, 0xfffc, 0x0c2c), /* JD */
@@ -2786,7 +2786,7 @@ static void alc282_shutup(struct hda_codec *codec)
2786 2786
2787static struct coef_fw alc283_coefs[] = { 2787static struct coef_fw alc283_coefs[] = {
2788 WRITE_COEF(0x03, 0x0002), /* Power Down Control */ 2788 WRITE_COEF(0x03, 0x0002), /* Power Down Control */
2789 WRITE_COEF(0x05, 0x0700), /* FIFO and filter clock */ 2789 UPDATE_COEF(0x05, 0xff3f, 0x0700), /* FIFO and filter clock */
2790 WRITE_COEF(0x07, 0x0200), /* DMIC control */ 2790 WRITE_COEF(0x07, 0x0200), /* DMIC control */
2791 UPDATE_COEF(0x06, 0x00f0, 0), /* Analog clock */ 2791 UPDATE_COEF(0x06, 0x00f0, 0), /* Analog clock */
2792 UPDATE_COEF(0x08, 0xfffc, 0x0c2c), /* JD */ 2792 UPDATE_COEF(0x08, 0xfffc, 0x0c2c), /* JD */
@@ -2817,6 +2817,7 @@ static struct coef_fw alc283_coefs[] = {
2817 UPDATE_COEF(0x40, 0xf800, 0x9800), /* Class D DC enable */ 2817 UPDATE_COEF(0x40, 0xf800, 0x9800), /* Class D DC enable */
2818 UPDATE_COEF(0x42, 0xf000, 0x2000), /* DC offset */ 2818 UPDATE_COEF(0x42, 0xf000, 0x2000), /* DC offset */
2819 WRITE_COEF(0x37, 0xfc06), /* Class D amp control */ 2819 WRITE_COEF(0x37, 0xfc06), /* Class D amp control */
2820 UPDATE_COEF(0x1b, 0x8000, 0), /* HP JD control */
2820 {} 2821 {}
2821}; 2822};
2822 2823
@@ -5922,6 +5923,7 @@ static const struct snd_pci_quirk alc662_fixup_tbl[] = {
5922 SND_PCI_QUIRK(0x1028, 0x0626, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE), 5923 SND_PCI_QUIRK(0x1028, 0x0626, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
5923 SND_PCI_QUIRK(0x1028, 0x0696, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE), 5924 SND_PCI_QUIRK(0x1028, 0x0696, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
5924 SND_PCI_QUIRK(0x1028, 0x0698, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE), 5925 SND_PCI_QUIRK(0x1028, 0x0698, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
5926 SND_PCI_QUIRK(0x1028, 0x069f, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
5925 SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800), 5927 SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800),
5926 SND_PCI_QUIRK(0x1043, 0x11cd, "Asus N550", ALC662_FIXUP_BASS_1A), 5928 SND_PCI_QUIRK(0x1043, 0x11cd, "Asus N550", ALC662_FIXUP_BASS_1A),
5927 SND_PCI_QUIRK(0x1043, 0x1477, "ASUS N56VZ", ALC662_FIXUP_BASS_MODE4_CHMAP), 5929 SND_PCI_QUIRK(0x1043, 0x1477, "ASUS N56VZ", ALC662_FIXUP_BASS_MODE4_CHMAP),
diff --git a/sound/soc/Kconfig b/sound/soc/Kconfig
index 0e9623368ab0..7d5d6444a837 100644
--- a/sound/soc/Kconfig
+++ b/sound/soc/Kconfig
@@ -49,7 +49,6 @@ source "sound/soc/mxs/Kconfig"
49source "sound/soc/pxa/Kconfig" 49source "sound/soc/pxa/Kconfig"
50source "sound/soc/rockchip/Kconfig" 50source "sound/soc/rockchip/Kconfig"
51source "sound/soc/samsung/Kconfig" 51source "sound/soc/samsung/Kconfig"
52source "sound/soc/s6000/Kconfig"
53source "sound/soc/sh/Kconfig" 52source "sound/soc/sh/Kconfig"
54source "sound/soc/sirf/Kconfig" 53source "sound/soc/sirf/Kconfig"
55source "sound/soc/spear/Kconfig" 54source "sound/soc/spear/Kconfig"
diff --git a/sound/soc/Makefile b/sound/soc/Makefile
index 534714a1ca44..d88edfced8c4 100644
--- a/sound/soc/Makefile
+++ b/sound/soc/Makefile
@@ -26,7 +26,6 @@ obj-$(CONFIG_SND_SOC) += kirkwood/
26obj-$(CONFIG_SND_SOC) += pxa/ 26obj-$(CONFIG_SND_SOC) += pxa/
27obj-$(CONFIG_SND_SOC) += rockchip/ 27obj-$(CONFIG_SND_SOC) += rockchip/
28obj-$(CONFIG_SND_SOC) += samsung/ 28obj-$(CONFIG_SND_SOC) += samsung/
29obj-$(CONFIG_SND_SOC) += s6000/
30obj-$(CONFIG_SND_SOC) += sh/ 29obj-$(CONFIG_SND_SOC) += sh/
31obj-$(CONFIG_SND_SOC) += sirf/ 30obj-$(CONFIG_SND_SOC) += sirf/
32obj-$(CONFIG_SND_SOC) += spear/ 31obj-$(CONFIG_SND_SOC) += spear/
diff --git a/sound/soc/codecs/adau1761.c b/sound/soc/codecs/adau1761.c
index 5518ebd6947c..91f60282fd2f 100644
--- a/sound/soc/codecs/adau1761.c
+++ b/sound/soc/codecs/adau1761.c
@@ -405,6 +405,7 @@ static const struct snd_soc_dapm_widget adau1761_dapm_widgets[] = {
405 2, 0, NULL, 0), 405 2, 0, NULL, 0),
406 406
407 SND_SOC_DAPM_SUPPLY("Slew Clock", ADAU1761_CLK_ENABLE0, 6, 0, NULL, 0), 407 SND_SOC_DAPM_SUPPLY("Slew Clock", ADAU1761_CLK_ENABLE0, 6, 0, NULL, 0),
408 SND_SOC_DAPM_SUPPLY("ALC Clock", ADAU1761_CLK_ENABLE0, 5, 0, NULL, 0),
408 409
409 SND_SOC_DAPM_SUPPLY_S("Digital Clock 0", 1, ADAU1761_CLK_ENABLE1, 410 SND_SOC_DAPM_SUPPLY_S("Digital Clock 0", 1, ADAU1761_CLK_ENABLE1,
410 0, 0, NULL, 0), 411 0, 0, NULL, 0),
@@ -436,6 +437,9 @@ static const struct snd_soc_dapm_route adau1761_dapm_routes[] = {
436 { "Right Playback Mixer", NULL, "Slew Clock" }, 437 { "Right Playback Mixer", NULL, "Slew Clock" },
437 { "Left Playback Mixer", NULL, "Slew Clock" }, 438 { "Left Playback Mixer", NULL, "Slew Clock" },
438 439
440 { "Left Input Mixer", NULL, "ALC Clock" },
441 { "Right Input Mixer", NULL, "ALC Clock" },
442
439 { "Digital Clock 0", NULL, "SYSCLK" }, 443 { "Digital Clock 0", NULL, "SYSCLK" },
440 { "Digital Clock 1", NULL, "SYSCLK" }, 444 { "Digital Clock 1", NULL, "SYSCLK" },
441}; 445};
diff --git a/sound/soc/fsl/fsl_asrc.c b/sound/soc/fsl/fsl_asrc.c
index 3b145313f93e..ed866e9a2928 100644
--- a/sound/soc/fsl/fsl_asrc.c
+++ b/sound/soc/fsl/fsl_asrc.c
@@ -792,7 +792,7 @@ static int fsl_asrc_probe(struct platform_device *pdev)
792 return -ENOMEM; 792 return -ENOMEM;
793 793
794 asrc_priv->pdev = pdev; 794 asrc_priv->pdev = pdev;
795 strcpy(asrc_priv->name, np->name); 795 strncpy(asrc_priv->name, np->name, sizeof(asrc_priv->name) - 1);
796 796
797 /* Get the addresses and IRQ */ 797 /* Get the addresses and IRQ */
798 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 798 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
diff --git a/sound/soc/fsl/fsl_esai.c b/sound/soc/fsl/fsl_esai.c
index 8bcdfda09d7a..a645e296199e 100644
--- a/sound/soc/fsl/fsl_esai.c
+++ b/sound/soc/fsl/fsl_esai.c
@@ -734,7 +734,7 @@ static int fsl_esai_probe(struct platform_device *pdev)
734 return -ENOMEM; 734 return -ENOMEM;
735 735
736 esai_priv->pdev = pdev; 736 esai_priv->pdev = pdev;
737 strcpy(esai_priv->name, np->name); 737 strncpy(esai_priv->name, np->name, sizeof(esai_priv->name) - 1);
738 738
739 /* Get the addresses and IRQ */ 739 /* Get the addresses and IRQ */
740 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 740 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
diff --git a/sound/soc/intel/sst-haswell-pcm.c b/sound/soc/intel/sst-haswell-pcm.c
index 33fc5c3abf55..4df867cbb92a 100644
--- a/sound/soc/intel/sst-haswell-pcm.c
+++ b/sound/soc/intel/sst-haswell-pcm.c
@@ -691,9 +691,7 @@ static int hsw_pcm_new(struct snd_soc_pcm_runtime *rtd)
691} 691}
692 692
693#define HSW_FORMATS \ 693#define HSW_FORMATS \
694 (SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S24_LE | \ 694 (SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S16_LE)
695 SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_S16_LE |\
696 SNDRV_PCM_FMTBIT_S8)
697 695
698static struct snd_soc_dai_driver hsw_dais[] = { 696static struct snd_soc_dai_driver hsw_dais[] = {
699 { 697 {
diff --git a/sound/soc/s6000/Kconfig b/sound/soc/s6000/Kconfig
deleted file mode 100644
index f244a2566f20..000000000000
--- a/sound/soc/s6000/Kconfig
+++ /dev/null
@@ -1,26 +0,0 @@
1config SND_S6000_SOC
2 tristate "SoC Audio for the Stretch s6000 family"
3 depends on XTENSA_VARIANT_S6000 || COMPILE_TEST
4 depends on HAS_IOMEM
5 select SND_S6000_SOC_PCM if XTENSA_VARIANT_S6000
6 help
7 Say Y or M if you want to add support for codecs attached to
8 s6000 family chips. You will also need to select the platform
9 to support below.
10
11config SND_S6000_SOC_PCM
12 tristate
13
14config SND_S6000_SOC_I2S
15 tristate
16
17config SND_S6000_SOC_S6IPCAM
18 bool "SoC Audio support for Stretch 6105 IP Camera"
19 depends on SND_S6000_SOC=y
20 depends on I2C=y
21 depends on XTENSA_PLATFORM_S6105 || COMPILE_TEST
22 select SND_S6000_SOC_I2S
23 select SND_SOC_TLV320AIC3X
24 help
25 Say Y if you want to add support for SoC audio on the
26 Stretch s6105 IP Camera Reference Design.
diff --git a/sound/soc/s6000/Makefile b/sound/soc/s6000/Makefile
deleted file mode 100644
index 0f0ae2a012aa..000000000000
--- a/sound/soc/s6000/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
1# s6000 Platform Support
2snd-soc-s6000-objs := s6000-pcm.o
3snd-soc-s6000-i2s-objs := s6000-i2s.o
4
5obj-$(CONFIG_SND_S6000_SOC_PCM) += snd-soc-s6000.o
6obj-$(CONFIG_SND_S6000_SOC_I2S) += snd-soc-s6000-i2s.o
7
8# s6105 Machine Support
9snd-soc-s6ipcam-objs := s6105-ipcam.o
10
11obj-$(CONFIG_SND_S6000_SOC_S6IPCAM) += snd-soc-s6ipcam.o
diff --git a/sound/soc/s6000/s6000-i2s.c b/sound/soc/s6000/s6000-i2s.c
deleted file mode 100644
index 1c8d01166e5b..000000000000
--- a/sound/soc/s6000/s6000-i2s.c
+++ /dev/null
@@ -1,617 +0,0 @@
1/*
2 * ALSA SoC I2S Audio Layer for the Stretch S6000 family
3 *
4 * Author: Daniel Gloeckner, <dg@emlix.com>
5 * Copyright: (C) 2009 emlix GmbH <info@emlix.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12#include <linux/init.h>
13#include <linux/module.h>
14#include <linux/device.h>
15#include <linux/delay.h>
16#include <linux/clk.h>
17#include <linux/interrupt.h>
18#include <linux/io.h>
19#include <linux/slab.h>
20
21#include <sound/core.h>
22#include <sound/pcm.h>
23#include <sound/pcm_params.h>
24#include <sound/initval.h>
25#include <sound/soc.h>
26
27#include "s6000-i2s.h"
28#include "s6000-pcm.h"
29
30struct s6000_i2s_dev {
31 dma_addr_t sifbase;
32 u8 __iomem *scbbase;
33 unsigned int wide;
34 unsigned int channel_in;
35 unsigned int channel_out;
36 unsigned int lines_in;
37 unsigned int lines_out;
38 struct s6000_pcm_dma_params dma_params;
39};
40
41#define S6_I2S_INTERRUPT_STATUS 0x00
42#define S6_I2S_INT_OVERRUN 1
43#define S6_I2S_INT_UNDERRUN 2
44#define S6_I2S_INT_ALIGNMENT 4
45#define S6_I2S_INTERRUPT_ENABLE 0x04
46#define S6_I2S_INTERRUPT_RAW 0x08
47#define S6_I2S_INTERRUPT_CLEAR 0x0C
48#define S6_I2S_INTERRUPT_SET 0x10
49#define S6_I2S_MODE 0x20
50#define S6_I2S_DUAL 0
51#define S6_I2S_WIDE 1
52#define S6_I2S_TX_DEFAULT 0x24
53#define S6_I2S_DATA_CFG(c) (0x40 + 0x10 * (c))
54#define S6_I2S_IN 0
55#define S6_I2S_OUT 1
56#define S6_I2S_UNUSED 2
57#define S6_I2S_INTERFACE_CFG(c) (0x44 + 0x10 * (c))
58#define S6_I2S_DIV_MASK 0x001fff
59#define S6_I2S_16BIT 0x000000
60#define S6_I2S_20BIT 0x002000
61#define S6_I2S_24BIT 0x004000
62#define S6_I2S_32BIT 0x006000
63#define S6_I2S_BITS_MASK 0x006000
64#define S6_I2S_MEM_16BIT 0x000000
65#define S6_I2S_MEM_32BIT 0x008000
66#define S6_I2S_MEM_MASK 0x008000
67#define S6_I2S_CHANNELS_SHIFT 16
68#define S6_I2S_CHANNELS_MASK 0x030000
69#define S6_I2S_SCK_IN 0x000000
70#define S6_I2S_SCK_OUT 0x040000
71#define S6_I2S_SCK_DIR 0x040000
72#define S6_I2S_WS_IN 0x000000
73#define S6_I2S_WS_OUT 0x080000
74#define S6_I2S_WS_DIR 0x080000
75#define S6_I2S_LEFT_FIRST 0x000000
76#define S6_I2S_RIGHT_FIRST 0x100000
77#define S6_I2S_FIRST 0x100000
78#define S6_I2S_CUR_SCK 0x200000
79#define S6_I2S_CUR_WS 0x400000
80#define S6_I2S_ENABLE(c) (0x48 + 0x10 * (c))
81#define S6_I2S_DISABLE_IF 0x02
82#define S6_I2S_ENABLE_IF 0x03
83#define S6_I2S_IS_BUSY 0x04
84#define S6_I2S_DMA_ACTIVE 0x08
85#define S6_I2S_IS_ENABLED 0x10
86
87#define S6_I2S_NUM_LINES 4
88
89#define S6_I2S_SIF_PORT0 0x0000000
90#define S6_I2S_SIF_PORT1 0x0000080 /* docs say 0x0000010 */
91
92static inline void s6_i2s_write_reg(struct s6000_i2s_dev *dev, int reg, u32 val)
93{
94 writel(val, dev->scbbase + reg);
95}
96
97static inline u32 s6_i2s_read_reg(struct s6000_i2s_dev *dev, int reg)
98{
99 return readl(dev->scbbase + reg);
100}
101
102static inline void s6_i2s_mod_reg(struct s6000_i2s_dev *dev, int reg,
103 u32 mask, u32 val)
104{
105 val ^= s6_i2s_read_reg(dev, reg) & ~mask;
106 s6_i2s_write_reg(dev, reg, val);
107}
108
109static void s6000_i2s_start_channel(struct s6000_i2s_dev *dev, int channel)
110{
111 int i, j, cur, prev;
112
113 /*
114 * Wait for WCLK to toggle 5 times before enabling the channel
115 * s6000 Family Datasheet 3.6.4:
116 * "At least two cycles of WS must occur between commands
117 * to disable or enable the interface"
118 */
119 j = 0;
120 prev = ~S6_I2S_CUR_WS;
121 for (i = 1000000; --i && j < 6; ) {
122 cur = s6_i2s_read_reg(dev, S6_I2S_INTERFACE_CFG(channel))
123 & S6_I2S_CUR_WS;
124 if (prev != cur) {
125 prev = cur;
126 j++;
127 }
128 }
129 if (j < 6)
130 printk(KERN_WARNING "s6000-i2s: timeout waiting for WCLK\n");
131
132 s6_i2s_write_reg(dev, S6_I2S_ENABLE(channel), S6_I2S_ENABLE_IF);
133}
134
135static void s6000_i2s_stop_channel(struct s6000_i2s_dev *dev, int channel)
136{
137 s6_i2s_write_reg(dev, S6_I2S_ENABLE(channel), S6_I2S_DISABLE_IF);
138}
139
140static void s6000_i2s_start(struct snd_pcm_substream *substream)
141{
142 struct snd_soc_pcm_runtime *rtd = substream->private_data;
143 struct s6000_i2s_dev *dev = snd_soc_dai_get_drvdata(rtd->cpu_dai);
144 int channel;
145
146 channel = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ?
147 dev->channel_out : dev->channel_in;
148
149 s6000_i2s_start_channel(dev, channel);
150}
151
152static void s6000_i2s_stop(struct snd_pcm_substream *substream)
153{
154 struct snd_soc_pcm_runtime *rtd = substream->private_data;
155 struct s6000_i2s_dev *dev = snd_soc_dai_get_drvdata(rtd->cpu_dai);
156 int channel;
157
158 channel = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ?
159 dev->channel_out : dev->channel_in;
160
161 s6000_i2s_stop_channel(dev, channel);
162}
163
164static int s6000_i2s_trigger(struct snd_pcm_substream *substream, int cmd,
165 int after)
166{
167 switch (cmd) {
168 case SNDRV_PCM_TRIGGER_START:
169 case SNDRV_PCM_TRIGGER_RESUME:
170 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
171 if ((substream->stream == SNDRV_PCM_STREAM_CAPTURE) ^ !after)
172 s6000_i2s_start(substream);
173 break;
174 case SNDRV_PCM_TRIGGER_STOP:
175 case SNDRV_PCM_TRIGGER_SUSPEND:
176 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
177 if (!after)
178 s6000_i2s_stop(substream);
179 }
180 return 0;
181}
182
183static unsigned int s6000_i2s_int_sources(struct s6000_i2s_dev *dev)
184{
185 unsigned int pending;
186 pending = s6_i2s_read_reg(dev, S6_I2S_INTERRUPT_RAW);
187 pending &= S6_I2S_INT_ALIGNMENT |
188 S6_I2S_INT_UNDERRUN |
189 S6_I2S_INT_OVERRUN;
190 s6_i2s_write_reg(dev, S6_I2S_INTERRUPT_CLEAR, pending);
191
192 return pending;
193}
194
195static unsigned int s6000_i2s_check_xrun(struct snd_soc_dai *cpu_dai)
196{
197 struct s6000_i2s_dev *dev = snd_soc_dai_get_drvdata(cpu_dai);
198 unsigned int errors;
199 unsigned int ret;
200
201 errors = s6000_i2s_int_sources(dev);
202 if (likely(!errors))
203 return 0;
204
205 ret = 0;
206 if (errors & S6_I2S_INT_ALIGNMENT)
207 printk(KERN_ERR "s6000-i2s: WCLK misaligned\n");
208 if (errors & S6_I2S_INT_UNDERRUN)
209 ret |= 1 << SNDRV_PCM_STREAM_PLAYBACK;
210 if (errors & S6_I2S_INT_OVERRUN)
211 ret |= 1 << SNDRV_PCM_STREAM_CAPTURE;
212 return ret;
213}
214
215static void s6000_i2s_wait_disabled(struct s6000_i2s_dev *dev)
216{
217 int channel;
218 int n = 50;
219 for (channel = 0; channel < 2; channel++) {
220 while (--n >= 0) {
221 int v = s6_i2s_read_reg(dev, S6_I2S_ENABLE(channel));
222 if ((v & S6_I2S_IS_ENABLED)
223 || !(v & (S6_I2S_DMA_ACTIVE | S6_I2S_IS_BUSY)))
224 break;
225 udelay(20);
226 }
227 }
228 if (n < 0)
229 printk(KERN_WARNING "s6000-i2s: timeout disabling interfaces");
230}
231
232static int s6000_i2s_set_dai_fmt(struct snd_soc_dai *cpu_dai,
233 unsigned int fmt)
234{
235 struct s6000_i2s_dev *dev = snd_soc_dai_get_drvdata(cpu_dai);
236 u32 w;
237
238 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
239 case SND_SOC_DAIFMT_CBM_CFM:
240 w = S6_I2S_SCK_IN | S6_I2S_WS_IN;
241 break;
242 case SND_SOC_DAIFMT_CBS_CFM:
243 w = S6_I2S_SCK_OUT | S6_I2S_WS_IN;
244 break;
245 case SND_SOC_DAIFMT_CBM_CFS:
246 w = S6_I2S_SCK_IN | S6_I2S_WS_OUT;
247 break;
248 case SND_SOC_DAIFMT_CBS_CFS:
249 w = S6_I2S_SCK_OUT | S6_I2S_WS_OUT;
250 break;
251 default:
252 return -EINVAL;
253 }
254
255 switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
256 case SND_SOC_DAIFMT_NB_NF:
257 w |= S6_I2S_LEFT_FIRST;
258 break;
259 case SND_SOC_DAIFMT_NB_IF:
260 w |= S6_I2S_RIGHT_FIRST;
261 break;
262 default:
263 return -EINVAL;
264 }
265
266 s6_i2s_mod_reg(dev, S6_I2S_INTERFACE_CFG(0),
267 S6_I2S_FIRST | S6_I2S_WS_DIR | S6_I2S_SCK_DIR, w);
268 s6_i2s_mod_reg(dev, S6_I2S_INTERFACE_CFG(1),
269 S6_I2S_FIRST | S6_I2S_WS_DIR | S6_I2S_SCK_DIR, w);
270
271 return 0;
272}
273
274static int s6000_i2s_set_clkdiv(struct snd_soc_dai *dai, int div_id, int div)
275{
276 struct s6000_i2s_dev *dev = snd_soc_dai_get_drvdata(dai);
277
278 if (!div || (div & 1) || div > (S6_I2S_DIV_MASK + 1) * 2)
279 return -EINVAL;
280
281 s6_i2s_mod_reg(dev, S6_I2S_INTERFACE_CFG(div_id),
282 S6_I2S_DIV_MASK, div / 2 - 1);
283 return 0;
284}
285
286static int s6000_i2s_hw_params(struct snd_pcm_substream *substream,
287 struct snd_pcm_hw_params *params,
288 struct snd_soc_dai *dai)
289{
290 struct s6000_i2s_dev *dev = snd_soc_dai_get_drvdata(dai);
291 int interf;
292 u32 w = 0;
293
294 if (dev->wide)
295 interf = 0;
296 else {
297 w |= (((params_channels(params) - 2) / 2)
298 << S6_I2S_CHANNELS_SHIFT) & S6_I2S_CHANNELS_MASK;
299 interf = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
300 ? dev->channel_out : dev->channel_in;
301 }
302
303 switch (params_format(params)) {
304 case SNDRV_PCM_FORMAT_S16_LE:
305 w |= S6_I2S_16BIT | S6_I2S_MEM_16BIT;
306 break;
307 case SNDRV_PCM_FORMAT_S32_LE:
308 w |= S6_I2S_32BIT | S6_I2S_MEM_32BIT;
309 break;
310 default:
311 printk(KERN_WARNING "s6000-i2s: unsupported PCM format %x\n",
312 params_format(params));
313 return -EINVAL;
314 }
315
316 if (s6_i2s_read_reg(dev, S6_I2S_INTERFACE_CFG(interf))
317 & S6_I2S_IS_ENABLED) {
318 printk(KERN_ERR "s6000-i2s: interface already enabled\n");
319 return -EBUSY;
320 }
321
322 s6_i2s_mod_reg(dev, S6_I2S_INTERFACE_CFG(interf),
323 S6_I2S_CHANNELS_MASK|S6_I2S_MEM_MASK|S6_I2S_BITS_MASK,
324 w);
325
326 return 0;
327}
328
329static int s6000_i2s_dai_probe(struct snd_soc_dai *dai)
330{
331 struct s6000_i2s_dev *dev = snd_soc_dai_get_drvdata(dai);
332 struct s6000_snd_platform_data *pdata = dai->dev->platform_data;
333
334 if (!pdata)
335 return -EINVAL;
336
337 dai->capture_dma_data = &dev->dma_params;
338 dai->playback_dma_data = &dev->dma_params;
339
340 dev->wide = pdata->wide;
341 dev->channel_in = pdata->channel_in;
342 dev->channel_out = pdata->channel_out;
343 dev->lines_in = pdata->lines_in;
344 dev->lines_out = pdata->lines_out;
345
346 s6_i2s_write_reg(dev, S6_I2S_MODE,
347 dev->wide ? S6_I2S_WIDE : S6_I2S_DUAL);
348
349 if (dev->wide) {
350 int i;
351
352 if (dev->lines_in + dev->lines_out > S6_I2S_NUM_LINES)
353 return -EINVAL;
354
355 dev->channel_in = 0;
356 dev->channel_out = 1;
357 dai->driver->capture.channels_min = 2 * dev->lines_in;
358 dai->driver->capture.channels_max = dai->driver->capture.channels_min;
359 dai->driver->playback.channels_min = 2 * dev->lines_out;
360 dai->driver->playback.channels_max = dai->driver->playback.channels_min;
361
362 for (i = 0; i < dev->lines_out; i++)
363 s6_i2s_write_reg(dev, S6_I2S_DATA_CFG(i), S6_I2S_OUT);
364
365 for (; i < S6_I2S_NUM_LINES - dev->lines_in; i++)
366 s6_i2s_write_reg(dev, S6_I2S_DATA_CFG(i),
367 S6_I2S_UNUSED);
368
369 for (; i < S6_I2S_NUM_LINES; i++)
370 s6_i2s_write_reg(dev, S6_I2S_DATA_CFG(i), S6_I2S_IN);
371 } else {
372 unsigned int cfg[2] = {S6_I2S_UNUSED, S6_I2S_UNUSED};
373
374 if (dev->lines_in > 1 || dev->lines_out > 1)
375 return -EINVAL;
376
377 dai->driver->capture.channels_min = 2 * dev->lines_in;
378 dai->driver->capture.channels_max = 8 * dev->lines_in;
379 dai->driver->playback.channels_min = 2 * dev->lines_out;
380 dai->driver->playback.channels_max = 8 * dev->lines_out;
381
382 if (dev->lines_in)
383 cfg[dev->channel_in] = S6_I2S_IN;
384 if (dev->lines_out)
385 cfg[dev->channel_out] = S6_I2S_OUT;
386
387 s6_i2s_write_reg(dev, S6_I2S_DATA_CFG(0), cfg[0]);
388 s6_i2s_write_reg(dev, S6_I2S_DATA_CFG(1), cfg[1]);
389 }
390
391 if (dev->lines_out) {
392 if (dev->lines_in) {
393 if (!dev->dma_params.dma_out)
394 return -ENODEV;
395 } else {
396 dev->dma_params.dma_out = dev->dma_params.dma_in;
397 dev->dma_params.dma_in = 0;
398 }
399 }
400 dev->dma_params.sif_in = dev->sifbase + (dev->channel_in ?
401 S6_I2S_SIF_PORT1 : S6_I2S_SIF_PORT0);
402 dev->dma_params.sif_out = dev->sifbase + (dev->channel_out ?
403 S6_I2S_SIF_PORT1 : S6_I2S_SIF_PORT0);
404 dev->dma_params.same_rate = pdata->same_rate | pdata->wide;
405 return 0;
406}
407
408#define S6000_I2S_RATES SNDRV_PCM_RATE_CONTINUOUS
409#define S6000_I2S_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE)
410
411static const struct snd_soc_dai_ops s6000_i2s_dai_ops = {
412 .set_fmt = s6000_i2s_set_dai_fmt,
413 .set_clkdiv = s6000_i2s_set_clkdiv,
414 .hw_params = s6000_i2s_hw_params,
415};
416
417static struct snd_soc_dai_driver s6000_i2s_dai = {
418 .probe = s6000_i2s_dai_probe,
419 .playback = {
420 .channels_min = 2,
421 .channels_max = 8,
422 .formats = S6000_I2S_FORMATS,
423 .rates = S6000_I2S_RATES,
424 .rate_min = 0,
425 .rate_max = 1562500,
426 },
427 .capture = {
428 .channels_min = 2,
429 .channels_max = 8,
430 .formats = S6000_I2S_FORMATS,
431 .rates = S6000_I2S_RATES,
432 .rate_min = 0,
433 .rate_max = 1562500,
434 },
435 .ops = &s6000_i2s_dai_ops,
436};
437
438static const struct snd_soc_component_driver s6000_i2s_component = {
439 .name = "s6000-i2s",
440};
441
442static int s6000_i2s_probe(struct platform_device *pdev)
443{
444 struct s6000_i2s_dev *dev;
445 struct resource *scbmem, *sifmem, *region, *dma1, *dma2;
446 u8 __iomem *mmio;
447 int ret;
448
449 scbmem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
450 if (!scbmem) {
451 dev_err(&pdev->dev, "no mem resource?\n");
452 ret = -ENODEV;
453 goto err_release_none;
454 }
455
456 region = request_mem_region(scbmem->start, resource_size(scbmem),
457 pdev->name);
458 if (!region) {
459 dev_err(&pdev->dev, "I2S SCB region already claimed\n");
460 ret = -EBUSY;
461 goto err_release_none;
462 }
463
464 mmio = ioremap(scbmem->start, resource_size(scbmem));
465 if (!mmio) {
466 dev_err(&pdev->dev, "can't ioremap SCB region\n");
467 ret = -ENOMEM;
468 goto err_release_scb;
469 }
470
471 sifmem = platform_get_resource(pdev, IORESOURCE_MEM, 1);
472 if (!sifmem) {
473 dev_err(&pdev->dev, "no second mem resource?\n");
474 ret = -ENODEV;
475 goto err_release_map;
476 }
477
478 region = request_mem_region(sifmem->start, resource_size(sifmem),
479 pdev->name);
480 if (!region) {
481 dev_err(&pdev->dev, "I2S SIF region already claimed\n");
482 ret = -EBUSY;
483 goto err_release_map;
484 }
485
486 dma1 = platform_get_resource(pdev, IORESOURCE_DMA, 0);
487 if (!dma1) {
488 dev_err(&pdev->dev, "no dma resource?\n");
489 ret = -ENODEV;
490 goto err_release_sif;
491 }
492
493 region = request_mem_region(dma1->start, resource_size(dma1),
494 pdev->name);
495 if (!region) {
496 dev_err(&pdev->dev, "I2S DMA region already claimed\n");
497 ret = -EBUSY;
498 goto err_release_sif;
499 }
500
501 dma2 = platform_get_resource(pdev, IORESOURCE_DMA, 1);
502 if (dma2) {
503 region = request_mem_region(dma2->start, resource_size(dma2),
504 pdev->name);
505 if (!region) {
506 dev_err(&pdev->dev,
507 "I2S DMA region already claimed\n");
508 ret = -EBUSY;
509 goto err_release_dma1;
510 }
511 }
512
513 dev = kzalloc(sizeof(struct s6000_i2s_dev), GFP_KERNEL);
514 if (!dev) {
515 ret = -ENOMEM;
516 goto err_release_dma2;
517 }
518 dev_set_drvdata(&pdev->dev, dev);
519
520 dev->sifbase = sifmem->start;
521 dev->scbbase = mmio;
522
523 s6_i2s_write_reg(dev, S6_I2S_INTERRUPT_ENABLE, 0);
524 s6_i2s_write_reg(dev, S6_I2S_INTERRUPT_CLEAR,
525 S6_I2S_INT_ALIGNMENT |
526 S6_I2S_INT_UNDERRUN |
527 S6_I2S_INT_OVERRUN);
528
529 s6000_i2s_stop_channel(dev, 0);
530 s6000_i2s_stop_channel(dev, 1);
531 s6000_i2s_wait_disabled(dev);
532
533 dev->dma_params.check_xrun = s6000_i2s_check_xrun;
534 dev->dma_params.trigger = s6000_i2s_trigger;
535 dev->dma_params.dma_in = dma1->start;
536 dev->dma_params.dma_out = dma2 ? dma2->start : 0;
537 dev->dma_params.irq = platform_get_irq(pdev, 0);
538 if (dev->dma_params.irq < 0) {
539 dev_err(&pdev->dev, "no irq resource?\n");
540 ret = -ENODEV;
541 goto err_release_dev;
542 }
543
544 s6_i2s_write_reg(dev, S6_I2S_INTERRUPT_ENABLE,
545 S6_I2S_INT_ALIGNMENT |
546 S6_I2S_INT_UNDERRUN |
547 S6_I2S_INT_OVERRUN);
548
549 ret = snd_soc_register_component(&pdev->dev, &s6000_i2s_component,
550 &s6000_i2s_dai, 1);
551 if (ret)
552 goto err_release_dev;
553
554 return 0;
555
556err_release_dev:
557 kfree(dev);
558err_release_dma2:
559 if (dma2)
560 release_mem_region(dma2->start, resource_size(dma2));
561err_release_dma1:
562 release_mem_region(dma1->start, resource_size(dma1));
563err_release_sif:
564 release_mem_region(sifmem->start, resource_size(sifmem));
565err_release_map:
566 iounmap(mmio);
567err_release_scb:
568 release_mem_region(scbmem->start, resource_size(scbmem));
569err_release_none:
570 return ret;
571}
572
573static int s6000_i2s_remove(struct platform_device *pdev)
574{
575 struct s6000_i2s_dev *dev = dev_get_drvdata(&pdev->dev);
576 struct resource *region;
577 void __iomem *mmio = dev->scbbase;
578
579 snd_soc_unregister_component(&pdev->dev);
580
581 s6000_i2s_stop_channel(dev, 0);
582 s6000_i2s_stop_channel(dev, 1);
583
584 s6_i2s_write_reg(dev, S6_I2S_INTERRUPT_ENABLE, 0);
585 kfree(dev);
586
587 region = platform_get_resource(pdev, IORESOURCE_DMA, 0);
588 release_mem_region(region->start, resource_size(region));
589
590 region = platform_get_resource(pdev, IORESOURCE_DMA, 1);
591 if (region)
592 release_mem_region(region->start, resource_size(region));
593
594 region = platform_get_resource(pdev, IORESOURCE_MEM, 0);
595 release_mem_region(region->start, resource_size(region));
596
597 iounmap(mmio);
598 region = platform_get_resource(pdev, IORESOURCE_IO, 0);
599 release_mem_region(region->start, resource_size(region));
600
601 return 0;
602}
603
604static struct platform_driver s6000_i2s_driver = {
605 .probe = s6000_i2s_probe,
606 .remove = s6000_i2s_remove,
607 .driver = {
608 .name = "s6000-i2s",
609 .owner = THIS_MODULE,
610 },
611};
612
613module_platform_driver(s6000_i2s_driver);
614
615MODULE_AUTHOR("Daniel Gloeckner");
616MODULE_DESCRIPTION("Stretch s6000 family I2S SoC Interface");
617MODULE_LICENSE("GPL");
diff --git a/sound/soc/s6000/s6000-i2s.h b/sound/soc/s6000/s6000-i2s.h
deleted file mode 100644
index 86aa1921c89e..000000000000
--- a/sound/soc/s6000/s6000-i2s.h
+++ /dev/null
@@ -1,23 +0,0 @@
1/*
2 * ALSA SoC I2S Audio Layer for the Stretch s6000 family
3 *
4 * Author: Daniel Gloeckner, <dg@emlix.com>
5 * Copyright: (C) 2009 emlix GmbH <info@emlix.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12#ifndef _S6000_I2S_H
13#define _S6000_I2S_H
14
15struct s6000_snd_platform_data {
16 int lines_in;
17 int lines_out;
18 int channel_in;
19 int channel_out;
20 int wide;
21 int same_rate;
22};
23#endif
diff --git a/sound/soc/s6000/s6000-pcm.c b/sound/soc/s6000/s6000-pcm.c
deleted file mode 100644
index fb8461e1b1f6..000000000000
--- a/sound/soc/s6000/s6000-pcm.c
+++ /dev/null
@@ -1,521 +0,0 @@
1/*
2 * ALSA PCM interface for the Stetch s6000 family
3 *
4 * Author: Daniel Gloeckner, <dg@emlix.com>
5 * Copyright: (C) 2009 emlix GmbH <info@emlix.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12#include <linux/module.h>
13#include <linux/init.h>
14#include <linux/platform_device.h>
15#include <linux/slab.h>
16#include <linux/dma-mapping.h>
17#include <linux/interrupt.h>
18
19#include <sound/core.h>
20#include <sound/pcm.h>
21#include <sound/pcm_params.h>
22#include <sound/soc.h>
23
24#include <asm/dma.h>
25#include <variant/dmac.h>
26
27#include "s6000-pcm.h"
28
29#define S6_PCM_PREALLOCATE_SIZE (96 * 1024)
30#define S6_PCM_PREALLOCATE_MAX (2048 * 1024)
31
32static struct snd_pcm_hardware s6000_pcm_hardware = {
33 .info = (SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER |
34 SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID |
35 SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_JOINT_DUPLEX),
36 .buffer_bytes_max = 0x7ffffff0,
37 .period_bytes_min = 16,
38 .period_bytes_max = 0xfffff0,
39 .periods_min = 2,
40 .periods_max = 1024, /* no limit */
41 .fifo_size = 0,
42};
43
44struct s6000_runtime_data {
45 spinlock_t lock;
46 int period; /* current DMA period */
47};
48
49static void s6000_pcm_enqueue_dma(struct snd_pcm_substream *substream)
50{
51 struct snd_pcm_runtime *runtime = substream->runtime;
52 struct s6000_runtime_data *prtd = runtime->private_data;
53 struct snd_soc_pcm_runtime *soc_runtime = substream->private_data;
54 struct s6000_pcm_dma_params *par;
55 int channel;
56 unsigned int period_size;
57 unsigned int dma_offset;
58 dma_addr_t dma_pos;
59 dma_addr_t src, dst;
60
61 par = snd_soc_dai_get_dma_data(soc_runtime->cpu_dai, substream);
62
63 period_size = snd_pcm_lib_period_bytes(substream);
64 dma_offset = prtd->period * period_size;
65 dma_pos = runtime->dma_addr + dma_offset;
66
67 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
68 src = dma_pos;
69 dst = par->sif_out;
70 channel = par->dma_out;
71 } else {
72 src = par->sif_in;
73 dst = dma_pos;
74 channel = par->dma_in;
75 }
76
77 if (!s6dmac_channel_enabled(DMA_MASK_DMAC(channel),
78 DMA_INDEX_CHNL(channel)))
79 return;
80
81 if (s6dmac_fifo_full(DMA_MASK_DMAC(channel), DMA_INDEX_CHNL(channel))) {
82 printk(KERN_ERR "s6000-pcm: fifo full\n");
83 return;
84 }
85
86 if (WARN_ON(period_size & 15))
87 return;
88 s6dmac_put_fifo(DMA_MASK_DMAC(channel), DMA_INDEX_CHNL(channel),
89 src, dst, period_size);
90
91 prtd->period++;
92 if (unlikely(prtd->period >= runtime->periods))
93 prtd->period = 0;
94}
95
96static irqreturn_t s6000_pcm_irq(int irq, void *data)
97{
98 struct snd_pcm *pcm = data;
99 struct snd_soc_pcm_runtime *runtime = pcm->private_data;
100 struct s6000_runtime_data *prtd;
101 unsigned int has_xrun;
102 int i, ret = IRQ_NONE;
103
104 for (i = 0; i < 2; ++i) {
105 struct snd_pcm_substream *substream = pcm->streams[i].substream;
106 struct s6000_pcm_dma_params *params =
107 snd_soc_dai_get_dma_data(runtime->cpu_dai, substream);
108 u32 channel;
109 unsigned int pending;
110
111 if (substream == SNDRV_PCM_STREAM_PLAYBACK)
112 channel = params->dma_out;
113 else
114 channel = params->dma_in;
115
116 has_xrun = params->check_xrun(runtime->cpu_dai);
117
118 if (!channel)
119 continue;
120
121 if (unlikely(has_xrun & (1 << i)) &&
122 substream->runtime &&
123 snd_pcm_running(substream)) {
124 dev_dbg(pcm->dev, "xrun\n");
125 snd_pcm_stream_lock(substream);
126 snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN);
127 snd_pcm_stream_unlock(substream);
128 ret = IRQ_HANDLED;
129 }
130
131 pending = s6dmac_int_sources(DMA_MASK_DMAC(channel),
132 DMA_INDEX_CHNL(channel));
133
134 if (pending & 1) {
135 ret = IRQ_HANDLED;
136 if (likely(substream->runtime &&
137 snd_pcm_running(substream))) {
138 snd_pcm_period_elapsed(substream);
139 dev_dbg(pcm->dev, "period elapsed %x %x\n",
140 s6dmac_cur_src(DMA_MASK_DMAC(channel),
141 DMA_INDEX_CHNL(channel)),
142 s6dmac_cur_dst(DMA_MASK_DMAC(channel),
143 DMA_INDEX_CHNL(channel)));
144 prtd = substream->runtime->private_data;
145 spin_lock(&prtd->lock);
146 s6000_pcm_enqueue_dma(substream);
147 spin_unlock(&prtd->lock);
148 }
149 }
150
151 if (unlikely(pending & ~7)) {
152 if (pending & (1 << 3))
153 printk(KERN_WARNING
154 "s6000-pcm: DMA %x Underflow\n",
155 channel);
156 if (pending & (1 << 4))
157 printk(KERN_WARNING
158 "s6000-pcm: DMA %x Overflow\n",
159 channel);
160 if (pending & 0x1e0)
161 printk(KERN_WARNING
162 "s6000-pcm: DMA %x Master Error "
163 "(mask %x)\n",
164 channel, pending >> 5);
165
166 }
167 }
168
169 return ret;
170}
171
172static int s6000_pcm_start(struct snd_pcm_substream *substream)
173{
174 struct s6000_runtime_data *prtd = substream->runtime->private_data;
175 struct snd_soc_pcm_runtime *soc_runtime = substream->private_data;
176 struct s6000_pcm_dma_params *par;
177 unsigned long flags;
178 int srcinc;
179 u32 dma;
180
181 par = snd_soc_dai_get_dma_data(soc_runtime->cpu_dai, substream);
182
183 spin_lock_irqsave(&prtd->lock, flags);
184
185 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
186 srcinc = 1;
187 dma = par->dma_out;
188 } else {
189 srcinc = 0;
190 dma = par->dma_in;
191 }
192 s6dmac_enable_chan(DMA_MASK_DMAC(dma), DMA_INDEX_CHNL(dma),
193 1 /* priority 1 (0 is max) */,
194 0 /* peripheral requests w/o xfer length mode */,
195 srcinc /* source address increment */,
196 srcinc^1 /* destination address increment */,
197 0 /* chunksize 0 (skip impossible on this dma) */,
198 0 /* source skip after chunk (impossible) */,
199 0 /* destination skip after chunk (impossible) */,
200 4 /* 16 byte burst size */,
201 -1 /* don't conserve bandwidth */,
202 0 /* low watermark irq descriptor threshold */,
203 0 /* disable hardware timestamps */,
204 1 /* enable channel */);
205
206 s6000_pcm_enqueue_dma(substream);
207 s6000_pcm_enqueue_dma(substream);
208
209 spin_unlock_irqrestore(&prtd->lock, flags);
210
211 return 0;
212}
213
214static int s6000_pcm_stop(struct snd_pcm_substream *substream)
215{
216 struct s6000_runtime_data *prtd = substream->runtime->private_data;
217 struct snd_soc_pcm_runtime *soc_runtime = substream->private_data;
218 struct s6000_pcm_dma_params *par;
219 unsigned long flags;
220 u32 channel;
221
222 par = snd_soc_dai_get_dma_data(soc_runtime->cpu_dai, substream);
223
224 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
225 channel = par->dma_out;
226 else
227 channel = par->dma_in;
228
229 s6dmac_set_terminal_count(DMA_MASK_DMAC(channel),
230 DMA_INDEX_CHNL(channel), 0);
231
232 spin_lock_irqsave(&prtd->lock, flags);
233
234 s6dmac_disable_chan(DMA_MASK_DMAC(channel), DMA_INDEX_CHNL(channel));
235
236 spin_unlock_irqrestore(&prtd->lock, flags);
237
238 return 0;
239}
240
241static int s6000_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
242{
243 struct snd_soc_pcm_runtime *soc_runtime = substream->private_data;
244 struct s6000_pcm_dma_params *par;
245 int ret;
246
247 par = snd_soc_dai_get_dma_data(soc_runtime->cpu_dai, substream);
248
249 ret = par->trigger(substream, cmd, 0);
250 if (ret < 0)
251 return ret;
252
253 switch (cmd) {
254 case SNDRV_PCM_TRIGGER_START:
255 case SNDRV_PCM_TRIGGER_RESUME:
256 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
257 ret = s6000_pcm_start(substream);
258 break;
259 case SNDRV_PCM_TRIGGER_STOP:
260 case SNDRV_PCM_TRIGGER_SUSPEND:
261 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
262 ret = s6000_pcm_stop(substream);
263 break;
264 default:
265 ret = -EINVAL;
266 }
267 if (ret < 0)
268 return ret;
269
270 return par->trigger(substream, cmd, 1);
271}
272
273static int s6000_pcm_prepare(struct snd_pcm_substream *substream)
274{
275 struct s6000_runtime_data *prtd = substream->runtime->private_data;
276
277 prtd->period = 0;
278
279 return 0;
280}
281
282static snd_pcm_uframes_t s6000_pcm_pointer(struct snd_pcm_substream *substream)
283{
284 struct snd_soc_pcm_runtime *soc_runtime = substream->private_data;
285 struct s6000_pcm_dma_params *par;
286 struct snd_pcm_runtime *runtime = substream->runtime;
287 struct s6000_runtime_data *prtd = runtime->private_data;
288 unsigned long flags;
289 unsigned int offset;
290 dma_addr_t count;
291
292 par = snd_soc_dai_get_dma_data(soc_runtime->cpu_dai, substream);
293
294 spin_lock_irqsave(&prtd->lock, flags);
295
296 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
297 count = s6dmac_cur_src(DMA_MASK_DMAC(par->dma_out),
298 DMA_INDEX_CHNL(par->dma_out));
299 else
300 count = s6dmac_cur_dst(DMA_MASK_DMAC(par->dma_in),
301 DMA_INDEX_CHNL(par->dma_in));
302
303 count -= runtime->dma_addr;
304
305 spin_unlock_irqrestore(&prtd->lock, flags);
306
307 offset = bytes_to_frames(runtime, count);
308 if (unlikely(offset >= runtime->buffer_size))
309 offset = 0;
310
311 return offset;
312}
313
314static int s6000_pcm_open(struct snd_pcm_substream *substream)
315{
316 struct snd_soc_pcm_runtime *soc_runtime = substream->private_data;
317 struct s6000_pcm_dma_params *par;
318 struct snd_pcm_runtime *runtime = substream->runtime;
319 struct s6000_runtime_data *prtd;
320 int ret;
321
322 par = snd_soc_dai_get_dma_data(soc_runtime->cpu_dai, substream);
323 snd_soc_set_runtime_hwparams(substream, &s6000_pcm_hardware);
324
325 ret = snd_pcm_hw_constraint_step(runtime, 0,
326 SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 16);
327 if (ret < 0)
328 return ret;
329 ret = snd_pcm_hw_constraint_step(runtime, 0,
330 SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 16);
331 if (ret < 0)
332 return ret;
333 ret = snd_pcm_hw_constraint_integer(runtime,
334 SNDRV_PCM_HW_PARAM_PERIODS);
335 if (ret < 0)
336 return ret;
337
338 if (par->same_rate) {
339 int rate;
340 spin_lock(&par->lock); /* needed? */
341 rate = par->rate;
342 spin_unlock(&par->lock);
343 if (rate != -1) {
344 ret = snd_pcm_hw_constraint_minmax(runtime,
345 SNDRV_PCM_HW_PARAM_RATE,
346 rate, rate);
347 if (ret < 0)
348 return ret;
349 }
350 }
351
352 prtd = kzalloc(sizeof(struct s6000_runtime_data), GFP_KERNEL);
353 if (prtd == NULL)
354 return -ENOMEM;
355
356 spin_lock_init(&prtd->lock);
357
358 runtime->private_data = prtd;
359
360 return 0;
361}
362
363static int s6000_pcm_close(struct snd_pcm_substream *substream)
364{
365 struct snd_pcm_runtime *runtime = substream->runtime;
366 struct s6000_runtime_data *prtd = runtime->private_data;
367
368 kfree(prtd);
369
370 return 0;
371}
372
373static int s6000_pcm_hw_params(struct snd_pcm_substream *substream,
374 struct snd_pcm_hw_params *hw_params)
375{
376 struct snd_soc_pcm_runtime *soc_runtime = substream->private_data;
377 struct s6000_pcm_dma_params *par;
378 int ret;
379 ret = snd_pcm_lib_malloc_pages(substream,
380 params_buffer_bytes(hw_params));
381 if (ret < 0) {
382 printk(KERN_WARNING "s6000-pcm: allocation of memory failed\n");
383 return ret;
384 }
385
386 par = snd_soc_dai_get_dma_data(soc_runtime->cpu_dai, substream);
387
388 if (par->same_rate) {
389 spin_lock(&par->lock);
390 if (par->rate == -1 ||
391 !(par->in_use & ~(1 << substream->stream))) {
392 par->rate = params_rate(hw_params);
393 par->in_use |= 1 << substream->stream;
394 } else if (params_rate(hw_params) != par->rate) {
395 snd_pcm_lib_free_pages(substream);
396 par->in_use &= ~(1 << substream->stream);
397 ret = -EBUSY;
398 }
399 spin_unlock(&par->lock);
400 }
401 return ret;
402}
403
404static int s6000_pcm_hw_free(struct snd_pcm_substream *substream)
405{
406 struct snd_soc_pcm_runtime *soc_runtime = substream->private_data;
407 struct s6000_pcm_dma_params *par =
408 snd_soc_dai_get_dma_data(soc_runtime->cpu_dai, substream);
409
410 spin_lock(&par->lock);
411 par->in_use &= ~(1 << substream->stream);
412 if (!par->in_use)
413 par->rate = -1;
414 spin_unlock(&par->lock);
415
416 return snd_pcm_lib_free_pages(substream);
417}
418
419static struct snd_pcm_ops s6000_pcm_ops = {
420 .open = s6000_pcm_open,
421 .close = s6000_pcm_close,
422 .ioctl = snd_pcm_lib_ioctl,
423 .hw_params = s6000_pcm_hw_params,
424 .hw_free = s6000_pcm_hw_free,
425 .trigger = s6000_pcm_trigger,
426 .prepare = s6000_pcm_prepare,
427 .pointer = s6000_pcm_pointer,
428};
429
430static void s6000_pcm_free(struct snd_pcm *pcm)
431{
432 struct snd_soc_pcm_runtime *runtime = pcm->private_data;
433 struct s6000_pcm_dma_params *params =
434 snd_soc_dai_get_dma_data(runtime->cpu_dai,
435 pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream);
436
437 free_irq(params->irq, pcm);
438 snd_pcm_lib_preallocate_free_for_all(pcm);
439}
440
441static int s6000_pcm_new(struct snd_soc_pcm_runtime *runtime)
442{
443 struct snd_card *card = runtime->card->snd_card;
444 struct snd_pcm *pcm = runtime->pcm;
445 struct s6000_pcm_dma_params *params;
446 int res;
447
448 params = snd_soc_dai_get_dma_data(runtime->cpu_dai,
449 pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream);
450
451 res = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32));
452 if (res)
453 return res;
454
455 if (params->dma_in) {
456 s6dmac_disable_chan(DMA_MASK_DMAC(params->dma_in),
457 DMA_INDEX_CHNL(params->dma_in));
458 s6dmac_int_sources(DMA_MASK_DMAC(params->dma_in),
459 DMA_INDEX_CHNL(params->dma_in));
460 }
461
462 if (params->dma_out) {
463 s6dmac_disable_chan(DMA_MASK_DMAC(params->dma_out),
464 DMA_INDEX_CHNL(params->dma_out));
465 s6dmac_int_sources(DMA_MASK_DMAC(params->dma_out),
466 DMA_INDEX_CHNL(params->dma_out));
467 }
468
469 res = request_irq(params->irq, s6000_pcm_irq, IRQF_SHARED,
470 "s6000-audio", pcm);
471 if (res) {
472 printk(KERN_ERR "s6000-pcm couldn't get IRQ\n");
473 return res;
474 }
475
476 res = snd_pcm_lib_preallocate_pages_for_all(pcm,
477 SNDRV_DMA_TYPE_DEV,
478 card->dev,
479 S6_PCM_PREALLOCATE_SIZE,
480 S6_PCM_PREALLOCATE_MAX);
481 if (res)
482 printk(KERN_WARNING "s6000-pcm: preallocation failed\n");
483
484 spin_lock_init(&params->lock);
485 params->in_use = 0;
486 params->rate = -1;
487 return 0;
488}
489
490static struct snd_soc_platform_driver s6000_soc_platform = {
491 .ops = &s6000_pcm_ops,
492 .pcm_new = s6000_pcm_new,
493 .pcm_free = s6000_pcm_free,
494};
495
496static int s6000_soc_platform_probe(struct platform_device *pdev)
497{
498 return snd_soc_register_platform(&pdev->dev, &s6000_soc_platform);
499}
500
501static int s6000_soc_platform_remove(struct platform_device *pdev)
502{
503 snd_soc_unregister_platform(&pdev->dev);
504 return 0;
505}
506
507static struct platform_driver s6000_pcm_driver = {
508 .driver = {
509 .name = "s6000-pcm-audio",
510 .owner = THIS_MODULE,
511 },
512
513 .probe = s6000_soc_platform_probe,
514 .remove = s6000_soc_platform_remove,
515};
516
517module_platform_driver(s6000_pcm_driver);
518
519MODULE_AUTHOR("Daniel Gloeckner");
520MODULE_DESCRIPTION("Stretch s6000 family PCM DMA module");
521MODULE_LICENSE("GPL");
diff --git a/sound/soc/s6000/s6000-pcm.h b/sound/soc/s6000/s6000-pcm.h
deleted file mode 100644
index 09d9b883e58b..000000000000
--- a/sound/soc/s6000/s6000-pcm.h
+++ /dev/null
@@ -1,33 +0,0 @@
1/*
2 * ALSA PCM interface for the Stretch s6000 family
3 *
4 * Author: Daniel Gloeckner, <dg@emlix.com>
5 * Copyright: (C) 2009 emlix GmbH <info@emlix.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12#ifndef _S6000_PCM_H
13#define _S6000_PCM_H
14
15struct snd_soc_dai;
16struct snd_pcm_substream;
17
18struct s6000_pcm_dma_params {
19 unsigned int (*check_xrun)(struct snd_soc_dai *cpu_dai);
20 int (*trigger)(struct snd_pcm_substream *substream, int cmd, int after);
21 dma_addr_t sif_in;
22 dma_addr_t sif_out;
23 u32 dma_in;
24 u32 dma_out;
25 int irq;
26 int same_rate;
27
28 spinlock_t lock;
29 int in_use;
30 int rate;
31};
32
33#endif
diff --git a/sound/soc/s6000/s6105-ipcam.c b/sound/soc/s6000/s6105-ipcam.c
deleted file mode 100644
index 3510c01f8a6a..000000000000
--- a/sound/soc/s6000/s6105-ipcam.c
+++ /dev/null
@@ -1,221 +0,0 @@
1/*
2 * ASoC driver for Stretch s6105 IP camera platform
3 *
4 * Author: Daniel Gloeckner, <dg@emlix.com>
5 * Copyright: (C) 2009 emlix GmbH <info@emlix.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12#include <linux/module.h>
13#include <linux/moduleparam.h>
14#include <linux/timer.h>
15#include <linux/interrupt.h>
16#include <linux/platform_device.h>
17#include <linux/i2c.h>
18#include <sound/core.h>
19#include <sound/pcm.h>
20#include <sound/soc.h>
21
22#include "s6000-pcm.h"
23#include "s6000-i2s.h"
24
25#define S6105_CAM_CODEC_CLOCK 12288000
26
27static int s6105_hw_params(struct snd_pcm_substream *substream,
28 struct snd_pcm_hw_params *params)
29{
30 struct snd_soc_pcm_runtime *rtd = substream->private_data;
31 struct snd_soc_dai *codec_dai = rtd->codec_dai;
32 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
33 int ret = 0;
34
35 /* set codec DAI configuration */
36 ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
37 SND_SOC_DAIFMT_CBM_CFM);
38 if (ret < 0)
39 return ret;
40
41 /* set cpu DAI configuration */
42 ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_CBM_CFM |
43 SND_SOC_DAIFMT_NB_NF);
44 if (ret < 0)
45 return ret;
46
47 /* set the codec system clock */
48 ret = snd_soc_dai_set_sysclk(codec_dai, 0, S6105_CAM_CODEC_CLOCK,
49 SND_SOC_CLOCK_OUT);
50 if (ret < 0)
51 return ret;
52
53 return 0;
54}
55
56static struct snd_soc_ops s6105_ops = {
57 .hw_params = s6105_hw_params,
58};
59
60/* s6105 machine dapm widgets */
61static const struct snd_soc_dapm_widget aic3x_dapm_widgets[] = {
62 SND_SOC_DAPM_LINE("Audio Out Differential", NULL),
63 SND_SOC_DAPM_LINE("Audio Out Stereo", NULL),
64 SND_SOC_DAPM_LINE("Audio In", NULL),
65};
66
67/* s6105 machine audio_mapnections to the codec pins */
68static const struct snd_soc_dapm_route audio_map[] = {
69 /* Audio Out connected to HPLOUT, HPLCOM, HPROUT */
70 {"Audio Out Differential", NULL, "HPLOUT"},
71 {"Audio Out Differential", NULL, "HPLCOM"},
72 {"Audio Out Stereo", NULL, "HPLOUT"},
73 {"Audio Out Stereo", NULL, "HPROUT"},
74
75 /* Audio In connected to LINE1L, LINE1R */
76 {"LINE1L", NULL, "Audio In"},
77 {"LINE1R", NULL, "Audio In"},
78};
79
80static int output_type_info(struct snd_kcontrol *kcontrol,
81 struct snd_ctl_elem_info *uinfo)
82{
83 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
84 uinfo->count = 1;
85 uinfo->value.enumerated.items = 2;
86 if (uinfo->value.enumerated.item) {
87 uinfo->value.enumerated.item = 1;
88 strcpy(uinfo->value.enumerated.name, "HPLOUT/HPROUT");
89 } else {
90 strcpy(uinfo->value.enumerated.name, "HPLOUT/HPLCOM");
91 }
92 return 0;
93}
94
95static int output_type_get(struct snd_kcontrol *kcontrol,
96 struct snd_ctl_elem_value *ucontrol)
97{
98 ucontrol->value.enumerated.item[0] = kcontrol->private_value;
99 return 0;
100}
101
102static int output_type_put(struct snd_kcontrol *kcontrol,
103 struct snd_ctl_elem_value *ucontrol)
104{
105 struct snd_soc_card *card = kcontrol->private_data;
106 struct snd_soc_dapm_context *dapm = &card->dapm;
107 unsigned int val = (ucontrol->value.enumerated.item[0] != 0);
108 char *differential = "Audio Out Differential";
109 char *stereo = "Audio Out Stereo";
110
111 if (kcontrol->private_value == val)
112 return 0;
113 kcontrol->private_value = val;
114 snd_soc_dapm_disable_pin(dapm, val ? differential : stereo);
115 snd_soc_dapm_sync(dapm);
116 snd_soc_dapm_enable_pin(dapm, val ? stereo : differential);
117 snd_soc_dapm_sync(dapm);
118
119 return 1;
120}
121
122static const struct snd_kcontrol_new audio_out_mux = {
123 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
124 .name = "Master Output Mux",
125 .index = 0,
126 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
127 .info = output_type_info,
128 .get = output_type_get,
129 .put = output_type_put,
130 .private_value = 1 /* default to stereo */
131};
132
133/* Logic for a aic3x as connected on the s6105 ip camera ref design */
134static int s6105_aic3x_init(struct snd_soc_pcm_runtime *rtd)
135{
136 struct snd_soc_card *card = rtd->card;
137
138 /* must correspond to audio_out_mux.private_value initializer */
139 snd_soc_dapm_disable_pin(&card->dapm, "Audio Out Differential");
140
141 snd_ctl_add(card->snd_card, snd_ctl_new1(&audio_out_mux, card));
142
143 return 0;
144}
145
146/* s6105 digital audio interface glue - connects codec <--> CPU */
147static struct snd_soc_dai_link s6105_dai = {
148 .name = "TLV320AIC31",
149 .stream_name = "AIC31",
150 .cpu_dai_name = "s6000-i2s",
151 .codec_dai_name = "tlv320aic3x-hifi",
152 .platform_name = "s6000-pcm-audio",
153 .codec_name = "tlv320aic3x-codec.0-001a",
154 .init = s6105_aic3x_init,
155 .ops = &s6105_ops,
156};
157
158/* s6105 audio machine driver */
159static struct snd_soc_card snd_soc_card_s6105 = {
160 .name = "Stretch IP Camera",
161 .owner = THIS_MODULE,
162 .dai_link = &s6105_dai,
163 .num_links = 1,
164
165 .dapm_widgets = aic3x_dapm_widgets,
166 .num_dapm_widgets = ARRAY_SIZE(aic3x_dapm_widgets),
167 .dapm_routes = audio_map,
168 .num_dapm_routes = ARRAY_SIZE(audio_map),
169 .fully_routed = true,
170};
171
172static struct s6000_snd_platform_data s6105_snd_data __initdata = {
173 .wide = 0,
174 .channel_in = 0,
175 .channel_out = 1,
176 .lines_in = 1,
177 .lines_out = 1,
178 .same_rate = 1,
179};
180
181static struct platform_device *s6105_snd_device;
182
183/* temporary i2c device creation until this can be moved into the machine
184 * support file.
185*/
186static struct i2c_board_info i2c_device[] = {
187 { I2C_BOARD_INFO("tlv320aic33", 0x18), }
188};
189
190static int __init s6105_init(void)
191{
192 int ret;
193
194 i2c_register_board_info(0, i2c_device, ARRAY_SIZE(i2c_device));
195
196 s6105_snd_device = platform_device_alloc("soc-audio", -1);
197 if (!s6105_snd_device)
198 return -ENOMEM;
199
200 platform_set_drvdata(s6105_snd_device, &snd_soc_card_s6105);
201 platform_device_add_data(s6105_snd_device, &s6105_snd_data,
202 sizeof(s6105_snd_data));
203
204 ret = platform_device_add(s6105_snd_device);
205 if (ret)
206 platform_device_put(s6105_snd_device);
207
208 return ret;
209}
210
211static void __exit s6105_exit(void)
212{
213 platform_device_unregister(s6105_snd_device);
214}
215
216module_init(s6105_init);
217module_exit(s6105_exit);
218
219MODULE_AUTHOR("Daniel Gloeckner");
220MODULE_DESCRIPTION("Stretch s6105 IP camera ASoC driver");
221MODULE_LICENSE("GPL");
diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c
index 8c5c11ca8c53..25114c9a6801 100644
--- a/tools/perf/builtin-diff.c
+++ b/tools/perf/builtin-diff.c
@@ -1142,6 +1142,11 @@ static int data_init(int argc, const char **argv)
1142 1142
1143int cmd_diff(int argc, const char **argv, const char *prefix __maybe_unused) 1143int cmd_diff(int argc, const char **argv, const char *prefix __maybe_unused)
1144{ 1144{
1145 int ret = hists__init();
1146
1147 if (ret < 0)
1148 return ret;
1149
1145 perf_config(perf_default_config, NULL); 1150 perf_config(perf_default_config, NULL);
1146 1151
1147 argc = parse_options(argc, argv, options, diff_usage, 0); 1152 argc = parse_options(argc, argv, options, diff_usage, 0);
diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c
index 04412b4770a2..7af26acf06d9 100644
--- a/tools/perf/builtin-probe.c
+++ b/tools/perf/builtin-probe.c
@@ -375,7 +375,7 @@ __cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused)
375 OPT_CALLBACK('x', "exec", NULL, "executable|path", 375 OPT_CALLBACK('x', "exec", NULL, "executable|path",
376 "target executable name or path", opt_set_target), 376 "target executable name or path", opt_set_target),
377 OPT_BOOLEAN(0, "demangle", &symbol_conf.demangle, 377 OPT_BOOLEAN(0, "demangle", &symbol_conf.demangle,
378 "Disable symbol demangling"), 378 "Enable symbol demangling"),
379 OPT_BOOLEAN(0, "demangle-kernel", &symbol_conf.demangle_kernel, 379 OPT_BOOLEAN(0, "demangle-kernel", &symbol_conf.demangle_kernel,
380 "Enable kernel symbol demangling"), 380 "Enable kernel symbol demangling"),
381 OPT_END() 381 OPT_END()
diff --git a/tools/perf/perf-sys.h b/tools/perf/perf-sys.h
index 937e4324ad94..a3b13d7dc1d4 100644
--- a/tools/perf/perf-sys.h
+++ b/tools/perf/perf-sys.h
@@ -13,7 +13,7 @@
13#define wmb() asm volatile("lock; addl $0,0(%%esp)" ::: "memory") 13#define wmb() asm volatile("lock; addl $0,0(%%esp)" ::: "memory")
14#define rmb() asm volatile("lock; addl $0,0(%%esp)" ::: "memory") 14#define rmb() asm volatile("lock; addl $0,0(%%esp)" ::: "memory")
15#define cpu_relax() asm volatile("rep; nop" ::: "memory"); 15#define cpu_relax() asm volatile("rep; nop" ::: "memory");
16#define CPUINFO_PROC "model name" 16#define CPUINFO_PROC {"model name"}
17#ifndef __NR_perf_event_open 17#ifndef __NR_perf_event_open
18# define __NR_perf_event_open 336 18# define __NR_perf_event_open 336
19#endif 19#endif
@@ -30,7 +30,7 @@
30#define wmb() asm volatile("sfence" ::: "memory") 30#define wmb() asm volatile("sfence" ::: "memory")
31#define rmb() asm volatile("lfence" ::: "memory") 31#define rmb() asm volatile("lfence" ::: "memory")
32#define cpu_relax() asm volatile("rep; nop" ::: "memory"); 32#define cpu_relax() asm volatile("rep; nop" ::: "memory");
33#define CPUINFO_PROC "model name" 33#define CPUINFO_PROC {"model name"}
34#ifndef __NR_perf_event_open 34#ifndef __NR_perf_event_open
35# define __NR_perf_event_open 298 35# define __NR_perf_event_open 298
36#endif 36#endif
@@ -47,14 +47,14 @@
47#define mb() asm volatile ("sync" ::: "memory") 47#define mb() asm volatile ("sync" ::: "memory")
48#define wmb() asm volatile ("sync" ::: "memory") 48#define wmb() asm volatile ("sync" ::: "memory")
49#define rmb() asm volatile ("sync" ::: "memory") 49#define rmb() asm volatile ("sync" ::: "memory")
50#define CPUINFO_PROC "cpu" 50#define CPUINFO_PROC {"cpu"}
51#endif 51#endif
52 52
53#ifdef __s390__ 53#ifdef __s390__
54#define mb() asm volatile("bcr 15,0" ::: "memory") 54#define mb() asm volatile("bcr 15,0" ::: "memory")
55#define wmb() asm volatile("bcr 15,0" ::: "memory") 55#define wmb() asm volatile("bcr 15,0" ::: "memory")
56#define rmb() asm volatile("bcr 15,0" ::: "memory") 56#define rmb() asm volatile("bcr 15,0" ::: "memory")
57#define CPUINFO_PROC "vendor_id" 57#define CPUINFO_PROC {"vendor_id"}
58#endif 58#endif
59 59
60#ifdef __sh__ 60#ifdef __sh__
@@ -67,14 +67,14 @@
67# define wmb() asm volatile("" ::: "memory") 67# define wmb() asm volatile("" ::: "memory")
68# define rmb() asm volatile("" ::: "memory") 68# define rmb() asm volatile("" ::: "memory")
69#endif 69#endif
70#define CPUINFO_PROC "cpu type" 70#define CPUINFO_PROC {"cpu type"}
71#endif 71#endif
72 72
73#ifdef __hppa__ 73#ifdef __hppa__
74#define mb() asm volatile("" ::: "memory") 74#define mb() asm volatile("" ::: "memory")
75#define wmb() asm volatile("" ::: "memory") 75#define wmb() asm volatile("" ::: "memory")
76#define rmb() asm volatile("" ::: "memory") 76#define rmb() asm volatile("" ::: "memory")
77#define CPUINFO_PROC "cpu" 77#define CPUINFO_PROC {"cpu"}
78#endif 78#endif
79 79
80#ifdef __sparc__ 80#ifdef __sparc__
@@ -87,14 +87,14 @@
87#endif 87#endif
88#define wmb() asm volatile("":::"memory") 88#define wmb() asm volatile("":::"memory")
89#define rmb() asm volatile("":::"memory") 89#define rmb() asm volatile("":::"memory")
90#define CPUINFO_PROC "cpu" 90#define CPUINFO_PROC {"cpu"}
91#endif 91#endif
92 92
93#ifdef __alpha__ 93#ifdef __alpha__
94#define mb() asm volatile("mb" ::: "memory") 94#define mb() asm volatile("mb" ::: "memory")
95#define wmb() asm volatile("wmb" ::: "memory") 95#define wmb() asm volatile("wmb" ::: "memory")
96#define rmb() asm volatile("mb" ::: "memory") 96#define rmb() asm volatile("mb" ::: "memory")
97#define CPUINFO_PROC "cpu model" 97#define CPUINFO_PROC {"cpu model"}
98#endif 98#endif
99 99
100#ifdef __ia64__ 100#ifdef __ia64__
@@ -102,7 +102,7 @@
102#define wmb() asm volatile ("mf" ::: "memory") 102#define wmb() asm volatile ("mf" ::: "memory")
103#define rmb() asm volatile ("mf" ::: "memory") 103#define rmb() asm volatile ("mf" ::: "memory")
104#define cpu_relax() asm volatile ("hint @pause" ::: "memory") 104#define cpu_relax() asm volatile ("hint @pause" ::: "memory")
105#define CPUINFO_PROC "model name" 105#define CPUINFO_PROC {"model name"}
106#endif 106#endif
107 107
108#ifdef __arm__ 108#ifdef __arm__
@@ -113,7 +113,7 @@
113#define mb() ((void(*)(void))0xffff0fa0)() 113#define mb() ((void(*)(void))0xffff0fa0)()
114#define wmb() ((void(*)(void))0xffff0fa0)() 114#define wmb() ((void(*)(void))0xffff0fa0)()
115#define rmb() ((void(*)(void))0xffff0fa0)() 115#define rmb() ((void(*)(void))0xffff0fa0)()
116#define CPUINFO_PROC "Processor" 116#define CPUINFO_PROC {"model name", "Processor"}
117#endif 117#endif
118 118
119#ifdef __aarch64__ 119#ifdef __aarch64__
@@ -133,28 +133,28 @@
133 : "memory") 133 : "memory")
134#define wmb() mb() 134#define wmb() mb()
135#define rmb() mb() 135#define rmb() mb()
136#define CPUINFO_PROC "cpu model" 136#define CPUINFO_PROC {"cpu model"}
137#endif 137#endif
138 138
139#ifdef __arc__ 139#ifdef __arc__
140#define mb() asm volatile("" ::: "memory") 140#define mb() asm volatile("" ::: "memory")
141#define wmb() asm volatile("" ::: "memory") 141#define wmb() asm volatile("" ::: "memory")
142#define rmb() asm volatile("" ::: "memory") 142#define rmb() asm volatile("" ::: "memory")
143#define CPUINFO_PROC "Processor" 143#define CPUINFO_PROC {"Processor"}
144#endif 144#endif
145 145
146#ifdef __metag__ 146#ifdef __metag__
147#define mb() asm volatile("" ::: "memory") 147#define mb() asm volatile("" ::: "memory")
148#define wmb() asm volatile("" ::: "memory") 148#define wmb() asm volatile("" ::: "memory")
149#define rmb() asm volatile("" ::: "memory") 149#define rmb() asm volatile("" ::: "memory")
150#define CPUINFO_PROC "CPU" 150#define CPUINFO_PROC {"CPU"}
151#endif 151#endif
152 152
153#ifdef __xtensa__ 153#ifdef __xtensa__
154#define mb() asm volatile("memw" ::: "memory") 154#define mb() asm volatile("memw" ::: "memory")
155#define wmb() asm volatile("memw" ::: "memory") 155#define wmb() asm volatile("memw" ::: "memory")
156#define rmb() asm volatile("" ::: "memory") 156#define rmb() asm volatile("" ::: "memory")
157#define CPUINFO_PROC "core ID" 157#define CPUINFO_PROC {"core ID"}
158#endif 158#endif
159 159
160#ifdef __tile__ 160#ifdef __tile__
@@ -162,7 +162,7 @@
162#define wmb() asm volatile ("mf" ::: "memory") 162#define wmb() asm volatile ("mf" ::: "memory")
163#define rmb() asm volatile ("mf" ::: "memory") 163#define rmb() asm volatile ("mf" ::: "memory")
164#define cpu_relax() asm volatile ("mfspr zero, PASS" ::: "memory") 164#define cpu_relax() asm volatile ("mfspr zero, PASS" ::: "memory")
165#define CPUINFO_PROC "model name" 165#define CPUINFO_PROC {"model name"}
166#endif 166#endif
167 167
168#define barrier() asm volatile ("" ::: "memory") 168#define barrier() asm volatile ("" ::: "memory")
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index ce0de00399da..26f5b2fe5dc8 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -579,16 +579,12 @@ static int write_version(int fd, struct perf_header *h __maybe_unused,
579 return do_write_string(fd, perf_version_string); 579 return do_write_string(fd, perf_version_string);
580} 580}
581 581
582static int write_cpudesc(int fd, struct perf_header *h __maybe_unused, 582static int __write_cpudesc(int fd, const char *cpuinfo_proc)
583 struct perf_evlist *evlist __maybe_unused)
584{ 583{
585#ifndef CPUINFO_PROC
586#define CPUINFO_PROC NULL
587#endif
588 FILE *file; 584 FILE *file;
589 char *buf = NULL; 585 char *buf = NULL;
590 char *s, *p; 586 char *s, *p;
591 const char *search = CPUINFO_PROC; 587 const char *search = cpuinfo_proc;
592 size_t len = 0; 588 size_t len = 0;
593 int ret = -1; 589 int ret = -1;
594 590
@@ -638,6 +634,25 @@ done:
638 return ret; 634 return ret;
639} 635}
640 636
637static int write_cpudesc(int fd, struct perf_header *h __maybe_unused,
638 struct perf_evlist *evlist __maybe_unused)
639{
640#ifndef CPUINFO_PROC
641#define CPUINFO_PROC {"model name", }
642#endif
643 const char *cpuinfo_procs[] = CPUINFO_PROC;
644 unsigned int i;
645
646 for (i = 0; i < ARRAY_SIZE(cpuinfo_procs); i++) {
647 int ret;
648 ret = __write_cpudesc(fd, cpuinfo_procs[i]);
649 if (ret >= 0)
650 return ret;
651 }
652 return -1;
653}
654
655
641static int write_nrcpus(int fd, struct perf_header *h __maybe_unused, 656static int write_nrcpus(int fd, struct perf_header *h __maybe_unused,
642 struct perf_evlist *evlist __maybe_unused) 657 struct perf_evlist *evlist __maybe_unused)
643{ 658{
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index 4906cd81cb56..9402885a77f3 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -373,6 +373,9 @@ struct sort_entry sort_cpu = {
373static int64_t 373static int64_t
374sort__dso_from_cmp(struct hist_entry *left, struct hist_entry *right) 374sort__dso_from_cmp(struct hist_entry *left, struct hist_entry *right)
375{ 375{
376 if (!left->branch_info || !right->branch_info)
377 return cmp_null(left->branch_info, right->branch_info);
378
376 return _sort__dso_cmp(left->branch_info->from.map, 379 return _sort__dso_cmp(left->branch_info->from.map,
377 right->branch_info->from.map); 380 right->branch_info->from.map);
378} 381}
@@ -380,13 +383,19 @@ sort__dso_from_cmp(struct hist_entry *left, struct hist_entry *right)
380static int hist_entry__dso_from_snprintf(struct hist_entry *he, char *bf, 383static int hist_entry__dso_from_snprintf(struct hist_entry *he, char *bf,
381 size_t size, unsigned int width) 384 size_t size, unsigned int width)
382{ 385{
383 return _hist_entry__dso_snprintf(he->branch_info->from.map, 386 if (he->branch_info)
384 bf, size, width); 387 return _hist_entry__dso_snprintf(he->branch_info->from.map,
388 bf, size, width);
389 else
390 return repsep_snprintf(bf, size, "%-*.*s", width, width, "N/A");
385} 391}
386 392
387static int64_t 393static int64_t
388sort__dso_to_cmp(struct hist_entry *left, struct hist_entry *right) 394sort__dso_to_cmp(struct hist_entry *left, struct hist_entry *right)
389{ 395{
396 if (!left->branch_info || !right->branch_info)
397 return cmp_null(left->branch_info, right->branch_info);
398
390 return _sort__dso_cmp(left->branch_info->to.map, 399 return _sort__dso_cmp(left->branch_info->to.map,
391 right->branch_info->to.map); 400 right->branch_info->to.map);
392} 401}
@@ -394,8 +403,11 @@ sort__dso_to_cmp(struct hist_entry *left, struct hist_entry *right)
394static int hist_entry__dso_to_snprintf(struct hist_entry *he, char *bf, 403static int hist_entry__dso_to_snprintf(struct hist_entry *he, char *bf,
395 size_t size, unsigned int width) 404 size_t size, unsigned int width)
396{ 405{
397 return _hist_entry__dso_snprintf(he->branch_info->to.map, 406 if (he->branch_info)
398 bf, size, width); 407 return _hist_entry__dso_snprintf(he->branch_info->to.map,
408 bf, size, width);
409 else
410 return repsep_snprintf(bf, size, "%-*.*s", width, width, "N/A");
399} 411}
400 412
401static int64_t 413static int64_t
@@ -404,6 +416,12 @@ sort__sym_from_cmp(struct hist_entry *left, struct hist_entry *right)
404 struct addr_map_symbol *from_l = &left->branch_info->from; 416 struct addr_map_symbol *from_l = &left->branch_info->from;
405 struct addr_map_symbol *from_r = &right->branch_info->from; 417 struct addr_map_symbol *from_r = &right->branch_info->from;
406 418
419 if (!left->branch_info || !right->branch_info)
420 return cmp_null(left->branch_info, right->branch_info);
421
422 from_l = &left->branch_info->from;
423 from_r = &right->branch_info->from;
424
407 if (!from_l->sym && !from_r->sym) 425 if (!from_l->sym && !from_r->sym)
408 return _sort__addr_cmp(from_l->addr, from_r->addr); 426 return _sort__addr_cmp(from_l->addr, from_r->addr);
409 427
@@ -413,8 +431,13 @@ sort__sym_from_cmp(struct hist_entry *left, struct hist_entry *right)
413static int64_t 431static int64_t
414sort__sym_to_cmp(struct hist_entry *left, struct hist_entry *right) 432sort__sym_to_cmp(struct hist_entry *left, struct hist_entry *right)
415{ 433{
416 struct addr_map_symbol *to_l = &left->branch_info->to; 434 struct addr_map_symbol *to_l, *to_r;
417 struct addr_map_symbol *to_r = &right->branch_info->to; 435
436 if (!left->branch_info || !right->branch_info)
437 return cmp_null(left->branch_info, right->branch_info);
438
439 to_l = &left->branch_info->to;
440 to_r = &right->branch_info->to;
418 441
419 if (!to_l->sym && !to_r->sym) 442 if (!to_l->sym && !to_r->sym)
420 return _sort__addr_cmp(to_l->addr, to_r->addr); 443 return _sort__addr_cmp(to_l->addr, to_r->addr);
@@ -425,19 +448,27 @@ sort__sym_to_cmp(struct hist_entry *left, struct hist_entry *right)
425static int hist_entry__sym_from_snprintf(struct hist_entry *he, char *bf, 448static int hist_entry__sym_from_snprintf(struct hist_entry *he, char *bf,
426 size_t size, unsigned int width) 449 size_t size, unsigned int width)
427{ 450{
428 struct addr_map_symbol *from = &he->branch_info->from; 451 if (he->branch_info) {
429 return _hist_entry__sym_snprintf(from->map, from->sym, from->addr, 452 struct addr_map_symbol *from = &he->branch_info->from;
430 he->level, bf, size, width);
431 453
454 return _hist_entry__sym_snprintf(from->map, from->sym, from->addr,
455 he->level, bf, size, width);
456 }
457
458 return repsep_snprintf(bf, size, "%-*.*s", width, width, "N/A");
432} 459}
433 460
434static int hist_entry__sym_to_snprintf(struct hist_entry *he, char *bf, 461static int hist_entry__sym_to_snprintf(struct hist_entry *he, char *bf,
435 size_t size, unsigned int width) 462 size_t size, unsigned int width)
436{ 463{
437 struct addr_map_symbol *to = &he->branch_info->to; 464 if (he->branch_info) {
438 return _hist_entry__sym_snprintf(to->map, to->sym, to->addr, 465 struct addr_map_symbol *to = &he->branch_info->to;
439 he->level, bf, size, width);
440 466
467 return _hist_entry__sym_snprintf(to->map, to->sym, to->addr,
468 he->level, bf, size, width);
469 }
470
471 return repsep_snprintf(bf, size, "%-*.*s", width, width, "N/A");
441} 472}
442 473
443struct sort_entry sort_dso_from = { 474struct sort_entry sort_dso_from = {
@@ -471,11 +502,13 @@ struct sort_entry sort_sym_to = {
471static int64_t 502static int64_t
472sort__mispredict_cmp(struct hist_entry *left, struct hist_entry *right) 503sort__mispredict_cmp(struct hist_entry *left, struct hist_entry *right)
473{ 504{
474 const unsigned char mp = left->branch_info->flags.mispred != 505 unsigned char mp, p;
475 right->branch_info->flags.mispred; 506
476 const unsigned char p = left->branch_info->flags.predicted != 507 if (!left->branch_info || !right->branch_info)
477 right->branch_info->flags.predicted; 508 return cmp_null(left->branch_info, right->branch_info);
478 509
510 mp = left->branch_info->flags.mispred != right->branch_info->flags.mispred;
511 p = left->branch_info->flags.predicted != right->branch_info->flags.predicted;
479 return mp || p; 512 return mp || p;
480} 513}
481 514
@@ -483,10 +516,12 @@ static int hist_entry__mispredict_snprintf(struct hist_entry *he, char *bf,
483 size_t size, unsigned int width){ 516 size_t size, unsigned int width){
484 static const char *out = "N/A"; 517 static const char *out = "N/A";
485 518
486 if (he->branch_info->flags.predicted) 519 if (he->branch_info) {
487 out = "N"; 520 if (he->branch_info->flags.predicted)
488 else if (he->branch_info->flags.mispred) 521 out = "N";
489 out = "Y"; 522 else if (he->branch_info->flags.mispred)
523 out = "Y";
524 }
490 525
491 return repsep_snprintf(bf, size, "%-*.*s", width, width, out); 526 return repsep_snprintf(bf, size, "%-*.*s", width, width, out);
492} 527}
@@ -989,6 +1024,9 @@ struct sort_entry sort_mem_dcacheline = {
989static int64_t 1024static int64_t
990sort__abort_cmp(struct hist_entry *left, struct hist_entry *right) 1025sort__abort_cmp(struct hist_entry *left, struct hist_entry *right)
991{ 1026{
1027 if (!left->branch_info || !right->branch_info)
1028 return cmp_null(left->branch_info, right->branch_info);
1029
992 return left->branch_info->flags.abort != 1030 return left->branch_info->flags.abort !=
993 right->branch_info->flags.abort; 1031 right->branch_info->flags.abort;
994} 1032}
@@ -996,10 +1034,15 @@ sort__abort_cmp(struct hist_entry *left, struct hist_entry *right)
996static int hist_entry__abort_snprintf(struct hist_entry *he, char *bf, 1034static int hist_entry__abort_snprintf(struct hist_entry *he, char *bf,
997 size_t size, unsigned int width) 1035 size_t size, unsigned int width)
998{ 1036{
999 static const char *out = "."; 1037 static const char *out = "N/A";
1038
1039 if (he->branch_info) {
1040 if (he->branch_info->flags.abort)
1041 out = "A";
1042 else
1043 out = ".";
1044 }
1000 1045
1001 if (he->branch_info->flags.abort)
1002 out = "A";
1003 return repsep_snprintf(bf, size, "%-*s", width, out); 1046 return repsep_snprintf(bf, size, "%-*s", width, out);
1004} 1047}
1005 1048
@@ -1013,6 +1056,9 @@ struct sort_entry sort_abort = {
1013static int64_t 1056static int64_t
1014sort__in_tx_cmp(struct hist_entry *left, struct hist_entry *right) 1057sort__in_tx_cmp(struct hist_entry *left, struct hist_entry *right)
1015{ 1058{
1059 if (!left->branch_info || !right->branch_info)
1060 return cmp_null(left->branch_info, right->branch_info);
1061
1016 return left->branch_info->flags.in_tx != 1062 return left->branch_info->flags.in_tx !=
1017 right->branch_info->flags.in_tx; 1063 right->branch_info->flags.in_tx;
1018} 1064}
@@ -1020,10 +1066,14 @@ sort__in_tx_cmp(struct hist_entry *left, struct hist_entry *right)
1020static int hist_entry__in_tx_snprintf(struct hist_entry *he, char *bf, 1066static int hist_entry__in_tx_snprintf(struct hist_entry *he, char *bf,
1021 size_t size, unsigned int width) 1067 size_t size, unsigned int width)
1022{ 1068{
1023 static const char *out = "."; 1069 static const char *out = "N/A";
1024 1070
1025 if (he->branch_info->flags.in_tx) 1071 if (he->branch_info) {
1026 out = "T"; 1072 if (he->branch_info->flags.in_tx)
1073 out = "T";
1074 else
1075 out = ".";
1076 }
1027 1077
1028 return repsep_snprintf(bf, size, "%-*s", width, out); 1078 return repsep_snprintf(bf, size, "%-*s", width, out);
1029} 1079}
diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c
index 2b7b2d91c016..c41411726c7a 100644
--- a/tools/perf/util/thread.c
+++ b/tools/perf/util/thread.c
@@ -117,6 +117,9 @@ int __thread__set_comm(struct thread *thread, const char *str, u64 timestamp,
117 if (!new) 117 if (!new)
118 return -ENOMEM; 118 return -ENOMEM;
119 list_add(&new->list, &thread->comm_list); 119 list_add(&new->list, &thread->comm_list);
120
121 if (exec)
122 unwind__flush_access(thread);
120 } 123 }
121 124
122 thread->comm_set = true; 125 thread->comm_set = true;
diff --git a/tools/perf/util/unwind-libunwind.c b/tools/perf/util/unwind-libunwind.c
index e060386165c5..4d45c0dfe343 100644
--- a/tools/perf/util/unwind-libunwind.c
+++ b/tools/perf/util/unwind-libunwind.c
@@ -539,11 +539,23 @@ int unwind__prepare_access(struct thread *thread)
539 return -ENOMEM; 539 return -ENOMEM;
540 } 540 }
541 541
542 unw_set_caching_policy(addr_space, UNW_CACHE_GLOBAL);
542 thread__set_priv(thread, addr_space); 543 thread__set_priv(thread, addr_space);
543 544
544 return 0; 545 return 0;
545} 546}
546 547
548void unwind__flush_access(struct thread *thread)
549{
550 unw_addr_space_t addr_space;
551
552 if (callchain_param.record_mode != CALLCHAIN_DWARF)
553 return;
554
555 addr_space = thread__priv(thread);
556 unw_flush_cache(addr_space, 0, 0);
557}
558
547void unwind__finish_access(struct thread *thread) 559void unwind__finish_access(struct thread *thread)
548{ 560{
549 unw_addr_space_t addr_space; 561 unw_addr_space_t addr_space;
diff --git a/tools/perf/util/unwind.h b/tools/perf/util/unwind.h
index c17c4855bdbc..f50b737235eb 100644
--- a/tools/perf/util/unwind.h
+++ b/tools/perf/util/unwind.h
@@ -23,6 +23,7 @@ int unwind__get_entries(unwind_entry_cb_t cb, void *arg,
23#ifdef HAVE_LIBUNWIND_SUPPORT 23#ifdef HAVE_LIBUNWIND_SUPPORT
24int libunwind__arch_reg_id(int regnum); 24int libunwind__arch_reg_id(int regnum);
25int unwind__prepare_access(struct thread *thread); 25int unwind__prepare_access(struct thread *thread);
26void unwind__flush_access(struct thread *thread);
26void unwind__finish_access(struct thread *thread); 27void unwind__finish_access(struct thread *thread);
27#else 28#else
28static inline int unwind__prepare_access(struct thread *thread __maybe_unused) 29static inline int unwind__prepare_access(struct thread *thread __maybe_unused)
@@ -30,6 +31,7 @@ static inline int unwind__prepare_access(struct thread *thread __maybe_unused)
30 return 0; 31 return 0;
31} 32}
32 33
34static inline void unwind__flush_access(struct thread *thread __maybe_unused) {}
33static inline void unwind__finish_access(struct thread *thread __maybe_unused) {} 35static inline void unwind__finish_access(struct thread *thread __maybe_unused) {}
34#endif 36#endif
35#else 37#else
@@ -49,6 +51,7 @@ static inline int unwind__prepare_access(struct thread *thread __maybe_unused)
49 return 0; 51 return 0;
50} 52}
51 53
54static inline void unwind__flush_access(struct thread *thread __maybe_unused) {}
52static inline void unwind__finish_access(struct thread *thread __maybe_unused) {} 55static inline void unwind__finish_access(struct thread *thread __maybe_unused) {}
53#endif /* HAVE_DWARF_UNWIND_SUPPORT */ 56#endif /* HAVE_DWARF_UNWIND_SUPPORT */
54#endif /* __UNWIND_H */ 57#endif /* __UNWIND_H */