aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/acpi/enumeration.txt26
-rw-r--r--Documentation/devicetree/bindings/net/dsa/dsa.txt4
-rw-r--r--Documentation/devicetree/bindings/thermal/rcar-thermal.txt2
-rw-r--r--Documentation/input/alps.txt8
-rw-r--r--Documentation/input/event-codes.txt6
-rw-r--r--Documentation/input/multi-touch-protocol.txt9
-rw-r--r--Documentation/kernel-parameters.txt7
-rw-r--r--Documentation/power/basic-pm-debugging.txt10
-rw-r--r--MAINTAINERS39
-rw-r--r--Makefile2
-rw-r--r--arch/arm/include/asm/cpuidle.h23
-rw-r--r--arch/arm/kernel/cpuidle.c133
-rw-r--r--arch/arm/mach-davinci/cpuidle.c1
-rw-r--r--arch/arm/mach-imx/cpuidle-imx6q.c1
-rw-r--r--arch/arm/mach-imx/cpuidle-imx6sl.c1
-rw-r--r--arch/arm/mach-imx/cpuidle-imx6sx.c1
-rw-r--r--arch/arm/mach-omap2/cpuidle44xx.c1
-rw-r--r--arch/arm/mach-s3c64xx/cpuidle.c2
-rw-r--r--arch/arm/mach-tegra/cpuidle-tegra20.c1
-rw-r--r--arch/arm/mach-tegra/cpuidle-tegra30.c1
-rw-r--r--arch/arm64/configs/defconfig2
-rw-r--r--arch/arm64/include/asm/cpuidle.h9
-rw-r--r--arch/arm64/kernel/cpuidle.c2
-rw-r--r--arch/nios2/include/asm/thread_info.h4
-rw-r--r--arch/nios2/include/uapi/asm/ptrace.h9
-rw-r--r--arch/nios2/kernel/entry.S2
-rw-r--r--arch/nios2/kernel/signal.c2
-rw-r--r--arch/nios2/mm/cacheflush.c3
-rw-r--r--arch/powerpc/include/asm/cputhreads.h2
-rw-r--r--arch/sparc/kernel/pci.c5
-rw-r--r--arch/x86/include/asm/pm-trace.h (renamed from arch/x86/include/asm/resume-trace.h)10
-rw-r--r--arch/x86/include/asm/uaccess_64.h2
-rw-r--r--arch/x86/kernel/cpu/perf_event_intel.c10
-rw-r--r--arch/x86/kernel/entry_64.S16
-rw-r--r--arch/x86/kernel/kgdb.c2
-rw-r--r--arch/x86/kernel/reboot.c10
-rw-r--r--arch/x86/lib/usercopy_64.c15
-rw-r--r--arch/x86/xen/p2m.c10
-rw-r--r--block/blk-mq.c4
-rw-r--r--block/blk-settings.c6
-rw-r--r--drivers/acpi/acpi_platform.c2
-rw-r--r--drivers/acpi/battery.c4
-rw-r--r--drivers/acpi/blacklist.c8
-rw-r--r--drivers/acpi/dock.c2
-rw-r--r--drivers/acpi/ec.c123
-rw-r--r--drivers/acpi/glue.c4
-rw-r--r--drivers/acpi/pmic/intel_pmic_crc.c2
-rw-r--r--drivers/acpi/processor_idle.c2
-rw-r--r--drivers/acpi/scan.c394
-rw-r--r--drivers/acpi/sleep.c17
-rw-r--r--drivers/acpi/sleep.h2
-rw-r--r--drivers/acpi/sysfs.c2
-rw-r--r--drivers/acpi/video.c36
-rw-r--r--drivers/acpi/video_detect.c8
-rw-r--r--drivers/ata/libata-core.c15
-rw-r--r--drivers/ata/pata_isapnp.c14
-rw-r--r--drivers/base/core.c51
-rw-r--r--drivers/base/dd.c14
-rw-r--r--drivers/base/platform.c2
-rw-r--r--drivers/base/power/domain.c70
-rw-r--r--drivers/base/power/main.c20
-rw-r--r--drivers/base/power/trace.c6
-rw-r--r--drivers/base/property.c198
-rw-r--r--drivers/char/ipmi/ipmi_powernv.c1
-rw-r--r--drivers/char/ipmi/ipmi_si_intf.c109
-rw-r--r--drivers/char/ipmi/ipmi_ssif.c8
-rw-r--r--drivers/char/tpm/tpm_infineon.c13
-rw-r--r--drivers/cpufreq/Kconfig8
-rw-r--r--drivers/cpufreq/Kconfig.arm9
-rw-r--r--drivers/cpufreq/Kconfig.powerpc9
-rw-r--r--drivers/cpufreq/Makefile3
-rw-r--r--drivers/cpufreq/cpufreq.c19
-rw-r--r--drivers/cpufreq/hisi-acpu-cpufreq.c42
-rw-r--r--drivers/cpufreq/intel_pstate.c45
-rw-r--r--drivers/cpufreq/powernv-cpufreq.c47
-rw-r--r--drivers/cpufreq/qoriq-cpufreq.c (renamed from drivers/cpufreq/ppc-corenet-cpufreq.c)163
-rw-r--r--drivers/cpuidle/Kconfig7
-rw-r--r--drivers/cpuidle/Kconfig.arm28
-rw-r--r--drivers/cpuidle/Kconfig.arm6413
-rw-r--r--drivers/cpuidle/Makefile5
-rw-r--r--drivers/cpuidle/cpuidle-arm.c (renamed from drivers/cpuidle/cpuidle-arm64.c)83
-rw-r--r--drivers/cpuidle/cpuidle-at91.c1
-rw-r--r--drivers/cpuidle/cpuidle-exynos.c1
-rw-r--r--drivers/cpuidle/cpuidle-kirkwood.c1
-rw-r--r--drivers/cpuidle/cpuidle-ux500.c1
-rw-r--r--drivers/cpuidle/cpuidle-zynq.c1
-rw-r--r--drivers/cpuidle/cpuidle.c3
-rw-r--r--drivers/cpuidle/sysfs.c5
-rw-r--r--drivers/dma/bcm2835-dma.c1
-rw-r--r--drivers/dma/cppi41.c9
-rw-r--r--drivers/dma/dma-jz4740.c7
-rw-r--r--drivers/dma/dmaengine.c3
-rw-r--r--drivers/dma/edma.c7
-rw-r--r--drivers/dma/moxart-dma.c4
-rw-r--r--drivers/dma/omap-dma.c1
-rw-r--r--drivers/firmware/dmi_scan.c22
-rw-r--r--drivers/gpio/gpio-mpc8xxx.c2
-rw-r--r--drivers/gpio/gpio-syscon.c2
-rw-r--r--drivers/gpio/gpiolib-acpi.c10
-rw-r--r--drivers/gpio/gpiolib.h2
-rw-r--r--drivers/gpu/drm/drm_crtc.c4
-rw-r--r--drivers/gpu/drm/drm_edid_load.c1
-rw-r--r--drivers/gpu/drm/drm_probe_helper.c1
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_fimd.c8
-rw-r--r--drivers/gpu/drm/exynos/exynos_mixer.c17
-rw-r--r--drivers/gpu/drm/i915/i915_drv.c14
-rw-r--r--drivers/gpu/drm/i915/i915_drv.h1
-rw-r--r--drivers/gpu/drm/i915/i915_gem_execbuffer.c2
-rw-r--r--drivers/gpu/drm/i915/intel_sprite.c4
-rw-r--r--drivers/gpu/drm/radeon/cikd.h1
-rw-r--r--drivers/gpu/drm/radeon/radeon.h1
-rw-r--r--drivers/gpu/drm/radeon/radeon_bios.c10
-rw-r--r--drivers/gpu/drm/radeon/radeon_mn.c11
-rw-r--r--drivers/gpu/drm/radeon/radeon_pm.c22
-rw-r--r--drivers/gpu/drm/radeon/radeon_ring.c2
-rw-r--r--drivers/gpu/drm/radeon/radeon_ttm.c4
-rw-r--r--drivers/gpu/drm/radeon/vce_v2_0.c3
-rw-r--r--drivers/i2c/busses/i2c-designware-platdrv.c4
-rw-r--r--drivers/i2c/i2c-core.c4
-rw-r--r--drivers/ide/ide-pnp.c14
-rw-r--r--drivers/idle/intel_idle.c68
-rw-r--r--drivers/iio/accel/bma180.c2
-rw-r--r--drivers/iio/accel/bmc150-accel.c20
-rw-r--r--drivers/iio/accel/kxcjk-1013.c2
-rw-r--r--drivers/iio/adc/Kconfig3
-rw-r--r--drivers/iio/adc/at91_adc.c5
-rw-r--r--drivers/iio/adc/ti_am335x_adc.c3
-rw-r--r--drivers/iio/adc/vf610_adc.c91
-rw-r--r--drivers/iio/gyro/bmg160.c2
-rw-r--r--drivers/iio/imu/adis_trigger.c2
-rw-r--r--drivers/iio/imu/inv_mpu6050/inv_mpu_core.c56
-rw-r--r--drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c25
-rw-r--r--drivers/iio/imu/kmx61.c2
-rw-r--r--drivers/iio/industrialio-core.c5
-rw-r--r--drivers/iio/industrialio-event.c1
-rw-r--r--drivers/iio/proximity/sx9500.c2
-rw-r--r--drivers/infiniband/core/umem.c8
-rw-r--r--drivers/input/mouse/alps.c48
-rw-r--r--drivers/input/mouse/synaptics.c7
-rw-r--r--drivers/iommu/arm-smmu.c9
-rw-r--r--drivers/iommu/intel-iommu.c9
-rw-r--r--drivers/iommu/ipmmu-vmsa.c1
-rw-r--r--drivers/irqchip/irq-gic-v3-its.c57
-rw-r--r--drivers/lguest/Kconfig2
-rw-r--r--drivers/media/dvb-frontends/rtl2832.c2
-rw-r--r--drivers/media/pci/cx23885/cx23885-417.c13
-rw-r--r--drivers/media/platform/s5p-jpeg/jpeg-core.c3
-rw-r--r--drivers/media/platform/s5p-jpeg/jpeg-hw-exynos3250.c2
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc.c1
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc_common.h2
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc_opr.h2
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc_opr_v5.c6
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c6
-rw-r--r--drivers/media/platform/s5p-tv/Kconfig1
-rw-r--r--drivers/media/platform/sh_veu.c1
-rw-r--r--drivers/media/platform/soc_camera/atmel-isi.c2
-rw-r--r--drivers/media/platform/soc_camera/soc_camera.c2
-rw-r--r--drivers/media/rc/ene_ir.c13
-rw-r--r--drivers/media/rc/fintek-cir.c13
-rw-r--r--drivers/media/rc/ite-cir.c13
-rw-r--r--drivers/media/rc/nuvoton-cir.c13
-rw-r--r--drivers/media/usb/dvb-usb-v2/rtl28xxu.c2
-rw-r--r--drivers/media/usb/gspca/Kconfig1
-rw-r--r--drivers/media/v4l2-core/videobuf2-core.c11
-rw-r--r--drivers/media/v4l2-core/videobuf2-dma-contig.c3
-rw-r--r--drivers/misc/enclosure.c11
-rw-r--r--drivers/net/bonding/bond_main.c3
-rw-r--r--drivers/net/can/flexcan.c18
-rw-r--r--drivers/net/can/usb/gs_usb.c2
-rw-r--r--drivers/net/can/usb/kvaser_usb.c69
-rw-r--r--drivers/net/can/usb/peak_usb/pcan_ucan.h15
-rw-r--r--drivers/net/can/usb/peak_usb/pcan_usb_fd.c73
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x.h4
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c99
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c4
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c162
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.h6
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/cxgb4.h14
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c8
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c137
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/sge.c7
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/t4_hw.c53
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/t4_regs.h3
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h39
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/t4fw_version.h8
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4vf/sge.c12
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c6
-rw-r--r--drivers/net/ethernet/freescale/fec_main.c30
-rw-r--r--drivers/net/ethernet/freescale/ucc_geth.c3
-rw-r--r--drivers/net/ethernet/marvell/mvneta.c7
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/cmd.c5
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_netdev.c15
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/eq.c18
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/resource_tracker.c6
-rw-r--r--drivers/net/ethernet/rocker/rocker.c8
-rw-r--r--drivers/net/ipvlan/ipvlan.h4
-rw-r--r--drivers/net/ipvlan/ipvlan_core.c28
-rw-r--r--drivers/net/ipvlan/ipvlan_main.c30
-rw-r--r--drivers/net/sb1000.c15
-rw-r--r--drivers/net/usb/asix_common.c2
-rw-r--r--drivers/net/usb/cdc_ether.c8
-rw-r--r--drivers/net/usb/cdc_ncm.c6
-rw-r--r--drivers/net/usb/r8152.c2
-rw-r--r--drivers/net/usb/sr9800.c1
-rw-r--r--drivers/net/usb/usbnet.c17
-rw-r--r--drivers/net/wireless/ath/ath9k/beacon.c20
-rw-r--r--drivers/net/wireless/ath/ath9k/common.h2
-rw-r--r--drivers/net/wireless/ath/ath9k/hw.c2
-rw-r--r--drivers/net/wireless/brcm80211/brcmfmac/feature.c3
-rw-r--r--drivers/net/wireless/iwlwifi/dvm/dev.h1
-rw-r--r--drivers/net/wireless/iwlwifi/dvm/mac80211.c17
-rw-r--r--drivers/net/wireless/iwlwifi/dvm/ucode.c5
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-drv.c1
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/rs.c24
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/time-event.c2
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/tx.c6
-rw-r--r--drivers/net/wireless/iwlwifi/pcie/drv.c6
-rw-r--r--drivers/net/wireless/rtlwifi/pci.c12
-rw-r--r--drivers/net/xen-netfront.c5
-rw-r--r--drivers/of/address.c11
-rw-r--r--drivers/pci/host/pcie-designware.c2
-rw-r--r--drivers/pci/host/pcie-spear13xx.c6
-rw-r--r--drivers/pci/hotplug/cpci_hotplug_pci.c3
-rw-r--r--drivers/pci/pci-acpi.c3
-rw-r--r--drivers/pci/pcie/aer/aerdrv_errprint.c12
-rw-r--r--drivers/platform/x86/apple-gmux.c14
-rw-r--r--drivers/pnp/base.h2
-rw-r--r--drivers/pnp/card.c25
-rw-r--r--drivers/pnp/core.c64
-rw-r--r--drivers/pnp/driver.c10
-rw-r--r--drivers/pnp/pnpacpi/core.c5
-rw-r--r--drivers/powercap/intel_rapl.c3
-rw-r--r--drivers/scsi/be2iscsi/be_main.c2
-rw-r--r--drivers/scsi/scsi_lib.c4
-rw-r--r--drivers/staging/iio/Kconfig1
-rw-r--r--drivers/staging/iio/magnetometer/hmc5843_core.c1
-rw-r--r--drivers/target/iscsi/iscsi_target.c11
-rw-r--r--drivers/target/target_core_device.c4
-rw-r--r--drivers/thermal/st/st_thermal.c2
-rw-r--r--drivers/thermal/st/st_thermal_memmap.c10
-rw-r--r--drivers/thermal/st/st_thermal_syscfg.c14
-rw-r--r--drivers/thermal/thermal_core.c6
-rw-r--r--drivers/tty/serial/8250/8250_fintek.c13
-rw-r--r--drivers/tty/serial/fsl_lpuart.c5
-rw-r--r--drivers/tty/serial/samsung.c1
-rw-r--r--drivers/usb/host/xhci-hub.c9
-rw-r--r--drivers/usb/host/xhci-pci.c2
-rw-r--r--drivers/usb/isp1760/isp1760-udc.c2
-rw-r--r--drivers/usb/serial/ftdi_sio.c9
-rw-r--r--drivers/usb/serial/ftdi_sio_ids.h6
-rw-r--r--drivers/usb/serial/keyspan_pda.c3
-rw-r--r--drivers/watchdog/iTCO_wdt.c51
-rw-r--r--drivers/xen/Kconfig17
-rw-r--r--drivers/xen/balloon.c23
-rw-r--r--fs/aio.c20
-rw-r--r--fs/cifs/cifsencrypt.c6
-rw-r--r--fs/cifs/connect.c13
-rw-r--r--fs/cifs/file.c1
-rw-r--r--fs/cifs/inode.c2
-rw-r--r--fs/cifs/smb2misc.c2
-rw-r--r--fs/cifs/smb2ops.c3
-rw-r--r--fs/cifs/smb2pdu.c17
-rw-r--r--fs/fs-writeback.c93
-rw-r--r--fs/locks.c5
-rw-r--r--fs/nfsd/blocklayout.c2
-rw-r--r--fs/nfsd/blocklayoutxdr.c6
-rw-r--r--fs/nfsd/nfs4layouts.c12
-rw-r--r--fs/nfsd/nfs4proc.c2
-rw-r--r--fs/nfsd/nfs4state.c4
-rw-r--r--fs/nfsd/nfs4xdr.c20
-rw-r--r--fs/nfsd/nfscache.c6
-rw-r--r--fs/ocfs2/file.c17
-rw-r--r--include/acpi/acpi_bus.h4
-rw-r--r--include/asm-generic/vmlinux.lds.h2
-rw-r--r--include/linux/acpi.h15
-rw-r--r--include/linux/blk_types.h4
-rw-r--r--include/linux/cpuidle.h1
-rw-r--r--include/linux/device.h16
-rw-r--r--include/linux/dmapool.h2
-rw-r--r--include/linux/fs.h3
-rw-r--r--include/linux/fwnode.h27
-rw-r--r--include/linux/i2c.h4
-rw-r--r--include/linux/irqchip/arm-gic-v3.h17
-rw-r--r--include/linux/lcm.h1
-rw-r--r--include/linux/mmzone.h7
-rw-r--r--include/linux/netdevice.h6
-rw-r--r--include/linux/platform_device.h2
-rw-r--r--include/linux/pm-trace.h (renamed from include/linux/resume-trace.h)9
-rw-r--r--include/linux/pm.h8
-rw-r--r--include/linux/pm_domain.h6
-rw-r--r--include/linux/pnp.h12
-rw-r--r--include/linux/property.h44
-rw-r--r--include/linux/sunrpc/debug.h18
-rw-r--r--include/linux/usb/usbnet.h16
-rw-r--r--include/linux/writeback.h3
-rw-r--r--include/media/atmel-isi.h4
-rw-r--r--include/net/ip.h16
-rw-r--r--include/net/ip6_route.h3
-rw-r--r--include/net/sock.h2
-rw-r--r--include/uapi/linux/input.h3
-rw-r--r--include/uapi/linux/nfsd/export.h2
-rw-r--r--kernel/module.c19
-rw-r--r--kernel/power/main.c2
-rw-r--r--kernel/power/snapshot.c21
-rw-r--r--kernel/power/suspend.c13
-rw-r--r--kernel/sched/fair.c4
-rw-r--r--kernel/sysctl.c8
-rw-r--r--lib/lcm.c11
-rw-r--r--lib/nlattr.c2
-rw-r--r--mm/mremap.c10
-rw-r--r--net/ceph/messenger.c9
-rw-r--r--net/core/dev.c4
-rw-r--r--net/core/fib_rules.c2
-rw-r--r--net/core/net_namespace.c4
-rw-r--r--net/core/rtnetlink.c4
-rw-r--r--net/core/sock.c19
-rw-r--r--net/decnet/dn_rules.c2
-rw-r--r--net/dsa/dsa.c23
-rw-r--r--net/ipv4/fib_frontend.c3
-rw-r--r--net/ipv4/ipmr.c7
-rw-r--r--net/ipv4/tcp_input.c7
-rw-r--r--net/ipv4/tcp_ipv4.c2
-rw-r--r--net/ipv6/fib6_rules.c2
-rw-r--r--net/ipv6/ip6_output.c3
-rw-r--r--net/ipv6/ip6mr.c6
-rw-r--r--net/ipv6/ndisc.c9
-rw-r--r--net/ipv6/tcp_ipv6.c13
-rw-r--r--net/iucv/af_iucv.c4
-rw-r--r--net/l2tp/l2tp_core.c1
-rw-r--r--net/mac80211/agg-rx.c8
-rw-r--r--net/mac80211/rx.c7
-rw-r--r--net/mac80211/sta_info.h2
-rw-r--r--net/openvswitch/vport.c4
-rw-r--r--net/sunrpc/clnt.c4
-rw-r--r--net/sunrpc/debugfs.c52
-rw-r--r--net/sunrpc/sunrpc_syms.c7
-rw-r--r--net/sunrpc/xprt.c7
-rw-r--r--net/tipc/core.c2
-rw-r--r--sound/firewire/bebob/bebob_maudio.c8
-rw-r--r--sound/pci/hda/patch_realtek.c27
-rw-r--r--sound/soc/codecs/pcm512x.c19
-rw-r--r--sound/usb/mixer_quirks.c1
-rw-r--r--sound/usb/quirks.c9
343 files changed, 3391 insertions, 1652 deletions
diff --git a/Documentation/acpi/enumeration.txt b/Documentation/acpi/enumeration.txt
index 9b121a569ab4..750401f91341 100644
--- a/Documentation/acpi/enumeration.txt
+++ b/Documentation/acpi/enumeration.txt
@@ -254,8 +254,13 @@ GPIO support
254~~~~~~~~~~~~ 254~~~~~~~~~~~~
255ACPI 5 introduced two new resources to describe GPIO connections: GpioIo 255ACPI 5 introduced two new resources to describe GPIO connections: GpioIo
256and GpioInt. These resources are used be used to pass GPIO numbers used by 256and GpioInt. These resources are used be used to pass GPIO numbers used by
257the device to the driver. For example: 257the device to the driver. ACPI 5.1 extended this with _DSD (Device
258Specific Data) which made it possible to name the GPIOs among other things.
258 259
260For example:
261
262Device (DEV)
263{
259 Method (_CRS, 0, NotSerialized) 264 Method (_CRS, 0, NotSerialized)
260 { 265 {
261 Name (SBUF, ResourceTemplate() 266 Name (SBUF, ResourceTemplate()
@@ -285,6 +290,18 @@ the device to the driver. For example:
285 Return (SBUF) 290 Return (SBUF)
286 } 291 }
287 292
293 // ACPI 5.1 _DSD used for naming the GPIOs
294 Name (_DSD, Package ()
295 {
296 ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
297 Package ()
298 {
299 Package () {"power-gpios", Package() {^DEV, 0, 0, 0 }},
300 Package () {"irq-gpios", Package() {^DEV, 1, 0, 0 }},
301 }
302 })
303 ...
304
288These GPIO numbers are controller relative and path "\\_SB.PCI0.GPI0" 305These GPIO numbers are controller relative and path "\\_SB.PCI0.GPI0"
289specifies the path to the controller. In order to use these GPIOs in Linux 306specifies the path to the controller. In order to use these GPIOs in Linux
290we need to translate them to the corresponding Linux GPIO descriptors. 307we need to translate them to the corresponding Linux GPIO descriptors.
@@ -300,11 +317,11 @@ a code like this:
300 317
301 struct gpio_desc *irq_desc, *power_desc; 318 struct gpio_desc *irq_desc, *power_desc;
302 319
303 irq_desc = gpiod_get_index(dev, NULL, 1); 320 irq_desc = gpiod_get(dev, "irq");
304 if (IS_ERR(irq_desc)) 321 if (IS_ERR(irq_desc))
305 /* handle error */ 322 /* handle error */
306 323
307 power_desc = gpiod_get_index(dev, NULL, 0); 324 power_desc = gpiod_get(dev, "power");
308 if (IS_ERR(power_desc)) 325 if (IS_ERR(power_desc))
309 /* handle error */ 326 /* handle error */
310 327
@@ -313,6 +330,9 @@ a code like this:
313There are also devm_* versions of these functions which release the 330There are also devm_* versions of these functions which release the
314descriptors once the device is released. 331descriptors once the device is released.
315 332
333See Documentation/acpi/gpio-properties.txt for more information about the
334_DSD binding related to GPIOs.
335
316MFD devices 336MFD devices
317~~~~~~~~~~~ 337~~~~~~~~~~~
318The MFD devices register their children as platform devices. For the child 338The MFD devices register their children as platform devices. For the child
diff --git a/Documentation/devicetree/bindings/net/dsa/dsa.txt b/Documentation/devicetree/bindings/net/dsa/dsa.txt
index e124847443f8..f0b4cd72411d 100644
--- a/Documentation/devicetree/bindings/net/dsa/dsa.txt
+++ b/Documentation/devicetree/bindings/net/dsa/dsa.txt
@@ -19,7 +19,9 @@ the parent DSA node. The maximum number of allowed child nodes is 4
19(DSA_MAX_SWITCHES). 19(DSA_MAX_SWITCHES).
20Each of these switch child nodes should have the following required properties: 20Each of these switch child nodes should have the following required properties:
21 21
22- reg : Describes the switch address on the MII bus 22- reg : Contains two fields. The first one describes the
23 address on the MII bus. The second is the switch
24 number that must be unique in cascaded configurations
23- #address-cells : Must be 1 25- #address-cells : Must be 1
24- #size-cells : Must be 0 26- #size-cells : Must be 0
25 27
diff --git a/Documentation/devicetree/bindings/thermal/rcar-thermal.txt b/Documentation/devicetree/bindings/thermal/rcar-thermal.txt
index 43404b197933..332e625f6ed0 100644
--- a/Documentation/devicetree/bindings/thermal/rcar-thermal.txt
+++ b/Documentation/devicetree/bindings/thermal/rcar-thermal.txt
@@ -4,7 +4,7 @@ Required properties:
4- compatible : "renesas,thermal-<soctype>", "renesas,rcar-thermal" 4- compatible : "renesas,thermal-<soctype>", "renesas,rcar-thermal"
5 as fallback. 5 as fallback.
6 Examples with soctypes are: 6 Examples with soctypes are:
7 - "renesas,thermal-r8a73a4" (R-Mobile AP6) 7 - "renesas,thermal-r8a73a4" (R-Mobile APE6)
8 - "renesas,thermal-r8a7779" (R-Car H1) 8 - "renesas,thermal-r8a7779" (R-Car H1)
9 - "renesas,thermal-r8a7790" (R-Car H2) 9 - "renesas,thermal-r8a7790" (R-Car H2)
10 - "renesas,thermal-r8a7791" (R-Car M2-W) 10 - "renesas,thermal-r8a7791" (R-Car M2-W)
diff --git a/Documentation/input/alps.txt b/Documentation/input/alps.txt
index a63e5e013a8c..92ae734c00c3 100644
--- a/Documentation/input/alps.txt
+++ b/Documentation/input/alps.txt
@@ -114,6 +114,9 @@ ALPS Absolute Mode - Protocol Version 2
114 byte 4: 0 y6 y5 y4 y3 y2 y1 y0 114 byte 4: 0 y6 y5 y4 y3 y2 y1 y0
115 byte 5: 0 z6 z5 z4 z3 z2 z1 z0 115 byte 5: 0 z6 z5 z4 z3 z2 z1 z0
116 116
117Protocol Version 2 DualPoint devices send standard PS/2 mouse packets for
118the DualPoint Stick.
119
117Dualpoint device -- interleaved packet format 120Dualpoint device -- interleaved packet format
118--------------------------------------------- 121---------------------------------------------
119 122
@@ -127,6 +130,11 @@ Dualpoint device -- interleaved packet format
127 byte 7: 0 y6 y5 y4 y3 y2 y1 y0 130 byte 7: 0 y6 y5 y4 y3 y2 y1 y0
128 byte 8: 0 z6 z5 z4 z3 z2 z1 z0 131 byte 8: 0 z6 z5 z4 z3 z2 z1 z0
129 132
133Devices which use the interleaving format normally send standard PS/2 mouse
134packets for the DualPoint Stick + ALPS Absolute Mode packets for the
135touchpad, switching to the interleaved packet format when both the stick and
136the touchpad are used at the same time.
137
130ALPS Absolute Mode - Protocol Version 3 138ALPS Absolute Mode - Protocol Version 3
131--------------------------------------- 139---------------------------------------
132 140
diff --git a/Documentation/input/event-codes.txt b/Documentation/input/event-codes.txt
index c587a966413e..96705616f582 100644
--- a/Documentation/input/event-codes.txt
+++ b/Documentation/input/event-codes.txt
@@ -294,6 +294,12 @@ accordingly. This property does not affect kernel behavior.
294The kernel does not provide button emulation for such devices but treats 294The kernel does not provide button emulation for such devices but treats
295them as any other INPUT_PROP_BUTTONPAD device. 295them as any other INPUT_PROP_BUTTONPAD device.
296 296
297INPUT_PROP_ACCELEROMETER
298-------------------------
299Directional axes on this device (absolute and/or relative x, y, z) represent
300accelerometer data. All other axes retain their meaning. A device must not mix
301regular directional axes and accelerometer axes on the same event node.
302
297Guidelines: 303Guidelines:
298========== 304==========
299The guidelines below ensure proper single-touch and multi-finger functionality. 305The guidelines below ensure proper single-touch and multi-finger functionality.
diff --git a/Documentation/input/multi-touch-protocol.txt b/Documentation/input/multi-touch-protocol.txt
index 7b4f59c09ee2..b85d000faeb4 100644
--- a/Documentation/input/multi-touch-protocol.txt
+++ b/Documentation/input/multi-touch-protocol.txt
@@ -312,9 +312,12 @@ ABS_MT_TOOL_TYPE
312 312
313The type of approaching tool. A lot of kernel drivers cannot distinguish 313The type of approaching tool. A lot of kernel drivers cannot distinguish
314between different tool types, such as a finger or a pen. In such cases, the 314between different tool types, such as a finger or a pen. In such cases, the
315event should be omitted. The protocol currently supports MT_TOOL_FINGER and 315event should be omitted. The protocol currently supports MT_TOOL_FINGER,
316MT_TOOL_PEN [2]. For type B devices, this event is handled by input core; 316MT_TOOL_PEN, and MT_TOOL_PALM [2]. For type B devices, this event is handled
317drivers should instead use input_mt_report_slot_state(). 317by input core; drivers should instead use input_mt_report_slot_state().
318A contact's ABS_MT_TOOL_TYPE may change over time while still touching the
319device, because the firmware may not be able to determine which tool is being
320used when it first appears.
318 321
319ABS_MT_BLOB_ID 322ABS_MT_BLOB_ID
320 323
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index bfcb1a62a7b4..8b1fa5e129ac 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -3462,6 +3462,13 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
3462 improve throughput, but will also increase the 3462 improve throughput, but will also increase the
3463 amount of memory reserved for use by the client. 3463 amount of memory reserved for use by the client.
3464 3464
3465 suspend.pm_test_delay=
3466 [SUSPEND]
3467 Sets the number of seconds to remain in a suspend test
3468 mode before resuming the system (see
3469 /sys/power/pm_test). Only available when CONFIG_PM_DEBUG
3470 is set. Default value is 5.
3471
3465 swapaccount=[0|1] 3472 swapaccount=[0|1]
3466 [KNL] Enable accounting of swap in memory resource 3473 [KNL] Enable accounting of swap in memory resource
3467 controller if no parameter or 1 is given or disable 3474 controller if no parameter or 1 is given or disable
diff --git a/Documentation/power/basic-pm-debugging.txt b/Documentation/power/basic-pm-debugging.txt
index edeecd447d23..b96098ccfe69 100644
--- a/Documentation/power/basic-pm-debugging.txt
+++ b/Documentation/power/basic-pm-debugging.txt
@@ -75,12 +75,14 @@ you should do the following:
75# echo platform > /sys/power/disk 75# echo platform > /sys/power/disk
76# echo disk > /sys/power/state 76# echo disk > /sys/power/state
77 77
78Then, the kernel will try to freeze processes, suspend devices, wait 5 seconds, 78Then, the kernel will try to freeze processes, suspend devices, wait a few
79resume devices and thaw processes. If "platform" is written to 79seconds (5 by default, but configurable by the suspend.pm_test_delay module
80parameter), resume devices and thaw processes. If "platform" is written to
80/sys/power/pm_test , then after suspending devices the kernel will additionally 81/sys/power/pm_test , then after suspending devices the kernel will additionally
81invoke the global control methods (eg. ACPI global control methods) used to 82invoke the global control methods (eg. ACPI global control methods) used to
82prepare the platform firmware for hibernation. Next, it will wait 5 seconds and 83prepare the platform firmware for hibernation. Next, it will wait a
83invoke the platform (eg. ACPI) global methods used to cancel hibernation etc. 84configurable number of seconds and invoke the platform (eg. ACPI) global
85methods used to cancel hibernation etc.
84 86
85Writing "none" to /sys/power/pm_test causes the kernel to switch to the normal 87Writing "none" to /sys/power/pm_test causes the kernel to switch to the normal
86hibernation/suspend operations. Also, when open for reading, /sys/power/pm_test 88hibernation/suspend operations. Also, when open for reading, /sys/power/pm_test
diff --git a/MAINTAINERS b/MAINTAINERS
index 1de6afa8ee51..83f9bb3eaf36 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -637,8 +637,7 @@ F: drivers/gpu/drm/radeon/radeon_kfd.h
637F: include/uapi/linux/kfd_ioctl.h 637F: include/uapi/linux/kfd_ioctl.h
638 638
639AMD MICROCODE UPDATE SUPPORT 639AMD MICROCODE UPDATE SUPPORT
640M: Andreas Herrmann <herrmann.der.user@googlemail.com> 640M: Borislav Petkov <bp@alien8.de>
641L: amd64-microcode@amd64.org
642S: Maintained 641S: Maintained
643F: arch/x86/kernel/cpu/microcode/amd* 642F: arch/x86/kernel/cpu/microcode/amd*
644 643
@@ -4313,6 +4312,15 @@ S: Supported
4313F: drivers/phy/ 4312F: drivers/phy/
4314F: include/linux/phy/ 4313F: include/linux/phy/
4315 4314
4315GENERIC PM DOMAINS
4316M: "Rafael J. Wysocki" <rjw@rjwysocki.net>
4317M: Kevin Hilman <khilman@kernel.org>
4318M: Ulf Hansson <ulf.hansson@linaro.org>
4319L: linux-pm@vger.kernel.org
4320S: Supported
4321F: drivers/base/power/domain*.c
4322F: include/linux/pm_domain.h
4323
4316GENERIC UIO DRIVER FOR PCI DEVICES 4324GENERIC UIO DRIVER FOR PCI DEVICES
4317M: "Michael S. Tsirkin" <mst@redhat.com> 4325M: "Michael S. Tsirkin" <mst@redhat.com>
4318L: kvm@vger.kernel.org 4326L: kvm@vger.kernel.org
@@ -5095,7 +5103,7 @@ S: Supported
5095F: drivers/platform/x86/intel_menlow.c 5103F: drivers/platform/x86/intel_menlow.c
5096 5104
5097INTEL IA32 MICROCODE UPDATE SUPPORT 5105INTEL IA32 MICROCODE UPDATE SUPPORT
5098M: Tigran Aivazian <tigran@aivazian.fsnet.co.uk> 5106M: Borislav Petkov <bp@alien8.de>
5099S: Maintained 5107S: Maintained
5100F: arch/x86/kernel/cpu/microcode/core* 5108F: arch/x86/kernel/cpu/microcode/core*
5101F: arch/x86/kernel/cpu/microcode/intel* 5109F: arch/x86/kernel/cpu/microcode/intel*
@@ -5136,22 +5144,21 @@ M: Deepak Saxena <dsaxena@plexity.net>
5136S: Maintained 5144S: Maintained
5137F: drivers/char/hw_random/ixp4xx-rng.c 5145F: drivers/char/hw_random/ixp4xx-rng.c
5138 5146
5139INTEL ETHERNET DRIVERS (e100/e1000/e1000e/fm10k/igb/igbvf/ixgb/ixgbe/ixgbevf/i40e/i40evf) 5147INTEL ETHERNET DRIVERS
5140M: Jeff Kirsher <jeffrey.t.kirsher@intel.com> 5148M: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
5141M: Jesse Brandeburg <jesse.brandeburg@intel.com> 5149R: Jesse Brandeburg <jesse.brandeburg@intel.com>
5142M: Bruce Allan <bruce.w.allan@intel.com> 5150R: Shannon Nelson <shannon.nelson@intel.com>
5143M: Carolyn Wyborny <carolyn.wyborny@intel.com> 5151R: Carolyn Wyborny <carolyn.wyborny@intel.com>
5144M: Don Skidmore <donald.c.skidmore@intel.com> 5152R: Don Skidmore <donald.c.skidmore@intel.com>
5145M: Greg Rose <gregory.v.rose@intel.com> 5153R: Matthew Vick <matthew.vick@intel.com>
5146M: Matthew Vick <matthew.vick@intel.com> 5154R: John Ronciak <john.ronciak@intel.com>
5147M: John Ronciak <john.ronciak@intel.com> 5155R: Mitch Williams <mitch.a.williams@intel.com>
5148M: Mitch Williams <mitch.a.williams@intel.com> 5156L: intel-wired-lan@lists.osuosl.org
5149M: Linux NICS <linux.nics@intel.com>
5150L: e1000-devel@lists.sourceforge.net
5151W: http://www.intel.com/support/feedback.htm 5157W: http://www.intel.com/support/feedback.htm
5152W: http://e1000.sourceforge.net/ 5158W: http://e1000.sourceforge.net/
5153T: git git://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/net.git 5159Q: http://patchwork.ozlabs.org/project/intel-wired-lan/list/
5154T: git git://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/net-next.git 5160T: git git://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/net-queue.git
5161T: git git://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/next-queue.git
5155S: Supported 5162S: Supported
5156F: Documentation/networking/e100.txt 5163F: Documentation/networking/e100.txt
5157F: Documentation/networking/e1000.txt 5164F: Documentation/networking/e1000.txt
diff --git a/Makefile b/Makefile
index da36a3be7969..fbd43bfe4445 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
1VERSION = 4 1VERSION = 4
2PATCHLEVEL = 0 2PATCHLEVEL = 0
3SUBLEVEL = 0 3SUBLEVEL = 0
4EXTRAVERSION = -rc6 4EXTRAVERSION =
5NAME = Hurr durr I'ma sheep 5NAME = Hurr durr I'ma sheep
6 6
7# *DOCUMENTATION* 7# *DOCUMENTATION*
diff --git a/arch/arm/include/asm/cpuidle.h b/arch/arm/include/asm/cpuidle.h
index af319ac4960c..0f8424924902 100644
--- a/arch/arm/include/asm/cpuidle.h
+++ b/arch/arm/include/asm/cpuidle.h
@@ -1,6 +1,8 @@
1#ifndef __ASM_ARM_CPUIDLE_H 1#ifndef __ASM_ARM_CPUIDLE_H
2#define __ASM_ARM_CPUIDLE_H 2#define __ASM_ARM_CPUIDLE_H
3 3
4#include <asm/proc-fns.h>
5
4#ifdef CONFIG_CPU_IDLE 6#ifdef CONFIG_CPU_IDLE
5extern int arm_cpuidle_simple_enter(struct cpuidle_device *dev, 7extern int arm_cpuidle_simple_enter(struct cpuidle_device *dev,
6 struct cpuidle_driver *drv, int index); 8 struct cpuidle_driver *drv, int index);
@@ -25,4 +27,25 @@ static inline int arm_cpuidle_simple_enter(struct cpuidle_device *dev,
25 */ 27 */
26#define ARM_CPUIDLE_WFI_STATE ARM_CPUIDLE_WFI_STATE_PWR(UINT_MAX) 28#define ARM_CPUIDLE_WFI_STATE ARM_CPUIDLE_WFI_STATE_PWR(UINT_MAX)
27 29
30struct device_node;
31
32struct cpuidle_ops {
33 int (*suspend)(int cpu, unsigned long arg);
34 int (*init)(struct device_node *, int cpu);
35};
36
37struct of_cpuidle_method {
38 const char *method;
39 struct cpuidle_ops *ops;
40};
41
42#define CPUIDLE_METHOD_OF_DECLARE(name, _method, _ops) \
43 static const struct of_cpuidle_method __cpuidle_method_of_table_##name \
44 __used __section(__cpuidle_method_of_table) \
45 = { .method = _method, .ops = _ops }
46
47extern int arm_cpuidle_suspend(int index);
48
49extern int arm_cpuidle_init(int cpu);
50
28#endif 51#endif
diff --git a/arch/arm/kernel/cpuidle.c b/arch/arm/kernel/cpuidle.c
index 89545f6c8403..318da33465f4 100644
--- a/arch/arm/kernel/cpuidle.c
+++ b/arch/arm/kernel/cpuidle.c
@@ -10,8 +10,28 @@
10 */ 10 */
11 11
12#include <linux/cpuidle.h> 12#include <linux/cpuidle.h>
13#include <asm/proc-fns.h> 13#include <linux/of.h>
14#include <linux/of_device.h>
15#include <asm/cpuidle.h>
14 16
17extern struct of_cpuidle_method __cpuidle_method_of_table[];
18
19static const struct of_cpuidle_method __cpuidle_method_of_table_sentinel
20 __used __section(__cpuidle_method_of_table_end);
21
22static struct cpuidle_ops cpuidle_ops[NR_CPUS];
23
24/**
25 * arm_cpuidle_simple_enter() - a wrapper to cpu_do_idle()
26 * @dev: not used
27 * @drv: not used
28 * @index: not used
29 *
30 * A trivial wrapper to allow the cpu_do_idle function to be assigned as a
31 * cpuidle callback by matching the function signature.
32 *
33 * Returns the index passed as parameter
34 */
15int arm_cpuidle_simple_enter(struct cpuidle_device *dev, 35int arm_cpuidle_simple_enter(struct cpuidle_device *dev,
16 struct cpuidle_driver *drv, int index) 36 struct cpuidle_driver *drv, int index)
17{ 37{
@@ -19,3 +39,114 @@ int arm_cpuidle_simple_enter(struct cpuidle_device *dev,
19 39
20 return index; 40 return index;
21} 41}
42
43/**
44 * arm_cpuidle_suspend() - function to enter low power idle states
45 * @index: an integer used as an identifier for the low level PM callbacks
46 *
47 * This function calls the underlying arch specific low level PM code as
48 * registered at the init time.
49 *
50 * Returns -EOPNOTSUPP if no suspend callback is defined, the result of the
51 * callback otherwise.
52 */
53int arm_cpuidle_suspend(int index)
54{
55 int ret = -EOPNOTSUPP;
56 int cpu = smp_processor_id();
57
58 if (cpuidle_ops[cpu].suspend)
59 ret = cpuidle_ops[cpu].suspend(cpu, index);
60
61 return ret;
62}
63
64/**
65 * arm_cpuidle_get_ops() - find a registered cpuidle_ops by name
66 * @method: the method name
67 *
68 * Search in the __cpuidle_method_of_table array the cpuidle ops matching the
69 * method name.
70 *
71 * Returns a struct cpuidle_ops pointer, NULL if not found.
72 */
73static struct cpuidle_ops *__init arm_cpuidle_get_ops(const char *method)
74{
75 struct of_cpuidle_method *m = __cpuidle_method_of_table;
76
77 for (; m->method; m++)
78 if (!strcmp(m->method, method))
79 return m->ops;
80
81 return NULL;
82}
83
84/**
85 * arm_cpuidle_read_ops() - Initialize the cpuidle ops with the device tree
86 * @dn: a pointer to a struct device node corresponding to a cpu node
87 * @cpu: the cpu identifier
88 *
89 * Get the method name defined in the 'enable-method' property, retrieve the
90 * associated cpuidle_ops and do a struct copy. This copy is needed because all
91 * cpuidle_ops are tagged __initdata and will be unloaded after the init
92 * process.
93 *
94 * Return 0 on sucess, -ENOENT if no 'enable-method' is defined, -EOPNOTSUPP if
95 * no cpuidle_ops is registered for the 'enable-method'.
96 */
97static int __init arm_cpuidle_read_ops(struct device_node *dn, int cpu)
98{
99 const char *enable_method;
100 struct cpuidle_ops *ops;
101
102 enable_method = of_get_property(dn, "enable-method", NULL);
103 if (!enable_method)
104 return -ENOENT;
105
106 ops = arm_cpuidle_get_ops(enable_method);
107 if (!ops) {
108 pr_warn("%s: unsupported enable-method property: %s\n",
109 dn->full_name, enable_method);
110 return -EOPNOTSUPP;
111 }
112
113 cpuidle_ops[cpu] = *ops; /* structure copy */
114
115 pr_notice("cpuidle: enable-method property '%s'"
116 " found operations\n", enable_method);
117
118 return 0;
119}
120
121/**
122 * arm_cpuidle_init() - Initialize cpuidle_ops for a specific cpu
123 * @cpu: the cpu to be initialized
124 *
125 * Initialize the cpuidle ops with the device for the cpu and then call
126 * the cpu's idle initialization callback. This may fail if the underlying HW
127 * is not operational.
128 *
129 * Returns:
130 * 0 on success,
131 * -ENODEV if it fails to find the cpu node in the device tree,
132 * -EOPNOTSUPP if it does not find a registered cpuidle_ops for this cpu,
133 * -ENOENT if it fails to find an 'enable-method' property,
134 * -ENXIO if the HW reports a failure or a misconfiguration,
135 * -ENOMEM if the HW report an memory allocation failure
136 */
137int __init arm_cpuidle_init(int cpu)
138{
139 struct device_node *cpu_node = of_cpu_device_node_get(cpu);
140 int ret;
141
142 if (!cpu_node)
143 return -ENODEV;
144
145 ret = arm_cpuidle_read_ops(cpu_node, cpu);
146 if (!ret && cpuidle_ops[cpu].init)
147 ret = cpuidle_ops[cpu].init(cpu_node, cpu);
148
149 of_node_put(cpu_node);
150
151 return ret;
152}
diff --git a/arch/arm/mach-davinci/cpuidle.c b/arch/arm/mach-davinci/cpuidle.c
index e365c1bb1265..306ebc51599a 100644
--- a/arch/arm/mach-davinci/cpuidle.c
+++ b/arch/arm/mach-davinci/cpuidle.c
@@ -17,7 +17,6 @@
17#include <linux/cpuidle.h> 17#include <linux/cpuidle.h>
18#include <linux/io.h> 18#include <linux/io.h>
19#include <linux/export.h> 19#include <linux/export.h>
20#include <asm/proc-fns.h>
21#include <asm/cpuidle.h> 20#include <asm/cpuidle.h>
22 21
23#include <mach/cpuidle.h> 22#include <mach/cpuidle.h>
diff --git a/arch/arm/mach-imx/cpuidle-imx6q.c b/arch/arm/mach-imx/cpuidle-imx6q.c
index d76d08623f9f..8e21ccc1eda2 100644
--- a/arch/arm/mach-imx/cpuidle-imx6q.c
+++ b/arch/arm/mach-imx/cpuidle-imx6q.c
@@ -9,7 +9,6 @@
9#include <linux/cpuidle.h> 9#include <linux/cpuidle.h>
10#include <linux/module.h> 10#include <linux/module.h>
11#include <asm/cpuidle.h> 11#include <asm/cpuidle.h>
12#include <asm/proc-fns.h>
13 12
14#include "common.h" 13#include "common.h"
15#include "cpuidle.h" 14#include "cpuidle.h"
diff --git a/arch/arm/mach-imx/cpuidle-imx6sl.c b/arch/arm/mach-imx/cpuidle-imx6sl.c
index 7d92e6584551..5742a9fd1ef2 100644
--- a/arch/arm/mach-imx/cpuidle-imx6sl.c
+++ b/arch/arm/mach-imx/cpuidle-imx6sl.c
@@ -9,7 +9,6 @@
9#include <linux/cpuidle.h> 9#include <linux/cpuidle.h>
10#include <linux/module.h> 10#include <linux/module.h>
11#include <asm/cpuidle.h> 11#include <asm/cpuidle.h>
12#include <asm/proc-fns.h>
13 12
14#include "common.h" 13#include "common.h"
15#include "cpuidle.h" 14#include "cpuidle.h"
diff --git a/arch/arm/mach-imx/cpuidle-imx6sx.c b/arch/arm/mach-imx/cpuidle-imx6sx.c
index 5a36722b089d..2c9f1a8bf245 100644
--- a/arch/arm/mach-imx/cpuidle-imx6sx.c
+++ b/arch/arm/mach-imx/cpuidle-imx6sx.c
@@ -10,7 +10,6 @@
10#include <linux/cpu_pm.h> 10#include <linux/cpu_pm.h>
11#include <linux/module.h> 11#include <linux/module.h>
12#include <asm/cpuidle.h> 12#include <asm/cpuidle.h>
13#include <asm/proc-fns.h>
14#include <asm/suspend.h> 13#include <asm/suspend.h>
15 14
16#include "common.h" 15#include "common.h"
diff --git a/arch/arm/mach-omap2/cpuidle44xx.c b/arch/arm/mach-omap2/cpuidle44xx.c
index 01e398a868bc..7622dbb05083 100644
--- a/arch/arm/mach-omap2/cpuidle44xx.c
+++ b/arch/arm/mach-omap2/cpuidle44xx.c
@@ -17,7 +17,6 @@
17#include <linux/clockchips.h> 17#include <linux/clockchips.h>
18 18
19#include <asm/cpuidle.h> 19#include <asm/cpuidle.h>
20#include <asm/proc-fns.h>
21 20
22#include "common.h" 21#include "common.h"
23#include "pm.h" 22#include "pm.h"
diff --git a/arch/arm/mach-s3c64xx/cpuidle.c b/arch/arm/mach-s3c64xx/cpuidle.c
index 2eb072440dfa..93aa8cb70195 100644
--- a/arch/arm/mach-s3c64xx/cpuidle.c
+++ b/arch/arm/mach-s3c64xx/cpuidle.c
@@ -16,7 +16,7 @@
16#include <linux/export.h> 16#include <linux/export.h>
17#include <linux/time.h> 17#include <linux/time.h>
18 18
19#include <asm/proc-fns.h> 19#include <asm/cpuidle.h>
20 20
21#include <mach/map.h> 21#include <mach/map.h>
22 22
diff --git a/arch/arm/mach-tegra/cpuidle-tegra20.c b/arch/arm/mach-tegra/cpuidle-tegra20.c
index 4f25a7c7ca0f..e22b0d9fdc88 100644
--- a/arch/arm/mach-tegra/cpuidle-tegra20.c
+++ b/arch/arm/mach-tegra/cpuidle-tegra20.c
@@ -27,7 +27,6 @@
27#include <linux/module.h> 27#include <linux/module.h>
28 28
29#include <asm/cpuidle.h> 29#include <asm/cpuidle.h>
30#include <asm/proc-fns.h>
31#include <asm/smp_plat.h> 30#include <asm/smp_plat.h>
32#include <asm/suspend.h> 31#include <asm/suspend.h>
33 32
diff --git a/arch/arm/mach-tegra/cpuidle-tegra30.c b/arch/arm/mach-tegra/cpuidle-tegra30.c
index f8815ed65d9d..a2400ab44daa 100644
--- a/arch/arm/mach-tegra/cpuidle-tegra30.c
+++ b/arch/arm/mach-tegra/cpuidle-tegra30.c
@@ -27,7 +27,6 @@
27#include <linux/module.h> 27#include <linux/module.h>
28 28
29#include <asm/cpuidle.h> 29#include <asm/cpuidle.h>
30#include <asm/proc-fns.h>
31#include <asm/smp_plat.h> 30#include <asm/smp_plat.h>
32#include <asm/suspend.h> 31#include <asm/suspend.h>
33 32
diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig
index be1f12a5a5f0..af6a452b1aac 100644
--- a/arch/arm64/configs/defconfig
+++ b/arch/arm64/configs/defconfig
@@ -48,7 +48,7 @@ CONFIG_CMDLINE="console=ttyAMA0"
48# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set 48# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
49CONFIG_COMPAT=y 49CONFIG_COMPAT=y
50CONFIG_CPU_IDLE=y 50CONFIG_CPU_IDLE=y
51CONFIG_ARM64_CPUIDLE=y 51CONFIG_ARM_CPUIDLE=y
52CONFIG_NET=y 52CONFIG_NET=y
53CONFIG_PACKET=y 53CONFIG_PACKET=y
54CONFIG_UNIX=y 54CONFIG_UNIX=y
diff --git a/arch/arm64/include/asm/cpuidle.h b/arch/arm64/include/asm/cpuidle.h
index c60643f14cda..141b2fcabaa6 100644
--- a/arch/arm64/include/asm/cpuidle.h
+++ b/arch/arm64/include/asm/cpuidle.h
@@ -4,10 +4,10 @@
4#include <asm/proc-fns.h> 4#include <asm/proc-fns.h>
5 5
6#ifdef CONFIG_CPU_IDLE 6#ifdef CONFIG_CPU_IDLE
7extern int cpu_init_idle(unsigned int cpu); 7extern int arm_cpuidle_init(unsigned int cpu);
8extern int cpu_suspend(unsigned long arg); 8extern int cpu_suspend(unsigned long arg);
9#else 9#else
10static inline int cpu_init_idle(unsigned int cpu) 10static inline int arm_cpuidle_init(unsigned int cpu)
11{ 11{
12 return -EOPNOTSUPP; 12 return -EOPNOTSUPP;
13} 13}
@@ -17,5 +17,8 @@ static inline int cpu_suspend(unsigned long arg)
17 return -EOPNOTSUPP; 17 return -EOPNOTSUPP;
18} 18}
19#endif 19#endif
20 20static inline int arm_cpuidle_suspend(int index)
21{
22 return cpu_suspend(index);
23}
21#endif 24#endif
diff --git a/arch/arm64/kernel/cpuidle.c b/arch/arm64/kernel/cpuidle.c
index 5c0896647fd1..a78143a5c99f 100644
--- a/arch/arm64/kernel/cpuidle.c
+++ b/arch/arm64/kernel/cpuidle.c
@@ -15,7 +15,7 @@
15#include <asm/cpuidle.h> 15#include <asm/cpuidle.h>
16#include <asm/cpu_ops.h> 16#include <asm/cpu_ops.h>
17 17
18int cpu_init_idle(unsigned int cpu) 18int arm_cpuidle_init(unsigned int cpu)
19{ 19{
20 int ret = -EOPNOTSUPP; 20 int ret = -EOPNOTSUPP;
21 struct device_node *cpu_node = of_cpu_device_node_get(cpu); 21 struct device_node *cpu_node = of_cpu_device_node_get(cpu);
diff --git a/arch/nios2/include/asm/thread_info.h b/arch/nios2/include/asm/thread_info.h
index 1f266575beb5..a16e55cbd8ad 100644
--- a/arch/nios2/include/asm/thread_info.h
+++ b/arch/nios2/include/asm/thread_info.h
@@ -47,7 +47,6 @@ struct thread_info {
47 0-0x7FFFFFFF for user-thead 47 0-0x7FFFFFFF for user-thead
48 0-0xFFFFFFFF for kernel-thread 48 0-0xFFFFFFFF for kernel-thread
49 */ 49 */
50 struct restart_block restart_block;
51 struct pt_regs *regs; 50 struct pt_regs *regs;
52}; 51};
53 52
@@ -64,9 +63,6 @@ struct thread_info {
64 .cpu = 0, \ 63 .cpu = 0, \
65 .preempt_count = INIT_PREEMPT_COUNT, \ 64 .preempt_count = INIT_PREEMPT_COUNT, \
66 .addr_limit = KERNEL_DS, \ 65 .addr_limit = KERNEL_DS, \
67 .restart_block = { \
68 .fn = do_no_restart_syscall, \
69 }, \
70} 66}
71 67
72#define init_thread_info (init_thread_union.thread_info) 68#define init_thread_info (init_thread_union.thread_info)
diff --git a/arch/nios2/include/uapi/asm/ptrace.h b/arch/nios2/include/uapi/asm/ptrace.h
index 71a330597adf..eff00e67c0a2 100644
--- a/arch/nios2/include/uapi/asm/ptrace.h
+++ b/arch/nios2/include/uapi/asm/ptrace.h
@@ -60,12 +60,17 @@
60#define PTR_IPENDING 37 60#define PTR_IPENDING 37
61#define PTR_CPUID 38 61#define PTR_CPUID 38
62#define PTR_CTL6 39 62#define PTR_CTL6 39
63#define PTR_CTL7 40 63#define PTR_EXCEPTION 40
64#define PTR_PTEADDR 41 64#define PTR_PTEADDR 41
65#define PTR_TLBACC 42 65#define PTR_TLBACC 42
66#define PTR_TLBMISC 43 66#define PTR_TLBMISC 43
67#define PTR_ECCINJ 44
68#define PTR_BADADDR 45
69#define PTR_CONFIG 46
70#define PTR_MPUBASE 47
71#define PTR_MPUACC 48
67 72
68#define NUM_PTRACE_REG (PTR_TLBMISC + 1) 73#define NUM_PTRACE_REG (PTR_MPUACC + 1)
69 74
70/* User structures for general purpose registers. */ 75/* User structures for general purpose registers. */
71struct user_pt_regs { 76struct user_pt_regs {
diff --git a/arch/nios2/kernel/entry.S b/arch/nios2/kernel/entry.S
index 7729bd3f2e79..27b006c52e12 100644
--- a/arch/nios2/kernel/entry.S
+++ b/arch/nios2/kernel/entry.S
@@ -161,7 +161,7 @@ ENTRY(inthandler)
161 *********************************************************************** 161 ***********************************************************************
162 */ 162 */
163ENTRY(handle_trap) 163ENTRY(handle_trap)
164 ldw r24, -4(ea) /* instruction that caused the exception */ 164 ldwio r24, -4(ea) /* instruction that caused the exception */
165 srli r24, r24, 4 165 srli r24, r24, 4
166 andi r24, r24, 0x7c 166 andi r24, r24, 0x7c
167 movia r9,trap_table 167 movia r9,trap_table
diff --git a/arch/nios2/kernel/signal.c b/arch/nios2/kernel/signal.c
index dda41e4fe707..20662b0f6c9e 100644
--- a/arch/nios2/kernel/signal.c
+++ b/arch/nios2/kernel/signal.c
@@ -43,7 +43,7 @@ static inline int rt_restore_ucontext(struct pt_regs *regs,
43 int err; 43 int err;
44 44
45 /* Always make any pending restarted system calls return -EINTR */ 45 /* Always make any pending restarted system calls return -EINTR */
46 current_thread_info()->restart_block.fn = do_no_restart_syscall; 46 current->restart_block.fn = do_no_restart_syscall;
47 47
48 err = __get_user(temp, &uc->uc_mcontext.version); 48 err = __get_user(temp, &uc->uc_mcontext.version);
49 if (temp != MCONTEXT_VERSION) 49 if (temp != MCONTEXT_VERSION)
diff --git a/arch/nios2/mm/cacheflush.c b/arch/nios2/mm/cacheflush.c
index 2ae482b42669..796642932e2e 100644
--- a/arch/nios2/mm/cacheflush.c
+++ b/arch/nios2/mm/cacheflush.c
@@ -23,9 +23,6 @@ static void __flush_dcache(unsigned long start, unsigned long end)
23 end += (cpuinfo.dcache_line_size - 1); 23 end += (cpuinfo.dcache_line_size - 1);
24 end &= ~(cpuinfo.dcache_line_size - 1); 24 end &= ~(cpuinfo.dcache_line_size - 1);
25 25
26 if (end > start + cpuinfo.dcache_size)
27 end = start + cpuinfo.dcache_size;
28
29 for (addr = start; addr < end; addr += cpuinfo.dcache_line_size) { 26 for (addr = start; addr < end; addr += cpuinfo.dcache_line_size) {
30 __asm__ __volatile__ (" flushda 0(%0)\n" 27 __asm__ __volatile__ (" flushda 0(%0)\n"
31 : /* Outputs */ 28 : /* Outputs */
diff --git a/arch/powerpc/include/asm/cputhreads.h b/arch/powerpc/include/asm/cputhreads.h
index 2bf8e9307be9..4c8ad592ae33 100644
--- a/arch/powerpc/include/asm/cputhreads.h
+++ b/arch/powerpc/include/asm/cputhreads.h
@@ -55,7 +55,7 @@ static inline cpumask_t cpu_thread_mask_to_cores(const struct cpumask *threads)
55 55
56static inline int cpu_nr_cores(void) 56static inline int cpu_nr_cores(void)
57{ 57{
58 return NR_CPUS >> threads_shift; 58 return nr_cpu_ids >> threads_shift;
59} 59}
60 60
61static inline cpumask_t cpu_online_cores_map(void) 61static inline cpumask_t cpu_online_cores_map(void)
diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
index 9ce5afe167ff..b36365f49478 100644
--- a/arch/sparc/kernel/pci.c
+++ b/arch/sparc/kernel/pci.c
@@ -639,10 +639,7 @@ static void pci_claim_bus_resources(struct pci_bus *bus)
639 (unsigned long long)r->end, 639 (unsigned long long)r->end,
640 (unsigned int)r->flags); 640 (unsigned int)r->flags);
641 641
642 if (pci_claim_resource(dev, i) == 0) 642 pci_claim_resource(dev, i);
643 continue;
644
645 pci_claim_bridge_resource(dev, i);
646 } 643 }
647 } 644 }
648 645
diff --git a/arch/x86/include/asm/resume-trace.h b/arch/x86/include/asm/pm-trace.h
index 3ff1c2cb1da5..7b7ac42c3661 100644
--- a/arch/x86/include/asm/resume-trace.h
+++ b/arch/x86/include/asm/pm-trace.h
@@ -1,5 +1,5 @@
1#ifndef _ASM_X86_RESUME_TRACE_H 1#ifndef _ASM_X86_PM_TRACE_H
2#define _ASM_X86_RESUME_TRACE_H 2#define _ASM_X86_PM_TRACE_H
3 3
4#include <asm/asm.h> 4#include <asm/asm.h>
5 5
@@ -14,8 +14,10 @@ do { \
14 ".previous" \ 14 ".previous" \
15 :"=r" (tracedata) \ 15 :"=r" (tracedata) \
16 : "i" (__LINE__), "i" (__FILE__)); \ 16 : "i" (__LINE__), "i" (__FILE__)); \
17 generate_resume_trace(tracedata, user); \ 17 generate_pm_trace(tracedata, user); \
18 } \ 18 } \
19} while (0) 19} while (0)
20 20
21#endif /* _ASM_X86_RESUME_TRACE_H */ 21#define TRACE_SUSPEND(user) TRACE_RESUME(user)
22
23#endif /* _ASM_X86_PM_TRACE_H */
diff --git a/arch/x86/include/asm/uaccess_64.h b/arch/x86/include/asm/uaccess_64.h
index 12a26b979bf1..f2f9b39b274a 100644
--- a/arch/x86/include/asm/uaccess_64.h
+++ b/arch/x86/include/asm/uaccess_64.h
@@ -231,6 +231,6 @@ __copy_from_user_inatomic_nocache(void *dst, const void __user *src,
231} 231}
232 232
233unsigned long 233unsigned long
234copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest); 234copy_user_handle_tail(char *to, char *from, unsigned len);
235 235
236#endif /* _ASM_X86_UACCESS_64_H */ 236#endif /* _ASM_X86_UACCESS_64_H */
diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
index 498b6d967138..258990688a5e 100644
--- a/arch/x86/kernel/cpu/perf_event_intel.c
+++ b/arch/x86/kernel/cpu/perf_event_intel.c
@@ -212,11 +212,11 @@ static struct event_constraint intel_hsw_event_constraints[] = {
212 INTEL_UEVENT_CONSTRAINT(0x01c0, 0x2), /* INST_RETIRED.PREC_DIST */ 212 INTEL_UEVENT_CONSTRAINT(0x01c0, 0x2), /* INST_RETIRED.PREC_DIST */
213 INTEL_EVENT_CONSTRAINT(0xcd, 0x8), /* MEM_TRANS_RETIRED.LOAD_LATENCY */ 213 INTEL_EVENT_CONSTRAINT(0xcd, 0x8), /* MEM_TRANS_RETIRED.LOAD_LATENCY */
214 /* CYCLE_ACTIVITY.CYCLES_L1D_PENDING */ 214 /* CYCLE_ACTIVITY.CYCLES_L1D_PENDING */
215 INTEL_EVENT_CONSTRAINT(0x08a3, 0x4), 215 INTEL_UEVENT_CONSTRAINT(0x08a3, 0x4),
216 /* CYCLE_ACTIVITY.STALLS_L1D_PENDING */ 216 /* CYCLE_ACTIVITY.STALLS_L1D_PENDING */
217 INTEL_EVENT_CONSTRAINT(0x0ca3, 0x4), 217 INTEL_UEVENT_CONSTRAINT(0x0ca3, 0x4),
218 /* CYCLE_ACTIVITY.CYCLES_NO_EXECUTE */ 218 /* CYCLE_ACTIVITY.CYCLES_NO_EXECUTE */
219 INTEL_EVENT_CONSTRAINT(0x04a3, 0xf), 219 INTEL_UEVENT_CONSTRAINT(0x04a3, 0xf),
220 EVENT_CONSTRAINT_END 220 EVENT_CONSTRAINT_END
221}; 221};
222 222
@@ -1649,11 +1649,11 @@ intel_get_event_constraints(struct cpu_hw_events *cpuc, struct perf_event *event
1649 if (c) 1649 if (c)
1650 return c; 1650 return c;
1651 1651
1652 c = intel_pebs_constraints(event); 1652 c = intel_shared_regs_constraints(cpuc, event);
1653 if (c) 1653 if (c)
1654 return c; 1654 return c;
1655 1655
1656 c = intel_shared_regs_constraints(cpuc, event); 1656 c = intel_pebs_constraints(event);
1657 if (c) 1657 if (c)
1658 return c; 1658 return c;
1659 1659
diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index 2babb393915e..f0095a76c182 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -799,7 +799,21 @@ retint_swapgs: /* return to user-space */
799 cmpq %r11,(EFLAGS-ARGOFFSET)(%rsp) /* R11 == RFLAGS */ 799 cmpq %r11,(EFLAGS-ARGOFFSET)(%rsp) /* R11 == RFLAGS */
800 jne opportunistic_sysret_failed 800 jne opportunistic_sysret_failed
801 801
802 testq $X86_EFLAGS_RF,%r11 /* sysret can't restore RF */ 802 /*
803 * SYSRET can't restore RF. SYSRET can restore TF, but unlike IRET,
804 * restoring TF results in a trap from userspace immediately after
805 * SYSRET. This would cause an infinite loop whenever #DB happens
806 * with register state that satisfies the opportunistic SYSRET
807 * conditions. For example, single-stepping this user code:
808 *
809 * movq $stuck_here,%rcx
810 * pushfq
811 * popq %r11
812 * stuck_here:
813 *
814 * would never get past 'stuck_here'.
815 */
816 testq $(X86_EFLAGS_RF|X86_EFLAGS_TF), %r11
803 jnz opportunistic_sysret_failed 817 jnz opportunistic_sysret_failed
804 818
805 /* nothing to check for RSP */ 819 /* nothing to check for RSP */
diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
index 7ec1d5f8d283..25ecd56cefa8 100644
--- a/arch/x86/kernel/kgdb.c
+++ b/arch/x86/kernel/kgdb.c
@@ -72,7 +72,7 @@ struct dbg_reg_def_t dbg_reg_def[DBG_MAX_REG_NUM] =
72 { "bx", 8, offsetof(struct pt_regs, bx) }, 72 { "bx", 8, offsetof(struct pt_regs, bx) },
73 { "cx", 8, offsetof(struct pt_regs, cx) }, 73 { "cx", 8, offsetof(struct pt_regs, cx) },
74 { "dx", 8, offsetof(struct pt_regs, dx) }, 74 { "dx", 8, offsetof(struct pt_regs, dx) },
75 { "si", 8, offsetof(struct pt_regs, dx) }, 75 { "si", 8, offsetof(struct pt_regs, si) },
76 { "di", 8, offsetof(struct pt_regs, di) }, 76 { "di", 8, offsetof(struct pt_regs, di) },
77 { "bp", 8, offsetof(struct pt_regs, bp) }, 77 { "bp", 8, offsetof(struct pt_regs, bp) },
78 { "sp", 8, offsetof(struct pt_regs, sp) }, 78 { "sp", 8, offsetof(struct pt_regs, sp) },
diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
index bae6c609888e..86db4bcd7ce5 100644
--- a/arch/x86/kernel/reboot.c
+++ b/arch/x86/kernel/reboot.c
@@ -183,6 +183,16 @@ static struct dmi_system_id __initdata reboot_dmi_table[] = {
183 }, 183 },
184 }, 184 },
185 185
186 /* ASRock */
187 { /* Handle problems with rebooting on ASRock Q1900DC-ITX */
188 .callback = set_pci_reboot,
189 .ident = "ASRock Q1900DC-ITX",
190 .matches = {
191 DMI_MATCH(DMI_BOARD_VENDOR, "ASRock"),
192 DMI_MATCH(DMI_BOARD_NAME, "Q1900DC-ITX"),
193 },
194 },
195
186 /* ASUS */ 196 /* ASUS */
187 { /* Handle problems with rebooting on ASUS P4S800 */ 197 { /* Handle problems with rebooting on ASUS P4S800 */
188 .callback = set_bios_reboot, 198 .callback = set_bios_reboot,
diff --git a/arch/x86/lib/usercopy_64.c b/arch/x86/lib/usercopy_64.c
index c905e89e19fe..1f33b3d1fd68 100644
--- a/arch/x86/lib/usercopy_64.c
+++ b/arch/x86/lib/usercopy_64.c
@@ -69,21 +69,20 @@ EXPORT_SYMBOL(copy_in_user);
69 * it is not necessary to optimize tail handling. 69 * it is not necessary to optimize tail handling.
70 */ 70 */
71__visible unsigned long 71__visible unsigned long
72copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest) 72copy_user_handle_tail(char *to, char *from, unsigned len)
73{ 73{
74 char c;
75 unsigned zero_len;
76
77 for (; len; --len, to++) { 74 for (; len; --len, to++) {
75 char c;
76
78 if (__get_user_nocheck(c, from++, sizeof(char))) 77 if (__get_user_nocheck(c, from++, sizeof(char)))
79 break; 78 break;
80 if (__put_user_nocheck(c, to, sizeof(char))) 79 if (__put_user_nocheck(c, to, sizeof(char)))
81 break; 80 break;
82 } 81 }
83
84 for (c = 0, zero_len = len; zerorest && zero_len; --zero_len)
85 if (__put_user_nocheck(c, to++, sizeof(char)))
86 break;
87 clac(); 82 clac();
83
84 /* If the destination is a kernel buffer, we always clear the end */
85 if ((unsigned long)to >= TASK_SIZE_MAX)
86 memset(to, 0, len);
88 return len; 87 return len;
89} 88}
diff --git a/arch/x86/xen/p2m.c b/arch/x86/xen/p2m.c
index 9f93af56a5fc..b47124d4cd67 100644
--- a/arch/x86/xen/p2m.c
+++ b/arch/x86/xen/p2m.c
@@ -91,6 +91,12 @@ EXPORT_SYMBOL_GPL(xen_p2m_size);
91unsigned long xen_max_p2m_pfn __read_mostly; 91unsigned long xen_max_p2m_pfn __read_mostly;
92EXPORT_SYMBOL_GPL(xen_max_p2m_pfn); 92EXPORT_SYMBOL_GPL(xen_max_p2m_pfn);
93 93
94#ifdef CONFIG_XEN_BALLOON_MEMORY_HOTPLUG_LIMIT
95#define P2M_LIMIT CONFIG_XEN_BALLOON_MEMORY_HOTPLUG_LIMIT
96#else
97#define P2M_LIMIT 0
98#endif
99
94static DEFINE_SPINLOCK(p2m_update_lock); 100static DEFINE_SPINLOCK(p2m_update_lock);
95 101
96static unsigned long *p2m_mid_missing_mfn; 102static unsigned long *p2m_mid_missing_mfn;
@@ -385,9 +391,11 @@ static void __init xen_rebuild_p2m_list(unsigned long *p2m)
385void __init xen_vmalloc_p2m_tree(void) 391void __init xen_vmalloc_p2m_tree(void)
386{ 392{
387 static struct vm_struct vm; 393 static struct vm_struct vm;
394 unsigned long p2m_limit;
388 395
396 p2m_limit = (phys_addr_t)P2M_LIMIT * 1024 * 1024 * 1024 / PAGE_SIZE;
389 vm.flags = VM_ALLOC; 397 vm.flags = VM_ALLOC;
390 vm.size = ALIGN(sizeof(unsigned long) * xen_max_p2m_pfn, 398 vm.size = ALIGN(sizeof(unsigned long) * max(xen_max_p2m_pfn, p2m_limit),
391 PMD_SIZE * PMDS_PER_MID_PAGE); 399 PMD_SIZE * PMDS_PER_MID_PAGE);
392 vm_area_register_early(&vm, PMD_SIZE * PMDS_PER_MID_PAGE); 400 vm_area_register_early(&vm, PMD_SIZE * PMDS_PER_MID_PAGE);
393 pr_notice("p2m virtual area at %p, size is %lx\n", vm.addr, vm.size); 401 pr_notice("p2m virtual area at %p, size is %lx\n", vm.addr, vm.size);
diff --git a/block/blk-mq.c b/block/blk-mq.c
index b7b8933ec241..33c428530193 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -1457,7 +1457,7 @@ static struct blk_mq_tags *blk_mq_init_rq_map(struct blk_mq_tag_set *set,
1457 1457
1458 do { 1458 do {
1459 page = alloc_pages_node(set->numa_node, 1459 page = alloc_pages_node(set->numa_node,
1460 GFP_KERNEL | __GFP_NOWARN | __GFP_NORETRY, 1460 GFP_KERNEL | __GFP_NOWARN | __GFP_NORETRY | __GFP_ZERO,
1461 this_order); 1461 this_order);
1462 if (page) 1462 if (page)
1463 break; 1463 break;
@@ -1479,8 +1479,6 @@ static struct blk_mq_tags *blk_mq_init_rq_map(struct blk_mq_tag_set *set,
1479 left -= to_do * rq_size; 1479 left -= to_do * rq_size;
1480 for (j = 0; j < to_do; j++) { 1480 for (j = 0; j < to_do; j++) {
1481 tags->rqs[i] = p; 1481 tags->rqs[i] = p;
1482 tags->rqs[i]->atomic_flags = 0;
1483 tags->rqs[i]->cmd_flags = 0;
1484 if (set->ops->init_request) { 1482 if (set->ops->init_request) {
1485 if (set->ops->init_request(set->driver_data, 1483 if (set->ops->init_request(set->driver_data,
1486 tags->rqs[i], hctx_idx, i, 1484 tags->rqs[i], hctx_idx, i,
diff --git a/block/blk-settings.c b/block/blk-settings.c
index 6ed2cbe5e8c9..12600bfffca9 100644
--- a/block/blk-settings.c
+++ b/block/blk-settings.c
@@ -585,7 +585,7 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b,
585 b->physical_block_size); 585 b->physical_block_size);
586 586
587 t->io_min = max(t->io_min, b->io_min); 587 t->io_min = max(t->io_min, b->io_min);
588 t->io_opt = lcm(t->io_opt, b->io_opt); 588 t->io_opt = lcm_not_zero(t->io_opt, b->io_opt);
589 589
590 t->cluster &= b->cluster; 590 t->cluster &= b->cluster;
591 t->discard_zeroes_data &= b->discard_zeroes_data; 591 t->discard_zeroes_data &= b->discard_zeroes_data;
@@ -616,7 +616,7 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b,
616 b->raid_partial_stripes_expensive); 616 b->raid_partial_stripes_expensive);
617 617
618 /* Find lowest common alignment_offset */ 618 /* Find lowest common alignment_offset */
619 t->alignment_offset = lcm(t->alignment_offset, alignment) 619 t->alignment_offset = lcm_not_zero(t->alignment_offset, alignment)
620 % max(t->physical_block_size, t->io_min); 620 % max(t->physical_block_size, t->io_min);
621 621
622 /* Verify that new alignment_offset is on a logical block boundary */ 622 /* Verify that new alignment_offset is on a logical block boundary */
@@ -643,7 +643,7 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b,
643 b->max_discard_sectors); 643 b->max_discard_sectors);
644 t->discard_granularity = max(t->discard_granularity, 644 t->discard_granularity = max(t->discard_granularity,
645 b->discard_granularity); 645 b->discard_granularity);
646 t->discard_alignment = lcm(t->discard_alignment, alignment) % 646 t->discard_alignment = lcm_not_zero(t->discard_alignment, alignment) %
647 t->discard_granularity; 647 t->discard_granularity;
648 } 648 }
649 649
diff --git a/drivers/acpi/acpi_platform.c b/drivers/acpi/acpi_platform.c
index 1284138e42ab..4bf75597f732 100644
--- a/drivers/acpi/acpi_platform.c
+++ b/drivers/acpi/acpi_platform.c
@@ -102,7 +102,7 @@ struct platform_device *acpi_create_platform_device(struct acpi_device *adev)
102 pdevinfo.id = -1; 102 pdevinfo.id = -1;
103 pdevinfo.res = resources; 103 pdevinfo.res = resources;
104 pdevinfo.num_res = count; 104 pdevinfo.num_res = count;
105 pdevinfo.acpi_node.companion = adev; 105 pdevinfo.fwnode = acpi_fwnode_handle(adev);
106 pdevinfo.dma_mask = DMA_BIT_MASK(32); 106 pdevinfo.dma_mask = DMA_BIT_MASK(32);
107 pdev = platform_device_register_full(&pdevinfo); 107 pdev = platform_device_register_full(&pdevinfo);
108 if (IS_ERR(pdev)) 108 if (IS_ERR(pdev))
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index d98ba4355819..baebd1a9b811 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -530,8 +530,8 @@ static int acpi_battery_get_state(struct acpi_battery *battery)
530 battery->rate_now != ACPI_BATTERY_VALUE_UNKNOWN && 530 battery->rate_now != ACPI_BATTERY_VALUE_UNKNOWN &&
531 (s16)(battery->rate_now) < 0) { 531 (s16)(battery->rate_now) < 0) {
532 battery->rate_now = abs((s16)battery->rate_now); 532 battery->rate_now = abs((s16)battery->rate_now);
533 printk_once(KERN_WARNING FW_BUG "battery: (dis)charge rate" 533 printk_once(KERN_WARNING FW_BUG
534 " invalid.\n"); 534 "battery: (dis)charge rate invalid.\n");
535 } 535 }
536 536
537 if (test_bit(ACPI_BATTERY_QUIRK_PERCENTAGE_CAPACITY, &battery->flags) 537 if (test_bit(ACPI_BATTERY_QUIRK_PERCENTAGE_CAPACITY, &battery->flags)
diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
index 9b693d54c743..1d1791935c31 100644
--- a/drivers/acpi/blacklist.c
+++ b/drivers/acpi/blacklist.c
@@ -215,6 +215,14 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
215 }, 215 },
216 { 216 {
217 .callback = dmi_disable_osi_vista, 217 .callback = dmi_disable_osi_vista,
218 .ident = "VGN-SR19XN",
219 .matches = {
220 DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
221 DMI_MATCH(DMI_PRODUCT_NAME, "VGN-SR19XN"),
222 },
223 },
224 {
225 .callback = dmi_disable_osi_vista,
218 .ident = "Toshiba Satellite L355", 226 .ident = "Toshiba Satellite L355",
219 .matches = { 227 .matches = {
220 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"), 228 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c
index d9339b442a4e..a688aa243f6c 100644
--- a/drivers/acpi/dock.c
+++ b/drivers/acpi/dock.c
@@ -615,7 +615,7 @@ void acpi_dock_add(struct acpi_device *adev)
615 memset(&pdevinfo, 0, sizeof(pdevinfo)); 615 memset(&pdevinfo, 0, sizeof(pdevinfo));
616 pdevinfo.name = "dock"; 616 pdevinfo.name = "dock";
617 pdevinfo.id = dock_station_count; 617 pdevinfo.id = dock_station_count;
618 pdevinfo.acpi_node.companion = adev; 618 pdevinfo.fwnode = acpi_fwnode_handle(adev);
619 pdevinfo.data = &ds; 619 pdevinfo.data = &ds;
620 pdevinfo.size_data = sizeof(ds); 620 pdevinfo.size_data = sizeof(ds);
621 dd = platform_device_register_full(&pdevinfo); 621 dd = platform_device_register_full(&pdevinfo);
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index a8dd2f763382..220d6406c9e9 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -137,6 +137,50 @@ static int EC_FLAGS_CLEAR_ON_RESUME; /* Needs acpi_ec_clear() on boot/resume */
137static int EC_FLAGS_QUERY_HANDSHAKE; /* Needs QR_EC issued when SCI_EVT set */ 137static int EC_FLAGS_QUERY_HANDSHAKE; /* Needs QR_EC issued when SCI_EVT set */
138 138
139/* -------------------------------------------------------------------------- 139/* --------------------------------------------------------------------------
140 * Logging/Debugging
141 * -------------------------------------------------------------------------- */
142
143/*
144 * Splitters used by the developers to track the boundary of the EC
145 * handling processes.
146 */
147#ifdef DEBUG
148#define EC_DBG_SEP " "
149#define EC_DBG_DRV "+++++"
150#define EC_DBG_STM "====="
151#define EC_DBG_REQ "*****"
152#define EC_DBG_EVT "#####"
153#else
154#define EC_DBG_SEP ""
155#define EC_DBG_DRV
156#define EC_DBG_STM
157#define EC_DBG_REQ
158#define EC_DBG_EVT
159#endif
160
161#define ec_log_raw(fmt, ...) \
162 pr_info(fmt "\n", ##__VA_ARGS__)
163#define ec_dbg_raw(fmt, ...) \
164 pr_debug(fmt "\n", ##__VA_ARGS__)
165#define ec_log(filter, fmt, ...) \
166 ec_log_raw(filter EC_DBG_SEP fmt EC_DBG_SEP filter, ##__VA_ARGS__)
167#define ec_dbg(filter, fmt, ...) \
168 ec_dbg_raw(filter EC_DBG_SEP fmt EC_DBG_SEP filter, ##__VA_ARGS__)
169
170#define ec_log_drv(fmt, ...) \
171 ec_log(EC_DBG_DRV, fmt, ##__VA_ARGS__)
172#define ec_dbg_drv(fmt, ...) \
173 ec_dbg(EC_DBG_DRV, fmt, ##__VA_ARGS__)
174#define ec_dbg_stm(fmt, ...) \
175 ec_dbg(EC_DBG_STM, fmt, ##__VA_ARGS__)
176#define ec_dbg_req(fmt, ...) \
177 ec_dbg(EC_DBG_REQ, fmt, ##__VA_ARGS__)
178#define ec_dbg_evt(fmt, ...) \
179 ec_dbg(EC_DBG_EVT, fmt, ##__VA_ARGS__)
180#define ec_dbg_ref(ec, fmt, ...) \
181 ec_dbg_raw("%lu: " fmt, ec->reference_count, ## __VA_ARGS__)
182
183/* --------------------------------------------------------------------------
140 * Device Flags 184 * Device Flags
141 * -------------------------------------------------------------------------- */ 185 * -------------------------------------------------------------------------- */
142 186
@@ -159,14 +203,14 @@ static inline u8 acpi_ec_read_status(struct acpi_ec *ec)
159{ 203{
160 u8 x = inb(ec->command_addr); 204 u8 x = inb(ec->command_addr);
161 205
162 pr_debug("EC_SC(R) = 0x%2.2x " 206 ec_dbg_raw("EC_SC(R) = 0x%2.2x "
163 "SCI_EVT=%d BURST=%d CMD=%d IBF=%d OBF=%d\n", 207 "SCI_EVT=%d BURST=%d CMD=%d IBF=%d OBF=%d",
164 x, 208 x,
165 !!(x & ACPI_EC_FLAG_SCI), 209 !!(x & ACPI_EC_FLAG_SCI),
166 !!(x & ACPI_EC_FLAG_BURST), 210 !!(x & ACPI_EC_FLAG_BURST),
167 !!(x & ACPI_EC_FLAG_CMD), 211 !!(x & ACPI_EC_FLAG_CMD),
168 !!(x & ACPI_EC_FLAG_IBF), 212 !!(x & ACPI_EC_FLAG_IBF),
169 !!(x & ACPI_EC_FLAG_OBF)); 213 !!(x & ACPI_EC_FLAG_OBF));
170 return x; 214 return x;
171} 215}
172 216
@@ -175,20 +219,20 @@ static inline u8 acpi_ec_read_data(struct acpi_ec *ec)
175 u8 x = inb(ec->data_addr); 219 u8 x = inb(ec->data_addr);
176 220
177 ec->curr->timestamp = jiffies; 221 ec->curr->timestamp = jiffies;
178 pr_debug("EC_DATA(R) = 0x%2.2x\n", x); 222 ec_dbg_raw("EC_DATA(R) = 0x%2.2x", x);
179 return x; 223 return x;
180} 224}
181 225
182static inline void acpi_ec_write_cmd(struct acpi_ec *ec, u8 command) 226static inline void acpi_ec_write_cmd(struct acpi_ec *ec, u8 command)
183{ 227{
184 pr_debug("EC_SC(W) = 0x%2.2x\n", command); 228 ec_dbg_raw("EC_SC(W) = 0x%2.2x", command);
185 outb(command, ec->command_addr); 229 outb(command, ec->command_addr);
186 ec->curr->timestamp = jiffies; 230 ec->curr->timestamp = jiffies;
187} 231}
188 232
189static inline void acpi_ec_write_data(struct acpi_ec *ec, u8 data) 233static inline void acpi_ec_write_data(struct acpi_ec *ec, u8 data)
190{ 234{
191 pr_debug("EC_DATA(W) = 0x%2.2x\n", data); 235 ec_dbg_raw("EC_DATA(W) = 0x%2.2x", data);
192 outb(data, ec->data_addr); 236 outb(data, ec->data_addr);
193 ec->curr->timestamp = jiffies; 237 ec->curr->timestamp = jiffies;
194} 238}
@@ -240,7 +284,7 @@ static inline void acpi_ec_enable_gpe(struct acpi_ec *ec, bool open)
240 * software need to manually trigger a pseudo GPE event on 284 * software need to manually trigger a pseudo GPE event on
241 * EN=1 writes. 285 * EN=1 writes.
242 */ 286 */
243 pr_debug("***** Polling quirk *****\n"); 287 ec_dbg_raw("Polling quirk");
244 advance_transaction(ec); 288 advance_transaction(ec);
245 } 289 }
246} 290}
@@ -299,7 +343,7 @@ static void acpi_ec_set_storm(struct acpi_ec *ec, u8 flag)
299{ 343{
300 if (!test_bit(flag, &ec->flags)) { 344 if (!test_bit(flag, &ec->flags)) {
301 acpi_ec_disable_gpe(ec, false); 345 acpi_ec_disable_gpe(ec, false);
302 pr_debug("+++++ Polling enabled +++++\n"); 346 ec_dbg_drv("Polling enabled");
303 set_bit(flag, &ec->flags); 347 set_bit(flag, &ec->flags);
304 } 348 }
305} 349}
@@ -309,7 +353,7 @@ static void acpi_ec_clear_storm(struct acpi_ec *ec, u8 flag)
309 if (test_bit(flag, &ec->flags)) { 353 if (test_bit(flag, &ec->flags)) {
310 clear_bit(flag, &ec->flags); 354 clear_bit(flag, &ec->flags);
311 acpi_ec_enable_gpe(ec, false); 355 acpi_ec_enable_gpe(ec, false);
312 pr_debug("+++++ Polling disabled +++++\n"); 356 ec_dbg_drv("Polling disabled");
313 } 357 }
314} 358}
315 359
@@ -335,7 +379,7 @@ static bool acpi_ec_submit_flushable_request(struct acpi_ec *ec)
335static void acpi_ec_submit_query(struct acpi_ec *ec) 379static void acpi_ec_submit_query(struct acpi_ec *ec)
336{ 380{
337 if (!test_and_set_bit(EC_FLAGS_QUERY_PENDING, &ec->flags)) { 381 if (!test_and_set_bit(EC_FLAGS_QUERY_PENDING, &ec->flags)) {
338 pr_debug("***** Event started *****\n"); 382 ec_dbg_req("Event started");
339 schedule_work(&ec->work); 383 schedule_work(&ec->work);
340 } 384 }
341} 385}
@@ -344,7 +388,7 @@ static void acpi_ec_complete_query(struct acpi_ec *ec)
344{ 388{
345 if (ec->curr->command == ACPI_EC_COMMAND_QUERY) { 389 if (ec->curr->command == ACPI_EC_COMMAND_QUERY) {
346 clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags); 390 clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags);
347 pr_debug("***** Event stopped *****\n"); 391 ec_dbg_req("Event stopped");
348 } 392 }
349} 393}
350 394
@@ -366,8 +410,8 @@ static void advance_transaction(struct acpi_ec *ec)
366 u8 status; 410 u8 status;
367 bool wakeup = false; 411 bool wakeup = false;
368 412
369 pr_debug("===== %s (%d) =====\n", 413 ec_dbg_stm("%s (%d)", in_interrupt() ? "IRQ" : "TASK",
370 in_interrupt() ? "IRQ" : "TASK", smp_processor_id()); 414 smp_processor_id());
371 /* 415 /*
372 * By always clearing STS before handling all indications, we can 416 * By always clearing STS before handling all indications, we can
373 * ensure a hardware STS 0->1 change after this clearing can always 417 * ensure a hardware STS 0->1 change after this clearing can always
@@ -390,8 +434,8 @@ static void advance_transaction(struct acpi_ec *ec)
390 if (t->rlen == t->ri) { 434 if (t->rlen == t->ri) {
391 t->flags |= ACPI_EC_COMMAND_COMPLETE; 435 t->flags |= ACPI_EC_COMMAND_COMPLETE;
392 if (t->command == ACPI_EC_COMMAND_QUERY) 436 if (t->command == ACPI_EC_COMMAND_QUERY)
393 pr_debug("***** Command(%s) hardware completion *****\n", 437 ec_dbg_req("Command(%s) hardware completion",
394 acpi_ec_cmd_string(t->command)); 438 acpi_ec_cmd_string(t->command));
395 wakeup = true; 439 wakeup = true;
396 } 440 }
397 } else 441 } else
@@ -410,8 +454,8 @@ static void advance_transaction(struct acpi_ec *ec)
410 acpi_ec_complete_query(ec); 454 acpi_ec_complete_query(ec);
411 t->rdata[t->ri++] = 0x00; 455 t->rdata[t->ri++] = 0x00;
412 t->flags |= ACPI_EC_COMMAND_COMPLETE; 456 t->flags |= ACPI_EC_COMMAND_COMPLETE;
413 pr_debug("***** Command(%s) software completion *****\n", 457 ec_dbg_req("Command(%s) software completion",
414 acpi_ec_cmd_string(t->command)); 458 acpi_ec_cmd_string(t->command));
415 wakeup = true; 459 wakeup = true;
416 } else if ((status & ACPI_EC_FLAG_IBF) == 0) { 460 } else if ((status & ACPI_EC_FLAG_IBF) == 0) {
417 acpi_ec_write_cmd(ec, t->command); 461 acpi_ec_write_cmd(ec, t->command);
@@ -502,21 +546,21 @@ static int acpi_ec_transaction_unlocked(struct acpi_ec *ec,
502 ret = -EINVAL; 546 ret = -EINVAL;
503 goto unlock; 547 goto unlock;
504 } 548 }
549 ec_dbg_ref(ec, "Increase command");
505 /* following two actions should be kept atomic */ 550 /* following two actions should be kept atomic */
506 ec->curr = t; 551 ec->curr = t;
507 pr_debug("***** Command(%s) started *****\n", 552 ec_dbg_req("Command(%s) started", acpi_ec_cmd_string(t->command));
508 acpi_ec_cmd_string(t->command));
509 start_transaction(ec); 553 start_transaction(ec);
510 spin_unlock_irqrestore(&ec->lock, tmp); 554 spin_unlock_irqrestore(&ec->lock, tmp);
511 ret = ec_poll(ec); 555 ret = ec_poll(ec);
512 spin_lock_irqsave(&ec->lock, tmp); 556 spin_lock_irqsave(&ec->lock, tmp);
513 if (t->irq_count == ec_storm_threshold) 557 if (t->irq_count == ec_storm_threshold)
514 acpi_ec_clear_storm(ec, EC_FLAGS_COMMAND_STORM); 558 acpi_ec_clear_storm(ec, EC_FLAGS_COMMAND_STORM);
515 pr_debug("***** Command(%s) stopped *****\n", 559 ec_dbg_req("Command(%s) stopped", acpi_ec_cmd_string(t->command));
516 acpi_ec_cmd_string(t->command));
517 ec->curr = NULL; 560 ec->curr = NULL;
518 /* Disable GPE for command processing (IBF=0/OBF=1) */ 561 /* Disable GPE for command processing (IBF=0/OBF=1) */
519 acpi_ec_complete_request(ec); 562 acpi_ec_complete_request(ec);
563 ec_dbg_ref(ec, "Decrease command");
520unlock: 564unlock:
521 spin_unlock_irqrestore(&ec->lock, tmp); 565 spin_unlock_irqrestore(&ec->lock, tmp);
522 return ret; 566 return ret;
@@ -676,11 +720,13 @@ static void acpi_ec_start(struct acpi_ec *ec, bool resuming)
676 720
677 spin_lock_irqsave(&ec->lock, flags); 721 spin_lock_irqsave(&ec->lock, flags);
678 if (!test_and_set_bit(EC_FLAGS_STARTED, &ec->flags)) { 722 if (!test_and_set_bit(EC_FLAGS_STARTED, &ec->flags)) {
679 pr_debug("+++++ Starting EC +++++\n"); 723 ec_dbg_drv("Starting EC");
680 /* Enable GPE for event processing (SCI_EVT=1) */ 724 /* Enable GPE for event processing (SCI_EVT=1) */
681 if (!resuming) 725 if (!resuming) {
682 acpi_ec_submit_request(ec); 726 acpi_ec_submit_request(ec);
683 pr_debug("EC started\n"); 727 ec_dbg_ref(ec, "Increase driver");
728 }
729 ec_log_drv("EC started");
684 } 730 }
685 spin_unlock_irqrestore(&ec->lock, flags); 731 spin_unlock_irqrestore(&ec->lock, flags);
686} 732}
@@ -702,17 +748,19 @@ static void acpi_ec_stop(struct acpi_ec *ec, bool suspending)
702 748
703 spin_lock_irqsave(&ec->lock, flags); 749 spin_lock_irqsave(&ec->lock, flags);
704 if (acpi_ec_started(ec)) { 750 if (acpi_ec_started(ec)) {
705 pr_debug("+++++ Stopping EC +++++\n"); 751 ec_dbg_drv("Stopping EC");
706 set_bit(EC_FLAGS_STOPPED, &ec->flags); 752 set_bit(EC_FLAGS_STOPPED, &ec->flags);
707 spin_unlock_irqrestore(&ec->lock, flags); 753 spin_unlock_irqrestore(&ec->lock, flags);
708 wait_event(ec->wait, acpi_ec_stopped(ec)); 754 wait_event(ec->wait, acpi_ec_stopped(ec));
709 spin_lock_irqsave(&ec->lock, flags); 755 spin_lock_irqsave(&ec->lock, flags);
710 /* Disable GPE for event processing (SCI_EVT=1) */ 756 /* Disable GPE for event processing (SCI_EVT=1) */
711 if (!suspending) 757 if (!suspending) {
712 acpi_ec_complete_request(ec); 758 acpi_ec_complete_request(ec);
759 ec_dbg_ref(ec, "Decrease driver");
760 }
713 clear_bit(EC_FLAGS_STARTED, &ec->flags); 761 clear_bit(EC_FLAGS_STARTED, &ec->flags);
714 clear_bit(EC_FLAGS_STOPPED, &ec->flags); 762 clear_bit(EC_FLAGS_STOPPED, &ec->flags);
715 pr_debug("EC stopped\n"); 763 ec_log_drv("EC stopped");
716 } 764 }
717 spin_unlock_irqrestore(&ec->lock, flags); 765 spin_unlock_irqrestore(&ec->lock, flags);
718} 766}
@@ -824,12 +872,12 @@ static void acpi_ec_run(void *cxt)
824 872
825 if (!handler) 873 if (!handler)
826 return; 874 return;
827 pr_debug("##### Query(0x%02x) started #####\n", handler->query_bit); 875 ec_dbg_evt("Query(0x%02x) started", handler->query_bit);
828 if (handler->func) 876 if (handler->func)
829 handler->func(handler->data); 877 handler->func(handler->data);
830 else if (handler->handle) 878 else if (handler->handle)
831 acpi_evaluate_object(handler->handle, NULL, NULL, NULL); 879 acpi_evaluate_object(handler->handle, NULL, NULL, NULL);
832 pr_debug("##### Query(0x%02x) stopped #####\n", handler->query_bit); 880 ec_dbg_evt("Query(0x%02x) stopped", handler->query_bit);
833 acpi_ec_put_query_handler(handler); 881 acpi_ec_put_query_handler(handler);
834} 882}
835 883
@@ -861,8 +909,8 @@ static int acpi_ec_query(struct acpi_ec *ec, u8 *data)
861 if (value == handler->query_bit) { 909 if (value == handler->query_bit) {
862 /* have custom handler for this bit */ 910 /* have custom handler for this bit */
863 handler = acpi_ec_get_query_handler(handler); 911 handler = acpi_ec_get_query_handler(handler);
864 pr_debug("##### Query(0x%02x) scheduled #####\n", 912 ec_dbg_evt("Query(0x%02x) scheduled",
865 handler->query_bit); 913 handler->query_bit);
866 status = acpi_os_execute((handler->func) ? 914 status = acpi_os_execute((handler->func) ?
867 OSL_NOTIFY_HANDLER : OSL_GPE_HANDLER, 915 OSL_NOTIFY_HANDLER : OSL_GPE_HANDLER,
868 acpi_ec_run, handler); 916 acpi_ec_run, handler);
@@ -1099,6 +1147,9 @@ static int acpi_ec_add(struct acpi_device *device)
1099 1147
1100 ret = ec_install_handlers(ec); 1148 ret = ec_install_handlers(ec);
1101 1149
1150 /* Reprobe devices depending on the EC */
1151 acpi_walk_dep_device_list(ec->handle);
1152
1102 /* EC is fully operational, allow queries */ 1153 /* EC is fully operational, allow queries */
1103 clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags); 1154 clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags);
1104 1155
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c
index f774c65ecb8b..39c485b0c25c 100644
--- a/drivers/acpi/glue.c
+++ b/drivers/acpi/glue.c
@@ -168,7 +168,7 @@ int acpi_bind_one(struct device *dev, struct acpi_device *acpi_dev)
168 unsigned int node_id; 168 unsigned int node_id;
169 int retval = -EINVAL; 169 int retval = -EINVAL;
170 170
171 if (ACPI_COMPANION(dev)) { 171 if (has_acpi_companion(dev)) {
172 if (acpi_dev) { 172 if (acpi_dev) {
173 dev_warn(dev, "ACPI companion already set\n"); 173 dev_warn(dev, "ACPI companion already set\n");
174 return -EINVAL; 174 return -EINVAL;
@@ -220,7 +220,7 @@ int acpi_bind_one(struct device *dev, struct acpi_device *acpi_dev)
220 list_add(&physical_node->node, physnode_list); 220 list_add(&physical_node->node, physnode_list);
221 acpi_dev->physical_node_count++; 221 acpi_dev->physical_node_count++;
222 222
223 if (!ACPI_COMPANION(dev)) 223 if (!has_acpi_companion(dev))
224 ACPI_COMPANION_SET(dev, acpi_dev); 224 ACPI_COMPANION_SET(dev, acpi_dev);
225 225
226 acpi_physnode_link_name(physical_node_name, node_id); 226 acpi_physnode_link_name(physical_node_name, node_id);
diff --git a/drivers/acpi/pmic/intel_pmic_crc.c b/drivers/acpi/pmic/intel_pmic_crc.c
index ef7d8ff95abe..42df46a86c25 100644
--- a/drivers/acpi/pmic/intel_pmic_crc.c
+++ b/drivers/acpi/pmic/intel_pmic_crc.c
@@ -207,5 +207,5 @@ static int __init intel_crc_pmic_opregion_driver_init(void)
207} 207}
208module_init(intel_crc_pmic_opregion_driver_init); 208module_init(intel_crc_pmic_opregion_driver_init);
209 209
210MODULE_DESCRIPTION("CrystalCove ACPI opration region driver"); 210MODULE_DESCRIPTION("CrystalCove ACPI operation region driver");
211MODULE_LICENSE("GPL"); 211MODULE_LICENSE("GPL");
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index c6bb9f1257c9..f98db0b50551 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -922,7 +922,7 @@ static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr)
922 return -EINVAL; 922 return -EINVAL;
923 923
924 drv->safe_state_index = -1; 924 drv->safe_state_index = -1;
925 for (i = 0; i < CPUIDLE_STATE_MAX; i++) { 925 for (i = CPUIDLE_DRIVER_STATE_START; i < CPUIDLE_STATE_MAX; i++) {
926 drv->states[i].name[0] = '\0'; 926 drv->states[i].name[0] = '\0';
927 drv->states[i].desc[0] = '\0'; 927 drv->states[i].desc[0] = '\0';
928 } 928 }
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index bbca7830e18a..69bc0d888c01 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -114,7 +114,12 @@ int acpi_scan_add_handler_with_hotplug(struct acpi_scan_handler *handler,
114 return 0; 114 return 0;
115} 115}
116 116
117/* 117/**
118 * create_pnp_modalias - Create hid/cid(s) string for modalias and uevent
119 * @acpi_dev: ACPI device object.
120 * @modalias: Buffer to print into.
121 * @size: Size of the buffer.
122 *
118 * Creates hid/cid(s) string needed for modalias and uevent 123 * Creates hid/cid(s) string needed for modalias and uevent
119 * e.g. on a device with hid:IBM0001 and cid:ACPI0001 you get: 124 * e.g. on a device with hid:IBM0001 and cid:ACPI0001 you get:
120 * char *modalias: "acpi:IBM0001:ACPI0001" 125 * char *modalias: "acpi:IBM0001:ACPI0001"
@@ -122,68 +127,98 @@ int acpi_scan_add_handler_with_hotplug(struct acpi_scan_handler *handler,
122 * -EINVAL: output error 127 * -EINVAL: output error
123 * -ENOMEM: output is truncated 128 * -ENOMEM: output is truncated
124*/ 129*/
125static int create_modalias(struct acpi_device *acpi_dev, char *modalias, 130static int create_pnp_modalias(struct acpi_device *acpi_dev, char *modalias,
126 int size) 131 int size)
127{ 132{
128 int len; 133 int len;
129 int count; 134 int count;
130 struct acpi_hardware_id *id; 135 struct acpi_hardware_id *id;
131 136
132 if (list_empty(&acpi_dev->pnp.ids))
133 return 0;
134
135 /* 137 /*
136 * If the device has PRP0001 we expose DT compatible modalias 138 * Since we skip PRP0001 from the modalias below, 0 should be returned
137 * instead in form of of:NnameTCcompatible. 139 * if PRP0001 is the only ACPI/PNP ID in the device's list.
138 */ 140 */
139 if (acpi_dev->data.of_compatible) { 141 count = 0;
140 struct acpi_buffer buf = { ACPI_ALLOCATE_BUFFER }; 142 list_for_each_entry(id, &acpi_dev->pnp.ids, list)
141 const union acpi_object *of_compatible, *obj; 143 if (strcmp(id->id, "PRP0001"))
142 int i, nval; 144 count++;
143 char *c;
144
145 acpi_get_name(acpi_dev->handle, ACPI_SINGLE_NAME, &buf);
146 /* DT strings are all in lower case */
147 for (c = buf.pointer; *c != '\0'; c++)
148 *c = tolower(*c);
149
150 len = snprintf(modalias, size, "of:N%sT", (char *)buf.pointer);
151 ACPI_FREE(buf.pointer);
152
153 of_compatible = acpi_dev->data.of_compatible;
154 if (of_compatible->type == ACPI_TYPE_PACKAGE) {
155 nval = of_compatible->package.count;
156 obj = of_compatible->package.elements;
157 } else { /* Must be ACPI_TYPE_STRING. */
158 nval = 1;
159 obj = of_compatible;
160 }
161 for (i = 0; i < nval; i++, obj++) {
162 count = snprintf(&modalias[len], size, "C%s",
163 obj->string.pointer);
164 if (count < 0)
165 return -EINVAL;
166 if (count >= size)
167 return -ENOMEM;
168
169 len += count;
170 size -= count;
171 }
172 } else {
173 len = snprintf(modalias, size, "acpi:");
174 size -= len;
175 145
176 list_for_each_entry(id, &acpi_dev->pnp.ids, list) { 146 if (!count)
177 count = snprintf(&modalias[len], size, "%s:", id->id); 147 return 0;
178 if (count < 0) 148
179 return -EINVAL; 149 len = snprintf(modalias, size, "acpi:");
180 if (count >= size) 150 if (len <= 0)
181 return -ENOMEM; 151 return len;
182 len += count; 152
183 size -= count; 153 size -= len;
184 } 154
155 list_for_each_entry(id, &acpi_dev->pnp.ids, list) {
156 if (!strcmp(id->id, "PRP0001"))
157 continue;
158
159 count = snprintf(&modalias[len], size, "%s:", id->id);
160 if (count < 0)
161 return -EINVAL;
162
163 if (count >= size)
164 return -ENOMEM;
165
166 len += count;
167 size -= count;
168 }
169 modalias[len] = '\0';
170 return len;
171}
172
173/**
174 * create_of_modalias - Creates DT compatible string for modalias and uevent
175 * @acpi_dev: ACPI device object.
176 * @modalias: Buffer to print into.
177 * @size: Size of the buffer.
178 *
179 * Expose DT compatible modalias as of:NnameTCcompatible. This function should
180 * only be called for devices having PRP0001 in their list of ACPI/PNP IDs.
181 */
182static int create_of_modalias(struct acpi_device *acpi_dev, char *modalias,
183 int size)
184{
185 struct acpi_buffer buf = { ACPI_ALLOCATE_BUFFER };
186 const union acpi_object *of_compatible, *obj;
187 int len, count;
188 int i, nval;
189 char *c;
190
191 acpi_get_name(acpi_dev->handle, ACPI_SINGLE_NAME, &buf);
192 /* DT strings are all in lower case */
193 for (c = buf.pointer; *c != '\0'; c++)
194 *c = tolower(*c);
195
196 len = snprintf(modalias, size, "of:N%sT", (char *)buf.pointer);
197 ACPI_FREE(buf.pointer);
198
199 if (len <= 0)
200 return len;
201
202 of_compatible = acpi_dev->data.of_compatible;
203 if (of_compatible->type == ACPI_TYPE_PACKAGE) {
204 nval = of_compatible->package.count;
205 obj = of_compatible->package.elements;
206 } else { /* Must be ACPI_TYPE_STRING. */
207 nval = 1;
208 obj = of_compatible;
185 } 209 }
210 for (i = 0; i < nval; i++, obj++) {
211 count = snprintf(&modalias[len], size, "C%s",
212 obj->string.pointer);
213 if (count < 0)
214 return -EINVAL;
186 215
216 if (count >= size)
217 return -ENOMEM;
218
219 len += count;
220 size -= count;
221 }
187 modalias[len] = '\0'; 222 modalias[len] = '\0';
188 return len; 223 return len;
189} 224}
@@ -194,7 +229,8 @@ static int create_modalias(struct acpi_device *acpi_dev, char *modalias,
194 * 229 *
195 * Check if the given device has an ACPI companion and if that companion has 230 * Check if the given device has an ACPI companion and if that companion has
196 * a valid list of PNP IDs, and if the device is the first (primary) physical 231 * a valid list of PNP IDs, and if the device is the first (primary) physical
197 * device associated with it. 232 * device associated with it. Return the companion pointer if that's the case
233 * or NULL otherwise.
198 * 234 *
199 * If multiple physical devices are attached to a single ACPI companion, we need 235 * If multiple physical devices are attached to a single ACPI companion, we need
200 * to be careful. The usage scenario for this kind of relationship is that all 236 * to be careful. The usage scenario for this kind of relationship is that all
@@ -208,88 +244,129 @@ static int create_modalias(struct acpi_device *acpi_dev, char *modalias,
208 * resources available from it but they will be matched normally using functions 244 * resources available from it but they will be matched normally using functions
209 * provided by their bus types (and analogously for their modalias). 245 * provided by their bus types (and analogously for their modalias).
210 */ 246 */
211static bool acpi_companion_match(const struct device *dev) 247static struct acpi_device *acpi_companion_match(const struct device *dev)
212{ 248{
213 struct acpi_device *adev; 249 struct acpi_device *adev;
214 bool ret; 250 struct mutex *physical_node_lock;
215 251
216 adev = ACPI_COMPANION(dev); 252 adev = ACPI_COMPANION(dev);
217 if (!adev) 253 if (!adev)
218 return false; 254 return NULL;
219 255
220 if (list_empty(&adev->pnp.ids)) 256 if (list_empty(&adev->pnp.ids))
221 return false; 257 return NULL;
222 258
223 mutex_lock(&adev->physical_node_lock); 259 physical_node_lock = &adev->physical_node_lock;
260 mutex_lock(physical_node_lock);
224 if (list_empty(&adev->physical_node_list)) { 261 if (list_empty(&adev->physical_node_list)) {
225 ret = false; 262 adev = NULL;
226 } else { 263 } else {
227 const struct acpi_device_physical_node *node; 264 const struct acpi_device_physical_node *node;
228 265
229 node = list_first_entry(&adev->physical_node_list, 266 node = list_first_entry(&adev->physical_node_list,
230 struct acpi_device_physical_node, node); 267 struct acpi_device_physical_node, node);
231 ret = node->dev == dev; 268 if (node->dev != dev)
269 adev = NULL;
232 } 270 }
233 mutex_unlock(&adev->physical_node_lock); 271 mutex_unlock(physical_node_lock);
234 272
235 return ret; 273 return adev;
236} 274}
237 275
238/* 276static int __acpi_device_uevent_modalias(struct acpi_device *adev,
239 * Creates uevent modalias field for ACPI enumerated devices. 277 struct kobj_uevent_env *env)
240 * Because the other buses does not support ACPI HIDs & CIDs.
241 * e.g. for a device with hid:IBM0001 and cid:ACPI0001 you get:
242 * "acpi:IBM0001:ACPI0001"
243 */
244int acpi_device_uevent_modalias(struct device *dev, struct kobj_uevent_env *env)
245{ 278{
246 int len; 279 int len;
247 280
248 if (!acpi_companion_match(dev)) 281 if (!adev)
249 return -ENODEV; 282 return -ENODEV;
250 283
284 if (list_empty(&adev->pnp.ids))
285 return 0;
286
251 if (add_uevent_var(env, "MODALIAS=")) 287 if (add_uevent_var(env, "MODALIAS="))
252 return -ENOMEM; 288 return -ENOMEM;
253 len = create_modalias(ACPI_COMPANION(dev), &env->buf[env->buflen - 1], 289
254 sizeof(env->buf) - env->buflen); 290 len = create_pnp_modalias(adev, &env->buf[env->buflen - 1],
255 if (len <= 0) 291 sizeof(env->buf) - env->buflen);
292 if (len < 0)
293 return len;
294
295 env->buflen += len;
296 if (!adev->data.of_compatible)
297 return 0;
298
299 if (len > 0 && add_uevent_var(env, "MODALIAS="))
300 return -ENOMEM;
301
302 len = create_of_modalias(adev, &env->buf[env->buflen - 1],
303 sizeof(env->buf) - env->buflen);
304 if (len < 0)
256 return len; 305 return len;
306
257 env->buflen += len; 307 env->buflen += len;
308
258 return 0; 309 return 0;
259} 310}
260EXPORT_SYMBOL_GPL(acpi_device_uevent_modalias);
261 311
262/* 312/*
263 * Creates modalias sysfs attribute for ACPI enumerated devices. 313 * Creates uevent modalias field for ACPI enumerated devices.
264 * Because the other buses does not support ACPI HIDs & CIDs. 314 * Because the other buses does not support ACPI HIDs & CIDs.
265 * e.g. for a device with hid:IBM0001 and cid:ACPI0001 you get: 315 * e.g. for a device with hid:IBM0001 and cid:ACPI0001 you get:
266 * "acpi:IBM0001:ACPI0001" 316 * "acpi:IBM0001:ACPI0001"
267 */ 317 */
268int acpi_device_modalias(struct device *dev, char *buf, int size) 318int acpi_device_uevent_modalias(struct device *dev, struct kobj_uevent_env *env)
269{ 319{
270 int len; 320 return __acpi_device_uevent_modalias(acpi_companion_match(dev), env);
321}
322EXPORT_SYMBOL_GPL(acpi_device_uevent_modalias);
271 323
272 if (!acpi_companion_match(dev)) 324static int __acpi_device_modalias(struct acpi_device *adev, char *buf, int size)
325{
326 int len, count;
327
328 if (!adev)
273 return -ENODEV; 329 return -ENODEV;
274 330
275 len = create_modalias(ACPI_COMPANION(dev), buf, size -1); 331 if (list_empty(&adev->pnp.ids))
276 if (len <= 0) 332 return 0;
333
334 len = create_pnp_modalias(adev, buf, size - 1);
335 if (len < 0) {
336 return len;
337 } else if (len > 0) {
338 buf[len++] = '\n';
339 size -= len;
340 }
341 if (!adev->data.of_compatible)
277 return len; 342 return len;
278 buf[len++] = '\n'; 343
344 count = create_of_modalias(adev, buf + len, size - 1);
345 if (count < 0) {
346 return count;
347 } else if (count > 0) {
348 len += count;
349 buf[len++] = '\n';
350 }
351
279 return len; 352 return len;
280} 353}
354
355/*
356 * Creates modalias sysfs attribute for ACPI enumerated devices.
357 * Because the other buses does not support ACPI HIDs & CIDs.
358 * e.g. for a device with hid:IBM0001 and cid:ACPI0001 you get:
359 * "acpi:IBM0001:ACPI0001"
360 */
361int acpi_device_modalias(struct device *dev, char *buf, int size)
362{
363 return __acpi_device_modalias(acpi_companion_match(dev), buf, size);
364}
281EXPORT_SYMBOL_GPL(acpi_device_modalias); 365EXPORT_SYMBOL_GPL(acpi_device_modalias);
282 366
283static ssize_t 367static ssize_t
284acpi_device_modalias_show(struct device *dev, struct device_attribute *attr, char *buf) { 368acpi_device_modalias_show(struct device *dev, struct device_attribute *attr, char *buf) {
285 struct acpi_device *acpi_dev = to_acpi_device(dev); 369 return __acpi_device_modalias(to_acpi_device(dev), buf, 1024);
286 int len;
287
288 len = create_modalias(acpi_dev, buf, 1024);
289 if (len <= 0)
290 return len;
291 buf[len++] = '\n';
292 return len;
293} 370}
294static DEVICE_ATTR(modalias, 0444, acpi_device_modalias_show, NULL); 371static DEVICE_ATTR(modalias, 0444, acpi_device_modalias_show, NULL);
295 372
@@ -894,8 +971,51 @@ static void acpi_device_remove_files(struct acpi_device *dev)
894 ACPI Bus operations 971 ACPI Bus operations
895 -------------------------------------------------------------------------- */ 972 -------------------------------------------------------------------------- */
896 973
974/**
975 * acpi_of_match_device - Match device object using the "compatible" property.
976 * @adev: ACPI device object to match.
977 * @of_match_table: List of device IDs to match against.
978 *
979 * If @dev has an ACPI companion which has the special PRP0001 device ID in its
980 * list of identifiers and a _DSD object with the "compatible" property, use
981 * that property to match against the given list of identifiers.
982 */
983static bool acpi_of_match_device(struct acpi_device *adev,
984 const struct of_device_id *of_match_table)
985{
986 const union acpi_object *of_compatible, *obj;
987 int i, nval;
988
989 if (!adev)
990 return false;
991
992 of_compatible = adev->data.of_compatible;
993 if (!of_match_table || !of_compatible)
994 return false;
995
996 if (of_compatible->type == ACPI_TYPE_PACKAGE) {
997 nval = of_compatible->package.count;
998 obj = of_compatible->package.elements;
999 } else { /* Must be ACPI_TYPE_STRING. */
1000 nval = 1;
1001 obj = of_compatible;
1002 }
1003 /* Now we can look for the driver DT compatible strings */
1004 for (i = 0; i < nval; i++, obj++) {
1005 const struct of_device_id *id;
1006
1007 for (id = of_match_table; id->compatible[0]; id++)
1008 if (!strcasecmp(obj->string.pointer, id->compatible))
1009 return true;
1010 }
1011
1012 return false;
1013}
1014
897static const struct acpi_device_id *__acpi_match_device( 1015static const struct acpi_device_id *__acpi_match_device(
898 struct acpi_device *device, const struct acpi_device_id *ids) 1016 struct acpi_device *device,
1017 const struct acpi_device_id *ids,
1018 const struct of_device_id *of_ids)
899{ 1019{
900 const struct acpi_device_id *id; 1020 const struct acpi_device_id *id;
901 struct acpi_hardware_id *hwid; 1021 struct acpi_hardware_id *hwid;
@@ -904,14 +1024,27 @@ static const struct acpi_device_id *__acpi_match_device(
904 * If the device is not present, it is unnecessary to load device 1024 * If the device is not present, it is unnecessary to load device
905 * driver for it. 1025 * driver for it.
906 */ 1026 */
907 if (!device->status.present) 1027 if (!device || !device->status.present)
908 return NULL; 1028 return NULL;
909 1029
910 for (id = ids; id->id[0]; id++) 1030 list_for_each_entry(hwid, &device->pnp.ids, list) {
911 list_for_each_entry(hwid, &device->pnp.ids, list) 1031 /* First, check the ACPI/PNP IDs provided by the caller. */
1032 for (id = ids; id->id[0]; id++)
912 if (!strcmp((char *) id->id, hwid->id)) 1033 if (!strcmp((char *) id->id, hwid->id))
913 return id; 1034 return id;
914 1035
1036 /*
1037 * Next, check the special "PRP0001" ID and try to match the
1038 * "compatible" property if found.
1039 *
1040 * The id returned by the below is not valid, but the only
1041 * caller passing non-NULL of_ids here is only interested in
1042 * whether or not the return value is NULL.
1043 */
1044 if (!strcmp("PRP0001", hwid->id)
1045 && acpi_of_match_device(device, of_ids))
1046 return id;
1047 }
915 return NULL; 1048 return NULL;
916} 1049}
917 1050
@@ -929,68 +1062,26 @@ static const struct acpi_device_id *__acpi_match_device(
929const struct acpi_device_id *acpi_match_device(const struct acpi_device_id *ids, 1062const struct acpi_device_id *acpi_match_device(const struct acpi_device_id *ids,
930 const struct device *dev) 1063 const struct device *dev)
931{ 1064{
932 struct acpi_device *adev; 1065 return __acpi_match_device(acpi_companion_match(dev), ids, NULL);
933 acpi_handle handle = ACPI_HANDLE(dev);
934
935 if (!ids || !handle || acpi_bus_get_device(handle, &adev))
936 return NULL;
937
938 if (!acpi_companion_match(dev))
939 return NULL;
940
941 return __acpi_match_device(adev, ids);
942} 1066}
943EXPORT_SYMBOL_GPL(acpi_match_device); 1067EXPORT_SYMBOL_GPL(acpi_match_device);
944 1068
945int acpi_match_device_ids(struct acpi_device *device, 1069int acpi_match_device_ids(struct acpi_device *device,
946 const struct acpi_device_id *ids) 1070 const struct acpi_device_id *ids)
947{ 1071{
948 return __acpi_match_device(device, ids) ? 0 : -ENOENT; 1072 return __acpi_match_device(device, ids, NULL) ? 0 : -ENOENT;
949} 1073}
950EXPORT_SYMBOL(acpi_match_device_ids); 1074EXPORT_SYMBOL(acpi_match_device_ids);
951 1075
952/* Performs match against special "PRP0001" shoehorn ACPI ID */
953static bool acpi_of_driver_match_device(struct device *dev,
954 const struct device_driver *drv)
955{
956 const union acpi_object *of_compatible, *obj;
957 struct acpi_device *adev;
958 int i, nval;
959
960 adev = ACPI_COMPANION(dev);
961 if (!adev)
962 return false;
963
964 of_compatible = adev->data.of_compatible;
965 if (!drv->of_match_table || !of_compatible)
966 return false;
967
968 if (of_compatible->type == ACPI_TYPE_PACKAGE) {
969 nval = of_compatible->package.count;
970 obj = of_compatible->package.elements;
971 } else { /* Must be ACPI_TYPE_STRING. */
972 nval = 1;
973 obj = of_compatible;
974 }
975 /* Now we can look for the driver DT compatible strings */
976 for (i = 0; i < nval; i++, obj++) {
977 const struct of_device_id *id;
978
979 for (id = drv->of_match_table; id->compatible[0]; id++)
980 if (!strcasecmp(obj->string.pointer, id->compatible))
981 return true;
982 }
983
984 return false;
985}
986
987bool acpi_driver_match_device(struct device *dev, 1076bool acpi_driver_match_device(struct device *dev,
988 const struct device_driver *drv) 1077 const struct device_driver *drv)
989{ 1078{
990 if (!drv->acpi_match_table) 1079 if (!drv->acpi_match_table)
991 return acpi_of_driver_match_device(dev, drv); 1080 return acpi_of_match_device(ACPI_COMPANION(dev),
1081 drv->of_match_table);
992 1082
993 return !!acpi_match_device(drv->acpi_match_table, dev); 1083 return !!__acpi_match_device(acpi_companion_match(dev),
1084 drv->acpi_match_table, drv->of_match_table);
994} 1085}
995EXPORT_SYMBOL_GPL(acpi_driver_match_device); 1086EXPORT_SYMBOL_GPL(acpi_driver_match_device);
996 1087
@@ -1031,20 +1122,7 @@ static int acpi_bus_match(struct device *dev, struct device_driver *drv)
1031 1122
1032static int acpi_device_uevent(struct device *dev, struct kobj_uevent_env *env) 1123static int acpi_device_uevent(struct device *dev, struct kobj_uevent_env *env)
1033{ 1124{
1034 struct acpi_device *acpi_dev = to_acpi_device(dev); 1125 return __acpi_device_uevent_modalias(to_acpi_device(dev), env);
1035 int len;
1036
1037 if (list_empty(&acpi_dev->pnp.ids))
1038 return 0;
1039
1040 if (add_uevent_var(env, "MODALIAS="))
1041 return -ENOMEM;
1042 len = create_modalias(acpi_dev, &env->buf[env->buflen - 1],
1043 sizeof(env->buf) - env->buflen);
1044 if (len <= 0)
1045 return len;
1046 env->buflen += len;
1047 return 0;
1048} 1126}
1049 1127
1050static void acpi_device_notify(acpi_handle handle, u32 event, void *data) 1128static void acpi_device_notify(acpi_handle handle, u32 event, void *data)
@@ -1062,10 +1140,10 @@ static void acpi_device_notify_fixed(void *data)
1062 acpi_device_notify(NULL, ACPI_FIXED_HARDWARE_EVENT, device); 1140 acpi_device_notify(NULL, ACPI_FIXED_HARDWARE_EVENT, device);
1063} 1141}
1064 1142
1065static acpi_status acpi_device_fixed_event(void *data) 1143static u32 acpi_device_fixed_event(void *data)
1066{ 1144{
1067 acpi_os_execute(OSL_NOTIFY_HANDLER, acpi_device_notify_fixed, data); 1145 acpi_os_execute(OSL_NOTIFY_HANDLER, acpi_device_notify_fixed, data);
1068 return AE_OK; 1146 return ACPI_INTERRUPT_HANDLED;
1069} 1147}
1070 1148
1071static int acpi_device_install_notify_handler(struct acpi_device *device) 1149static int acpi_device_install_notify_handler(struct acpi_device *device)
diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
index 7f251dd1a687..2f0d4db40a9e 100644
--- a/drivers/acpi/sleep.c
+++ b/drivers/acpi/sleep.c
@@ -629,6 +629,7 @@ static int acpi_freeze_begin(void)
629 629
630static int acpi_freeze_prepare(void) 630static int acpi_freeze_prepare(void)
631{ 631{
632 acpi_enable_wakeup_devices(ACPI_STATE_S0);
632 acpi_enable_all_wakeup_gpes(); 633 acpi_enable_all_wakeup_gpes();
633 acpi_os_wait_events_complete(); 634 acpi_os_wait_events_complete();
634 enable_irq_wake(acpi_gbl_FADT.sci_interrupt); 635 enable_irq_wake(acpi_gbl_FADT.sci_interrupt);
@@ -637,6 +638,7 @@ static int acpi_freeze_prepare(void)
637 638
638static void acpi_freeze_restore(void) 639static void acpi_freeze_restore(void)
639{ 640{
641 acpi_disable_wakeup_devices(ACPI_STATE_S0);
640 disable_irq_wake(acpi_gbl_FADT.sci_interrupt); 642 disable_irq_wake(acpi_gbl_FADT.sci_interrupt);
641 acpi_enable_all_runtime_gpes(); 643 acpi_enable_all_runtime_gpes();
642} 644}
@@ -806,21 +808,6 @@ static void acpi_sleep_hibernate_setup(void)
806static inline void acpi_sleep_hibernate_setup(void) {} 808static inline void acpi_sleep_hibernate_setup(void) {}
807#endif /* !CONFIG_HIBERNATION */ 809#endif /* !CONFIG_HIBERNATION */
808 810
809int acpi_suspend(u32 acpi_state)
810{
811 suspend_state_t states[] = {
812 [1] = PM_SUSPEND_STANDBY,
813 [3] = PM_SUSPEND_MEM,
814 [5] = PM_SUSPEND_MAX
815 };
816
817 if (acpi_state < 6 && states[acpi_state])
818 return pm_suspend(states[acpi_state]);
819 if (acpi_state == 4)
820 return hibernate();
821 return -EINVAL;
822}
823
824static void acpi_power_off_prepare(void) 811static void acpi_power_off_prepare(void)
825{ 812{
826 /* Prepare to power off the system */ 813 /* Prepare to power off the system */
diff --git a/drivers/acpi/sleep.h b/drivers/acpi/sleep.h
index 0143540a2519..c797ffa568d5 100644
--- a/drivers/acpi/sleep.h
+++ b/drivers/acpi/sleep.h
@@ -1,6 +1,4 @@
1 1
2extern int acpi_suspend(u32 state);
3
4extern void acpi_enable_wakeup_devices(u8 sleep_state); 2extern void acpi_enable_wakeup_devices(u8 sleep_state);
5extern void acpi_disable_wakeup_devices(u8 sleep_state); 3extern void acpi_disable_wakeup_devices(u8 sleep_state);
6 4
diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
index 13e577c80201..0876d77b3206 100644
--- a/drivers/acpi/sysfs.c
+++ b/drivers/acpi/sysfs.c
@@ -527,7 +527,7 @@ static ssize_t counter_show(struct kobject *kobj,
527 acpi_irq_not_handled; 527 acpi_irq_not_handled;
528 all_counters[num_gpes + ACPI_NUM_FIXED_EVENTS + COUNT_GPE].count = 528 all_counters[num_gpes + ACPI_NUM_FIXED_EVENTS + COUNT_GPE].count =
529 acpi_gpe_count; 529 acpi_gpe_count;
530 size = sprintf(buf, "%8d", all_counters[index].count); 530 size = sprintf(buf, "%8u", all_counters[index].count);
531 531
532 /* "gpe_all" or "sci" */ 532 /* "gpe_all" or "sci" */
533 if (index >= num_gpes + ACPI_NUM_FIXED_EVENTS) 533 if (index >= num_gpes + ACPI_NUM_FIXED_EVENTS)
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index 26eb70c8f518..cc79d3fedfb2 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -82,9 +82,15 @@ module_param(allow_duplicates, bool, 0644);
82 * For Windows 8 systems: used to decide if video module 82 * For Windows 8 systems: used to decide if video module
83 * should skip registering backlight interface of its own. 83 * should skip registering backlight interface of its own.
84 */ 84 */
85static int use_native_backlight_param = -1; 85enum {
86 NATIVE_BACKLIGHT_NOT_SET = -1,
87 NATIVE_BACKLIGHT_OFF,
88 NATIVE_BACKLIGHT_ON,
89};
90
91static int use_native_backlight_param = NATIVE_BACKLIGHT_NOT_SET;
86module_param_named(use_native_backlight, use_native_backlight_param, int, 0444); 92module_param_named(use_native_backlight, use_native_backlight_param, int, 0444);
87static bool use_native_backlight_dmi = true; 93static int use_native_backlight_dmi = NATIVE_BACKLIGHT_NOT_SET;
88 94
89static int register_count; 95static int register_count;
90static struct mutex video_list_lock; 96static struct mutex video_list_lock;
@@ -237,15 +243,16 @@ static void acpi_video_switch_brightness(struct work_struct *work);
237 243
238static bool acpi_video_use_native_backlight(void) 244static bool acpi_video_use_native_backlight(void)
239{ 245{
240 if (use_native_backlight_param != -1) 246 if (use_native_backlight_param != NATIVE_BACKLIGHT_NOT_SET)
241 return use_native_backlight_param; 247 return use_native_backlight_param;
242 else 248 else if (use_native_backlight_dmi != NATIVE_BACKLIGHT_NOT_SET)
243 return use_native_backlight_dmi; 249 return use_native_backlight_dmi;
250 return acpi_osi_is_win8();
244} 251}
245 252
246bool acpi_video_verify_backlight_support(void) 253bool acpi_video_verify_backlight_support(void)
247{ 254{
248 if (acpi_osi_is_win8() && acpi_video_use_native_backlight() && 255 if (acpi_video_use_native_backlight() &&
249 backlight_device_registered(BACKLIGHT_RAW)) 256 backlight_device_registered(BACKLIGHT_RAW))
250 return false; 257 return false;
251 return acpi_video_backlight_support(); 258 return acpi_video_backlight_support();
@@ -414,7 +421,13 @@ static int __init video_set_bqc_offset(const struct dmi_system_id *d)
414 421
415static int __init video_disable_native_backlight(const struct dmi_system_id *d) 422static int __init video_disable_native_backlight(const struct dmi_system_id *d)
416{ 423{
417 use_native_backlight_dmi = false; 424 use_native_backlight_dmi = NATIVE_BACKLIGHT_OFF;
425 return 0;
426}
427
428static int __init video_enable_native_backlight(const struct dmi_system_id *d)
429{
430 use_native_backlight_dmi = NATIVE_BACKLIGHT_ON;
418 return 0; 431 return 0;
419} 432}
420 433
@@ -559,6 +572,17 @@ static struct dmi_system_id video_dmi_table[] __initdata = {
559 DMI_MATCH(DMI_PRODUCT_NAME, "XPS L521X"), 572 DMI_MATCH(DMI_PRODUCT_NAME, "XPS L521X"),
560 }, 573 },
561 }, 574 },
575
576 /* Non win8 machines which need native backlight nevertheless */
577 {
578 /* https://bugzilla.redhat.com/show_bug.cgi?id=1187004 */
579 .callback = video_enable_native_backlight,
580 .ident = "Lenovo Ideapad Z570",
581 .matches = {
582 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
583 DMI_MATCH(DMI_PRODUCT_NAME, "102434U"),
584 },
585 },
562 {} 586 {}
563}; 587};
564 588
diff --git a/drivers/acpi/video_detect.c b/drivers/acpi/video_detect.c
index 27c43499977a..c42feb2bacd0 100644
--- a/drivers/acpi/video_detect.c
+++ b/drivers/acpi/video_detect.c
@@ -174,14 +174,6 @@ static struct dmi_system_id video_detect_dmi_table[] = {
174 DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 5737"), 174 DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 5737"),
175 }, 175 },
176 }, 176 },
177 {
178 .callback = video_detect_force_vendor,
179 .ident = "Lenovo IdeaPad Z570",
180 .matches = {
181 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
182 DMI_MATCH(DMI_PRODUCT_VERSION, "Ideapad Z570"),
183 },
184 },
185 { }, 177 { },
186}; 178};
187 179
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index ef150ebb4c30..23dac3babfe3 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -4204,9 +4204,18 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = {
4204 { "PIONEER DVD-RW DVR-216D", NULL, ATA_HORKAGE_NOSETXFER }, 4204 { "PIONEER DVD-RW DVR-216D", NULL, ATA_HORKAGE_NOSETXFER },
4205 4205
4206 /* devices that don't properly handle queued TRIM commands */ 4206 /* devices that don't properly handle queued TRIM commands */
4207 { "Micron_M[56]*", NULL, ATA_HORKAGE_NO_NCQ_TRIM | 4207 { "Micron_M500*", NULL, ATA_HORKAGE_NO_NCQ_TRIM |
4208 ATA_HORKAGE_ZERO_AFTER_TRIM, },
4209 { "Crucial_CT*M500*", NULL, ATA_HORKAGE_NO_NCQ_TRIM |
4210 ATA_HORKAGE_ZERO_AFTER_TRIM, },
4211 { "Micron_M5[15]0*", "MU01", ATA_HORKAGE_NO_NCQ_TRIM |
4212 ATA_HORKAGE_ZERO_AFTER_TRIM, },
4213 { "Crucial_CT*M550*", "MU01", ATA_HORKAGE_NO_NCQ_TRIM |
4214 ATA_HORKAGE_ZERO_AFTER_TRIM, },
4215 { "Crucial_CT*MX100*", "MU01", ATA_HORKAGE_NO_NCQ_TRIM |
4216 ATA_HORKAGE_ZERO_AFTER_TRIM, },
4217 { "Samsung SSD 850 PRO*", NULL, ATA_HORKAGE_NO_NCQ_TRIM |
4208 ATA_HORKAGE_ZERO_AFTER_TRIM, }, 4218 ATA_HORKAGE_ZERO_AFTER_TRIM, },
4209 { "Crucial_CT*SSD*", NULL, ATA_HORKAGE_NO_NCQ_TRIM, },
4210 4219
4211 /* 4220 /*
4212 * As defined, the DRAT (Deterministic Read After Trim) and RZAT 4221 * As defined, the DRAT (Deterministic Read After Trim) and RZAT
@@ -4226,6 +4235,8 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = {
4226 */ 4235 */
4227 { "INTEL*SSDSC2MH*", NULL, 0, }, 4236 { "INTEL*SSDSC2MH*", NULL, 0, },
4228 4237
4238 { "Micron*", NULL, ATA_HORKAGE_ZERO_AFTER_TRIM, },
4239 { "Crucial*", NULL, ATA_HORKAGE_ZERO_AFTER_TRIM, },
4229 { "INTEL*SSD*", NULL, ATA_HORKAGE_ZERO_AFTER_TRIM, }, 4240 { "INTEL*SSD*", NULL, ATA_HORKAGE_ZERO_AFTER_TRIM, },
4230 { "SSD*INTEL*", NULL, ATA_HORKAGE_ZERO_AFTER_TRIM, }, 4241 { "SSD*INTEL*", NULL, ATA_HORKAGE_ZERO_AFTER_TRIM, },
4231 { "Samsung*SSD*", NULL, ATA_HORKAGE_ZERO_AFTER_TRIM, }, 4242 { "Samsung*SSD*", NULL, ATA_HORKAGE_ZERO_AFTER_TRIM, },
diff --git a/drivers/ata/pata_isapnp.c b/drivers/ata/pata_isapnp.c
index b33d1f99b3a4..994f168b54a8 100644
--- a/drivers/ata/pata_isapnp.c
+++ b/drivers/ata/pata_isapnp.c
@@ -128,20 +128,8 @@ static struct pnp_driver isapnp_driver = {
128 .remove = isapnp_remove_one, 128 .remove = isapnp_remove_one,
129}; 129};
130 130
131static int __init isapnp_init(void) 131module_pnp_driver(isapnp_driver);
132{
133 return pnp_register_driver(&isapnp_driver);
134}
135
136static void __exit isapnp_exit(void)
137{
138 pnp_unregister_driver(&isapnp_driver);
139}
140
141MODULE_AUTHOR("Alan Cox"); 132MODULE_AUTHOR("Alan Cox");
142MODULE_DESCRIPTION("low-level driver for ISA PnP ATA"); 133MODULE_DESCRIPTION("low-level driver for ISA PnP ATA");
143MODULE_LICENSE("GPL"); 134MODULE_LICENSE("GPL");
144MODULE_VERSION(DRV_VERSION); 135MODULE_VERSION(DRV_VERSION);
145
146module_init(isapnp_init);
147module_exit(isapnp_exit);
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 07304a3b9ee2..c7e2a9a70865 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -12,6 +12,7 @@
12 12
13#include <linux/device.h> 13#include <linux/device.h>
14#include <linux/err.h> 14#include <linux/err.h>
15#include <linux/fwnode.h>
15#include <linux/init.h> 16#include <linux/init.h>
16#include <linux/module.h> 17#include <linux/module.h>
17#include <linux/slab.h> 18#include <linux/slab.h>
@@ -2133,3 +2134,53 @@ define_dev_printk_level(dev_notice, KERN_NOTICE);
2133define_dev_printk_level(_dev_info, KERN_INFO); 2134define_dev_printk_level(_dev_info, KERN_INFO);
2134 2135
2135#endif 2136#endif
2137
2138static inline bool fwnode_is_primary(struct fwnode_handle *fwnode)
2139{
2140 return fwnode && !IS_ERR(fwnode->secondary);
2141}
2142
2143/**
2144 * set_primary_fwnode - Change the primary firmware node of a given device.
2145 * @dev: Device to handle.
2146 * @fwnode: New primary firmware node of the device.
2147 *
2148 * Set the device's firmware node pointer to @fwnode, but if a secondary
2149 * firmware node of the device is present, preserve it.
2150 */
2151void set_primary_fwnode(struct device *dev, struct fwnode_handle *fwnode)
2152{
2153 if (fwnode) {
2154 struct fwnode_handle *fn = dev->fwnode;
2155
2156 if (fwnode_is_primary(fn))
2157 fn = fn->secondary;
2158
2159 fwnode->secondary = fn;
2160 dev->fwnode = fwnode;
2161 } else {
2162 dev->fwnode = fwnode_is_primary(dev->fwnode) ?
2163 dev->fwnode->secondary : NULL;
2164 }
2165}
2166EXPORT_SYMBOL_GPL(set_primary_fwnode);
2167
2168/**
2169 * set_secondary_fwnode - Change the secondary firmware node of a given device.
2170 * @dev: Device to handle.
2171 * @fwnode: New secondary firmware node of the device.
2172 *
2173 * If a primary firmware node of the device is present, set its secondary
2174 * pointer to @fwnode. Otherwise, set the device's firmware node pointer to
2175 * @fwnode.
2176 */
2177void set_secondary_fwnode(struct device *dev, struct fwnode_handle *fwnode)
2178{
2179 if (fwnode)
2180 fwnode->secondary = ERR_PTR(-ENODEV);
2181
2182 if (fwnode_is_primary(dev->fwnode))
2183 dev->fwnode->secondary = fwnode;
2184 else
2185 dev->fwnode = fwnode;
2186}
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index cdc779cf79a3..aeb744891e44 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -298,6 +298,12 @@ static int really_probe(struct device *dev, struct device_driver *drv)
298 goto probe_failed; 298 goto probe_failed;
299 } 299 }
300 300
301 if (dev->pm_domain && dev->pm_domain->activate) {
302 ret = dev->pm_domain->activate(dev);
303 if (ret)
304 goto probe_failed;
305 }
306
301 if (dev->bus->probe) { 307 if (dev->bus->probe) {
302 ret = dev->bus->probe(dev); 308 ret = dev->bus->probe(dev);
303 if (ret) 309 if (ret)
@@ -308,6 +314,9 @@ static int really_probe(struct device *dev, struct device_driver *drv)
308 goto probe_failed; 314 goto probe_failed;
309 } 315 }
310 316
317 if (dev->pm_domain && dev->pm_domain->sync)
318 dev->pm_domain->sync(dev);
319
311 driver_bound(dev); 320 driver_bound(dev);
312 ret = 1; 321 ret = 1;
313 pr_debug("bus: '%s': %s: bound device %s to driver %s\n", 322 pr_debug("bus: '%s': %s: bound device %s to driver %s\n",
@@ -319,6 +328,8 @@ probe_failed:
319 driver_sysfs_remove(dev); 328 driver_sysfs_remove(dev);
320 dev->driver = NULL; 329 dev->driver = NULL;
321 dev_set_drvdata(dev, NULL); 330 dev_set_drvdata(dev, NULL);
331 if (dev->pm_domain && dev->pm_domain->dismiss)
332 dev->pm_domain->dismiss(dev);
322 333
323 if (ret == -EPROBE_DEFER) { 334 if (ret == -EPROBE_DEFER) {
324 /* Driver requested deferred probing */ 335 /* Driver requested deferred probing */
@@ -525,6 +536,9 @@ static void __device_release_driver(struct device *dev)
525 devres_release_all(dev); 536 devres_release_all(dev);
526 dev->driver = NULL; 537 dev->driver = NULL;
527 dev_set_drvdata(dev, NULL); 538 dev_set_drvdata(dev, NULL);
539 if (dev->pm_domain && dev->pm_domain->dismiss)
540 dev->pm_domain->dismiss(dev);
541
528 klist_remove(&dev->p->knode_driver); 542 klist_remove(&dev->p->knode_driver);
529 if (dev->bus) 543 if (dev->bus)
530 blocking_notifier_call_chain(&dev->bus->p->bus_notifier, 544 blocking_notifier_call_chain(&dev->bus->p->bus_notifier,
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 9421fed40905..17f0204fabef 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -454,7 +454,7 @@ struct platform_device *platform_device_register_full(
454 goto err_alloc; 454 goto err_alloc;
455 455
456 pdev->dev.parent = pdevinfo->parent; 456 pdev->dev.parent = pdevinfo->parent;
457 ACPI_COMPANION_SET(&pdev->dev, pdevinfo->acpi_node.companion); 457 pdev->dev.fwnode = pdevinfo->fwnode;
458 458
459 if (pdevinfo->dma_mask) { 459 if (pdevinfo->dma_mask) {
460 /* 460 /*
diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
index 45937f88e77c..2327613d4539 100644
--- a/drivers/base/power/domain.c
+++ b/drivers/base/power/domain.c
@@ -68,7 +68,36 @@ static struct generic_pm_domain *pm_genpd_lookup_name(const char *domain_name)
68 return genpd; 68 return genpd;
69} 69}
70 70
71struct generic_pm_domain *dev_to_genpd(struct device *dev) 71/*
72 * Get the generic PM domain for a particular struct device.
73 * This validates the struct device pointer, the PM domain pointer,
74 * and checks that the PM domain pointer is a real generic PM domain.
75 * Any failure results in NULL being returned.
76 */
77struct generic_pm_domain *pm_genpd_lookup_dev(struct device *dev)
78{
79 struct generic_pm_domain *genpd = NULL, *gpd;
80
81 if (IS_ERR_OR_NULL(dev) || IS_ERR_OR_NULL(dev->pm_domain))
82 return NULL;
83
84 mutex_lock(&gpd_list_lock);
85 list_for_each_entry(gpd, &gpd_list, gpd_list_node) {
86 if (&gpd->domain == dev->pm_domain) {
87 genpd = gpd;
88 break;
89 }
90 }
91 mutex_unlock(&gpd_list_lock);
92
93 return genpd;
94}
95
96/*
97 * This should only be used where we are certain that the pm_domain
98 * attached to the device is a genpd domain.
99 */
100static struct generic_pm_domain *dev_to_genpd(struct device *dev)
72{ 101{
73 if (IS_ERR_OR_NULL(dev->pm_domain)) 102 if (IS_ERR_OR_NULL(dev->pm_domain))
74 return ERR_PTR(-EINVAL); 103 return ERR_PTR(-EINVAL);
@@ -173,8 +202,8 @@ static int genpd_power_on(struct generic_pm_domain *genpd)
173 genpd->power_on_latency_ns = elapsed_ns; 202 genpd->power_on_latency_ns = elapsed_ns;
174 genpd->max_off_time_changed = true; 203 genpd->max_off_time_changed = true;
175 genpd_recalc_cpu_exit_latency(genpd); 204 genpd_recalc_cpu_exit_latency(genpd);
176 pr_warn("%s: Power-%s latency exceeded, new value %lld ns\n", 205 pr_debug("%s: Power-%s latency exceeded, new value %lld ns\n",
177 genpd->name, "on", elapsed_ns); 206 genpd->name, "on", elapsed_ns);
178 207
179 return ret; 208 return ret;
180} 209}
@@ -199,8 +228,8 @@ static int genpd_power_off(struct generic_pm_domain *genpd)
199 228
200 genpd->power_off_latency_ns = elapsed_ns; 229 genpd->power_off_latency_ns = elapsed_ns;
201 genpd->max_off_time_changed = true; 230 genpd->max_off_time_changed = true;
202 pr_warn("%s: Power-%s latency exceeded, new value %lld ns\n", 231 pr_debug("%s: Power-%s latency exceeded, new value %lld ns\n",
203 genpd->name, "off", elapsed_ns); 232 genpd->name, "off", elapsed_ns);
204 233
205 return ret; 234 return ret;
206} 235}
@@ -1513,9 +1542,7 @@ int pm_genpd_remove_device(struct generic_pm_domain *genpd,
1513 1542
1514 dev_dbg(dev, "%s()\n", __func__); 1543 dev_dbg(dev, "%s()\n", __func__);
1515 1544
1516 if (IS_ERR_OR_NULL(genpd) || IS_ERR_OR_NULL(dev) 1545 if (!genpd || genpd != pm_genpd_lookup_dev(dev))
1517 || IS_ERR_OR_NULL(dev->pm_domain)
1518 || pd_to_genpd(dev->pm_domain) != genpd)
1519 return -EINVAL; 1546 return -EINVAL;
1520 1547
1521 /* The above validation also means we have existing domain_data. */ 1548 /* The above validation also means we have existing domain_data. */
@@ -2093,21 +2120,10 @@ EXPORT_SYMBOL_GPL(of_genpd_get_from_provider);
2093 */ 2120 */
2094static void genpd_dev_pm_detach(struct device *dev, bool power_off) 2121static void genpd_dev_pm_detach(struct device *dev, bool power_off)
2095{ 2122{
2096 struct generic_pm_domain *pd = NULL, *gpd; 2123 struct generic_pm_domain *pd;
2097 int ret = 0; 2124 int ret = 0;
2098 2125
2099 if (!dev->pm_domain) 2126 pd = pm_genpd_lookup_dev(dev);
2100 return;
2101
2102 mutex_lock(&gpd_list_lock);
2103 list_for_each_entry(gpd, &gpd_list, gpd_list_node) {
2104 if (&gpd->domain == dev->pm_domain) {
2105 pd = gpd;
2106 break;
2107 }
2108 }
2109 mutex_unlock(&gpd_list_lock);
2110
2111 if (!pd) 2127 if (!pd)
2112 return; 2128 return;
2113 2129
@@ -2130,6 +2146,17 @@ static void genpd_dev_pm_detach(struct device *dev, bool power_off)
2130 genpd_queue_power_off_work(pd); 2146 genpd_queue_power_off_work(pd);
2131} 2147}
2132 2148
2149static void genpd_dev_pm_sync(struct device *dev)
2150{
2151 struct generic_pm_domain *pd;
2152
2153 pd = dev_to_genpd(dev);
2154 if (IS_ERR(pd))
2155 return;
2156
2157 genpd_queue_power_off_work(pd);
2158}
2159
2133/** 2160/**
2134 * genpd_dev_pm_attach - Attach a device to its PM domain using DT. 2161 * genpd_dev_pm_attach - Attach a device to its PM domain using DT.
2135 * @dev: Device to attach. 2162 * @dev: Device to attach.
@@ -2196,6 +2223,7 @@ int genpd_dev_pm_attach(struct device *dev)
2196 } 2223 }
2197 2224
2198 dev->pm_domain->detach = genpd_dev_pm_detach; 2225 dev->pm_domain->detach = genpd_dev_pm_detach;
2226 dev->pm_domain->sync = genpd_dev_pm_sync;
2199 pm_genpd_poweron(pd); 2227 pm_genpd_poweron(pd);
2200 2228
2201 return 0; 2229 return 0;
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index 9717d5f20139..3d874eca7104 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -23,7 +23,7 @@
23#include <linux/mutex.h> 23#include <linux/mutex.h>
24#include <linux/pm.h> 24#include <linux/pm.h>
25#include <linux/pm_runtime.h> 25#include <linux/pm_runtime.h>
26#include <linux/resume-trace.h> 26#include <linux/pm-trace.h>
27#include <linux/interrupt.h> 27#include <linux/interrupt.h>
28#include <linux/sched.h> 28#include <linux/sched.h>
29#include <linux/async.h> 29#include <linux/async.h>
@@ -1017,6 +1017,9 @@ static int __device_suspend_noirq(struct device *dev, pm_message_t state, bool a
1017 char *info = NULL; 1017 char *info = NULL;
1018 int error = 0; 1018 int error = 0;
1019 1019
1020 TRACE_DEVICE(dev);
1021 TRACE_SUSPEND(0);
1022
1020 if (async_error) 1023 if (async_error)
1021 goto Complete; 1024 goto Complete;
1022 1025
@@ -1057,6 +1060,7 @@ static int __device_suspend_noirq(struct device *dev, pm_message_t state, bool a
1057 1060
1058Complete: 1061Complete:
1059 complete_all(&dev->power.completion); 1062 complete_all(&dev->power.completion);
1063 TRACE_SUSPEND(error);
1060 return error; 1064 return error;
1061} 1065}
1062 1066
@@ -1078,7 +1082,7 @@ static int device_suspend_noirq(struct device *dev)
1078{ 1082{
1079 reinit_completion(&dev->power.completion); 1083 reinit_completion(&dev->power.completion);
1080 1084
1081 if (pm_async_enabled && dev->power.async_suspend) { 1085 if (is_async(dev)) {
1082 get_device(dev); 1086 get_device(dev);
1083 async_schedule(async_suspend_noirq, dev); 1087 async_schedule(async_suspend_noirq, dev);
1084 return 0; 1088 return 0;
@@ -1157,6 +1161,9 @@ static int __device_suspend_late(struct device *dev, pm_message_t state, bool as
1157 char *info = NULL; 1161 char *info = NULL;
1158 int error = 0; 1162 int error = 0;
1159 1163
1164 TRACE_DEVICE(dev);
1165 TRACE_SUSPEND(0);
1166
1160 __pm_runtime_disable(dev, false); 1167 __pm_runtime_disable(dev, false);
1161 1168
1162 if (async_error) 1169 if (async_error)
@@ -1198,6 +1205,7 @@ static int __device_suspend_late(struct device *dev, pm_message_t state, bool as
1198 async_error = error; 1205 async_error = error;
1199 1206
1200Complete: 1207Complete:
1208 TRACE_SUSPEND(error);
1201 complete_all(&dev->power.completion); 1209 complete_all(&dev->power.completion);
1202 return error; 1210 return error;
1203} 1211}
@@ -1219,7 +1227,7 @@ static int device_suspend_late(struct device *dev)
1219{ 1227{
1220 reinit_completion(&dev->power.completion); 1228 reinit_completion(&dev->power.completion);
1221 1229
1222 if (pm_async_enabled && dev->power.async_suspend) { 1230 if (is_async(dev)) {
1223 get_device(dev); 1231 get_device(dev);
1224 async_schedule(async_suspend_late, dev); 1232 async_schedule(async_suspend_late, dev);
1225 return 0; 1233 return 0;
@@ -1338,6 +1346,9 @@ static int __device_suspend(struct device *dev, pm_message_t state, bool async)
1338 int error = 0; 1346 int error = 0;
1339 DECLARE_DPM_WATCHDOG_ON_STACK(wd); 1347 DECLARE_DPM_WATCHDOG_ON_STACK(wd);
1340 1348
1349 TRACE_DEVICE(dev);
1350 TRACE_SUSPEND(0);
1351
1341 dpm_wait_for_children(dev, async); 1352 dpm_wait_for_children(dev, async);
1342 1353
1343 if (async_error) 1354 if (async_error)
@@ -1444,6 +1455,7 @@ static int __device_suspend(struct device *dev, pm_message_t state, bool async)
1444 if (error) 1455 if (error)
1445 async_error = error; 1456 async_error = error;
1446 1457
1458 TRACE_SUSPEND(error);
1447 return error; 1459 return error;
1448} 1460}
1449 1461
@@ -1465,7 +1477,7 @@ static int device_suspend(struct device *dev)
1465{ 1477{
1466 reinit_completion(&dev->power.completion); 1478 reinit_completion(&dev->power.completion);
1467 1479
1468 if (pm_async_enabled && dev->power.async_suspend) { 1480 if (is_async(dev)) {
1469 get_device(dev); 1481 get_device(dev);
1470 async_schedule(async_suspend, dev); 1482 async_schedule(async_suspend, dev);
1471 return 0; 1483 return 0;
diff --git a/drivers/base/power/trace.c b/drivers/base/power/trace.c
index d94a1f5121cf..a311cfa4c5bd 100644
--- a/drivers/base/power/trace.c
+++ b/drivers/base/power/trace.c
@@ -7,7 +7,7 @@
7 * devices may be working. 7 * devices may be working.
8 */ 8 */
9 9
10#include <linux/resume-trace.h> 10#include <linux/pm-trace.h>
11#include <linux/export.h> 11#include <linux/export.h>
12#include <linux/rtc.h> 12#include <linux/rtc.h>
13 13
@@ -154,7 +154,7 @@ EXPORT_SYMBOL(set_trace_device);
154 * it's not any guarantee, but it's a high _likelihood_ that 154 * it's not any guarantee, but it's a high _likelihood_ that
155 * the match is valid). 155 * the match is valid).
156 */ 156 */
157void generate_resume_trace(const void *tracedata, unsigned int user) 157void generate_pm_trace(const void *tracedata, unsigned int user)
158{ 158{
159 unsigned short lineno = *(unsigned short *)tracedata; 159 unsigned short lineno = *(unsigned short *)tracedata;
160 const char *file = *(const char **)(tracedata + 2); 160 const char *file = *(const char **)(tracedata + 2);
@@ -164,7 +164,7 @@ void generate_resume_trace(const void *tracedata, unsigned int user)
164 file_hash_value = hash_string(lineno, file, FILEHASH); 164 file_hash_value = hash_string(lineno, file, FILEHASH);
165 set_magic_time(user_hash_value, file_hash_value, dev_hash_value); 165 set_magic_time(user_hash_value, file_hash_value, dev_hash_value);
166} 166}
167EXPORT_SYMBOL(generate_resume_trace); 167EXPORT_SYMBOL(generate_pm_trace);
168 168
169extern char __tracedata_start, __tracedata_end; 169extern char __tracedata_start, __tracedata_end;
170static int show_file_hash(unsigned int value) 170static int show_file_hash(unsigned int value)
diff --git a/drivers/base/property.c b/drivers/base/property.c
index c45845874d4f..6a3f7d8af341 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -10,10 +10,102 @@
10 * published by the Free Software Foundation. 10 * published by the Free Software Foundation.
11 */ 11 */
12 12
13#include <linux/property.h>
14#include <linux/export.h>
15#include <linux/acpi.h> 13#include <linux/acpi.h>
14#include <linux/export.h>
15#include <linux/kernel.h>
16#include <linux/of.h> 16#include <linux/of.h>
17#include <linux/property.h>
18
19/**
20 * device_add_property_set - Add a collection of properties to a device object.
21 * @dev: Device to add properties to.
22 * @pset: Collection of properties to add.
23 *
24 * Associate a collection of device properties represented by @pset with @dev
25 * as its secondary firmware node.
26 */
27void device_add_property_set(struct device *dev, struct property_set *pset)
28{
29 if (pset)
30 pset->fwnode.type = FWNODE_PDATA;
31
32 set_secondary_fwnode(dev, &pset->fwnode);
33}
34EXPORT_SYMBOL_GPL(device_add_property_set);
35
36static inline bool is_pset(struct fwnode_handle *fwnode)
37{
38 return fwnode && fwnode->type == FWNODE_PDATA;
39}
40
41static inline struct property_set *to_pset(struct fwnode_handle *fwnode)
42{
43 return is_pset(fwnode) ?
44 container_of(fwnode, struct property_set, fwnode) : NULL;
45}
46
47static struct property_entry *pset_prop_get(struct property_set *pset,
48 const char *name)
49{
50 struct property_entry *prop;
51
52 if (!pset || !pset->properties)
53 return NULL;
54
55 for (prop = pset->properties; prop->name; prop++)
56 if (!strcmp(name, prop->name))
57 return prop;
58
59 return NULL;
60}
61
62static int pset_prop_read_array(struct property_set *pset, const char *name,
63 enum dev_prop_type type, void *val, size_t nval)
64{
65 struct property_entry *prop;
66 unsigned int item_size;
67
68 prop = pset_prop_get(pset, name);
69 if (!prop)
70 return -ENODATA;
71
72 if (prop->type != type)
73 return -EPROTO;
74
75 if (!val)
76 return prop->nval;
77
78 if (prop->nval < nval)
79 return -EOVERFLOW;
80
81 switch (type) {
82 case DEV_PROP_U8:
83 item_size = sizeof(u8);
84 break;
85 case DEV_PROP_U16:
86 item_size = sizeof(u16);
87 break;
88 case DEV_PROP_U32:
89 item_size = sizeof(u32);
90 break;
91 case DEV_PROP_U64:
92 item_size = sizeof(u64);
93 break;
94 case DEV_PROP_STRING:
95 item_size = sizeof(const char *);
96 break;
97 default:
98 return -EINVAL;
99 }
100 memcpy(val, prop->value.raw_data, nval * item_size);
101 return 0;
102}
103
104static inline struct fwnode_handle *dev_fwnode(struct device *dev)
105{
106 return IS_ENABLED(CONFIG_OF) && dev->of_node ?
107 &dev->of_node->fwnode : dev->fwnode;
108}
17 109
18/** 110/**
19 * device_property_present - check if a property of a device is present 111 * device_property_present - check if a property of a device is present
@@ -24,10 +116,7 @@
24 */ 116 */
25bool device_property_present(struct device *dev, const char *propname) 117bool device_property_present(struct device *dev, const char *propname)
26{ 118{
27 if (IS_ENABLED(CONFIG_OF) && dev->of_node) 119 return fwnode_property_present(dev_fwnode(dev), propname);
28 return of_property_read_bool(dev->of_node, propname);
29
30 return !acpi_dev_prop_get(ACPI_COMPANION(dev), propname, NULL);
31} 120}
32EXPORT_SYMBOL_GPL(device_property_present); 121EXPORT_SYMBOL_GPL(device_property_present);
33 122
@@ -43,32 +132,22 @@ bool fwnode_property_present(struct fwnode_handle *fwnode, const char *propname)
43 else if (is_acpi_node(fwnode)) 132 else if (is_acpi_node(fwnode))
44 return !acpi_dev_prop_get(acpi_node(fwnode), propname, NULL); 133 return !acpi_dev_prop_get(acpi_node(fwnode), propname, NULL);
45 134
46 return false; 135 return !!pset_prop_get(to_pset(fwnode), propname);
47} 136}
48EXPORT_SYMBOL_GPL(fwnode_property_present); 137EXPORT_SYMBOL_GPL(fwnode_property_present);
49 138
50#define OF_DEV_PROP_READ_ARRAY(node, propname, type, val, nval) \
51 (val) ? of_property_read_##type##_array((node), (propname), (val), (nval)) \
52 : of_property_count_elems_of_size((node), (propname), sizeof(type))
53
54#define DEV_PROP_READ_ARRAY(_dev_, _propname_, _type_, _proptype_, _val_, _nval_) \
55 IS_ENABLED(CONFIG_OF) && _dev_->of_node ? \
56 (OF_DEV_PROP_READ_ARRAY(_dev_->of_node, _propname_, _type_, \
57 _val_, _nval_)) : \
58 acpi_dev_prop_read(ACPI_COMPANION(_dev_), _propname_, \
59 _proptype_, _val_, _nval_)
60
61/** 139/**
62 * device_property_read_u8_array - return a u8 array property of a device 140 * device_property_read_u8_array - return a u8 array property of a device
63 * @dev: Device to get the property of 141 * @dev: Device to get the property of
64 * @propname: Name of the property 142 * @propname: Name of the property
65 * @val: The values are stored here 143 * @val: The values are stored here or %NULL to return the number of values
66 * @nval: Size of the @val array 144 * @nval: Size of the @val array
67 * 145 *
68 * Function reads an array of u8 properties with @propname from the device 146 * Function reads an array of u8 properties with @propname from the device
69 * firmware description and stores them to @val if found. 147 * firmware description and stores them to @val if found.
70 * 148 *
71 * Return: %0 if the property was found (success), 149 * Return: number of values if @val was %NULL,
150 * %0 if the property was found (success),
72 * %-EINVAL if given arguments are not valid, 151 * %-EINVAL if given arguments are not valid,
73 * %-ENODATA if the property does not have a value, 152 * %-ENODATA if the property does not have a value,
74 * %-EPROTO if the property is not an array of numbers, 153 * %-EPROTO if the property is not an array of numbers,
@@ -77,7 +156,7 @@ EXPORT_SYMBOL_GPL(fwnode_property_present);
77int device_property_read_u8_array(struct device *dev, const char *propname, 156int device_property_read_u8_array(struct device *dev, const char *propname,
78 u8 *val, size_t nval) 157 u8 *val, size_t nval)
79{ 158{
80 return DEV_PROP_READ_ARRAY(dev, propname, u8, DEV_PROP_U8, val, nval); 159 return fwnode_property_read_u8_array(dev_fwnode(dev), propname, val, nval);
81} 160}
82EXPORT_SYMBOL_GPL(device_property_read_u8_array); 161EXPORT_SYMBOL_GPL(device_property_read_u8_array);
83 162
@@ -85,13 +164,14 @@ EXPORT_SYMBOL_GPL(device_property_read_u8_array);
85 * device_property_read_u16_array - return a u16 array property of a device 164 * device_property_read_u16_array - return a u16 array property of a device
86 * @dev: Device to get the property of 165 * @dev: Device to get the property of
87 * @propname: Name of the property 166 * @propname: Name of the property
88 * @val: The values are stored here 167 * @val: The values are stored here or %NULL to return the number of values
89 * @nval: Size of the @val array 168 * @nval: Size of the @val array
90 * 169 *
91 * Function reads an array of u16 properties with @propname from the device 170 * Function reads an array of u16 properties with @propname from the device
92 * firmware description and stores them to @val if found. 171 * firmware description and stores them to @val if found.
93 * 172 *
94 * Return: %0 if the property was found (success), 173 * Return: number of values if @val was %NULL,
174 * %0 if the property was found (success),
95 * %-EINVAL if given arguments are not valid, 175 * %-EINVAL if given arguments are not valid,
96 * %-ENODATA if the property does not have a value, 176 * %-ENODATA if the property does not have a value,
97 * %-EPROTO if the property is not an array of numbers, 177 * %-EPROTO if the property is not an array of numbers,
@@ -100,7 +180,7 @@ EXPORT_SYMBOL_GPL(device_property_read_u8_array);
100int device_property_read_u16_array(struct device *dev, const char *propname, 180int device_property_read_u16_array(struct device *dev, const char *propname,
101 u16 *val, size_t nval) 181 u16 *val, size_t nval)
102{ 182{
103 return DEV_PROP_READ_ARRAY(dev, propname, u16, DEV_PROP_U16, val, nval); 183 return fwnode_property_read_u16_array(dev_fwnode(dev), propname, val, nval);
104} 184}
105EXPORT_SYMBOL_GPL(device_property_read_u16_array); 185EXPORT_SYMBOL_GPL(device_property_read_u16_array);
106 186
@@ -108,13 +188,14 @@ EXPORT_SYMBOL_GPL(device_property_read_u16_array);
108 * device_property_read_u32_array - return a u32 array property of a device 188 * device_property_read_u32_array - return a u32 array property of a device
109 * @dev: Device to get the property of 189 * @dev: Device to get the property of
110 * @propname: Name of the property 190 * @propname: Name of the property
111 * @val: The values are stored here 191 * @val: The values are stored here or %NULL to return the number of values
112 * @nval: Size of the @val array 192 * @nval: Size of the @val array
113 * 193 *
114 * Function reads an array of u32 properties with @propname from the device 194 * Function reads an array of u32 properties with @propname from the device
115 * firmware description and stores them to @val if found. 195 * firmware description and stores them to @val if found.
116 * 196 *
117 * Return: %0 if the property was found (success), 197 * Return: number of values if @val was %NULL,
198 * %0 if the property was found (success),
118 * %-EINVAL if given arguments are not valid, 199 * %-EINVAL if given arguments are not valid,
119 * %-ENODATA if the property does not have a value, 200 * %-ENODATA if the property does not have a value,
120 * %-EPROTO if the property is not an array of numbers, 201 * %-EPROTO if the property is not an array of numbers,
@@ -123,7 +204,7 @@ EXPORT_SYMBOL_GPL(device_property_read_u16_array);
123int device_property_read_u32_array(struct device *dev, const char *propname, 204int device_property_read_u32_array(struct device *dev, const char *propname,
124 u32 *val, size_t nval) 205 u32 *val, size_t nval)
125{ 206{
126 return DEV_PROP_READ_ARRAY(dev, propname, u32, DEV_PROP_U32, val, nval); 207 return fwnode_property_read_u32_array(dev_fwnode(dev), propname, val, nval);
127} 208}
128EXPORT_SYMBOL_GPL(device_property_read_u32_array); 209EXPORT_SYMBOL_GPL(device_property_read_u32_array);
129 210
@@ -131,13 +212,14 @@ EXPORT_SYMBOL_GPL(device_property_read_u32_array);
131 * device_property_read_u64_array - return a u64 array property of a device 212 * device_property_read_u64_array - return a u64 array property of a device
132 * @dev: Device to get the property of 213 * @dev: Device to get the property of
133 * @propname: Name of the property 214 * @propname: Name of the property
134 * @val: The values are stored here 215 * @val: The values are stored here or %NULL to return the number of values
135 * @nval: Size of the @val array 216 * @nval: Size of the @val array
136 * 217 *
137 * Function reads an array of u64 properties with @propname from the device 218 * Function reads an array of u64 properties with @propname from the device
138 * firmware description and stores them to @val if found. 219 * firmware description and stores them to @val if found.
139 * 220 *
140 * Return: %0 if the property was found (success), 221 * Return: number of values if @val was %NULL,
222 * %0 if the property was found (success),
141 * %-EINVAL if given arguments are not valid, 223 * %-EINVAL if given arguments are not valid,
142 * %-ENODATA if the property does not have a value, 224 * %-ENODATA if the property does not have a value,
143 * %-EPROTO if the property is not an array of numbers, 225 * %-EPROTO if the property is not an array of numbers,
@@ -146,7 +228,7 @@ EXPORT_SYMBOL_GPL(device_property_read_u32_array);
146int device_property_read_u64_array(struct device *dev, const char *propname, 228int device_property_read_u64_array(struct device *dev, const char *propname,
147 u64 *val, size_t nval) 229 u64 *val, size_t nval)
148{ 230{
149 return DEV_PROP_READ_ARRAY(dev, propname, u64, DEV_PROP_U64, val, nval); 231 return fwnode_property_read_u64_array(dev_fwnode(dev), propname, val, nval);
150} 232}
151EXPORT_SYMBOL_GPL(device_property_read_u64_array); 233EXPORT_SYMBOL_GPL(device_property_read_u64_array);
152 234
@@ -154,13 +236,14 @@ EXPORT_SYMBOL_GPL(device_property_read_u64_array);
154 * device_property_read_string_array - return a string array property of device 236 * device_property_read_string_array - return a string array property of device
155 * @dev: Device to get the property of 237 * @dev: Device to get the property of
156 * @propname: Name of the property 238 * @propname: Name of the property
157 * @val: The values are stored here 239 * @val: The values are stored here or %NULL to return the number of values
158 * @nval: Size of the @val array 240 * @nval: Size of the @val array
159 * 241 *
160 * Function reads an array of string properties with @propname from the device 242 * Function reads an array of string properties with @propname from the device
161 * firmware description and stores them to @val if found. 243 * firmware description and stores them to @val if found.
162 * 244 *
163 * Return: %0 if the property was found (success), 245 * Return: number of values if @val was %NULL,
246 * %0 if the property was found (success),
164 * %-EINVAL if given arguments are not valid, 247 * %-EINVAL if given arguments are not valid,
165 * %-ENODATA if the property does not have a value, 248 * %-ENODATA if the property does not have a value,
166 * %-EPROTO or %-EILSEQ if the property is not an array of strings, 249 * %-EPROTO or %-EILSEQ if the property is not an array of strings,
@@ -169,10 +252,7 @@ EXPORT_SYMBOL_GPL(device_property_read_u64_array);
169int device_property_read_string_array(struct device *dev, const char *propname, 252int device_property_read_string_array(struct device *dev, const char *propname,
170 const char **val, size_t nval) 253 const char **val, size_t nval)
171{ 254{
172 return IS_ENABLED(CONFIG_OF) && dev->of_node ? 255 return fwnode_property_read_string_array(dev_fwnode(dev), propname, val, nval);
173 of_property_read_string_array(dev->of_node, propname, val, nval) :
174 acpi_dev_prop_read(ACPI_COMPANION(dev), propname,
175 DEV_PROP_STRING, val, nval);
176} 256}
177EXPORT_SYMBOL_GPL(device_property_read_string_array); 257EXPORT_SYMBOL_GPL(device_property_read_string_array);
178 258
@@ -193,13 +273,14 @@ EXPORT_SYMBOL_GPL(device_property_read_string_array);
193int device_property_read_string(struct device *dev, const char *propname, 273int device_property_read_string(struct device *dev, const char *propname,
194 const char **val) 274 const char **val)
195{ 275{
196 return IS_ENABLED(CONFIG_OF) && dev->of_node ? 276 return fwnode_property_read_string(dev_fwnode(dev), propname, val);
197 of_property_read_string(dev->of_node, propname, val) :
198 acpi_dev_prop_read(ACPI_COMPANION(dev), propname,
199 DEV_PROP_STRING, val, 1);
200} 277}
201EXPORT_SYMBOL_GPL(device_property_read_string); 278EXPORT_SYMBOL_GPL(device_property_read_string);
202 279
280#define OF_DEV_PROP_READ_ARRAY(node, propname, type, val, nval) \
281 (val) ? of_property_read_##type##_array((node), (propname), (val), (nval)) \
282 : of_property_count_elems_of_size((node), (propname), sizeof(type))
283
203#define FWNODE_PROP_READ_ARRAY(_fwnode_, _propname_, _type_, _proptype_, _val_, _nval_) \ 284#define FWNODE_PROP_READ_ARRAY(_fwnode_, _propname_, _type_, _proptype_, _val_, _nval_) \
204({ \ 285({ \
205 int _ret_; \ 286 int _ret_; \
@@ -210,7 +291,8 @@ EXPORT_SYMBOL_GPL(device_property_read_string);
210 _ret_ = acpi_dev_prop_read(acpi_node(_fwnode_), _propname_, \ 291 _ret_ = acpi_dev_prop_read(acpi_node(_fwnode_), _propname_, \
211 _proptype_, _val_, _nval_); \ 292 _proptype_, _val_, _nval_); \
212 else \ 293 else \
213 _ret_ = -ENXIO; \ 294 _ret_ = pset_prop_read_array(to_pset(_fwnode_), _propname_, \
295 _proptype_, _val_, _nval_); \
214 _ret_; \ 296 _ret_; \
215}) 297})
216 298
@@ -218,13 +300,14 @@ EXPORT_SYMBOL_GPL(device_property_read_string);
218 * fwnode_property_read_u8_array - return a u8 array property of firmware node 300 * fwnode_property_read_u8_array - return a u8 array property of firmware node
219 * @fwnode: Firmware node to get the property of 301 * @fwnode: Firmware node to get the property of
220 * @propname: Name of the property 302 * @propname: Name of the property
221 * @val: The values are stored here 303 * @val: The values are stored here or %NULL to return the number of values
222 * @nval: Size of the @val array 304 * @nval: Size of the @val array
223 * 305 *
224 * Read an array of u8 properties with @propname from @fwnode and stores them to 306 * Read an array of u8 properties with @propname from @fwnode and stores them to
225 * @val if found. 307 * @val if found.
226 * 308 *
227 * Return: %0 if the property was found (success), 309 * Return: number of values if @val was %NULL,
310 * %0 if the property was found (success),
228 * %-EINVAL if given arguments are not valid, 311 * %-EINVAL if given arguments are not valid,
229 * %-ENODATA if the property does not have a value, 312 * %-ENODATA if the property does not have a value,
230 * %-EPROTO if the property is not an array of numbers, 313 * %-EPROTO if the property is not an array of numbers,
@@ -243,13 +326,14 @@ EXPORT_SYMBOL_GPL(fwnode_property_read_u8_array);
243 * fwnode_property_read_u16_array - return a u16 array property of firmware node 326 * fwnode_property_read_u16_array - return a u16 array property of firmware node
244 * @fwnode: Firmware node to get the property of 327 * @fwnode: Firmware node to get the property of
245 * @propname: Name of the property 328 * @propname: Name of the property
246 * @val: The values are stored here 329 * @val: The values are stored here or %NULL to return the number of values
247 * @nval: Size of the @val array 330 * @nval: Size of the @val array
248 * 331 *
249 * Read an array of u16 properties with @propname from @fwnode and store them to 332 * Read an array of u16 properties with @propname from @fwnode and store them to
250 * @val if found. 333 * @val if found.
251 * 334 *
252 * Return: %0 if the property was found (success), 335 * Return: number of values if @val was %NULL,
336 * %0 if the property was found (success),
253 * %-EINVAL if given arguments are not valid, 337 * %-EINVAL if given arguments are not valid,
254 * %-ENODATA if the property does not have a value, 338 * %-ENODATA if the property does not have a value,
255 * %-EPROTO if the property is not an array of numbers, 339 * %-EPROTO if the property is not an array of numbers,
@@ -268,13 +352,14 @@ EXPORT_SYMBOL_GPL(fwnode_property_read_u16_array);
268 * fwnode_property_read_u32_array - return a u32 array property of firmware node 352 * fwnode_property_read_u32_array - return a u32 array property of firmware node
269 * @fwnode: Firmware node to get the property of 353 * @fwnode: Firmware node to get the property of
270 * @propname: Name of the property 354 * @propname: Name of the property
271 * @val: The values are stored here 355 * @val: The values are stored here or %NULL to return the number of values
272 * @nval: Size of the @val array 356 * @nval: Size of the @val array
273 * 357 *
274 * Read an array of u32 properties with @propname from @fwnode store them to 358 * Read an array of u32 properties with @propname from @fwnode store them to
275 * @val if found. 359 * @val if found.
276 * 360 *
277 * Return: %0 if the property was found (success), 361 * Return: number of values if @val was %NULL,
362 * %0 if the property was found (success),
278 * %-EINVAL if given arguments are not valid, 363 * %-EINVAL if given arguments are not valid,
279 * %-ENODATA if the property does not have a value, 364 * %-ENODATA if the property does not have a value,
280 * %-EPROTO if the property is not an array of numbers, 365 * %-EPROTO if the property is not an array of numbers,
@@ -293,13 +378,14 @@ EXPORT_SYMBOL_GPL(fwnode_property_read_u32_array);
293 * fwnode_property_read_u64_array - return a u64 array property firmware node 378 * fwnode_property_read_u64_array - return a u64 array property firmware node
294 * @fwnode: Firmware node to get the property of 379 * @fwnode: Firmware node to get the property of
295 * @propname: Name of the property 380 * @propname: Name of the property
296 * @val: The values are stored here 381 * @val: The values are stored here or %NULL to return the number of values
297 * @nval: Size of the @val array 382 * @nval: Size of the @val array
298 * 383 *
299 * Read an array of u64 properties with @propname from @fwnode and store them to 384 * Read an array of u64 properties with @propname from @fwnode and store them to
300 * @val if found. 385 * @val if found.
301 * 386 *
302 * Return: %0 if the property was found (success), 387 * Return: number of values if @val was %NULL,
388 * %0 if the property was found (success),
303 * %-EINVAL if given arguments are not valid, 389 * %-EINVAL if given arguments are not valid,
304 * %-ENODATA if the property does not have a value, 390 * %-ENODATA if the property does not have a value,
305 * %-EPROTO if the property is not an array of numbers, 391 * %-EPROTO if the property is not an array of numbers,
@@ -318,13 +404,14 @@ EXPORT_SYMBOL_GPL(fwnode_property_read_u64_array);
318 * fwnode_property_read_string_array - return string array property of a node 404 * fwnode_property_read_string_array - return string array property of a node
319 * @fwnode: Firmware node to get the property of 405 * @fwnode: Firmware node to get the property of
320 * @propname: Name of the property 406 * @propname: Name of the property
321 * @val: The values are stored here 407 * @val: The values are stored here or %NULL to return the number of values
322 * @nval: Size of the @val array 408 * @nval: Size of the @val array
323 * 409 *
324 * Read an string list property @propname from the given firmware node and store 410 * Read an string list property @propname from the given firmware node and store
325 * them to @val if found. 411 * them to @val if found.
326 * 412 *
327 * Return: %0 if the property was found (success), 413 * Return: number of values if @val was %NULL,
414 * %0 if the property was found (success),
328 * %-EINVAL if given arguments are not valid, 415 * %-EINVAL if given arguments are not valid,
329 * %-ENODATA if the property does not have a value, 416 * %-ENODATA if the property does not have a value,
330 * %-EPROTO if the property is not an array of strings, 417 * %-EPROTO if the property is not an array of strings,
@@ -336,13 +423,16 @@ int fwnode_property_read_string_array(struct fwnode_handle *fwnode,
336 size_t nval) 423 size_t nval)
337{ 424{
338 if (is_of_node(fwnode)) 425 if (is_of_node(fwnode))
339 return of_property_read_string_array(of_node(fwnode), propname, 426 return val ?
340 val, nval); 427 of_property_read_string_array(of_node(fwnode), propname,
428 val, nval) :
429 of_property_count_strings(of_node(fwnode), propname);
341 else if (is_acpi_node(fwnode)) 430 else if (is_acpi_node(fwnode))
342 return acpi_dev_prop_read(acpi_node(fwnode), propname, 431 return acpi_dev_prop_read(acpi_node(fwnode), propname,
343 DEV_PROP_STRING, val, nval); 432 DEV_PROP_STRING, val, nval);
344 433
345 return -ENXIO; 434 return pset_prop_read_array(to_pset(fwnode), propname,
435 DEV_PROP_STRING, val, nval);
346} 436}
347EXPORT_SYMBOL_GPL(fwnode_property_read_string_array); 437EXPORT_SYMBOL_GPL(fwnode_property_read_string_array);
348 438
diff --git a/drivers/char/ipmi/ipmi_powernv.c b/drivers/char/ipmi/ipmi_powernv.c
index 79524ed2a3cb..8753b0f6a317 100644
--- a/drivers/char/ipmi/ipmi_powernv.c
+++ b/drivers/char/ipmi/ipmi_powernv.c
@@ -125,6 +125,7 @@ static int ipmi_powernv_recv(struct ipmi_smi_powernv *smi)
125 spin_lock_irqsave(&smi->msg_lock, flags); 125 spin_lock_irqsave(&smi->msg_lock, flags);
126 126
127 if (!smi->cur_msg) { 127 if (!smi->cur_msg) {
128 spin_unlock_irqrestore(&smi->msg_lock, flags);
128 pr_warn("no current message?\n"); 129 pr_warn("no current message?\n");
129 return 0; 130 return 0;
130 } 131 }
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
index f6646ed3047e..518585c1ce94 100644
--- a/drivers/char/ipmi/ipmi_si_intf.c
+++ b/drivers/char/ipmi/ipmi_si_intf.c
@@ -263,6 +263,11 @@ struct smi_info {
263 bool supports_event_msg_buff; 263 bool supports_event_msg_buff;
264 264
265 /* 265 /*
266 * Can we clear the global enables receive irq bit?
267 */
268 bool cannot_clear_recv_irq_bit;
269
270 /*
266 * Did we get an attention that we did not handle? 271 * Did we get an attention that we did not handle?
267 */ 272 */
268 bool got_attn; 273 bool got_attn;
@@ -461,6 +466,9 @@ static void smi_mod_timer(struct smi_info *smi_info, unsigned long new_val)
461 * allocate messages, we just leave them in the BMC and run the system 466 * allocate messages, we just leave them in the BMC and run the system
462 * polled until we can allocate some memory. Once we have some 467 * polled until we can allocate some memory. Once we have some
463 * memory, we will re-enable the interrupt. 468 * memory, we will re-enable the interrupt.
469 *
470 * Note that we cannot just use disable_irq(), since the interrupt may
471 * be shared.
464 */ 472 */
465static inline bool disable_si_irq(struct smi_info *smi_info) 473static inline bool disable_si_irq(struct smi_info *smi_info)
466{ 474{
@@ -549,20 +557,15 @@ static u8 current_global_enables(struct smi_info *smi_info, u8 base,
549 557
550 if (smi_info->supports_event_msg_buff) 558 if (smi_info->supports_event_msg_buff)
551 enables |= IPMI_BMC_EVT_MSG_BUFF; 559 enables |= IPMI_BMC_EVT_MSG_BUFF;
552 else
553 enables &= ~IPMI_BMC_EVT_MSG_BUFF;
554 560
555 if (smi_info->irq && !smi_info->interrupt_disabled) 561 if ((smi_info->irq && !smi_info->interrupt_disabled) ||
562 smi_info->cannot_clear_recv_irq_bit)
556 enables |= IPMI_BMC_RCV_MSG_INTR; 563 enables |= IPMI_BMC_RCV_MSG_INTR;
557 else
558 enables &= ~IPMI_BMC_RCV_MSG_INTR;
559 564
560 if (smi_info->supports_event_msg_buff && 565 if (smi_info->supports_event_msg_buff &&
561 smi_info->irq && !smi_info->interrupt_disabled) 566 smi_info->irq && !smi_info->interrupt_disabled)
562 567
563 enables |= IPMI_BMC_EVT_MSG_INTR; 568 enables |= IPMI_BMC_EVT_MSG_INTR;
564 else
565 enables &= ~IPMI_BMC_EVT_MSG_INTR;
566 569
567 *irq_on = enables & (IPMI_BMC_EVT_MSG_INTR | IPMI_BMC_RCV_MSG_INTR); 570 *irq_on = enables & (IPMI_BMC_EVT_MSG_INTR | IPMI_BMC_RCV_MSG_INTR);
568 571
@@ -2900,6 +2903,96 @@ static int try_get_dev_id(struct smi_info *smi_info)
2900 return rv; 2903 return rv;
2901} 2904}
2902 2905
2906/*
2907 * Some BMCs do not support clearing the receive irq bit in the global
2908 * enables (even if they don't support interrupts on the BMC). Check
2909 * for this and handle it properly.
2910 */
2911static void check_clr_rcv_irq(struct smi_info *smi_info)
2912{
2913 unsigned char msg[3];
2914 unsigned char *resp;
2915 unsigned long resp_len;
2916 int rv;
2917
2918 resp = kmalloc(IPMI_MAX_MSG_LENGTH, GFP_KERNEL);
2919 if (!resp) {
2920 printk(KERN_WARNING PFX "Out of memory allocating response for"
2921 " global enables command, cannot check recv irq bit"
2922 " handling.\n");
2923 return;
2924 }
2925
2926 msg[0] = IPMI_NETFN_APP_REQUEST << 2;
2927 msg[1] = IPMI_GET_BMC_GLOBAL_ENABLES_CMD;
2928 smi_info->handlers->start_transaction(smi_info->si_sm, msg, 2);
2929
2930 rv = wait_for_msg_done(smi_info);
2931 if (rv) {
2932 printk(KERN_WARNING PFX "Error getting response from get"
2933 " global enables command, cannot check recv irq bit"
2934 " handling.\n");
2935 goto out;
2936 }
2937
2938 resp_len = smi_info->handlers->get_result(smi_info->si_sm,
2939 resp, IPMI_MAX_MSG_LENGTH);
2940
2941 if (resp_len < 4 ||
2942 resp[0] != (IPMI_NETFN_APP_REQUEST | 1) << 2 ||
2943 resp[1] != IPMI_GET_BMC_GLOBAL_ENABLES_CMD ||
2944 resp[2] != 0) {
2945 printk(KERN_WARNING PFX "Invalid return from get global"
2946 " enables command, cannot check recv irq bit"
2947 " handling.\n");
2948 rv = -EINVAL;
2949 goto out;
2950 }
2951
2952 if ((resp[3] & IPMI_BMC_RCV_MSG_INTR) == 0)
2953 /* Already clear, should work ok. */
2954 goto out;
2955
2956 msg[0] = IPMI_NETFN_APP_REQUEST << 2;
2957 msg[1] = IPMI_SET_BMC_GLOBAL_ENABLES_CMD;
2958 msg[2] = resp[3] & ~IPMI_BMC_RCV_MSG_INTR;
2959 smi_info->handlers->start_transaction(smi_info->si_sm, msg, 3);
2960
2961 rv = wait_for_msg_done(smi_info);
2962 if (rv) {
2963 printk(KERN_WARNING PFX "Error getting response from set"
2964 " global enables command, cannot check recv irq bit"
2965 " handling.\n");
2966 goto out;
2967 }
2968
2969 resp_len = smi_info->handlers->get_result(smi_info->si_sm,
2970 resp, IPMI_MAX_MSG_LENGTH);
2971
2972 if (resp_len < 3 ||
2973 resp[0] != (IPMI_NETFN_APP_REQUEST | 1) << 2 ||
2974 resp[1] != IPMI_SET_BMC_GLOBAL_ENABLES_CMD) {
2975 printk(KERN_WARNING PFX "Invalid return from get global"
2976 " enables command, cannot check recv irq bit"
2977 " handling.\n");
2978 rv = -EINVAL;
2979 goto out;
2980 }
2981
2982 if (resp[2] != 0) {
2983 /*
2984 * An error when setting the event buffer bit means
2985 * clearing the bit is not supported.
2986 */
2987 printk(KERN_WARNING PFX "The BMC does not support clearing"
2988 " the recv irq bit, compensating, but the BMC needs to"
2989 " be fixed.\n");
2990 smi_info->cannot_clear_recv_irq_bit = true;
2991 }
2992 out:
2993 kfree(resp);
2994}
2995
2903static int try_enable_event_buffer(struct smi_info *smi_info) 2996static int try_enable_event_buffer(struct smi_info *smi_info)
2904{ 2997{
2905 unsigned char msg[3]; 2998 unsigned char msg[3];
@@ -3395,6 +3488,8 @@ static int try_smi_init(struct smi_info *new_smi)
3395 goto out_err; 3488 goto out_err;
3396 } 3489 }
3397 3490
3491 check_clr_rcv_irq(new_smi);
3492
3398 setup_oem_data_handler(new_smi); 3493 setup_oem_data_handler(new_smi);
3399 setup_xaction_handlers(new_smi); 3494 setup_xaction_handlers(new_smi);
3400 3495
diff --git a/drivers/char/ipmi/ipmi_ssif.c b/drivers/char/ipmi/ipmi_ssif.c
index f6e378dac5f5..f40e3bd2c69c 100644
--- a/drivers/char/ipmi/ipmi_ssif.c
+++ b/drivers/char/ipmi/ipmi_ssif.c
@@ -468,11 +468,13 @@ static int ipmi_ssif_thread(void *data)
468 int result; 468 int result;
469 469
470 /* Wait for something to do */ 470 /* Wait for something to do */
471 wait_for_completion(&ssif_info->wake_thread); 471 result = wait_for_completion_interruptible(
472 init_completion(&ssif_info->wake_thread); 472 &ssif_info->wake_thread);
473
474 if (ssif_info->stopping) 473 if (ssif_info->stopping)
475 break; 474 break;
475 if (result == -ERESTARTSYS)
476 continue;
477 init_completion(&ssif_info->wake_thread);
476 478
477 if (ssif_info->i2c_read_write == I2C_SMBUS_WRITE) { 479 if (ssif_info->i2c_read_write == I2C_SMBUS_WRITE) {
478 result = i2c_smbus_write_block_data( 480 result = i2c_smbus_write_block_data(
diff --git a/drivers/char/tpm/tpm_infineon.c b/drivers/char/tpm/tpm_infineon.c
index 6d492132ad2b..29ba520ac24d 100644
--- a/drivers/char/tpm/tpm_infineon.c
+++ b/drivers/char/tpm/tpm_infineon.c
@@ -637,18 +637,7 @@ static struct pnp_driver tpm_inf_pnp_driver = {
637 .remove = tpm_inf_pnp_remove 637 .remove = tpm_inf_pnp_remove
638}; 638};
639 639
640static int __init init_inf(void) 640module_pnp_driver(tpm_inf_pnp_driver);
641{
642 return pnp_register_driver(&tpm_inf_pnp_driver);
643}
644
645static void __exit cleanup_inf(void)
646{
647 pnp_unregister_driver(&tpm_inf_pnp_driver);
648}
649
650module_init(init_inf);
651module_exit(cleanup_inf);
652 641
653MODULE_AUTHOR("Marcel Selhorst <tpmdd@sirrix.com>"); 642MODULE_AUTHOR("Marcel Selhorst <tpmdd@sirrix.com>");
654MODULE_DESCRIPTION("Driver for Infineon TPM SLD 9630 TT 1.1 / SLB 9635 TT 1.2"); 643MODULE_DESCRIPTION("Driver for Infineon TPM SLD 9630 TT 1.1 / SLB 9635 TT 1.2");
diff --git a/drivers/cpufreq/Kconfig b/drivers/cpufreq/Kconfig
index a171fef2c2b6..659879a56dba 100644
--- a/drivers/cpufreq/Kconfig
+++ b/drivers/cpufreq/Kconfig
@@ -293,5 +293,13 @@ config SH_CPU_FREQ
293 If unsure, say N. 293 If unsure, say N.
294endif 294endif
295 295
296config QORIQ_CPUFREQ
297 tristate "CPU frequency scaling driver for Freescale QorIQ SoCs"
298 depends on OF && COMMON_CLK && (PPC_E500MC || ARM)
299 select CLK_QORIQ
300 help
301 This adds the CPUFreq driver support for Freescale QorIQ SoCs
302 which are capable of changing the CPU's frequency dynamically.
303
296endif 304endif
297endmenu 305endmenu
diff --git a/drivers/cpufreq/Kconfig.arm b/drivers/cpufreq/Kconfig.arm
index 1b06fc4640e2..4f3dbc8cf729 100644
--- a/drivers/cpufreq/Kconfig.arm
+++ b/drivers/cpufreq/Kconfig.arm
@@ -108,6 +108,15 @@ config ARM_HIGHBANK_CPUFREQ
108 108
109 If in doubt, say N. 109 If in doubt, say N.
110 110
111config ARM_HISI_ACPU_CPUFREQ
112 tristate "Hisilicon ACPU CPUfreq driver"
113 depends on ARCH_HISI && CPUFREQ_DT
114 select PM_OPP
115 help
116 This enables the hisilicon ACPU CPUfreq driver.
117
118 If in doubt, say N.
119
111config ARM_IMX6Q_CPUFREQ 120config ARM_IMX6Q_CPUFREQ
112 tristate "Freescale i.MX6 cpufreq support" 121 tristate "Freescale i.MX6 cpufreq support"
113 depends on ARCH_MXC 122 depends on ARCH_MXC
diff --git a/drivers/cpufreq/Kconfig.powerpc b/drivers/cpufreq/Kconfig.powerpc
index 7ea24413cee6..3a0595b41eab 100644
--- a/drivers/cpufreq/Kconfig.powerpc
+++ b/drivers/cpufreq/Kconfig.powerpc
@@ -23,15 +23,6 @@ config CPU_FREQ_MAPLE
23 This adds support for frequency switching on Maple 970FX 23 This adds support for frequency switching on Maple 970FX
24 Evaluation Board and compatible boards (IBM JS2x blades). 24 Evaluation Board and compatible boards (IBM JS2x blades).
25 25
26config PPC_CORENET_CPUFREQ
27 tristate "CPU frequency scaling driver for Freescale E500MC SoCs"
28 depends on PPC_E500MC && OF && COMMON_CLK
29 select CLK_QORIQ
30 help
31 This adds the CPUFreq driver support for Freescale e500mc,
32 e5500 and e6500 series SoCs which are capable of changing
33 the CPU's frequency dynamically.
34
35config CPU_FREQ_PMAC 26config CPU_FREQ_PMAC
36 bool "Support for Apple PowerBooks" 27 bool "Support for Apple PowerBooks"
37 depends on ADB_PMU && PPC32 28 depends on ADB_PMU && PPC32
diff --git a/drivers/cpufreq/Makefile b/drivers/cpufreq/Makefile
index 82a1821471fd..cdce92ae2e8b 100644
--- a/drivers/cpufreq/Makefile
+++ b/drivers/cpufreq/Makefile
@@ -59,6 +59,7 @@ arm-exynos-cpufreq-$(CONFIG_ARM_EXYNOS4X12_CPUFREQ) += exynos4x12-cpufreq.o
59arm-exynos-cpufreq-$(CONFIG_ARM_EXYNOS5250_CPUFREQ) += exynos5250-cpufreq.o 59arm-exynos-cpufreq-$(CONFIG_ARM_EXYNOS5250_CPUFREQ) += exynos5250-cpufreq.o
60obj-$(CONFIG_ARM_EXYNOS5440_CPUFREQ) += exynos5440-cpufreq.o 60obj-$(CONFIG_ARM_EXYNOS5440_CPUFREQ) += exynos5440-cpufreq.o
61obj-$(CONFIG_ARM_HIGHBANK_CPUFREQ) += highbank-cpufreq.o 61obj-$(CONFIG_ARM_HIGHBANK_CPUFREQ) += highbank-cpufreq.o
62obj-$(CONFIG_ARM_HISI_ACPU_CPUFREQ) += hisi-acpu-cpufreq.o
62obj-$(CONFIG_ARM_IMX6Q_CPUFREQ) += imx6q-cpufreq.o 63obj-$(CONFIG_ARM_IMX6Q_CPUFREQ) += imx6q-cpufreq.o
63obj-$(CONFIG_ARM_INTEGRATOR) += integrator-cpufreq.o 64obj-$(CONFIG_ARM_INTEGRATOR) += integrator-cpufreq.o
64obj-$(CONFIG_ARM_KIRKWOOD_CPUFREQ) += kirkwood-cpufreq.o 65obj-$(CONFIG_ARM_KIRKWOOD_CPUFREQ) += kirkwood-cpufreq.o
@@ -85,7 +86,7 @@ obj-$(CONFIG_CPU_FREQ_CBE) += ppc-cbe-cpufreq.o
85ppc-cbe-cpufreq-y += ppc_cbe_cpufreq_pervasive.o ppc_cbe_cpufreq.o 86ppc-cbe-cpufreq-y += ppc_cbe_cpufreq_pervasive.o ppc_cbe_cpufreq.o
86obj-$(CONFIG_CPU_FREQ_CBE_PMI) += ppc_cbe_cpufreq_pmi.o 87obj-$(CONFIG_CPU_FREQ_CBE_PMI) += ppc_cbe_cpufreq_pmi.o
87obj-$(CONFIG_CPU_FREQ_MAPLE) += maple-cpufreq.o 88obj-$(CONFIG_CPU_FREQ_MAPLE) += maple-cpufreq.o
88obj-$(CONFIG_PPC_CORENET_CPUFREQ) += ppc-corenet-cpufreq.o 89obj-$(CONFIG_QORIQ_CPUFREQ) += qoriq-cpufreq.o
89obj-$(CONFIG_CPU_FREQ_PMAC) += pmac32-cpufreq.o 90obj-$(CONFIG_CPU_FREQ_PMAC) += pmac32-cpufreq.o
90obj-$(CONFIG_CPU_FREQ_PMAC64) += pmac64-cpufreq.o 91obj-$(CONFIG_CPU_FREQ_PMAC64) += pmac64-cpufreq.o
91obj-$(CONFIG_PPC_PASEMI_CPUFREQ) += pasemi-cpufreq.o 92obj-$(CONFIG_PPC_PASEMI_CPUFREQ) += pasemi-cpufreq.o
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 28e59a48b35f..8ae655c364f4 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -1698,15 +1698,18 @@ void cpufreq_resume(void)
1698 || __cpufreq_governor(policy, CPUFREQ_GOV_LIMITS)) 1698 || __cpufreq_governor(policy, CPUFREQ_GOV_LIMITS))
1699 pr_err("%s: Failed to start governor for policy: %p\n", 1699 pr_err("%s: Failed to start governor for policy: %p\n",
1700 __func__, policy); 1700 __func__, policy);
1701
1702 /*
1703 * schedule call cpufreq_update_policy() for boot CPU, i.e. last
1704 * policy in list. It will verify that the current freq is in
1705 * sync with what we believe it to be.
1706 */
1707 if (list_is_last(&policy->policy_list, &cpufreq_policy_list))
1708 schedule_work(&policy->update);
1709 } 1701 }
1702
1703 /*
1704 * schedule call cpufreq_update_policy() for first-online CPU, as that
1705 * wouldn't be hotplugged-out on suspend. It will verify that the
1706 * current freq is in sync with what we believe it to be.
1707 */
1708 policy = cpufreq_cpu_get_raw(cpumask_first(cpu_online_mask));
1709 if (WARN_ON(!policy))
1710 return;
1711
1712 schedule_work(&policy->update);
1710} 1713}
1711 1714
1712/** 1715/**
diff --git a/drivers/cpufreq/hisi-acpu-cpufreq.c b/drivers/cpufreq/hisi-acpu-cpufreq.c
new file mode 100644
index 000000000000..026d5b2224de
--- /dev/null
+++ b/drivers/cpufreq/hisi-acpu-cpufreq.c
@@ -0,0 +1,42 @@
1/*
2 * Hisilicon Platforms Using ACPU CPUFreq Support
3 *
4 * Copyright (c) 2015 Hisilicon Limited.
5 * Copyright (c) 2015 Linaro Limited.
6 *
7 * Leo Yan <leo.yan@linaro.org>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 *
13 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
14 * kind, whether express or implied; without even the implied warranty
15 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 */
18
19#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
20
21#include <linux/err.h>
22#include <linux/init.h>
23#include <linux/kernel.h>
24#include <linux/module.h>
25#include <linux/of.h>
26#include <linux/platform_device.h>
27
28static int __init hisi_acpu_cpufreq_driver_init(void)
29{
30 struct platform_device *pdev;
31
32 if (!of_machine_is_compatible("hisilicon,hi6220"))
33 return -ENODEV;
34
35 pdev = platform_device_register_simple("cpufreq-dt", -1, NULL, 0);
36 return PTR_ERR_OR_ZERO(pdev);
37}
38module_init(hisi_acpu_cpufreq_driver_init);
39
40MODULE_AUTHOR("Leo Yan <leo.yan@linaro.org>");
41MODULE_DESCRIPTION("Hisilicon acpu cpufreq driver");
42MODULE_LICENSE("GPL v2");
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index 872c5772c5d3..c5b81beccc8e 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -614,6 +614,19 @@ static void core_set_pstate(struct cpudata *cpudata, int pstate)
614 wrmsrl_on_cpu(cpudata->cpu, MSR_IA32_PERF_CTL, val); 614 wrmsrl_on_cpu(cpudata->cpu, MSR_IA32_PERF_CTL, val);
615} 615}
616 616
617static int knl_get_turbo_pstate(void)
618{
619 u64 value;
620 int nont, ret;
621
622 rdmsrl(MSR_NHM_TURBO_RATIO_LIMIT, value);
623 nont = core_get_max_pstate();
624 ret = (((value) >> 8) & 0xFF);
625 if (ret <= nont)
626 ret = nont;
627 return ret;
628}
629
617static struct cpu_defaults core_params = { 630static struct cpu_defaults core_params = {
618 .pid_policy = { 631 .pid_policy = {
619 .sample_rate_ms = 10, 632 .sample_rate_ms = 10,
@@ -651,6 +664,23 @@ static struct cpu_defaults byt_params = {
651 }, 664 },
652}; 665};
653 666
667static struct cpu_defaults knl_params = {
668 .pid_policy = {
669 .sample_rate_ms = 10,
670 .deadband = 0,
671 .setpoint = 97,
672 .p_gain_pct = 20,
673 .d_gain_pct = 0,
674 .i_gain_pct = 0,
675 },
676 .funcs = {
677 .get_max = core_get_max_pstate,
678 .get_min = core_get_min_pstate,
679 .get_turbo = knl_get_turbo_pstate,
680 .set = core_set_pstate,
681 },
682};
683
654static void intel_pstate_get_min_max(struct cpudata *cpu, int *min, int *max) 684static void intel_pstate_get_min_max(struct cpudata *cpu, int *min, int *max)
655{ 685{
656 int max_perf = cpu->pstate.turbo_pstate; 686 int max_perf = cpu->pstate.turbo_pstate;
@@ -865,6 +895,7 @@ static const struct x86_cpu_id intel_pstate_cpu_ids[] = {
865 ICPU(0x4e, core_params), 895 ICPU(0x4e, core_params),
866 ICPU(0x4f, core_params), 896 ICPU(0x4f, core_params),
867 ICPU(0x56, core_params), 897 ICPU(0x56, core_params),
898 ICPU(0x57, knl_params),
868 {} 899 {}
869}; 900};
870MODULE_DEVICE_TABLE(x86cpu, intel_pstate_cpu_ids); 901MODULE_DEVICE_TABLE(x86cpu, intel_pstate_cpu_ids);
@@ -1024,25 +1055,11 @@ static unsigned int force_load;
1024 1055
1025static int intel_pstate_msrs_not_valid(void) 1056static int intel_pstate_msrs_not_valid(void)
1026{ 1057{
1027 /* Check that all the msr's we are using are valid. */
1028 u64 aperf, mperf, tmp;
1029
1030 rdmsrl(MSR_IA32_APERF, aperf);
1031 rdmsrl(MSR_IA32_MPERF, mperf);
1032
1033 if (!pstate_funcs.get_max() || 1058 if (!pstate_funcs.get_max() ||
1034 !pstate_funcs.get_min() || 1059 !pstate_funcs.get_min() ||
1035 !pstate_funcs.get_turbo()) 1060 !pstate_funcs.get_turbo())
1036 return -ENODEV; 1061 return -ENODEV;
1037 1062
1038 rdmsrl(MSR_IA32_APERF, tmp);
1039 if (!(tmp - aperf))
1040 return -ENODEV;
1041
1042 rdmsrl(MSR_IA32_MPERF, tmp);
1043 if (!(tmp - mperf))
1044 return -ENODEV;
1045
1046 return 0; 1063 return 0;
1047} 1064}
1048 1065
diff --git a/drivers/cpufreq/powernv-cpufreq.c b/drivers/cpufreq/powernv-cpufreq.c
index 2dfd4fdb5a52..ebef0d8279c7 100644
--- a/drivers/cpufreq/powernv-cpufreq.c
+++ b/drivers/cpufreq/powernv-cpufreq.c
@@ -34,9 +34,13 @@
34#include <asm/smp.h> /* Required for cpu_sibling_mask() in UP configs */ 34#include <asm/smp.h> /* Required for cpu_sibling_mask() in UP configs */
35 35
36#define POWERNV_MAX_PSTATES 256 36#define POWERNV_MAX_PSTATES 256
37#define PMSR_PSAFE_ENABLE (1UL << 30)
38#define PMSR_SPR_EM_DISABLE (1UL << 31)
39#define PMSR_MAX(x) ((x >> 32) & 0xFF)
40#define PMSR_LP(x) ((x >> 48) & 0xFF)
37 41
38static struct cpufreq_frequency_table powernv_freqs[POWERNV_MAX_PSTATES+1]; 42static struct cpufreq_frequency_table powernv_freqs[POWERNV_MAX_PSTATES+1];
39static bool rebooting; 43static bool rebooting, throttled;
40 44
41/* 45/*
42 * Note: The set of pstates consists of contiguous integers, the 46 * Note: The set of pstates consists of contiguous integers, the
@@ -294,6 +298,44 @@ static inline unsigned int get_nominal_index(void)
294 return powernv_pstate_info.max - powernv_pstate_info.nominal; 298 return powernv_pstate_info.max - powernv_pstate_info.nominal;
295} 299}
296 300
301static void powernv_cpufreq_throttle_check(unsigned int cpu)
302{
303 unsigned long pmsr;
304 int pmsr_pmax, pmsr_lp;
305
306 pmsr = get_pmspr(SPRN_PMSR);
307
308 /* Check for Pmax Capping */
309 pmsr_pmax = (s8)PMSR_MAX(pmsr);
310 if (pmsr_pmax != powernv_pstate_info.max) {
311 throttled = true;
312 pr_info("CPU %d Pmax is reduced to %d\n", cpu, pmsr_pmax);
313 pr_info("Max allowed Pstate is capped\n");
314 }
315
316 /*
317 * Check for Psafe by reading LocalPstate
318 * or check if Psafe_mode_active is set in PMSR.
319 */
320 pmsr_lp = (s8)PMSR_LP(pmsr);
321 if ((pmsr_lp < powernv_pstate_info.min) ||
322 (pmsr & PMSR_PSAFE_ENABLE)) {
323 throttled = true;
324 pr_info("Pstate set to safe frequency\n");
325 }
326
327 /* Check if SPR_EM_DISABLE is set in PMSR */
328 if (pmsr & PMSR_SPR_EM_DISABLE) {
329 throttled = true;
330 pr_info("Frequency Control disabled from OS\n");
331 }
332
333 if (throttled) {
334 pr_info("PMSR = %16lx\n", pmsr);
335 pr_crit("CPU Frequency could be throttled\n");
336 }
337}
338
297/* 339/*
298 * powernv_cpufreq_target_index: Sets the frequency corresponding to 340 * powernv_cpufreq_target_index: Sets the frequency corresponding to
299 * the cpufreq table entry indexed by new_index on the cpus in the 341 * the cpufreq table entry indexed by new_index on the cpus in the
@@ -307,6 +349,9 @@ static int powernv_cpufreq_target_index(struct cpufreq_policy *policy,
307 if (unlikely(rebooting) && new_index != get_nominal_index()) 349 if (unlikely(rebooting) && new_index != get_nominal_index())
308 return 0; 350 return 0;
309 351
352 if (!throttled)
353 powernv_cpufreq_throttle_check(smp_processor_id());
354
310 freq_data.pstate_id = powernv_freqs[new_index].driver_data; 355 freq_data.pstate_id = powernv_freqs[new_index].driver_data;
311 356
312 /* 357 /*
diff --git a/drivers/cpufreq/ppc-corenet-cpufreq.c b/drivers/cpufreq/qoriq-cpufreq.c
index 7cb4b766cf94..88b21ae0d6b0 100644
--- a/drivers/cpufreq/ppc-corenet-cpufreq.c
+++ b/drivers/cpufreq/qoriq-cpufreq.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Copyright 2013 Freescale Semiconductor, Inc. 2 * Copyright 2013 Freescale Semiconductor, Inc.
3 * 3 *
4 * CPU Frequency Scaling driver for Freescale PowerPC corenet SoCs. 4 * CPU Frequency Scaling driver for Freescale QorIQ SoCs.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as 7 * it under the terms of the GNU General Public License version 2 as
@@ -20,12 +20,13 @@
20#include <linux/of.h> 20#include <linux/of.h>
21#include <linux/slab.h> 21#include <linux/slab.h>
22#include <linux/smp.h> 22#include <linux/smp.h>
23#include <sysdev/fsl_soc.h>
24 23
24#if !defined(CONFIG_ARM)
25#include <asm/smp.h> /* for get_hard_smp_processor_id() in UP configs */ 25#include <asm/smp.h> /* for get_hard_smp_processor_id() in UP configs */
26#endif
26 27
27/** 28/**
28 * struct cpu_data - per CPU data struct 29 * struct cpu_data
29 * @parent: the parent node of cpu clock 30 * @parent: the parent node of cpu clock
30 * @table: frequency table 31 * @table: frequency table
31 */ 32 */
@@ -69,17 +70,78 @@ static const struct soc_data sdata[] = {
69static u32 min_cpufreq; 70static u32 min_cpufreq;
70static const u32 *fmask; 71static const u32 *fmask;
71 72
72static DEFINE_PER_CPU(struct cpu_data *, cpu_data); 73#if defined(CONFIG_ARM)
74static int get_cpu_physical_id(int cpu)
75{
76 return topology_core_id(cpu);
77}
78#else
79static int get_cpu_physical_id(int cpu)
80{
81 return get_hard_smp_processor_id(cpu);
82}
83#endif
73 84
74/* cpumask in a cluster */ 85static u32 get_bus_freq(void)
75static DEFINE_PER_CPU(cpumask_var_t, cpu_mask); 86{
87 struct device_node *soc;
88 u32 sysfreq;
89
90 soc = of_find_node_by_type(NULL, "soc");
91 if (!soc)
92 return 0;
93
94 if (of_property_read_u32(soc, "bus-frequency", &sysfreq))
95 sysfreq = 0;
76 96
77#ifndef CONFIG_SMP 97 of_node_put(soc);
78static inline const struct cpumask *cpu_core_mask(int cpu) 98
99 return sysfreq;
100}
101
102static struct device_node *cpu_to_clk_node(int cpu)
79{ 103{
80 return cpumask_of(0); 104 struct device_node *np, *clk_np;
105
106 if (!cpu_present(cpu))
107 return NULL;
108
109 np = of_get_cpu_node(cpu, NULL);
110 if (!np)
111 return NULL;
112
113 clk_np = of_parse_phandle(np, "clocks", 0);
114 if (!clk_np)
115 return NULL;
116
117 of_node_put(np);
118
119 return clk_np;
120}
121
122/* traverse cpu nodes to get cpu mask of sharing clock wire */
123static void set_affected_cpus(struct cpufreq_policy *policy)
124{
125 struct device_node *np, *clk_np;
126 struct cpumask *dstp = policy->cpus;
127 int i;
128
129 np = cpu_to_clk_node(policy->cpu);
130 if (!np)
131 return;
132
133 for_each_present_cpu(i) {
134 clk_np = cpu_to_clk_node(i);
135 if (!clk_np)
136 continue;
137
138 if (clk_np == np)
139 cpumask_set_cpu(i, dstp);
140
141 of_node_put(clk_np);
142 }
143 of_node_put(np);
81} 144}
82#endif
83 145
84/* reduce the duplicated frequencies in frequency table */ 146/* reduce the duplicated frequencies in frequency table */
85static void freq_table_redup(struct cpufreq_frequency_table *freq_table, 147static void freq_table_redup(struct cpufreq_frequency_table *freq_table,
@@ -107,6 +169,7 @@ static void freq_table_sort(struct cpufreq_frequency_table *freq_table,
107 int i, j, ind; 169 int i, j, ind;
108 unsigned int freq, max_freq; 170 unsigned int freq, max_freq;
109 struct cpufreq_frequency_table table; 171 struct cpufreq_frequency_table table;
172
110 for (i = 0; i < count - 1; i++) { 173 for (i = 0; i < count - 1; i++) {
111 max_freq = freq_table[i].frequency; 174 max_freq = freq_table[i].frequency;
112 ind = i; 175 ind = i;
@@ -131,7 +194,7 @@ static void freq_table_sort(struct cpufreq_frequency_table *freq_table,
131 } 194 }
132} 195}
133 196
134static int corenet_cpufreq_cpu_init(struct cpufreq_policy *policy) 197static int qoriq_cpufreq_cpu_init(struct cpufreq_policy *policy)
135{ 198{
136 struct device_node *np; 199 struct device_node *np;
137 int i, count, ret; 200 int i, count, ret;
@@ -147,10 +210,8 @@ static int corenet_cpufreq_cpu_init(struct cpufreq_policy *policy)
147 return -ENODEV; 210 return -ENODEV;
148 211
149 data = kzalloc(sizeof(*data), GFP_KERNEL); 212 data = kzalloc(sizeof(*data), GFP_KERNEL);
150 if (!data) { 213 if (!data)
151 pr_err("%s: no memory\n", __func__);
152 goto err_np; 214 goto err_np;
153 }
154 215
155 policy->clk = of_clk_get(np, 0); 216 policy->clk = of_clk_get(np, 0);
156 if (IS_ERR(policy->clk)) { 217 if (IS_ERR(policy->clk)) {
@@ -172,7 +233,7 @@ static int corenet_cpufreq_cpu_init(struct cpufreq_policy *policy)
172 } 233 }
173 234
174 if (fmask) 235 if (fmask)
175 mask = fmask[get_hard_smp_processor_id(cpu)]; 236 mask = fmask[get_cpu_physical_id(cpu)];
176 else 237 else
177 mask = 0x0; 238 mask = 0x0;
178 239
@@ -203,13 +264,12 @@ static int corenet_cpufreq_cpu_init(struct cpufreq_policy *policy)
203 data->table = table; 264 data->table = table;
204 265
205 /* update ->cpus if we have cluster, no harm if not */ 266 /* update ->cpus if we have cluster, no harm if not */
206 cpumask_copy(policy->cpus, per_cpu(cpu_mask, cpu)); 267 set_affected_cpus(policy);
207 for_each_cpu(i, per_cpu(cpu_mask, cpu)) 268 policy->driver_data = data;
208 per_cpu(cpu_data, i) = data;
209 269
210 /* Minimum transition latency is 12 platform clocks */ 270 /* Minimum transition latency is 12 platform clocks */
211 u64temp = 12ULL * NSEC_PER_SEC; 271 u64temp = 12ULL * NSEC_PER_SEC;
212 do_div(u64temp, fsl_get_sys_freq()); 272 do_div(u64temp, get_bus_freq());
213 policy->cpuinfo.transition_latency = u64temp + 1; 273 policy->cpuinfo.transition_latency = u64temp + 1;
214 274
215 of_node_put(np); 275 of_node_put(np);
@@ -221,7 +281,7 @@ err_nomem1:
221err_node: 281err_node:
222 of_node_put(data->parent); 282 of_node_put(data->parent);
223err_nomem2: 283err_nomem2:
224 per_cpu(cpu_data, cpu) = NULL; 284 policy->driver_data = NULL;
225 kfree(data); 285 kfree(data);
226err_np: 286err_np:
227 of_node_put(np); 287 of_node_put(np);
@@ -229,43 +289,40 @@ err_np:
229 return -ENODEV; 289 return -ENODEV;
230} 290}
231 291
232static int __exit corenet_cpufreq_cpu_exit(struct cpufreq_policy *policy) 292static int __exit qoriq_cpufreq_cpu_exit(struct cpufreq_policy *policy)
233{ 293{
234 struct cpu_data *data = per_cpu(cpu_data, policy->cpu); 294 struct cpu_data *data = policy->driver_data;
235 unsigned int cpu;
236 295
237 of_node_put(data->parent); 296 of_node_put(data->parent);
238 kfree(data->table); 297 kfree(data->table);
239 kfree(data); 298 kfree(data);
240 299 policy->driver_data = NULL;
241 for_each_cpu(cpu, per_cpu(cpu_mask, policy->cpu))
242 per_cpu(cpu_data, cpu) = NULL;
243 300
244 return 0; 301 return 0;
245} 302}
246 303
247static int corenet_cpufreq_target(struct cpufreq_policy *policy, 304static int qoriq_cpufreq_target(struct cpufreq_policy *policy,
248 unsigned int index) 305 unsigned int index)
249{ 306{
250 struct clk *parent; 307 struct clk *parent;
251 struct cpu_data *data = per_cpu(cpu_data, policy->cpu); 308 struct cpu_data *data = policy->driver_data;
252 309
253 parent = of_clk_get(data->parent, data->table[index].driver_data); 310 parent = of_clk_get(data->parent, data->table[index].driver_data);
254 return clk_set_parent(policy->clk, parent); 311 return clk_set_parent(policy->clk, parent);
255} 312}
256 313
257static struct cpufreq_driver ppc_corenet_cpufreq_driver = { 314static struct cpufreq_driver qoriq_cpufreq_driver = {
258 .name = "ppc_cpufreq", 315 .name = "qoriq_cpufreq",
259 .flags = CPUFREQ_CONST_LOOPS, 316 .flags = CPUFREQ_CONST_LOOPS,
260 .init = corenet_cpufreq_cpu_init, 317 .init = qoriq_cpufreq_cpu_init,
261 .exit = __exit_p(corenet_cpufreq_cpu_exit), 318 .exit = __exit_p(qoriq_cpufreq_cpu_exit),
262 .verify = cpufreq_generic_frequency_table_verify, 319 .verify = cpufreq_generic_frequency_table_verify,
263 .target_index = corenet_cpufreq_target, 320 .target_index = qoriq_cpufreq_target,
264 .get = cpufreq_generic_get, 321 .get = cpufreq_generic_get,
265 .attr = cpufreq_generic_attr, 322 .attr = cpufreq_generic_attr,
266}; 323};
267 324
268static const struct of_device_id node_matches[] __initdata = { 325static const struct of_device_id node_matches[] __initconst = {
269 { .compatible = "fsl,p2041-clockgen", .data = &sdata[0], }, 326 { .compatible = "fsl,p2041-clockgen", .data = &sdata[0], },
270 { .compatible = "fsl,p3041-clockgen", .data = &sdata[0], }, 327 { .compatible = "fsl,p3041-clockgen", .data = &sdata[0], },
271 { .compatible = "fsl,p5020-clockgen", .data = &sdata[1], }, 328 { .compatible = "fsl,p5020-clockgen", .data = &sdata[1], },
@@ -275,61 +332,43 @@ static const struct of_device_id node_matches[] __initdata = {
275 {} 332 {}
276}; 333};
277 334
278static int __init ppc_corenet_cpufreq_init(void) 335static int __init qoriq_cpufreq_init(void)
279{ 336{
280 int ret; 337 int ret;
281 struct device_node *np; 338 struct device_node *np;
282 const struct of_device_id *match; 339 const struct of_device_id *match;
283 const struct soc_data *data; 340 const struct soc_data *data;
284 unsigned int cpu;
285 341
286 np = of_find_matching_node(NULL, node_matches); 342 np = of_find_matching_node(NULL, node_matches);
287 if (!np) 343 if (!np)
288 return -ENODEV; 344 return -ENODEV;
289 345
290 for_each_possible_cpu(cpu) {
291 if (!alloc_cpumask_var(&per_cpu(cpu_mask, cpu), GFP_KERNEL))
292 goto err_mask;
293 cpumask_copy(per_cpu(cpu_mask, cpu), cpu_core_mask(cpu));
294 }
295
296 match = of_match_node(node_matches, np); 346 match = of_match_node(node_matches, np);
297 data = match->data; 347 data = match->data;
298 if (data) { 348 if (data) {
299 if (data->flag) 349 if (data->flag)
300 fmask = data->freq_mask; 350 fmask = data->freq_mask;
301 min_cpufreq = fsl_get_sys_freq(); 351 min_cpufreq = get_bus_freq();
302 } else { 352 } else {
303 min_cpufreq = fsl_get_sys_freq() / 2; 353 min_cpufreq = get_bus_freq() / 2;
304 } 354 }
305 355
306 of_node_put(np); 356 of_node_put(np);
307 357
308 ret = cpufreq_register_driver(&ppc_corenet_cpufreq_driver); 358 ret = cpufreq_register_driver(&qoriq_cpufreq_driver);
309 if (!ret) 359 if (!ret)
310 pr_info("Freescale PowerPC corenet CPU frequency scaling driver\n"); 360 pr_info("Freescale QorIQ CPU frequency scaling driver\n");
311 361
312 return ret; 362 return ret;
313
314err_mask:
315 for_each_possible_cpu(cpu)
316 free_cpumask_var(per_cpu(cpu_mask, cpu));
317
318 return -ENOMEM;
319} 363}
320module_init(ppc_corenet_cpufreq_init); 364module_init(qoriq_cpufreq_init);
321 365
322static void __exit ppc_corenet_cpufreq_exit(void) 366static void __exit qoriq_cpufreq_exit(void)
323{ 367{
324 unsigned int cpu; 368 cpufreq_unregister_driver(&qoriq_cpufreq_driver);
325
326 for_each_possible_cpu(cpu)
327 free_cpumask_var(per_cpu(cpu_mask, cpu));
328
329 cpufreq_unregister_driver(&ppc_corenet_cpufreq_driver);
330} 369}
331module_exit(ppc_corenet_cpufreq_exit); 370module_exit(qoriq_cpufreq_exit);
332 371
333MODULE_LICENSE("GPL"); 372MODULE_LICENSE("GPL");
334MODULE_AUTHOR("Tang Yuantian <Yuantian.Tang@freescale.com>"); 373MODULE_AUTHOR("Tang Yuantian <Yuantian.Tang@freescale.com>");
335MODULE_DESCRIPTION("cpufreq driver for Freescale e500mc series SoCs"); 374MODULE_DESCRIPTION("cpufreq driver for Freescale QorIQ series SoCs");
diff --git a/drivers/cpuidle/Kconfig b/drivers/cpuidle/Kconfig
index c5029c1209b4..8c7930b5a65f 100644
--- a/drivers/cpuidle/Kconfig
+++ b/drivers/cpuidle/Kconfig
@@ -29,15 +29,10 @@ config DT_IDLE_STATES
29 bool 29 bool
30 30
31menu "ARM CPU Idle Drivers" 31menu "ARM CPU Idle Drivers"
32depends on ARM 32depends on ARM || ARM64
33source "drivers/cpuidle/Kconfig.arm" 33source "drivers/cpuidle/Kconfig.arm"
34endmenu 34endmenu
35 35
36menu "ARM64 CPU Idle Drivers"
37depends on ARM64
38source "drivers/cpuidle/Kconfig.arm64"
39endmenu
40
41menu "MIPS CPU Idle Drivers" 36menu "MIPS CPU Idle Drivers"
42depends on MIPS 37depends on MIPS
43source "drivers/cpuidle/Kconfig.mips" 38source "drivers/cpuidle/Kconfig.mips"
diff --git a/drivers/cpuidle/Kconfig.arm b/drivers/cpuidle/Kconfig.arm
index 8e07c9419153..21340e0be73e 100644
--- a/drivers/cpuidle/Kconfig.arm
+++ b/drivers/cpuidle/Kconfig.arm
@@ -1,10 +1,20 @@
1# 1#
2# ARM CPU Idle drivers 2# ARM CPU Idle drivers
3# 3#
4config ARM_CPUIDLE
5 bool "Generic ARM/ARM64 CPU idle Driver"
6 select DT_IDLE_STATES
7 help
8 Select this to enable generic cpuidle driver for ARM.
9 It provides a generic idle driver whose idle states are configured
10 at run-time through DT nodes. The CPUidle suspend backend is
11 initialized by calling the CPU operations init idle hook
12 provided by architecture code.
13
4config ARM_BIG_LITTLE_CPUIDLE 14config ARM_BIG_LITTLE_CPUIDLE
5 bool "Support for ARM big.LITTLE processors" 15 bool "Support for ARM big.LITTLE processors"
6 depends on ARCH_VEXPRESS_TC2_PM || ARCH_EXYNOS 16 depends on ARCH_VEXPRESS_TC2_PM || ARCH_EXYNOS
7 depends on MCPM 17 depends on MCPM && !ARM64
8 select ARM_CPU_SUSPEND 18 select ARM_CPU_SUSPEND
9 select CPU_IDLE_MULTIPLE_DRIVERS 19 select CPU_IDLE_MULTIPLE_DRIVERS
10 select DT_IDLE_STATES 20 select DT_IDLE_STATES
@@ -16,51 +26,51 @@ config ARM_BIG_LITTLE_CPUIDLE
16 26
17config ARM_CLPS711X_CPUIDLE 27config ARM_CLPS711X_CPUIDLE
18 bool "CPU Idle Driver for CLPS711X processors" 28 bool "CPU Idle Driver for CLPS711X processors"
19 depends on ARCH_CLPS711X || COMPILE_TEST 29 depends on ARCH_CLPS711X && !ARM64 || COMPILE_TEST
20 help 30 help
21 Select this to enable cpuidle on Cirrus Logic CLPS711X SOCs. 31 Select this to enable cpuidle on Cirrus Logic CLPS711X SOCs.
22 32
23config ARM_HIGHBANK_CPUIDLE 33config ARM_HIGHBANK_CPUIDLE
24 bool "CPU Idle Driver for Calxeda processors" 34 bool "CPU Idle Driver for Calxeda processors"
25 depends on ARM_PSCI 35 depends on ARM_PSCI && !ARM64
26 select ARM_CPU_SUSPEND 36 select ARM_CPU_SUSPEND
27 help 37 help
28 Select this to enable cpuidle on Calxeda processors. 38 Select this to enable cpuidle on Calxeda processors.
29 39
30config ARM_KIRKWOOD_CPUIDLE 40config ARM_KIRKWOOD_CPUIDLE
31 bool "CPU Idle Driver for Marvell Kirkwood SoCs" 41 bool "CPU Idle Driver for Marvell Kirkwood SoCs"
32 depends on MACH_KIRKWOOD 42 depends on MACH_KIRKWOOD && !ARM64
33 help 43 help
34 This adds the CPU Idle driver for Marvell Kirkwood SoCs. 44 This adds the CPU Idle driver for Marvell Kirkwood SoCs.
35 45
36config ARM_ZYNQ_CPUIDLE 46config ARM_ZYNQ_CPUIDLE
37 bool "CPU Idle Driver for Xilinx Zynq processors" 47 bool "CPU Idle Driver for Xilinx Zynq processors"
38 depends on ARCH_ZYNQ 48 depends on ARCH_ZYNQ && !ARM64
39 help 49 help
40 Select this to enable cpuidle on Xilinx Zynq processors. 50 Select this to enable cpuidle on Xilinx Zynq processors.
41 51
42config ARM_U8500_CPUIDLE 52config ARM_U8500_CPUIDLE
43 bool "Cpu Idle Driver for the ST-E u8500 processors" 53 bool "Cpu Idle Driver for the ST-E u8500 processors"
44 depends on ARCH_U8500 54 depends on ARCH_U8500 && !ARM64
45 help 55 help
46 Select this to enable cpuidle for ST-E u8500 processors 56 Select this to enable cpuidle for ST-E u8500 processors
47 57
48config ARM_AT91_CPUIDLE 58config ARM_AT91_CPUIDLE
49 bool "Cpu Idle Driver for the AT91 processors" 59 bool "Cpu Idle Driver for the AT91 processors"
50 default y 60 default y
51 depends on ARCH_AT91 61 depends on ARCH_AT91 && !ARM64
52 help 62 help
53 Select this to enable cpuidle for AT91 processors 63 Select this to enable cpuidle for AT91 processors
54 64
55config ARM_EXYNOS_CPUIDLE 65config ARM_EXYNOS_CPUIDLE
56 bool "Cpu Idle Driver for the Exynos processors" 66 bool "Cpu Idle Driver for the Exynos processors"
57 depends on ARCH_EXYNOS 67 depends on ARCH_EXYNOS && !ARM64
58 select ARCH_NEEDS_CPU_IDLE_COUPLED if SMP 68 select ARCH_NEEDS_CPU_IDLE_COUPLED if SMP
59 help 69 help
60 Select this to enable cpuidle for Exynos processors 70 Select this to enable cpuidle for Exynos processors
61 71
62config ARM_MVEBU_V7_CPUIDLE 72config ARM_MVEBU_V7_CPUIDLE
63 bool "CPU Idle Driver for mvebu v7 family processors" 73 bool "CPU Idle Driver for mvebu v7 family processors"
64 depends on ARCH_MVEBU 74 depends on ARCH_MVEBU && !ARM64
65 help 75 help
66 Select this to enable cpuidle on Armada 370, 38x and XP processors. 76 Select this to enable cpuidle on Armada 370, 38x and XP processors.
diff --git a/drivers/cpuidle/Kconfig.arm64 b/drivers/cpuidle/Kconfig.arm64
deleted file mode 100644
index 6effb3656735..000000000000
--- a/drivers/cpuidle/Kconfig.arm64
+++ /dev/null
@@ -1,13 +0,0 @@
1#
2# ARM64 CPU Idle drivers
3#
4
5config ARM64_CPUIDLE
6 bool "Generic ARM64 CPU idle Driver"
7 select DT_IDLE_STATES
8 help
9 Select this to enable generic cpuidle driver for ARM64.
10 It provides a generic idle driver whose idle states are configured
11 at run-time through DT nodes. The CPUidle suspend backend is
12 initialized by calling the CPU operations init idle hook
13 provided by architecture code.
diff --git a/drivers/cpuidle/Makefile b/drivers/cpuidle/Makefile
index 4d177b916f75..3ba81b1dffad 100644
--- a/drivers/cpuidle/Makefile
+++ b/drivers/cpuidle/Makefile
@@ -17,16 +17,13 @@ obj-$(CONFIG_ARM_ZYNQ_CPUIDLE) += cpuidle-zynq.o
17obj-$(CONFIG_ARM_U8500_CPUIDLE) += cpuidle-ux500.o 17obj-$(CONFIG_ARM_U8500_CPUIDLE) += cpuidle-ux500.o
18obj-$(CONFIG_ARM_AT91_CPUIDLE) += cpuidle-at91.o 18obj-$(CONFIG_ARM_AT91_CPUIDLE) += cpuidle-at91.o
19obj-$(CONFIG_ARM_EXYNOS_CPUIDLE) += cpuidle-exynos.o 19obj-$(CONFIG_ARM_EXYNOS_CPUIDLE) += cpuidle-exynos.o
20obj-$(CONFIG_ARM_CPUIDLE) += cpuidle-arm.o
20 21
21############################################################################### 22###############################################################################
22# MIPS drivers 23# MIPS drivers
23obj-$(CONFIG_MIPS_CPS_CPUIDLE) += cpuidle-cps.o 24obj-$(CONFIG_MIPS_CPS_CPUIDLE) += cpuidle-cps.o
24 25
25############################################################################### 26###############################################################################
26# ARM64 drivers
27obj-$(CONFIG_ARM64_CPUIDLE) += cpuidle-arm64.o
28
29###############################################################################
30# POWERPC drivers 27# POWERPC drivers
31obj-$(CONFIG_PSERIES_CPUIDLE) += cpuidle-pseries.o 28obj-$(CONFIG_PSERIES_CPUIDLE) += cpuidle-pseries.o
32obj-$(CONFIG_POWERNV_CPUIDLE) += cpuidle-powernv.o 29obj-$(CONFIG_POWERNV_CPUIDLE) += cpuidle-powernv.o
diff --git a/drivers/cpuidle/cpuidle-arm64.c b/drivers/cpuidle/cpuidle-arm.c
index 39a2c62716c3..545069d5fdfb 100644
--- a/drivers/cpuidle/cpuidle-arm64.c
+++ b/drivers/cpuidle/cpuidle-arm.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * ARM64 generic CPU idle driver. 2 * ARM/ARM64 generic CPU idle driver.
3 * 3 *
4 * Copyright (C) 2014 ARM Ltd. 4 * Copyright (C) 2014 ARM Ltd.
5 * Author: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> 5 * Author: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
@@ -9,7 +9,7 @@
9 * published by the Free Software Foundation. 9 * published by the Free Software Foundation.
10 */ 10 */
11 11
12#define pr_fmt(fmt) "CPUidle arm64: " fmt 12#define pr_fmt(fmt) "CPUidle arm: " fmt
13 13
14#include <linux/cpuidle.h> 14#include <linux/cpuidle.h>
15#include <linux/cpumask.h> 15#include <linux/cpumask.h>
@@ -17,13 +17,14 @@
17#include <linux/kernel.h> 17#include <linux/kernel.h>
18#include <linux/module.h> 18#include <linux/module.h>
19#include <linux/of.h> 19#include <linux/of.h>
20#include <linux/slab.h>
20 21
21#include <asm/cpuidle.h> 22#include <asm/cpuidle.h>
22 23
23#include "dt_idle_states.h" 24#include "dt_idle_states.h"
24 25
25/* 26/*
26 * arm64_enter_idle_state - Programs CPU to enter the specified state 27 * arm_enter_idle_state - Programs CPU to enter the specified state
27 * 28 *
28 * dev: cpuidle device 29 * dev: cpuidle device
29 * drv: cpuidle driver 30 * drv: cpuidle driver
@@ -32,8 +33,8 @@
32 * Called from the CPUidle framework to program the device to the 33 * Called from the CPUidle framework to program the device to the
33 * specified target state selected by the governor. 34 * specified target state selected by the governor.
34 */ 35 */
35static int arm64_enter_idle_state(struct cpuidle_device *dev, 36static int arm_enter_idle_state(struct cpuidle_device *dev,
36 struct cpuidle_driver *drv, int idx) 37 struct cpuidle_driver *drv, int idx)
37{ 38{
38 int ret; 39 int ret;
39 40
@@ -49,7 +50,7 @@ static int arm64_enter_idle_state(struct cpuidle_device *dev,
49 * call the CPU ops suspend protocol with idle index as a 50 * call the CPU ops suspend protocol with idle index as a
50 * parameter. 51 * parameter.
51 */ 52 */
52 ret = cpu_suspend(idx); 53 arm_cpuidle_suspend(idx);
53 54
54 cpu_pm_exit(); 55 cpu_pm_exit();
55 } 56 }
@@ -57,8 +58,8 @@ static int arm64_enter_idle_state(struct cpuidle_device *dev,
57 return ret ? -1 : idx; 58 return ret ? -1 : idx;
58} 59}
59 60
60static struct cpuidle_driver arm64_idle_driver = { 61static struct cpuidle_driver arm_idle_driver = {
61 .name = "arm64_idle", 62 .name = "arm_idle",
62 .owner = THIS_MODULE, 63 .owner = THIS_MODULE,
63 /* 64 /*
64 * State at index 0 is standby wfi and considered standard 65 * State at index 0 is standby wfi and considered standard
@@ -68,32 +69,33 @@ static struct cpuidle_driver arm64_idle_driver = {
68 * handler for idle state index 0. 69 * handler for idle state index 0.
69 */ 70 */
70 .states[0] = { 71 .states[0] = {
71 .enter = arm64_enter_idle_state, 72 .enter = arm_enter_idle_state,
72 .exit_latency = 1, 73 .exit_latency = 1,
73 .target_residency = 1, 74 .target_residency = 1,
74 .power_usage = UINT_MAX, 75 .power_usage = UINT_MAX,
75 .name = "WFI", 76 .name = "WFI",
76 .desc = "ARM64 WFI", 77 .desc = "ARM WFI",
77 } 78 }
78}; 79};
79 80
80static const struct of_device_id arm64_idle_state_match[] __initconst = { 81static const struct of_device_id arm_idle_state_match[] __initconst = {
81 { .compatible = "arm,idle-state", 82 { .compatible = "arm,idle-state",
82 .data = arm64_enter_idle_state }, 83 .data = arm_enter_idle_state },
83 { }, 84 { },
84}; 85};
85 86
86/* 87/*
87 * arm64_idle_init 88 * arm_idle_init
88 * 89 *
89 * Registers the arm64 specific cpuidle driver with the cpuidle 90 * Registers the arm specific cpuidle driver with the cpuidle
90 * framework. It relies on core code to parse the idle states 91 * framework. It relies on core code to parse the idle states
91 * and initialize them using driver data structures accordingly. 92 * and initialize them using driver data structures accordingly.
92 */ 93 */
93static int __init arm64_idle_init(void) 94static int __init arm_idle_init(void)
94{ 95{
95 int cpu, ret; 96 int cpu, ret;
96 struct cpuidle_driver *drv = &arm64_idle_driver; 97 struct cpuidle_driver *drv = &arm_idle_driver;
98 struct cpuidle_device *dev;
97 99
98 /* 100 /*
99 * Initialize idle states data, starting at index 1. 101 * Initialize idle states data, starting at index 1.
@@ -101,22 +103,61 @@ static int __init arm64_idle_init(void)
101 * let the driver initialization fail accordingly since there is no 103 * let the driver initialization fail accordingly since there is no
102 * reason to initialize the idle driver if only wfi is supported. 104 * reason to initialize the idle driver if only wfi is supported.
103 */ 105 */
104 ret = dt_init_idle_driver(drv, arm64_idle_state_match, 1); 106 ret = dt_init_idle_driver(drv, arm_idle_state_match, 1);
105 if (ret <= 0) 107 if (ret <= 0)
106 return ret ? : -ENODEV; 108 return ret ? : -ENODEV;
107 109
110 ret = cpuidle_register_driver(drv);
111 if (ret) {
112 pr_err("Failed to register cpuidle driver\n");
113 return ret;
114 }
115
108 /* 116 /*
109 * Call arch CPU operations in order to initialize 117 * Call arch CPU operations in order to initialize
110 * idle states suspend back-end specific data 118 * idle states suspend back-end specific data
111 */ 119 */
112 for_each_possible_cpu(cpu) { 120 for_each_possible_cpu(cpu) {
113 ret = cpu_init_idle(cpu); 121 ret = arm_cpuidle_init(cpu);
122
123 /*
124 * Skip the cpuidle device initialization if the reported
125 * failure is a HW misconfiguration/breakage (-ENXIO).
126 */
127 if (ret == -ENXIO)
128 continue;
129
114 if (ret) { 130 if (ret) {
115 pr_err("CPU %d failed to init idle CPU ops\n", cpu); 131 pr_err("CPU %d failed to init idle CPU ops\n", cpu);
116 return ret; 132 goto out_fail;
133 }
134
135 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
136 if (!dev) {
137 pr_err("Failed to allocate cpuidle device\n");
138 goto out_fail;
139 }
140 dev->cpu = cpu;
141
142 ret = cpuidle_register_device(dev);
143 if (ret) {
144 pr_err("Failed to register cpuidle device for CPU %d\n",
145 cpu);
146 kfree(dev);
147 goto out_fail;
117 } 148 }
118 } 149 }
119 150
120 return cpuidle_register(drv, NULL); 151 return 0;
152out_fail:
153 while (--cpu >= 0) {
154 dev = per_cpu(cpuidle_devices, cpu);
155 cpuidle_unregister_device(dev);
156 kfree(dev);
157 }
158
159 cpuidle_unregister_driver(drv);
160
161 return ret;
121} 162}
122device_initcall(arm64_idle_init); 163device_initcall(arm_idle_init);
diff --git a/drivers/cpuidle/cpuidle-at91.c b/drivers/cpuidle/cpuidle-at91.c
index aae7bfc1ea36..f2446c78d87c 100644
--- a/drivers/cpuidle/cpuidle-at91.c
+++ b/drivers/cpuidle/cpuidle-at91.c
@@ -19,7 +19,6 @@
19#include <linux/cpuidle.h> 19#include <linux/cpuidle.h>
20#include <linux/io.h> 20#include <linux/io.h>
21#include <linux/export.h> 21#include <linux/export.h>
22#include <asm/proc-fns.h>
23#include <asm/cpuidle.h> 22#include <asm/cpuidle.h>
24 23
25#define AT91_MAX_STATES 2 24#define AT91_MAX_STATES 2
diff --git a/drivers/cpuidle/cpuidle-exynos.c b/drivers/cpuidle/cpuidle-exynos.c
index 26f5f29fdb03..0c06ea2f50bb 100644
--- a/drivers/cpuidle/cpuidle-exynos.c
+++ b/drivers/cpuidle/cpuidle-exynos.c
@@ -19,7 +19,6 @@
19#include <linux/of.h> 19#include <linux/of.h>
20#include <linux/platform_data/cpuidle-exynos.h> 20#include <linux/platform_data/cpuidle-exynos.h>
21 21
22#include <asm/proc-fns.h>
23#include <asm/suspend.h> 22#include <asm/suspend.h>
24#include <asm/cpuidle.h> 23#include <asm/cpuidle.h>
25 24
diff --git a/drivers/cpuidle/cpuidle-kirkwood.c b/drivers/cpuidle/cpuidle-kirkwood.c
index cea0a6c4b1db..d23d8f468c12 100644
--- a/drivers/cpuidle/cpuidle-kirkwood.c
+++ b/drivers/cpuidle/cpuidle-kirkwood.c
@@ -21,7 +21,6 @@
21#include <linux/cpuidle.h> 21#include <linux/cpuidle.h>
22#include <linux/io.h> 22#include <linux/io.h>
23#include <linux/export.h> 23#include <linux/export.h>
24#include <asm/proc-fns.h>
25#include <asm/cpuidle.h> 24#include <asm/cpuidle.h>
26 25
27#define KIRKWOOD_MAX_STATES 2 26#define KIRKWOOD_MAX_STATES 2
diff --git a/drivers/cpuidle/cpuidle-ux500.c b/drivers/cpuidle/cpuidle-ux500.c
index 66f81e410f0d..8bf895c0017d 100644
--- a/drivers/cpuidle/cpuidle-ux500.c
+++ b/drivers/cpuidle/cpuidle-ux500.c
@@ -19,7 +19,6 @@
19#include <linux/platform_device.h> 19#include <linux/platform_device.h>
20 20
21#include <asm/cpuidle.h> 21#include <asm/cpuidle.h>
22#include <asm/proc-fns.h>
23 22
24static atomic_t master = ATOMIC_INIT(0); 23static atomic_t master = ATOMIC_INIT(0);
25static DEFINE_SPINLOCK(master_lock); 24static DEFINE_SPINLOCK(master_lock);
diff --git a/drivers/cpuidle/cpuidle-zynq.c b/drivers/cpuidle/cpuidle-zynq.c
index 002b8c9f98f5..543292b1d38e 100644
--- a/drivers/cpuidle/cpuidle-zynq.c
+++ b/drivers/cpuidle/cpuidle-zynq.c
@@ -28,7 +28,6 @@
28#include <linux/init.h> 28#include <linux/init.h>
29#include <linux/cpuidle.h> 29#include <linux/cpuidle.h>
30#include <linux/platform_device.h> 30#include <linux/platform_device.h>
31#include <asm/proc-fns.h>
32#include <asm/cpuidle.h> 31#include <asm/cpuidle.h>
33 32
34#define ZYNQ_MAX_STATES 2 33#define ZYNQ_MAX_STATES 2
diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
index 080bd2dbde4b..7a73a279e179 100644
--- a/drivers/cpuidle/cpuidle.c
+++ b/drivers/cpuidle/cpuidle.c
@@ -330,9 +330,6 @@ int cpuidle_enable_device(struct cpuidle_device *dev)
330 if (!dev->registered) 330 if (!dev->registered)
331 return -EINVAL; 331 return -EINVAL;
332 332
333 if (!dev->state_count)
334 dev->state_count = drv->state_count;
335
336 ret = cpuidle_add_device_sysfs(dev); 333 ret = cpuidle_add_device_sysfs(dev);
337 if (ret) 334 if (ret)
338 return ret; 335 return ret;
diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
index 97c5903b4606..832a2c3f01ff 100644
--- a/drivers/cpuidle/sysfs.c
+++ b/drivers/cpuidle/sysfs.c
@@ -401,7 +401,7 @@ static int cpuidle_add_state_sysfs(struct cpuidle_device *device)
401 struct cpuidle_driver *drv = cpuidle_get_cpu_driver(device); 401 struct cpuidle_driver *drv = cpuidle_get_cpu_driver(device);
402 402
403 /* state statistics */ 403 /* state statistics */
404 for (i = 0; i < device->state_count; i++) { 404 for (i = 0; i < drv->state_count; i++) {
405 kobj = kzalloc(sizeof(struct cpuidle_state_kobj), GFP_KERNEL); 405 kobj = kzalloc(sizeof(struct cpuidle_state_kobj), GFP_KERNEL);
406 if (!kobj) 406 if (!kobj)
407 goto error_state; 407 goto error_state;
@@ -433,9 +433,10 @@ error_state:
433 */ 433 */
434static void cpuidle_remove_state_sysfs(struct cpuidle_device *device) 434static void cpuidle_remove_state_sysfs(struct cpuidle_device *device)
435{ 435{
436 struct cpuidle_driver *drv = cpuidle_get_cpu_driver(device);
436 int i; 437 int i;
437 438
438 for (i = 0; i < device->state_count; i++) 439 for (i = 0; i < drv->state_count; i++)
439 cpuidle_free_state_kobj(device, i); 440 cpuidle_free_state_kobj(device, i);
440} 441}
441 442
diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c
index 0723096fb50a..c92d6a70ccf3 100644
--- a/drivers/dma/bcm2835-dma.c
+++ b/drivers/dma/bcm2835-dma.c
@@ -475,6 +475,7 @@ static int bcm2835_dma_terminate_all(struct dma_chan *chan)
475 * c->desc is NULL and exit.) 475 * c->desc is NULL and exit.)
476 */ 476 */
477 if (c->desc) { 477 if (c->desc) {
478 bcm2835_dma_desc_free(&c->desc->vd);
478 c->desc = NULL; 479 c->desc = NULL;
479 bcm2835_dma_abort(c->chan_base); 480 bcm2835_dma_abort(c->chan_base);
480 481
diff --git a/drivers/dma/cppi41.c b/drivers/dma/cppi41.c
index 512cb8e2805e..ceedafbd23e0 100644
--- a/drivers/dma/cppi41.c
+++ b/drivers/dma/cppi41.c
@@ -903,6 +903,11 @@ static const struct cppi_glue_infos *get_glue_info(struct device *dev)
903 return of_id->data; 903 return of_id->data;
904} 904}
905 905
906#define CPPI41_DMA_BUSWIDTHS (BIT(DMA_SLAVE_BUSWIDTH_1_BYTE) | \
907 BIT(DMA_SLAVE_BUSWIDTH_2_BYTES) | \
908 BIT(DMA_SLAVE_BUSWIDTH_3_BYTES) | \
909 BIT(DMA_SLAVE_BUSWIDTH_4_BYTES))
910
906static int cppi41_dma_probe(struct platform_device *pdev) 911static int cppi41_dma_probe(struct platform_device *pdev)
907{ 912{
908 struct cppi41_dd *cdd; 913 struct cppi41_dd *cdd;
@@ -926,6 +931,10 @@ static int cppi41_dma_probe(struct platform_device *pdev)
926 cdd->ddev.device_issue_pending = cppi41_dma_issue_pending; 931 cdd->ddev.device_issue_pending = cppi41_dma_issue_pending;
927 cdd->ddev.device_prep_slave_sg = cppi41_dma_prep_slave_sg; 932 cdd->ddev.device_prep_slave_sg = cppi41_dma_prep_slave_sg;
928 cdd->ddev.device_terminate_all = cppi41_stop_chan; 933 cdd->ddev.device_terminate_all = cppi41_stop_chan;
934 cdd->ddev.directions = BIT(DMA_DEV_TO_MEM) | BIT(DMA_MEM_TO_DEV);
935 cdd->ddev.src_addr_widths = CPPI41_DMA_BUSWIDTHS;
936 cdd->ddev.dst_addr_widths = CPPI41_DMA_BUSWIDTHS;
937 cdd->ddev.residue_granularity = DMA_RESIDUE_GRANULARITY_BURST;
929 cdd->ddev.dev = dev; 938 cdd->ddev.dev = dev;
930 INIT_LIST_HEAD(&cdd->ddev.channels); 939 INIT_LIST_HEAD(&cdd->ddev.channels);
931 cpp41_dma_info.dma_cap = cdd->ddev.cap_mask; 940 cpp41_dma_info.dma_cap = cdd->ddev.cap_mask;
diff --git a/drivers/dma/dma-jz4740.c b/drivers/dma/dma-jz4740.c
index 4527a3ebeac4..84884418fd30 100644
--- a/drivers/dma/dma-jz4740.c
+++ b/drivers/dma/dma-jz4740.c
@@ -511,6 +511,9 @@ static void jz4740_dma_desc_free(struct virt_dma_desc *vdesc)
511 kfree(container_of(vdesc, struct jz4740_dma_desc, vdesc)); 511 kfree(container_of(vdesc, struct jz4740_dma_desc, vdesc));
512} 512}
513 513
514#define JZ4740_DMA_BUSWIDTHS (BIT(DMA_SLAVE_BUSWIDTH_1_BYTE) | \
515 BIT(DMA_SLAVE_BUSWIDTH_2_BYTES) | BIT(DMA_SLAVE_BUSWIDTH_4_BYTES))
516
514static int jz4740_dma_probe(struct platform_device *pdev) 517static int jz4740_dma_probe(struct platform_device *pdev)
515{ 518{
516 struct jz4740_dmaengine_chan *chan; 519 struct jz4740_dmaengine_chan *chan;
@@ -548,6 +551,10 @@ static int jz4740_dma_probe(struct platform_device *pdev)
548 dd->device_prep_dma_cyclic = jz4740_dma_prep_dma_cyclic; 551 dd->device_prep_dma_cyclic = jz4740_dma_prep_dma_cyclic;
549 dd->device_config = jz4740_dma_slave_config; 552 dd->device_config = jz4740_dma_slave_config;
550 dd->device_terminate_all = jz4740_dma_terminate_all; 553 dd->device_terminate_all = jz4740_dma_terminate_all;
554 dd->src_addr_widths = JZ4740_DMA_BUSWIDTHS;
555 dd->dst_addr_widths = JZ4740_DMA_BUSWIDTHS;
556 dd->directions = BIT(DMA_DEV_TO_MEM) | BIT(DMA_MEM_TO_DEV);
557 dd->residue_granularity = DMA_RESIDUE_GRANULARITY_BURST;
551 dd->dev = &pdev->dev; 558 dd->dev = &pdev->dev;
552 INIT_LIST_HEAD(&dd->channels); 559 INIT_LIST_HEAD(&dd->channels);
553 560
diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
index f15712f2fec6..ac336a961dea 100644
--- a/drivers/dma/dmaengine.c
+++ b/drivers/dma/dmaengine.c
@@ -859,9 +859,6 @@ int dma_async_device_register(struct dma_device *device)
859 BUG_ON(!device->device_issue_pending); 859 BUG_ON(!device->device_issue_pending);
860 BUG_ON(!device->dev); 860 BUG_ON(!device->dev);
861 861
862 WARN(dma_has_cap(DMA_SLAVE, device->cap_mask) && !device->directions,
863 "this driver doesn't support generic slave capabilities reporting\n");
864
865 /* note: this only matters in the 862 /* note: this only matters in the
866 * CONFIG_ASYNC_TX_ENABLE_CHANNEL_SWITCH=n case 863 * CONFIG_ASYNC_TX_ENABLE_CHANNEL_SWITCH=n case
867 */ 864 */
diff --git a/drivers/dma/edma.c b/drivers/dma/edma.c
index 276157f22612..53dbd3b3384c 100644
--- a/drivers/dma/edma.c
+++ b/drivers/dma/edma.c
@@ -260,6 +260,13 @@ static int edma_terminate_all(struct dma_chan *chan)
260 */ 260 */
261 if (echan->edesc) { 261 if (echan->edesc) {
262 int cyclic = echan->edesc->cyclic; 262 int cyclic = echan->edesc->cyclic;
263
264 /*
265 * free the running request descriptor
266 * since it is not in any of the vdesc lists
267 */
268 edma_desc_free(&echan->edesc->vdesc);
269
263 echan->edesc = NULL; 270 echan->edesc = NULL;
264 edma_stop(echan->ch_num); 271 edma_stop(echan->ch_num);
265 /* Move the cyclic channel back to default queue */ 272 /* Move the cyclic channel back to default queue */
diff --git a/drivers/dma/moxart-dma.c b/drivers/dma/moxart-dma.c
index 15cab7d79525..b4634109e010 100644
--- a/drivers/dma/moxart-dma.c
+++ b/drivers/dma/moxart-dma.c
@@ -193,8 +193,10 @@ static int moxart_terminate_all(struct dma_chan *chan)
193 193
194 spin_lock_irqsave(&ch->vc.lock, flags); 194 spin_lock_irqsave(&ch->vc.lock, flags);
195 195
196 if (ch->desc) 196 if (ch->desc) {
197 moxart_dma_desc_free(&ch->desc->vd);
197 ch->desc = NULL; 198 ch->desc = NULL;
199 }
198 200
199 ctrl = readl(ch->base + REG_OFF_CTRL); 201 ctrl = readl(ch->base + REG_OFF_CTRL);
200 ctrl &= ~(APB_DMA_ENABLE | APB_DMA_FIN_INT_EN | APB_DMA_ERR_INT_EN); 202 ctrl &= ~(APB_DMA_ENABLE | APB_DMA_FIN_INT_EN | APB_DMA_ERR_INT_EN);
diff --git a/drivers/dma/omap-dma.c b/drivers/dma/omap-dma.c
index 7dd6dd121681..167dbaf65742 100644
--- a/drivers/dma/omap-dma.c
+++ b/drivers/dma/omap-dma.c
@@ -981,6 +981,7 @@ static int omap_dma_terminate_all(struct dma_chan *chan)
981 * c->desc is NULL and exit.) 981 * c->desc is NULL and exit.)
982 */ 982 */
983 if (c->desc) { 983 if (c->desc) {
984 omap_dma_desc_free(&c->desc->vd);
984 c->desc = NULL; 985 c->desc = NULL;
985 /* Avoid stopping the dma twice */ 986 /* Avoid stopping the dma twice */
986 if (!c->paused) 987 if (!c->paused)
diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
index 69fac068669f..2eebd28b4c40 100644
--- a/drivers/firmware/dmi_scan.c
+++ b/drivers/firmware/dmi_scan.c
@@ -86,10 +86,13 @@ static void dmi_table(u8 *buf, u32 len, int num,
86 int i = 0; 86 int i = 0;
87 87
88 /* 88 /*
89 * Stop when we see all the items the table claimed to have 89 * Stop when we have seen all the items the table claimed to have
90 * OR we run off the end of the table (also happens) 90 * (SMBIOS < 3.0 only) OR we reach an end-of-table marker OR we run
91 * off the end of the table (should never happen but sometimes does
92 * on bogus implementations.)
91 */ 93 */
92 while ((i < num) && (data - buf + sizeof(struct dmi_header)) <= len) { 94 while ((!num || i < num) &&
95 (data - buf + sizeof(struct dmi_header)) <= len) {
93 const struct dmi_header *dm = (const struct dmi_header *)data; 96 const struct dmi_header *dm = (const struct dmi_header *)data;
94 97
95 /* 98 /*
@@ -529,21 +532,10 @@ static int __init dmi_smbios3_present(const u8 *buf)
529 if (memcmp(buf, "_SM3_", 5) == 0 && 532 if (memcmp(buf, "_SM3_", 5) == 0 &&
530 buf[6] < 32 && dmi_checksum(buf, buf[6])) { 533 buf[6] < 32 && dmi_checksum(buf, buf[6])) {
531 dmi_ver = get_unaligned_be16(buf + 7); 534 dmi_ver = get_unaligned_be16(buf + 7);
535 dmi_num = 0; /* No longer specified */
532 dmi_len = get_unaligned_le32(buf + 12); 536 dmi_len = get_unaligned_le32(buf + 12);
533 dmi_base = get_unaligned_le64(buf + 16); 537 dmi_base = get_unaligned_le64(buf + 16);
534 538
535 /*
536 * The 64-bit SMBIOS 3.0 entry point no longer has a field
537 * containing the number of structures present in the table.
538 * Instead, it defines the table size as a maximum size, and
539 * relies on the end-of-table structure type (#127) to be used
540 * to signal the end of the table.
541 * So let's define dmi_num as an upper bound as well: each
542 * structure has a 4 byte header, so dmi_len / 4 is an upper
543 * bound for the number of structures in the table.
544 */
545 dmi_num = dmi_len / 4;
546
547 if (dmi_walk_early(dmi_decode) == 0) { 539 if (dmi_walk_early(dmi_decode) == 0) {
548 pr_info("SMBIOS %d.%d present.\n", 540 pr_info("SMBIOS %d.%d present.\n",
549 dmi_ver >> 8, dmi_ver & 0xFF); 541 dmi_ver >> 8, dmi_ver & 0xFF);
diff --git a/drivers/gpio/gpio-mpc8xxx.c b/drivers/gpio/gpio-mpc8xxx.c
index a6952ba343a8..a65b75161aa4 100644
--- a/drivers/gpio/gpio-mpc8xxx.c
+++ b/drivers/gpio/gpio-mpc8xxx.c
@@ -334,7 +334,7 @@ static struct irq_domain_ops mpc8xxx_gpio_irq_ops = {
334 .xlate = irq_domain_xlate_twocell, 334 .xlate = irq_domain_xlate_twocell,
335}; 335};
336 336
337static struct of_device_id mpc8xxx_gpio_ids[] __initdata = { 337static struct of_device_id mpc8xxx_gpio_ids[] = {
338 { .compatible = "fsl,mpc8349-gpio", }, 338 { .compatible = "fsl,mpc8349-gpio", },
339 { .compatible = "fsl,mpc8572-gpio", }, 339 { .compatible = "fsl,mpc8572-gpio", },
340 { .compatible = "fsl,mpc8610-gpio", }, 340 { .compatible = "fsl,mpc8610-gpio", },
diff --git a/drivers/gpio/gpio-syscon.c b/drivers/gpio/gpio-syscon.c
index 257e2989215c..045a952576c7 100644
--- a/drivers/gpio/gpio-syscon.c
+++ b/drivers/gpio/gpio-syscon.c
@@ -219,7 +219,7 @@ static int syscon_gpio_probe(struct platform_device *pdev)
219 ret = of_property_read_u32_index(np, "gpio,syscon-dev", 2, 219 ret = of_property_read_u32_index(np, "gpio,syscon-dev", 2,
220 &priv->dir_reg_offset); 220 &priv->dir_reg_offset);
221 if (ret) 221 if (ret)
222 dev_err(dev, "can't read the dir register offset!\n"); 222 dev_dbg(dev, "can't read the dir register offset!\n");
223 223
224 priv->dir_reg_offset <<= 3; 224 priv->dir_reg_offset <<= 3;
225 } 225 }
diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
index c0929d938ced..df990f29757a 100644
--- a/drivers/gpio/gpiolib-acpi.c
+++ b/drivers/gpio/gpiolib-acpi.c
@@ -201,6 +201,10 @@ static acpi_status acpi_gpiochip_request_interrupt(struct acpi_resource *ares,
201 if (!handler) 201 if (!handler)
202 return AE_BAD_PARAMETER; 202 return AE_BAD_PARAMETER;
203 203
204 pin = acpi_gpiochip_pin_to_gpio_offset(chip, pin);
205 if (pin < 0)
206 return AE_BAD_PARAMETER;
207
204 desc = gpiochip_request_own_desc(chip, pin, "ACPI:Event"); 208 desc = gpiochip_request_own_desc(chip, pin, "ACPI:Event");
205 if (IS_ERR(desc)) { 209 if (IS_ERR(desc)) {
206 dev_err(chip->dev, "Failed to request GPIO\n"); 210 dev_err(chip->dev, "Failed to request GPIO\n");
@@ -551,6 +555,12 @@ acpi_gpio_adr_space_handler(u32 function, acpi_physical_address address,
551 struct gpio_desc *desc; 555 struct gpio_desc *desc;
552 bool found; 556 bool found;
553 557
558 pin = acpi_gpiochip_pin_to_gpio_offset(chip, pin);
559 if (pin < 0) {
560 status = AE_BAD_PARAMETER;
561 goto out;
562 }
563
554 mutex_lock(&achip->conn_lock); 564 mutex_lock(&achip->conn_lock);
555 565
556 found = false; 566 found = false;
diff --git a/drivers/gpio/gpiolib.h b/drivers/gpio/gpiolib.h
index 550a5eafbd38..ab892be26dc2 100644
--- a/drivers/gpio/gpiolib.h
+++ b/drivers/gpio/gpiolib.h
@@ -17,6 +17,8 @@
17 17
18enum of_gpio_flags; 18enum of_gpio_flags;
19 19
20struct acpi_device;
21
20/** 22/**
21 * struct acpi_gpio_info - ACPI GPIO specific information 23 * struct acpi_gpio_info - ACPI GPIO specific information
22 * @gpioint: if %true this GPIO is of type GpioInt otherwise type is GpioIo 24 * @gpioint: if %true this GPIO is of type GpioInt otherwise type is GpioIo
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 679b10e34fb5..b6f076b213bc 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -2121,7 +2121,7 @@ int drm_mode_getconnector(struct drm_device *dev, void *data,
2121 connector = drm_connector_find(dev, out_resp->connector_id); 2121 connector = drm_connector_find(dev, out_resp->connector_id);
2122 if (!connector) { 2122 if (!connector) {
2123 ret = -ENOENT; 2123 ret = -ENOENT;
2124 goto out; 2124 goto out_unlock;
2125 } 2125 }
2126 2126
2127 for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) 2127 for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++)
@@ -2201,6 +2201,8 @@ int drm_mode_getconnector(struct drm_device *dev, void *data,
2201 2201
2202out: 2202out:
2203 drm_modeset_unlock(&dev->mode_config.connection_mutex); 2203 drm_modeset_unlock(&dev->mode_config.connection_mutex);
2204
2205out_unlock:
2204 mutex_unlock(&dev->mode_config.mutex); 2206 mutex_unlock(&dev->mode_config.mutex);
2205 2207
2206 return ret; 2208 return ret;
diff --git a/drivers/gpu/drm/drm_edid_load.c b/drivers/gpu/drm/drm_edid_load.c
index 732cb6f8e653..4c0aa97aaf03 100644
--- a/drivers/gpu/drm/drm_edid_load.c
+++ b/drivers/gpu/drm/drm_edid_load.c
@@ -287,6 +287,7 @@ int drm_load_edid_firmware(struct drm_connector *connector)
287 287
288 drm_mode_connector_update_edid_property(connector, edid); 288 drm_mode_connector_update_edid_property(connector, edid);
289 ret = drm_add_edid_modes(connector, edid); 289 ret = drm_add_edid_modes(connector, edid);
290 drm_edid_to_eld(connector, edid);
290 kfree(edid); 291 kfree(edid);
291 292
292 return ret; 293 return ret;
diff --git a/drivers/gpu/drm/drm_probe_helper.c b/drivers/gpu/drm/drm_probe_helper.c
index 6591d48c1b9d..3fee587bc284 100644
--- a/drivers/gpu/drm/drm_probe_helper.c
+++ b/drivers/gpu/drm/drm_probe_helper.c
@@ -174,6 +174,7 @@ static int drm_helper_probe_single_connector_modes_merge_bits(struct drm_connect
174 struct edid *edid = (struct edid *) connector->edid_blob_ptr->data; 174 struct edid *edid = (struct edid *) connector->edid_blob_ptr->data;
175 175
176 count = drm_add_edid_modes(connector, edid); 176 count = drm_add_edid_modes(connector, edid);
177 drm_edid_to_eld(connector, edid);
177 } else 178 } else
178 count = (*connector_funcs->get_modes)(connector); 179 count = (*connector_funcs->get_modes)(connector);
179 } 180 }
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
index c300e22da8ac..33a10ce967ea 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
@@ -147,6 +147,7 @@ struct fimd_win_data {
147 unsigned int ovl_height; 147 unsigned int ovl_height;
148 unsigned int fb_width; 148 unsigned int fb_width;
149 unsigned int fb_height; 149 unsigned int fb_height;
150 unsigned int fb_pitch;
150 unsigned int bpp; 151 unsigned int bpp;
151 unsigned int pixel_format; 152 unsigned int pixel_format;
152 dma_addr_t dma_addr; 153 dma_addr_t dma_addr;
@@ -532,13 +533,14 @@ static void fimd_win_mode_set(struct exynos_drm_crtc *crtc,
532 win_data->offset_y = plane->crtc_y; 533 win_data->offset_y = plane->crtc_y;
533 win_data->ovl_width = plane->crtc_width; 534 win_data->ovl_width = plane->crtc_width;
534 win_data->ovl_height = plane->crtc_height; 535 win_data->ovl_height = plane->crtc_height;
536 win_data->fb_pitch = plane->pitch;
535 win_data->fb_width = plane->fb_width; 537 win_data->fb_width = plane->fb_width;
536 win_data->fb_height = plane->fb_height; 538 win_data->fb_height = plane->fb_height;
537 win_data->dma_addr = plane->dma_addr[0] + offset; 539 win_data->dma_addr = plane->dma_addr[0] + offset;
538 win_data->bpp = plane->bpp; 540 win_data->bpp = plane->bpp;
539 win_data->pixel_format = plane->pixel_format; 541 win_data->pixel_format = plane->pixel_format;
540 win_data->buf_offsize = (plane->fb_width - plane->crtc_width) * 542 win_data->buf_offsize =
541 (plane->bpp >> 3); 543 plane->pitch - (plane->crtc_width * (plane->bpp >> 3));
542 win_data->line_size = plane->crtc_width * (plane->bpp >> 3); 544 win_data->line_size = plane->crtc_width * (plane->bpp >> 3);
543 545
544 DRM_DEBUG_KMS("offset_x = %d, offset_y = %d\n", 546 DRM_DEBUG_KMS("offset_x = %d, offset_y = %d\n",
@@ -704,7 +706,7 @@ static void fimd_win_commit(struct exynos_drm_crtc *crtc, int zpos)
704 writel(val, ctx->regs + VIDWx_BUF_START(win, 0)); 706 writel(val, ctx->regs + VIDWx_BUF_START(win, 0));
705 707
706 /* buffer end address */ 708 /* buffer end address */
707 size = win_data->fb_width * win_data->ovl_height * (win_data->bpp >> 3); 709 size = win_data->fb_pitch * win_data->ovl_height * (win_data->bpp >> 3);
708 val = (unsigned long)(win_data->dma_addr + size); 710 val = (unsigned long)(win_data->dma_addr + size);
709 writel(val, ctx->regs + VIDWx_BUF_END(win, 0)); 711 writel(val, ctx->regs + VIDWx_BUF_END(win, 0));
710 712
diff --git a/drivers/gpu/drm/exynos/exynos_mixer.c b/drivers/gpu/drm/exynos/exynos_mixer.c
index 3518bc4654c5..2e3bc57ea50e 100644
--- a/drivers/gpu/drm/exynos/exynos_mixer.c
+++ b/drivers/gpu/drm/exynos/exynos_mixer.c
@@ -55,6 +55,7 @@ struct hdmi_win_data {
55 unsigned int fb_x; 55 unsigned int fb_x;
56 unsigned int fb_y; 56 unsigned int fb_y;
57 unsigned int fb_width; 57 unsigned int fb_width;
58 unsigned int fb_pitch;
58 unsigned int fb_height; 59 unsigned int fb_height;
59 unsigned int src_width; 60 unsigned int src_width;
60 unsigned int src_height; 61 unsigned int src_height;
@@ -438,7 +439,7 @@ static void vp_video_buffer(struct mixer_context *ctx, int win)
438 } else { 439 } else {
439 luma_addr[0] = win_data->dma_addr; 440 luma_addr[0] = win_data->dma_addr;
440 chroma_addr[0] = win_data->dma_addr 441 chroma_addr[0] = win_data->dma_addr
441 + (win_data->fb_width * win_data->fb_height); 442 + (win_data->fb_pitch * win_data->fb_height);
442 } 443 }
443 444
444 if (win_data->scan_flags & DRM_MODE_FLAG_INTERLACE) { 445 if (win_data->scan_flags & DRM_MODE_FLAG_INTERLACE) {
@@ -447,8 +448,8 @@ static void vp_video_buffer(struct mixer_context *ctx, int win)
447 luma_addr[1] = luma_addr[0] + 0x40; 448 luma_addr[1] = luma_addr[0] + 0x40;
448 chroma_addr[1] = chroma_addr[0] + 0x40; 449 chroma_addr[1] = chroma_addr[0] + 0x40;
449 } else { 450 } else {
450 luma_addr[1] = luma_addr[0] + win_data->fb_width; 451 luma_addr[1] = luma_addr[0] + win_data->fb_pitch;
451 chroma_addr[1] = chroma_addr[0] + win_data->fb_width; 452 chroma_addr[1] = chroma_addr[0] + win_data->fb_pitch;
452 } 453 }
453 } else { 454 } else {
454 ctx->interlace = false; 455 ctx->interlace = false;
@@ -469,10 +470,10 @@ static void vp_video_buffer(struct mixer_context *ctx, int win)
469 vp_reg_writemask(res, VP_MODE, val, VP_MODE_FMT_MASK); 470 vp_reg_writemask(res, VP_MODE, val, VP_MODE_FMT_MASK);
470 471
471 /* setting size of input image */ 472 /* setting size of input image */
472 vp_reg_write(res, VP_IMG_SIZE_Y, VP_IMG_HSIZE(win_data->fb_width) | 473 vp_reg_write(res, VP_IMG_SIZE_Y, VP_IMG_HSIZE(win_data->fb_pitch) |
473 VP_IMG_VSIZE(win_data->fb_height)); 474 VP_IMG_VSIZE(win_data->fb_height));
474 /* chroma height has to reduced by 2 to avoid chroma distorions */ 475 /* chroma height has to reduced by 2 to avoid chroma distorions */
475 vp_reg_write(res, VP_IMG_SIZE_C, VP_IMG_HSIZE(win_data->fb_width) | 476 vp_reg_write(res, VP_IMG_SIZE_C, VP_IMG_HSIZE(win_data->fb_pitch) |
476 VP_IMG_VSIZE(win_data->fb_height / 2)); 477 VP_IMG_VSIZE(win_data->fb_height / 2));
477 478
478 vp_reg_write(res, VP_SRC_WIDTH, win_data->src_width); 479 vp_reg_write(res, VP_SRC_WIDTH, win_data->src_width);
@@ -559,7 +560,7 @@ static void mixer_graph_buffer(struct mixer_context *ctx, int win)
559 /* converting dma address base and source offset */ 560 /* converting dma address base and source offset */
560 dma_addr = win_data->dma_addr 561 dma_addr = win_data->dma_addr
561 + (win_data->fb_x * win_data->bpp >> 3) 562 + (win_data->fb_x * win_data->bpp >> 3)
562 + (win_data->fb_y * win_data->fb_width * win_data->bpp >> 3); 563 + (win_data->fb_y * win_data->fb_pitch);
563 src_x_offset = 0; 564 src_x_offset = 0;
564 src_y_offset = 0; 565 src_y_offset = 0;
565 566
@@ -576,7 +577,8 @@ static void mixer_graph_buffer(struct mixer_context *ctx, int win)
576 MXR_GRP_CFG_FORMAT_VAL(fmt), MXR_GRP_CFG_FORMAT_MASK); 577 MXR_GRP_CFG_FORMAT_VAL(fmt), MXR_GRP_CFG_FORMAT_MASK);
577 578
578 /* setup geometry */ 579 /* setup geometry */
579 mixer_reg_write(res, MXR_GRAPHIC_SPAN(win), win_data->fb_width); 580 mixer_reg_write(res, MXR_GRAPHIC_SPAN(win),
581 win_data->fb_pitch / (win_data->bpp >> 3));
580 582
581 /* setup display size */ 583 /* setup display size */
582 if (ctx->mxr_ver == MXR_VER_128_0_0_184 && 584 if (ctx->mxr_ver == MXR_VER_128_0_0_184 &&
@@ -961,6 +963,7 @@ static void mixer_win_mode_set(struct exynos_drm_crtc *crtc,
961 win_data->fb_y = plane->fb_y; 963 win_data->fb_y = plane->fb_y;
962 win_data->fb_width = plane->fb_width; 964 win_data->fb_width = plane->fb_width;
963 win_data->fb_height = plane->fb_height; 965 win_data->fb_height = plane->fb_height;
966 win_data->fb_pitch = plane->pitch;
964 win_data->src_width = plane->src_width; 967 win_data->src_width = plane->src_width;
965 win_data->src_height = plane->src_height; 968 win_data->src_height = plane->src_height;
966 969
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index cc6ea53d2b81..5c66b568bb81 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -1095,6 +1095,7 @@ static void vlv_save_gunit_s0ix_state(struct drm_i915_private *dev_priv)
1095 /* Gunit-Display CZ domain, 0x182028-0x1821CF */ 1095 /* Gunit-Display CZ domain, 0x182028-0x1821CF */
1096 s->gu_ctl0 = I915_READ(VLV_GU_CTL0); 1096 s->gu_ctl0 = I915_READ(VLV_GU_CTL0);
1097 s->gu_ctl1 = I915_READ(VLV_GU_CTL1); 1097 s->gu_ctl1 = I915_READ(VLV_GU_CTL1);
1098 s->pcbr = I915_READ(VLV_PCBR);
1098 s->clock_gate_dis2 = I915_READ(VLV_GUNIT_CLOCK_GATE2); 1099 s->clock_gate_dis2 = I915_READ(VLV_GUNIT_CLOCK_GATE2);
1099 1100
1100 /* 1101 /*
@@ -1189,6 +1190,7 @@ static void vlv_restore_gunit_s0ix_state(struct drm_i915_private *dev_priv)
1189 /* Gunit-Display CZ domain, 0x182028-0x1821CF */ 1190 /* Gunit-Display CZ domain, 0x182028-0x1821CF */
1190 I915_WRITE(VLV_GU_CTL0, s->gu_ctl0); 1191 I915_WRITE(VLV_GU_CTL0, s->gu_ctl0);
1191 I915_WRITE(VLV_GU_CTL1, s->gu_ctl1); 1192 I915_WRITE(VLV_GU_CTL1, s->gu_ctl1);
1193 I915_WRITE(VLV_PCBR, s->pcbr);
1192 I915_WRITE(VLV_GUNIT_CLOCK_GATE2, s->clock_gate_dis2); 1194 I915_WRITE(VLV_GUNIT_CLOCK_GATE2, s->clock_gate_dis2);
1193} 1195}
1194 1196
@@ -1197,19 +1199,7 @@ int vlv_force_gfx_clock(struct drm_i915_private *dev_priv, bool force_on)
1197 u32 val; 1199 u32 val;
1198 int err; 1200 int err;
1199 1201
1200 val = I915_READ(VLV_GTLC_SURVIVABILITY_REG);
1201 WARN_ON(!!(val & VLV_GFX_CLK_FORCE_ON_BIT) == force_on);
1202
1203#define COND (I915_READ(VLV_GTLC_SURVIVABILITY_REG) & VLV_GFX_CLK_STATUS_BIT) 1202#define COND (I915_READ(VLV_GTLC_SURVIVABILITY_REG) & VLV_GFX_CLK_STATUS_BIT)
1204 /* Wait for a previous force-off to settle */
1205 if (force_on) {
1206 err = wait_for(!COND, 20);
1207 if (err) {
1208 DRM_ERROR("timeout waiting for GFX clock force-off (%08x)\n",
1209 I915_READ(VLV_GTLC_SURVIVABILITY_REG));
1210 return err;
1211 }
1212 }
1213 1203
1214 val = I915_READ(VLV_GTLC_SURVIVABILITY_REG); 1204 val = I915_READ(VLV_GTLC_SURVIVABILITY_REG);
1215 val &= ~VLV_GFX_CLK_FORCE_ON_BIT; 1205 val &= ~VLV_GFX_CLK_FORCE_ON_BIT;
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 8727086cf48c..b4faa2df9d3d 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -1094,6 +1094,7 @@ struct vlv_s0ix_state {
1094 /* Display 2 CZ domain */ 1094 /* Display 2 CZ domain */
1095 u32 gu_ctl0; 1095 u32 gu_ctl0;
1096 u32 gu_ctl1; 1096 u32 gu_ctl1;
1097 u32 pcbr;
1097 u32 clock_gate_dis2; 1098 u32 clock_gate_dis2;
1098}; 1099};
1099 1100
diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
index b773368fc62c..38a742532c4f 100644
--- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
@@ -1487,7 +1487,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
1487 goto err; 1487 goto err;
1488 } 1488 }
1489 1489
1490 if (i915_needs_cmd_parser(ring)) { 1490 if (i915_needs_cmd_parser(ring) && args->batch_len) {
1491 batch_obj = i915_gem_execbuffer_parse(ring, 1491 batch_obj = i915_gem_execbuffer_parse(ring,
1492 &shadow_exec_entry, 1492 &shadow_exec_entry,
1493 eb, 1493 eb,
diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c
index 0a52c44ad03d..9c5451c97942 100644
--- a/drivers/gpu/drm/i915/intel_sprite.c
+++ b/drivers/gpu/drm/i915/intel_sprite.c
@@ -1322,7 +1322,7 @@ int intel_sprite_set_colorkey(struct drm_device *dev, void *data,
1322 drm_modeset_lock_all(dev); 1322 drm_modeset_lock_all(dev);
1323 1323
1324 plane = drm_plane_find(dev, set->plane_id); 1324 plane = drm_plane_find(dev, set->plane_id);
1325 if (!plane) { 1325 if (!plane || plane->type != DRM_PLANE_TYPE_OVERLAY) {
1326 ret = -ENOENT; 1326 ret = -ENOENT;
1327 goto out_unlock; 1327 goto out_unlock;
1328 } 1328 }
@@ -1349,7 +1349,7 @@ int intel_sprite_get_colorkey(struct drm_device *dev, void *data,
1349 drm_modeset_lock_all(dev); 1349 drm_modeset_lock_all(dev);
1350 1350
1351 plane = drm_plane_find(dev, get->plane_id); 1351 plane = drm_plane_find(dev, get->plane_id);
1352 if (!plane) { 1352 if (!plane || plane->type != DRM_PLANE_TYPE_OVERLAY) {
1353 ret = -ENOENT; 1353 ret = -ENOENT;
1354 goto out_unlock; 1354 goto out_unlock;
1355 } 1355 }
diff --git a/drivers/gpu/drm/radeon/cikd.h b/drivers/gpu/drm/radeon/cikd.h
index c648e1996dab..243a36c93b8f 100644
--- a/drivers/gpu/drm/radeon/cikd.h
+++ b/drivers/gpu/drm/radeon/cikd.h
@@ -2129,6 +2129,7 @@
2129#define VCE_UENC_REG_CLOCK_GATING 0x207c0 2129#define VCE_UENC_REG_CLOCK_GATING 0x207c0
2130#define VCE_SYS_INT_EN 0x21300 2130#define VCE_SYS_INT_EN 0x21300
2131# define VCE_SYS_INT_TRAP_INTERRUPT_EN (1 << 3) 2131# define VCE_SYS_INT_TRAP_INTERRUPT_EN (1 << 3)
2132#define VCE_LMI_VCPU_CACHE_40BIT_BAR 0x2145c
2132#define VCE_LMI_CTRL2 0x21474 2133#define VCE_LMI_CTRL2 0x21474
2133#define VCE_LMI_CTRL 0x21498 2134#define VCE_LMI_CTRL 0x21498
2134#define VCE_LMI_VM_CTRL 0x214a0 2135#define VCE_LMI_VM_CTRL 0x214a0
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index 5587603b4a89..33d5a4f4eebd 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -1565,6 +1565,7 @@ struct radeon_dpm {
1565 int new_active_crtc_count; 1565 int new_active_crtc_count;
1566 u32 current_active_crtcs; 1566 u32 current_active_crtcs;
1567 int current_active_crtc_count; 1567 int current_active_crtc_count;
1568 bool single_display;
1568 struct radeon_dpm_dynamic_state dyn_state; 1569 struct radeon_dpm_dynamic_state dyn_state;
1569 struct radeon_dpm_fan fan; 1570 struct radeon_dpm_fan fan;
1570 u32 tdp_limit; 1571 u32 tdp_limit;
diff --git a/drivers/gpu/drm/radeon/radeon_bios.c b/drivers/gpu/drm/radeon/radeon_bios.c
index 63ccb8fa799c..d27e4ccb848c 100644
--- a/drivers/gpu/drm/radeon/radeon_bios.c
+++ b/drivers/gpu/drm/radeon/radeon_bios.c
@@ -76,7 +76,7 @@ static bool igp_read_bios_from_vram(struct radeon_device *rdev)
76 76
77static bool radeon_read_bios(struct radeon_device *rdev) 77static bool radeon_read_bios(struct radeon_device *rdev)
78{ 78{
79 uint8_t __iomem *bios; 79 uint8_t __iomem *bios, val1, val2;
80 size_t size; 80 size_t size;
81 81
82 rdev->bios = NULL; 82 rdev->bios = NULL;
@@ -86,15 +86,19 @@ static bool radeon_read_bios(struct radeon_device *rdev)
86 return false; 86 return false;
87 } 87 }
88 88
89 if (size == 0 || bios[0] != 0x55 || bios[1] != 0xaa) { 89 val1 = readb(&bios[0]);
90 val2 = readb(&bios[1]);
91
92 if (size == 0 || val1 != 0x55 || val2 != 0xaa) {
90 pci_unmap_rom(rdev->pdev, bios); 93 pci_unmap_rom(rdev->pdev, bios);
91 return false; 94 return false;
92 } 95 }
93 rdev->bios = kmemdup(bios, size, GFP_KERNEL); 96 rdev->bios = kzalloc(size, GFP_KERNEL);
94 if (rdev->bios == NULL) { 97 if (rdev->bios == NULL) {
95 pci_unmap_rom(rdev->pdev, bios); 98 pci_unmap_rom(rdev->pdev, bios);
96 return false; 99 return false;
97 } 100 }
101 memcpy_fromio(rdev->bios, bios, size);
98 pci_unmap_rom(rdev->pdev, bios); 102 pci_unmap_rom(rdev->pdev, bios);
99 return true; 103 return true;
100} 104}
diff --git a/drivers/gpu/drm/radeon/radeon_mn.c b/drivers/gpu/drm/radeon/radeon_mn.c
index a69bd441dd2d..572b4dbec186 100644
--- a/drivers/gpu/drm/radeon/radeon_mn.c
+++ b/drivers/gpu/drm/radeon/radeon_mn.c
@@ -122,7 +122,6 @@ static void radeon_mn_invalidate_range_start(struct mmu_notifier *mn,
122 it = interval_tree_iter_first(&rmn->objects, start, end); 122 it = interval_tree_iter_first(&rmn->objects, start, end);
123 while (it) { 123 while (it) {
124 struct radeon_bo *bo; 124 struct radeon_bo *bo;
125 struct fence *fence;
126 int r; 125 int r;
127 126
128 bo = container_of(it, struct radeon_bo, mn_it); 127 bo = container_of(it, struct radeon_bo, mn_it);
@@ -134,12 +133,10 @@ static void radeon_mn_invalidate_range_start(struct mmu_notifier *mn,
134 continue; 133 continue;
135 } 134 }
136 135
137 fence = reservation_object_get_excl(bo->tbo.resv); 136 r = reservation_object_wait_timeout_rcu(bo->tbo.resv, true,
138 if (fence) { 137 false, MAX_SCHEDULE_TIMEOUT);
139 r = radeon_fence_wait((struct radeon_fence *)fence, false); 138 if (r)
140 if (r) 139 DRM_ERROR("(%d) failed to wait for user bo\n", r);
141 DRM_ERROR("(%d) failed to wait for user bo\n", r);
142 }
143 140
144 radeon_ttm_placement_from_domain(bo, RADEON_GEM_DOMAIN_CPU); 141 radeon_ttm_placement_from_domain(bo, RADEON_GEM_DOMAIN_CPU);
145 r = ttm_bo_validate(&bo->tbo, &bo->placement, false, false); 142 r = ttm_bo_validate(&bo->tbo, &bo->placement, false, false);
diff --git a/drivers/gpu/drm/radeon/radeon_pm.c b/drivers/gpu/drm/radeon/radeon_pm.c
index 33cf4108386d..c1ba83a8dd8c 100644
--- a/drivers/gpu/drm/radeon/radeon_pm.c
+++ b/drivers/gpu/drm/radeon/radeon_pm.c
@@ -837,12 +837,8 @@ static void radeon_dpm_thermal_work_handler(struct work_struct *work)
837 radeon_pm_compute_clocks(rdev); 837 radeon_pm_compute_clocks(rdev);
838} 838}
839 839
840static struct radeon_ps *radeon_dpm_pick_power_state(struct radeon_device *rdev, 840static bool radeon_dpm_single_display(struct radeon_device *rdev)
841 enum radeon_pm_state_type dpm_state)
842{ 841{
843 int i;
844 struct radeon_ps *ps;
845 u32 ui_class;
846 bool single_display = (rdev->pm.dpm.new_active_crtc_count < 2) ? 842 bool single_display = (rdev->pm.dpm.new_active_crtc_count < 2) ?
847 true : false; 843 true : false;
848 844
@@ -858,6 +854,17 @@ static struct radeon_ps *radeon_dpm_pick_power_state(struct radeon_device *rdev,
858 if (single_display && (r600_dpm_get_vrefresh(rdev) >= 120)) 854 if (single_display && (r600_dpm_get_vrefresh(rdev) >= 120))
859 single_display = false; 855 single_display = false;
860 856
857 return single_display;
858}
859
860static struct radeon_ps *radeon_dpm_pick_power_state(struct radeon_device *rdev,
861 enum radeon_pm_state_type dpm_state)
862{
863 int i;
864 struct radeon_ps *ps;
865 u32 ui_class;
866 bool single_display = radeon_dpm_single_display(rdev);
867
861 /* certain older asics have a separare 3D performance state, 868 /* certain older asics have a separare 3D performance state,
862 * so try that first if the user selected performance 869 * so try that first if the user selected performance
863 */ 870 */
@@ -983,6 +990,7 @@ static void radeon_dpm_change_power_state_locked(struct radeon_device *rdev)
983 struct radeon_ps *ps; 990 struct radeon_ps *ps;
984 enum radeon_pm_state_type dpm_state; 991 enum radeon_pm_state_type dpm_state;
985 int ret; 992 int ret;
993 bool single_display = radeon_dpm_single_display(rdev);
986 994
987 /* if dpm init failed */ 995 /* if dpm init failed */
988 if (!rdev->pm.dpm_enabled) 996 if (!rdev->pm.dpm_enabled)
@@ -1007,6 +1015,9 @@ static void radeon_dpm_change_power_state_locked(struct radeon_device *rdev)
1007 /* vce just modifies an existing state so force a change */ 1015 /* vce just modifies an existing state so force a change */
1008 if (ps->vce_active != rdev->pm.dpm.vce_active) 1016 if (ps->vce_active != rdev->pm.dpm.vce_active)
1009 goto force; 1017 goto force;
1018 /* user has made a display change (such as timing) */
1019 if (rdev->pm.dpm.single_display != single_display)
1020 goto force;
1010 if ((rdev->family < CHIP_BARTS) || (rdev->flags & RADEON_IS_IGP)) { 1021 if ((rdev->family < CHIP_BARTS) || (rdev->flags & RADEON_IS_IGP)) {
1011 /* for pre-BTC and APUs if the num crtcs changed but state is the same, 1022 /* for pre-BTC and APUs if the num crtcs changed but state is the same,
1012 * all we need to do is update the display configuration. 1023 * all we need to do is update the display configuration.
@@ -1069,6 +1080,7 @@ force:
1069 1080
1070 rdev->pm.dpm.current_active_crtcs = rdev->pm.dpm.new_active_crtcs; 1081 rdev->pm.dpm.current_active_crtcs = rdev->pm.dpm.new_active_crtcs;
1071 rdev->pm.dpm.current_active_crtc_count = rdev->pm.dpm.new_active_crtc_count; 1082 rdev->pm.dpm.current_active_crtc_count = rdev->pm.dpm.new_active_crtc_count;
1083 rdev->pm.dpm.single_display = single_display;
1072 1084
1073 /* wait for the rings to drain */ 1085 /* wait for the rings to drain */
1074 for (i = 0; i < RADEON_NUM_RINGS; i++) { 1086 for (i = 0; i < RADEON_NUM_RINGS; i++) {
diff --git a/drivers/gpu/drm/radeon/radeon_ring.c b/drivers/gpu/drm/radeon/radeon_ring.c
index 2456f69efd23..8c7872339c2a 100644
--- a/drivers/gpu/drm/radeon/radeon_ring.c
+++ b/drivers/gpu/drm/radeon/radeon_ring.c
@@ -495,7 +495,7 @@ static int radeon_debugfs_ring_info(struct seq_file *m, void *data)
495 seq_printf(m, "%u free dwords in ring\n", ring->ring_free_dw); 495 seq_printf(m, "%u free dwords in ring\n", ring->ring_free_dw);
496 seq_printf(m, "%u dwords in ring\n", count); 496 seq_printf(m, "%u dwords in ring\n", count);
497 497
498 if (!ring->ready) 498 if (!ring->ring)
499 return 0; 499 return 0;
500 500
501 /* print 8 dw before current rptr as often it's the last executed 501 /* print 8 dw before current rptr as often it's the last executed
diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
index d02aa1d0f588..b292aca0f342 100644
--- a/drivers/gpu/drm/radeon/radeon_ttm.c
+++ b/drivers/gpu/drm/radeon/radeon_ttm.c
@@ -598,6 +598,10 @@ static void radeon_ttm_tt_unpin_userptr(struct ttm_tt *ttm)
598 enum dma_data_direction direction = write ? 598 enum dma_data_direction direction = write ?
599 DMA_BIDIRECTIONAL : DMA_TO_DEVICE; 599 DMA_BIDIRECTIONAL : DMA_TO_DEVICE;
600 600
601 /* double check that we don't free the table twice */
602 if (!ttm->sg->sgl)
603 return;
604
601 /* free the sg table and pages again */ 605 /* free the sg table and pages again */
602 dma_unmap_sg(rdev->dev, ttm->sg->sgl, ttm->sg->nents, direction); 606 dma_unmap_sg(rdev->dev, ttm->sg->sgl, ttm->sg->nents, direction);
603 607
diff --git a/drivers/gpu/drm/radeon/vce_v2_0.c b/drivers/gpu/drm/radeon/vce_v2_0.c
index 1ac7bb825a1b..fbbe78fbd087 100644
--- a/drivers/gpu/drm/radeon/vce_v2_0.c
+++ b/drivers/gpu/drm/radeon/vce_v2_0.c
@@ -156,6 +156,9 @@ int vce_v2_0_resume(struct radeon_device *rdev)
156 WREG32(VCE_LMI_SWAP_CNTL1, 0); 156 WREG32(VCE_LMI_SWAP_CNTL1, 0);
157 WREG32(VCE_LMI_VM_CTRL, 0); 157 WREG32(VCE_LMI_VM_CTRL, 0);
158 158
159 WREG32(VCE_LMI_VCPU_CACHE_40BIT_BAR, addr >> 8);
160
161 addr &= 0xff;
159 size = RADEON_GPU_PAGE_ALIGN(rdev->vce_fw->size); 162 size = RADEON_GPU_PAGE_ALIGN(rdev->vce_fw->size);
160 WREG32(VCE_VCPU_CACHE_OFFSET0, addr & 0x7fffffff); 163 WREG32(VCE_VCPU_CACHE_OFFSET0, addr & 0x7fffffff);
161 WREG32(VCE_VCPU_CACHE_SIZE0, size); 164 WREG32(VCE_VCPU_CACHE_SIZE0, size);
diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
index c270f5f9a8f9..538d6910b550 100644
--- a/drivers/i2c/busses/i2c-designware-platdrv.c
+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
@@ -166,7 +166,7 @@ static int dw_i2c_probe(struct platform_device *pdev)
166 /* fast mode by default because of legacy reasons */ 166 /* fast mode by default because of legacy reasons */
167 clk_freq = 400000; 167 clk_freq = 400000;
168 168
169 if (ACPI_COMPANION(&pdev->dev)) { 169 if (has_acpi_companion(&pdev->dev)) {
170 dw_i2c_acpi_configure(pdev); 170 dw_i2c_acpi_configure(pdev);
171 } else if (pdev->dev.of_node) { 171 } else if (pdev->dev.of_node) {
172 of_property_read_u32(pdev->dev.of_node, 172 of_property_read_u32(pdev->dev.of_node,
@@ -286,7 +286,7 @@ static int dw_i2c_remove(struct platform_device *pdev)
286 pm_runtime_put(&pdev->dev); 286 pm_runtime_put(&pdev->dev);
287 pm_runtime_disable(&pdev->dev); 287 pm_runtime_disable(&pdev->dev);
288 288
289 if (ACPI_COMPANION(&pdev->dev)) 289 if (has_acpi_companion(&pdev->dev))
290 dw_i2c_acpi_unconfigure(pdev); 290 dw_i2c_acpi_unconfigure(pdev);
291 291
292 return 0; 292 return 0;
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index edf274cabe81..c87c31387e2d 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -133,7 +133,7 @@ static acpi_status acpi_i2c_add_device(acpi_handle handle, u32 level,
133 return AE_OK; 133 return AE_OK;
134 134
135 memset(&info, 0, sizeof(info)); 135 memset(&info, 0, sizeof(info));
136 info.acpi_node.companion = adev; 136 info.fwnode = acpi_fwnode_handle(adev);
137 info.irq = -1; 137 info.irq = -1;
138 138
139 INIT_LIST_HEAD(&resource_list); 139 INIT_LIST_HEAD(&resource_list);
@@ -971,7 +971,7 @@ i2c_new_device(struct i2c_adapter *adap, struct i2c_board_info const *info)
971 client->dev.bus = &i2c_bus_type; 971 client->dev.bus = &i2c_bus_type;
972 client->dev.type = &i2c_client_type; 972 client->dev.type = &i2c_client_type;
973 client->dev.of_node = info->of_node; 973 client->dev.of_node = info->of_node;
974 ACPI_COMPANION_SET(&client->dev, info->acpi_node.companion); 974 client->dev.fwnode = info->fwnode;
975 975
976 i2c_dev_set_name(adap, client); 976 i2c_dev_set_name(adap, client);
977 status = device_register(&client->dev); 977 status = device_register(&client->dev);
diff --git a/drivers/ide/ide-pnp.c b/drivers/ide/ide-pnp.c
index e5f3db831373..f5f2b62471da 100644
--- a/drivers/ide/ide-pnp.c
+++ b/drivers/ide/ide-pnp.c
@@ -96,17 +96,5 @@ static struct pnp_driver idepnp_driver = {
96 .remove = idepnp_remove, 96 .remove = idepnp_remove,
97}; 97};
98 98
99static int __init pnpide_init(void) 99module_pnp_driver(idepnp_driver);
100{
101 return pnp_register_driver(&idepnp_driver);
102}
103
104static void __exit pnpide_exit(void)
105{
106 pnp_unregister_driver(&idepnp_driver);
107}
108
109module_init(pnpide_init);
110module_exit(pnpide_exit);
111
112MODULE_LICENSE("GPL"); 100MODULE_LICENSE("GPL");
diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c
index b0e58522780d..1fb52f4e5870 100644
--- a/drivers/idle/intel_idle.c
+++ b/drivers/idle/intel_idle.c
@@ -218,18 +218,10 @@ static struct cpuidle_state byt_cstates[] = {
218 .enter = &intel_idle, 218 .enter = &intel_idle,
219 .enter_freeze = intel_idle_freeze, }, 219 .enter_freeze = intel_idle_freeze, },
220 { 220 {
221 .name = "C1E-BYT",
222 .desc = "MWAIT 0x01",
223 .flags = MWAIT2flg(0x01),
224 .exit_latency = 15,
225 .target_residency = 30,
226 .enter = &intel_idle,
227 .enter_freeze = intel_idle_freeze, },
228 {
229 .name = "C6N-BYT", 221 .name = "C6N-BYT",
230 .desc = "MWAIT 0x58", 222 .desc = "MWAIT 0x58",
231 .flags = MWAIT2flg(0x58) | CPUIDLE_FLAG_TLB_FLUSHED, 223 .flags = MWAIT2flg(0x58) | CPUIDLE_FLAG_TLB_FLUSHED,
232 .exit_latency = 40, 224 .exit_latency = 300,
233 .target_residency = 275, 225 .target_residency = 275,
234 .enter = &intel_idle, 226 .enter = &intel_idle,
235 .enter_freeze = intel_idle_freeze, }, 227 .enter_freeze = intel_idle_freeze, },
@@ -237,7 +229,7 @@ static struct cpuidle_state byt_cstates[] = {
237 .name = "C6S-BYT", 229 .name = "C6S-BYT",
238 .desc = "MWAIT 0x52", 230 .desc = "MWAIT 0x52",
239 .flags = MWAIT2flg(0x52) | CPUIDLE_FLAG_TLB_FLUSHED, 231 .flags = MWAIT2flg(0x52) | CPUIDLE_FLAG_TLB_FLUSHED,
240 .exit_latency = 140, 232 .exit_latency = 500,
241 .target_residency = 560, 233 .target_residency = 560,
242 .enter = &intel_idle, 234 .enter = &intel_idle,
243 .enter_freeze = intel_idle_freeze, }, 235 .enter_freeze = intel_idle_freeze, },
@@ -246,7 +238,7 @@ static struct cpuidle_state byt_cstates[] = {
246 .desc = "MWAIT 0x60", 238 .desc = "MWAIT 0x60",
247 .flags = MWAIT2flg(0x60) | CPUIDLE_FLAG_TLB_FLUSHED, 239 .flags = MWAIT2flg(0x60) | CPUIDLE_FLAG_TLB_FLUSHED,
248 .exit_latency = 1200, 240 .exit_latency = 1200,
249 .target_residency = 1500, 241 .target_residency = 4000,
250 .enter = &intel_idle, 242 .enter = &intel_idle,
251 .enter_freeze = intel_idle_freeze, }, 243 .enter_freeze = intel_idle_freeze, },
252 { 244 {
@@ -261,6 +253,51 @@ static struct cpuidle_state byt_cstates[] = {
261 .enter = NULL } 253 .enter = NULL }
262}; 254};
263 255
256static struct cpuidle_state cht_cstates[] = {
257 {
258 .name = "C1-CHT",
259 .desc = "MWAIT 0x00",
260 .flags = MWAIT2flg(0x00),
261 .exit_latency = 1,
262 .target_residency = 1,
263 .enter = &intel_idle,
264 .enter_freeze = intel_idle_freeze, },
265 {
266 .name = "C6N-CHT",
267 .desc = "MWAIT 0x58",
268 .flags = MWAIT2flg(0x58) | CPUIDLE_FLAG_TLB_FLUSHED,
269 .exit_latency = 80,
270 .target_residency = 275,
271 .enter = &intel_idle,
272 .enter_freeze = intel_idle_freeze, },
273 {
274 .name = "C6S-CHT",
275 .desc = "MWAIT 0x52",
276 .flags = MWAIT2flg(0x52) | CPUIDLE_FLAG_TLB_FLUSHED,
277 .exit_latency = 200,
278 .target_residency = 560,
279 .enter = &intel_idle,
280 .enter_freeze = intel_idle_freeze, },
281 {
282 .name = "C7-CHT",
283 .desc = "MWAIT 0x60",
284 .flags = MWAIT2flg(0x60) | CPUIDLE_FLAG_TLB_FLUSHED,
285 .exit_latency = 1200,
286 .target_residency = 4000,
287 .enter = &intel_idle,
288 .enter_freeze = intel_idle_freeze, },
289 {
290 .name = "C7S-CHT",
291 .desc = "MWAIT 0x64",
292 .flags = MWAIT2flg(0x64) | CPUIDLE_FLAG_TLB_FLUSHED,
293 .exit_latency = 10000,
294 .target_residency = 20000,
295 .enter = &intel_idle,
296 .enter_freeze = intel_idle_freeze, },
297 {
298 .enter = NULL }
299};
300
264static struct cpuidle_state ivb_cstates[] = { 301static struct cpuidle_state ivb_cstates[] = {
265 { 302 {
266 .name = "C1-IVB", 303 .name = "C1-IVB",
@@ -748,6 +785,12 @@ static const struct idle_cpu idle_cpu_byt = {
748 .byt_auto_demotion_disable_flag = true, 785 .byt_auto_demotion_disable_flag = true,
749}; 786};
750 787
788static const struct idle_cpu idle_cpu_cht = {
789 .state_table = cht_cstates,
790 .disable_promotion_to_c1e = true,
791 .byt_auto_demotion_disable_flag = true,
792};
793
751static const struct idle_cpu idle_cpu_ivb = { 794static const struct idle_cpu idle_cpu_ivb = {
752 .state_table = ivb_cstates, 795 .state_table = ivb_cstates,
753 .disable_promotion_to_c1e = true, 796 .disable_promotion_to_c1e = true,
@@ -776,7 +819,7 @@ static const struct idle_cpu idle_cpu_avn = {
776#define ICPU(model, cpu) \ 819#define ICPU(model, cpu) \
777 { X86_VENDOR_INTEL, 6, model, X86_FEATURE_MWAIT, (unsigned long)&cpu } 820 { X86_VENDOR_INTEL, 6, model, X86_FEATURE_MWAIT, (unsigned long)&cpu }
778 821
779static const struct x86_cpu_id intel_idle_ids[] = { 822static const struct x86_cpu_id intel_idle_ids[] __initconst = {
780 ICPU(0x1a, idle_cpu_nehalem), 823 ICPU(0x1a, idle_cpu_nehalem),
781 ICPU(0x1e, idle_cpu_nehalem), 824 ICPU(0x1e, idle_cpu_nehalem),
782 ICPU(0x1f, idle_cpu_nehalem), 825 ICPU(0x1f, idle_cpu_nehalem),
@@ -790,6 +833,7 @@ static const struct x86_cpu_id intel_idle_ids[] = {
790 ICPU(0x2d, idle_cpu_snb), 833 ICPU(0x2d, idle_cpu_snb),
791 ICPU(0x36, idle_cpu_atom), 834 ICPU(0x36, idle_cpu_atom),
792 ICPU(0x37, idle_cpu_byt), 835 ICPU(0x37, idle_cpu_byt),
836 ICPU(0x4c, idle_cpu_cht),
793 ICPU(0x3a, idle_cpu_ivb), 837 ICPU(0x3a, idle_cpu_ivb),
794 ICPU(0x3e, idle_cpu_ivt), 838 ICPU(0x3e, idle_cpu_ivt),
795 ICPU(0x3c, idle_cpu_hsw), 839 ICPU(0x3c, idle_cpu_hsw),
diff --git a/drivers/iio/accel/bma180.c b/drivers/iio/accel/bma180.c
index 1096da327130..75c6d2103e07 100644
--- a/drivers/iio/accel/bma180.c
+++ b/drivers/iio/accel/bma180.c
@@ -659,7 +659,7 @@ static irqreturn_t bma180_trigger_handler(int irq, void *p)
659 659
660 mutex_lock(&data->mutex); 660 mutex_lock(&data->mutex);
661 661
662 for_each_set_bit(bit, indio_dev->buffer->scan_mask, 662 for_each_set_bit(bit, indio_dev->active_scan_mask,
663 indio_dev->masklength) { 663 indio_dev->masklength) {
664 ret = bma180_get_data_reg(data, bit); 664 ret = bma180_get_data_reg(data, bit);
665 if (ret < 0) { 665 if (ret < 0) {
diff --git a/drivers/iio/accel/bmc150-accel.c b/drivers/iio/accel/bmc150-accel.c
index 066d0c04072c..75567fd457dc 100644
--- a/drivers/iio/accel/bmc150-accel.c
+++ b/drivers/iio/accel/bmc150-accel.c
@@ -168,14 +168,14 @@ static const struct {
168 int val; 168 int val;
169 int val2; 169 int val2;
170 u8 bw_bits; 170 u8 bw_bits;
171} bmc150_accel_samp_freq_table[] = { {7, 810000, 0x08}, 171} bmc150_accel_samp_freq_table[] = { {15, 620000, 0x08},
172 {15, 630000, 0x09}, 172 {31, 260000, 0x09},
173 {31, 250000, 0x0A}, 173 {62, 500000, 0x0A},
174 {62, 500000, 0x0B}, 174 {125, 0, 0x0B},
175 {125, 0, 0x0C}, 175 {250, 0, 0x0C},
176 {250, 0, 0x0D}, 176 {500, 0, 0x0D},
177 {500, 0, 0x0E}, 177 {1000, 0, 0x0E},
178 {1000, 0, 0x0F} }; 178 {2000, 0, 0x0F} };
179 179
180static const struct { 180static const struct {
181 int bw_bits; 181 int bw_bits;
@@ -840,7 +840,7 @@ static int bmc150_accel_validate_trigger(struct iio_dev *indio_dev,
840} 840}
841 841
842static IIO_CONST_ATTR_SAMP_FREQ_AVAIL( 842static IIO_CONST_ATTR_SAMP_FREQ_AVAIL(
843 "7.810000 15.630000 31.250000 62.500000 125 250 500 1000"); 843 "15.620000 31.260000 62.50000 125 250 500 1000 2000");
844 844
845static struct attribute *bmc150_accel_attributes[] = { 845static struct attribute *bmc150_accel_attributes[] = {
846 &iio_const_attr_sampling_frequency_available.dev_attr.attr, 846 &iio_const_attr_sampling_frequency_available.dev_attr.attr,
@@ -986,7 +986,7 @@ static irqreturn_t bmc150_accel_trigger_handler(int irq, void *p)
986 int bit, ret, i = 0; 986 int bit, ret, i = 0;
987 987
988 mutex_lock(&data->mutex); 988 mutex_lock(&data->mutex);
989 for_each_set_bit(bit, indio_dev->buffer->scan_mask, 989 for_each_set_bit(bit, indio_dev->active_scan_mask,
990 indio_dev->masklength) { 990 indio_dev->masklength) {
991 ret = i2c_smbus_read_word_data(data->client, 991 ret = i2c_smbus_read_word_data(data->client,
992 BMC150_ACCEL_AXIS_TO_REG(bit)); 992 BMC150_ACCEL_AXIS_TO_REG(bit));
diff --git a/drivers/iio/accel/kxcjk-1013.c b/drivers/iio/accel/kxcjk-1013.c
index 567de269cc00..1a6379525fa4 100644
--- a/drivers/iio/accel/kxcjk-1013.c
+++ b/drivers/iio/accel/kxcjk-1013.c
@@ -956,7 +956,7 @@ static irqreturn_t kxcjk1013_trigger_handler(int irq, void *p)
956 956
957 mutex_lock(&data->mutex); 957 mutex_lock(&data->mutex);
958 958
959 for_each_set_bit(bit, indio_dev->buffer->scan_mask, 959 for_each_set_bit(bit, indio_dev->active_scan_mask,
960 indio_dev->masklength) { 960 indio_dev->masklength) {
961 ret = kxcjk1013_get_acc_reg(data, bit); 961 ret = kxcjk1013_get_acc_reg(data, bit);
962 if (ret < 0) { 962 if (ret < 0) {
diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
index 202daf889be2..46379b1fb25b 100644
--- a/drivers/iio/adc/Kconfig
+++ b/drivers/iio/adc/Kconfig
@@ -137,7 +137,8 @@ config AXP288_ADC
137 137
138config CC10001_ADC 138config CC10001_ADC
139 tristate "Cosmic Circuits 10001 ADC driver" 139 tristate "Cosmic Circuits 10001 ADC driver"
140 depends on HAS_IOMEM || HAVE_CLK || REGULATOR 140 depends on HAVE_CLK || REGULATOR
141 depends on HAS_IOMEM
141 select IIO_BUFFER 142 select IIO_BUFFER
142 select IIO_TRIGGERED_BUFFER 143 select IIO_TRIGGERED_BUFFER
143 help 144 help
diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
index ff61ae55dd3f..8a0eb4a04fb5 100644
--- a/drivers/iio/adc/at91_adc.c
+++ b/drivers/iio/adc/at91_adc.c
@@ -544,7 +544,6 @@ static int at91_adc_configure_trigger(struct iio_trigger *trig, bool state)
544{ 544{
545 struct iio_dev *idev = iio_trigger_get_drvdata(trig); 545 struct iio_dev *idev = iio_trigger_get_drvdata(trig);
546 struct at91_adc_state *st = iio_priv(idev); 546 struct at91_adc_state *st = iio_priv(idev);
547 struct iio_buffer *buffer = idev->buffer;
548 struct at91_adc_reg_desc *reg = st->registers; 547 struct at91_adc_reg_desc *reg = st->registers;
549 u32 status = at91_adc_readl(st, reg->trigger_register); 548 u32 status = at91_adc_readl(st, reg->trigger_register);
550 int value; 549 int value;
@@ -564,7 +563,7 @@ static int at91_adc_configure_trigger(struct iio_trigger *trig, bool state)
564 at91_adc_writel(st, reg->trigger_register, 563 at91_adc_writel(st, reg->trigger_register,
565 status | value); 564 status | value);
566 565
567 for_each_set_bit(bit, buffer->scan_mask, 566 for_each_set_bit(bit, idev->active_scan_mask,
568 st->num_channels) { 567 st->num_channels) {
569 struct iio_chan_spec const *chan = idev->channels + bit; 568 struct iio_chan_spec const *chan = idev->channels + bit;
570 at91_adc_writel(st, AT91_ADC_CHER, 569 at91_adc_writel(st, AT91_ADC_CHER,
@@ -579,7 +578,7 @@ static int at91_adc_configure_trigger(struct iio_trigger *trig, bool state)
579 at91_adc_writel(st, reg->trigger_register, 578 at91_adc_writel(st, reg->trigger_register,
580 status & ~value); 579 status & ~value);
581 580
582 for_each_set_bit(bit, buffer->scan_mask, 581 for_each_set_bit(bit, idev->active_scan_mask,
583 st->num_channels) { 582 st->num_channels) {
584 struct iio_chan_spec const *chan = idev->channels + bit; 583 struct iio_chan_spec const *chan = idev->channels + bit;
585 at91_adc_writel(st, AT91_ADC_CHDR, 584 at91_adc_writel(st, AT91_ADC_CHDR,
diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c
index 2e5cc4409f78..a0e7161f040c 100644
--- a/drivers/iio/adc/ti_am335x_adc.c
+++ b/drivers/iio/adc/ti_am335x_adc.c
@@ -188,12 +188,11 @@ static int tiadc_buffer_preenable(struct iio_dev *indio_dev)
188static int tiadc_buffer_postenable(struct iio_dev *indio_dev) 188static int tiadc_buffer_postenable(struct iio_dev *indio_dev)
189{ 189{
190 struct tiadc_device *adc_dev = iio_priv(indio_dev); 190 struct tiadc_device *adc_dev = iio_priv(indio_dev);
191 struct iio_buffer *buffer = indio_dev->buffer;
192 unsigned int enb = 0; 191 unsigned int enb = 0;
193 u8 bit; 192 u8 bit;
194 193
195 tiadc_step_config(indio_dev); 194 tiadc_step_config(indio_dev);
196 for_each_set_bit(bit, buffer->scan_mask, adc_dev->channels) 195 for_each_set_bit(bit, indio_dev->active_scan_mask, adc_dev->channels)
197 enb |= (get_adc_step_bit(adc_dev, bit) << 1); 196 enb |= (get_adc_step_bit(adc_dev, bit) << 1);
198 adc_dev->buffer_en_ch_steps = enb; 197 adc_dev->buffer_en_ch_steps = enb;
199 198
diff --git a/drivers/iio/adc/vf610_adc.c b/drivers/iio/adc/vf610_adc.c
index 8ec353c01d98..e63b8e76d4c3 100644
--- a/drivers/iio/adc/vf610_adc.c
+++ b/drivers/iio/adc/vf610_adc.c
@@ -141,9 +141,13 @@ struct vf610_adc {
141 struct regulator *vref; 141 struct regulator *vref;
142 struct vf610_adc_feature adc_feature; 142 struct vf610_adc_feature adc_feature;
143 143
144 u32 sample_freq_avail[5];
145
144 struct completion completion; 146 struct completion completion;
145}; 147};
146 148
149static const u32 vf610_hw_avgs[] = { 1, 4, 8, 16, 32 };
150
147#define VF610_ADC_CHAN(_idx, _chan_type) { \ 151#define VF610_ADC_CHAN(_idx, _chan_type) { \
148 .type = (_chan_type), \ 152 .type = (_chan_type), \
149 .indexed = 1, \ 153 .indexed = 1, \
@@ -180,35 +184,47 @@ static const struct iio_chan_spec vf610_adc_iio_channels[] = {
180 /* sentinel */ 184 /* sentinel */
181}; 185};
182 186
183/* 187static inline void vf610_adc_calculate_rates(struct vf610_adc *info)
184 * ADC sample frequency, unit is ADCK cycles. 188{
185 * ADC clk source is ipg clock, which is the same as bus clock. 189 unsigned long adck_rate, ipg_rate = clk_get_rate(info->clk);
186 * 190 int i;
187 * ADC conversion time = SFCAdder + AverageNum x (BCT + LSTAdder) 191
188 * SFCAdder: fixed to 6 ADCK cycles 192 /*
189 * AverageNum: 1, 4, 8, 16, 32 samples for hardware average. 193 * Calculate ADC sample frequencies
190 * BCT (Base Conversion Time): fixed to 25 ADCK cycles for 12 bit mode 194 * Sample time unit is ADCK cycles. ADCK clk source is ipg clock,
191 * LSTAdder(Long Sample Time): fixed to 3 ADCK cycles 195 * which is the same as bus clock.
192 * 196 *
193 * By default, enable 12 bit resolution mode, clock source 197 * ADC conversion time = SFCAdder + AverageNum x (BCT + LSTAdder)
194 * set to ipg clock, So get below frequency group: 198 * SFCAdder: fixed to 6 ADCK cycles
195 */ 199 * AverageNum: 1, 4, 8, 16, 32 samples for hardware average.
196static const u32 vf610_sample_freq_avail[5] = 200 * BCT (Base Conversion Time): fixed to 25 ADCK cycles for 12 bit mode
197{1941176, 559332, 286957, 145374, 73171}; 201 * LSTAdder(Long Sample Time): fixed to 3 ADCK cycles
202 */
203 adck_rate = ipg_rate / info->adc_feature.clk_div;
204 for (i = 0; i < ARRAY_SIZE(vf610_hw_avgs); i++)
205 info->sample_freq_avail[i] =
206 adck_rate / (6 + vf610_hw_avgs[i] * (25 + 3));
207}
198 208
199static inline void vf610_adc_cfg_init(struct vf610_adc *info) 209static inline void vf610_adc_cfg_init(struct vf610_adc *info)
200{ 210{
211 struct vf610_adc_feature *adc_feature = &info->adc_feature;
212
201 /* set default Configuration for ADC controller */ 213 /* set default Configuration for ADC controller */
202 info->adc_feature.clk_sel = VF610_ADCIOC_BUSCLK_SET; 214 adc_feature->clk_sel = VF610_ADCIOC_BUSCLK_SET;
203 info->adc_feature.vol_ref = VF610_ADCIOC_VR_VREF_SET; 215 adc_feature->vol_ref = VF610_ADCIOC_VR_VREF_SET;
216
217 adc_feature->calibration = true;
218 adc_feature->ovwren = true;
219
220 adc_feature->res_mode = 12;
221 adc_feature->sample_rate = 1;
222 adc_feature->lpm = true;
204 223
205 info->adc_feature.calibration = true; 224 /* Use a save ADCK which is below 20MHz on all devices */
206 info->adc_feature.ovwren = true; 225 adc_feature->clk_div = 8;
207 226
208 info->adc_feature.clk_div = 1; 227 vf610_adc_calculate_rates(info);
209 info->adc_feature.res_mode = 12;
210 info->adc_feature.sample_rate = 1;
211 info->adc_feature.lpm = true;
212} 228}
213 229
214static void vf610_adc_cfg_post_set(struct vf610_adc *info) 230static void vf610_adc_cfg_post_set(struct vf610_adc *info)
@@ -290,12 +306,10 @@ static void vf610_adc_cfg_set(struct vf610_adc *info)
290 306
291 cfg_data = readl(info->regs + VF610_REG_ADC_CFG); 307 cfg_data = readl(info->regs + VF610_REG_ADC_CFG);
292 308
293 /* low power configuration */
294 cfg_data &= ~VF610_ADC_ADLPC_EN; 309 cfg_data &= ~VF610_ADC_ADLPC_EN;
295 if (adc_feature->lpm) 310 if (adc_feature->lpm)
296 cfg_data |= VF610_ADC_ADLPC_EN; 311 cfg_data |= VF610_ADC_ADLPC_EN;
297 312
298 /* disable high speed */
299 cfg_data &= ~VF610_ADC_ADHSC_EN; 313 cfg_data &= ~VF610_ADC_ADHSC_EN;
300 314
301 writel(cfg_data, info->regs + VF610_REG_ADC_CFG); 315 writel(cfg_data, info->regs + VF610_REG_ADC_CFG);
@@ -435,10 +449,27 @@ static irqreturn_t vf610_adc_isr(int irq, void *dev_id)
435 return IRQ_HANDLED; 449 return IRQ_HANDLED;
436} 450}
437 451
438static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("1941176, 559332, 286957, 145374, 73171"); 452static ssize_t vf610_show_samp_freq_avail(struct device *dev,
453 struct device_attribute *attr, char *buf)
454{
455 struct vf610_adc *info = iio_priv(dev_to_iio_dev(dev));
456 size_t len = 0;
457 int i;
458
459 for (i = 0; i < ARRAY_SIZE(info->sample_freq_avail); i++)
460 len += scnprintf(buf + len, PAGE_SIZE - len,
461 "%u ", info->sample_freq_avail[i]);
462
463 /* replace trailing space by newline */
464 buf[len - 1] = '\n';
465
466 return len;
467}
468
469static IIO_DEV_ATTR_SAMP_FREQ_AVAIL(vf610_show_samp_freq_avail);
439 470
440static struct attribute *vf610_attributes[] = { 471static struct attribute *vf610_attributes[] = {
441 &iio_const_attr_sampling_frequency_available.dev_attr.attr, 472 &iio_dev_attr_sampling_frequency_available.dev_attr.attr,
442 NULL 473 NULL
443}; 474};
444 475
@@ -502,7 +533,7 @@ static int vf610_read_raw(struct iio_dev *indio_dev,
502 return IIO_VAL_FRACTIONAL_LOG2; 533 return IIO_VAL_FRACTIONAL_LOG2;
503 534
504 case IIO_CHAN_INFO_SAMP_FREQ: 535 case IIO_CHAN_INFO_SAMP_FREQ:
505 *val = vf610_sample_freq_avail[info->adc_feature.sample_rate]; 536 *val = info->sample_freq_avail[info->adc_feature.sample_rate];
506 *val2 = 0; 537 *val2 = 0;
507 return IIO_VAL_INT; 538 return IIO_VAL_INT;
508 539
@@ -525,9 +556,9 @@ static int vf610_write_raw(struct iio_dev *indio_dev,
525 switch (mask) { 556 switch (mask) {
526 case IIO_CHAN_INFO_SAMP_FREQ: 557 case IIO_CHAN_INFO_SAMP_FREQ:
527 for (i = 0; 558 for (i = 0;
528 i < ARRAY_SIZE(vf610_sample_freq_avail); 559 i < ARRAY_SIZE(info->sample_freq_avail);
529 i++) 560 i++)
530 if (val == vf610_sample_freq_avail[i]) { 561 if (val == info->sample_freq_avail[i]) {
531 info->adc_feature.sample_rate = i; 562 info->adc_feature.sample_rate = i;
532 vf610_adc_sample_set(info); 563 vf610_adc_sample_set(info);
533 return 0; 564 return 0;
diff --git a/drivers/iio/gyro/bmg160.c b/drivers/iio/gyro/bmg160.c
index 60451b328242..ccf3ea7e1afa 100644
--- a/drivers/iio/gyro/bmg160.c
+++ b/drivers/iio/gyro/bmg160.c
@@ -822,7 +822,7 @@ static irqreturn_t bmg160_trigger_handler(int irq, void *p)
822 int bit, ret, i = 0; 822 int bit, ret, i = 0;
823 823
824 mutex_lock(&data->mutex); 824 mutex_lock(&data->mutex);
825 for_each_set_bit(bit, indio_dev->buffer->scan_mask, 825 for_each_set_bit(bit, indio_dev->active_scan_mask,
826 indio_dev->masklength) { 826 indio_dev->masklength) {
827 ret = i2c_smbus_read_word_data(data->client, 827 ret = i2c_smbus_read_word_data(data->client,
828 BMG160_AXIS_TO_REG(bit)); 828 BMG160_AXIS_TO_REG(bit));
diff --git a/drivers/iio/imu/adis_trigger.c b/drivers/iio/imu/adis_trigger.c
index e0017c22bb9c..f53e9a803a0e 100644
--- a/drivers/iio/imu/adis_trigger.c
+++ b/drivers/iio/imu/adis_trigger.c
@@ -60,7 +60,7 @@ int adis_probe_trigger(struct adis *adis, struct iio_dev *indio_dev)
60 iio_trigger_set_drvdata(adis->trig, adis); 60 iio_trigger_set_drvdata(adis->trig, adis);
61 ret = iio_trigger_register(adis->trig); 61 ret = iio_trigger_register(adis->trig);
62 62
63 indio_dev->trig = adis->trig; 63 indio_dev->trig = iio_trigger_get(adis->trig);
64 if (ret) 64 if (ret)
65 goto error_free_irq; 65 goto error_free_irq;
66 66
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
index d8d5bed65e07..ef76afe2643c 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
@@ -410,42 +410,46 @@ error_read_raw:
410 } 410 }
411} 411}
412 412
413static int inv_mpu6050_write_fsr(struct inv_mpu6050_state *st, int fsr) 413static int inv_mpu6050_write_gyro_scale(struct inv_mpu6050_state *st, int val)
414{ 414{
415 int result; 415 int result, i;
416 u8 d; 416 u8 d;
417 417
418 if (fsr < 0 || fsr > INV_MPU6050_MAX_GYRO_FS_PARAM) 418 for (i = 0; i < ARRAY_SIZE(gyro_scale_6050); ++i) {
419 return -EINVAL; 419 if (gyro_scale_6050[i] == val) {
420 if (fsr == st->chip_config.fsr) 420 d = (i << INV_MPU6050_GYRO_CONFIG_FSR_SHIFT);
421 return 0; 421 result = inv_mpu6050_write_reg(st,
422 st->reg->gyro_config, d);
423 if (result)
424 return result;
422 425
423 d = (fsr << INV_MPU6050_GYRO_CONFIG_FSR_SHIFT); 426 st->chip_config.fsr = i;
424 result = inv_mpu6050_write_reg(st, st->reg->gyro_config, d); 427 return 0;
425 if (result) 428 }
426 return result; 429 }
427 st->chip_config.fsr = fsr;
428 430
429 return 0; 431 return -EINVAL;
430} 432}
431 433
432static int inv_mpu6050_write_accel_fs(struct inv_mpu6050_state *st, int fs) 434static int inv_mpu6050_write_accel_scale(struct inv_mpu6050_state *st, int val)
433{ 435{
434 int result; 436 int result, i;
435 u8 d; 437 u8 d;
436 438
437 if (fs < 0 || fs > INV_MPU6050_MAX_ACCL_FS_PARAM) 439 for (i = 0; i < ARRAY_SIZE(accel_scale); ++i) {
438 return -EINVAL; 440 if (accel_scale[i] == val) {
439 if (fs == st->chip_config.accl_fs) 441 d = (i << INV_MPU6050_ACCL_CONFIG_FSR_SHIFT);
440 return 0; 442 result = inv_mpu6050_write_reg(st,
443 st->reg->accl_config, d);
444 if (result)
445 return result;
441 446
442 d = (fs << INV_MPU6050_ACCL_CONFIG_FSR_SHIFT); 447 st->chip_config.accl_fs = i;
443 result = inv_mpu6050_write_reg(st, st->reg->accl_config, d); 448 return 0;
444 if (result) 449 }
445 return result; 450 }
446 st->chip_config.accl_fs = fs;
447 451
448 return 0; 452 return -EINVAL;
449} 453}
450 454
451static int inv_mpu6050_write_raw(struct iio_dev *indio_dev, 455static int inv_mpu6050_write_raw(struct iio_dev *indio_dev,
@@ -471,10 +475,10 @@ static int inv_mpu6050_write_raw(struct iio_dev *indio_dev,
471 case IIO_CHAN_INFO_SCALE: 475 case IIO_CHAN_INFO_SCALE:
472 switch (chan->type) { 476 switch (chan->type) {
473 case IIO_ANGL_VEL: 477 case IIO_ANGL_VEL:
474 result = inv_mpu6050_write_fsr(st, val); 478 result = inv_mpu6050_write_gyro_scale(st, val2);
475 break; 479 break;
476 case IIO_ACCEL: 480 case IIO_ACCEL:
477 result = inv_mpu6050_write_accel_fs(st, val); 481 result = inv_mpu6050_write_accel_scale(st, val2);
478 break; 482 break;
479 default: 483 default:
480 result = -EINVAL; 484 result = -EINVAL;
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c
index 0cd306a72a6e..ba27e277511f 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c
@@ -24,6 +24,16 @@
24#include <linux/poll.h> 24#include <linux/poll.h>
25#include "inv_mpu_iio.h" 25#include "inv_mpu_iio.h"
26 26
27static void inv_clear_kfifo(struct inv_mpu6050_state *st)
28{
29 unsigned long flags;
30
31 /* take the spin lock sem to avoid interrupt kick in */
32 spin_lock_irqsave(&st->time_stamp_lock, flags);
33 kfifo_reset(&st->timestamps);
34 spin_unlock_irqrestore(&st->time_stamp_lock, flags);
35}
36
27int inv_reset_fifo(struct iio_dev *indio_dev) 37int inv_reset_fifo(struct iio_dev *indio_dev)
28{ 38{
29 int result; 39 int result;
@@ -50,6 +60,10 @@ int inv_reset_fifo(struct iio_dev *indio_dev)
50 INV_MPU6050_BIT_FIFO_RST); 60 INV_MPU6050_BIT_FIFO_RST);
51 if (result) 61 if (result)
52 goto reset_fifo_fail; 62 goto reset_fifo_fail;
63
64 /* clear timestamps fifo */
65 inv_clear_kfifo(st);
66
53 /* enable interrupt */ 67 /* enable interrupt */
54 if (st->chip_config.accl_fifo_enable || 68 if (st->chip_config.accl_fifo_enable ||
55 st->chip_config.gyro_fifo_enable) { 69 st->chip_config.gyro_fifo_enable) {
@@ -83,16 +97,6 @@ reset_fifo_fail:
83 return result; 97 return result;
84} 98}
85 99
86static void inv_clear_kfifo(struct inv_mpu6050_state *st)
87{
88 unsigned long flags;
89
90 /* take the spin lock sem to avoid interrupt kick in */
91 spin_lock_irqsave(&st->time_stamp_lock, flags);
92 kfifo_reset(&st->timestamps);
93 spin_unlock_irqrestore(&st->time_stamp_lock, flags);
94}
95
96/** 100/**
97 * inv_mpu6050_irq_handler() - Cache a timestamp at each data ready interrupt. 101 * inv_mpu6050_irq_handler() - Cache a timestamp at each data ready interrupt.
98 */ 102 */
@@ -184,7 +188,6 @@ end_session:
184flush_fifo: 188flush_fifo:
185 /* Flush HW and SW FIFOs. */ 189 /* Flush HW and SW FIFOs. */
186 inv_reset_fifo(indio_dev); 190 inv_reset_fifo(indio_dev);
187 inv_clear_kfifo(st);
188 mutex_unlock(&indio_dev->mlock); 191 mutex_unlock(&indio_dev->mlock);
189 iio_trigger_notify_done(indio_dev->trig); 192 iio_trigger_notify_done(indio_dev->trig);
190 193
diff --git a/drivers/iio/imu/kmx61.c b/drivers/iio/imu/kmx61.c
index 5cc3692acf37..b3a36376c719 100644
--- a/drivers/iio/imu/kmx61.c
+++ b/drivers/iio/imu/kmx61.c
@@ -1227,7 +1227,7 @@ static irqreturn_t kmx61_trigger_handler(int irq, void *p)
1227 base = KMX61_MAG_XOUT_L; 1227 base = KMX61_MAG_XOUT_L;
1228 1228
1229 mutex_lock(&data->lock); 1229 mutex_lock(&data->lock);
1230 for_each_set_bit(bit, indio_dev->buffer->scan_mask, 1230 for_each_set_bit(bit, indio_dev->active_scan_mask,
1231 indio_dev->masklength) { 1231 indio_dev->masklength) {
1232 ret = kmx61_read_measurement(data, base, bit); 1232 ret = kmx61_read_measurement(data, base, bit);
1233 if (ret < 0) { 1233 if (ret < 0) {
diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
index aaba9d3d980e..4df97f650e44 100644
--- a/drivers/iio/industrialio-core.c
+++ b/drivers/iio/industrialio-core.c
@@ -847,8 +847,7 @@ static int iio_device_add_channel_sysfs(struct iio_dev *indio_dev,
847 * @attr_list: List of IIO device attributes 847 * @attr_list: List of IIO device attributes
848 * 848 *
849 * This function frees the memory allocated for each of the IIO device 849 * This function frees the memory allocated for each of the IIO device
850 * attributes in the list. Note: if you want to reuse the list after calling 850 * attributes in the list.
851 * this function you have to reinitialize it using INIT_LIST_HEAD().
852 */ 851 */
853void iio_free_chan_devattr_list(struct list_head *attr_list) 852void iio_free_chan_devattr_list(struct list_head *attr_list)
854{ 853{
@@ -856,6 +855,7 @@ void iio_free_chan_devattr_list(struct list_head *attr_list)
856 855
857 list_for_each_entry_safe(p, n, attr_list, l) { 856 list_for_each_entry_safe(p, n, attr_list, l) {
858 kfree(p->dev_attr.attr.name); 857 kfree(p->dev_attr.attr.name);
858 list_del(&p->l);
859 kfree(p); 859 kfree(p);
860 } 860 }
861} 861}
@@ -936,6 +936,7 @@ static void iio_device_unregister_sysfs(struct iio_dev *indio_dev)
936 936
937 iio_free_chan_devattr_list(&indio_dev->channel_attr_list); 937 iio_free_chan_devattr_list(&indio_dev->channel_attr_list);
938 kfree(indio_dev->chan_attr_group.attrs); 938 kfree(indio_dev->chan_attr_group.attrs);
939 indio_dev->chan_attr_group.attrs = NULL;
939} 940}
940 941
941static void iio_dev_release(struct device *device) 942static void iio_dev_release(struct device *device)
diff --git a/drivers/iio/industrialio-event.c b/drivers/iio/industrialio-event.c
index a4b397048f71..a99692ba91bc 100644
--- a/drivers/iio/industrialio-event.c
+++ b/drivers/iio/industrialio-event.c
@@ -500,6 +500,7 @@ int iio_device_register_eventset(struct iio_dev *indio_dev)
500error_free_setup_event_lines: 500error_free_setup_event_lines:
501 iio_free_chan_devattr_list(&indio_dev->event_interface->dev_attr_list); 501 iio_free_chan_devattr_list(&indio_dev->event_interface->dev_attr_list);
502 kfree(indio_dev->event_interface); 502 kfree(indio_dev->event_interface);
503 indio_dev->event_interface = NULL;
503 return ret; 504 return ret;
504} 505}
505 506
diff --git a/drivers/iio/proximity/sx9500.c b/drivers/iio/proximity/sx9500.c
index 74dff4e4a11a..89fca3a70750 100644
--- a/drivers/iio/proximity/sx9500.c
+++ b/drivers/iio/proximity/sx9500.c
@@ -494,7 +494,7 @@ static irqreturn_t sx9500_trigger_handler(int irq, void *private)
494 494
495 mutex_lock(&data->mutex); 495 mutex_lock(&data->mutex);
496 496
497 for_each_set_bit(bit, indio_dev->buffer->scan_mask, 497 for_each_set_bit(bit, indio_dev->active_scan_mask,
498 indio_dev->masklength) { 498 indio_dev->masklength) {
499 ret = sx9500_read_proximity(data, &indio_dev->channels[bit], 499 ret = sx9500_read_proximity(data, &indio_dev->channels[bit],
500 &val); 500 &val);
diff --git a/drivers/infiniband/core/umem.c b/drivers/infiniband/core/umem.c
index aec7a6aa2951..8c014b5dab4c 100644
--- a/drivers/infiniband/core/umem.c
+++ b/drivers/infiniband/core/umem.c
@@ -99,6 +99,14 @@ struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr,
99 if (dmasync) 99 if (dmasync)
100 dma_set_attr(DMA_ATTR_WRITE_BARRIER, &attrs); 100 dma_set_attr(DMA_ATTR_WRITE_BARRIER, &attrs);
101 101
102 /*
103 * If the combination of the addr and size requested for this memory
104 * region causes an integer overflow, return error.
105 */
106 if ((PAGE_ALIGN(addr + size) <= size) ||
107 (PAGE_ALIGN(addr + size) <= addr))
108 return ERR_PTR(-EINVAL);
109
102 if (!can_do_mlock()) 110 if (!can_do_mlock())
103 return ERR_PTR(-EPERM); 111 return ERR_PTR(-EPERM);
104 112
diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c
index 1bd15ebc01f2..27bcdbc950c9 100644
--- a/drivers/input/mouse/alps.c
+++ b/drivers/input/mouse/alps.c
@@ -1154,10 +1154,28 @@ out:
1154 mutex_unlock(&alps_mutex); 1154 mutex_unlock(&alps_mutex);
1155} 1155}
1156 1156
1157static void alps_report_bare_ps2_packet(struct input_dev *dev, 1157static void alps_report_bare_ps2_packet(struct psmouse *psmouse,
1158 unsigned char packet[], 1158 unsigned char packet[],
1159 bool report_buttons) 1159 bool report_buttons)
1160{ 1160{
1161 struct alps_data *priv = psmouse->private;
1162 struct input_dev *dev;
1163
1164 /* Figure out which device to use to report the bare packet */
1165 if (priv->proto_version == ALPS_PROTO_V2 &&
1166 (priv->flags & ALPS_DUALPOINT)) {
1167 /* On V2 devices the DualPoint Stick reports bare packets */
1168 dev = priv->dev2;
1169 } else if (unlikely(IS_ERR_OR_NULL(priv->dev3))) {
1170 /* Register dev3 mouse if we received PS/2 packet first time */
1171 if (!IS_ERR(priv->dev3))
1172 psmouse_queue_work(psmouse, &priv->dev3_register_work,
1173 0);
1174 return;
1175 } else {
1176 dev = priv->dev3;
1177 }
1178
1161 if (report_buttons) 1179 if (report_buttons)
1162 alps_report_buttons(dev, NULL, 1180 alps_report_buttons(dev, NULL,
1163 packet[0] & 1, packet[0] & 2, packet[0] & 4); 1181 packet[0] & 1, packet[0] & 2, packet[0] & 4);
@@ -1232,8 +1250,8 @@ static psmouse_ret_t alps_handle_interleaved_ps2(struct psmouse *psmouse)
1232 * de-synchronization. 1250 * de-synchronization.
1233 */ 1251 */
1234 1252
1235 alps_report_bare_ps2_packet(priv->dev2, 1253 alps_report_bare_ps2_packet(psmouse, &psmouse->packet[3],
1236 &psmouse->packet[3], false); 1254 false);
1237 1255
1238 /* 1256 /*
1239 * Continue with the standard ALPS protocol handling, 1257 * Continue with the standard ALPS protocol handling,
@@ -1289,18 +1307,9 @@ static psmouse_ret_t alps_process_byte(struct psmouse *psmouse)
1289 * properly we only do this if the device is fully synchronized. 1307 * properly we only do this if the device is fully synchronized.
1290 */ 1308 */
1291 if (!psmouse->out_of_sync_cnt && (psmouse->packet[0] & 0xc8) == 0x08) { 1309 if (!psmouse->out_of_sync_cnt && (psmouse->packet[0] & 0xc8) == 0x08) {
1292
1293 /* Register dev3 mouse if we received PS/2 packet first time */
1294 if (unlikely(!priv->dev3))
1295 psmouse_queue_work(psmouse,
1296 &priv->dev3_register_work, 0);
1297
1298 if (psmouse->pktcnt == 3) { 1310 if (psmouse->pktcnt == 3) {
1299 /* Once dev3 mouse device is registered report data */ 1311 alps_report_bare_ps2_packet(psmouse, psmouse->packet,
1300 if (likely(!IS_ERR_OR_NULL(priv->dev3))) 1312 true);
1301 alps_report_bare_ps2_packet(priv->dev3,
1302 psmouse->packet,
1303 true);
1304 return PSMOUSE_FULL_PACKET; 1313 return PSMOUSE_FULL_PACKET;
1305 } 1314 }
1306 return PSMOUSE_GOOD_DATA; 1315 return PSMOUSE_GOOD_DATA;
@@ -2281,10 +2290,12 @@ static int alps_set_protocol(struct psmouse *psmouse,
2281 priv->set_abs_params = alps_set_abs_params_mt; 2290 priv->set_abs_params = alps_set_abs_params_mt;
2282 priv->nibble_commands = alps_v3_nibble_commands; 2291 priv->nibble_commands = alps_v3_nibble_commands;
2283 priv->addr_command = PSMOUSE_CMD_RESET_WRAP; 2292 priv->addr_command = PSMOUSE_CMD_RESET_WRAP;
2284 priv->x_max = 1360;
2285 priv->y_max = 660;
2286 priv->x_bits = 23; 2293 priv->x_bits = 23;
2287 priv->y_bits = 12; 2294 priv->y_bits = 12;
2295
2296 if (alps_dolphin_get_device_area(psmouse, priv))
2297 return -EIO;
2298
2288 break; 2299 break;
2289 2300
2290 case ALPS_PROTO_V6: 2301 case ALPS_PROTO_V6:
@@ -2303,9 +2314,8 @@ static int alps_set_protocol(struct psmouse *psmouse,
2303 priv->set_abs_params = alps_set_abs_params_mt; 2314 priv->set_abs_params = alps_set_abs_params_mt;
2304 priv->nibble_commands = alps_v3_nibble_commands; 2315 priv->nibble_commands = alps_v3_nibble_commands;
2305 priv->addr_command = PSMOUSE_CMD_RESET_WRAP; 2316 priv->addr_command = PSMOUSE_CMD_RESET_WRAP;
2306 2317 priv->x_max = 0xfff;
2307 if (alps_dolphin_get_device_area(psmouse, priv)) 2318 priv->y_max = 0x7ff;
2308 return -EIO;
2309 2319
2310 if (priv->fw_ver[1] != 0xba) 2320 if (priv->fw_ver[1] != 0xba)
2311 priv->flags |= ALPS_BUTTONPAD; 2321 priv->flags |= ALPS_BUTTONPAD;
diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
index dda605836546..3b06c8a360b6 100644
--- a/drivers/input/mouse/synaptics.c
+++ b/drivers/input/mouse/synaptics.c
@@ -154,6 +154,11 @@ static const struct min_max_quirk min_max_pnpid_table[] = {
154 }, 154 },
155 { 155 {
156 (const char * const []){"LEN2006", NULL}, 156 (const char * const []){"LEN2006", NULL},
157 {2691, 2691},
158 1024, 5045, 2457, 4832
159 },
160 {
161 (const char * const []){"LEN2006", NULL},
157 {ANY_BOARD_ID, ANY_BOARD_ID}, 162 {ANY_BOARD_ID, ANY_BOARD_ID},
158 1264, 5675, 1171, 4688 163 1264, 5675, 1171, 4688
159 }, 164 },
@@ -189,7 +194,7 @@ static const char * const topbuttonpad_pnp_ids[] = {
189 "LEN2003", 194 "LEN2003",
190 "LEN2004", /* L440 */ 195 "LEN2004", /* L440 */
191 "LEN2005", 196 "LEN2005",
192 "LEN2006", 197 "LEN2006", /* Edge E440/E540 */
193 "LEN2007", 198 "LEN2007",
194 "LEN2008", 199 "LEN2008",
195 "LEN2009", 200 "LEN2009",
diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c
index fc13dd56953e..a3adde6519f0 100644
--- a/drivers/iommu/arm-smmu.c
+++ b/drivers/iommu/arm-smmu.c
@@ -1288,10 +1288,13 @@ static phys_addr_t arm_smmu_iova_to_phys(struct iommu_domain *domain,
1288 return 0; 1288 return 0;
1289 1289
1290 spin_lock_irqsave(&smmu_domain->pgtbl_lock, flags); 1290 spin_lock_irqsave(&smmu_domain->pgtbl_lock, flags);
1291 if (smmu_domain->smmu->features & ARM_SMMU_FEAT_TRANS_OPS) 1291 if (smmu_domain->smmu->features & ARM_SMMU_FEAT_TRANS_OPS &&
1292 smmu_domain->stage == ARM_SMMU_DOMAIN_S1) {
1292 ret = arm_smmu_iova_to_phys_hard(domain, iova); 1293 ret = arm_smmu_iova_to_phys_hard(domain, iova);
1293 else 1294 } else {
1294 ret = ops->iova_to_phys(ops, iova); 1295 ret = ops->iova_to_phys(ops, iova);
1296 }
1297
1295 spin_unlock_irqrestore(&smmu_domain->pgtbl_lock, flags); 1298 spin_unlock_irqrestore(&smmu_domain->pgtbl_lock, flags);
1296 1299
1297 return ret; 1300 return ret;
@@ -1556,7 +1559,7 @@ static int arm_smmu_device_cfg_probe(struct arm_smmu_device *smmu)
1556 return -ENODEV; 1559 return -ENODEV;
1557 } 1560 }
1558 1561
1559 if (smmu->version == 1 || (!(id & ID0_ATOSNS) && (id & ID0_S1TS))) { 1562 if ((id & ID0_S1TS) && ((smmu->version == 1) || (id & ID0_ATOSNS))) {
1560 smmu->features |= ARM_SMMU_FEAT_TRANS_OPS; 1563 smmu->features |= ARM_SMMU_FEAT_TRANS_OPS;
1561 dev_notice(smmu->dev, "\taddress translation ops\n"); 1564 dev_notice(smmu->dev, "\taddress translation ops\n");
1562 } 1565 }
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index ae4c1a854e57..4fc1f8a7f98e 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -684,7 +684,7 @@ static struct intel_iommu *device_to_iommu(struct device *dev, u8 *bus, u8 *devf
684 if (dev_is_pci(dev)) { 684 if (dev_is_pci(dev)) {
685 pdev = to_pci_dev(dev); 685 pdev = to_pci_dev(dev);
686 segment = pci_domain_nr(pdev->bus); 686 segment = pci_domain_nr(pdev->bus);
687 } else if (ACPI_COMPANION(dev)) 687 } else if (has_acpi_companion(dev))
688 dev = &ACPI_COMPANION(dev)->dev; 688 dev = &ACPI_COMPANION(dev)->dev;
689 689
690 rcu_read_lock(); 690 rcu_read_lock();
@@ -1742,9 +1742,8 @@ static int domain_init(struct dmar_domain *domain, int guest_width)
1742 1742
1743static void domain_exit(struct dmar_domain *domain) 1743static void domain_exit(struct dmar_domain *domain)
1744{ 1744{
1745 struct dmar_drhd_unit *drhd;
1746 struct intel_iommu *iommu;
1747 struct page *freelist = NULL; 1745 struct page *freelist = NULL;
1746 int i;
1748 1747
1749 /* Domain 0 is reserved, so dont process it */ 1748 /* Domain 0 is reserved, so dont process it */
1750 if (!domain) 1749 if (!domain)
@@ -1764,8 +1763,8 @@ static void domain_exit(struct dmar_domain *domain)
1764 1763
1765 /* clear attached or cached domains */ 1764 /* clear attached or cached domains */
1766 rcu_read_lock(); 1765 rcu_read_lock();
1767 for_each_active_iommu(iommu, drhd) 1766 for_each_set_bit(i, domain->iommu_bmp, g_num_of_iommus)
1768 iommu_detach_domain(domain, iommu); 1767 iommu_detach_domain(domain, g_iommus[i]);
1769 rcu_read_unlock(); 1768 rcu_read_unlock();
1770 1769
1771 dma_free_pagelist(freelist); 1770 dma_free_pagelist(freelist);
diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c
index 10186cac7716..bc39bdf7b99b 100644
--- a/drivers/iommu/ipmmu-vmsa.c
+++ b/drivers/iommu/ipmmu-vmsa.c
@@ -851,6 +851,7 @@ static int ipmmu_remove(struct platform_device *pdev)
851 851
852static const struct of_device_id ipmmu_of_ids[] = { 852static const struct of_device_id ipmmu_of_ids[] = {
853 { .compatible = "renesas,ipmmu-vmsa", }, 853 { .compatible = "renesas,ipmmu-vmsa", },
854 { }
854}; 855};
855 856
856static struct platform_driver ipmmu_driver = { 857static struct platform_driver ipmmu_driver = {
diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
index 596b0a9eee99..9687f8afebff 100644
--- a/drivers/irqchip/irq-gic-v3-its.c
+++ b/drivers/irqchip/irq-gic-v3-its.c
@@ -169,7 +169,7 @@ static void its_encode_cmd(struct its_cmd_block *cmd, u8 cmd_nr)
169 169
170static void its_encode_devid(struct its_cmd_block *cmd, u32 devid) 170static void its_encode_devid(struct its_cmd_block *cmd, u32 devid)
171{ 171{
172 cmd->raw_cmd[0] &= ~(0xffffUL << 32); 172 cmd->raw_cmd[0] &= BIT_ULL(32) - 1;
173 cmd->raw_cmd[0] |= ((u64)devid) << 32; 173 cmd->raw_cmd[0] |= ((u64)devid) << 32;
174} 174}
175 175
@@ -802,6 +802,7 @@ static int its_alloc_tables(struct its_node *its)
802 int i; 802 int i;
803 int psz = SZ_64K; 803 int psz = SZ_64K;
804 u64 shr = GITS_BASER_InnerShareable; 804 u64 shr = GITS_BASER_InnerShareable;
805 u64 cache = GITS_BASER_WaWb;
805 806
806 for (i = 0; i < GITS_BASER_NR_REGS; i++) { 807 for (i = 0; i < GITS_BASER_NR_REGS; i++) {
807 u64 val = readq_relaxed(its->base + GITS_BASER + i * 8); 808 u64 val = readq_relaxed(its->base + GITS_BASER + i * 8);
@@ -848,7 +849,7 @@ retry_baser:
848 val = (virt_to_phys(base) | 849 val = (virt_to_phys(base) |
849 (type << GITS_BASER_TYPE_SHIFT) | 850 (type << GITS_BASER_TYPE_SHIFT) |
850 ((entry_size - 1) << GITS_BASER_ENTRY_SIZE_SHIFT) | 851 ((entry_size - 1) << GITS_BASER_ENTRY_SIZE_SHIFT) |
851 GITS_BASER_WaWb | 852 cache |
852 shr | 853 shr |
853 GITS_BASER_VALID); 854 GITS_BASER_VALID);
854 855
@@ -874,9 +875,12 @@ retry_baser:
874 * Shareability didn't stick. Just use 875 * Shareability didn't stick. Just use
875 * whatever the read reported, which is likely 876 * whatever the read reported, which is likely
876 * to be the only thing this redistributor 877 * to be the only thing this redistributor
877 * supports. 878 * supports. If that's zero, make it
879 * non-cacheable as well.
878 */ 880 */
879 shr = tmp & GITS_BASER_SHAREABILITY_MASK; 881 shr = tmp & GITS_BASER_SHAREABILITY_MASK;
882 if (!shr)
883 cache = GITS_BASER_nC;
880 goto retry_baser; 884 goto retry_baser;
881 } 885 }
882 886
@@ -980,16 +984,39 @@ static void its_cpu_init_lpis(void)
980 tmp = readq_relaxed(rbase + GICR_PROPBASER); 984 tmp = readq_relaxed(rbase + GICR_PROPBASER);
981 985
982 if ((tmp ^ val) & GICR_PROPBASER_SHAREABILITY_MASK) { 986 if ((tmp ^ val) & GICR_PROPBASER_SHAREABILITY_MASK) {
987 if (!(tmp & GICR_PROPBASER_SHAREABILITY_MASK)) {
988 /*
989 * The HW reports non-shareable, we must
990 * remove the cacheability attributes as
991 * well.
992 */
993 val &= ~(GICR_PROPBASER_SHAREABILITY_MASK |
994 GICR_PROPBASER_CACHEABILITY_MASK);
995 val |= GICR_PROPBASER_nC;
996 writeq_relaxed(val, rbase + GICR_PROPBASER);
997 }
983 pr_info_once("GIC: using cache flushing for LPI property table\n"); 998 pr_info_once("GIC: using cache flushing for LPI property table\n");
984 gic_rdists->flags |= RDIST_FLAGS_PROPBASE_NEEDS_FLUSHING; 999 gic_rdists->flags |= RDIST_FLAGS_PROPBASE_NEEDS_FLUSHING;
985 } 1000 }
986 1001
987 /* set PENDBASE */ 1002 /* set PENDBASE */
988 val = (page_to_phys(pend_page) | 1003 val = (page_to_phys(pend_page) |
989 GICR_PROPBASER_InnerShareable | 1004 GICR_PENDBASER_InnerShareable |
990 GICR_PROPBASER_WaWb); 1005 GICR_PENDBASER_WaWb);
991 1006
992 writeq_relaxed(val, rbase + GICR_PENDBASER); 1007 writeq_relaxed(val, rbase + GICR_PENDBASER);
1008 tmp = readq_relaxed(rbase + GICR_PENDBASER);
1009
1010 if (!(tmp & GICR_PENDBASER_SHAREABILITY_MASK)) {
1011 /*
1012 * The HW reports non-shareable, we must remove the
1013 * cacheability attributes as well.
1014 */
1015 val &= ~(GICR_PENDBASER_SHAREABILITY_MASK |
1016 GICR_PENDBASER_CACHEABILITY_MASK);
1017 val |= GICR_PENDBASER_nC;
1018 writeq_relaxed(val, rbase + GICR_PENDBASER);
1019 }
993 1020
994 /* Enable LPIs */ 1021 /* Enable LPIs */
995 val = readl_relaxed(rbase + GICR_CTLR); 1022 val = readl_relaxed(rbase + GICR_CTLR);
@@ -1026,7 +1053,7 @@ static void its_cpu_init_collection(void)
1026 * This ITS wants a linear CPU number. 1053 * This ITS wants a linear CPU number.
1027 */ 1054 */
1028 target = readq_relaxed(gic_data_rdist_rd_base() + GICR_TYPER); 1055 target = readq_relaxed(gic_data_rdist_rd_base() + GICR_TYPER);
1029 target = GICR_TYPER_CPU_NUMBER(target); 1056 target = GICR_TYPER_CPU_NUMBER(target) << 16;
1030 } 1057 }
1031 1058
1032 /* Perform collection mapping */ 1059 /* Perform collection mapping */
@@ -1422,14 +1449,26 @@ static int its_probe(struct device_node *node, struct irq_domain *parent)
1422 1449
1423 writeq_relaxed(baser, its->base + GITS_CBASER); 1450 writeq_relaxed(baser, its->base + GITS_CBASER);
1424 tmp = readq_relaxed(its->base + GITS_CBASER); 1451 tmp = readq_relaxed(its->base + GITS_CBASER);
1425 writeq_relaxed(0, its->base + GITS_CWRITER);
1426 writel_relaxed(GITS_CTLR_ENABLE, its->base + GITS_CTLR);
1427 1452
1428 if ((tmp ^ baser) & GITS_BASER_SHAREABILITY_MASK) { 1453 if ((tmp ^ baser) & GITS_CBASER_SHAREABILITY_MASK) {
1454 if (!(tmp & GITS_CBASER_SHAREABILITY_MASK)) {
1455 /*
1456 * The HW reports non-shareable, we must
1457 * remove the cacheability attributes as
1458 * well.
1459 */
1460 baser &= ~(GITS_CBASER_SHAREABILITY_MASK |
1461 GITS_CBASER_CACHEABILITY_MASK);
1462 baser |= GITS_CBASER_nC;
1463 writeq_relaxed(baser, its->base + GITS_CBASER);
1464 }
1429 pr_info("ITS: using cache flushing for cmd queue\n"); 1465 pr_info("ITS: using cache flushing for cmd queue\n");
1430 its->flags |= ITS_FLAGS_CMDQ_NEEDS_FLUSHING; 1466 its->flags |= ITS_FLAGS_CMDQ_NEEDS_FLUSHING;
1431 } 1467 }
1432 1468
1469 writeq_relaxed(0, its->base + GITS_CWRITER);
1470 writel_relaxed(GITS_CTLR_ENABLE, its->base + GITS_CTLR);
1471
1433 if (of_property_read_bool(its->msi_chip.of_node, "msi-controller")) { 1472 if (of_property_read_bool(its->msi_chip.of_node, "msi-controller")) {
1434 its->domain = irq_domain_add_tree(NULL, &its_domain_ops, its); 1473 its->domain = irq_domain_add_tree(NULL, &its_domain_ops, its);
1435 if (!its->domain) { 1474 if (!its->domain) {
diff --git a/drivers/lguest/Kconfig b/drivers/lguest/Kconfig
index ee035ec4526b..169172d2ba05 100644
--- a/drivers/lguest/Kconfig
+++ b/drivers/lguest/Kconfig
@@ -1,6 +1,6 @@
1config LGUEST 1config LGUEST
2 tristate "Linux hypervisor example code" 2 tristate "Linux hypervisor example code"
3 depends on X86_32 && EVENTFD && TTY 3 depends on X86_32 && EVENTFD && TTY && PCI_DIRECT
4 select HVC_DRIVER 4 select HVC_DRIVER
5 ---help--- 5 ---help---
6 This is a very simple module which allows you to run 6 This is a very simple module which allows you to run
diff --git a/drivers/media/dvb-frontends/rtl2832.c b/drivers/media/dvb-frontends/rtl2832.c
index 5d2d8f45b4b6..67faa8d6950e 100644
--- a/drivers/media/dvb-frontends/rtl2832.c
+++ b/drivers/media/dvb-frontends/rtl2832.c
@@ -1240,7 +1240,7 @@ static int rtl2832_probe(struct i2c_client *client,
1240 dev->regmap_config.max_register = 5 * 0x100, 1240 dev->regmap_config.max_register = 5 * 0x100,
1241 dev->regmap_config.ranges = regmap_range_cfg, 1241 dev->regmap_config.ranges = regmap_range_cfg,
1242 dev->regmap_config.num_ranges = ARRAY_SIZE(regmap_range_cfg), 1242 dev->regmap_config.num_ranges = ARRAY_SIZE(regmap_range_cfg),
1243 dev->regmap_config.cache_type = REGCACHE_RBTREE, 1243 dev->regmap_config.cache_type = REGCACHE_NONE,
1244 dev->regmap = regmap_init(&client->dev, &regmap_bus, client, 1244 dev->regmap = regmap_init(&client->dev, &regmap_bus, client,
1245 &dev->regmap_config); 1245 &dev->regmap_config);
1246 if (IS_ERR(dev->regmap)) { 1246 if (IS_ERR(dev->regmap)) {
diff --git a/drivers/media/pci/cx23885/cx23885-417.c b/drivers/media/pci/cx23885/cx23885-417.c
index e4901a503c73..63c0ee5d0bf5 100644
--- a/drivers/media/pci/cx23885/cx23885-417.c
+++ b/drivers/media/pci/cx23885/cx23885-417.c
@@ -1339,14 +1339,13 @@ static int vidioc_querycap(struct file *file, void *priv,
1339 strlcpy(cap->driver, dev->name, sizeof(cap->driver)); 1339 strlcpy(cap->driver, dev->name, sizeof(cap->driver));
1340 strlcpy(cap->card, cx23885_boards[tsport->dev->board].name, 1340 strlcpy(cap->card, cx23885_boards[tsport->dev->board].name,
1341 sizeof(cap->card)); 1341 sizeof(cap->card));
1342 sprintf(cap->bus_info, "PCI:%s", pci_name(dev->pci)); 1342 sprintf(cap->bus_info, "PCIe:%s", pci_name(dev->pci));
1343 cap->capabilities = 1343 cap->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_READWRITE |
1344 V4L2_CAP_VIDEO_CAPTURE | 1344 V4L2_CAP_STREAMING;
1345 V4L2_CAP_READWRITE |
1346 V4L2_CAP_STREAMING |
1347 0;
1348 if (dev->tuner_type != TUNER_ABSENT) 1345 if (dev->tuner_type != TUNER_ABSENT)
1349 cap->capabilities |= V4L2_CAP_TUNER; 1346 cap->device_caps |= V4L2_CAP_TUNER;
1347 cap->capabilities = cap->device_caps | V4L2_CAP_VBI_CAPTURE |
1348 V4L2_CAP_AUDIO | V4L2_CAP_DEVICE_CAPS;
1350 1349
1351 return 0; 1350 return 0;
1352} 1351}
diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c
index 12f7452edce3..a92ff4249d10 100644
--- a/drivers/media/platform/s5p-jpeg/jpeg-core.c
+++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c
@@ -1845,6 +1845,9 @@ static void exynos4_jpeg_set_img_addr(struct s5p_jpeg_ctx *ctx)
1845 struct s5p_jpeg_addr jpeg_addr; 1845 struct s5p_jpeg_addr jpeg_addr;
1846 u32 pix_size, padding_bytes = 0; 1846 u32 pix_size, padding_bytes = 0;
1847 1847
1848 jpeg_addr.cb = 0;
1849 jpeg_addr.cr = 0;
1850
1848 pix_size = ctx->cap_q.w * ctx->cap_q.h; 1851 pix_size = ctx->cap_q.w * ctx->cap_q.h;
1849 1852
1850 if (ctx->mode == S5P_JPEG_ENCODE) { 1853 if (ctx->mode == S5P_JPEG_ENCODE) {
diff --git a/drivers/media/platform/s5p-jpeg/jpeg-hw-exynos3250.c b/drivers/media/platform/s5p-jpeg/jpeg-hw-exynos3250.c
index e8c2cad93962..0974b9a7a584 100644
--- a/drivers/media/platform/s5p-jpeg/jpeg-hw-exynos3250.c
+++ b/drivers/media/platform/s5p-jpeg/jpeg-hw-exynos3250.c
@@ -20,7 +20,7 @@
20 20
21void exynos3250_jpeg_reset(void __iomem *regs) 21void exynos3250_jpeg_reset(void __iomem *regs)
22{ 22{
23 u32 reg = 0; 23 u32 reg = 1;
24 int count = 1000; 24 int count = 1000;
25 25
26 writel(1, regs + EXYNOS3250_SW_RESET); 26 writel(1, regs + EXYNOS3250_SW_RESET);
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c b/drivers/media/platform/s5p-mfc/s5p_mfc.c
index 8e44a59d8ec2..98374e8bad3e 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c
@@ -833,6 +833,7 @@ static int s5p_mfc_open(struct file *file)
833 q->type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; 833 q->type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
834 q->io_modes = VB2_MMAP; 834 q->io_modes = VB2_MMAP;
835 q->drv_priv = &ctx->fh; 835 q->drv_priv = &ctx->fh;
836 q->lock = &dev->mfc_mutex;
836 if (vdev == dev->vfd_dec) { 837 if (vdev == dev->vfd_dec) {
837 q->io_modes = VB2_MMAP; 838 q->io_modes = VB2_MMAP;
838 q->ops = get_dec_queue_ops(); 839 q->ops = get_dec_queue_ops();
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
index 15f7663dd9f5..24262bbb1a35 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h
@@ -29,7 +29,7 @@
29 29
30/* Offset base used to differentiate between CAPTURE and OUTPUT 30/* Offset base used to differentiate between CAPTURE and OUTPUT
31* while mmaping */ 31* while mmaping */
32#define DST_QUEUE_OFF_BASE (TASK_SIZE / 2) 32#define DST_QUEUE_OFF_BASE (1 << 30)
33 33
34#define MFC_BANK1_ALLOC_CTX 0 34#define MFC_BANK1_ALLOC_CTX 0
35#define MFC_BANK2_ALLOC_CTX 1 35#define MFC_BANK2_ALLOC_CTX 1
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_opr.h b/drivers/media/platform/s5p-mfc/s5p_mfc_opr.h
index de2b8c69daa5..22dfb3effda8 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_opr.h
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_opr.h
@@ -302,7 +302,7 @@ struct s5p_mfc_hw_ops {
302 void (*write_info)(struct s5p_mfc_ctx *ctx, unsigned int data, 302 void (*write_info)(struct s5p_mfc_ctx *ctx, unsigned int data,
303 unsigned int ofs); 303 unsigned int ofs);
304 unsigned int (*read_info)(struct s5p_mfc_ctx *ctx, 304 unsigned int (*read_info)(struct s5p_mfc_ctx *ctx,
305 unsigned int ofs); 305 unsigned long ofs);
306 int (*get_dspl_y_adr)(struct s5p_mfc_dev *dev); 306 int (*get_dspl_y_adr)(struct s5p_mfc_dev *dev);
307 int (*get_dec_y_adr)(struct s5p_mfc_dev *dev); 307 int (*get_dec_y_adr)(struct s5p_mfc_dev *dev);
308 int (*get_dspl_status)(struct s5p_mfc_dev *dev); 308 int (*get_dspl_status)(struct s5p_mfc_dev *dev);
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v5.c b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v5.c
index 0c4fcf2dfd09..b09bcd140491 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v5.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v5.c
@@ -263,15 +263,15 @@ static void s5p_mfc_release_dev_context_buffer_v5(struct s5p_mfc_dev *dev)
263static void s5p_mfc_write_info_v5(struct s5p_mfc_ctx *ctx, unsigned int data, 263static void s5p_mfc_write_info_v5(struct s5p_mfc_ctx *ctx, unsigned int data,
264 unsigned int ofs) 264 unsigned int ofs)
265{ 265{
266 writel(data, (volatile void __iomem *)(ctx->shm.virt + ofs)); 266 writel(data, (void *)(ctx->shm.virt + ofs));
267 wmb(); 267 wmb();
268} 268}
269 269
270static unsigned int s5p_mfc_read_info_v5(struct s5p_mfc_ctx *ctx, 270static unsigned int s5p_mfc_read_info_v5(struct s5p_mfc_ctx *ctx,
271 unsigned int ofs) 271 unsigned long ofs)
272{ 272{
273 rmb(); 273 rmb();
274 return readl((volatile void __iomem *)(ctx->shm.virt + ofs)); 274 return readl((void *)(ctx->shm.virt + ofs));
275} 275}
276 276
277static void s5p_mfc_dec_calc_dpb_size_v5(struct s5p_mfc_ctx *ctx) 277static void s5p_mfc_dec_calc_dpb_size_v5(struct s5p_mfc_ctx *ctx)
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c
index d826c58b5d53..cefad184fe96 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c
@@ -1852,17 +1852,17 @@ static void s5p_mfc_write_info_v6(struct s5p_mfc_ctx *ctx, unsigned int data,
1852 unsigned int ofs) 1852 unsigned int ofs)
1853{ 1853{
1854 s5p_mfc_clock_on(); 1854 s5p_mfc_clock_on();
1855 writel(data, (volatile void __iomem *)((unsigned long)ofs)); 1855 writel(data, (void *)((unsigned long)ofs));
1856 s5p_mfc_clock_off(); 1856 s5p_mfc_clock_off();
1857} 1857}
1858 1858
1859static unsigned int 1859static unsigned int
1860s5p_mfc_read_info_v6(struct s5p_mfc_ctx *ctx, unsigned int ofs) 1860s5p_mfc_read_info_v6(struct s5p_mfc_ctx *ctx, unsigned long ofs)
1861{ 1861{
1862 int ret; 1862 int ret;
1863 1863
1864 s5p_mfc_clock_on(); 1864 s5p_mfc_clock_on();
1865 ret = readl((volatile void __iomem *)((unsigned long)ofs)); 1865 ret = readl((void *)ofs);
1866 s5p_mfc_clock_off(); 1866 s5p_mfc_clock_off();
1867 1867
1868 return ret; 1868 return ret;
diff --git a/drivers/media/platform/s5p-tv/Kconfig b/drivers/media/platform/s5p-tv/Kconfig
index 5a1835dd65e8..697aaed42486 100644
--- a/drivers/media/platform/s5p-tv/Kconfig
+++ b/drivers/media/platform/s5p-tv/Kconfig
@@ -20,6 +20,7 @@ if VIDEO_SAMSUNG_S5P_TV
20config VIDEO_SAMSUNG_S5P_HDMI 20config VIDEO_SAMSUNG_S5P_HDMI
21 tristate "Samsung HDMI Driver" 21 tristate "Samsung HDMI Driver"
22 depends on VIDEO_V4L2 22 depends on VIDEO_V4L2
23 depends on I2C
23 depends on VIDEO_SAMSUNG_S5P_TV 24 depends on VIDEO_SAMSUNG_S5P_TV
24 select VIDEO_SAMSUNG_S5P_HDMIPHY 25 select VIDEO_SAMSUNG_S5P_HDMIPHY
25 help 26 help
diff --git a/drivers/media/platform/sh_veu.c b/drivers/media/platform/sh_veu.c
index a901b6248557..2554f3719b9e 100644
--- a/drivers/media/platform/sh_veu.c
+++ b/drivers/media/platform/sh_veu.c
@@ -1158,6 +1158,7 @@ static int sh_veu_probe(struct platform_device *pdev)
1158 } 1158 }
1159 1159
1160 *vdev = sh_veu_videodev; 1160 *vdev = sh_veu_videodev;
1161 vdev->v4l2_dev = &veu->v4l2_dev;
1161 spin_lock_init(&veu->lock); 1162 spin_lock_init(&veu->lock);
1162 mutex_init(&veu->fop_lock); 1163 mutex_init(&veu->fop_lock);
1163 vdev->lock = &veu->fop_lock; 1164 vdev->lock = &veu->fop_lock;
diff --git a/drivers/media/platform/soc_camera/atmel-isi.c b/drivers/media/platform/soc_camera/atmel-isi.c
index 8526bf5c8429..c835beb2a1a8 100644
--- a/drivers/media/platform/soc_camera/atmel-isi.c
+++ b/drivers/media/platform/soc_camera/atmel-isi.c
@@ -843,6 +843,8 @@ static int isi_camera_set_bus_param(struct soc_camera_device *icd)
843 if (isi->pdata.full_mode) 843 if (isi->pdata.full_mode)
844 cfg1 |= ISI_CFG1_FULL_MODE; 844 cfg1 |= ISI_CFG1_FULL_MODE;
845 845
846 cfg1 |= ISI_CFG1_THMASK_BEATS_16;
847
846 isi_writel(isi, ISI_CTRL, ISI_CTRL_DIS); 848 isi_writel(isi, ISI_CTRL, ISI_CTRL_DIS);
847 isi_writel(isi, ISI_CFG1, cfg1); 849 isi_writel(isi, ISI_CFG1, cfg1);
848 850
diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c
index cee7b56f8404..66634b469c98 100644
--- a/drivers/media/platform/soc_camera/soc_camera.c
+++ b/drivers/media/platform/soc_camera/soc_camera.c
@@ -1665,7 +1665,7 @@ eclkreg:
1665eaddpdev: 1665eaddpdev:
1666 platform_device_put(sasc->pdev); 1666 platform_device_put(sasc->pdev);
1667eallocpdev: 1667eallocpdev:
1668 devm_kfree(ici->v4l2_dev.dev, sasc); 1668 devm_kfree(ici->v4l2_dev.dev, info);
1669 dev_err(ici->v4l2_dev.dev, "group probe failed: %d\n", ret); 1669 dev_err(ici->v4l2_dev.dev, "group probe failed: %d\n", ret);
1670 1670
1671 return ret; 1671 return ret;
diff --git a/drivers/media/rc/ene_ir.c b/drivers/media/rc/ene_ir.c
index e80f2c6c5f1a..8d77e1c4a141 100644
--- a/drivers/media/rc/ene_ir.c
+++ b/drivers/media/rc/ene_ir.c
@@ -1195,16 +1195,6 @@ static struct pnp_driver ene_driver = {
1195 .shutdown = ene_shutdown, 1195 .shutdown = ene_shutdown,
1196}; 1196};
1197 1197
1198static int __init ene_init(void)
1199{
1200 return pnp_register_driver(&ene_driver);
1201}
1202
1203static void ene_exit(void)
1204{
1205 pnp_unregister_driver(&ene_driver);
1206}
1207
1208module_param(sample_period, int, S_IRUGO); 1198module_param(sample_period, int, S_IRUGO);
1209MODULE_PARM_DESC(sample_period, "Hardware sample period (50 us default)"); 1199MODULE_PARM_DESC(sample_period, "Hardware sample period (50 us default)");
1210 1200
@@ -1226,5 +1216,4 @@ MODULE_DESCRIPTION
1226MODULE_AUTHOR("Maxim Levitsky"); 1216MODULE_AUTHOR("Maxim Levitsky");
1227MODULE_LICENSE("GPL"); 1217MODULE_LICENSE("GPL");
1228 1218
1229module_init(ene_init); 1219module_pnp_driver(ene_driver);
1230module_exit(ene_exit);
diff --git a/drivers/media/rc/fintek-cir.c b/drivers/media/rc/fintek-cir.c
index b5167573240e..5c63c2ec6183 100644
--- a/drivers/media/rc/fintek-cir.c
+++ b/drivers/media/rc/fintek-cir.c
@@ -684,16 +684,6 @@ static struct pnp_driver fintek_driver = {
684 .shutdown = fintek_shutdown, 684 .shutdown = fintek_shutdown,
685}; 685};
686 686
687static int __init fintek_init(void)
688{
689 return pnp_register_driver(&fintek_driver);
690}
691
692static void __exit fintek_exit(void)
693{
694 pnp_unregister_driver(&fintek_driver);
695}
696
697module_param(debug, int, S_IRUGO | S_IWUSR); 687module_param(debug, int, S_IRUGO | S_IWUSR);
698MODULE_PARM_DESC(debug, "Enable debugging output"); 688MODULE_PARM_DESC(debug, "Enable debugging output");
699 689
@@ -703,5 +693,4 @@ MODULE_DESCRIPTION(FINTEK_DESCRIPTION " driver");
703MODULE_AUTHOR("Jarod Wilson <jarod@redhat.com>"); 693MODULE_AUTHOR("Jarod Wilson <jarod@redhat.com>");
704MODULE_LICENSE("GPL"); 694MODULE_LICENSE("GPL");
705 695
706module_init(fintek_init); 696module_pnp_driver(fintek_driver);
707module_exit(fintek_exit);
diff --git a/drivers/media/rc/ite-cir.c b/drivers/media/rc/ite-cir.c
index 56abf9120cc2..0f301903aa6f 100644
--- a/drivers/media/rc/ite-cir.c
+++ b/drivers/media/rc/ite-cir.c
@@ -1708,21 +1708,10 @@ static struct pnp_driver ite_driver = {
1708 .shutdown = ite_shutdown, 1708 .shutdown = ite_shutdown,
1709}; 1709};
1710 1710
1711static int __init ite_init(void)
1712{
1713 return pnp_register_driver(&ite_driver);
1714}
1715
1716static void __exit ite_exit(void)
1717{
1718 pnp_unregister_driver(&ite_driver);
1719}
1720
1721MODULE_DEVICE_TABLE(pnp, ite_ids); 1711MODULE_DEVICE_TABLE(pnp, ite_ids);
1722MODULE_DESCRIPTION("ITE Tech Inc. IT8712F/ITE8512F CIR driver"); 1712MODULE_DESCRIPTION("ITE Tech Inc. IT8712F/ITE8512F CIR driver");
1723 1713
1724MODULE_AUTHOR("Juan J. Garcia de Soria <skandalfo@gmail.com>"); 1714MODULE_AUTHOR("Juan J. Garcia de Soria <skandalfo@gmail.com>");
1725MODULE_LICENSE("GPL"); 1715MODULE_LICENSE("GPL");
1726 1716
1727module_init(ite_init); 1717module_pnp_driver(ite_driver);
1728module_exit(ite_exit);
diff --git a/drivers/media/rc/nuvoton-cir.c b/drivers/media/rc/nuvoton-cir.c
index 9c2c8635ff33..85af7a869167 100644
--- a/drivers/media/rc/nuvoton-cir.c
+++ b/drivers/media/rc/nuvoton-cir.c
@@ -1219,16 +1219,6 @@ static struct pnp_driver nvt_driver = {
1219 .shutdown = nvt_shutdown, 1219 .shutdown = nvt_shutdown,
1220}; 1220};
1221 1221
1222static int __init nvt_init(void)
1223{
1224 return pnp_register_driver(&nvt_driver);
1225}
1226
1227static void __exit nvt_exit(void)
1228{
1229 pnp_unregister_driver(&nvt_driver);
1230}
1231
1232module_param(debug, int, S_IRUGO | S_IWUSR); 1222module_param(debug, int, S_IRUGO | S_IWUSR);
1233MODULE_PARM_DESC(debug, "Enable debugging output"); 1223MODULE_PARM_DESC(debug, "Enable debugging output");
1234 1224
@@ -1238,5 +1228,4 @@ MODULE_DESCRIPTION("Nuvoton W83667HG-A & W83677HG-I CIR driver");
1238MODULE_AUTHOR("Jarod Wilson <jarod@redhat.com>"); 1228MODULE_AUTHOR("Jarod Wilson <jarod@redhat.com>");
1239MODULE_LICENSE("GPL"); 1229MODULE_LICENSE("GPL");
1240 1230
1241module_init(nvt_init); 1231module_pnp_driver(nvt_driver);
1242module_exit(nvt_exit);
diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
index 77dcfdf547ac..87fc0fe29ebd 100644
--- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
+++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
@@ -780,8 +780,6 @@ static int rtl2832u_frontend_callback(void *adapter_priv, int component,
780 case TUNER_RTL2832_TUA9001: 780 case TUNER_RTL2832_TUA9001:
781 return rtl2832u_tua9001_tuner_callback(d, cmd, arg); 781 return rtl2832u_tua9001_tuner_callback(d, cmd, arg);
782 } 782 }
783 default:
784 return -EINVAL;
785 } 783 }
786 784
787 return 0; 785 return 0;
diff --git a/drivers/media/usb/gspca/Kconfig b/drivers/media/usb/gspca/Kconfig
index 60af3b167f3b..3fd94fe7e1eb 100644
--- a/drivers/media/usb/gspca/Kconfig
+++ b/drivers/media/usb/gspca/Kconfig
@@ -1,6 +1,7 @@
1menuconfig USB_GSPCA 1menuconfig USB_GSPCA
2 tristate "GSPCA based webcams" 2 tristate "GSPCA based webcams"
3 depends on VIDEO_V4L2 3 depends on VIDEO_V4L2
4 depends on INPUT || INPUT=n
4 default m 5 default m
5 ---help--- 6 ---help---
6 Say Y here if you want to enable selecting webcams based 7 Say Y here if you want to enable selecting webcams based
diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c
index bc08a829bc13..cc16e76a2493 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -3230,18 +3230,13 @@ int vb2_thread_stop(struct vb2_queue *q)
3230 3230
3231 if (threadio == NULL) 3231 if (threadio == NULL)
3232 return 0; 3232 return 0;
3233 call_void_qop(q, wait_finish, q);
3234 threadio->stop = true; 3233 threadio->stop = true;
3235 vb2_internal_streamoff(q, q->type); 3234 /* Wake up all pending sleeps in the thread */
3236 call_void_qop(q, wait_prepare, q); 3235 vb2_queue_error(q);
3237 err = kthread_stop(threadio->thread); 3236 err = kthread_stop(threadio->thread);
3238 q->fileio = NULL; 3237 __vb2_cleanup_fileio(q);
3239 fileio->req.count = 0;
3240 vb2_reqbufs(q, &fileio->req);
3241 kfree(fileio);
3242 threadio->thread = NULL; 3238 threadio->thread = NULL;
3243 kfree(threadio); 3239 kfree(threadio);
3244 q->fileio = NULL;
3245 q->threadio = NULL; 3240 q->threadio = NULL;
3246 return err; 3241 return err;
3247} 3242}
diff --git a/drivers/media/v4l2-core/videobuf2-dma-contig.c b/drivers/media/v4l2-core/videobuf2-dma-contig.c
index b481d20c8372..69e0483adfee 100644
--- a/drivers/media/v4l2-core/videobuf2-dma-contig.c
+++ b/drivers/media/v4l2-core/videobuf2-dma-contig.c
@@ -632,8 +632,7 @@ static void *vb2_dc_get_userptr(void *alloc_ctx, unsigned long vaddr,
632 } 632 }
633 633
634 /* extract page list from userspace mapping */ 634 /* extract page list from userspace mapping */
635 ret = vb2_dc_get_user_pages(start, pages, n_pages, vma, 635 ret = vb2_dc_get_user_pages(start, pages, n_pages, vma, dma_dir);
636 dma_dir == DMA_FROM_DEVICE);
637 if (ret) { 636 if (ret) {
638 unsigned long pfn; 637 unsigned long pfn;
639 if (vb2_dc_get_user_pfn(start, n_pages, vma, &pfn) == 0) { 638 if (vb2_dc_get_user_pfn(start, n_pages, vma, &pfn) == 0) {
diff --git a/drivers/misc/enclosure.c b/drivers/misc/enclosure.c
index 38552a31304a..65fed7146e9b 100644
--- a/drivers/misc/enclosure.c
+++ b/drivers/misc/enclosure.c
@@ -202,16 +202,17 @@ static void enclosure_remove_links(struct enclosure_component *cdev)
202{ 202{
203 char name[ENCLOSURE_NAME_SIZE]; 203 char name[ENCLOSURE_NAME_SIZE];
204 204
205 enclosure_link_name(cdev, name);
206
205 /* 207 /*
206 * In odd circumstances, like multipath devices, something else may 208 * In odd circumstances, like multipath devices, something else may
207 * already have removed the links, so check for this condition first. 209 * already have removed the links, so check for this condition first.
208 */ 210 */
209 if (!cdev->dev->kobj.sd) 211 if (cdev->dev->kobj.sd)
210 return; 212 sysfs_remove_link(&cdev->dev->kobj, name);
211 213
212 enclosure_link_name(cdev, name); 214 if (cdev->cdev.kobj.sd)
213 sysfs_remove_link(&cdev->dev->kobj, name); 215 sysfs_remove_link(&cdev->cdev.kobj, "device");
214 sysfs_remove_link(&cdev->cdev.kobj, "device");
215} 216}
216 217
217static int enclosure_add_links(struct enclosure_component *cdev) 218static int enclosure_add_links(struct enclosure_component *cdev)
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index b979c265fc51..089a4028859d 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -3850,7 +3850,8 @@ static inline int bond_slave_override(struct bonding *bond,
3850 /* Find out if any slaves have the same mapping as this skb. */ 3850 /* Find out if any slaves have the same mapping as this skb. */
3851 bond_for_each_slave_rcu(bond, slave, iter) { 3851 bond_for_each_slave_rcu(bond, slave, iter) {
3852 if (slave->queue_id == skb->queue_mapping) { 3852 if (slave->queue_id == skb->queue_mapping) {
3853 if (bond_slave_can_tx(slave)) { 3853 if (bond_slave_is_up(slave) &&
3854 slave->link == BOND_LINK_UP) {
3854 bond_dev_queue_xmit(bond, skb, slave->dev); 3855 bond_dev_queue_xmit(bond, skb, slave->dev);
3855 return 0; 3856 return 0;
3856 } 3857 }
diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
index 80c46ad4cee4..ad0a7e8c2c2b 100644
--- a/drivers/net/can/flexcan.c
+++ b/drivers/net/can/flexcan.c
@@ -592,13 +592,12 @@ static int flexcan_poll_state(struct net_device *dev, u32 reg_esr)
592 rx_state = unlikely(reg_esr & FLEXCAN_ESR_RX_WRN) ? 592 rx_state = unlikely(reg_esr & FLEXCAN_ESR_RX_WRN) ?
593 CAN_STATE_ERROR_WARNING : CAN_STATE_ERROR_ACTIVE; 593 CAN_STATE_ERROR_WARNING : CAN_STATE_ERROR_ACTIVE;
594 new_state = max(tx_state, rx_state); 594 new_state = max(tx_state, rx_state);
595 } else if (unlikely(flt == FLEXCAN_ESR_FLT_CONF_PASSIVE)) { 595 } else {
596 __flexcan_get_berr_counter(dev, &bec); 596 __flexcan_get_berr_counter(dev, &bec);
597 new_state = CAN_STATE_ERROR_PASSIVE; 597 new_state = flt == FLEXCAN_ESR_FLT_CONF_PASSIVE ?
598 CAN_STATE_ERROR_PASSIVE : CAN_STATE_BUS_OFF;
598 rx_state = bec.rxerr >= bec.txerr ? new_state : 0; 599 rx_state = bec.rxerr >= bec.txerr ? new_state : 0;
599 tx_state = bec.rxerr <= bec.txerr ? new_state : 0; 600 tx_state = bec.rxerr <= bec.txerr ? new_state : 0;
600 } else {
601 new_state = CAN_STATE_BUS_OFF;
602 } 601 }
603 602
604 /* state hasn't changed */ 603 /* state hasn't changed */
@@ -1158,12 +1157,19 @@ static int flexcan_probe(struct platform_device *pdev)
1158 const struct flexcan_devtype_data *devtype_data; 1157 const struct flexcan_devtype_data *devtype_data;
1159 struct net_device *dev; 1158 struct net_device *dev;
1160 struct flexcan_priv *priv; 1159 struct flexcan_priv *priv;
1160 struct regulator *reg_xceiver;
1161 struct resource *mem; 1161 struct resource *mem;
1162 struct clk *clk_ipg = NULL, *clk_per = NULL; 1162 struct clk *clk_ipg = NULL, *clk_per = NULL;
1163 void __iomem *base; 1163 void __iomem *base;
1164 int err, irq; 1164 int err, irq;
1165 u32 clock_freq = 0; 1165 u32 clock_freq = 0;
1166 1166
1167 reg_xceiver = devm_regulator_get(&pdev->dev, "xceiver");
1168 if (PTR_ERR(reg_xceiver) == -EPROBE_DEFER)
1169 return -EPROBE_DEFER;
1170 else if (IS_ERR(reg_xceiver))
1171 reg_xceiver = NULL;
1172
1167 if (pdev->dev.of_node) 1173 if (pdev->dev.of_node)
1168 of_property_read_u32(pdev->dev.of_node, 1174 of_property_read_u32(pdev->dev.of_node,
1169 "clock-frequency", &clock_freq); 1175 "clock-frequency", &clock_freq);
@@ -1224,9 +1230,7 @@ static int flexcan_probe(struct platform_device *pdev)
1224 priv->pdata = dev_get_platdata(&pdev->dev); 1230 priv->pdata = dev_get_platdata(&pdev->dev);
1225 priv->devtype_data = devtype_data; 1231 priv->devtype_data = devtype_data;
1226 1232
1227 priv->reg_xceiver = devm_regulator_get(&pdev->dev, "xceiver"); 1233 priv->reg_xceiver = reg_xceiver;
1228 if (IS_ERR(priv->reg_xceiver))
1229 priv->reg_xceiver = NULL;
1230 1234
1231 netif_napi_add(dev, &priv->napi, flexcan_poll, FLEXCAN_NAPI_WEIGHT); 1235 netif_napi_add(dev, &priv->napi, flexcan_poll, FLEXCAN_NAPI_WEIGHT);
1232 1236
diff --git a/drivers/net/can/usb/gs_usb.c b/drivers/net/can/usb/gs_usb.c
index 009acc8641fc..8b4d3e6875eb 100644
--- a/drivers/net/can/usb/gs_usb.c
+++ b/drivers/net/can/usb/gs_usb.c
@@ -901,6 +901,8 @@ static int gs_usb_probe(struct usb_interface *intf, const struct usb_device_id *
901 } 901 }
902 902
903 dev = kzalloc(sizeof(*dev), GFP_KERNEL); 903 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
904 if (!dev)
905 return -ENOMEM;
904 init_usb_anchor(&dev->rx_submitted); 906 init_usb_anchor(&dev->rx_submitted);
905 907
906 atomic_set(&dev->active_channels, 0); 908 atomic_set(&dev->active_channels, 0);
diff --git a/drivers/net/can/usb/kvaser_usb.c b/drivers/net/can/usb/kvaser_usb.c
index e97a08ce0b90..57611fd91229 100644
--- a/drivers/net/can/usb/kvaser_usb.c
+++ b/drivers/net/can/usb/kvaser_usb.c
@@ -25,7 +25,6 @@
25#include <linux/can/dev.h> 25#include <linux/can/dev.h>
26#include <linux/can/error.h> 26#include <linux/can/error.h>
27 27
28#define MAX_TX_URBS 16
29#define MAX_RX_URBS 4 28#define MAX_RX_URBS 4
30#define START_TIMEOUT 1000 /* msecs */ 29#define START_TIMEOUT 1000 /* msecs */
31#define STOP_TIMEOUT 1000 /* msecs */ 30#define STOP_TIMEOUT 1000 /* msecs */
@@ -443,6 +442,7 @@ struct kvaser_usb_error_summary {
443 }; 442 };
444}; 443};
445 444
445/* Context for an outstanding, not yet ACKed, transmission */
446struct kvaser_usb_tx_urb_context { 446struct kvaser_usb_tx_urb_context {
447 struct kvaser_usb_net_priv *priv; 447 struct kvaser_usb_net_priv *priv;
448 u32 echo_index; 448 u32 echo_index;
@@ -456,8 +456,13 @@ struct kvaser_usb {
456 struct usb_endpoint_descriptor *bulk_in, *bulk_out; 456 struct usb_endpoint_descriptor *bulk_in, *bulk_out;
457 struct usb_anchor rx_submitted; 457 struct usb_anchor rx_submitted;
458 458
459 /* @max_tx_urbs: Firmware-reported maximum number of oustanding,
460 * not yet ACKed, transmissions on this device. This value is
461 * also used as a sentinel for marking free tx contexts.
462 */
459 u32 fw_version; 463 u32 fw_version;
460 unsigned int nchannels; 464 unsigned int nchannels;
465 unsigned int max_tx_urbs;
461 enum kvaser_usb_family family; 466 enum kvaser_usb_family family;
462 467
463 bool rxinitdone; 468 bool rxinitdone;
@@ -467,19 +472,18 @@ struct kvaser_usb {
467 472
468struct kvaser_usb_net_priv { 473struct kvaser_usb_net_priv {
469 struct can_priv can; 474 struct can_priv can;
470 475 struct can_berr_counter bec;
471 spinlock_t tx_contexts_lock;
472 int active_tx_contexts;
473 struct kvaser_usb_tx_urb_context tx_contexts[MAX_TX_URBS];
474
475 struct usb_anchor tx_submitted;
476 struct completion start_comp, stop_comp;
477 476
478 struct kvaser_usb *dev; 477 struct kvaser_usb *dev;
479 struct net_device *netdev; 478 struct net_device *netdev;
480 int channel; 479 int channel;
481 480
482 struct can_berr_counter bec; 481 struct completion start_comp, stop_comp;
482 struct usb_anchor tx_submitted;
483
484 spinlock_t tx_contexts_lock;
485 int active_tx_contexts;
486 struct kvaser_usb_tx_urb_context tx_contexts[];
483}; 487};
484 488
485static const struct usb_device_id kvaser_usb_table[] = { 489static const struct usb_device_id kvaser_usb_table[] = {
@@ -592,8 +596,8 @@ static int kvaser_usb_wait_msg(const struct kvaser_usb *dev, u8 id,
592 * for further details. 596 * for further details.
593 */ 597 */
594 if (tmp->len == 0) { 598 if (tmp->len == 0) {
595 pos = round_up(pos, 599 pos = round_up(pos, le16_to_cpu(dev->bulk_in->
596 dev->bulk_in->wMaxPacketSize); 600 wMaxPacketSize));
597 continue; 601 continue;
598 } 602 }
599 603
@@ -657,9 +661,13 @@ static int kvaser_usb_get_software_info(struct kvaser_usb *dev)
657 switch (dev->family) { 661 switch (dev->family) {
658 case KVASER_LEAF: 662 case KVASER_LEAF:
659 dev->fw_version = le32_to_cpu(msg.u.leaf.softinfo.fw_version); 663 dev->fw_version = le32_to_cpu(msg.u.leaf.softinfo.fw_version);
664 dev->max_tx_urbs =
665 le16_to_cpu(msg.u.leaf.softinfo.max_outstanding_tx);
660 break; 666 break;
661 case KVASER_USBCAN: 667 case KVASER_USBCAN:
662 dev->fw_version = le32_to_cpu(msg.u.usbcan.softinfo.fw_version); 668 dev->fw_version = le32_to_cpu(msg.u.usbcan.softinfo.fw_version);
669 dev->max_tx_urbs =
670 le16_to_cpu(msg.u.usbcan.softinfo.max_outstanding_tx);
663 break; 671 break;
664 } 672 }
665 673
@@ -715,7 +723,7 @@ static void kvaser_usb_tx_acknowledge(const struct kvaser_usb *dev,
715 723
716 stats = &priv->netdev->stats; 724 stats = &priv->netdev->stats;
717 725
718 context = &priv->tx_contexts[tid % MAX_TX_URBS]; 726 context = &priv->tx_contexts[tid % dev->max_tx_urbs];
719 727
720 /* Sometimes the state change doesn't come after a bus-off event */ 728 /* Sometimes the state change doesn't come after a bus-off event */
721 if (priv->can.restart_ms && 729 if (priv->can.restart_ms &&
@@ -744,7 +752,7 @@ static void kvaser_usb_tx_acknowledge(const struct kvaser_usb *dev,
744 spin_lock_irqsave(&priv->tx_contexts_lock, flags); 752 spin_lock_irqsave(&priv->tx_contexts_lock, flags);
745 753
746 can_get_echo_skb(priv->netdev, context->echo_index); 754 can_get_echo_skb(priv->netdev, context->echo_index);
747 context->echo_index = MAX_TX_URBS; 755 context->echo_index = dev->max_tx_urbs;
748 --priv->active_tx_contexts; 756 --priv->active_tx_contexts;
749 netif_wake_queue(priv->netdev); 757 netif_wake_queue(priv->netdev);
750 758
@@ -1329,7 +1337,8 @@ static void kvaser_usb_read_bulk_callback(struct urb *urb)
1329 * number of events in case of a heavy rx load on the bus. 1337 * number of events in case of a heavy rx load on the bus.
1330 */ 1338 */
1331 if (msg->len == 0) { 1339 if (msg->len == 0) {
1332 pos = round_up(pos, dev->bulk_in->wMaxPacketSize); 1340 pos = round_up(pos, le16_to_cpu(dev->bulk_in->
1341 wMaxPacketSize));
1333 continue; 1342 continue;
1334 } 1343 }
1335 1344
@@ -1512,11 +1521,13 @@ error:
1512 1521
1513static void kvaser_usb_reset_tx_urb_contexts(struct kvaser_usb_net_priv *priv) 1522static void kvaser_usb_reset_tx_urb_contexts(struct kvaser_usb_net_priv *priv)
1514{ 1523{
1515 int i; 1524 int i, max_tx_urbs;
1525
1526 max_tx_urbs = priv->dev->max_tx_urbs;
1516 1527
1517 priv->active_tx_contexts = 0; 1528 priv->active_tx_contexts = 0;
1518 for (i = 0; i < MAX_TX_URBS; i++) 1529 for (i = 0; i < max_tx_urbs; i++)
1519 priv->tx_contexts[i].echo_index = MAX_TX_URBS; 1530 priv->tx_contexts[i].echo_index = max_tx_urbs;
1520} 1531}
1521 1532
1522/* This method might sleep. Do not call it in the atomic context 1533/* This method might sleep. Do not call it in the atomic context
@@ -1702,14 +1713,14 @@ static netdev_tx_t kvaser_usb_start_xmit(struct sk_buff *skb,
1702 *msg_tx_can_flags |= MSG_FLAG_REMOTE_FRAME; 1713 *msg_tx_can_flags |= MSG_FLAG_REMOTE_FRAME;
1703 1714
1704 spin_lock_irqsave(&priv->tx_contexts_lock, flags); 1715 spin_lock_irqsave(&priv->tx_contexts_lock, flags);
1705 for (i = 0; i < ARRAY_SIZE(priv->tx_contexts); i++) { 1716 for (i = 0; i < dev->max_tx_urbs; i++) {
1706 if (priv->tx_contexts[i].echo_index == MAX_TX_URBS) { 1717 if (priv->tx_contexts[i].echo_index == dev->max_tx_urbs) {
1707 context = &priv->tx_contexts[i]; 1718 context = &priv->tx_contexts[i];
1708 1719
1709 context->echo_index = i; 1720 context->echo_index = i;
1710 can_put_echo_skb(skb, netdev, context->echo_index); 1721 can_put_echo_skb(skb, netdev, context->echo_index);
1711 ++priv->active_tx_contexts; 1722 ++priv->active_tx_contexts;
1712 if (priv->active_tx_contexts >= MAX_TX_URBS) 1723 if (priv->active_tx_contexts >= dev->max_tx_urbs)
1713 netif_stop_queue(netdev); 1724 netif_stop_queue(netdev);
1714 1725
1715 break; 1726 break;
@@ -1743,7 +1754,7 @@ static netdev_tx_t kvaser_usb_start_xmit(struct sk_buff *skb,
1743 spin_lock_irqsave(&priv->tx_contexts_lock, flags); 1754 spin_lock_irqsave(&priv->tx_contexts_lock, flags);
1744 1755
1745 can_free_echo_skb(netdev, context->echo_index); 1756 can_free_echo_skb(netdev, context->echo_index);
1746 context->echo_index = MAX_TX_URBS; 1757 context->echo_index = dev->max_tx_urbs;
1747 --priv->active_tx_contexts; 1758 --priv->active_tx_contexts;
1748 netif_wake_queue(netdev); 1759 netif_wake_queue(netdev);
1749 1760
@@ -1881,7 +1892,9 @@ static int kvaser_usb_init_one(struct usb_interface *intf,
1881 if (err) 1892 if (err)
1882 return err; 1893 return err;
1883 1894
1884 netdev = alloc_candev(sizeof(*priv), MAX_TX_URBS); 1895 netdev = alloc_candev(sizeof(*priv) +
1896 dev->max_tx_urbs * sizeof(*priv->tx_contexts),
1897 dev->max_tx_urbs);
1885 if (!netdev) { 1898 if (!netdev) {
1886 dev_err(&intf->dev, "Cannot alloc candev\n"); 1899 dev_err(&intf->dev, "Cannot alloc candev\n");
1887 return -ENOMEM; 1900 return -ENOMEM;
@@ -2009,6 +2022,13 @@ static int kvaser_usb_probe(struct usb_interface *intf,
2009 return err; 2022 return err;
2010 } 2023 }
2011 2024
2025 dev_dbg(&intf->dev, "Firmware version: %d.%d.%d\n",
2026 ((dev->fw_version >> 24) & 0xff),
2027 ((dev->fw_version >> 16) & 0xff),
2028 (dev->fw_version & 0xffff));
2029
2030 dev_dbg(&intf->dev, "Max oustanding tx = %d URBs\n", dev->max_tx_urbs);
2031
2012 err = kvaser_usb_get_card_info(dev); 2032 err = kvaser_usb_get_card_info(dev);
2013 if (err) { 2033 if (err) {
2014 dev_err(&intf->dev, 2034 dev_err(&intf->dev,
@@ -2016,11 +2036,6 @@ static int kvaser_usb_probe(struct usb_interface *intf,
2016 return err; 2036 return err;
2017 } 2037 }
2018 2038
2019 dev_dbg(&intf->dev, "Firmware version: %d.%d.%d\n",
2020 ((dev->fw_version >> 24) & 0xff),
2021 ((dev->fw_version >> 16) & 0xff),
2022 (dev->fw_version & 0xffff));
2023
2024 for (i = 0; i < dev->nchannels; i++) { 2039 for (i = 0; i < dev->nchannels; i++) {
2025 err = kvaser_usb_init_one(intf, id, i); 2040 err = kvaser_usb_init_one(intf, id, i);
2026 if (err) { 2041 if (err) {
diff --git a/drivers/net/can/usb/peak_usb/pcan_ucan.h b/drivers/net/can/usb/peak_usb/pcan_ucan.h
index 1ba7c25002e1..e8fc4952c6b0 100644
--- a/drivers/net/can/usb/peak_usb/pcan_ucan.h
+++ b/drivers/net/can/usb/peak_usb/pcan_ucan.h
@@ -26,8 +26,8 @@
26#define PUCAN_CMD_FILTER_STD 0x008 26#define PUCAN_CMD_FILTER_STD 0x008
27#define PUCAN_CMD_TX_ABORT 0x009 27#define PUCAN_CMD_TX_ABORT 0x009
28#define PUCAN_CMD_WR_ERR_CNT 0x00a 28#define PUCAN_CMD_WR_ERR_CNT 0x00a
29#define PUCAN_CMD_RX_FRAME_ENABLE 0x00b 29#define PUCAN_CMD_SET_EN_OPTION 0x00b
30#define PUCAN_CMD_RX_FRAME_DISABLE 0x00c 30#define PUCAN_CMD_CLR_DIS_OPTION 0x00c
31#define PUCAN_CMD_END_OF_COLLECTION 0x3ff 31#define PUCAN_CMD_END_OF_COLLECTION 0x3ff
32 32
33/* uCAN received messages list */ 33/* uCAN received messages list */
@@ -101,14 +101,15 @@ struct __packed pucan_wr_err_cnt {
101 u16 unused; 101 u16 unused;
102}; 102};
103 103
104/* uCAN RX_FRAME_ENABLE command fields */ 104/* uCAN SET_EN/CLR_DIS _OPTION command fields */
105#define PUCAN_FLTEXT_ERROR 0x0001 105#define PUCAN_OPTION_ERROR 0x0001
106#define PUCAN_FLTEXT_BUSLOAD 0x0002 106#define PUCAN_OPTION_BUSLOAD 0x0002
107#define PUCAN_OPTION_CANDFDISO 0x0004
107 108
108struct __packed pucan_filter_ext { 109struct __packed pucan_options {
109 __le16 opcode_channel; 110 __le16 opcode_channel;
110 111
111 __le16 ext_mask; 112 __le16 options;
112 u32 unused; 113 u32 unused;
113}; 114};
114 115
diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_fd.c b/drivers/net/can/usb/peak_usb/pcan_usb_fd.c
index 0bac0f14edc3..a9221ad9f1a0 100644
--- a/drivers/net/can/usb/peak_usb/pcan_usb_fd.c
+++ b/drivers/net/can/usb/peak_usb/pcan_usb_fd.c
@@ -110,13 +110,13 @@ struct __packed pcan_ufd_led {
110 u8 unused[5]; 110 u8 unused[5];
111}; 111};
112 112
113/* Extended usage of uCAN commands CMD_RX_FRAME_xxxABLE for PCAN-USB Pro FD */ 113/* Extended usage of uCAN commands CMD_xxx_xx_OPTION for PCAN-USB Pro FD */
114#define PCAN_UFD_FLTEXT_CALIBRATION 0x8000 114#define PCAN_UFD_FLTEXT_CALIBRATION 0x8000
115 115
116struct __packed pcan_ufd_filter_ext { 116struct __packed pcan_ufd_options {
117 __le16 opcode_channel; 117 __le16 opcode_channel;
118 118
119 __le16 ext_mask; 119 __le16 ucan_mask;
120 u16 unused; 120 u16 unused;
121 __le16 usb_mask; 121 __le16 usb_mask;
122}; 122};
@@ -251,6 +251,27 @@ static int pcan_usb_fd_build_restart_cmd(struct peak_usb_device *dev, u8 *buf)
251 /* moves the pointer forward */ 251 /* moves the pointer forward */
252 pc += sizeof(struct pucan_wr_err_cnt); 252 pc += sizeof(struct pucan_wr_err_cnt);
253 253
254 /* add command to switch from ISO to non-ISO mode, if fw allows it */
255 if (dev->can.ctrlmode_supported & CAN_CTRLMODE_FD_NON_ISO) {
256 struct pucan_options *puo = (struct pucan_options *)pc;
257
258 puo->opcode_channel =
259 (dev->can.ctrlmode & CAN_CTRLMODE_FD_NON_ISO) ?
260 pucan_cmd_opcode_channel(dev,
261 PUCAN_CMD_CLR_DIS_OPTION) :
262 pucan_cmd_opcode_channel(dev, PUCAN_CMD_SET_EN_OPTION);
263
264 puo->options = cpu_to_le16(PUCAN_OPTION_CANDFDISO);
265
266 /* to be sure that no other extended bits will be taken into
267 * account
268 */
269 puo->unused = 0;
270
271 /* moves the pointer forward */
272 pc += sizeof(struct pucan_options);
273 }
274
254 /* next, go back to operational mode */ 275 /* next, go back to operational mode */
255 cmd = (struct pucan_command *)pc; 276 cmd = (struct pucan_command *)pc;
256 cmd->opcode_channel = pucan_cmd_opcode_channel(dev, 277 cmd->opcode_channel = pucan_cmd_opcode_channel(dev,
@@ -321,21 +342,21 @@ static int pcan_usb_fd_set_filter_std(struct peak_usb_device *dev, int idx,
321 return pcan_usb_fd_send_cmd(dev, cmd); 342 return pcan_usb_fd_send_cmd(dev, cmd);
322} 343}
323 344
324/* set/unset notifications filter: 345/* set/unset options
325 * 346 *
326 * onoff sets(1)/unset(0) notifications 347 * onoff set(1)/unset(0) options
327 * mask each bit defines a kind of notification to set/unset 348 * mask each bit defines a kind of options to set/unset
328 */ 349 */
329static int pcan_usb_fd_set_filter_ext(struct peak_usb_device *dev, 350static int pcan_usb_fd_set_options(struct peak_usb_device *dev,
330 bool onoff, u16 ext_mask, u16 usb_mask) 351 bool onoff, u16 ucan_mask, u16 usb_mask)
331{ 352{
332 struct pcan_ufd_filter_ext *cmd = pcan_usb_fd_cmd_buffer(dev); 353 struct pcan_ufd_options *cmd = pcan_usb_fd_cmd_buffer(dev);
333 354
334 cmd->opcode_channel = pucan_cmd_opcode_channel(dev, 355 cmd->opcode_channel = pucan_cmd_opcode_channel(dev,
335 (onoff) ? PUCAN_CMD_RX_FRAME_ENABLE : 356 (onoff) ? PUCAN_CMD_SET_EN_OPTION :
336 PUCAN_CMD_RX_FRAME_DISABLE); 357 PUCAN_CMD_CLR_DIS_OPTION);
337 358
338 cmd->ext_mask = cpu_to_le16(ext_mask); 359 cmd->ucan_mask = cpu_to_le16(ucan_mask);
339 cmd->usb_mask = cpu_to_le16(usb_mask); 360 cmd->usb_mask = cpu_to_le16(usb_mask);
340 361
341 /* send the command */ 362 /* send the command */
@@ -770,9 +791,9 @@ static int pcan_usb_fd_start(struct peak_usb_device *dev)
770 &pcan_usb_pro_fd); 791 &pcan_usb_pro_fd);
771 792
772 /* enable USB calibration messages */ 793 /* enable USB calibration messages */
773 err = pcan_usb_fd_set_filter_ext(dev, 1, 794 err = pcan_usb_fd_set_options(dev, 1,
774 PUCAN_FLTEXT_ERROR, 795 PUCAN_OPTION_ERROR,
775 PCAN_UFD_FLTEXT_CALIBRATION); 796 PCAN_UFD_FLTEXT_CALIBRATION);
776 } 797 }
777 798
778 pdev->usb_if->dev_opened_count++; 799 pdev->usb_if->dev_opened_count++;
@@ -806,9 +827,9 @@ static int pcan_usb_fd_stop(struct peak_usb_device *dev)
806 827
807 /* turn off special msgs for that interface if no other dev opened */ 828 /* turn off special msgs for that interface if no other dev opened */
808 if (pdev->usb_if->dev_opened_count == 1) 829 if (pdev->usb_if->dev_opened_count == 1)
809 pcan_usb_fd_set_filter_ext(dev, 0, 830 pcan_usb_fd_set_options(dev, 0,
810 PUCAN_FLTEXT_ERROR, 831 PUCAN_OPTION_ERROR,
811 PCAN_UFD_FLTEXT_CALIBRATION); 832 PCAN_UFD_FLTEXT_CALIBRATION);
812 pdev->usb_if->dev_opened_count--; 833 pdev->usb_if->dev_opened_count--;
813 834
814 return 0; 835 return 0;
@@ -860,8 +881,14 @@ static int pcan_usb_fd_init(struct peak_usb_device *dev)
860 pdev->usb_if->fw_info.fw_version[2], 881 pdev->usb_if->fw_info.fw_version[2],
861 dev->adapter->ctrl_count); 882 dev->adapter->ctrl_count);
862 883
863 /* the currently supported hw is non-ISO */ 884 /* check for ability to switch between ISO/non-ISO modes */
864 dev->can.ctrlmode = CAN_CTRLMODE_FD_NON_ISO; 885 if (pdev->usb_if->fw_info.fw_version[0] >= 2) {
886 /* firmware >= 2.x supports ISO/non-ISO switching */
887 dev->can.ctrlmode_supported |= CAN_CTRLMODE_FD_NON_ISO;
888 } else {
889 /* firmware < 2.x only supports fixed(!) non-ISO */
890 dev->can.ctrlmode |= CAN_CTRLMODE_FD_NON_ISO;
891 }
865 892
866 /* tell the hardware the can driver is running */ 893 /* tell the hardware the can driver is running */
867 err = pcan_usb_fd_drv_loaded(dev, 1); 894 err = pcan_usb_fd_drv_loaded(dev, 1);
@@ -937,9 +964,9 @@ static void pcan_usb_fd_exit(struct peak_usb_device *dev)
937 if (dev->ctrl_idx == 0) { 964 if (dev->ctrl_idx == 0) {
938 /* turn off calibration message if any device were opened */ 965 /* turn off calibration message if any device were opened */
939 if (pdev->usb_if->dev_opened_count > 0) 966 if (pdev->usb_if->dev_opened_count > 0)
940 pcan_usb_fd_set_filter_ext(dev, 0, 967 pcan_usb_fd_set_options(dev, 0,
941 PUCAN_FLTEXT_ERROR, 968 PUCAN_OPTION_ERROR,
942 PCAN_UFD_FLTEXT_CALIBRATION); 969 PCAN_UFD_FLTEXT_CALIBRATION);
943 970
944 /* tell USB adapter that the driver is being unloaded */ 971 /* tell USB adapter that the driver is being unloaded */
945 pcan_usb_fd_drv_loaded(dev, 0); 972 pcan_usb_fd_drv_loaded(dev, 0);
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
index 756053c028be..4085c4b31047 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
@@ -1811,7 +1811,7 @@ struct bnx2x {
1811 int stats_state; 1811 int stats_state;
1812 1812
1813 /* used for synchronization of concurrent threads statistics handling */ 1813 /* used for synchronization of concurrent threads statistics handling */
1814 spinlock_t stats_lock; 1814 struct mutex stats_lock;
1815 1815
1816 /* used by dmae command loader */ 1816 /* used by dmae command loader */
1817 struct dmae_command stats_dmae; 1817 struct dmae_command stats_dmae;
@@ -1935,8 +1935,6 @@ struct bnx2x {
1935 1935
1936 int fp_array_size; 1936 int fp_array_size;
1937 u32 dump_preset_idx; 1937 u32 dump_preset_idx;
1938 bool stats_started;
1939 struct semaphore stats_sema;
1940 1938
1941 u8 phys_port_id[ETH_ALEN]; 1939 u8 phys_port_id[ETH_ALEN];
1942 1940
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index 996e215fc324..1ec635f54994 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -129,8 +129,8 @@ struct bnx2x_mac_vals {
129 u32 xmac_val; 129 u32 xmac_val;
130 u32 emac_addr; 130 u32 emac_addr;
131 u32 emac_val; 131 u32 emac_val;
132 u32 umac_addr; 132 u32 umac_addr[2];
133 u32 umac_val; 133 u32 umac_val[2];
134 u32 bmac_addr; 134 u32 bmac_addr;
135 u32 bmac_val[2]; 135 u32 bmac_val[2];
136}; 136};
@@ -7866,6 +7866,20 @@ int bnx2x_init_hw_func_cnic(struct bnx2x *bp)
7866 return 0; 7866 return 0;
7867} 7867}
7868 7868
7869/* previous driver DMAE transaction may have occurred when pre-boot stage ended
7870 * and boot began, or when kdump kernel was loaded. Either case would invalidate
7871 * the addresses of the transaction, resulting in was-error bit set in the pci
7872 * causing all hw-to-host pcie transactions to timeout. If this happened we want
7873 * to clear the interrupt which detected this from the pglueb and the was done
7874 * bit
7875 */
7876static void bnx2x_clean_pglue_errors(struct bnx2x *bp)
7877{
7878 if (!CHIP_IS_E1x(bp))
7879 REG_WR(bp, PGLUE_B_REG_WAS_ERROR_PF_7_0_CLR,
7880 1 << BP_ABS_FUNC(bp));
7881}
7882
7869static int bnx2x_init_hw_func(struct bnx2x *bp) 7883static int bnx2x_init_hw_func(struct bnx2x *bp)
7870{ 7884{
7871 int port = BP_PORT(bp); 7885 int port = BP_PORT(bp);
@@ -7958,8 +7972,7 @@ static int bnx2x_init_hw_func(struct bnx2x *bp)
7958 7972
7959 bnx2x_init_block(bp, BLOCK_PGLUE_B, init_phase); 7973 bnx2x_init_block(bp, BLOCK_PGLUE_B, init_phase);
7960 7974
7961 if (!CHIP_IS_E1x(bp)) 7975 bnx2x_clean_pglue_errors(bp);
7962 REG_WR(bp, PGLUE_B_REG_WAS_ERROR_PF_7_0_CLR, func);
7963 7976
7964 bnx2x_init_block(bp, BLOCK_ATC, init_phase); 7977 bnx2x_init_block(bp, BLOCK_ATC, init_phase);
7965 bnx2x_init_block(bp, BLOCK_DMAE, init_phase); 7978 bnx2x_init_block(bp, BLOCK_DMAE, init_phase);
@@ -10141,6 +10154,25 @@ static u32 bnx2x_get_pretend_reg(struct bnx2x *bp)
10141 return base + (BP_ABS_FUNC(bp)) * stride; 10154 return base + (BP_ABS_FUNC(bp)) * stride;
10142} 10155}
10143 10156
10157static bool bnx2x_prev_unload_close_umac(struct bnx2x *bp,
10158 u8 port, u32 reset_reg,
10159 struct bnx2x_mac_vals *vals)
10160{
10161 u32 mask = MISC_REGISTERS_RESET_REG_2_UMAC0 << port;
10162 u32 base_addr;
10163
10164 if (!(mask & reset_reg))
10165 return false;
10166
10167 BNX2X_DEV_INFO("Disable umac Rx %02x\n", port);
10168 base_addr = port ? GRCBASE_UMAC1 : GRCBASE_UMAC0;
10169 vals->umac_addr[port] = base_addr + UMAC_REG_COMMAND_CONFIG;
10170 vals->umac_val[port] = REG_RD(bp, vals->umac_addr[port]);
10171 REG_WR(bp, vals->umac_addr[port], 0);
10172
10173 return true;
10174}
10175
10144static void bnx2x_prev_unload_close_mac(struct bnx2x *bp, 10176static void bnx2x_prev_unload_close_mac(struct bnx2x *bp,
10145 struct bnx2x_mac_vals *vals) 10177 struct bnx2x_mac_vals *vals)
10146{ 10178{
@@ -10149,10 +10181,7 @@ static void bnx2x_prev_unload_close_mac(struct bnx2x *bp,
10149 u8 port = BP_PORT(bp); 10181 u8 port = BP_PORT(bp);
10150 10182
10151 /* reset addresses as they also mark which values were changed */ 10183 /* reset addresses as they also mark which values were changed */
10152 vals->bmac_addr = 0; 10184 memset(vals, 0, sizeof(*vals));
10153 vals->umac_addr = 0;
10154 vals->xmac_addr = 0;
10155 vals->emac_addr = 0;
10156 10185
10157 reset_reg = REG_RD(bp, MISC_REG_RESET_REG_2); 10186 reset_reg = REG_RD(bp, MISC_REG_RESET_REG_2);
10158 10187
@@ -10201,15 +10230,11 @@ static void bnx2x_prev_unload_close_mac(struct bnx2x *bp,
10201 REG_WR(bp, vals->xmac_addr, 0); 10230 REG_WR(bp, vals->xmac_addr, 0);
10202 mac_stopped = true; 10231 mac_stopped = true;
10203 } 10232 }
10204 mask = MISC_REGISTERS_RESET_REG_2_UMAC0 << port; 10233
10205 if (mask & reset_reg) { 10234 mac_stopped |= bnx2x_prev_unload_close_umac(bp, 0,
10206 BNX2X_DEV_INFO("Disable umac Rx\n"); 10235 reset_reg, vals);
10207 base_addr = BP_PORT(bp) ? GRCBASE_UMAC1 : GRCBASE_UMAC0; 10236 mac_stopped |= bnx2x_prev_unload_close_umac(bp, 1,
10208 vals->umac_addr = base_addr + UMAC_REG_COMMAND_CONFIG; 10237 reset_reg, vals);
10209 vals->umac_val = REG_RD(bp, vals->umac_addr);
10210 REG_WR(bp, vals->umac_addr, 0);
10211 mac_stopped = true;
10212 }
10213 } 10238 }
10214 10239
10215 if (mac_stopped) 10240 if (mac_stopped)
@@ -10505,8 +10530,11 @@ static int bnx2x_prev_unload_common(struct bnx2x *bp)
10505 /* Close the MAC Rx to prevent BRB from filling up */ 10530 /* Close the MAC Rx to prevent BRB from filling up */
10506 bnx2x_prev_unload_close_mac(bp, &mac_vals); 10531 bnx2x_prev_unload_close_mac(bp, &mac_vals);
10507 10532
10508 /* close LLH filters towards the BRB */ 10533 /* close LLH filters for both ports towards the BRB */
10509 bnx2x_set_rx_filter(&bp->link_params, 0); 10534 bnx2x_set_rx_filter(&bp->link_params, 0);
10535 bp->link_params.port ^= 1;
10536 bnx2x_set_rx_filter(&bp->link_params, 0);
10537 bp->link_params.port ^= 1;
10510 10538
10511 /* Check if the UNDI driver was previously loaded */ 10539 /* Check if the UNDI driver was previously loaded */
10512 if (bnx2x_prev_is_after_undi(bp)) { 10540 if (bnx2x_prev_is_after_undi(bp)) {
@@ -10553,8 +10581,10 @@ static int bnx2x_prev_unload_common(struct bnx2x *bp)
10553 10581
10554 if (mac_vals.xmac_addr) 10582 if (mac_vals.xmac_addr)
10555 REG_WR(bp, mac_vals.xmac_addr, mac_vals.xmac_val); 10583 REG_WR(bp, mac_vals.xmac_addr, mac_vals.xmac_val);
10556 if (mac_vals.umac_addr) 10584 if (mac_vals.umac_addr[0])
10557 REG_WR(bp, mac_vals.umac_addr, mac_vals.umac_val); 10585 REG_WR(bp, mac_vals.umac_addr[0], mac_vals.umac_val[0]);
10586 if (mac_vals.umac_addr[1])
10587 REG_WR(bp, mac_vals.umac_addr[1], mac_vals.umac_val[1]);
10558 if (mac_vals.emac_addr) 10588 if (mac_vals.emac_addr)
10559 REG_WR(bp, mac_vals.emac_addr, mac_vals.emac_val); 10589 REG_WR(bp, mac_vals.emac_addr, mac_vals.emac_val);
10560 if (mac_vals.bmac_addr) { 10590 if (mac_vals.bmac_addr) {
@@ -10571,26 +10601,6 @@ static int bnx2x_prev_unload_common(struct bnx2x *bp)
10571 return bnx2x_prev_mcp_done(bp); 10601 return bnx2x_prev_mcp_done(bp);
10572} 10602}
10573 10603
10574/* previous driver DMAE transaction may have occurred when pre-boot stage ended
10575 * and boot began, or when kdump kernel was loaded. Either case would invalidate
10576 * the addresses of the transaction, resulting in was-error bit set in the pci
10577 * causing all hw-to-host pcie transactions to timeout. If this happened we want
10578 * to clear the interrupt which detected this from the pglueb and the was done
10579 * bit
10580 */
10581static void bnx2x_prev_interrupted_dmae(struct bnx2x *bp)
10582{
10583 if (!CHIP_IS_E1x(bp)) {
10584 u32 val = REG_RD(bp, PGLUE_B_REG_PGLUE_B_INT_STS);
10585 if (val & PGLUE_B_PGLUE_B_INT_STS_REG_WAS_ERROR_ATTN) {
10586 DP(BNX2X_MSG_SP,
10587 "'was error' bit was found to be set in pglueb upon startup. Clearing\n");
10588 REG_WR(bp, PGLUE_B_REG_WAS_ERROR_PF_7_0_CLR,
10589 1 << BP_FUNC(bp));
10590 }
10591 }
10592}
10593
10594static int bnx2x_prev_unload(struct bnx2x *bp) 10604static int bnx2x_prev_unload(struct bnx2x *bp)
10595{ 10605{
10596 int time_counter = 10; 10606 int time_counter = 10;
@@ -10600,7 +10610,7 @@ static int bnx2x_prev_unload(struct bnx2x *bp)
10600 /* clear hw from errors which may have resulted from an interrupted 10610 /* clear hw from errors which may have resulted from an interrupted
10601 * dmae transaction. 10611 * dmae transaction.
10602 */ 10612 */
10603 bnx2x_prev_interrupted_dmae(bp); 10613 bnx2x_clean_pglue_errors(bp);
10604 10614
10605 /* Release previously held locks */ 10615 /* Release previously held locks */
10606 hw_lock_reg = (BP_FUNC(bp) <= 5) ? 10616 hw_lock_reg = (BP_FUNC(bp) <= 5) ?
@@ -12037,9 +12047,8 @@ static int bnx2x_init_bp(struct bnx2x *bp)
12037 mutex_init(&bp->port.phy_mutex); 12047 mutex_init(&bp->port.phy_mutex);
12038 mutex_init(&bp->fw_mb_mutex); 12048 mutex_init(&bp->fw_mb_mutex);
12039 mutex_init(&bp->drv_info_mutex); 12049 mutex_init(&bp->drv_info_mutex);
12050 mutex_init(&bp->stats_lock);
12040 bp->drv_info_mng_owner = false; 12051 bp->drv_info_mng_owner = false;
12041 spin_lock_init(&bp->stats_lock);
12042 sema_init(&bp->stats_sema, 1);
12043 12052
12044 INIT_DELAYED_WORK(&bp->sp_task, bnx2x_sp_task); 12053 INIT_DELAYED_WORK(&bp->sp_task, bnx2x_sp_task);
12045 INIT_DELAYED_WORK(&bp->sp_rtnl_task, bnx2x_sp_rtnl_task); 12054 INIT_DELAYED_WORK(&bp->sp_rtnl_task, bnx2x_sp_rtnl_task);
@@ -13668,9 +13677,9 @@ static int bnx2x_eeh_nic_unload(struct bnx2x *bp)
13668 cancel_delayed_work_sync(&bp->sp_task); 13677 cancel_delayed_work_sync(&bp->sp_task);
13669 cancel_delayed_work_sync(&bp->period_task); 13678 cancel_delayed_work_sync(&bp->period_task);
13670 13679
13671 spin_lock_bh(&bp->stats_lock); 13680 mutex_lock(&bp->stats_lock);
13672 bp->stats_state = STATS_STATE_DISABLED; 13681 bp->stats_state = STATS_STATE_DISABLED;
13673 spin_unlock_bh(&bp->stats_lock); 13682 mutex_unlock(&bp->stats_lock);
13674 13683
13675 bnx2x_save_statistics(bp); 13684 bnx2x_save_statistics(bp);
13676 13685
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
index e5aca2de1871..cfe3c7695455 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
@@ -2238,7 +2238,9 @@ int bnx2x_vf_close(struct bnx2x *bp, struct bnx2x_virtf *vf)
2238 2238
2239 cookie.vf = vf; 2239 cookie.vf = vf;
2240 cookie.state = VF_ACQUIRED; 2240 cookie.state = VF_ACQUIRED;
2241 bnx2x_stats_safe_exec(bp, bnx2x_set_vf_state, &cookie); 2241 rc = bnx2x_stats_safe_exec(bp, bnx2x_set_vf_state, &cookie);
2242 if (rc)
2243 goto op_err;
2242 } 2244 }
2243 2245
2244 DP(BNX2X_MSG_IOV, "set state to acquired\n"); 2246 DP(BNX2X_MSG_IOV, "set state to acquired\n");
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c
index d1608297c773..800ab44a07ce 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c
@@ -123,36 +123,28 @@ static void bnx2x_dp_stats(struct bnx2x *bp)
123 */ 123 */
124static void bnx2x_storm_stats_post(struct bnx2x *bp) 124static void bnx2x_storm_stats_post(struct bnx2x *bp)
125{ 125{
126 if (!bp->stats_pending) { 126 int rc;
127 int rc;
128 127
129 spin_lock_bh(&bp->stats_lock); 128 if (bp->stats_pending)
130 129 return;
131 if (bp->stats_pending) {
132 spin_unlock_bh(&bp->stats_lock);
133 return;
134 }
135
136 bp->fw_stats_req->hdr.drv_stats_counter =
137 cpu_to_le16(bp->stats_counter++);
138 130
139 DP(BNX2X_MSG_STATS, "Sending statistics ramrod %d\n", 131 bp->fw_stats_req->hdr.drv_stats_counter =
140 le16_to_cpu(bp->fw_stats_req->hdr.drv_stats_counter)); 132 cpu_to_le16(bp->stats_counter++);
141 133
142 /* adjust the ramrod to include VF queues statistics */ 134 DP(BNX2X_MSG_STATS, "Sending statistics ramrod %d\n",
143 bnx2x_iov_adjust_stats_req(bp); 135 le16_to_cpu(bp->fw_stats_req->hdr.drv_stats_counter));
144 bnx2x_dp_stats(bp);
145 136
146 /* send FW stats ramrod */ 137 /* adjust the ramrod to include VF queues statistics */
147 rc = bnx2x_sp_post(bp, RAMROD_CMD_ID_COMMON_STAT_QUERY, 0, 138 bnx2x_iov_adjust_stats_req(bp);
148 U64_HI(bp->fw_stats_req_mapping), 139 bnx2x_dp_stats(bp);
149 U64_LO(bp->fw_stats_req_mapping),
150 NONE_CONNECTION_TYPE);
151 if (rc == 0)
152 bp->stats_pending = 1;
153 140
154 spin_unlock_bh(&bp->stats_lock); 141 /* send FW stats ramrod */
155 } 142 rc = bnx2x_sp_post(bp, RAMROD_CMD_ID_COMMON_STAT_QUERY, 0,
143 U64_HI(bp->fw_stats_req_mapping),
144 U64_LO(bp->fw_stats_req_mapping),
145 NONE_CONNECTION_TYPE);
146 if (rc == 0)
147 bp->stats_pending = 1;
156} 148}
157 149
158static void bnx2x_hw_stats_post(struct bnx2x *bp) 150static void bnx2x_hw_stats_post(struct bnx2x *bp)
@@ -221,7 +213,7 @@ static void bnx2x_stats_comp(struct bnx2x *bp)
221 */ 213 */
222 214
223/* should be called under stats_sema */ 215/* should be called under stats_sema */
224static void __bnx2x_stats_pmf_update(struct bnx2x *bp) 216static void bnx2x_stats_pmf_update(struct bnx2x *bp)
225{ 217{
226 struct dmae_command *dmae; 218 struct dmae_command *dmae;
227 u32 opcode; 219 u32 opcode;
@@ -519,7 +511,7 @@ static void bnx2x_func_stats_init(struct bnx2x *bp)
519} 511}
520 512
521/* should be called under stats_sema */ 513/* should be called under stats_sema */
522static void __bnx2x_stats_start(struct bnx2x *bp) 514static void bnx2x_stats_start(struct bnx2x *bp)
523{ 515{
524 if (IS_PF(bp)) { 516 if (IS_PF(bp)) {
525 if (bp->port.pmf) 517 if (bp->port.pmf)
@@ -531,34 +523,13 @@ static void __bnx2x_stats_start(struct bnx2x *bp)
531 bnx2x_hw_stats_post(bp); 523 bnx2x_hw_stats_post(bp);
532 bnx2x_storm_stats_post(bp); 524 bnx2x_storm_stats_post(bp);
533 } 525 }
534
535 bp->stats_started = true;
536}
537
538static void bnx2x_stats_start(struct bnx2x *bp)
539{
540 if (down_timeout(&bp->stats_sema, HZ/10))
541 BNX2X_ERR("Unable to acquire stats lock\n");
542 __bnx2x_stats_start(bp);
543 up(&bp->stats_sema);
544} 526}
545 527
546static void bnx2x_stats_pmf_start(struct bnx2x *bp) 528static void bnx2x_stats_pmf_start(struct bnx2x *bp)
547{ 529{
548 if (down_timeout(&bp->stats_sema, HZ/10))
549 BNX2X_ERR("Unable to acquire stats lock\n");
550 bnx2x_stats_comp(bp); 530 bnx2x_stats_comp(bp);
551 __bnx2x_stats_pmf_update(bp); 531 bnx2x_stats_pmf_update(bp);
552 __bnx2x_stats_start(bp); 532 bnx2x_stats_start(bp);
553 up(&bp->stats_sema);
554}
555
556static void bnx2x_stats_pmf_update(struct bnx2x *bp)
557{
558 if (down_timeout(&bp->stats_sema, HZ/10))
559 BNX2X_ERR("Unable to acquire stats lock\n");
560 __bnx2x_stats_pmf_update(bp);
561 up(&bp->stats_sema);
562} 533}
563 534
564static void bnx2x_stats_restart(struct bnx2x *bp) 535static void bnx2x_stats_restart(struct bnx2x *bp)
@@ -568,11 +539,9 @@ static void bnx2x_stats_restart(struct bnx2x *bp)
568 */ 539 */
569 if (IS_VF(bp)) 540 if (IS_VF(bp))
570 return; 541 return;
571 if (down_timeout(&bp->stats_sema, HZ/10)) 542
572 BNX2X_ERR("Unable to acquire stats lock\n");
573 bnx2x_stats_comp(bp); 543 bnx2x_stats_comp(bp);
574 __bnx2x_stats_start(bp); 544 bnx2x_stats_start(bp);
575 up(&bp->stats_sema);
576} 545}
577 546
578static void bnx2x_bmac_stats_update(struct bnx2x *bp) 547static void bnx2x_bmac_stats_update(struct bnx2x *bp)
@@ -1246,18 +1215,12 @@ static void bnx2x_stats_update(struct bnx2x *bp)
1246{ 1215{
1247 u32 *stats_comp = bnx2x_sp(bp, stats_comp); 1216 u32 *stats_comp = bnx2x_sp(bp, stats_comp);
1248 1217
1249 /* we run update from timer context, so give up 1218 if (bnx2x_edebug_stats_stopped(bp))
1250 * if somebody is in the middle of transition
1251 */
1252 if (down_trylock(&bp->stats_sema))
1253 return; 1219 return;
1254 1220
1255 if (bnx2x_edebug_stats_stopped(bp) || !bp->stats_started)
1256 goto out;
1257
1258 if (IS_PF(bp)) { 1221 if (IS_PF(bp)) {
1259 if (*stats_comp != DMAE_COMP_VAL) 1222 if (*stats_comp != DMAE_COMP_VAL)
1260 goto out; 1223 return;
1261 1224
1262 if (bp->port.pmf) 1225 if (bp->port.pmf)
1263 bnx2x_hw_stats_update(bp); 1226 bnx2x_hw_stats_update(bp);
@@ -1267,7 +1230,7 @@ static void bnx2x_stats_update(struct bnx2x *bp)
1267 BNX2X_ERR("storm stats were not updated for 3 times\n"); 1230 BNX2X_ERR("storm stats were not updated for 3 times\n");
1268 bnx2x_panic(); 1231 bnx2x_panic();
1269 } 1232 }
1270 goto out; 1233 return;
1271 } 1234 }
1272 } else { 1235 } else {
1273 /* vf doesn't collect HW statistics, and doesn't get completions 1236 /* vf doesn't collect HW statistics, and doesn't get completions
@@ -1281,7 +1244,7 @@ static void bnx2x_stats_update(struct bnx2x *bp)
1281 1244
1282 /* vf is done */ 1245 /* vf is done */
1283 if (IS_VF(bp)) 1246 if (IS_VF(bp))
1284 goto out; 1247 return;
1285 1248
1286 if (netif_msg_timer(bp)) { 1249 if (netif_msg_timer(bp)) {
1287 struct bnx2x_eth_stats *estats = &bp->eth_stats; 1250 struct bnx2x_eth_stats *estats = &bp->eth_stats;
@@ -1292,9 +1255,6 @@ static void bnx2x_stats_update(struct bnx2x *bp)
1292 1255
1293 bnx2x_hw_stats_post(bp); 1256 bnx2x_hw_stats_post(bp);
1294 bnx2x_storm_stats_post(bp); 1257 bnx2x_storm_stats_post(bp);
1295
1296out:
1297 up(&bp->stats_sema);
1298} 1258}
1299 1259
1300static void bnx2x_port_stats_stop(struct bnx2x *bp) 1260static void bnx2x_port_stats_stop(struct bnx2x *bp)
@@ -1358,12 +1318,7 @@ static void bnx2x_port_stats_stop(struct bnx2x *bp)
1358 1318
1359static void bnx2x_stats_stop(struct bnx2x *bp) 1319static void bnx2x_stats_stop(struct bnx2x *bp)
1360{ 1320{
1361 int update = 0; 1321 bool update = false;
1362
1363 if (down_timeout(&bp->stats_sema, HZ/10))
1364 BNX2X_ERR("Unable to acquire stats lock\n");
1365
1366 bp->stats_started = false;
1367 1322
1368 bnx2x_stats_comp(bp); 1323 bnx2x_stats_comp(bp);
1369 1324
@@ -1381,8 +1336,6 @@ static void bnx2x_stats_stop(struct bnx2x *bp)
1381 bnx2x_hw_stats_post(bp); 1336 bnx2x_hw_stats_post(bp);
1382 bnx2x_stats_comp(bp); 1337 bnx2x_stats_comp(bp);
1383 } 1338 }
1384
1385 up(&bp->stats_sema);
1386} 1339}
1387 1340
1388static void bnx2x_stats_do_nothing(struct bnx2x *bp) 1341static void bnx2x_stats_do_nothing(struct bnx2x *bp)
@@ -1410,18 +1363,28 @@ static const struct {
1410 1363
1411void bnx2x_stats_handle(struct bnx2x *bp, enum bnx2x_stats_event event) 1364void bnx2x_stats_handle(struct bnx2x *bp, enum bnx2x_stats_event event)
1412{ 1365{
1413 enum bnx2x_stats_state state; 1366 enum bnx2x_stats_state state = bp->stats_state;
1414 void (*action)(struct bnx2x *bp); 1367
1415 if (unlikely(bp->panic)) 1368 if (unlikely(bp->panic))
1416 return; 1369 return;
1417 1370
1418 spin_lock_bh(&bp->stats_lock); 1371 /* Statistics update run from timer context, and we don't want to stop
1419 state = bp->stats_state; 1372 * that context in case someone is in the middle of a transition.
1373 * For other events, wait a bit until lock is taken.
1374 */
1375 if (!mutex_trylock(&bp->stats_lock)) {
1376 if (event == STATS_EVENT_UPDATE)
1377 return;
1378
1379 DP(BNX2X_MSG_STATS,
1380 "Unlikely stats' lock contention [event %d]\n", event);
1381 mutex_lock(&bp->stats_lock);
1382 }
1383
1384 bnx2x_stats_stm[state][event].action(bp);
1420 bp->stats_state = bnx2x_stats_stm[state][event].next_state; 1385 bp->stats_state = bnx2x_stats_stm[state][event].next_state;
1421 action = bnx2x_stats_stm[state][event].action;
1422 spin_unlock_bh(&bp->stats_lock);
1423 1386
1424 action(bp); 1387 mutex_unlock(&bp->stats_lock);
1425 1388
1426 if ((event != STATS_EVENT_UPDATE) || netif_msg_timer(bp)) 1389 if ((event != STATS_EVENT_UPDATE) || netif_msg_timer(bp))
1427 DP(BNX2X_MSG_STATS, "state %d -> event %d -> state %d\n", 1390 DP(BNX2X_MSG_STATS, "state %d -> event %d -> state %d\n",
@@ -1998,13 +1961,34 @@ void bnx2x_afex_collect_stats(struct bnx2x *bp, void *void_afex_stats,
1998 } 1961 }
1999} 1962}
2000 1963
2001void bnx2x_stats_safe_exec(struct bnx2x *bp, 1964int bnx2x_stats_safe_exec(struct bnx2x *bp,
2002 void (func_to_exec)(void *cookie), 1965 void (func_to_exec)(void *cookie),
2003 void *cookie){ 1966 void *cookie)
2004 if (down_timeout(&bp->stats_sema, HZ/10)) 1967{
2005 BNX2X_ERR("Unable to acquire stats lock\n"); 1968 int cnt = 10, rc = 0;
1969
1970 /* Wait for statistics to end [while blocking further requests],
1971 * then run supplied function 'safely'.
1972 */
1973 mutex_lock(&bp->stats_lock);
1974
2006 bnx2x_stats_comp(bp); 1975 bnx2x_stats_comp(bp);
1976 while (bp->stats_pending && cnt--)
1977 if (bnx2x_storm_stats_update(bp))
1978 usleep_range(1000, 2000);
1979 if (bp->stats_pending) {
1980 BNX2X_ERR("Failed to wait for stats pending to clear [possibly FW is stuck]\n");
1981 rc = -EBUSY;
1982 goto out;
1983 }
1984
2007 func_to_exec(cookie); 1985 func_to_exec(cookie);
2008 __bnx2x_stats_start(bp); 1986
2009 up(&bp->stats_sema); 1987out:
1988 /* No need to restart statistics - if they're enabled, the timer
1989 * will restart the statistics.
1990 */
1991 mutex_unlock(&bp->stats_lock);
1992
1993 return rc;
2010} 1994}
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.h
index 2beceaefdeea..965539a9dabe 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.h
@@ -539,9 +539,9 @@ struct bnx2x;
539void bnx2x_memset_stats(struct bnx2x *bp); 539void bnx2x_memset_stats(struct bnx2x *bp);
540void bnx2x_stats_init(struct bnx2x *bp); 540void bnx2x_stats_init(struct bnx2x *bp);
541void bnx2x_stats_handle(struct bnx2x *bp, enum bnx2x_stats_event event); 541void bnx2x_stats_handle(struct bnx2x *bp, enum bnx2x_stats_event event);
542void bnx2x_stats_safe_exec(struct bnx2x *bp, 542int bnx2x_stats_safe_exec(struct bnx2x *bp,
543 void (func_to_exec)(void *cookie), 543 void (func_to_exec)(void *cookie),
544 void *cookie); 544 void *cookie);
545 545
546/** 546/**
547 * bnx2x_save_statistics - save statistics when unloading. 547 * bnx2x_save_statistics - save statistics when unloading.
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
index 97842d03675b..c6ff4890d171 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
@@ -376,8 +376,6 @@ enum {
376enum { 376enum {
377 INGQ_EXTRAS = 2, /* firmware event queue and */ 377 INGQ_EXTRAS = 2, /* firmware event queue and */
378 /* forwarded interrupts */ 378 /* forwarded interrupts */
379 MAX_EGRQ = MAX_ETH_QSETS*2 + MAX_OFLD_QSETS*2
380 + MAX_CTRL_QUEUES + MAX_RDMA_QUEUES + MAX_ISCSI_QUEUES,
381 MAX_INGQ = MAX_ETH_QSETS + MAX_OFLD_QSETS + MAX_RDMA_QUEUES 379 MAX_INGQ = MAX_ETH_QSETS + MAX_OFLD_QSETS + MAX_RDMA_QUEUES
382 + MAX_RDMA_CIQS + MAX_ISCSI_QUEUES + INGQ_EXTRAS, 380 + MAX_RDMA_CIQS + MAX_ISCSI_QUEUES + INGQ_EXTRAS,
383}; 381};
@@ -616,11 +614,13 @@ struct sge {
616 unsigned int idma_qid[2]; /* SGE IDMA Hung Ingress Queue ID */ 614 unsigned int idma_qid[2]; /* SGE IDMA Hung Ingress Queue ID */
617 615
618 unsigned int egr_start; 616 unsigned int egr_start;
617 unsigned int egr_sz;
619 unsigned int ingr_start; 618 unsigned int ingr_start;
620 void *egr_map[MAX_EGRQ]; /* qid->queue egress queue map */ 619 unsigned int ingr_sz;
621 struct sge_rspq *ingr_map[MAX_INGQ]; /* qid->queue ingress queue map */ 620 void **egr_map; /* qid->queue egress queue map */
622 DECLARE_BITMAP(starving_fl, MAX_EGRQ); 621 struct sge_rspq **ingr_map; /* qid->queue ingress queue map */
623 DECLARE_BITMAP(txq_maperr, MAX_EGRQ); 622 unsigned long *starving_fl;
623 unsigned long *txq_maperr;
624 struct timer_list rx_timer; /* refills starving FLs */ 624 struct timer_list rx_timer; /* refills starving FLs */
625 struct timer_list tx_timer; /* checks Tx queues */ 625 struct timer_list tx_timer; /* checks Tx queues */
626}; 626};
@@ -1136,6 +1136,8 @@ int cxgb4_t4_bar2_sge_qregs(struct adapter *adapter,
1136 1136
1137unsigned int qtimer_val(const struct adapter *adap, 1137unsigned int qtimer_val(const struct adapter *adap,
1138 const struct sge_rspq *q); 1138 const struct sge_rspq *q);
1139
1140int t4_init_devlog_params(struct adapter *adapter);
1139int t4_init_sge_params(struct adapter *adapter); 1141int t4_init_sge_params(struct adapter *adapter);
1140int t4_init_tp_params(struct adapter *adap); 1142int t4_init_tp_params(struct adapter *adap);
1141int t4_filter_field_shift(const struct adapter *adap, int filter_sel); 1143int t4_filter_field_shift(const struct adapter *adap, int filter_sel);
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
index 78854ceb0870..dcb047945290 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
@@ -670,9 +670,13 @@ static int cctrl_tbl_show(struct seq_file *seq, void *v)
670 "0.9375" }; 670 "0.9375" };
671 671
672 int i; 672 int i;
673 u16 incr[NMTUS][NCCTRL_WIN]; 673 u16 (*incr)[NCCTRL_WIN];
674 struct adapter *adap = seq->private; 674 struct adapter *adap = seq->private;
675 675
676 incr = kmalloc(sizeof(*incr) * NMTUS, GFP_KERNEL);
677 if (!incr)
678 return -ENOMEM;
679
676 t4_read_cong_tbl(adap, incr); 680 t4_read_cong_tbl(adap, incr);
677 681
678 for (i = 0; i < NCCTRL_WIN; ++i) { 682 for (i = 0; i < NCCTRL_WIN; ++i) {
@@ -685,6 +689,8 @@ static int cctrl_tbl_show(struct seq_file *seq, void *v)
685 adap->params.a_wnd[i], 689 adap->params.a_wnd[i],
686 dec_fac[adap->params.b_wnd[i]]); 690 dec_fac[adap->params.b_wnd[i]]);
687 } 691 }
692
693 kfree(incr);
688 return 0; 694 return 0;
689} 695}
690 696
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index a22cf932ca35..d92995138f7e 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -920,7 +920,7 @@ static void quiesce_rx(struct adapter *adap)
920{ 920{
921 int i; 921 int i;
922 922
923 for (i = 0; i < ARRAY_SIZE(adap->sge.ingr_map); i++) { 923 for (i = 0; i < adap->sge.ingr_sz; i++) {
924 struct sge_rspq *q = adap->sge.ingr_map[i]; 924 struct sge_rspq *q = adap->sge.ingr_map[i];
925 925
926 if (q && q->handler) { 926 if (q && q->handler) {
@@ -934,6 +934,21 @@ static void quiesce_rx(struct adapter *adap)
934 } 934 }
935} 935}
936 936
937/* Disable interrupt and napi handler */
938static void disable_interrupts(struct adapter *adap)
939{
940 if (adap->flags & FULL_INIT_DONE) {
941 t4_intr_disable(adap);
942 if (adap->flags & USING_MSIX) {
943 free_msix_queue_irqs(adap);
944 free_irq(adap->msix_info[0].vec, adap);
945 } else {
946 free_irq(adap->pdev->irq, adap);
947 }
948 quiesce_rx(adap);
949 }
950}
951
937/* 952/*
938 * Enable NAPI scheduling and interrupt generation for all Rx queues. 953 * Enable NAPI scheduling and interrupt generation for all Rx queues.
939 */ 954 */
@@ -941,7 +956,7 @@ static void enable_rx(struct adapter *adap)
941{ 956{
942 int i; 957 int i;
943 958
944 for (i = 0; i < ARRAY_SIZE(adap->sge.ingr_map); i++) { 959 for (i = 0; i < adap->sge.ingr_sz; i++) {
945 struct sge_rspq *q = adap->sge.ingr_map[i]; 960 struct sge_rspq *q = adap->sge.ingr_map[i];
946 961
947 if (!q) 962 if (!q)
@@ -970,8 +985,8 @@ static int setup_sge_queues(struct adapter *adap)
970 int err, msi_idx, i, j; 985 int err, msi_idx, i, j;
971 struct sge *s = &adap->sge; 986 struct sge *s = &adap->sge;
972 987
973 bitmap_zero(s->starving_fl, MAX_EGRQ); 988 bitmap_zero(s->starving_fl, s->egr_sz);
974 bitmap_zero(s->txq_maperr, MAX_EGRQ); 989 bitmap_zero(s->txq_maperr, s->egr_sz);
975 990
976 if (adap->flags & USING_MSIX) 991 if (adap->flags & USING_MSIX)
977 msi_idx = 1; /* vector 0 is for non-queue interrupts */ 992 msi_idx = 1; /* vector 0 is for non-queue interrupts */
@@ -983,6 +998,19 @@ static int setup_sge_queues(struct adapter *adap)
983 msi_idx = -((int)s->intrq.abs_id + 1); 998 msi_idx = -((int)s->intrq.abs_id + 1);
984 } 999 }
985 1000
1001 /* NOTE: If you add/delete any Ingress/Egress Queue allocations in here,
1002 * don't forget to update the following which need to be
1003 * synchronized to and changes here.
1004 *
1005 * 1. The calculations of MAX_INGQ in cxgb4.h.
1006 *
1007 * 2. Update enable_msix/name_msix_vecs/request_msix_queue_irqs
1008 * to accommodate any new/deleted Ingress Queues
1009 * which need MSI-X Vectors.
1010 *
1011 * 3. Update sge_qinfo_show() to include information on the
1012 * new/deleted queues.
1013 */
986 err = t4_sge_alloc_rxq(adap, &s->fw_evtq, true, adap->port[0], 1014 err = t4_sge_alloc_rxq(adap, &s->fw_evtq, true, adap->port[0],
987 msi_idx, NULL, fwevtq_handler); 1015 msi_idx, NULL, fwevtq_handler);
988 if (err) { 1016 if (err) {
@@ -4244,19 +4272,12 @@ static int cxgb_up(struct adapter *adap)
4244 4272
4245static void cxgb_down(struct adapter *adapter) 4273static void cxgb_down(struct adapter *adapter)
4246{ 4274{
4247 t4_intr_disable(adapter);
4248 cancel_work_sync(&adapter->tid_release_task); 4275 cancel_work_sync(&adapter->tid_release_task);
4249 cancel_work_sync(&adapter->db_full_task); 4276 cancel_work_sync(&adapter->db_full_task);
4250 cancel_work_sync(&adapter->db_drop_task); 4277 cancel_work_sync(&adapter->db_drop_task);
4251 adapter->tid_release_task_busy = false; 4278 adapter->tid_release_task_busy = false;
4252 adapter->tid_release_head = NULL; 4279 adapter->tid_release_head = NULL;
4253 4280
4254 if (adapter->flags & USING_MSIX) {
4255 free_msix_queue_irqs(adapter);
4256 free_irq(adapter->msix_info[0].vec, adapter);
4257 } else
4258 free_irq(adapter->pdev->irq, adapter);
4259 quiesce_rx(adapter);
4260 t4_sge_stop(adapter); 4281 t4_sge_stop(adapter);
4261 t4_free_sge_resources(adapter); 4282 t4_free_sge_resources(adapter);
4262 adapter->flags &= ~FULL_INIT_DONE; 4283 adapter->flags &= ~FULL_INIT_DONE;
@@ -4733,8 +4754,9 @@ static int adap_init1(struct adapter *adap, struct fw_caps_config_cmd *c)
4733 if (ret < 0) 4754 if (ret < 0)
4734 return ret; 4755 return ret;
4735 4756
4736 ret = t4_cfg_pfvf(adap, adap->fn, adap->fn, 0, MAX_EGRQ, 64, MAX_INGQ, 4757 ret = t4_cfg_pfvf(adap, adap->fn, adap->fn, 0, adap->sge.egr_sz, 64,
4737 0, 0, 4, 0xf, 0xf, 16, FW_CMD_CAP_PF, FW_CMD_CAP_PF); 4758 MAX_INGQ, 0, 0, 4, 0xf, 0xf, 16, FW_CMD_CAP_PF,
4759 FW_CMD_CAP_PF);
4738 if (ret < 0) 4760 if (ret < 0)
4739 return ret; 4761 return ret;
4740 4762
@@ -5088,10 +5110,15 @@ static int adap_init0(struct adapter *adap)
5088 enum dev_state state; 5110 enum dev_state state;
5089 u32 params[7], val[7]; 5111 u32 params[7], val[7];
5090 struct fw_caps_config_cmd caps_cmd; 5112 struct fw_caps_config_cmd caps_cmd;
5091 struct fw_devlog_cmd devlog_cmd;
5092 u32 devlog_meminfo;
5093 int reset = 1; 5113 int reset = 1;
5094 5114
5115 /* Grab Firmware Device Log parameters as early as possible so we have
5116 * access to it for debugging, etc.
5117 */
5118 ret = t4_init_devlog_params(adap);
5119 if (ret < 0)
5120 return ret;
5121
5095 /* Contact FW, advertising Master capability */ 5122 /* Contact FW, advertising Master capability */
5096 ret = t4_fw_hello(adap, adap->mbox, adap->mbox, MASTER_MAY, &state); 5123 ret = t4_fw_hello(adap, adap->mbox, adap->mbox, MASTER_MAY, &state);
5097 if (ret < 0) { 5124 if (ret < 0) {
@@ -5169,30 +5196,6 @@ static int adap_init0(struct adapter *adap)
5169 if (ret < 0) 5196 if (ret < 0)
5170 goto bye; 5197 goto bye;
5171 5198
5172 /* Read firmware device log parameters. We really need to find a way
5173 * to get these parameters initialized with some default values (which
5174 * are likely to be correct) for the case where we either don't
5175 * attache to the firmware or it's crashed when we probe the adapter.
5176 * That way we'll still be able to perform early firmware startup
5177 * debugging ... If the request to get the Firmware's Device Log
5178 * parameters fails, we'll live so we don't make that a fatal error.
5179 */
5180 memset(&devlog_cmd, 0, sizeof(devlog_cmd));
5181 devlog_cmd.op_to_write = htonl(FW_CMD_OP_V(FW_DEVLOG_CMD) |
5182 FW_CMD_REQUEST_F | FW_CMD_READ_F);
5183 devlog_cmd.retval_len16 = htonl(FW_LEN16(devlog_cmd));
5184 ret = t4_wr_mbox(adap, adap->mbox, &devlog_cmd, sizeof(devlog_cmd),
5185 &devlog_cmd);
5186 if (ret == 0) {
5187 devlog_meminfo =
5188 ntohl(devlog_cmd.memtype_devlog_memaddr16_devlog);
5189 adap->params.devlog.memtype =
5190 FW_DEVLOG_CMD_MEMTYPE_DEVLOG_G(devlog_meminfo);
5191 adap->params.devlog.start =
5192 FW_DEVLOG_CMD_MEMADDR16_DEVLOG_G(devlog_meminfo) << 4;
5193 adap->params.devlog.size = ntohl(devlog_cmd.memsize_devlog);
5194 }
5195
5196 /* 5199 /*
5197 * Find out what ports are available to us. Note that we need to do 5200 * Find out what ports are available to us. Note that we need to do
5198 * this before calling adap_init0_no_config() since it needs nports 5201 * this before calling adap_init0_no_config() since it needs nports
@@ -5293,6 +5296,51 @@ static int adap_init0(struct adapter *adap)
5293 adap->tids.nftids = val[4] - val[3] + 1; 5296 adap->tids.nftids = val[4] - val[3] + 1;
5294 adap->sge.ingr_start = val[5]; 5297 adap->sge.ingr_start = val[5];
5295 5298
5299 /* qids (ingress/egress) returned from firmware can be anywhere
5300 * in the range from EQ(IQFLINT)_START to EQ(IQFLINT)_END.
5301 * Hence driver needs to allocate memory for this range to
5302 * store the queue info. Get the highest IQFLINT/EQ index returned
5303 * in FW_EQ_*_CMD.alloc command.
5304 */
5305 params[0] = FW_PARAM_PFVF(EQ_END);
5306 params[1] = FW_PARAM_PFVF(IQFLINT_END);
5307 ret = t4_query_params(adap, adap->mbox, adap->fn, 0, 2, params, val);
5308 if (ret < 0)
5309 goto bye;
5310 adap->sge.egr_sz = val[0] - adap->sge.egr_start + 1;
5311 adap->sge.ingr_sz = val[1] - adap->sge.ingr_start + 1;
5312
5313 adap->sge.egr_map = kcalloc(adap->sge.egr_sz,
5314 sizeof(*adap->sge.egr_map), GFP_KERNEL);
5315 if (!adap->sge.egr_map) {
5316 ret = -ENOMEM;
5317 goto bye;
5318 }
5319
5320 adap->sge.ingr_map = kcalloc(adap->sge.ingr_sz,
5321 sizeof(*adap->sge.ingr_map), GFP_KERNEL);
5322 if (!adap->sge.ingr_map) {
5323 ret = -ENOMEM;
5324 goto bye;
5325 }
5326
5327 /* Allocate the memory for the vaious egress queue bitmaps
5328 * ie starving_fl and txq_maperr.
5329 */
5330 adap->sge.starving_fl = kcalloc(BITS_TO_LONGS(adap->sge.egr_sz),
5331 sizeof(long), GFP_KERNEL);
5332 if (!adap->sge.starving_fl) {
5333 ret = -ENOMEM;
5334 goto bye;
5335 }
5336
5337 adap->sge.txq_maperr = kcalloc(BITS_TO_LONGS(adap->sge.egr_sz),
5338 sizeof(long), GFP_KERNEL);
5339 if (!adap->sge.txq_maperr) {
5340 ret = -ENOMEM;
5341 goto bye;
5342 }
5343
5296 params[0] = FW_PARAM_PFVF(CLIP_START); 5344 params[0] = FW_PARAM_PFVF(CLIP_START);
5297 params[1] = FW_PARAM_PFVF(CLIP_END); 5345 params[1] = FW_PARAM_PFVF(CLIP_END);
5298 ret = t4_query_params(adap, adap->mbox, adap->fn, 0, 2, params, val); 5346 ret = t4_query_params(adap, adap->mbox, adap->fn, 0, 2, params, val);
@@ -5501,6 +5549,10 @@ static int adap_init0(struct adapter *adap)
5501 * happened to HW/FW, stop issuing commands. 5549 * happened to HW/FW, stop issuing commands.
5502 */ 5550 */
5503bye: 5551bye:
5552 kfree(adap->sge.egr_map);
5553 kfree(adap->sge.ingr_map);
5554 kfree(adap->sge.starving_fl);
5555 kfree(adap->sge.txq_maperr);
5504 if (ret != -ETIMEDOUT && ret != -EIO) 5556 if (ret != -ETIMEDOUT && ret != -EIO)
5505 t4_fw_bye(adap, adap->mbox); 5557 t4_fw_bye(adap, adap->mbox);
5506 return ret; 5558 return ret;
@@ -5528,6 +5580,7 @@ static pci_ers_result_t eeh_err_detected(struct pci_dev *pdev,
5528 netif_carrier_off(dev); 5580 netif_carrier_off(dev);
5529 } 5581 }
5530 spin_unlock(&adap->stats_lock); 5582 spin_unlock(&adap->stats_lock);
5583 disable_interrupts(adap);
5531 if (adap->flags & FULL_INIT_DONE) 5584 if (adap->flags & FULL_INIT_DONE)
5532 cxgb_down(adap); 5585 cxgb_down(adap);
5533 rtnl_unlock(); 5586 rtnl_unlock();
@@ -5912,6 +5965,10 @@ static void free_some_resources(struct adapter *adapter)
5912 5965
5913 t4_free_mem(adapter->l2t); 5966 t4_free_mem(adapter->l2t);
5914 t4_free_mem(adapter->tids.tid_tab); 5967 t4_free_mem(adapter->tids.tid_tab);
5968 kfree(adapter->sge.egr_map);
5969 kfree(adapter->sge.ingr_map);
5970 kfree(adapter->sge.starving_fl);
5971 kfree(adapter->sge.txq_maperr);
5915 disable_msi(adapter); 5972 disable_msi(adapter);
5916 5973
5917 for_each_port(adapter, i) 5974 for_each_port(adapter, i)
@@ -6237,6 +6294,8 @@ static void remove_one(struct pci_dev *pdev)
6237 if (is_offload(adapter)) 6294 if (is_offload(adapter))
6238 detach_ulds(adapter); 6295 detach_ulds(adapter);
6239 6296
6297 disable_interrupts(adapter);
6298
6240 for_each_port(adapter, i) 6299 for_each_port(adapter, i)
6241 if (adapter->port[i]->reg_state == NETREG_REGISTERED) 6300 if (adapter->port[i]->reg_state == NETREG_REGISTERED)
6242 unregister_netdev(adapter->port[i]); 6301 unregister_netdev(adapter->port[i]);
diff --git a/drivers/net/ethernet/chelsio/cxgb4/sge.c b/drivers/net/ethernet/chelsio/cxgb4/sge.c
index b4b9f6048fe7..b688b32c21fe 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/sge.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/sge.c
@@ -2171,7 +2171,7 @@ static void sge_rx_timer_cb(unsigned long data)
2171 struct adapter *adap = (struct adapter *)data; 2171 struct adapter *adap = (struct adapter *)data;
2172 struct sge *s = &adap->sge; 2172 struct sge *s = &adap->sge;
2173 2173
2174 for (i = 0; i < ARRAY_SIZE(s->starving_fl); i++) 2174 for (i = 0; i < BITS_TO_LONGS(s->egr_sz); i++)
2175 for (m = s->starving_fl[i]; m; m &= m - 1) { 2175 for (m = s->starving_fl[i]; m; m &= m - 1) {
2176 struct sge_eth_rxq *rxq; 2176 struct sge_eth_rxq *rxq;
2177 unsigned int id = __ffs(m) + i * BITS_PER_LONG; 2177 unsigned int id = __ffs(m) + i * BITS_PER_LONG;
@@ -2259,7 +2259,7 @@ static void sge_tx_timer_cb(unsigned long data)
2259 struct adapter *adap = (struct adapter *)data; 2259 struct adapter *adap = (struct adapter *)data;
2260 struct sge *s = &adap->sge; 2260 struct sge *s = &adap->sge;
2261 2261
2262 for (i = 0; i < ARRAY_SIZE(s->txq_maperr); i++) 2262 for (i = 0; i < BITS_TO_LONGS(s->egr_sz); i++)
2263 for (m = s->txq_maperr[i]; m; m &= m - 1) { 2263 for (m = s->txq_maperr[i]; m; m &= m - 1) {
2264 unsigned long id = __ffs(m) + i * BITS_PER_LONG; 2264 unsigned long id = __ffs(m) + i * BITS_PER_LONG;
2265 struct sge_ofld_txq *txq = s->egr_map[id]; 2265 struct sge_ofld_txq *txq = s->egr_map[id];
@@ -2741,7 +2741,8 @@ void t4_free_sge_resources(struct adapter *adap)
2741 free_rspq_fl(adap, &adap->sge.intrq, NULL); 2741 free_rspq_fl(adap, &adap->sge.intrq, NULL);
2742 2742
2743 /* clear the reverse egress queue map */ 2743 /* clear the reverse egress queue map */
2744 memset(adap->sge.egr_map, 0, sizeof(adap->sge.egr_map)); 2744 memset(adap->sge.egr_map, 0,
2745 adap->sge.egr_sz * sizeof(*adap->sge.egr_map));
2745} 2746}
2746 2747
2747void t4_sge_start(struct adapter *adap) 2748void t4_sge_start(struct adapter *adap)
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
index 1abdfa123c6c..ee394dc68303 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
@@ -4459,6 +4459,59 @@ int cxgb4_t4_bar2_sge_qregs(struct adapter *adapter,
4459} 4459}
4460 4460
4461/** 4461/**
4462 * t4_init_devlog_params - initialize adapter->params.devlog
4463 * @adap: the adapter
4464 *
4465 * Initialize various fields of the adapter's Firmware Device Log
4466 * Parameters structure.
4467 */
4468int t4_init_devlog_params(struct adapter *adap)
4469{
4470 struct devlog_params *dparams = &adap->params.devlog;
4471 u32 pf_dparams;
4472 unsigned int devlog_meminfo;
4473 struct fw_devlog_cmd devlog_cmd;
4474 int ret;
4475
4476 /* If we're dealing with newer firmware, the Device Log Paramerters
4477 * are stored in a designated register which allows us to access the
4478 * Device Log even if we can't talk to the firmware.
4479 */
4480 pf_dparams =
4481 t4_read_reg(adap, PCIE_FW_REG(PCIE_FW_PF_A, PCIE_FW_PF_DEVLOG));
4482 if (pf_dparams) {
4483 unsigned int nentries, nentries128;
4484
4485 dparams->memtype = PCIE_FW_PF_DEVLOG_MEMTYPE_G(pf_dparams);
4486 dparams->start = PCIE_FW_PF_DEVLOG_ADDR16_G(pf_dparams) << 4;
4487
4488 nentries128 = PCIE_FW_PF_DEVLOG_NENTRIES128_G(pf_dparams);
4489 nentries = (nentries128 + 1) * 128;
4490 dparams->size = nentries * sizeof(struct fw_devlog_e);
4491
4492 return 0;
4493 }
4494
4495 /* Otherwise, ask the firmware for it's Device Log Parameters.
4496 */
4497 memset(&devlog_cmd, 0, sizeof(devlog_cmd));
4498 devlog_cmd.op_to_write = htonl(FW_CMD_OP_V(FW_DEVLOG_CMD) |
4499 FW_CMD_REQUEST_F | FW_CMD_READ_F);
4500 devlog_cmd.retval_len16 = htonl(FW_LEN16(devlog_cmd));
4501 ret = t4_wr_mbox(adap, adap->mbox, &devlog_cmd, sizeof(devlog_cmd),
4502 &devlog_cmd);
4503 if (ret)
4504 return ret;
4505
4506 devlog_meminfo = ntohl(devlog_cmd.memtype_devlog_memaddr16_devlog);
4507 dparams->memtype = FW_DEVLOG_CMD_MEMTYPE_DEVLOG_G(devlog_meminfo);
4508 dparams->start = FW_DEVLOG_CMD_MEMADDR16_DEVLOG_G(devlog_meminfo) << 4;
4509 dparams->size = ntohl(devlog_cmd.memsize_devlog);
4510
4511 return 0;
4512}
4513
4514/**
4462 * t4_init_sge_params - initialize adap->params.sge 4515 * t4_init_sge_params - initialize adap->params.sge
4463 * @adapter: the adapter 4516 * @adapter: the adapter
4464 * 4517 *
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_regs.h b/drivers/net/ethernet/chelsio/cxgb4/t4_regs.h
index 231a725f6d5d..326674b19983 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4_regs.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4_regs.h
@@ -63,6 +63,8 @@
63#define MC_BIST_STATUS_REG(reg_addr, idx) ((reg_addr) + (idx) * 4) 63#define MC_BIST_STATUS_REG(reg_addr, idx) ((reg_addr) + (idx) * 4)
64#define EDC_BIST_STATUS_REG(reg_addr, idx) ((reg_addr) + (idx) * 4) 64#define EDC_BIST_STATUS_REG(reg_addr, idx) ((reg_addr) + (idx) * 4)
65 65
66#define PCIE_FW_REG(reg_addr, idx) ((reg_addr) + (idx) * 4)
67
66#define SGE_PF_KDOORBELL_A 0x0 68#define SGE_PF_KDOORBELL_A 0x0
67 69
68#define QID_S 15 70#define QID_S 15
@@ -707,6 +709,7 @@
707#define PFNUM_V(x) ((x) << PFNUM_S) 709#define PFNUM_V(x) ((x) << PFNUM_S)
708 710
709#define PCIE_FW_A 0x30b8 711#define PCIE_FW_A 0x30b8
712#define PCIE_FW_PF_A 0x30bc
710 713
711#define PCIE_CORE_UTL_SYSTEM_BUS_AGENT_STATUS_A 0x5908 714#define PCIE_CORE_UTL_SYSTEM_BUS_AGENT_STATUS_A 0x5908
712 715
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h b/drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h
index 9b353a88cbda..a4a19e0ec7f5 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h
@@ -101,7 +101,7 @@ enum fw_wr_opcodes {
101 FW_RI_BIND_MW_WR = 0x18, 101 FW_RI_BIND_MW_WR = 0x18,
102 FW_RI_FR_NSMR_WR = 0x19, 102 FW_RI_FR_NSMR_WR = 0x19,
103 FW_RI_INV_LSTAG_WR = 0x1a, 103 FW_RI_INV_LSTAG_WR = 0x1a,
104 FW_LASTC2E_WR = 0x40 104 FW_LASTC2E_WR = 0x70
105}; 105};
106 106
107struct fw_wr_hdr { 107struct fw_wr_hdr {
@@ -993,6 +993,7 @@ enum fw_memtype_cf {
993 FW_MEMTYPE_CF_EXTMEM = 0x2, 993 FW_MEMTYPE_CF_EXTMEM = 0x2,
994 FW_MEMTYPE_CF_FLASH = 0x4, 994 FW_MEMTYPE_CF_FLASH = 0x4,
995 FW_MEMTYPE_CF_INTERNAL = 0x5, 995 FW_MEMTYPE_CF_INTERNAL = 0x5,
996 FW_MEMTYPE_CF_EXTMEM1 = 0x6,
996}; 997};
997 998
998struct fw_caps_config_cmd { 999struct fw_caps_config_cmd {
@@ -1035,6 +1036,7 @@ enum fw_params_mnem {
1035 FW_PARAMS_MNEM_PFVF = 2, /* function params */ 1036 FW_PARAMS_MNEM_PFVF = 2, /* function params */
1036 FW_PARAMS_MNEM_REG = 3, /* limited register access */ 1037 FW_PARAMS_MNEM_REG = 3, /* limited register access */
1037 FW_PARAMS_MNEM_DMAQ = 4, /* dma queue params */ 1038 FW_PARAMS_MNEM_DMAQ = 4, /* dma queue params */
1039 FW_PARAMS_MNEM_CHNET = 5, /* chnet params */
1038 FW_PARAMS_MNEM_LAST 1040 FW_PARAMS_MNEM_LAST
1039}; 1041};
1040 1042
@@ -3102,7 +3104,8 @@ enum fw_devlog_facility {
3102 FW_DEVLOG_FACILITY_FCOE = 0x2E, 3104 FW_DEVLOG_FACILITY_FCOE = 0x2E,
3103 FW_DEVLOG_FACILITY_FOISCSI = 0x30, 3105 FW_DEVLOG_FACILITY_FOISCSI = 0x30,
3104 FW_DEVLOG_FACILITY_FOFCOE = 0x32, 3106 FW_DEVLOG_FACILITY_FOFCOE = 0x32,
3105 FW_DEVLOG_FACILITY_MAX = 0x32, 3107 FW_DEVLOG_FACILITY_CHNET = 0x34,
3108 FW_DEVLOG_FACILITY_MAX = 0x34,
3106}; 3109};
3107 3110
3108/* log message format */ 3111/* log message format */
@@ -3139,4 +3142,36 @@ struct fw_devlog_cmd {
3139 (((x) >> FW_DEVLOG_CMD_MEMADDR16_DEVLOG_S) & \ 3142 (((x) >> FW_DEVLOG_CMD_MEMADDR16_DEVLOG_S) & \
3140 FW_DEVLOG_CMD_MEMADDR16_DEVLOG_M) 3143 FW_DEVLOG_CMD_MEMADDR16_DEVLOG_M)
3141 3144
3145/* P C I E F W P F 7 R E G I S T E R */
3146
3147/* PF7 stores the Firmware Device Log parameters which allows Host Drivers to
3148 * access the "devlog" which needing to contact firmware. The encoding is
3149 * mostly the same as that returned by the DEVLOG command except for the size
3150 * which is encoded as the number of entries in multiples-1 of 128 here rather
3151 * than the memory size as is done in the DEVLOG command. Thus, 0 means 128
3152 * and 15 means 2048. This of course in turn constrains the allowed values
3153 * for the devlog size ...
3154 */
3155#define PCIE_FW_PF_DEVLOG 7
3156
3157#define PCIE_FW_PF_DEVLOG_NENTRIES128_S 28
3158#define PCIE_FW_PF_DEVLOG_NENTRIES128_M 0xf
3159#define PCIE_FW_PF_DEVLOG_NENTRIES128_V(x) \
3160 ((x) << PCIE_FW_PF_DEVLOG_NENTRIES128_S)
3161#define PCIE_FW_PF_DEVLOG_NENTRIES128_G(x) \
3162 (((x) >> PCIE_FW_PF_DEVLOG_NENTRIES128_S) & \
3163 PCIE_FW_PF_DEVLOG_NENTRIES128_M)
3164
3165#define PCIE_FW_PF_DEVLOG_ADDR16_S 4
3166#define PCIE_FW_PF_DEVLOG_ADDR16_M 0xffffff
3167#define PCIE_FW_PF_DEVLOG_ADDR16_V(x) ((x) << PCIE_FW_PF_DEVLOG_ADDR16_S)
3168#define PCIE_FW_PF_DEVLOG_ADDR16_G(x) \
3169 (((x) >> PCIE_FW_PF_DEVLOG_ADDR16_S) & PCIE_FW_PF_DEVLOG_ADDR16_M)
3170
3171#define PCIE_FW_PF_DEVLOG_MEMTYPE_S 0
3172#define PCIE_FW_PF_DEVLOG_MEMTYPE_M 0xf
3173#define PCIE_FW_PF_DEVLOG_MEMTYPE_V(x) ((x) << PCIE_FW_PF_DEVLOG_MEMTYPE_S)
3174#define PCIE_FW_PF_DEVLOG_MEMTYPE_G(x) \
3175 (((x) >> PCIE_FW_PF_DEVLOG_MEMTYPE_S) & PCIE_FW_PF_DEVLOG_MEMTYPE_M)
3176
3142#endif /* _T4FW_INTERFACE_H_ */ 3177#endif /* _T4FW_INTERFACE_H_ */
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4fw_version.h b/drivers/net/ethernet/chelsio/cxgb4/t4fw_version.h
index e2bd3f747858..b9d1cbac0eee 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4fw_version.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4fw_version.h
@@ -36,13 +36,13 @@
36#define __T4FW_VERSION_H__ 36#define __T4FW_VERSION_H__
37 37
38#define T4FW_VERSION_MAJOR 0x01 38#define T4FW_VERSION_MAJOR 0x01
39#define T4FW_VERSION_MINOR 0x0C 39#define T4FW_VERSION_MINOR 0x0D
40#define T4FW_VERSION_MICRO 0x19 40#define T4FW_VERSION_MICRO 0x20
41#define T4FW_VERSION_BUILD 0x00 41#define T4FW_VERSION_BUILD 0x00
42 42
43#define T5FW_VERSION_MAJOR 0x01 43#define T5FW_VERSION_MAJOR 0x01
44#define T5FW_VERSION_MINOR 0x0C 44#define T5FW_VERSION_MINOR 0x0D
45#define T5FW_VERSION_MICRO 0x19 45#define T5FW_VERSION_MICRO 0x20
46#define T5FW_VERSION_BUILD 0x00 46#define T5FW_VERSION_BUILD 0x00
47 47
48#endif 48#endif
diff --git a/drivers/net/ethernet/chelsio/cxgb4vf/sge.c b/drivers/net/ethernet/chelsio/cxgb4vf/sge.c
index 0545f0de1c52..e0d711071afb 100644
--- a/drivers/net/ethernet/chelsio/cxgb4vf/sge.c
+++ b/drivers/net/ethernet/chelsio/cxgb4vf/sge.c
@@ -1004,7 +1004,7 @@ static inline void ring_tx_db(struct adapter *adapter, struct sge_txq *tq,
1004 ? (tq->pidx - 1) 1004 ? (tq->pidx - 1)
1005 : (tq->size - 1)); 1005 : (tq->size - 1));
1006 __be64 *src = (__be64 *)&tq->desc[index]; 1006 __be64 *src = (__be64 *)&tq->desc[index];
1007 __be64 __iomem *dst = (__be64 *)(tq->bar2_addr + 1007 __be64 __iomem *dst = (__be64 __iomem *)(tq->bar2_addr +
1008 SGE_UDB_WCDOORBELL); 1008 SGE_UDB_WCDOORBELL);
1009 unsigned int count = EQ_UNIT / sizeof(__be64); 1009 unsigned int count = EQ_UNIT / sizeof(__be64);
1010 1010
@@ -1018,7 +1018,11 @@ static inline void ring_tx_db(struct adapter *adapter, struct sge_txq *tq,
1018 * DMA. 1018 * DMA.
1019 */ 1019 */
1020 while (count) { 1020 while (count) {
1021 writeq(*src, dst); 1021 /* the (__force u64) is because the compiler
1022 * doesn't understand the endian swizzling
1023 * going on
1024 */
1025 writeq((__force u64)*src, dst);
1022 src++; 1026 src++;
1023 dst++; 1027 dst++;
1024 count--; 1028 count--;
@@ -1252,8 +1256,8 @@ int t4vf_eth_xmit(struct sk_buff *skb, struct net_device *dev)
1252 BUG_ON(DIV_ROUND_UP(ETHTXQ_MAX_HDR, TXD_PER_EQ_UNIT) > 1); 1256 BUG_ON(DIV_ROUND_UP(ETHTXQ_MAX_HDR, TXD_PER_EQ_UNIT) > 1);
1253 wr = (void *)&txq->q.desc[txq->q.pidx]; 1257 wr = (void *)&txq->q.desc[txq->q.pidx];
1254 wr->equiq_to_len16 = cpu_to_be32(wr_mid); 1258 wr->equiq_to_len16 = cpu_to_be32(wr_mid);
1255 wr->r3[0] = cpu_to_be64(0); 1259 wr->r3[0] = cpu_to_be32(0);
1256 wr->r3[1] = cpu_to_be64(0); 1260 wr->r3[1] = cpu_to_be32(0);
1257 skb_copy_from_linear_data(skb, (void *)wr->ethmacdst, fw_hdr_copy_len); 1261 skb_copy_from_linear_data(skb, (void *)wr->ethmacdst, fw_hdr_copy_len);
1258 end = (u64 *)wr + flits; 1262 end = (u64 *)wr + flits;
1259 1263
diff --git a/drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c b/drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c
index 1b5506df35b1..280b4a215849 100644
--- a/drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c
+++ b/drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c
@@ -210,10 +210,10 @@ int t4vf_wr_mbox_core(struct adapter *adapter, const void *cmd, int size,
210 210
211 if (rpl) { 211 if (rpl) {
212 /* request bit in high-order BE word */ 212 /* request bit in high-order BE word */
213 WARN_ON((be32_to_cpu(*(const u32 *)cmd) 213 WARN_ON((be32_to_cpu(*(const __be32 *)cmd)
214 & FW_CMD_REQUEST_F) == 0); 214 & FW_CMD_REQUEST_F) == 0);
215 get_mbox_rpl(adapter, rpl, size, mbox_data); 215 get_mbox_rpl(adapter, rpl, size, mbox_data);
216 WARN_ON((be32_to_cpu(*(u32 *)rpl) 216 WARN_ON((be32_to_cpu(*(__be32 *)rpl)
217 & FW_CMD_REQUEST_F) != 0); 217 & FW_CMD_REQUEST_F) != 0);
218 } 218 }
219 t4_write_reg(adapter, mbox_ctl, 219 t4_write_reg(adapter, mbox_ctl,
@@ -484,7 +484,7 @@ int t4_bar2_sge_qregs(struct adapter *adapter,
484 * o The BAR2 Queue ID. 484 * o The BAR2 Queue ID.
485 * o The BAR2 Queue ID Offset into the BAR2 page. 485 * o The BAR2 Queue ID Offset into the BAR2 page.
486 */ 486 */
487 bar2_page_offset = ((qid >> qpp_shift) << page_shift); 487 bar2_page_offset = ((u64)(qid >> qpp_shift) << page_shift);
488 bar2_qid = qid & qpp_mask; 488 bar2_qid = qid & qpp_mask;
489 bar2_qid_offset = bar2_qid * SGE_UDB_SIZE; 489 bar2_qid_offset = bar2_qid * SGE_UDB_SIZE;
490 490
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index 78e1ce09b1ab..f6a3a7abd468 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -1954,6 +1954,7 @@ static int fec_enet_mii_init(struct platform_device *pdev)
1954 struct fec_enet_private *fep = netdev_priv(ndev); 1954 struct fec_enet_private *fep = netdev_priv(ndev);
1955 struct device_node *node; 1955 struct device_node *node;
1956 int err = -ENXIO, i; 1956 int err = -ENXIO, i;
1957 u32 mii_speed, holdtime;
1957 1958
1958 /* 1959 /*
1959 * The i.MX28 dual fec interfaces are not equal. 1960 * The i.MX28 dual fec interfaces are not equal.
@@ -1991,10 +1992,33 @@ static int fec_enet_mii_init(struct platform_device *pdev)
1991 * Reference Manual has an error on this, and gets fixed on i.MX6Q 1992 * Reference Manual has an error on this, and gets fixed on i.MX6Q
1992 * document. 1993 * document.
1993 */ 1994 */
1994 fep->phy_speed = DIV_ROUND_UP(clk_get_rate(fep->clk_ipg), 5000000); 1995 mii_speed = DIV_ROUND_UP(clk_get_rate(fep->clk_ipg), 5000000);
1995 if (fep->quirks & FEC_QUIRK_ENET_MAC) 1996 if (fep->quirks & FEC_QUIRK_ENET_MAC)
1996 fep->phy_speed--; 1997 mii_speed--;
1997 fep->phy_speed <<= 1; 1998 if (mii_speed > 63) {
1999 dev_err(&pdev->dev,
2000 "fec clock (%lu) to fast to get right mii speed\n",
2001 clk_get_rate(fep->clk_ipg));
2002 err = -EINVAL;
2003 goto err_out;
2004 }
2005
2006 /*
2007 * The i.MX28 and i.MX6 types have another filed in the MSCR (aka
2008 * MII_SPEED) register that defines the MDIO output hold time. Earlier
2009 * versions are RAZ there, so just ignore the difference and write the
2010 * register always.
2011 * The minimal hold time according to IEE802.3 (clause 22) is 10 ns.
2012 * HOLDTIME + 1 is the number of clk cycles the fec is holding the
2013 * output.
2014 * The HOLDTIME bitfield takes values between 0 and 7 (inclusive).
2015 * Given that ceil(clkrate / 5000000) <= 64, the calculation for
2016 * holdtime cannot result in a value greater than 3.
2017 */
2018 holdtime = DIV_ROUND_UP(clk_get_rate(fep->clk_ipg), 100000000) - 1;
2019
2020 fep->phy_speed = mii_speed << 1 | holdtime << 8;
2021
1998 writel(fep->phy_speed, fep->hwp + FEC_MII_SPEED); 2022 writel(fep->phy_speed, fep->hwp + FEC_MII_SPEED);
1999 2023
2000 fep->mii_bus = mdiobus_alloc(); 2024 fep->mii_bus = mdiobus_alloc();
diff --git a/drivers/net/ethernet/freescale/ucc_geth.c b/drivers/net/ethernet/freescale/ucc_geth.c
index 357e8b576905..56b774d3a13d 100644
--- a/drivers/net/ethernet/freescale/ucc_geth.c
+++ b/drivers/net/ethernet/freescale/ucc_geth.c
@@ -3893,6 +3893,9 @@ static int ucc_geth_probe(struct platform_device* ofdev)
3893 ugeth->phy_interface = phy_interface; 3893 ugeth->phy_interface = phy_interface;
3894 ugeth->max_speed = max_speed; 3894 ugeth->max_speed = max_speed;
3895 3895
3896 /* Carrier starts down, phylib will bring it up */
3897 netif_carrier_off(dev);
3898
3896 err = register_netdev(dev); 3899 err = register_netdev(dev);
3897 if (err) { 3900 if (err) {
3898 if (netif_msg_probe(ugeth)) 3901 if (netif_msg_probe(ugeth))
diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
index 96208f17bb53..2db653225a0e 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -2658,16 +2658,11 @@ static int mvneta_stop(struct net_device *dev)
2658static int mvneta_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) 2658static int mvneta_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
2659{ 2659{
2660 struct mvneta_port *pp = netdev_priv(dev); 2660 struct mvneta_port *pp = netdev_priv(dev);
2661 int ret;
2662 2661
2663 if (!pp->phy_dev) 2662 if (!pp->phy_dev)
2664 return -ENOTSUPP; 2663 return -ENOTSUPP;
2665 2664
2666 ret = phy_mii_ioctl(pp->phy_dev, ifr, cmd); 2665 return phy_mii_ioctl(pp->phy_dev, ifr, cmd);
2667 if (!ret)
2668 mvneta_adjust_link(dev);
2669
2670 return ret;
2671} 2666}
2672 2667
2673/* Ethtool methods */ 2668/* Ethtool methods */
diff --git a/drivers/net/ethernet/mellanox/mlx4/cmd.c b/drivers/net/ethernet/mellanox/mlx4/cmd.c
index a681d7c0bb9f..546ca4226916 100644
--- a/drivers/net/ethernet/mellanox/mlx4/cmd.c
+++ b/drivers/net/ethernet/mellanox/mlx4/cmd.c
@@ -724,7 +724,8 @@ static int mlx4_cmd_wait(struct mlx4_dev *dev, u64 in_param, u64 *out_param,
724 * on the host, we deprecate the error message for this 724 * on the host, we deprecate the error message for this
725 * specific command/input_mod/opcode_mod/fw-status to be debug. 725 * specific command/input_mod/opcode_mod/fw-status to be debug.
726 */ 726 */
727 if (op == MLX4_CMD_SET_PORT && in_modifier == 1 && 727 if (op == MLX4_CMD_SET_PORT &&
728 (in_modifier == 1 || in_modifier == 2) &&
728 op_modifier == 0 && context->fw_status == CMD_STAT_BAD_SIZE) 729 op_modifier == 0 && context->fw_status == CMD_STAT_BAD_SIZE)
729 mlx4_dbg(dev, "command 0x%x failed: fw status = 0x%x\n", 730 mlx4_dbg(dev, "command 0x%x failed: fw status = 0x%x\n",
730 op, context->fw_status); 731 op, context->fw_status);
@@ -1993,7 +1994,6 @@ static void mlx4_master_do_cmd(struct mlx4_dev *dev, int slave, u8 cmd,
1993 goto reset_slave; 1994 goto reset_slave;
1994 slave_state[slave].vhcr_dma = ((u64) param) << 48; 1995 slave_state[slave].vhcr_dma = ((u64) param) << 48;
1995 priv->mfunc.master.slave_state[slave].cookie = 0; 1996 priv->mfunc.master.slave_state[slave].cookie = 0;
1996 mutex_init(&priv->mfunc.master.gen_eqe_mutex[slave]);
1997 break; 1997 break;
1998 case MLX4_COMM_CMD_VHCR1: 1998 case MLX4_COMM_CMD_VHCR1:
1999 if (slave_state[slave].last_cmd != MLX4_COMM_CMD_VHCR0) 1999 if (slave_state[slave].last_cmd != MLX4_COMM_CMD_VHCR0)
@@ -2225,6 +2225,7 @@ int mlx4_multi_func_init(struct mlx4_dev *dev)
2225 for (i = 0; i < dev->num_slaves; ++i) { 2225 for (i = 0; i < dev->num_slaves; ++i) {
2226 s_state = &priv->mfunc.master.slave_state[i]; 2226 s_state = &priv->mfunc.master.slave_state[i];
2227 s_state->last_cmd = MLX4_COMM_CMD_RESET; 2227 s_state->last_cmd = MLX4_COMM_CMD_RESET;
2228 mutex_init(&priv->mfunc.master.gen_eqe_mutex[i]);
2228 for (j = 0; j < MLX4_EVENT_TYPES_NUM; ++j) 2229 for (j = 0; j < MLX4_EVENT_TYPES_NUM; ++j)
2229 s_state->event_eq[j].eqn = -1; 2230 s_state->event_eq[j].eqn = -1;
2230 __raw_writel((__force u32) 0, 2231 __raw_writel((__force u32) 0,
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
index ebce5bb24df9..3485acf03014 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
@@ -2805,13 +2805,6 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port,
2805 netif_carrier_off(dev); 2805 netif_carrier_off(dev);
2806 mlx4_en_set_default_moderation(priv); 2806 mlx4_en_set_default_moderation(priv);
2807 2807
2808 err = register_netdev(dev);
2809 if (err) {
2810 en_err(priv, "Netdev registration failed for port %d\n", port);
2811 goto out;
2812 }
2813 priv->registered = 1;
2814
2815 en_warn(priv, "Using %d TX rings\n", prof->tx_ring_num); 2808 en_warn(priv, "Using %d TX rings\n", prof->tx_ring_num);
2816 en_warn(priv, "Using %d RX rings\n", prof->rx_ring_num); 2809 en_warn(priv, "Using %d RX rings\n", prof->rx_ring_num);
2817 2810
@@ -2853,6 +2846,14 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port,
2853 2846
2854 mlx4_set_stats_bitmap(mdev->dev, &priv->stats_bitmap); 2847 mlx4_set_stats_bitmap(mdev->dev, &priv->stats_bitmap);
2855 2848
2849 err = register_netdev(dev);
2850 if (err) {
2851 en_err(priv, "Netdev registration failed for port %d\n", port);
2852 goto out;
2853 }
2854
2855 priv->registered = 1;
2856
2856 return 0; 2857 return 0;
2857 2858
2858out: 2859out:
diff --git a/drivers/net/ethernet/mellanox/mlx4/eq.c b/drivers/net/ethernet/mellanox/mlx4/eq.c
index 264bc15c1ff2..6e70ffee8e87 100644
--- a/drivers/net/ethernet/mellanox/mlx4/eq.c
+++ b/drivers/net/ethernet/mellanox/mlx4/eq.c
@@ -153,12 +153,10 @@ void mlx4_gen_slave_eqe(struct work_struct *work)
153 153
154 /* All active slaves need to receive the event */ 154 /* All active slaves need to receive the event */
155 if (slave == ALL_SLAVES) { 155 if (slave == ALL_SLAVES) {
156 for (i = 0; i < dev->num_slaves; i++) { 156 for (i = 0; i <= dev->persist->num_vfs; i++) {
157 if (i != dev->caps.function && 157 if (mlx4_GEN_EQE(dev, i, eqe))
158 master->slave_state[i].active) 158 mlx4_warn(dev, "Failed to generate event for slave %d\n",
159 if (mlx4_GEN_EQE(dev, i, eqe)) 159 i);
160 mlx4_warn(dev, "Failed to generate event for slave %d\n",
161 i);
162 } 160 }
163 } else { 161 } else {
164 if (mlx4_GEN_EQE(dev, slave, eqe)) 162 if (mlx4_GEN_EQE(dev, slave, eqe))
@@ -203,13 +201,11 @@ static void mlx4_slave_event(struct mlx4_dev *dev, int slave,
203 struct mlx4_eqe *eqe) 201 struct mlx4_eqe *eqe)
204{ 202{
205 struct mlx4_priv *priv = mlx4_priv(dev); 203 struct mlx4_priv *priv = mlx4_priv(dev);
206 struct mlx4_slave_state *s_slave =
207 &priv->mfunc.master.slave_state[slave];
208 204
209 if (!s_slave->active) { 205 if (slave < 0 || slave > dev->persist->num_vfs ||
210 /*mlx4_warn(dev, "Trying to pass event to inactive slave\n");*/ 206 slave == dev->caps.function ||
207 !priv->mfunc.master.slave_state[slave].active)
211 return; 208 return;
212 }
213 209
214 slave_event(dev, slave, eqe); 210 slave_event(dev, slave, eqe);
215} 211}
diff --git a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
index d97ca88c55b5..6e413ac4e940 100644
--- a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
+++ b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
@@ -3095,6 +3095,12 @@ int mlx4_GEN_EQE(struct mlx4_dev *dev, int slave, struct mlx4_eqe *eqe)
3095 if (!priv->mfunc.master.slave_state) 3095 if (!priv->mfunc.master.slave_state)
3096 return -EINVAL; 3096 return -EINVAL;
3097 3097
3098 /* check for slave valid, slave not PF, and slave active */
3099 if (slave < 0 || slave > dev->persist->num_vfs ||
3100 slave == dev->caps.function ||
3101 !priv->mfunc.master.slave_state[slave].active)
3102 return 0;
3103
3098 event_eq = &priv->mfunc.master.slave_state[slave].event_eq[eqe->type]; 3104 event_eq = &priv->mfunc.master.slave_state[slave].event_eq[eqe->type];
3099 3105
3100 /* Create the event only if the slave is registered */ 3106 /* Create the event only if the slave is registered */
diff --git a/drivers/net/ethernet/rocker/rocker.c b/drivers/net/ethernet/rocker/rocker.c
index 9fb6948e14c6..5cecec282aba 100644
--- a/drivers/net/ethernet/rocker/rocker.c
+++ b/drivers/net/ethernet/rocker/rocker.c
@@ -4468,10 +4468,16 @@ static int rocker_port_master_changed(struct net_device *dev)
4468 struct net_device *master = netdev_master_upper_dev_get(dev); 4468 struct net_device *master = netdev_master_upper_dev_get(dev);
4469 int err = 0; 4469 int err = 0;
4470 4470
4471 /* There are currently three cases handled here:
4472 * 1. Joining a bridge
4473 * 2. Leaving a previously joined bridge
4474 * 3. Other, e.g. being added to or removed from a bond or openvswitch,
4475 * in which case nothing is done
4476 */
4471 if (master && master->rtnl_link_ops && 4477 if (master && master->rtnl_link_ops &&
4472 !strcmp(master->rtnl_link_ops->kind, "bridge")) 4478 !strcmp(master->rtnl_link_ops->kind, "bridge"))
4473 err = rocker_port_bridge_join(rocker_port, master); 4479 err = rocker_port_bridge_join(rocker_port, master);
4474 else 4480 else if (rocker_port_is_bridged(rocker_port))
4475 err = rocker_port_bridge_leave(rocker_port); 4481 err = rocker_port_bridge_leave(rocker_port);
4476 4482
4477 return err; 4483 return err;
diff --git a/drivers/net/ipvlan/ipvlan.h b/drivers/net/ipvlan/ipvlan.h
index 924ea98bd531..54549a6223dd 100644
--- a/drivers/net/ipvlan/ipvlan.h
+++ b/drivers/net/ipvlan/ipvlan.h
@@ -114,7 +114,9 @@ unsigned int ipvlan_mac_hash(const unsigned char *addr);
114rx_handler_result_t ipvlan_handle_frame(struct sk_buff **pskb); 114rx_handler_result_t ipvlan_handle_frame(struct sk_buff **pskb);
115int ipvlan_queue_xmit(struct sk_buff *skb, struct net_device *dev); 115int ipvlan_queue_xmit(struct sk_buff *skb, struct net_device *dev);
116void ipvlan_ht_addr_add(struct ipvl_dev *ipvlan, struct ipvl_addr *addr); 116void ipvlan_ht_addr_add(struct ipvl_dev *ipvlan, struct ipvl_addr *addr);
117bool ipvlan_addr_busy(struct ipvl_dev *ipvlan, void *iaddr, bool is_v6); 117struct ipvl_addr *ipvlan_find_addr(const struct ipvl_dev *ipvlan,
118 const void *iaddr, bool is_v6);
119bool ipvlan_addr_busy(struct ipvl_port *port, void *iaddr, bool is_v6);
118struct ipvl_addr *ipvlan_ht_addr_lookup(const struct ipvl_port *port, 120struct ipvl_addr *ipvlan_ht_addr_lookup(const struct ipvl_port *port,
119 const void *iaddr, bool is_v6); 121 const void *iaddr, bool is_v6);
120void ipvlan_ht_addr_del(struct ipvl_addr *addr, bool sync); 122void ipvlan_ht_addr_del(struct ipvl_addr *addr, bool sync);
diff --git a/drivers/net/ipvlan/ipvlan_core.c b/drivers/net/ipvlan/ipvlan_core.c
index 2a175006028b..b7877a194cfe 100644
--- a/drivers/net/ipvlan/ipvlan_core.c
+++ b/drivers/net/ipvlan/ipvlan_core.c
@@ -81,19 +81,20 @@ void ipvlan_ht_addr_add(struct ipvl_dev *ipvlan, struct ipvl_addr *addr)
81 hash = (addr->atype == IPVL_IPV6) ? 81 hash = (addr->atype == IPVL_IPV6) ?
82 ipvlan_get_v6_hash(&addr->ip6addr) : 82 ipvlan_get_v6_hash(&addr->ip6addr) :
83 ipvlan_get_v4_hash(&addr->ip4addr); 83 ipvlan_get_v4_hash(&addr->ip4addr);
84 hlist_add_head_rcu(&addr->hlnode, &port->hlhead[hash]); 84 if (hlist_unhashed(&addr->hlnode))
85 hlist_add_head_rcu(&addr->hlnode, &port->hlhead[hash]);
85} 86}
86 87
87void ipvlan_ht_addr_del(struct ipvl_addr *addr, bool sync) 88void ipvlan_ht_addr_del(struct ipvl_addr *addr, bool sync)
88{ 89{
89 hlist_del_rcu(&addr->hlnode); 90 hlist_del_init_rcu(&addr->hlnode);
90 if (sync) 91 if (sync)
91 synchronize_rcu(); 92 synchronize_rcu();
92} 93}
93 94
94bool ipvlan_addr_busy(struct ipvl_dev *ipvlan, void *iaddr, bool is_v6) 95struct ipvl_addr *ipvlan_find_addr(const struct ipvl_dev *ipvlan,
96 const void *iaddr, bool is_v6)
95{ 97{
96 struct ipvl_port *port = ipvlan->port;
97 struct ipvl_addr *addr; 98 struct ipvl_addr *addr;
98 99
99 list_for_each_entry(addr, &ipvlan->addrs, anode) { 100 list_for_each_entry(addr, &ipvlan->addrs, anode) {
@@ -101,12 +102,21 @@ bool ipvlan_addr_busy(struct ipvl_dev *ipvlan, void *iaddr, bool is_v6)
101 ipv6_addr_equal(&addr->ip6addr, iaddr)) || 102 ipv6_addr_equal(&addr->ip6addr, iaddr)) ||
102 (!is_v6 && addr->atype == IPVL_IPV4 && 103 (!is_v6 && addr->atype == IPVL_IPV4 &&
103 addr->ip4addr.s_addr == ((struct in_addr *)iaddr)->s_addr)) 104 addr->ip4addr.s_addr == ((struct in_addr *)iaddr)->s_addr))
104 return true; 105 return addr;
105 } 106 }
107 return NULL;
108}
109
110bool ipvlan_addr_busy(struct ipvl_port *port, void *iaddr, bool is_v6)
111{
112 struct ipvl_dev *ipvlan;
106 113
107 if (ipvlan_ht_addr_lookup(port, iaddr, is_v6)) 114 ASSERT_RTNL();
108 return true;
109 115
116 list_for_each_entry(ipvlan, &port->ipvlans, pnode) {
117 if (ipvlan_find_addr(ipvlan, iaddr, is_v6))
118 return true;
119 }
110 return false; 120 return false;
111} 121}
112 122
@@ -192,7 +202,8 @@ static void ipvlan_multicast_frame(struct ipvl_port *port, struct sk_buff *skb,
192 if (skb->protocol == htons(ETH_P_PAUSE)) 202 if (skb->protocol == htons(ETH_P_PAUSE))
193 return; 203 return;
194 204
195 list_for_each_entry(ipvlan, &port->ipvlans, pnode) { 205 rcu_read_lock();
206 list_for_each_entry_rcu(ipvlan, &port->ipvlans, pnode) {
196 if (local && (ipvlan == in_dev)) 207 if (local && (ipvlan == in_dev))
197 continue; 208 continue;
198 209
@@ -219,6 +230,7 @@ static void ipvlan_multicast_frame(struct ipvl_port *port, struct sk_buff *skb,
219mcast_acct: 230mcast_acct:
220 ipvlan_count_rx(ipvlan, len, ret == NET_RX_SUCCESS, true); 231 ipvlan_count_rx(ipvlan, len, ret == NET_RX_SUCCESS, true);
221 } 232 }
233 rcu_read_unlock();
222 234
223 /* Locally generated? ...Forward a copy to the main-device as 235 /* Locally generated? ...Forward a copy to the main-device as
224 * well. On the RX side we'll ignore it (wont give it to any 236 * well. On the RX side we'll ignore it (wont give it to any
diff --git a/drivers/net/ipvlan/ipvlan_main.c b/drivers/net/ipvlan/ipvlan_main.c
index 4f4099d5603d..4fa14208d799 100644
--- a/drivers/net/ipvlan/ipvlan_main.c
+++ b/drivers/net/ipvlan/ipvlan_main.c
@@ -505,7 +505,7 @@ static void ipvlan_link_delete(struct net_device *dev, struct list_head *head)
505 if (ipvlan->ipv6cnt > 0 || ipvlan->ipv4cnt > 0) { 505 if (ipvlan->ipv6cnt > 0 || ipvlan->ipv4cnt > 0) {
506 list_for_each_entry_safe(addr, next, &ipvlan->addrs, anode) { 506 list_for_each_entry_safe(addr, next, &ipvlan->addrs, anode) {
507 ipvlan_ht_addr_del(addr, !dev->dismantle); 507 ipvlan_ht_addr_del(addr, !dev->dismantle);
508 list_del_rcu(&addr->anode); 508 list_del(&addr->anode);
509 } 509 }
510 } 510 }
511 list_del_rcu(&ipvlan->pnode); 511 list_del_rcu(&ipvlan->pnode);
@@ -607,7 +607,7 @@ static int ipvlan_add_addr6(struct ipvl_dev *ipvlan, struct in6_addr *ip6_addr)
607{ 607{
608 struct ipvl_addr *addr; 608 struct ipvl_addr *addr;
609 609
610 if (ipvlan_addr_busy(ipvlan, ip6_addr, true)) { 610 if (ipvlan_addr_busy(ipvlan->port, ip6_addr, true)) {
611 netif_err(ipvlan, ifup, ipvlan->dev, 611 netif_err(ipvlan, ifup, ipvlan->dev,
612 "Failed to add IPv6=%pI6c addr for %s intf\n", 612 "Failed to add IPv6=%pI6c addr for %s intf\n",
613 ip6_addr, ipvlan->dev->name); 613 ip6_addr, ipvlan->dev->name);
@@ -620,9 +620,13 @@ static int ipvlan_add_addr6(struct ipvl_dev *ipvlan, struct in6_addr *ip6_addr)
620 addr->master = ipvlan; 620 addr->master = ipvlan;
621 memcpy(&addr->ip6addr, ip6_addr, sizeof(struct in6_addr)); 621 memcpy(&addr->ip6addr, ip6_addr, sizeof(struct in6_addr));
622 addr->atype = IPVL_IPV6; 622 addr->atype = IPVL_IPV6;
623 list_add_tail_rcu(&addr->anode, &ipvlan->addrs); 623 list_add_tail(&addr->anode, &ipvlan->addrs);
624 ipvlan->ipv6cnt++; 624 ipvlan->ipv6cnt++;
625 ipvlan_ht_addr_add(ipvlan, addr); 625 /* If the interface is not up, the address will be added to the hash
626 * list by ipvlan_open.
627 */
628 if (netif_running(ipvlan->dev))
629 ipvlan_ht_addr_add(ipvlan, addr);
626 630
627 return 0; 631 return 0;
628} 632}
@@ -631,12 +635,12 @@ static void ipvlan_del_addr6(struct ipvl_dev *ipvlan, struct in6_addr *ip6_addr)
631{ 635{
632 struct ipvl_addr *addr; 636 struct ipvl_addr *addr;
633 637
634 addr = ipvlan_ht_addr_lookup(ipvlan->port, ip6_addr, true); 638 addr = ipvlan_find_addr(ipvlan, ip6_addr, true);
635 if (!addr) 639 if (!addr)
636 return; 640 return;
637 641
638 ipvlan_ht_addr_del(addr, true); 642 ipvlan_ht_addr_del(addr, true);
639 list_del_rcu(&addr->anode); 643 list_del(&addr->anode);
640 ipvlan->ipv6cnt--; 644 ipvlan->ipv6cnt--;
641 WARN_ON(ipvlan->ipv6cnt < 0); 645 WARN_ON(ipvlan->ipv6cnt < 0);
642 kfree_rcu(addr, rcu); 646 kfree_rcu(addr, rcu);
@@ -675,7 +679,7 @@ static int ipvlan_add_addr4(struct ipvl_dev *ipvlan, struct in_addr *ip4_addr)
675{ 679{
676 struct ipvl_addr *addr; 680 struct ipvl_addr *addr;
677 681
678 if (ipvlan_addr_busy(ipvlan, ip4_addr, false)) { 682 if (ipvlan_addr_busy(ipvlan->port, ip4_addr, false)) {
679 netif_err(ipvlan, ifup, ipvlan->dev, 683 netif_err(ipvlan, ifup, ipvlan->dev,
680 "Failed to add IPv4=%pI4 on %s intf.\n", 684 "Failed to add IPv4=%pI4 on %s intf.\n",
681 ip4_addr, ipvlan->dev->name); 685 ip4_addr, ipvlan->dev->name);
@@ -688,9 +692,13 @@ static int ipvlan_add_addr4(struct ipvl_dev *ipvlan, struct in_addr *ip4_addr)
688 addr->master = ipvlan; 692 addr->master = ipvlan;
689 memcpy(&addr->ip4addr, ip4_addr, sizeof(struct in_addr)); 693 memcpy(&addr->ip4addr, ip4_addr, sizeof(struct in_addr));
690 addr->atype = IPVL_IPV4; 694 addr->atype = IPVL_IPV4;
691 list_add_tail_rcu(&addr->anode, &ipvlan->addrs); 695 list_add_tail(&addr->anode, &ipvlan->addrs);
692 ipvlan->ipv4cnt++; 696 ipvlan->ipv4cnt++;
693 ipvlan_ht_addr_add(ipvlan, addr); 697 /* If the interface is not up, the address will be added to the hash
698 * list by ipvlan_open.
699 */
700 if (netif_running(ipvlan->dev))
701 ipvlan_ht_addr_add(ipvlan, addr);
694 ipvlan_set_broadcast_mac_filter(ipvlan, true); 702 ipvlan_set_broadcast_mac_filter(ipvlan, true);
695 703
696 return 0; 704 return 0;
@@ -700,12 +708,12 @@ static void ipvlan_del_addr4(struct ipvl_dev *ipvlan, struct in_addr *ip4_addr)
700{ 708{
701 struct ipvl_addr *addr; 709 struct ipvl_addr *addr;
702 710
703 addr = ipvlan_ht_addr_lookup(ipvlan->port, ip4_addr, false); 711 addr = ipvlan_find_addr(ipvlan, ip4_addr, false);
704 if (!addr) 712 if (!addr)
705 return; 713 return;
706 714
707 ipvlan_ht_addr_del(addr, true); 715 ipvlan_ht_addr_del(addr, true);
708 list_del_rcu(&addr->anode); 716 list_del(&addr->anode);
709 ipvlan->ipv4cnt--; 717 ipvlan->ipv4cnt--;
710 WARN_ON(ipvlan->ipv4cnt < 0); 718 WARN_ON(ipvlan->ipv4cnt < 0);
711 if (!ipvlan->ipv4cnt) 719 if (!ipvlan->ipv4cnt)
diff --git a/drivers/net/sb1000.c b/drivers/net/sb1000.c
index 66c2f1a01963..aad0b59d41e3 100644
--- a/drivers/net/sb1000.c
+++ b/drivers/net/sb1000.c
@@ -1175,17 +1175,4 @@ MODULE_AUTHOR("Franco Venturi <fventuri@mediaone.net>");
1175MODULE_DESCRIPTION("General Instruments SB1000 driver"); 1175MODULE_DESCRIPTION("General Instruments SB1000 driver");
1176MODULE_LICENSE("GPL"); 1176MODULE_LICENSE("GPL");
1177 1177
1178static int __init 1178module_pnp_driver(sb1000_driver);
1179sb1000_init(void)
1180{
1181 return pnp_register_driver(&sb1000_driver);
1182}
1183
1184static void __exit
1185sb1000_exit(void)
1186{
1187 pnp_unregister_driver(&sb1000_driver);
1188}
1189
1190module_init(sb1000_init);
1191module_exit(sb1000_exit);
diff --git a/drivers/net/usb/asix_common.c b/drivers/net/usb/asix_common.c
index 5c55f11572ba..75d6f26729a3 100644
--- a/drivers/net/usb/asix_common.c
+++ b/drivers/net/usb/asix_common.c
@@ -188,6 +188,8 @@ struct sk_buff *asix_tx_fixup(struct usbnet *dev, struct sk_buff *skb,
188 memcpy(skb_tail_pointer(skb), &padbytes, sizeof(padbytes)); 188 memcpy(skb_tail_pointer(skb), &padbytes, sizeof(padbytes));
189 skb_put(skb, sizeof(padbytes)); 189 skb_put(skb, sizeof(padbytes));
190 } 190 }
191
192 usbnet_set_skb_tx_stats(skb, 1, 0);
191 return skb; 193 return skb;
192} 194}
193 195
diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c
index 9311a08565be..4545e78840b0 100644
--- a/drivers/net/usb/cdc_ether.c
+++ b/drivers/net/usb/cdc_ether.c
@@ -522,6 +522,7 @@ static const struct driver_info wwan_info = {
522#define DELL_VENDOR_ID 0x413C 522#define DELL_VENDOR_ID 0x413C
523#define REALTEK_VENDOR_ID 0x0bda 523#define REALTEK_VENDOR_ID 0x0bda
524#define SAMSUNG_VENDOR_ID 0x04e8 524#define SAMSUNG_VENDOR_ID 0x04e8
525#define LENOVO_VENDOR_ID 0x17ef
525 526
526static const struct usb_device_id products[] = { 527static const struct usb_device_id products[] = {
527/* BLACKLIST !! 528/* BLACKLIST !!
@@ -702,6 +703,13 @@ static const struct usb_device_id products[] = {
702 .driver_info = 0, 703 .driver_info = 0,
703}, 704},
704 705
706/* Lenovo Thinkpad USB 3.0 Ethernet Adapters (based on Realtek RTL8153) */
707{
708 USB_DEVICE_AND_INTERFACE_INFO(LENOVO_VENDOR_ID, 0x7205, USB_CLASS_COMM,
709 USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE),
710 .driver_info = 0,
711},
712
705/* WHITELIST!!! 713/* WHITELIST!!!
706 * 714 *
707 * CDC Ether uses two interfaces, not necessarily consecutive. 715 * CDC Ether uses two interfaces, not necessarily consecutive.
diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index 80a844e0ae03..c3e4da9e79ca 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -1172,17 +1172,17 @@ cdc_ncm_fill_tx_frame(struct usbnet *dev, struct sk_buff *skb, __le32 sign)
1172 1172
1173 /* return skb */ 1173 /* return skb */
1174 ctx->tx_curr_skb = NULL; 1174 ctx->tx_curr_skb = NULL;
1175 dev->net->stats.tx_packets += ctx->tx_curr_frame_num;
1176 1175
1177 /* keep private stats: framing overhead and number of NTBs */ 1176 /* keep private stats: framing overhead and number of NTBs */
1178 ctx->tx_overhead += skb_out->len - ctx->tx_curr_frame_payload; 1177 ctx->tx_overhead += skb_out->len - ctx->tx_curr_frame_payload;
1179 ctx->tx_ntbs++; 1178 ctx->tx_ntbs++;
1180 1179
1181 /* usbnet has already counted all the framing overhead. 1180 /* usbnet will count all the framing overhead by default.
1182 * Adjust the stats so that the tx_bytes counter show real 1181 * Adjust the stats so that the tx_bytes counter show real
1183 * payload data instead. 1182 * payload data instead.
1184 */ 1183 */
1185 dev->net->stats.tx_bytes -= skb_out->len - ctx->tx_curr_frame_payload; 1184 usbnet_set_skb_tx_stats(skb_out, n,
1185 ctx->tx_curr_frame_payload - skb_out->len);
1186 1186
1187 return skb_out; 1187 return skb_out;
1188 1188
diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index 438fc6bcaef1..9f7c0ab3b349 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -492,6 +492,7 @@ enum rtl8152_flags {
492/* Define these values to match your device */ 492/* Define these values to match your device */
493#define VENDOR_ID_REALTEK 0x0bda 493#define VENDOR_ID_REALTEK 0x0bda
494#define VENDOR_ID_SAMSUNG 0x04e8 494#define VENDOR_ID_SAMSUNG 0x04e8
495#define VENDOR_ID_LENOVO 0x17ef
495 496
496#define MCU_TYPE_PLA 0x0100 497#define MCU_TYPE_PLA 0x0100
497#define MCU_TYPE_USB 0x0000 498#define MCU_TYPE_USB 0x0000
@@ -4037,6 +4038,7 @@ static struct usb_device_id rtl8152_table[] = {
4037 {REALTEK_USB_DEVICE(VENDOR_ID_REALTEK, 0x8152)}, 4038 {REALTEK_USB_DEVICE(VENDOR_ID_REALTEK, 0x8152)},
4038 {REALTEK_USB_DEVICE(VENDOR_ID_REALTEK, 0x8153)}, 4039 {REALTEK_USB_DEVICE(VENDOR_ID_REALTEK, 0x8153)},
4039 {REALTEK_USB_DEVICE(VENDOR_ID_SAMSUNG, 0xa101)}, 4040 {REALTEK_USB_DEVICE(VENDOR_ID_SAMSUNG, 0xa101)},
4041 {REALTEK_USB_DEVICE(VENDOR_ID_LENOVO, 0x7205)},
4040 {} 4042 {}
4041}; 4043};
4042 4044
diff --git a/drivers/net/usb/sr9800.c b/drivers/net/usb/sr9800.c
index b94a0fbb8b3b..953de13267df 100644
--- a/drivers/net/usb/sr9800.c
+++ b/drivers/net/usb/sr9800.c
@@ -144,6 +144,7 @@ static struct sk_buff *sr_tx_fixup(struct usbnet *dev, struct sk_buff *skb,
144 skb_put(skb, sizeof(padbytes)); 144 skb_put(skb, sizeof(padbytes));
145 } 145 }
146 146
147 usbnet_set_skb_tx_stats(skb, 1, 0);
147 return skb; 148 return skb;
148} 149}
149 150
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 449835f4331e..777757ae1973 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -1188,8 +1188,7 @@ static void tx_complete (struct urb *urb)
1188 struct usbnet *dev = entry->dev; 1188 struct usbnet *dev = entry->dev;
1189 1189
1190 if (urb->status == 0) { 1190 if (urb->status == 0) {
1191 if (!(dev->driver_info->flags & FLAG_MULTI_PACKET)) 1191 dev->net->stats.tx_packets += entry->packets;
1192 dev->net->stats.tx_packets++;
1193 dev->net->stats.tx_bytes += entry->length; 1192 dev->net->stats.tx_bytes += entry->length;
1194 } else { 1193 } else {
1195 dev->net->stats.tx_errors++; 1194 dev->net->stats.tx_errors++;
@@ -1347,7 +1346,19 @@ netdev_tx_t usbnet_start_xmit (struct sk_buff *skb,
1347 } else 1346 } else
1348 urb->transfer_flags |= URB_ZERO_PACKET; 1347 urb->transfer_flags |= URB_ZERO_PACKET;
1349 } 1348 }
1350 entry->length = urb->transfer_buffer_length = length; 1349 urb->transfer_buffer_length = length;
1350
1351 if (info->flags & FLAG_MULTI_PACKET) {
1352 /* Driver has set number of packets and a length delta.
1353 * Calculate the complete length and ensure that it's
1354 * positive.
1355 */
1356 entry->length += length;
1357 if (WARN_ON_ONCE(entry->length <= 0))
1358 entry->length = length;
1359 } else {
1360 usbnet_set_skb_tx_stats(skb, 1, length);
1361 }
1351 1362
1352 spin_lock_irqsave(&dev->txq.lock, flags); 1363 spin_lock_irqsave(&dev->txq.lock, flags);
1353 retval = usb_autopm_get_interface_async(dev->intf); 1364 retval = usb_autopm_get_interface_async(dev->intf);
diff --git a/drivers/net/wireless/ath/ath9k/beacon.c b/drivers/net/wireless/ath/ath9k/beacon.c
index cb366adc820b..f50a6bc5d06e 100644
--- a/drivers/net/wireless/ath/ath9k/beacon.c
+++ b/drivers/net/wireless/ath/ath9k/beacon.c
@@ -219,12 +219,15 @@ void ath9k_beacon_remove_slot(struct ath_softc *sc, struct ieee80211_vif *vif)
219 struct ath_common *common = ath9k_hw_common(sc->sc_ah); 219 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
220 struct ath_vif *avp = (void *)vif->drv_priv; 220 struct ath_vif *avp = (void *)vif->drv_priv;
221 struct ath_buf *bf = avp->av_bcbuf; 221 struct ath_buf *bf = avp->av_bcbuf;
222 struct ath_beacon_config *cur_conf = &sc->cur_chan->beacon;
222 223
223 ath_dbg(common, CONFIG, "Removing interface at beacon slot: %d\n", 224 ath_dbg(common, CONFIG, "Removing interface at beacon slot: %d\n",
224 avp->av_bslot); 225 avp->av_bslot);
225 226
226 tasklet_disable(&sc->bcon_tasklet); 227 tasklet_disable(&sc->bcon_tasklet);
227 228
229 cur_conf->enable_beacon &= ~BIT(avp->av_bslot);
230
228 if (bf && bf->bf_mpdu) { 231 if (bf && bf->bf_mpdu) {
229 struct sk_buff *skb = bf->bf_mpdu; 232 struct sk_buff *skb = bf->bf_mpdu;
230 dma_unmap_single(sc->dev, bf->bf_buf_addr, 233 dma_unmap_single(sc->dev, bf->bf_buf_addr,
@@ -521,8 +524,7 @@ static bool ath9k_allow_beacon_config(struct ath_softc *sc,
521 } 524 }
522 525
523 if (sc->sc_ah->opmode == NL80211_IFTYPE_AP) { 526 if (sc->sc_ah->opmode == NL80211_IFTYPE_AP) {
524 if ((vif->type != NL80211_IFTYPE_AP) || 527 if (vif->type != NL80211_IFTYPE_AP) {
525 (sc->nbcnvifs > 1)) {
526 ath_dbg(common, CONFIG, 528 ath_dbg(common, CONFIG,
527 "An AP interface is already present !\n"); 529 "An AP interface is already present !\n");
528 return false; 530 return false;
@@ -616,12 +618,14 @@ void ath9k_beacon_config(struct ath_softc *sc, struct ieee80211_vif *vif,
616 * enabling/disabling SWBA. 618 * enabling/disabling SWBA.
617 */ 619 */
618 if (changed & BSS_CHANGED_BEACON_ENABLED) { 620 if (changed & BSS_CHANGED_BEACON_ENABLED) {
619 if (!bss_conf->enable_beacon && 621 bool enabled = cur_conf->enable_beacon;
620 (sc->nbcnvifs <= 1)) { 622
621 cur_conf->enable_beacon = false; 623 if (!bss_conf->enable_beacon) {
622 } else if (bss_conf->enable_beacon) { 624 cur_conf->enable_beacon &= ~BIT(avp->av_bslot);
623 cur_conf->enable_beacon = true; 625 } else {
624 ath9k_cache_beacon_config(sc, ctx, bss_conf); 626 cur_conf->enable_beacon |= BIT(avp->av_bslot);
627 if (!enabled)
628 ath9k_cache_beacon_config(sc, ctx, bss_conf);
625 } 629 }
626 } 630 }
627 631
diff --git a/drivers/net/wireless/ath/ath9k/common.h b/drivers/net/wireless/ath/ath9k/common.h
index 2b79a568e803..d23737342f4f 100644
--- a/drivers/net/wireless/ath/ath9k/common.h
+++ b/drivers/net/wireless/ath/ath9k/common.h
@@ -54,7 +54,7 @@ struct ath_beacon_config {
54 u16 dtim_period; 54 u16 dtim_period;
55 u16 bmiss_timeout; 55 u16 bmiss_timeout;
56 u8 dtim_count; 56 u8 dtim_count;
57 bool enable_beacon; 57 u8 enable_beacon;
58 bool ibss_creator; 58 bool ibss_creator;
59 u32 nexttbtt; 59 u32 nexttbtt;
60 u32 intval; 60 u32 intval;
diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c
index 60aa8d71e753..8529014e1a5e 100644
--- a/drivers/net/wireless/ath/ath9k/hw.c
+++ b/drivers/net/wireless/ath/ath9k/hw.c
@@ -424,7 +424,7 @@ static void ath9k_hw_init_defaults(struct ath_hw *ah)
424 ah->power_mode = ATH9K_PM_UNDEFINED; 424 ah->power_mode = ATH9K_PM_UNDEFINED;
425 ah->htc_reset_init = true; 425 ah->htc_reset_init = true;
426 426
427 ah->tpc_enabled = true; 427 ah->tpc_enabled = false;
428 428
429 ah->ani_function = ATH9K_ANI_ALL; 429 ah->ani_function = ATH9K_ANI_ALL;
430 if (!AR_SREV_9300_20_OR_LATER(ah)) 430 if (!AR_SREV_9300_20_OR_LATER(ah))
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/feature.c b/drivers/net/wireless/brcm80211/brcmfmac/feature.c
index defb7a44e0bc..7748a1ccf14f 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/feature.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/feature.c
@@ -126,7 +126,8 @@ void brcmf_feat_attach(struct brcmf_pub *drvr)
126 brcmf_feat_iovar_int_get(ifp, BRCMF_FEAT_MCHAN, "mchan"); 126 brcmf_feat_iovar_int_get(ifp, BRCMF_FEAT_MCHAN, "mchan");
127 if (drvr->bus_if->wowl_supported) 127 if (drvr->bus_if->wowl_supported)
128 brcmf_feat_iovar_int_get(ifp, BRCMF_FEAT_WOWL, "wowl"); 128 brcmf_feat_iovar_int_get(ifp, BRCMF_FEAT_WOWL, "wowl");
129 brcmf_feat_iovar_int_set(ifp, BRCMF_FEAT_MBSS, "mbss", 0); 129 if (drvr->bus_if->chip != BRCM_CC_43362_CHIP_ID)
130 brcmf_feat_iovar_int_set(ifp, BRCMF_FEAT_MBSS, "mbss", 0);
130 131
131 /* set chip related quirks */ 132 /* set chip related quirks */
132 switch (drvr->bus_if->chip) { 133 switch (drvr->bus_if->chip) {
diff --git a/drivers/net/wireless/iwlwifi/dvm/dev.h b/drivers/net/wireless/iwlwifi/dvm/dev.h
index a6f22c32a279..3811878ab9cd 100644
--- a/drivers/net/wireless/iwlwifi/dvm/dev.h
+++ b/drivers/net/wireless/iwlwifi/dvm/dev.h
@@ -708,7 +708,6 @@ struct iwl_priv {
708 unsigned long reload_jiffies; 708 unsigned long reload_jiffies;
709 int reload_count; 709 int reload_count;
710 bool ucode_loaded; 710 bool ucode_loaded;
711 bool init_ucode_run; /* Don't run init uCode again */
712 711
713 u8 plcp_delta_threshold; 712 u8 plcp_delta_threshold;
714 713
diff --git a/drivers/net/wireless/iwlwifi/dvm/mac80211.c b/drivers/net/wireless/iwlwifi/dvm/mac80211.c
index 47e64e8b9517..cceb026e0793 100644
--- a/drivers/net/wireless/iwlwifi/dvm/mac80211.c
+++ b/drivers/net/wireless/iwlwifi/dvm/mac80211.c
@@ -1114,16 +1114,17 @@ static void iwlagn_mac_flush(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
1114 scd_queues &= ~(BIT(IWL_IPAN_CMD_QUEUE_NUM) | 1114 scd_queues &= ~(BIT(IWL_IPAN_CMD_QUEUE_NUM) |
1115 BIT(IWL_DEFAULT_CMD_QUEUE_NUM)); 1115 BIT(IWL_DEFAULT_CMD_QUEUE_NUM));
1116 1116
1117 if (vif) 1117 if (drop) {
1118 scd_queues &= ~BIT(vif->hw_queue[IEEE80211_AC_VO]); 1118 IWL_DEBUG_TX_QUEUES(priv, "Flushing SCD queues: 0x%x\n",
1119 1119 scd_queues);
1120 IWL_DEBUG_TX_QUEUES(priv, "Flushing SCD queues: 0x%x\n", scd_queues); 1120 if (iwlagn_txfifo_flush(priv, scd_queues)) {
1121 if (iwlagn_txfifo_flush(priv, scd_queues)) { 1121 IWL_ERR(priv, "flush request fail\n");
1122 IWL_ERR(priv, "flush request fail\n"); 1122 goto done;
1123 goto done; 1123 }
1124 } 1124 }
1125
1125 IWL_DEBUG_TX_QUEUES(priv, "wait transmit/flush all frames\n"); 1126 IWL_DEBUG_TX_QUEUES(priv, "wait transmit/flush all frames\n");
1126 iwl_trans_wait_tx_queue_empty(priv->trans, 0xffffffff); 1127 iwl_trans_wait_tx_queue_empty(priv->trans, scd_queues);
1127done: 1128done:
1128 mutex_unlock(&priv->mutex); 1129 mutex_unlock(&priv->mutex);
1129 IWL_DEBUG_MAC80211(priv, "leave\n"); 1130 IWL_DEBUG_MAC80211(priv, "leave\n");
diff --git a/drivers/net/wireless/iwlwifi/dvm/ucode.c b/drivers/net/wireless/iwlwifi/dvm/ucode.c
index 4dbef7e58c2e..5244e43bfafb 100644
--- a/drivers/net/wireless/iwlwifi/dvm/ucode.c
+++ b/drivers/net/wireless/iwlwifi/dvm/ucode.c
@@ -418,9 +418,6 @@ int iwl_run_init_ucode(struct iwl_priv *priv)
418 if (!priv->fw->img[IWL_UCODE_INIT].sec[0].len) 418 if (!priv->fw->img[IWL_UCODE_INIT].sec[0].len)
419 return 0; 419 return 0;
420 420
421 if (priv->init_ucode_run)
422 return 0;
423
424 iwl_init_notification_wait(&priv->notif_wait, &calib_wait, 421 iwl_init_notification_wait(&priv->notif_wait, &calib_wait,
425 calib_complete, ARRAY_SIZE(calib_complete), 422 calib_complete, ARRAY_SIZE(calib_complete),
426 iwlagn_wait_calib, priv); 423 iwlagn_wait_calib, priv);
@@ -440,8 +437,6 @@ int iwl_run_init_ucode(struct iwl_priv *priv)
440 */ 437 */
441 ret = iwl_wait_notification(&priv->notif_wait, &calib_wait, 438 ret = iwl_wait_notification(&priv->notif_wait, &calib_wait,
442 UCODE_CALIB_TIMEOUT); 439 UCODE_CALIB_TIMEOUT);
443 if (!ret)
444 priv->init_ucode_run = true;
445 440
446 goto out; 441 goto out;
447 442
diff --git a/drivers/net/wireless/iwlwifi/iwl-drv.c b/drivers/net/wireless/iwlwifi/iwl-drv.c
index 996e7f16adf9..c7154ac42c8c 100644
--- a/drivers/net/wireless/iwlwifi/iwl-drv.c
+++ b/drivers/net/wireless/iwlwifi/iwl-drv.c
@@ -1257,6 +1257,7 @@ static void iwl_req_fw_callback(const struct firmware *ucode_raw, void *context)
1257 op->name, err); 1257 op->name, err);
1258#endif 1258#endif
1259 } 1259 }
1260 kfree(pieces);
1260 return; 1261 return;
1261 1262
1262 try_again: 1263 try_again:
diff --git a/drivers/net/wireless/iwlwifi/mvm/rs.c b/drivers/net/wireless/iwlwifi/mvm/rs.c
index efa9688a4cf1..078f24cf4af3 100644
--- a/drivers/net/wireless/iwlwifi/mvm/rs.c
+++ b/drivers/net/wireless/iwlwifi/mvm/rs.c
@@ -1278,6 +1278,9 @@ static void rs_mac80211_tx_status(void *mvm_r,
1278 struct iwl_mvm *mvm = IWL_OP_MODE_GET_MVM(op_mode); 1278 struct iwl_mvm *mvm = IWL_OP_MODE_GET_MVM(op_mode);
1279 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 1279 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
1280 1280
1281 if (!iwl_mvm_sta_from_mac80211(sta)->vif)
1282 return;
1283
1281 if (!ieee80211_is_data(hdr->frame_control) || 1284 if (!ieee80211_is_data(hdr->frame_control) ||
1282 info->flags & IEEE80211_TX_CTL_NO_ACK) 1285 info->flags & IEEE80211_TX_CTL_NO_ACK)
1283 return; 1286 return;
@@ -2511,6 +2514,14 @@ static void rs_get_rate(void *mvm_r, struct ieee80211_sta *sta, void *mvm_sta,
2511 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 2514 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
2512 struct iwl_lq_sta *lq_sta = mvm_sta; 2515 struct iwl_lq_sta *lq_sta = mvm_sta;
2513 2516
2517 if (sta && !iwl_mvm_sta_from_mac80211(sta)->vif) {
2518 /* if vif isn't initialized mvm doesn't know about
2519 * this station, so don't do anything with the it
2520 */
2521 sta = NULL;
2522 mvm_sta = NULL;
2523 }
2524
2514 /* TODO: handle rate_idx_mask and rate_idx_mcs_mask */ 2525 /* TODO: handle rate_idx_mask and rate_idx_mcs_mask */
2515 2526
2516 /* Treat uninitialized rate scaling data same as non-existing. */ 2527 /* Treat uninitialized rate scaling data same as non-existing. */
@@ -2827,6 +2838,9 @@ static void rs_rate_update(void *mvm_r,
2827 (struct iwl_op_mode *)mvm_r; 2838 (struct iwl_op_mode *)mvm_r;
2828 struct iwl_mvm *mvm = IWL_OP_MODE_GET_MVM(op_mode); 2839 struct iwl_mvm *mvm = IWL_OP_MODE_GET_MVM(op_mode);
2829 2840
2841 if (!iwl_mvm_sta_from_mac80211(sta)->vif)
2842 return;
2843
2830 /* Stop any ongoing aggregations as rs starts off assuming no agg */ 2844 /* Stop any ongoing aggregations as rs starts off assuming no agg */
2831 for (tid = 0; tid < IWL_MAX_TID_COUNT; tid++) 2845 for (tid = 0; tid < IWL_MAX_TID_COUNT; tid++)
2832 ieee80211_stop_tx_ba_session(sta, tid); 2846 ieee80211_stop_tx_ba_session(sta, tid);
@@ -3587,9 +3601,15 @@ static ssize_t iwl_dbgfs_ss_force_write(struct iwl_lq_sta *lq_sta, char *buf,
3587 3601
3588MVM_DEBUGFS_READ_WRITE_FILE_OPS(ss_force, 32); 3602MVM_DEBUGFS_READ_WRITE_FILE_OPS(ss_force, 32);
3589 3603
3590static void rs_add_debugfs(void *mvm, void *mvm_sta, struct dentry *dir) 3604static void rs_add_debugfs(void *mvm, void *priv_sta, struct dentry *dir)
3591{ 3605{
3592 struct iwl_lq_sta *lq_sta = mvm_sta; 3606 struct iwl_lq_sta *lq_sta = priv_sta;
3607 struct iwl_mvm_sta *mvmsta;
3608
3609 mvmsta = container_of(lq_sta, struct iwl_mvm_sta, lq_sta);
3610
3611 if (!mvmsta->vif)
3612 return;
3593 3613
3594 debugfs_create_file("rate_scale_table", S_IRUSR | S_IWUSR, dir, 3614 debugfs_create_file("rate_scale_table", S_IRUSR | S_IWUSR, dir,
3595 lq_sta, &rs_sta_dbgfs_scale_table_ops); 3615 lq_sta, &rs_sta_dbgfs_scale_table_ops);
diff --git a/drivers/net/wireless/iwlwifi/mvm/time-event.c b/drivers/net/wireless/iwlwifi/mvm/time-event.c
index f8d6f306dd76..4b81c0bf63b0 100644
--- a/drivers/net/wireless/iwlwifi/mvm/time-event.c
+++ b/drivers/net/wireless/iwlwifi/mvm/time-event.c
@@ -197,6 +197,8 @@ iwl_mvm_te_handle_notify_csa(struct iwl_mvm *mvm,
197 struct iwl_time_event_notif *notif) 197 struct iwl_time_event_notif *notif)
198{ 198{
199 if (!le32_to_cpu(notif->status)) { 199 if (!le32_to_cpu(notif->status)) {
200 if (te_data->vif->type == NL80211_IFTYPE_STATION)
201 ieee80211_connection_loss(te_data->vif);
200 IWL_DEBUG_TE(mvm, "CSA time event failed to start\n"); 202 IWL_DEBUG_TE(mvm, "CSA time event failed to start\n");
201 iwl_mvm_te_clear_data(mvm, te_data); 203 iwl_mvm_te_clear_data(mvm, te_data);
202 return; 204 return;
diff --git a/drivers/net/wireless/iwlwifi/mvm/tx.c b/drivers/net/wireless/iwlwifi/mvm/tx.c
index 07304e1fd64a..96a05406babf 100644
--- a/drivers/net/wireless/iwlwifi/mvm/tx.c
+++ b/drivers/net/wireless/iwlwifi/mvm/tx.c
@@ -949,8 +949,10 @@ int iwl_mvm_rx_ba_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb,
949 mvmsta = iwl_mvm_sta_from_mac80211(sta); 949 mvmsta = iwl_mvm_sta_from_mac80211(sta);
950 tid_data = &mvmsta->tid_data[tid]; 950 tid_data = &mvmsta->tid_data[tid];
951 951
952 if (WARN_ONCE(tid_data->txq_id != scd_flow, "Q %d, tid %d, flow %d", 952 if (tid_data->txq_id != scd_flow) {
953 tid_data->txq_id, tid, scd_flow)) { 953 IWL_ERR(mvm,
954 "invalid BA notification: Q %d, tid %d, flow %d\n",
955 tid_data->txq_id, tid, scd_flow);
954 rcu_read_unlock(); 956 rcu_read_unlock();
955 return 0; 957 return 0;
956 } 958 }
diff --git a/drivers/net/wireless/iwlwifi/pcie/drv.c b/drivers/net/wireless/iwlwifi/pcie/drv.c
index dbd6bcf52205..686dd301cd53 100644
--- a/drivers/net/wireless/iwlwifi/pcie/drv.c
+++ b/drivers/net/wireless/iwlwifi/pcie/drv.c
@@ -368,10 +368,12 @@ static const struct pci_device_id iwl_hw_card_ids[] = {
368/* 3165 Series */ 368/* 3165 Series */
369 {IWL_PCI_DEVICE(0x3165, 0x4010, iwl3165_2ac_cfg)}, 369 {IWL_PCI_DEVICE(0x3165, 0x4010, iwl3165_2ac_cfg)},
370 {IWL_PCI_DEVICE(0x3165, 0x4012, iwl3165_2ac_cfg)}, 370 {IWL_PCI_DEVICE(0x3165, 0x4012, iwl3165_2ac_cfg)},
371 {IWL_PCI_DEVICE(0x3165, 0x4110, iwl3165_2ac_cfg)},
372 {IWL_PCI_DEVICE(0x3165, 0x4210, iwl3165_2ac_cfg)},
373 {IWL_PCI_DEVICE(0x3165, 0x4410, iwl3165_2ac_cfg)}, 371 {IWL_PCI_DEVICE(0x3165, 0x4410, iwl3165_2ac_cfg)},
374 {IWL_PCI_DEVICE(0x3165, 0x4510, iwl3165_2ac_cfg)}, 372 {IWL_PCI_DEVICE(0x3165, 0x4510, iwl3165_2ac_cfg)},
373 {IWL_PCI_DEVICE(0x3165, 0x4110, iwl3165_2ac_cfg)},
374 {IWL_PCI_DEVICE(0x3166, 0x4310, iwl3165_2ac_cfg)},
375 {IWL_PCI_DEVICE(0x3166, 0x4210, iwl3165_2ac_cfg)},
376 {IWL_PCI_DEVICE(0x3165, 0x8010, iwl3165_2ac_cfg)},
375 377
376/* 7265 Series */ 378/* 7265 Series */
377 {IWL_PCI_DEVICE(0x095A, 0x5010, iwl7265_2ac_cfg)}, 379 {IWL_PCI_DEVICE(0x095A, 0x5010, iwl7265_2ac_cfg)},
diff --git a/drivers/net/wireless/rtlwifi/pci.c b/drivers/net/wireless/rtlwifi/pci.c
index a62170ea0481..8c45cf44ce24 100644
--- a/drivers/net/wireless/rtlwifi/pci.c
+++ b/drivers/net/wireless/rtlwifi/pci.c
@@ -1124,12 +1124,22 @@ static void _rtl_pci_prepare_bcn_tasklet(struct ieee80211_hw *hw)
1124 /*This is for new trx flow*/ 1124 /*This is for new trx flow*/
1125 struct rtl_tx_buffer_desc *pbuffer_desc = NULL; 1125 struct rtl_tx_buffer_desc *pbuffer_desc = NULL;
1126 u8 temp_one = 1; 1126 u8 temp_one = 1;
1127 u8 *entry;
1127 1128
1128 memset(&tcb_desc, 0, sizeof(struct rtl_tcb_desc)); 1129 memset(&tcb_desc, 0, sizeof(struct rtl_tcb_desc));
1129 ring = &rtlpci->tx_ring[BEACON_QUEUE]; 1130 ring = &rtlpci->tx_ring[BEACON_QUEUE];
1130 pskb = __skb_dequeue(&ring->queue); 1131 pskb = __skb_dequeue(&ring->queue);
1131 if (pskb) 1132 if (rtlpriv->use_new_trx_flow)
1133 entry = (u8 *)(&ring->buffer_desc[ring->idx]);
1134 else
1135 entry = (u8 *)(&ring->desc[ring->idx]);
1136 if (pskb) {
1137 pci_unmap_single(rtlpci->pdev,
1138 rtlpriv->cfg->ops->get_desc(
1139 (u8 *)entry, true, HW_DESC_TXBUFF_ADDR),
1140 pskb->len, PCI_DMA_TODEVICE);
1132 kfree_skb(pskb); 1141 kfree_skb(pskb);
1142 }
1133 1143
1134 /*NB: the beacon data buffer must be 32-bit aligned. */ 1144 /*NB: the beacon data buffer must be 32-bit aligned. */
1135 pskb = ieee80211_beacon_get(hw, mac->vif); 1145 pskb = ieee80211_beacon_get(hw, mac->vif);
diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index e9b960f0ff32..720aaf6313d2 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -1008,8 +1008,7 @@ err:
1008 1008
1009static int xennet_change_mtu(struct net_device *dev, int mtu) 1009static int xennet_change_mtu(struct net_device *dev, int mtu)
1010{ 1010{
1011 int max = xennet_can_sg(dev) ? 1011 int max = xennet_can_sg(dev) ? XEN_NETIF_MAX_TX_SIZE : ETH_DATA_LEN;
1012 XEN_NETIF_MAX_TX_SIZE - MAX_TCP_HEADER : ETH_DATA_LEN;
1013 1012
1014 if (mtu > max) 1013 if (mtu > max)
1015 return -EINVAL; 1014 return -EINVAL;
@@ -1279,8 +1278,6 @@ static struct net_device *xennet_create_dev(struct xenbus_device *dev)
1279 netdev->ethtool_ops = &xennet_ethtool_ops; 1278 netdev->ethtool_ops = &xennet_ethtool_ops;
1280 SET_NETDEV_DEV(netdev, &dev->dev); 1279 SET_NETDEV_DEV(netdev, &dev->dev);
1281 1280
1282 netif_set_gso_max_size(netdev, XEN_NETIF_MAX_TX_SIZE - MAX_TCP_HEADER);
1283
1284 np->netdev = netdev; 1281 np->netdev = netdev;
1285 1282
1286 netif_carrier_off(netdev); 1283 netif_carrier_off(netdev);
diff --git a/drivers/of/address.c b/drivers/of/address.c
index ad2906919d45..78a7dcbec7d8 100644
--- a/drivers/of/address.c
+++ b/drivers/of/address.c
@@ -450,12 +450,17 @@ static struct of_bus *of_match_bus(struct device_node *np)
450 return NULL; 450 return NULL;
451} 451}
452 452
453static int of_empty_ranges_quirk(void) 453static int of_empty_ranges_quirk(struct device_node *np)
454{ 454{
455 if (IS_ENABLED(CONFIG_PPC)) { 455 if (IS_ENABLED(CONFIG_PPC)) {
456 /* To save cycles, we cache the result */ 456 /* To save cycles, we cache the result for global "Mac" setting */
457 static int quirk_state = -1; 457 static int quirk_state = -1;
458 458
459 /* PA-SEMI sdc DT bug */
460 if (of_device_is_compatible(np, "1682m-sdc"))
461 return true;
462
463 /* Make quirk cached */
459 if (quirk_state < 0) 464 if (quirk_state < 0)
460 quirk_state = 465 quirk_state =
461 of_machine_is_compatible("Power Macintosh") || 466 of_machine_is_compatible("Power Macintosh") ||
@@ -490,7 +495,7 @@ static int of_translate_one(struct device_node *parent, struct of_bus *bus,
490 * This code is only enabled on powerpc. --gcl 495 * This code is only enabled on powerpc. --gcl
491 */ 496 */
492 ranges = of_get_property(parent, rprop, &rlen); 497 ranges = of_get_property(parent, rprop, &rlen);
493 if (ranges == NULL && !of_empty_ranges_quirk()) { 498 if (ranges == NULL && !of_empty_ranges_quirk(parent)) {
494 pr_debug("OF: no ranges; cannot translate\n"); 499 pr_debug("OF: no ranges; cannot translate\n");
495 return 1; 500 return 1;
496 } 501 }
diff --git a/drivers/pci/host/pcie-designware.c b/drivers/pci/host/pcie-designware.c
index 1f4ea6f2d910..2e9f84fdd9ce 100644
--- a/drivers/pci/host/pcie-designware.c
+++ b/drivers/pci/host/pcie-designware.c
@@ -342,7 +342,7 @@ static const struct irq_domain_ops msi_domain_ops = {
342 .map = dw_pcie_msi_map, 342 .map = dw_pcie_msi_map,
343}; 343};
344 344
345int __init dw_pcie_host_init(struct pcie_port *pp) 345int dw_pcie_host_init(struct pcie_port *pp)
346{ 346{
347 struct device_node *np = pp->dev->of_node; 347 struct device_node *np = pp->dev->of_node;
348 struct platform_device *pdev = to_platform_device(pp->dev); 348 struct platform_device *pdev = to_platform_device(pp->dev);
diff --git a/drivers/pci/host/pcie-spear13xx.c b/drivers/pci/host/pcie-spear13xx.c
index 866465fd3dbf..020d78890719 100644
--- a/drivers/pci/host/pcie-spear13xx.c
+++ b/drivers/pci/host/pcie-spear13xx.c
@@ -269,7 +269,7 @@ static struct pcie_host_ops spear13xx_pcie_host_ops = {
269 .host_init = spear13xx_pcie_host_init, 269 .host_init = spear13xx_pcie_host_init,
270}; 270};
271 271
272static int __init spear13xx_add_pcie_port(struct pcie_port *pp, 272static int spear13xx_add_pcie_port(struct pcie_port *pp,
273 struct platform_device *pdev) 273 struct platform_device *pdev)
274{ 274{
275 struct device *dev = &pdev->dev; 275 struct device *dev = &pdev->dev;
@@ -299,7 +299,7 @@ static int __init spear13xx_add_pcie_port(struct pcie_port *pp,
299 return 0; 299 return 0;
300} 300}
301 301
302static int __init spear13xx_pcie_probe(struct platform_device *pdev) 302static int spear13xx_pcie_probe(struct platform_device *pdev)
303{ 303{
304 struct spear13xx_pcie *spear13xx_pcie; 304 struct spear13xx_pcie *spear13xx_pcie;
305 struct pcie_port *pp; 305 struct pcie_port *pp;
@@ -370,7 +370,7 @@ static const struct of_device_id spear13xx_pcie_of_match[] = {
370}; 370};
371MODULE_DEVICE_TABLE(of, spear13xx_pcie_of_match); 371MODULE_DEVICE_TABLE(of, spear13xx_pcie_of_match);
372 372
373static struct platform_driver spear13xx_pcie_driver __initdata = { 373static struct platform_driver spear13xx_pcie_driver = {
374 .probe = spear13xx_pcie_probe, 374 .probe = spear13xx_pcie_probe,
375 .driver = { 375 .driver = {
376 .name = "spear-pcie", 376 .name = "spear-pcie",
diff --git a/drivers/pci/hotplug/cpci_hotplug_pci.c b/drivers/pci/hotplug/cpci_hotplug_pci.c
index 7d48ecae6695..788db48dbbad 100644
--- a/drivers/pci/hotplug/cpci_hotplug_pci.c
+++ b/drivers/pci/hotplug/cpci_hotplug_pci.c
@@ -286,11 +286,12 @@ int cpci_configure_slot(struct slot *slot)
286 } 286 }
287 parent = slot->dev->bus; 287 parent = slot->dev->bus;
288 288
289 list_for_each_entry(dev, &parent->devices, bus_list) 289 list_for_each_entry(dev, &parent->devices, bus_list) {
290 if (PCI_SLOT(dev->devfn) != PCI_SLOT(slot->devfn)) 290 if (PCI_SLOT(dev->devfn) != PCI_SLOT(slot->devfn))
291 continue; 291 continue;
292 if (pci_is_bridge(dev)) 292 if (pci_is_bridge(dev))
293 pci_hp_add_bridge(dev); 293 pci_hp_add_bridge(dev);
294 }
294 295
295 296
296 pci_assign_unassigned_bridge_resources(parent->self); 297 pci_assign_unassigned_bridge_resources(parent->self);
diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
index 489063987325..c93fbe76d281 100644
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -248,6 +248,9 @@ int pci_get_hp_params(struct pci_dev *dev, struct hotplug_params *hpp)
248 acpi_handle handle, phandle; 248 acpi_handle handle, phandle;
249 struct pci_bus *pbus; 249 struct pci_bus *pbus;
250 250
251 if (acpi_pci_disabled)
252 return -ENODEV;
253
251 handle = NULL; 254 handle = NULL;
252 for (pbus = dev->bus; pbus; pbus = pbus->parent) { 255 for (pbus = dev->bus; pbus; pbus = pbus->parent) {
253 handle = acpi_pci_get_bridge_handle(pbus); 256 handle = acpi_pci_get_bridge_handle(pbus);
diff --git a/drivers/pci/pcie/aer/aerdrv_errprint.c b/drivers/pci/pcie/aer/aerdrv_errprint.c
index c6849d9e86ce..167fe411ce2e 100644
--- a/drivers/pci/pcie/aer/aerdrv_errprint.c
+++ b/drivers/pci/pcie/aer/aerdrv_errprint.c
@@ -132,16 +132,8 @@ static const char *aer_agent_string[] = {
132static void __print_tlp_header(struct pci_dev *dev, 132static void __print_tlp_header(struct pci_dev *dev,
133 struct aer_header_log_regs *t) 133 struct aer_header_log_regs *t)
134{ 134{
135 unsigned char *tlp = (unsigned char *)&t; 135 dev_err(&dev->dev, " TLP Header: %08x %08x %08x %08x\n",
136 136 t->dw0, t->dw1, t->dw2, t->dw3);
137 dev_err(&dev->dev, " TLP Header:"
138 " %02x%02x%02x%02x %02x%02x%02x%02x"
139 " %02x%02x%02x%02x %02x%02x%02x%02x\n",
140 *(tlp + 3), *(tlp + 2), *(tlp + 1), *tlp,
141 *(tlp + 7), *(tlp + 6), *(tlp + 5), *(tlp + 4),
142 *(tlp + 11), *(tlp + 10), *(tlp + 9),
143 *(tlp + 8), *(tlp + 15), *(tlp + 14),
144 *(tlp + 13), *(tlp + 12));
145} 137}
146 138
147static void __aer_print_error(struct pci_dev *dev, 139static void __aer_print_error(struct pci_dev *dev,
diff --git a/drivers/platform/x86/apple-gmux.c b/drivers/platform/x86/apple-gmux.c
index b9429fbf1cd8..66d6d22c239c 100644
--- a/drivers/platform/x86/apple-gmux.c
+++ b/drivers/platform/x86/apple-gmux.c
@@ -624,19 +624,7 @@ static struct pnp_driver gmux_pnp_driver = {
624 }, 624 },
625}; 625};
626 626
627static int __init apple_gmux_init(void) 627module_pnp_driver(gmux_pnp_driver);
628{
629 return pnp_register_driver(&gmux_pnp_driver);
630}
631
632static void __exit apple_gmux_exit(void)
633{
634 pnp_unregister_driver(&gmux_pnp_driver);
635}
636
637module_init(apple_gmux_init);
638module_exit(apple_gmux_exit);
639
640MODULE_AUTHOR("Seth Forshee <seth.forshee@canonical.com>"); 628MODULE_AUTHOR("Seth Forshee <seth.forshee@canonical.com>");
641MODULE_DESCRIPTION("Apple Gmux Driver"); 629MODULE_DESCRIPTION("Apple Gmux Driver");
642MODULE_LICENSE("GPL"); 630MODULE_LICENSE("GPL");
diff --git a/drivers/pnp/base.h b/drivers/pnp/base.h
index c8873b0ca551..3151fd164614 100644
--- a/drivers/pnp/base.h
+++ b/drivers/pnp/base.h
@@ -3,7 +3,7 @@
3 * Bjorn Helgaas <bjorn.helgaas@hp.com> 3 * Bjorn Helgaas <bjorn.helgaas@hp.com>
4 */ 4 */
5 5
6extern spinlock_t pnp_lock; 6extern struct mutex pnp_lock;
7extern const struct attribute_group *pnp_dev_groups[]; 7extern const struct attribute_group *pnp_dev_groups[];
8void *pnp_alloc(long size); 8void *pnp_alloc(long size);
9 9
diff --git a/drivers/pnp/card.c b/drivers/pnp/card.c
index 874c236ac1a7..31ad9fc3f701 100644
--- a/drivers/pnp/card.c
+++ b/drivers/pnp/card.c
@@ -5,6 +5,7 @@
5 */ 5 */
6 6
7#include <linux/module.h> 7#include <linux/module.h>
8#include <linux/mutex.h>
8#include <linux/ctype.h> 9#include <linux/ctype.h>
9#include <linux/slab.h> 10#include <linux/slab.h>
10#include <linux/pnp.h> 11#include <linux/pnp.h>
@@ -244,10 +245,10 @@ int pnp_add_card(struct pnp_card *card)
244 } 245 }
245 246
246 pnp_interface_attach_card(card); 247 pnp_interface_attach_card(card);
247 spin_lock(&pnp_lock); 248 mutex_lock(&pnp_lock);
248 list_add_tail(&card->global_list, &pnp_cards); 249 list_add_tail(&card->global_list, &pnp_cards);
249 list_add_tail(&card->protocol_list, &card->protocol->cards); 250 list_add_tail(&card->protocol_list, &card->protocol->cards);
250 spin_unlock(&pnp_lock); 251 mutex_unlock(&pnp_lock);
251 252
252 /* we wait until now to add devices in order to ensure the drivers 253 /* we wait until now to add devices in order to ensure the drivers
253 * will be able to use all of the related devices on the card 254 * will be able to use all of the related devices on the card
@@ -276,10 +277,10 @@ void pnp_remove_card(struct pnp_card *card)
276 struct list_head *pos, *temp; 277 struct list_head *pos, *temp;
277 278
278 device_unregister(&card->dev); 279 device_unregister(&card->dev);
279 spin_lock(&pnp_lock); 280 mutex_lock(&pnp_lock);
280 list_del(&card->global_list); 281 list_del(&card->global_list);
281 list_del(&card->protocol_list); 282 list_del(&card->protocol_list);
282 spin_unlock(&pnp_lock); 283 mutex_unlock(&pnp_lock);
283 list_for_each_safe(pos, temp, &card->devices) { 284 list_for_each_safe(pos, temp, &card->devices) {
284 struct pnp_dev *dev = card_to_pnp_dev(pos); 285 struct pnp_dev *dev = card_to_pnp_dev(pos);
285 pnp_remove_card_device(dev); 286 pnp_remove_card_device(dev);
@@ -297,10 +298,10 @@ int pnp_add_card_device(struct pnp_card *card, struct pnp_dev *dev)
297 dev->card_link = NULL; 298 dev->card_link = NULL;
298 dev_set_name(&dev->dev, "%02x:%02x.%02x", 299 dev_set_name(&dev->dev, "%02x:%02x.%02x",
299 dev->protocol->number, card->number, dev->number); 300 dev->protocol->number, card->number, dev->number);
300 spin_lock(&pnp_lock); 301 mutex_lock(&pnp_lock);
301 dev->card = card; 302 dev->card = card;
302 list_add_tail(&dev->card_list, &card->devices); 303 list_add_tail(&dev->card_list, &card->devices);
303 spin_unlock(&pnp_lock); 304 mutex_unlock(&pnp_lock);
304 return 0; 305 return 0;
305} 306}
306 307
@@ -310,10 +311,10 @@ int pnp_add_card_device(struct pnp_card *card, struct pnp_dev *dev)
310 */ 311 */
311void pnp_remove_card_device(struct pnp_dev *dev) 312void pnp_remove_card_device(struct pnp_dev *dev)
312{ 313{
313 spin_lock(&pnp_lock); 314 mutex_lock(&pnp_lock);
314 dev->card = NULL; 315 dev->card = NULL;
315 list_del(&dev->card_list); 316 list_del(&dev->card_list);
316 spin_unlock(&pnp_lock); 317 mutex_unlock(&pnp_lock);
317 __pnp_remove_device(dev); 318 __pnp_remove_device(dev);
318} 319}
319 320
@@ -426,9 +427,9 @@ int pnp_register_card_driver(struct pnp_card_driver *drv)
426 if (error < 0) 427 if (error < 0)
427 return error; 428 return error;
428 429
429 spin_lock(&pnp_lock); 430 mutex_lock(&pnp_lock);
430 list_add_tail(&drv->global_list, &pnp_card_drivers); 431 list_add_tail(&drv->global_list, &pnp_card_drivers);
431 spin_unlock(&pnp_lock); 432 mutex_unlock(&pnp_lock);
432 433
433 list_for_each_safe(pos, temp, &pnp_cards) { 434 list_for_each_safe(pos, temp, &pnp_cards) {
434 struct pnp_card *card = 435 struct pnp_card *card =
@@ -444,9 +445,9 @@ int pnp_register_card_driver(struct pnp_card_driver *drv)
444 */ 445 */
445void pnp_unregister_card_driver(struct pnp_card_driver *drv) 446void pnp_unregister_card_driver(struct pnp_card_driver *drv)
446{ 447{
447 spin_lock(&pnp_lock); 448 mutex_lock(&pnp_lock);
448 list_del(&drv->global_list); 449 list_del(&drv->global_list);
449 spin_unlock(&pnp_lock); 450 mutex_unlock(&pnp_lock);
450 pnp_unregister_driver(&drv->link); 451 pnp_unregister_driver(&drv->link);
451} 452}
452 453
diff --git a/drivers/pnp/core.c b/drivers/pnp/core.c
index cb6ce42f8e77..b54620e53830 100644
--- a/drivers/pnp/core.c
+++ b/drivers/pnp/core.c
@@ -9,6 +9,7 @@
9#include <linux/list.h> 9#include <linux/list.h>
10#include <linux/device.h> 10#include <linux/device.h>
11#include <linux/module.h> 11#include <linux/module.h>
12#include <linux/mutex.h>
12#include <linux/init.h> 13#include <linux/init.h>
13#include <linux/string.h> 14#include <linux/string.h>
14#include <linux/slab.h> 15#include <linux/slab.h>
@@ -19,7 +20,7 @@
19 20
20static LIST_HEAD(pnp_protocols); 21static LIST_HEAD(pnp_protocols);
21LIST_HEAD(pnp_global); 22LIST_HEAD(pnp_global);
22DEFINE_SPINLOCK(pnp_lock); 23DEFINE_MUTEX(pnp_lock);
23 24
24/* 25/*
25 * ACPI or PNPBIOS should tell us about all platform devices, so we can 26 * ACPI or PNPBIOS should tell us about all platform devices, so we can
@@ -41,6 +42,13 @@ void *pnp_alloc(long size)
41 return result; 42 return result;
42} 43}
43 44
45static void pnp_remove_protocol(struct pnp_protocol *protocol)
46{
47 mutex_lock(&pnp_lock);
48 list_del(&protocol->protocol_list);
49 mutex_unlock(&pnp_lock);
50}
51
44/** 52/**
45 * pnp_protocol_register - adds a pnp protocol to the pnp layer 53 * pnp_protocol_register - adds a pnp protocol to the pnp layer
46 * @protocol: pointer to the corresponding pnp_protocol structure 54 * @protocol: pointer to the corresponding pnp_protocol structure
@@ -49,13 +57,14 @@ void *pnp_alloc(long size)
49 */ 57 */
50int pnp_register_protocol(struct pnp_protocol *protocol) 58int pnp_register_protocol(struct pnp_protocol *protocol)
51{ 59{
52 int nodenum;
53 struct list_head *pos; 60 struct list_head *pos;
61 int nodenum, ret;
54 62
55 INIT_LIST_HEAD(&protocol->devices); 63 INIT_LIST_HEAD(&protocol->devices);
56 INIT_LIST_HEAD(&protocol->cards); 64 INIT_LIST_HEAD(&protocol->cards);
57 nodenum = 0; 65 nodenum = 0;
58 spin_lock(&pnp_lock); 66
67 mutex_lock(&pnp_lock);
59 68
60 /* assign the lowest unused number */ 69 /* assign the lowest unused number */
61 list_for_each(pos, &pnp_protocols) { 70 list_for_each(pos, &pnp_protocols) {
@@ -66,12 +75,18 @@ int pnp_register_protocol(struct pnp_protocol *protocol)
66 } 75 }
67 } 76 }
68 77
69 list_add_tail(&protocol->protocol_list, &pnp_protocols);
70 spin_unlock(&pnp_lock);
71
72 protocol->number = nodenum; 78 protocol->number = nodenum;
73 dev_set_name(&protocol->dev, "pnp%d", nodenum); 79 dev_set_name(&protocol->dev, "pnp%d", nodenum);
74 return device_register(&protocol->dev); 80
81 list_add_tail(&protocol->protocol_list, &pnp_protocols);
82
83 mutex_unlock(&pnp_lock);
84
85 ret = device_register(&protocol->dev);
86 if (ret)
87 pnp_remove_protocol(protocol);
88
89 return ret;
75} 90}
76 91
77/** 92/**
@@ -80,9 +95,7 @@ int pnp_register_protocol(struct pnp_protocol *protocol)
80 */ 95 */
81void pnp_unregister_protocol(struct pnp_protocol *protocol) 96void pnp_unregister_protocol(struct pnp_protocol *protocol)
82{ 97{
83 spin_lock(&pnp_lock); 98 pnp_remove_protocol(protocol);
84 list_del(&protocol->protocol_list);
85 spin_unlock(&pnp_lock);
86 device_unregister(&protocol->dev); 99 device_unregister(&protocol->dev);
87} 100}
88 101
@@ -157,18 +170,36 @@ struct pnp_dev *pnp_alloc_dev(struct pnp_protocol *protocol, int id,
157 return dev; 170 return dev;
158} 171}
159 172
173static void pnp_delist_device(struct pnp_dev *dev)
174{
175 mutex_lock(&pnp_lock);
176 list_del(&dev->global_list);
177 list_del(&dev->protocol_list);
178 mutex_unlock(&pnp_lock);
179}
180
160int __pnp_add_device(struct pnp_dev *dev) 181int __pnp_add_device(struct pnp_dev *dev)
161{ 182{
183 int ret;
184
162 pnp_fixup_device(dev); 185 pnp_fixup_device(dev);
163 dev->status = PNP_READY; 186 dev->status = PNP_READY;
164 spin_lock(&pnp_lock); 187
188 mutex_lock(&pnp_lock);
189
165 list_add_tail(&dev->global_list, &pnp_global); 190 list_add_tail(&dev->global_list, &pnp_global);
166 list_add_tail(&dev->protocol_list, &dev->protocol->devices); 191 list_add_tail(&dev->protocol_list, &dev->protocol->devices);
167 spin_unlock(&pnp_lock); 192
168 if (dev->protocol->can_wakeup) 193 mutex_unlock(&pnp_lock);
194
195 ret = device_register(&dev->dev);
196 if (ret)
197 pnp_delist_device(dev);
198 else if (dev->protocol->can_wakeup)
169 device_set_wakeup_capable(&dev->dev, 199 device_set_wakeup_capable(&dev->dev,
170 dev->protocol->can_wakeup(dev)); 200 dev->protocol->can_wakeup(dev));
171 return device_register(&dev->dev); 201
202 return ret;
172} 203}
173 204
174/* 205/*
@@ -203,10 +234,7 @@ int pnp_add_device(struct pnp_dev *dev)
203 234
204void __pnp_remove_device(struct pnp_dev *dev) 235void __pnp_remove_device(struct pnp_dev *dev)
205{ 236{
206 spin_lock(&pnp_lock); 237 pnp_delist_device(dev);
207 list_del(&dev->global_list);
208 list_del(&dev->protocol_list);
209 spin_unlock(&pnp_lock);
210 device_unregister(&dev->dev); 238 device_unregister(&dev->dev);
211} 239}
212 240
diff --git a/drivers/pnp/driver.c b/drivers/pnp/driver.c
index 4e57d3370368..153a493b5413 100644
--- a/drivers/pnp/driver.c
+++ b/drivers/pnp/driver.c
@@ -58,22 +58,22 @@ static const struct pnp_device_id *match_device(struct pnp_driver *drv,
58 58
59int pnp_device_attach(struct pnp_dev *pnp_dev) 59int pnp_device_attach(struct pnp_dev *pnp_dev)
60{ 60{
61 spin_lock(&pnp_lock); 61 mutex_lock(&pnp_lock);
62 if (pnp_dev->status != PNP_READY) { 62 if (pnp_dev->status != PNP_READY) {
63 spin_unlock(&pnp_lock); 63 mutex_unlock(&pnp_lock);
64 return -EBUSY; 64 return -EBUSY;
65 } 65 }
66 pnp_dev->status = PNP_ATTACHED; 66 pnp_dev->status = PNP_ATTACHED;
67 spin_unlock(&pnp_lock); 67 mutex_unlock(&pnp_lock);
68 return 0; 68 return 0;
69} 69}
70 70
71void pnp_device_detach(struct pnp_dev *pnp_dev) 71void pnp_device_detach(struct pnp_dev *pnp_dev)
72{ 72{
73 spin_lock(&pnp_lock); 73 mutex_lock(&pnp_lock);
74 if (pnp_dev->status == PNP_ATTACHED) 74 if (pnp_dev->status == PNP_ATTACHED)
75 pnp_dev->status = PNP_READY; 75 pnp_dev->status = PNP_READY;
76 spin_unlock(&pnp_lock); 76 mutex_unlock(&pnp_lock);
77 pnp_disable_dev(pnp_dev); 77 pnp_disable_dev(pnp_dev);
78} 78}
79 79
diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c
index d2b780aade89..5153d1d69aee 100644
--- a/drivers/pnp/pnpacpi/core.c
+++ b/drivers/pnp/pnpacpi/core.c
@@ -248,6 +248,7 @@ static int __init pnpacpi_add_device(struct acpi_device *device)
248 if (!dev) 248 if (!dev)
249 return -ENOMEM; 249 return -ENOMEM;
250 250
251 ACPI_COMPANION_SET(&dev->dev, device);
251 dev->data = device; 252 dev->data = device;
252 /* .enabled means the device can decode the resources */ 253 /* .enabled means the device can decode the resources */
253 dev->active = device->status.enabled; 254 dev->active = device->status.enabled;
@@ -290,11 +291,9 @@ static int __init pnpacpi_add_device(struct acpi_device *device)
290 return error; 291 return error;
291 } 292 }
292 293
293 error = acpi_bind_one(&dev->dev, device);
294
295 num++; 294 num++;
296 295
297 return error; 296 return 0;
298} 297}
299 298
300static acpi_status __init pnpacpi_add_device_handler(acpi_handle handle, 299static acpi_status __init pnpacpi_add_device_handler(acpi_handle handle,
diff --git a/drivers/powercap/intel_rapl.c b/drivers/powercap/intel_rapl.c
index 63d4033eb683..e03877c4b195 100644
--- a/drivers/powercap/intel_rapl.c
+++ b/drivers/powercap/intel_rapl.c
@@ -1054,7 +1054,7 @@ static const struct rapl_defaults rapl_defaults_atom = {
1054 .driver_data = (kernel_ulong_t)&_ops, \ 1054 .driver_data = (kernel_ulong_t)&_ops, \
1055 } 1055 }
1056 1056
1057static const struct x86_cpu_id rapl_ids[] = { 1057static const struct x86_cpu_id rapl_ids[] __initconst = {
1058 RAPL_CPU(0x2a, rapl_defaults_core),/* Sandy Bridge */ 1058 RAPL_CPU(0x2a, rapl_defaults_core),/* Sandy Bridge */
1059 RAPL_CPU(0x2d, rapl_defaults_core),/* Sandy Bridge EP */ 1059 RAPL_CPU(0x2d, rapl_defaults_core),/* Sandy Bridge EP */
1060 RAPL_CPU(0x37, rapl_defaults_atom),/* Valleyview */ 1060 RAPL_CPU(0x37, rapl_defaults_atom),/* Valleyview */
@@ -1062,6 +1062,7 @@ static const struct x86_cpu_id rapl_ids[] = {
1062 RAPL_CPU(0x3c, rapl_defaults_core),/* Haswell */ 1062 RAPL_CPU(0x3c, rapl_defaults_core),/* Haswell */
1063 RAPL_CPU(0x3d, rapl_defaults_core),/* Broadwell */ 1063 RAPL_CPU(0x3d, rapl_defaults_core),/* Broadwell */
1064 RAPL_CPU(0x3f, rapl_defaults_hsw_server),/* Haswell servers */ 1064 RAPL_CPU(0x3f, rapl_defaults_hsw_server),/* Haswell servers */
1065 RAPL_CPU(0x4f, rapl_defaults_hsw_server),/* Broadwell servers */
1065 RAPL_CPU(0x45, rapl_defaults_core),/* Haswell ULT */ 1066 RAPL_CPU(0x45, rapl_defaults_core),/* Haswell ULT */
1066 RAPL_CPU(0x4C, rapl_defaults_atom),/* Braswell */ 1067 RAPL_CPU(0x4C, rapl_defaults_atom),/* Braswell */
1067 RAPL_CPU(0x4A, rapl_defaults_atom),/* Tangier */ 1068 RAPL_CPU(0x4A, rapl_defaults_atom),/* Tangier */
diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index a7cc61837818..923a2b5a2439 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -5734,9 +5734,9 @@ free_port:
5734hba_free: 5734hba_free:
5735 if (phba->msix_enabled) 5735 if (phba->msix_enabled)
5736 pci_disable_msix(phba->pcidev); 5736 pci_disable_msix(phba->pcidev);
5737 iscsi_host_remove(phba->shost);
5738 pci_dev_put(phba->pcidev); 5737 pci_dev_put(phba->pcidev);
5739 iscsi_host_free(phba->shost); 5738 iscsi_host_free(phba->shost);
5739 pci_set_drvdata(pcidev, NULL);
5740disable_pci: 5740disable_pci:
5741 pci_disable_device(pcidev); 5741 pci_disable_device(pcidev);
5742 return ret; 5742 return ret;
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 54d7a6cbb98a..b1a263137a23 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1311,9 +1311,11 @@ scsi_prep_state_check(struct scsi_device *sdev, struct request *req)
1311 "rejecting I/O to dead device\n"); 1311 "rejecting I/O to dead device\n");
1312 ret = BLKPREP_KILL; 1312 ret = BLKPREP_KILL;
1313 break; 1313 break;
1314 case SDEV_QUIESCE:
1315 case SDEV_BLOCK: 1314 case SDEV_BLOCK:
1316 case SDEV_CREATED_BLOCK: 1315 case SDEV_CREATED_BLOCK:
1316 ret = BLKPREP_DEFER;
1317 break;
1318 case SDEV_QUIESCE:
1317 /* 1319 /*
1318 * If the devices is blocked we defer normal commands. 1320 * If the devices is blocked we defer normal commands.
1319 */ 1321 */
diff --git a/drivers/staging/iio/Kconfig b/drivers/staging/iio/Kconfig
index 24183028bd71..6d5b38d69578 100644
--- a/drivers/staging/iio/Kconfig
+++ b/drivers/staging/iio/Kconfig
@@ -38,6 +38,7 @@ config IIO_SIMPLE_DUMMY_EVENTS
38config IIO_SIMPLE_DUMMY_BUFFER 38config IIO_SIMPLE_DUMMY_BUFFER
39 bool "Buffered capture support" 39 bool "Buffered capture support"
40 select IIO_BUFFER 40 select IIO_BUFFER
41 select IIO_TRIGGER
41 select IIO_KFIFO_BUF 42 select IIO_KFIFO_BUF
42 help 43 help
43 Add buffered data capture to the simple dummy driver. 44 Add buffered data capture to the simple dummy driver.
diff --git a/drivers/staging/iio/magnetometer/hmc5843_core.c b/drivers/staging/iio/magnetometer/hmc5843_core.c
index fd171d8b38fb..90cc18b703cf 100644
--- a/drivers/staging/iio/magnetometer/hmc5843_core.c
+++ b/drivers/staging/iio/magnetometer/hmc5843_core.c
@@ -592,6 +592,7 @@ int hmc5843_common_probe(struct device *dev, struct regmap *regmap,
592 mutex_init(&data->lock); 592 mutex_init(&data->lock);
593 593
594 indio_dev->dev.parent = dev; 594 indio_dev->dev.parent = dev;
595 indio_dev->name = dev->driver->name;
595 indio_dev->info = &hmc5843_info; 596 indio_dev->info = &hmc5843_info;
596 indio_dev->modes = INDIO_DIRECT_MODE; 597 indio_dev->modes = INDIO_DIRECT_MODE;
597 indio_dev->channels = data->variant->channels; 598 indio_dev->channels = data->variant->channels;
diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
index 2accb6e47beb..77d64251af40 100644
--- a/drivers/target/iscsi/iscsi_target.c
+++ b/drivers/target/iscsi/iscsi_target.c
@@ -1181,7 +1181,7 @@ iscsit_handle_scsi_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd,
1181 * traditional iSCSI block I/O. 1181 * traditional iSCSI block I/O.
1182 */ 1182 */
1183 if (iscsit_allocate_iovecs(cmd) < 0) { 1183 if (iscsit_allocate_iovecs(cmd) < 0) {
1184 return iscsit_add_reject_cmd(cmd, 1184 return iscsit_reject_cmd(cmd,
1185 ISCSI_REASON_BOOKMARK_NO_RESOURCES, buf); 1185 ISCSI_REASON_BOOKMARK_NO_RESOURCES, buf);
1186 } 1186 }
1187 immed_data = cmd->immediate_data; 1187 immed_data = cmd->immediate_data;
@@ -3468,6 +3468,7 @@ iscsit_build_sendtargets_response(struct iscsi_cmd *cmd,
3468 tpg_np_list) { 3468 tpg_np_list) {
3469 struct iscsi_np *np = tpg_np->tpg_np; 3469 struct iscsi_np *np = tpg_np->tpg_np;
3470 bool inaddr_any = iscsit_check_inaddr_any(np); 3470 bool inaddr_any = iscsit_check_inaddr_any(np);
3471 char *fmt_str;
3471 3472
3472 if (np->np_network_transport != network_transport) 3473 if (np->np_network_transport != network_transport)
3473 continue; 3474 continue;
@@ -3495,8 +3496,12 @@ iscsit_build_sendtargets_response(struct iscsi_cmd *cmd,
3495 } 3496 }
3496 } 3497 }
3497 3498
3498 len = sprintf(buf, "TargetAddress=" 3499 if (np->np_sockaddr.ss_family == AF_INET6)
3499 "%s:%hu,%hu", 3500 fmt_str = "TargetAddress=[%s]:%hu,%hu";
3501 else
3502 fmt_str = "TargetAddress=%s:%hu,%hu";
3503
3504 len = sprintf(buf, fmt_str,
3500 inaddr_any ? conn->local_ip : np->np_ip, 3505 inaddr_any ? conn->local_ip : np->np_ip,
3501 np->np_port, 3506 np->np_port,
3502 tpg->tpgt); 3507 tpg->tpgt);
diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
index 79b4ec3ca2db..7faa6aef9a4d 100644
--- a/drivers/target/target_core_device.c
+++ b/drivers/target/target_core_device.c
@@ -781,8 +781,8 @@ int se_dev_set_emulate_fua_write(struct se_device *dev, int flag)
781 } 781 }
782 if (flag && 782 if (flag &&
783 dev->transport->get_write_cache) { 783 dev->transport->get_write_cache) {
784 pr_err("emulate_fua_write not supported for this device\n"); 784 pr_warn("emulate_fua_write not supported for this device, ignoring\n");
785 return -EINVAL; 785 return 0;
786 } 786 }
787 if (dev->export_count) { 787 if (dev->export_count) {
788 pr_err("emulate_fua_write cannot be changed with active" 788 pr_err("emulate_fua_write cannot be changed with active"
diff --git a/drivers/thermal/st/st_thermal.c b/drivers/thermal/st/st_thermal.c
index d1ec5804c0bb..76c515dd802b 100644
--- a/drivers/thermal/st/st_thermal.c
+++ b/drivers/thermal/st/st_thermal.c
@@ -25,7 +25,7 @@
25 * Function to allocate regfields which are common 25 * Function to allocate regfields which are common
26 * between syscfg and memory mapped based sensors 26 * between syscfg and memory mapped based sensors
27 */ 27 */
28int st_thermal_alloc_regfields(struct st_thermal_sensor *sensor) 28static int st_thermal_alloc_regfields(struct st_thermal_sensor *sensor)
29{ 29{
30 struct device *dev = sensor->dev; 30 struct device *dev = sensor->dev;
31 struct regmap *regmap = sensor->regmap; 31 struct regmap *regmap = sensor->regmap;
diff --git a/drivers/thermal/st/st_thermal_memmap.c b/drivers/thermal/st/st_thermal_memmap.c
index 067bfcdb91d6..fc0c9e198710 100644
--- a/drivers/thermal/st/st_thermal_memmap.c
+++ b/drivers/thermal/st/st_thermal_memmap.c
@@ -157,7 +157,7 @@ static const struct st_thermal_sensor_ops st_mmap_sensor_ops = {
157}; 157};
158 158
159/* Compatible device data stih416 mpe thermal sensor */ 159/* Compatible device data stih416 mpe thermal sensor */
160const struct st_thermal_compat_data st_416mpe_cdata = { 160static const struct st_thermal_compat_data st_416mpe_cdata = {
161 .reg_fields = st_mmap_thermal_regfields, 161 .reg_fields = st_mmap_thermal_regfields,
162 .ops = &st_mmap_sensor_ops, 162 .ops = &st_mmap_sensor_ops,
163 .calibration_val = 14, 163 .calibration_val = 14,
@@ -166,7 +166,7 @@ const struct st_thermal_compat_data st_416mpe_cdata = {
166}; 166};
167 167
168/* Compatible device data stih407 thermal sensor */ 168/* Compatible device data stih407 thermal sensor */
169const struct st_thermal_compat_data st_407_cdata = { 169static const struct st_thermal_compat_data st_407_cdata = {
170 .reg_fields = st_mmap_thermal_regfields, 170 .reg_fields = st_mmap_thermal_regfields,
171 .ops = &st_mmap_sensor_ops, 171 .ops = &st_mmap_sensor_ops,
172 .calibration_val = 16, 172 .calibration_val = 16,
@@ -174,19 +174,19 @@ const struct st_thermal_compat_data st_407_cdata = {
174 .crit_temp = 120, 174 .crit_temp = 120,
175}; 175};
176 176
177static struct of_device_id st_mmap_thermal_of_match[] = { 177static const struct of_device_id st_mmap_thermal_of_match[] = {
178 { .compatible = "st,stih416-mpe-thermal", .data = &st_416mpe_cdata }, 178 { .compatible = "st,stih416-mpe-thermal", .data = &st_416mpe_cdata },
179 { .compatible = "st,stih407-thermal", .data = &st_407_cdata }, 179 { .compatible = "st,stih407-thermal", .data = &st_407_cdata },
180 { /* sentinel */ } 180 { /* sentinel */ }
181}; 181};
182MODULE_DEVICE_TABLE(of, st_mmap_thermal_of_match); 182MODULE_DEVICE_TABLE(of, st_mmap_thermal_of_match);
183 183
184int st_mmap_probe(struct platform_device *pdev) 184static int st_mmap_probe(struct platform_device *pdev)
185{ 185{
186 return st_thermal_register(pdev, st_mmap_thermal_of_match); 186 return st_thermal_register(pdev, st_mmap_thermal_of_match);
187} 187}
188 188
189int st_mmap_remove(struct platform_device *pdev) 189static int st_mmap_remove(struct platform_device *pdev)
190{ 190{
191 return st_thermal_unregister(pdev); 191 return st_thermal_unregister(pdev);
192} 192}
diff --git a/drivers/thermal/st/st_thermal_syscfg.c b/drivers/thermal/st/st_thermal_syscfg.c
index 26d36a242bb8..3df5b7890703 100644
--- a/drivers/thermal/st/st_thermal_syscfg.c
+++ b/drivers/thermal/st/st_thermal_syscfg.c
@@ -104,7 +104,7 @@ static const struct st_thermal_sensor_ops st_syscfg_sensor_ops = {
104}; 104};
105 105
106/* Compatible device data for stih415 sas thermal sensor */ 106/* Compatible device data for stih415 sas thermal sensor */
107const struct st_thermal_compat_data st_415sas_cdata = { 107static const struct st_thermal_compat_data st_415sas_cdata = {
108 .sys_compat = "st,stih415-front-syscfg", 108 .sys_compat = "st,stih415-front-syscfg",
109 .reg_fields = st_415sas_regfields, 109 .reg_fields = st_415sas_regfields,
110 .ops = &st_syscfg_sensor_ops, 110 .ops = &st_syscfg_sensor_ops,
@@ -114,7 +114,7 @@ const struct st_thermal_compat_data st_415sas_cdata = {
114}; 114};
115 115
116/* Compatible device data for stih415 mpe thermal sensor */ 116/* Compatible device data for stih415 mpe thermal sensor */
117const struct st_thermal_compat_data st_415mpe_cdata = { 117static const struct st_thermal_compat_data st_415mpe_cdata = {
118 .sys_compat = "st,stih415-system-syscfg", 118 .sys_compat = "st,stih415-system-syscfg",
119 .reg_fields = st_415mpe_regfields, 119 .reg_fields = st_415mpe_regfields,
120 .ops = &st_syscfg_sensor_ops, 120 .ops = &st_syscfg_sensor_ops,
@@ -124,7 +124,7 @@ const struct st_thermal_compat_data st_415mpe_cdata = {
124}; 124};
125 125
126/* Compatible device data for stih416 sas thermal sensor */ 126/* Compatible device data for stih416 sas thermal sensor */
127const struct st_thermal_compat_data st_416sas_cdata = { 127static const struct st_thermal_compat_data st_416sas_cdata = {
128 .sys_compat = "st,stih416-front-syscfg", 128 .sys_compat = "st,stih416-front-syscfg",
129 .reg_fields = st_416sas_regfields, 129 .reg_fields = st_416sas_regfields,
130 .ops = &st_syscfg_sensor_ops, 130 .ops = &st_syscfg_sensor_ops,
@@ -134,7 +134,7 @@ const struct st_thermal_compat_data st_416sas_cdata = {
134}; 134};
135 135
136/* Compatible device data for stid127 thermal sensor */ 136/* Compatible device data for stid127 thermal sensor */
137const struct st_thermal_compat_data st_127_cdata = { 137static const struct st_thermal_compat_data st_127_cdata = {
138 .sys_compat = "st,stid127-cpu-syscfg", 138 .sys_compat = "st,stid127-cpu-syscfg",
139 .reg_fields = st_127_regfields, 139 .reg_fields = st_127_regfields,
140 .ops = &st_syscfg_sensor_ops, 140 .ops = &st_syscfg_sensor_ops,
@@ -143,7 +143,7 @@ const struct st_thermal_compat_data st_127_cdata = {
143 .crit_temp = 120, 143 .crit_temp = 120,
144}; 144};
145 145
146static struct of_device_id st_syscfg_thermal_of_match[] = { 146static const struct of_device_id st_syscfg_thermal_of_match[] = {
147 { .compatible = "st,stih415-sas-thermal", .data = &st_415sas_cdata }, 147 { .compatible = "st,stih415-sas-thermal", .data = &st_415sas_cdata },
148 { .compatible = "st,stih415-mpe-thermal", .data = &st_415mpe_cdata }, 148 { .compatible = "st,stih415-mpe-thermal", .data = &st_415mpe_cdata },
149 { .compatible = "st,stih416-sas-thermal", .data = &st_416sas_cdata }, 149 { .compatible = "st,stih416-sas-thermal", .data = &st_416sas_cdata },
@@ -152,12 +152,12 @@ static struct of_device_id st_syscfg_thermal_of_match[] = {
152}; 152};
153MODULE_DEVICE_TABLE(of, st_syscfg_thermal_of_match); 153MODULE_DEVICE_TABLE(of, st_syscfg_thermal_of_match);
154 154
155int st_syscfg_probe(struct platform_device *pdev) 155static int st_syscfg_probe(struct platform_device *pdev)
156{ 156{
157 return st_thermal_register(pdev, st_syscfg_thermal_of_match); 157 return st_thermal_register(pdev, st_syscfg_thermal_of_match);
158} 158}
159 159
160int st_syscfg_remove(struct platform_device *pdev) 160static int st_syscfg_remove(struct platform_device *pdev)
161{ 161{
162 return st_thermal_unregister(pdev); 162 return st_thermal_unregister(pdev);
163} 163}
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index 174d3bcf8bd7..4108db7e10c1 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -458,8 +458,10 @@ static void update_temperature(struct thermal_zone_device *tz)
458 458
459 ret = thermal_zone_get_temp(tz, &temp); 459 ret = thermal_zone_get_temp(tz, &temp);
460 if (ret) { 460 if (ret) {
461 dev_warn(&tz->device, "failed to read out thermal zone %d\n", 461 if (ret != -EAGAIN)
462 tz->id); 462 dev_warn(&tz->device,
463 "failed to read out thermal zone (%d)\n",
464 ret);
463 return; 465 return;
464 } 466 }
465 467
diff --git a/drivers/tty/serial/8250/8250_fintek.c b/drivers/tty/serial/8250/8250_fintek.c
index 1e6899bc9429..5815e81b5fc6 100644
--- a/drivers/tty/serial/8250/8250_fintek.c
+++ b/drivers/tty/serial/8250/8250_fintek.c
@@ -234,18 +234,7 @@ static struct pnp_driver fintek_8250_driver = {
234 .id_table = fintek_dev_table, 234 .id_table = fintek_dev_table,
235}; 235};
236 236
237static int fintek_8250_init(void) 237module_pnp_driver(fintek_8250_driver);
238{
239 return pnp_register_driver(&fintek_8250_driver);
240}
241module_init(fintek_8250_init);
242
243static void fintek_8250_exit(void)
244{
245 pnp_unregister_driver(&fintek_8250_driver);
246}
247module_exit(fintek_8250_exit);
248
249MODULE_DESCRIPTION("Fintek F812164 module"); 238MODULE_DESCRIPTION("Fintek F812164 module");
250MODULE_AUTHOR("Ricardo Ribalda <ricardo.ribalda@gmail.com>"); 239MODULE_AUTHOR("Ricardo Ribalda <ricardo.ribalda@gmail.com>");
251MODULE_LICENSE("GPL"); 240MODULE_LICENSE("GPL");
diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
index b1893f3f88f1..3ad1458bfeb0 100644
--- a/drivers/tty/serial/fsl_lpuart.c
+++ b/drivers/tty/serial/fsl_lpuart.c
@@ -921,6 +921,9 @@ static void lpuart_setup_watermark(struct lpuart_port *sport)
921 writeb(val | UARTPFIFO_TXFE | UARTPFIFO_RXFE, 921 writeb(val | UARTPFIFO_TXFE | UARTPFIFO_RXFE,
922 sport->port.membase + UARTPFIFO); 922 sport->port.membase + UARTPFIFO);
923 923
924 /* explicitly clear RDRF */
925 readb(sport->port.membase + UARTSR1);
926
924 /* flush Tx and Rx FIFO */ 927 /* flush Tx and Rx FIFO */
925 writeb(UARTCFIFO_TXFLUSH | UARTCFIFO_RXFLUSH, 928 writeb(UARTCFIFO_TXFLUSH | UARTCFIFO_RXFLUSH,
926 sport->port.membase + UARTCFIFO); 929 sport->port.membase + UARTCFIFO);
@@ -1076,6 +1079,8 @@ static int lpuart_startup(struct uart_port *port)
1076 sport->txfifo_size = 0x1 << (((temp >> UARTPFIFO_TXSIZE_OFF) & 1079 sport->txfifo_size = 0x1 << (((temp >> UARTPFIFO_TXSIZE_OFF) &
1077 UARTPFIFO_FIFOSIZE_MASK) + 1); 1080 UARTPFIFO_FIFOSIZE_MASK) + 1);
1078 1081
1082 sport->port.fifosize = sport->txfifo_size;
1083
1079 sport->rxfifo_size = 0x1 << (((temp >> UARTPFIFO_RXSIZE_OFF) & 1084 sport->rxfifo_size = 0x1 << (((temp >> UARTPFIFO_RXSIZE_OFF) &
1080 UARTPFIFO_FIFOSIZE_MASK) + 1); 1085 UARTPFIFO_FIFOSIZE_MASK) + 1);
1081 1086
diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
index af821a908720..cf08876922f1 100644
--- a/drivers/tty/serial/samsung.c
+++ b/drivers/tty/serial/samsung.c
@@ -963,6 +963,7 @@ static void s3c24xx_serial_shutdown(struct uart_port *port)
963 free_irq(ourport->tx_irq, ourport); 963 free_irq(ourport->tx_irq, ourport);
964 tx_enabled(port) = 0; 964 tx_enabled(port) = 0;
965 ourport->tx_claimed = 0; 965 ourport->tx_claimed = 0;
966 ourport->tx_mode = 0;
966 } 967 }
967 968
968 if (ourport->rx_claimed) { 969 if (ourport->rx_claimed) {
diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
index a7865c4b0498..0827d7c96527 100644
--- a/drivers/usb/host/xhci-hub.c
+++ b/drivers/usb/host/xhci-hub.c
@@ -387,6 +387,10 @@ static void xhci_clear_port_change_bit(struct xhci_hcd *xhci, u16 wValue,
387 status = PORT_PLC; 387 status = PORT_PLC;
388 port_change_bit = "link state"; 388 port_change_bit = "link state";
389 break; 389 break;
390 case USB_PORT_FEAT_C_PORT_CONFIG_ERROR:
391 status = PORT_CEC;
392 port_change_bit = "config error";
393 break;
390 default: 394 default:
391 /* Should never happen */ 395 /* Should never happen */
392 return; 396 return;
@@ -588,6 +592,8 @@ static u32 xhci_get_port_status(struct usb_hcd *hcd,
588 status |= USB_PORT_STAT_C_LINK_STATE << 16; 592 status |= USB_PORT_STAT_C_LINK_STATE << 16;
589 if ((raw_port_status & PORT_WRC)) 593 if ((raw_port_status & PORT_WRC))
590 status |= USB_PORT_STAT_C_BH_RESET << 16; 594 status |= USB_PORT_STAT_C_BH_RESET << 16;
595 if ((raw_port_status & PORT_CEC))
596 status |= USB_PORT_STAT_C_CONFIG_ERROR << 16;
591 } 597 }
592 598
593 if (hcd->speed != HCD_USB3) { 599 if (hcd->speed != HCD_USB3) {
@@ -1005,6 +1011,7 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
1005 case USB_PORT_FEAT_C_OVER_CURRENT: 1011 case USB_PORT_FEAT_C_OVER_CURRENT:
1006 case USB_PORT_FEAT_C_ENABLE: 1012 case USB_PORT_FEAT_C_ENABLE:
1007 case USB_PORT_FEAT_C_PORT_LINK_STATE: 1013 case USB_PORT_FEAT_C_PORT_LINK_STATE:
1014 case USB_PORT_FEAT_C_PORT_CONFIG_ERROR:
1008 xhci_clear_port_change_bit(xhci, wValue, wIndex, 1015 xhci_clear_port_change_bit(xhci, wValue, wIndex,
1009 port_array[wIndex], temp); 1016 port_array[wIndex], temp);
1010 break; 1017 break;
@@ -1069,7 +1076,7 @@ int xhci_hub_status_data(struct usb_hcd *hcd, char *buf)
1069 */ 1076 */
1070 status = bus_state->resuming_ports; 1077 status = bus_state->resuming_ports;
1071 1078
1072 mask = PORT_CSC | PORT_PEC | PORT_OCC | PORT_PLC | PORT_WRC; 1079 mask = PORT_CSC | PORT_PEC | PORT_OCC | PORT_PLC | PORT_WRC | PORT_CEC;
1073 1080
1074 spin_lock_irqsave(&xhci->lock, flags); 1081 spin_lock_irqsave(&xhci->lock, flags);
1075 /* For each port, did anything change? If so, set that bit in buf. */ 1082 /* For each port, did anything change? If so, set that bit in buf. */
diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
index fd53c9ebd662..2af32e26fafc 100644
--- a/drivers/usb/host/xhci-pci.c
+++ b/drivers/usb/host/xhci-pci.c
@@ -115,6 +115,7 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
115 if (pdev->vendor == PCI_VENDOR_ID_INTEL) { 115 if (pdev->vendor == PCI_VENDOR_ID_INTEL) {
116 xhci->quirks |= XHCI_LPM_SUPPORT; 116 xhci->quirks |= XHCI_LPM_SUPPORT;
117 xhci->quirks |= XHCI_INTEL_HOST; 117 xhci->quirks |= XHCI_INTEL_HOST;
118 xhci->quirks |= XHCI_AVOID_BEI;
118 } 119 }
119 if (pdev->vendor == PCI_VENDOR_ID_INTEL && 120 if (pdev->vendor == PCI_VENDOR_ID_INTEL &&
120 pdev->device == PCI_DEVICE_ID_INTEL_PANTHERPOINT_XHCI) { 121 pdev->device == PCI_DEVICE_ID_INTEL_PANTHERPOINT_XHCI) {
@@ -130,7 +131,6 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
130 * PPT chipsets. 131 * PPT chipsets.
131 */ 132 */
132 xhci->quirks |= XHCI_SPURIOUS_REBOOT; 133 xhci->quirks |= XHCI_SPURIOUS_REBOOT;
133 xhci->quirks |= XHCI_AVOID_BEI;
134 } 134 }
135 if (pdev->vendor == PCI_VENDOR_ID_INTEL && 135 if (pdev->vendor == PCI_VENDOR_ID_INTEL &&
136 pdev->device == PCI_DEVICE_ID_INTEL_LYNXPOINT_LP_XHCI) { 136 pdev->device == PCI_DEVICE_ID_INTEL_LYNXPOINT_LP_XHCI) {
diff --git a/drivers/usb/isp1760/isp1760-udc.c b/drivers/usb/isp1760/isp1760-udc.c
index f32c292cc868..3fc4fe770253 100644
--- a/drivers/usb/isp1760/isp1760-udc.c
+++ b/drivers/usb/isp1760/isp1760-udc.c
@@ -1203,7 +1203,7 @@ static int isp1760_udc_start(struct usb_gadget *gadget,
1203 1203
1204 if (udc->driver) { 1204 if (udc->driver) {
1205 dev_err(udc->isp->dev, "UDC already has a gadget driver\n"); 1205 dev_err(udc->isp->dev, "UDC already has a gadget driver\n");
1206 spin_unlock(&udc->lock); 1206 spin_unlock_irqrestore(&udc->lock, flags);
1207 return -EBUSY; 1207 return -EBUSY;
1208 } 1208 }
1209 1209
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 3086dec0ef53..8eb68a31cab6 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -604,6 +604,7 @@ static const struct usb_device_id id_table_combined[] = {
604 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, 604 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
605 { USB_DEVICE(FTDI_VID, FTDI_NT_ORIONLXM_PID), 605 { USB_DEVICE(FTDI_VID, FTDI_NT_ORIONLXM_PID),
606 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, 606 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
607 { USB_DEVICE(FTDI_VID, FTDI_SYNAPSE_SS200_PID) },
607 /* 608 /*
608 * ELV devices: 609 * ELV devices:
609 */ 610 */
@@ -1883,8 +1884,12 @@ static int ftdi_8u2232c_probe(struct usb_serial *serial)
1883{ 1884{
1884 struct usb_device *udev = serial->dev; 1885 struct usb_device *udev = serial->dev;
1885 1886
1886 if ((udev->manufacturer && !strcmp(udev->manufacturer, "CALAO Systems")) || 1887 if (udev->manufacturer && !strcmp(udev->manufacturer, "CALAO Systems"))
1887 (udev->product && !strcmp(udev->product, "BeagleBone/XDS100V2"))) 1888 return ftdi_jtag_probe(serial);
1889
1890 if (udev->product &&
1891 (!strcmp(udev->product, "BeagleBone/XDS100V2") ||
1892 !strcmp(udev->product, "SNAP Connect E10")))
1888 return ftdi_jtag_probe(serial); 1893 return ftdi_jtag_probe(serial);
1889 1894
1890 return 0; 1895 return 0;
diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h
index 56b1b55c4751..4e4f46f3c89c 100644
--- a/drivers/usb/serial/ftdi_sio_ids.h
+++ b/drivers/usb/serial/ftdi_sio_ids.h
@@ -561,6 +561,12 @@
561 */ 561 */
562#define FTDI_NT_ORIONLXM_PID 0x7c90 /* OrionLXm Substation Automation Platform */ 562#define FTDI_NT_ORIONLXM_PID 0x7c90 /* OrionLXm Substation Automation Platform */
563 563
564/*
565 * Synapse Wireless product ids (FTDI_VID)
566 * http://www.synapse-wireless.com
567 */
568#define FTDI_SYNAPSE_SS200_PID 0x9090 /* SS200 - SNAP Stick 200 */
569
564 570
565/********************************/ 571/********************************/
566/** third-party VID/PID combos **/ 572/** third-party VID/PID combos **/
diff --git a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c
index dd97d8b572c3..4f7e072e4e00 100644
--- a/drivers/usb/serial/keyspan_pda.c
+++ b/drivers/usb/serial/keyspan_pda.c
@@ -61,6 +61,7 @@ struct keyspan_pda_private {
61/* For Xircom PGSDB9 and older Entrega version of the same device */ 61/* For Xircom PGSDB9 and older Entrega version of the same device */
62#define XIRCOM_VENDOR_ID 0x085a 62#define XIRCOM_VENDOR_ID 0x085a
63#define XIRCOM_FAKE_ID 0x8027 63#define XIRCOM_FAKE_ID 0x8027
64#define XIRCOM_FAKE_ID_2 0x8025 /* "PGMFHUB" serial */
64#define ENTREGA_VENDOR_ID 0x1645 65#define ENTREGA_VENDOR_ID 0x1645
65#define ENTREGA_FAKE_ID 0x8093 66#define ENTREGA_FAKE_ID 0x8093
66 67
@@ -70,6 +71,7 @@ static const struct usb_device_id id_table_combined[] = {
70#endif 71#endif
71#ifdef XIRCOM 72#ifdef XIRCOM
72 { USB_DEVICE(XIRCOM_VENDOR_ID, XIRCOM_FAKE_ID) }, 73 { USB_DEVICE(XIRCOM_VENDOR_ID, XIRCOM_FAKE_ID) },
74 { USB_DEVICE(XIRCOM_VENDOR_ID, XIRCOM_FAKE_ID_2) },
73 { USB_DEVICE(ENTREGA_VENDOR_ID, ENTREGA_FAKE_ID) }, 75 { USB_DEVICE(ENTREGA_VENDOR_ID, ENTREGA_FAKE_ID) },
74#endif 76#endif
75 { USB_DEVICE(KEYSPAN_VENDOR_ID, KEYSPAN_PDA_ID) }, 77 { USB_DEVICE(KEYSPAN_VENDOR_ID, KEYSPAN_PDA_ID) },
@@ -93,6 +95,7 @@ static const struct usb_device_id id_table_fake[] = {
93#ifdef XIRCOM 95#ifdef XIRCOM
94static const struct usb_device_id id_table_fake_xircom[] = { 96static const struct usb_device_id id_table_fake_xircom[] = {
95 { USB_DEVICE(XIRCOM_VENDOR_ID, XIRCOM_FAKE_ID) }, 97 { USB_DEVICE(XIRCOM_VENDOR_ID, XIRCOM_FAKE_ID) },
98 { USB_DEVICE(XIRCOM_VENDOR_ID, XIRCOM_FAKE_ID_2) },
96 { USB_DEVICE(ENTREGA_VENDOR_ID, ENTREGA_FAKE_ID) }, 99 { USB_DEVICE(ENTREGA_VENDOR_ID, ENTREGA_FAKE_ID) },
97 { } 100 { }
98}; 101};
diff --git a/drivers/watchdog/iTCO_wdt.c b/drivers/watchdog/iTCO_wdt.c
index 05ee0bf88ce9..3c3fd417ddeb 100644
--- a/drivers/watchdog/iTCO_wdt.c
+++ b/drivers/watchdog/iTCO_wdt.c
@@ -51,6 +51,7 @@
51#define DRV_VERSION "1.11" 51#define DRV_VERSION "1.11"
52 52
53/* Includes */ 53/* Includes */
54#include <linux/acpi.h> /* For ACPI support */
54#include <linux/module.h> /* For module specific items */ 55#include <linux/module.h> /* For module specific items */
55#include <linux/moduleparam.h> /* For new moduleparam's */ 56#include <linux/moduleparam.h> /* For new moduleparam's */
56#include <linux/types.h> /* For standard types (like size_t) */ 57#include <linux/types.h> /* For standard types (like size_t) */
@@ -103,6 +104,8 @@ static struct { /* this is private data for the iTCO_wdt device */
103 struct platform_device *dev; 104 struct platform_device *dev;
104 /* the PCI-device */ 105 /* the PCI-device */
105 struct pci_dev *pdev; 106 struct pci_dev *pdev;
107 /* whether or not the watchdog has been suspended */
108 bool suspended;
106} iTCO_wdt_private; 109} iTCO_wdt_private;
107 110
108/* module parameters */ 111/* module parameters */
@@ -571,12 +574,60 @@ static void iTCO_wdt_shutdown(struct platform_device *dev)
571 iTCO_wdt_stop(NULL); 574 iTCO_wdt_stop(NULL);
572} 575}
573 576
577#ifdef CONFIG_PM_SLEEP
578/*
579 * Suspend-to-idle requires this, because it stops the ticks and timekeeping, so
580 * the watchdog cannot be pinged while in that state. In ACPI sleep states the
581 * watchdog is stopped by the platform firmware.
582 */
583
584#ifdef CONFIG_ACPI
585static inline bool need_suspend(void)
586{
587 return acpi_target_system_state() == ACPI_STATE_S0;
588}
589#else
590static inline bool need_suspend(void) { return true; }
591#endif
592
593static int iTCO_wdt_suspend_noirq(struct device *dev)
594{
595 int ret = 0;
596
597 iTCO_wdt_private.suspended = false;
598 if (watchdog_active(&iTCO_wdt_watchdog_dev) && need_suspend()) {
599 ret = iTCO_wdt_stop(&iTCO_wdt_watchdog_dev);
600 if (!ret)
601 iTCO_wdt_private.suspended = true;
602 }
603 return ret;
604}
605
606static int iTCO_wdt_resume_noirq(struct device *dev)
607{
608 if (iTCO_wdt_private.suspended)
609 iTCO_wdt_start(&iTCO_wdt_watchdog_dev);
610
611 return 0;
612}
613
614static struct dev_pm_ops iTCO_wdt_pm = {
615 .suspend_noirq = iTCO_wdt_suspend_noirq,
616 .resume_noirq = iTCO_wdt_resume_noirq,
617};
618
619#define ITCO_WDT_PM_OPS (&iTCO_wdt_pm)
620#else
621#define ITCO_WDT_PM_OPS NULL
622#endif /* CONFIG_PM_SLEEP */
623
574static struct platform_driver iTCO_wdt_driver = { 624static struct platform_driver iTCO_wdt_driver = {
575 .probe = iTCO_wdt_probe, 625 .probe = iTCO_wdt_probe,
576 .remove = iTCO_wdt_remove, 626 .remove = iTCO_wdt_remove,
577 .shutdown = iTCO_wdt_shutdown, 627 .shutdown = iTCO_wdt_shutdown,
578 .driver = { 628 .driver = {
579 .name = DRV_NAME, 629 .name = DRV_NAME,
630 .pm = ITCO_WDT_PM_OPS,
580 }, 631 },
581}; 632};
582 633
diff --git a/drivers/xen/Kconfig b/drivers/xen/Kconfig
index b812462083fc..94d96809e686 100644
--- a/drivers/xen/Kconfig
+++ b/drivers/xen/Kconfig
@@ -55,6 +55,23 @@ config XEN_BALLOON_MEMORY_HOTPLUG
55 55
56 In that case step 3 should be omitted. 56 In that case step 3 should be omitted.
57 57
58config XEN_BALLOON_MEMORY_HOTPLUG_LIMIT
59 int "Hotplugged memory limit (in GiB) for a PV guest"
60 default 512 if X86_64
61 default 4 if X86_32
62 range 0 64 if X86_32
63 depends on XEN_HAVE_PVMMU
64 depends on XEN_BALLOON_MEMORY_HOTPLUG
65 help
66 Maxmium amount of memory (in GiB) that a PV guest can be
67 expanded to when using memory hotplug.
68
69 A PV guest can have more memory than this limit if is
70 started with a larger maximum.
71
72 This value is used to allocate enough space in internal
73 tables needed for physical memory administration.
74
58config XEN_SCRUB_PAGES 75config XEN_SCRUB_PAGES
59 bool "Scrub pages before returning them to system" 76 bool "Scrub pages before returning them to system"
60 depends on XEN_BALLOON 77 depends on XEN_BALLOON
diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c
index 0b52d92cb2e5..fd933695f232 100644
--- a/drivers/xen/balloon.c
+++ b/drivers/xen/balloon.c
@@ -229,6 +229,29 @@ static enum bp_state reserve_additional_memory(long credit)
229 balloon_hotplug = round_up(balloon_hotplug, PAGES_PER_SECTION); 229 balloon_hotplug = round_up(balloon_hotplug, PAGES_PER_SECTION);
230 nid = memory_add_physaddr_to_nid(hotplug_start_paddr); 230 nid = memory_add_physaddr_to_nid(hotplug_start_paddr);
231 231
232#ifdef CONFIG_XEN_HAVE_PVMMU
233 /*
234 * add_memory() will build page tables for the new memory so
235 * the p2m must contain invalid entries so the correct
236 * non-present PTEs will be written.
237 *
238 * If a failure occurs, the original (identity) p2m entries
239 * are not restored since this region is now known not to
240 * conflict with any devices.
241 */
242 if (!xen_feature(XENFEAT_auto_translated_physmap)) {
243 unsigned long pfn, i;
244
245 pfn = PFN_DOWN(hotplug_start_paddr);
246 for (i = 0; i < balloon_hotplug; i++) {
247 if (!set_phys_to_machine(pfn + i, INVALID_P2M_ENTRY)) {
248 pr_warn("set_phys_to_machine() failed, no memory added\n");
249 return BP_ECANCELED;
250 }
251 }
252 }
253#endif
254
232 rc = add_memory(nid, hotplug_start_paddr, balloon_hotplug << PAGE_SHIFT); 255 rc = add_memory(nid, hotplug_start_paddr, balloon_hotplug << PAGE_SHIFT);
233 256
234 if (rc) { 257 if (rc) {
diff --git a/fs/aio.c b/fs/aio.c
index f8e52a1854c1..a793f7023755 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -278,11 +278,11 @@ static int aio_ring_mmap(struct file *file, struct vm_area_struct *vma)
278 return 0; 278 return 0;
279} 279}
280 280
281static void aio_ring_remap(struct file *file, struct vm_area_struct *vma) 281static int aio_ring_remap(struct file *file, struct vm_area_struct *vma)
282{ 282{
283 struct mm_struct *mm = vma->vm_mm; 283 struct mm_struct *mm = vma->vm_mm;
284 struct kioctx_table *table; 284 struct kioctx_table *table;
285 int i; 285 int i, res = -EINVAL;
286 286
287 spin_lock(&mm->ioctx_lock); 287 spin_lock(&mm->ioctx_lock);
288 rcu_read_lock(); 288 rcu_read_lock();
@@ -292,13 +292,17 @@ static void aio_ring_remap(struct file *file, struct vm_area_struct *vma)
292 292
293 ctx = table->table[i]; 293 ctx = table->table[i];
294 if (ctx && ctx->aio_ring_file == file) { 294 if (ctx && ctx->aio_ring_file == file) {
295 ctx->user_id = ctx->mmap_base = vma->vm_start; 295 if (!atomic_read(&ctx->dead)) {
296 ctx->user_id = ctx->mmap_base = vma->vm_start;
297 res = 0;
298 }
296 break; 299 break;
297 } 300 }
298 } 301 }
299 302
300 rcu_read_unlock(); 303 rcu_read_unlock();
301 spin_unlock(&mm->ioctx_lock); 304 spin_unlock(&mm->ioctx_lock);
305 return res;
302} 306}
303 307
304static const struct file_operations aio_ring_fops = { 308static const struct file_operations aio_ring_fops = {
@@ -727,6 +731,9 @@ static struct kioctx *ioctx_alloc(unsigned nr_events)
727err_cleanup: 731err_cleanup:
728 aio_nr_sub(ctx->max_reqs); 732 aio_nr_sub(ctx->max_reqs);
729err_ctx: 733err_ctx:
734 atomic_set(&ctx->dead, 1);
735 if (ctx->mmap_size)
736 vm_munmap(ctx->mmap_base, ctx->mmap_size);
730 aio_free_ring(ctx); 737 aio_free_ring(ctx);
731err: 738err:
732 mutex_unlock(&ctx->ring_lock); 739 mutex_unlock(&ctx->ring_lock);
@@ -748,11 +755,12 @@ static int kill_ioctx(struct mm_struct *mm, struct kioctx *ctx,
748{ 755{
749 struct kioctx_table *table; 756 struct kioctx_table *table;
750 757
751 if (atomic_xchg(&ctx->dead, 1)) 758 spin_lock(&mm->ioctx_lock);
759 if (atomic_xchg(&ctx->dead, 1)) {
760 spin_unlock(&mm->ioctx_lock);
752 return -EINVAL; 761 return -EINVAL;
762 }
753 763
754
755 spin_lock(&mm->ioctx_lock);
756 table = rcu_dereference_raw(mm->ioctx_table); 764 table = rcu_dereference_raw(mm->ioctx_table);
757 WARN_ON(ctx != table->table[ctx->id]); 765 WARN_ON(ctx != table->table[ctx->id]);
758 table->table[ctx->id] = NULL; 766 table->table[ctx->id] = NULL;
diff --git a/fs/cifs/cifsencrypt.c b/fs/cifs/cifsencrypt.c
index 4ac7445e6ec7..aa0dc2573374 100644
--- a/fs/cifs/cifsencrypt.c
+++ b/fs/cifs/cifsencrypt.c
@@ -1,6 +1,9 @@
1/* 1/*
2 * fs/cifs/cifsencrypt.c 2 * fs/cifs/cifsencrypt.c
3 * 3 *
4 * Encryption and hashing operations relating to NTLM, NTLMv2. See MS-NLMP
5 * for more detailed information
6 *
4 * Copyright (C) International Business Machines Corp., 2005,2013 7 * Copyright (C) International Business Machines Corp., 2005,2013
5 * Author(s): Steve French (sfrench@us.ibm.com) 8 * Author(s): Steve French (sfrench@us.ibm.com)
6 * 9 *
@@ -515,7 +518,8 @@ static int calc_ntlmv2_hash(struct cifs_ses *ses, char *ntlmv2_hash,
515 __func__); 518 __func__);
516 return rc; 519 return rc;
517 } 520 }
518 } else if (ses->serverName) { 521 } else {
522 /* We use ses->serverName if no domain name available */
519 len = strlen(ses->serverName); 523 len = strlen(ses->serverName);
520 524
521 server = kmalloc(2 + (len * 2), GFP_KERNEL); 525 server = kmalloc(2 + (len * 2), GFP_KERNEL);
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index d3aa999ab785..480cf9c81d50 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -1599,6 +1599,8 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
1599 pr_warn("CIFS: username too long\n"); 1599 pr_warn("CIFS: username too long\n");
1600 goto cifs_parse_mount_err; 1600 goto cifs_parse_mount_err;
1601 } 1601 }
1602
1603 kfree(vol->username);
1602 vol->username = kstrdup(string, GFP_KERNEL); 1604 vol->username = kstrdup(string, GFP_KERNEL);
1603 if (!vol->username) 1605 if (!vol->username)
1604 goto cifs_parse_mount_err; 1606 goto cifs_parse_mount_err;
@@ -1700,6 +1702,7 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
1700 goto cifs_parse_mount_err; 1702 goto cifs_parse_mount_err;
1701 } 1703 }
1702 1704
1705 kfree(vol->domainname);
1703 vol->domainname = kstrdup(string, GFP_KERNEL); 1706 vol->domainname = kstrdup(string, GFP_KERNEL);
1704 if (!vol->domainname) { 1707 if (!vol->domainname) {
1705 pr_warn("CIFS: no memory for domainname\n"); 1708 pr_warn("CIFS: no memory for domainname\n");
@@ -1731,6 +1734,7 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
1731 } 1734 }
1732 1735
1733 if (strncasecmp(string, "default", 7) != 0) { 1736 if (strncasecmp(string, "default", 7) != 0) {
1737 kfree(vol->iocharset);
1734 vol->iocharset = kstrdup(string, 1738 vol->iocharset = kstrdup(string,
1735 GFP_KERNEL); 1739 GFP_KERNEL);
1736 if (!vol->iocharset) { 1740 if (!vol->iocharset) {
@@ -2913,8 +2917,7 @@ ip_rfc1001_connect(struct TCP_Server_Info *server)
2913 * calling name ends in null (byte 16) from old smb 2917 * calling name ends in null (byte 16) from old smb
2914 * convention. 2918 * convention.
2915 */ 2919 */
2916 if (server->workstation_RFC1001_name && 2920 if (server->workstation_RFC1001_name[0] != 0)
2917 server->workstation_RFC1001_name[0] != 0)
2918 rfc1002mangle(ses_init_buf->trailer. 2921 rfc1002mangle(ses_init_buf->trailer.
2919 session_req.calling_name, 2922 session_req.calling_name,
2920 server->workstation_RFC1001_name, 2923 server->workstation_RFC1001_name,
@@ -3692,6 +3695,12 @@ CIFSTCon(const unsigned int xid, struct cifs_ses *ses,
3692#endif /* CIFS_WEAK_PW_HASH */ 3695#endif /* CIFS_WEAK_PW_HASH */
3693 rc = SMBNTencrypt(tcon->password, ses->server->cryptkey, 3696 rc = SMBNTencrypt(tcon->password, ses->server->cryptkey,
3694 bcc_ptr, nls_codepage); 3697 bcc_ptr, nls_codepage);
3698 if (rc) {
3699 cifs_dbg(FYI, "%s Can't generate NTLM rsp. Error: %d\n",
3700 __func__, rc);
3701 cifs_buf_release(smb_buffer);
3702 return rc;
3703 }
3695 3704
3696 bcc_ptr += CIFS_AUTH_RESP_SIZE; 3705 bcc_ptr += CIFS_AUTH_RESP_SIZE;
3697 if (ses->capabilities & CAP_UNICODE) { 3706 if (ses->capabilities & CAP_UNICODE) {
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index a94b3e673182..ca30c391a894 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -1823,6 +1823,7 @@ refind_writable:
1823 cifsFileInfo_put(inv_file); 1823 cifsFileInfo_put(inv_file);
1824 spin_lock(&cifs_file_list_lock); 1824 spin_lock(&cifs_file_list_lock);
1825 ++refind; 1825 ++refind;
1826 inv_file = NULL;
1826 goto refind_writable; 1827 goto refind_writable;
1827 } 1828 }
1828 } 1829 }
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index 2d4f37235ed0..3e126d7bb2ea 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -771,6 +771,8 @@ cifs_get_inode_info(struct inode **inode, const char *full_path,
771 cifs_buf_release(srchinf->ntwrk_buf_start); 771 cifs_buf_release(srchinf->ntwrk_buf_start);
772 } 772 }
773 kfree(srchinf); 773 kfree(srchinf);
774 if (rc)
775 goto cgii_exit;
774 } else 776 } else
775 goto cgii_exit; 777 goto cgii_exit;
776 778
diff --git a/fs/cifs/smb2misc.c b/fs/cifs/smb2misc.c
index 689f035915cf..22dfdf17d065 100644
--- a/fs/cifs/smb2misc.c
+++ b/fs/cifs/smb2misc.c
@@ -322,7 +322,7 @@ smb2_get_data_area_len(int *off, int *len, struct smb2_hdr *hdr)
322 322
323 /* return pointer to beginning of data area, ie offset from SMB start */ 323 /* return pointer to beginning of data area, ie offset from SMB start */
324 if ((*off != 0) && (*len != 0)) 324 if ((*off != 0) && (*len != 0))
325 return hdr->ProtocolId + *off; 325 return (char *)(&hdr->ProtocolId[0]) + *off;
326 else 326 else
327 return NULL; 327 return NULL;
328} 328}
diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
index 96b5d40a2ece..eab05e1aa587 100644
--- a/fs/cifs/smb2ops.c
+++ b/fs/cifs/smb2ops.c
@@ -684,7 +684,8 @@ smb2_clone_range(const unsigned int xid,
684 684
685 /* No need to change MaxChunks since already set to 1 */ 685 /* No need to change MaxChunks since already set to 1 */
686 chunk_sizes_updated = true; 686 chunk_sizes_updated = true;
687 } 687 } else
688 goto cchunk_out;
688 } 689 }
689 690
690cchunk_out: 691cchunk_out:
diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
index 3417340bf89e..65cd7a84c8bc 100644
--- a/fs/cifs/smb2pdu.c
+++ b/fs/cifs/smb2pdu.c
@@ -1218,7 +1218,7 @@ SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid,
1218 struct smb2_ioctl_req *req; 1218 struct smb2_ioctl_req *req;
1219 struct smb2_ioctl_rsp *rsp; 1219 struct smb2_ioctl_rsp *rsp;
1220 struct TCP_Server_Info *server; 1220 struct TCP_Server_Info *server;
1221 struct cifs_ses *ses = tcon->ses; 1221 struct cifs_ses *ses;
1222 struct kvec iov[2]; 1222 struct kvec iov[2];
1223 int resp_buftype; 1223 int resp_buftype;
1224 int num_iovecs; 1224 int num_iovecs;
@@ -1233,6 +1233,11 @@ SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid,
1233 if (plen) 1233 if (plen)
1234 *plen = 0; 1234 *plen = 0;
1235 1235
1236 if (tcon)
1237 ses = tcon->ses;
1238 else
1239 return -EIO;
1240
1236 if (ses && (ses->server)) 1241 if (ses && (ses->server))
1237 server = ses->server; 1242 server = ses->server;
1238 else 1243 else
@@ -1296,14 +1301,12 @@ SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid,
1296 rsp = (struct smb2_ioctl_rsp *)iov[0].iov_base; 1301 rsp = (struct smb2_ioctl_rsp *)iov[0].iov_base;
1297 1302
1298 if ((rc != 0) && (rc != -EINVAL)) { 1303 if ((rc != 0) && (rc != -EINVAL)) {
1299 if (tcon) 1304 cifs_stats_fail_inc(tcon, SMB2_IOCTL_HE);
1300 cifs_stats_fail_inc(tcon, SMB2_IOCTL_HE);
1301 goto ioctl_exit; 1305 goto ioctl_exit;
1302 } else if (rc == -EINVAL) { 1306 } else if (rc == -EINVAL) {
1303 if ((opcode != FSCTL_SRV_COPYCHUNK_WRITE) && 1307 if ((opcode != FSCTL_SRV_COPYCHUNK_WRITE) &&
1304 (opcode != FSCTL_SRV_COPYCHUNK)) { 1308 (opcode != FSCTL_SRV_COPYCHUNK)) {
1305 if (tcon) 1309 cifs_stats_fail_inc(tcon, SMB2_IOCTL_HE);
1306 cifs_stats_fail_inc(tcon, SMB2_IOCTL_HE);
1307 goto ioctl_exit; 1310 goto ioctl_exit;
1308 } 1311 }
1309 } 1312 }
@@ -1629,7 +1632,7 @@ SMB2_flush(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid,
1629 1632
1630 rc = SendReceive2(xid, ses, iov, 1, &resp_buftype, 0); 1633 rc = SendReceive2(xid, ses, iov, 1, &resp_buftype, 0);
1631 1634
1632 if ((rc != 0) && tcon) 1635 if (rc != 0)
1633 cifs_stats_fail_inc(tcon, SMB2_FLUSH_HE); 1636 cifs_stats_fail_inc(tcon, SMB2_FLUSH_HE);
1634 1637
1635 free_rsp_buf(resp_buftype, iov[0].iov_base); 1638 free_rsp_buf(resp_buftype, iov[0].iov_base);
@@ -2114,7 +2117,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
2114 struct kvec iov[2]; 2117 struct kvec iov[2];
2115 int rc = 0; 2118 int rc = 0;
2116 int len; 2119 int len;
2117 int resp_buftype; 2120 int resp_buftype = CIFS_NO_BUFFER;
2118 unsigned char *bufptr; 2121 unsigned char *bufptr;
2119 struct TCP_Server_Info *server; 2122 struct TCP_Server_Info *server;
2120 struct cifs_ses *ses = tcon->ses; 2123 struct cifs_ses *ses = tcon->ses;
diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index e907052eeadb..32a8bbd7a9ad 100644
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -53,6 +53,18 @@ struct wb_writeback_work {
53 struct completion *done; /* set if the caller waits */ 53 struct completion *done; /* set if the caller waits */
54}; 54};
55 55
56/*
57 * If an inode is constantly having its pages dirtied, but then the
58 * updates stop dirtytime_expire_interval seconds in the past, it's
59 * possible for the worst case time between when an inode has its
60 * timestamps updated and when they finally get written out to be two
61 * dirtytime_expire_intervals. We set the default to 12 hours (in
62 * seconds), which means most of the time inodes will have their
63 * timestamps written to disk after 12 hours, but in the worst case a
64 * few inodes might not their timestamps updated for 24 hours.
65 */
66unsigned int dirtytime_expire_interval = 12 * 60 * 60;
67
56/** 68/**
57 * writeback_in_progress - determine whether there is writeback in progress 69 * writeback_in_progress - determine whether there is writeback in progress
58 * @bdi: the device's backing_dev_info structure. 70 * @bdi: the device's backing_dev_info structure.
@@ -275,8 +287,8 @@ static int move_expired_inodes(struct list_head *delaying_queue,
275 287
276 if ((flags & EXPIRE_DIRTY_ATIME) == 0) 288 if ((flags & EXPIRE_DIRTY_ATIME) == 0)
277 older_than_this = work->older_than_this; 289 older_than_this = work->older_than_this;
278 else if ((work->reason == WB_REASON_SYNC) == 0) { 290 else if (!work->for_sync) {
279 expire_time = jiffies - (HZ * 86400); 291 expire_time = jiffies - (dirtytime_expire_interval * HZ);
280 older_than_this = &expire_time; 292 older_than_this = &expire_time;
281 } 293 }
282 while (!list_empty(delaying_queue)) { 294 while (!list_empty(delaying_queue)) {
@@ -458,6 +470,7 @@ static void requeue_inode(struct inode *inode, struct bdi_writeback *wb,
458 */ 470 */
459 redirty_tail(inode, wb); 471 redirty_tail(inode, wb);
460 } else if (inode->i_state & I_DIRTY_TIME) { 472 } else if (inode->i_state & I_DIRTY_TIME) {
473 inode->dirtied_when = jiffies;
461 list_move(&inode->i_wb_list, &wb->b_dirty_time); 474 list_move(&inode->i_wb_list, &wb->b_dirty_time);
462 } else { 475 } else {
463 /* The inode is clean. Remove from writeback lists. */ 476 /* The inode is clean. Remove from writeback lists. */
@@ -505,12 +518,17 @@ __writeback_single_inode(struct inode *inode, struct writeback_control *wbc)
505 spin_lock(&inode->i_lock); 518 spin_lock(&inode->i_lock);
506 519
507 dirty = inode->i_state & I_DIRTY; 520 dirty = inode->i_state & I_DIRTY;
508 if (((dirty & (I_DIRTY_SYNC | I_DIRTY_DATASYNC)) && 521 if (inode->i_state & I_DIRTY_TIME) {
509 (inode->i_state & I_DIRTY_TIME)) || 522 if ((dirty & (I_DIRTY_SYNC | I_DIRTY_DATASYNC)) ||
510 (inode->i_state & I_DIRTY_TIME_EXPIRED)) { 523 unlikely(inode->i_state & I_DIRTY_TIME_EXPIRED) ||
511 dirty |= I_DIRTY_TIME | I_DIRTY_TIME_EXPIRED; 524 unlikely(time_after(jiffies,
512 trace_writeback_lazytime(inode); 525 (inode->dirtied_time_when +
513 } 526 dirtytime_expire_interval * HZ)))) {
527 dirty |= I_DIRTY_TIME | I_DIRTY_TIME_EXPIRED;
528 trace_writeback_lazytime(inode);
529 }
530 } else
531 inode->i_state &= ~I_DIRTY_TIME_EXPIRED;
514 inode->i_state &= ~dirty; 532 inode->i_state &= ~dirty;
515 533
516 /* 534 /*
@@ -1131,6 +1149,56 @@ void wakeup_flusher_threads(long nr_pages, enum wb_reason reason)
1131 rcu_read_unlock(); 1149 rcu_read_unlock();
1132} 1150}
1133 1151
1152/*
1153 * Wake up bdi's periodically to make sure dirtytime inodes gets
1154 * written back periodically. We deliberately do *not* check the
1155 * b_dirtytime list in wb_has_dirty_io(), since this would cause the
1156 * kernel to be constantly waking up once there are any dirtytime
1157 * inodes on the system. So instead we define a separate delayed work
1158 * function which gets called much more rarely. (By default, only
1159 * once every 12 hours.)
1160 *
1161 * If there is any other write activity going on in the file system,
1162 * this function won't be necessary. But if the only thing that has
1163 * happened on the file system is a dirtytime inode caused by an atime
1164 * update, we need this infrastructure below to make sure that inode
1165 * eventually gets pushed out to disk.
1166 */
1167static void wakeup_dirtytime_writeback(struct work_struct *w);
1168static DECLARE_DELAYED_WORK(dirtytime_work, wakeup_dirtytime_writeback);
1169
1170static void wakeup_dirtytime_writeback(struct work_struct *w)
1171{
1172 struct backing_dev_info *bdi;
1173
1174 rcu_read_lock();
1175 list_for_each_entry_rcu(bdi, &bdi_list, bdi_list) {
1176 if (list_empty(&bdi->wb.b_dirty_time))
1177 continue;
1178 bdi_wakeup_thread(bdi);
1179 }
1180 rcu_read_unlock();
1181 schedule_delayed_work(&dirtytime_work, dirtytime_expire_interval * HZ);
1182}
1183
1184static int __init start_dirtytime_writeback(void)
1185{
1186 schedule_delayed_work(&dirtytime_work, dirtytime_expire_interval * HZ);
1187 return 0;
1188}
1189__initcall(start_dirtytime_writeback);
1190
1191int dirtytime_interval_handler(struct ctl_table *table, int write,
1192 void __user *buffer, size_t *lenp, loff_t *ppos)
1193{
1194 int ret;
1195
1196 ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
1197 if (ret == 0 && write)
1198 mod_delayed_work(system_wq, &dirtytime_work, 0);
1199 return ret;
1200}
1201
1134static noinline void block_dump___mark_inode_dirty(struct inode *inode) 1202static noinline void block_dump___mark_inode_dirty(struct inode *inode)
1135{ 1203{
1136 if (inode->i_ino || strcmp(inode->i_sb->s_id, "bdev")) { 1204 if (inode->i_ino || strcmp(inode->i_sb->s_id, "bdev")) {
@@ -1269,8 +1337,13 @@ void __mark_inode_dirty(struct inode *inode, int flags)
1269 } 1337 }
1270 1338
1271 inode->dirtied_when = jiffies; 1339 inode->dirtied_when = jiffies;
1272 list_move(&inode->i_wb_list, dirtytime ? 1340 if (dirtytime)
1273 &bdi->wb.b_dirty_time : &bdi->wb.b_dirty); 1341 inode->dirtied_time_when = jiffies;
1342 if (inode->i_state & (I_DIRTY_INODE | I_DIRTY_PAGES))
1343 list_move(&inode->i_wb_list, &bdi->wb.b_dirty);
1344 else
1345 list_move(&inode->i_wb_list,
1346 &bdi->wb.b_dirty_time);
1274 spin_unlock(&bdi->wb.list_lock); 1347 spin_unlock(&bdi->wb.list_lock);
1275 trace_writeback_dirty_inode_enqueue(inode); 1348 trace_writeback_dirty_inode_enqueue(inode);
1276 1349
diff --git a/fs/locks.c b/fs/locks.c
index 528fedfda15e..40bc384728c0 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -1388,9 +1388,8 @@ any_leases_conflict(struct inode *inode, struct file_lock *breaker)
1388int __break_lease(struct inode *inode, unsigned int mode, unsigned int type) 1388int __break_lease(struct inode *inode, unsigned int mode, unsigned int type)
1389{ 1389{
1390 int error = 0; 1390 int error = 0;
1391 struct file_lock *new_fl;
1392 struct file_lock_context *ctx = inode->i_flctx; 1391 struct file_lock_context *ctx = inode->i_flctx;
1393 struct file_lock *fl; 1392 struct file_lock *new_fl, *fl, *tmp;
1394 unsigned long break_time; 1393 unsigned long break_time;
1395 int want_write = (mode & O_ACCMODE) != O_RDONLY; 1394 int want_write = (mode & O_ACCMODE) != O_RDONLY;
1396 LIST_HEAD(dispose); 1395 LIST_HEAD(dispose);
@@ -1420,7 +1419,7 @@ int __break_lease(struct inode *inode, unsigned int mode, unsigned int type)
1420 break_time++; /* so that 0 means no break time */ 1419 break_time++; /* so that 0 means no break time */
1421 } 1420 }
1422 1421
1423 list_for_each_entry(fl, &ctx->flc_lease, fl_list) { 1422 list_for_each_entry_safe(fl, tmp, &ctx->flc_lease, fl_list) {
1424 if (!leases_conflict(fl, new_fl)) 1423 if (!leases_conflict(fl, new_fl))
1425 continue; 1424 continue;
1426 if (want_write) { 1425 if (want_write) {
diff --git a/fs/nfsd/blocklayout.c b/fs/nfsd/blocklayout.c
index cdbc78c72542..03d647bf195d 100644
--- a/fs/nfsd/blocklayout.c
+++ b/fs/nfsd/blocklayout.c
@@ -137,7 +137,7 @@ nfsd4_block_proc_layoutget(struct inode *inode, const struct svc_fh *fhp,
137 seg->offset = iomap.offset; 137 seg->offset = iomap.offset;
138 seg->length = iomap.length; 138 seg->length = iomap.length;
139 139
140 dprintk("GET: %lld:%lld %d\n", bex->foff, bex->len, bex->es); 140 dprintk("GET: 0x%llx:0x%llx %d\n", bex->foff, bex->len, bex->es);
141 return 0; 141 return 0;
142 142
143out_error: 143out_error:
diff --git a/fs/nfsd/blocklayoutxdr.c b/fs/nfsd/blocklayoutxdr.c
index 9da89fddab33..9aa2796da90d 100644
--- a/fs/nfsd/blocklayoutxdr.c
+++ b/fs/nfsd/blocklayoutxdr.c
@@ -122,19 +122,19 @@ nfsd4_block_decode_layoutupdate(__be32 *p, u32 len, struct iomap **iomapp,
122 122
123 p = xdr_decode_hyper(p, &bex.foff); 123 p = xdr_decode_hyper(p, &bex.foff);
124 if (bex.foff & (block_size - 1)) { 124 if (bex.foff & (block_size - 1)) {
125 dprintk("%s: unaligned offset %lld\n", 125 dprintk("%s: unaligned offset 0x%llx\n",
126 __func__, bex.foff); 126 __func__, bex.foff);
127 goto fail; 127 goto fail;
128 } 128 }
129 p = xdr_decode_hyper(p, &bex.len); 129 p = xdr_decode_hyper(p, &bex.len);
130 if (bex.len & (block_size - 1)) { 130 if (bex.len & (block_size - 1)) {
131 dprintk("%s: unaligned length %lld\n", 131 dprintk("%s: unaligned length 0x%llx\n",
132 __func__, bex.foff); 132 __func__, bex.foff);
133 goto fail; 133 goto fail;
134 } 134 }
135 p = xdr_decode_hyper(p, &bex.soff); 135 p = xdr_decode_hyper(p, &bex.soff);
136 if (bex.soff & (block_size - 1)) { 136 if (bex.soff & (block_size - 1)) {
137 dprintk("%s: unaligned disk offset %lld\n", 137 dprintk("%s: unaligned disk offset 0x%llx\n",
138 __func__, bex.soff); 138 __func__, bex.soff);
139 goto fail; 139 goto fail;
140 } 140 }
diff --git a/fs/nfsd/nfs4layouts.c b/fs/nfsd/nfs4layouts.c
index 1028a0629543..6904213a4363 100644
--- a/fs/nfsd/nfs4layouts.c
+++ b/fs/nfsd/nfs4layouts.c
@@ -118,7 +118,7 @@ void nfsd4_setup_layout_type(struct svc_export *exp)
118{ 118{
119 struct super_block *sb = exp->ex_path.mnt->mnt_sb; 119 struct super_block *sb = exp->ex_path.mnt->mnt_sb;
120 120
121 if (exp->ex_flags & NFSEXP_NOPNFS) 121 if (!(exp->ex_flags & NFSEXP_PNFS))
122 return; 122 return;
123 123
124 if (sb->s_export_op->get_uuid && 124 if (sb->s_export_op->get_uuid &&
@@ -440,15 +440,14 @@ nfsd4_return_file_layout(struct nfs4_layout *lp, struct nfsd4_layout_seg *seg,
440 list_move_tail(&lp->lo_perstate, reaplist); 440 list_move_tail(&lp->lo_perstate, reaplist);
441 return; 441 return;
442 } 442 }
443 end = seg->offset; 443 lo->offset = layout_end(seg);
444 } else { 444 } else {
445 /* retain the whole layout segment on a split. */ 445 /* retain the whole layout segment on a split. */
446 if (layout_end(seg) < end) { 446 if (layout_end(seg) < end) {
447 dprintk("%s: split not supported\n", __func__); 447 dprintk("%s: split not supported\n", __func__);
448 return; 448 return;
449 } 449 }
450 450 end = seg->offset;
451 lo->offset = layout_end(seg);
452 } 451 }
453 452
454 layout_update_len(lo, end); 453 layout_update_len(lo, end);
@@ -513,6 +512,9 @@ nfsd4_return_client_layouts(struct svc_rqst *rqstp,
513 512
514 spin_lock(&clp->cl_lock); 513 spin_lock(&clp->cl_lock);
515 list_for_each_entry_safe(ls, n, &clp->cl_lo_states, ls_perclnt) { 514 list_for_each_entry_safe(ls, n, &clp->cl_lo_states, ls_perclnt) {
515 if (ls->ls_layout_type != lrp->lr_layout_type)
516 continue;
517
516 if (lrp->lr_return_type == RETURN_FSID && 518 if (lrp->lr_return_type == RETURN_FSID &&
517 !fh_fsid_match(&ls->ls_stid.sc_file->fi_fhandle, 519 !fh_fsid_match(&ls->ls_stid.sc_file->fi_fhandle,
518 &cstate->current_fh.fh_handle)) 520 &cstate->current_fh.fh_handle))
@@ -587,6 +589,8 @@ nfsd4_cb_layout_fail(struct nfs4_layout_stateid *ls)
587 589
588 rpc_ntop((struct sockaddr *)&clp->cl_addr, addr_str, sizeof(addr_str)); 590 rpc_ntop((struct sockaddr *)&clp->cl_addr, addr_str, sizeof(addr_str));
589 591
592 trace_layout_recall_fail(&ls->ls_stid.sc_stateid);
593
590 printk(KERN_WARNING 594 printk(KERN_WARNING
591 "nfsd: client %s failed to respond to layout recall. " 595 "nfsd: client %s failed to respond to layout recall. "
592 " Fencing..\n", addr_str); 596 " Fencing..\n", addr_str);
diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
index d30bea8d0277..92b9d97aff4f 100644
--- a/fs/nfsd/nfs4proc.c
+++ b/fs/nfsd/nfs4proc.c
@@ -1237,8 +1237,8 @@ nfsd4_getdeviceinfo(struct svc_rqst *rqstp,
1237 nfserr = ops->proc_getdeviceinfo(exp->ex_path.mnt->mnt_sb, gdp); 1237 nfserr = ops->proc_getdeviceinfo(exp->ex_path.mnt->mnt_sb, gdp);
1238 1238
1239 gdp->gd_notify_types &= ops->notify_types; 1239 gdp->gd_notify_types &= ops->notify_types;
1240 exp_put(exp);
1241out: 1240out:
1241 exp_put(exp);
1242 return nfserr; 1242 return nfserr;
1243} 1243}
1244 1244
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index d2f2c37dc2db..8ba1d888f1e6 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -3221,7 +3221,7 @@ alloc_init_open_stateowner(unsigned int strhashval, struct nfsd4_open *open,
3221 } else 3221 } else
3222 nfs4_free_openowner(&oo->oo_owner); 3222 nfs4_free_openowner(&oo->oo_owner);
3223 spin_unlock(&clp->cl_lock); 3223 spin_unlock(&clp->cl_lock);
3224 return oo; 3224 return ret;
3225} 3225}
3226 3226
3227static void init_open_stateid(struct nfs4_ol_stateid *stp, struct nfs4_file *fp, struct nfsd4_open *open) { 3227static void init_open_stateid(struct nfs4_ol_stateid *stp, struct nfs4_file *fp, struct nfsd4_open *open) {
@@ -5062,7 +5062,7 @@ alloc_init_lock_stateowner(unsigned int strhashval, struct nfs4_client *clp,
5062 } else 5062 } else
5063 nfs4_free_lockowner(&lo->lo_owner); 5063 nfs4_free_lockowner(&lo->lo_owner);
5064 spin_unlock(&clp->cl_lock); 5064 spin_unlock(&clp->cl_lock);
5065 return lo; 5065 return ret;
5066} 5066}
5067 5067
5068static void 5068static void
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index df5e66caf100..5fb7e78169a6 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -1562,7 +1562,11 @@ nfsd4_decode_layoutget(struct nfsd4_compoundargs *argp,
1562 p = xdr_decode_hyper(p, &lgp->lg_seg.offset); 1562 p = xdr_decode_hyper(p, &lgp->lg_seg.offset);
1563 p = xdr_decode_hyper(p, &lgp->lg_seg.length); 1563 p = xdr_decode_hyper(p, &lgp->lg_seg.length);
1564 p = xdr_decode_hyper(p, &lgp->lg_minlength); 1564 p = xdr_decode_hyper(p, &lgp->lg_minlength);
1565 nfsd4_decode_stateid(argp, &lgp->lg_sid); 1565
1566 status = nfsd4_decode_stateid(argp, &lgp->lg_sid);
1567 if (status)
1568 return status;
1569
1566 READ_BUF(4); 1570 READ_BUF(4);
1567 lgp->lg_maxcount = be32_to_cpup(p++); 1571 lgp->lg_maxcount = be32_to_cpup(p++);
1568 1572
@@ -1580,7 +1584,11 @@ nfsd4_decode_layoutcommit(struct nfsd4_compoundargs *argp,
1580 p = xdr_decode_hyper(p, &lcp->lc_seg.offset); 1584 p = xdr_decode_hyper(p, &lcp->lc_seg.offset);
1581 p = xdr_decode_hyper(p, &lcp->lc_seg.length); 1585 p = xdr_decode_hyper(p, &lcp->lc_seg.length);
1582 lcp->lc_reclaim = be32_to_cpup(p++); 1586 lcp->lc_reclaim = be32_to_cpup(p++);
1583 nfsd4_decode_stateid(argp, &lcp->lc_sid); 1587
1588 status = nfsd4_decode_stateid(argp, &lcp->lc_sid);
1589 if (status)
1590 return status;
1591
1584 READ_BUF(4); 1592 READ_BUF(4);
1585 lcp->lc_newoffset = be32_to_cpup(p++); 1593 lcp->lc_newoffset = be32_to_cpup(p++);
1586 if (lcp->lc_newoffset) { 1594 if (lcp->lc_newoffset) {
@@ -1628,7 +1636,11 @@ nfsd4_decode_layoutreturn(struct nfsd4_compoundargs *argp,
1628 READ_BUF(16); 1636 READ_BUF(16);
1629 p = xdr_decode_hyper(p, &lrp->lr_seg.offset); 1637 p = xdr_decode_hyper(p, &lrp->lr_seg.offset);
1630 p = xdr_decode_hyper(p, &lrp->lr_seg.length); 1638 p = xdr_decode_hyper(p, &lrp->lr_seg.length);
1631 nfsd4_decode_stateid(argp, &lrp->lr_sid); 1639
1640 status = nfsd4_decode_stateid(argp, &lrp->lr_sid);
1641 if (status)
1642 return status;
1643
1632 READ_BUF(4); 1644 READ_BUF(4);
1633 lrp->lrf_body_len = be32_to_cpup(p++); 1645 lrp->lrf_body_len = be32_to_cpup(p++);
1634 if (lrp->lrf_body_len > 0) { 1646 if (lrp->lrf_body_len > 0) {
@@ -4123,7 +4135,7 @@ nfsd4_encode_layoutreturn(struct nfsd4_compoundres *resp, __be32 nfserr,
4123 return nfserr_resource; 4135 return nfserr_resource;
4124 *p++ = cpu_to_be32(lrp->lrs_present); 4136 *p++ = cpu_to_be32(lrp->lrs_present);
4125 if (lrp->lrs_present) 4137 if (lrp->lrs_present)
4126 nfsd4_encode_stateid(xdr, &lrp->lr_sid); 4138 return nfsd4_encode_stateid(xdr, &lrp->lr_sid);
4127 return nfs_ok; 4139 return nfs_ok;
4128} 4140}
4129#endif /* CONFIG_NFSD_PNFS */ 4141#endif /* CONFIG_NFSD_PNFS */
diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c
index 83a9694ec485..46ec934f5dee 100644
--- a/fs/nfsd/nfscache.c
+++ b/fs/nfsd/nfscache.c
@@ -165,13 +165,17 @@ int nfsd_reply_cache_init(void)
165{ 165{
166 unsigned int hashsize; 166 unsigned int hashsize;
167 unsigned int i; 167 unsigned int i;
168 int status = 0;
168 169
169 max_drc_entries = nfsd_cache_size_limit(); 170 max_drc_entries = nfsd_cache_size_limit();
170 atomic_set(&num_drc_entries, 0); 171 atomic_set(&num_drc_entries, 0);
171 hashsize = nfsd_hashsize(max_drc_entries); 172 hashsize = nfsd_hashsize(max_drc_entries);
172 maskbits = ilog2(hashsize); 173 maskbits = ilog2(hashsize);
173 174
174 register_shrinker(&nfsd_reply_cache_shrinker); 175 status = register_shrinker(&nfsd_reply_cache_shrinker);
176 if (status)
177 return status;
178
175 drc_slab = kmem_cache_create("nfsd_drc", sizeof(struct svc_cacherep), 179 drc_slab = kmem_cache_create("nfsd_drc", sizeof(struct svc_cacherep),
176 0, 0, NULL); 180 0, 0, NULL);
177 if (!drc_slab) 181 if (!drc_slab)
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index 46e0d4e857c7..ba1790e52ff2 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -2394,7 +2394,6 @@ relock:
2394 /* 2394 /*
2395 * for completing the rest of the request. 2395 * for completing the rest of the request.
2396 */ 2396 */
2397 *ppos += written;
2398 count -= written; 2397 count -= written;
2399 written_buffered = generic_perform_write(file, from, *ppos); 2398 written_buffered = generic_perform_write(file, from, *ppos);
2400 /* 2399 /*
@@ -2409,7 +2408,6 @@ relock:
2409 goto out_dio; 2408 goto out_dio;
2410 } 2409 }
2411 2410
2412 iocb->ki_pos = *ppos + written_buffered;
2413 /* We need to ensure that the page cache pages are written to 2411 /* We need to ensure that the page cache pages are written to
2414 * disk and invalidated to preserve the expected O_DIRECT 2412 * disk and invalidated to preserve the expected O_DIRECT
2415 * semantics. 2413 * semantics.
@@ -2418,6 +2416,7 @@ relock:
2418 ret = filemap_write_and_wait_range(file->f_mapping, *ppos, 2416 ret = filemap_write_and_wait_range(file->f_mapping, *ppos,
2419 endbyte); 2417 endbyte);
2420 if (ret == 0) { 2418 if (ret == 0) {
2419 iocb->ki_pos = *ppos + written_buffered;
2421 written += written_buffered; 2420 written += written_buffered;
2422 invalidate_mapping_pages(mapping, 2421 invalidate_mapping_pages(mapping,
2423 *ppos >> PAGE_CACHE_SHIFT, 2422 *ppos >> PAGE_CACHE_SHIFT,
@@ -2440,10 +2439,14 @@ out_dio:
2440 /* buffered aio wouldn't have proper lock coverage today */ 2439 /* buffered aio wouldn't have proper lock coverage today */
2441 BUG_ON(ret == -EIOCBQUEUED && !(file->f_flags & O_DIRECT)); 2440 BUG_ON(ret == -EIOCBQUEUED && !(file->f_flags & O_DIRECT));
2442 2441
2442 if (unlikely(written <= 0))
2443 goto no_sync;
2444
2443 if (((file->f_flags & O_DSYNC) && !direct_io) || IS_SYNC(inode) || 2445 if (((file->f_flags & O_DSYNC) && !direct_io) || IS_SYNC(inode) ||
2444 ((file->f_flags & O_DIRECT) && !direct_io)) { 2446 ((file->f_flags & O_DIRECT) && !direct_io)) {
2445 ret = filemap_fdatawrite_range(file->f_mapping, *ppos, 2447 ret = filemap_fdatawrite_range(file->f_mapping,
2446 *ppos + count - 1); 2448 iocb->ki_pos - written,
2449 iocb->ki_pos - 1);
2447 if (ret < 0) 2450 if (ret < 0)
2448 written = ret; 2451 written = ret;
2449 2452
@@ -2454,10 +2457,12 @@ out_dio:
2454 } 2457 }
2455 2458
2456 if (!ret) 2459 if (!ret)
2457 ret = filemap_fdatawait_range(file->f_mapping, *ppos, 2460 ret = filemap_fdatawait_range(file->f_mapping,
2458 *ppos + count - 1); 2461 iocb->ki_pos - written,
2462 iocb->ki_pos - 1);
2459 } 2463 }
2460 2464
2465no_sync:
2461 /* 2466 /*
2462 * deep in g_f_a_w_n()->ocfs2_direct_IO we pass in a ocfs2_dio_end_io 2467 * deep in g_f_a_w_n()->ocfs2_direct_IO we pass in a ocfs2_dio_end_io
2463 * function pointer which is called when o_direct io completes so that 2468 * function pointer which is called when o_direct io completes so that
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index 61e32ec1fc4d..8de4fa90e8c4 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -252,6 +252,7 @@ struct acpi_device_pnp {
252#define acpi_device_bid(d) ((d)->pnp.bus_id) 252#define acpi_device_bid(d) ((d)->pnp.bus_id)
253#define acpi_device_adr(d) ((d)->pnp.bus_address) 253#define acpi_device_adr(d) ((d)->pnp.bus_address)
254const char *acpi_device_hid(struct acpi_device *device); 254const char *acpi_device_hid(struct acpi_device *device);
255#define acpi_device_uid(d) ((d)->pnp.unique_id)
255#define acpi_device_name(d) ((d)->pnp.device_name) 256#define acpi_device_name(d) ((d)->pnp.device_name)
256#define acpi_device_class(d) ((d)->pnp.device_class) 257#define acpi_device_class(d) ((d)->pnp.device_class)
257 258
@@ -386,7 +387,8 @@ static inline bool is_acpi_node(struct fwnode_handle *fwnode)
386 387
387static inline struct acpi_device *acpi_node(struct fwnode_handle *fwnode) 388static inline struct acpi_device *acpi_node(struct fwnode_handle *fwnode)
388{ 389{
389 return fwnode ? container_of(fwnode, struct acpi_device, fwnode) : NULL; 390 return is_acpi_node(fwnode) ?
391 container_of(fwnode, struct acpi_device, fwnode) : NULL;
390} 392}
391 393
392static inline struct fwnode_handle *acpi_fwnode_handle(struct acpi_device *adev) 394static inline struct fwnode_handle *acpi_fwnode_handle(struct acpi_device *adev)
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index ac78910d7416..91c09305106d 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -167,6 +167,7 @@
167#define IOMMU_OF_TABLES() OF_TABLE(CONFIG_OF_IOMMU, iommu) 167#define IOMMU_OF_TABLES() OF_TABLE(CONFIG_OF_IOMMU, iommu)
168#define RESERVEDMEM_OF_TABLES() OF_TABLE(CONFIG_OF_RESERVED_MEM, reservedmem) 168#define RESERVEDMEM_OF_TABLES() OF_TABLE(CONFIG_OF_RESERVED_MEM, reservedmem)
169#define CPU_METHOD_OF_TABLES() OF_TABLE(CONFIG_SMP, cpu_method) 169#define CPU_METHOD_OF_TABLES() OF_TABLE(CONFIG_SMP, cpu_method)
170#define CPUIDLE_METHOD_OF_TABLES() OF_TABLE(CONFIG_CPU_IDLE, cpuidle_method)
170#define EARLYCON_OF_TABLES() OF_TABLE(CONFIG_SERIAL_EARLYCON, earlycon) 171#define EARLYCON_OF_TABLES() OF_TABLE(CONFIG_SERIAL_EARLYCON, earlycon)
171 172
172#define KERNEL_DTB() \ 173#define KERNEL_DTB() \
@@ -501,6 +502,7 @@
501 CLKSRC_OF_TABLES() \ 502 CLKSRC_OF_TABLES() \
502 IOMMU_OF_TABLES() \ 503 IOMMU_OF_TABLES() \
503 CPU_METHOD_OF_TABLES() \ 504 CPU_METHOD_OF_TABLES() \
505 CPUIDLE_METHOD_OF_TABLES() \
504 KERNEL_DTB() \ 506 KERNEL_DTB() \
505 IRQCHIP_OF_MATCH_TABLE() \ 507 IRQCHIP_OF_MATCH_TABLE() \
506 EARLYCON_OF_TABLES() 508 EARLYCON_OF_TABLES()
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 24c7aa8b1d20..dd12127f171c 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -53,10 +53,16 @@ static inline acpi_handle acpi_device_handle(struct acpi_device *adev)
53 return adev ? adev->handle : NULL; 53 return adev ? adev->handle : NULL;
54} 54}
55 55
56#define ACPI_COMPANION(dev) ((dev)->acpi_node.companion) 56#define ACPI_COMPANION(dev) acpi_node((dev)->fwnode)
57#define ACPI_COMPANION_SET(dev, adev) ACPI_COMPANION(dev) = (adev) 57#define ACPI_COMPANION_SET(dev, adev) set_primary_fwnode(dev, (adev) ? \
58 acpi_fwnode_handle(adev) : NULL)
58#define ACPI_HANDLE(dev) acpi_device_handle(ACPI_COMPANION(dev)) 59#define ACPI_HANDLE(dev) acpi_device_handle(ACPI_COMPANION(dev))
59 60
61static inline bool has_acpi_companion(struct device *dev)
62{
63 return is_acpi_node(dev->fwnode);
64}
65
60static inline void acpi_preset_companion(struct device *dev, 66static inline void acpi_preset_companion(struct device *dev,
61 struct acpi_device *parent, u64 addr) 67 struct acpi_device *parent, u64 addr)
62{ 68{
@@ -471,6 +477,11 @@ static inline struct fwnode_handle *acpi_fwnode_handle(struct acpi_device *adev)
471 return NULL; 477 return NULL;
472} 478}
473 479
480static inline bool has_acpi_companion(struct device *dev)
481{
482 return false;
483}
484
474static inline const char *acpi_dev_name(struct acpi_device *adev) 485static inline const char *acpi_dev_name(struct acpi_device *adev)
475{ 486{
476 return NULL; 487 return NULL;
diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h
index c294e3e25e37..a1b25e35ea5f 100644
--- a/include/linux/blk_types.h
+++ b/include/linux/blk_types.h
@@ -181,7 +181,9 @@ enum rq_flag_bits {
181 __REQ_ELVPRIV, /* elevator private data attached */ 181 __REQ_ELVPRIV, /* elevator private data attached */
182 __REQ_FAILED, /* set if the request failed */ 182 __REQ_FAILED, /* set if the request failed */
183 __REQ_QUIET, /* don't worry about errors */ 183 __REQ_QUIET, /* don't worry about errors */
184 __REQ_PREEMPT, /* set for "ide_preempt" requests */ 184 __REQ_PREEMPT, /* set for "ide_preempt" requests and also
185 for requests for which the SCSI "quiesce"
186 state must be ignored. */
185 __REQ_ALLOCED, /* request came from our alloc pool */ 187 __REQ_ALLOCED, /* request came from our alloc pool */
186 __REQ_COPY_USER, /* contains copies of user pages */ 188 __REQ_COPY_USER, /* contains copies of user pages */
187 __REQ_FLUSH_SEQ, /* request for flush sequence */ 189 __REQ_FLUSH_SEQ, /* request for flush sequence */
diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
index 306178d7309f..9c5e89254796 100644
--- a/include/linux/cpuidle.h
+++ b/include/linux/cpuidle.h
@@ -77,7 +77,6 @@ struct cpuidle_device {
77 unsigned int cpu; 77 unsigned int cpu;
78 78
79 int last_residency; 79 int last_residency;
80 int state_count;
81 struct cpuidle_state_usage states_usage[CPUIDLE_STATE_MAX]; 80 struct cpuidle_state_usage states_usage[CPUIDLE_STATE_MAX];
82 struct cpuidle_state_kobj *kobjs[CPUIDLE_STATE_MAX]; 81 struct cpuidle_state_kobj *kobjs[CPUIDLE_STATE_MAX];
83 struct cpuidle_driver_kobj *kobj_driver; 82 struct cpuidle_driver_kobj *kobj_driver;
diff --git a/include/linux/device.h b/include/linux/device.h
index 0eb8ee2dc6d1..324d02add7b4 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -38,6 +38,7 @@ struct class;
38struct subsys_private; 38struct subsys_private;
39struct bus_type; 39struct bus_type;
40struct device_node; 40struct device_node;
41struct fwnode_handle;
41struct iommu_ops; 42struct iommu_ops;
42struct iommu_group; 43struct iommu_group;
43 44
@@ -650,14 +651,6 @@ struct device_dma_parameters {
650 unsigned long segment_boundary_mask; 651 unsigned long segment_boundary_mask;
651}; 652};
652 653
653struct acpi_device;
654
655struct acpi_dev_node {
656#ifdef CONFIG_ACPI
657 struct acpi_device *companion;
658#endif
659};
660
661/** 654/**
662 * struct device - The basic device structure 655 * struct device - The basic device structure
663 * @parent: The device's "parent" device, the device to which it is attached. 656 * @parent: The device's "parent" device, the device to which it is attached.
@@ -703,7 +696,7 @@ struct acpi_dev_node {
703 * @cma_area: Contiguous memory area for dma allocations 696 * @cma_area: Contiguous memory area for dma allocations
704 * @archdata: For arch-specific additions. 697 * @archdata: For arch-specific additions.
705 * @of_node: Associated device tree node. 698 * @of_node: Associated device tree node.
706 * @acpi_node: Associated ACPI device node. 699 * @fwnode: Associated device node supplied by platform firmware.
707 * @devt: For creating the sysfs "dev". 700 * @devt: For creating the sysfs "dev".
708 * @id: device instance 701 * @id: device instance
709 * @devres_lock: Spinlock to protect the resource of the device. 702 * @devres_lock: Spinlock to protect the resource of the device.
@@ -779,7 +772,7 @@ struct device {
779 struct dev_archdata archdata; 772 struct dev_archdata archdata;
780 773
781 struct device_node *of_node; /* associated device tree node */ 774 struct device_node *of_node; /* associated device tree node */
782 struct acpi_dev_node acpi_node; /* associated ACPI device node */ 775 struct fwnode_handle *fwnode; /* firmware device node */
783 776
784 dev_t devt; /* dev_t, creates the sysfs "dev" */ 777 dev_t devt; /* dev_t, creates the sysfs "dev" */
785 u32 id; /* device instance */ 778 u32 id; /* device instance */
@@ -947,6 +940,9 @@ extern void unlock_device_hotplug(void);
947extern int lock_device_hotplug_sysfs(void); 940extern int lock_device_hotplug_sysfs(void);
948extern int device_offline(struct device *dev); 941extern int device_offline(struct device *dev);
949extern int device_online(struct device *dev); 942extern int device_online(struct device *dev);
943extern void set_primary_fwnode(struct device *dev, struct fwnode_handle *fwnode);
944extern void set_secondary_fwnode(struct device *dev, struct fwnode_handle *fwnode);
945
950/* 946/*
951 * Root device objects for grouping under /sys/devices 947 * Root device objects for grouping under /sys/devices
952 */ 948 */
diff --git a/include/linux/dmapool.h b/include/linux/dmapool.h
index 022e34fcbd1b..52456aa566a0 100644
--- a/include/linux/dmapool.h
+++ b/include/linux/dmapool.h
@@ -14,6 +14,8 @@
14#include <asm/io.h> 14#include <asm/io.h>
15#include <asm/scatterlist.h> 15#include <asm/scatterlist.h>
16 16
17struct device;
18
17struct dma_pool *dma_pool_create(const char *name, struct device *dev, 19struct dma_pool *dma_pool_create(const char *name, struct device *dev,
18 size_t size, size_t align, size_t allocation); 20 size_t size, size_t align, size_t allocation);
19 21
diff --git a/include/linux/fs.h b/include/linux/fs.h
index b4d71b5e1ff2..52cc4492cb3a 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -604,6 +604,7 @@ struct inode {
604 struct mutex i_mutex; 604 struct mutex i_mutex;
605 605
606 unsigned long dirtied_when; /* jiffies of first dirtying */ 606 unsigned long dirtied_when; /* jiffies of first dirtying */
607 unsigned long dirtied_time_when;
607 608
608 struct hlist_node i_hash; 609 struct hlist_node i_hash;
609 struct list_head i_wb_list; /* backing dev IO list */ 610 struct list_head i_wb_list; /* backing dev IO list */
@@ -1548,7 +1549,7 @@ struct file_operations {
1548 long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long); 1549 long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
1549 long (*compat_ioctl) (struct file *, unsigned int, unsigned long); 1550 long (*compat_ioctl) (struct file *, unsigned int, unsigned long);
1550 int (*mmap) (struct file *, struct vm_area_struct *); 1551 int (*mmap) (struct file *, struct vm_area_struct *);
1551 void (*mremap)(struct file *, struct vm_area_struct *); 1552 int (*mremap)(struct file *, struct vm_area_struct *);
1552 int (*open) (struct inode *, struct file *); 1553 int (*open) (struct inode *, struct file *);
1553 int (*flush) (struct file *, fl_owner_t id); 1554 int (*flush) (struct file *, fl_owner_t id);
1554 int (*release) (struct inode *, struct file *); 1555 int (*release) (struct inode *, struct file *);
diff --git a/include/linux/fwnode.h b/include/linux/fwnode.h
new file mode 100644
index 000000000000..0408545bce42
--- /dev/null
+++ b/include/linux/fwnode.h
@@ -0,0 +1,27 @@
1/*
2 * fwnode.h - Firmware device node object handle type definition.
3 *
4 * Copyright (C) 2015, Intel Corporation
5 * Author: Rafael J. Wysocki <rafael.j.wysocki@intel.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 _LINUX_FWNODE_H_
13#define _LINUX_FWNODE_H_
14
15enum fwnode_type {
16 FWNODE_INVALID = 0,
17 FWNODE_OF,
18 FWNODE_ACPI,
19 FWNODE_PDATA,
20};
21
22struct fwnode_handle {
23 enum fwnode_type type;
24 struct fwnode_handle *secondary;
25};
26
27#endif
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index f17da50402a4..6d89575361a8 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -278,7 +278,7 @@ static inline int i2c_slave_event(struct i2c_client *client,
278 * @platform_data: stored in i2c_client.dev.platform_data 278 * @platform_data: stored in i2c_client.dev.platform_data
279 * @archdata: copied into i2c_client.dev.archdata 279 * @archdata: copied into i2c_client.dev.archdata
280 * @of_node: pointer to OpenFirmware device node 280 * @of_node: pointer to OpenFirmware device node
281 * @acpi_node: ACPI device node 281 * @fwnode: device node supplied by the platform firmware
282 * @irq: stored in i2c_client.irq 282 * @irq: stored in i2c_client.irq
283 * 283 *
284 * I2C doesn't actually support hardware probing, although controllers and 284 * I2C doesn't actually support hardware probing, although controllers and
@@ -299,7 +299,7 @@ struct i2c_board_info {
299 void *platform_data; 299 void *platform_data;
300 struct dev_archdata *archdata; 300 struct dev_archdata *archdata;
301 struct device_node *of_node; 301 struct device_node *of_node;
302 struct acpi_dev_node acpi_node; 302 struct fwnode_handle *fwnode;
303 int irq; 303 int irq;
304}; 304};
305 305
diff --git a/include/linux/irqchip/arm-gic-v3.h b/include/linux/irqchip/arm-gic-v3.h
index 781974afff9f..ffbc034c8810 100644
--- a/include/linux/irqchip/arm-gic-v3.h
+++ b/include/linux/irqchip/arm-gic-v3.h
@@ -126,8 +126,23 @@
126#define GICR_PROPBASER_WaWb (5U << 7) 126#define GICR_PROPBASER_WaWb (5U << 7)
127#define GICR_PROPBASER_RaWaWt (6U << 7) 127#define GICR_PROPBASER_RaWaWt (6U << 7)
128#define GICR_PROPBASER_RaWaWb (7U << 7) 128#define GICR_PROPBASER_RaWaWb (7U << 7)
129#define GICR_PROPBASER_CACHEABILITY_MASK (7U << 7)
129#define GICR_PROPBASER_IDBITS_MASK (0x1f) 130#define GICR_PROPBASER_IDBITS_MASK (0x1f)
130 131
132#define GICR_PENDBASER_NonShareable (0U << 10)
133#define GICR_PENDBASER_InnerShareable (1U << 10)
134#define GICR_PENDBASER_OuterShareable (2U << 10)
135#define GICR_PENDBASER_SHAREABILITY_MASK (3UL << 10)
136#define GICR_PENDBASER_nCnB (0U << 7)
137#define GICR_PENDBASER_nC (1U << 7)
138#define GICR_PENDBASER_RaWt (2U << 7)
139#define GICR_PENDBASER_RaWb (3U << 7)
140#define GICR_PENDBASER_WaWt (4U << 7)
141#define GICR_PENDBASER_WaWb (5U << 7)
142#define GICR_PENDBASER_RaWaWt (6U << 7)
143#define GICR_PENDBASER_RaWaWb (7U << 7)
144#define GICR_PENDBASER_CACHEABILITY_MASK (7U << 7)
145
131/* 146/*
132 * Re-Distributor registers, offsets from SGI_base 147 * Re-Distributor registers, offsets from SGI_base
133 */ 148 */
@@ -182,6 +197,7 @@
182#define GITS_CBASER_WaWb (5UL << 59) 197#define GITS_CBASER_WaWb (5UL << 59)
183#define GITS_CBASER_RaWaWt (6UL << 59) 198#define GITS_CBASER_RaWaWt (6UL << 59)
184#define GITS_CBASER_RaWaWb (7UL << 59) 199#define GITS_CBASER_RaWaWb (7UL << 59)
200#define GITS_CBASER_CACHEABILITY_MASK (7UL << 59)
185#define GITS_CBASER_NonShareable (0UL << 10) 201#define GITS_CBASER_NonShareable (0UL << 10)
186#define GITS_CBASER_InnerShareable (1UL << 10) 202#define GITS_CBASER_InnerShareable (1UL << 10)
187#define GITS_CBASER_OuterShareable (2UL << 10) 203#define GITS_CBASER_OuterShareable (2UL << 10)
@@ -198,6 +214,7 @@
198#define GITS_BASER_WaWb (5UL << 59) 214#define GITS_BASER_WaWb (5UL << 59)
199#define GITS_BASER_RaWaWt (6UL << 59) 215#define GITS_BASER_RaWaWt (6UL << 59)
200#define GITS_BASER_RaWaWb (7UL << 59) 216#define GITS_BASER_RaWaWb (7UL << 59)
217#define GITS_BASER_CACHEABILITY_MASK (7UL << 59)
201#define GITS_BASER_TYPE_SHIFT (56) 218#define GITS_BASER_TYPE_SHIFT (56)
202#define GITS_BASER_TYPE(r) (((r) >> GITS_BASER_TYPE_SHIFT) & 7) 219#define GITS_BASER_TYPE(r) (((r) >> GITS_BASER_TYPE_SHIFT) & 7)
203#define GITS_BASER_ENTRY_SIZE_SHIFT (48) 220#define GITS_BASER_ENTRY_SIZE_SHIFT (48)
diff --git a/include/linux/lcm.h b/include/linux/lcm.h
index 7bf01d779b45..1ce79a7f1daa 100644
--- a/include/linux/lcm.h
+++ b/include/linux/lcm.h
@@ -4,5 +4,6 @@
4#include <linux/compiler.h> 4#include <linux/compiler.h>
5 5
6unsigned long lcm(unsigned long a, unsigned long b) __attribute_const__; 6unsigned long lcm(unsigned long a, unsigned long b) __attribute_const__;
7unsigned long lcm_not_zero(unsigned long a, unsigned long b) __attribute_const__;
7 8
8#endif /* _LCM_H */ 9#endif /* _LCM_H */
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index f279d9c158cd..2782df47101e 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -474,16 +474,15 @@ struct zone {
474 unsigned long wait_table_bits; 474 unsigned long wait_table_bits;
475 475
476 ZONE_PADDING(_pad1_) 476 ZONE_PADDING(_pad1_)
477
478 /* Write-intensive fields used from the page allocator */
479 spinlock_t lock;
480
481 /* free areas of different sizes */ 477 /* free areas of different sizes */
482 struct free_area free_area[MAX_ORDER]; 478 struct free_area free_area[MAX_ORDER];
483 479
484 /* zone flags, see below */ 480 /* zone flags, see below */
485 unsigned long flags; 481 unsigned long flags;
486 482
483 /* Write-intensive fields used from the page allocator */
484 spinlock_t lock;
485
487 ZONE_PADDING(_pad2_) 486 ZONE_PADDING(_pad2_)
488 487
489 /* Write-intensive fields used by page reclaim */ 488 /* Write-intensive fields used by page reclaim */
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index dcf6ec27739b..278738873703 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -2185,6 +2185,12 @@ void netdev_freemem(struct net_device *dev);
2185void synchronize_net(void); 2185void synchronize_net(void);
2186int init_dummy_netdev(struct net_device *dev); 2186int init_dummy_netdev(struct net_device *dev);
2187 2187
2188DECLARE_PER_CPU(int, xmit_recursion);
2189static inline int dev_recursion_level(void)
2190{
2191 return this_cpu_read(xmit_recursion);
2192}
2193
2188struct net_device *dev_get_by_index(struct net *net, int ifindex); 2194struct net_device *dev_get_by_index(struct net *net, int ifindex);
2189struct net_device *__dev_get_by_index(struct net *net, int ifindex); 2195struct net_device *__dev_get_by_index(struct net *net, int ifindex);
2190struct net_device *dev_get_by_index_rcu(struct net *net, int ifindex); 2196struct net_device *dev_get_by_index_rcu(struct net *net, int ifindex);
diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
index ae4882ca4a64..58f1e75ba105 100644
--- a/include/linux/platform_device.h
+++ b/include/linux/platform_device.h
@@ -59,7 +59,7 @@ extern int platform_add_devices(struct platform_device **, int);
59 59
60struct platform_device_info { 60struct platform_device_info {
61 struct device *parent; 61 struct device *parent;
62 struct acpi_dev_node acpi_node; 62 struct fwnode_handle *fwnode;
63 63
64 const char *name; 64 const char *name;
65 int id; 65 int id;
diff --git a/include/linux/resume-trace.h b/include/linux/pm-trace.h
index f31db2368782..ecbde7a5548e 100644
--- a/include/linux/resume-trace.h
+++ b/include/linux/pm-trace.h
@@ -1,8 +1,8 @@
1#ifndef RESUME_TRACE_H 1#ifndef PM_TRACE_H
2#define RESUME_TRACE_H 2#define PM_TRACE_H
3 3
4#ifdef CONFIG_PM_TRACE 4#ifdef CONFIG_PM_TRACE
5#include <asm/resume-trace.h> 5#include <asm/pm-trace.h>
6#include <linux/types.h> 6#include <linux/types.h>
7 7
8extern int pm_trace_enabled; 8extern int pm_trace_enabled;
@@ -14,7 +14,7 @@ static inline int pm_trace_is_enabled(void)
14 14
15struct device; 15struct device;
16extern void set_trace_device(struct device *); 16extern void set_trace_device(struct device *);
17extern void generate_resume_trace(const void *tracedata, unsigned int user); 17extern void generate_pm_trace(const void *tracedata, unsigned int user);
18extern int show_trace_dev_match(char *buf, size_t size); 18extern int show_trace_dev_match(char *buf, size_t size);
19 19
20#define TRACE_DEVICE(dev) do { \ 20#define TRACE_DEVICE(dev) do { \
@@ -28,6 +28,7 @@ static inline int pm_trace_is_enabled(void) { return 0; }
28 28
29#define TRACE_DEVICE(dev) do { } while (0) 29#define TRACE_DEVICE(dev) do { } while (0)
30#define TRACE_RESUME(dev) do { } while (0) 30#define TRACE_RESUME(dev) do { } while (0)
31#define TRACE_SUSPEND(dev) do { } while (0)
31 32
32#endif 33#endif
33 34
diff --git a/include/linux/pm.h b/include/linux/pm.h
index e2f1be6dd9dd..2d29c64f8fb1 100644
--- a/include/linux/pm.h
+++ b/include/linux/pm.h
@@ -603,10 +603,18 @@ extern void dev_pm_put_subsys_data(struct device *dev);
603 * Power domains provide callbacks that are executed during system suspend, 603 * Power domains provide callbacks that are executed during system suspend,
604 * hibernation, system resume and during runtime PM transitions along with 604 * hibernation, system resume and during runtime PM transitions along with
605 * subsystem-level and driver-level callbacks. 605 * subsystem-level and driver-level callbacks.
606 *
607 * @detach: Called when removing a device from the domain.
608 * @activate: Called before executing probe routines for bus types and drivers.
609 * @sync: Called after successful driver probe.
610 * @dismiss: Called after unsuccessful driver probe and after driver removal.
606 */ 611 */
607struct dev_pm_domain { 612struct dev_pm_domain {
608 struct dev_pm_ops ops; 613 struct dev_pm_ops ops;
609 void (*detach)(struct device *dev, bool power_off); 614 void (*detach)(struct device *dev, bool power_off);
615 int (*activate)(struct device *dev);
616 void (*sync)(struct device *dev);
617 void (*dismiss)(struct device *dev);
610}; 618};
611 619
612/* 620/*
diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
index 080e778118ba..681ccb053f72 100644
--- a/include/linux/pm_domain.h
+++ b/include/linux/pm_domain.h
@@ -127,7 +127,7 @@ static inline struct generic_pm_domain_data *dev_gpd_data(struct device *dev)
127 return to_gpd_data(dev->power.subsys_data->domain_data); 127 return to_gpd_data(dev->power.subsys_data->domain_data);
128} 128}
129 129
130extern struct generic_pm_domain *dev_to_genpd(struct device *dev); 130extern struct generic_pm_domain *pm_genpd_lookup_dev(struct device *dev);
131extern int __pm_genpd_add_device(struct generic_pm_domain *genpd, 131extern int __pm_genpd_add_device(struct generic_pm_domain *genpd,
132 struct device *dev, 132 struct device *dev,
133 struct gpd_timing_data *td); 133 struct gpd_timing_data *td);
@@ -163,9 +163,9 @@ static inline struct generic_pm_domain_data *dev_gpd_data(struct device *dev)
163{ 163{
164 return ERR_PTR(-ENOSYS); 164 return ERR_PTR(-ENOSYS);
165} 165}
166static inline struct generic_pm_domain *dev_to_genpd(struct device *dev) 166static inline struct generic_pm_domain *pm_genpd_lookup_dev(struct device *dev)
167{ 167{
168 return ERR_PTR(-ENOSYS); 168 return NULL;
169} 169}
170static inline int __pm_genpd_add_device(struct generic_pm_domain *genpd, 170static inline int __pm_genpd_add_device(struct generic_pm_domain *genpd,
171 struct device *dev, 171 struct device *dev,
diff --git a/include/linux/pnp.h b/include/linux/pnp.h
index 6512e9cbc6d5..5df733b8f704 100644
--- a/include/linux/pnp.h
+++ b/include/linux/pnp.h
@@ -510,4 +510,16 @@ static inline void pnp_unregister_driver(struct pnp_driver *drv) { }
510 510
511#endif /* CONFIG_PNP */ 511#endif /* CONFIG_PNP */
512 512
513/**
514 * module_pnp_driver() - Helper macro for registering a PnP driver
515 * @__pnp_driver: pnp_driver struct
516 *
517 * Helper macro for PnP drivers which do not do anything special in module
518 * init/exit. This eliminates a lot of boilerplate. Each module may only
519 * use this macro once, and calling it replaces module_init() and module_exit()
520 */
521#define module_pnp_driver(__pnp_driver) \
522 module_driver(__pnp_driver, pnp_register_driver, \
523 pnp_unregister_driver)
524
513#endif /* _LINUX_PNP_H */ 525#endif /* _LINUX_PNP_H */
diff --git a/include/linux/property.h b/include/linux/property.h
index a6a3d98bd7e9..de8bdf417a35 100644
--- a/include/linux/property.h
+++ b/include/linux/property.h
@@ -13,6 +13,7 @@
13#ifndef _LINUX_PROPERTY_H_ 13#ifndef _LINUX_PROPERTY_H_
14#define _LINUX_PROPERTY_H_ 14#define _LINUX_PROPERTY_H_
15 15
16#include <linux/fwnode.h>
16#include <linux/types.h> 17#include <linux/types.h>
17 18
18struct device; 19struct device;
@@ -40,16 +41,6 @@ int device_property_read_string_array(struct device *dev, const char *propname,
40int device_property_read_string(struct device *dev, const char *propname, 41int device_property_read_string(struct device *dev, const char *propname,
41 const char **val); 42 const char **val);
42 43
43enum fwnode_type {
44 FWNODE_INVALID = 0,
45 FWNODE_OF,
46 FWNODE_ACPI,
47};
48
49struct fwnode_handle {
50 enum fwnode_type type;
51};
52
53bool fwnode_property_present(struct fwnode_handle *fwnode, const char *propname); 44bool fwnode_property_present(struct fwnode_handle *fwnode, const char *propname);
54int fwnode_property_read_u8_array(struct fwnode_handle *fwnode, 45int fwnode_property_read_u8_array(struct fwnode_handle *fwnode,
55 const char *propname, u8 *val, 46 const char *propname, u8 *val,
@@ -140,4 +131,37 @@ static inline int fwnode_property_read_u64(struct fwnode_handle *fwnode,
140 return fwnode_property_read_u64_array(fwnode, propname, val, 1); 131 return fwnode_property_read_u64_array(fwnode, propname, val, 1);
141} 132}
142 133
134/**
135 * struct property_entry - "Built-in" device property representation.
136 * @name: Name of the property.
137 * @type: Type of the property.
138 * @nval: Number of items of type @type making up the value.
139 * @value: Value of the property (an array of @nval items of type @type).
140 */
141struct property_entry {
142 const char *name;
143 enum dev_prop_type type;
144 size_t nval;
145 union {
146 void *raw_data;
147 u8 *u8_data;
148 u16 *u16_data;
149 u32 *u32_data;
150 u64 *u64_data;
151 const char **str;
152 } value;
153};
154
155/**
156 * struct property_set - Collection of "built-in" device properties.
157 * @fwnode: Handle to be pointed to by the fwnode field of struct device.
158 * @properties: Array of properties terminated with a null entry.
159 */
160struct property_set {
161 struct fwnode_handle fwnode;
162 struct property_entry *properties;
163};
164
165void device_add_property_set(struct device *dev, struct property_set *pset);
166
143#endif /* _LINUX_PROPERTY_H_ */ 167#endif /* _LINUX_PROPERTY_H_ */
diff --git a/include/linux/sunrpc/debug.h b/include/linux/sunrpc/debug.h
index c57d8ea0716c..59a7889e15db 100644
--- a/include/linux/sunrpc/debug.h
+++ b/include/linux/sunrpc/debug.h
@@ -60,17 +60,17 @@ struct rpc_xprt;
60#if IS_ENABLED(CONFIG_SUNRPC_DEBUG) 60#if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
61void rpc_register_sysctl(void); 61void rpc_register_sysctl(void);
62void rpc_unregister_sysctl(void); 62void rpc_unregister_sysctl(void);
63int sunrpc_debugfs_init(void); 63void sunrpc_debugfs_init(void);
64void sunrpc_debugfs_exit(void); 64void sunrpc_debugfs_exit(void);
65int rpc_clnt_debugfs_register(struct rpc_clnt *); 65void rpc_clnt_debugfs_register(struct rpc_clnt *);
66void rpc_clnt_debugfs_unregister(struct rpc_clnt *); 66void rpc_clnt_debugfs_unregister(struct rpc_clnt *);
67int rpc_xprt_debugfs_register(struct rpc_xprt *); 67void rpc_xprt_debugfs_register(struct rpc_xprt *);
68void rpc_xprt_debugfs_unregister(struct rpc_xprt *); 68void rpc_xprt_debugfs_unregister(struct rpc_xprt *);
69#else 69#else
70static inline int 70static inline void
71sunrpc_debugfs_init(void) 71sunrpc_debugfs_init(void)
72{ 72{
73 return 0; 73 return;
74} 74}
75 75
76static inline void 76static inline void
@@ -79,10 +79,10 @@ sunrpc_debugfs_exit(void)
79 return; 79 return;
80} 80}
81 81
82static inline int 82static inline void
83rpc_clnt_debugfs_register(struct rpc_clnt *clnt) 83rpc_clnt_debugfs_register(struct rpc_clnt *clnt)
84{ 84{
85 return 0; 85 return;
86} 86}
87 87
88static inline void 88static inline void
@@ -91,10 +91,10 @@ rpc_clnt_debugfs_unregister(struct rpc_clnt *clnt)
91 return; 91 return;
92} 92}
93 93
94static inline int 94static inline void
95rpc_xprt_debugfs_register(struct rpc_xprt *xprt) 95rpc_xprt_debugfs_register(struct rpc_xprt *xprt)
96{ 96{
97 return 0; 97 return;
98} 98}
99 99
100static inline void 100static inline void
diff --git a/include/linux/usb/usbnet.h b/include/linux/usb/usbnet.h
index d9a4905e01d0..6e0ce8c7b8cb 100644
--- a/include/linux/usb/usbnet.h
+++ b/include/linux/usb/usbnet.h
@@ -227,9 +227,23 @@ struct skb_data { /* skb->cb is one of these */
227 struct urb *urb; 227 struct urb *urb;
228 struct usbnet *dev; 228 struct usbnet *dev;
229 enum skb_state state; 229 enum skb_state state;
230 size_t length; 230 long length;
231 unsigned long packets;
231}; 232};
232 233
234/* Drivers that set FLAG_MULTI_PACKET must call this in their
235 * tx_fixup method before returning an skb.
236 */
237static inline void
238usbnet_set_skb_tx_stats(struct sk_buff *skb,
239 unsigned long packets, long bytes_delta)
240{
241 struct skb_data *entry = (struct skb_data *) skb->cb;
242
243 entry->packets = packets;
244 entry->length = bytes_delta;
245}
246
233extern int usbnet_open(struct net_device *net); 247extern int usbnet_open(struct net_device *net);
234extern int usbnet_stop(struct net_device *net); 248extern int usbnet_stop(struct net_device *net);
235extern netdev_tx_t usbnet_start_xmit(struct sk_buff *skb, 249extern netdev_tx_t usbnet_start_xmit(struct sk_buff *skb,
diff --git a/include/linux/writeback.h b/include/linux/writeback.h
index 00048339c23e..b2dd371ec0ca 100644
--- a/include/linux/writeback.h
+++ b/include/linux/writeback.h
@@ -130,6 +130,7 @@ extern int vm_dirty_ratio;
130extern unsigned long vm_dirty_bytes; 130extern unsigned long vm_dirty_bytes;
131extern unsigned int dirty_writeback_interval; 131extern unsigned int dirty_writeback_interval;
132extern unsigned int dirty_expire_interval; 132extern unsigned int dirty_expire_interval;
133extern unsigned int dirtytime_expire_interval;
133extern int vm_highmem_is_dirtyable; 134extern int vm_highmem_is_dirtyable;
134extern int block_dump; 135extern int block_dump;
135extern int laptop_mode; 136extern int laptop_mode;
@@ -146,6 +147,8 @@ extern int dirty_ratio_handler(struct ctl_table *table, int write,
146extern int dirty_bytes_handler(struct ctl_table *table, int write, 147extern int dirty_bytes_handler(struct ctl_table *table, int write,
147 void __user *buffer, size_t *lenp, 148 void __user *buffer, size_t *lenp,
148 loff_t *ppos); 149 loff_t *ppos);
150int dirtytime_interval_handler(struct ctl_table *table, int write,
151 void __user *buffer, size_t *lenp, loff_t *ppos);
149 152
150struct ctl_table; 153struct ctl_table;
151int dirty_writeback_centisecs_handler(struct ctl_table *, int, 154int dirty_writeback_centisecs_handler(struct ctl_table *, int,
diff --git a/include/media/atmel-isi.h b/include/media/atmel-isi.h
index c2e570336269..6008b0985b7b 100644
--- a/include/media/atmel-isi.h
+++ b/include/media/atmel-isi.h
@@ -59,6 +59,10 @@
59#define ISI_CFG1_FRATE_DIV_MASK (7 << 8) 59#define ISI_CFG1_FRATE_DIV_MASK (7 << 8)
60#define ISI_CFG1_DISCR (1 << 11) 60#define ISI_CFG1_DISCR (1 << 11)
61#define ISI_CFG1_FULL_MODE (1 << 12) 61#define ISI_CFG1_FULL_MODE (1 << 12)
62/* Definition for THMASK(ISI_V2) */
63#define ISI_CFG1_THMASK_BEATS_4 (0 << 13)
64#define ISI_CFG1_THMASK_BEATS_8 (1 << 13)
65#define ISI_CFG1_THMASK_BEATS_16 (2 << 13)
62 66
63/* Bitfields in CFG2 */ 67/* Bitfields in CFG2 */
64#define ISI_CFG2_GRAYSCALE (1 << 13) 68#define ISI_CFG2_GRAYSCALE (1 << 13)
diff --git a/include/net/ip.h b/include/net/ip.h
index 025c61c0dffb..6cc1eafb153a 100644
--- a/include/net/ip.h
+++ b/include/net/ip.h
@@ -453,22 +453,6 @@ static __inline__ void inet_reset_saddr(struct sock *sk)
453 453
454#endif 454#endif
455 455
456static inline int sk_mc_loop(struct sock *sk)
457{
458 if (!sk)
459 return 1;
460 switch (sk->sk_family) {
461 case AF_INET:
462 return inet_sk(sk)->mc_loop;
463#if IS_ENABLED(CONFIG_IPV6)
464 case AF_INET6:
465 return inet6_sk(sk)->mc_loop;
466#endif
467 }
468 WARN_ON(1);
469 return 1;
470}
471
472bool ip_call_ra_chain(struct sk_buff *skb); 456bool ip_call_ra_chain(struct sk_buff *skb);
473 457
474/* 458/*
diff --git a/include/net/ip6_route.h b/include/net/ip6_route.h
index 1d09b46c1e48..eda131d179d9 100644
--- a/include/net/ip6_route.h
+++ b/include/net/ip6_route.h
@@ -174,7 +174,8 @@ int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *));
174 174
175static inline int ip6_skb_dst_mtu(struct sk_buff *skb) 175static inline int ip6_skb_dst_mtu(struct sk_buff *skb)
176{ 176{
177 struct ipv6_pinfo *np = skb->sk ? inet6_sk(skb->sk) : NULL; 177 struct ipv6_pinfo *np = skb->sk && !dev_recursion_level() ?
178 inet6_sk(skb->sk) : NULL;
178 179
179 return (np && np->pmtudisc >= IPV6_PMTUDISC_PROBE) ? 180 return (np && np->pmtudisc >= IPV6_PMTUDISC_PROBE) ?
180 skb_dst(skb)->dev->mtu : dst_mtu(skb_dst(skb)); 181 skb_dst(skb)->dev->mtu : dst_mtu(skb_dst(skb));
diff --git a/include/net/sock.h b/include/net/sock.h
index ab186b1d31ff..e4079c28e6b8 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -1762,6 +1762,8 @@ struct dst_entry *__sk_dst_check(struct sock *sk, u32 cookie);
1762 1762
1763struct dst_entry *sk_dst_check(struct sock *sk, u32 cookie); 1763struct dst_entry *sk_dst_check(struct sock *sk, u32 cookie);
1764 1764
1765bool sk_mc_loop(struct sock *sk);
1766
1765static inline bool sk_can_gso(const struct sock *sk) 1767static inline bool sk_can_gso(const struct sock *sk)
1766{ 1768{
1767 return net_gso_ok(sk->sk_route_caps, sk->sk_gso_type); 1769 return net_gso_ok(sk->sk_route_caps, sk->sk_gso_type);
diff --git a/include/uapi/linux/input.h b/include/uapi/linux/input.h
index b0a813079852..2f62ab2d7bf9 100644
--- a/include/uapi/linux/input.h
+++ b/include/uapi/linux/input.h
@@ -973,7 +973,8 @@ struct input_keymap_entry {
973 */ 973 */
974#define MT_TOOL_FINGER 0 974#define MT_TOOL_FINGER 0
975#define MT_TOOL_PEN 1 975#define MT_TOOL_PEN 1
976#define MT_TOOL_MAX 1 976#define MT_TOOL_PALM 2
977#define MT_TOOL_MAX 2
977 978
978/* 979/*
979 * Values describing the status of a force-feedback effect 980 * Values describing the status of a force-feedback effect
diff --git a/include/uapi/linux/nfsd/export.h b/include/uapi/linux/nfsd/export.h
index 4742f2cb42f2..d3bd6ffec041 100644
--- a/include/uapi/linux/nfsd/export.h
+++ b/include/uapi/linux/nfsd/export.h
@@ -47,7 +47,7 @@
47 * exported filesystem. 47 * exported filesystem.
48 */ 48 */
49#define NFSEXP_V4ROOT 0x10000 49#define NFSEXP_V4ROOT 0x10000
50#define NFSEXP_NOPNFS 0x20000 50#define NFSEXP_PNFS 0x20000
51 51
52/* All flags that we claim to support. (Note we don't support NOACL.) */ 52/* All flags that we claim to support. (Note we don't support NOACL.) */
53#define NFSEXP_ALLFLAGS 0x3FE7F 53#define NFSEXP_ALLFLAGS 0x3FE7F
diff --git a/kernel/module.c b/kernel/module.c
index 99fdf94efce8..ec53f594e9c9 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -2479,6 +2479,23 @@ static int elf_header_check(struct load_info *info)
2479 return 0; 2479 return 0;
2480} 2480}
2481 2481
2482#define COPY_CHUNK_SIZE (16*PAGE_SIZE)
2483
2484static int copy_chunked_from_user(void *dst, const void __user *usrc, unsigned long len)
2485{
2486 do {
2487 unsigned long n = min(len, COPY_CHUNK_SIZE);
2488
2489 if (copy_from_user(dst, usrc, n) != 0)
2490 return -EFAULT;
2491 cond_resched();
2492 dst += n;
2493 usrc += n;
2494 len -= n;
2495 } while (len);
2496 return 0;
2497}
2498
2482/* Sets info->hdr and info->len. */ 2499/* Sets info->hdr and info->len. */
2483static int copy_module_from_user(const void __user *umod, unsigned long len, 2500static int copy_module_from_user(const void __user *umod, unsigned long len,
2484 struct load_info *info) 2501 struct load_info *info)
@@ -2498,7 +2515,7 @@ static int copy_module_from_user(const void __user *umod, unsigned long len,
2498 if (!info->hdr) 2515 if (!info->hdr)
2499 return -ENOMEM; 2516 return -ENOMEM;
2500 2517
2501 if (copy_from_user(info->hdr, umod, info->len) != 0) { 2518 if (copy_chunked_from_user(info->hdr, umod, info->len) != 0) {
2502 vfree(info->hdr); 2519 vfree(info->hdr);
2503 return -EFAULT; 2520 return -EFAULT;
2504 } 2521 }
diff --git a/kernel/power/main.c b/kernel/power/main.c
index 9a59d042ea84..86e8157a450f 100644
--- a/kernel/power/main.c
+++ b/kernel/power/main.c
@@ -11,7 +11,7 @@
11#include <linux/export.h> 11#include <linux/export.h>
12#include <linux/kobject.h> 12#include <linux/kobject.h>
13#include <linux/string.h> 13#include <linux/string.h>
14#include <linux/resume-trace.h> 14#include <linux/pm-trace.h>
15#include <linux/workqueue.h> 15#include <linux/workqueue.h>
16#include <linux/debugfs.h> 16#include <linux/debugfs.h>
17#include <linux/seq_file.h> 17#include <linux/seq_file.h>
diff --git a/kernel/power/snapshot.c b/kernel/power/snapshot.c
index c24d5a23bf93..5235dd4e1e2f 100644
--- a/kernel/power/snapshot.c
+++ b/kernel/power/snapshot.c
@@ -955,25 +955,6 @@ static void mark_nosave_pages(struct memory_bitmap *bm)
955 } 955 }
956} 956}
957 957
958static bool is_nosave_page(unsigned long pfn)
959{
960 struct nosave_region *region;
961
962 list_for_each_entry(region, &nosave_regions, list) {
963 if (pfn >= region->start_pfn && pfn < region->end_pfn) {
964 pr_err("PM: %#010llx in e820 nosave region: "
965 "[mem %#010llx-%#010llx]\n",
966 (unsigned long long) pfn << PAGE_SHIFT,
967 (unsigned long long) region->start_pfn << PAGE_SHIFT,
968 ((unsigned long long) region->end_pfn << PAGE_SHIFT)
969 - 1);
970 return true;
971 }
972 }
973
974 return false;
975}
976
977/** 958/**
978 * create_basic_memory_bitmaps - create bitmaps needed for marking page 959 * create_basic_memory_bitmaps - create bitmaps needed for marking page
979 * frames that should not be saved and free page frames. The pointers 960 * frames that should not be saved and free page frames. The pointers
@@ -2042,7 +2023,7 @@ static int mark_unsafe_pages(struct memory_bitmap *bm)
2042 do { 2023 do {
2043 pfn = memory_bm_next_pfn(bm); 2024 pfn = memory_bm_next_pfn(bm);
2044 if (likely(pfn != BM_END_OF_MAP)) { 2025 if (likely(pfn != BM_END_OF_MAP)) {
2045 if (likely(pfn_valid(pfn)) && !is_nosave_page(pfn)) 2026 if (likely(pfn_valid(pfn)))
2046 swsusp_set_page_free(pfn_to_page(pfn)); 2027 swsusp_set_page_free(pfn_to_page(pfn));
2047 else 2028 else
2048 return -EFAULT; 2029 return -EFAULT;
diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c
index b7d6b3a721b1..8d7a1ef72758 100644
--- a/kernel/power/suspend.c
+++ b/kernel/power/suspend.c
@@ -28,6 +28,7 @@
28#include <linux/ftrace.h> 28#include <linux/ftrace.h>
29#include <trace/events/power.h> 29#include <trace/events/power.h>
30#include <linux/compiler.h> 30#include <linux/compiler.h>
31#include <linux/moduleparam.h>
31 32
32#include "power.h" 33#include "power.h"
33 34
@@ -233,12 +234,20 @@ static bool platform_suspend_again(suspend_state_t state)
233 suspend_ops->suspend_again() : false; 234 suspend_ops->suspend_again() : false;
234} 235}
235 236
237#ifdef CONFIG_PM_DEBUG
238static unsigned int pm_test_delay = 5;
239module_param(pm_test_delay, uint, 0644);
240MODULE_PARM_DESC(pm_test_delay,
241 "Number of seconds to wait before resuming from suspend test");
242#endif
243
236static int suspend_test(int level) 244static int suspend_test(int level)
237{ 245{
238#ifdef CONFIG_PM_DEBUG 246#ifdef CONFIG_PM_DEBUG
239 if (pm_test_level == level) { 247 if (pm_test_level == level) {
240 printk(KERN_INFO "suspend debug: Waiting for 5 seconds.\n"); 248 printk(KERN_INFO "suspend debug: Waiting for %d second(s).\n",
241 mdelay(5000); 249 pm_test_delay);
250 mdelay(pm_test_delay * 1000);
242 return 1; 251 return 1;
243 } 252 }
244#endif /* !CONFIG_PM_DEBUG */ 253#endif /* !CONFIG_PM_DEBUG */
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index bcfe32088b37..241213be507c 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -2165,8 +2165,10 @@ void task_numa_work(struct callback_head *work)
2165 vma = mm->mmap; 2165 vma = mm->mmap;
2166 } 2166 }
2167 for (; vma; vma = vma->vm_next) { 2167 for (; vma; vma = vma->vm_next) {
2168 if (!vma_migratable(vma) || !vma_policy_mof(vma)) 2168 if (!vma_migratable(vma) || !vma_policy_mof(vma) ||
2169 is_vm_hugetlb_page(vma)) {
2169 continue; 2170 continue;
2171 }
2170 2172
2171 /* 2173 /*
2172 * Shared library pages mapped by multiple processes are not 2174 * Shared library pages mapped by multiple processes are not
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 88ea2d6e0031..ce410bb9f2e1 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -1228,6 +1228,14 @@ static struct ctl_table vm_table[] = {
1228 .extra1 = &zero, 1228 .extra1 = &zero,
1229 }, 1229 },
1230 { 1230 {
1231 .procname = "dirtytime_expire_seconds",
1232 .data = &dirtytime_expire_interval,
1233 .maxlen = sizeof(dirty_expire_interval),
1234 .mode = 0644,
1235 .proc_handler = dirtytime_interval_handler,
1236 .extra1 = &zero,
1237 },
1238 {
1231 .procname = "nr_pdflush_threads", 1239 .procname = "nr_pdflush_threads",
1232 .mode = 0444 /* read-only */, 1240 .mode = 0444 /* read-only */,
1233 .proc_handler = pdflush_proc_obsolete, 1241 .proc_handler = pdflush_proc_obsolete,
diff --git a/lib/lcm.c b/lib/lcm.c
index e97dbd51e756..03d7fcb420b5 100644
--- a/lib/lcm.c
+++ b/lib/lcm.c
@@ -12,3 +12,14 @@ unsigned long lcm(unsigned long a, unsigned long b)
12 return 0; 12 return 0;
13} 13}
14EXPORT_SYMBOL_GPL(lcm); 14EXPORT_SYMBOL_GPL(lcm);
15
16unsigned long lcm_not_zero(unsigned long a, unsigned long b)
17{
18 unsigned long l = lcm(a, b);
19
20 if (l)
21 return l;
22
23 return (b ? : a);
24}
25EXPORT_SYMBOL_GPL(lcm_not_zero);
diff --git a/lib/nlattr.c b/lib/nlattr.c
index 76a1b59523ab..f5907d23272d 100644
--- a/lib/nlattr.c
+++ b/lib/nlattr.c
@@ -279,6 +279,8 @@ int nla_memcpy(void *dest, const struct nlattr *src, int count)
279 int minlen = min_t(int, count, nla_len(src)); 279 int minlen = min_t(int, count, nla_len(src));
280 280
281 memcpy(dest, nla_data(src), minlen); 281 memcpy(dest, nla_data(src), minlen);
282 if (count > minlen)
283 memset(dest + minlen, 0, count - minlen);
282 284
283 return minlen; 285 return minlen;
284} 286}
diff --git a/mm/mremap.c b/mm/mremap.c
index 57dadc025c64..2dc44b1cb1df 100644
--- a/mm/mremap.c
+++ b/mm/mremap.c
@@ -286,8 +286,14 @@ static unsigned long move_vma(struct vm_area_struct *vma,
286 old_len = new_len; 286 old_len = new_len;
287 old_addr = new_addr; 287 old_addr = new_addr;
288 new_addr = -ENOMEM; 288 new_addr = -ENOMEM;
289 } else if (vma->vm_file && vma->vm_file->f_op->mremap) 289 } else if (vma->vm_file && vma->vm_file->f_op->mremap) {
290 vma->vm_file->f_op->mremap(vma->vm_file, new_vma); 290 err = vma->vm_file->f_op->mremap(vma->vm_file, new_vma);
291 if (err < 0) {
292 move_page_tables(new_vma, new_addr, vma, old_addr,
293 moved_len, true);
294 return err;
295 }
296 }
291 297
292 /* Conceal VM_ACCOUNT so old reservation is not undone */ 298 /* Conceal VM_ACCOUNT so old reservation is not undone */
293 if (vm_flags & VM_ACCOUNT) { 299 if (vm_flags & VM_ACCOUNT) {
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index 6b3f54ed65ba..a9f4ae45b7fb 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 | __GFP_MEMALLOC; 487 sock->sk->sk_allocation = GFP_NOFS;
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);
@@ -520,8 +520,6 @@ static int ceph_tcp_connect(struct ceph_connection *con)
520 ret); 520 ret);
521 } 521 }
522 522
523 sk_set_memalloc(sock->sk);
524
525 con->sock = sock; 523 con->sock = sock;
526 return 0; 524 return 0;
527} 525}
@@ -2808,11 +2806,8 @@ static void con_work(struct work_struct *work)
2808{ 2806{
2809 struct ceph_connection *con = container_of(work, struct ceph_connection, 2807 struct ceph_connection *con = container_of(work, struct ceph_connection,
2810 work.work); 2808 work.work);
2811 unsigned long pflags = current->flags;
2812 bool fault; 2809 bool fault;
2813 2810
2814 current->flags |= PF_MEMALLOC;
2815
2816 mutex_lock(&con->mutex); 2811 mutex_lock(&con->mutex);
2817 while (true) { 2812 while (true) {
2818 int ret; 2813 int ret;
@@ -2866,8 +2861,6 @@ static void con_work(struct work_struct *work)
2866 con_fault_finish(con); 2861 con_fault_finish(con);
2867 2862
2868 con->ops->put(con); 2863 con->ops->put(con);
2869
2870 tsk_restore_flags(current, pflags, PF_MEMALLOC);
2871} 2864}
2872 2865
2873/* 2866/*
diff --git a/net/core/dev.c b/net/core/dev.c
index 962ee9d71964..45109b70664e 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -2848,7 +2848,9 @@ static void skb_update_prio(struct sk_buff *skb)
2848#define skb_update_prio(skb) 2848#define skb_update_prio(skb)
2849#endif 2849#endif
2850 2850
2851static DEFINE_PER_CPU(int, xmit_recursion); 2851DEFINE_PER_CPU(int, xmit_recursion);
2852EXPORT_SYMBOL(xmit_recursion);
2853
2852#define RECURSION_LIMIT 10 2854#define RECURSION_LIMIT 10
2853 2855
2854/** 2856/**
diff --git a/net/core/fib_rules.c b/net/core/fib_rules.c
index 44706e81b2e0..e4fdc9dfb2c7 100644
--- a/net/core/fib_rules.c
+++ b/net/core/fib_rules.c
@@ -175,9 +175,9 @@ void fib_rules_unregister(struct fib_rules_ops *ops)
175 175
176 spin_lock(&net->rules_mod_lock); 176 spin_lock(&net->rules_mod_lock);
177 list_del_rcu(&ops->list); 177 list_del_rcu(&ops->list);
178 fib_rules_cleanup_ops(ops);
179 spin_unlock(&net->rules_mod_lock); 178 spin_unlock(&net->rules_mod_lock);
180 179
180 fib_rules_cleanup_ops(ops);
181 call_rcu(&ops->rcu, fib_rules_put_rcu); 181 call_rcu(&ops->rcu, fib_rules_put_rcu);
182} 182}
183EXPORT_SYMBOL_GPL(fib_rules_unregister); 183EXPORT_SYMBOL_GPL(fib_rules_unregister);
diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
index cb5290b8c428..70d3450588b2 100644
--- a/net/core/net_namespace.c
+++ b/net/core/net_namespace.c
@@ -198,8 +198,10 @@ static int __peernet2id(struct net *net, struct net *peer, bool alloc)
198 */ 198 */
199int peernet2id(struct net *net, struct net *peer) 199int peernet2id(struct net *net, struct net *peer)
200{ 200{
201 int id = __peernet2id(net, peer, true); 201 bool alloc = atomic_read(&peer->count) == 0 ? false : true;
202 int id;
202 203
204 id = __peernet2id(net, peer, alloc);
203 return id >= 0 ? id : NETNSA_NSID_NOT_ASSIGNED; 205 return id >= 0 ? id : NETNSA_NSID_NOT_ASSIGNED;
204} 206}
205EXPORT_SYMBOL(peernet2id); 207EXPORT_SYMBOL(peernet2id);
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index ee0608bb3bc0..7ebed55b5f7d 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -1932,10 +1932,10 @@ static int rtnl_group_changelink(const struct sk_buff *skb,
1932 struct ifinfomsg *ifm, 1932 struct ifinfomsg *ifm,
1933 struct nlattr **tb) 1933 struct nlattr **tb)
1934{ 1934{
1935 struct net_device *dev; 1935 struct net_device *dev, *aux;
1936 int err; 1936 int err;
1937 1937
1938 for_each_netdev(net, dev) { 1938 for_each_netdev_safe(net, dev, aux) {
1939 if (dev->group == group) { 1939 if (dev->group == group) {
1940 err = do_setlink(skb, dev, ifm, tb, NULL, 0); 1940 err = do_setlink(skb, dev, ifm, tb, NULL, 0);
1941 if (err < 0) 1941 if (err < 0)
diff --git a/net/core/sock.c b/net/core/sock.c
index 78e89eb7eb70..71e3e5f1eaa0 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -653,6 +653,25 @@ static inline void sock_valbool_flag(struct sock *sk, int bit, int valbool)
653 sock_reset_flag(sk, bit); 653 sock_reset_flag(sk, bit);
654} 654}
655 655
656bool sk_mc_loop(struct sock *sk)
657{
658 if (dev_recursion_level())
659 return false;
660 if (!sk)
661 return true;
662 switch (sk->sk_family) {
663 case AF_INET:
664 return inet_sk(sk)->mc_loop;
665#if IS_ENABLED(CONFIG_IPV6)
666 case AF_INET6:
667 return inet6_sk(sk)->mc_loop;
668#endif
669 }
670 WARN_ON(1);
671 return true;
672}
673EXPORT_SYMBOL(sk_mc_loop);
674
656/* 675/*
657 * This is meant for all protocols to use and covers goings on 676 * This is meant for all protocols to use and covers goings on
658 * at the socket level. Everything here is generic. 677 * at the socket level. Everything here is generic.
diff --git a/net/decnet/dn_rules.c b/net/decnet/dn_rules.c
index faf7cc3483fe..9d66a0f72f90 100644
--- a/net/decnet/dn_rules.c
+++ b/net/decnet/dn_rules.c
@@ -248,7 +248,9 @@ void __init dn_fib_rules_init(void)
248 248
249void __exit dn_fib_rules_cleanup(void) 249void __exit dn_fib_rules_cleanup(void)
250{ 250{
251 rtnl_lock();
251 fib_rules_unregister(dn_fib_rules_ops); 252 fib_rules_unregister(dn_fib_rules_ops);
253 rtnl_unlock();
252 rcu_barrier(); 254 rcu_barrier();
253} 255}
254 256
diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index 2173402d87e0..4dea2e0681d1 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -501,12 +501,10 @@ static struct net_device *dev_to_net_device(struct device *dev)
501#ifdef CONFIG_OF 501#ifdef CONFIG_OF
502static int dsa_of_setup_routing_table(struct dsa_platform_data *pd, 502static int dsa_of_setup_routing_table(struct dsa_platform_data *pd,
503 struct dsa_chip_data *cd, 503 struct dsa_chip_data *cd,
504 int chip_index, 504 int chip_index, int port_index,
505 struct device_node *link) 505 struct device_node *link)
506{ 506{
507 int ret;
508 const __be32 *reg; 507 const __be32 *reg;
509 int link_port_addr;
510 int link_sw_addr; 508 int link_sw_addr;
511 struct device_node *parent_sw; 509 struct device_node *parent_sw;
512 int len; 510 int len;
@@ -519,6 +517,10 @@ static int dsa_of_setup_routing_table(struct dsa_platform_data *pd,
519 if (!reg || (len != sizeof(*reg) * 2)) 517 if (!reg || (len != sizeof(*reg) * 2))
520 return -EINVAL; 518 return -EINVAL;
521 519
520 /*
521 * Get the destination switch number from the second field of its 'reg'
522 * property, i.e. for "reg = <0x19 1>" sw_addr is '1'.
523 */
522 link_sw_addr = be32_to_cpup(reg + 1); 524 link_sw_addr = be32_to_cpup(reg + 1);
523 525
524 if (link_sw_addr >= pd->nr_chips) 526 if (link_sw_addr >= pd->nr_chips)
@@ -535,20 +537,9 @@ static int dsa_of_setup_routing_table(struct dsa_platform_data *pd,
535 memset(cd->rtable, -1, pd->nr_chips * sizeof(s8)); 537 memset(cd->rtable, -1, pd->nr_chips * sizeof(s8));
536 } 538 }
537 539
538 reg = of_get_property(link, "reg", NULL); 540 cd->rtable[link_sw_addr] = port_index;
539 if (!reg) {
540 ret = -EINVAL;
541 goto out;
542 }
543
544 link_port_addr = be32_to_cpup(reg);
545
546 cd->rtable[link_sw_addr] = link_port_addr;
547 541
548 return 0; 542 return 0;
549out:
550 kfree(cd->rtable);
551 return ret;
552} 543}
553 544
554static void dsa_of_free_platform_data(struct dsa_platform_data *pd) 545static void dsa_of_free_platform_data(struct dsa_platform_data *pd)
@@ -658,7 +649,7 @@ static int dsa_of_probe(struct platform_device *pdev)
658 if (!strcmp(port_name, "dsa") && link && 649 if (!strcmp(port_name, "dsa") && link &&
659 pd->nr_chips > 1) { 650 pd->nr_chips > 1) {
660 ret = dsa_of_setup_routing_table(pd, cd, 651 ret = dsa_of_setup_routing_table(pd, cd,
661 chip_index, link); 652 chip_index, port_index, link);
662 if (ret) 653 if (ret)
663 goto out_free_chip; 654 goto out_free_chip;
664 } 655 }
diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
index 57be71dd6a9e..23b9b3e86f4c 100644
--- a/net/ipv4/fib_frontend.c
+++ b/net/ipv4/fib_frontend.c
@@ -1111,11 +1111,10 @@ static void ip_fib_net_exit(struct net *net)
1111{ 1111{
1112 unsigned int i; 1112 unsigned int i;
1113 1113
1114 rtnl_lock();
1114#ifdef CONFIG_IP_MULTIPLE_TABLES 1115#ifdef CONFIG_IP_MULTIPLE_TABLES
1115 fib4_rules_exit(net); 1116 fib4_rules_exit(net);
1116#endif 1117#endif
1117
1118 rtnl_lock();
1119 for (i = 0; i < FIB_TABLE_HASHSZ; i++) { 1118 for (i = 0; i < FIB_TABLE_HASHSZ; i++) {
1120 struct fib_table *tb; 1119 struct fib_table *tb;
1121 struct hlist_head *head; 1120 struct hlist_head *head;
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
index 9d78427652d2..fe54eba6d00d 100644
--- a/net/ipv4/ipmr.c
+++ b/net/ipv4/ipmr.c
@@ -268,7 +268,7 @@ static int __net_init ipmr_rules_init(struct net *net)
268 return 0; 268 return 0;
269 269
270err2: 270err2:
271 kfree(mrt); 271 ipmr_free_table(mrt);
272err1: 272err1:
273 fib_rules_unregister(ops); 273 fib_rules_unregister(ops);
274 return err; 274 return err;
@@ -278,11 +278,13 @@ static void __net_exit ipmr_rules_exit(struct net *net)
278{ 278{
279 struct mr_table *mrt, *next; 279 struct mr_table *mrt, *next;
280 280
281 rtnl_lock();
281 list_for_each_entry_safe(mrt, next, &net->ipv4.mr_tables, list) { 282 list_for_each_entry_safe(mrt, next, &net->ipv4.mr_tables, list) {
282 list_del(&mrt->list); 283 list_del(&mrt->list);
283 ipmr_free_table(mrt); 284 ipmr_free_table(mrt);
284 } 285 }
285 fib_rules_unregister(net->ipv4.mr_rules_ops); 286 fib_rules_unregister(net->ipv4.mr_rules_ops);
287 rtnl_unlock();
286} 288}
287#else 289#else
288#define ipmr_for_each_table(mrt, net) \ 290#define ipmr_for_each_table(mrt, net) \
@@ -308,7 +310,10 @@ static int __net_init ipmr_rules_init(struct net *net)
308 310
309static void __net_exit ipmr_rules_exit(struct net *net) 311static void __net_exit ipmr_rules_exit(struct net *net)
310{ 312{
313 rtnl_lock();
311 ipmr_free_table(net->ipv4.mrt); 314 ipmr_free_table(net->ipv4.mrt);
315 net->ipv4.mrt = NULL;
316 rtnl_unlock();
312} 317}
313#endif 318#endif
314 319
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index fb4cf8b8e121..f501ac048366 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -3105,10 +3105,11 @@ static int tcp_clean_rtx_queue(struct sock *sk, int prior_fackets,
3105 if (!first_ackt.v64) 3105 if (!first_ackt.v64)
3106 first_ackt = last_ackt; 3106 first_ackt = last_ackt;
3107 3107
3108 if (!(sacked & TCPCB_SACKED_ACKED)) 3108 if (!(sacked & TCPCB_SACKED_ACKED)) {
3109 reord = min(pkts_acked, reord); 3109 reord = min(pkts_acked, reord);
3110 if (!after(scb->end_seq, tp->high_seq)) 3110 if (!after(scb->end_seq, tp->high_seq))
3111 flag |= FLAG_ORIG_SACK_ACKED; 3111 flag |= FLAG_ORIG_SACK_ACKED;
3112 }
3112 } 3113 }
3113 3114
3114 if (sacked & TCPCB_SACKED_ACKED) 3115 if (sacked & TCPCB_SACKED_ACKED)
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 5a2dfed4783b..f1756ee02207 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -1518,7 +1518,7 @@ void tcp_v4_early_demux(struct sk_buff *skb)
1518 skb->sk = sk; 1518 skb->sk = sk;
1519 skb->destructor = sock_edemux; 1519 skb->destructor = sock_edemux;
1520 if (sk->sk_state != TCP_TIME_WAIT) { 1520 if (sk->sk_state != TCP_TIME_WAIT) {
1521 struct dst_entry *dst = sk->sk_rx_dst; 1521 struct dst_entry *dst = READ_ONCE(sk->sk_rx_dst);
1522 1522
1523 if (dst) 1523 if (dst)
1524 dst = dst_check(dst, 0); 1524 dst = dst_check(dst, 0);
diff --git a/net/ipv6/fib6_rules.c b/net/ipv6/fib6_rules.c
index 27ca79682efb..70bc6abc0639 100644
--- a/net/ipv6/fib6_rules.c
+++ b/net/ipv6/fib6_rules.c
@@ -322,7 +322,9 @@ out_fib6_rules_ops:
322 322
323static void __net_exit fib6_rules_net_exit(struct net *net) 323static void __net_exit fib6_rules_net_exit(struct net *net)
324{ 324{
325 rtnl_lock();
325 fib_rules_unregister(net->ipv6.fib6_rules_ops); 326 fib_rules_unregister(net->ipv6.fib6_rules_ops);
327 rtnl_unlock();
326} 328}
327 329
328static struct pernet_operations fib6_rules_net_ops = { 330static struct pernet_operations fib6_rules_net_ops = {
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 7e80b61b51ff..36cf0ab685a0 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -542,7 +542,8 @@ int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *))
542{ 542{
543 struct sk_buff *frag; 543 struct sk_buff *frag;
544 struct rt6_info *rt = (struct rt6_info *)skb_dst(skb); 544 struct rt6_info *rt = (struct rt6_info *)skb_dst(skb);
545 struct ipv6_pinfo *np = skb->sk ? inet6_sk(skb->sk) : NULL; 545 struct ipv6_pinfo *np = skb->sk && !dev_recursion_level() ?
546 inet6_sk(skb->sk) : NULL;
546 struct ipv6hdr *tmp_hdr; 547 struct ipv6hdr *tmp_hdr;
547 struct frag_hdr *fh; 548 struct frag_hdr *fh;
548 unsigned int mtu, hlen, left, len; 549 unsigned int mtu, hlen, left, len;
diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c
index 34b682617f50..312e0ff47339 100644
--- a/net/ipv6/ip6mr.c
+++ b/net/ipv6/ip6mr.c
@@ -252,7 +252,7 @@ static int __net_init ip6mr_rules_init(struct net *net)
252 return 0; 252 return 0;
253 253
254err2: 254err2:
255 kfree(mrt); 255 ip6mr_free_table(mrt);
256err1: 256err1:
257 fib_rules_unregister(ops); 257 fib_rules_unregister(ops);
258 return err; 258 return err;
@@ -267,8 +267,8 @@ static void __net_exit ip6mr_rules_exit(struct net *net)
267 list_del(&mrt->list); 267 list_del(&mrt->list);
268 ip6mr_free_table(mrt); 268 ip6mr_free_table(mrt);
269 } 269 }
270 rtnl_unlock();
271 fib_rules_unregister(net->ipv6.mr6_rules_ops); 270 fib_rules_unregister(net->ipv6.mr6_rules_ops);
271 rtnl_unlock();
272} 272}
273#else 273#else
274#define ip6mr_for_each_table(mrt, net) \ 274#define ip6mr_for_each_table(mrt, net) \
@@ -336,7 +336,7 @@ static struct mr6_table *ip6mr_new_table(struct net *net, u32 id)
336 336
337static void ip6mr_free_table(struct mr6_table *mrt) 337static void ip6mr_free_table(struct mr6_table *mrt)
338{ 338{
339 del_timer(&mrt->ipmr_expire_timer); 339 del_timer_sync(&mrt->ipmr_expire_timer);
340 mroute_clean_tables(mrt); 340 mroute_clean_tables(mrt);
341 kfree(mrt); 341 kfree(mrt);
342} 342}
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index 471ed24aabae..14ecdaf06bf7 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -1218,7 +1218,14 @@ static void ndisc_router_discovery(struct sk_buff *skb)
1218 if (rt) 1218 if (rt)
1219 rt6_set_expires(rt, jiffies + (HZ * lifetime)); 1219 rt6_set_expires(rt, jiffies + (HZ * lifetime));
1220 if (ra_msg->icmph.icmp6_hop_limit) { 1220 if (ra_msg->icmph.icmp6_hop_limit) {
1221 in6_dev->cnf.hop_limit = ra_msg->icmph.icmp6_hop_limit; 1221 /* Only set hop_limit on the interface if it is higher than
1222 * the current hop_limit.
1223 */
1224 if (in6_dev->cnf.hop_limit < ra_msg->icmph.icmp6_hop_limit) {
1225 in6_dev->cnf.hop_limit = ra_msg->icmph.icmp6_hop_limit;
1226 } else {
1227 ND_PRINTK(2, warn, "RA: Got route advertisement with lower hop_limit than current\n");
1228 }
1222 if (rt) 1229 if (rt)
1223 dst_metric_set(&rt->dst, RTAX_HOPLIMIT, 1230 dst_metric_set(&rt->dst, RTAX_HOPLIMIT,
1224 ra_msg->icmph.icmp6_hop_limit); 1231 ra_msg->icmph.icmp6_hop_limit);
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 5d46832c6f72..1f5e62229aaa 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -1411,6 +1411,15 @@ static void tcp_v6_fill_cb(struct sk_buff *skb, const struct ipv6hdr *hdr,
1411 TCP_SKB_CB(skb)->sacked = 0; 1411 TCP_SKB_CB(skb)->sacked = 0;
1412} 1412}
1413 1413
1414static void tcp_v6_restore_cb(struct sk_buff *skb)
1415{
1416 /* We need to move header back to the beginning if xfrm6_policy_check()
1417 * and tcp_v6_fill_cb() are going to be called again.
1418 */
1419 memmove(IP6CB(skb), &TCP_SKB_CB(skb)->header.h6,
1420 sizeof(struct inet6_skb_parm));
1421}
1422
1414static int tcp_v6_rcv(struct sk_buff *skb) 1423static int tcp_v6_rcv(struct sk_buff *skb)
1415{ 1424{
1416 const struct tcphdr *th; 1425 const struct tcphdr *th;
@@ -1543,6 +1552,7 @@ do_time_wait:
1543 inet_twsk_deschedule(tw, &tcp_death_row); 1552 inet_twsk_deschedule(tw, &tcp_death_row);
1544 inet_twsk_put(tw); 1553 inet_twsk_put(tw);
1545 sk = sk2; 1554 sk = sk2;
1555 tcp_v6_restore_cb(skb);
1546 goto process; 1556 goto process;
1547 } 1557 }
1548 /* Fall through to ACK */ 1558 /* Fall through to ACK */
@@ -1551,6 +1561,7 @@ do_time_wait:
1551 tcp_v6_timewait_ack(sk, skb); 1561 tcp_v6_timewait_ack(sk, skb);
1552 break; 1562 break;
1553 case TCP_TW_RST: 1563 case TCP_TW_RST:
1564 tcp_v6_restore_cb(skb);
1554 goto no_tcp_socket; 1565 goto no_tcp_socket;
1555 case TCP_TW_SUCCESS: 1566 case TCP_TW_SUCCESS:
1556 ; 1567 ;
@@ -1585,7 +1596,7 @@ static void tcp_v6_early_demux(struct sk_buff *skb)
1585 skb->sk = sk; 1596 skb->sk = sk;
1586 skb->destructor = sock_edemux; 1597 skb->destructor = sock_edemux;
1587 if (sk->sk_state != TCP_TIME_WAIT) { 1598 if (sk->sk_state != TCP_TIME_WAIT) {
1588 struct dst_entry *dst = sk->sk_rx_dst; 1599 struct dst_entry *dst = READ_ONCE(sk->sk_rx_dst);
1589 1600
1590 if (dst) 1601 if (dst)
1591 dst = dst_check(dst, inet6_sk(sk)->rx_dst_cookie); 1602 dst = dst_check(dst, inet6_sk(sk)->rx_dst_cookie);
diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
index 2e9953b2db84..53d931172088 100644
--- a/net/iucv/af_iucv.c
+++ b/net/iucv/af_iucv.c
@@ -1114,10 +1114,8 @@ static int iucv_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
1114 noblock, &err); 1114 noblock, &err);
1115 else 1115 else
1116 skb = sock_alloc_send_skb(sk, len, noblock, &err); 1116 skb = sock_alloc_send_skb(sk, len, noblock, &err);
1117 if (!skb) { 1117 if (!skb)
1118 err = -ENOMEM;
1119 goto out; 1118 goto out;
1120 }
1121 if (iucv->transport == AF_IUCV_TRANS_HIPER) 1119 if (iucv->transport == AF_IUCV_TRANS_HIPER)
1122 skb_reserve(skb, sizeof(struct af_iucv_trans_hdr) + ETH_HLEN); 1120 skb_reserve(skb, sizeof(struct af_iucv_trans_hdr) + ETH_HLEN);
1123 if (memcpy_from_msg(skb_put(skb, len), msg, len)) { 1121 if (memcpy_from_msg(skb_put(skb, len), msg, len)) {
diff --git a/net/l2tp/l2tp_core.c b/net/l2tp/l2tp_core.c
index 895348e44c7d..a29a504492af 100644
--- a/net/l2tp/l2tp_core.c
+++ b/net/l2tp/l2tp_core.c
@@ -1871,6 +1871,7 @@ static int __init l2tp_init(void)
1871 l2tp_wq = alloc_workqueue("l2tp", WQ_UNBOUND, 0); 1871 l2tp_wq = alloc_workqueue("l2tp", WQ_UNBOUND, 0);
1872 if (!l2tp_wq) { 1872 if (!l2tp_wq) {
1873 pr_err("alloc_workqueue failed\n"); 1873 pr_err("alloc_workqueue failed\n");
1874 unregister_pernet_device(&l2tp_net_ops);
1874 rc = -ENOMEM; 1875 rc = -ENOMEM;
1875 goto out; 1876 goto out;
1876 } 1877 }
diff --git a/net/mac80211/agg-rx.c b/net/mac80211/agg-rx.c
index a48bad468880..7702978a4c99 100644
--- a/net/mac80211/agg-rx.c
+++ b/net/mac80211/agg-rx.c
@@ -49,8 +49,6 @@ static void ieee80211_free_tid_rx(struct rcu_head *h)
49 container_of(h, struct tid_ampdu_rx, rcu_head); 49 container_of(h, struct tid_ampdu_rx, rcu_head);
50 int i; 50 int i;
51 51
52 del_timer_sync(&tid_rx->reorder_timer);
53
54 for (i = 0; i < tid_rx->buf_size; i++) 52 for (i = 0; i < tid_rx->buf_size; i++)
55 __skb_queue_purge(&tid_rx->reorder_buf[i]); 53 __skb_queue_purge(&tid_rx->reorder_buf[i]);
56 kfree(tid_rx->reorder_buf); 54 kfree(tid_rx->reorder_buf);
@@ -93,6 +91,12 @@ void ___ieee80211_stop_rx_ba_session(struct sta_info *sta, u16 tid,
93 91
94 del_timer_sync(&tid_rx->session_timer); 92 del_timer_sync(&tid_rx->session_timer);
95 93
94 /* make sure ieee80211_sta_reorder_release() doesn't re-arm the timer */
95 spin_lock_bh(&tid_rx->reorder_lock);
96 tid_rx->removed = true;
97 spin_unlock_bh(&tid_rx->reorder_lock);
98 del_timer_sync(&tid_rx->reorder_timer);
99
96 call_rcu(&tid_rx->rcu_head, ieee80211_free_tid_rx); 100 call_rcu(&tid_rx->rcu_head, ieee80211_free_tid_rx);
97} 101}
98 102
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index 944bdc04e913..1eb730bf8752 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -873,9 +873,10 @@ static void ieee80211_sta_reorder_release(struct ieee80211_sub_if_data *sdata,
873 873
874 set_release_timer: 874 set_release_timer:
875 875
876 mod_timer(&tid_agg_rx->reorder_timer, 876 if (!tid_agg_rx->removed)
877 tid_agg_rx->reorder_time[j] + 1 + 877 mod_timer(&tid_agg_rx->reorder_timer,
878 HT_RX_REORDER_BUF_TIMEOUT); 878 tid_agg_rx->reorder_time[j] + 1 +
879 HT_RX_REORDER_BUF_TIMEOUT);
879 } else { 880 } else {
880 del_timer(&tid_agg_rx->reorder_timer); 881 del_timer(&tid_agg_rx->reorder_timer);
881 } 882 }
diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h
index 925e68fe64c7..fb0fc1302a58 100644
--- a/net/mac80211/sta_info.h
+++ b/net/mac80211/sta_info.h
@@ -175,6 +175,7 @@ struct tid_ampdu_tx {
175 * @reorder_lock: serializes access to reorder buffer, see below. 175 * @reorder_lock: serializes access to reorder buffer, see below.
176 * @auto_seq: used for offloaded BA sessions to automatically pick head_seq_and 176 * @auto_seq: used for offloaded BA sessions to automatically pick head_seq_and
177 * and ssn. 177 * and ssn.
178 * @removed: this session is removed (but might have been found due to RCU)
178 * 179 *
179 * This structure's lifetime is managed by RCU, assignments to 180 * This structure's lifetime is managed by RCU, assignments to
180 * the array holding it must hold the aggregation mutex. 181 * the array holding it must hold the aggregation mutex.
@@ -199,6 +200,7 @@ struct tid_ampdu_rx {
199 u16 timeout; 200 u16 timeout;
200 u8 dialog_token; 201 u8 dialog_token;
201 bool auto_seq; 202 bool auto_seq;
203 bool removed;
202}; 204};
203 205
204/** 206/**
diff --git a/net/openvswitch/vport.c b/net/openvswitch/vport.c
index ec2954ffc690..067a3fff1d2c 100644
--- a/net/openvswitch/vport.c
+++ b/net/openvswitch/vport.c
@@ -274,10 +274,8 @@ void ovs_vport_del(struct vport *vport)
274 ASSERT_OVSL(); 274 ASSERT_OVSL();
275 275
276 hlist_del_rcu(&vport->hash_node); 276 hlist_del_rcu(&vport->hash_node);
277
278 vport->ops->destroy(vport);
279
280 module_put(vport->ops->owner); 277 module_put(vport->ops->owner);
278 vport->ops->destroy(vport);
281} 279}
282 280
283/** 281/**
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
index 612aa73bbc60..e6ce1517367f 100644
--- a/net/sunrpc/clnt.c
+++ b/net/sunrpc/clnt.c
@@ -303,9 +303,7 @@ static int rpc_client_register(struct rpc_clnt *clnt,
303 struct super_block *pipefs_sb; 303 struct super_block *pipefs_sb;
304 int err; 304 int err;
305 305
306 err = rpc_clnt_debugfs_register(clnt); 306 rpc_clnt_debugfs_register(clnt);
307 if (err)
308 return err;
309 307
310 pipefs_sb = rpc_get_sb_net(net); 308 pipefs_sb = rpc_get_sb_net(net);
311 if (pipefs_sb) { 309 if (pipefs_sb) {
diff --git a/net/sunrpc/debugfs.c b/net/sunrpc/debugfs.c
index e811f390f9f6..82962f7e6e88 100644
--- a/net/sunrpc/debugfs.c
+++ b/net/sunrpc/debugfs.c
@@ -129,48 +129,52 @@ static const struct file_operations tasks_fops = {
129 .release = tasks_release, 129 .release = tasks_release,
130}; 130};
131 131
132int 132void
133rpc_clnt_debugfs_register(struct rpc_clnt *clnt) 133rpc_clnt_debugfs_register(struct rpc_clnt *clnt)
134{ 134{
135 int len, err; 135 int len;
136 char name[24]; /* enough for "../../rpc_xprt/ + 8 hex digits + NULL */ 136 char name[24]; /* enough for "../../rpc_xprt/ + 8 hex digits + NULL */
137 struct rpc_xprt *xprt;
137 138
138 /* Already registered? */ 139 /* Already registered? */
139 if (clnt->cl_debugfs) 140 if (clnt->cl_debugfs || !rpc_clnt_dir)
140 return 0; 141 return;
141 142
142 len = snprintf(name, sizeof(name), "%x", clnt->cl_clid); 143 len = snprintf(name, sizeof(name), "%x", clnt->cl_clid);
143 if (len >= sizeof(name)) 144 if (len >= sizeof(name))
144 return -EINVAL; 145 return;
145 146
146 /* make the per-client dir */ 147 /* make the per-client dir */
147 clnt->cl_debugfs = debugfs_create_dir(name, rpc_clnt_dir); 148 clnt->cl_debugfs = debugfs_create_dir(name, rpc_clnt_dir);
148 if (!clnt->cl_debugfs) 149 if (!clnt->cl_debugfs)
149 return -ENOMEM; 150 return;
150 151
151 /* make tasks file */ 152 /* make tasks file */
152 err = -ENOMEM;
153 if (!debugfs_create_file("tasks", S_IFREG | S_IRUSR, clnt->cl_debugfs, 153 if (!debugfs_create_file("tasks", S_IFREG | S_IRUSR, clnt->cl_debugfs,
154 clnt, &tasks_fops)) 154 clnt, &tasks_fops))
155 goto out_err; 155 goto out_err;
156 156
157 err = -EINVAL;
158 rcu_read_lock(); 157 rcu_read_lock();
158 xprt = rcu_dereference(clnt->cl_xprt);
159 /* no "debugfs" dentry? Don't bother with the symlink. */
160 if (!xprt->debugfs) {
161 rcu_read_unlock();
162 return;
163 }
159 len = snprintf(name, sizeof(name), "../../rpc_xprt/%s", 164 len = snprintf(name, sizeof(name), "../../rpc_xprt/%s",
160 rcu_dereference(clnt->cl_xprt)->debugfs->d_name.name); 165 xprt->debugfs->d_name.name);
161 rcu_read_unlock(); 166 rcu_read_unlock();
167
162 if (len >= sizeof(name)) 168 if (len >= sizeof(name))
163 goto out_err; 169 goto out_err;
164 170
165 err = -ENOMEM;
166 if (!debugfs_create_symlink("xprt", clnt->cl_debugfs, name)) 171 if (!debugfs_create_symlink("xprt", clnt->cl_debugfs, name))
167 goto out_err; 172 goto out_err;
168 173
169 return 0; 174 return;
170out_err: 175out_err:
171 debugfs_remove_recursive(clnt->cl_debugfs); 176 debugfs_remove_recursive(clnt->cl_debugfs);
172 clnt->cl_debugfs = NULL; 177 clnt->cl_debugfs = NULL;
173 return err;
174} 178}
175 179
176void 180void
@@ -226,33 +230,33 @@ static const struct file_operations xprt_info_fops = {
226 .release = xprt_info_release, 230 .release = xprt_info_release,
227}; 231};
228 232
229int 233void
230rpc_xprt_debugfs_register(struct rpc_xprt *xprt) 234rpc_xprt_debugfs_register(struct rpc_xprt *xprt)
231{ 235{
232 int len, id; 236 int len, id;
233 static atomic_t cur_id; 237 static atomic_t cur_id;
234 char name[9]; /* 8 hex digits + NULL term */ 238 char name[9]; /* 8 hex digits + NULL term */
235 239
240 if (!rpc_xprt_dir)
241 return;
242
236 id = (unsigned int)atomic_inc_return(&cur_id); 243 id = (unsigned int)atomic_inc_return(&cur_id);
237 244
238 len = snprintf(name, sizeof(name), "%x", id); 245 len = snprintf(name, sizeof(name), "%x", id);
239 if (len >= sizeof(name)) 246 if (len >= sizeof(name))
240 return -EINVAL; 247 return;
241 248
242 /* make the per-client dir */ 249 /* make the per-client dir */
243 xprt->debugfs = debugfs_create_dir(name, rpc_xprt_dir); 250 xprt->debugfs = debugfs_create_dir(name, rpc_xprt_dir);
244 if (!xprt->debugfs) 251 if (!xprt->debugfs)
245 return -ENOMEM; 252 return;
246 253
247 /* make tasks file */ 254 /* make tasks file */
248 if (!debugfs_create_file("info", S_IFREG | S_IRUSR, xprt->debugfs, 255 if (!debugfs_create_file("info", S_IFREG | S_IRUSR, xprt->debugfs,
249 xprt, &xprt_info_fops)) { 256 xprt, &xprt_info_fops)) {
250 debugfs_remove_recursive(xprt->debugfs); 257 debugfs_remove_recursive(xprt->debugfs);
251 xprt->debugfs = NULL; 258 xprt->debugfs = NULL;
252 return -ENOMEM;
253 } 259 }
254
255 return 0;
256} 260}
257 261
258void 262void
@@ -266,14 +270,17 @@ void __exit
266sunrpc_debugfs_exit(void) 270sunrpc_debugfs_exit(void)
267{ 271{
268 debugfs_remove_recursive(topdir); 272 debugfs_remove_recursive(topdir);
273 topdir = NULL;
274 rpc_clnt_dir = NULL;
275 rpc_xprt_dir = NULL;
269} 276}
270 277
271int __init 278void __init
272sunrpc_debugfs_init(void) 279sunrpc_debugfs_init(void)
273{ 280{
274 topdir = debugfs_create_dir("sunrpc", NULL); 281 topdir = debugfs_create_dir("sunrpc", NULL);
275 if (!topdir) 282 if (!topdir)
276 goto out; 283 return;
277 284
278 rpc_clnt_dir = debugfs_create_dir("rpc_clnt", topdir); 285 rpc_clnt_dir = debugfs_create_dir("rpc_clnt", topdir);
279 if (!rpc_clnt_dir) 286 if (!rpc_clnt_dir)
@@ -283,10 +290,9 @@ sunrpc_debugfs_init(void)
283 if (!rpc_xprt_dir) 290 if (!rpc_xprt_dir)
284 goto out_remove; 291 goto out_remove;
285 292
286 return 0; 293 return;
287out_remove: 294out_remove:
288 debugfs_remove_recursive(topdir); 295 debugfs_remove_recursive(topdir);
289 topdir = NULL; 296 topdir = NULL;
290out: 297 rpc_clnt_dir = NULL;
291 return -ENOMEM;
292} 298}
diff --git a/net/sunrpc/sunrpc_syms.c b/net/sunrpc/sunrpc_syms.c
index e37fbed87956..ee5d3d253102 100644
--- a/net/sunrpc/sunrpc_syms.c
+++ b/net/sunrpc/sunrpc_syms.c
@@ -98,10 +98,7 @@ init_sunrpc(void)
98 if (err) 98 if (err)
99 goto out4; 99 goto out4;
100 100
101 err = sunrpc_debugfs_init(); 101 sunrpc_debugfs_init();
102 if (err)
103 goto out5;
104
105#if IS_ENABLED(CONFIG_SUNRPC_DEBUG) 102#if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
106 rpc_register_sysctl(); 103 rpc_register_sysctl();
107#endif 104#endif
@@ -109,8 +106,6 @@ init_sunrpc(void)
109 init_socket_xprt(); /* clnt sock transport */ 106 init_socket_xprt(); /* clnt sock transport */
110 return 0; 107 return 0;
111 108
112out5:
113 unregister_rpc_pipefs();
114out4: 109out4:
115 unregister_pernet_subsys(&sunrpc_net_ops); 110 unregister_pernet_subsys(&sunrpc_net_ops);
116out3: 111out3:
diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c
index e3015aede0d9..9949722d99ce 100644
--- a/net/sunrpc/xprt.c
+++ b/net/sunrpc/xprt.c
@@ -1331,7 +1331,6 @@ static void xprt_init(struct rpc_xprt *xprt, struct net *net)
1331 */ 1331 */
1332struct rpc_xprt *xprt_create_transport(struct xprt_create *args) 1332struct rpc_xprt *xprt_create_transport(struct xprt_create *args)
1333{ 1333{
1334 int err;
1335 struct rpc_xprt *xprt; 1334 struct rpc_xprt *xprt;
1336 struct xprt_class *t; 1335 struct xprt_class *t;
1337 1336
@@ -1372,11 +1371,7 @@ found:
1372 return ERR_PTR(-ENOMEM); 1371 return ERR_PTR(-ENOMEM);
1373 } 1372 }
1374 1373
1375 err = rpc_xprt_debugfs_register(xprt); 1374 rpc_xprt_debugfs_register(xprt);
1376 if (err) {
1377 xprt_destroy(xprt);
1378 return ERR_PTR(err);
1379 }
1380 1375
1381 dprintk("RPC: created transport %p with %u slots\n", xprt, 1376 dprintk("RPC: created transport %p with %u slots\n", xprt,
1382 xprt->max_reqs); 1377 xprt->max_reqs);
diff --git a/net/tipc/core.c b/net/tipc/core.c
index 935205e6bcfe..be1c9fa60b09 100644
--- a/net/tipc/core.c
+++ b/net/tipc/core.c
@@ -152,11 +152,11 @@ out_netlink:
152static void __exit tipc_exit(void) 152static void __exit tipc_exit(void)
153{ 153{
154 tipc_bearer_cleanup(); 154 tipc_bearer_cleanup();
155 unregister_pernet_subsys(&tipc_net_ops);
155 tipc_netlink_stop(); 156 tipc_netlink_stop();
156 tipc_netlink_compat_stop(); 157 tipc_netlink_compat_stop();
157 tipc_socket_stop(); 158 tipc_socket_stop();
158 tipc_unregister_sysctl(); 159 tipc_unregister_sysctl();
159 unregister_pernet_subsys(&tipc_net_ops);
160 160
161 pr_info("Deactivated\n"); 161 pr_info("Deactivated\n");
162} 162}
diff --git a/sound/firewire/bebob/bebob_maudio.c b/sound/firewire/bebob/bebob_maudio.c
index a422aaa3bb0c..9ee25a63f684 100644
--- a/sound/firewire/bebob/bebob_maudio.c
+++ b/sound/firewire/bebob/bebob_maudio.c
@@ -96,10 +96,10 @@ int snd_bebob_maudio_load_firmware(struct fw_unit *unit)
96 struct fw_device *device = fw_parent_device(unit); 96 struct fw_device *device = fw_parent_device(unit);
97 int err, rcode; 97 int err, rcode;
98 u64 date; 98 u64 date;
99 __be32 cues[3] = { 99 __le32 cues[3] = {
100 MAUDIO_BOOTLOADER_CUE1, 100 cpu_to_le32(MAUDIO_BOOTLOADER_CUE1),
101 MAUDIO_BOOTLOADER_CUE2, 101 cpu_to_le32(MAUDIO_BOOTLOADER_CUE2),
102 MAUDIO_BOOTLOADER_CUE3 102 cpu_to_le32(MAUDIO_BOOTLOADER_CUE3)
103 }; 103 };
104 104
105 /* check date of software used to build */ 105 /* check date of software used to build */
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 74382137b9f5..f9d12c0a7e5a 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -2912,6 +2912,8 @@ static void alc283_init(struct hda_codec *codec)
2912 2912
2913 if (!hp_pin) 2913 if (!hp_pin)
2914 return; 2914 return;
2915
2916 msleep(30);
2915 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin); 2917 hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
2916 2918
2917 /* Index 0x43 Direct Drive HP AMP LPM Control 1 */ 2919 /* Index 0x43 Direct Drive HP AMP LPM Control 1 */
@@ -3607,6 +3609,7 @@ static void alc_headset_mode_unplugged(struct hda_codec *codec)
3607 3609
3608 switch (codec->vendor_id) { 3610 switch (codec->vendor_id) {
3609 case 0x10ec0255: 3611 case 0x10ec0255:
3612 case 0x10ec0256:
3610 alc_process_coef_fw(codec, coef0255); 3613 alc_process_coef_fw(codec, coef0255);
3611 break; 3614 break;
3612 case 0x10ec0233: 3615 case 0x10ec0233:
@@ -3662,6 +3665,7 @@ static void alc_headset_mode_mic_in(struct hda_codec *codec, hda_nid_t hp_pin,
3662 3665
3663 switch (codec->vendor_id) { 3666 switch (codec->vendor_id) {
3664 case 0x10ec0255: 3667 case 0x10ec0255:
3668 case 0x10ec0256:
3665 alc_write_coef_idx(codec, 0x45, 0xc489); 3669 alc_write_coef_idx(codec, 0x45, 0xc489);
3666 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0); 3670 snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
3667 alc_process_coef_fw(codec, coef0255); 3671 alc_process_coef_fw(codec, coef0255);
@@ -3731,6 +3735,7 @@ static void alc_headset_mode_default(struct hda_codec *codec)
3731 3735
3732 switch (codec->vendor_id) { 3736 switch (codec->vendor_id) {
3733 case 0x10ec0255: 3737 case 0x10ec0255:
3738 case 0x10ec0256:
3734 alc_process_coef_fw(codec, coef0255); 3739 alc_process_coef_fw(codec, coef0255);
3735 break; 3740 break;
3736 case 0x10ec0233: 3741 case 0x10ec0233:
@@ -3785,6 +3790,7 @@ static void alc_headset_mode_ctia(struct hda_codec *codec)
3785 3790
3786 switch (codec->vendor_id) { 3791 switch (codec->vendor_id) {
3787 case 0x10ec0255: 3792 case 0x10ec0255:
3793 case 0x10ec0256:
3788 alc_process_coef_fw(codec, coef0255); 3794 alc_process_coef_fw(codec, coef0255);
3789 break; 3795 break;
3790 case 0x10ec0233: 3796 case 0x10ec0233:
@@ -3839,6 +3845,7 @@ static void alc_headset_mode_omtp(struct hda_codec *codec)
3839 3845
3840 switch (codec->vendor_id) { 3846 switch (codec->vendor_id) {
3841 case 0x10ec0255: 3847 case 0x10ec0255:
3848 case 0x10ec0256:
3842 alc_process_coef_fw(codec, coef0255); 3849 alc_process_coef_fw(codec, coef0255);
3843 break; 3850 break;
3844 case 0x10ec0233: 3851 case 0x10ec0233:
@@ -3884,6 +3891,7 @@ static void alc_determine_headset_type(struct hda_codec *codec)
3884 3891
3885 switch (codec->vendor_id) { 3892 switch (codec->vendor_id) {
3886 case 0x10ec0255: 3893 case 0x10ec0255:
3894 case 0x10ec0256:
3887 alc_process_coef_fw(codec, coef0255); 3895 alc_process_coef_fw(codec, coef0255);
3888 msleep(300); 3896 msleep(300);
3889 val = alc_read_coef_idx(codec, 0x46); 3897 val = alc_read_coef_idx(codec, 0x46);
@@ -4364,6 +4372,7 @@ enum {
4364 ALC269_FIXUP_QUANTA_MUTE, 4372 ALC269_FIXUP_QUANTA_MUTE,
4365 ALC269_FIXUP_LIFEBOOK, 4373 ALC269_FIXUP_LIFEBOOK,
4366 ALC269_FIXUP_LIFEBOOK_EXTMIC, 4374 ALC269_FIXUP_LIFEBOOK_EXTMIC,
4375 ALC269_FIXUP_LIFEBOOK_HP_PIN,
4367 ALC269_FIXUP_AMIC, 4376 ALC269_FIXUP_AMIC,
4368 ALC269_FIXUP_DMIC, 4377 ALC269_FIXUP_DMIC,
4369 ALC269VB_FIXUP_AMIC, 4378 ALC269VB_FIXUP_AMIC,
@@ -4517,6 +4526,13 @@ static const struct hda_fixup alc269_fixups[] = {
4517 { } 4526 { }
4518 }, 4527 },
4519 }, 4528 },
4529 [ALC269_FIXUP_LIFEBOOK_HP_PIN] = {
4530 .type = HDA_FIXUP_PINS,
4531 .v.pins = (const struct hda_pintbl[]) {
4532 { 0x21, 0x0221102f }, /* HP out */
4533 { }
4534 },
4535 },
4520 [ALC269_FIXUP_AMIC] = { 4536 [ALC269_FIXUP_AMIC] = {
4521 .type = HDA_FIXUP_PINS, 4537 .type = HDA_FIXUP_PINS,
4522 .v.pins = (const struct hda_pintbl[]) { 4538 .v.pins = (const struct hda_pintbl[]) {
@@ -5010,6 +5026,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
5010 SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ), 5026 SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
5011 SND_PCI_QUIRK(0x104d, 0x9099, "Sony VAIO S13", ALC275_FIXUP_SONY_DISABLE_AAMIX), 5027 SND_PCI_QUIRK(0x104d, 0x9099, "Sony VAIO S13", ALC275_FIXUP_SONY_DISABLE_AAMIX),
5012 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook", ALC269_FIXUP_LIFEBOOK), 5028 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook", ALC269_FIXUP_LIFEBOOK),
5029 SND_PCI_QUIRK(0x10cf, 0x15dc, "Lifebook T731", ALC269_FIXUP_LIFEBOOK_HP_PIN),
5013 SND_PCI_QUIRK(0x10cf, 0x1845, "Lifebook U904", ALC269_FIXUP_LIFEBOOK_EXTMIC), 5030 SND_PCI_QUIRK(0x10cf, 0x1845, "Lifebook U904", ALC269_FIXUP_LIFEBOOK_EXTMIC),
5014 SND_PCI_QUIRK(0x144d, 0xc109, "Samsung Ativ book 9 (NP900X3G)", ALC269_FIXUP_INV_DMIC), 5031 SND_PCI_QUIRK(0x144d, 0xc109, "Samsung Ativ book 9 (NP900X3G)", ALC269_FIXUP_INV_DMIC),
5015 SND_PCI_QUIRK(0x1458, 0xfa53, "Gigabyte BXBT-2807", ALC283_FIXUP_BXBT2807_MIC), 5032 SND_PCI_QUIRK(0x1458, 0xfa53, "Gigabyte BXBT-2807", ALC283_FIXUP_BXBT2807_MIC),
@@ -5217,6 +5234,16 @@ static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = {
5217 {0x17, 0x40000000}, 5234 {0x17, 0x40000000},
5218 {0x1d, 0x40700001}, 5235 {0x1d, 0x40700001},
5219 {0x21, 0x02211050}), 5236 {0x21, 0x02211050}),
5237 SND_HDA_PIN_QUIRK(0x10ec0256, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
5238 {0x12, 0x90a60140},
5239 {0x13, 0x40000000},
5240 {0x14, 0x90170110},
5241 {0x19, 0x411111f0},
5242 {0x1a, 0x411111f0},
5243 {0x1b, 0x411111f0},
5244 {0x1d, 0x40700001},
5245 {0x1e, 0x411111f0},
5246 {0x21, 0x02211020}),
5220 SND_HDA_PIN_QUIRK(0x10ec0280, 0x103c, "HP", ALC280_FIXUP_HP_GPIO4, 5247 SND_HDA_PIN_QUIRK(0x10ec0280, 0x103c, "HP", ALC280_FIXUP_HP_GPIO4,
5221 {0x12, 0x90a60130}, 5248 {0x12, 0x90a60130},
5222 {0x13, 0x40000000}, 5249 {0x13, 0x40000000},
diff --git a/sound/soc/codecs/pcm512x.c b/sound/soc/codecs/pcm512x.c
index 9974f201a08f..474cae82a874 100644
--- a/sound/soc/codecs/pcm512x.c
+++ b/sound/soc/codecs/pcm512x.c
@@ -1156,25 +1156,6 @@ static int pcm512x_hw_params(struct snd_pcm_substream *substream,
1156 ret, pcm512x->pll_out); 1156 ret, pcm512x->pll_out);
1157 return ret; 1157 return ret;
1158 } 1158 }
1159
1160 gpio = PCM512x_G1OE << (4 - 1);
1161 ret = regmap_update_bits(pcm512x->regmap, PCM512x_GPIO_EN,
1162 gpio, gpio);
1163 if (ret != 0) {
1164 dev_err(codec->dev, "Failed to enable gpio %d: %d\n",
1165 4, ret);
1166 return ret;
1167 }
1168
1169 gpio = PCM512x_GPIO_OUTPUT_1 + 4 - 1;
1170 ret = regmap_update_bits(pcm512x->regmap, gpio,
1171 PCM512x_GxSL, PCM512x_GxSL_PLLLK);
1172 if (ret != 0) {
1173 dev_err(codec->dev,
1174 "Failed to output pll lock on %d: %d\n",
1175 ret, 4);
1176 return ret;
1177 }
1178 } 1159 }
1179 1160
1180 ret = regmap_update_bits(pcm512x->regmap, PCM512x_SYNCHRONIZE, 1161 ret = regmap_update_bits(pcm512x->regmap, PCM512x_SYNCHRONIZE,
diff --git a/sound/usb/mixer_quirks.c b/sound/usb/mixer_quirks.c
index dc9df007d3e3..337c317ead6f 100644
--- a/sound/usb/mixer_quirks.c
+++ b/sound/usb/mixer_quirks.c
@@ -192,6 +192,7 @@ static const struct rc_config {
192 { USB_ID(0x041e, 0x3040), 2, 2, 6, 6, 2, 0x6e91 }, /* Live! 24-bit */ 192 { USB_ID(0x041e, 0x3040), 2, 2, 6, 6, 2, 0x6e91 }, /* Live! 24-bit */
193 { USB_ID(0x041e, 0x3042), 0, 1, 1, 1, 1, 0x000d }, /* Usb X-Fi S51 */ 193 { USB_ID(0x041e, 0x3042), 0, 1, 1, 1, 1, 0x000d }, /* Usb X-Fi S51 */
194 { USB_ID(0x041e, 0x30df), 0, 1, 1, 1, 1, 0x000d }, /* Usb X-Fi S51 Pro */ 194 { USB_ID(0x041e, 0x30df), 0, 1, 1, 1, 1, 0x000d }, /* Usb X-Fi S51 Pro */
195 { USB_ID(0x041e, 0x3237), 0, 1, 1, 1, 1, 0x000d }, /* Usb X-Fi S51 Pro */
195 { USB_ID(0x041e, 0x3048), 2, 2, 6, 6, 2, 0x6e91 }, /* Toshiba SB0500 */ 196 { USB_ID(0x041e, 0x3048), 2, 2, 6, 6, 2, 0x6e91 }, /* Toshiba SB0500 */
196}; 197};
197 198
diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c
index 753a47de8459..9a28365126f9 100644
--- a/sound/usb/quirks.c
+++ b/sound/usb/quirks.c
@@ -1113,8 +1113,13 @@ void snd_usb_set_format_quirk(struct snd_usb_substream *subs,
1113 1113
1114bool snd_usb_get_sample_rate_quirk(struct snd_usb_audio *chip) 1114bool snd_usb_get_sample_rate_quirk(struct snd_usb_audio *chip)
1115{ 1115{
1116 /* MS Lifecam HD-5000 doesn't support reading the sample rate. */ 1116 /* devices which do not support reading the sample rate. */
1117 return chip->usb_id == USB_ID(0x045E, 0x076D); 1117 switch (chip->usb_id) {
1118 case USB_ID(0x045E, 0x076D): /* MS Lifecam HD-5000 */
1119 case USB_ID(0x04D8, 0xFEEA): /* Benchmark DAC1 Pre */
1120 return true;
1121 }
1122 return false;
1118} 1123}
1119 1124
1120/* Marantz/Denon USB DACs need a vendor cmd to switch 1125/* Marantz/Denon USB DACs need a vendor cmd to switch