summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2017-05-22 23:32:48 -0400
committerDavid S. Miller <davem@davemloft.net>2017-05-22 23:32:48 -0400
commit218b6a5b23e939caf2064549b1cb61ba22b9d0a1 (patch)
treebdabf5439fb58905268953165779614d2aadb677
parent1db3a61017c627d590315347ccf302d9a6b97970 (diff)
parentfadd2ce5a3680fb265694f573cbfb8bcb7d6c9d5 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
-rw-r--r--Documentation/acpi/acpi-lid.txt16
-rw-r--r--Documentation/admin-guide/pm/cpufreq.rst19
-rw-r--r--Documentation/admin-guide/pm/index.rst1
-rw-r--r--Documentation/admin-guide/pm/intel_pstate.rst755
-rw-r--r--Documentation/cpu-freq/intel-pstate.txt281
-rw-r--r--Documentation/devicetree/bindings/staging/ion/hi6220-ion.txt31
-rw-r--r--Documentation/usb/typec.rst6
-rw-r--r--Documentation/watchdog/watchdog-parameters.txt2
-rw-r--r--MAINTAINERS15
-rw-r--r--Makefile2
-rw-r--r--arch/alpha/kernel/osf_sys.c6
-rw-r--r--arch/arm/boot/dts/bcm283x-rpi-smsc9512.dtsi2
-rw-r--r--arch/arm/boot/dts/bcm283x-rpi-smsc9514.dtsi2
-rw-r--r--arch/arm/boot/dts/bcm283x.dtsi22
-rw-r--r--arch/arm/boot/dts/dra7-evm.dts2
-rw-r--r--arch/arm/boot/dts/dra7.dtsi4
-rw-r--r--arch/arm/boot/dts/imx53-qsrb.dts2
-rw-r--r--arch/arm/boot/dts/imx6sx-sdb.dts17
l---------arch/arm/boot/dts/include/arm1
l---------arch/arm/boot/dts/include/arm641
l---------arch/arm/boot/dts/include/dt-bindings1
-rw-r--r--arch/arm/boot/dts/logicpd-torpedo-37xx-devkit.dts6
-rw-r--r--arch/arm/boot/dts/mt7623.dtsi2
-rw-r--r--arch/arm/boot/dts/omap3-gta04.dtsi3
-rw-r--r--arch/arm/boot/dts/omap4-panda-a4.dts2
-rw-r--r--arch/arm/boot/dts/omap4-panda-es.dts2
-rw-r--r--arch/arm/configs/gemini_defconfig68
-rw-r--r--arch/arm/include/asm/kvm_coproc.h3
-rw-r--r--arch/arm/kvm/coproc.c106
-rw-r--r--arch/arm/kvm/handle_exit.c4
-rw-r--r--arch/arm/kvm/hyp/Makefile2
-rw-r--r--arch/arm/kvm/hyp/switch.c4
-rw-r--r--arch/arm/kvm/trace.h8
-rw-r--r--arch/arm/mach-at91/pm.c2
-rw-r--r--arch/arm/mach-bcm/bcm_kona_smc.c2
-rw-r--r--arch/arm/mach-cns3xxx/core.c2
-rw-r--r--arch/arm/mach-omap2/common.h3
-rw-r--r--arch/arm/mach-omap2/omap-mpuss-lowpower.c10
-rw-r--r--arch/arm/mach-omap2/omap-smp.c11
-rw-r--r--arch/arm/mach-omap2/prm_common.c2
-rw-r--r--arch/arm/mach-omap2/vc.c2
-rw-r--r--arch/arm/mach-spear/time.c2
-rw-r--r--arch/arm64/Kconfig.platforms5
l---------arch/arm64/boot/dts/include/arm1
l---------arch/arm64/boot/dts/include/arm641
l---------arch/arm64/boot/dts/include/dt-bindings1
-rw-r--r--arch/arm64/boot/dts/marvell/armada-3720-db.dts8
-rw-r--r--arch/arm64/boot/dts/marvell/armada-37xx.dtsi73
-rw-r--r--arch/arm64/boot/dts/mediatek/mt8173-evb.dts3
-rw-r--r--arch/arm64/boot/dts/rockchip/rk3399-gru-kevin.dts2
-rw-r--r--arch/arm64/configs/defconfig106
-rw-r--r--arch/arm64/include/asm/atomic_ll_sc.h1
-rw-r--r--arch/arm64/include/asm/cpufeature.h12
-rw-r--r--arch/arm64/include/asm/kvm_host.h8
-rw-r--r--arch/arm64/kernel/cpufeature.c23
-rw-r--r--arch/arm64/kernel/perf_event.c23
-rw-r--r--arch/arm64/kvm/hyp/Makefile2
l---------arch/cris/boot/dts/include/dt-bindings1
l---------arch/metag/boot/dts/include/dt-bindings1
l---------arch/mips/boot/dts/include/dt-bindings1
l---------arch/powerpc/boot/dts/include/dt-bindings1
-rw-r--r--arch/powerpc/include/asm/module.h4
-rw-r--r--arch/powerpc/include/asm/page.h12
-rw-r--r--arch/powerpc/kernel/idle_book3s.S2
-rw-r--r--arch/powerpc/kernel/kprobes.c3
-rw-r--r--arch/powerpc/kernel/process.c19
-rw-r--r--arch/powerpc/kvm/Kconfig2
-rw-r--r--arch/powerpc/kvm/Makefile4
-rw-r--r--arch/powerpc/kvm/book3s_64_vio_hv.c13
-rw-r--r--arch/powerpc/kvm/book3s_hv_builtin.c9
-rw-r--r--arch/powerpc/kvm/book3s_pr_papr.c70
-rw-r--r--arch/powerpc/kvm/powerpc.c4
-rw-r--r--arch/powerpc/mm/dump_linuxpagetables.c7
-rw-r--r--arch/x86/include/asm/kvm_host.h2
-rw-r--r--arch/x86/include/asm/uaccess.h11
-rw-r--r--arch/x86/kernel/fpu/init.c1
-rw-r--r--arch/x86/kvm/emulate.c2
-rw-r--r--arch/x86/kvm/paging_tmpl.h35
-rw-r--r--arch/x86/kvm/pmu_intel.c2
-rw-r--r--arch/x86/kvm/svm.c3
-rw-r--r--arch/x86/kvm/vmx.c4
-rw-r--r--arch/x86/kvm/x86.c45
-rw-r--r--arch/x86/xen/enlighten_pv.c15
-rw-r--r--arch/x86/xen/mmu.c2
-rw-r--r--arch/x86/xen/mmu_pv.c102
-rw-r--r--drivers/acpi/button.c9
-rw-r--r--drivers/base/power/wakeup.c11
-rw-r--r--drivers/block/drbd/drbd_req.c27
-rw-r--r--drivers/block/xen-blkback/xenbus.c8
-rw-r--r--drivers/char/lp.c6
-rw-r--r--drivers/char/mem.c5
-rw-r--r--drivers/cpufreq/Kconfig.arm9
-rw-r--r--drivers/cpufreq/Makefile2
-rw-r--r--drivers/dax/super.c2
-rw-r--r--drivers/firmware/efi/efi-pstore.c17
-rw-r--r--drivers/firmware/google/vpd.c21
-rw-r--r--drivers/firmware/ti_sci.c3
-rw-r--r--drivers/gpu/drm/arm/hdlcd_crtc.c47
-rw-r--r--drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c36
-rw-r--r--drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c4
-rw-r--r--drivers/gpu/drm/i915/gvt/handlers.c2
-rw-r--r--drivers/gpu/drm/i915/gvt/render.c3
-rw-r--r--drivers/gpu/drm/i915/gvt/sched_policy.c8
-rw-r--r--drivers/gpu/drm/i915/i915_gem_gtt.c12
-rw-r--r--drivers/gpu/drm/i915/i915_reg.h10
-rw-r--r--drivers/gpu/drm/i915/intel_cdclk.c6
-rw-r--r--drivers/gpu/drm/i915/intel_dsi.c7
-rw-r--r--drivers/gpu/drm/i915/intel_lpe_audio.c5
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_display.c6
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_drm.c6
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.c3
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/secboot/ls_ucode_gr.c4
-rw-r--r--drivers/gpu/host1x/Kconfig1
-rw-r--r--drivers/i2c/busses/i2c-designware-platdrv.c18
-rw-r--r--drivers/iommu/dma-iommu.c13
-rw-r--r--drivers/iommu/intel-iommu.c5
-rw-r--r--drivers/iommu/mtk_iommu_v1.c1
-rw-r--r--drivers/irqchip/irq-mbigen.c17
-rw-r--r--drivers/memory/omap-gpmc.c2
-rw-r--r--drivers/misc/Kconfig1
-rw-r--r--drivers/net/bonding/bond_3ad.c2
-rw-r--r--drivers/net/bonding/bond_main.c5
-rw-r--r--drivers/net/ethernet/atheros/atlx/atl2.c8
-rw-r--r--drivers/net/usb/smsc95xx.c13
-rw-r--r--drivers/nvme/host/fc.c10
-rw-r--r--drivers/nvme/host/pci.c7
-rw-r--r--drivers/nvme/target/core.c6
-rw-r--r--drivers/nvme/target/fc.c4
-rw-r--r--drivers/nvme/target/fcloop.c1
-rw-r--r--drivers/nvme/target/nvmet.h1
-rw-r--r--drivers/nvme/target/rdma.c1
-rw-r--r--drivers/of/fdt.c3
-rw-r--r--drivers/of/of_reserved_mem.c2
-rw-r--r--drivers/powercap/powercap_sys.c1
-rw-r--r--drivers/rtc/rtc-cmos.c2
-rw-r--r--drivers/scsi/cxlflash/Kconfig1
-rw-r--r--drivers/scsi/libfc/fc_fcp.c15
-rw-r--r--drivers/scsi/lpfc/lpfc_crtn.h1
-rw-r--r--drivers/scsi/lpfc/lpfc_ct.c2
-rw-r--r--drivers/scsi/lpfc/lpfc_init.c9
-rw-r--r--drivers/scsi/lpfc/lpfc_nvmet.c1
-rw-r--r--drivers/scsi/lpfc/lpfc_sli.c19
-rw-r--r--drivers/scsi/pmcraid.c3
-rw-r--r--drivers/scsi/qedf/qedf.h2
-rw-r--r--drivers/scsi/qedf/qedf_els.c2
-rw-r--r--drivers/scsi/qedf/qedf_main.c2
-rw-r--r--drivers/scsi/scsi.c2
-rw-r--r--drivers/scsi/scsi_lib.c1
-rw-r--r--drivers/soc/bcm/brcmstb/common.c2
-rw-r--r--drivers/soc/imx/Kconfig3
-rw-r--r--drivers/staging/android/ion/devicetree.txt51
-rw-r--r--drivers/staging/ccree/ssi_request_mgr.c1
-rw-r--r--drivers/staging/fsl-dpaa2/Kconfig1
-rw-r--r--drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c24
-rw-r--r--drivers/staging/rtl8192e/rtl819x_TSProc.c15
-rw-r--r--drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c1
-rw-r--r--drivers/staging/typec/fusb302/fusb302.c86
-rw-r--r--drivers/staging/typec/pd.h10
-rw-r--r--drivers/staging/typec/pd_vdo.h4
-rw-r--r--drivers/staging/typec/tcpci.c2
-rw-r--r--drivers/staging/typec/tcpm.c77
-rw-r--r--drivers/staging/typec/tcpm.h3
-rw-r--r--drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c31
-rw-r--r--drivers/tee/Kconfig1
-rw-r--r--drivers/uio/uio.c8
-rw-r--r--drivers/usb/core/devio.c14
-rw-r--r--drivers/usb/core/hcd.c5
-rw-r--r--drivers/usb/core/hub.c27
-rw-r--r--drivers/usb/core/of.c3
-rw-r--r--drivers/usb/core/urb.c2
-rw-r--r--drivers/usb/dwc3/dwc3-keystone.c4
-rw-r--r--drivers/usb/dwc3/dwc3-pci.c4
-rw-r--r--drivers/usb/dwc3/gadget.c21
-rw-r--r--drivers/usb/gadget/function/f_fs.c10
-rw-r--r--drivers/usb/gadget/function/u_serial.c2
-rw-r--r--drivers/usb/gadget/udc/dummy_hcd.c6
-rw-r--r--drivers/usb/host/ehci-platform.c4
-rw-r--r--drivers/usb/host/r8a66597-hcd.c6
-rw-r--r--drivers/usb/host/xhci-hub.c2
-rw-r--r--drivers/usb/host/xhci-mem.c11
-rw-r--r--drivers/usb/host/xhci-pci.c7
-rw-r--r--drivers/usb/host/xhci-plat.c2
-rw-r--r--drivers/usb/host/xhci-ring.c20
-rw-r--r--drivers/usb/host/xhci.c13
-rw-r--r--drivers/usb/misc/chaoskey.c2
-rw-r--r--drivers/usb/misc/iowarrior.c2
-rw-r--r--drivers/usb/misc/legousbtower.c1
-rw-r--r--drivers/usb/misc/sisusbvga/sisusb_con.c2
-rw-r--r--drivers/usb/musb/musb_host.c9
-rw-r--r--drivers/usb/musb/tusb6010_omap.c13
-rw-r--r--drivers/usb/serial/ftdi_sio.c10
-rw-r--r--drivers/usb/serial/ftdi_sio_ids.h2
-rw-r--r--drivers/usb/serial/io_ti.c5
-rw-r--r--drivers/usb/serial/ir-usb.c21
-rw-r--r--drivers/usb/serial/mct_u232.c2
-rw-r--r--drivers/usb/serial/option.c8
-rw-r--r--drivers/usb/serial/qcserial.c2
-rw-r--r--drivers/usb/storage/ene_ub6250.c90
-rw-r--r--drivers/usb/usbip/vhci_hcd.c11
-rw-r--r--drivers/uwb/i1480/dfu/usb.c5
-rw-r--r--drivers/watchdog/Kconfig2
-rw-r--r--drivers/watchdog/bcm_kona_wdt.c3
-rw-r--r--drivers/watchdog/cadence_wdt.c2
-rw-r--r--drivers/watchdog/iTCO_wdt.c22
-rw-r--r--drivers/watchdog/pcwd_usb.c3
-rw-r--r--drivers/watchdog/sama5d4_wdt.c77
-rw-r--r--drivers/watchdog/wdt_pci.c2
-rw-r--r--drivers/watchdog/zx2967_wdt.c4
-rw-r--r--fs/ext2/inode.c4
-rw-r--r--fs/ext4/inode.c4
-rw-r--r--fs/fuse/inode.c9
-rw-r--r--fs/xfs/xfs_iomap.c4
-rw-r--r--include/kvm/arm_vgic.h5
-rw-r--r--include/linux/dax.h34
-rw-r--r--include/linux/kprobes.h3
-rw-r--r--include/linux/netfilter/x_tables.h2
-rw-r--r--include/linux/netfilter_bridge/ebtables.h5
-rw-r--r--include/linux/nvme-fc-driver.h16
-rw-r--r--include/linux/of_irq.h2
-rw-r--r--include/linux/soc/renesas/rcar-rst.h5
-rw-r--r--include/linux/usb/hcd.h1
-rw-r--r--include/net/netfilter/nf_conntrack_helper.h4
-rw-r--r--include/net/netfilter/nf_tables.h2
-rw-r--r--include/uapi/linux/usb/ch11.h3
-rw-r--r--kernel/bpf/verifier.c12
-rw-r--r--kernel/irq/chip.c2
-rw-r--r--kernel/kprobes.c8
-rw-r--r--kernel/power/snapshot.c2
-rw-r--r--kernel/sched/core.c25
-rw-r--r--kernel/sched/cpufreq_schedutil.c7
-rw-r--r--kernel/sched/idle.c2
-rw-r--r--kernel/sched/sched.h2
-rw-r--r--kernel/trace/blktrace.c4
-rw-r--r--kernel/trace/ftrace.c12
-rw-r--r--kernel/trace/trace.c34
-rw-r--r--kernel/trace/trace.h5
-rw-r--r--kernel/trace/trace_kprobe.c5
-rw-r--r--net/9p/trans_xen.c8
-rw-r--r--net/bridge/br_stp_if.c1
-rw-r--r--net/bridge/br_stp_timer.c2
-rw-r--r--net/bridge/netfilter/ebt_arpreply.c3
-rw-r--r--net/bridge/netfilter/ebtables.c9
-rw-r--r--net/ipv4/arp.c56
-rw-r--r--net/ipv4/tcp.c4
-rw-r--r--net/ipv6/ip6_output.c15
-rw-r--r--net/netfilter/ipvs/ip_vs_core.c19
-rw-r--r--net/netfilter/nf_conntrack_helper.c12
-rw-r--r--net/netfilter/nf_conntrack_netlink.c11
-rw-r--r--net/netfilter/nf_nat_core.c4
-rw-r--r--net/netfilter/nf_tables_api.c160
-rw-r--r--net/netfilter/nfnetlink_cthelper.c17
-rw-r--r--net/netfilter/nft_bitwise.c19
-rw-r--r--net/netfilter/nft_cmp.c12
-rw-r--r--net/netfilter/nft_ct.c4
-rw-r--r--net/netfilter/nft_immediate.c5
-rw-r--r--net/netfilter/nft_range.c4
-rw-r--r--net/netfilter/nft_set_hash.c2
-rw-r--r--net/netfilter/x_tables.c24
-rw-r--r--net/netfilter/xt_CT.c6
-rw-r--r--net/openvswitch/conntrack.c4
-rw-r--r--net/sched/cls_matchall.c1
-rw-r--r--net/vmw_vsock/af_vsock.c21
-rw-r--r--scripts/Makefile.lib2
-rw-r--r--scripts/dtc/checks.c2
l---------scripts/dtc/include-prefixes/arc1
l---------scripts/dtc/include-prefixes/arm1
l---------scripts/dtc/include-prefixes/arm641
l---------scripts/dtc/include-prefixes/c6x1
l---------scripts/dtc/include-prefixes/cris1
l---------scripts/dtc/include-prefixes/dt-bindings1
l---------scripts/dtc/include-prefixes/h83001
l---------scripts/dtc/include-prefixes/metag1
l---------scripts/dtc/include-prefixes/microblaze1
l---------scripts/dtc/include-prefixes/mips1
l---------scripts/dtc/include-prefixes/nios21
l---------scripts/dtc/include-prefixes/openrisc1
l---------scripts/dtc/include-prefixes/powerpc1
l---------scripts/dtc/include-prefixes/sh1
l---------scripts/dtc/include-prefixes/xtensa1
-rw-r--r--sound/x86/intel_hdmi_audio.c4
-rw-r--r--tools/power/acpi/.gitignore4
-rwxr-xr-xtools/testing/selftests/ftrace/ftracetest2
-rw-r--r--tools/testing/selftests/ftrace/test.d/ftrace/func_event_triggers.tc2
-rw-r--r--tools/testing/selftests/ftrace/test.d/functions4
-rw-r--r--tools/testing/selftests/ftrace/test.d/instances/instance-event.tc8
-rw-r--r--tools/testing/selftests/powerpc/tm/.gitignore1
-rw-r--r--tools/testing/selftests/powerpc/tm/Makefile4
-rw-r--r--tools/testing/selftests/powerpc/tm/tm-vmx-unavail.c118
-rw-r--r--virt/kvm/arm/hyp/vgic-v3-sr.c18
-rw-r--r--virt/kvm/arm/mmu.c33
-rw-r--r--virt/kvm/arm/vgic/vgic-init.c5
-rw-r--r--virt/kvm/arm/vgic/vgic-mmio-v3.c12
-rw-r--r--virt/kvm/arm/vgic/vgic-v2.c7
-rw-r--r--virt/kvm/arm/vgic/vgic-v3.c7
294 files changed, 2894 insertions, 1326 deletions
diff --git a/Documentation/acpi/acpi-lid.txt b/Documentation/acpi/acpi-lid.txt
index 22cb3091f297..effe7af3a5af 100644
--- a/Documentation/acpi/acpi-lid.txt
+++ b/Documentation/acpi/acpi-lid.txt
@@ -59,20 +59,28 @@ button driver uses the following 3 modes in order not to trigger issues.
59If the userspace hasn't been prepared to ignore the unreliable "opened" 59If the userspace hasn't been prepared to ignore the unreliable "opened"
60events and the unreliable initial state notification, Linux users can use 60events and the unreliable initial state notification, Linux users can use
61the following kernel parameters to handle the possible issues: 61the following kernel parameters to handle the possible issues:
62A. button.lid_init_state=open: 62A. button.lid_init_state=method:
63 When this option is specified, the ACPI button driver reports the
64 initial lid state using the returning value of the _LID control method
65 and whether the "opened"/"closed" events are paired fully relies on the
66 firmware implementation.
67 This option can be used to fix some platforms where the returning value
68 of the _LID control method is reliable but the initial lid state
69 notification is missing.
70 This option is the default behavior during the period the userspace
71 isn't ready to handle the buggy AML tables.
72B. button.lid_init_state=open:
63 When this option is specified, the ACPI button driver always reports the 73 When this option is specified, the ACPI button driver always reports the
64 initial lid state as "opened" and whether the "opened"/"closed" events 74 initial lid state as "opened" and whether the "opened"/"closed" events
65 are paired fully relies on the firmware implementation. 75 are paired fully relies on the firmware implementation.
66 This may fix some platforms where the returning value of the _LID 76 This may fix some platforms where the returning value of the _LID
67 control method is not reliable and the initial lid state notification is 77 control method is not reliable and the initial lid state notification is
68 missing. 78 missing.
69 This option is the default behavior during the period the userspace
70 isn't ready to handle the buggy AML tables.
71 79
72If the userspace has been prepared to ignore the unreliable "opened" events 80If the userspace has been prepared to ignore the unreliable "opened" events
73and the unreliable initial state notification, Linux users should always 81and the unreliable initial state notification, Linux users should always
74use the following kernel parameter: 82use the following kernel parameter:
75B. button.lid_init_state=ignore: 83C. button.lid_init_state=ignore:
76 When this option is specified, the ACPI button driver never reports the 84 When this option is specified, the ACPI button driver never reports the
77 initial lid state and there is a compensation mechanism implemented to 85 initial lid state and there is a compensation mechanism implemented to
78 ensure that the reliable "closed" notifications can always be delievered 86 ensure that the reliable "closed" notifications can always be delievered
diff --git a/Documentation/admin-guide/pm/cpufreq.rst b/Documentation/admin-guide/pm/cpufreq.rst
index 289c80f7760e..09aa2e949787 100644
--- a/Documentation/admin-guide/pm/cpufreq.rst
+++ b/Documentation/admin-guide/pm/cpufreq.rst
@@ -1,4 +1,5 @@
1.. |struct cpufreq_policy| replace:: :c:type:`struct cpufreq_policy <cpufreq_policy>` 1.. |struct cpufreq_policy| replace:: :c:type:`struct cpufreq_policy <cpufreq_policy>`
2.. |intel_pstate| replace:: :doc:`intel_pstate <intel_pstate>`
2 3
3======================= 4=======================
4CPU Performance Scaling 5CPU Performance Scaling
@@ -75,7 +76,7 @@ feedback registers, as that information is typically specific to the hardware
75interface it comes from and may not be easily represented in an abstract, 76interface it comes from and may not be easily represented in an abstract,
76platform-independent way. For this reason, ``CPUFreq`` allows scaling drivers 77platform-independent way. For this reason, ``CPUFreq`` allows scaling drivers
77to bypass the governor layer and implement their own performance scaling 78to bypass the governor layer and implement their own performance scaling
78algorithms. That is done by the ``intel_pstate`` scaling driver. 79algorithms. That is done by the |intel_pstate| scaling driver.
79 80
80 81
81``CPUFreq`` Policy Objects 82``CPUFreq`` Policy Objects
@@ -174,13 +175,13 @@ necessary to restart the scaling governor so that it can take the new online CPU
174into account. That is achieved by invoking the governor's ``->stop`` and 175into account. That is achieved by invoking the governor's ``->stop`` and
175``->start()`` callbacks, in this order, for the entire policy. 176``->start()`` callbacks, in this order, for the entire policy.
176 177
177As mentioned before, the ``intel_pstate`` scaling driver bypasses the scaling 178As mentioned before, the |intel_pstate| scaling driver bypasses the scaling
178governor layer of ``CPUFreq`` and provides its own P-state selection algorithms. 179governor layer of ``CPUFreq`` and provides its own P-state selection algorithms.
179Consequently, if ``intel_pstate`` is used, scaling governors are not attached to 180Consequently, if |intel_pstate| is used, scaling governors are not attached to
180new policy objects. Instead, the driver's ``->setpolicy()`` callback is invoked 181new policy objects. Instead, the driver's ``->setpolicy()`` callback is invoked
181to register per-CPU utilization update callbacks for each policy. These 182to register per-CPU utilization update callbacks for each policy. These
182callbacks are invoked by the CPU scheduler in the same way as for scaling 183callbacks are invoked by the CPU scheduler in the same way as for scaling
183governors, but in the ``intel_pstate`` case they both determine the P-state to 184governors, but in the |intel_pstate| case they both determine the P-state to
184use and change the hardware configuration accordingly in one go from scheduler 185use and change the hardware configuration accordingly in one go from scheduler
185context. 186context.
186 187
@@ -257,7 +258,7 @@ are the following:
257 258
258``scaling_available_governors`` 259``scaling_available_governors``
259 List of ``CPUFreq`` scaling governors present in the kernel that can 260 List of ``CPUFreq`` scaling governors present in the kernel that can
260 be attached to this policy or (if the ``intel_pstate`` scaling driver is 261 be attached to this policy or (if the |intel_pstate| scaling driver is
261 in use) list of scaling algorithms provided by the driver that can be 262 in use) list of scaling algorithms provided by the driver that can be
262 applied to this policy. 263 applied to this policy.
263 264
@@ -274,7 +275,7 @@ are the following:
274 the CPU is actually running at (due to hardware design and other 275 the CPU is actually running at (due to hardware design and other
275 limitations). 276 limitations).
276 277
277 Some scaling drivers (e.g. ``intel_pstate``) attempt to provide 278 Some scaling drivers (e.g. |intel_pstate|) attempt to provide
278 information more precisely reflecting the current CPU frequency through 279 information more precisely reflecting the current CPU frequency through
279 this attribute, but that still may not be the exact current CPU 280 this attribute, but that still may not be the exact current CPU
280 frequency as seen by the hardware at the moment. 281 frequency as seen by the hardware at the moment.
@@ -284,13 +285,13 @@ are the following:
284 285
285``scaling_governor`` 286``scaling_governor``
286 The scaling governor currently attached to this policy or (if the 287 The scaling governor currently attached to this policy or (if the
287 ``intel_pstate`` scaling driver is in use) the scaling algorithm 288 |intel_pstate| scaling driver is in use) the scaling algorithm
288 provided by the driver that is currently applied to this policy. 289 provided by the driver that is currently applied to this policy.
289 290
290 This attribute is read-write and writing to it will cause a new scaling 291 This attribute is read-write and writing to it will cause a new scaling
291 governor to be attached to this policy or a new scaling algorithm 292 governor to be attached to this policy or a new scaling algorithm
292 provided by the scaling driver to be applied to it (in the 293 provided by the scaling driver to be applied to it (in the
293 ``intel_pstate`` case), as indicated by the string written to this 294 |intel_pstate| case), as indicated by the string written to this
294 attribute (which must be one of the names listed by the 295 attribute (which must be one of the names listed by the
295 ``scaling_available_governors`` attribute described above). 296 ``scaling_available_governors`` attribute described above).
296 297
@@ -619,7 +620,7 @@ This file is located under :file:`/sys/devices/system/cpu/cpufreq/` and controls
619the "boost" setting for the whole system. It is not present if the underlying 620the "boost" setting for the whole system. It is not present if the underlying
620scaling driver does not support the frequency boost mechanism (or supports it, 621scaling driver does not support the frequency boost mechanism (or supports it,
621but provides a driver-specific interface for controlling it, like 622but provides a driver-specific interface for controlling it, like
622``intel_pstate``). 623|intel_pstate|).
623 624
624If the value in this file is 1, the frequency boost mechanism is enabled. This 625If the value in this file is 1, the frequency boost mechanism is enabled. This
625means that either the hardware can be put into states in which it is able to 626means that either the hardware can be put into states in which it is able to
diff --git a/Documentation/admin-guide/pm/index.rst b/Documentation/admin-guide/pm/index.rst
index c80f087321fc..7f148f76f432 100644
--- a/Documentation/admin-guide/pm/index.rst
+++ b/Documentation/admin-guide/pm/index.rst
@@ -6,6 +6,7 @@ Power Management
6 :maxdepth: 2 6 :maxdepth: 2
7 7
8 cpufreq 8 cpufreq
9 intel_pstate
9 10
10.. only:: subproject and html 11.. only:: subproject and html
11 12
diff --git a/Documentation/admin-guide/pm/intel_pstate.rst b/Documentation/admin-guide/pm/intel_pstate.rst
new file mode 100644
index 000000000000..33d703989ea8
--- /dev/null
+++ b/Documentation/admin-guide/pm/intel_pstate.rst
@@ -0,0 +1,755 @@
1===============================================
2``intel_pstate`` CPU Performance Scaling Driver
3===============================================
4
5::
6
7 Copyright (c) 2017 Intel Corp., Rafael J. Wysocki <rafael.j.wysocki@intel.com>
8
9
10General Information
11===================
12
13``intel_pstate`` is a part of the
14:doc:`CPU performance scaling subsystem <cpufreq>` in the Linux kernel
15(``CPUFreq``). It is a scaling driver for the Sandy Bridge and later
16generations of Intel processors. Note, however, that some of those processors
17may not be supported. [To understand ``intel_pstate`` it is necessary to know
18how ``CPUFreq`` works in general, so this is the time to read :doc:`cpufreq` if
19you have not done that yet.]
20
21For the processors supported by ``intel_pstate``, the P-state concept is broader
22than just an operating frequency or an operating performance point (see the
23`LinuxCon Europe 2015 presentation by Kristen Accardi <LCEU2015_>`_ for more
24information about that). For this reason, the representation of P-states used
25by ``intel_pstate`` internally follows the hardware specification (for details
26refer to `Intel® 64 and IA-32 Architectures Software Developer’s Manual
27Volume 3: System Programming Guide <SDM_>`_). However, the ``CPUFreq`` core
28uses frequencies for identifying operating performance points of CPUs and
29frequencies are involved in the user space interface exposed by it, so
30``intel_pstate`` maps its internal representation of P-states to frequencies too
31(fortunately, that mapping is unambiguous). At the same time, it would not be
32practical for ``intel_pstate`` to supply the ``CPUFreq`` core with a table of
33available frequencies due to the possible size of it, so the driver does not do
34that. Some functionality of the core is limited by that.
35
36Since the hardware P-state selection interface used by ``intel_pstate`` is
37available at the logical CPU level, the driver always works with individual
38CPUs. Consequently, if ``intel_pstate`` is in use, every ``CPUFreq`` policy
39object corresponds to one logical CPU and ``CPUFreq`` policies are effectively
40equivalent to CPUs. In particular, this means that they become "inactive" every
41time the corresponding CPU is taken offline and need to be re-initialized when
42it goes back online.
43
44``intel_pstate`` is not modular, so it cannot be unloaded, which means that the
45only way to pass early-configuration-time parameters to it is via the kernel
46command line. However, its configuration can be adjusted via ``sysfs`` to a
47great extent. In some configurations it even is possible to unregister it via
48``sysfs`` which allows another ``CPUFreq`` scaling driver to be loaded and
49registered (see `below <status_attr_>`_).
50
51
52Operation Modes
53===============
54
55``intel_pstate`` can operate in three different modes: in the active mode with
56or without hardware-managed P-states support and in the passive mode. Which of
57them will be in effect depends on what kernel command line options are used and
58on the capabilities of the processor.
59
60Active Mode
61-----------
62
63This is the default operation mode of ``intel_pstate``. If it works in this
64mode, the ``scaling_driver`` policy attribute in ``sysfs`` for all ``CPUFreq``
65policies contains the string "intel_pstate".
66
67In this mode the driver bypasses the scaling governors layer of ``CPUFreq`` and
68provides its own scaling algorithms for P-state selection. Those algorithms
69can be applied to ``CPUFreq`` policies in the same way as generic scaling
70governors (that is, through the ``scaling_governor`` policy attribute in
71``sysfs``). [Note that different P-state selection algorithms may be chosen for
72different policies, but that is not recommended.]
73
74They are not generic scaling governors, but their names are the same as the
75names of some of those governors. Moreover, confusingly enough, they generally
76do not work in the same way as the generic governors they share the names with.
77For example, the ``powersave`` P-state selection algorithm provided by
78``intel_pstate`` is not a counterpart of the generic ``powersave`` governor
79(roughly, it corresponds to the ``schedutil`` and ``ondemand`` governors).
80
81There are two P-state selection algorithms provided by ``intel_pstate`` in the
82active mode: ``powersave`` and ``performance``. The way they both operate
83depends on whether or not the hardware-managed P-states (HWP) feature has been
84enabled in the processor and possibly on the processor model.
85
86Which of the P-state selection algorithms is used by default depends on the
87:c:macro:`CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE` kernel configuration option.
88Namely, if that option is set, the ``performance`` algorithm will be used by
89default, and the other one will be used by default if it is not set.
90
91Active Mode With HWP
92~~~~~~~~~~~~~~~~~~~~
93
94If the processor supports the HWP feature, it will be enabled during the
95processor initialization and cannot be disabled after that. It is possible
96to avoid enabling it by passing the ``intel_pstate=no_hwp`` argument to the
97kernel in the command line.
98
99If the HWP feature has been enabled, ``intel_pstate`` relies on the processor to
100select P-states by itself, but still it can give hints to the processor's
101internal P-state selection logic. What those hints are depends on which P-state
102selection algorithm has been applied to the given policy (or to the CPU it
103corresponds to).
104
105Even though the P-state selection is carried out by the processor automatically,
106``intel_pstate`` registers utilization update callbacks with the CPU scheduler
107in this mode. However, they are not used for running a P-state selection
108algorithm, but for periodic updates of the current CPU frequency information to
109be made available from the ``scaling_cur_freq`` policy attribute in ``sysfs``.
110
111HWP + ``performance``
112.....................
113
114In this configuration ``intel_pstate`` will write 0 to the processor's
115Energy-Performance Preference (EPP) knob (if supported) or its
116Energy-Performance Bias (EPB) knob (otherwise), which means that the processor's
117internal P-state selection logic is expected to focus entirely on performance.
118
119This will override the EPP/EPB setting coming from the ``sysfs`` interface
120(see `Energy vs Performance Hints`_ below).
121
122Also, in this configuration the range of P-states available to the processor's
123internal P-state selection logic is always restricted to the upper boundary
124(that is, the maximum P-state that the driver is allowed to use).
125
126HWP + ``powersave``
127...................
128
129In this configuration ``intel_pstate`` will set the processor's
130Energy-Performance Preference (EPP) knob (if supported) or its
131Energy-Performance Bias (EPB) knob (otherwise) to whatever value it was
132previously set to via ``sysfs`` (or whatever default value it was
133set to by the platform firmware). This usually causes the processor's
134internal P-state selection logic to be less performance-focused.
135
136Active Mode Without HWP
137~~~~~~~~~~~~~~~~~~~~~~~
138
139This is the default operation mode for processors that do not support the HWP
140feature. It also is used by default with the ``intel_pstate=no_hwp`` argument
141in the kernel command line. However, in this mode ``intel_pstate`` may refuse
142to work with the given processor if it does not recognize it. [Note that
143``intel_pstate`` will never refuse to work with any processor with the HWP
144feature enabled.]
145
146In this mode ``intel_pstate`` registers utilization update callbacks with the
147CPU scheduler in order to run a P-state selection algorithm, either
148``powersave`` or ``performance``, depending on the ``scaling_cur_freq`` policy
149setting in ``sysfs``. The current CPU frequency information to be made
150available from the ``scaling_cur_freq`` policy attribute in ``sysfs`` is
151periodically updated by those utilization update callbacks too.
152
153``performance``
154...............
155
156Without HWP, this P-state selection algorithm is always the same regardless of
157the processor model and platform configuration.
158
159It selects the maximum P-state it is allowed to use, subject to limits set via
160``sysfs``, every time the P-state selection computations are carried out by the
161driver's utilization update callback for the given CPU (that does not happen
162more often than every 10 ms), but the hardware configuration will not be changed
163if the new P-state is the same as the current one.
164
165This is the default P-state selection algorithm if the
166:c:macro:`CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE` kernel configuration option
167is set.
168
169``powersave``
170.............
171
172Without HWP, this P-state selection algorithm generally depends on the
173processor model and/or the system profile setting in the ACPI tables and there
174are two variants of it.
175
176One of them is used with processors from the Atom line and (regardless of the
177processor model) on platforms with the system profile in the ACPI tables set to
178"mobile" (laptops mostly), "tablet", "appliance PC", "desktop", or
179"workstation". It is also used with processors supporting the HWP feature if
180that feature has not been enabled (that is, with the ``intel_pstate=no_hwp``
181argument in the kernel command line). It is similar to the algorithm
182implemented by the generic ``schedutil`` scaling governor except that the
183utilization metric used by it is based on numbers coming from feedback
184registers of the CPU. It generally selects P-states proportional to the
185current CPU utilization, so it is referred to as the "proportional" algorithm.
186
187The second variant of the ``powersave`` P-state selection algorithm, used in all
188of the other cases (generally, on processors from the Core line, so it is
189referred to as the "Core" algorithm), is based on the values read from the APERF
190and MPERF feedback registers and the previously requested target P-state.
191It does not really take CPU utilization into account explicitly, but as a rule
192it causes the CPU P-state to ramp up very quickly in response to increased
193utilization which is generally desirable in server environments.
194
195Regardless of the variant, this algorithm is run by the driver's utilization
196update callback for the given CPU when it is invoked by the CPU scheduler, but
197not more often than every 10 ms (that can be tweaked via ``debugfs`` in `this
198particular case <Tuning Interface in debugfs_>`_). Like in the ``performance``
199case, the hardware configuration is not touched if the new P-state turns out to
200be the same as the current one.
201
202This is the default P-state selection algorithm if the
203:c:macro:`CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE` kernel configuration option
204is not set.
205
206Passive Mode
207------------
208
209This mode is used if the ``intel_pstate=passive`` argument is passed to the
210kernel in the command line (it implies the ``intel_pstate=no_hwp`` setting too).
211Like in the active mode without HWP support, in this mode ``intel_pstate`` may
212refuse to work with the given processor if it does not recognize it.
213
214If the driver works in this mode, the ``scaling_driver`` policy attribute in
215``sysfs`` for all ``CPUFreq`` policies contains the string "intel_cpufreq".
216Then, the driver behaves like a regular ``CPUFreq`` scaling driver. That is,
217it is invoked by generic scaling governors when necessary to talk to the
218hardware in order to change the P-state of a CPU (in particular, the
219``schedutil`` governor can invoke it directly from scheduler context).
220
221While in this mode, ``intel_pstate`` can be used with all of the (generic)
222scaling governors listed by the ``scaling_available_governors`` policy attribute
223in ``sysfs`` (and the P-state selection algorithms described above are not
224used). Then, it is responsible for the configuration of policy objects
225corresponding to CPUs and provides the ``CPUFreq`` core (and the scaling
226governors attached to the policy objects) with accurate information on the
227maximum and minimum operating frequencies supported by the hardware (including
228the so-called "turbo" frequency ranges). In other words, in the passive mode
229the entire range of available P-states is exposed by ``intel_pstate`` to the
230``CPUFreq`` core. However, in this mode the driver does not register
231utilization update callbacks with the CPU scheduler and the ``scaling_cur_freq``
232information comes from the ``CPUFreq`` core (and is the last frequency selected
233by the current scaling governor for the given policy).
234
235
236.. _turbo:
237
238Turbo P-states Support
239======================
240
241In the majority of cases, the entire range of P-states available to
242``intel_pstate`` can be divided into two sub-ranges that correspond to
243different types of processor behavior, above and below a boundary that
244will be referred to as the "turbo threshold" in what follows.
245
246The P-states above the turbo threshold are referred to as "turbo P-states" and
247the whole sub-range of P-states they belong to is referred to as the "turbo
248range". These names are related to the Turbo Boost technology allowing a
249multicore processor to opportunistically increase the P-state of one or more
250cores if there is enough power to do that and if that is not going to cause the
251thermal envelope of the processor package to be exceeded.
252
253Specifically, if software sets the P-state of a CPU core within the turbo range
254(that is, above the turbo threshold), the processor is permitted to take over
255performance scaling control for that core and put it into turbo P-states of its
256choice going forward. However, that permission is interpreted differently by
257different processor generations. Namely, the Sandy Bridge generation of
258processors will never use any P-states above the last one set by software for
259the given core, even if it is within the turbo range, whereas all of the later
260processor generations will take it as a license to use any P-states from the
261turbo range, even above the one set by software. In other words, on those
262processors setting any P-state from the turbo range will enable the processor
263to put the given core into all turbo P-states up to and including the maximum
264supported one as it sees fit.
265
266One important property of turbo P-states is that they are not sustainable. More
267precisely, there is no guarantee that any CPUs will be able to stay in any of
268those states indefinitely, because the power distribution within the processor
269package may change over time or the thermal envelope it was designed for might
270be exceeded if a turbo P-state was used for too long.
271
272In turn, the P-states below the turbo threshold generally are sustainable. In
273fact, if one of them is set by software, the processor is not expected to change
274it to a lower one unless in a thermal stress or a power limit violation
275situation (a higher P-state may still be used if it is set for another CPU in
276the same package at the same time, for example).
277
278Some processors allow multiple cores to be in turbo P-states at the same time,
279but the maximum P-state that can be set for them generally depends on the number
280of cores running concurrently. The maximum turbo P-state that can be set for 3
281cores at the same time usually is lower than the analogous maximum P-state for
2822 cores, which in turn usually is lower than the maximum turbo P-state that can
283be set for 1 core. The one-core maximum turbo P-state is thus the maximum
284supported one overall.
285
286The maximum supported turbo P-state, the turbo threshold (the maximum supported
287non-turbo P-state) and the minimum supported P-state are specific to the
288processor model and can be determined by reading the processor's model-specific
289registers (MSRs). Moreover, some processors support the Configurable TDP
290(Thermal Design Power) feature and, when that feature is enabled, the turbo
291threshold effectively becomes a configurable value that can be set by the
292platform firmware.
293
294Unlike ``_PSS`` objects in the ACPI tables, ``intel_pstate`` always exposes
295the entire range of available P-states, including the whole turbo range, to the
296``CPUFreq`` core and (in the passive mode) to generic scaling governors. This
297generally causes turbo P-states to be set more often when ``intel_pstate`` is
298used relative to ACPI-based CPU performance scaling (see `below <acpi-cpufreq_>`_
299for more information).
300
301Moreover, since ``intel_pstate`` always knows what the real turbo threshold is
302(even if the Configurable TDP feature is enabled in the processor), its
303``no_turbo`` attribute in ``sysfs`` (described `below <no_turbo_attr_>`_) should
304work as expected in all cases (that is, if set to disable turbo P-states, it
305always should prevent ``intel_pstate`` from using them).
306
307
308Processor Support
309=================
310
311To handle a given processor ``intel_pstate`` requires a number of different
312pieces of information on it to be known, including:
313
314 * The minimum supported P-state.
315
316 * The maximum supported `non-turbo P-state <turbo_>`_.
317
318 * Whether or not turbo P-states are supported at all.
319
320 * The maximum supported `one-core turbo P-state <turbo_>`_ (if turbo P-states
321 are supported).
322
323 * The scaling formula to translate the driver's internal representation
324 of P-states into frequencies and the other way around.
325
326Generally, ways to obtain that information are specific to the processor model
327or family. Although it often is possible to obtain all of it from the processor
328itself (using model-specific registers), there are cases in which hardware
329manuals need to be consulted to get to it too.
330
331For this reason, there is a list of supported processors in ``intel_pstate`` and
332the driver initialization will fail if the detected processor is not in that
333list, unless it supports the `HWP feature <Active Mode_>`_. [The interface to
334obtain all of the information listed above is the same for all of the processors
335supporting the HWP feature, which is why they all are supported by
336``intel_pstate``.]
337
338
339User Space Interface in ``sysfs``
340=================================
341
342Global Attributes
343-----------------
344
345``intel_pstate`` exposes several global attributes (files) in ``sysfs`` to
346control its functionality at the system level. They are located in the
347``/sys/devices/system/cpu/cpufreq/intel_pstate/`` directory and affect all
348CPUs.
349
350Some of them are not present if the ``intel_pstate=per_cpu_perf_limits``
351argument is passed to the kernel in the command line.
352
353``max_perf_pct``
354 Maximum P-state the driver is allowed to set in percent of the
355 maximum supported performance level (the highest supported `turbo
356 P-state <turbo_>`_).
357
358 This attribute will not be exposed if the
359 ``intel_pstate=per_cpu_perf_limits`` argument is present in the kernel
360 command line.
361
362``min_perf_pct``
363 Minimum P-state the driver is allowed to set in percent of the
364 maximum supported performance level (the highest supported `turbo
365 P-state <turbo_>`_).
366
367 This attribute will not be exposed if the
368 ``intel_pstate=per_cpu_perf_limits`` argument is present in the kernel
369 command line.
370
371``num_pstates``
372 Number of P-states supported by the processor (between 0 and 255
373 inclusive) including both turbo and non-turbo P-states (see
374 `Turbo P-states Support`_).
375
376 The value of this attribute is not affected by the ``no_turbo``
377 setting described `below <no_turbo_attr_>`_.
378
379 This attribute is read-only.
380
381``turbo_pct``
382 Ratio of the `turbo range <turbo_>`_ size to the size of the entire
383 range of supported P-states, in percent.
384
385 This attribute is read-only.
386
387.. _no_turbo_attr:
388
389``no_turbo``
390 If set (equal to 1), the driver is not allowed to set any turbo P-states
391 (see `Turbo P-states Support`_). If unset (equalt to 0, which is the
392 default), turbo P-states can be set by the driver.
393 [Note that ``intel_pstate`` does not support the general ``boost``
394 attribute (supported by some other scaling drivers) which is replaced
395 by this one.]
396
397 This attrubute does not affect the maximum supported frequency value
398 supplied to the ``CPUFreq`` core and exposed via the policy interface,
399 but it affects the maximum possible value of per-policy P-state limits
400 (see `Interpretation of Policy Attributes`_ below for details).
401
402.. _status_attr:
403
404``status``
405 Operation mode of the driver: "active", "passive" or "off".
406
407 "active"
408 The driver is functional and in the `active mode
409 <Active Mode_>`_.
410
411 "passive"
412 The driver is functional and in the `passive mode
413 <Passive Mode_>`_.
414
415 "off"
416 The driver is not functional (it is not registered as a scaling
417 driver with the ``CPUFreq`` core).
418
419 This attribute can be written to in order to change the driver's
420 operation mode or to unregister it. The string written to it must be
421 one of the possible values of it and, if successful, the write will
422 cause the driver to switch over to the operation mode represented by
423 that string - or to be unregistered in the "off" case. [Actually,
424 switching over from the active mode to the passive mode or the other
425 way around causes the driver to be unregistered and registered again
426 with a different set of callbacks, so all of its settings (the global
427 as well as the per-policy ones) are then reset to their default
428 values, possibly depending on the target operation mode.]
429
430 That only is supported in some configurations, though (for example, if
431 the `HWP feature is enabled in the processor <Active Mode With HWP_>`_,
432 the operation mode of the driver cannot be changed), and if it is not
433 supported in the current configuration, writes to this attribute with
434 fail with an appropriate error.
435
436Interpretation of Policy Attributes
437-----------------------------------
438
439The interpretation of some ``CPUFreq`` policy attributes described in
440:doc:`cpufreq` is special with ``intel_pstate`` as the current scaling driver
441and it generally depends on the driver's `operation mode <Operation Modes_>`_.
442
443First of all, the values of the ``cpuinfo_max_freq``, ``cpuinfo_min_freq`` and
444``scaling_cur_freq`` attributes are produced by applying a processor-specific
445multiplier to the internal P-state representation used by ``intel_pstate``.
446Also, the values of the ``scaling_max_freq`` and ``scaling_min_freq``
447attributes are capped by the frequency corresponding to the maximum P-state that
448the driver is allowed to set.
449
450If the ``no_turbo`` `global attribute <no_turbo_attr_>`_ is set, the driver is
451not allowed to use turbo P-states, so the maximum value of ``scaling_max_freq``
452and ``scaling_min_freq`` is limited to the maximum non-turbo P-state frequency.
453Accordingly, setting ``no_turbo`` causes ``scaling_max_freq`` and
454``scaling_min_freq`` to go down to that value if they were above it before.
455However, the old values of ``scaling_max_freq`` and ``scaling_min_freq`` will be
456restored after unsetting ``no_turbo``, unless these attributes have been written
457to after ``no_turbo`` was set.
458
459If ``no_turbo`` is not set, the maximum possible value of ``scaling_max_freq``
460and ``scaling_min_freq`` corresponds to the maximum supported turbo P-state,
461which also is the value of ``cpuinfo_max_freq`` in either case.
462
463Next, the following policy attributes have special meaning if
464``intel_pstate`` works in the `active mode <Active Mode_>`_:
465
466``scaling_available_governors``
467 List of P-state selection algorithms provided by ``intel_pstate``.
468
469``scaling_governor``
470 P-state selection algorithm provided by ``intel_pstate`` currently in
471 use with the given policy.
472
473``scaling_cur_freq``
474 Frequency of the average P-state of the CPU represented by the given
475 policy for the time interval between the last two invocations of the
476 driver's utilization update callback by the CPU scheduler for that CPU.
477
478The meaning of these attributes in the `passive mode <Passive Mode_>`_ is the
479same as for other scaling drivers.
480
481Additionally, the value of the ``scaling_driver`` attribute for ``intel_pstate``
482depends on the operation mode of the driver. Namely, it is either
483"intel_pstate" (in the `active mode <Active Mode_>`_) or "intel_cpufreq" (in the
484`passive mode <Passive Mode_>`_).
485
486Coordination of P-State Limits
487------------------------------
488
489``intel_pstate`` allows P-state limits to be set in two ways: with the help of
490the ``max_perf_pct`` and ``min_perf_pct`` `global attributes
491<Global Attributes_>`_ or via the ``scaling_max_freq`` and ``scaling_min_freq``
492``CPUFreq`` policy attributes. The coordination between those limits is based
493on the following rules, regardless of the current operation mode of the driver:
494
495 1. All CPUs are affected by the global limits (that is, none of them can be
496 requested to run faster than the global maximum and none of them can be
497 requested to run slower than the global minimum).
498
499 2. Each individual CPU is affected by its own per-policy limits (that is, it
500 cannot be requested to run faster than its own per-policy maximum and it
501 cannot be requested to run slower than its own per-policy minimum).
502
503 3. The global and per-policy limits can be set independently.
504
505If the `HWP feature is enabled in the processor <Active Mode With HWP_>`_, the
506resulting effective values are written into its registers whenever the limits
507change in order to request its internal P-state selection logic to always set
508P-states within these limits. Otherwise, the limits are taken into account by
509scaling governors (in the `passive mode <Passive Mode_>`_) and by the driver
510every time before setting a new P-state for a CPU.
511
512Additionally, if the ``intel_pstate=per_cpu_perf_limits`` command line argument
513is passed to the kernel, ``max_perf_pct`` and ``min_perf_pct`` are not exposed
514at all and the only way to set the limits is by using the policy attributes.
515
516
517Energy vs Performance Hints
518---------------------------
519
520If ``intel_pstate`` works in the `active mode with the HWP feature enabled
521<Active Mode With HWP_>`_ in the processor, additional attributes are present
522in every ``CPUFreq`` policy directory in ``sysfs``. They are intended to allow
523user space to help ``intel_pstate`` to adjust the processor's internal P-state
524selection logic by focusing it on performance or on energy-efficiency, or
525somewhere between the two extremes:
526
527``energy_performance_preference``
528 Current value of the energy vs performance hint for the given policy
529 (or the CPU represented by it).
530
531 The hint can be changed by writing to this attribute.
532
533``energy_performance_available_preferences``
534 List of strings that can be written to the
535 ``energy_performance_preference`` attribute.
536
537 They represent different energy vs performance hints and should be
538 self-explanatory, except that ``default`` represents whatever hint
539 value was set by the platform firmware.
540
541Strings written to the ``energy_performance_preference`` attribute are
542internally translated to integer values written to the processor's
543Energy-Performance Preference (EPP) knob (if supported) or its
544Energy-Performance Bias (EPB) knob.
545
546[Note that tasks may by migrated from one CPU to another by the scheduler's
547load-balancing algorithm and if different energy vs performance hints are
548set for those CPUs, that may lead to undesirable outcomes. To avoid such
549issues it is better to set the same energy vs performance hint for all CPUs
550or to pin every task potentially sensitive to them to a specific CPU.]
551
552.. _acpi-cpufreq:
553
554``intel_pstate`` vs ``acpi-cpufreq``
555====================================
556
557On the majority of systems supported by ``intel_pstate``, the ACPI tables
558provided by the platform firmware contain ``_PSS`` objects returning information
559that can be used for CPU performance scaling (refer to the `ACPI specification`_
560for details on the ``_PSS`` objects and the format of the information returned
561by them).
562
563The information returned by the ACPI ``_PSS`` objects is used by the
564``acpi-cpufreq`` scaling driver. On systems supported by ``intel_pstate``
565the ``acpi-cpufreq`` driver uses the same hardware CPU performance scaling
566interface, but the set of P-states it can use is limited by the ``_PSS``
567output.
568
569On those systems each ``_PSS`` object returns a list of P-states supported by
570the corresponding CPU which basically is a subset of the P-states range that can
571be used by ``intel_pstate`` on the same system, with one exception: the whole
572`turbo range <turbo_>`_ is represented by one item in it (the topmost one). By
573convention, the frequency returned by ``_PSS`` for that item is greater by 1 MHz
574than the frequency of the highest non-turbo P-state listed by it, but the
575corresponding P-state representation (following the hardware specification)
576returned for it matches the maximum supported turbo P-state (or is the
577special value 255 meaning essentially "go as high as you can get").
578
579The list of P-states returned by ``_PSS`` is reflected by the table of
580available frequencies supplied by ``acpi-cpufreq`` to the ``CPUFreq`` core and
581scaling governors and the minimum and maximum supported frequencies reported by
582it come from that list as well. In particular, given the special representation
583of the turbo range described above, this means that the maximum supported
584frequency reported by ``acpi-cpufreq`` is higher by 1 MHz than the frequency
585of the highest supported non-turbo P-state listed by ``_PSS`` which, of course,
586affects decisions made by the scaling governors, except for ``powersave`` and
587``performance``.
588
589For example, if a given governor attempts to select a frequency proportional to
590estimated CPU load and maps the load of 100% to the maximum supported frequency
591(possibly multiplied by a constant), then it will tend to choose P-states below
592the turbo threshold if ``acpi-cpufreq`` is used as the scaling driver, because
593in that case the turbo range corresponds to a small fraction of the frequency
594band it can use (1 MHz vs 1 GHz or more). In consequence, it will only go to
595the turbo range for the highest loads and the other loads above 50% that might
596benefit from running at turbo frequencies will be given non-turbo P-states
597instead.
598
599One more issue related to that may appear on systems supporting the
600`Configurable TDP feature <turbo_>`_ allowing the platform firmware to set the
601turbo threshold. Namely, if that is not coordinated with the lists of P-states
602returned by ``_PSS`` properly, there may be more than one item corresponding to
603a turbo P-state in those lists and there may be a problem with avoiding the
604turbo range (if desirable or necessary). Usually, to avoid using turbo
605P-states overall, ``acpi-cpufreq`` simply avoids using the topmost state listed
606by ``_PSS``, but that is not sufficient when there are other turbo P-states in
607the list returned by it.
608
609Apart from the above, ``acpi-cpufreq`` works like ``intel_pstate`` in the
610`passive mode <Passive Mode_>`_, except that the number of P-states it can set
611is limited to the ones listed by the ACPI ``_PSS`` objects.
612
613
614Kernel Command Line Options for ``intel_pstate``
615================================================
616
617Several kernel command line options can be used to pass early-configuration-time
618parameters to ``intel_pstate`` in order to enforce specific behavior of it. All
619of them have to be prepended with the ``intel_pstate=`` prefix.
620
621``disable``
622 Do not register ``intel_pstate`` as the scaling driver even if the
623 processor is supported by it.
624
625``passive``
626 Register ``intel_pstate`` in the `passive mode <Passive Mode_>`_ to
627 start with.
628
629 This option implies the ``no_hwp`` one described below.
630
631``force``
632 Register ``intel_pstate`` as the scaling driver instead of
633 ``acpi-cpufreq`` even if the latter is preferred on the given system.
634
635 This may prevent some platform features (such as thermal controls and
636 power capping) that rely on the availability of ACPI P-states
637 information from functioning as expected, so it should be used with
638 caution.
639
640 This option does not work with processors that are not supported by
641 ``intel_pstate`` and on platforms where the ``pcc-cpufreq`` scaling
642 driver is used instead of ``acpi-cpufreq``.
643
644``no_hwp``
645 Do not enable the `hardware-managed P-states (HWP) feature
646 <Active Mode With HWP_>`_ even if it is supported by the processor.
647
648``hwp_only``
649 Register ``intel_pstate`` as the scaling driver only if the
650 `hardware-managed P-states (HWP) feature <Active Mode With HWP_>`_ is
651 supported by the processor.
652
653``support_acpi_ppc``
654 Take ACPI ``_PPC`` performance limits into account.
655
656 If the preferred power management profile in the FADT (Fixed ACPI
657 Description Table) is set to "Enterprise Server" or "Performance
658 Server", the ACPI ``_PPC`` limits are taken into account by default
659 and this option has no effect.
660
661``per_cpu_perf_limits``
662 Use per-logical-CPU P-State limits (see `Coordination of P-state
663 Limits`_ for details).
664
665
666Diagnostics and Tuning
667======================
668
669Trace Events
670------------
671
672There are two static trace events that can be used for ``intel_pstate``
673diagnostics. One of them is the ``cpu_frequency`` trace event generally used
674by ``CPUFreq``, and the other one is the ``pstate_sample`` trace event specific
675to ``intel_pstate``. Both of them are triggered by ``intel_pstate`` only if
676it works in the `active mode <Active Mode_>`_.
677
678The following sequence of shell commands can be used to enable them and see
679their output (if the kernel is generally configured to support event tracing)::
680
681 # cd /sys/kernel/debug/tracing/
682 # echo 1 > events/power/pstate_sample/enable
683 # echo 1 > events/power/cpu_frequency/enable
684 # cat trace
685 gnome-terminal--4510 [001] ..s. 1177.680733: pstate_sample: core_busy=107 scaled=94 from=26 to=26 mperf=1143818 aperf=1230607 tsc=29838618 freq=2474476
686 cat-5235 [002] ..s. 1177.681723: cpu_frequency: state=2900000 cpu_id=2
687
688If ``intel_pstate`` works in the `passive mode <Passive Mode_>`_, the
689``cpu_frequency`` trace event will be triggered either by the ``schedutil``
690scaling governor (for the policies it is attached to), or by the ``CPUFreq``
691core (for the policies with other scaling governors).
692
693``ftrace``
694----------
695
696The ``ftrace`` interface can be used for low-level diagnostics of
697``intel_pstate``. For example, to check how often the function to set a
698P-state is called, the ``ftrace`` filter can be set to to
699:c:func:`intel_pstate_set_pstate`::
700
701 # cd /sys/kernel/debug/tracing/
702 # cat available_filter_functions | grep -i pstate
703 intel_pstate_set_pstate
704 intel_pstate_cpu_init
705 ...
706 # echo intel_pstate_set_pstate > set_ftrace_filter
707 # echo function > current_tracer
708 # cat trace | head -15
709 # tracer: function
710 #
711 # entries-in-buffer/entries-written: 80/80 #P:4
712 #
713 # _-----=> irqs-off
714 # / _----=> need-resched
715 # | / _---=> hardirq/softirq
716 # || / _--=> preempt-depth
717 # ||| / delay
718 # TASK-PID CPU# |||| TIMESTAMP FUNCTION
719 # | | | |||| | |
720 Xorg-3129 [000] ..s. 2537.644844: intel_pstate_set_pstate <-intel_pstate_timer_func
721 gnome-terminal--4510 [002] ..s. 2537.649844: intel_pstate_set_pstate <-intel_pstate_timer_func
722 gnome-shell-3409 [001] ..s. 2537.650850: intel_pstate_set_pstate <-intel_pstate_timer_func
723 <idle>-0 [000] ..s. 2537.654843: intel_pstate_set_pstate <-intel_pstate_timer_func
724
725Tuning Interface in ``debugfs``
726-------------------------------
727
728The ``powersave`` algorithm provided by ``intel_pstate`` for `the Core line of
729processors in the active mode <powersave_>`_ is based on a `PID controller`_
730whose parameters were chosen to address a number of different use cases at the
731same time. However, it still is possible to fine-tune it to a specific workload
732and the ``debugfs`` interface under ``/sys/kernel/debug/pstate_snb/`` is
733provided for this purpose. [Note that the ``pstate_snb`` directory will be
734present only if the specific P-state selection algorithm matching the interface
735in it actually is in use.]
736
737The following files present in that directory can be used to modify the PID
738controller parameters at run time:
739
740| ``deadband``
741| ``d_gain_pct``
742| ``i_gain_pct``
743| ``p_gain_pct``
744| ``sample_rate_ms``
745| ``setpoint``
746
747Note, however, that achieving desirable results this way generally requires
748expert-level understanding of the power vs performance tradeoff, so extra care
749is recommended when attempting to do that.
750
751
752.. _LCEU2015: http://events.linuxfoundation.org/sites/events/files/slides/LinuxConEurope_2015.pdf
753.. _SDM: http://www.intel.com/content/www/us/en/architecture-and-technology/64-ia-32-architectures-software-developer-system-programming-manual-325384.html
754.. _ACPI specification: http://www.uefi.org/sites/default/files/resources/ACPI_6_1.pdf
755.. _PID controller: https://en.wikipedia.org/wiki/PID_controller
diff --git a/Documentation/cpu-freq/intel-pstate.txt b/Documentation/cpu-freq/intel-pstate.txt
deleted file mode 100644
index 3fdcdfd968ba..000000000000
--- a/Documentation/cpu-freq/intel-pstate.txt
+++ /dev/null
@@ -1,281 +0,0 @@
1Intel P-State driver
2--------------------
3
4This driver provides an interface to control the P-State selection for the
5SandyBridge+ Intel processors.
6
7The following document explains P-States:
8http://events.linuxfoundation.org/sites/events/files/slides/LinuxConEurope_2015.pdf
9As stated in the document, P-State doesn’t exactly mean a frequency. However, for
10the sake of the relationship with cpufreq, P-State and frequency are used
11interchangeably.
12
13Understanding the cpufreq core governors and policies are important before
14discussing more details about the Intel P-State driver. Based on what callbacks
15a cpufreq driver provides to the cpufreq core, it can support two types of
16drivers:
17- with target_index() callback: In this mode, the drivers using cpufreq core
18simply provide the minimum and maximum frequency limits and an additional
19interface target_index() to set the current frequency. The cpufreq subsystem
20has a number of scaling governors ("performance", "powersave", "ondemand",
21etc.). Depending on which governor is in use, cpufreq core will call for
22transitions to a specific frequency using target_index() callback.
23- setpolicy() callback: In this mode, drivers do not provide target_index()
24callback, so cpufreq core can't request a transition to a specific frequency.
25The driver provides minimum and maximum frequency limits and callbacks to set a
26policy. The policy in cpufreq sysfs is referred to as the "scaling governor".
27The cpufreq core can request the driver to operate in any of the two policies:
28"performance" and "powersave". The driver decides which frequency to use based
29on the above policy selection considering minimum and maximum frequency limits.
30
31The Intel P-State driver falls under the latter category, which implements the
32setpolicy() callback. This driver decides what P-State to use based on the
33requested policy from the cpufreq core. If the processor is capable of
34selecting its next P-State internally, then the driver will offload this
35responsibility to the processor (aka HWP: Hardware P-States). If not, the
36driver implements algorithms to select the next P-State.
37
38Since these policies are implemented in the driver, they are not same as the
39cpufreq scaling governors implementation, even if they have the same name in
40the cpufreq sysfs (scaling_governors). For example the "performance" policy is
41similar to cpufreq’s "performance" governor, but "powersave" is completely
42different than the cpufreq "powersave" governor. The strategy here is similar
43to cpufreq "ondemand", where the requested P-State is related to the system load.
44
45Sysfs Interface
46
47In addition to the frequency-controlling interfaces provided by the cpufreq
48core, the driver provides its own sysfs files to control the P-State selection.
49These files have been added to /sys/devices/system/cpu/intel_pstate/.
50Any changes made to these files are applicable to all CPUs (even in a
51multi-package system, Refer to later section on placing "Per-CPU limits").
52
53 max_perf_pct: Limits the maximum P-State that will be requested by
54 the driver. It states it as a percentage of the available performance. The
55 available (P-State) performance may be reduced by the no_turbo
56 setting described below.
57
58 min_perf_pct: Limits the minimum P-State that will be requested by
59 the driver. It states it as a percentage of the max (non-turbo)
60 performance level.
61
62 no_turbo: Limits the driver to selecting P-State below the turbo
63 frequency range.
64
65 turbo_pct: Displays the percentage of the total performance that
66 is supported by hardware that is in the turbo range. This number
67 is independent of whether turbo has been disabled or not.
68
69 num_pstates: Displays the number of P-States that are supported
70 by hardware. This number is independent of whether turbo has
71 been disabled or not.
72
73For example, if a system has these parameters:
74 Max 1 core turbo ratio: 0x21 (Max 1 core ratio is the maximum P-State)
75 Max non turbo ratio: 0x17
76 Minimum ratio : 0x08 (Here the ratio is called max efficiency ratio)
77
78Sysfs will show :
79 max_perf_pct:100, which corresponds to 1 core ratio
80 min_perf_pct:24, max_efficiency_ratio / max 1 Core ratio
81 no_turbo:0, turbo is not disabled
82 num_pstates:26 = (max 1 Core ratio - Max Efficiency Ratio + 1)
83 turbo_pct:39 = (max 1 core ratio - max non turbo ratio) / num_pstates
84
85Refer to "Intel® 64 and IA-32 Architectures Software Developer’s Manual
86Volume 3: System Programming Guide" to understand ratios.
87
88There is one more sysfs attribute in /sys/devices/system/cpu/intel_pstate/
89that can be used for controlling the operation mode of the driver:
90
91 status: Three settings are possible:
92 "off" - The driver is not in use at this time.
93 "active" - The driver works as a P-state governor (default).
94 "passive" - The driver works as a regular cpufreq one and collaborates
95 with the generic cpufreq governors (it sets P-states as
96 requested by those governors).
97 The current setting is returned by reads from this attribute. Writing one
98 of the above strings to it changes the operation mode as indicated by that
99 string, if possible. If HW-managed P-states (HWP) are enabled, it is not
100 possible to change the driver's operation mode and attempts to write to
101 this attribute will fail.
102
103cpufreq sysfs for Intel P-State
104
105Since this driver registers with cpufreq, cpufreq sysfs is also presented.
106There are some important differences, which need to be considered.
107
108scaling_cur_freq: This displays the real frequency which was used during
109the last sample period instead of what is requested. Some other cpufreq driver,
110like acpi-cpufreq, displays what is requested (Some changes are on the
111way to fix this for acpi-cpufreq driver). The same is true for frequencies
112displayed at /proc/cpuinfo.
113
114scaling_governor: This displays current active policy. Since each CPU has a
115cpufreq sysfs, it is possible to set a scaling governor to each CPU. But this
116is not possible with Intel P-States, as there is one common policy for all
117CPUs. Here, the last requested policy will be applicable to all CPUs. It is
118suggested that one use the cpupower utility to change policy to all CPUs at the
119same time.
120
121scaling_setspeed: This attribute can never be used with Intel P-State.
122
123scaling_max_freq/scaling_min_freq: This interface can be used similarly to
124the max_perf_pct/min_perf_pct of Intel P-State sysfs. However since frequencies
125are converted to nearest possible P-State, this is prone to rounding errors.
126This method is not preferred to limit performance.
127
128affected_cpus: Not used
129related_cpus: Not used
130
131For contemporary Intel processors, the frequency is controlled by the
132processor itself and the P-State exposed to software is related to
133performance levels. The idea that frequency can be set to a single
134frequency is fictional for Intel Core processors. Even if the scaling
135driver selects a single P-State, the actual frequency the processor
136will run at is selected by the processor itself.
137
138Per-CPU limits
139
140The kernel command line option "intel_pstate=per_cpu_perf_limits" forces
141the intel_pstate driver to use per-CPU performance limits. When it is set,
142the sysfs control interface described above is subject to limitations.
143- The following controls are not available for both read and write
144 /sys/devices/system/cpu/intel_pstate/max_perf_pct
145 /sys/devices/system/cpu/intel_pstate/min_perf_pct
146- The following controls can be used to set performance limits, as far as the
147architecture of the processor permits:
148 /sys/devices/system/cpu/cpu*/cpufreq/scaling_max_freq
149 /sys/devices/system/cpu/cpu*/cpufreq/scaling_min_freq
150 /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
151- User can still observe turbo percent and number of P-States from
152 /sys/devices/system/cpu/intel_pstate/turbo_pct
153 /sys/devices/system/cpu/intel_pstate/num_pstates
154- User can read write system wide turbo status
155 /sys/devices/system/cpu/no_turbo
156
157Support of energy performance hints
158It is possible to provide hints to the HWP algorithms in the processor
159to be more performance centric to more energy centric. When the driver
160is using HWP, two additional cpufreq sysfs attributes are presented for
161each logical CPU.
162These attributes are:
163 - energy_performance_available_preferences
164 - energy_performance_preference
165
166To get list of supported hints:
167$ cat energy_performance_available_preferences
168 default performance balance_performance balance_power power
169
170The current preference can be read or changed via cpufreq sysfs
171attribute "energy_performance_preference". Reading from this attribute
172will display current effective setting. User can write any of the valid
173preference string to this attribute. User can always restore to power-on
174default by writing "default".
175
176Since threads can migrate to different CPUs, this is possible that the
177new CPU may have different energy performance preference than the previous
178one. To avoid such issues, either threads can be pinned to specific CPUs
179or set the same energy performance preference value to all CPUs.
180
181Tuning Intel P-State driver
182
183When the performance can be tuned using PID (Proportional Integral
184Derivative) controller, debugfs files are provided for adjusting performance.
185They are presented under:
186/sys/kernel/debug/pstate_snb/
187
188The PID tunable parameters are:
189 deadband
190 d_gain_pct
191 i_gain_pct
192 p_gain_pct
193 sample_rate_ms
194 setpoint
195
196To adjust these parameters, some understanding of driver implementation is
197necessary. There are some tweeks described here, but be very careful. Adjusting
198them requires expert level understanding of power and performance relationship.
199These limits are only useful when the "powersave" policy is active.
200
201-To make the system more responsive to load changes, sample_rate_ms can
202be adjusted (current default is 10ms).
203-To make the system use higher performance, even if the load is lower, setpoint
204can be adjusted to a lower number. This will also lead to faster ramp up time
205to reach the maximum P-State.
206If there are no derivative and integral coefficients, The next P-State will be
207equal to:
208 current P-State - ((setpoint - current cpu load) * p_gain_pct)
209
210For example, if the current PID parameters are (Which are defaults for the core
211processors like SandyBridge):
212 deadband = 0
213 d_gain_pct = 0
214 i_gain_pct = 0
215 p_gain_pct = 20
216 sample_rate_ms = 10
217 setpoint = 97
218
219If the current P-State = 0x08 and current load = 100, this will result in the
220next P-State = 0x08 - ((97 - 100) * 0.2) = 8.6 (rounded to 9). Here the P-State
221goes up by only 1. If during next sample interval the current load doesn't
222change and still 100, then P-State goes up by one again. This process will
223continue as long as the load is more than the setpoint until the maximum P-State
224is reached.
225
226For the same load at setpoint = 60, this will result in the next P-State
227= 0x08 - ((60 - 100) * 0.2) = 16
228So by changing the setpoint from 97 to 60, there is an increase of the
229next P-State from 9 to 16. So this will make processor execute at higher
230P-State for the same CPU load. If the load continues to be more than the
231setpoint during next sample intervals, then P-State will go up again till the
232maximum P-State is reached. But the ramp up time to reach the maximum P-State
233will be much faster when the setpoint is 60 compared to 97.
234
235Debugging Intel P-State driver
236
237Event tracing
238To debug P-State transition, the Linux event tracing interface can be used.
239There are two specific events, which can be enabled (Provided the kernel
240configs related to event tracing are enabled).
241
242# cd /sys/kernel/debug/tracing/
243# echo 1 > events/power/pstate_sample/enable
244# echo 1 > events/power/cpu_frequency/enable
245# cat trace
246gnome-terminal--4510 [001] ..s. 1177.680733: pstate_sample: core_busy=107
247 scaled=94 from=26 to=26 mperf=1143818 aperf=1230607 tsc=29838618
248 freq=2474476
249cat-5235 [002] ..s. 1177.681723: cpu_frequency: state=2900000 cpu_id=2
250
251
252Using ftrace
253
254If function level tracing is required, the Linux ftrace interface can be used.
255For example if we want to check how often a function to set a P-State is
256called, we can set ftrace filter to intel_pstate_set_pstate.
257
258# cd /sys/kernel/debug/tracing/
259# cat available_filter_functions | grep -i pstate
260intel_pstate_set_pstate
261intel_pstate_cpu_init
262...
263
264# echo intel_pstate_set_pstate > set_ftrace_filter
265# echo function > current_tracer
266# cat trace | head -15
267# tracer: function
268#
269# entries-in-buffer/entries-written: 80/80 #P:4
270#
271# _-----=> irqs-off
272# / _----=> need-resched
273# | / _---=> hardirq/softirq
274# || / _--=> preempt-depth
275# ||| / delay
276# TASK-PID CPU# |||| TIMESTAMP FUNCTION
277# | | | |||| | |
278 Xorg-3129 [000] ..s. 2537.644844: intel_pstate_set_pstate <-intel_pstate_timer_func
279 gnome-terminal--4510 [002] ..s. 2537.649844: intel_pstate_set_pstate <-intel_pstate_timer_func
280 gnome-shell-3409 [001] ..s. 2537.650850: intel_pstate_set_pstate <-intel_pstate_timer_func
281 <idle>-0 [000] ..s. 2537.654843: intel_pstate_set_pstate <-intel_pstate_timer_func
diff --git a/Documentation/devicetree/bindings/staging/ion/hi6220-ion.txt b/Documentation/devicetree/bindings/staging/ion/hi6220-ion.txt
deleted file mode 100644
index c59e27c632c1..000000000000
--- a/Documentation/devicetree/bindings/staging/ion/hi6220-ion.txt
+++ /dev/null
@@ -1,31 +0,0 @@
1Hi6220 SoC ION
2===================================================================
3Required properties:
4- compatible : "hisilicon,hi6220-ion"
5- list of the ION heaps
6 - heap name : maybe heap_sys_user@0
7 - heap id : id should be unique in the system.
8 - heap base : base ddr address of the heap,0 means that
9 it is dynamic.
10 - heap size : memory size and 0 means it is dynamic.
11 - heap type : the heap type of the heap, please also
12 see the define in ion.h(drivers/staging/android/uapi/ion.h)
13-------------------------------------------------------------------
14Example:
15 hi6220-ion {
16 compatible = "hisilicon,hi6220-ion";
17 heap_sys_user@0 {
18 heap-name = "sys_user";
19 heap-id = <0x0>;
20 heap-base = <0x0>;
21 heap-size = <0x0>;
22 heap-type = "ion_system";
23 };
24 heap_sys_contig@0 {
25 heap-name = "sys_contig";
26 heap-id = <0x1>;
27 heap-base = <0x0>;
28 heap-size = <0x0>;
29 heap-type = "ion_system_contig";
30 };
31 };
diff --git a/Documentation/usb/typec.rst b/Documentation/usb/typec.rst
index b67a46779de9..8a7249f2ff04 100644
--- a/Documentation/usb/typec.rst
+++ b/Documentation/usb/typec.rst
@@ -114,8 +114,7 @@ the details during registration. The class offers the following API for
114registering/unregistering cables and their plugs: 114registering/unregistering cables and their plugs:
115 115
116.. kernel-doc:: drivers/usb/typec/typec.c 116.. kernel-doc:: drivers/usb/typec/typec.c
117 :functions: typec_register_cable typec_unregister_cable typec_register_plug 117 :functions: typec_register_cable typec_unregister_cable typec_register_plug typec_unregister_plug
118 typec_unregister_plug
119 118
120The class will provide a handle to struct typec_cable and struct typec_plug if 119The class will provide a handle to struct typec_cable and struct typec_plug if
121the registration is successful, or NULL if it isn't. 120the registration is successful, or NULL if it isn't.
@@ -137,8 +136,7 @@ during connection of a partner or cable, the port driver must use the following
137APIs to report it to the class: 136APIs to report it to the class:
138 137
139.. kernel-doc:: drivers/usb/typec/typec.c 138.. kernel-doc:: drivers/usb/typec/typec.c
140 :functions: typec_set_data_role typec_set_pwr_role typec_set_vconn_role 139 :functions: typec_set_data_role typec_set_pwr_role typec_set_vconn_role typec_set_pwr_opmode
141 typec_set_pwr_opmode
142 140
143Alternate Modes 141Alternate Modes
144~~~~~~~~~~~~~~~ 142~~~~~~~~~~~~~~~
diff --git a/Documentation/watchdog/watchdog-parameters.txt b/Documentation/watchdog/watchdog-parameters.txt
index 4f7d86dd0a5d..914518aeb972 100644
--- a/Documentation/watchdog/watchdog-parameters.txt
+++ b/Documentation/watchdog/watchdog-parameters.txt
@@ -117,7 +117,7 @@ nowayout: Watchdog cannot be stopped once started
117------------------------------------------------- 117-------------------------------------------------
118iTCO_wdt: 118iTCO_wdt:
119heartbeat: Watchdog heartbeat in seconds. 119heartbeat: Watchdog heartbeat in seconds.
120 (2<heartbeat<39 (TCO v1) or 613 (TCO v2), default=30) 120 (5<=heartbeat<=74 (TCO v1) or 1226 (TCO v2), default=30)
121nowayout: Watchdog cannot be stopped once started 121nowayout: Watchdog cannot be stopped once started
122 (default=kernel config parameter) 122 (default=kernel config parameter)
123------------------------------------------------- 123-------------------------------------------------
diff --git a/MAINTAINERS b/MAINTAINERS
index f7d568b8f133..9e984645c4b0 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -846,7 +846,6 @@ M: Laura Abbott <labbott@redhat.com>
846M: Sumit Semwal <sumit.semwal@linaro.org> 846M: Sumit Semwal <sumit.semwal@linaro.org>
847L: devel@driverdev.osuosl.org 847L: devel@driverdev.osuosl.org
848S: Supported 848S: Supported
849F: Documentation/devicetree/bindings/staging/ion/
850F: drivers/staging/android/ion 849F: drivers/staging/android/ion
851F: drivers/staging/android/uapi/ion.h 850F: drivers/staging/android/uapi/ion.h
852F: drivers/staging/android/uapi/ion_test.h 851F: drivers/staging/android/uapi/ion_test.h
@@ -3116,6 +3115,14 @@ F: drivers/net/ieee802154/cc2520.c
3116F: include/linux/spi/cc2520.h 3115F: include/linux/spi/cc2520.h
3117F: Documentation/devicetree/bindings/net/ieee802154/cc2520.txt 3116F: Documentation/devicetree/bindings/net/ieee802154/cc2520.txt
3118 3117
3118CCREE ARM TRUSTZONE CRYPTOCELL 700 REE DRIVER
3119M: Gilad Ben-Yossef <gilad@benyossef.com>
3120L: linux-crypto@vger.kernel.org
3121L: driverdev-devel@linuxdriverproject.org
3122S: Supported
3123F: drivers/staging/ccree/
3124W: https://developer.arm.com/products/system-ip/trustzone-cryptocell/cryptocell-700-family
3125
3119CEC FRAMEWORK 3126CEC FRAMEWORK
3120M: Hans Verkuil <hans.verkuil@cisco.com> 3127M: Hans Verkuil <hans.verkuil@cisco.com>
3121L: linux-media@vger.kernel.org 3128L: linux-media@vger.kernel.org
@@ -5695,7 +5702,7 @@ M: Alex Elder <elder@kernel.org>
5695M: Greg Kroah-Hartman <gregkh@linuxfoundation.org> 5702M: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
5696S: Maintained 5703S: Maintained
5697F: drivers/staging/greybus/ 5704F: drivers/staging/greybus/
5698L: greybus-dev@lists.linaro.org 5705L: greybus-dev@lists.linaro.org (moderated for non-subscribers)
5699 5706
5700GREYBUS AUDIO PROTOCOLS DRIVERS 5707GREYBUS AUDIO PROTOCOLS DRIVERS
5701M: Vaibhav Agarwal <vaibhav.sr@gmail.com> 5708M: Vaibhav Agarwal <vaibhav.sr@gmail.com>
@@ -9553,10 +9560,6 @@ F: drivers/net/wireless/intersil/orinoco/
9553 9560
9554OSD LIBRARY and FILESYSTEM 9561OSD LIBRARY and FILESYSTEM
9555M: Boaz Harrosh <ooo@electrozaur.com> 9562M: Boaz Harrosh <ooo@electrozaur.com>
9556M: Benny Halevy <bhalevy@primarydata.com>
9557L: osd-dev@open-osd.org
9558W: http://open-osd.org
9559T: git git://git.open-osd.org/open-osd.git
9560S: Maintained 9563S: Maintained
9561F: drivers/scsi/osd/ 9564F: drivers/scsi/osd/
9562F: include/scsi/osd_* 9565F: include/scsi/osd_*
diff --git a/Makefile b/Makefile
index b1ee4a49efa2..63e10bd4f14a 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
1VERSION = 4 1VERSION = 4
2PATCHLEVEL = 12 2PATCHLEVEL = 12
3SUBLEVEL = 0 3SUBLEVEL = 0
4EXTRAVERSION = -rc1 4EXTRAVERSION = -rc2
5NAME = Fearless Coyote 5NAME = Fearless Coyote
6 6
7# *DOCUMENTATION* 7# *DOCUMENTATION*
diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c
index 9ec56dc97374..ce93124a850b 100644
--- a/arch/alpha/kernel/osf_sys.c
+++ b/arch/alpha/kernel/osf_sys.c
@@ -1201,8 +1201,10 @@ SYSCALL_DEFINE4(osf_wait4, pid_t, pid, int __user *, ustatus, int, options,
1201 if (!access_ok(VERIFY_WRITE, ur, sizeof(*ur))) 1201 if (!access_ok(VERIFY_WRITE, ur, sizeof(*ur)))
1202 return -EFAULT; 1202 return -EFAULT;
1203 1203
1204 err = 0; 1204 err = put_user(status, ustatus);
1205 err |= put_user(status, ustatus); 1205 if (ret < 0)
1206 return err ? err : ret;
1207
1206 err |= __put_user(r.ru_utime.tv_sec, &ur->ru_utime.tv_sec); 1208 err |= __put_user(r.ru_utime.tv_sec, &ur->ru_utime.tv_sec);
1207 err |= __put_user(r.ru_utime.tv_usec, &ur->ru_utime.tv_usec); 1209 err |= __put_user(r.ru_utime.tv_usec, &ur->ru_utime.tv_usec);
1208 err |= __put_user(r.ru_stime.tv_sec, &ur->ru_stime.tv_sec); 1210 err |= __put_user(r.ru_stime.tv_sec, &ur->ru_stime.tv_sec);
diff --git a/arch/arm/boot/dts/bcm283x-rpi-smsc9512.dtsi b/arch/arm/boot/dts/bcm283x-rpi-smsc9512.dtsi
index 12c981e51134..9a0599f711ff 100644
--- a/arch/arm/boot/dts/bcm283x-rpi-smsc9512.dtsi
+++ b/arch/arm/boot/dts/bcm283x-rpi-smsc9512.dtsi
@@ -1,6 +1,6 @@
1/ { 1/ {
2 aliases { 2 aliases {
3 ethernet = &ethernet; 3 ethernet0 = &ethernet;
4 }; 4 };
5}; 5};
6 6
diff --git a/arch/arm/boot/dts/bcm283x-rpi-smsc9514.dtsi b/arch/arm/boot/dts/bcm283x-rpi-smsc9514.dtsi
index 3f0a56ebcf1f..dc7ae776db5f 100644
--- a/arch/arm/boot/dts/bcm283x-rpi-smsc9514.dtsi
+++ b/arch/arm/boot/dts/bcm283x-rpi-smsc9514.dtsi
@@ -1,6 +1,6 @@
1/ { 1/ {
2 aliases { 2 aliases {
3 ethernet = &ethernet; 3 ethernet0 = &ethernet;
4 }; 4 };
5}; 5};
6 6
diff --git a/arch/arm/boot/dts/bcm283x.dtsi b/arch/arm/boot/dts/bcm283x.dtsi
index 35cea3fcaf5c..561f27d8d922 100644
--- a/arch/arm/boot/dts/bcm283x.dtsi
+++ b/arch/arm/boot/dts/bcm283x.dtsi
@@ -198,8 +198,8 @@
198 brcm,pins = <0 1>; 198 brcm,pins = <0 1>;
199 brcm,function = <BCM2835_FSEL_ALT0>; 199 brcm,function = <BCM2835_FSEL_ALT0>;
200 }; 200 };
201 i2c0_gpio32: i2c0_gpio32 { 201 i2c0_gpio28: i2c0_gpio28 {
202 brcm,pins = <32 34>; 202 brcm,pins = <28 29>;
203 brcm,function = <BCM2835_FSEL_ALT0>; 203 brcm,function = <BCM2835_FSEL_ALT0>;
204 }; 204 };
205 i2c0_gpio44: i2c0_gpio44 { 205 i2c0_gpio44: i2c0_gpio44 {
@@ -295,20 +295,28 @@
295 /* Separate from the uart0_gpio14 group 295 /* Separate from the uart0_gpio14 group
296 * because it conflicts with spi1_gpio16, and 296 * because it conflicts with spi1_gpio16, and
297 * people often run uart0 on the two pins 297 * people often run uart0 on the two pins
298 * without flow contrl. 298 * without flow control.
299 */ 299 */
300 uart0_ctsrts_gpio16: uart0_ctsrts_gpio16 { 300 uart0_ctsrts_gpio16: uart0_ctsrts_gpio16 {
301 brcm,pins = <16 17>; 301 brcm,pins = <16 17>;
302 brcm,function = <BCM2835_FSEL_ALT3>; 302 brcm,function = <BCM2835_FSEL_ALT3>;
303 }; 303 };
304 uart0_gpio30: uart0_gpio30 { 304 uart0_ctsrts_gpio30: uart0_ctsrts_gpio30 {
305 brcm,pins = <30 31>; 305 brcm,pins = <30 31>;
306 brcm,function = <BCM2835_FSEL_ALT3>; 306 brcm,function = <BCM2835_FSEL_ALT3>;
307 }; 307 };
308 uart0_ctsrts_gpio32: uart0_ctsrts_gpio32 { 308 uart0_gpio32: uart0_gpio32 {
309 brcm,pins = <32 33>; 309 brcm,pins = <32 33>;
310 brcm,function = <BCM2835_FSEL_ALT3>; 310 brcm,function = <BCM2835_FSEL_ALT3>;
311 }; 311 };
312 uart0_gpio36: uart0_gpio36 {
313 brcm,pins = <36 37>;
314 brcm,function = <BCM2835_FSEL_ALT2>;
315 };
316 uart0_ctsrts_gpio38: uart0_ctsrts_gpio38 {
317 brcm,pins = <38 39>;
318 brcm,function = <BCM2835_FSEL_ALT2>;
319 };
312 320
313 uart1_gpio14: uart1_gpio14 { 321 uart1_gpio14: uart1_gpio14 {
314 brcm,pins = <14 15>; 322 brcm,pins = <14 15>;
@@ -326,10 +334,6 @@
326 brcm,pins = <30 31>; 334 brcm,pins = <30 31>;
327 brcm,function = <BCM2835_FSEL_ALT5>; 335 brcm,function = <BCM2835_FSEL_ALT5>;
328 }; 336 };
329 uart1_gpio36: uart1_gpio36 {
330 brcm,pins = <36 37 38 39>;
331 brcm,function = <BCM2835_FSEL_ALT2>;
332 };
333 uart1_gpio40: uart1_gpio40 { 337 uart1_gpio40: uart1_gpio40 {
334 brcm,pins = <40 41>; 338 brcm,pins = <40 41>;
335 brcm,function = <BCM2835_FSEL_ALT5>; 339 brcm,function = <BCM2835_FSEL_ALT5>;
diff --git a/arch/arm/boot/dts/dra7-evm.dts b/arch/arm/boot/dts/dra7-evm.dts
index 4bc4b575c99b..31a9e061ddd0 100644
--- a/arch/arm/boot/dts/dra7-evm.dts
+++ b/arch/arm/boot/dts/dra7-evm.dts
@@ -204,6 +204,8 @@
204 tps659038: tps659038@58 { 204 tps659038: tps659038@58 {
205 compatible = "ti,tps659038"; 205 compatible = "ti,tps659038";
206 reg = <0x58>; 206 reg = <0x58>;
207 ti,palmas-override-powerhold;
208 ti,system-power-controller;
207 209
208 tps659038_pmic { 210 tps659038_pmic {
209 compatible = "ti,tps659038-pmic"; 211 compatible = "ti,tps659038-pmic";
diff --git a/arch/arm/boot/dts/dra7.dtsi b/arch/arm/boot/dts/dra7.dtsi
index 57892f264cea..e7144662af45 100644
--- a/arch/arm/boot/dts/dra7.dtsi
+++ b/arch/arm/boot/dts/dra7.dtsi
@@ -2017,4 +2017,8 @@
2017 coefficients = <0 2000>; 2017 coefficients = <0 2000>;
2018}; 2018};
2019 2019
2020&cpu_crit {
2021 temperature = <120000>; /* milli Celsius */
2022};
2023
2020/include/ "dra7xx-clocks.dtsi" 2024/include/ "dra7xx-clocks.dtsi"
diff --git a/arch/arm/boot/dts/imx53-qsrb.dts b/arch/arm/boot/dts/imx53-qsrb.dts
index de2215832372..4e103a905dc9 100644
--- a/arch/arm/boot/dts/imx53-qsrb.dts
+++ b/arch/arm/boot/dts/imx53-qsrb.dts
@@ -23,7 +23,7 @@
23 imx53-qsrb { 23 imx53-qsrb {
24 pinctrl_pmic: pmicgrp { 24 pinctrl_pmic: pmicgrp {
25 fsl,pins = < 25 fsl,pins = <
26 MX53_PAD_CSI0_DAT5__GPIO5_23 0x1e4 /* IRQ */ 26 MX53_PAD_CSI0_DAT5__GPIO5_23 0x1c4 /* IRQ */
27 >; 27 >;
28 }; 28 };
29 }; 29 };
diff --git a/arch/arm/boot/dts/imx6sx-sdb.dts b/arch/arm/boot/dts/imx6sx-sdb.dts
index 5bb8fd57e7f5..d71da30c9cff 100644
--- a/arch/arm/boot/dts/imx6sx-sdb.dts
+++ b/arch/arm/boot/dts/imx6sx-sdb.dts
@@ -12,23 +12,6 @@
12 model = "Freescale i.MX6 SoloX SDB RevB Board"; 12 model = "Freescale i.MX6 SoloX SDB RevB Board";
13}; 13};
14 14
15&cpu0 {
16 operating-points = <
17 /* kHz uV */
18 996000 1250000
19 792000 1175000
20 396000 1175000
21 198000 1175000
22 >;
23 fsl,soc-operating-points = <
24 /* ARM kHz SOC uV */
25 996000 1250000
26 792000 1175000
27 396000 1175000
28 198000 1175000
29 >;
30};
31
32&i2c1 { 15&i2c1 {
33 clock-frequency = <100000>; 16 clock-frequency = <100000>;
34 pinctrl-names = "default"; 17 pinctrl-names = "default";
diff --git a/arch/arm/boot/dts/include/arm b/arch/arm/boot/dts/include/arm
deleted file mode 120000
index a96aa0ea9d8c..000000000000
--- a/arch/arm/boot/dts/include/arm
+++ /dev/null
@@ -1 +0,0 @@
1.. \ No newline at end of file
diff --git a/arch/arm/boot/dts/include/arm64 b/arch/arm/boot/dts/include/arm64
deleted file mode 120000
index 074a835fca3e..000000000000
--- a/arch/arm/boot/dts/include/arm64
+++ /dev/null
@@ -1 +0,0 @@
1../../../../arm64/boot/dts \ No newline at end of file
diff --git a/arch/arm/boot/dts/include/dt-bindings b/arch/arm/boot/dts/include/dt-bindings
deleted file mode 120000
index 08c00e4972fa..000000000000
--- a/arch/arm/boot/dts/include/dt-bindings
+++ /dev/null
@@ -1 +0,0 @@
1../../../../../include/dt-bindings \ No newline at end of file
diff --git a/arch/arm/boot/dts/logicpd-torpedo-37xx-devkit.dts b/arch/arm/boot/dts/logicpd-torpedo-37xx-devkit.dts
index 08cce17a25a0..43e9364083de 100644
--- a/arch/arm/boot/dts/logicpd-torpedo-37xx-devkit.dts
+++ b/arch/arm/boot/dts/logicpd-torpedo-37xx-devkit.dts
@@ -249,9 +249,9 @@
249 OMAP3_CORE1_IOPAD(0x2110, PIN_INPUT | MUX_MODE0) /* cam_xclka.cam_xclka */ 249 OMAP3_CORE1_IOPAD(0x2110, PIN_INPUT | MUX_MODE0) /* cam_xclka.cam_xclka */
250 OMAP3_CORE1_IOPAD(0x2112, PIN_INPUT | MUX_MODE0) /* cam_pclk.cam_pclk */ 250 OMAP3_CORE1_IOPAD(0x2112, PIN_INPUT | MUX_MODE0) /* cam_pclk.cam_pclk */
251 251
252 OMAP3_CORE1_IOPAD(0x2114, PIN_INPUT | MUX_MODE0) /* cam_d0.cam_d0 */ 252 OMAP3_CORE1_IOPAD(0x2116, PIN_INPUT | MUX_MODE0) /* cam_d0.cam_d0 */
253 OMAP3_CORE1_IOPAD(0x2116, PIN_INPUT | MUX_MODE0) /* cam_d1.cam_d1 */ 253 OMAP3_CORE1_IOPAD(0x2118, PIN_INPUT | MUX_MODE0) /* cam_d1.cam_d1 */
254 OMAP3_CORE1_IOPAD(0x2118, PIN_INPUT | MUX_MODE0) /* cam_d2.cam_d2 */ 254 OMAP3_CORE1_IOPAD(0x211a, PIN_INPUT | MUX_MODE0) /* cam_d2.cam_d2 */
255 OMAP3_CORE1_IOPAD(0x211c, PIN_INPUT | MUX_MODE0) /* cam_d3.cam_d3 */ 255 OMAP3_CORE1_IOPAD(0x211c, PIN_INPUT | MUX_MODE0) /* cam_d3.cam_d3 */
256 OMAP3_CORE1_IOPAD(0x211e, PIN_INPUT | MUX_MODE0) /* cam_d4.cam_d4 */ 256 OMAP3_CORE1_IOPAD(0x211e, PIN_INPUT | MUX_MODE0) /* cam_d4.cam_d4 */
257 OMAP3_CORE1_IOPAD(0x2120, PIN_INPUT | MUX_MODE0) /* cam_d5.cam_d5 */ 257 OMAP3_CORE1_IOPAD(0x2120, PIN_INPUT | MUX_MODE0) /* cam_d5.cam_d5 */
diff --git a/arch/arm/boot/dts/mt7623.dtsi b/arch/arm/boot/dts/mt7623.dtsi
index 402579ab70d2..3a9e9b6aea68 100644
--- a/arch/arm/boot/dts/mt7623.dtsi
+++ b/arch/arm/boot/dts/mt7623.dtsi
@@ -72,6 +72,8 @@
72 <GIC_PPI 14 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_HIGH)>, 72 <GIC_PPI 14 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_HIGH)>,
73 <GIC_PPI 11 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_HIGH)>, 73 <GIC_PPI 11 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_HIGH)>,
74 <GIC_PPI 10 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_HIGH)>; 74 <GIC_PPI 10 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_HIGH)>;
75 clock-frequency = <13000000>;
76 arm,cpu-registers-not-fw-configured;
75 }; 77 };
76 78
77 watchdog: watchdog@10007000 { 79 watchdog: watchdog@10007000 {
diff --git a/arch/arm/boot/dts/omap3-gta04.dtsi b/arch/arm/boot/dts/omap3-gta04.dtsi
index b3a8b1f24499..9ec737069369 100644
--- a/arch/arm/boot/dts/omap3-gta04.dtsi
+++ b/arch/arm/boot/dts/omap3-gta04.dtsi
@@ -55,7 +55,8 @@
55 simple-audio-card,bitclock-master = <&telephony_link_master>; 55 simple-audio-card,bitclock-master = <&telephony_link_master>;
56 simple-audio-card,frame-master = <&telephony_link_master>; 56 simple-audio-card,frame-master = <&telephony_link_master>;
57 simple-audio-card,format = "i2s"; 57 simple-audio-card,format = "i2s";
58 58 simple-audio-card,bitclock-inversion;
59 simple-audio-card,frame-inversion;
59 simple-audio-card,cpu { 60 simple-audio-card,cpu {
60 sound-dai = <&mcbsp4>; 61 sound-dai = <&mcbsp4>;
61 }; 62 };
diff --git a/arch/arm/boot/dts/omap4-panda-a4.dts b/arch/arm/boot/dts/omap4-panda-a4.dts
index 78d363177762..f1a6476af371 100644
--- a/arch/arm/boot/dts/omap4-panda-a4.dts
+++ b/arch/arm/boot/dts/omap4-panda-a4.dts
@@ -13,7 +13,7 @@
13/* Pandaboard Rev A4+ have external pullups on SCL & SDA */ 13/* Pandaboard Rev A4+ have external pullups on SCL & SDA */
14&dss_hdmi_pins { 14&dss_hdmi_pins {
15 pinctrl-single,pins = < 15 pinctrl-single,pins = <
16 OMAP4_IOPAD(0x09a, PIN_INPUT_PULLUP | MUX_MODE0) /* hdmi_cec.hdmi_cec */ 16 OMAP4_IOPAD(0x09a, PIN_INPUT | MUX_MODE0) /* hdmi_cec.hdmi_cec */
17 OMAP4_IOPAD(0x09c, PIN_INPUT | MUX_MODE0) /* hdmi_scl.hdmi_scl */ 17 OMAP4_IOPAD(0x09c, PIN_INPUT | MUX_MODE0) /* hdmi_scl.hdmi_scl */
18 OMAP4_IOPAD(0x09e, PIN_INPUT | MUX_MODE0) /* hdmi_sda.hdmi_sda */ 18 OMAP4_IOPAD(0x09e, PIN_INPUT | MUX_MODE0) /* hdmi_sda.hdmi_sda */
19 >; 19 >;
diff --git a/arch/arm/boot/dts/omap4-panda-es.dts b/arch/arm/boot/dts/omap4-panda-es.dts
index 119f8e657edc..940fe4f7c5f6 100644
--- a/arch/arm/boot/dts/omap4-panda-es.dts
+++ b/arch/arm/boot/dts/omap4-panda-es.dts
@@ -34,7 +34,7 @@
34/* PandaboardES has external pullups on SCL & SDA */ 34/* PandaboardES has external pullups on SCL & SDA */
35&dss_hdmi_pins { 35&dss_hdmi_pins {
36 pinctrl-single,pins = < 36 pinctrl-single,pins = <
37 OMAP4_IOPAD(0x09a, PIN_INPUT_PULLUP | MUX_MODE0) /* hdmi_cec.hdmi_cec */ 37 OMAP4_IOPAD(0x09a, PIN_INPUT | MUX_MODE0) /* hdmi_cec.hdmi_cec */
38 OMAP4_IOPAD(0x09c, PIN_INPUT | MUX_MODE0) /* hdmi_scl.hdmi_scl */ 38 OMAP4_IOPAD(0x09c, PIN_INPUT | MUX_MODE0) /* hdmi_scl.hdmi_scl */
39 OMAP4_IOPAD(0x09e, PIN_INPUT | MUX_MODE0) /* hdmi_sda.hdmi_sda */ 39 OMAP4_IOPAD(0x09e, PIN_INPUT | MUX_MODE0) /* hdmi_sda.hdmi_sda */
40 >; 40 >;
diff --git a/arch/arm/configs/gemini_defconfig b/arch/arm/configs/gemini_defconfig
new file mode 100644
index 000000000000..d2d75fa664a6
--- /dev/null
+++ b/arch/arm/configs/gemini_defconfig
@@ -0,0 +1,68 @@
1# CONFIG_LOCALVERSION_AUTO is not set
2CONFIG_SYSVIPC=y
3CONFIG_NO_HZ_IDLE=y
4CONFIG_BSD_PROCESS_ACCT=y
5CONFIG_USER_NS=y
6CONFIG_RELAY=y
7CONFIG_BLK_DEV_INITRD=y
8CONFIG_PARTITION_ADVANCED=y
9CONFIG_ARCH_MULTI_V4=y
10# CONFIG_ARCH_MULTI_V7 is not set
11CONFIG_ARCH_GEMINI=y
12CONFIG_PCI=y
13CONFIG_PREEMPT=y
14CONFIG_AEABI=y
15CONFIG_CMDLINE="console=ttyS0,115200n8"
16CONFIG_KEXEC=y
17CONFIG_BINFMT_MISC=y
18CONFIG_PM=y
19CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
20CONFIG_DEVTMPFS=y
21CONFIG_MTD=y
22CONFIG_MTD_BLOCK=y
23CONFIG_MTD_CFI=y
24CONFIG_MTD_CFI_INTELEXT=y
25CONFIG_MTD_CFI_AMDSTD=y
26CONFIG_MTD_CFI_STAA=y
27CONFIG_MTD_PHYSMAP=y
28CONFIG_MTD_PHYSMAP_OF=y
29CONFIG_BLK_DEV_RAM=y
30CONFIG_BLK_DEV_RAM_SIZE=16384
31# CONFIG_SCSI_PROC_FS is not set
32CONFIG_BLK_DEV_SD=y
33# CONFIG_SCSI_LOWLEVEL is not set
34CONFIG_ATA=y
35CONFIG_INPUT_EVDEV=y
36CONFIG_KEYBOARD_GPIO=y
37# CONFIG_INPUT_MOUSE is not set
38# CONFIG_LEGACY_PTYS is not set
39CONFIG_SERIAL_8250=y
40CONFIG_SERIAL_8250_CONSOLE=y
41CONFIG_SERIAL_8250_NR_UARTS=1
42CONFIG_SERIAL_8250_RUNTIME_UARTS=1
43CONFIG_SERIAL_OF_PLATFORM=y
44# CONFIG_HW_RANDOM is not set
45# CONFIG_HWMON is not set
46CONFIG_WATCHDOG=y
47CONFIG_GEMINI_WATCHDOG=y
48CONFIG_USB=y
49CONFIG_USB_MON=y
50CONFIG_USB_FOTG210_HCD=y
51CONFIG_USB_STORAGE=y
52CONFIG_NEW_LEDS=y
53CONFIG_LEDS_CLASS=y
54CONFIG_LEDS_GPIO=y
55CONFIG_LEDS_TRIGGERS=y
56CONFIG_LEDS_TRIGGER_HEARTBEAT=y
57CONFIG_RTC_CLASS=y
58CONFIG_RTC_DRV_GEMINI=y
59CONFIG_DMADEVICES=y
60# CONFIG_DNOTIFY is not set
61CONFIG_TMPFS=y
62CONFIG_TMPFS_POSIX_ACL=y
63CONFIG_ROMFS_FS=y
64CONFIG_NLS_CODEPAGE_437=y
65CONFIG_NLS_ISO8859_1=y
66# CONFIG_ENABLE_WARN_DEPRECATED is not set
67# CONFIG_ENABLE_MUST_CHECK is not set
68CONFIG_DEBUG_FS=y
diff --git a/arch/arm/include/asm/kvm_coproc.h b/arch/arm/include/asm/kvm_coproc.h
index 4917c2f7e459..e74ab0fbab79 100644
--- a/arch/arm/include/asm/kvm_coproc.h
+++ b/arch/arm/include/asm/kvm_coproc.h
@@ -31,7 +31,8 @@ void kvm_register_target_coproc_table(struct kvm_coproc_target_table *table);
31int kvm_handle_cp10_id(struct kvm_vcpu *vcpu, struct kvm_run *run); 31int kvm_handle_cp10_id(struct kvm_vcpu *vcpu, struct kvm_run *run);
32int kvm_handle_cp_0_13_access(struct kvm_vcpu *vcpu, struct kvm_run *run); 32int kvm_handle_cp_0_13_access(struct kvm_vcpu *vcpu, struct kvm_run *run);
33int kvm_handle_cp14_load_store(struct kvm_vcpu *vcpu, struct kvm_run *run); 33int kvm_handle_cp14_load_store(struct kvm_vcpu *vcpu, struct kvm_run *run);
34int kvm_handle_cp14_access(struct kvm_vcpu *vcpu, struct kvm_run *run); 34int kvm_handle_cp14_32(struct kvm_vcpu *vcpu, struct kvm_run *run);
35int kvm_handle_cp14_64(struct kvm_vcpu *vcpu, struct kvm_run *run);
35int kvm_handle_cp15_32(struct kvm_vcpu *vcpu, struct kvm_run *run); 36int kvm_handle_cp15_32(struct kvm_vcpu *vcpu, struct kvm_run *run);
36int kvm_handle_cp15_64(struct kvm_vcpu *vcpu, struct kvm_run *run); 37int kvm_handle_cp15_64(struct kvm_vcpu *vcpu, struct kvm_run *run);
37 38
diff --git a/arch/arm/kvm/coproc.c b/arch/arm/kvm/coproc.c
index 2c14b69511e9..6d1d2e26dfe5 100644
--- a/arch/arm/kvm/coproc.c
+++ b/arch/arm/kvm/coproc.c
@@ -32,6 +32,7 @@
32#include <asm/vfp.h> 32#include <asm/vfp.h>
33#include "../vfp/vfpinstr.h" 33#include "../vfp/vfpinstr.h"
34 34
35#define CREATE_TRACE_POINTS
35#include "trace.h" 36#include "trace.h"
36#include "coproc.h" 37#include "coproc.h"
37 38
@@ -111,12 +112,6 @@ int kvm_handle_cp14_load_store(struct kvm_vcpu *vcpu, struct kvm_run *run)
111 return 1; 112 return 1;
112} 113}
113 114
114int kvm_handle_cp14_access(struct kvm_vcpu *vcpu, struct kvm_run *run)
115{
116 kvm_inject_undefined(vcpu);
117 return 1;
118}
119
120static void reset_mpidr(struct kvm_vcpu *vcpu, const struct coproc_reg *r) 115static void reset_mpidr(struct kvm_vcpu *vcpu, const struct coproc_reg *r)
121{ 116{
122 /* 117 /*
@@ -284,7 +279,7 @@ static bool access_gic_sre(struct kvm_vcpu *vcpu,
284 * must always support PMCCNTR (the cycle counter): we just RAZ/WI for 279 * must always support PMCCNTR (the cycle counter): we just RAZ/WI for
285 * all PM registers, which doesn't crash the guest kernel at least. 280 * all PM registers, which doesn't crash the guest kernel at least.
286 */ 281 */
287static bool pm_fake(struct kvm_vcpu *vcpu, 282static bool trap_raz_wi(struct kvm_vcpu *vcpu,
288 const struct coproc_params *p, 283 const struct coproc_params *p,
289 const struct coproc_reg *r) 284 const struct coproc_reg *r)
290{ 285{
@@ -294,19 +289,19 @@ static bool pm_fake(struct kvm_vcpu *vcpu,
294 return read_zero(vcpu, p); 289 return read_zero(vcpu, p);
295} 290}
296 291
297#define access_pmcr pm_fake 292#define access_pmcr trap_raz_wi
298#define access_pmcntenset pm_fake 293#define access_pmcntenset trap_raz_wi
299#define access_pmcntenclr pm_fake 294#define access_pmcntenclr trap_raz_wi
300#define access_pmovsr pm_fake 295#define access_pmovsr trap_raz_wi
301#define access_pmselr pm_fake 296#define access_pmselr trap_raz_wi
302#define access_pmceid0 pm_fake 297#define access_pmceid0 trap_raz_wi
303#define access_pmceid1 pm_fake 298#define access_pmceid1 trap_raz_wi
304#define access_pmccntr pm_fake 299#define access_pmccntr trap_raz_wi
305#define access_pmxevtyper pm_fake 300#define access_pmxevtyper trap_raz_wi
306#define access_pmxevcntr pm_fake 301#define access_pmxevcntr trap_raz_wi
307#define access_pmuserenr pm_fake 302#define access_pmuserenr trap_raz_wi
308#define access_pmintenset pm_fake 303#define access_pmintenset trap_raz_wi
309#define access_pmintenclr pm_fake 304#define access_pmintenclr trap_raz_wi
310 305
311/* Architected CP15 registers. 306/* Architected CP15 registers.
312 * CRn denotes the primary register number, but is copied to the CRm in the 307 * CRn denotes the primary register number, but is copied to the CRm in the
@@ -532,12 +527,7 @@ static int emulate_cp15(struct kvm_vcpu *vcpu,
532 return 1; 527 return 1;
533} 528}
534 529
535/** 530static struct coproc_params decode_64bit_hsr(struct kvm_vcpu *vcpu)
536 * kvm_handle_cp15_64 -- handles a mrrc/mcrr trap on a guest CP15 access
537 * @vcpu: The VCPU pointer
538 * @run: The kvm_run struct
539 */
540int kvm_handle_cp15_64(struct kvm_vcpu *vcpu, struct kvm_run *run)
541{ 531{
542 struct coproc_params params; 532 struct coproc_params params;
543 533
@@ -551,9 +541,38 @@ int kvm_handle_cp15_64(struct kvm_vcpu *vcpu, struct kvm_run *run)
551 params.Rt2 = (kvm_vcpu_get_hsr(vcpu) >> 10) & 0xf; 541 params.Rt2 = (kvm_vcpu_get_hsr(vcpu) >> 10) & 0xf;
552 params.CRm = 0; 542 params.CRm = 0;
553 543
544 return params;
545}
546
547/**
548 * kvm_handle_cp15_64 -- handles a mrrc/mcrr trap on a guest CP15 access
549 * @vcpu: The VCPU pointer
550 * @run: The kvm_run struct
551 */
552int kvm_handle_cp15_64(struct kvm_vcpu *vcpu, struct kvm_run *run)
553{
554 struct coproc_params params = decode_64bit_hsr(vcpu);
555
554 return emulate_cp15(vcpu, &params); 556 return emulate_cp15(vcpu, &params);
555} 557}
556 558
559/**
560 * kvm_handle_cp14_64 -- handles a mrrc/mcrr trap on a guest CP14 access
561 * @vcpu: The VCPU pointer
562 * @run: The kvm_run struct
563 */
564int kvm_handle_cp14_64(struct kvm_vcpu *vcpu, struct kvm_run *run)
565{
566 struct coproc_params params = decode_64bit_hsr(vcpu);
567
568 /* raz_wi cp14 */
569 trap_raz_wi(vcpu, &params, NULL);
570
571 /* handled */
572 kvm_skip_instr(vcpu, kvm_vcpu_trap_il_is32bit(vcpu));
573 return 1;
574}
575
557static void reset_coproc_regs(struct kvm_vcpu *vcpu, 576static void reset_coproc_regs(struct kvm_vcpu *vcpu,
558 const struct coproc_reg *table, size_t num) 577 const struct coproc_reg *table, size_t num)
559{ 578{
@@ -564,12 +583,7 @@ static void reset_coproc_regs(struct kvm_vcpu *vcpu,
564 table[i].reset(vcpu, &table[i]); 583 table[i].reset(vcpu, &table[i]);
565} 584}
566 585
567/** 586static struct coproc_params decode_32bit_hsr(struct kvm_vcpu *vcpu)
568 * kvm_handle_cp15_32 -- handles a mrc/mcr trap on a guest CP15 access
569 * @vcpu: The VCPU pointer
570 * @run: The kvm_run struct
571 */
572int kvm_handle_cp15_32(struct kvm_vcpu *vcpu, struct kvm_run *run)
573{ 587{
574 struct coproc_params params; 588 struct coproc_params params;
575 589
@@ -583,9 +597,37 @@ int kvm_handle_cp15_32(struct kvm_vcpu *vcpu, struct kvm_run *run)
583 params.Op2 = (kvm_vcpu_get_hsr(vcpu) >> 17) & 0x7; 597 params.Op2 = (kvm_vcpu_get_hsr(vcpu) >> 17) & 0x7;
584 params.Rt2 = 0; 598 params.Rt2 = 0;
585 599
600 return params;
601}
602
603/**
604 * kvm_handle_cp15_32 -- handles a mrc/mcr trap on a guest CP15 access
605 * @vcpu: The VCPU pointer
606 * @run: The kvm_run struct
607 */
608int kvm_handle_cp15_32(struct kvm_vcpu *vcpu, struct kvm_run *run)
609{
610 struct coproc_params params = decode_32bit_hsr(vcpu);
586 return emulate_cp15(vcpu, &params); 611 return emulate_cp15(vcpu, &params);
587} 612}
588 613
614/**
615 * kvm_handle_cp14_32 -- handles a mrc/mcr trap on a guest CP14 access
616 * @vcpu: The VCPU pointer
617 * @run: The kvm_run struct
618 */
619int kvm_handle_cp14_32(struct kvm_vcpu *vcpu, struct kvm_run *run)
620{
621 struct coproc_params params = decode_32bit_hsr(vcpu);
622
623 /* raz_wi cp14 */
624 trap_raz_wi(vcpu, &params, NULL);
625
626 /* handled */
627 kvm_skip_instr(vcpu, kvm_vcpu_trap_il_is32bit(vcpu));
628 return 1;
629}
630
589/****************************************************************************** 631/******************************************************************************
590 * Userspace API 632 * Userspace API
591 *****************************************************************************/ 633 *****************************************************************************/
diff --git a/arch/arm/kvm/handle_exit.c b/arch/arm/kvm/handle_exit.c
index 5fd7968cdae9..f86a9aaef462 100644
--- a/arch/arm/kvm/handle_exit.c
+++ b/arch/arm/kvm/handle_exit.c
@@ -95,9 +95,9 @@ static exit_handle_fn arm_exit_handlers[] = {
95 [HSR_EC_WFI] = kvm_handle_wfx, 95 [HSR_EC_WFI] = kvm_handle_wfx,
96 [HSR_EC_CP15_32] = kvm_handle_cp15_32, 96 [HSR_EC_CP15_32] = kvm_handle_cp15_32,
97 [HSR_EC_CP15_64] = kvm_handle_cp15_64, 97 [HSR_EC_CP15_64] = kvm_handle_cp15_64,
98 [HSR_EC_CP14_MR] = kvm_handle_cp14_access, 98 [HSR_EC_CP14_MR] = kvm_handle_cp14_32,
99 [HSR_EC_CP14_LS] = kvm_handle_cp14_load_store, 99 [HSR_EC_CP14_LS] = kvm_handle_cp14_load_store,
100 [HSR_EC_CP14_64] = kvm_handle_cp14_access, 100 [HSR_EC_CP14_64] = kvm_handle_cp14_64,
101 [HSR_EC_CP_0_13] = kvm_handle_cp_0_13_access, 101 [HSR_EC_CP_0_13] = kvm_handle_cp_0_13_access,
102 [HSR_EC_CP10_ID] = kvm_handle_cp10_id, 102 [HSR_EC_CP10_ID] = kvm_handle_cp10_id,
103 [HSR_EC_HVC] = handle_hvc, 103 [HSR_EC_HVC] = handle_hvc,
diff --git a/arch/arm/kvm/hyp/Makefile b/arch/arm/kvm/hyp/Makefile
index 3023bb530edf..8679405b0b2b 100644
--- a/arch/arm/kvm/hyp/Makefile
+++ b/arch/arm/kvm/hyp/Makefile
@@ -2,6 +2,8 @@
2# Makefile for Kernel-based Virtual Machine module, HYP part 2# Makefile for Kernel-based Virtual Machine module, HYP part
3# 3#
4 4
5ccflags-y += -fno-stack-protector
6
5KVM=../../../../virt/kvm 7KVM=../../../../virt/kvm
6 8
7obj-$(CONFIG_KVM_ARM_HOST) += $(KVM)/arm/hyp/vgic-v2-sr.o 9obj-$(CONFIG_KVM_ARM_HOST) += $(KVM)/arm/hyp/vgic-v2-sr.o
diff --git a/arch/arm/kvm/hyp/switch.c b/arch/arm/kvm/hyp/switch.c
index 92678b7bd046..624a510d31df 100644
--- a/arch/arm/kvm/hyp/switch.c
+++ b/arch/arm/kvm/hyp/switch.c
@@ -48,7 +48,9 @@ static void __hyp_text __activate_traps(struct kvm_vcpu *vcpu, u32 *fpexc_host)
48 write_sysreg(HSTR_T(15), HSTR); 48 write_sysreg(HSTR_T(15), HSTR);
49 write_sysreg(HCPTR_TTA | HCPTR_TCP(10) | HCPTR_TCP(11), HCPTR); 49 write_sysreg(HCPTR_TTA | HCPTR_TCP(10) | HCPTR_TCP(11), HCPTR);
50 val = read_sysreg(HDCR); 50 val = read_sysreg(HDCR);
51 write_sysreg(val | HDCR_TPM | HDCR_TPMCR, HDCR); 51 val |= HDCR_TPM | HDCR_TPMCR; /* trap performance monitors */
52 val |= HDCR_TDRA | HDCR_TDOSA | HDCR_TDA; /* trap debug regs */
53 write_sysreg(val, HDCR);
52} 54}
53 55
54static void __hyp_text __deactivate_traps(struct kvm_vcpu *vcpu) 56static void __hyp_text __deactivate_traps(struct kvm_vcpu *vcpu)
diff --git a/arch/arm/kvm/trace.h b/arch/arm/kvm/trace.h
index fc0943776db2..b0d10648c486 100644
--- a/arch/arm/kvm/trace.h
+++ b/arch/arm/kvm/trace.h
@@ -1,5 +1,5 @@
1#if !defined(_TRACE_KVM_H) || defined(TRACE_HEADER_MULTI_READ) 1#if !defined(_TRACE_ARM_KVM_H) || defined(TRACE_HEADER_MULTI_READ)
2#define _TRACE_KVM_H 2#define _TRACE_ARM_KVM_H
3 3
4#include <linux/tracepoint.h> 4#include <linux/tracepoint.h>
5 5
@@ -74,10 +74,10 @@ TRACE_EVENT(kvm_hvc,
74 __entry->vcpu_pc, __entry->r0, __entry->imm) 74 __entry->vcpu_pc, __entry->r0, __entry->imm)
75); 75);
76 76
77#endif /* _TRACE_KVM_H */ 77#endif /* _TRACE_ARM_KVM_H */
78 78
79#undef TRACE_INCLUDE_PATH 79#undef TRACE_INCLUDE_PATH
80#define TRACE_INCLUDE_PATH arch/arm/kvm 80#define TRACE_INCLUDE_PATH .
81#undef TRACE_INCLUDE_FILE 81#undef TRACE_INCLUDE_FILE
82#define TRACE_INCLUDE_FILE trace 82#define TRACE_INCLUDE_FILE trace
83 83
diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c
index 2cd27c830ab6..283e79ab587d 100644
--- a/arch/arm/mach-at91/pm.c
+++ b/arch/arm/mach-at91/pm.c
@@ -335,7 +335,7 @@ static const struct ramc_info ramc_infos[] __initconst = {
335 { .idle = sama5d3_ddr_standby, .memctrl = AT91_MEMCTRL_DDRSDR}, 335 { .idle = sama5d3_ddr_standby, .memctrl = AT91_MEMCTRL_DDRSDR},
336}; 336};
337 337
338static const struct of_device_id const ramc_ids[] __initconst = { 338static const struct of_device_id ramc_ids[] __initconst = {
339 { .compatible = "atmel,at91rm9200-sdramc", .data = &ramc_infos[0] }, 339 { .compatible = "atmel,at91rm9200-sdramc", .data = &ramc_infos[0] },
340 { .compatible = "atmel,at91sam9260-sdramc", .data = &ramc_infos[1] }, 340 { .compatible = "atmel,at91sam9260-sdramc", .data = &ramc_infos[1] },
341 { .compatible = "atmel,at91sam9g45-ddramc", .data = &ramc_infos[2] }, 341 { .compatible = "atmel,at91sam9g45-ddramc", .data = &ramc_infos[2] },
diff --git a/arch/arm/mach-bcm/bcm_kona_smc.c b/arch/arm/mach-bcm/bcm_kona_smc.c
index cf3f8658f0e5..a55a7ecf146a 100644
--- a/arch/arm/mach-bcm/bcm_kona_smc.c
+++ b/arch/arm/mach-bcm/bcm_kona_smc.c
@@ -33,7 +33,7 @@ struct bcm_kona_smc_data {
33 unsigned result; 33 unsigned result;
34}; 34};
35 35
36static const struct of_device_id const bcm_kona_smc_ids[] __initconst = { 36static const struct of_device_id bcm_kona_smc_ids[] __initconst = {
37 {.compatible = "brcm,kona-smc"}, 37 {.compatible = "brcm,kona-smc"},
38 {.compatible = "bcm,kona-smc"}, /* deprecated name */ 38 {.compatible = "bcm,kona-smc"}, /* deprecated name */
39 {}, 39 {},
diff --git a/arch/arm/mach-cns3xxx/core.c b/arch/arm/mach-cns3xxx/core.c
index 03da3813f1ab..7d5a44a06648 100644
--- a/arch/arm/mach-cns3xxx/core.c
+++ b/arch/arm/mach-cns3xxx/core.c
@@ -346,7 +346,7 @@ static struct usb_ohci_pdata cns3xxx_usb_ohci_pdata = {
346 .power_off = csn3xxx_usb_power_off, 346 .power_off = csn3xxx_usb_power_off,
347}; 347};
348 348
349static const struct of_dev_auxdata const cns3xxx_auxdata[] __initconst = { 349static const struct of_dev_auxdata cns3xxx_auxdata[] __initconst = {
350 { "intel,usb-ehci", CNS3XXX_USB_BASE, "ehci-platform", &cns3xxx_usb_ehci_pdata }, 350 { "intel,usb-ehci", CNS3XXX_USB_BASE, "ehci-platform", &cns3xxx_usb_ehci_pdata },
351 { "intel,usb-ohci", CNS3XXX_USB_OHCI_BASE, "ohci-platform", &cns3xxx_usb_ohci_pdata }, 351 { "intel,usb-ohci", CNS3XXX_USB_OHCI_BASE, "ohci-platform", &cns3xxx_usb_ohci_pdata },
352 { "cavium,cns3420-ahci", CNS3XXX_SATA2_BASE, "ahci", NULL }, 352 { "cavium,cns3420-ahci", CNS3XXX_SATA2_BASE, "ahci", NULL },
diff --git a/arch/arm/mach-omap2/common.h b/arch/arm/mach-omap2/common.h
index 3089d3bfa19b..8cc6338fcb12 100644
--- a/arch/arm/mach-omap2/common.h
+++ b/arch/arm/mach-omap2/common.h
@@ -266,11 +266,12 @@ extern int omap4_cpu_kill(unsigned int cpu);
266extern const struct smp_operations omap4_smp_ops; 266extern const struct smp_operations omap4_smp_ops;
267#endif 267#endif
268 268
269extern u32 omap4_get_cpu1_ns_pa_addr(void);
270
269#if defined(CONFIG_SMP) && defined(CONFIG_PM) 271#if defined(CONFIG_SMP) && defined(CONFIG_PM)
270extern int omap4_mpuss_init(void); 272extern int omap4_mpuss_init(void);
271extern int omap4_enter_lowpower(unsigned int cpu, unsigned int power_state); 273extern int omap4_enter_lowpower(unsigned int cpu, unsigned int power_state);
272extern int omap4_hotplug_cpu(unsigned int cpu, unsigned int power_state); 274extern int omap4_hotplug_cpu(unsigned int cpu, unsigned int power_state);
273extern u32 omap4_get_cpu1_ns_pa_addr(void);
274#else 275#else
275static inline int omap4_enter_lowpower(unsigned int cpu, 276static inline int omap4_enter_lowpower(unsigned int cpu,
276 unsigned int power_state) 277 unsigned int power_state)
diff --git a/arch/arm/mach-omap2/omap-mpuss-lowpower.c b/arch/arm/mach-omap2/omap-mpuss-lowpower.c
index 03ec6d307c82..4cfc4f9b2c69 100644
--- a/arch/arm/mach-omap2/omap-mpuss-lowpower.c
+++ b/arch/arm/mach-omap2/omap-mpuss-lowpower.c
@@ -213,11 +213,6 @@ static void __init save_l2x0_context(void)
213{} 213{}
214#endif 214#endif
215 215
216u32 omap4_get_cpu1_ns_pa_addr(void)
217{
218 return old_cpu1_ns_pa_addr;
219}
220
221/** 216/**
222 * omap4_enter_lowpower: OMAP4 MPUSS Low Power Entry Function 217 * omap4_enter_lowpower: OMAP4 MPUSS Low Power Entry Function
223 * The purpose of this function is to manage low power programming 218 * The purpose of this function is to manage low power programming
@@ -457,6 +452,11 @@ int __init omap4_mpuss_init(void)
457 452
458#endif 453#endif
459 454
455u32 omap4_get_cpu1_ns_pa_addr(void)
456{
457 return old_cpu1_ns_pa_addr;
458}
459
460/* 460/*
461 * For kexec, we must set CPU1_WAKEUP_NS_PA_ADDR to point to 461 * For kexec, we must set CPU1_WAKEUP_NS_PA_ADDR to point to
462 * current kernel's secondary_startup() early before 462 * current kernel's secondary_startup() early before
diff --git a/arch/arm/mach-omap2/omap-smp.c b/arch/arm/mach-omap2/omap-smp.c
index 3faf454ba487..33e4953c61a8 100644
--- a/arch/arm/mach-omap2/omap-smp.c
+++ b/arch/arm/mach-omap2/omap-smp.c
@@ -306,7 +306,6 @@ static void __init omap4_smp_maybe_reset_cpu1(struct omap_smp_config *c)
306 306
307 cpu1_startup_pa = readl_relaxed(cfg.wakeupgen_base + 307 cpu1_startup_pa = readl_relaxed(cfg.wakeupgen_base +
308 OMAP_AUX_CORE_BOOT_1); 308 OMAP_AUX_CORE_BOOT_1);
309 cpu1_ns_pa_addr = omap4_get_cpu1_ns_pa_addr();
310 309
311 /* Did the configured secondary_startup() get overwritten? */ 310 /* Did the configured secondary_startup() get overwritten? */
312 if (!omap4_smp_cpu1_startup_valid(cpu1_startup_pa)) 311 if (!omap4_smp_cpu1_startup_valid(cpu1_startup_pa))
@@ -316,9 +315,13 @@ static void __init omap4_smp_maybe_reset_cpu1(struct omap_smp_config *c)
316 * If omap4 or 5 has NS_PA_ADDR configured, CPU1 may be in a 315 * If omap4 or 5 has NS_PA_ADDR configured, CPU1 may be in a
317 * deeper idle state in WFI and will wake to an invalid address. 316 * deeper idle state in WFI and will wake to an invalid address.
318 */ 317 */
319 if ((soc_is_omap44xx() || soc_is_omap54xx()) && 318 if ((soc_is_omap44xx() || soc_is_omap54xx())) {
320 !omap4_smp_cpu1_startup_valid(cpu1_ns_pa_addr)) 319 cpu1_ns_pa_addr = omap4_get_cpu1_ns_pa_addr();
321 needs_reset = true; 320 if (!omap4_smp_cpu1_startup_valid(cpu1_ns_pa_addr))
321 needs_reset = true;
322 } else {
323 cpu1_ns_pa_addr = 0;
324 }
322 325
323 if (!needs_reset || !c->cpu1_rstctrl_va) 326 if (!needs_reset || !c->cpu1_rstctrl_va)
324 return; 327 return;
diff --git a/arch/arm/mach-omap2/prm_common.c b/arch/arm/mach-omap2/prm_common.c
index 2b138b65129a..dc11841ca334 100644
--- a/arch/arm/mach-omap2/prm_common.c
+++ b/arch/arm/mach-omap2/prm_common.c
@@ -711,7 +711,7 @@ static struct omap_prcm_init_data scrm_data __initdata = {
711}; 711};
712#endif 712#endif
713 713
714static const struct of_device_id const omap_prcm_dt_match_table[] __initconst = { 714static const struct of_device_id omap_prcm_dt_match_table[] __initconst = {
715#ifdef CONFIG_SOC_AM33XX 715#ifdef CONFIG_SOC_AM33XX
716 { .compatible = "ti,am3-prcm", .data = &am3_prm_data }, 716 { .compatible = "ti,am3-prcm", .data = &am3_prm_data },
717#endif 717#endif
diff --git a/arch/arm/mach-omap2/vc.c b/arch/arm/mach-omap2/vc.c
index 2028167fff31..d76b1e5eb8ba 100644
--- a/arch/arm/mach-omap2/vc.c
+++ b/arch/arm/mach-omap2/vc.c
@@ -559,7 +559,7 @@ struct i2c_init_data {
559 u8 hsscll_12; 559 u8 hsscll_12;
560}; 560};
561 561
562static const struct i2c_init_data const omap4_i2c_timing_data[] __initconst = { 562static const struct i2c_init_data omap4_i2c_timing_data[] __initconst = {
563 { 563 {
564 .load = 50, 564 .load = 50,
565 .loadbits = 0x3, 565 .loadbits = 0x3,
diff --git a/arch/arm/mach-spear/time.c b/arch/arm/mach-spear/time.c
index 4878ba90026d..289e036c9c30 100644
--- a/arch/arm/mach-spear/time.c
+++ b/arch/arm/mach-spear/time.c
@@ -204,7 +204,7 @@ static void __init spear_clockevent_init(int irq)
204 setup_irq(irq, &spear_timer_irq); 204 setup_irq(irq, &spear_timer_irq);
205} 205}
206 206
207static const struct of_device_id const timer_of_match[] __initconst = { 207static const struct of_device_id timer_of_match[] __initconst = {
208 { .compatible = "st,spear-timer", }, 208 { .compatible = "st,spear-timer", },
209 { }, 209 { },
210}; 210};
diff --git a/arch/arm64/Kconfig.platforms b/arch/arm64/Kconfig.platforms
index 4afcffcb46cb..73272f43ca01 100644
--- a/arch/arm64/Kconfig.platforms
+++ b/arch/arm64/Kconfig.platforms
@@ -106,8 +106,13 @@ config ARCH_MVEBU
106 select ARMADA_AP806_SYSCON 106 select ARMADA_AP806_SYSCON
107 select ARMADA_CP110_SYSCON 107 select ARMADA_CP110_SYSCON
108 select ARMADA_37XX_CLK 108 select ARMADA_37XX_CLK
109 select GPIOLIB
110 select GPIOLIB_IRQCHIP
109 select MVEBU_ODMI 111 select MVEBU_ODMI
110 select MVEBU_PIC 112 select MVEBU_PIC
113 select OF_GPIO
114 select PINCTRL
115 select PINCTRL_ARMADA_37XX
111 help 116 help
112 This enables support for Marvell EBU familly, including: 117 This enables support for Marvell EBU familly, including:
113 - Armada 3700 SoC Family 118 - Armada 3700 SoC Family
diff --git a/arch/arm64/boot/dts/include/arm b/arch/arm64/boot/dts/include/arm
deleted file mode 120000
index cf63d80e2b93..000000000000
--- a/arch/arm64/boot/dts/include/arm
+++ /dev/null
@@ -1 +0,0 @@
1../../../../arm/boot/dts \ No newline at end of file
diff --git a/arch/arm64/boot/dts/include/arm64 b/arch/arm64/boot/dts/include/arm64
deleted file mode 120000
index a96aa0ea9d8c..000000000000
--- a/arch/arm64/boot/dts/include/arm64
+++ /dev/null
@@ -1 +0,0 @@
1.. \ No newline at end of file
diff --git a/arch/arm64/boot/dts/include/dt-bindings b/arch/arm64/boot/dts/include/dt-bindings
deleted file mode 120000
index 08c00e4972fa..000000000000
--- a/arch/arm64/boot/dts/include/dt-bindings
+++ /dev/null
@@ -1 +0,0 @@
1../../../../../include/dt-bindings \ No newline at end of file
diff --git a/arch/arm64/boot/dts/marvell/armada-3720-db.dts b/arch/arm64/boot/dts/marvell/armada-3720-db.dts
index cef5f976bc0f..a89855f57091 100644
--- a/arch/arm64/boot/dts/marvell/armada-3720-db.dts
+++ b/arch/arm64/boot/dts/marvell/armada-3720-db.dts
@@ -79,6 +79,8 @@
79}; 79};
80 80
81&i2c0 { 81&i2c0 {
82 pinctrl-names = "default";
83 pinctrl-0 = <&i2c1_pins>;
82 status = "okay"; 84 status = "okay";
83 85
84 gpio_exp: pca9555@22 { 86 gpio_exp: pca9555@22 {
@@ -113,6 +115,8 @@
113 115
114&spi0 { 116&spi0 {
115 status = "okay"; 117 status = "okay";
118 pinctrl-names = "default";
119 pinctrl-0 = <&spi_quad_pins>;
116 120
117 m25p80@0 { 121 m25p80@0 {
118 compatible = "jedec,spi-nor"; 122 compatible = "jedec,spi-nor";
@@ -143,6 +147,8 @@
143 147
144/* Exported on the micro USB connector CON32 through an FTDI */ 148/* Exported on the micro USB connector CON32 through an FTDI */
145&uart0 { 149&uart0 {
150 pinctrl-names = "default";
151 pinctrl-0 = <&uart1_pins>;
146 status = "okay"; 152 status = "okay";
147}; 153};
148 154
@@ -184,6 +190,8 @@
184}; 190};
185 191
186&eth0 { 192&eth0 {
193 pinctrl-names = "default";
194 pinctrl-0 = <&rgmii_pins>;
187 phy-mode = "rgmii-id"; 195 phy-mode = "rgmii-id";
188 phy = <&phy0>; 196 phy = <&phy0>;
189 status = "okay"; 197 status = "okay";
diff --git a/arch/arm64/boot/dts/marvell/armada-37xx.dtsi b/arch/arm64/boot/dts/marvell/armada-37xx.dtsi
index 58ae9e095af2..4d495ec39202 100644
--- a/arch/arm64/boot/dts/marvell/armada-37xx.dtsi
+++ b/arch/arm64/boot/dts/marvell/armada-37xx.dtsi
@@ -161,16 +161,83 @@
161 #clock-cells = <1>; 161 #clock-cells = <1>;
162 }; 162 };
163 163
164 gpio1: gpio@13800 { 164 pinctrl_nb: pinctrl@13800 {
165 compatible = "marvell,mvebu-gpio-3700", 165 compatible = "marvell,armada3710-nb-pinctrl",
166 "syscon", "simple-mfd"; 166 "syscon", "simple-mfd";
167 reg = <0x13800 0x500>; 167 reg = <0x13800 0x100>, <0x13C00 0x20>;
168 gpionb: gpio {
169 #gpio-cells = <2>;
170 gpio-ranges = <&pinctrl_nb 0 0 36>;
171 gpio-controller;
172 interrupts =
173 <GIC_SPI 51 IRQ_TYPE_LEVEL_HIGH>,
174 <GIC_SPI 52 IRQ_TYPE_LEVEL_HIGH>,
175 <GIC_SPI 53 IRQ_TYPE_LEVEL_HIGH>,
176 <GIC_SPI 54 IRQ_TYPE_LEVEL_HIGH>,
177 <GIC_SPI 55 IRQ_TYPE_LEVEL_HIGH>,
178 <GIC_SPI 56 IRQ_TYPE_LEVEL_HIGH>,
179 <GIC_SPI 57 IRQ_TYPE_LEVEL_HIGH>,
180 <GIC_SPI 58 IRQ_TYPE_LEVEL_HIGH>,
181 <GIC_SPI 152 IRQ_TYPE_LEVEL_HIGH>,
182 <GIC_SPI 153 IRQ_TYPE_LEVEL_HIGH>,
183 <GIC_SPI 154 IRQ_TYPE_LEVEL_HIGH>,
184 <GIC_SPI 155 IRQ_TYPE_LEVEL_HIGH>;
185
186 };
168 187
169 xtalclk: xtal-clk { 188 xtalclk: xtal-clk {
170 compatible = "marvell,armada-3700-xtal-clock"; 189 compatible = "marvell,armada-3700-xtal-clock";
171 clock-output-names = "xtal"; 190 clock-output-names = "xtal";
172 #clock-cells = <0>; 191 #clock-cells = <0>;
173 }; 192 };
193
194 spi_quad_pins: spi-quad-pins {
195 groups = "spi_quad";
196 function = "spi";
197 };
198
199 i2c1_pins: i2c1-pins {
200 groups = "i2c1";
201 function = "i2c";
202 };
203
204 i2c2_pins: i2c2-pins {
205 groups = "i2c2";
206 function = "i2c";
207 };
208
209 uart1_pins: uart1-pins {
210 groups = "uart1";
211 function = "uart";
212 };
213
214 uart2_pins: uart2-pins {
215 groups = "uart2";
216 function = "uart";
217 };
218 };
219
220 pinctrl_sb: pinctrl@18800 {
221 compatible = "marvell,armada3710-sb-pinctrl",
222 "syscon", "simple-mfd";
223 reg = <0x18800 0x100>, <0x18C00 0x20>;
224 gpiosb: gpio {
225 #gpio-cells = <2>;
226 gpio-ranges = <&pinctrl_sb 0 0 29>;
227 gpio-controller;
228 interrupts =
229 <GIC_SPI 160 IRQ_TYPE_LEVEL_HIGH>,
230 <GIC_SPI 159 IRQ_TYPE_LEVEL_HIGH>,
231 <GIC_SPI 158 IRQ_TYPE_LEVEL_HIGH>,
232 <GIC_SPI 157 IRQ_TYPE_LEVEL_HIGH>,
233 <GIC_SPI 156 IRQ_TYPE_LEVEL_HIGH>;
234 };
235
236 rgmii_pins: mii-pins {
237 groups = "rgmii";
238 function = "mii";
239 };
240
174 }; 241 };
175 242
176 eth0: ethernet@30000 { 243 eth0: ethernet@30000 {
diff --git a/arch/arm64/boot/dts/mediatek/mt8173-evb.dts b/arch/arm64/boot/dts/mediatek/mt8173-evb.dts
index 0ecaad4333a7..1c3634fa94bf 100644
--- a/arch/arm64/boot/dts/mediatek/mt8173-evb.dts
+++ b/arch/arm64/boot/dts/mediatek/mt8173-evb.dts
@@ -134,6 +134,9 @@
134 bus-width = <8>; 134 bus-width = <8>;
135 max-frequency = <50000000>; 135 max-frequency = <50000000>;
136 cap-mmc-highspeed; 136 cap-mmc-highspeed;
137 mediatek,hs200-cmd-int-delay=<26>;
138 mediatek,hs400-cmd-int-delay=<14>;
139 mediatek,hs400-cmd-resp-sel-rising;
137 vmmc-supply = <&mt6397_vemc_3v3_reg>; 140 vmmc-supply = <&mt6397_vemc_3v3_reg>;
138 vqmmc-supply = <&mt6397_vio18_reg>; 141 vqmmc-supply = <&mt6397_vio18_reg>;
139 non-removable; 142 non-removable;
diff --git a/arch/arm64/boot/dts/rockchip/rk3399-gru-kevin.dts b/arch/arm64/boot/dts/rockchip/rk3399-gru-kevin.dts
index 658bb9dc9dfd..7bd31066399b 100644
--- a/arch/arm64/boot/dts/rockchip/rk3399-gru-kevin.dts
+++ b/arch/arm64/boot/dts/rockchip/rk3399-gru-kevin.dts
@@ -44,7 +44,7 @@
44 44
45/dts-v1/; 45/dts-v1/;
46#include "rk3399-gru.dtsi" 46#include "rk3399-gru.dtsi"
47#include <include/dt-bindings/input/linux-event-codes.h> 47#include <dt-bindings/input/linux-event-codes.h>
48 48
49/* 49/*
50 * Kevin-specific things 50 * Kevin-specific things
diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig
index ce072859e3b2..65cdd878cfbd 100644
--- a/arch/arm64/configs/defconfig
+++ b/arch/arm64/configs/defconfig
@@ -30,7 +30,6 @@ CONFIG_PROFILING=y
30CONFIG_JUMP_LABEL=y 30CONFIG_JUMP_LABEL=y
31CONFIG_MODULES=y 31CONFIG_MODULES=y
32CONFIG_MODULE_UNLOAD=y 32CONFIG_MODULE_UNLOAD=y
33# CONFIG_BLK_DEV_BSG is not set
34# CONFIG_IOSCHED_DEADLINE is not set 33# CONFIG_IOSCHED_DEADLINE is not set
35CONFIG_ARCH_SUNXI=y 34CONFIG_ARCH_SUNXI=y
36CONFIG_ARCH_ALPINE=y 35CONFIG_ARCH_ALPINE=y
@@ -62,16 +61,15 @@ CONFIG_ARCH_XGENE=y
62CONFIG_ARCH_ZX=y 61CONFIG_ARCH_ZX=y
63CONFIG_ARCH_ZYNQMP=y 62CONFIG_ARCH_ZYNQMP=y
64CONFIG_PCI=y 63CONFIG_PCI=y
65CONFIG_PCI_MSI=y
66CONFIG_PCI_IOV=y 64CONFIG_PCI_IOV=y
67CONFIG_PCI_AARDVARK=y
68CONFIG_PCIE_RCAR=y
69CONFIG_PCI_HOST_GENERIC=y
70CONFIG_PCI_XGENE=y
71CONFIG_PCI_LAYERSCAPE=y 65CONFIG_PCI_LAYERSCAPE=y
72CONFIG_PCI_HISI=y 66CONFIG_PCI_HISI=y
73CONFIG_PCIE_QCOM=y 67CONFIG_PCIE_QCOM=y
74CONFIG_PCIE_ARMADA_8K=y 68CONFIG_PCIE_ARMADA_8K=y
69CONFIG_PCI_AARDVARK=y
70CONFIG_PCIE_RCAR=y
71CONFIG_PCI_HOST_GENERIC=y
72CONFIG_PCI_XGENE=y
75CONFIG_ARM64_VA_BITS_48=y 73CONFIG_ARM64_VA_BITS_48=y
76CONFIG_SCHED_MC=y 74CONFIG_SCHED_MC=y
77CONFIG_NUMA=y 75CONFIG_NUMA=y
@@ -80,12 +78,11 @@ CONFIG_KSM=y
80CONFIG_TRANSPARENT_HUGEPAGE=y 78CONFIG_TRANSPARENT_HUGEPAGE=y
81CONFIG_CMA=y 79CONFIG_CMA=y
82CONFIG_SECCOMP=y 80CONFIG_SECCOMP=y
83CONFIG_XEN=y
84CONFIG_KEXEC=y 81CONFIG_KEXEC=y
85CONFIG_CRASH_DUMP=y 82CONFIG_CRASH_DUMP=y
83CONFIG_XEN=y
86# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set 84# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
87CONFIG_COMPAT=y 85CONFIG_COMPAT=y
88CONFIG_CPU_IDLE=y
89CONFIG_HIBERNATION=y 86CONFIG_HIBERNATION=y
90CONFIG_ARM_CPUIDLE=y 87CONFIG_ARM_CPUIDLE=y
91CONFIG_CPU_FREQ=y 88CONFIG_CPU_FREQ=y
@@ -155,8 +152,8 @@ CONFIG_MTD_SPI_NOR=y
155CONFIG_BLK_DEV_LOOP=y 152CONFIG_BLK_DEV_LOOP=y
156CONFIG_BLK_DEV_NBD=m 153CONFIG_BLK_DEV_NBD=m
157CONFIG_VIRTIO_BLK=y 154CONFIG_VIRTIO_BLK=y
158CONFIG_EEPROM_AT25=m
159CONFIG_SRAM=y 155CONFIG_SRAM=y
156CONFIG_EEPROM_AT25=m
160# CONFIG_SCSI_PROC_FS is not set 157# CONFIG_SCSI_PROC_FS is not set
161CONFIG_BLK_DEV_SD=y 158CONFIG_BLK_DEV_SD=y
162CONFIG_SCSI_SAS_ATA=y 159CONFIG_SCSI_SAS_ATA=y
@@ -168,8 +165,8 @@ CONFIG_AHCI_CEVA=y
168CONFIG_AHCI_MVEBU=y 165CONFIG_AHCI_MVEBU=y
169CONFIG_AHCI_XGENE=y 166CONFIG_AHCI_XGENE=y
170CONFIG_AHCI_QORIQ=y 167CONFIG_AHCI_QORIQ=y
171CONFIG_SATA_RCAR=y
172CONFIG_SATA_SIL24=y 168CONFIG_SATA_SIL24=y
169CONFIG_SATA_RCAR=y
173CONFIG_PATA_PLATFORM=y 170CONFIG_PATA_PLATFORM=y
174CONFIG_PATA_OF_PLATFORM=y 171CONFIG_PATA_OF_PLATFORM=y
175CONFIG_NETDEVICES=y 172CONFIG_NETDEVICES=y
@@ -186,18 +183,17 @@ CONFIG_HNS_ENET=y
186CONFIG_E1000E=y 183CONFIG_E1000E=y
187CONFIG_IGB=y 184CONFIG_IGB=y
188CONFIG_IGBVF=y 185CONFIG_IGBVF=y
189CONFIG_MVPP2=y
190CONFIG_MVNETA=y 186CONFIG_MVNETA=y
187CONFIG_MVPP2=y
191CONFIG_SKY2=y 188CONFIG_SKY2=y
192CONFIG_RAVB=y 189CONFIG_RAVB=y
193CONFIG_SMC91X=y 190CONFIG_SMC91X=y
194CONFIG_SMSC911X=y 191CONFIG_SMSC911X=y
195CONFIG_STMMAC_ETH=m 192CONFIG_STMMAC_ETH=m
196CONFIG_REALTEK_PHY=m 193CONFIG_MDIO_BUS_MUX_MMIOREG=y
197CONFIG_MESON_GXL_PHY=m 194CONFIG_MESON_GXL_PHY=m
198CONFIG_MICREL_PHY=y 195CONFIG_MICREL_PHY=y
199CONFIG_MDIO_BUS_MUX=y 196CONFIG_REALTEK_PHY=m
200CONFIG_MDIO_BUS_MUX_MMIOREG=y
201CONFIG_USB_PEGASUS=m 197CONFIG_USB_PEGASUS=m
202CONFIG_USB_RTL8150=m 198CONFIG_USB_RTL8150=m
203CONFIG_USB_RTL8152=m 199CONFIG_USB_RTL8152=m
@@ -230,14 +226,14 @@ CONFIG_SERIAL_8250_UNIPHIER=y
230CONFIG_SERIAL_OF_PLATFORM=y 226CONFIG_SERIAL_OF_PLATFORM=y
231CONFIG_SERIAL_AMBA_PL011=y 227CONFIG_SERIAL_AMBA_PL011=y
232CONFIG_SERIAL_AMBA_PL011_CONSOLE=y 228CONFIG_SERIAL_AMBA_PL011_CONSOLE=y
229CONFIG_SERIAL_MESON=y
230CONFIG_SERIAL_MESON_CONSOLE=y
233CONFIG_SERIAL_SAMSUNG=y 231CONFIG_SERIAL_SAMSUNG=y
234CONFIG_SERIAL_SAMSUNG_CONSOLE=y 232CONFIG_SERIAL_SAMSUNG_CONSOLE=y
235CONFIG_SERIAL_TEGRA=y 233CONFIG_SERIAL_TEGRA=y
236CONFIG_SERIAL_SH_SCI=y 234CONFIG_SERIAL_SH_SCI=y
237CONFIG_SERIAL_SH_SCI_NR_UARTS=11 235CONFIG_SERIAL_SH_SCI_NR_UARTS=11
238CONFIG_SERIAL_SH_SCI_CONSOLE=y 236CONFIG_SERIAL_SH_SCI_CONSOLE=y
239CONFIG_SERIAL_MESON=y
240CONFIG_SERIAL_MESON_CONSOLE=y
241CONFIG_SERIAL_MSM=y 237CONFIG_SERIAL_MSM=y
242CONFIG_SERIAL_MSM_CONSOLE=y 238CONFIG_SERIAL_MSM_CONSOLE=y
243CONFIG_SERIAL_XILINX_PS_UART=y 239CONFIG_SERIAL_XILINX_PS_UART=y
@@ -261,14 +257,14 @@ CONFIG_I2C_UNIPHIER_F=y
261CONFIG_I2C_RCAR=y 257CONFIG_I2C_RCAR=y
262CONFIG_I2C_CROS_EC_TUNNEL=y 258CONFIG_I2C_CROS_EC_TUNNEL=y
263CONFIG_SPI=y 259CONFIG_SPI=y
264CONFIG_SPI_MESON_SPIFC=m
265CONFIG_SPI_BCM2835=m 260CONFIG_SPI_BCM2835=m
266CONFIG_SPI_BCM2835AUX=m 261CONFIG_SPI_BCM2835AUX=m
262CONFIG_SPI_MESON_SPIFC=m
267CONFIG_SPI_ORION=y 263CONFIG_SPI_ORION=y
268CONFIG_SPI_PL022=y 264CONFIG_SPI_PL022=y
269CONFIG_SPI_QUP=y 265CONFIG_SPI_QUP=y
270CONFIG_SPI_SPIDEV=m
271CONFIG_SPI_S3C64XX=y 266CONFIG_SPI_S3C64XX=y
267CONFIG_SPI_SPIDEV=m
272CONFIG_SPMI=y 268CONFIG_SPMI=y
273CONFIG_PINCTRL_SINGLE=y 269CONFIG_PINCTRL_SINGLE=y
274CONFIG_PINCTRL_MAX77620=y 270CONFIG_PINCTRL_MAX77620=y
@@ -286,33 +282,30 @@ CONFIG_GPIO_PCA953X=y
286CONFIG_GPIO_PCA953X_IRQ=y 282CONFIG_GPIO_PCA953X_IRQ=y
287CONFIG_GPIO_MAX77620=y 283CONFIG_GPIO_MAX77620=y
288CONFIG_POWER_RESET_MSM=y 284CONFIG_POWER_RESET_MSM=y
289CONFIG_BATTERY_BQ27XXX=y
290CONFIG_POWER_RESET_XGENE=y 285CONFIG_POWER_RESET_XGENE=y
291CONFIG_POWER_RESET_SYSCON=y 286CONFIG_POWER_RESET_SYSCON=y
287CONFIG_BATTERY_BQ27XXX=y
288CONFIG_SENSORS_ARM_SCPI=y
292CONFIG_SENSORS_LM90=m 289CONFIG_SENSORS_LM90=m
293CONFIG_SENSORS_INA2XX=m 290CONFIG_SENSORS_INA2XX=m
294CONFIG_SENSORS_ARM_SCPI=y
295CONFIG_THERMAL=y
296CONFIG_THERMAL_EMULATION=y
297CONFIG_THERMAL_GOV_POWER_ALLOCATOR=y 291CONFIG_THERMAL_GOV_POWER_ALLOCATOR=y
298CONFIG_CPU_THERMAL=y 292CONFIG_CPU_THERMAL=y
299CONFIG_BCM2835_THERMAL=y 293CONFIG_THERMAL_EMULATION=y
300CONFIG_EXYNOS_THERMAL=y 294CONFIG_EXYNOS_THERMAL=y
301CONFIG_WATCHDOG=y 295CONFIG_WATCHDOG=y
302CONFIG_BCM2835_WDT=y
303CONFIG_RENESAS_WDT=y
304CONFIG_S3C2410_WATCHDOG=y 296CONFIG_S3C2410_WATCHDOG=y
305CONFIG_MESON_GXBB_WATCHDOG=m 297CONFIG_MESON_GXBB_WATCHDOG=m
306CONFIG_MESON_WATCHDOG=m 298CONFIG_MESON_WATCHDOG=m
299CONFIG_RENESAS_WDT=y
300CONFIG_BCM2835_WDT=y
301CONFIG_MFD_CROS_EC=y
302CONFIG_MFD_CROS_EC_I2C=y
307CONFIG_MFD_EXYNOS_LPASS=m 303CONFIG_MFD_EXYNOS_LPASS=m
304CONFIG_MFD_HI655X_PMIC=y
308CONFIG_MFD_MAX77620=y 305CONFIG_MFD_MAX77620=y
309CONFIG_MFD_RK808=y
310CONFIG_MFD_SPMI_PMIC=y 306CONFIG_MFD_SPMI_PMIC=y
307CONFIG_MFD_RK808=y
311CONFIG_MFD_SEC_CORE=y 308CONFIG_MFD_SEC_CORE=y
312CONFIG_MFD_HI655X_PMIC=y
313CONFIG_REGULATOR=y
314CONFIG_MFD_CROS_EC=y
315CONFIG_MFD_CROS_EC_I2C=y
316CONFIG_REGULATOR_FIXED_VOLTAGE=y 309CONFIG_REGULATOR_FIXED_VOLTAGE=y
317CONFIG_REGULATOR_GPIO=y 310CONFIG_REGULATOR_GPIO=y
318CONFIG_REGULATOR_HI655X=y 311CONFIG_REGULATOR_HI655X=y
@@ -345,13 +338,12 @@ CONFIG_DRM_EXYNOS_DSI=y
345CONFIG_DRM_EXYNOS_HDMI=y 338CONFIG_DRM_EXYNOS_HDMI=y
346CONFIG_DRM_EXYNOS_MIC=y 339CONFIG_DRM_EXYNOS_MIC=y
347CONFIG_DRM_RCAR_DU=m 340CONFIG_DRM_RCAR_DU=m
348CONFIG_DRM_RCAR_HDMI=y
349CONFIG_DRM_RCAR_LVDS=y 341CONFIG_DRM_RCAR_LVDS=y
350CONFIG_DRM_RCAR_VSP=y 342CONFIG_DRM_RCAR_VSP=y
351CONFIG_DRM_TEGRA=m 343CONFIG_DRM_TEGRA=m
352CONFIG_DRM_VC4=m
353CONFIG_DRM_PANEL_SIMPLE=m 344CONFIG_DRM_PANEL_SIMPLE=m
354CONFIG_DRM_I2C_ADV7511=m 345CONFIG_DRM_I2C_ADV7511=m
346CONFIG_DRM_VC4=m
355CONFIG_DRM_HISI_KIRIN=m 347CONFIG_DRM_HISI_KIRIN=m
356CONFIG_DRM_MESON=m 348CONFIG_DRM_MESON=m
357CONFIG_FB=y 349CONFIG_FB=y
@@ -366,39 +358,37 @@ CONFIG_SOUND=y
366CONFIG_SND=y 358CONFIG_SND=y
367CONFIG_SND_SOC=y 359CONFIG_SND_SOC=y
368CONFIG_SND_BCM2835_SOC_I2S=m 360CONFIG_SND_BCM2835_SOC_I2S=m
369CONFIG_SND_SOC_RCAR=y
370CONFIG_SND_SOC_SAMSUNG=y 361CONFIG_SND_SOC_SAMSUNG=y
362CONFIG_SND_SOC_RCAR=y
371CONFIG_SND_SOC_AK4613=y 363CONFIG_SND_SOC_AK4613=y
372CONFIG_USB=y 364CONFIG_USB=y
373CONFIG_USB_OTG=y 365CONFIG_USB_OTG=y
374CONFIG_USB_XHCI_HCD=y 366CONFIG_USB_XHCI_HCD=y
375CONFIG_USB_XHCI_PLATFORM=y
376CONFIG_USB_XHCI_RCAR=y
377CONFIG_USB_EHCI_EXYNOS=y
378CONFIG_USB_XHCI_TEGRA=y 367CONFIG_USB_XHCI_TEGRA=y
379CONFIG_USB_EHCI_HCD=y 368CONFIG_USB_EHCI_HCD=y
380CONFIG_USB_EHCI_MSM=y 369CONFIG_USB_EHCI_MSM=y
370CONFIG_USB_EHCI_EXYNOS=y
381CONFIG_USB_EHCI_HCD_PLATFORM=y 371CONFIG_USB_EHCI_HCD_PLATFORM=y
382CONFIG_USB_OHCI_EXYNOS=y
383CONFIG_USB_OHCI_HCD=y 372CONFIG_USB_OHCI_HCD=y
373CONFIG_USB_OHCI_EXYNOS=y
384CONFIG_USB_OHCI_HCD_PLATFORM=y 374CONFIG_USB_OHCI_HCD_PLATFORM=y
385CONFIG_USB_RENESAS_USBHS=m 375CONFIG_USB_RENESAS_USBHS=m
386CONFIG_USB_STORAGE=y 376CONFIG_USB_STORAGE=y
387CONFIG_USB_DWC2=y
388CONFIG_USB_DWC3=y 377CONFIG_USB_DWC3=y
378CONFIG_USB_DWC2=y
389CONFIG_USB_CHIPIDEA=y 379CONFIG_USB_CHIPIDEA=y
390CONFIG_USB_CHIPIDEA_UDC=y 380CONFIG_USB_CHIPIDEA_UDC=y
391CONFIG_USB_CHIPIDEA_HOST=y 381CONFIG_USB_CHIPIDEA_HOST=y
392CONFIG_USB_ISP1760=y 382CONFIG_USB_ISP1760=y
393CONFIG_USB_HSIC_USB3503=y 383CONFIG_USB_HSIC_USB3503=y
394CONFIG_USB_MSM_OTG=y 384CONFIG_USB_MSM_OTG=y
385CONFIG_USB_QCOM_8X16_PHY=y
395CONFIG_USB_ULPI=y 386CONFIG_USB_ULPI=y
396CONFIG_USB_GADGET=y 387CONFIG_USB_GADGET=y
397CONFIG_USB_RENESAS_USBHS_UDC=m 388CONFIG_USB_RENESAS_USBHS_UDC=m
398CONFIG_MMC=y 389CONFIG_MMC=y
399CONFIG_MMC_BLOCK_MINORS=32 390CONFIG_MMC_BLOCK_MINORS=32
400CONFIG_MMC_ARMMMCI=y 391CONFIG_MMC_ARMMMCI=y
401CONFIG_MMC_MESON_GX=y
402CONFIG_MMC_SDHCI=y 392CONFIG_MMC_SDHCI=y
403CONFIG_MMC_SDHCI_ACPI=y 393CONFIG_MMC_SDHCI_ACPI=y
404CONFIG_MMC_SDHCI_PLTFM=y 394CONFIG_MMC_SDHCI_PLTFM=y
@@ -406,6 +396,7 @@ CONFIG_MMC_SDHCI_OF_ARASAN=y
406CONFIG_MMC_SDHCI_OF_ESDHC=y 396CONFIG_MMC_SDHCI_OF_ESDHC=y
407CONFIG_MMC_SDHCI_CADENCE=y 397CONFIG_MMC_SDHCI_CADENCE=y
408CONFIG_MMC_SDHCI_TEGRA=y 398CONFIG_MMC_SDHCI_TEGRA=y
399CONFIG_MMC_MESON_GX=y
409CONFIG_MMC_SDHCI_MSM=y 400CONFIG_MMC_SDHCI_MSM=y
410CONFIG_MMC_SPI=y 401CONFIG_MMC_SPI=y
411CONFIG_MMC_SDHI=y 402CONFIG_MMC_SDHI=y
@@ -414,32 +405,31 @@ CONFIG_MMC_DW_EXYNOS=y
414CONFIG_MMC_DW_K3=y 405CONFIG_MMC_DW_K3=y
415CONFIG_MMC_DW_ROCKCHIP=y 406CONFIG_MMC_DW_ROCKCHIP=y
416CONFIG_MMC_SUNXI=y 407CONFIG_MMC_SUNXI=y
417CONFIG_MMC_SDHCI_XENON=y
418CONFIG_MMC_BCM2835=y 408CONFIG_MMC_BCM2835=y
409CONFIG_MMC_SDHCI_XENON=y
419CONFIG_NEW_LEDS=y 410CONFIG_NEW_LEDS=y
420CONFIG_LEDS_CLASS=y 411CONFIG_LEDS_CLASS=y
421CONFIG_LEDS_GPIO=y 412CONFIG_LEDS_GPIO=y
422CONFIG_LEDS_PWM=y 413CONFIG_LEDS_PWM=y
423CONFIG_LEDS_SYSCON=y 414CONFIG_LEDS_SYSCON=y
424CONFIG_LEDS_TRIGGERS=y
425CONFIG_LEDS_TRIGGER_DEFAULT_ON=y
426CONFIG_LEDS_TRIGGER_HEARTBEAT=y 415CONFIG_LEDS_TRIGGER_HEARTBEAT=y
427CONFIG_LEDS_TRIGGER_CPU=y 416CONFIG_LEDS_TRIGGER_CPU=y
417CONFIG_LEDS_TRIGGER_DEFAULT_ON=y
428CONFIG_RTC_CLASS=y 418CONFIG_RTC_CLASS=y
429CONFIG_RTC_DRV_MAX77686=y 419CONFIG_RTC_DRV_MAX77686=y
420CONFIG_RTC_DRV_RK808=m
430CONFIG_RTC_DRV_S5M=y 421CONFIG_RTC_DRV_S5M=y
431CONFIG_RTC_DRV_DS3232=y 422CONFIG_RTC_DRV_DS3232=y
432CONFIG_RTC_DRV_EFI=y 423CONFIG_RTC_DRV_EFI=y
424CONFIG_RTC_DRV_S3C=y
433CONFIG_RTC_DRV_PL031=y 425CONFIG_RTC_DRV_PL031=y
434CONFIG_RTC_DRV_SUN6I=y 426CONFIG_RTC_DRV_SUN6I=y
435CONFIG_RTC_DRV_RK808=m
436CONFIG_RTC_DRV_TEGRA=y 427CONFIG_RTC_DRV_TEGRA=y
437CONFIG_RTC_DRV_XGENE=y 428CONFIG_RTC_DRV_XGENE=y
438CONFIG_RTC_DRV_S3C=y
439CONFIG_DMADEVICES=y 429CONFIG_DMADEVICES=y
430CONFIG_DMA_BCM2835=m
440CONFIG_MV_XOR_V2=y 431CONFIG_MV_XOR_V2=y
441CONFIG_PL330_DMA=y 432CONFIG_PL330_DMA=y
442CONFIG_DMA_BCM2835=m
443CONFIG_TEGRA20_APB_DMA=y 433CONFIG_TEGRA20_APB_DMA=y
444CONFIG_QCOM_BAM_DMA=y 434CONFIG_QCOM_BAM_DMA=y
445CONFIG_QCOM_HIDMA_MGMT=y 435CONFIG_QCOM_HIDMA_MGMT=y
@@ -452,52 +442,53 @@ CONFIG_VIRTIO_BALLOON=y
452CONFIG_VIRTIO_MMIO=y 442CONFIG_VIRTIO_MMIO=y
453CONFIG_XEN_GNTDEV=y 443CONFIG_XEN_GNTDEV=y
454CONFIG_XEN_GRANT_DEV_ALLOC=y 444CONFIG_XEN_GRANT_DEV_ALLOC=y
445CONFIG_COMMON_CLK_RK808=y
455CONFIG_COMMON_CLK_SCPI=y 446CONFIG_COMMON_CLK_SCPI=y
456CONFIG_COMMON_CLK_CS2000_CP=y 447CONFIG_COMMON_CLK_CS2000_CP=y
457CONFIG_COMMON_CLK_S2MPS11=y 448CONFIG_COMMON_CLK_S2MPS11=y
458CONFIG_COMMON_CLK_PWM=y
459CONFIG_COMMON_CLK_RK808=y
460CONFIG_CLK_QORIQ=y 449CONFIG_CLK_QORIQ=y
450CONFIG_COMMON_CLK_PWM=y
461CONFIG_COMMON_CLK_QCOM=y 451CONFIG_COMMON_CLK_QCOM=y
452CONFIG_QCOM_CLK_SMD_RPM=y
462CONFIG_MSM_GCC_8916=y 453CONFIG_MSM_GCC_8916=y
463CONFIG_MSM_GCC_8994=y 454CONFIG_MSM_GCC_8994=y
464CONFIG_MSM_MMCC_8996=y 455CONFIG_MSM_MMCC_8996=y
465CONFIG_HWSPINLOCK_QCOM=y 456CONFIG_HWSPINLOCK_QCOM=y
466CONFIG_MAILBOX=y
467CONFIG_ARM_MHU=y 457CONFIG_ARM_MHU=y
468CONFIG_PLATFORM_MHU=y 458CONFIG_PLATFORM_MHU=y
469CONFIG_BCM2835_MBOX=y 459CONFIG_BCM2835_MBOX=y
470CONFIG_HI6220_MBOX=y 460CONFIG_HI6220_MBOX=y
471CONFIG_ARM_SMMU=y 461CONFIG_ARM_SMMU=y
472CONFIG_ARM_SMMU_V3=y 462CONFIG_ARM_SMMU_V3=y
463CONFIG_RPMSG_QCOM_SMD=y
473CONFIG_RASPBERRYPI_POWER=y 464CONFIG_RASPBERRYPI_POWER=y
474CONFIG_QCOM_SMEM=y 465CONFIG_QCOM_SMEM=y
475CONFIG_QCOM_SMD=y
476CONFIG_QCOM_SMD_RPM=y 466CONFIG_QCOM_SMD_RPM=y
467CONFIG_QCOM_SMP2P=y
468CONFIG_QCOM_SMSM=y
477CONFIG_ROCKCHIP_PM_DOMAINS=y 469CONFIG_ROCKCHIP_PM_DOMAINS=y
478CONFIG_ARCH_TEGRA_132_SOC=y 470CONFIG_ARCH_TEGRA_132_SOC=y
479CONFIG_ARCH_TEGRA_210_SOC=y 471CONFIG_ARCH_TEGRA_210_SOC=y
480CONFIG_ARCH_TEGRA_186_SOC=y 472CONFIG_ARCH_TEGRA_186_SOC=y
481CONFIG_EXTCON_USB_GPIO=y 473CONFIG_EXTCON_USB_GPIO=y
474CONFIG_IIO=y
475CONFIG_EXYNOS_ADC=y
482CONFIG_PWM=y 476CONFIG_PWM=y
483CONFIG_PWM_BCM2835=m 477CONFIG_PWM_BCM2835=m
478CONFIG_PWM_MESON=m
484CONFIG_PWM_ROCKCHIP=y 479CONFIG_PWM_ROCKCHIP=y
480CONFIG_PWM_SAMSUNG=y
485CONFIG_PWM_TEGRA=m 481CONFIG_PWM_TEGRA=m
486CONFIG_PWM_MESON=m
487CONFIG_COMMON_RESET_HI6220=y
488CONFIG_PHY_RCAR_GEN3_USB2=y 482CONFIG_PHY_RCAR_GEN3_USB2=y
489CONFIG_PHY_HI6220_USB=y 483CONFIG_PHY_HI6220_USB=y
484CONFIG_PHY_SUN4I_USB=y
490CONFIG_PHY_ROCKCHIP_INNO_USB2=y 485CONFIG_PHY_ROCKCHIP_INNO_USB2=y
491CONFIG_PHY_ROCKCHIP_EMMC=y 486CONFIG_PHY_ROCKCHIP_EMMC=y
492CONFIG_PHY_SUN4I_USB=y
493CONFIG_PHY_XGENE=y 487CONFIG_PHY_XGENE=y
494CONFIG_PHY_TEGRA_XUSB=y 488CONFIG_PHY_TEGRA_XUSB=y
495CONFIG_ARM_SCPI_PROTOCOL=y 489CONFIG_ARM_SCPI_PROTOCOL=y
496CONFIG_ACPI=y
497CONFIG_IIO=y
498CONFIG_EXYNOS_ADC=y
499CONFIG_PWM_SAMSUNG=y
500CONFIG_RASPBERRYPI_FIRMWARE=y 490CONFIG_RASPBERRYPI_FIRMWARE=y
491CONFIG_ACPI=y
501CONFIG_EXT2_FS=y 492CONFIG_EXT2_FS=y
502CONFIG_EXT3_FS=y 493CONFIG_EXT3_FS=y
503CONFIG_EXT4_FS_POSIX_ACL=y 494CONFIG_EXT4_FS_POSIX_ACL=y
@@ -511,7 +502,6 @@ CONFIG_FUSE_FS=m
511CONFIG_CUSE=m 502CONFIG_CUSE=m
512CONFIG_OVERLAY_FS=m 503CONFIG_OVERLAY_FS=m
513CONFIG_VFAT_FS=y 504CONFIG_VFAT_FS=y
514CONFIG_TMPFS=y
515CONFIG_HUGETLBFS=y 505CONFIG_HUGETLBFS=y
516CONFIG_CONFIGFS_FS=y 506CONFIG_CONFIGFS_FS=y
517CONFIG_EFIVAR_FS=y 507CONFIG_EFIVAR_FS=y
@@ -539,11 +529,9 @@ CONFIG_MEMTEST=y
539CONFIG_SECURITY=y 529CONFIG_SECURITY=y
540CONFIG_CRYPTO_ECHAINIV=y 530CONFIG_CRYPTO_ECHAINIV=y
541CONFIG_CRYPTO_ANSI_CPRNG=y 531CONFIG_CRYPTO_ANSI_CPRNG=y
542CONFIG_CRYPTO_DEV_SAFEXCEL=m
543CONFIG_ARM64_CRYPTO=y 532CONFIG_ARM64_CRYPTO=y
544CONFIG_CRYPTO_SHA1_ARM64_CE=y 533CONFIG_CRYPTO_SHA1_ARM64_CE=y
545CONFIG_CRYPTO_SHA2_ARM64_CE=y 534CONFIG_CRYPTO_SHA2_ARM64_CE=y
546CONFIG_CRYPTO_GHASH_ARM64_CE=y 535CONFIG_CRYPTO_GHASH_ARM64_CE=y
547CONFIG_CRYPTO_AES_ARM64_CE_CCM=y 536CONFIG_CRYPTO_AES_ARM64_CE_CCM=y
548CONFIG_CRYPTO_AES_ARM64_CE_BLK=y 537CONFIG_CRYPTO_AES_ARM64_CE_BLK=y
549# CONFIG_CRYPTO_AES_ARM64_NEON_BLK is not set
diff --git a/arch/arm64/include/asm/atomic_ll_sc.h b/arch/arm64/include/asm/atomic_ll_sc.h
index f819fdcff1ac..f5a2d09afb38 100644
--- a/arch/arm64/include/asm/atomic_ll_sc.h
+++ b/arch/arm64/include/asm/atomic_ll_sc.h
@@ -264,7 +264,6 @@ __LL_SC_PREFIX(__cmpxchg_case_##name(volatile void *ptr, \
264 " st" #rel "xr" #sz "\t%w[tmp], %" #w "[new], %[v]\n" \ 264 " st" #rel "xr" #sz "\t%w[tmp], %" #w "[new], %[v]\n" \
265 " cbnz %w[tmp], 1b\n" \ 265 " cbnz %w[tmp], 1b\n" \
266 " " #mb "\n" \ 266 " " #mb "\n" \
267 " mov %" #w "[oldval], %" #w "[old]\n" \
268 "2:" \ 267 "2:" \
269 : [tmp] "=&r" (tmp), [oldval] "=&r" (oldval), \ 268 : [tmp] "=&r" (tmp), [oldval] "=&r" (oldval), \
270 [v] "+Q" (*(unsigned long *)ptr) \ 269 [v] "+Q" (*(unsigned long *)ptr) \
diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h
index e7f84a7b4465..428ee1f2468c 100644
--- a/arch/arm64/include/asm/cpufeature.h
+++ b/arch/arm64/include/asm/cpufeature.h
@@ -115,6 +115,7 @@ struct arm64_cpu_capabilities {
115 115
116extern DECLARE_BITMAP(cpu_hwcaps, ARM64_NCAPS); 116extern DECLARE_BITMAP(cpu_hwcaps, ARM64_NCAPS);
117extern struct static_key_false cpu_hwcap_keys[ARM64_NCAPS]; 117extern struct static_key_false cpu_hwcap_keys[ARM64_NCAPS];
118extern struct static_key_false arm64_const_caps_ready;
118 119
119bool this_cpu_has_cap(unsigned int cap); 120bool this_cpu_has_cap(unsigned int cap);
120 121
@@ -124,7 +125,7 @@ static inline bool cpu_have_feature(unsigned int num)
124} 125}
125 126
126/* System capability check for constant caps */ 127/* System capability check for constant caps */
127static inline bool cpus_have_const_cap(int num) 128static inline bool __cpus_have_const_cap(int num)
128{ 129{
129 if (num >= ARM64_NCAPS) 130 if (num >= ARM64_NCAPS)
130 return false; 131 return false;
@@ -138,6 +139,14 @@ static inline bool cpus_have_cap(unsigned int num)
138 return test_bit(num, cpu_hwcaps); 139 return test_bit(num, cpu_hwcaps);
139} 140}
140 141
142static inline bool cpus_have_const_cap(int num)
143{
144 if (static_branch_likely(&arm64_const_caps_ready))
145 return __cpus_have_const_cap(num);
146 else
147 return cpus_have_cap(num);
148}
149
141static inline void cpus_set_cap(unsigned int num) 150static inline void cpus_set_cap(unsigned int num)
142{ 151{
143 if (num >= ARM64_NCAPS) { 152 if (num >= ARM64_NCAPS) {
@@ -145,7 +154,6 @@ static inline void cpus_set_cap(unsigned int num)
145 num, ARM64_NCAPS); 154 num, ARM64_NCAPS);
146 } else { 155 } else {
147 __set_bit(num, cpu_hwcaps); 156 __set_bit(num, cpu_hwcaps);
148 static_branch_enable(&cpu_hwcap_keys[num]);
149 } 157 }
150} 158}
151 159
diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h
index 5e19165c5fa8..1f252a95bc02 100644
--- a/arch/arm64/include/asm/kvm_host.h
+++ b/arch/arm64/include/asm/kvm_host.h
@@ -24,6 +24,7 @@
24 24
25#include <linux/types.h> 25#include <linux/types.h>
26#include <linux/kvm_types.h> 26#include <linux/kvm_types.h>
27#include <asm/cpufeature.h>
27#include <asm/kvm.h> 28#include <asm/kvm.h>
28#include <asm/kvm_asm.h> 29#include <asm/kvm_asm.h>
29#include <asm/kvm_mmio.h> 30#include <asm/kvm_mmio.h>
@@ -355,9 +356,12 @@ static inline void __cpu_init_hyp_mode(phys_addr_t pgd_ptr,
355 unsigned long vector_ptr) 356 unsigned long vector_ptr)
356{ 357{
357 /* 358 /*
358 * Call initialization code, and switch to the full blown 359 * Call initialization code, and switch to the full blown HYP code.
359 * HYP code. 360 * If the cpucaps haven't been finalized yet, something has gone very
361 * wrong, and hyp will crash and burn when it uses any
362 * cpus_have_const_cap() wrapper.
360 */ 363 */
364 BUG_ON(!static_branch_likely(&arm64_const_caps_ready));
361 __kvm_call_hyp((void *)pgd_ptr, hyp_stack_ptr, vector_ptr); 365 __kvm_call_hyp((void *)pgd_ptr, hyp_stack_ptr, vector_ptr);
362} 366}
363 367
diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
index 94b8f7fc3310..817ce3365e20 100644
--- a/arch/arm64/kernel/cpufeature.c
+++ b/arch/arm64/kernel/cpufeature.c
@@ -985,8 +985,16 @@ void update_cpu_capabilities(const struct arm64_cpu_capabilities *caps,
985 */ 985 */
986void __init enable_cpu_capabilities(const struct arm64_cpu_capabilities *caps) 986void __init enable_cpu_capabilities(const struct arm64_cpu_capabilities *caps)
987{ 987{
988 for (; caps->matches; caps++) 988 for (; caps->matches; caps++) {
989 if (caps->enable && cpus_have_cap(caps->capability)) 989 unsigned int num = caps->capability;
990
991 if (!cpus_have_cap(num))
992 continue;
993
994 /* Ensure cpus_have_const_cap(num) works */
995 static_branch_enable(&cpu_hwcap_keys[num]);
996
997 if (caps->enable) {
990 /* 998 /*
991 * Use stop_machine() as it schedules the work allowing 999 * Use stop_machine() as it schedules the work allowing
992 * us to modify PSTATE, instead of on_each_cpu() which 1000 * us to modify PSTATE, instead of on_each_cpu() which
@@ -994,6 +1002,8 @@ void __init enable_cpu_capabilities(const struct arm64_cpu_capabilities *caps)
994 * we return. 1002 * we return.
995 */ 1003 */
996 stop_machine(caps->enable, NULL, cpu_online_mask); 1004 stop_machine(caps->enable, NULL, cpu_online_mask);
1005 }
1006 }
997} 1007}
998 1008
999/* 1009/*
@@ -1096,6 +1106,14 @@ static void __init setup_feature_capabilities(void)
1096 enable_cpu_capabilities(arm64_features); 1106 enable_cpu_capabilities(arm64_features);
1097} 1107}
1098 1108
1109DEFINE_STATIC_KEY_FALSE(arm64_const_caps_ready);
1110EXPORT_SYMBOL(arm64_const_caps_ready);
1111
1112static void __init mark_const_caps_ready(void)
1113{
1114 static_branch_enable(&arm64_const_caps_ready);
1115}
1116
1099/* 1117/*
1100 * Check if the current CPU has a given feature capability. 1118 * Check if the current CPU has a given feature capability.
1101 * Should be called from non-preemptible context. 1119 * Should be called from non-preemptible context.
@@ -1131,6 +1149,7 @@ void __init setup_cpu_features(void)
1131 /* Set the CPU feature capabilies */ 1149 /* Set the CPU feature capabilies */
1132 setup_feature_capabilities(); 1150 setup_feature_capabilities();
1133 enable_errata_workarounds(); 1151 enable_errata_workarounds();
1152 mark_const_caps_ready();
1134 setup_elf_hwcaps(arm64_elf_hwcaps); 1153 setup_elf_hwcaps(arm64_elf_hwcaps);
1135 1154
1136 if (system_supports_32bit_el0()) 1155 if (system_supports_32bit_el0())
diff --git a/arch/arm64/kernel/perf_event.c b/arch/arm64/kernel/perf_event.c
index bcc79471b38e..83a1b1ad189f 100644
--- a/arch/arm64/kernel/perf_event.c
+++ b/arch/arm64/kernel/perf_event.c
@@ -877,15 +877,24 @@ static int armv8pmu_set_event_filter(struct hw_perf_event *event,
877 877
878 if (attr->exclude_idle) 878 if (attr->exclude_idle)
879 return -EPERM; 879 return -EPERM;
880 if (is_kernel_in_hyp_mode() && 880
881 attr->exclude_kernel != attr->exclude_hv) 881 /*
882 return -EINVAL; 882 * If we're running in hyp mode, then we *are* the hypervisor.
883 * Therefore we ignore exclude_hv in this configuration, since
884 * there's no hypervisor to sample anyway. This is consistent
885 * with other architectures (x86 and Power).
886 */
887 if (is_kernel_in_hyp_mode()) {
888 if (!attr->exclude_kernel)
889 config_base |= ARMV8_PMU_INCLUDE_EL2;
890 } else {
891 if (attr->exclude_kernel)
892 config_base |= ARMV8_PMU_EXCLUDE_EL1;
893 if (!attr->exclude_hv)
894 config_base |= ARMV8_PMU_INCLUDE_EL2;
895 }
883 if (attr->exclude_user) 896 if (attr->exclude_user)
884 config_base |= ARMV8_PMU_EXCLUDE_EL0; 897 config_base |= ARMV8_PMU_EXCLUDE_EL0;
885 if (!is_kernel_in_hyp_mode() && attr->exclude_kernel)
886 config_base |= ARMV8_PMU_EXCLUDE_EL1;
887 if (!attr->exclude_hv)
888 config_base |= ARMV8_PMU_INCLUDE_EL2;
889 898
890 /* 899 /*
891 * Install the filter into config_base as this is used to 900 * Install the filter into config_base as this is used to
diff --git a/arch/arm64/kvm/hyp/Makefile b/arch/arm64/kvm/hyp/Makefile
index aaf42ae8d8c3..14c4e3b14bcb 100644
--- a/arch/arm64/kvm/hyp/Makefile
+++ b/arch/arm64/kvm/hyp/Makefile
@@ -2,6 +2,8 @@
2# Makefile for Kernel-based Virtual Machine module, HYP part 2# Makefile for Kernel-based Virtual Machine module, HYP part
3# 3#
4 4
5ccflags-y += -fno-stack-protector
6
5KVM=../../../../virt/kvm 7KVM=../../../../virt/kvm
6 8
7obj-$(CONFIG_KVM_ARM_HOST) += $(KVM)/arm/hyp/vgic-v2-sr.o 9obj-$(CONFIG_KVM_ARM_HOST) += $(KVM)/arm/hyp/vgic-v2-sr.o
diff --git a/arch/cris/boot/dts/include/dt-bindings b/arch/cris/boot/dts/include/dt-bindings
deleted file mode 120000
index 08c00e4972fa..000000000000
--- a/arch/cris/boot/dts/include/dt-bindings
+++ /dev/null
@@ -1 +0,0 @@
1../../../../../include/dt-bindings \ No newline at end of file
diff --git a/arch/metag/boot/dts/include/dt-bindings b/arch/metag/boot/dts/include/dt-bindings
deleted file mode 120000
index 08c00e4972fa..000000000000
--- a/arch/metag/boot/dts/include/dt-bindings
+++ /dev/null
@@ -1 +0,0 @@
1../../../../../include/dt-bindings \ No newline at end of file
diff --git a/arch/mips/boot/dts/include/dt-bindings b/arch/mips/boot/dts/include/dt-bindings
deleted file mode 120000
index 08c00e4972fa..000000000000
--- a/arch/mips/boot/dts/include/dt-bindings
+++ /dev/null
@@ -1 +0,0 @@
1../../../../../include/dt-bindings \ No newline at end of file
diff --git a/arch/powerpc/boot/dts/include/dt-bindings b/arch/powerpc/boot/dts/include/dt-bindings
deleted file mode 120000
index 08c00e4972fa..000000000000
--- a/arch/powerpc/boot/dts/include/dt-bindings
+++ /dev/null
@@ -1 +0,0 @@
1../../../../../include/dt-bindings \ No newline at end of file
diff --git a/arch/powerpc/include/asm/module.h b/arch/powerpc/include/asm/module.h
index 53885512b8d3..6c0132c7212f 100644
--- a/arch/powerpc/include/asm/module.h
+++ b/arch/powerpc/include/asm/module.h
@@ -14,6 +14,10 @@
14#include <asm-generic/module.h> 14#include <asm-generic/module.h>
15 15
16 16
17#ifdef CC_USING_MPROFILE_KERNEL
18#define MODULE_ARCH_VERMAGIC "mprofile-kernel"
19#endif
20
17#ifndef __powerpc64__ 21#ifndef __powerpc64__
18/* 22/*
19 * Thanks to Paul M for explaining this. 23 * Thanks to Paul M for explaining this.
diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
index 2a32483c7b6c..8da5d4c1cab2 100644
--- a/arch/powerpc/include/asm/page.h
+++ b/arch/powerpc/include/asm/page.h
@@ -132,7 +132,19 @@ extern long long virt_phys_offset;
132#define virt_to_pfn(kaddr) (__pa(kaddr) >> PAGE_SHIFT) 132#define virt_to_pfn(kaddr) (__pa(kaddr) >> PAGE_SHIFT)
133#define virt_to_page(kaddr) pfn_to_page(virt_to_pfn(kaddr)) 133#define virt_to_page(kaddr) pfn_to_page(virt_to_pfn(kaddr))
134#define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT) 134#define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT)
135
136#ifdef CONFIG_PPC_BOOK3S_64
137/*
138 * On hash the vmalloc and other regions alias to the kernel region when passed
139 * through __pa(), which virt_to_pfn() uses. That means virt_addr_valid() can
140 * return true for some vmalloc addresses, which is incorrect. So explicitly
141 * check that the address is in the kernel region.
142 */
143#define virt_addr_valid(kaddr) (REGION_ID(kaddr) == KERNEL_REGION_ID && \
144 pfn_valid(virt_to_pfn(kaddr)))
145#else
135#define virt_addr_valid(kaddr) pfn_valid(virt_to_pfn(kaddr)) 146#define virt_addr_valid(kaddr) pfn_valid(virt_to_pfn(kaddr))
147#endif
136 148
137/* 149/*
138 * On Book-E parts we need __va to parse the device tree and we can't 150 * On Book-E parts we need __va to parse the device tree and we can't
diff --git a/arch/powerpc/kernel/idle_book3s.S b/arch/powerpc/kernel/idle_book3s.S
index 07d4e0ad60db..4898d676dcae 100644
--- a/arch/powerpc/kernel/idle_book3s.S
+++ b/arch/powerpc/kernel/idle_book3s.S
@@ -416,7 +416,7 @@ power9_dd1_recover_paca:
416 * which needs to be restored from the stack. 416 * which needs to be restored from the stack.
417 */ 417 */
418 li r3, 1 418 li r3, 1
419 stb r0,PACA_NAPSTATELOST(r13) 419 stb r3,PACA_NAPSTATELOST(r13)
420 blr 420 blr
421 421
422/* 422/*
diff --git a/arch/powerpc/kernel/kprobes.c b/arch/powerpc/kernel/kprobes.c
index 160ae0fa7d0d..fc4343514bed 100644
--- a/arch/powerpc/kernel/kprobes.c
+++ b/arch/powerpc/kernel/kprobes.c
@@ -305,16 +305,17 @@ int kprobe_handler(struct pt_regs *regs)
305 save_previous_kprobe(kcb); 305 save_previous_kprobe(kcb);
306 set_current_kprobe(p, regs, kcb); 306 set_current_kprobe(p, regs, kcb);
307 kprobes_inc_nmissed_count(p); 307 kprobes_inc_nmissed_count(p);
308 prepare_singlestep(p, regs);
309 kcb->kprobe_status = KPROBE_REENTER; 308 kcb->kprobe_status = KPROBE_REENTER;
310 if (p->ainsn.boostable >= 0) { 309 if (p->ainsn.boostable >= 0) {
311 ret = try_to_emulate(p, regs); 310 ret = try_to_emulate(p, regs);
312 311
313 if (ret > 0) { 312 if (ret > 0) {
314 restore_previous_kprobe(kcb); 313 restore_previous_kprobe(kcb);
314 preempt_enable_no_resched();
315 return 1; 315 return 1;
316 } 316 }
317 } 317 }
318 prepare_singlestep(p, regs);
318 return 1; 319 return 1;
319 } else { 320 } else {
320 if (*addr != BREAKPOINT_INSTRUCTION) { 321 if (*addr != BREAKPOINT_INSTRUCTION) {
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index d645da302bf2..baae104b16c7 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -864,6 +864,25 @@ static void tm_reclaim_thread(struct thread_struct *thr,
864 if (!MSR_TM_SUSPENDED(mfmsr())) 864 if (!MSR_TM_SUSPENDED(mfmsr()))
865 return; 865 return;
866 866
867 /*
868 * If we are in a transaction and FP is off then we can't have
869 * used FP inside that transaction. Hence the checkpointed
870 * state is the same as the live state. We need to copy the
871 * live state to the checkpointed state so that when the
872 * transaction is restored, the checkpointed state is correct
873 * and the aborted transaction sees the correct state. We use
874 * ckpt_regs.msr here as that's what tm_reclaim will use to
875 * determine if it's going to write the checkpointed state or
876 * not. So either this will write the checkpointed registers,
877 * or reclaim will. Similarly for VMX.
878 */
879 if ((thr->ckpt_regs.msr & MSR_FP) == 0)
880 memcpy(&thr->ckfp_state, &thr->fp_state,
881 sizeof(struct thread_fp_state));
882 if ((thr->ckpt_regs.msr & MSR_VEC) == 0)
883 memcpy(&thr->ckvr_state, &thr->vr_state,
884 sizeof(struct thread_vr_state));
885
867 giveup_all(container_of(thr, struct task_struct, thread)); 886 giveup_all(container_of(thr, struct task_struct, thread));
868 887
869 tm_reclaim(thr, thr->ckpt_regs.msr, cause); 888 tm_reclaim(thr, thr->ckpt_regs.msr, cause);
diff --git a/arch/powerpc/kvm/Kconfig b/arch/powerpc/kvm/Kconfig
index 24de532c1736..0c52cb5d43f5 100644
--- a/arch/powerpc/kvm/Kconfig
+++ b/arch/powerpc/kvm/Kconfig
@@ -67,7 +67,7 @@ config KVM_BOOK3S_64
67 select KVM_BOOK3S_64_HANDLER 67 select KVM_BOOK3S_64_HANDLER
68 select KVM 68 select KVM
69 select KVM_BOOK3S_PR_POSSIBLE if !KVM_BOOK3S_HV_POSSIBLE 69 select KVM_BOOK3S_PR_POSSIBLE if !KVM_BOOK3S_HV_POSSIBLE
70 select SPAPR_TCE_IOMMU if IOMMU_SUPPORT 70 select SPAPR_TCE_IOMMU if IOMMU_SUPPORT && (PPC_SERIES || PPC_POWERNV)
71 ---help--- 71 ---help---
72 Support running unmodified book3s_64 and book3s_32 guest kernels 72 Support running unmodified book3s_64 and book3s_32 guest kernels
73 in virtual machines on book3s_64 host processors. 73 in virtual machines on book3s_64 host processors.
diff --git a/arch/powerpc/kvm/Makefile b/arch/powerpc/kvm/Makefile
index d91a2604c496..381a6ec0ff3b 100644
--- a/arch/powerpc/kvm/Makefile
+++ b/arch/powerpc/kvm/Makefile
@@ -46,7 +46,7 @@ kvm-e500mc-objs := \
46 e500_emulate.o 46 e500_emulate.o
47kvm-objs-$(CONFIG_KVM_E500MC) := $(kvm-e500mc-objs) 47kvm-objs-$(CONFIG_KVM_E500MC) := $(kvm-e500mc-objs)
48 48
49kvm-book3s_64-builtin-objs-$(CONFIG_KVM_BOOK3S_64_HANDLER) := \ 49kvm-book3s_64-builtin-objs-$(CONFIG_SPAPR_TCE_IOMMU) := \
50 book3s_64_vio_hv.o 50 book3s_64_vio_hv.o
51 51
52kvm-pr-y := \ 52kvm-pr-y := \
@@ -90,11 +90,11 @@ kvm-book3s_64-objs-$(CONFIG_KVM_XICS) += \
90 book3s_xics.o 90 book3s_xics.o
91 91
92kvm-book3s_64-objs-$(CONFIG_KVM_XIVE) += book3s_xive.o 92kvm-book3s_64-objs-$(CONFIG_KVM_XIVE) += book3s_xive.o
93kvm-book3s_64-objs-$(CONFIG_SPAPR_TCE_IOMMU) += book3s_64_vio.o
93 94
94kvm-book3s_64-module-objs := \ 95kvm-book3s_64-module-objs := \
95 $(common-objs-y) \ 96 $(common-objs-y) \
96 book3s.o \ 97 book3s.o \
97 book3s_64_vio.o \
98 book3s_rtas.o \ 98 book3s_rtas.o \
99 $(kvm-book3s_64-objs-y) 99 $(kvm-book3s_64-objs-y)
100 100
diff --git a/arch/powerpc/kvm/book3s_64_vio_hv.c b/arch/powerpc/kvm/book3s_64_vio_hv.c
index eda0a8f6fae8..3adfd2f5301c 100644
--- a/arch/powerpc/kvm/book3s_64_vio_hv.c
+++ b/arch/powerpc/kvm/book3s_64_vio_hv.c
@@ -301,6 +301,10 @@ long kvmppc_rm_h_put_tce(struct kvm_vcpu *vcpu, unsigned long liobn,
301 /* udbg_printf("H_PUT_TCE(): liobn=0x%lx ioba=0x%lx, tce=0x%lx\n", */ 301 /* udbg_printf("H_PUT_TCE(): liobn=0x%lx ioba=0x%lx, tce=0x%lx\n", */
302 /* liobn, ioba, tce); */ 302 /* liobn, ioba, tce); */
303 303
304 /* For radix, we might be in virtual mode, so punt */
305 if (kvm_is_radix(vcpu->kvm))
306 return H_TOO_HARD;
307
304 stt = kvmppc_find_table(vcpu->kvm, liobn); 308 stt = kvmppc_find_table(vcpu->kvm, liobn);
305 if (!stt) 309 if (!stt)
306 return H_TOO_HARD; 310 return H_TOO_HARD;
@@ -381,6 +385,10 @@ long kvmppc_rm_h_put_tce_indirect(struct kvm_vcpu *vcpu,
381 bool prereg = false; 385 bool prereg = false;
382 struct kvmppc_spapr_tce_iommu_table *stit; 386 struct kvmppc_spapr_tce_iommu_table *stit;
383 387
388 /* For radix, we might be in virtual mode, so punt */
389 if (kvm_is_radix(vcpu->kvm))
390 return H_TOO_HARD;
391
384 stt = kvmppc_find_table(vcpu->kvm, liobn); 392 stt = kvmppc_find_table(vcpu->kvm, liobn);
385 if (!stt) 393 if (!stt)
386 return H_TOO_HARD; 394 return H_TOO_HARD;
@@ -491,6 +499,10 @@ long kvmppc_rm_h_stuff_tce(struct kvm_vcpu *vcpu,
491 long i, ret; 499 long i, ret;
492 struct kvmppc_spapr_tce_iommu_table *stit; 500 struct kvmppc_spapr_tce_iommu_table *stit;
493 501
502 /* For radix, we might be in virtual mode, so punt */
503 if (kvm_is_radix(vcpu->kvm))
504 return H_TOO_HARD;
505
494 stt = kvmppc_find_table(vcpu->kvm, liobn); 506 stt = kvmppc_find_table(vcpu->kvm, liobn);
495 if (!stt) 507 if (!stt)
496 return H_TOO_HARD; 508 return H_TOO_HARD;
@@ -527,6 +539,7 @@ long kvmppc_rm_h_stuff_tce(struct kvm_vcpu *vcpu,
527 return H_SUCCESS; 539 return H_SUCCESS;
528} 540}
529 541
542/* This can be called in either virtual mode or real mode */
530long kvmppc_h_get_tce(struct kvm_vcpu *vcpu, unsigned long liobn, 543long kvmppc_h_get_tce(struct kvm_vcpu *vcpu, unsigned long liobn,
531 unsigned long ioba) 544 unsigned long ioba)
532{ 545{
diff --git a/arch/powerpc/kvm/book3s_hv_builtin.c b/arch/powerpc/kvm/book3s_hv_builtin.c
index 88a65923c649..ee4c2558c305 100644
--- a/arch/powerpc/kvm/book3s_hv_builtin.c
+++ b/arch/powerpc/kvm/book3s_hv_builtin.c
@@ -207,7 +207,14 @@ EXPORT_SYMBOL_GPL(kvmppc_hwrng_present);
207 207
208long kvmppc_h_random(struct kvm_vcpu *vcpu) 208long kvmppc_h_random(struct kvm_vcpu *vcpu)
209{ 209{
210 if (powernv_get_random_real_mode(&vcpu->arch.gpr[4])) 210 int r;
211
212 /* Only need to do the expensive mfmsr() on radix */
213 if (kvm_is_radix(vcpu->kvm) && (mfmsr() & MSR_IR))
214 r = powernv_get_random_long(&vcpu->arch.gpr[4]);
215 else
216 r = powernv_get_random_real_mode(&vcpu->arch.gpr[4]);
217 if (r)
211 return H_SUCCESS; 218 return H_SUCCESS;
212 219
213 return H_HARDWARE; 220 return H_HARDWARE;
diff --git a/arch/powerpc/kvm/book3s_pr_papr.c b/arch/powerpc/kvm/book3s_pr_papr.c
index bcbeeb62dd13..8a4205fa774f 100644
--- a/arch/powerpc/kvm/book3s_pr_papr.c
+++ b/arch/powerpc/kvm/book3s_pr_papr.c
@@ -50,7 +50,9 @@ static int kvmppc_h_pr_enter(struct kvm_vcpu *vcpu)
50 pteg_addr = get_pteg_addr(vcpu, pte_index); 50 pteg_addr = get_pteg_addr(vcpu, pte_index);
51 51
52 mutex_lock(&vcpu->kvm->arch.hpt_mutex); 52 mutex_lock(&vcpu->kvm->arch.hpt_mutex);
53 copy_from_user(pteg, (void __user *)pteg_addr, sizeof(pteg)); 53 ret = H_FUNCTION;
54 if (copy_from_user(pteg, (void __user *)pteg_addr, sizeof(pteg)))
55 goto done;
54 hpte = pteg; 56 hpte = pteg;
55 57
56 ret = H_PTEG_FULL; 58 ret = H_PTEG_FULL;
@@ -71,7 +73,9 @@ static int kvmppc_h_pr_enter(struct kvm_vcpu *vcpu)
71 hpte[0] = cpu_to_be64(kvmppc_get_gpr(vcpu, 6)); 73 hpte[0] = cpu_to_be64(kvmppc_get_gpr(vcpu, 6));
72 hpte[1] = cpu_to_be64(kvmppc_get_gpr(vcpu, 7)); 74 hpte[1] = cpu_to_be64(kvmppc_get_gpr(vcpu, 7));
73 pteg_addr += i * HPTE_SIZE; 75 pteg_addr += i * HPTE_SIZE;
74 copy_to_user((void __user *)pteg_addr, hpte, HPTE_SIZE); 76 ret = H_FUNCTION;
77 if (copy_to_user((void __user *)pteg_addr, hpte, HPTE_SIZE))
78 goto done;
75 kvmppc_set_gpr(vcpu, 4, pte_index | i); 79 kvmppc_set_gpr(vcpu, 4, pte_index | i);
76 ret = H_SUCCESS; 80 ret = H_SUCCESS;
77 81
@@ -93,7 +97,9 @@ static int kvmppc_h_pr_remove(struct kvm_vcpu *vcpu)
93 97
94 pteg = get_pteg_addr(vcpu, pte_index); 98 pteg = get_pteg_addr(vcpu, pte_index);
95 mutex_lock(&vcpu->kvm->arch.hpt_mutex); 99 mutex_lock(&vcpu->kvm->arch.hpt_mutex);
96 copy_from_user(pte, (void __user *)pteg, sizeof(pte)); 100 ret = H_FUNCTION;
101 if (copy_from_user(pte, (void __user *)pteg, sizeof(pte)))
102 goto done;
97 pte[0] = be64_to_cpu((__force __be64)pte[0]); 103 pte[0] = be64_to_cpu((__force __be64)pte[0]);
98 pte[1] = be64_to_cpu((__force __be64)pte[1]); 104 pte[1] = be64_to_cpu((__force __be64)pte[1]);
99 105
@@ -103,7 +109,9 @@ static int kvmppc_h_pr_remove(struct kvm_vcpu *vcpu)
103 ((flags & H_ANDCOND) && (pte[0] & avpn) != 0)) 109 ((flags & H_ANDCOND) && (pte[0] & avpn) != 0))
104 goto done; 110 goto done;
105 111
106 copy_to_user((void __user *)pteg, &v, sizeof(v)); 112 ret = H_FUNCTION;
113 if (copy_to_user((void __user *)pteg, &v, sizeof(v)))
114 goto done;
107 115
108 rb = compute_tlbie_rb(pte[0], pte[1], pte_index); 116 rb = compute_tlbie_rb(pte[0], pte[1], pte_index);
109 vcpu->arch.mmu.tlbie(vcpu, rb, rb & 1 ? true : false); 117 vcpu->arch.mmu.tlbie(vcpu, rb, rb & 1 ? true : false);
@@ -171,7 +179,10 @@ static int kvmppc_h_pr_bulk_remove(struct kvm_vcpu *vcpu)
171 } 179 }
172 180
173 pteg = get_pteg_addr(vcpu, tsh & H_BULK_REMOVE_PTEX); 181 pteg = get_pteg_addr(vcpu, tsh & H_BULK_REMOVE_PTEX);
174 copy_from_user(pte, (void __user *)pteg, sizeof(pte)); 182 if (copy_from_user(pte, (void __user *)pteg, sizeof(pte))) {
183 ret = H_FUNCTION;
184 break;
185 }
175 pte[0] = be64_to_cpu((__force __be64)pte[0]); 186 pte[0] = be64_to_cpu((__force __be64)pte[0]);
176 pte[1] = be64_to_cpu((__force __be64)pte[1]); 187 pte[1] = be64_to_cpu((__force __be64)pte[1]);
177 188
@@ -184,7 +195,10 @@ static int kvmppc_h_pr_bulk_remove(struct kvm_vcpu *vcpu)
184 tsh |= H_BULK_REMOVE_NOT_FOUND; 195 tsh |= H_BULK_REMOVE_NOT_FOUND;
185 } else { 196 } else {
186 /* Splat the pteg in (userland) hpt */ 197 /* Splat the pteg in (userland) hpt */
187 copy_to_user((void __user *)pteg, &v, sizeof(v)); 198 if (copy_to_user((void __user *)pteg, &v, sizeof(v))) {
199 ret = H_FUNCTION;
200 break;
201 }
188 202
189 rb = compute_tlbie_rb(pte[0], pte[1], 203 rb = compute_tlbie_rb(pte[0], pte[1],
190 tsh & H_BULK_REMOVE_PTEX); 204 tsh & H_BULK_REMOVE_PTEX);
@@ -211,7 +225,9 @@ static int kvmppc_h_pr_protect(struct kvm_vcpu *vcpu)
211 225
212 pteg = get_pteg_addr(vcpu, pte_index); 226 pteg = get_pteg_addr(vcpu, pte_index);
213 mutex_lock(&vcpu->kvm->arch.hpt_mutex); 227 mutex_lock(&vcpu->kvm->arch.hpt_mutex);
214 copy_from_user(pte, (void __user *)pteg, sizeof(pte)); 228 ret = H_FUNCTION;
229 if (copy_from_user(pte, (void __user *)pteg, sizeof(pte)))
230 goto done;
215 pte[0] = be64_to_cpu((__force __be64)pte[0]); 231 pte[0] = be64_to_cpu((__force __be64)pte[0]);
216 pte[1] = be64_to_cpu((__force __be64)pte[1]); 232 pte[1] = be64_to_cpu((__force __be64)pte[1]);
217 233
@@ -234,7 +250,9 @@ static int kvmppc_h_pr_protect(struct kvm_vcpu *vcpu)
234 vcpu->arch.mmu.tlbie(vcpu, rb, rb & 1 ? true : false); 250 vcpu->arch.mmu.tlbie(vcpu, rb, rb & 1 ? true : false);
235 pte[0] = (__force u64)cpu_to_be64(pte[0]); 251 pte[0] = (__force u64)cpu_to_be64(pte[0]);
236 pte[1] = (__force u64)cpu_to_be64(pte[1]); 252 pte[1] = (__force u64)cpu_to_be64(pte[1]);
237 copy_to_user((void __user *)pteg, pte, sizeof(pte)); 253 ret = H_FUNCTION;
254 if (copy_to_user((void __user *)pteg, pte, sizeof(pte)))
255 goto done;
238 ret = H_SUCCESS; 256 ret = H_SUCCESS;
239 257
240 done: 258 done:
@@ -244,36 +262,37 @@ static int kvmppc_h_pr_protect(struct kvm_vcpu *vcpu)
244 return EMULATE_DONE; 262 return EMULATE_DONE;
245} 263}
246 264
247static int kvmppc_h_pr_put_tce(struct kvm_vcpu *vcpu) 265static int kvmppc_h_pr_logical_ci_load(struct kvm_vcpu *vcpu)
248{ 266{
249 unsigned long liobn = kvmppc_get_gpr(vcpu, 4);
250 unsigned long ioba = kvmppc_get_gpr(vcpu, 5);
251 unsigned long tce = kvmppc_get_gpr(vcpu, 6);
252 long rc; 267 long rc;
253 268
254 rc = kvmppc_h_put_tce(vcpu, liobn, ioba, tce); 269 rc = kvmppc_h_logical_ci_load(vcpu);
255 if (rc == H_TOO_HARD) 270 if (rc == H_TOO_HARD)
256 return EMULATE_FAIL; 271 return EMULATE_FAIL;
257 kvmppc_set_gpr(vcpu, 3, rc); 272 kvmppc_set_gpr(vcpu, 3, rc);
258 return EMULATE_DONE; 273 return EMULATE_DONE;
259} 274}
260 275
261static int kvmppc_h_pr_logical_ci_load(struct kvm_vcpu *vcpu) 276static int kvmppc_h_pr_logical_ci_store(struct kvm_vcpu *vcpu)
262{ 277{
263 long rc; 278 long rc;
264 279
265 rc = kvmppc_h_logical_ci_load(vcpu); 280 rc = kvmppc_h_logical_ci_store(vcpu);
266 if (rc == H_TOO_HARD) 281 if (rc == H_TOO_HARD)
267 return EMULATE_FAIL; 282 return EMULATE_FAIL;
268 kvmppc_set_gpr(vcpu, 3, rc); 283 kvmppc_set_gpr(vcpu, 3, rc);
269 return EMULATE_DONE; 284 return EMULATE_DONE;
270} 285}
271 286
272static int kvmppc_h_pr_logical_ci_store(struct kvm_vcpu *vcpu) 287#ifdef CONFIG_SPAPR_TCE_IOMMU
288static int kvmppc_h_pr_put_tce(struct kvm_vcpu *vcpu)
273{ 289{
290 unsigned long liobn = kvmppc_get_gpr(vcpu, 4);
291 unsigned long ioba = kvmppc_get_gpr(vcpu, 5);
292 unsigned long tce = kvmppc_get_gpr(vcpu, 6);
274 long rc; 293 long rc;
275 294
276 rc = kvmppc_h_logical_ci_store(vcpu); 295 rc = kvmppc_h_put_tce(vcpu, liobn, ioba, tce);
277 if (rc == H_TOO_HARD) 296 if (rc == H_TOO_HARD)
278 return EMULATE_FAIL; 297 return EMULATE_FAIL;
279 kvmppc_set_gpr(vcpu, 3, rc); 298 kvmppc_set_gpr(vcpu, 3, rc);
@@ -311,6 +330,23 @@ static int kvmppc_h_pr_stuff_tce(struct kvm_vcpu *vcpu)
311 return EMULATE_DONE; 330 return EMULATE_DONE;
312} 331}
313 332
333#else /* CONFIG_SPAPR_TCE_IOMMU */
334static int kvmppc_h_pr_put_tce(struct kvm_vcpu *vcpu)
335{
336 return EMULATE_FAIL;
337}
338
339static int kvmppc_h_pr_put_tce_indirect(struct kvm_vcpu *vcpu)
340{
341 return EMULATE_FAIL;
342}
343
344static int kvmppc_h_pr_stuff_tce(struct kvm_vcpu *vcpu)
345{
346 return EMULATE_FAIL;
347}
348#endif /* CONFIG_SPAPR_TCE_IOMMU */
349
314static int kvmppc_h_pr_xics_hcall(struct kvm_vcpu *vcpu, u32 cmd) 350static int kvmppc_h_pr_xics_hcall(struct kvm_vcpu *vcpu, u32 cmd)
315{ 351{
316 long rc = kvmppc_xics_hcall(vcpu, cmd); 352 long rc = kvmppc_xics_hcall(vcpu, cmd);
diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
index f7cf2cd564ef..7f71ab5fcad1 100644
--- a/arch/powerpc/kvm/powerpc.c
+++ b/arch/powerpc/kvm/powerpc.c
@@ -1749,7 +1749,7 @@ long kvm_arch_vm_ioctl(struct file *filp,
1749 r = kvm_vm_ioctl_enable_cap(kvm, &cap); 1749 r = kvm_vm_ioctl_enable_cap(kvm, &cap);
1750 break; 1750 break;
1751 } 1751 }
1752#ifdef CONFIG_PPC_BOOK3S_64 1752#ifdef CONFIG_SPAPR_TCE_IOMMU
1753 case KVM_CREATE_SPAPR_TCE_64: { 1753 case KVM_CREATE_SPAPR_TCE_64: {
1754 struct kvm_create_spapr_tce_64 create_tce_64; 1754 struct kvm_create_spapr_tce_64 create_tce_64;
1755 1755
@@ -1780,6 +1780,8 @@ long kvm_arch_vm_ioctl(struct file *filp,
1780 r = kvm_vm_ioctl_create_spapr_tce(kvm, &create_tce_64); 1780 r = kvm_vm_ioctl_create_spapr_tce(kvm, &create_tce_64);
1781 goto out; 1781 goto out;
1782 } 1782 }
1783#endif
1784#ifdef CONFIG_PPC_BOOK3S_64
1783 case KVM_PPC_GET_SMMU_INFO: { 1785 case KVM_PPC_GET_SMMU_INFO: {
1784 struct kvm_ppc_smmu_info info; 1786 struct kvm_ppc_smmu_info info;
1785 struct kvm *kvm = filp->private_data; 1787 struct kvm *kvm = filp->private_data;
diff --git a/arch/powerpc/mm/dump_linuxpagetables.c b/arch/powerpc/mm/dump_linuxpagetables.c
index d659345a98d6..44fe4833910f 100644
--- a/arch/powerpc/mm/dump_linuxpagetables.c
+++ b/arch/powerpc/mm/dump_linuxpagetables.c
@@ -16,6 +16,7 @@
16 */ 16 */
17#include <linux/debugfs.h> 17#include <linux/debugfs.h>
18#include <linux/fs.h> 18#include <linux/fs.h>
19#include <linux/hugetlb.h>
19#include <linux/io.h> 20#include <linux/io.h>
20#include <linux/mm.h> 21#include <linux/mm.h>
21#include <linux/sched.h> 22#include <linux/sched.h>
@@ -391,7 +392,7 @@ static void walk_pmd(struct pg_state *st, pud_t *pud, unsigned long start)
391 392
392 for (i = 0; i < PTRS_PER_PMD; i++, pmd++) { 393 for (i = 0; i < PTRS_PER_PMD; i++, pmd++) {
393 addr = start + i * PMD_SIZE; 394 addr = start + i * PMD_SIZE;
394 if (!pmd_none(*pmd)) 395 if (!pmd_none(*pmd) && !pmd_huge(*pmd))
395 /* pmd exists */ 396 /* pmd exists */
396 walk_pte(st, pmd, addr); 397 walk_pte(st, pmd, addr);
397 else 398 else
@@ -407,7 +408,7 @@ static void walk_pud(struct pg_state *st, pgd_t *pgd, unsigned long start)
407 408
408 for (i = 0; i < PTRS_PER_PUD; i++, pud++) { 409 for (i = 0; i < PTRS_PER_PUD; i++, pud++) {
409 addr = start + i * PUD_SIZE; 410 addr = start + i * PUD_SIZE;
410 if (!pud_none(*pud)) 411 if (!pud_none(*pud) && !pud_huge(*pud))
411 /* pud exists */ 412 /* pud exists */
412 walk_pmd(st, pud, addr); 413 walk_pmd(st, pud, addr);
413 else 414 else
@@ -427,7 +428,7 @@ static void walk_pagetables(struct pg_state *st)
427 */ 428 */
428 for (i = 0; i < PTRS_PER_PGD; i++, pgd++) { 429 for (i = 0; i < PTRS_PER_PGD; i++, pgd++) {
429 addr = KERN_VIRT_START + i * PGDIR_SIZE; 430 addr = KERN_VIRT_START + i * PGDIR_SIZE;
430 if (!pgd_none(*pgd)) 431 if (!pgd_none(*pgd) && !pgd_huge(*pgd))
431 /* pgd exists */ 432 /* pgd exists */
432 walk_pud(st, pgd, addr); 433 walk_pud(st, pgd, addr);
433 else 434 else
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index 9c761fea0c98..695605eb1dfb 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -43,7 +43,7 @@
43#define KVM_PRIVATE_MEM_SLOTS 3 43#define KVM_PRIVATE_MEM_SLOTS 3
44#define KVM_MEM_SLOTS_NUM (KVM_USER_MEM_SLOTS + KVM_PRIVATE_MEM_SLOTS) 44#define KVM_MEM_SLOTS_NUM (KVM_USER_MEM_SLOTS + KVM_PRIVATE_MEM_SLOTS)
45 45
46#define KVM_HALT_POLL_NS_DEFAULT 400000 46#define KVM_HALT_POLL_NS_DEFAULT 200000
47 47
48#define KVM_IRQCHIP_NUM_PINS KVM_IOAPIC_NUM_PINS 48#define KVM_IRQCHIP_NUM_PINS KVM_IOAPIC_NUM_PINS
49 49
diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
index 68766b276d9e..a059aac9e937 100644
--- a/arch/x86/include/asm/uaccess.h
+++ b/arch/x86/include/asm/uaccess.h
@@ -319,10 +319,10 @@ do { \
319#define __get_user_asm_u64(x, ptr, retval, errret) \ 319#define __get_user_asm_u64(x, ptr, retval, errret) \
320({ \ 320({ \
321 __typeof__(ptr) __ptr = (ptr); \ 321 __typeof__(ptr) __ptr = (ptr); \
322 asm volatile(ASM_STAC "\n" \ 322 asm volatile("\n" \
323 "1: movl %2,%%eax\n" \ 323 "1: movl %2,%%eax\n" \
324 "2: movl %3,%%edx\n" \ 324 "2: movl %3,%%edx\n" \
325 "3: " ASM_CLAC "\n" \ 325 "3:\n" \
326 ".section .fixup,\"ax\"\n" \ 326 ".section .fixup,\"ax\"\n" \
327 "4: mov %4,%0\n" \ 327 "4: mov %4,%0\n" \
328 " xorl %%eax,%%eax\n" \ 328 " xorl %%eax,%%eax\n" \
@@ -331,7 +331,7 @@ do { \
331 ".previous\n" \ 331 ".previous\n" \
332 _ASM_EXTABLE(1b, 4b) \ 332 _ASM_EXTABLE(1b, 4b) \
333 _ASM_EXTABLE(2b, 4b) \ 333 _ASM_EXTABLE(2b, 4b) \
334 : "=r" (retval), "=A"(x) \ 334 : "=r" (retval), "=&A"(x) \
335 : "m" (__m(__ptr)), "m" __m(((u32 *)(__ptr)) + 1), \ 335 : "m" (__m(__ptr)), "m" __m(((u32 *)(__ptr)) + 1), \
336 "i" (errret), "0" (retval)); \ 336 "i" (errret), "0" (retval)); \
337}) 337})
@@ -703,14 +703,15 @@ extern struct movsl_mask {
703#define unsafe_put_user(x, ptr, err_label) \ 703#define unsafe_put_user(x, ptr, err_label) \
704do { \ 704do { \
705 int __pu_err; \ 705 int __pu_err; \
706 __put_user_size((x), (ptr), sizeof(*(ptr)), __pu_err, -EFAULT); \ 706 __typeof__(*(ptr)) __pu_val = (x); \
707 __put_user_size(__pu_val, (ptr), sizeof(*(ptr)), __pu_err, -EFAULT); \
707 if (unlikely(__pu_err)) goto err_label; \ 708 if (unlikely(__pu_err)) goto err_label; \
708} while (0) 709} while (0)
709 710
710#define unsafe_get_user(x, ptr, err_label) \ 711#define unsafe_get_user(x, ptr, err_label) \
711do { \ 712do { \
712 int __gu_err; \ 713 int __gu_err; \
713 unsigned long __gu_val; \ 714 __inttype(*(ptr)) __gu_val; \
714 __get_user_size(__gu_val, (ptr), sizeof(*(ptr)), __gu_err, -EFAULT); \ 715 __get_user_size(__gu_val, (ptr), sizeof(*(ptr)), __gu_err, -EFAULT); \
715 (x) = (__force __typeof__(*(ptr)))__gu_val; \ 716 (x) = (__force __typeof__(*(ptr)))__gu_val; \
716 if (unlikely(__gu_err)) goto err_label; \ 717 if (unlikely(__gu_err)) goto err_label; \
diff --git a/arch/x86/kernel/fpu/init.c b/arch/x86/kernel/fpu/init.c
index c2f8dde3255c..d5d44c452624 100644
--- a/arch/x86/kernel/fpu/init.c
+++ b/arch/x86/kernel/fpu/init.c
@@ -90,6 +90,7 @@ static void fpu__init_system_early_generic(struct cpuinfo_x86 *c)
90 * Boot time FPU feature detection code: 90 * Boot time FPU feature detection code:
91 */ 91 */
92unsigned int mxcsr_feature_mask __read_mostly = 0xffffffffu; 92unsigned int mxcsr_feature_mask __read_mostly = 0xffffffffu;
93EXPORT_SYMBOL_GPL(mxcsr_feature_mask);
93 94
94static void __init fpu__init_system_mxcsr(void) 95static void __init fpu__init_system_mxcsr(void)
95{ 96{
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index c25cfaf584e7..0816ab2e8adc 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -4173,7 +4173,7 @@ static int check_dr_write(struct x86_emulate_ctxt *ctxt)
4173 4173
4174static int check_svme(struct x86_emulate_ctxt *ctxt) 4174static int check_svme(struct x86_emulate_ctxt *ctxt)
4175{ 4175{
4176 u64 efer; 4176 u64 efer = 0;
4177 4177
4178 ctxt->ops->get_msr(ctxt, MSR_EFER, &efer); 4178 ctxt->ops->get_msr(ctxt, MSR_EFER, &efer);
4179 4179
diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
index 56241746abbd..b0454c7e4cff 100644
--- a/arch/x86/kvm/paging_tmpl.h
+++ b/arch/x86/kvm/paging_tmpl.h
@@ -283,11 +283,13 @@ static int FNAME(walk_addr_generic)(struct guest_walker *walker,
283 pt_element_t pte; 283 pt_element_t pte;
284 pt_element_t __user *uninitialized_var(ptep_user); 284 pt_element_t __user *uninitialized_var(ptep_user);
285 gfn_t table_gfn; 285 gfn_t table_gfn;
286 unsigned index, pt_access, pte_access, accessed_dirty, pte_pkey; 286 u64 pt_access, pte_access;
287 unsigned index, accessed_dirty, pte_pkey;
287 unsigned nested_access; 288 unsigned nested_access;
288 gpa_t pte_gpa; 289 gpa_t pte_gpa;
289 bool have_ad; 290 bool have_ad;
290 int offset; 291 int offset;
292 u64 walk_nx_mask = 0;
291 const int write_fault = access & PFERR_WRITE_MASK; 293 const int write_fault = access & PFERR_WRITE_MASK;
292 const int user_fault = access & PFERR_USER_MASK; 294 const int user_fault = access & PFERR_USER_MASK;
293 const int fetch_fault = access & PFERR_FETCH_MASK; 295 const int fetch_fault = access & PFERR_FETCH_MASK;
@@ -302,6 +304,7 @@ retry_walk:
302 have_ad = PT_HAVE_ACCESSED_DIRTY(mmu); 304 have_ad = PT_HAVE_ACCESSED_DIRTY(mmu);
303 305
304#if PTTYPE == 64 306#if PTTYPE == 64
307 walk_nx_mask = 1ULL << PT64_NX_SHIFT;
305 if (walker->level == PT32E_ROOT_LEVEL) { 308 if (walker->level == PT32E_ROOT_LEVEL) {
306 pte = mmu->get_pdptr(vcpu, (addr >> 30) & 3); 309 pte = mmu->get_pdptr(vcpu, (addr >> 30) & 3);
307 trace_kvm_mmu_paging_element(pte, walker->level); 310 trace_kvm_mmu_paging_element(pte, walker->level);
@@ -313,8 +316,6 @@ retry_walk:
313 walker->max_level = walker->level; 316 walker->max_level = walker->level;
314 ASSERT(!(is_long_mode(vcpu) && !is_pae(vcpu))); 317 ASSERT(!(is_long_mode(vcpu) && !is_pae(vcpu)));
315 318
316 accessed_dirty = have_ad ? PT_GUEST_ACCESSED_MASK : 0;
317
318 /* 319 /*
319 * FIXME: on Intel processors, loads of the PDPTE registers for PAE paging 320 * FIXME: on Intel processors, loads of the PDPTE registers for PAE paging
320 * by the MOV to CR instruction are treated as reads and do not cause the 321 * by the MOV to CR instruction are treated as reads and do not cause the
@@ -322,14 +323,14 @@ retry_walk:
322 */ 323 */
323 nested_access = (have_ad ? PFERR_WRITE_MASK : 0) | PFERR_USER_MASK; 324 nested_access = (have_ad ? PFERR_WRITE_MASK : 0) | PFERR_USER_MASK;
324 325
325 pt_access = pte_access = ACC_ALL; 326 pte_access = ~0;
326 ++walker->level; 327 ++walker->level;
327 328
328 do { 329 do {
329 gfn_t real_gfn; 330 gfn_t real_gfn;
330 unsigned long host_addr; 331 unsigned long host_addr;
331 332
332 pt_access &= pte_access; 333 pt_access = pte_access;
333 --walker->level; 334 --walker->level;
334 335
335 index = PT_INDEX(addr, walker->level); 336 index = PT_INDEX(addr, walker->level);
@@ -371,6 +372,12 @@ retry_walk:
371 372
372 trace_kvm_mmu_paging_element(pte, walker->level); 373 trace_kvm_mmu_paging_element(pte, walker->level);
373 374
375 /*
376 * Inverting the NX it lets us AND it like other
377 * permission bits.
378 */
379 pte_access = pt_access & (pte ^ walk_nx_mask);
380
374 if (unlikely(!FNAME(is_present_gpte)(pte))) 381 if (unlikely(!FNAME(is_present_gpte)(pte)))
375 goto error; 382 goto error;
376 383
@@ -379,14 +386,16 @@ retry_walk:
379 goto error; 386 goto error;
380 } 387 }
381 388
382 accessed_dirty &= pte;
383 pte_access = pt_access & FNAME(gpte_access)(vcpu, pte);
384
385 walker->ptes[walker->level - 1] = pte; 389 walker->ptes[walker->level - 1] = pte;
386 } while (!is_last_gpte(mmu, walker->level, pte)); 390 } while (!is_last_gpte(mmu, walker->level, pte));
387 391
388 pte_pkey = FNAME(gpte_pkeys)(vcpu, pte); 392 pte_pkey = FNAME(gpte_pkeys)(vcpu, pte);
389 errcode = permission_fault(vcpu, mmu, pte_access, pte_pkey, access); 393 accessed_dirty = have_ad ? pte_access & PT_GUEST_ACCESSED_MASK : 0;
394
395 /* Convert to ACC_*_MASK flags for struct guest_walker. */
396 walker->pt_access = FNAME(gpte_access)(vcpu, pt_access ^ walk_nx_mask);
397 walker->pte_access = FNAME(gpte_access)(vcpu, pte_access ^ walk_nx_mask);
398 errcode = permission_fault(vcpu, mmu, walker->pte_access, pte_pkey, access);
390 if (unlikely(errcode)) 399 if (unlikely(errcode))
391 goto error; 400 goto error;
392 401
@@ -403,7 +412,7 @@ retry_walk:
403 walker->gfn = real_gpa >> PAGE_SHIFT; 412 walker->gfn = real_gpa >> PAGE_SHIFT;
404 413
405 if (!write_fault) 414 if (!write_fault)
406 FNAME(protect_clean_gpte)(mmu, &pte_access, pte); 415 FNAME(protect_clean_gpte)(mmu, &walker->pte_access, pte);
407 else 416 else
408 /* 417 /*
409 * On a write fault, fold the dirty bit into accessed_dirty. 418 * On a write fault, fold the dirty bit into accessed_dirty.
@@ -421,10 +430,8 @@ retry_walk:
421 goto retry_walk; 430 goto retry_walk;
422 } 431 }
423 432
424 walker->pt_access = pt_access;
425 walker->pte_access = pte_access;
426 pgprintk("%s: pte %llx pte_access %x pt_access %x\n", 433 pgprintk("%s: pte %llx pte_access %x pt_access %x\n",
427 __func__, (u64)pte, pte_access, pt_access); 434 __func__, (u64)pte, walker->pte_access, walker->pt_access);
428 return 1; 435 return 1;
429 436
430error: 437error:
@@ -452,7 +459,7 @@ error:
452 */ 459 */
453 if (!(errcode & PFERR_RSVD_MASK)) { 460 if (!(errcode & PFERR_RSVD_MASK)) {
454 vcpu->arch.exit_qualification &= 0x187; 461 vcpu->arch.exit_qualification &= 0x187;
455 vcpu->arch.exit_qualification |= ((pt_access & pte) & 0x7) << 3; 462 vcpu->arch.exit_qualification |= (pte_access & 0x7) << 3;
456 } 463 }
457#endif 464#endif
458 walker->fault.address = addr; 465 walker->fault.address = addr;
diff --git a/arch/x86/kvm/pmu_intel.c b/arch/x86/kvm/pmu_intel.c
index 9d4a8504a95a..5ab4a364348e 100644
--- a/arch/x86/kvm/pmu_intel.c
+++ b/arch/x86/kvm/pmu_intel.c
@@ -294,7 +294,7 @@ static void intel_pmu_refresh(struct kvm_vcpu *vcpu)
294 ((u64)1 << edx.split.bit_width_fixed) - 1; 294 ((u64)1 << edx.split.bit_width_fixed) - 1;
295 } 295 }
296 296
297 pmu->global_ctrl = ((1 << pmu->nr_arch_gp_counters) - 1) | 297 pmu->global_ctrl = ((1ull << pmu->nr_arch_gp_counters) - 1) |
298 (((1ull << pmu->nr_arch_fixed_counters) - 1) << INTEL_PMC_IDX_FIXED); 298 (((1ull << pmu->nr_arch_fixed_counters) - 1) << INTEL_PMC_IDX_FIXED);
299 pmu->global_ctrl_mask = ~pmu->global_ctrl; 299 pmu->global_ctrl_mask = ~pmu->global_ctrl;
300 300
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index c27ac6923a18..183ddb235fb4 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -1272,7 +1272,8 @@ static void init_vmcb(struct vcpu_svm *svm)
1272 1272
1273} 1273}
1274 1274
1275static u64 *avic_get_physical_id_entry(struct kvm_vcpu *vcpu, int index) 1275static u64 *avic_get_physical_id_entry(struct kvm_vcpu *vcpu,
1276 unsigned int index)
1276{ 1277{
1277 u64 *avic_physical_id_table; 1278 u64 *avic_physical_id_table;
1278 struct kvm_arch *vm_data = &vcpu->kvm->arch; 1279 struct kvm_arch *vm_data = &vcpu->kvm->arch;
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index c6f4ad44aa95..72f78396bc09 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -6504,7 +6504,7 @@ static __init int hardware_setup(void)
6504 enable_ept_ad_bits = 0; 6504 enable_ept_ad_bits = 0;
6505 } 6505 }
6506 6506
6507 if (!cpu_has_vmx_ept_ad_bits()) 6507 if (!cpu_has_vmx_ept_ad_bits() || !enable_ept)
6508 enable_ept_ad_bits = 0; 6508 enable_ept_ad_bits = 0;
6509 6509
6510 if (!cpu_has_vmx_unrestricted_guest()) 6510 if (!cpu_has_vmx_unrestricted_guest())
@@ -11213,7 +11213,7 @@ static int vmx_write_pml_buffer(struct kvm_vcpu *vcpu)
11213 if (!nested_cpu_has_pml(vmcs12)) 11213 if (!nested_cpu_has_pml(vmcs12))
11214 return 0; 11214 return 0;
11215 11215
11216 if (vmcs12->guest_pml_index > PML_ENTITY_NUM) { 11216 if (vmcs12->guest_pml_index >= PML_ENTITY_NUM) {
11217 vmx->nested.pml_full = true; 11217 vmx->nested.pml_full = true;
11218 return 1; 11218 return 1;
11219 } 11219 }
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 464da936c53d..02363e37d4a6 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -1763,6 +1763,7 @@ u64 get_kvmclock_ns(struct kvm *kvm)
1763{ 1763{
1764 struct kvm_arch *ka = &kvm->arch; 1764 struct kvm_arch *ka = &kvm->arch;
1765 struct pvclock_vcpu_time_info hv_clock; 1765 struct pvclock_vcpu_time_info hv_clock;
1766 u64 ret;
1766 1767
1767 spin_lock(&ka->pvclock_gtod_sync_lock); 1768 spin_lock(&ka->pvclock_gtod_sync_lock);
1768 if (!ka->use_master_clock) { 1769 if (!ka->use_master_clock) {
@@ -1774,10 +1775,17 @@ u64 get_kvmclock_ns(struct kvm *kvm)
1774 hv_clock.system_time = ka->master_kernel_ns + ka->kvmclock_offset; 1775 hv_clock.system_time = ka->master_kernel_ns + ka->kvmclock_offset;
1775 spin_unlock(&ka->pvclock_gtod_sync_lock); 1776 spin_unlock(&ka->pvclock_gtod_sync_lock);
1776 1777
1778 /* both __this_cpu_read() and rdtsc() should be on the same cpu */
1779 get_cpu();
1780
1777 kvm_get_time_scale(NSEC_PER_SEC, __this_cpu_read(cpu_tsc_khz) * 1000LL, 1781 kvm_get_time_scale(NSEC_PER_SEC, __this_cpu_read(cpu_tsc_khz) * 1000LL,
1778 &hv_clock.tsc_shift, 1782 &hv_clock.tsc_shift,
1779 &hv_clock.tsc_to_system_mul); 1783 &hv_clock.tsc_to_system_mul);
1780 return __pvclock_read_cycles(&hv_clock, rdtsc()); 1784 ret = __pvclock_read_cycles(&hv_clock, rdtsc());
1785
1786 put_cpu();
1787
1788 return ret;
1781} 1789}
1782 1790
1783static void kvm_setup_pvclock_page(struct kvm_vcpu *v) 1791static void kvm_setup_pvclock_page(struct kvm_vcpu *v)
@@ -3288,11 +3296,14 @@ static void kvm_vcpu_ioctl_x86_get_xsave(struct kvm_vcpu *vcpu,
3288 } 3296 }
3289} 3297}
3290 3298
3299#define XSAVE_MXCSR_OFFSET 24
3300
3291static int kvm_vcpu_ioctl_x86_set_xsave(struct kvm_vcpu *vcpu, 3301static int kvm_vcpu_ioctl_x86_set_xsave(struct kvm_vcpu *vcpu,
3292 struct kvm_xsave *guest_xsave) 3302 struct kvm_xsave *guest_xsave)
3293{ 3303{
3294 u64 xstate_bv = 3304 u64 xstate_bv =
3295 *(u64 *)&guest_xsave->region[XSAVE_HDR_OFFSET / sizeof(u32)]; 3305 *(u64 *)&guest_xsave->region[XSAVE_HDR_OFFSET / sizeof(u32)];
3306 u32 mxcsr = *(u32 *)&guest_xsave->region[XSAVE_MXCSR_OFFSET / sizeof(u32)];
3296 3307
3297 if (boot_cpu_has(X86_FEATURE_XSAVE)) { 3308 if (boot_cpu_has(X86_FEATURE_XSAVE)) {
3298 /* 3309 /*
@@ -3300,11 +3311,13 @@ static int kvm_vcpu_ioctl_x86_set_xsave(struct kvm_vcpu *vcpu,
3300 * CPUID leaf 0xD, index 0, EDX:EAX. This is for compatibility 3311 * CPUID leaf 0xD, index 0, EDX:EAX. This is for compatibility
3301 * with old userspace. 3312 * with old userspace.
3302 */ 3313 */
3303 if (xstate_bv & ~kvm_supported_xcr0()) 3314 if (xstate_bv & ~kvm_supported_xcr0() ||
3315 mxcsr & ~mxcsr_feature_mask)
3304 return -EINVAL; 3316 return -EINVAL;
3305 load_xsave(vcpu, (u8 *)guest_xsave->region); 3317 load_xsave(vcpu, (u8 *)guest_xsave->region);
3306 } else { 3318 } else {
3307 if (xstate_bv & ~XFEATURE_MASK_FPSSE) 3319 if (xstate_bv & ~XFEATURE_MASK_FPSSE ||
3320 mxcsr & ~mxcsr_feature_mask)
3308 return -EINVAL; 3321 return -EINVAL;
3309 memcpy(&vcpu->arch.guest_fpu.state.fxsave, 3322 memcpy(&vcpu->arch.guest_fpu.state.fxsave,
3310 guest_xsave->region, sizeof(struct fxregs_state)); 3323 guest_xsave->region, sizeof(struct fxregs_state));
@@ -4818,16 +4831,20 @@ emul_write:
4818 4831
4819static int kernel_pio(struct kvm_vcpu *vcpu, void *pd) 4832static int kernel_pio(struct kvm_vcpu *vcpu, void *pd)
4820{ 4833{
4821 /* TODO: String I/O for in kernel device */ 4834 int r = 0, i;
4822 int r;
4823 4835
4824 if (vcpu->arch.pio.in) 4836 for (i = 0; i < vcpu->arch.pio.count; i++) {
4825 r = kvm_io_bus_read(vcpu, KVM_PIO_BUS, vcpu->arch.pio.port, 4837 if (vcpu->arch.pio.in)
4826 vcpu->arch.pio.size, pd); 4838 r = kvm_io_bus_read(vcpu, KVM_PIO_BUS, vcpu->arch.pio.port,
4827 else 4839 vcpu->arch.pio.size, pd);
4828 r = kvm_io_bus_write(vcpu, KVM_PIO_BUS, 4840 else
4829 vcpu->arch.pio.port, vcpu->arch.pio.size, 4841 r = kvm_io_bus_write(vcpu, KVM_PIO_BUS,
4830 pd); 4842 vcpu->arch.pio.port, vcpu->arch.pio.size,
4843 pd);
4844 if (r)
4845 break;
4846 pd += vcpu->arch.pio.size;
4847 }
4831 return r; 4848 return r;
4832} 4849}
4833 4850
@@ -4865,6 +4882,8 @@ static int emulator_pio_in_emulated(struct x86_emulate_ctxt *ctxt,
4865 if (vcpu->arch.pio.count) 4882 if (vcpu->arch.pio.count)
4866 goto data_avail; 4883 goto data_avail;
4867 4884
4885 memset(vcpu->arch.pio_data, 0, size * count);
4886
4868 ret = emulator_pio_in_out(vcpu, size, port, val, count, true); 4887 ret = emulator_pio_in_out(vcpu, size, port, val, count, true);
4869 if (ret) { 4888 if (ret) {
4870data_avail: 4889data_avail:
@@ -5048,6 +5067,8 @@ static bool emulator_get_segment(struct x86_emulate_ctxt *ctxt, u16 *selector,
5048 5067
5049 if (var.unusable) { 5068 if (var.unusable) {
5050 memset(desc, 0, sizeof(*desc)); 5069 memset(desc, 0, sizeof(*desc));
5070 if (base3)
5071 *base3 = 0;
5051 return false; 5072 return false;
5052 } 5073 }
5053 5074
diff --git a/arch/x86/xen/enlighten_pv.c b/arch/x86/xen/enlighten_pv.c
index 7cd442690f9d..f33eef4ebd12 100644
--- a/arch/x86/xen/enlighten_pv.c
+++ b/arch/x86/xen/enlighten_pv.c
@@ -142,9 +142,7 @@ static void __init xen_banner(void)
142 struct xen_extraversion extra; 142 struct xen_extraversion extra;
143 HYPERVISOR_xen_version(XENVER_extraversion, &extra); 143 HYPERVISOR_xen_version(XENVER_extraversion, &extra);
144 144
145 pr_info("Booting paravirtualized kernel %son %s\n", 145 pr_info("Booting paravirtualized kernel on %s\n", pv_info.name);
146 xen_feature(XENFEAT_auto_translated_physmap) ?
147 "with PVH extensions " : "", pv_info.name);
148 printk(KERN_INFO "Xen version: %d.%d%s%s\n", 146 printk(KERN_INFO "Xen version: %d.%d%s%s\n",
149 version >> 16, version & 0xffff, extra.extraversion, 147 version >> 16, version & 0xffff, extra.extraversion,
150 xen_feature(XENFEAT_mmu_pt_update_preserve_ad) ? " (preserve-AD)" : ""); 148 xen_feature(XENFEAT_mmu_pt_update_preserve_ad) ? " (preserve-AD)" : "");
@@ -957,15 +955,10 @@ static void xen_write_msr(unsigned int msr, unsigned low, unsigned high)
957 955
958void xen_setup_shared_info(void) 956void xen_setup_shared_info(void)
959{ 957{
960 if (!xen_feature(XENFEAT_auto_translated_physmap)) { 958 set_fixmap(FIX_PARAVIRT_BOOTMAP, xen_start_info->shared_info);
961 set_fixmap(FIX_PARAVIRT_BOOTMAP,
962 xen_start_info->shared_info);
963 959
964 HYPERVISOR_shared_info = 960 HYPERVISOR_shared_info =
965 (struct shared_info *)fix_to_virt(FIX_PARAVIRT_BOOTMAP); 961 (struct shared_info *)fix_to_virt(FIX_PARAVIRT_BOOTMAP);
966 } else
967 HYPERVISOR_shared_info =
968 (struct shared_info *)__va(xen_start_info->shared_info);
969 962
970#ifndef CONFIG_SMP 963#ifndef CONFIG_SMP
971 /* In UP this is as good a place as any to set up shared info */ 964 /* In UP this is as good a place as any to set up shared info */
diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
index 5e375a5e815f..3be06f3caf3c 100644
--- a/arch/x86/xen/mmu.c
+++ b/arch/x86/xen/mmu.c
@@ -42,7 +42,7 @@ xmaddr_t arbitrary_virt_to_machine(void *vaddr)
42} 42}
43EXPORT_SYMBOL_GPL(arbitrary_virt_to_machine); 43EXPORT_SYMBOL_GPL(arbitrary_virt_to_machine);
44 44
45void xen_flush_tlb_all(void) 45static void xen_flush_tlb_all(void)
46{ 46{
47 struct mmuext_op *op; 47 struct mmuext_op *op;
48 struct multicall_space mcs; 48 struct multicall_space mcs;
diff --git a/arch/x86/xen/mmu_pv.c b/arch/x86/xen/mmu_pv.c
index 7397d8b8459d..1f386d7fdf70 100644
--- a/arch/x86/xen/mmu_pv.c
+++ b/arch/x86/xen/mmu_pv.c
@@ -355,10 +355,8 @@ static pteval_t pte_pfn_to_mfn(pteval_t val)
355 pteval_t flags = val & PTE_FLAGS_MASK; 355 pteval_t flags = val & PTE_FLAGS_MASK;
356 unsigned long mfn; 356 unsigned long mfn;
357 357
358 if (!xen_feature(XENFEAT_auto_translated_physmap)) 358 mfn = __pfn_to_mfn(pfn);
359 mfn = __pfn_to_mfn(pfn); 359
360 else
361 mfn = pfn;
362 /* 360 /*
363 * If there's no mfn for the pfn, then just create an 361 * If there's no mfn for the pfn, then just create an
364 * empty non-present pte. Unfortunately this loses 362 * empty non-present pte. Unfortunately this loses
@@ -647,9 +645,6 @@ static int __xen_pgd_walk(struct mm_struct *mm, pgd_t *pgd,
647 limit--; 645 limit--;
648 BUG_ON(limit >= FIXADDR_TOP); 646 BUG_ON(limit >= FIXADDR_TOP);
649 647
650 if (xen_feature(XENFEAT_auto_translated_physmap))
651 return 0;
652
653 /* 648 /*
654 * 64-bit has a great big hole in the middle of the address 649 * 64-bit has a great big hole in the middle of the address
655 * space, which contains the Xen mappings. On 32-bit these 650 * space, which contains the Xen mappings. On 32-bit these
@@ -1289,9 +1284,6 @@ static void __init xen_pagetable_cleanhighmap(void)
1289 1284
1290static void __init xen_pagetable_p2m_setup(void) 1285static void __init xen_pagetable_p2m_setup(void)
1291{ 1286{
1292 if (xen_feature(XENFEAT_auto_translated_physmap))
1293 return;
1294
1295 xen_vmalloc_p2m_tree(); 1287 xen_vmalloc_p2m_tree();
1296 1288
1297#ifdef CONFIG_X86_64 1289#ifdef CONFIG_X86_64
@@ -1314,8 +1306,7 @@ static void __init xen_pagetable_init(void)
1314 xen_build_mfn_list_list(); 1306 xen_build_mfn_list_list();
1315 1307
1316 /* Remap memory freed due to conflicts with E820 map */ 1308 /* Remap memory freed due to conflicts with E820 map */
1317 if (!xen_feature(XENFEAT_auto_translated_physmap)) 1309 xen_remap_memory();
1318 xen_remap_memory();
1319 1310
1320 xen_setup_shared_info(); 1311 xen_setup_shared_info();
1321} 1312}
@@ -1925,21 +1916,20 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
1925 /* Zap identity mapping */ 1916 /* Zap identity mapping */
1926 init_level4_pgt[0] = __pgd(0); 1917 init_level4_pgt[0] = __pgd(0);
1927 1918
1928 if (!xen_feature(XENFEAT_auto_translated_physmap)) { 1919 /* Pre-constructed entries are in pfn, so convert to mfn */
1929 /* Pre-constructed entries are in pfn, so convert to mfn */ 1920 /* L4[272] -> level3_ident_pgt */
1930 /* L4[272] -> level3_ident_pgt 1921 /* L4[511] -> level3_kernel_pgt */
1931 * L4[511] -> level3_kernel_pgt */ 1922 convert_pfn_mfn(init_level4_pgt);
1932 convert_pfn_mfn(init_level4_pgt);
1933 1923
1934 /* L3_i[0] -> level2_ident_pgt */ 1924 /* L3_i[0] -> level2_ident_pgt */
1935 convert_pfn_mfn(level3_ident_pgt); 1925 convert_pfn_mfn(level3_ident_pgt);
1936 /* L3_k[510] -> level2_kernel_pgt 1926 /* L3_k[510] -> level2_kernel_pgt */
1937 * L3_k[511] -> level2_fixmap_pgt */ 1927 /* L3_k[511] -> level2_fixmap_pgt */
1938 convert_pfn_mfn(level3_kernel_pgt); 1928 convert_pfn_mfn(level3_kernel_pgt);
1929
1930 /* L3_k[511][506] -> level1_fixmap_pgt */
1931 convert_pfn_mfn(level2_fixmap_pgt);
1939 1932
1940 /* L3_k[511][506] -> level1_fixmap_pgt */
1941 convert_pfn_mfn(level2_fixmap_pgt);
1942 }
1943 /* We get [511][511] and have Xen's version of level2_kernel_pgt */ 1933 /* We get [511][511] and have Xen's version of level2_kernel_pgt */
1944 l3 = m2v(pgd[pgd_index(__START_KERNEL_map)].pgd); 1934 l3 = m2v(pgd[pgd_index(__START_KERNEL_map)].pgd);
1945 l2 = m2v(l3[pud_index(__START_KERNEL_map)].pud); 1935 l2 = m2v(l3[pud_index(__START_KERNEL_map)].pud);
@@ -1962,34 +1952,30 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
1962 if (i && i < pgd_index(__START_KERNEL_map)) 1952 if (i && i < pgd_index(__START_KERNEL_map))
1963 init_level4_pgt[i] = ((pgd_t *)xen_start_info->pt_base)[i]; 1953 init_level4_pgt[i] = ((pgd_t *)xen_start_info->pt_base)[i];
1964 1954
1965 if (!xen_feature(XENFEAT_auto_translated_physmap)) { 1955 /* Make pagetable pieces RO */
1966 /* Make pagetable pieces RO */ 1956 set_page_prot(init_level4_pgt, PAGE_KERNEL_RO);
1967 set_page_prot(init_level4_pgt, PAGE_KERNEL_RO); 1957 set_page_prot(level3_ident_pgt, PAGE_KERNEL_RO);
1968 set_page_prot(level3_ident_pgt, PAGE_KERNEL_RO); 1958 set_page_prot(level3_kernel_pgt, PAGE_KERNEL_RO);
1969 set_page_prot(level3_kernel_pgt, PAGE_KERNEL_RO); 1959 set_page_prot(level3_user_vsyscall, PAGE_KERNEL_RO);
1970 set_page_prot(level3_user_vsyscall, PAGE_KERNEL_RO); 1960 set_page_prot(level2_ident_pgt, PAGE_KERNEL_RO);
1971 set_page_prot(level2_ident_pgt, PAGE_KERNEL_RO); 1961 set_page_prot(level2_kernel_pgt, PAGE_KERNEL_RO);
1972 set_page_prot(level2_kernel_pgt, PAGE_KERNEL_RO); 1962 set_page_prot(level2_fixmap_pgt, PAGE_KERNEL_RO);
1973 set_page_prot(level2_fixmap_pgt, PAGE_KERNEL_RO); 1963 set_page_prot(level1_fixmap_pgt, PAGE_KERNEL_RO);
1974 set_page_prot(level1_fixmap_pgt, PAGE_KERNEL_RO); 1964
1975 1965 /* Pin down new L4 */
1976 /* Pin down new L4 */ 1966 pin_pagetable_pfn(MMUEXT_PIN_L4_TABLE,
1977 pin_pagetable_pfn(MMUEXT_PIN_L4_TABLE, 1967 PFN_DOWN(__pa_symbol(init_level4_pgt)));
1978 PFN_DOWN(__pa_symbol(init_level4_pgt))); 1968
1979 1969 /* Unpin Xen-provided one */
1980 /* Unpin Xen-provided one */ 1970 pin_pagetable_pfn(MMUEXT_UNPIN_TABLE, PFN_DOWN(__pa(pgd)));
1981 pin_pagetable_pfn(MMUEXT_UNPIN_TABLE, PFN_DOWN(__pa(pgd)));
1982 1971
1983 /* 1972 /*
1984 * At this stage there can be no user pgd, and no page 1973 * At this stage there can be no user pgd, and no page structure to
1985 * structure to attach it to, so make sure we just set kernel 1974 * attach it to, so make sure we just set kernel pgd.
1986 * pgd. 1975 */
1987 */ 1976 xen_mc_batch();
1988 xen_mc_batch(); 1977 __xen_write_cr3(true, __pa(init_level4_pgt));
1989 __xen_write_cr3(true, __pa(init_level4_pgt)); 1978 xen_mc_issue(PARAVIRT_LAZY_CPU);
1990 xen_mc_issue(PARAVIRT_LAZY_CPU);
1991 } else
1992 native_write_cr3(__pa(init_level4_pgt));
1993 1979
1994 /* We can't that easily rip out L3 and L2, as the Xen pagetables are 1980 /* We can't that easily rip out L3 and L2, as the Xen pagetables are
1995 * set out this way: [L4], [L1], [L2], [L3], [L1], [L1] ... for 1981 * set out this way: [L4], [L1], [L2], [L3], [L1], [L1] ... for
@@ -2403,9 +2389,6 @@ static void xen_set_fixmap(unsigned idx, phys_addr_t phys, pgprot_t prot)
2403 2389
2404static void __init xen_post_allocator_init(void) 2390static void __init xen_post_allocator_init(void)
2405{ 2391{
2406 if (xen_feature(XENFEAT_auto_translated_physmap))
2407 return;
2408
2409 pv_mmu_ops.set_pte = xen_set_pte; 2392 pv_mmu_ops.set_pte = xen_set_pte;
2410 pv_mmu_ops.set_pmd = xen_set_pmd; 2393 pv_mmu_ops.set_pmd = xen_set_pmd;
2411 pv_mmu_ops.set_pud = xen_set_pud; 2394 pv_mmu_ops.set_pud = xen_set_pud;
@@ -2511,9 +2494,6 @@ void __init xen_init_mmu_ops(void)
2511{ 2494{
2512 x86_init.paging.pagetable_init = xen_pagetable_init; 2495 x86_init.paging.pagetable_init = xen_pagetable_init;
2513 2496
2514 if (xen_feature(XENFEAT_auto_translated_physmap))
2515 return;
2516
2517 pv_mmu_ops = xen_mmu_ops; 2497 pv_mmu_ops = xen_mmu_ops;
2518 2498
2519 memset(dummy_mapping, 0xff, PAGE_SIZE); 2499 memset(dummy_mapping, 0xff, PAGE_SIZE);
@@ -2650,9 +2630,6 @@ int xen_create_contiguous_region(phys_addr_t pstart, unsigned int order,
2650 * this function are redundant and can be ignored. 2630 * this function are redundant and can be ignored.
2651 */ 2631 */
2652 2632
2653 if (xen_feature(XENFEAT_auto_translated_physmap))
2654 return 0;
2655
2656 if (unlikely(order > MAX_CONTIG_ORDER)) 2633 if (unlikely(order > MAX_CONTIG_ORDER))
2657 return -ENOMEM; 2634 return -ENOMEM;
2658 2635
@@ -2689,9 +2666,6 @@ void xen_destroy_contiguous_region(phys_addr_t pstart, unsigned int order)
2689 int success; 2666 int success;
2690 unsigned long vstart; 2667 unsigned long vstart;
2691 2668
2692 if (xen_feature(XENFEAT_auto_translated_physmap))
2693 return;
2694
2695 if (unlikely(order > MAX_CONTIG_ORDER)) 2669 if (unlikely(order > MAX_CONTIG_ORDER))
2696 return; 2670 return;
2697 2671
diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c
index b7c2a06963d6..25aba9b107dd 100644
--- a/drivers/acpi/button.c
+++ b/drivers/acpi/button.c
@@ -57,6 +57,7 @@
57 57
58#define ACPI_BUTTON_LID_INIT_IGNORE 0x00 58#define ACPI_BUTTON_LID_INIT_IGNORE 0x00
59#define ACPI_BUTTON_LID_INIT_OPEN 0x01 59#define ACPI_BUTTON_LID_INIT_OPEN 0x01
60#define ACPI_BUTTON_LID_INIT_METHOD 0x02
60 61
61#define _COMPONENT ACPI_BUTTON_COMPONENT 62#define _COMPONENT ACPI_BUTTON_COMPONENT
62ACPI_MODULE_NAME("button"); 63ACPI_MODULE_NAME("button");
@@ -376,6 +377,9 @@ static void acpi_lid_initialize_state(struct acpi_device *device)
376 case ACPI_BUTTON_LID_INIT_OPEN: 377 case ACPI_BUTTON_LID_INIT_OPEN:
377 (void)acpi_lid_notify_state(device, 1); 378 (void)acpi_lid_notify_state(device, 1);
378 break; 379 break;
380 case ACPI_BUTTON_LID_INIT_METHOD:
381 (void)acpi_lid_update_state(device);
382 break;
379 case ACPI_BUTTON_LID_INIT_IGNORE: 383 case ACPI_BUTTON_LID_INIT_IGNORE:
380 default: 384 default:
381 break; 385 break;
@@ -560,6 +564,9 @@ static int param_set_lid_init_state(const char *val, struct kernel_param *kp)
560 if (!strncmp(val, "open", sizeof("open") - 1)) { 564 if (!strncmp(val, "open", sizeof("open") - 1)) {
561 lid_init_state = ACPI_BUTTON_LID_INIT_OPEN; 565 lid_init_state = ACPI_BUTTON_LID_INIT_OPEN;
562 pr_info("Notify initial lid state as open\n"); 566 pr_info("Notify initial lid state as open\n");
567 } else if (!strncmp(val, "method", sizeof("method") - 1)) {
568 lid_init_state = ACPI_BUTTON_LID_INIT_METHOD;
569 pr_info("Notify initial lid state with _LID return value\n");
563 } else if (!strncmp(val, "ignore", sizeof("ignore") - 1)) { 570 } else if (!strncmp(val, "ignore", sizeof("ignore") - 1)) {
564 lid_init_state = ACPI_BUTTON_LID_INIT_IGNORE; 571 lid_init_state = ACPI_BUTTON_LID_INIT_IGNORE;
565 pr_info("Do not notify initial lid state\n"); 572 pr_info("Do not notify initial lid state\n");
@@ -573,6 +580,8 @@ static int param_get_lid_init_state(char *buffer, struct kernel_param *kp)
573 switch (lid_init_state) { 580 switch (lid_init_state) {
574 case ACPI_BUTTON_LID_INIT_OPEN: 581 case ACPI_BUTTON_LID_INIT_OPEN:
575 return sprintf(buffer, "open"); 582 return sprintf(buffer, "open");
583 case ACPI_BUTTON_LID_INIT_METHOD:
584 return sprintf(buffer, "method");
576 case ACPI_BUTTON_LID_INIT_IGNORE: 585 case ACPI_BUTTON_LID_INIT_IGNORE:
577 return sprintf(buffer, "ignore"); 586 return sprintf(buffer, "ignore");
578 default: 587 default:
diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
index f62082fdd670..9c36b27996fc 100644
--- a/drivers/base/power/wakeup.c
+++ b/drivers/base/power/wakeup.c
@@ -512,13 +512,12 @@ static bool wakeup_source_not_registered(struct wakeup_source *ws)
512/** 512/**
513 * wakup_source_activate - Mark given wakeup source as active. 513 * wakup_source_activate - Mark given wakeup source as active.
514 * @ws: Wakeup source to handle. 514 * @ws: Wakeup source to handle.
515 * @hard: If set, abort suspends in progress and wake up from suspend-to-idle.
516 * 515 *
517 * Update the @ws' statistics and, if @ws has just been activated, notify the PM 516 * Update the @ws' statistics and, if @ws has just been activated, notify the PM
518 * core of the event by incrementing the counter of of wakeup events being 517 * core of the event by incrementing the counter of of wakeup events being
519 * processed. 518 * processed.
520 */ 519 */
521static void wakeup_source_activate(struct wakeup_source *ws, bool hard) 520static void wakeup_source_activate(struct wakeup_source *ws)
522{ 521{
523 unsigned int cec; 522 unsigned int cec;
524 523
@@ -526,9 +525,6 @@ static void wakeup_source_activate(struct wakeup_source *ws, bool hard)
526 "unregistered wakeup source\n")) 525 "unregistered wakeup source\n"))
527 return; 526 return;
528 527
529 if (hard)
530 pm_system_wakeup();
531
532 ws->active = true; 528 ws->active = true;
533 ws->active_count++; 529 ws->active_count++;
534 ws->last_time = ktime_get(); 530 ws->last_time = ktime_get();
@@ -554,7 +550,10 @@ static void wakeup_source_report_event(struct wakeup_source *ws, bool hard)
554 ws->wakeup_count++; 550 ws->wakeup_count++;
555 551
556 if (!ws->active) 552 if (!ws->active)
557 wakeup_source_activate(ws, hard); 553 wakeup_source_activate(ws);
554
555 if (hard)
556 pm_system_wakeup();
558} 557}
559 558
560/** 559/**
diff --git a/drivers/block/drbd/drbd_req.c b/drivers/block/drbd/drbd_req.c
index b5730e17b455..656624314f0d 100644
--- a/drivers/block/drbd/drbd_req.c
+++ b/drivers/block/drbd/drbd_req.c
@@ -315,24 +315,32 @@ void drbd_req_complete(struct drbd_request *req, struct bio_and_error *m)
315} 315}
316 316
317/* still holds resource->req_lock */ 317/* still holds resource->req_lock */
318static int drbd_req_put_completion_ref(struct drbd_request *req, struct bio_and_error *m, int put) 318static void drbd_req_put_completion_ref(struct drbd_request *req, struct bio_and_error *m, int put)
319{ 319{
320 struct drbd_device *device = req->device; 320 struct drbd_device *device = req->device;
321 D_ASSERT(device, m || (req->rq_state & RQ_POSTPONED)); 321 D_ASSERT(device, m || (req->rq_state & RQ_POSTPONED));
322 322
323 if (!put)
324 return;
325
323 if (!atomic_sub_and_test(put, &req->completion_ref)) 326 if (!atomic_sub_and_test(put, &req->completion_ref))
324 return 0; 327 return;
325 328
326 drbd_req_complete(req, m); 329 drbd_req_complete(req, m);
327 330
331 /* local completion may still come in later,
332 * we need to keep the req object around. */
333 if (req->rq_state & RQ_LOCAL_ABORTED)
334 return;
335
328 if (req->rq_state & RQ_POSTPONED) { 336 if (req->rq_state & RQ_POSTPONED) {
329 /* don't destroy the req object just yet, 337 /* don't destroy the req object just yet,
330 * but queue it for retry */ 338 * but queue it for retry */
331 drbd_restart_request(req); 339 drbd_restart_request(req);
332 return 0; 340 return;
333 } 341 }
334 342
335 return 1; 343 kref_put(&req->kref, drbd_req_destroy);
336} 344}
337 345
338static void set_if_null_req_next(struct drbd_peer_device *peer_device, struct drbd_request *req) 346static void set_if_null_req_next(struct drbd_peer_device *peer_device, struct drbd_request *req)
@@ -519,12 +527,8 @@ static void mod_rq_state(struct drbd_request *req, struct bio_and_error *m,
519 if (req->i.waiting) 527 if (req->i.waiting)
520 wake_up(&device->misc_wait); 528 wake_up(&device->misc_wait);
521 529
522 if (c_put) { 530 drbd_req_put_completion_ref(req, m, c_put);
523 if (drbd_req_put_completion_ref(req, m, c_put)) 531 kref_put(&req->kref, drbd_req_destroy);
524 kref_put(&req->kref, drbd_req_destroy);
525 } else {
526 kref_put(&req->kref, drbd_req_destroy);
527 }
528} 532}
529 533
530static void drbd_report_io_error(struct drbd_device *device, struct drbd_request *req) 534static void drbd_report_io_error(struct drbd_device *device, struct drbd_request *req)
@@ -1366,8 +1370,7 @@ nodata:
1366 } 1370 }
1367 1371
1368out: 1372out:
1369 if (drbd_req_put_completion_ref(req, &m, 1)) 1373 drbd_req_put_completion_ref(req, &m, 1);
1370 kref_put(&req->kref, drbd_req_destroy);
1371 spin_unlock_irq(&resource->req_lock); 1374 spin_unlock_irq(&resource->req_lock);
1372 1375
1373 /* Even though above is a kref_put(), this is safe. 1376 /* Even though above is a kref_put(), this is safe.
diff --git a/drivers/block/xen-blkback/xenbus.c b/drivers/block/xen-blkback/xenbus.c
index 8fe61b5dc5a6..1f3dfaa54d87 100644
--- a/drivers/block/xen-blkback/xenbus.c
+++ b/drivers/block/xen-blkback/xenbus.c
@@ -504,11 +504,13 @@ static int xen_blkbk_remove(struct xenbus_device *dev)
504 504
505 dev_set_drvdata(&dev->dev, NULL); 505 dev_set_drvdata(&dev->dev, NULL);
506 506
507 if (be->blkif) 507 if (be->blkif) {
508 xen_blkif_disconnect(be->blkif); 508 xen_blkif_disconnect(be->blkif);
509 509
510 /* Put the reference we set in xen_blkif_alloc(). */ 510 /* Put the reference we set in xen_blkif_alloc(). */
511 xen_blkif_put(be->blkif); 511 xen_blkif_put(be->blkif);
512 }
513
512 kfree(be->mode); 514 kfree(be->mode);
513 kfree(be); 515 kfree(be);
514 return 0; 516 return 0;
diff --git a/drivers/char/lp.c b/drivers/char/lp.c
index 565e4cf04a02..8249762192d5 100644
--- a/drivers/char/lp.c
+++ b/drivers/char/lp.c
@@ -859,7 +859,11 @@ static int __init lp_setup (char *str)
859 } else if (!strcmp(str, "auto")) { 859 } else if (!strcmp(str, "auto")) {
860 parport_nr[0] = LP_PARPORT_AUTO; 860 parport_nr[0] = LP_PARPORT_AUTO;
861 } else if (!strcmp(str, "none")) { 861 } else if (!strcmp(str, "none")) {
862 parport_nr[parport_ptr++] = LP_PARPORT_NONE; 862 if (parport_ptr < LP_NO)
863 parport_nr[parport_ptr++] = LP_PARPORT_NONE;
864 else
865 printk(KERN_INFO "lp: too many ports, %s ignored.\n",
866 str);
863 } else if (!strcmp(str, "reset")) { 867 } else if (!strcmp(str, "reset")) {
864 reset = 1; 868 reset = 1;
865 } 869 }
diff --git a/drivers/char/mem.c b/drivers/char/mem.c
index 7e4a9d1296bb..6e0cbe092220 100644
--- a/drivers/char/mem.c
+++ b/drivers/char/mem.c
@@ -340,6 +340,11 @@ static const struct vm_operations_struct mmap_mem_ops = {
340static int mmap_mem(struct file *file, struct vm_area_struct *vma) 340static int mmap_mem(struct file *file, struct vm_area_struct *vma)
341{ 341{
342 size_t size = vma->vm_end - vma->vm_start; 342 size_t size = vma->vm_end - vma->vm_start;
343 phys_addr_t offset = (phys_addr_t)vma->vm_pgoff << PAGE_SHIFT;
344
345 /* It's illegal to wrap around the end of the physical address space. */
346 if (offset + (phys_addr_t)size < offset)
347 return -EINVAL;
343 348
344 if (!valid_mmap_phys_addr_range(vma->vm_pgoff, size)) 349 if (!valid_mmap_phys_addr_range(vma->vm_pgoff, size))
345 return -EINVAL; 350 return -EINVAL;
diff --git a/drivers/cpufreq/Kconfig.arm b/drivers/cpufreq/Kconfig.arm
index 74ed7e9a7f27..2011fec2d6ad 100644
--- a/drivers/cpufreq/Kconfig.arm
+++ b/drivers/cpufreq/Kconfig.arm
@@ -71,6 +71,15 @@ config ARM_HIGHBANK_CPUFREQ
71 71
72 If in doubt, say N. 72 If in doubt, say N.
73 73
74config ARM_DB8500_CPUFREQ
75 tristate "ST-Ericsson DB8500 cpufreq" if COMPILE_TEST && !ARCH_U8500
76 default ARCH_U8500
77 depends on HAS_IOMEM
78 depends on !CPU_THERMAL || THERMAL
79 help
80 This adds the CPUFreq driver for ST-Ericsson Ux500 (DB8500) SoC
81 series.
82
74config ARM_IMX6Q_CPUFREQ 83config ARM_IMX6Q_CPUFREQ
75 tristate "Freescale i.MX6 cpufreq support" 84 tristate "Freescale i.MX6 cpufreq support"
76 depends on ARCH_MXC 85 depends on ARCH_MXC
diff --git a/drivers/cpufreq/Makefile b/drivers/cpufreq/Makefile
index b7e78f063c4f..ab3a42cd29ef 100644
--- a/drivers/cpufreq/Makefile
+++ b/drivers/cpufreq/Makefile
@@ -53,7 +53,7 @@ obj-$(CONFIG_ARM_DT_BL_CPUFREQ) += arm_big_little_dt.o
53 53
54obj-$(CONFIG_ARM_BRCMSTB_AVS_CPUFREQ) += brcmstb-avs-cpufreq.o 54obj-$(CONFIG_ARM_BRCMSTB_AVS_CPUFREQ) += brcmstb-avs-cpufreq.o
55obj-$(CONFIG_ARCH_DAVINCI) += davinci-cpufreq.o 55obj-$(CONFIG_ARCH_DAVINCI) += davinci-cpufreq.o
56obj-$(CONFIG_UX500_SOC_DB8500) += dbx500-cpufreq.o 56obj-$(CONFIG_ARM_DB8500_CPUFREQ) += dbx500-cpufreq.o
57obj-$(CONFIG_ARM_EXYNOS5440_CPUFREQ) += exynos5440-cpufreq.o 57obj-$(CONFIG_ARM_EXYNOS5440_CPUFREQ) += exynos5440-cpufreq.o
58obj-$(CONFIG_ARM_HIGHBANK_CPUFREQ) += highbank-cpufreq.o 58obj-$(CONFIG_ARM_HIGHBANK_CPUFREQ) += highbank-cpufreq.o
59obj-$(CONFIG_ARM_IMX6Q_CPUFREQ) += imx6q-cpufreq.o 59obj-$(CONFIG_ARM_IMX6Q_CPUFREQ) += imx6q-cpufreq.o
diff --git a/drivers/dax/super.c b/drivers/dax/super.c
index ebf43f531ada..6ed32aac8bbe 100644
--- a/drivers/dax/super.c
+++ b/drivers/dax/super.c
@@ -44,6 +44,7 @@ void dax_read_unlock(int id)
44} 44}
45EXPORT_SYMBOL_GPL(dax_read_unlock); 45EXPORT_SYMBOL_GPL(dax_read_unlock);
46 46
47#ifdef CONFIG_BLOCK
47int bdev_dax_pgoff(struct block_device *bdev, sector_t sector, size_t size, 48int bdev_dax_pgoff(struct block_device *bdev, sector_t sector, size_t size,
48 pgoff_t *pgoff) 49 pgoff_t *pgoff)
49{ 50{
@@ -112,6 +113,7 @@ int __bdev_dax_supported(struct super_block *sb, int blocksize)
112 return 0; 113 return 0;
113} 114}
114EXPORT_SYMBOL_GPL(__bdev_dax_supported); 115EXPORT_SYMBOL_GPL(__bdev_dax_supported);
116#endif
115 117
116/** 118/**
117 * struct dax_device - anchor object for dax services 119 * struct dax_device - anchor object for dax services
diff --git a/drivers/firmware/efi/efi-pstore.c b/drivers/firmware/efi/efi-pstore.c
index ab3a951a17e6..ef1fafdad400 100644
--- a/drivers/firmware/efi/efi-pstore.c
+++ b/drivers/firmware/efi/efi-pstore.c
@@ -53,6 +53,7 @@ static int efi_pstore_read_func(struct efivar_entry *entry,
53 if (sscanf(name, "dump-type%u-%u-%d-%lu-%c", 53 if (sscanf(name, "dump-type%u-%u-%d-%lu-%c",
54 &record->type, &part, &cnt, &time, &data_type) == 5) { 54 &record->type, &part, &cnt, &time, &data_type) == 5) {
55 record->id = generic_id(time, part, cnt); 55 record->id = generic_id(time, part, cnt);
56 record->part = part;
56 record->count = cnt; 57 record->count = cnt;
57 record->time.tv_sec = time; 58 record->time.tv_sec = time;
58 record->time.tv_nsec = 0; 59 record->time.tv_nsec = 0;
@@ -64,6 +65,7 @@ static int efi_pstore_read_func(struct efivar_entry *entry,
64 } else if (sscanf(name, "dump-type%u-%u-%d-%lu", 65 } else if (sscanf(name, "dump-type%u-%u-%d-%lu",
65 &record->type, &part, &cnt, &time) == 4) { 66 &record->type, &part, &cnt, &time) == 4) {
66 record->id = generic_id(time, part, cnt); 67 record->id = generic_id(time, part, cnt);
68 record->part = part;
67 record->count = cnt; 69 record->count = cnt;
68 record->time.tv_sec = time; 70 record->time.tv_sec = time;
69 record->time.tv_nsec = 0; 71 record->time.tv_nsec = 0;
@@ -77,6 +79,7 @@ static int efi_pstore_read_func(struct efivar_entry *entry,
77 * multiple logs, remains. 79 * multiple logs, remains.
78 */ 80 */
79 record->id = generic_id(time, part, 0); 81 record->id = generic_id(time, part, 0);
82 record->part = part;
80 record->count = 0; 83 record->count = 0;
81 record->time.tv_sec = time; 84 record->time.tv_sec = time;
82 record->time.tv_nsec = 0; 85 record->time.tv_nsec = 0;
@@ -241,9 +244,15 @@ static int efi_pstore_write(struct pstore_record *record)
241 efi_guid_t vendor = LINUX_EFI_CRASH_GUID; 244 efi_guid_t vendor = LINUX_EFI_CRASH_GUID;
242 int i, ret = 0; 245 int i, ret = 0;
243 246
247 record->time.tv_sec = get_seconds();
248 record->time.tv_nsec = 0;
249
250 record->id = generic_id(record->time.tv_sec, record->part,
251 record->count);
252
244 snprintf(name, sizeof(name), "dump-type%u-%u-%d-%lu-%c", 253 snprintf(name, sizeof(name), "dump-type%u-%u-%d-%lu-%c",
245 record->type, record->part, record->count, 254 record->type, record->part, record->count,
246 get_seconds(), record->compressed ? 'C' : 'D'); 255 record->time.tv_sec, record->compressed ? 'C' : 'D');
247 256
248 for (i = 0; i < DUMP_NAME_LEN; i++) 257 for (i = 0; i < DUMP_NAME_LEN; i++)
249 efi_name[i] = name[i]; 258 efi_name[i] = name[i];
@@ -255,7 +264,6 @@ static int efi_pstore_write(struct pstore_record *record)
255 if (record->reason == KMSG_DUMP_OOPS) 264 if (record->reason == KMSG_DUMP_OOPS)
256 efivar_run_worker(); 265 efivar_run_worker();
257 266
258 record->id = record->part;
259 return ret; 267 return ret;
260}; 268};
261 269
@@ -287,7 +295,7 @@ static int efi_pstore_erase_func(struct efivar_entry *entry, void *data)
287 * holding multiple logs, remains. 295 * holding multiple logs, remains.
288 */ 296 */
289 snprintf(name_old, sizeof(name_old), "dump-type%u-%u-%lu", 297 snprintf(name_old, sizeof(name_old), "dump-type%u-%u-%lu",
290 ed->record->type, (unsigned int)ed->record->id, 298 ed->record->type, ed->record->part,
291 ed->record->time.tv_sec); 299 ed->record->time.tv_sec);
292 300
293 for (i = 0; i < DUMP_NAME_LEN; i++) 301 for (i = 0; i < DUMP_NAME_LEN; i++)
@@ -320,10 +328,7 @@ static int efi_pstore_erase(struct pstore_record *record)
320 char name[DUMP_NAME_LEN]; 328 char name[DUMP_NAME_LEN];
321 efi_char16_t efi_name[DUMP_NAME_LEN]; 329 efi_char16_t efi_name[DUMP_NAME_LEN];
322 int found, i; 330 int found, i;
323 unsigned int part;
324 331
325 do_div(record->id, 1000);
326 part = do_div(record->id, 100);
327 snprintf(name, sizeof(name), "dump-type%u-%u-%d-%lu", 332 snprintf(name, sizeof(name), "dump-type%u-%u-%d-%lu",
328 record->type, record->part, record->count, 333 record->type, record->part, record->count,
329 record->time.tv_sec); 334 record->time.tv_sec);
diff --git a/drivers/firmware/google/vpd.c b/drivers/firmware/google/vpd.c
index 3ce813110d5e..1e7860f02f4f 100644
--- a/drivers/firmware/google/vpd.c
+++ b/drivers/firmware/google/vpd.c
@@ -116,9 +116,13 @@ static int vpd_section_attrib_add(const u8 *key, s32 key_len,
116 return VPD_OK; 116 return VPD_OK;
117 117
118 info = kzalloc(sizeof(*info), GFP_KERNEL); 118 info = kzalloc(sizeof(*info), GFP_KERNEL);
119 info->key = kzalloc(key_len + 1, GFP_KERNEL); 119 if (!info)
120 if (!info->key)
121 return -ENOMEM; 120 return -ENOMEM;
121 info->key = kzalloc(key_len + 1, GFP_KERNEL);
122 if (!info->key) {
123 ret = -ENOMEM;
124 goto free_info;
125 }
122 126
123 memcpy(info->key, key, key_len); 127 memcpy(info->key, key, key_len);
124 128
@@ -135,12 +139,17 @@ static int vpd_section_attrib_add(const u8 *key, s32 key_len,
135 list_add_tail(&info->list, &sec->attribs); 139 list_add_tail(&info->list, &sec->attribs);
136 140
137 ret = sysfs_create_bin_file(sec->kobj, &info->bin_attr); 141 ret = sysfs_create_bin_file(sec->kobj, &info->bin_attr);
138 if (ret) { 142 if (ret)
139 kfree(info->key); 143 goto free_info_key;
140 return ret;
141 }
142 144
143 return 0; 145 return 0;
146
147free_info_key:
148 kfree(info->key);
149free_info:
150 kfree(info);
151
152 return ret;
144} 153}
145 154
146static void vpd_section_attrib_destroy(struct vpd_section *sec) 155static void vpd_section_attrib_destroy(struct vpd_section *sec)
diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c
index 874ff32db366..00cfed3c3e1a 100644
--- a/drivers/firmware/ti_sci.c
+++ b/drivers/firmware/ti_sci.c
@@ -202,7 +202,8 @@ static int ti_sci_debugfs_create(struct platform_device *pdev,
202 info->debug_buffer[info->debug_region_size] = 0; 202 info->debug_buffer[info->debug_region_size] = 0;
203 203
204 info->d = debugfs_create_file(strncat(debug_name, dev_name(dev), 204 info->d = debugfs_create_file(strncat(debug_name, dev_name(dev),
205 sizeof(debug_name)), 205 sizeof(debug_name) -
206 sizeof("ti_sci_debug@")),
206 0444, NULL, info, &ti_sci_debug_fops); 207 0444, NULL, info, &ti_sci_debug_fops);
207 if (IS_ERR(info->d)) 208 if (IS_ERR(info->d))
208 return PTR_ERR(info->d); 209 return PTR_ERR(info->d);
diff --git a/drivers/gpu/drm/arm/hdlcd_crtc.c b/drivers/gpu/drm/arm/hdlcd_crtc.c
index 798a3cc480a2..1a3359c0f6cd 100644
--- a/drivers/gpu/drm/arm/hdlcd_crtc.c
+++ b/drivers/gpu/drm/arm/hdlcd_crtc.c
@@ -10,6 +10,7 @@
10 */ 10 */
11 11
12#include <drm/drmP.h> 12#include <drm/drmP.h>
13#include <drm/drm_atomic.h>
13#include <drm/drm_atomic_helper.h> 14#include <drm/drm_atomic_helper.h>
14#include <drm/drm_crtc.h> 15#include <drm/drm_crtc.h>
15#include <drm/drm_crtc_helper.h> 16#include <drm/drm_crtc_helper.h>
@@ -226,16 +227,33 @@ static const struct drm_crtc_helper_funcs hdlcd_crtc_helper_funcs = {
226static int hdlcd_plane_atomic_check(struct drm_plane *plane, 227static int hdlcd_plane_atomic_check(struct drm_plane *plane,
227 struct drm_plane_state *state) 228 struct drm_plane_state *state)
228{ 229{
229 u32 src_w, src_h; 230 struct drm_rect clip = { 0 };
231 struct drm_crtc_state *crtc_state;
232 u32 src_h = state->src_h >> 16;
230 233
231 src_w = state->src_w >> 16; 234 /* only the HDLCD_REG_FB_LINE_COUNT register has a limit */
232 src_h = state->src_h >> 16; 235 if (src_h >= HDLCD_MAX_YRES) {
236 DRM_DEBUG_KMS("Invalid source width: %d\n", src_h);
237 return -EINVAL;
238 }
239
240 if (!state->fb || !state->crtc)
241 return 0;
233 242
234 /* we can't do any scaling of the plane source */ 243 crtc_state = drm_atomic_get_existing_crtc_state(state->state,
235 if ((src_w != state->crtc_w) || (src_h != state->crtc_h)) 244 state->crtc);
245 if (!crtc_state) {
246 DRM_DEBUG_KMS("Invalid crtc state\n");
236 return -EINVAL; 247 return -EINVAL;
248 }
237 249
238 return 0; 250 clip.x2 = crtc_state->adjusted_mode.hdisplay;
251 clip.y2 = crtc_state->adjusted_mode.vdisplay;
252
253 return drm_plane_helper_check_state(state, &clip,
254 DRM_PLANE_HELPER_NO_SCALING,
255 DRM_PLANE_HELPER_NO_SCALING,
256 false, true);
239} 257}
240 258
241static void hdlcd_plane_atomic_update(struct drm_plane *plane, 259static void hdlcd_plane_atomic_update(struct drm_plane *plane,
@@ -244,21 +262,20 @@ static void hdlcd_plane_atomic_update(struct drm_plane *plane,
244 struct drm_framebuffer *fb = plane->state->fb; 262 struct drm_framebuffer *fb = plane->state->fb;
245 struct hdlcd_drm_private *hdlcd; 263 struct hdlcd_drm_private *hdlcd;
246 struct drm_gem_cma_object *gem; 264 struct drm_gem_cma_object *gem;
247 u32 src_w, src_h, dest_w, dest_h; 265 u32 src_x, src_y, dest_h;
248 dma_addr_t scanout_start; 266 dma_addr_t scanout_start;
249 267
250 if (!fb) 268 if (!fb)
251 return; 269 return;
252 270
253 src_w = plane->state->src_w >> 16; 271 src_x = plane->state->src.x1 >> 16;
254 src_h = plane->state->src_h >> 16; 272 src_y = plane->state->src.y1 >> 16;
255 dest_w = plane->state->crtc_w; 273 dest_h = drm_rect_height(&plane->state->dst);
256 dest_h = plane->state->crtc_h;
257 gem = drm_fb_cma_get_gem_obj(fb, 0); 274 gem = drm_fb_cma_get_gem_obj(fb, 0);
275
258 scanout_start = gem->paddr + fb->offsets[0] + 276 scanout_start = gem->paddr + fb->offsets[0] +
259 plane->state->crtc_y * fb->pitches[0] + 277 src_y * fb->pitches[0] +
260 plane->state->crtc_x * 278 src_x * fb->format->cpp[0];
261 fb->format->cpp[0];
262 279
263 hdlcd = plane->dev->dev_private; 280 hdlcd = plane->dev->dev_private;
264 hdlcd_write(hdlcd, HDLCD_REG_FB_LINE_LENGTH, fb->pitches[0]); 281 hdlcd_write(hdlcd, HDLCD_REG_FB_LINE_LENGTH, fb->pitches[0]);
@@ -305,7 +322,6 @@ static struct drm_plane *hdlcd_plane_init(struct drm_device *drm)
305 formats, ARRAY_SIZE(formats), 322 formats, ARRAY_SIZE(formats),
306 DRM_PLANE_TYPE_PRIMARY, NULL); 323 DRM_PLANE_TYPE_PRIMARY, NULL);
307 if (ret) { 324 if (ret) {
308 devm_kfree(drm->dev, plane);
309 return ERR_PTR(ret); 325 return ERR_PTR(ret);
310 } 326 }
311 327
@@ -329,7 +345,6 @@ int hdlcd_setup_crtc(struct drm_device *drm)
329 &hdlcd_crtc_funcs, NULL); 345 &hdlcd_crtc_funcs, NULL);
330 if (ret) { 346 if (ret) {
331 hdlcd_plane_destroy(primary); 347 hdlcd_plane_destroy(primary);
332 devm_kfree(drm->dev, primary);
333 return ret; 348 return ret;
334 } 349 }
335 350
diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c
index 65a3bd7a0c00..423dda2785d4 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c
@@ -152,8 +152,7 @@ static const struct drm_connector_funcs atmel_hlcdc_panel_connector_funcs = {
152 .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, 152 .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
153}; 153};
154 154
155static int atmel_hlcdc_attach_endpoint(struct drm_device *dev, 155static int atmel_hlcdc_attach_endpoint(struct drm_device *dev, int endpoint)
156 const struct device_node *np)
157{ 156{
158 struct atmel_hlcdc_dc *dc = dev->dev_private; 157 struct atmel_hlcdc_dc *dc = dev->dev_private;
159 struct atmel_hlcdc_rgb_output *output; 158 struct atmel_hlcdc_rgb_output *output;
@@ -161,6 +160,11 @@ static int atmel_hlcdc_attach_endpoint(struct drm_device *dev,
161 struct drm_bridge *bridge; 160 struct drm_bridge *bridge;
162 int ret; 161 int ret;
163 162
163 ret = drm_of_find_panel_or_bridge(dev->dev->of_node, 0, endpoint,
164 &panel, &bridge);
165 if (ret)
166 return ret;
167
164 output = devm_kzalloc(dev->dev, sizeof(*output), GFP_KERNEL); 168 output = devm_kzalloc(dev->dev, sizeof(*output), GFP_KERNEL);
165 if (!output) 169 if (!output)
166 return -EINVAL; 170 return -EINVAL;
@@ -177,10 +181,6 @@ static int atmel_hlcdc_attach_endpoint(struct drm_device *dev,
177 181
178 output->encoder.possible_crtcs = 0x1; 182 output->encoder.possible_crtcs = 0x1;
179 183
180 ret = drm_of_find_panel_or_bridge(np, 0, 0, &panel, &bridge);
181 if (ret)
182 return ret;
183
184 if (panel) { 184 if (panel) {
185 output->connector.dpms = DRM_MODE_DPMS_OFF; 185 output->connector.dpms = DRM_MODE_DPMS_OFF;
186 output->connector.polled = DRM_CONNECTOR_POLL_CONNECT; 186 output->connector.polled = DRM_CONNECTOR_POLL_CONNECT;
@@ -220,22 +220,14 @@ err_encoder_cleanup:
220 220
221int atmel_hlcdc_create_outputs(struct drm_device *dev) 221int atmel_hlcdc_create_outputs(struct drm_device *dev)
222{ 222{
223 struct device_node *remote; 223 int endpoint, ret = 0;
224 int ret = -ENODEV; 224
225 int endpoint = 0; 225 for (endpoint = 0; !ret; endpoint++)
226 226 ret = atmel_hlcdc_attach_endpoint(dev, endpoint);
227 while (true) { 227
228 /* Loop thru possible multiple connections to the output */ 228 /* At least one device was successfully attached.*/
229 remote = of_graph_get_remote_node(dev->dev->of_node, 0, 229 if (ret == -ENODEV && endpoint)
230 endpoint++); 230 return 0;
231 if (!remote)
232 break;
233
234 ret = atmel_hlcdc_attach_endpoint(dev, remote);
235 of_node_put(remote);
236 if (ret)
237 return ret;
238 }
239 231
240 return ret; 232 return ret;
241} 233}
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
index e1909429837e..de80ee1b71df 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
@@ -44,6 +44,7 @@ static struct etnaviv_gem_submit *submit_create(struct drm_device *dev,
44 44
45 /* initially, until copy_from_user() and bo lookup succeeds: */ 45 /* initially, until copy_from_user() and bo lookup succeeds: */
46 submit->nr_bos = 0; 46 submit->nr_bos = 0;
47 submit->fence = NULL;
47 48
48 ww_acquire_init(&submit->ticket, &reservation_ww_class); 49 ww_acquire_init(&submit->ticket, &reservation_ww_class);
49 } 50 }
@@ -294,7 +295,8 @@ static void submit_cleanup(struct etnaviv_gem_submit *submit)
294 } 295 }
295 296
296 ww_acquire_fini(&submit->ticket); 297 ww_acquire_fini(&submit->ticket);
297 dma_fence_put(submit->fence); 298 if (submit->fence)
299 dma_fence_put(submit->fence);
298 kfree(submit); 300 kfree(submit);
299} 301}
300 302
diff --git a/drivers/gpu/drm/i915/gvt/handlers.c b/drivers/gpu/drm/i915/gvt/handlers.c
index 0ad1a508e2af..c995e540ff96 100644
--- a/drivers/gpu/drm/i915/gvt/handlers.c
+++ b/drivers/gpu/drm/i915/gvt/handlers.c
@@ -1244,7 +1244,7 @@ static int dma_ctrl_write(struct intel_vgpu *vgpu, unsigned int offset,
1244 mode = vgpu_vreg(vgpu, offset); 1244 mode = vgpu_vreg(vgpu, offset);
1245 1245
1246 if (GFX_MODE_BIT_SET_IN_MASK(mode, START_DMA)) { 1246 if (GFX_MODE_BIT_SET_IN_MASK(mode, START_DMA)) {
1247 WARN_ONCE(1, "VM(%d): iGVT-g doesn't supporte GuC\n", 1247 WARN_ONCE(1, "VM(%d): iGVT-g doesn't support GuC\n",
1248 vgpu->id); 1248 vgpu->id);
1249 return 0; 1249 return 0;
1250 } 1250 }
diff --git a/drivers/gpu/drm/i915/gvt/render.c b/drivers/gpu/drm/i915/gvt/render.c
index c6e7972ac21d..a5e11d89df2f 100644
--- a/drivers/gpu/drm/i915/gvt/render.c
+++ b/drivers/gpu/drm/i915/gvt/render.c
@@ -340,6 +340,9 @@ void intel_gvt_restore_render_mmio(struct intel_vgpu *vgpu, int ring_id)
340 } else 340 } else
341 v = mmio->value; 341 v = mmio->value;
342 342
343 if (mmio->in_context)
344 continue;
345
343 I915_WRITE(mmio->reg, v); 346 I915_WRITE(mmio->reg, v);
344 POSTING_READ(mmio->reg); 347 POSTING_READ(mmio->reg);
345 348
diff --git a/drivers/gpu/drm/i915/gvt/sched_policy.c b/drivers/gpu/drm/i915/gvt/sched_policy.c
index 79ba4b3440aa..f25ff133865f 100644
--- a/drivers/gpu/drm/i915/gvt/sched_policy.c
+++ b/drivers/gpu/drm/i915/gvt/sched_policy.c
@@ -129,9 +129,13 @@ static void try_to_schedule_next_vgpu(struct intel_gvt *gvt)
129 struct vgpu_sched_data *vgpu_data; 129 struct vgpu_sched_data *vgpu_data;
130 ktime_t cur_time; 130 ktime_t cur_time;
131 131
132 /* no target to schedule */ 132 /* no need to schedule if next_vgpu is the same with current_vgpu,
133 if (!scheduler->next_vgpu) 133 * let scheduler chose next_vgpu again by setting it to NULL.
134 */
135 if (scheduler->next_vgpu == scheduler->current_vgpu) {
136 scheduler->next_vgpu = NULL;
134 return; 137 return;
138 }
135 139
136 /* 140 /*
137 * after the flag is set, workload dispatch thread will 141 * after the flag is set, workload dispatch thread will
diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index 2aa6b97fd22f..a0563e18d753 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -195,9 +195,12 @@ static int ppgtt_bind_vma(struct i915_vma *vma,
195 u32 pte_flags; 195 u32 pte_flags;
196 int ret; 196 int ret;
197 197
198 ret = vma->vm->allocate_va_range(vma->vm, vma->node.start, vma->size); 198 if (!(vma->flags & I915_VMA_LOCAL_BIND)) {
199 if (ret) 199 ret = vma->vm->allocate_va_range(vma->vm, vma->node.start,
200 return ret; 200 vma->size);
201 if (ret)
202 return ret;
203 }
201 204
202 vma->pages = vma->obj->mm.pages; 205 vma->pages = vma->obj->mm.pages;
203 206
@@ -2306,7 +2309,8 @@ static int aliasing_gtt_bind_vma(struct i915_vma *vma,
2306 if (flags & I915_VMA_LOCAL_BIND) { 2309 if (flags & I915_VMA_LOCAL_BIND) {
2307 struct i915_hw_ppgtt *appgtt = i915->mm.aliasing_ppgtt; 2310 struct i915_hw_ppgtt *appgtt = i915->mm.aliasing_ppgtt;
2308 2311
2309 if (appgtt->base.allocate_va_range) { 2312 if (!(vma->flags & I915_VMA_LOCAL_BIND) &&
2313 appgtt->base.allocate_va_range) {
2310 ret = appgtt->base.allocate_va_range(&appgtt->base, 2314 ret = appgtt->base.allocate_va_range(&appgtt->base,
2311 vma->node.start, 2315 vma->node.start,
2312 vma->node.size); 2316 vma->node.size);
diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index 11b12f412492..5a7c63e64381 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -3051,10 +3051,14 @@ enum skl_disp_power_wells {
3051#define CLKCFG_FSB_667 (3 << 0) /* hrawclk 166 */ 3051#define CLKCFG_FSB_667 (3 << 0) /* hrawclk 166 */
3052#define CLKCFG_FSB_800 (2 << 0) /* hrawclk 200 */ 3052#define CLKCFG_FSB_800 (2 << 0) /* hrawclk 200 */
3053#define CLKCFG_FSB_1067 (6 << 0) /* hrawclk 266 */ 3053#define CLKCFG_FSB_1067 (6 << 0) /* hrawclk 266 */
3054#define CLKCFG_FSB_1067_ALT (0 << 0) /* hrawclk 266 */
3054#define CLKCFG_FSB_1333 (7 << 0) /* hrawclk 333 */ 3055#define CLKCFG_FSB_1333 (7 << 0) /* hrawclk 333 */
3055/* Note, below two are guess */ 3056/*
3056#define CLKCFG_FSB_1600 (4 << 0) /* hrawclk 400 */ 3057 * Note that on at least on ELK the below value is reported for both
3057#define CLKCFG_FSB_1600_ALT (0 << 0) /* hrawclk 400 */ 3058 * 333 and 400 MHz BIOS FSB setting, but given that the gmch datasheet
3059 * lists only 200/266/333 MHz FSB as supported let's decode it as 333 MHz.
3060 */
3061#define CLKCFG_FSB_1333_ALT (4 << 0) /* hrawclk 333 */
3058#define CLKCFG_FSB_MASK (7 << 0) 3062#define CLKCFG_FSB_MASK (7 << 0)
3059#define CLKCFG_MEM_533 (1 << 4) 3063#define CLKCFG_MEM_533 (1 << 4)
3060#define CLKCFG_MEM_667 (2 << 4) 3064#define CLKCFG_MEM_667 (2 << 4)
diff --git a/drivers/gpu/drm/i915/intel_cdclk.c b/drivers/gpu/drm/i915/intel_cdclk.c
index dd3ad52b7dfe..f29a226e24d8 100644
--- a/drivers/gpu/drm/i915/intel_cdclk.c
+++ b/drivers/gpu/drm/i915/intel_cdclk.c
@@ -1798,13 +1798,11 @@ static int g4x_hrawclk(struct drm_i915_private *dev_priv)
1798 case CLKCFG_FSB_800: 1798 case CLKCFG_FSB_800:
1799 return 200000; 1799 return 200000;
1800 case CLKCFG_FSB_1067: 1800 case CLKCFG_FSB_1067:
1801 case CLKCFG_FSB_1067_ALT:
1801 return 266667; 1802 return 266667;
1802 case CLKCFG_FSB_1333: 1803 case CLKCFG_FSB_1333:
1804 case CLKCFG_FSB_1333_ALT:
1803 return 333333; 1805 return 333333;
1804 /* these two are just a guess; one of them might be right */
1805 case CLKCFG_FSB_1600:
1806 case CLKCFG_FSB_1600_ALT:
1807 return 400000;
1808 default: 1806 default:
1809 return 133333; 1807 return 133333;
1810 } 1808 }
diff --git a/drivers/gpu/drm/i915/intel_dsi.c b/drivers/gpu/drm/i915/intel_dsi.c
index 3ffe8b1f1d48..fc0ef492252a 100644
--- a/drivers/gpu/drm/i915/intel_dsi.c
+++ b/drivers/gpu/drm/i915/intel_dsi.c
@@ -410,11 +410,10 @@ static void glk_dsi_device_ready(struct intel_encoder *encoder)
410 val |= (ULPS_STATE_ENTER | DEVICE_READY); 410 val |= (ULPS_STATE_ENTER | DEVICE_READY);
411 I915_WRITE(MIPI_DEVICE_READY(port), val); 411 I915_WRITE(MIPI_DEVICE_READY(port), val);
412 412
413 /* Wait for ULPS Not active */ 413 /* Wait for ULPS active */
414 if (intel_wait_for_register(dev_priv, 414 if (intel_wait_for_register(dev_priv,
415 MIPI_CTRL(port), GLK_ULPS_NOT_ACTIVE, 415 MIPI_CTRL(port), GLK_ULPS_NOT_ACTIVE, 0, 20))
416 GLK_ULPS_NOT_ACTIVE, 20)) 416 DRM_ERROR("ULPS not active\n");
417 DRM_ERROR("ULPS is still active\n");
418 417
419 /* Exit ULPS */ 418 /* Exit ULPS */
420 val = I915_READ(MIPI_DEVICE_READY(port)); 419 val = I915_READ(MIPI_DEVICE_READY(port));
diff --git a/drivers/gpu/drm/i915/intel_lpe_audio.c b/drivers/gpu/drm/i915/intel_lpe_audio.c
index 25d8e76489e4..668f00480d97 100644
--- a/drivers/gpu/drm/i915/intel_lpe_audio.c
+++ b/drivers/gpu/drm/i915/intel_lpe_audio.c
@@ -63,6 +63,7 @@
63#include <linux/acpi.h> 63#include <linux/acpi.h>
64#include <linux/device.h> 64#include <linux/device.h>
65#include <linux/pci.h> 65#include <linux/pci.h>
66#include <linux/pm_runtime.h>
66 67
67#include "i915_drv.h" 68#include "i915_drv.h"
68#include <linux/delay.h> 69#include <linux/delay.h>
@@ -121,6 +122,10 @@ lpe_audio_platdev_create(struct drm_i915_private *dev_priv)
121 122
122 kfree(rsc); 123 kfree(rsc);
123 124
125 pm_runtime_forbid(&platdev->dev);
126 pm_runtime_set_active(&platdev->dev);
127 pm_runtime_enable(&platdev->dev);
128
124 return platdev; 129 return platdev;
125 130
126err: 131err:
diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c b/drivers/gpu/drm/nouveau/nouveau_display.c
index 21b10f9840c9..549763f5e17d 100644
--- a/drivers/gpu/drm/nouveau/nouveau_display.c
+++ b/drivers/gpu/drm/nouveau/nouveau_display.c
@@ -360,6 +360,8 @@ nouveau_display_hpd_work(struct work_struct *work)
360 pm_runtime_get_sync(drm->dev->dev); 360 pm_runtime_get_sync(drm->dev->dev);
361 361
362 drm_helper_hpd_irq_event(drm->dev); 362 drm_helper_hpd_irq_event(drm->dev);
363 /* enable polling for external displays */
364 drm_kms_helper_poll_enable(drm->dev);
363 365
364 pm_runtime_mark_last_busy(drm->dev->dev); 366 pm_runtime_mark_last_busy(drm->dev->dev);
365 pm_runtime_put_sync(drm->dev->dev); 367 pm_runtime_put_sync(drm->dev->dev);
@@ -413,10 +415,6 @@ nouveau_display_init(struct drm_device *dev)
413 if (ret) 415 if (ret)
414 return ret; 416 return ret;
415 417
416 /* enable polling for external displays */
417 if (!dev->mode_config.poll_enabled)
418 drm_kms_helper_poll_enable(dev);
419
420 /* enable hotplug interrupts */ 418 /* enable hotplug interrupts */
421 list_for_each_entry(connector, &dev->mode_config.connector_list, head) { 419 list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
422 struct nouveau_connector *conn = nouveau_connector(connector); 420 struct nouveau_connector *conn = nouveau_connector(connector);
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index 2b6ac24ce690..36268e1802b5 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -502,6 +502,9 @@ nouveau_drm_load(struct drm_device *dev, unsigned long flags)
502 pm_runtime_allow(dev->dev); 502 pm_runtime_allow(dev->dev);
503 pm_runtime_mark_last_busy(dev->dev); 503 pm_runtime_mark_last_busy(dev->dev);
504 pm_runtime_put(dev->dev); 504 pm_runtime_put(dev->dev);
505 } else {
506 /* enable polling for external displays */
507 drm_kms_helper_poll_enable(dev);
505 } 508 }
506 return 0; 509 return 0;
507 510
@@ -774,9 +777,6 @@ nouveau_pmops_runtime_resume(struct device *dev)
774 777
775 ret = nouveau_do_resume(drm_dev, true); 778 ret = nouveau_do_resume(drm_dev, true);
776 779
777 if (!drm_dev->mode_config.poll_enabled)
778 drm_kms_helper_poll_enable(drm_dev);
779
780 /* do magic */ 780 /* do magic */
781 nvif_mask(&device->object, 0x088488, (1 << 25), (1 << 25)); 781 nvif_mask(&device->object, 0x088488, (1 << 25), (1 << 25));
782 vga_switcheroo_set_dynamic_switch(pdev, VGA_SWITCHEROO_ON); 782 vga_switcheroo_set_dynamic_switch(pdev, VGA_SWITCHEROO_ON);
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.c b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.c
index 3a24788c3185..a7e55c422501 100644
--- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.c
+++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.c
@@ -148,7 +148,7 @@ gk104_fifo_runlist_commit(struct gk104_fifo *fifo, int runl)
148 case NVKM_MEM_TARGET_NCOH: target = 3; break; 148 case NVKM_MEM_TARGET_NCOH: target = 3; break;
149 default: 149 default:
150 WARN_ON(1); 150 WARN_ON(1);
151 return; 151 goto unlock;
152 } 152 }
153 153
154 nvkm_wr32(device, 0x002270, (nvkm_memory_addr(mem) >> 12) | 154 nvkm_wr32(device, 0x002270, (nvkm_memory_addr(mem) >> 12) |
@@ -160,6 +160,7 @@ gk104_fifo_runlist_commit(struct gk104_fifo *fifo, int runl)
160 & 0x00100000), 160 & 0x00100000),
161 msecs_to_jiffies(2000)) == 0) 161 msecs_to_jiffies(2000)) == 0)
162 nvkm_error(subdev, "runlist %d update timeout\n", runl); 162 nvkm_error(subdev, "runlist %d update timeout\n", runl);
163unlock:
163 mutex_unlock(&subdev->mutex); 164 mutex_unlock(&subdev->mutex);
164} 165}
165 166
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/secboot/ls_ucode_gr.c b/drivers/gpu/drm/nouveau/nvkm/subdev/secboot/ls_ucode_gr.c
index d1cf02d22db1..1b0c793c0192 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/secboot/ls_ucode_gr.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/secboot/ls_ucode_gr.c
@@ -116,6 +116,7 @@ ls_ucode_img_load_gr(const struct nvkm_subdev *subdev, struct ls_ucode_img *img,
116 ret = nvkm_firmware_get(subdev->device, f, &sig); 116 ret = nvkm_firmware_get(subdev->device, f, &sig);
117 if (ret) 117 if (ret)
118 goto free_data; 118 goto free_data;
119
119 img->sig = kmemdup(sig->data, sig->size, GFP_KERNEL); 120 img->sig = kmemdup(sig->data, sig->size, GFP_KERNEL);
120 if (!img->sig) { 121 if (!img->sig) {
121 ret = -ENOMEM; 122 ret = -ENOMEM;
@@ -126,8 +127,9 @@ ls_ucode_img_load_gr(const struct nvkm_subdev *subdev, struct ls_ucode_img *img,
126 img->ucode_data = ls_ucode_img_build(bl, code, data, 127 img->ucode_data = ls_ucode_img_build(bl, code, data,
127 &img->ucode_desc); 128 &img->ucode_desc);
128 if (IS_ERR(img->ucode_data)) { 129 if (IS_ERR(img->ucode_data)) {
130 kfree(img->sig);
129 ret = PTR_ERR(img->ucode_data); 131 ret = PTR_ERR(img->ucode_data);
130 goto free_data; 132 goto free_sig;
131 } 133 }
132 img->ucode_size = img->ucode_desc.image_size; 134 img->ucode_size = img->ucode_desc.image_size;
133 135
diff --git a/drivers/gpu/host1x/Kconfig b/drivers/gpu/host1x/Kconfig
index b2fd029d67b3..91916326957f 100644
--- a/drivers/gpu/host1x/Kconfig
+++ b/drivers/gpu/host1x/Kconfig
@@ -1,6 +1,7 @@
1config TEGRA_HOST1X 1config TEGRA_HOST1X
2 tristate "NVIDIA Tegra host1x driver" 2 tristate "NVIDIA Tegra host1x driver"
3 depends on ARCH_TEGRA || (ARM && COMPILE_TEST) 3 depends on ARCH_TEGRA || (ARM && COMPILE_TEST)
4 select IOMMU_IOVA if IOMMU_SUPPORT
4 help 5 help
5 Driver for the NVIDIA Tegra host1x hardware. 6 Driver for the NVIDIA Tegra host1x hardware.
6 7
diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
index f2acd4b6bf01..d1263b82d646 100644
--- a/drivers/i2c/busses/i2c-designware-platdrv.c
+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
@@ -94,6 +94,7 @@ static void dw_i2c_acpi_params(struct platform_device *pdev, char method[],
94static int dw_i2c_acpi_configure(struct platform_device *pdev) 94static int dw_i2c_acpi_configure(struct platform_device *pdev)
95{ 95{
96 struct dw_i2c_dev *dev = platform_get_drvdata(pdev); 96 struct dw_i2c_dev *dev = platform_get_drvdata(pdev);
97 u32 ss_ht = 0, fp_ht = 0, hs_ht = 0, fs_ht = 0;
97 acpi_handle handle = ACPI_HANDLE(&pdev->dev); 98 acpi_handle handle = ACPI_HANDLE(&pdev->dev);
98 const struct acpi_device_id *id; 99 const struct acpi_device_id *id;
99 struct acpi_device *adev; 100 struct acpi_device *adev;
@@ -107,23 +108,24 @@ static int dw_i2c_acpi_configure(struct platform_device *pdev)
107 * Try to get SDA hold time and *CNT values from an ACPI method for 108 * Try to get SDA hold time and *CNT values from an ACPI method for
108 * selected speed modes. 109 * selected speed modes.
109 */ 110 */
111 dw_i2c_acpi_params(pdev, "SSCN", &dev->ss_hcnt, &dev->ss_lcnt, &ss_ht);
112 dw_i2c_acpi_params(pdev, "FPCN", &dev->fp_hcnt, &dev->fp_lcnt, &fp_ht);
113 dw_i2c_acpi_params(pdev, "HSCN", &dev->hs_hcnt, &dev->hs_lcnt, &hs_ht);
114 dw_i2c_acpi_params(pdev, "FMCN", &dev->fs_hcnt, &dev->fs_lcnt, &fs_ht);
115
110 switch (dev->clk_freq) { 116 switch (dev->clk_freq) {
111 case 100000: 117 case 100000:
112 dw_i2c_acpi_params(pdev, "SSCN", &dev->ss_hcnt, &dev->ss_lcnt, 118 dev->sda_hold_time = ss_ht;
113 &dev->sda_hold_time);
114 break; 119 break;
115 case 1000000: 120 case 1000000:
116 dw_i2c_acpi_params(pdev, "FPCN", &dev->fp_hcnt, &dev->fp_lcnt, 121 dev->sda_hold_time = fp_ht;
117 &dev->sda_hold_time);
118 break; 122 break;
119 case 3400000: 123 case 3400000:
120 dw_i2c_acpi_params(pdev, "HSCN", &dev->hs_hcnt, &dev->hs_lcnt, 124 dev->sda_hold_time = hs_ht;
121 &dev->sda_hold_time);
122 break; 125 break;
123 case 400000: 126 case 400000:
124 default: 127 default:
125 dw_i2c_acpi_params(pdev, "FMCN", &dev->fs_hcnt, &dev->fs_lcnt, 128 dev->sda_hold_time = fs_ht;
126 &dev->sda_hold_time);
127 break; 129 break;
128 } 130 }
129 131
diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c
index 8348f366ddd1..62618e77bedc 100644
--- a/drivers/iommu/dma-iommu.c
+++ b/drivers/iommu/dma-iommu.c
@@ -396,13 +396,13 @@ static void iommu_dma_free_iova(struct iommu_dma_cookie *cookie,
396 dma_addr_t iova, size_t size) 396 dma_addr_t iova, size_t size)
397{ 397{
398 struct iova_domain *iovad = &cookie->iovad; 398 struct iova_domain *iovad = &cookie->iovad;
399 unsigned long shift = iova_shift(iovad);
400 399
401 /* The MSI case is only ever cleaning up its most recent allocation */ 400 /* The MSI case is only ever cleaning up its most recent allocation */
402 if (cookie->type == IOMMU_DMA_MSI_COOKIE) 401 if (cookie->type == IOMMU_DMA_MSI_COOKIE)
403 cookie->msi_iova -= size; 402 cookie->msi_iova -= size;
404 else 403 else
405 free_iova_fast(iovad, iova >> shift, size >> shift); 404 free_iova_fast(iovad, iova_pfn(iovad, iova),
405 size >> iova_shift(iovad));
406} 406}
407 407
408static void __iommu_dma_unmap(struct iommu_domain *domain, dma_addr_t dma_addr, 408static void __iommu_dma_unmap(struct iommu_domain *domain, dma_addr_t dma_addr,
@@ -617,11 +617,14 @@ static dma_addr_t __iommu_dma_map(struct device *dev, phys_addr_t phys,
617{ 617{
618 struct iommu_domain *domain = iommu_get_domain_for_dev(dev); 618 struct iommu_domain *domain = iommu_get_domain_for_dev(dev);
619 struct iommu_dma_cookie *cookie = domain->iova_cookie; 619 struct iommu_dma_cookie *cookie = domain->iova_cookie;
620 struct iova_domain *iovad = &cookie->iovad; 620 size_t iova_off = 0;
621 size_t iova_off = iova_offset(iovad, phys);
622 dma_addr_t iova; 621 dma_addr_t iova;
623 622
624 size = iova_align(iovad, size + iova_off); 623 if (cookie->type == IOMMU_DMA_IOVA_COOKIE) {
624 iova_off = iova_offset(&cookie->iovad, phys);
625 size = iova_align(&cookie->iovad, size + iova_off);
626 }
627
625 iova = iommu_dma_alloc_iova(domain, size, dma_get_mask(dev), dev); 628 iova = iommu_dma_alloc_iova(domain, size, dma_get_mask(dev), dev);
626 if (!iova) 629 if (!iova)
627 return DMA_ERROR_CODE; 630 return DMA_ERROR_CODE;
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index 90ab0115d78e..fc2765ccdb57 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -2055,11 +2055,14 @@ static int domain_context_mapping_one(struct dmar_domain *domain,
2055 if (context_copied(context)) { 2055 if (context_copied(context)) {
2056 u16 did_old = context_domain_id(context); 2056 u16 did_old = context_domain_id(context);
2057 2057
2058 if (did_old >= 0 && did_old < cap_ndoms(iommu->cap)) 2058 if (did_old >= 0 && did_old < cap_ndoms(iommu->cap)) {
2059 iommu->flush.flush_context(iommu, did_old, 2059 iommu->flush.flush_context(iommu, did_old,
2060 (((u16)bus) << 8) | devfn, 2060 (((u16)bus) << 8) | devfn,
2061 DMA_CCMD_MASK_NOBIT, 2061 DMA_CCMD_MASK_NOBIT,
2062 DMA_CCMD_DEVICE_INVL); 2062 DMA_CCMD_DEVICE_INVL);
2063 iommu->flush.flush_iotlb(iommu, did_old, 0, 0,
2064 DMA_TLB_DSI_FLUSH);
2065 }
2063 } 2066 }
2064 2067
2065 pgd = domain->pgd; 2068 pgd = domain->pgd;
diff --git a/drivers/iommu/mtk_iommu_v1.c b/drivers/iommu/mtk_iommu_v1.c
index a27ef570c328..bc1efbfb9ddf 100644
--- a/drivers/iommu/mtk_iommu_v1.c
+++ b/drivers/iommu/mtk_iommu_v1.c
@@ -18,6 +18,7 @@
18#include <linux/clk.h> 18#include <linux/clk.h>
19#include <linux/component.h> 19#include <linux/component.h>
20#include <linux/device.h> 20#include <linux/device.h>
21#include <linux/dma-mapping.h>
21#include <linux/dma-iommu.h> 22#include <linux/dma-iommu.h>
22#include <linux/err.h> 23#include <linux/err.h>
23#include <linux/interrupt.h> 24#include <linux/interrupt.h>
diff --git a/drivers/irqchip/irq-mbigen.c b/drivers/irqchip/irq-mbigen.c
index d2306c821ebb..31d6b5a582d2 100644
--- a/drivers/irqchip/irq-mbigen.c
+++ b/drivers/irqchip/irq-mbigen.c
@@ -106,10 +106,7 @@ static inline void get_mbigen_type_reg(irq_hw_number_t hwirq,
106static inline void get_mbigen_clear_reg(irq_hw_number_t hwirq, 106static inline void get_mbigen_clear_reg(irq_hw_number_t hwirq,
107 u32 *mask, u32 *addr) 107 u32 *mask, u32 *addr)
108{ 108{
109 unsigned int ofst; 109 unsigned int ofst = (hwirq / 32) * 4;
110
111 hwirq -= RESERVED_IRQ_PER_MBIGEN_CHIP;
112 ofst = hwirq / 32 * 4;
113 110
114 *mask = 1 << (hwirq % 32); 111 *mask = 1 << (hwirq % 32);
115 *addr = ofst + REG_MBIGEN_CLEAR_OFFSET; 112 *addr = ofst + REG_MBIGEN_CLEAR_OFFSET;
@@ -337,9 +334,15 @@ static int mbigen_device_probe(struct platform_device *pdev)
337 mgn_chip->pdev = pdev; 334 mgn_chip->pdev = pdev;
338 335
339 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 336 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
340 mgn_chip->base = devm_ioremap_resource(&pdev->dev, res); 337 if (!res)
341 if (IS_ERR(mgn_chip->base)) 338 return -EINVAL;
342 return PTR_ERR(mgn_chip->base); 339
340 mgn_chip->base = devm_ioremap(&pdev->dev, res->start,
341 resource_size(res));
342 if (!mgn_chip->base) {
343 dev_err(&pdev->dev, "failed to ioremap %pR\n", res);
344 return -ENOMEM;
345 }
343 346
344 if (IS_ENABLED(CONFIG_OF) && pdev->dev.of_node) 347 if (IS_ENABLED(CONFIG_OF) && pdev->dev.of_node)
345 err = mbigen_of_create_domain(pdev, mgn_chip); 348 err = mbigen_of_create_domain(pdev, mgn_chip);
diff --git a/drivers/memory/omap-gpmc.c b/drivers/memory/omap-gpmc.c
index bf0fe0137dfe..6d1b4b707cc2 100644
--- a/drivers/memory/omap-gpmc.c
+++ b/drivers/memory/omap-gpmc.c
@@ -512,7 +512,7 @@ static void gpmc_cs_show_timings(int cs, const char *desc)
512 pr_info("gpmc cs%i access configuration:\n", cs); 512 pr_info("gpmc cs%i access configuration:\n", cs);
513 GPMC_GET_RAW_BOOL(GPMC_CS_CONFIG1, 4, 4, "time-para-granularity"); 513 GPMC_GET_RAW_BOOL(GPMC_CS_CONFIG1, 4, 4, "time-para-granularity");
514 GPMC_GET_RAW(GPMC_CS_CONFIG1, 8, 9, "mux-add-data"); 514 GPMC_GET_RAW(GPMC_CS_CONFIG1, 8, 9, "mux-add-data");
515 GPMC_GET_RAW_MAX(GPMC_CS_CONFIG1, 12, 13, 515 GPMC_GET_RAW_SHIFT_MAX(GPMC_CS_CONFIG1, 12, 13, 1,
516 GPMC_CONFIG1_DEVICESIZE_MAX, "device-width"); 516 GPMC_CONFIG1_DEVICESIZE_MAX, "device-width");
517 GPMC_GET_RAW(GPMC_CS_CONFIG1, 16, 17, "wait-pin"); 517 GPMC_GET_RAW(GPMC_CS_CONFIG1, 16, 17, "wait-pin");
518 GPMC_GET_RAW_BOOL(GPMC_CS_CONFIG1, 21, 21, "wait-on-write"); 518 GPMC_GET_RAW_BOOL(GPMC_CS_CONFIG1, 21, 21, "wait-on-write");
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 2cba76e6fa3c..07bbd4cc1852 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -492,6 +492,7 @@ config ASPEED_LPC_CTRL
492 492
493config PCI_ENDPOINT_TEST 493config PCI_ENDPOINT_TEST
494 depends on PCI 494 depends on PCI
495 select CRC32
495 tristate "PCI Endpoint Test driver" 496 tristate "PCI Endpoint Test driver"
496 ---help--- 497 ---help---
497 Enable this configuration option to enable the host side test driver 498 Enable this configuration option to enable the host side test driver
diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c
index c5fd4259da33..b44a6aeb346d 100644
--- a/drivers/net/bonding/bond_3ad.c
+++ b/drivers/net/bonding/bond_3ad.c
@@ -2577,7 +2577,7 @@ int __bond_3ad_get_active_agg_info(struct bonding *bond,
2577 return -1; 2577 return -1;
2578 2578
2579 ad_info->aggregator_id = aggregator->aggregator_identifier; 2579 ad_info->aggregator_id = aggregator->aggregator_identifier;
2580 ad_info->ports = aggregator->num_of_ports; 2580 ad_info->ports = __agg_active_ports(aggregator);
2581 ad_info->actor_key = aggregator->actor_oper_aggregator_key; 2581 ad_info->actor_key = aggregator->actor_oper_aggregator_key;
2582 ad_info->partner_key = aggregator->partner_oper_aggregator_key; 2582 ad_info->partner_key = aggregator->partner_oper_aggregator_key;
2583 ether_addr_copy(ad_info->partner_system, 2583 ether_addr_copy(ad_info->partner_system,
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 2be78807fd6e..73313318399c 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -4271,10 +4271,10 @@ static int bond_check_params(struct bond_params *params)
4271 int arp_validate_value, fail_over_mac_value, primary_reselect_value, i; 4271 int arp_validate_value, fail_over_mac_value, primary_reselect_value, i;
4272 struct bond_opt_value newval; 4272 struct bond_opt_value newval;
4273 const struct bond_opt_value *valptr; 4273 const struct bond_opt_value *valptr;
4274 int arp_all_targets_value; 4274 int arp_all_targets_value = 0;
4275 u16 ad_actor_sys_prio = 0; 4275 u16 ad_actor_sys_prio = 0;
4276 u16 ad_user_port_key = 0; 4276 u16 ad_user_port_key = 0;
4277 __be32 arp_target[BOND_MAX_ARP_TARGETS]; 4277 __be32 arp_target[BOND_MAX_ARP_TARGETS] = { 0 };
4278 int arp_ip_count; 4278 int arp_ip_count;
4279 int bond_mode = BOND_MODE_ROUNDROBIN; 4279 int bond_mode = BOND_MODE_ROUNDROBIN;
4280 int xmit_hashtype = BOND_XMIT_POLICY_LAYER2; 4280 int xmit_hashtype = BOND_XMIT_POLICY_LAYER2;
@@ -4501,7 +4501,6 @@ static int bond_check_params(struct bond_params *params)
4501 arp_validate_value = 0; 4501 arp_validate_value = 0;
4502 } 4502 }
4503 4503
4504 arp_all_targets_value = 0;
4505 if (arp_all_targets) { 4504 if (arp_all_targets) {
4506 bond_opt_initstr(&newval, arp_all_targets); 4505 bond_opt_initstr(&newval, arp_all_targets);
4507 valptr = bond_opt_parse(bond_opt_get(BOND_OPT_ARP_ALL_TARGETS), 4506 valptr = bond_opt_parse(bond_opt_get(BOND_OPT_ARP_ALL_TARGETS),
diff --git a/drivers/net/ethernet/atheros/atlx/atl2.c b/drivers/net/ethernet/atheros/atlx/atl2.c
index 63f2deec2a52..77a1c03255de 100644
--- a/drivers/net/ethernet/atheros/atlx/atl2.c
+++ b/drivers/net/ethernet/atheros/atlx/atl2.c
@@ -1353,6 +1353,7 @@ static int atl2_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1353 if (pci_set_dma_mask(pdev, DMA_BIT_MASK(32)) && 1353 if (pci_set_dma_mask(pdev, DMA_BIT_MASK(32)) &&
1354 pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32))) { 1354 pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32))) {
1355 printk(KERN_ERR "atl2: No usable DMA configuration, aborting\n"); 1355 printk(KERN_ERR "atl2: No usable DMA configuration, aborting\n");
1356 err = -EIO;
1356 goto err_dma; 1357 goto err_dma;
1357 } 1358 }
1358 1359
@@ -1366,10 +1367,11 @@ static int atl2_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1366 * pcibios_set_master to do the needed arch specific settings */ 1367 * pcibios_set_master to do the needed arch specific settings */
1367 pci_set_master(pdev); 1368 pci_set_master(pdev);
1368 1369
1369 err = -ENOMEM;
1370 netdev = alloc_etherdev(sizeof(struct atl2_adapter)); 1370 netdev = alloc_etherdev(sizeof(struct atl2_adapter));
1371 if (!netdev) 1371 if (!netdev) {
1372 err = -ENOMEM;
1372 goto err_alloc_etherdev; 1373 goto err_alloc_etherdev;
1374 }
1373 1375
1374 SET_NETDEV_DEV(netdev, &pdev->dev); 1376 SET_NETDEV_DEV(netdev, &pdev->dev);
1375 1377
@@ -1408,8 +1410,6 @@ static int atl2_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1408 if (err) 1410 if (err)
1409 goto err_sw_init; 1411 goto err_sw_init;
1410 1412
1411 err = -EIO;
1412
1413 netdev->hw_features = NETIF_F_HW_VLAN_CTAG_RX; 1413 netdev->hw_features = NETIF_F_HW_VLAN_CTAG_RX;
1414 netdev->features |= (NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX); 1414 netdev->features |= (NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX);
1415 1415
diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c
index 765400b62168..2dfca96a63b6 100644
--- a/drivers/net/usb/smsc95xx.c
+++ b/drivers/net/usb/smsc95xx.c
@@ -681,7 +681,7 @@ static int smsc95xx_set_features(struct net_device *netdev,
681 if (ret < 0) 681 if (ret < 0)
682 return ret; 682 return ret;
683 683
684 if (features & NETIF_F_HW_CSUM) 684 if (features & NETIF_F_IP_CSUM)
685 read_buf |= Tx_COE_EN_; 685 read_buf |= Tx_COE_EN_;
686 else 686 else
687 read_buf &= ~Tx_COE_EN_; 687 read_buf &= ~Tx_COE_EN_;
@@ -1279,12 +1279,19 @@ static int smsc95xx_bind(struct usbnet *dev, struct usb_interface *intf)
1279 1279
1280 spin_lock_init(&pdata->mac_cr_lock); 1280 spin_lock_init(&pdata->mac_cr_lock);
1281 1281
1282 /* LAN95xx devices do not alter the computed checksum of 0 to 0xffff.
1283 * RFC 2460, ipv6 UDP calculated checksum yields a result of zero must
1284 * be changed to 0xffff. RFC 768, ipv4 UDP computed checksum is zero,
1285 * it is transmitted as all ones. The zero transmitted checksum means
1286 * transmitter generated no checksum. Hence, enable csum offload only
1287 * for ipv4 packets.
1288 */
1282 if (DEFAULT_TX_CSUM_ENABLE) 1289 if (DEFAULT_TX_CSUM_ENABLE)
1283 dev->net->features |= NETIF_F_HW_CSUM; 1290 dev->net->features |= NETIF_F_IP_CSUM;
1284 if (DEFAULT_RX_CSUM_ENABLE) 1291 if (DEFAULT_RX_CSUM_ENABLE)
1285 dev->net->features |= NETIF_F_RXCSUM; 1292 dev->net->features |= NETIF_F_RXCSUM;
1286 1293
1287 dev->net->hw_features = NETIF_F_HW_CSUM | NETIF_F_RXCSUM; 1294 dev->net->hw_features = NETIF_F_IP_CSUM | NETIF_F_RXCSUM;
1288 1295
1289 smsc95xx_init_mac_address(dev); 1296 smsc95xx_init_mac_address(dev);
1290 1297
diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c
index 70e689bf1cad..dca7165fabcf 100644
--- a/drivers/nvme/host/fc.c
+++ b/drivers/nvme/host/fc.c
@@ -1754,6 +1754,10 @@ nvme_fc_error_recovery(struct nvme_fc_ctrl *ctrl, char *errmsg)
1754 dev_info(ctrl->ctrl.device, 1754 dev_info(ctrl->ctrl.device,
1755 "NVME-FC{%d}: resetting controller\n", ctrl->cnum); 1755 "NVME-FC{%d}: resetting controller\n", ctrl->cnum);
1756 1756
1757 /* stop the queues on error, cleanup is in reset thread */
1758 if (ctrl->queue_count > 1)
1759 nvme_stop_queues(&ctrl->ctrl);
1760
1757 if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_RECONNECTING)) { 1761 if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_RECONNECTING)) {
1758 dev_err(ctrl->ctrl.device, 1762 dev_err(ctrl->ctrl.device,
1759 "NVME-FC{%d}: error_recovery: Couldn't change state " 1763 "NVME-FC{%d}: error_recovery: Couldn't change state "
@@ -2720,6 +2724,12 @@ nvme_fc_init_ctrl(struct device *dev, struct nvmf_ctrl_options *opts,
2720 unsigned long flags; 2724 unsigned long flags;
2721 int ret, idx; 2725 int ret, idx;
2722 2726
2727 if (!(rport->remoteport.port_role &
2728 (FC_PORT_ROLE_NVME_DISCOVERY | FC_PORT_ROLE_NVME_TARGET))) {
2729 ret = -EBADR;
2730 goto out_fail;
2731 }
2732
2723 ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL); 2733 ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL);
2724 if (!ctrl) { 2734 if (!ctrl) {
2725 ret = -ENOMEM; 2735 ret = -ENOMEM;
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index fed803232edc..4c2ff2bb26bc 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -1506,6 +1506,11 @@ static inline void nvme_release_cmb(struct nvme_dev *dev)
1506 if (dev->cmb) { 1506 if (dev->cmb) {
1507 iounmap(dev->cmb); 1507 iounmap(dev->cmb);
1508 dev->cmb = NULL; 1508 dev->cmb = NULL;
1509 if (dev->cmbsz) {
1510 sysfs_remove_file_from_group(&dev->ctrl.device->kobj,
1511 &dev_attr_cmb.attr, NULL);
1512 dev->cmbsz = 0;
1513 }
1509 } 1514 }
1510} 1515}
1511 1516
@@ -1779,6 +1784,7 @@ static void nvme_pci_disable(struct nvme_dev *dev)
1779{ 1784{
1780 struct pci_dev *pdev = to_pci_dev(dev->dev); 1785 struct pci_dev *pdev = to_pci_dev(dev->dev);
1781 1786
1787 nvme_release_cmb(dev);
1782 pci_free_irq_vectors(pdev); 1788 pci_free_irq_vectors(pdev);
1783 1789
1784 if (pci_is_enabled(pdev)) { 1790 if (pci_is_enabled(pdev)) {
@@ -2184,7 +2190,6 @@ static void nvme_remove(struct pci_dev *pdev)
2184 nvme_dev_disable(dev, true); 2190 nvme_dev_disable(dev, true);
2185 nvme_dev_remove_admin(dev); 2191 nvme_dev_remove_admin(dev);
2186 nvme_free_queues(dev, 0); 2192 nvme_free_queues(dev, 0);
2187 nvme_release_cmb(dev);
2188 nvme_release_prp_pools(dev); 2193 nvme_release_prp_pools(dev);
2189 nvme_dev_unmap(dev); 2194 nvme_dev_unmap(dev);
2190 nvme_put_ctrl(&dev->ctrl); 2195 nvme_put_ctrl(&dev->ctrl);
diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c
index cf90713043da..eb9399ac97cf 100644
--- a/drivers/nvme/target/core.c
+++ b/drivers/nvme/target/core.c
@@ -529,6 +529,12 @@ fail:
529} 529}
530EXPORT_SYMBOL_GPL(nvmet_req_init); 530EXPORT_SYMBOL_GPL(nvmet_req_init);
531 531
532void nvmet_req_uninit(struct nvmet_req *req)
533{
534 percpu_ref_put(&req->sq->ref);
535}
536EXPORT_SYMBOL_GPL(nvmet_req_uninit);
537
532static inline bool nvmet_cc_en(u32 cc) 538static inline bool nvmet_cc_en(u32 cc)
533{ 539{
534 return cc & 0x1; 540 return cc & 0x1;
diff --git a/drivers/nvme/target/fc.c b/drivers/nvme/target/fc.c
index 62eba29c85fb..2006fae61980 100644
--- a/drivers/nvme/target/fc.c
+++ b/drivers/nvme/target/fc.c
@@ -517,9 +517,7 @@ nvmet_fc_queue_to_cpu(struct nvmet_fc_tgtport *tgtport, int qid)
517{ 517{
518 int cpu, idx, cnt; 518 int cpu, idx, cnt;
519 519
520 if (!(tgtport->ops->target_features & 520 if (tgtport->ops->max_hw_queues == 1)
521 NVMET_FCTGTFEAT_NEEDS_CMD_CPUSCHED) ||
522 tgtport->ops->max_hw_queues == 1)
523 return WORK_CPU_UNBOUND; 521 return WORK_CPU_UNBOUND;
524 522
525 /* Simple cpu selection based on qid modulo active cpu count */ 523 /* Simple cpu selection based on qid modulo active cpu count */
diff --git a/drivers/nvme/target/fcloop.c b/drivers/nvme/target/fcloop.c
index 15551ef79c8c..294a6611fb24 100644
--- a/drivers/nvme/target/fcloop.c
+++ b/drivers/nvme/target/fcloop.c
@@ -698,7 +698,6 @@ static struct nvmet_fc_target_template tgttemplate = {
698 .dma_boundary = FCLOOP_DMABOUND_4G, 698 .dma_boundary = FCLOOP_DMABOUND_4G,
699 /* optional features */ 699 /* optional features */
700 .target_features = NVMET_FCTGTFEAT_CMD_IN_ISR | 700 .target_features = NVMET_FCTGTFEAT_CMD_IN_ISR |
701 NVMET_FCTGTFEAT_NEEDS_CMD_CPUSCHED |
702 NVMET_FCTGTFEAT_OPDONE_IN_ISR, 701 NVMET_FCTGTFEAT_OPDONE_IN_ISR,
703 /* sizes of additional private data for data structures */ 702 /* sizes of additional private data for data structures */
704 .target_priv_sz = sizeof(struct fcloop_tport), 703 .target_priv_sz = sizeof(struct fcloop_tport),
diff --git a/drivers/nvme/target/nvmet.h b/drivers/nvme/target/nvmet.h
index 7cb77ba5993b..cfc5c7fb0ab7 100644
--- a/drivers/nvme/target/nvmet.h
+++ b/drivers/nvme/target/nvmet.h
@@ -261,6 +261,7 @@ u16 nvmet_parse_fabrics_cmd(struct nvmet_req *req);
261 261
262bool nvmet_req_init(struct nvmet_req *req, struct nvmet_cq *cq, 262bool nvmet_req_init(struct nvmet_req *req, struct nvmet_cq *cq,
263 struct nvmet_sq *sq, struct nvmet_fabrics_ops *ops); 263 struct nvmet_sq *sq, struct nvmet_fabrics_ops *ops);
264void nvmet_req_uninit(struct nvmet_req *req);
264void nvmet_req_complete(struct nvmet_req *req, u16 status); 265void nvmet_req_complete(struct nvmet_req *req, u16 status);
265 266
266void nvmet_cq_setup(struct nvmet_ctrl *ctrl, struct nvmet_cq *cq, u16 qid, 267void nvmet_cq_setup(struct nvmet_ctrl *ctrl, struct nvmet_cq *cq, u16 qid,
diff --git a/drivers/nvme/target/rdma.c b/drivers/nvme/target/rdma.c
index 99c69018a35f..9e45cde63376 100644
--- a/drivers/nvme/target/rdma.c
+++ b/drivers/nvme/target/rdma.c
@@ -567,6 +567,7 @@ static void nvmet_rdma_read_data_done(struct ib_cq *cq, struct ib_wc *wc)
567 rsp->n_rdma = 0; 567 rsp->n_rdma = 0;
568 568
569 if (unlikely(wc->status != IB_WC_SUCCESS)) { 569 if (unlikely(wc->status != IB_WC_SUCCESS)) {
570 nvmet_req_uninit(&rsp->req);
570 nvmet_rdma_release_rsp(rsp); 571 nvmet_rdma_release_rsp(rsp);
571 if (wc->status != IB_WC_WR_FLUSH_ERR) { 572 if (wc->status != IB_WC_WR_FLUSH_ERR) {
572 pr_info("RDMA READ for CQE 0x%p failed with status %s (%d).\n", 573 pr_info("RDMA READ for CQE 0x%p failed with status %s (%d).\n",
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 3080d9dd031d..43bd69dceabf 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -507,6 +507,9 @@ void *__unflatten_device_tree(const void *blob,
507 507
508 /* Allocate memory for the expanded device tree */ 508 /* Allocate memory for the expanded device tree */
509 mem = dt_alloc(size + 4, __alignof__(struct device_node)); 509 mem = dt_alloc(size + 4, __alignof__(struct device_node));
510 if (!mem)
511 return NULL;
512
510 memset(mem, 0, size); 513 memset(mem, 0, size);
511 514
512 *(__be32 *)(mem + size) = cpu_to_be32(0xdeadbeef); 515 *(__be32 *)(mem + size) = cpu_to_be32(0xdeadbeef);
diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
index 4dec07ea510f..d507c3569a88 100644
--- a/drivers/of/of_reserved_mem.c
+++ b/drivers/of/of_reserved_mem.c
@@ -197,7 +197,7 @@ static int __init __reserved_mem_init_node(struct reserved_mem *rmem)
197 const struct of_device_id *i; 197 const struct of_device_id *i;
198 198
199 for (i = __reservedmem_of_table; i < &__rmem_of_table_sentinel; i++) { 199 for (i = __reservedmem_of_table; i < &__rmem_of_table_sentinel; i++) {
200 int const (*initfn)(struct reserved_mem *rmem) = i->data; 200 reservedmem_of_init_fn initfn = i->data;
201 const char *compat = i->compatible; 201 const char *compat = i->compatible;
202 202
203 if (!of_flat_dt_is_compatible(rmem->fdt_node, compat)) 203 if (!of_flat_dt_is_compatible(rmem->fdt_node, compat))
diff --git a/drivers/powercap/powercap_sys.c b/drivers/powercap/powercap_sys.c
index 14bde0db8c24..5b10b50f8686 100644
--- a/drivers/powercap/powercap_sys.c
+++ b/drivers/powercap/powercap_sys.c
@@ -538,6 +538,7 @@ struct powercap_zone *powercap_register_zone(
538 538
539 power_zone->id = result; 539 power_zone->id = result;
540 idr_init(&power_zone->idr); 540 idr_init(&power_zone->idr);
541 result = -ENOMEM;
541 power_zone->name = kstrdup(name, GFP_KERNEL); 542 power_zone->name = kstrdup(name, GFP_KERNEL);
542 if (!power_zone->name) 543 if (!power_zone->name)
543 goto err_name_alloc; 544 goto err_name_alloc;
diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
index b3de973a6260..9dca53df3584 100644
--- a/drivers/rtc/rtc-cmos.c
+++ b/drivers/rtc/rtc-cmos.c
@@ -1088,7 +1088,7 @@ static u32 rtc_handler(void *context)
1088 } 1088 }
1089 spin_unlock_irqrestore(&rtc_lock, flags); 1089 spin_unlock_irqrestore(&rtc_lock, flags);
1090 1090
1091 pm_wakeup_event(dev, 0); 1091 pm_wakeup_hard_event(dev);
1092 acpi_clear_event(ACPI_EVENT_RTC); 1092 acpi_clear_event(ACPI_EVENT_RTC);
1093 acpi_disable_event(ACPI_EVENT_RTC, 0); 1093 acpi_disable_event(ACPI_EVENT_RTC, 0);
1094 return ACPI_INTERRUPT_HANDLED; 1094 return ACPI_INTERRUPT_HANDLED;
diff --git a/drivers/scsi/cxlflash/Kconfig b/drivers/scsi/cxlflash/Kconfig
index c052104e523e..a011c5dbf214 100644
--- a/drivers/scsi/cxlflash/Kconfig
+++ b/drivers/scsi/cxlflash/Kconfig
@@ -5,6 +5,7 @@
5config CXLFLASH 5config CXLFLASH
6 tristate "Support for IBM CAPI Flash" 6 tristate "Support for IBM CAPI Flash"
7 depends on PCI && SCSI && CXL && EEH 7 depends on PCI && SCSI && CXL && EEH
8 select IRQ_POLL
8 default m 9 default m
9 help 10 help
10 Allows CAPI Accelerated IO to Flash 11 Allows CAPI Accelerated IO to Flash
diff --git a/drivers/scsi/libfc/fc_fcp.c b/drivers/scsi/libfc/fc_fcp.c
index a808e8ef1d08..234352da5c3c 100644
--- a/drivers/scsi/libfc/fc_fcp.c
+++ b/drivers/scsi/libfc/fc_fcp.c
@@ -407,11 +407,12 @@ unlock:
407 * can_queue. Eventually we will hit the point where we run 407 * can_queue. Eventually we will hit the point where we run
408 * on all reserved structs. 408 * on all reserved structs.
409 */ 409 */
410static void fc_fcp_can_queue_ramp_down(struct fc_lport *lport) 410static bool fc_fcp_can_queue_ramp_down(struct fc_lport *lport)
411{ 411{
412 struct fc_fcp_internal *si = fc_get_scsi_internal(lport); 412 struct fc_fcp_internal *si = fc_get_scsi_internal(lport);
413 unsigned long flags; 413 unsigned long flags;
414 int can_queue; 414 int can_queue;
415 bool changed = false;
415 416
416 spin_lock_irqsave(lport->host->host_lock, flags); 417 spin_lock_irqsave(lport->host->host_lock, flags);
417 418
@@ -427,9 +428,11 @@ static void fc_fcp_can_queue_ramp_down(struct fc_lport *lport)
427 if (!can_queue) 428 if (!can_queue)
428 can_queue = 1; 429 can_queue = 1;
429 lport->host->can_queue = can_queue; 430 lport->host->can_queue = can_queue;
431 changed = true;
430 432
431unlock: 433unlock:
432 spin_unlock_irqrestore(lport->host->host_lock, flags); 434 spin_unlock_irqrestore(lport->host->host_lock, flags);
435 return changed;
433} 436}
434 437
435/* 438/*
@@ -1896,11 +1899,11 @@ int fc_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *sc_cmd)
1896 1899
1897 if (!fc_fcp_lport_queue_ready(lport)) { 1900 if (!fc_fcp_lport_queue_ready(lport)) {
1898 if (lport->qfull) { 1901 if (lport->qfull) {
1899 fc_fcp_can_queue_ramp_down(lport); 1902 if (fc_fcp_can_queue_ramp_down(lport))
1900 shost_printk(KERN_ERR, lport->host, 1903 shost_printk(KERN_ERR, lport->host,
1901 "libfc: queue full, " 1904 "libfc: queue full, "
1902 "reducing can_queue to %d.\n", 1905 "reducing can_queue to %d.\n",
1903 lport->host->can_queue); 1906 lport->host->can_queue);
1904 } 1907 }
1905 rc = SCSI_MLQUEUE_HOST_BUSY; 1908 rc = SCSI_MLQUEUE_HOST_BUSY;
1906 goto out; 1909 goto out;
diff --git a/drivers/scsi/lpfc/lpfc_crtn.h b/drivers/scsi/lpfc/lpfc_crtn.h
index 944b32ca4931..1c55408ac718 100644
--- a/drivers/scsi/lpfc/lpfc_crtn.h
+++ b/drivers/scsi/lpfc/lpfc_crtn.h
@@ -294,6 +294,7 @@ int lpfc_selective_reset(struct lpfc_hba *);
294void lpfc_reset_barrier(struct lpfc_hba *); 294void lpfc_reset_barrier(struct lpfc_hba *);
295int lpfc_sli_brdready(struct lpfc_hba *, uint32_t); 295int lpfc_sli_brdready(struct lpfc_hba *, uint32_t);
296int lpfc_sli_brdkill(struct lpfc_hba *); 296int lpfc_sli_brdkill(struct lpfc_hba *);
297int lpfc_sli_chipset_init(struct lpfc_hba *phba);
297int lpfc_sli_brdreset(struct lpfc_hba *); 298int lpfc_sli_brdreset(struct lpfc_hba *);
298int lpfc_sli_brdrestart(struct lpfc_hba *); 299int lpfc_sli_brdrestart(struct lpfc_hba *);
299int lpfc_sli_hba_setup(struct lpfc_hba *); 300int lpfc_sli_hba_setup(struct lpfc_hba *);
diff --git a/drivers/scsi/lpfc/lpfc_ct.c b/drivers/scsi/lpfc/lpfc_ct.c
index 1487406aea77..c7962dae4dab 100644
--- a/drivers/scsi/lpfc/lpfc_ct.c
+++ b/drivers/scsi/lpfc/lpfc_ct.c
@@ -630,7 +630,7 @@ lpfc_ns_rsp(struct lpfc_vport *vport, struct lpfc_dmabuf *mp, uint8_t fc4_type,
630 NLP_EVT_DEVICE_RECOVERY); 630 NLP_EVT_DEVICE_RECOVERY);
631 spin_lock_irq(shost->host_lock); 631 spin_lock_irq(shost->host_lock);
632 ndlp->nlp_flag &= ~NLP_NVMET_RECOV; 632 ndlp->nlp_flag &= ~NLP_NVMET_RECOV;
633 spin_lock_irq(shost->host_lock); 633 spin_unlock_irq(shost->host_lock);
634 } 634 }
635 } 635 }
636 636
diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
index 90ae354a9c45..4b1eb98c228d 100644
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -3602,6 +3602,13 @@ lpfc_get_wwpn(struct lpfc_hba *phba)
3602 LPFC_MBOXQ_t *mboxq; 3602 LPFC_MBOXQ_t *mboxq;
3603 MAILBOX_t *mb; 3603 MAILBOX_t *mb;
3604 3604
3605 if (phba->sli_rev < LPFC_SLI_REV4) {
3606 /* Reset the port first */
3607 lpfc_sli_brdrestart(phba);
3608 rc = lpfc_sli_chipset_init(phba);
3609 if (rc)
3610 return (uint64_t)-1;
3611 }
3605 3612
3606 mboxq = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, 3613 mboxq = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool,
3607 GFP_KERNEL); 3614 GFP_KERNEL);
@@ -8847,7 +8854,7 @@ lpfc_sli4_queue_unset(struct lpfc_hba *phba)
8847 lpfc_wq_destroy(phba, phba->sli4_hba.nvmels_wq); 8854 lpfc_wq_destroy(phba, phba->sli4_hba.nvmels_wq);
8848 8855
8849 /* Unset ELS work queue */ 8856 /* Unset ELS work queue */
8850 if (phba->sli4_hba.els_cq) 8857 if (phba->sli4_hba.els_wq)
8851 lpfc_wq_destroy(phba, phba->sli4_hba.els_wq); 8858 lpfc_wq_destroy(phba, phba->sli4_hba.els_wq);
8852 8859
8853 /* Unset unsolicited receive queue */ 8860 /* Unset unsolicited receive queue */
diff --git a/drivers/scsi/lpfc/lpfc_nvmet.c b/drivers/scsi/lpfc/lpfc_nvmet.c
index 94434e621c33..0488580eea12 100644
--- a/drivers/scsi/lpfc/lpfc_nvmet.c
+++ b/drivers/scsi/lpfc/lpfc_nvmet.c
@@ -764,7 +764,6 @@ lpfc_nvmet_create_targetport(struct lpfc_hba *phba)
764 lpfc_tgttemplate.max_sgl_segments = phba->cfg_nvme_seg_cnt + 1; 764 lpfc_tgttemplate.max_sgl_segments = phba->cfg_nvme_seg_cnt + 1;
765 lpfc_tgttemplate.max_hw_queues = phba->cfg_nvme_io_channel; 765 lpfc_tgttemplate.max_hw_queues = phba->cfg_nvme_io_channel;
766 lpfc_tgttemplate.target_features = NVMET_FCTGTFEAT_READDATA_RSP | 766 lpfc_tgttemplate.target_features = NVMET_FCTGTFEAT_READDATA_RSP |
767 NVMET_FCTGTFEAT_NEEDS_CMD_CPUSCHED |
768 NVMET_FCTGTFEAT_CMD_IN_ISR | 767 NVMET_FCTGTFEAT_CMD_IN_ISR |
769 NVMET_FCTGTFEAT_OPDONE_IN_ISR; 768 NVMET_FCTGTFEAT_OPDONE_IN_ISR;
770 769
diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
index cf19f4976f5f..2a4fc00dfa9b 100644
--- a/drivers/scsi/lpfc/lpfc_sli.c
+++ b/drivers/scsi/lpfc/lpfc_sli.c
@@ -4204,13 +4204,16 @@ lpfc_sli_brdreset(struct lpfc_hba *phba)
4204 /* Reset HBA */ 4204 /* Reset HBA */
4205 lpfc_printf_log(phba, KERN_INFO, LOG_SLI, 4205 lpfc_printf_log(phba, KERN_INFO, LOG_SLI,
4206 "0325 Reset HBA Data: x%x x%x\n", 4206 "0325 Reset HBA Data: x%x x%x\n",
4207 phba->pport->port_state, psli->sli_flag); 4207 (phba->pport) ? phba->pport->port_state : 0,
4208 psli->sli_flag);
4208 4209
4209 /* perform board reset */ 4210 /* perform board reset */
4210 phba->fc_eventTag = 0; 4211 phba->fc_eventTag = 0;
4211 phba->link_events = 0; 4212 phba->link_events = 0;
4212 phba->pport->fc_myDID = 0; 4213 if (phba->pport) {
4213 phba->pport->fc_prevDID = 0; 4214 phba->pport->fc_myDID = 0;
4215 phba->pport->fc_prevDID = 0;
4216 }
4214 4217
4215 /* Turn off parity checking and serr during the physical reset */ 4218 /* Turn off parity checking and serr during the physical reset */
4216 pci_read_config_word(phba->pcidev, PCI_COMMAND, &cfg_value); 4219 pci_read_config_word(phba->pcidev, PCI_COMMAND, &cfg_value);
@@ -4336,7 +4339,8 @@ lpfc_sli_brdrestart_s3(struct lpfc_hba *phba)
4336 /* Restart HBA */ 4339 /* Restart HBA */
4337 lpfc_printf_log(phba, KERN_INFO, LOG_SLI, 4340 lpfc_printf_log(phba, KERN_INFO, LOG_SLI,
4338 "0337 Restart HBA Data: x%x x%x\n", 4341 "0337 Restart HBA Data: x%x x%x\n",
4339 phba->pport->port_state, psli->sli_flag); 4342 (phba->pport) ? phba->pport->port_state : 0,
4343 psli->sli_flag);
4340 4344
4341 word0 = 0; 4345 word0 = 0;
4342 mb = (MAILBOX_t *) &word0; 4346 mb = (MAILBOX_t *) &word0;
@@ -4350,7 +4354,7 @@ lpfc_sli_brdrestart_s3(struct lpfc_hba *phba)
4350 readl(to_slim); /* flush */ 4354 readl(to_slim); /* flush */
4351 4355
4352 /* Only skip post after fc_ffinit is completed */ 4356 /* Only skip post after fc_ffinit is completed */
4353 if (phba->pport->port_state) 4357 if (phba->pport && phba->pport->port_state)
4354 word0 = 1; /* This is really setting up word1 */ 4358 word0 = 1; /* This is really setting up word1 */
4355 else 4359 else
4356 word0 = 0; /* This is really setting up word1 */ 4360 word0 = 0; /* This is really setting up word1 */
@@ -4359,7 +4363,8 @@ lpfc_sli_brdrestart_s3(struct lpfc_hba *phba)
4359 readl(to_slim); /* flush */ 4363 readl(to_slim); /* flush */
4360 4364
4361 lpfc_sli_brdreset(phba); 4365 lpfc_sli_brdreset(phba);
4362 phba->pport->stopped = 0; 4366 if (phba->pport)
4367 phba->pport->stopped = 0;
4363 phba->link_state = LPFC_INIT_START; 4368 phba->link_state = LPFC_INIT_START;
4364 phba->hba_flag = 0; 4369 phba->hba_flag = 0;
4365 spin_unlock_irq(&phba->hbalock); 4370 spin_unlock_irq(&phba->hbalock);
@@ -4446,7 +4451,7 @@ lpfc_sli_brdrestart(struct lpfc_hba *phba)
4446 * iteration, the function will restart the HBA again. The function returns 4451 * iteration, the function will restart the HBA again. The function returns
4447 * zero if HBA successfully restarted else returns negative error code. 4452 * zero if HBA successfully restarted else returns negative error code.
4448 **/ 4453 **/
4449static int 4454int
4450lpfc_sli_chipset_init(struct lpfc_hba *phba) 4455lpfc_sli_chipset_init(struct lpfc_hba *phba)
4451{ 4456{
4452 uint32_t status, i = 0; 4457 uint32_t status, i = 0;
diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
index a4aadf5f4dc6..1cc814f1505a 100644
--- a/drivers/scsi/pmcraid.c
+++ b/drivers/scsi/pmcraid.c
@@ -3770,9 +3770,6 @@ static long pmcraid_ioctl_passthrough(
3770 pmcraid_err("couldn't build passthrough ioadls\n"); 3770 pmcraid_err("couldn't build passthrough ioadls\n");
3771 goto out_free_cmd; 3771 goto out_free_cmd;
3772 } 3772 }
3773 } else if (request_size < 0) {
3774 rc = -EINVAL;
3775 goto out_free_cmd;
3776 } 3773 }
3777 3774
3778 /* If data is being written into the device, copy the data from user 3775 /* If data is being written into the device, copy the data from user
diff --git a/drivers/scsi/qedf/qedf.h b/drivers/scsi/qedf/qedf.h
index 40aeb6bb96a2..07ee88200e91 100644
--- a/drivers/scsi/qedf/qedf.h
+++ b/drivers/scsi/qedf/qedf.h
@@ -259,7 +259,7 @@ struct qedf_io_log {
259 uint16_t task_id; 259 uint16_t task_id;
260 uint32_t port_id; /* Remote port fabric ID */ 260 uint32_t port_id; /* Remote port fabric ID */
261 int lun; 261 int lun;
262 char op; /* SCSI CDB */ 262 unsigned char op; /* SCSI CDB */
263 uint8_t lba[4]; 263 uint8_t lba[4];
264 unsigned int bufflen; /* SCSI buffer length */ 264 unsigned int bufflen; /* SCSI buffer length */
265 unsigned int sg_count; /* Number of SG elements */ 265 unsigned int sg_count; /* Number of SG elements */
diff --git a/drivers/scsi/qedf/qedf_els.c b/drivers/scsi/qedf/qedf_els.c
index c505d41f6dc8..90627033bde6 100644
--- a/drivers/scsi/qedf/qedf_els.c
+++ b/drivers/scsi/qedf/qedf_els.c
@@ -109,7 +109,7 @@ retry_els:
109 did = fcport->rdata->ids.port_id; 109 did = fcport->rdata->ids.port_id;
110 sid = fcport->sid; 110 sid = fcport->sid;
111 111
112 __fc_fill_fc_hdr(fc_hdr, FC_RCTL_ELS_REQ, sid, did, 112 __fc_fill_fc_hdr(fc_hdr, FC_RCTL_ELS_REQ, did, sid,
113 FC_TYPE_ELS, FC_FC_FIRST_SEQ | FC_FC_END_SEQ | 113 FC_TYPE_ELS, FC_FC_FIRST_SEQ | FC_FC_END_SEQ |
114 FC_FC_SEQ_INIT, 0); 114 FC_FC_SEQ_INIT, 0);
115 115
diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
index cceddd995a4b..a5c97342fd5d 100644
--- a/drivers/scsi/qedf/qedf_main.c
+++ b/drivers/scsi/qedf/qedf_main.c
@@ -2895,7 +2895,7 @@ static int __qedf_probe(struct pci_dev *pdev, int mode)
2895 slowpath_params.drv_minor = QEDF_DRIVER_MINOR_VER; 2895 slowpath_params.drv_minor = QEDF_DRIVER_MINOR_VER;
2896 slowpath_params.drv_rev = QEDF_DRIVER_REV_VER; 2896 slowpath_params.drv_rev = QEDF_DRIVER_REV_VER;
2897 slowpath_params.drv_eng = QEDF_DRIVER_ENG_VER; 2897 slowpath_params.drv_eng = QEDF_DRIVER_ENG_VER;
2898 memcpy(slowpath_params.name, "qedf", QED_DRV_VER_STR_SIZE); 2898 strncpy(slowpath_params.name, "qedf", QED_DRV_VER_STR_SIZE);
2899 rc = qed_ops->common->slowpath_start(qedf->cdev, &slowpath_params); 2899 rc = qed_ops->common->slowpath_start(qedf->cdev, &slowpath_params);
2900 if (rc) { 2900 if (rc) {
2901 QEDF_ERR(&(qedf->dbg_ctx), "Cannot start slowpath.\n"); 2901 QEDF_ERR(&(qedf->dbg_ctx), "Cannot start slowpath.\n");
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index 7bfbcfa7af40..61cdd99ae41e 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -763,6 +763,8 @@ struct scsi_device *__scsi_device_lookup(struct Scsi_Host *shost,
763 struct scsi_device *sdev; 763 struct scsi_device *sdev;
764 764
765 list_for_each_entry(sdev, &shost->__devices, siblings) { 765 list_for_each_entry(sdev, &shost->__devices, siblings) {
766 if (sdev->sdev_state == SDEV_DEL)
767 continue;
766 if (sdev->channel == channel && sdev->id == id && 768 if (sdev->channel == channel && sdev->id == id &&
767 sdev->lun ==lun) 769 sdev->lun ==lun)
768 return sdev; 770 return sdev;
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 814a4bd8405d..e31f1cc90b81 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -30,6 +30,7 @@
30#include <scsi/scsi_driver.h> 30#include <scsi/scsi_driver.h>
31#include <scsi/scsi_eh.h> 31#include <scsi/scsi_eh.h>
32#include <scsi/scsi_host.h> 32#include <scsi/scsi_host.h>
33#include <scsi/scsi_transport.h> /* __scsi_init_queue() */
33#include <scsi/scsi_dh.h> 34#include <scsi/scsi_dh.h>
34 35
35#include <trace/events/scsi.h> 36#include <trace/events/scsi.h>
diff --git a/drivers/soc/bcm/brcmstb/common.c b/drivers/soc/bcm/brcmstb/common.c
index b6195fdf0d00..22e98a90468c 100644
--- a/drivers/soc/bcm/brcmstb/common.c
+++ b/drivers/soc/bcm/brcmstb/common.c
@@ -49,7 +49,7 @@ static const struct of_device_id sun_top_ctrl_match[] = {
49 { .compatible = "brcm,bcm7420-sun-top-ctrl", }, 49 { .compatible = "brcm,bcm7420-sun-top-ctrl", },
50 { .compatible = "brcm,bcm7425-sun-top-ctrl", }, 50 { .compatible = "brcm,bcm7425-sun-top-ctrl", },
51 { .compatible = "brcm,bcm7429-sun-top-ctrl", }, 51 { .compatible = "brcm,bcm7429-sun-top-ctrl", },
52 { .compatible = "brcm,bcm7425-sun-top-ctrl", }, 52 { .compatible = "brcm,bcm7435-sun-top-ctrl", },
53 { .compatible = "brcm,brcmstb-sun-top-ctrl", }, 53 { .compatible = "brcm,brcmstb-sun-top-ctrl", },
54 { } 54 { }
55}; 55};
diff --git a/drivers/soc/imx/Kconfig b/drivers/soc/imx/Kconfig
index 357a5d8f8da0..a5b86a28f343 100644
--- a/drivers/soc/imx/Kconfig
+++ b/drivers/soc/imx/Kconfig
@@ -2,8 +2,9 @@ menu "i.MX SoC drivers"
2 2
3config IMX7_PM_DOMAINS 3config IMX7_PM_DOMAINS
4 bool "i.MX7 PM domains" 4 bool "i.MX7 PM domains"
5 select PM_GENERIC_DOMAINS
6 depends on SOC_IMX7D || (COMPILE_TEST && OF) 5 depends on SOC_IMX7D || (COMPILE_TEST && OF)
6 depends on PM
7 select PM_GENERIC_DOMAINS
7 default y if SOC_IMX7D 8 default y if SOC_IMX7D
8 9
9endmenu 10endmenu
diff --git a/drivers/staging/android/ion/devicetree.txt b/drivers/staging/android/ion/devicetree.txt
deleted file mode 100644
index 168715271f06..000000000000
--- a/drivers/staging/android/ion/devicetree.txt
+++ /dev/null
@@ -1,51 +0,0 @@
1Ion Memory Manager
2
3Ion is a memory manager that allows for sharing of buffers via dma-buf.
4Ion allows for different types of allocation via an abstraction called
5a 'heap'. A heap represents a specific type of memory. Each heap has
6a different type. There can be multiple instances of the same heap
7type.
8
9Specific heap instances are tied to heap IDs. Heap IDs are not to be specified
10in the devicetree.
11
12Required properties for Ion
13
14- compatible: "linux,ion" PLUS a compatible property for the device
15
16All child nodes of a linux,ion node are interpreted as heaps
17
18required properties for heaps
19
20- compatible: compatible string for a heap type PLUS a compatible property
21for the specific instance of the heap. Current heap types
22-- linux,ion-heap-system
23-- linux,ion-heap-system-contig
24-- linux,ion-heap-carveout
25-- linux,ion-heap-chunk
26-- linux,ion-heap-dma
27-- linux,ion-heap-custom
28
29Optional properties
30- memory-region: A phandle to a memory region. Required for DMA heap type
31(see reserved-memory.txt for details on the reservation)
32
33Example:
34
35 ion {
36 compatbile = "hisilicon,ion", "linux,ion";
37
38 ion-system-heap {
39 compatbile = "hisilicon,system-heap", "linux,ion-heap-system"
40 };
41
42 ion-camera-region {
43 compatible = "hisilicon,camera-heap", "linux,ion-heap-dma"
44 memory-region = <&camera_region>;
45 };
46
47 ion-fb-region {
48 compatbile = "hisilicon,fb-heap", "linux,ion-heap-dma"
49 memory-region = <&fb_region>;
50 };
51 }
diff --git a/drivers/staging/ccree/ssi_request_mgr.c b/drivers/staging/ccree/ssi_request_mgr.c
index 522bd62c102e..8611adf3bb2e 100644
--- a/drivers/staging/ccree/ssi_request_mgr.c
+++ b/drivers/staging/ccree/ssi_request_mgr.c
@@ -376,7 +376,6 @@ int send_request(
376 rc = ssi_power_mgr_runtime_get(&drvdata->plat_dev->dev); 376 rc = ssi_power_mgr_runtime_get(&drvdata->plat_dev->dev);
377 if (rc != 0) { 377 if (rc != 0) {
378 SSI_LOG_ERR("ssi_power_mgr_runtime_get returned %x\n",rc); 378 SSI_LOG_ERR("ssi_power_mgr_runtime_get returned %x\n",rc);
379 spin_unlock_bh(&req_mgr_h->hw_lock);
380 return rc; 379 return rc;
381 } 380 }
382#endif 381#endif
diff --git a/drivers/staging/fsl-dpaa2/Kconfig b/drivers/staging/fsl-dpaa2/Kconfig
index 2e325cb747ae..730fd6d4db33 100644
--- a/drivers/staging/fsl-dpaa2/Kconfig
+++ b/drivers/staging/fsl-dpaa2/Kconfig
@@ -12,6 +12,7 @@ config FSL_DPAA2
12config FSL_DPAA2_ETH 12config FSL_DPAA2_ETH
13 tristate "Freescale DPAA2 Ethernet" 13 tristate "Freescale DPAA2 Ethernet"
14 depends on FSL_DPAA2 && FSL_MC_DPIO 14 depends on FSL_DPAA2 && FSL_MC_DPIO
15 depends on NETDEVICES && ETHERNET
15 ---help--- 16 ---help---
16 Ethernet driver for Freescale DPAA2 SoCs, using the 17 Ethernet driver for Freescale DPAA2 SoCs, using the
17 Freescale MC bus driver 18 Freescale MC bus driver
diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
index 4723a0bd5067..1c6ed5b2a6f9 100644
--- a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
+++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
@@ -97,8 +97,9 @@ void rtl92e_set_reg(struct net_device *dev, u8 variable, u8 *val)
97 97
98 switch (variable) { 98 switch (variable) {
99 case HW_VAR_BSSID: 99 case HW_VAR_BSSID:
100 rtl92e_writel(dev, BSSIDR, ((u32 *)(val))[0]); 100 /* BSSIDR 2 byte alignment */
101 rtl92e_writew(dev, BSSIDR+2, ((u16 *)(val+2))[0]); 101 rtl92e_writew(dev, BSSIDR, *(u16 *)val);
102 rtl92e_writel(dev, BSSIDR + 2, *(u32 *)(val + 2));
102 break; 103 break;
103 104
104 case HW_VAR_MEDIA_STATUS: 105 case HW_VAR_MEDIA_STATUS:
@@ -624,7 +625,7 @@ void rtl92e_get_eeprom_size(struct net_device *dev)
624 struct r8192_priv *priv = rtllib_priv(dev); 625 struct r8192_priv *priv = rtllib_priv(dev);
625 626
626 RT_TRACE(COMP_INIT, "===========>%s()\n", __func__); 627 RT_TRACE(COMP_INIT, "===========>%s()\n", __func__);
627 curCR = rtl92e_readl(dev, EPROM_CMD); 628 curCR = rtl92e_readw(dev, EPROM_CMD);
628 RT_TRACE(COMP_INIT, "read from Reg Cmd9346CR(%x):%x\n", EPROM_CMD, 629 RT_TRACE(COMP_INIT, "read from Reg Cmd9346CR(%x):%x\n", EPROM_CMD,
629 curCR); 630 curCR);
630 priv->epromtype = (curCR & EPROM_CMD_9356SEL) ? EEPROM_93C56 : 631 priv->epromtype = (curCR & EPROM_CMD_9356SEL) ? EEPROM_93C56 :
@@ -961,8 +962,8 @@ static void _rtl92e_net_update(struct net_device *dev)
961 rtl92e_config_rate(dev, &rate_config); 962 rtl92e_config_rate(dev, &rate_config);
962 priv->dot11CurrentPreambleMode = PREAMBLE_AUTO; 963 priv->dot11CurrentPreambleMode = PREAMBLE_AUTO;
963 priv->basic_rate = rate_config &= 0x15f; 964 priv->basic_rate = rate_config &= 0x15f;
964 rtl92e_writel(dev, BSSIDR, ((u32 *)net->bssid)[0]); 965 rtl92e_writew(dev, BSSIDR, *(u16 *)net->bssid);
965 rtl92e_writew(dev, BSSIDR+4, ((u16 *)net->bssid)[2]); 966 rtl92e_writel(dev, BSSIDR + 2, *(u32 *)(net->bssid + 2));
966 967
967 if (priv->rtllib->iw_mode == IW_MODE_ADHOC) { 968 if (priv->rtllib->iw_mode == IW_MODE_ADHOC) {
968 rtl92e_writew(dev, ATIMWND, 2); 969 rtl92e_writew(dev, ATIMWND, 2);
@@ -1182,8 +1183,7 @@ void rtl92e_fill_tx_desc(struct net_device *dev, struct tx_desc *pdesc,
1182 struct cb_desc *cb_desc, struct sk_buff *skb) 1183 struct cb_desc *cb_desc, struct sk_buff *skb)
1183{ 1184{
1184 struct r8192_priv *priv = rtllib_priv(dev); 1185 struct r8192_priv *priv = rtllib_priv(dev);
1185 dma_addr_t mapping = pci_map_single(priv->pdev, skb->data, skb->len, 1186 dma_addr_t mapping;
1186 PCI_DMA_TODEVICE);
1187 struct tx_fwinfo_8190pci *pTxFwInfo; 1187 struct tx_fwinfo_8190pci *pTxFwInfo;
1188 1188
1189 pTxFwInfo = (struct tx_fwinfo_8190pci *)skb->data; 1189 pTxFwInfo = (struct tx_fwinfo_8190pci *)skb->data;
@@ -1194,8 +1194,6 @@ void rtl92e_fill_tx_desc(struct net_device *dev, struct tx_desc *pdesc,
1194 pTxFwInfo->Short = _rtl92e_query_is_short(pTxFwInfo->TxHT, 1194 pTxFwInfo->Short = _rtl92e_query_is_short(pTxFwInfo->TxHT,
1195 pTxFwInfo->TxRate, cb_desc); 1195 pTxFwInfo->TxRate, cb_desc);
1196 1196
1197 if (pci_dma_mapping_error(priv->pdev, mapping))
1198 netdev_err(dev, "%s(): DMA Mapping error\n", __func__);
1199 if (cb_desc->bAMPDUEnable) { 1197 if (cb_desc->bAMPDUEnable) {
1200 pTxFwInfo->AllowAggregation = 1; 1198 pTxFwInfo->AllowAggregation = 1;
1201 pTxFwInfo->RxMF = cb_desc->ampdu_factor; 1199 pTxFwInfo->RxMF = cb_desc->ampdu_factor;
@@ -1230,6 +1228,14 @@ void rtl92e_fill_tx_desc(struct net_device *dev, struct tx_desc *pdesc,
1230 } 1228 }
1231 1229
1232 memset((u8 *)pdesc, 0, 12); 1230 memset((u8 *)pdesc, 0, 12);
1231
1232 mapping = pci_map_single(priv->pdev, skb->data, skb->len,
1233 PCI_DMA_TODEVICE);
1234 if (pci_dma_mapping_error(priv->pdev, mapping)) {
1235 netdev_err(dev, "%s(): DMA Mapping error\n", __func__);
1236 return;
1237 }
1238
1233 pdesc->LINIP = 0; 1239 pdesc->LINIP = 0;
1234 pdesc->CmdInit = 1; 1240 pdesc->CmdInit = 1;
1235 pdesc->Offset = sizeof(struct tx_fwinfo_8190pci) + 8; 1241 pdesc->Offset = sizeof(struct tx_fwinfo_8190pci) + 8;
diff --git a/drivers/staging/rtl8192e/rtl819x_TSProc.c b/drivers/staging/rtl8192e/rtl819x_TSProc.c
index 48bbd9e8a52f..dcc4eb691889 100644
--- a/drivers/staging/rtl8192e/rtl819x_TSProc.c
+++ b/drivers/staging/rtl8192e/rtl819x_TSProc.c
@@ -306,11 +306,6 @@ static void MakeTSEntry(struct ts_common_info *pTsCommonInfo, u8 *Addr,
306 pTsCommonInfo->TClasNum = TCLAS_Num; 306 pTsCommonInfo->TClasNum = TCLAS_Num;
307} 307}
308 308
309static bool IsACValid(unsigned int tid)
310{
311 return tid < 7;
312}
313
314bool GetTs(struct rtllib_device *ieee, struct ts_common_info **ppTS, 309bool GetTs(struct rtllib_device *ieee, struct ts_common_info **ppTS,
315 u8 *Addr, u8 TID, enum tr_select TxRxSelect, bool bAddNewTs) 310 u8 *Addr, u8 TID, enum tr_select TxRxSelect, bool bAddNewTs)
316{ 311{
@@ -328,12 +323,6 @@ bool GetTs(struct rtllib_device *ieee, struct ts_common_info **ppTS,
328 if (ieee->current_network.qos_data.supported == 0) { 323 if (ieee->current_network.qos_data.supported == 0) {
329 UP = 0; 324 UP = 0;
330 } else { 325 } else {
331 if (!IsACValid(TID)) {
332 netdev_warn(ieee->dev, "%s(): TID(%d) is not valid\n",
333 __func__, TID);
334 return false;
335 }
336
337 switch (TID) { 326 switch (TID) {
338 case 0: 327 case 0:
339 case 3: 328 case 3:
@@ -351,6 +340,10 @@ bool GetTs(struct rtllib_device *ieee, struct ts_common_info **ppTS,
351 case 7: 340 case 7:
352 UP = 7; 341 UP = 7;
353 break; 342 break;
343 default:
344 netdev_warn(ieee->dev, "%s(): TID(%d) is not valid\n",
345 __func__, TID);
346 return false;
354 } 347 }
355 } 348 }
356 349
diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
index 5e7a61f24f8d..36c3189fc4b7 100644
--- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
+++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
@@ -3531,7 +3531,6 @@ int rtw_wdev_alloc(struct adapter *padapter, struct device *dev)
3531 pwdev_priv->power_mgmt = true; 3531 pwdev_priv->power_mgmt = true;
3532 else 3532 else
3533 pwdev_priv->power_mgmt = false; 3533 pwdev_priv->power_mgmt = false;
3534 kfree((u8 *)wdev);
3535 3534
3536 return ret; 3535 return ret;
3537 3536
diff --git a/drivers/staging/typec/fusb302/fusb302.c b/drivers/staging/typec/fusb302/fusb302.c
index 2cee9a952c9b..4a356e509fe4 100644
--- a/drivers/staging/typec/fusb302/fusb302.c
+++ b/drivers/staging/typec/fusb302/fusb302.c
@@ -264,22 +264,36 @@ static void fusb302_debugfs_exit(const struct fusb302_chip *chip) { }
264 264
265#define FUSB302_RESUME_RETRY 10 265#define FUSB302_RESUME_RETRY 10
266#define FUSB302_RESUME_RETRY_SLEEP 50 266#define FUSB302_RESUME_RETRY_SLEEP 50
267static int fusb302_i2c_write(struct fusb302_chip *chip, 267
268 u8 address, u8 data) 268static bool fusb302_is_suspended(struct fusb302_chip *chip)
269{ 269{
270 int retry_cnt; 270 int retry_cnt;
271 int ret = 0;
272 271
273 atomic_set(&chip->i2c_busy, 1);
274 for (retry_cnt = 0; retry_cnt < FUSB302_RESUME_RETRY; retry_cnt++) { 272 for (retry_cnt = 0; retry_cnt < FUSB302_RESUME_RETRY; retry_cnt++) {
275 if (atomic_read(&chip->pm_suspend)) { 273 if (atomic_read(&chip->pm_suspend)) {
276 pr_err("fusb302_i2c: pm suspend, retry %d/%d\n", 274 dev_err(chip->dev, "i2c: pm suspend, retry %d/%d\n",
277 retry_cnt + 1, FUSB302_RESUME_RETRY); 275 retry_cnt + 1, FUSB302_RESUME_RETRY);
278 msleep(FUSB302_RESUME_RETRY_SLEEP); 276 msleep(FUSB302_RESUME_RETRY_SLEEP);
279 } else { 277 } else {
280 break; 278 return false;
281 } 279 }
282 } 280 }
281
282 return true;
283}
284
285static int fusb302_i2c_write(struct fusb302_chip *chip,
286 u8 address, u8 data)
287{
288 int ret = 0;
289
290 atomic_set(&chip->i2c_busy, 1);
291
292 if (fusb302_is_suspended(chip)) {
293 atomic_set(&chip->i2c_busy, 0);
294 return -ETIMEDOUT;
295 }
296
283 ret = i2c_smbus_write_byte_data(chip->i2c_client, address, data); 297 ret = i2c_smbus_write_byte_data(chip->i2c_client, address, data);
284 if (ret < 0) 298 if (ret < 0)
285 fusb302_log(chip, "cannot write 0x%02x to 0x%02x, ret=%d", 299 fusb302_log(chip, "cannot write 0x%02x to 0x%02x, ret=%d",
@@ -292,21 +306,17 @@ static int fusb302_i2c_write(struct fusb302_chip *chip,
292static int fusb302_i2c_block_write(struct fusb302_chip *chip, u8 address, 306static int fusb302_i2c_block_write(struct fusb302_chip *chip, u8 address,
293 u8 length, const u8 *data) 307 u8 length, const u8 *data)
294{ 308{
295 int retry_cnt;
296 int ret = 0; 309 int ret = 0;
297 310
298 if (length <= 0) 311 if (length <= 0)
299 return ret; 312 return ret;
300 atomic_set(&chip->i2c_busy, 1); 313 atomic_set(&chip->i2c_busy, 1);
301 for (retry_cnt = 0; retry_cnt < FUSB302_RESUME_RETRY; retry_cnt++) { 314
302 if (atomic_read(&chip->pm_suspend)) { 315 if (fusb302_is_suspended(chip)) {
303 pr_err("fusb302_i2c: pm suspend, retry %d/%d\n", 316 atomic_set(&chip->i2c_busy, 0);
304 retry_cnt + 1, FUSB302_RESUME_RETRY); 317 return -ETIMEDOUT;
305 msleep(FUSB302_RESUME_RETRY_SLEEP);
306 } else {
307 break;
308 }
309 } 318 }
319
310 ret = i2c_smbus_write_i2c_block_data(chip->i2c_client, address, 320 ret = i2c_smbus_write_i2c_block_data(chip->i2c_client, address,
311 length, data); 321 length, data);
312 if (ret < 0) 322 if (ret < 0)
@@ -320,19 +330,15 @@ static int fusb302_i2c_block_write(struct fusb302_chip *chip, u8 address,
320static int fusb302_i2c_read(struct fusb302_chip *chip, 330static int fusb302_i2c_read(struct fusb302_chip *chip,
321 u8 address, u8 *data) 331 u8 address, u8 *data)
322{ 332{
323 int retry_cnt;
324 int ret = 0; 333 int ret = 0;
325 334
326 atomic_set(&chip->i2c_busy, 1); 335 atomic_set(&chip->i2c_busy, 1);
327 for (retry_cnt = 0; retry_cnt < FUSB302_RESUME_RETRY; retry_cnt++) { 336
328 if (atomic_read(&chip->pm_suspend)) { 337 if (fusb302_is_suspended(chip)) {
329 pr_err("fusb302_i2c: pm suspend, retry %d/%d\n", 338 atomic_set(&chip->i2c_busy, 0);
330 retry_cnt + 1, FUSB302_RESUME_RETRY); 339 return -ETIMEDOUT;
331 msleep(FUSB302_RESUME_RETRY_SLEEP);
332 } else {
333 break;
334 }
335 } 340 }
341
336 ret = i2c_smbus_read_byte_data(chip->i2c_client, address); 342 ret = i2c_smbus_read_byte_data(chip->i2c_client, address);
337 *data = (u8)ret; 343 *data = (u8)ret;
338 if (ret < 0) 344 if (ret < 0)
@@ -345,33 +351,31 @@ static int fusb302_i2c_read(struct fusb302_chip *chip,
345static int fusb302_i2c_block_read(struct fusb302_chip *chip, u8 address, 351static int fusb302_i2c_block_read(struct fusb302_chip *chip, u8 address,
346 u8 length, u8 *data) 352 u8 length, u8 *data)
347{ 353{
348 int retry_cnt;
349 int ret = 0; 354 int ret = 0;
350 355
351 if (length <= 0) 356 if (length <= 0)
352 return ret; 357 return ret;
353 atomic_set(&chip->i2c_busy, 1); 358 atomic_set(&chip->i2c_busy, 1);
354 for (retry_cnt = 0; retry_cnt < FUSB302_RESUME_RETRY; retry_cnt++) { 359
355 if (atomic_read(&chip->pm_suspend)) { 360 if (fusb302_is_suspended(chip)) {
356 pr_err("fusb302_i2c: pm suspend, retry %d/%d\n", 361 atomic_set(&chip->i2c_busy, 0);
357 retry_cnt + 1, FUSB302_RESUME_RETRY); 362 return -ETIMEDOUT;
358 msleep(FUSB302_RESUME_RETRY_SLEEP);
359 } else {
360 break;
361 }
362 } 363 }
364
363 ret = i2c_smbus_read_i2c_block_data(chip->i2c_client, address, 365 ret = i2c_smbus_read_i2c_block_data(chip->i2c_client, address,
364 length, data); 366 length, data);
365 if (ret < 0) { 367 if (ret < 0) {
366 fusb302_log(chip, "cannot block read 0x%02x, len=%d, ret=%d", 368 fusb302_log(chip, "cannot block read 0x%02x, len=%d, ret=%d",
367 address, length, ret); 369 address, length, ret);
368 return ret; 370 goto done;
369 } 371 }
370 if (ret != length) { 372 if (ret != length) {
371 fusb302_log(chip, "only read %d/%d bytes from 0x%02x", 373 fusb302_log(chip, "only read %d/%d bytes from 0x%02x",
372 ret, length, address); 374 ret, length, address);
373 return -EIO; 375 ret = -EIO;
374 } 376 }
377
378done:
375 atomic_set(&chip->i2c_busy, 0); 379 atomic_set(&chip->i2c_busy, 0);
376 380
377 return ret; 381 return ret;
@@ -489,7 +493,7 @@ static int tcpm_init(struct tcpc_dev *dev)
489 ret = fusb302_i2c_read(chip, FUSB_REG_STATUS0, &data); 493 ret = fusb302_i2c_read(chip, FUSB_REG_STATUS0, &data);
490 if (ret < 0) 494 if (ret < 0)
491 return ret; 495 return ret;
492 chip->vbus_present = !!(FUSB_REG_STATUS0 & FUSB_REG_STATUS0_VBUSOK); 496 chip->vbus_present = !!(data & FUSB_REG_STATUS0_VBUSOK);
493 ret = fusb302_i2c_read(chip, FUSB_REG_DEVICE_ID, &data); 497 ret = fusb302_i2c_read(chip, FUSB_REG_DEVICE_ID, &data);
494 if (ret < 0) 498 if (ret < 0)
495 return ret; 499 return ret;
@@ -1025,7 +1029,7 @@ static int fusb302_pd_send_message(struct fusb302_chip *chip,
1025 buf[pos++] = FUSB302_TKN_SYNC1; 1029 buf[pos++] = FUSB302_TKN_SYNC1;
1026 buf[pos++] = FUSB302_TKN_SYNC2; 1030 buf[pos++] = FUSB302_TKN_SYNC2;
1027 1031
1028 len = pd_header_cnt(msg->header) * 4; 1032 len = pd_header_cnt_le(msg->header) * 4;
1029 /* plug 2 for header */ 1033 /* plug 2 for header */
1030 len += 2; 1034 len += 2;
1031 if (len > 0x1F) { 1035 if (len > 0x1F) {
@@ -1481,7 +1485,7 @@ static int fusb302_pd_read_message(struct fusb302_chip *chip,
1481 (u8 *)&msg->header); 1485 (u8 *)&msg->header);
1482 if (ret < 0) 1486 if (ret < 0)
1483 return ret; 1487 return ret;
1484 len = pd_header_cnt(msg->header) * 4; 1488 len = pd_header_cnt_le(msg->header) * 4;
1485 /* add 4 to length to include the CRC */ 1489 /* add 4 to length to include the CRC */
1486 if (len > PD_MAX_PAYLOAD * 4) { 1490 if (len > PD_MAX_PAYLOAD * 4) {
1487 fusb302_log(chip, "PD message too long %d", len); 1491 fusb302_log(chip, "PD message too long %d", len);
@@ -1663,14 +1667,12 @@ static int init_gpio(struct fusb302_chip *chip)
1663 if (ret < 0) { 1667 if (ret < 0) {
1664 fusb302_log(chip, 1668 fusb302_log(chip,
1665 "cannot set GPIO Int_N to input, ret=%d", ret); 1669 "cannot set GPIO Int_N to input, ret=%d", ret);
1666 gpio_free(chip->gpio_int_n);
1667 return ret; 1670 return ret;
1668 } 1671 }
1669 ret = gpio_to_irq(chip->gpio_int_n); 1672 ret = gpio_to_irq(chip->gpio_int_n);
1670 if (ret < 0) { 1673 if (ret < 0) {
1671 fusb302_log(chip, 1674 fusb302_log(chip,
1672 "cannot request IRQ for GPIO Int_N, ret=%d", ret); 1675 "cannot request IRQ for GPIO Int_N, ret=%d", ret);
1673 gpio_free(chip->gpio_int_n);
1674 return ret; 1676 return ret;
1675 } 1677 }
1676 chip->gpio_int_n_irq = ret; 1678 chip->gpio_int_n_irq = ret;
@@ -1787,11 +1789,13 @@ static const struct of_device_id fusb302_dt_match[] = {
1787 {.compatible = "fcs,fusb302"}, 1789 {.compatible = "fcs,fusb302"},
1788 {}, 1790 {},
1789}; 1791};
1792MODULE_DEVICE_TABLE(of, fusb302_dt_match);
1790 1793
1791static const struct i2c_device_id fusb302_i2c_device_id[] = { 1794static const struct i2c_device_id fusb302_i2c_device_id[] = {
1792 {"typec_fusb302", 0}, 1795 {"typec_fusb302", 0},
1793 {}, 1796 {},
1794}; 1797};
1798MODULE_DEVICE_TABLE(i2c, fusb302_i2c_device_id);
1795 1799
1796static const struct dev_pm_ops fusb302_pm_ops = { 1800static const struct dev_pm_ops fusb302_pm_ops = {
1797 .suspend = fusb302_pm_suspend, 1801 .suspend = fusb302_pm_suspend,
diff --git a/drivers/staging/typec/pd.h b/drivers/staging/typec/pd.h
index 8d97bdb95f23..510ef7279900 100644
--- a/drivers/staging/typec/pd.h
+++ b/drivers/staging/typec/pd.h
@@ -92,6 +92,16 @@ static inline unsigned int pd_header_type_le(__le16 header)
92 return pd_header_type(le16_to_cpu(header)); 92 return pd_header_type(le16_to_cpu(header));
93} 93}
94 94
95static inline unsigned int pd_header_msgid(u16 header)
96{
97 return (header >> PD_HEADER_ID_SHIFT) & PD_HEADER_ID_MASK;
98}
99
100static inline unsigned int pd_header_msgid_le(__le16 header)
101{
102 return pd_header_msgid(le16_to_cpu(header));
103}
104
95#define PD_MAX_PAYLOAD 7 105#define PD_MAX_PAYLOAD 7
96 106
97struct pd_message { 107struct pd_message {
diff --git a/drivers/staging/typec/pd_vdo.h b/drivers/staging/typec/pd_vdo.h
index dba172e0e0d1..d92259f8de0a 100644
--- a/drivers/staging/typec/pd_vdo.h
+++ b/drivers/staging/typec/pd_vdo.h
@@ -22,6 +22,9 @@
22 * VDM object is minimum of VDM header + 6 additional data objects. 22 * VDM object is minimum of VDM header + 6 additional data objects.
23 */ 23 */
24 24
25#define VDO_MAX_OBJECTS 6
26#define VDO_MAX_SIZE (VDO_MAX_OBJECTS + 1)
27
25/* 28/*
26 * VDM header 29 * VDM header
27 * ---------- 30 * ----------
@@ -34,7 +37,6 @@
34 * <5> :: reserved (SVDM), command type (UVDM) 37 * <5> :: reserved (SVDM), command type (UVDM)
35 * <4:0> :: command 38 * <4:0> :: command
36 */ 39 */
37#define VDO_MAX_SIZE 7
38#define VDO(vid, type, custom) \ 40#define VDO(vid, type, custom) \
39 (((vid) << 16) | \ 41 (((vid) << 16) | \
40 ((type) << 15) | \ 42 ((type) << 15) | \
diff --git a/drivers/staging/typec/tcpci.c b/drivers/staging/typec/tcpci.c
index 5e5be74c7850..df72d8b01e73 100644
--- a/drivers/staging/typec/tcpci.c
+++ b/drivers/staging/typec/tcpci.c
@@ -425,7 +425,7 @@ static const struct regmap_config tcpci_regmap_config = {
425 .max_register = 0x7F, /* 0x80 .. 0xFF are vendor defined */ 425 .max_register = 0x7F, /* 0x80 .. 0xFF are vendor defined */
426}; 426};
427 427
428const struct tcpc_config tcpci_tcpc_config = { 428static const struct tcpc_config tcpci_tcpc_config = {
429 .type = TYPEC_PORT_DFP, 429 .type = TYPEC_PORT_DFP,
430 .default_role = TYPEC_SINK, 430 .default_role = TYPEC_SINK,
431}; 431};
diff --git a/drivers/staging/typec/tcpm.c b/drivers/staging/typec/tcpm.c
index abba655ba00a..20eb4ebcf8c3 100644
--- a/drivers/staging/typec/tcpm.c
+++ b/drivers/staging/typec/tcpm.c
@@ -238,6 +238,7 @@ struct tcpm_port {
238 unsigned int hard_reset_count; 238 unsigned int hard_reset_count;
239 bool pd_capable; 239 bool pd_capable;
240 bool explicit_contract; 240 bool explicit_contract;
241 unsigned int rx_msgid;
241 242
242 /* Partner capabilities/requests */ 243 /* Partner capabilities/requests */
243 u32 sink_request; 244 u32 sink_request;
@@ -251,6 +252,8 @@ struct tcpm_port {
251 unsigned int nr_src_pdo; 252 unsigned int nr_src_pdo;
252 u32 snk_pdo[PDO_MAX_OBJECTS]; 253 u32 snk_pdo[PDO_MAX_OBJECTS];
253 unsigned int nr_snk_pdo; 254 unsigned int nr_snk_pdo;
255 u32 snk_vdo[VDO_MAX_OBJECTS];
256 unsigned int nr_snk_vdo;
254 257
255 unsigned int max_snk_mv; 258 unsigned int max_snk_mv;
256 unsigned int max_snk_ma; 259 unsigned int max_snk_ma;
@@ -997,6 +1000,7 @@ static int tcpm_pd_svdm(struct tcpm_port *port, const __le32 *payload, int cnt,
997 struct pd_mode_data *modep; 1000 struct pd_mode_data *modep;
998 int rlen = 0; 1001 int rlen = 0;
999 u16 svid; 1002 u16 svid;
1003 int i;
1000 1004
1001 tcpm_log(port, "Rx VDM cmd 0x%x type %d cmd %d len %d", 1005 tcpm_log(port, "Rx VDM cmd 0x%x type %d cmd %d len %d",
1002 p0, cmd_type, cmd, cnt); 1006 p0, cmd_type, cmd, cnt);
@@ -1007,6 +1011,14 @@ static int tcpm_pd_svdm(struct tcpm_port *port, const __le32 *payload, int cnt,
1007 case CMDT_INIT: 1011 case CMDT_INIT:
1008 switch (cmd) { 1012 switch (cmd) {
1009 case CMD_DISCOVER_IDENT: 1013 case CMD_DISCOVER_IDENT:
1014 /* 6.4.4.3.1: Only respond as UFP (device) */
1015 if (port->data_role == TYPEC_DEVICE &&
1016 port->nr_snk_vdo) {
1017 for (i = 0; i < port->nr_snk_vdo; i++)
1018 response[i + 1]
1019 = cpu_to_le32(port->snk_vdo[i]);
1020 rlen = port->nr_snk_vdo + 1;
1021 }
1010 break; 1022 break;
1011 case CMD_DISCOVER_SVID: 1023 case CMD_DISCOVER_SVID:
1012 break; 1024 break;
@@ -1415,6 +1427,7 @@ static void tcpm_pd_ctrl_request(struct tcpm_port *port,
1415 break; 1427 break;
1416 case SOFT_RESET_SEND: 1428 case SOFT_RESET_SEND:
1417 port->message_id = 0; 1429 port->message_id = 0;
1430 port->rx_msgid = -1;
1418 if (port->pwr_role == TYPEC_SOURCE) 1431 if (port->pwr_role == TYPEC_SOURCE)
1419 next_state = SRC_SEND_CAPABILITIES; 1432 next_state = SRC_SEND_CAPABILITIES;
1420 else 1433 else
@@ -1503,6 +1516,22 @@ static void tcpm_pd_rx_handler(struct work_struct *work)
1503 port->attached); 1516 port->attached);
1504 1517
1505 if (port->attached) { 1518 if (port->attached) {
1519 enum pd_ctrl_msg_type type = pd_header_type_le(msg->header);
1520 unsigned int msgid = pd_header_msgid_le(msg->header);
1521
1522 /*
1523 * USB PD standard, 6.6.1.2:
1524 * "... if MessageID value in a received Message is the
1525 * same as the stored value, the receiver shall return a
1526 * GoodCRC Message with that MessageID value and drop
1527 * the Message (this is a retry of an already received
1528 * Message). Note: this shall not apply to the Soft_Reset
1529 * Message which always has a MessageID value of zero."
1530 */
1531 if (msgid == port->rx_msgid && type != PD_CTRL_SOFT_RESET)
1532 goto done;
1533 port->rx_msgid = msgid;
1534
1506 /* 1535 /*
1507 * If both ends believe to be DFP/host, we have a data role 1536 * If both ends believe to be DFP/host, we have a data role
1508 * mismatch. 1537 * mismatch.
@@ -1520,6 +1549,7 @@ static void tcpm_pd_rx_handler(struct work_struct *work)
1520 } 1549 }
1521 } 1550 }
1522 1551
1552done:
1523 mutex_unlock(&port->lock); 1553 mutex_unlock(&port->lock);
1524 kfree(event); 1554 kfree(event);
1525} 1555}
@@ -1719,8 +1749,7 @@ static int tcpm_pd_build_request(struct tcpm_port *port, u32 *rdo)
1719 } 1749 }
1720 ma = min(ma, port->max_snk_ma); 1750 ma = min(ma, port->max_snk_ma);
1721 1751
1722 /* XXX: Any other flags need to be set? */ 1752 flags = RDO_USB_COMM | RDO_NO_SUSPEND;
1723 flags = 0;
1724 1753
1725 /* Set mismatch bit if offered power is less than operating power */ 1754 /* Set mismatch bit if offered power is less than operating power */
1726 mw = ma * mv / 1000; 1755 mw = ma * mv / 1000;
@@ -1957,6 +1986,12 @@ static void tcpm_reset_port(struct tcpm_port *port)
1957 port->attached = false; 1986 port->attached = false;
1958 port->pd_capable = false; 1987 port->pd_capable = false;
1959 1988
1989 /*
1990 * First Rx ID should be 0; set this to a sentinel of -1 so that
1991 * we can check tcpm_pd_rx_handler() if we had seen it before.
1992 */
1993 port->rx_msgid = -1;
1994
1960 port->tcpc->set_pd_rx(port->tcpc, false); 1995 port->tcpc->set_pd_rx(port->tcpc, false);
1961 tcpm_init_vbus(port); /* also disables charging */ 1996 tcpm_init_vbus(port); /* also disables charging */
1962 tcpm_init_vconn(port); 1997 tcpm_init_vconn(port);
@@ -2170,6 +2205,7 @@ static void run_state_machine(struct tcpm_port *port)
2170 port->pwr_opmode = TYPEC_PWR_MODE_USB; 2205 port->pwr_opmode = TYPEC_PWR_MODE_USB;
2171 port->caps_count = 0; 2206 port->caps_count = 0;
2172 port->message_id = 0; 2207 port->message_id = 0;
2208 port->rx_msgid = -1;
2173 port->explicit_contract = false; 2209 port->explicit_contract = false;
2174 tcpm_set_state(port, SRC_SEND_CAPABILITIES, 0); 2210 tcpm_set_state(port, SRC_SEND_CAPABILITIES, 0);
2175 break; 2211 break;
@@ -2329,6 +2365,7 @@ static void run_state_machine(struct tcpm_port *port)
2329 typec_set_pwr_opmode(port->typec_port, TYPEC_PWR_MODE_USB); 2365 typec_set_pwr_opmode(port->typec_port, TYPEC_PWR_MODE_USB);
2330 port->pwr_opmode = TYPEC_PWR_MODE_USB; 2366 port->pwr_opmode = TYPEC_PWR_MODE_USB;
2331 port->message_id = 0; 2367 port->message_id = 0;
2368 port->rx_msgid = -1;
2332 port->explicit_contract = false; 2369 port->explicit_contract = false;
2333 tcpm_set_state(port, SNK_DISCOVERY, 0); 2370 tcpm_set_state(port, SNK_DISCOVERY, 0);
2334 break; 2371 break;
@@ -2496,6 +2533,7 @@ static void run_state_machine(struct tcpm_port *port)
2496 /* Soft_Reset states */ 2533 /* Soft_Reset states */
2497 case SOFT_RESET: 2534 case SOFT_RESET:
2498 port->message_id = 0; 2535 port->message_id = 0;
2536 port->rx_msgid = -1;
2499 tcpm_pd_send_control(port, PD_CTRL_ACCEPT); 2537 tcpm_pd_send_control(port, PD_CTRL_ACCEPT);
2500 if (port->pwr_role == TYPEC_SOURCE) 2538 if (port->pwr_role == TYPEC_SOURCE)
2501 tcpm_set_state(port, SRC_SEND_CAPABILITIES, 0); 2539 tcpm_set_state(port, SRC_SEND_CAPABILITIES, 0);
@@ -2504,6 +2542,7 @@ static void run_state_machine(struct tcpm_port *port)
2504 break; 2542 break;
2505 case SOFT_RESET_SEND: 2543 case SOFT_RESET_SEND:
2506 port->message_id = 0; 2544 port->message_id = 0;
2545 port->rx_msgid = -1;
2507 if (tcpm_pd_send_control(port, PD_CTRL_SOFT_RESET)) 2546 if (tcpm_pd_send_control(port, PD_CTRL_SOFT_RESET))
2508 tcpm_set_state_cond(port, hard_reset_state(port), 0); 2547 tcpm_set_state_cond(port, hard_reset_state(port), 0);
2509 else 2548 else
@@ -2568,6 +2607,14 @@ static void run_state_machine(struct tcpm_port *port)
2568 break; 2607 break;
2569 case PR_SWAP_SRC_SNK_SOURCE_OFF: 2608 case PR_SWAP_SRC_SNK_SOURCE_OFF:
2570 tcpm_set_cc(port, TYPEC_CC_RD); 2609 tcpm_set_cc(port, TYPEC_CC_RD);
2610 /*
2611 * USB-PD standard, 6.2.1.4, Port Power Role:
2612 * "During the Power Role Swap Sequence, for the initial Source
2613 * Port, the Port Power Role field shall be set to Sink in the
2614 * PS_RDY Message indicating that the initial Source’s power
2615 * supply is turned off"
2616 */
2617 tcpm_set_pwr_role(port, TYPEC_SINK);
2571 if (tcpm_pd_send_control(port, PD_CTRL_PS_RDY)) { 2618 if (tcpm_pd_send_control(port, PD_CTRL_PS_RDY)) {
2572 tcpm_set_state(port, ERROR_RECOVERY, 0); 2619 tcpm_set_state(port, ERROR_RECOVERY, 0);
2573 break; 2620 break;
@@ -2575,7 +2622,6 @@ static void run_state_machine(struct tcpm_port *port)
2575 tcpm_set_state_cond(port, SNK_UNATTACHED, PD_T_PS_SOURCE_ON); 2622 tcpm_set_state_cond(port, SNK_UNATTACHED, PD_T_PS_SOURCE_ON);
2576 break; 2623 break;
2577 case PR_SWAP_SRC_SNK_SINK_ON: 2624 case PR_SWAP_SRC_SNK_SINK_ON:
2578 tcpm_set_pwr_role(port, TYPEC_SINK);
2579 tcpm_swap_complete(port, 0); 2625 tcpm_swap_complete(port, 0);
2580 tcpm_set_state(port, SNK_STARTUP, 0); 2626 tcpm_set_state(port, SNK_STARTUP, 0);
2581 break; 2627 break;
@@ -2587,8 +2633,15 @@ static void run_state_machine(struct tcpm_port *port)
2587 case PR_SWAP_SNK_SRC_SOURCE_ON: 2633 case PR_SWAP_SNK_SRC_SOURCE_ON:
2588 tcpm_set_cc(port, tcpm_rp_cc(port)); 2634 tcpm_set_cc(port, tcpm_rp_cc(port));
2589 tcpm_set_vbus(port, true); 2635 tcpm_set_vbus(port, true);
2590 tcpm_pd_send_control(port, PD_CTRL_PS_RDY); 2636 /*
2637 * USB PD standard, 6.2.1.4:
2638 * "Subsequent Messages initiated by the Policy Engine,
2639 * such as the PS_RDY Message sent to indicate that Vbus
2640 * is ready, will have the Port Power Role field set to
2641 * Source."
2642 */
2591 tcpm_set_pwr_role(port, TYPEC_SOURCE); 2643 tcpm_set_pwr_role(port, TYPEC_SOURCE);
2644 tcpm_pd_send_control(port, PD_CTRL_PS_RDY);
2592 tcpm_swap_complete(port, 0); 2645 tcpm_swap_complete(port, 0);
2593 tcpm_set_state(port, SRC_STARTUP, 0); 2646 tcpm_set_state(port, SRC_STARTUP, 0);
2594 break; 2647 break;
@@ -3292,6 +3345,20 @@ static int tcpm_copy_pdos(u32 *dest_pdo, const u32 *src_pdo,
3292 return nr_pdo; 3345 return nr_pdo;
3293} 3346}
3294 3347
3348static int tcpm_copy_vdos(u32 *dest_vdo, const u32 *src_vdo,
3349 unsigned int nr_vdo)
3350{
3351 unsigned int i;
3352
3353 if (nr_vdo > VDO_MAX_OBJECTS)
3354 nr_vdo = VDO_MAX_OBJECTS;
3355
3356 for (i = 0; i < nr_vdo; i++)
3357 dest_vdo[i] = src_vdo[i];
3358
3359 return nr_vdo;
3360}
3361
3295void tcpm_update_source_capabilities(struct tcpm_port *port, const u32 *pdo, 3362void tcpm_update_source_capabilities(struct tcpm_port *port, const u32 *pdo,
3296 unsigned int nr_pdo) 3363 unsigned int nr_pdo)
3297{ 3364{
@@ -3382,6 +3449,8 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc)
3382 tcpc->config->nr_src_pdo); 3449 tcpc->config->nr_src_pdo);
3383 port->nr_snk_pdo = tcpm_copy_pdos(port->snk_pdo, tcpc->config->snk_pdo, 3450 port->nr_snk_pdo = tcpm_copy_pdos(port->snk_pdo, tcpc->config->snk_pdo,
3384 tcpc->config->nr_snk_pdo); 3451 tcpc->config->nr_snk_pdo);
3452 port->nr_snk_vdo = tcpm_copy_vdos(port->snk_vdo, tcpc->config->snk_vdo,
3453 tcpc->config->nr_snk_vdo);
3385 3454
3386 port->max_snk_mv = tcpc->config->max_snk_mv; 3455 port->max_snk_mv = tcpc->config->max_snk_mv;
3387 port->max_snk_ma = tcpc->config->max_snk_ma; 3456 port->max_snk_ma = tcpc->config->max_snk_ma;
diff --git a/drivers/staging/typec/tcpm.h b/drivers/staging/typec/tcpm.h
index 969b365e6549..19c307d31a5a 100644
--- a/drivers/staging/typec/tcpm.h
+++ b/drivers/staging/typec/tcpm.h
@@ -60,6 +60,9 @@ struct tcpc_config {
60 const u32 *snk_pdo; 60 const u32 *snk_pdo;
61 unsigned int nr_snk_pdo; 61 unsigned int nr_snk_pdo;
62 62
63 const u32 *snk_vdo;
64 unsigned int nr_snk_vdo;
65
63 unsigned int max_snk_mv; 66 unsigned int max_snk_mv;
64 unsigned int max_snk_ma; 67 unsigned int max_snk_ma;
65 unsigned int max_snk_mw; 68 unsigned int max_snk_mw;
diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
index 988ee61fb4a7..d04db3f55519 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
@@ -502,8 +502,15 @@ create_pagelist(char __user *buf, size_t count, unsigned short type,
502 */ 502 */
503 sg_init_table(scatterlist, num_pages); 503 sg_init_table(scatterlist, num_pages);
504 /* Now set the pages for each scatterlist */ 504 /* Now set the pages for each scatterlist */
505 for (i = 0; i < num_pages; i++) 505 for (i = 0; i < num_pages; i++) {
506 sg_set_page(scatterlist + i, pages[i], PAGE_SIZE, 0); 506 unsigned int len = PAGE_SIZE - offset;
507
508 if (len > count)
509 len = count;
510 sg_set_page(scatterlist + i, pages[i], len, offset);
511 offset = 0;
512 count -= len;
513 }
507 514
508 dma_buffers = dma_map_sg(g_dev, 515 dma_buffers = dma_map_sg(g_dev,
509 scatterlist, 516 scatterlist,
@@ -524,20 +531,20 @@ create_pagelist(char __user *buf, size_t count, unsigned short type,
524 u32 addr = sg_dma_address(sg); 531 u32 addr = sg_dma_address(sg);
525 532
526 /* Note: addrs is the address + page_count - 1 533 /* Note: addrs is the address + page_count - 1
527 * The firmware expects the block to be page 534 * The firmware expects blocks after the first to be page-
528 * aligned and a multiple of the page size 535 * aligned and a multiple of the page size
529 */ 536 */
530 WARN_ON(len == 0); 537 WARN_ON(len == 0);
531 WARN_ON(len & ~PAGE_MASK); 538 WARN_ON(i && (i != (dma_buffers - 1)) && (len & ~PAGE_MASK));
532 WARN_ON(addr & ~PAGE_MASK); 539 WARN_ON(i && (addr & ~PAGE_MASK));
533 if (k > 0 && 540 if (k > 0 &&
534 ((addrs[k - 1] & PAGE_MASK) | 541 ((addrs[k - 1] & PAGE_MASK) +
535 ((addrs[k - 1] & ~PAGE_MASK) + 1) << PAGE_SHIFT) 542 (((addrs[k - 1] & ~PAGE_MASK) + 1) << PAGE_SHIFT))
536 == addr) { 543 == (addr & PAGE_MASK))
537 addrs[k - 1] += (len >> PAGE_SHIFT); 544 addrs[k - 1] += ((len + PAGE_SIZE - 1) >> PAGE_SHIFT);
538 } else { 545 else
539 addrs[k++] = addr | ((len >> PAGE_SHIFT) - 1); 546 addrs[k++] = (addr & PAGE_MASK) |
540 } 547 (((len + PAGE_SIZE - 1) >> PAGE_SHIFT) - 1);
541 } 548 }
542 549
543 /* Partial cache lines (fragments) require special measures */ 550 /* Partial cache lines (fragments) require special measures */
diff --git a/drivers/tee/Kconfig b/drivers/tee/Kconfig
index 2330a4eb4e8b..a6df12d88f90 100644
--- a/drivers/tee/Kconfig
+++ b/drivers/tee/Kconfig
@@ -1,6 +1,7 @@
1# Generic Trusted Execution Environment Configuration 1# Generic Trusted Execution Environment Configuration
2config TEE 2config TEE
3 tristate "Trusted Execution Environment support" 3 tristate "Trusted Execution Environment support"
4 depends on HAVE_ARM_SMCCC || COMPILE_TEST
4 select DMA_SHARED_BUFFER 5 select DMA_SHARED_BUFFER
5 select GENERIC_ALLOCATOR 6 select GENERIC_ALLOCATOR
6 help 7 help
diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
index 1c196f87e9d9..ff04b7f8549f 100644
--- a/drivers/uio/uio.c
+++ b/drivers/uio/uio.c
@@ -279,7 +279,7 @@ static int uio_dev_add_attributes(struct uio_device *idev)
279 map = kzalloc(sizeof(*map), GFP_KERNEL); 279 map = kzalloc(sizeof(*map), GFP_KERNEL);
280 if (!map) { 280 if (!map) {
281 ret = -ENOMEM; 281 ret = -ENOMEM;
282 goto err_map_kobj; 282 goto err_map;
283 } 283 }
284 kobject_init(&map->kobj, &map_attr_type); 284 kobject_init(&map->kobj, &map_attr_type);
285 map->mem = mem; 285 map->mem = mem;
@@ -289,7 +289,7 @@ static int uio_dev_add_attributes(struct uio_device *idev)
289 goto err_map_kobj; 289 goto err_map_kobj;
290 ret = kobject_uevent(&map->kobj, KOBJ_ADD); 290 ret = kobject_uevent(&map->kobj, KOBJ_ADD);
291 if (ret) 291 if (ret)
292 goto err_map; 292 goto err_map_kobj;
293 } 293 }
294 294
295 for (pi = 0; pi < MAX_UIO_PORT_REGIONS; pi++) { 295 for (pi = 0; pi < MAX_UIO_PORT_REGIONS; pi++) {
@@ -308,7 +308,7 @@ static int uio_dev_add_attributes(struct uio_device *idev)
308 portio = kzalloc(sizeof(*portio), GFP_KERNEL); 308 portio = kzalloc(sizeof(*portio), GFP_KERNEL);
309 if (!portio) { 309 if (!portio) {
310 ret = -ENOMEM; 310 ret = -ENOMEM;
311 goto err_portio_kobj; 311 goto err_portio;
312 } 312 }
313 kobject_init(&portio->kobj, &portio_attr_type); 313 kobject_init(&portio->kobj, &portio_attr_type);
314 portio->port = port; 314 portio->port = port;
@@ -319,7 +319,7 @@ static int uio_dev_add_attributes(struct uio_device *idev)
319 goto err_portio_kobj; 319 goto err_portio_kobj;
320 ret = kobject_uevent(&portio->kobj, KOBJ_ADD); 320 ret = kobject_uevent(&portio->kobj, KOBJ_ADD);
321 if (ret) 321 if (ret)
322 goto err_portio; 322 goto err_portio_kobj;
323 } 323 }
324 324
325 return 0; 325 return 0;
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index cfc3cff6e8d5..8e6ef671be9b 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -475,11 +475,11 @@ static void snoop_urb(struct usb_device *udev,
475 475
476 if (userurb) { /* Async */ 476 if (userurb) { /* Async */
477 if (when == SUBMIT) 477 if (when == SUBMIT)
478 dev_info(&udev->dev, "userurb %p, ep%d %s-%s, " 478 dev_info(&udev->dev, "userurb %pK, ep%d %s-%s, "
479 "length %u\n", 479 "length %u\n",
480 userurb, ep, t, d, length); 480 userurb, ep, t, d, length);
481 else 481 else
482 dev_info(&udev->dev, "userurb %p, ep%d %s-%s, " 482 dev_info(&udev->dev, "userurb %pK, ep%d %s-%s, "
483 "actual_length %u status %d\n", 483 "actual_length %u status %d\n",
484 userurb, ep, t, d, length, 484 userurb, ep, t, d, length,
485 timeout_or_status); 485 timeout_or_status);
@@ -1895,7 +1895,7 @@ static int proc_reapurb(struct usb_dev_state *ps, void __user *arg)
1895 if (as) { 1895 if (as) {
1896 int retval; 1896 int retval;
1897 1897
1898 snoop(&ps->dev->dev, "reap %p\n", as->userurb); 1898 snoop(&ps->dev->dev, "reap %pK\n", as->userurb);
1899 retval = processcompl(as, (void __user * __user *)arg); 1899 retval = processcompl(as, (void __user * __user *)arg);
1900 free_async(as); 1900 free_async(as);
1901 return retval; 1901 return retval;
@@ -1912,7 +1912,7 @@ static int proc_reapurbnonblock(struct usb_dev_state *ps, void __user *arg)
1912 1912
1913 as = async_getcompleted(ps); 1913 as = async_getcompleted(ps);
1914 if (as) { 1914 if (as) {
1915 snoop(&ps->dev->dev, "reap %p\n", as->userurb); 1915 snoop(&ps->dev->dev, "reap %pK\n", as->userurb);
1916 retval = processcompl(as, (void __user * __user *)arg); 1916 retval = processcompl(as, (void __user * __user *)arg);
1917 free_async(as); 1917 free_async(as);
1918 } else { 1918 } else {
@@ -2043,7 +2043,7 @@ static int proc_reapurb_compat(struct usb_dev_state *ps, void __user *arg)
2043 if (as) { 2043 if (as) {
2044 int retval; 2044 int retval;
2045 2045
2046 snoop(&ps->dev->dev, "reap %p\n", as->userurb); 2046 snoop(&ps->dev->dev, "reap %pK\n", as->userurb);
2047 retval = processcompl_compat(as, (void __user * __user *)arg); 2047 retval = processcompl_compat(as, (void __user * __user *)arg);
2048 free_async(as); 2048 free_async(as);
2049 return retval; 2049 return retval;
@@ -2060,7 +2060,7 @@ static int proc_reapurbnonblock_compat(struct usb_dev_state *ps, void __user *ar
2060 2060
2061 as = async_getcompleted(ps); 2061 as = async_getcompleted(ps);
2062 if (as) { 2062 if (as) {
2063 snoop(&ps->dev->dev, "reap %p\n", as->userurb); 2063 snoop(&ps->dev->dev, "reap %pK\n", as->userurb);
2064 retval = processcompl_compat(as, (void __user * __user *)arg); 2064 retval = processcompl_compat(as, (void __user * __user *)arg);
2065 free_async(as); 2065 free_async(as);
2066 } else { 2066 } else {
@@ -2489,7 +2489,7 @@ static long usbdev_do_ioctl(struct file *file, unsigned int cmd,
2489#endif 2489#endif
2490 2490
2491 case USBDEVFS_DISCARDURB: 2491 case USBDEVFS_DISCARDURB:
2492 snoop(&dev->dev, "%s: DISCARDURB %p\n", __func__, p); 2492 snoop(&dev->dev, "%s: DISCARDURB %pK\n", __func__, p);
2493 ret = proc_unlinkurb(ps, p); 2493 ret = proc_unlinkurb(ps, p);
2494 break; 2494 break;
2495 2495
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 49550790a3cb..5dea98358c05 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -1723,7 +1723,7 @@ int usb_hcd_unlink_urb (struct urb *urb, int status)
1723 if (retval == 0) 1723 if (retval == 0)
1724 retval = -EINPROGRESS; 1724 retval = -EINPROGRESS;
1725 else if (retval != -EIDRM && retval != -EBUSY) 1725 else if (retval != -EIDRM && retval != -EBUSY)
1726 dev_dbg(&udev->dev, "hcd_unlink_urb %p fail %d\n", 1726 dev_dbg(&udev->dev, "hcd_unlink_urb %pK fail %d\n",
1727 urb, retval); 1727 urb, retval);
1728 usb_put_dev(udev); 1728 usb_put_dev(udev);
1729 } 1729 }
@@ -1890,7 +1890,7 @@ rescan:
1890 /* kick hcd */ 1890 /* kick hcd */
1891 unlink1(hcd, urb, -ESHUTDOWN); 1891 unlink1(hcd, urb, -ESHUTDOWN);
1892 dev_dbg (hcd->self.controller, 1892 dev_dbg (hcd->self.controller,
1893 "shutdown urb %p ep%d%s%s\n", 1893 "shutdown urb %pK ep%d%s%s\n",
1894 urb, usb_endpoint_num(&ep->desc), 1894 urb, usb_endpoint_num(&ep->desc),
1895 is_in ? "in" : "out", 1895 is_in ? "in" : "out",
1896 ({ char *s; 1896 ({ char *s;
@@ -2520,6 +2520,7 @@ struct usb_hcd *__usb_create_hcd(const struct hc_driver *driver,
2520 hcd->bandwidth_mutex = kmalloc(sizeof(*hcd->bandwidth_mutex), 2520 hcd->bandwidth_mutex = kmalloc(sizeof(*hcd->bandwidth_mutex),
2521 GFP_KERNEL); 2521 GFP_KERNEL);
2522 if (!hcd->bandwidth_mutex) { 2522 if (!hcd->bandwidth_mutex) {
2523 kfree(hcd->address0_mutex);
2523 kfree(hcd); 2524 kfree(hcd);
2524 dev_dbg(dev, "hcd bandwidth mutex alloc failed\n"); 2525 dev_dbg(dev, "hcd bandwidth mutex alloc failed\n");
2525 return NULL; 2526 return NULL;
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 9dca59ef18b3..b8bb20d7acdb 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -362,7 +362,8 @@ static void usb_set_lpm_parameters(struct usb_device *udev)
362} 362}
363 363
364/* USB 2.0 spec Section 11.24.4.5 */ 364/* USB 2.0 spec Section 11.24.4.5 */
365static int get_hub_descriptor(struct usb_device *hdev, void *data) 365static int get_hub_descriptor(struct usb_device *hdev,
366 struct usb_hub_descriptor *desc)
366{ 367{
367 int i, ret, size; 368 int i, ret, size;
368 unsigned dtype; 369 unsigned dtype;
@@ -378,10 +379,18 @@ static int get_hub_descriptor(struct usb_device *hdev, void *data)
378 for (i = 0; i < 3; i++) { 379 for (i = 0; i < 3; i++) {
379 ret = usb_control_msg(hdev, usb_rcvctrlpipe(hdev, 0), 380 ret = usb_control_msg(hdev, usb_rcvctrlpipe(hdev, 0),
380 USB_REQ_GET_DESCRIPTOR, USB_DIR_IN | USB_RT_HUB, 381 USB_REQ_GET_DESCRIPTOR, USB_DIR_IN | USB_RT_HUB,
381 dtype << 8, 0, data, size, 382 dtype << 8, 0, desc, size,
382 USB_CTRL_GET_TIMEOUT); 383 USB_CTRL_GET_TIMEOUT);
383 if (ret >= (USB_DT_HUB_NONVAR_SIZE + 2)) 384 if (hub_is_superspeed(hdev)) {
385 if (ret == size)
386 return ret;
387 } else if (ret >= USB_DT_HUB_NONVAR_SIZE + 2) {
388 /* Make sure we have the DeviceRemovable field. */
389 size = USB_DT_HUB_NONVAR_SIZE + desc->bNbrPorts / 8 + 1;
390 if (ret < size)
391 return -EMSGSIZE;
384 return ret; 392 return ret;
393 }
385 } 394 }
386 return -EINVAL; 395 return -EINVAL;
387} 396}
@@ -1313,7 +1322,7 @@ static int hub_configure(struct usb_hub *hub,
1313 } 1322 }
1314 mutex_init(&hub->status_mutex); 1323 mutex_init(&hub->status_mutex);
1315 1324
1316 hub->descriptor = kmalloc(sizeof(*hub->descriptor), GFP_KERNEL); 1325 hub->descriptor = kzalloc(sizeof(*hub->descriptor), GFP_KERNEL);
1317 if (!hub->descriptor) { 1326 if (!hub->descriptor) {
1318 ret = -ENOMEM; 1327 ret = -ENOMEM;
1319 goto fail; 1328 goto fail;
@@ -1321,13 +1330,19 @@ static int hub_configure(struct usb_hub *hub,
1321 1330
1322 /* Request the entire hub descriptor. 1331 /* Request the entire hub descriptor.
1323 * hub->descriptor can handle USB_MAXCHILDREN ports, 1332 * hub->descriptor can handle USB_MAXCHILDREN ports,
1324 * but the hub can/will return fewer bytes here. 1333 * but a (non-SS) hub can/will return fewer bytes here.
1325 */ 1334 */
1326 ret = get_hub_descriptor(hdev, hub->descriptor); 1335 ret = get_hub_descriptor(hdev, hub->descriptor);
1327 if (ret < 0) { 1336 if (ret < 0) {
1328 message = "can't read hub descriptor"; 1337 message = "can't read hub descriptor";
1329 goto fail; 1338 goto fail;
1330 } else if (hub->descriptor->bNbrPorts > USB_MAXCHILDREN) { 1339 }
1340
1341 maxchild = USB_MAXCHILDREN;
1342 if (hub_is_superspeed(hdev))
1343 maxchild = min_t(unsigned, maxchild, USB_SS_MAXPORTS);
1344
1345 if (hub->descriptor->bNbrPorts > maxchild) {
1331 message = "hub has too many ports!"; 1346 message = "hub has too many ports!";
1332 ret = -ENODEV; 1347 ret = -ENODEV;
1333 goto fail; 1348 goto fail;
diff --git a/drivers/usb/core/of.c b/drivers/usb/core/of.c
index d787f195a9a6..d563cbcf76cf 100644
--- a/drivers/usb/core/of.c
+++ b/drivers/usb/core/of.c
@@ -53,6 +53,9 @@ EXPORT_SYMBOL_GPL(usb_of_get_child_node);
53 * 53 *
54 * Find the companion device from platform bus. 54 * Find the companion device from platform bus.
55 * 55 *
56 * Takes a reference to the returned struct device which needs to be dropped
57 * after use.
58 *
56 * Return: On success, a pointer to the companion device, %NULL on failure. 59 * Return: On success, a pointer to the companion device, %NULL on failure.
57 */ 60 */
58struct device *usb_of_get_companion_dev(struct device *dev) 61struct device *usb_of_get_companion_dev(struct device *dev)
diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c
index d75cb8c0f7df..47903d510955 100644
--- a/drivers/usb/core/urb.c
+++ b/drivers/usb/core/urb.c
@@ -338,7 +338,7 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags)
338 if (!urb || !urb->complete) 338 if (!urb || !urb->complete)
339 return -EINVAL; 339 return -EINVAL;
340 if (urb->hcpriv) { 340 if (urb->hcpriv) {
341 WARN_ONCE(1, "URB %p submitted while active\n", urb); 341 WARN_ONCE(1, "URB %pK submitted while active\n", urb);
342 return -EBUSY; 342 return -EBUSY;
343 } 343 }
344 344
diff --git a/drivers/usb/dwc3/dwc3-keystone.c b/drivers/usb/dwc3/dwc3-keystone.c
index 72664700b8a2..12ee23f53cdd 100644
--- a/drivers/usb/dwc3/dwc3-keystone.c
+++ b/drivers/usb/dwc3/dwc3-keystone.c
@@ -107,6 +107,10 @@ static int kdwc3_probe(struct platform_device *pdev)
107 return PTR_ERR(kdwc->usbss); 107 return PTR_ERR(kdwc->usbss);
108 108
109 kdwc->clk = devm_clk_get(kdwc->dev, "usb"); 109 kdwc->clk = devm_clk_get(kdwc->dev, "usb");
110 if (IS_ERR(kdwc->clk)) {
111 dev_err(kdwc->dev, "unable to get usb clock\n");
112 return PTR_ERR(kdwc->clk);
113 }
110 114
111 error = clk_prepare_enable(kdwc->clk); 115 error = clk_prepare_enable(kdwc->clk);
112 if (error < 0) { 116 if (error < 0) {
diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c
index a15ec71d0423..84a2cebfc712 100644
--- a/drivers/usb/dwc3/dwc3-pci.c
+++ b/drivers/usb/dwc3/dwc3-pci.c
@@ -39,6 +39,8 @@
39#define PCI_DEVICE_ID_INTEL_APL 0x5aaa 39#define PCI_DEVICE_ID_INTEL_APL 0x5aaa
40#define PCI_DEVICE_ID_INTEL_KBP 0xa2b0 40#define PCI_DEVICE_ID_INTEL_KBP 0xa2b0
41#define PCI_DEVICE_ID_INTEL_GLK 0x31aa 41#define PCI_DEVICE_ID_INTEL_GLK 0x31aa
42#define PCI_DEVICE_ID_INTEL_CNPLP 0x9dee
43#define PCI_DEVICE_ID_INTEL_CNPH 0xa36e
42 44
43#define PCI_INTEL_BXT_DSM_UUID "732b85d5-b7a7-4a1b-9ba0-4bbd00ffd511" 45#define PCI_INTEL_BXT_DSM_UUID "732b85d5-b7a7-4a1b-9ba0-4bbd00ffd511"
44#define PCI_INTEL_BXT_FUNC_PMU_PWR 4 46#define PCI_INTEL_BXT_FUNC_PMU_PWR 4
@@ -270,6 +272,8 @@ static const struct pci_device_id dwc3_pci_id_table[] = {
270 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_APL), }, 272 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_APL), },
271 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_KBP), }, 273 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_KBP), },
272 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_GLK), }, 274 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_GLK), },
275 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_CNPLP), },
276 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_CNPH), },
273 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_NL_USB), }, 277 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_NL_USB), },
274 { } /* Terminating Entry */ 278 { } /* Terminating Entry */
275}; 279};
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 6f6f0b3be3ad..aea9a5b948b4 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -1261,14 +1261,24 @@ static int __dwc3_gadget_ep_queue(struct dwc3_ep *dep, struct dwc3_request *req)
1261 __dwc3_gadget_start_isoc(dwc, dep, cur_uf); 1261 __dwc3_gadget_start_isoc(dwc, dep, cur_uf);
1262 dep->flags &= ~DWC3_EP_PENDING_REQUEST; 1262 dep->flags &= ~DWC3_EP_PENDING_REQUEST;
1263 } 1263 }
1264 return 0;
1264 } 1265 }
1265 return 0; 1266
1267 if ((dep->flags & DWC3_EP_BUSY) &&
1268 !(dep->flags & DWC3_EP_MISSED_ISOC)) {
1269 WARN_ON_ONCE(!dep->resource_index);
1270 ret = __dwc3_gadget_kick_transfer(dep,
1271 dep->resource_index);
1272 }
1273
1274 goto out;
1266 } 1275 }
1267 1276
1268 if (!dwc3_calc_trbs_left(dep)) 1277 if (!dwc3_calc_trbs_left(dep))
1269 return 0; 1278 return 0;
1270 1279
1271 ret = __dwc3_gadget_kick_transfer(dep, 0); 1280 ret = __dwc3_gadget_kick_transfer(dep, 0);
1281out:
1272 if (ret == -EBUSY) 1282 if (ret == -EBUSY)
1273 ret = 0; 1283 ret = 0;
1274 1284
@@ -3026,6 +3036,15 @@ static irqreturn_t dwc3_check_event_buf(struct dwc3_event_buffer *evt)
3026 return IRQ_HANDLED; 3036 return IRQ_HANDLED;
3027 } 3037 }
3028 3038
3039 /*
3040 * With PCIe legacy interrupt, test shows that top-half irq handler can
3041 * be called again after HW interrupt deassertion. Check if bottom-half
3042 * irq event handler completes before caching new event to prevent
3043 * losing events.
3044 */
3045 if (evt->flags & DWC3_EVENT_PENDING)
3046 return IRQ_HANDLED;
3047
3029 count = dwc3_readl(dwc->regs, DWC3_GEVNTCOUNT(0)); 3048 count = dwc3_readl(dwc->regs, DWC3_GEVNTCOUNT(0));
3030 count &= DWC3_GEVNTCOUNT_MASK; 3049 count &= DWC3_GEVNTCOUNT_MASK;
3031 if (!count) 3050 if (!count)
diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
index 71dd27c0d7f2..47dda3450abd 100644
--- a/drivers/usb/gadget/function/f_fs.c
+++ b/drivers/usb/gadget/function/f_fs.c
@@ -1858,12 +1858,12 @@ static int ffs_func_eps_enable(struct ffs_function *func)
1858 ep->ep->driver_data = ep; 1858 ep->ep->driver_data = ep;
1859 ep->ep->desc = ds; 1859 ep->ep->desc = ds;
1860 1860
1861 comp_desc = (struct usb_ss_ep_comp_descriptor *)(ds + 1861 if (needs_comp_desc) {
1862 USB_DT_ENDPOINT_SIZE); 1862 comp_desc = (struct usb_ss_ep_comp_descriptor *)(ds +
1863 ep->ep->maxburst = comp_desc->bMaxBurst + 1; 1863 USB_DT_ENDPOINT_SIZE);
1864 1864 ep->ep->maxburst = comp_desc->bMaxBurst + 1;
1865 if (needs_comp_desc)
1866 ep->ep->comp_desc = comp_desc; 1865 ep->ep->comp_desc = comp_desc;
1866 }
1867 1867
1868 ret = usb_ep_enable(ep->ep); 1868 ret = usb_ep_enable(ep->ep);
1869 if (likely(!ret)) { 1869 if (likely(!ret)) {
diff --git a/drivers/usb/gadget/function/u_serial.c b/drivers/usb/gadget/function/u_serial.c
index 000677c991b0..9b0805f55ad7 100644
--- a/drivers/usb/gadget/function/u_serial.c
+++ b/drivers/usb/gadget/function/u_serial.c
@@ -1256,7 +1256,7 @@ static void gserial_console_exit(void)
1256 struct gscons_info *info = &gscons_info; 1256 struct gscons_info *info = &gscons_info;
1257 1257
1258 unregister_console(&gserial_cons); 1258 unregister_console(&gserial_cons);
1259 if (info->console_thread != NULL) 1259 if (!IS_ERR_OR_NULL(info->console_thread))
1260 kthread_stop(info->console_thread); 1260 kthread_stop(info->console_thread);
1261 gs_buf_free(&info->con_buf); 1261 gs_buf_free(&info->con_buf);
1262} 1262}
diff --git a/drivers/usb/gadget/udc/dummy_hcd.c b/drivers/usb/gadget/udc/dummy_hcd.c
index c79081952ea0..ccabb51cb98d 100644
--- a/drivers/usb/gadget/udc/dummy_hcd.c
+++ b/drivers/usb/gadget/udc/dummy_hcd.c
@@ -2008,7 +2008,7 @@ ss_hub_descriptor(struct usb_hub_descriptor *desc)
2008 HUB_CHAR_COMMON_OCPM); 2008 HUB_CHAR_COMMON_OCPM);
2009 desc->bNbrPorts = 1; 2009 desc->bNbrPorts = 1;
2010 desc->u.ss.bHubHdrDecLat = 0x04; /* Worst case: 0.4 micro sec*/ 2010 desc->u.ss.bHubHdrDecLat = 0x04; /* Worst case: 0.4 micro sec*/
2011 desc->u.ss.DeviceRemovable = 0xffff; 2011 desc->u.ss.DeviceRemovable = 0;
2012} 2012}
2013 2013
2014static inline void hub_descriptor(struct usb_hub_descriptor *desc) 2014static inline void hub_descriptor(struct usb_hub_descriptor *desc)
@@ -2020,8 +2020,8 @@ static inline void hub_descriptor(struct usb_hub_descriptor *desc)
2020 HUB_CHAR_INDV_PORT_LPSM | 2020 HUB_CHAR_INDV_PORT_LPSM |
2021 HUB_CHAR_COMMON_OCPM); 2021 HUB_CHAR_COMMON_OCPM);
2022 desc->bNbrPorts = 1; 2022 desc->bNbrPorts = 1;
2023 desc->u.hs.DeviceRemovable[0] = 0xff; 2023 desc->u.hs.DeviceRemovable[0] = 0;
2024 desc->u.hs.DeviceRemovable[1] = 0xff; 2024 desc->u.hs.DeviceRemovable[1] = 0xff; /* PortPwrCtrlMask */
2025} 2025}
2026 2026
2027static int dummy_hub_control( 2027static int dummy_hub_control(
diff --git a/drivers/usb/host/ehci-platform.c b/drivers/usb/host/ehci-platform.c
index bc7b9be12f54..f1908ea9fbd8 100644
--- a/drivers/usb/host/ehci-platform.c
+++ b/drivers/usb/host/ehci-platform.c
@@ -384,8 +384,10 @@ static int ehci_platform_resume(struct device *dev)
384 } 384 }
385 385
386 companion_dev = usb_of_get_companion_dev(hcd->self.controller); 386 companion_dev = usb_of_get_companion_dev(hcd->self.controller);
387 if (companion_dev) 387 if (companion_dev) {
388 device_pm_wait_for_dev(hcd->self.controller, companion_dev); 388 device_pm_wait_for_dev(hcd->self.controller, companion_dev);
389 put_device(companion_dev);
390 }
389 391
390 ehci_resume(hcd, priv->reset_on_resume); 392 ehci_resume(hcd, priv->reset_on_resume);
391 return 0; 393 return 0;
diff --git a/drivers/usb/host/r8a66597-hcd.c b/drivers/usb/host/r8a66597-hcd.c
index bfa7fa3d2eea..7bf78be1fd32 100644
--- a/drivers/usb/host/r8a66597-hcd.c
+++ b/drivers/usb/host/r8a66597-hcd.c
@@ -1269,7 +1269,7 @@ static void set_td_timer(struct r8a66597 *r8a66597, struct r8a66597_td *td)
1269 time = 30; 1269 time = 30;
1270 break; 1270 break;
1271 default: 1271 default:
1272 time = 300; 1272 time = 50;
1273 break; 1273 break;
1274 } 1274 }
1275 1275
@@ -1785,6 +1785,7 @@ static void r8a66597_td_timer(unsigned long _r8a66597)
1785 pipe = td->pipe; 1785 pipe = td->pipe;
1786 pipe_stop(r8a66597, pipe); 1786 pipe_stop(r8a66597, pipe);
1787 1787
1788 /* Select a different address or endpoint */
1788 new_td = td; 1789 new_td = td;
1789 do { 1790 do {
1790 list_move_tail(&new_td->queue, 1791 list_move_tail(&new_td->queue,
@@ -1794,7 +1795,8 @@ static void r8a66597_td_timer(unsigned long _r8a66597)
1794 new_td = td; 1795 new_td = td;
1795 break; 1796 break;
1796 } 1797 }
1797 } while (td != new_td && td->address == new_td->address); 1798 } while (td != new_td && td->address == new_td->address &&
1799 td->pipe->info.epnum == new_td->pipe->info.epnum);
1798 1800
1799 start_transfer(r8a66597, new_td); 1801 start_transfer(r8a66597, new_td);
1800 1802
diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
index 5e3e9d4c6956..0dde49c35dd2 100644
--- a/drivers/usb/host/xhci-hub.c
+++ b/drivers/usb/host/xhci-hub.c
@@ -419,7 +419,7 @@ static int xhci_stop_device(struct xhci_hcd *xhci, int slot_id, int suspend)
419 wait_for_completion(cmd->completion); 419 wait_for_completion(cmd->completion);
420 420
421 if (cmd->status == COMP_COMMAND_ABORTED || 421 if (cmd->status == COMP_COMMAND_ABORTED ||
422 cmd->status == COMP_STOPPED) { 422 cmd->status == COMP_COMMAND_RING_STOPPED) {
423 xhci_warn(xhci, "Timeout while waiting for stop endpoint command\n"); 423 xhci_warn(xhci, "Timeout while waiting for stop endpoint command\n");
424 ret = -ETIME; 424 ret = -ETIME;
425 } 425 }
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index bbe22bcc550a..1f1687e888d6 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -56,7 +56,7 @@ static struct xhci_segment *xhci_segment_alloc(struct xhci_hcd *xhci,
56 } 56 }
57 57
58 if (max_packet) { 58 if (max_packet) {
59 seg->bounce_buf = kzalloc(max_packet, flags | GFP_DMA); 59 seg->bounce_buf = kzalloc(max_packet, flags);
60 if (!seg->bounce_buf) { 60 if (!seg->bounce_buf) {
61 dma_pool_free(xhci->segment_pool, seg->trbs, dma); 61 dma_pool_free(xhci->segment_pool, seg->trbs, dma);
62 kfree(seg); 62 kfree(seg);
@@ -1724,7 +1724,7 @@ static int scratchpad_alloc(struct xhci_hcd *xhci, gfp_t flags)
1724 xhci->dcbaa->dev_context_ptrs[0] = cpu_to_le64(xhci->scratchpad->sp_dma); 1724 xhci->dcbaa->dev_context_ptrs[0] = cpu_to_le64(xhci->scratchpad->sp_dma);
1725 for (i = 0; i < num_sp; i++) { 1725 for (i = 0; i < num_sp; i++) {
1726 dma_addr_t dma; 1726 dma_addr_t dma;
1727 void *buf = dma_alloc_coherent(dev, xhci->page_size, &dma, 1727 void *buf = dma_zalloc_coherent(dev, xhci->page_size, &dma,
1728 flags); 1728 flags);
1729 if (!buf) 1729 if (!buf)
1730 goto fail_sp4; 1730 goto fail_sp4;
@@ -2307,10 +2307,11 @@ static int xhci_setup_port_arrays(struct xhci_hcd *xhci, gfp_t flags)
2307 /* Place limits on the number of roothub ports so that the hub 2307 /* Place limits on the number of roothub ports so that the hub
2308 * descriptors aren't longer than the USB core will allocate. 2308 * descriptors aren't longer than the USB core will allocate.
2309 */ 2309 */
2310 if (xhci->num_usb3_ports > 15) { 2310 if (xhci->num_usb3_ports > USB_SS_MAXPORTS) {
2311 xhci_dbg_trace(xhci, trace_xhci_dbg_init, 2311 xhci_dbg_trace(xhci, trace_xhci_dbg_init,
2312 "Limiting USB 3.0 roothub ports to 15."); 2312 "Limiting USB 3.0 roothub ports to %u.",
2313 xhci->num_usb3_ports = 15; 2313 USB_SS_MAXPORTS);
2314 xhci->num_usb3_ports = USB_SS_MAXPORTS;
2314 } 2315 }
2315 if (xhci->num_usb2_ports > USB_MAXCHILDREN) { 2316 if (xhci->num_usb2_ports > USB_MAXCHILDREN) {
2316 xhci_dbg_trace(xhci, trace_xhci_dbg_init, 2317 xhci_dbg_trace(xhci, trace_xhci_dbg_init,
diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
index 7b86508ac8cf..fcf1f3f63e7a 100644
--- a/drivers/usb/host/xhci-pci.c
+++ b/drivers/usb/host/xhci-pci.c
@@ -52,6 +52,7 @@
52#define PCI_DEVICE_ID_INTEL_BROXTON_M_XHCI 0x0aa8 52#define PCI_DEVICE_ID_INTEL_BROXTON_M_XHCI 0x0aa8
53#define PCI_DEVICE_ID_INTEL_BROXTON_B_XHCI 0x1aa8 53#define PCI_DEVICE_ID_INTEL_BROXTON_B_XHCI 0x1aa8
54#define PCI_DEVICE_ID_INTEL_APL_XHCI 0x5aa8 54#define PCI_DEVICE_ID_INTEL_APL_XHCI 0x5aa8
55#define PCI_DEVICE_ID_INTEL_DNV_XHCI 0x19d0
55 56
56static const char hcd_name[] = "xhci_hcd"; 57static const char hcd_name[] = "xhci_hcd";
57 58
@@ -166,7 +167,8 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
166 pdev->device == PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI || 167 pdev->device == PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI ||
167 pdev->device == PCI_DEVICE_ID_INTEL_BROXTON_M_XHCI || 168 pdev->device == PCI_DEVICE_ID_INTEL_BROXTON_M_XHCI ||
168 pdev->device == PCI_DEVICE_ID_INTEL_BROXTON_B_XHCI || 169 pdev->device == PCI_DEVICE_ID_INTEL_BROXTON_B_XHCI ||
169 pdev->device == PCI_DEVICE_ID_INTEL_APL_XHCI)) { 170 pdev->device == PCI_DEVICE_ID_INTEL_APL_XHCI ||
171 pdev->device == PCI_DEVICE_ID_INTEL_DNV_XHCI)) {
170 xhci->quirks |= XHCI_PME_STUCK_QUIRK; 172 xhci->quirks |= XHCI_PME_STUCK_QUIRK;
171 } 173 }
172 if (pdev->vendor == PCI_VENDOR_ID_INTEL && 174 if (pdev->vendor == PCI_VENDOR_ID_INTEL &&
@@ -175,7 +177,8 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
175 } 177 }
176 if (pdev->vendor == PCI_VENDOR_ID_INTEL && 178 if (pdev->vendor == PCI_VENDOR_ID_INTEL &&
177 (pdev->device == PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI || 179 (pdev->device == PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI ||
178 pdev->device == PCI_DEVICE_ID_INTEL_APL_XHCI)) 180 pdev->device == PCI_DEVICE_ID_INTEL_APL_XHCI ||
181 pdev->device == PCI_DEVICE_ID_INTEL_DNV_XHCI))
179 xhci->quirks |= XHCI_MISSING_CAS; 182 xhci->quirks |= XHCI_MISSING_CAS;
180 183
181 if (pdev->vendor == PCI_VENDOR_ID_ETRON && 184 if (pdev->vendor == PCI_VENDOR_ID_ETRON &&
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 7c2a9e7c8e0f..c04144b25a67 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -177,7 +177,7 @@ static int xhci_plat_probe(struct platform_device *pdev)
177 177
178 irq = platform_get_irq(pdev, 0); 178 irq = platform_get_irq(pdev, 0);
179 if (irq < 0) 179 if (irq < 0)
180 return -ENODEV; 180 return irq;
181 181
182 /* 182 /*
183 * sysdev must point to a device that is known to the system firmware 183 * sysdev must point to a device that is known to the system firmware
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 74bf5c60a260..03f63f50afb6 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -323,7 +323,7 @@ static void xhci_handle_stopped_cmd_ring(struct xhci_hcd *xhci,
323 if (i_cmd->status != COMP_COMMAND_ABORTED) 323 if (i_cmd->status != COMP_COMMAND_ABORTED)
324 continue; 324 continue;
325 325
326 i_cmd->status = COMP_STOPPED; 326 i_cmd->status = COMP_COMMAND_RING_STOPPED;
327 327
328 xhci_dbg(xhci, "Turn aborted command %p to no-op\n", 328 xhci_dbg(xhci, "Turn aborted command %p to no-op\n",
329 i_cmd->command_trb); 329 i_cmd->command_trb);
@@ -641,8 +641,8 @@ static void xhci_giveback_urb_in_irq(struct xhci_hcd *xhci,
641 xhci_urb_free_priv(urb_priv); 641 xhci_urb_free_priv(urb_priv);
642 usb_hcd_unlink_urb_from_ep(hcd, urb); 642 usb_hcd_unlink_urb_from_ep(hcd, urb);
643 spin_unlock(&xhci->lock); 643 spin_unlock(&xhci->lock);
644 usb_hcd_giveback_urb(hcd, urb, status);
645 trace_xhci_urb_giveback(urb); 644 trace_xhci_urb_giveback(urb);
645 usb_hcd_giveback_urb(hcd, urb, status);
646 spin_lock(&xhci->lock); 646 spin_lock(&xhci->lock);
647} 647}
648 648
@@ -1380,7 +1380,7 @@ static void handle_cmd_completion(struct xhci_hcd *xhci,
1380 cmd_comp_code = GET_COMP_CODE(le32_to_cpu(event->status)); 1380 cmd_comp_code = GET_COMP_CODE(le32_to_cpu(event->status));
1381 1381
1382 /* If CMD ring stopped we own the trbs between enqueue and dequeue */ 1382 /* If CMD ring stopped we own the trbs between enqueue and dequeue */
1383 if (cmd_comp_code == COMP_STOPPED) { 1383 if (cmd_comp_code == COMP_COMMAND_RING_STOPPED) {
1384 complete_all(&xhci->cmd_ring_stop_completion); 1384 complete_all(&xhci->cmd_ring_stop_completion);
1385 return; 1385 return;
1386 } 1386 }
@@ -1436,8 +1436,8 @@ static void handle_cmd_completion(struct xhci_hcd *xhci,
1436 break; 1436 break;
1437 case TRB_CMD_NOOP: 1437 case TRB_CMD_NOOP:
1438 /* Is this an aborted command turned to NO-OP? */ 1438 /* Is this an aborted command turned to NO-OP? */
1439 if (cmd->status == COMP_STOPPED) 1439 if (cmd->status == COMP_COMMAND_RING_STOPPED)
1440 cmd_comp_code = COMP_STOPPED; 1440 cmd_comp_code = COMP_COMMAND_RING_STOPPED;
1441 break; 1441 break;
1442 case TRB_RESET_EP: 1442 case TRB_RESET_EP:
1443 WARN_ON(slot_id != TRB_TO_SLOT_ID( 1443 WARN_ON(slot_id != TRB_TO_SLOT_ID(
@@ -2677,11 +2677,12 @@ irqreturn_t xhci_irq(struct usb_hcd *hcd)
2677 struct xhci_hcd *xhci = hcd_to_xhci(hcd); 2677 struct xhci_hcd *xhci = hcd_to_xhci(hcd);
2678 union xhci_trb *event_ring_deq; 2678 union xhci_trb *event_ring_deq;
2679 irqreturn_t ret = IRQ_NONE; 2679 irqreturn_t ret = IRQ_NONE;
2680 unsigned long flags;
2680 dma_addr_t deq; 2681 dma_addr_t deq;
2681 u64 temp_64; 2682 u64 temp_64;
2682 u32 status; 2683 u32 status;
2683 2684
2684 spin_lock(&xhci->lock); 2685 spin_lock_irqsave(&xhci->lock, flags);
2685 /* Check if the xHC generated the interrupt, or the irq is shared */ 2686 /* Check if the xHC generated the interrupt, or the irq is shared */
2686 status = readl(&xhci->op_regs->status); 2687 status = readl(&xhci->op_regs->status);
2687 if (status == ~(u32)0) { 2688 if (status == ~(u32)0) {
@@ -2707,12 +2708,9 @@ irqreturn_t xhci_irq(struct usb_hcd *hcd)
2707 */ 2708 */
2708 status |= STS_EINT; 2709 status |= STS_EINT;
2709 writel(status, &xhci->op_regs->status); 2710 writel(status, &xhci->op_regs->status);
2710 /* FIXME when MSI-X is supported and there are multiple vectors */
2711 /* Clear the MSI-X event interrupt status */
2712 2711
2713 if (hcd->irq) { 2712 if (!hcd->msi_enabled) {
2714 u32 irq_pending; 2713 u32 irq_pending;
2715 /* Acknowledge the PCI interrupt */
2716 irq_pending = readl(&xhci->ir_set->irq_pending); 2714 irq_pending = readl(&xhci->ir_set->irq_pending);
2717 irq_pending |= IMAN_IP; 2715 irq_pending |= IMAN_IP;
2718 writel(irq_pending, &xhci->ir_set->irq_pending); 2716 writel(irq_pending, &xhci->ir_set->irq_pending);
@@ -2757,7 +2755,7 @@ irqreturn_t xhci_irq(struct usb_hcd *hcd)
2757 ret = IRQ_HANDLED; 2755 ret = IRQ_HANDLED;
2758 2756
2759out: 2757out:
2760 spin_unlock(&xhci->lock); 2758 spin_unlock_irqrestore(&xhci->lock, flags);
2761 2759
2762 return ret; 2760 return ret;
2763} 2761}
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 2d1310220832..30f47d92a610 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -359,9 +359,10 @@ static int xhci_try_enable_msi(struct usb_hcd *hcd)
359 /* fall back to msi*/ 359 /* fall back to msi*/
360 ret = xhci_setup_msi(xhci); 360 ret = xhci_setup_msi(xhci);
361 361
362 if (!ret) 362 if (!ret) {
363 /* hcd->irq is 0, we have MSI */ 363 hcd->msi_enabled = 1;
364 return 0; 364 return 0;
365 }
365 366
366 if (!pdev->irq) { 367 if (!pdev->irq) {
367 xhci_err(xhci, "No msi-x/msi found and no IRQ in BIOS\n"); 368 xhci_err(xhci, "No msi-x/msi found and no IRQ in BIOS\n");
@@ -1763,7 +1764,7 @@ static int xhci_configure_endpoint_result(struct xhci_hcd *xhci,
1763 1764
1764 switch (*cmd_status) { 1765 switch (*cmd_status) {
1765 case COMP_COMMAND_ABORTED: 1766 case COMP_COMMAND_ABORTED:
1766 case COMP_STOPPED: 1767 case COMP_COMMAND_RING_STOPPED:
1767 xhci_warn(xhci, "Timeout while waiting for configure endpoint command\n"); 1768 xhci_warn(xhci, "Timeout while waiting for configure endpoint command\n");
1768 ret = -ETIME; 1769 ret = -ETIME;
1769 break; 1770 break;
@@ -1813,7 +1814,7 @@ static int xhci_evaluate_context_result(struct xhci_hcd *xhci,
1813 1814
1814 switch (*cmd_status) { 1815 switch (*cmd_status) {
1815 case COMP_COMMAND_ABORTED: 1816 case COMP_COMMAND_ABORTED:
1816 case COMP_STOPPED: 1817 case COMP_COMMAND_RING_STOPPED:
1817 xhci_warn(xhci, "Timeout while waiting for evaluate context command\n"); 1818 xhci_warn(xhci, "Timeout while waiting for evaluate context command\n");
1818 ret = -ETIME; 1819 ret = -ETIME;
1819 break; 1820 break;
@@ -3432,7 +3433,7 @@ static int xhci_discover_or_reset_device(struct usb_hcd *hcd,
3432 ret = reset_device_cmd->status; 3433 ret = reset_device_cmd->status;
3433 switch (ret) { 3434 switch (ret) {
3434 case COMP_COMMAND_ABORTED: 3435 case COMP_COMMAND_ABORTED:
3435 case COMP_STOPPED: 3436 case COMP_COMMAND_RING_STOPPED:
3436 xhci_warn(xhci, "Timeout waiting for reset device command\n"); 3437 xhci_warn(xhci, "Timeout waiting for reset device command\n");
3437 ret = -ETIME; 3438 ret = -ETIME;
3438 goto command_cleanup; 3439 goto command_cleanup;
@@ -3817,7 +3818,7 @@ static int xhci_setup_device(struct usb_hcd *hcd, struct usb_device *udev,
3817 */ 3818 */
3818 switch (command->status) { 3819 switch (command->status) {
3819 case COMP_COMMAND_ABORTED: 3820 case COMP_COMMAND_ABORTED:
3820 case COMP_STOPPED: 3821 case COMP_COMMAND_RING_STOPPED:
3821 xhci_warn(xhci, "Timeout while waiting for setup device command\n"); 3822 xhci_warn(xhci, "Timeout while waiting for setup device command\n");
3822 ret = -ETIME; 3823 ret = -ETIME;
3823 break; 3824 break;
diff --git a/drivers/usb/misc/chaoskey.c b/drivers/usb/misc/chaoskey.c
index e9cae4d82af2..15d4e64d3b65 100644
--- a/drivers/usb/misc/chaoskey.c
+++ b/drivers/usb/misc/chaoskey.c
@@ -192,7 +192,7 @@ static int chaoskey_probe(struct usb_interface *interface,
192 192
193 dev->in_ep = in_ep; 193 dev->in_ep = in_ep;
194 194
195 if (udev->descriptor.idVendor != ALEA_VENDOR_ID) 195 if (le16_to_cpu(udev->descriptor.idVendor) != ALEA_VENDOR_ID)
196 dev->reads_started = 1; 196 dev->reads_started = 1;
197 197
198 dev->size = size; 198 dev->size = size;
diff --git a/drivers/usb/misc/iowarrior.c b/drivers/usb/misc/iowarrior.c
index 77569531b78a..83b05a287b0c 100644
--- a/drivers/usb/misc/iowarrior.c
+++ b/drivers/usb/misc/iowarrior.c
@@ -554,7 +554,7 @@ static long iowarrior_ioctl(struct file *file, unsigned int cmd,
554 info.revision = le16_to_cpu(dev->udev->descriptor.bcdDevice); 554 info.revision = le16_to_cpu(dev->udev->descriptor.bcdDevice);
555 555
556 /* 0==UNKNOWN, 1==LOW(usb1.1) ,2=FULL(usb1.1), 3=HIGH(usb2.0) */ 556 /* 0==UNKNOWN, 1==LOW(usb1.1) ,2=FULL(usb1.1), 3=HIGH(usb2.0) */
557 info.speed = le16_to_cpu(dev->udev->speed); 557 info.speed = dev->udev->speed;
558 info.if_num = dev->interface->cur_altsetting->desc.bInterfaceNumber; 558 info.if_num = dev->interface->cur_altsetting->desc.bInterfaceNumber;
559 info.report_size = dev->report_size; 559 info.report_size = dev->report_size;
560 560
diff --git a/drivers/usb/misc/legousbtower.c b/drivers/usb/misc/legousbtower.c
index aa3c280fdf8d..0782ac6f5edf 100644
--- a/drivers/usb/misc/legousbtower.c
+++ b/drivers/usb/misc/legousbtower.c
@@ -926,6 +926,7 @@ static int tower_probe (struct usb_interface *interface, const struct usb_device
926 USB_MAJOR, dev->minor); 926 USB_MAJOR, dev->minor);
927 927
928exit: 928exit:
929 kfree(get_version_reply);
929 return retval; 930 return retval;
930 931
931error: 932error:
diff --git a/drivers/usb/misc/sisusbvga/sisusb_con.c b/drivers/usb/misc/sisusbvga/sisusb_con.c
index 3c6948af726a..f019d80ca9e4 100644
--- a/drivers/usb/misc/sisusbvga/sisusb_con.c
+++ b/drivers/usb/misc/sisusbvga/sisusb_con.c
@@ -973,7 +973,7 @@ sisusbcon_set_origin(struct vc_data *c)
973 973
974 mutex_unlock(&sisusb->lock); 974 mutex_unlock(&sisusb->lock);
975 975
976 return 1; 976 return true;
977} 977}
978 978
979/* Interface routine */ 979/* Interface routine */
diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
index ac3a4952abb4..dbe617a735d8 100644
--- a/drivers/usb/musb/musb_host.c
+++ b/drivers/usb/musb/musb_host.c
@@ -2780,10 +2780,11 @@ int musb_host_setup(struct musb *musb, int power_budget)
2780 int ret; 2780 int ret;
2781 struct usb_hcd *hcd = musb->hcd; 2781 struct usb_hcd *hcd = musb->hcd;
2782 2782
2783 MUSB_HST_MODE(musb); 2783 if (musb->port_mode == MUSB_PORT_MODE_HOST) {
2784 musb->xceiv->otg->default_a = 1; 2784 MUSB_HST_MODE(musb);
2785 musb->xceiv->otg->state = OTG_STATE_A_IDLE; 2785 musb->xceiv->otg->default_a = 1;
2786 2786 musb->xceiv->otg->state = OTG_STATE_A_IDLE;
2787 }
2787 otg_set_host(musb->xceiv->otg, &hcd->self); 2788 otg_set_host(musb->xceiv->otg, &hcd->self);
2788 hcd->self.otg_port = 1; 2789 hcd->self.otg_port = 1;
2789 musb->xceiv->otg->host = &hcd->self; 2790 musb->xceiv->otg->host = &hcd->self;
diff --git a/drivers/usb/musb/tusb6010_omap.c b/drivers/usb/musb/tusb6010_omap.c
index 8b43c4b99f04..7870b37e0ea5 100644
--- a/drivers/usb/musb/tusb6010_omap.c
+++ b/drivers/usb/musb/tusb6010_omap.c
@@ -219,6 +219,7 @@ static int tusb_omap_dma_program(struct dma_channel *channel, u16 packet_sz,
219 u32 dma_remaining; 219 u32 dma_remaining;
220 int src_burst, dst_burst; 220 int src_burst, dst_burst;
221 u16 csr; 221 u16 csr;
222 u32 psize;
222 int ch; 223 int ch;
223 s8 dmareq; 224 s8 dmareq;
224 s8 sync_dev; 225 s8 sync_dev;
@@ -390,15 +391,19 @@ static int tusb_omap_dma_program(struct dma_channel *channel, u16 packet_sz,
390 391
391 if (chdat->tx) { 392 if (chdat->tx) {
392 /* Send transfer_packet_sz packets at a time */ 393 /* Send transfer_packet_sz packets at a time */
393 musb_writel(ep_conf, TUSB_EP_MAX_PACKET_SIZE_OFFSET, 394 psize = musb_readl(ep_conf, TUSB_EP_MAX_PACKET_SIZE_OFFSET);
394 chdat->transfer_packet_sz); 395 psize &= ~0x7ff;
396 psize |= chdat->transfer_packet_sz;
397 musb_writel(ep_conf, TUSB_EP_MAX_PACKET_SIZE_OFFSET, psize);
395 398
396 musb_writel(ep_conf, TUSB_EP_TX_OFFSET, 399 musb_writel(ep_conf, TUSB_EP_TX_OFFSET,
397 TUSB_EP_CONFIG_XFR_SIZE(chdat->transfer_len)); 400 TUSB_EP_CONFIG_XFR_SIZE(chdat->transfer_len));
398 } else { 401 } else {
399 /* Receive transfer_packet_sz packets at a time */ 402 /* Receive transfer_packet_sz packets at a time */
400 musb_writel(ep_conf, TUSB_EP_MAX_PACKET_SIZE_OFFSET, 403 psize = musb_readl(ep_conf, TUSB_EP_MAX_PACKET_SIZE_OFFSET);
401 chdat->transfer_packet_sz << 16); 404 psize &= ~(0x7ff << 16);
405 psize |= (chdat->transfer_packet_sz << 16);
406 musb_writel(ep_conf, TUSB_EP_MAX_PACKET_SIZE_OFFSET, psize);
402 407
403 musb_writel(ep_conf, TUSB_EP_RX_OFFSET, 408 musb_writel(ep_conf, TUSB_EP_RX_OFFSET,
404 TUSB_EP_CONFIG_XFR_SIZE(chdat->transfer_len)); 409 TUSB_EP_CONFIG_XFR_SIZE(chdat->transfer_len));
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index d38780fa8788..aba74f817dc6 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -809,10 +809,10 @@ static const struct usb_device_id id_table_combined[] = {
809 { USB_DEVICE(FTDI_VID, FTDI_PROPOX_ISPCABLEIII_PID) }, 809 { USB_DEVICE(FTDI_VID, FTDI_PROPOX_ISPCABLEIII_PID) },
810 { USB_DEVICE(FTDI_VID, CYBER_CORTEX_AV_PID), 810 { USB_DEVICE(FTDI_VID, CYBER_CORTEX_AV_PID),
811 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, 811 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
812 { USB_DEVICE(OLIMEX_VID, OLIMEX_ARM_USB_OCD_PID), 812 { USB_DEVICE_INTERFACE_NUMBER(OLIMEX_VID, OLIMEX_ARM_USB_OCD_PID, 1) },
813 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, 813 { USB_DEVICE_INTERFACE_NUMBER(OLIMEX_VID, OLIMEX_ARM_USB_OCD_H_PID, 1) },
814 { USB_DEVICE(OLIMEX_VID, OLIMEX_ARM_USB_OCD_H_PID), 814 { USB_DEVICE_INTERFACE_NUMBER(OLIMEX_VID, OLIMEX_ARM_USB_TINY_PID, 1) },
815 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, 815 { USB_DEVICE_INTERFACE_NUMBER(OLIMEX_VID, OLIMEX_ARM_USB_TINY_H_PID, 1) },
816 { USB_DEVICE(FIC_VID, FIC_NEO1973_DEBUG_PID), 816 { USB_DEVICE(FIC_VID, FIC_NEO1973_DEBUG_PID),
817 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, 817 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
818 { USB_DEVICE(FTDI_VID, FTDI_OOCDLINK_PID), 818 { USB_DEVICE(FTDI_VID, FTDI_OOCDLINK_PID),
@@ -1527,9 +1527,9 @@ static int set_serial_info(struct tty_struct *tty,
1527 (new_serial.flags & ASYNC_FLAGS)); 1527 (new_serial.flags & ASYNC_FLAGS));
1528 priv->custom_divisor = new_serial.custom_divisor; 1528 priv->custom_divisor = new_serial.custom_divisor;
1529 1529
1530check_and_exit:
1530 write_latency_timer(port); 1531 write_latency_timer(port);
1531 1532
1532check_and_exit:
1533 if ((old_priv.flags & ASYNC_SPD_MASK) != 1533 if ((old_priv.flags & ASYNC_SPD_MASK) !=
1534 (priv->flags & ASYNC_SPD_MASK)) { 1534 (priv->flags & ASYNC_SPD_MASK)) {
1535 if ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI) 1535 if ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h
index 71fb9e59db71..4fcf1cecb6d7 100644
--- a/drivers/usb/serial/ftdi_sio_ids.h
+++ b/drivers/usb/serial/ftdi_sio_ids.h
@@ -882,6 +882,8 @@
882/* Olimex */ 882/* Olimex */
883#define OLIMEX_VID 0x15BA 883#define OLIMEX_VID 0x15BA
884#define OLIMEX_ARM_USB_OCD_PID 0x0003 884#define OLIMEX_ARM_USB_OCD_PID 0x0003
885#define OLIMEX_ARM_USB_TINY_PID 0x0004
886#define OLIMEX_ARM_USB_TINY_H_PID 0x002a
885#define OLIMEX_ARM_USB_OCD_H_PID 0x002b 887#define OLIMEX_ARM_USB_OCD_H_PID 0x002b
886 888
887/* 889/*
diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c
index 87798e625d6c..6cefb9cb133d 100644
--- a/drivers/usb/serial/io_ti.c
+++ b/drivers/usb/serial/io_ti.c
@@ -2336,8 +2336,11 @@ static void change_port_settings(struct tty_struct *tty,
2336 if (!baud) { 2336 if (!baud) {
2337 /* pick a default, any default... */ 2337 /* pick a default, any default... */
2338 baud = 9600; 2338 baud = 9600;
2339 } else 2339 } else {
2340 /* Avoid a zero divisor. */
2341 baud = min(baud, 461550);
2340 tty_encode_baud_rate(tty, baud, baud); 2342 tty_encode_baud_rate(tty, baud, baud);
2343 }
2341 2344
2342 edge_port->baud_rate = baud; 2345 edge_port->baud_rate = baud;
2343 config->wBaudRate = (__u16)((461550L + baud/2) / baud); 2346 config->wBaudRate = (__u16)((461550L + baud/2) / baud);
diff --git a/drivers/usb/serial/ir-usb.c b/drivers/usb/serial/ir-usb.c
index 73956d48a0c5..f9734a96d516 100644
--- a/drivers/usb/serial/ir-usb.c
+++ b/drivers/usb/serial/ir-usb.c
@@ -197,6 +197,7 @@ static u8 ir_xbof_change(u8 xbof)
197static int ir_startup(struct usb_serial *serial) 197static int ir_startup(struct usb_serial *serial)
198{ 198{
199 struct usb_irda_cs_descriptor *irda_desc; 199 struct usb_irda_cs_descriptor *irda_desc;
200 int rates;
200 201
201 irda_desc = irda_usb_find_class_desc(serial, 0); 202 irda_desc = irda_usb_find_class_desc(serial, 0);
202 if (!irda_desc) { 203 if (!irda_desc) {
@@ -205,18 +206,20 @@ static int ir_startup(struct usb_serial *serial)
205 return -ENODEV; 206 return -ENODEV;
206 } 207 }
207 208
209 rates = le16_to_cpu(irda_desc->wBaudRate);
210
208 dev_dbg(&serial->dev->dev, 211 dev_dbg(&serial->dev->dev,
209 "%s - Baud rates supported:%s%s%s%s%s%s%s%s%s\n", 212 "%s - Baud rates supported:%s%s%s%s%s%s%s%s%s\n",
210 __func__, 213 __func__,
211 (irda_desc->wBaudRate & USB_IRDA_BR_2400) ? " 2400" : "", 214 (rates & USB_IRDA_BR_2400) ? " 2400" : "",
212 (irda_desc->wBaudRate & USB_IRDA_BR_9600) ? " 9600" : "", 215 (rates & USB_IRDA_BR_9600) ? " 9600" : "",
213 (irda_desc->wBaudRate & USB_IRDA_BR_19200) ? " 19200" : "", 216 (rates & USB_IRDA_BR_19200) ? " 19200" : "",
214 (irda_desc->wBaudRate & USB_IRDA_BR_38400) ? " 38400" : "", 217 (rates & USB_IRDA_BR_38400) ? " 38400" : "",
215 (irda_desc->wBaudRate & USB_IRDA_BR_57600) ? " 57600" : "", 218 (rates & USB_IRDA_BR_57600) ? " 57600" : "",
216 (irda_desc->wBaudRate & USB_IRDA_BR_115200) ? " 115200" : "", 219 (rates & USB_IRDA_BR_115200) ? " 115200" : "",
217 (irda_desc->wBaudRate & USB_IRDA_BR_576000) ? " 576000" : "", 220 (rates & USB_IRDA_BR_576000) ? " 576000" : "",
218 (irda_desc->wBaudRate & USB_IRDA_BR_1152000) ? " 1152000" : "", 221 (rates & USB_IRDA_BR_1152000) ? " 1152000" : "",
219 (irda_desc->wBaudRate & USB_IRDA_BR_4000000) ? " 4000000" : ""); 222 (rates & USB_IRDA_BR_4000000) ? " 4000000" : "");
220 223
221 switch (irda_desc->bmAdditionalBOFs) { 224 switch (irda_desc->bmAdditionalBOFs) {
222 case USB_IRDA_AB_48: 225 case USB_IRDA_AB_48:
diff --git a/drivers/usb/serial/mct_u232.c b/drivers/usb/serial/mct_u232.c
index edbc81f205c2..70f346f1aa86 100644
--- a/drivers/usb/serial/mct_u232.c
+++ b/drivers/usb/serial/mct_u232.c
@@ -189,7 +189,7 @@ static int mct_u232_set_baud_rate(struct tty_struct *tty,
189 return -ENOMEM; 189 return -ENOMEM;
190 190
191 divisor = mct_u232_calculate_baud_rate(serial, value, &speed); 191 divisor = mct_u232_calculate_baud_rate(serial, value, &speed);
192 put_unaligned_le32(cpu_to_le32(divisor), buf); 192 put_unaligned_le32(divisor, buf);
193 rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), 193 rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
194 MCT_U232_SET_BAUD_RATE_REQUEST, 194 MCT_U232_SET_BAUD_RATE_REQUEST,
195 MCT_U232_SET_REQUEST_TYPE, 195 MCT_U232_SET_REQUEST_TYPE,
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index af67a0de6b5d..3bf61acfc26b 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -281,6 +281,7 @@ static void option_instat_callback(struct urb *urb);
281#define TELIT_PRODUCT_LE922_USBCFG0 0x1042 281#define TELIT_PRODUCT_LE922_USBCFG0 0x1042
282#define TELIT_PRODUCT_LE922_USBCFG3 0x1043 282#define TELIT_PRODUCT_LE922_USBCFG3 0x1043
283#define TELIT_PRODUCT_LE922_USBCFG5 0x1045 283#define TELIT_PRODUCT_LE922_USBCFG5 0x1045
284#define TELIT_PRODUCT_ME910 0x1100
284#define TELIT_PRODUCT_LE920 0x1200 285#define TELIT_PRODUCT_LE920 0x1200
285#define TELIT_PRODUCT_LE910 0x1201 286#define TELIT_PRODUCT_LE910 0x1201
286#define TELIT_PRODUCT_LE910_USBCFG4 0x1206 287#define TELIT_PRODUCT_LE910_USBCFG4 0x1206
@@ -640,6 +641,11 @@ static const struct option_blacklist_info simcom_sim7100e_blacklist = {
640 .reserved = BIT(5) | BIT(6), 641 .reserved = BIT(5) | BIT(6),
641}; 642};
642 643
644static const struct option_blacklist_info telit_me910_blacklist = {
645 .sendsetup = BIT(0),
646 .reserved = BIT(1) | BIT(3),
647};
648
643static const struct option_blacklist_info telit_le910_blacklist = { 649static const struct option_blacklist_info telit_le910_blacklist = {
644 .sendsetup = BIT(0), 650 .sendsetup = BIT(0),
645 .reserved = BIT(1) | BIT(2), 651 .reserved = BIT(1) | BIT(2),
@@ -1235,6 +1241,8 @@ static const struct usb_device_id option_ids[] = {
1235 .driver_info = (kernel_ulong_t)&telit_le922_blacklist_usbcfg3 }, 1241 .driver_info = (kernel_ulong_t)&telit_le922_blacklist_usbcfg3 },
1236 { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, TELIT_PRODUCT_LE922_USBCFG5, 0xff), 1242 { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, TELIT_PRODUCT_LE922_USBCFG5, 0xff),
1237 .driver_info = (kernel_ulong_t)&telit_le922_blacklist_usbcfg0 }, 1243 .driver_info = (kernel_ulong_t)&telit_le922_blacklist_usbcfg0 },
1244 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_ME910),
1245 .driver_info = (kernel_ulong_t)&telit_me910_blacklist },
1238 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE910), 1246 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE910),
1239 .driver_info = (kernel_ulong_t)&telit_le910_blacklist }, 1247 .driver_info = (kernel_ulong_t)&telit_le910_blacklist },
1240 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE910_USBCFG4), 1248 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE910_USBCFG4),
diff --git a/drivers/usb/serial/qcserial.c b/drivers/usb/serial/qcserial.c
index 38b3f0d8cd58..fd509ed6cf70 100644
--- a/drivers/usb/serial/qcserial.c
+++ b/drivers/usb/serial/qcserial.c
@@ -162,6 +162,8 @@ static const struct usb_device_id id_table[] = {
162 {DEVICE_SWI(0x1199, 0x9071)}, /* Sierra Wireless MC74xx */ 162 {DEVICE_SWI(0x1199, 0x9071)}, /* Sierra Wireless MC74xx */
163 {DEVICE_SWI(0x1199, 0x9078)}, /* Sierra Wireless EM74xx */ 163 {DEVICE_SWI(0x1199, 0x9078)}, /* Sierra Wireless EM74xx */
164 {DEVICE_SWI(0x1199, 0x9079)}, /* Sierra Wireless EM74xx */ 164 {DEVICE_SWI(0x1199, 0x9079)}, /* Sierra Wireless EM74xx */
165 {DEVICE_SWI(0x1199, 0x907a)}, /* Sierra Wireless EM74xx QDL */
166 {DEVICE_SWI(0x1199, 0x907b)}, /* Sierra Wireless EM74xx */
165 {DEVICE_SWI(0x413c, 0x81a2)}, /* Dell Wireless 5806 Gobi(TM) 4G LTE Mobile Broadband Card */ 167 {DEVICE_SWI(0x413c, 0x81a2)}, /* Dell Wireless 5806 Gobi(TM) 4G LTE Mobile Broadband Card */
166 {DEVICE_SWI(0x413c, 0x81a3)}, /* Dell Wireless 5570 HSPA+ (42Mbps) Mobile Broadband Card */ 168 {DEVICE_SWI(0x413c, 0x81a3)}, /* Dell Wireless 5570 HSPA+ (42Mbps) Mobile Broadband Card */
167 {DEVICE_SWI(0x413c, 0x81a4)}, /* Dell Wireless 5570e HSPA+ (42Mbps) Mobile Broadband Card */ 169 {DEVICE_SWI(0x413c, 0x81a4)}, /* Dell Wireless 5570e HSPA+ (42Mbps) Mobile Broadband Card */
diff --git a/drivers/usb/storage/ene_ub6250.c b/drivers/usb/storage/ene_ub6250.c
index 369f3c24815a..44af719194b2 100644
--- a/drivers/usb/storage/ene_ub6250.c
+++ b/drivers/usb/storage/ene_ub6250.c
@@ -446,6 +446,10 @@ struct ms_lib_ctrl {
446#define SD_BLOCK_LEN 9 446#define SD_BLOCK_LEN 9
447 447
448struct ene_ub6250_info { 448struct ene_ub6250_info {
449
450 /* I/O bounce buffer */
451 u8 *bbuf;
452
449 /* for 6250 code */ 453 /* for 6250 code */
450 struct SD_STATUS SD_Status; 454 struct SD_STATUS SD_Status;
451 struct MS_STATUS MS_Status; 455 struct MS_STATUS MS_Status;
@@ -493,8 +497,11 @@ static int ene_load_bincode(struct us_data *us, unsigned char flag);
493 497
494static void ene_ub6250_info_destructor(void *extra) 498static void ene_ub6250_info_destructor(void *extra)
495{ 499{
500 struct ene_ub6250_info *info = (struct ene_ub6250_info *) extra;
501
496 if (!extra) 502 if (!extra)
497 return; 503 return;
504 kfree(info->bbuf);
498} 505}
499 506
500static int ene_send_scsi_cmd(struct us_data *us, u8 fDir, void *buf, int use_sg) 507static int ene_send_scsi_cmd(struct us_data *us, u8 fDir, void *buf, int use_sg)
@@ -860,8 +867,9 @@ static int ms_read_readpage(struct us_data *us, u32 PhyBlockAddr,
860 u8 PageNum, u32 *PageBuf, struct ms_lib_type_extdat *ExtraDat) 867 u8 PageNum, u32 *PageBuf, struct ms_lib_type_extdat *ExtraDat)
861{ 868{
862 struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf; 869 struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
870 struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra;
871 u8 *bbuf = info->bbuf;
863 int result; 872 int result;
864 u8 ExtBuf[4];
865 u32 bn = PhyBlockAddr * 0x20 + PageNum; 873 u32 bn = PhyBlockAddr * 0x20 + PageNum;
866 874
867 result = ene_load_bincode(us, MS_RW_PATTERN); 875 result = ene_load_bincode(us, MS_RW_PATTERN);
@@ -901,7 +909,7 @@ static int ms_read_readpage(struct us_data *us, u32 PhyBlockAddr,
901 bcb->CDB[2] = (unsigned char)(PhyBlockAddr>>16); 909 bcb->CDB[2] = (unsigned char)(PhyBlockAddr>>16);
902 bcb->CDB[6] = 0x01; 910 bcb->CDB[6] = 0x01;
903 911
904 result = ene_send_scsi_cmd(us, FDIR_READ, &ExtBuf, 0); 912 result = ene_send_scsi_cmd(us, FDIR_READ, bbuf, 0);
905 if (result != USB_STOR_XFER_GOOD) 913 if (result != USB_STOR_XFER_GOOD)
906 return USB_STOR_TRANSPORT_ERROR; 914 return USB_STOR_TRANSPORT_ERROR;
907 915
@@ -910,9 +918,9 @@ static int ms_read_readpage(struct us_data *us, u32 PhyBlockAddr,
910 ExtraDat->status0 = 0x10; /* Not yet,fireware support */ 918 ExtraDat->status0 = 0x10; /* Not yet,fireware support */
911 919
912 ExtraDat->status1 = 0x00; /* Not yet,fireware support */ 920 ExtraDat->status1 = 0x00; /* Not yet,fireware support */
913 ExtraDat->ovrflg = ExtBuf[0]; 921 ExtraDat->ovrflg = bbuf[0];
914 ExtraDat->mngflg = ExtBuf[1]; 922 ExtraDat->mngflg = bbuf[1];
915 ExtraDat->logadr = memstick_logaddr(ExtBuf[2], ExtBuf[3]); 923 ExtraDat->logadr = memstick_logaddr(bbuf[2], bbuf[3]);
916 924
917 return USB_STOR_TRANSPORT_GOOD; 925 return USB_STOR_TRANSPORT_GOOD;
918} 926}
@@ -1332,8 +1340,9 @@ static int ms_lib_read_extra(struct us_data *us, u32 PhyBlock,
1332 u8 PageNum, struct ms_lib_type_extdat *ExtraDat) 1340 u8 PageNum, struct ms_lib_type_extdat *ExtraDat)
1333{ 1341{
1334 struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf; 1342 struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
1343 struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra;
1344 u8 *bbuf = info->bbuf;
1335 int result; 1345 int result;
1336 u8 ExtBuf[4];
1337 1346
1338 memset(bcb, 0, sizeof(struct bulk_cb_wrap)); 1347 memset(bcb, 0, sizeof(struct bulk_cb_wrap));
1339 bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); 1348 bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
@@ -1347,7 +1356,7 @@ static int ms_lib_read_extra(struct us_data *us, u32 PhyBlock,
1347 bcb->CDB[2] = (unsigned char)(PhyBlock>>16); 1356 bcb->CDB[2] = (unsigned char)(PhyBlock>>16);
1348 bcb->CDB[6] = 0x01; 1357 bcb->CDB[6] = 0x01;
1349 1358
1350 result = ene_send_scsi_cmd(us, FDIR_READ, &ExtBuf, 0); 1359 result = ene_send_scsi_cmd(us, FDIR_READ, bbuf, 0);
1351 if (result != USB_STOR_XFER_GOOD) 1360 if (result != USB_STOR_XFER_GOOD)
1352 return USB_STOR_TRANSPORT_ERROR; 1361 return USB_STOR_TRANSPORT_ERROR;
1353 1362
@@ -1355,9 +1364,9 @@ static int ms_lib_read_extra(struct us_data *us, u32 PhyBlock,
1355 ExtraDat->intr = 0x80; /* Not yet, waiting for fireware support */ 1364 ExtraDat->intr = 0x80; /* Not yet, waiting for fireware support */
1356 ExtraDat->status0 = 0x10; /* Not yet, waiting for fireware support */ 1365 ExtraDat->status0 = 0x10; /* Not yet, waiting for fireware support */
1357 ExtraDat->status1 = 0x00; /* Not yet, waiting for fireware support */ 1366 ExtraDat->status1 = 0x00; /* Not yet, waiting for fireware support */
1358 ExtraDat->ovrflg = ExtBuf[0]; 1367 ExtraDat->ovrflg = bbuf[0];
1359 ExtraDat->mngflg = ExtBuf[1]; 1368 ExtraDat->mngflg = bbuf[1];
1360 ExtraDat->logadr = memstick_logaddr(ExtBuf[2], ExtBuf[3]); 1369 ExtraDat->logadr = memstick_logaddr(bbuf[2], bbuf[3]);
1361 1370
1362 return USB_STOR_TRANSPORT_GOOD; 1371 return USB_STOR_TRANSPORT_GOOD;
1363} 1372}
@@ -1556,9 +1565,9 @@ static int ms_lib_scan_logicalblocknumber(struct us_data *us, u16 btBlk1st)
1556 u16 PhyBlock, newblk, i; 1565 u16 PhyBlock, newblk, i;
1557 u16 LogStart, LogEnde; 1566 u16 LogStart, LogEnde;
1558 struct ms_lib_type_extdat extdat; 1567 struct ms_lib_type_extdat extdat;
1559 u8 buf[0x200];
1560 u32 count = 0, index = 0; 1568 u32 count = 0, index = 0;
1561 struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra; 1569 struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra;
1570 u8 *bbuf = info->bbuf;
1562 1571
1563 for (PhyBlock = 0; PhyBlock < info->MS_Lib.NumberOfPhyBlock;) { 1572 for (PhyBlock = 0; PhyBlock < info->MS_Lib.NumberOfPhyBlock;) {
1564 ms_lib_phy_to_log_range(PhyBlock, &LogStart, &LogEnde); 1573 ms_lib_phy_to_log_range(PhyBlock, &LogStart, &LogEnde);
@@ -1572,14 +1581,16 @@ static int ms_lib_scan_logicalblocknumber(struct us_data *us, u16 btBlk1st)
1572 } 1581 }
1573 1582
1574 if (count == PhyBlock) { 1583 if (count == PhyBlock) {
1575 ms_lib_read_extrablock(us, PhyBlock, 0, 0x80, &buf); 1584 ms_lib_read_extrablock(us, PhyBlock, 0, 0x80,
1585 bbuf);
1576 count += 0x80; 1586 count += 0x80;
1577 } 1587 }
1578 index = (PhyBlock % 0x80) * 4; 1588 index = (PhyBlock % 0x80) * 4;
1579 1589
1580 extdat.ovrflg = buf[index]; 1590 extdat.ovrflg = bbuf[index];
1581 extdat.mngflg = buf[index+1]; 1591 extdat.mngflg = bbuf[index+1];
1582 extdat.logadr = memstick_logaddr(buf[index+2], buf[index+3]); 1592 extdat.logadr = memstick_logaddr(bbuf[index+2],
1593 bbuf[index+3]);
1583 1594
1584 if ((extdat.ovrflg & MS_REG_OVR_BKST) != MS_REG_OVR_BKST_OK) { 1595 if ((extdat.ovrflg & MS_REG_OVR_BKST) != MS_REG_OVR_BKST_OK) {
1585 ms_lib_setacquired_errorblock(us, PhyBlock); 1596 ms_lib_setacquired_errorblock(us, PhyBlock);
@@ -2062,9 +2073,9 @@ static int ene_ms_init(struct us_data *us)
2062{ 2073{
2063 struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf; 2074 struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
2064 int result; 2075 int result;
2065 u8 buf[0x200];
2066 u16 MSP_BlockSize, MSP_UserAreaBlocks; 2076 u16 MSP_BlockSize, MSP_UserAreaBlocks;
2067 struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra; 2077 struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra;
2078 u8 *bbuf = info->bbuf;
2068 2079
2069 printk(KERN_INFO "transport --- ENE_MSInit\n"); 2080 printk(KERN_INFO "transport --- ENE_MSInit\n");
2070 2081
@@ -2083,13 +2094,13 @@ static int ene_ms_init(struct us_data *us)
2083 bcb->CDB[0] = 0xF1; 2094 bcb->CDB[0] = 0xF1;
2084 bcb->CDB[1] = 0x01; 2095 bcb->CDB[1] = 0x01;
2085 2096
2086 result = ene_send_scsi_cmd(us, FDIR_READ, &buf, 0); 2097 result = ene_send_scsi_cmd(us, FDIR_READ, bbuf, 0);
2087 if (result != USB_STOR_XFER_GOOD) { 2098 if (result != USB_STOR_XFER_GOOD) {
2088 printk(KERN_ERR "Execution MS Init Code Fail !!\n"); 2099 printk(KERN_ERR "Execution MS Init Code Fail !!\n");
2089 return USB_STOR_TRANSPORT_ERROR; 2100 return USB_STOR_TRANSPORT_ERROR;
2090 } 2101 }
2091 /* the same part to test ENE */ 2102 /* the same part to test ENE */
2092 info->MS_Status = *(struct MS_STATUS *)&buf[0]; 2103 info->MS_Status = *(struct MS_STATUS *) bbuf;
2093 2104
2094 if (info->MS_Status.Insert && info->MS_Status.Ready) { 2105 if (info->MS_Status.Insert && info->MS_Status.Ready) {
2095 printk(KERN_INFO "Insert = %x\n", info->MS_Status.Insert); 2106 printk(KERN_INFO "Insert = %x\n", info->MS_Status.Insert);
@@ -2098,15 +2109,15 @@ static int ene_ms_init(struct us_data *us)
2098 printk(KERN_INFO "IsMSPHG = %x\n", info->MS_Status.IsMSPHG); 2109 printk(KERN_INFO "IsMSPHG = %x\n", info->MS_Status.IsMSPHG);
2099 printk(KERN_INFO "WtP= %x\n", info->MS_Status.WtP); 2110 printk(KERN_INFO "WtP= %x\n", info->MS_Status.WtP);
2100 if (info->MS_Status.IsMSPro) { 2111 if (info->MS_Status.IsMSPro) {
2101 MSP_BlockSize = (buf[6] << 8) | buf[7]; 2112 MSP_BlockSize = (bbuf[6] << 8) | bbuf[7];
2102 MSP_UserAreaBlocks = (buf[10] << 8) | buf[11]; 2113 MSP_UserAreaBlocks = (bbuf[10] << 8) | bbuf[11];
2103 info->MSP_TotalBlock = MSP_BlockSize * MSP_UserAreaBlocks; 2114 info->MSP_TotalBlock = MSP_BlockSize * MSP_UserAreaBlocks;
2104 } else { 2115 } else {
2105 ms_card_init(us); /* Card is MS (to ms.c)*/ 2116 ms_card_init(us); /* Card is MS (to ms.c)*/
2106 } 2117 }
2107 usb_stor_dbg(us, "MS Init Code OK !!\n"); 2118 usb_stor_dbg(us, "MS Init Code OK !!\n");
2108 } else { 2119 } else {
2109 usb_stor_dbg(us, "MS Card Not Ready --- %x\n", buf[0]); 2120 usb_stor_dbg(us, "MS Card Not Ready --- %x\n", bbuf[0]);
2110 return USB_STOR_TRANSPORT_ERROR; 2121 return USB_STOR_TRANSPORT_ERROR;
2111 } 2122 }
2112 2123
@@ -2116,9 +2127,9 @@ static int ene_ms_init(struct us_data *us)
2116static int ene_sd_init(struct us_data *us) 2127static int ene_sd_init(struct us_data *us)
2117{ 2128{
2118 int result; 2129 int result;
2119 u8 buf[0x200];
2120 struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf; 2130 struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
2121 struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra; 2131 struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra;
2132 u8 *bbuf = info->bbuf;
2122 2133
2123 usb_stor_dbg(us, "transport --- ENE_SDInit\n"); 2134 usb_stor_dbg(us, "transport --- ENE_SDInit\n");
2124 /* SD Init Part-1 */ 2135 /* SD Init Part-1 */
@@ -2152,17 +2163,17 @@ static int ene_sd_init(struct us_data *us)
2152 bcb->Flags = US_BULK_FLAG_IN; 2163 bcb->Flags = US_BULK_FLAG_IN;
2153 bcb->CDB[0] = 0xF1; 2164 bcb->CDB[0] = 0xF1;
2154 2165
2155 result = ene_send_scsi_cmd(us, FDIR_READ, &buf, 0); 2166 result = ene_send_scsi_cmd(us, FDIR_READ, bbuf, 0);
2156 if (result != USB_STOR_XFER_GOOD) { 2167 if (result != USB_STOR_XFER_GOOD) {
2157 usb_stor_dbg(us, "Execution SD Init Code Fail !!\n"); 2168 usb_stor_dbg(us, "Execution SD Init Code Fail !!\n");
2158 return USB_STOR_TRANSPORT_ERROR; 2169 return USB_STOR_TRANSPORT_ERROR;
2159 } 2170 }
2160 2171
2161 info->SD_Status = *(struct SD_STATUS *)&buf[0]; 2172 info->SD_Status = *(struct SD_STATUS *) bbuf;
2162 if (info->SD_Status.Insert && info->SD_Status.Ready) { 2173 if (info->SD_Status.Insert && info->SD_Status.Ready) {
2163 struct SD_STATUS *s = &info->SD_Status; 2174 struct SD_STATUS *s = &info->SD_Status;
2164 2175
2165 ene_get_card_status(us, (unsigned char *)&buf); 2176 ene_get_card_status(us, bbuf);
2166 usb_stor_dbg(us, "Insert = %x\n", s->Insert); 2177 usb_stor_dbg(us, "Insert = %x\n", s->Insert);
2167 usb_stor_dbg(us, "Ready = %x\n", s->Ready); 2178 usb_stor_dbg(us, "Ready = %x\n", s->Ready);
2168 usb_stor_dbg(us, "IsMMC = %x\n", s->IsMMC); 2179 usb_stor_dbg(us, "IsMMC = %x\n", s->IsMMC);
@@ -2170,7 +2181,7 @@ static int ene_sd_init(struct us_data *us)
2170 usb_stor_dbg(us, "HiSpeed = %x\n", s->HiSpeed); 2181 usb_stor_dbg(us, "HiSpeed = %x\n", s->HiSpeed);
2171 usb_stor_dbg(us, "WtP = %x\n", s->WtP); 2182 usb_stor_dbg(us, "WtP = %x\n", s->WtP);
2172 } else { 2183 } else {
2173 usb_stor_dbg(us, "SD Card Not Ready --- %x\n", buf[0]); 2184 usb_stor_dbg(us, "SD Card Not Ready --- %x\n", bbuf[0]);
2174 return USB_STOR_TRANSPORT_ERROR; 2185 return USB_STOR_TRANSPORT_ERROR;
2175 } 2186 }
2176 return USB_STOR_TRANSPORT_GOOD; 2187 return USB_STOR_TRANSPORT_GOOD;
@@ -2180,13 +2191,15 @@ static int ene_sd_init(struct us_data *us)
2180static int ene_init(struct us_data *us) 2191static int ene_init(struct us_data *us)
2181{ 2192{
2182 int result; 2193 int result;
2183 u8 misc_reg03 = 0; 2194 u8 misc_reg03;
2184 struct ene_ub6250_info *info = (struct ene_ub6250_info *)(us->extra); 2195 struct ene_ub6250_info *info = (struct ene_ub6250_info *)(us->extra);
2196 u8 *bbuf = info->bbuf;
2185 2197
2186 result = ene_get_card_type(us, REG_CARD_STATUS, &misc_reg03); 2198 result = ene_get_card_type(us, REG_CARD_STATUS, bbuf);
2187 if (result != USB_STOR_XFER_GOOD) 2199 if (result != USB_STOR_XFER_GOOD)
2188 return USB_STOR_TRANSPORT_ERROR; 2200 return USB_STOR_TRANSPORT_ERROR;
2189 2201
2202 misc_reg03 = bbuf[0];
2190 if (misc_reg03 & 0x01) { 2203 if (misc_reg03 & 0x01) {
2191 if (!info->SD_Status.Ready) { 2204 if (!info->SD_Status.Ready) {
2192 result = ene_sd_init(us); 2205 result = ene_sd_init(us);
@@ -2303,8 +2316,9 @@ static int ene_ub6250_probe(struct usb_interface *intf,
2303 const struct usb_device_id *id) 2316 const struct usb_device_id *id)
2304{ 2317{
2305 int result; 2318 int result;
2306 u8 misc_reg03 = 0; 2319 u8 misc_reg03;
2307 struct us_data *us; 2320 struct us_data *us;
2321 struct ene_ub6250_info *info;
2308 2322
2309 result = usb_stor_probe1(&us, intf, id, 2323 result = usb_stor_probe1(&us, intf, id,
2310 (id - ene_ub6250_usb_ids) + ene_ub6250_unusual_dev_list, 2324 (id - ene_ub6250_usb_ids) + ene_ub6250_unusual_dev_list,
@@ -2313,11 +2327,16 @@ static int ene_ub6250_probe(struct usb_interface *intf,
2313 return result; 2327 return result;
2314 2328
2315 /* FIXME: where should the code alloc extra buf ? */ 2329 /* FIXME: where should the code alloc extra buf ? */
2316 if (!us->extra) { 2330 us->extra = kzalloc(sizeof(struct ene_ub6250_info), GFP_KERNEL);
2317 us->extra = kzalloc(sizeof(struct ene_ub6250_info), GFP_KERNEL); 2331 if (!us->extra)
2318 if (!us->extra) 2332 return -ENOMEM;
2319 return -ENOMEM; 2333 us->extra_destructor = ene_ub6250_info_destructor;
2320 us->extra_destructor = ene_ub6250_info_destructor; 2334
2335 info = (struct ene_ub6250_info *)(us->extra);
2336 info->bbuf = kmalloc(512, GFP_KERNEL);
2337 if (!info->bbuf) {
2338 kfree(us->extra);
2339 return -ENOMEM;
2321 } 2340 }
2322 2341
2323 us->transport_name = "ene_ub6250"; 2342 us->transport_name = "ene_ub6250";
@@ -2329,12 +2348,13 @@ static int ene_ub6250_probe(struct usb_interface *intf,
2329 return result; 2348 return result;
2330 2349
2331 /* probe card type */ 2350 /* probe card type */
2332 result = ene_get_card_type(us, REG_CARD_STATUS, &misc_reg03); 2351 result = ene_get_card_type(us, REG_CARD_STATUS, info->bbuf);
2333 if (result != USB_STOR_XFER_GOOD) { 2352 if (result != USB_STOR_XFER_GOOD) {
2334 usb_stor_disconnect(intf); 2353 usb_stor_disconnect(intf);
2335 return USB_STOR_TRANSPORT_ERROR; 2354 return USB_STOR_TRANSPORT_ERROR;
2336 } 2355 }
2337 2356
2357 misc_reg03 = info->bbuf[0];
2338 if (!(misc_reg03 & 0x01)) { 2358 if (!(misc_reg03 & 0x01)) {
2339 pr_info("ums_eneub6250: This driver only supports SD/MS cards. " 2359 pr_info("ums_eneub6250: This driver only supports SD/MS cards. "
2340 "It does not support SM cards.\n"); 2360 "It does not support SM cards.\n");
diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
index 5d8b2c261940..0585078638db 100644
--- a/drivers/usb/usbip/vhci_hcd.c
+++ b/drivers/usb/usbip/vhci_hcd.c
@@ -235,14 +235,19 @@ done:
235 235
236static inline void hub_descriptor(struct usb_hub_descriptor *desc) 236static inline void hub_descriptor(struct usb_hub_descriptor *desc)
237{ 237{
238 int width;
239
238 memset(desc, 0, sizeof(*desc)); 240 memset(desc, 0, sizeof(*desc));
239 desc->bDescriptorType = USB_DT_HUB; 241 desc->bDescriptorType = USB_DT_HUB;
240 desc->bDescLength = 9;
241 desc->wHubCharacteristics = cpu_to_le16( 242 desc->wHubCharacteristics = cpu_to_le16(
242 HUB_CHAR_INDV_PORT_LPSM | HUB_CHAR_COMMON_OCPM); 243 HUB_CHAR_INDV_PORT_LPSM | HUB_CHAR_COMMON_OCPM);
244
243 desc->bNbrPorts = VHCI_HC_PORTS; 245 desc->bNbrPorts = VHCI_HC_PORTS;
244 desc->u.hs.DeviceRemovable[0] = 0xff; 246 BUILD_BUG_ON(VHCI_HC_PORTS > USB_MAXCHILDREN);
245 desc->u.hs.DeviceRemovable[1] = 0xff; 247 width = desc->bNbrPorts / 8 + 1;
248 desc->bDescLength = USB_DT_HUB_NONVAR_SIZE + 2 * width;
249 memset(&desc->u.hs.DeviceRemovable[0], 0, width);
250 memset(&desc->u.hs.DeviceRemovable[width], 0xff, width);
246} 251}
247 252
248static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, 253static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
diff --git a/drivers/uwb/i1480/dfu/usb.c b/drivers/uwb/i1480/dfu/usb.c
index 6345e85822a4..a50cf45e530f 100644
--- a/drivers/uwb/i1480/dfu/usb.c
+++ b/drivers/uwb/i1480/dfu/usb.c
@@ -341,6 +341,7 @@ error_submit_ep1:
341static 341static
342int i1480_usb_probe(struct usb_interface *iface, const struct usb_device_id *id) 342int i1480_usb_probe(struct usb_interface *iface, const struct usb_device_id *id)
343{ 343{
344 struct usb_device *udev = interface_to_usbdev(iface);
344 struct i1480_usb *i1480_usb; 345 struct i1480_usb *i1480_usb;
345 struct i1480 *i1480; 346 struct i1480 *i1480;
346 struct device *dev = &iface->dev; 347 struct device *dev = &iface->dev;
@@ -352,8 +353,8 @@ int i1480_usb_probe(struct usb_interface *iface, const struct usb_device_id *id)
352 iface->cur_altsetting->desc.bInterfaceNumber); 353 iface->cur_altsetting->desc.bInterfaceNumber);
353 goto error; 354 goto error;
354 } 355 }
355 if (iface->num_altsetting > 1 356 if (iface->num_altsetting > 1 &&
356 && interface_to_usbdev(iface)->descriptor.idProduct == 0xbabe) { 357 le16_to_cpu(udev->descriptor.idProduct) == 0xbabe) {
357 /* Need altsetting #1 [HW QUIRK] or EP1 won't work */ 358 /* Need altsetting #1 [HW QUIRK] or EP1 won't work */
358 result = usb_set_interface(interface_to_usbdev(iface), 0, 1); 359 result = usb_set_interface(interface_to_usbdev(iface), 0, 1);
359 if (result < 0) 360 if (result < 0)
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index 52a70ee6014f..8b9049dac094 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -452,7 +452,7 @@ config DAVINCI_WATCHDOG
452 452
453config ORION_WATCHDOG 453config ORION_WATCHDOG
454 tristate "Orion watchdog" 454 tristate "Orion watchdog"
455 depends on ARCH_ORION5X || ARCH_DOVE || MACH_DOVE || ARCH_MVEBU || COMPILE_TEST 455 depends on ARCH_ORION5X || ARCH_DOVE || MACH_DOVE || ARCH_MVEBU || (COMPILE_TEST && !ARCH_EBSA110)
456 depends on ARM 456 depends on ARM
457 select WATCHDOG_CORE 457 select WATCHDOG_CORE
458 help 458 help
diff --git a/drivers/watchdog/bcm_kona_wdt.c b/drivers/watchdog/bcm_kona_wdt.c
index 6fce17d5b9f1..a5775dfd8d5f 100644
--- a/drivers/watchdog/bcm_kona_wdt.c
+++ b/drivers/watchdog/bcm_kona_wdt.c
@@ -304,6 +304,8 @@ static int bcm_kona_wdt_probe(struct platform_device *pdev)
304 if (!wdt) 304 if (!wdt)
305 return -ENOMEM; 305 return -ENOMEM;
306 306
307 spin_lock_init(&wdt->lock);
308
307 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 309 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
308 wdt->base = devm_ioremap_resource(dev, res); 310 wdt->base = devm_ioremap_resource(dev, res);
309 if (IS_ERR(wdt->base)) 311 if (IS_ERR(wdt->base))
@@ -316,7 +318,6 @@ static int bcm_kona_wdt_probe(struct platform_device *pdev)
316 return ret; 318 return ret;
317 } 319 }
318 320
319 spin_lock_init(&wdt->lock);
320 platform_set_drvdata(pdev, wdt); 321 platform_set_drvdata(pdev, wdt);
321 watchdog_set_drvdata(&bcm_kona_wdt_wdd, wdt); 322 watchdog_set_drvdata(&bcm_kona_wdt_wdd, wdt);
322 bcm_kona_wdt_wdd.parent = &pdev->dev; 323 bcm_kona_wdt_wdd.parent = &pdev->dev;
diff --git a/drivers/watchdog/cadence_wdt.c b/drivers/watchdog/cadence_wdt.c
index 8d61e8bfe60b..86e0b5d2e761 100644
--- a/drivers/watchdog/cadence_wdt.c
+++ b/drivers/watchdog/cadence_wdt.c
@@ -49,7 +49,7 @@
49/* Counter maximum value */ 49/* Counter maximum value */
50#define CDNS_WDT_COUNTER_MAX 0xFFF 50#define CDNS_WDT_COUNTER_MAX 0xFFF
51 51
52static int wdt_timeout = CDNS_WDT_DEFAULT_TIMEOUT; 52static int wdt_timeout;
53static int nowayout = WATCHDOG_NOWAYOUT; 53static int nowayout = WATCHDOG_NOWAYOUT;
54 54
55module_param(wdt_timeout, int, 0); 55module_param(wdt_timeout, int, 0);
diff --git a/drivers/watchdog/iTCO_wdt.c b/drivers/watchdog/iTCO_wdt.c
index 347f0389b089..c4f65873bfa4 100644
--- a/drivers/watchdog/iTCO_wdt.c
+++ b/drivers/watchdog/iTCO_wdt.c
@@ -306,16 +306,15 @@ static int iTCO_wdt_ping(struct watchdog_device *wd_dev)
306 306
307 iTCO_vendor_pre_keepalive(p->smi_res, wd_dev->timeout); 307 iTCO_vendor_pre_keepalive(p->smi_res, wd_dev->timeout);
308 308
309 /* Reset the timeout status bit so that the timer
310 * needs to count down twice again before rebooting */
311 outw(0x0008, TCO1_STS(p)); /* write 1 to clear bit */
312
309 /* Reload the timer by writing to the TCO Timer Counter register */ 313 /* Reload the timer by writing to the TCO Timer Counter register */
310 if (p->iTCO_version >= 2) { 314 if (p->iTCO_version >= 2)
311 outw(0x01, TCO_RLD(p)); 315 outw(0x01, TCO_RLD(p));
312 } else if (p->iTCO_version == 1) { 316 else if (p->iTCO_version == 1)
313 /* Reset the timeout status bit so that the timer
314 * needs to count down twice again before rebooting */
315 outw(0x0008, TCO1_STS(p)); /* write 1 to clear bit */
316
317 outb(0x01, TCO_RLD(p)); 317 outb(0x01, TCO_RLD(p));
318 }
319 318
320 spin_unlock(&p->io_lock); 319 spin_unlock(&p->io_lock);
321 return 0; 320 return 0;
@@ -328,11 +327,8 @@ static int iTCO_wdt_set_timeout(struct watchdog_device *wd_dev, unsigned int t)
328 unsigned char val8; 327 unsigned char val8;
329 unsigned int tmrval; 328 unsigned int tmrval;
330 329
331 tmrval = seconds_to_ticks(p, t); 330 /* The timer counts down twice before rebooting */
332 331 tmrval = seconds_to_ticks(p, t) / 2;
333 /* For TCO v1 the timer counts down twice before rebooting */
334 if (p->iTCO_version == 1)
335 tmrval /= 2;
336 332
337 /* from the specs: */ 333 /* from the specs: */
338 /* "Values of 0h-3h are ignored and should not be attempted" */ 334 /* "Values of 0h-3h are ignored and should not be attempted" */
@@ -385,6 +381,8 @@ static unsigned int iTCO_wdt_get_timeleft(struct watchdog_device *wd_dev)
385 spin_lock(&p->io_lock); 381 spin_lock(&p->io_lock);
386 val16 = inw(TCO_RLD(p)); 382 val16 = inw(TCO_RLD(p));
387 val16 &= 0x3ff; 383 val16 &= 0x3ff;
384 if (!(inw(TCO1_STS(p)) & 0x0008))
385 val16 += (inw(TCOv2_TMR(p)) & 0x3ff);
388 spin_unlock(&p->io_lock); 386 spin_unlock(&p->io_lock);
389 387
390 time_left = ticks_to_seconds(p, val16); 388 time_left = ticks_to_seconds(p, val16);
diff --git a/drivers/watchdog/pcwd_usb.c b/drivers/watchdog/pcwd_usb.c
index 99ebf6ea3de6..5615f4013924 100644
--- a/drivers/watchdog/pcwd_usb.c
+++ b/drivers/watchdog/pcwd_usb.c
@@ -630,6 +630,9 @@ static int usb_pcwd_probe(struct usb_interface *interface,
630 return -ENODEV; 630 return -ENODEV;
631 } 631 }
632 632
633 if (iface_desc->desc.bNumEndpoints < 1)
634 return -ENODEV;
635
633 /* check out the endpoint: it has to be Interrupt & IN */ 636 /* check out the endpoint: it has to be Interrupt & IN */
634 endpoint = &iface_desc->endpoint[0].desc; 637 endpoint = &iface_desc->endpoint[0].desc;
635 638
diff --git a/drivers/watchdog/sama5d4_wdt.c b/drivers/watchdog/sama5d4_wdt.c
index f709962018ac..362fd229786d 100644
--- a/drivers/watchdog/sama5d4_wdt.c
+++ b/drivers/watchdog/sama5d4_wdt.c
@@ -6,6 +6,7 @@
6 * Licensed under GPLv2. 6 * Licensed under GPLv2.
7 */ 7 */
8 8
9#include <linux/delay.h>
9#include <linux/interrupt.h> 10#include <linux/interrupt.h>
10#include <linux/io.h> 11#include <linux/io.h>
11#include <linux/kernel.h> 12#include <linux/kernel.h>
@@ -29,6 +30,7 @@ struct sama5d4_wdt {
29 struct watchdog_device wdd; 30 struct watchdog_device wdd;
30 void __iomem *reg_base; 31 void __iomem *reg_base;
31 u32 mr; 32 u32 mr;
33 unsigned long last_ping;
32}; 34};
33 35
34static int wdt_timeout = WDT_DEFAULT_TIMEOUT; 36static int wdt_timeout = WDT_DEFAULT_TIMEOUT;
@@ -44,11 +46,34 @@ MODULE_PARM_DESC(nowayout,
44 "Watchdog cannot be stopped once started (default=" 46 "Watchdog cannot be stopped once started (default="
45 __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); 47 __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
46 48
49#define wdt_enabled (!(wdt->mr & AT91_WDT_WDDIS))
50
47#define wdt_read(wdt, field) \ 51#define wdt_read(wdt, field) \
48 readl_relaxed((wdt)->reg_base + (field)) 52 readl_relaxed((wdt)->reg_base + (field))
49 53
50#define wdt_write(wtd, field, val) \ 54/* 4 slow clock periods is 4/32768 = 122.07µs*/
51 writel_relaxed((val), (wdt)->reg_base + (field)) 55#define WDT_DELAY usecs_to_jiffies(123)
56
57static void wdt_write(struct sama5d4_wdt *wdt, u32 field, u32 val)
58{
59 /*
60 * WDT_CR and WDT_MR must not be modified within three slow clock
61 * periods following a restart of the watchdog performed by a write
62 * access in WDT_CR.
63 */
64 while (time_before(jiffies, wdt->last_ping + WDT_DELAY))
65 usleep_range(30, 125);
66 writel_relaxed(val, wdt->reg_base + field);
67 wdt->last_ping = jiffies;
68}
69
70static void wdt_write_nosleep(struct sama5d4_wdt *wdt, u32 field, u32 val)
71{
72 if (time_before(jiffies, wdt->last_ping + WDT_DELAY))
73 udelay(123);
74 writel_relaxed(val, wdt->reg_base + field);
75 wdt->last_ping = jiffies;
76}
52 77
53static int sama5d4_wdt_start(struct watchdog_device *wdd) 78static int sama5d4_wdt_start(struct watchdog_device *wdd)
54{ 79{
@@ -89,7 +114,16 @@ static int sama5d4_wdt_set_timeout(struct watchdog_device *wdd,
89 wdt->mr &= ~AT91_WDT_WDD; 114 wdt->mr &= ~AT91_WDT_WDD;
90 wdt->mr |= AT91_WDT_SET_WDV(value); 115 wdt->mr |= AT91_WDT_SET_WDV(value);
91 wdt->mr |= AT91_WDT_SET_WDD(value); 116 wdt->mr |= AT91_WDT_SET_WDD(value);
92 wdt_write(wdt, AT91_WDT_MR, wdt->mr); 117
118 /*
119 * WDDIS has to be 0 when updating WDD/WDV. The datasheet states: When
120 * setting the WDDIS bit, and while it is set, the fields WDV and WDD
121 * must not be modified.
122 * If the watchdog is enabled, then the timeout can be updated. Else,
123 * wait that the user enables it.
124 */
125 if (wdt_enabled)
126 wdt_write(wdt, AT91_WDT_MR, wdt->mr & ~AT91_WDT_WDDIS);
93 127
94 wdd->timeout = timeout; 128 wdd->timeout = timeout;
95 129
@@ -145,23 +179,21 @@ static int of_sama5d4_wdt_init(struct device_node *np, struct sama5d4_wdt *wdt)
145 179
146static int sama5d4_wdt_init(struct sama5d4_wdt *wdt) 180static int sama5d4_wdt_init(struct sama5d4_wdt *wdt)
147{ 181{
148 struct watchdog_device *wdd = &wdt->wdd;
149 u32 value = WDT_SEC2TICKS(wdd->timeout);
150 u32 reg; 182 u32 reg;
151
152 /* 183 /*
153 * Because the fields WDV and WDD must not be modified when the WDDIS 184 * When booting and resuming, the bootloader may have changed the
154 * bit is set, so clear the WDDIS bit before writing the WDT_MR. 185 * watchdog configuration.
186 * If the watchdog is already running, we can safely update it.
187 * Else, we have to disable it properly.
155 */ 188 */
156 reg = wdt_read(wdt, AT91_WDT_MR); 189 if (wdt_enabled) {
157 reg &= ~AT91_WDT_WDDIS; 190 wdt_write_nosleep(wdt, AT91_WDT_MR, wdt->mr);
158 wdt_write(wdt, AT91_WDT_MR, reg); 191 } else {
159 192 reg = wdt_read(wdt, AT91_WDT_MR);
160 wdt->mr |= AT91_WDT_SET_WDD(value); 193 if (!(reg & AT91_WDT_WDDIS))
161 wdt->mr |= AT91_WDT_SET_WDV(value); 194 wdt_write_nosleep(wdt, AT91_WDT_MR,
162 195 reg | AT91_WDT_WDDIS);
163 wdt_write(wdt, AT91_WDT_MR, wdt->mr); 196 }
164
165 return 0; 197 return 0;
166} 198}
167 199
@@ -172,6 +204,7 @@ static int sama5d4_wdt_probe(struct platform_device *pdev)
172 struct resource *res; 204 struct resource *res;
173 void __iomem *regs; 205 void __iomem *regs;
174 u32 irq = 0; 206 u32 irq = 0;
207 u32 timeout;
175 int ret; 208 int ret;
176 209
177 wdt = devm_kzalloc(&pdev->dev, sizeof(*wdt), GFP_KERNEL); 210 wdt = devm_kzalloc(&pdev->dev, sizeof(*wdt), GFP_KERNEL);
@@ -184,6 +217,7 @@ static int sama5d4_wdt_probe(struct platform_device *pdev)
184 wdd->ops = &sama5d4_wdt_ops; 217 wdd->ops = &sama5d4_wdt_ops;
185 wdd->min_timeout = MIN_WDT_TIMEOUT; 218 wdd->min_timeout = MIN_WDT_TIMEOUT;
186 wdd->max_timeout = MAX_WDT_TIMEOUT; 219 wdd->max_timeout = MAX_WDT_TIMEOUT;
220 wdt->last_ping = jiffies;
187 221
188 watchdog_set_drvdata(wdd, wdt); 222 watchdog_set_drvdata(wdd, wdt);
189 223
@@ -221,6 +255,11 @@ static int sama5d4_wdt_probe(struct platform_device *pdev)
221 return ret; 255 return ret;
222 } 256 }
223 257
258 timeout = WDT_SEC2TICKS(wdd->timeout);
259
260 wdt->mr |= AT91_WDT_SET_WDD(timeout);
261 wdt->mr |= AT91_WDT_SET_WDV(timeout);
262
224 ret = sama5d4_wdt_init(wdt); 263 ret = sama5d4_wdt_init(wdt);
225 if (ret) 264 if (ret)
226 return ret; 265 return ret;
@@ -263,9 +302,7 @@ static int sama5d4_wdt_resume(struct device *dev)
263{ 302{
264 struct sama5d4_wdt *wdt = dev_get_drvdata(dev); 303 struct sama5d4_wdt *wdt = dev_get_drvdata(dev);
265 304
266 wdt_write(wdt, AT91_WDT_MR, wdt->mr & ~AT91_WDT_WDDIS); 305 sama5d4_wdt_init(wdt);
267 if (wdt->mr & AT91_WDT_WDDIS)
268 wdt_write(wdt, AT91_WDT_MR, wdt->mr);
269 306
270 return 0; 307 return 0;
271} 308}
diff --git a/drivers/watchdog/wdt_pci.c b/drivers/watchdog/wdt_pci.c
index 48b2c058b009..bc7addc2dc06 100644
--- a/drivers/watchdog/wdt_pci.c
+++ b/drivers/watchdog/wdt_pci.c
@@ -332,7 +332,7 @@ static irqreturn_t wdtpci_interrupt(int irq, void *dev_id)
332 pr_crit("Would Reboot\n"); 332 pr_crit("Would Reboot\n");
333#else 333#else
334 pr_crit("Initiating system reboot\n"); 334 pr_crit("Initiating system reboot\n");
335 emergency_restart(NULL); 335 emergency_restart();
336#endif 336#endif
337#else 337#else
338 pr_crit("Reset in 5ms\n"); 338 pr_crit("Reset in 5ms\n");
diff --git a/drivers/watchdog/zx2967_wdt.c b/drivers/watchdog/zx2967_wdt.c
index e290d5a13a6d..c98252733c30 100644
--- a/drivers/watchdog/zx2967_wdt.c
+++ b/drivers/watchdog/zx2967_wdt.c
@@ -211,10 +211,8 @@ static int zx2967_wdt_probe(struct platform_device *pdev)
211 211
212 base = platform_get_resource(pdev, IORESOURCE_MEM, 0); 212 base = platform_get_resource(pdev, IORESOURCE_MEM, 0);
213 wdt->reg_base = devm_ioremap_resource(dev, base); 213 wdt->reg_base = devm_ioremap_resource(dev, base);
214 if (IS_ERR(wdt->reg_base)) { 214 if (IS_ERR(wdt->reg_base))
215 dev_err(dev, "ioremap failed\n");
216 return PTR_ERR(wdt->reg_base); 215 return PTR_ERR(wdt->reg_base);
217 }
218 216
219 zx2967_wdt_reset_sysctrl(dev); 217 zx2967_wdt_reset_sysctrl(dev);
220 218
diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c
index 26d77f9f8c12..2dcbd5698884 100644
--- a/fs/ext2/inode.c
+++ b/fs/ext2/inode.c
@@ -817,7 +817,7 @@ static int ext2_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
817 iomap->bdev = bdev; 817 iomap->bdev = bdev;
818 iomap->offset = (u64)first_block << blkbits; 818 iomap->offset = (u64)first_block << blkbits;
819 if (blk_queue_dax(bdev->bd_queue)) 819 if (blk_queue_dax(bdev->bd_queue))
820 iomap->dax_dev = dax_get_by_host(bdev->bd_disk->disk_name); 820 iomap->dax_dev = fs_dax_get_by_host(bdev->bd_disk->disk_name);
821 else 821 else
822 iomap->dax_dev = NULL; 822 iomap->dax_dev = NULL;
823 823
@@ -841,7 +841,7 @@ static int
841ext2_iomap_end(struct inode *inode, loff_t offset, loff_t length, 841ext2_iomap_end(struct inode *inode, loff_t offset, loff_t length,
842 ssize_t written, unsigned flags, struct iomap *iomap) 842 ssize_t written, unsigned flags, struct iomap *iomap)
843{ 843{
844 put_dax(iomap->dax_dev); 844 fs_put_dax(iomap->dax_dev);
845 if (iomap->type == IOMAP_MAPPED && 845 if (iomap->type == IOMAP_MAPPED &&
846 written < length && 846 written < length &&
847 (flags & IOMAP_WRITE)) 847 (flags & IOMAP_WRITE))
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 5834c4d76be8..1bd0bfa547f6 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -3412,7 +3412,7 @@ retry:
3412 bdev = inode->i_sb->s_bdev; 3412 bdev = inode->i_sb->s_bdev;
3413 iomap->bdev = bdev; 3413 iomap->bdev = bdev;
3414 if (blk_queue_dax(bdev->bd_queue)) 3414 if (blk_queue_dax(bdev->bd_queue))
3415 iomap->dax_dev = dax_get_by_host(bdev->bd_disk->disk_name); 3415 iomap->dax_dev = fs_dax_get_by_host(bdev->bd_disk->disk_name);
3416 else 3416 else
3417 iomap->dax_dev = NULL; 3417 iomap->dax_dev = NULL;
3418 iomap->offset = first_block << blkbits; 3418 iomap->offset = first_block << blkbits;
@@ -3447,7 +3447,7 @@ static int ext4_iomap_end(struct inode *inode, loff_t offset, loff_t length,
3447 int blkbits = inode->i_blkbits; 3447 int blkbits = inode->i_blkbits;
3448 bool truncate = false; 3448 bool truncate = false;
3449 3449
3450 put_dax(iomap->dax_dev); 3450 fs_put_dax(iomap->dax_dev);
3451 if (!(flags & IOMAP_WRITE) || (flags & IOMAP_FAULT)) 3451 if (!(flags & IOMAP_WRITE) || (flags & IOMAP_FAULT))
3452 return 0; 3452 return 0;
3453 3453
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index 5a1b58f8fef4..65c88379a3a1 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -975,8 +975,15 @@ static int fuse_bdi_init(struct fuse_conn *fc, struct super_block *sb)
975 int err; 975 int err;
976 char *suffix = ""; 976 char *suffix = "";
977 977
978 if (sb->s_bdev) 978 if (sb->s_bdev) {
979 suffix = "-fuseblk"; 979 suffix = "-fuseblk";
980 /*
981 * sb->s_bdi points to blkdev's bdi however we want to redirect
982 * it to our private bdi...
983 */
984 bdi_put(sb->s_bdi);
985 sb->s_bdi = &noop_backing_dev_info;
986 }
980 err = super_setup_bdi_name(sb, "%u:%u%s", MAJOR(fc->dev), 987 err = super_setup_bdi_name(sb, "%u:%u%s", MAJOR(fc->dev),
981 MINOR(fc->dev), suffix); 988 MINOR(fc->dev), suffix);
982 if (err) 989 if (err)
diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c
index a63f61c256bd..94e5bdf7304c 100644
--- a/fs/xfs/xfs_iomap.c
+++ b/fs/xfs/xfs_iomap.c
@@ -1068,7 +1068,7 @@ xfs_file_iomap_begin(
1068 /* optionally associate a dax device with the iomap bdev */ 1068 /* optionally associate a dax device with the iomap bdev */
1069 bdev = iomap->bdev; 1069 bdev = iomap->bdev;
1070 if (blk_queue_dax(bdev->bd_queue)) 1070 if (blk_queue_dax(bdev->bd_queue))
1071 iomap->dax_dev = dax_get_by_host(bdev->bd_disk->disk_name); 1071 iomap->dax_dev = fs_dax_get_by_host(bdev->bd_disk->disk_name);
1072 else 1072 else
1073 iomap->dax_dev = NULL; 1073 iomap->dax_dev = NULL;
1074 1074
@@ -1149,7 +1149,7 @@ xfs_file_iomap_end(
1149 unsigned flags, 1149 unsigned flags,
1150 struct iomap *iomap) 1150 struct iomap *iomap)
1151{ 1151{
1152 put_dax(iomap->dax_dev); 1152 fs_put_dax(iomap->dax_dev);
1153 if ((flags & IOMAP_WRITE) && iomap->type == IOMAP_DELALLOC) 1153 if ((flags & IOMAP_WRITE) && iomap->type == IOMAP_DELALLOC)
1154 return xfs_file_iomap_end_delalloc(XFS_I(inode), offset, 1154 return xfs_file_iomap_end_delalloc(XFS_I(inode), offset,
1155 length, written, iomap); 1155 length, written, iomap);
diff --git a/include/kvm/arm_vgic.h b/include/kvm/arm_vgic.h
index 97b8d3728b31..ef718586321c 100644
--- a/include/kvm/arm_vgic.h
+++ b/include/kvm/arm_vgic.h
@@ -195,7 +195,10 @@ struct vgic_dist {
195 /* either a GICv2 CPU interface */ 195 /* either a GICv2 CPU interface */
196 gpa_t vgic_cpu_base; 196 gpa_t vgic_cpu_base;
197 /* or a number of GICv3 redistributor regions */ 197 /* or a number of GICv3 redistributor regions */
198 gpa_t vgic_redist_base; 198 struct {
199 gpa_t vgic_redist_base;
200 gpa_t vgic_redist_free_offset;
201 };
199 }; 202 };
200 203
201 /* distributor enabled */ 204 /* distributor enabled */
diff --git a/include/linux/dax.h b/include/linux/dax.h
index 00ebac854bb7..5ec1f6c47716 100644
--- a/include/linux/dax.h
+++ b/include/linux/dax.h
@@ -18,6 +18,20 @@ struct dax_operations {
18 void **, pfn_t *); 18 void **, pfn_t *);
19}; 19};
20 20
21#if IS_ENABLED(CONFIG_DAX)
22struct dax_device *dax_get_by_host(const char *host);
23void put_dax(struct dax_device *dax_dev);
24#else
25static inline struct dax_device *dax_get_by_host(const char *host)
26{
27 return NULL;
28}
29
30static inline void put_dax(struct dax_device *dax_dev)
31{
32}
33#endif
34
21int bdev_dax_pgoff(struct block_device *, sector_t, size_t, pgoff_t *pgoff); 35int bdev_dax_pgoff(struct block_device *, sector_t, size_t, pgoff_t *pgoff);
22#if IS_ENABLED(CONFIG_FS_DAX) 36#if IS_ENABLED(CONFIG_FS_DAX)
23int __bdev_dax_supported(struct super_block *sb, int blocksize); 37int __bdev_dax_supported(struct super_block *sb, int blocksize);
@@ -25,23 +39,29 @@ static inline int bdev_dax_supported(struct super_block *sb, int blocksize)
25{ 39{
26 return __bdev_dax_supported(sb, blocksize); 40 return __bdev_dax_supported(sb, blocksize);
27} 41}
42
43static inline struct dax_device *fs_dax_get_by_host(const char *host)
44{
45 return dax_get_by_host(host);
46}
47
48static inline void fs_put_dax(struct dax_device *dax_dev)
49{
50 put_dax(dax_dev);
51}
52
28#else 53#else
29static inline int bdev_dax_supported(struct super_block *sb, int blocksize) 54static inline int bdev_dax_supported(struct super_block *sb, int blocksize)
30{ 55{
31 return -EOPNOTSUPP; 56 return -EOPNOTSUPP;
32} 57}
33#endif
34 58
35#if IS_ENABLED(CONFIG_DAX) 59static inline struct dax_device *fs_dax_get_by_host(const char *host)
36struct dax_device *dax_get_by_host(const char *host);
37void put_dax(struct dax_device *dax_dev);
38#else
39static inline struct dax_device *dax_get_by_host(const char *host)
40{ 60{
41 return NULL; 61 return NULL;
42} 62}
43 63
44static inline void put_dax(struct dax_device *dax_dev) 64static inline void fs_put_dax(struct dax_device *dax_dev)
45{ 65{
46} 66}
47#endif 67#endif
diff --git a/include/linux/kprobes.h b/include/linux/kprobes.h
index 30f90c1a0aaf..541df0b5b815 100644
--- a/include/linux/kprobes.h
+++ b/include/linux/kprobes.h
@@ -349,6 +349,9 @@ extern int proc_kprobes_optimization_handler(struct ctl_table *table,
349 int write, void __user *buffer, 349 int write, void __user *buffer,
350 size_t *length, loff_t *ppos); 350 size_t *length, loff_t *ppos);
351#endif 351#endif
352extern void wait_for_kprobe_optimizer(void);
353#else
354static inline void wait_for_kprobe_optimizer(void) { }
352#endif /* CONFIG_OPTPROBES */ 355#endif /* CONFIG_OPTPROBES */
353#ifdef CONFIG_KPROBES_ON_FTRACE 356#ifdef CONFIG_KPROBES_ON_FTRACE
354extern void kprobe_ftrace_handler(unsigned long ip, unsigned long parent_ip, 357extern void kprobe_ftrace_handler(unsigned long ip, unsigned long parent_ip,
diff --git a/include/linux/netfilter/x_tables.h b/include/linux/netfilter/x_tables.h
index be378cf47fcc..b3044c2c62cb 100644
--- a/include/linux/netfilter/x_tables.h
+++ b/include/linux/netfilter/x_tables.h
@@ -294,7 +294,7 @@ int xt_match_to_user(const struct xt_entry_match *m,
294int xt_target_to_user(const struct xt_entry_target *t, 294int xt_target_to_user(const struct xt_entry_target *t,
295 struct xt_entry_target __user *u); 295 struct xt_entry_target __user *u);
296int xt_data_to_user(void __user *dst, const void *src, 296int xt_data_to_user(void __user *dst, const void *src,
297 int usersize, int size); 297 int usersize, int size, int aligned_size);
298 298
299void *xt_copy_counters_from_user(const void __user *user, unsigned int len, 299void *xt_copy_counters_from_user(const void __user *user, unsigned int len,
300 struct xt_counters_info *info, bool compat); 300 struct xt_counters_info *info, bool compat);
diff --git a/include/linux/netfilter_bridge/ebtables.h b/include/linux/netfilter_bridge/ebtables.h
index a30efb437e6d..e0cbf17af780 100644
--- a/include/linux/netfilter_bridge/ebtables.h
+++ b/include/linux/netfilter_bridge/ebtables.h
@@ -125,4 +125,9 @@ extern unsigned int ebt_do_table(struct sk_buff *skb,
125/* True if the target is not a standard target */ 125/* True if the target is not a standard target */
126#define INVALID_TARGET (info->target < -NUM_STANDARD_TARGETS || info->target >= 0) 126#define INVALID_TARGET (info->target < -NUM_STANDARD_TARGETS || info->target >= 0)
127 127
128static inline bool ebt_invalid_target(int target)
129{
130 return (target < -NUM_STANDARD_TARGETS || target >= 0);
131}
132
128#endif 133#endif
diff --git a/include/linux/nvme-fc-driver.h b/include/linux/nvme-fc-driver.h
index 0db37158a61d..6c8c5d8041b7 100644
--- a/include/linux/nvme-fc-driver.h
+++ b/include/linux/nvme-fc-driver.h
@@ -27,8 +27,8 @@
27 27
28/* FC Port role bitmask - can merge with FC Port Roles in fc transport */ 28/* FC Port role bitmask - can merge with FC Port Roles in fc transport */
29#define FC_PORT_ROLE_NVME_INITIATOR 0x10 29#define FC_PORT_ROLE_NVME_INITIATOR 0x10
30#define FC_PORT_ROLE_NVME_TARGET 0x11 30#define FC_PORT_ROLE_NVME_TARGET 0x20
31#define FC_PORT_ROLE_NVME_DISCOVERY 0x12 31#define FC_PORT_ROLE_NVME_DISCOVERY 0x40
32 32
33 33
34/** 34/**
@@ -642,15 +642,7 @@ enum {
642 * sequence in one LLDD operation. Errors during Data 642 * sequence in one LLDD operation. Errors during Data
643 * sequence transmit must not allow RSP sequence to be sent. 643 * sequence transmit must not allow RSP sequence to be sent.
644 */ 644 */
645 NVMET_FCTGTFEAT_NEEDS_CMD_CPUSCHED = (1 << 1), 645 NVMET_FCTGTFEAT_CMD_IN_ISR = (1 << 1),
646 /* Bit 1: When 0, the LLDD will deliver FCP CMD
647 * on the CPU it should be affinitized to. Thus work will
648 * be scheduled on the cpu received on. When 1, the LLDD
649 * may not deliver the CMD on the CPU it should be worked
650 * on. The transport should pick a cpu to schedule the work
651 * on.
652 */
653 NVMET_FCTGTFEAT_CMD_IN_ISR = (1 << 2),
654 /* Bit 2: When 0, the LLDD is calling the cmd rcv handler 646 /* Bit 2: When 0, the LLDD is calling the cmd rcv handler
655 * in a non-isr context, allowing the transport to finish 647 * in a non-isr context, allowing the transport to finish
656 * op completion in the calling context. When 1, the LLDD 648 * op completion in the calling context. When 1, the LLDD
@@ -658,7 +650,7 @@ enum {
658 * requiring the transport to transition to a workqueue 650 * requiring the transport to transition to a workqueue
659 * for op completion. 651 * for op completion.
660 */ 652 */
661 NVMET_FCTGTFEAT_OPDONE_IN_ISR = (1 << 3), 653 NVMET_FCTGTFEAT_OPDONE_IN_ISR = (1 << 2),
662 /* Bit 3: When 0, the LLDD is calling the op done handler 654 /* Bit 3: When 0, the LLDD is calling the op done handler
663 * in a non-isr context, allowing the transport to finish 655 * in a non-isr context, allowing the transport to finish
664 * op completion in the calling context. When 1, the LLDD 656 * op completion in the calling context. When 1, the LLDD
diff --git a/include/linux/of_irq.h b/include/linux/of_irq.h
index ec6b11deb773..1e0deb8e8494 100644
--- a/include/linux/of_irq.h
+++ b/include/linux/of_irq.h
@@ -8,7 +8,7 @@
8#include <linux/ioport.h> 8#include <linux/ioport.h>
9#include <linux/of.h> 9#include <linux/of.h>
10 10
11typedef int const (*of_irq_init_cb_t)(struct device_node *, struct device_node *); 11typedef int (*of_irq_init_cb_t)(struct device_node *, struct device_node *);
12 12
13/* 13/*
14 * Workarounds only applied to 32bit powermac machines 14 * Workarounds only applied to 32bit powermac machines
diff --git a/include/linux/soc/renesas/rcar-rst.h b/include/linux/soc/renesas/rcar-rst.h
index a18e0783946b..787e7ad53d45 100644
--- a/include/linux/soc/renesas/rcar-rst.h
+++ b/include/linux/soc/renesas/rcar-rst.h
@@ -1,6 +1,11 @@
1#ifndef __LINUX_SOC_RENESAS_RCAR_RST_H__ 1#ifndef __LINUX_SOC_RENESAS_RCAR_RST_H__
2#define __LINUX_SOC_RENESAS_RCAR_RST_H__ 2#define __LINUX_SOC_RENESAS_RCAR_RST_H__
3 3
4#if defined(CONFIG_ARCH_RCAR_GEN1) || defined(CONFIG_ARCH_RCAR_GEN2) || \
5 defined(CONFIG_ARCH_R8A7795) || defined(CONFIG_ARCH_R8A7796)
4int rcar_rst_read_mode_pins(u32 *mode); 6int rcar_rst_read_mode_pins(u32 *mode);
7#else
8static inline int rcar_rst_read_mode_pins(u32 *mode) { return -ENODEV; }
9#endif
5 10
6#endif /* __LINUX_SOC_RENESAS_RCAR_RST_H__ */ 11#endif /* __LINUX_SOC_RENESAS_RCAR_RST_H__ */
diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h
index a469999a106d..50398b69ca44 100644
--- a/include/linux/usb/hcd.h
+++ b/include/linux/usb/hcd.h
@@ -148,6 +148,7 @@ struct usb_hcd {
148 unsigned rh_registered:1;/* is root hub registered? */ 148 unsigned rh_registered:1;/* is root hub registered? */
149 unsigned rh_pollable:1; /* may we poll the root hub? */ 149 unsigned rh_pollable:1; /* may we poll the root hub? */
150 unsigned msix_enabled:1; /* driver has MSI-X enabled? */ 150 unsigned msix_enabled:1; /* driver has MSI-X enabled? */
151 unsigned msi_enabled:1; /* driver has MSI enabled? */
151 unsigned remove_phy:1; /* auto-remove USB phy */ 152 unsigned remove_phy:1; /* auto-remove USB phy */
152 153
153 /* The next flag is a stopgap, to be removed when all the HCDs 154 /* The next flag is a stopgap, to be removed when all the HCDs
diff --git a/include/net/netfilter/nf_conntrack_helper.h b/include/net/netfilter/nf_conntrack_helper.h
index e04fa7691e5d..c519bb5b5bb8 100644
--- a/include/net/netfilter/nf_conntrack_helper.h
+++ b/include/net/netfilter/nf_conntrack_helper.h
@@ -9,6 +9,7 @@
9 9
10#ifndef _NF_CONNTRACK_HELPER_H 10#ifndef _NF_CONNTRACK_HELPER_H
11#define _NF_CONNTRACK_HELPER_H 11#define _NF_CONNTRACK_HELPER_H
12#include <linux/refcount.h>
12#include <net/netfilter/nf_conntrack.h> 13#include <net/netfilter/nf_conntrack.h>
13#include <net/netfilter/nf_conntrack_extend.h> 14#include <net/netfilter/nf_conntrack_extend.h>
14#include <net/netfilter/nf_conntrack_expect.h> 15#include <net/netfilter/nf_conntrack_expect.h>
@@ -26,6 +27,7 @@ struct nf_conntrack_helper {
26 struct hlist_node hnode; /* Internal use. */ 27 struct hlist_node hnode; /* Internal use. */
27 28
28 char name[NF_CT_HELPER_NAME_LEN]; /* name of the module */ 29 char name[NF_CT_HELPER_NAME_LEN]; /* name of the module */
30 refcount_t refcnt;
29 struct module *me; /* pointer to self */ 31 struct module *me; /* pointer to self */
30 const struct nf_conntrack_expect_policy *expect_policy; 32 const struct nf_conntrack_expect_policy *expect_policy;
31 33
@@ -79,6 +81,8 @@ struct nf_conntrack_helper *__nf_conntrack_helper_find(const char *name,
79struct nf_conntrack_helper *nf_conntrack_helper_try_module_get(const char *name, 81struct nf_conntrack_helper *nf_conntrack_helper_try_module_get(const char *name,
80 u16 l3num, 82 u16 l3num,
81 u8 protonum); 83 u8 protonum);
84void nf_conntrack_helper_put(struct nf_conntrack_helper *helper);
85
82void nf_ct_helper_init(struct nf_conntrack_helper *helper, 86void nf_ct_helper_init(struct nf_conntrack_helper *helper,
83 u16 l3num, u16 protonum, const char *name, 87 u16 l3num, u16 protonum, const char *name,
84 u16 default_port, u16 spec_port, u32 id, 88 u16 default_port, u16 spec_port, u32 id,
diff --git a/include/net/netfilter/nf_tables.h b/include/net/netfilter/nf_tables.h
index 028faec8fc27..8a8bab8d7b15 100644
--- a/include/net/netfilter/nf_tables.h
+++ b/include/net/netfilter/nf_tables.h
@@ -176,7 +176,7 @@ struct nft_data_desc {
176int nft_data_init(const struct nft_ctx *ctx, 176int nft_data_init(const struct nft_ctx *ctx,
177 struct nft_data *data, unsigned int size, 177 struct nft_data *data, unsigned int size,
178 struct nft_data_desc *desc, const struct nlattr *nla); 178 struct nft_data_desc *desc, const struct nlattr *nla);
179void nft_data_uninit(const struct nft_data *data, enum nft_data_types type); 179void nft_data_release(const struct nft_data *data, enum nft_data_types type);
180int nft_data_dump(struct sk_buff *skb, int attr, const struct nft_data *data, 180int nft_data_dump(struct sk_buff *skb, int attr, const struct nft_data *data,
181 enum nft_data_types type, unsigned int len); 181 enum nft_data_types type, unsigned int len);
182 182
diff --git a/include/uapi/linux/usb/ch11.h b/include/uapi/linux/usb/ch11.h
index 361297e96f58..576c704e3fb8 100644
--- a/include/uapi/linux/usb/ch11.h
+++ b/include/uapi/linux/usb/ch11.h
@@ -22,6 +22,9 @@
22 */ 22 */
23#define USB_MAXCHILDREN 31 23#define USB_MAXCHILDREN 31
24 24
25/* See USB 3.1 spec Table 10-5 */
26#define USB_SS_MAXPORTS 15
27
25/* 28/*
26 * Hub request types 29 * Hub request types
27 */ 30 */
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 1eddb713b815..c72cd41f5b8b 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -808,11 +808,15 @@ static int check_pkt_ptr_alignment(const struct bpf_reg_state *reg,
808 reg_off += reg->aux_off; 808 reg_off += reg->aux_off;
809 } 809 }
810 810
811 /* skb->data is NET_IP_ALIGN-ed, but for strict alignment checking 811 /* For platforms that do not have a Kconfig enabling
812 * we force this to 2 which is universally what architectures use 812 * CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS the value of
813 * when they don't set CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS. 813 * NET_IP_ALIGN is universally set to '2'. And on platforms
814 * that do set CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS, we get
815 * to this code only in strict mode where we want to emulate
816 * the NET_IP_ALIGN==2 checking. Therefore use an
817 * unconditional IP align value of '2'.
814 */ 818 */
815 ip_align = strict ? 2 : NET_IP_ALIGN; 819 ip_align = 2;
816 if ((ip_align + reg_off + off) % size != 0) { 820 if ((ip_align + reg_off + off) % size != 0) {
817 verbose("misaligned packet access off %d+%d+%d size %d\n", 821 verbose("misaligned packet access off %d+%d+%d size %d\n",
818 ip_align, reg_off, off, size); 822 ip_align, reg_off, off, size);
diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c
index 686be4b73018..c94da688ee9b 100644
--- a/kernel/irq/chip.c
+++ b/kernel/irq/chip.c
@@ -880,8 +880,8 @@ irq_set_chained_handler_and_data(unsigned int irq, irq_flow_handler_t handle,
880 if (!desc) 880 if (!desc)
881 return; 881 return;
882 882
883 __irq_do_set_handler(desc, handle, 1, NULL);
884 desc->irq_common_data.handler_data = data; 883 desc->irq_common_data.handler_data = data;
884 __irq_do_set_handler(desc, handle, 1, NULL);
885 885
886 irq_put_desc_busunlock(desc, flags); 886 irq_put_desc_busunlock(desc, flags);
887} 887}
diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 7367e0ec6f81..2d2d3a568e4e 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -595,7 +595,7 @@ static void kprobe_optimizer(struct work_struct *work)
595} 595}
596 596
597/* Wait for completing optimization and unoptimization */ 597/* Wait for completing optimization and unoptimization */
598static void wait_for_kprobe_optimizer(void) 598void wait_for_kprobe_optimizer(void)
599{ 599{
600 mutex_lock(&kprobe_mutex); 600 mutex_lock(&kprobe_mutex);
601 601
@@ -2183,6 +2183,12 @@ static int kprobes_module_callback(struct notifier_block *nb,
2183 * The vaddr this probe is installed will soon 2183 * The vaddr this probe is installed will soon
2184 * be vfreed buy not synced to disk. Hence, 2184 * be vfreed buy not synced to disk. Hence,
2185 * disarming the breakpoint isn't needed. 2185 * disarming the breakpoint isn't needed.
2186 *
2187 * Note, this will also move any optimized probes
2188 * that are pending to be removed from their
2189 * corresponding lists to the freeing_list and
2190 * will not be touched by the delayed
2191 * kprobe_optimizer work handler.
2186 */ 2192 */
2187 kill_kprobe(p); 2193 kill_kprobe(p);
2188 } 2194 }
diff --git a/kernel/power/snapshot.c b/kernel/power/snapshot.c
index 3b1e0f3ad07f..fa46606f3356 100644
--- a/kernel/power/snapshot.c
+++ b/kernel/power/snapshot.c
@@ -1425,7 +1425,7 @@ static unsigned int nr_meta_pages;
1425 * Numbers of normal and highmem page frames allocated for hibernation image 1425 * Numbers of normal and highmem page frames allocated for hibernation image
1426 * before suspending devices. 1426 * before suspending devices.
1427 */ 1427 */
1428unsigned int alloc_normal, alloc_highmem; 1428static unsigned int alloc_normal, alloc_highmem;
1429/* 1429/*
1430 * Memory bitmap used for marking saveable pages (during hibernation) or 1430 * Memory bitmap used for marking saveable pages (during hibernation) or
1431 * hibernation image pages (during restore) 1431 * hibernation image pages (during restore)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 759f4bd52cd6..803c3bc274c4 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -3502,6 +3502,31 @@ asmlinkage __visible void __sched schedule(void)
3502} 3502}
3503EXPORT_SYMBOL(schedule); 3503EXPORT_SYMBOL(schedule);
3504 3504
3505/*
3506 * synchronize_rcu_tasks() makes sure that no task is stuck in preempted
3507 * state (have scheduled out non-voluntarily) by making sure that all
3508 * tasks have either left the run queue or have gone into user space.
3509 * As idle tasks do not do either, they must not ever be preempted
3510 * (schedule out non-voluntarily).
3511 *
3512 * schedule_idle() is similar to schedule_preempt_disable() except that it
3513 * never enables preemption because it does not call sched_submit_work().
3514 */
3515void __sched schedule_idle(void)
3516{
3517 /*
3518 * As this skips calling sched_submit_work(), which the idle task does
3519 * regardless because that function is a nop when the task is in a
3520 * TASK_RUNNING state, make sure this isn't used someplace that the
3521 * current task can be in any other state. Note, idle is always in the
3522 * TASK_RUNNING state.
3523 */
3524 WARN_ON_ONCE(current->state);
3525 do {
3526 __schedule(false);
3527 } while (need_resched());
3528}
3529
3505#ifdef CONFIG_CONTEXT_TRACKING 3530#ifdef CONFIG_CONTEXT_TRACKING
3506asmlinkage __visible void __sched schedule_user(void) 3531asmlinkage __visible void __sched schedule_user(void)
3507{ 3532{
diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c
index 76877a62b5fa..622eed1b7658 100644
--- a/kernel/sched/cpufreq_schedutil.c
+++ b/kernel/sched/cpufreq_schedutil.c
@@ -245,11 +245,10 @@ static void sugov_update_single(struct update_util_data *hook, u64 time,
245 sugov_update_commit(sg_policy, time, next_f); 245 sugov_update_commit(sg_policy, time, next_f);
246} 246}
247 247
248static unsigned int sugov_next_freq_shared(struct sugov_cpu *sg_cpu) 248static unsigned int sugov_next_freq_shared(struct sugov_cpu *sg_cpu, u64 time)
249{ 249{
250 struct sugov_policy *sg_policy = sg_cpu->sg_policy; 250 struct sugov_policy *sg_policy = sg_cpu->sg_policy;
251 struct cpufreq_policy *policy = sg_policy->policy; 251 struct cpufreq_policy *policy = sg_policy->policy;
252 u64 last_freq_update_time = sg_policy->last_freq_update_time;
253 unsigned long util = 0, max = 1; 252 unsigned long util = 0, max = 1;
254 unsigned int j; 253 unsigned int j;
255 254
@@ -265,7 +264,7 @@ static unsigned int sugov_next_freq_shared(struct sugov_cpu *sg_cpu)
265 * enough, don't take the CPU into account as it probably is 264 * enough, don't take the CPU into account as it probably is
266 * idle now (and clear iowait_boost for it). 265 * idle now (and clear iowait_boost for it).
267 */ 266 */
268 delta_ns = last_freq_update_time - j_sg_cpu->last_update; 267 delta_ns = time - j_sg_cpu->last_update;
269 if (delta_ns > TICK_NSEC) { 268 if (delta_ns > TICK_NSEC) {
270 j_sg_cpu->iowait_boost = 0; 269 j_sg_cpu->iowait_boost = 0;
271 continue; 270 continue;
@@ -309,7 +308,7 @@ static void sugov_update_shared(struct update_util_data *hook, u64 time,
309 if (flags & SCHED_CPUFREQ_RT_DL) 308 if (flags & SCHED_CPUFREQ_RT_DL)
310 next_f = sg_policy->policy->cpuinfo.max_freq; 309 next_f = sg_policy->policy->cpuinfo.max_freq;
311 else 310 else
312 next_f = sugov_next_freq_shared(sg_cpu); 311 next_f = sugov_next_freq_shared(sg_cpu, time);
313 312
314 sugov_update_commit(sg_policy, time, next_f); 313 sugov_update_commit(sg_policy, time, next_f);
315 } 314 }
diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c
index 2a25a9ec2c6e..ef63adce0c9c 100644
--- a/kernel/sched/idle.c
+++ b/kernel/sched/idle.c
@@ -265,7 +265,7 @@ static void do_idle(void)
265 smp_mb__after_atomic(); 265 smp_mb__after_atomic();
266 266
267 sched_ttwu_pending(); 267 sched_ttwu_pending();
268 schedule_preempt_disabled(); 268 schedule_idle();
269 269
270 if (unlikely(klp_patch_pending(current))) 270 if (unlikely(klp_patch_pending(current)))
271 klp_update_patch_state(current); 271 klp_update_patch_state(current);
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 7808ab050599..6dda2aab731e 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -1467,6 +1467,8 @@ static inline struct cpuidle_state *idle_get_state(struct rq *rq)
1467} 1467}
1468#endif 1468#endif
1469 1469
1470extern void schedule_idle(void);
1471
1470extern void sysrq_sched_debug_show(void); 1472extern void sysrq_sched_debug_show(void);
1471extern void sched_init_granularity(void); 1473extern void sched_init_granularity(void);
1472extern void update_max_interval(void); 1474extern void update_max_interval(void);
diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
index bd8ae8d5ae9c..193c5f5e3f79 100644
--- a/kernel/trace/blktrace.c
+++ b/kernel/trace/blktrace.c
@@ -1662,14 +1662,14 @@ static ssize_t sysfs_blk_trace_attr_store(struct device *dev,
1662 goto out; 1662 goto out;
1663 1663
1664 if (attr == &dev_attr_act_mask) { 1664 if (attr == &dev_attr_act_mask) {
1665 if (sscanf(buf, "%llx", &value) != 1) { 1665 if (kstrtoull(buf, 0, &value)) {
1666 /* Assume it is a list of trace category names */ 1666 /* Assume it is a list of trace category names */
1667 ret = blk_trace_str2mask(buf); 1667 ret = blk_trace_str2mask(buf);
1668 if (ret < 0) 1668 if (ret < 0)
1669 goto out; 1669 goto out;
1670 value = ret; 1670 value = ret;
1671 } 1671 }
1672 } else if (sscanf(buf, "%llu", &value) != 1) 1672 } else if (kstrtoull(buf, 0, &value))
1673 goto out; 1673 goto out;
1674 1674
1675 ret = -ENXIO; 1675 ret = -ENXIO;
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 39dca4e86a94..74fdfe9ed3db 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -4144,9 +4144,9 @@ unregister_ftrace_function_probe_func(char *glob, struct trace_array *tr,
4144 int i, ret = -ENODEV; 4144 int i, ret = -ENODEV;
4145 int size; 4145 int size;
4146 4146
4147 if (glob && (strcmp(glob, "*") == 0 || !strlen(glob))) 4147 if (!glob || !strlen(glob) || !strcmp(glob, "*"))
4148 func_g.search = NULL; 4148 func_g.search = NULL;
4149 else if (glob) { 4149 else {
4150 int not; 4150 int not;
4151 4151
4152 func_g.type = filter_parse_regex(glob, strlen(glob), 4152 func_g.type = filter_parse_regex(glob, strlen(glob),
@@ -4256,6 +4256,14 @@ unregister_ftrace_function_probe_func(char *glob, struct trace_array *tr,
4256 return ret; 4256 return ret;
4257} 4257}
4258 4258
4259void clear_ftrace_function_probes(struct trace_array *tr)
4260{
4261 struct ftrace_func_probe *probe, *n;
4262
4263 list_for_each_entry_safe(probe, n, &tr->func_probes, list)
4264 unregister_ftrace_function_probe_func(NULL, tr, probe->probe_ops);
4265}
4266
4259static LIST_HEAD(ftrace_commands); 4267static LIST_HEAD(ftrace_commands);
4260static DEFINE_MUTEX(ftrace_cmd_mutex); 4268static DEFINE_MUTEX(ftrace_cmd_mutex);
4261 4269
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index c4536c449021..1122f151466f 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -1558,7 +1558,7 @@ static __init int init_trace_selftests(void)
1558 1558
1559 return 0; 1559 return 0;
1560} 1560}
1561early_initcall(init_trace_selftests); 1561core_initcall(init_trace_selftests);
1562#else 1562#else
1563static inline int run_tracer_selftest(struct tracer *type) 1563static inline int run_tracer_selftest(struct tracer *type)
1564{ 1564{
@@ -2568,7 +2568,36 @@ static inline void ftrace_trace_stack(struct trace_array *tr,
2568void __trace_stack(struct trace_array *tr, unsigned long flags, int skip, 2568void __trace_stack(struct trace_array *tr, unsigned long flags, int skip,
2569 int pc) 2569 int pc)
2570{ 2570{
2571 __ftrace_trace_stack(tr->trace_buffer.buffer, flags, skip, pc, NULL); 2571 struct ring_buffer *buffer = tr->trace_buffer.buffer;
2572
2573 if (rcu_is_watching()) {
2574 __ftrace_trace_stack(buffer, flags, skip, pc, NULL);
2575 return;
2576 }
2577
2578 /*
2579 * When an NMI triggers, RCU is enabled via rcu_nmi_enter(),
2580 * but if the above rcu_is_watching() failed, then the NMI
2581 * triggered someplace critical, and rcu_irq_enter() should
2582 * not be called from NMI.
2583 */
2584 if (unlikely(in_nmi()))
2585 return;
2586
2587 /*
2588 * It is possible that a function is being traced in a
2589 * location that RCU is not watching. A call to
2590 * rcu_irq_enter() will make sure that it is, but there's
2591 * a few internal rcu functions that could be traced
2592 * where that wont work either. In those cases, we just
2593 * do nothing.
2594 */
2595 if (unlikely(rcu_irq_enter_disabled()))
2596 return;
2597
2598 rcu_irq_enter_irqson();
2599 __ftrace_trace_stack(buffer, flags, skip, pc, NULL);
2600 rcu_irq_exit_irqson();
2572} 2601}
2573 2602
2574/** 2603/**
@@ -7550,6 +7579,7 @@ static int instance_rmdir(const char *name)
7550 } 7579 }
7551 7580
7552 tracing_set_nop(tr); 7581 tracing_set_nop(tr);
7582 clear_ftrace_function_probes(tr);
7553 event_trace_del_tracer(tr); 7583 event_trace_del_tracer(tr);
7554 ftrace_clear_pids(tr); 7584 ftrace_clear_pids(tr);
7555 ftrace_destroy_function_files(tr); 7585 ftrace_destroy_function_files(tr);
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index 291a1bca5748..39fd77330aab 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -980,6 +980,7 @@ register_ftrace_function_probe(char *glob, struct trace_array *tr,
980extern int 980extern int
981unregister_ftrace_function_probe_func(char *glob, struct trace_array *tr, 981unregister_ftrace_function_probe_func(char *glob, struct trace_array *tr,
982 struct ftrace_probe_ops *ops); 982 struct ftrace_probe_ops *ops);
983extern void clear_ftrace_function_probes(struct trace_array *tr);
983 984
984int register_ftrace_command(struct ftrace_func_command *cmd); 985int register_ftrace_command(struct ftrace_func_command *cmd);
985int unregister_ftrace_command(struct ftrace_func_command *cmd); 986int unregister_ftrace_command(struct ftrace_func_command *cmd);
@@ -998,6 +999,10 @@ static inline __init int unregister_ftrace_command(char *cmd_name)
998{ 999{
999 return -EINVAL; 1000 return -EINVAL;
1000} 1001}
1002static inline void clear_ftrace_function_probes(struct trace_array *tr)
1003{
1004}
1005
1001/* 1006/*
1002 * The ops parameter passed in is usually undefined. 1007 * The ops parameter passed in is usually undefined.
1003 * This must be a macro. 1008 * This must be a macro.
diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
index 8485f6738a87..c129fca6ec99 100644
--- a/kernel/trace/trace_kprobe.c
+++ b/kernel/trace/trace_kprobe.c
@@ -1535,6 +1535,11 @@ static __init int kprobe_trace_self_tests_init(void)
1535 1535
1536end: 1536end:
1537 release_all_trace_kprobes(); 1537 release_all_trace_kprobes();
1538 /*
1539 * Wait for the optimizer work to finish. Otherwise it might fiddle
1540 * with probes in already freed __init text.
1541 */
1542 wait_for_kprobe_optimizer();
1538 if (warn) 1543 if (warn)
1539 pr_cont("NG: Some tests are failed. Please check them.\n"); 1544 pr_cont("NG: Some tests are failed. Please check them.\n");
1540 else 1545 else
diff --git a/net/9p/trans_xen.c b/net/9p/trans_xen.c
index 71e85643b3f9..6ad3e043c617 100644
--- a/net/9p/trans_xen.c
+++ b/net/9p/trans_xen.c
@@ -454,8 +454,8 @@ static int xen_9pfs_front_probe(struct xenbus_device *dev,
454 goto error_xenbus; 454 goto error_xenbus;
455 } 455 }
456 priv->tag = xenbus_read(xbt, dev->nodename, "tag", NULL); 456 priv->tag = xenbus_read(xbt, dev->nodename, "tag", NULL);
457 if (!priv->tag) { 457 if (IS_ERR(priv->tag)) {
458 ret = -EINVAL; 458 ret = PTR_ERR(priv->tag);
459 goto error_xenbus; 459 goto error_xenbus;
460 } 460 }
461 ret = xenbus_transaction_end(xbt, 0); 461 ret = xenbus_transaction_end(xbt, 0);
@@ -525,7 +525,7 @@ static struct xenbus_driver xen_9pfs_front_driver = {
525 .otherend_changed = xen_9pfs_front_changed, 525 .otherend_changed = xen_9pfs_front_changed,
526}; 526};
527 527
528int p9_trans_xen_init(void) 528static int p9_trans_xen_init(void)
529{ 529{
530 if (!xen_domain()) 530 if (!xen_domain())
531 return -ENODEV; 531 return -ENODEV;
@@ -537,7 +537,7 @@ int p9_trans_xen_init(void)
537} 537}
538module_init(p9_trans_xen_init); 538module_init(p9_trans_xen_init);
539 539
540void p9_trans_xen_exit(void) 540static void p9_trans_xen_exit(void)
541{ 541{
542 v9fs_unregister_trans(&p9_xen_trans); 542 v9fs_unregister_trans(&p9_xen_trans);
543 return xenbus_unregister_driver(&xen_9pfs_front_driver); 543 return xenbus_unregister_driver(&xen_9pfs_front_driver);
diff --git a/net/bridge/br_stp_if.c b/net/bridge/br_stp_if.c
index a05027027513..4efd5d54498a 100644
--- a/net/bridge/br_stp_if.c
+++ b/net/bridge/br_stp_if.c
@@ -173,6 +173,7 @@ static void br_stp_start(struct net_bridge *br)
173 br_debug(br, "using kernel STP\n"); 173 br_debug(br, "using kernel STP\n");
174 174
175 /* To start timers on any ports left in blocking */ 175 /* To start timers on any ports left in blocking */
176 mod_timer(&br->hello_timer, jiffies + br->hello_time);
176 br_port_state_selection(br); 177 br_port_state_selection(br);
177 } 178 }
178 179
diff --git a/net/bridge/br_stp_timer.c b/net/bridge/br_stp_timer.c
index c98b3e5c140a..60b6fe277a8b 100644
--- a/net/bridge/br_stp_timer.c
+++ b/net/bridge/br_stp_timer.c
@@ -40,7 +40,7 @@ static void br_hello_timer_expired(unsigned long arg)
40 if (br->dev->flags & IFF_UP) { 40 if (br->dev->flags & IFF_UP) {
41 br_config_bpdu_generation(br); 41 br_config_bpdu_generation(br);
42 42
43 if (br->stp_enabled != BR_USER_STP) 43 if (br->stp_enabled == BR_KERNEL_STP)
44 mod_timer(&br->hello_timer, 44 mod_timer(&br->hello_timer,
45 round_jiffies(jiffies + br->hello_time)); 45 round_jiffies(jiffies + br->hello_time));
46 } 46 }
diff --git a/net/bridge/netfilter/ebt_arpreply.c b/net/bridge/netfilter/ebt_arpreply.c
index 5929309beaa1..db85230e49c3 100644
--- a/net/bridge/netfilter/ebt_arpreply.c
+++ b/net/bridge/netfilter/ebt_arpreply.c
@@ -68,6 +68,9 @@ static int ebt_arpreply_tg_check(const struct xt_tgchk_param *par)
68 if (e->ethproto != htons(ETH_P_ARP) || 68 if (e->ethproto != htons(ETH_P_ARP) ||
69 e->invflags & EBT_IPROTO) 69 e->invflags & EBT_IPROTO)
70 return -EINVAL; 70 return -EINVAL;
71 if (ebt_invalid_target(info->target))
72 return -EINVAL;
73
71 return 0; 74 return 0;
72} 75}
73 76
diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
index 9ec0c9f908fa..9c6e619f452b 100644
--- a/net/bridge/netfilter/ebtables.c
+++ b/net/bridge/netfilter/ebtables.c
@@ -1373,7 +1373,8 @@ static inline int ebt_obj_to_user(char __user *um, const char *_name,
1373 strlcpy(name, _name, sizeof(name)); 1373 strlcpy(name, _name, sizeof(name));
1374 if (copy_to_user(um, name, EBT_FUNCTION_MAXNAMELEN) || 1374 if (copy_to_user(um, name, EBT_FUNCTION_MAXNAMELEN) ||
1375 put_user(datasize, (int __user *)(um + EBT_FUNCTION_MAXNAMELEN)) || 1375 put_user(datasize, (int __user *)(um + EBT_FUNCTION_MAXNAMELEN)) ||
1376 xt_data_to_user(um + entrysize, data, usersize, datasize)) 1376 xt_data_to_user(um + entrysize, data, usersize, datasize,
1377 XT_ALIGN(datasize)))
1377 return -EFAULT; 1378 return -EFAULT;
1378 1379
1379 return 0; 1380 return 0;
@@ -1658,7 +1659,8 @@ static int compat_match_to_user(struct ebt_entry_match *m, void __user **dstptr,
1658 if (match->compat_to_user(cm->data, m->data)) 1659 if (match->compat_to_user(cm->data, m->data))
1659 return -EFAULT; 1660 return -EFAULT;
1660 } else { 1661 } else {
1661 if (xt_data_to_user(cm->data, m->data, match->usersize, msize)) 1662 if (xt_data_to_user(cm->data, m->data, match->usersize, msize,
1663 COMPAT_XT_ALIGN(msize)))
1662 return -EFAULT; 1664 return -EFAULT;
1663 } 1665 }
1664 1666
@@ -1687,7 +1689,8 @@ static int compat_target_to_user(struct ebt_entry_target *t,
1687 if (target->compat_to_user(cm->data, t->data)) 1689 if (target->compat_to_user(cm->data, t->data))
1688 return -EFAULT; 1690 return -EFAULT;
1689 } else { 1691 } else {
1690 if (xt_data_to_user(cm->data, t->data, target->usersize, tsize)) 1692 if (xt_data_to_user(cm->data, t->data, target->usersize, tsize,
1693 COMPAT_XT_ALIGN(tsize)))
1691 return -EFAULT; 1694 return -EFAULT;
1692 } 1695 }
1693 1696
diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c
index d54345a06f72..ae96e6f3e0cb 100644
--- a/net/ipv4/arp.c
+++ b/net/ipv4/arp.c
@@ -641,6 +641,32 @@ void arp_xmit(struct sk_buff *skb)
641} 641}
642EXPORT_SYMBOL(arp_xmit); 642EXPORT_SYMBOL(arp_xmit);
643 643
644static bool arp_is_garp(struct net *net, struct net_device *dev,
645 int *addr_type, __be16 ar_op,
646 __be32 sip, __be32 tip,
647 unsigned char *sha, unsigned char *tha)
648{
649 bool is_garp = tip == sip;
650
651 /* Gratuitous ARP _replies_ also require target hwaddr to be
652 * the same as source.
653 */
654 if (is_garp && ar_op == htons(ARPOP_REPLY))
655 is_garp =
656 /* IPv4 over IEEE 1394 doesn't provide target
657 * hardware address field in its ARP payload.
658 */
659 tha &&
660 !memcmp(tha, sha, dev->addr_len);
661
662 if (is_garp) {
663 *addr_type = inet_addr_type_dev_table(net, dev, sip);
664 if (*addr_type != RTN_UNICAST)
665 is_garp = false;
666 }
667 return is_garp;
668}
669
644/* 670/*
645 * Process an arp request. 671 * Process an arp request.
646 */ 672 */
@@ -837,29 +863,25 @@ static int arp_process(struct net *net, struct sock *sk, struct sk_buff *skb)
837 863
838 n = __neigh_lookup(&arp_tbl, &sip, dev, 0); 864 n = __neigh_lookup(&arp_tbl, &sip, dev, 0);
839 865
840 if (IN_DEV_ARP_ACCEPT(in_dev)) { 866 if (n || IN_DEV_ARP_ACCEPT(in_dev)) {
841 unsigned int addr_type = inet_addr_type_dev_table(net, dev, sip); 867 addr_type = -1;
868 is_garp = arp_is_garp(net, dev, &addr_type, arp->ar_op,
869 sip, tip, sha, tha);
870 }
842 871
872 if (IN_DEV_ARP_ACCEPT(in_dev)) {
843 /* Unsolicited ARP is not accepted by default. 873 /* Unsolicited ARP is not accepted by default.
844 It is possible, that this option should be enabled for some 874 It is possible, that this option should be enabled for some
845 devices (strip is candidate) 875 devices (strip is candidate)
846 */ 876 */
847 is_garp = tip == sip && addr_type == RTN_UNICAST;
848
849 /* Unsolicited ARP _replies_ also require target hwaddr to be
850 * the same as source.
851 */
852 if (is_garp && arp->ar_op == htons(ARPOP_REPLY))
853 is_garp =
854 /* IPv4 over IEEE 1394 doesn't provide target
855 * hardware address field in its ARP payload.
856 */
857 tha &&
858 !memcmp(tha, sha, dev->addr_len);
859
860 if (!n && 877 if (!n &&
861 ((arp->ar_op == htons(ARPOP_REPLY) && 878 (is_garp ||
862 addr_type == RTN_UNICAST) || is_garp)) 879 (arp->ar_op == htons(ARPOP_REPLY) &&
880 (addr_type == RTN_UNICAST ||
881 (addr_type < 0 &&
882 /* postpone calculation to as late as possible */
883 inet_addr_type_dev_table(net, dev, sip) ==
884 RTN_UNICAST)))))
863 n = __neigh_lookup(&arp_tbl, &sip, dev, 1); 885 n = __neigh_lookup(&arp_tbl, &sip, dev, 1);
864 } 886 }
865 887
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 9a56077eafea..aaf663a1e571 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -2320,6 +2320,10 @@ int tcp_disconnect(struct sock *sk, int flags)
2320 tcp_set_ca_state(sk, TCP_CA_Open); 2320 tcp_set_ca_state(sk, TCP_CA_Open);
2321 tcp_clear_retrans(tp); 2321 tcp_clear_retrans(tp);
2322 inet_csk_delack_init(sk); 2322 inet_csk_delack_init(sk);
2323 /* Initialize rcv_mss to TCP_MIN_MSS to avoid division by 0
2324 * issue in __tcp_select_window()
2325 */
2326 icsk->icsk_ack.rcv_mss = TCP_MIN_MSS;
2323 tcp_init_send_head(sk); 2327 tcp_init_send_head(sk);
2324 memset(&tp->rx_opt, 0, sizeof(tp->rx_opt)); 2328 memset(&tp->rx_opt, 0, sizeof(tp->rx_opt));
2325 __sk_dst_reset(sk); 2329 __sk_dst_reset(sk);
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index d4a31becbd25..bf8a58a1c32d 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -1466,6 +1466,11 @@ alloc_new_skb:
1466 */ 1466 */
1467 alloclen += sizeof(struct frag_hdr); 1467 alloclen += sizeof(struct frag_hdr);
1468 1468
1469 copy = datalen - transhdrlen - fraggap;
1470 if (copy < 0) {
1471 err = -EINVAL;
1472 goto error;
1473 }
1469 if (transhdrlen) { 1474 if (transhdrlen) {
1470 skb = sock_alloc_send_skb(sk, 1475 skb = sock_alloc_send_skb(sk,
1471 alloclen + hh_len, 1476 alloclen + hh_len,
@@ -1515,13 +1520,9 @@ alloc_new_skb:
1515 data += fraggap; 1520 data += fraggap;
1516 pskb_trim_unique(skb_prev, maxfraglen); 1521 pskb_trim_unique(skb_prev, maxfraglen);
1517 } 1522 }
1518 copy = datalen - transhdrlen - fraggap; 1523 if (copy > 0 &&
1519 1524 getfrag(from, data + transhdrlen, offset,
1520 if (copy < 0) { 1525 copy, fraggap, skb) < 0) {
1521 err = -EINVAL;
1522 kfree_skb(skb);
1523 goto error;
1524 } else if (copy > 0 && getfrag(from, data + transhdrlen, offset, copy, fraggap, skb) < 0) {
1525 err = -EFAULT; 1526 err = -EFAULT;
1526 kfree_skb(skb); 1527 kfree_skb(skb);
1527 goto error; 1528 goto error;
diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
index d2d7bdf1d510..ad99c1ceea6f 100644
--- a/net/netfilter/ipvs/ip_vs_core.c
+++ b/net/netfilter/ipvs/ip_vs_core.c
@@ -849,10 +849,8 @@ static int handle_response_icmp(int af, struct sk_buff *skb,
849{ 849{
850 unsigned int verdict = NF_DROP; 850 unsigned int verdict = NF_DROP;
851 851
852 if (IP_VS_FWD_METHOD(cp) != 0) { 852 if (IP_VS_FWD_METHOD(cp) != IP_VS_CONN_F_MASQ)
853 pr_err("shouldn't reach here, because the box is on the " 853 goto ignore_cp;
854 "half connection in the tun/dr module.\n");
855 }
856 854
857 /* Ensure the checksum is correct */ 855 /* Ensure the checksum is correct */
858 if (!skb_csum_unnecessary(skb) && ip_vs_checksum_complete(skb, ihl)) { 856 if (!skb_csum_unnecessary(skb) && ip_vs_checksum_complete(skb, ihl)) {
@@ -886,6 +884,8 @@ static int handle_response_icmp(int af, struct sk_buff *skb,
886 ip_vs_notrack(skb); 884 ip_vs_notrack(skb);
887 else 885 else
888 ip_vs_update_conntrack(skb, cp, 0); 886 ip_vs_update_conntrack(skb, cp, 0);
887
888ignore_cp:
889 verdict = NF_ACCEPT; 889 verdict = NF_ACCEPT;
890 890
891out: 891out:
@@ -1385,8 +1385,11 @@ ip_vs_out(struct netns_ipvs *ipvs, unsigned int hooknum, struct sk_buff *skb, in
1385 */ 1385 */
1386 cp = pp->conn_out_get(ipvs, af, skb, &iph); 1386 cp = pp->conn_out_get(ipvs, af, skb, &iph);
1387 1387
1388 if (likely(cp)) 1388 if (likely(cp)) {
1389 if (IP_VS_FWD_METHOD(cp) != IP_VS_CONN_F_MASQ)
1390 goto ignore_cp;
1389 return handle_response(af, skb, pd, cp, &iph, hooknum); 1391 return handle_response(af, skb, pd, cp, &iph, hooknum);
1392 }
1390 1393
1391 /* Check for real-server-started requests */ 1394 /* Check for real-server-started requests */
1392 if (atomic_read(&ipvs->conn_out_counter)) { 1395 if (atomic_read(&ipvs->conn_out_counter)) {
@@ -1444,9 +1447,15 @@ ip_vs_out(struct netns_ipvs *ipvs, unsigned int hooknum, struct sk_buff *skb, in
1444 } 1447 }
1445 } 1448 }
1446 } 1449 }
1450
1451out:
1447 IP_VS_DBG_PKT(12, af, pp, skb, iph.off, 1452 IP_VS_DBG_PKT(12, af, pp, skb, iph.off,
1448 "ip_vs_out: packet continues traversal as normal"); 1453 "ip_vs_out: packet continues traversal as normal");
1449 return NF_ACCEPT; 1454 return NF_ACCEPT;
1455
1456ignore_cp:
1457 __ip_vs_conn_put(cp);
1458 goto out;
1450} 1459}
1451 1460
1452/* 1461/*
diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c
index 3a60efa7799b..7f6100ca63be 100644
--- a/net/netfilter/nf_conntrack_helper.c
+++ b/net/netfilter/nf_conntrack_helper.c
@@ -174,6 +174,10 @@ nf_conntrack_helper_try_module_get(const char *name, u16 l3num, u8 protonum)
174#endif 174#endif
175 if (h != NULL && !try_module_get(h->me)) 175 if (h != NULL && !try_module_get(h->me))
176 h = NULL; 176 h = NULL;
177 if (h != NULL && !refcount_inc_not_zero(&h->refcnt)) {
178 module_put(h->me);
179 h = NULL;
180 }
177 181
178 rcu_read_unlock(); 182 rcu_read_unlock();
179 183
@@ -181,6 +185,13 @@ nf_conntrack_helper_try_module_get(const char *name, u16 l3num, u8 protonum)
181} 185}
182EXPORT_SYMBOL_GPL(nf_conntrack_helper_try_module_get); 186EXPORT_SYMBOL_GPL(nf_conntrack_helper_try_module_get);
183 187
188void nf_conntrack_helper_put(struct nf_conntrack_helper *helper)
189{
190 refcount_dec(&helper->refcnt);
191 module_put(helper->me);
192}
193EXPORT_SYMBOL_GPL(nf_conntrack_helper_put);
194
184struct nf_conn_help * 195struct nf_conn_help *
185nf_ct_helper_ext_add(struct nf_conn *ct, 196nf_ct_helper_ext_add(struct nf_conn *ct,
186 struct nf_conntrack_helper *helper, gfp_t gfp) 197 struct nf_conntrack_helper *helper, gfp_t gfp)
@@ -417,6 +428,7 @@ int nf_conntrack_helper_register(struct nf_conntrack_helper *me)
417 } 428 }
418 } 429 }
419 } 430 }
431 refcount_set(&me->refcnt, 1);
420 hlist_add_head_rcu(&me->hnode, &nf_ct_helper_hash[h]); 432 hlist_add_head_rcu(&me->hnode, &nf_ct_helper_hash[h]);
421 nf_ct_helper_count++; 433 nf_ct_helper_count++;
422out: 434out:
diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c
index dcf561b5c97a..9799a50bc604 100644
--- a/net/netfilter/nf_conntrack_netlink.c
+++ b/net/netfilter/nf_conntrack_netlink.c
@@ -45,6 +45,8 @@
45#include <net/netfilter/nf_conntrack_zones.h> 45#include <net/netfilter/nf_conntrack_zones.h>
46#include <net/netfilter/nf_conntrack_timestamp.h> 46#include <net/netfilter/nf_conntrack_timestamp.h>
47#include <net/netfilter/nf_conntrack_labels.h> 47#include <net/netfilter/nf_conntrack_labels.h>
48#include <net/netfilter/nf_conntrack_seqadj.h>
49#include <net/netfilter/nf_conntrack_synproxy.h>
48#ifdef CONFIG_NF_NAT_NEEDED 50#ifdef CONFIG_NF_NAT_NEEDED
49#include <net/netfilter/nf_nat_core.h> 51#include <net/netfilter/nf_nat_core.h>
50#include <net/netfilter/nf_nat_l4proto.h> 52#include <net/netfilter/nf_nat_l4proto.h>
@@ -1007,9 +1009,8 @@ static const struct nla_policy tuple_nla_policy[CTA_TUPLE_MAX+1] = {
1007 1009
1008static int 1010static int
1009ctnetlink_parse_tuple(const struct nlattr * const cda[], 1011ctnetlink_parse_tuple(const struct nlattr * const cda[],
1010 struct nf_conntrack_tuple *tuple, 1012 struct nf_conntrack_tuple *tuple, u32 type,
1011 enum ctattr_type type, u_int8_t l3num, 1013 u_int8_t l3num, struct nf_conntrack_zone *zone)
1012 struct nf_conntrack_zone *zone)
1013{ 1014{
1014 struct nlattr *tb[CTA_TUPLE_MAX+1]; 1015 struct nlattr *tb[CTA_TUPLE_MAX+1];
1015 int err; 1016 int err;
@@ -1828,6 +1829,8 @@ ctnetlink_create_conntrack(struct net *net,
1828 nf_ct_tstamp_ext_add(ct, GFP_ATOMIC); 1829 nf_ct_tstamp_ext_add(ct, GFP_ATOMIC);
1829 nf_ct_ecache_ext_add(ct, 0, 0, GFP_ATOMIC); 1830 nf_ct_ecache_ext_add(ct, 0, 0, GFP_ATOMIC);
1830 nf_ct_labels_ext_add(ct); 1831 nf_ct_labels_ext_add(ct);
1832 nfct_seqadj_ext_add(ct);
1833 nfct_synproxy_ext_add(ct);
1831 1834
1832 /* we must add conntrack extensions before confirmation. */ 1835 /* we must add conntrack extensions before confirmation. */
1833 ct->status |= IPS_CONFIRMED; 1836 ct->status |= IPS_CONFIRMED;
@@ -2447,7 +2450,7 @@ static struct nfnl_ct_hook ctnetlink_glue_hook = {
2447 2450
2448static int ctnetlink_exp_dump_tuple(struct sk_buff *skb, 2451static int ctnetlink_exp_dump_tuple(struct sk_buff *skb,
2449 const struct nf_conntrack_tuple *tuple, 2452 const struct nf_conntrack_tuple *tuple,
2450 enum ctattr_expect type) 2453 u32 type)
2451{ 2454{
2452 struct nlattr *nest_parms; 2455 struct nlattr *nest_parms;
2453 2456
diff --git a/net/netfilter/nf_nat_core.c b/net/netfilter/nf_nat_core.c
index b48d6b5aae8a..ef0be325a0c6 100644
--- a/net/netfilter/nf_nat_core.c
+++ b/net/netfilter/nf_nat_core.c
@@ -409,6 +409,10 @@ nf_nat_setup_info(struct nf_conn *ct,
409{ 409{
410 struct nf_conntrack_tuple curr_tuple, new_tuple; 410 struct nf_conntrack_tuple curr_tuple, new_tuple;
411 411
412 /* Can't setup nat info for confirmed ct. */
413 if (nf_ct_is_confirmed(ct))
414 return NF_ACCEPT;
415
412 NF_CT_ASSERT(maniptype == NF_NAT_MANIP_SRC || 416 NF_CT_ASSERT(maniptype == NF_NAT_MANIP_SRC ||
413 maniptype == NF_NAT_MANIP_DST); 417 maniptype == NF_NAT_MANIP_DST);
414 BUG_ON(nf_nat_initialized(ct, maniptype)); 418 BUG_ON(nf_nat_initialized(ct, maniptype));
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index 559225029740..da314be0c048 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -3367,35 +3367,50 @@ static int nf_tables_dump_setelem(const struct nft_ctx *ctx,
3367 return nf_tables_fill_setelem(args->skb, set, elem); 3367 return nf_tables_fill_setelem(args->skb, set, elem);
3368} 3368}
3369 3369
3370struct nft_set_dump_ctx {
3371 const struct nft_set *set;
3372 struct nft_ctx ctx;
3373};
3374
3370static int nf_tables_dump_set(struct sk_buff *skb, struct netlink_callback *cb) 3375static int nf_tables_dump_set(struct sk_buff *skb, struct netlink_callback *cb)
3371{ 3376{
3377 struct nft_set_dump_ctx *dump_ctx = cb->data;
3372 struct net *net = sock_net(skb->sk); 3378 struct net *net = sock_net(skb->sk);
3373 u8 genmask = nft_genmask_cur(net); 3379 struct nft_af_info *afi;
3380 struct nft_table *table;
3374 struct nft_set *set; 3381 struct nft_set *set;
3375 struct nft_set_dump_args args; 3382 struct nft_set_dump_args args;
3376 struct nft_ctx ctx; 3383 bool set_found = false;
3377 struct nlattr *nla[NFTA_SET_ELEM_LIST_MAX + 1];
3378 struct nfgenmsg *nfmsg; 3384 struct nfgenmsg *nfmsg;
3379 struct nlmsghdr *nlh; 3385 struct nlmsghdr *nlh;
3380 struct nlattr *nest; 3386 struct nlattr *nest;
3381 u32 portid, seq; 3387 u32 portid, seq;
3382 int event, err; 3388 int event;
3383 3389
3384 err = nlmsg_parse(cb->nlh, sizeof(struct nfgenmsg), nla, 3390 rcu_read_lock();
3385 NFTA_SET_ELEM_LIST_MAX, nft_set_elem_list_policy, 3391 list_for_each_entry_rcu(afi, &net->nft.af_info, list) {
3386 NULL); 3392 if (afi != dump_ctx->ctx.afi)
3387 if (err < 0) 3393 continue;
3388 return err;
3389 3394
3390 err = nft_ctx_init_from_elemattr(&ctx, net, cb->skb, cb->nlh, 3395 list_for_each_entry_rcu(table, &afi->tables, list) {
3391 (void *)nla, genmask); 3396 if (table != dump_ctx->ctx.table)
3392 if (err < 0) 3397 continue;
3393 return err;
3394 3398
3395 set = nf_tables_set_lookup(ctx.table, nla[NFTA_SET_ELEM_LIST_SET], 3399 list_for_each_entry_rcu(set, &table->sets, list) {
3396 genmask); 3400 if (set == dump_ctx->set) {
3397 if (IS_ERR(set)) 3401 set_found = true;
3398 return PTR_ERR(set); 3402 break;
3403 }
3404 }
3405 break;
3406 }
3407 break;
3408 }
3409
3410 if (!set_found) {
3411 rcu_read_unlock();
3412 return -ENOENT;
3413 }
3399 3414
3400 event = nfnl_msg_type(NFNL_SUBSYS_NFTABLES, NFT_MSG_NEWSETELEM); 3415 event = nfnl_msg_type(NFNL_SUBSYS_NFTABLES, NFT_MSG_NEWSETELEM);
3401 portid = NETLINK_CB(cb->skb).portid; 3416 portid = NETLINK_CB(cb->skb).portid;
@@ -3407,11 +3422,11 @@ static int nf_tables_dump_set(struct sk_buff *skb, struct netlink_callback *cb)
3407 goto nla_put_failure; 3422 goto nla_put_failure;
3408 3423
3409 nfmsg = nlmsg_data(nlh); 3424 nfmsg = nlmsg_data(nlh);
3410 nfmsg->nfgen_family = ctx.afi->family; 3425 nfmsg->nfgen_family = afi->family;
3411 nfmsg->version = NFNETLINK_V0; 3426 nfmsg->version = NFNETLINK_V0;
3412 nfmsg->res_id = htons(ctx.net->nft.base_seq & 0xffff); 3427 nfmsg->res_id = htons(net->nft.base_seq & 0xffff);
3413 3428
3414 if (nla_put_string(skb, NFTA_SET_ELEM_LIST_TABLE, ctx.table->name)) 3429 if (nla_put_string(skb, NFTA_SET_ELEM_LIST_TABLE, table->name))
3415 goto nla_put_failure; 3430 goto nla_put_failure;
3416 if (nla_put_string(skb, NFTA_SET_ELEM_LIST_SET, set->name)) 3431 if (nla_put_string(skb, NFTA_SET_ELEM_LIST_SET, set->name))
3417 goto nla_put_failure; 3432 goto nla_put_failure;
@@ -3422,12 +3437,13 @@ static int nf_tables_dump_set(struct sk_buff *skb, struct netlink_callback *cb)
3422 3437
3423 args.cb = cb; 3438 args.cb = cb;
3424 args.skb = skb; 3439 args.skb = skb;
3425 args.iter.genmask = nft_genmask_cur(ctx.net); 3440 args.iter.genmask = nft_genmask_cur(net);
3426 args.iter.skip = cb->args[0]; 3441 args.iter.skip = cb->args[0];
3427 args.iter.count = 0; 3442 args.iter.count = 0;
3428 args.iter.err = 0; 3443 args.iter.err = 0;
3429 args.iter.fn = nf_tables_dump_setelem; 3444 args.iter.fn = nf_tables_dump_setelem;
3430 set->ops->walk(&ctx, set, &args.iter); 3445 set->ops->walk(&dump_ctx->ctx, set, &args.iter);
3446 rcu_read_unlock();
3431 3447
3432 nla_nest_end(skb, nest); 3448 nla_nest_end(skb, nest);
3433 nlmsg_end(skb, nlh); 3449 nlmsg_end(skb, nlh);
@@ -3441,9 +3457,16 @@ static int nf_tables_dump_set(struct sk_buff *skb, struct netlink_callback *cb)
3441 return skb->len; 3457 return skb->len;
3442 3458
3443nla_put_failure: 3459nla_put_failure:
3460 rcu_read_unlock();
3444 return -ENOSPC; 3461 return -ENOSPC;
3445} 3462}
3446 3463
3464static int nf_tables_dump_set_done(struct netlink_callback *cb)
3465{
3466 kfree(cb->data);
3467 return 0;
3468}
3469
3447static int nf_tables_getsetelem(struct net *net, struct sock *nlsk, 3470static int nf_tables_getsetelem(struct net *net, struct sock *nlsk,
3448 struct sk_buff *skb, const struct nlmsghdr *nlh, 3471 struct sk_buff *skb, const struct nlmsghdr *nlh,
3449 const struct nlattr * const nla[]) 3472 const struct nlattr * const nla[])
@@ -3465,7 +3488,18 @@ static int nf_tables_getsetelem(struct net *net, struct sock *nlsk,
3465 if (nlh->nlmsg_flags & NLM_F_DUMP) { 3488 if (nlh->nlmsg_flags & NLM_F_DUMP) {
3466 struct netlink_dump_control c = { 3489 struct netlink_dump_control c = {
3467 .dump = nf_tables_dump_set, 3490 .dump = nf_tables_dump_set,
3491 .done = nf_tables_dump_set_done,
3468 }; 3492 };
3493 struct nft_set_dump_ctx *dump_ctx;
3494
3495 dump_ctx = kmalloc(sizeof(*dump_ctx), GFP_KERNEL);
3496 if (!dump_ctx)
3497 return -ENOMEM;
3498
3499 dump_ctx->set = set;
3500 dump_ctx->ctx = ctx;
3501
3502 c.data = dump_ctx;
3469 return netlink_dump_start(nlsk, skb, nlh, &c); 3503 return netlink_dump_start(nlsk, skb, nlh, &c);
3470 } 3504 }
3471 return -EOPNOTSUPP; 3505 return -EOPNOTSUPP;
@@ -3593,9 +3627,9 @@ void nft_set_elem_destroy(const struct nft_set *set, void *elem,
3593{ 3627{
3594 struct nft_set_ext *ext = nft_set_elem_ext(set, elem); 3628 struct nft_set_ext *ext = nft_set_elem_ext(set, elem);
3595 3629
3596 nft_data_uninit(nft_set_ext_key(ext), NFT_DATA_VALUE); 3630 nft_data_release(nft_set_ext_key(ext), NFT_DATA_VALUE);
3597 if (nft_set_ext_exists(ext, NFT_SET_EXT_DATA)) 3631 if (nft_set_ext_exists(ext, NFT_SET_EXT_DATA))
3598 nft_data_uninit(nft_set_ext_data(ext), set->dtype); 3632 nft_data_release(nft_set_ext_data(ext), set->dtype);
3599 if (destroy_expr && nft_set_ext_exists(ext, NFT_SET_EXT_EXPR)) 3633 if (destroy_expr && nft_set_ext_exists(ext, NFT_SET_EXT_EXPR))
3600 nf_tables_expr_destroy(NULL, nft_set_ext_expr(ext)); 3634 nf_tables_expr_destroy(NULL, nft_set_ext_expr(ext));
3601 if (nft_set_ext_exists(ext, NFT_SET_EXT_OBJREF)) 3635 if (nft_set_ext_exists(ext, NFT_SET_EXT_OBJREF))
@@ -3604,6 +3638,18 @@ void nft_set_elem_destroy(const struct nft_set *set, void *elem,
3604} 3638}
3605EXPORT_SYMBOL_GPL(nft_set_elem_destroy); 3639EXPORT_SYMBOL_GPL(nft_set_elem_destroy);
3606 3640
3641/* Only called from commit path, nft_set_elem_deactivate() already deals with
3642 * the refcounting from the preparation phase.
3643 */
3644static void nf_tables_set_elem_destroy(const struct nft_set *set, void *elem)
3645{
3646 struct nft_set_ext *ext = nft_set_elem_ext(set, elem);
3647
3648 if (nft_set_ext_exists(ext, NFT_SET_EXT_EXPR))
3649 nf_tables_expr_destroy(NULL, nft_set_ext_expr(ext));
3650 kfree(elem);
3651}
3652
3607static int nft_setelem_parse_flags(const struct nft_set *set, 3653static int nft_setelem_parse_flags(const struct nft_set *set,
3608 const struct nlattr *attr, u32 *flags) 3654 const struct nlattr *attr, u32 *flags)
3609{ 3655{
@@ -3815,9 +3861,9 @@ err4:
3815 kfree(elem.priv); 3861 kfree(elem.priv);
3816err3: 3862err3:
3817 if (nla[NFTA_SET_ELEM_DATA] != NULL) 3863 if (nla[NFTA_SET_ELEM_DATA] != NULL)
3818 nft_data_uninit(&data, d2.type); 3864 nft_data_release(&data, d2.type);
3819err2: 3865err2:
3820 nft_data_uninit(&elem.key.val, d1.type); 3866 nft_data_release(&elem.key.val, d1.type);
3821err1: 3867err1:
3822 return err; 3868 return err;
3823} 3869}
@@ -3862,6 +3908,53 @@ static int nf_tables_newsetelem(struct net *net, struct sock *nlsk,
3862 return err; 3908 return err;
3863} 3909}
3864 3910
3911/**
3912 * nft_data_hold - hold a nft_data item
3913 *
3914 * @data: struct nft_data to release
3915 * @type: type of data
3916 *
3917 * Hold a nft_data item. NFT_DATA_VALUE types can be silently discarded,
3918 * NFT_DATA_VERDICT bumps the reference to chains in case of NFT_JUMP and
3919 * NFT_GOTO verdicts. This function must be called on active data objects
3920 * from the second phase of the commit protocol.
3921 */
3922static void nft_data_hold(const struct nft_data *data, enum nft_data_types type)
3923{
3924 if (type == NFT_DATA_VERDICT) {
3925 switch (data->verdict.code) {
3926 case NFT_JUMP:
3927 case NFT_GOTO:
3928 data->verdict.chain->use++;
3929 break;
3930 }
3931 }
3932}
3933
3934static void nft_set_elem_activate(const struct net *net,
3935 const struct nft_set *set,
3936 struct nft_set_elem *elem)
3937{
3938 const struct nft_set_ext *ext = nft_set_elem_ext(set, elem->priv);
3939
3940 if (nft_set_ext_exists(ext, NFT_SET_EXT_DATA))
3941 nft_data_hold(nft_set_ext_data(ext), set->dtype);
3942 if (nft_set_ext_exists(ext, NFT_SET_EXT_OBJREF))
3943 (*nft_set_ext_obj(ext))->use++;
3944}
3945
3946static void nft_set_elem_deactivate(const struct net *net,
3947 const struct nft_set *set,
3948 struct nft_set_elem *elem)
3949{
3950 const struct nft_set_ext *ext = nft_set_elem_ext(set, elem->priv);
3951
3952 if (nft_set_ext_exists(ext, NFT_SET_EXT_DATA))
3953 nft_data_release(nft_set_ext_data(ext), set->dtype);
3954 if (nft_set_ext_exists(ext, NFT_SET_EXT_OBJREF))
3955 (*nft_set_ext_obj(ext))->use--;
3956}
3957
3865static int nft_del_setelem(struct nft_ctx *ctx, struct nft_set *set, 3958static int nft_del_setelem(struct nft_ctx *ctx, struct nft_set *set,
3866 const struct nlattr *attr) 3959 const struct nlattr *attr)
3867{ 3960{
@@ -3927,6 +4020,8 @@ static int nft_del_setelem(struct nft_ctx *ctx, struct nft_set *set,
3927 kfree(elem.priv); 4020 kfree(elem.priv);
3928 elem.priv = priv; 4021 elem.priv = priv;
3929 4022
4023 nft_set_elem_deactivate(ctx->net, set, &elem);
4024
3930 nft_trans_elem(trans) = elem; 4025 nft_trans_elem(trans) = elem;
3931 list_add_tail(&trans->list, &ctx->net->nft.commit_list); 4026 list_add_tail(&trans->list, &ctx->net->nft.commit_list);
3932 return 0; 4027 return 0;
@@ -3936,7 +4031,7 @@ err4:
3936err3: 4031err3:
3937 kfree(elem.priv); 4032 kfree(elem.priv);
3938err2: 4033err2:
3939 nft_data_uninit(&elem.key.val, desc.type); 4034 nft_data_release(&elem.key.val, desc.type);
3940err1: 4035err1:
3941 return err; 4036 return err;
3942} 4037}
@@ -4743,8 +4838,8 @@ static void nf_tables_commit_release(struct nft_trans *trans)
4743 nft_set_destroy(nft_trans_set(trans)); 4838 nft_set_destroy(nft_trans_set(trans));
4744 break; 4839 break;
4745 case NFT_MSG_DELSETELEM: 4840 case NFT_MSG_DELSETELEM:
4746 nft_set_elem_destroy(nft_trans_elem_set(trans), 4841 nf_tables_set_elem_destroy(nft_trans_elem_set(trans),
4747 nft_trans_elem(trans).priv, true); 4842 nft_trans_elem(trans).priv);
4748 break; 4843 break;
4749 case NFT_MSG_DELOBJ: 4844 case NFT_MSG_DELOBJ:
4750 nft_obj_destroy(nft_trans_obj(trans)); 4845 nft_obj_destroy(nft_trans_obj(trans));
@@ -4979,6 +5074,7 @@ static int nf_tables_abort(struct net *net, struct sk_buff *skb)
4979 case NFT_MSG_DELSETELEM: 5074 case NFT_MSG_DELSETELEM:
4980 te = (struct nft_trans_elem *)trans->data; 5075 te = (struct nft_trans_elem *)trans->data;
4981 5076
5077 nft_set_elem_activate(net, te->set, &te->elem);
4982 te->set->ops->activate(net, te->set, &te->elem); 5078 te->set->ops->activate(net, te->set, &te->elem);
4983 te->set->ndeact--; 5079 te->set->ndeact--;
4984 5080
@@ -5464,7 +5560,7 @@ int nft_data_init(const struct nft_ctx *ctx,
5464EXPORT_SYMBOL_GPL(nft_data_init); 5560EXPORT_SYMBOL_GPL(nft_data_init);
5465 5561
5466/** 5562/**
5467 * nft_data_uninit - release a nft_data item 5563 * nft_data_release - release a nft_data item
5468 * 5564 *
5469 * @data: struct nft_data to release 5565 * @data: struct nft_data to release
5470 * @type: type of data 5566 * @type: type of data
@@ -5472,7 +5568,7 @@ EXPORT_SYMBOL_GPL(nft_data_init);
5472 * Release a nft_data item. NFT_DATA_VALUE types can be silently discarded, 5568 * Release a nft_data item. NFT_DATA_VALUE types can be silently discarded,
5473 * all others need to be released by calling this function. 5569 * all others need to be released by calling this function.
5474 */ 5570 */
5475void nft_data_uninit(const struct nft_data *data, enum nft_data_types type) 5571void nft_data_release(const struct nft_data *data, enum nft_data_types type)
5476{ 5572{
5477 if (type < NFT_DATA_VERDICT) 5573 if (type < NFT_DATA_VERDICT)
5478 return; 5574 return;
@@ -5483,7 +5579,7 @@ void nft_data_uninit(const struct nft_data *data, enum nft_data_types type)
5483 WARN_ON(1); 5579 WARN_ON(1);
5484 } 5580 }
5485} 5581}
5486EXPORT_SYMBOL_GPL(nft_data_uninit); 5582EXPORT_SYMBOL_GPL(nft_data_release);
5487 5583
5488int nft_data_dump(struct sk_buff *skb, int attr, const struct nft_data *data, 5584int nft_data_dump(struct sk_buff *skb, int attr, const struct nft_data *data,
5489 enum nft_data_types type, unsigned int len) 5585 enum nft_data_types type, unsigned int len)
diff --git a/net/netfilter/nfnetlink_cthelper.c b/net/netfilter/nfnetlink_cthelper.c
index 950bf6eadc65..be678a323598 100644
--- a/net/netfilter/nfnetlink_cthelper.c
+++ b/net/netfilter/nfnetlink_cthelper.c
@@ -686,6 +686,7 @@ static int nfnl_cthelper_del(struct net *net, struct sock *nfnl,
686 tuple_set = true; 686 tuple_set = true;
687 } 687 }
688 688
689 ret = -ENOENT;
689 list_for_each_entry_safe(nlcth, n, &nfnl_cthelper_list, list) { 690 list_for_each_entry_safe(nlcth, n, &nfnl_cthelper_list, list) {
690 cur = &nlcth->helper; 691 cur = &nlcth->helper;
691 j++; 692 j++;
@@ -699,16 +700,20 @@ static int nfnl_cthelper_del(struct net *net, struct sock *nfnl,
699 tuple.dst.protonum != cur->tuple.dst.protonum)) 700 tuple.dst.protonum != cur->tuple.dst.protonum))
700 continue; 701 continue;
701 702
702 found = true; 703 if (refcount_dec_if_one(&cur->refcnt)) {
703 nf_conntrack_helper_unregister(cur); 704 found = true;
704 kfree(cur->expect_policy); 705 nf_conntrack_helper_unregister(cur);
706 kfree(cur->expect_policy);
705 707
706 list_del(&nlcth->list); 708 list_del(&nlcth->list);
707 kfree(nlcth); 709 kfree(nlcth);
710 } else {
711 ret = -EBUSY;
712 }
708 } 713 }
709 714
710 /* Make sure we return success if we flush and there is no helpers */ 715 /* Make sure we return success if we flush and there is no helpers */
711 return (found || j == 0) ? 0 : -ENOENT; 716 return (found || j == 0) ? 0 : ret;
712} 717}
713 718
714static const struct nla_policy nfnl_cthelper_policy[NFCTH_MAX+1] = { 719static const struct nla_policy nfnl_cthelper_policy[NFCTH_MAX+1] = {
diff --git a/net/netfilter/nft_bitwise.c b/net/netfilter/nft_bitwise.c
index 877d9acd91ef..fff8073e2a56 100644
--- a/net/netfilter/nft_bitwise.c
+++ b/net/netfilter/nft_bitwise.c
@@ -83,17 +83,26 @@ static int nft_bitwise_init(const struct nft_ctx *ctx,
83 tb[NFTA_BITWISE_MASK]); 83 tb[NFTA_BITWISE_MASK]);
84 if (err < 0) 84 if (err < 0)
85 return err; 85 return err;
86 if (d1.len != priv->len) 86 if (d1.len != priv->len) {
87 return -EINVAL; 87 err = -EINVAL;
88 goto err1;
89 }
88 90
89 err = nft_data_init(NULL, &priv->xor, sizeof(priv->xor), &d2, 91 err = nft_data_init(NULL, &priv->xor, sizeof(priv->xor), &d2,
90 tb[NFTA_BITWISE_XOR]); 92 tb[NFTA_BITWISE_XOR]);
91 if (err < 0) 93 if (err < 0)
92 return err; 94 goto err1;
93 if (d2.len != priv->len) 95 if (d2.len != priv->len) {
94 return -EINVAL; 96 err = -EINVAL;
97 goto err2;
98 }
95 99
96 return 0; 100 return 0;
101err2:
102 nft_data_release(&priv->xor, d2.type);
103err1:
104 nft_data_release(&priv->mask, d1.type);
105 return err;
97} 106}
98 107
99static int nft_bitwise_dump(struct sk_buff *skb, const struct nft_expr *expr) 108static int nft_bitwise_dump(struct sk_buff *skb, const struct nft_expr *expr)
diff --git a/net/netfilter/nft_cmp.c b/net/netfilter/nft_cmp.c
index 2b96effeadc1..c2945eb3397c 100644
--- a/net/netfilter/nft_cmp.c
+++ b/net/netfilter/nft_cmp.c
@@ -201,10 +201,18 @@ nft_cmp_select_ops(const struct nft_ctx *ctx, const struct nlattr * const tb[])
201 if (err < 0) 201 if (err < 0)
202 return ERR_PTR(err); 202 return ERR_PTR(err);
203 203
204 if (desc.type != NFT_DATA_VALUE) {
205 err = -EINVAL;
206 goto err1;
207 }
208
204 if (desc.len <= sizeof(u32) && op == NFT_CMP_EQ) 209 if (desc.len <= sizeof(u32) && op == NFT_CMP_EQ)
205 return &nft_cmp_fast_ops; 210 return &nft_cmp_fast_ops;
206 else 211
207 return &nft_cmp_ops; 212 return &nft_cmp_ops;
213err1:
214 nft_data_release(&data, desc.type);
215 return ERR_PTR(-EINVAL);
208} 216}
209 217
210struct nft_expr_type nft_cmp_type __read_mostly = { 218struct nft_expr_type nft_cmp_type __read_mostly = {
diff --git a/net/netfilter/nft_ct.c b/net/netfilter/nft_ct.c
index a34ceb38fc55..1678e9e75e8e 100644
--- a/net/netfilter/nft_ct.c
+++ b/net/netfilter/nft_ct.c
@@ -826,9 +826,9 @@ static void nft_ct_helper_obj_destroy(struct nft_object *obj)
826 struct nft_ct_helper_obj *priv = nft_obj_data(obj); 826 struct nft_ct_helper_obj *priv = nft_obj_data(obj);
827 827
828 if (priv->helper4) 828 if (priv->helper4)
829 module_put(priv->helper4->me); 829 nf_conntrack_helper_put(priv->helper4);
830 if (priv->helper6) 830 if (priv->helper6)
831 module_put(priv->helper6->me); 831 nf_conntrack_helper_put(priv->helper6);
832} 832}
833 833
834static void nft_ct_helper_obj_eval(struct nft_object *obj, 834static void nft_ct_helper_obj_eval(struct nft_object *obj,
diff --git a/net/netfilter/nft_immediate.c b/net/netfilter/nft_immediate.c
index 728baf88295a..4717d7796927 100644
--- a/net/netfilter/nft_immediate.c
+++ b/net/netfilter/nft_immediate.c
@@ -65,7 +65,7 @@ static int nft_immediate_init(const struct nft_ctx *ctx,
65 return 0; 65 return 0;
66 66
67err1: 67err1:
68 nft_data_uninit(&priv->data, desc.type); 68 nft_data_release(&priv->data, desc.type);
69 return err; 69 return err;
70} 70}
71 71
@@ -73,7 +73,8 @@ static void nft_immediate_destroy(const struct nft_ctx *ctx,
73 const struct nft_expr *expr) 73 const struct nft_expr *expr)
74{ 74{
75 const struct nft_immediate_expr *priv = nft_expr_priv(expr); 75 const struct nft_immediate_expr *priv = nft_expr_priv(expr);
76 return nft_data_uninit(&priv->data, nft_dreg_to_type(priv->dreg)); 76
77 return nft_data_release(&priv->data, nft_dreg_to_type(priv->dreg));
77} 78}
78 79
79static int nft_immediate_dump(struct sk_buff *skb, const struct nft_expr *expr) 80static int nft_immediate_dump(struct sk_buff *skb, const struct nft_expr *expr)
diff --git a/net/netfilter/nft_range.c b/net/netfilter/nft_range.c
index 9edc74eedc10..cedb96c3619f 100644
--- a/net/netfilter/nft_range.c
+++ b/net/netfilter/nft_range.c
@@ -102,9 +102,9 @@ static int nft_range_init(const struct nft_ctx *ctx, const struct nft_expr *expr
102 priv->len = desc_from.len; 102 priv->len = desc_from.len;
103 return 0; 103 return 0;
104err2: 104err2:
105 nft_data_uninit(&priv->data_to, desc_to.type); 105 nft_data_release(&priv->data_to, desc_to.type);
106err1: 106err1:
107 nft_data_uninit(&priv->data_from, desc_from.type); 107 nft_data_release(&priv->data_from, desc_from.type);
108 return err; 108 return err;
109} 109}
110 110
diff --git a/net/netfilter/nft_set_hash.c b/net/netfilter/nft_set_hash.c
index 8ec086b6b56b..3d3a6df4ce70 100644
--- a/net/netfilter/nft_set_hash.c
+++ b/net/netfilter/nft_set_hash.c
@@ -222,7 +222,7 @@ static void nft_hash_walk(const struct nft_ctx *ctx, struct nft_set *set,
222 struct nft_set_elem elem; 222 struct nft_set_elem elem;
223 int err; 223 int err;
224 224
225 err = rhashtable_walk_init(&priv->ht, &hti, GFP_KERNEL); 225 err = rhashtable_walk_init(&priv->ht, &hti, GFP_ATOMIC);
226 iter->err = err; 226 iter->err = err;
227 if (err) 227 if (err)
228 return; 228 return;
diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c
index 8876b7da6884..1770c1d9b37f 100644
--- a/net/netfilter/x_tables.c
+++ b/net/netfilter/x_tables.c
@@ -283,28 +283,30 @@ static int xt_obj_to_user(u16 __user *psize, u16 size,
283 &U->u.user.revision, K->u.kernel.TYPE->revision) 283 &U->u.user.revision, K->u.kernel.TYPE->revision)
284 284
285int xt_data_to_user(void __user *dst, const void *src, 285int xt_data_to_user(void __user *dst, const void *src,
286 int usersize, int size) 286 int usersize, int size, int aligned_size)
287{ 287{
288 usersize = usersize ? : size; 288 usersize = usersize ? : size;
289 if (copy_to_user(dst, src, usersize)) 289 if (copy_to_user(dst, src, usersize))
290 return -EFAULT; 290 return -EFAULT;
291 if (usersize != size && clear_user(dst + usersize, size - usersize)) 291 if (usersize != aligned_size &&
292 clear_user(dst + usersize, aligned_size - usersize))
292 return -EFAULT; 293 return -EFAULT;
293 294
294 return 0; 295 return 0;
295} 296}
296EXPORT_SYMBOL_GPL(xt_data_to_user); 297EXPORT_SYMBOL_GPL(xt_data_to_user);
297 298
298#define XT_DATA_TO_USER(U, K, TYPE, C_SIZE) \ 299#define XT_DATA_TO_USER(U, K, TYPE) \
299 xt_data_to_user(U->data, K->data, \ 300 xt_data_to_user(U->data, K->data, \
300 K->u.kernel.TYPE->usersize, \ 301 K->u.kernel.TYPE->usersize, \
301 C_SIZE ? : K->u.kernel.TYPE->TYPE##size) 302 K->u.kernel.TYPE->TYPE##size, \
303 XT_ALIGN(K->u.kernel.TYPE->TYPE##size))
302 304
303int xt_match_to_user(const struct xt_entry_match *m, 305int xt_match_to_user(const struct xt_entry_match *m,
304 struct xt_entry_match __user *u) 306 struct xt_entry_match __user *u)
305{ 307{
306 return XT_OBJ_TO_USER(u, m, match, 0) || 308 return XT_OBJ_TO_USER(u, m, match, 0) ||
307 XT_DATA_TO_USER(u, m, match, 0); 309 XT_DATA_TO_USER(u, m, match);
308} 310}
309EXPORT_SYMBOL_GPL(xt_match_to_user); 311EXPORT_SYMBOL_GPL(xt_match_to_user);
310 312
@@ -312,7 +314,7 @@ int xt_target_to_user(const struct xt_entry_target *t,
312 struct xt_entry_target __user *u) 314 struct xt_entry_target __user *u)
313{ 315{
314 return XT_OBJ_TO_USER(u, t, target, 0) || 316 return XT_OBJ_TO_USER(u, t, target, 0) ||
315 XT_DATA_TO_USER(u, t, target, 0); 317 XT_DATA_TO_USER(u, t, target);
316} 318}
317EXPORT_SYMBOL_GPL(xt_target_to_user); 319EXPORT_SYMBOL_GPL(xt_target_to_user);
318 320
@@ -611,6 +613,12 @@ void xt_compat_match_from_user(struct xt_entry_match *m, void **dstptr,
611} 613}
612EXPORT_SYMBOL_GPL(xt_compat_match_from_user); 614EXPORT_SYMBOL_GPL(xt_compat_match_from_user);
613 615
616#define COMPAT_XT_DATA_TO_USER(U, K, TYPE, C_SIZE) \
617 xt_data_to_user(U->data, K->data, \
618 K->u.kernel.TYPE->usersize, \
619 C_SIZE, \
620 COMPAT_XT_ALIGN(C_SIZE))
621
614int xt_compat_match_to_user(const struct xt_entry_match *m, 622int xt_compat_match_to_user(const struct xt_entry_match *m,
615 void __user **dstptr, unsigned int *size) 623 void __user **dstptr, unsigned int *size)
616{ 624{
@@ -626,7 +634,7 @@ int xt_compat_match_to_user(const struct xt_entry_match *m,
626 if (match->compat_to_user((void __user *)cm->data, m->data)) 634 if (match->compat_to_user((void __user *)cm->data, m->data))
627 return -EFAULT; 635 return -EFAULT;
628 } else { 636 } else {
629 if (XT_DATA_TO_USER(cm, m, match, msize - sizeof(*cm))) 637 if (COMPAT_XT_DATA_TO_USER(cm, m, match, msize - sizeof(*cm)))
630 return -EFAULT; 638 return -EFAULT;
631 } 639 }
632 640
@@ -972,7 +980,7 @@ int xt_compat_target_to_user(const struct xt_entry_target *t,
972 if (target->compat_to_user((void __user *)ct->data, t->data)) 980 if (target->compat_to_user((void __user *)ct->data, t->data))
973 return -EFAULT; 981 return -EFAULT;
974 } else { 982 } else {
975 if (XT_DATA_TO_USER(ct, t, target, tsize - sizeof(*ct))) 983 if (COMPAT_XT_DATA_TO_USER(ct, t, target, tsize - sizeof(*ct)))
976 return -EFAULT; 984 return -EFAULT;
977 } 985 }
978 986
diff --git a/net/netfilter/xt_CT.c b/net/netfilter/xt_CT.c
index bb7ad82dcd56..623ef37de886 100644
--- a/net/netfilter/xt_CT.c
+++ b/net/netfilter/xt_CT.c
@@ -96,7 +96,7 @@ xt_ct_set_helper(struct nf_conn *ct, const char *helper_name,
96 96
97 help = nf_ct_helper_ext_add(ct, helper, GFP_KERNEL); 97 help = nf_ct_helper_ext_add(ct, helper, GFP_KERNEL);
98 if (help == NULL) { 98 if (help == NULL) {
99 module_put(helper->me); 99 nf_conntrack_helper_put(helper);
100 return -ENOMEM; 100 return -ENOMEM;
101 } 101 }
102 102
@@ -263,7 +263,7 @@ out:
263err4: 263err4:
264 help = nfct_help(ct); 264 help = nfct_help(ct);
265 if (help) 265 if (help)
266 module_put(help->helper->me); 266 nf_conntrack_helper_put(help->helper);
267err3: 267err3:
268 nf_ct_tmpl_free(ct); 268 nf_ct_tmpl_free(ct);
269err2: 269err2:
@@ -346,7 +346,7 @@ static void xt_ct_tg_destroy(const struct xt_tgdtor_param *par,
346 if (ct) { 346 if (ct) {
347 help = nfct_help(ct); 347 help = nfct_help(ct);
348 if (help) 348 if (help)
349 module_put(help->helper->me); 349 nf_conntrack_helper_put(help->helper);
350 350
351 nf_ct_netns_put(par->net, par->family); 351 nf_ct_netns_put(par->net, par->family);
352 352
diff --git a/net/openvswitch/conntrack.c b/net/openvswitch/conntrack.c
index bf602e33c40a..08679ebb3068 100644
--- a/net/openvswitch/conntrack.c
+++ b/net/openvswitch/conntrack.c
@@ -1123,7 +1123,7 @@ static int ovs_ct_add_helper(struct ovs_conntrack_info *info, const char *name,
1123 1123
1124 help = nf_ct_helper_ext_add(info->ct, helper, GFP_KERNEL); 1124 help = nf_ct_helper_ext_add(info->ct, helper, GFP_KERNEL);
1125 if (!help) { 1125 if (!help) {
1126 module_put(helper->me); 1126 nf_conntrack_helper_put(helper);
1127 return -ENOMEM; 1127 return -ENOMEM;
1128 } 1128 }
1129 1129
@@ -1584,7 +1584,7 @@ void ovs_ct_free_action(const struct nlattr *a)
1584static void __ovs_ct_free_action(struct ovs_conntrack_info *ct_info) 1584static void __ovs_ct_free_action(struct ovs_conntrack_info *ct_info)
1585{ 1585{
1586 if (ct_info->helper) 1586 if (ct_info->helper)
1587 module_put(ct_info->helper->me); 1587 nf_conntrack_helper_put(ct_info->helper);
1588 if (ct_info->ct) 1588 if (ct_info->ct)
1589 nf_ct_tmpl_free(ct_info->ct); 1589 nf_ct_tmpl_free(ct_info->ct);
1590} 1590}
diff --git a/net/sched/cls_matchall.c b/net/sched/cls_matchall.c
index dee469fed967..51859b8edd7e 100644
--- a/net/sched/cls_matchall.c
+++ b/net/sched/cls_matchall.c
@@ -203,7 +203,6 @@ static int mall_change(struct net *net, struct sk_buff *in_skb,
203 203
204 *arg = (unsigned long) head; 204 *arg = (unsigned long) head;
205 rcu_assign_pointer(tp->root, new); 205 rcu_assign_pointer(tp->root, new);
206 call_rcu(&head->rcu, mall_destroy_rcu);
207 return 0; 206 return 0;
208 207
209err_replace_hw_filter: 208err_replace_hw_filter:
diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
index 6f7f6757ceef..dfc8c51e4d74 100644
--- a/net/vmw_vsock/af_vsock.c
+++ b/net/vmw_vsock/af_vsock.c
@@ -1540,8 +1540,7 @@ static int vsock_stream_sendmsg(struct socket *sock, struct msghdr *msg,
1540 long timeout; 1540 long timeout;
1541 int err; 1541 int err;
1542 struct vsock_transport_send_notify_data send_data; 1542 struct vsock_transport_send_notify_data send_data;
1543 1543 DEFINE_WAIT_FUNC(wait, woken_wake_function);
1544 DEFINE_WAIT(wait);
1545 1544
1546 sk = sock->sk; 1545 sk = sock->sk;
1547 vsk = vsock_sk(sk); 1546 vsk = vsock_sk(sk);
@@ -1584,11 +1583,10 @@ static int vsock_stream_sendmsg(struct socket *sock, struct msghdr *msg,
1584 if (err < 0) 1583 if (err < 0)
1585 goto out; 1584 goto out;
1586 1585
1587
1588 while (total_written < len) { 1586 while (total_written < len) {
1589 ssize_t written; 1587 ssize_t written;
1590 1588
1591 prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE); 1589 add_wait_queue(sk_sleep(sk), &wait);
1592 while (vsock_stream_has_space(vsk) == 0 && 1590 while (vsock_stream_has_space(vsk) == 0 &&
1593 sk->sk_err == 0 && 1591 sk->sk_err == 0 &&
1594 !(sk->sk_shutdown & SEND_SHUTDOWN) && 1592 !(sk->sk_shutdown & SEND_SHUTDOWN) &&
@@ -1597,33 +1595,30 @@ static int vsock_stream_sendmsg(struct socket *sock, struct msghdr *msg,
1597 /* Don't wait for non-blocking sockets. */ 1595 /* Don't wait for non-blocking sockets. */
1598 if (timeout == 0) { 1596 if (timeout == 0) {
1599 err = -EAGAIN; 1597 err = -EAGAIN;
1600 finish_wait(sk_sleep(sk), &wait); 1598 remove_wait_queue(sk_sleep(sk), &wait);
1601 goto out_err; 1599 goto out_err;
1602 } 1600 }
1603 1601
1604 err = transport->notify_send_pre_block(vsk, &send_data); 1602 err = transport->notify_send_pre_block(vsk, &send_data);
1605 if (err < 0) { 1603 if (err < 0) {
1606 finish_wait(sk_sleep(sk), &wait); 1604 remove_wait_queue(sk_sleep(sk), &wait);
1607 goto out_err; 1605 goto out_err;
1608 } 1606 }
1609 1607
1610 release_sock(sk); 1608 release_sock(sk);
1611 timeout = schedule_timeout(timeout); 1609 timeout = wait_woken(&wait, TASK_INTERRUPTIBLE, timeout);
1612 lock_sock(sk); 1610 lock_sock(sk);
1613 if (signal_pending(current)) { 1611 if (signal_pending(current)) {
1614 err = sock_intr_errno(timeout); 1612 err = sock_intr_errno(timeout);
1615 finish_wait(sk_sleep(sk), &wait); 1613 remove_wait_queue(sk_sleep(sk), &wait);
1616 goto out_err; 1614 goto out_err;
1617 } else if (timeout == 0) { 1615 } else if (timeout == 0) {
1618 err = -EAGAIN; 1616 err = -EAGAIN;
1619 finish_wait(sk_sleep(sk), &wait); 1617 remove_wait_queue(sk_sleep(sk), &wait);
1620 goto out_err; 1618 goto out_err;
1621 } 1619 }
1622
1623 prepare_to_wait(sk_sleep(sk), &wait,
1624 TASK_INTERRUPTIBLE);
1625 } 1620 }
1626 finish_wait(sk_sleep(sk), &wait); 1621 remove_wait_queue(sk_sleep(sk), &wait);
1627 1622
1628 /* These checks occur both as part of and after the loop 1623 /* These checks occur both as part of and after the loop
1629 * conditional since we need to check before and after 1624 * conditional since we need to check before and after
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 6dc1eda13b8e..58c05e5d9870 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -175,7 +175,7 @@ ld_flags = $(LDFLAGS) $(ldflags-y)
175 175
176dtc_cpp_flags = -Wp,-MD,$(depfile).pre.tmp -nostdinc \ 176dtc_cpp_flags = -Wp,-MD,$(depfile).pre.tmp -nostdinc \
177 -I$(srctree)/arch/$(SRCARCH)/boot/dts \ 177 -I$(srctree)/arch/$(SRCARCH)/boot/dts \
178 -I$(srctree)/arch/$(SRCARCH)/boot/dts/include \ 178 -I$(srctree)/scripts/dtc/include-prefixes \
179 -I$(srctree)/drivers/of/testcase-data \ 179 -I$(srctree)/drivers/of/testcase-data \
180 -undef -D__DTS__ 180 -undef -D__DTS__
181 181
diff --git a/scripts/dtc/checks.c b/scripts/dtc/checks.c
index 5adfc8f52b4f..4b72b530c84f 100644
--- a/scripts/dtc/checks.c
+++ b/scripts/dtc/checks.c
@@ -873,7 +873,7 @@ static void check_simple_bus_reg(struct check *c, struct dt_info *dti, struct no
873 while (size--) 873 while (size--)
874 reg = (reg << 32) | fdt32_to_cpu(*(cells++)); 874 reg = (reg << 32) | fdt32_to_cpu(*(cells++));
875 875
876 snprintf(unit_addr, sizeof(unit_addr), "%lx", reg); 876 snprintf(unit_addr, sizeof(unit_addr), "%zx", reg);
877 if (!streq(unitname, unit_addr)) 877 if (!streq(unitname, unit_addr))
878 FAIL(c, dti, "Node %s simple-bus unit address format error, expected \"%s\"", 878 FAIL(c, dti, "Node %s simple-bus unit address format error, expected \"%s\"",
879 node->fullpath, unit_addr); 879 node->fullpath, unit_addr);
diff --git a/scripts/dtc/include-prefixes/arc b/scripts/dtc/include-prefixes/arc
new file mode 120000
index 000000000000..5d21b5a69a11
--- /dev/null
+++ b/scripts/dtc/include-prefixes/arc
@@ -0,0 +1 @@
../../../arch/arc/boot/dts \ No newline at end of file
diff --git a/scripts/dtc/include-prefixes/arm b/scripts/dtc/include-prefixes/arm
new file mode 120000
index 000000000000..eb14d4515a57
--- /dev/null
+++ b/scripts/dtc/include-prefixes/arm
@@ -0,0 +1 @@
../../../arch/arm/boot/dts \ No newline at end of file
diff --git a/scripts/dtc/include-prefixes/arm64 b/scripts/dtc/include-prefixes/arm64
new file mode 120000
index 000000000000..275c42c21d71
--- /dev/null
+++ b/scripts/dtc/include-prefixes/arm64
@@ -0,0 +1 @@
../../../arch/arm64/boot/dts \ No newline at end of file
diff --git a/scripts/dtc/include-prefixes/c6x b/scripts/dtc/include-prefixes/c6x
new file mode 120000
index 000000000000..49ded4cae2be
--- /dev/null
+++ b/scripts/dtc/include-prefixes/c6x
@@ -0,0 +1 @@
../../../arch/c6x/boot/dts \ No newline at end of file
diff --git a/scripts/dtc/include-prefixes/cris b/scripts/dtc/include-prefixes/cris
new file mode 120000
index 000000000000..736d998ba506
--- /dev/null
+++ b/scripts/dtc/include-prefixes/cris
@@ -0,0 +1 @@
../../../arch/cris/boot/dts \ No newline at end of file
diff --git a/scripts/dtc/include-prefixes/dt-bindings b/scripts/dtc/include-prefixes/dt-bindings
new file mode 120000
index 000000000000..04fdbb3af016
--- /dev/null
+++ b/scripts/dtc/include-prefixes/dt-bindings
@@ -0,0 +1 @@
../../../include/dt-bindings \ No newline at end of file
diff --git a/scripts/dtc/include-prefixes/h8300 b/scripts/dtc/include-prefixes/h8300
new file mode 120000
index 000000000000..3bdaa332c54c
--- /dev/null
+++ b/scripts/dtc/include-prefixes/h8300
@@ -0,0 +1 @@
../../../arch/h8300/boot/dts \ No newline at end of file
diff --git a/scripts/dtc/include-prefixes/metag b/scripts/dtc/include-prefixes/metag
new file mode 120000
index 000000000000..87a3c847db8f
--- /dev/null
+++ b/scripts/dtc/include-prefixes/metag
@@ -0,0 +1 @@
../../../arch/metag/boot/dts \ No newline at end of file
diff --git a/scripts/dtc/include-prefixes/microblaze b/scripts/dtc/include-prefixes/microblaze
new file mode 120000
index 000000000000..d9830330a21d
--- /dev/null
+++ b/scripts/dtc/include-prefixes/microblaze
@@ -0,0 +1 @@
../../../arch/microblaze/boot/dts \ No newline at end of file
diff --git a/scripts/dtc/include-prefixes/mips b/scripts/dtc/include-prefixes/mips
new file mode 120000
index 000000000000..ae8d4948dc8d
--- /dev/null
+++ b/scripts/dtc/include-prefixes/mips
@@ -0,0 +1 @@
../../../arch/mips/boot/dts \ No newline at end of file
diff --git a/scripts/dtc/include-prefixes/nios2 b/scripts/dtc/include-prefixes/nios2
new file mode 120000
index 000000000000..51772336d13f
--- /dev/null
+++ b/scripts/dtc/include-prefixes/nios2
@@ -0,0 +1 @@
../../../arch/nios2/boot/dts \ No newline at end of file
diff --git a/scripts/dtc/include-prefixes/openrisc b/scripts/dtc/include-prefixes/openrisc
new file mode 120000
index 000000000000..71c3bc75c560
--- /dev/null
+++ b/scripts/dtc/include-prefixes/openrisc
@@ -0,0 +1 @@
../../../arch/openrisc/boot/dts \ No newline at end of file
diff --git a/scripts/dtc/include-prefixes/powerpc b/scripts/dtc/include-prefixes/powerpc
new file mode 120000
index 000000000000..7cd6ec16e899
--- /dev/null
+++ b/scripts/dtc/include-prefixes/powerpc
@@ -0,0 +1 @@
../../../arch/powerpc/boot/dts \ No newline at end of file
diff --git a/scripts/dtc/include-prefixes/sh b/scripts/dtc/include-prefixes/sh
new file mode 120000
index 000000000000..67d37808c599
--- /dev/null
+++ b/scripts/dtc/include-prefixes/sh
@@ -0,0 +1 @@
../../../arch/sh/boot/dts \ No newline at end of file
diff --git a/scripts/dtc/include-prefixes/xtensa b/scripts/dtc/include-prefixes/xtensa
new file mode 120000
index 000000000000..d1eaf6ec7a2b
--- /dev/null
+++ b/scripts/dtc/include-prefixes/xtensa
@@ -0,0 +1 @@
../../../arch/xtensa/boot/dts \ No newline at end of file
diff --git a/sound/x86/intel_hdmi_audio.c b/sound/x86/intel_hdmi_audio.c
index 664b7fe206d6..b11d3920b9a5 100644
--- a/sound/x86/intel_hdmi_audio.c
+++ b/sound/x86/intel_hdmi_audio.c
@@ -1809,10 +1809,6 @@ static int hdmi_lpe_audio_probe(struct platform_device *pdev)
1809 pdata->notify_pending = false; 1809 pdata->notify_pending = false;
1810 spin_unlock_irq(&pdata->lpe_audio_slock); 1810 spin_unlock_irq(&pdata->lpe_audio_slock);
1811 1811
1812 /* runtime PM isn't enabled as default, since it won't save much on
1813 * BYT/CHT devices; user who want the runtime PM should adjust the
1814 * power/ontrol and power/autosuspend_delay_ms sysfs entries instead
1815 */
1816 pm_runtime_use_autosuspend(&pdev->dev); 1812 pm_runtime_use_autosuspend(&pdev->dev);
1817 pm_runtime_mark_last_busy(&pdev->dev); 1813 pm_runtime_mark_last_busy(&pdev->dev);
1818 pm_runtime_set_active(&pdev->dev); 1814 pm_runtime_set_active(&pdev->dev);
diff --git a/tools/power/acpi/.gitignore b/tools/power/acpi/.gitignore
new file mode 100644
index 000000000000..cba3d994995c
--- /dev/null
+++ b/tools/power/acpi/.gitignore
@@ -0,0 +1,4 @@
1acpidbg
2acpidump
3ec
4include
diff --git a/tools/testing/selftests/ftrace/ftracetest b/tools/testing/selftests/ftrace/ftracetest
index 32e6211e1c6e..717581145cfc 100755
--- a/tools/testing/selftests/ftrace/ftracetest
+++ b/tools/testing/selftests/ftrace/ftracetest
@@ -58,7 +58,7 @@ parse_opts() { # opts
58 ;; 58 ;;
59 --verbose|-v|-vv) 59 --verbose|-v|-vv)
60 VERBOSE=$((VERBOSE + 1)) 60 VERBOSE=$((VERBOSE + 1))
61 [ $1 == '-vv' ] && VERBOSE=$((VERBOSE + 1)) 61 [ $1 = '-vv' ] && VERBOSE=$((VERBOSE + 1))
62 shift 1 62 shift 1
63 ;; 63 ;;
64 --debug|-d) 64 --debug|-d)
diff --git a/tools/testing/selftests/ftrace/test.d/ftrace/func_event_triggers.tc b/tools/testing/selftests/ftrace/test.d/ftrace/func_event_triggers.tc
index 07bb3e5930b4..aa31368851c9 100644
--- a/tools/testing/selftests/ftrace/test.d/ftrace/func_event_triggers.tc
+++ b/tools/testing/selftests/ftrace/test.d/ftrace/func_event_triggers.tc
@@ -48,7 +48,7 @@ test_event_enabled() {
48 e=`cat $EVENT_ENABLE` 48 e=`cat $EVENT_ENABLE`
49 if [ "$e" != $val ]; then 49 if [ "$e" != $val ]; then
50 echo "Expected $val but found $e" 50 echo "Expected $val but found $e"
51 exit -1 51 exit 1
52 fi 52 fi
53} 53}
54 54
diff --git a/tools/testing/selftests/ftrace/test.d/functions b/tools/testing/selftests/ftrace/test.d/functions
index 9aec6fcb7729..f2019b37370d 100644
--- a/tools/testing/selftests/ftrace/test.d/functions
+++ b/tools/testing/selftests/ftrace/test.d/functions
@@ -34,10 +34,10 @@ reset_ftrace_filter() { # reset all triggers in set_ftrace_filter
34 echo > set_ftrace_filter 34 echo > set_ftrace_filter
35 grep -v '^#' set_ftrace_filter | while read t; do 35 grep -v '^#' set_ftrace_filter | while read t; do
36 tr=`echo $t | cut -d: -f2` 36 tr=`echo $t | cut -d: -f2`
37 if [ "$tr" == "" ]; then 37 if [ "$tr" = "" ]; then
38 continue 38 continue
39 fi 39 fi
40 if [ $tr == "enable_event" -o $tr == "disable_event" ]; then 40 if [ $tr = "enable_event" -o $tr = "disable_event" ]; then
41 tr=`echo $t | cut -d: -f1-4` 41 tr=`echo $t | cut -d: -f1-4`
42 limit=`echo $t | cut -d: -f5` 42 limit=`echo $t | cut -d: -f5`
43 else 43 else
diff --git a/tools/testing/selftests/ftrace/test.d/instances/instance-event.tc b/tools/testing/selftests/ftrace/test.d/instances/instance-event.tc
index 4c5a061a5b4e..c73db7863adb 100644
--- a/tools/testing/selftests/ftrace/test.d/instances/instance-event.tc
+++ b/tools/testing/selftests/ftrace/test.d/instances/instance-event.tc
@@ -75,9 +75,13 @@ rmdir foo
75if [ -d foo ]; then 75if [ -d foo ]; then
76 fail "foo still exists" 76 fail "foo still exists"
77fi 77fi
78exit 0
79
80 78
79mkdir foo
80echo "schedule:enable_event:sched:sched_switch" > foo/set_ftrace_filter
81rmdir foo
82if [ -d foo ]; then
83 fail "foo still exists"
84fi
81 85
82 86
83instance_slam() { 87instance_slam() {
diff --git a/tools/testing/selftests/powerpc/tm/.gitignore b/tools/testing/selftests/powerpc/tm/.gitignore
index 427621792229..2f1f7b013293 100644
--- a/tools/testing/selftests/powerpc/tm/.gitignore
+++ b/tools/testing/selftests/powerpc/tm/.gitignore
@@ -11,3 +11,4 @@ tm-signal-context-chk-fpu
11tm-signal-context-chk-gpr 11tm-signal-context-chk-gpr
12tm-signal-context-chk-vmx 12tm-signal-context-chk-vmx
13tm-signal-context-chk-vsx 13tm-signal-context-chk-vsx
14tm-vmx-unavail
diff --git a/tools/testing/selftests/powerpc/tm/Makefile b/tools/testing/selftests/powerpc/tm/Makefile
index 5576ee6a51f2..958c11c14acd 100644
--- a/tools/testing/selftests/powerpc/tm/Makefile
+++ b/tools/testing/selftests/powerpc/tm/Makefile
@@ -2,7 +2,8 @@ SIGNAL_CONTEXT_CHK_TESTS := tm-signal-context-chk-gpr tm-signal-context-chk-fpu
2 tm-signal-context-chk-vmx tm-signal-context-chk-vsx 2 tm-signal-context-chk-vmx tm-signal-context-chk-vsx
3 3
4TEST_GEN_PROGS := tm-resched-dscr tm-syscall tm-signal-msr-resv tm-signal-stack \ 4TEST_GEN_PROGS := tm-resched-dscr tm-syscall tm-signal-msr-resv tm-signal-stack \
5 tm-vmxcopy tm-fork tm-tar tm-tmspr $(SIGNAL_CONTEXT_CHK_TESTS) 5 tm-vmxcopy tm-fork tm-tar tm-tmspr tm-vmx-unavail \
6 $(SIGNAL_CONTEXT_CHK_TESTS)
6 7
7include ../../lib.mk 8include ../../lib.mk
8 9
@@ -13,6 +14,7 @@ CFLAGS += -mhtm
13$(OUTPUT)/tm-syscall: tm-syscall-asm.S 14$(OUTPUT)/tm-syscall: tm-syscall-asm.S
14$(OUTPUT)/tm-syscall: CFLAGS += -I../../../../../usr/include 15$(OUTPUT)/tm-syscall: CFLAGS += -I../../../../../usr/include
15$(OUTPUT)/tm-tmspr: CFLAGS += -pthread 16$(OUTPUT)/tm-tmspr: CFLAGS += -pthread
17$(OUTPUT)/tm-vmx-unavail: CFLAGS += -pthread -m64
16 18
17SIGNAL_CONTEXT_CHK_TESTS := $(patsubst %,$(OUTPUT)/%,$(SIGNAL_CONTEXT_CHK_TESTS)) 19SIGNAL_CONTEXT_CHK_TESTS := $(patsubst %,$(OUTPUT)/%,$(SIGNAL_CONTEXT_CHK_TESTS))
18$(SIGNAL_CONTEXT_CHK_TESTS): tm-signal.S 20$(SIGNAL_CONTEXT_CHK_TESTS): tm-signal.S
diff --git a/tools/testing/selftests/powerpc/tm/tm-vmx-unavail.c b/tools/testing/selftests/powerpc/tm/tm-vmx-unavail.c
new file mode 100644
index 000000000000..137185ba4937
--- /dev/null
+++ b/tools/testing/selftests/powerpc/tm/tm-vmx-unavail.c
@@ -0,0 +1,118 @@
1/*
2 * Copyright 2017, Michael Neuling, IBM Corp.
3 * Licensed under GPLv2.
4 * Original: Breno Leitao <brenohl@br.ibm.com> &
5 * Gustavo Bueno Romero <gromero@br.ibm.com>
6 * Edited: Michael Neuling
7 *
8 * Force VMX unavailable during a transaction and see if it corrupts
9 * the checkpointed VMX register state after the abort.
10 */
11
12#include <inttypes.h>
13#include <htmintrin.h>
14#include <string.h>
15#include <stdlib.h>
16#include <stdio.h>
17#include <pthread.h>
18#include <sys/mman.h>
19#include <unistd.h>
20#include <pthread.h>
21
22#include "tm.h"
23#include "utils.h"
24
25int passed;
26
27void *worker(void *unused)
28{
29 __int128 vmx0;
30 uint64_t texasr;
31
32 asm goto (
33 "li 3, 1;" /* Stick non-zero value in VMX0 */
34 "std 3, 0(%[vmx0_ptr]);"
35 "lvx 0, 0, %[vmx0_ptr];"
36
37 /* Wait here a bit so we get scheduled out 255 times */
38 "lis 3, 0x3fff;"
39 "1: ;"
40 "addi 3, 3, -1;"
41 "cmpdi 3, 0;"
42 "bne 1b;"
43
44 /* Kernel will hopefully turn VMX off now */
45
46 "tbegin. ;"
47 "beq failure;"
48
49 /* Cause VMX unavail. Any VMX instruction */
50 "vaddcuw 0,0,0;"
51
52 "tend. ;"
53 "b %l[success];"
54
55 /* Check VMX0 sanity after abort */
56 "failure: ;"
57 "lvx 1, 0, %[vmx0_ptr];"
58 "vcmpequb. 2, 0, 1;"
59 "bc 4, 24, %l[value_mismatch];"
60 "b %l[value_match];"
61 :
62 : [vmx0_ptr] "r"(&vmx0)
63 : "r3"
64 : success, value_match, value_mismatch
65 );
66
67 /* HTM aborted and VMX0 is corrupted */
68value_mismatch:
69 texasr = __builtin_get_texasr();
70
71 printf("\n\n==============\n\n");
72 printf("Failure with error: %lx\n", _TEXASR_FAILURE_CODE(texasr));
73 printf("Summary error : %lx\n", _TEXASR_FAILURE_SUMMARY(texasr));
74 printf("TFIAR exact : %lx\n\n", _TEXASR_TFIAR_EXACT(texasr));
75
76 passed = 0;
77 return NULL;
78
79 /* HTM aborted but VMX0 is correct */
80value_match:
81// printf("!");
82 return NULL;
83
84success:
85// printf(".");
86 return NULL;
87}
88
89int tm_vmx_unavail_test()
90{
91 int threads;
92 pthread_t *thread;
93
94 SKIP_IF(!have_htm());
95
96 passed = 1;
97
98 threads = sysconf(_SC_NPROCESSORS_ONLN) * 4;
99 thread = malloc(sizeof(pthread_t)*threads);
100 if (!thread)
101 return EXIT_FAILURE;
102
103 for (uint64_t i = 0; i < threads; i++)
104 pthread_create(&thread[i], NULL, &worker, NULL);
105
106 for (uint64_t i = 0; i < threads; i++)
107 pthread_join(thread[i], NULL);
108
109 free(thread);
110
111 return passed ? EXIT_SUCCESS : EXIT_FAILURE;
112}
113
114
115int main(int argc, char **argv)
116{
117 return test_harness(tm_vmx_unavail_test, "tm_vmx_unavail_test");
118}
diff --git a/virt/kvm/arm/hyp/vgic-v3-sr.c b/virt/kvm/arm/hyp/vgic-v3-sr.c
index bce6037cf01d..32c3295929b0 100644
--- a/virt/kvm/arm/hyp/vgic-v3-sr.c
+++ b/virt/kvm/arm/hyp/vgic-v3-sr.c
@@ -22,7 +22,7 @@
22#include <asm/kvm_hyp.h> 22#include <asm/kvm_hyp.h>
23 23
24#define vtr_to_max_lr_idx(v) ((v) & 0xf) 24#define vtr_to_max_lr_idx(v) ((v) & 0xf)
25#define vtr_to_nr_pri_bits(v) (((u32)(v) >> 29) + 1) 25#define vtr_to_nr_pre_bits(v) (((u32)(v) >> 26) + 1)
26 26
27static u64 __hyp_text __gic_v3_get_lr(unsigned int lr) 27static u64 __hyp_text __gic_v3_get_lr(unsigned int lr)
28{ 28{
@@ -135,13 +135,13 @@ void __hyp_text __vgic_v3_save_state(struct kvm_vcpu *vcpu)
135 135
136 if (used_lrs) { 136 if (used_lrs) {
137 int i; 137 int i;
138 u32 nr_pri_bits; 138 u32 nr_pre_bits;
139 139
140 cpu_if->vgic_elrsr = read_gicreg(ICH_ELSR_EL2); 140 cpu_if->vgic_elrsr = read_gicreg(ICH_ELSR_EL2);
141 141
142 write_gicreg(0, ICH_HCR_EL2); 142 write_gicreg(0, ICH_HCR_EL2);
143 val = read_gicreg(ICH_VTR_EL2); 143 val = read_gicreg(ICH_VTR_EL2);
144 nr_pri_bits = vtr_to_nr_pri_bits(val); 144 nr_pre_bits = vtr_to_nr_pre_bits(val);
145 145
146 for (i = 0; i < used_lrs; i++) { 146 for (i = 0; i < used_lrs; i++) {
147 if (cpu_if->vgic_elrsr & (1 << i)) 147 if (cpu_if->vgic_elrsr & (1 << i))
@@ -152,7 +152,7 @@ void __hyp_text __vgic_v3_save_state(struct kvm_vcpu *vcpu)
152 __gic_v3_set_lr(0, i); 152 __gic_v3_set_lr(0, i);
153 } 153 }
154 154
155 switch (nr_pri_bits) { 155 switch (nr_pre_bits) {
156 case 7: 156 case 7:
157 cpu_if->vgic_ap0r[3] = read_gicreg(ICH_AP0R3_EL2); 157 cpu_if->vgic_ap0r[3] = read_gicreg(ICH_AP0R3_EL2);
158 cpu_if->vgic_ap0r[2] = read_gicreg(ICH_AP0R2_EL2); 158 cpu_if->vgic_ap0r[2] = read_gicreg(ICH_AP0R2_EL2);
@@ -162,7 +162,7 @@ void __hyp_text __vgic_v3_save_state(struct kvm_vcpu *vcpu)
162 cpu_if->vgic_ap0r[0] = read_gicreg(ICH_AP0R0_EL2); 162 cpu_if->vgic_ap0r[0] = read_gicreg(ICH_AP0R0_EL2);
163 } 163 }
164 164
165 switch (nr_pri_bits) { 165 switch (nr_pre_bits) {
166 case 7: 166 case 7:
167 cpu_if->vgic_ap1r[3] = read_gicreg(ICH_AP1R3_EL2); 167 cpu_if->vgic_ap1r[3] = read_gicreg(ICH_AP1R3_EL2);
168 cpu_if->vgic_ap1r[2] = read_gicreg(ICH_AP1R2_EL2); 168 cpu_if->vgic_ap1r[2] = read_gicreg(ICH_AP1R2_EL2);
@@ -198,7 +198,7 @@ void __hyp_text __vgic_v3_restore_state(struct kvm_vcpu *vcpu)
198 struct vgic_v3_cpu_if *cpu_if = &vcpu->arch.vgic_cpu.vgic_v3; 198 struct vgic_v3_cpu_if *cpu_if = &vcpu->arch.vgic_cpu.vgic_v3;
199 u64 used_lrs = vcpu->arch.vgic_cpu.used_lrs; 199 u64 used_lrs = vcpu->arch.vgic_cpu.used_lrs;
200 u64 val; 200 u64 val;
201 u32 nr_pri_bits; 201 u32 nr_pre_bits;
202 int i; 202 int i;
203 203
204 /* 204 /*
@@ -217,12 +217,12 @@ void __hyp_text __vgic_v3_restore_state(struct kvm_vcpu *vcpu)
217 } 217 }
218 218
219 val = read_gicreg(ICH_VTR_EL2); 219 val = read_gicreg(ICH_VTR_EL2);
220 nr_pri_bits = vtr_to_nr_pri_bits(val); 220 nr_pre_bits = vtr_to_nr_pre_bits(val);
221 221
222 if (used_lrs) { 222 if (used_lrs) {
223 write_gicreg(cpu_if->vgic_hcr, ICH_HCR_EL2); 223 write_gicreg(cpu_if->vgic_hcr, ICH_HCR_EL2);
224 224
225 switch (nr_pri_bits) { 225 switch (nr_pre_bits) {
226 case 7: 226 case 7:
227 write_gicreg(cpu_if->vgic_ap0r[3], ICH_AP0R3_EL2); 227 write_gicreg(cpu_if->vgic_ap0r[3], ICH_AP0R3_EL2);
228 write_gicreg(cpu_if->vgic_ap0r[2], ICH_AP0R2_EL2); 228 write_gicreg(cpu_if->vgic_ap0r[2], ICH_AP0R2_EL2);
@@ -232,7 +232,7 @@ void __hyp_text __vgic_v3_restore_state(struct kvm_vcpu *vcpu)
232 write_gicreg(cpu_if->vgic_ap0r[0], ICH_AP0R0_EL2); 232 write_gicreg(cpu_if->vgic_ap0r[0], ICH_AP0R0_EL2);
233 } 233 }
234 234
235 switch (nr_pri_bits) { 235 switch (nr_pre_bits) {
236 case 7: 236 case 7:
237 write_gicreg(cpu_if->vgic_ap1r[3], ICH_AP1R3_EL2); 237 write_gicreg(cpu_if->vgic_ap1r[3], ICH_AP1R3_EL2);
238 write_gicreg(cpu_if->vgic_ap1r[2], ICH_AP1R2_EL2); 238 write_gicreg(cpu_if->vgic_ap1r[2], ICH_AP1R2_EL2);
diff --git a/virt/kvm/arm/mmu.c b/virt/kvm/arm/mmu.c
index 313ee646480f..a2d63247d1bb 100644
--- a/virt/kvm/arm/mmu.c
+++ b/virt/kvm/arm/mmu.c
@@ -295,6 +295,13 @@ static void unmap_stage2_range(struct kvm *kvm, phys_addr_t start, u64 size)
295 assert_spin_locked(&kvm->mmu_lock); 295 assert_spin_locked(&kvm->mmu_lock);
296 pgd = kvm->arch.pgd + stage2_pgd_index(addr); 296 pgd = kvm->arch.pgd + stage2_pgd_index(addr);
297 do { 297 do {
298 /*
299 * Make sure the page table is still active, as another thread
300 * could have possibly freed the page table, while we released
301 * the lock.
302 */
303 if (!READ_ONCE(kvm->arch.pgd))
304 break;
298 next = stage2_pgd_addr_end(addr, end); 305 next = stage2_pgd_addr_end(addr, end);
299 if (!stage2_pgd_none(*pgd)) 306 if (!stage2_pgd_none(*pgd))
300 unmap_stage2_puds(kvm, pgd, addr, next); 307 unmap_stage2_puds(kvm, pgd, addr, next);
@@ -829,22 +836,22 @@ void stage2_unmap_vm(struct kvm *kvm)
829 * Walks the level-1 page table pointed to by kvm->arch.pgd and frees all 836 * Walks the level-1 page table pointed to by kvm->arch.pgd and frees all
830 * underlying level-2 and level-3 tables before freeing the actual level-1 table 837 * underlying level-2 and level-3 tables before freeing the actual level-1 table
831 * and setting the struct pointer to NULL. 838 * and setting the struct pointer to NULL.
832 *
833 * Note we don't need locking here as this is only called when the VM is
834 * destroyed, which can only be done once.
835 */ 839 */
836void kvm_free_stage2_pgd(struct kvm *kvm) 840void kvm_free_stage2_pgd(struct kvm *kvm)
837{ 841{
838 if (kvm->arch.pgd == NULL) 842 void *pgd = NULL;
839 return;
840 843
841 spin_lock(&kvm->mmu_lock); 844 spin_lock(&kvm->mmu_lock);
842 unmap_stage2_range(kvm, 0, KVM_PHYS_SIZE); 845 if (kvm->arch.pgd) {
846 unmap_stage2_range(kvm, 0, KVM_PHYS_SIZE);
847 pgd = READ_ONCE(kvm->arch.pgd);
848 kvm->arch.pgd = NULL;
849 }
843 spin_unlock(&kvm->mmu_lock); 850 spin_unlock(&kvm->mmu_lock);
844 851
845 /* Free the HW pgd, one page at a time */ 852 /* Free the HW pgd, one page at a time */
846 free_pages_exact(kvm->arch.pgd, S2_PGD_SIZE); 853 if (pgd)
847 kvm->arch.pgd = NULL; 854 free_pages_exact(pgd, S2_PGD_SIZE);
848} 855}
849 856
850static pud_t *stage2_get_pud(struct kvm *kvm, struct kvm_mmu_memory_cache *cache, 857static pud_t *stage2_get_pud(struct kvm *kvm, struct kvm_mmu_memory_cache *cache,
@@ -1170,11 +1177,13 @@ static void stage2_wp_range(struct kvm *kvm, phys_addr_t addr, phys_addr_t end)
1170 * large. Otherwise, we may see kernel panics with 1177 * large. Otherwise, we may see kernel panics with
1171 * CONFIG_DETECT_HUNG_TASK, CONFIG_LOCKUP_DETECTOR, 1178 * CONFIG_DETECT_HUNG_TASK, CONFIG_LOCKUP_DETECTOR,
1172 * CONFIG_LOCKDEP. Additionally, holding the lock too long 1179 * CONFIG_LOCKDEP. Additionally, holding the lock too long
1173 * will also starve other vCPUs. 1180 * will also starve other vCPUs. We have to also make sure
1181 * that the page tables are not freed while we released
1182 * the lock.
1174 */ 1183 */
1175 if (need_resched() || spin_needbreak(&kvm->mmu_lock)) 1184 cond_resched_lock(&kvm->mmu_lock);
1176 cond_resched_lock(&kvm->mmu_lock); 1185 if (!READ_ONCE(kvm->arch.pgd))
1177 1186 break;
1178 next = stage2_pgd_addr_end(addr, end); 1187 next = stage2_pgd_addr_end(addr, end);
1179 if (stage2_pgd_present(*pgd)) 1188 if (stage2_pgd_present(*pgd))
1180 stage2_wp_puds(pgd, addr, next); 1189 stage2_wp_puds(pgd, addr, next);
diff --git a/virt/kvm/arm/vgic/vgic-init.c b/virt/kvm/arm/vgic/vgic-init.c
index dc68e2e424ab..3a0b8999f011 100644
--- a/virt/kvm/arm/vgic/vgic-init.c
+++ b/virt/kvm/arm/vgic/vgic-init.c
@@ -242,8 +242,11 @@ int kvm_vgic_vcpu_init(struct kvm_vcpu *vcpu)
242 * If we are creating a VCPU with a GICv3 we must also register the 242 * If we are creating a VCPU with a GICv3 we must also register the
243 * KVM io device for the redistributor that belongs to this VCPU. 243 * KVM io device for the redistributor that belongs to this VCPU.
244 */ 244 */
245 if (dist->vgic_model == KVM_DEV_TYPE_ARM_VGIC_V3) 245 if (dist->vgic_model == KVM_DEV_TYPE_ARM_VGIC_V3) {
246 mutex_lock(&vcpu->kvm->lock);
246 ret = vgic_register_redist_iodev(vcpu); 247 ret = vgic_register_redist_iodev(vcpu);
248 mutex_unlock(&vcpu->kvm->lock);
249 }
247 return ret; 250 return ret;
248} 251}
249 252
diff --git a/virt/kvm/arm/vgic/vgic-mmio-v3.c b/virt/kvm/arm/vgic/vgic-mmio-v3.c
index 99da1a207c19..201d5e2e973d 100644
--- a/virt/kvm/arm/vgic/vgic-mmio-v3.c
+++ b/virt/kvm/arm/vgic/vgic-mmio-v3.c
@@ -586,7 +586,7 @@ int vgic_register_redist_iodev(struct kvm_vcpu *vcpu)
586 if (!vgic_v3_check_base(kvm)) 586 if (!vgic_v3_check_base(kvm))
587 return -EINVAL; 587 return -EINVAL;
588 588
589 rd_base = vgic->vgic_redist_base + kvm_vcpu_get_idx(vcpu) * SZ_64K * 2; 589 rd_base = vgic->vgic_redist_base + vgic->vgic_redist_free_offset;
590 sgi_base = rd_base + SZ_64K; 590 sgi_base = rd_base + SZ_64K;
591 591
592 kvm_iodevice_init(&rd_dev->dev, &kvm_io_gic_ops); 592 kvm_iodevice_init(&rd_dev->dev, &kvm_io_gic_ops);
@@ -614,11 +614,15 @@ int vgic_register_redist_iodev(struct kvm_vcpu *vcpu)
614 mutex_lock(&kvm->slots_lock); 614 mutex_lock(&kvm->slots_lock);
615 ret = kvm_io_bus_register_dev(kvm, KVM_MMIO_BUS, sgi_base, 615 ret = kvm_io_bus_register_dev(kvm, KVM_MMIO_BUS, sgi_base,
616 SZ_64K, &sgi_dev->dev); 616 SZ_64K, &sgi_dev->dev);
617 mutex_unlock(&kvm->slots_lock); 617 if (ret) {
618 if (ret)
619 kvm_io_bus_unregister_dev(kvm, KVM_MMIO_BUS, 618 kvm_io_bus_unregister_dev(kvm, KVM_MMIO_BUS,
620 &rd_dev->dev); 619 &rd_dev->dev);
620 goto out;
621 }
621 622
623 vgic->vgic_redist_free_offset += 2 * SZ_64K;
624out:
625 mutex_unlock(&kvm->slots_lock);
622 return ret; 626 return ret;
623} 627}
624 628
@@ -644,10 +648,12 @@ static int vgic_register_all_redist_iodevs(struct kvm *kvm)
644 648
645 if (ret) { 649 if (ret) {
646 /* The current c failed, so we start with the previous one. */ 650 /* The current c failed, so we start with the previous one. */
651 mutex_lock(&kvm->slots_lock);
647 for (c--; c >= 0; c--) { 652 for (c--; c >= 0; c--) {
648 vcpu = kvm_get_vcpu(kvm, c); 653 vcpu = kvm_get_vcpu(kvm, c);
649 vgic_unregister_redist_iodev(vcpu); 654 vgic_unregister_redist_iodev(vcpu);
650 } 655 }
656 mutex_unlock(&kvm->slots_lock);
651 } 657 }
652 658
653 return ret; 659 return ret;
diff --git a/virt/kvm/arm/vgic/vgic-v2.c b/virt/kvm/arm/vgic/vgic-v2.c
index a65757aab6d3..504b4bd0d651 100644
--- a/virt/kvm/arm/vgic/vgic-v2.c
+++ b/virt/kvm/arm/vgic/vgic-v2.c
@@ -149,6 +149,13 @@ void vgic_v2_populate_lr(struct kvm_vcpu *vcpu, struct vgic_irq *irq, int lr)
149 if (irq->hw) { 149 if (irq->hw) {
150 val |= GICH_LR_HW; 150 val |= GICH_LR_HW;
151 val |= irq->hwintid << GICH_LR_PHYSID_CPUID_SHIFT; 151 val |= irq->hwintid << GICH_LR_PHYSID_CPUID_SHIFT;
152 /*
153 * Never set pending+active on a HW interrupt, as the
154 * pending state is kept at the physical distributor
155 * level.
156 */
157 if (irq->active && irq_is_pending(irq))
158 val &= ~GICH_LR_PENDING_BIT;
152 } else { 159 } else {
153 if (irq->config == VGIC_CONFIG_LEVEL) 160 if (irq->config == VGIC_CONFIG_LEVEL)
154 val |= GICH_LR_EOI; 161 val |= GICH_LR_EOI;
diff --git a/virt/kvm/arm/vgic/vgic-v3.c b/virt/kvm/arm/vgic/vgic-v3.c
index 8fa737edde6f..6fe3f003636a 100644
--- a/virt/kvm/arm/vgic/vgic-v3.c
+++ b/virt/kvm/arm/vgic/vgic-v3.c
@@ -127,6 +127,13 @@ void vgic_v3_populate_lr(struct kvm_vcpu *vcpu, struct vgic_irq *irq, int lr)
127 if (irq->hw) { 127 if (irq->hw) {
128 val |= ICH_LR_HW; 128 val |= ICH_LR_HW;
129 val |= ((u64)irq->hwintid) << ICH_LR_PHYS_ID_SHIFT; 129 val |= ((u64)irq->hwintid) << ICH_LR_PHYS_ID_SHIFT;
130 /*
131 * Never set pending+active on a HW interrupt, as the
132 * pending state is kept at the physical distributor
133 * level.
134 */
135 if (irq->active && irq_is_pending(irq))
136 val &= ~ICH_LR_PENDING_BIT;
130 } else { 137 } else {
131 if (irq->config == VGIC_CONFIG_LEVEL) 138 if (irq->config == VGIC_CONFIG_LEVEL)
132 val |= ICH_LR_EOI; 139 val |= ICH_LR_EOI;