aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/devicetree/bindings/pinctrl/meson,pinctrl.txt38
-rw-r--r--Documentation/kernel-parameters.txt2
-rw-r--r--Documentation/usb/gadget_multi.txt2
-rw-r--r--Documentation/x86/protection-keys.txt27
-rw-r--r--MAINTAINERS2
-rw-r--r--Makefile2
-rw-r--r--arch/arm/boot/dts/am335x-baltos-ir5221.dts5
-rw-r--r--arch/arm/boot/dts/am4372.dtsi2
-rw-r--r--arch/arm/boot/dts/am43x-epos-evm.dts5
-rw-r--r--arch/arm/boot/dts/armada-385-linksys.dtsi2
-rw-r--r--arch/arm/boot/dts/meson8.dtsi57
-rw-r--r--arch/arm/boot/dts/meson8b.dtsi12
-rw-r--r--arch/arm/boot/dts/omap4.dtsi2
-rw-r--r--arch/arm/configs/u8500_defconfig3
-rw-r--r--arch/arm/kvm/arm.c13
-rw-r--r--arch/arm/mach-omap2/id.c4
-rw-r--r--arch/arm/mach-omap2/io.c1
-rw-r--r--arch/arm/mach-omap2/omap_hwmod.c8
-rw-r--r--arch/arm/mach-omap2/omap_hwmod_81xx_data.c2
-rw-r--r--arch/arm/mach-omap2/soc.h1
-rw-r--r--arch/arm/mach-pxa/devices.c1
-rw-r--r--arch/arm/mach-sa1100/Kconfig10
-rw-r--r--arch/arm/mach-uniphier/platsmp.c2
-rw-r--r--arch/arm64/boot/dts/broadcom/vulcan.dtsi15
-rw-r--r--arch/arm64/include/asm/kvm_arm.h6
-rw-r--r--arch/arm64/include/asm/kvm_asm.h2
-rw-r--r--arch/arm64/include/asm/kvm_host.h7
-rw-r--r--arch/arm64/kvm/hyp/s2-setup.c39
-rw-r--r--arch/m68k/coldfire/gpio.c8
-rw-r--r--arch/parisc/Kconfig4
-rw-r--r--arch/parisc/Kconfig.debug4
-rw-r--r--arch/parisc/Makefile4
-rw-r--r--arch/parisc/include/asm/ftrace.h18
-rw-r--r--arch/parisc/kernel/Makefile4
-rw-r--r--arch/parisc/kernel/entry.S93
-rw-r--r--arch/parisc/kernel/ftrace.c146
-rw-r--r--arch/parisc/kernel/head.S9
-rw-r--r--arch/sh/include/asm/smp.h5
-rw-r--r--arch/sh/include/asm/topology.h2
-rw-r--r--arch/sh/kernel/cpu/sh4a/smp-shx3.c2
-rw-r--r--arch/sh/kernel/topology.c4
-rw-r--r--arch/x86/boot/compressed/Makefile14
-rw-r--r--arch/x86/boot/compressed/head_32.S28
-rw-r--r--arch/x86/boot/compressed/head_64.S8
-rw-r--r--arch/x86/kernel/cpu/mcheck/mce-genpool.c4
-rw-r--r--arch/x86/kernel/setup.c37
-rw-r--r--arch/x86/kvm/cpuid.c1
-rw-r--r--arch/x86/kvm/mmu.h9
-rw-r--r--arch/x86/kvm/paging_tmpl.h2
-rw-r--r--arch/x86/kvm/x86.c10
-rw-r--r--block/partition-generic.c13
-rw-r--r--drivers/block/loop.c6
-rw-r--r--drivers/bus/mvebu-mbus.c2
-rw-r--r--drivers/bus/uniphier-system-bus.c2
-rw-r--r--drivers/char/hw_random/bcm63xx-rng.c1
-rw-r--r--drivers/dma/dw/core.c34
-rw-r--r--drivers/dma/edma.c63
-rw-r--r--drivers/dma/hsu/hsu.c13
-rw-r--r--drivers/dma/hsu/hsu.h3
-rw-r--r--drivers/dma/omap-dma.c26
-rw-r--r--drivers/dma/xilinx/xilinx_vdma.c2
-rw-r--r--drivers/extcon/extcon-palmas.c3
-rw-r--r--drivers/firmware/efi/arm-init.c18
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu.h1
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c2
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_object.c12
-rw-r--r--drivers/gpu/drm/amd/amdgpu/tonga_ih.c2
-rw-r--r--drivers/gpu/drm/drm_edid.c10
-rw-r--r--drivers/gpu/drm/exynos/Kconfig2
-rw-r--r--drivers/gpu/drm/exynos/Makefile6
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_core.c2
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_fb.c11
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_fbdev.c11
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_fbdev.h23
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_fimd.c2
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_mic.c3
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_plane.c12
-rw-r--r--drivers/gpu/drm/i915/i915_drv.c4
-rw-r--r--drivers/gpu/drm/i915/i915_irq.c4
-rw-r--r--drivers/gpu/drm/i915/intel_dp_mst.c6
-rw-r--r--drivers/gpu/drm/i915/intel_lvds.c5
-rw-r--r--drivers/gpu/drm/qxl/qxl_display.c13
-rw-r--r--drivers/gpu/drm/qxl/qxl_drv.h2
-rw-r--r--drivers/gpu/drm/radeon/ni_reg.h2
-rw-r--r--drivers/gpu/drm/radeon/radeon_dp_mst.c31
-rw-r--r--drivers/lguest/interrupts_and_traps.c6
-rw-r--r--drivers/lguest/lg.h1
-rw-r--r--drivers/lguest/x86/core.c6
-rw-r--r--drivers/mailbox/mailbox-test.c16
-rw-r--r--drivers/mailbox/mailbox-xgene-slimpro.c4
-rw-r--r--drivers/mailbox/mailbox.c4
-rw-r--r--drivers/md/dm-cache-metadata.c64
-rw-r--r--drivers/md/dm.c4
-rw-r--r--drivers/misc/lkdtm.c11
-rw-r--r--drivers/mmc/card/block.c18
-rw-r--r--drivers/mmc/host/sdhci-tegra.c10
-rw-r--r--drivers/mtd/nand/nand_base.c10
-rw-r--r--drivers/nvdimm/pmem.c14
-rw-r--r--drivers/nvme/host/pci.c31
-rw-r--r--drivers/pci/pci-sysfs.c2
-rw-r--r--drivers/pwm/pwm-fsl-ftm.c2
-rw-r--r--drivers/scsi/device_handler/scsi_dh_alua.c1
-rw-r--r--drivers/scsi/lpfc/lpfc_mem.c6
-rw-r--r--drivers/scsi/qla1280.c2
-rw-r--r--drivers/usb/class/cdc-acm.c4
-rw-r--r--drivers/usb/core/hcd-pci.c9
-rw-r--r--drivers/usb/host/xhci-mem.c6
-rw-r--r--drivers/usb/host/xhci-pci.c5
-rw-r--r--drivers/usb/host/xhci-plat.c13
-rw-r--r--drivers/usb/host/xhci-plat.h2
-rw-r--r--drivers/usb/host/xhci-ring.c3
-rw-r--r--drivers/usb/host/xhci.c24
-rw-r--r--drivers/usb/host/xhci.h2
-rw-r--r--drivers/usb/storage/uas.c21
-rw-r--r--drivers/usb/storage/unusual_uas.h7
-rw-r--r--drivers/usb/storage/usb.c5
-rw-r--r--fs/crypto/crypto.c51
-rw-r--r--fs/debugfs/inode.c2
-rw-r--r--fs/ext4/crypto.c4
-rw-r--r--fs/f2fs/data.c16
-rw-r--r--fs/f2fs/file.c10
-rw-r--r--fs/seq_file.c7
-rw-r--r--include/linux/fscrypto.h9
-rw-r--r--include/linux/mm.h64
-rw-r--r--include/linux/pmem.h22
-rw-r--r--include/linux/seq_file.h13
-rw-r--r--include/linux/usb_usual.h2
-rw-r--r--kernel/locking/lockdep.c2
-rw-r--r--kernel/resource.c13
-rw-r--r--lib/assoc_array.c4
-rw-r--r--lib/lz4/lz4defs.h25
-rw-r--r--mm/backing-dev.c4
-rw-r--r--mm/gup.c52
-rw-r--r--mm/nommu.c44
-rw-r--r--net/sunrpc/auth_gss/gss_krb5_crypto.c8
-rw-r--r--net/sunrpc/auth_gss/gss_krb5_mech.c3
-rw-r--r--scripts/asn1_compiler.c2
-rw-r--r--sound/hda/hdac_i915.c15
-rw-r--r--sound/isa/sscape.c2
-rw-r--r--sound/pci/hda/patch_hdmi.c9
-rw-r--r--sound/pci/hda/patch_realtek.c10
-rw-r--r--sound/usb/mixer_maps.c14
-rw-r--r--sound/usb/quirks.c2
-rw-r--r--virt/kvm/arm/arch_timer.c49
-rw-r--r--virt/kvm/arm/pmu.c3
145 files changed, 1040 insertions, 774 deletions
diff --git a/Documentation/devicetree/bindings/pinctrl/meson,pinctrl.txt b/Documentation/devicetree/bindings/pinctrl/meson,pinctrl.txt
index 3f6a524cc5ff..32f4a2d6d0b3 100644
--- a/Documentation/devicetree/bindings/pinctrl/meson,pinctrl.txt
+++ b/Documentation/devicetree/bindings/pinctrl/meson,pinctrl.txt
@@ -1,13 +1,16 @@
1== Amlogic Meson pinmux controller == 1== Amlogic Meson pinmux controller ==
2 2
3Required properties for the root node: 3Required properties for the root node:
4 - compatible: "amlogic,meson8-pinctrl" or "amlogic,meson8b-pinctrl" 4 - compatible: one of "amlogic,meson8-cbus-pinctrl"
5 "amlogic,meson8b-cbus-pinctrl"
6 "amlogic,meson8-aobus-pinctrl"
7 "amlogic,meson8b-aobus-pinctrl"
5 - reg: address and size of registers controlling irq functionality 8 - reg: address and size of registers controlling irq functionality
6 9
7=== GPIO sub-nodes === 10=== GPIO sub-nodes ===
8 11
9The 2 power domains of the controller (regular and always-on) are 12The GPIO bank for the controller is represented as a sub-node and it acts as a
10represented as sub-nodes and each of them acts as a GPIO controller. 13GPIO controller.
11 14
12Required properties for sub-nodes are: 15Required properties for sub-nodes are:
13 - reg: should contain address and size for mux, pull-enable, pull and 16 - reg: should contain address and size for mux, pull-enable, pull and
@@ -18,10 +21,6 @@ Required properties for sub-nodes are:
18 - gpio-controller: identifies the node as a gpio controller 21 - gpio-controller: identifies the node as a gpio controller
19 - #gpio-cells: must be 2 22 - #gpio-cells: must be 2
20 23
21Valid sub-node names are:
22 - "banks" for the regular domain
23 - "ao-bank" for the always-on domain
24
25=== Other sub-nodes === 24=== Other sub-nodes ===
26 25
27Child nodes without the "gpio-controller" represent some desired 26Child nodes without the "gpio-controller" represent some desired
@@ -45,7 +44,7 @@ pinctrl-bindings.txt
45=== Example === 44=== Example ===
46 45
47 pinctrl: pinctrl@c1109880 { 46 pinctrl: pinctrl@c1109880 {
48 compatible = "amlogic,meson8-pinctrl"; 47 compatible = "amlogic,meson8-cbus-pinctrl";
49 reg = <0xc1109880 0x10>; 48 reg = <0xc1109880 0x10>;
50 #address-cells = <1>; 49 #address-cells = <1>;
51 #size-cells = <1>; 50 #size-cells = <1>;
@@ -61,15 +60,6 @@ pinctrl-bindings.txt
61 #gpio-cells = <2>; 60 #gpio-cells = <2>;
62 }; 61 };
63 62
64 gpio_ao: ao-bank@c1108030 {
65 reg = <0xc8100014 0x4>,
66 <0xc810002c 0x4>,
67 <0xc8100024 0x8>;
68 reg-names = "mux", "pull", "gpio";
69 gpio-controller;
70 #gpio-cells = <2>;
71 };
72
73 nand { 63 nand {
74 mux { 64 mux {
75 groups = "nand_io", "nand_io_ce0", "nand_io_ce1", 65 groups = "nand_io", "nand_io_ce0", "nand_io_ce1",
@@ -79,18 +69,4 @@ pinctrl-bindings.txt
79 function = "nand"; 69 function = "nand";
80 }; 70 };
81 }; 71 };
82
83 uart_ao_a {
84 mux {
85 groups = "uart_tx_ao_a", "uart_rx_ao_a",
86 "uart_cts_ao_a", "uart_rts_ao_a";
87 function = "uart_ao";
88 };
89
90 conf {
91 pins = "GPIOAO_0", "GPIOAO_1",
92 "GPIOAO_2", "GPIOAO_3";
93 bias-disable;
94 };
95 };
96 }; 72 };
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index ecc74fa4bfde..0b3de80ec8f6 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -4077,6 +4077,8 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
4077 sector if the number is odd); 4077 sector if the number is odd);
4078 i = IGNORE_DEVICE (don't bind to this 4078 i = IGNORE_DEVICE (don't bind to this
4079 device); 4079 device);
4080 j = NO_REPORT_LUNS (don't use report luns
4081 command, uas only);
4080 l = NOT_LOCKABLE (don't try to lock and 4082 l = NOT_LOCKABLE (don't try to lock and
4081 unlock ejectable media); 4083 unlock ejectable media);
4082 m = MAX_SECTORS_64 (don't transfer more 4084 m = MAX_SECTORS_64 (don't transfer more
diff --git a/Documentation/usb/gadget_multi.txt b/Documentation/usb/gadget_multi.txt
index 7d66a8636cb5..5faf514047e9 100644
--- a/Documentation/usb/gadget_multi.txt
+++ b/Documentation/usb/gadget_multi.txt
@@ -43,7 +43,7 @@ For the gadget two work under Windows two conditions have to be met:
43First of all, Windows need to detect the gadget as an USB composite 43First of all, Windows need to detect the gadget as an USB composite
44gadget which on its own have some conditions[4]. If they are met, 44gadget which on its own have some conditions[4]. If they are met,
45Windows lets USB Generic Parent Driver[5] handle the device which then 45Windows lets USB Generic Parent Driver[5] handle the device which then
46tries to much drivers for each individual interface (sort of, don't 46tries to match drivers for each individual interface (sort of, don't
47get into too many details). 47get into too many details).
48 48
49The good news is: you do not have to worry about most of the 49The good news is: you do not have to worry about most of the
diff --git a/Documentation/x86/protection-keys.txt b/Documentation/x86/protection-keys.txt
new file mode 100644
index 000000000000..c281ded1ba16
--- /dev/null
+++ b/Documentation/x86/protection-keys.txt
@@ -0,0 +1,27 @@
1Memory Protection Keys for Userspace (PKU aka PKEYs) is a CPU feature
2which will be found on future Intel CPUs.
3
4Memory Protection Keys provides a mechanism for enforcing page-based
5protections, but without requiring modification of the page tables
6when an application changes protection domains. It works by
7dedicating 4 previously ignored bits in each page table entry to a
8"protection key", giving 16 possible keys.
9
10There is also a new user-accessible register (PKRU) with two separate
11bits (Access Disable and Write Disable) for each key. Being a CPU
12register, PKRU is inherently thread-local, potentially giving each
13thread a different set of protections from every other thread.
14
15There are two new instructions (RDPKRU/WRPKRU) for reading and writing
16to the new register. The feature is only available in 64-bit mode,
17even though there is theoretically space in the PAE PTEs. These
18permissions are enforced on data access only and have no effect on
19instruction fetches.
20
21=========================== Config Option ===========================
22
23This config option adds approximately 1.5kb of text. and 50 bytes of
24data to the executable. A workload which does large O_DIRECT reads
25of holes in XFS files was run to exercise get_user_pages_fast(). No
26performance delta was observed with the config option
27enabled or disabled.
diff --git a/MAINTAINERS b/MAINTAINERS
index a87defae88c8..078168c4ba9a 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -6252,8 +6252,8 @@ S: Maintained
6252F: tools/testing/selftests 6252F: tools/testing/selftests
6253 6253
6254KERNEL VIRTUAL MACHINE (KVM) 6254KERNEL VIRTUAL MACHINE (KVM)
6255M: Gleb Natapov <gleb@kernel.org>
6256M: Paolo Bonzini <pbonzini@redhat.com> 6255M: Paolo Bonzini <pbonzini@redhat.com>
6256M: Radim Krčmář <rkrcmar@redhat.com>
6257L: kvm@vger.kernel.org 6257L: kvm@vger.kernel.org
6258W: http://www.linux-kvm.org 6258W: http://www.linux-kvm.org
6259T: git git://git.kernel.org/pub/scm/virt/kvm/kvm.git 6259T: git git://git.kernel.org/pub/scm/virt/kvm/kvm.git
diff --git a/Makefile b/Makefile
index 1d0aef03eae7..873411873c03 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
1VERSION = 4 1VERSION = 4
2PATCHLEVEL = 6 2PATCHLEVEL = 6
3SUBLEVEL = 0 3SUBLEVEL = 0
4EXTRAVERSION = -rc3 4EXTRAVERSION = -rc4
5NAME = Blurry Fish Butt 5NAME = Blurry Fish Butt
6 6
7# *DOCUMENTATION* 7# *DOCUMENTATION*
diff --git a/arch/arm/boot/dts/am335x-baltos-ir5221.dts b/arch/arm/boot/dts/am335x-baltos-ir5221.dts
index 6c667fb35449..4e28d87e9356 100644
--- a/arch/arm/boot/dts/am335x-baltos-ir5221.dts
+++ b/arch/arm/boot/dts/am335x-baltos-ir5221.dts
@@ -470,9 +470,12 @@
470}; 470};
471 471
472&cpsw_emac0 { 472&cpsw_emac0 {
473 phy_id = <&davinci_mdio>, <0>;
474 phy-mode = "rmii"; 473 phy-mode = "rmii";
475 dual_emac_res_vlan = <1>; 474 dual_emac_res_vlan = <1>;
475 fixed-link {
476 speed = <100>;
477 full-duplex;
478 };
476}; 479};
477 480
478&cpsw_emac1 { 481&cpsw_emac1 {
diff --git a/arch/arm/boot/dts/am4372.dtsi b/arch/arm/boot/dts/am4372.dtsi
index 6e4f5af3d8f8..344b861a55a5 100644
--- a/arch/arm/boot/dts/am4372.dtsi
+++ b/arch/arm/boot/dts/am4372.dtsi
@@ -207,7 +207,7 @@
207 ti,tptcs = <&edma_tptc0 7>, <&edma_tptc1 5>, 207 ti,tptcs = <&edma_tptc0 7>, <&edma_tptc1 5>,
208 <&edma_tptc2 0>; 208 <&edma_tptc2 0>;
209 209
210 ti,edma-memcpy-channels = <32 33>; 210 ti,edma-memcpy-channels = <58 59>;
211 }; 211 };
212 212
213 edma_tptc0: tptc@49800000 { 213 edma_tptc0: tptc@49800000 {
diff --git a/arch/arm/boot/dts/am43x-epos-evm.dts b/arch/arm/boot/dts/am43x-epos-evm.dts
index 83dfafaaba1b..d5dd72047a7e 100644
--- a/arch/arm/boot/dts/am43x-epos-evm.dts
+++ b/arch/arm/boot/dts/am43x-epos-evm.dts
@@ -794,3 +794,8 @@
794 tx-num-evt = <32>; 794 tx-num-evt = <32>;
795 rx-num-evt = <32>; 795 rx-num-evt = <32>;
796}; 796};
797
798&synctimer_32kclk {
799 assigned-clocks = <&mux_synctimer32k_ck>;
800 assigned-clock-parents = <&clkdiv32k_ick>;
801};
diff --git a/arch/arm/boot/dts/armada-385-linksys.dtsi b/arch/arm/boot/dts/armada-385-linksys.dtsi
index 3710755c6d76..85d2c377c332 100644
--- a/arch/arm/boot/dts/armada-385-linksys.dtsi
+++ b/arch/arm/boot/dts/armada-385-linksys.dtsi
@@ -117,7 +117,7 @@
117 }; 117 };
118 118
119 /* USB part of the eSATA/USB 2.0 port */ 119 /* USB part of the eSATA/USB 2.0 port */
120 usb@50000 { 120 usb@58000 {
121 status = "okay"; 121 status = "okay";
122 }; 122 };
123 123
diff --git a/arch/arm/boot/dts/meson8.dtsi b/arch/arm/boot/dts/meson8.dtsi
index a2ddcb8c545a..45619f6162c5 100644
--- a/arch/arm/boot/dts/meson8.dtsi
+++ b/arch/arm/boot/dts/meson8.dtsi
@@ -91,8 +91,8 @@
91 clock-frequency = <141666666>; 91 clock-frequency = <141666666>;
92 }; 92 };
93 93
94 pinctrl: pinctrl@c1109880 { 94 pinctrl_cbus: pinctrl@c1109880 {
95 compatible = "amlogic,meson8-pinctrl"; 95 compatible = "amlogic,meson8-cbus-pinctrl";
96 reg = <0xc1109880 0x10>; 96 reg = <0xc1109880 0x10>;
97 #address-cells = <1>; 97 #address-cells = <1>;
98 #size-cells = <1>; 98 #size-cells = <1>;
@@ -108,29 +108,6 @@
108 #gpio-cells = <2>; 108 #gpio-cells = <2>;
109 }; 109 };
110 110
111 gpio_ao: ao-bank@c1108030 {
112 reg = <0xc8100014 0x4>,
113 <0xc810002c 0x4>,
114 <0xc8100024 0x8>;
115 reg-names = "mux", "pull", "gpio";
116 gpio-controller;
117 #gpio-cells = <2>;
118 };
119
120 uart_ao_a_pins: uart_ao_a {
121 mux {
122 groups = "uart_tx_ao_a", "uart_rx_ao_a";
123 function = "uart_ao";
124 };
125 };
126
127 i2c_ao_pins: i2c_mst_ao {
128 mux {
129 groups = "i2c_mst_sck_ao", "i2c_mst_sda_ao";
130 function = "i2c_mst_ao";
131 };
132 };
133
134 spi_nor_pins: nor { 111 spi_nor_pins: nor {
135 mux { 112 mux {
136 groups = "nor_d", "nor_q", "nor_c", "nor_cs"; 113 groups = "nor_d", "nor_q", "nor_c", "nor_cs";
@@ -157,4 +134,34 @@
157 }; 134 };
158 }; 135 };
159 136
137 pinctrl_aobus: pinctrl@c8100084 {
138 compatible = "amlogic,meson8-aobus-pinctrl";
139 reg = <0xc8100084 0xc>;
140 #address-cells = <1>;
141 #size-cells = <1>;
142 ranges;
143
144 gpio_ao: ao-bank@c1108030 {
145 reg = <0xc8100014 0x4>,
146 <0xc810002c 0x4>,
147 <0xc8100024 0x8>;
148 reg-names = "mux", "pull", "gpio";
149 gpio-controller;
150 #gpio-cells = <2>;
151 };
152
153 uart_ao_a_pins: uart_ao_a {
154 mux {
155 groups = "uart_tx_ao_a", "uart_rx_ao_a";
156 function = "uart_ao";
157 };
158 };
159
160 i2c_ao_pins: i2c_mst_ao {
161 mux {
162 groups = "i2c_mst_sck_ao", "i2c_mst_sda_ao";
163 function = "i2c_mst_ao";
164 };
165 };
166 };
160}; /* end of / */ 167}; /* end of / */
diff --git a/arch/arm/boot/dts/meson8b.dtsi b/arch/arm/boot/dts/meson8b.dtsi
index 8bad5571af46..2bfe401a4da9 100644
--- a/arch/arm/boot/dts/meson8b.dtsi
+++ b/arch/arm/boot/dts/meson8b.dtsi
@@ -155,8 +155,8 @@
155 reg = <0xc1108000 0x4>, <0xc1104000 0x460>; 155 reg = <0xc1108000 0x4>, <0xc1104000 0x460>;
156 }; 156 };
157 157
158 pinctrl: pinctrl@c1109880 { 158 pinctrl_cbus: pinctrl@c1109880 {
159 compatible = "amlogic,meson8b-pinctrl"; 159 compatible = "amlogic,meson8b-cbus-pinctrl";
160 reg = <0xc1109880 0x10>; 160 reg = <0xc1109880 0x10>;
161 #address-cells = <1>; 161 #address-cells = <1>;
162 #size-cells = <1>; 162 #size-cells = <1>;
@@ -171,6 +171,14 @@
171 gpio-controller; 171 gpio-controller;
172 #gpio-cells = <2>; 172 #gpio-cells = <2>;
173 }; 173 };
174 };
175
176 pinctrl_aobus: pinctrl@c8100084 {
177 compatible = "amlogic,meson8b-aobus-pinctrl";
178 reg = <0xc8100084 0xc>;
179 #address-cells = <1>;
180 #size-cells = <1>;
181 ranges;
174 182
175 gpio_ao: ao-bank@c1108030 { 183 gpio_ao: ao-bank@c1108030 {
176 reg = <0xc8100014 0x4>, 184 reg = <0xc8100014 0x4>,
diff --git a/arch/arm/boot/dts/omap4.dtsi b/arch/arm/boot/dts/omap4.dtsi
index 2bd9c83300b2..421fe9f8a9eb 100644
--- a/arch/arm/boot/dts/omap4.dtsi
+++ b/arch/arm/boot/dts/omap4.dtsi
@@ -70,7 +70,7 @@
70 compatible = "arm,cortex-a9-twd-timer"; 70 compatible = "arm,cortex-a9-twd-timer";
71 clocks = <&mpu_periphclk>; 71 clocks = <&mpu_periphclk>;
72 reg = <0x48240600 0x20>; 72 reg = <0x48240600 0x20>;
73 interrupts = <GIC_PPI 13 (GIC_CPU_MASK_RAW(3) | IRQ_TYPE_LEVEL_HIGH)>; 73 interrupts = <GIC_PPI 13 (GIC_CPU_MASK_RAW(3) | IRQ_TYPE_EDGE_RISING)>;
74 interrupt-parent = <&gic>; 74 interrupt-parent = <&gic>;
75 }; 75 };
76 76
diff --git a/arch/arm/configs/u8500_defconfig b/arch/arm/configs/u8500_defconfig
index 07055eacbb0f..a691d590fbd1 100644
--- a/arch/arm/configs/u8500_defconfig
+++ b/arch/arm/configs/u8500_defconfig
@@ -63,6 +63,9 @@ CONFIG_INPUT_TOUCHSCREEN=y
63CONFIG_TOUCHSCREEN_BU21013=y 63CONFIG_TOUCHSCREEN_BU21013=y
64CONFIG_INPUT_MISC=y 64CONFIG_INPUT_MISC=y
65CONFIG_INPUT_AB8500_PONKEY=y 65CONFIG_INPUT_AB8500_PONKEY=y
66CONFIG_RMI4_CORE=y
67CONFIG_RMI4_I2C=y
68CONFIG_RMI4_F11=y
66# CONFIG_SERIO is not set 69# CONFIG_SERIO is not set
67CONFIG_VT_HW_CONSOLE_BINDING=y 70CONFIG_VT_HW_CONSOLE_BINDING=y
68# CONFIG_LEGACY_PTYS is not set 71# CONFIG_LEGACY_PTYS is not set
diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
index b5384311dec4..dded1b763c16 100644
--- a/arch/arm/kvm/arm.c
+++ b/arch/arm/kvm/arm.c
@@ -1112,10 +1112,17 @@ static void __init hyp_cpu_pm_init(void)
1112{ 1112{
1113 cpu_pm_register_notifier(&hyp_init_cpu_pm_nb); 1113 cpu_pm_register_notifier(&hyp_init_cpu_pm_nb);
1114} 1114}
1115static void __init hyp_cpu_pm_exit(void)
1116{
1117 cpu_pm_unregister_notifier(&hyp_init_cpu_pm_nb);
1118}
1115#else 1119#else
1116static inline void hyp_cpu_pm_init(void) 1120static inline void hyp_cpu_pm_init(void)
1117{ 1121{
1118} 1122}
1123static inline void hyp_cpu_pm_exit(void)
1124{
1125}
1119#endif 1126#endif
1120 1127
1121static void teardown_common_resources(void) 1128static void teardown_common_resources(void)
@@ -1141,9 +1148,7 @@ static int init_subsystems(void)
1141 /* 1148 /*
1142 * Register CPU Hotplug notifier 1149 * Register CPU Hotplug notifier
1143 */ 1150 */
1144 cpu_notifier_register_begin(); 1151 err = register_cpu_notifier(&hyp_init_cpu_nb);
1145 err = __register_cpu_notifier(&hyp_init_cpu_nb);
1146 cpu_notifier_register_done();
1147 if (err) { 1152 if (err) {
1148 kvm_err("Cannot register KVM init CPU notifier (%d)\n", err); 1153 kvm_err("Cannot register KVM init CPU notifier (%d)\n", err);
1149 return err; 1154 return err;
@@ -1193,6 +1198,8 @@ static void teardown_hyp_mode(void)
1193 free_hyp_pgds(); 1198 free_hyp_pgds();
1194 for_each_possible_cpu(cpu) 1199 for_each_possible_cpu(cpu)
1195 free_page(per_cpu(kvm_arm_hyp_stack_page, cpu)); 1200 free_page(per_cpu(kvm_arm_hyp_stack_page, cpu));
1201 unregister_cpu_notifier(&hyp_init_cpu_nb);
1202 hyp_cpu_pm_exit();
1196} 1203}
1197 1204
1198static int init_vhe_mode(void) 1205static int init_vhe_mode(void)
diff --git a/arch/arm/mach-omap2/id.c b/arch/arm/mach-omap2/id.c
index d85c24918c17..2abd53ae3e7a 100644
--- a/arch/arm/mach-omap2/id.c
+++ b/arch/arm/mach-omap2/id.c
@@ -669,9 +669,9 @@ void __init dra7xxx_check_revision(void)
669 case 0: 669 case 0:
670 omap_revision = DRA722_REV_ES1_0; 670 omap_revision = DRA722_REV_ES1_0;
671 break; 671 break;
672 case 1:
672 default: 673 default:
673 /* If we have no new revisions */ 674 omap_revision = DRA722_REV_ES2_0;
674 omap_revision = DRA722_REV_ES1_0;
675 break; 675 break;
676 } 676 }
677 break; 677 break;
diff --git a/arch/arm/mach-omap2/io.c b/arch/arm/mach-omap2/io.c
index 3c87e40650cf..9821be6dfd5e 100644
--- a/arch/arm/mach-omap2/io.c
+++ b/arch/arm/mach-omap2/io.c
@@ -368,6 +368,7 @@ void __init omap5_map_io(void)
368void __init dra7xx_map_io(void) 368void __init dra7xx_map_io(void)
369{ 369{
370 iotable_init(dra7xx_io_desc, ARRAY_SIZE(dra7xx_io_desc)); 370 iotable_init(dra7xx_io_desc, ARRAY_SIZE(dra7xx_io_desc));
371 omap_barriers_init();
371} 372}
372#endif 373#endif
373/* 374/*
diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index b6d62e4cdfdd..2af6ff63e3b4 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -1416,9 +1416,7 @@ static void _enable_sysc(struct omap_hwmod *oh)
1416 (sf & SYSC_HAS_CLOCKACTIVITY)) 1416 (sf & SYSC_HAS_CLOCKACTIVITY))
1417 _set_clockactivity(oh, oh->class->sysc->clockact, &v); 1417 _set_clockactivity(oh, oh->class->sysc->clockact, &v);
1418 1418
1419 /* If the cached value is the same as the new value, skip the write */ 1419 _write_sysconfig(v, oh);
1420 if (oh->_sysc_cache != v)
1421 _write_sysconfig(v, oh);
1422 1420
1423 /* 1421 /*
1424 * Set the autoidle bit only after setting the smartidle bit 1422 * Set the autoidle bit only after setting the smartidle bit
@@ -1481,7 +1479,9 @@ static void _idle_sysc(struct omap_hwmod *oh)
1481 _set_master_standbymode(oh, idlemode, &v); 1479 _set_master_standbymode(oh, idlemode, &v);
1482 } 1480 }
1483 1481
1484 _write_sysconfig(v, oh); 1482 /* If the cached value is the same as the new value, skip the write */
1483 if (oh->_sysc_cache != v)
1484 _write_sysconfig(v, oh);
1485} 1485}
1486 1486
1487/** 1487/**
diff --git a/arch/arm/mach-omap2/omap_hwmod_81xx_data.c b/arch/arm/mach-omap2/omap_hwmod_81xx_data.c
index 39736ad2a754..df8327713d06 100644
--- a/arch/arm/mach-omap2/omap_hwmod_81xx_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_81xx_data.c
@@ -582,9 +582,11 @@ static struct omap_hwmod_ocp_if dm81xx_alwon_l3_slow__gpmc = {
582 .user = OCP_USER_MPU, 582 .user = OCP_USER_MPU,
583}; 583};
584 584
585/* USB needs udelay 1 after reset at least on hp t410, use 2 for margin */
585static struct omap_hwmod_class_sysconfig dm81xx_usbhsotg_sysc = { 586static struct omap_hwmod_class_sysconfig dm81xx_usbhsotg_sysc = {
586 .rev_offs = 0x0, 587 .rev_offs = 0x0,
587 .sysc_offs = 0x10, 588 .sysc_offs = 0x10,
589 .srst_udelay = 2,
588 .sysc_flags = SYSC_HAS_SIDLEMODE | SYSC_HAS_MIDLEMODE | 590 .sysc_flags = SYSC_HAS_SIDLEMODE | SYSC_HAS_MIDLEMODE |
589 SYSC_HAS_SOFTRESET, 591 SYSC_HAS_SOFTRESET,
590 .idlemodes = SIDLE_SMART | MSTANDBY_FORCE | MSTANDBY_SMART, 592 .idlemodes = SIDLE_SMART | MSTANDBY_FORCE | MSTANDBY_SMART,
diff --git a/arch/arm/mach-omap2/soc.h b/arch/arm/mach-omap2/soc.h
index 70df8f6cddcc..364418c78bf3 100644
--- a/arch/arm/mach-omap2/soc.h
+++ b/arch/arm/mach-omap2/soc.h
@@ -489,6 +489,7 @@ IS_OMAP_TYPE(3430, 0x3430)
489#define DRA752_REV_ES2_0 (DRA7XX_CLASS | (0x52 << 16) | (0x20 << 8)) 489#define DRA752_REV_ES2_0 (DRA7XX_CLASS | (0x52 << 16) | (0x20 << 8))
490#define DRA722_REV_ES1_0 (DRA7XX_CLASS | (0x22 << 16) | (0x10 << 8)) 490#define DRA722_REV_ES1_0 (DRA7XX_CLASS | (0x22 << 16) | (0x10 << 8))
491#define DRA722_REV_ES1_0 (DRA7XX_CLASS | (0x22 << 16) | (0x10 << 8)) 491#define DRA722_REV_ES1_0 (DRA7XX_CLASS | (0x22 << 16) | (0x10 << 8))
492#define DRA722_REV_ES2_0 (DRA7XX_CLASS | (0x22 << 16) | (0x20 << 8))
492 493
493void omap2xxx_check_revision(void); 494void omap2xxx_check_revision(void);
494void omap3xxx_check_revision(void); 495void omap3xxx_check_revision(void);
diff --git a/arch/arm/mach-pxa/devices.c b/arch/arm/mach-pxa/devices.c
index 913a319c7b00..fffb697bbf0e 100644
--- a/arch/arm/mach-pxa/devices.c
+++ b/arch/arm/mach-pxa/devices.c
@@ -1235,5 +1235,6 @@ static struct platform_device pxa2xx_pxa_dma = {
1235void __init pxa2xx_set_dmac_info(int nb_channels, int nb_requestors) 1235void __init pxa2xx_set_dmac_info(int nb_channels, int nb_requestors)
1236{ 1236{
1237 pxa_dma_pdata.dma_channels = nb_channels; 1237 pxa_dma_pdata.dma_channels = nb_channels;
1238 pxa_dma_pdata.nb_requestors = nb_requestors;
1238 pxa_register_device(&pxa2xx_pxa_dma, &pxa_dma_pdata); 1239 pxa_register_device(&pxa2xx_pxa_dma, &pxa_dma_pdata);
1239} 1240}
diff --git a/arch/arm/mach-sa1100/Kconfig b/arch/arm/mach-sa1100/Kconfig
index c6f6ed1cbed0..36e3c79f4973 100644
--- a/arch/arm/mach-sa1100/Kconfig
+++ b/arch/arm/mach-sa1100/Kconfig
@@ -61,10 +61,7 @@ config SA1100_H3100
61 select MFD_IPAQ_MICRO 61 select MFD_IPAQ_MICRO
62 help 62 help
63 Say Y here if you intend to run this kernel on the Compaq iPAQ 63 Say Y here if you intend to run this kernel on the Compaq iPAQ
64 H3100 handheld computer. Information about this machine and the 64 H3100 handheld computer.
65 Linux port to this machine can be found at:
66
67 <http://www.handhelds.org/Compaq/index.html#iPAQ_H3100>
68 65
69config SA1100_H3600 66config SA1100_H3600
70 bool "Compaq iPAQ H3600/H3700" 67 bool "Compaq iPAQ H3600/H3700"
@@ -73,10 +70,7 @@ config SA1100_H3600
73 select MFD_IPAQ_MICRO 70 select MFD_IPAQ_MICRO
74 help 71 help
75 Say Y here if you intend to run this kernel on the Compaq iPAQ 72 Say Y here if you intend to run this kernel on the Compaq iPAQ
76 H3600 handheld computer. Information about this machine and the 73 H3600 and H3700 handheld computers.
77 Linux port to this machine can be found at:
78
79 <http://www.handhelds.org/Compaq/index.html#iPAQ_H3600>
80 74
81config SA1100_BADGE4 75config SA1100_BADGE4
82 bool "HP Labs BadgePAD 4" 76 bool "HP Labs BadgePAD 4"
diff --git a/arch/arm/mach-uniphier/platsmp.c b/arch/arm/mach-uniphier/platsmp.c
index 69141357afe8..db04142f88bc 100644
--- a/arch/arm/mach-uniphier/platsmp.c
+++ b/arch/arm/mach-uniphier/platsmp.c
@@ -120,7 +120,7 @@ static int __init uniphier_smp_prepare_trampoline(unsigned int max_cpus)
120 if (ret) 120 if (ret)
121 return ret; 121 return ret;
122 122
123 uniphier_smp_rom_boot_rsv2 = ioremap(rom_rsv2_phys, sizeof(SZ_4)); 123 uniphier_smp_rom_boot_rsv2 = ioremap(rom_rsv2_phys, SZ_4);
124 if (!uniphier_smp_rom_boot_rsv2) { 124 if (!uniphier_smp_rom_boot_rsv2) {
125 pr_err("failed to map ROM_BOOT_RSV2 register\n"); 125 pr_err("failed to map ROM_BOOT_RSV2 register\n");
126 return -ENOMEM; 126 return -ENOMEM;
diff --git a/arch/arm64/boot/dts/broadcom/vulcan.dtsi b/arch/arm64/boot/dts/broadcom/vulcan.dtsi
index c49b5a85809c..85820e2bca9d 100644
--- a/arch/arm64/boot/dts/broadcom/vulcan.dtsi
+++ b/arch/arm64/boot/dts/broadcom/vulcan.dtsi
@@ -108,12 +108,15 @@
108 reg = <0x0 0x30000000 0x0 0x10000000>; 108 reg = <0x0 0x30000000 0x0 0x10000000>;
109 reg-names = "PCI ECAM"; 109 reg-names = "PCI ECAM";
110 110
111 /* IO 0x4000_0000 - 0x4001_0000 */ 111 /*
112 ranges = <0x01000000 0 0x40000000 0 0x40000000 0 0x00010000 112 * PCI ranges:
113 /* MEM 0x4800_0000 - 0x5000_0000 */ 113 * IO no supported
114 0x02000000 0 0x48000000 0 0x48000000 0 0x08000000 114 * MEM 0x4000_0000 - 0x6000_0000
115 /* MEM64 pref 0x6_0000_0000 - 0x7_0000_0000 */ 115 * MEM64 pref 0x40_0000_0000 - 0x60_0000_0000
116 0x43000000 6 0x00000000 6 0x00000000 1 0x00000000>; 116 */
117 ranges =
118 <0x02000000 0 0x40000000 0 0x40000000 0 0x20000000
119 0x43000000 0x40 0x00000000 0x40 0x00000000 0x20 0x00000000>;
117 interrupt-map-mask = <0 0 0 7>; 120 interrupt-map-mask = <0 0 0 7>;
118 interrupt-map = 121 interrupt-map =
119 /* addr pin ic icaddr icintr */ 122 /* addr pin ic icaddr icintr */
diff --git a/arch/arm64/include/asm/kvm_arm.h b/arch/arm64/include/asm/kvm_arm.h
index 4150fd8bae01..3f29887995bc 100644
--- a/arch/arm64/include/asm/kvm_arm.h
+++ b/arch/arm64/include/asm/kvm_arm.h
@@ -151,8 +151,7 @@
151 */ 151 */
152#define VTCR_EL2_FLAGS (VTCR_EL2_TG0_64K | VTCR_EL2_SH0_INNER | \ 152#define VTCR_EL2_FLAGS (VTCR_EL2_TG0_64K | VTCR_EL2_SH0_INNER | \
153 VTCR_EL2_ORGN0_WBWA | VTCR_EL2_IRGN0_WBWA | \ 153 VTCR_EL2_ORGN0_WBWA | VTCR_EL2_IRGN0_WBWA | \
154 VTCR_EL2_SL0_LVL1 | VTCR_EL2_T0SZ_40B | \ 154 VTCR_EL2_SL0_LVL1 | VTCR_EL2_RES1)
155 VTCR_EL2_RES1)
156#define VTTBR_X (38 - VTCR_EL2_T0SZ_40B) 155#define VTTBR_X (38 - VTCR_EL2_T0SZ_40B)
157#else 156#else
158/* 157/*
@@ -163,8 +162,7 @@
163 */ 162 */
164#define VTCR_EL2_FLAGS (VTCR_EL2_TG0_4K | VTCR_EL2_SH0_INNER | \ 163#define VTCR_EL2_FLAGS (VTCR_EL2_TG0_4K | VTCR_EL2_SH0_INNER | \
165 VTCR_EL2_ORGN0_WBWA | VTCR_EL2_IRGN0_WBWA | \ 164 VTCR_EL2_ORGN0_WBWA | VTCR_EL2_IRGN0_WBWA | \
166 VTCR_EL2_SL0_LVL1 | VTCR_EL2_T0SZ_40B | \ 165 VTCR_EL2_SL0_LVL1 | VTCR_EL2_RES1)
167 VTCR_EL2_RES1)
168#define VTTBR_X (37 - VTCR_EL2_T0SZ_40B) 166#define VTTBR_X (37 - VTCR_EL2_T0SZ_40B)
169#endif 167#endif
170 168
diff --git a/arch/arm64/include/asm/kvm_asm.h b/arch/arm64/include/asm/kvm_asm.h
index eb7490d232a0..40a0a24e6c98 100644
--- a/arch/arm64/include/asm/kvm_asm.h
+++ b/arch/arm64/include/asm/kvm_asm.h
@@ -54,7 +54,7 @@ extern void __vgic_v3_init_lrs(void);
54 54
55extern u32 __kvm_get_mdcr_el2(void); 55extern u32 __kvm_get_mdcr_el2(void);
56 56
57extern void __init_stage2_translation(void); 57extern u32 __init_stage2_translation(void);
58 58
59#endif 59#endif
60 60
diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h
index b7e82a795ac9..f5c6bd2541ef 100644
--- a/arch/arm64/include/asm/kvm_host.h
+++ b/arch/arm64/include/asm/kvm_host.h
@@ -369,11 +369,12 @@ int kvm_arm_vcpu_arch_get_attr(struct kvm_vcpu *vcpu,
369int kvm_arm_vcpu_arch_has_attr(struct kvm_vcpu *vcpu, 369int kvm_arm_vcpu_arch_has_attr(struct kvm_vcpu *vcpu,
370 struct kvm_device_attr *attr); 370 struct kvm_device_attr *attr);
371 371
372/* #define kvm_call_hyp(f, ...) __kvm_call_hyp(kvm_ksym_ref(f), ##__VA_ARGS__) */
373
374static inline void __cpu_init_stage2(void) 372static inline void __cpu_init_stage2(void)
375{ 373{
376 kvm_call_hyp(__init_stage2_translation); 374 u32 parange = kvm_call_hyp(__init_stage2_translation);
375
376 WARN_ONCE(parange < 40,
377 "PARange is %d bits, unsupported configuration!", parange);
377} 378}
378 379
379#endif /* __ARM64_KVM_HOST_H__ */ 380#endif /* __ARM64_KVM_HOST_H__ */
diff --git a/arch/arm64/kvm/hyp/s2-setup.c b/arch/arm64/kvm/hyp/s2-setup.c
index 5a9f3bf542b0..bcbe761a5a3d 100644
--- a/arch/arm64/kvm/hyp/s2-setup.c
+++ b/arch/arm64/kvm/hyp/s2-setup.c
@@ -20,9 +20,10 @@
20#include <asm/kvm_asm.h> 20#include <asm/kvm_asm.h>
21#include <asm/kvm_hyp.h> 21#include <asm/kvm_hyp.h>
22 22
23void __hyp_text __init_stage2_translation(void) 23u32 __hyp_text __init_stage2_translation(void)
24{ 24{
25 u64 val = VTCR_EL2_FLAGS; 25 u64 val = VTCR_EL2_FLAGS;
26 u64 parange;
26 u64 tmp; 27 u64 tmp;
27 28
28 /* 29 /*
@@ -30,7 +31,39 @@ void __hyp_text __init_stage2_translation(void)
30 * bits in VTCR_EL2. Amusingly, the PARange is 4 bits, while 31 * bits in VTCR_EL2. Amusingly, the PARange is 4 bits, while
31 * PS is only 3. Fortunately, bit 19 is RES0 in VTCR_EL2... 32 * PS is only 3. Fortunately, bit 19 is RES0 in VTCR_EL2...
32 */ 33 */
33 val |= (read_sysreg(id_aa64mmfr0_el1) & 7) << 16; 34 parange = read_sysreg(id_aa64mmfr0_el1) & 7;
35 val |= parange << 16;
36
37 /* Compute the actual PARange... */
38 switch (parange) {
39 case 0:
40 parange = 32;
41 break;
42 case 1:
43 parange = 36;
44 break;
45 case 2:
46 parange = 40;
47 break;
48 case 3:
49 parange = 42;
50 break;
51 case 4:
52 parange = 44;
53 break;
54 case 5:
55 default:
56 parange = 48;
57 break;
58 }
59
60 /*
61 * ... and clamp it to 40 bits, unless we have some braindead
62 * HW that implements less than that. In all cases, we'll
63 * return that value for the rest of the kernel to decide what
64 * to do.
65 */
66 val |= 64 - (parange > 40 ? 40 : parange);
34 67
35 /* 68 /*
36 * Read the VMIDBits bits from ID_AA64MMFR1_EL1 and set the VS 69 * Read the VMIDBits bits from ID_AA64MMFR1_EL1 and set the VS
@@ -42,4 +75,6 @@ void __hyp_text __init_stage2_translation(void)
42 VTCR_EL2_VS_8BIT; 75 VTCR_EL2_VS_8BIT;
43 76
44 write_sysreg(val, vtcr_el2); 77 write_sysreg(val, vtcr_el2);
78
79 return parange;
45} 80}
diff --git a/arch/m68k/coldfire/gpio.c b/arch/m68k/coldfire/gpio.c
index 8832083e1cb8..b515809be2b9 100644
--- a/arch/m68k/coldfire/gpio.c
+++ b/arch/m68k/coldfire/gpio.c
@@ -158,11 +158,6 @@ static int mcfgpio_to_irq(struct gpio_chip *chip, unsigned offset)
158 return -EINVAL; 158 return -EINVAL;
159} 159}
160 160
161static struct bus_type mcfgpio_subsys = {
162 .name = "gpio",
163 .dev_name = "gpio",
164};
165
166static struct gpio_chip mcfgpio_chip = { 161static struct gpio_chip mcfgpio_chip = {
167 .label = "mcfgpio", 162 .label = "mcfgpio",
168 .request = mcfgpio_request, 163 .request = mcfgpio_request,
@@ -178,8 +173,7 @@ static struct gpio_chip mcfgpio_chip = {
178 173
179static int __init mcfgpio_sysinit(void) 174static int __init mcfgpio_sysinit(void)
180{ 175{
181 gpiochip_add_data(&mcfgpio_chip, NULL); 176 return gpiochip_add_data(&mcfgpio_chip, NULL);
182 return subsys_system_register(&mcfgpio_subsys, NULL);
183} 177}
184 178
185core_initcall(mcfgpio_sysinit); 179core_initcall(mcfgpio_sysinit);
diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig
index bd3c873951a1..88cfaa8af78e 100644
--- a/arch/parisc/Kconfig
+++ b/arch/parisc/Kconfig
@@ -4,8 +4,8 @@ config PARISC
4 select ARCH_MIGHT_HAVE_PC_PARPORT 4 select ARCH_MIGHT_HAVE_PC_PARPORT
5 select HAVE_IDE 5 select HAVE_IDE
6 select HAVE_OPROFILE 6 select HAVE_OPROFILE
7 select HAVE_FUNCTION_TRACER if 64BIT 7 select HAVE_FUNCTION_TRACER
8 select HAVE_FUNCTION_GRAPH_TRACER if 64BIT 8 select HAVE_FUNCTION_GRAPH_TRACER
9 select ARCH_WANT_FRAME_POINTERS 9 select ARCH_WANT_FRAME_POINTERS
10 select RTC_CLASS 10 select RTC_CLASS
11 select RTC_DRV_GENERIC 11 select RTC_DRV_GENERIC
diff --git a/arch/parisc/Kconfig.debug b/arch/parisc/Kconfig.debug
index bc989e522a04..68b7cbd0810a 100644
--- a/arch/parisc/Kconfig.debug
+++ b/arch/parisc/Kconfig.debug
@@ -2,9 +2,13 @@ menu "Kernel hacking"
2 2
3source "lib/Kconfig.debug" 3source "lib/Kconfig.debug"
4 4
5config TRACE_IRQFLAGS_SUPPORT
6 def_bool y
7
5config DEBUG_RODATA 8config DEBUG_RODATA
6 bool "Write protect kernel read-only data structures" 9 bool "Write protect kernel read-only data structures"
7 depends on DEBUG_KERNEL 10 depends on DEBUG_KERNEL
11 default y
8 help 12 help
9 Mark the kernel read-only data as write-protected in the pagetables, 13 Mark the kernel read-only data as write-protected in the pagetables,
10 in order to catch accidental (and incorrect) writes to such const 14 in order to catch accidental (and incorrect) writes to such const
diff --git a/arch/parisc/Makefile b/arch/parisc/Makefile
index 965a0999fc4c..75cb451b1f03 100644
--- a/arch/parisc/Makefile
+++ b/arch/parisc/Makefile
@@ -62,9 +62,7 @@ cflags-y += -mdisable-fpregs
62 62
63# Without this, "ld -r" results in .text sections that are too big 63# Without this, "ld -r" results in .text sections that are too big
64# (> 0x40000) for branches to reach stubs. 64# (> 0x40000) for branches to reach stubs.
65ifndef CONFIG_FUNCTION_TRACER 65cflags-y += -ffunction-sections
66 cflags-y += -ffunction-sections
67endif
68 66
69# Use long jumps instead of long branches (needed if your linker fails to 67# Use long jumps instead of long branches (needed if your linker fails to
70# link a too big vmlinux executable). Not enabled for building modules. 68# link a too big vmlinux executable). Not enabled for building modules.
diff --git a/arch/parisc/include/asm/ftrace.h b/arch/parisc/include/asm/ftrace.h
index 544ed8ef87eb..24cd81d58d70 100644
--- a/arch/parisc/include/asm/ftrace.h
+++ b/arch/parisc/include/asm/ftrace.h
@@ -4,23 +4,7 @@
4#ifndef __ASSEMBLY__ 4#ifndef __ASSEMBLY__
5extern void mcount(void); 5extern void mcount(void);
6 6
7/* 7#define MCOUNT_INSN_SIZE 4
8 * Stack of return addresses for functions of a thread.
9 * Used in struct thread_info
10 */
11struct ftrace_ret_stack {
12 unsigned long ret;
13 unsigned long func;
14 unsigned long long calltime;
15};
16
17/*
18 * Primary handler of a function return.
19 * It relays on ftrace_return_to_handler.
20 * Defined in entry.S
21 */
22extern void return_to_handler(void);
23
24 8
25extern unsigned long return_address(unsigned int); 9extern unsigned long return_address(unsigned int);
26 10
diff --git a/arch/parisc/kernel/Makefile b/arch/parisc/kernel/Makefile
index ff87b4603e3d..69a11183d48d 100644
--- a/arch/parisc/kernel/Makefile
+++ b/arch/parisc/kernel/Makefile
@@ -15,11 +15,7 @@ ifdef CONFIG_FUNCTION_TRACER
15# Do not profile debug and lowlevel utilities 15# Do not profile debug and lowlevel utilities
16CFLAGS_REMOVE_ftrace.o = -pg 16CFLAGS_REMOVE_ftrace.o = -pg
17CFLAGS_REMOVE_cache.o = -pg 17CFLAGS_REMOVE_cache.o = -pg
18CFLAGS_REMOVE_irq.o = -pg
19CFLAGS_REMOVE_pacache.o = -pg
20CFLAGS_REMOVE_perf.o = -pg 18CFLAGS_REMOVE_perf.o = -pg
21CFLAGS_REMOVE_traps.o = -pg
22CFLAGS_REMOVE_unaligned.o = -pg
23CFLAGS_REMOVE_unwind.o = -pg 19CFLAGS_REMOVE_unwind.o = -pg
24endif 20endif
25 21
diff --git a/arch/parisc/kernel/entry.S b/arch/parisc/kernel/entry.S
index 623496c11756..39127d3e70e5 100644
--- a/arch/parisc/kernel/entry.S
+++ b/arch/parisc/kernel/entry.S
@@ -1970,43 +1970,98 @@ pt_regs_ok:
1970 b intr_restore 1970 b intr_restore
1971 copy %r25,%r16 1971 copy %r25,%r16
1972 1972
1973 .import schedule,code
1974syscall_do_resched: 1973syscall_do_resched:
1975 BL schedule,%r2 1974 load32 syscall_check_resched,%r2 /* if resched, we start over again */
1975 load32 schedule,%r19
1976 bv %r0(%r19) /* jumps to schedule() */
1976#ifdef CONFIG_64BIT 1977#ifdef CONFIG_64BIT
1977 ldo -16(%r30),%r29 /* Reference param save area */ 1978 ldo -16(%r30),%r29 /* Reference param save area */
1978#else 1979#else
1979 nop 1980 nop
1980#endif 1981#endif
1981 b syscall_check_resched /* if resched, we start over again */
1982 nop
1983ENDPROC(syscall_exit) 1982ENDPROC(syscall_exit)
1984 1983
1985 1984
1986#ifdef CONFIG_FUNCTION_TRACER 1985#ifdef CONFIG_FUNCTION_TRACER
1986
1987 .import ftrace_function_trampoline,code 1987 .import ftrace_function_trampoline,code
1988ENTRY(_mcount) 1988 .align L1_CACHE_BYTES
1989 copy %r3, %arg2 1989 .globl mcount
1990 .type mcount, @function
1991ENTRY(mcount)
1992_mcount:
1993 .export _mcount,data
1994 .proc
1995 .callinfo caller,frame=0
1996 .entry
1997 /*
1998 * The 64bit mcount() function pointer needs 4 dwords, of which the
1999 * first two are free. We optimize it here and put 2 instructions for
2000 * calling mcount(), and 2 instructions for ftrace_stub(). That way we
2001 * have all on one L1 cacheline.
2002 */
1990 b ftrace_function_trampoline 2003 b ftrace_function_trampoline
2004 copy %r3, %arg2 /* caller original %sp */
2005ftrace_stub:
2006 .globl ftrace_stub
2007 .type ftrace_stub, @function
2008#ifdef CONFIG_64BIT
2009 bve (%rp)
2010#else
2011 bv %r0(%rp)
2012#endif
1991 nop 2013 nop
1992ENDPROC(_mcount) 2014#ifdef CONFIG_64BIT
2015 .dword mcount
2016 .dword 0 /* code in head.S puts value of global gp here */
2017#endif
2018 .exit
2019 .procend
2020ENDPROC(mcount)
1993 2021
2022 .align 8
2023 .globl return_to_handler
2024 .type return_to_handler, @function
1994ENTRY(return_to_handler) 2025ENTRY(return_to_handler)
1995 load32 return_trampoline, %rp 2026 .proc
1996 copy %ret0, %arg0 2027 .callinfo caller,frame=FRAME_SIZE
1997 copy %ret1, %arg1 2028 .entry
1998 b ftrace_return_to_handler 2029 .export parisc_return_to_handler,data
1999 nop 2030parisc_return_to_handler:
2000return_trampoline: 2031 copy %r3,%r1
2001 copy %ret0, %rp 2032 STREG %r0,-RP_OFFSET(%sp) /* store 0 as %rp */
2002 copy %r23, %ret0 2033 copy %sp,%r3
2003 copy %r24, %ret1 2034 STREGM %r1,FRAME_SIZE(%sp)
2035 STREG %ret0,8(%r3)
2036 STREG %ret1,16(%r3)
2004 2037
2005.globl ftrace_stub 2038#ifdef CONFIG_64BIT
2006ftrace_stub: 2039 loadgp
2040#endif
2041
2042 /* call ftrace_return_to_handler(0) */
2043#ifdef CONFIG_64BIT
2044 ldo -16(%sp),%ret1 /* Reference param save area */
2045#endif
2046 BL ftrace_return_to_handler,%r2
2047 ldi 0,%r26
2048 copy %ret0,%rp
2049
2050 /* restore original return values */
2051 LDREG 8(%r3),%ret0
2052 LDREG 16(%r3),%ret1
2053
2054 /* return from function */
2055#ifdef CONFIG_64BIT
2056 bve (%rp)
2057#else
2007 bv %r0(%rp) 2058 bv %r0(%rp)
2008 nop 2059#endif
2060 LDREGM -FRAME_SIZE(%sp),%r3
2061 .exit
2062 .procend
2009ENDPROC(return_to_handler) 2063ENDPROC(return_to_handler)
2064
2010#endif /* CONFIG_FUNCTION_TRACER */ 2065#endif /* CONFIG_FUNCTION_TRACER */
2011 2066
2012#ifdef CONFIG_IRQSTACKS 2067#ifdef CONFIG_IRQSTACKS
diff --git a/arch/parisc/kernel/ftrace.c b/arch/parisc/kernel/ftrace.c
index 559d400f9385..b13f9ec6f294 100644
--- a/arch/parisc/kernel/ftrace.c
+++ b/arch/parisc/kernel/ftrace.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * Code for tracing calls in Linux kernel. 2 * Code for tracing calls in Linux kernel.
3 * Copyright (C) 2009 Helge Deller <deller@gmx.de> 3 * Copyright (C) 2009-2016 Helge Deller <deller@gmx.de>
4 * 4 *
5 * based on code for x86 which is: 5 * based on code for x86 which is:
6 * Copyright (C) 2007-2008 Steven Rostedt <srostedt@redhat.com> 6 * Copyright (C) 2007-2008 Steven Rostedt <srostedt@redhat.com>
@@ -13,104 +13,21 @@
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/ftrace.h> 14#include <linux/ftrace.h>
15 15
16#include <asm/assembly.h>
16#include <asm/sections.h> 17#include <asm/sections.h>
17#include <asm/ftrace.h> 18#include <asm/ftrace.h>
18 19
19 20
20
21#ifdef CONFIG_FUNCTION_GRAPH_TRACER 21#ifdef CONFIG_FUNCTION_GRAPH_TRACER
22
23/* Add a function return address to the trace stack on thread info.*/
24static int push_return_trace(unsigned long ret, unsigned long long time,
25 unsigned long func, int *depth)
26{
27 int index;
28
29 if (!current->ret_stack)
30 return -EBUSY;
31
32 /* The return trace stack is full */
33 if (current->curr_ret_stack == FTRACE_RETFUNC_DEPTH - 1) {
34 atomic_inc(&current->trace_overrun);
35 return -EBUSY;
36 }
37
38 index = ++current->curr_ret_stack;
39 barrier();
40 current->ret_stack[index].ret = ret;
41 current->ret_stack[index].func = func;
42 current->ret_stack[index].calltime = time;
43 *depth = index;
44
45 return 0;
46}
47
48/* Retrieve a function return address to the trace stack on thread info.*/
49static void pop_return_trace(struct ftrace_graph_ret *trace, unsigned long *ret)
50{
51 int index;
52
53 index = current->curr_ret_stack;
54
55 if (unlikely(index < 0)) {
56 ftrace_graph_stop();
57 WARN_ON(1);
58 /* Might as well panic, otherwise we have no where to go */
59 *ret = (unsigned long)
60 dereference_function_descriptor(&panic);
61 return;
62 }
63
64 *ret = current->ret_stack[index].ret;
65 trace->func = current->ret_stack[index].func;
66 trace->calltime = current->ret_stack[index].calltime;
67 trace->overrun = atomic_read(&current->trace_overrun);
68 trace->depth = index;
69 barrier();
70 current->curr_ret_stack--;
71
72}
73
74/*
75 * Send the trace to the ring-buffer.
76 * @return the original return address.
77 */
78unsigned long ftrace_return_to_handler(unsigned long retval0,
79 unsigned long retval1)
80{
81 struct ftrace_graph_ret trace;
82 unsigned long ret;
83
84 pop_return_trace(&trace, &ret);
85 trace.rettime = local_clock();
86 ftrace_graph_return(&trace);
87
88 if (unlikely(!ret)) {
89 ftrace_graph_stop();
90 WARN_ON(1);
91 /* Might as well panic. What else to do? */
92 ret = (unsigned long)
93 dereference_function_descriptor(&panic);
94 }
95
96 /* HACK: we hand over the old functions' return values
97 in %r23 and %r24. Assembly in entry.S will take care
98 and move those to their final registers %ret0 and %ret1 */
99 asm( "copy %0, %%r23 \n\t"
100 "copy %1, %%r24 \n" : : "r" (retval0), "r" (retval1) );
101
102 return ret;
103}
104
105/* 22/*
106 * Hook the return address and push it in the stack of return addrs 23 * Hook the return address and push it in the stack of return addrs
107 * in current thread info. 24 * in current thread info.
108 */ 25 */
109void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr) 26static void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr)
110{ 27{
111 unsigned long old; 28 unsigned long old;
112 unsigned long long calltime;
113 struct ftrace_graph_ent trace; 29 struct ftrace_graph_ent trace;
30 extern int parisc_return_to_handler;
114 31
115 if (unlikely(ftrace_graph_is_dead())) 32 if (unlikely(ftrace_graph_is_dead()))
116 return; 33 return;
@@ -119,64 +36,47 @@ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr)
119 return; 36 return;
120 37
121 old = *parent; 38 old = *parent;
122 *parent = (unsigned long)
123 dereference_function_descriptor(&return_to_handler);
124 39
125 if (unlikely(!__kernel_text_address(old))) { 40 trace.func = self_addr;
126 ftrace_graph_stop(); 41 trace.depth = current->curr_ret_stack + 1;
127 *parent = old;
128 WARN_ON(1);
129 return;
130 }
131
132 calltime = local_clock();
133 42
134 if (push_return_trace(old, calltime, 43 /* Only trace if the calling function expects to */
135 self_addr, &trace.depth) == -EBUSY) { 44 if (!ftrace_graph_entry(&trace))
136 *parent = old;
137 return; 45 return;
138 }
139 46
140 trace.func = self_addr; 47 if (ftrace_push_return_trace(old, self_addr, &trace.depth,
48 0 ) == -EBUSY)
49 return;
141 50
142 /* Only trace if the calling function expects to */ 51 /* activate parisc_return_to_handler() as return point */
143 if (!ftrace_graph_entry(&trace)) { 52 *parent = (unsigned long) &parisc_return_to_handler;
144 current->curr_ret_stack--;
145 *parent = old;
146 }
147} 53}
148
149#endif /* CONFIG_FUNCTION_GRAPH_TRACER */ 54#endif /* CONFIG_FUNCTION_GRAPH_TRACER */
150 55
151 56void notrace ftrace_function_trampoline(unsigned long parent,
152void ftrace_function_trampoline(unsigned long parent,
153 unsigned long self_addr, 57 unsigned long self_addr,
154 unsigned long org_sp_gr3) 58 unsigned long org_sp_gr3)
155{ 59{
156 extern ftrace_func_t ftrace_trace_function; 60 extern ftrace_func_t ftrace_trace_function; /* depends on CONFIG_DYNAMIC_FTRACE */
61 extern int ftrace_graph_entry_stub(struct ftrace_graph_ent *trace);
157 62
158 if (ftrace_trace_function != ftrace_stub) { 63 if (ftrace_trace_function != ftrace_stub) {
159 ftrace_trace_function(parent, self_addr); 64 /* struct ftrace_ops *op, struct pt_regs *regs); */
65 ftrace_trace_function(parent, self_addr, NULL, NULL);
160 return; 66 return;
161 } 67 }
68
162#ifdef CONFIG_FUNCTION_GRAPH_TRACER 69#ifdef CONFIG_FUNCTION_GRAPH_TRACER
163 if (ftrace_graph_entry && ftrace_graph_return) { 70 if (ftrace_graph_return != (trace_func_graph_ret_t) ftrace_stub ||
164 unsigned long sp; 71 ftrace_graph_entry != ftrace_graph_entry_stub) {
165 unsigned long *parent_rp; 72 unsigned long *parent_rp;
166 73
167 asm volatile ("copy %%r30, %0" : "=r"(sp));
168 /* sanity check: is stack pointer which we got from
169 assembler function in entry.S in a reasonable
170 range compared to current stack pointer? */
171 if ((sp - org_sp_gr3) > 0x400)
172 return;
173
174 /* calculate pointer to %rp in stack */ 74 /* calculate pointer to %rp in stack */
175 parent_rp = (unsigned long *) org_sp_gr3 - 0x10; 75 parent_rp = (unsigned long *) (org_sp_gr3 - RP_OFFSET);
176 /* sanity check: parent_rp should hold parent */ 76 /* sanity check: parent_rp should hold parent */
177 if (*parent_rp != parent) 77 if (*parent_rp != parent)
178 return; 78 return;
179 79
180 prepare_ftrace_return(parent_rp, self_addr); 80 prepare_ftrace_return(parent_rp, self_addr);
181 return; 81 return;
182 } 82 }
diff --git a/arch/parisc/kernel/head.S b/arch/parisc/kernel/head.S
index 75aa0db9f69e..bbbe360b458f 100644
--- a/arch/parisc/kernel/head.S
+++ b/arch/parisc/kernel/head.S
@@ -129,6 +129,15 @@ $pgt_fill_loop:
129 /* And the stack pointer too */ 129 /* And the stack pointer too */
130 ldo THREAD_SZ_ALGN(%r6),%sp 130 ldo THREAD_SZ_ALGN(%r6),%sp
131 131
132#if defined(CONFIG_64BIT) && defined(CONFIG_FUNCTION_TRACER)
133 .import _mcount,data
134 /* initialize mcount FPTR */
135 /* Get the global data pointer */
136 loadgp
137 load32 PA(_mcount), %r10
138 std %dp,0x18(%r10)
139#endif
140
132#ifdef CONFIG_SMP 141#ifdef CONFIG_SMP
133 /* Set the smp rendezvous address into page zero. 142 /* Set the smp rendezvous address into page zero.
134 ** It would be safer to do this in init_smp_config() but 143 ** It would be safer to do this in init_smp_config() but
diff --git a/arch/sh/include/asm/smp.h b/arch/sh/include/asm/smp.h
index 1baf0ba96242..c9f8bbdb1bf8 100644
--- a/arch/sh/include/asm/smp.h
+++ b/arch/sh/include/asm/smp.h
@@ -34,11 +34,6 @@ enum {
34DECLARE_PER_CPU(int, cpu_state); 34DECLARE_PER_CPU(int, cpu_state);
35 35
36void smp_message_recv(unsigned int msg); 36void smp_message_recv(unsigned int msg);
37void smp_timer_broadcast(const struct cpumask *mask);
38
39void local_timer_interrupt(void);
40void local_timer_setup(unsigned int cpu);
41void local_timer_stop(unsigned int cpu);
42 37
43void arch_send_call_function_single_ipi(int cpu); 38void arch_send_call_function_single_ipi(int cpu);
44void arch_send_call_function_ipi_mask(const struct cpumask *mask); 39void arch_send_call_function_ipi_mask(const struct cpumask *mask);
diff --git a/arch/sh/include/asm/topology.h b/arch/sh/include/asm/topology.h
index b0a282d65f6a..358e3f516ef6 100644
--- a/arch/sh/include/asm/topology.h
+++ b/arch/sh/include/asm/topology.h
@@ -17,7 +17,7 @@
17 17
18#define mc_capable() (1) 18#define mc_capable() (1)
19 19
20const struct cpumask *cpu_coregroup_mask(unsigned int cpu); 20const struct cpumask *cpu_coregroup_mask(int cpu);
21 21
22extern cpumask_t cpu_core_map[NR_CPUS]; 22extern cpumask_t cpu_core_map[NR_CPUS];
23 23
diff --git a/arch/sh/kernel/cpu/sh4a/smp-shx3.c b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
index 4a298808789c..839612c8a0a0 100644
--- a/arch/sh/kernel/cpu/sh4a/smp-shx3.c
+++ b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
@@ -73,8 +73,6 @@ static void shx3_prepare_cpus(unsigned int max_cpus)
73{ 73{
74 int i; 74 int i;
75 75
76 local_timer_setup(0);
77
78 BUILD_BUG_ON(SMP_MSG_NR >= 8); 76 BUILD_BUG_ON(SMP_MSG_NR >= 8);
79 77
80 for (i = 0; i < SMP_MSG_NR; i++) 78 for (i = 0; i < SMP_MSG_NR; i++)
diff --git a/arch/sh/kernel/topology.c b/arch/sh/kernel/topology.c
index 772caffba22f..c82912a61d74 100644
--- a/arch/sh/kernel/topology.c
+++ b/arch/sh/kernel/topology.c
@@ -21,7 +21,7 @@ static DEFINE_PER_CPU(struct cpu, cpu_devices);
21cpumask_t cpu_core_map[NR_CPUS]; 21cpumask_t cpu_core_map[NR_CPUS];
22EXPORT_SYMBOL(cpu_core_map); 22EXPORT_SYMBOL(cpu_core_map);
23 23
24static cpumask_t cpu_coregroup_map(unsigned int cpu) 24static cpumask_t cpu_coregroup_map(int cpu)
25{ 25{
26 /* 26 /*
27 * Presently all SH-X3 SMP cores are multi-cores, so just keep it 27 * Presently all SH-X3 SMP cores are multi-cores, so just keep it
@@ -30,7 +30,7 @@ static cpumask_t cpu_coregroup_map(unsigned int cpu)
30 return *cpu_possible_mask; 30 return *cpu_possible_mask;
31} 31}
32 32
33const struct cpumask *cpu_coregroup_mask(unsigned int cpu) 33const struct cpumask *cpu_coregroup_mask(int cpu)
34{ 34{
35 return &cpu_core_map[cpu]; 35 return &cpu_core_map[cpu];
36} 36}
diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
index 6915ff2bd996..8774cb23064f 100644
--- a/arch/x86/boot/compressed/Makefile
+++ b/arch/x86/boot/compressed/Makefile
@@ -26,7 +26,7 @@ targets := vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lzma \
26 vmlinux.bin.xz vmlinux.bin.lzo vmlinux.bin.lz4 26 vmlinux.bin.xz vmlinux.bin.lzo vmlinux.bin.lz4
27 27
28KBUILD_CFLAGS := -m$(BITS) -D__KERNEL__ $(LINUX_INCLUDE) -O2 28KBUILD_CFLAGS := -m$(BITS) -D__KERNEL__ $(LINUX_INCLUDE) -O2
29KBUILD_CFLAGS += -fno-strict-aliasing -fPIC 29KBUILD_CFLAGS += -fno-strict-aliasing $(call cc-option, -fPIE, -fPIC)
30KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING 30KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING
31cflags-$(CONFIG_X86_32) := -march=i386 31cflags-$(CONFIG_X86_32) := -march=i386
32cflags-$(CONFIG_X86_64) := -mcmodel=small 32cflags-$(CONFIG_X86_64) := -mcmodel=small
@@ -40,6 +40,18 @@ GCOV_PROFILE := n
40UBSAN_SANITIZE :=n 40UBSAN_SANITIZE :=n
41 41
42LDFLAGS := -m elf_$(UTS_MACHINE) 42LDFLAGS := -m elf_$(UTS_MACHINE)
43ifeq ($(CONFIG_RELOCATABLE),y)
44# If kernel is relocatable, build compressed kernel as PIE.
45ifeq ($(CONFIG_X86_32),y)
46LDFLAGS += $(call ld-option, -pie) $(call ld-option, --no-dynamic-linker)
47else
48# To build 64-bit compressed kernel as PIE, we disable relocation
49# overflow check to avoid relocation overflow error with a new linker
50# command-line option, -z noreloc-overflow.
51LDFLAGS += $(shell $(LD) --help 2>&1 | grep -q "\-z noreloc-overflow" \
52 && echo "-z noreloc-overflow -pie --no-dynamic-linker")
53endif
54endif
43LDFLAGS_vmlinux := -T 55LDFLAGS_vmlinux := -T
44 56
45hostprogs-y := mkpiggy 57hostprogs-y := mkpiggy
diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S
index 8ef964ddc18e..0256064da8da 100644
--- a/arch/x86/boot/compressed/head_32.S
+++ b/arch/x86/boot/compressed/head_32.S
@@ -31,6 +31,34 @@
31#include <asm/asm-offsets.h> 31#include <asm/asm-offsets.h>
32#include <asm/bootparam.h> 32#include <asm/bootparam.h>
33 33
34/*
35 * The 32-bit x86 assembler in binutils 2.26 will generate R_386_GOT32X
36 * relocation to get the symbol address in PIC. When the compressed x86
37 * kernel isn't built as PIC, the linker optimizes R_386_GOT32X
38 * relocations to their fixed symbol addresses. However, when the
39 * compressed x86 kernel is loaded at a different address, it leads
40 * to the following load failure:
41 *
42 * Failed to allocate space for phdrs
43 *
44 * during the decompression stage.
45 *
46 * If the compressed x86 kernel is relocatable at run-time, it should be
47 * compiled with -fPIE, instead of -fPIC, if possible and should be built as
48 * Position Independent Executable (PIE) so that linker won't optimize
49 * R_386_GOT32X relocation to its fixed symbol address. Older
50 * linkers generate R_386_32 relocations against locally defined symbols,
51 * _bss, _ebss, _got and _egot, in PIE. It isn't wrong, just less
52 * optimal than R_386_RELATIVE. But the x86 kernel fails to properly handle
53 * R_386_32 relocations when relocating the kernel. To generate
54 * R_386_RELATIVE relocations, we mark _bss, _ebss, _got and _egot as
55 * hidden:
56 */
57 .hidden _bss
58 .hidden _ebss
59 .hidden _got
60 .hidden _egot
61
34 __HEAD 62 __HEAD
35ENTRY(startup_32) 63ENTRY(startup_32)
36#ifdef CONFIG_EFI_STUB 64#ifdef CONFIG_EFI_STUB
diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
index b0c0d16ef58d..86558a199139 100644
--- a/arch/x86/boot/compressed/head_64.S
+++ b/arch/x86/boot/compressed/head_64.S
@@ -33,6 +33,14 @@
33#include <asm/asm-offsets.h> 33#include <asm/asm-offsets.h>
34#include <asm/bootparam.h> 34#include <asm/bootparam.h>
35 35
36/*
37 * Locally defined symbols should be marked hidden:
38 */
39 .hidden _bss
40 .hidden _ebss
41 .hidden _got
42 .hidden _egot
43
36 __HEAD 44 __HEAD
37 .code32 45 .code32
38ENTRY(startup_32) 46ENTRY(startup_32)
diff --git a/arch/x86/kernel/cpu/mcheck/mce-genpool.c b/arch/x86/kernel/cpu/mcheck/mce-genpool.c
index 0a850100c594..2658e2af74ec 100644
--- a/arch/x86/kernel/cpu/mcheck/mce-genpool.c
+++ b/arch/x86/kernel/cpu/mcheck/mce-genpool.c
@@ -29,7 +29,7 @@ static char gen_pool_buf[MCE_POOLSZ];
29void mce_gen_pool_process(void) 29void mce_gen_pool_process(void)
30{ 30{
31 struct llist_node *head; 31 struct llist_node *head;
32 struct mce_evt_llist *node; 32 struct mce_evt_llist *node, *tmp;
33 struct mce *mce; 33 struct mce *mce;
34 34
35 head = llist_del_all(&mce_event_llist); 35 head = llist_del_all(&mce_event_llist);
@@ -37,7 +37,7 @@ void mce_gen_pool_process(void)
37 return; 37 return;
38 38
39 head = llist_reverse_order(head); 39 head = llist_reverse_order(head);
40 llist_for_each_entry(node, head, llnode) { 40 llist_for_each_entry_safe(node, tmp, head, llnode) {
41 mce = &node->mce; 41 mce = &node->mce;
42 atomic_notifier_call_chain(&x86_mce_decoder_chain, 0, mce); 42 atomic_notifier_call_chain(&x86_mce_decoder_chain, 0, mce);
43 gen_pool_free(mce_evt_pool, (unsigned long)node, sizeof(*node)); 43 gen_pool_free(mce_evt_pool, (unsigned long)node, sizeof(*node));
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index 319b08a5b6ed..2367ae07eb76 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -146,6 +146,31 @@ int default_check_phys_apicid_present(int phys_apicid)
146 146
147struct boot_params boot_params; 147struct boot_params boot_params;
148 148
149/*
150 * Machine setup..
151 */
152static struct resource data_resource = {
153 .name = "Kernel data",
154 .start = 0,
155 .end = 0,
156 .flags = IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM
157};
158
159static struct resource code_resource = {
160 .name = "Kernel code",
161 .start = 0,
162 .end = 0,
163 .flags = IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM
164};
165
166static struct resource bss_resource = {
167 .name = "Kernel bss",
168 .start = 0,
169 .end = 0,
170 .flags = IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM
171};
172
173
149#ifdef CONFIG_X86_32 174#ifdef CONFIG_X86_32
150/* cpu data as detected by the assembly code in head.S */ 175/* cpu data as detected by the assembly code in head.S */
151struct cpuinfo_x86 new_cpu_data = { 176struct cpuinfo_x86 new_cpu_data = {
@@ -924,6 +949,13 @@ void __init setup_arch(char **cmdline_p)
924 949
925 mpx_mm_init(&init_mm); 950 mpx_mm_init(&init_mm);
926 951
952 code_resource.start = __pa_symbol(_text);
953 code_resource.end = __pa_symbol(_etext)-1;
954 data_resource.start = __pa_symbol(_etext);
955 data_resource.end = __pa_symbol(_edata)-1;
956 bss_resource.start = __pa_symbol(__bss_start);
957 bss_resource.end = __pa_symbol(__bss_stop)-1;
958
927#ifdef CONFIG_CMDLINE_BOOL 959#ifdef CONFIG_CMDLINE_BOOL
928#ifdef CONFIG_CMDLINE_OVERRIDE 960#ifdef CONFIG_CMDLINE_OVERRIDE
929 strlcpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE); 961 strlcpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
@@ -987,6 +1019,11 @@ void __init setup_arch(char **cmdline_p)
987 1019
988 x86_init.resources.probe_roms(); 1020 x86_init.resources.probe_roms();
989 1021
1022 /* after parse_early_param, so could debug it */
1023 insert_resource(&iomem_resource, &code_resource);
1024 insert_resource(&iomem_resource, &data_resource);
1025 insert_resource(&iomem_resource, &bss_resource);
1026
990 e820_add_kernel_range(); 1027 e820_add_kernel_range();
991 trim_bios_range(); 1028 trim_bios_range();
992#ifdef CONFIG_X86_32 1029#ifdef CONFIG_X86_32
diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
index 8efb839948e5..bbbaa802d13e 100644
--- a/arch/x86/kvm/cpuid.c
+++ b/arch/x86/kvm/cpuid.c
@@ -534,6 +534,7 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
534 do_cpuid_1_ent(&entry[i], function, idx); 534 do_cpuid_1_ent(&entry[i], function, idx);
535 if (idx == 1) { 535 if (idx == 1) {
536 entry[i].eax &= kvm_cpuid_D_1_eax_x86_features; 536 entry[i].eax &= kvm_cpuid_D_1_eax_x86_features;
537 cpuid_mask(&entry[i].eax, CPUID_D_1_EAX);
537 entry[i].ebx = 0; 538 entry[i].ebx = 0;
538 if (entry[i].eax & (F(XSAVES)|F(XSAVEC))) 539 if (entry[i].eax & (F(XSAVES)|F(XSAVEC)))
539 entry[i].ebx = 540 entry[i].ebx =
diff --git a/arch/x86/kvm/mmu.h b/arch/x86/kvm/mmu.h
index b70df72e2b33..66b33b96a31b 100644
--- a/arch/x86/kvm/mmu.h
+++ b/arch/x86/kvm/mmu.h
@@ -173,10 +173,9 @@ static inline u8 permission_fault(struct kvm_vcpu *vcpu, struct kvm_mmu *mmu,
173 int index = (pfec >> 1) + 173 int index = (pfec >> 1) +
174 (smap >> (X86_EFLAGS_AC_BIT - PFERR_RSVD_BIT + 1)); 174 (smap >> (X86_EFLAGS_AC_BIT - PFERR_RSVD_BIT + 1));
175 bool fault = (mmu->permissions[index] >> pte_access) & 1; 175 bool fault = (mmu->permissions[index] >> pte_access) & 1;
176 u32 errcode = PFERR_PRESENT_MASK;
176 177
177 WARN_ON(pfec & (PFERR_PK_MASK | PFERR_RSVD_MASK)); 178 WARN_ON(pfec & (PFERR_PK_MASK | PFERR_RSVD_MASK));
178 pfec |= PFERR_PRESENT_MASK;
179
180 if (unlikely(mmu->pkru_mask)) { 179 if (unlikely(mmu->pkru_mask)) {
181 u32 pkru_bits, offset; 180 u32 pkru_bits, offset;
182 181
@@ -189,15 +188,15 @@ static inline u8 permission_fault(struct kvm_vcpu *vcpu, struct kvm_mmu *mmu,
189 pkru_bits = (kvm_read_pkru(vcpu) >> (pte_pkey * 2)) & 3; 188 pkru_bits = (kvm_read_pkru(vcpu) >> (pte_pkey * 2)) & 3;
190 189
191 /* clear present bit, replace PFEC.RSVD with ACC_USER_MASK. */ 190 /* clear present bit, replace PFEC.RSVD with ACC_USER_MASK. */
192 offset = pfec - 1 + 191 offset = (pfec & ~1) +
193 ((pte_access & PT_USER_MASK) << (PFERR_RSVD_BIT - PT_USER_SHIFT)); 192 ((pte_access & PT_USER_MASK) << (PFERR_RSVD_BIT - PT_USER_SHIFT));
194 193
195 pkru_bits &= mmu->pkru_mask >> offset; 194 pkru_bits &= mmu->pkru_mask >> offset;
196 pfec |= -pkru_bits & PFERR_PK_MASK; 195 errcode |= -pkru_bits & PFERR_PK_MASK;
197 fault |= (pkru_bits != 0); 196 fault |= (pkru_bits != 0);
198 } 197 }
199 198
200 return -(uint32_t)fault & pfec; 199 return -(u32)fault & errcode;
201} 200}
202 201
203void kvm_mmu_invalidate_zap_all_pages(struct kvm *kvm); 202void kvm_mmu_invalidate_zap_all_pages(struct kvm *kvm);
diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
index 1d971c7553c3..bc019f70e0b6 100644
--- a/arch/x86/kvm/paging_tmpl.h
+++ b/arch/x86/kvm/paging_tmpl.h
@@ -360,7 +360,7 @@ retry_walk:
360 goto error; 360 goto error;
361 361
362 if (unlikely(is_rsvd_bits_set(mmu, pte, walker->level))) { 362 if (unlikely(is_rsvd_bits_set(mmu, pte, walker->level))) {
363 errcode |= PFERR_RSVD_MASK | PFERR_PRESENT_MASK; 363 errcode = PFERR_RSVD_MASK | PFERR_PRESENT_MASK;
364 goto error; 364 goto error;
365 } 365 }
366 366
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 0a2c70e43bc8..9b7798c7b210 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -700,7 +700,6 @@ static int __kvm_set_xcr(struct kvm_vcpu *vcpu, u32 index, u64 xcr)
700 if ((xcr0 & XFEATURE_MASK_AVX512) != XFEATURE_MASK_AVX512) 700 if ((xcr0 & XFEATURE_MASK_AVX512) != XFEATURE_MASK_AVX512)
701 return 1; 701 return 1;
702 } 702 }
703 kvm_put_guest_xcr0(vcpu);
704 vcpu->arch.xcr0 = xcr0; 703 vcpu->arch.xcr0 = xcr0;
705 704
706 if ((xcr0 ^ old_xcr0) & XFEATURE_MASK_EXTEND) 705 if ((xcr0 ^ old_xcr0) & XFEATURE_MASK_EXTEND)
@@ -6590,8 +6589,6 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
6590 kvm_x86_ops->prepare_guest_switch(vcpu); 6589 kvm_x86_ops->prepare_guest_switch(vcpu);
6591 if (vcpu->fpu_active) 6590 if (vcpu->fpu_active)
6592 kvm_load_guest_fpu(vcpu); 6591 kvm_load_guest_fpu(vcpu);
6593 kvm_load_guest_xcr0(vcpu);
6594
6595 vcpu->mode = IN_GUEST_MODE; 6592 vcpu->mode = IN_GUEST_MODE;
6596 6593
6597 srcu_read_unlock(&vcpu->kvm->srcu, vcpu->srcu_idx); 6594 srcu_read_unlock(&vcpu->kvm->srcu, vcpu->srcu_idx);
@@ -6618,6 +6615,8 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
6618 goto cancel_injection; 6615 goto cancel_injection;
6619 } 6616 }
6620 6617
6618 kvm_load_guest_xcr0(vcpu);
6619
6621 if (req_immediate_exit) 6620 if (req_immediate_exit)
6622 smp_send_reschedule(vcpu->cpu); 6621 smp_send_reschedule(vcpu->cpu);
6623 6622
@@ -6667,6 +6666,8 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
6667 vcpu->mode = OUTSIDE_GUEST_MODE; 6666 vcpu->mode = OUTSIDE_GUEST_MODE;
6668 smp_wmb(); 6667 smp_wmb();
6669 6668
6669 kvm_put_guest_xcr0(vcpu);
6670
6670 /* Interrupt is enabled by handle_external_intr() */ 6671 /* Interrupt is enabled by handle_external_intr() */
6671 kvm_x86_ops->handle_external_intr(vcpu); 6672 kvm_x86_ops->handle_external_intr(vcpu);
6672 6673
@@ -7314,7 +7315,6 @@ void kvm_load_guest_fpu(struct kvm_vcpu *vcpu)
7314 * and assume host would use all available bits. 7315 * and assume host would use all available bits.
7315 * Guest xcr0 would be loaded later. 7316 * Guest xcr0 would be loaded later.
7316 */ 7317 */
7317 kvm_put_guest_xcr0(vcpu);
7318 vcpu->guest_fpu_loaded = 1; 7318 vcpu->guest_fpu_loaded = 1;
7319 __kernel_fpu_begin(); 7319 __kernel_fpu_begin();
7320 __copy_kernel_to_fpregs(&vcpu->arch.guest_fpu.state); 7320 __copy_kernel_to_fpregs(&vcpu->arch.guest_fpu.state);
@@ -7323,8 +7323,6 @@ void kvm_load_guest_fpu(struct kvm_vcpu *vcpu)
7323 7323
7324void kvm_put_guest_fpu(struct kvm_vcpu *vcpu) 7324void kvm_put_guest_fpu(struct kvm_vcpu *vcpu)
7325{ 7325{
7326 kvm_put_guest_xcr0(vcpu);
7327
7328 if (!vcpu->guest_fpu_loaded) { 7326 if (!vcpu->guest_fpu_loaded) {
7329 vcpu->fpu_counter = 0; 7327 vcpu->fpu_counter = 0;
7330 return; 7328 return;
diff --git a/block/partition-generic.c b/block/partition-generic.c
index 2c6ae2aed2c4..d7eb77e1e3a8 100644
--- a/block/partition-generic.c
+++ b/block/partition-generic.c
@@ -361,15 +361,20 @@ struct hd_struct *add_partition(struct gendisk *disk, int partno,
361 goto out_del; 361 goto out_del;
362 } 362 }
363 363
364 err = hd_ref_init(p);
365 if (err) {
366 if (flags & ADDPART_FLAG_WHOLEDISK)
367 goto out_remove_file;
368 goto out_del;
369 }
370
364 /* everything is up and running, commence */ 371 /* everything is up and running, commence */
365 rcu_assign_pointer(ptbl->part[partno], p); 372 rcu_assign_pointer(ptbl->part[partno], p);
366 373
367 /* suppress uevent if the disk suppresses it */ 374 /* suppress uevent if the disk suppresses it */
368 if (!dev_get_uevent_suppress(ddev)) 375 if (!dev_get_uevent_suppress(ddev))
369 kobject_uevent(&pdev->kobj, KOBJ_ADD); 376 kobject_uevent(&pdev->kobj, KOBJ_ADD);
370 377 return p;
371 if (!hd_ref_init(p))
372 return p;
373 378
374out_free_info: 379out_free_info:
375 free_part_info(p); 380 free_part_info(p);
@@ -378,6 +383,8 @@ out_free_stats:
378out_free: 383out_free:
379 kfree(p); 384 kfree(p);
380 return ERR_PTR(err); 385 return ERR_PTR(err);
386out_remove_file:
387 device_remove_file(pdev, &dev_attr_whole_disk);
381out_del: 388out_del:
382 kobject_put(p->holder_dir); 389 kobject_put(p->holder_dir);
383 device_del(pdev); 390 device_del(pdev);
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 423f4ca7d712..80cf8add46ff 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -488,6 +488,12 @@ static int lo_rw_aio(struct loop_device *lo, struct loop_cmd *cmd,
488 bvec = __bvec_iter_bvec(bio->bi_io_vec, bio->bi_iter); 488 bvec = __bvec_iter_bvec(bio->bi_io_vec, bio->bi_iter);
489 iov_iter_bvec(&iter, ITER_BVEC | rw, bvec, 489 iov_iter_bvec(&iter, ITER_BVEC | rw, bvec,
490 bio_segments(bio), blk_rq_bytes(cmd->rq)); 490 bio_segments(bio), blk_rq_bytes(cmd->rq));
491 /*
492 * This bio may be started from the middle of the 'bvec'
493 * because of bio splitting, so offset from the bvec must
494 * be passed to iov iterator
495 */
496 iter.iov_offset = bio->bi_iter.bi_bvec_done;
491 497
492 cmd->iocb.ki_pos = pos; 498 cmd->iocb.ki_pos = pos;
493 cmd->iocb.ki_filp = file; 499 cmd->iocb.ki_filp = file;
diff --git a/drivers/bus/mvebu-mbus.c b/drivers/bus/mvebu-mbus.c
index c2e52864bb03..ce54a0160faa 100644
--- a/drivers/bus/mvebu-mbus.c
+++ b/drivers/bus/mvebu-mbus.c
@@ -972,7 +972,7 @@ int mvebu_mbus_get_dram_win_info(phys_addr_t phyaddr, u8 *target, u8 *attr)
972 } 972 }
973 } 973 }
974 974
975 pr_err("invalid dram address 0x%x\n", phyaddr); 975 pr_err("invalid dram address %pa\n", &phyaddr);
976 return -EINVAL; 976 return -EINVAL;
977} 977}
978EXPORT_SYMBOL_GPL(mvebu_mbus_get_dram_win_info); 978EXPORT_SYMBOL_GPL(mvebu_mbus_get_dram_win_info);
diff --git a/drivers/bus/uniphier-system-bus.c b/drivers/bus/uniphier-system-bus.c
index 834a2aeaf27a..350b7309c26d 100644
--- a/drivers/bus/uniphier-system-bus.c
+++ b/drivers/bus/uniphier-system-bus.c
@@ -108,7 +108,7 @@ static int uniphier_system_bus_check_overlap(
108 108
109 for (i = 0; i < ARRAY_SIZE(priv->bank); i++) { 109 for (i = 0; i < ARRAY_SIZE(priv->bank); i++) {
110 for (j = i + 1; j < ARRAY_SIZE(priv->bank); j++) { 110 for (j = i + 1; j < ARRAY_SIZE(priv->bank); j++) {
111 if (priv->bank[i].end > priv->bank[j].base || 111 if (priv->bank[i].end > priv->bank[j].base &&
112 priv->bank[i].base < priv->bank[j].end) { 112 priv->bank[i].base < priv->bank[j].end) {
113 dev_err(priv->dev, 113 dev_err(priv->dev,
114 "region overlap between bank%d and bank%d\n", 114 "region overlap between bank%d and bank%d\n",
diff --git a/drivers/char/hw_random/bcm63xx-rng.c b/drivers/char/hw_random/bcm63xx-rng.c
index ca9c40309757..5132c9cde50d 100644
--- a/drivers/char/hw_random/bcm63xx-rng.c
+++ b/drivers/char/hw_random/bcm63xx-rng.c
@@ -12,6 +12,7 @@
12#include <linux/clk.h> 12#include <linux/clk.h>
13#include <linux/platform_device.h> 13#include <linux/platform_device.h>
14#include <linux/hw_random.h> 14#include <linux/hw_random.h>
15#include <linux/of.h>
15 16
16#define RNG_CTRL 0x00 17#define RNG_CTRL 0x00
17#define RNG_EN (1 << 0) 18#define RNG_EN (1 << 0)
diff --git a/drivers/dma/dw/core.c b/drivers/dma/dw/core.c
index 5ad0ec1f0e29..97199b3c25a2 100644
--- a/drivers/dma/dw/core.c
+++ b/drivers/dma/dw/core.c
@@ -130,26 +130,14 @@ static void dwc_desc_put(struct dw_dma_chan *dwc, struct dw_desc *desc)
130static void dwc_initialize(struct dw_dma_chan *dwc) 130static void dwc_initialize(struct dw_dma_chan *dwc)
131{ 131{
132 struct dw_dma *dw = to_dw_dma(dwc->chan.device); 132 struct dw_dma *dw = to_dw_dma(dwc->chan.device);
133 struct dw_dma_slave *dws = dwc->chan.private;
134 u32 cfghi = DWC_CFGH_FIFO_MODE; 133 u32 cfghi = DWC_CFGH_FIFO_MODE;
135 u32 cfglo = DWC_CFGL_CH_PRIOR(dwc->priority); 134 u32 cfglo = DWC_CFGL_CH_PRIOR(dwc->priority);
136 135
137 if (dwc->initialized == true) 136 if (dwc->initialized == true)
138 return; 137 return;
139 138
140 if (dws) { 139 cfghi |= DWC_CFGH_DST_PER(dwc->dst_id);
141 /* 140 cfghi |= DWC_CFGH_SRC_PER(dwc->src_id);
142 * We need controller-specific data to set up slave
143 * transfers.
144 */
145 BUG_ON(!dws->dma_dev || dws->dma_dev != dw->dma.dev);
146
147 cfghi |= DWC_CFGH_DST_PER(dws->dst_id);
148 cfghi |= DWC_CFGH_SRC_PER(dws->src_id);
149 } else {
150 cfghi |= DWC_CFGH_DST_PER(dwc->dst_id);
151 cfghi |= DWC_CFGH_SRC_PER(dwc->src_id);
152 }
153 141
154 channel_writel(dwc, CFG_LO, cfglo); 142 channel_writel(dwc, CFG_LO, cfglo);
155 channel_writel(dwc, CFG_HI, cfghi); 143 channel_writel(dwc, CFG_HI, cfghi);
@@ -941,7 +929,7 @@ bool dw_dma_filter(struct dma_chan *chan, void *param)
941 struct dw_dma_chan *dwc = to_dw_dma_chan(chan); 929 struct dw_dma_chan *dwc = to_dw_dma_chan(chan);
942 struct dw_dma_slave *dws = param; 930 struct dw_dma_slave *dws = param;
943 931
944 if (!dws || dws->dma_dev != chan->device->dev) 932 if (dws->dma_dev != chan->device->dev)
945 return false; 933 return false;
946 934
947 /* We have to copy data since dws can be temporary storage */ 935 /* We have to copy data since dws can be temporary storage */
@@ -1165,6 +1153,14 @@ static int dwc_alloc_chan_resources(struct dma_chan *chan)
1165 * doesn't mean what you think it means), and status writeback. 1153 * doesn't mean what you think it means), and status writeback.
1166 */ 1154 */
1167 1155
1156 /*
1157 * We need controller-specific data to set up slave transfers.
1158 */
1159 if (chan->private && !dw_dma_filter(chan, chan->private)) {
1160 dev_warn(chan2dev(chan), "Wrong controller-specific data\n");
1161 return -EINVAL;
1162 }
1163
1168 /* Enable controller here if needed */ 1164 /* Enable controller here if needed */
1169 if (!dw->in_use) 1165 if (!dw->in_use)
1170 dw_dma_on(dw); 1166 dw_dma_on(dw);
@@ -1226,6 +1222,14 @@ static void dwc_free_chan_resources(struct dma_chan *chan)
1226 spin_lock_irqsave(&dwc->lock, flags); 1222 spin_lock_irqsave(&dwc->lock, flags);
1227 list_splice_init(&dwc->free_list, &list); 1223 list_splice_init(&dwc->free_list, &list);
1228 dwc->descs_allocated = 0; 1224 dwc->descs_allocated = 0;
1225
1226 /* Clear custom channel configuration */
1227 dwc->src_id = 0;
1228 dwc->dst_id = 0;
1229
1230 dwc->src_master = 0;
1231 dwc->dst_master = 0;
1232
1229 dwc->initialized = false; 1233 dwc->initialized = false;
1230 1234
1231 /* Disable interrupts */ 1235 /* Disable interrupts */
diff --git a/drivers/dma/edma.c b/drivers/dma/edma.c
index ee3463e774f8..04070baab78a 100644
--- a/drivers/dma/edma.c
+++ b/drivers/dma/edma.c
@@ -1238,6 +1238,7 @@ static struct dma_async_tx_descriptor *edma_prep_dma_cyclic(
1238 struct edma_desc *edesc; 1238 struct edma_desc *edesc;
1239 dma_addr_t src_addr, dst_addr; 1239 dma_addr_t src_addr, dst_addr;
1240 enum dma_slave_buswidth dev_width; 1240 enum dma_slave_buswidth dev_width;
1241 bool use_intermediate = false;
1241 u32 burst; 1242 u32 burst;
1242 int i, ret, nslots; 1243 int i, ret, nslots;
1243 1244
@@ -1279,8 +1280,21 @@ static struct dma_async_tx_descriptor *edma_prep_dma_cyclic(
1279 * but the synchronization is difficult to achieve with Cyclic and 1280 * but the synchronization is difficult to achieve with Cyclic and
1280 * cannot be guaranteed, so we error out early. 1281 * cannot be guaranteed, so we error out early.
1281 */ 1282 */
1282 if (nslots > MAX_NR_SG) 1283 if (nslots > MAX_NR_SG) {
1283 return NULL; 1284 /*
1285 * If the burst and period sizes are the same, we can put
1286 * the full buffer into a single period and activate
1287 * intermediate interrupts. This will produce interrupts
1288 * after each burst, which is also after each desired period.
1289 */
1290 if (burst == period_len) {
1291 period_len = buf_len;
1292 nslots = 2;
1293 use_intermediate = true;
1294 } else {
1295 return NULL;
1296 }
1297 }
1284 1298
1285 edesc = kzalloc(sizeof(*edesc) + nslots * sizeof(edesc->pset[0]), 1299 edesc = kzalloc(sizeof(*edesc) + nslots * sizeof(edesc->pset[0]),
1286 GFP_ATOMIC); 1300 GFP_ATOMIC);
@@ -1358,8 +1372,13 @@ static struct dma_async_tx_descriptor *edma_prep_dma_cyclic(
1358 /* 1372 /*
1359 * Enable period interrupt only if it is requested 1373 * Enable period interrupt only if it is requested
1360 */ 1374 */
1361 if (tx_flags & DMA_PREP_INTERRUPT) 1375 if (tx_flags & DMA_PREP_INTERRUPT) {
1362 edesc->pset[i].param.opt |= TCINTEN; 1376 edesc->pset[i].param.opt |= TCINTEN;
1377
1378 /* Also enable intermediate interrupts if necessary */
1379 if (use_intermediate)
1380 edesc->pset[i].param.opt |= ITCINTEN;
1381 }
1363 } 1382 }
1364 1383
1365 /* Place the cyclic channel to highest priority queue */ 1384 /* Place the cyclic channel to highest priority queue */
@@ -1570,32 +1589,6 @@ static irqreturn_t dma_ccerr_handler(int irq, void *data)
1570 return IRQ_HANDLED; 1589 return IRQ_HANDLED;
1571} 1590}
1572 1591
1573static void edma_tc_set_pm_state(struct edma_tc *tc, bool enable)
1574{
1575 struct platform_device *tc_pdev;
1576 int ret;
1577
1578 if (!IS_ENABLED(CONFIG_OF) || !tc)
1579 return;
1580
1581 tc_pdev = of_find_device_by_node(tc->node);
1582 if (!tc_pdev) {
1583 pr_err("%s: TPTC device is not found\n", __func__);
1584 return;
1585 }
1586 if (!pm_runtime_enabled(&tc_pdev->dev))
1587 pm_runtime_enable(&tc_pdev->dev);
1588
1589 if (enable)
1590 ret = pm_runtime_get_sync(&tc_pdev->dev);
1591 else
1592 ret = pm_runtime_put_sync(&tc_pdev->dev);
1593
1594 if (ret < 0)
1595 pr_err("%s: pm_runtime_%s_sync() failed for %s\n", __func__,
1596 enable ? "get" : "put", dev_name(&tc_pdev->dev));
1597}
1598
1599/* Alloc channel resources */ 1592/* Alloc channel resources */
1600static int edma_alloc_chan_resources(struct dma_chan *chan) 1593static int edma_alloc_chan_resources(struct dma_chan *chan)
1601{ 1594{
@@ -1632,8 +1625,6 @@ static int edma_alloc_chan_resources(struct dma_chan *chan)
1632 EDMA_CHAN_SLOT(echan->ch_num), chan->chan_id, 1625 EDMA_CHAN_SLOT(echan->ch_num), chan->chan_id,
1633 echan->hw_triggered ? "HW" : "SW"); 1626 echan->hw_triggered ? "HW" : "SW");
1634 1627
1635 edma_tc_set_pm_state(echan->tc, true);
1636
1637 return 0; 1628 return 0;
1638 1629
1639err_slot: 1630err_slot:
@@ -1670,7 +1661,6 @@ static void edma_free_chan_resources(struct dma_chan *chan)
1670 echan->alloced = false; 1661 echan->alloced = false;
1671 } 1662 }
1672 1663
1673 edma_tc_set_pm_state(echan->tc, false);
1674 echan->tc = NULL; 1664 echan->tc = NULL;
1675 echan->hw_triggered = false; 1665 echan->hw_triggered = false;
1676 1666
@@ -2417,10 +2407,8 @@ static int edma_pm_suspend(struct device *dev)
2417 int i; 2407 int i;
2418 2408
2419 for (i = 0; i < ecc->num_channels; i++) { 2409 for (i = 0; i < ecc->num_channels; i++) {
2420 if (echan[i].alloced) { 2410 if (echan[i].alloced)
2421 edma_setup_interrupt(&echan[i], false); 2411 edma_setup_interrupt(&echan[i], false);
2422 edma_tc_set_pm_state(echan[i].tc, false);
2423 }
2424 } 2412 }
2425 2413
2426 return 0; 2414 return 0;
@@ -2450,8 +2438,6 @@ static int edma_pm_resume(struct device *dev)
2450 2438
2451 /* Set up channel -> slot mapping for the entry slot */ 2439 /* Set up channel -> slot mapping for the entry slot */
2452 edma_set_chmap(&echan[i], echan[i].slot[0]); 2440 edma_set_chmap(&echan[i], echan[i].slot[0]);
2453
2454 edma_tc_set_pm_state(echan[i].tc, true);
2455 } 2441 }
2456 } 2442 }
2457 2443
@@ -2475,7 +2461,8 @@ static struct platform_driver edma_driver = {
2475 2461
2476static int edma_tptc_probe(struct platform_device *pdev) 2462static int edma_tptc_probe(struct platform_device *pdev)
2477{ 2463{
2478 return 0; 2464 pm_runtime_enable(&pdev->dev);
2465 return pm_runtime_get_sync(&pdev->dev);
2479} 2466}
2480 2467
2481static struct platform_driver edma_tptc_driver = { 2468static struct platform_driver edma_tptc_driver = {
diff --git a/drivers/dma/hsu/hsu.c b/drivers/dma/hsu/hsu.c
index eef145edb936..ee510515ce18 100644
--- a/drivers/dma/hsu/hsu.c
+++ b/drivers/dma/hsu/hsu.c
@@ -64,10 +64,10 @@ static void hsu_dma_chan_start(struct hsu_dma_chan *hsuc)
64 64
65 if (hsuc->direction == DMA_MEM_TO_DEV) { 65 if (hsuc->direction == DMA_MEM_TO_DEV) {
66 bsr = config->dst_maxburst; 66 bsr = config->dst_maxburst;
67 mtsr = config->dst_addr_width; 67 mtsr = config->src_addr_width;
68 } else if (hsuc->direction == DMA_DEV_TO_MEM) { 68 } else if (hsuc->direction == DMA_DEV_TO_MEM) {
69 bsr = config->src_maxburst; 69 bsr = config->src_maxburst;
70 mtsr = config->src_addr_width; 70 mtsr = config->dst_addr_width;
71 } 71 }
72 72
73 hsu_chan_disable(hsuc); 73 hsu_chan_disable(hsuc);
@@ -135,7 +135,7 @@ static u32 hsu_dma_chan_get_sr(struct hsu_dma_chan *hsuc)
135 sr = hsu_chan_readl(hsuc, HSU_CH_SR); 135 sr = hsu_chan_readl(hsuc, HSU_CH_SR);
136 spin_unlock_irqrestore(&hsuc->vchan.lock, flags); 136 spin_unlock_irqrestore(&hsuc->vchan.lock, flags);
137 137
138 return sr; 138 return sr & ~(HSU_CH_SR_DESCE_ANY | HSU_CH_SR_CDESC_ANY);
139} 139}
140 140
141irqreturn_t hsu_dma_irq(struct hsu_dma_chip *chip, unsigned short nr) 141irqreturn_t hsu_dma_irq(struct hsu_dma_chip *chip, unsigned short nr)
@@ -254,10 +254,13 @@ static void hsu_dma_issue_pending(struct dma_chan *chan)
254static size_t hsu_dma_active_desc_size(struct hsu_dma_chan *hsuc) 254static size_t hsu_dma_active_desc_size(struct hsu_dma_chan *hsuc)
255{ 255{
256 struct hsu_dma_desc *desc = hsuc->desc; 256 struct hsu_dma_desc *desc = hsuc->desc;
257 size_t bytes = desc->length; 257 size_t bytes = 0;
258 int i; 258 int i;
259 259
260 i = desc->active % HSU_DMA_CHAN_NR_DESC; 260 for (i = desc->active; i < desc->nents; i++)
261 bytes += desc->sg[i].len;
262
263 i = HSU_DMA_CHAN_NR_DESC - 1;
261 do { 264 do {
262 bytes += hsu_chan_readl(hsuc, HSU_CH_DxTSR(i)); 265 bytes += hsu_chan_readl(hsuc, HSU_CH_DxTSR(i));
263 } while (--i >= 0); 266 } while (--i >= 0);
diff --git a/drivers/dma/hsu/hsu.h b/drivers/dma/hsu/hsu.h
index 578a8ee8cd05..6b070c22b1df 100644
--- a/drivers/dma/hsu/hsu.h
+++ b/drivers/dma/hsu/hsu.h
@@ -41,6 +41,9 @@
41#define HSU_CH_SR_DESCTO(x) BIT(8 + (x)) 41#define HSU_CH_SR_DESCTO(x) BIT(8 + (x))
42#define HSU_CH_SR_DESCTO_ANY (BIT(11) | BIT(10) | BIT(9) | BIT(8)) 42#define HSU_CH_SR_DESCTO_ANY (BIT(11) | BIT(10) | BIT(9) | BIT(8))
43#define HSU_CH_SR_CHE BIT(15) 43#define HSU_CH_SR_CHE BIT(15)
44#define HSU_CH_SR_DESCE(x) BIT(16 + (x))
45#define HSU_CH_SR_DESCE_ANY (BIT(19) | BIT(18) | BIT(17) | BIT(16))
46#define HSU_CH_SR_CDESC_ANY (BIT(31) | BIT(30))
44 47
45/* Bits in HSU_CH_CR */ 48/* Bits in HSU_CH_CR */
46#define HSU_CH_CR_CHA BIT(0) 49#define HSU_CH_CR_CHA BIT(0)
diff --git a/drivers/dma/omap-dma.c b/drivers/dma/omap-dma.c
index 43bd5aee7ffe..1e984e18c126 100644
--- a/drivers/dma/omap-dma.c
+++ b/drivers/dma/omap-dma.c
@@ -48,6 +48,7 @@ struct omap_chan {
48 unsigned dma_sig; 48 unsigned dma_sig;
49 bool cyclic; 49 bool cyclic;
50 bool paused; 50 bool paused;
51 bool running;
51 52
52 int dma_ch; 53 int dma_ch;
53 struct omap_desc *desc; 54 struct omap_desc *desc;
@@ -294,6 +295,8 @@ static void omap_dma_start(struct omap_chan *c, struct omap_desc *d)
294 295
295 /* Enable channel */ 296 /* Enable channel */
296 omap_dma_chan_write(c, CCR, d->ccr | CCR_ENABLE); 297 omap_dma_chan_write(c, CCR, d->ccr | CCR_ENABLE);
298
299 c->running = true;
297} 300}
298 301
299static void omap_dma_stop(struct omap_chan *c) 302static void omap_dma_stop(struct omap_chan *c)
@@ -355,6 +358,8 @@ static void omap_dma_stop(struct omap_chan *c)
355 358
356 omap_dma_chan_write(c, CLNK_CTRL, val); 359 omap_dma_chan_write(c, CLNK_CTRL, val);
357 } 360 }
361
362 c->running = false;
358} 363}
359 364
360static void omap_dma_start_sg(struct omap_chan *c, struct omap_desc *d, 365static void omap_dma_start_sg(struct omap_chan *c, struct omap_desc *d,
@@ -673,15 +678,20 @@ static enum dma_status omap_dma_tx_status(struct dma_chan *chan,
673 struct omap_chan *c = to_omap_dma_chan(chan); 678 struct omap_chan *c = to_omap_dma_chan(chan);
674 struct virt_dma_desc *vd; 679 struct virt_dma_desc *vd;
675 enum dma_status ret; 680 enum dma_status ret;
676 uint32_t ccr;
677 unsigned long flags; 681 unsigned long flags;
678 682
679 ccr = omap_dma_chan_read(c, CCR);
680 /* The channel is no longer active, handle the completion right away */
681 if (!(ccr & CCR_ENABLE))
682 omap_dma_callback(c->dma_ch, 0, c);
683
684 ret = dma_cookie_status(chan, cookie, txstate); 683 ret = dma_cookie_status(chan, cookie, txstate);
684
685 if (!c->paused && c->running) {
686 uint32_t ccr = omap_dma_chan_read(c, CCR);
687 /*
688 * The channel is no longer active, set the return value
689 * accordingly
690 */
691 if (!(ccr & CCR_ENABLE))
692 ret = DMA_COMPLETE;
693 }
694
685 if (ret == DMA_COMPLETE || !txstate) 695 if (ret == DMA_COMPLETE || !txstate)
686 return ret; 696 return ret;
687 697
@@ -945,9 +955,7 @@ static struct dma_async_tx_descriptor *omap_dma_prep_dma_memcpy(
945 d->ccr = c->ccr; 955 d->ccr = c->ccr;
946 d->ccr |= CCR_DST_AMODE_POSTINC | CCR_SRC_AMODE_POSTINC; 956 d->ccr |= CCR_DST_AMODE_POSTINC | CCR_SRC_AMODE_POSTINC;
947 957
948 d->cicr = CICR_DROP_IE; 958 d->cicr = CICR_DROP_IE | CICR_FRAME_IE;
949 if (tx_flags & DMA_PREP_INTERRUPT)
950 d->cicr |= CICR_FRAME_IE;
951 959
952 d->csdp = data_type; 960 d->csdp = data_type;
953 961
diff --git a/drivers/dma/xilinx/xilinx_vdma.c b/drivers/dma/xilinx/xilinx_vdma.c
index 0ee0321868d3..ef67f278e076 100644
--- a/drivers/dma/xilinx/xilinx_vdma.c
+++ b/drivers/dma/xilinx/xilinx_vdma.c
@@ -1236,7 +1236,7 @@ static struct dma_chan *of_dma_xilinx_xlate(struct of_phandle_args *dma_spec,
1236 struct xilinx_vdma_device *xdev = ofdma->of_dma_data; 1236 struct xilinx_vdma_device *xdev = ofdma->of_dma_data;
1237 int chan_id = dma_spec->args[0]; 1237 int chan_id = dma_spec->args[0];
1238 1238
1239 if (chan_id >= XILINX_VDMA_MAX_CHANS_PER_DEVICE) 1239 if (chan_id >= XILINX_VDMA_MAX_CHANS_PER_DEVICE || !xdev->chan[chan_id])
1240 return NULL; 1240 return NULL;
1241 1241
1242 return dma_get_slave_channel(&xdev->chan[chan_id]->common); 1242 return dma_get_slave_channel(&xdev->chan[chan_id]->common);
diff --git a/drivers/extcon/extcon-palmas.c b/drivers/extcon/extcon-palmas.c
index 841a4b586395..8b3226dca1d9 100644
--- a/drivers/extcon/extcon-palmas.c
+++ b/drivers/extcon/extcon-palmas.c
@@ -348,8 +348,7 @@ static int palmas_usb_probe(struct platform_device *pdev)
348 palmas_vbus_irq_handler, 348 palmas_vbus_irq_handler,
349 IRQF_TRIGGER_FALLING | 349 IRQF_TRIGGER_FALLING |
350 IRQF_TRIGGER_RISING | 350 IRQF_TRIGGER_RISING |
351 IRQF_ONESHOT | 351 IRQF_ONESHOT,
352 IRQF_EARLY_RESUME,
353 "palmas_usb_vbus", 352 "palmas_usb_vbus",
354 palmas_usb); 353 palmas_usb);
355 if (status < 0) { 354 if (status < 0) {
diff --git a/drivers/firmware/efi/arm-init.c b/drivers/firmware/efi/arm-init.c
index aa1f743152a2..8714f8c271ba 100644
--- a/drivers/firmware/efi/arm-init.c
+++ b/drivers/firmware/efi/arm-init.c
@@ -203,7 +203,19 @@ void __init efi_init(void)
203 203
204 reserve_regions(); 204 reserve_regions();
205 early_memunmap(memmap.map, params.mmap_size); 205 early_memunmap(memmap.map, params.mmap_size);
206 memblock_mark_nomap(params.mmap & PAGE_MASK, 206
207 PAGE_ALIGN(params.mmap_size + 207 if (IS_ENABLED(CONFIG_ARM)) {
208 (params.mmap & ~PAGE_MASK))); 208 /*
209 * ARM currently does not allow ioremap_cache() to be called on
210 * memory regions that are covered by struct page. So remove the
211 * UEFI memory map from the linear mapping.
212 */
213 memblock_mark_nomap(params.mmap & PAGE_MASK,
214 PAGE_ALIGN(params.mmap_size +
215 (params.mmap & ~PAGE_MASK)));
216 } else {
217 memblock_reserve(params.mmap & PAGE_MASK,
218 PAGE_ALIGN(params.mmap_size +
219 (params.mmap & ~PAGE_MASK)));
220 }
209} 221}
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 62a778012fe0..b77489dec6e8 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -2034,6 +2034,7 @@ struct amdgpu_device {
2034 2034
2035 /* tracking pinned memory */ 2035 /* tracking pinned memory */
2036 u64 vram_pin_size; 2036 u64 vram_pin_size;
2037 u64 invisible_pin_size;
2037 u64 gart_pin_size; 2038 u64 gart_pin_size;
2038 2039
2039 /* amdkfd interface */ 2040 /* amdkfd interface */
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
index 598eb0cd5aab..aef70db16832 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
@@ -384,7 +384,7 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file
384 vram_gtt.vram_size = adev->mc.real_vram_size; 384 vram_gtt.vram_size = adev->mc.real_vram_size;
385 vram_gtt.vram_size -= adev->vram_pin_size; 385 vram_gtt.vram_size -= adev->vram_pin_size;
386 vram_gtt.vram_cpu_accessible_size = adev->mc.visible_vram_size; 386 vram_gtt.vram_cpu_accessible_size = adev->mc.visible_vram_size;
387 vram_gtt.vram_cpu_accessible_size -= adev->vram_pin_size; 387 vram_gtt.vram_cpu_accessible_size -= (adev->vram_pin_size - adev->invisible_pin_size);
388 vram_gtt.gtt_size = adev->mc.gtt_size; 388 vram_gtt.gtt_size = adev->mc.gtt_size;
389 vram_gtt.gtt_size -= adev->gart_pin_size; 389 vram_gtt.gtt_size -= adev->gart_pin_size;
390 return copy_to_user(out, &vram_gtt, 390 return copy_to_user(out, &vram_gtt,
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index 5b6639faa731..e557fc1f17c8 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -424,9 +424,11 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain,
424 bo->pin_count = 1; 424 bo->pin_count = 1;
425 if (gpu_addr != NULL) 425 if (gpu_addr != NULL)
426 *gpu_addr = amdgpu_bo_gpu_offset(bo); 426 *gpu_addr = amdgpu_bo_gpu_offset(bo);
427 if (domain == AMDGPU_GEM_DOMAIN_VRAM) 427 if (domain == AMDGPU_GEM_DOMAIN_VRAM) {
428 bo->adev->vram_pin_size += amdgpu_bo_size(bo); 428 bo->adev->vram_pin_size += amdgpu_bo_size(bo);
429 else 429 if (bo->flags & AMDGPU_GEM_CREATE_NO_CPU_ACCESS)
430 bo->adev->invisible_pin_size += amdgpu_bo_size(bo);
431 } else
430 bo->adev->gart_pin_size += amdgpu_bo_size(bo); 432 bo->adev->gart_pin_size += amdgpu_bo_size(bo);
431 } else { 433 } else {
432 dev_err(bo->adev->dev, "%p pin failed\n", bo); 434 dev_err(bo->adev->dev, "%p pin failed\n", bo);
@@ -456,9 +458,11 @@ int amdgpu_bo_unpin(struct amdgpu_bo *bo)
456 } 458 }
457 r = ttm_bo_validate(&bo->tbo, &bo->placement, false, false); 459 r = ttm_bo_validate(&bo->tbo, &bo->placement, false, false);
458 if (likely(r == 0)) { 460 if (likely(r == 0)) {
459 if (bo->tbo.mem.mem_type == TTM_PL_VRAM) 461 if (bo->tbo.mem.mem_type == TTM_PL_VRAM) {
460 bo->adev->vram_pin_size -= amdgpu_bo_size(bo); 462 bo->adev->vram_pin_size -= amdgpu_bo_size(bo);
461 else 463 if (bo->flags & AMDGPU_GEM_CREATE_NO_CPU_ACCESS)
464 bo->adev->invisible_pin_size -= amdgpu_bo_size(bo);
465 } else
462 bo->adev->gart_pin_size -= amdgpu_bo_size(bo); 466 bo->adev->gart_pin_size -= amdgpu_bo_size(bo);
463 } else { 467 } else {
464 dev_err(bo->adev->dev, "%p validate failed for unpin\n", bo); 468 dev_err(bo->adev->dev, "%p validate failed for unpin\n", bo);
diff --git a/drivers/gpu/drm/amd/amdgpu/tonga_ih.c b/drivers/gpu/drm/amd/amdgpu/tonga_ih.c
index b6f7d7bff929..0f14199cf716 100644
--- a/drivers/gpu/drm/amd/amdgpu/tonga_ih.c
+++ b/drivers/gpu/drm/amd/amdgpu/tonga_ih.c
@@ -307,7 +307,7 @@ static int tonga_ih_sw_fini(void *handle)
307 307
308 amdgpu_irq_fini(adev); 308 amdgpu_irq_fini(adev);
309 amdgpu_ih_ring_fini(adev); 309 amdgpu_ih_ring_fini(adev);
310 amdgpu_irq_add_domain(adev); 310 amdgpu_irq_remove_domain(adev);
311 311
312 return 0; 312 return 0;
313} 313}
diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index 414d7f61aa05..558ef9fc39e6 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -205,7 +205,7 @@ static const struct drm_display_mode drm_dmt_modes[] = {
205 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, 205 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
206 /* 0x0f - 1024x768@43Hz, interlace */ 206 /* 0x0f - 1024x768@43Hz, interlace */
207 { DRM_MODE("1024x768i", DRM_MODE_TYPE_DRIVER, 44900, 1024, 1032, 207 { DRM_MODE("1024x768i", DRM_MODE_TYPE_DRIVER, 44900, 1024, 1032,
208 1208, 1264, 0, 768, 768, 772, 817, 0, 208 1208, 1264, 0, 768, 768, 776, 817, 0,
209 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC | 209 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC |
210 DRM_MODE_FLAG_INTERLACE) }, 210 DRM_MODE_FLAG_INTERLACE) },
211 /* 0x10 - 1024x768@60Hz */ 211 /* 0x10 - 1024x768@60Hz */
@@ -522,12 +522,12 @@ static const struct drm_display_mode edid_est_modes[] = {
522 720, 840, 0, 480, 481, 484, 500, 0, 522 720, 840, 0, 480, 481, 484, 500, 0,
523 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, /* 640x480@75Hz */ 523 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, /* 640x480@75Hz */
524 { DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 31500, 640, 664, 524 { DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 31500, 640, 664,
525 704, 832, 0, 480, 489, 491, 520, 0, 525 704, 832, 0, 480, 489, 492, 520, 0,
526 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, /* 640x480@72Hz */ 526 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, /* 640x480@72Hz */
527 { DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 30240, 640, 704, 527 { DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 30240, 640, 704,
528 768, 864, 0, 480, 483, 486, 525, 0, 528 768, 864, 0, 480, 483, 486, 525, 0,
529 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, /* 640x480@67Hz */ 529 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, /* 640x480@67Hz */
530 { DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 25200, 640, 656, 530 { DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 25175, 640, 656,
531 752, 800, 0, 480, 490, 492, 525, 0, 531 752, 800, 0, 480, 490, 492, 525, 0,
532 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, /* 640x480@60Hz */ 532 DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, /* 640x480@60Hz */
533 { DRM_MODE("720x400", DRM_MODE_TYPE_DRIVER, 35500, 720, 738, 533 { DRM_MODE("720x400", DRM_MODE_TYPE_DRIVER, 35500, 720, 738,
@@ -539,7 +539,7 @@ static const struct drm_display_mode edid_est_modes[] = {
539 { DRM_MODE("1280x1024", DRM_MODE_TYPE_DRIVER, 135000, 1280, 1296, 539 { DRM_MODE("1280x1024", DRM_MODE_TYPE_DRIVER, 135000, 1280, 1296,
540 1440, 1688, 0, 1024, 1025, 1028, 1066, 0, 540 1440, 1688, 0, 1024, 1025, 1028, 1066, 0,
541 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, /* 1280x1024@75Hz */ 541 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, /* 1280x1024@75Hz */
542 { DRM_MODE("1024x768", DRM_MODE_TYPE_DRIVER, 78800, 1024, 1040, 542 { DRM_MODE("1024x768", DRM_MODE_TYPE_DRIVER, 78750, 1024, 1040,
543 1136, 1312, 0, 768, 769, 772, 800, 0, 543 1136, 1312, 0, 768, 769, 772, 800, 0,
544 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, /* 1024x768@75Hz */ 544 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, /* 1024x768@75Hz */
545 { DRM_MODE("1024x768", DRM_MODE_TYPE_DRIVER, 75000, 1024, 1048, 545 { DRM_MODE("1024x768", DRM_MODE_TYPE_DRIVER, 75000, 1024, 1048,
@@ -2241,7 +2241,7 @@ drm_est3_modes(struct drm_connector *connector, struct detailed_timing *timing)
2241{ 2241{
2242 int i, j, m, modes = 0; 2242 int i, j, m, modes = 0;
2243 struct drm_display_mode *mode; 2243 struct drm_display_mode *mode;
2244 u8 *est = ((u8 *)timing) + 5; 2244 u8 *est = ((u8 *)timing) + 6;
2245 2245
2246 for (i = 0; i < 6; i++) { 2246 for (i = 0; i < 6; i++) {
2247 for (j = 7; j >= 0; j--) { 2247 for (j = 7; j >= 0; j--) {
diff --git a/drivers/gpu/drm/exynos/Kconfig b/drivers/gpu/drm/exynos/Kconfig
index f17d39279596..baddf33fb475 100644
--- a/drivers/gpu/drm/exynos/Kconfig
+++ b/drivers/gpu/drm/exynos/Kconfig
@@ -94,7 +94,7 @@ comment "Sub-drivers"
94 94
95config DRM_EXYNOS_G2D 95config DRM_EXYNOS_G2D
96 bool "G2D" 96 bool "G2D"
97 depends on !VIDEO_SAMSUNG_S5P_G2D 97 depends on VIDEO_SAMSUNG_S5P_G2D=n
98 select FRAME_VECTOR 98 select FRAME_VECTOR
99 help 99 help
100 Choose this option if you want to use Exynos G2D for DRM. 100 Choose this option if you want to use Exynos G2D for DRM.
diff --git a/drivers/gpu/drm/exynos/Makefile b/drivers/gpu/drm/exynos/Makefile
index 968b31c522b2..23d2f958739b 100644
--- a/drivers/gpu/drm/exynos/Makefile
+++ b/drivers/gpu/drm/exynos/Makefile
@@ -2,10 +2,10 @@
2# Makefile for the drm device driver. This driver provides support for the 2# Makefile for the drm device driver. This driver provides support for the
3# Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher. 3# Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.
4 4
5exynosdrm-y := exynos_drm_drv.o exynos_drm_crtc.o exynos_drm_fbdev.o \ 5exynosdrm-y := exynos_drm_drv.o exynos_drm_crtc.o exynos_drm_fb.o \
6 exynos_drm_fb.o exynos_drm_gem.o exynos_drm_core.o \ 6 exynos_drm_gem.o exynos_drm_core.o exynos_drm_plane.o
7 exynos_drm_plane.o
8 7
8exynosdrm-$(CONFIG_DRM_FBDEV_EMULATION) += exynos_drm_fbdev.o
9exynosdrm-$(CONFIG_DRM_EXYNOS_IOMMU) += exynos_drm_iommu.o 9exynosdrm-$(CONFIG_DRM_EXYNOS_IOMMU) += exynos_drm_iommu.o
10exynosdrm-$(CONFIG_DRM_EXYNOS_FIMD) += exynos_drm_fimd.o 10exynosdrm-$(CONFIG_DRM_EXYNOS_FIMD) += exynos_drm_fimd.o
11exynosdrm-$(CONFIG_DRM_EXYNOS5433_DECON) += exynos5433_drm_decon.o 11exynosdrm-$(CONFIG_DRM_EXYNOS5433_DECON) += exynos5433_drm_decon.o
diff --git a/drivers/gpu/drm/exynos/exynos_drm_core.c b/drivers/gpu/drm/exynos/exynos_drm_core.c
index 7f55ba6771c6..011211e4167d 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_core.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_core.c
@@ -101,7 +101,7 @@ int exynos_drm_subdrv_open(struct drm_device *dev, struct drm_file *file)
101 return 0; 101 return 0;
102 102
103err: 103err:
104 list_for_each_entry_reverse(subdrv, &subdrv->list, list) { 104 list_for_each_entry_continue_reverse(subdrv, &exynos_drm_subdrv_list, list) {
105 if (subdrv->close) 105 if (subdrv->close)
106 subdrv->close(dev, subdrv->dev, file); 106 subdrv->close(dev, subdrv->dev, file);
107 } 107 }
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fb.c b/drivers/gpu/drm/exynos/exynos_drm_fb.c
index d614194644c8..81cc5537cf25 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fb.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fb.c
@@ -199,17 +199,6 @@ dma_addr_t exynos_drm_fb_dma_addr(struct drm_framebuffer *fb, int index)
199 return exynos_fb->dma_addr[index]; 199 return exynos_fb->dma_addr[index];
200} 200}
201 201
202static void exynos_drm_output_poll_changed(struct drm_device *dev)
203{
204 struct exynos_drm_private *private = dev->dev_private;
205 struct drm_fb_helper *fb_helper = private->fb_helper;
206
207 if (fb_helper)
208 drm_fb_helper_hotplug_event(fb_helper);
209 else
210 exynos_drm_fbdev_init(dev);
211}
212
213static const struct drm_mode_config_funcs exynos_drm_mode_config_funcs = { 202static const struct drm_mode_config_funcs exynos_drm_mode_config_funcs = {
214 .fb_create = exynos_user_fb_create, 203 .fb_create = exynos_user_fb_create,
215 .output_poll_changed = exynos_drm_output_poll_changed, 204 .output_poll_changed = exynos_drm_output_poll_changed,
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
index 4ae860c44f1d..72d7c0b7c216 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
@@ -317,3 +317,14 @@ void exynos_drm_fbdev_restore_mode(struct drm_device *dev)
317 317
318 drm_fb_helper_restore_fbdev_mode_unlocked(private->fb_helper); 318 drm_fb_helper_restore_fbdev_mode_unlocked(private->fb_helper);
319} 319}
320
321void exynos_drm_output_poll_changed(struct drm_device *dev)
322{
323 struct exynos_drm_private *private = dev->dev_private;
324 struct drm_fb_helper *fb_helper = private->fb_helper;
325
326 if (fb_helper)
327 drm_fb_helper_hotplug_event(fb_helper);
328 else
329 exynos_drm_fbdev_init(dev);
330}
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fbdev.h b/drivers/gpu/drm/exynos/exynos_drm_fbdev.h
index e16d7f0ae192..330eef87f718 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fbdev.h
+++ b/drivers/gpu/drm/exynos/exynos_drm_fbdev.h
@@ -15,9 +15,30 @@
15#ifndef _EXYNOS_DRM_FBDEV_H_ 15#ifndef _EXYNOS_DRM_FBDEV_H_
16#define _EXYNOS_DRM_FBDEV_H_ 16#define _EXYNOS_DRM_FBDEV_H_
17 17
18#ifdef CONFIG_DRM_FBDEV_EMULATION
19
18int exynos_drm_fbdev_init(struct drm_device *dev); 20int exynos_drm_fbdev_init(struct drm_device *dev);
19int exynos_drm_fbdev_reinit(struct drm_device *dev);
20void exynos_drm_fbdev_fini(struct drm_device *dev); 21void exynos_drm_fbdev_fini(struct drm_device *dev);
21void exynos_drm_fbdev_restore_mode(struct drm_device *dev); 22void exynos_drm_fbdev_restore_mode(struct drm_device *dev);
23void exynos_drm_output_poll_changed(struct drm_device *dev);
24
25#else
26
27static inline int exynos_drm_fbdev_init(struct drm_device *dev)
28{
29 return 0;
30}
31
32static inline void exynos_drm_fbdev_fini(struct drm_device *dev)
33{
34}
35
36static inline void exynos_drm_fbdev_restore_mode(struct drm_device *dev)
37{
38}
39
40#define exynos_drm_output_poll_changed (NULL)
41
42#endif
22 43
23#endif 44#endif
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
index 51d484ae9f49..018449f8d557 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
@@ -888,7 +888,7 @@ static void fimd_dp_clock_enable(struct exynos_drm_crtc *crtc, bool enable)
888 * clock. On these SoCs the bootloader may enable it but any 888 * clock. On these SoCs the bootloader may enable it but any
889 * power domain off/on will reset it to disable state. 889 * power domain off/on will reset it to disable state.
890 */ 890 */
891 if (ctx->driver_data != &exynos5_fimd_driver_data || 891 if (ctx->driver_data != &exynos5_fimd_driver_data &&
892 ctx->driver_data != &exynos5420_fimd_driver_data) 892 ctx->driver_data != &exynos5420_fimd_driver_data)
893 return; 893 return;
894 894
diff --git a/drivers/gpu/drm/exynos/exynos_drm_mic.c b/drivers/gpu/drm/exynos/exynos_drm_mic.c
index 9869d70e9e54..a0def0be6d65 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_mic.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_mic.c
@@ -129,7 +129,7 @@ static void mic_set_path(struct exynos_mic *mic, bool enable)
129 } else 129 } else
130 val &= ~(MIC0_RGB_MUX | MIC0_I80_MUX | MIC0_ON_MUX); 130 val &= ~(MIC0_RGB_MUX | MIC0_I80_MUX | MIC0_ON_MUX);
131 131
132 regmap_write(mic->sysreg, DSD_CFG_MUX, val); 132 ret = regmap_write(mic->sysreg, DSD_CFG_MUX, val);
133 if (ret) 133 if (ret)
134 DRM_ERROR("mic: Failed to read system register\n"); 134 DRM_ERROR("mic: Failed to read system register\n");
135} 135}
@@ -457,6 +457,7 @@ static int exynos_mic_probe(struct platform_device *pdev)
457 "samsung,disp-syscon"); 457 "samsung,disp-syscon");
458 if (IS_ERR(mic->sysreg)) { 458 if (IS_ERR(mic->sysreg)) {
459 DRM_ERROR("mic: Failed to get system register.\n"); 459 DRM_ERROR("mic: Failed to get system register.\n");
460 ret = PTR_ERR(mic->sysreg);
460 goto err; 461 goto err;
461 } 462 }
462 463
diff --git a/drivers/gpu/drm/exynos/exynos_drm_plane.c b/drivers/gpu/drm/exynos/exynos_drm_plane.c
index d86227236f55..50185ac347b2 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_plane.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_plane.c
@@ -11,9 +11,10 @@
11 11
12#include <drm/drmP.h> 12#include <drm/drmP.h>
13 13
14#include <drm/exynos_drm.h> 14#include <drm/drm_atomic.h>
15#include <drm/drm_plane_helper.h>
16#include <drm/drm_atomic_helper.h> 15#include <drm/drm_atomic_helper.h>
16#include <drm/drm_plane_helper.h>
17#include <drm/exynos_drm.h>
17#include "exynos_drm_drv.h" 18#include "exynos_drm_drv.h"
18#include "exynos_drm_crtc.h" 19#include "exynos_drm_crtc.h"
19#include "exynos_drm_fb.h" 20#include "exynos_drm_fb.h"
@@ -57,11 +58,12 @@ static int exynos_plane_get_size(int start, unsigned length, unsigned last)
57} 58}
58 59
59static void exynos_plane_mode_set(struct exynos_drm_plane_state *exynos_state) 60static void exynos_plane_mode_set(struct exynos_drm_plane_state *exynos_state)
60
61{ 61{
62 struct drm_plane_state *state = &exynos_state->base; 62 struct drm_plane_state *state = &exynos_state->base;
63 struct drm_crtc *crtc = exynos_state->base.crtc; 63 struct drm_crtc *crtc = state->crtc;
64 struct drm_display_mode *mode = &crtc->state->adjusted_mode; 64 struct drm_crtc_state *crtc_state =
65 drm_atomic_get_existing_crtc_state(state->state, crtc);
66 struct drm_display_mode *mode = &crtc_state->adjusted_mode;
65 int crtc_x, crtc_y; 67 int crtc_x, crtc_y;
66 unsigned int crtc_w, crtc_h; 68 unsigned int crtc_w, crtc_h;
67 unsigned int src_x, src_y; 69 unsigned int src_x, src_y;
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index 20e82008b8b6..30798cbc6fc0 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -758,10 +758,10 @@ static int i915_drm_resume(struct drm_device *dev)
758 dev_priv->display.hpd_irq_setup(dev); 758 dev_priv->display.hpd_irq_setup(dev);
759 spin_unlock_irq(&dev_priv->irq_lock); 759 spin_unlock_irq(&dev_priv->irq_lock);
760 760
761 intel_display_resume(dev);
762
763 intel_dp_mst_resume(dev); 761 intel_dp_mst_resume(dev);
764 762
763 intel_display_resume(dev);
764
765 /* 765 /*
766 * ... but also need to make sure that hotplug processing 766 * ... but also need to make sure that hotplug processing
767 * doesn't cause havoc. Like in the driver load code we don't 767 * doesn't cause havoc. Like in the driver load code we don't
diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index d1a46ef5ab3f..1c212205d0e7 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -1829,7 +1829,7 @@ static irqreturn_t cherryview_irq_handler(int irq, void *arg)
1829 /* IRQs are synced during runtime_suspend, we don't require a wakeref */ 1829 /* IRQs are synced during runtime_suspend, we don't require a wakeref */
1830 disable_rpm_wakeref_asserts(dev_priv); 1830 disable_rpm_wakeref_asserts(dev_priv);
1831 1831
1832 for (;;) { 1832 do {
1833 master_ctl = I915_READ(GEN8_MASTER_IRQ) & ~GEN8_MASTER_IRQ_CONTROL; 1833 master_ctl = I915_READ(GEN8_MASTER_IRQ) & ~GEN8_MASTER_IRQ_CONTROL;
1834 iir = I915_READ(VLV_IIR); 1834 iir = I915_READ(VLV_IIR);
1835 1835
@@ -1857,7 +1857,7 @@ static irqreturn_t cherryview_irq_handler(int irq, void *arg)
1857 1857
1858 I915_WRITE(GEN8_MASTER_IRQ, DE_MASTER_IRQ_CONTROL); 1858 I915_WRITE(GEN8_MASTER_IRQ, DE_MASTER_IRQ_CONTROL);
1859 POSTING_READ(GEN8_MASTER_IRQ); 1859 POSTING_READ(GEN8_MASTER_IRQ);
1860 } 1860 } while (0);
1861 1861
1862 enable_rpm_wakeref_asserts(dev_priv); 1862 enable_rpm_wakeref_asserts(dev_priv);
1863 1863
diff --git a/drivers/gpu/drm/i915/intel_dp_mst.c b/drivers/gpu/drm/i915/intel_dp_mst.c
index a2bd698fe2f7..937e77228466 100644
--- a/drivers/gpu/drm/i915/intel_dp_mst.c
+++ b/drivers/gpu/drm/i915/intel_dp_mst.c
@@ -506,6 +506,8 @@ static void intel_dp_destroy_mst_connector(struct drm_dp_mst_topology_mgr *mgr,
506 struct intel_connector *intel_connector = to_intel_connector(connector); 506 struct intel_connector *intel_connector = to_intel_connector(connector);
507 struct drm_device *dev = connector->dev; 507 struct drm_device *dev = connector->dev;
508 508
509 intel_connector->unregister(intel_connector);
510
509 /* need to nuke the connector */ 511 /* need to nuke the connector */
510 drm_modeset_lock_all(dev); 512 drm_modeset_lock_all(dev);
511 if (connector->state->crtc) { 513 if (connector->state->crtc) {
@@ -519,11 +521,7 @@ static void intel_dp_destroy_mst_connector(struct drm_dp_mst_topology_mgr *mgr,
519 521
520 WARN(ret, "Disabling mst crtc failed with %i\n", ret); 522 WARN(ret, "Disabling mst crtc failed with %i\n", ret);
521 } 523 }
522 drm_modeset_unlock_all(dev);
523 524
524 intel_connector->unregister(intel_connector);
525
526 drm_modeset_lock_all(dev);
527 intel_connector_remove_from_fbdev(intel_connector); 525 intel_connector_remove_from_fbdev(intel_connector);
528 drm_connector_cleanup(connector); 526 drm_connector_cleanup(connector);
529 drm_modeset_unlock_all(dev); 527 drm_modeset_unlock_all(dev);
diff --git a/drivers/gpu/drm/i915/intel_lvds.c b/drivers/gpu/drm/i915/intel_lvds.c
index 30a8403a8f4f..cd9fe609aefb 100644
--- a/drivers/gpu/drm/i915/intel_lvds.c
+++ b/drivers/gpu/drm/i915/intel_lvds.c
@@ -478,11 +478,8 @@ static int intel_lid_notify(struct notifier_block *nb, unsigned long val,
478 * and as part of the cleanup in the hw state restore we also redisable 478 * and as part of the cleanup in the hw state restore we also redisable
479 * the vga plane. 479 * the vga plane.
480 */ 480 */
481 if (!HAS_PCH_SPLIT(dev)) { 481 if (!HAS_PCH_SPLIT(dev))
482 drm_modeset_lock_all(dev);
483 intel_display_resume(dev); 482 intel_display_resume(dev);
484 drm_modeset_unlock_all(dev);
485 }
486 483
487 dev_priv->modeset_restore = MODESET_DONE; 484 dev_priv->modeset_restore = MODESET_DONE;
488 485
diff --git a/drivers/gpu/drm/qxl/qxl_display.c b/drivers/gpu/drm/qxl/qxl_display.c
index 43e5f503d1c5..030409a3ee4e 100644
--- a/drivers/gpu/drm/qxl/qxl_display.c
+++ b/drivers/gpu/drm/qxl/qxl_display.c
@@ -375,10 +375,15 @@ static int qxl_crtc_cursor_set2(struct drm_crtc *crtc,
375 375
376 qxl_bo_kunmap(user_bo); 376 qxl_bo_kunmap(user_bo);
377 377
378 qcrtc->cur_x += qcrtc->hot_spot_x - hot_x;
379 qcrtc->cur_y += qcrtc->hot_spot_y - hot_y;
380 qcrtc->hot_spot_x = hot_x;
381 qcrtc->hot_spot_y = hot_y;
382
378 cmd = (struct qxl_cursor_cmd *)qxl_release_map(qdev, release); 383 cmd = (struct qxl_cursor_cmd *)qxl_release_map(qdev, release);
379 cmd->type = QXL_CURSOR_SET; 384 cmd->type = QXL_CURSOR_SET;
380 cmd->u.set.position.x = qcrtc->cur_x; 385 cmd->u.set.position.x = qcrtc->cur_x + qcrtc->hot_spot_x;
381 cmd->u.set.position.y = qcrtc->cur_y; 386 cmd->u.set.position.y = qcrtc->cur_y + qcrtc->hot_spot_y;
382 387
383 cmd->u.set.shape = qxl_bo_physical_address(qdev, cursor_bo, 0); 388 cmd->u.set.shape = qxl_bo_physical_address(qdev, cursor_bo, 0);
384 389
@@ -441,8 +446,8 @@ static int qxl_crtc_cursor_move(struct drm_crtc *crtc,
441 446
442 cmd = (struct qxl_cursor_cmd *)qxl_release_map(qdev, release); 447 cmd = (struct qxl_cursor_cmd *)qxl_release_map(qdev, release);
443 cmd->type = QXL_CURSOR_MOVE; 448 cmd->type = QXL_CURSOR_MOVE;
444 cmd->u.position.x = qcrtc->cur_x; 449 cmd->u.position.x = qcrtc->cur_x + qcrtc->hot_spot_x;
445 cmd->u.position.y = qcrtc->cur_y; 450 cmd->u.position.y = qcrtc->cur_y + qcrtc->hot_spot_y;
446 qxl_release_unmap(qdev, release, &cmd->release_info); 451 qxl_release_unmap(qdev, release, &cmd->release_info);
447 452
448 qxl_push_cursor_ring_release(qdev, release, QXL_CMD_CURSOR, false); 453 qxl_push_cursor_ring_release(qdev, release, QXL_CMD_CURSOR, false);
diff --git a/drivers/gpu/drm/qxl/qxl_drv.h b/drivers/gpu/drm/qxl/qxl_drv.h
index 6e6b9b1519b8..3f3897eb458c 100644
--- a/drivers/gpu/drm/qxl/qxl_drv.h
+++ b/drivers/gpu/drm/qxl/qxl_drv.h
@@ -135,6 +135,8 @@ struct qxl_crtc {
135 int index; 135 int index;
136 int cur_x; 136 int cur_x;
137 int cur_y; 137 int cur_y;
138 int hot_spot_x;
139 int hot_spot_y;
138}; 140};
139 141
140struct qxl_output { 142struct qxl_output {
diff --git a/drivers/gpu/drm/radeon/ni_reg.h b/drivers/gpu/drm/radeon/ni_reg.h
index da310a70c0f0..827ccc87cbc3 100644
--- a/drivers/gpu/drm/radeon/ni_reg.h
+++ b/drivers/gpu/drm/radeon/ni_reg.h
@@ -109,6 +109,8 @@
109#define NI_DP_MSE_SAT2 0x7398 109#define NI_DP_MSE_SAT2 0x7398
110 110
111#define NI_DP_MSE_SAT_UPDATE 0x739c 111#define NI_DP_MSE_SAT_UPDATE 0x739c
112# define NI_DP_MSE_SAT_UPDATE_MASK 0x3
113# define NI_DP_MSE_16_MTP_KEEPOUT 0x100
112 114
113#define NI_DIG_BE_CNTL 0x7140 115#define NI_DIG_BE_CNTL 0x7140
114# define NI_DIG_FE_SOURCE_SELECT(x) (((x) & 0x7f) << 8) 116# define NI_DIG_FE_SOURCE_SELECT(x) (((x) & 0x7f) << 8)
diff --git a/drivers/gpu/drm/radeon/radeon_dp_mst.c b/drivers/gpu/drm/radeon/radeon_dp_mst.c
index 43cffb526b0c..de504ea29c06 100644
--- a/drivers/gpu/drm/radeon/radeon_dp_mst.c
+++ b/drivers/gpu/drm/radeon/radeon_dp_mst.c
@@ -89,8 +89,16 @@ static int radeon_dp_mst_set_stream_attrib(struct radeon_encoder *primary,
89 WREG32(NI_DP_MSE_SAT_UPDATE + primary->offset, 1); 89 WREG32(NI_DP_MSE_SAT_UPDATE + primary->offset, 1);
90 90
91 do { 91 do {
92 unsigned value1, value2;
93 udelay(10);
92 temp = RREG32(NI_DP_MSE_SAT_UPDATE + primary->offset); 94 temp = RREG32(NI_DP_MSE_SAT_UPDATE + primary->offset);
93 } while ((temp & 0x1) && retries++ < 10000); 95
96 value1 = temp & NI_DP_MSE_SAT_UPDATE_MASK;
97 value2 = temp & NI_DP_MSE_16_MTP_KEEPOUT;
98
99 if (!value1 && !value2)
100 break;
101 } while (retries++ < 50);
94 102
95 if (retries == 10000) 103 if (retries == 10000)
96 DRM_ERROR("timed out waitin for SAT update %d\n", primary->offset); 104 DRM_ERROR("timed out waitin for SAT update %d\n", primary->offset);
@@ -150,7 +158,7 @@ static int radeon_dp_mst_update_stream_attribs(struct radeon_connector *mst_conn
150 return 0; 158 return 0;
151} 159}
152 160
153static int radeon_dp_mst_set_vcp_size(struct radeon_encoder *mst, uint32_t x, uint32_t y) 161static int radeon_dp_mst_set_vcp_size(struct radeon_encoder *mst, s64 avg_time_slots_per_mtp)
154{ 162{
155 struct drm_device *dev = mst->base.dev; 163 struct drm_device *dev = mst->base.dev;
156 struct radeon_device *rdev = dev->dev_private; 164 struct radeon_device *rdev = dev->dev_private;
@@ -158,6 +166,8 @@ static int radeon_dp_mst_set_vcp_size(struct radeon_encoder *mst, uint32_t x, ui
158 uint32_t val, temp; 166 uint32_t val, temp;
159 uint32_t offset = radeon_atom_set_enc_offset(mst_enc->fe); 167 uint32_t offset = radeon_atom_set_enc_offset(mst_enc->fe);
160 int retries = 0; 168 int retries = 0;
169 uint32_t x = drm_fixp2int(avg_time_slots_per_mtp);
170 uint32_t y = drm_fixp2int_ceil((avg_time_slots_per_mtp - x) << 26);
161 171
162 val = NI_DP_MSE_RATE_X(x) | NI_DP_MSE_RATE_Y(y); 172 val = NI_DP_MSE_RATE_X(x) | NI_DP_MSE_RATE_Y(y);
163 173
@@ -165,6 +175,7 @@ static int radeon_dp_mst_set_vcp_size(struct radeon_encoder *mst, uint32_t x, ui
165 175
166 do { 176 do {
167 temp = RREG32(NI_DP_MSE_RATE_UPDATE + offset); 177 temp = RREG32(NI_DP_MSE_RATE_UPDATE + offset);
178 udelay(10);
168 } while ((temp & 0x1) && (retries++ < 10000)); 179 } while ((temp & 0x1) && (retries++ < 10000));
169 180
170 if (retries >= 10000) 181 if (retries >= 10000)
@@ -246,14 +257,8 @@ radeon_dp_mst_connector_destroy(struct drm_connector *connector)
246 kfree(radeon_connector); 257 kfree(radeon_connector);
247} 258}
248 259
249static int radeon_connector_dpms(struct drm_connector *connector, int mode)
250{
251 DRM_DEBUG_KMS("\n");
252 return 0;
253}
254
255static const struct drm_connector_funcs radeon_dp_mst_connector_funcs = { 260static const struct drm_connector_funcs radeon_dp_mst_connector_funcs = {
256 .dpms = radeon_connector_dpms, 261 .dpms = drm_helper_connector_dpms,
257 .detect = radeon_dp_mst_detect, 262 .detect = radeon_dp_mst_detect,
258 .fill_modes = drm_helper_probe_single_connector_modes, 263 .fill_modes = drm_helper_probe_single_connector_modes,
259 .destroy = radeon_dp_mst_connector_destroy, 264 .destroy = radeon_dp_mst_connector_destroy,
@@ -394,7 +399,7 @@ radeon_mst_encoder_dpms(struct drm_encoder *encoder, int mode)
394 struct drm_crtc *crtc; 399 struct drm_crtc *crtc;
395 struct radeon_crtc *radeon_crtc; 400 struct radeon_crtc *radeon_crtc;
396 int ret, slots; 401 int ret, slots;
397 402 s64 fixed_pbn, fixed_pbn_per_slot, avg_time_slots_per_mtp;
398 if (!ASIC_IS_DCE5(rdev)) { 403 if (!ASIC_IS_DCE5(rdev)) {
399 DRM_ERROR("got mst dpms on non-DCE5\n"); 404 DRM_ERROR("got mst dpms on non-DCE5\n");
400 return; 405 return;
@@ -456,7 +461,11 @@ radeon_mst_encoder_dpms(struct drm_encoder *encoder, int mode)
456 461
457 mst_enc->enc_active = true; 462 mst_enc->enc_active = true;
458 radeon_dp_mst_update_stream_attribs(radeon_connector->mst_port, primary); 463 radeon_dp_mst_update_stream_attribs(radeon_connector->mst_port, primary);
459 radeon_dp_mst_set_vcp_size(radeon_encoder, slots, 0); 464
465 fixed_pbn = drm_int2fixp(mst_enc->pbn);
466 fixed_pbn_per_slot = drm_int2fixp(radeon_connector->mst_port->mst_mgr.pbn_div);
467 avg_time_slots_per_mtp = drm_fixp_div(fixed_pbn, fixed_pbn_per_slot);
468 radeon_dp_mst_set_vcp_size(radeon_encoder, avg_time_slots_per_mtp);
460 469
461 atombios_dig_encoder_setup2(&primary->base, ATOM_ENCODER_CMD_DP_VIDEO_ON, 0, 470 atombios_dig_encoder_setup2(&primary->base, ATOM_ENCODER_CMD_DP_VIDEO_ON, 0,
462 mst_enc->fe); 471 mst_enc->fe);
diff --git a/drivers/lguest/interrupts_and_traps.c b/drivers/lguest/interrupts_and_traps.c
index eb934b0242e0..67392b6ab845 100644
--- a/drivers/lguest/interrupts_and_traps.c
+++ b/drivers/lguest/interrupts_and_traps.c
@@ -331,7 +331,7 @@ void set_interrupt(struct lg_cpu *cpu, unsigned int irq)
331 * Actually now I think of it, it's possible that Ron *is* half the Plan 9 331 * Actually now I think of it, it's possible that Ron *is* half the Plan 9
332 * userbase. Oh well. 332 * userbase. Oh well.
333 */ 333 */
334static bool could_be_syscall(unsigned int num) 334bool could_be_syscall(unsigned int num)
335{ 335{
336 /* Normal Linux IA32_SYSCALL_VECTOR or reserved vector? */ 336 /* Normal Linux IA32_SYSCALL_VECTOR or reserved vector? */
337 return num == IA32_SYSCALL_VECTOR || num == syscall_vector; 337 return num == IA32_SYSCALL_VECTOR || num == syscall_vector;
@@ -416,6 +416,10 @@ bool deliver_trap(struct lg_cpu *cpu, unsigned int num)
416 * 416 *
417 * This routine indicates if a particular trap number could be delivered 417 * This routine indicates if a particular trap number could be delivered
418 * directly. 418 * directly.
419 *
420 * Unfortunately, Linux 4.6 started using an interrupt gate instead of a
421 * trap gate for syscalls, so this trick is ineffective. See Mastery for
422 * how we could do this anyway...
419 */ 423 */
420static bool direct_trap(unsigned int num) 424static bool direct_trap(unsigned int num)
421{ 425{
diff --git a/drivers/lguest/lg.h b/drivers/lguest/lg.h
index ac8ad0461e80..69b3814afd2f 100644
--- a/drivers/lguest/lg.h
+++ b/drivers/lguest/lg.h
@@ -167,6 +167,7 @@ void guest_set_clockevent(struct lg_cpu *cpu, unsigned long delta);
167bool send_notify_to_eventfd(struct lg_cpu *cpu); 167bool send_notify_to_eventfd(struct lg_cpu *cpu);
168void init_clockdev(struct lg_cpu *cpu); 168void init_clockdev(struct lg_cpu *cpu);
169bool check_syscall_vector(struct lguest *lg); 169bool check_syscall_vector(struct lguest *lg);
170bool could_be_syscall(unsigned int num);
170int init_interrupts(void); 171int init_interrupts(void);
171void free_interrupts(void); 172void free_interrupts(void);
172 173
diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
index 6a4cd771a2be..adc162c7040d 100644
--- a/drivers/lguest/x86/core.c
+++ b/drivers/lguest/x86/core.c
@@ -429,8 +429,12 @@ void lguest_arch_handle_trap(struct lg_cpu *cpu)
429 return; 429 return;
430 break; 430 break;
431 case 32 ... 255: 431 case 32 ... 255:
432 /* This might be a syscall. */
433 if (could_be_syscall(cpu->regs->trapnum))
434 break;
435
432 /* 436 /*
433 * These values mean a real interrupt occurred, in which case 437 * Other values mean a real interrupt occurred, in which case
434 * the Host handler has already been run. We just do a 438 * the Host handler has already been run. We just do a
435 * friendly check if another process should now be run, then 439 * friendly check if another process should now be run, then
436 * return to run the Guest again. 440 * return to run the Guest again.
diff --git a/drivers/mailbox/mailbox-test.c b/drivers/mailbox/mailbox-test.c
index dc11bbf27274..58d04726cdd7 100644
--- a/drivers/mailbox/mailbox-test.c
+++ b/drivers/mailbox/mailbox-test.c
@@ -46,7 +46,6 @@ static ssize_t mbox_test_signal_write(struct file *filp,
46 size_t count, loff_t *ppos) 46 size_t count, loff_t *ppos)
47{ 47{
48 struct mbox_test_device *tdev = filp->private_data; 48 struct mbox_test_device *tdev = filp->private_data;
49 int ret;
50 49
51 if (!tdev->tx_channel) { 50 if (!tdev->tx_channel) {
52 dev_err(tdev->dev, "Channel cannot do Tx\n"); 51 dev_err(tdev->dev, "Channel cannot do Tx\n");
@@ -60,17 +59,20 @@ static ssize_t mbox_test_signal_write(struct file *filp,
60 return -EINVAL; 59 return -EINVAL;
61 } 60 }
62 61
63 tdev->signal = kzalloc(MBOX_MAX_SIG_LEN, GFP_KERNEL); 62 /* Only allocate memory if we need to */
64 if (!tdev->signal) 63 if (!tdev->signal) {
65 return -ENOMEM; 64 tdev->signal = kzalloc(MBOX_MAX_SIG_LEN, GFP_KERNEL);
65 if (!tdev->signal)
66 return -ENOMEM;
67 }
66 68
67 ret = copy_from_user(tdev->signal, userbuf, count); 69 if (copy_from_user(tdev->signal, userbuf, count)) {
68 if (ret) {
69 kfree(tdev->signal); 70 kfree(tdev->signal);
71 tdev->signal = NULL;
70 return -EFAULT; 72 return -EFAULT;
71 } 73 }
72 74
73 return ret < 0 ? ret : count; 75 return count;
74} 76}
75 77
76static const struct file_operations mbox_test_signal_ops = { 78static const struct file_operations mbox_test_signal_ops = {
diff --git a/drivers/mailbox/mailbox-xgene-slimpro.c b/drivers/mailbox/mailbox-xgene-slimpro.c
index bd07f39f0692..dd2afbca51c9 100644
--- a/drivers/mailbox/mailbox-xgene-slimpro.c
+++ b/drivers/mailbox/mailbox-xgene-slimpro.c
@@ -189,8 +189,8 @@ static int slimpro_mbox_probe(struct platform_device *pdev)
189 int i; 189 int i;
190 190
191 ctx = devm_kzalloc(&pdev->dev, sizeof(struct slimpro_mbox), GFP_KERNEL); 191 ctx = devm_kzalloc(&pdev->dev, sizeof(struct slimpro_mbox), GFP_KERNEL);
192 if (IS_ERR(ctx)) 192 if (!ctx)
193 return PTR_ERR(ctx); 193 return -ENOMEM;
194 194
195 platform_set_drvdata(pdev, ctx); 195 platform_set_drvdata(pdev, ctx);
196 196
diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c
index 6a4811f85705..4a36632c236f 100644
--- a/drivers/mailbox/mailbox.c
+++ b/drivers/mailbox/mailbox.c
@@ -375,13 +375,13 @@ struct mbox_chan *mbox_request_channel_byname(struct mbox_client *cl,
375 375
376 if (!np) { 376 if (!np) {
377 dev_err(cl->dev, "%s() currently only supports DT\n", __func__); 377 dev_err(cl->dev, "%s() currently only supports DT\n", __func__);
378 return ERR_PTR(-ENOSYS); 378 return ERR_PTR(-EINVAL);
379 } 379 }
380 380
381 if (!of_get_property(np, "mbox-names", NULL)) { 381 if (!of_get_property(np, "mbox-names", NULL)) {
382 dev_err(cl->dev, 382 dev_err(cl->dev,
383 "%s() requires an \"mbox-names\" property\n", __func__); 383 "%s() requires an \"mbox-names\" property\n", __func__);
384 return ERR_PTR(-ENOSYS); 384 return ERR_PTR(-EINVAL);
385 } 385 }
386 386
387 of_property_for_each_string(np, "mbox-names", prop, mbox_name) { 387 of_property_for_each_string(np, "mbox-names", prop, mbox_name) {
diff --git a/drivers/md/dm-cache-metadata.c b/drivers/md/dm-cache-metadata.c
index 27f2ef300f8b..3970cda10080 100644
--- a/drivers/md/dm-cache-metadata.c
+++ b/drivers/md/dm-cache-metadata.c
@@ -867,39 +867,55 @@ static int blocks_are_unmapped_or_clean(struct dm_cache_metadata *cmd,
867 return 0; 867 return 0;
868} 868}
869 869
870#define WRITE_LOCK(cmd) \ 870static bool cmd_write_lock(struct dm_cache_metadata *cmd)
871 down_write(&cmd->root_lock); \ 871{
872 if (cmd->fail_io || dm_bm_is_read_only(cmd->bm)) { \ 872 down_write(&cmd->root_lock);
873 up_write(&cmd->root_lock); \ 873 if (cmd->fail_io || dm_bm_is_read_only(cmd->bm)) {
874 return -EINVAL; \ 874 up_write(&cmd->root_lock);
875 return false;
875 } 876 }
877 return true;
878}
876 879
877#define WRITE_LOCK_VOID(cmd) \ 880#define WRITE_LOCK(cmd) \
878 down_write(&cmd->root_lock); \ 881 do { \
879 if (cmd->fail_io || dm_bm_is_read_only(cmd->bm)) { \ 882 if (!cmd_write_lock((cmd))) \
880 up_write(&cmd->root_lock); \ 883 return -EINVAL; \
881 return; \ 884 } while(0)
882 } 885
886#define WRITE_LOCK_VOID(cmd) \
887 do { \
888 if (!cmd_write_lock((cmd))) \
889 return; \
890 } while(0)
883 891
884#define WRITE_UNLOCK(cmd) \ 892#define WRITE_UNLOCK(cmd) \
885 up_write(&cmd->root_lock) 893 up_write(&(cmd)->root_lock)
886 894
887#define READ_LOCK(cmd) \ 895static bool cmd_read_lock(struct dm_cache_metadata *cmd)
888 down_read(&cmd->root_lock); \ 896{
889 if (cmd->fail_io || dm_bm_is_read_only(cmd->bm)) { \ 897 down_read(&cmd->root_lock);
890 up_read(&cmd->root_lock); \ 898 if (cmd->fail_io) {
891 return -EINVAL; \ 899 up_read(&cmd->root_lock);
900 return false;
892 } 901 }
902 return true;
903}
893 904
894#define READ_LOCK_VOID(cmd) \ 905#define READ_LOCK(cmd) \
895 down_read(&cmd->root_lock); \ 906 do { \
896 if (cmd->fail_io || dm_bm_is_read_only(cmd->bm)) { \ 907 if (!cmd_read_lock((cmd))) \
897 up_read(&cmd->root_lock); \ 908 return -EINVAL; \
898 return; \ 909 } while(0)
899 } 910
911#define READ_LOCK_VOID(cmd) \
912 do { \
913 if (!cmd_read_lock((cmd))) \
914 return; \
915 } while(0)
900 916
901#define READ_UNLOCK(cmd) \ 917#define READ_UNLOCK(cmd) \
902 up_read(&cmd->root_lock) 918 up_read(&(cmd)->root_lock)
903 919
904int dm_cache_resize(struct dm_cache_metadata *cmd, dm_cblock_t new_cache_size) 920int dm_cache_resize(struct dm_cache_metadata *cmd, dm_cblock_t new_cache_size)
905{ 921{
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index be4905769a45..3d3ac13287a4 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -1662,8 +1662,10 @@ static int __clone_and_map_data_bio(struct clone_info *ci, struct dm_target *ti,
1662 tio = alloc_tio(ci, ti, target_bio_nr); 1662 tio = alloc_tio(ci, ti, target_bio_nr);
1663 tio->len_ptr = len; 1663 tio->len_ptr = len;
1664 r = clone_bio(tio, bio, sector, *len); 1664 r = clone_bio(tio, bio, sector, *len);
1665 if (r < 0) 1665 if (r < 0) {
1666 free_tio(ci->md, tio);
1666 break; 1667 break;
1668 }
1667 __map_bio(tio); 1669 __map_bio(tio);
1668 } 1670 }
1669 1671
diff --git a/drivers/misc/lkdtm.c b/drivers/misc/lkdtm.c
index 5f1a36b8fbb0..0a5cbbe12452 100644
--- a/drivers/misc/lkdtm.c
+++ b/drivers/misc/lkdtm.c
@@ -458,8 +458,10 @@ static void lkdtm_do_action(enum ctype which)
458 break; 458 break;
459 459
460 val = kmalloc(len, GFP_KERNEL); 460 val = kmalloc(len, GFP_KERNEL);
461 if (!val) 461 if (!val) {
462 kfree(base);
462 break; 463 break;
464 }
463 465
464 *val = 0x12345678; 466 *val = 0x12345678;
465 base[offset] = *val; 467 base[offset] = *val;
@@ -498,14 +500,17 @@ static void lkdtm_do_action(enum ctype which)
498 } 500 }
499 case CT_READ_BUDDY_AFTER_FREE: { 501 case CT_READ_BUDDY_AFTER_FREE: {
500 unsigned long p = __get_free_page(GFP_KERNEL); 502 unsigned long p = __get_free_page(GFP_KERNEL);
501 int saw, *val = kmalloc(1024, GFP_KERNEL); 503 int saw, *val;
502 int *base; 504 int *base;
503 505
504 if (!p) 506 if (!p)
505 break; 507 break;
506 508
507 if (!val) 509 val = kmalloc(1024, GFP_KERNEL);
510 if (!val) {
511 free_page(p);
508 break; 512 break;
513 }
509 514
510 base = (int *)p; 515 base = (int *)p;
511 516
diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index 3bdbe50a363f..8a0147dfed27 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -86,7 +86,6 @@ static int max_devices;
86 86
87/* TODO: Replace these with struct ida */ 87/* TODO: Replace these with struct ida */
88static DECLARE_BITMAP(dev_use, MAX_DEVICES); 88static DECLARE_BITMAP(dev_use, MAX_DEVICES);
89static DECLARE_BITMAP(name_use, MAX_DEVICES);
90 89
91/* 90/*
92 * There is one mmc_blk_data per slot. 91 * There is one mmc_blk_data per slot.
@@ -105,7 +104,6 @@ struct mmc_blk_data {
105 unsigned int usage; 104 unsigned int usage;
106 unsigned int read_only; 105 unsigned int read_only;
107 unsigned int part_type; 106 unsigned int part_type;
108 unsigned int name_idx;
109 unsigned int reset_done; 107 unsigned int reset_done;
110#define MMC_BLK_READ BIT(0) 108#define MMC_BLK_READ BIT(0)
111#define MMC_BLK_WRITE BIT(1) 109#define MMC_BLK_WRITE BIT(1)
@@ -2202,19 +2200,6 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card,
2202 goto out; 2200 goto out;
2203 } 2201 }
2204 2202
2205 /*
2206 * !subname implies we are creating main mmc_blk_data that will be
2207 * associated with mmc_card with dev_set_drvdata. Due to device
2208 * partitions, devidx will not coincide with a per-physical card
2209 * index anymore so we keep track of a name index.
2210 */
2211 if (!subname) {
2212 md->name_idx = find_first_zero_bit(name_use, max_devices);
2213 __set_bit(md->name_idx, name_use);
2214 } else
2215 md->name_idx = ((struct mmc_blk_data *)
2216 dev_to_disk(parent)->private_data)->name_idx;
2217
2218 md->area_type = area_type; 2203 md->area_type = area_type;
2219 2204
2220 /* 2205 /*
@@ -2264,7 +2249,7 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card,
2264 */ 2249 */
2265 2250
2266 snprintf(md->disk->disk_name, sizeof(md->disk->disk_name), 2251 snprintf(md->disk->disk_name, sizeof(md->disk->disk_name),
2267 "mmcblk%u%s", md->name_idx, subname ? subname : ""); 2252 "mmcblk%u%s", card->host->index, subname ? subname : "");
2268 2253
2269 if (mmc_card_mmc(card)) 2254 if (mmc_card_mmc(card))
2270 blk_queue_logical_block_size(md->queue.queue, 2255 blk_queue_logical_block_size(md->queue.queue,
@@ -2418,7 +2403,6 @@ static void mmc_blk_remove_parts(struct mmc_card *card,
2418 struct list_head *pos, *q; 2403 struct list_head *pos, *q;
2419 struct mmc_blk_data *part_md; 2404 struct mmc_blk_data *part_md;
2420 2405
2421 __clear_bit(md->name_idx, name_use);
2422 list_for_each_safe(pos, q, &md->part) { 2406 list_for_each_safe(pos, q, &md->part) {
2423 part_md = list_entry(pos, struct mmc_blk_data, part); 2407 part_md = list_entry(pos, struct mmc_blk_data, part);
2424 list_del(pos); 2408 list_del(pos);
diff --git a/drivers/mmc/host/sdhci-tegra.c b/drivers/mmc/host/sdhci-tegra.c
index f8c4762bb48d..bcc0de47fe7e 100644
--- a/drivers/mmc/host/sdhci-tegra.c
+++ b/drivers/mmc/host/sdhci-tegra.c
@@ -382,14 +382,6 @@ static const struct sdhci_tegra_soc_data soc_data_tegra114 = {
382 .pdata = &sdhci_tegra114_pdata, 382 .pdata = &sdhci_tegra114_pdata,
383}; 383};
384 384
385static const struct sdhci_tegra_soc_data soc_data_tegra124 = {
386 .pdata = &sdhci_tegra114_pdata,
387 .nvquirks = NVQUIRK_ENABLE_SDR50 |
388 NVQUIRK_ENABLE_DDR50 |
389 NVQUIRK_ENABLE_SDR104 |
390 NVQUIRK_HAS_PADCALIB,
391};
392
393static const struct sdhci_pltfm_data sdhci_tegra210_pdata = { 385static const struct sdhci_pltfm_data sdhci_tegra210_pdata = {
394 .quirks = SDHCI_QUIRK_BROKEN_TIMEOUT_VAL | 386 .quirks = SDHCI_QUIRK_BROKEN_TIMEOUT_VAL |
395 SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK | 387 SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK |
@@ -407,7 +399,7 @@ static const struct sdhci_tegra_soc_data soc_data_tegra210 = {
407 399
408static const struct of_device_id sdhci_tegra_dt_match[] = { 400static const struct of_device_id sdhci_tegra_dt_match[] = {
409 { .compatible = "nvidia,tegra210-sdhci", .data = &soc_data_tegra210 }, 401 { .compatible = "nvidia,tegra210-sdhci", .data = &soc_data_tegra210 },
410 { .compatible = "nvidia,tegra124-sdhci", .data = &soc_data_tegra124 }, 402 { .compatible = "nvidia,tegra124-sdhci", .data = &soc_data_tegra114 },
411 { .compatible = "nvidia,tegra114-sdhci", .data = &soc_data_tegra114 }, 403 { .compatible = "nvidia,tegra114-sdhci", .data = &soc_data_tegra114 },
412 { .compatible = "nvidia,tegra30-sdhci", .data = &soc_data_tegra30 }, 404 { .compatible = "nvidia,tegra30-sdhci", .data = &soc_data_tegra30 },
413 { .compatible = "nvidia,tegra20-sdhci", .data = &soc_data_tegra20 }, 405 { .compatible = "nvidia,tegra20-sdhci", .data = &soc_data_tegra20 },
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index b6facac54fc0..557b8462f55e 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -4009,7 +4009,6 @@ static int nand_dt_init(struct nand_chip *chip)
4009 * This is the first phase of the normal nand_scan() function. It reads the 4009 * This is the first phase of the normal nand_scan() function. It reads the
4010 * flash ID and sets up MTD fields accordingly. 4010 * flash ID and sets up MTD fields accordingly.
4011 * 4011 *
4012 * The mtd->owner field must be set to the module of the caller.
4013 */ 4012 */
4014int nand_scan_ident(struct mtd_info *mtd, int maxchips, 4013int nand_scan_ident(struct mtd_info *mtd, int maxchips,
4015 struct nand_flash_dev *table) 4014 struct nand_flash_dev *table)
@@ -4429,19 +4428,12 @@ EXPORT_SYMBOL(nand_scan_tail);
4429 * 4428 *
4430 * This fills out all the uninitialized function pointers with the defaults. 4429 * This fills out all the uninitialized function pointers with the defaults.
4431 * The flash ID is read and the mtd/chip structures are filled with the 4430 * The flash ID is read and the mtd/chip structures are filled with the
4432 * appropriate values. The mtd->owner field must be set to the module of the 4431 * appropriate values.
4433 * caller.
4434 */ 4432 */
4435int nand_scan(struct mtd_info *mtd, int maxchips) 4433int nand_scan(struct mtd_info *mtd, int maxchips)
4436{ 4434{
4437 int ret; 4435 int ret;
4438 4436
4439 /* Many callers got this wrong, so check for it for a while... */
4440 if (!mtd->owner && caller_is_module()) {
4441 pr_crit("%s called with NULL mtd->owner!\n", __func__);
4442 BUG();
4443 }
4444
4445 ret = nand_scan_ident(mtd, maxchips, NULL); 4437 ret = nand_scan_ident(mtd, maxchips, NULL);
4446 if (!ret) 4438 if (!ret)
4447 ret = nand_scan_tail(mtd); 4439 ret = nand_scan_tail(mtd);
diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c
index 8e09c544d892..f798899338ed 100644
--- a/drivers/nvdimm/pmem.c
+++ b/drivers/nvdimm/pmem.c
@@ -103,6 +103,20 @@ static int pmem_do_bvec(struct pmem_device *pmem, struct page *page,
103 flush_dcache_page(page); 103 flush_dcache_page(page);
104 } 104 }
105 } else { 105 } else {
106 /*
107 * Note that we write the data both before and after
108 * clearing poison. The write before clear poison
109 * handles situations where the latest written data is
110 * preserved and the clear poison operation simply marks
111 * the address range as valid without changing the data.
112 * In this case application software can assume that an
113 * interrupted write will either return the new good
114 * data or an error.
115 *
116 * However, if pmem_clear_poison() leaves the data in an
117 * indeterminate state we need to perform the write
118 * after clear poison.
119 */
106 flush_dcache_page(page); 120 flush_dcache_page(page);
107 memcpy_to_pmem(pmem_addr, mem + off, len); 121 memcpy_to_pmem(pmem_addr, mem + off, len);
108 if (unlikely(bad_pmem)) { 122 if (unlikely(bad_pmem)) {
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 24ccda303efb..4fd733ff72b1 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -1478,8 +1478,7 @@ static int nvme_setup_io_queues(struct nvme_dev *dev)
1478 if (result > 0) { 1478 if (result > 0) {
1479 dev_err(dev->ctrl.device, 1479 dev_err(dev->ctrl.device,
1480 "Could not set queue count (%d)\n", result); 1480 "Could not set queue count (%d)\n", result);
1481 nr_io_queues = 0; 1481 return 0;
1482 result = 0;
1483 } 1482 }
1484 1483
1485 if (dev->cmb && NVME_CMB_SQS(dev->cmbsz)) { 1484 if (dev->cmb && NVME_CMB_SQS(dev->cmbsz)) {
@@ -1513,7 +1512,9 @@ static int nvme_setup_io_queues(struct nvme_dev *dev)
1513 * If we enable msix early due to not intx, disable it again before 1512 * If we enable msix early due to not intx, disable it again before
1514 * setting up the full range we need. 1513 * setting up the full range we need.
1515 */ 1514 */
1516 if (!pdev->irq) 1515 if (pdev->msi_enabled)
1516 pci_disable_msi(pdev);
1517 else if (pdev->msix_enabled)
1517 pci_disable_msix(pdev); 1518 pci_disable_msix(pdev);
1518 1519
1519 for (i = 0; i < nr_io_queues; i++) 1520 for (i = 0; i < nr_io_queues; i++)
@@ -1696,7 +1697,6 @@ static int nvme_pci_enable(struct nvme_dev *dev)
1696 if (pci_enable_device_mem(pdev)) 1697 if (pci_enable_device_mem(pdev))
1697 return result; 1698 return result;
1698 1699
1699 dev->entry[0].vector = pdev->irq;
1700 pci_set_master(pdev); 1700 pci_set_master(pdev);
1701 1701
1702 if (dma_set_mask_and_coherent(dev->dev, DMA_BIT_MASK(64)) && 1702 if (dma_set_mask_and_coherent(dev->dev, DMA_BIT_MASK(64)) &&
@@ -1709,13 +1709,18 @@ static int nvme_pci_enable(struct nvme_dev *dev)
1709 } 1709 }
1710 1710
1711 /* 1711 /*
1712 * Some devices don't advertse INTx interrupts, pre-enable a single 1712 * Some devices and/or platforms don't advertise or work with INTx
1713 * MSIX vec for setup. We'll adjust this later. 1713 * interrupts. Pre-enable a single MSIX or MSI vec for setup. We'll
1714 * adjust this later.
1714 */ 1715 */
1715 if (!pdev->irq) { 1716 if (pci_enable_msix(pdev, dev->entry, 1)) {
1716 result = pci_enable_msix(pdev, dev->entry, 1); 1717 pci_enable_msi(pdev);
1717 if (result < 0) 1718 dev->entry[0].vector = pdev->irq;
1718 goto disable; 1719 }
1720
1721 if (!dev->entry[0].vector) {
1722 result = -ENODEV;
1723 goto disable;
1719 } 1724 }
1720 1725
1721 cap = lo_hi_readq(dev->bar + NVME_REG_CAP); 1726 cap = lo_hi_readq(dev->bar + NVME_REG_CAP);
@@ -1859,6 +1864,9 @@ static void nvme_reset_work(struct work_struct *work)
1859 if (dev->ctrl.ctrl_config & NVME_CC_ENABLE) 1864 if (dev->ctrl.ctrl_config & NVME_CC_ENABLE)
1860 nvme_dev_disable(dev, false); 1865 nvme_dev_disable(dev, false);
1861 1866
1867 if (test_bit(NVME_CTRL_REMOVING, &dev->flags))
1868 goto out;
1869
1862 set_bit(NVME_CTRL_RESETTING, &dev->flags); 1870 set_bit(NVME_CTRL_RESETTING, &dev->flags);
1863 1871
1864 result = nvme_pci_enable(dev); 1872 result = nvme_pci_enable(dev);
@@ -2078,11 +2086,10 @@ static void nvme_remove(struct pci_dev *pdev)
2078{ 2086{
2079 struct nvme_dev *dev = pci_get_drvdata(pdev); 2087 struct nvme_dev *dev = pci_get_drvdata(pdev);
2080 2088
2081 del_timer_sync(&dev->watchdog_timer);
2082
2083 set_bit(NVME_CTRL_REMOVING, &dev->flags); 2089 set_bit(NVME_CTRL_REMOVING, &dev->flags);
2084 pci_set_drvdata(pdev, NULL); 2090 pci_set_drvdata(pdev, NULL);
2085 flush_work(&dev->async_work); 2091 flush_work(&dev->async_work);
2092 flush_work(&dev->reset_work);
2086 flush_work(&dev->scan_work); 2093 flush_work(&dev->scan_work);
2087 nvme_remove_namespaces(&dev->ctrl); 2094 nvme_remove_namespaces(&dev->ctrl);
2088 nvme_uninit_ctrl(&dev->ctrl); 2095 nvme_uninit_ctrl(&dev->ctrl);
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index e982010f0ed1..342b6918bbde 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -636,7 +636,7 @@ static ssize_t pci_read_config(struct file *filp, struct kobject *kobj,
636 u8 *data = (u8 *) buf; 636 u8 *data = (u8 *) buf;
637 637
638 /* Several chips lock up trying to read undefined config space */ 638 /* Several chips lock up trying to read undefined config space */
639 if (security_capable(filp->f_cred, &init_user_ns, CAP_SYS_ADMIN) == 0) 639 if (file_ns_capable(filp, &init_user_ns, CAP_SYS_ADMIN))
640 size = dev->cfg_size; 640 size = dev->cfg_size;
641 else if (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS) 641 else if (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS)
642 size = 128; 642 size = 128;
diff --git a/drivers/pwm/pwm-fsl-ftm.c b/drivers/pwm/pwm-fsl-ftm.c
index 7225ac6b3df5..fad968eb75f6 100644
--- a/drivers/pwm/pwm-fsl-ftm.c
+++ b/drivers/pwm/pwm-fsl-ftm.c
@@ -392,7 +392,7 @@ static const struct regmap_config fsl_pwm_regmap_config = {
392 392
393 .max_register = FTM_PWMLOAD, 393 .max_register = FTM_PWMLOAD,
394 .volatile_reg = fsl_pwm_volatile_reg, 394 .volatile_reg = fsl_pwm_volatile_reg,
395 .cache_type = REGCACHE_RBTREE, 395 .cache_type = REGCACHE_FLAT,
396}; 396};
397 397
398static int fsl_pwm_probe(struct platform_device *pdev) 398static int fsl_pwm_probe(struct platform_device *pdev)
diff --git a/drivers/scsi/device_handler/scsi_dh_alua.c b/drivers/scsi/device_handler/scsi_dh_alua.c
index b2244eb90776..752b5c9d1ab2 100644
--- a/drivers/scsi/device_handler/scsi_dh_alua.c
+++ b/drivers/scsi/device_handler/scsi_dh_alua.c
@@ -541,6 +541,7 @@ static int alua_rtpg(struct scsi_device *sdev, struct alua_port_group *pg)
541 return SCSI_DH_DEV_TEMP_BUSY; 541 return SCSI_DH_DEV_TEMP_BUSY;
542 542
543 retry: 543 retry:
544 err = 0;
544 retval = submit_rtpg(sdev, buff, bufflen, &sense_hdr, pg->flags); 545 retval = submit_rtpg(sdev, buff, bufflen, &sense_hdr, pg->flags);
545 546
546 if (retval) { 547 if (retval) {
diff --git a/drivers/scsi/lpfc/lpfc_mem.c b/drivers/scsi/lpfc/lpfc_mem.c
index 4fb3581d4614..3fa65338d3f5 100644
--- a/drivers/scsi/lpfc/lpfc_mem.c
+++ b/drivers/scsi/lpfc/lpfc_mem.c
@@ -231,13 +231,15 @@ lpfc_mem_free(struct lpfc_hba *phba)
231 if (phba->lpfc_hbq_pool) 231 if (phba->lpfc_hbq_pool)
232 pci_pool_destroy(phba->lpfc_hbq_pool); 232 pci_pool_destroy(phba->lpfc_hbq_pool);
233 phba->lpfc_hbq_pool = NULL; 233 phba->lpfc_hbq_pool = NULL;
234 mempool_destroy(phba->rrq_pool); 234
235 if (phba->rrq_pool)
236 mempool_destroy(phba->rrq_pool);
235 phba->rrq_pool = NULL; 237 phba->rrq_pool = NULL;
236 238
237 /* Free NLP memory pool */ 239 /* Free NLP memory pool */
238 mempool_destroy(phba->nlp_mem_pool); 240 mempool_destroy(phba->nlp_mem_pool);
239 phba->nlp_mem_pool = NULL; 241 phba->nlp_mem_pool = NULL;
240 if (phba->sli_rev == LPFC_SLI_REV4) { 242 if (phba->sli_rev == LPFC_SLI_REV4 && phba->active_rrq_pool) {
241 mempool_destroy(phba->active_rrq_pool); 243 mempool_destroy(phba->active_rrq_pool);
242 phba->active_rrq_pool = NULL; 244 phba->active_rrq_pool = NULL;
243 } 245 }
diff --git a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c
index 5d0ec42a9317..634254a52301 100644
--- a/drivers/scsi/qla1280.c
+++ b/drivers/scsi/qla1280.c
@@ -4214,7 +4214,7 @@ static struct scsi_host_template qla1280_driver_template = {
4214 .eh_bus_reset_handler = qla1280_eh_bus_reset, 4214 .eh_bus_reset_handler = qla1280_eh_bus_reset,
4215 .eh_host_reset_handler = qla1280_eh_adapter_reset, 4215 .eh_host_reset_handler = qla1280_eh_adapter_reset,
4216 .bios_param = qla1280_biosparam, 4216 .bios_param = qla1280_biosparam,
4217 .can_queue = 0xfffff, 4217 .can_queue = MAX_OUTSTANDING_COMMANDS,
4218 .this_id = -1, 4218 .this_id = -1,
4219 .sg_tablesize = SG_ALL, 4219 .sg_tablesize = SG_ALL,
4220 .use_clustering = ENABLE_CLUSTERING, 4220 .use_clustering = ENABLE_CLUSTERING,
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 83fd30b0577c..a6c4a1b895bd 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -744,11 +744,15 @@ static void acm_tty_flush_chars(struct tty_struct *tty)
744 int err; 744 int err;
745 unsigned long flags; 745 unsigned long flags;
746 746
747 if (!cur) /* nothing to do */
748 return;
749
747 acm->putbuffer = NULL; 750 acm->putbuffer = NULL;
748 err = usb_autopm_get_interface_async(acm->control); 751 err = usb_autopm_get_interface_async(acm->control);
749 spin_lock_irqsave(&acm->write_lock, flags); 752 spin_lock_irqsave(&acm->write_lock, flags);
750 if (err < 0) { 753 if (err < 0) {
751 cur->use = 0; 754 cur->use = 0;
755 acm->putbuffer = cur;
752 goto out; 756 goto out;
753 } 757 }
754 758
diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c
index f9d42cf23e55..7859d738df41 100644
--- a/drivers/usb/core/hcd-pci.c
+++ b/drivers/usb/core/hcd-pci.c
@@ -73,6 +73,15 @@ static void for_each_companion(struct pci_dev *pdev, struct usb_hcd *hcd,
73 if (companion->bus != pdev->bus || 73 if (companion->bus != pdev->bus ||
74 PCI_SLOT(companion->devfn) != slot) 74 PCI_SLOT(companion->devfn) != slot)
75 continue; 75 continue;
76
77 /*
78 * Companion device should be either UHCI,OHCI or EHCI host
79 * controller, otherwise skip.
80 */
81 if (companion->class != CL_UHCI && companion->class != CL_OHCI &&
82 companion->class != CL_EHCI)
83 continue;
84
76 companion_hcd = pci_get_drvdata(companion); 85 companion_hcd = pci_get_drvdata(companion);
77 if (!companion_hcd || !companion_hcd->self.root_hub) 86 if (!companion_hcd || !companion_hcd->self.root_hub)
78 continue; 87 continue;
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 80c1de239e9a..bad0d1f9a41d 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -1861,6 +1861,12 @@ no_bw:
1861 kfree(xhci->rh_bw); 1861 kfree(xhci->rh_bw);
1862 kfree(xhci->ext_caps); 1862 kfree(xhci->ext_caps);
1863 1863
1864 xhci->usb2_ports = NULL;
1865 xhci->usb3_ports = NULL;
1866 xhci->port_array = NULL;
1867 xhci->rh_bw = NULL;
1868 xhci->ext_caps = NULL;
1869
1864 xhci->page_size = 0; 1870 xhci->page_size = 0;
1865 xhci->page_shift = 0; 1871 xhci->page_shift = 0;
1866 xhci->bus_state[0].bus_suspended = 0; 1872 xhci->bus_state[0].bus_suspended = 0;
diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
index f0640b7a1c42..48672fac7ff3 100644
--- a/drivers/usb/host/xhci-pci.c
+++ b/drivers/usb/host/xhci-pci.c
@@ -48,6 +48,7 @@
48#define PCI_DEVICE_ID_INTEL_SUNRISEPOINT_H_XHCI 0xa12f 48#define PCI_DEVICE_ID_INTEL_SUNRISEPOINT_H_XHCI 0xa12f
49#define PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_XHCI 0x9d2f 49#define PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_XHCI 0x9d2f
50#define PCI_DEVICE_ID_INTEL_BROXTON_M_XHCI 0x0aa8 50#define PCI_DEVICE_ID_INTEL_BROXTON_M_XHCI 0x0aa8
51#define PCI_DEVICE_ID_INTEL_BROXTON_B_XHCI 0x1aa8
51 52
52static const char hcd_name[] = "xhci_hcd"; 53static const char hcd_name[] = "xhci_hcd";
53 54
@@ -155,7 +156,8 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
155 (pdev->device == PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_XHCI || 156 (pdev->device == PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_XHCI ||
156 pdev->device == PCI_DEVICE_ID_INTEL_SUNRISEPOINT_H_XHCI || 157 pdev->device == PCI_DEVICE_ID_INTEL_SUNRISEPOINT_H_XHCI ||
157 pdev->device == PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI || 158 pdev->device == PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI ||
158 pdev->device == PCI_DEVICE_ID_INTEL_BROXTON_M_XHCI)) { 159 pdev->device == PCI_DEVICE_ID_INTEL_BROXTON_M_XHCI ||
160 pdev->device == PCI_DEVICE_ID_INTEL_BROXTON_B_XHCI)) {
159 xhci->quirks |= XHCI_PME_STUCK_QUIRK; 161 xhci->quirks |= XHCI_PME_STUCK_QUIRK;
160 } 162 }
161 if (pdev->vendor == PCI_VENDOR_ID_INTEL && 163 if (pdev->vendor == PCI_VENDOR_ID_INTEL &&
@@ -302,6 +304,7 @@ static void xhci_pci_remove(struct pci_dev *dev)
302 struct xhci_hcd *xhci; 304 struct xhci_hcd *xhci;
303 305
304 xhci = hcd_to_xhci(pci_get_drvdata(dev)); 306 xhci = hcd_to_xhci(pci_get_drvdata(dev));
307 xhci->xhc_state |= XHCI_STATE_REMOVING;
305 if (xhci->shared_hcd) { 308 if (xhci->shared_hcd) {
306 usb_remove_hcd(xhci->shared_hcd); 309 usb_remove_hcd(xhci->shared_hcd);
307 usb_put_hcd(xhci->shared_hcd); 310 usb_put_hcd(xhci->shared_hcd);
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 5c15e9bc5f7a..474b5fa14900 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -39,12 +39,25 @@ static const struct xhci_driver_overrides xhci_plat_overrides __initconst = {
39 39
40static void xhci_plat_quirks(struct device *dev, struct xhci_hcd *xhci) 40static void xhci_plat_quirks(struct device *dev, struct xhci_hcd *xhci)
41{ 41{
42 struct usb_hcd *hcd = xhci_to_hcd(xhci);
43
42 /* 44 /*
43 * As of now platform drivers don't provide MSI support so we ensure 45 * As of now platform drivers don't provide MSI support so we ensure
44 * here that the generic code does not try to make a pci_dev from our 46 * here that the generic code does not try to make a pci_dev from our
45 * dev struct in order to setup MSI 47 * dev struct in order to setup MSI
46 */ 48 */
47 xhci->quirks |= XHCI_PLAT; 49 xhci->quirks |= XHCI_PLAT;
50
51 /*
52 * On R-Car Gen2 and Gen3, the AC64 bit (bit 0) of HCCPARAMS1 is set
53 * to 1. However, these SoCs don't support 64-bit address memory
54 * pointers. So, this driver clears the AC64 bit of xhci->hcc_params
55 * to call dma_set_coherent_mask(dev, DMA_BIT_MASK(32)) in
56 * xhci_gen_setup().
57 */
58 if (xhci_plat_type_is(hcd, XHCI_PLAT_TYPE_RENESAS_RCAR_GEN2) ||
59 xhci_plat_type_is(hcd, XHCI_PLAT_TYPE_RENESAS_RCAR_GEN3))
60 xhci->quirks |= XHCI_NO_64BIT_SUPPORT;
48} 61}
49 62
50/* called during probe() after chip reset completes */ 63/* called during probe() after chip reset completes */
diff --git a/drivers/usb/host/xhci-plat.h b/drivers/usb/host/xhci-plat.h
index 5a2e2e3936c4..529c3c40f901 100644
--- a/drivers/usb/host/xhci-plat.h
+++ b/drivers/usb/host/xhci-plat.h
@@ -14,7 +14,7 @@
14#include "xhci.h" /* for hcd_to_xhci() */ 14#include "xhci.h" /* for hcd_to_xhci() */
15 15
16enum xhci_plat_type { 16enum xhci_plat_type {
17 XHCI_PLAT_TYPE_MARVELL_ARMADA, 17 XHCI_PLAT_TYPE_MARVELL_ARMADA = 1,
18 XHCI_PLAT_TYPE_RENESAS_RCAR_GEN2, 18 XHCI_PLAT_TYPE_RENESAS_RCAR_GEN2,
19 XHCI_PLAT_TYPE_RENESAS_RCAR_GEN3, 19 XHCI_PLAT_TYPE_RENESAS_RCAR_GEN3,
20}; 20};
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 7cf66212ceae..99b4ff42f7a0 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -4004,7 +4004,8 @@ static int queue_command(struct xhci_hcd *xhci, struct xhci_command *cmd,
4004 int reserved_trbs = xhci->cmd_ring_reserved_trbs; 4004 int reserved_trbs = xhci->cmd_ring_reserved_trbs;
4005 int ret; 4005 int ret;
4006 4006
4007 if (xhci->xhc_state) { 4007 if ((xhci->xhc_state & XHCI_STATE_DYING) ||
4008 (xhci->xhc_state & XHCI_STATE_HALTED)) {
4008 xhci_dbg(xhci, "xHCI dying or halted, can't queue_command\n"); 4009 xhci_dbg(xhci, "xHCI dying or halted, can't queue_command\n");
4009 return -ESHUTDOWN; 4010 return -ESHUTDOWN;
4010 } 4011 }
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index d51ee0c3cf9f..9e71c96ad74a 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -147,7 +147,8 @@ static int xhci_start(struct xhci_hcd *xhci)
147 "waited %u microseconds.\n", 147 "waited %u microseconds.\n",
148 XHCI_MAX_HALT_USEC); 148 XHCI_MAX_HALT_USEC);
149 if (!ret) 149 if (!ret)
150 xhci->xhc_state &= ~(XHCI_STATE_HALTED | XHCI_STATE_DYING); 150 /* clear state flags. Including dying, halted or removing */
151 xhci->xhc_state = 0;
151 152
152 return ret; 153 return ret;
153} 154}
@@ -1108,8 +1109,8 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
1108 /* Resume root hubs only when have pending events. */ 1109 /* Resume root hubs only when have pending events. */
1109 status = readl(&xhci->op_regs->status); 1110 status = readl(&xhci->op_regs->status);
1110 if (status & STS_EINT) { 1111 if (status & STS_EINT) {
1111 usb_hcd_resume_root_hub(hcd);
1112 usb_hcd_resume_root_hub(xhci->shared_hcd); 1112 usb_hcd_resume_root_hub(xhci->shared_hcd);
1113 usb_hcd_resume_root_hub(hcd);
1113 } 1114 }
1114 } 1115 }
1115 1116
@@ -1124,10 +1125,10 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
1124 1125
1125 /* Re-enable port polling. */ 1126 /* Re-enable port polling. */
1126 xhci_dbg(xhci, "%s: starting port polling.\n", __func__); 1127 xhci_dbg(xhci, "%s: starting port polling.\n", __func__);
1127 set_bit(HCD_FLAG_POLL_RH, &hcd->flags);
1128 usb_hcd_poll_rh_status(hcd);
1129 set_bit(HCD_FLAG_POLL_RH, &xhci->shared_hcd->flags); 1128 set_bit(HCD_FLAG_POLL_RH, &xhci->shared_hcd->flags);
1130 usb_hcd_poll_rh_status(xhci->shared_hcd); 1129 usb_hcd_poll_rh_status(xhci->shared_hcd);
1130 set_bit(HCD_FLAG_POLL_RH, &hcd->flags);
1131 usb_hcd_poll_rh_status(hcd);
1131 1132
1132 return retval; 1133 return retval;
1133} 1134}
@@ -2773,7 +2774,8 @@ int xhci_check_bandwidth(struct usb_hcd *hcd, struct usb_device *udev)
2773 if (ret <= 0) 2774 if (ret <= 0)
2774 return ret; 2775 return ret;
2775 xhci = hcd_to_xhci(hcd); 2776 xhci = hcd_to_xhci(hcd);
2776 if (xhci->xhc_state & XHCI_STATE_DYING) 2777 if ((xhci->xhc_state & XHCI_STATE_DYING) ||
2778 (xhci->xhc_state & XHCI_STATE_REMOVING))
2777 return -ENODEV; 2779 return -ENODEV;
2778 2780
2779 xhci_dbg(xhci, "%s called for udev %p\n", __func__, udev); 2781 xhci_dbg(xhci, "%s called for udev %p\n", __func__, udev);
@@ -3820,7 +3822,7 @@ static int xhci_setup_device(struct usb_hcd *hcd, struct usb_device *udev,
3820 3822
3821 mutex_lock(&xhci->mutex); 3823 mutex_lock(&xhci->mutex);
3822 3824
3823 if (xhci->xhc_state) /* dying or halted */ 3825 if (xhci->xhc_state) /* dying, removing or halted */
3824 goto out; 3826 goto out;
3825 3827
3826 if (!udev->slot_id) { 3828 if (!udev->slot_id) {
@@ -4948,6 +4950,16 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks)
4948 return retval; 4950 return retval;
4949 xhci_dbg(xhci, "Reset complete\n"); 4951 xhci_dbg(xhci, "Reset complete\n");
4950 4952
4953 /*
4954 * On some xHCI controllers (e.g. R-Car SoCs), the AC64 bit (bit 0)
4955 * of HCCPARAMS1 is set to 1. However, the xHCs don't support 64-bit
4956 * address memory pointers actually. So, this driver clears the AC64
4957 * bit of xhci->hcc_params to call dma_set_coherent_mask(dev,
4958 * DMA_BIT_MASK(32)) in this xhci_gen_setup().
4959 */
4960 if (xhci->quirks & XHCI_NO_64BIT_SUPPORT)
4961 xhci->hcc_params &= ~BIT(0);
4962
4951 /* Set dma_mask and coherent_dma_mask to 64-bits, 4963 /* Set dma_mask and coherent_dma_mask to 64-bits,
4952 * if xHC supports 64-bit addressing */ 4964 * if xHC supports 64-bit addressing */
4953 if (HCC_64BIT_ADDR(xhci->hcc_params) && 4965 if (HCC_64BIT_ADDR(xhci->hcc_params) &&
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index e293e0974f48..6c629c97f8ad 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1605,6 +1605,7 @@ struct xhci_hcd {
1605 */ 1605 */
1606#define XHCI_STATE_DYING (1 << 0) 1606#define XHCI_STATE_DYING (1 << 0)
1607#define XHCI_STATE_HALTED (1 << 1) 1607#define XHCI_STATE_HALTED (1 << 1)
1608#define XHCI_STATE_REMOVING (1 << 2)
1608 /* Statistics */ 1609 /* Statistics */
1609 int error_bitmask; 1610 int error_bitmask;
1610 unsigned int quirks; 1611 unsigned int quirks;
@@ -1641,6 +1642,7 @@ struct xhci_hcd {
1641#define XHCI_PME_STUCK_QUIRK (1 << 20) 1642#define XHCI_PME_STUCK_QUIRK (1 << 20)
1642#define XHCI_MTK_HOST (1 << 21) 1643#define XHCI_MTK_HOST (1 << 21)
1643#define XHCI_SSIC_PORT_UNUSED (1 << 22) 1644#define XHCI_SSIC_PORT_UNUSED (1 << 22)
1645#define XHCI_NO_64BIT_SUPPORT (1 << 23)
1644 unsigned int num_active_eps; 1646 unsigned int num_active_eps;
1645 unsigned int limit_active_eps; 1647 unsigned int limit_active_eps;
1646 /* There are two roothubs to keep track of bus suspend info for */ 1648 /* There are two roothubs to keep track of bus suspend info for */
diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c
index 13e4cc31bc79..16bc679dc2fc 100644
--- a/drivers/usb/storage/uas.c
+++ b/drivers/usb/storage/uas.c
@@ -2,7 +2,7 @@
2 * USB Attached SCSI 2 * USB Attached SCSI
3 * Note that this is not the same as the USB Mass Storage driver 3 * Note that this is not the same as the USB Mass Storage driver
4 * 4 *
5 * Copyright Hans de Goede <hdegoede@redhat.com> for Red Hat, Inc. 2013 - 2014 5 * Copyright Hans de Goede <hdegoede@redhat.com> for Red Hat, Inc. 2013 - 2016
6 * Copyright Matthew Wilcox for Intel Corp, 2010 6 * Copyright Matthew Wilcox for Intel Corp, 2010
7 * Copyright Sarah Sharp for Intel Corp, 2010 7 * Copyright Sarah Sharp for Intel Corp, 2010
8 * 8 *
@@ -781,6 +781,17 @@ static int uas_eh_bus_reset_handler(struct scsi_cmnd *cmnd)
781 return SUCCESS; 781 return SUCCESS;
782} 782}
783 783
784static int uas_target_alloc(struct scsi_target *starget)
785{
786 struct uas_dev_info *devinfo = (struct uas_dev_info *)
787 dev_to_shost(starget->dev.parent)->hostdata;
788
789 if (devinfo->flags & US_FL_NO_REPORT_LUNS)
790 starget->no_report_luns = 1;
791
792 return 0;
793}
794
784static int uas_slave_alloc(struct scsi_device *sdev) 795static int uas_slave_alloc(struct scsi_device *sdev)
785{ 796{
786 struct uas_dev_info *devinfo = 797 struct uas_dev_info *devinfo =
@@ -824,7 +835,6 @@ static int uas_slave_configure(struct scsi_device *sdev)
824 if (devinfo->flags & US_FL_BROKEN_FUA) 835 if (devinfo->flags & US_FL_BROKEN_FUA)
825 sdev->broken_fua = 1; 836 sdev->broken_fua = 1;
826 837
827 scsi_change_queue_depth(sdev, devinfo->qdepth - 2);
828 return 0; 838 return 0;
829} 839}
830 840
@@ -832,6 +842,7 @@ static struct scsi_host_template uas_host_template = {
832 .module = THIS_MODULE, 842 .module = THIS_MODULE,
833 .name = "uas", 843 .name = "uas",
834 .queuecommand = uas_queuecommand, 844 .queuecommand = uas_queuecommand,
845 .target_alloc = uas_target_alloc,
835 .slave_alloc = uas_slave_alloc, 846 .slave_alloc = uas_slave_alloc,
836 .slave_configure = uas_slave_configure, 847 .slave_configure = uas_slave_configure,
837 .eh_abort_handler = uas_eh_abort_handler, 848 .eh_abort_handler = uas_eh_abort_handler,
@@ -956,6 +967,12 @@ static int uas_probe(struct usb_interface *intf, const struct usb_device_id *id)
956 if (result) 967 if (result)
957 goto set_alt0; 968 goto set_alt0;
958 969
970 /*
971 * 1 tag is reserved for untagged commands +
972 * 1 tag to avoid off by one errors in some bridge firmwares
973 */
974 shost->can_queue = devinfo->qdepth - 2;
975
959 usb_set_intfdata(intf, shost); 976 usb_set_intfdata(intf, shost);
960 result = scsi_add_host(shost, &intf->dev); 977 result = scsi_add_host(shost, &intf->dev);
961 if (result) 978 if (result)
diff --git a/drivers/usb/storage/unusual_uas.h b/drivers/usb/storage/unusual_uas.h
index ccc113e83d88..53341a77d89f 100644
--- a/drivers/usb/storage/unusual_uas.h
+++ b/drivers/usb/storage/unusual_uas.h
@@ -64,6 +64,13 @@ UNUSUAL_DEV(0x0bc2, 0x3312, 0x0000, 0x9999,
64 USB_SC_DEVICE, USB_PR_DEVICE, NULL, 64 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
65 US_FL_NO_ATA_1X), 65 US_FL_NO_ATA_1X),
66 66
67/* Reported-by: David Webb <djw@noc.ac.uk> */
68UNUSUAL_DEV(0x0bc2, 0x331a, 0x0000, 0x9999,
69 "Seagate",
70 "Expansion Desk",
71 USB_SC_DEVICE, USB_PR_DEVICE, NULL,
72 US_FL_NO_REPORT_LUNS),
73
67/* Reported-by: Hans de Goede <hdegoede@redhat.com> */ 74/* Reported-by: Hans de Goede <hdegoede@redhat.com> */
68UNUSUAL_DEV(0x0bc2, 0x3320, 0x0000, 0x9999, 75UNUSUAL_DEV(0x0bc2, 0x3320, 0x0000, 0x9999,
69 "Seagate", 76 "Seagate",
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index 43576ed31ccd..9de988a0f856 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -482,7 +482,7 @@ void usb_stor_adjust_quirks(struct usb_device *udev, unsigned long *fflags)
482 US_FL_NO_READ_DISC_INFO | US_FL_NO_READ_CAPACITY_16 | 482 US_FL_NO_READ_DISC_INFO | US_FL_NO_READ_CAPACITY_16 |
483 US_FL_INITIAL_READ10 | US_FL_WRITE_CACHE | 483 US_FL_INITIAL_READ10 | US_FL_WRITE_CACHE |
484 US_FL_NO_ATA_1X | US_FL_NO_REPORT_OPCODES | 484 US_FL_NO_ATA_1X | US_FL_NO_REPORT_OPCODES |
485 US_FL_MAX_SECTORS_240); 485 US_FL_MAX_SECTORS_240 | US_FL_NO_REPORT_LUNS);
486 486
487 p = quirks; 487 p = quirks;
488 while (*p) { 488 while (*p) {
@@ -532,6 +532,9 @@ void usb_stor_adjust_quirks(struct usb_device *udev, unsigned long *fflags)
532 case 'i': 532 case 'i':
533 f |= US_FL_IGNORE_DEVICE; 533 f |= US_FL_IGNORE_DEVICE;
534 break; 534 break;
535 case 'j':
536 f |= US_FL_NO_REPORT_LUNS;
537 break;
535 case 'l': 538 case 'l':
536 f |= US_FL_NOT_LOCKABLE; 539 f |= US_FL_NOT_LOCKABLE;
537 break; 540 break;
diff --git a/fs/crypto/crypto.c b/fs/crypto/crypto.c
index 7f5804537d30..2fc8c43ce531 100644
--- a/fs/crypto/crypto.c
+++ b/fs/crypto/crypto.c
@@ -26,6 +26,7 @@
26#include <linux/ratelimit.h> 26#include <linux/ratelimit.h>
27#include <linux/bio.h> 27#include <linux/bio.h>
28#include <linux/dcache.h> 28#include <linux/dcache.h>
29#include <linux/namei.h>
29#include <linux/fscrypto.h> 30#include <linux/fscrypto.h>
30#include <linux/ecryptfs.h> 31#include <linux/ecryptfs.h>
31 32
@@ -81,13 +82,14 @@ EXPORT_SYMBOL(fscrypt_release_ctx);
81/** 82/**
82 * fscrypt_get_ctx() - Gets an encryption context 83 * fscrypt_get_ctx() - Gets an encryption context
83 * @inode: The inode for which we are doing the crypto 84 * @inode: The inode for which we are doing the crypto
85 * @gfp_flags: The gfp flag for memory allocation
84 * 86 *
85 * Allocates and initializes an encryption context. 87 * Allocates and initializes an encryption context.
86 * 88 *
87 * Return: An allocated and initialized encryption context on success; error 89 * Return: An allocated and initialized encryption context on success; error
88 * value or NULL otherwise. 90 * value or NULL otherwise.
89 */ 91 */
90struct fscrypt_ctx *fscrypt_get_ctx(struct inode *inode) 92struct fscrypt_ctx *fscrypt_get_ctx(struct inode *inode, gfp_t gfp_flags)
91{ 93{
92 struct fscrypt_ctx *ctx = NULL; 94 struct fscrypt_ctx *ctx = NULL;
93 struct fscrypt_info *ci = inode->i_crypt_info; 95 struct fscrypt_info *ci = inode->i_crypt_info;
@@ -113,7 +115,7 @@ struct fscrypt_ctx *fscrypt_get_ctx(struct inode *inode)
113 list_del(&ctx->free_list); 115 list_del(&ctx->free_list);
114 spin_unlock_irqrestore(&fscrypt_ctx_lock, flags); 116 spin_unlock_irqrestore(&fscrypt_ctx_lock, flags);
115 if (!ctx) { 117 if (!ctx) {
116 ctx = kmem_cache_zalloc(fscrypt_ctx_cachep, GFP_NOFS); 118 ctx = kmem_cache_zalloc(fscrypt_ctx_cachep, gfp_flags);
117 if (!ctx) 119 if (!ctx)
118 return ERR_PTR(-ENOMEM); 120 return ERR_PTR(-ENOMEM);
119 ctx->flags |= FS_CTX_REQUIRES_FREE_ENCRYPT_FL; 121 ctx->flags |= FS_CTX_REQUIRES_FREE_ENCRYPT_FL;
@@ -147,7 +149,8 @@ typedef enum {
147 149
148static int do_page_crypto(struct inode *inode, 150static int do_page_crypto(struct inode *inode,
149 fscrypt_direction_t rw, pgoff_t index, 151 fscrypt_direction_t rw, pgoff_t index,
150 struct page *src_page, struct page *dest_page) 152 struct page *src_page, struct page *dest_page,
153 gfp_t gfp_flags)
151{ 154{
152 u8 xts_tweak[FS_XTS_TWEAK_SIZE]; 155 u8 xts_tweak[FS_XTS_TWEAK_SIZE];
153 struct skcipher_request *req = NULL; 156 struct skcipher_request *req = NULL;
@@ -157,7 +160,7 @@ static int do_page_crypto(struct inode *inode,
157 struct crypto_skcipher *tfm = ci->ci_ctfm; 160 struct crypto_skcipher *tfm = ci->ci_ctfm;
158 int res = 0; 161 int res = 0;
159 162
160 req = skcipher_request_alloc(tfm, GFP_NOFS); 163 req = skcipher_request_alloc(tfm, gfp_flags);
161 if (!req) { 164 if (!req) {
162 printk_ratelimited(KERN_ERR 165 printk_ratelimited(KERN_ERR
163 "%s: crypto_request_alloc() failed\n", 166 "%s: crypto_request_alloc() failed\n",
@@ -199,10 +202,9 @@ static int do_page_crypto(struct inode *inode,
199 return 0; 202 return 0;
200} 203}
201 204
202static struct page *alloc_bounce_page(struct fscrypt_ctx *ctx) 205static struct page *alloc_bounce_page(struct fscrypt_ctx *ctx, gfp_t gfp_flags)
203{ 206{
204 ctx->w.bounce_page = mempool_alloc(fscrypt_bounce_page_pool, 207 ctx->w.bounce_page = mempool_alloc(fscrypt_bounce_page_pool, gfp_flags);
205 GFP_NOWAIT);
206 if (ctx->w.bounce_page == NULL) 208 if (ctx->w.bounce_page == NULL)
207 return ERR_PTR(-ENOMEM); 209 return ERR_PTR(-ENOMEM);
208 ctx->flags |= FS_WRITE_PATH_FL; 210 ctx->flags |= FS_WRITE_PATH_FL;
@@ -213,6 +215,7 @@ static struct page *alloc_bounce_page(struct fscrypt_ctx *ctx)
213 * fscypt_encrypt_page() - Encrypts a page 215 * fscypt_encrypt_page() - Encrypts a page
214 * @inode: The inode for which the encryption should take place 216 * @inode: The inode for which the encryption should take place
215 * @plaintext_page: The page to encrypt. Must be locked. 217 * @plaintext_page: The page to encrypt. Must be locked.
218 * @gfp_flags: The gfp flag for memory allocation
216 * 219 *
217 * Allocates a ciphertext page and encrypts plaintext_page into it using the ctx 220 * Allocates a ciphertext page and encrypts plaintext_page into it using the ctx
218 * encryption context. 221 * encryption context.
@@ -225,7 +228,7 @@ static struct page *alloc_bounce_page(struct fscrypt_ctx *ctx)
225 * error value or NULL. 228 * error value or NULL.
226 */ 229 */
227struct page *fscrypt_encrypt_page(struct inode *inode, 230struct page *fscrypt_encrypt_page(struct inode *inode,
228 struct page *plaintext_page) 231 struct page *plaintext_page, gfp_t gfp_flags)
229{ 232{
230 struct fscrypt_ctx *ctx; 233 struct fscrypt_ctx *ctx;
231 struct page *ciphertext_page = NULL; 234 struct page *ciphertext_page = NULL;
@@ -233,18 +236,19 @@ struct page *fscrypt_encrypt_page(struct inode *inode,
233 236
234 BUG_ON(!PageLocked(plaintext_page)); 237 BUG_ON(!PageLocked(plaintext_page));
235 238
236 ctx = fscrypt_get_ctx(inode); 239 ctx = fscrypt_get_ctx(inode, gfp_flags);
237 if (IS_ERR(ctx)) 240 if (IS_ERR(ctx))
238 return (struct page *)ctx; 241 return (struct page *)ctx;
239 242
240 /* The encryption operation will require a bounce page. */ 243 /* The encryption operation will require a bounce page. */
241 ciphertext_page = alloc_bounce_page(ctx); 244 ciphertext_page = alloc_bounce_page(ctx, gfp_flags);
242 if (IS_ERR(ciphertext_page)) 245 if (IS_ERR(ciphertext_page))
243 goto errout; 246 goto errout;
244 247
245 ctx->w.control_page = plaintext_page; 248 ctx->w.control_page = plaintext_page;
246 err = do_page_crypto(inode, FS_ENCRYPT, plaintext_page->index, 249 err = do_page_crypto(inode, FS_ENCRYPT, plaintext_page->index,
247 plaintext_page, ciphertext_page); 250 plaintext_page, ciphertext_page,
251 gfp_flags);
248 if (err) { 252 if (err) {
249 ciphertext_page = ERR_PTR(err); 253 ciphertext_page = ERR_PTR(err);
250 goto errout; 254 goto errout;
@@ -275,7 +279,7 @@ int fscrypt_decrypt_page(struct page *page)
275 BUG_ON(!PageLocked(page)); 279 BUG_ON(!PageLocked(page));
276 280
277 return do_page_crypto(page->mapping->host, 281 return do_page_crypto(page->mapping->host,
278 FS_DECRYPT, page->index, page, page); 282 FS_DECRYPT, page->index, page, page, GFP_NOFS);
279} 283}
280EXPORT_SYMBOL(fscrypt_decrypt_page); 284EXPORT_SYMBOL(fscrypt_decrypt_page);
281 285
@@ -289,11 +293,11 @@ int fscrypt_zeroout_range(struct inode *inode, pgoff_t lblk,
289 293
290 BUG_ON(inode->i_sb->s_blocksize != PAGE_SIZE); 294 BUG_ON(inode->i_sb->s_blocksize != PAGE_SIZE);
291 295
292 ctx = fscrypt_get_ctx(inode); 296 ctx = fscrypt_get_ctx(inode, GFP_NOFS);
293 if (IS_ERR(ctx)) 297 if (IS_ERR(ctx))
294 return PTR_ERR(ctx); 298 return PTR_ERR(ctx);
295 299
296 ciphertext_page = alloc_bounce_page(ctx); 300 ciphertext_page = alloc_bounce_page(ctx, GFP_NOWAIT);
297 if (IS_ERR(ciphertext_page)) { 301 if (IS_ERR(ciphertext_page)) {
298 err = PTR_ERR(ciphertext_page); 302 err = PTR_ERR(ciphertext_page);
299 goto errout; 303 goto errout;
@@ -301,11 +305,12 @@ int fscrypt_zeroout_range(struct inode *inode, pgoff_t lblk,
301 305
302 while (len--) { 306 while (len--) {
303 err = do_page_crypto(inode, FS_ENCRYPT, lblk, 307 err = do_page_crypto(inode, FS_ENCRYPT, lblk,
304 ZERO_PAGE(0), ciphertext_page); 308 ZERO_PAGE(0), ciphertext_page,
309 GFP_NOFS);
305 if (err) 310 if (err)
306 goto errout; 311 goto errout;
307 312
308 bio = bio_alloc(GFP_KERNEL, 1); 313 bio = bio_alloc(GFP_NOWAIT, 1);
309 if (!bio) { 314 if (!bio) {
310 err = -ENOMEM; 315 err = -ENOMEM;
311 goto errout; 316 goto errout;
@@ -345,13 +350,20 @@ EXPORT_SYMBOL(fscrypt_zeroout_range);
345 */ 350 */
346static int fscrypt_d_revalidate(struct dentry *dentry, unsigned int flags) 351static int fscrypt_d_revalidate(struct dentry *dentry, unsigned int flags)
347{ 352{
348 struct inode *dir = d_inode(dentry->d_parent); 353 struct dentry *dir;
349 struct fscrypt_info *ci = dir->i_crypt_info; 354 struct fscrypt_info *ci;
350 int dir_has_key, cached_with_key; 355 int dir_has_key, cached_with_key;
351 356
352 if (!dir->i_sb->s_cop->is_encrypted(dir)) 357 if (flags & LOOKUP_RCU)
358 return -ECHILD;
359
360 dir = dget_parent(dentry);
361 if (!d_inode(dir)->i_sb->s_cop->is_encrypted(d_inode(dir))) {
362 dput(dir);
353 return 0; 363 return 0;
364 }
354 365
366 ci = d_inode(dir)->i_crypt_info;
355 if (ci && ci->ci_keyring_key && 367 if (ci && ci->ci_keyring_key &&
356 (ci->ci_keyring_key->flags & ((1 << KEY_FLAG_INVALIDATED) | 368 (ci->ci_keyring_key->flags & ((1 << KEY_FLAG_INVALIDATED) |
357 (1 << KEY_FLAG_REVOKED) | 369 (1 << KEY_FLAG_REVOKED) |
@@ -363,6 +375,7 @@ static int fscrypt_d_revalidate(struct dentry *dentry, unsigned int flags)
363 cached_with_key = dentry->d_flags & DCACHE_ENCRYPTED_WITH_KEY; 375 cached_with_key = dentry->d_flags & DCACHE_ENCRYPTED_WITH_KEY;
364 spin_unlock(&dentry->d_lock); 376 spin_unlock(&dentry->d_lock);
365 dir_has_key = (ci != NULL); 377 dir_has_key = (ci != NULL);
378 dput(dir);
366 379
367 /* 380 /*
368 * If the dentry was cached without the key, and it is a 381 * If the dentry was cached without the key, and it is a
diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
index bece948b363d..8580831ed237 100644
--- a/fs/debugfs/inode.c
+++ b/fs/debugfs/inode.c
@@ -457,7 +457,7 @@ struct dentry *debugfs_create_automount(const char *name,
457 if (unlikely(!inode)) 457 if (unlikely(!inode))
458 return failed_creating(dentry); 458 return failed_creating(dentry);
459 459
460 inode->i_mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO; 460 make_empty_dir_inode(inode);
461 inode->i_flags |= S_AUTOMOUNT; 461 inode->i_flags |= S_AUTOMOUNT;
462 inode->i_private = data; 462 inode->i_private = data;
463 dentry->d_fsdata = (void *)f; 463 dentry->d_fsdata = (void *)f;
diff --git a/fs/ext4/crypto.c b/fs/ext4/crypto.c
index db9ae6e18154..6a6c27373b54 100644
--- a/fs/ext4/crypto.c
+++ b/fs/ext4/crypto.c
@@ -32,6 +32,7 @@
32#include <linux/random.h> 32#include <linux/random.h>
33#include <linux/scatterlist.h> 33#include <linux/scatterlist.h>
34#include <linux/spinlock_types.h> 34#include <linux/spinlock_types.h>
35#include <linux/namei.h>
35 36
36#include "ext4_extents.h" 37#include "ext4_extents.h"
37#include "xattr.h" 38#include "xattr.h"
@@ -482,6 +483,9 @@ static int ext4_d_revalidate(struct dentry *dentry, unsigned int flags)
482 struct ext4_crypt_info *ci; 483 struct ext4_crypt_info *ci;
483 int dir_has_key, cached_with_key; 484 int dir_has_key, cached_with_key;
484 485
486 if (flags & LOOKUP_RCU)
487 return -ECHILD;
488
485 dir = dget_parent(dentry); 489 dir = dget_parent(dentry);
486 if (!ext4_encrypted_inode(d_inode(dir))) { 490 if (!ext4_encrypted_inode(d_inode(dir))) {
487 dput(dir); 491 dput(dir);
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 53fec0872e60..5dafb9cef12e 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -992,7 +992,7 @@ submit_and_realloc:
992 if (f2fs_encrypted_inode(inode) && 992 if (f2fs_encrypted_inode(inode) &&
993 S_ISREG(inode->i_mode)) { 993 S_ISREG(inode->i_mode)) {
994 994
995 ctx = fscrypt_get_ctx(inode); 995 ctx = fscrypt_get_ctx(inode, GFP_NOFS);
996 if (IS_ERR(ctx)) 996 if (IS_ERR(ctx))
997 goto set_error_page; 997 goto set_error_page;
998 998
@@ -1092,14 +1092,24 @@ int do_write_data_page(struct f2fs_io_info *fio)
1092 } 1092 }
1093 1093
1094 if (f2fs_encrypted_inode(inode) && S_ISREG(inode->i_mode)) { 1094 if (f2fs_encrypted_inode(inode) && S_ISREG(inode->i_mode)) {
1095 gfp_t gfp_flags = GFP_NOFS;
1095 1096
1096 /* wait for GCed encrypted page writeback */ 1097 /* wait for GCed encrypted page writeback */
1097 f2fs_wait_on_encrypted_page_writeback(F2FS_I_SB(inode), 1098 f2fs_wait_on_encrypted_page_writeback(F2FS_I_SB(inode),
1098 fio->old_blkaddr); 1099 fio->old_blkaddr);
1099 1100retry_encrypt:
1100 fio->encrypted_page = fscrypt_encrypt_page(inode, fio->page); 1101 fio->encrypted_page = fscrypt_encrypt_page(inode, fio->page,
1102 gfp_flags);
1101 if (IS_ERR(fio->encrypted_page)) { 1103 if (IS_ERR(fio->encrypted_page)) {
1102 err = PTR_ERR(fio->encrypted_page); 1104 err = PTR_ERR(fio->encrypted_page);
1105 if (err == -ENOMEM) {
1106 /* flush pending ios and wait for a while */
1107 f2fs_flush_merged_bios(F2FS_I_SB(inode));
1108 congestion_wait(BLK_RW_ASYNC, HZ/50);
1109 gfp_flags |= __GFP_NOFAIL;
1110 err = 0;
1111 goto retry_encrypt;
1112 }
1103 goto out_writepage; 1113 goto out_writepage;
1104 } 1114 }
1105 } 1115 }
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 443e07705c2a..90d1157a09f9 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -441,7 +441,7 @@ static int f2fs_file_mmap(struct file *file, struct vm_area_struct *vma)
441static int f2fs_file_open(struct inode *inode, struct file *filp) 441static int f2fs_file_open(struct inode *inode, struct file *filp)
442{ 442{
443 int ret = generic_file_open(inode, filp); 443 int ret = generic_file_open(inode, filp);
444 struct inode *dir = filp->f_path.dentry->d_parent->d_inode; 444 struct dentry *dir;
445 445
446 if (!ret && f2fs_encrypted_inode(inode)) { 446 if (!ret && f2fs_encrypted_inode(inode)) {
447 ret = fscrypt_get_encryption_info(inode); 447 ret = fscrypt_get_encryption_info(inode);
@@ -450,9 +450,13 @@ static int f2fs_file_open(struct inode *inode, struct file *filp)
450 if (!fscrypt_has_encryption_key(inode)) 450 if (!fscrypt_has_encryption_key(inode))
451 return -ENOKEY; 451 return -ENOKEY;
452 } 452 }
453 if (f2fs_encrypted_inode(dir) && 453 dir = dget_parent(file_dentry(filp));
454 !fscrypt_has_permitted_context(dir, inode)) 454 if (f2fs_encrypted_inode(d_inode(dir)) &&
455 !fscrypt_has_permitted_context(d_inode(dir), inode)) {
456 dput(dir);
455 return -EPERM; 457 return -EPERM;
458 }
459 dput(dir);
456 return ret; 460 return ret;
457} 461}
458 462
diff --git a/fs/seq_file.c b/fs/seq_file.c
index e85664b7c7d9..19f532e7d35e 100644
--- a/fs/seq_file.c
+++ b/fs/seq_file.c
@@ -72,9 +72,10 @@ int seq_open(struct file *file, const struct seq_operations *op)
72 72
73 mutex_init(&p->lock); 73 mutex_init(&p->lock);
74 p->op = op; 74 p->op = op;
75#ifdef CONFIG_USER_NS 75
76 p->user_ns = file->f_cred->user_ns; 76 // No refcounting: the lifetime of 'p' is constrained
77#endif 77 // to the lifetime of the file.
78 p->file = file;
78 79
79 /* 80 /*
80 * Wrappers around seq_open(e.g. swaps_open) need to be 81 * Wrappers around seq_open(e.g. swaps_open) need to be
diff --git a/include/linux/fscrypto.h b/include/linux/fscrypto.h
index cd91f75de49b..6027f6bbb061 100644
--- a/include/linux/fscrypto.h
+++ b/include/linux/fscrypto.h
@@ -263,9 +263,9 @@ static inline void fscrypt_set_d_op(struct dentry *dentry)
263extern struct kmem_cache *fscrypt_info_cachep; 263extern struct kmem_cache *fscrypt_info_cachep;
264int fscrypt_initialize(void); 264int fscrypt_initialize(void);
265 265
266extern struct fscrypt_ctx *fscrypt_get_ctx(struct inode *); 266extern struct fscrypt_ctx *fscrypt_get_ctx(struct inode *, gfp_t);
267extern void fscrypt_release_ctx(struct fscrypt_ctx *); 267extern void fscrypt_release_ctx(struct fscrypt_ctx *);
268extern struct page *fscrypt_encrypt_page(struct inode *, struct page *); 268extern struct page *fscrypt_encrypt_page(struct inode *, struct page *, gfp_t);
269extern int fscrypt_decrypt_page(struct page *); 269extern int fscrypt_decrypt_page(struct page *);
270extern void fscrypt_decrypt_bio_pages(struct fscrypt_ctx *, struct bio *); 270extern void fscrypt_decrypt_bio_pages(struct fscrypt_ctx *, struct bio *);
271extern void fscrypt_pullback_bio_page(struct page **, bool); 271extern void fscrypt_pullback_bio_page(struct page **, bool);
@@ -299,7 +299,8 @@ extern int fscrypt_fname_usr_to_disk(struct inode *, const struct qstr *,
299#endif 299#endif
300 300
301/* crypto.c */ 301/* crypto.c */
302static inline struct fscrypt_ctx *fscrypt_notsupp_get_ctx(struct inode *i) 302static inline struct fscrypt_ctx *fscrypt_notsupp_get_ctx(struct inode *i,
303 gfp_t f)
303{ 304{
304 return ERR_PTR(-EOPNOTSUPP); 305 return ERR_PTR(-EOPNOTSUPP);
305} 306}
@@ -310,7 +311,7 @@ static inline void fscrypt_notsupp_release_ctx(struct fscrypt_ctx *c)
310} 311}
311 312
312static inline struct page *fscrypt_notsupp_encrypt_page(struct inode *i, 313static inline struct page *fscrypt_notsupp_encrypt_page(struct inode *i,
313 struct page *p) 314 struct page *p, gfp_t f)
314{ 315{
315 return ERR_PTR(-EOPNOTSUPP); 316 return ERR_PTR(-EOPNOTSUPP);
316} 317}
diff --git a/include/linux/mm.h b/include/linux/mm.h
index ffcff53e3b2b..a55e5be0894f 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1250,78 +1250,20 @@ long get_user_pages_remote(struct task_struct *tsk, struct mm_struct *mm,
1250 unsigned long start, unsigned long nr_pages, 1250 unsigned long start, unsigned long nr_pages,
1251 int write, int force, struct page **pages, 1251 int write, int force, struct page **pages,
1252 struct vm_area_struct **vmas); 1252 struct vm_area_struct **vmas);
1253long get_user_pages6(unsigned long start, unsigned long nr_pages, 1253long get_user_pages(unsigned long start, unsigned long nr_pages,
1254 int write, int force, struct page **pages, 1254 int write, int force, struct page **pages,
1255 struct vm_area_struct **vmas); 1255 struct vm_area_struct **vmas);
1256long get_user_pages_locked6(unsigned long start, unsigned long nr_pages, 1256long get_user_pages_locked(unsigned long start, unsigned long nr_pages,
1257 int write, int force, struct page **pages, int *locked); 1257 int write, int force, struct page **pages, int *locked);
1258long __get_user_pages_unlocked(struct task_struct *tsk, struct mm_struct *mm, 1258long __get_user_pages_unlocked(struct task_struct *tsk, struct mm_struct *mm,
1259 unsigned long start, unsigned long nr_pages, 1259 unsigned long start, unsigned long nr_pages,
1260 int write, int force, struct page **pages, 1260 int write, int force, struct page **pages,
1261 unsigned int gup_flags); 1261 unsigned int gup_flags);
1262long get_user_pages_unlocked5(unsigned long start, unsigned long nr_pages, 1262long get_user_pages_unlocked(unsigned long start, unsigned long nr_pages,
1263 int write, int force, struct page **pages); 1263 int write, int force, struct page **pages);
1264int get_user_pages_fast(unsigned long start, int nr_pages, int write, 1264int get_user_pages_fast(unsigned long start, int nr_pages, int write,
1265 struct page **pages); 1265 struct page **pages);
1266 1266
1267/* suppress warnings from use in EXPORT_SYMBOL() */
1268#ifndef __DISABLE_GUP_DEPRECATED
1269#define __gup_deprecated __deprecated
1270#else
1271#define __gup_deprecated
1272#endif
1273/*
1274 * These macros provide backward-compatibility with the old
1275 * get_user_pages() variants which took tsk/mm. These
1276 * functions/macros provide both compile-time __deprecated so we
1277 * can catch old-style use and not break the build. The actual
1278 * functions also have WARN_ON()s to let us know at runtime if
1279 * the get_user_pages() should have been the "remote" variant.
1280 *
1281 * These are hideous, but temporary.
1282 *
1283 * If you run into one of these __deprecated warnings, look
1284 * at how you are calling get_user_pages(). If you are calling
1285 * it with current/current->mm as the first two arguments,
1286 * simply remove those arguments. The behavior will be the same
1287 * as it is now. If you are calling it on another task, use
1288 * get_user_pages_remote() instead.
1289 *
1290 * Any questions? Ask Dave Hansen <dave@sr71.net>
1291 */
1292long
1293__gup_deprecated
1294get_user_pages8(struct task_struct *tsk, struct mm_struct *mm,
1295 unsigned long start, unsigned long nr_pages,
1296 int write, int force, struct page **pages,
1297 struct vm_area_struct **vmas);
1298#define GUP_MACRO(_1, _2, _3, _4, _5, _6, _7, _8, get_user_pages, ...) \
1299 get_user_pages
1300#define get_user_pages(...) GUP_MACRO(__VA_ARGS__, \
1301 get_user_pages8, x, \
1302 get_user_pages6, x, x, x, x, x)(__VA_ARGS__)
1303
1304__gup_deprecated
1305long get_user_pages_locked8(struct task_struct *tsk, struct mm_struct *mm,
1306 unsigned long start, unsigned long nr_pages,
1307 int write, int force, struct page **pages,
1308 int *locked);
1309#define GUPL_MACRO(_1, _2, _3, _4, _5, _6, _7, _8, get_user_pages_locked, ...) \
1310 get_user_pages_locked
1311#define get_user_pages_locked(...) GUPL_MACRO(__VA_ARGS__, \
1312 get_user_pages_locked8, x, \
1313 get_user_pages_locked6, x, x, x, x)(__VA_ARGS__)
1314
1315__gup_deprecated
1316long get_user_pages_unlocked7(struct task_struct *tsk, struct mm_struct *mm,
1317 unsigned long start, unsigned long nr_pages,
1318 int write, int force, struct page **pages);
1319#define GUPU_MACRO(_1, _2, _3, _4, _5, _6, _7, get_user_pages_unlocked, ...) \
1320 get_user_pages_unlocked
1321#define get_user_pages_unlocked(...) GUPU_MACRO(__VA_ARGS__, \
1322 get_user_pages_unlocked7, x, \
1323 get_user_pages_unlocked5, x, x, x, x)(__VA_ARGS__)
1324
1325/* Container for pinned pfns / pages */ 1267/* Container for pinned pfns / pages */
1326struct frame_vector { 1268struct frame_vector {
1327 unsigned int nr_allocated; /* Number of frames we have space for */ 1269 unsigned int nr_allocated; /* Number of frames we have space for */
diff --git a/include/linux/pmem.h b/include/linux/pmem.h
index ac6d872ce067..57d146fe44dd 100644
--- a/include/linux/pmem.h
+++ b/include/linux/pmem.h
@@ -72,6 +72,18 @@ static inline void arch_invalidate_pmem(void __pmem *addr, size_t size)
72} 72}
73#endif 73#endif
74 74
75static inline bool arch_has_pmem_api(void)
76{
77 return IS_ENABLED(CONFIG_ARCH_HAS_PMEM_API);
78}
79
80static inline int default_memcpy_from_pmem(void *dst, void __pmem const *src,
81 size_t size)
82{
83 memcpy(dst, (void __force *) src, size);
84 return 0;
85}
86
75/* 87/*
76 * memcpy_from_pmem - read from persistent memory with error handling 88 * memcpy_from_pmem - read from persistent memory with error handling
77 * @dst: destination buffer 89 * @dst: destination buffer
@@ -83,12 +95,10 @@ static inline void arch_invalidate_pmem(void __pmem *addr, size_t size)
83static inline int memcpy_from_pmem(void *dst, void __pmem const *src, 95static inline int memcpy_from_pmem(void *dst, void __pmem const *src,
84 size_t size) 96 size_t size)
85{ 97{
86 return arch_memcpy_from_pmem(dst, src, size); 98 if (arch_has_pmem_api())
87} 99 return arch_memcpy_from_pmem(dst, src, size);
88 100 else
89static inline bool arch_has_pmem_api(void) 101 return default_memcpy_from_pmem(dst, src, size);
90{
91 return IS_ENABLED(CONFIG_ARCH_HAS_PMEM_API);
92} 102}
93 103
94/** 104/**
diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
index dde00defbaa5..f3d45dd42695 100644
--- a/include/linux/seq_file.h
+++ b/include/linux/seq_file.h
@@ -7,13 +7,10 @@
7#include <linux/mutex.h> 7#include <linux/mutex.h>
8#include <linux/cpumask.h> 8#include <linux/cpumask.h>
9#include <linux/nodemask.h> 9#include <linux/nodemask.h>
10#include <linux/fs.h>
11#include <linux/cred.h>
10 12
11struct seq_operations; 13struct seq_operations;
12struct file;
13struct path;
14struct inode;
15struct dentry;
16struct user_namespace;
17 14
18struct seq_file { 15struct seq_file {
19 char *buf; 16 char *buf;
@@ -27,9 +24,7 @@ struct seq_file {
27 struct mutex lock; 24 struct mutex lock;
28 const struct seq_operations *op; 25 const struct seq_operations *op;
29 int poll_event; 26 int poll_event;
30#ifdef CONFIG_USER_NS 27 const struct file *file;
31 struct user_namespace *user_ns;
32#endif
33 void *private; 28 void *private;
34}; 29};
35 30
@@ -147,7 +142,7 @@ int seq_release_private(struct inode *, struct file *);
147static inline struct user_namespace *seq_user_ns(struct seq_file *seq) 142static inline struct user_namespace *seq_user_ns(struct seq_file *seq)
148{ 143{
149#ifdef CONFIG_USER_NS 144#ifdef CONFIG_USER_NS
150 return seq->user_ns; 145 return seq->file->f_cred->user_ns;
151#else 146#else
152 extern struct user_namespace init_user_ns; 147 extern struct user_namespace init_user_ns;
153 return &init_user_ns; 148 return &init_user_ns;
diff --git a/include/linux/usb_usual.h b/include/linux/usb_usual.h
index 7f5f78bd15ad..245f57dbbb61 100644
--- a/include/linux/usb_usual.h
+++ b/include/linux/usb_usual.h
@@ -79,6 +79,8 @@
79 /* Cannot handle MI_REPORT_SUPPORTED_OPERATION_CODES */ \ 79 /* Cannot handle MI_REPORT_SUPPORTED_OPERATION_CODES */ \
80 US_FLAG(MAX_SECTORS_240, 0x08000000) \ 80 US_FLAG(MAX_SECTORS_240, 0x08000000) \
81 /* Sets max_sectors to 240 */ \ 81 /* Sets max_sectors to 240 */ \
82 US_FLAG(NO_REPORT_LUNS, 0x10000000) \
83 /* Cannot handle REPORT_LUNS */ \
82 84
83#define US_FLAG(name, value) US_FL_##name = value , 85#define US_FLAG(name, value) US_FL_##name = value ,
84enum { US_DO_ALL_FLAGS }; 86enum { US_DO_ALL_FLAGS };
diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
index 2324ba5310db..ed9410936a22 100644
--- a/kernel/locking/lockdep.c
+++ b/kernel/locking/lockdep.c
@@ -1999,6 +1999,7 @@ static inline int get_first_held_lock(struct task_struct *curr,
1999 return ++i; 1999 return ++i;
2000} 2000}
2001 2001
2002#ifdef CONFIG_DEBUG_LOCKDEP
2002/* 2003/*
2003 * Returns the next chain_key iteration 2004 * Returns the next chain_key iteration
2004 */ 2005 */
@@ -2069,6 +2070,7 @@ static void print_collision(struct task_struct *curr,
2069 printk("\nstack backtrace:\n"); 2070 printk("\nstack backtrace:\n");
2070 dump_stack(); 2071 dump_stack();
2071} 2072}
2073#endif
2072 2074
2073/* 2075/*
2074 * Checks whether the chain and the current held locks are consistent 2076 * Checks whether the chain and the current held locks are consistent
diff --git a/kernel/resource.c b/kernel/resource.c
index 2e78ead30934..9b5f04404152 100644
--- a/kernel/resource.c
+++ b/kernel/resource.c
@@ -105,16 +105,25 @@ static int r_show(struct seq_file *m, void *v)
105{ 105{
106 struct resource *root = m->private; 106 struct resource *root = m->private;
107 struct resource *r = v, *p; 107 struct resource *r = v, *p;
108 unsigned long long start, end;
108 int width = root->end < 0x10000 ? 4 : 8; 109 int width = root->end < 0x10000 ? 4 : 8;
109 int depth; 110 int depth;
110 111
111 for (depth = 0, p = r; depth < MAX_IORES_LEVEL; depth++, p = p->parent) 112 for (depth = 0, p = r; depth < MAX_IORES_LEVEL; depth++, p = p->parent)
112 if (p->parent == root) 113 if (p->parent == root)
113 break; 114 break;
115
116 if (file_ns_capable(m->file, &init_user_ns, CAP_SYS_ADMIN)) {
117 start = r->start;
118 end = r->end;
119 } else {
120 start = end = 0;
121 }
122
114 seq_printf(m, "%*s%0*llx-%0*llx : %s\n", 123 seq_printf(m, "%*s%0*llx-%0*llx : %s\n",
115 depth * 2, "", 124 depth * 2, "",
116 width, (unsigned long long) r->start, 125 width, start,
117 width, (unsigned long long) r->end, 126 width, end,
118 r->name ? r->name : "<BAD>"); 127 r->name ? r->name : "<BAD>");
119 return 0; 128 return 0;
120} 129}
diff --git a/lib/assoc_array.c b/lib/assoc_array.c
index 03dd576e6773..59fd7c0b119c 100644
--- a/lib/assoc_array.c
+++ b/lib/assoc_array.c
@@ -524,7 +524,9 @@ static bool assoc_array_insert_into_terminal_node(struct assoc_array_edit *edit,
524 free_slot = i; 524 free_slot = i;
525 continue; 525 continue;
526 } 526 }
527 if (ops->compare_object(assoc_array_ptr_to_leaf(ptr), index_key)) { 527 if (assoc_array_ptr_is_leaf(ptr) &&
528 ops->compare_object(assoc_array_ptr_to_leaf(ptr),
529 index_key)) {
528 pr_devel("replace in slot %d\n", i); 530 pr_devel("replace in slot %d\n", i);
529 edit->leaf_p = &node->slots[i]; 531 edit->leaf_p = &node->slots[i];
530 edit->dead_leaf = node->slots[i]; 532 edit->dead_leaf = node->slots[i];
diff --git a/lib/lz4/lz4defs.h b/lib/lz4/lz4defs.h
index abcecdc2d0f2..c79d7ea8a38e 100644
--- a/lib/lz4/lz4defs.h
+++ b/lib/lz4/lz4defs.h
@@ -11,8 +11,7 @@
11/* 11/*
12 * Detects 64 bits mode 12 * Detects 64 bits mode
13 */ 13 */
14#if (defined(__x86_64__) || defined(__x86_64) || defined(__amd64__) \ 14#if defined(CONFIG_64BIT)
15 || defined(__ppc64__) || defined(__LP64__))
16#define LZ4_ARCH64 1 15#define LZ4_ARCH64 1
17#else 16#else
18#define LZ4_ARCH64 0 17#define LZ4_ARCH64 0
@@ -25,9 +24,7 @@
25typedef struct _U16_S { u16 v; } U16_S; 24typedef struct _U16_S { u16 v; } U16_S;
26typedef struct _U32_S { u32 v; } U32_S; 25typedef struct _U32_S { u32 v; } U32_S;
27typedef struct _U64_S { u64 v; } U64_S; 26typedef struct _U64_S { u64 v; } U64_S;
28#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) \ 27#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)
29 || defined(CONFIG_ARM) && __LINUX_ARM_ARCH__ >= 6 \
30 && defined(ARM_EFFICIENT_UNALIGNED_ACCESS)
31 28
32#define A16(x) (((U16_S *)(x))->v) 29#define A16(x) (((U16_S *)(x))->v)
33#define A32(x) (((U32_S *)(x))->v) 30#define A32(x) (((U32_S *)(x))->v)
@@ -35,6 +32,10 @@ typedef struct _U64_S { u64 v; } U64_S;
35 32
36#define PUT4(s, d) (A32(d) = A32(s)) 33#define PUT4(s, d) (A32(d) = A32(s))
37#define PUT8(s, d) (A64(d) = A64(s)) 34#define PUT8(s, d) (A64(d) = A64(s))
35
36#define LZ4_READ_LITTLEENDIAN_16(d, s, p) \
37 (d = s - A16(p))
38
38#define LZ4_WRITE_LITTLEENDIAN_16(p, v) \ 39#define LZ4_WRITE_LITTLEENDIAN_16(p, v) \
39 do { \ 40 do { \
40 A16(p) = v; \ 41 A16(p) = v; \
@@ -51,10 +52,13 @@ typedef struct _U64_S { u64 v; } U64_S;
51#define PUT8(s, d) \ 52#define PUT8(s, d) \
52 put_unaligned(get_unaligned((const u64 *) s), (u64 *) d) 53 put_unaligned(get_unaligned((const u64 *) s), (u64 *) d)
53 54
54#define LZ4_WRITE_LITTLEENDIAN_16(p, v) \ 55#define LZ4_READ_LITTLEENDIAN_16(d, s, p) \
55 do { \ 56 (d = s - get_unaligned_le16(p))
56 put_unaligned(v, (u16 *)(p)); \ 57
57 p += 2; \ 58#define LZ4_WRITE_LITTLEENDIAN_16(p, v) \
59 do { \
60 put_unaligned_le16(v, (u16 *)(p)); \
61 p += 2; \
58 } while (0) 62 } while (0)
59#endif 63#endif
60 64
@@ -140,9 +144,6 @@ typedef struct _U64_S { u64 v; } U64_S;
140 144
141#endif 145#endif
142 146
143#define LZ4_READ_LITTLEENDIAN_16(d, s, p) \
144 (d = s - get_unaligned_le16(p))
145
146#define LZ4_WILDCOPY(s, d, e) \ 147#define LZ4_WILDCOPY(s, d, e) \
147 do { \ 148 do { \
148 LZ4_COPYPACKET(s, d); \ 149 LZ4_COPYPACKET(s, d); \
diff --git a/mm/backing-dev.c b/mm/backing-dev.c
index bfbd7096b6ed..0c6317b7db38 100644
--- a/mm/backing-dev.c
+++ b/mm/backing-dev.c
@@ -898,7 +898,7 @@ static atomic_t nr_wb_congested[2];
898void clear_wb_congested(struct bdi_writeback_congested *congested, int sync) 898void clear_wb_congested(struct bdi_writeback_congested *congested, int sync)
899{ 899{
900 wait_queue_head_t *wqh = &congestion_wqh[sync]; 900 wait_queue_head_t *wqh = &congestion_wqh[sync];
901 enum wb_state bit; 901 enum wb_congested_state bit;
902 902
903 bit = sync ? WB_sync_congested : WB_async_congested; 903 bit = sync ? WB_sync_congested : WB_async_congested;
904 if (test_and_clear_bit(bit, &congested->state)) 904 if (test_and_clear_bit(bit, &congested->state))
@@ -911,7 +911,7 @@ EXPORT_SYMBOL(clear_wb_congested);
911 911
912void set_wb_congested(struct bdi_writeback_congested *congested, int sync) 912void set_wb_congested(struct bdi_writeback_congested *congested, int sync)
913{ 913{
914 enum wb_state bit; 914 enum wb_congested_state bit;
915 915
916 bit = sync ? WB_sync_congested : WB_async_congested; 916 bit = sync ? WB_sync_congested : WB_async_congested;
917 if (!test_and_set_bit(bit, &congested->state)) 917 if (!test_and_set_bit(bit, &congested->state))
diff --git a/mm/gup.c b/mm/gup.c
index fb87aea9edc8..c057784c8444 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -1,4 +1,3 @@
1#define __DISABLE_GUP_DEPRECATED 1
2#include <linux/kernel.h> 1#include <linux/kernel.h>
3#include <linux/errno.h> 2#include <linux/errno.h>
4#include <linux/err.h> 3#include <linux/err.h>
@@ -839,7 +838,7 @@ static __always_inline long __get_user_pages_locked(struct task_struct *tsk,
839 * if (locked) 838 * if (locked)
840 * up_read(&mm->mmap_sem); 839 * up_read(&mm->mmap_sem);
841 */ 840 */
842long get_user_pages_locked6(unsigned long start, unsigned long nr_pages, 841long get_user_pages_locked(unsigned long start, unsigned long nr_pages,
843 int write, int force, struct page **pages, 842 int write, int force, struct page **pages,
844 int *locked) 843 int *locked)
845{ 844{
@@ -847,7 +846,7 @@ long get_user_pages_locked6(unsigned long start, unsigned long nr_pages,
847 write, force, pages, NULL, locked, true, 846 write, force, pages, NULL, locked, true,
848 FOLL_TOUCH); 847 FOLL_TOUCH);
849} 848}
850EXPORT_SYMBOL(get_user_pages_locked6); 849EXPORT_SYMBOL(get_user_pages_locked);
851 850
852/* 851/*
853 * Same as get_user_pages_unlocked(...., FOLL_TOUCH) but it allows to 852 * Same as get_user_pages_unlocked(...., FOLL_TOUCH) but it allows to
@@ -892,13 +891,13 @@ EXPORT_SYMBOL(__get_user_pages_unlocked);
892 * or if "force" shall be set to 1 (get_user_pages_fast misses the 891 * or if "force" shall be set to 1 (get_user_pages_fast misses the
893 * "force" parameter). 892 * "force" parameter).
894 */ 893 */
895long get_user_pages_unlocked5(unsigned long start, unsigned long nr_pages, 894long get_user_pages_unlocked(unsigned long start, unsigned long nr_pages,
896 int write, int force, struct page **pages) 895 int write, int force, struct page **pages)
897{ 896{
898 return __get_user_pages_unlocked(current, current->mm, start, nr_pages, 897 return __get_user_pages_unlocked(current, current->mm, start, nr_pages,
899 write, force, pages, FOLL_TOUCH); 898 write, force, pages, FOLL_TOUCH);
900} 899}
901EXPORT_SYMBOL(get_user_pages_unlocked5); 900EXPORT_SYMBOL(get_user_pages_unlocked);
902 901
903/* 902/*
904 * get_user_pages_remote() - pin user pages in memory 903 * get_user_pages_remote() - pin user pages in memory
@@ -972,7 +971,7 @@ EXPORT_SYMBOL(get_user_pages_remote);
972 * and mm being operated on are the current task's. We also 971 * and mm being operated on are the current task's. We also
973 * obviously don't pass FOLL_REMOTE in here. 972 * obviously don't pass FOLL_REMOTE in here.
974 */ 973 */
975long get_user_pages6(unsigned long start, unsigned long nr_pages, 974long get_user_pages(unsigned long start, unsigned long nr_pages,
976 int write, int force, struct page **pages, 975 int write, int force, struct page **pages,
977 struct vm_area_struct **vmas) 976 struct vm_area_struct **vmas)
978{ 977{
@@ -980,7 +979,7 @@ long get_user_pages6(unsigned long start, unsigned long nr_pages,
980 write, force, pages, vmas, NULL, false, 979 write, force, pages, vmas, NULL, false,
981 FOLL_TOUCH); 980 FOLL_TOUCH);
982} 981}
983EXPORT_SYMBOL(get_user_pages6); 982EXPORT_SYMBOL(get_user_pages);
984 983
985/** 984/**
986 * populate_vma_page_range() - populate a range of pages in the vma. 985 * populate_vma_page_range() - populate a range of pages in the vma.
@@ -1491,7 +1490,6 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
1491int get_user_pages_fast(unsigned long start, int nr_pages, int write, 1490int get_user_pages_fast(unsigned long start, int nr_pages, int write,
1492 struct page **pages) 1491 struct page **pages)
1493{ 1492{
1494 struct mm_struct *mm = current->mm;
1495 int nr, ret; 1493 int nr, ret;
1496 1494
1497 start &= PAGE_MASK; 1495 start &= PAGE_MASK;
@@ -1503,8 +1501,7 @@ int get_user_pages_fast(unsigned long start, int nr_pages, int write,
1503 start += nr << PAGE_SHIFT; 1501 start += nr << PAGE_SHIFT;
1504 pages += nr; 1502 pages += nr;
1505 1503
1506 ret = get_user_pages_unlocked(current, mm, start, 1504 ret = get_user_pages_unlocked(start, nr_pages - nr, write, 0, pages);
1507 nr_pages - nr, write, 0, pages);
1508 1505
1509 /* Have to be a bit careful with return values */ 1506 /* Have to be a bit careful with return values */
1510 if (nr > 0) { 1507 if (nr > 0) {
@@ -1519,38 +1516,3 @@ int get_user_pages_fast(unsigned long start, int nr_pages, int write,
1519} 1516}
1520 1517
1521#endif /* CONFIG_HAVE_GENERIC_RCU_GUP */ 1518#endif /* CONFIG_HAVE_GENERIC_RCU_GUP */
1522
1523long get_user_pages8(struct task_struct *tsk, struct mm_struct *mm,
1524 unsigned long start, unsigned long nr_pages,
1525 int write, int force, struct page **pages,
1526 struct vm_area_struct **vmas)
1527{
1528 WARN_ONCE(tsk != current, "get_user_pages() called on remote task");
1529 WARN_ONCE(mm != current->mm, "get_user_pages() called on remote mm");
1530
1531 return get_user_pages6(start, nr_pages, write, force, pages, vmas);
1532}
1533EXPORT_SYMBOL(get_user_pages8);
1534
1535long get_user_pages_locked8(struct task_struct *tsk, struct mm_struct *mm,
1536 unsigned long start, unsigned long nr_pages,
1537 int write, int force, struct page **pages, int *locked)
1538{
1539 WARN_ONCE(tsk != current, "get_user_pages_locked() called on remote task");
1540 WARN_ONCE(mm != current->mm, "get_user_pages_locked() called on remote mm");
1541
1542 return get_user_pages_locked6(start, nr_pages, write, force, pages, locked);
1543}
1544EXPORT_SYMBOL(get_user_pages_locked8);
1545
1546long get_user_pages_unlocked7(struct task_struct *tsk, struct mm_struct *mm,
1547 unsigned long start, unsigned long nr_pages,
1548 int write, int force, struct page **pages)
1549{
1550 WARN_ONCE(tsk != current, "get_user_pages_unlocked() called on remote task");
1551 WARN_ONCE(mm != current->mm, "get_user_pages_unlocked() called on remote mm");
1552
1553 return get_user_pages_unlocked5(start, nr_pages, write, force, pages);
1554}
1555EXPORT_SYMBOL(get_user_pages_unlocked7);
1556
diff --git a/mm/nommu.c b/mm/nommu.c
index 102e257cc6c3..c8bd59a03c71 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -15,8 +15,6 @@
15 15
16#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 16#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
17 17
18#define __DISABLE_GUP_DEPRECATED
19
20#include <linux/export.h> 18#include <linux/export.h>
21#include <linux/mm.h> 19#include <linux/mm.h>
22#include <linux/vmacache.h> 20#include <linux/vmacache.h>
@@ -161,7 +159,7 @@ finish_or_fault:
161 * slab page or a secondary page from a compound page 159 * slab page or a secondary page from a compound page
162 * - don't permit access to VMAs that don't support it, such as I/O mappings 160 * - don't permit access to VMAs that don't support it, such as I/O mappings
163 */ 161 */
164long get_user_pages6(unsigned long start, unsigned long nr_pages, 162long get_user_pages(unsigned long start, unsigned long nr_pages,
165 int write, int force, struct page **pages, 163 int write, int force, struct page **pages,
166 struct vm_area_struct **vmas) 164 struct vm_area_struct **vmas)
167{ 165{
@@ -175,15 +173,15 @@ long get_user_pages6(unsigned long start, unsigned long nr_pages,
175 return __get_user_pages(current, current->mm, start, nr_pages, flags, 173 return __get_user_pages(current, current->mm, start, nr_pages, flags,
176 pages, vmas, NULL); 174 pages, vmas, NULL);
177} 175}
178EXPORT_SYMBOL(get_user_pages6); 176EXPORT_SYMBOL(get_user_pages);
179 177
180long get_user_pages_locked6(unsigned long start, unsigned long nr_pages, 178long get_user_pages_locked(unsigned long start, unsigned long nr_pages,
181 int write, int force, struct page **pages, 179 int write, int force, struct page **pages,
182 int *locked) 180 int *locked)
183{ 181{
184 return get_user_pages6(start, nr_pages, write, force, pages, NULL); 182 return get_user_pages(start, nr_pages, write, force, pages, NULL);
185} 183}
186EXPORT_SYMBOL(get_user_pages_locked6); 184EXPORT_SYMBOL(get_user_pages_locked);
187 185
188long __get_user_pages_unlocked(struct task_struct *tsk, struct mm_struct *mm, 186long __get_user_pages_unlocked(struct task_struct *tsk, struct mm_struct *mm,
189 unsigned long start, unsigned long nr_pages, 187 unsigned long start, unsigned long nr_pages,
@@ -199,13 +197,13 @@ long __get_user_pages_unlocked(struct task_struct *tsk, struct mm_struct *mm,
199} 197}
200EXPORT_SYMBOL(__get_user_pages_unlocked); 198EXPORT_SYMBOL(__get_user_pages_unlocked);
201 199
202long get_user_pages_unlocked5(unsigned long start, unsigned long nr_pages, 200long get_user_pages_unlocked(unsigned long start, unsigned long nr_pages,
203 int write, int force, struct page **pages) 201 int write, int force, struct page **pages)
204{ 202{
205 return __get_user_pages_unlocked(current, current->mm, start, nr_pages, 203 return __get_user_pages_unlocked(current, current->mm, start, nr_pages,
206 write, force, pages, 0); 204 write, force, pages, 0);
207} 205}
208EXPORT_SYMBOL(get_user_pages_unlocked5); 206EXPORT_SYMBOL(get_user_pages_unlocked);
209 207
210/** 208/**
211 * follow_pfn - look up PFN at a user virtual address 209 * follow_pfn - look up PFN at a user virtual address
@@ -1989,31 +1987,3 @@ static int __meminit init_admin_reserve(void)
1989 return 0; 1987 return 0;
1990} 1988}
1991subsys_initcall(init_admin_reserve); 1989subsys_initcall(init_admin_reserve);
1992
1993long get_user_pages8(struct task_struct *tsk, struct mm_struct *mm,
1994 unsigned long start, unsigned long nr_pages,
1995 int write, int force, struct page **pages,
1996 struct vm_area_struct **vmas)
1997{
1998 return get_user_pages6(start, nr_pages, write, force, pages, vmas);
1999}
2000EXPORT_SYMBOL(get_user_pages8);
2001
2002long get_user_pages_locked8(struct task_struct *tsk, struct mm_struct *mm,
2003 unsigned long start, unsigned long nr_pages,
2004 int write, int force, struct page **pages,
2005 int *locked)
2006{
2007 return get_user_pages_locked6(start, nr_pages, write,
2008 force, pages, locked);
2009}
2010EXPORT_SYMBOL(get_user_pages_locked8);
2011
2012long get_user_pages_unlocked7(struct task_struct *tsk, struct mm_struct *mm,
2013 unsigned long start, unsigned long nr_pages,
2014 int write, int force, struct page **pages)
2015{
2016 return get_user_pages_unlocked5(start, nr_pages, write, force, pages);
2017}
2018EXPORT_SYMBOL(get_user_pages_unlocked7);
2019
diff --git a/net/sunrpc/auth_gss/gss_krb5_crypto.c b/net/sunrpc/auth_gss/gss_krb5_crypto.c
index 045e11ecd332..244245bcbbd2 100644
--- a/net/sunrpc/auth_gss/gss_krb5_crypto.c
+++ b/net/sunrpc/auth_gss/gss_krb5_crypto.c
@@ -78,6 +78,7 @@ krb5_encrypt(
78 memcpy(out, in, length); 78 memcpy(out, in, length);
79 sg_init_one(sg, out, length); 79 sg_init_one(sg, out, length);
80 80
81 skcipher_request_set_tfm(req, tfm);
81 skcipher_request_set_callback(req, 0, NULL, NULL); 82 skcipher_request_set_callback(req, 0, NULL, NULL);
82 skcipher_request_set_crypt(req, sg, sg, length, local_iv); 83 skcipher_request_set_crypt(req, sg, sg, length, local_iv);
83 84
@@ -115,6 +116,7 @@ krb5_decrypt(
115 memcpy(out, in, length); 116 memcpy(out, in, length);
116 sg_init_one(sg, out, length); 117 sg_init_one(sg, out, length);
117 118
119 skcipher_request_set_tfm(req, tfm);
118 skcipher_request_set_callback(req, 0, NULL, NULL); 120 skcipher_request_set_callback(req, 0, NULL, NULL);
119 skcipher_request_set_crypt(req, sg, sg, length, local_iv); 121 skcipher_request_set_crypt(req, sg, sg, length, local_iv);
120 122
@@ -946,7 +948,8 @@ krb5_rc4_setup_seq_key(struct krb5_ctx *kctx, struct crypto_skcipher *cipher,
946 return PTR_ERR(hmac); 948 return PTR_ERR(hmac);
947 } 949 }
948 950
949 desc = kmalloc(sizeof(*desc), GFP_KERNEL); 951 desc = kmalloc(sizeof(*desc) + crypto_shash_descsize(hmac),
952 GFP_KERNEL);
950 if (!desc) { 953 if (!desc) {
951 dprintk("%s: failed to allocate shash descriptor for '%s'\n", 954 dprintk("%s: failed to allocate shash descriptor for '%s'\n",
952 __func__, kctx->gk5e->cksum_name); 955 __func__, kctx->gk5e->cksum_name);
@@ -1012,7 +1015,8 @@ krb5_rc4_setup_enc_key(struct krb5_ctx *kctx, struct crypto_skcipher *cipher,
1012 return PTR_ERR(hmac); 1015 return PTR_ERR(hmac);
1013 } 1016 }
1014 1017
1015 desc = kmalloc(sizeof(*desc), GFP_KERNEL); 1018 desc = kmalloc(sizeof(*desc) + crypto_shash_descsize(hmac),
1019 GFP_KERNEL);
1016 if (!desc) { 1020 if (!desc) {
1017 dprintk("%s: failed to allocate shash descriptor for '%s'\n", 1021 dprintk("%s: failed to allocate shash descriptor for '%s'\n",
1018 __func__, kctx->gk5e->cksum_name); 1022 __func__, kctx->gk5e->cksum_name);
diff --git a/net/sunrpc/auth_gss/gss_krb5_mech.c b/net/sunrpc/auth_gss/gss_krb5_mech.c
index 71341ccb9890..65427492b1c9 100644
--- a/net/sunrpc/auth_gss/gss_krb5_mech.c
+++ b/net/sunrpc/auth_gss/gss_krb5_mech.c
@@ -451,7 +451,8 @@ context_derive_keys_rc4(struct krb5_ctx *ctx)
451 goto out_err_free_hmac; 451 goto out_err_free_hmac;
452 452
453 453
454 desc = kmalloc(sizeof(*desc), GFP_KERNEL); 454 desc = kmalloc(sizeof(*desc) + crypto_shash_descsize(hmac),
455 GFP_KERNEL);
455 if (!desc) { 456 if (!desc) {
456 dprintk("%s: failed to allocate hash descriptor for '%s'\n", 457 dprintk("%s: failed to allocate hash descriptor for '%s'\n",
457 __func__, ctx->gk5e->cksum_name); 458 __func__, ctx->gk5e->cksum_name);
diff --git a/scripts/asn1_compiler.c b/scripts/asn1_compiler.c
index e000f44e37b8..c1b7ef3e24c1 100644
--- a/scripts/asn1_compiler.c
+++ b/scripts/asn1_compiler.c
@@ -650,7 +650,7 @@ int main(int argc, char **argv)
650 } 650 }
651 651
652 hdr = fopen(headername, "w"); 652 hdr = fopen(headername, "w");
653 if (!out) { 653 if (!hdr) {
654 perror(headername); 654 perror(headername);
655 exit(1); 655 exit(1);
656 } 656 }
diff --git a/sound/hda/hdac_i915.c b/sound/hda/hdac_i915.c
index fb96aead8257..54babe1c0b16 100644
--- a/sound/hda/hdac_i915.c
+++ b/sound/hda/hdac_i915.c
@@ -267,6 +267,18 @@ int snd_hdac_i915_register_notifier(const struct i915_audio_component_audio_ops
267} 267}
268EXPORT_SYMBOL_GPL(snd_hdac_i915_register_notifier); 268EXPORT_SYMBOL_GPL(snd_hdac_i915_register_notifier);
269 269
270/* check whether intel graphics is present */
271static bool i915_gfx_present(void)
272{
273 static struct pci_device_id ids[] = {
274 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_ANY_ID),
275 .class = PCI_BASE_CLASS_DISPLAY << 16,
276 .class_mask = 0xff << 16 },
277 {}
278 };
279 return pci_dev_present(ids);
280}
281
270/** 282/**
271 * snd_hdac_i915_init - Initialize i915 audio component 283 * snd_hdac_i915_init - Initialize i915 audio component
272 * @bus: HDA core bus 284 * @bus: HDA core bus
@@ -286,6 +298,9 @@ int snd_hdac_i915_init(struct hdac_bus *bus)
286 struct i915_audio_component *acomp; 298 struct i915_audio_component *acomp;
287 int ret; 299 int ret;
288 300
301 if (!i915_gfx_present())
302 return -ENODEV;
303
289 acomp = kzalloc(sizeof(*acomp), GFP_KERNEL); 304 acomp = kzalloc(sizeof(*acomp), GFP_KERNEL);
290 if (!acomp) 305 if (!acomp)
291 return -ENOMEM; 306 return -ENOMEM;
diff --git a/sound/isa/sscape.c b/sound/isa/sscape.c
index 7b248cdf06e2..fdcfa29e2205 100644
--- a/sound/isa/sscape.c
+++ b/sound/isa/sscape.c
@@ -591,7 +591,7 @@ static int sscape_upload_microcode(struct snd_card *card, int version)
591 } 591 }
592 err = upload_dma_data(sscape, init_fw->data, init_fw->size); 592 err = upload_dma_data(sscape, init_fw->data, init_fw->size);
593 if (err == 0) 593 if (err == 0)
594 snd_printk(KERN_INFO "sscape: MIDI firmware loaded %d KBs\n", 594 snd_printk(KERN_INFO "sscape: MIDI firmware loaded %zu KBs\n",
595 init_fw->size >> 10); 595 init_fw->size >> 10);
596 596
597 release_firmware(init_fw); 597 release_firmware(init_fw);
diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
index 5af372d01834..c83c1a8d9742 100644
--- a/sound/pci/hda/patch_hdmi.c
+++ b/sound/pci/hda/patch_hdmi.c
@@ -1396,7 +1396,6 @@ static bool hdmi_present_sense_via_verbs(struct hdmi_spec_per_pin *per_pin,
1396 struct hda_codec *codec = per_pin->codec; 1396 struct hda_codec *codec = per_pin->codec;
1397 struct hdmi_spec *spec = codec->spec; 1397 struct hdmi_spec *spec = codec->spec;
1398 struct hdmi_eld *eld = &spec->temp_eld; 1398 struct hdmi_eld *eld = &spec->temp_eld;
1399 struct hdmi_eld *pin_eld = &per_pin->sink_eld;
1400 hda_nid_t pin_nid = per_pin->pin_nid; 1399 hda_nid_t pin_nid = per_pin->pin_nid;
1401 /* 1400 /*
1402 * Always execute a GetPinSense verb here, even when called from 1401 * Always execute a GetPinSense verb here, even when called from
@@ -1413,15 +1412,15 @@ static bool hdmi_present_sense_via_verbs(struct hdmi_spec_per_pin *per_pin,
1413 present = snd_hda_pin_sense(codec, pin_nid); 1412 present = snd_hda_pin_sense(codec, pin_nid);
1414 1413
1415 mutex_lock(&per_pin->lock); 1414 mutex_lock(&per_pin->lock);
1416 pin_eld->monitor_present = !!(present & AC_PINSENSE_PRESENCE); 1415 eld->monitor_present = !!(present & AC_PINSENSE_PRESENCE);
1417 if (pin_eld->monitor_present) 1416 if (eld->monitor_present)
1418 eld->eld_valid = !!(present & AC_PINSENSE_ELDV); 1417 eld->eld_valid = !!(present & AC_PINSENSE_ELDV);
1419 else 1418 else
1420 eld->eld_valid = false; 1419 eld->eld_valid = false;
1421 1420
1422 codec_dbg(codec, 1421 codec_dbg(codec,
1423 "HDMI status: Codec=%d Pin=%d Presence_Detect=%d ELD_Valid=%d\n", 1422 "HDMI status: Codec=%d Pin=%d Presence_Detect=%d ELD_Valid=%d\n",
1424 codec->addr, pin_nid, pin_eld->monitor_present, eld->eld_valid); 1423 codec->addr, pin_nid, eld->monitor_present, eld->eld_valid);
1425 1424
1426 if (eld->eld_valid) { 1425 if (eld->eld_valid) {
1427 if (spec->ops.pin_get_eld(codec, pin_nid, eld->eld_buffer, 1426 if (spec->ops.pin_get_eld(codec, pin_nid, eld->eld_buffer,
@@ -1441,7 +1440,7 @@ static bool hdmi_present_sense_via_verbs(struct hdmi_spec_per_pin *per_pin,
1441 else 1440 else
1442 update_eld(codec, per_pin, eld); 1441 update_eld(codec, per_pin, eld);
1443 1442
1444 ret = !repoll || !pin_eld->monitor_present || pin_eld->eld_valid; 1443 ret = !repoll || !eld->monitor_present || eld->eld_valid;
1445 1444
1446 jack = snd_hda_jack_tbl_get(codec, pin_nid); 1445 jack = snd_hda_jack_tbl_get(codec, pin_nid);
1447 if (jack) 1446 if (jack)
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index fefe83f2beab..1402ba954b3d 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -4760,6 +4760,7 @@ enum {
4760 ALC225_FIXUP_DELL1_MIC_NO_PRESENCE, 4760 ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
4761 ALC280_FIXUP_HP_HEADSET_MIC, 4761 ALC280_FIXUP_HP_HEADSET_MIC,
4762 ALC221_FIXUP_HP_FRONT_MIC, 4762 ALC221_FIXUP_HP_FRONT_MIC,
4763 ALC292_FIXUP_TPT460,
4763}; 4764};
4764 4765
4765static const struct hda_fixup alc269_fixups[] = { 4766static const struct hda_fixup alc269_fixups[] = {
@@ -5409,6 +5410,12 @@ static const struct hda_fixup alc269_fixups[] = {
5409 { } 5410 { }
5410 }, 5411 },
5411 }, 5412 },
5413 [ALC292_FIXUP_TPT460] = {
5414 .type = HDA_FIXUP_FUNC,
5415 .v.func = alc_fixup_tpt440_dock,
5416 .chained = true,
5417 .chain_id = ALC293_FIXUP_LENOVO_SPK_NOISE,
5418 },
5412}; 5419};
5413 5420
5414static const struct snd_pci_quirk alc269_fixup_tbl[] = { 5421static const struct snd_pci_quirk alc269_fixup_tbl[] = {
@@ -5563,7 +5570,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
5563 SND_PCI_QUIRK(0x17aa, 0x2218, "Thinkpad X1 Carbon 2nd", ALC292_FIXUP_TPT440_DOCK), 5570 SND_PCI_QUIRK(0x17aa, 0x2218, "Thinkpad X1 Carbon 2nd", ALC292_FIXUP_TPT440_DOCK),
5564 SND_PCI_QUIRK(0x17aa, 0x2223, "ThinkPad T550", ALC292_FIXUP_TPT440_DOCK), 5571 SND_PCI_QUIRK(0x17aa, 0x2223, "ThinkPad T550", ALC292_FIXUP_TPT440_DOCK),
5565 SND_PCI_QUIRK(0x17aa, 0x2226, "ThinkPad X250", ALC292_FIXUP_TPT440_DOCK), 5572 SND_PCI_QUIRK(0x17aa, 0x2226, "ThinkPad X250", ALC292_FIXUP_TPT440_DOCK),
5566 SND_PCI_QUIRK(0x17aa, 0x2233, "Thinkpad", ALC293_FIXUP_LENOVO_SPK_NOISE), 5573 SND_PCI_QUIRK(0x17aa, 0x2233, "Thinkpad", ALC292_FIXUP_TPT460),
5567 SND_PCI_QUIRK(0x17aa, 0x30bb, "ThinkCentre AIO", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY), 5574 SND_PCI_QUIRK(0x17aa, 0x30bb, "ThinkCentre AIO", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY),
5568 SND_PCI_QUIRK(0x17aa, 0x30e2, "ThinkCentre AIO", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY), 5575 SND_PCI_QUIRK(0x17aa, 0x30e2, "ThinkCentre AIO", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY),
5569 SND_PCI_QUIRK(0x17aa, 0x3902, "Lenovo E50-80", ALC269_FIXUP_DMIC_THINKPAD_ACPI), 5576 SND_PCI_QUIRK(0x17aa, 0x3902, "Lenovo E50-80", ALC269_FIXUP_DMIC_THINKPAD_ACPI),
@@ -5658,6 +5665,7 @@ static const struct hda_model_fixup alc269_fixup_models[] = {
5658 {.id = ALC283_FIXUP_SENSE_COMBO_JACK, .name = "alc283-sense-combo"}, 5665 {.id = ALC283_FIXUP_SENSE_COMBO_JACK, .name = "alc283-sense-combo"},
5659 {.id = ALC292_FIXUP_TPT440_DOCK, .name = "tpt440-dock"}, 5666 {.id = ALC292_FIXUP_TPT440_DOCK, .name = "tpt440-dock"},
5660 {.id = ALC292_FIXUP_TPT440, .name = "tpt440"}, 5667 {.id = ALC292_FIXUP_TPT440, .name = "tpt440"},
5668 {.id = ALC292_FIXUP_TPT460, .name = "tpt460"},
5661 {} 5669 {}
5662}; 5670};
5663#define ALC225_STANDARD_PINS \ 5671#define ALC225_STANDARD_PINS \
diff --git a/sound/usb/mixer_maps.c b/sound/usb/mixer_maps.c
index ddca6547399b..1f8fb0d904e0 100644
--- a/sound/usb/mixer_maps.c
+++ b/sound/usb/mixer_maps.c
@@ -349,6 +349,16 @@ static struct usbmix_name_map bose_companion5_map[] = {
349}; 349};
350 350
351/* 351/*
352 * Dell usb dock with ALC4020 codec had a firmware problem where it got
353 * screwed up when zero volume is passed; just skip it as a workaround
354 */
355static const struct usbmix_name_map dell_alc4020_map[] = {
356 { 16, NULL },
357 { 19, NULL },
358 { 0 }
359};
360
361/*
352 * Control map entries 362 * Control map entries
353 */ 363 */
354 364
@@ -431,6 +441,10 @@ static struct usbmix_ctl_map usbmix_ctl_maps[] = {
431 .map = aureon_51_2_map, 441 .map = aureon_51_2_map,
432 }, 442 },
433 { 443 {
444 .id = USB_ID(0x0bda, 0x4014),
445 .map = dell_alc4020_map,
446 },
447 {
434 .id = USB_ID(0x0dba, 0x1000), 448 .id = USB_ID(0x0dba, 0x1000),
435 .map = mbox1_map, 449 .map = mbox1_map,
436 }, 450 },
diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c
index 6178bb5d0731..0adfd9537cf7 100644
--- a/sound/usb/quirks.c
+++ b/sound/usb/quirks.c
@@ -1134,9 +1134,11 @@ bool snd_usb_get_sample_rate_quirk(struct snd_usb_audio *chip)
1134 case USB_ID(0x045E, 0x076F): /* MS Lifecam HD-6000 */ 1134 case USB_ID(0x045E, 0x076F): /* MS Lifecam HD-6000 */
1135 case USB_ID(0x045E, 0x0772): /* MS Lifecam Studio */ 1135 case USB_ID(0x045E, 0x0772): /* MS Lifecam Studio */
1136 case USB_ID(0x045E, 0x0779): /* MS Lifecam HD-3000 */ 1136 case USB_ID(0x045E, 0x0779): /* MS Lifecam HD-3000 */
1137 case USB_ID(0x047F, 0x0415): /* Plantronics BT-300 */
1137 case USB_ID(0x047F, 0xAA05): /* Plantronics DA45 */ 1138 case USB_ID(0x047F, 0xAA05): /* Plantronics DA45 */
1138 case USB_ID(0x04D8, 0xFEEA): /* Benchmark DAC1 Pre */ 1139 case USB_ID(0x04D8, 0xFEEA): /* Benchmark DAC1 Pre */
1139 case USB_ID(0x074D, 0x3553): /* Outlaw RR2150 (Micronas UAC3553B) */ 1140 case USB_ID(0x074D, 0x3553): /* Outlaw RR2150 (Micronas UAC3553B) */
1141 case USB_ID(0x1de7, 0x0014): /* Phoenix Audio TMX320 */
1140 case USB_ID(0x21B4, 0x0081): /* AudioQuest DragonFly */ 1142 case USB_ID(0x21B4, 0x0081): /* AudioQuest DragonFly */
1141 return true; 1143 return true;
1142 } 1144 }
diff --git a/virt/kvm/arm/arch_timer.c b/virt/kvm/arm/arch_timer.c
index a9ad4fe3f68f..9aaa35dd9144 100644
--- a/virt/kvm/arm/arch_timer.c
+++ b/virt/kvm/arm/arch_timer.c
@@ -91,6 +91,8 @@ static void kvm_timer_inject_irq_work(struct work_struct *work)
91 vcpu = container_of(work, struct kvm_vcpu, arch.timer_cpu.expired); 91 vcpu = container_of(work, struct kvm_vcpu, arch.timer_cpu.expired);
92 vcpu->arch.timer_cpu.armed = false; 92 vcpu->arch.timer_cpu.armed = false;
93 93
94 WARN_ON(!kvm_timer_should_fire(vcpu));
95
94 /* 96 /*
95 * If the vcpu is blocked we want to wake it up so that it will see 97 * If the vcpu is blocked we want to wake it up so that it will see
96 * the timer has expired when entering the guest. 98 * the timer has expired when entering the guest.
@@ -98,10 +100,46 @@ static void kvm_timer_inject_irq_work(struct work_struct *work)
98 kvm_vcpu_kick(vcpu); 100 kvm_vcpu_kick(vcpu);
99} 101}
100 102
103static u64 kvm_timer_compute_delta(struct kvm_vcpu *vcpu)
104{
105 cycle_t cval, now;
106
107 cval = vcpu->arch.timer_cpu.cntv_cval;
108 now = kvm_phys_timer_read() - vcpu->kvm->arch.timer.cntvoff;
109
110 if (now < cval) {
111 u64 ns;
112
113 ns = cyclecounter_cyc2ns(timecounter->cc,
114 cval - now,
115 timecounter->mask,
116 &timecounter->frac);
117 return ns;
118 }
119
120 return 0;
121}
122
101static enum hrtimer_restart kvm_timer_expire(struct hrtimer *hrt) 123static enum hrtimer_restart kvm_timer_expire(struct hrtimer *hrt)
102{ 124{
103 struct arch_timer_cpu *timer; 125 struct arch_timer_cpu *timer;
126 struct kvm_vcpu *vcpu;
127 u64 ns;
128
104 timer = container_of(hrt, struct arch_timer_cpu, timer); 129 timer = container_of(hrt, struct arch_timer_cpu, timer);
130 vcpu = container_of(timer, struct kvm_vcpu, arch.timer_cpu);
131
132 /*
133 * Check that the timer has really expired from the guest's
134 * PoV (NTP on the host may have forced it to expire
135 * early). If we should have slept longer, restart it.
136 */
137 ns = kvm_timer_compute_delta(vcpu);
138 if (unlikely(ns)) {
139 hrtimer_forward_now(hrt, ns_to_ktime(ns));
140 return HRTIMER_RESTART;
141 }
142
105 queue_work(wqueue, &timer->expired); 143 queue_work(wqueue, &timer->expired);
106 return HRTIMER_NORESTART; 144 return HRTIMER_NORESTART;
107} 145}
@@ -176,8 +214,6 @@ static int kvm_timer_update_state(struct kvm_vcpu *vcpu)
176void kvm_timer_schedule(struct kvm_vcpu *vcpu) 214void kvm_timer_schedule(struct kvm_vcpu *vcpu)
177{ 215{
178 struct arch_timer_cpu *timer = &vcpu->arch.timer_cpu; 216 struct arch_timer_cpu *timer = &vcpu->arch.timer_cpu;
179 u64 ns;
180 cycle_t cval, now;
181 217
182 BUG_ON(timer_is_armed(timer)); 218 BUG_ON(timer_is_armed(timer));
183 219
@@ -197,14 +233,7 @@ void kvm_timer_schedule(struct kvm_vcpu *vcpu)
197 return; 233 return;
198 234
199 /* The timer has not yet expired, schedule a background timer */ 235 /* The timer has not yet expired, schedule a background timer */
200 cval = timer->cntv_cval; 236 timer_arm(timer, kvm_timer_compute_delta(vcpu));
201 now = kvm_phys_timer_read() - vcpu->kvm->arch.timer.cntvoff;
202
203 ns = cyclecounter_cyc2ns(timecounter->cc,
204 cval - now,
205 timecounter->mask,
206 &timecounter->frac);
207 timer_arm(timer, ns);
208} 237}
209 238
210void kvm_timer_unschedule(struct kvm_vcpu *vcpu) 239void kvm_timer_unschedule(struct kvm_vcpu *vcpu)
diff --git a/virt/kvm/arm/pmu.c b/virt/kvm/arm/pmu.c
index b5754c6c5508..575c7aa30d7e 100644
--- a/virt/kvm/arm/pmu.c
+++ b/virt/kvm/arm/pmu.c
@@ -193,11 +193,12 @@ static u64 kvm_pmu_overflow_status(struct kvm_vcpu *vcpu)
193{ 193{
194 u64 reg = 0; 194 u64 reg = 0;
195 195
196 if ((vcpu_sys_reg(vcpu, PMCR_EL0) & ARMV8_PMU_PMCR_E)) 196 if ((vcpu_sys_reg(vcpu, PMCR_EL0) & ARMV8_PMU_PMCR_E)) {
197 reg = vcpu_sys_reg(vcpu, PMOVSSET_EL0); 197 reg = vcpu_sys_reg(vcpu, PMOVSSET_EL0);
198 reg &= vcpu_sys_reg(vcpu, PMCNTENSET_EL0); 198 reg &= vcpu_sys_reg(vcpu, PMCNTENSET_EL0);
199 reg &= vcpu_sys_reg(vcpu, PMINTENSET_EL1); 199 reg &= vcpu_sys_reg(vcpu, PMINTENSET_EL1);
200 reg &= kvm_pmu_valid_counter_mask(vcpu); 200 reg &= kvm_pmu_valid_counter_mask(vcpu);
201 }
201 202
202 return reg; 203 return reg;
203} 204}