From a6511dec0ada86c55cd672e1ecca0e3ad0d9c1d6 Mon Sep 17 00:00:00 2001 From: Peter Vicman Date: Tue, 4 Oct 2016 20:23:13 +0200 Subject: [PATCH] imx6: bump linux to 4.4.19 --- packages/linux/package.mk | 2 +- .../linux/4.4-xbian/linux-000-from-mk01.patch | 63383 ---------------- 2 files changed, 1 insertion(+), 63384 deletions(-) delete mode 100644 projects/imx6/patches/linux/4.4-xbian/linux-000-from-mk01.patch diff --git a/packages/linux/package.mk b/packages/linux/package.mk index f99859b671..1c049a7615 100644 --- a/packages/linux/package.mk +++ b/packages/linux/package.mk @@ -53,7 +53,7 @@ case "$LINUX" in ;; imx6-4.4-xbian) PKG_VERSION="4.4-xbian" - PKG_COMMIT="20160403-d08b62d" + PKG_COMMIT="20160821-f14907b" PKG_SOURCE_DIR="$PKG_NAME-$PKG_VERSION-$PKG_COMMIT" PKG_SOURCE_NAME="$PKG_SOURCE_DIR.tar.xz" PKG_URL="$DISTRO_SRC/$PKG_SOURCE_NAME" diff --git a/projects/imx6/patches/linux/4.4-xbian/linux-000-from-mk01.patch b/projects/imx6/patches/linux/4.4-xbian/linux-000-from-mk01.patch deleted file mode 100644 index 142d111d7e..0000000000 --- a/projects/imx6/patches/linux/4.4-xbian/linux-000-from-mk01.patch +++ /dev/null @@ -1,63383 +0,0 @@ -From 09b4602e20e6792ca1cbad8191a436bec11b0f64 Mon Sep 17 00:00:00 2001 -From: Peter Vicman -Date: Sun, 10 Jul 2016 13:45:21 +0200 -Subject: [PATCH] patch for linux from mk01 - -linux base: linux-4.4-xbian-20160403-d08b62d -linux mk01: - https://github.com/mk01/linux-fslc/tree/imx6-4.4.y b44d3e1999d75af99aa0821b430cb8fe45a6f570 ---- - .../devicetree/bindings/ata/ahci-platform.txt | 4 + - .../devicetree/bindings/clock/imx35-clock.txt | 1 + - .../bindings/pinctrl/img,pistachio-pinctrl.txt | 12 +- - .../devicetree/bindings/sound/fsl,esai.txt | 4 + - .../devicetree/bindings/sound/fsl,spdif.txt | 4 + - .../devicetree/bindings/sound/fsl,ssi.txt | 4 + - Documentation/kernel-parameters.txt | 11 + - Documentation/serial/tty.txt | 3 - - Documentation/sysctl/fs.txt | 23 + - MAINTAINERS | 100 +-- - Makefile | 12 +- - arch/Kconfig | 1 + - arch/arc/include/asm/bitops.h | 15 - - arch/arc/include/asm/io.h | 45 +- - arch/arm/boot/dts/Makefile | 4 + - arch/arm/boot/dts/am43x-epos-evm.dts | 5 + - arch/arm/boot/dts/armada-375.dtsi | 2 +- - arch/arm/boot/dts/armada-385-linksys.dtsi | 2 +- - arch/arm/boot/dts/at91-sama5d3_xplained.dts | 1 + - arch/arm/boot/dts/at91-sama5d4_xplained.dts | 1 + - arch/arm/boot/dts/at91sam9x5.dtsi | 2 +- - arch/arm/boot/dts/exynos4210-trats.dts | 2 + - arch/arm/boot/dts/imx6dl-udoo-15lvds.dts | 63 ++ - arch/arm/boot/dts/imx6dl-udoo-7lvds.dts | 58 ++ - arch/arm/boot/dts/imx6q-tbs2910.dts | 2 +- - arch/arm/boot/dts/imx6q-udoo-15lvds.dts | 67 ++ - arch/arm/boot/dts/imx6q-udoo-7lvds.dts | 62 ++ - arch/arm/boot/dts/imx6qdl-udoo.dtsi | 6 +- - arch/arm/boot/dts/imx6qdl.dtsi | 5 +- - arch/arm/boot/dts/pxa3xx.dtsi | 2 +- - arch/arm/boot/dts/sama5d2-pinfunc.h | 4 +- - arch/arm/configs/xbian_defconfig_imx6_mvebu | 199 ++--- - arch/arm/kernel/entry-armv.S | 6 +- - arch/arm/kernel/ptrace.c | 2 +- - arch/arm/kvm/arm.c | 12 +- - arch/arm/kvm/mmu.c | 17 +- - arch/arm/kvm/psci.c | 4 +- - arch/arm/mach-at91/Kconfig | 1 + - arch/arm/mach-at91/at91rm9200.c | 2 - - arch/arm/mach-at91/at91sam9.c | 2 - - arch/arm/mach-at91/generic.h | 13 +- - arch/arm/mach-at91/pm.c | 70 +- - arch/arm/mach-at91/sama5.c | 2 +- - arch/arm/mach-cns3xxx/pcie.c | 6 +- - arch/arm/mach-exynos/Kconfig | 1 + - arch/arm/mach-exynos/pm_domains.c | 2 +- - arch/arm/mach-imx/Kconfig | 3 +- - arch/arm/mach-imx/common.h | 1 + - arch/arm/mach-imx/gpc.c | 147 +++- - arch/arm/mach-imx/mach-imx6q.c | 118 ++- - arch/arm/mach-imx/mach-imx6sl.c | 11 +- - arch/arm/mach-imx/mach-imx6sx.c | 1 + - arch/arm/mach-imx/mach-imx7d.c | 1 + - arch/arm/mach-omap2/cpuidle34xx.c | 69 +- - arch/arm/mach-omap2/io.c | 1 + - arch/arm/mach-omap2/omap_hwmod.c | 8 +- - arch/arm/mach-prima2/Kconfig | 1 + - arch/arm/mach-s3c64xx/dev-audio.c | 41 +- - arch/arm/mach-s3c64xx/include/mach/dma.h | 52 +- - arch/arm/mach-socfpga/headsmp.S | 1 + - arch/arm/plat-samsung/devs.c | 11 +- - arch/arm64/include/asm/elf.h | 4 +- - arch/arm64/include/asm/opcodes.h | 4 + - arch/arm64/include/asm/pgtable-hwdef.h | 1 - - arch/arm64/include/asm/pgtable.h | 47 +- - arch/arm64/kernel/cpuinfo.c | 11 +- - arch/arm64/kvm/inject_fault.c | 2 +- - arch/arm64/mm/fault.c | 50 ++ - arch/ia64/include/asm/io.h | 1 + - arch/mips/alchemy/devboards/db1000.c | 18 +- - arch/mips/alchemy/devboards/db1550.c | 4 +- - arch/mips/ath79/early_printk.c | 6 +- - arch/mips/include/asm/asmmacro.h | 40 +- - arch/mips/include/asm/cacheflush.h | 6 - - arch/mips/include/asm/kvm_host.h | 2 +- - arch/mips/include/asm/msa.h | 13 + - arch/mips/include/asm/pgtable.h | 26 +- - arch/mips/include/asm/processor.h | 2 +- - arch/mips/include/asm/switch_to.h | 2 +- - arch/mips/include/asm/watch.h | 10 +- - arch/mips/include/uapi/asm/siginfo.h | 22 +- - arch/mips/kernel/mips-r2-to-r6-emul.c | 105 +-- - arch/mips/kernel/pm.c | 2 +- - arch/mips/kernel/process.c | 6 +- - arch/mips/kernel/ptrace.c | 27 +- - arch/mips/kernel/r4k_fpu.S | 10 +- - arch/mips/kernel/setup.c | 3 + - arch/mips/kernel/signal.c | 15 +- - arch/mips/kernel/traps.c | 8 +- - arch/mips/kernel/unaligned.c | 51 +- - arch/mips/kernel/watch.c | 5 +- - arch/mips/kvm/emulate.c | 89 ++- - arch/mips/kvm/mips.c | 8 +- - arch/mips/kvm/trap_emul.c | 2 +- - arch/mips/lib/ashldi3.c | 2 +- - arch/mips/lib/ashrdi3.c | 2 +- - arch/mips/lib/bswapdi.c | 2 +- - arch/mips/lib/bswapsi.c | 2 +- - arch/mips/lib/cmpdi2.c | 2 +- - arch/mips/lib/lshrdi3.c | 2 +- - arch/mips/lib/ucmpdi2.c | 2 +- - arch/mips/loongson64/loongson-3/numa.c | 6 +- - arch/mips/math-emu/cp1emu.c | 8 +- - arch/mips/mm/cache.c | 41 +- - arch/mips/vdso/Makefile | 4 +- - arch/parisc/include/asm/uaccess.h | 1 + - arch/parisc/kernel/asm-offsets.c | 1 + - arch/parisc/kernel/parisc_ksyms.c | 10 +- - arch/parisc/kernel/traps.c | 3 + - arch/parisc/kernel/unaligned.c | 10 +- - arch/parisc/lib/fixup.S | 6 + - arch/parisc/mm/fault.c | 1 + - arch/powerpc/include/asm/kvm_host.h | 4 +- - arch/powerpc/include/asm/reg.h | 6 +- - arch/powerpc/include/asm/word-at-a-time.h | 2 +- - arch/powerpc/include/uapi/asm/cputable.h | 1 + - arch/powerpc/kernel/eeh.c | 2 +- - arch/powerpc/kernel/eeh_driver.c | 26 +- - arch/powerpc/kernel/exceptions-64s.S | 16 +- - arch/powerpc/kernel/process.c | 18 - - arch/powerpc/kernel/prom.c | 26 +- - arch/powerpc/kernel/prom_init.c | 1 + - arch/powerpc/kvm/book3s_hv.c | 22 +- - arch/powerpc/mm/hugetlbpage.c | 4 +- - arch/powerpc/platforms/pseries/eeh_pseries.c | 51 +- - arch/s390/include/asm/kvm_host.h | 2 +- - arch/s390/include/asm/mmu.h | 2 +- - arch/s390/include/asm/mmu_context.h | 28 +- - arch/s390/include/asm/pci.h | 3 +- - arch/s390/include/asm/pgalloc.h | 4 +- - arch/s390/include/asm/processor.h | 2 +- - arch/s390/include/asm/tlbflush.h | 9 +- - arch/s390/kernel/entry.S | 106 +-- - arch/s390/kernel/head64.S | 2 +- - arch/s390/kernel/setup.c | 1 + - arch/s390/kvm/interrupt.c | 4 +- - arch/s390/mm/init.c | 3 +- - arch/s390/mm/mmap.c | 6 +- - arch/s390/mm/pgtable.c | 85 +-- - arch/s390/net/bpf_jit.h | 4 +- - arch/s390/net/bpf_jit_comp.c | 4 +- - arch/s390/pci/pci.c | 5 +- - arch/sh/mm/kmap.c | 2 + - arch/sparc/include/asm/head_64.h | 4 + - arch/sparc/include/asm/pgtable_64.h | 43 +- - arch/sparc/include/asm/tlbflush_64.h | 3 +- - arch/sparc/include/asm/ttable.h | 8 +- - arch/sparc/kernel/Makefile | 1 + - arch/sparc/kernel/cherrs.S | 14 +- - arch/sparc/kernel/entry.S | 17 + - arch/sparc/kernel/fpu_traps.S | 11 +- - arch/sparc/kernel/head_64.S | 24 +- - arch/sparc/kernel/misctrap.S | 12 +- - arch/sparc/kernel/pci.c | 17 + - arch/sparc/kernel/rtrap_64.S | 57 +- - arch/sparc/kernel/signal32.c | 46 +- - arch/sparc/kernel/signal_32.c | 41 +- - arch/sparc/kernel/signal_64.c | 33 +- - arch/sparc/kernel/sigutil_32.c | 9 +- - arch/sparc/kernel/sigutil_64.c | 10 +- - arch/sparc/kernel/spiterrs.S | 18 +- - arch/sparc/kernel/syscalls.S | 36 + - arch/sparc/kernel/urtt_fill.S | 98 +++ - arch/sparc/kernel/utrap.S | 3 +- - arch/sparc/kernel/vmlinux.lds.S | 4 + - arch/sparc/kernel/winfixup.S | 3 +- - arch/sparc/mm/hugetlbpage.c | 33 +- - arch/sparc/mm/init_64.c | 37 +- - arch/sparc/mm/tlb.c | 25 +- - arch/sparc/mm/tsb.c | 32 +- - arch/um/drivers/mconsole_kern.c | 2 +- - arch/x86/Kconfig | 27 +- - arch/x86/crypto/sha-mb/sha1_mb.c | 4 +- - arch/x86/entry/common.c | 23 +- - arch/x86/include/asm/apic.h | 2 +- - arch/x86/include/asm/hugetlb.h | 1 + - arch/x86/include/asm/hw_irq.h | 1 + - arch/x86/include/asm/kvm_host.h | 2 +- - arch/x86/include/asm/microcode.h | 26 + - arch/x86/include/asm/pci_x86.h | 2 + - arch/x86/include/asm/perf_event.h | 1 + - arch/x86/include/asm/xen/hypervisor.h | 2 + - arch/x86/kernel/apic/vector.c | 91 ++- - arch/x86/kernel/cpu/mcheck/mce-genpool.c | 4 +- - arch/x86/kernel/cpu/mcheck/therm_throt.c | 3 + - arch/x86/kernel/cpu/microcode/intel.c | 38 +- - arch/x86/kernel/cpu/perf_event.c | 13 + - arch/x86/kernel/cpu/perf_event.h | 3 + - arch/x86/kernel/cpu/perf_event_intel.c | 27 +- - arch/x86/kernel/cpu/perf_event_intel_ds.c | 24 +- - arch/x86/kernel/cpu/perf_event_intel_pt.c | 2 + - arch/x86/kernel/cpu/perf_event_intel_rapl.c | 20 +- - arch/x86/kernel/cpu/perf_event_knc.c | 4 +- - arch/x86/kernel/ioport.c | 12 +- - arch/x86/kernel/kvm.c | 37 +- - arch/x86/kernel/nmi.c | 16 +- - arch/x86/kernel/process_64.c | 12 + - arch/x86/kernel/reboot.c | 20 + - arch/x86/kernel/smpboot.c | 5 + - arch/x86/kernel/sysfb_efi.c | 14 +- - arch/x86/kernel/traps.c | 20 +- - arch/x86/kernel/tsc_msr.c | 2 +- - arch/x86/kvm/cpuid.c | 1 + - arch/x86/kvm/i8254.c | 12 +- - arch/x86/kvm/lapic.c | 6 +- - arch/x86/kvm/mtrr.c | 2 - - arch/x86/kvm/vmx.c | 18 +- - arch/x86/kvm/x86.c | 36 +- - arch/x86/mm/kmmio.c | 88 ++- - arch/x86/mm/tlb.c | 12 +- - arch/x86/pci/common.c | 26 +- - arch/x86/pci/fixup.c | 7 + - arch/x86/pci/intel_mid_pci.c | 9 +- - arch/x86/pci/irq.c | 23 +- - arch/x86/pci/xen.c | 7 +- - arch/x86/xen/enlighten.c | 2 +- - arch/x86/xen/setup.c | 65 +- - arch/xtensa/kernel/head.S | 2 +- - arch/xtensa/mm/cache.c | 8 +- - arch/xtensa/platforms/iss/console.c | 10 +- - block/blk-core.c | 6 +- - block/blk-mq.c | 4 +- - block/partition-generic.c | 13 +- - crypto/ahash.c | 3 +- - crypto/asymmetric_keys/Kconfig | 1 + - crypto/asymmetric_keys/pkcs7_trust.c | 2 + - crypto/asymmetric_keys/x509_cert_parser.c | 8 +- - crypto/keywrap.c | 4 +- - crypto/testmgr.c | 27 +- - drivers/acpi/acpi_processor.c | 52 ++ - drivers/acpi/acpica/dsmethod.c | 3 + - drivers/acpi/bus.c | 3 + - drivers/acpi/internal.h | 6 + - drivers/acpi/osl.c | 16 +- - drivers/acpi/pci_irq.c | 17 +- - drivers/acpi/resource.c | 14 +- - drivers/acpi/sleep.c | 1 + - drivers/ata/ahci_platform.c | 3 + - drivers/ata/ahci_xgene.c | 4 +- - drivers/ata/libahci.c | 1 + - drivers/base/power/domain.c | 2 +- - drivers/base/power/main.c | 5 +- - drivers/base/power/opp/core.c | 10 +- - drivers/base/power/runtime.c | 9 +- - drivers/base/regmap/regmap-spmi.c | 2 +- - drivers/block/brd.c | 2 +- - drivers/block/loop.c | 6 + - drivers/block/mtip32xx/mtip32xx.c | 267 +++++-- - drivers/block/mtip32xx/mtip32xx.h | 11 +- - drivers/block/nbd.c | 4 +- - drivers/block/paride/pd.c | 4 +- - drivers/block/paride/pt.c | 4 +- - drivers/block/rbd.c | 6 +- - drivers/block/zram/zram_drv.c | 30 +- - drivers/block/zram/zram_drv.h | 41 + - drivers/bluetooth/ath3k.c | 8 + - drivers/bluetooth/btusb.c | 4 + - drivers/bluetooth/hci_vhci.c | 28 +- - drivers/bus/imx-weim.c | 2 +- - drivers/char/hw_random/exynos-rng.c | 10 +- - drivers/char/tpm/tpm-chip.c | 14 +- - drivers/char/tpm/tpm_crb.c | 4 +- - drivers/char/tpm/tpm_eventlog.c | 14 +- - drivers/clk/at91/clk-generated.c | 95 ++- - drivers/clk/at91/clk-h32mx.c | 42 +- - drivers/clk/at91/clk-main.c | 324 ++++---- - drivers/clk/at91/clk-master.c | 94 +-- - drivers/clk/at91/clk-peripheral.c | 136 ++-- - drivers/clk/at91/clk-pll.c | 150 ++-- - drivers/clk/at91/clk-plldiv.c | 44 +- - drivers/clk/at91/clk-programmable.c | 96 +-- - drivers/clk/at91/clk-slow.c | 34 +- - drivers/clk/at91/clk-smd.c | 56 +- - drivers/clk/at91/clk-system.c | 96 +-- - drivers/clk/at91/clk-usb.c | 123 +-- - drivers/clk/at91/clk-utmi.c | 80 +- - drivers/clk/at91/pmc.c | 426 +---------- - drivers/clk/at91/pmc.h | 98 +-- - drivers/clk/bcm/clk-bcm2835.c | 35 +- - drivers/clk/clk-divider.c | 11 +- - drivers/clk/imx/clk-imx35.c | 4 +- - drivers/clk/imx/clk-imx6q.c | 23 +- - drivers/clk/meson/clkc.c | 2 +- - drivers/clk/nxp/clk-lpc18xx-ccu.c | 2 +- - drivers/clk/qcom/gcc-msm8916.c | 2 + - drivers/clk/qcom/gcc-msm8960.c | 4 +- - drivers/clk/rockchip/clk-rk3188.c | 1 + - drivers/clk/rockchip/clk-rk3368.c | 48 +- - drivers/clk/rockchip/clk.c | 13 +- - drivers/clk/versatile/clk-sp810.c | 4 +- - drivers/clocksource/tcb_clksrc.c | 33 +- - drivers/clocksource/timer-atmel-pit.c | 8 +- - drivers/cpufreq/intel_pstate.c | 5 + - drivers/cpuidle/cpuidle-arm.c | 2 +- - drivers/cpuidle/cpuidle.c | 4 +- - drivers/crypto/atmel-aes.c | 4 +- - drivers/crypto/atmel-sha.c | 4 +- - drivers/crypto/atmel-tdes.c | 4 +- - drivers/crypto/caam/jr.c | 2 +- - drivers/crypto/ccp/ccp-crypto-aes-cmac.c | 39 + - drivers/crypto/ccp/ccp-crypto-aes-xts.c | 17 +- - drivers/crypto/ccp/ccp-crypto-sha.c | 43 ++ - drivers/crypto/ccp/ccp-crypto.h | 22 + - drivers/crypto/marvell/cesa.c | 2 +- - drivers/crypto/qat/qat_common/adf_common_drv.h | 11 + - drivers/crypto/qat/qat_common/adf_ctl_drv.c | 6 + - drivers/crypto/qat/qat_common/adf_sriov.c | 26 +- - drivers/crypto/sunxi-ss/sun4i-ss-cipher.c | 10 +- - drivers/crypto/talitos.c | 151 +++- - drivers/crypto/ux500/cryp/cryp_core.c | 4 +- - drivers/crypto/ux500/hash/hash_core.c | 4 +- - drivers/dma/dw/core.c | 34 +- - drivers/dma/hsu/hsu.c | 2 +- - drivers/dma/hsu/hsu.h | 3 + - drivers/dma/pxa_dma.c | 39 +- - drivers/edac/amd64_edac.c | 2 +- - drivers/edac/i7core_edac.c | 2 +- - drivers/edac/sb_edac.c | 30 +- - drivers/extcon/extcon-max77843.c | 2 +- - drivers/firmware/efi/efi.c | 1 + - drivers/firmware/efi/vars.c | 37 +- - drivers/gpio/gpio-bcm-kona.c | 4 +- - drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + - drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c | 10 +- - drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.c | 2 +- - drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 2 +- - drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h | 6 +- - drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 1 + - drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 5 + - drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c | 1 + - drivers/gpu/drm/amd/amdgpu/atombios_encoders.c | 4 + - drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c | 2 +- - drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c | 16 +- - drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c | 23 +- - drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c | 4 +- - drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c | 2 +- - drivers/gpu/drm/drm_atomic.c | 2 +- - drivers/gpu/drm/drm_crtc.c | 60 +- - drivers/gpu/drm/drm_dp_helper.c | 27 +- - drivers/gpu/drm/drm_dp_mst_topology.c | 29 +- - drivers/gpu/drm/drm_fb_helper.c | 5 +- - drivers/gpu/drm/gma500/mdfld_dsi_pkg_sender.c | 2 +- - drivers/gpu/drm/i915/i915_irq.c | 2 + - drivers/gpu/drm/i915/i915_reg.h | 9 +- - drivers/gpu/drm/i915/intel_crt.c | 8 +- - drivers/gpu/drm/i915/intel_csr.c | 3 +- - drivers/gpu/drm/i915/intel_ddi.c | 22 +- - drivers/gpu/drm/i915/intel_display.c | 2 +- - drivers/gpu/drm/i915/intel_dp.c | 4 +- - drivers/gpu/drm/i915/intel_dp_mst.c | 6 +- - drivers/gpu/drm/i915/intel_drv.h | 2 + - drivers/gpu/drm/i915/intel_fbdev.c | 6 +- - drivers/gpu/drm/i915/intel_hdmi.c | 12 +- - drivers/gpu/drm/i915/intel_lrc.c | 6 +- - drivers/gpu/drm/i915/intel_pm.c | 8 + - drivers/gpu/drm/i915/intel_ringbuffer.c | 30 +- - drivers/gpu/drm/i915/intel_sprite.c | 11 +- - drivers/gpu/drm/i915/intel_uncore.c | 6 +- - drivers/gpu/drm/imx/imx-drm-core.c | 8 + - drivers/gpu/drm/imx/ipuv3-crtc.c | 2 +- - drivers/gpu/drm/nouveau/nvkm/core/ramht.c | 6 +- - drivers/gpu/drm/nouveau/nvkm/engine/gr/gf100.c | 2 + - drivers/gpu/drm/qxl/qxl_display.c | 13 +- - drivers/gpu/drm/qxl/qxl_drv.h | 2 + - drivers/gpu/drm/radeon/atombios_crtc.c | 10 + - drivers/gpu/drm/radeon/atombios_encoders.c | 10 +- - drivers/gpu/drm/radeon/evergreen.c | 154 +++- - drivers/gpu/drm/radeon/evergreen_reg.h | 46 ++ - drivers/gpu/drm/radeon/radeon_connectors.c | 7 +- - drivers/gpu/drm/radeon/radeon_display.c | 2 + - drivers/gpu/drm/radeon/radeon_dp_auxch.c | 2 +- - drivers/gpu/drm/radeon/radeon_ttm.c | 2 + - drivers/gpu/drm/radeon/si_dpm.c | 7 + - drivers/gpu/drm/udl/udl_fb.c | 2 +- - drivers/gpu/drm/udl/udl_gem.c | 2 +- - drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 10 +- - drivers/gpu/drm/vmwgfx/vmwgfx_fb.c | 6 +- - drivers/gpu/galcore/Kbuild | 57 +- - .../default/gc_hal_kernel_allocator_array.h | 68 +- - .../default/gc_hal_kernel_allocator_dmabuf.c | 353 +++++++++ - .../freescale/gc_hal_kernel_allocator_array.h | 70 +- - .../freescale/gc_hal_kernel_allocator_cma.c | 54 +- - drivers/gpu/galcore/arch/gc_hal_kernel_context.c | 264 +++++-- - drivers/gpu/galcore/arch/gc_hal_kernel_context.h | 82 +- - drivers/gpu/galcore/arch/gc_hal_kernel_hardware.c | 842 +++++++++++++++------ - drivers/gpu/galcore/arch/gc_hal_kernel_hardware.h | 70 +- - drivers/gpu/galcore/arch/gc_hal_kernel_recorder.c | 58 +- - .../archvg/gc_hal_kernel_hardware_command_vg.c | 50 +- - .../archvg/gc_hal_kernel_hardware_command_vg.h | 50 +- - .../gpu/galcore/archvg/gc_hal_kernel_hardware_vg.c | 157 +++- - .../gpu/galcore/archvg/gc_hal_kernel_hardware_vg.h | 50 +- - drivers/gpu/galcore/gc_hal_kernel.c | 344 +++++++-- - drivers/gpu/galcore/gc_hal_kernel.h | 129 +++- - drivers/gpu/galcore/gc_hal_kernel_allocator.c | 70 +- - drivers/gpu/galcore/gc_hal_kernel_allocator.h | 90 ++- - drivers/gpu/galcore/gc_hal_kernel_command.c | 726 ++++++++++-------- - drivers/gpu/galcore/gc_hal_kernel_command_vg.c | 67 +- - drivers/gpu/galcore/gc_hal_kernel_db.c | 170 +++-- - drivers/gpu/galcore/gc_hal_kernel_debug.c | 68 +- - drivers/gpu/galcore/gc_hal_kernel_debug.h | 50 +- - drivers/gpu/galcore/gc_hal_kernel_debugfs.c | 155 ++-- - drivers/gpu/galcore/gc_hal_kernel_debugfs.h | 50 +- - drivers/gpu/galcore/gc_hal_kernel_device.c | 238 ++++-- - drivers/gpu/galcore/gc_hal_kernel_device.h | 86 ++- - drivers/gpu/galcore/gc_hal_kernel_event.c | 91 ++- - drivers/gpu/galcore/gc_hal_kernel_interrupt_vg.c | 50 +- - drivers/gpu/galcore/gc_hal_kernel_iommu.c | 50 +- - drivers/gpu/galcore/gc_hal_kernel_linux.c | 55 +- - drivers/gpu/galcore/gc_hal_kernel_linux.h | 56 +- - drivers/gpu/galcore/gc_hal_kernel_math.c | 50 +- - drivers/gpu/galcore/gc_hal_kernel_mmu.c | 97 ++- - drivers/gpu/galcore/gc_hal_kernel_mmu_vg.c | 50 +- - drivers/gpu/galcore/gc_hal_kernel_mutex.h | 89 +++ - drivers/gpu/galcore/gc_hal_kernel_os.c | 638 ++++++++++------ - drivers/gpu/galcore/gc_hal_kernel_os.h | 50 +- - drivers/gpu/galcore/gc_hal_kernel_platform.h | 83 +- - drivers/gpu/galcore/gc_hal_kernel_power.c | 50 +- - drivers/gpu/galcore/gc_hal_kernel_precomp.h | 50 +- - drivers/gpu/galcore/gc_hal_kernel_probe.c | 88 ++- - drivers/gpu/galcore/gc_hal_kernel_sync.c | 50 +- - drivers/gpu/galcore/gc_hal_kernel_sync.h | 50 +- - drivers/gpu/galcore/gc_hal_kernel_vg.c | 94 ++- - drivers/gpu/galcore/gc_hal_kernel_vg.h | 50 +- - drivers/gpu/galcore/gc_hal_kernel_video_memory.c | 150 +++- - drivers/gpu/galcore/inc/gc_hal.h | 147 +++- - drivers/gpu/galcore/inc/gc_hal_base.h | 253 ++++++- - drivers/gpu/galcore/inc/gc_hal_driver.h | 157 +++- - drivers/gpu/galcore/inc/gc_hal_driver_vg.h | 50 +- - drivers/gpu/galcore/inc/gc_hal_dump.h | 50 +- - drivers/gpu/galcore/inc/gc_hal_eglplatform.h | 95 ++- - drivers/gpu/galcore/inc/gc_hal_eglplatform_type.h | 82 +- - drivers/gpu/galcore/inc/gc_hal_engine.h | 133 +++- - drivers/gpu/galcore/inc/gc_hal_engine_vg.h | 233 ++++-- - drivers/gpu/galcore/inc/gc_hal_enum.h | 131 +++- - drivers/gpu/galcore/inc/gc_hal_kernel_buffer.h | 52 +- - drivers/gpu/galcore/inc/gc_hal_mem.h | 50 +- - drivers/gpu/galcore/inc/gc_hal_options.h | 101 ++- - drivers/gpu/galcore/inc/gc_hal_profiler.h | 50 +- - drivers/gpu/galcore/inc/gc_hal_raster.h | 56 +- - drivers/gpu/galcore/inc/gc_hal_rename.h | 50 +- - drivers/gpu/galcore/inc/gc_hal_statistics.h | 50 +- - drivers/gpu/galcore/inc/gc_hal_types.h | 60 +- - drivers/gpu/galcore/inc/gc_hal_version.h | 58 +- - drivers/gpu/galcore/inc/gc_hal_vg.h | 50 +- - .../freescale/gc_hal_kernel_platform_imx6q14.c | 62 +- - .../gc_hal_kernel_platform_imx6q14.config | 5 + - drivers/gpu/ipu-v3/ipu-common.c | 12 +- - drivers/hid/hid-core.c | 8 +- - drivers/hid/hid-ids.h | 1 + - drivers/hid/hid-multitouch.c | 5 + - drivers/hid/i2c-hid/i2c-hid.c | 16 +- - drivers/hid/usbhid/hid-core.c | 73 +- - drivers/hid/usbhid/hid-quirks.c | 1 + - drivers/hid/wacom_wac.c | 16 + - drivers/hwmon/ads7828.c | 10 + - drivers/hwmon/max1111.c | 6 + - drivers/hwtracing/stm/Kconfig | 1 + - drivers/i2c/busses/i2c-cpm.c | 4 +- - drivers/i2c/busses/i2c-exynos5.c | 24 +- - drivers/idle/intel_idle.c | 108 ++- - drivers/iio/accel/bmc150-accel-core.c | 7 +- - drivers/iio/gyro/bmg160_core.c | 9 +- - drivers/iio/magnetometer/ak8975.c | 6 +- - drivers/iio/magnetometer/st_magn.h | 1 + - drivers/infiniband/core/ucm.c | 4 + - drivers/infiniband/core/ucma.c | 3 + - drivers/infiniband/core/uverbs_main.c | 5 + - drivers/infiniband/hw/cxgb4/cq.c | 2 +- - drivers/infiniband/hw/cxgb4/qp.c | 6 +- - drivers/infiniband/hw/mlx5/main.c | 6 +- - drivers/infiniband/hw/qib/qib_file_ops.c | 5 + - drivers/infiniband/ulp/ipoib/ipoib_multicast.c | 24 +- - drivers/infiniband/ulp/isert/ib_isert.c | 122 +-- - drivers/infiniband/ulp/isert/ib_isert.h | 2 +- - drivers/infiniband/ulp/srp/ib_srp.c | 2 +- - drivers/infiniband/ulp/srpt/ib_srpt.c | 59 +- - drivers/input/misc/ati_remote2.c | 36 +- - drivers/input/misc/ims-pcu.c | 4 + - drivers/input/misc/max8997_haptic.c | 6 +- - drivers/input/misc/pmic8xxx-pwrkey.c | 7 +- - drivers/input/misc/powermate.c | 3 + - drivers/input/misc/pwm-beeper.c | 69 +- - drivers/input/misc/uinput.c | 6 + - drivers/input/mouse/synaptics.c | 5 +- - drivers/input/tablet/gtco.c | 10 +- - drivers/input/touchscreen/zforce_ts.c | 4 +- - drivers/iommu/amd_iommu.c | 99 ++- - drivers/iommu/dma-iommu.c | 4 +- - drivers/iommu/iommu.c | 3 +- - drivers/irqchip/irq-gic-v3.c | 19 + - drivers/irqchip/irq-gic.c | 8 + - drivers/irqchip/irq-mxs.c | 2 +- - drivers/irqchip/irq-sunxi-nmi.c | 4 +- - drivers/mcb/mcb-parse.c | 2 +- - drivers/md/bcache/super.c | 46 +- - drivers/md/dm-cache-metadata.c | 122 +-- - drivers/md/dm-cache-metadata.h | 4 +- - drivers/md/dm-cache-target.c | 12 +- - drivers/md/dm-snap.c | 9 + - drivers/md/dm-table.c | 36 +- - drivers/md/dm-thin-metadata.c | 5 +- - drivers/md/dm.c | 15 +- - drivers/md/md.c | 2 + - drivers/md/multipath.c | 4 +- - drivers/md/raid1.c | 7 +- - drivers/md/raid10.c | 7 +- - drivers/md/raid5.c | 51 +- - drivers/md/raid5.h | 4 +- - drivers/media/i2c/adv7511.c | 21 +- - drivers/media/pci/bt8xx/bttv-driver.c | 26 +- - drivers/media/pci/saa7134/saa7134-video.c | 18 +- - drivers/media/platform/coda/coda-bit.c | 2 +- - drivers/media/platform/coda/coda-common.c | 10 +- - drivers/media/platform/vsp1/vsp1_sru.c | 1 + - drivers/media/usb/au0828/au0828-core.c | 2 +- - drivers/media/usb/au0828/au0828-input.c | 4 +- - drivers/media/usb/au0828/au0828-video.c | 63 +- - drivers/media/usb/au0828/au0828.h | 9 +- - drivers/media/usb/pwc/pwc-if.c | 6 + - drivers/media/usb/usbvision/usbvision-video.c | 16 +- - drivers/media/v4l2-core/v4l2-compat-ioctl32.c | 26 +- - drivers/media/v4l2-core/videobuf2-core.c | 10 +- - drivers/media/v4l2-core/videobuf2-memops.c | 2 +- - drivers/mfd/intel-lpss.c | 20 +- - drivers/mfd/intel_soc_pmic_core.c | 1 + - drivers/mfd/mxc-hdmi-core.c | 17 +- - drivers/mfd/omap-usb-tll.c | 13 +- - drivers/misc/Kconfig | 2 +- - drivers/misc/ad525x_dpot.c | 2 +- - drivers/misc/cxl/irq.c | 1 - - drivers/misc/mei/amthif.c | 4 +- - drivers/misc/mei/bus.c | 24 +- - drivers/misc/mei/client.c | 4 + - drivers/misc/mei/hbm.c | 3 +- - drivers/misc/mei/interrupt.c | 6 +- - drivers/misc/mei/mei_dev.h | 2 + - drivers/misc/mic/scif/scif_rma.c | 7 +- - drivers/mmc/card/block.c | 29 +- - drivers/mmc/core/core.c | 4 +- - drivers/mmc/core/mmc.c | 7 + - drivers/mmc/host/mmc_spi.c | 6 + - drivers/mmc/host/sdhci-acpi.c | 6 +- - drivers/mmc/host/sdhci-esdhc-imx.c | 63 +- - drivers/mmc/host/sdhci-pci-core.c | 30 +- - drivers/mmc/host/sdhci-pci.h | 3 + - drivers/mmc/host/sdhci.c | 37 +- - drivers/mmc/host/sdhci.h | 3 + - drivers/mmc/host/sh_mmcif.c | 2 +- - drivers/mtd/nand/brcmnand/brcmnand.c | 34 +- - drivers/mtd/nand/nand_base.c | 10 +- - drivers/mtd/onenand/onenand_base.c | 3 +- - drivers/mtd/spi-nor/spi-nor.c | 46 +- - drivers/mtd/ubi/eba.c | 21 +- - drivers/mtd/ubi/fastmap.c | 1 + - drivers/mtd/ubi/ubi.h | 2 + - .../gpu-viv/hal/os/linux/kernel/gc_hal_kernel_os.c | 6 +- - drivers/mxc/hdmi-cec/mxc_hdmi-cec.c | 5 +- - drivers/mxc/ipu3/ipu_device.c | 4 +- - drivers/net/bonding/bond_main.c | 65 +- - drivers/net/can/dev.c | 56 +- - drivers/net/can/m_can/m_can.c | 2 +- - drivers/net/ethernet/atheros/atlx/atl2.c | 2 +- - drivers/net/ethernet/broadcom/genet/bcmgenet.c | 4 +- - drivers/net/ethernet/cavium/thunder/nicvf_queues.c | 4 + - drivers/net/ethernet/freescale/fec_main.c | 51 +- - drivers/net/ethernet/jme.c | 26 +- - drivers/net/ethernet/marvell/mvneta.c | 2 +- - drivers/net/ethernet/mellanox/mlx4/en_rx.c | 2 +- - drivers/net/ethernet/mellanox/mlx4/en_tx.c | 6 +- - .../net/ethernet/mellanox/mlx4/resource_tracker.c | 3 +- - drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 15 +- - drivers/net/ethernet/mellanox/mlx5/core/port.c | 10 +- - drivers/net/ethernet/mellanox/mlxsw/spectrum.h | 2 + - .../ethernet/mellanox/mlxsw/spectrum_switchdev.c | 9 +- - drivers/net/ethernet/qlogic/qlcnic/qlcnic.h | 3 +- - .../net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c | 24 +- - .../net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c | 3 +- - drivers/net/ethernet/qlogic/qlge/qlge_main.c | 11 + - drivers/net/ethernet/qualcomm/qca_spi.c | 2 +- - drivers/net/ethernet/renesas/sh_eth.c | 10 +- - drivers/net/ethernet/rocker/rocker.c | 14 +- - drivers/net/ethernet/sfc/ef10.c | 16 + - drivers/net/geneve.c | 41 +- - drivers/net/irda/irtty-sir.c | 10 - - drivers/net/macvtap.c | 9 +- - drivers/net/ppp/ppp_generic.c | 36 +- - drivers/net/rionet.c | 4 +- - drivers/net/team/team.c | 9 +- - drivers/net/tun.c | 18 +- - drivers/net/usb/asix_common.c | 2 +- - drivers/net/usb/cdc_ether.c | 8 +- - drivers/net/usb/cdc_mbim.c | 9 +- - drivers/net/usb/cdc_ncm.c | 6 +- - drivers/net/usb/qmi_wwan.c | 7 +- - drivers/net/usb/usbnet.c | 7 + - drivers/net/vrf.c | 13 +- - drivers/net/vxlan.c | 64 +- - drivers/net/wan/farsync.c | 2 +- - drivers/net/wireless/ath/ath10k/core.c | 8 +- - drivers/net/wireless/ath/ath10k/debug.c | 7 +- - drivers/net/wireless/ath/ath10k/mac.c | 13 +- - drivers/net/wireless/ath/ath5k/led.c | 2 +- - drivers/net/wireless/ath/ath9k/ar5008_phy.c | 8 +- - drivers/net/wireless/ath/ath9k/ar9002_phy.c | 5 - - drivers/net/wireless/ath/ath9k/eeprom.c | 7 +- - drivers/net/wireless/ath/ath9k/init.c | 7 + - drivers/net/wireless/ath/ath9k/pci.c | 10 + - drivers/net/wireless/iwlwifi/mvm/fw.c | 4 +- - drivers/net/wireless/iwlwifi/mvm/mac80211.c | 2 + - drivers/net/wireless/iwlwifi/mvm/mvm.h | 3 + - drivers/net/wireless/iwlwifi/pcie/trans.c | 4 +- - drivers/net/wireless/mwifiex/sta_ioctl.c | 1 + - drivers/net/wireless/realtek/rtlwifi/base.c | 4 +- - .../realtek/rtlwifi/btcoexist/halbtc8723b2ant.c | 9 +- - .../realtek/rtlwifi/btcoexist/halbtcoutsrc.c | 27 +- - .../realtek/rtlwifi/btcoexist/halbtcoutsrc.h | 2 +- - .../wireless/realtek/rtlwifi/btcoexist/rtl_btc.c | 5 +- - drivers/net/wireless/realtek/rtlwifi/pci.c | 2 +- - .../net/wireless/realtek/rtlwifi/rtl8723be/hw.c | 5 + - .../net/wireless/realtek/rtlwifi/rtl8723be/sw.c | 3 + - drivers/net/wireless/realtek/rtlwifi/wifi.h | 3 + - drivers/nvdimm/bus.c | 10 +- - drivers/nvdimm/pfn_devs.c | 2 +- - drivers/nvmem/mxs-ocotp.c | 4 +- - drivers/of/of_reserved_mem.c | 4 +- - drivers/pci/probe.c | 14 + - drivers/pcmcia/db1xxx_ss.c | 11 +- - drivers/pinctrl/bcm/pinctrl-bcm2835.c | 2 +- - drivers/pinctrl/freescale/pinctrl-imx.c | 17 +- - drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 14 +- - drivers/pinctrl/nomadik/pinctrl-nomadik.c | 2 +- - drivers/pinctrl/pinctrl-at91-pio4.c | 2 + - drivers/pinctrl/pinctrl-pistachio.c | 24 +- - drivers/pinctrl/pinctrl-single.c | 6 +- - drivers/pinctrl/samsung/pinctrl-exynos5440.c | 15 +- - drivers/pinctrl/sh-pfc/core.c | 4 +- - drivers/pinctrl/sunxi/pinctrl-sun8i-a33.c | 1 + - drivers/pinctrl/sunxi/pinctrl-sunxi.c | 17 +- - drivers/pinctrl/sunxi/pinctrl-sunxi.h | 21 +- - drivers/platform/x86/dell-rbtn.c | 56 ++ - drivers/platform/x86/ideapad-laptop.c | 14 + - drivers/platform/x86/toshiba_acpi.c | 2 +- - drivers/pwm/pwm-brcmstb.c | 4 +- - drivers/regulator/axp20x-regulator.c | 4 +- - drivers/regulator/core.c | 22 +- - drivers/regulator/s2mps11.c | 28 +- - drivers/regulator/s5m8767.c | 13 +- - drivers/rtc/rtc-ds1685.c | 8 +- - drivers/rtc/rtc-hym8563.c | 2 +- - drivers/rtc/rtc-max77686.c | 2 +- - drivers/rtc/rtc-rx8025.c | 1 - - drivers/rtc/rtc-vr41xx.c | 13 +- - drivers/scsi/aacraid/aacraid.h | 3 + - drivers/scsi/aacraid/comminit.c | 24 + - drivers/scsi/aacraid/commsup.c | 49 +- - drivers/scsi/aacraid/linit.c | 12 +- - drivers/scsi/aacraid/src.c | 30 +- - drivers/scsi/aic7xxx/aic7xxx_osm.c | 1 + - drivers/scsi/be2iscsi/be_main.c | 1 + - drivers/scsi/device_handler/Kconfig | 8 +- - drivers/scsi/ipr.c | 10 +- - drivers/scsi/lpfc/lpfc_init.c | 5 +- - drivers/scsi/megaraid/megaraid_sas_base.c | 3 +- - drivers/scsi/qla1280.c | 2 +- - drivers/scsi/scsi_common.c | 12 +- - drivers/scsi/scsi_devinfo.c | 1 + - drivers/scsi/scsi_lib.c | 7 +- - drivers/scsi/scsi_scan.c | 1 + - drivers/scsi/scsi_sysfs.c | 6 +- - drivers/scsi/sd.c | 30 +- - drivers/scsi/sd.h | 7 +- - drivers/scsi/sg.c | 3 +- - drivers/scsi/storvsc_drv.c | 5 +- - drivers/soc/rockchip/pm_domains.c | 1 + - drivers/spi/spi-pxa2xx.c | 2 +- - drivers/spi/spi-rockchip.c | 7 +- - drivers/spi/spi-ti-qspi.c | 45 +- - drivers/staging/android/ion/ion.c | 4 +- - drivers/staging/android/ion/ion_test.c | 4 +- - drivers/staging/comedi/drivers/das1800.c | 22 +- - drivers/staging/comedi/drivers/ni_mio_common.c | 12 +- - drivers/staging/comedi/drivers/ni_tiocmd.c | 2 +- - drivers/staging/media/lirc/lirc_atiusb.c | 4 +- - drivers/staging/media/lirc/lirc_hb.c | 6 +- - drivers/staging/media/lirc/lirc_xbox.c | 4 +- - drivers/staging/rdma/hfi1/TODO | 2 +- - drivers/staging/rdma/hfi1/file_ops.c | 6 + - drivers/target/target_core_transport.c | 2 - - drivers/thermal/rockchip_thermal.c | 11 +- - drivers/thermal/thermal_core.c | 13 +- - drivers/thunderbolt/eeprom.c | 1 + - drivers/tty/n_gsm.c | 4 +- - drivers/tty/n_hdlc.c | 4 +- - drivers/tty/n_tty.c | 70 +- - drivers/tty/pty.c | 4 +- - drivers/tty/serial/8250/8250_mid.c | 35 +- - drivers/tty/serial/8250/8250_pci.c | 3 + - drivers/tty/serial/8250/8250_port.c | 22 +- - drivers/tty/serial/atmel_serial.c | 14 +- - drivers/tty/serial/samsung.c | 4 +- - drivers/tty/serial/sc16is7xx.c | 2 +- - drivers/tty/serial/sh-sci.c | 39 - - drivers/tty/serial/ucc_uart.c | 3 + - drivers/tty/tty_buffer.c | 34 +- - drivers/tty/vt/vt.c | 5 +- - drivers/usb/class/cdc-acm.c | 3 + - drivers/usb/core/driver.c | 46 +- - drivers/usb/core/hcd-pci.c | 9 + - drivers/usb/core/hub.c | 24 +- - drivers/usb/gadget/function/f_fs.c | 9 +- - drivers/usb/gadget/function/f_mass_storage.c | 36 +- - drivers/usb/gadget/function/f_mass_storage.h | 2 - - drivers/usb/gadget/legacy/acm_ms.c | 4 - - drivers/usb/gadget/legacy/mass_storage.c | 4 - - drivers/usb/gadget/legacy/multi.c | 12 - - drivers/usb/gadget/legacy/nokia.c | 7 - - drivers/usb/gadget/udc/atmel_usba_udc.c | 20 +- - drivers/usb/gadget/udc/atmel_usba_udc.h | 2 + - drivers/usb/gadget/udc/udc-core.c | 2 +- - drivers/usb/host/xhci-mem.c | 6 + - drivers/usb/host/xhci-pci.c | 5 +- - drivers/usb/host/xhci-ring.c | 3 +- - drivers/usb/host/xhci.c | 14 +- - drivers/usb/host/xhci.h | 1 + - drivers/usb/misc/iowarrior.c | 6 + - drivers/usb/misc/usbtest.c | 4 +- - drivers/usb/renesas_usbhs/fifo.c | 4 +- - drivers/usb/renesas_usbhs/mod_gadget.c | 6 +- - drivers/usb/serial/cp210x.c | 5 + - drivers/usb/serial/cypress_m8.c | 11 +- - drivers/usb/serial/digi_acceleport.c | 19 + - drivers/usb/serial/ftdi_sio.c | 4 + - drivers/usb/serial/ftdi_sio_ids.h | 8 + - drivers/usb/serial/io_edgeport.c | 56 +- - drivers/usb/serial/keyspan.c | 4 + - drivers/usb/serial/mct_u232.c | 9 +- - drivers/usb/serial/mxuport.c | 10 + - drivers/usb/serial/option.c | 157 +++- - drivers/usb/serial/quatech2.c | 1 + - drivers/usb/storage/uas.c | 23 +- - drivers/usb/storage/unusual_uas.h | 7 + - drivers/usb/storage/usb.c | 5 +- - drivers/usb/usbip/usbip_common.c | 11 + - drivers/video/fbdev/Kconfig | 1 - - drivers/video/fbdev/da8xx-fb.c | 7 +- - drivers/video/mxc/mxc_edid.c | 13 +- - drivers/video/mxc/mxc_hdmi.c | 15 +- - drivers/virtio/virtio_pci_modern.c | 11 +- - drivers/watchdog/rc32434_wdt.c | 2 +- - drivers/xen/balloon.c | 16 + - drivers/xen/events/events_base.c | 30 +- - drivers/xen/evtchn.c | 20 +- - firmware/imx/sdma/sdma-imx6q.bin.ihex | 255 ++++--- - fs/affs/super.c | 5 +- - fs/btrfs/file.c | 2 +- - fs/btrfs/ioctl.c | 2 +- - fs/btrfs/tree-log.c | 137 ++++ - fs/btrfs/volumes.c | 1 - - fs/cifs/sess.c | 139 ++-- - fs/cifs/smb2glob.h | 1 + - fs/cifs/smb2inode.c | 8 +- - fs/cifs/smb2pdu.c | 16 + - fs/cifs/smb2proto.h | 2 + - fs/coredump.c | 30 +- - fs/dcache.c | 9 +- - fs/debugfs/inode.c | 2 +- - fs/ecryptfs/kthread.c | 13 +- - fs/ext4/ext4.h | 36 + - fs/ext4/extents.c | 133 ++-- - fs/ext4/file.c | 66 +- - fs/ext4/ialloc.c | 59 +- - fs/ext4/inode.c | 77 +- - fs/ext4/mballoc.c | 10 +- - fs/ext4/move_extent.c | 12 +- - fs/ext4/namei.c | 2 +- - fs/ext4/super.c | 48 +- - fs/ext4/truncate.h | 2 + - fs/f2fs/f2fs.h | 4 +- - fs/fhandle.c | 2 +- - fs/fs-writeback.c | 37 +- - fs/fuse/cuse.c | 4 +- - fs/fuse/file.c | 33 +- - fs/fuse/fuse_i.h | 9 + - fs/hpfs/super.c | 42 +- - fs/isofs/rock.c | 13 +- - fs/jbd2/journal.c | 17 +- - fs/namei.c | 26 +- - fs/nfs/dir.c | 6 +- - fs/nfs/inode.c | 2 +- - fs/nfs/nfs4file.c | 4 +- - fs/nfsd/nfs4proc.c | 1 + - fs/nfsd/nfs4xdr.c | 13 +- - fs/ocfs2/acl.c | 87 +++ - fs/ocfs2/acl.h | 5 + - fs/ocfs2/dlm/dlmconvert.c | 24 +- - fs/ocfs2/dlm/dlmrecovery.c | 1 - - fs/ocfs2/file.c | 4 +- - fs/ocfs2/namei.c | 23 +- - fs/ocfs2/refcounttree.c | 17 +- - fs/ocfs2/xattr.c | 14 +- - fs/ocfs2/xattr.h | 4 +- - fs/open.c | 18 +- - fs/overlayfs/super.c | 33 + - fs/pipe.c | 47 +- - fs/pnode.c | 32 +- - fs/proc/base.c | 3 +- - fs/proc/root.c | 7 + - fs/proc/task_mmu.c | 33 +- - fs/proc_namespace.c | 2 + - fs/quota/dquot.c | 3 +- - fs/splice.c | 3 + - fs/xfs/libxfs/xfs_alloc.c | 2 + - fs/xfs/libxfs/xfs_alloc_btree.c | 1 + - fs/xfs/libxfs/xfs_attr_leaf.c | 1 + - fs/xfs/libxfs/xfs_attr_remote.c | 1 + - fs/xfs/libxfs/xfs_bmap_btree.c | 1 + - fs/xfs/libxfs/xfs_da_btree.c | 1 + - fs/xfs/libxfs/xfs_dir2_block.c | 1 + - fs/xfs/libxfs/xfs_dir2_data.c | 2 + - fs/xfs/libxfs/xfs_dir2_leaf.c | 2 + - fs/xfs/libxfs/xfs_dir2_node.c | 1 + - fs/xfs/libxfs/xfs_dquot_buf.c | 37 +- - fs/xfs/libxfs/xfs_ialloc.c | 1 + - fs/xfs/libxfs/xfs_ialloc_btree.c | 1 + - fs/xfs/libxfs/xfs_inode_buf.c | 4 + - fs/xfs/libxfs/xfs_quota_defs.h | 2 +- - fs/xfs/libxfs/xfs_sb.c | 2 + - fs/xfs/libxfs/xfs_shared.h | 1 + - fs/xfs/libxfs/xfs_symlink_remote.c | 1 + - fs/xfs/xfs_attr_list.c | 19 +- - fs/xfs/xfs_buf.h | 1 + - fs/xfs/xfs_error.c | 4 +- - fs/xfs/xfs_fsops.c | 4 +- - fs/xfs/xfs_inode.c | 26 +- - fs/xfs/xfs_log_recover.c | 9 +- - fs/xfs/xfs_super.c | 10 + - include/asm-generic/bitops/lock.h | 14 +- - include/asm-generic/futex.h | 8 +- - include/asm-generic/preempt.h | 4 +- - include/asm-generic/qspinlock.h | 27 +- - include/asm-generic/siginfo.h | 15 - - include/drm/drm_cache.h | 2 + - include/linux/blkdev.h | 2 +- - include/linux/bpf.h | 3 +- - include/linux/can/dev.h | 22 +- - include/linux/cgroup-defs.h | 4 + - include/linux/clk-provider.h | 1 + - include/linux/clk/at91_pmc.h | 12 - - include/linux/compiler-gcc.h | 2 +- - include/linux/completion.h | 8 +- - include/linux/cpuset.h | 6 - - include/linux/dcache.h | 22 + - include/linux/device-mapper.h | 2 + - include/linux/filter.h | 4 + - include/linux/fs.h | 12 +- - include/linux/ftrace.h | 12 + - include/linux/hash.h | 20 +- - include/linux/hrtimer.h | 2 +- - include/linux/if_bridge.h | 4 - - include/linux/init_task.h | 3 +- - include/linux/irqchip/arm-gic-v3.h | 2 +- - include/linux/kernel.h | 15 +- - include/linux/kvm_host.h | 5 +- - include/linux/list_bl.h | 12 +- - include/linux/locallock.h | 6 +- - include/linux/mfd/samsung/s2mps11.h | 2 + - include/linux/mfd/syscon/imx6q-iomuxc-gpr.h | 1 + - include/linux/mlx5/device.h | 11 + - include/linux/mlx5/driver.h | 6 +- - include/linux/mm.h | 4 +- - include/linux/net.h | 10 +- - include/linux/netdevice.h | 22 +- - include/linux/netfilter/x_tables.h | 12 +- - include/linux/pci.h | 18 +- - include/linux/pipe_fs_i.h | 4 + - include/linux/platform_data/asoc-s3c.h | 4 + - include/linux/sched.h | 11 +- - include/linux/signal.h | 15 + - include/linux/skbuff.h | 41 + - include/linux/spinlock_rt.h | 25 +- - include/linux/suspend.h | 6 + - include/linux/swait.h | 173 +++++ - include/linux/thermal.h | 2 + - include/linux/tty.h | 4 +- - include/linux/usb.h | 2 +- - include/linux/usb_usual.h | 2 + - include/media/videobuf2-core.h | 1 + - include/net/bonding.h | 1 + - include/net/codel.h | 4 + - include/net/ip_tunnels.h | 1 + - include/net/ip_vs.h | 17 + - include/net/sch_generic.h | 20 +- - include/net/switchdev.h | 2 +- - include/rdma/ib.h | 16 + - include/scsi/scsi_device.h | 1 + - include/trace/events/hist.h | 1 + - include/trace/events/writeback.h | 121 ++- - include/uapi/linux/Kbuild | 1 + - include/uapi/linux/if.h | 28 + - include/uapi/linux/libc-compat.h | 44 ++ - include/uapi/linux/v4l2-dv-timings.h | 30 +- - include/video/imx-ipu-v3.h | 2 + - include/video/mxc_edid.h | 2 +- - include/xen/page.h | 4 +- - kernel/bpf/helpers.c | 2 +- - kernel/bpf/inode.c | 10 +- - kernel/bpf/syscall.c | 24 +- - kernel/bpf/verifier.c | 66 +- - kernel/cgroup.c | 34 +- - kernel/cpu.c | 4 +- - kernel/cpuset.c | 4 +- - kernel/events/core.c | 73 +- - kernel/events/ring_buffer.c | 10 +- - kernel/exit.c | 29 +- - kernel/fork.c | 5 +- - kernel/futex.c | 45 +- - kernel/irq/irqdesc.c | 21 +- - kernel/irq/manage.c | 2 +- - kernel/locking/lglock.c | 6 +- - kernel/locking/mcs_spinlock.h | 8 +- - kernel/locking/rt.c | 2 - - kernel/locking/rtmutex.c | 246 +++--- - kernel/panic.c | 45 +- - kernel/power/hibernate.c | 8 + - kernel/power/suspend.c | 5 + - kernel/printk/printk.c | 126 +-- - kernel/rcu/rcutorture.c | 7 + - kernel/rcu/tree.c | 24 +- - kernel/rcu/tree.h | 15 +- - kernel/rcu/tree_plugin.h | 26 +- - kernel/sched/Makefile | 2 +- - kernel/sched/completion.c | 10 +- - kernel/sched/core.c | 151 ++-- - kernel/sched/cputime.c | 84 +- - kernel/sched/fair.c | 182 ++--- - kernel/sched/loadavg.c | 11 +- - kernel/sched/sched.h | 13 + - kernel/sched/swait.c | 143 ++++ - kernel/sched/work-simple.c | 8 +- - kernel/softirq.c | 8 +- - kernel/stop_machine.c | 40 +- - kernel/sysctl.c | 14 + - kernel/sysctl_binary.c | 2 +- - kernel/time/tick-broadcast-hrtimer.c | 1 + - kernel/trace/ring_buffer.c | 35 +- - kernel/trace/trace.c | 5 +- - kernel/trace/trace_events.c | 9 +- - kernel/trace/trace_irqsoff.c | 16 +- - kernel/trace/trace_printk.c | 3 + - kernel/watchdog.c | 11 +- - kernel/workqueue.c | 40 + - lib/assoc_array.c | 4 +- - lib/dma-debug.c | 2 +- - lib/dump_stack.c | 4 +- - lib/lz4/lz4defs.h | 21 +- - lib/mpi/mpicoder.c | 39 +- - lib/test-string_helpers.c | 67 +- - localversion-rt | 2 +- - mm/backing-dev.c | 4 +- - mm/compaction.c | 10 +- - mm/huge_memory.c | 6 +- - mm/memcontrol.c | 84 +- - mm/memory.c | 40 + - mm/migrate.c | 8 +- - mm/page-writeback.c | 6 +- - mm/page_alloc.c | 50 +- - mm/page_isolation.c | 8 +- - mm/slub.c | 22 +- - mm/vmscan.c | 2 +- - mm/zsmalloc.c | 11 +- - mm/zswap.c | 8 +- - net/ax25/ax25_ip.c | 15 + - net/batman-adv/distributed-arp-table.c | 17 +- - net/batman-adv/routing.c | 9 + - net/batman-adv/send.c | 6 + - net/batman-adv/soft-interface.c | 8 +- - net/bluetooth/mgmt.c | 4 + - net/bridge/br_fdb.c | 2 + - net/bridge/br_ioctl.c | 5 +- - net/bridge/br_multicast.c | 12 +- - net/bridge/br_stp.c | 13 +- - net/core/dev.c | 6 +- - net/core/filter.c | 33 +- - net/core/rtnetlink.c | 19 +- - net/core/skbuff.c | 33 +- - net/dccp/ipv4.c | 2 - - net/decnet/dn_route.c | 9 +- - net/ipv4/devinet.c | 4 + - net/ipv4/fib_frontend.c | 26 +- - net/ipv4/fib_semantics.c | 2 + - net/ipv4/igmp.c | 3 +- - net/ipv4/ip_gre.c | 19 +- - net/ipv4/ip_output.c | 5 +- - net/ipv4/ip_tunnel.c | 23 +- - net/ipv4/netfilter/arp_tables.c | 326 +++----- - net/ipv4/netfilter/ip_tables.c | 356 +++------ - net/ipv4/netfilter/nf_nat_masquerade_ipv4.c | 12 +- - net/ipv4/route.c | 12 + - net/ipv4/tcp_ipv4.c | 2 - - net/ipv4/tcp_metrics.c | 2 +- - net/ipv4/tcp_minisocks.c | 3 +- - net/ipv4/tcp_output.c | 6 +- - net/ipv4/udp.c | 14 +- - net/ipv4/udp_tunnel.c | 2 + - net/ipv6/exthdrs_core.c | 6 +- - net/ipv6/ip6_gre.c | 2 + - net/ipv6/ip6_output.c | 19 +- - net/ipv6/ip6_tunnel.c | 4 +- - net/ipv6/mcast.c | 3 +- - net/ipv6/netfilter/ip6_tables.c | 349 +++------ - net/ipv6/reassembly.c | 6 +- - net/ipv6/route.c | 2 + - net/ipv6/tcp_ipv6.c | 4 +- - net/ipv6/udp.c | 12 +- - net/l2tp/l2tp_core.c | 2 +- - net/l2tp/l2tp_ip.c | 8 +- - net/l2tp/l2tp_ip6.c | 8 +- - net/llc/af_llc.c | 1 + - net/mac80211/ibss.c | 22 +- - net/mac80211/iface.c | 7 +- - net/mac80211/rx.c | 5 +- - net/mac80211/sta_info.c | 37 +- - net/mpls/af_mpls.c | 3 + - net/netfilter/ipvs/ip_vs_core.c | 37 +- - net/netfilter/ipvs/ip_vs_pe_sip.c | 6 +- - net/netfilter/nf_conntrack_core.c | 4 +- - net/netfilter/x_tables.c | 245 +++++- - net/netlink/af_netlink.c | 9 +- - net/openvswitch/actions.c | 12 +- - net/openvswitch/vport-netdev.c | 2 +- - net/openvswitch/vport-vxlan.c | 2 + - net/openvswitch/vport.h | 7 - - net/packet/af_packet.c | 38 +- - net/sched/sch_api.c | 8 +- - net/sched/sch_cbq.c | 12 +- - net/sched/sch_choke.c | 6 +- - net/sched/sch_codel.c | 10 +- - net/sched/sch_drr.c | 9 +- - net/sched/sch_dsmark.c | 11 +- - net/sched/sch_fq.c | 4 +- - net/sched/sch_fq_codel.c | 17 +- - net/sched/sch_generic.c | 5 +- - net/sched/sch_hfsc.c | 9 +- - net/sched/sch_hhf.c | 10 +- - net/sched/sch_htb.c | 24 +- - net/sched/sch_multiq.c | 16 +- - net/sched/sch_netem.c | 74 +- - net/sched/sch_pie.c | 5 +- - net/sched/sch_prio.c | 15 +- - net/sched/sch_qfq.c | 9 +- - net/sched/sch_red.c | 10 +- - net/sched/sch_sfb.c | 10 +- - net/sched/sch_sfq.c | 16 +- - net/sched/sch_tbf.c | 15 +- - net/sctp/ipv6.c | 2 + - net/socket.c | 38 +- - net/sunrpc/auth_gss/svcauth_gss.c | 4 +- - net/sunrpc/cache.c | 6 +- - net/switchdev/switchdev.c | 6 +- - net/tipc/netlink_compat.c | 2 +- - net/tipc/socket.c | 36 +- - net/vmw_vsock/af_vsock.c | 21 +- - net/wireless/nl80211.c | 2 +- - net/wireless/wext-core.c | 25 +- - net/x25/x25_facilities.c | 1 + - net/xfrm/xfrm_input.c | 3 + - samples/bpf/trace_output_kern.c | 1 - - scripts/Makefile.extrawarn | 1 + - scripts/coccinelle/iterators/use_after_iter.cocci | 2 +- - scripts/kconfig/Makefile | 4 +- - scripts/kconfig/confdata.c | 12 +- - scripts/package/Makefile | 4 +- - scripts/package/mkspec | 8 +- - sound/core/pcm_lib.c | 2 +- - sound/core/timer.c | 4 +- - sound/pci/hda/hda_generic.c | 6 +- - sound/pci/hda/hda_intel.c | 14 +- - sound/pci/hda/hda_sysfs.c | 8 - - sound/pci/hda/patch_cirrus.c | 22 +- - sound/pci/hda/patch_conexant.c | 7 +- - sound/pci/hda/patch_hdmi.c | 4 + - sound/pci/hda/patch_realtek.c | 180 ++++- - sound/pci/intel8x0.c | 1 + - sound/pci/pcxhr/pcxhr_core.c | 1 + - sound/soc/codecs/ak4642.c | 3 + - sound/soc/codecs/rt5640.c | 2 +- - sound/soc/codecs/rt5640.h | 36 +- - sound/soc/codecs/ssm4567.c | 5 + - sound/soc/fsl/fsl_esai.c | 8 +- - sound/soc/fsl/fsl_sai.c | 6 +- - sound/soc/fsl/fsl_spdif.c | 91 ++- - sound/soc/fsl/fsl_ssi.c | 6 +- - sound/soc/fsl/imx-hdmi-dma.c | 5 +- - sound/soc/fsl/imx-hdmi.c | 1 - - sound/soc/fsl/imx-pcm.h | 4 - - sound/soc/samsung/ac97.c | 26 +- - sound/soc/samsung/dma.h | 2 +- - sound/soc/samsung/dmaengine.c | 4 +- - sound/soc/samsung/i2s.c | 26 +- - sound/soc/samsung/pcm.c | 20 +- - sound/soc/samsung/s3c-i2s-v2.c | 2 +- - sound/soc/samsung/s3c-i2s-v2.h | 2 +- - sound/soc/samsung/s3c2412-i2s.c | 4 +- - sound/soc/samsung/s3c24xx-i2s.c | 4 +- - sound/soc/samsung/spdif.c | 10 +- - sound/soc/soc-dapm.c | 7 + - sound/usb/clock.c | 2 + - sound/usb/endpoint.c | 3 + - sound/usb/mixer_maps.c | 14 + - sound/usb/mixer_quirks.c | 4 + - sound/usb/pcm.c | 2 + - sound/usb/quirks.c | 32 +- - sound/usb/stream.c | 6 +- - tools/hv/Makefile | 2 + - tools/lib/traceevent/parse-filter.c | 4 +- - tools/perf/Documentation/perf-stat.txt | 8 + - tools/perf/tests/bpf.c | 14 +- - tools/perf/tests/llvm.c | 8 +- - tools/perf/ui/browsers/hists.c | 10 +- - tools/perf/util/event.c | 2 +- - tools/perf/util/evlist.c | 4 +- - tools/perf/util/intel-pt.c | 2 +- - tools/perf/util/parse-events.c | 6 +- - tools/perf/util/pmu.c | 15 +- - tools/perf/util/setup.py | 4 + - virt/kvm/arm/arch_timer.c | 49 +- - virt/kvm/async_pf.c | 4 +- - virt/kvm/irqchip.c | 2 +- - virt/kvm/kvm_main.c | 38 +- - 1129 files changed, 19122 insertions(+), 9086 deletions(-) - create mode 100644 arch/arm/boot/dts/imx6dl-udoo-15lvds.dts - create mode 100644 arch/arm/boot/dts/imx6dl-udoo-7lvds.dts - create mode 100644 arch/arm/boot/dts/imx6q-udoo-15lvds.dts - create mode 100644 arch/arm/boot/dts/imx6q-udoo-7lvds.dts - create mode 100644 arch/sparc/kernel/urtt_fill.S - create mode 100644 drivers/gpu/galcore/allocator/default/gc_hal_kernel_allocator_dmabuf.c - create mode 100644 drivers/gpu/galcore/gc_hal_kernel_mutex.h - create mode 100644 include/linux/swait.h - create mode 100644 kernel/sched/swait.c - -diff --git a/Documentation/devicetree/bindings/ata/ahci-platform.txt b/Documentation/devicetree/bindings/ata/ahci-platform.txt -index c2340ee..c000832 100644 ---- a/Documentation/devicetree/bindings/ata/ahci-platform.txt -+++ b/Documentation/devicetree/bindings/ata/ahci-platform.txt -@@ -30,6 +30,10 @@ Optional properties: - - target-supply : regulator for SATA target power - - phys : reference to the SATA PHY node - - phy-names : must be "sata-phy" -+- ports-implemented : Mask that indicates which ports that the HBA supports -+ are available for software to use. Useful if PORTS_IMPL -+ is not programmed by the BIOS, which is true with -+ some embedded SOC's. - - Required properties when using sub-nodes: - - #address-cells : number of cells to encode an address -diff --git a/Documentation/devicetree/bindings/clock/imx35-clock.txt b/Documentation/devicetree/bindings/clock/imx35-clock.txt -index a703564..f497832 100644 ---- a/Documentation/devicetree/bindings/clock/imx35-clock.txt -+++ b/Documentation/devicetree/bindings/clock/imx35-clock.txt -@@ -94,6 +94,7 @@ clocks and IDs. - csi_sel 79 - iim_gate 80 - gpu2d_gate 81 -+ ckli_gate 82 - - Examples: - -diff --git a/Documentation/devicetree/bindings/pinctrl/img,pistachio-pinctrl.txt b/Documentation/devicetree/bindings/pinctrl/img,pistachio-pinctrl.txt -index 08a4a32..0326154 100644 ---- a/Documentation/devicetree/bindings/pinctrl/img,pistachio-pinctrl.txt -+++ b/Documentation/devicetree/bindings/pinctrl/img,pistachio-pinctrl.txt -@@ -134,12 +134,12 @@ mfio80 ddr_debug, mips_trace_data, mips_debug - mfio81 dreq0, mips_trace_data, eth_debug - mfio82 dreq1, mips_trace_data, eth_debug - mfio83 mips_pll_lock, mips_trace_data, usb_debug --mfio84 sys_pll_lock, mips_trace_data, usb_debug --mfio85 wifi_pll_lock, mips_trace_data, sdhost_debug --mfio86 bt_pll_lock, mips_trace_data, sdhost_debug --mfio87 rpu_v_pll_lock, dreq2, socif_debug --mfio88 rpu_l_pll_lock, dreq3, socif_debug --mfio89 audio_pll_lock, dreq4, dreq5 -+mfio84 audio_pll_lock, mips_trace_data, usb_debug -+mfio85 rpu_v_pll_lock, mips_trace_data, sdhost_debug -+mfio86 rpu_l_pll_lock, mips_trace_data, sdhost_debug -+mfio87 sys_pll_lock, dreq2, socif_debug -+mfio88 wifi_pll_lock, dreq3, socif_debug -+mfio89 bt_pll_lock, dreq4, dreq5 - tck - trstn - tdi -diff --git a/Documentation/devicetree/bindings/sound/fsl,esai.txt b/Documentation/devicetree/bindings/sound/fsl,esai.txt -index d3b6b5f..80a6ee9 100644 ---- a/Documentation/devicetree/bindings/sound/fsl,esai.txt -+++ b/Documentation/devicetree/bindings/sound/fsl,esai.txt -@@ -41,6 +41,10 @@ Required properties: - will be in use as default, or the big endian mode - will be in use for all the device registers. - -+ - fsl,dma-buffer-size: It specify the audio buffer size of playback and -+ capture. If this property is absent, using the default value of audio buffer -+ size. -+ - Example: - - esai: esai@02024000 { -diff --git a/Documentation/devicetree/bindings/sound/fsl,spdif.txt b/Documentation/devicetree/bindings/sound/fsl,spdif.txt -index b5ee32e..89dfabd 100644 ---- a/Documentation/devicetree/bindings/sound/fsl,spdif.txt -+++ b/Documentation/devicetree/bindings/sound/fsl,spdif.txt -@@ -32,6 +32,10 @@ Required properties: - will be in use as default, or the big endian mode - will be in use for all the device registers. - -+ - fsl,dma-buffer-size: It specify the audio buffer size of playback and -+ capture. If this property is absent, using the default value of audio buffer -+ size. -+ - Example: - - spdif: spdif@02004000 { -diff --git a/Documentation/devicetree/bindings/sound/fsl,ssi.txt b/Documentation/devicetree/bindings/sound/fsl,ssi.txt -index 5b76be4..3ad1096 100644 ---- a/Documentation/devicetree/bindings/sound/fsl,ssi.txt -+++ b/Documentation/devicetree/bindings/sound/fsl,ssi.txt -@@ -62,6 +62,10 @@ Optional properties: - "ac97-slave" - AC97 mode, SSI is clock slave - "ac97-master" - AC97 mode, SSI is clock master - -+- fsl,dma-buffer-size: It specify the audio buffer size of playback and -+ capture. If this property is absent, using the default value of audio buffer -+ size. -+ - Child 'codec' node required properties: - - compatible: Compatible list, contains the name of the codec - -diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt -index 742f69d..26b5f39 100644 ---- a/Documentation/kernel-parameters.txt -+++ b/Documentation/kernel-parameters.txt -@@ -1629,6 +1629,15 @@ bytes respectively. Such letter suffixes can also be entirely omitted. - ip= [IP_PNP] - See Documentation/filesystems/nfs/nfsroot.txt. - -+ irqaffinity= [SMP] Set the default irq affinity mask -+ Format: -+ ,..., -+ or -+ - -+ (must be a positive range in ascending order) -+ or a mixture -+ ,...,- -+ - irqfixup [HW] - When an interrupt is not handled search all handlers - for it. Intended to get systems with badly broken -@@ -3928,6 +3937,8 @@ bytes respectively. Such letter suffixes can also be entirely omitted. - sector if the number is odd); - i = IGNORE_DEVICE (don't bind to this - device); -+ j = NO_REPORT_LUNS (don't use report luns -+ command, uas only); - l = NOT_LOCKABLE (don't try to lock and - unlock ejectable media); - m = MAX_SECTORS_64 (don't transfer more -diff --git a/Documentation/serial/tty.txt b/Documentation/serial/tty.txt -index bc3842d..e2dea3d 100644 ---- a/Documentation/serial/tty.txt -+++ b/Documentation/serial/tty.txt -@@ -213,9 +213,6 @@ TTY_IO_ERROR If set, causes all subsequent userspace read/write - - TTY_OTHER_CLOSED Device is a pty and the other side has closed. - --TTY_OTHER_DONE Device is a pty and the other side has closed and -- all pending input processing has been completed. -- - TTY_NO_WRITE_SPLIT Prevent driver from splitting up writes into - smaller chunks. - -diff --git a/Documentation/sysctl/fs.txt b/Documentation/sysctl/fs.txt -index 88152f2..302b5ed 100644 ---- a/Documentation/sysctl/fs.txt -+++ b/Documentation/sysctl/fs.txt -@@ -32,6 +32,8 @@ Currently, these files are in /proc/sys/fs: - - nr_open - - overflowuid - - overflowgid -+- pipe-user-pages-hard -+- pipe-user-pages-soft - - protected_hardlinks - - protected_symlinks - - suid_dumpable -@@ -159,6 +161,27 @@ The default is 65534. - - ============================================================== - -+pipe-user-pages-hard: -+ -+Maximum total number of pages a non-privileged user may allocate for pipes. -+Once this limit is reached, no new pipes may be allocated until usage goes -+below the limit again. When set to 0, no limit is applied, which is the default -+setting. -+ -+============================================================== -+ -+pipe-user-pages-soft: -+ -+Maximum total number of pages a non-privileged user may allocate for pipes -+before the pipe size gets limited to a single page. Once this limit is reached, -+new pipes will be limited to a single page in size for this user in order to -+limit total memory usage, and trying to increase them using fcntl() will be -+denied until usage goes below the limit again. The default value allows to -+allocate up to 1024 pipes at their default size. When set to 0, no limit is -+applied. -+ -+============================================================== -+ - protected_hardlinks: - - A long-standing class of security issues is the hardlink-based -diff --git a/MAINTAINERS b/MAINTAINERS -index d826f1b..ab65bbe 100644 ---- a/MAINTAINERS -+++ b/MAINTAINERS -@@ -230,13 +230,13 @@ F: kernel/sys_ni.c - - ABIT UGURU 1,2 HARDWARE MONITOR DRIVER - M: Hans de Goede --L: lm-sensors@lm-sensors.org -+L: linux-hwmon@vger.kernel.org - S: Maintained - F: drivers/hwmon/abituguru.c - - ABIT UGURU 3 HARDWARE MONITOR DRIVER - M: Alistair John Strachan --L: lm-sensors@lm-sensors.org -+L: linux-hwmon@vger.kernel.org - S: Maintained - F: drivers/hwmon/abituguru3.c - -@@ -373,14 +373,14 @@ S: Maintained - - ADM1025 HARDWARE MONITOR DRIVER - M: Jean Delvare --L: lm-sensors@lm-sensors.org -+L: linux-hwmon@vger.kernel.org - S: Maintained - F: Documentation/hwmon/adm1025 - F: drivers/hwmon/adm1025.c - - ADM1029 HARDWARE MONITOR DRIVER - M: Corentin Labbe --L: lm-sensors@lm-sensors.org -+L: linux-hwmon@vger.kernel.org - S: Maintained - F: drivers/hwmon/adm1029.c - -@@ -425,7 +425,7 @@ F: drivers/video/backlight/adp8860_bl.c - - ADS1015 HARDWARE MONITOR DRIVER - M: Dirk Eibach --L: lm-sensors@lm-sensors.org -+L: linux-hwmon@vger.kernel.org - S: Maintained - F: Documentation/hwmon/ads1015 - F: drivers/hwmon/ads1015.c -@@ -438,7 +438,7 @@ F: drivers/macintosh/therm_adt746x.c - - ADT7475 HARDWARE MONITOR DRIVER - M: Jean Delvare --L: lm-sensors@lm-sensors.org -+L: linux-hwmon@vger.kernel.org - S: Maintained - F: Documentation/hwmon/adt7475 - F: drivers/hwmon/adt7475.c -@@ -615,7 +615,7 @@ F: include/linux/ccp.h - - AMD FAM15H PROCESSOR POWER MONITORING DRIVER - M: Andreas Herrmann --L: lm-sensors@lm-sensors.org -+L: linux-hwmon@vger.kernel.org - S: Maintained - F: Documentation/hwmon/fam15h_power - F: drivers/hwmon/fam15h_power.c -@@ -779,7 +779,7 @@ F: drivers/input/mouse/bcm5974.c - - APPLE SMC DRIVER - M: Henrik Rydberg --L: lm-sensors@lm-sensors.org -+L: linux-hwmon@vger.kernel.org - S: Odd fixes - F: drivers/hwmon/applesmc.c - -@@ -1777,7 +1777,7 @@ F: include/media/as3645a.h - - ASC7621 HARDWARE MONITOR DRIVER - M: George Joseph --L: lm-sensors@lm-sensors.org -+L: linux-hwmon@vger.kernel.org - S: Maintained - F: Documentation/hwmon/asc7621 - F: drivers/hwmon/asc7621.c -@@ -1864,7 +1864,7 @@ F: drivers/net/wireless/ath/carl9170/ - - ATK0110 HWMON DRIVER - M: Luca Tettamanti --L: lm-sensors@lm-sensors.org -+L: linux-hwmon@vger.kernel.org - S: Maintained - F: drivers/hwmon/asus_atk0110.c - -@@ -2984,7 +2984,7 @@ F: mm/swap_cgroup.c - - CORETEMP HARDWARE MONITORING DRIVER - M: Fenghua Yu --L: lm-sensors@lm-sensors.org -+L: linux-hwmon@vger.kernel.org - S: Maintained - F: Documentation/hwmon/coretemp - F: drivers/hwmon/coretemp.c -@@ -3549,7 +3549,7 @@ T: git git://git.infradead.org/users/vkoul/slave-dma.git - - DME1737 HARDWARE MONITOR DRIVER - M: Juerg Haefliger --L: lm-sensors@lm-sensors.org -+L: linux-hwmon@vger.kernel.org - S: Maintained - F: Documentation/hwmon/dme1737 - F: drivers/hwmon/dme1737.c -@@ -4097,8 +4097,8 @@ F: Documentation/efi-stub.txt - F: arch/ia64/kernel/efi.c - F: arch/x86/boot/compressed/eboot.[ch] - F: arch/x86/include/asm/efi.h --F: arch/x86/platform/efi/* --F: drivers/firmware/efi/* -+F: arch/x86/platform/efi/ -+F: drivers/firmware/efi/ - F: include/linux/efi*.h - - EFI VARIABLE FILESYSTEM -@@ -4262,7 +4262,7 @@ F: include/video/exynos_mipi* - - F71805F HARDWARE MONITORING DRIVER - M: Jean Delvare --L: lm-sensors@lm-sensors.org -+L: linux-hwmon@vger.kernel.org - S: Maintained - F: Documentation/hwmon/f71805f - F: drivers/hwmon/f71805f.c -@@ -4341,7 +4341,7 @@ F: fs/* - - FINTEK F75375S HARDWARE MONITOR AND FAN CONTROLLER DRIVER - M: Riku Voipio --L: lm-sensors@lm-sensors.org -+L: linux-hwmon@vger.kernel.org - S: Maintained - F: drivers/hwmon/f75375s.c - F: include/linux/f75375s.h -@@ -4883,8 +4883,8 @@ F: drivers/media/usb/hackrf/ - HARDWARE MONITORING - M: Jean Delvare - M: Guenter Roeck --L: lm-sensors@lm-sensors.org --W: http://www.lm-sensors.org/ -+L: linux-hwmon@vger.kernel.org -+W: http://hwmon.wiki.kernel.org/ - T: quilt http://jdelvare.nerim.net/devel/linux/jdelvare-hwmon/ - T: git git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git - S: Maintained -@@ -5393,7 +5393,7 @@ F: drivers/usb/atm/ueagle-atm.c - - INA209 HARDWARE MONITOR DRIVER - M: Guenter Roeck --L: lm-sensors@lm-sensors.org -+L: linux-hwmon@vger.kernel.org - S: Maintained - F: Documentation/hwmon/ina209 - F: Documentation/devicetree/bindings/i2c/ina209.txt -@@ -5401,7 +5401,7 @@ F: drivers/hwmon/ina209.c - - INA2XX HARDWARE MONITOR DRIVER - M: Guenter Roeck --L: lm-sensors@lm-sensors.org -+L: linux-hwmon@vger.kernel.org - S: Maintained - F: Documentation/hwmon/ina2xx - F: drivers/hwmon/ina2xx.c -@@ -5884,7 +5884,7 @@ F: drivers/isdn/hardware/eicon/ - - IT87 HARDWARE MONITORING DRIVER - M: Jean Delvare --L: lm-sensors@lm-sensors.org -+L: linux-hwmon@vger.kernel.org - S: Maintained - F: Documentation/hwmon/it87 - F: drivers/hwmon/it87.c -@@ -5920,7 +5920,7 @@ F: drivers/media/dvb-frontends/ix2505v* - - JC42.4 TEMPERATURE SENSOR DRIVER - M: Guenter Roeck --L: lm-sensors@lm-sensors.org -+L: linux-hwmon@vger.kernel.org - S: Maintained - F: drivers/hwmon/jc42.c - F: Documentation/hwmon/jc42 -@@ -5970,14 +5970,14 @@ F: drivers/tty/serial/jsm/ - - K10TEMP HARDWARE MONITORING DRIVER - M: Clemens Ladisch --L: lm-sensors@lm-sensors.org -+L: linux-hwmon@vger.kernel.org - S: Maintained - F: Documentation/hwmon/k10temp - F: drivers/hwmon/k10temp.c - - K8TEMP HARDWARE MONITORING DRIVER - M: Rudolf Marek --L: lm-sensors@lm-sensors.org -+L: linux-hwmon@vger.kernel.org - S: Maintained - F: Documentation/hwmon/k8temp - F: drivers/hwmon/k8temp.c -@@ -6485,27 +6485,27 @@ F: net/llc/ - - LM73 HARDWARE MONITOR DRIVER - M: Guillaume Ligneul --L: lm-sensors@lm-sensors.org -+L: linux-hwmon@vger.kernel.org - S: Maintained - F: drivers/hwmon/lm73.c - - LM78 HARDWARE MONITOR DRIVER - M: Jean Delvare --L: lm-sensors@lm-sensors.org -+L: linux-hwmon@vger.kernel.org - S: Maintained - F: Documentation/hwmon/lm78 - F: drivers/hwmon/lm78.c - - LM83 HARDWARE MONITOR DRIVER - M: Jean Delvare --L: lm-sensors@lm-sensors.org -+L: linux-hwmon@vger.kernel.org - S: Maintained - F: Documentation/hwmon/lm83 - F: drivers/hwmon/lm83.c - - LM90 HARDWARE MONITOR DRIVER - M: Jean Delvare --L: lm-sensors@lm-sensors.org -+L: linux-hwmon@vger.kernel.org - S: Maintained - F: Documentation/hwmon/lm90 - F: Documentation/devicetree/bindings/hwmon/lm90.txt -@@ -6513,7 +6513,7 @@ F: drivers/hwmon/lm90.c - - LM95234 HARDWARE MONITOR DRIVER - M: Guenter Roeck --L: lm-sensors@lm-sensors.org -+L: linux-hwmon@vger.kernel.org - S: Maintained - F: Documentation/hwmon/lm95234 - F: drivers/hwmon/lm95234.c -@@ -6580,7 +6580,7 @@ F: drivers/scsi/sym53c8xx_2/ - - LTC4261 HARDWARE MONITOR DRIVER - M: Guenter Roeck --L: lm-sensors@lm-sensors.org -+L: linux-hwmon@vger.kernel.org - S: Maintained - F: Documentation/hwmon/ltc4261 - F: drivers/hwmon/ltc4261.c -@@ -6749,28 +6749,28 @@ F: include/uapi/linux/matroxfb.h - - MAX16065 HARDWARE MONITOR DRIVER - M: Guenter Roeck --L: lm-sensors@lm-sensors.org -+L: linux-hwmon@vger.kernel.org - S: Maintained - F: Documentation/hwmon/max16065 - F: drivers/hwmon/max16065.c - - MAX20751 HARDWARE MONITOR DRIVER - M: Guenter Roeck --L: lm-sensors@lm-sensors.org -+L: linux-hwmon@vger.kernel.org - S: Maintained - F: Documentation/hwmon/max20751 - F: drivers/hwmon/max20751.c - - MAX6650 HARDWARE MONITOR AND FAN CONTROLLER DRIVER - M: "Hans J. Koch" --L: lm-sensors@lm-sensors.org -+L: linux-hwmon@vger.kernel.org - S: Maintained - F: Documentation/hwmon/max6650 - F: drivers/hwmon/max6650.c - - MAX6697 HARDWARE MONITOR DRIVER - M: Guenter Roeck --L: lm-sensors@lm-sensors.org -+L: linux-hwmon@vger.kernel.org - S: Maintained - F: Documentation/hwmon/max6697 - F: Documentation/devicetree/bindings/i2c/max6697.txt -@@ -7303,7 +7303,7 @@ F: drivers/scsi/NCR_D700.* - - NCT6775 HARDWARE MONITOR DRIVER - M: Guenter Roeck --L: lm-sensors@lm-sensors.org -+L: linux-hwmon@vger.kernel.org - S: Maintained - F: Documentation/hwmon/nct6775 - F: drivers/hwmon/nct6775.c -@@ -8064,7 +8064,7 @@ F: drivers/video/logo/logo_parisc* - - PC87360 HARDWARE MONITORING DRIVER - M: Jim Cromie --L: lm-sensors@lm-sensors.org -+L: linux-hwmon@vger.kernel.org - S: Maintained - F: Documentation/hwmon/pc87360 - F: drivers/hwmon/pc87360.c -@@ -8076,7 +8076,7 @@ F: drivers/char/pc8736x_gpio.c - - PC87427 HARDWARE MONITORING DRIVER - M: Jean Delvare --L: lm-sensors@lm-sensors.org -+L: linux-hwmon@vger.kernel.org - S: Maintained - F: Documentation/hwmon/pc87427 - F: drivers/hwmon/pc87427.c -@@ -8415,8 +8415,8 @@ F: drivers/rtc/rtc-puv3.c - - PMBUS HARDWARE MONITORING DRIVERS - M: Guenter Roeck --L: lm-sensors@lm-sensors.org --W: http://www.lm-sensors.org/ -+L: linux-hwmon@vger.kernel.org -+W: http://hwmon.wiki.kernel.org/ - W: http://www.roeck-us.net/linux/drivers/ - T: git git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git - S: Maintained -@@ -8610,7 +8610,7 @@ F: drivers/media/usb/pwc/* - - PWM FAN DRIVER - M: Kamil Debski --L: lm-sensors@lm-sensors.org -+L: linux-hwmon@vger.kernel.org - S: Supported - F: Documentation/devicetree/bindings/hwmon/pwm-fan.txt - F: Documentation/hwmon/pwm-fan -@@ -9882,28 +9882,28 @@ F: Documentation/devicetree/bindings/media/i2c/nokia,smia.txt - - SMM665 HARDWARE MONITOR DRIVER - M: Guenter Roeck --L: lm-sensors@lm-sensors.org -+L: linux-hwmon@vger.kernel.org - S: Maintained - F: Documentation/hwmon/smm665 - F: drivers/hwmon/smm665.c - - SMSC EMC2103 HARDWARE MONITOR DRIVER - M: Steve Glendinning --L: lm-sensors@lm-sensors.org -+L: linux-hwmon@vger.kernel.org - S: Maintained - F: Documentation/hwmon/emc2103 - F: drivers/hwmon/emc2103.c - - SMSC SCH5627 HARDWARE MONITOR DRIVER - M: Hans de Goede --L: lm-sensors@lm-sensors.org -+L: linux-hwmon@vger.kernel.org - S: Supported - F: Documentation/hwmon/sch5627 - F: drivers/hwmon/sch5627.c - - SMSC47B397 HARDWARE MONITOR DRIVER - M: Jean Delvare --L: lm-sensors@lm-sensors.org -+L: linux-hwmon@vger.kernel.org - S: Maintained - F: Documentation/hwmon/smsc47b397 - F: drivers/hwmon/smsc47b397.c -@@ -10830,7 +10830,7 @@ F: include/linux/mmc/sh_mobile_sdhi.h - - TMP401 HARDWARE MONITOR DRIVER - M: Guenter Roeck --L: lm-sensors@lm-sensors.org -+L: linux-hwmon@vger.kernel.org - S: Maintained - F: Documentation/hwmon/tmp401 - F: drivers/hwmon/tmp401.c -@@ -11564,14 +11564,14 @@ F: Documentation/networking/vrf.txt - - VT1211 HARDWARE MONITOR DRIVER - M: Juerg Haefliger --L: lm-sensors@lm-sensors.org -+L: linux-hwmon@vger.kernel.org - S: Maintained - F: Documentation/hwmon/vt1211 - F: drivers/hwmon/vt1211.c - - VT8231 HARDWARE MONITOR DRIVER - M: Roger Lucas --L: lm-sensors@lm-sensors.org -+L: linux-hwmon@vger.kernel.org - S: Maintained - F: drivers/hwmon/vt8231.c - -@@ -11590,21 +11590,21 @@ F: drivers/w1/ - - W83791D HARDWARE MONITORING DRIVER - M: Marc Hulsman --L: lm-sensors@lm-sensors.org -+L: linux-hwmon@vger.kernel.org - S: Maintained - F: Documentation/hwmon/w83791d - F: drivers/hwmon/w83791d.c - - W83793 HARDWARE MONITORING DRIVER - M: Rudolf Marek --L: lm-sensors@lm-sensors.org -+L: linux-hwmon@vger.kernel.org - S: Maintained - F: Documentation/hwmon/w83793 - F: drivers/hwmon/w83793.c - - W83795 HARDWARE MONITORING DRIVER - M: Jean Delvare --L: lm-sensors@lm-sensors.org -+L: linux-hwmon@vger.kernel.org - S: Maintained - F: drivers/hwmon/w83795.c - -diff --git a/Makefile b/Makefile -index 87d12b4..ce2ce88 100644 ---- a/Makefile -+++ b/Makefile -@@ -1,6 +1,6 @@ - VERSION = 4 - PATCHLEVEL = 4 --SUBLEVEL = 6 -+SUBLEVEL = 14 - EXTRAVERSION = - NAME = Blurry Fish Butt - -@@ -364,7 +364,7 @@ AFLAGS_MODULE = - LDFLAGS_MODULE = - CFLAGS_KERNEL = - AFLAGS_KERNEL = --CFLAGS_GCOV = -fprofile-arcs -ftest-coverage -+CFLAGS_GCOV = -fprofile-arcs -ftest-coverage -fno-tree-loop-im - - - # Use USERINCLUDE when you must reference the UAPI directories only. -@@ -682,9 +682,10 @@ KBUILD_CFLAGS += $(call cc-option, -mno-global-merge,) - KBUILD_CFLAGS += $(call cc-option, -fcatch-undefined-behavior) - else - --# This warning generated too much noise in a regular build. --# Use make W=1 to enable this warning (see scripts/Makefile.build) -+# These warnings generated too much noise in a regular build. -+# Use make W=1 to enable them (see scripts/Makefile.build) - KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable) -+KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable) - endif - - ifdef CONFIG_FRAME_POINTER -@@ -767,6 +768,9 @@ KBUILD_CFLAGS += $(call cc-option,-Werror=strict-prototypes) - # Prohibit date/time macros, which would make the build non-deterministic - KBUILD_CFLAGS += $(call cc-option,-Werror=date-time) - -+# enforce correct pointer usage -+KBUILD_CFLAGS += $(call cc-option,-Werror=incompatible-pointer-types) -+ - # use the deterministic mode of AR if available - KBUILD_ARFLAGS := $(call ar-option,D) - -diff --git a/arch/Kconfig b/arch/Kconfig -index 81592b3..3b26d76 100644 ---- a/arch/Kconfig -+++ b/arch/Kconfig -@@ -53,6 +53,7 @@ config KPROBES - config JUMP_LABEL - bool "Optimize very unlikely/likely branches" - depends on HAVE_ARCH_JUMP_LABEL -+ depends on (!INTERRUPT_OFF_HIST && !PREEMPT_OFF_HIST && !WAKEUP_LATENCY_HIST && !MISSED_TIMER_OFFSETS_HIST) - help - This option enables a transparent branch optimization that - makes certain almost-always-true or almost-always-false branch -diff --git a/arch/arc/include/asm/bitops.h b/arch/arc/include/asm/bitops.h -index 57c1f33..0352fb8 100644 ---- a/arch/arc/include/asm/bitops.h -+++ b/arch/arc/include/asm/bitops.h -@@ -35,21 +35,6 @@ static inline void op##_bit(unsigned long nr, volatile unsigned long *m)\ - \ - m += nr >> 5; \ - \ -- /* \ -- * ARC ISA micro-optimization: \ -- * \ -- * Instructions dealing with bitpos only consider lower 5 bits \ -- * e.g (x << 33) is handled like (x << 1) by ASL instruction \ -- * (mem pointer still needs adjustment to point to next word) \ -- * \ -- * Hence the masking to clamp @nr arg can be elided in general. \ -- * \ -- * However if @nr is a constant (above assumed in a register), \ -- * and greater than 31, gcc can optimize away (x << 33) to 0, \ -- * as overflow, given the 32-bit ISA. Thus masking needs to be \ -- * done for const @nr, but no code is generated due to gcc \ -- * const prop. \ -- */ \ - nr &= 0x1f; \ - \ - __asm__ __volatile__( \ -diff --git a/arch/arc/include/asm/io.h b/arch/arc/include/asm/io.h -index 694ece8..cb69299 100644 ---- a/arch/arc/include/asm/io.h -+++ b/arch/arc/include/asm/io.h -@@ -13,6 +13,15 @@ - #include - #include - -+#ifdef CONFIG_ISA_ARCV2 -+#include -+#define __iormb() rmb() -+#define __iowmb() wmb() -+#else -+#define __iormb() do { } while (0) -+#define __iowmb() do { } while (0) -+#endif -+ - extern void __iomem *ioremap(unsigned long physaddr, unsigned long size); - extern void __iomem *ioremap_prot(phys_addr_t offset, unsigned long size, - unsigned long flags); -@@ -22,6 +31,15 @@ extern void iounmap(const void __iomem *addr); - #define ioremap_wc(phy, sz) ioremap(phy, sz) - #define ioremap_wt(phy, sz) ioremap(phy, sz) - -+/* -+ * io{read,write}{16,32}be() macros -+ */ -+#define ioread16be(p) ({ u16 __v = be16_to_cpu((__force __be16)__raw_readw(p)); __iormb(); __v; }) -+#define ioread32be(p) ({ u32 __v = be32_to_cpu((__force __be32)__raw_readl(p)); __iormb(); __v; }) -+ -+#define iowrite16be(v,p) ({ __iowmb(); __raw_writew((__force u16)cpu_to_be16(v), p); }) -+#define iowrite32be(v,p) ({ __iowmb(); __raw_writel((__force u32)cpu_to_be32(v), p); }) -+ - /* Change struct page to physical address */ - #define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT) - -@@ -99,15 +117,6 @@ static inline void __raw_writel(u32 w, volatile void __iomem *addr) - - } - --#ifdef CONFIG_ISA_ARCV2 --#include --#define __iormb() rmb() --#define __iowmb() wmb() --#else --#define __iormb() do { } while (0) --#define __iowmb() do { } while (0) --#endif -- - /* - * MMIO can also get buffered/optimized in micro-arch, so barriers needed - * Based on ARM model for the typical use case -@@ -129,15 +138,23 @@ static inline void __raw_writel(u32 w, volatile void __iomem *addr) - #define writel(v,c) ({ __iowmb(); writel_relaxed(v,c); }) - - /* -- * Relaxed API for drivers which can handle any ordering themselves -+ * Relaxed API for drivers which can handle barrier ordering themselves -+ * -+ * Also these are defined to perform little endian accesses. -+ * To provide the typical device register semantics of fixed endian, -+ * swap the byte order for Big Endian -+ * -+ * http://lkml.kernel.org/r/201603100845.30602.arnd@arndb.de - */ - #define readb_relaxed(c) __raw_readb(c) --#define readw_relaxed(c) __raw_readw(c) --#define readl_relaxed(c) __raw_readl(c) -+#define readw_relaxed(c) ({ u16 __r = le16_to_cpu((__force __le16) \ -+ __raw_readw(c)); __r; }) -+#define readl_relaxed(c) ({ u32 __r = le32_to_cpu((__force __le32) \ -+ __raw_readl(c)); __r; }) - - #define writeb_relaxed(v,c) __raw_writeb(v,c) --#define writew_relaxed(v,c) __raw_writew(v,c) --#define writel_relaxed(v,c) __raw_writel(v,c) -+#define writew_relaxed(v,c) __raw_writew((__force u16) cpu_to_le16(v),c) -+#define writel_relaxed(v,c) __raw_writel((__force u32) cpu_to_le32(v),c) - - #include - -diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile -index d240cee..e20073a 100644 ---- a/arch/arm/boot/dts/Makefile -+++ b/arch/arm/boot/dts/Makefile -@@ -308,6 +308,8 @@ dtb-$(CONFIG_SOC_IMX6Q) += \ - imx6dl-tx6u-801x.dtb \ - imx6dl-tx6u-811x.dtb \ - imx6dl-udoo.dtb \ -+ imx6dl-udoo-7lvds.dtb \ -+ imx6dl-udoo-15lvds.dtb \ - imx6dl-sbc-fx6.dtb \ - imx6dl-sbc-fx6m.dtb \ - imx6dl-wandboard.dtb \ -@@ -351,6 +353,8 @@ dtb-$(CONFIG_SOC_IMX6Q) += \ - imx6q-tx6q-1020-comtft.dtb \ - imx6q-tx6q-1110.dtb \ - imx6q-udoo.dtb \ -+ imx6q-udoo-7lvds.dtb \ -+ imx6q-udoo-15lvds.dtb \ - imx6q-wandboard.dtb \ - imx6q-wandboard-revb1.dtb \ - imx6dl-vero.dtb -diff --git a/arch/arm/boot/dts/am43x-epos-evm.dts b/arch/arm/boot/dts/am43x-epos-evm.dts -index 47954ed..00707aa 100644 ---- a/arch/arm/boot/dts/am43x-epos-evm.dts -+++ b/arch/arm/boot/dts/am43x-epos-evm.dts -@@ -792,3 +792,8 @@ - tx-num-evt = <32>; - rx-num-evt = <32>; - }; -+ -+&synctimer_32kclk { -+ assigned-clocks = <&mux_synctimer32k_ck>; -+ assigned-clock-parents = <&clkdiv32k_ick>; -+}; -diff --git a/arch/arm/boot/dts/armada-375.dtsi b/arch/arm/boot/dts/armada-375.dtsi -index 7ccce75..cc952cf 100644 ---- a/arch/arm/boot/dts/armada-375.dtsi -+++ b/arch/arm/boot/dts/armada-375.dtsi -@@ -529,7 +529,7 @@ - }; - - sata@a0000 { -- compatible = "marvell,orion-sata"; -+ compatible = "marvell,armada-370-sata"; - reg = <0xa0000 0x5000>; - interrupts = ; - clocks = <&gateclk 14>, <&gateclk 20>; -diff --git a/arch/arm/boot/dts/armada-385-linksys.dtsi b/arch/arm/boot/dts/armada-385-linksys.dtsi -index c2d87f5..dd079d0 100644 ---- a/arch/arm/boot/dts/armada-385-linksys.dtsi -+++ b/arch/arm/boot/dts/armada-385-linksys.dtsi -@@ -117,7 +117,7 @@ - }; - - /* USB part of the eSATA/USB 2.0 port */ -- usb@50000 { -+ usb@58000 { - status = "okay"; - }; - -diff --git a/arch/arm/boot/dts/at91-sama5d3_xplained.dts b/arch/arm/boot/dts/at91-sama5d3_xplained.dts -index ff888d2..f3e2b96 100644 ---- a/arch/arm/boot/dts/at91-sama5d3_xplained.dts -+++ b/arch/arm/boot/dts/at91-sama5d3_xplained.dts -@@ -303,6 +303,7 @@ - regulator-name = "mmc0-card-supply"; - regulator-min-microvolt = <3300000>; - regulator-max-microvolt = <3300000>; -+ regulator-always-on; - }; - - gpio_keys { -diff --git a/arch/arm/boot/dts/at91-sama5d4_xplained.dts b/arch/arm/boot/dts/at91-sama5d4_xplained.dts -index 569026e..da84e65 100644 ---- a/arch/arm/boot/dts/at91-sama5d4_xplained.dts -+++ b/arch/arm/boot/dts/at91-sama5d4_xplained.dts -@@ -268,5 +268,6 @@ - regulator-min-microvolt = <3300000>; - regulator-max-microvolt = <3300000>; - vin-supply = <&vcc_3v3_reg>; -+ regulator-always-on; - }; - }; -diff --git a/arch/arm/boot/dts/at91sam9x5.dtsi b/arch/arm/boot/dts/at91sam9x5.dtsi -index 0827d59..cd0cd5f 100644 ---- a/arch/arm/boot/dts/at91sam9x5.dtsi -+++ b/arch/arm/boot/dts/at91sam9x5.dtsi -@@ -106,7 +106,7 @@ - - pmc: pmc@fffffc00 { - compatible = "atmel,at91sam9x5-pmc", "syscon"; -- reg = <0xfffffc00 0x100>; -+ reg = <0xfffffc00 0x200>; - interrupts = <1 IRQ_TYPE_LEVEL_HIGH 7>; - interrupt-controller; - #address-cells = <1>; -diff --git a/arch/arm/boot/dts/exynos4210-trats.dts b/arch/arm/boot/dts/exynos4210-trats.dts -index a50be64..59411e4 100644 ---- a/arch/arm/boot/dts/exynos4210-trats.dts -+++ b/arch/arm/boot/dts/exynos4210-trats.dts -@@ -298,6 +298,8 @@ - compatible = "maxim,max8997-pmic"; - - reg = <0x66>; -+ interrupt-parent = <&gpx0>; -+ interrupts = <7 0>; - - max8997,pmic-buck1-uses-gpio-dvs; - max8997,pmic-buck2-uses-gpio-dvs; -diff --git a/arch/arm/boot/dts/imx6dl-udoo-15lvds.dts b/arch/arm/boot/dts/imx6dl-udoo-15lvds.dts -new file mode 100644 -index 0000000..3b2c7ce ---- /dev/null -+++ b/arch/arm/boot/dts/imx6dl-udoo-15lvds.dts -@@ -0,0 +1,63 @@ -+/* -+ * Copyright 2013 Freescale Semiconductor, Inc. -+ * -+ * Author: Fabio Estevam -+ * Author: Ettore Chimenti -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License version 2 as -+ * published by the Free Software Foundation. -+ * -+ */ -+ -+/dts-v1/; -+#include "imx6dl.dtsi" -+#include "imx6qdl-udoo.dtsi" -+ -+/ { -+ model = "Udoo i.MX6 Dual-lite Board"; -+ compatible = "udoo,imx6dl-udoo", "fsl,imx6dl"; -+ -+ mxcfb2: fb@1 { -+ compatible = "fsl,mxc_sdc_fb"; -+ disp_dev = "ldb"; -+ interface_pix_fmt = "RGB24"; -+ mode_str = "1360x768M@60"; -+ default_bpp = <32>; -+ int_clk = <0>; -+ late_init = <1>; -+ status = "okay"; -+ }; -+ -+ regulators { -+ reg_lcd0_pwr: regulator@1 { -+ status = "okay"; -+ }; -+ -+ reg_lcd0_backlight: regulator@2 { -+ status = "okay"; -+ }; -+ }; -+}; -+ -+&dcic1 { -+ status = "disabled"; -+}; -+ -+&dcic2 { -+ dcic_id = <0>; -+ status = "okay"; -+}; -+ -+&ldb { -+ status = "okay"; -+ -+ lvds-channel@0 { -+ status = "okay"; -+ fsl,data-width = <24>; -+ -+ display-timings { -+ native-mode = <&timing2>; -+ }; -+ }; -+}; -diff --git a/arch/arm/boot/dts/imx6dl-udoo-7lvds.dts b/arch/arm/boot/dts/imx6dl-udoo-7lvds.dts -new file mode 100644 -index 0000000..65114b7 ---- /dev/null -+++ b/arch/arm/boot/dts/imx6dl-udoo-7lvds.dts -@@ -0,0 +1,58 @@ -+/* -+ * Copyright 2013 Freescale Semiconductor, Inc. -+ * -+ * Author: Fabio Estevam -+ * Author: Ettore Chimenti -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License version 2 as -+ * published by the Free Software Foundation. -+ * -+ */ -+ -+/dts-v1/; -+#include "imx6dl.dtsi" -+#include "imx6qdl-udoo.dtsi" -+ -+/ { -+ model = "Udoo i.MX6 Dual-lite Board"; -+ compatible = "udoo,imx6dl-udoo", "fsl,imx6dl"; -+ -+ mxcfb2: fb@1 { -+ compatible = "fsl,mxc_sdc_fb"; -+ disp_dev = "ldb"; -+ interface_pix_fmt = "RGB666"; -+ mode_str = "800x480M@60"; -+ default_bpp = <32>; -+ int_clk = <0>; -+ late_init = <0>; -+ status = "okay"; -+ }; -+ -+ regulators { -+ reg_lcd0_pwr: regulator@1 { -+ status = "okay"; -+ }; -+ -+ reg_lcd0_backlight: regulator@2 { -+ status = "okay"; -+ }; -+ }; -+}; -+ -+&dcic1 { -+ status = "disabled"; -+}; -+ -+&dcic2 { -+ dcic_id = <0>; -+ status = "okay"; -+}; -+ -+&ldb { -+ status = "okay"; -+ -+ lvds-channel@0 { -+ status = "okay"; -+ }; -+}; -diff --git a/arch/arm/boot/dts/imx6q-tbs2910.dts b/arch/arm/boot/dts/imx6q-tbs2910.dts -index 5645d52..a910249 100644 ---- a/arch/arm/boot/dts/imx6q-tbs2910.dts -+++ b/arch/arm/boot/dts/imx6q-tbs2910.dts -@@ -154,7 +154,7 @@ - status = "okay"; - }; - --&hdmi { -+&hdmi_core { - pinctrl-names = "default"; - pinctrl-0 = <&pinctrl_hdmi>; - ddc-i2c-bus = <&i2c2>; -diff --git a/arch/arm/boot/dts/imx6q-udoo-15lvds.dts b/arch/arm/boot/dts/imx6q-udoo-15lvds.dts -new file mode 100644 -index 0000000..182c696 ---- /dev/null -+++ b/arch/arm/boot/dts/imx6q-udoo-15lvds.dts -@@ -0,0 +1,67 @@ -+/* -+ * Copyright 2013 Freescale Semiconductor, Inc. -+ * -+ * Author: Fabio Estevam -+ * Author: Ettore Chimenti -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License version 2 as -+ * published by the Free Software Foundation. -+ * -+ */ -+ -+/dts-v1/; -+#include "imx6q.dtsi" -+#include "imx6qdl-udoo.dtsi" -+ -+/ { -+ model = "Udoo i.MX6 Quad Board"; -+ compatible = "udoo,imx6q-udoo", "fsl,imx6q"; -+ -+ mxcfb2: fb@1 { -+ compatible = "fsl,mxc_sdc_fb"; -+ disp_dev = "ldb"; -+ interface_pix_fmt = "RGB24"; -+ mode_str = "1360x768M@60"; -+ default_bpp = <32>; -+ int_clk = <0>; -+ late_init = <1>; -+ status = "okay"; -+ }; -+ -+ regulators { -+ reg_lcd0_pwr: regulator@1 { -+ status = "okay"; -+ }; -+ -+ reg_lcd0_backlight: regulator@2 { -+ status = "okay"; -+ }; -+ }; -+}; -+ -+&sata { -+ status = "okay"; -+}; -+ -+&dcic1 { -+ status = "disabled"; -+}; -+ -+&dcic2 { -+ dcic_id = <0>; -+ status = "okay"; -+}; -+ -+&ldb { -+ status = "okay"; -+ -+ lvds-channel@0 { -+ status = "okay"; -+ fsl,data-width = <24>; -+ -+ display-timings { -+ native-mode = <&timing2>; -+ }; -+ }; -+}; -diff --git a/arch/arm/boot/dts/imx6q-udoo-7lvds.dts b/arch/arm/boot/dts/imx6q-udoo-7lvds.dts -new file mode 100644 -index 0000000..5ba2ff2 ---- /dev/null -+++ b/arch/arm/boot/dts/imx6q-udoo-7lvds.dts -@@ -0,0 +1,62 @@ -+/* -+ * Copyright 2013 Freescale Semiconductor, Inc. -+ * -+ * Author: Fabio Estevam -+ * Author: Ettore Chimenti -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License version 2 as -+ * published by the Free Software Foundation. -+ * -+ */ -+ -+/dts-v1/; -+#include "imx6q.dtsi" -+#include "imx6qdl-udoo.dtsi" -+ -+/ { -+ model = "Udoo i.MX6 Quad Board"; -+ compatible = "udoo,imx6q-udoo", "fsl,imx6q"; -+ -+ mxcfb2: fb@1 { -+ compatible = "fsl,mxc_sdc_fb"; -+ disp_dev = "ldb"; -+ interface_pix_fmt = "RGB666"; -+ mode_str = "800x480M@60"; -+ default_bpp = <32>; -+ int_clk = <0>; -+ late_init = <0>; -+ status = "okay"; -+ }; -+ -+ regulators { -+ reg_lcd0_pwr: regulator@1 { -+ status = "okay"; -+ }; -+ -+ reg_lcd0_backlight: regulator@2 { -+ status = "okay"; -+ }; -+ }; -+}; -+ -+&sata { -+ status = "okay"; -+}; -+ -+&dcic1 { -+ status = "disabled"; -+}; -+ -+&dcic2 { -+ dcic_id = <0>; -+ status = "okay"; -+}; -+ -+&ldb { -+ status = "okay"; -+ -+ lvds-channel@0 { -+ status = "okay"; -+ }; -+}; -diff --git a/arch/arm/boot/dts/imx6qdl-udoo.dtsi b/arch/arm/boot/dts/imx6qdl-udoo.dtsi -index 7c64e72..4c201c6 100755 ---- a/arch/arm/boot/dts/imx6qdl-udoo.dtsi -+++ b/arch/arm/boot/dts/imx6qdl-udoo.dtsi -@@ -202,7 +202,7 @@ - &dcic2 { - dcic_id = <1>; - dcic_mux = "dcic-lvds1"; -- status = "okay"; -+ status = "disabled"; - }; - - &gpc { // General power controller -@@ -254,9 +254,9 @@ - vsync-len = <2>; - }; - -- timing2: 1366x768 { // 15.6" display -+ timing2: 1360x768 { // 15.6" display - clock-frequency = <76000000>; -- hactive = <1366>; -+ hactive = <1360>; // IPU needs x and y modulo 8 - vactive = <768>; - hback-porch = <220>; - hfront-porch = <40>; -diff --git a/arch/arm/boot/dts/imx6qdl.dtsi b/arch/arm/boot/dts/imx6qdl.dtsi -index 5e2c93e..74fb390 100644 ---- a/arch/arm/boot/dts/imx6qdl.dtsi -+++ b/arch/arm/boot/dts/imx6qdl.dtsi -@@ -242,12 +242,12 @@ - <&clks IMX6QDL_CLK_SPDIF>, <&clks IMX6QDL_CLK_DUMMY>, - <&clks IMX6QDL_CLK_DUMMY>, <&clks IMX6QDL_CLK_DUMMY>, - <&clks IMX6QDL_CLK_DUMMY>, <&clks IMX6QDL_CLK_DUMMY>, -- <&clks IMX6QDL_CLK_DUMMY>; -+ <&clks IMX6QDL_CLK_DUMMY>, <&clks IMX6QDL_CLK_SPBA>; - clock-names = "core", "rxtx0", - "rxtx1", "rxtx2", - "rxtx3", "rxtx4", - "rxtx5", "rxtx6", -- "rxtx7"; -+ "rxtx7", "dma"; - status = "disabled"; - }; - -@@ -1126,6 +1126,7 @@ - compatible = "fsl,imx6q-vdoa"; - reg = <0x021e4000 0x4000>; - interrupts = <0 18 IRQ_TYPE_LEVEL_HIGH>; -+ interrupt-names = "vdoa"; - clocks = <&clks IMX6QDL_CLK_VDOA>; - iram = <&ocram>; - }; -diff --git a/arch/arm/boot/dts/pxa3xx.dtsi b/arch/arm/boot/dts/pxa3xx.dtsi -index cf6998a..564341a 100644 ---- a/arch/arm/boot/dts/pxa3xx.dtsi -+++ b/arch/arm/boot/dts/pxa3xx.dtsi -@@ -30,7 +30,7 @@ - reg = <0x43100000 90>; - interrupts = <45>; - clocks = <&clks CLK_NAND>; -- dmas = <&pdma 97>; -+ dmas = <&pdma 97 3>; - dma-names = "data"; - #address-cells = <1>; - #size-cells = <1>; -diff --git a/arch/arm/boot/dts/sama5d2-pinfunc.h b/arch/arm/boot/dts/sama5d2-pinfunc.h -index b0c912f..8a394f3 100644 ---- a/arch/arm/boot/dts/sama5d2-pinfunc.h -+++ b/arch/arm/boot/dts/sama5d2-pinfunc.h -@@ -837,8 +837,8 @@ - #define PIN_PD23__ISC_FIELD PINMUX_PIN(PIN_PD23, 6, 4) - #define PIN_PD24 120 - #define PIN_PD24__GPIO PINMUX_PIN(PIN_PD24, 0, 0) --#define PIN_PD24__UTXD2 PINMUX_PIN(PIN_PD23, 1, 2) --#define PIN_PD24__FLEXCOM4_IO3 PINMUX_PIN(PIN_PD23, 3, 3) -+#define PIN_PD24__UTXD2 PINMUX_PIN(PIN_PD24, 1, 2) -+#define PIN_PD24__FLEXCOM4_IO3 PINMUX_PIN(PIN_PD24, 3, 3) - #define PIN_PD25 121 - #define PIN_PD25__GPIO PINMUX_PIN(PIN_PD25, 0, 0) - #define PIN_PD25__SPI1_SPCK PINMUX_PIN(PIN_PD25, 1, 3) -diff --git a/arch/arm/configs/xbian_defconfig_imx6_mvebu b/arch/arm/configs/xbian_defconfig_imx6_mvebu -index 2bc59d8..83cda36 100644 ---- a/arch/arm/configs/xbian_defconfig_imx6_mvebu -+++ b/arch/arm/configs/xbian_defconfig_imx6_mvebu -@@ -1,6 +1,6 @@ - # - # Automatically generated file; DO NOT EDIT. --# Linux/arm 4.4.1 Kernel Configuration -+# Linux/arm 4.4.6 Kernel Configuration - # - CONFIG_ARM=y - CONFIG_ARM_HAS_SG_CHAIN=y -@@ -83,7 +83,7 @@ CONFIG_NO_HZ_COMMON=y - # CONFIG_HZ_PERIODIC is not set - CONFIG_NO_HZ_IDLE=y - # CONFIG_NO_HZ_FULL is not set --CONFIG_NO_HZ=y -+# CONFIG_NO_HZ is not set - CONFIG_HIGH_RES_TIMERS=y - - # -@@ -104,12 +104,12 @@ CONFIG_RCU_EXPERT=y - CONFIG_SRCU=y - # CONFIG_TASKS_RCU is not set - CONFIG_RCU_STALL_COMMON=y --CONFIG_RCU_FANOUT=16 --CONFIG_RCU_FANOUT_LEAF=8 -+CONFIG_RCU_FANOUT=8 -+CONFIG_RCU_FANOUT_LEAF=2 - # CONFIG_TREE_RCU_TRACE is not set - CONFIG_RCU_BOOST=y - CONFIG_RCU_KTHREAD_PRIO=1 --CONFIG_RCU_BOOST_DELAY=500 -+CONFIG_RCU_BOOST_DELAY=300 - CONFIG_RCU_NOCB_CPU=y - CONFIG_RCU_NOCB_CPU_NONE=y - # CONFIG_RCU_NOCB_CPU_ZERO is not set -@@ -166,7 +166,6 @@ CONFIG_MULTIUSER=y - CONFIG_SYSFS_SYSCALL=y - CONFIG_SYSCTL_SYSCALL=y - CONFIG_KALLSYMS=y --CONFIG_KALLSYMS_ALL=y - CONFIG_PRINTK=y - CONFIG_BUG=y - CONFIG_BASE_FULL=y -@@ -178,7 +177,7 @@ CONFIG_EVENTFD=y - # CONFIG_BPF_SYSCALL is not set - CONFIG_SHMEM=y - CONFIG_AIO=y --# CONFIG_ADVISE_SYSCALLS is not set -+CONFIG_ADVISE_SYSCALLS=y - CONFIG_USERFAULTFD=y - CONFIG_PCI_QUIRKS=y - CONFIG_MEMBARRIER=y -@@ -190,7 +189,6 @@ CONFIG_PERF_USE_VMALLOC=y - # Kernel Performance Events And Counters - # - CONFIG_PERF_EVENTS=y --# CONFIG_DEBUG_PERF_USE_VMALLOC is not set - # CONFIG_VM_EVENT_COUNTERS is not set - # CONFIG_SLUB_DEBUG is not set - CONFIG_COMPAT_BRK=y -@@ -248,8 +246,8 @@ CONFIG_MODULES=y - # CONFIG_MODULE_FORCE_LOAD is not set - CONFIG_MODULE_UNLOAD=y - # CONFIG_MODULE_FORCE_UNLOAD is not set --CONFIG_MODVERSIONS=y --CONFIG_MODULE_SRCVERSION_ALL=y -+# CONFIG_MODVERSIONS is not set -+# CONFIG_MODULE_SRCVERSION_ALL is not set - # CONFIG_MODULE_SIG is not set - # CONFIG_MODULE_COMPRESS is not set - CONFIG_MODULES_TREE_LOOKUP=y -@@ -490,7 +488,6 @@ CONFIG_PCI_DOMAINS=y - CONFIG_PCI_DOMAINS_GENERIC=y - CONFIG_PCI_SYSCALL=y - CONFIG_PCI_MSI=y --# CONFIG_PCI_DEBUG is not set - CONFIG_PCI_REALLOC_ENABLE_AUTO=y - CONFIG_PCI_STUB=y - CONFIG_PCI_ATS=y -@@ -587,14 +584,12 @@ CONFIG_MIGRATION=y - CONFIG_ZONE_DMA_FLAG=1 - CONFIG_BOUNCE=y - # CONFIG_KSM is not set --CONFIG_DEFAULT_MMAP_MIN_ADDR=16384 --CONFIG_CLEANCACHE=y --CONFIG_FRONTSWAP=y -+CONFIG_DEFAULT_MMAP_MIN_ADDR=8192 -+# CONFIG_CLEANCACHE is not set -+# CONFIG_FRONTSWAP is not set - CONFIG_CMA=y --# CONFIG_CMA_DEBUG is not set - # CONFIG_CMA_DEBUGFS is not set - CONFIG_CMA_AREAS=7 --# CONFIG_ZSWAP is not set - # CONFIG_ZPOOL is not set - # CONFIG_ZBUD is not set - # CONFIG_ZSMALLOC is not set -@@ -699,14 +694,18 @@ CONFIG_BINFMT_MISC=m - CONFIG_SUSPEND=y - CONFIG_SUSPEND_FREEZER=y - # CONFIG_SUSPEND_SKIP_SYNC is not set --# CONFIG_HIBERNATION is not set -+CONFIG_HIBERNATE_CALLBACKS=y -+CONFIG_HIBERNATION=y -+CONFIG_PM_STD_PARTITION="" - CONFIG_PM_SLEEP=y - CONFIG_PM_SLEEP_SMP=y - # CONFIG_PM_AUTOSLEEP is not set --# CONFIG_PM_WAKELOCKS is not set -+CONFIG_PM_WAKELOCKS=y -+CONFIG_PM_WAKELOCKS_LIMIT=100 -+CONFIG_PM_WAKELOCKS_GC=y - CONFIG_PM=y - # CONFIG_PM_DEBUG is not set --# CONFIG_APM_EMULATION is not set -+CONFIG_APM_EMULATION=y - CONFIG_PM_OPP=y - CONFIG_PM_CLK=y - CONFIG_PM_GENERIC_DOMAINS=y -@@ -777,7 +776,7 @@ CONFIG_INET_UDP_DIAG=m - CONFIG_TCP_CONG_ADVANCED=y - CONFIG_TCP_CONG_BIC=m - CONFIG_TCP_CONG_CUBIC=m --CONFIG_TCP_CONG_WESTWOOD=m -+CONFIG_TCP_CONG_WESTWOOD=y - CONFIG_TCP_CONG_HTCP=m - CONFIG_TCP_CONG_HSTCP=m - CONFIG_TCP_CONG_HYBLA=m -@@ -789,9 +788,10 @@ CONFIG_TCP_CONG_YEAH=y - CONFIG_TCP_CONG_ILLINOIS=m - CONFIG_TCP_CONG_DCTCP=m - # CONFIG_TCP_CONG_CDG is not set --CONFIG_DEFAULT_VEGAS=y -+# CONFIG_DEFAULT_VEGAS is not set -+CONFIG_DEFAULT_WESTWOOD=y - # CONFIG_DEFAULT_RENO is not set --CONFIG_DEFAULT_TCP_CONG="vegas" -+CONFIG_DEFAULT_TCP_CONG="westwood" - CONFIG_TCP_MD5SIG=y - CONFIG_IPV6=m - CONFIG_IPV6_ROUTER_PREF=y -@@ -821,7 +821,7 @@ CONFIG_IPV6_MROUTE_MULTIPLE_TABLES=y - CONFIG_IPV6_PIMSM_V2=y - # CONFIG_NETWORK_SECMARK is not set - CONFIG_NET_PTP_CLASSIFY=y --# CONFIG_NETWORK_PHY_TIMESTAMPING is not set -+CONFIG_NETWORK_PHY_TIMESTAMPING=y - CONFIG_NETFILTER=y - # CONFIG_NETFILTER_DEBUG is not set - CONFIG_NETFILTER_ADVANCED=y -@@ -1153,20 +1153,15 @@ CONFIG_INET_DCCP_DIAG=m - CONFIG_IP_DCCP_CCID3=y - # CONFIG_IP_DCCP_CCID3_DEBUG is not set - CONFIG_IP_DCCP_TFRC_LIB=y -- --# --# DCCP Kernel Hacking --# --# CONFIG_IP_DCCP_DEBUG is not set - CONFIG_IP_SCTP=m - # CONFIG_SCTP_DBG_OBJCNT is not set --CONFIG_SCTP_DEFAULT_COOKIE_HMAC_MD5=y -+# CONFIG_SCTP_DEFAULT_COOKIE_HMAC_MD5 is not set - # CONFIG_SCTP_DEFAULT_COOKIE_HMAC_SHA1 is not set --# CONFIG_SCTP_DEFAULT_COOKIE_HMAC_NONE is not set --CONFIG_SCTP_COOKIE_HMAC_MD5=y --CONFIG_SCTP_COOKIE_HMAC_SHA1=y -+CONFIG_SCTP_DEFAULT_COOKIE_HMAC_NONE=y -+# CONFIG_SCTP_COOKIE_HMAC_MD5 is not set -+# CONFIG_SCTP_COOKIE_HMAC_SHA1 is not set - CONFIG_RDS=m --# CONFIG_RDS_TCP is not set -+CONFIG_RDS_TCP=m - # CONFIG_RDS_DEBUG is not set - CONFIG_TIPC=m - CONFIG_TIPC_MEDIA_UDP=y -@@ -1177,6 +1172,8 @@ CONFIG_L2TP_V3=y - CONFIG_L2TP_IP=m - CONFIG_L2TP_ETH=m - CONFIG_STP=m -+CONFIG_GARP=m -+CONFIG_MRP=m - CONFIG_BRIDGE=m - CONFIG_BRIDGE_IGMP_SNOOPING=y - CONFIG_BRIDGE_VLAN_FILTERING=y -@@ -1185,8 +1182,8 @@ CONFIG_NET_DSA=y - CONFIG_NET_DSA_HWMON=y - CONFIG_NET_DSA_TAG_EDSA=y - CONFIG_VLAN_8021Q=m --# CONFIG_VLAN_8021Q_GVRP is not set --# CONFIG_VLAN_8021Q_MVRP is not set -+CONFIG_VLAN_8021Q_GVRP=y -+CONFIG_VLAN_8021Q_MVRP=y - # CONFIG_DECNET is not set - CONFIG_LLC=m - CONFIG_LLC2=m -@@ -1197,7 +1194,7 @@ CONFIG_IPDDP=m - CONFIG_IPDDP_ENCAP=y - # CONFIG_X25 is not set - # CONFIG_LAPB is not set --# CONFIG_PHONET is not set -+CONFIG_PHONET=m - # CONFIG_6LOWPAN is not set - # CONFIG_IEEE802154 is not set - CONFIG_NET_SCHED=y -@@ -1286,7 +1283,7 @@ CONFIG_NET_MPLS_GSO=m - # CONFIG_MPLS_ROUTING is not set - # CONFIG_HSR is not set - CONFIG_NET_SWITCHDEV=y --# CONFIG_NET_L3_MASTER_DEV is not set -+CONFIG_NET_L3_MASTER_DEV=y - CONFIG_RPS=y - CONFIG_RFS_ACCEL=y - CONFIG_XPS=y -@@ -1403,7 +1400,6 @@ CONFIG_BT_CMTP=m - CONFIG_BT_HIDP=y - CONFIG_BT_HS=y - CONFIG_BT_LE=y --# CONFIG_BT_SELFTEST is not set - # CONFIG_BT_DEBUGFS is not set - - # -@@ -1523,8 +1519,6 @@ CONFIG_FW_LOADER_USER_HELPER_FALLBACK=y - CONFIG_WANT_DEV_COREDUMP=y - CONFIG_ALLOW_DEV_COREDUMP=y - CONFIG_DEV_COREDUMP=y --# CONFIG_DEBUG_DRIVER is not set --# CONFIG_DEBUG_DEVRES is not set - # CONFIG_SYS_HYPERVISOR is not set - # CONFIG_GENERIC_CPU_DEVICES is not set - CONFIG_SOC_BUS=y -@@ -2043,9 +2037,9 @@ CONFIG_DM_VERITY=m - # CONFIG_FIREWIRE is not set - # CONFIG_FIREWIRE_NOSY is not set - CONFIG_NETDEVICES=y --CONFIG_MII=y -+CONFIG_MII=m - CONFIG_NET_CORE=y --CONFIG_BONDING=y -+CONFIG_BONDING=m - CONFIG_DUMMY=m - CONFIG_EQUALIZER=m - # CONFIG_NET_FC is not set -@@ -2070,6 +2064,7 @@ CONFIG_TUN=m - CONFIG_VETH=m - # CONFIG_VIRTIO_NET is not set - CONFIG_NLMON=m -+# CONFIG_NET_VRF is not set - # CONFIG_ARCNET is not set - - # -@@ -2096,7 +2091,7 @@ CONFIG_NET_DSA_MV88E6XXX=y - CONFIG_NET_DSA_MV88E6352=y - # CONFIG_NET_DSA_BCM_SF2 is not set - CONFIG_ETHERNET=y --CONFIG_MDIO=y -+CONFIG_MDIO=m - # CONFIG_NET_VENDOR_3COM is not set - # CONFIG_NET_VENDOR_ADAPTEC is not set - # CONFIG_NET_VENDOR_AGERE is not set -@@ -2105,11 +2100,11 @@ CONFIG_MDIO=y - # CONFIG_NET_VENDOR_AMD is not set - # CONFIG_NET_VENDOR_ARC is not set - CONFIG_NET_VENDOR_ATHEROS=y --CONFIG_ATL2=y --CONFIG_ATL1=y --CONFIG_ATL1E=y --CONFIG_ATL1C=y --CONFIG_ALX=y -+CONFIG_ATL2=m -+CONFIG_ATL1=m -+CONFIG_ATL1E=m -+CONFIG_ATL1C=m -+CONFIG_ALX=m - # CONFIG_NET_VENDOR_AURORA is not set - # CONFIG_NET_CADENCE is not set - # CONFIG_NET_VENDOR_BROADCOM is not set -@@ -2129,7 +2124,7 @@ CONFIG_ALX=y - CONFIG_NET_VENDOR_FREESCALE=y - CONFIG_FEC=y - CONFIG_FSL_PQ_MDIO=y --CONFIG_FSL_XGMAC_MDIO=y -+# CONFIG_FSL_XGMAC_MDIO is not set - CONFIG_GIANFAR=y - # CONFIG_NET_VENDOR_HISILICON is not set - # CONFIG_NET_VENDOR_HP is not set -@@ -2279,6 +2274,7 @@ CONFIG_USB_NET_KALMIA=m - CONFIG_USB_NET_QMI_WWAN=m - CONFIG_USB_HSO=m - CONFIG_USB_NET_INT51X1=m -+# CONFIG_USB_CDC_PHONET is not set - CONFIG_USB_IPHETH=m - CONFIG_USB_SIERRA_NET=m - CONFIG_USB_VL600=m -@@ -2471,24 +2467,9 @@ CONFIG_RT2X00_LIB_LEDS=y - # CONFIG_RT2X00_DEBUG is not set - CONFIG_WL_MEDIATEK=y - CONFIG_MT7601U=m --CONFIG_RTL_CARDS=m --CONFIG_RTL8192CE=m --CONFIG_RTL8192SE=m --CONFIG_RTL8192DE=m --CONFIG_RTL8723AE=m --CONFIG_RTL8723BE=m --CONFIG_RTL8188EE=m --CONFIG_RTL8192EE=m --CONFIG_RTL8821AE=m -+CONFIG_RTL8XXXU=m -+CONFIG_RTL8XXXU_UNTESTED=y - CONFIG_RTL8192CU=m --CONFIG_RTLWIFI=m --CONFIG_RTLWIFI_PCI=m --CONFIG_RTLWIFI_USB=m --CONFIG_RTLWIFI_DEBUG=y --CONFIG_RTL8192C_COMMON=m --CONFIG_RTL8723_COMMON=m --CONFIG_RTLBTCOEXIST=m --# CONFIG_RTL8XXXU is not set - CONFIG_WL_TI=y - CONFIG_WL1251=m - CONFIG_WL1251_SPI=m -@@ -2619,6 +2600,7 @@ CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768 - CONFIG_INPUT_JOYDEV=m - CONFIG_INPUT_EVDEV=y - CONFIG_INPUT_EVBUG=m -+# CONFIG_INPUT_APMPOWER is not set - - # - # Input Device Drivers -@@ -3007,7 +2989,6 @@ CONFIG_I2C_SLAVE_EEPROM=m - # CONFIG_I2C_DEBUG_ALGO is not set - # CONFIG_I2C_DEBUG_BUS is not set - CONFIG_SPI=y --# CONFIG_SPI_DEBUG is not set - CONFIG_SPI_MASTER=y - - # -@@ -3016,8 +2997,8 @@ CONFIG_SPI_MASTER=y - # CONFIG_SPI_ALTERA is not set - CONFIG_SPI_BITBANG=y - # CONFIG_SPI_CADENCE is not set --CONFIG_SPI_GPIO=y --CONFIG_SPI_IMX=m -+# CONFIG_SPI_GPIO is not set -+CONFIG_SPI_IMX=y - # CONFIG_SPI_FSL_SPI is not set - # CONFIG_SPI_OC_TINY is not set - CONFIG_SPI_ORION=m -@@ -3043,13 +3024,14 @@ CONFIG_SPI_SPIDEV=y - # - CONFIG_PPS=y - # CONFIG_PPS_DEBUG is not set -+CONFIG_NTP_PPS=y - - # - # PPS clients support - # - # CONFIG_PPS_CLIENT_KTIMER is not set --CONFIG_PPS_CLIENT_LDISC=m --CONFIG_PPS_CLIENT_GPIO=m -+CONFIG_PPS_CLIENT_LDISC=y -+CONFIG_PPS_CLIENT_GPIO=y - - # - # PPS generators support -@@ -3060,10 +3042,7 @@ CONFIG_PPS_CLIENT_GPIO=m - # - CONFIG_PTP_1588_CLOCK=y - CONFIG_PTP_1588_CLOCK_GIANFAR=y -- --# --# Enable PHYLIB and NETWORK_PHY_TIMESTAMPING to see the additional clocks. --# -+# CONFIG_DP83640_PHY is not set - CONFIG_PINCTRL=y - - # -@@ -3072,7 +3051,6 @@ CONFIG_PINCTRL=y - CONFIG_PINMUX=y - CONFIG_PINCONF=y - CONFIG_GENERIC_PINCONF=y --# CONFIG_DEBUG_PINCTRL is not set - # CONFIG_PINCTRL_AMD is not set - CONFIG_PINCTRL_SINGLE=y - CONFIG_PINCTRL_IMX=y -@@ -3087,7 +3065,6 @@ CONFIG_GPIOLIB=y - CONFIG_GPIO_DEVRES=y - CONFIG_OF_GPIO=y - CONFIG_GPIOLIB_IRQCHIP=y --# CONFIG_DEBUG_GPIO is not set - CONFIG_GPIO_SYSFS=y - CONFIG_GPIO_GENERIC=y - -@@ -3101,6 +3078,7 @@ CONFIG_GPIO_74XX_MMIO=y - CONFIG_GPIO_GENERIC_PLATFORM=y - # CONFIG_GPIO_GRGPIO is not set - CONFIG_GPIO_MVEBU=y -+CONFIG_GPIO_MVEBU_PWM=y - CONFIG_GPIO_MXC=y - CONFIG_GPIO_SYSCON=y - # CONFIG_GPIO_VX855 is not set -@@ -3181,6 +3159,7 @@ CONFIG_W1_SLAVE_BQ27000=m - CONFIG_POWER_SUPPLY=y - # CONFIG_POWER_SUPPLY_DEBUG is not set - # CONFIG_PDA_POWER is not set -+# CONFIG_APM_POWER is not set - # CONFIG_GENERIC_ADC_BATTERY is not set - CONFIG_TEST_POWER=m - # CONFIG_BATTERY_88PM860X is not set -@@ -4830,7 +4809,7 @@ CONFIG_USB_XHCI_MVEBU=y - CONFIG_USB_EHCI_HCD=y - CONFIG_USB_EHCI_ROOT_HUB_TT=y - CONFIG_USB_EHCI_TT_NEWSCHED=y --CONFIG_USB_FSL_MPH_DR_OF=m -+CONFIG_USB_FSL_MPH_DR_OF=y - CONFIG_USB_EHCI_PCI=y - CONFIG_USB_EHCI_MXC=y - CONFIG_USB_EHCI_HCD_ORION=y -@@ -5044,7 +5023,6 @@ CONFIG_USB_ISP1301=y - CONFIG_USB_MXS_PHY=y - # CONFIG_USB_ULPI is not set - CONFIG_USB_GADGET=y --# CONFIG_USB_GADGET_DEBUG is not set - # CONFIG_USB_GADGET_DEBUG_FILES is not set - # CONFIG_USB_GADGET_DEBUG_FS is not set - CONFIG_USB_GADGET_VBUS_DRAW=2 -@@ -5053,7 +5031,7 @@ CONFIG_USB_GADGET_STORAGE_NUM_BUFFERS=2 - # - # USB Peripheral Controller - # --CONFIG_USB_FSL_USB2=m -+CONFIG_USB_FSL_USB2=y - # CONFIG_USB_FUSB300 is not set - # CONFIG_USB_FOTG210_UDC is not set - # CONFIG_USB_GR_UDC is not set -@@ -5099,6 +5077,7 @@ CONFIG_USB_CONFIGFS_ECM=y - CONFIG_USB_CONFIGFS_ECM_SUBSET=y - CONFIG_USB_CONFIGFS_RNDIS=y - CONFIG_USB_CONFIGFS_EEM=y -+# CONFIG_USB_CONFIGFS_PHONET is not set - CONFIG_USB_CONFIGFS_MASS_STORAGE=y - CONFIG_USB_CONFIGFS_F_LB_SS=y - CONFIG_USB_CONFIGFS_F_FS=y -@@ -5126,6 +5105,7 @@ CONFIG_USB_G_SERIAL=m - CONFIG_USB_MIDI_GADGET=m - CONFIG_USB_G_PRINTER=m - CONFIG_USB_CDC_COMPOSITE=m -+# CONFIG_USB_G_NOKIA is not set - CONFIG_USB_G_ACM_MS=m - CONFIG_USB_G_MULTI=m - CONFIG_USB_G_MULTI_RNDIS=y -@@ -5531,11 +5511,14 @@ CONFIG_DVB_MN88473=m - CONFIG_LIRC_STAGING=y - CONFIG_LIRC_BT829=m - CONFIG_LIRC_IMON=m -+CONFIG_LIRC_HB=m -+CONFIG_LIRC_XBOX=m - CONFIG_LIRC_SASEM=m - CONFIG_LIRC_SERIAL=m - CONFIG_LIRC_SERIAL_TRANSMITTER=y - CONFIG_LIRC_SIR=m - CONFIG_LIRC_ZILOG=m -+CONFIG_LIRC_ATIUSB=m - - # - # Android -@@ -6177,7 +6160,6 @@ CONFIG_NFSD_V3=y - CONFIG_NFSD_V3_ACL=y - CONFIG_NFSD_V4=y - # CONFIG_NFSD_PNFS is not set --# CONFIG_NFSD_FAULT_INJECTION is not set - CONFIG_GRACE_PERIOD=y - CONFIG_LOCKD=y - CONFIG_LOCKD_V4=y -@@ -6274,83 +6256,47 @@ CONFIG_DLM=m - # - CONFIG_PRINTK_TIME=y - CONFIG_MESSAGE_LOGLEVEL_DEFAULT=4 --# CONFIG_BOOT_PRINTK_DELAY is not set - CONFIG_DYNAMIC_DEBUG=y - - # - # Compile-time checks and compiler options - # --# CONFIG_DEBUG_INFO is not set - CONFIG_ENABLE_WARN_DEPRECATED=y - CONFIG_ENABLE_MUST_CHECK=y - CONFIG_FRAME_WARN=1024 - CONFIG_STRIP_ASM_SYMS=y --# CONFIG_READABLE_ASM is not set - # CONFIG_UNUSED_SYMBOLS is not set --# CONFIG_PAGE_OWNER is not set - CONFIG_DEBUG_FS=y - # CONFIG_HEADERS_CHECK is not set - # CONFIG_DEBUG_SECTION_MISMATCH is not set - CONFIG_SECTION_MISMATCH_WARN_ONLY=y - CONFIG_FRAME_POINTER=y --# CONFIG_DEBUG_FORCE_WEAK_PER_CPU is not set - CONFIG_MAGIC_SYSRQ=y - CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE=0x1 --CONFIG_DEBUG_KERNEL=y -+# CONFIG_DEBUG_KERNEL is not set - - # - # Memory Debugging - # - # CONFIG_PAGE_EXTENSION is not set --# CONFIG_DEBUG_PAGEALLOC is not set --# CONFIG_DEBUG_OBJECTS is not set - # CONFIG_SLUB_STATS is not set - CONFIG_HAVE_DEBUG_KMEMLEAK=y --# CONFIG_DEBUG_KMEMLEAK is not set --# CONFIG_DEBUG_STACK_USAGE is not set --# CONFIG_DEBUG_VM is not set - # CONFIG_DEBUG_MEMORY_INIT is not set --# CONFIG_DEBUG_PER_CPU_MAPS is not set --# CONFIG_DEBUG_HIGHMEM is not set --# CONFIG_DEBUG_SHIRQ is not set - - # - # Debug Lockups and Hangs - # --# CONFIG_LOCKUP_DETECTOR is not set --# CONFIG_DETECT_HUNG_TASK is not set - CONFIG_PANIC_ON_OOPS=y - CONFIG_PANIC_ON_OOPS_VALUE=1 - CONFIG_PANIC_TIMEOUT=1 --# CONFIG_SCHED_DEBUG is not set - # CONFIG_SCHED_INFO is not set --# CONFIG_SCHEDSTATS is not set --# CONFIG_SCHED_STACK_END_CHECK is not set - # CONFIG_DEBUG_TIMEKEEPING is not set --CONFIG_TIMER_STATS=y --# CONFIG_DEBUG_PREEMPT is not set - - # - # Lock Debugging (spinlocks, mutexes, etc...) - # --# CONFIG_DEBUG_RT_MUTEXES is not set --# CONFIG_DEBUG_SPINLOCK is not set --# CONFIG_DEBUG_MUTEXES is not set --# CONFIG_DEBUG_WW_MUTEX_SLOWPATH is not set --# CONFIG_DEBUG_LOCK_ALLOC is not set --# CONFIG_PROVE_LOCKING is not set --# CONFIG_LOCK_STAT is not set --# CONFIG_DEBUG_ATOMIC_SLEEP is not set --# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set --# CONFIG_LOCK_TORTURE_TEST is not set - CONFIG_STACKTRACE=y --# CONFIG_DEBUG_KOBJECT is not set --# CONFIG_DEBUG_BUGVERBOSE is not set --# CONFIG_DEBUG_LIST is not set --# CONFIG_DEBUG_PI_LIST is not set --# CONFIG_DEBUG_SG is not set --# CONFIG_DEBUG_NOTIFIERS is not set --# CONFIG_DEBUG_CREDENTIALS is not set -+CONFIG_DEBUG_BUGVERBOSE=y - - # - # RCU Debugging -@@ -6358,13 +6304,7 @@ CONFIG_STACKTRACE=y - # CONFIG_PROVE_RCU is not set - # CONFIG_SPARSE_RCU_POINTER is not set - # CONFIG_TORTURE_TEST is not set --# CONFIG_RCU_TORTURE_TEST is not set - CONFIG_RCU_CPU_STALL_TIMEOUT=21 --# CONFIG_RCU_TRACE is not set --# CONFIG_RCU_EQS_DEBUG is not set --# CONFIG_DEBUG_BLOCK_EXT_DEVT is not set --# CONFIG_NOTIFIER_ERROR_INJECTION is not set --# CONFIG_FAULT_INJECTION is not set - CONFIG_NOP_TRACER=y - CONFIG_HAVE_FUNCTION_TRACER=y - CONFIG_HAVE_FUNCTION_GRAPH_TRACER=y -@@ -6409,11 +6349,6 @@ CONFIG_FTRACE_MCOUNT_RECORD=y - # Runtime Testing - # - # CONFIG_LKDTM is not set --# CONFIG_TEST_LIST_SORT is not set --# CONFIG_BACKTRACE_SELF_TEST is not set --# CONFIG_RBTREE_TEST is not set --# CONFIG_INTERVAL_TREE_TEST is not set --# CONFIG_PERCPU_TEST is not set - # CONFIG_ATOMIC64_SELFTEST is not set - # CONFIG_ASYNC_RAID6_TEST is not set - # CONFIG_TEST_HEXDUMP is not set -@@ -6431,17 +6366,13 @@ CONFIG_FTRACE_MCOUNT_RECORD=y - # CONFIG_TEST_STATIC_KEYS is not set - # CONFIG_SAMPLES is not set - CONFIG_HAVE_ARCH_KGDB=y --# CONFIG_KGDB is not set --# CONFIG_ARM_PTDUMP is not set - # CONFIG_STRICT_DEVMEM is not set - CONFIG_ARM_UNWIND=y - CONFIG_OLD_MCOUNT=y - # CONFIG_DEBUG_USER is not set --# CONFIG_DEBUG_LL is not set - CONFIG_DEBUG_IMX_UART_PORT=1 - CONFIG_DEBUG_LL_INCLUDE="mach/debug-macro.S" - # CONFIG_DEBUG_UART_8250 is not set --# CONFIG_DEBUG_UART_BCM63XX is not set - CONFIG_UNCOMPRESS_INCLUDE="debug/uncompress.h" - # CONFIG_PID_IN_CONTEXTIDR is not set - # CONFIG_DEBUG_SET_MODULE_RONX is not set -diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S -index d66b1ae..d044cea 100644 ---- a/arch/arm/kernel/entry-armv.S -+++ b/arch/arm/kernel/entry-armv.S -@@ -244,7 +244,11 @@ svc_preempt: - bne 1b - tst r0, #_TIF_NEED_RESCHED_LAZY - reteq r8 @ go again -- b 1b -+ ldr r0, [tsk, #TI_PREEMPT_LAZY] @ get preempt lazy count -+ teq r0, #0 @ if preempt lazy count != 0 -+ beq 1b -+ ret r8 @ go again -+ - #endif - - __und_fault: -diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c -index ef9119f..4d93758 100644 ---- a/arch/arm/kernel/ptrace.c -+++ b/arch/arm/kernel/ptrace.c -@@ -733,8 +733,8 @@ static int vfp_set(struct task_struct *target, - if (ret) - return ret; - -- vfp_flush_hwstate(thread); - thread->vfpstate.hard = new_vfp; -+ vfp_flush_hwstate(thread); - - return 0; - } -diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c -index 4f5c42a..bb43bc3 100644 ---- a/arch/arm/kvm/arm.c -+++ b/arch/arm/kvm/arm.c -@@ -498,16 +498,16 @@ static void kvm_arm_resume_guest(struct kvm *kvm) - struct kvm_vcpu *vcpu; - - kvm_for_each_vcpu(i, vcpu, kvm) { -- struct swait_head *wq = kvm_arch_vcpu_wq(vcpu); -+ struct swait_queue_head *wq = kvm_arch_vcpu_wq(vcpu); - - vcpu->arch.pause = false; -- swait_wake_interruptible(wq); -+ swake_up(wq); - } - } - - static void vcpu_sleep(struct kvm_vcpu *vcpu) - { -- struct swait_head *wq = kvm_arch_vcpu_wq(vcpu); -+ struct swait_queue_head *wq = kvm_arch_vcpu_wq(vcpu); - - swait_event_interruptible(*wq, ((!vcpu->arch.power_off) && - (!vcpu->arch.pause))); -@@ -568,7 +568,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run) - * involves poking the GIC, which must be done in a - * non-preemptible context. - */ -- preempt_disable(); -+ migrate_disable(); - kvm_timer_flush_hwstate(vcpu); - kvm_vgic_flush_hwstate(vcpu); - -@@ -587,7 +587,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run) - local_irq_enable(); - kvm_timer_sync_hwstate(vcpu); - kvm_vgic_sync_hwstate(vcpu); -- preempt_enable(); -+ migrate_enable(); - continue; - } - -@@ -641,7 +641,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run) - - kvm_vgic_sync_hwstate(vcpu); - -- preempt_enable(); -+ migrate_enable(); - - ret = handle_exit(vcpu, run, ret); - } -diff --git a/arch/arm/kvm/mmu.c b/arch/arm/kvm/mmu.c -index 61d96a6..12d727f 100644 ---- a/arch/arm/kvm/mmu.c -+++ b/arch/arm/kvm/mmu.c -@@ -886,11 +886,14 @@ static int stage2_set_pmd_huge(struct kvm *kvm, struct kvm_mmu_memory_cache - VM_BUG_ON(pmd_present(*pmd) && pmd_pfn(*pmd) != pmd_pfn(*new_pmd)); - - old_pmd = *pmd; -- kvm_set_pmd(pmd, *new_pmd); -- if (pmd_present(old_pmd)) -+ if (pmd_present(old_pmd)) { -+ pmd_clear(pmd); - kvm_tlb_flush_vmid_ipa(kvm, addr); -- else -+ } else { - get_page(virt_to_page(pmd)); -+ } -+ -+ kvm_set_pmd(pmd, *new_pmd); - return 0; - } - -@@ -939,12 +942,14 @@ static int stage2_set_pte(struct kvm *kvm, struct kvm_mmu_memory_cache *cache, - - /* Create 2nd stage page table mapping - Level 3 */ - old_pte = *pte; -- kvm_set_pte(pte, *new_pte); -- if (pte_present(old_pte)) -+ if (pte_present(old_pte)) { -+ kvm_set_pte(pte, __pte(0)); - kvm_tlb_flush_vmid_ipa(kvm, addr); -- else -+ } else { - get_page(virt_to_page(pte)); -+ } - -+ kvm_set_pte(pte, *new_pte); - return 0; - } - -diff --git a/arch/arm/kvm/psci.c b/arch/arm/kvm/psci.c -index 08148c4..c2b1315 100644 ---- a/arch/arm/kvm/psci.c -+++ b/arch/arm/kvm/psci.c -@@ -70,7 +70,7 @@ static unsigned long kvm_psci_vcpu_on(struct kvm_vcpu *source_vcpu) - { - struct kvm *kvm = source_vcpu->kvm; - struct kvm_vcpu *vcpu = NULL; -- struct swait_head *wq; -+ struct swait_queue_head *wq; - unsigned long cpu_id; - unsigned long context_id; - phys_addr_t target_pc; -@@ -119,7 +119,7 @@ static unsigned long kvm_psci_vcpu_on(struct kvm_vcpu *source_vcpu) - smp_mb(); /* Make sure the above is visible */ - - wq = kvm_arch_vcpu_wq(vcpu); -- swait_wake_interruptible(wq); -+ swake_up(wq); - - return PSCI_RET_SUCCESS; - } -diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig -index 28656c2..3f50130 100644 ---- a/arch/arm/mach-at91/Kconfig -+++ b/arch/arm/mach-at91/Kconfig -@@ -99,6 +99,7 @@ config HAVE_AT91_USB_CLK - config COMMON_CLK_AT91 - bool - select COMMON_CLK -+ select MFD_SYSCON - - config HAVE_AT91_SMD - bool -diff --git a/arch/arm/mach-at91/at91rm9200.c b/arch/arm/mach-at91/at91rm9200.c -index c1a7c6c..63b4fa2 100644 ---- a/arch/arm/mach-at91/at91rm9200.c -+++ b/arch/arm/mach-at91/at91rm9200.c -@@ -12,7 +12,6 @@ - #include - - #include --#include - - #include "generic.h" - #include "soc.h" -@@ -33,7 +32,6 @@ static void __init at91rm9200_dt_device_init(void) - - of_platform_populate(NULL, of_default_bus_match_table, NULL, soc_dev); - -- arm_pm_idle = at91rm9200_idle; - at91rm9200_pm_init(); - } - -diff --git a/arch/arm/mach-at91/at91sam9.c b/arch/arm/mach-at91/at91sam9.c -index 7eb64f7..cada2a6 100644 ---- a/arch/arm/mach-at91/at91sam9.c -+++ b/arch/arm/mach-at91/at91sam9.c -@@ -62,8 +62,6 @@ static void __init at91sam9_common_init(void) - soc_dev = soc_device_to_device(soc); - - of_platform_populate(NULL, of_default_bus_match_table, NULL, soc_dev); -- -- arm_pm_idle = at91sam9_idle; - } - - static void __init at91sam9_dt_device_init(void) -diff --git a/arch/arm/mach-at91/generic.h b/arch/arm/mach-at91/generic.h -index b0fa7dc..28ca57a 100644 ---- a/arch/arm/mach-at91/generic.h -+++ b/arch/arm/mach-at91/generic.h -@@ -11,27 +11,18 @@ - #ifndef _AT91_GENERIC_H - #define _AT91_GENERIC_H - --#include --#include -- -- /* Map io */ --extern void __init at91_map_io(void); --extern void __init at91_alt_map_io(void); -- --/* idle */ --extern void at91rm9200_idle(void); --extern void at91sam9_idle(void); -- - #ifdef CONFIG_PM - extern void __init at91rm9200_pm_init(void); - extern void __init at91sam9260_pm_init(void); - extern void __init at91sam9g45_pm_init(void); - extern void __init at91sam9x5_pm_init(void); -+extern void __init sama5_pm_init(void); - #else - static inline void __init at91rm9200_pm_init(void) { } - static inline void __init at91sam9260_pm_init(void) { } - static inline void __init at91sam9g45_pm_init(void) { } - static inline void __init at91sam9x5_pm_init(void) { } -+static inline void __init sama5_pm_init(void) { } - #endif - - #endif /* _AT91_GENERIC_H */ -diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c -index 23726fb..f062701 100644 ---- a/arch/arm/mach-at91/pm.c -+++ b/arch/arm/mach-at91/pm.c -@@ -31,10 +31,13 @@ - #include - #include - #include -+#include - - #include "generic.h" - #include "pm.h" - -+static void __iomem *pmc; -+ - /* - * FIXME: this is needed to communicate between the pinctrl driver and - * the PM implementation in the machine. Possibly part of the PM -@@ -87,7 +90,7 @@ static int at91_pm_verify_clocks(void) - unsigned long scsr; - int i; - -- scsr = at91_pmc_read(AT91_PMC_SCSR); -+ scsr = readl(pmc + AT91_PMC_SCSR); - - /* USB must not be using PLLB */ - if ((scsr & at91_pm_data.uhp_udp_mask) != 0) { -@@ -101,8 +104,7 @@ static int at91_pm_verify_clocks(void) - - if ((scsr & (AT91_PMC_PCK0 << i)) == 0) - continue; -- -- css = at91_pmc_read(AT91_PMC_PCKR(i)) & AT91_PMC_CSS; -+ css = readl(pmc + AT91_PMC_PCKR(i)) & AT91_PMC_CSS; - if (css != AT91_PMC_CSS_SLOW) { - pr_err("AT91: PM - Suspend-to-RAM with PCK%d src %d\n", i, css); - return 0; -@@ -145,8 +147,8 @@ static void at91_pm_suspend(suspend_state_t state) - flush_cache_all(); - outer_disable(); - -- at91_suspend_sram_fn(at91_pmc_base, at91_ramc_base[0], -- at91_ramc_base[1], pm_data); -+ at91_suspend_sram_fn(pmc, at91_ramc_base[0], -+ at91_ramc_base[1], pm_data); - - outer_resume(); - } -@@ -353,6 +355,21 @@ static __init void at91_dt_ramc(void) - at91_pm_set_standby(standby); - } - -+void at91rm9200_idle(void) -+{ -+ /* -+ * Disable the processor clock. The processor will be automatically -+ * re-enabled by an interrupt or by a reset. -+ */ -+ writel(AT91_PMC_PCK, pmc + AT91_PMC_SCDR); -+} -+ -+void at91sam9_idle(void) -+{ -+ writel(AT91_PMC_PCK, pmc + AT91_PMC_SCDR); -+ cpu_do_idle(); -+} -+ - static void __init at91_pm_sram_init(void) - { - struct gen_pool *sram_pool; -@@ -399,13 +416,36 @@ static void __init at91_pm_sram_init(void) - &at91_pm_suspend_in_sram, at91_pm_suspend_in_sram_sz); - } - --static void __init at91_pm_init(void) -+static const struct of_device_id atmel_pmc_ids[] __initconst = { -+ { .compatible = "atmel,at91rm9200-pmc" }, -+ { .compatible = "atmel,at91sam9260-pmc" }, -+ { .compatible = "atmel,at91sam9g45-pmc" }, -+ { .compatible = "atmel,at91sam9n12-pmc" }, -+ { .compatible = "atmel,at91sam9x5-pmc" }, -+ { .compatible = "atmel,sama5d3-pmc" }, -+ { .compatible = "atmel,sama5d2-pmc" }, -+ { /* sentinel */ }, -+}; -+ -+static void __init at91_pm_init(void (*pm_idle)(void)) - { -- at91_pm_sram_init(); -+ struct device_node *pmc_np; - - if (at91_cpuidle_device.dev.platform_data) - platform_device_register(&at91_cpuidle_device); - -+ pmc_np = of_find_matching_node(NULL, atmel_pmc_ids); -+ pmc = of_iomap(pmc_np, 0); -+ if (!pmc) { -+ pr_err("AT91: PM not supported, PMC not found\n"); -+ return; -+ } -+ -+ if (pm_idle) -+ arm_pm_idle = pm_idle; -+ -+ at91_pm_sram_init(); -+ - if (at91_suspend_sram_fn) - suspend_set_ops(&at91_pm_ops); - else -@@ -424,7 +464,7 @@ void __init at91rm9200_pm_init(void) - at91_pm_data.uhp_udp_mask = AT91RM9200_PMC_UHP | AT91RM9200_PMC_UDP; - at91_pm_data.memctrl = AT91_MEMCTRL_MC; - -- at91_pm_init(); -+ at91_pm_init(at91rm9200_idle); - } - - void __init at91sam9260_pm_init(void) -@@ -432,7 +472,7 @@ void __init at91sam9260_pm_init(void) - at91_dt_ramc(); - at91_pm_data.memctrl = AT91_MEMCTRL_SDRAMC; - at91_pm_data.uhp_udp_mask = AT91SAM926x_PMC_UHP | AT91SAM926x_PMC_UDP; -- return at91_pm_init(); -+ at91_pm_init(at91sam9_idle); - } - - void __init at91sam9g45_pm_init(void) -@@ -440,7 +480,7 @@ void __init at91sam9g45_pm_init(void) - at91_dt_ramc(); - at91_pm_data.uhp_udp_mask = AT91SAM926x_PMC_UHP; - at91_pm_data.memctrl = AT91_MEMCTRL_DDRSDR; -- return at91_pm_init(); -+ at91_pm_init(at91sam9_idle); - } - - void __init at91sam9x5_pm_init(void) -@@ -448,5 +488,13 @@ void __init at91sam9x5_pm_init(void) - at91_dt_ramc(); - at91_pm_data.uhp_udp_mask = AT91SAM926x_PMC_UHP | AT91SAM926x_PMC_UDP; - at91_pm_data.memctrl = AT91_MEMCTRL_DDRSDR; -- return at91_pm_init(); -+ at91_pm_init(at91sam9_idle); -+} -+ -+void __init sama5_pm_init(void) -+{ -+ at91_dt_ramc(); -+ at91_pm_data.uhp_udp_mask = AT91SAM926x_PMC_UHP | AT91SAM926x_PMC_UDP; -+ at91_pm_data.memctrl = AT91_MEMCTRL_DDRSDR; -+ at91_pm_init(NULL); - } -diff --git a/arch/arm/mach-at91/sama5.c b/arch/arm/mach-at91/sama5.c -index d9cf679..df8fdf1 100644 ---- a/arch/arm/mach-at91/sama5.c -+++ b/arch/arm/mach-at91/sama5.c -@@ -51,7 +51,7 @@ static void __init sama5_dt_device_init(void) - soc_dev = soc_device_to_device(soc); - - of_platform_populate(NULL, of_default_bus_match_table, NULL, soc_dev); -- at91sam9x5_pm_init(); -+ sama5_pm_init(); - } - - static const char *const sama5_dt_board_compat[] __initconst = { -diff --git a/arch/arm/mach-cns3xxx/pcie.c b/arch/arm/mach-cns3xxx/pcie.c -index 47905a5..318394e 100644 ---- a/arch/arm/mach-cns3xxx/pcie.c -+++ b/arch/arm/mach-cns3xxx/pcie.c -@@ -220,13 +220,13 @@ static void cns3xxx_write_config(struct cns3xxx_pcie *cnspci, - u32 mask = (0x1ull << (size * 8)) - 1; - int shift = (where % 4) * 8; - -- v = readl_relaxed(base + (where & 0xffc)); -+ v = readl_relaxed(base); - - v &= ~(mask << shift); - v |= (val & mask) << shift; - -- writel_relaxed(v, base + (where & 0xffc)); -- readl_relaxed(base + (where & 0xffc)); -+ writel_relaxed(v, base); -+ readl_relaxed(base); - } - - static void __init cns3xxx_pcie_hw_init(struct cns3xxx_pcie *cnspci) -diff --git a/arch/arm/mach-exynos/Kconfig b/arch/arm/mach-exynos/Kconfig -index 3a10f1a..bfd8bb3 100644 ---- a/arch/arm/mach-exynos/Kconfig -+++ b/arch/arm/mach-exynos/Kconfig -@@ -26,6 +26,7 @@ menuconfig ARCH_EXYNOS - select S5P_DEV_MFC - select SRAM - select THERMAL -+ select THERMAL_OF - select MFD_SYSCON - help - Support for SAMSUNG EXYNOS SoCs (EXYNOS4/5) -diff --git a/arch/arm/mach-exynos/pm_domains.c b/arch/arm/mach-exynos/pm_domains.c -index 7c21760..875a2ba 100644 ---- a/arch/arm/mach-exynos/pm_domains.c -+++ b/arch/arm/mach-exynos/pm_domains.c -@@ -92,7 +92,7 @@ static int exynos_pd_power(struct generic_pm_domain *domain, bool power_on) - if (IS_ERR(pd->clk[i])) - break; - -- if (IS_ERR(pd->clk[i])) -+ if (IS_ERR(pd->pclk[i])) - continue; /* Skip on first power up */ - if (clk_set_parent(pd->clk[i], pd->pclk[i])) - pr_err("%s: error setting parent to clock%d\n", -diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig -index 8bee527..dfcadee 100644 ---- a/arch/arm/mach-imx/Kconfig -+++ b/arch/arm/mach-imx/Kconfig -@@ -8,7 +8,6 @@ menuconfig ARCH_MXC - select PM_OPP if PM - select SOC_BUS - select SRAM -- select ZONE_DMA - help - Support for Freescale MXC/iMX-based family of processors - -@@ -526,7 +525,7 @@ config SOC_IMX6Q - bool "i.MX6 Quad/DualLite support" - select ARM_ERRATA_764369 if SMP - select HAVE_ARM_SCU if SMP -- select HAVE_ARM_TWD if SMP -+ select HAVE_ARM_TWD - select PCI_DOMAINS if PCI - select PINCTRL_IMX6Q - select SOC_IMX6 -diff --git a/arch/arm/mach-imx/common.h b/arch/arm/mach-imx/common.h -index 75d2a4f..396b9fa 100644 ---- a/arch/arm/mach-imx/common.h -+++ b/arch/arm/mach-imx/common.h -@@ -112,6 +112,7 @@ void imx_anatop_post_resume(void); - int imx6_set_lpm(enum mxc_cpu_pwr_mode mode); - void imx6q_set_int_mem_clk_lpm(bool enable); - void imx6sl_set_wait_clk(bool enter); -+void imx6_enet_mac_init(const char *enet_compat, const char *ocotp_compat); - int imx_mmdc_get_ddr_type(void); - - void imx_cpu_die(unsigned int cpu); -diff --git a/arch/arm/mach-imx/gpc.c b/arch/arm/mach-imx/gpc.c -index ae14184..3cb7c48 100644 ---- a/arch/arm/mach-imx/gpc.c -+++ b/arch/arm/mach-imx/gpc.c -@@ -35,6 +35,10 @@ - #define GPC_PGC_CPU_PDNSCR 0x2a8 - #define GPC_PGC_SW2ISO_SHIFT 0x8 - #define GPC_PGC_SW_SHIFT 0x0 -+#define GPC_PGC_DISP_PGCR_OFFSET 0x240 -+#define GPC_PGC_DISP_PUPSCR_OFFSET 0x244 -+#define GPC_PGC_DISP_PDNSCR_OFFSET 0x248 -+#define GPC_PGC_DISP_SR_OFFSET 0x24c - - #define IMR_NUM 4 - #define GPC_MAX_IRQS (IMR_NUM * 32) -@@ -43,6 +47,8 @@ - #define GPU_VPU_PDN_REQ BIT(0) - - #define GPC_CLK_MAX 10 -+#define DEFAULT_IPG_RATE 66000000 -+#define GPC_PU_UP_DELAY_MARGIN 2 - - struct pu_domain { - struct generic_pm_domain base; -@@ -51,9 +57,16 @@ struct pu_domain { - int num_clks; - }; - -+struct disp_domain { -+ struct generic_pm_domain base; -+ struct clk *clk[GPC_CLK_MAX]; -+ int num_clks; -+}; -+ - static void __iomem *gpc_base; - static u32 gpc_wake_irqs[IMR_NUM]; - static u32 gpc_saved_imrs[IMR_NUM]; -+static struct clk *ipg; - - void imx_gpc_set_arm_power_up_timing(u32 sw2iso, u32 sw) - { -@@ -365,6 +378,67 @@ static int imx6q_pm_pu_power_on(struct generic_pm_domain *genpd) - return 0; - } - -+static int imx_pm_dispmix_on(struct generic_pm_domain *genpd) -+{ -+ struct disp_domain *disp = container_of(genpd, struct disp_domain, base); -+ u32 val = readl_relaxed(gpc_base + GPC_CNTR); -+ int i; -+ u32 ipg_rate = clk_get_rate(ipg); -+ -+ if ((cpu_is_imx6sl() && -+ imx_get_soc_revision() >= IMX_CHIP_REVISION_1_2) || cpu_is_imx6sx()) { -+ -+ /* Enable reset clocks for all devices in the disp domain */ -+ for (i = 0; i < disp->num_clks; i++) -+ clk_prepare_enable(disp->clk[i]); -+ -+ writel_relaxed(0x0, gpc_base + GPC_PGC_DISP_PGCR_OFFSET); -+ writel_relaxed(0x20 | val, gpc_base + GPC_CNTR); -+ while (readl_relaxed(gpc_base + GPC_CNTR) & 0x20) -+ ; -+ -+ writel_relaxed(0x1, gpc_base + GPC_PGC_DISP_SR_OFFSET); -+ -+ /* Wait power switch done */ -+ udelay(2 * DEFAULT_IPG_RATE / ipg_rate + -+ GPC_PU_UP_DELAY_MARGIN); -+ -+ /* Disable reset clocks for all devices in the disp domain */ -+ for (i = 0; i < disp->num_clks; i++) -+ clk_disable_unprepare(disp->clk[i]); -+ } -+ return 0; -+} -+ -+static int imx_pm_dispmix_off(struct generic_pm_domain *genpd) -+{ -+ struct disp_domain *disp = container_of(genpd, struct disp_domain, base); -+ u32 val = readl_relaxed(gpc_base + GPC_CNTR); -+ int i; -+ -+ if ((cpu_is_imx6sl() && -+ imx_get_soc_revision() >= IMX_CHIP_REVISION_1_2) || cpu_is_imx6sx()) { -+ -+ /* Enable reset clocks for all devices in the disp domain */ -+ for (i = 0; i < disp->num_clks; i++) -+ clk_prepare_enable(disp->clk[i]); -+ -+ writel_relaxed(0xFFFFFFFF, -+ gpc_base + GPC_PGC_DISP_PUPSCR_OFFSET); -+ writel_relaxed(0xFFFFFFFF, -+ gpc_base + GPC_PGC_DISP_PDNSCR_OFFSET); -+ writel_relaxed(0x1, gpc_base + GPC_PGC_DISP_PGCR_OFFSET); -+ writel_relaxed(0x10 | val, gpc_base + GPC_CNTR); -+ while (readl_relaxed(gpc_base + GPC_CNTR) & 0x10) -+ ; -+ -+ /* Disable reset clocks for all devices in the disp domain */ -+ for (i = 0; i < disp->num_clks; i++) -+ clk_disable_unprepare(disp->clk[i]); -+ } -+ return 0; -+} -+ - static struct generic_pm_domain imx6q_arm_domain = { - .name = "ARM", - }; -@@ -379,14 +453,18 @@ static struct pu_domain imx6q_pu_domain = { - }, - }; - --static struct generic_pm_domain imx6sl_display_domain = { -- .name = "DISPLAY", -+static struct disp_domain imx6s_display_domain = { -+ .base = { -+ .name = "DISPLAY", -+ .power_off = imx_pm_dispmix_off, -+ .power_on = imx_pm_dispmix_on, -+ }, - }; - - static struct generic_pm_domain *imx_gpc_domains[] = { - &imx6q_arm_domain, - &imx6q_pu_domain.base, -- &imx6sl_display_domain, -+ &imx6s_display_domain.base, - }; - - static struct genpd_onecell_data imx_gpc_onecell_data = { -@@ -397,42 +475,68 @@ static struct genpd_onecell_data imx_gpc_onecell_data = { - static int imx_gpc_genpd_init(struct device *dev, struct regulator *pu_reg) - { - struct clk *clk; -- int i; -+ bool is_off; -+ int pu_clks, disp_clks, ipg_clks = 1; -+ int i = 0, k = 0; - - imx6q_pu_domain.reg = pu_reg; - -- for (i = 0; ; i++) { -+ if ((cpu_is_imx6sl() && -+ imx_get_soc_revision() >= IMX_CHIP_REVISION_1_2)) { -+ pu_clks = 2 ; -+ disp_clks = 5; -+ } else if (cpu_is_imx6sx()) { -+ pu_clks = 1; -+ disp_clks = 7; -+ } else { -+ pu_clks = 6; -+ disp_clks = 0; -+ } -+ -+ /* Get pu domain clks */ -+ for (i = 0; i < pu_clks ; i++) { - clk = of_clk_get(dev->of_node, i); - if (IS_ERR(clk)) - break; -- if (i >= GPC_CLK_MAX) { -- dev_err(dev, "more than %d clocks\n", GPC_CLK_MAX); -- goto clk_err; -- } - imx6q_pu_domain.clk[i] = clk; - } - imx6q_pu_domain.num_clks = i; - -- /* Enable power always in case bootloader disabled it. */ -- imx6q_pm_pu_power_on(&imx6q_pu_domain.base); -+ ipg = of_clk_get(dev->of_node, pu_clks); - -- if (!IS_ENABLED(CONFIG_PM_GENERIC_DOMAINS)) -- return 0; -+ /* Get disp domain clks */ -+ for (k = 0, i = pu_clks + ipg_clks; i < pu_clks + ipg_clks + disp_clks; -+ i++, k++) { -+ clk = of_clk_get(dev->of_node, i); -+ if (IS_ERR(clk)) -+ break; -+ imx6s_display_domain.clk[k] = clk; -+ } -+ imx6s_display_domain.num_clks = k; -+ -+ is_off = IS_ENABLED(CONFIG_PM); -+ if (is_off) { -+ _imx6q_pm_pu_power_off(&imx6q_pu_domain.base); -+ } else { -+ /* -+ * Enable power if compiled without CONFIG_PM in case the -+ * bootloader disabled it. -+ */ -+ imx6q_pm_pu_power_on(&imx6q_pu_domain.base); -+ } -+ -+ pm_genpd_init(&imx6q_pu_domain.base, NULL, is_off); -+ pm_genpd_init(&imx6s_display_domain.base, NULL, is_off); - -- pm_genpd_init(&imx6q_pu_domain.base, NULL, false); - return of_genpd_add_provider_onecell(dev->of_node, - &imx_gpc_onecell_data); -- --clk_err: -- while (i--) -- clk_put(imx6q_pu_domain.clk[i]); -- return -EINVAL; - } - - static int imx_gpc_probe(struct platform_device *pdev) - { - struct regulator *pu_reg; - int ret; -+ u32 bypass = 0; - - /* bail out if DT too old and doesn't provide the necessary info */ - if (!of_property_read_bool(pdev->dev.of_node, "#power-domain-cells")) -@@ -447,6 +551,11 @@ static int imx_gpc_probe(struct platform_device *pdev) - return ret; - } - -+ of_property_read_u32(pdev->dev.of_node, "fsl,ldo-bypass", &bypass); -+ /* We only bypass pu since arm and soc has been set in u-boot */ -+ if (pu_reg && bypass) -+ regulator_allow_bypass(pu_reg, true); -+ - return imx_gpc_genpd_init(&pdev->dev, pu_reg); - } - -diff --git a/arch/arm/mach-imx/mach-imx6q.c b/arch/arm/mach-imx/mach-imx6q.c -index 8766316..945072f 100644 ---- a/arch/arm/mach-imx/mach-imx6q.c -+++ b/arch/arm/mach-imx/mach-imx6q.c -@@ -1,5 +1,5 @@ - /* -- * Copyright 2011-2013 Freescale Semiconductor, Inc. -+ * Copyright 2011-2015 Freescale Semiconductor, Inc. - * Copyright 2011 Linaro Ltd. - * - * The code contained herein is licensed under the GNU General Public -@@ -31,6 +31,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -125,6 +126,10 @@ static int ar8031_phy_fixup(struct phy_device *dev) - { - u16 val; - -+ /* Set RGMII IO voltage to 1.8V */ -+ phy_write(dev, 0x1d, 0x1f); -+ phy_write(dev, 0x1e, 0x8); -+ - /* disable phy AR8031 SmartEEE function. */ - phy_write(dev, 0xd, 0x3); - phy_write(dev, 0xe, 0x805d); -@@ -221,9 +226,7 @@ static void __init imx6q_1588_init(void) - { - struct device_node *np; - struct clk *ptp_clk; -- struct clk *enet_ref; - struct regmap *gpr; -- u32 clksel; - - np = of_find_compatible_node(NULL, NULL, "fsl,imx6q-fec"); - if (!np) { -@@ -237,30 +240,19 @@ static void __init imx6q_1588_init(void) - goto put_node; - } - -- enet_ref = clk_get_sys(NULL, "enet_ref"); -- if (IS_ERR(enet_ref)) { -- pr_warn("%s: failed to get enet clock\n", __func__); -- goto put_ptp_clk; -- } -- - /* - * If enet_ref from ANATOP/CCM is the PTP clock source, we need to - * set bit IOMUXC_GPR1[21]. Or the PTP clock must be from pad - * (external OSC), and we need to clear the bit. - */ -- clksel = clk_is_match(ptp_clk, enet_ref) ? -- IMX6Q_GPR1_ENET_CLK_SEL_ANATOP : -- IMX6Q_GPR1_ENET_CLK_SEL_PAD; - gpr = syscon_regmap_lookup_by_compatible("fsl,imx6q-iomuxc-gpr"); - if (!IS_ERR(gpr)) - regmap_update_bits(gpr, IOMUXC_GPR1, - IMX6Q_GPR1_ENET_CLK_SEL_MASK, -- clksel); -+ IMX6Q_GPR1_ENET_CLK_SEL_ANATOP); - else - pr_err("failed to find fsl,imx6q-iomux-gpr regmap\n"); - -- clk_put(enet_ref); --put_ptp_clk: - clk_put(ptp_clk); - put_node: - of_node_put(np); -@@ -334,6 +326,18 @@ static const struct of_dev_auxdata imx6q_auxdata_lookup[] __initconst = { - { /* sentinel */ } - }; - -+static void __init imx6q_enet_clk_sel(void) -+{ -+ struct regmap *gpr; -+ -+ gpr = syscon_regmap_lookup_by_compatible("fsl,imx6q-iomuxc-gpr"); -+ if (!IS_ERR(gpr)) -+ regmap_update_bits(gpr, IOMUXC_GPR5, -+ IMX6Q_GPR5_ENET_TX_CLK_SEL, IMX6Q_GPR5_ENET_TX_CLK_SEL); -+ else -+ pr_err("failed to find fsl,imx6q-iomux-gpr regmap\n"); -+} -+ - static void imx6q_fec_sleep_enable(int enabled) - { - struct regmap *gpr; -@@ -358,6 +362,87 @@ static void __init imx6q_enet_plt_init(void) - np = of_find_node_by_path("/soc/aips-bus@02100000/ethernet@02188000"); - if (np && of_get_property(np, "fsl,magic-packet", NULL)) - fec_pdata.sleep_mode_enable = imx6q_fec_sleep_enable; -+ -+ if (cpu_is_imx6q() && imx_get_soc_revision() == IMX_CHIP_REVISION_2_0) -+ imx6q_enet_clk_sel(); -+} -+ -+#define OCOTP_MACn(n) (0x00000620 + (n) * 0x10) -+void __init imx6_enet_mac_init(const char *enet_compat, const char *ocotp_compat) -+{ -+ struct device_node *ocotp_np, *enet_np, *from = NULL; -+ void __iomem *base; -+ struct property *newmac; -+ u32 macaddr_low; -+ u32 macaddr_high = 0; -+ u32 macaddr1_high = 0; -+ u8 *macaddr; -+ int i; -+ -+ for (i = 0; i < 2; i++) { -+ enet_np = of_find_compatible_node(from, NULL, enet_compat); -+ if (!enet_np) -+ return; -+ -+ from = enet_np; -+ -+ if (of_get_mac_address(enet_np)) -+ goto put_enet_node; -+ -+ ocotp_np = of_find_compatible_node(NULL, NULL, ocotp_compat); -+ if (!ocotp_np) { -+ pr_warn("failed to find ocotp node\n"); -+ goto put_enet_node; -+ } -+ -+ base = of_iomap(ocotp_np, 0); -+ if (!base) { -+ pr_warn("failed to map ocotp\n"); -+ goto put_ocotp_node; -+ } -+ -+ macaddr_low = readl_relaxed(base + OCOTP_MACn(1)); -+ if (i) -+ macaddr1_high = readl_relaxed(base + OCOTP_MACn(2)); -+ else -+ macaddr_high = readl_relaxed(base + OCOTP_MACn(0)); -+ -+ newmac = kzalloc(sizeof(*newmac) + 6, GFP_KERNEL); -+ if (!newmac) -+ goto put_ocotp_node; -+ -+ newmac->value = newmac + 1; -+ newmac->length = 6; -+ newmac->name = kstrdup("local-mac-address", GFP_KERNEL); -+ if (!newmac->name) { -+ kfree(newmac); -+ goto put_ocotp_node; -+ } -+ -+ macaddr = newmac->value; -+ if (i) { -+ macaddr[5] = (macaddr_low >> 16) & 0xff; -+ macaddr[4] = (macaddr_low >> 24) & 0xff; -+ macaddr[3] = macaddr1_high & 0xff; -+ macaddr[2] = (macaddr1_high >> 8) & 0xff; -+ macaddr[1] = (macaddr1_high >> 16) & 0xff; -+ macaddr[0] = (macaddr1_high >> 24) & 0xff; -+ } else { -+ macaddr[5] = macaddr_high & 0xff; -+ macaddr[4] = (macaddr_high >> 8) & 0xff; -+ macaddr[3] = (macaddr_high >> 16) & 0xff; -+ macaddr[2] = (macaddr_high >> 24) & 0xff; -+ macaddr[1] = macaddr_low & 0xff; -+ macaddr[0] = (macaddr_low >> 8) & 0xff; -+ } -+ -+ of_update_property(enet_np, newmac); -+ -+put_ocotp_node: -+ of_node_put(ocotp_np); -+put_enet_node: -+ of_node_put(enet_np); -+ } - } - - static void __init imx6q_init_machine(void) -@@ -381,8 +466,11 @@ static void __init imx6q_init_machine(void) - imx_anatop_init(); - imx6q_csi_mux_init(); - cpu_is_imx6q() ? imx6q_pm_init() : imx6dl_pm_init(); -+ - imx6q_1588_init(); - imx6q_enet_plt_init(); -+ imx6_enet_mac_init("fsl,imx6q-fec", "fsl,imx6q-ocotp"); -+ - imx6q_axi_init(); - - p = ioremap(0x21b0000, SZ_4K); -diff --git a/arch/arm/mach-imx/mach-imx6sl.c b/arch/arm/mach-imx/mach-imx6sl.c -index e5371e9..005becf 100644 ---- a/arch/arm/mach-imx/mach-imx6sl.c -+++ b/arch/arm/mach-imx/mach-imx6sl.c -@@ -19,7 +19,7 @@ - #include "common.h" - #include "cpuidle.h" - --static void __init imx6sl_fec_init(void) -+static void __init imx6sl_fec_clk_init(void) - { - struct regmap *gpr; - -@@ -30,9 +30,14 @@ static void __init imx6sl_fec_init(void) - IMX6SL_GPR1_FEC_CLOCK_MUX2_SEL_MASK, 0); - regmap_update_bits(gpr, IOMUXC_GPR1, - IMX6SL_GPR1_FEC_CLOCK_MUX1_SEL_MASK, 0); -- } else { -+ } else - pr_err("failed to find fsl,imx6sl-iomux-gpr regmap\n"); -- } -+} -+ -+static inline void imx6sl_fec_init(void) -+{ -+ imx6sl_fec_clk_init(); -+ imx6_enet_mac_init("fsl,imx6sl-fec", "fsl,imx6sl-ocotp"); - } - - static void __init imx6sl_init_late(void) -diff --git a/arch/arm/mach-imx/mach-imx6sx.c b/arch/arm/mach-imx/mach-imx6sx.c -index 3f56432..49d4e8e 100644 ---- a/arch/arm/mach-imx/mach-imx6sx.c -+++ b/arch/arm/mach-imx/mach-imx6sx.c -@@ -60,6 +60,7 @@ static void __init imx6sx_enet_clk_sel(void) - - static inline void imx6sx_enet_init(void) - { -+ imx6_enet_mac_init("fsl,imx6sx-fec", "fsl,imx6sx-ocotp"); - imx6sx_enet_phy_init(); - imx6sx_enet_clk_sel(); - } -diff --git a/arch/arm/mach-imx/mach-imx7d.c b/arch/arm/mach-imx/mach-imx7d.c -index b450f52..68a5a58 100644 ---- a/arch/arm/mach-imx/mach-imx7d.c -+++ b/arch/arm/mach-imx/mach-imx7d.c -@@ -81,6 +81,7 @@ static void __init imx7d_enet_clk_sel(void) - - static inline void imx7d_enet_init(void) - { -+ imx6_enet_mac_init("fsl,imx7d-fec", "fsl,imx7d-ocotp"); - imx7d_enet_phy_init(); - imx7d_enet_clk_sel(); - } -diff --git a/arch/arm/mach-omap2/cpuidle34xx.c b/arch/arm/mach-omap2/cpuidle34xx.c -index aa7b379..2a3db0b 100644 ---- a/arch/arm/mach-omap2/cpuidle34xx.c -+++ b/arch/arm/mach-omap2/cpuidle34xx.c -@@ -34,6 +34,7 @@ - #include "pm.h" - #include "control.h" - #include "common.h" -+#include "soc.h" - - /* Mach specific information to be recorded in the C-state driver_data */ - struct omap3_idle_statedata { -@@ -315,6 +316,69 @@ static struct cpuidle_driver omap3_idle_driver = { - .safe_state_index = 0, - }; - -+/* -+ * Numbers based on measurements made in October 2009 for PM optimized kernel -+ * with CPU freq enabled on device Nokia N900. Assumes OPP2 (main idle OPP, -+ * and worst case latencies). -+ */ -+static struct cpuidle_driver omap3430_idle_driver = { -+ .name = "omap3430_idle", -+ .owner = THIS_MODULE, -+ .states = { -+ { -+ .enter = omap3_enter_idle_bm, -+ .exit_latency = 110 + 162, -+ .target_residency = 5, -+ .name = "C1", -+ .desc = "MPU ON + CORE ON", -+ }, -+ { -+ .enter = omap3_enter_idle_bm, -+ .exit_latency = 106 + 180, -+ .target_residency = 309, -+ .name = "C2", -+ .desc = "MPU ON + CORE ON", -+ }, -+ { -+ .enter = omap3_enter_idle_bm, -+ .exit_latency = 107 + 410, -+ .target_residency = 46057, -+ .name = "C3", -+ .desc = "MPU RET + CORE ON", -+ }, -+ { -+ .enter = omap3_enter_idle_bm, -+ .exit_latency = 121 + 3374, -+ .target_residency = 46057, -+ .name = "C4", -+ .desc = "MPU OFF + CORE ON", -+ }, -+ { -+ .enter = omap3_enter_idle_bm, -+ .exit_latency = 855 + 1146, -+ .target_residency = 46057, -+ .name = "C5", -+ .desc = "MPU RET + CORE RET", -+ }, -+ { -+ .enter = omap3_enter_idle_bm, -+ .exit_latency = 7580 + 4134, -+ .target_residency = 484329, -+ .name = "C6", -+ .desc = "MPU OFF + CORE RET", -+ }, -+ { -+ .enter = omap3_enter_idle_bm, -+ .exit_latency = 7505 + 15274, -+ .target_residency = 484329, -+ .name = "C7", -+ .desc = "MPU OFF + CORE OFF", -+ }, -+ }, -+ .state_count = ARRAY_SIZE(omap3_idle_data), -+ .safe_state_index = 0, -+}; -+ - /* Public functions */ - - /** -@@ -333,5 +397,8 @@ int __init omap3_idle_init(void) - if (!mpu_pd || !core_pd || !per_pd || !cam_pd) - return -ENODEV; - -- return cpuidle_register(&omap3_idle_driver, NULL); -+ if (cpu_is_omap3430()) -+ return cpuidle_register(&omap3430_idle_driver, NULL); -+ else -+ return cpuidle_register(&omap3_idle_driver, NULL); - } -diff --git a/arch/arm/mach-omap2/io.c b/arch/arm/mach-omap2/io.c -index 3eaeaca..3a911d8 100644 ---- a/arch/arm/mach-omap2/io.c -+++ b/arch/arm/mach-omap2/io.c -@@ -368,6 +368,7 @@ void __init omap5_map_io(void) - void __init dra7xx_map_io(void) - { - iotable_init(dra7xx_io_desc, ARRAY_SIZE(dra7xx_io_desc)); -+ omap_barriers_init(); - } - #endif - /* -diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c -index 8e0bd59..147c90e 100644 ---- a/arch/arm/mach-omap2/omap_hwmod.c -+++ b/arch/arm/mach-omap2/omap_hwmod.c -@@ -1416,9 +1416,7 @@ static void _enable_sysc(struct omap_hwmod *oh) - (sf & SYSC_HAS_CLOCKACTIVITY)) - _set_clockactivity(oh, oh->class->sysc->clockact, &v); - -- /* If the cached value is the same as the new value, skip the write */ -- if (oh->_sysc_cache != v) -- _write_sysconfig(v, oh); -+ _write_sysconfig(v, oh); - - /* - * Set the autoidle bit only after setting the smartidle bit -@@ -1481,7 +1479,9 @@ static void _idle_sysc(struct omap_hwmod *oh) - _set_master_standbymode(oh, idlemode, &v); - } - -- _write_sysconfig(v, oh); -+ /* If the cached value is the same as the new value, skip the write */ -+ if (oh->_sysc_cache != v) -+ _write_sysconfig(v, oh); - } - - /** -diff --git a/arch/arm/mach-prima2/Kconfig b/arch/arm/mach-prima2/Kconfig -index 9ab8932..56e55fd 100644 ---- a/arch/arm/mach-prima2/Kconfig -+++ b/arch/arm/mach-prima2/Kconfig -@@ -1,6 +1,7 @@ - menuconfig ARCH_SIRF - bool "CSR SiRF" if ARCH_MULTI_V7 - select ARCH_HAS_RESET_CONTROLLER -+ select RESET_CONTROLLER - select ARCH_REQUIRE_GPIOLIB - select GENERIC_IRQ_CHIP - select NO_IOPORT_MAP -diff --git a/arch/arm/mach-s3c64xx/dev-audio.c b/arch/arm/mach-s3c64xx/dev-audio.c -index ff780a8..9a42736 100644 ---- a/arch/arm/mach-s3c64xx/dev-audio.c -+++ b/arch/arm/mach-s3c64xx/dev-audio.c -@@ -54,12 +54,12 @@ static int s3c64xx_i2s_cfg_gpio(struct platform_device *pdev) - - static struct resource s3c64xx_iis0_resource[] = { - [0] = DEFINE_RES_MEM(S3C64XX_PA_IIS0, SZ_256), -- [1] = DEFINE_RES_DMA(DMACH_I2S0_OUT), -- [2] = DEFINE_RES_DMA(DMACH_I2S0_IN), - }; - --static struct s3c_audio_pdata i2sv3_pdata = { -+static struct s3c_audio_pdata i2s0_pdata = { - .cfg_gpio = s3c64xx_i2s_cfg_gpio, -+ .dma_playback = DMACH_I2S0_OUT, -+ .dma_capture = DMACH_I2S0_IN, - }; - - struct platform_device s3c64xx_device_iis0 = { -@@ -68,15 +68,19 @@ struct platform_device s3c64xx_device_iis0 = { - .num_resources = ARRAY_SIZE(s3c64xx_iis0_resource), - .resource = s3c64xx_iis0_resource, - .dev = { -- .platform_data = &i2sv3_pdata, -+ .platform_data = &i2s0_pdata, - }, - }; - EXPORT_SYMBOL(s3c64xx_device_iis0); - - static struct resource s3c64xx_iis1_resource[] = { - [0] = DEFINE_RES_MEM(S3C64XX_PA_IIS1, SZ_256), -- [1] = DEFINE_RES_DMA(DMACH_I2S1_OUT), -- [2] = DEFINE_RES_DMA(DMACH_I2S1_IN), -+}; -+ -+static struct s3c_audio_pdata i2s1_pdata = { -+ .cfg_gpio = s3c64xx_i2s_cfg_gpio, -+ .dma_playback = DMACH_I2S1_OUT, -+ .dma_capture = DMACH_I2S1_IN, - }; - - struct platform_device s3c64xx_device_iis1 = { -@@ -85,19 +89,19 @@ struct platform_device s3c64xx_device_iis1 = { - .num_resources = ARRAY_SIZE(s3c64xx_iis1_resource), - .resource = s3c64xx_iis1_resource, - .dev = { -- .platform_data = &i2sv3_pdata, -+ .platform_data = &i2s1_pdata, - }, - }; - EXPORT_SYMBOL(s3c64xx_device_iis1); - - static struct resource s3c64xx_iisv4_resource[] = { - [0] = DEFINE_RES_MEM(S3C64XX_PA_IISV4, SZ_256), -- [1] = DEFINE_RES_DMA(DMACH_HSI_I2SV40_TX), -- [2] = DEFINE_RES_DMA(DMACH_HSI_I2SV40_RX), - }; - - static struct s3c_audio_pdata i2sv4_pdata = { - .cfg_gpio = s3c64xx_i2s_cfg_gpio, -+ .dma_playback = DMACH_HSI_I2SV40_TX, -+ .dma_capture = DMACH_HSI_I2SV40_RX, - .type = { - .i2s = { - .quirks = QUIRK_PRI_6CHAN, -@@ -142,12 +146,12 @@ static int s3c64xx_pcm_cfg_gpio(struct platform_device *pdev) - - static struct resource s3c64xx_pcm0_resource[] = { - [0] = DEFINE_RES_MEM(S3C64XX_PA_PCM0, SZ_256), -- [1] = DEFINE_RES_DMA(DMACH_PCM0_TX), -- [2] = DEFINE_RES_DMA(DMACH_PCM0_RX), - }; - - static struct s3c_audio_pdata s3c_pcm0_pdata = { - .cfg_gpio = s3c64xx_pcm_cfg_gpio, -+ .dma_capture = DMACH_PCM0_RX, -+ .dma_playback = DMACH_PCM0_TX, - }; - - struct platform_device s3c64xx_device_pcm0 = { -@@ -163,12 +167,12 @@ EXPORT_SYMBOL(s3c64xx_device_pcm0); - - static struct resource s3c64xx_pcm1_resource[] = { - [0] = DEFINE_RES_MEM(S3C64XX_PA_PCM1, SZ_256), -- [1] = DEFINE_RES_DMA(DMACH_PCM1_TX), -- [2] = DEFINE_RES_DMA(DMACH_PCM1_RX), - }; - - static struct s3c_audio_pdata s3c_pcm1_pdata = { - .cfg_gpio = s3c64xx_pcm_cfg_gpio, -+ .dma_playback = DMACH_PCM1_TX, -+ .dma_capture = DMACH_PCM1_RX, - }; - - struct platform_device s3c64xx_device_pcm1 = { -@@ -196,13 +200,14 @@ static int s3c64xx_ac97_cfg_gpe(struct platform_device *pdev) - - static struct resource s3c64xx_ac97_resource[] = { - [0] = DEFINE_RES_MEM(S3C64XX_PA_AC97, SZ_256), -- [1] = DEFINE_RES_DMA(DMACH_AC97_PCMOUT), -- [2] = DEFINE_RES_DMA(DMACH_AC97_PCMIN), -- [3] = DEFINE_RES_DMA(DMACH_AC97_MICIN), -- [4] = DEFINE_RES_IRQ(IRQ_AC97), -+ [1] = DEFINE_RES_IRQ(IRQ_AC97), - }; - --static struct s3c_audio_pdata s3c_ac97_pdata; -+static struct s3c_audio_pdata s3c_ac97_pdata = { -+ .dma_playback = DMACH_AC97_PCMOUT, -+ .dma_capture = DMACH_AC97_PCMIN, -+ .dma_capture_mic = DMACH_AC97_MICIN, -+}; - - static u64 s3c64xx_ac97_dmamask = DMA_BIT_MASK(32); - -diff --git a/arch/arm/mach-s3c64xx/include/mach/dma.h b/arch/arm/mach-s3c64xx/include/mach/dma.h -index 096e140..9c739ea 100644 ---- a/arch/arm/mach-s3c64xx/include/mach/dma.h -+++ b/arch/arm/mach-s3c64xx/include/mach/dma.h -@@ -14,38 +14,38 @@ - #define S3C64XX_DMA_CHAN(name) ((unsigned long)(name)) - - /* DMA0/SDMA0 */ --#define DMACH_UART0 S3C64XX_DMA_CHAN("uart0_tx") --#define DMACH_UART0_SRC2 S3C64XX_DMA_CHAN("uart0_rx") --#define DMACH_UART1 S3C64XX_DMA_CHAN("uart1_tx") --#define DMACH_UART1_SRC2 S3C64XX_DMA_CHAN("uart1_rx") --#define DMACH_UART2 S3C64XX_DMA_CHAN("uart2_tx") --#define DMACH_UART2_SRC2 S3C64XX_DMA_CHAN("uart2_rx") --#define DMACH_UART3 S3C64XX_DMA_CHAN("uart3_tx") --#define DMACH_UART3_SRC2 S3C64XX_DMA_CHAN("uart3_rx") --#define DMACH_PCM0_TX S3C64XX_DMA_CHAN("pcm0_tx") --#define DMACH_PCM0_RX S3C64XX_DMA_CHAN("pcm0_rx") --#define DMACH_I2S0_OUT S3C64XX_DMA_CHAN("i2s0_tx") --#define DMACH_I2S0_IN S3C64XX_DMA_CHAN("i2s0_rx") -+#define DMACH_UART0 "uart0_tx" -+#define DMACH_UART0_SRC2 "uart0_rx" -+#define DMACH_UART1 "uart1_tx" -+#define DMACH_UART1_SRC2 "uart1_rx" -+#define DMACH_UART2 "uart2_tx" -+#define DMACH_UART2_SRC2 "uart2_rx" -+#define DMACH_UART3 "uart3_tx" -+#define DMACH_UART3_SRC2 "uart3_rx" -+#define DMACH_PCM0_TX "pcm0_tx" -+#define DMACH_PCM0_RX "pcm0_rx" -+#define DMACH_I2S0_OUT "i2s0_tx" -+#define DMACH_I2S0_IN "i2s0_rx" - #define DMACH_SPI0_TX S3C64XX_DMA_CHAN("spi0_tx") - #define DMACH_SPI0_RX S3C64XX_DMA_CHAN("spi0_rx") --#define DMACH_HSI_I2SV40_TX S3C64XX_DMA_CHAN("i2s2_tx") --#define DMACH_HSI_I2SV40_RX S3C64XX_DMA_CHAN("i2s2_rx") -+#define DMACH_HSI_I2SV40_TX "i2s2_tx" -+#define DMACH_HSI_I2SV40_RX "i2s2_rx" - - /* DMA1/SDMA1 */ --#define DMACH_PCM1_TX S3C64XX_DMA_CHAN("pcm1_tx") --#define DMACH_PCM1_RX S3C64XX_DMA_CHAN("pcm1_rx") --#define DMACH_I2S1_OUT S3C64XX_DMA_CHAN("i2s1_tx") --#define DMACH_I2S1_IN S3C64XX_DMA_CHAN("i2s1_rx") -+#define DMACH_PCM1_TX "pcm1_tx" -+#define DMACH_PCM1_RX "pcm1_rx" -+#define DMACH_I2S1_OUT "i2s1_tx" -+#define DMACH_I2S1_IN "i2s1_rx" - #define DMACH_SPI1_TX S3C64XX_DMA_CHAN("spi1_tx") - #define DMACH_SPI1_RX S3C64XX_DMA_CHAN("spi1_rx") --#define DMACH_AC97_PCMOUT S3C64XX_DMA_CHAN("ac97_out") --#define DMACH_AC97_PCMIN S3C64XX_DMA_CHAN("ac97_in") --#define DMACH_AC97_MICIN S3C64XX_DMA_CHAN("ac97_mic") --#define DMACH_PWM S3C64XX_DMA_CHAN("pwm") --#define DMACH_IRDA S3C64XX_DMA_CHAN("irda") --#define DMACH_EXTERNAL S3C64XX_DMA_CHAN("external") --#define DMACH_SECURITY_RX S3C64XX_DMA_CHAN("sec_rx") --#define DMACH_SECURITY_TX S3C64XX_DMA_CHAN("sec_tx") -+#define DMACH_AC97_PCMOUT "ac97_out" -+#define DMACH_AC97_PCMIN "ac97_in" -+#define DMACH_AC97_MICIN "ac97_mic" -+#define DMACH_PWM "pwm" -+#define DMACH_IRDA "irda" -+#define DMACH_EXTERNAL "external" -+#define DMACH_SECURITY_RX "sec_rx" -+#define DMACH_SECURITY_TX "sec_tx" - - enum dma_ch { - DMACH_MAX = 32 -diff --git a/arch/arm/mach-socfpga/headsmp.S b/arch/arm/mach-socfpga/headsmp.S -index 5d94b7a..c160fa3 100644 ---- a/arch/arm/mach-socfpga/headsmp.S -+++ b/arch/arm/mach-socfpga/headsmp.S -@@ -13,6 +13,7 @@ - #include - - .arch armv7-a -+ .arm - - ENTRY(secondary_trampoline) - /* CPU1 will always fetch from 0x0 when it is brought out of reset. -diff --git a/arch/arm/plat-samsung/devs.c b/arch/arm/plat-samsung/devs.c -index 8207462..e212f9d 100644 ---- a/arch/arm/plat-samsung/devs.c -+++ b/arch/arm/plat-samsung/devs.c -@@ -65,6 +65,7 @@ - #include - #include - #include -+#include - #include - - static u64 samsung_device_dma_mask = DMA_BIT_MASK(32); -@@ -74,9 +75,12 @@ static u64 samsung_device_dma_mask = DMA_BIT_MASK(32); - static struct resource s3c_ac97_resource[] = { - [0] = DEFINE_RES_MEM(S3C2440_PA_AC97, S3C2440_SZ_AC97), - [1] = DEFINE_RES_IRQ(IRQ_S3C244X_AC97), -- [2] = DEFINE_RES_DMA_NAMED(DMACH_PCM_OUT, "PCM out"), -- [3] = DEFINE_RES_DMA_NAMED(DMACH_PCM_IN, "PCM in"), -- [4] = DEFINE_RES_DMA_NAMED(DMACH_MIC_IN, "Mic in"), -+}; -+ -+static struct s3c_audio_pdata s3c_ac97_pdata = { -+ .dma_playback = (void *)DMACH_PCM_OUT, -+ .dma_capture = (void *)DMACH_PCM_IN, -+ .dma_capture_mic = (void *)DMACH_MIC_IN, - }; - - struct platform_device s3c_device_ac97 = { -@@ -87,6 +91,7 @@ struct platform_device s3c_device_ac97 = { - .dev = { - .dma_mask = &samsung_device_dma_mask, - .coherent_dma_mask = DMA_BIT_MASK(32), -+ .platform_data = &s3c_ac97_pdata, - } - }; - #endif /* CONFIG_CPU_S3C2440 */ -diff --git a/arch/arm64/include/asm/elf.h b/arch/arm64/include/asm/elf.h -index faad6df..bc6492b 100644 ---- a/arch/arm64/include/asm/elf.h -+++ b/arch/arm64/include/asm/elf.h -@@ -156,14 +156,14 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm, - #define STACK_RND_MASK (0x3ffff >> (PAGE_SHIFT - 12)) - #endif - --#ifdef CONFIG_COMPAT -- - #ifdef __AARCH64EB__ - #define COMPAT_ELF_PLATFORM ("v8b") - #else - #define COMPAT_ELF_PLATFORM ("v8l") - #endif - -+#ifdef CONFIG_COMPAT -+ - #define COMPAT_ELF_ET_DYN_BASE (2 * TASK_SIZE_32 / 3) - - /* AArch32 registers. */ -diff --git a/arch/arm64/include/asm/opcodes.h b/arch/arm64/include/asm/opcodes.h -index 4e603ea..123f45d 100644 ---- a/arch/arm64/include/asm/opcodes.h -+++ b/arch/arm64/include/asm/opcodes.h -@@ -1 +1,5 @@ -+#ifdef CONFIG_CPU_BIG_ENDIAN -+#define CONFIG_CPU_ENDIAN_BE8 CONFIG_CPU_BIG_ENDIAN -+#endif -+ - #include <../../arm/include/asm/opcodes.h> -diff --git a/arch/arm64/include/asm/pgtable-hwdef.h b/arch/arm64/include/asm/pgtable-hwdef.h -index d6739e8..b9da954 100644 ---- a/arch/arm64/include/asm/pgtable-hwdef.h -+++ b/arch/arm64/include/asm/pgtable-hwdef.h -@@ -117,7 +117,6 @@ - * Section - */ - #define PMD_SECT_VALID (_AT(pmdval_t, 1) << 0) --#define PMD_SECT_PROT_NONE (_AT(pmdval_t, 1) << 58) - #define PMD_SECT_USER (_AT(pmdval_t, 1) << 6) /* AP[1] */ - #define PMD_SECT_RDONLY (_AT(pmdval_t, 1) << 7) /* AP[2] */ - #define PMD_SECT_S (_AT(pmdval_t, 3) << 8) -diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h -index eaa9cab..67c2ad6 100644 ---- a/arch/arm64/include/asm/pgtable.h -+++ b/arch/arm64/include/asm/pgtable.h -@@ -69,11 +69,11 @@ extern void __pgd_error(const char *file, int line, unsigned long val); - #define PROT_DEFAULT (PTE_TYPE_PAGE | PTE_AF | PTE_SHARED) - #define PROT_SECT_DEFAULT (PMD_TYPE_SECT | PMD_SECT_AF | PMD_SECT_S) - --#define PROT_DEVICE_nGnRnE (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_ATTRINDX(MT_DEVICE_nGnRnE)) --#define PROT_DEVICE_nGnRE (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_ATTRINDX(MT_DEVICE_nGnRE)) --#define PROT_NORMAL_NC (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_ATTRINDX(MT_NORMAL_NC)) --#define PROT_NORMAL_WT (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_ATTRINDX(MT_NORMAL_WT)) --#define PROT_NORMAL (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_ATTRINDX(MT_NORMAL)) -+#define PROT_DEVICE_nGnRnE (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_DIRTY | PTE_WRITE | PTE_ATTRINDX(MT_DEVICE_nGnRnE)) -+#define PROT_DEVICE_nGnRE (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_DIRTY | PTE_WRITE | PTE_ATTRINDX(MT_DEVICE_nGnRE)) -+#define PROT_NORMAL_NC (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_DIRTY | PTE_WRITE | PTE_ATTRINDX(MT_NORMAL_NC)) -+#define PROT_NORMAL_WT (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_DIRTY | PTE_WRITE | PTE_ATTRINDX(MT_NORMAL_WT)) -+#define PROT_NORMAL (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_DIRTY | PTE_WRITE | PTE_ATTRINDX(MT_NORMAL)) - - #define PROT_SECT_DEVICE_nGnRE (PROT_SECT_DEFAULT | PMD_SECT_PXN | PMD_SECT_UXN | PMD_ATTRINDX(MT_DEVICE_nGnRE)) - #define PROT_SECT_NORMAL (PROT_SECT_DEFAULT | PMD_SECT_PXN | PMD_SECT_UXN | PMD_ATTRINDX(MT_NORMAL)) -@@ -83,7 +83,7 @@ extern void __pgd_error(const char *file, int line, unsigned long val); - - #define PAGE_KERNEL __pgprot(_PAGE_DEFAULT | PTE_PXN | PTE_UXN | PTE_DIRTY | PTE_WRITE) - #define PAGE_KERNEL_RO __pgprot(_PAGE_DEFAULT | PTE_PXN | PTE_UXN | PTE_DIRTY | PTE_RDONLY) --#define PAGE_KERNEL_ROX __pgprot(_PAGE_DEFAULT | PTE_UXN | PTE_DIRTY | PTE_RDONLY) -+#define PAGE_KERNEL_ROX __pgprot(_PAGE_DEFAULT | PTE_UXN | PTE_DIRTY | PTE_RDONLY) - #define PAGE_KERNEL_EXEC __pgprot(_PAGE_DEFAULT | PTE_UXN | PTE_DIRTY | PTE_WRITE) - #define PAGE_KERNEL_EXEC_CONT __pgprot(_PAGE_DEFAULT | PTE_UXN | PTE_DIRTY | PTE_WRITE | PTE_CONT) - -@@ -155,6 +155,7 @@ extern struct page *empty_zero_page; - #define pte_write(pte) (!!(pte_val(pte) & PTE_WRITE)) - #define pte_exec(pte) (!(pte_val(pte) & PTE_UXN)) - #define pte_cont(pte) (!!(pte_val(pte) & PTE_CONT)) -+#define pte_user(pte) (!!(pte_val(pte) & PTE_USER)) - - #ifdef CONFIG_ARM64_HW_AFDBM - #define pte_hw_dirty(pte) (pte_write(pte) && !(pte_val(pte) & PTE_RDONLY)) -@@ -165,8 +166,6 @@ extern struct page *empty_zero_page; - #define pte_dirty(pte) (pte_sw_dirty(pte) || pte_hw_dirty(pte)) - - #define pte_valid(pte) (!!(pte_val(pte) & PTE_VALID)) --#define pte_valid_user(pte) \ -- ((pte_val(pte) & (PTE_VALID | PTE_USER)) == (PTE_VALID | PTE_USER)) - #define pte_valid_not_user(pte) \ - ((pte_val(pte) & (PTE_VALID | PTE_USER)) == PTE_VALID) - -@@ -264,13 +263,13 @@ extern void __sync_icache_dcache(pte_t pteval, unsigned long addr); - static inline void set_pte_at(struct mm_struct *mm, unsigned long addr, - pte_t *ptep, pte_t pte) - { -- if (pte_valid_user(pte)) { -- if (!pte_special(pte) && pte_exec(pte)) -- __sync_icache_dcache(pte, addr); -+ if (pte_present(pte)) { - if (pte_sw_dirty(pte) && pte_write(pte)) - pte_val(pte) &= ~PTE_RDONLY; - else - pte_val(pte) |= PTE_RDONLY; -+ if (pte_user(pte) && pte_exec(pte) && !pte_special(pte)) -+ __sync_icache_dcache(pte, addr); - } - - /* -@@ -348,6 +347,7 @@ void pmdp_splitting_flush(struct vm_area_struct *vma, unsigned long address, - #endif /* CONFIG_HAVE_RCU_TABLE_FREE */ - #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ - -+#define pmd_present(pmd) pte_present(pmd_pte(pmd)) - #define pmd_dirty(pmd) pte_dirty(pmd_pte(pmd)) - #define pmd_young(pmd) pte_young(pmd_pte(pmd)) - #define pmd_wrprotect(pmd) pte_pmd(pte_wrprotect(pmd_pte(pmd))) -@@ -356,7 +356,7 @@ void pmdp_splitting_flush(struct vm_area_struct *vma, unsigned long address, - #define pmd_mkwrite(pmd) pte_pmd(pte_mkwrite(pmd_pte(pmd))) - #define pmd_mkdirty(pmd) pte_pmd(pte_mkdirty(pmd_pte(pmd))) - #define pmd_mkyoung(pmd) pte_pmd(pte_mkyoung(pmd_pte(pmd))) --#define pmd_mknotpresent(pmd) (__pmd(pmd_val(pmd) & ~PMD_TYPE_MASK)) -+#define pmd_mknotpresent(pmd) (__pmd(pmd_val(pmd) & ~PMD_SECT_VALID)) - - #define __HAVE_ARCH_PMD_WRITE - #define pmd_write(pmd) pte_write(pmd_pte(pmd)) -@@ -395,7 +395,6 @@ extern pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn, - unsigned long size, pgprot_t vma_prot); - - #define pmd_none(pmd) (!pmd_val(pmd)) --#define pmd_present(pmd) (pmd_val(pmd)) - - #define pmd_bad(pmd) (!(pmd_val(pmd) & 2)) - -@@ -539,6 +538,21 @@ static inline pmd_t pmd_modify(pmd_t pmd, pgprot_t newprot) - } - - #ifdef CONFIG_ARM64_HW_AFDBM -+#define __HAVE_ARCH_PTEP_SET_ACCESS_FLAGS -+extern int ptep_set_access_flags(struct vm_area_struct *vma, -+ unsigned long address, pte_t *ptep, -+ pte_t entry, int dirty); -+ -+#ifdef CONFIG_TRANSPARENT_HUGEPAGE -+#define __HAVE_ARCH_PMDP_SET_ACCESS_FLAGS -+static inline int pmdp_set_access_flags(struct vm_area_struct *vma, -+ unsigned long address, pmd_t *pmdp, -+ pmd_t entry, int dirty) -+{ -+ return ptep_set_access_flags(vma, address, (pte_t *)pmdp, pmd_pte(entry), dirty); -+} -+#endif -+ - /* - * Atomic pte/pmd modifications. - */ -@@ -591,9 +605,9 @@ static inline pte_t ptep_get_and_clear(struct mm_struct *mm, - } - - #ifdef CONFIG_TRANSPARENT_HUGEPAGE --#define __HAVE_ARCH_PMDP_GET_AND_CLEAR --static inline pmd_t pmdp_get_and_clear(struct mm_struct *mm, -- unsigned long address, pmd_t *pmdp) -+#define __HAVE_ARCH_PMDP_HUGE_GET_AND_CLEAR -+static inline pmd_t pmdp_huge_get_and_clear(struct mm_struct *mm, -+ unsigned long address, pmd_t *pmdp) - { - return pte_pmd(ptep_get_and_clear(mm, address, (pte_t *)pmdp)); - } -@@ -641,6 +655,7 @@ extern pgd_t idmap_pg_dir[PTRS_PER_PGD]; - * bits 0-1: present (must be zero) - * bits 2-7: swap type - * bits 8-57: swap offset -+ * bit 58: PTE_PROT_NONE (must be zero) - */ - #define __SWP_TYPE_SHIFT 2 - #define __SWP_TYPE_BITS 6 -diff --git a/arch/arm64/kernel/cpuinfo.c b/arch/arm64/kernel/cpuinfo.c -index 212ae63..0166cfb 100644 ---- a/arch/arm64/kernel/cpuinfo.c -+++ b/arch/arm64/kernel/cpuinfo.c -@@ -22,6 +22,8 @@ - - #include - #include -+#include -+#include - #include - #include - #include -@@ -85,7 +87,8 @@ static const char *const compat_hwcap_str[] = { - "idivt", - "vfpd32", - "lpae", -- "evtstrm" -+ "evtstrm", -+ NULL - }; - - static const char *const compat_hwcap2_str[] = { -@@ -101,6 +104,7 @@ static const char *const compat_hwcap2_str[] = { - static int c_show(struct seq_file *m, void *v) - { - int i, j; -+ bool compat = personality(current->personality) == PER_LINUX32; - - for_each_online_cpu(i) { - struct cpuinfo_arm64 *cpuinfo = &per_cpu(cpu_data, i); -@@ -112,6 +116,9 @@ static int c_show(struct seq_file *m, void *v) - * "processor". Give glibc what it expects. - */ - seq_printf(m, "processor\t: %d\n", i); -+ if (compat) -+ seq_printf(m, "model name\t: ARMv8 Processor rev %d (%s)\n", -+ MIDR_REVISION(midr), COMPAT_ELF_PLATFORM); - - seq_printf(m, "BogoMIPS\t: %lu.%02lu\n", - loops_per_jiffy / (500000UL/HZ), -@@ -124,7 +131,7 @@ static int c_show(struct seq_file *m, void *v) - * software which does already (at least for 32-bit). - */ - seq_puts(m, "Features\t:"); -- if (personality(current->personality) == PER_LINUX32) { -+ if (compat) { - #ifdef CONFIG_COMPAT - for (j = 0; compat_hwcap_str[j]; j++) - if (compat_elf_hwcap & (1 << j)) -diff --git a/arch/arm64/kvm/inject_fault.c b/arch/arm64/kvm/inject_fault.c -index 648112e..3972e65 100644 ---- a/arch/arm64/kvm/inject_fault.c -+++ b/arch/arm64/kvm/inject_fault.c -@@ -130,7 +130,7 @@ static void inject_abt64(struct kvm_vcpu *vcpu, bool is_iabt, unsigned long addr - esr |= (ESR_ELx_EC_IABT_CUR << ESR_ELx_EC_SHIFT); - - if (!is_iabt) -- esr |= ESR_ELx_EC_DABT_LOW; -+ esr |= ESR_ELx_EC_DABT_LOW << ESR_ELx_EC_SHIFT; - - vcpu_sys_reg(vcpu, ESR_EL1) = esr | ESR_ELx_FSC_EXTABT; - } -diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c -index 92ddac1..4c1a118 100644 ---- a/arch/arm64/mm/fault.c -+++ b/arch/arm64/mm/fault.c -@@ -81,6 +81,56 @@ void show_pte(struct mm_struct *mm, unsigned long addr) - printk("\n"); - } - -+#ifdef CONFIG_ARM64_HW_AFDBM -+/* -+ * This function sets the access flags (dirty, accessed), as well as write -+ * permission, and only to a more permissive setting. -+ * -+ * It needs to cope with hardware update of the accessed/dirty state by other -+ * agents in the system and can safely skip the __sync_icache_dcache() call as, -+ * like set_pte_at(), the PTE is never changed from no-exec to exec here. -+ * -+ * Returns whether or not the PTE actually changed. -+ */ -+int ptep_set_access_flags(struct vm_area_struct *vma, -+ unsigned long address, pte_t *ptep, -+ pte_t entry, int dirty) -+{ -+ pteval_t old_pteval; -+ unsigned int tmp; -+ -+ if (pte_same(*ptep, entry)) -+ return 0; -+ -+ /* only preserve the access flags and write permission */ -+ pte_val(entry) &= PTE_AF | PTE_WRITE | PTE_DIRTY; -+ -+ /* -+ * PTE_RDONLY is cleared by default in the asm below, so set it in -+ * back if necessary (read-only or clean PTE). -+ */ -+ if (!pte_write(entry) || !pte_sw_dirty(entry)) -+ pte_val(entry) |= PTE_RDONLY; -+ -+ /* -+ * Setting the flags must be done atomically to avoid racing with the -+ * hardware update of the access/dirty state. -+ */ -+ asm volatile("// ptep_set_access_flags\n" -+ " prfm pstl1strm, %2\n" -+ "1: ldxr %0, %2\n" -+ " and %0, %0, %3 // clear PTE_RDONLY\n" -+ " orr %0, %0, %4 // set flags\n" -+ " stxr %w1, %0, %2\n" -+ " cbnz %w1, 1b\n" -+ : "=&r" (old_pteval), "=&r" (tmp), "+Q" (pte_val(*ptep)) -+ : "L" (~PTE_RDONLY), "r" (pte_val(entry))); -+ -+ flush_tlb_fix_spurious_fault(vma, address); -+ return 1; -+} -+#endif -+ - /* - * The kernel tried to access some page that wasn't present. - */ -diff --git a/arch/ia64/include/asm/io.h b/arch/ia64/include/asm/io.h -index 9041bbe..8fdb9c7 100644 ---- a/arch/ia64/include/asm/io.h -+++ b/arch/ia64/include/asm/io.h -@@ -436,6 +436,7 @@ static inline void __iomem * ioremap_cache (unsigned long phys_addr, unsigned lo - return ioremap(phys_addr, size); - } - #define ioremap_cache ioremap_cache -+#define ioremap_uc ioremap_nocache - - - /* -diff --git a/arch/mips/alchemy/devboards/db1000.c b/arch/mips/alchemy/devboards/db1000.c -index bdeed9d..433c4b9 100644 ---- a/arch/mips/alchemy/devboards/db1000.c -+++ b/arch/mips/alchemy/devboards/db1000.c -@@ -503,15 +503,15 @@ int __init db1000_dev_setup(void) - if (board == BCSR_WHOAMI_DB1500) { - c0 = AU1500_GPIO2_INT; - c1 = AU1500_GPIO5_INT; -- d0 = AU1500_GPIO0_INT; -- d1 = AU1500_GPIO3_INT; -+ d0 = 0; /* GPIO number, NOT irq! */ -+ d1 = 3; /* GPIO number, NOT irq! */ - s0 = AU1500_GPIO1_INT; - s1 = AU1500_GPIO4_INT; - } else if (board == BCSR_WHOAMI_DB1100) { - c0 = AU1100_GPIO2_INT; - c1 = AU1100_GPIO5_INT; -- d0 = AU1100_GPIO0_INT; -- d1 = AU1100_GPIO3_INT; -+ d0 = 0; /* GPIO number, NOT irq! */ -+ d1 = 3; /* GPIO number, NOT irq! */ - s0 = AU1100_GPIO1_INT; - s1 = AU1100_GPIO4_INT; - -@@ -545,15 +545,15 @@ int __init db1000_dev_setup(void) - } else if (board == BCSR_WHOAMI_DB1000) { - c0 = AU1000_GPIO2_INT; - c1 = AU1000_GPIO5_INT; -- d0 = AU1000_GPIO0_INT; -- d1 = AU1000_GPIO3_INT; -+ d0 = 0; /* GPIO number, NOT irq! */ -+ d1 = 3; /* GPIO number, NOT irq! */ - s0 = AU1000_GPIO1_INT; - s1 = AU1000_GPIO4_INT; - platform_add_devices(db1000_devs, ARRAY_SIZE(db1000_devs)); - } else if ((board == BCSR_WHOAMI_PB1500) || - (board == BCSR_WHOAMI_PB1500R2)) { - c0 = AU1500_GPIO203_INT; -- d0 = AU1500_GPIO201_INT; -+ d0 = 1; /* GPIO number, NOT irq! */ - s0 = AU1500_GPIO202_INT; - twosocks = 0; - flashsize = 64; -@@ -566,7 +566,7 @@ int __init db1000_dev_setup(void) - */ - } else if (board == BCSR_WHOAMI_PB1100) { - c0 = AU1100_GPIO11_INT; -- d0 = AU1100_GPIO9_INT; -+ d0 = 9; /* GPIO number, NOT irq! */ - s0 = AU1100_GPIO10_INT; - twosocks = 0; - flashsize = 64; -@@ -583,7 +583,6 @@ int __init db1000_dev_setup(void) - } else - return 0; /* unknown board, no further dev setup to do */ - -- irq_set_irq_type(d0, IRQ_TYPE_EDGE_BOTH); - irq_set_irq_type(c0, IRQ_TYPE_LEVEL_LOW); - irq_set_irq_type(s0, IRQ_TYPE_LEVEL_LOW); - -@@ -597,7 +596,6 @@ int __init db1000_dev_setup(void) - c0, d0, /*s0*/0, 0, 0); - - if (twosocks) { -- irq_set_irq_type(d1, IRQ_TYPE_EDGE_BOTH); - irq_set_irq_type(c1, IRQ_TYPE_LEVEL_LOW); - irq_set_irq_type(s1, IRQ_TYPE_LEVEL_LOW); - -diff --git a/arch/mips/alchemy/devboards/db1550.c b/arch/mips/alchemy/devboards/db1550.c -index 5740bcf..6c37b93 100644 ---- a/arch/mips/alchemy/devboards/db1550.c -+++ b/arch/mips/alchemy/devboards/db1550.c -@@ -514,7 +514,7 @@ static void __init db1550_devices(void) - AU1000_PCMCIA_MEM_PHYS_ADDR + 0x000400000 - 1, - AU1000_PCMCIA_IO_PHYS_ADDR, - AU1000_PCMCIA_IO_PHYS_ADDR + 0x000010000 - 1, -- AU1550_GPIO3_INT, AU1550_GPIO0_INT, -+ AU1550_GPIO3_INT, 0, - /*AU1550_GPIO21_INT*/0, 0, 0); - - db1x_register_pcmcia_socket( -@@ -524,7 +524,7 @@ static void __init db1550_devices(void) - AU1000_PCMCIA_MEM_PHYS_ADDR + 0x004400000 - 1, - AU1000_PCMCIA_IO_PHYS_ADDR + 0x004000000, - AU1000_PCMCIA_IO_PHYS_ADDR + 0x004010000 - 1, -- AU1550_GPIO5_INT, AU1550_GPIO1_INT, -+ AU1550_GPIO5_INT, 1, - /*AU1550_GPIO22_INT*/0, 0, 1); - - platform_device_register(&db1550_nand_dev); -diff --git a/arch/mips/ath79/early_printk.c b/arch/mips/ath79/early_printk.c -index b955faf..d1adc59 100644 ---- a/arch/mips/ath79/early_printk.c -+++ b/arch/mips/ath79/early_printk.c -@@ -31,13 +31,15 @@ static inline void prom_putchar_wait(void __iomem *reg, u32 mask, u32 val) - } while (1); - } - -+#define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE) -+ - static void prom_putchar_ar71xx(unsigned char ch) - { - void __iomem *base = (void __iomem *)(KSEG1ADDR(AR71XX_UART_BASE)); - -- prom_putchar_wait(base + UART_LSR * 4, UART_LSR_THRE, UART_LSR_THRE); -+ prom_putchar_wait(base + UART_LSR * 4, BOTH_EMPTY, BOTH_EMPTY); - __raw_writel(ch, base + UART_TX * 4); -- prom_putchar_wait(base + UART_LSR * 4, UART_LSR_THRE, UART_LSR_THRE); -+ prom_putchar_wait(base + UART_LSR * 4, BOTH_EMPTY, BOTH_EMPTY); - } - - static void prom_putchar_ar933x(unsigned char ch) -diff --git a/arch/mips/include/asm/asmmacro.h b/arch/mips/include/asm/asmmacro.h -index 867f924..e689b89 100644 ---- a/arch/mips/include/asm/asmmacro.h -+++ b/arch/mips/include/asm/asmmacro.h -@@ -298,21 +298,21 @@ - .set pop - .endm - -- .macro copy_u_w ws, n -+ .macro copy_s_w ws, n - .set push - .set mips32r2 - .set fp=64 - .set msa -- copy_u.w $1, $w\ws[\n] -+ copy_s.w $1, $w\ws[\n] - .set pop - .endm - -- .macro copy_u_d ws, n -+ .macro copy_s_d ws, n - .set push - .set mips64r2 - .set fp=64 - .set msa -- copy_u.d $1, $w\ws[\n] -+ copy_s.d $1, $w\ws[\n] - .set pop - .endm - -@@ -346,8 +346,8 @@ - #define STH_MSA_INSN 0x5800081f - #define STW_MSA_INSN 0x5800082f - #define STD_MSA_INSN 0x5800083f --#define COPY_UW_MSA_INSN 0x58f00056 --#define COPY_UD_MSA_INSN 0x58f80056 -+#define COPY_SW_MSA_INSN 0x58b00056 -+#define COPY_SD_MSA_INSN 0x58b80056 - #define INSERT_W_MSA_INSN 0x59300816 - #define INSERT_D_MSA_INSN 0x59380816 - #else -@@ -361,8 +361,8 @@ - #define STH_MSA_INSN 0x78000825 - #define STW_MSA_INSN 0x78000826 - #define STD_MSA_INSN 0x78000827 --#define COPY_UW_MSA_INSN 0x78f00059 --#define COPY_UD_MSA_INSN 0x78f80059 -+#define COPY_SW_MSA_INSN 0x78b00059 -+#define COPY_SD_MSA_INSN 0x78b80059 - #define INSERT_W_MSA_INSN 0x79300819 - #define INSERT_D_MSA_INSN 0x79380819 - #endif -@@ -393,7 +393,7 @@ - .set push - .set noat - SET_HARDFLOAT -- addu $1, \base, \off -+ PTR_ADDU $1, \base, \off - .word LDB_MSA_INSN | (\wd << 6) - .set pop - .endm -@@ -402,7 +402,7 @@ - .set push - .set noat - SET_HARDFLOAT -- addu $1, \base, \off -+ PTR_ADDU $1, \base, \off - .word LDH_MSA_INSN | (\wd << 6) - .set pop - .endm -@@ -411,7 +411,7 @@ - .set push - .set noat - SET_HARDFLOAT -- addu $1, \base, \off -+ PTR_ADDU $1, \base, \off - .word LDW_MSA_INSN | (\wd << 6) - .set pop - .endm -@@ -420,7 +420,7 @@ - .set push - .set noat - SET_HARDFLOAT -- addu $1, \base, \off -+ PTR_ADDU $1, \base, \off - .word LDD_MSA_INSN | (\wd << 6) - .set pop - .endm -@@ -429,7 +429,7 @@ - .set push - .set noat - SET_HARDFLOAT -- addu $1, \base, \off -+ PTR_ADDU $1, \base, \off - .word STB_MSA_INSN | (\wd << 6) - .set pop - .endm -@@ -438,7 +438,7 @@ - .set push - .set noat - SET_HARDFLOAT -- addu $1, \base, \off -+ PTR_ADDU $1, \base, \off - .word STH_MSA_INSN | (\wd << 6) - .set pop - .endm -@@ -447,7 +447,7 @@ - .set push - .set noat - SET_HARDFLOAT -- addu $1, \base, \off -+ PTR_ADDU $1, \base, \off - .word STW_MSA_INSN | (\wd << 6) - .set pop - .endm -@@ -456,26 +456,26 @@ - .set push - .set noat - SET_HARDFLOAT -- addu $1, \base, \off -+ PTR_ADDU $1, \base, \off - .word STD_MSA_INSN | (\wd << 6) - .set pop - .endm - -- .macro copy_u_w ws, n -+ .macro copy_s_w ws, n - .set push - .set noat - SET_HARDFLOAT - .insn -- .word COPY_UW_MSA_INSN | (\n << 16) | (\ws << 11) -+ .word COPY_SW_MSA_INSN | (\n << 16) | (\ws << 11) - .set pop - .endm - -- .macro copy_u_d ws, n -+ .macro copy_s_d ws, n - .set push - .set noat - SET_HARDFLOAT - .insn -- .word COPY_UD_MSA_INSN | (\n << 16) | (\ws << 11) -+ .word COPY_SD_MSA_INSN | (\n << 16) | (\ws << 11) - .set pop - .endm - -diff --git a/arch/mips/include/asm/cacheflush.h b/arch/mips/include/asm/cacheflush.h -index 723229f..176de58 100644 ---- a/arch/mips/include/asm/cacheflush.h -+++ b/arch/mips/include/asm/cacheflush.h -@@ -51,7 +51,6 @@ extern void (*flush_cache_range)(struct vm_area_struct *vma, - unsigned long start, unsigned long end); - extern void (*flush_cache_page)(struct vm_area_struct *vma, unsigned long page, unsigned long pfn); - extern void __flush_dcache_page(struct page *page); --extern void __flush_icache_page(struct vm_area_struct *vma, struct page *page); - - #define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 1 - static inline void flush_dcache_page(struct page *page) -@@ -77,11 +76,6 @@ static inline void flush_anon_page(struct vm_area_struct *vma, - static inline void flush_icache_page(struct vm_area_struct *vma, - struct page *page) - { -- if (!cpu_has_ic_fills_f_dc && (vma->vm_flags & VM_EXEC) && -- Page_dcache_dirty(page)) { -- __flush_icache_page(vma, page); -- ClearPageDcacheDirty(page); -- } - } - - extern void (*flush_icache_range)(unsigned long start, unsigned long end); -diff --git a/arch/mips/include/asm/kvm_host.h b/arch/mips/include/asm/kvm_host.h -index 6ded8d3..4e956b3 100644 ---- a/arch/mips/include/asm/kvm_host.h -+++ b/arch/mips/include/asm/kvm_host.h -@@ -784,7 +784,7 @@ extern enum emulation_result kvm_mips_complete_mmio_load(struct kvm_vcpu *vcpu, - - uint32_t kvm_mips_read_count(struct kvm_vcpu *vcpu); - void kvm_mips_write_count(struct kvm_vcpu *vcpu, uint32_t count); --void kvm_mips_write_compare(struct kvm_vcpu *vcpu, uint32_t compare); -+void kvm_mips_write_compare(struct kvm_vcpu *vcpu, uint32_t compare, bool ack); - void kvm_mips_init_count(struct kvm_vcpu *vcpu); - int kvm_mips_set_count_ctl(struct kvm_vcpu *vcpu, s64 count_ctl); - int kvm_mips_set_count_resume(struct kvm_vcpu *vcpu, s64 count_resume); -diff --git a/arch/mips/include/asm/msa.h b/arch/mips/include/asm/msa.h -index bbb85fe..6e4effa 100644 ---- a/arch/mips/include/asm/msa.h -+++ b/arch/mips/include/asm/msa.h -@@ -147,6 +147,19 @@ static inline void restore_msa(struct task_struct *t) - _restore_msa(t); - } - -+static inline void init_msa_upper(void) -+{ -+ /* -+ * Check cpu_has_msa only if it's a constant. This will allow the -+ * compiler to optimise out code for CPUs without MSA without adding -+ * an extra redundant check for CPUs with MSA. -+ */ -+ if (__builtin_constant_p(cpu_has_msa) && !cpu_has_msa) -+ return; -+ -+ _init_msa_upper(); -+} -+ - #ifdef TOOLCHAIN_SUPPORTS_MSA - - #define __BUILD_MSA_CTL_REG(name, cs) \ -diff --git a/arch/mips/include/asm/pgtable.h b/arch/mips/include/asm/pgtable.h -index 18826aa..4e68c64 100644 ---- a/arch/mips/include/asm/pgtable.h -+++ b/arch/mips/include/asm/pgtable.h -@@ -127,10 +127,14 @@ do { \ - } \ - } while(0) - -+static inline void set_pte_at(struct mm_struct *mm, unsigned long addr, -+ pte_t *ptep, pte_t pteval); -+ - #if defined(CONFIG_PHYS_ADDR_T_64BIT) && defined(CONFIG_CPU_MIPS32) - - #define pte_none(pte) (!(((pte).pte_high) & ~_PAGE_GLOBAL)) - #define pte_present(pte) ((pte).pte_low & _PAGE_PRESENT) -+#define pte_no_exec(pte) ((pte).pte_low & _PAGE_NO_EXEC) - - static inline void set_pte(pte_t *ptep, pte_t pte) - { -@@ -148,7 +152,6 @@ static inline void set_pte(pte_t *ptep, pte_t pte) - buddy->pte_high |= _PAGE_GLOBAL; - } - } --#define set_pte_at(mm, addr, ptep, pteval) set_pte(ptep, pteval) - - static inline void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep) - { -@@ -166,6 +169,7 @@ static inline void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *pt - - #define pte_none(pte) (!(pte_val(pte) & ~_PAGE_GLOBAL)) - #define pte_present(pte) (pte_val(pte) & _PAGE_PRESENT) -+#define pte_no_exec(pte) (pte_val(pte) & _PAGE_NO_EXEC) - - /* - * Certain architectures need to do special things when pte's -@@ -218,7 +222,6 @@ static inline void set_pte(pte_t *ptep, pte_t pteval) - } - #endif - } --#define set_pte_at(mm, addr, ptep, pteval) set_pte(ptep, pteval) - - static inline void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep) - { -@@ -234,6 +237,22 @@ static inline void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *pt - } - #endif - -+static inline void set_pte_at(struct mm_struct *mm, unsigned long addr, -+ pte_t *ptep, pte_t pteval) -+{ -+ extern void __update_cache(unsigned long address, pte_t pte); -+ -+ if (!pte_present(pteval)) -+ goto cache_sync_done; -+ -+ if (pte_present(*ptep) && (pte_pfn(*ptep) == pte_pfn(pteval))) -+ goto cache_sync_done; -+ -+ __update_cache(addr, pteval); -+cache_sync_done: -+ set_pte(ptep, pteval); -+} -+ - /* - * (pmds are folded into puds so this doesn't get actually called, - * but the define is needed for a generic inline function.) -@@ -430,15 +449,12 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot) - - extern void __update_tlb(struct vm_area_struct *vma, unsigned long address, - pte_t pte); --extern void __update_cache(struct vm_area_struct *vma, unsigned long address, -- pte_t pte); - - static inline void update_mmu_cache(struct vm_area_struct *vma, - unsigned long address, pte_t *ptep) - { - pte_t pte = *ptep; - __update_tlb(vma, address, pte); -- __update_cache(vma, address, pte); - } - - static inline void update_mmu_cache_pmd(struct vm_area_struct *vma, -diff --git a/arch/mips/include/asm/processor.h b/arch/mips/include/asm/processor.h -index 3f832c3..041153f 100644 ---- a/arch/mips/include/asm/processor.h -+++ b/arch/mips/include/asm/processor.h -@@ -45,7 +45,7 @@ extern unsigned int vced_count, vcei_count; - * User space process size: 2GB. This is hardcoded into a few places, - * so don't change it unless you know what you are doing. - */ --#define TASK_SIZE 0x7fff8000UL -+#define TASK_SIZE 0x80000000UL - #endif - - #define STACK_TOP_MAX TASK_SIZE -diff --git a/arch/mips/include/asm/switch_to.h b/arch/mips/include/asm/switch_to.h -index 28b5d84..ebb5c0f 100644 ---- a/arch/mips/include/asm/switch_to.h -+++ b/arch/mips/include/asm/switch_to.h -@@ -105,7 +105,7 @@ do { \ - __clear_software_ll_bit(); \ - if (cpu_has_userlocal) \ - write_c0_userlocal(task_thread_info(next)->tp_value); \ -- __restore_watch(); \ -+ __restore_watch(next); \ - (last) = resume(prev, next, task_thread_info(next)); \ - } while (0) - -diff --git a/arch/mips/include/asm/watch.h b/arch/mips/include/asm/watch.h -index 20126ec..6ffe3ea 100644 ---- a/arch/mips/include/asm/watch.h -+++ b/arch/mips/include/asm/watch.h -@@ -12,21 +12,21 @@ - - #include - --void mips_install_watch_registers(void); -+void mips_install_watch_registers(struct task_struct *t); - void mips_read_watch_registers(void); - void mips_clear_watch_registers(void); - void mips_probe_watch_registers(struct cpuinfo_mips *c); - - #ifdef CONFIG_HARDWARE_WATCHPOINTS --#define __restore_watch() do { \ -+#define __restore_watch(task) do { \ - if (unlikely(test_bit(TIF_LOAD_WATCH, \ -- ¤t_thread_info()->flags))) { \ -- mips_install_watch_registers(); \ -+ &task_thread_info(task)->flags))) { \ -+ mips_install_watch_registers(task); \ - } \ - } while (0) - - #else --#define __restore_watch() do {} while (0) -+#define __restore_watch(task) do {} while (0) - #endif - - #endif /* _ASM_WATCH_H */ -diff --git a/arch/mips/include/uapi/asm/siginfo.h b/arch/mips/include/uapi/asm/siginfo.h -index 2cb7fde..e2b5337 100644 ---- a/arch/mips/include/uapi/asm/siginfo.h -+++ b/arch/mips/include/uapi/asm/siginfo.h -@@ -28,7 +28,7 @@ - - #define __ARCH_SIGSYS - --#include -+#include - - /* We can't use generic siginfo_t, because our si_code and si_errno are swapped */ - typedef struct siginfo { -@@ -42,13 +42,13 @@ typedef struct siginfo { - - /* kill() */ - struct { -- pid_t _pid; /* sender's pid */ -+ __kernel_pid_t _pid; /* sender's pid */ - __ARCH_SI_UID_T _uid; /* sender's uid */ - } _kill; - - /* POSIX.1b timers */ - struct { -- timer_t _tid; /* timer id */ -+ __kernel_timer_t _tid; /* timer id */ - int _overrun; /* overrun count */ - char _pad[sizeof( __ARCH_SI_UID_T) - sizeof(int)]; - sigval_t _sigval; /* same as below */ -@@ -57,26 +57,26 @@ typedef struct siginfo { - - /* POSIX.1b signals */ - struct { -- pid_t _pid; /* sender's pid */ -+ __kernel_pid_t _pid; /* sender's pid */ - __ARCH_SI_UID_T _uid; /* sender's uid */ - sigval_t _sigval; - } _rt; - - /* SIGCHLD */ - struct { -- pid_t _pid; /* which child */ -+ __kernel_pid_t _pid; /* which child */ - __ARCH_SI_UID_T _uid; /* sender's uid */ - int _status; /* exit code */ -- clock_t _utime; -- clock_t _stime; -+ __kernel_clock_t _utime; -+ __kernel_clock_t _stime; - } _sigchld; - - /* IRIX SIGCHLD */ - struct { -- pid_t _pid; /* which child */ -- clock_t _utime; -+ __kernel_pid_t _pid; /* which child */ -+ __kernel_clock_t _utime; - int _status; /* exit code */ -- clock_t _stime; -+ __kernel_clock_t _stime; - } _irix_sigchld; - - /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */ -@@ -118,6 +118,4 @@ typedef struct siginfo { - #define SI_TIMER __SI_CODE(__SI_TIMER, -3) /* sent by timer expiration */ - #define SI_MESGQ __SI_CODE(__SI_MESGQ, -4) /* sent by real time mesq state change */ - --#include -- - #endif /* _UAPI_ASM_SIGINFO_H */ -diff --git a/arch/mips/kernel/mips-r2-to-r6-emul.c b/arch/mips/kernel/mips-r2-to-r6-emul.c -index 1f5aac7..4674a74 100644 ---- a/arch/mips/kernel/mips-r2-to-r6-emul.c -+++ b/arch/mips/kernel/mips-r2-to-r6-emul.c -@@ -28,6 +28,7 @@ - #include - #include - #include -+#include - #include - #include - -@@ -1251,10 +1252,10 @@ fpu_emul: - " j 10b\n" - " .previous\n" - " .section __ex_table,\"a\"\n" -- " .word 1b,8b\n" -- " .word 2b,8b\n" -- " .word 3b,8b\n" -- " .word 4b,8b\n" -+ STR(PTR) " 1b,8b\n" -+ STR(PTR) " 2b,8b\n" -+ STR(PTR) " 3b,8b\n" -+ STR(PTR) " 4b,8b\n" - " .previous\n" - " .set pop\n" - : "+&r"(rt), "=&r"(rs), -@@ -1326,10 +1327,10 @@ fpu_emul: - " j 10b\n" - " .previous\n" - " .section __ex_table,\"a\"\n" -- " .word 1b,8b\n" -- " .word 2b,8b\n" -- " .word 3b,8b\n" -- " .word 4b,8b\n" -+ STR(PTR) " 1b,8b\n" -+ STR(PTR) " 2b,8b\n" -+ STR(PTR) " 3b,8b\n" -+ STR(PTR) " 4b,8b\n" - " .previous\n" - " .set pop\n" - : "+&r"(rt), "=&r"(rs), -@@ -1397,10 +1398,10 @@ fpu_emul: - " j 9b\n" - " .previous\n" - " .section __ex_table,\"a\"\n" -- " .word 1b,8b\n" -- " .word 2b,8b\n" -- " .word 3b,8b\n" -- " .word 4b,8b\n" -+ STR(PTR) " 1b,8b\n" -+ STR(PTR) " 2b,8b\n" -+ STR(PTR) " 3b,8b\n" -+ STR(PTR) " 4b,8b\n" - " .previous\n" - " .set pop\n" - : "+&r"(rt), "=&r"(rs), -@@ -1467,10 +1468,10 @@ fpu_emul: - " j 9b\n" - " .previous\n" - " .section __ex_table,\"a\"\n" -- " .word 1b,8b\n" -- " .word 2b,8b\n" -- " .word 3b,8b\n" -- " .word 4b,8b\n" -+ STR(PTR) " 1b,8b\n" -+ STR(PTR) " 2b,8b\n" -+ STR(PTR) " 3b,8b\n" -+ STR(PTR) " 4b,8b\n" - " .previous\n" - " .set pop\n" - : "+&r"(rt), "=&r"(rs), -@@ -1582,14 +1583,14 @@ fpu_emul: - " j 9b\n" - " .previous\n" - " .section __ex_table,\"a\"\n" -- " .word 1b,8b\n" -- " .word 2b,8b\n" -- " .word 3b,8b\n" -- " .word 4b,8b\n" -- " .word 5b,8b\n" -- " .word 6b,8b\n" -- " .word 7b,8b\n" -- " .word 0b,8b\n" -+ STR(PTR) " 1b,8b\n" -+ STR(PTR) " 2b,8b\n" -+ STR(PTR) " 3b,8b\n" -+ STR(PTR) " 4b,8b\n" -+ STR(PTR) " 5b,8b\n" -+ STR(PTR) " 6b,8b\n" -+ STR(PTR) " 7b,8b\n" -+ STR(PTR) " 0b,8b\n" - " .previous\n" - " .set pop\n" - : "+&r"(rt), "=&r"(rs), -@@ -1701,14 +1702,14 @@ fpu_emul: - " j 9b\n" - " .previous\n" - " .section __ex_table,\"a\"\n" -- " .word 1b,8b\n" -- " .word 2b,8b\n" -- " .word 3b,8b\n" -- " .word 4b,8b\n" -- " .word 5b,8b\n" -- " .word 6b,8b\n" -- " .word 7b,8b\n" -- " .word 0b,8b\n" -+ STR(PTR) " 1b,8b\n" -+ STR(PTR) " 2b,8b\n" -+ STR(PTR) " 3b,8b\n" -+ STR(PTR) " 4b,8b\n" -+ STR(PTR) " 5b,8b\n" -+ STR(PTR) " 6b,8b\n" -+ STR(PTR) " 7b,8b\n" -+ STR(PTR) " 0b,8b\n" - " .previous\n" - " .set pop\n" - : "+&r"(rt), "=&r"(rs), -@@ -1820,14 +1821,14 @@ fpu_emul: - " j 9b\n" - " .previous\n" - " .section __ex_table,\"a\"\n" -- " .word 1b,8b\n" -- " .word 2b,8b\n" -- " .word 3b,8b\n" -- " .word 4b,8b\n" -- " .word 5b,8b\n" -- " .word 6b,8b\n" -- " .word 7b,8b\n" -- " .word 0b,8b\n" -+ STR(PTR) " 1b,8b\n" -+ STR(PTR) " 2b,8b\n" -+ STR(PTR) " 3b,8b\n" -+ STR(PTR) " 4b,8b\n" -+ STR(PTR) " 5b,8b\n" -+ STR(PTR) " 6b,8b\n" -+ STR(PTR) " 7b,8b\n" -+ STR(PTR) " 0b,8b\n" - " .previous\n" - " .set pop\n" - : "+&r"(rt), "=&r"(rs), -@@ -1938,14 +1939,14 @@ fpu_emul: - " j 9b\n" - " .previous\n" - " .section __ex_table,\"a\"\n" -- " .word 1b,8b\n" -- " .word 2b,8b\n" -- " .word 3b,8b\n" -- " .word 4b,8b\n" -- " .word 5b,8b\n" -- " .word 6b,8b\n" -- " .word 7b,8b\n" -- " .word 0b,8b\n" -+ STR(PTR) " 1b,8b\n" -+ STR(PTR) " 2b,8b\n" -+ STR(PTR) " 3b,8b\n" -+ STR(PTR) " 4b,8b\n" -+ STR(PTR) " 5b,8b\n" -+ STR(PTR) " 6b,8b\n" -+ STR(PTR) " 7b,8b\n" -+ STR(PTR) " 0b,8b\n" - " .previous\n" - " .set pop\n" - : "+&r"(rt), "=&r"(rs), -@@ -2000,7 +2001,7 @@ fpu_emul: - "j 2b\n" - ".previous\n" - ".section __ex_table,\"a\"\n" -- ".word 1b, 3b\n" -+ STR(PTR) " 1b,3b\n" - ".previous\n" - : "=&r"(res), "+&r"(err) - : "r"(vaddr), "i"(SIGSEGV) -@@ -2058,7 +2059,7 @@ fpu_emul: - "j 2b\n" - ".previous\n" - ".section __ex_table,\"a\"\n" -- ".word 1b, 3b\n" -+ STR(PTR) " 1b,3b\n" - ".previous\n" - : "+&r"(res), "+&r"(err) - : "r"(vaddr), "i"(SIGSEGV)); -@@ -2119,7 +2120,7 @@ fpu_emul: - "j 2b\n" - ".previous\n" - ".section __ex_table,\"a\"\n" -- ".word 1b, 3b\n" -+ STR(PTR) " 1b,3b\n" - ".previous\n" - : "=&r"(res), "+&r"(err) - : "r"(vaddr), "i"(SIGSEGV) -@@ -2182,7 +2183,7 @@ fpu_emul: - "j 2b\n" - ".previous\n" - ".section __ex_table,\"a\"\n" -- ".word 1b, 3b\n" -+ STR(PTR) " 1b,3b\n" - ".previous\n" - : "+&r"(res), "+&r"(err) - : "r"(vaddr), "i"(SIGSEGV)); -diff --git a/arch/mips/kernel/pm.c b/arch/mips/kernel/pm.c -index fefdf39..dc81489 100644 ---- a/arch/mips/kernel/pm.c -+++ b/arch/mips/kernel/pm.c -@@ -56,7 +56,7 @@ static void mips_cpu_restore(void) - write_c0_userlocal(current_thread_info()->tp_value); - - /* Restore watch registers */ -- __restore_watch(); -+ __restore_watch(current); - } - - /** -diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c -index f2975d4..89847be 100644 ---- a/arch/mips/kernel/process.c -+++ b/arch/mips/kernel/process.c -@@ -457,7 +457,7 @@ unsigned long notrace unwind_stack_by_address(unsigned long stack_page, - *sp + sizeof(*regs) <= stack_page + THREAD_SIZE - 32) { - regs = (struct pt_regs *)*sp; - pc = regs->cp0_epc; -- if (__kernel_text_address(pc)) { -+ if (!user_mode(regs) && __kernel_text_address(pc)) { - *sp = regs->regs[29]; - *ra = regs->regs[31]; - return pc; -@@ -603,6 +603,9 @@ int mips_set_process_fp_mode(struct task_struct *task, unsigned int value) - if (!(value & PR_FP_MODE_FR) && cpu_has_fpu && cpu_has_mips_r6) - return -EOPNOTSUPP; - -+ /* Proceed with the mode switch */ -+ preempt_disable(); -+ - /* Save FP & vector context, then disable FPU & MSA */ - if (task->signal == current->signal) - lose_fpu(1); -@@ -661,6 +664,7 @@ int mips_set_process_fp_mode(struct task_struct *task, unsigned int value) - - /* Allow threads to use FP again */ - atomic_set(&task->mm->context.fp_mode_switching, 0); -+ preempt_enable(); - - return 0; - } -diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c -index 4f0ac78..74d5815 100644 ---- a/arch/mips/kernel/ptrace.c -+++ b/arch/mips/kernel/ptrace.c -@@ -57,8 +57,7 @@ static void init_fp_ctx(struct task_struct *target) - /* Begin with data registers set to all 1s... */ - memset(&target->thread.fpu.fpr, ~0, sizeof(target->thread.fpu.fpr)); - -- /* ...and FCSR zeroed */ -- target->thread.fpu.fcr31 = 0; -+ /* FCSR has been preset by `mips_set_personality_nan'. */ - - /* - * Record that the target has "used" math, such that the context -@@ -80,6 +79,22 @@ void ptrace_disable(struct task_struct *child) - } - - /* -+ * Poke at FCSR according to its mask. Don't set the cause bits as -+ * this is currently not handled correctly in FP context restoration -+ * and will cause an oops if a corresponding enable bit is set. -+ */ -+static void ptrace_setfcr31(struct task_struct *child, u32 value) -+{ -+ u32 fcr31; -+ u32 mask; -+ -+ value &= ~FPU_CSR_ALL_X; -+ fcr31 = child->thread.fpu.fcr31; -+ mask = boot_cpu_data.fpu_msk31; -+ child->thread.fpu.fcr31 = (value & ~mask) | (fcr31 & mask); -+} -+ -+/* - * Read a general register set. We always use the 64-bit format, even - * for 32-bit kernels and for 32-bit processes on a 64-bit kernel. - * Registers are sign extended to fill the available space. -@@ -159,9 +174,7 @@ int ptrace_setfpregs(struct task_struct *child, __u32 __user *data) - { - union fpureg *fregs; - u64 fpr_val; -- u32 fcr31; - u32 value; -- u32 mask; - int i; - - if (!access_ok(VERIFY_READ, data, 33 * 8)) -@@ -176,9 +189,7 @@ int ptrace_setfpregs(struct task_struct *child, __u32 __user *data) - } - - __get_user(value, data + 64); -- fcr31 = child->thread.fpu.fcr31; -- mask = boot_cpu_data.fpu_msk31; -- child->thread.fpu.fcr31 = (value & ~mask) | (fcr31 & mask); -+ ptrace_setfcr31(child, value); - - /* FIR may not be written. */ - -@@ -808,7 +819,7 @@ long arch_ptrace(struct task_struct *child, long request, - break; - #endif - case FPC_CSR: -- child->thread.fpu.fcr31 = data & ~FPU_CSR_ALL_X; -+ ptrace_setfcr31(child, data); - break; - case DSP_BASE ... DSP_BASE + 5: { - dspreg_t *dregs; -diff --git a/arch/mips/kernel/r4k_fpu.S b/arch/mips/kernel/r4k_fpu.S -index f09546e..bc74485 100644 ---- a/arch/mips/kernel/r4k_fpu.S -+++ b/arch/mips/kernel/r4k_fpu.S -@@ -244,17 +244,17 @@ LEAF(\name) - .set push - .set noat - #ifdef CONFIG_64BIT -- copy_u_d \wr, 1 -+ copy_s_d \wr, 1 - EX sd $1, \off(\base) - #elif defined(CONFIG_CPU_LITTLE_ENDIAN) -- copy_u_w \wr, 2 -+ copy_s_w \wr, 2 - EX sw $1, \off(\base) -- copy_u_w \wr, 3 -+ copy_s_w \wr, 3 - EX sw $1, (\off+4)(\base) - #else /* CONFIG_CPU_BIG_ENDIAN */ -- copy_u_w \wr, 2 -+ copy_s_w \wr, 2 - EX sw $1, (\off+4)(\base) -- copy_u_w \wr, 3 -+ copy_s_w \wr, 3 - EX sw $1, \off(\base) - #endif - .set pop -diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c -index 66aac55..8acae31 100644 ---- a/arch/mips/kernel/setup.c -+++ b/arch/mips/kernel/setup.c -@@ -706,6 +706,9 @@ static void __init arch_mem_init(char **cmdline_p) - for_each_memblock(reserved, reg) - if (reg->size != 0) - reserve_bootmem(reg->base, reg->size, BOOTMEM_DEFAULT); -+ -+ reserve_bootmem_region(__pa_symbol(&__nosave_begin), -+ __pa_symbol(&__nosave_end)); /* Reserve for hibernation */ - } - - static void __init resource_init(void) -diff --git a/arch/mips/kernel/signal.c b/arch/mips/kernel/signal.c -index bf792e2..9e35b6b 100644 ---- a/arch/mips/kernel/signal.c -+++ b/arch/mips/kernel/signal.c -@@ -195,6 +195,9 @@ static int restore_msa_extcontext(void __user *buf, unsigned int size) - unsigned int csr; - int i, err; - -+ if (!config_enabled(CONFIG_CPU_HAS_MSA)) -+ return SIGSYS; -+ - if (size != sizeof(*msa)) - return -EINVAL; - -@@ -398,8 +401,8 @@ int protected_restore_fp_context(void __user *sc) - } - - fp_done: -- if (used & USED_EXTCONTEXT) -- err |= restore_extcontext(sc_to_extcontext(sc)); -+ if (!err && (used & USED_EXTCONTEXT)) -+ err = restore_extcontext(sc_to_extcontext(sc)); - - return err ?: sig; - } -@@ -767,15 +770,7 @@ static void handle_signal(struct ksignal *ksig, struct pt_regs *regs) - sigset_t *oldset = sigmask_to_save(); - int ret; - struct mips_abi *abi = current->thread.abi; --#ifdef CONFIG_CPU_MICROMIPS -- void *vdso; -- unsigned long tmp = (unsigned long)current->mm->context.vdso; -- -- set_isa16_mode(tmp); -- vdso = (void *)tmp; --#else - void *vdso = current->mm->context.vdso; --#endif - - if (regs->regs[0]) { - switch(regs->regs[2]) { -diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c -index ca9a810..99a4022 100644 ---- a/arch/mips/kernel/traps.c -+++ b/arch/mips/kernel/traps.c -@@ -144,7 +144,7 @@ static void show_backtrace(struct task_struct *task, const struct pt_regs *regs) - if (!task) - task = current; - -- if (raw_show_trace || !__kernel_text_address(pc)) { -+ if (raw_show_trace || user_mode(regs) || !__kernel_text_address(pc)) { - show_raw_backtrace(sp); - return; - } -@@ -1241,7 +1241,7 @@ static int enable_restore_fp_context(int msa) - err = init_fpu(); - if (msa && !err) { - enable_msa(); -- _init_msa_upper(); -+ init_msa_upper(); - set_thread_flag(TIF_USEDMSA); - set_thread_flag(TIF_MSA_CTX_LIVE); - } -@@ -1304,7 +1304,7 @@ static int enable_restore_fp_context(int msa) - */ - prior_msa = test_and_set_thread_flag(TIF_MSA_CTX_LIVE); - if (!prior_msa && was_fpu_owner) { -- _init_msa_upper(); -+ init_msa_upper(); - - goto out; - } -@@ -1321,7 +1321,7 @@ static int enable_restore_fp_context(int msa) - * of each vector register such that it cannot see data left - * behind by another task. - */ -- _init_msa_upper(); -+ init_msa_upper(); - } else { - /* We need to restore the vector context. */ - restore_msa(current); -diff --git a/arch/mips/kernel/unaligned.c b/arch/mips/kernel/unaligned.c -index 490cea5..5c62065 100644 ---- a/arch/mips/kernel/unaligned.c -+++ b/arch/mips/kernel/unaligned.c -@@ -885,7 +885,7 @@ static void emulate_load_store_insn(struct pt_regs *regs, - { - union mips_instruction insn; - unsigned long value; -- unsigned int res; -+ unsigned int res, preempted; - unsigned long origpc; - unsigned long orig31; - void __user *fault_addr = NULL; -@@ -1226,27 +1226,36 @@ static void emulate_load_store_insn(struct pt_regs *regs, - if (!access_ok(VERIFY_READ, addr, sizeof(*fpr))) - goto sigbus; - -- /* -- * Disable preemption to avoid a race between copying -- * state from userland, migrating to another CPU and -- * updating the hardware vector register below. -- */ -- preempt_disable(); -- -- res = __copy_from_user_inatomic(fpr, addr, -- sizeof(*fpr)); -- if (res) -- goto fault; -- -- /* -- * Update the hardware register if it is in use by the -- * task in this quantum, in order to avoid having to -- * save & restore the whole vector context. -- */ -- if (test_thread_flag(TIF_USEDMSA)) -- write_msa_wr(wd, fpr, df); -+ do { -+ /* -+ * If we have live MSA context keep track of -+ * whether we get preempted in order to avoid -+ * the register context we load being clobbered -+ * by the live context as it's saved during -+ * preemption. If we don't have live context -+ * then it can't be saved to clobber the value -+ * we load. -+ */ -+ preempted = test_thread_flag(TIF_USEDMSA); -+ -+ res = __copy_from_user_inatomic(fpr, addr, -+ sizeof(*fpr)); -+ if (res) -+ goto fault; - -- preempt_enable(); -+ /* -+ * Update the hardware register if it is in use -+ * by the task in this quantum, in order to -+ * avoid having to save & restore the whole -+ * vector context. -+ */ -+ preempt_disable(); -+ if (test_thread_flag(TIF_USEDMSA)) { -+ write_msa_wr(wd, fpr, df); -+ preempted = 0; -+ } -+ preempt_enable(); -+ } while (preempted); - break; - - case msa_st_op: -diff --git a/arch/mips/kernel/watch.c b/arch/mips/kernel/watch.c -index 2a03abb..9b78e37 100644 ---- a/arch/mips/kernel/watch.c -+++ b/arch/mips/kernel/watch.c -@@ -15,10 +15,9 @@ - * Install the watch registers for the current thread. A maximum of - * four registers are installed although the machine may have more. - */ --void mips_install_watch_registers(void) -+void mips_install_watch_registers(struct task_struct *t) - { -- struct mips3264_watch_reg_state *watches = -- ¤t->thread.watch.mips3264; -+ struct mips3264_watch_reg_state *watches = &t->thread.watch.mips3264; - switch (current_cpu_data.watch_reg_use_cnt) { - default: - BUG(); -diff --git a/arch/mips/kvm/emulate.c b/arch/mips/kvm/emulate.c -index 41b1b09..dc10c77 100644 ---- a/arch/mips/kvm/emulate.c -+++ b/arch/mips/kvm/emulate.c -@@ -302,12 +302,31 @@ static inline ktime_t kvm_mips_count_time(struct kvm_vcpu *vcpu) - */ - static uint32_t kvm_mips_read_count_running(struct kvm_vcpu *vcpu, ktime_t now) - { -- ktime_t expires; -+ struct mips_coproc *cop0 = vcpu->arch.cop0; -+ ktime_t expires, threshold; -+ uint32_t count, compare; - int running; - -- /* Is the hrtimer pending? */ -+ /* Calculate the biased and scaled guest CP0_Count */ -+ count = vcpu->arch.count_bias + kvm_mips_ktime_to_count(vcpu, now); -+ compare = kvm_read_c0_guest_compare(cop0); -+ -+ /* -+ * Find whether CP0_Count has reached the closest timer interrupt. If -+ * not, we shouldn't inject it. -+ */ -+ if ((int32_t)(count - compare) < 0) -+ return count; -+ -+ /* -+ * The CP0_Count we're going to return has already reached the closest -+ * timer interrupt. Quickly check if it really is a new interrupt by -+ * looking at whether the interval until the hrtimer expiry time is -+ * less than 1/4 of the timer period. -+ */ - expires = hrtimer_get_expires(&vcpu->arch.comparecount_timer); -- if (ktime_compare(now, expires) >= 0) { -+ threshold = ktime_add_ns(now, vcpu->arch.count_period / 4); -+ if (ktime_before(expires, threshold)) { - /* - * Cancel it while we handle it so there's no chance of - * interference with the timeout handler. -@@ -329,8 +348,7 @@ static uint32_t kvm_mips_read_count_running(struct kvm_vcpu *vcpu, ktime_t now) - } - } - -- /* Return the biased and scaled guest CP0_Count */ -- return vcpu->arch.count_bias + kvm_mips_ktime_to_count(vcpu, now); -+ return count; - } - - /** -@@ -420,32 +438,6 @@ static void kvm_mips_resume_hrtimer(struct kvm_vcpu *vcpu, - } - - /** -- * kvm_mips_update_hrtimer() - Update next expiry time of hrtimer. -- * @vcpu: Virtual CPU. -- * -- * Recalculates and updates the expiry time of the hrtimer. This can be used -- * after timer parameters have been altered which do not depend on the time that -- * the change occurs (in those cases kvm_mips_freeze_hrtimer() and -- * kvm_mips_resume_hrtimer() are used directly). -- * -- * It is guaranteed that no timer interrupts will be lost in the process. -- * -- * Assumes !kvm_mips_count_disabled(@vcpu) (guest CP0_Count timer is running). -- */ --static void kvm_mips_update_hrtimer(struct kvm_vcpu *vcpu) --{ -- ktime_t now; -- uint32_t count; -- -- /* -- * freeze_hrtimer takes care of a timer interrupts <= count, and -- * resume_hrtimer the hrtimer takes care of a timer interrupts > count. -- */ -- now = kvm_mips_freeze_hrtimer(vcpu, &count); -- kvm_mips_resume_hrtimer(vcpu, now, count); --} -- --/** - * kvm_mips_write_count() - Modify the count and update timer. - * @vcpu: Virtual CPU. - * @count: Guest CP0_Count value to set. -@@ -540,23 +532,42 @@ int kvm_mips_set_count_hz(struct kvm_vcpu *vcpu, s64 count_hz) - * kvm_mips_write_compare() - Modify compare and update timer. - * @vcpu: Virtual CPU. - * @compare: New CP0_Compare value. -+ * @ack: Whether to acknowledge timer interrupt. - * - * Update CP0_Compare to a new value and update the timeout. -+ * If @ack, atomically acknowledge any pending timer interrupt, otherwise ensure -+ * any pending timer interrupt is preserved. - */ --void kvm_mips_write_compare(struct kvm_vcpu *vcpu, uint32_t compare) -+void kvm_mips_write_compare(struct kvm_vcpu *vcpu, uint32_t compare, bool ack) - { - struct mips_coproc *cop0 = vcpu->arch.cop0; -+ int dc; -+ u32 old_compare = kvm_read_c0_guest_compare(cop0); -+ ktime_t now; -+ uint32_t count; - - /* if unchanged, must just be an ack */ -- if (kvm_read_c0_guest_compare(cop0) == compare) -+ if (old_compare == compare) { -+ if (!ack) -+ return; -+ kvm_mips_callbacks->dequeue_timer_int(vcpu); -+ kvm_write_c0_guest_compare(cop0, compare); - return; -+ } -+ -+ /* freeze_hrtimer() takes care of timer interrupts <= count */ -+ dc = kvm_mips_count_disabled(vcpu); -+ if (!dc) -+ now = kvm_mips_freeze_hrtimer(vcpu, &count); -+ -+ if (ack) -+ kvm_mips_callbacks->dequeue_timer_int(vcpu); - -- /* Update compare */ - kvm_write_c0_guest_compare(cop0, compare); - -- /* Update timeout if count enabled */ -- if (!kvm_mips_count_disabled(vcpu)) -- kvm_mips_update_hrtimer(vcpu); -+ /* resume_hrtimer() takes care of timer interrupts > count */ -+ if (!dc) -+ kvm_mips_resume_hrtimer(vcpu, now, count); - } - - /** -@@ -1095,9 +1106,9 @@ enum emulation_result kvm_mips_emulate_CP0(uint32_t inst, uint32_t *opc, - - /* If we are writing to COMPARE */ - /* Clear pending timer interrupt, if any */ -- kvm_mips_callbacks->dequeue_timer_int(vcpu); - kvm_mips_write_compare(vcpu, -- vcpu->arch.gprs[rt]); -+ vcpu->arch.gprs[rt], -+ true); - } else if ((rd == MIPS_CP0_STATUS) && (sel == 0)) { - unsigned int old_val, val, change; - -diff --git a/arch/mips/kvm/mips.c b/arch/mips/kvm/mips.c -index 2683d04..8a11329 100644 ---- a/arch/mips/kvm/mips.c -+++ b/arch/mips/kvm/mips.c -@@ -445,8 +445,8 @@ int kvm_vcpu_ioctl_interrupt(struct kvm_vcpu *vcpu, - - dvcpu->arch.wait = 0; - -- if (waitqueue_active(&dvcpu->wq)) -- wake_up_interruptible(&dvcpu->wq); -+ if (swait_active(&dvcpu->wq)) -+ swake_up(&dvcpu->wq); - - return 0; - } -@@ -1174,8 +1174,8 @@ static void kvm_mips_comparecount_func(unsigned long data) - kvm_mips_callbacks->queue_timer_int(vcpu); - - vcpu->arch.wait = 0; -- if (waitqueue_active(&vcpu->wq)) -- wake_up_interruptible(&vcpu->wq); -+ if (swait_active(&vcpu->wq)) -+ swake_up(&vcpu->wq); - } - - /* low level hrtimer wake routine */ -diff --git a/arch/mips/kvm/trap_emul.c b/arch/mips/kvm/trap_emul.c -index d836ed5..307cc4c 100644 ---- a/arch/mips/kvm/trap_emul.c -+++ b/arch/mips/kvm/trap_emul.c -@@ -547,7 +547,7 @@ static int kvm_trap_emul_set_one_reg(struct kvm_vcpu *vcpu, - kvm_mips_write_count(vcpu, v); - break; - case KVM_REG_MIPS_CP0_COMPARE: -- kvm_mips_write_compare(vcpu, v); -+ kvm_mips_write_compare(vcpu, v, false); - break; - case KVM_REG_MIPS_CP0_CAUSE: - /* -diff --git a/arch/mips/lib/ashldi3.c b/arch/mips/lib/ashldi3.c -index beb80f3..927dc94 100644 ---- a/arch/mips/lib/ashldi3.c -+++ b/arch/mips/lib/ashldi3.c -@@ -2,7 +2,7 @@ - - #include "libgcc.h" - --long long __ashldi3(long long u, word_type b) -+long long notrace __ashldi3(long long u, word_type b) - { - DWunion uu, w; - word_type bm; -diff --git a/arch/mips/lib/ashrdi3.c b/arch/mips/lib/ashrdi3.c -index c884a91..9fdf1a5 100644 ---- a/arch/mips/lib/ashrdi3.c -+++ b/arch/mips/lib/ashrdi3.c -@@ -2,7 +2,7 @@ - - #include "libgcc.h" - --long long __ashrdi3(long long u, word_type b) -+long long notrace __ashrdi3(long long u, word_type b) - { - DWunion uu, w; - word_type bm; -diff --git a/arch/mips/lib/bswapdi.c b/arch/mips/lib/bswapdi.c -index 77e5f9c..e3e77aa 100644 ---- a/arch/mips/lib/bswapdi.c -+++ b/arch/mips/lib/bswapdi.c -@@ -1,6 +1,6 @@ - #include - --unsigned long long __bswapdi2(unsigned long long u) -+unsigned long long notrace __bswapdi2(unsigned long long u) - { - return (((u) & 0xff00000000000000ull) >> 56) | - (((u) & 0x00ff000000000000ull) >> 40) | -diff --git a/arch/mips/lib/bswapsi.c b/arch/mips/lib/bswapsi.c -index 2b302ff..530a8af 100644 ---- a/arch/mips/lib/bswapsi.c -+++ b/arch/mips/lib/bswapsi.c -@@ -1,6 +1,6 @@ - #include - --unsigned int __bswapsi2(unsigned int u) -+unsigned int notrace __bswapsi2(unsigned int u) - { - return (((u) & 0xff000000) >> 24) | - (((u) & 0x00ff0000) >> 8) | -diff --git a/arch/mips/lib/cmpdi2.c b/arch/mips/lib/cmpdi2.c -index 8c13064..06857da 100644 ---- a/arch/mips/lib/cmpdi2.c -+++ b/arch/mips/lib/cmpdi2.c -@@ -2,7 +2,7 @@ - - #include "libgcc.h" - --word_type __cmpdi2(long long a, long long b) -+word_type notrace __cmpdi2(long long a, long long b) - { - const DWunion au = { - .ll = a -diff --git a/arch/mips/lib/lshrdi3.c b/arch/mips/lib/lshrdi3.c -index dcf8d68..3645474 100644 ---- a/arch/mips/lib/lshrdi3.c -+++ b/arch/mips/lib/lshrdi3.c -@@ -2,7 +2,7 @@ - - #include "libgcc.h" - --long long __lshrdi3(long long u, word_type b) -+long long notrace __lshrdi3(long long u, word_type b) - { - DWunion uu, w; - word_type bm; -diff --git a/arch/mips/lib/ucmpdi2.c b/arch/mips/lib/ucmpdi2.c -index bb4cb2f..bd599f5 100644 ---- a/arch/mips/lib/ucmpdi2.c -+++ b/arch/mips/lib/ucmpdi2.c -@@ -2,7 +2,7 @@ - - #include "libgcc.h" - --word_type __ucmpdi2(unsigned long long a, unsigned long long b) -+word_type notrace __ucmpdi2(unsigned long long a, unsigned long long b) - { - const DWunion au = {.ll = a}; - const DWunion bu = {.ll = b}; -diff --git a/arch/mips/loongson64/loongson-3/numa.c b/arch/mips/loongson64/loongson-3/numa.c -index 6f9e010..282c5a8 100644 ---- a/arch/mips/loongson64/loongson-3/numa.c -+++ b/arch/mips/loongson64/loongson-3/numa.c -@@ -213,10 +213,10 @@ static void __init node_mem_init(unsigned int node) - BOOTMEM_DEFAULT); - - if (node == 0 && node_end_pfn(0) >= (0xffffffff >> PAGE_SHIFT)) { -- /* Reserve 0xff800000~0xffffffff for RS780E integrated GPU */ -+ /* Reserve 0xfe000000~0xffffffff for RS780E integrated GPU */ - reserve_bootmem_node(NODE_DATA(node), -- (node_addrspace_offset | 0xff800000), -- 8 << 20, BOOTMEM_DEFAULT); -+ (node_addrspace_offset | 0xfe000000), -+ 32 << 20, BOOTMEM_DEFAULT); - } - - sparse_memory_present_with_active_regions(node); -diff --git a/arch/mips/math-emu/cp1emu.c b/arch/mips/math-emu/cp1emu.c -index 32f0e19..734a2c7 100644 ---- a/arch/mips/math-emu/cp1emu.c -+++ b/arch/mips/math-emu/cp1emu.c -@@ -445,9 +445,11 @@ static int isBranchInstr(struct pt_regs *regs, struct mm_decoded_insn dec_insn, - case spec_op: - switch (insn.r_format.func) { - case jalr_op: -- regs->regs[insn.r_format.rd] = -- regs->cp0_epc + dec_insn.pc_inc + -- dec_insn.next_pc_inc; -+ if (insn.r_format.rd != 0) { -+ regs->regs[insn.r_format.rd] = -+ regs->cp0_epc + dec_insn.pc_inc + -+ dec_insn.next_pc_inc; -+ } - /* Fall through */ - case jr_op: - /* For R6, JR already emulated in jalr_op */ -diff --git a/arch/mips/mm/cache.c b/arch/mips/mm/cache.c -index aab218c..e87bccd 100644 ---- a/arch/mips/mm/cache.c -+++ b/arch/mips/mm/cache.c -@@ -16,6 +16,7 @@ - #include - - #include -+#include - #include - #include - #include -@@ -83,8 +84,6 @@ void __flush_dcache_page(struct page *page) - struct address_space *mapping = page_mapping(page); - unsigned long addr; - -- if (PageHighMem(page)) -- return; - if (mapping && !mapping_mapped(mapping)) { - SetPageDcacheDirty(page); - return; -@@ -95,8 +94,15 @@ void __flush_dcache_page(struct page *page) - * case is for exec env/arg pages and those are %99 certainly going to - * get faulted into the tlb (and thus flushed) anyways. - */ -- addr = (unsigned long) page_address(page); -+ if (PageHighMem(page)) -+ addr = (unsigned long)kmap_atomic(page); -+ else -+ addr = (unsigned long)page_address(page); -+ - flush_data_cache_page(addr); -+ -+ if (PageHighMem(page)) -+ __kunmap_atomic((void *)addr); - } - - EXPORT_SYMBOL(__flush_dcache_page); -@@ -119,33 +125,28 @@ void __flush_anon_page(struct page *page, unsigned long vmaddr) - - EXPORT_SYMBOL(__flush_anon_page); - --void __flush_icache_page(struct vm_area_struct *vma, struct page *page) --{ -- unsigned long addr; -- -- if (PageHighMem(page)) -- return; -- -- addr = (unsigned long) page_address(page); -- flush_data_cache_page(addr); --} --EXPORT_SYMBOL_GPL(__flush_icache_page); -- --void __update_cache(struct vm_area_struct *vma, unsigned long address, -- pte_t pte) -+void __update_cache(unsigned long address, pte_t pte) - { - struct page *page; - unsigned long pfn, addr; -- int exec = (vma->vm_flags & VM_EXEC) && !cpu_has_ic_fills_f_dc; -+ int exec = !pte_no_exec(pte) && !cpu_has_ic_fills_f_dc; - - pfn = pte_pfn(pte); - if (unlikely(!pfn_valid(pfn))) - return; - page = pfn_to_page(pfn); -- if (page_mapping(page) && Page_dcache_dirty(page)) { -- addr = (unsigned long) page_address(page); -+ if (Page_dcache_dirty(page)) { -+ if (PageHighMem(page)) -+ addr = (unsigned long)kmap_atomic(page); -+ else -+ addr = (unsigned long)page_address(page); -+ - if (exec || pages_do_alias(addr, address & PAGE_MASK)) - flush_data_cache_page(addr); -+ -+ if (PageHighMem(page)) -+ __kunmap_atomic((void *)addr); -+ - ClearPageDcacheDirty(page); - } - } -diff --git a/arch/mips/vdso/Makefile b/arch/mips/vdso/Makefile -index 1456890..090393a 100644 ---- a/arch/mips/vdso/Makefile -+++ b/arch/mips/vdso/Makefile -@@ -5,10 +5,12 @@ obj-vdso-y := elf.o gettimeofday.o sigreturn.o - ccflags-vdso := \ - $(filter -I%,$(KBUILD_CFLAGS)) \ - $(filter -E%,$(KBUILD_CFLAGS)) \ -+ $(filter -mmicromips,$(KBUILD_CFLAGS)) \ - $(filter -march=%,$(KBUILD_CFLAGS)) - cflags-vdso := $(ccflags-vdso) \ - $(filter -W%,$(filter-out -Wa$(comma)%,$(KBUILD_CFLAGS))) \ -- -O2 -g -fPIC -fno-common -fno-builtin -G 0 -DDISABLE_BRANCH_PROFILING \ -+ -O2 -g -fPIC -fno-strict-aliasing -fno-common -fno-builtin -G 0 \ -+ -DDISABLE_BRANCH_PROFILING \ - $(call cc-option, -fno-stack-protector) - aflags-vdso := $(ccflags-vdso) \ - $(filter -I%,$(KBUILD_CFLAGS)) \ -diff --git a/arch/parisc/include/asm/uaccess.h b/arch/parisc/include/asm/uaccess.h -index 0abdd4c..1960b87 100644 ---- a/arch/parisc/include/asm/uaccess.h -+++ b/arch/parisc/include/asm/uaccess.h -@@ -76,6 +76,7 @@ struct exception_table_entry { - */ - struct exception_data { - unsigned long fault_ip; -+ unsigned long fault_gp; - unsigned long fault_space; - unsigned long fault_addr; - }; -diff --git a/arch/parisc/kernel/asm-offsets.c b/arch/parisc/kernel/asm-offsets.c -index d2f6257..78d30d2 100644 ---- a/arch/parisc/kernel/asm-offsets.c -+++ b/arch/parisc/kernel/asm-offsets.c -@@ -299,6 +299,7 @@ int main(void) - #endif - BLANK(); - DEFINE(EXCDATA_IP, offsetof(struct exception_data, fault_ip)); -+ DEFINE(EXCDATA_GP, offsetof(struct exception_data, fault_gp)); - DEFINE(EXCDATA_SPACE, offsetof(struct exception_data, fault_space)); - DEFINE(EXCDATA_ADDR, offsetof(struct exception_data, fault_addr)); - BLANK(); -diff --git a/arch/parisc/kernel/parisc_ksyms.c b/arch/parisc/kernel/parisc_ksyms.c -index 568b2c6..3cad8aa 100644 ---- a/arch/parisc/kernel/parisc_ksyms.c -+++ b/arch/parisc/kernel/parisc_ksyms.c -@@ -47,11 +47,11 @@ EXPORT_SYMBOL(__cmpxchg_u64); - EXPORT_SYMBOL(lclear_user); - EXPORT_SYMBOL(lstrnlen_user); - --/* Global fixups */ --extern void fixup_get_user_skip_1(void); --extern void fixup_get_user_skip_2(void); --extern void fixup_put_user_skip_1(void); --extern void fixup_put_user_skip_2(void); -+/* Global fixups - defined as int to avoid creation of function pointers */ -+extern int fixup_get_user_skip_1; -+extern int fixup_get_user_skip_2; -+extern int fixup_put_user_skip_1; -+extern int fixup_put_user_skip_2; - EXPORT_SYMBOL(fixup_get_user_skip_1); - EXPORT_SYMBOL(fixup_get_user_skip_2); - EXPORT_SYMBOL(fixup_put_user_skip_1); -diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c -index 553b098..77e2262 100644 ---- a/arch/parisc/kernel/traps.c -+++ b/arch/parisc/kernel/traps.c -@@ -798,6 +798,9 @@ void notrace handle_interruption(int code, struct pt_regs *regs) - - if (fault_space == 0 && !faulthandler_disabled()) - { -+ /* Clean up and return if in exception table. */ -+ if (fixup_exception(regs)) -+ return; - pdc_chassis_send_status(PDC_CHASSIS_DIRECT_PANIC); - parisc_terminate("Kernel Fault", regs, code, fault_address); - } -diff --git a/arch/parisc/kernel/unaligned.c b/arch/parisc/kernel/unaligned.c -index d7c0acb..8d49614 100644 ---- a/arch/parisc/kernel/unaligned.c -+++ b/arch/parisc/kernel/unaligned.c -@@ -666,7 +666,7 @@ void handle_unaligned(struct pt_regs *regs) - break; - } - -- if (modify && R1(regs->iir)) -+ if (ret == 0 && modify && R1(regs->iir)) - regs->gr[R1(regs->iir)] = newbase; - - -@@ -677,6 +677,14 @@ void handle_unaligned(struct pt_regs *regs) - - if (ret) - { -+ /* -+ * The unaligned handler failed. -+ * If we were called by __get_user() or __put_user() jump -+ * to it's exception fixup handler instead of crashing. -+ */ -+ if (!user_mode(regs) && fixup_exception(regs)) -+ return; -+ - printk(KERN_CRIT "Unaligned handler failed, ret = %d\n", ret); - die_if_kernel("Unaligned data reference", regs, 28); - -diff --git a/arch/parisc/lib/fixup.S b/arch/parisc/lib/fixup.S -index 536ef66..1052b74 100644 ---- a/arch/parisc/lib/fixup.S -+++ b/arch/parisc/lib/fixup.S -@@ -26,6 +26,7 @@ - - #ifdef CONFIG_SMP - .macro get_fault_ip t1 t2 -+ loadgp - addil LT%__per_cpu_offset,%r27 - LDREG RT%__per_cpu_offset(%r1),\t1 - /* t2 = smp_processor_id() */ -@@ -40,14 +41,19 @@ - LDREG RT%exception_data(%r1),\t1 - /* t1 = this_cpu_ptr(&exception_data) */ - add,l \t1,\t2,\t1 -+ /* %r27 = t1->fault_gp - restore gp */ -+ LDREG EXCDATA_GP(\t1), %r27 - /* t1 = t1->fault_ip */ - LDREG EXCDATA_IP(\t1), \t1 - .endm - #else - .macro get_fault_ip t1 t2 -+ loadgp - /* t1 = this_cpu_ptr(&exception_data) */ - addil LT%exception_data,%r27 - LDREG RT%exception_data(%r1),\t2 -+ /* %r27 = t2->fault_gp - restore gp */ -+ LDREG EXCDATA_GP(\t2), %r27 - /* t1 = t2->fault_ip */ - LDREG EXCDATA_IP(\t2), \t1 - .endm -diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c -index a762864..f906444 100644 ---- a/arch/parisc/mm/fault.c -+++ b/arch/parisc/mm/fault.c -@@ -151,6 +151,7 @@ int fixup_exception(struct pt_regs *regs) - struct exception_data *d; - d = this_cpu_ptr(&exception_data); - d->fault_ip = regs->iaoq[0]; -+ d->fault_gp = regs->gr[27]; - d->fault_space = regs->isr; - d->fault_addr = regs->ior; - -diff --git a/arch/powerpc/include/asm/kvm_host.h b/arch/powerpc/include/asm/kvm_host.h -index b439518..f8673ff 100644 ---- a/arch/powerpc/include/asm/kvm_host.h -+++ b/arch/powerpc/include/asm/kvm_host.h -@@ -286,7 +286,7 @@ struct kvmppc_vcore { - struct list_head runnable_threads; - struct list_head preempt_list; - spinlock_t lock; -- struct swait_head wq; -+ struct swait_queue_head wq; - spinlock_t stoltb_lock; /* protects stolen_tb and preempt_tb */ - u64 stolen_tb; - u64 preempt_tb; -@@ -626,7 +626,7 @@ struct kvm_vcpu_arch { - u8 prodded; - u32 last_inst; - -- struct swait_head *wqp; -+ struct swait_queue_head *wqp; - struct kvmppc_vcore *vcore; - int ret; - int trap; -diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h -index 2220f7a..070fa85 100644 ---- a/arch/powerpc/include/asm/reg.h -+++ b/arch/powerpc/include/asm/reg.h -@@ -707,7 +707,7 @@ - #define MMCR0_FCWAIT 0x00000002UL /* freeze counter in WAIT state */ - #define MMCR0_FCHV 0x00000001UL /* freeze conditions in hypervisor mode */ - #define SPRN_MMCR1 798 --#define SPRN_MMCR2 769 -+#define SPRN_MMCR2 785 - #define SPRN_MMCRA 0x312 - #define MMCRA_SDSYNC 0x80000000UL /* SDAR synced with SIAR */ - #define MMCRA_SDAR_DCACHE_MISS 0x40000000UL -@@ -744,13 +744,13 @@ - #define SPRN_PMC6 792 - #define SPRN_PMC7 793 - #define SPRN_PMC8 794 --#define SPRN_SIAR 780 --#define SPRN_SDAR 781 - #define SPRN_SIER 784 - #define SIER_SIPR 0x2000000 /* Sampled MSR_PR */ - #define SIER_SIHV 0x1000000 /* Sampled MSR_HV */ - #define SIER_SIAR_VALID 0x0400000 /* SIAR contents valid */ - #define SIER_SDAR_VALID 0x0200000 /* SDAR contents valid */ -+#define SPRN_SIAR 796 -+#define SPRN_SDAR 797 - #define SPRN_TACR 888 - #define SPRN_TCSCR 889 - #define SPRN_CSIGR 890 -diff --git a/arch/powerpc/include/asm/word-at-a-time.h b/arch/powerpc/include/asm/word-at-a-time.h -index e4396a7..4afe66a 100644 ---- a/arch/powerpc/include/asm/word-at-a-time.h -+++ b/arch/powerpc/include/asm/word-at-a-time.h -@@ -82,7 +82,7 @@ static inline unsigned long create_zero_mask(unsigned long bits) - "andc %1,%1,%2\n\t" - "popcntd %0,%1" - : "=r" (leading_zero_bits), "=&r" (trailing_zero_bit_mask) -- : "r" (bits)); -+ : "b" (bits)); - - return leading_zero_bits; - } -diff --git a/arch/powerpc/include/uapi/asm/cputable.h b/arch/powerpc/include/uapi/asm/cputable.h -index 4368604..2734c00 100644 ---- a/arch/powerpc/include/uapi/asm/cputable.h -+++ b/arch/powerpc/include/uapi/asm/cputable.h -@@ -31,6 +31,7 @@ - #define PPC_FEATURE_PSERIES_PERFMON_COMPAT \ - 0x00000040 - -+/* Reserved - do not use 0x00000004 */ - #define PPC_FEATURE_TRUE_LE 0x00000002 - #define PPC_FEATURE_PPC_LE 0x00000001 - -diff --git a/arch/powerpc/kernel/eeh.c b/arch/powerpc/kernel/eeh.c -index 40e4d4a..b34e8a5 100644 ---- a/arch/powerpc/kernel/eeh.c -+++ b/arch/powerpc/kernel/eeh.c -@@ -1072,7 +1072,7 @@ void eeh_add_device_early(struct pci_dn *pdn) - struct pci_controller *phb; - struct eeh_dev *edev = pdn_to_eeh_dev(pdn); - -- if (!edev || !eeh_enabled()) -+ if (!edev) - return; - - if (!eeh_has_flag(EEH_PROBE_MODE_DEVTREE)) -diff --git a/arch/powerpc/kernel/eeh_driver.c b/arch/powerpc/kernel/eeh_driver.c -index 52c1e27..247a0dc 100644 ---- a/arch/powerpc/kernel/eeh_driver.c -+++ b/arch/powerpc/kernel/eeh_driver.c -@@ -166,6 +166,16 @@ static void *eeh_dev_save_state(void *data, void *userdata) - if (!edev) - return NULL; - -+ /* -+ * We cannot access the config space on some adapters. -+ * Otherwise, it will cause fenced PHB. We don't save -+ * the content in their config space and will restore -+ * from the initial config space saved when the EEH -+ * device is created. -+ */ -+ if (edev->pe && (edev->pe->state & EEH_PE_CFG_RESTRICTED)) -+ return NULL; -+ - pdev = eeh_dev_to_pci_dev(edev); - if (!pdev) - return NULL; -@@ -305,6 +315,19 @@ static void *eeh_dev_restore_state(void *data, void *userdata) - if (!edev) - return NULL; - -+ /* -+ * The content in the config space isn't saved because -+ * the blocked config space on some adapters. We have -+ * to restore the initial saved config space when the -+ * EEH device is created. -+ */ -+ if (edev->pe && (edev->pe->state & EEH_PE_CFG_RESTRICTED)) { -+ if (list_is_last(&edev->list, &edev->pe->edevs)) -+ eeh_pe_restore_bars(edev->pe); -+ -+ return NULL; -+ } -+ - pdev = eeh_dev_to_pci_dev(edev); - if (!pdev) - return NULL; -@@ -504,9 +527,6 @@ int eeh_pe_reset_and_recover(struct eeh_pe *pe) - /* Save states */ - eeh_pe_dev_traverse(pe, eeh_dev_save_state, NULL); - -- /* Report error */ -- eeh_pe_dev_traverse(pe, eeh_report_error, &result); -- - /* Issue reset */ - ret = eeh_reset_pe(pe); - if (ret) { -diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S -index 0a0399c..b81ccc5 100644 ---- a/arch/powerpc/kernel/exceptions-64s.S -+++ b/arch/powerpc/kernel/exceptions-64s.S -@@ -962,11 +962,6 @@ hv_facility_unavailable_relon_trampoline: - #endif - STD_RELON_EXCEPTION_PSERIES(0x5700, 0x1700, altivec_assist) - -- /* Other future vectors */ -- .align 7 -- .globl __end_interrupts --__end_interrupts: -- - .align 7 - system_call_entry: - b system_call_common -@@ -1253,6 +1248,17 @@ __end_handlers: - STD_RELON_EXCEPTION_PSERIES_OOL(0xf60, facility_unavailable) - STD_RELON_EXCEPTION_HV_OOL(0xf80, hv_facility_unavailable) - -+ /* -+ * The __end_interrupts marker must be past the out-of-line (OOL) -+ * handlers, so that they are copied to real address 0x100 when running -+ * a relocatable kernel. This ensures they can be reached from the short -+ * trampoline handlers (like 0x4f00, 0x4f20, etc.) which branch -+ * directly, without using LOAD_HANDLER(). -+ */ -+ .align 7 -+ .globl __end_interrupts -+__end_interrupts: -+ - #if defined(CONFIG_PPC_PSERIES) || defined(CONFIG_PPC_POWERNV) - /* - * Data area reserved for FWNMI option. -diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c -index ef2ad2d..646bf4d 100644 ---- a/arch/powerpc/kernel/process.c -+++ b/arch/powerpc/kernel/process.c -@@ -569,24 +569,6 @@ static void tm_reclaim_thread(struct thread_struct *thr, - if (!MSR_TM_SUSPENDED(mfmsr())) - return; - -- /* -- * Use the current MSR TM suspended bit to track if we have -- * checkpointed state outstanding. -- * On signal delivery, we'd normally reclaim the checkpointed -- * state to obtain stack pointer (see:get_tm_stackpointer()). -- * This will then directly return to userspace without going -- * through __switch_to(). However, if the stack frame is bad, -- * we need to exit this thread which calls __switch_to() which -- * will again attempt to reclaim the already saved tm state. -- * Hence we need to check that we've not already reclaimed -- * this state. -- * We do this using the current MSR, rather tracking it in -- * some specific thread_struct bit, as it has the additional -- * benifit of checking for a potential TM bad thing exception. -- */ -- if (!MSR_TM_SUSPENDED(mfmsr())) -- return; -- - tm_reclaim(thr, thr->regs->msr, cause); - - /* Having done the reclaim, we now have the checkpointed -diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c -index 7030b03..a15fe1d 100644 ---- a/arch/powerpc/kernel/prom.c -+++ b/arch/powerpc/kernel/prom.c -@@ -148,23 +148,25 @@ static struct ibm_pa_feature { - unsigned long cpu_features; /* CPU_FTR_xxx bit */ - unsigned long mmu_features; /* MMU_FTR_xxx bit */ - unsigned int cpu_user_ftrs; /* PPC_FEATURE_xxx bit */ -+ unsigned int cpu_user_ftrs2; /* PPC_FEATURE2_xxx bit */ - unsigned char pabyte; /* byte number in ibm,pa-features */ - unsigned char pabit; /* bit number (big-endian) */ - unsigned char invert; /* if 1, pa bit set => clear feature */ - } ibm_pa_features[] __initdata = { -- {0, 0, PPC_FEATURE_HAS_MMU, 0, 0, 0}, -- {0, 0, PPC_FEATURE_HAS_FPU, 0, 1, 0}, -- {CPU_FTR_CTRL, 0, 0, 0, 3, 0}, -- {CPU_FTR_NOEXECUTE, 0, 0, 0, 6, 0}, -- {CPU_FTR_NODSISRALIGN, 0, 0, 1, 1, 1}, -- {0, MMU_FTR_CI_LARGE_PAGE, 0, 1, 2, 0}, -- {CPU_FTR_REAL_LE, PPC_FEATURE_TRUE_LE, 5, 0, 0}, -+ {0, 0, PPC_FEATURE_HAS_MMU, 0, 0, 0, 0}, -+ {0, 0, PPC_FEATURE_HAS_FPU, 0, 0, 1, 0}, -+ {CPU_FTR_CTRL, 0, 0, 0, 0, 3, 0}, -+ {CPU_FTR_NOEXECUTE, 0, 0, 0, 0, 6, 0}, -+ {CPU_FTR_NODSISRALIGN, 0, 0, 0, 1, 1, 1}, -+ {0, MMU_FTR_CI_LARGE_PAGE, 0, 0, 1, 2, 0}, -+ {CPU_FTR_REAL_LE, 0, PPC_FEATURE_TRUE_LE, 0, 5, 0, 0}, - /* -- * If the kernel doesn't support TM (ie. CONFIG_PPC_TRANSACTIONAL_MEM=n), -- * we don't want to turn on CPU_FTR_TM here, so we use CPU_FTR_TM_COMP -- * which is 0 if the kernel doesn't support TM. -+ * If the kernel doesn't support TM (ie CONFIG_PPC_TRANSACTIONAL_MEM=n), -+ * we don't want to turn on TM here, so we use the *_COMP versions -+ * which are 0 if the kernel doesn't support TM. - */ -- {CPU_FTR_TM_COMP, 0, 0, 22, 0, 0}, -+ {CPU_FTR_TM_COMP, 0, 0, -+ PPC_FEATURE2_HTM_COMP|PPC_FEATURE2_HTM_NOSC_COMP, 22, 0, 0}, - }; - - static void __init scan_features(unsigned long node, const unsigned char *ftrs, -@@ -195,10 +197,12 @@ static void __init scan_features(unsigned long node, const unsigned char *ftrs, - if (bit ^ fp->invert) { - cur_cpu_spec->cpu_features |= fp->cpu_features; - cur_cpu_spec->cpu_user_features |= fp->cpu_user_ftrs; -+ cur_cpu_spec->cpu_user_features2 |= fp->cpu_user_ftrs2; - cur_cpu_spec->mmu_features |= fp->mmu_features; - } else { - cur_cpu_spec->cpu_features &= ~fp->cpu_features; - cur_cpu_spec->cpu_user_features &= ~fp->cpu_user_ftrs; -+ cur_cpu_spec->cpu_user_features2 &= ~fp->cpu_user_ftrs2; - cur_cpu_spec->mmu_features &= ~fp->mmu_features; - } - } -diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c -index 92dea8d..e52b82b 100644 ---- a/arch/powerpc/kernel/prom_init.c -+++ b/arch/powerpc/kernel/prom_init.c -@@ -655,6 +655,7 @@ unsigned char ibm_architecture_vec[] = { - W(0xffff0000), W(0x003e0000), /* POWER6 */ - W(0xffff0000), W(0x003f0000), /* POWER7 */ - W(0xffff0000), W(0x004b0000), /* POWER8E */ -+ W(0xffff0000), W(0x004c0000), /* POWER8NVL */ - W(0xffff0000), W(0x004d0000), /* POWER8 */ - W(0xffffffff), W(0x0f000004), /* all 2.07-compliant */ - W(0xffffffff), W(0x0f000003), /* all 2.06-compliant */ -diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c -index 32be32b..df34a64 100644 ---- a/arch/powerpc/kvm/book3s_hv.c -+++ b/arch/powerpc/kvm/book3s_hv.c -@@ -114,11 +114,11 @@ static bool kvmppc_ipi_thread(int cpu) - static void kvmppc_fast_vcpu_kick_hv(struct kvm_vcpu *vcpu) - { - int cpu; -- struct swait_head *wqp; -+ struct swait_queue_head *wqp; - - wqp = kvm_arch_vcpu_wq(vcpu); -- if (swaitqueue_active(wqp)) { -- swait_wake_interruptible(wqp); -+ if (swait_active(wqp)) { -+ swake_up(wqp); - ++vcpu->stat.halt_wakeup; - } - -@@ -707,8 +707,8 @@ int kvmppc_pseries_do_hcall(struct kvm_vcpu *vcpu) - tvcpu->arch.prodded = 1; - smp_mb(); - if (vcpu->arch.ceded) { -- if (swaitqueue_active(&vcpu->wq)) { -- swait_wake_interruptible(&vcpu->wq); -+ if (swait_active(&vcpu->wq)) { -+ swake_up(&vcpu->wq); - vcpu->stat.halt_wakeup++; - } - } -@@ -1447,7 +1447,7 @@ static struct kvmppc_vcore *kvmppc_vcore_create(struct kvm *kvm, int core) - INIT_LIST_HEAD(&vcore->runnable_threads); - spin_lock_init(&vcore->lock); - spin_lock_init(&vcore->stoltb_lock); -- init_swait_head(&vcore->wq); -+ init_swait_queue_head(&vcore->wq); - vcore->preempt_tb = TB_NIL; - vcore->lpcr = kvm->arch.lpcr; - vcore->first_vcpuid = core * threads_per_subcore; -@@ -2519,9 +2519,9 @@ static void kvmppc_vcore_blocked(struct kvmppc_vcore *vc) - { - struct kvm_vcpu *vcpu; - int do_sleep = 1; -- DEFINE_SWAITER(wait); -+ DECLARE_SWAITQUEUE(wait); - -- swait_prepare(&vc->wq, &wait, TASK_INTERRUPTIBLE); -+ prepare_to_swait(&vc->wq, &wait, TASK_INTERRUPTIBLE); - - /* - * Check one last time for pending exceptions and ceded state after -@@ -2535,7 +2535,7 @@ static void kvmppc_vcore_blocked(struct kvmppc_vcore *vc) - } - - if (!do_sleep) { -- swait_finish(&vc->wq, &wait); -+ finish_swait(&vc->wq, &wait); - return; - } - -@@ -2543,7 +2543,7 @@ static void kvmppc_vcore_blocked(struct kvmppc_vcore *vc) - trace_kvmppc_vcore_blocked(vc, 0); - spin_unlock(&vc->lock); - schedule(); -- swait_finish(&vc->wq, &wait); -+ finish_swait(&vc->wq, &wait); - spin_lock(&vc->lock); - vc->vcore_state = VCORE_INACTIVE; - trace_kvmppc_vcore_blocked(vc, 1); -@@ -2599,7 +2599,7 @@ static int kvmppc_run_vcpu(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu) - kvmppc_start_thread(vcpu, vc); - trace_kvm_guest_enter(vcpu); - } else if (vc->vcore_state == VCORE_SLEEPING) { -- swait_wake(&vc->wq); -+ swake_up(&vc->wq); - } - - } -diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c -index 9833fee..807f159 100644 ---- a/arch/powerpc/mm/hugetlbpage.c -+++ b/arch/powerpc/mm/hugetlbpage.c -@@ -486,13 +486,13 @@ static void hugepd_free(struct mmu_gather *tlb, void *hugepte) - { - struct hugepd_freelist **batchp; - -- batchp = this_cpu_ptr(&hugepd_freelist_cur); -+ batchp = &get_cpu_var(hugepd_freelist_cur); - - if (atomic_read(&tlb->mm->mm_users) < 2 || - cpumask_equal(mm_cpumask(tlb->mm), - cpumask_of(smp_processor_id()))) { - kmem_cache_free(hugepte_cache, hugepte); -- put_cpu_var(hugepd_freelist_cur); -+ put_cpu_var(hugepd_freelist_cur); - return; - } - -diff --git a/arch/powerpc/platforms/pseries/eeh_pseries.c b/arch/powerpc/platforms/pseries/eeh_pseries.c -index ac3ffd9..405baaf 100644 ---- a/arch/powerpc/platforms/pseries/eeh_pseries.c -+++ b/arch/powerpc/platforms/pseries/eeh_pseries.c -@@ -615,29 +615,50 @@ static int pseries_eeh_configure_bridge(struct eeh_pe *pe) - { - int config_addr; - int ret; -+ /* Waiting 0.2s maximum before skipping configuration */ -+ int max_wait = 200; - - /* Figure out the PE address */ - config_addr = pe->config_addr; - if (pe->addr) - config_addr = pe->addr; - -- /* Use new configure-pe function, if supported */ -- if (ibm_configure_pe != RTAS_UNKNOWN_SERVICE) { -- ret = rtas_call(ibm_configure_pe, 3, 1, NULL, -- config_addr, BUID_HI(pe->phb->buid), -- BUID_LO(pe->phb->buid)); -- } else if (ibm_configure_bridge != RTAS_UNKNOWN_SERVICE) { -- ret = rtas_call(ibm_configure_bridge, 3, 1, NULL, -- config_addr, BUID_HI(pe->phb->buid), -- BUID_LO(pe->phb->buid)); -- } else { -- return -EFAULT; -- } -+ while (max_wait > 0) { -+ /* Use new configure-pe function, if supported */ -+ if (ibm_configure_pe != RTAS_UNKNOWN_SERVICE) { -+ ret = rtas_call(ibm_configure_pe, 3, 1, NULL, -+ config_addr, BUID_HI(pe->phb->buid), -+ BUID_LO(pe->phb->buid)); -+ } else if (ibm_configure_bridge != RTAS_UNKNOWN_SERVICE) { -+ ret = rtas_call(ibm_configure_bridge, 3, 1, NULL, -+ config_addr, BUID_HI(pe->phb->buid), -+ BUID_LO(pe->phb->buid)); -+ } else { -+ return -EFAULT; -+ } - -- if (ret) -- pr_warn("%s: Unable to configure bridge PHB#%d-PE#%x (%d)\n", -- __func__, pe->phb->global_number, pe->addr, ret); -+ if (!ret) -+ return ret; -+ -+ /* -+ * If RTAS returns a delay value that's above 100ms, cut it -+ * down to 100ms in case firmware made a mistake. For more -+ * on how these delay values work see rtas_busy_delay_time -+ */ -+ if (ret > RTAS_EXTENDED_DELAY_MIN+2 && -+ ret <= RTAS_EXTENDED_DELAY_MAX) -+ ret = RTAS_EXTENDED_DELAY_MIN+2; -+ -+ max_wait -= rtas_busy_delay_time(ret); -+ -+ if (max_wait < 0) -+ break; -+ -+ rtas_busy_delay(ret); -+ } - -+ pr_warn("%s: Unable to configure bridge PHB#%d-PE#%x (%d)\n", -+ __func__, pe->phb->global_number, pe->addr, ret); - return ret; - } - -diff --git a/arch/s390/include/asm/kvm_host.h b/arch/s390/include/asm/kvm_host.h -index 2a84c76..bbdc539 100644 ---- a/arch/s390/include/asm/kvm_host.h -+++ b/arch/s390/include/asm/kvm_host.h -@@ -427,7 +427,7 @@ struct kvm_s390_irq_payload { - struct kvm_s390_local_interrupt { - spinlock_t lock; - struct kvm_s390_float_interrupt *float_int; -- struct swait_head *wq; -+ struct swait_queue_head *wq; - atomic_t *cpuflags; - DECLARE_BITMAP(sigp_emerg_pending, KVM_MAX_VCPUS); - struct kvm_s390_irq_payload irq; -diff --git a/arch/s390/include/asm/mmu.h b/arch/s390/include/asm/mmu.h -index d29ad95..081b2ad 100644 ---- a/arch/s390/include/asm/mmu.h -+++ b/arch/s390/include/asm/mmu.h -@@ -11,7 +11,7 @@ typedef struct { - spinlock_t list_lock; - struct list_head pgtable_list; - struct list_head gmap_list; -- unsigned long asce_bits; -+ unsigned long asce; - unsigned long asce_limit; - unsigned long vdso_base; - /* The mmu context allocates 4K page tables. */ -diff --git a/arch/s390/include/asm/mmu_context.h b/arch/s390/include/asm/mmu_context.h -index e485817..22877c9 100644 ---- a/arch/s390/include/asm/mmu_context.h -+++ b/arch/s390/include/asm/mmu_context.h -@@ -26,12 +26,28 @@ static inline int init_new_context(struct task_struct *tsk, - mm->context.has_pgste = 0; - mm->context.use_skey = 0; - #endif -- if (mm->context.asce_limit == 0) { -+ switch (mm->context.asce_limit) { -+ case 1UL << 42: -+ /* -+ * forked 3-level task, fall through to set new asce with new -+ * mm->pgd -+ */ -+ case 0: - /* context created by exec, set asce limit to 4TB */ -- mm->context.asce_bits = _ASCE_TABLE_LENGTH | -- _ASCE_USER_BITS | _ASCE_TYPE_REGION3; - mm->context.asce_limit = STACK_TOP_MAX; -- } else if (mm->context.asce_limit == (1UL << 31)) { -+ mm->context.asce = __pa(mm->pgd) | _ASCE_TABLE_LENGTH | -+ _ASCE_USER_BITS | _ASCE_TYPE_REGION3; -+ break; -+ case 1UL << 53: -+ /* forked 4-level task, set new asce with new mm->pgd */ -+ mm->context.asce = __pa(mm->pgd) | _ASCE_TABLE_LENGTH | -+ _ASCE_USER_BITS | _ASCE_TYPE_REGION2; -+ break; -+ case 1UL << 31: -+ /* forked 2-level compat task, set new asce with new mm->pgd */ -+ mm->context.asce = __pa(mm->pgd) | _ASCE_TABLE_LENGTH | -+ _ASCE_USER_BITS | _ASCE_TYPE_SEGMENT; -+ /* pgd_alloc() did not increase mm->nr_pmds */ - mm_inc_nr_pmds(mm); - } - crst_table_init((unsigned long *) mm->pgd, pgd_entry_type(mm)); -@@ -42,7 +58,7 @@ static inline int init_new_context(struct task_struct *tsk, - - static inline void set_user_asce(struct mm_struct *mm) - { -- S390_lowcore.user_asce = mm->context.asce_bits | __pa(mm->pgd); -+ S390_lowcore.user_asce = mm->context.asce; - if (current->thread.mm_segment.ar4) - __ctl_load(S390_lowcore.user_asce, 7, 7); - set_cpu_flag(CIF_ASCE); -@@ -71,7 +87,7 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next, - { - int cpu = smp_processor_id(); - -- S390_lowcore.user_asce = next->context.asce_bits | __pa(next->pgd); -+ S390_lowcore.user_asce = next->context.asce; - if (prev == next) - return; - if (MACHINE_HAS_TLB_LC) -diff --git a/arch/s390/include/asm/pci.h b/arch/s390/include/asm/pci.h -index c873e68..6dafabb 100644 ---- a/arch/s390/include/asm/pci.h -+++ b/arch/s390/include/asm/pci.h -@@ -45,7 +45,8 @@ struct zpci_fmb { - u64 rpcit_ops; - u64 dma_rbytes; - u64 dma_wbytes; --} __packed __aligned(16); -+ u64 pad[2]; -+} __packed __aligned(128); - - enum zpci_state { - ZPCI_FN_STATE_RESERVED, -diff --git a/arch/s390/include/asm/pgalloc.h b/arch/s390/include/asm/pgalloc.h -index d7cc79f..5991cdcb5 100644 ---- a/arch/s390/include/asm/pgalloc.h -+++ b/arch/s390/include/asm/pgalloc.h -@@ -56,8 +56,8 @@ static inline unsigned long pgd_entry_type(struct mm_struct *mm) - return _REGION2_ENTRY_EMPTY; - } - --int crst_table_upgrade(struct mm_struct *, unsigned long limit); --void crst_table_downgrade(struct mm_struct *, unsigned long limit); -+int crst_table_upgrade(struct mm_struct *); -+void crst_table_downgrade(struct mm_struct *); - - static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long address) - { -diff --git a/arch/s390/include/asm/processor.h b/arch/s390/include/asm/processor.h -index b16c3d0..c1ea67d 100644 ---- a/arch/s390/include/asm/processor.h -+++ b/arch/s390/include/asm/processor.h -@@ -163,7 +163,7 @@ extern __vector128 init_task_fpu_regs[__NUM_VXRS]; - regs->psw.mask = PSW_USER_BITS | PSW_MASK_BA; \ - regs->psw.addr = new_psw | PSW_ADDR_AMODE; \ - regs->gprs[15] = new_stackp; \ -- crst_table_downgrade(current->mm, 1UL << 31); \ -+ crst_table_downgrade(current->mm); \ - execve_tail(); \ - } while (0) - -diff --git a/arch/s390/include/asm/tlbflush.h b/arch/s390/include/asm/tlbflush.h -index ca148f7..a2e6ef3 100644 ---- a/arch/s390/include/asm/tlbflush.h -+++ b/arch/s390/include/asm/tlbflush.h -@@ -110,8 +110,7 @@ static inline void __tlb_flush_asce(struct mm_struct *mm, unsigned long asce) - static inline void __tlb_flush_kernel(void) - { - if (MACHINE_HAS_IDTE) -- __tlb_flush_idte((unsigned long) init_mm.pgd | -- init_mm.context.asce_bits); -+ __tlb_flush_idte(init_mm.context.asce); - else - __tlb_flush_global(); - } -@@ -133,8 +132,7 @@ static inline void __tlb_flush_asce(struct mm_struct *mm, unsigned long asce) - static inline void __tlb_flush_kernel(void) - { - if (MACHINE_HAS_TLB_LC) -- __tlb_flush_idte_local((unsigned long) init_mm.pgd | -- init_mm.context.asce_bits); -+ __tlb_flush_idte_local(init_mm.context.asce); - else - __tlb_flush_local(); - } -@@ -148,8 +146,7 @@ static inline void __tlb_flush_mm(struct mm_struct * mm) - * only ran on the local cpu. - */ - if (MACHINE_HAS_IDTE && list_empty(&mm->context.gmap_list)) -- __tlb_flush_asce(mm, (unsigned long) mm->pgd | -- mm->context.asce_bits); -+ __tlb_flush_asce(mm, mm->context.asce); - else - __tlb_flush_full(mm); - } -diff --git a/arch/s390/kernel/entry.S b/arch/s390/kernel/entry.S -index 857b652..424e680 100644 ---- a/arch/s390/kernel/entry.S -+++ b/arch/s390/kernel/entry.S -@@ -1197,114 +1197,12 @@ cleanup_critical: - .quad .Lpsw_idle_lpsw - - .Lcleanup_save_fpu_regs: -- TSTMSK __LC_CPU_FLAGS,_CIF_FPU -- bor %r14 -- clg %r9,BASED(.Lcleanup_save_fpu_regs_done) -- jhe 5f -- clg %r9,BASED(.Lcleanup_save_fpu_regs_fp) -- jhe 4f -- clg %r9,BASED(.Lcleanup_save_fpu_regs_vx_high) -- jhe 3f -- clg %r9,BASED(.Lcleanup_save_fpu_regs_vx_low) -- jhe 2f -- clg %r9,BASED(.Lcleanup_save_fpu_fpc_end) -- jhe 1f -- lg %r2,__LC_CURRENT -- aghi %r2,__TASK_thread --0: # Store floating-point controls -- stfpc __THREAD_FPU_fpc(%r2) --1: # Load register save area and check if VX is active -- lg %r3,__THREAD_FPU_regs(%r2) -- TSTMSK __LC_MACHINE_FLAGS,MACHINE_FLAG_VX -- jz 4f # no VX -> store FP regs --2: # Store vector registers (V0-V15) -- VSTM %v0,%v15,0,%r3 # vstm 0,15,0(3) --3: # Store vector registers (V16-V31) -- VSTM %v16,%v31,256,%r3 # vstm 16,31,256(3) -- j 5f # -> done, set CIF_FPU flag --4: # Store floating-point registers -- std 0,0(%r3) -- std 1,8(%r3) -- std 2,16(%r3) -- std 3,24(%r3) -- std 4,32(%r3) -- std 5,40(%r3) -- std 6,48(%r3) -- std 7,56(%r3) -- std 8,64(%r3) -- std 9,72(%r3) -- std 10,80(%r3) -- std 11,88(%r3) -- std 12,96(%r3) -- std 13,104(%r3) -- std 14,112(%r3) -- std 15,120(%r3) --5: # Set CIF_FPU flag -- oi __LC_CPU_FLAGS+7,_CIF_FPU -- lg %r9,48(%r11) # return from save_fpu_regs -+ larl %r9,save_fpu_regs - br %r14 --.Lcleanup_save_fpu_fpc_end: -- .quad .Lsave_fpu_regs_fpc_end --.Lcleanup_save_fpu_regs_vx_low: -- .quad .Lsave_fpu_regs_vx_low --.Lcleanup_save_fpu_regs_vx_high: -- .quad .Lsave_fpu_regs_vx_high --.Lcleanup_save_fpu_regs_fp: -- .quad .Lsave_fpu_regs_fp --.Lcleanup_save_fpu_regs_done: -- .quad .Lsave_fpu_regs_done - - .Lcleanup_load_fpu_regs: -- TSTMSK __LC_CPU_FLAGS,_CIF_FPU -- bnor %r14 -- clg %r9,BASED(.Lcleanup_load_fpu_regs_done) -- jhe 1f -- clg %r9,BASED(.Lcleanup_load_fpu_regs_fp) -- jhe 2f -- clg %r9,BASED(.Lcleanup_load_fpu_regs_vx_high) -- jhe 3f -- clg %r9,BASED(.Lcleanup_load_fpu_regs_vx) -- jhe 4f -- lg %r4,__LC_CURRENT -- aghi %r4,__TASK_thread -- lfpc __THREAD_FPU_fpc(%r4) -- TSTMSK __LC_MACHINE_FLAGS,MACHINE_FLAG_VX -- lg %r4,__THREAD_FPU_regs(%r4) # %r4 <- reg save area -- jz 2f # -> no VX, load FP regs --4: # Load V0 ..V15 registers -- VLM %v0,%v15,0,%r4 --3: # Load V16..V31 registers -- VLM %v16,%v31,256,%r4 -- j 1f --2: # Load floating-point registers -- ld 0,0(%r4) -- ld 1,8(%r4) -- ld 2,16(%r4) -- ld 3,24(%r4) -- ld 4,32(%r4) -- ld 5,40(%r4) -- ld 6,48(%r4) -- ld 7,56(%r4) -- ld 8,64(%r4) -- ld 9,72(%r4) -- ld 10,80(%r4) -- ld 11,88(%r4) -- ld 12,96(%r4) -- ld 13,104(%r4) -- ld 14,112(%r4) -- ld 15,120(%r4) --1: # Clear CIF_FPU bit -- ni __LC_CPU_FLAGS+7,255-_CIF_FPU -- lg %r9,48(%r11) # return from load_fpu_regs -+ larl %r9,load_fpu_regs - br %r14 --.Lcleanup_load_fpu_regs_vx: -- .quad .Lload_fpu_regs_vx --.Lcleanup_load_fpu_regs_vx_high: -- .quad .Lload_fpu_regs_vx_high --.Lcleanup_load_fpu_regs_fp: -- .quad .Lload_fpu_regs_fp --.Lcleanup_load_fpu_regs_done: -- .quad .Lload_fpu_regs_done - - /* - * Integer constants -diff --git a/arch/s390/kernel/head64.S b/arch/s390/kernel/head64.S -index 58b719f..1ad2407 100644 ---- a/arch/s390/kernel/head64.S -+++ b/arch/s390/kernel/head64.S -@@ -16,7 +16,7 @@ - - __HEAD - ENTRY(startup_continue) -- tm __LC_STFL_FAC_LIST+6,0x80 # LPP available ? -+ tm __LC_STFL_FAC_LIST+5,0x80 # LPP available ? - jz 0f - xc __LC_LPP+1(7,0),__LC_LPP+1 # clear lpp and current_pid - mvi __LC_LPP,0x80 # and set LPP_MAGIC -diff --git a/arch/s390/kernel/setup.c b/arch/s390/kernel/setup.c -index c837bca..1f581eb 100644 ---- a/arch/s390/kernel/setup.c -+++ b/arch/s390/kernel/setup.c -@@ -329,6 +329,7 @@ static void __init setup_lowcore(void) - + PAGE_SIZE - STACK_FRAME_OVERHEAD - sizeof(struct pt_regs); - lc->current_task = (unsigned long) init_thread_union.thread_info.task; - lc->thread_info = (unsigned long) &init_thread_union; -+ lc->lpp = LPP_MAGIC; - lc->machine_flags = S390_lowcore.machine_flags; - lc->stfl_fac_list = S390_lowcore.stfl_fac_list; - memcpy(lc->stfle_fac_list, S390_lowcore.stfle_fac_list, -diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c -index 8b4516b..cc862c4 100644 ---- a/arch/s390/kvm/interrupt.c -+++ b/arch/s390/kvm/interrupt.c -@@ -868,13 +868,13 @@ no_timer: - - void kvm_s390_vcpu_wakeup(struct kvm_vcpu *vcpu) - { -- if (swaitqueue_active(&vcpu->wq)) { -+ if (swait_active(&vcpu->wq)) { - /* - * The vcpu gave up the cpu voluntarily, mark it as a good - * yield-candidate. - */ - vcpu->preempted = true; -- swait_wake_interruptible(&vcpu->wq); -+ swake_up(&vcpu->wq); - vcpu->stat.halt_wakeup++; - } - } -diff --git a/arch/s390/mm/init.c b/arch/s390/mm/init.c -index c722400..feff9ca 100644 ---- a/arch/s390/mm/init.c -+++ b/arch/s390/mm/init.c -@@ -89,7 +89,8 @@ void __init paging_init(void) - asce_bits = _ASCE_TYPE_REGION3 | _ASCE_TABLE_LENGTH; - pgd_type = _REGION3_ENTRY_EMPTY; - } -- S390_lowcore.kernel_asce = (__pa(init_mm.pgd) & PAGE_MASK) | asce_bits; -+ init_mm.context.asce = (__pa(init_mm.pgd) & PAGE_MASK) | asce_bits; -+ S390_lowcore.kernel_asce = init_mm.context.asce; - clear_table((unsigned long *) init_mm.pgd, pgd_type, - sizeof(unsigned long)*2048); - vmem_map_init(); -diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c -index ea01477..f2b6b1d 100644 ---- a/arch/s390/mm/mmap.c -+++ b/arch/s390/mm/mmap.c -@@ -174,7 +174,7 @@ int s390_mmap_check(unsigned long addr, unsigned long len, unsigned long flags) - if (!(flags & MAP_FIXED)) - addr = 0; - if ((addr + len) >= TASK_SIZE) -- return crst_table_upgrade(current->mm, 1UL << 53); -+ return crst_table_upgrade(current->mm); - return 0; - } - -@@ -191,7 +191,7 @@ s390_get_unmapped_area(struct file *filp, unsigned long addr, - return area; - if (area == -ENOMEM && !is_compat_task() && TASK_SIZE < (1UL << 53)) { - /* Upgrade the page table to 4 levels and retry. */ -- rc = crst_table_upgrade(mm, 1UL << 53); -+ rc = crst_table_upgrade(mm); - if (rc) - return (unsigned long) rc; - area = arch_get_unmapped_area(filp, addr, len, pgoff, flags); -@@ -213,7 +213,7 @@ s390_get_unmapped_area_topdown(struct file *filp, const unsigned long addr, - return area; - if (area == -ENOMEM && !is_compat_task() && TASK_SIZE < (1UL << 53)) { - /* Upgrade the page table to 4 levels and retry. */ -- rc = crst_table_upgrade(mm, 1UL << 53); -+ rc = crst_table_upgrade(mm); - if (rc) - return (unsigned long) rc; - area = arch_get_unmapped_area_topdown(filp, addr, len, -diff --git a/arch/s390/mm/pgtable.c b/arch/s390/mm/pgtable.c -index 54ef3bc..471a370 100644 ---- a/arch/s390/mm/pgtable.c -+++ b/arch/s390/mm/pgtable.c -@@ -49,81 +49,52 @@ static void __crst_table_upgrade(void *arg) - __tlb_flush_local(); - } - --int crst_table_upgrade(struct mm_struct *mm, unsigned long limit) -+int crst_table_upgrade(struct mm_struct *mm) - { - unsigned long *table, *pgd; -- unsigned long entry; -- int flush; - -- BUG_ON(limit > (1UL << 53)); -- flush = 0; --repeat: -+ /* upgrade should only happen from 3 to 4 levels */ -+ BUG_ON(mm->context.asce_limit != (1UL << 42)); -+ - table = crst_table_alloc(mm); - if (!table) - return -ENOMEM; -+ - spin_lock_bh(&mm->page_table_lock); -- if (mm->context.asce_limit < limit) { -- pgd = (unsigned long *) mm->pgd; -- if (mm->context.asce_limit <= (1UL << 31)) { -- entry = _REGION3_ENTRY_EMPTY; -- mm->context.asce_limit = 1UL << 42; -- mm->context.asce_bits = _ASCE_TABLE_LENGTH | -- _ASCE_USER_BITS | -- _ASCE_TYPE_REGION3; -- } else { -- entry = _REGION2_ENTRY_EMPTY; -- mm->context.asce_limit = 1UL << 53; -- mm->context.asce_bits = _ASCE_TABLE_LENGTH | -- _ASCE_USER_BITS | -- _ASCE_TYPE_REGION2; -- } -- crst_table_init(table, entry); -- pgd_populate(mm, (pgd_t *) table, (pud_t *) pgd); -- mm->pgd = (pgd_t *) table; -- mm->task_size = mm->context.asce_limit; -- table = NULL; -- flush = 1; -- } -+ pgd = (unsigned long *) mm->pgd; -+ crst_table_init(table, _REGION2_ENTRY_EMPTY); -+ pgd_populate(mm, (pgd_t *) table, (pud_t *) pgd); -+ mm->pgd = (pgd_t *) table; -+ mm->context.asce_limit = 1UL << 53; -+ mm->context.asce = __pa(mm->pgd) | _ASCE_TABLE_LENGTH | -+ _ASCE_USER_BITS | _ASCE_TYPE_REGION2; -+ mm->task_size = mm->context.asce_limit; - spin_unlock_bh(&mm->page_table_lock); -- if (table) -- crst_table_free(mm, table); -- if (mm->context.asce_limit < limit) -- goto repeat; -- if (flush) -- on_each_cpu(__crst_table_upgrade, mm, 0); -+ -+ on_each_cpu(__crst_table_upgrade, mm, 0); - return 0; - } - --void crst_table_downgrade(struct mm_struct *mm, unsigned long limit) -+void crst_table_downgrade(struct mm_struct *mm) - { - pgd_t *pgd; - -+ /* downgrade should only happen from 3 to 2 levels (compat only) */ -+ BUG_ON(mm->context.asce_limit != (1UL << 42)); -+ - if (current->active_mm == mm) { - clear_user_asce(); - __tlb_flush_mm(mm); - } -- while (mm->context.asce_limit > limit) { -- pgd = mm->pgd; -- switch (pgd_val(*pgd) & _REGION_ENTRY_TYPE_MASK) { -- case _REGION_ENTRY_TYPE_R2: -- mm->context.asce_limit = 1UL << 42; -- mm->context.asce_bits = _ASCE_TABLE_LENGTH | -- _ASCE_USER_BITS | -- _ASCE_TYPE_REGION3; -- break; -- case _REGION_ENTRY_TYPE_R3: -- mm->context.asce_limit = 1UL << 31; -- mm->context.asce_bits = _ASCE_TABLE_LENGTH | -- _ASCE_USER_BITS | -- _ASCE_TYPE_SEGMENT; -- break; -- default: -- BUG(); -- } -- mm->pgd = (pgd_t *) (pgd_val(*pgd) & _REGION_ENTRY_ORIGIN); -- mm->task_size = mm->context.asce_limit; -- crst_table_free(mm, (unsigned long *) pgd); -- } -+ -+ pgd = mm->pgd; -+ mm->pgd = (pgd_t *) (pgd_val(*pgd) & _REGION_ENTRY_ORIGIN); -+ mm->context.asce_limit = 1UL << 31; -+ mm->context.asce = __pa(mm->pgd) | _ASCE_TABLE_LENGTH | -+ _ASCE_USER_BITS | _ASCE_TYPE_SEGMENT; -+ mm->task_size = mm->context.asce_limit; -+ crst_table_free(mm, (unsigned long *) pgd); -+ - if (current->active_mm == mm) - set_user_asce(mm); - } -diff --git a/arch/s390/net/bpf_jit.h b/arch/s390/net/bpf_jit.h -index f010c93..fda605d 100644 ---- a/arch/s390/net/bpf_jit.h -+++ b/arch/s390/net/bpf_jit.h -@@ -37,7 +37,7 @@ extern u8 sk_load_word[], sk_load_half[], sk_load_byte[]; - * | | | - * +---------------+ | - * | 8 byte skbp | | -- * R15+170 -> +---------------+ | -+ * R15+176 -> +---------------+ | - * | 8 byte hlen | | - * R15+168 -> +---------------+ | - * | 4 byte align | | -@@ -58,7 +58,7 @@ extern u8 sk_load_word[], sk_load_half[], sk_load_byte[]; - #define STK_OFF (STK_SPACE - STK_160_UNUSED) - #define STK_OFF_TMP 160 /* Offset of tmp buffer on stack */ - #define STK_OFF_HLEN 168 /* Offset of SKB header length on stack */ --#define STK_OFF_SKBP 170 /* Offset of SKB pointer on stack */ -+#define STK_OFF_SKBP 176 /* Offset of SKB pointer on stack */ - - #define STK_OFF_R6 (160 - 11 * 8) /* Offset of r6 on stack */ - #define STK_OFF_TCCNT (160 - 12 * 8) /* Offset of tail_call_cnt on stack */ -diff --git a/arch/s390/net/bpf_jit_comp.c b/arch/s390/net/bpf_jit_comp.c -index 9a0c4c2..0e2919d 100644 ---- a/arch/s390/net/bpf_jit_comp.c -+++ b/arch/s390/net/bpf_jit_comp.c -@@ -45,7 +45,7 @@ struct bpf_jit { - int labels[1]; /* Labels for local jumps */ - }; - --#define BPF_SIZE_MAX 0x7ffff /* Max size for program (20 bit signed displ) */ -+#define BPF_SIZE_MAX 0xffff /* Max size for program (16 bit branches) */ - - #define SEEN_SKB 1 /* skb access */ - #define SEEN_MEM 2 /* use mem[] for temporary storage */ -@@ -446,7 +446,7 @@ static void bpf_jit_prologue(struct bpf_jit *jit, bool is_classic) - emit_load_skb_data_hlen(jit); - if (jit->seen & SEEN_SKB_CHANGE) - /* stg %b1,ST_OFF_SKBP(%r0,%r15) */ -- EMIT6_DISP_LH(0xe3000000, 0x0024, REG_W1, REG_0, REG_15, -+ EMIT6_DISP_LH(0xe3000000, 0x0024, BPF_REG_1, REG_0, REG_15, - STK_OFF_SKBP); - /* Clear A (%b0) and X (%b7) registers for converted BPF programs */ - if (is_classic) { -diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c -index 7ef12a3..1944239 100644 ---- a/arch/s390/pci/pci.c -+++ b/arch/s390/pci/pci.c -@@ -871,8 +871,11 @@ static inline int barsize(u8 size) - - static int zpci_mem_init(void) - { -+ BUILD_BUG_ON(!is_power_of_2(__alignof__(struct zpci_fmb)) || -+ __alignof__(struct zpci_fmb) < sizeof(struct zpci_fmb)); -+ - zdev_fmb_cache = kmem_cache_create("PCI_FMB_cache", sizeof(struct zpci_fmb), -- 16, 0, NULL); -+ __alignof__(struct zpci_fmb), 0, NULL); - if (!zdev_fmb_cache) - goto error_zdev; - -diff --git a/arch/sh/mm/kmap.c b/arch/sh/mm/kmap.c -index ec29e14..bf25d7c 100644 ---- a/arch/sh/mm/kmap.c -+++ b/arch/sh/mm/kmap.c -@@ -36,6 +36,7 @@ void *kmap_coherent(struct page *page, unsigned long addr) - - BUG_ON(!test_bit(PG_dcache_clean, &page->flags)); - -+ preempt_disable(); - pagefault_disable(); - - idx = FIX_CMAP_END - -@@ -64,4 +65,5 @@ void kunmap_coherent(void *kvaddr) - } - - pagefault_enable(); -+ preempt_enable(); - } -diff --git a/arch/sparc/include/asm/head_64.h b/arch/sparc/include/asm/head_64.h -index 10e9dab..f0700cf 100644 ---- a/arch/sparc/include/asm/head_64.h -+++ b/arch/sparc/include/asm/head_64.h -@@ -15,6 +15,10 @@ - - #define PTREGS_OFF (STACK_BIAS + STACKFRAME_SZ) - -+#define RTRAP_PSTATE (PSTATE_TSO|PSTATE_PEF|PSTATE_PRIV|PSTATE_IE) -+#define RTRAP_PSTATE_IRQOFF (PSTATE_TSO|PSTATE_PEF|PSTATE_PRIV) -+#define RTRAP_PSTATE_AG_IRQOFF (PSTATE_TSO|PSTATE_PEF|PSTATE_PRIV|PSTATE_AG) -+ - #define __CHEETAH_ID 0x003e0014 - #define __JALAPENO_ID 0x003e0016 - #define __SERRANO_ID 0x003e0022 -diff --git a/arch/sparc/include/asm/pgtable_64.h b/arch/sparc/include/asm/pgtable_64.h -index 131d36f..408b715 100644 ---- a/arch/sparc/include/asm/pgtable_64.h -+++ b/arch/sparc/include/asm/pgtable_64.h -@@ -375,7 +375,7 @@ static inline pgprot_t pgprot_noncached(pgprot_t prot) - #define pgprot_noncached pgprot_noncached - - #if defined(CONFIG_HUGETLB_PAGE) || defined(CONFIG_TRANSPARENT_HUGEPAGE) --static inline pte_t pte_mkhuge(pte_t pte) -+static inline unsigned long __pte_huge_mask(void) - { - unsigned long mask; - -@@ -390,8 +390,19 @@ static inline pte_t pte_mkhuge(pte_t pte) - : "=r" (mask) - : "i" (_PAGE_SZHUGE_4U), "i" (_PAGE_SZHUGE_4V)); - -- return __pte(pte_val(pte) | mask); -+ return mask; -+} -+ -+static inline pte_t pte_mkhuge(pte_t pte) -+{ -+ return __pte(pte_val(pte) | __pte_huge_mask()); -+} -+ -+static inline bool is_hugetlb_pte(pte_t pte) -+{ -+ return !!(pte_val(pte) & __pte_huge_mask()); - } -+ - #ifdef CONFIG_TRANSPARENT_HUGEPAGE - static inline pmd_t pmd_mkhuge(pmd_t pmd) - { -@@ -403,6 +414,11 @@ static inline pmd_t pmd_mkhuge(pmd_t pmd) - return __pmd(pte_val(pte)); - } - #endif -+#else -+static inline bool is_hugetlb_pte(pte_t pte) -+{ -+ return false; -+} - #endif - - static inline pte_t pte_mkdirty(pte_t pte) -@@ -865,6 +881,19 @@ static inline unsigned long pud_pfn(pud_t pud) - void tlb_batch_add(struct mm_struct *mm, unsigned long vaddr, - pte_t *ptep, pte_t orig, int fullmm); - -+static void maybe_tlb_batch_add(struct mm_struct *mm, unsigned long vaddr, -+ pte_t *ptep, pte_t orig, int fullmm) -+{ -+ /* It is more efficient to let flush_tlb_kernel_range() -+ * handle init_mm tlb flushes. -+ * -+ * SUN4V NOTE: _PAGE_VALID is the same value in both the SUN4U -+ * and SUN4V pte layout, so this inline test is fine. -+ */ -+ if (likely(mm != &init_mm) && pte_accessible(mm, orig)) -+ tlb_batch_add(mm, vaddr, ptep, orig, fullmm); -+} -+ - #define __HAVE_ARCH_PMDP_HUGE_GET_AND_CLEAR - static inline pmd_t pmdp_huge_get_and_clear(struct mm_struct *mm, - unsigned long addr, -@@ -881,15 +910,7 @@ static inline void __set_pte_at(struct mm_struct *mm, unsigned long addr, - pte_t orig = *ptep; - - *ptep = pte; -- -- /* It is more efficient to let flush_tlb_kernel_range() -- * handle init_mm tlb flushes. -- * -- * SUN4V NOTE: _PAGE_VALID is the same value in both the SUN4U -- * and SUN4V pte layout, so this inline test is fine. -- */ -- if (likely(mm != &init_mm) && pte_accessible(mm, orig)) -- tlb_batch_add(mm, addr, ptep, orig, fullmm); -+ maybe_tlb_batch_add(mm, addr, ptep, orig, fullmm); - } - - #define set_pte_at(mm,addr,ptep,pte) \ -diff --git a/arch/sparc/include/asm/tlbflush_64.h b/arch/sparc/include/asm/tlbflush_64.h -index dea1cfa..a8e192e 100644 ---- a/arch/sparc/include/asm/tlbflush_64.h -+++ b/arch/sparc/include/asm/tlbflush_64.h -@@ -8,6 +8,7 @@ - #define TLB_BATCH_NR 192 - - struct tlb_batch { -+ bool huge; - struct mm_struct *mm; - unsigned long tlb_nr; - unsigned long active; -@@ -16,7 +17,7 @@ struct tlb_batch { - - void flush_tsb_kernel_range(unsigned long start, unsigned long end); - void flush_tsb_user(struct tlb_batch *tb); --void flush_tsb_user_page(struct mm_struct *mm, unsigned long vaddr); -+void flush_tsb_user_page(struct mm_struct *mm, unsigned long vaddr, bool huge); - - /* TLB flush operations. */ - -diff --git a/arch/sparc/include/asm/ttable.h b/arch/sparc/include/asm/ttable.h -index 71b5a67..781b9f1 100644 ---- a/arch/sparc/include/asm/ttable.h -+++ b/arch/sparc/include/asm/ttable.h -@@ -589,8 +589,8 @@ user_rtt_fill_64bit: \ - restored; \ - nop; nop; nop; nop; nop; nop; \ - nop; nop; nop; nop; nop; \ -- ba,a,pt %xcc, user_rtt_fill_fixup; \ -- ba,a,pt %xcc, user_rtt_fill_fixup; \ -+ ba,a,pt %xcc, user_rtt_fill_fixup_dax; \ -+ ba,a,pt %xcc, user_rtt_fill_fixup_mna; \ - ba,a,pt %xcc, user_rtt_fill_fixup; - - -@@ -652,8 +652,8 @@ user_rtt_fill_32bit: \ - restored; \ - nop; nop; nop; nop; nop; \ - nop; nop; nop; \ -- ba,a,pt %xcc, user_rtt_fill_fixup; \ -- ba,a,pt %xcc, user_rtt_fill_fixup; \ -+ ba,a,pt %xcc, user_rtt_fill_fixup_dax; \ -+ ba,a,pt %xcc, user_rtt_fill_fixup_mna; \ - ba,a,pt %xcc, user_rtt_fill_fixup; - - -diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile -index 7cf9c6e..fdb1332 100644 ---- a/arch/sparc/kernel/Makefile -+++ b/arch/sparc/kernel/Makefile -@@ -21,6 +21,7 @@ CFLAGS_REMOVE_perf_event.o := -pg - CFLAGS_REMOVE_pcr.o := -pg - endif - -+obj-$(CONFIG_SPARC64) += urtt_fill.o - obj-$(CONFIG_SPARC32) += entry.o wof.o wuf.o - obj-$(CONFIG_SPARC32) += etrap_32.o - obj-$(CONFIG_SPARC32) += rtrap_32.o -diff --git a/arch/sparc/kernel/cherrs.S b/arch/sparc/kernel/cherrs.S -index 4ee1ad4..655628d 100644 ---- a/arch/sparc/kernel/cherrs.S -+++ b/arch/sparc/kernel/cherrs.S -@@ -214,8 +214,7 @@ do_dcpe_tl1_nonfatal: /* Ok we may use interrupt globals safely. */ - subcc %g1, %g2, %g1 ! Next cacheline - bge,pt %icc, 1b - nop -- ba,pt %xcc, dcpe_icpe_tl1_common -- nop -+ ba,a,pt %xcc, dcpe_icpe_tl1_common - - do_dcpe_tl1_fatal: - sethi %hi(1f), %g7 -@@ -224,8 +223,7 @@ do_dcpe_tl1_fatal: - mov 0x2, %o0 - call cheetah_plus_parity_error - add %sp, PTREGS_OFF, %o1 -- ba,pt %xcc, rtrap -- nop -+ ba,a,pt %xcc, rtrap - .size do_dcpe_tl1,.-do_dcpe_tl1 - - .globl do_icpe_tl1 -@@ -259,8 +257,7 @@ do_icpe_tl1_nonfatal: /* Ok we may use interrupt globals safely. */ - subcc %g1, %g2, %g1 - bge,pt %icc, 1b - nop -- ba,pt %xcc, dcpe_icpe_tl1_common -- nop -+ ba,a,pt %xcc, dcpe_icpe_tl1_common - - do_icpe_tl1_fatal: - sethi %hi(1f), %g7 -@@ -269,8 +266,7 @@ do_icpe_tl1_fatal: - mov 0x3, %o0 - call cheetah_plus_parity_error - add %sp, PTREGS_OFF, %o1 -- ba,pt %xcc, rtrap -- nop -+ ba,a,pt %xcc, rtrap - .size do_icpe_tl1,.-do_icpe_tl1 - - .type dcpe_icpe_tl1_common,#function -@@ -456,7 +452,7 @@ __cheetah_log_error: - cmp %g2, 0x63 - be c_cee - nop -- ba,pt %xcc, c_deferred -+ ba,a,pt %xcc, c_deferred - .size __cheetah_log_error,.-__cheetah_log_error - - /* Cheetah FECC trap handling, we get here from tl{0,1}_fecc -diff --git a/arch/sparc/kernel/entry.S b/arch/sparc/kernel/entry.S -index 33c02b1..a83707c 100644 ---- a/arch/sparc/kernel/entry.S -+++ b/arch/sparc/kernel/entry.S -@@ -948,7 +948,24 @@ linux_syscall_trace: - cmp %o0, 0 - bne 3f - mov -ENOSYS, %o0 -+ -+ /* Syscall tracing can modify the registers. */ -+ ld [%sp + STACKFRAME_SZ + PT_G1], %g1 -+ sethi %hi(sys_call_table), %l7 -+ ld [%sp + STACKFRAME_SZ + PT_I0], %i0 -+ or %l7, %lo(sys_call_table), %l7 -+ ld [%sp + STACKFRAME_SZ + PT_I1], %i1 -+ ld [%sp + STACKFRAME_SZ + PT_I2], %i2 -+ ld [%sp + STACKFRAME_SZ + PT_I3], %i3 -+ ld [%sp + STACKFRAME_SZ + PT_I4], %i4 -+ ld [%sp + STACKFRAME_SZ + PT_I5], %i5 -+ cmp %g1, NR_syscalls -+ bgeu 3f -+ mov -ENOSYS, %o0 -+ -+ sll %g1, 2, %l4 - mov %i0, %o0 -+ ld [%l7 + %l4], %l7 - mov %i1, %o1 - mov %i2, %o2 - mov %i3, %o3 -diff --git a/arch/sparc/kernel/fpu_traps.S b/arch/sparc/kernel/fpu_traps.S -index a686482..336d275 100644 ---- a/arch/sparc/kernel/fpu_traps.S -+++ b/arch/sparc/kernel/fpu_traps.S -@@ -100,8 +100,8 @@ do_fpdis: - fmuld %f0, %f2, %f26 - faddd %f0, %f2, %f28 - fmuld %f0, %f2, %f30 -- b,pt %xcc, fpdis_exit -- nop -+ ba,a,pt %xcc, fpdis_exit -+ - 2: andcc %g5, FPRS_DU, %g0 - bne,pt %icc, 3f - fzero %f32 -@@ -144,8 +144,8 @@ do_fpdis: - fmuld %f32, %f34, %f58 - faddd %f32, %f34, %f60 - fmuld %f32, %f34, %f62 -- ba,pt %xcc, fpdis_exit -- nop -+ ba,a,pt %xcc, fpdis_exit -+ - 3: mov SECONDARY_CONTEXT, %g3 - add %g6, TI_FPREGS, %g1 - -@@ -197,8 +197,7 @@ fpdis_exit2: - fp_other_bounce: - call do_fpother - add %sp, PTREGS_OFF, %o0 -- ba,pt %xcc, rtrap -- nop -+ ba,a,pt %xcc, rtrap - .size fp_other_bounce,.-fp_other_bounce - - .align 32 -diff --git a/arch/sparc/kernel/head_64.S b/arch/sparc/kernel/head_64.S -index f2d30ca..51faf92 100644 ---- a/arch/sparc/kernel/head_64.S -+++ b/arch/sparc/kernel/head_64.S -@@ -461,9 +461,8 @@ sun4v_chip_type: - subcc %g3, 1, %g3 - bne,pt %xcc, 41b - add %g1, 1, %g1 -- mov SUN4V_CHIP_SPARC64X, %g4 - ba,pt %xcc, 5f -- nop -+ mov SUN4V_CHIP_SPARC64X, %g4 - - 49: - mov SUN4V_CHIP_UNKNOWN, %g4 -@@ -548,8 +547,7 @@ sun4u_init: - stxa %g0, [%g7] ASI_DMMU - membar #Sync - -- ba,pt %xcc, sun4u_continue -- nop -+ ba,a,pt %xcc, sun4u_continue - - sun4v_init: - /* Set ctx 0 */ -@@ -560,14 +558,12 @@ sun4v_init: - mov SECONDARY_CONTEXT, %g7 - stxa %g0, [%g7] ASI_MMU - membar #Sync -- ba,pt %xcc, niagara_tlb_fixup -- nop -+ ba,a,pt %xcc, niagara_tlb_fixup - - sun4u_continue: - BRANCH_IF_ANY_CHEETAH(g1, g7, cheetah_tlb_fixup) - -- ba,pt %xcc, spitfire_tlb_fixup -- nop -+ ba,a,pt %xcc, spitfire_tlb_fixup - - niagara_tlb_fixup: - mov 3, %g2 /* Set TLB type to hypervisor. */ -@@ -639,8 +635,7 @@ niagara_patch: - call hypervisor_patch_cachetlbops - nop - -- ba,pt %xcc, tlb_fixup_done -- nop -+ ba,a,pt %xcc, tlb_fixup_done - - cheetah_tlb_fixup: - mov 2, %g2 /* Set TLB type to cheetah+. */ -@@ -659,8 +654,7 @@ cheetah_tlb_fixup: - call cheetah_patch_cachetlbops - nop - -- ba,pt %xcc, tlb_fixup_done -- nop -+ ba,a,pt %xcc, tlb_fixup_done - - spitfire_tlb_fixup: - /* Set TLB type to spitfire. */ -@@ -782,8 +776,7 @@ setup_trap_table: - call %o1 - add %sp, (2047 + 128), %o0 - -- ba,pt %xcc, 2f -- nop -+ ba,a,pt %xcc, 2f - - 1: sethi %hi(sparc64_ttable_tl0), %o0 - set prom_set_trap_table_name, %g2 -@@ -822,8 +815,7 @@ setup_trap_table: - - BRANCH_IF_ANY_CHEETAH(o2, o3, 1f) - -- ba,pt %xcc, 2f -- nop -+ ba,a,pt %xcc, 2f - - /* Disable STICK_INT interrupts. */ - 1: -diff --git a/arch/sparc/kernel/misctrap.S b/arch/sparc/kernel/misctrap.S -index 753b4f0..34b4933 100644 ---- a/arch/sparc/kernel/misctrap.S -+++ b/arch/sparc/kernel/misctrap.S -@@ -18,8 +18,7 @@ __do_privact: - 109: or %g7, %lo(109b), %g7 - call do_privact - add %sp, PTREGS_OFF, %o0 -- ba,pt %xcc, rtrap -- nop -+ ba,a,pt %xcc, rtrap - .size __do_privact,.-__do_privact - - .type do_mna,#function -@@ -46,8 +45,7 @@ do_mna: - mov %l5, %o2 - call mem_address_unaligned - add %sp, PTREGS_OFF, %o0 -- ba,pt %xcc, rtrap -- nop -+ ba,a,pt %xcc, rtrap - .size do_mna,.-do_mna - - .type do_lddfmna,#function -@@ -65,8 +63,7 @@ do_lddfmna: - mov %l5, %o2 - call handle_lddfmna - add %sp, PTREGS_OFF, %o0 -- ba,pt %xcc, rtrap -- nop -+ ba,a,pt %xcc, rtrap - .size do_lddfmna,.-do_lddfmna - - .type do_stdfmna,#function -@@ -84,8 +81,7 @@ do_stdfmna: - mov %l5, %o2 - call handle_stdfmna - add %sp, PTREGS_OFF, %o0 -- ba,pt %xcc, rtrap -- nop -+ ba,a,pt %xcc, rtrap - .size do_stdfmna,.-do_stdfmna - - .type breakpoint_trap,#function -diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c -index badf095..9f9614d 100644 ---- a/arch/sparc/kernel/pci.c -+++ b/arch/sparc/kernel/pci.c -@@ -994,6 +994,23 @@ void pcibios_set_master(struct pci_dev *dev) - /* No special bus mastering setup handling */ - } - -+#ifdef CONFIG_PCI_IOV -+int pcibios_add_device(struct pci_dev *dev) -+{ -+ struct pci_dev *pdev; -+ -+ /* Add sriov arch specific initialization here. -+ * Copy dev_archdata from PF to VF -+ */ -+ if (dev->is_virtfn) { -+ pdev = dev->physfn; -+ memcpy(&dev->dev.archdata, &pdev->dev.archdata, -+ sizeof(struct dev_archdata)); -+ } -+ return 0; -+} -+#endif /* CONFIG_PCI_IOV */ -+ - static int __init pcibios_init(void) - { - pci_dfl_cache_line_size = 64 >> 2; -diff --git a/arch/sparc/kernel/rtrap_64.S b/arch/sparc/kernel/rtrap_64.S -index d08bdaf..216948c 100644 ---- a/arch/sparc/kernel/rtrap_64.S -+++ b/arch/sparc/kernel/rtrap_64.S -@@ -14,10 +14,6 @@ - #include - #include - --#define RTRAP_PSTATE (PSTATE_TSO|PSTATE_PEF|PSTATE_PRIV|PSTATE_IE) --#define RTRAP_PSTATE_IRQOFF (PSTATE_TSO|PSTATE_PEF|PSTATE_PRIV) --#define RTRAP_PSTATE_AG_IRQOFF (PSTATE_TSO|PSTATE_PEF|PSTATE_PRIV|PSTATE_AG) -- - #ifdef CONFIG_CONTEXT_TRACKING - # define SCHEDULE_USER schedule_user - #else -@@ -242,52 +238,17 @@ rt_continue: ldx [%sp + PTREGS_OFF + PT_V9_G1], %g1 - wrpr %g1, %cwp - ba,a,pt %xcc, user_rtt_fill_64bit - --user_rtt_fill_fixup: -- rdpr %cwp, %g1 -- add %g1, 1, %g1 -- wrpr %g1, 0x0, %cwp -- -- rdpr %wstate, %g2 -- sll %g2, 3, %g2 -- wrpr %g2, 0x0, %wstate -- -- /* We know %canrestore and %otherwin are both zero. */ -- -- sethi %hi(sparc64_kern_pri_context), %g2 -- ldx [%g2 + %lo(sparc64_kern_pri_context)], %g2 -- mov PRIMARY_CONTEXT, %g1 -- --661: stxa %g2, [%g1] ASI_DMMU -- .section .sun4v_1insn_patch, "ax" -- .word 661b -- stxa %g2, [%g1] ASI_MMU -- .previous -- -- sethi %hi(KERNBASE), %g1 -- flush %g1 -+user_rtt_fill_fixup_dax: -+ ba,pt %xcc, user_rtt_fill_fixup_common -+ mov 1, %g3 - -- or %g4, FAULT_CODE_WINFIXUP, %g4 -- stb %g4, [%g6 + TI_FAULT_CODE] -- stx %g5, [%g6 + TI_FAULT_ADDR] -+user_rtt_fill_fixup_mna: -+ ba,pt %xcc, user_rtt_fill_fixup_common -+ mov 2, %g3 - -- mov %g6, %l1 -- wrpr %g0, 0x0, %tl -- --661: nop -- .section .sun4v_1insn_patch, "ax" -- .word 661b -- SET_GL(0) -- .previous -- -- wrpr %g0, RTRAP_PSTATE, %pstate -- -- mov %l1, %g6 -- ldx [%g6 + TI_TASK], %g4 -- LOAD_PER_CPU_BASE(%g5, %g6, %g1, %g2, %g3) -- call do_sparc64_fault -- add %sp, PTREGS_OFF, %o0 -- ba,pt %xcc, rtrap -- nop -+user_rtt_fill_fixup: -+ ba,pt %xcc, user_rtt_fill_fixup_common -+ clr %g3 - - user_rtt_pre_restore: - add %g1, 1, %g1 -diff --git a/arch/sparc/kernel/signal32.c b/arch/sparc/kernel/signal32.c -index 4eed773..77655f0 100644 ---- a/arch/sparc/kernel/signal32.c -+++ b/arch/sparc/kernel/signal32.c -@@ -138,12 +138,24 @@ int copy_siginfo_from_user32(siginfo_t *to, compat_siginfo_t __user *from) - return 0; - } - -+/* Checks if the fp is valid. We always build signal frames which are -+ * 16-byte aligned, therefore we can always enforce that the restore -+ * frame has that property as well. -+ */ -+static bool invalid_frame_pointer(void __user *fp, int fplen) -+{ -+ if ((((unsigned long) fp) & 15) || -+ ((unsigned long)fp) > 0x100000000ULL - fplen) -+ return true; -+ return false; -+} -+ - void do_sigreturn32(struct pt_regs *regs) - { - struct signal_frame32 __user *sf; - compat_uptr_t fpu_save; - compat_uptr_t rwin_save; -- unsigned int psr; -+ unsigned int psr, ufp; - unsigned pc, npc; - sigset_t set; - compat_sigset_t seta; -@@ -158,11 +170,16 @@ void do_sigreturn32(struct pt_regs *regs) - sf = (struct signal_frame32 __user *) regs->u_regs[UREG_FP]; - - /* 1. Make sure we are not getting garbage from the user */ -- if (!access_ok(VERIFY_READ, sf, sizeof(*sf)) || -- (((unsigned long) sf) & 3)) -+ if (invalid_frame_pointer(sf, sizeof(*sf))) -+ goto segv; -+ -+ if (get_user(ufp, &sf->info.si_regs.u_regs[UREG_FP])) -+ goto segv; -+ -+ if (ufp & 0x7) - goto segv; - -- if (get_user(pc, &sf->info.si_regs.pc) || -+ if (__get_user(pc, &sf->info.si_regs.pc) || - __get_user(npc, &sf->info.si_regs.npc)) - goto segv; - -@@ -227,7 +244,7 @@ segv: - asmlinkage void do_rt_sigreturn32(struct pt_regs *regs) - { - struct rt_signal_frame32 __user *sf; -- unsigned int psr, pc, npc; -+ unsigned int psr, pc, npc, ufp; - compat_uptr_t fpu_save; - compat_uptr_t rwin_save; - sigset_t set; -@@ -242,11 +259,16 @@ asmlinkage void do_rt_sigreturn32(struct pt_regs *regs) - sf = (struct rt_signal_frame32 __user *) regs->u_regs[UREG_FP]; - - /* 1. Make sure we are not getting garbage from the user */ -- if (!access_ok(VERIFY_READ, sf, sizeof(*sf)) || -- (((unsigned long) sf) & 3)) -+ if (invalid_frame_pointer(sf, sizeof(*sf))) - goto segv; - -- if (get_user(pc, &sf->regs.pc) || -+ if (get_user(ufp, &sf->regs.u_regs[UREG_FP])) -+ goto segv; -+ -+ if (ufp & 0x7) -+ goto segv; -+ -+ if (__get_user(pc, &sf->regs.pc) || - __get_user(npc, &sf->regs.npc)) - goto segv; - -@@ -307,14 +329,6 @@ segv: - force_sig(SIGSEGV, current); - } - --/* Checks if the fp is valid */ --static int invalid_frame_pointer(void __user *fp, int fplen) --{ -- if ((((unsigned long) fp) & 7) || ((unsigned long)fp) > 0x100000000ULL - fplen) -- return 1; -- return 0; --} -- - static void __user *get_sigframe(struct ksignal *ksig, struct pt_regs *regs, unsigned long framesize) - { - unsigned long sp; -diff --git a/arch/sparc/kernel/signal_32.c b/arch/sparc/kernel/signal_32.c -index 52aa5e4..c3c12ef 100644 ---- a/arch/sparc/kernel/signal_32.c -+++ b/arch/sparc/kernel/signal_32.c -@@ -60,10 +60,22 @@ struct rt_signal_frame { - #define SF_ALIGNEDSZ (((sizeof(struct signal_frame) + 7) & (~7))) - #define RT_ALIGNEDSZ (((sizeof(struct rt_signal_frame) + 7) & (~7))) - -+/* Checks if the fp is valid. We always build signal frames which are -+ * 16-byte aligned, therefore we can always enforce that the restore -+ * frame has that property as well. -+ */ -+static inline bool invalid_frame_pointer(void __user *fp, int fplen) -+{ -+ if ((((unsigned long) fp) & 15) || !__access_ok((unsigned long)fp, fplen)) -+ return true; -+ -+ return false; -+} -+ - asmlinkage void do_sigreturn(struct pt_regs *regs) - { -+ unsigned long up_psr, pc, npc, ufp; - struct signal_frame __user *sf; -- unsigned long up_psr, pc, npc; - sigset_t set; - __siginfo_fpu_t __user *fpu_save; - __siginfo_rwin_t __user *rwin_save; -@@ -77,10 +89,13 @@ asmlinkage void do_sigreturn(struct pt_regs *regs) - sf = (struct signal_frame __user *) regs->u_regs[UREG_FP]; - - /* 1. Make sure we are not getting garbage from the user */ -- if (!access_ok(VERIFY_READ, sf, sizeof(*sf))) -+ if (!invalid_frame_pointer(sf, sizeof(*sf))) -+ goto segv_and_exit; -+ -+ if (get_user(ufp, &sf->info.si_regs.u_regs[UREG_FP])) - goto segv_and_exit; - -- if (((unsigned long) sf) & 3) -+ if (ufp & 0x7) - goto segv_and_exit; - - err = __get_user(pc, &sf->info.si_regs.pc); -@@ -127,7 +142,7 @@ segv_and_exit: - asmlinkage void do_rt_sigreturn(struct pt_regs *regs) - { - struct rt_signal_frame __user *sf; -- unsigned int psr, pc, npc; -+ unsigned int psr, pc, npc, ufp; - __siginfo_fpu_t __user *fpu_save; - __siginfo_rwin_t __user *rwin_save; - sigset_t set; -@@ -135,8 +150,13 @@ asmlinkage void do_rt_sigreturn(struct pt_regs *regs) - - synchronize_user_stack(); - sf = (struct rt_signal_frame __user *) regs->u_regs[UREG_FP]; -- if (!access_ok(VERIFY_READ, sf, sizeof(*sf)) || -- (((unsigned long) sf) & 0x03)) -+ if (!invalid_frame_pointer(sf, sizeof(*sf))) -+ goto segv; -+ -+ if (get_user(ufp, &sf->regs.u_regs[UREG_FP])) -+ goto segv; -+ -+ if (ufp & 0x7) - goto segv; - - err = __get_user(pc, &sf->regs.pc); -@@ -178,15 +198,6 @@ segv: - force_sig(SIGSEGV, current); - } - --/* Checks if the fp is valid */ --static inline int invalid_frame_pointer(void __user *fp, int fplen) --{ -- if ((((unsigned long) fp) & 7) || !__access_ok((unsigned long)fp, fplen)) -- return 1; -- -- return 0; --} -- - static inline void __user *get_sigframe(struct ksignal *ksig, struct pt_regs *regs, unsigned long framesize) - { - unsigned long sp = regs->u_regs[UREG_FP]; -diff --git a/arch/sparc/kernel/signal_64.c b/arch/sparc/kernel/signal_64.c -index d88beff..5ee930c 100644 ---- a/arch/sparc/kernel/signal_64.c -+++ b/arch/sparc/kernel/signal_64.c -@@ -52,7 +52,7 @@ asmlinkage void sparc64_set_context(struct pt_regs *regs) - unsigned char fenab; - int err; - -- flush_user_windows(); -+ synchronize_user_stack(); - if (get_thread_wsaved() || - (((unsigned long)ucp) & (sizeof(unsigned long)-1)) || - (!__access_ok(ucp, sizeof(*ucp)))) -@@ -234,6 +234,17 @@ do_sigsegv: - goto out; - } - -+/* Checks if the fp is valid. We always build rt signal frames which -+ * are 16-byte aligned, therefore we can always enforce that the -+ * restore frame has that property as well. -+ */ -+static bool invalid_frame_pointer(void __user *fp) -+{ -+ if (((unsigned long) fp) & 15) -+ return true; -+ return false; -+} -+ - struct rt_signal_frame { - struct sparc_stackf ss; - siginfo_t info; -@@ -246,8 +257,8 @@ struct rt_signal_frame { - - void do_rt_sigreturn(struct pt_regs *regs) - { -+ unsigned long tpc, tnpc, tstate, ufp; - struct rt_signal_frame __user *sf; -- unsigned long tpc, tnpc, tstate; - __siginfo_fpu_t __user *fpu_save; - __siginfo_rwin_t __user *rwin_save; - sigset_t set; -@@ -261,10 +272,16 @@ void do_rt_sigreturn(struct pt_regs *regs) - (regs->u_regs [UREG_FP] + STACK_BIAS); - - /* 1. Make sure we are not getting garbage from the user */ -- if (((unsigned long) sf) & 3) -+ if (invalid_frame_pointer(sf)) -+ goto segv; -+ -+ if (get_user(ufp, &sf->regs.u_regs[UREG_FP])) - goto segv; - -- err = get_user(tpc, &sf->regs.tpc); -+ if ((ufp + STACK_BIAS) & 0x7) -+ goto segv; -+ -+ err = __get_user(tpc, &sf->regs.tpc); - err |= __get_user(tnpc, &sf->regs.tnpc); - if (test_thread_flag(TIF_32BIT)) { - tpc &= 0xffffffff; -@@ -308,14 +325,6 @@ segv: - force_sig(SIGSEGV, current); - } - --/* Checks if the fp is valid */ --static int invalid_frame_pointer(void __user *fp) --{ -- if (((unsigned long) fp) & 15) -- return 1; -- return 0; --} -- - static inline void __user *get_sigframe(struct ksignal *ksig, struct pt_regs *regs, unsigned long framesize) - { - unsigned long sp = regs->u_regs[UREG_FP] + STACK_BIAS; -diff --git a/arch/sparc/kernel/sigutil_32.c b/arch/sparc/kernel/sigutil_32.c -index 0f6eebe..e5fe8ce 100644 ---- a/arch/sparc/kernel/sigutil_32.c -+++ b/arch/sparc/kernel/sigutil_32.c -@@ -48,6 +48,10 @@ int save_fpu_state(struct pt_regs *regs, __siginfo_fpu_t __user *fpu) - int restore_fpu_state(struct pt_regs *regs, __siginfo_fpu_t __user *fpu) - { - int err; -+ -+ if (((unsigned long) fpu) & 3) -+ return -EFAULT; -+ - #ifdef CONFIG_SMP - if (test_tsk_thread_flag(current, TIF_USEDFPU)) - regs->psr &= ~PSR_EF; -@@ -97,7 +101,10 @@ int restore_rwin_state(__siginfo_rwin_t __user *rp) - struct thread_info *t = current_thread_info(); - int i, wsaved, err; - -- __get_user(wsaved, &rp->wsaved); -+ if (((unsigned long) rp) & 3) -+ return -EFAULT; -+ -+ get_user(wsaved, &rp->wsaved); - if (wsaved > NSWINS) - return -EFAULT; - -diff --git a/arch/sparc/kernel/sigutil_64.c b/arch/sparc/kernel/sigutil_64.c -index 387834a..36aadcb 100644 ---- a/arch/sparc/kernel/sigutil_64.c -+++ b/arch/sparc/kernel/sigutil_64.c -@@ -37,7 +37,10 @@ int restore_fpu_state(struct pt_regs *regs, __siginfo_fpu_t __user *fpu) - unsigned long fprs; - int err; - -- err = __get_user(fprs, &fpu->si_fprs); -+ if (((unsigned long) fpu) & 7) -+ return -EFAULT; -+ -+ err = get_user(fprs, &fpu->si_fprs); - fprs_write(0); - regs->tstate &= ~TSTATE_PEF; - if (fprs & FPRS_DL) -@@ -72,7 +75,10 @@ int restore_rwin_state(__siginfo_rwin_t __user *rp) - struct thread_info *t = current_thread_info(); - int i, wsaved, err; - -- __get_user(wsaved, &rp->wsaved); -+ if (((unsigned long) rp) & 7) -+ return -EFAULT; -+ -+ get_user(wsaved, &rp->wsaved); - if (wsaved > NSWINS) - return -EFAULT; - -diff --git a/arch/sparc/kernel/spiterrs.S b/arch/sparc/kernel/spiterrs.S -index c357e40..4a73009 100644 ---- a/arch/sparc/kernel/spiterrs.S -+++ b/arch/sparc/kernel/spiterrs.S -@@ -85,8 +85,7 @@ __spitfire_cee_trap_continue: - ba,pt %xcc, etraptl1 - rd %pc, %g7 - -- ba,pt %xcc, 2f -- nop -+ ba,a,pt %xcc, 2f - - 1: ba,pt %xcc, etrap_irq - rd %pc, %g7 -@@ -100,8 +99,7 @@ __spitfire_cee_trap_continue: - mov %l5, %o2 - call spitfire_access_error - add %sp, PTREGS_OFF, %o0 -- ba,pt %xcc, rtrap -- nop -+ ba,a,pt %xcc, rtrap - .size __spitfire_access_error,.-__spitfire_access_error - - /* This is the trap handler entry point for ECC correctable -@@ -179,8 +177,7 @@ __spitfire_data_access_exception_tl1: - mov %l5, %o2 - call spitfire_data_access_exception_tl1 - add %sp, PTREGS_OFF, %o0 -- ba,pt %xcc, rtrap -- nop -+ ba,a,pt %xcc, rtrap - .size __spitfire_data_access_exception_tl1,.-__spitfire_data_access_exception_tl1 - - .type __spitfire_data_access_exception,#function -@@ -200,8 +197,7 @@ __spitfire_data_access_exception: - mov %l5, %o2 - call spitfire_data_access_exception - add %sp, PTREGS_OFF, %o0 -- ba,pt %xcc, rtrap -- nop -+ ba,a,pt %xcc, rtrap - .size __spitfire_data_access_exception,.-__spitfire_data_access_exception - - .type __spitfire_insn_access_exception_tl1,#function -@@ -220,8 +216,7 @@ __spitfire_insn_access_exception_tl1: - mov %l5, %o2 - call spitfire_insn_access_exception_tl1 - add %sp, PTREGS_OFF, %o0 -- ba,pt %xcc, rtrap -- nop -+ ba,a,pt %xcc, rtrap - .size __spitfire_insn_access_exception_tl1,.-__spitfire_insn_access_exception_tl1 - - .type __spitfire_insn_access_exception,#function -@@ -240,6 +235,5 @@ __spitfire_insn_access_exception: - mov %l5, %o2 - call spitfire_insn_access_exception - add %sp, PTREGS_OFF, %o0 -- ba,pt %xcc, rtrap -- nop -+ ba,a,pt %xcc, rtrap - .size __spitfire_insn_access_exception,.-__spitfire_insn_access_exception -diff --git a/arch/sparc/kernel/syscalls.S b/arch/sparc/kernel/syscalls.S -index bb00089..c4a1b5c 100644 ---- a/arch/sparc/kernel/syscalls.S -+++ b/arch/sparc/kernel/syscalls.S -@@ -158,7 +158,25 @@ linux_syscall_trace32: - add %sp, PTREGS_OFF, %o0 - brnz,pn %o0, 3f - mov -ENOSYS, %o0 -+ -+ /* Syscall tracing can modify the registers. */ -+ ldx [%sp + PTREGS_OFF + PT_V9_G1], %g1 -+ sethi %hi(sys_call_table32), %l7 -+ ldx [%sp + PTREGS_OFF + PT_V9_I0], %i0 -+ or %l7, %lo(sys_call_table32), %l7 -+ ldx [%sp + PTREGS_OFF + PT_V9_I1], %i1 -+ ldx [%sp + PTREGS_OFF + PT_V9_I2], %i2 -+ ldx [%sp + PTREGS_OFF + PT_V9_I3], %i3 -+ ldx [%sp + PTREGS_OFF + PT_V9_I4], %i4 -+ ldx [%sp + PTREGS_OFF + PT_V9_I5], %i5 -+ -+ cmp %g1, NR_syscalls -+ bgeu,pn %xcc, 3f -+ mov -ENOSYS, %o0 -+ -+ sll %g1, 2, %l4 - srl %i0, 0, %o0 -+ lduw [%l7 + %l4], %l7 - srl %i4, 0, %o4 - srl %i1, 0, %o1 - srl %i2, 0, %o2 -@@ -170,7 +188,25 @@ linux_syscall_trace: - add %sp, PTREGS_OFF, %o0 - brnz,pn %o0, 3f - mov -ENOSYS, %o0 -+ -+ /* Syscall tracing can modify the registers. */ -+ ldx [%sp + PTREGS_OFF + PT_V9_G1], %g1 -+ sethi %hi(sys_call_table64), %l7 -+ ldx [%sp + PTREGS_OFF + PT_V9_I0], %i0 -+ or %l7, %lo(sys_call_table64), %l7 -+ ldx [%sp + PTREGS_OFF + PT_V9_I1], %i1 -+ ldx [%sp + PTREGS_OFF + PT_V9_I2], %i2 -+ ldx [%sp + PTREGS_OFF + PT_V9_I3], %i3 -+ ldx [%sp + PTREGS_OFF + PT_V9_I4], %i4 -+ ldx [%sp + PTREGS_OFF + PT_V9_I5], %i5 -+ -+ cmp %g1, NR_syscalls -+ bgeu,pn %xcc, 3f -+ mov -ENOSYS, %o0 -+ -+ sll %g1, 2, %l4 - mov %i0, %o0 -+ lduw [%l7 + %l4], %l7 - mov %i1, %o1 - mov %i2, %o2 - mov %i3, %o3 -diff --git a/arch/sparc/kernel/urtt_fill.S b/arch/sparc/kernel/urtt_fill.S -new file mode 100644 -index 0000000..5604a2b ---- /dev/null -+++ b/arch/sparc/kernel/urtt_fill.S -@@ -0,0 +1,98 @@ -+#include -+#include -+#include -+#include -+#include -+ -+ .text -+ .align 8 -+ .globl user_rtt_fill_fixup_common -+user_rtt_fill_fixup_common: -+ rdpr %cwp, %g1 -+ add %g1, 1, %g1 -+ wrpr %g1, 0x0, %cwp -+ -+ rdpr %wstate, %g2 -+ sll %g2, 3, %g2 -+ wrpr %g2, 0x0, %wstate -+ -+ /* We know %canrestore and %otherwin are both zero. */ -+ -+ sethi %hi(sparc64_kern_pri_context), %g2 -+ ldx [%g2 + %lo(sparc64_kern_pri_context)], %g2 -+ mov PRIMARY_CONTEXT, %g1 -+ -+661: stxa %g2, [%g1] ASI_DMMU -+ .section .sun4v_1insn_patch, "ax" -+ .word 661b -+ stxa %g2, [%g1] ASI_MMU -+ .previous -+ -+ sethi %hi(KERNBASE), %g1 -+ flush %g1 -+ -+ mov %g4, %l4 -+ mov %g5, %l5 -+ brnz,pn %g3, 1f -+ mov %g3, %l3 -+ -+ or %g4, FAULT_CODE_WINFIXUP, %g4 -+ stb %g4, [%g6 + TI_FAULT_CODE] -+ stx %g5, [%g6 + TI_FAULT_ADDR] -+1: -+ mov %g6, %l1 -+ wrpr %g0, 0x0, %tl -+ -+661: nop -+ .section .sun4v_1insn_patch, "ax" -+ .word 661b -+ SET_GL(0) -+ .previous -+ -+ wrpr %g0, RTRAP_PSTATE, %pstate -+ -+ mov %l1, %g6 -+ ldx [%g6 + TI_TASK], %g4 -+ LOAD_PER_CPU_BASE(%g5, %g6, %g1, %g2, %g3) -+ -+ brnz,pn %l3, 1f -+ nop -+ -+ call do_sparc64_fault -+ add %sp, PTREGS_OFF, %o0 -+ ba,pt %xcc, rtrap -+ nop -+ -+1: cmp %g3, 2 -+ bne,pn %xcc, 2f -+ nop -+ -+ sethi %hi(tlb_type), %g1 -+ lduw [%g1 + %lo(tlb_type)], %g1 -+ cmp %g1, 3 -+ bne,pt %icc, 1f -+ add %sp, PTREGS_OFF, %o0 -+ mov %l4, %o2 -+ call sun4v_do_mna -+ mov %l5, %o1 -+ ba,a,pt %xcc, rtrap -+1: mov %l4, %o1 -+ mov %l5, %o2 -+ call mem_address_unaligned -+ nop -+ ba,a,pt %xcc, rtrap -+ -+2: sethi %hi(tlb_type), %g1 -+ mov %l4, %o1 -+ lduw [%g1 + %lo(tlb_type)], %g1 -+ mov %l5, %o2 -+ cmp %g1, 3 -+ bne,pt %icc, 1f -+ add %sp, PTREGS_OFF, %o0 -+ call sun4v_data_access_exception -+ nop -+ ba,a,pt %xcc, rtrap -+ -+1: call spitfire_data_access_exception -+ nop -+ ba,a,pt %xcc, rtrap -diff --git a/arch/sparc/kernel/utrap.S b/arch/sparc/kernel/utrap.S -index b7f0f3f..c731e80 100644 ---- a/arch/sparc/kernel/utrap.S -+++ b/arch/sparc/kernel/utrap.S -@@ -11,8 +11,7 @@ utrap_trap: /* %g3=handler,%g4=level */ - mov %l4, %o1 - call bad_trap - add %sp, PTREGS_OFF, %o0 -- ba,pt %xcc, rtrap -- nop -+ ba,a,pt %xcc, rtrap - - invoke_utrap: - sllx %g3, 3, %g3 -diff --git a/arch/sparc/kernel/vmlinux.lds.S b/arch/sparc/kernel/vmlinux.lds.S -index f1a2f68..4a41d41 100644 ---- a/arch/sparc/kernel/vmlinux.lds.S -+++ b/arch/sparc/kernel/vmlinux.lds.S -@@ -33,6 +33,10 @@ ENTRY(_start) - jiffies = jiffies_64; - #endif - -+#ifdef CONFIG_SPARC64 -+ASSERT((swapper_tsb == 0x0000000000408000), "Error: sparc64 early assembler too large") -+#endif -+ - SECTIONS - { - #ifdef CONFIG_SPARC64 -diff --git a/arch/sparc/kernel/winfixup.S b/arch/sparc/kernel/winfixup.S -index 1e67ce9..855019a 100644 ---- a/arch/sparc/kernel/winfixup.S -+++ b/arch/sparc/kernel/winfixup.S -@@ -32,8 +32,7 @@ fill_fixup: - rd %pc, %g7 - call do_sparc64_fault - add %sp, PTREGS_OFF, %o0 -- ba,pt %xcc, rtrap -- nop -+ ba,a,pt %xcc, rtrap - - /* Be very careful about usage of the trap globals here. - * You cannot touch %g5 as that has the fault information. -diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c -index 131eaf4..364d093 100644 ---- a/arch/sparc/mm/hugetlbpage.c -+++ b/arch/sparc/mm/hugetlbpage.c -@@ -176,17 +176,31 @@ void set_huge_pte_at(struct mm_struct *mm, unsigned long addr, - pte_t *ptep, pte_t entry) - { - int i; -+ pte_t orig[2]; -+ unsigned long nptes; - - if (!pte_present(*ptep) && pte_present(entry)) - mm->context.huge_pte_count++; - - addr &= HPAGE_MASK; -- for (i = 0; i < (1 << HUGETLB_PAGE_ORDER); i++) { -- set_pte_at(mm, addr, ptep, entry); -+ -+ nptes = 1 << HUGETLB_PAGE_ORDER; -+ orig[0] = *ptep; -+ orig[1] = *(ptep + nptes / 2); -+ for (i = 0; i < nptes; i++) { -+ *ptep = entry; - ptep++; - addr += PAGE_SIZE; - pte_val(entry) += PAGE_SIZE; - } -+ -+ /* Issue TLB flush at REAL_HPAGE_SIZE boundaries */ -+ addr -= REAL_HPAGE_SIZE; -+ ptep -= nptes / 2; -+ maybe_tlb_batch_add(mm, addr, ptep, orig[1], 0); -+ addr -= REAL_HPAGE_SIZE; -+ ptep -= nptes / 2; -+ maybe_tlb_batch_add(mm, addr, ptep, orig[0], 0); - } - - pte_t huge_ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, -@@ -194,19 +208,28 @@ pte_t huge_ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, - { - pte_t entry; - int i; -+ unsigned long nptes; - - entry = *ptep; - if (pte_present(entry)) - mm->context.huge_pte_count--; - - addr &= HPAGE_MASK; -- -- for (i = 0; i < (1 << HUGETLB_PAGE_ORDER); i++) { -- pte_clear(mm, addr, ptep); -+ nptes = 1 << HUGETLB_PAGE_ORDER; -+ for (i = 0; i < nptes; i++) { -+ *ptep = __pte(0UL); - addr += PAGE_SIZE; - ptep++; - } - -+ /* Issue TLB flush at REAL_HPAGE_SIZE boundaries */ -+ addr -= REAL_HPAGE_SIZE; -+ ptep -= nptes / 2; -+ maybe_tlb_batch_add(mm, addr, ptep, entry, 0); -+ addr -= REAL_HPAGE_SIZE; -+ ptep -= nptes / 2; -+ maybe_tlb_batch_add(mm, addr, ptep, entry, 0); -+ - return entry; - } - -diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c -index 3025bd5..3c4b897 100644 ---- a/arch/sparc/mm/init_64.c -+++ b/arch/sparc/mm/init_64.c -@@ -324,18 +324,6 @@ static void __update_mmu_tsb_insert(struct mm_struct *mm, unsigned long tsb_inde - tsb_insert(tsb, tag, tte); - } - --#if defined(CONFIG_HUGETLB_PAGE) || defined(CONFIG_TRANSPARENT_HUGEPAGE) --static inline bool is_hugetlb_pte(pte_t pte) --{ -- if ((tlb_type == hypervisor && -- (pte_val(pte) & _PAGE_SZALL_4V) == _PAGE_SZHUGE_4V) || -- (tlb_type != hypervisor && -- (pte_val(pte) & _PAGE_SZALL_4U) == _PAGE_SZHUGE_4U)) -- return true; -- return false; --} --#endif -- - void update_mmu_cache(struct vm_area_struct *vma, unsigned long address, pte_t *ptep) - { - struct mm_struct *mm; -@@ -1267,13 +1255,6 @@ static int __init numa_parse_mdesc(void) - int i, j, err, count; - u64 node; - -- /* Some sane defaults for numa latency values */ -- for (i = 0; i < MAX_NUMNODES; i++) { -- for (j = 0; j < MAX_NUMNODES; j++) -- numa_latency[i][j] = (i == j) ? -- LOCAL_DISTANCE : REMOTE_DISTANCE; -- } -- - node = mdesc_node_by_name(md, MDESC_NODE_NULL, "latency-groups"); - if (node == MDESC_NODE_NULL) { - mdesc_release(md); -@@ -1369,10 +1350,18 @@ static int __init numa_parse_sun4u(void) - - static int __init bootmem_init_numa(void) - { -+ int i, j; - int err = -1; - - numadbg("bootmem_init_numa()\n"); - -+ /* Some sane defaults for numa latency values */ -+ for (i = 0; i < MAX_NUMNODES; i++) { -+ for (j = 0; j < MAX_NUMNODES; j++) -+ numa_latency[i][j] = (i == j) ? -+ LOCAL_DISTANCE : REMOTE_DISTANCE; -+ } -+ - if (numa_enabled) { - if (tlb_type == hypervisor) - err = numa_parse_mdesc(); -@@ -2832,9 +2821,10 @@ void hugetlb_setup(struct pt_regs *regs) - * the Data-TLB for huge pages. - */ - if (tlb_type == cheetah_plus) { -+ bool need_context_reload = false; - unsigned long ctx; - -- spin_lock(&ctx_alloc_lock); -+ spin_lock_irq(&ctx_alloc_lock); - ctx = mm->context.sparc64_ctx_val; - ctx &= ~CTX_PGSZ_MASK; - ctx |= CTX_PGSZ_BASE << CTX_PGSZ0_SHIFT; -@@ -2853,9 +2843,12 @@ void hugetlb_setup(struct pt_regs *regs) - * also executing in this address space. - */ - mm->context.sparc64_ctx_val = ctx; -- on_each_cpu(context_reload, mm, 0); -+ need_context_reload = true; - } -- spin_unlock(&ctx_alloc_lock); -+ spin_unlock_irq(&ctx_alloc_lock); -+ -+ if (need_context_reload) -+ on_each_cpu(context_reload, mm, 0); - } - } - #endif -diff --git a/arch/sparc/mm/tlb.c b/arch/sparc/mm/tlb.c -index 9df2190..f81cd97 100644 ---- a/arch/sparc/mm/tlb.c -+++ b/arch/sparc/mm/tlb.c -@@ -67,7 +67,7 @@ void arch_leave_lazy_mmu_mode(void) - } - - static void tlb_batch_add_one(struct mm_struct *mm, unsigned long vaddr, -- bool exec) -+ bool exec, bool huge) - { - struct tlb_batch *tb = &get_cpu_var(tlb_batch); - unsigned long nr; -@@ -84,13 +84,21 @@ static void tlb_batch_add_one(struct mm_struct *mm, unsigned long vaddr, - } - - if (!tb->active) { -- flush_tsb_user_page(mm, vaddr); -+ flush_tsb_user_page(mm, vaddr, huge); - global_flush_tlb_page(mm, vaddr); - goto out; - } - -- if (nr == 0) -+ if (nr == 0) { - tb->mm = mm; -+ tb->huge = huge; -+ } -+ -+ if (tb->huge != huge) { -+ flush_tlb_pending(); -+ tb->huge = huge; -+ nr = 0; -+ } - - tb->vaddrs[nr] = vaddr; - tb->tlb_nr = ++nr; -@@ -104,6 +112,8 @@ out: - void tlb_batch_add(struct mm_struct *mm, unsigned long vaddr, - pte_t *ptep, pte_t orig, int fullmm) - { -+ bool huge = is_hugetlb_pte(orig); -+ - if (tlb_type != hypervisor && - pte_dirty(orig)) { - unsigned long paddr, pfn = pte_pfn(orig); -@@ -129,7 +139,7 @@ void tlb_batch_add(struct mm_struct *mm, unsigned long vaddr, - - no_cache_flush: - if (!fullmm) -- tlb_batch_add_one(mm, vaddr, pte_exec(orig)); -+ tlb_batch_add_one(mm, vaddr, pte_exec(orig), huge); - } - - #ifdef CONFIG_TRANSPARENT_HUGEPAGE -@@ -145,7 +155,7 @@ static void tlb_batch_pmd_scan(struct mm_struct *mm, unsigned long vaddr, - if (pte_val(*pte) & _PAGE_VALID) { - bool exec = pte_exec(*pte); - -- tlb_batch_add_one(mm, vaddr, exec); -+ tlb_batch_add_one(mm, vaddr, exec, false); - } - pte++; - vaddr += PAGE_SIZE; -@@ -185,8 +195,9 @@ void set_pmd_at(struct mm_struct *mm, unsigned long addr, - pte_t orig_pte = __pte(pmd_val(orig)); - bool exec = pte_exec(orig_pte); - -- tlb_batch_add_one(mm, addr, exec); -- tlb_batch_add_one(mm, addr + REAL_HPAGE_SIZE, exec); -+ tlb_batch_add_one(mm, addr, exec, true); -+ tlb_batch_add_one(mm, addr + REAL_HPAGE_SIZE, exec, -+ true); - } else { - tlb_batch_pmd_scan(mm, addr, orig); - } -diff --git a/arch/sparc/mm/tsb.c b/arch/sparc/mm/tsb.c -index a065766..a0604a4 100644 ---- a/arch/sparc/mm/tsb.c -+++ b/arch/sparc/mm/tsb.c -@@ -76,14 +76,15 @@ void flush_tsb_user(struct tlb_batch *tb) - - spin_lock_irqsave(&mm->context.lock, flags); - -- base = (unsigned long) mm->context.tsb_block[MM_TSB_BASE].tsb; -- nentries = mm->context.tsb_block[MM_TSB_BASE].tsb_nentries; -- if (tlb_type == cheetah_plus || tlb_type == hypervisor) -- base = __pa(base); -- __flush_tsb_one(tb, PAGE_SHIFT, base, nentries); -- -+ if (!tb->huge) { -+ base = (unsigned long) mm->context.tsb_block[MM_TSB_BASE].tsb; -+ nentries = mm->context.tsb_block[MM_TSB_BASE].tsb_nentries; -+ if (tlb_type == cheetah_plus || tlb_type == hypervisor) -+ base = __pa(base); -+ __flush_tsb_one(tb, PAGE_SHIFT, base, nentries); -+ } - #if defined(CONFIG_HUGETLB_PAGE) || defined(CONFIG_TRANSPARENT_HUGEPAGE) -- if (mm->context.tsb_block[MM_TSB_HUGE].tsb) { -+ if (tb->huge && mm->context.tsb_block[MM_TSB_HUGE].tsb) { - base = (unsigned long) mm->context.tsb_block[MM_TSB_HUGE].tsb; - nentries = mm->context.tsb_block[MM_TSB_HUGE].tsb_nentries; - if (tlb_type == cheetah_plus || tlb_type == hypervisor) -@@ -94,20 +95,21 @@ void flush_tsb_user(struct tlb_batch *tb) - spin_unlock_irqrestore(&mm->context.lock, flags); - } - --void flush_tsb_user_page(struct mm_struct *mm, unsigned long vaddr) -+void flush_tsb_user_page(struct mm_struct *mm, unsigned long vaddr, bool huge) - { - unsigned long nentries, base, flags; - - spin_lock_irqsave(&mm->context.lock, flags); - -- base = (unsigned long) mm->context.tsb_block[MM_TSB_BASE].tsb; -- nentries = mm->context.tsb_block[MM_TSB_BASE].tsb_nentries; -- if (tlb_type == cheetah_plus || tlb_type == hypervisor) -- base = __pa(base); -- __flush_tsb_one_entry(base, vaddr, PAGE_SHIFT, nentries); -- -+ if (!huge) { -+ base = (unsigned long) mm->context.tsb_block[MM_TSB_BASE].tsb; -+ nentries = mm->context.tsb_block[MM_TSB_BASE].tsb_nentries; -+ if (tlb_type == cheetah_plus || tlb_type == hypervisor) -+ base = __pa(base); -+ __flush_tsb_one_entry(base, vaddr, PAGE_SHIFT, nentries); -+ } - #if defined(CONFIG_HUGETLB_PAGE) || defined(CONFIG_TRANSPARENT_HUGEPAGE) -- if (mm->context.tsb_block[MM_TSB_HUGE].tsb) { -+ if (huge && mm->context.tsb_block[MM_TSB_HUGE].tsb) { - base = (unsigned long) mm->context.tsb_block[MM_TSB_HUGE].tsb; - nentries = mm->context.tsb_block[MM_TSB_HUGE].tsb_nentries; - if (tlb_type == cheetah_plus || tlb_type == hypervisor) -diff --git a/arch/um/drivers/mconsole_kern.c b/arch/um/drivers/mconsole_kern.c -index 29880c9..e22e572 100644 ---- a/arch/um/drivers/mconsole_kern.c -+++ b/arch/um/drivers/mconsole_kern.c -@@ -133,7 +133,7 @@ void mconsole_proc(struct mc_request *req) - ptr += strlen("proc"); - ptr = skip_spaces(ptr); - -- file = file_open_root(mnt->mnt_root, mnt, ptr, O_RDONLY); -+ file = file_open_root(mnt->mnt_root, mnt, ptr, O_RDONLY, 0); - if (IS_ERR(file)) { - mconsole_reply(req, "Failed to open file", 1, 0); - printk(KERN_ERR "open /proc/%s: %ld\n", ptr, PTR_ERR(file)); -diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig -index d8a1650..6ee1dd0 100644 ---- a/arch/x86/Kconfig -+++ b/arch/x86/Kconfig -@@ -1130,22 +1130,23 @@ config MICROCODE - bool "CPU microcode loading support" - default y - depends on CPU_SUP_AMD || CPU_SUP_INTEL -- depends on BLK_DEV_INITRD - select FW_LOADER - ---help--- -- - If you say Y here, you will be able to update the microcode on -- certain Intel and AMD processors. The Intel support is for the -- IA32 family, e.g. Pentium Pro, Pentium II, Pentium III, Pentium 4, -- Xeon etc. The AMD support is for families 0x10 and later. You will -- obviously need the actual microcode binary data itself which is not -- shipped with the Linux kernel. -- -- This option selects the general module only, you need to select -- at least one vendor specific module as well. -- -- To compile this driver as a module, choose M here: the module -- will be called microcode. -+ Intel and AMD processors. The Intel support is for the IA32 family, -+ e.g. Pentium Pro, Pentium II, Pentium III, Pentium 4, Xeon etc. The -+ AMD support is for families 0x10 and later. You will obviously need -+ the actual microcode binary data itself which is not shipped with -+ the Linux kernel. -+ -+ The preferred method to load microcode from a detached initrd is described -+ in Documentation/x86/early-microcode.txt. For that you need to enable -+ CONFIG_BLK_DEV_INITRD in order for the loader to be able to scan the -+ initrd for microcode blobs. -+ -+ In addition, you can build-in the microcode into the kernel. For that you -+ need to enable FIRMWARE_IN_KERNEL and add the vendor-supplied microcode -+ to the CONFIG_EXTRA_FIRMWARE config option. - - config MICROCODE_INTEL - bool "Intel microcode loading support" -diff --git a/arch/x86/crypto/sha-mb/sha1_mb.c b/arch/x86/crypto/sha-mb/sha1_mb.c -index a841e97..8381c09 100644 ---- a/arch/x86/crypto/sha-mb/sha1_mb.c -+++ b/arch/x86/crypto/sha-mb/sha1_mb.c -@@ -453,10 +453,10 @@ static int sha_complete_job(struct mcryptd_hash_request_ctx *rctx, - - req = cast_mcryptd_ctx_to_req(req_ctx); - if (irqs_disabled()) -- rctx->complete(&req->base, ret); -+ req_ctx->complete(&req->base, ret); - else { - local_bh_disable(); -- rctx->complete(&req->base, ret); -+ req_ctx->complete(&req->base, ret); - local_bh_enable(); - } - } -diff --git a/arch/x86/entry/common.c b/arch/x86/entry/common.c -index 3ec240f..75a301b 100644 ---- a/arch/x86/entry/common.c -+++ b/arch/x86/entry/common.c -@@ -275,6 +275,7 @@ static void exit_to_usermode_loop(struct pt_regs *regs, u32 cached_flags) - /* Called with IRQs disabled. */ - __visible inline void prepare_exit_to_usermode(struct pt_regs *regs) - { -+ struct thread_info *ti = pt_regs_to_thread_info(regs); - u32 cached_flags; - - if (IS_ENABLED(CONFIG_PROVE_LOCKING) && WARN_ON(!irqs_disabled())) -@@ -282,12 +283,22 @@ __visible inline void prepare_exit_to_usermode(struct pt_regs *regs) - - lockdep_sys_exit(); - -- cached_flags = -- READ_ONCE(pt_regs_to_thread_info(regs)->flags); -+ cached_flags = READ_ONCE(ti->flags); - - if (unlikely(cached_flags & EXIT_TO_USERMODE_LOOP_FLAGS)) - exit_to_usermode_loop(regs, cached_flags); - -+#ifdef CONFIG_COMPAT -+ /* -+ * Compat syscalls set TS_COMPAT. Make sure we clear it before -+ * returning to user mode. We need to clear it *after* signal -+ * handling, because syscall restart has a fixup for compat -+ * syscalls. The fixup is exercised by the ptrace_syscall_32 -+ * selftest. -+ */ -+ ti->status &= ~TS_COMPAT; -+#endif -+ - user_enter(); - } - -@@ -339,14 +350,6 @@ __visible inline void syscall_return_slowpath(struct pt_regs *regs) - if (unlikely(cached_flags & SYSCALL_EXIT_WORK_FLAGS)) - syscall_slow_exit_work(regs, cached_flags); - --#ifdef CONFIG_COMPAT -- /* -- * Compat syscalls set TS_COMPAT. Make sure we clear it before -- * returning to user mode. -- */ -- ti->status &= ~TS_COMPAT; --#endif -- - local_irq_disable(); - prepare_exit_to_usermode(regs); - } -diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h -index a30316b..163769d 100644 ---- a/arch/x86/include/asm/apic.h -+++ b/arch/x86/include/asm/apic.h -@@ -638,8 +638,8 @@ static inline void entering_irq(void) - - static inline void entering_ack_irq(void) - { -- ack_APIC_irq(); - entering_irq(); -+ ack_APIC_irq(); - } - - static inline void ipi_entering_ack_irq(void) -diff --git a/arch/x86/include/asm/hugetlb.h b/arch/x86/include/asm/hugetlb.h -index f8a29d2..e6a8613 100644 ---- a/arch/x86/include/asm/hugetlb.h -+++ b/arch/x86/include/asm/hugetlb.h -@@ -4,6 +4,7 @@ - #include - #include - -+#define hugepages_supported() cpu_has_pse - - static inline int is_hugepage_only_range(struct mm_struct *mm, - unsigned long addr, -diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h -index 1e3408e..59caa55 100644 ---- a/arch/x86/include/asm/hw_irq.h -+++ b/arch/x86/include/asm/hw_irq.h -@@ -136,6 +136,7 @@ struct irq_alloc_info { - struct irq_cfg { - unsigned int dest_apicid; - u8 vector; -+ u8 old_vector; - }; - - extern struct irq_cfg *irq_cfg(unsigned int irq); -diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h -index 30cfd64..9d2abb2 100644 ---- a/arch/x86/include/asm/kvm_host.h -+++ b/arch/x86/include/asm/kvm_host.h -@@ -41,7 +41,7 @@ - - #define KVM_PIO_PAGE_OFFSET 1 - #define KVM_COALESCED_MMIO_PAGE_OFFSET 2 --#define KVM_HALT_POLL_NS_DEFAULT 500000 -+#define KVM_HALT_POLL_NS_DEFAULT 400000 - - #define KVM_IRQCHIP_NUM_PINS KVM_IOAPIC_NUM_PINS - -diff --git a/arch/x86/include/asm/microcode.h b/arch/x86/include/asm/microcode.h -index 34e62b1..712b24e 100644 ---- a/arch/x86/include/asm/microcode.h -+++ b/arch/x86/include/asm/microcode.h -@@ -2,6 +2,7 @@ - #define _ASM_X86_MICROCODE_H - - #include -+#include - - #define native_rdmsr(msr, val1, val2) \ - do { \ -@@ -168,4 +169,29 @@ static inline void reload_early_microcode(void) { } - static inline bool - get_builtin_firmware(struct cpio_data *cd, const char *name) { return false; } - #endif -+ -+static inline unsigned long get_initrd_start(void) -+{ -+#ifdef CONFIG_BLK_DEV_INITRD -+ return initrd_start; -+#else -+ return 0; -+#endif -+} -+ -+static inline unsigned long get_initrd_start_addr(void) -+{ -+#ifdef CONFIG_BLK_DEV_INITRD -+#ifdef CONFIG_X86_32 -+ unsigned long *initrd_start_p = (unsigned long *)__pa_nodebug(&initrd_start); -+ -+ return (unsigned long)__pa_nodebug(*initrd_start_p); -+#else -+ return get_initrd_start(); -+#endif -+#else /* CONFIG_BLK_DEV_INITRD */ -+ return 0; -+#endif -+} -+ - #endif /* _ASM_X86_MICROCODE_H */ -diff --git a/arch/x86/include/asm/pci_x86.h b/arch/x86/include/asm/pci_x86.h -index fa1195d..164e3f8 100644 ---- a/arch/x86/include/asm/pci_x86.h -+++ b/arch/x86/include/asm/pci_x86.h -@@ -93,6 +93,8 @@ extern raw_spinlock_t pci_config_lock; - extern int (*pcibios_enable_irq)(struct pci_dev *dev); - extern void (*pcibios_disable_irq)(struct pci_dev *dev); - -+extern bool mp_should_keep_irq(struct device *dev); -+ - struct pci_raw_ops { - int (*read)(unsigned int domain, unsigned int bus, unsigned int devfn, - int reg, int len, u32 *val); -diff --git a/arch/x86/include/asm/perf_event.h b/arch/x86/include/asm/perf_event.h -index 7bcb861..5a2ed3e 100644 ---- a/arch/x86/include/asm/perf_event.h -+++ b/arch/x86/include/asm/perf_event.h -@@ -165,6 +165,7 @@ struct x86_pmu_capability { - #define GLOBAL_STATUS_ASIF BIT_ULL(60) - #define GLOBAL_STATUS_COUNTERS_FROZEN BIT_ULL(59) - #define GLOBAL_STATUS_LBRS_FROZEN BIT_ULL(58) -+#define GLOBAL_STATUS_TRACE_TOPAPMI BIT_ULL(55) - - /* - * IBS cpuid feature detection -diff --git a/arch/x86/include/asm/xen/hypervisor.h b/arch/x86/include/asm/xen/hypervisor.h -index 8b2d4be..39171b3 100644 ---- a/arch/x86/include/asm/xen/hypervisor.h -+++ b/arch/x86/include/asm/xen/hypervisor.h -@@ -62,4 +62,6 @@ void xen_arch_register_cpu(int num); - void xen_arch_unregister_cpu(int num); - #endif - -+extern void xen_set_iopl_mask(unsigned mask); -+ - #endif /* _ASM_X86_XEN_HYPERVISOR_H */ -diff --git a/arch/x86/kernel/apic/vector.c b/arch/x86/kernel/apic/vector.c -index a35f6b5..df6b4ee 100644 ---- a/arch/x86/kernel/apic/vector.c -+++ b/arch/x86/kernel/apic/vector.c -@@ -211,6 +211,7 @@ update: - */ - cpumask_and(d->old_domain, d->old_domain, cpu_online_mask); - d->move_in_progress = !cpumask_empty(d->old_domain); -+ d->cfg.old_vector = d->move_in_progress ? d->cfg.vector : 0; - d->cfg.vector = vector; - cpumask_copy(d->domain, vector_cpumask); - success: -@@ -253,7 +254,8 @@ static void clear_irq_vector(int irq, struct apic_chip_data *data) - struct irq_desc *desc; - int cpu, vector; - -- BUG_ON(!data->cfg.vector); -+ if (!data->cfg.vector) -+ return; - - vector = data->cfg.vector; - for_each_cpu_and(cpu, data->domain, cpu_online_mask) -@@ -653,46 +655,97 @@ void irq_complete_move(struct irq_cfg *cfg) - } - - /* -- * Called with @desc->lock held and interrupts disabled. -+ * Called from fixup_irqs() with @desc->lock held and interrupts disabled. - */ - void irq_force_complete_move(struct irq_desc *desc) - { - struct irq_data *irqdata = irq_desc_get_irq_data(desc); - struct apic_chip_data *data = apic_chip_data(irqdata); - struct irq_cfg *cfg = data ? &data->cfg : NULL; -+ unsigned int cpu; - - if (!cfg) - return; - -- __irq_complete_move(cfg, cfg->vector); -- - /* - * This is tricky. If the cleanup of @data->old_domain has not been - * done yet, then the following setaffinity call will fail with - * -EBUSY. This can leave the interrupt in a stale state. - * -- * The cleanup cannot make progress because we hold @desc->lock. So in -- * case @data->old_domain is not yet cleaned up, we need to drop the -- * lock and acquire it again. @desc cannot go away, because the -- * hotplug code holds the sparse irq lock. -+ * All CPUs are stuck in stop machine with interrupts disabled so -+ * calling __irq_complete_move() would be completely pointless. - */ - raw_spin_lock(&vector_lock); -- /* Clean out all offline cpus (including ourself) first. */ -+ /* -+ * Clean out all offline cpus (including the outgoing one) from the -+ * old_domain mask. -+ */ - cpumask_and(data->old_domain, data->old_domain, cpu_online_mask); -- while (!cpumask_empty(data->old_domain)) { -+ -+ /* -+ * If move_in_progress is cleared and the old_domain mask is empty, -+ * then there is nothing to cleanup. fixup_irqs() will take care of -+ * the stale vectors on the outgoing cpu. -+ */ -+ if (!data->move_in_progress && cpumask_empty(data->old_domain)) { - raw_spin_unlock(&vector_lock); -- raw_spin_unlock(&desc->lock); -- cpu_relax(); -- raw_spin_lock(&desc->lock); -+ return; -+ } -+ -+ /* -+ * 1) The interrupt is in move_in_progress state. That means that we -+ * have not seen an interrupt since the io_apic was reprogrammed to -+ * the new vector. -+ * -+ * 2) The interrupt has fired on the new vector, but the cleanup IPIs -+ * have not been processed yet. -+ */ -+ if (data->move_in_progress) { - /* -- * Reevaluate apic_chip_data. It might have been cleared after -- * we dropped @desc->lock. -+ * In theory there is a race: -+ * -+ * set_ioapic(new_vector) <-- Interrupt is raised before update -+ * is effective, i.e. it's raised on -+ * the old vector. -+ * -+ * So if the target cpu cannot handle that interrupt before -+ * the old vector is cleaned up, we get a spurious interrupt -+ * and in the worst case the ioapic irq line becomes stale. -+ * -+ * But in case of cpu hotplug this should be a non issue -+ * because if the affinity update happens right before all -+ * cpus rendevouz in stop machine, there is no way that the -+ * interrupt can be blocked on the target cpu because all cpus -+ * loops first with interrupts enabled in stop machine, so the -+ * old vector is not yet cleaned up when the interrupt fires. -+ * -+ * So the only way to run into this issue is if the delivery -+ * of the interrupt on the apic/system bus would be delayed -+ * beyond the point where the target cpu disables interrupts -+ * in stop machine. I doubt that it can happen, but at least -+ * there is a theroretical chance. Virtualization might be -+ * able to expose this, but AFAICT the IOAPIC emulation is not -+ * as stupid as the real hardware. -+ * -+ * Anyway, there is nothing we can do about that at this point -+ * w/o refactoring the whole fixup_irq() business completely. -+ * We print at least the irq number and the old vector number, -+ * so we have the necessary information when a problem in that -+ * area arises. - */ -- data = apic_chip_data(irqdata); -- if (!data) -- return; -- raw_spin_lock(&vector_lock); -+ pr_warn("IRQ fixup: irq %d move in progress, old vector %d\n", -+ irqdata->irq, cfg->old_vector); - } -+ /* -+ * If old_domain is not empty, then other cpus still have the irq -+ * descriptor set in their vector array. Clean it up. -+ */ -+ for_each_cpu(cpu, data->old_domain) -+ per_cpu(vector_irq, cpu)[cfg->old_vector] = VECTOR_UNUSED; -+ -+ /* Cleanup the left overs of the (half finished) move */ -+ cpumask_clear(data->old_domain); -+ data->move_in_progress = 0; - raw_spin_unlock(&vector_lock); - } - #endif -diff --git a/arch/x86/kernel/cpu/mcheck/mce-genpool.c b/arch/x86/kernel/cpu/mcheck/mce-genpool.c -index 0a85010..2658e2a 100644 ---- a/arch/x86/kernel/cpu/mcheck/mce-genpool.c -+++ b/arch/x86/kernel/cpu/mcheck/mce-genpool.c -@@ -29,7 +29,7 @@ static char gen_pool_buf[MCE_POOLSZ]; - void mce_gen_pool_process(void) - { - struct llist_node *head; -- struct mce_evt_llist *node; -+ struct mce_evt_llist *node, *tmp; - struct mce *mce; - - head = llist_del_all(&mce_event_llist); -@@ -37,7 +37,7 @@ void mce_gen_pool_process(void) - return; - - head = llist_reverse_order(head); -- llist_for_each_entry(node, head, llnode) { -+ llist_for_each_entry_safe(node, tmp, head, llnode) { - mce = &node->mce; - atomic_notifier_call_chain(&x86_mce_decoder_chain, 0, mce); - gen_pool_free(mce_evt_pool, (unsigned long)node, sizeof(*node)); -diff --git a/arch/x86/kernel/cpu/mcheck/therm_throt.c b/arch/x86/kernel/cpu/mcheck/therm_throt.c -index 2c5aaf8..0553858 100644 ---- a/arch/x86/kernel/cpu/mcheck/therm_throt.c -+++ b/arch/x86/kernel/cpu/mcheck/therm_throt.c -@@ -385,6 +385,9 @@ static void intel_thermal_interrupt(void) - { - __u64 msr_val; - -+ if (static_cpu_has(X86_FEATURE_HWP)) -+ wrmsrl_safe(MSR_HWP_STATUS, 0); -+ - rdmsrl(MSR_IA32_THERM_STATUS, msr_val); - - /* Check for violation of core thermal thresholds*/ -diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c -index ce47402..ac8975a 100644 ---- a/arch/x86/kernel/cpu/microcode/intel.c -+++ b/arch/x86/kernel/cpu/microcode/intel.c -@@ -555,10 +555,14 @@ scan_microcode(struct mc_saved_data *mc_saved_data, unsigned long *initrd, - cd.data = NULL; - cd.size = 0; - -- cd = find_cpio_data(p, (void *)start, size, &offset); -- if (!cd.data) { -+ /* try built-in microcode if no initrd */ -+ if (!size) { - if (!load_builtin_intel_microcode(&cd)) - return UCODE_ERROR; -+ } else { -+ cd = find_cpio_data(p, (void *)start, size, &offset); -+ if (!cd.data) -+ return UCODE_ERROR; - } - - return get_matching_model_microcode(0, start, cd.data, cd.size, -@@ -694,7 +698,7 @@ int __init save_microcode_in_initrd_intel(void) - if (count == 0) - return ret; - -- copy_initrd_ptrs(mc_saved, mc_saved_in_initrd, initrd_start, count); -+ copy_initrd_ptrs(mc_saved, mc_saved_in_initrd, get_initrd_start(), count); - ret = save_microcode(&mc_saved_data, mc_saved, count); - if (ret) - pr_err("Cannot save microcode patches from initrd.\n"); -@@ -732,16 +736,20 @@ void __init load_ucode_intel_bsp(void) - struct boot_params *p; - - p = (struct boot_params *)__pa_nodebug(&boot_params); -- start = p->hdr.ramdisk_image; - size = p->hdr.ramdisk_size; - -- _load_ucode_intel_bsp( -- (struct mc_saved_data *)__pa_nodebug(&mc_saved_data), -- (unsigned long *)__pa_nodebug(&mc_saved_in_initrd), -- start, size); -+ /* -+ * Set start only if we have an initrd image. We cannot use initrd_start -+ * because it is not set that early yet. -+ */ -+ start = (size ? p->hdr.ramdisk_image : 0); -+ -+ _load_ucode_intel_bsp((struct mc_saved_data *)__pa_nodebug(&mc_saved_data), -+ (unsigned long *)__pa_nodebug(&mc_saved_in_initrd), -+ start, size); - #else -- start = boot_params.hdr.ramdisk_image + PAGE_OFFSET; - size = boot_params.hdr.ramdisk_size; -+ start = (size ? boot_params.hdr.ramdisk_image + PAGE_OFFSET : 0); - - _load_ucode_intel_bsp(&mc_saved_data, mc_saved_in_initrd, start, size); - #endif -@@ -752,20 +760,14 @@ void load_ucode_intel_ap(void) - struct mc_saved_data *mc_saved_data_p; - struct ucode_cpu_info uci; - unsigned long *mc_saved_in_initrd_p; -- unsigned long initrd_start_addr; - enum ucode_state ret; - #ifdef CONFIG_X86_32 -- unsigned long *initrd_start_p; - -- mc_saved_in_initrd_p = -- (unsigned long *)__pa_nodebug(mc_saved_in_initrd); -+ mc_saved_in_initrd_p = (unsigned long *)__pa_nodebug(mc_saved_in_initrd); - mc_saved_data_p = (struct mc_saved_data *)__pa_nodebug(&mc_saved_data); -- initrd_start_p = (unsigned long *)__pa_nodebug(&initrd_start); -- initrd_start_addr = (unsigned long)__pa_nodebug(*initrd_start_p); - #else -- mc_saved_data_p = &mc_saved_data; - mc_saved_in_initrd_p = mc_saved_in_initrd; -- initrd_start_addr = initrd_start; -+ mc_saved_data_p = &mc_saved_data; - #endif - - /* -@@ -777,7 +779,7 @@ void load_ucode_intel_ap(void) - - collect_cpu_info_early(&uci); - ret = load_microcode(mc_saved_data_p, mc_saved_in_initrd_p, -- initrd_start_addr, &uci); -+ get_initrd_start_addr(), &uci); - - if (ret != UCODE_OK) - return; -diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c -index 2bf79d7..a3aeb2c 100644 ---- a/arch/x86/kernel/cpu/perf_event.c -+++ b/arch/x86/kernel/cpu/perf_event.c -@@ -593,6 +593,19 @@ void x86_pmu_disable_all(void) - } - } - -+/* -+ * There may be PMI landing after enabled=0. The PMI hitting could be before or -+ * after disable_all. -+ * -+ * If PMI hits before disable_all, the PMU will be disabled in the NMI handler. -+ * It will not be re-enabled in the NMI handler again, because enabled=0. After -+ * handling the NMI, disable_all will be called, which will not change the -+ * state either. If PMI hits after disable_all, the PMU is already disabled -+ * before entering NMI handler. The NMI handler will not change the state -+ * either. -+ * -+ * So either situation is harmless. -+ */ - static void x86_pmu_disable(struct pmu *pmu) - { - struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events); -diff --git a/arch/x86/kernel/cpu/perf_event.h b/arch/x86/kernel/cpu/perf_event.h -index d0e35eb..ee70445 100644 ---- a/arch/x86/kernel/cpu/perf_event.h -+++ b/arch/x86/kernel/cpu/perf_event.h -@@ -591,6 +591,7 @@ struct x86_pmu { - pebs_active :1, - pebs_broken :1; - int pebs_record_size; -+ int pebs_buffer_size; - void (*drain_pebs)(struct pt_regs *regs); - struct event_constraint *pebs_constraints; - void (*pebs_aliases)(struct perf_event *event); -@@ -907,6 +908,8 @@ void intel_pmu_lbr_init_hsw(void); - - void intel_pmu_lbr_init_skl(void); - -+void intel_pmu_pebs_data_source_nhm(void); -+ - int intel_pmu_setup_lbr_filter(struct perf_event *event); - - void intel_pt_interrupt(void); -diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c -index e2a4300..078de2e 100644 ---- a/arch/x86/kernel/cpu/perf_event_intel.c -+++ b/arch/x86/kernel/cpu/perf_event_intel.c -@@ -1458,7 +1458,15 @@ static __initconst const u64 slm_hw_cache_event_ids - }; - - /* -- * Use from PMIs where the LBRs are already disabled. -+ * Used from PMIs where the LBRs are already disabled. -+ * -+ * This function could be called consecutively. It is required to remain in -+ * disabled state if called consecutively. -+ * -+ * During consecutive calls, the same disable value will be written to related -+ * registers, so the PMU state remains unchanged. hw.state in -+ * intel_bts_disable_local will remain PERF_HES_STOPPED too in consecutive -+ * calls. - */ - static void __intel_pmu_disable_all(void) - { -@@ -1840,6 +1848,16 @@ again: - if (__test_and_clear_bit(62, (unsigned long *)&status)) { - handled++; - x86_pmu.drain_pebs(regs); -+ /* -+ * There are cases where, even though, the PEBS ovfl bit is set -+ * in GLOBAL_OVF_STATUS, the PEBS events may also have their -+ * overflow bits set for their counters. We must clear them -+ * here because they have been processed as exact samples in -+ * the drain_pebs() routine. They must not be processed again -+ * in the for_each_bit_set() loop for regular samples below. -+ */ -+ status &= ~cpuc->pebs_enabled; -+ status &= x86_pmu.intel_ctrl | GLOBAL_STATUS_TRACE_TOPAPMI; - } - - /* -@@ -1885,7 +1903,10 @@ again: - goto again; - - done: -- __intel_pmu_enable_all(0, true); -+ /* Only restore PMU state when it's active. See x86_pmu_disable(). */ -+ if (cpuc->enabled) -+ __intel_pmu_enable_all(0, true); -+ - /* - * Only unmask the NMI after the overflow counters - * have been reset. This avoids spurious NMIs on -@@ -3315,6 +3336,7 @@ __init int intel_pmu_init(void) - intel_perfmon_event_map[PERF_COUNT_HW_STALLED_CYCLES_BACKEND] = - X86_CONFIG(.event=0xb1, .umask=0x3f, .inv=1, .cmask=1); - -+ intel_pmu_pebs_data_source_nhm(); - x86_add_quirk(intel_nehalem_quirk); - - pr_cont("Nehalem events, "); -@@ -3377,6 +3399,7 @@ __init int intel_pmu_init(void) - intel_perfmon_event_map[PERF_COUNT_HW_STALLED_CYCLES_BACKEND] = - X86_CONFIG(.event=0xb1, .umask=0x3f, .inv=1, .cmask=1); - -+ intel_pmu_pebs_data_source_nhm(); - pr_cont("Westmere events, "); - break; - -diff --git a/arch/x86/kernel/cpu/perf_event_intel_ds.c b/arch/x86/kernel/cpu/perf_event_intel_ds.c -index 5db1c77..7abb2b8 100644 ---- a/arch/x86/kernel/cpu/perf_event_intel_ds.c -+++ b/arch/x86/kernel/cpu/perf_event_intel_ds.c -@@ -51,7 +51,8 @@ union intel_x86_pebs_dse { - #define OP_LH (P(OP, LOAD) | P(LVL, HIT)) - #define SNOOP_NONE_MISS (P(SNOOP, NONE) | P(SNOOP, MISS)) - --static const u64 pebs_data_source[] = { -+/* Version for Sandy Bridge and later */ -+static u64 pebs_data_source[] = { - P(OP, LOAD) | P(LVL, MISS) | P(LVL, L3) | P(SNOOP, NA),/* 0x00:ukn L3 */ - OP_LH | P(LVL, L1) | P(SNOOP, NONE), /* 0x01: L1 local */ - OP_LH | P(LVL, LFB) | P(SNOOP, NONE), /* 0x02: LFB hit */ -@@ -70,6 +71,14 @@ static const u64 pebs_data_source[] = { - OP_LH | P(LVL, UNC) | P(SNOOP, NONE), /* 0x0f: uncached */ - }; - -+/* Patch up minor differences in the bits */ -+void __init intel_pmu_pebs_data_source_nhm(void) -+{ -+ pebs_data_source[0x05] = OP_LH | P(LVL, L3) | P(SNOOP, HIT); -+ pebs_data_source[0x06] = OP_LH | P(LVL, L3) | P(SNOOP, HITM); -+ pebs_data_source[0x07] = OP_LH | P(LVL, L3) | P(SNOOP, HITM); -+} -+ - static u64 precise_store_data(u64 status) - { - union intel_x86_pebs_dse dse; -@@ -269,7 +278,7 @@ static int alloc_pebs_buffer(int cpu) - if (!x86_pmu.pebs) - return 0; - -- buffer = kzalloc_node(PEBS_BUFFER_SIZE, GFP_KERNEL, node); -+ buffer = kzalloc_node(x86_pmu.pebs_buffer_size, GFP_KERNEL, node); - if (unlikely(!buffer)) - return -ENOMEM; - -@@ -286,7 +295,7 @@ static int alloc_pebs_buffer(int cpu) - per_cpu(insn_buffer, cpu) = ibuffer; - } - -- max = PEBS_BUFFER_SIZE / x86_pmu.pebs_record_size; -+ max = x86_pmu.pebs_buffer_size / x86_pmu.pebs_record_size; - - ds->pebs_buffer_base = (u64)(unsigned long)buffer; - ds->pebs_index = ds->pebs_buffer_base; -@@ -1296,6 +1305,7 @@ void __init intel_ds_init(void) - - x86_pmu.bts = boot_cpu_has(X86_FEATURE_BTS); - x86_pmu.pebs = boot_cpu_has(X86_FEATURE_PEBS); -+ x86_pmu.pebs_buffer_size = PEBS_BUFFER_SIZE; - if (x86_pmu.pebs) { - char pebs_type = x86_pmu.intel_cap.pebs_trap ? '+' : '-'; - int format = x86_pmu.intel_cap.pebs_format; -@@ -1304,6 +1314,14 @@ void __init intel_ds_init(void) - case 0: - printk(KERN_CONT "PEBS fmt0%c, ", pebs_type); - x86_pmu.pebs_record_size = sizeof(struct pebs_record_core); -+ /* -+ * Using >PAGE_SIZE buffers makes the WRMSR to -+ * PERF_GLOBAL_CTRL in intel_pmu_enable_all() -+ * mysteriously hang on Core2. -+ * -+ * As a workaround, we don't do this. -+ */ -+ x86_pmu.pebs_buffer_size = PAGE_SIZE; - x86_pmu.drain_pebs = intel_pmu_drain_pebs_core; - break; - -diff --git a/arch/x86/kernel/cpu/perf_event_intel_pt.c b/arch/x86/kernel/cpu/perf_event_intel_pt.c -index 868e119..49e35d0 100644 ---- a/arch/x86/kernel/cpu/perf_event_intel_pt.c -+++ b/arch/x86/kernel/cpu/perf_event_intel_pt.c -@@ -694,6 +694,7 @@ static int pt_buffer_reset_markers(struct pt_buffer *buf, - - /* clear STOP and INT from current entry */ - buf->topa_index[buf->stop_pos]->stop = 0; -+ buf->topa_index[buf->stop_pos]->intr = 0; - buf->topa_index[buf->intr_pos]->intr = 0; - - /* how many pages till the STOP marker */ -@@ -718,6 +719,7 @@ static int pt_buffer_reset_markers(struct pt_buffer *buf, - buf->intr_pos = idx; - - buf->topa_index[buf->stop_pos]->stop = 1; -+ buf->topa_index[buf->stop_pos]->intr = 1; - buf->topa_index[buf->intr_pos]->intr = 1; - - return 0; -diff --git a/arch/x86/kernel/cpu/perf_event_intel_rapl.c b/arch/x86/kernel/cpu/perf_event_intel_rapl.c -index ed446bd..d2ac364 100644 ---- a/arch/x86/kernel/cpu/perf_event_intel_rapl.c -+++ b/arch/x86/kernel/cpu/perf_event_intel_rapl.c -@@ -117,7 +117,7 @@ static struct perf_pmu_events_attr event_attr_##v = { \ - }; - - struct rapl_pmu { -- spinlock_t lock; -+ raw_spinlock_t lock; - int n_active; /* number of active events */ - struct list_head active_list; - struct pmu *pmu; /* pointer to rapl_pmu_class */ -@@ -220,13 +220,13 @@ static enum hrtimer_restart rapl_hrtimer_handle(struct hrtimer *hrtimer) - if (!pmu->n_active) - return HRTIMER_NORESTART; - -- spin_lock_irqsave(&pmu->lock, flags); -+ raw_spin_lock_irqsave(&pmu->lock, flags); - - list_for_each_entry(event, &pmu->active_list, active_entry) { - rapl_event_update(event); - } - -- spin_unlock_irqrestore(&pmu->lock, flags); -+ raw_spin_unlock_irqrestore(&pmu->lock, flags); - - hrtimer_forward_now(hrtimer, pmu->timer_interval); - -@@ -263,9 +263,9 @@ static void rapl_pmu_event_start(struct perf_event *event, int mode) - struct rapl_pmu *pmu = __this_cpu_read(rapl_pmu); - unsigned long flags; - -- spin_lock_irqsave(&pmu->lock, flags); -+ raw_spin_lock_irqsave(&pmu->lock, flags); - __rapl_pmu_event_start(pmu, event); -- spin_unlock_irqrestore(&pmu->lock, flags); -+ raw_spin_unlock_irqrestore(&pmu->lock, flags); - } - - static void rapl_pmu_event_stop(struct perf_event *event, int mode) -@@ -274,7 +274,7 @@ static void rapl_pmu_event_stop(struct perf_event *event, int mode) - struct hw_perf_event *hwc = &event->hw; - unsigned long flags; - -- spin_lock_irqsave(&pmu->lock, flags); -+ raw_spin_lock_irqsave(&pmu->lock, flags); - - /* mark event as deactivated and stopped */ - if (!(hwc->state & PERF_HES_STOPPED)) { -@@ -299,7 +299,7 @@ static void rapl_pmu_event_stop(struct perf_event *event, int mode) - hwc->state |= PERF_HES_UPTODATE; - } - -- spin_unlock_irqrestore(&pmu->lock, flags); -+ raw_spin_unlock_irqrestore(&pmu->lock, flags); - } - - static int rapl_pmu_event_add(struct perf_event *event, int mode) -@@ -308,14 +308,14 @@ static int rapl_pmu_event_add(struct perf_event *event, int mode) - struct hw_perf_event *hwc = &event->hw; - unsigned long flags; - -- spin_lock_irqsave(&pmu->lock, flags); -+ raw_spin_lock_irqsave(&pmu->lock, flags); - - hwc->state = PERF_HES_UPTODATE | PERF_HES_STOPPED; - - if (mode & PERF_EF_START) - __rapl_pmu_event_start(pmu, event); - -- spin_unlock_irqrestore(&pmu->lock, flags); -+ raw_spin_unlock_irqrestore(&pmu->lock, flags); - - return 0; - } -@@ -603,7 +603,7 @@ static int rapl_cpu_prepare(int cpu) - pmu = kzalloc_node(sizeof(*pmu), GFP_KERNEL, cpu_to_node(cpu)); - if (!pmu) - return -1; -- spin_lock_init(&pmu->lock); -+ raw_spin_lock_init(&pmu->lock); - - INIT_LIST_HEAD(&pmu->active_list); - -diff --git a/arch/x86/kernel/cpu/perf_event_knc.c b/arch/x86/kernel/cpu/perf_event_knc.c -index 5b0c232..b931095 100644 ---- a/arch/x86/kernel/cpu/perf_event_knc.c -+++ b/arch/x86/kernel/cpu/perf_event_knc.c -@@ -263,7 +263,9 @@ again: - goto again; - - done: -- knc_pmu_enable_all(0); -+ /* Only restore PMU state when it's active. See x86_pmu_disable(). */ -+ if (cpuc->enabled) -+ knc_pmu_enable_all(0); - - return handled; - } -diff --git a/arch/x86/kernel/ioport.c b/arch/x86/kernel/ioport.c -index 37dae79..589b319 100644 ---- a/arch/x86/kernel/ioport.c -+++ b/arch/x86/kernel/ioport.c -@@ -96,9 +96,14 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on) - SYSCALL_DEFINE1(iopl, unsigned int, level) - { - struct pt_regs *regs = current_pt_regs(); -- unsigned int old = (regs->flags >> 12) & 3; - struct thread_struct *t = ¤t->thread; - -+ /* -+ * Careful: the IOPL bits in regs->flags are undefined under Xen PV -+ * and changing them has no effect. -+ */ -+ unsigned int old = t->iopl >> X86_EFLAGS_IOPL_BIT; -+ - if (level > 3) - return -EINVAL; - /* Trying to gain more privileges? */ -@@ -106,8 +111,9 @@ SYSCALL_DEFINE1(iopl, unsigned int, level) - if (!capable(CAP_SYS_RAWIO)) - return -EPERM; - } -- regs->flags = (regs->flags & ~X86_EFLAGS_IOPL) | (level << 12); -- t->iopl = level << 12; -+ regs->flags = (regs->flags & ~X86_EFLAGS_IOPL) | -+ (level << X86_EFLAGS_IOPL_BIT); -+ t->iopl = level << X86_EFLAGS_IOPL_BIT; - set_iopl_mask(t->iopl); - - return 0; -diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c -index 47190bd..8079508 100644 ---- a/arch/x86/kernel/kvm.c -+++ b/arch/x86/kernel/kvm.c -@@ -36,6 +36,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -91,14 +92,14 @@ static void kvm_io_delay(void) - - struct kvm_task_sleep_node { - struct hlist_node link; -- wait_queue_head_t wq; -+ struct swait_queue_head wq; - u32 token; - int cpu; - bool halted; - }; - - static struct kvm_task_sleep_head { -- spinlock_t lock; -+ raw_spinlock_t lock; - struct hlist_head list; - } async_pf_sleepers[KVM_TASK_SLEEP_HASHSIZE]; - -@@ -122,17 +123,17 @@ void kvm_async_pf_task_wait(u32 token) - u32 key = hash_32(token, KVM_TASK_SLEEP_HASHBITS); - struct kvm_task_sleep_head *b = &async_pf_sleepers[key]; - struct kvm_task_sleep_node n, *e; -- DEFINE_WAIT(wait); -+ DECLARE_SWAITQUEUE(wait); - - rcu_irq_enter(); - -- spin_lock(&b->lock); -+ raw_spin_lock(&b->lock); - e = _find_apf_task(b, token); - if (e) { - /* dummy entry exist -> wake up was delivered ahead of PF */ - hlist_del(&e->link); - kfree(e); -- spin_unlock(&b->lock); -+ raw_spin_unlock(&b->lock); - - rcu_irq_exit(); - return; -@@ -141,13 +142,13 @@ void kvm_async_pf_task_wait(u32 token) - n.token = token; - n.cpu = smp_processor_id(); - n.halted = is_idle_task(current) || preempt_count() > 1; -- init_waitqueue_head(&n.wq); -+ init_swait_queue_head(&n.wq); - hlist_add_head(&n.link, &b->list); -- spin_unlock(&b->lock); -+ raw_spin_unlock(&b->lock); - - for (;;) { - if (!n.halted) -- prepare_to_wait(&n.wq, &wait, TASK_UNINTERRUPTIBLE); -+ prepare_to_swait(&n.wq, &wait, TASK_UNINTERRUPTIBLE); - if (hlist_unhashed(&n.link)) - break; - -@@ -166,7 +167,7 @@ void kvm_async_pf_task_wait(u32 token) - } - } - if (!n.halted) -- finish_wait(&n.wq, &wait); -+ finish_swait(&n.wq, &wait); - - rcu_irq_exit(); - return; -@@ -178,8 +179,8 @@ static void apf_task_wake_one(struct kvm_task_sleep_node *n) - hlist_del_init(&n->link); - if (n->halted) - smp_send_reschedule(n->cpu); -- else if (waitqueue_active(&n->wq)) -- wake_up(&n->wq); -+ else if (swait_active(&n->wq)) -+ swake_up(&n->wq); - } - - static void apf_task_wake_all(void) -@@ -189,14 +190,14 @@ static void apf_task_wake_all(void) - for (i = 0; i < KVM_TASK_SLEEP_HASHSIZE; i++) { - struct hlist_node *p, *next; - struct kvm_task_sleep_head *b = &async_pf_sleepers[i]; -- spin_lock(&b->lock); -+ raw_spin_lock(&b->lock); - hlist_for_each_safe(p, next, &b->list) { - struct kvm_task_sleep_node *n = - hlist_entry(p, typeof(*n), link); - if (n->cpu == smp_processor_id()) - apf_task_wake_one(n); - } -- spin_unlock(&b->lock); -+ raw_spin_unlock(&b->lock); - } - } - -@@ -212,7 +213,7 @@ void kvm_async_pf_task_wake(u32 token) - } - - again: -- spin_lock(&b->lock); -+ raw_spin_lock(&b->lock); - n = _find_apf_task(b, token); - if (!n) { - /* -@@ -225,17 +226,17 @@ again: - * Allocation failed! Busy wait while other cpu - * handles async PF. - */ -- spin_unlock(&b->lock); -+ raw_spin_unlock(&b->lock); - cpu_relax(); - goto again; - } - n->token = token; - n->cpu = smp_processor_id(); -- init_waitqueue_head(&n->wq); -+ init_swait_queue_head(&n->wq); - hlist_add_head(&n->link, &b->list); - } else - apf_task_wake_one(n); -- spin_unlock(&b->lock); -+ raw_spin_unlock(&b->lock); - return; - } - EXPORT_SYMBOL_GPL(kvm_async_pf_task_wake); -@@ -486,7 +487,7 @@ void __init kvm_guest_init(void) - paravirt_ops_setup(); - register_reboot_notifier(&kvm_pv_reboot_nb); - for (i = 0; i < KVM_TASK_SLEEP_HASHSIZE; i++) -- spin_lock_init(&async_pf_sleepers[i].lock); -+ raw_spin_lock_init(&async_pf_sleepers[i].lock); - if (kvm_para_has_feature(KVM_FEATURE_ASYNC_PF)) - x86_init.irqs.trap_init = kvm_apf_trap_init; - -diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c -index 697f90d..424aec4 100644 ---- a/arch/x86/kernel/nmi.c -+++ b/arch/x86/kernel/nmi.c -@@ -231,7 +231,7 @@ pci_serr_error(unsigned char reason, struct pt_regs *regs) - #endif - - if (panic_on_unrecovered_nmi) -- panic("NMI: Not continuing"); -+ nmi_panic(regs, "NMI: Not continuing"); - - pr_emerg("Dazed and confused, but trying to continue\n"); - -@@ -255,8 +255,16 @@ io_check_error(unsigned char reason, struct pt_regs *regs) - reason, smp_processor_id()); - show_regs(regs); - -- if (panic_on_io_nmi) -- panic("NMI IOCK error: Not continuing"); -+ if (panic_on_io_nmi) { -+ nmi_panic(regs, "NMI IOCK error: Not continuing"); -+ -+ /* -+ * If we end up here, it means we have received an NMI while -+ * processing panic(). Simply return without delaying and -+ * re-enabling NMIs. -+ */ -+ return; -+ } - - /* Re-enable the IOCK line, wait for a few seconds */ - reason = (reason & NMI_REASON_CLEAR_MASK) | NMI_REASON_CLEAR_IOCHK; -@@ -297,7 +305,7 @@ unknown_nmi_error(unsigned char reason, struct pt_regs *regs) - - pr_emerg("Do you have a strange power saving mode enabled?\n"); - if (unknown_nmi_panic || panic_on_unrecovered_nmi) -- panic("NMI: Not continuing"); -+ nmi_panic(regs, "NMI: Not continuing"); - - pr_emerg("Dazed and confused, but trying to continue\n"); - } -diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c -index e835d26..4cbb60f 100644 ---- a/arch/x86/kernel/process_64.c -+++ b/arch/x86/kernel/process_64.c -@@ -48,6 +48,7 @@ - #include - #include - #include -+#include - - asmlinkage extern void ret_from_fork(void); - -@@ -411,6 +412,17 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p) - task_thread_info(prev_p)->flags & _TIF_WORK_CTXSW_PREV)) - __switch_to_xtra(prev_p, next_p, tss); - -+#ifdef CONFIG_XEN -+ /* -+ * On Xen PV, IOPL bits in pt_regs->flags have no effect, and -+ * current_pt_regs()->flags may not match the current task's -+ * intended IOPL. We need to switch it manually. -+ */ -+ if (unlikely(static_cpu_has(X86_FEATURE_XENPV) && -+ prev->iopl != next->iopl)) -+ xen_set_iopl_mask(next->iopl); -+#endif -+ - if (static_cpu_has_bug(X86_BUG_SYSRET_SS_ATTRS)) { - /* - * AMD CPUs have a misfeature: SYSRET sets the SS selector but -diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c -index f660d63..8384207 100644 ---- a/arch/x86/kernel/reboot.c -+++ b/arch/x86/kernel/reboot.c -@@ -726,6 +726,7 @@ static int crashing_cpu; - static nmi_shootdown_cb shootdown_callback; - - static atomic_t waiting_for_crash_ipi; -+static int crash_ipi_issued; - - static int crash_nmi_callback(unsigned int val, struct pt_regs *regs) - { -@@ -788,6 +789,9 @@ void nmi_shootdown_cpus(nmi_shootdown_cb callback) - - smp_send_nmi_allbutself(); - -+ /* Kick CPUs looping in NMI context. */ -+ WRITE_ONCE(crash_ipi_issued, 1); -+ - msecs = 1000; /* Wait at most a second for the other cpus to stop */ - while ((atomic_read(&waiting_for_crash_ipi) > 0) && msecs) { - mdelay(1); -@@ -796,6 +800,22 @@ void nmi_shootdown_cpus(nmi_shootdown_cb callback) - - /* Leave the nmi callback set */ - } -+ -+/* Override the weak function in kernel/panic.c */ -+void nmi_panic_self_stop(struct pt_regs *regs) -+{ -+ while (1) { -+ /* -+ * Wait for the crash dumping IPI to be issued, and then -+ * call its callback directly. -+ */ -+ if (READ_ONCE(crash_ipi_issued)) -+ crash_nmi_callback(0, regs); /* Don't return */ -+ -+ cpu_relax(); -+ } -+} -+ - #else /* !CONFIG_SMP */ - void nmi_shootdown_cpus(nmi_shootdown_cb callback) - { -diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c -index fbabe4f..b0256e0 100644 ---- a/arch/x86/kernel/smpboot.c -+++ b/arch/x86/kernel/smpboot.c -@@ -429,7 +429,12 @@ void set_cpu_sibling_map(int cpu) - } else if (i != cpu && !c->booted_cores) - c->booted_cores = cpu_data(i).booted_cores; - } -+#ifndef CONFIG_NUMA - if (match_die(c, o) && !topology_same_node(c, o)) -+#else -+ if (match_die(c, o) && !topology_same_node(c, o) -+ && sched_max_numa_distance == -1) -+#endif - primarily_use_numa_for_topology(); - } - } -diff --git a/arch/x86/kernel/sysfb_efi.c b/arch/x86/kernel/sysfb_efi.c -index b285d4e..5da924b 100644 ---- a/arch/x86/kernel/sysfb_efi.c -+++ b/arch/x86/kernel/sysfb_efi.c -@@ -106,14 +106,24 @@ static int __init efifb_set_system(const struct dmi_system_id *id) - continue; - for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { - resource_size_t start, end; -+ unsigned long flags; -+ -+ flags = pci_resource_flags(dev, i); -+ if (!(flags & IORESOURCE_MEM)) -+ continue; -+ -+ if (flags & IORESOURCE_UNSET) -+ continue; -+ -+ if (pci_resource_len(dev, i) == 0) -+ continue; - - start = pci_resource_start(dev, i); -- if (start == 0) -- break; - end = pci_resource_end(dev, i); - if (screen_info.lfb_base >= start && - screen_info.lfb_base < end) { - found_bar = 1; -+ break; - } - } - } -diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c -index ade185a..679302c 100644 ---- a/arch/x86/kernel/traps.c -+++ b/arch/x86/kernel/traps.c -@@ -109,6 +109,12 @@ static inline void preempt_conditional_cli(struct pt_regs *regs) - preempt_count_dec(); - } - -+/* -+ * In IST context, we explicitly disable preemption. This serves two -+ * purposes: it makes it much less likely that we would accidentally -+ * schedule in IST context and it will force a warning if we somehow -+ * manage to schedule by accident. -+ */ - void ist_enter(struct pt_regs *regs) - { - if (user_mode(regs)) { -@@ -123,13 +129,7 @@ void ist_enter(struct pt_regs *regs) - rcu_nmi_enter(); - } - -- /* -- * We are atomic because we're on the IST stack; or we're on -- * x86_32, in which case we still shouldn't schedule; or we're -- * on x86_64 and entered from user mode, in which case we're -- * still atomic unless ist_begin_non_atomic is called. -- */ -- preempt_count_add(HARDIRQ_OFFSET); -+ preempt_disable(); - - /* This code is a bit fragile. Test it. */ - RCU_LOCKDEP_WARN(!rcu_is_watching(), "ist_enter didn't work"); -@@ -137,7 +137,7 @@ void ist_enter(struct pt_regs *regs) - - void ist_exit(struct pt_regs *regs) - { -- preempt_count_sub(HARDIRQ_OFFSET); -+ preempt_enable_no_resched(); - - if (!user_mode(regs)) - rcu_nmi_exit(); -@@ -168,7 +168,7 @@ void ist_begin_non_atomic(struct pt_regs *regs) - BUG_ON((unsigned long)(current_top_of_stack() - - current_stack_pointer()) >= THREAD_SIZE); - -- preempt_count_sub(HARDIRQ_OFFSET); -+ preempt_enable_no_resched(); - } - - /** -@@ -178,7 +178,7 @@ void ist_begin_non_atomic(struct pt_regs *regs) - */ - void ist_end_non_atomic(void) - { -- preempt_count_add(HARDIRQ_OFFSET); -+ preempt_disable(); - } - - static nokprobe_inline int -diff --git a/arch/x86/kernel/tsc_msr.c b/arch/x86/kernel/tsc_msr.c -index 92ae6ac..6aa0f4d 100644 ---- a/arch/x86/kernel/tsc_msr.c -+++ b/arch/x86/kernel/tsc_msr.c -@@ -92,7 +92,7 @@ unsigned long try_msr_calibrate_tsc(void) - - if (freq_desc_tables[cpu_index].msr_plat) { - rdmsr(MSR_PLATFORM_INFO, lo, hi); -- ratio = (lo >> 8) & 0x1f; -+ ratio = (lo >> 8) & 0xff; - } else { - rdmsr(MSR_IA32_PERF_STATUS, lo, hi); - ratio = (hi >> 8) & 0x1f; -diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c -index 6525e92..2e1fd58 100644 ---- a/arch/x86/kvm/cpuid.c -+++ b/arch/x86/kvm/cpuid.c -@@ -509,6 +509,7 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function, - do_cpuid_1_ent(&entry[i], function, idx); - if (idx == 1) { - entry[i].eax &= kvm_supported_word10_x86_features; -+ cpuid_mask(&entry[i].eax, 10); - entry[i].ebx = 0; - if (entry[i].eax & (F(XSAVES)|F(XSAVEC))) - entry[i].ebx = -diff --git a/arch/x86/kvm/i8254.c b/arch/x86/kvm/i8254.c -index b0ea42b..ab53187 100644 ---- a/arch/x86/kvm/i8254.c -+++ b/arch/x86/kvm/i8254.c -@@ -245,7 +245,7 @@ static void kvm_pit_ack_irq(struct kvm_irq_ack_notifier *kian) - * PIC is being reset. Handle it gracefully here - */ - atomic_inc(&ps->pending); -- else if (value > 0) -+ else if (value > 0 && ps->reinject) - /* in this case, we had multiple outstanding pit interrupts - * that we needed to inject. Reinject - */ -@@ -288,7 +288,9 @@ static void pit_do_work(struct kthread_work *work) - * last one has been acked. - */ - spin_lock(&ps->inject_lock); -- if (ps->irq_ack) { -+ if (!ps->reinject) -+ inject = 1; -+ else if (ps->irq_ack) { - ps->irq_ack = 0; - inject = 1; - } -@@ -317,10 +319,10 @@ static enum hrtimer_restart pit_timer_fn(struct hrtimer *data) - struct kvm_kpit_state *ps = container_of(data, struct kvm_kpit_state, timer); - struct kvm_pit *pt = ps->kvm->arch.vpit; - -- if (ps->reinject || !atomic_read(&ps->pending)) { -+ if (ps->reinject) - atomic_inc(&ps->pending); -- queue_kthread_work(&pt->worker, &pt->expired); -- } -+ -+ queue_kthread_work(&pt->worker, &pt->expired); - - if (ps->is_periodic) { - hrtimer_add_expires_ns(&ps->timer, ps->period); -diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c -index 906a1ec..20d9e9f 100644 ---- a/arch/x86/kvm/lapic.c -+++ b/arch/x86/kvm/lapic.c -@@ -1195,7 +1195,7 @@ static void apic_update_lvtt(struct kvm_lapic *apic) - static void apic_timer_expired(struct kvm_lapic *apic) - { - struct kvm_vcpu *vcpu = apic->vcpu; -- struct swait_head *q = &vcpu->wq; -+ struct swait_queue_head *q = &vcpu->wq; - struct kvm_timer *ktimer = &apic->lapic_timer; - - if (atomic_read(&apic->lapic_timer.pending)) -@@ -1204,8 +1204,8 @@ static void apic_timer_expired(struct kvm_lapic *apic) - atomic_inc(&apic->lapic_timer.pending); - kvm_set_pending_timer(vcpu); - -- if (swaitqueue_active(q)) -- swait_wake_interruptible(q); -+ if (swait_active(q)) -+ swake_up(q); - - if (apic_lvtt_tscdeadline(apic)) - ktimer->expired_tscdeadline = ktimer->tscdeadline; -diff --git a/arch/x86/kvm/mtrr.c b/arch/x86/kvm/mtrr.c -index 3f8c732..c146f3c 100644 ---- a/arch/x86/kvm/mtrr.c -+++ b/arch/x86/kvm/mtrr.c -@@ -44,8 +44,6 @@ static bool msr_mtrr_valid(unsigned msr) - case MSR_MTRRdefType: - case MSR_IA32_CR_PAT: - return true; -- case 0x2f8: -- return true; - } - return false; - } -diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c -index 0958fa2..f314e9b 100644 ---- a/arch/x86/kvm/vmx.c -+++ b/arch/x86/kvm/vmx.c -@@ -2637,8 +2637,15 @@ static void nested_vmx_setup_ctls_msrs(struct vcpu_vmx *vmx) - } else - vmx->nested.nested_vmx_ept_caps = 0; - -+ /* -+ * Old versions of KVM use the single-context version without -+ * checking for support, so declare that it is supported even -+ * though it is treated as global context. The alternative is -+ * not failing the single-context invvpid, and it is worse. -+ */ - if (enable_vpid) - vmx->nested.nested_vmx_vpid_caps = VMX_VPID_INVVPID_BIT | -+ VMX_VPID_EXTENT_SINGLE_CONTEXT_BIT | - VMX_VPID_EXTENT_GLOBAL_CONTEXT_BIT; - else - vmx->nested.nested_vmx_vpid_caps = 0; -@@ -4947,8 +4954,8 @@ static void vmx_vcpu_reset(struct kvm_vcpu *vcpu, bool init_event) - vmcs_write16(VIRTUAL_PROCESSOR_ID, vmx->vpid); - - cr0 = X86_CR0_NW | X86_CR0_CD | X86_CR0_ET; -- vmx_set_cr0(vcpu, cr0); /* enter rmode */ - vmx->vcpu.arch.cr0 = cr0; -+ vmx_set_cr0(vcpu, cr0); /* enter rmode */ - vmx_set_cr4(vcpu, 0); - vmx_set_efer(vcpu, 0); - vmx_fpu_activate(vcpu); -@@ -7340,6 +7347,7 @@ static int handle_invept(struct kvm_vcpu *vcpu) - if (!(types & (1UL << type))) { - nested_vmx_failValid(vcpu, - VMXERR_INVALID_OPERAND_TO_INVEPT_INVVPID); -+ skip_emulated_instruction(vcpu); - return 1; - } - -@@ -7398,6 +7406,7 @@ static int handle_invvpid(struct kvm_vcpu *vcpu) - if (!(types & (1UL << type))) { - nested_vmx_failValid(vcpu, - VMXERR_INVALID_OPERAND_TO_INVEPT_INVVPID); -+ skip_emulated_instruction(vcpu); - return 1; - } - -@@ -7414,12 +7423,17 @@ static int handle_invvpid(struct kvm_vcpu *vcpu) - } - - switch (type) { -+ case VMX_VPID_EXTENT_SINGLE_CONTEXT: -+ /* -+ * Old versions of KVM use the single-context version so we -+ * have to support it; just treat it the same as all-context. -+ */ - case VMX_VPID_EXTENT_ALL_CONTEXT: - __vmx_flush_tlb(vcpu, to_vmx(vcpu)->nested.vpid02); - nested_vmx_succeed(vcpu); - break; - default: -- /* Trap single context invalidation invvpid calls */ -+ /* Trap individual address invalidation invvpid calls */ - BUG_ON(1); - break; - } -diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c -index 27419ba..6974578 100644 ---- a/arch/x86/kvm/x86.c -+++ b/arch/x86/kvm/x86.c -@@ -697,7 +697,6 @@ static int __kvm_set_xcr(struct kvm_vcpu *vcpu, u32 index, u64 xcr) - if ((xcr0 & XFEATURE_MASK_AVX512) != XFEATURE_MASK_AVX512) - return 1; - } -- kvm_put_guest_xcr0(vcpu); - vcpu->arch.xcr0 = xcr0; - - if ((xcr0 ^ old_xcr0) & XFEATURE_MASK_EXTEND) -@@ -2736,6 +2735,7 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu) - } - - kvm_make_request(KVM_REQ_STEAL_UPDATE, vcpu); -+ vcpu->arch.switch_db_regs |= KVM_DEBUGREG_RELOAD; - } - - void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu) -@@ -3014,6 +3014,11 @@ static int kvm_vcpu_ioctl_x86_set_debugregs(struct kvm_vcpu *vcpu, - if (dbgregs->flags) - return -EINVAL; - -+ if (dbgregs->dr6 & ~0xffffffffull) -+ return -EINVAL; -+ if (dbgregs->dr7 & ~0xffffffffull) -+ return -EINVAL; -+ - memcpy(vcpu->arch.db, dbgregs->db, sizeof(vcpu->arch.db)); - kvm_update_dr0123(vcpu); - vcpu->arch.dr6 = dbgregs->dr6; -@@ -6030,12 +6035,10 @@ static int inject_pending_event(struct kvm_vcpu *vcpu, bool req_int_win) - } - - /* try to inject new event if pending */ -- if (vcpu->arch.nmi_pending) { -- if (kvm_x86_ops->nmi_allowed(vcpu)) { -- --vcpu->arch.nmi_pending; -- vcpu->arch.nmi_injected = true; -- kvm_x86_ops->set_nmi(vcpu); -- } -+ if (vcpu->arch.nmi_pending && kvm_x86_ops->nmi_allowed(vcpu)) { -+ --vcpu->arch.nmi_pending; -+ vcpu->arch.nmi_injected = true; -+ kvm_x86_ops->set_nmi(vcpu); - } else if (kvm_cpu_has_injectable_intr(vcpu)) { - /* - * Because interrupts can be injected asynchronously, we are -@@ -6480,10 +6483,12 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu) - if (inject_pending_event(vcpu, req_int_win) != 0) - req_immediate_exit = true; - /* enable NMI/IRQ window open exits if needed */ -- else if (vcpu->arch.nmi_pending) -- kvm_x86_ops->enable_nmi_window(vcpu); -- else if (kvm_cpu_has_injectable_intr(vcpu) || req_int_win) -- kvm_x86_ops->enable_irq_window(vcpu); -+ else { -+ if (vcpu->arch.nmi_pending) -+ kvm_x86_ops->enable_nmi_window(vcpu); -+ if (kvm_cpu_has_injectable_intr(vcpu) || req_int_win) -+ kvm_x86_ops->enable_irq_window(vcpu); -+ } - - if (kvm_lapic_enabled(vcpu)) { - update_cr8_intercept(vcpu); -@@ -6501,8 +6506,6 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu) - kvm_x86_ops->prepare_guest_switch(vcpu); - if (vcpu->fpu_active) - kvm_load_guest_fpu(vcpu); -- kvm_load_guest_xcr0(vcpu); -- - vcpu->mode = IN_GUEST_MODE; - - srcu_read_unlock(&vcpu->kvm->srcu, vcpu->srcu_idx); -@@ -6525,6 +6528,8 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu) - goto cancel_injection; - } - -+ kvm_load_guest_xcr0(vcpu); -+ - if (req_immediate_exit) - smp_send_reschedule(vcpu->cpu); - -@@ -6574,6 +6579,8 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu) - vcpu->mode = OUTSIDE_GUEST_MODE; - smp_wmb(); - -+ kvm_put_guest_xcr0(vcpu); -+ - /* Interrupt is enabled by handle_external_intr() */ - kvm_x86_ops->handle_external_intr(vcpu); - -@@ -7221,7 +7228,6 @@ void kvm_load_guest_fpu(struct kvm_vcpu *vcpu) - * and assume host would use all available bits. - * Guest xcr0 would be loaded later. - */ -- kvm_put_guest_xcr0(vcpu); - vcpu->guest_fpu_loaded = 1; - __kernel_fpu_begin(); - __copy_kernel_to_fpregs(&vcpu->arch.guest_fpu.state); -@@ -7230,8 +7236,6 @@ void kvm_load_guest_fpu(struct kvm_vcpu *vcpu) - - void kvm_put_guest_fpu(struct kvm_vcpu *vcpu) - { -- kvm_put_guest_xcr0(vcpu); -- - if (!vcpu->guest_fpu_loaded) { - vcpu->fpu_counter = 0; - return; -diff --git a/arch/x86/mm/kmmio.c b/arch/x86/mm/kmmio.c -index 637ab34..ddb2244 100644 ---- a/arch/x86/mm/kmmio.c -+++ b/arch/x86/mm/kmmio.c -@@ -33,7 +33,7 @@ - struct kmmio_fault_page { - struct list_head list; - struct kmmio_fault_page *release_next; -- unsigned long page; /* location of the fault page */ -+ unsigned long addr; /* the requested address */ - pteval_t old_presence; /* page presence prior to arming */ - bool armed; - -@@ -70,9 +70,16 @@ unsigned int kmmio_count; - static struct list_head kmmio_page_table[KMMIO_PAGE_TABLE_SIZE]; - static LIST_HEAD(kmmio_probes); - --static struct list_head *kmmio_page_list(unsigned long page) -+static struct list_head *kmmio_page_list(unsigned long addr) - { -- return &kmmio_page_table[hash_long(page, KMMIO_PAGE_HASH_BITS)]; -+ unsigned int l; -+ pte_t *pte = lookup_address(addr, &l); -+ -+ if (!pte) -+ return NULL; -+ addr &= page_level_mask(l); -+ -+ return &kmmio_page_table[hash_long(addr, KMMIO_PAGE_HASH_BITS)]; - } - - /* Accessed per-cpu */ -@@ -98,15 +105,19 @@ static struct kmmio_probe *get_kmmio_probe(unsigned long addr) - } - - /* You must be holding RCU read lock. */ --static struct kmmio_fault_page *get_kmmio_fault_page(unsigned long page) -+static struct kmmio_fault_page *get_kmmio_fault_page(unsigned long addr) - { - struct list_head *head; - struct kmmio_fault_page *f; -+ unsigned int l; -+ pte_t *pte = lookup_address(addr, &l); - -- page &= PAGE_MASK; -- head = kmmio_page_list(page); -+ if (!pte) -+ return NULL; -+ addr &= page_level_mask(l); -+ head = kmmio_page_list(addr); - list_for_each_entry_rcu(f, head, list) { -- if (f->page == page) -+ if (f->addr == addr) - return f; - } - return NULL; -@@ -137,10 +148,10 @@ static void clear_pte_presence(pte_t *pte, bool clear, pteval_t *old) - static int clear_page_presence(struct kmmio_fault_page *f, bool clear) - { - unsigned int level; -- pte_t *pte = lookup_address(f->page, &level); -+ pte_t *pte = lookup_address(f->addr, &level); - - if (!pte) { -- pr_err("no pte for page 0x%08lx\n", f->page); -+ pr_err("no pte for addr 0x%08lx\n", f->addr); - return -1; - } - -@@ -156,7 +167,7 @@ static int clear_page_presence(struct kmmio_fault_page *f, bool clear) - return -1; - } - -- __flush_tlb_one(f->page); -+ __flush_tlb_one(f->addr); - return 0; - } - -@@ -176,12 +187,12 @@ static int arm_kmmio_fault_page(struct kmmio_fault_page *f) - int ret; - WARN_ONCE(f->armed, KERN_ERR pr_fmt("kmmio page already armed.\n")); - if (f->armed) { -- pr_warning("double-arm: page 0x%08lx, ref %d, old %d\n", -- f->page, f->count, !!f->old_presence); -+ pr_warning("double-arm: addr 0x%08lx, ref %d, old %d\n", -+ f->addr, f->count, !!f->old_presence); - } - ret = clear_page_presence(f, true); -- WARN_ONCE(ret < 0, KERN_ERR pr_fmt("arming 0x%08lx failed.\n"), -- f->page); -+ WARN_ONCE(ret < 0, KERN_ERR pr_fmt("arming at 0x%08lx failed.\n"), -+ f->addr); - f->armed = true; - return ret; - } -@@ -191,7 +202,7 @@ static void disarm_kmmio_fault_page(struct kmmio_fault_page *f) - { - int ret = clear_page_presence(f, false); - WARN_ONCE(ret < 0, -- KERN_ERR "kmmio disarming 0x%08lx failed.\n", f->page); -+ KERN_ERR "kmmio disarming at 0x%08lx failed.\n", f->addr); - f->armed = false; - } - -@@ -215,6 +226,12 @@ int kmmio_handler(struct pt_regs *regs, unsigned long addr) - struct kmmio_context *ctx; - struct kmmio_fault_page *faultpage; - int ret = 0; /* default to fault not handled */ -+ unsigned long page_base = addr; -+ unsigned int l; -+ pte_t *pte = lookup_address(addr, &l); -+ if (!pte) -+ return -EINVAL; -+ page_base &= page_level_mask(l); - - /* - * Preemption is now disabled to prevent process switch during -@@ -227,7 +244,7 @@ int kmmio_handler(struct pt_regs *regs, unsigned long addr) - preempt_disable(); - rcu_read_lock(); - -- faultpage = get_kmmio_fault_page(addr); -+ faultpage = get_kmmio_fault_page(page_base); - if (!faultpage) { - /* - * Either this page fault is not caused by kmmio, or -@@ -239,7 +256,7 @@ int kmmio_handler(struct pt_regs *regs, unsigned long addr) - - ctx = &get_cpu_var(kmmio_ctx); - if (ctx->active) { -- if (addr == ctx->addr) { -+ if (page_base == ctx->addr) { - /* - * A second fault on the same page means some other - * condition needs handling by do_page_fault(), the -@@ -267,9 +284,9 @@ int kmmio_handler(struct pt_regs *regs, unsigned long addr) - ctx->active++; - - ctx->fpage = faultpage; -- ctx->probe = get_kmmio_probe(addr); -+ ctx->probe = get_kmmio_probe(page_base); - ctx->saved_flags = (regs->flags & (X86_EFLAGS_TF | X86_EFLAGS_IF)); -- ctx->addr = addr; -+ ctx->addr = page_base; - - if (ctx->probe && ctx->probe->pre_handler) - ctx->probe->pre_handler(ctx->probe, regs, addr); -@@ -354,12 +371,11 @@ out: - } - - /* You must be holding kmmio_lock. */ --static int add_kmmio_fault_page(unsigned long page) -+static int add_kmmio_fault_page(unsigned long addr) - { - struct kmmio_fault_page *f; - -- page &= PAGE_MASK; -- f = get_kmmio_fault_page(page); -+ f = get_kmmio_fault_page(addr); - if (f) { - if (!f->count) - arm_kmmio_fault_page(f); -@@ -372,26 +388,25 @@ static int add_kmmio_fault_page(unsigned long page) - return -1; - - f->count = 1; -- f->page = page; -+ f->addr = addr; - - if (arm_kmmio_fault_page(f)) { - kfree(f); - return -1; - } - -- list_add_rcu(&f->list, kmmio_page_list(f->page)); -+ list_add_rcu(&f->list, kmmio_page_list(f->addr)); - - return 0; - } - - /* You must be holding kmmio_lock. */ --static void release_kmmio_fault_page(unsigned long page, -+static void release_kmmio_fault_page(unsigned long addr, - struct kmmio_fault_page **release_list) - { - struct kmmio_fault_page *f; - -- page &= PAGE_MASK; -- f = get_kmmio_fault_page(page); -+ f = get_kmmio_fault_page(addr); - if (!f) - return; - -@@ -420,18 +435,27 @@ int register_kmmio_probe(struct kmmio_probe *p) - int ret = 0; - unsigned long size = 0; - const unsigned long size_lim = p->len + (p->addr & ~PAGE_MASK); -+ unsigned int l; -+ pte_t *pte; - - spin_lock_irqsave(&kmmio_lock, flags); - if (get_kmmio_probe(p->addr)) { - ret = -EEXIST; - goto out; - } -+ -+ pte = lookup_address(p->addr, &l); -+ if (!pte) { -+ ret = -EINVAL; -+ goto out; -+ } -+ - kmmio_count++; - list_add_rcu(&p->list, &kmmio_probes); - while (size < size_lim) { - if (add_kmmio_fault_page(p->addr + size)) - pr_err("Unable to set page fault.\n"); -- size += PAGE_SIZE; -+ size += page_level_size(l); - } - out: - spin_unlock_irqrestore(&kmmio_lock, flags); -@@ -506,11 +530,17 @@ void unregister_kmmio_probe(struct kmmio_probe *p) - const unsigned long size_lim = p->len + (p->addr & ~PAGE_MASK); - struct kmmio_fault_page *release_list = NULL; - struct kmmio_delayed_release *drelease; -+ unsigned int l; -+ pte_t *pte; -+ -+ pte = lookup_address(p->addr, &l); -+ if (!pte) -+ return; - - spin_lock_irqsave(&kmmio_lock, flags); - while (size < size_lim) { - release_kmmio_fault_page(p->addr + size, &release_list); -- size += PAGE_SIZE; -+ size += page_level_size(l); - } - list_del_rcu(&p->list); - kmmio_count--; -diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c -index 8f4cc3d..5fb6ada 100644 ---- a/arch/x86/mm/tlb.c -+++ b/arch/x86/mm/tlb.c -@@ -106,8 +106,6 @@ static void flush_tlb_func(void *info) - - if (f->flush_mm != this_cpu_read(cpu_tlbstate.active_mm)) - return; -- if (!f->flush_end) -- f->flush_end = f->flush_start + PAGE_SIZE; - - count_vm_tlb_event(NR_TLB_REMOTE_FLUSH_RECEIVED); - if (this_cpu_read(cpu_tlbstate.state) == TLBSTATE_OK) { -@@ -135,12 +133,20 @@ void native_flush_tlb_others(const struct cpumask *cpumask, - unsigned long end) - { - struct flush_tlb_info info; -+ -+ if (end == 0) -+ end = start + PAGE_SIZE; - info.flush_mm = mm; - info.flush_start = start; - info.flush_end = end; - - count_vm_tlb_event(NR_TLB_REMOTE_FLUSH); -- trace_tlb_flush(TLB_REMOTE_SEND_IPI, end - start); -+ if (end == TLB_FLUSH_ALL) -+ trace_tlb_flush(TLB_REMOTE_SEND_IPI, TLB_FLUSH_ALL); -+ else -+ trace_tlb_flush(TLB_REMOTE_SEND_IPI, -+ (end - start) >> PAGE_SHIFT); -+ - if (is_uv_system()) { - unsigned int cpu; - -diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c -index eccd4d9..8fd6f44 100644 ---- a/arch/x86/pci/common.c -+++ b/arch/x86/pci/common.c -@@ -673,28 +673,22 @@ int pcibios_add_device(struct pci_dev *dev) - return 0; - } - --int pcibios_alloc_irq(struct pci_dev *dev) -+int pcibios_enable_device(struct pci_dev *dev, int mask) - { -- /* -- * If the PCI device was already claimed by core code and has -- * MSI enabled, probing of the pcibios IRQ will overwrite -- * dev->irq. So bail out if MSI is already enabled. -- */ -- if (pci_dev_msi_enabled(dev)) -- return -EBUSY; -+ int err; - -- return pcibios_enable_irq(dev); --} -+ if ((err = pci_enable_resources(dev, mask)) < 0) -+ return err; - --void pcibios_free_irq(struct pci_dev *dev) --{ -- if (pcibios_disable_irq) -- pcibios_disable_irq(dev); -+ if (!pci_dev_msi_enabled(dev)) -+ return pcibios_enable_irq(dev); -+ return 0; - } - --int pcibios_enable_device(struct pci_dev *dev, int mask) -+void pcibios_disable_device (struct pci_dev *dev) - { -- return pci_enable_resources(dev, mask); -+ if (!pci_dev_msi_enabled(dev) && pcibios_disable_irq) -+ pcibios_disable_irq(dev); - } - - int pci_ext_cfg_avail(void) -diff --git a/arch/x86/pci/fixup.c b/arch/x86/pci/fixup.c -index e585655..0ae7e9f 100644 ---- a/arch/x86/pci/fixup.c -+++ b/arch/x86/pci/fixup.c -@@ -540,3 +540,10 @@ static void twinhead_reserve_killing_zone(struct pci_dev *dev) - } - } - DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x27B9, twinhead_reserve_killing_zone); -+ -+static void pci_bdwep_bar(struct pci_dev *dev) -+{ -+ dev->non_compliant_bars = 1; -+} -+DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x6fa0, pci_bdwep_bar); -+DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x6fc0, pci_bdwep_bar); -diff --git a/arch/x86/pci/intel_mid_pci.c b/arch/x86/pci/intel_mid_pci.c -index 0d24e7c..8b93e63 100644 ---- a/arch/x86/pci/intel_mid_pci.c -+++ b/arch/x86/pci/intel_mid_pci.c -@@ -215,7 +215,7 @@ static int intel_mid_pci_irq_enable(struct pci_dev *dev) - int polarity; - int ret; - -- if (pci_has_managed_irq(dev)) -+ if (dev->irq_managed && dev->irq > 0) - return 0; - - switch (intel_mid_identify_cpu()) { -@@ -256,13 +256,10 @@ static int intel_mid_pci_irq_enable(struct pci_dev *dev) - - static void intel_mid_pci_irq_disable(struct pci_dev *dev) - { -- if (pci_has_managed_irq(dev)) { -+ if (!mp_should_keep_irq(&dev->dev) && dev->irq_managed && -+ dev->irq > 0) { - mp_unmap_irq(dev->irq); - dev->irq_managed = 0; -- /* -- * Don't reset dev->irq here, otherwise -- * intel_mid_pci_irq_enable() will fail on next call. -- */ - } - } - -diff --git a/arch/x86/pci/irq.c b/arch/x86/pci/irq.c -index 32e7034..9bd1154 100644 ---- a/arch/x86/pci/irq.c -+++ b/arch/x86/pci/irq.c -@@ -1202,7 +1202,7 @@ static int pirq_enable_irq(struct pci_dev *dev) - struct pci_dev *temp_dev; - int irq; - -- if (pci_has_managed_irq(dev)) -+ if (dev->irq_managed && dev->irq > 0) - return 0; - - irq = IO_APIC_get_PCI_irq_vector(dev->bus->number, -@@ -1230,7 +1230,8 @@ static int pirq_enable_irq(struct pci_dev *dev) - } - dev = temp_dev; - if (irq >= 0) { -- pci_set_managed_irq(dev, irq); -+ dev->irq_managed = 1; -+ dev->irq = irq; - dev_info(&dev->dev, "PCI->APIC IRQ transform: " - "INT %c -> IRQ %d\n", 'A' + pin - 1, irq); - return 0; -@@ -1256,10 +1257,24 @@ static int pirq_enable_irq(struct pci_dev *dev) - return 0; - } - -+bool mp_should_keep_irq(struct device *dev) -+{ -+ if (dev->power.is_prepared) -+ return true; -+#ifdef CONFIG_PM -+ if (dev->power.runtime_status == RPM_SUSPENDING) -+ return true; -+#endif -+ -+ return false; -+} -+ - static void pirq_disable_irq(struct pci_dev *dev) - { -- if (io_apic_assign_pci_irqs && pci_has_managed_irq(dev)) { -+ if (io_apic_assign_pci_irqs && !mp_should_keep_irq(&dev->dev) && -+ dev->irq_managed && dev->irq) { - mp_unmap_irq(dev->irq); -- pci_reset_managed_irq(dev); -+ dev->irq = 0; -+ dev->irq_managed = 0; - } - } -diff --git a/arch/x86/pci/xen.c b/arch/x86/pci/xen.c -index ff31ab4..c6d6efe 100644 ---- a/arch/x86/pci/xen.c -+++ b/arch/x86/pci/xen.c -@@ -488,8 +488,11 @@ int __init pci_xen_initial_domain(void) - #endif - __acpi_register_gsi = acpi_register_gsi_xen; - __acpi_unregister_gsi = NULL; -- /* Pre-allocate legacy irqs */ -- for (irq = 0; irq < nr_legacy_irqs(); irq++) { -+ /* -+ * Pre-allocate the legacy IRQs. Use NR_LEGACY_IRQS here -+ * because we don't have a PIC and thus nr_legacy_irqs() is zero. -+ */ -+ for (irq = 0; irq < NR_IRQS_LEGACY; irq++) { - int trigger, polarity; - - if (acpi_get_override_irq(irq, &trigger, &polarity) == -1) -diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c -index b7de78b..beab8c7 100644 ---- a/arch/x86/xen/enlighten.c -+++ b/arch/x86/xen/enlighten.c -@@ -961,7 +961,7 @@ static void xen_load_sp0(struct tss_struct *tss, - tss->x86_tss.sp0 = thread->sp0; - } - --static void xen_set_iopl_mask(unsigned mask) -+void xen_set_iopl_mask(unsigned mask) - { - struct physdev_set_iopl set_iopl; - -diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c -index 7ab2951..e345891 100644 ---- a/arch/x86/xen/setup.c -+++ b/arch/x86/xen/setup.c -@@ -393,6 +393,9 @@ static unsigned long __init xen_set_identity_and_remap_chunk( - unsigned long i = 0; - unsigned long n = end_pfn - start_pfn; - -+ if (remap_pfn == 0) -+ remap_pfn = nr_pages; -+ - while (i < n) { - unsigned long cur_pfn = start_pfn + i; - unsigned long left = n - i; -@@ -438,17 +441,29 @@ static unsigned long __init xen_set_identity_and_remap_chunk( - return remap_pfn; - } - --static void __init xen_set_identity_and_remap(unsigned long nr_pages) -+static unsigned long __init xen_count_remap_pages( -+ unsigned long start_pfn, unsigned long end_pfn, unsigned long nr_pages, -+ unsigned long remap_pages) -+{ -+ if (start_pfn >= nr_pages) -+ return remap_pages; -+ -+ return remap_pages + min(end_pfn, nr_pages) - start_pfn; -+} -+ -+static unsigned long __init xen_foreach_remap_area(unsigned long nr_pages, -+ unsigned long (*func)(unsigned long start_pfn, unsigned long end_pfn, -+ unsigned long nr_pages, unsigned long last_val)) - { - phys_addr_t start = 0; -- unsigned long last_pfn = nr_pages; -+ unsigned long ret_val = 0; - const struct e820entry *entry = xen_e820_map; - int i; - - /* - * Combine non-RAM regions and gaps until a RAM region (or the -- * end of the map) is reached, then set the 1:1 map and -- * remap the memory in those non-RAM regions. -+ * end of the map) is reached, then call the provided function -+ * to perform its duty on the non-RAM region. - * - * The combined non-RAM regions are rounded to a whole number - * of pages so any partial pages are accessible via the 1:1 -@@ -466,14 +481,13 @@ static void __init xen_set_identity_and_remap(unsigned long nr_pages) - end_pfn = PFN_UP(entry->addr); - - if (start_pfn < end_pfn) -- last_pfn = xen_set_identity_and_remap_chunk( -- start_pfn, end_pfn, nr_pages, -- last_pfn); -+ ret_val = func(start_pfn, end_pfn, nr_pages, -+ ret_val); - start = end; - } - } - -- pr_info("Released %ld page(s)\n", xen_released_pages); -+ return ret_val; - } - - /* -@@ -596,35 +610,6 @@ static void __init xen_ignore_unusable(void) - } - } - --static unsigned long __init xen_count_remap_pages(unsigned long max_pfn) --{ -- unsigned long extra = 0; -- unsigned long start_pfn, end_pfn; -- const struct e820entry *entry = xen_e820_map; -- int i; -- -- end_pfn = 0; -- for (i = 0; i < xen_e820_map_entries; i++, entry++) { -- start_pfn = PFN_DOWN(entry->addr); -- /* Adjacent regions on non-page boundaries handling! */ -- end_pfn = min(end_pfn, start_pfn); -- -- if (start_pfn >= max_pfn) -- return extra + max_pfn - end_pfn; -- -- /* Add any holes in map to result. */ -- extra += start_pfn - end_pfn; -- -- end_pfn = PFN_UP(entry->addr + entry->size); -- end_pfn = min(end_pfn, max_pfn); -- -- if (entry->type != E820_RAM) -- extra += end_pfn - start_pfn; -- } -- -- return extra; --} -- - bool __init xen_is_e820_reserved(phys_addr_t start, phys_addr_t size) - { - struct e820entry *entry; -@@ -804,7 +789,7 @@ char * __init xen_memory_setup(void) - max_pages = xen_get_max_pages(); - - /* How many extra pages do we need due to remapping? */ -- max_pages += xen_count_remap_pages(max_pfn); -+ max_pages += xen_foreach_remap_area(max_pfn, xen_count_remap_pages); - - if (max_pages > max_pfn) - extra_pages += max_pages - max_pfn; -@@ -922,7 +907,9 @@ char * __init xen_memory_setup(void) - * Set identity map on non-RAM pages and prepare remapping the - * underlying RAM. - */ -- xen_set_identity_and_remap(max_pfn); -+ xen_foreach_remap_area(max_pfn, xen_set_identity_and_remap_chunk); -+ -+ pr_info("Released %ld page(s)\n", xen_released_pages); - - return "Xen"; - } -diff --git a/arch/xtensa/kernel/head.S b/arch/xtensa/kernel/head.S -index 9ed5564..05e1df9 100644 ---- a/arch/xtensa/kernel/head.S -+++ b/arch/xtensa/kernel/head.S -@@ -128,7 +128,7 @@ ENTRY(_startup) - wsr a0, icountlevel - - .set _index, 0 -- .rept XCHAL_NUM_DBREAK - 1 -+ .rept XCHAL_NUM_DBREAK - wsr a0, SREG_DBREAKC + _index - .set _index, _index + 1 - .endr -diff --git a/arch/xtensa/mm/cache.c b/arch/xtensa/mm/cache.c -index d75aa14..1a804a2 100644 ---- a/arch/xtensa/mm/cache.c -+++ b/arch/xtensa/mm/cache.c -@@ -97,11 +97,11 @@ void clear_user_highpage(struct page *page, unsigned long vaddr) - unsigned long paddr; - void *kvaddr = coherent_kvaddr(page, TLBTEMP_BASE_1, vaddr, &paddr); - -- pagefault_disable(); -+ preempt_disable(); - kmap_invalidate_coherent(page, vaddr); - set_bit(PG_arch_1, &page->flags); - clear_page_alias(kvaddr, paddr); -- pagefault_enable(); -+ preempt_enable(); - } - - void copy_user_highpage(struct page *dst, struct page *src, -@@ -113,11 +113,11 @@ void copy_user_highpage(struct page *dst, struct page *src, - void *src_vaddr = coherent_kvaddr(src, TLBTEMP_BASE_2, vaddr, - &src_paddr); - -- pagefault_disable(); -+ preempt_disable(); - kmap_invalidate_coherent(dst, vaddr); - set_bit(PG_arch_1, &dst->flags); - copy_page_alias(dst_vaddr, src_vaddr, dst_paddr, src_paddr); -- pagefault_enable(); -+ preempt_enable(); - } - - #endif /* DCACHE_WAY_SIZE > PAGE_SIZE */ -diff --git a/arch/xtensa/platforms/iss/console.c b/arch/xtensa/platforms/iss/console.c -index 70cb408..92d785f 100644 ---- a/arch/xtensa/platforms/iss/console.c -+++ b/arch/xtensa/platforms/iss/console.c -@@ -100,21 +100,23 @@ static void rs_poll(unsigned long priv) - { - struct tty_port *port = (struct tty_port *)priv; - int i = 0; -+ int rd = 1; - unsigned char c; - - spin_lock(&timer_lock); - - while (simc_poll(0)) { -- simc_read(0, &c, 1); -+ rd = simc_read(0, &c, 1); -+ if (rd <= 0) -+ break; - tty_insert_flip_char(port, c, TTY_NORMAL); - i++; - } - - if (i) - tty_flip_buffer_push(port); -- -- -- mod_timer(&serial_timer, jiffies + SERIAL_TIMER_VALUE); -+ if (rd) -+ mod_timer(&serial_timer, jiffies + SERIAL_TIMER_VALUE); - spin_unlock(&timer_lock); - } - -diff --git a/block/blk-core.c b/block/blk-core.c -index 4c8cefd..842cfe4 100644 ---- a/block/blk-core.c -+++ b/block/blk-core.c -@@ -680,7 +680,7 @@ static void blk_queue_usage_counter_release(struct percpu_ref *ref) - struct request_queue *q = - container_of(ref, struct request_queue, q_usage_counter); - -- swait_wake_all(&q->mq_freeze_wq); -+ swake_up_all(&q->mq_freeze_wq); - } - - struct request_queue *blk_alloc_queue_node(gfp_t gfp_mask, int node_id) -@@ -742,7 +742,7 @@ struct request_queue *blk_alloc_queue_node(gfp_t gfp_mask, int node_id) - q->bypass_depth = 1; - __set_bit(QUEUE_FLAG_BYPASS, &q->queue_flags); - -- init_swait_head(&q->mq_freeze_wq); -+ init_swait_queue_head(&q->mq_freeze_wq); - - /* - * Init percpu_ref in atomic mode so that it's faster to shutdown. -@@ -2192,7 +2192,7 @@ int blk_insert_cloned_request(struct request_queue *q, struct request *rq) - if (q->mq_ops) { - if (blk_queue_io_stat(q)) - blk_account_io_start(rq, true); -- blk_mq_insert_request(rq, false, true, true); -+ blk_mq_insert_request(rq, false, true, false); - return 0; - } - -diff --git a/block/blk-mq.c b/block/blk-mq.c -index 3c70813..7cdf19e 100644 ---- a/block/blk-mq.c -+++ b/block/blk-mq.c -@@ -130,7 +130,7 @@ void blk_mq_unfreeze_queue(struct request_queue *q) - WARN_ON_ONCE(freeze_depth < 0); - if (!freeze_depth) { - percpu_ref_reinit(&q->q_usage_counter); -- swait_wake_all(&q->mq_freeze_wq); -+ swake_up_all(&q->mq_freeze_wq); - } - } - EXPORT_SYMBOL_GPL(blk_mq_unfreeze_queue); -@@ -149,7 +149,7 @@ void blk_mq_wake_waiters(struct request_queue *q) - * dying, we need to ensure that processes currently waiting on - * the queue are notified as well. - */ -- swait_wake_all(&q->mq_freeze_wq); -+ swake_up_all(&q->mq_freeze_wq); - } - - bool blk_mq_can_queue(struct blk_mq_hw_ctx *hctx) -diff --git a/block/partition-generic.c b/block/partition-generic.c -index 746935a..a241e39 100644 ---- a/block/partition-generic.c -+++ b/block/partition-generic.c -@@ -349,15 +349,20 @@ struct hd_struct *add_partition(struct gendisk *disk, int partno, - goto out_del; - } - -+ err = hd_ref_init(p); -+ if (err) { -+ if (flags & ADDPART_FLAG_WHOLEDISK) -+ goto out_remove_file; -+ goto out_del; -+ } -+ - /* everything is up and running, commence */ - rcu_assign_pointer(ptbl->part[partno], p); - - /* suppress uevent if the disk suppresses it */ - if (!dev_get_uevent_suppress(ddev)) - kobject_uevent(&pdev->kobj, KOBJ_ADD); -- -- if (!hd_ref_init(p)) -- return p; -+ return p; - - out_free_info: - free_part_info(p); -@@ -366,6 +371,8 @@ out_free_stats: - out_free: - kfree(p); - return ERR_PTR(err); -+out_remove_file: -+ device_remove_file(pdev, &dev_attr_whole_disk); - out_del: - kobject_put(p->holder_dir); - device_del(pdev); -diff --git a/crypto/ahash.c b/crypto/ahash.c -index d19b523..dac1c24 100644 ---- a/crypto/ahash.c -+++ b/crypto/ahash.c -@@ -69,8 +69,9 @@ static int hash_walk_new_entry(struct crypto_hash_walk *walk) - struct scatterlist *sg; - - sg = walk->sg; -- walk->pg = sg_page(sg); - walk->offset = sg->offset; -+ walk->pg = sg_page(walk->sg) + (walk->offset >> PAGE_SHIFT); -+ walk->offset = offset_in_page(walk->offset); - walk->entrylen = sg->length; - - if (walk->entrylen > walk->total) -diff --git a/crypto/asymmetric_keys/Kconfig b/crypto/asymmetric_keys/Kconfig -index 4870f28..05bfe56 100644 ---- a/crypto/asymmetric_keys/Kconfig -+++ b/crypto/asymmetric_keys/Kconfig -@@ -14,6 +14,7 @@ config ASYMMETRIC_PUBLIC_KEY_SUBTYPE - select MPILIB - select PUBLIC_KEY_ALGO_RSA - select CRYPTO_HASH_INFO -+ select CRYPTO_AKCIPHER - help - This option provides support for asymmetric public key type handling. - If signature generation and/or verification are to be used, -diff --git a/crypto/asymmetric_keys/pkcs7_trust.c b/crypto/asymmetric_keys/pkcs7_trust.c -index 90d6d47..ecdb5a2 100644 ---- a/crypto/asymmetric_keys/pkcs7_trust.c -+++ b/crypto/asymmetric_keys/pkcs7_trust.c -@@ -178,6 +178,8 @@ int pkcs7_validate_trust(struct pkcs7_message *pkcs7, - int cached_ret = -ENOKEY; - int ret; - -+ *_trusted = false; -+ - for (p = pkcs7->certs; p; p = p->next) - p->seen = false; - -diff --git a/crypto/asymmetric_keys/x509_cert_parser.c b/crypto/asymmetric_keys/x509_cert_parser.c -index 021d39c..13c4e5a 100644 ---- a/crypto/asymmetric_keys/x509_cert_parser.c -+++ b/crypto/asymmetric_keys/x509_cert_parser.c -@@ -494,7 +494,7 @@ int x509_decode_time(time64_t *_t, size_t hdrlen, - unsigned char tag, - const unsigned char *value, size_t vlen) - { -- static const unsigned char month_lengths[] = { 31, 29, 31, 30, 31, 30, -+ static const unsigned char month_lengths[] = { 31, 28, 31, 30, 31, 30, - 31, 31, 30, 31, 30, 31 }; - const unsigned char *p = value; - unsigned year, mon, day, hour, min, sec, mon_len; -@@ -540,9 +540,9 @@ int x509_decode_time(time64_t *_t, size_t hdrlen, - if (year % 4 == 0) { - mon_len = 29; - if (year % 100 == 0) { -- year /= 100; -- if (year % 4 != 0) -- mon_len = 28; -+ mon_len = 28; -+ if (year % 400 == 0) -+ mon_len = 29; - } - } - } -diff --git a/crypto/keywrap.c b/crypto/keywrap.c -index b1d106c..72014f9 100644 ---- a/crypto/keywrap.c -+++ b/crypto/keywrap.c -@@ -212,7 +212,7 @@ static int crypto_kw_decrypt(struct blkcipher_desc *desc, - SEMIBSIZE)) - ret = -EBADMSG; - -- memzero_explicit(&block, sizeof(struct crypto_kw_block)); -+ memzero_explicit(block, sizeof(struct crypto_kw_block)); - - return ret; - } -@@ -297,7 +297,7 @@ static int crypto_kw_encrypt(struct blkcipher_desc *desc, - /* establish the IV for the caller to pick up */ - memcpy(desc->info, block->A, SEMIBSIZE); - -- memzero_explicit(&block, sizeof(struct crypto_kw_block)); -+ memzero_explicit(block, sizeof(struct crypto_kw_block)); - - return 0; - } -diff --git a/crypto/testmgr.c b/crypto/testmgr.c -index ae8c57f..d494431 100644 ---- a/crypto/testmgr.c -+++ b/crypto/testmgr.c -@@ -1849,6 +1849,7 @@ static int alg_test_drbg(const struct alg_test_desc *desc, const char *driver, - static int do_test_rsa(struct crypto_akcipher *tfm, - struct akcipher_testvec *vecs) - { -+ char *xbuf[XBUFSIZE]; - struct akcipher_request *req; - void *outbuf_enc = NULL; - void *outbuf_dec = NULL; -@@ -1857,9 +1858,12 @@ static int do_test_rsa(struct crypto_akcipher *tfm, - int err = -ENOMEM; - struct scatterlist src, dst, src_tab[2]; - -+ if (testmgr_alloc_buf(xbuf)) -+ return err; -+ - req = akcipher_request_alloc(tfm, GFP_KERNEL); - if (!req) -- return err; -+ goto free_xbuf; - - init_completion(&result.completion); - -@@ -1877,9 +1881,14 @@ static int do_test_rsa(struct crypto_akcipher *tfm, - if (!outbuf_enc) - goto free_req; - -+ if (WARN_ON(vecs->m_size > PAGE_SIZE)) -+ goto free_all; -+ -+ memcpy(xbuf[0], vecs->m, vecs->m_size); -+ - sg_init_table(src_tab, 2); -- sg_set_buf(&src_tab[0], vecs->m, 8); -- sg_set_buf(&src_tab[1], vecs->m + 8, vecs->m_size - 8); -+ sg_set_buf(&src_tab[0], xbuf[0], 8); -+ sg_set_buf(&src_tab[1], xbuf[0] + 8, vecs->m_size - 8); - sg_init_one(&dst, outbuf_enc, out_len_max); - akcipher_request_set_crypt(req, src_tab, &dst, vecs->m_size, - out_len_max); -@@ -1898,7 +1907,7 @@ static int do_test_rsa(struct crypto_akcipher *tfm, - goto free_all; - } - /* verify that encrypted message is equal to expected */ -- if (memcmp(vecs->c, sg_virt(req->dst), vecs->c_size)) { -+ if (memcmp(vecs->c, outbuf_enc, vecs->c_size)) { - pr_err("alg: rsa: encrypt test failed. Invalid output\n"); - err = -EINVAL; - goto free_all; -@@ -1913,7 +1922,13 @@ static int do_test_rsa(struct crypto_akcipher *tfm, - err = -ENOMEM; - goto free_all; - } -- sg_init_one(&src, vecs->c, vecs->c_size); -+ -+ if (WARN_ON(vecs->c_size > PAGE_SIZE)) -+ goto free_all; -+ -+ memcpy(xbuf[0], vecs->c, vecs->c_size); -+ -+ sg_init_one(&src, xbuf[0], vecs->c_size); - sg_init_one(&dst, outbuf_dec, out_len_max); - init_completion(&result.completion); - akcipher_request_set_crypt(req, &src, &dst, vecs->c_size, out_len_max); -@@ -1940,6 +1955,8 @@ free_all: - kfree(outbuf_enc); - free_req: - akcipher_request_free(req); -+free_xbuf: -+ testmgr_free_buf(xbuf); - return err; - } - -diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c -index 6979186..9f77943 100644 ---- a/drivers/acpi/acpi_processor.c -+++ b/drivers/acpi/acpi_processor.c -@@ -491,6 +491,58 @@ static void acpi_processor_remove(struct acpi_device *device) - } - #endif /* CONFIG_ACPI_HOTPLUG_CPU */ - -+#ifdef CONFIG_X86 -+static bool acpi_hwp_native_thermal_lvt_set; -+static acpi_status __init acpi_hwp_native_thermal_lvt_osc(acpi_handle handle, -+ u32 lvl, -+ void *context, -+ void **rv) -+{ -+ u8 sb_uuid_str[] = "4077A616-290C-47BE-9EBD-D87058713953"; -+ u32 capbuf[2]; -+ struct acpi_osc_context osc_context = { -+ .uuid_str = sb_uuid_str, -+ .rev = 1, -+ .cap.length = 8, -+ .cap.pointer = capbuf, -+ }; -+ -+ if (acpi_hwp_native_thermal_lvt_set) -+ return AE_CTRL_TERMINATE; -+ -+ capbuf[0] = 0x0000; -+ capbuf[1] = 0x1000; /* set bit 12 */ -+ -+ if (ACPI_SUCCESS(acpi_run_osc(handle, &osc_context))) { -+ if (osc_context.ret.pointer && osc_context.ret.length > 1) { -+ u32 *capbuf_ret = osc_context.ret.pointer; -+ -+ if (capbuf_ret[1] & 0x1000) { -+ acpi_handle_info(handle, -+ "_OSC native thermal LVT Acked\n"); -+ acpi_hwp_native_thermal_lvt_set = true; -+ } -+ } -+ kfree(osc_context.ret.pointer); -+ } -+ -+ return AE_OK; -+} -+ -+void __init acpi_early_processor_osc(void) -+{ -+ if (boot_cpu_has(X86_FEATURE_HWP)) { -+ acpi_walk_namespace(ACPI_TYPE_PROCESSOR, ACPI_ROOT_OBJECT, -+ ACPI_UINT32_MAX, -+ acpi_hwp_native_thermal_lvt_osc, -+ NULL, NULL, NULL); -+ acpi_get_devices(ACPI_PROCESSOR_DEVICE_HID, -+ acpi_hwp_native_thermal_lvt_osc, -+ NULL, NULL); -+ } -+} -+#endif -+ - /* - * The following ACPI IDs are known to be suitable for representing as - * processor devices. -diff --git a/drivers/acpi/acpica/dsmethod.c b/drivers/acpi/acpica/dsmethod.c -index bc32f31..28c50c6 100644 ---- a/drivers/acpi/acpica/dsmethod.c -+++ b/drivers/acpi/acpica/dsmethod.c -@@ -417,6 +417,9 @@ acpi_ds_begin_method_execution(struct acpi_namespace_node *method_node, - obj_desc->method.mutex->mutex. - original_sync_level = - obj_desc->method.mutex->mutex.sync_level; -+ -+ obj_desc->method.mutex->mutex.thread_id = -+ acpi_os_get_thread_id(); - } - } - -diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c -index a212cef..ca4f284 100644 ---- a/drivers/acpi/bus.c -+++ b/drivers/acpi/bus.c -@@ -1004,6 +1004,9 @@ static int __init acpi_bus_init(void) - goto error1; - } - -+ /* Set capability bits for _OSC under processor scope */ -+ acpi_early_processor_osc(); -+ - /* - * _OSC method may exist in module level code, - * so it must be run after ACPI_FULL_INITIALIZATION -diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h -index 11d87bf..0f3f41c 100644 ---- a/drivers/acpi/internal.h -+++ b/drivers/acpi/internal.h -@@ -130,6 +130,12 @@ void acpi_early_processor_set_pdc(void); - static inline void acpi_early_processor_set_pdc(void) {} - #endif - -+#ifdef CONFIG_X86 -+void acpi_early_processor_osc(void); -+#else -+static inline void acpi_early_processor_osc(void) {} -+#endif -+ - /* -------------------------------------------------------------------------- - Embedded Controller - -------------------------------------------------------------------------- */ -diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c -index 32d684a..a000ecb 100644 ---- a/drivers/acpi/osl.c -+++ b/drivers/acpi/osl.c -@@ -135,7 +135,7 @@ static struct osi_linux { - unsigned int enable:1; - unsigned int dmi:1; - unsigned int cmdline:1; -- unsigned int default_disabling:1; -+ u8 default_disabling; - } osi_linux = {0, 0, 0, 0}; - - static u32 acpi_osi_handler(acpi_string interface, u32 supported) -@@ -1444,10 +1444,13 @@ void __init acpi_osi_setup(char *str) - if (*str == '!') { - str++; - if (*str == '\0') { -- osi_linux.default_disabling = 1; -+ /* Do not override acpi_osi=!* */ -+ if (!osi_linux.default_disabling) -+ osi_linux.default_disabling = -+ ACPI_DISABLE_ALL_VENDOR_STRINGS; - return; - } else if (*str == '*') { -- acpi_update_interfaces(ACPI_DISABLE_ALL_STRINGS); -+ osi_linux.default_disabling = ACPI_DISABLE_ALL_STRINGS; - for (i = 0; i < OSI_STRING_ENTRIES_MAX; i++) { - osi = &osi_setup_entries[i]; - osi->enable = false; -@@ -1520,10 +1523,13 @@ static void __init acpi_osi_setup_late(void) - acpi_status status; - - if (osi_linux.default_disabling) { -- status = acpi_update_interfaces(ACPI_DISABLE_ALL_VENDOR_STRINGS); -+ status = acpi_update_interfaces(osi_linux.default_disabling); - - if (ACPI_SUCCESS(status)) -- printk(KERN_INFO PREFIX "Disabled all _OSI OS vendors\n"); -+ printk(KERN_INFO PREFIX "Disabled all _OSI OS vendors%s\n", -+ osi_linux.default_disabling == -+ ACPI_DISABLE_ALL_STRINGS ? -+ " and feature groups" : ""); - } - - for (i = 0; i < OSI_STRING_ENTRIES_MAX; i++) { -diff --git a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c -index c933675..8a10a7a 100644 ---- a/drivers/acpi/pci_irq.c -+++ b/drivers/acpi/pci_irq.c -@@ -409,7 +409,7 @@ int acpi_pci_irq_enable(struct pci_dev *dev) - return 0; - } - -- if (pci_has_managed_irq(dev)) -+ if (dev->irq_managed && dev->irq > 0) - return 0; - - entry = acpi_pci_irq_lookup(dev, pin); -@@ -454,7 +454,8 @@ int acpi_pci_irq_enable(struct pci_dev *dev) - kfree(entry); - return rc; - } -- pci_set_managed_irq(dev, rc); -+ dev->irq = rc; -+ dev->irq_managed = 1; - - if (link) - snprintf(link_desc, sizeof(link_desc), " -> Link[%s]", link); -@@ -477,9 +478,17 @@ void acpi_pci_irq_disable(struct pci_dev *dev) - u8 pin; - - pin = dev->pin; -- if (!pin || !pci_has_managed_irq(dev)) -+ if (!pin || !dev->irq_managed || dev->irq <= 0) - return; - -+ /* Keep IOAPIC pin configuration when suspending */ -+ if (dev->dev.power.is_prepared) -+ return; -+#ifdef CONFIG_PM -+ if (dev->dev.power.runtime_status == RPM_SUSPENDING) -+ return; -+#endif -+ - entry = acpi_pci_irq_lookup(dev, pin); - if (!entry) - return; -@@ -499,6 +508,6 @@ void acpi_pci_irq_disable(struct pci_dev *dev) - dev_dbg(&dev->dev, "PCI INT %c disabled\n", pin_name(pin)); - if (gsi >= 0) { - acpi_unregister_gsi(gsi); -- pci_reset_managed_irq(dev); -+ dev->irq_managed = 0; - } - } -diff --git a/drivers/acpi/resource.c b/drivers/acpi/resource.c -index cdc5c25..627f8fb 100644 ---- a/drivers/acpi/resource.c -+++ b/drivers/acpi/resource.c -@@ -26,8 +26,20 @@ - - #ifdef CONFIG_X86 - #define valid_IRQ(i) (((i) != 0) && ((i) != 2)) -+static inline bool acpi_iospace_resource_valid(struct resource *res) -+{ -+ /* On X86 IO space is limited to the [0 - 64K] IO port range */ -+ return res->end < 0x10003; -+} - #else - #define valid_IRQ(i) (true) -+/* -+ * ACPI IO descriptors on arches other than X86 contain MMIO CPU physical -+ * addresses mapping IO space in CPU physical address space, IO space -+ * resources can be placed anywhere in the 64-bit physical address space. -+ */ -+static inline bool -+acpi_iospace_resource_valid(struct resource *res) { return true; } - #endif - - static bool acpi_dev_resource_len_valid(u64 start, u64 end, u64 len, bool io) -@@ -126,7 +138,7 @@ static void acpi_dev_ioresource_flags(struct resource *res, u64 len, - if (!acpi_dev_resource_len_valid(res->start, res->end, len, true)) - res->flags |= IORESOURCE_DISABLED | IORESOURCE_UNSET; - -- if (res->end >= 0x10003) -+ if (!acpi_iospace_resource_valid(res)) - res->flags |= IORESOURCE_DISABLED | IORESOURCE_UNSET; - - if (io_decode == ACPI_DECODE_16) -diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c -index 0d94621..e3322ad 100644 ---- a/drivers/acpi/sleep.c -+++ b/drivers/acpi/sleep.c -@@ -714,6 +714,7 @@ static int acpi_hibernation_enter(void) - - static void acpi_hibernation_leave(void) - { -+ pm_set_resume_via_firmware(); - /* - * If ACPI is not enabled by the BIOS and the boot kernel, we need to - * enable it here. -diff --git a/drivers/ata/ahci_platform.c b/drivers/ata/ahci_platform.c -index 04975b8..639adb1 100644 ---- a/drivers/ata/ahci_platform.c -+++ b/drivers/ata/ahci_platform.c -@@ -51,6 +51,9 @@ static int ahci_probe(struct platform_device *pdev) - if (rc) - return rc; - -+ of_property_read_u32(dev->of_node, -+ "ports-implemented", &hpriv->force_port_map); -+ - if (of_device_is_compatible(dev->of_node, "hisilicon,hisi-ahci")) - hpriv->flags |= AHCI_HFLAG_NO_FBS | AHCI_HFLAG_NO_NCQ; - -diff --git a/drivers/ata/ahci_xgene.c b/drivers/ata/ahci_xgene.c -index e2c6d9e..e916bff 100644 ---- a/drivers/ata/ahci_xgene.c -+++ b/drivers/ata/ahci_xgene.c -@@ -739,9 +739,9 @@ static int xgene_ahci_probe(struct platform_device *pdev) - dev_warn(&pdev->dev, "%s: Error reading device info. Assume version1\n", - __func__); - version = XGENE_AHCI_V1; -- } -- if (info->valid & ACPI_VALID_CID) -+ } else if (info->valid & ACPI_VALID_CID) { - version = XGENE_AHCI_V2; -+ } - } - } - #endif -diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c -index 998c6a8..9628fa1 100644 ---- a/drivers/ata/libahci.c -+++ b/drivers/ata/libahci.c -@@ -467,6 +467,7 @@ void ahci_save_initial_config(struct device *dev, struct ahci_host_priv *hpriv) - dev_info(dev, "forcing port_map 0x%x -> 0x%x\n", - port_map, hpriv->force_port_map); - port_map = hpriv->force_port_map; -+ hpriv->saved_port_map = port_map; - } - - if (hpriv->mask_port_map) { -diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c -index 65f50ec..a48824d 100644 ---- a/drivers/base/power/domain.c -+++ b/drivers/base/power/domain.c -@@ -1381,7 +1381,7 @@ int pm_genpd_remove_subdomain(struct generic_pm_domain *genpd, - - mutex_lock(&genpd->lock); - -- if (!list_empty(&subdomain->slave_links) || subdomain->device_count) { -+ if (!list_empty(&subdomain->master_links) || subdomain->device_count) { - pr_warn("%s: unable to remove subdomain %s\n", genpd->name, - subdomain->name); - ret = -EBUSY; -diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c -index 1710c26..ae60e63 100644 ---- a/drivers/base/power/main.c -+++ b/drivers/base/power/main.c -@@ -1262,14 +1262,15 @@ int dpm_suspend_late(pm_message_t state) - error = device_suspend_late(dev); - - mutex_lock(&dpm_list_mtx); -+ if (!list_empty(&dev->power.entry)) -+ list_move(&dev->power.entry, &dpm_late_early_list); -+ - if (error) { - pm_dev_err(dev, state, " late", error); - dpm_save_failed_dev(dev_name(dev)); - put_device(dev); - break; - } -- if (!list_empty(&dev->power.entry)) -- list_move(&dev->power.entry, &dpm_late_early_list); - put_device(dev); - - if (async_error) -diff --git a/drivers/base/power/opp/core.c b/drivers/base/power/opp/core.c -index b8e76f7..f858090 100644 ---- a/drivers/base/power/opp/core.c -+++ b/drivers/base/power/opp/core.c -@@ -809,8 +809,14 @@ static int opp_parse_supplies(struct dev_pm_opp *opp, struct device *dev) - } - - opp->u_volt = microvolt[0]; -- opp->u_volt_min = microvolt[1]; -- opp->u_volt_max = microvolt[2]; -+ -+ if (count == 1) { -+ opp->u_volt_min = opp->u_volt; -+ opp->u_volt_max = opp->u_volt; -+ } else { -+ opp->u_volt_min = microvolt[1]; -+ opp->u_volt_max = microvolt[2]; -+ } - - if (!of_property_read_u32(opp->np, "opp-microamp", &val)) - opp->u_amp = val; -diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c -index e1a10a0..9796a1a 100644 ---- a/drivers/base/power/runtime.c -+++ b/drivers/base/power/runtime.c -@@ -1468,11 +1468,16 @@ int pm_runtime_force_resume(struct device *dev) - goto out; - } - -- ret = callback(dev); -+ ret = pm_runtime_set_active(dev); - if (ret) - goto out; - -- pm_runtime_set_active(dev); -+ ret = callback(dev); -+ if (ret) { -+ pm_runtime_set_suspended(dev); -+ goto out; -+ } -+ - pm_runtime_mark_last_busy(dev); - out: - pm_runtime_enable(dev); -diff --git a/drivers/base/regmap/regmap-spmi.c b/drivers/base/regmap/regmap-spmi.c -index 7e58f65..4a36e41 100644 ---- a/drivers/base/regmap/regmap-spmi.c -+++ b/drivers/base/regmap/regmap-spmi.c -@@ -142,7 +142,7 @@ static int regmap_spmi_ext_read(void *context, - while (val_size) { - len = min_t(size_t, val_size, 8); - -- err = spmi_ext_register_readl(context, addr, val, val_size); -+ err = spmi_ext_register_readl(context, addr, val, len); - if (err) - goto err_out; - -diff --git a/drivers/block/brd.c b/drivers/block/brd.c -index a5880f4..1914c63 100644 ---- a/drivers/block/brd.c -+++ b/drivers/block/brd.c -@@ -338,7 +338,7 @@ static blk_qc_t brd_make_request(struct request_queue *q, struct bio *bio) - - if (unlikely(bio->bi_rw & REQ_DISCARD)) { - if (sector & ((PAGE_SIZE >> SECTOR_SHIFT) - 1) || -- bio->bi_iter.bi_size & PAGE_MASK) -+ bio->bi_iter.bi_size & ~PAGE_MASK) - goto io_error; - discard_from_brd(brd, sector, bio->bi_iter.bi_size); - goto out; -diff --git a/drivers/block/loop.c b/drivers/block/loop.c -index 423f4ca..80cf8ad 100644 ---- a/drivers/block/loop.c -+++ b/drivers/block/loop.c -@@ -488,6 +488,12 @@ static int lo_rw_aio(struct loop_device *lo, struct loop_cmd *cmd, - bvec = __bvec_iter_bvec(bio->bi_io_vec, bio->bi_iter); - iov_iter_bvec(&iter, ITER_BVEC | rw, bvec, - bio_segments(bio), blk_rq_bytes(cmd->rq)); -+ /* -+ * This bio may be started from the middle of the 'bvec' -+ * because of bio splitting, so offset from the bvec must -+ * be passed to iov iterator -+ */ -+ iter.iov_offset = bio->bi_iter.bi_bvec_done; - - cmd->iocb.ki_pos = pos; - cmd->iocb.ki_filp = file; -diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c -index 3457ac8..55d3d1d 100644 ---- a/drivers/block/mtip32xx/mtip32xx.c -+++ b/drivers/block/mtip32xx/mtip32xx.c -@@ -173,7 +173,13 @@ static struct mtip_cmd *mtip_get_int_command(struct driver_data *dd) - { - struct request *rq; - -+ if (mtip_check_surprise_removal(dd->pdev)) -+ return NULL; -+ - rq = blk_mq_alloc_request(dd->queue, 0, __GFP_RECLAIM, true); -+ if (IS_ERR(rq)) -+ return NULL; -+ - return blk_mq_rq_to_pdu(rq); - } - -@@ -233,15 +239,9 @@ static void mtip_async_complete(struct mtip_port *port, - "Command tag %d failed due to TFE\n", tag); - } - -- /* Unmap the DMA scatter list entries */ -- dma_unmap_sg(&dd->pdev->dev, cmd->sg, cmd->scatter_ents, cmd->direction); -- - rq = mtip_rq_from_tag(dd, tag); - -- if (unlikely(cmd->unaligned)) -- up(&port->cmd_slot_unal); -- -- blk_mq_end_request(rq, status ? -EIO : 0); -+ blk_mq_complete_request(rq, status); - } - - /* -@@ -581,6 +581,8 @@ static void mtip_completion(struct mtip_port *port, - dev_warn(&port->dd->pdev->dev, - "Internal command %d completed with TFE\n", tag); - -+ command->comp_func = NULL; -+ command->comp_data = NULL; - complete(waiting); - } - -@@ -618,8 +620,6 @@ static void mtip_handle_tfe(struct driver_data *dd) - - port = dd->port; - -- set_bit(MTIP_PF_EH_ACTIVE_BIT, &port->flags); -- - if (test_bit(MTIP_PF_IC_ACTIVE_BIT, &port->flags)) { - cmd = mtip_cmd_from_tag(dd, MTIP_TAG_INTERNAL); - dbg_printk(MTIP_DRV_NAME " TFE for the internal command\n"); -@@ -628,7 +628,7 @@ static void mtip_handle_tfe(struct driver_data *dd) - cmd->comp_func(port, MTIP_TAG_INTERNAL, - cmd, PORT_IRQ_TF_ERR); - } -- goto handle_tfe_exit; -+ return; - } - - /* clear the tag accumulator */ -@@ -701,7 +701,7 @@ static void mtip_handle_tfe(struct driver_data *dd) - fail_reason = "thermal shutdown"; - } - if (buf[288] == 0xBF) { -- set_bit(MTIP_DDF_SEC_LOCK_BIT, &dd->dd_flag); -+ set_bit(MTIP_DDF_REBUILD_FAILED_BIT, &dd->dd_flag); - dev_info(&dd->pdev->dev, - "Drive indicates rebuild has failed. Secure erase required.\n"); - fail_all_ncq_cmds = 1; -@@ -771,11 +771,6 @@ static void mtip_handle_tfe(struct driver_data *dd) - } - } - print_tags(dd, "reissued (TFE)", tagaccum, cmd_cnt); -- --handle_tfe_exit: -- /* clear eh_active */ -- clear_bit(MTIP_PF_EH_ACTIVE_BIT, &port->flags); -- wake_up_interruptible(&port->svc_wait); - } - - /* -@@ -1007,6 +1002,7 @@ static bool mtip_pause_ncq(struct mtip_port *port, - (fis->features == 0x27 || fis->features == 0x72 || - fis->features == 0x62 || fis->features == 0x26))) { - clear_bit(MTIP_DDF_SEC_LOCK_BIT, &port->dd->dd_flag); -+ clear_bit(MTIP_DDF_REBUILD_FAILED_BIT, &port->dd->dd_flag); - /* Com reset after secure erase or lowlevel format */ - mtip_restart_port(port); - clear_bit(MTIP_PF_SE_ACTIVE_BIT, &port->flags); -@@ -1021,12 +1017,14 @@ static bool mtip_pause_ncq(struct mtip_port *port, - * - * @port Pointer to port data structure - * @timeout Max duration to wait (ms) -+ * @atomic gfp_t flag to indicate blockable context or not - * - * return value - * 0 Success - * -EBUSY Commands still active - */ --static int mtip_quiesce_io(struct mtip_port *port, unsigned long timeout) -+static int mtip_quiesce_io(struct mtip_port *port, unsigned long timeout, -+ gfp_t atomic) - { - unsigned long to; - unsigned int n; -@@ -1037,16 +1035,21 @@ static int mtip_quiesce_io(struct mtip_port *port, unsigned long timeout) - to = jiffies + msecs_to_jiffies(timeout); - do { - if (test_bit(MTIP_PF_SVC_THD_ACTIVE_BIT, &port->flags) && -- test_bit(MTIP_PF_ISSUE_CMDS_BIT, &port->flags)) { -+ test_bit(MTIP_PF_ISSUE_CMDS_BIT, &port->flags) && -+ atomic == GFP_KERNEL) { - msleep(20); - continue; /* svc thd is actively issuing commands */ - } - -- msleep(100); -+ if (atomic == GFP_KERNEL) -+ msleep(100); -+ else { -+ cpu_relax(); -+ udelay(100); -+ } -+ - if (mtip_check_surprise_removal(port->dd->pdev)) - goto err_fault; -- if (test_bit(MTIP_DDF_REMOVE_PENDING_BIT, &port->dd->dd_flag)) -- goto err_fault; - - /* - * Ignore s_active bit 0 of array element 0. -@@ -1099,6 +1102,7 @@ static int mtip_exec_internal_command(struct mtip_port *port, - struct mtip_cmd *int_cmd; - struct driver_data *dd = port->dd; - int rv = 0; -+ unsigned long start; - - /* Make sure the buffer is 8 byte aligned. This is asic specific. */ - if (buffer & 0x00000007) { -@@ -1107,6 +1111,10 @@ static int mtip_exec_internal_command(struct mtip_port *port, - } - - int_cmd = mtip_get_int_command(dd); -+ if (!int_cmd) { -+ dbg_printk(MTIP_DRV_NAME "Unable to allocate tag for PIO cmd\n"); -+ return -EFAULT; -+ } - - set_bit(MTIP_PF_IC_ACTIVE_BIT, &port->flags); - -@@ -1119,7 +1127,7 @@ static int mtip_exec_internal_command(struct mtip_port *port, - if (fis->command != ATA_CMD_STANDBYNOW1) { - /* wait for io to complete if non atomic */ - if (mtip_quiesce_io(port, -- MTIP_QUIESCE_IO_TIMEOUT_MS) < 0) { -+ MTIP_QUIESCE_IO_TIMEOUT_MS, atomic) < 0) { - dev_warn(&dd->pdev->dev, - "Failed to quiesce IO\n"); - mtip_put_int_command(dd, int_cmd); -@@ -1162,6 +1170,8 @@ static int mtip_exec_internal_command(struct mtip_port *port, - /* Populate the command header */ - int_cmd->command_header->byte_count = 0; - -+ start = jiffies; -+ - /* Issue the command to the hardware */ - mtip_issue_non_ncq_command(port, MTIP_TAG_INTERNAL); - -@@ -1170,10 +1180,12 @@ static int mtip_exec_internal_command(struct mtip_port *port, - if ((rv = wait_for_completion_interruptible_timeout( - &wait, - msecs_to_jiffies(timeout))) <= 0) { -+ - if (rv == -ERESTARTSYS) { /* interrupted */ - dev_err(&dd->pdev->dev, -- "Internal command [%02X] was interrupted after %lu ms\n", -- fis->command, timeout); -+ "Internal command [%02X] was interrupted after %u ms\n", -+ fis->command, -+ jiffies_to_msecs(jiffies - start)); - rv = -EINTR; - goto exec_ic_exit; - } else if (rv == 0) /* timeout */ -@@ -2897,6 +2909,42 @@ static int mtip_ftl_rebuild_poll(struct driver_data *dd) - return -EFAULT; - } - -+static void mtip_softirq_done_fn(struct request *rq) -+{ -+ struct mtip_cmd *cmd = blk_mq_rq_to_pdu(rq); -+ struct driver_data *dd = rq->q->queuedata; -+ -+ /* Unmap the DMA scatter list entries */ -+ dma_unmap_sg(&dd->pdev->dev, cmd->sg, cmd->scatter_ents, -+ cmd->direction); -+ -+ if (unlikely(cmd->unaligned)) -+ up(&dd->port->cmd_slot_unal); -+ -+ blk_mq_end_request(rq, rq->errors); -+} -+ -+static void mtip_abort_cmd(struct request *req, void *data, -+ bool reserved) -+{ -+ struct driver_data *dd = data; -+ -+ dbg_printk(MTIP_DRV_NAME " Aborting request, tag = %d\n", req->tag); -+ -+ clear_bit(req->tag, dd->port->cmds_to_issue); -+ req->errors = -EIO; -+ mtip_softirq_done_fn(req); -+} -+ -+static void mtip_queue_cmd(struct request *req, void *data, -+ bool reserved) -+{ -+ struct driver_data *dd = data; -+ -+ set_bit(req->tag, dd->port->cmds_to_issue); -+ blk_abort_request(req); -+} -+ - /* - * service thread to issue queued commands - * -@@ -2909,7 +2957,7 @@ static int mtip_ftl_rebuild_poll(struct driver_data *dd) - static int mtip_service_thread(void *data) - { - struct driver_data *dd = (struct driver_data *)data; -- unsigned long slot, slot_start, slot_wrap; -+ unsigned long slot, slot_start, slot_wrap, to; - unsigned int num_cmd_slots = dd->slot_groups * 32; - struct mtip_port *port = dd->port; - -@@ -2924,9 +2972,7 @@ static int mtip_service_thread(void *data) - * is in progress nor error handling is active - */ - wait_event_interruptible(port->svc_wait, (port->flags) && -- !(port->flags & MTIP_PF_PAUSE_IO)); -- -- set_bit(MTIP_PF_SVC_THD_ACTIVE_BIT, &port->flags); -+ (port->flags & MTIP_PF_SVC_THD_WORK)); - - if (kthread_should_stop() || - test_bit(MTIP_PF_SVC_THD_STOP_BIT, &port->flags)) -@@ -2936,6 +2982,8 @@ static int mtip_service_thread(void *data) - &dd->dd_flag))) - goto st_out; - -+ set_bit(MTIP_PF_SVC_THD_ACTIVE_BIT, &port->flags); -+ - restart_eh: - /* Demux bits: start with error handling */ - if (test_bit(MTIP_PF_EH_ACTIVE_BIT, &port->flags)) { -@@ -2946,6 +2994,32 @@ restart_eh: - if (test_bit(MTIP_PF_EH_ACTIVE_BIT, &port->flags)) - goto restart_eh; - -+ if (test_bit(MTIP_PF_TO_ACTIVE_BIT, &port->flags)) { -+ to = jiffies + msecs_to_jiffies(5000); -+ -+ do { -+ mdelay(100); -+ } while (atomic_read(&dd->irq_workers_active) != 0 && -+ time_before(jiffies, to)); -+ -+ if (atomic_read(&dd->irq_workers_active) != 0) -+ dev_warn(&dd->pdev->dev, -+ "Completion workers still active!"); -+ -+ spin_lock(dd->queue->queue_lock); -+ blk_mq_all_tag_busy_iter(*dd->tags.tags, -+ mtip_queue_cmd, dd); -+ spin_unlock(dd->queue->queue_lock); -+ -+ set_bit(MTIP_PF_ISSUE_CMDS_BIT, &dd->port->flags); -+ -+ if (mtip_device_reset(dd)) -+ blk_mq_all_tag_busy_iter(*dd->tags.tags, -+ mtip_abort_cmd, dd); -+ -+ clear_bit(MTIP_PF_TO_ACTIVE_BIT, &dd->port->flags); -+ } -+ - if (test_bit(MTIP_PF_ISSUE_CMDS_BIT, &port->flags)) { - slot = 1; - /* used to restrict the loop to one iteration */ -@@ -2978,10 +3052,8 @@ restart_eh: - } - - if (test_bit(MTIP_PF_REBUILD_BIT, &port->flags)) { -- if (mtip_ftl_rebuild_poll(dd) < 0) -- set_bit(MTIP_DDF_REBUILD_FAILED_BIT, -- &dd->dd_flag); -- clear_bit(MTIP_PF_REBUILD_BIT, &port->flags); -+ if (mtip_ftl_rebuild_poll(dd) == 0) -+ clear_bit(MTIP_PF_REBUILD_BIT, &port->flags); - } - } - -@@ -3096,7 +3168,7 @@ static int mtip_hw_get_identify(struct driver_data *dd) - if (buf[288] == 0xBF) { - dev_info(&dd->pdev->dev, - "Drive indicates rebuild has failed.\n"); -- /* TODO */ -+ set_bit(MTIP_DDF_REBUILD_FAILED_BIT, &dd->dd_flag); - } - } - -@@ -3270,20 +3342,25 @@ out1: - return rv; - } - --static void mtip_standby_drive(struct driver_data *dd) -+static int mtip_standby_drive(struct driver_data *dd) - { -- if (dd->sr) -- return; -+ int rv = 0; - -+ if (dd->sr || !dd->port) -+ return -ENODEV; - /* - * Send standby immediate (E0h) to the drive so that it - * saves its state. - */ - if (!test_bit(MTIP_PF_REBUILD_BIT, &dd->port->flags) && -- !test_bit(MTIP_DDF_SEC_LOCK_BIT, &dd->dd_flag)) -- if (mtip_standby_immediate(dd->port)) -+ !test_bit(MTIP_DDF_REBUILD_FAILED_BIT, &dd->dd_flag) && -+ !test_bit(MTIP_DDF_SEC_LOCK_BIT, &dd->dd_flag)) { -+ rv = mtip_standby_immediate(dd->port); -+ if (rv) - dev_warn(&dd->pdev->dev, - "STANDBY IMMEDIATE failed\n"); -+ } -+ return rv; - } - - /* -@@ -3296,10 +3373,6 @@ static void mtip_standby_drive(struct driver_data *dd) - */ - static int mtip_hw_exit(struct driver_data *dd) - { -- /* -- * Send standby immediate (E0h) to the drive so that it -- * saves its state. -- */ - if (!dd->sr) { - /* de-initialize the port. */ - mtip_deinit_port(dd->port); -@@ -3341,8 +3414,7 @@ static int mtip_hw_shutdown(struct driver_data *dd) - * Send standby immediate (E0h) to the drive so that it - * saves its state. - */ -- if (!dd->sr && dd->port) -- mtip_standby_immediate(dd->port); -+ mtip_standby_drive(dd); - - return 0; - } -@@ -3365,7 +3437,7 @@ static int mtip_hw_suspend(struct driver_data *dd) - * Send standby immediate (E0h) to the drive - * so that it saves its state. - */ -- if (mtip_standby_immediate(dd->port) != 0) { -+ if (mtip_standby_drive(dd) != 0) { - dev_err(&dd->pdev->dev, - "Failed standby-immediate command\n"); - return -EFAULT; -@@ -3603,6 +3675,28 @@ static int mtip_block_getgeo(struct block_device *dev, - return 0; - } - -+static int mtip_block_open(struct block_device *dev, fmode_t mode) -+{ -+ struct driver_data *dd; -+ -+ if (dev && dev->bd_disk) { -+ dd = (struct driver_data *) dev->bd_disk->private_data; -+ -+ if (dd) { -+ if (test_bit(MTIP_DDF_REMOVAL_BIT, -+ &dd->dd_flag)) { -+ return -ENODEV; -+ } -+ return 0; -+ } -+ } -+ return -ENODEV; -+} -+ -+void mtip_block_release(struct gendisk *disk, fmode_t mode) -+{ -+} -+ - /* - * Block device operation function. - * -@@ -3610,6 +3704,8 @@ static int mtip_block_getgeo(struct block_device *dev, - * layer. - */ - static const struct block_device_operations mtip_block_ops = { -+ .open = mtip_block_open, -+ .release = mtip_block_release, - .ioctl = mtip_block_ioctl, - #ifdef CONFIG_COMPAT - .compat_ioctl = mtip_block_compat_ioctl, -@@ -3671,10 +3767,9 @@ static int mtip_submit_request(struct blk_mq_hw_ctx *hctx, struct request *rq) - rq_data_dir(rq))) { - return -ENODATA; - } -- if (unlikely(test_bit(MTIP_DDF_SEC_LOCK_BIT, &dd->dd_flag))) -+ if (unlikely(test_bit(MTIP_DDF_SEC_LOCK_BIT, &dd->dd_flag) || -+ test_bit(MTIP_DDF_REBUILD_FAILED_BIT, &dd->dd_flag))) - return -ENODATA; -- if (test_bit(MTIP_DDF_REBUILD_FAILED_BIT, &dd->dd_flag)) -- return -ENXIO; - } - - if (rq->cmd_flags & REQ_DISCARD) { -@@ -3786,11 +3881,33 @@ static int mtip_init_cmd(void *data, struct request *rq, unsigned int hctx_idx, - return 0; - } - -+static enum blk_eh_timer_return mtip_cmd_timeout(struct request *req, -+ bool reserved) -+{ -+ struct driver_data *dd = req->q->queuedata; -+ int ret = BLK_EH_RESET_TIMER; -+ -+ if (reserved) -+ goto exit_handler; -+ -+ if (test_bit(req->tag, dd->port->cmds_to_issue)) -+ goto exit_handler; -+ -+ if (test_and_set_bit(MTIP_PF_TO_ACTIVE_BIT, &dd->port->flags)) -+ goto exit_handler; -+ -+ wake_up_interruptible(&dd->port->svc_wait); -+exit_handler: -+ return ret; -+} -+ - static struct blk_mq_ops mtip_mq_ops = { - .queue_rq = mtip_queue_rq, - .map_queue = blk_mq_map_queue, - .init_request = mtip_init_cmd, - .exit_request = mtip_free_cmd, -+ .complete = mtip_softirq_done_fn, -+ .timeout = mtip_cmd_timeout, - }; - - /* -@@ -3857,7 +3974,6 @@ static int mtip_block_initialize(struct driver_data *dd) - - mtip_hw_debugfs_init(dd); - --skip_create_disk: - memset(&dd->tags, 0, sizeof(dd->tags)); - dd->tags.ops = &mtip_mq_ops; - dd->tags.nr_hw_queues = 1; -@@ -3867,12 +3983,13 @@ skip_create_disk: - dd->tags.numa_node = dd->numa_node; - dd->tags.flags = BLK_MQ_F_SHOULD_MERGE; - dd->tags.driver_data = dd; -+ dd->tags.timeout = MTIP_NCQ_CMD_TIMEOUT_MS; - - rv = blk_mq_alloc_tag_set(&dd->tags); - if (rv) { - dev_err(&dd->pdev->dev, - "Unable to allocate request queue\n"); -- goto block_queue_alloc_init_error; -+ goto block_queue_alloc_tag_error; - } - - /* Allocate the request queue. */ -@@ -3887,6 +4004,7 @@ skip_create_disk: - dd->disk->queue = dd->queue; - dd->queue->queuedata = dd; - -+skip_create_disk: - /* Initialize the protocol layer. */ - wait_for_rebuild = mtip_hw_get_identify(dd); - if (wait_for_rebuild < 0) { -@@ -3983,8 +4101,9 @@ kthread_run_error: - read_capacity_error: - init_hw_cmds_error: - blk_cleanup_queue(dd->queue); -- blk_mq_free_tag_set(&dd->tags); - block_queue_alloc_init_error: -+ blk_mq_free_tag_set(&dd->tags); -+block_queue_alloc_tag_error: - mtip_hw_debugfs_exit(dd); - disk_index_error: - spin_lock(&rssd_index_lock); -@@ -4001,6 +4120,22 @@ protocol_init_error: - return rv; - } - -+static void mtip_no_dev_cleanup(struct request *rq, void *data, bool reserv) -+{ -+ struct driver_data *dd = (struct driver_data *)data; -+ struct mtip_cmd *cmd; -+ -+ if (likely(!reserv)) -+ blk_mq_complete_request(rq, -ENODEV); -+ else if (test_bit(MTIP_PF_IC_ACTIVE_BIT, &dd->port->flags)) { -+ -+ cmd = mtip_cmd_from_tag(dd, MTIP_TAG_INTERNAL); -+ if (cmd->comp_func) -+ cmd->comp_func(dd->port, MTIP_TAG_INTERNAL, -+ cmd, -ENODEV); -+ } -+} -+ - /* - * Block layer deinitialization function. - * -@@ -4032,12 +4167,23 @@ static int mtip_block_remove(struct driver_data *dd) - } - } - -- if (!dd->sr) -- mtip_standby_drive(dd); -+ if (!dd->sr) { -+ /* -+ * Explicitly wait here for IOs to quiesce, -+ * as mtip_standby_drive usually won't wait for IOs. -+ */ -+ if (!mtip_quiesce_io(dd->port, MTIP_QUIESCE_IO_TIMEOUT_MS, -+ GFP_KERNEL)) -+ mtip_standby_drive(dd); -+ } - else - dev_info(&dd->pdev->dev, "device %s surprise removal\n", - dd->disk->disk_name); - -+ blk_mq_freeze_queue_start(dd->queue); -+ blk_mq_stop_hw_queues(dd->queue); -+ blk_mq_all_tag_busy_iter(dd->tags.tags[0], mtip_no_dev_cleanup, dd); -+ - /* - * Delete our gendisk structure. This also removes the device - * from /dev -@@ -4047,7 +4193,8 @@ static int mtip_block_remove(struct driver_data *dd) - dd->bdev = NULL; - } - if (dd->disk) { -- del_gendisk(dd->disk); -+ if (test_bit(MTIP_DDF_INIT_DONE_BIT, &dd->dd_flag)) -+ del_gendisk(dd->disk); - if (dd->disk->queue) { - blk_cleanup_queue(dd->queue); - blk_mq_free_tag_set(&dd->tags); -@@ -4088,7 +4235,8 @@ static int mtip_block_shutdown(struct driver_data *dd) - dev_info(&dd->pdev->dev, - "Shutting down %s ...\n", dd->disk->disk_name); - -- del_gendisk(dd->disk); -+ if (test_bit(MTIP_DDF_INIT_DONE_BIT, &dd->dd_flag)) -+ del_gendisk(dd->disk); - if (dd->disk->queue) { - blk_cleanup_queue(dd->queue); - blk_mq_free_tag_set(&dd->tags); -@@ -4433,7 +4581,7 @@ static void mtip_pci_remove(struct pci_dev *pdev) - struct driver_data *dd = pci_get_drvdata(pdev); - unsigned long flags, to; - -- set_bit(MTIP_DDF_REMOVE_PENDING_BIT, &dd->dd_flag); -+ set_bit(MTIP_DDF_REMOVAL_BIT, &dd->dd_flag); - - spin_lock_irqsave(&dev_lock, flags); - list_del_init(&dd->online_list); -@@ -4450,12 +4598,17 @@ static void mtip_pci_remove(struct pci_dev *pdev) - } while (atomic_read(&dd->irq_workers_active) != 0 && - time_before(jiffies, to)); - -+ if (!dd->sr) -+ fsync_bdev(dd->bdev); -+ - if (atomic_read(&dd->irq_workers_active) != 0) { - dev_warn(&dd->pdev->dev, - "Completion workers still active!\n"); - } - -- blk_mq_stop_hw_queues(dd->queue); -+ blk_set_queue_dying(dd->queue); -+ set_bit(MTIP_DDF_REMOVE_PENDING_BIT, &dd->dd_flag); -+ - /* Clean up the block layer. */ - mtip_block_remove(dd); - -diff --git a/drivers/block/mtip32xx/mtip32xx.h b/drivers/block/mtip32xx/mtip32xx.h -index 3274784..7617888 100644 ---- a/drivers/block/mtip32xx/mtip32xx.h -+++ b/drivers/block/mtip32xx/mtip32xx.h -@@ -134,16 +134,24 @@ enum { - MTIP_PF_EH_ACTIVE_BIT = 1, /* error handling */ - MTIP_PF_SE_ACTIVE_BIT = 2, /* secure erase */ - MTIP_PF_DM_ACTIVE_BIT = 3, /* download microcde */ -+ MTIP_PF_TO_ACTIVE_BIT = 9, /* timeout handling */ - MTIP_PF_PAUSE_IO = ((1 << MTIP_PF_IC_ACTIVE_BIT) | - (1 << MTIP_PF_EH_ACTIVE_BIT) | - (1 << MTIP_PF_SE_ACTIVE_BIT) | -- (1 << MTIP_PF_DM_ACTIVE_BIT)), -+ (1 << MTIP_PF_DM_ACTIVE_BIT) | -+ (1 << MTIP_PF_TO_ACTIVE_BIT)), - - MTIP_PF_SVC_THD_ACTIVE_BIT = 4, - MTIP_PF_ISSUE_CMDS_BIT = 5, - MTIP_PF_REBUILD_BIT = 6, - MTIP_PF_SVC_THD_STOP_BIT = 8, - -+ MTIP_PF_SVC_THD_WORK = ((1 << MTIP_PF_EH_ACTIVE_BIT) | -+ (1 << MTIP_PF_ISSUE_CMDS_BIT) | -+ (1 << MTIP_PF_REBUILD_BIT) | -+ (1 << MTIP_PF_SVC_THD_STOP_BIT) | -+ (1 << MTIP_PF_TO_ACTIVE_BIT)), -+ - /* below are bit numbers in 'dd_flag' defined in driver_data */ - MTIP_DDF_SEC_LOCK_BIT = 0, - MTIP_DDF_REMOVE_PENDING_BIT = 1, -@@ -153,6 +161,7 @@ enum { - MTIP_DDF_RESUME_BIT = 6, - MTIP_DDF_INIT_DONE_BIT = 7, - MTIP_DDF_REBUILD_FAILED_BIT = 8, -+ MTIP_DDF_REMOVAL_BIT = 9, - - MTIP_DDF_STOP_IO = ((1 << MTIP_DDF_REMOVE_PENDING_BIT) | - (1 << MTIP_DDF_SEC_LOCK_BIT) | -diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c -index 93b3f99..8f1ce6d 100644 ---- a/drivers/block/nbd.c -+++ b/drivers/block/nbd.c -@@ -618,8 +618,8 @@ static void nbd_request_handler(struct request_queue *q) - req, req->cmd_type); - - if (unlikely(!nbd->sock)) { -- dev_err(disk_to_dev(nbd->disk), -- "Attempted send on closed socket\n"); -+ dev_err_ratelimited(disk_to_dev(nbd->disk), -+ "Attempted send on closed socket\n"); - req->errors++; - nbd_end_request(nbd, req); - spin_lock_irq(q->queue_lock); -diff --git a/drivers/block/paride/pd.c b/drivers/block/paride/pd.c -index 562b5a4..78a39f7 100644 ---- a/drivers/block/paride/pd.c -+++ b/drivers/block/paride/pd.c -@@ -126,7 +126,7 @@ - */ - #include - --static bool verbose = 0; -+static int verbose = 0; - static int major = PD_MAJOR; - static char *name = PD_NAME; - static int cluster = 64; -@@ -161,7 +161,7 @@ enum {D_PRT, D_PRO, D_UNI, D_MOD, D_GEO, D_SBY, D_DLY, D_SLV}; - static DEFINE_MUTEX(pd_mutex); - static DEFINE_SPINLOCK(pd_lock); - --module_param(verbose, bool, 0); -+module_param(verbose, int, 0); - module_param(major, int, 0); - module_param(name, charp, 0); - module_param(cluster, int, 0); -diff --git a/drivers/block/paride/pt.c b/drivers/block/paride/pt.c -index 1740d75..216a94f 100644 ---- a/drivers/block/paride/pt.c -+++ b/drivers/block/paride/pt.c -@@ -117,7 +117,7 @@ - - */ - --static bool verbose = 0; -+static int verbose = 0; - static int major = PT_MAJOR; - static char *name = PT_NAME; - static int disable = 0; -@@ -152,7 +152,7 @@ static int (*drives[4])[6] = {&drive0, &drive1, &drive2, &drive3}; - - #include - --module_param(verbose, bool, 0); -+module_param(verbose, int, 0); - module_param(major, int, 0); - module_param(name, charp, 0); - module_param_array(drive0, int, NULL, 0); -diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c -index 81ea69f..fbdddd6 100644 ---- a/drivers/block/rbd.c -+++ b/drivers/block/rbd.c -@@ -1955,7 +1955,7 @@ static struct ceph_osd_request *rbd_osd_req_create( - - osdc = &rbd_dev->rbd_client->client->osdc; - osd_req = ceph_osdc_alloc_request(osdc, snapc, num_ops, false, -- GFP_ATOMIC); -+ GFP_NOIO); - if (!osd_req) - return NULL; /* ENOMEM */ - -@@ -2004,7 +2004,7 @@ rbd_osd_req_create_copyup(struct rbd_obj_request *obj_request) - rbd_dev = img_request->rbd_dev; - osdc = &rbd_dev->rbd_client->client->osdc; - osd_req = ceph_osdc_alloc_request(osdc, snapc, num_osd_ops, -- false, GFP_ATOMIC); -+ false, GFP_NOIO); - if (!osd_req) - return NULL; /* ENOMEM */ - -@@ -2506,7 +2506,7 @@ static int rbd_img_request_fill(struct rbd_img_request *img_request, - bio_chain_clone_range(&bio_list, - &bio_offset, - clone_size, -- GFP_ATOMIC); -+ GFP_NOIO); - if (!obj_request->bio_list) - goto out_unwind; - } else if (type == OBJ_REQUEST_PAGES) { -diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c -index 370c2f7..65e0b37 100644 ---- a/drivers/block/zram/zram_drv.c -+++ b/drivers/block/zram/zram_drv.c -@@ -520,6 +520,8 @@ static struct zram_meta *zram_meta_alloc(char *pool_name, u64 disksize) - goto out_error; - } - -+ zram_meta_init_table_locks(meta, disksize); -+ - return meta; - - out_error: -@@ -568,12 +570,12 @@ static int zram_decompress_page(struct zram *zram, char *mem, u32 index) - unsigned long handle; - size_t size; - -- bit_spin_lock(ZRAM_ACCESS, &meta->table[index].value); -+ zram_lock_table(&meta->table[index]); - handle = meta->table[index].handle; - size = zram_get_obj_size(meta, index); - - if (!handle || zram_test_flag(meta, index, ZRAM_ZERO)) { -- bit_spin_unlock(ZRAM_ACCESS, &meta->table[index].value); -+ zram_unlock_table(&meta->table[index]); - clear_page(mem); - return 0; - } -@@ -584,7 +586,7 @@ static int zram_decompress_page(struct zram *zram, char *mem, u32 index) - else - ret = zcomp_decompress(zram->comp, cmem, size, mem); - zs_unmap_object(meta->mem_pool, handle); -- bit_spin_unlock(ZRAM_ACCESS, &meta->table[index].value); -+ zram_unlock_table(&meta->table[index]); - - /* Should NEVER happen. Return bio error if it does. */ - if (unlikely(ret)) { -@@ -604,14 +606,14 @@ static int zram_bvec_read(struct zram *zram, struct bio_vec *bvec, - struct zram_meta *meta = zram->meta; - page = bvec->bv_page; - -- bit_spin_lock(ZRAM_ACCESS, &meta->table[index].value); -+ zram_lock_table(&meta->table[index]); - if (unlikely(!meta->table[index].handle) || - zram_test_flag(meta, index, ZRAM_ZERO)) { -- bit_spin_unlock(ZRAM_ACCESS, &meta->table[index].value); -+ zram_unlock_table(&meta->table[index]); - handle_zero_page(bvec); - return 0; - } -- bit_spin_unlock(ZRAM_ACCESS, &meta->table[index].value); -+ zram_unlock_table(&meta->table[index]); - - if (is_partial_io(bvec)) - /* Use a temporary buffer to decompress the page */ -@@ -689,10 +691,10 @@ static int zram_bvec_write(struct zram *zram, struct bio_vec *bvec, u32 index, - if (user_mem) - kunmap_atomic(user_mem); - /* Free memory associated with this sector now. */ -- bit_spin_lock(ZRAM_ACCESS, &meta->table[index].value); -+ zram_lock_table(&meta->table[index]); - zram_free_page(zram, index); - zram_set_flag(meta, index, ZRAM_ZERO); -- bit_spin_unlock(ZRAM_ACCESS, &meta->table[index].value); -+ zram_unlock_table(&meta->table[index]); - - atomic64_inc(&zram->stats.zero_pages); - ret = 0; -@@ -752,12 +754,12 @@ static int zram_bvec_write(struct zram *zram, struct bio_vec *bvec, u32 index, - * Free memory associated with this sector - * before overwriting unused sectors. - */ -- bit_spin_lock(ZRAM_ACCESS, &meta->table[index].value); -+ zram_lock_table(&meta->table[index]); - zram_free_page(zram, index); - - meta->table[index].handle = handle; - zram_set_obj_size(meta, index, clen); -- bit_spin_unlock(ZRAM_ACCESS, &meta->table[index].value); -+ zram_unlock_table(&meta->table[index]); - - /* Update stats */ - atomic64_add(clen, &zram->stats.compr_data_size); -@@ -800,9 +802,9 @@ static void zram_bio_discard(struct zram *zram, u32 index, - } - - while (n >= PAGE_SIZE) { -- bit_spin_lock(ZRAM_ACCESS, &meta->table[index].value); -+ zram_lock_table(&meta->table[index]); - zram_free_page(zram, index); -- bit_spin_unlock(ZRAM_ACCESS, &meta->table[index].value); -+ zram_unlock_table(&meta->table[index]); - atomic64_inc(&zram->stats.notify_free); - index++; - n -= PAGE_SIZE; -@@ -928,9 +930,9 @@ static void zram_slot_free_notify(struct block_device *bdev, - zram = bdev->bd_disk->private_data; - meta = zram->meta; - -- bit_spin_lock(ZRAM_ACCESS, &meta->table[index].value); -+ zram_lock_table(&meta->table[index]); - zram_free_page(zram, index); -- bit_spin_unlock(ZRAM_ACCESS, &meta->table[index].value); -+ zram_unlock_table(&meta->table[index]); - atomic64_inc(&zram->stats.notify_free); - } - -diff --git a/drivers/block/zram/zram_drv.h b/drivers/block/zram/zram_drv.h -index 8e92339..9e3e953 100644 ---- a/drivers/block/zram/zram_drv.h -+++ b/drivers/block/zram/zram_drv.h -@@ -72,6 +72,9 @@ enum zram_pageflags { - struct zram_table_entry { - unsigned long handle; - unsigned long value; -+#ifdef CONFIG_PREEMPT_RT_BASE -+ spinlock_t lock; -+#endif - }; - - struct zram_stats { -@@ -119,4 +122,42 @@ struct zram { - */ - bool claim; /* Protected by bdev->bd_mutex */ - }; -+ -+#ifndef CONFIG_PREEMPT_RT_BASE -+static inline void zram_lock_table(struct zram_table_entry *table) -+{ -+ bit_spin_lock(ZRAM_ACCESS, &table->value); -+} -+ -+static inline void zram_unlock_table(struct zram_table_entry *table) -+{ -+ bit_spin_unlock(ZRAM_ACCESS, &table->value); -+} -+ -+static inline void zram_meta_init_table_locks(struct zram_meta *meta, u64 disksize) { } -+#else /* CONFIG_PREEMPT_RT_BASE */ -+static inline void zram_lock_table(struct zram_table_entry *table) -+{ -+ spin_lock(&table->lock); -+ __set_bit(ZRAM_ACCESS, &table->value); -+} -+ -+static inline void zram_unlock_table(struct zram_table_entry *table) -+{ -+ __clear_bit(ZRAM_ACCESS, &table->value); -+ spin_unlock(&table->lock); -+} -+ -+static inline void zram_meta_init_table_locks(struct zram_meta *meta, u64 disksize) -+{ -+ size_t num_pages = disksize >> PAGE_SHIFT; -+ size_t index; -+ -+ for (index = 0; index < num_pages; index++) { -+ spinlock_t *lock = &meta->table[index].lock; -+ spin_lock_init(lock); -+ } -+} -+#endif /* CONFIG_PREEMPT_RT_BASE */ -+ - #endif -diff --git a/drivers/bluetooth/ath3k.c b/drivers/bluetooth/ath3k.c -index fa893c3..0beaa52 100644 ---- a/drivers/bluetooth/ath3k.c -+++ b/drivers/bluetooth/ath3k.c -@@ -82,6 +82,7 @@ static const struct usb_device_id ath3k_table[] = { - { USB_DEVICE(0x0489, 0xe05f) }, - { USB_DEVICE(0x0489, 0xe076) }, - { USB_DEVICE(0x0489, 0xe078) }, -+ { USB_DEVICE(0x0489, 0xe095) }, - { USB_DEVICE(0x04c5, 0x1330) }, - { USB_DEVICE(0x04CA, 0x3004) }, - { USB_DEVICE(0x04CA, 0x3005) }, -@@ -92,6 +93,7 @@ static const struct usb_device_id ath3k_table[] = { - { USB_DEVICE(0x04CA, 0x300d) }, - { USB_DEVICE(0x04CA, 0x300f) }, - { USB_DEVICE(0x04CA, 0x3010) }, -+ { USB_DEVICE(0x04CA, 0x3014) }, - { USB_DEVICE(0x0930, 0x0219) }, - { USB_DEVICE(0x0930, 0x021c) }, - { USB_DEVICE(0x0930, 0x0220) }, -@@ -113,10 +115,12 @@ static const struct usb_device_id ath3k_table[] = { - { USB_DEVICE(0x13d3, 0x3362) }, - { USB_DEVICE(0x13d3, 0x3375) }, - { USB_DEVICE(0x13d3, 0x3393) }, -+ { USB_DEVICE(0x13d3, 0x3395) }, - { USB_DEVICE(0x13d3, 0x3402) }, - { USB_DEVICE(0x13d3, 0x3408) }, - { USB_DEVICE(0x13d3, 0x3423) }, - { USB_DEVICE(0x13d3, 0x3432) }, -+ { USB_DEVICE(0x13d3, 0x3472) }, - { USB_DEVICE(0x13d3, 0x3474) }, - - /* Atheros AR5BBU12 with sflash firmware */ -@@ -144,6 +148,7 @@ static const struct usb_device_id ath3k_blist_tbl[] = { - { USB_DEVICE(0x0489, 0xe05f), .driver_info = BTUSB_ATH3012 }, - { USB_DEVICE(0x0489, 0xe076), .driver_info = BTUSB_ATH3012 }, - { USB_DEVICE(0x0489, 0xe078), .driver_info = BTUSB_ATH3012 }, -+ { USB_DEVICE(0x0489, 0xe095), .driver_info = BTUSB_ATH3012 }, - { USB_DEVICE(0x04c5, 0x1330), .driver_info = BTUSB_ATH3012 }, - { USB_DEVICE(0x04ca, 0x3004), .driver_info = BTUSB_ATH3012 }, - { USB_DEVICE(0x04ca, 0x3005), .driver_info = BTUSB_ATH3012 }, -@@ -154,6 +159,7 @@ static const struct usb_device_id ath3k_blist_tbl[] = { - { USB_DEVICE(0x04ca, 0x300d), .driver_info = BTUSB_ATH3012 }, - { USB_DEVICE(0x04ca, 0x300f), .driver_info = BTUSB_ATH3012 }, - { USB_DEVICE(0x04ca, 0x3010), .driver_info = BTUSB_ATH3012 }, -+ { USB_DEVICE(0x04ca, 0x3014), .driver_info = BTUSB_ATH3012 }, - { USB_DEVICE(0x0930, 0x0219), .driver_info = BTUSB_ATH3012 }, - { USB_DEVICE(0x0930, 0x021c), .driver_info = BTUSB_ATH3012 }, - { USB_DEVICE(0x0930, 0x0220), .driver_info = BTUSB_ATH3012 }, -@@ -175,10 +181,12 @@ static const struct usb_device_id ath3k_blist_tbl[] = { - { USB_DEVICE(0x13d3, 0x3362), .driver_info = BTUSB_ATH3012 }, - { USB_DEVICE(0x13d3, 0x3375), .driver_info = BTUSB_ATH3012 }, - { USB_DEVICE(0x13d3, 0x3393), .driver_info = BTUSB_ATH3012 }, -+ { USB_DEVICE(0x13d3, 0x3395), .driver_info = BTUSB_ATH3012 }, - { USB_DEVICE(0x13d3, 0x3402), .driver_info = BTUSB_ATH3012 }, - { USB_DEVICE(0x13d3, 0x3408), .driver_info = BTUSB_ATH3012 }, - { USB_DEVICE(0x13d3, 0x3423), .driver_info = BTUSB_ATH3012 }, - { USB_DEVICE(0x13d3, 0x3432), .driver_info = BTUSB_ATH3012 }, -+ { USB_DEVICE(0x13d3, 0x3472), .driver_info = BTUSB_ATH3012 }, - { USB_DEVICE(0x13d3, 0x3474), .driver_info = BTUSB_ATH3012 }, - - /* Atheros AR5BBU22 with sflash firmware */ -diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c -index 9688971..7910759 100644 ---- a/drivers/bluetooth/btusb.c -+++ b/drivers/bluetooth/btusb.c -@@ -196,6 +196,7 @@ static const struct usb_device_id blacklist_table[] = { - { USB_DEVICE(0x0489, 0xe05f), .driver_info = BTUSB_ATH3012 }, - { USB_DEVICE(0x0489, 0xe076), .driver_info = BTUSB_ATH3012 }, - { USB_DEVICE(0x0489, 0xe078), .driver_info = BTUSB_ATH3012 }, -+ { USB_DEVICE(0x0489, 0xe095), .driver_info = BTUSB_ATH3012 }, - { USB_DEVICE(0x04c5, 0x1330), .driver_info = BTUSB_ATH3012 }, - { USB_DEVICE(0x04ca, 0x3004), .driver_info = BTUSB_ATH3012 }, - { USB_DEVICE(0x04ca, 0x3005), .driver_info = BTUSB_ATH3012 }, -@@ -206,6 +207,7 @@ static const struct usb_device_id blacklist_table[] = { - { USB_DEVICE(0x04ca, 0x300d), .driver_info = BTUSB_ATH3012 }, - { USB_DEVICE(0x04ca, 0x300f), .driver_info = BTUSB_ATH3012 }, - { USB_DEVICE(0x04ca, 0x3010), .driver_info = BTUSB_ATH3012 }, -+ { USB_DEVICE(0x04ca, 0x3014), .driver_info = BTUSB_ATH3012 }, - { USB_DEVICE(0x0930, 0x0219), .driver_info = BTUSB_ATH3012 }, - { USB_DEVICE(0x0930, 0x021c), .driver_info = BTUSB_ATH3012 }, - { USB_DEVICE(0x0930, 0x0220), .driver_info = BTUSB_ATH3012 }, -@@ -227,10 +229,12 @@ static const struct usb_device_id blacklist_table[] = { - { USB_DEVICE(0x13d3, 0x3362), .driver_info = BTUSB_ATH3012 }, - { USB_DEVICE(0x13d3, 0x3375), .driver_info = BTUSB_ATH3012 }, - { USB_DEVICE(0x13d3, 0x3393), .driver_info = BTUSB_ATH3012 }, -+ { USB_DEVICE(0x13d3, 0x3395), .driver_info = BTUSB_ATH3012 }, - { USB_DEVICE(0x13d3, 0x3402), .driver_info = BTUSB_ATH3012 }, - { USB_DEVICE(0x13d3, 0x3408), .driver_info = BTUSB_ATH3012 }, - { USB_DEVICE(0x13d3, 0x3423), .driver_info = BTUSB_ATH3012 }, - { USB_DEVICE(0x13d3, 0x3432), .driver_info = BTUSB_ATH3012 }, -+ { USB_DEVICE(0x13d3, 0x3472), .driver_info = BTUSB_ATH3012 }, - { USB_DEVICE(0x13d3, 0x3474), .driver_info = BTUSB_ATH3012 }, - - /* Atheros AR5BBU12 with sflash firmware */ -diff --git a/drivers/bluetooth/hci_vhci.c b/drivers/bluetooth/hci_vhci.c -index ed888e3..597b2d1 100644 ---- a/drivers/bluetooth/hci_vhci.c -+++ b/drivers/bluetooth/hci_vhci.c -@@ -50,6 +50,7 @@ struct vhci_data { - wait_queue_head_t read_wait; - struct sk_buff_head readq; - -+ struct mutex open_mutex; - struct delayed_work open_timeout; - }; - -@@ -87,12 +88,15 @@ static int vhci_send_frame(struct hci_dev *hdev, struct sk_buff *skb) - return 0; - } - --static int vhci_create_device(struct vhci_data *data, __u8 opcode) -+static int __vhci_create_device(struct vhci_data *data, __u8 opcode) - { - struct hci_dev *hdev; - struct sk_buff *skb; - __u8 dev_type; - -+ if (data->hdev) -+ return -EBADFD; -+ - /* bits 0-1 are dev_type (BR/EDR or AMP) */ - dev_type = opcode & 0x03; - -@@ -151,6 +155,17 @@ static int vhci_create_device(struct vhci_data *data, __u8 opcode) - return 0; - } - -+static int vhci_create_device(struct vhci_data *data, __u8 opcode) -+{ -+ int err; -+ -+ mutex_lock(&data->open_mutex); -+ err = __vhci_create_device(data, opcode); -+ mutex_unlock(&data->open_mutex); -+ -+ return err; -+} -+ - static inline ssize_t vhci_get_user(struct vhci_data *data, - struct iov_iter *from) - { -@@ -189,11 +204,6 @@ static inline ssize_t vhci_get_user(struct vhci_data *data, - break; - - case HCI_VENDOR_PKT: -- if (data->hdev) { -- kfree_skb(skb); -- return -EBADFD; -- } -- - cancel_delayed_work_sync(&data->open_timeout); - - opcode = *((__u8 *) skb->data); -@@ -320,6 +330,7 @@ static int vhci_open(struct inode *inode, struct file *file) - skb_queue_head_init(&data->readq); - init_waitqueue_head(&data->read_wait); - -+ mutex_init(&data->open_mutex); - INIT_DELAYED_WORK(&data->open_timeout, vhci_open_timeout); - - file->private_data = data; -@@ -333,15 +344,18 @@ static int vhci_open(struct inode *inode, struct file *file) - static int vhci_release(struct inode *inode, struct file *file) - { - struct vhci_data *data = file->private_data; -- struct hci_dev *hdev = data->hdev; -+ struct hci_dev *hdev; - - cancel_delayed_work_sync(&data->open_timeout); - -+ hdev = data->hdev; -+ - if (hdev) { - hci_unregister_dev(hdev); - hci_free_dev(hdev); - } - -+ skb_queue_purge(&data->readq); - file->private_data = NULL; - kfree(data); - -diff --git a/drivers/bus/imx-weim.c b/drivers/bus/imx-weim.c -index e98d15e..1827fc4 100644 ---- a/drivers/bus/imx-weim.c -+++ b/drivers/bus/imx-weim.c -@@ -150,7 +150,7 @@ static int __init weim_parse_dt(struct platform_device *pdev, - return ret; - } - -- for_each_child_of_node(pdev->dev.of_node, child) { -+ for_each_available_child_of_node(pdev->dev.of_node, child) { - if (!child->name) - continue; - -diff --git a/drivers/char/hw_random/exynos-rng.c b/drivers/char/hw_random/exynos-rng.c -index 30cf462..aa30af5 100644 ---- a/drivers/char/hw_random/exynos-rng.c -+++ b/drivers/char/hw_random/exynos-rng.c -@@ -89,6 +89,7 @@ static int exynos_read(struct hwrng *rng, void *buf, - struct exynos_rng, rng); - u32 *data = buf; - int retry = 100; -+ int ret = 4; - - pm_runtime_get_sync(exynos_rng->dev); - -@@ -97,17 +98,20 @@ static int exynos_read(struct hwrng *rng, void *buf, - while (!(exynos_rng_readl(exynos_rng, - EXYNOS_PRNG_STATUS_OFFSET) & PRNG_DONE) && --retry) - cpu_relax(); -- if (!retry) -- return -ETIMEDOUT; -+ if (!retry) { -+ ret = -ETIMEDOUT; -+ goto out; -+ } - - exynos_rng_writel(exynos_rng, PRNG_DONE, EXYNOS_PRNG_STATUS_OFFSET); - - *data = exynos_rng_readl(exynos_rng, EXYNOS_PRNG_OUT1_OFFSET); - -+out: - pm_runtime_mark_last_busy(exynos_rng->dev); - pm_runtime_put_sync_autosuspend(exynos_rng->dev); - -- return 4; -+ return ret; - } - - static int exynos_rng_probe(struct platform_device *pdev) -diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c -index 45cc39a..2521425 100644 ---- a/drivers/char/tpm/tpm-chip.c -+++ b/drivers/char/tpm/tpm-chip.c -@@ -136,11 +136,13 @@ struct tpm_chip *tpmm_chip_alloc(struct device *dev, - chip->cdev.owner = chip->pdev->driver->owner; - chip->cdev.kobj.parent = &chip->dev.kobj; - -+ devm_add_action(dev, (void (*)(void *)) put_device, &chip->dev); -+ - return chip; - } - EXPORT_SYMBOL_GPL(tpmm_chip_alloc); - --static int tpm_dev_add_device(struct tpm_chip *chip) -+static int tpm_add_char_device(struct tpm_chip *chip) - { - int rc; - -@@ -151,7 +153,6 @@ static int tpm_dev_add_device(struct tpm_chip *chip) - chip->devname, MAJOR(chip->dev.devt), - MINOR(chip->dev.devt), rc); - -- device_unregister(&chip->dev); - return rc; - } - -@@ -162,16 +163,17 @@ static int tpm_dev_add_device(struct tpm_chip *chip) - chip->devname, MAJOR(chip->dev.devt), - MINOR(chip->dev.devt), rc); - -+ cdev_del(&chip->cdev); - return rc; - } - - return rc; - } - --static void tpm_dev_del_device(struct tpm_chip *chip) -+static void tpm_del_char_device(struct tpm_chip *chip) - { - cdev_del(&chip->cdev); -- device_unregister(&chip->dev); -+ device_del(&chip->dev); - } - - static int tpm1_chip_register(struct tpm_chip *chip) -@@ -222,7 +224,7 @@ int tpm_chip_register(struct tpm_chip *chip) - - tpm_add_ppi(chip); - -- rc = tpm_dev_add_device(chip); -+ rc = tpm_add_char_device(chip); - if (rc) - goto out_err; - -@@ -274,6 +276,6 @@ void tpm_chip_unregister(struct tpm_chip *chip) - sysfs_remove_link(&chip->pdev->kobj, "ppi"); - - tpm1_chip_unregister(chip); -- tpm_dev_del_device(chip); -+ tpm_del_char_device(chip); - } - EXPORT_SYMBOL_GPL(tpm_chip_unregister); -diff --git a/drivers/char/tpm/tpm_crb.c b/drivers/char/tpm/tpm_crb.c -index 4bb9727..61e6429 100644 ---- a/drivers/char/tpm/tpm_crb.c -+++ b/drivers/char/tpm/tpm_crb.c -@@ -310,11 +310,11 @@ static int crb_acpi_remove(struct acpi_device *device) - struct device *dev = &device->dev; - struct tpm_chip *chip = dev_get_drvdata(dev); - -- tpm_chip_unregister(chip); -- - if (chip->flags & TPM_CHIP_FLAG_TPM2) - tpm2_shutdown(chip, TPM2_SU_CLEAR); - -+ tpm_chip_unregister(chip); -+ - return 0; - } - -diff --git a/drivers/char/tpm/tpm_eventlog.c b/drivers/char/tpm/tpm_eventlog.c -index bd72fb0..4e6940a 100644 ---- a/drivers/char/tpm/tpm_eventlog.c -+++ b/drivers/char/tpm/tpm_eventlog.c -@@ -232,7 +232,7 @@ static int tpm_binary_bios_measurements_show(struct seq_file *m, void *v) - { - struct tcpa_event *event = v; - struct tcpa_event temp_event; -- char *tempPtr; -+ char *temp_ptr; - int i; - - memcpy(&temp_event, event, sizeof(struct tcpa_event)); -@@ -242,10 +242,16 @@ static int tpm_binary_bios_measurements_show(struct seq_file *m, void *v) - temp_event.event_type = do_endian_conversion(event->event_type); - temp_event.event_size = do_endian_conversion(event->event_size); - -- tempPtr = (char *)&temp_event; -+ temp_ptr = (char *) &temp_event; - -- for (i = 0; i < sizeof(struct tcpa_event) + temp_event.event_size; i++) -- seq_putc(m, tempPtr[i]); -+ for (i = 0; i < (sizeof(struct tcpa_event) - 1) ; i++) -+ seq_putc(m, temp_ptr[i]); -+ -+ temp_ptr = (char *) v; -+ -+ for (i = (sizeof(struct tcpa_event) - 1); -+ i < (sizeof(struct tcpa_event) + temp_event.event_size); i++) -+ seq_putc(m, temp_ptr[i]); - - return 0; - -diff --git a/drivers/clk/at91/clk-generated.c b/drivers/clk/at91/clk-generated.c -index abc8094..4ad3298 100644 ---- a/drivers/clk/at91/clk-generated.c -+++ b/drivers/clk/at91/clk-generated.c -@@ -15,8 +15,8 @@ - #include - #include - #include --#include --#include -+#include -+#include - - #include "pmc.h" - -@@ -28,8 +28,9 @@ - - struct clk_generated { - struct clk_hw hw; -- struct at91_pmc *pmc; -+ struct regmap *regmap; - struct clk_range range; -+ spinlock_t *lock; - u32 id; - u32 gckdiv; - u8 parent_id; -@@ -41,49 +42,52 @@ struct clk_generated { - static int clk_generated_enable(struct clk_hw *hw) - { - struct clk_generated *gck = to_clk_generated(hw); -- struct at91_pmc *pmc = gck->pmc; -- u32 tmp; -+ unsigned long flags; - - pr_debug("GCLK: %s, gckdiv = %d, parent id = %d\n", - __func__, gck->gckdiv, gck->parent_id); - -- pmc_lock(pmc); -- pmc_write(pmc, AT91_PMC_PCR, (gck->id & AT91_PMC_PCR_PID_MASK)); -- tmp = pmc_read(pmc, AT91_PMC_PCR) & -- ~(AT91_PMC_PCR_GCKDIV_MASK | AT91_PMC_PCR_GCKCSS_MASK); -- pmc_write(pmc, AT91_PMC_PCR, tmp | AT91_PMC_PCR_GCKCSS(gck->parent_id) -- | AT91_PMC_PCR_CMD -- | AT91_PMC_PCR_GCKDIV(gck->gckdiv) -- | AT91_PMC_PCR_GCKEN); -- pmc_unlock(pmc); -+ spin_lock_irqsave(gck->lock, flags); -+ regmap_write(gck->regmap, AT91_PMC_PCR, -+ (gck->id & AT91_PMC_PCR_PID_MASK)); -+ regmap_update_bits(gck->regmap, AT91_PMC_PCR, -+ AT91_PMC_PCR_GCKDIV_MASK | AT91_PMC_PCR_GCKCSS_MASK | -+ AT91_PMC_PCR_CMD | AT91_PMC_PCR_GCKEN, -+ AT91_PMC_PCR_GCKCSS(gck->parent_id) | -+ AT91_PMC_PCR_CMD | -+ AT91_PMC_PCR_GCKDIV(gck->gckdiv) | -+ AT91_PMC_PCR_GCKEN); -+ spin_unlock_irqrestore(gck->lock, flags); - return 0; - } - - static void clk_generated_disable(struct clk_hw *hw) - { - struct clk_generated *gck = to_clk_generated(hw); -- struct at91_pmc *pmc = gck->pmc; -- u32 tmp; -- -- pmc_lock(pmc); -- pmc_write(pmc, AT91_PMC_PCR, (gck->id & AT91_PMC_PCR_PID_MASK)); -- tmp = pmc_read(pmc, AT91_PMC_PCR) & ~AT91_PMC_PCR_GCKEN; -- pmc_write(pmc, AT91_PMC_PCR, tmp | AT91_PMC_PCR_CMD); -- pmc_unlock(pmc); -+ unsigned long flags; -+ -+ spin_lock_irqsave(gck->lock, flags); -+ regmap_write(gck->regmap, AT91_PMC_PCR, -+ (gck->id & AT91_PMC_PCR_PID_MASK)); -+ regmap_update_bits(gck->regmap, AT91_PMC_PCR, -+ AT91_PMC_PCR_CMD | AT91_PMC_PCR_GCKEN, -+ AT91_PMC_PCR_CMD); -+ spin_unlock_irqrestore(gck->lock, flags); - } - - static int clk_generated_is_enabled(struct clk_hw *hw) - { - struct clk_generated *gck = to_clk_generated(hw); -- struct at91_pmc *pmc = gck->pmc; -- int ret; -+ unsigned long flags; -+ unsigned int status; - -- pmc_lock(pmc); -- pmc_write(pmc, AT91_PMC_PCR, (gck->id & AT91_PMC_PCR_PID_MASK)); -- ret = !!(pmc_read(pmc, AT91_PMC_PCR) & AT91_PMC_PCR_GCKEN); -- pmc_unlock(pmc); -+ spin_lock_irqsave(gck->lock, flags); -+ regmap_write(gck->regmap, AT91_PMC_PCR, -+ (gck->id & AT91_PMC_PCR_PID_MASK)); -+ regmap_read(gck->regmap, AT91_PMC_PCR, &status); -+ spin_unlock_irqrestore(gck->lock, flags); - -- return ret; -+ return status & AT91_PMC_PCR_GCKEN ? 1 : 0; - } - - static unsigned long -@@ -214,13 +218,14 @@ static const struct clk_ops generated_ops = { - */ - static void clk_generated_startup(struct clk_generated *gck) - { -- struct at91_pmc *pmc = gck->pmc; - u32 tmp; -+ unsigned long flags; - -- pmc_lock(pmc); -- pmc_write(pmc, AT91_PMC_PCR, (gck->id & AT91_PMC_PCR_PID_MASK)); -- tmp = pmc_read(pmc, AT91_PMC_PCR); -- pmc_unlock(pmc); -+ spin_lock_irqsave(gck->lock, flags); -+ regmap_write(gck->regmap, AT91_PMC_PCR, -+ (gck->id & AT91_PMC_PCR_PID_MASK)); -+ regmap_read(gck->regmap, AT91_PMC_PCR, &tmp); -+ spin_unlock_irqrestore(gck->lock, flags); - - gck->parent_id = (tmp & AT91_PMC_PCR_GCKCSS_MASK) - >> AT91_PMC_PCR_GCKCSS_OFFSET; -@@ -229,8 +234,8 @@ static void clk_generated_startup(struct clk_generated *gck) - } - - static struct clk * __init --at91_clk_register_generated(struct at91_pmc *pmc, const char *name, -- const char **parent_names, u8 num_parents, -+at91_clk_register_generated(struct regmap *regmap, spinlock_t *lock, const char -+ *name, const char **parent_names, u8 num_parents, - u8 id, const struct clk_range *range) - { - struct clk_generated *gck; -@@ -249,7 +254,8 @@ at91_clk_register_generated(struct at91_pmc *pmc, const char *name, - - gck->id = id; - gck->hw.init = &init; -- gck->pmc = pmc; -+ gck->regmap = regmap; -+ gck->lock = lock; - gck->range = *range; - - clk = clk_register(NULL, &gck->hw); -@@ -261,8 +267,7 @@ at91_clk_register_generated(struct at91_pmc *pmc, const char *name, - return clk; - } - --void __init of_sama5d2_clk_generated_setup(struct device_node *np, -- struct at91_pmc *pmc) -+void __init of_sama5d2_clk_generated_setup(struct device_node *np) - { - int num; - u32 id; -@@ -272,6 +277,7 @@ void __init of_sama5d2_clk_generated_setup(struct device_node *np, - const char *parent_names[GENERATED_SOURCE_MAX]; - struct device_node *gcknp; - struct clk_range range = CLK_RANGE(0, 0); -+ struct regmap *regmap; - - num_parents = of_clk_get_parent_count(np); - if (num_parents <= 0 || num_parents > GENERATED_SOURCE_MAX) -@@ -283,6 +289,10 @@ void __init of_sama5d2_clk_generated_setup(struct device_node *np, - if (!num || num > PERIPHERAL_MAX) - return; - -+ regmap = syscon_node_to_regmap(of_get_parent(np)); -+ if (IS_ERR(regmap)) -+ return; -+ - for_each_child_of_node(np, gcknp) { - if (of_property_read_u32(gcknp, "reg", &id)) - continue; -@@ -296,11 +306,14 @@ void __init of_sama5d2_clk_generated_setup(struct device_node *np, - of_at91_get_clk_range(gcknp, "atmel,clk-output-range", - &range); - -- clk = at91_clk_register_generated(pmc, name, parent_names, -- num_parents, id, &range); -+ clk = at91_clk_register_generated(regmap, &pmc_pcr_lock, name, -+ parent_names, num_parents, -+ id, &range); - if (IS_ERR(clk)) - continue; - - of_clk_add_provider(gcknp, of_clk_src_simple_get, clk); - } - } -+CLK_OF_DECLARE(of_sama5d2_clk_generated_setup, "atmel,sama5d2-clk-generated", -+ of_sama5d2_clk_generated_setup); -diff --git a/drivers/clk/at91/clk-h32mx.c b/drivers/clk/at91/clk-h32mx.c -index 61566bc..8e20c8a 100644 ---- a/drivers/clk/at91/clk-h32mx.c -+++ b/drivers/clk/at91/clk-h32mx.c -@@ -15,15 +15,9 @@ - #include - #include - #include --#include - #include --#include --#include --#include --#include --#include --#include --#include -+#include -+#include - - #include "pmc.h" - -@@ -31,7 +25,7 @@ - - struct clk_sama5d4_h32mx { - struct clk_hw hw; -- struct at91_pmc *pmc; -+ struct regmap *regmap; - }; - - #define to_clk_sama5d4_h32mx(hw) container_of(hw, struct clk_sama5d4_h32mx, hw) -@@ -40,8 +34,10 @@ static unsigned long clk_sama5d4_h32mx_recalc_rate(struct clk_hw *hw, - unsigned long parent_rate) - { - struct clk_sama5d4_h32mx *h32mxclk = to_clk_sama5d4_h32mx(hw); -+ unsigned int mckr; - -- if (pmc_read(h32mxclk->pmc, AT91_PMC_MCKR) & AT91_PMC_H32MXDIV) -+ regmap_read(h32mxclk->regmap, AT91_PMC_MCKR, &mckr); -+ if (mckr & AT91_PMC_H32MXDIV) - return parent_rate / 2; - - if (parent_rate > H32MX_MAX_FREQ) -@@ -70,18 +66,16 @@ static int clk_sama5d4_h32mx_set_rate(struct clk_hw *hw, unsigned long rate, - unsigned long parent_rate) - { - struct clk_sama5d4_h32mx *h32mxclk = to_clk_sama5d4_h32mx(hw); -- struct at91_pmc *pmc = h32mxclk->pmc; -- u32 tmp; -+ u32 mckr = 0; - - if (parent_rate != rate && (parent_rate / 2) != rate) - return -EINVAL; - -- pmc_lock(pmc); -- tmp = pmc_read(pmc, AT91_PMC_MCKR) & ~AT91_PMC_H32MXDIV; - if ((parent_rate / 2) == rate) -- tmp |= AT91_PMC_H32MXDIV; -- pmc_write(pmc, AT91_PMC_MCKR, tmp); -- pmc_unlock(pmc); -+ mckr = AT91_PMC_H32MXDIV; -+ -+ regmap_update_bits(h32mxclk->regmap, AT91_PMC_MCKR, -+ AT91_PMC_H32MXDIV, mckr); - - return 0; - } -@@ -92,14 +86,18 @@ static const struct clk_ops h32mx_ops = { - .set_rate = clk_sama5d4_h32mx_set_rate, - }; - --void __init of_sama5d4_clk_h32mx_setup(struct device_node *np, -- struct at91_pmc *pmc) -+static void __init of_sama5d4_clk_h32mx_setup(struct device_node *np) - { - struct clk_sama5d4_h32mx *h32mxclk; - struct clk_init_data init; - const char *parent_name; -+ struct regmap *regmap; - struct clk *clk; - -+ regmap = syscon_node_to_regmap(of_get_parent(np)); -+ if (IS_ERR(regmap)) -+ return; -+ - h32mxclk = kzalloc(sizeof(*h32mxclk), GFP_KERNEL); - if (!h32mxclk) - return; -@@ -113,13 +111,15 @@ void __init of_sama5d4_clk_h32mx_setup(struct device_node *np, - init.flags = CLK_SET_RATE_GATE; - - h32mxclk->hw.init = &init; -- h32mxclk->pmc = pmc; -+ h32mxclk->regmap = regmap; - - clk = clk_register(NULL, &h32mxclk->hw); -- if (!clk) { -+ if (IS_ERR(clk)) { - kfree(h32mxclk); - return; - } - - of_clk_add_provider(np, of_clk_src_simple_get, clk); - } -+CLK_OF_DECLARE(of_sama5d4_clk_h32mx_setup, "atmel,sama5d4-clk-h32mx", -+ of_sama5d4_clk_h32mx_setup); -diff --git a/drivers/clk/at91/clk-main.c b/drivers/clk/at91/clk-main.c -index fd7247d..4bfc94d 100644 ---- a/drivers/clk/at91/clk-main.c -+++ b/drivers/clk/at91/clk-main.c -@@ -13,13 +13,8 @@ - #include - #include - #include --#include --#include --#include --#include --#include --#include --#include -+#include -+#include - - #include "pmc.h" - -@@ -34,18 +29,14 @@ - - struct clk_main_osc { - struct clk_hw hw; -- struct at91_pmc *pmc; -- unsigned int irq; -- wait_queue_head_t wait; -+ struct regmap *regmap; - }; - - #define to_clk_main_osc(hw) container_of(hw, struct clk_main_osc, hw) - - struct clk_main_rc_osc { - struct clk_hw hw; -- struct at91_pmc *pmc; -- unsigned int irq; -- wait_queue_head_t wait; -+ struct regmap *regmap; - unsigned long frequency; - unsigned long accuracy; - }; -@@ -54,51 +45,47 @@ struct clk_main_rc_osc { - - struct clk_rm9200_main { - struct clk_hw hw; -- struct at91_pmc *pmc; -+ struct regmap *regmap; - }; - - #define to_clk_rm9200_main(hw) container_of(hw, struct clk_rm9200_main, hw) - - struct clk_sam9x5_main { - struct clk_hw hw; -- struct at91_pmc *pmc; -- unsigned int irq; -- wait_queue_head_t wait; -+ struct regmap *regmap; - u8 parent; - }; - - #define to_clk_sam9x5_main(hw) container_of(hw, struct clk_sam9x5_main, hw) - --static irqreturn_t clk_main_osc_irq_handler(int irq, void *dev_id) -+static inline bool clk_main_osc_ready(struct regmap *regmap) - { -- struct clk_main_osc *osc = dev_id; -+ unsigned int status; - -- wake_up(&osc->wait); -- disable_irq_nosync(osc->irq); -+ regmap_read(regmap, AT91_PMC_SR, &status); - -- return IRQ_HANDLED; -+ return status & AT91_PMC_MOSCS; - } - - static int clk_main_osc_prepare(struct clk_hw *hw) - { - struct clk_main_osc *osc = to_clk_main_osc(hw); -- struct at91_pmc *pmc = osc->pmc; -+ struct regmap *regmap = osc->regmap; - u32 tmp; - -- tmp = pmc_read(pmc, AT91_CKGR_MOR) & ~MOR_KEY_MASK; -+ regmap_read(regmap, AT91_CKGR_MOR, &tmp); -+ tmp &= ~MOR_KEY_MASK; -+ - if (tmp & AT91_PMC_OSCBYPASS) - return 0; - - if (!(tmp & AT91_PMC_MOSCEN)) { - tmp |= AT91_PMC_MOSCEN | AT91_PMC_KEY; -- pmc_write(pmc, AT91_CKGR_MOR, tmp); -+ regmap_write(regmap, AT91_CKGR_MOR, tmp); - } - -- while (!(pmc_read(pmc, AT91_PMC_SR) & AT91_PMC_MOSCS)) { -- enable_irq(osc->irq); -- wait_event(osc->wait, -- pmc_read(pmc, AT91_PMC_SR) & AT91_PMC_MOSCS); -- } -+ while (!clk_main_osc_ready(regmap)) -+ cpu_relax(); - - return 0; - } -@@ -106,9 +93,10 @@ static int clk_main_osc_prepare(struct clk_hw *hw) - static void clk_main_osc_unprepare(struct clk_hw *hw) - { - struct clk_main_osc *osc = to_clk_main_osc(hw); -- struct at91_pmc *pmc = osc->pmc; -- u32 tmp = pmc_read(pmc, AT91_CKGR_MOR); -+ struct regmap *regmap = osc->regmap; -+ u32 tmp; - -+ regmap_read(regmap, AT91_CKGR_MOR, &tmp); - if (tmp & AT91_PMC_OSCBYPASS) - return; - -@@ -116,20 +104,22 @@ static void clk_main_osc_unprepare(struct clk_hw *hw) - return; - - tmp &= ~(AT91_PMC_KEY | AT91_PMC_MOSCEN); -- pmc_write(pmc, AT91_CKGR_MOR, tmp | AT91_PMC_KEY); -+ regmap_write(regmap, AT91_CKGR_MOR, tmp | AT91_PMC_KEY); - } - - static int clk_main_osc_is_prepared(struct clk_hw *hw) - { - struct clk_main_osc *osc = to_clk_main_osc(hw); -- struct at91_pmc *pmc = osc->pmc; -- u32 tmp = pmc_read(pmc, AT91_CKGR_MOR); -+ struct regmap *regmap = osc->regmap; -+ u32 tmp, status; - -+ regmap_read(regmap, AT91_CKGR_MOR, &tmp); - if (tmp & AT91_PMC_OSCBYPASS) - return 1; - -- return !!((pmc_read(pmc, AT91_PMC_SR) & AT91_PMC_MOSCS) && -- (pmc_read(pmc, AT91_CKGR_MOR) & AT91_PMC_MOSCEN)); -+ regmap_read(regmap, AT91_PMC_SR, &status); -+ -+ return (status & AT91_PMC_MOSCS) && (tmp & AT91_PMC_MOSCEN); - } - - static const struct clk_ops main_osc_ops = { -@@ -139,18 +129,16 @@ static const struct clk_ops main_osc_ops = { - }; - - static struct clk * __init --at91_clk_register_main_osc(struct at91_pmc *pmc, -- unsigned int irq, -+at91_clk_register_main_osc(struct regmap *regmap, - const char *name, - const char *parent_name, - bool bypass) - { -- int ret; - struct clk_main_osc *osc; - struct clk *clk = NULL; - struct clk_init_data init; - -- if (!pmc || !irq || !name || !parent_name) -+ if (!name || !parent_name) - return ERR_PTR(-EINVAL); - - osc = kzalloc(sizeof(*osc), GFP_KERNEL); -@@ -164,85 +152,70 @@ at91_clk_register_main_osc(struct at91_pmc *pmc, - init.flags = CLK_IGNORE_UNUSED; - - osc->hw.init = &init; -- osc->pmc = pmc; -- osc->irq = irq; -- -- init_waitqueue_head(&osc->wait); -- irq_set_status_flags(osc->irq, IRQ_NOAUTOEN); -- ret = request_irq(osc->irq, clk_main_osc_irq_handler, -- IRQF_TRIGGER_HIGH, name, osc); -- if (ret) { -- kfree(osc); -- return ERR_PTR(ret); -- } -+ osc->regmap = regmap; - - if (bypass) -- pmc_write(pmc, AT91_CKGR_MOR, -- (pmc_read(pmc, AT91_CKGR_MOR) & -- ~(MOR_KEY_MASK | AT91_PMC_MOSCEN)) | -- AT91_PMC_OSCBYPASS | AT91_PMC_KEY); -+ regmap_update_bits(regmap, -+ AT91_CKGR_MOR, MOR_KEY_MASK | -+ AT91_PMC_MOSCEN, -+ AT91_PMC_OSCBYPASS | AT91_PMC_KEY); - - clk = clk_register(NULL, &osc->hw); -- if (IS_ERR(clk)) { -- free_irq(irq, osc); -+ if (IS_ERR(clk)) - kfree(osc); -- } - - return clk; - } - --void __init of_at91rm9200_clk_main_osc_setup(struct device_node *np, -- struct at91_pmc *pmc) -+static void __init of_at91rm9200_clk_main_osc_setup(struct device_node *np) - { - struct clk *clk; -- unsigned int irq; - const char *name = np->name; - const char *parent_name; -+ struct regmap *regmap; - bool bypass; - - of_property_read_string(np, "clock-output-names", &name); - bypass = of_property_read_bool(np, "atmel,osc-bypass"); - parent_name = of_clk_get_parent_name(np, 0); - -- irq = irq_of_parse_and_map(np, 0); -- if (!irq) -+ regmap = syscon_node_to_regmap(of_get_parent(np)); -+ if (IS_ERR(regmap)) - return; - -- clk = at91_clk_register_main_osc(pmc, irq, name, parent_name, bypass); -+ clk = at91_clk_register_main_osc(regmap, name, parent_name, bypass); - if (IS_ERR(clk)) - return; - - of_clk_add_provider(np, of_clk_src_simple_get, clk); - } -+CLK_OF_DECLARE(at91rm9200_clk_main_osc, "atmel,at91rm9200-clk-main-osc", -+ of_at91rm9200_clk_main_osc_setup); - --static irqreturn_t clk_main_rc_osc_irq_handler(int irq, void *dev_id) -+static bool clk_main_rc_osc_ready(struct regmap *regmap) - { -- struct clk_main_rc_osc *osc = dev_id; -+ unsigned int status; - -- wake_up(&osc->wait); -- disable_irq_nosync(osc->irq); -+ regmap_read(regmap, AT91_PMC_SR, &status); - -- return IRQ_HANDLED; -+ return status & AT91_PMC_MOSCRCS; - } - - static int clk_main_rc_osc_prepare(struct clk_hw *hw) - { - struct clk_main_rc_osc *osc = to_clk_main_rc_osc(hw); -- struct at91_pmc *pmc = osc->pmc; -- u32 tmp; -+ struct regmap *regmap = osc->regmap; -+ unsigned int mor; - -- tmp = pmc_read(pmc, AT91_CKGR_MOR) & ~MOR_KEY_MASK; -+ regmap_read(regmap, AT91_CKGR_MOR, &mor); - -- if (!(tmp & AT91_PMC_MOSCRCEN)) { -- tmp |= AT91_PMC_MOSCRCEN | AT91_PMC_KEY; -- pmc_write(pmc, AT91_CKGR_MOR, tmp); -- } -+ if (!(mor & AT91_PMC_MOSCRCEN)) -+ regmap_update_bits(regmap, AT91_CKGR_MOR, -+ MOR_KEY_MASK | AT91_PMC_MOSCRCEN, -+ AT91_PMC_MOSCRCEN | AT91_PMC_KEY); - -- while (!(pmc_read(pmc, AT91_PMC_SR) & AT91_PMC_MOSCRCS)) { -- enable_irq(osc->irq); -- wait_event(osc->wait, -- pmc_read(pmc, AT91_PMC_SR) & AT91_PMC_MOSCRCS); -- } -+ while (!clk_main_rc_osc_ready(regmap)) -+ cpu_relax(); - - return 0; - } -@@ -250,23 +223,28 @@ static int clk_main_rc_osc_prepare(struct clk_hw *hw) - static void clk_main_rc_osc_unprepare(struct clk_hw *hw) - { - struct clk_main_rc_osc *osc = to_clk_main_rc_osc(hw); -- struct at91_pmc *pmc = osc->pmc; -- u32 tmp = pmc_read(pmc, AT91_CKGR_MOR); -+ struct regmap *regmap = osc->regmap; -+ unsigned int mor; -+ -+ regmap_read(regmap, AT91_CKGR_MOR, &mor); - -- if (!(tmp & AT91_PMC_MOSCRCEN)) -+ if (!(mor & AT91_PMC_MOSCRCEN)) - return; - -- tmp &= ~(MOR_KEY_MASK | AT91_PMC_MOSCRCEN); -- pmc_write(pmc, AT91_CKGR_MOR, tmp | AT91_PMC_KEY); -+ regmap_update_bits(regmap, AT91_CKGR_MOR, -+ MOR_KEY_MASK | AT91_PMC_MOSCRCEN, AT91_PMC_KEY); - } - - static int clk_main_rc_osc_is_prepared(struct clk_hw *hw) - { - struct clk_main_rc_osc *osc = to_clk_main_rc_osc(hw); -- struct at91_pmc *pmc = osc->pmc; -+ struct regmap *regmap = osc->regmap; -+ unsigned int mor, status; - -- return !!((pmc_read(pmc, AT91_PMC_SR) & AT91_PMC_MOSCRCS) && -- (pmc_read(pmc, AT91_CKGR_MOR) & AT91_PMC_MOSCRCEN)); -+ regmap_read(regmap, AT91_CKGR_MOR, &mor); -+ regmap_read(regmap, AT91_PMC_SR, &status); -+ -+ return (mor & AT91_PMC_MOSCRCEN) && (status & AT91_PMC_MOSCRCS); - } - - static unsigned long clk_main_rc_osc_recalc_rate(struct clk_hw *hw, -@@ -294,17 +272,15 @@ static const struct clk_ops main_rc_osc_ops = { - }; - - static struct clk * __init --at91_clk_register_main_rc_osc(struct at91_pmc *pmc, -- unsigned int irq, -+at91_clk_register_main_rc_osc(struct regmap *regmap, - const char *name, - u32 frequency, u32 accuracy) - { -- int ret; - struct clk_main_rc_osc *osc; - struct clk *clk = NULL; - struct clk_init_data init; - -- if (!pmc || !irq || !name || !frequency) -+ if (!name || !frequency) - return ERR_PTR(-EINVAL); - - osc = kzalloc(sizeof(*osc), GFP_KERNEL); -@@ -318,63 +294,53 @@ at91_clk_register_main_rc_osc(struct at91_pmc *pmc, - init.flags = CLK_IS_ROOT | CLK_IGNORE_UNUSED; - - osc->hw.init = &init; -- osc->pmc = pmc; -- osc->irq = irq; -+ osc->regmap = regmap; - osc->frequency = frequency; - osc->accuracy = accuracy; - -- init_waitqueue_head(&osc->wait); -- irq_set_status_flags(osc->irq, IRQ_NOAUTOEN); -- ret = request_irq(osc->irq, clk_main_rc_osc_irq_handler, -- IRQF_TRIGGER_HIGH, name, osc); -- if (ret) -- return ERR_PTR(ret); -- - clk = clk_register(NULL, &osc->hw); -- if (IS_ERR(clk)) { -- free_irq(irq, osc); -+ if (IS_ERR(clk)) - kfree(osc); -- } - - return clk; - } - --void __init of_at91sam9x5_clk_main_rc_osc_setup(struct device_node *np, -- struct at91_pmc *pmc) -+static void __init of_at91sam9x5_clk_main_rc_osc_setup(struct device_node *np) - { - struct clk *clk; -- unsigned int irq; - u32 frequency = 0; - u32 accuracy = 0; - const char *name = np->name; -+ struct regmap *regmap; - - of_property_read_string(np, "clock-output-names", &name); - of_property_read_u32(np, "clock-frequency", &frequency); - of_property_read_u32(np, "clock-accuracy", &accuracy); - -- irq = irq_of_parse_and_map(np, 0); -- if (!irq) -+ regmap = syscon_node_to_regmap(of_get_parent(np)); -+ if (IS_ERR(regmap)) - return; - -- clk = at91_clk_register_main_rc_osc(pmc, irq, name, frequency, -- accuracy); -+ clk = at91_clk_register_main_rc_osc(regmap, name, frequency, accuracy); - if (IS_ERR(clk)) - return; - - of_clk_add_provider(np, of_clk_src_simple_get, clk); - } -+CLK_OF_DECLARE(at91sam9x5_clk_main_rc_osc, "atmel,at91sam9x5-clk-main-rc-osc", -+ of_at91sam9x5_clk_main_rc_osc_setup); - - --static int clk_main_probe_frequency(struct at91_pmc *pmc) -+static int clk_main_probe_frequency(struct regmap *regmap) - { - unsigned long prep_time, timeout; -- u32 tmp; -+ unsigned int mcfr; - - timeout = jiffies + usecs_to_jiffies(MAINFRDY_TIMEOUT); - do { - prep_time = jiffies; -- tmp = pmc_read(pmc, AT91_CKGR_MCFR); -- if (tmp & AT91_PMC_MAINRDY) -+ regmap_read(regmap, AT91_CKGR_MCFR, &mcfr); -+ if (mcfr & AT91_PMC_MAINRDY) - return 0; - usleep_range(MAINF_LOOP_MIN_WAIT, MAINF_LOOP_MAX_WAIT); - } while (time_before(prep_time, timeout)); -@@ -382,34 +348,37 @@ static int clk_main_probe_frequency(struct at91_pmc *pmc) - return -ETIMEDOUT; - } - --static unsigned long clk_main_recalc_rate(struct at91_pmc *pmc, -+static unsigned long clk_main_recalc_rate(struct regmap *regmap, - unsigned long parent_rate) - { -- u32 tmp; -+ unsigned int mcfr; - - if (parent_rate) - return parent_rate; - - pr_warn("Main crystal frequency not set, using approximate value\n"); -- tmp = pmc_read(pmc, AT91_CKGR_MCFR); -- if (!(tmp & AT91_PMC_MAINRDY)) -+ regmap_read(regmap, AT91_CKGR_MCFR, &mcfr); -+ if (!(mcfr & AT91_PMC_MAINRDY)) - return 0; - -- return ((tmp & AT91_PMC_MAINF) * SLOW_CLOCK_FREQ) / MAINF_DIV; -+ return ((mcfr & AT91_PMC_MAINF) * SLOW_CLOCK_FREQ) / MAINF_DIV; - } - - static int clk_rm9200_main_prepare(struct clk_hw *hw) - { - struct clk_rm9200_main *clkmain = to_clk_rm9200_main(hw); - -- return clk_main_probe_frequency(clkmain->pmc); -+ return clk_main_probe_frequency(clkmain->regmap); - } - - static int clk_rm9200_main_is_prepared(struct clk_hw *hw) - { - struct clk_rm9200_main *clkmain = to_clk_rm9200_main(hw); -+ unsigned int status; -+ -+ regmap_read(clkmain->regmap, AT91_CKGR_MCFR, &status); - -- return !!(pmc_read(clkmain->pmc, AT91_CKGR_MCFR) & AT91_PMC_MAINRDY); -+ return status & AT91_PMC_MAINRDY ? 1 : 0; - } - - static unsigned long clk_rm9200_main_recalc_rate(struct clk_hw *hw, -@@ -417,7 +386,7 @@ static unsigned long clk_rm9200_main_recalc_rate(struct clk_hw *hw, - { - struct clk_rm9200_main *clkmain = to_clk_rm9200_main(hw); - -- return clk_main_recalc_rate(clkmain->pmc, parent_rate); -+ return clk_main_recalc_rate(clkmain->regmap, parent_rate); - } - - static const struct clk_ops rm9200_main_ops = { -@@ -427,7 +396,7 @@ static const struct clk_ops rm9200_main_ops = { - }; - - static struct clk * __init --at91_clk_register_rm9200_main(struct at91_pmc *pmc, -+at91_clk_register_rm9200_main(struct regmap *regmap, - const char *name, - const char *parent_name) - { -@@ -435,7 +404,7 @@ at91_clk_register_rm9200_main(struct at91_pmc *pmc, - struct clk *clk = NULL; - struct clk_init_data init; - -- if (!pmc || !name) -+ if (!name) - return ERR_PTR(-EINVAL); - - if (!parent_name) -@@ -452,7 +421,7 @@ at91_clk_register_rm9200_main(struct at91_pmc *pmc, - init.flags = 0; - - clkmain->hw.init = &init; -- clkmain->pmc = pmc; -+ clkmain->regmap = regmap; - - clk = clk_register(NULL, &clkmain->hw); - if (IS_ERR(clk)) -@@ -461,52 +430,54 @@ at91_clk_register_rm9200_main(struct at91_pmc *pmc, - return clk; - } - --void __init of_at91rm9200_clk_main_setup(struct device_node *np, -- struct at91_pmc *pmc) -+static void __init of_at91rm9200_clk_main_setup(struct device_node *np) - { - struct clk *clk; - const char *parent_name; - const char *name = np->name; -+ struct regmap *regmap; - - parent_name = of_clk_get_parent_name(np, 0); - of_property_read_string(np, "clock-output-names", &name); - -- clk = at91_clk_register_rm9200_main(pmc, name, parent_name); -+ regmap = syscon_node_to_regmap(of_get_parent(np)); -+ if (IS_ERR(regmap)) -+ return; -+ -+ clk = at91_clk_register_rm9200_main(regmap, name, parent_name); - if (IS_ERR(clk)) - return; - - of_clk_add_provider(np, of_clk_src_simple_get, clk); - } -+CLK_OF_DECLARE(at91rm9200_clk_main, "atmel,at91rm9200-clk-main", -+ of_at91rm9200_clk_main_setup); - --static irqreturn_t clk_sam9x5_main_irq_handler(int irq, void *dev_id) -+static inline bool clk_sam9x5_main_ready(struct regmap *regmap) - { -- struct clk_sam9x5_main *clkmain = dev_id; -+ unsigned int status; - -- wake_up(&clkmain->wait); -- disable_irq_nosync(clkmain->irq); -+ regmap_read(regmap, AT91_PMC_SR, &status); - -- return IRQ_HANDLED; -+ return status & AT91_PMC_MOSCSELS ? 1 : 0; - } - - static int clk_sam9x5_main_prepare(struct clk_hw *hw) - { - struct clk_sam9x5_main *clkmain = to_clk_sam9x5_main(hw); -- struct at91_pmc *pmc = clkmain->pmc; -+ struct regmap *regmap = clkmain->regmap; - -- while (!(pmc_read(pmc, AT91_PMC_SR) & AT91_PMC_MOSCSELS)) { -- enable_irq(clkmain->irq); -- wait_event(clkmain->wait, -- pmc_read(pmc, AT91_PMC_SR) & AT91_PMC_MOSCSELS); -- } -+ while (!clk_sam9x5_main_ready(regmap)) -+ cpu_relax(); - -- return clk_main_probe_frequency(pmc); -+ return clk_main_probe_frequency(regmap); - } - - static int clk_sam9x5_main_is_prepared(struct clk_hw *hw) - { - struct clk_sam9x5_main *clkmain = to_clk_sam9x5_main(hw); - -- return !!(pmc_read(clkmain->pmc, AT91_PMC_SR) & AT91_PMC_MOSCSELS); -+ return clk_sam9x5_main_ready(clkmain->regmap); - } - - static unsigned long clk_sam9x5_main_recalc_rate(struct clk_hw *hw, -@@ -514,30 +485,28 @@ static unsigned long clk_sam9x5_main_recalc_rate(struct clk_hw *hw, - { - struct clk_sam9x5_main *clkmain = to_clk_sam9x5_main(hw); - -- return clk_main_recalc_rate(clkmain->pmc, parent_rate); -+ return clk_main_recalc_rate(clkmain->regmap, parent_rate); - } - - static int clk_sam9x5_main_set_parent(struct clk_hw *hw, u8 index) - { - struct clk_sam9x5_main *clkmain = to_clk_sam9x5_main(hw); -- struct at91_pmc *pmc = clkmain->pmc; -- u32 tmp; -+ struct regmap *regmap = clkmain->regmap; -+ unsigned int tmp; - - if (index > 1) - return -EINVAL; - -- tmp = pmc_read(pmc, AT91_CKGR_MOR) & ~MOR_KEY_MASK; -+ regmap_read(regmap, AT91_CKGR_MOR, &tmp); -+ tmp &= ~MOR_KEY_MASK; - - if (index && !(tmp & AT91_PMC_MOSCSEL)) -- pmc_write(pmc, AT91_CKGR_MOR, tmp | AT91_PMC_MOSCSEL); -+ regmap_write(regmap, AT91_CKGR_MOR, tmp | AT91_PMC_MOSCSEL); - else if (!index && (tmp & AT91_PMC_MOSCSEL)) -- pmc_write(pmc, AT91_CKGR_MOR, tmp & ~AT91_PMC_MOSCSEL); -+ regmap_write(regmap, AT91_CKGR_MOR, tmp & ~AT91_PMC_MOSCSEL); - -- while (!(pmc_read(pmc, AT91_PMC_SR) & AT91_PMC_MOSCSELS)) { -- enable_irq(clkmain->irq); -- wait_event(clkmain->wait, -- pmc_read(pmc, AT91_PMC_SR) & AT91_PMC_MOSCSELS); -- } -+ while (!clk_sam9x5_main_ready(regmap)) -+ cpu_relax(); - - return 0; - } -@@ -545,8 +514,11 @@ static int clk_sam9x5_main_set_parent(struct clk_hw *hw, u8 index) - static u8 clk_sam9x5_main_get_parent(struct clk_hw *hw) - { - struct clk_sam9x5_main *clkmain = to_clk_sam9x5_main(hw); -+ unsigned int status; -+ -+ regmap_read(clkmain->regmap, AT91_CKGR_MOR, &status); - -- return !!(pmc_read(clkmain->pmc, AT91_CKGR_MOR) & AT91_PMC_MOSCEN); -+ return status & AT91_PMC_MOSCEN ? 1 : 0; - } - - static const struct clk_ops sam9x5_main_ops = { -@@ -558,18 +530,17 @@ static const struct clk_ops sam9x5_main_ops = { - }; - - static struct clk * __init --at91_clk_register_sam9x5_main(struct at91_pmc *pmc, -- unsigned int irq, -+at91_clk_register_sam9x5_main(struct regmap *regmap, - const char *name, - const char **parent_names, - int num_parents) - { -- int ret; - struct clk_sam9x5_main *clkmain; - struct clk *clk = NULL; - struct clk_init_data init; -+ unsigned int status; - -- if (!pmc || !irq || !name) -+ if (!name) - return ERR_PTR(-EINVAL); - - if (!parent_names || !num_parents) -@@ -586,51 +557,42 @@ at91_clk_register_sam9x5_main(struct at91_pmc *pmc, - init.flags = CLK_SET_PARENT_GATE; - - clkmain->hw.init = &init; -- clkmain->pmc = pmc; -- clkmain->irq = irq; -- clkmain->parent = !!(pmc_read(clkmain->pmc, AT91_CKGR_MOR) & -- AT91_PMC_MOSCEN); -- init_waitqueue_head(&clkmain->wait); -- irq_set_status_flags(clkmain->irq, IRQ_NOAUTOEN); -- ret = request_irq(clkmain->irq, clk_sam9x5_main_irq_handler, -- IRQF_TRIGGER_HIGH, name, clkmain); -- if (ret) -- return ERR_PTR(ret); -+ clkmain->regmap = regmap; -+ regmap_read(clkmain->regmap, AT91_CKGR_MOR, &status); -+ clkmain->parent = status & AT91_PMC_MOSCEN ? 1 : 0; - - clk = clk_register(NULL, &clkmain->hw); -- if (IS_ERR(clk)) { -- free_irq(clkmain->irq, clkmain); -+ if (IS_ERR(clk)) - kfree(clkmain); -- } - - return clk; - } - --void __init of_at91sam9x5_clk_main_setup(struct device_node *np, -- struct at91_pmc *pmc) -+static void __init of_at91sam9x5_clk_main_setup(struct device_node *np) - { - struct clk *clk; - const char *parent_names[2]; - int num_parents; -- unsigned int irq; - const char *name = np->name; -+ struct regmap *regmap; - - num_parents = of_clk_get_parent_count(np); - if (num_parents <= 0 || num_parents > 2) - return; - - of_clk_parent_fill(np, parent_names, num_parents); -+ regmap = syscon_node_to_regmap(of_get_parent(np)); -+ if (IS_ERR(regmap)) -+ return; - - of_property_read_string(np, "clock-output-names", &name); - -- irq = irq_of_parse_and_map(np, 0); -- if (!irq) -- return; -- -- clk = at91_clk_register_sam9x5_main(pmc, irq, name, parent_names, -+ clk = at91_clk_register_sam9x5_main(regmap, name, parent_names, - num_parents); - if (IS_ERR(clk)) - return; - - of_clk_add_provider(np, of_clk_src_simple_get, clk); - } -+CLK_OF_DECLARE(at91sam9x5_clk_main, "atmel,at91sam9x5-clk-main", -+ of_at91sam9x5_clk_main_setup); -diff --git a/drivers/clk/at91/clk-master.c b/drivers/clk/at91/clk-master.c -index 620ea32..7d4a186 100644 ---- a/drivers/clk/at91/clk-master.c -+++ b/drivers/clk/at91/clk-master.c -@@ -12,13 +12,8 @@ - #include - #include - #include --#include --#include --#include --#include --#include --#include --#include -+#include -+#include - - #include "pmc.h" - -@@ -44,32 +39,26 @@ struct clk_master_layout { - - struct clk_master { - struct clk_hw hw; -- struct at91_pmc *pmc; -- unsigned int irq; -- wait_queue_head_t wait; -+ struct regmap *regmap; - const struct clk_master_layout *layout; - const struct clk_master_characteristics *characteristics; - }; - --static irqreturn_t clk_master_irq_handler(int irq, void *dev_id) -+static inline bool clk_master_ready(struct regmap *regmap) - { -- struct clk_master *master = (struct clk_master *)dev_id; -+ unsigned int status; - -- wake_up(&master->wait); -- disable_irq_nosync(master->irq); -+ regmap_read(regmap, AT91_PMC_SR, &status); - -- return IRQ_HANDLED; -+ return status & AT91_PMC_MCKRDY ? 1 : 0; - } -+ - static int clk_master_prepare(struct clk_hw *hw) - { - struct clk_master *master = to_clk_master(hw); -- struct at91_pmc *pmc = master->pmc; - -- while (!(pmc_read(pmc, AT91_PMC_SR) & AT91_PMC_MCKRDY)) { -- enable_irq(master->irq); -- wait_event(master->wait, -- pmc_read(pmc, AT91_PMC_SR) & AT91_PMC_MCKRDY); -- } -+ while (!clk_master_ready(master->regmap)) -+ cpu_relax(); - - return 0; - } -@@ -78,7 +67,7 @@ static int clk_master_is_prepared(struct clk_hw *hw) - { - struct clk_master *master = to_clk_master(hw); - -- return !!(pmc_read(master->pmc, AT91_PMC_SR) & AT91_PMC_MCKRDY); -+ return clk_master_ready(master->regmap); - } - - static unsigned long clk_master_recalc_rate(struct clk_hw *hw, -@@ -88,18 +77,16 @@ static unsigned long clk_master_recalc_rate(struct clk_hw *hw, - u8 div; - unsigned long rate = parent_rate; - struct clk_master *master = to_clk_master(hw); -- struct at91_pmc *pmc = master->pmc; - const struct clk_master_layout *layout = master->layout; - const struct clk_master_characteristics *characteristics = - master->characteristics; -- u32 tmp; -+ unsigned int mckr; - -- pmc_lock(pmc); -- tmp = pmc_read(pmc, AT91_PMC_MCKR) & layout->mask; -- pmc_unlock(pmc); -+ regmap_read(master->regmap, AT91_PMC_MCKR, &mckr); -+ mckr &= layout->mask; - -- pres = (tmp >> layout->pres_shift) & MASTER_PRES_MASK; -- div = (tmp >> MASTER_DIV_SHIFT) & MASTER_DIV_MASK; -+ pres = (mckr >> layout->pres_shift) & MASTER_PRES_MASK; -+ div = (mckr >> MASTER_DIV_SHIFT) & MASTER_DIV_MASK; - - if (characteristics->have_div3_pres && pres == MASTER_PRES_MAX) - rate /= 3; -@@ -119,9 +106,11 @@ static unsigned long clk_master_recalc_rate(struct clk_hw *hw, - static u8 clk_master_get_parent(struct clk_hw *hw) - { - struct clk_master *master = to_clk_master(hw); -- struct at91_pmc *pmc = master->pmc; -+ unsigned int mckr; - -- return pmc_read(pmc, AT91_PMC_MCKR) & AT91_PMC_CSS; -+ regmap_read(master->regmap, AT91_PMC_MCKR, &mckr); -+ -+ return mckr & AT91_PMC_CSS; - } - - static const struct clk_ops master_ops = { -@@ -132,18 +121,17 @@ static const struct clk_ops master_ops = { - }; - - static struct clk * __init --at91_clk_register_master(struct at91_pmc *pmc, unsigned int irq, -+at91_clk_register_master(struct regmap *regmap, - const char *name, int num_parents, - const char **parent_names, - const struct clk_master_layout *layout, - const struct clk_master_characteristics *characteristics) - { -- int ret; - struct clk_master *master; - struct clk *clk = NULL; - struct clk_init_data init; - -- if (!pmc || !irq || !name || !num_parents || !parent_names) -+ if (!name || !num_parents || !parent_names) - return ERR_PTR(-EINVAL); - - master = kzalloc(sizeof(*master), GFP_KERNEL); -@@ -159,20 +147,10 @@ at91_clk_register_master(struct at91_pmc *pmc, unsigned int irq, - master->hw.init = &init; - master->layout = layout; - master->characteristics = characteristics; -- master->pmc = pmc; -- master->irq = irq; -- init_waitqueue_head(&master->wait); -- irq_set_status_flags(master->irq, IRQ_NOAUTOEN); -- ret = request_irq(master->irq, clk_master_irq_handler, -- IRQF_TRIGGER_HIGH, "clk-master", master); -- if (ret) { -- kfree(master); -- return ERR_PTR(ret); -- } -+ master->regmap = regmap; - - clk = clk_register(NULL, &master->hw); - if (IS_ERR(clk)) { -- free_irq(master->irq, master); - kfree(master); - } - -@@ -217,15 +195,15 @@ out_free_characteristics: - } - - static void __init --of_at91_clk_master_setup(struct device_node *np, struct at91_pmc *pmc, -+of_at91_clk_master_setup(struct device_node *np, - const struct clk_master_layout *layout) - { - struct clk *clk; - int num_parents; -- unsigned int irq; - const char *parent_names[MASTER_SOURCE_MAX]; - const char *name = np->name; - struct clk_master_characteristics *characteristics; -+ struct regmap *regmap; - - num_parents = of_clk_get_parent_count(np); - if (num_parents <= 0 || num_parents > MASTER_SOURCE_MAX) -@@ -239,11 +217,11 @@ of_at91_clk_master_setup(struct device_node *np, struct at91_pmc *pmc, - if (!characteristics) - return; - -- irq = irq_of_parse_and_map(np, 0); -- if (!irq) -- goto out_free_characteristics; -+ regmap = syscon_node_to_regmap(of_get_parent(np)); -+ if (IS_ERR(regmap)) -+ return; - -- clk = at91_clk_register_master(pmc, irq, name, num_parents, -+ clk = at91_clk_register_master(regmap, name, num_parents, - parent_names, layout, - characteristics); - if (IS_ERR(clk)) -@@ -256,14 +234,16 @@ out_free_characteristics: - kfree(characteristics); - } - --void __init of_at91rm9200_clk_master_setup(struct device_node *np, -- struct at91_pmc *pmc) -+static void __init of_at91rm9200_clk_master_setup(struct device_node *np) - { -- of_at91_clk_master_setup(np, pmc, &at91rm9200_master_layout); -+ of_at91_clk_master_setup(np, &at91rm9200_master_layout); - } -+CLK_OF_DECLARE(at91rm9200_clk_master, "atmel,at91rm9200-clk-master", -+ of_at91rm9200_clk_master_setup); - --void __init of_at91sam9x5_clk_master_setup(struct device_node *np, -- struct at91_pmc *pmc) -+static void __init of_at91sam9x5_clk_master_setup(struct device_node *np) - { -- of_at91_clk_master_setup(np, pmc, &at91sam9x5_master_layout); -+ of_at91_clk_master_setup(np, &at91sam9x5_master_layout); - } -+CLK_OF_DECLARE(at91sam9x5_clk_master, "atmel,at91sam9x5-clk-master", -+ of_at91sam9x5_clk_master_setup); -diff --git a/drivers/clk/at91/clk-peripheral.c b/drivers/clk/at91/clk-peripheral.c -index 58f3b56..d69cd2a 100644 ---- a/drivers/clk/at91/clk-peripheral.c -+++ b/drivers/clk/at91/clk-peripheral.c -@@ -12,11 +12,13 @@ - #include - #include - #include --#include --#include -+#include -+#include - - #include "pmc.h" - -+DEFINE_SPINLOCK(pmc_pcr_lock); -+ - #define PERIPHERAL_MAX 64 - - #define PERIPHERAL_AT91RM9200 0 -@@ -33,7 +35,7 @@ - - struct clk_peripheral { - struct clk_hw hw; -- struct at91_pmc *pmc; -+ struct regmap *regmap; - u32 id; - }; - -@@ -41,8 +43,9 @@ struct clk_peripheral { - - struct clk_sam9x5_peripheral { - struct clk_hw hw; -- struct at91_pmc *pmc; -+ struct regmap *regmap; - struct clk_range range; -+ spinlock_t *lock; - u32 id; - u32 div; - bool auto_div; -@@ -54,7 +57,6 @@ struct clk_sam9x5_peripheral { - static int clk_peripheral_enable(struct clk_hw *hw) - { - struct clk_peripheral *periph = to_clk_peripheral(hw); -- struct at91_pmc *pmc = periph->pmc; - int offset = AT91_PMC_PCER; - u32 id = periph->id; - -@@ -62,14 +64,14 @@ static int clk_peripheral_enable(struct clk_hw *hw) - return 0; - if (id > PERIPHERAL_ID_MAX) - offset = AT91_PMC_PCER1; -- pmc_write(pmc, offset, PERIPHERAL_MASK(id)); -+ regmap_write(periph->regmap, offset, PERIPHERAL_MASK(id)); -+ - return 0; - } - - static void clk_peripheral_disable(struct clk_hw *hw) - { - struct clk_peripheral *periph = to_clk_peripheral(hw); -- struct at91_pmc *pmc = periph->pmc; - int offset = AT91_PMC_PCDR; - u32 id = periph->id; - -@@ -77,21 +79,23 @@ static void clk_peripheral_disable(struct clk_hw *hw) - return; - if (id > PERIPHERAL_ID_MAX) - offset = AT91_PMC_PCDR1; -- pmc_write(pmc, offset, PERIPHERAL_MASK(id)); -+ regmap_write(periph->regmap, offset, PERIPHERAL_MASK(id)); - } - - static int clk_peripheral_is_enabled(struct clk_hw *hw) - { - struct clk_peripheral *periph = to_clk_peripheral(hw); -- struct at91_pmc *pmc = periph->pmc; - int offset = AT91_PMC_PCSR; -+ unsigned int status; - u32 id = periph->id; - - if (id < PERIPHERAL_ID_MIN) - return 1; - if (id > PERIPHERAL_ID_MAX) - offset = AT91_PMC_PCSR1; -- return !!(pmc_read(pmc, offset) & PERIPHERAL_MASK(id)); -+ regmap_read(periph->regmap, offset, &status); -+ -+ return status & PERIPHERAL_MASK(id) ? 1 : 0; - } - - static const struct clk_ops peripheral_ops = { -@@ -101,14 +105,14 @@ static const struct clk_ops peripheral_ops = { - }; - - static struct clk * __init --at91_clk_register_peripheral(struct at91_pmc *pmc, const char *name, -+at91_clk_register_peripheral(struct regmap *regmap, const char *name, - const char *parent_name, u32 id) - { - struct clk_peripheral *periph; - struct clk *clk = NULL; - struct clk_init_data init; - -- if (!pmc || !name || !parent_name || id > PERIPHERAL_ID_MAX) -+ if (!name || !parent_name || id > PERIPHERAL_ID_MAX) - return ERR_PTR(-EINVAL); - - periph = kzalloc(sizeof(*periph), GFP_KERNEL); -@@ -123,7 +127,7 @@ at91_clk_register_peripheral(struct at91_pmc *pmc, const char *name, - - periph->id = id; - periph->hw.init = &init; -- periph->pmc = pmc; -+ periph->regmap = regmap; - - clk = clk_register(NULL, &periph->hw); - if (IS_ERR(clk)) -@@ -160,53 +164,58 @@ static void clk_sam9x5_peripheral_autodiv(struct clk_sam9x5_peripheral *periph) - static int clk_sam9x5_peripheral_enable(struct clk_hw *hw) - { - struct clk_sam9x5_peripheral *periph = to_clk_sam9x5_peripheral(hw); -- struct at91_pmc *pmc = periph->pmc; -- u32 tmp; -+ unsigned long flags; - - if (periph->id < PERIPHERAL_ID_MIN) - return 0; - -- pmc_lock(pmc); -- pmc_write(pmc, AT91_PMC_PCR, (periph->id & AT91_PMC_PCR_PID_MASK)); -- tmp = pmc_read(pmc, AT91_PMC_PCR) & ~AT91_PMC_PCR_DIV_MASK; -- pmc_write(pmc, AT91_PMC_PCR, tmp | AT91_PMC_PCR_DIV(periph->div) -- | AT91_PMC_PCR_CMD -- | AT91_PMC_PCR_EN); -- pmc_unlock(pmc); -+ spin_lock_irqsave(periph->lock, flags); -+ regmap_write(periph->regmap, AT91_PMC_PCR, -+ (periph->id & AT91_PMC_PCR_PID_MASK)); -+ regmap_update_bits(periph->regmap, AT91_PMC_PCR, -+ AT91_PMC_PCR_DIV_MASK | AT91_PMC_PCR_CMD | -+ AT91_PMC_PCR_EN, -+ AT91_PMC_PCR_DIV(periph->div) | -+ AT91_PMC_PCR_CMD | -+ AT91_PMC_PCR_EN); -+ spin_unlock_irqrestore(periph->lock, flags); -+ - return 0; - } - - static void clk_sam9x5_peripheral_disable(struct clk_hw *hw) - { - struct clk_sam9x5_peripheral *periph = to_clk_sam9x5_peripheral(hw); -- struct at91_pmc *pmc = periph->pmc; -- u32 tmp; -+ unsigned long flags; - - if (periph->id < PERIPHERAL_ID_MIN) - return; - -- pmc_lock(pmc); -- pmc_write(pmc, AT91_PMC_PCR, (periph->id & AT91_PMC_PCR_PID_MASK)); -- tmp = pmc_read(pmc, AT91_PMC_PCR) & ~AT91_PMC_PCR_EN; -- pmc_write(pmc, AT91_PMC_PCR, tmp | AT91_PMC_PCR_CMD); -- pmc_unlock(pmc); -+ spin_lock_irqsave(periph->lock, flags); -+ regmap_write(periph->regmap, AT91_PMC_PCR, -+ (periph->id & AT91_PMC_PCR_PID_MASK)); -+ regmap_update_bits(periph->regmap, AT91_PMC_PCR, -+ AT91_PMC_PCR_EN | AT91_PMC_PCR_CMD, -+ AT91_PMC_PCR_CMD); -+ spin_unlock_irqrestore(periph->lock, flags); - } - - static int clk_sam9x5_peripheral_is_enabled(struct clk_hw *hw) - { - struct clk_sam9x5_peripheral *periph = to_clk_sam9x5_peripheral(hw); -- struct at91_pmc *pmc = periph->pmc; -- int ret; -+ unsigned long flags; -+ unsigned int status; - - if (periph->id < PERIPHERAL_ID_MIN) - return 1; - -- pmc_lock(pmc); -- pmc_write(pmc, AT91_PMC_PCR, (periph->id & AT91_PMC_PCR_PID_MASK)); -- ret = !!(pmc_read(pmc, AT91_PMC_PCR) & AT91_PMC_PCR_EN); -- pmc_unlock(pmc); -+ spin_lock_irqsave(periph->lock, flags); -+ regmap_write(periph->regmap, AT91_PMC_PCR, -+ (periph->id & AT91_PMC_PCR_PID_MASK)); -+ regmap_read(periph->regmap, AT91_PMC_PCR, &status); -+ spin_unlock_irqrestore(periph->lock, flags); - -- return ret; -+ return status & AT91_PMC_PCR_EN ? 1 : 0; - } - - static unsigned long -@@ -214,19 +223,20 @@ clk_sam9x5_peripheral_recalc_rate(struct clk_hw *hw, - unsigned long parent_rate) - { - struct clk_sam9x5_peripheral *periph = to_clk_sam9x5_peripheral(hw); -- struct at91_pmc *pmc = periph->pmc; -- u32 tmp; -+ unsigned long flags; -+ unsigned int status; - - if (periph->id < PERIPHERAL_ID_MIN) - return parent_rate; - -- pmc_lock(pmc); -- pmc_write(pmc, AT91_PMC_PCR, (periph->id & AT91_PMC_PCR_PID_MASK)); -- tmp = pmc_read(pmc, AT91_PMC_PCR); -- pmc_unlock(pmc); -+ spin_lock_irqsave(periph->lock, flags); -+ regmap_write(periph->regmap, AT91_PMC_PCR, -+ (periph->id & AT91_PMC_PCR_PID_MASK)); -+ regmap_read(periph->regmap, AT91_PMC_PCR, &status); -+ spin_unlock_irqrestore(periph->lock, flags); - -- if (tmp & AT91_PMC_PCR_EN) { -- periph->div = PERIPHERAL_RSHIFT(tmp); -+ if (status & AT91_PMC_PCR_EN) { -+ periph->div = PERIPHERAL_RSHIFT(status); - periph->auto_div = false; - } else { - clk_sam9x5_peripheral_autodiv(periph); -@@ -318,15 +328,15 @@ static const struct clk_ops sam9x5_peripheral_ops = { - }; - - static struct clk * __init --at91_clk_register_sam9x5_peripheral(struct at91_pmc *pmc, const char *name, -- const char *parent_name, u32 id, -- const struct clk_range *range) -+at91_clk_register_sam9x5_peripheral(struct regmap *regmap, spinlock_t *lock, -+ const char *name, const char *parent_name, -+ u32 id, const struct clk_range *range) - { - struct clk_sam9x5_peripheral *periph; - struct clk *clk = NULL; - struct clk_init_data init; - -- if (!pmc || !name || !parent_name) -+ if (!name || !parent_name) - return ERR_PTR(-EINVAL); - - periph = kzalloc(sizeof(*periph), GFP_KERNEL); -@@ -342,7 +352,8 @@ at91_clk_register_sam9x5_peripheral(struct at91_pmc *pmc, const char *name, - periph->id = id; - periph->hw.init = &init; - periph->div = 0; -- periph->pmc = pmc; -+ periph->regmap = regmap; -+ periph->lock = lock; - periph->auto_div = true; - periph->range = *range; - -@@ -356,7 +367,7 @@ at91_clk_register_sam9x5_peripheral(struct at91_pmc *pmc, const char *name, - } - - static void __init --of_at91_clk_periph_setup(struct device_node *np, struct at91_pmc *pmc, u8 type) -+of_at91_clk_periph_setup(struct device_node *np, u8 type) - { - int num; - u32 id; -@@ -364,6 +375,7 @@ of_at91_clk_periph_setup(struct device_node *np, struct at91_pmc *pmc, u8 type) - const char *parent_name; - const char *name; - struct device_node *periphclknp; -+ struct regmap *regmap; - - parent_name = of_clk_get_parent_name(np, 0); - if (!parent_name) -@@ -373,6 +385,10 @@ of_at91_clk_periph_setup(struct device_node *np, struct at91_pmc *pmc, u8 type) - if (!num || num > PERIPHERAL_MAX) - return; - -+ regmap = syscon_node_to_regmap(of_get_parent(np)); -+ if (IS_ERR(regmap)) -+ return; -+ - for_each_child_of_node(np, periphclknp) { - if (of_property_read_u32(periphclknp, "reg", &id)) - continue; -@@ -384,7 +400,7 @@ of_at91_clk_periph_setup(struct device_node *np, struct at91_pmc *pmc, u8 type) - name = periphclknp->name; - - if (type == PERIPHERAL_AT91RM9200) { -- clk = at91_clk_register_peripheral(pmc, name, -+ clk = at91_clk_register_peripheral(regmap, name, - parent_name, id); - } else { - struct clk_range range = CLK_RANGE(0, 0); -@@ -393,7 +409,9 @@ of_at91_clk_periph_setup(struct device_node *np, struct at91_pmc *pmc, u8 type) - "atmel,clk-output-range", - &range); - -- clk = at91_clk_register_sam9x5_peripheral(pmc, name, -+ clk = at91_clk_register_sam9x5_peripheral(regmap, -+ &pmc_pcr_lock, -+ name, - parent_name, - id, &range); - } -@@ -405,14 +423,16 @@ of_at91_clk_periph_setup(struct device_node *np, struct at91_pmc *pmc, u8 type) - } - } - --void __init of_at91rm9200_clk_periph_setup(struct device_node *np, -- struct at91_pmc *pmc) -+static void __init of_at91rm9200_clk_periph_setup(struct device_node *np) - { -- of_at91_clk_periph_setup(np, pmc, PERIPHERAL_AT91RM9200); -+ of_at91_clk_periph_setup(np, PERIPHERAL_AT91RM9200); - } -+CLK_OF_DECLARE(at91rm9200_clk_periph, "atmel,at91rm9200-clk-peripheral", -+ of_at91rm9200_clk_periph_setup); - --void __init of_at91sam9x5_clk_periph_setup(struct device_node *np, -- struct at91_pmc *pmc) -+static void __init of_at91sam9x5_clk_periph_setup(struct device_node *np) - { -- of_at91_clk_periph_setup(np, pmc, PERIPHERAL_AT91SAM9X5); -+ of_at91_clk_periph_setup(np, PERIPHERAL_AT91SAM9X5); - } -+CLK_OF_DECLARE(at91sam9x5_clk_periph, "atmel,at91sam9x5-clk-peripheral", -+ of_at91sam9x5_clk_periph_setup); -diff --git a/drivers/clk/at91/clk-pll.c b/drivers/clk/at91/clk-pll.c -index 18b60f4..fb2e0b5 100644 ---- a/drivers/clk/at91/clk-pll.c -+++ b/drivers/clk/at91/clk-pll.c -@@ -12,14 +12,8 @@ - #include - #include - #include --#include --#include --#include --#include --#include --#include --#include --#include -+#include -+#include - - #include "pmc.h" - -@@ -58,9 +52,7 @@ struct clk_pll_layout { - - struct clk_pll { - struct clk_hw hw; -- struct at91_pmc *pmc; -- unsigned int irq; -- wait_queue_head_t wait; -+ struct regmap *regmap; - u8 id; - u8 div; - u8 range; -@@ -69,20 +61,19 @@ struct clk_pll { - const struct clk_pll_characteristics *characteristics; - }; - --static irqreturn_t clk_pll_irq_handler(int irq, void *dev_id) -+static inline bool clk_pll_ready(struct regmap *regmap, int id) - { -- struct clk_pll *pll = (struct clk_pll *)dev_id; -+ unsigned int status; - -- wake_up(&pll->wait); -- disable_irq_nosync(pll->irq); -+ regmap_read(regmap, AT91_PMC_SR, &status); - -- return IRQ_HANDLED; -+ return status & PLL_STATUS_MASK(id) ? 1 : 0; - } - - static int clk_pll_prepare(struct clk_hw *hw) - { - struct clk_pll *pll = to_clk_pll(hw); -- struct at91_pmc *pmc = pll->pmc; -+ struct regmap *regmap = pll->regmap; - const struct clk_pll_layout *layout = pll->layout; - const struct clk_pll_characteristics *characteristics = - pll->characteristics; -@@ -90,39 +81,34 @@ static int clk_pll_prepare(struct clk_hw *hw) - u32 mask = PLL_STATUS_MASK(id); - int offset = PLL_REG(id); - u8 out = 0; -- u32 pllr, icpr; -+ unsigned int pllr; -+ unsigned int status; - u8 div; - u16 mul; - -- pllr = pmc_read(pmc, offset); -+ regmap_read(regmap, offset, &pllr); - div = PLL_DIV(pllr); - mul = PLL_MUL(pllr, layout); - -- if ((pmc_read(pmc, AT91_PMC_SR) & mask) && -+ regmap_read(regmap, AT91_PMC_SR, &status); -+ if ((status & mask) && - (div == pll->div && mul == pll->mul)) - return 0; - - if (characteristics->out) - out = characteristics->out[pll->range]; -- if (characteristics->icpll) { -- icpr = pmc_read(pmc, AT91_PMC_PLLICPR) & ~PLL_ICPR_MASK(id); -- icpr |= (characteristics->icpll[pll->range] << -- PLL_ICPR_SHIFT(id)); -- pmc_write(pmc, AT91_PMC_PLLICPR, icpr); -- } - -- pllr &= ~layout->pllr_mask; -- pllr |= layout->pllr_mask & -- (pll->div | (PLL_MAX_COUNT << PLL_COUNT_SHIFT) | -- (out << PLL_OUT_SHIFT) | -- ((pll->mul & layout->mul_mask) << layout->mul_shift)); -- pmc_write(pmc, offset, pllr); -- -- while (!(pmc_read(pmc, AT91_PMC_SR) & mask)) { -- enable_irq(pll->irq); -- wait_event(pll->wait, -- pmc_read(pmc, AT91_PMC_SR) & mask); -- } -+ if (characteristics->icpll) -+ regmap_update_bits(regmap, AT91_PMC_PLLICPR, PLL_ICPR_MASK(id), -+ characteristics->icpll[pll->range] << PLL_ICPR_SHIFT(id)); -+ -+ regmap_update_bits(regmap, offset, layout->pllr_mask, -+ pll->div | (PLL_MAX_COUNT << PLL_COUNT_SHIFT) | -+ (out << PLL_OUT_SHIFT) | -+ ((pll->mul & layout->mul_mask) << layout->mul_shift)); -+ -+ while (!clk_pll_ready(regmap, pll->id)) -+ cpu_relax(); - - return 0; - } -@@ -130,32 +116,35 @@ static int clk_pll_prepare(struct clk_hw *hw) - static int clk_pll_is_prepared(struct clk_hw *hw) - { - struct clk_pll *pll = to_clk_pll(hw); -- struct at91_pmc *pmc = pll->pmc; - -- return !!(pmc_read(pmc, AT91_PMC_SR) & -- PLL_STATUS_MASK(pll->id)); -+ return clk_pll_ready(pll->regmap, pll->id); - } - - static void clk_pll_unprepare(struct clk_hw *hw) - { - struct clk_pll *pll = to_clk_pll(hw); -- struct at91_pmc *pmc = pll->pmc; -- const struct clk_pll_layout *layout = pll->layout; -- int offset = PLL_REG(pll->id); -- u32 tmp = pmc_read(pmc, offset) & ~(layout->pllr_mask); -+ unsigned int mask = pll->layout->pllr_mask; - -- pmc_write(pmc, offset, tmp); -+ regmap_update_bits(pll->regmap, PLL_REG(pll->id), mask, ~mask); - } - - static unsigned long clk_pll_recalc_rate(struct clk_hw *hw, - unsigned long parent_rate) - { - struct clk_pll *pll = to_clk_pll(hw); -+ unsigned int pllr; -+ u16 mul; -+ u8 div; - -- if (!pll->div || !pll->mul) -+ regmap_read(pll->regmap, PLL_REG(pll->id), &pllr); -+ -+ div = PLL_DIV(pllr); -+ mul = PLL_MUL(pllr, pll->layout); -+ -+ if (!div || !mul) - return 0; - -- return (parent_rate / pll->div) * (pll->mul + 1); -+ return (parent_rate / div) * (mul + 1); - } - - static long clk_pll_get_best_div_mul(struct clk_pll *pll, unsigned long rate, -@@ -308,7 +297,7 @@ static const struct clk_ops pll_ops = { - }; - - static struct clk * __init --at91_clk_register_pll(struct at91_pmc *pmc, unsigned int irq, const char *name, -+at91_clk_register_pll(struct regmap *regmap, const char *name, - const char *parent_name, u8 id, - const struct clk_pll_layout *layout, - const struct clk_pll_characteristics *characteristics) -@@ -316,9 +305,8 @@ at91_clk_register_pll(struct at91_pmc *pmc, unsigned int irq, const char *name, - struct clk_pll *pll; - struct clk *clk = NULL; - struct clk_init_data init; -- int ret; - int offset = PLL_REG(id); -- u32 tmp; -+ unsigned int pllr; - - if (id > PLL_MAX_ID) - return ERR_PTR(-EINVAL); -@@ -337,23 +325,13 @@ at91_clk_register_pll(struct at91_pmc *pmc, unsigned int irq, const char *name, - pll->hw.init = &init; - pll->layout = layout; - pll->characteristics = characteristics; -- pll->pmc = pmc; -- pll->irq = irq; -- tmp = pmc_read(pmc, offset) & layout->pllr_mask; -- pll->div = PLL_DIV(tmp); -- pll->mul = PLL_MUL(tmp, layout); -- init_waitqueue_head(&pll->wait); -- irq_set_status_flags(pll->irq, IRQ_NOAUTOEN); -- ret = request_irq(pll->irq, clk_pll_irq_handler, IRQF_TRIGGER_HIGH, -- id ? "clk-pllb" : "clk-plla", pll); -- if (ret) { -- kfree(pll); -- return ERR_PTR(ret); -- } -+ pll->regmap = regmap; -+ regmap_read(regmap, offset, &pllr); -+ pll->div = PLL_DIV(pllr); -+ pll->mul = PLL_MUL(pllr, layout); - - clk = clk_register(NULL, &pll->hw); - if (IS_ERR(clk)) { -- free_irq(pll->irq, pll); - kfree(pll); - } - -@@ -483,12 +461,12 @@ out_free_characteristics: - } - - static void __init --of_at91_clk_pll_setup(struct device_node *np, struct at91_pmc *pmc, -+of_at91_clk_pll_setup(struct device_node *np, - const struct clk_pll_layout *layout) - { - u32 id; -- unsigned int irq; - struct clk *clk; -+ struct regmap *regmap; - const char *parent_name; - const char *name = np->name; - struct clk_pll_characteristics *characteristics; -@@ -500,15 +478,15 @@ of_at91_clk_pll_setup(struct device_node *np, struct at91_pmc *pmc, - - of_property_read_string(np, "clock-output-names", &name); - -- characteristics = of_at91_clk_pll_get_characteristics(np); -- if (!characteristics) -+ regmap = syscon_node_to_regmap(of_get_parent(np)); -+ if (IS_ERR(regmap)) - return; - -- irq = irq_of_parse_and_map(np, 0); -- if (!irq) -+ characteristics = of_at91_clk_pll_get_characteristics(np); -+ if (!characteristics) - return; - -- clk = at91_clk_register_pll(pmc, irq, name, parent_name, id, layout, -+ clk = at91_clk_register_pll(regmap, name, parent_name, id, layout, - characteristics); - if (IS_ERR(clk)) - goto out_free_characteristics; -@@ -520,26 +498,30 @@ out_free_characteristics: - kfree(characteristics); - } - --void __init of_at91rm9200_clk_pll_setup(struct device_node *np, -- struct at91_pmc *pmc) -+static void __init of_at91rm9200_clk_pll_setup(struct device_node *np) - { -- of_at91_clk_pll_setup(np, pmc, &at91rm9200_pll_layout); -+ of_at91_clk_pll_setup(np, &at91rm9200_pll_layout); - } -+CLK_OF_DECLARE(at91rm9200_clk_pll, "atmel,at91rm9200-clk-pll", -+ of_at91rm9200_clk_pll_setup); - --void __init of_at91sam9g45_clk_pll_setup(struct device_node *np, -- struct at91_pmc *pmc) -+static void __init of_at91sam9g45_clk_pll_setup(struct device_node *np) - { -- of_at91_clk_pll_setup(np, pmc, &at91sam9g45_pll_layout); -+ of_at91_clk_pll_setup(np, &at91sam9g45_pll_layout); - } -+CLK_OF_DECLARE(at91sam9g45_clk_pll, "atmel,at91sam9g45-clk-pll", -+ of_at91sam9g45_clk_pll_setup); - --void __init of_at91sam9g20_clk_pllb_setup(struct device_node *np, -- struct at91_pmc *pmc) -+static void __init of_at91sam9g20_clk_pllb_setup(struct device_node *np) - { -- of_at91_clk_pll_setup(np, pmc, &at91sam9g20_pllb_layout); -+ of_at91_clk_pll_setup(np, &at91sam9g20_pllb_layout); - } -+CLK_OF_DECLARE(at91sam9g20_clk_pllb, "atmel,at91sam9g20-clk-pllb", -+ of_at91sam9g20_clk_pllb_setup); - --void __init of_sama5d3_clk_pll_setup(struct device_node *np, -- struct at91_pmc *pmc) -+static void __init of_sama5d3_clk_pll_setup(struct device_node *np) - { -- of_at91_clk_pll_setup(np, pmc, &sama5d3_pll_layout); -+ of_at91_clk_pll_setup(np, &sama5d3_pll_layout); - } -+CLK_OF_DECLARE(sama5d3_clk_pll, "atmel,sama5d3-clk-pll", -+ of_sama5d3_clk_pll_setup); -diff --git a/drivers/clk/at91/clk-plldiv.c b/drivers/clk/at91/clk-plldiv.c -index ea22656..2bed264 100644 ---- a/drivers/clk/at91/clk-plldiv.c -+++ b/drivers/clk/at91/clk-plldiv.c -@@ -12,8 +12,8 @@ - #include - #include - #include --#include --#include -+#include -+#include - - #include "pmc.h" - -@@ -21,16 +21,18 @@ - - struct clk_plldiv { - struct clk_hw hw; -- struct at91_pmc *pmc; -+ struct regmap *regmap; - }; - - static unsigned long clk_plldiv_recalc_rate(struct clk_hw *hw, - unsigned long parent_rate) - { - struct clk_plldiv *plldiv = to_clk_plldiv(hw); -- struct at91_pmc *pmc = plldiv->pmc; -+ unsigned int mckr; - -- if (pmc_read(pmc, AT91_PMC_MCKR) & AT91_PMC_PLLADIV2) -+ regmap_read(plldiv->regmap, AT91_PMC_MCKR, &mckr); -+ -+ if (mckr & AT91_PMC_PLLADIV2) - return parent_rate / 2; - - return parent_rate; -@@ -57,18 +59,12 @@ static int clk_plldiv_set_rate(struct clk_hw *hw, unsigned long rate, - unsigned long parent_rate) - { - struct clk_plldiv *plldiv = to_clk_plldiv(hw); -- struct at91_pmc *pmc = plldiv->pmc; -- u32 tmp; - -- if (parent_rate != rate && (parent_rate / 2) != rate) -+ if ((parent_rate != rate) && (parent_rate / 2 != rate)) - return -EINVAL; - -- pmc_lock(pmc); -- tmp = pmc_read(pmc, AT91_PMC_MCKR) & ~AT91_PMC_PLLADIV2; -- if ((parent_rate / 2) == rate) -- tmp |= AT91_PMC_PLLADIV2; -- pmc_write(pmc, AT91_PMC_MCKR, tmp); -- pmc_unlock(pmc); -+ regmap_update_bits(plldiv->regmap, AT91_PMC_MCKR, AT91_PMC_PLLADIV2, -+ parent_rate != rate ? AT91_PMC_PLLADIV2 : 0); - - return 0; - } -@@ -80,7 +76,7 @@ static const struct clk_ops plldiv_ops = { - }; - - static struct clk * __init --at91_clk_register_plldiv(struct at91_pmc *pmc, const char *name, -+at91_clk_register_plldiv(struct regmap *regmap, const char *name, - const char *parent_name) - { - struct clk_plldiv *plldiv; -@@ -98,7 +94,7 @@ at91_clk_register_plldiv(struct at91_pmc *pmc, const char *name, - init.flags = CLK_SET_RATE_GATE; - - plldiv->hw.init = &init; -- plldiv->pmc = pmc; -+ plldiv->regmap = regmap; - - clk = clk_register(NULL, &plldiv->hw); - -@@ -109,27 +105,27 @@ at91_clk_register_plldiv(struct at91_pmc *pmc, const char *name, - } - - static void __init --of_at91_clk_plldiv_setup(struct device_node *np, struct at91_pmc *pmc) -+of_at91sam9x5_clk_plldiv_setup(struct device_node *np) - { - struct clk *clk; - const char *parent_name; - const char *name = np->name; -+ struct regmap *regmap; - - parent_name = of_clk_get_parent_name(np, 0); - - of_property_read_string(np, "clock-output-names", &name); - -- clk = at91_clk_register_plldiv(pmc, name, parent_name); -+ regmap = syscon_node_to_regmap(of_get_parent(np)); -+ if (IS_ERR(regmap)) -+ return; - -+ clk = at91_clk_register_plldiv(regmap, name, parent_name); - if (IS_ERR(clk)) - return; - - of_clk_add_provider(np, of_clk_src_simple_get, clk); - return; - } -- --void __init of_at91sam9x5_clk_plldiv_setup(struct device_node *np, -- struct at91_pmc *pmc) --{ -- of_at91_clk_plldiv_setup(np, pmc); --} -+CLK_OF_DECLARE(at91sam9x5_clk_plldiv, "atmel,at91sam9x5-clk-plldiv", -+ of_at91sam9x5_clk_plldiv_setup); -diff --git a/drivers/clk/at91/clk-programmable.c b/drivers/clk/at91/clk-programmable.c -index 14b270b..bc0be62 100644 ---- a/drivers/clk/at91/clk-programmable.c -+++ b/drivers/clk/at91/clk-programmable.c -@@ -12,10 +12,8 @@ - #include - #include - #include --#include --#include --#include --#include -+#include -+#include - - #include "pmc.h" - -@@ -24,6 +22,7 @@ - - #define PROG_STATUS_MASK(id) (1 << ((id) + 8)) - #define PROG_PRES_MASK 0x7 -+#define PROG_PRES(layout, pckr) ((pckr >> layout->pres_shift) & PROG_PRES_MASK) - #define PROG_MAX_RM9200_CSS 3 - - struct clk_programmable_layout { -@@ -34,7 +33,7 @@ struct clk_programmable_layout { - - struct clk_programmable { - struct clk_hw hw; -- struct at91_pmc *pmc; -+ struct regmap *regmap; - u8 id; - const struct clk_programmable_layout *layout; - }; -@@ -44,14 +43,12 @@ struct clk_programmable { - static unsigned long clk_programmable_recalc_rate(struct clk_hw *hw, - unsigned long parent_rate) - { -- u32 pres; - struct clk_programmable *prog = to_clk_programmable(hw); -- struct at91_pmc *pmc = prog->pmc; -- const struct clk_programmable_layout *layout = prog->layout; -+ unsigned int pckr; -+ -+ regmap_read(prog->regmap, AT91_PMC_PCKR(prog->id), &pckr); - -- pres = (pmc_read(pmc, AT91_PMC_PCKR(prog->id)) >> layout->pres_shift) & -- PROG_PRES_MASK; -- return parent_rate >> pres; -+ return parent_rate >> PROG_PRES(prog->layout, pckr); - } - - static int clk_programmable_determine_rate(struct clk_hw *hw, -@@ -101,36 +98,36 @@ static int clk_programmable_set_parent(struct clk_hw *hw, u8 index) - { - struct clk_programmable *prog = to_clk_programmable(hw); - const struct clk_programmable_layout *layout = prog->layout; -- struct at91_pmc *pmc = prog->pmc; -- u32 tmp = pmc_read(pmc, AT91_PMC_PCKR(prog->id)) & ~layout->css_mask; -+ unsigned int mask = layout->css_mask; -+ unsigned int pckr = 0; - - if (layout->have_slck_mck) -- tmp &= AT91_PMC_CSSMCK_MCK; -+ mask |= AT91_PMC_CSSMCK_MCK; - - if (index > layout->css_mask) { -- if (index > PROG_MAX_RM9200_CSS && layout->have_slck_mck) { -- tmp |= AT91_PMC_CSSMCK_MCK; -- return 0; -- } else { -+ if (index > PROG_MAX_RM9200_CSS && !layout->have_slck_mck) - return -EINVAL; -- } -+ -+ pckr |= AT91_PMC_CSSMCK_MCK; - } - -- pmc_write(pmc, AT91_PMC_PCKR(prog->id), tmp | index); -+ regmap_update_bits(prog->regmap, AT91_PMC_PCKR(prog->id), mask, pckr); -+ - return 0; - } - - static u8 clk_programmable_get_parent(struct clk_hw *hw) - { -- u32 tmp; -- u8 ret; - struct clk_programmable *prog = to_clk_programmable(hw); -- struct at91_pmc *pmc = prog->pmc; - const struct clk_programmable_layout *layout = prog->layout; -+ unsigned int pckr; -+ u8 ret; -+ -+ regmap_read(prog->regmap, AT91_PMC_PCKR(prog->id), &pckr); -+ -+ ret = pckr & layout->css_mask; - -- tmp = pmc_read(pmc, AT91_PMC_PCKR(prog->id)); -- ret = tmp & layout->css_mask; -- if (layout->have_slck_mck && (tmp & AT91_PMC_CSSMCK_MCK) && !ret) -+ if (layout->have_slck_mck && (pckr & AT91_PMC_CSSMCK_MCK) && !ret) - ret = PROG_MAX_RM9200_CSS + 1; - - return ret; -@@ -140,26 +137,27 @@ static int clk_programmable_set_rate(struct clk_hw *hw, unsigned long rate, - unsigned long parent_rate) - { - struct clk_programmable *prog = to_clk_programmable(hw); -- struct at91_pmc *pmc = prog->pmc; - const struct clk_programmable_layout *layout = prog->layout; - unsigned long div = parent_rate / rate; -+ unsigned int pckr; - int shift = 0; -- u32 tmp = pmc_read(pmc, AT91_PMC_PCKR(prog->id)) & -- ~(PROG_PRES_MASK << layout->pres_shift); -+ -+ regmap_read(prog->regmap, AT91_PMC_PCKR(prog->id), &pckr); - - if (!div) - return -EINVAL; - - shift = fls(div) - 1; - -- if (div != (1<= PROG_PRES_MASK) - return -EINVAL; - -- pmc_write(pmc, AT91_PMC_PCKR(prog->id), -- tmp | (shift << layout->pres_shift)); -+ regmap_update_bits(prog->regmap, AT91_PMC_PCKR(prog->id), -+ PROG_PRES_MASK << layout->pres_shift, -+ shift << layout->pres_shift); - - return 0; - } -@@ -173,7 +171,7 @@ static const struct clk_ops programmable_ops = { - }; - - static struct clk * __init --at91_clk_register_programmable(struct at91_pmc *pmc, -+at91_clk_register_programmable(struct regmap *regmap, - const char *name, const char **parent_names, - u8 num_parents, u8 id, - const struct clk_programmable_layout *layout) -@@ -198,7 +196,7 @@ at91_clk_register_programmable(struct at91_pmc *pmc, - prog->id = id; - prog->layout = layout; - prog->hw.init = &init; -- prog->pmc = pmc; -+ prog->regmap = regmap; - - clk = clk_register(NULL, &prog->hw); - if (IS_ERR(clk)) -@@ -226,7 +224,7 @@ static const struct clk_programmable_layout at91sam9x5_programmable_layout = { - }; - - static void __init --of_at91_clk_prog_setup(struct device_node *np, struct at91_pmc *pmc, -+of_at91_clk_prog_setup(struct device_node *np, - const struct clk_programmable_layout *layout) - { - int num; -@@ -236,6 +234,7 @@ of_at91_clk_prog_setup(struct device_node *np, struct at91_pmc *pmc, - const char *parent_names[PROG_SOURCE_MAX]; - const char *name; - struct device_node *progclknp; -+ struct regmap *regmap; - - num_parents = of_clk_get_parent_count(np); - if (num_parents <= 0 || num_parents > PROG_SOURCE_MAX) -@@ -247,6 +246,10 @@ of_at91_clk_prog_setup(struct device_node *np, struct at91_pmc *pmc, - if (!num || num > (PROG_ID_MAX + 1)) - return; - -+ regmap = syscon_node_to_regmap(of_get_parent(np)); -+ if (IS_ERR(regmap)) -+ return; -+ - for_each_child_of_node(np, progclknp) { - if (of_property_read_u32(progclknp, "reg", &id)) - continue; -@@ -254,7 +257,7 @@ of_at91_clk_prog_setup(struct device_node *np, struct at91_pmc *pmc, - if (of_property_read_string(np, "clock-output-names", &name)) - name = progclknp->name; - -- clk = at91_clk_register_programmable(pmc, name, -+ clk = at91_clk_register_programmable(regmap, name, - parent_names, num_parents, - id, layout); - if (IS_ERR(clk)) -@@ -265,20 +268,23 @@ of_at91_clk_prog_setup(struct device_node *np, struct at91_pmc *pmc, - } - - --void __init of_at91rm9200_clk_prog_setup(struct device_node *np, -- struct at91_pmc *pmc) -+static void __init of_at91rm9200_clk_prog_setup(struct device_node *np) - { -- of_at91_clk_prog_setup(np, pmc, &at91rm9200_programmable_layout); -+ of_at91_clk_prog_setup(np, &at91rm9200_programmable_layout); - } -+CLK_OF_DECLARE(at91rm9200_clk_prog, "atmel,at91rm9200-clk-programmable", -+ of_at91rm9200_clk_prog_setup); - --void __init of_at91sam9g45_clk_prog_setup(struct device_node *np, -- struct at91_pmc *pmc) -+static void __init of_at91sam9g45_clk_prog_setup(struct device_node *np) - { -- of_at91_clk_prog_setup(np, pmc, &at91sam9g45_programmable_layout); -+ of_at91_clk_prog_setup(np, &at91sam9g45_programmable_layout); - } -+CLK_OF_DECLARE(at91sam9g45_clk_prog, "atmel,at91sam9g45-clk-programmable", -+ of_at91sam9g45_clk_prog_setup); - --void __init of_at91sam9x5_clk_prog_setup(struct device_node *np, -- struct at91_pmc *pmc) -+static void __init of_at91sam9x5_clk_prog_setup(struct device_node *np) - { -- of_at91_clk_prog_setup(np, pmc, &at91sam9x5_programmable_layout); -+ of_at91_clk_prog_setup(np, &at91sam9x5_programmable_layout); - } -+CLK_OF_DECLARE(at91sam9x5_clk_prog, "atmel,at91sam9x5-clk-programmable", -+ of_at91sam9x5_clk_prog_setup); -diff --git a/drivers/clk/at91/clk-slow.c b/drivers/clk/at91/clk-slow.c -index d0d5076..221c096 100644 ---- a/drivers/clk/at91/clk-slow.c -+++ b/drivers/clk/at91/clk-slow.c -@@ -13,17 +13,11 @@ - #include - #include - #include --#include - #include - #include - #include --#include --#include --#include --#include --#include --#include --#include -+#include -+#include - - #include "pmc.h" - #include "sckc.h" -@@ -59,7 +53,7 @@ struct clk_slow_rc_osc { - - struct clk_sam9260_slow { - struct clk_hw hw; -- struct at91_pmc *pmc; -+ struct regmap *regmap; - }; - - #define to_clk_sam9260_slow(hw) container_of(hw, struct clk_sam9260_slow, hw) -@@ -393,8 +387,11 @@ void __init of_at91sam9x5_clk_slow_setup(struct device_node *np, - static u8 clk_sam9260_slow_get_parent(struct clk_hw *hw) - { - struct clk_sam9260_slow *slowck = to_clk_sam9260_slow(hw); -+ unsigned int status; - -- return !!(pmc_read(slowck->pmc, AT91_PMC_SR) & AT91_PMC_OSCSEL); -+ regmap_read(slowck->regmap, AT91_PMC_SR, &status); -+ -+ return status & AT91_PMC_OSCSEL ? 1 : 0; - } - - static const struct clk_ops sam9260_slow_ops = { -@@ -402,7 +399,7 @@ static const struct clk_ops sam9260_slow_ops = { - }; - - static struct clk * __init --at91_clk_register_sam9260_slow(struct at91_pmc *pmc, -+at91_clk_register_sam9260_slow(struct regmap *regmap, - const char *name, - const char **parent_names, - int num_parents) -@@ -411,7 +408,7 @@ at91_clk_register_sam9260_slow(struct at91_pmc *pmc, - struct clk *clk = NULL; - struct clk_init_data init; - -- if (!pmc || !name) -+ if (!name) - return ERR_PTR(-EINVAL); - - if (!parent_names || !num_parents) -@@ -428,7 +425,7 @@ at91_clk_register_sam9260_slow(struct at91_pmc *pmc, - init.flags = 0; - - slowck->hw.init = &init; -- slowck->pmc = pmc; -+ slowck->regmap = regmap; - - clk = clk_register(NULL, &slowck->hw); - if (IS_ERR(clk)) -@@ -439,29 +436,34 @@ at91_clk_register_sam9260_slow(struct at91_pmc *pmc, - return clk; - } - --void __init of_at91sam9260_clk_slow_setup(struct device_node *np, -- struct at91_pmc *pmc) -+static void __init of_at91sam9260_clk_slow_setup(struct device_node *np) - { - struct clk *clk; - const char *parent_names[2]; - int num_parents; - const char *name = np->name; -+ struct regmap *regmap; - - num_parents = of_clk_get_parent_count(np); - if (num_parents != 2) - return; - - of_clk_parent_fill(np, parent_names, num_parents); -+ regmap = syscon_node_to_regmap(of_get_parent(np)); -+ if (IS_ERR(regmap)) -+ return; - - of_property_read_string(np, "clock-output-names", &name); - -- clk = at91_clk_register_sam9260_slow(pmc, name, parent_names, -+ clk = at91_clk_register_sam9260_slow(regmap, name, parent_names, - num_parents); - if (IS_ERR(clk)) - return; - - of_clk_add_provider(np, of_clk_src_simple_get, clk); - } -+CLK_OF_DECLARE(at91sam9260_clk_slow, "atmel,at91sam9260-clk-slow", -+ of_at91sam9260_clk_slow_setup); - - /* - * FIXME: All slow clk users are not properly claiming it (get + prepare + -diff --git a/drivers/clk/at91/clk-smd.c b/drivers/clk/at91/clk-smd.c -index a7f8501..e6948a5 100644 ---- a/drivers/clk/at91/clk-smd.c -+++ b/drivers/clk/at91/clk-smd.c -@@ -12,8 +12,8 @@ - #include - #include - #include --#include --#include -+#include -+#include - - #include "pmc.h" - -@@ -24,7 +24,7 @@ - - struct at91sam9x5_clk_smd { - struct clk_hw hw; -- struct at91_pmc *pmc; -+ struct regmap *regmap; - }; - - #define to_at91sam9x5_clk_smd(hw) \ -@@ -33,13 +33,13 @@ struct at91sam9x5_clk_smd { - static unsigned long at91sam9x5_clk_smd_recalc_rate(struct clk_hw *hw, - unsigned long parent_rate) - { -- u32 tmp; -- u8 smddiv; - struct at91sam9x5_clk_smd *smd = to_at91sam9x5_clk_smd(hw); -- struct at91_pmc *pmc = smd->pmc; -+ unsigned int smdr; -+ u8 smddiv; -+ -+ regmap_read(smd->regmap, AT91_PMC_SMD, &smdr); -+ smddiv = (smdr & AT91_PMC_SMD_DIV) >> SMD_DIV_SHIFT; - -- tmp = pmc_read(pmc, AT91_PMC_SMD); -- smddiv = (tmp & AT91_PMC_SMD_DIV) >> SMD_DIV_SHIFT; - return parent_rate / (smddiv + 1); - } - -@@ -67,40 +67,38 @@ static long at91sam9x5_clk_smd_round_rate(struct clk_hw *hw, unsigned long rate, - - static int at91sam9x5_clk_smd_set_parent(struct clk_hw *hw, u8 index) - { -- u32 tmp; - struct at91sam9x5_clk_smd *smd = to_at91sam9x5_clk_smd(hw); -- struct at91_pmc *pmc = smd->pmc; - - if (index > 1) - return -EINVAL; -- tmp = pmc_read(pmc, AT91_PMC_SMD) & ~AT91_PMC_SMDS; -- if (index) -- tmp |= AT91_PMC_SMDS; -- pmc_write(pmc, AT91_PMC_SMD, tmp); -+ -+ regmap_update_bits(smd->regmap, AT91_PMC_SMD, AT91_PMC_SMDS, -+ index ? AT91_PMC_SMDS : 0); -+ - return 0; - } - - static u8 at91sam9x5_clk_smd_get_parent(struct clk_hw *hw) - { - struct at91sam9x5_clk_smd *smd = to_at91sam9x5_clk_smd(hw); -- struct at91_pmc *pmc = smd->pmc; -+ unsigned int smdr; - -- return pmc_read(pmc, AT91_PMC_SMD) & AT91_PMC_SMDS; -+ regmap_read(smd->regmap, AT91_PMC_SMD, &smdr); -+ -+ return smdr & AT91_PMC_SMDS; - } - - static int at91sam9x5_clk_smd_set_rate(struct clk_hw *hw, unsigned long rate, - unsigned long parent_rate) - { -- u32 tmp; - struct at91sam9x5_clk_smd *smd = to_at91sam9x5_clk_smd(hw); -- struct at91_pmc *pmc = smd->pmc; - unsigned long div = parent_rate / rate; - - if (parent_rate % rate || div < 1 || div > (SMD_MAX_DIV + 1)) - return -EINVAL; -- tmp = pmc_read(pmc, AT91_PMC_SMD) & ~AT91_PMC_SMD_DIV; -- tmp |= (div - 1) << SMD_DIV_SHIFT; -- pmc_write(pmc, AT91_PMC_SMD, tmp); -+ -+ regmap_update_bits(smd->regmap, AT91_PMC_SMD, AT91_PMC_SMD_DIV, -+ (div - 1) << SMD_DIV_SHIFT); - - return 0; - } -@@ -114,7 +112,7 @@ static const struct clk_ops at91sam9x5_smd_ops = { - }; - - static struct clk * __init --at91sam9x5_clk_register_smd(struct at91_pmc *pmc, const char *name, -+at91sam9x5_clk_register_smd(struct regmap *regmap, const char *name, - const char **parent_names, u8 num_parents) - { - struct at91sam9x5_clk_smd *smd; -@@ -132,7 +130,7 @@ at91sam9x5_clk_register_smd(struct at91_pmc *pmc, const char *name, - init.flags = CLK_SET_RATE_GATE | CLK_SET_PARENT_GATE; - - smd->hw.init = &init; -- smd->pmc = pmc; -+ smd->regmap = regmap; - - clk = clk_register(NULL, &smd->hw); - if (IS_ERR(clk)) -@@ -141,13 +139,13 @@ at91sam9x5_clk_register_smd(struct at91_pmc *pmc, const char *name, - return clk; - } - --void __init of_at91sam9x5_clk_smd_setup(struct device_node *np, -- struct at91_pmc *pmc) -+static void __init of_at91sam9x5_clk_smd_setup(struct device_node *np) - { - struct clk *clk; - int num_parents; - const char *parent_names[SMD_SOURCE_MAX]; - const char *name = np->name; -+ struct regmap *regmap; - - num_parents = of_clk_get_parent_count(np); - if (num_parents <= 0 || num_parents > SMD_SOURCE_MAX) -@@ -157,10 +155,16 @@ void __init of_at91sam9x5_clk_smd_setup(struct device_node *np, - - of_property_read_string(np, "clock-output-names", &name); - -- clk = at91sam9x5_clk_register_smd(pmc, name, parent_names, -+ regmap = syscon_node_to_regmap(of_get_parent(np)); -+ if (IS_ERR(regmap)) -+ return; -+ -+ clk = at91sam9x5_clk_register_smd(regmap, name, parent_names, - num_parents); - if (IS_ERR(clk)) - return; - - of_clk_add_provider(np, of_clk_src_simple_get, clk); - } -+CLK_OF_DECLARE(at91sam9x5_clk_smd, "atmel,at91sam9x5-clk-smd", -+ of_at91sam9x5_clk_smd_setup); -diff --git a/drivers/clk/at91/clk-system.c b/drivers/clk/at91/clk-system.c -index 3f53143..8f35d81 100644 ---- a/drivers/clk/at91/clk-system.c -+++ b/drivers/clk/at91/clk-system.c -@@ -12,13 +12,8 @@ - #include - #include - #include --#include --#include --#include --#include --#include --#include --#include -+#include -+#include - - #include "pmc.h" - -@@ -29,9 +24,7 @@ - #define to_clk_system(hw) container_of(hw, struct clk_system, hw) - struct clk_system { - struct clk_hw hw; -- struct at91_pmc *pmc; -- unsigned int irq; -- wait_queue_head_t wait; -+ struct regmap *regmap; - u8 id; - }; - -@@ -39,58 +32,54 @@ static inline int is_pck(int id) - { - return (id >= 8) && (id <= 15); - } --static irqreturn_t clk_system_irq_handler(int irq, void *dev_id) -+ -+static inline bool clk_system_ready(struct regmap *regmap, int id) - { -- struct clk_system *sys = (struct clk_system *)dev_id; -+ unsigned int status; - -- wake_up(&sys->wait); -- disable_irq_nosync(sys->irq); -+ regmap_read(regmap, AT91_PMC_SR, &status); - -- return IRQ_HANDLED; -+ return status & (1 << id) ? 1 : 0; - } - - static int clk_system_prepare(struct clk_hw *hw) - { - struct clk_system *sys = to_clk_system(hw); -- struct at91_pmc *pmc = sys->pmc; -- u32 mask = 1 << sys->id; - -- pmc_write(pmc, AT91_PMC_SCER, mask); -+ regmap_write(sys->regmap, AT91_PMC_SCER, 1 << sys->id); - - if (!is_pck(sys->id)) - return 0; - -- while (!(pmc_read(pmc, AT91_PMC_SR) & mask)) { -- if (sys->irq) { -- enable_irq(sys->irq); -- wait_event(sys->wait, -- pmc_read(pmc, AT91_PMC_SR) & mask); -- } else -- cpu_relax(); -- } -+ while (!clk_system_ready(sys->regmap, sys->id)) -+ cpu_relax(); -+ - return 0; - } - - static void clk_system_unprepare(struct clk_hw *hw) - { - struct clk_system *sys = to_clk_system(hw); -- struct at91_pmc *pmc = sys->pmc; - -- pmc_write(pmc, AT91_PMC_SCDR, 1 << sys->id); -+ regmap_write(sys->regmap, AT91_PMC_SCDR, 1 << sys->id); - } - - static int clk_system_is_prepared(struct clk_hw *hw) - { - struct clk_system *sys = to_clk_system(hw); -- struct at91_pmc *pmc = sys->pmc; -+ unsigned int status; -+ -+ regmap_read(sys->regmap, AT91_PMC_SCSR, &status); - -- if (!(pmc_read(pmc, AT91_PMC_SCSR) & (1 << sys->id))) -+ if (!(status & (1 << sys->id))) - return 0; - - if (!is_pck(sys->id)) - return 1; - -- return !!(pmc_read(pmc, AT91_PMC_SR) & (1 << sys->id)); -+ regmap_read(sys->regmap, AT91_PMC_SR, &status); -+ -+ return status & (1 << sys->id) ? 1 : 0; - } - - static const struct clk_ops system_ops = { -@@ -100,13 +89,12 @@ static const struct clk_ops system_ops = { - }; - - static struct clk * __init --at91_clk_register_system(struct at91_pmc *pmc, const char *name, -- const char *parent_name, u8 id, int irq) -+at91_clk_register_system(struct regmap *regmap, const char *name, -+ const char *parent_name, u8 id) - { - struct clk_system *sys; - struct clk *clk = NULL; - struct clk_init_data init; -- int ret; - - if (!parent_name || id > SYSTEM_MAX_ID) - return ERR_PTR(-EINVAL); -@@ -123,44 +111,33 @@ at91_clk_register_system(struct at91_pmc *pmc, const char *name, - - sys->id = id; - sys->hw.init = &init; -- sys->pmc = pmc; -- sys->irq = irq; -- if (irq) { -- init_waitqueue_head(&sys->wait); -- irq_set_status_flags(sys->irq, IRQ_NOAUTOEN); -- ret = request_irq(sys->irq, clk_system_irq_handler, -- IRQF_TRIGGER_HIGH, name, sys); -- if (ret) { -- kfree(sys); -- return ERR_PTR(ret); -- } -- } -+ sys->regmap = regmap; - - clk = clk_register(NULL, &sys->hw); -- if (IS_ERR(clk)) { -- if (irq) -- free_irq(sys->irq, sys); -+ if (IS_ERR(clk)) - kfree(sys); -- } - - return clk; - } - --static void __init --of_at91_clk_sys_setup(struct device_node *np, struct at91_pmc *pmc) -+static void __init of_at91rm9200_clk_sys_setup(struct device_node *np) - { - int num; -- int irq = 0; - u32 id; - struct clk *clk; - const char *name; - struct device_node *sysclknp; - const char *parent_name; -+ struct regmap *regmap; - - num = of_get_child_count(np); - if (num > (SYSTEM_MAX_ID + 1)) - return; - -+ regmap = syscon_node_to_regmap(of_get_parent(np)); -+ if (IS_ERR(regmap)) -+ return; -+ - for_each_child_of_node(np, sysclknp) { - if (of_property_read_u32(sysclknp, "reg", &id)) - continue; -@@ -168,21 +145,14 @@ of_at91_clk_sys_setup(struct device_node *np, struct at91_pmc *pmc) - if (of_property_read_string(np, "clock-output-names", &name)) - name = sysclknp->name; - -- if (is_pck(id)) -- irq = irq_of_parse_and_map(sysclknp, 0); -- - parent_name = of_clk_get_parent_name(sysclknp, 0); - -- clk = at91_clk_register_system(pmc, name, parent_name, id, irq); -+ clk = at91_clk_register_system(regmap, name, parent_name, id); - if (IS_ERR(clk)) - continue; - - of_clk_add_provider(sysclknp, of_clk_src_simple_get, clk); - } - } -- --void __init of_at91rm9200_clk_sys_setup(struct device_node *np, -- struct at91_pmc *pmc) --{ -- of_at91_clk_sys_setup(np, pmc); --} -+CLK_OF_DECLARE(at91rm9200_clk_sys, "atmel,at91rm9200-clk-system", -+ of_at91rm9200_clk_sys_setup); -diff --git a/drivers/clk/at91/clk-usb.c b/drivers/clk/at91/clk-usb.c -index 8ab8502..650ca45 100644 ---- a/drivers/clk/at91/clk-usb.c -+++ b/drivers/clk/at91/clk-usb.c -@@ -12,8 +12,8 @@ - #include - #include - #include --#include --#include -+#include -+#include - - #include "pmc.h" - -@@ -27,7 +27,7 @@ - - struct at91sam9x5_clk_usb { - struct clk_hw hw; -- struct at91_pmc *pmc; -+ struct regmap *regmap; - }; - - #define to_at91sam9x5_clk_usb(hw) \ -@@ -35,7 +35,7 @@ struct at91sam9x5_clk_usb { - - struct at91rm9200_clk_usb { - struct clk_hw hw; -- struct at91_pmc *pmc; -+ struct regmap *regmap; - u32 divisors[4]; - }; - -@@ -45,13 +45,12 @@ struct at91rm9200_clk_usb { - static unsigned long at91sam9x5_clk_usb_recalc_rate(struct clk_hw *hw, - unsigned long parent_rate) - { -- u32 tmp; -- u8 usbdiv; - struct at91sam9x5_clk_usb *usb = to_at91sam9x5_clk_usb(hw); -- struct at91_pmc *pmc = usb->pmc; -+ unsigned int usbr; -+ u8 usbdiv; - -- tmp = pmc_read(pmc, AT91_PMC_USB); -- usbdiv = (tmp & AT91_PMC_OHCIUSBDIV) >> SAM9X5_USB_DIV_SHIFT; -+ regmap_read(usb->regmap, AT91_PMC_USB, &usbr); -+ usbdiv = (usbr & AT91_PMC_OHCIUSBDIV) >> SAM9X5_USB_DIV_SHIFT; - - return DIV_ROUND_CLOSEST(parent_rate, (usbdiv + 1)); - } -@@ -109,33 +108,31 @@ static int at91sam9x5_clk_usb_determine_rate(struct clk_hw *hw, - - static int at91sam9x5_clk_usb_set_parent(struct clk_hw *hw, u8 index) - { -- u32 tmp; - struct at91sam9x5_clk_usb *usb = to_at91sam9x5_clk_usb(hw); -- struct at91_pmc *pmc = usb->pmc; - - if (index > 1) - return -EINVAL; -- tmp = pmc_read(pmc, AT91_PMC_USB) & ~AT91_PMC_USBS; -- if (index) -- tmp |= AT91_PMC_USBS; -- pmc_write(pmc, AT91_PMC_USB, tmp); -+ -+ regmap_update_bits(usb->regmap, AT91_PMC_USB, AT91_PMC_USBS, -+ index ? AT91_PMC_USBS : 0); -+ - return 0; - } - - static u8 at91sam9x5_clk_usb_get_parent(struct clk_hw *hw) - { - struct at91sam9x5_clk_usb *usb = to_at91sam9x5_clk_usb(hw); -- struct at91_pmc *pmc = usb->pmc; -+ unsigned int usbr; - -- return pmc_read(pmc, AT91_PMC_USB) & AT91_PMC_USBS; -+ regmap_read(usb->regmap, AT91_PMC_USB, &usbr); -+ -+ return usbr & AT91_PMC_USBS; - } - - static int at91sam9x5_clk_usb_set_rate(struct clk_hw *hw, unsigned long rate, - unsigned long parent_rate) - { -- u32 tmp; - struct at91sam9x5_clk_usb *usb = to_at91sam9x5_clk_usb(hw); -- struct at91_pmc *pmc = usb->pmc; - unsigned long div; - - if (!rate) -@@ -145,9 +142,8 @@ static int at91sam9x5_clk_usb_set_rate(struct clk_hw *hw, unsigned long rate, - if (div > SAM9X5_USB_MAX_DIV + 1 || !div) - return -EINVAL; - -- tmp = pmc_read(pmc, AT91_PMC_USB) & ~AT91_PMC_OHCIUSBDIV; -- tmp |= (div - 1) << SAM9X5_USB_DIV_SHIFT; -- pmc_write(pmc, AT91_PMC_USB, tmp); -+ regmap_update_bits(usb->regmap, AT91_PMC_USB, AT91_PMC_OHCIUSBDIV, -+ (div - 1) << SAM9X5_USB_DIV_SHIFT); - - return 0; - } -@@ -163,28 +159,28 @@ static const struct clk_ops at91sam9x5_usb_ops = { - static int at91sam9n12_clk_usb_enable(struct clk_hw *hw) - { - struct at91sam9x5_clk_usb *usb = to_at91sam9x5_clk_usb(hw); -- struct at91_pmc *pmc = usb->pmc; - -- pmc_write(pmc, AT91_PMC_USB, -- pmc_read(pmc, AT91_PMC_USB) | AT91_PMC_USBS); -+ regmap_update_bits(usb->regmap, AT91_PMC_USB, AT91_PMC_USBS, -+ AT91_PMC_USBS); -+ - return 0; - } - - static void at91sam9n12_clk_usb_disable(struct clk_hw *hw) - { - struct at91sam9x5_clk_usb *usb = to_at91sam9x5_clk_usb(hw); -- struct at91_pmc *pmc = usb->pmc; - -- pmc_write(pmc, AT91_PMC_USB, -- pmc_read(pmc, AT91_PMC_USB) & ~AT91_PMC_USBS); -+ regmap_update_bits(usb->regmap, AT91_PMC_USB, AT91_PMC_USBS, 0); - } - - static int at91sam9n12_clk_usb_is_enabled(struct clk_hw *hw) - { - struct at91sam9x5_clk_usb *usb = to_at91sam9x5_clk_usb(hw); -- struct at91_pmc *pmc = usb->pmc; -+ unsigned int usbr; - -- return !!(pmc_read(pmc, AT91_PMC_USB) & AT91_PMC_USBS); -+ regmap_read(usb->regmap, AT91_PMC_USB, &usbr); -+ -+ return usbr & AT91_PMC_USBS; - } - - static const struct clk_ops at91sam9n12_usb_ops = { -@@ -197,7 +193,7 @@ static const struct clk_ops at91sam9n12_usb_ops = { - }; - - static struct clk * __init --at91sam9x5_clk_register_usb(struct at91_pmc *pmc, const char *name, -+at91sam9x5_clk_register_usb(struct regmap *regmap, const char *name, - const char **parent_names, u8 num_parents) - { - struct at91sam9x5_clk_usb *usb; -@@ -216,7 +212,7 @@ at91sam9x5_clk_register_usb(struct at91_pmc *pmc, const char *name, - CLK_SET_RATE_PARENT; - - usb->hw.init = &init; -- usb->pmc = pmc; -+ usb->regmap = regmap; - - clk = clk_register(NULL, &usb->hw); - if (IS_ERR(clk)) -@@ -226,7 +222,7 @@ at91sam9x5_clk_register_usb(struct at91_pmc *pmc, const char *name, - } - - static struct clk * __init --at91sam9n12_clk_register_usb(struct at91_pmc *pmc, const char *name, -+at91sam9n12_clk_register_usb(struct regmap *regmap, const char *name, - const char *parent_name) - { - struct at91sam9x5_clk_usb *usb; -@@ -244,7 +240,7 @@ at91sam9n12_clk_register_usb(struct at91_pmc *pmc, const char *name, - init.flags = CLK_SET_RATE_GATE | CLK_SET_RATE_PARENT; - - usb->hw.init = &init; -- usb->pmc = pmc; -+ usb->regmap = regmap; - - clk = clk_register(NULL, &usb->hw); - if (IS_ERR(clk)) -@@ -257,12 +253,12 @@ static unsigned long at91rm9200_clk_usb_recalc_rate(struct clk_hw *hw, - unsigned long parent_rate) - { - struct at91rm9200_clk_usb *usb = to_at91rm9200_clk_usb(hw); -- struct at91_pmc *pmc = usb->pmc; -- u32 tmp; -+ unsigned int pllbr; - u8 usbdiv; - -- tmp = pmc_read(pmc, AT91_CKGR_PLLBR); -- usbdiv = (tmp & AT91_PMC_USBDIV) >> RM9200_USB_DIV_SHIFT; -+ regmap_read(usb->regmap, AT91_CKGR_PLLBR, &pllbr); -+ -+ usbdiv = (pllbr & AT91_PMC_USBDIV) >> RM9200_USB_DIV_SHIFT; - if (usb->divisors[usbdiv]) - return parent_rate / usb->divisors[usbdiv]; - -@@ -310,10 +306,8 @@ static long at91rm9200_clk_usb_round_rate(struct clk_hw *hw, unsigned long rate, - static int at91rm9200_clk_usb_set_rate(struct clk_hw *hw, unsigned long rate, - unsigned long parent_rate) - { -- u32 tmp; - int i; - struct at91rm9200_clk_usb *usb = to_at91rm9200_clk_usb(hw); -- struct at91_pmc *pmc = usb->pmc; - unsigned long div; - - if (!rate) -@@ -323,10 +317,10 @@ static int at91rm9200_clk_usb_set_rate(struct clk_hw *hw, unsigned long rate, - - for (i = 0; i < RM9200_USB_DIV_TAB_SIZE; i++) { - if (usb->divisors[i] == div) { -- tmp = pmc_read(pmc, AT91_CKGR_PLLBR) & -- ~AT91_PMC_USBDIV; -- tmp |= i << RM9200_USB_DIV_SHIFT; -- pmc_write(pmc, AT91_CKGR_PLLBR, tmp); -+ regmap_update_bits(usb->regmap, AT91_CKGR_PLLBR, -+ AT91_PMC_USBDIV, -+ i << RM9200_USB_DIV_SHIFT); -+ - return 0; - } - } -@@ -341,7 +335,7 @@ static const struct clk_ops at91rm9200_usb_ops = { - }; - - static struct clk * __init --at91rm9200_clk_register_usb(struct at91_pmc *pmc, const char *name, -+at91rm9200_clk_register_usb(struct regmap *regmap, const char *name, - const char *parent_name, const u32 *divisors) - { - struct at91rm9200_clk_usb *usb; -@@ -359,7 +353,7 @@ at91rm9200_clk_register_usb(struct at91_pmc *pmc, const char *name, - init.flags = CLK_SET_RATE_PARENT; - - usb->hw.init = &init; -- usb->pmc = pmc; -+ usb->regmap = regmap; - memcpy(usb->divisors, divisors, sizeof(usb->divisors)); - - clk = clk_register(NULL, &usb->hw); -@@ -369,13 +363,13 @@ at91rm9200_clk_register_usb(struct at91_pmc *pmc, const char *name, - return clk; - } - --void __init of_at91sam9x5_clk_usb_setup(struct device_node *np, -- struct at91_pmc *pmc) -+static void __init of_at91sam9x5_clk_usb_setup(struct device_node *np) - { - struct clk *clk; - int num_parents; - const char *parent_names[USB_SOURCE_MAX]; - const char *name = np->name; -+ struct regmap *regmap; - - num_parents = of_clk_get_parent_count(np); - if (num_parents <= 0 || num_parents > USB_SOURCE_MAX) -@@ -385,19 +379,26 @@ void __init of_at91sam9x5_clk_usb_setup(struct device_node *np, - - of_property_read_string(np, "clock-output-names", &name); - -- clk = at91sam9x5_clk_register_usb(pmc, name, parent_names, num_parents); -+ regmap = syscon_node_to_regmap(of_get_parent(np)); -+ if (IS_ERR(regmap)) -+ return; -+ -+ clk = at91sam9x5_clk_register_usb(regmap, name, parent_names, -+ num_parents); - if (IS_ERR(clk)) - return; - - of_clk_add_provider(np, of_clk_src_simple_get, clk); - } -+CLK_OF_DECLARE(at91sam9x5_clk_usb, "atmel,at91sam9x5-clk-usb", -+ of_at91sam9x5_clk_usb_setup); - --void __init of_at91sam9n12_clk_usb_setup(struct device_node *np, -- struct at91_pmc *pmc) -+static void __init of_at91sam9n12_clk_usb_setup(struct device_node *np) - { - struct clk *clk; - const char *parent_name; - const char *name = np->name; -+ struct regmap *regmap; - - parent_name = of_clk_get_parent_name(np, 0); - if (!parent_name) -@@ -405,20 +406,26 @@ void __init of_at91sam9n12_clk_usb_setup(struct device_node *np, - - of_property_read_string(np, "clock-output-names", &name); - -- clk = at91sam9n12_clk_register_usb(pmc, name, parent_name); -+ regmap = syscon_node_to_regmap(of_get_parent(np)); -+ if (IS_ERR(regmap)) -+ return; -+ -+ clk = at91sam9n12_clk_register_usb(regmap, name, parent_name); - if (IS_ERR(clk)) - return; - - of_clk_add_provider(np, of_clk_src_simple_get, clk); - } -+CLK_OF_DECLARE(at91sam9n12_clk_usb, "atmel,at91sam9n12-clk-usb", -+ of_at91sam9n12_clk_usb_setup); - --void __init of_at91rm9200_clk_usb_setup(struct device_node *np, -- struct at91_pmc *pmc) -+static void __init of_at91rm9200_clk_usb_setup(struct device_node *np) - { - struct clk *clk; - const char *parent_name; - const char *name = np->name; - u32 divisors[4] = {0, 0, 0, 0}; -+ struct regmap *regmap; - - parent_name = of_clk_get_parent_name(np, 0); - if (!parent_name) -@@ -430,9 +437,15 @@ void __init of_at91rm9200_clk_usb_setup(struct device_node *np, - - of_property_read_string(np, "clock-output-names", &name); - -- clk = at91rm9200_clk_register_usb(pmc, name, parent_name, divisors); -+ regmap = syscon_node_to_regmap(of_get_parent(np)); -+ if (IS_ERR(regmap)) -+ return; -+ -+ clk = at91rm9200_clk_register_usb(regmap, name, parent_name, divisors); - if (IS_ERR(clk)) - return; - - of_clk_add_provider(np, of_clk_src_simple_get, clk); - } -+CLK_OF_DECLARE(at91rm9200_clk_usb, "atmel,at91rm9200-clk-usb", -+ of_at91rm9200_clk_usb_setup); -diff --git a/drivers/clk/at91/clk-utmi.c b/drivers/clk/at91/clk-utmi.c -index ca561e9..61fcf39 100644 ---- a/drivers/clk/at91/clk-utmi.c -+++ b/drivers/clk/at91/clk-utmi.c -@@ -11,14 +11,9 @@ - #include - #include - #include --#include --#include - #include --#include --#include --#include --#include --#include -+#include -+#include - - #include "pmc.h" - -@@ -26,37 +21,30 @@ - - struct clk_utmi { - struct clk_hw hw; -- struct at91_pmc *pmc; -- unsigned int irq; -- wait_queue_head_t wait; -+ struct regmap *regmap; - }; - - #define to_clk_utmi(hw) container_of(hw, struct clk_utmi, hw) - --static irqreturn_t clk_utmi_irq_handler(int irq, void *dev_id) -+static inline bool clk_utmi_ready(struct regmap *regmap) - { -- struct clk_utmi *utmi = (struct clk_utmi *)dev_id; -+ unsigned int status; - -- wake_up(&utmi->wait); -- disable_irq_nosync(utmi->irq); -+ regmap_read(regmap, AT91_PMC_SR, &status); - -- return IRQ_HANDLED; -+ return status & AT91_PMC_LOCKU; - } - - static int clk_utmi_prepare(struct clk_hw *hw) - { - struct clk_utmi *utmi = to_clk_utmi(hw); -- struct at91_pmc *pmc = utmi->pmc; -- u32 tmp = pmc_read(pmc, AT91_CKGR_UCKR) | AT91_PMC_UPLLEN | -- AT91_PMC_UPLLCOUNT | AT91_PMC_BIASEN; -+ unsigned int uckr = AT91_PMC_UPLLEN | AT91_PMC_UPLLCOUNT | -+ AT91_PMC_BIASEN; - -- pmc_write(pmc, AT91_CKGR_UCKR, tmp); -+ regmap_update_bits(utmi->regmap, AT91_CKGR_UCKR, uckr, uckr); - -- while (!(pmc_read(pmc, AT91_PMC_SR) & AT91_PMC_LOCKU)) { -- enable_irq(utmi->irq); -- wait_event(utmi->wait, -- pmc_read(pmc, AT91_PMC_SR) & AT91_PMC_LOCKU); -- } -+ while (!clk_utmi_ready(utmi->regmap)) -+ cpu_relax(); - - return 0; - } -@@ -64,18 +52,15 @@ static int clk_utmi_prepare(struct clk_hw *hw) - static int clk_utmi_is_prepared(struct clk_hw *hw) - { - struct clk_utmi *utmi = to_clk_utmi(hw); -- struct at91_pmc *pmc = utmi->pmc; - -- return !!(pmc_read(pmc, AT91_PMC_SR) & AT91_PMC_LOCKU); -+ return clk_utmi_ready(utmi->regmap); - } - - static void clk_utmi_unprepare(struct clk_hw *hw) - { - struct clk_utmi *utmi = to_clk_utmi(hw); -- struct at91_pmc *pmc = utmi->pmc; -- u32 tmp = pmc_read(pmc, AT91_CKGR_UCKR) & ~AT91_PMC_UPLLEN; - -- pmc_write(pmc, AT91_CKGR_UCKR, tmp); -+ regmap_update_bits(utmi->regmap, AT91_CKGR_UCKR, AT91_PMC_UPLLEN, 0); - } - - static unsigned long clk_utmi_recalc_rate(struct clk_hw *hw, -@@ -93,10 +78,9 @@ static const struct clk_ops utmi_ops = { - }; - - static struct clk * __init --at91_clk_register_utmi(struct at91_pmc *pmc, unsigned int irq, -+at91_clk_register_utmi(struct regmap *regmap, - const char *name, const char *parent_name) - { -- int ret; - struct clk_utmi *utmi; - struct clk *clk = NULL; - struct clk_init_data init; -@@ -112,52 +96,36 @@ at91_clk_register_utmi(struct at91_pmc *pmc, unsigned int irq, - init.flags = CLK_SET_RATE_GATE; - - utmi->hw.init = &init; -- utmi->pmc = pmc; -- utmi->irq = irq; -- init_waitqueue_head(&utmi->wait); -- irq_set_status_flags(utmi->irq, IRQ_NOAUTOEN); -- ret = request_irq(utmi->irq, clk_utmi_irq_handler, -- IRQF_TRIGGER_HIGH, "clk-utmi", utmi); -- if (ret) { -- kfree(utmi); -- return ERR_PTR(ret); -- } -+ utmi->regmap = regmap; - - clk = clk_register(NULL, &utmi->hw); -- if (IS_ERR(clk)) { -- free_irq(utmi->irq, utmi); -+ if (IS_ERR(clk)) - kfree(utmi); -- } - - return clk; - } - --static void __init --of_at91_clk_utmi_setup(struct device_node *np, struct at91_pmc *pmc) -+static void __init of_at91sam9x5_clk_utmi_setup(struct device_node *np) - { -- unsigned int irq; - struct clk *clk; - const char *parent_name; - const char *name = np->name; -+ struct regmap *regmap; - - parent_name = of_clk_get_parent_name(np, 0); - - of_property_read_string(np, "clock-output-names", &name); - -- irq = irq_of_parse_and_map(np, 0); -- if (!irq) -+ regmap = syscon_node_to_regmap(of_get_parent(np)); -+ if (IS_ERR(regmap)) - return; - -- clk = at91_clk_register_utmi(pmc, irq, name, parent_name); -+ clk = at91_clk_register_utmi(regmap, name, parent_name); - if (IS_ERR(clk)) - return; - - of_clk_add_provider(np, of_clk_src_simple_get, clk); - return; - } -- --void __init of_at91sam9x5_clk_utmi_setup(struct device_node *np, -- struct at91_pmc *pmc) --{ -- of_at91_clk_utmi_setup(np, pmc); --} -+CLK_OF_DECLARE(at91sam9x5_clk_utmi, "atmel,at91sam9x5-clk-utmi", -+ of_at91sam9x5_clk_utmi_setup); -diff --git a/drivers/clk/at91/pmc.c b/drivers/clk/at91/pmc.c -index 8476b57..526df5b 100644 ---- a/drivers/clk/at91/pmc.c -+++ b/drivers/clk/at91/pmc.c -@@ -12,36 +12,13 @@ - #include - #include - #include --#include --#include --#include --#include --#include --#include --#include -+#include -+#include - - #include - - #include "pmc.h" - --void __iomem *at91_pmc_base; --EXPORT_SYMBOL_GPL(at91_pmc_base); -- --void at91rm9200_idle(void) --{ -- /* -- * Disable the processor clock. The processor will be automatically -- * re-enabled by an interrupt or by a reset. -- */ -- at91_pmc_write(AT91_PMC_SCDR, AT91_PMC_PCK); --} -- --void at91sam9_idle(void) --{ -- at91_pmc_write(AT91_PMC_SCDR, AT91_PMC_PCK); -- cpu_do_idle(); --} -- - int of_at91_get_clk_range(struct device_node *np, const char *propname, - struct clk_range *range) - { -@@ -64,402 +41,3 @@ int of_at91_get_clk_range(struct device_node *np, const char *propname, - return 0; - } - EXPORT_SYMBOL_GPL(of_at91_get_clk_range); -- --static void pmc_irq_mask(struct irq_data *d) --{ -- struct at91_pmc *pmc = irq_data_get_irq_chip_data(d); -- -- pmc_write(pmc, AT91_PMC_IDR, 1 << d->hwirq); --} -- --static void pmc_irq_unmask(struct irq_data *d) --{ -- struct at91_pmc *pmc = irq_data_get_irq_chip_data(d); -- -- pmc_write(pmc, AT91_PMC_IER, 1 << d->hwirq); --} -- --static int pmc_irq_set_type(struct irq_data *d, unsigned type) --{ -- if (type != IRQ_TYPE_LEVEL_HIGH) { -- pr_warn("PMC: type not supported (support only IRQ_TYPE_LEVEL_HIGH type)\n"); -- return -EINVAL; -- } -- -- return 0; --} -- --static void pmc_irq_suspend(struct irq_data *d) --{ -- struct at91_pmc *pmc = irq_data_get_irq_chip_data(d); -- -- pmc->imr = pmc_read(pmc, AT91_PMC_IMR); -- pmc_write(pmc, AT91_PMC_IDR, pmc->imr); --} -- --static void pmc_irq_resume(struct irq_data *d) --{ -- struct at91_pmc *pmc = irq_data_get_irq_chip_data(d); -- -- pmc_write(pmc, AT91_PMC_IER, pmc->imr); --} -- --static struct irq_chip pmc_irq = { -- .name = "PMC", -- .irq_disable = pmc_irq_mask, -- .irq_mask = pmc_irq_mask, -- .irq_unmask = pmc_irq_unmask, -- .irq_set_type = pmc_irq_set_type, -- .irq_suspend = pmc_irq_suspend, -- .irq_resume = pmc_irq_resume, --}; -- --static struct lock_class_key pmc_lock_class; -- --static int pmc_irq_map(struct irq_domain *h, unsigned int virq, -- irq_hw_number_t hw) --{ -- struct at91_pmc *pmc = h->host_data; -- -- irq_set_lockdep_class(virq, &pmc_lock_class); -- -- irq_set_chip_and_handler(virq, &pmc_irq, -- handle_level_irq); -- irq_set_chip_data(virq, pmc); -- -- return 0; --} -- --static int pmc_irq_domain_xlate(struct irq_domain *d, -- struct device_node *ctrlr, -- const u32 *intspec, unsigned int intsize, -- irq_hw_number_t *out_hwirq, -- unsigned int *out_type) --{ -- struct at91_pmc *pmc = d->host_data; -- const struct at91_pmc_caps *caps = pmc->caps; -- -- if (WARN_ON(intsize < 1)) -- return -EINVAL; -- -- *out_hwirq = intspec[0]; -- -- if (!(caps->available_irqs & (1 << *out_hwirq))) -- return -EINVAL; -- -- *out_type = IRQ_TYPE_LEVEL_HIGH; -- -- return 0; --} -- --static const struct irq_domain_ops pmc_irq_ops = { -- .map = pmc_irq_map, -- .xlate = pmc_irq_domain_xlate, --}; -- --static irqreturn_t pmc_irq_handler(int irq, void *data) --{ -- struct at91_pmc *pmc = (struct at91_pmc *)data; -- unsigned long sr; -- int n; -- -- sr = pmc_read(pmc, AT91_PMC_SR) & pmc_read(pmc, AT91_PMC_IMR); -- if (!sr) -- return IRQ_NONE; -- -- for_each_set_bit(n, &sr, BITS_PER_LONG) -- generic_handle_irq(irq_find_mapping(pmc->irqdomain, n)); -- -- return IRQ_HANDLED; --} -- --static const struct at91_pmc_caps at91rm9200_caps = { -- .available_irqs = AT91_PMC_MOSCS | AT91_PMC_LOCKA | AT91_PMC_LOCKB | -- AT91_PMC_MCKRDY | AT91_PMC_PCK0RDY | -- AT91_PMC_PCK1RDY | AT91_PMC_PCK2RDY | -- AT91_PMC_PCK3RDY, --}; -- --static const struct at91_pmc_caps at91sam9260_caps = { -- .available_irqs = AT91_PMC_MOSCS | AT91_PMC_LOCKA | AT91_PMC_LOCKB | -- AT91_PMC_MCKRDY | AT91_PMC_PCK0RDY | -- AT91_PMC_PCK1RDY, --}; -- --static const struct at91_pmc_caps at91sam9g45_caps = { -- .available_irqs = AT91_PMC_MOSCS | AT91_PMC_LOCKA | AT91_PMC_MCKRDY | -- AT91_PMC_LOCKU | AT91_PMC_PCK0RDY | -- AT91_PMC_PCK1RDY, --}; -- --static const struct at91_pmc_caps at91sam9n12_caps = { -- .available_irqs = AT91_PMC_MOSCS | AT91_PMC_LOCKA | AT91_PMC_LOCKB | -- AT91_PMC_MCKRDY | AT91_PMC_PCK0RDY | -- AT91_PMC_PCK1RDY | AT91_PMC_MOSCSELS | -- AT91_PMC_MOSCRCS | AT91_PMC_CFDEV, --}; -- --static const struct at91_pmc_caps at91sam9x5_caps = { -- .available_irqs = AT91_PMC_MOSCS | AT91_PMC_LOCKA | AT91_PMC_MCKRDY | -- AT91_PMC_LOCKU | AT91_PMC_PCK0RDY | -- AT91_PMC_PCK1RDY | AT91_PMC_MOSCSELS | -- AT91_PMC_MOSCRCS | AT91_PMC_CFDEV, --}; -- --static const struct at91_pmc_caps sama5d2_caps = { -- .available_irqs = AT91_PMC_MOSCS | AT91_PMC_LOCKA | AT91_PMC_MCKRDY | -- AT91_PMC_LOCKU | AT91_PMC_PCK0RDY | -- AT91_PMC_PCK1RDY | AT91_PMC_PCK2RDY | -- AT91_PMC_MOSCSELS | AT91_PMC_MOSCRCS | -- AT91_PMC_CFDEV | AT91_PMC_GCKRDY, --}; -- --static const struct at91_pmc_caps sama5d3_caps = { -- .available_irqs = AT91_PMC_MOSCS | AT91_PMC_LOCKA | AT91_PMC_MCKRDY | -- AT91_PMC_LOCKU | AT91_PMC_PCK0RDY | -- AT91_PMC_PCK1RDY | AT91_PMC_PCK2RDY | -- AT91_PMC_MOSCSELS | AT91_PMC_MOSCRCS | -- AT91_PMC_CFDEV, --}; -- --static struct at91_pmc *__init at91_pmc_init(struct device_node *np, -- void __iomem *regbase, int virq, -- const struct at91_pmc_caps *caps) --{ -- struct at91_pmc *pmc; -- -- if (!regbase || !virq || !caps) -- return NULL; -- -- at91_pmc_base = regbase; -- -- pmc = kzalloc(sizeof(*pmc), GFP_KERNEL); -- if (!pmc) -- return NULL; -- -- spin_lock_init(&pmc->lock); -- pmc->regbase = regbase; -- pmc->virq = virq; -- pmc->caps = caps; -- -- pmc->irqdomain = irq_domain_add_linear(np, 32, &pmc_irq_ops, pmc); -- -- if (!pmc->irqdomain) -- goto out_free_pmc; -- -- pmc_write(pmc, AT91_PMC_IDR, 0xffffffff); -- if (request_irq(pmc->virq, pmc_irq_handler, -- IRQF_SHARED | IRQF_COND_SUSPEND, "pmc", pmc)) -- goto out_remove_irqdomain; -- -- return pmc; -- --out_remove_irqdomain: -- irq_domain_remove(pmc->irqdomain); --out_free_pmc: -- kfree(pmc); -- -- return NULL; --} -- --static const struct of_device_id pmc_clk_ids[] __initconst = { -- /* Slow oscillator */ -- { -- .compatible = "atmel,at91sam9260-clk-slow", -- .data = of_at91sam9260_clk_slow_setup, -- }, -- /* Main clock */ -- { -- .compatible = "atmel,at91rm9200-clk-main-osc", -- .data = of_at91rm9200_clk_main_osc_setup, -- }, -- { -- .compatible = "atmel,at91sam9x5-clk-main-rc-osc", -- .data = of_at91sam9x5_clk_main_rc_osc_setup, -- }, -- { -- .compatible = "atmel,at91rm9200-clk-main", -- .data = of_at91rm9200_clk_main_setup, -- }, -- { -- .compatible = "atmel,at91sam9x5-clk-main", -- .data = of_at91sam9x5_clk_main_setup, -- }, -- /* PLL clocks */ -- { -- .compatible = "atmel,at91rm9200-clk-pll", -- .data = of_at91rm9200_clk_pll_setup, -- }, -- { -- .compatible = "atmel,at91sam9g45-clk-pll", -- .data = of_at91sam9g45_clk_pll_setup, -- }, -- { -- .compatible = "atmel,at91sam9g20-clk-pllb", -- .data = of_at91sam9g20_clk_pllb_setup, -- }, -- { -- .compatible = "atmel,sama5d3-clk-pll", -- .data = of_sama5d3_clk_pll_setup, -- }, -- { -- .compatible = "atmel,at91sam9x5-clk-plldiv", -- .data = of_at91sam9x5_clk_plldiv_setup, -- }, -- /* Master clock */ -- { -- .compatible = "atmel,at91rm9200-clk-master", -- .data = of_at91rm9200_clk_master_setup, -- }, -- { -- .compatible = "atmel,at91sam9x5-clk-master", -- .data = of_at91sam9x5_clk_master_setup, -- }, -- /* System clocks */ -- { -- .compatible = "atmel,at91rm9200-clk-system", -- .data = of_at91rm9200_clk_sys_setup, -- }, -- /* Peripheral clocks */ -- { -- .compatible = "atmel,at91rm9200-clk-peripheral", -- .data = of_at91rm9200_clk_periph_setup, -- }, -- { -- .compatible = "atmel,at91sam9x5-clk-peripheral", -- .data = of_at91sam9x5_clk_periph_setup, -- }, -- /* Programmable clocks */ -- { -- .compatible = "atmel,at91rm9200-clk-programmable", -- .data = of_at91rm9200_clk_prog_setup, -- }, -- { -- .compatible = "atmel,at91sam9g45-clk-programmable", -- .data = of_at91sam9g45_clk_prog_setup, -- }, -- { -- .compatible = "atmel,at91sam9x5-clk-programmable", -- .data = of_at91sam9x5_clk_prog_setup, -- }, -- /* UTMI clock */ --#if defined(CONFIG_HAVE_AT91_UTMI) -- { -- .compatible = "atmel,at91sam9x5-clk-utmi", -- .data = of_at91sam9x5_clk_utmi_setup, -- }, --#endif -- /* USB clock */ --#if defined(CONFIG_HAVE_AT91_USB_CLK) -- { -- .compatible = "atmel,at91rm9200-clk-usb", -- .data = of_at91rm9200_clk_usb_setup, -- }, -- { -- .compatible = "atmel,at91sam9x5-clk-usb", -- .data = of_at91sam9x5_clk_usb_setup, -- }, -- { -- .compatible = "atmel,at91sam9n12-clk-usb", -- .data = of_at91sam9n12_clk_usb_setup, -- }, --#endif -- /* SMD clock */ --#if defined(CONFIG_HAVE_AT91_SMD) -- { -- .compatible = "atmel,at91sam9x5-clk-smd", -- .data = of_at91sam9x5_clk_smd_setup, -- }, --#endif --#if defined(CONFIG_HAVE_AT91_H32MX) -- { -- .compatible = "atmel,sama5d4-clk-h32mx", -- .data = of_sama5d4_clk_h32mx_setup, -- }, --#endif --#if defined(CONFIG_HAVE_AT91_GENERATED_CLK) -- { -- .compatible = "atmel,sama5d2-clk-generated", -- .data = of_sama5d2_clk_generated_setup, -- }, --#endif -- { /*sentinel*/ } --}; -- --static void __init of_at91_pmc_setup(struct device_node *np, -- const struct at91_pmc_caps *caps) --{ -- struct at91_pmc *pmc; -- struct device_node *childnp; -- void (*clk_setup)(struct device_node *, struct at91_pmc *); -- const struct of_device_id *clk_id; -- void __iomem *regbase = of_iomap(np, 0); -- int virq; -- -- if (!regbase) -- return; -- -- virq = irq_of_parse_and_map(np, 0); -- if (!virq) -- return; -- -- pmc = at91_pmc_init(np, regbase, virq, caps); -- if (!pmc) -- return; -- for_each_child_of_node(np, childnp) { -- clk_id = of_match_node(pmc_clk_ids, childnp); -- if (!clk_id) -- continue; -- clk_setup = clk_id->data; -- clk_setup(childnp, pmc); -- } --} -- --static void __init of_at91rm9200_pmc_setup(struct device_node *np) --{ -- of_at91_pmc_setup(np, &at91rm9200_caps); --} --CLK_OF_DECLARE(at91rm9200_clk_pmc, "atmel,at91rm9200-pmc", -- of_at91rm9200_pmc_setup); -- --static void __init of_at91sam9260_pmc_setup(struct device_node *np) --{ -- of_at91_pmc_setup(np, &at91sam9260_caps); --} --CLK_OF_DECLARE(at91sam9260_clk_pmc, "atmel,at91sam9260-pmc", -- of_at91sam9260_pmc_setup); -- --static void __init of_at91sam9g45_pmc_setup(struct device_node *np) --{ -- of_at91_pmc_setup(np, &at91sam9g45_caps); --} --CLK_OF_DECLARE(at91sam9g45_clk_pmc, "atmel,at91sam9g45-pmc", -- of_at91sam9g45_pmc_setup); -- --static void __init of_at91sam9n12_pmc_setup(struct device_node *np) --{ -- of_at91_pmc_setup(np, &at91sam9n12_caps); --} --CLK_OF_DECLARE(at91sam9n12_clk_pmc, "atmel,at91sam9n12-pmc", -- of_at91sam9n12_pmc_setup); -- --static void __init of_at91sam9x5_pmc_setup(struct device_node *np) --{ -- of_at91_pmc_setup(np, &at91sam9x5_caps); --} --CLK_OF_DECLARE(at91sam9x5_clk_pmc, "atmel,at91sam9x5-pmc", -- of_at91sam9x5_pmc_setup); -- --static void __init of_sama5d2_pmc_setup(struct device_node *np) --{ -- of_at91_pmc_setup(np, &sama5d2_caps); --} --CLK_OF_DECLARE(sama5d2_clk_pmc, "atmel,sama5d2-pmc", -- of_sama5d2_pmc_setup); -- --static void __init of_sama5d3_pmc_setup(struct device_node *np) --{ -- of_at91_pmc_setup(np, &sama5d3_caps); --} --CLK_OF_DECLARE(sama5d3_clk_pmc, "atmel,sama5d3-pmc", -- of_sama5d3_pmc_setup); -diff --git a/drivers/clk/at91/pmc.h b/drivers/clk/at91/pmc.h -index f657392..5771fff 100644 ---- a/drivers/clk/at91/pmc.h -+++ b/drivers/clk/at91/pmc.h -@@ -14,8 +14,11 @@ - - #include - #include -+#include - #include - -+extern spinlock_t pmc_pcr_lock; -+ - struct clk_range { - unsigned long min; - unsigned long max; -@@ -23,102 +26,7 @@ struct clk_range { - - #define CLK_RANGE(MIN, MAX) {.min = MIN, .max = MAX,} - --struct at91_pmc_caps { -- u32 available_irqs; --}; -- --struct at91_pmc { -- void __iomem *regbase; -- int virq; -- spinlock_t lock; -- const struct at91_pmc_caps *caps; -- struct irq_domain *irqdomain; -- u32 imr; --}; -- --static inline void pmc_lock(struct at91_pmc *pmc) --{ -- spin_lock(&pmc->lock); --} -- --static inline void pmc_unlock(struct at91_pmc *pmc) --{ -- spin_unlock(&pmc->lock); --} -- --static inline u32 pmc_read(struct at91_pmc *pmc, int offset) --{ -- return readl(pmc->regbase + offset); --} -- --static inline void pmc_write(struct at91_pmc *pmc, int offset, u32 value) --{ -- writel(value, pmc->regbase + offset); --} -- - int of_at91_get_clk_range(struct device_node *np, const char *propname, - struct clk_range *range); - --void of_at91sam9260_clk_slow_setup(struct device_node *np, -- struct at91_pmc *pmc); -- --void of_at91rm9200_clk_main_osc_setup(struct device_node *np, -- struct at91_pmc *pmc); --void of_at91sam9x5_clk_main_rc_osc_setup(struct device_node *np, -- struct at91_pmc *pmc); --void of_at91rm9200_clk_main_setup(struct device_node *np, -- struct at91_pmc *pmc); --void of_at91sam9x5_clk_main_setup(struct device_node *np, -- struct at91_pmc *pmc); -- --void of_at91rm9200_clk_pll_setup(struct device_node *np, -- struct at91_pmc *pmc); --void of_at91sam9g45_clk_pll_setup(struct device_node *np, -- struct at91_pmc *pmc); --void of_at91sam9g20_clk_pllb_setup(struct device_node *np, -- struct at91_pmc *pmc); --void of_sama5d3_clk_pll_setup(struct device_node *np, -- struct at91_pmc *pmc); --void of_at91sam9x5_clk_plldiv_setup(struct device_node *np, -- struct at91_pmc *pmc); -- --void of_at91rm9200_clk_master_setup(struct device_node *np, -- struct at91_pmc *pmc); --void of_at91sam9x5_clk_master_setup(struct device_node *np, -- struct at91_pmc *pmc); -- --void of_at91rm9200_clk_sys_setup(struct device_node *np, -- struct at91_pmc *pmc); -- --void of_at91rm9200_clk_periph_setup(struct device_node *np, -- struct at91_pmc *pmc); --void of_at91sam9x5_clk_periph_setup(struct device_node *np, -- struct at91_pmc *pmc); -- --void of_at91rm9200_clk_prog_setup(struct device_node *np, -- struct at91_pmc *pmc); --void of_at91sam9g45_clk_prog_setup(struct device_node *np, -- struct at91_pmc *pmc); --void of_at91sam9x5_clk_prog_setup(struct device_node *np, -- struct at91_pmc *pmc); -- --void of_at91sam9x5_clk_utmi_setup(struct device_node *np, -- struct at91_pmc *pmc); -- --void of_at91rm9200_clk_usb_setup(struct device_node *np, -- struct at91_pmc *pmc); --void of_at91sam9x5_clk_usb_setup(struct device_node *np, -- struct at91_pmc *pmc); --void of_at91sam9n12_clk_usb_setup(struct device_node *np, -- struct at91_pmc *pmc); -- --void of_at91sam9x5_clk_smd_setup(struct device_node *np, -- struct at91_pmc *pmc); -- --void of_sama5d4_clk_h32mx_setup(struct device_node *np, -- struct at91_pmc *pmc); -- --void of_sama5d2_clk_generated_setup(struct device_node *np, -- struct at91_pmc *pmc); -- - #endif /* __PMC_H_ */ -diff --git a/drivers/clk/bcm/clk-bcm2835.c b/drivers/clk/bcm/clk-bcm2835.c -index 39bf582..6029313 100644 ---- a/drivers/clk/bcm/clk-bcm2835.c -+++ b/drivers/clk/bcm/clk-bcm2835.c -@@ -890,8 +890,14 @@ static void bcm2835_pll_off(struct clk_hw *hw) - struct bcm2835_cprman *cprman = pll->cprman; - const struct bcm2835_pll_data *data = pll->data; - -- cprman_write(cprman, data->cm_ctrl_reg, CM_PLL_ANARST); -- cprman_write(cprman, data->a2w_ctrl_reg, A2W_PLL_CTRL_PWRDN); -+ spin_lock(&cprman->regs_lock); -+ cprman_write(cprman, data->cm_ctrl_reg, -+ cprman_read(cprman, data->cm_ctrl_reg) | -+ CM_PLL_ANARST); -+ cprman_write(cprman, data->a2w_ctrl_reg, -+ cprman_read(cprman, data->a2w_ctrl_reg) | -+ A2W_PLL_CTRL_PWRDN); -+ spin_unlock(&cprman->regs_lock); - } - - static int bcm2835_pll_on(struct clk_hw *hw) -@@ -901,6 +907,10 @@ static int bcm2835_pll_on(struct clk_hw *hw) - const struct bcm2835_pll_data *data = pll->data; - ktime_t timeout; - -+ cprman_write(cprman, data->a2w_ctrl_reg, -+ cprman_read(cprman, data->a2w_ctrl_reg) & -+ ~A2W_PLL_CTRL_PWRDN); -+ - /* Take the PLL out of reset. */ - cprman_write(cprman, data->cm_ctrl_reg, - cprman_read(cprman, data->cm_ctrl_reg) & ~CM_PLL_ANARST); -@@ -1068,10 +1078,12 @@ static void bcm2835_pll_divider_off(struct clk_hw *hw) - struct bcm2835_cprman *cprman = divider->cprman; - const struct bcm2835_pll_divider_data *data = divider->data; - -+ spin_lock(&cprman->regs_lock); - cprman_write(cprman, data->cm_reg, - (cprman_read(cprman, data->cm_reg) & - ~data->load_mask) | data->hold_mask); - cprman_write(cprman, data->a2w_reg, A2W_PLL_CHANNEL_DISABLE); -+ spin_unlock(&cprman->regs_lock); - } - - static int bcm2835_pll_divider_on(struct clk_hw *hw) -@@ -1080,12 +1092,14 @@ static int bcm2835_pll_divider_on(struct clk_hw *hw) - struct bcm2835_cprman *cprman = divider->cprman; - const struct bcm2835_pll_divider_data *data = divider->data; - -+ spin_lock(&cprman->regs_lock); - cprman_write(cprman, data->a2w_reg, - cprman_read(cprman, data->a2w_reg) & - ~A2W_PLL_CHANNEL_DISABLE); - - cprman_write(cprman, data->cm_reg, - cprman_read(cprman, data->cm_reg) & ~data->hold_mask); -+ spin_unlock(&cprman->regs_lock); - - return 0; - } -@@ -1097,13 +1111,15 @@ static int bcm2835_pll_divider_set_rate(struct clk_hw *hw, - struct bcm2835_pll_divider *divider = bcm2835_pll_divider_from_hw(hw); - struct bcm2835_cprman *cprman = divider->cprman; - const struct bcm2835_pll_divider_data *data = divider->data; -- u32 cm; -- int ret; -+ u32 cm, div, max_div = 1 << A2W_PLL_DIV_BITS; - -- ret = clk_divider_ops.set_rate(hw, rate, parent_rate); -- if (ret) -- return ret; -+ div = DIV_ROUND_UP_ULL(parent_rate, rate); -+ -+ div = min(div, max_div); -+ if (div == max_div) -+ div = 0; - -+ cprman_write(cprman, data->a2w_reg, div); - cm = cprman_read(cprman, data->cm_reg); - cprman_write(cprman, data->cm_reg, cm | data->load_mask); - cprman_write(cprman, data->cm_reg, cm & ~data->load_mask); -@@ -1165,8 +1181,9 @@ static u32 bcm2835_clock_choose_div(struct clk_hw *hw, - div &= ~unused_frac_mask; - } - -- /* Clamp to the limits. */ -- div = max(div, unused_frac_mask + 1); -+ /* clamp to min divider of 1 */ -+ div = max_t(u32, div, 1 << CM_DIV_FRAC_BITS); -+ /* clamp to the highest possible fractional divider */ - div = min_t(u32, div, GENMASK(data->int_bits + CM_DIV_FRAC_BITS - 1, - CM_DIV_FRAC_BITS - data->frac_bits)); - -diff --git a/drivers/clk/clk-divider.c b/drivers/clk/clk-divider.c -index 3ace102..bbf206e 100644 ---- a/drivers/clk/clk-divider.c -+++ b/drivers/clk/clk-divider.c -@@ -422,6 +422,12 @@ const struct clk_ops clk_divider_ops = { - }; - EXPORT_SYMBOL_GPL(clk_divider_ops); - -+const struct clk_ops clk_divider_ro_ops = { -+ .recalc_rate = clk_divider_recalc_rate, -+ .round_rate = clk_divider_round_rate, -+}; -+EXPORT_SYMBOL_GPL(clk_divider_ro_ops); -+ - static struct clk *_register_divider(struct device *dev, const char *name, - const char *parent_name, unsigned long flags, - void __iomem *reg, u8 shift, u8 width, -@@ -445,7 +451,10 @@ static struct clk *_register_divider(struct device *dev, const char *name, - return ERR_PTR(-ENOMEM); - - init.name = name; -- init.ops = &clk_divider_ops; -+ if (clk_divider_flags & CLK_DIVIDER_READ_ONLY) -+ init.ops = &clk_divider_ro_ops; -+ else -+ init.ops = &clk_divider_ops; - init.flags = flags | CLK_IS_BASIC; - init.parent_names = (parent_name ? &parent_name: NULL); - init.num_parents = (parent_name ? 1 : 0); -diff --git a/drivers/clk/imx/clk-imx35.c b/drivers/clk/imx/clk-imx35.c -index a71d24c..b0978d3 100644 ---- a/drivers/clk/imx/clk-imx35.c -+++ b/drivers/clk/imx/clk-imx35.c -@@ -66,7 +66,7 @@ static const char *std_sel[] = {"ppll", "arm"}; - static const char *ipg_per_sel[] = {"ahb_per_div", "arm_per_div"}; - - enum mx35_clks { -- ckih, ckil, mpll, ppll, mpll_075, arm, hsp, hsp_div, hsp_sel, ahb, ipg, -+ ckih, mpll, ppll, mpll_075, arm, hsp, hsp_div, hsp_sel, ahb, ipg, - arm_per_div, ahb_per_div, ipg_per, uart_sel, uart_div, esdhc_sel, - esdhc1_div, esdhc2_div, esdhc3_div, spdif_sel, spdif_div_pre, - spdif_div_post, ssi_sel, ssi1_div_pre, ssi1_div_post, ssi2_div_pre, -@@ -79,7 +79,7 @@ enum mx35_clks { - rtc_gate, rtic_gate, scc_gate, sdma_gate, spba_gate, spdif_gate, - ssi1_gate, ssi2_gate, uart1_gate, uart2_gate, uart3_gate, usbotg_gate, - wdog_gate, max_gate, admux_gate, csi_gate, csi_div, csi_sel, iim_gate, -- gpu2d_gate, clk_max -+ gpu2d_gate, ckil, clk_max - }; - - static struct clk *clk[clk_max]; -diff --git a/drivers/clk/imx/clk-imx6q.c b/drivers/clk/imx/clk-imx6q.c -index d3366be..ceb8703 100644 ---- a/drivers/clk/imx/clk-imx6q.c -+++ b/drivers/clk/imx/clk-imx6q.c -@@ -507,6 +507,7 @@ static void __init imx6q_clocks_init(struct device_node *ccm_node) - clk_data.clk_num = ARRAY_SIZE(clk); - of_clk_add_provider(np, of_clk_src_onecell_get, &clk_data); - -+ clk_register_clkdev(clk[IMX6QDL_CLK_GPT_3M], "gpt_3m", "imx-gpt.0"); - clk_register_clkdev(clk[IMX6QDL_CLK_ENET_REF], "enet_ref", NULL); - - if ((imx_get_soc_revision() != IMX_CHIP_REVISION_1_0) || -@@ -515,6 +516,10 @@ static void __init imx6q_clocks_init(struct device_node *ccm_node) - imx_clk_set_parent(clk[IMX6QDL_CLK_LDB_DI1_SEL], clk[IMX6QDL_CLK_PLL5_VIDEO_DIV]); - } - -+ imx_clk_set_rate(clk[IMX6QDL_CLK_PLL3_PFD1_540M], 540000000); -+ if (clk_on_imx6dl()) -+ imx_clk_set_parent(clk[IMX6QDL_CLK_IPU1_SEL], clk[IMX6QDL_CLK_PLL3_PFD1_540M]); -+ - imx_clk_set_parent(clk[IMX6QDL_CLK_IPU1_DI0_PRE_SEL], clk[IMX6QDL_CLK_PLL5_VIDEO_DIV]); - imx_clk_set_parent(clk[IMX6QDL_CLK_IPU1_DI1_PRE_SEL], clk[IMX6QDL_CLK_PLL5_VIDEO_DIV]); - imx_clk_set_parent(clk[IMX6QDL_CLK_IPU2_DI0_PRE_SEL], clk[IMX6QDL_CLK_PLL5_VIDEO_DIV]); -@@ -524,8 +529,6 @@ static void __init imx6q_clocks_init(struct device_node *ccm_node) - imx_clk_set_parent(clk[IMX6QDL_CLK_IPU2_DI0_SEL], clk[IMX6QDL_CLK_IPU2_DI0_PRE]); - imx_clk_set_parent(clk[IMX6QDL_CLK_IPU2_DI1_SEL], clk[IMX6QDL_CLK_IPU2_DI1_PRE]); - -- imx_clk_set_rate(clk[IMX6QDL_CLK_PLL3_PFD1_540M], 540000000); -- imx_clk_set_parent(clk[IMX6QDL_CLK_IPU1_SEL], clk[IMX6QDL_CLK_PLL3_PFD1_540M]); - imx_clk_set_parent(clk[IMX6QDL_CLK_AXI_ALT_SEL], clk[IMX6QDL_CLK_PLL3_PFD1_540M]); - imx_clk_set_parent(clk[IMX6QDL_CLK_AXI_SEL], clk[IMX6QDL_CLK_AXI_ALT_SEL]); - /* set epdc/pxp axi clock to 200Mhz */ -@@ -543,6 +546,14 @@ static void __init imx6q_clocks_init(struct device_node *ccm_node) - */ - imx_clk_set_parent(clk[IMX6QDL_CLK_ENFC_SEL], clk[IMX6QDL_CLK_PLL2_PFD2_396M]); - -+ for (i = 0; i < ARRAY_SIZE(clks_init_on); i++) -+ imx_clk_prepare_enable(clk[clks_init_on[i]]); -+ -+ if (IS_ENABLED(CONFIG_USB_MXS_PHY)) { -+ imx_clk_prepare_enable(clk[IMX6QDL_CLK_USBPHY1_GATE]); -+ imx_clk_prepare_enable(clk[IMX6QDL_CLK_USBPHY2_GATE]); -+ } -+ - /* gpu clock initilazation */ - /* - * On mx6dl, 2d core clock sources(sel, podf) is from 3d -@@ -588,14 +599,6 @@ static void __init imx6q_clocks_init(struct device_node *ccm_node) - - imx_register_uart_clocks(uart_clks); - -- for (i = 0; i < ARRAY_SIZE(clks_init_on); i++) -- imx_clk_prepare_enable(clk[clks_init_on[i]]); -- -- if (IS_ENABLED(CONFIG_USB_MXS_PHY)) { -- imx_clk_prepare_enable(clk[IMX6QDL_CLK_USBPHY1_GATE]); -- imx_clk_prepare_enable(clk[IMX6QDL_CLK_USBPHY2_GATE]); -- } -- - imx_clk_set_parent(clk[IMX6QDL_CLK_VPU_AXI_SEL], clk[IMX6QDL_CLK_PLL2_PFD0_352M]); - - if (clk_on_imx6dl()) -diff --git a/drivers/clk/meson/clkc.c b/drivers/clk/meson/clkc.c -index c83ae13..d920d41 100644 ---- a/drivers/clk/meson/clkc.c -+++ b/drivers/clk/meson/clkc.c -@@ -198,7 +198,7 @@ meson_clk_register_fixed_rate(const struct clk_conf *clk_conf, - } - - void __init meson_clk_register_clks(const struct clk_conf *clk_confs, -- size_t nr_confs, -+ unsigned int nr_confs, - void __iomem *clk_base) - { - unsigned int i; -diff --git a/drivers/clk/nxp/clk-lpc18xx-ccu.c b/drivers/clk/nxp/clk-lpc18xx-ccu.c -index 13aabbb..558da89 100644 ---- a/drivers/clk/nxp/clk-lpc18xx-ccu.c -+++ b/drivers/clk/nxp/clk-lpc18xx-ccu.c -@@ -222,7 +222,7 @@ static void lpc18xx_ccu_register_branch_gate_div(struct lpc18xx_clk_branch *bran - div->width = 1; - - div_hw = &div->hw; -- div_ops = &clk_divider_ops; -+ div_ops = &clk_divider_ro_ops; - } - - branch->gate.reg = branch->offset + reg_base; -diff --git a/drivers/clk/qcom/gcc-msm8916.c b/drivers/clk/qcom/gcc-msm8916.c -index d0a0313..2e7f03d 100644 ---- a/drivers/clk/qcom/gcc-msm8916.c -+++ b/drivers/clk/qcom/gcc-msm8916.c -@@ -2346,6 +2346,7 @@ static struct clk_branch gcc_crypto_ahb_clk = { - "pcnoc_bfdcd_clk_src", - }, - .num_parents = 1, -+ .flags = CLK_SET_RATE_PARENT, - .ops = &clk_branch2_ops, - }, - }, -@@ -2381,6 +2382,7 @@ static struct clk_branch gcc_crypto_clk = { - "crypto_clk_src", - }, - .num_parents = 1, -+ .flags = CLK_SET_RATE_PARENT, - .ops = &clk_branch2_ops, - }, - }, -diff --git a/drivers/clk/qcom/gcc-msm8960.c b/drivers/clk/qcom/gcc-msm8960.c -index 66c18bc..bdc4b2d 100644 ---- a/drivers/clk/qcom/gcc-msm8960.c -+++ b/drivers/clk/qcom/gcc-msm8960.c -@@ -2753,7 +2753,7 @@ static struct clk_rcg ce3_src = { - }, - .freq_tbl = clk_tbl_ce3, - .clkr = { -- .enable_reg = 0x2c08, -+ .enable_reg = 0x36c0, - .enable_mask = BIT(7), - .hw.init = &(struct clk_init_data){ - .name = "ce3_src", -@@ -2769,7 +2769,7 @@ static struct clk_branch ce3_core_clk = { - .halt_reg = 0x2fdc, - .halt_bit = 5, - .clkr = { -- .enable_reg = 0x36c4, -+ .enable_reg = 0x36cc, - .enable_mask = BIT(4), - .hw.init = &(struct clk_init_data){ - .name = "ce3_core_clk", -diff --git a/drivers/clk/rockchip/clk-rk3188.c b/drivers/clk/rockchip/clk-rk3188.c -index abb4760..fe728f8 100644 ---- a/drivers/clk/rockchip/clk-rk3188.c -+++ b/drivers/clk/rockchip/clk-rk3188.c -@@ -718,6 +718,7 @@ static const char *const rk3188_critical_clocks[] __initconst = { - "hclk_peri", - "pclk_cpu", - "pclk_peri", -+ "hclk_cpubus" - }; - - static void __init rk3188_common_clk_init(struct device_node *np) -diff --git a/drivers/clk/rockchip/clk-rk3368.c b/drivers/clk/rockchip/clk-rk3368.c -index 7e6b783..1b14869 100644 ---- a/drivers/clk/rockchip/clk-rk3368.c -+++ b/drivers/clk/rockchip/clk-rk3368.c -@@ -165,7 +165,7 @@ static const struct rockchip_cpuclk_reg_data rk3368_cpuclkb_data = { - .core_reg = RK3368_CLKSEL_CON(0), - .div_core_shift = 0, - .div_core_mask = 0x1f, -- .mux_core_shift = 15, -+ .mux_core_shift = 7, - }; - - static const struct rockchip_cpuclk_reg_data rk3368_cpuclkl_data = { -@@ -218,29 +218,29 @@ static const struct rockchip_cpuclk_reg_data rk3368_cpuclkl_data = { - } - - static struct rockchip_cpuclk_rate_table rk3368_cpuclkb_rates[] __initdata = { -- RK3368_CPUCLKB_RATE(1512000000, 2, 6, 6), -- RK3368_CPUCLKB_RATE(1488000000, 2, 5, 5), -- RK3368_CPUCLKB_RATE(1416000000, 2, 5, 5), -- RK3368_CPUCLKB_RATE(1200000000, 2, 4, 4), -- RK3368_CPUCLKB_RATE(1008000000, 2, 4, 4), -- RK3368_CPUCLKB_RATE( 816000000, 2, 3, 3), -- RK3368_CPUCLKB_RATE( 696000000, 2, 3, 3), -- RK3368_CPUCLKB_RATE( 600000000, 2, 2, 2), -- RK3368_CPUCLKB_RATE( 408000000, 2, 2, 2), -- RK3368_CPUCLKB_RATE( 312000000, 2, 2, 2), -+ RK3368_CPUCLKB_RATE(1512000000, 1, 5, 5), -+ RK3368_CPUCLKB_RATE(1488000000, 1, 4, 4), -+ RK3368_CPUCLKB_RATE(1416000000, 1, 4, 4), -+ RK3368_CPUCLKB_RATE(1200000000, 1, 3, 3), -+ RK3368_CPUCLKB_RATE(1008000000, 1, 3, 3), -+ RK3368_CPUCLKB_RATE( 816000000, 1, 2, 2), -+ RK3368_CPUCLKB_RATE( 696000000, 1, 2, 2), -+ RK3368_CPUCLKB_RATE( 600000000, 1, 1, 1), -+ RK3368_CPUCLKB_RATE( 408000000, 1, 1, 1), -+ RK3368_CPUCLKB_RATE( 312000000, 1, 1, 1), - }; - - static struct rockchip_cpuclk_rate_table rk3368_cpuclkl_rates[] __initdata = { -- RK3368_CPUCLKL_RATE(1512000000, 2, 7, 7), -- RK3368_CPUCLKL_RATE(1488000000, 2, 6, 6), -- RK3368_CPUCLKL_RATE(1416000000, 2, 6, 6), -- RK3368_CPUCLKL_RATE(1200000000, 2, 5, 5), -- RK3368_CPUCLKL_RATE(1008000000, 2, 5, 5), -- RK3368_CPUCLKL_RATE( 816000000, 2, 4, 4), -- RK3368_CPUCLKL_RATE( 696000000, 2, 3, 3), -- RK3368_CPUCLKL_RATE( 600000000, 2, 3, 3), -- RK3368_CPUCLKL_RATE( 408000000, 2, 2, 2), -- RK3368_CPUCLKL_RATE( 312000000, 2, 2, 2), -+ RK3368_CPUCLKL_RATE(1512000000, 1, 6, 6), -+ RK3368_CPUCLKL_RATE(1488000000, 1, 5, 5), -+ RK3368_CPUCLKL_RATE(1416000000, 1, 5, 5), -+ RK3368_CPUCLKL_RATE(1200000000, 1, 4, 4), -+ RK3368_CPUCLKL_RATE(1008000000, 1, 4, 4), -+ RK3368_CPUCLKL_RATE( 816000000, 1, 3, 3), -+ RK3368_CPUCLKL_RATE( 696000000, 1, 2, 2), -+ RK3368_CPUCLKL_RATE( 600000000, 1, 2, 2), -+ RK3368_CPUCLKL_RATE( 408000000, 1, 1, 1), -+ RK3368_CPUCLKL_RATE( 312000000, 1, 1, 1), - }; - - static struct rockchip_clk_branch rk3368_clk_branches[] __initdata = { -@@ -384,10 +384,10 @@ static struct rockchip_clk_branch rk3368_clk_branches[] __initdata = { - * Clock-Architecture Diagram 3 - */ - -- COMPOSITE(0, "aclk_vepu", mux_pll_src_cpll_gpll_usb_p, 0, -+ COMPOSITE(0, "aclk_vepu", mux_pll_src_cpll_gpll_npll_usb_p, 0, - RK3368_CLKSEL_CON(15), 6, 2, MFLAGS, 0, 5, DFLAGS, - RK3368_CLKGATE_CON(4), 6, GFLAGS), -- COMPOSITE(0, "aclk_vdpu", mux_pll_src_cpll_gpll_usb_p, 0, -+ COMPOSITE(0, "aclk_vdpu", mux_pll_src_cpll_gpll_npll_usb_p, 0, - RK3368_CLKSEL_CON(15), 14, 2, MFLAGS, 8, 5, DFLAGS, - RK3368_CLKGATE_CON(4), 7, GFLAGS), - -@@ -442,7 +442,7 @@ static struct rockchip_clk_branch rk3368_clk_branches[] __initdata = { - GATE(SCLK_HDMI_HDCP, "sclk_hdmi_hdcp", "xin24m", 0, - RK3368_CLKGATE_CON(4), 13, GFLAGS), - GATE(SCLK_HDMI_CEC, "sclk_hdmi_cec", "xin32k", 0, -- RK3368_CLKGATE_CON(5), 12, GFLAGS), -+ RK3368_CLKGATE_CON(4), 12, GFLAGS), - - COMPOSITE_NODIV(0, "vip_src", mux_pll_src_cpll_gpll_p, 0, - RK3368_CLKSEL_CON(21), 15, 1, MFLAGS, -diff --git a/drivers/clk/rockchip/clk.c b/drivers/clk/rockchip/clk.c -index be6c7fd..9b6c818 100644 ---- a/drivers/clk/rockchip/clk.c -+++ b/drivers/clk/rockchip/clk.c -@@ -70,7 +70,7 @@ static struct clk *rockchip_clk_register_branch(const char *name, - if (gate_offset >= 0) { - gate = kzalloc(sizeof(*gate), GFP_KERNEL); - if (!gate) -- return ERR_PTR(-ENOMEM); -+ goto err_gate; - - gate->flags = gate_flags; - gate->reg = base + gate_offset; -@@ -82,7 +82,7 @@ static struct clk *rockchip_clk_register_branch(const char *name, - if (div_width > 0) { - div = kzalloc(sizeof(*div), GFP_KERNEL); - if (!div) -- return ERR_PTR(-ENOMEM); -+ goto err_div; - - div->flags = div_flags; - div->reg = base + muxdiv_offset; -@@ -90,7 +90,9 @@ static struct clk *rockchip_clk_register_branch(const char *name, - div->width = div_width; - div->lock = lock; - div->table = div_table; -- div_ops = &clk_divider_ops; -+ div_ops = (div_flags & CLK_DIVIDER_READ_ONLY) -+ ? &clk_divider_ro_ops -+ : &clk_divider_ops; - } - - clk = clk_register_composite(NULL, name, parent_names, num_parents, -@@ -100,6 +102,11 @@ static struct clk *rockchip_clk_register_branch(const char *name, - flags); - - return clk; -+err_div: -+ kfree(gate); -+err_gate: -+ kfree(mux); -+ return ERR_PTR(-ENOMEM); - } - - static struct clk *rockchip_clk_register_frac_branch(const char *name, -diff --git a/drivers/clk/versatile/clk-sp810.c b/drivers/clk/versatile/clk-sp810.c -index a1cdef6..897c36c 100644 ---- a/drivers/clk/versatile/clk-sp810.c -+++ b/drivers/clk/versatile/clk-sp810.c -@@ -92,6 +92,7 @@ static void __init clk_sp810_of_setup(struct device_node *node) - int num = ARRAY_SIZE(parent_names); - char name[12]; - struct clk_init_data init; -+ static int instance; - int i; - bool deprecated; - -@@ -118,7 +119,7 @@ static void __init clk_sp810_of_setup(struct device_node *node) - deprecated = !of_find_property(node, "assigned-clock-parents", NULL); - - for (i = 0; i < ARRAY_SIZE(sp810->timerclken); i++) { -- snprintf(name, ARRAY_SIZE(name), "timerclken%d", i); -+ snprintf(name, sizeof(name), "sp810_%d_%d", instance, i); - - sp810->timerclken[i].sp810 = sp810; - sp810->timerclken[i].channel = i; -@@ -139,5 +140,6 @@ static void __init clk_sp810_of_setup(struct device_node *node) - } - - of_clk_add_provider(node, clk_sp810_timerclken_of_get, sp810); -+ instance++; - } - CLK_OF_DECLARE(sp810, "arm,sp810", clk_sp810_of_setup); -diff --git a/drivers/clocksource/tcb_clksrc.c b/drivers/clocksource/tcb_clksrc.c -index 7524941..5b6f57f 100644 ---- a/drivers/clocksource/tcb_clksrc.c -+++ b/drivers/clocksource/tcb_clksrc.c -@@ -73,6 +73,7 @@ static struct clocksource clksrc = { - struct tc_clkevt_device { - struct clock_event_device clkevt; - struct clk *clk; -+ bool clk_enabled; - u32 freq; - void __iomem *regs; - }; -@@ -84,6 +85,24 @@ static struct tc_clkevt_device *to_tc_clkevt(struct clock_event_device *clkevt) - - static u32 timer_clock; - -+static void tc_clk_disable(struct clock_event_device *d) -+{ -+ struct tc_clkevt_device *tcd = to_tc_clkevt(d); -+ -+ clk_disable(tcd->clk); -+ tcd->clk_enabled = false; -+} -+ -+static void tc_clk_enable(struct clock_event_device *d) -+{ -+ struct tc_clkevt_device *tcd = to_tc_clkevt(d); -+ -+ if (tcd->clk_enabled) -+ return; -+ clk_enable(tcd->clk); -+ tcd->clk_enabled = true; -+} -+ - static int tc_shutdown(struct clock_event_device *d) - { - struct tc_clkevt_device *tcd = to_tc_clkevt(d); -@@ -91,8 +110,14 @@ static int tc_shutdown(struct clock_event_device *d) - - __raw_writel(0xff, regs + ATMEL_TC_REG(2, IDR)); - __raw_writel(ATMEL_TC_CLKDIS, regs + ATMEL_TC_REG(2, CCR)); -+ return 0; -+} -+ -+static int tc_shutdown_clk_off(struct clock_event_device *d) -+{ -+ tc_shutdown(d); - if (!clockevent_state_detached(d)) -- clk_disable(tcd->clk); -+ tc_clk_disable(d); - - return 0; - } -@@ -105,7 +130,7 @@ static int tc_set_oneshot(struct clock_event_device *d) - if (clockevent_state_oneshot(d) || clockevent_state_periodic(d)) - tc_shutdown(d); - -- clk_enable(tcd->clk); -+ tc_clk_enable(d); - - /* count up to RC, then irq and stop */ - __raw_writel(timer_clock | ATMEL_TC_CPCSTOP | ATMEL_TC_WAVE | -@@ -127,7 +152,7 @@ static int tc_set_periodic(struct clock_event_device *d) - /* By not making the gentime core emulate periodic mode on top - * of oneshot, we get lower overhead and improved accuracy. - */ -- clk_enable(tcd->clk); -+ tc_clk_enable(d); - - /* count up to RC, then irq and restart */ - __raw_writel(timer_clock | ATMEL_TC_WAVE | ATMEL_TC_WAVESEL_UP_AUTO, -@@ -165,7 +190,7 @@ static struct tc_clkevt_device clkevt = { - .rating = 200, - #endif - .set_next_event = tc_next_event, -- .set_state_shutdown = tc_shutdown, -+ .set_state_shutdown = tc_shutdown_clk_off, - .set_state_periodic = tc_set_periodic, - .set_state_oneshot = tc_set_oneshot, - }, -diff --git a/drivers/clocksource/timer-atmel-pit.c b/drivers/clocksource/timer-atmel-pit.c -index a7abdb6..7a40f7e 100644 ---- a/drivers/clocksource/timer-atmel-pit.c -+++ b/drivers/clocksource/timer-atmel-pit.c -@@ -46,6 +46,7 @@ struct pit_data { - u32 cycle; - u32 cnt; - unsigned int irq; -+ bool irq_requested; - struct clk *mck; - }; - -@@ -96,7 +97,10 @@ static int pit_clkevt_shutdown(struct clock_event_device *dev) - - /* disable irq, leaving the clocksource active */ - pit_write(data->base, AT91_PIT_MR, (data->cycle - 1) | AT91_PIT_PITEN); -- free_irq(data->irq, data); -+ if (data->irq_requested) { -+ free_irq(data->irq, data); -+ data->irq_requested = false; -+ } - return 0; - } - -@@ -115,6 +119,8 @@ static int pit_clkevt_set_periodic(struct clock_event_device *dev) - if (ret) - panic(pr_fmt("Unable to setup IRQ\n")); - -+ data->irq_requested = true; -+ - /* update clocksource counter */ - data->cnt += data->cycle * PIT_PICNT(pit_read(data->base, AT91_PIT_PIVR)); - pit_write(data->base, AT91_PIT_MR, -diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c -index 98fb882..f53b02a 100644 ---- a/drivers/cpufreq/intel_pstate.c -+++ b/drivers/cpufreq/intel_pstate.c -@@ -667,6 +667,11 @@ static int core_get_max_pstate(void) - if (err) - goto skip_tar; - -+ /* For level 1 and 2, bits[23:16] contain the ratio */ -+ if (tdp_ctrl) -+ tdp_ratio >>= 16; -+ -+ tdp_ratio &= 0xff; /* ratios are only 8 bits long */ - if (tdp_ratio - 1 == tar) { - max_pstate = tar; - pr_debug("max_pstate=TAC %x\n", max_pstate); -diff --git a/drivers/cpuidle/cpuidle-arm.c b/drivers/cpuidle/cpuidle-arm.c -index 545069d..e342565 100644 ---- a/drivers/cpuidle/cpuidle-arm.c -+++ b/drivers/cpuidle/cpuidle-arm.c -@@ -50,7 +50,7 @@ static int arm_enter_idle_state(struct cpuidle_device *dev, - * call the CPU ops suspend protocol with idle index as a - * parameter. - */ -- arm_cpuidle_suspend(idx); -+ ret = arm_cpuidle_suspend(idx); - - cpu_pm_exit(); - } -diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c -index 17a6dc0..d40b2c0 100644 ---- a/drivers/cpuidle/cpuidle.c -+++ b/drivers/cpuidle/cpuidle.c -@@ -214,7 +214,7 @@ int cpuidle_enter_state(struct cpuidle_device *dev, struct cpuidle_driver *drv, - tick_broadcast_exit(); - } - -- if (!cpuidle_state_is_coupled(drv, entered_state)) -+ if (!cpuidle_state_is_coupled(drv, index)) - local_irq_enable(); - - diff = ktime_to_us(ktime_sub(time_end, time_start)); -@@ -433,6 +433,8 @@ static void __cpuidle_unregister_device(struct cpuidle_device *dev) - list_del(&dev->device_list); - per_cpu(cpuidle_devices, dev->cpu) = NULL; - module_put(drv->owner); -+ -+ dev->registered = 0; - } - - static void __cpuidle_device_init(struct cpuidle_device *dev) -diff --git a/drivers/crypto/atmel-aes.c b/drivers/crypto/atmel-aes.c -index fb16d81..1dffb13 100644 ---- a/drivers/crypto/atmel-aes.c -+++ b/drivers/crypto/atmel-aes.c -@@ -1396,9 +1396,9 @@ static int atmel_aes_probe(struct platform_device *pdev) - } - - aes_dd->io_base = devm_ioremap_resource(&pdev->dev, aes_res); -- if (!aes_dd->io_base) { -+ if (IS_ERR(aes_dd->io_base)) { - dev_err(dev, "can't ioremap\n"); -- err = -ENOMEM; -+ err = PTR_ERR(aes_dd->io_base); - goto res_err; - } - -diff --git a/drivers/crypto/atmel-sha.c b/drivers/crypto/atmel-sha.c -index 3178f84..0dadb63 100644 ---- a/drivers/crypto/atmel-sha.c -+++ b/drivers/crypto/atmel-sha.c -@@ -1405,9 +1405,9 @@ static int atmel_sha_probe(struct platform_device *pdev) - } - - sha_dd->io_base = devm_ioremap_resource(&pdev->dev, sha_res); -- if (!sha_dd->io_base) { -+ if (IS_ERR(sha_dd->io_base)) { - dev_err(dev, "can't ioremap\n"); -- err = -ENOMEM; -+ err = PTR_ERR(sha_dd->io_base); - goto res_err; - } - -diff --git a/drivers/crypto/atmel-tdes.c b/drivers/crypto/atmel-tdes.c -index 2c7a628..bf467d7 100644 ---- a/drivers/crypto/atmel-tdes.c -+++ b/drivers/crypto/atmel-tdes.c -@@ -1417,9 +1417,9 @@ static int atmel_tdes_probe(struct platform_device *pdev) - } - - tdes_dd->io_base = devm_ioremap_resource(&pdev->dev, tdes_res); -- if (!tdes_dd->io_base) { -+ if (IS_ERR(tdes_dd->io_base)) { - dev_err(dev, "can't ioremap\n"); -- err = -ENOMEM; -+ err = PTR_ERR(tdes_dd->io_base); - goto res_err; - } - -diff --git a/drivers/crypto/caam/jr.c b/drivers/crypto/caam/jr.c -index 2085cb5..efa8cad 100644 ---- a/drivers/crypto/caam/jr.c -+++ b/drivers/crypto/caam/jr.c -@@ -248,7 +248,7 @@ static void caam_jr_dequeue(unsigned long devarg) - struct device *caam_jr_alloc(void) - { - struct caam_drv_private_jr *jrpriv, *min_jrpriv = NULL; -- struct device *dev = NULL; -+ struct device *dev = ERR_PTR(-ENODEV); - int min_tfm_cnt = INT_MAX; - int tfm_cnt; - -diff --git a/drivers/crypto/ccp/ccp-crypto-aes-cmac.c b/drivers/crypto/ccp/ccp-crypto-aes-cmac.c -index d89f20c..60fc0fa 100644 ---- a/drivers/crypto/ccp/ccp-crypto-aes-cmac.c -+++ b/drivers/crypto/ccp/ccp-crypto-aes-cmac.c -@@ -220,6 +220,42 @@ static int ccp_aes_cmac_digest(struct ahash_request *req) - return ccp_aes_cmac_finup(req); - } - -+static int ccp_aes_cmac_export(struct ahash_request *req, void *out) -+{ -+ struct ccp_aes_cmac_req_ctx *rctx = ahash_request_ctx(req); -+ struct ccp_aes_cmac_exp_ctx state; -+ -+ /* Don't let anything leak to 'out' */ -+ memset(&state, 0, sizeof(state)); -+ -+ state.null_msg = rctx->null_msg; -+ memcpy(state.iv, rctx->iv, sizeof(state.iv)); -+ state.buf_count = rctx->buf_count; -+ memcpy(state.buf, rctx->buf, sizeof(state.buf)); -+ -+ /* 'out' may not be aligned so memcpy from local variable */ -+ memcpy(out, &state, sizeof(state)); -+ -+ return 0; -+} -+ -+static int ccp_aes_cmac_import(struct ahash_request *req, const void *in) -+{ -+ struct ccp_aes_cmac_req_ctx *rctx = ahash_request_ctx(req); -+ struct ccp_aes_cmac_exp_ctx state; -+ -+ /* 'in' may not be aligned so memcpy to local variable */ -+ memcpy(&state, in, sizeof(state)); -+ -+ memset(rctx, 0, sizeof(*rctx)); -+ rctx->null_msg = state.null_msg; -+ memcpy(rctx->iv, state.iv, sizeof(rctx->iv)); -+ rctx->buf_count = state.buf_count; -+ memcpy(rctx->buf, state.buf, sizeof(rctx->buf)); -+ -+ return 0; -+} -+ - static int ccp_aes_cmac_setkey(struct crypto_ahash *tfm, const u8 *key, - unsigned int key_len) - { -@@ -352,10 +388,13 @@ int ccp_register_aes_cmac_algs(struct list_head *head) - alg->final = ccp_aes_cmac_final; - alg->finup = ccp_aes_cmac_finup; - alg->digest = ccp_aes_cmac_digest; -+ alg->export = ccp_aes_cmac_export; -+ alg->import = ccp_aes_cmac_import; - alg->setkey = ccp_aes_cmac_setkey; - - halg = &alg->halg; - halg->digestsize = AES_BLOCK_SIZE; -+ halg->statesize = sizeof(struct ccp_aes_cmac_exp_ctx); - - base = &halg->base; - snprintf(base->cra_name, CRYPTO_MAX_ALG_NAME, "cmac(aes)"); -diff --git a/drivers/crypto/ccp/ccp-crypto-aes-xts.c b/drivers/crypto/ccp/ccp-crypto-aes-xts.c -index 52c7395..0d0d452 100644 ---- a/drivers/crypto/ccp/ccp-crypto-aes-xts.c -+++ b/drivers/crypto/ccp/ccp-crypto-aes-xts.c -@@ -122,6 +122,7 @@ static int ccp_aes_xts_crypt(struct ablkcipher_request *req, - struct ccp_ctx *ctx = crypto_tfm_ctx(req->base.tfm); - struct ccp_aes_req_ctx *rctx = ablkcipher_request_ctx(req); - unsigned int unit; -+ u32 unit_size; - int ret; - - if (!ctx->u.aes.key_len) -@@ -133,11 +134,17 @@ static int ccp_aes_xts_crypt(struct ablkcipher_request *req, - if (!req->info) - return -EINVAL; - -- for (unit = 0; unit < ARRAY_SIZE(unit_size_map); unit++) -- if (!(req->nbytes & (unit_size_map[unit].size - 1))) -- break; -+ unit_size = CCP_XTS_AES_UNIT_SIZE__LAST; -+ if (req->nbytes <= unit_size_map[0].size) { -+ for (unit = 0; unit < ARRAY_SIZE(unit_size_map); unit++) { -+ if (!(req->nbytes & (unit_size_map[unit].size - 1))) { -+ unit_size = unit_size_map[unit].value; -+ break; -+ } -+ } -+ } - -- if ((unit_size_map[unit].value == CCP_XTS_AES_UNIT_SIZE__LAST) || -+ if ((unit_size == CCP_XTS_AES_UNIT_SIZE__LAST) || - (ctx->u.aes.key_len != AES_KEYSIZE_128)) { - /* Use the fallback to process the request for any - * unsupported unit sizes or key sizes -@@ -158,7 +165,7 @@ static int ccp_aes_xts_crypt(struct ablkcipher_request *req, - rctx->cmd.engine = CCP_ENGINE_XTS_AES_128; - rctx->cmd.u.xts.action = (encrypt) ? CCP_AES_ACTION_ENCRYPT - : CCP_AES_ACTION_DECRYPT; -- rctx->cmd.u.xts.unit_size = unit_size_map[unit].value; -+ rctx->cmd.u.xts.unit_size = unit_size; - rctx->cmd.u.xts.key = &ctx->u.aes.key_sg; - rctx->cmd.u.xts.key_len = ctx->u.aes.key_len; - rctx->cmd.u.xts.iv = &rctx->iv_sg; -diff --git a/drivers/crypto/ccp/ccp-crypto-sha.c b/drivers/crypto/ccp/ccp-crypto-sha.c -index d14b3f2..ab9945f 100644 ---- a/drivers/crypto/ccp/ccp-crypto-sha.c -+++ b/drivers/crypto/ccp/ccp-crypto-sha.c -@@ -207,6 +207,46 @@ static int ccp_sha_digest(struct ahash_request *req) - return ccp_sha_finup(req); - } - -+static int ccp_sha_export(struct ahash_request *req, void *out) -+{ -+ struct ccp_sha_req_ctx *rctx = ahash_request_ctx(req); -+ struct ccp_sha_exp_ctx state; -+ -+ /* Don't let anything leak to 'out' */ -+ memset(&state, 0, sizeof(state)); -+ -+ state.type = rctx->type; -+ state.msg_bits = rctx->msg_bits; -+ state.first = rctx->first; -+ memcpy(state.ctx, rctx->ctx, sizeof(state.ctx)); -+ state.buf_count = rctx->buf_count; -+ memcpy(state.buf, rctx->buf, sizeof(state.buf)); -+ -+ /* 'out' may not be aligned so memcpy from local variable */ -+ memcpy(out, &state, sizeof(state)); -+ -+ return 0; -+} -+ -+static int ccp_sha_import(struct ahash_request *req, const void *in) -+{ -+ struct ccp_sha_req_ctx *rctx = ahash_request_ctx(req); -+ struct ccp_sha_exp_ctx state; -+ -+ /* 'in' may not be aligned so memcpy to local variable */ -+ memcpy(&state, in, sizeof(state)); -+ -+ memset(rctx, 0, sizeof(*rctx)); -+ rctx->type = state.type; -+ rctx->msg_bits = state.msg_bits; -+ rctx->first = state.first; -+ memcpy(rctx->ctx, state.ctx, sizeof(rctx->ctx)); -+ rctx->buf_count = state.buf_count; -+ memcpy(rctx->buf, state.buf, sizeof(rctx->buf)); -+ -+ return 0; -+} -+ - static int ccp_sha_setkey(struct crypto_ahash *tfm, const u8 *key, - unsigned int key_len) - { -@@ -403,9 +443,12 @@ static int ccp_register_sha_alg(struct list_head *head, - alg->final = ccp_sha_final; - alg->finup = ccp_sha_finup; - alg->digest = ccp_sha_digest; -+ alg->export = ccp_sha_export; -+ alg->import = ccp_sha_import; - - halg = &alg->halg; - halg->digestsize = def->digest_size; -+ halg->statesize = sizeof(struct ccp_sha_exp_ctx); - - base = &halg->base; - snprintf(base->cra_name, CRYPTO_MAX_ALG_NAME, "%s", def->name); -diff --git a/drivers/crypto/ccp/ccp-crypto.h b/drivers/crypto/ccp/ccp-crypto.h -index 76a96f0..a326ec2 100644 ---- a/drivers/crypto/ccp/ccp-crypto.h -+++ b/drivers/crypto/ccp/ccp-crypto.h -@@ -129,6 +129,15 @@ struct ccp_aes_cmac_req_ctx { - struct ccp_cmd cmd; - }; - -+struct ccp_aes_cmac_exp_ctx { -+ unsigned int null_msg; -+ -+ u8 iv[AES_BLOCK_SIZE]; -+ -+ unsigned int buf_count; -+ u8 buf[AES_BLOCK_SIZE]; -+}; -+ - /***** SHA related defines *****/ - #define MAX_SHA_CONTEXT_SIZE SHA256_DIGEST_SIZE - #define MAX_SHA_BLOCK_SIZE SHA256_BLOCK_SIZE -@@ -171,6 +180,19 @@ struct ccp_sha_req_ctx { - struct ccp_cmd cmd; - }; - -+struct ccp_sha_exp_ctx { -+ enum ccp_sha_type type; -+ -+ u64 msg_bits; -+ -+ unsigned int first; -+ -+ u8 ctx[MAX_SHA_CONTEXT_SIZE]; -+ -+ unsigned int buf_count; -+ u8 buf[MAX_SHA_BLOCK_SIZE]; -+}; -+ - /***** Common Context Structure *****/ - struct ccp_ctx { - int (*complete)(struct crypto_async_request *req, int ret); -diff --git a/drivers/crypto/marvell/cesa.c b/drivers/crypto/marvell/cesa.c -index c0656e7..80239ae 100644 ---- a/drivers/crypto/marvell/cesa.c -+++ b/drivers/crypto/marvell/cesa.c -@@ -420,7 +420,7 @@ static int mv_cesa_probe(struct platform_device *pdev) - res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "regs"); - cesa->regs = devm_ioremap_resource(dev, res); - if (IS_ERR(cesa->regs)) -- return -ENOMEM; -+ return PTR_ERR(cesa->regs); - - ret = mv_cesa_dev_dma_init(cesa); - if (ret) -diff --git a/drivers/crypto/qat/qat_common/adf_common_drv.h b/drivers/crypto/qat/qat_common/adf_common_drv.h -index 3f76bd4..aa1dbea 100644 ---- a/drivers/crypto/qat/qat_common/adf_common_drv.h -+++ b/drivers/crypto/qat/qat_common/adf_common_drv.h -@@ -227,6 +227,8 @@ void adf_disable_vf2pf_interrupts(struct adf_accel_dev *accel_dev, - uint32_t vf_mask); - void adf_enable_vf2pf_interrupts(struct adf_accel_dev *accel_dev, - uint32_t vf_mask); -+int adf_init_pf_wq(void); -+void adf_exit_pf_wq(void); - #else - static inline int adf_sriov_configure(struct pci_dev *pdev, int numvfs) - { -@@ -236,5 +238,14 @@ static inline int adf_sriov_configure(struct pci_dev *pdev, int numvfs) - static inline void adf_disable_sriov(struct adf_accel_dev *accel_dev) - { - } -+ -+static inline int adf_init_pf_wq(void) -+{ -+ return 0; -+} -+ -+static inline void adf_exit_pf_wq(void) -+{ -+} - #endif - #endif -diff --git a/drivers/crypto/qat/qat_common/adf_ctl_drv.c b/drivers/crypto/qat/qat_common/adf_ctl_drv.c -index 473d36d..e7480f3 100644 ---- a/drivers/crypto/qat/qat_common/adf_ctl_drv.c -+++ b/drivers/crypto/qat/qat_common/adf_ctl_drv.c -@@ -469,12 +469,17 @@ static int __init adf_register_ctl_device_driver(void) - if (adf_init_aer()) - goto err_aer; - -+ if (adf_init_pf_wq()) -+ goto err_pf_wq; -+ - if (qat_crypto_register()) - goto err_crypto_register; - - return 0; - - err_crypto_register: -+ adf_exit_pf_wq(); -+err_pf_wq: - adf_exit_aer(); - err_aer: - adf_chr_drv_destroy(); -@@ -487,6 +492,7 @@ static void __exit adf_unregister_ctl_device_driver(void) - { - adf_chr_drv_destroy(); - adf_exit_aer(); -+ adf_exit_pf_wq(); - qat_crypto_unregister(); - adf_clean_vf_map(false); - mutex_destroy(&adf_ctl_lock); -diff --git a/drivers/crypto/qat/qat_common/adf_sriov.c b/drivers/crypto/qat/qat_common/adf_sriov.c -index 1117a8b..38a0415 100644 ---- a/drivers/crypto/qat/qat_common/adf_sriov.c -+++ b/drivers/crypto/qat/qat_common/adf_sriov.c -@@ -119,11 +119,6 @@ static int adf_enable_sriov(struct adf_accel_dev *accel_dev) - int i; - u32 reg; - -- /* Workqueue for PF2VF responses */ -- pf2vf_resp_wq = create_workqueue("qat_pf2vf_resp_wq"); -- if (!pf2vf_resp_wq) -- return -ENOMEM; -- - for (i = 0, vf_info = accel_dev->pf.vf_info; i < totalvfs; - i++, vf_info++) { - /* This ptr will be populated when VFs will be created */ -@@ -216,11 +211,6 @@ void adf_disable_sriov(struct adf_accel_dev *accel_dev) - - kfree(accel_dev->pf.vf_info); - accel_dev->pf.vf_info = NULL; -- -- if (pf2vf_resp_wq) { -- destroy_workqueue(pf2vf_resp_wq); -- pf2vf_resp_wq = NULL; -- } - } - EXPORT_SYMBOL_GPL(adf_disable_sriov); - -@@ -304,3 +294,19 @@ int adf_sriov_configure(struct pci_dev *pdev, int numvfs) - return numvfs; - } - EXPORT_SYMBOL_GPL(adf_sriov_configure); -+ -+int __init adf_init_pf_wq(void) -+{ -+ /* Workqueue for PF2VF responses */ -+ pf2vf_resp_wq = create_workqueue("qat_pf2vf_resp_wq"); -+ -+ return !pf2vf_resp_wq ? -ENOMEM : 0; -+} -+ -+void adf_exit_pf_wq(void) -+{ -+ if (pf2vf_resp_wq) { -+ destroy_workqueue(pf2vf_resp_wq); -+ pf2vf_resp_wq = NULL; -+ } -+} -diff --git a/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c b/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c -index a19ee12..e72fea7 100644 ---- a/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c -+++ b/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c -@@ -35,6 +35,7 @@ static int sun4i_ss_opti_poll(struct ablkcipher_request *areq) - unsigned int todo; - struct sg_mapping_iter mi, mo; - unsigned int oi, oo; /* offset for in and out */ -+ unsigned long flags; - - if (areq->nbytes == 0) - return 0; -@@ -49,7 +50,7 @@ static int sun4i_ss_opti_poll(struct ablkcipher_request *areq) - return -EINVAL; - } - -- spin_lock_bh(&ss->slock); -+ spin_lock_irqsave(&ss->slock, flags); - - for (i = 0; i < op->keylen; i += 4) - writel(*(op->key + i / 4), ss->base + SS_KEY0 + i); -@@ -117,7 +118,7 @@ release_ss: - sg_miter_stop(&mi); - sg_miter_stop(&mo); - writel(0, ss->base + SS_CTL); -- spin_unlock_bh(&ss->slock); -+ spin_unlock_irqrestore(&ss->slock, flags); - return err; - } - -@@ -149,6 +150,7 @@ static int sun4i_ss_cipher_poll(struct ablkcipher_request *areq) - unsigned int ob = 0; /* offset in buf */ - unsigned int obo = 0; /* offset in bufo*/ - unsigned int obl = 0; /* length of data in bufo */ -+ unsigned long flags; - - if (areq->nbytes == 0) - return 0; -@@ -181,7 +183,7 @@ static int sun4i_ss_cipher_poll(struct ablkcipher_request *areq) - if (no_chunk == 1) - return sun4i_ss_opti_poll(areq); - -- spin_lock_bh(&ss->slock); -+ spin_lock_irqsave(&ss->slock, flags); - - for (i = 0; i < op->keylen; i += 4) - writel(*(op->key + i / 4), ss->base + SS_KEY0 + i); -@@ -308,7 +310,7 @@ release_ss: - sg_miter_stop(&mi); - sg_miter_stop(&mo); - writel(0, ss->base + SS_CTL); -- spin_unlock_bh(&ss->slock); -+ spin_unlock_irqrestore(&ss->slock, flags); - - return err; - } -diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c -index b6f9f42..9a8a18a 100644 ---- a/drivers/crypto/talitos.c -+++ b/drivers/crypto/talitos.c -@@ -63,6 +63,14 @@ static void to_talitos_ptr(struct talitos_ptr *ptr, dma_addr_t dma_addr, - ptr->eptr = upper_32_bits(dma_addr); - } - -+static void copy_talitos_ptr(struct talitos_ptr *dst_ptr, -+ struct talitos_ptr *src_ptr, bool is_sec1) -+{ -+ dst_ptr->ptr = src_ptr->ptr; -+ if (!is_sec1) -+ dst_ptr->eptr = src_ptr->eptr; -+} -+ - static void to_talitos_ptr_len(struct talitos_ptr *ptr, unsigned int len, - bool is_sec1) - { -@@ -827,6 +835,16 @@ struct talitos_ahash_req_ctx { - struct scatterlist *psrc; - }; - -+struct talitos_export_state { -+ u32 hw_context[TALITOS_MDEU_MAX_CONTEXT_SIZE / sizeof(u32)]; -+ u8 buf[HASH_MAX_BLOCK_SIZE]; -+ unsigned int swinit; -+ unsigned int first; -+ unsigned int last; -+ unsigned int to_hash_later; -+ unsigned int nbuf; -+}; -+ - static int aead_setkey(struct crypto_aead *authenc, - const u8 *key, unsigned int keylen) - { -@@ -1083,21 +1101,20 @@ static int ipsec_esp(struct talitos_edesc *edesc, struct aead_request *areq, - sg_count = dma_map_sg(dev, areq->src, edesc->src_nents ?: 1, - (areq->src == areq->dst) ? DMA_BIDIRECTIONAL - : DMA_TO_DEVICE); -- - /* hmac data */ - desc->ptr[1].len = cpu_to_be16(areq->assoclen); - if (sg_count > 1 && - (ret = sg_to_link_tbl_offset(areq->src, sg_count, 0, - areq->assoclen, - &edesc->link_tbl[tbl_off])) > 1) { -- tbl_off += ret; -- - to_talitos_ptr(&desc->ptr[1], edesc->dma_link_tbl + tbl_off * - sizeof(struct talitos_ptr), 0); - desc->ptr[1].j_extent = DESC_PTR_LNKTBL_JUMP; - - dma_sync_single_for_device(dev, edesc->dma_link_tbl, - edesc->dma_len, DMA_BIDIRECTIONAL); -+ -+ tbl_off += ret; - } else { - to_talitos_ptr(&desc->ptr[1], sg_dma_address(areq->src), 0); - desc->ptr[1].j_extent = 0; -@@ -1126,11 +1143,13 @@ static int ipsec_esp(struct talitos_edesc *edesc, struct aead_request *areq, - if (edesc->desc.hdr & DESC_HDR_MODE1_MDEU_CICV) - sg_link_tbl_len += authsize; - -- if (sg_count > 1 && -- (ret = sg_to_link_tbl_offset(areq->src, sg_count, areq->assoclen, -- sg_link_tbl_len, -- &edesc->link_tbl[tbl_off])) > 1) { -- tbl_off += ret; -+ if (sg_count == 1) { -+ to_talitos_ptr(&desc->ptr[4], sg_dma_address(areq->src) + -+ areq->assoclen, 0); -+ } else if ((ret = sg_to_link_tbl_offset(areq->src, sg_count, -+ areq->assoclen, sg_link_tbl_len, -+ &edesc->link_tbl[tbl_off])) > -+ 1) { - desc->ptr[4].j_extent |= DESC_PTR_LNKTBL_JUMP; - to_talitos_ptr(&desc->ptr[4], edesc->dma_link_tbl + - tbl_off * -@@ -1138,8 +1157,10 @@ static int ipsec_esp(struct talitos_edesc *edesc, struct aead_request *areq, - dma_sync_single_for_device(dev, edesc->dma_link_tbl, - edesc->dma_len, - DMA_BIDIRECTIONAL); -- } else -- to_talitos_ptr(&desc->ptr[4], sg_dma_address(areq->src), 0); -+ tbl_off += ret; -+ } else { -+ copy_talitos_ptr(&desc->ptr[4], &edesc->link_tbl[tbl_off], 0); -+ } - - /* cipher out */ - desc->ptr[5].len = cpu_to_be16(cryptlen); -@@ -1151,11 +1172,13 @@ static int ipsec_esp(struct talitos_edesc *edesc, struct aead_request *areq, - - edesc->icv_ool = false; - -- if (sg_count > 1 && -- (sg_count = sg_to_link_tbl_offset(areq->dst, sg_count, -+ if (sg_count == 1) { -+ to_talitos_ptr(&desc->ptr[5], sg_dma_address(areq->dst) + -+ areq->assoclen, 0); -+ } else if ((sg_count = -+ sg_to_link_tbl_offset(areq->dst, sg_count, - areq->assoclen, cryptlen, -- &edesc->link_tbl[tbl_off])) > -- 1) { -+ &edesc->link_tbl[tbl_off])) > 1) { - struct talitos_ptr *tbl_ptr = &edesc->link_tbl[tbl_off]; - - to_talitos_ptr(&desc->ptr[5], edesc->dma_link_tbl + -@@ -1178,8 +1201,9 @@ static int ipsec_esp(struct talitos_edesc *edesc, struct aead_request *areq, - edesc->dma_len, DMA_BIDIRECTIONAL); - - edesc->icv_ool = true; -- } else -- to_talitos_ptr(&desc->ptr[5], sg_dma_address(areq->dst), 0); -+ } else { -+ copy_talitos_ptr(&desc->ptr[5], &edesc->link_tbl[tbl_off], 0); -+ } - - /* iv out */ - map_single_talitos_ptr(dev, &desc->ptr[6], ivsize, ctx->iv, -@@ -1940,6 +1964,46 @@ static int ahash_digest(struct ahash_request *areq) - return ahash_process_req(areq, areq->nbytes); - } - -+static int ahash_export(struct ahash_request *areq, void *out) -+{ -+ struct talitos_ahash_req_ctx *req_ctx = ahash_request_ctx(areq); -+ struct talitos_export_state *export = out; -+ -+ memcpy(export->hw_context, req_ctx->hw_context, -+ req_ctx->hw_context_size); -+ memcpy(export->buf, req_ctx->buf, req_ctx->nbuf); -+ export->swinit = req_ctx->swinit; -+ export->first = req_ctx->first; -+ export->last = req_ctx->last; -+ export->to_hash_later = req_ctx->to_hash_later; -+ export->nbuf = req_ctx->nbuf; -+ -+ return 0; -+} -+ -+static int ahash_import(struct ahash_request *areq, const void *in) -+{ -+ struct talitos_ahash_req_ctx *req_ctx = ahash_request_ctx(areq); -+ struct crypto_ahash *tfm = crypto_ahash_reqtfm(areq); -+ const struct talitos_export_state *export = in; -+ -+ memset(req_ctx, 0, sizeof(*req_ctx)); -+ req_ctx->hw_context_size = -+ (crypto_ahash_digestsize(tfm) <= SHA256_DIGEST_SIZE) -+ ? TALITOS_MDEU_CONTEXT_SIZE_MD5_SHA1_SHA256 -+ : TALITOS_MDEU_CONTEXT_SIZE_SHA384_SHA512; -+ memcpy(req_ctx->hw_context, export->hw_context, -+ req_ctx->hw_context_size); -+ memcpy(req_ctx->buf, export->buf, export->nbuf); -+ req_ctx->swinit = export->swinit; -+ req_ctx->first = export->first; -+ req_ctx->last = export->last; -+ req_ctx->to_hash_later = export->to_hash_later; -+ req_ctx->nbuf = export->nbuf; -+ -+ return 0; -+} -+ - struct keyhash_result { - struct completion completion; - int err; -@@ -2334,6 +2398,7 @@ static struct talitos_alg_template driver_algs[] = { - { .type = CRYPTO_ALG_TYPE_AHASH, - .alg.hash = { - .halg.digestsize = MD5_DIGEST_SIZE, -+ .halg.statesize = sizeof(struct talitos_export_state), - .halg.base = { - .cra_name = "md5", - .cra_driver_name = "md5-talitos", -@@ -2349,6 +2414,7 @@ static struct talitos_alg_template driver_algs[] = { - { .type = CRYPTO_ALG_TYPE_AHASH, - .alg.hash = { - .halg.digestsize = SHA1_DIGEST_SIZE, -+ .halg.statesize = sizeof(struct talitos_export_state), - .halg.base = { - .cra_name = "sha1", - .cra_driver_name = "sha1-talitos", -@@ -2364,6 +2430,7 @@ static struct talitos_alg_template driver_algs[] = { - { .type = CRYPTO_ALG_TYPE_AHASH, - .alg.hash = { - .halg.digestsize = SHA224_DIGEST_SIZE, -+ .halg.statesize = sizeof(struct talitos_export_state), - .halg.base = { - .cra_name = "sha224", - .cra_driver_name = "sha224-talitos", -@@ -2379,6 +2446,7 @@ static struct talitos_alg_template driver_algs[] = { - { .type = CRYPTO_ALG_TYPE_AHASH, - .alg.hash = { - .halg.digestsize = SHA256_DIGEST_SIZE, -+ .halg.statesize = sizeof(struct talitos_export_state), - .halg.base = { - .cra_name = "sha256", - .cra_driver_name = "sha256-talitos", -@@ -2394,6 +2462,7 @@ static struct talitos_alg_template driver_algs[] = { - { .type = CRYPTO_ALG_TYPE_AHASH, - .alg.hash = { - .halg.digestsize = SHA384_DIGEST_SIZE, -+ .halg.statesize = sizeof(struct talitos_export_state), - .halg.base = { - .cra_name = "sha384", - .cra_driver_name = "sha384-talitos", -@@ -2409,6 +2478,7 @@ static struct talitos_alg_template driver_algs[] = { - { .type = CRYPTO_ALG_TYPE_AHASH, - .alg.hash = { - .halg.digestsize = SHA512_DIGEST_SIZE, -+ .halg.statesize = sizeof(struct talitos_export_state), - .halg.base = { - .cra_name = "sha512", - .cra_driver_name = "sha512-talitos", -@@ -2424,6 +2494,7 @@ static struct talitos_alg_template driver_algs[] = { - { .type = CRYPTO_ALG_TYPE_AHASH, - .alg.hash = { - .halg.digestsize = MD5_DIGEST_SIZE, -+ .halg.statesize = sizeof(struct talitos_export_state), - .halg.base = { - .cra_name = "hmac(md5)", - .cra_driver_name = "hmac-md5-talitos", -@@ -2439,6 +2510,7 @@ static struct talitos_alg_template driver_algs[] = { - { .type = CRYPTO_ALG_TYPE_AHASH, - .alg.hash = { - .halg.digestsize = SHA1_DIGEST_SIZE, -+ .halg.statesize = sizeof(struct talitos_export_state), - .halg.base = { - .cra_name = "hmac(sha1)", - .cra_driver_name = "hmac-sha1-talitos", -@@ -2454,6 +2526,7 @@ static struct talitos_alg_template driver_algs[] = { - { .type = CRYPTO_ALG_TYPE_AHASH, - .alg.hash = { - .halg.digestsize = SHA224_DIGEST_SIZE, -+ .halg.statesize = sizeof(struct talitos_export_state), - .halg.base = { - .cra_name = "hmac(sha224)", - .cra_driver_name = "hmac-sha224-talitos", -@@ -2469,6 +2542,7 @@ static struct talitos_alg_template driver_algs[] = { - { .type = CRYPTO_ALG_TYPE_AHASH, - .alg.hash = { - .halg.digestsize = SHA256_DIGEST_SIZE, -+ .halg.statesize = sizeof(struct talitos_export_state), - .halg.base = { - .cra_name = "hmac(sha256)", - .cra_driver_name = "hmac-sha256-talitos", -@@ -2484,6 +2558,7 @@ static struct talitos_alg_template driver_algs[] = { - { .type = CRYPTO_ALG_TYPE_AHASH, - .alg.hash = { - .halg.digestsize = SHA384_DIGEST_SIZE, -+ .halg.statesize = sizeof(struct talitos_export_state), - .halg.base = { - .cra_name = "hmac(sha384)", - .cra_driver_name = "hmac-sha384-talitos", -@@ -2499,6 +2574,7 @@ static struct talitos_alg_template driver_algs[] = { - { .type = CRYPTO_ALG_TYPE_AHASH, - .alg.hash = { - .halg.digestsize = SHA512_DIGEST_SIZE, -+ .halg.statesize = sizeof(struct talitos_export_state), - .halg.base = { - .cra_name = "hmac(sha512)", - .cra_driver_name = "hmac-sha512-talitos", -@@ -2519,21 +2595,11 @@ struct talitos_crypto_alg { - struct talitos_alg_template algt; - }; - --static int talitos_cra_init(struct crypto_tfm *tfm) -+static int talitos_init_common(struct talitos_ctx *ctx, -+ struct talitos_crypto_alg *talitos_alg) - { -- struct crypto_alg *alg = tfm->__crt_alg; -- struct talitos_crypto_alg *talitos_alg; -- struct talitos_ctx *ctx = crypto_tfm_ctx(tfm); - struct talitos_private *priv; - -- if ((alg->cra_flags & CRYPTO_ALG_TYPE_MASK) == CRYPTO_ALG_TYPE_AHASH) -- talitos_alg = container_of(__crypto_ahash_alg(alg), -- struct talitos_crypto_alg, -- algt.alg.hash); -- else -- talitos_alg = container_of(alg, struct talitos_crypto_alg, -- algt.alg.crypto); -- - /* update context with ptr to dev */ - ctx->dev = talitos_alg->dev; - -@@ -2551,10 +2617,33 @@ static int talitos_cra_init(struct crypto_tfm *tfm) - return 0; - } - -+static int talitos_cra_init(struct crypto_tfm *tfm) -+{ -+ struct crypto_alg *alg = tfm->__crt_alg; -+ struct talitos_crypto_alg *talitos_alg; -+ struct talitos_ctx *ctx = crypto_tfm_ctx(tfm); -+ -+ if ((alg->cra_flags & CRYPTO_ALG_TYPE_MASK) == CRYPTO_ALG_TYPE_AHASH) -+ talitos_alg = container_of(__crypto_ahash_alg(alg), -+ struct talitos_crypto_alg, -+ algt.alg.hash); -+ else -+ talitos_alg = container_of(alg, struct talitos_crypto_alg, -+ algt.alg.crypto); -+ -+ return talitos_init_common(ctx, talitos_alg); -+} -+ - static int talitos_cra_init_aead(struct crypto_aead *tfm) - { -- talitos_cra_init(crypto_aead_tfm(tfm)); -- return 0; -+ struct aead_alg *alg = crypto_aead_alg(tfm); -+ struct talitos_crypto_alg *talitos_alg; -+ struct talitos_ctx *ctx = crypto_aead_ctx(tfm); -+ -+ talitos_alg = container_of(alg, struct talitos_crypto_alg, -+ algt.alg.aead); -+ -+ return talitos_init_common(ctx, talitos_alg); - } - - static int talitos_cra_init_ahash(struct crypto_tfm *tfm) -@@ -2677,6 +2766,8 @@ static struct talitos_crypto_alg *talitos_alg_alloc(struct device *dev, - t_alg->algt.alg.hash.finup = ahash_finup; - t_alg->algt.alg.hash.digest = ahash_digest; - t_alg->algt.alg.hash.setkey = ahash_setkey; -+ t_alg->algt.alg.hash.import = ahash_import; -+ t_alg->algt.alg.hash.export = ahash_export; - - if (!(priv->features & TALITOS_FTR_HMAC_OK) && - !strncmp(alg->cra_name, "hmac", 4)) { -diff --git a/drivers/crypto/ux500/cryp/cryp_core.c b/drivers/crypto/ux500/cryp/cryp_core.c -index 4c243c1..790f7ca 100644 ---- a/drivers/crypto/ux500/cryp/cryp_core.c -+++ b/drivers/crypto/ux500/cryp/cryp_core.c -@@ -1440,9 +1440,9 @@ static int ux500_cryp_probe(struct platform_device *pdev) - - device_data->phybase = res->start; - device_data->base = devm_ioremap_resource(dev, res); -- if (!device_data->base) { -+ if (IS_ERR(device_data->base)) { - dev_err(dev, "[%s]: ioremap failed!", __func__); -- ret = -ENOMEM; -+ ret = PTR_ERR(device_data->base); - goto out; - } - -diff --git a/drivers/crypto/ux500/hash/hash_core.c b/drivers/crypto/ux500/hash/hash_core.c -index f47d112..66b1c33 100644 ---- a/drivers/crypto/ux500/hash/hash_core.c -+++ b/drivers/crypto/ux500/hash/hash_core.c -@@ -1675,9 +1675,9 @@ static int ux500_hash_probe(struct platform_device *pdev) - - device_data->phybase = res->start; - device_data->base = devm_ioremap_resource(dev, res); -- if (!device_data->base) { -+ if (IS_ERR(device_data->base)) { - dev_err(dev, "%s: ioremap() failed!\n", __func__); -- ret = -ENOMEM; -+ ret = PTR_ERR(device_data->base); - goto out; - } - spin_lock_init(&device_data->ctx_lock); -diff --git a/drivers/dma/dw/core.c b/drivers/dma/dw/core.c -index 4f099ea..c66133b 100644 ---- a/drivers/dma/dw/core.c -+++ b/drivers/dma/dw/core.c -@@ -130,26 +130,14 @@ static void dwc_desc_put(struct dw_dma_chan *dwc, struct dw_desc *desc) - static void dwc_initialize(struct dw_dma_chan *dwc) - { - struct dw_dma *dw = to_dw_dma(dwc->chan.device); -- struct dw_dma_slave *dws = dwc->chan.private; - u32 cfghi = DWC_CFGH_FIFO_MODE; - u32 cfglo = DWC_CFGL_CH_PRIOR(dwc->priority); - - if (dwc->initialized == true) - return; - -- if (dws) { -- /* -- * We need controller-specific data to set up slave -- * transfers. -- */ -- BUG_ON(!dws->dma_dev || dws->dma_dev != dw->dma.dev); -- -- cfghi |= DWC_CFGH_DST_PER(dws->dst_id); -- cfghi |= DWC_CFGH_SRC_PER(dws->src_id); -- } else { -- cfghi |= DWC_CFGH_DST_PER(dwc->dst_id); -- cfghi |= DWC_CFGH_SRC_PER(dwc->src_id); -- } -+ cfghi |= DWC_CFGH_DST_PER(dwc->dst_id); -+ cfghi |= DWC_CFGH_SRC_PER(dwc->src_id); - - channel_writel(dwc, CFG_LO, cfglo); - channel_writel(dwc, CFG_HI, cfghi); -@@ -936,7 +924,7 @@ bool dw_dma_filter(struct dma_chan *chan, void *param) - struct dw_dma_chan *dwc = to_dw_dma_chan(chan); - struct dw_dma_slave *dws = param; - -- if (!dws || dws->dma_dev != chan->device->dev) -+ if (dws->dma_dev != chan->device->dev) - return false; - - /* We have to copy data since dws can be temporary storage */ -@@ -1160,6 +1148,14 @@ static int dwc_alloc_chan_resources(struct dma_chan *chan) - * doesn't mean what you think it means), and status writeback. - */ - -+ /* -+ * We need controller-specific data to set up slave transfers. -+ */ -+ if (chan->private && !dw_dma_filter(chan, chan->private)) { -+ dev_warn(chan2dev(chan), "Wrong controller-specific data\n"); -+ return -EINVAL; -+ } -+ - /* Enable controller here if needed */ - if (!dw->in_use) - dw_dma_on(dw); -@@ -1221,6 +1217,14 @@ static void dwc_free_chan_resources(struct dma_chan *chan) - spin_lock_irqsave(&dwc->lock, flags); - list_splice_init(&dwc->free_list, &list); - dwc->descs_allocated = 0; -+ -+ /* Clear custom channel configuration */ -+ dwc->src_id = 0; -+ dwc->dst_id = 0; -+ -+ dwc->src_master = 0; -+ dwc->dst_master = 0; -+ - dwc->initialized = false; - - /* Disable interrupts */ -diff --git a/drivers/dma/hsu/hsu.c b/drivers/dma/hsu/hsu.c -index 823ad72..efc02b9 100644 ---- a/drivers/dma/hsu/hsu.c -+++ b/drivers/dma/hsu/hsu.c -@@ -135,7 +135,7 @@ static u32 hsu_dma_chan_get_sr(struct hsu_dma_chan *hsuc) - sr = hsu_chan_readl(hsuc, HSU_CH_SR); - spin_unlock_irqrestore(&hsuc->vchan.lock, flags); - -- return sr; -+ return sr & ~(HSU_CH_SR_DESCE_ANY | HSU_CH_SR_CDESC_ANY); - } - - irqreturn_t hsu_dma_irq(struct hsu_dma_chip *chip, unsigned short nr) -diff --git a/drivers/dma/hsu/hsu.h b/drivers/dma/hsu/hsu.h -index f06579c..26da286 100644 ---- a/drivers/dma/hsu/hsu.h -+++ b/drivers/dma/hsu/hsu.h -@@ -41,6 +41,9 @@ - #define HSU_CH_SR_DESCTO(x) BIT(8 + (x)) - #define HSU_CH_SR_DESCTO_ANY (BIT(11) | BIT(10) | BIT(9) | BIT(8)) - #define HSU_CH_SR_CHE BIT(15) -+#define HSU_CH_SR_DESCE(x) BIT(16 + (x)) -+#define HSU_CH_SR_DESCE_ANY (BIT(19) | BIT(18) | BIT(17) | BIT(16)) -+#define HSU_CH_SR_CDESC_ANY (BIT(31) | BIT(30)) - - /* Bits in HSU_CH_CR */ - #define HSU_CH_CR_CHA BIT(0) -diff --git a/drivers/dma/pxa_dma.c b/drivers/dma/pxa_dma.c -index a59061e..55f5d33 100644 ---- a/drivers/dma/pxa_dma.c -+++ b/drivers/dma/pxa_dma.c -@@ -122,6 +122,7 @@ struct pxad_chan { - struct pxad_device { - struct dma_device slave; - int nr_chans; -+ int nr_requestors; - void __iomem *base; - struct pxad_phy *phys; - spinlock_t phy_lock; /* Phy association */ -@@ -473,7 +474,7 @@ static void pxad_free_phy(struct pxad_chan *chan) - return; - - /* clear the channel mapping in DRCMR */ -- if (chan->drcmr <= DRCMR_CHLNUM) { -+ if (chan->drcmr <= pdev->nr_requestors) { - reg = pxad_drcmr(chan->drcmr); - writel_relaxed(0, chan->phy->base + reg); - } -@@ -509,6 +510,7 @@ static bool is_running_chan_misaligned(struct pxad_chan *chan) - - static void phy_enable(struct pxad_phy *phy, bool misaligned) - { -+ struct pxad_device *pdev; - u32 reg, dalgn; - - if (!phy->vchan) -@@ -518,7 +520,8 @@ static void phy_enable(struct pxad_phy *phy, bool misaligned) - "%s(); phy=%p(%d) misaligned=%d\n", __func__, - phy, phy->idx, misaligned); - -- if (phy->vchan->drcmr <= DRCMR_CHLNUM) { -+ pdev = to_pxad_dev(phy->vchan->vc.chan.device); -+ if (phy->vchan->drcmr <= pdev->nr_requestors) { - reg = pxad_drcmr(phy->vchan->drcmr); - writel_relaxed(DRCMR_MAPVLD | phy->idx, phy->base + reg); - } -@@ -914,6 +917,7 @@ static void pxad_get_config(struct pxad_chan *chan, - { - u32 maxburst = 0, dev_addr = 0; - enum dma_slave_buswidth width = DMA_SLAVE_BUSWIDTH_UNDEFINED; -+ struct pxad_device *pdev = to_pxad_dev(chan->vc.chan.device); - - *dcmd = 0; - if (dir == DMA_DEV_TO_MEM) { -@@ -922,7 +926,7 @@ static void pxad_get_config(struct pxad_chan *chan, - dev_addr = chan->cfg.src_addr; - *dev_src = dev_addr; - *dcmd |= PXA_DCMD_INCTRGADDR; -- if (chan->drcmr <= DRCMR_CHLNUM) -+ if (chan->drcmr <= pdev->nr_requestors) - *dcmd |= PXA_DCMD_FLOWSRC; - } - if (dir == DMA_MEM_TO_DEV) { -@@ -931,7 +935,7 @@ static void pxad_get_config(struct pxad_chan *chan, - dev_addr = chan->cfg.dst_addr; - *dev_dst = dev_addr; - *dcmd |= PXA_DCMD_INCSRCADDR; -- if (chan->drcmr <= DRCMR_CHLNUM) -+ if (chan->drcmr <= pdev->nr_requestors) - *dcmd |= PXA_DCMD_FLOWTRG; - } - if (dir == DMA_MEM_TO_MEM) -@@ -1341,13 +1345,15 @@ static struct dma_chan *pxad_dma_xlate(struct of_phandle_args *dma_spec, - - static int pxad_init_dmadev(struct platform_device *op, - struct pxad_device *pdev, -- unsigned int nr_phy_chans) -+ unsigned int nr_phy_chans, -+ unsigned int nr_requestors) - { - int ret; - unsigned int i; - struct pxad_chan *c; - - pdev->nr_chans = nr_phy_chans; -+ pdev->nr_requestors = nr_requestors; - INIT_LIST_HEAD(&pdev->slave.channels); - pdev->slave.device_alloc_chan_resources = pxad_alloc_chan_resources; - pdev->slave.device_free_chan_resources = pxad_free_chan_resources; -@@ -1382,7 +1388,7 @@ static int pxad_probe(struct platform_device *op) - const struct of_device_id *of_id; - struct mmp_dma_platdata *pdata = dev_get_platdata(&op->dev); - struct resource *iores; -- int ret, dma_channels = 0; -+ int ret, dma_channels = 0, nb_requestors = 0; - const enum dma_slave_buswidth widths = - DMA_SLAVE_BUSWIDTH_1_BYTE | DMA_SLAVE_BUSWIDTH_2_BYTES | - DMA_SLAVE_BUSWIDTH_4_BYTES; -@@ -1399,13 +1405,23 @@ static int pxad_probe(struct platform_device *op) - return PTR_ERR(pdev->base); - - of_id = of_match_device(pxad_dt_ids, &op->dev); -- if (of_id) -+ if (of_id) { - of_property_read_u32(op->dev.of_node, "#dma-channels", - &dma_channels); -- else if (pdata && pdata->dma_channels) -+ ret = of_property_read_u32(op->dev.of_node, "#dma-requests", -+ &nb_requestors); -+ if (ret) { -+ dev_warn(pdev->slave.dev, -+ "#dma-requests set to default 32 as missing in OF: %d", -+ ret); -+ nb_requestors = 32; -+ }; -+ } else if (pdata && pdata->dma_channels) { - dma_channels = pdata->dma_channels; -- else -+ nb_requestors = pdata->nb_requestors; -+ } else { - dma_channels = 32; /* default 32 channel */ -+ } - - dma_cap_set(DMA_SLAVE, pdev->slave.cap_mask); - dma_cap_set(DMA_MEMCPY, pdev->slave.cap_mask); -@@ -1422,7 +1438,7 @@ static int pxad_probe(struct platform_device *op) - pdev->slave.residue_granularity = DMA_RESIDUE_GRANULARITY_DESCRIPTOR; - - pdev->slave.dev = &op->dev; -- ret = pxad_init_dmadev(op, pdev, dma_channels); -+ ret = pxad_init_dmadev(op, pdev, dma_channels, nb_requestors); - if (ret) { - dev_err(pdev->slave.dev, "unable to register\n"); - return ret; -@@ -1441,7 +1457,8 @@ static int pxad_probe(struct platform_device *op) - - platform_set_drvdata(op, pdev); - pxad_init_debugfs(pdev); -- dev_info(pdev->slave.dev, "initialized %d channels\n", dma_channels); -+ dev_info(pdev->slave.dev, "initialized %d channels on %d requestors\n", -+ dma_channels, nb_requestors); - return 0; - } - -diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c -index 9eee13e..d87a475 100644 ---- a/drivers/edac/amd64_edac.c -+++ b/drivers/edac/amd64_edac.c -@@ -1452,7 +1452,7 @@ static u64 f1x_get_norm_dct_addr(struct amd64_pvt *pvt, u8 range, - u64 chan_off; - u64 dram_base = get_dram_base(pvt, range); - u64 hole_off = f10_dhar_offset(pvt); -- u64 dct_sel_base_off = (pvt->dct_sel_hi & 0xFFFFFC00) << 16; -+ u64 dct_sel_base_off = (u64)(pvt->dct_sel_hi & 0xFFFFFC00) << 16; - - if (hi_rng) { - /* -diff --git a/drivers/edac/i7core_edac.c b/drivers/edac/i7core_edac.c -index 01087a3..792bdae 100644 ---- a/drivers/edac/i7core_edac.c -+++ b/drivers/edac/i7core_edac.c -@@ -1866,7 +1866,7 @@ static int i7core_mce_check_error(struct notifier_block *nb, unsigned long val, - - i7_dev = get_i7core_dev(mce->socketid); - if (!i7_dev) -- return NOTIFY_BAD; -+ return NOTIFY_DONE; - - mci = i7_dev->mci; - pvt = mci->pvt_info; -diff --git a/drivers/edac/sb_edac.c b/drivers/edac/sb_edac.c -index 429309c..3764922 100644 ---- a/drivers/edac/sb_edac.c -+++ b/drivers/edac/sb_edac.c -@@ -1117,8 +1117,8 @@ static void get_memory_layout(const struct mem_ctl_info *mci) - edac_dbg(0, "TAD#%d: up to %u.%03u GB (0x%016Lx), socket interleave %d, memory interleave %d, TGT: %d, %d, %d, %d, reg=0x%08x\n", - n_tads, gb, (mb*1000)/1024, - ((u64)tmp_mb) << 20L, -- (u32)TAD_SOCK(reg), -- (u32)TAD_CH(reg), -+ (u32)(1 << TAD_SOCK(reg)), -+ (u32)TAD_CH(reg) + 1, - (u32)TAD_TGT0(reg), - (u32)TAD_TGT1(reg), - (u32)TAD_TGT2(reg), -@@ -1396,7 +1396,7 @@ static int get_memory_error_data(struct mem_ctl_info *mci, - } - - ch_way = TAD_CH(reg) + 1; -- sck_way = TAD_SOCK(reg) + 1; -+ sck_way = TAD_SOCK(reg); - - if (ch_way == 3) - idx = addr >> 6; -@@ -1435,7 +1435,7 @@ static int get_memory_error_data(struct mem_ctl_info *mci, - switch(ch_way) { - case 2: - case 4: -- sck_xch = 1 << sck_way * (ch_way >> 1); -+ sck_xch = (1 << sck_way) * (ch_way >> 1); - break; - default: - sprintf(msg, "Invalid mirror set. Can't decode addr"); -@@ -1453,7 +1453,7 @@ static int get_memory_error_data(struct mem_ctl_info *mci, - n_tads, - addr, - limit, -- (u32)TAD_SOCK(reg), -+ sck_way, - ch_way, - offset, - idx, -@@ -1468,18 +1468,12 @@ static int get_memory_error_data(struct mem_ctl_info *mci, - offset, addr); - return -EINVAL; - } -- addr -= offset; -- /* Store the low bits [0:6] of the addr */ -- ch_addr = addr & 0x7f; -- /* Remove socket wayness and remove 6 bits */ -- addr >>= 6; -- addr = div_u64(addr, sck_xch); --#if 0 -- /* Divide by channel way */ -- addr = addr / ch_way; --#endif -- /* Recover the last 6 bits */ -- ch_addr |= addr << 6; -+ -+ ch_addr = addr - offset; -+ ch_addr >>= (6 + shiftup); -+ ch_addr /= sck_xch; -+ ch_addr <<= (6 + shiftup); -+ ch_addr |= addr & ((1 << (6 + shiftup)) - 1); - - /* - * Step 3) Decode rank -@@ -2260,7 +2254,7 @@ static int sbridge_mce_check_error(struct notifier_block *nb, unsigned long val, - - mci = get_mci_for_node_id(mce->socketid); - if (!mci) -- return NOTIFY_BAD; -+ return NOTIFY_DONE; - pvt = mci->pvt_info; - - /* -diff --git a/drivers/extcon/extcon-max77843.c b/drivers/extcon/extcon-max77843.c -index 9f9ea33..b6cb30d 100644 ---- a/drivers/extcon/extcon-max77843.c -+++ b/drivers/extcon/extcon-max77843.c -@@ -803,7 +803,7 @@ static int max77843_muic_probe(struct platform_device *pdev) - /* Clear IRQ bits before request IRQs */ - ret = regmap_bulk_read(max77843->regmap_muic, - MAX77843_MUIC_REG_INT1, info->status, -- MAX77843_MUIC_IRQ_NUM); -+ MAX77843_MUIC_STATUS_NUM); - if (ret) { - dev_err(&pdev->dev, "Failed to Clear IRQ bits\n"); - goto err_muic_irq; -diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c -index 027ca21..3b52677 100644 ---- a/drivers/firmware/efi/efi.c -+++ b/drivers/firmware/efi/efi.c -@@ -180,6 +180,7 @@ static int generic_ops_register(void) - { - generic_ops.get_variable = efi.get_variable; - generic_ops.set_variable = efi.set_variable; -+ generic_ops.set_variable_nonblocking = efi.set_variable_nonblocking; - generic_ops.get_next_variable = efi.get_next_variable; - generic_ops.query_variable_store = efi_query_variable_store; - -diff --git a/drivers/firmware/efi/vars.c b/drivers/firmware/efi/vars.c -index 7f2ea21..6f182fd 100644 ---- a/drivers/firmware/efi/vars.c -+++ b/drivers/firmware/efi/vars.c -@@ -202,29 +202,44 @@ static const struct variable_validate variable_validate[] = { - { NULL_GUID, "", NULL }, - }; - -+/* -+ * Check if @var_name matches the pattern given in @match_name. -+ * -+ * @var_name: an array of @len non-NUL characters. -+ * @match_name: a NUL-terminated pattern string, optionally ending in "*". A -+ * final "*" character matches any trailing characters @var_name, -+ * including the case when there are none left in @var_name. -+ * @match: on output, the number of non-wildcard characters in @match_name -+ * that @var_name matches, regardless of the return value. -+ * @return: whether @var_name fully matches @match_name. -+ */ - static bool - variable_matches(const char *var_name, size_t len, const char *match_name, - int *match) - { - for (*match = 0; ; (*match)++) { - char c = match_name[*match]; -- char u = var_name[*match]; - -- /* Wildcard in the matching name means we've matched */ -- if (c == '*') -+ switch (c) { -+ case '*': -+ /* Wildcard in @match_name means we've matched. */ - return true; - -- /* Case sensitive match */ -- if (!c && *match == len) -- return true; -+ case '\0': -+ /* @match_name has ended. Has @var_name too? */ -+ return (*match == len); - -- if (c != u) -+ default: -+ /* -+ * We've reached a non-wildcard char in @match_name. -+ * Continue only if there's an identical character in -+ * @var_name. -+ */ -+ if (*match < len && c == var_name[*match]) -+ continue; - return false; -- -- if (!c) -- return true; -+ } - } -- return true; - } - - bool -diff --git a/drivers/gpio/gpio-bcm-kona.c b/drivers/gpio/gpio-bcm-kona.c -index 33a1f97..4ea71d5 100644 ---- a/drivers/gpio/gpio-bcm-kona.c -+++ b/drivers/gpio/gpio-bcm-kona.c -@@ -551,11 +551,11 @@ static void bcm_kona_gpio_reset(struct bcm_kona_gpio *kona_gpio) - /* disable interrupts and clear status */ - for (i = 0; i < kona_gpio->num_bank; i++) { - /* Unlock the entire bank first */ -- bcm_kona_gpio_write_lock_regs(kona_gpio, i, UNLOCK_CODE); -+ bcm_kona_gpio_write_lock_regs(reg_base, i, UNLOCK_CODE); - writel(0xffffffff, reg_base + GPIO_INT_MASK(i)); - writel(0xffffffff, reg_base + GPIO_INT_STATUS(i)); - /* Now re-lock the bank */ -- bcm_kona_gpio_write_lock_regs(kona_gpio, i, LOCK_CODE); -+ bcm_kona_gpio_write_lock_regs(reg_base, i, LOCK_CODE); - } - } - -diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h -index bb1099c..053fc2f 100644 ---- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h -+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h -@@ -1673,6 +1673,7 @@ struct amdgpu_uvd { - struct amdgpu_bo *vcpu_bo; - void *cpu_addr; - uint64_t gpu_addr; -+ unsigned fw_version; - atomic_t handles[AMDGPU_MAX_UVD_HANDLES]; - struct drm_file *filp[AMDGPU_MAX_UVD_HANDLES]; - struct delayed_work idle_work; -diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c -index 119cdc2..7ef2c13 100644 ---- a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c -+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c -@@ -194,12 +194,12 @@ int amdgpu_connector_get_monitor_bpc(struct drm_connector *connector) - bpc = 8; - DRM_DEBUG("%s: HDMI deep color 10 bpc exceeds max tmds clock. Using %d bpc.\n", - connector->name, bpc); -- } else if (bpc > 8) { -- /* max_tmds_clock missing, but hdmi spec mandates it for deep color. */ -- DRM_DEBUG("%s: Required max tmds clock for HDMI deep color missing. Using 8 bpc.\n", -- connector->name); -- bpc = 8; - } -+ } else if (bpc > 8) { -+ /* max_tmds_clock missing, but hdmi spec mandates it for deep color. */ -+ DRM_DEBUG("%s: Required max tmds clock for HDMI deep color missing. Using 8 bpc.\n", -+ connector->name); -+ bpc = 8; - } - } - -diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.c -index 7b7f4ab..fe36caf 100644 ---- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.c -+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.c -@@ -150,7 +150,7 @@ u32 amdgpu_dpm_get_vrefresh(struct amdgpu_device *adev) - list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { - amdgpu_crtc = to_amdgpu_crtc(crtc); - if (crtc->enabled && amdgpu_crtc->enabled && amdgpu_crtc->hw_mode.clock) { -- vrefresh = amdgpu_crtc->hw_mode.vrefresh; -+ vrefresh = drm_mode_vrefresh(&amdgpu_crtc->hw_mode); - break; - } - } -diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c -index e23843f..4488e82 100644 ---- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c -+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c -@@ -303,7 +303,7 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file - fw_info.feature = adev->vce.fb_version; - break; - case AMDGPU_INFO_FW_UVD: -- fw_info.ver = 0; -+ fw_info.ver = adev->uvd.fw_version; - fw_info.feature = 0; - break; - case AMDGPU_INFO_FW_GMC: -diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h -index 064ebb3..89df787 100644 ---- a/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h -+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h -@@ -52,7 +52,7 @@ struct amdgpu_hpd; - - #define AMDGPU_MAX_HPD_PINS 6 - #define AMDGPU_MAX_CRTCS 6 --#define AMDGPU_MAX_AFMT_BLOCKS 7 -+#define AMDGPU_MAX_AFMT_BLOCKS 9 - - enum amdgpu_rmx_type { - RMX_OFF, -@@ -308,8 +308,8 @@ struct amdgpu_mode_info { - struct atom_context *atom_context; - struct card_info *atom_card_info; - bool mode_config_initialized; -- struct amdgpu_crtc *crtcs[6]; -- struct amdgpu_afmt *afmt[7]; -+ struct amdgpu_crtc *crtcs[AMDGPU_MAX_CRTCS]; -+ struct amdgpu_afmt *afmt[AMDGPU_MAX_AFMT_BLOCKS]; - /* DVI-I properties */ - struct drm_property *coherent_mode_property; - /* DAC enable load detect */ -diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c -index b8fbbd7..73628c7 100644 ---- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c -+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c -@@ -540,6 +540,7 @@ int amdgpu_bo_set_metadata (struct amdgpu_bo *bo, void *metadata, - if (!metadata_size) { - if (bo->metadata_size) { - kfree(bo->metadata); -+ bo->metadata = NULL; - bo->metadata_size = 0; - } - return 0; -diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c -index 53f987a..3b35ad8 100644 ---- a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c -+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c -@@ -156,6 +156,9 @@ int amdgpu_uvd_sw_init(struct amdgpu_device *adev) - DRM_INFO("Found UVD firmware Version: %hu.%hu Family ID: %hu\n", - version_major, version_minor, family_id); - -+ adev->uvd.fw_version = ((version_major << 24) | (version_minor << 16) | -+ (family_id << 8)); -+ - bo_size = AMDGPU_GPU_PAGE_ALIGN(le32_to_cpu(hdr->ucode_size_bytes) + 8) - + AMDGPU_UVD_STACK_SIZE + AMDGPU_UVD_HEAP_SIZE; - r = amdgpu_bo_create(adev, bo_size, PAGE_SIZE, true, -@@ -273,6 +276,8 @@ int amdgpu_uvd_resume(struct amdgpu_device *adev) - memcpy(adev->uvd.cpu_addr, (adev->uvd.fw->data) + offset, - (adev->uvd.fw->size) - offset); - -+ cancel_delayed_work_sync(&adev->uvd.idle_work); -+ - size = amdgpu_bo_size(adev->uvd.vcpu_bo); - size -= le32_to_cpu(hdr->ucode_size_bytes); - ptr = adev->uvd.cpu_addr; -diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c -index a745eee..bb0da76 100644 ---- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c -+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c -@@ -220,6 +220,7 @@ int amdgpu_vce_suspend(struct amdgpu_device *adev) - if (i == AMDGPU_MAX_VCE_HANDLES) - return 0; - -+ cancel_delayed_work_sync(&adev->vce.idle_work); - /* TODO: suspending running encoding sessions isn't supported */ - return -EINVAL; - } -diff --git a/drivers/gpu/drm/amd/amdgpu/atombios_encoders.c b/drivers/gpu/drm/amd/amdgpu/atombios_encoders.c -index 1e0bba2..1cd6de5 100644 ---- a/drivers/gpu/drm/amd/amdgpu/atombios_encoders.c -+++ b/drivers/gpu/drm/amd/amdgpu/atombios_encoders.c -@@ -298,6 +298,10 @@ bool amdgpu_atombios_encoder_mode_fixup(struct drm_encoder *encoder, - && (mode->crtc_vsync_start < (mode->crtc_vdisplay + 2))) - adjusted_mode->crtc_vsync_start = adjusted_mode->crtc_vdisplay + 2; - -+ /* vertical FP must be at least 1 */ -+ if (mode->crtc_vsync_start == mode->crtc_vdisplay) -+ adjusted_mode->crtc_vsync_start++; -+ - /* get the native mode for scaling */ - if (amdgpu_encoder->active_device & (ATOM_DEVICE_LCD_SUPPORT)) - amdgpu_panel_mode_fixup(encoder, adjusted_mode); -diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c -index aa49154..9463007 100644 ---- a/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c -+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c -@@ -3628,7 +3628,7 @@ static void gfx_v7_0_ring_emit_vm_flush(struct amdgpu_ring *ring, - unsigned vm_id, uint64_t pd_addr) - { - int usepfp = (ring->type == AMDGPU_RING_TYPE_GFX); -- uint32_t seq = ring->fence_drv.sync_seq; -+ uint32_t seq = ring->fence_drv.sync_seq[ring->idx]; - uint64_t addr = ring->fence_drv.gpu_addr; - - amdgpu_ring_write(ring, PACKET3(PACKET3_WAIT_REG_MEM, 5)); -diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c -index 272110c..ea87033 100644 ---- a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c -+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c -@@ -898,14 +898,6 @@ static int gmc_v7_0_early_init(void *handle) - gmc_v7_0_set_gart_funcs(adev); - gmc_v7_0_set_irq_funcs(adev); - -- if (adev->flags & AMD_IS_APU) { -- adev->mc.vram_type = AMDGPU_VRAM_TYPE_UNKNOWN; -- } else { -- u32 tmp = RREG32(mmMC_SEQ_MISC0); -- tmp &= MC_SEQ_MISC0__MT__MASK; -- adev->mc.vram_type = gmc_v7_0_convert_vram_type(tmp); -- } -- - return 0; - } - -@@ -926,6 +918,14 @@ static int gmc_v7_0_sw_init(void *handle) - if (r) - return r; - -+ if (adev->flags & AMD_IS_APU) { -+ adev->mc.vram_type = AMDGPU_VRAM_TYPE_UNKNOWN; -+ } else { -+ u32 tmp = RREG32(mmMC_SEQ_MISC0); -+ tmp &= MC_SEQ_MISC0__MT__MASK; -+ adev->mc.vram_type = gmc_v7_0_convert_vram_type(tmp); -+ } -+ - r = amdgpu_irq_add_id(adev, 146, &adev->mc.vm_fault); - if (r) - return r; -diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c -index ba4ad00..0842308 100644 ---- a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c -+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c -@@ -852,14 +852,6 @@ static int gmc_v8_0_early_init(void *handle) - gmc_v8_0_set_gart_funcs(adev); - gmc_v8_0_set_irq_funcs(adev); - -- if (adev->flags & AMD_IS_APU) { -- adev->mc.vram_type = AMDGPU_VRAM_TYPE_UNKNOWN; -- } else { -- u32 tmp = RREG32(mmMC_SEQ_MISC0); -- tmp &= MC_SEQ_MISC0__MT__MASK; -- adev->mc.vram_type = gmc_v8_0_convert_vram_type(tmp); -- } -- - return 0; - } - -@@ -870,6 +862,8 @@ static int gmc_v8_0_late_init(void *handle) - return amdgpu_irq_get(adev, &adev->mc.vm_fault, 0); - } - -+#define mmMC_SEQ_MISC0_FIJI 0xA71 -+ - static int gmc_v8_0_sw_init(void *handle) - { - int r; -@@ -880,6 +874,19 @@ static int gmc_v8_0_sw_init(void *handle) - if (r) - return r; - -+ if (adev->flags & AMD_IS_APU) { -+ adev->mc.vram_type = AMDGPU_VRAM_TYPE_UNKNOWN; -+ } else { -+ u32 tmp; -+ -+ if (adev->asic_type == CHIP_FIJI) -+ tmp = RREG32(mmMC_SEQ_MISC0_FIJI); -+ else -+ tmp = RREG32(mmMC_SEQ_MISC0); -+ tmp &= MC_SEQ_MISC0__MT__MASK; -+ adev->mc.vram_type = gmc_v8_0_convert_vram_type(tmp); -+ } -+ - r = amdgpu_irq_add_id(adev, 146, &adev->mc.vm_fault); - if (r) - return r; -diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c b/drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c -index 2cf5018..b1c7a9b 100644 ---- a/drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c -+++ b/drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c -@@ -32,8 +32,8 @@ - #include "oss/oss_2_4_d.h" - #include "oss/oss_2_4_sh_mask.h" - --#include "gmc/gmc_8_1_d.h" --#include "gmc/gmc_8_1_sh_mask.h" -+#include "gmc/gmc_7_1_d.h" -+#include "gmc/gmc_7_1_sh_mask.h" - - #include "gca/gfx_8_0_d.h" - #include "gca/gfx_8_0_enum.h" -diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c b/drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c -index c34c393..d5e19b5 100644 ---- a/drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c -+++ b/drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c -@@ -513,7 +513,7 @@ static int dbgdev_wave_control_set_registers( - union SQ_CMD_BITS *in_reg_sq_cmd, - union GRBM_GFX_INDEX_BITS *in_reg_gfx_index) - { -- int status; -+ int status = 0; - union SQ_CMD_BITS reg_sq_cmd; - union GRBM_GFX_INDEX_BITS reg_gfx_index; - struct HsaDbgWaveMsgAMDGen2 *pMsg; -diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c -index aeee083..aed2e3f 100644 ---- a/drivers/gpu/drm/drm_atomic.c -+++ b/drivers/gpu/drm/drm_atomic.c -@@ -150,7 +150,7 @@ void drm_atomic_state_default_clear(struct drm_atomic_state *state) - for (i = 0; i < state->num_connector; i++) { - struct drm_connector *connector = state->connectors[i]; - -- if (!connector) -+ if (!connector || !connector->funcs) - continue; - - /* -diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c -index 24c5434..a02238c 100644 ---- a/drivers/gpu/drm/drm_crtc.c -+++ b/drivers/gpu/drm/drm_crtc.c -@@ -3316,6 +3316,24 @@ int drm_mode_addfb2(struct drm_device *dev, - return 0; - } - -+struct drm_mode_rmfb_work { -+ struct work_struct work; -+ struct list_head fbs; -+}; -+ -+static void drm_mode_rmfb_work_fn(struct work_struct *w) -+{ -+ struct drm_mode_rmfb_work *arg = container_of(w, typeof(*arg), work); -+ -+ while (!list_empty(&arg->fbs)) { -+ struct drm_framebuffer *fb = -+ list_first_entry(&arg->fbs, typeof(*fb), filp_head); -+ -+ list_del_init(&fb->filp_head); -+ drm_framebuffer_remove(fb); -+ } -+} -+ - /** - * drm_mode_rmfb - remove an FB from the configuration - * @dev: drm device for the ioctl -@@ -3356,7 +3374,25 @@ int drm_mode_rmfb(struct drm_device *dev, - mutex_unlock(&dev->mode_config.fb_lock); - mutex_unlock(&file_priv->fbs_lock); - -- drm_framebuffer_unreference(fb); -+ /* -+ * we now own the reference that was stored in the fbs list -+ * -+ * drm_framebuffer_remove may fail with -EINTR on pending signals, -+ * so run this in a separate stack as there's no way to correctly -+ * handle this after the fb is already removed from the lookup table. -+ */ -+ if (atomic_read(&fb->refcount.refcount) > 1) { -+ struct drm_mode_rmfb_work arg; -+ -+ INIT_WORK_ONSTACK(&arg.work, drm_mode_rmfb_work_fn); -+ INIT_LIST_HEAD(&arg.fbs); -+ list_add_tail(&fb->filp_head, &arg.fbs); -+ -+ schedule_work(&arg.work); -+ flush_work(&arg.work); -+ destroy_work_on_stack(&arg.work); -+ } else -+ drm_framebuffer_unreference(fb); - - return 0; - -@@ -3509,7 +3545,6 @@ out_err1: - return ret; - } - -- - /** - * drm_fb_release - remove and free the FBs on this file - * @priv: drm file for the ioctl -@@ -3524,6 +3559,9 @@ out_err1: - void drm_fb_release(struct drm_file *priv) - { - struct drm_framebuffer *fb, *tfb; -+ struct drm_mode_rmfb_work arg; -+ -+ INIT_LIST_HEAD(&arg.fbs); - - /* - * When the file gets released that means no one else can access the fb -@@ -3536,10 +3574,22 @@ void drm_fb_release(struct drm_file *priv) - * at it any more. - */ - list_for_each_entry_safe(fb, tfb, &priv->fbs, filp_head) { -- list_del_init(&fb->filp_head); -+ if (atomic_read(&fb->refcount.refcount) > 1) { -+ list_move_tail(&fb->filp_head, &arg.fbs); -+ } else { -+ list_del_init(&fb->filp_head); - -- /* This drops the fpriv->fbs reference. */ -- drm_framebuffer_unreference(fb); -+ /* This drops the fpriv->fbs reference. */ -+ drm_framebuffer_unreference(fb); -+ } -+ } -+ -+ if (!list_empty(&arg.fbs)) { -+ INIT_WORK_ONSTACK(&arg.work, drm_mode_rmfb_work_fn); -+ -+ schedule_work(&arg.work); -+ flush_work(&arg.work); -+ destroy_work_on_stack(&arg.work); - } - } - -diff --git a/drivers/gpu/drm/drm_dp_helper.c b/drivers/gpu/drm/drm_dp_helper.c -index 9535c5b..7e5a972 100644 ---- a/drivers/gpu/drm/drm_dp_helper.c -+++ b/drivers/gpu/drm/drm_dp_helper.c -@@ -178,7 +178,7 @@ static int drm_dp_dpcd_access(struct drm_dp_aux *aux, u8 request, - { - struct drm_dp_aux_msg msg; - unsigned int retry; -- int err; -+ int err = 0; - - memset(&msg, 0, sizeof(msg)); - msg.address = offset; -@@ -186,6 +186,8 @@ static int drm_dp_dpcd_access(struct drm_dp_aux *aux, u8 request, - msg.buffer = buffer; - msg.size = size; - -+ mutex_lock(&aux->hw_mutex); -+ - /* - * The specification doesn't give any recommendation on how often to - * retry native transactions. We used to retry 7 times like for -@@ -194,25 +196,24 @@ static int drm_dp_dpcd_access(struct drm_dp_aux *aux, u8 request, - */ - for (retry = 0; retry < 32; retry++) { - -- mutex_lock(&aux->hw_mutex); - err = aux->transfer(aux, &msg); -- mutex_unlock(&aux->hw_mutex); - if (err < 0) { - if (err == -EBUSY) - continue; - -- return err; -+ goto unlock; - } - - - switch (msg.reply & DP_AUX_NATIVE_REPLY_MASK) { - case DP_AUX_NATIVE_REPLY_ACK: - if (err < size) -- return -EPROTO; -- return err; -+ err = -EPROTO; -+ goto unlock; - - case DP_AUX_NATIVE_REPLY_NACK: -- return -EIO; -+ err = -EIO; -+ goto unlock; - - case DP_AUX_NATIVE_REPLY_DEFER: - usleep_range(AUX_RETRY_INTERVAL, AUX_RETRY_INTERVAL + 100); -@@ -221,7 +222,11 @@ static int drm_dp_dpcd_access(struct drm_dp_aux *aux, u8 request, - } - - DRM_DEBUG_KMS("too many retries, giving up\n"); -- return -EIO; -+ err = -EIO; -+ -+unlock: -+ mutex_unlock(&aux->hw_mutex); -+ return err; - } - - /** -@@ -543,9 +548,7 @@ static int drm_dp_i2c_do_msg(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg) - int max_retries = max(7, drm_dp_i2c_retry_count(msg, dp_aux_i2c_speed_khz)); - - for (retry = 0, defer_i2c = 0; retry < (max_retries + defer_i2c); retry++) { -- mutex_lock(&aux->hw_mutex); - ret = aux->transfer(aux, msg); -- mutex_unlock(&aux->hw_mutex); - if (ret < 0) { - if (ret == -EBUSY) - continue; -@@ -684,6 +687,8 @@ static int drm_dp_i2c_xfer(struct i2c_adapter *adapter, struct i2c_msg *msgs, - - memset(&msg, 0, sizeof(msg)); - -+ mutex_lock(&aux->hw_mutex); -+ - for (i = 0; i < num; i++) { - msg.address = msgs[i].addr; - drm_dp_i2c_msg_set_request(&msg, &msgs[i]); -@@ -738,6 +743,8 @@ static int drm_dp_i2c_xfer(struct i2c_adapter *adapter, struct i2c_msg *msgs, - msg.size = 0; - (void)drm_dp_i2c_do_msg(aux, &msg); - -+ mutex_unlock(&aux->hw_mutex); -+ - return err; - } - -diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c -index 39d7e2e..d268bf1 100644 ---- a/drivers/gpu/drm/drm_dp_mst_topology.c -+++ b/drivers/gpu/drm/drm_dp_mst_topology.c -@@ -1665,13 +1665,19 @@ static int drm_dp_payload_send_msg(struct drm_dp_mst_topology_mgr *mgr, - struct drm_dp_mst_branch *mstb; - int len, ret, port_num; - -+ port = drm_dp_get_validated_port_ref(mgr, port); -+ if (!port) -+ return -EINVAL; -+ - port_num = port->port_num; - mstb = drm_dp_get_validated_mstb_ref(mgr, port->parent); - if (!mstb) { - mstb = drm_dp_get_last_connected_port_and_mstb(mgr, port->parent, &port_num); - -- if (!mstb) -+ if (!mstb) { -+ drm_dp_put_port(port); - return -EINVAL; -+ } - } - - txmsg = kzalloc(sizeof(*txmsg), GFP_KERNEL); -@@ -1697,6 +1703,7 @@ static int drm_dp_payload_send_msg(struct drm_dp_mst_topology_mgr *mgr, - kfree(txmsg); - fail_put: - drm_dp_put_mst_branch_device(mstb); -+ drm_dp_put_port(port); - return ret; - } - -@@ -1779,6 +1786,11 @@ int drm_dp_update_payload_part1(struct drm_dp_mst_topology_mgr *mgr) - req_payload.start_slot = cur_slots; - if (mgr->proposed_vcpis[i]) { - port = container_of(mgr->proposed_vcpis[i], struct drm_dp_mst_port, vcpi); -+ port = drm_dp_get_validated_port_ref(mgr, port); -+ if (!port) { -+ mutex_unlock(&mgr->payload_lock); -+ return -EINVAL; -+ } - req_payload.num_slots = mgr->proposed_vcpis[i]->num_slots; - } else { - port = NULL; -@@ -1804,6 +1816,9 @@ int drm_dp_update_payload_part1(struct drm_dp_mst_topology_mgr *mgr) - mgr->payloads[i].payload_state = req_payload.payload_state; - } - cur_slots += req_payload.num_slots; -+ -+ if (port) -+ drm_dp_put_port(port); - } - - for (i = 0; i < mgr->max_payloads; i++) { -@@ -2109,6 +2124,8 @@ int drm_dp_mst_topology_mgr_resume(struct drm_dp_mst_topology_mgr *mgr) - - if (mgr->mst_primary) { - int sret; -+ u8 guid[16]; -+ - sret = drm_dp_dpcd_read(mgr->aux, DP_DPCD_REV, mgr->dpcd, DP_RECEIVER_CAP_SIZE); - if (sret != DP_RECEIVER_CAP_SIZE) { - DRM_DEBUG_KMS("dpcd read failed - undocked during suspend?\n"); -@@ -2123,6 +2140,16 @@ int drm_dp_mst_topology_mgr_resume(struct drm_dp_mst_topology_mgr *mgr) - ret = -1; - goto out_unlock; - } -+ -+ /* Some hubs forget their guids after they resume */ -+ sret = drm_dp_dpcd_read(mgr->aux, DP_GUID, guid, 16); -+ if (sret != 16) { -+ DRM_DEBUG_KMS("dpcd read failed - undocked during suspend?\n"); -+ ret = -1; -+ goto out_unlock; -+ } -+ drm_dp_check_mstb_guid(mgr->mst_primary, guid); -+ - ret = 0; - } else - ret = -1; -diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c -index 69cbab5..5ad0367 100644 ---- a/drivers/gpu/drm/drm_fb_helper.c -+++ b/drivers/gpu/drm/drm_fb_helper.c -@@ -1899,7 +1899,6 @@ static int drm_pick_crtcs(struct drm_fb_helper *fb_helper, - int n, int width, int height) - { - int c, o; -- struct drm_device *dev = fb_helper->dev; - struct drm_connector *connector; - const struct drm_connector_helper_funcs *connector_funcs; - struct drm_encoder *encoder; -@@ -1918,7 +1917,7 @@ static int drm_pick_crtcs(struct drm_fb_helper *fb_helper, - if (modes[n] == NULL) - return best_score; - -- crtcs = kzalloc(dev->mode_config.num_connector * -+ crtcs = kzalloc(fb_helper->connector_count * - sizeof(struct drm_fb_helper_crtc *), GFP_KERNEL); - if (!crtcs) - return best_score; -@@ -1964,7 +1963,7 @@ static int drm_pick_crtcs(struct drm_fb_helper *fb_helper, - if (score > best_score) { - best_score = score; - memcpy(best_crtcs, crtcs, -- dev->mode_config.num_connector * -+ fb_helper->connector_count * - sizeof(struct drm_fb_helper_crtc *)); - } - } -diff --git a/drivers/gpu/drm/gma500/mdfld_dsi_pkg_sender.c b/drivers/gpu/drm/gma500/mdfld_dsi_pkg_sender.c -index 6b43ae3..1616af2 100644 ---- a/drivers/gpu/drm/gma500/mdfld_dsi_pkg_sender.c -+++ b/drivers/gpu/drm/gma500/mdfld_dsi_pkg_sender.c -@@ -72,7 +72,7 @@ static const char *const dsi_errors[] = { - "RX Prot Violation", - "HS Generic Write FIFO Full", - "LP Generic Write FIFO Full", -- "Generic Read Data Avail" -+ "Generic Read Data Avail", - "Special Packet Sent", - "Tearing Effect", - }; -diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c -index 0f42a27..80a1db0 100644 ---- a/drivers/gpu/drm/i915/i915_irq.c -+++ b/drivers/gpu/drm/i915/i915_irq.c -@@ -812,6 +812,7 @@ static int i915_get_crtc_scanoutpos(struct drm_device *dev, unsigned int pipe, - spin_lock_irqsave(&dev_priv->uncore.lock, irqflags); - - /* preempt_disable_rt() should go right here in PREEMPT_RT patchset. */ -+ preempt_disable_rt(); - - /* Get optional system timestamp before query. */ - if (stime) -@@ -863,6 +864,7 @@ static int i915_get_crtc_scanoutpos(struct drm_device *dev, unsigned int pipe, - *etime = ktime_get(); - - /* preempt_enable_rt() should go right here in PREEMPT_RT patchset. */ -+ preempt_enable_rt(); - - spin_unlock_irqrestore(&dev_priv->uncore.lock, irqflags); - -diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h -index bc7b8fa..7e461dc 100644 ---- a/drivers/gpu/drm/i915/i915_reg.h -+++ b/drivers/gpu/drm/i915/i915_reg.h -@@ -2838,7 +2838,14 @@ enum skl_disp_power_wells { - #define GEN6_RP_STATE_CAP (MCHBAR_MIRROR_BASE_SNB + 0x5998) - #define BXT_RP_STATE_CAP 0x138170 - --#define INTERVAL_1_28_US(us) (((us) * 100) >> 7) -+/* -+ * Make these a multiple of magic 25 to avoid SNB (eg. Dell XPS -+ * 8300) freezing up around GPU hangs. Looks as if even -+ * scheduling/timer interrupts start misbehaving if the RPS -+ * EI/thresholds are "bad", leading to a very sluggish or even -+ * frozen machine. -+ */ -+#define INTERVAL_1_28_US(us) roundup(((us) * 100) >> 7, 25) - #define INTERVAL_1_33_US(us) (((us) * 3) >> 2) - #define INTERVAL_0_833_US(us) (((us) * 6) / 5) - #define GT_INTERVAL_FROM_US(dev_priv, us) (IS_GEN9(dev_priv) ? \ -diff --git a/drivers/gpu/drm/i915/intel_crt.c b/drivers/gpu/drm/i915/intel_crt.c -index 6a2c76e..97d1ed2 100644 ---- a/drivers/gpu/drm/i915/intel_crt.c -+++ b/drivers/gpu/drm/i915/intel_crt.c -@@ -248,8 +248,14 @@ static bool intel_crt_compute_config(struct intel_encoder *encoder, - pipe_config->has_pch_encoder = true; - - /* LPT FDI RX only supports 8bpc. */ -- if (HAS_PCH_LPT(dev)) -+ if (HAS_PCH_LPT(dev)) { -+ if (pipe_config->bw_constrained && pipe_config->pipe_bpp < 24) { -+ DRM_DEBUG_KMS("LPT only supports 24bpp\n"); -+ return false; -+ } -+ - pipe_config->pipe_bpp = 24; -+ } - - /* FDI must always be 2.7 GHz */ - if (HAS_DDI(dev)) { -diff --git a/drivers/gpu/drm/i915/intel_csr.c b/drivers/gpu/drm/i915/intel_csr.c -index 9e530a7..fc28c51 100644 ---- a/drivers/gpu/drm/i915/intel_csr.c -+++ b/drivers/gpu/drm/i915/intel_csr.c -@@ -180,7 +180,8 @@ struct stepping_info { - static const struct stepping_info skl_stepping_info[] = { - {'A', '0'}, {'B', '0'}, {'C', '0'}, - {'D', '0'}, {'E', '0'}, {'F', '0'}, -- {'G', '0'}, {'H', '0'}, {'I', '0'} -+ {'G', '0'}, {'H', '0'}, {'I', '0'}, -+ {'J', '0'}, {'K', '0'} - }; - - static struct stepping_info bxt_stepping_info[] = { -diff --git a/drivers/gpu/drm/i915/intel_ddi.c b/drivers/gpu/drm/i915/intel_ddi.c -index 7e6158b..3c6b076 100644 ---- a/drivers/gpu/drm/i915/intel_ddi.c -+++ b/drivers/gpu/drm/i915/intel_ddi.c -@@ -464,9 +464,17 @@ static void intel_prepare_ddi_buffers(struct drm_device *dev, enum port port, - } else if (IS_BROADWELL(dev)) { - ddi_translations_fdi = bdw_ddi_translations_fdi; - ddi_translations_dp = bdw_ddi_translations_dp; -- ddi_translations_edp = bdw_ddi_translations_edp; -+ -+ if (dev_priv->edp_low_vswing) { -+ ddi_translations_edp = bdw_ddi_translations_edp; -+ n_edp_entries = ARRAY_SIZE(bdw_ddi_translations_edp); -+ } else { -+ ddi_translations_edp = bdw_ddi_translations_dp; -+ n_edp_entries = ARRAY_SIZE(bdw_ddi_translations_dp); -+ } -+ - ddi_translations_hdmi = bdw_ddi_translations_hdmi; -- n_edp_entries = ARRAY_SIZE(bdw_ddi_translations_edp); -+ - n_dp_entries = ARRAY_SIZE(bdw_ddi_translations_dp); - n_hdmi_entries = ARRAY_SIZE(bdw_ddi_translations_hdmi); - hdmi_default_entry = 7; -@@ -3188,12 +3196,6 @@ void intel_ddi_get_config(struct intel_encoder *encoder, - intel_ddi_clock_get(encoder, pipe_config); - } - --static void intel_ddi_destroy(struct drm_encoder *encoder) --{ -- /* HDMI has nothing special to destroy, so we can go with this. */ -- intel_dp_encoder_destroy(encoder); --} -- - static bool intel_ddi_compute_config(struct intel_encoder *encoder, - struct intel_crtc_state *pipe_config) - { -@@ -3212,7 +3214,8 @@ static bool intel_ddi_compute_config(struct intel_encoder *encoder, - } - - static const struct drm_encoder_funcs intel_ddi_funcs = { -- .destroy = intel_ddi_destroy, -+ .reset = intel_dp_encoder_reset, -+ .destroy = intel_dp_encoder_destroy, - }; - - static struct intel_connector * -@@ -3284,6 +3287,7 @@ void intel_ddi_init(struct drm_device *dev, enum port port) - intel_encoder->post_disable = intel_ddi_post_disable; - intel_encoder->get_hw_state = intel_ddi_get_hw_state; - intel_encoder->get_config = intel_ddi_get_config; -+ intel_encoder->suspend = intel_dp_encoder_suspend; - - intel_dig_port->port = port; - intel_dig_port->saved_port_bits = I915_READ(DDI_BUF_CTL(port)) & -diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c -index f1c6c97..b32ff51 100644 ---- a/drivers/gpu/drm/i915/intel_display.c -+++ b/drivers/gpu/drm/i915/intel_display.c -@@ -4447,7 +4447,7 @@ int skl_update_scaler_crtc(struct intel_crtc_state *state) - intel_crtc->base.base.id, intel_crtc->pipe, SKL_CRTC_INDEX); - - return skl_update_scaler(state, !state->base.active, SKL_CRTC_INDEX, -- &state->scaler_state.scaler_id, DRM_ROTATE_0, -+ &state->scaler_state.scaler_id, BIT(DRM_ROTATE_0), - state->pipe_src_w, state->pipe_src_h, - adjusted_mode->crtc_hdisplay, adjusted_mode->crtc_vdisplay); - } -diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c -index 78b8ec8..e55a82a 100644 ---- a/drivers/gpu/drm/i915/intel_dp.c -+++ b/drivers/gpu/drm/i915/intel_dp.c -@@ -5035,7 +5035,7 @@ void intel_dp_encoder_destroy(struct drm_encoder *encoder) - kfree(intel_dig_port); - } - --static void intel_dp_encoder_suspend(struct intel_encoder *intel_encoder) -+void intel_dp_encoder_suspend(struct intel_encoder *intel_encoder) - { - struct intel_dp *intel_dp = enc_to_intel_dp(&intel_encoder->base); - -@@ -5077,7 +5077,7 @@ static void intel_edp_panel_vdd_sanitize(struct intel_dp *intel_dp) - edp_panel_vdd_schedule_off(intel_dp); - } - --static void intel_dp_encoder_reset(struct drm_encoder *encoder) -+void intel_dp_encoder_reset(struct drm_encoder *encoder) - { - struct intel_dp *intel_dp; - -diff --git a/drivers/gpu/drm/i915/intel_dp_mst.c b/drivers/gpu/drm/i915/intel_dp_mst.c -index 0639275..06bd925 100644 ---- a/drivers/gpu/drm/i915/intel_dp_mst.c -+++ b/drivers/gpu/drm/i915/intel_dp_mst.c -@@ -477,6 +477,8 @@ static void intel_dp_destroy_mst_connector(struct drm_dp_mst_topology_mgr *mgr, - struct intel_connector *intel_connector = to_intel_connector(connector); - struct drm_device *dev = connector->dev; - -+ intel_connector->unregister(intel_connector); -+ - /* need to nuke the connector */ - drm_modeset_lock_all(dev); - if (connector->state->crtc) { -@@ -490,11 +492,7 @@ static void intel_dp_destroy_mst_connector(struct drm_dp_mst_topology_mgr *mgr, - - WARN(ret, "Disabling mst crtc failed with %i\n", ret); - } -- drm_modeset_unlock_all(dev); - -- intel_connector->unregister(intel_connector); -- -- drm_modeset_lock_all(dev); - intel_connector_remove_from_fbdev(intel_connector); - drm_connector_cleanup(connector); - drm_modeset_unlock_all(dev); -diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h -index 0d00f07..f34a219 100644 ---- a/drivers/gpu/drm/i915/intel_drv.h -+++ b/drivers/gpu/drm/i915/intel_drv.h -@@ -1204,6 +1204,8 @@ void intel_dp_set_link_params(struct intel_dp *intel_dp, - void intel_dp_start_link_train(struct intel_dp *intel_dp); - void intel_dp_stop_link_train(struct intel_dp *intel_dp); - void intel_dp_sink_dpms(struct intel_dp *intel_dp, int mode); -+void intel_dp_encoder_reset(struct drm_encoder *encoder); -+void intel_dp_encoder_suspend(struct intel_encoder *intel_encoder); - void intel_dp_encoder_destroy(struct drm_encoder *encoder); - int intel_dp_sink_crc(struct intel_dp *intel_dp, u8 *crc); - bool intel_dp_compute_config(struct intel_encoder *encoder, -diff --git a/drivers/gpu/drm/i915/intel_fbdev.c b/drivers/gpu/drm/i915/intel_fbdev.c -index 4fd5fdf..c0c094d 100644 ---- a/drivers/gpu/drm/i915/intel_fbdev.c -+++ b/drivers/gpu/drm/i915/intel_fbdev.c -@@ -362,12 +362,12 @@ static bool intel_fb_initial_config(struct drm_fb_helper *fb_helper, - uint64_t conn_configured = 0, mask; - int pass = 0; - -- save_enabled = kcalloc(dev->mode_config.num_connector, sizeof(bool), -+ save_enabled = kcalloc(fb_helper->connector_count, sizeof(bool), - GFP_KERNEL); - if (!save_enabled) - return false; - -- memcpy(save_enabled, enabled, dev->mode_config.num_connector); -+ memcpy(save_enabled, enabled, fb_helper->connector_count); - mask = (1 << fb_helper->connector_count) - 1; - retry: - for (i = 0; i < fb_helper->connector_count; i++) { -@@ -501,7 +501,7 @@ retry: - if (fallback) { - bail: - DRM_DEBUG_KMS("Not using firmware configuration\n"); -- memcpy(enabled, save_enabled, dev->mode_config.num_connector); -+ memcpy(enabled, save_enabled, fb_helper->connector_count); - kfree(save_enabled); - return false; - } -diff --git a/drivers/gpu/drm/i915/intel_hdmi.c b/drivers/gpu/drm/i915/intel_hdmi.c -index e6c035b..4b8ed9f 100644 ---- a/drivers/gpu/drm/i915/intel_hdmi.c -+++ b/drivers/gpu/drm/i915/intel_hdmi.c -@@ -1388,8 +1388,16 @@ intel_hdmi_detect(struct drm_connector *connector, bool force) - hdmi_to_dig_port(intel_hdmi)); - } - -- if (!live_status) -- DRM_DEBUG_KMS("Live status not up!"); -+ if (!live_status) { -+ DRM_DEBUG_KMS("HDMI live status down\n"); -+ /* -+ * Live status register is not reliable on all intel platforms. -+ * So consider live_status only for certain platforms, for -+ * others, read EDID to determine presence of sink. -+ */ -+ if (INTEL_INFO(dev_priv)->gen < 7 || IS_IVYBRIDGE(dev_priv)) -+ live_status = true; -+ } - - intel_hdmi_unset_edid(connector); - -diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c -index d69547a..7058f75 100644 ---- a/drivers/gpu/drm/i915/intel_lrc.c -+++ b/drivers/gpu/drm/i915/intel_lrc.c -@@ -776,11 +776,11 @@ static int logical_ring_prepare(struct drm_i915_gem_request *req, int bytes) - if (unlikely(total_bytes > remain_usable)) { - /* - * The base request will fit but the reserved space -- * falls off the end. So only need to to wait for the -- * reserved size after flushing out the remainder. -+ * falls off the end. So don't need an immediate wrap -+ * and only need to effectively wait for the reserved -+ * size space from the start of ringbuffer. - */ - wait_bytes = remain_actual + ringbuf->reserved_size; -- need_wrap = true; - } else if (total_bytes > ringbuf->space) { - /* No wrapping required, just waiting. */ - wait_bytes = total_bytes; -diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c -index f091ad1..62284e4 100644 ---- a/drivers/gpu/drm/i915/intel_pm.c -+++ b/drivers/gpu/drm/i915/intel_pm.c -@@ -3880,6 +3880,8 @@ static void ilk_pipe_wm_get_hw_state(struct drm_crtc *crtc) - if (IS_HASWELL(dev) || IS_BROADWELL(dev)) - hw->wm_linetime[pipe] = I915_READ(PIPE_WM_LINETIME(pipe)); - -+ memset(active, 0, sizeof(*active)); -+ - active->pipe_enabled = intel_crtc->active; - - if (active->pipe_enabled) { -@@ -6620,6 +6622,12 @@ static void broadwell_init_clock_gating(struct drm_device *dev) - misccpctl = I915_READ(GEN7_MISCCPCTL); - I915_WRITE(GEN7_MISCCPCTL, misccpctl & ~GEN7_DOP_CLOCK_GATE_ENABLE); - I915_WRITE(GEN8_L3SQCREG1, BDW_WA_L3SQCREG1_DEFAULT); -+ /* -+ * Wait at least 100 clocks before re-enabling clock gating. See -+ * the definition of L3SQCREG1 in BSpec. -+ */ -+ POSTING_READ(GEN8_L3SQCREG1); -+ udelay(1); - I915_WRITE(GEN7_MISCCPCTL, misccpctl); - - /* -diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c -index f6b2a81..9d48443 100644 ---- a/drivers/gpu/drm/i915/intel_ringbuffer.c -+++ b/drivers/gpu/drm/i915/intel_ringbuffer.c -@@ -1922,6 +1922,17 @@ i915_dispatch_execbuffer(struct drm_i915_gem_request *req, - return 0; - } - -+static void cleanup_phys_status_page(struct intel_engine_cs *ring) -+{ -+ struct drm_i915_private *dev_priv = to_i915(ring->dev); -+ -+ if (!dev_priv->status_page_dmah) -+ return; -+ -+ drm_pci_free(ring->dev, dev_priv->status_page_dmah); -+ ring->status_page.page_addr = NULL; -+} -+ - static void cleanup_status_page(struct intel_engine_cs *ring) - { - struct drm_i915_gem_object *obj; -@@ -1938,9 +1949,9 @@ static void cleanup_status_page(struct intel_engine_cs *ring) - - static int init_status_page(struct intel_engine_cs *ring) - { -- struct drm_i915_gem_object *obj; -+ struct drm_i915_gem_object *obj = ring->status_page.obj; - -- if ((obj = ring->status_page.obj) == NULL) { -+ if (obj == NULL) { - unsigned flags; - int ret; - -@@ -2134,7 +2145,7 @@ static int intel_init_ring_buffer(struct drm_device *dev, - if (ret) - goto error; - } else { -- BUG_ON(ring->id != RCS); -+ WARN_ON(ring->id != RCS); - ret = init_phys_status_page(ring); - if (ret) - goto error; -@@ -2179,7 +2190,12 @@ void intel_cleanup_ring_buffer(struct intel_engine_cs *ring) - if (ring->cleanup) - ring->cleanup(ring); - -- cleanup_status_page(ring); -+ if (I915_NEED_GFX_HWS(ring->dev)) { -+ cleanup_status_page(ring); -+ } else { -+ WARN_ON(ring->id != RCS); -+ cleanup_phys_status_page(ring); -+ } - - i915_cmd_parser_fini_ring(ring); - i915_gem_batch_pool_fini(&ring->batch_pool); -@@ -2341,11 +2357,11 @@ static int __intel_ring_prepare(struct intel_engine_cs *ring, int bytes) - if (unlikely(total_bytes > remain_usable)) { - /* - * The base request will fit but the reserved space -- * falls off the end. So only need to to wait for the -- * reserved size after flushing out the remainder. -+ * falls off the end. So don't need an immediate wrap -+ * and only need to effectively wait for the reserved -+ * size space from the start of ringbuffer. - */ - wait_bytes = remain_actual + ringbuf->reserved_size; -- need_wrap = true; - } else if (total_bytes > ringbuf->space) { - /* No wrapping required, just waiting. */ - wait_bytes = total_bytes; -diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c -index 56dc132..8771d66 100644 ---- a/drivers/gpu/drm/i915/intel_sprite.c -+++ b/drivers/gpu/drm/i915/intel_sprite.c -@@ -38,6 +38,7 @@ - #include "intel_drv.h" - #include - #include "i915_drv.h" -+#include - - static bool - format_is_yuv(uint32_t format) -@@ -64,6 +65,8 @@ static int usecs_to_scanlines(const struct drm_display_mode *adjusted_mode, - 1000 * adjusted_mode->crtc_htotal); - } - -+static DEFINE_LOCAL_IRQ_LOCK(pipe_update_lock); -+ - /** - * intel_pipe_update_start() - start update of a set of display registers - * @crtc: the crtc of which the registers are going to be updated -@@ -96,7 +99,7 @@ void intel_pipe_update_start(struct intel_crtc *crtc) - min = vblank_start - usecs_to_scanlines(adjusted_mode, 100); - max = vblank_start - 1; - -- local_irq_disable(); -+ local_lock_irq(pipe_update_lock); - - if (min <= 0 || max <= 0) - return; -@@ -126,11 +129,11 @@ void intel_pipe_update_start(struct intel_crtc *crtc) - break; - } - -- local_irq_enable(); -+ local_unlock_irq(pipe_update_lock); - - timeout = schedule_timeout(timeout); - -- local_irq_disable(); -+ local_lock_irq(pipe_update_lock); - } - - finish_wait(wq, &wait); -@@ -164,7 +167,7 @@ void intel_pipe_update_end(struct intel_crtc *crtc) - - trace_i915_pipe_update_end(crtc, end_vbl_count, scanline_end); - -- local_irq_enable(); -+ local_unlock_irq(pipe_update_lock); - - if (crtc->debug.start_vbl_count && - crtc->debug.start_vbl_count != end_vbl_count) { -diff --git a/drivers/gpu/drm/i915/intel_uncore.c b/drivers/gpu/drm/i915/intel_uncore.c -index 43cba12..cc91ae8 100644 ---- a/drivers/gpu/drm/i915/intel_uncore.c -+++ b/drivers/gpu/drm/i915/intel_uncore.c -@@ -1132,7 +1132,11 @@ static void intel_uncore_fw_domains_init(struct drm_device *dev) - } else if (IS_HASWELL(dev) || IS_BROADWELL(dev)) { - dev_priv->uncore.funcs.force_wake_get = - fw_domains_get_with_thread_status; -- dev_priv->uncore.funcs.force_wake_put = fw_domains_put; -+ if (IS_HASWELL(dev)) -+ dev_priv->uncore.funcs.force_wake_put = -+ fw_domains_put_with_fifo; -+ else -+ dev_priv->uncore.funcs.force_wake_put = fw_domains_put; - fw_domain_init(dev_priv, FW_DOMAIN_ID_RENDER, - FORCEWAKE_MT, FORCEWAKE_ACK_HSW); - } else if (IS_IVYBRIDGE(dev)) { -diff --git a/drivers/gpu/drm/imx/imx-drm-core.c b/drivers/gpu/drm/imx/imx-drm-core.c -index 7b990b4..5378bdc 100644 ---- a/drivers/gpu/drm/imx/imx-drm-core.c -+++ b/drivers/gpu/drm/imx/imx-drm-core.c -@@ -26,6 +26,7 @@ - #include - #include - #include -+#include