aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/printk-formats.txt19
-rw-r--r--MAINTAINERS1
-rw-r--r--Makefile2
-rw-r--r--arch/arm/boot/dts/imx25.dtsi1
-rw-r--r--arch/arm/boot/dts/imx6qdl-nitrogen6_som2.dtsi4
-rw-r--r--arch/arm/boot/dts/imx7d-sdb.dts16
-rw-r--r--arch/arm/boot/dts/sama5d2.dtsi12
-rw-r--r--arch/arm64/boot/dts/allwinner/sun50i-a64-bananapi-m64.dts1
-rw-r--r--arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts1
-rw-r--r--arch/arm64/boot/dts/allwinner/sun50i-a64-sopine-baseboard.dts1
-rw-r--r--arch/arm64/boot/dts/allwinner/sun50i-h5.dtsi3
-rw-r--r--arch/arm64/boot/dts/renesas/salvator-common.dtsi2
-rw-r--r--arch/arm64/include/asm/arch_timer.h4
-rw-r--r--arch/arm64/include/asm/elf.h4
-rw-r--r--arch/powerpc/Kconfig2
-rw-r--r--arch/powerpc/kernel/process.c5
-rw-r--r--arch/x86/Kconfig3
-rw-r--r--arch/x86/crypto/sha1_avx2_x86_64_asm.S67
-rw-r--r--arch/x86/crypto/sha1_ssse3_glue.c2
-rw-r--r--arch/x86/entry/entry_64.S2
-rw-r--r--arch/x86/events/core.c16
-rw-r--r--arch/x86/events/intel/bts.c2
-rw-r--r--arch/x86/events/intel/p4.c2
-rw-r--r--arch/x86/events/intel/rapl.c2
-rw-r--r--arch/x86/events/intel/uncore.c2
-rw-r--r--arch/x86/events/intel/uncore_nhmex.c12
-rw-r--r--arch/x86/events/intel/uncore_snb.c6
-rw-r--r--arch/x86/events/intel/uncore_snbep.c42
-rw-r--r--arch/x86/include/asm/cpufeatures.h2
-rw-r--r--arch/x86/include/asm/elf.h4
-rw-r--r--arch/x86/kernel/cpu/aperfmperf.c3
-rw-r--r--arch/x86/kernel/cpu/mcheck/therm_throt.c2
-rw-r--r--arch/x86/kernel/cpu/microcode/core.c4
-rw-r--r--arch/x86/kernel/cpu/mtrr/main.c18
-rw-r--r--arch/x86/kernel/head64.c7
-rw-r--r--arch/x86/kernel/ksysfs.c4
-rw-r--r--arch/x86/kernel/smpboot.c30
-rw-r--r--arch/x86/kvm/svm.c2
-rw-r--r--arch/x86/mm/mmap.c7
-rw-r--r--arch/x86/platform/uv/tlb_uv.c4
-rw-r--r--block/blk-mq-pci.c8
-rw-r--r--block/blk-mq.c5
-rw-r--r--drivers/acpi/acpica/nsxfeval.c10
-rw-r--r--drivers/acpi/property.c2
-rw-r--r--drivers/block/xen-blkfront.c6
-rw-r--r--drivers/clocksource/Kconfig2
-rw-r--r--drivers/clocksource/arm_arch_timer.c2
-rw-r--r--drivers/clocksource/em_sti.c11
-rw-r--r--drivers/clocksource/timer-of.c4
-rw-r--r--drivers/cpufreq/intel_pstate.c3
-rw-r--r--drivers/crypto/ixp4xx_crypto.c6
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c13
-rw-r--r--drivers/gpu/drm/i915/i915_debugfs.c2
-rw-r--r--drivers/gpu/drm/i915/i915_gem_context.c15
-rw-r--r--drivers/gpu/drm/i915/i915_gem_render_state.c4
-rw-r--r--drivers/gpu/drm/i915/intel_ddi.c2
-rw-r--r--drivers/gpu/drm/i915/intel_display.c7
-rw-r--r--drivers/gpu/drm/i915/intel_lrc.h1
-rw-r--r--drivers/infiniband/core/device.c5
-rw-r--r--drivers/infiniband/core/uverbs_main.c2
-rw-r--r--drivers/infiniband/hw/cxgb4/mem.c2
-rw-r--r--drivers/infiniband/hw/hns/hns_roce_ah.c4
-rw-r--r--drivers/infiniband/hw/i40iw/i40iw_ctrl.c123
-rw-r--r--drivers/infiniband/hw/i40iw/i40iw_d.h4
-rw-r--r--drivers/infiniband/hw/i40iw/i40iw_puda.c2
-rw-r--r--drivers/infiniband/hw/i40iw/i40iw_status.h2
-rw-r--r--drivers/infiniband/hw/i40iw/i40iw_uk.c8
-rw-r--r--drivers/infiniband/hw/vmw_pvrdma/pvrdma_cq.c17
-rw-r--r--drivers/input/mouse/elan_i2c_core.c4
-rw-r--r--drivers/input/mouse/trackpoint.c4
-rw-r--r--drivers/irqchip/irq-atmel-aic-common.c13
-rw-r--r--drivers/irqchip/irq-atmel-aic-common.h4
-rw-r--r--drivers/irqchip/irq-atmel-aic.c14
-rw-r--r--drivers/irqchip/irq-atmel-aic5.c4
-rw-r--r--drivers/irqchip/irq-brcmstb-l2.c1
-rw-r--r--drivers/irqchip/irq-gic-v3-its-platform-msi.c1
-rw-r--r--drivers/irqchip/irq-gic-v3-its.c40
-rw-r--r--drivers/irqchip/irq-gic-v3.c16
-rw-r--r--drivers/irqchip/irq-gic.c14
-rw-r--r--drivers/isdn/mISDN/fsm.c5
-rw-r--r--drivers/isdn/mISDN/fsm.h2
-rw-r--r--drivers/isdn/mISDN/layer1.c3
-rw-r--r--drivers/isdn/mISDN/layer2.c15
-rw-r--r--drivers/isdn/mISDN/tei.c20
-rw-r--r--drivers/md/md.c5
-rw-r--r--drivers/md/raid5-cache.c61
-rw-r--r--drivers/net/bonding/bond_main.c13
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/cxgb4.h1
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c23
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/sge.c5
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4vf/adapter.h1
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c18
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4vf/sge.c3
-rw-r--r--drivers/net/ethernet/netronome/nfp/flower/cmsg.c8
-rw-r--r--drivers/net/ethernet/sfc/mcdi_port.c8
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c9
-rw-r--r--drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.c6
-rw-r--r--drivers/net/wireless/intel/iwlwifi/cfg/9000.c14
-rw-r--r--drivers/net/wireless/intel/iwlwifi/fw/file.h2
-rw-r--r--drivers/net/wireless/intel/iwlwifi/iwl-config.h8
-rw-r--r--drivers/net/wireless/intel/iwlwifi/iwl-drv.c5
-rw-r--r--drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c19
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/fw.c6
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c12
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/rs.c8
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c10
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/sta.c7
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/tx.c12
-rw-r--r--drivers/net/wireless/intel/iwlwifi/pcie/drv.c20
-rw-r--r--drivers/nvme/host/fabrics.c3
-rw-r--r--drivers/nvme/host/pci.c5
-rw-r--r--drivers/nvme/target/admin-cmd.c6
-rw-r--r--drivers/nvme/target/fc.c9
-rw-r--r--drivers/of/device.c8
-rw-r--r--drivers/parisc/dino.c2
-rw-r--r--drivers/pci/pci.c7
-rw-r--r--drivers/pci/probe.c43
-rw-r--r--drivers/pci/quirks.c89
-rw-r--r--drivers/scsi/ipr.c33
-rw-r--r--drivers/scsi/ipr.h2
-rw-r--r--drivers/scsi/qla2xxx/qla_tmpl.c12
-rw-r--r--drivers/scsi/ses.c2
-rw-r--r--drivers/scsi/st.c4
-rw-r--r--drivers/soc/imx/gpcv2.c15
-rw-r--r--drivers/soc/ti/ti_sci_pm_domains.c2
-rw-r--r--drivers/tty/pty.c7
-rw-r--r--drivers/xen/biomerge.c3
-rw-r--r--fs/binfmt_elf.c3
-rw-r--r--fs/devpts/inode.c4
-rw-r--r--fs/iomap.c4
-rw-r--r--fs/quota/dquot.c21
-rw-r--r--fs/xfs/libxfs/xfs_ialloc.c2
-rw-r--r--fs/xfs/xfs_log.c11
-rw-r--r--fs/xfs/xfs_mount.c12
-rw-r--r--include/linux/devpts_fs.h2
-rw-r--r--include/linux/memblock.h6
-rw-r--r--include/linux/memcontrol.h10
-rw-r--r--include/linux/net.h2
-rw-r--r--include/linux/nmi.h8
-rw-r--r--include/linux/oom.h22
-rw-r--r--include/linux/pci.h3
-rw-r--r--include/linux/perf_event.h4
-rw-r--r--include/linux/wait.h37
-rw-r--r--include/net/addrconf.h10
-rw-r--r--include/net/bonding.h5
-rw-r--r--include/net/busy_poll.h12
-rw-r--r--include/net/mac80211.h15
-rw-r--r--include/net/udp.h7
-rw-r--r--kernel/audit_watch.c14
-rw-r--r--kernel/events/core.c47
-rw-r--r--kernel/irq/chip.c10
-rw-r--r--kernel/irq/ipi.c4
-rw-r--r--kernel/kmod.c25
-rw-r--r--kernel/signal.c6
-rw-r--r--kernel/trace/bpf_trace.c34
-rw-r--r--kernel/watchdog.c1
-rw-r--r--kernel/watchdog_hld.c59
-rw-r--r--lib/Kconfig.debug7
-rw-r--r--mm/cma_debug.c2
-rw-r--r--mm/huge_memory.c30
-rw-r--r--mm/memblock.c38
-rw-r--r--mm/memcontrol.c43
-rw-r--r--mm/memory.c36
-rw-r--r--mm/mempolicy.c5
-rw-r--r--mm/migrate.c11
-rw-r--r--mm/nobootmem.c16
-rw-r--r--mm/page-writeback.c15
-rw-r--r--mm/page_alloc.c4
-rw-r--r--mm/slub.c3
-rw-r--r--mm/vmalloc.c13
-rw-r--r--net/core/filter.c2
-rw-r--r--net/dccp/proto.c5
-rw-r--r--net/dsa/tag_ksz.c13
-rw-r--r--net/ipv4/fib_semantics.c12
-rw-r--r--net/ipv4/route.c3
-rw-r--r--net/ipv4/tcp_ipv4.c4
-rw-r--r--net/ipv4/tcp_ulp.c14
-rw-r--r--net/ipv6/route.c19
-rw-r--r--net/ipv6/tcp_ipv6.c4
-rw-r--r--net/key/af_key.c48
-rw-r--r--net/mac80211/agg-rx.c22
-rw-r--r--net/sched/sch_api.c3
-rw-r--r--net/sched/sch_atm.c4
-rw-r--r--net/sched/sch_cbq.c4
-rw-r--r--net/sched/sch_hfsc.c12
-rw-r--r--net/sched/sch_htb.c4
-rw-r--r--net/sched/sch_sfq.c5
-rw-r--r--net/tipc/bearer.c2
-rw-r--r--net/tipc/msg.c1
-rw-r--r--sound/core/seq/Kconfig4
-rw-r--r--sound/core/seq/seq_clientmgr.c13
-rw-r--r--sound/core/seq/seq_queue.c14
-rw-r--r--sound/core/seq/seq_queue.h2
-rw-r--r--sound/pci/emu10k1/emufx.c14
-rw-r--r--sound/pci/hda/patch_realtek.c1
-rw-r--r--sound/usb/mixer.c2
-rw-r--r--sound/usb/mixer.h1
-rw-r--r--sound/usb/mixer_quirks.c6
-rw-r--r--sound/usb/quirks.c5
-rw-r--r--tools/testing/selftests/futex/Makefile2
-rwxr-xr-x[-rw-r--r--]tools/testing/selftests/kmod/kmod.sh4
-rwxr-xr-x[-rw-r--r--]tools/testing/selftests/sysctl/sysctl.sh0
-rw-r--r--tools/testing/selftests/timers/freq-step.c7
203 files changed, 1486 insertions, 684 deletions
diff --git a/Documentation/printk-formats.txt b/Documentation/printk-formats.txt
index 65ea5915178b..074670b98bac 100644
--- a/Documentation/printk-formats.txt
+++ b/Documentation/printk-formats.txt
@@ -58,20 +58,23 @@ Symbols/Function Pointers
58 %ps versatile_init 58 %ps versatile_init
59 %pB prev_fn_of_versatile_init+0x88/0x88 59 %pB prev_fn_of_versatile_init+0x88/0x88
60 60
61For printing symbols and function pointers. The ``S`` and ``s`` specifiers 61The ``F`` and ``f`` specifiers are for printing function pointers,
62result in the symbol name with (``S``) or without (``s``) offsets. Where 62for example, f->func, &gettimeofday. They have the same result as
63this is used on a kernel without KALLSYMS - the symbol address is 63``S`` and ``s`` specifiers. But they do an extra conversion on
64printed instead. 64ia64, ppc64 and parisc64 architectures where the function pointers
65are actually function descriptors.
66
67The ``S`` and ``s`` specifiers can be used for printing symbols
68from direct addresses, for example, __builtin_return_address(0),
69(void *)regs->ip. They result in the symbol name with (``S``) or
70without (``s``) offsets. If KALLSYMS are disabled then the symbol
71address is printed instead.
65 72
66The ``B`` specifier results in the symbol name with offsets and should be 73The ``B`` specifier results in the symbol name with offsets and should be
67used when printing stack backtraces. The specifier takes into 74used when printing stack backtraces. The specifier takes into
68consideration the effect of compiler optimisations which may occur 75consideration the effect of compiler optimisations which may occur
69when tail-call``s are used and marked with the noreturn GCC attribute. 76when tail-call``s are used and marked with the noreturn GCC attribute.
70 77
71On ia64, ppc64 and parisc64 architectures function pointers are
72actually function descriptors which must first be resolved. The ``F`` and
73``f`` specifiers perform this resolution and then provide the same
74functionality as the ``S`` and ``s`` specifiers.
75 78
76Kernel Pointers 79Kernel Pointers
77=============== 80===============
diff --git a/MAINTAINERS b/MAINTAINERS
index 6f7721d1634c..1c3feffb1c1c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -7110,7 +7110,6 @@ M: Marc Zyngier <marc.zyngier@arm.com>
7110L: linux-kernel@vger.kernel.org 7110L: linux-kernel@vger.kernel.org
7111S: Maintained 7111S: Maintained
7112T: git git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git irq/core 7112T: git git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git irq/core
7113T: git git://git.infradead.org/users/jcooper/linux.git irqchip/core
7114F: Documentation/devicetree/bindings/interrupt-controller/ 7113F: Documentation/devicetree/bindings/interrupt-controller/
7115F: drivers/irqchip/ 7114F: drivers/irqchip/
7116 7115
diff --git a/Makefile b/Makefile
index 90da7bdc3f45..235826f95741 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
1VERSION = 4 1VERSION = 4
2PATCHLEVEL = 13 2PATCHLEVEL = 13
3SUBLEVEL = 0 3SUBLEVEL = 0
4EXTRAVERSION = -rc5 4EXTRAVERSION = -rc6
5NAME = Fearless Coyote 5NAME = Fearless Coyote
6 6
7# *DOCUMENTATION* 7# *DOCUMENTATION*
diff --git a/arch/arm/boot/dts/imx25.dtsi b/arch/arm/boot/dts/imx25.dtsi
index dfcc8e00cf1c..0ade3619f3c3 100644
--- a/arch/arm/boot/dts/imx25.dtsi
+++ b/arch/arm/boot/dts/imx25.dtsi
@@ -297,6 +297,7 @@
297 #address-cells = <1>; 297 #address-cells = <1>;
298 #size-cells = <1>; 298 #size-cells = <1>;
299 status = "disabled"; 299 status = "disabled";
300 ranges;
300 301
301 adc: adc@50030800 { 302 adc: adc@50030800 {
302 compatible = "fsl,imx25-gcq"; 303 compatible = "fsl,imx25-gcq";
diff --git a/arch/arm/boot/dts/imx6qdl-nitrogen6_som2.dtsi b/arch/arm/boot/dts/imx6qdl-nitrogen6_som2.dtsi
index aeaa5a6e4fcf..a24e4f1911ab 100644
--- a/arch/arm/boot/dts/imx6qdl-nitrogen6_som2.dtsi
+++ b/arch/arm/boot/dts/imx6qdl-nitrogen6_som2.dtsi
@@ -507,7 +507,7 @@
507 pinctrl_pcie: pciegrp { 507 pinctrl_pcie: pciegrp {
508 fsl,pins = < 508 fsl,pins = <
509 /* PCIe reset */ 509 /* PCIe reset */
510 MX6QDL_PAD_EIM_BCLK__GPIO6_IO31 0x030b0 510 MX6QDL_PAD_EIM_DA0__GPIO3_IO00 0x030b0
511 MX6QDL_PAD_EIM_DA4__GPIO3_IO04 0x030b0 511 MX6QDL_PAD_EIM_DA4__GPIO3_IO04 0x030b0
512 >; 512 >;
513 }; 513 };
@@ -668,7 +668,7 @@
668&pcie { 668&pcie {
669 pinctrl-names = "default"; 669 pinctrl-names = "default";
670 pinctrl-0 = <&pinctrl_pcie>; 670 pinctrl-0 = <&pinctrl_pcie>;
671 reset-gpio = <&gpio6 31 GPIO_ACTIVE_LOW>; 671 reset-gpio = <&gpio3 0 GPIO_ACTIVE_LOW>;
672 status = "okay"; 672 status = "okay";
673}; 673};
674 674
diff --git a/arch/arm/boot/dts/imx7d-sdb.dts b/arch/arm/boot/dts/imx7d-sdb.dts
index 54c45402286b..0a24d1bf3c39 100644
--- a/arch/arm/boot/dts/imx7d-sdb.dts
+++ b/arch/arm/boot/dts/imx7d-sdb.dts
@@ -557,6 +557,14 @@
557 >; 557 >;
558 }; 558 };
559 559
560 pinctrl_spi4: spi4grp {
561 fsl,pins = <
562 MX7D_PAD_GPIO1_IO09__GPIO1_IO9 0x59
563 MX7D_PAD_GPIO1_IO12__GPIO1_IO12 0x59
564 MX7D_PAD_GPIO1_IO13__GPIO1_IO13 0x59
565 >;
566 };
567
560 pinctrl_tsc2046_pendown: tsc2046_pendown { 568 pinctrl_tsc2046_pendown: tsc2046_pendown {
561 fsl,pins = < 569 fsl,pins = <
562 MX7D_PAD_EPDC_BDR1__GPIO2_IO29 0x59 570 MX7D_PAD_EPDC_BDR1__GPIO2_IO29 0x59
@@ -697,13 +705,5 @@
697 fsl,pins = < 705 fsl,pins = <
698 MX7D_PAD_LPSR_GPIO1_IO01__PWM1_OUT 0x110b0 706 MX7D_PAD_LPSR_GPIO1_IO01__PWM1_OUT 0x110b0
699 >; 707 >;
700
701 pinctrl_spi4: spi4grp {
702 fsl,pins = <
703 MX7D_PAD_GPIO1_IO09__GPIO1_IO9 0x59
704 MX7D_PAD_GPIO1_IO12__GPIO1_IO12 0x59
705 MX7D_PAD_GPIO1_IO13__GPIO1_IO13 0x59
706 >;
707 };
708 }; 708 };
709}; 709};
diff --git a/arch/arm/boot/dts/sama5d2.dtsi b/arch/arm/boot/dts/sama5d2.dtsi
index cc06da394366..60e69aeacbdb 100644
--- a/arch/arm/boot/dts/sama5d2.dtsi
+++ b/arch/arm/boot/dts/sama5d2.dtsi
@@ -303,7 +303,7 @@
303 #size-cells = <1>; 303 #size-cells = <1>;
304 atmel,smc = <&hsmc>; 304 atmel,smc = <&hsmc>;
305 reg = <0x10000000 0x10000000 305 reg = <0x10000000 0x10000000
306 0x40000000 0x30000000>; 306 0x60000000 0x30000000>;
307 ranges = <0x0 0x0 0x10000000 0x10000000 307 ranges = <0x0 0x0 0x10000000 0x10000000
308 0x1 0x0 0x60000000 0x10000000 308 0x1 0x0 0x60000000 0x10000000
309 0x2 0x0 0x70000000 0x10000000 309 0x2 0x0 0x70000000 0x10000000
@@ -1048,18 +1048,18 @@
1048 }; 1048 };
1049 1049
1050 hsmc: hsmc@f8014000 { 1050 hsmc: hsmc@f8014000 {
1051 compatible = "atmel,sama5d3-smc", "syscon", "simple-mfd"; 1051 compatible = "atmel,sama5d2-smc", "syscon", "simple-mfd";
1052 reg = <0xf8014000 0x1000>; 1052 reg = <0xf8014000 0x1000>;
1053 interrupts = <5 IRQ_TYPE_LEVEL_HIGH 6>; 1053 interrupts = <17 IRQ_TYPE_LEVEL_HIGH 6>;
1054 clocks = <&hsmc_clk>; 1054 clocks = <&hsmc_clk>;
1055 #address-cells = <1>; 1055 #address-cells = <1>;
1056 #size-cells = <1>; 1056 #size-cells = <1>;
1057 ranges; 1057 ranges;
1058 1058
1059 pmecc: ecc-engine@ffffc070 { 1059 pmecc: ecc-engine@f8014070 {
1060 compatible = "atmel,sama5d2-pmecc"; 1060 compatible = "atmel,sama5d2-pmecc";
1061 reg = <0xffffc070 0x490>, 1061 reg = <0xf8014070 0x490>,
1062 <0xffffc500 0x100>; 1062 <0xf8014500 0x100>;
1063 }; 1063 };
1064 }; 1064 };
1065 1065
diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64-bananapi-m64.dts b/arch/arm64/boot/dts/allwinner/sun50i-a64-bananapi-m64.dts
index 0d1f026d831a..ba2fde2909f9 100644
--- a/arch/arm64/boot/dts/allwinner/sun50i-a64-bananapi-m64.dts
+++ b/arch/arm64/boot/dts/allwinner/sun50i-a64-bananapi-m64.dts
@@ -51,6 +51,7 @@
51 compatible = "sinovoip,bananapi-m64", "allwinner,sun50i-a64"; 51 compatible = "sinovoip,bananapi-m64", "allwinner,sun50i-a64";
52 52
53 aliases { 53 aliases {
54 ethernet0 = &emac;
54 serial0 = &uart0; 55 serial0 = &uart0;
55 serial1 = &uart1; 56 serial1 = &uart1;
56 }; 57 };
diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts b/arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts
index 08cda24ea194..827168bc22ed 100644
--- a/arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts
+++ b/arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts
@@ -51,6 +51,7 @@
51 compatible = "pine64,pine64", "allwinner,sun50i-a64"; 51 compatible = "pine64,pine64", "allwinner,sun50i-a64";
52 52
53 aliases { 53 aliases {
54 ethernet0 = &emac;
54 serial0 = &uart0; 55 serial0 = &uart0;
55 serial1 = &uart1; 56 serial1 = &uart1;
56 serial2 = &uart2; 57 serial2 = &uart2;
diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64-sopine-baseboard.dts b/arch/arm64/boot/dts/allwinner/sun50i-a64-sopine-baseboard.dts
index 17eb1cc5bf6b..216e3a5dafae 100644
--- a/arch/arm64/boot/dts/allwinner/sun50i-a64-sopine-baseboard.dts
+++ b/arch/arm64/boot/dts/allwinner/sun50i-a64-sopine-baseboard.dts
@@ -53,6 +53,7 @@
53 "allwinner,sun50i-a64"; 53 "allwinner,sun50i-a64";
54 54
55 aliases { 55 aliases {
56 ethernet0 = &emac;
56 serial0 = &uart0; 57 serial0 = &uart0;
57 }; 58 };
58 59
diff --git a/arch/arm64/boot/dts/allwinner/sun50i-h5.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-h5.dtsi
index 732e2e06f503..d9a720bff05d 100644
--- a/arch/arm64/boot/dts/allwinner/sun50i-h5.dtsi
+++ b/arch/arm64/boot/dts/allwinner/sun50i-h5.dtsi
@@ -120,5 +120,8 @@
120}; 120};
121 121
122&pio { 122&pio {
123 interrupts = <GIC_SPI 11 IRQ_TYPE_LEVEL_HIGH>,
124 <GIC_SPI 17 IRQ_TYPE_LEVEL_HIGH>,
125 <GIC_SPI 23 IRQ_TYPE_LEVEL_HIGH>;
123 compatible = "allwinner,sun50i-h5-pinctrl"; 126 compatible = "allwinner,sun50i-h5-pinctrl";
124}; 127};
diff --git a/arch/arm64/boot/dts/renesas/salvator-common.dtsi b/arch/arm64/boot/dts/renesas/salvator-common.dtsi
index a451996f590a..f903957da504 100644
--- a/arch/arm64/boot/dts/renesas/salvator-common.dtsi
+++ b/arch/arm64/boot/dts/renesas/salvator-common.dtsi
@@ -45,7 +45,7 @@
45 stdout-path = "serial0:115200n8"; 45 stdout-path = "serial0:115200n8";
46 }; 46 };
47 47
48 audio_clkout: audio_clkout { 48 audio_clkout: audio-clkout {
49 /* 49 /*
50 * This is same as <&rcar_sound 0> 50 * This is same as <&rcar_sound 0>
51 * but needed to avoid cs2000/rcar_sound probe dead-lock 51 * but needed to avoid cs2000/rcar_sound probe dead-lock
diff --git a/arch/arm64/include/asm/arch_timer.h b/arch/arm64/include/asm/arch_timer.h
index 74d08e44a651..a652ce0a5cb2 100644
--- a/arch/arm64/include/asm/arch_timer.h
+++ b/arch/arm64/include/asm/arch_timer.h
@@ -65,13 +65,13 @@ DECLARE_PER_CPU(const struct arch_timer_erratum_workaround *,
65 u64 _val; \ 65 u64 _val; \
66 if (needs_unstable_timer_counter_workaround()) { \ 66 if (needs_unstable_timer_counter_workaround()) { \
67 const struct arch_timer_erratum_workaround *wa; \ 67 const struct arch_timer_erratum_workaround *wa; \
68 preempt_disable(); \ 68 preempt_disable_notrace(); \
69 wa = __this_cpu_read(timer_unstable_counter_workaround); \ 69 wa = __this_cpu_read(timer_unstable_counter_workaround); \
70 if (wa && wa->read_##reg) \ 70 if (wa && wa->read_##reg) \
71 _val = wa->read_##reg(); \ 71 _val = wa->read_##reg(); \
72 else \ 72 else \
73 _val = read_sysreg(reg); \ 73 _val = read_sysreg(reg); \
74 preempt_enable(); \ 74 preempt_enable_notrace(); \
75 } else { \ 75 } else { \
76 _val = read_sysreg(reg); \ 76 _val = read_sysreg(reg); \
77 } \ 77 } \
diff --git a/arch/arm64/include/asm/elf.h b/arch/arm64/include/asm/elf.h
index acae781f7359..3288c2b36731 100644
--- a/arch/arm64/include/asm/elf.h
+++ b/arch/arm64/include/asm/elf.h
@@ -114,10 +114,10 @@
114 114
115/* 115/*
116 * This is the base location for PIE (ET_DYN with INTERP) loads. On 116 * This is the base location for PIE (ET_DYN with INTERP) loads. On
117 * 64-bit, this is raised to 4GB to leave the entire 32-bit address 117 * 64-bit, this is above 4GB to leave the entire 32-bit address
118 * space open for things that want to use the area for 32-bit pointers. 118 * space open for things that want to use the area for 32-bit pointers.
119 */ 119 */
120#define ELF_ET_DYN_BASE 0x100000000UL 120#define ELF_ET_DYN_BASE (2 * TASK_SIZE_64 / 3)
121 121
122#ifndef __ASSEMBLY__ 122#ifndef __ASSEMBLY__
123 123
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 36f858c37ca7..81b0031f909f 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -199,7 +199,7 @@ config PPC
199 select HAVE_OPTPROBES if PPC64 199 select HAVE_OPTPROBES if PPC64
200 select HAVE_PERF_EVENTS 200 select HAVE_PERF_EVENTS
201 select HAVE_PERF_EVENTS_NMI if PPC64 201 select HAVE_PERF_EVENTS_NMI if PPC64
202 select HAVE_HARDLOCKUP_DETECTOR_PERF if HAVE_PERF_EVENTS_NMI && !HAVE_HARDLOCKUP_DETECTOR_ARCH 202 select HAVE_HARDLOCKUP_DETECTOR_PERF if PERF_EVENTS && HAVE_PERF_EVENTS_NMI && !HAVE_HARDLOCKUP_DETECTOR_ARCH
203 select HAVE_PERF_REGS 203 select HAVE_PERF_REGS
204 select HAVE_PERF_USER_STACK_DUMP 204 select HAVE_PERF_USER_STACK_DUMP
205 select HAVE_RCU_TABLE_FREE if SMP 205 select HAVE_RCU_TABLE_FREE if SMP
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index ec480966f9bf..1f0fd361e09b 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -362,7 +362,8 @@ void enable_kernel_vsx(void)
362 362
363 cpumsr = msr_check_and_set(MSR_FP|MSR_VEC|MSR_VSX); 363 cpumsr = msr_check_and_set(MSR_FP|MSR_VEC|MSR_VSX);
364 364
365 if (current->thread.regs && (current->thread.regs->msr & MSR_VSX)) { 365 if (current->thread.regs &&
366 (current->thread.regs->msr & (MSR_VSX|MSR_VEC|MSR_FP))) {
366 check_if_tm_restore_required(current); 367 check_if_tm_restore_required(current);
367 /* 368 /*
368 * If a thread has already been reclaimed then the 369 * If a thread has already been reclaimed then the
@@ -386,7 +387,7 @@ void flush_vsx_to_thread(struct task_struct *tsk)
386{ 387{
387 if (tsk->thread.regs) { 388 if (tsk->thread.regs) {
388 preempt_disable(); 389 preempt_disable();
389 if (tsk->thread.regs->msr & MSR_VSX) { 390 if (tsk->thread.regs->msr & (MSR_VSX|MSR_VEC|MSR_FP)) {
390 BUG_ON(tsk != current); 391 BUG_ON(tsk != current);
391 giveup_vsx(tsk); 392 giveup_vsx(tsk);
392 } 393 }
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 781521b7cf9e..323cb065be5e 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -100,6 +100,7 @@ config X86
100 select GENERIC_STRNCPY_FROM_USER 100 select GENERIC_STRNCPY_FROM_USER
101 select GENERIC_STRNLEN_USER 101 select GENERIC_STRNLEN_USER
102 select GENERIC_TIME_VSYSCALL 102 select GENERIC_TIME_VSYSCALL
103 select HARDLOCKUP_CHECK_TIMESTAMP if X86_64
103 select HAVE_ACPI_APEI if ACPI 104 select HAVE_ACPI_APEI if ACPI
104 select HAVE_ACPI_APEI_NMI if ACPI 105 select HAVE_ACPI_APEI_NMI if ACPI
105 select HAVE_ALIGNED_STRUCT_PAGE if SLUB 106 select HAVE_ALIGNED_STRUCT_PAGE if SLUB
@@ -163,7 +164,7 @@ config X86
163 select HAVE_PCSPKR_PLATFORM 164 select HAVE_PCSPKR_PLATFORM
164 select HAVE_PERF_EVENTS 165 select HAVE_PERF_EVENTS
165 select HAVE_PERF_EVENTS_NMI 166 select HAVE_PERF_EVENTS_NMI
166 select HAVE_HARDLOCKUP_DETECTOR_PERF if HAVE_PERF_EVENTS_NMI 167 select HAVE_HARDLOCKUP_DETECTOR_PERF if PERF_EVENTS && HAVE_PERF_EVENTS_NMI
167 select HAVE_PERF_REGS 168 select HAVE_PERF_REGS
168 select HAVE_PERF_USER_STACK_DUMP 169 select HAVE_PERF_USER_STACK_DUMP
169 select HAVE_REGS_AND_STACK_ACCESS_API 170 select HAVE_REGS_AND_STACK_ACCESS_API
diff --git a/arch/x86/crypto/sha1_avx2_x86_64_asm.S b/arch/x86/crypto/sha1_avx2_x86_64_asm.S
index 1cd792db15ef..1eab79c9ac48 100644
--- a/arch/x86/crypto/sha1_avx2_x86_64_asm.S
+++ b/arch/x86/crypto/sha1_avx2_x86_64_asm.S
@@ -117,11 +117,10 @@
117 .set T1, REG_T1 117 .set T1, REG_T1
118.endm 118.endm
119 119
120#define K_BASE %r8
121#define HASH_PTR %r9 120#define HASH_PTR %r9
121#define BLOCKS_CTR %r8
122#define BUFFER_PTR %r10 122#define BUFFER_PTR %r10
123#define BUFFER_PTR2 %r13 123#define BUFFER_PTR2 %r13
124#define BUFFER_END %r11
125 124
126#define PRECALC_BUF %r14 125#define PRECALC_BUF %r14
127#define WK_BUF %r15 126#define WK_BUF %r15
@@ -205,14 +204,14 @@
205 * blended AVX2 and ALU instruction scheduling 204 * blended AVX2 and ALU instruction scheduling
206 * 1 vector iteration per 8 rounds 205 * 1 vector iteration per 8 rounds
207 */ 206 */
208 vmovdqu ((i * 2) + PRECALC_OFFSET)(BUFFER_PTR), W_TMP 207 vmovdqu (i * 2)(BUFFER_PTR), W_TMP
209 .elseif ((i & 7) == 1) 208 .elseif ((i & 7) == 1)
210 vinsertf128 $1, (((i-1) * 2)+PRECALC_OFFSET)(BUFFER_PTR2),\ 209 vinsertf128 $1, ((i-1) * 2)(BUFFER_PTR2),\
211 WY_TMP, WY_TMP 210 WY_TMP, WY_TMP
212 .elseif ((i & 7) == 2) 211 .elseif ((i & 7) == 2)
213 vpshufb YMM_SHUFB_BSWAP, WY_TMP, WY 212 vpshufb YMM_SHUFB_BSWAP, WY_TMP, WY
214 .elseif ((i & 7) == 4) 213 .elseif ((i & 7) == 4)
215 vpaddd K_XMM(K_BASE), WY, WY_TMP 214 vpaddd K_XMM + K_XMM_AR(%rip), WY, WY_TMP
216 .elseif ((i & 7) == 7) 215 .elseif ((i & 7) == 7)
217 vmovdqu WY_TMP, PRECALC_WK(i&~7) 216 vmovdqu WY_TMP, PRECALC_WK(i&~7)
218 217
@@ -255,7 +254,7 @@
255 vpxor WY, WY_TMP, WY_TMP 254 vpxor WY, WY_TMP, WY_TMP
256 .elseif ((i & 7) == 7) 255 .elseif ((i & 7) == 7)
257 vpxor WY_TMP2, WY_TMP, WY 256 vpxor WY_TMP2, WY_TMP, WY
258 vpaddd K_XMM(K_BASE), WY, WY_TMP 257 vpaddd K_XMM + K_XMM_AR(%rip), WY, WY_TMP
259 vmovdqu WY_TMP, PRECALC_WK(i&~7) 258 vmovdqu WY_TMP, PRECALC_WK(i&~7)
260 259
261 PRECALC_ROTATE_WY 260 PRECALC_ROTATE_WY
@@ -291,7 +290,7 @@
291 vpsrld $30, WY, WY 290 vpsrld $30, WY, WY
292 vpor WY, WY_TMP, WY 291 vpor WY, WY_TMP, WY
293 .elseif ((i & 7) == 7) 292 .elseif ((i & 7) == 7)
294 vpaddd K_XMM(K_BASE), WY, WY_TMP 293 vpaddd K_XMM + K_XMM_AR(%rip), WY, WY_TMP
295 vmovdqu WY_TMP, PRECALC_WK(i&~7) 294 vmovdqu WY_TMP, PRECALC_WK(i&~7)
296 295
297 PRECALC_ROTATE_WY 296 PRECALC_ROTATE_WY
@@ -446,6 +445,16 @@
446 445
447.endm 446.endm
448 447
448/* Add constant only if (%2 > %3) condition met (uses RTA as temp)
449 * %1 + %2 >= %3 ? %4 : 0
450 */
451.macro ADD_IF_GE a, b, c, d
452 mov \a, RTA
453 add $\d, RTA
454 cmp $\c, \b
455 cmovge RTA, \a
456.endm
457
449/* 458/*
450 * macro implements 80 rounds of SHA-1, for multiple blocks with s/w pipelining 459 * macro implements 80 rounds of SHA-1, for multiple blocks with s/w pipelining
451 */ 460 */
@@ -463,13 +472,16 @@
463 lea (2*4*80+32)(%rsp), WK_BUF 472 lea (2*4*80+32)(%rsp), WK_BUF
464 473
465 # Precalc WK for first 2 blocks 474 # Precalc WK for first 2 blocks
466 PRECALC_OFFSET = 0 475 ADD_IF_GE BUFFER_PTR2, BLOCKS_CTR, 2, 64
467 .set i, 0 476 .set i, 0
468 .rept 160 477 .rept 160
469 PRECALC i 478 PRECALC i
470 .set i, i + 1 479 .set i, i + 1
471 .endr 480 .endr
472 PRECALC_OFFSET = 128 481
482 /* Go to next block if needed */
483 ADD_IF_GE BUFFER_PTR, BLOCKS_CTR, 3, 128
484 ADD_IF_GE BUFFER_PTR2, BLOCKS_CTR, 4, 128
473 xchg WK_BUF, PRECALC_BUF 485 xchg WK_BUF, PRECALC_BUF
474 486
475 .align 32 487 .align 32
@@ -479,8 +491,8 @@ _loop:
479 * we use K_BASE value as a signal of a last block, 491 * we use K_BASE value as a signal of a last block,
480 * it is set below by: cmovae BUFFER_PTR, K_BASE 492 * it is set below by: cmovae BUFFER_PTR, K_BASE
481 */ 493 */
482 cmp K_BASE, BUFFER_PTR 494 test BLOCKS_CTR, BLOCKS_CTR
483 jne _begin 495 jnz _begin
484 .align 32 496 .align 32
485 jmp _end 497 jmp _end
486 .align 32 498 .align 32
@@ -512,10 +524,10 @@ _loop0:
512 .set j, j+2 524 .set j, j+2
513 .endr 525 .endr
514 526
515 add $(2*64), BUFFER_PTR /* move to next odd-64-byte block */ 527 /* Update Counter */
516 cmp BUFFER_END, BUFFER_PTR /* is current block the last one? */ 528 sub $1, BLOCKS_CTR
517 cmovae K_BASE, BUFFER_PTR /* signal the last iteration smartly */ 529 /* Move to the next block only if needed*/
518 530 ADD_IF_GE BUFFER_PTR, BLOCKS_CTR, 4, 128
519 /* 531 /*
520 * rounds 532 * rounds
521 * 60,62,64,66,68 533 * 60,62,64,66,68
@@ -532,8 +544,8 @@ _loop0:
532 UPDATE_HASH 12(HASH_PTR), D 544 UPDATE_HASH 12(HASH_PTR), D
533 UPDATE_HASH 16(HASH_PTR), E 545 UPDATE_HASH 16(HASH_PTR), E
534 546
535 cmp K_BASE, BUFFER_PTR /* is current block the last one? */ 547 test BLOCKS_CTR, BLOCKS_CTR
536 je _loop 548 jz _loop
537 549
538 mov TB, B 550 mov TB, B
539 551
@@ -575,10 +587,10 @@ _loop2:
575 .set j, j+2 587 .set j, j+2
576 .endr 588 .endr
577 589
578 add $(2*64), BUFFER_PTR2 /* move to next even-64-byte block */ 590 /* update counter */
579 591 sub $1, BLOCKS_CTR
580 cmp BUFFER_END, BUFFER_PTR2 /* is current block the last one */ 592 /* Move to the next block only if needed*/
581 cmovae K_BASE, BUFFER_PTR /* signal the last iteration smartly */ 593 ADD_IF_GE BUFFER_PTR2, BLOCKS_CTR, 4, 128
582 594
583 jmp _loop3 595 jmp _loop3
584_loop3: 596_loop3:
@@ -641,19 +653,12 @@ _loop3:
641 653
642 avx2_zeroupper 654 avx2_zeroupper
643 655
644 lea K_XMM_AR(%rip), K_BASE 656 /* Setup initial values */
645
646 mov CTX, HASH_PTR 657 mov CTX, HASH_PTR
647 mov BUF, BUFFER_PTR 658 mov BUF, BUFFER_PTR
648 lea 64(BUF), BUFFER_PTR2
649
650 shl $6, CNT /* mul by 64 */
651 add BUF, CNT
652 add $64, CNT
653 mov CNT, BUFFER_END
654 659
655 cmp BUFFER_END, BUFFER_PTR2 660 mov BUF, BUFFER_PTR2
656 cmovae K_BASE, BUFFER_PTR2 661 mov CNT, BLOCKS_CTR
657 662
658 xmm_mov BSWAP_SHUFB_CTL(%rip), YMM_SHUFB_BSWAP 663 xmm_mov BSWAP_SHUFB_CTL(%rip), YMM_SHUFB_BSWAP
659 664
diff --git a/arch/x86/crypto/sha1_ssse3_glue.c b/arch/x86/crypto/sha1_ssse3_glue.c
index f960a043cdeb..fc61739150e7 100644
--- a/arch/x86/crypto/sha1_ssse3_glue.c
+++ b/arch/x86/crypto/sha1_ssse3_glue.c
@@ -201,7 +201,7 @@ asmlinkage void sha1_transform_avx2(u32 *digest, const char *data,
201 201
202static bool avx2_usable(void) 202static bool avx2_usable(void)
203{ 203{
204 if (false && avx_usable() && boot_cpu_has(X86_FEATURE_AVX2) 204 if (avx_usable() && boot_cpu_has(X86_FEATURE_AVX2)
205 && boot_cpu_has(X86_FEATURE_BMI1) 205 && boot_cpu_has(X86_FEATURE_BMI1)
206 && boot_cpu_has(X86_FEATURE_BMI2)) 206 && boot_cpu_has(X86_FEATURE_BMI2))
207 return true; 207 return true;
diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
index d271fb79248f..6d078b89a5e8 100644
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -1211,6 +1211,8 @@ ENTRY(nmi)
1211 * other IST entries. 1211 * other IST entries.
1212 */ 1212 */
1213 1213
1214 ASM_CLAC
1215
1214 /* Use %rdx as our temp variable throughout */ 1216 /* Use %rdx as our temp variable throughout */
1215 pushq %rdx 1217 pushq %rdx
1216 1218
diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c
index 8e3db8f642a7..af12e294caed 100644
--- a/arch/x86/events/core.c
+++ b/arch/x86/events/core.c
@@ -2114,7 +2114,7 @@ static void refresh_pce(void *ignored)
2114 load_mm_cr4(this_cpu_read(cpu_tlbstate.loaded_mm)); 2114 load_mm_cr4(this_cpu_read(cpu_tlbstate.loaded_mm));
2115} 2115}
2116 2116
2117static void x86_pmu_event_mapped(struct perf_event *event) 2117static void x86_pmu_event_mapped(struct perf_event *event, struct mm_struct *mm)
2118{ 2118{
2119 if (!(event->hw.flags & PERF_X86_EVENT_RDPMC_ALLOWED)) 2119 if (!(event->hw.flags & PERF_X86_EVENT_RDPMC_ALLOWED))
2120 return; 2120 return;
@@ -2129,22 +2129,20 @@ static void x86_pmu_event_mapped(struct perf_event *event)
2129 * For now, this can't happen because all callers hold mmap_sem 2129 * For now, this can't happen because all callers hold mmap_sem
2130 * for write. If this changes, we'll need a different solution. 2130 * for write. If this changes, we'll need a different solution.
2131 */ 2131 */
2132 lockdep_assert_held_exclusive(&current->mm->mmap_sem); 2132 lockdep_assert_held_exclusive(&mm->mmap_sem);
2133 2133
2134 if (atomic_inc_return(&current->mm->context.perf_rdpmc_allowed) == 1) 2134 if (atomic_inc_return(&mm->context.perf_rdpmc_allowed) == 1)
2135 on_each_cpu_mask(mm_cpumask(current->mm), refresh_pce, NULL, 1); 2135 on_each_cpu_mask(mm_cpumask(mm), refresh_pce, NULL, 1);
2136} 2136}
2137 2137
2138static void x86_pmu_event_unmapped(struct perf_event *event) 2138static void x86_pmu_event_unmapped(struct perf_event *event, struct mm_struct *mm)
2139{ 2139{
2140 if (!current->mm)
2141 return;
2142 2140
2143 if (!(event->hw.flags & PERF_X86_EVENT_RDPMC_ALLOWED)) 2141 if (!(event->hw.flags & PERF_X86_EVENT_RDPMC_ALLOWED))
2144 return; 2142 return;
2145 2143
2146 if (atomic_dec_and_test(&current->mm->context.perf_rdpmc_allowed)) 2144 if (atomic_dec_and_test(&mm->context.perf_rdpmc_allowed))
2147 on_each_cpu_mask(mm_cpumask(current->mm), refresh_pce, NULL, 1); 2145 on_each_cpu_mask(mm_cpumask(mm), refresh_pce, NULL, 1);
2148} 2146}
2149 2147
2150static int x86_pmu_event_idx(struct perf_event *event) 2148static int x86_pmu_event_idx(struct perf_event *event)
diff --git a/arch/x86/events/intel/bts.c b/arch/x86/events/intel/bts.c
index 8ae8c5ce3a1f..ddd8d3516bfc 100644
--- a/arch/x86/events/intel/bts.c
+++ b/arch/x86/events/intel/bts.c
@@ -69,7 +69,7 @@ struct bts_buffer {
69 struct bts_phys buf[0]; 69 struct bts_phys buf[0];
70}; 70};
71 71
72struct pmu bts_pmu; 72static struct pmu bts_pmu;
73 73
74static size_t buf_size(struct page *page) 74static size_t buf_size(struct page *page)
75{ 75{
diff --git a/arch/x86/events/intel/p4.c b/arch/x86/events/intel/p4.c
index eb0533558c2b..d32c0eed38ca 100644
--- a/arch/x86/events/intel/p4.c
+++ b/arch/x86/events/intel/p4.c
@@ -587,7 +587,7 @@ static __initconst const u64 p4_hw_cache_event_ids
587 * P4_CONFIG_ALIASABLE or bits for P4_PEBS_METRIC, they are 587 * P4_CONFIG_ALIASABLE or bits for P4_PEBS_METRIC, they are
588 * either up to date automatically or not applicable at all. 588 * either up to date automatically or not applicable at all.
589 */ 589 */
590struct p4_event_alias { 590static struct p4_event_alias {
591 u64 original; 591 u64 original;
592 u64 alternative; 592 u64 alternative;
593} p4_event_aliases[] = { 593} p4_event_aliases[] = {
diff --git a/arch/x86/events/intel/rapl.c b/arch/x86/events/intel/rapl.c
index a45e2114a846..8e2457cb6b4a 100644
--- a/arch/x86/events/intel/rapl.c
+++ b/arch/x86/events/intel/rapl.c
@@ -559,7 +559,7 @@ static struct attribute_group rapl_pmu_format_group = {
559 .attrs = rapl_formats_attr, 559 .attrs = rapl_formats_attr,
560}; 560};
561 561
562const struct attribute_group *rapl_attr_groups[] = { 562static const struct attribute_group *rapl_attr_groups[] = {
563 &rapl_pmu_attr_group, 563 &rapl_pmu_attr_group,
564 &rapl_pmu_format_group, 564 &rapl_pmu_format_group,
565 &rapl_pmu_events_group, 565 &rapl_pmu_events_group,
diff --git a/arch/x86/events/intel/uncore.c b/arch/x86/events/intel/uncore.c
index 44ec523287f6..1c5390f1cf09 100644
--- a/arch/x86/events/intel/uncore.c
+++ b/arch/x86/events/intel/uncore.c
@@ -721,7 +721,7 @@ static struct attribute *uncore_pmu_attrs[] = {
721 NULL, 721 NULL,
722}; 722};
723 723
724static struct attribute_group uncore_pmu_attr_group = { 724static const struct attribute_group uncore_pmu_attr_group = {
725 .attrs = uncore_pmu_attrs, 725 .attrs = uncore_pmu_attrs,
726}; 726};
727 727
diff --git a/arch/x86/events/intel/uncore_nhmex.c b/arch/x86/events/intel/uncore_nhmex.c
index cda569332005..6a5cbe90f859 100644
--- a/arch/x86/events/intel/uncore_nhmex.c
+++ b/arch/x86/events/intel/uncore_nhmex.c
@@ -272,7 +272,7 @@ static struct attribute *nhmex_uncore_ubox_formats_attr[] = {
272 NULL, 272 NULL,
273}; 273};
274 274
275static struct attribute_group nhmex_uncore_ubox_format_group = { 275static const struct attribute_group nhmex_uncore_ubox_format_group = {
276 .name = "format", 276 .name = "format",
277 .attrs = nhmex_uncore_ubox_formats_attr, 277 .attrs = nhmex_uncore_ubox_formats_attr,
278}; 278};
@@ -299,7 +299,7 @@ static struct attribute *nhmex_uncore_cbox_formats_attr[] = {
299 NULL, 299 NULL,
300}; 300};
301 301
302static struct attribute_group nhmex_uncore_cbox_format_group = { 302static const struct attribute_group nhmex_uncore_cbox_format_group = {
303 .name = "format", 303 .name = "format",
304 .attrs = nhmex_uncore_cbox_formats_attr, 304 .attrs = nhmex_uncore_cbox_formats_attr,
305}; 305};
@@ -407,7 +407,7 @@ static struct attribute *nhmex_uncore_bbox_formats_attr[] = {
407 NULL, 407 NULL,
408}; 408};
409 409
410static struct attribute_group nhmex_uncore_bbox_format_group = { 410static const struct attribute_group nhmex_uncore_bbox_format_group = {
411 .name = "format", 411 .name = "format",
412 .attrs = nhmex_uncore_bbox_formats_attr, 412 .attrs = nhmex_uncore_bbox_formats_attr,
413}; 413};
@@ -484,7 +484,7 @@ static struct attribute *nhmex_uncore_sbox_formats_attr[] = {
484 NULL, 484 NULL,
485}; 485};
486 486
487static struct attribute_group nhmex_uncore_sbox_format_group = { 487static const struct attribute_group nhmex_uncore_sbox_format_group = {
488 .name = "format", 488 .name = "format",
489 .attrs = nhmex_uncore_sbox_formats_attr, 489 .attrs = nhmex_uncore_sbox_formats_attr,
490}; 490};
@@ -898,7 +898,7 @@ static struct attribute *nhmex_uncore_mbox_formats_attr[] = {
898 NULL, 898 NULL,
899}; 899};
900 900
901static struct attribute_group nhmex_uncore_mbox_format_group = { 901static const struct attribute_group nhmex_uncore_mbox_format_group = {
902 .name = "format", 902 .name = "format",
903 .attrs = nhmex_uncore_mbox_formats_attr, 903 .attrs = nhmex_uncore_mbox_formats_attr,
904}; 904};
@@ -1163,7 +1163,7 @@ static struct attribute *nhmex_uncore_rbox_formats_attr[] = {
1163 NULL, 1163 NULL,
1164}; 1164};
1165 1165
1166static struct attribute_group nhmex_uncore_rbox_format_group = { 1166static const struct attribute_group nhmex_uncore_rbox_format_group = {
1167 .name = "format", 1167 .name = "format",
1168 .attrs = nhmex_uncore_rbox_formats_attr, 1168 .attrs = nhmex_uncore_rbox_formats_attr,
1169}; 1169};
diff --git a/arch/x86/events/intel/uncore_snb.c b/arch/x86/events/intel/uncore_snb.c
index a3dcc12bef4a..db1127ce685e 100644
--- a/arch/x86/events/intel/uncore_snb.c
+++ b/arch/x86/events/intel/uncore_snb.c
@@ -130,7 +130,7 @@ static struct attribute *snb_uncore_formats_attr[] = {
130 NULL, 130 NULL,
131}; 131};
132 132
133static struct attribute_group snb_uncore_format_group = { 133static const struct attribute_group snb_uncore_format_group = {
134 .name = "format", 134 .name = "format",
135 .attrs = snb_uncore_formats_attr, 135 .attrs = snb_uncore_formats_attr,
136}; 136};
@@ -289,7 +289,7 @@ static struct attribute *snb_uncore_imc_formats_attr[] = {
289 NULL, 289 NULL,
290}; 290};
291 291
292static struct attribute_group snb_uncore_imc_format_group = { 292static const struct attribute_group snb_uncore_imc_format_group = {
293 .name = "format", 293 .name = "format",
294 .attrs = snb_uncore_imc_formats_attr, 294 .attrs = snb_uncore_imc_formats_attr,
295}; 295};
@@ -769,7 +769,7 @@ static struct attribute *nhm_uncore_formats_attr[] = {
769 NULL, 769 NULL,
770}; 770};
771 771
772static struct attribute_group nhm_uncore_format_group = { 772static const struct attribute_group nhm_uncore_format_group = {
773 .name = "format", 773 .name = "format",
774 .attrs = nhm_uncore_formats_attr, 774 .attrs = nhm_uncore_formats_attr,
775}; 775};
diff --git a/arch/x86/events/intel/uncore_snbep.c b/arch/x86/events/intel/uncore_snbep.c
index 4f9127644b80..db1fe377e6dd 100644
--- a/arch/x86/events/intel/uncore_snbep.c
+++ b/arch/x86/events/intel/uncore_snbep.c
@@ -602,27 +602,27 @@ static struct uncore_event_desc snbep_uncore_qpi_events[] = {
602 { /* end: all zeroes */ }, 602 { /* end: all zeroes */ },
603}; 603};
604 604
605static struct attribute_group snbep_uncore_format_group = { 605static const struct attribute_group snbep_uncore_format_group = {
606 .name = "format", 606 .name = "format",
607 .attrs = snbep_uncore_formats_attr, 607 .attrs = snbep_uncore_formats_attr,
608}; 608};
609 609
610static struct attribute_group snbep_uncore_ubox_format_group = { 610static const struct attribute_group snbep_uncore_ubox_format_group = {
611 .name = "format", 611 .name = "format",
612 .attrs = snbep_uncore_ubox_formats_attr, 612 .attrs = snbep_uncore_ubox_formats_attr,
613}; 613};
614 614
615static struct attribute_group snbep_uncore_cbox_format_group = { 615static const struct attribute_group snbep_uncore_cbox_format_group = {
616 .name = "format", 616 .name = "format",
617 .attrs = snbep_uncore_cbox_formats_attr, 617 .attrs = snbep_uncore_cbox_formats_attr,
618}; 618};
619 619
620static struct attribute_group snbep_uncore_pcu_format_group = { 620static const struct attribute_group snbep_uncore_pcu_format_group = {
621 .name = "format", 621 .name = "format",
622 .attrs = snbep_uncore_pcu_formats_attr, 622 .attrs = snbep_uncore_pcu_formats_attr,
623}; 623};
624 624
625static struct attribute_group snbep_uncore_qpi_format_group = { 625static const struct attribute_group snbep_uncore_qpi_format_group = {
626 .name = "format", 626 .name = "format",
627 .attrs = snbep_uncore_qpi_formats_attr, 627 .attrs = snbep_uncore_qpi_formats_attr,
628}; 628};
@@ -1431,27 +1431,27 @@ static struct attribute *ivbep_uncore_qpi_formats_attr[] = {
1431 NULL, 1431 NULL,
1432}; 1432};
1433 1433
1434static struct attribute_group ivbep_uncore_format_group = { 1434static const struct attribute_group ivbep_uncore_format_group = {
1435 .name = "format", 1435 .name = "format",
1436 .attrs = ivbep_uncore_formats_attr, 1436 .attrs = ivbep_uncore_formats_attr,
1437}; 1437};
1438 1438
1439static struct attribute_group ivbep_uncore_ubox_format_group = { 1439static const struct attribute_group ivbep_uncore_ubox_format_group = {
1440 .name = "format", 1440 .name = "format",
1441 .attrs = ivbep_uncore_ubox_formats_attr, 1441 .attrs = ivbep_uncore_ubox_formats_attr,
1442}; 1442};
1443 1443
1444static struct attribute_group ivbep_uncore_cbox_format_group = { 1444static const struct attribute_group ivbep_uncore_cbox_format_group = {
1445 .name = "format", 1445 .name = "format",
1446 .attrs = ivbep_uncore_cbox_formats_attr, 1446 .attrs = ivbep_uncore_cbox_formats_attr,
1447}; 1447};
1448 1448
1449static struct attribute_group ivbep_uncore_pcu_format_group = { 1449static const struct attribute_group ivbep_uncore_pcu_format_group = {
1450 .name = "format", 1450 .name = "format",
1451 .attrs = ivbep_uncore_pcu_formats_attr, 1451 .attrs = ivbep_uncore_pcu_formats_attr,
1452}; 1452};
1453 1453
1454static struct attribute_group ivbep_uncore_qpi_format_group = { 1454static const struct attribute_group ivbep_uncore_qpi_format_group = {
1455 .name = "format", 1455 .name = "format",
1456 .attrs = ivbep_uncore_qpi_formats_attr, 1456 .attrs = ivbep_uncore_qpi_formats_attr,
1457}; 1457};
@@ -1887,7 +1887,7 @@ static struct attribute *knl_uncore_ubox_formats_attr[] = {
1887 NULL, 1887 NULL,
1888}; 1888};
1889 1889
1890static struct attribute_group knl_uncore_ubox_format_group = { 1890static const struct attribute_group knl_uncore_ubox_format_group = {
1891 .name = "format", 1891 .name = "format",
1892 .attrs = knl_uncore_ubox_formats_attr, 1892 .attrs = knl_uncore_ubox_formats_attr,
1893}; 1893};
@@ -1927,7 +1927,7 @@ static struct attribute *knl_uncore_cha_formats_attr[] = {
1927 NULL, 1927 NULL,
1928}; 1928};
1929 1929
1930static struct attribute_group knl_uncore_cha_format_group = { 1930static const struct attribute_group knl_uncore_cha_format_group = {
1931 .name = "format", 1931 .name = "format",
1932 .attrs = knl_uncore_cha_formats_attr, 1932 .attrs = knl_uncore_cha_formats_attr,
1933}; 1933};
@@ -2037,7 +2037,7 @@ static struct attribute *knl_uncore_pcu_formats_attr[] = {
2037 NULL, 2037 NULL,
2038}; 2038};
2039 2039
2040static struct attribute_group knl_uncore_pcu_format_group = { 2040static const struct attribute_group knl_uncore_pcu_format_group = {
2041 .name = "format", 2041 .name = "format",
2042 .attrs = knl_uncore_pcu_formats_attr, 2042 .attrs = knl_uncore_pcu_formats_attr,
2043}; 2043};
@@ -2187,7 +2187,7 @@ static struct attribute *knl_uncore_irp_formats_attr[] = {
2187 NULL, 2187 NULL,
2188}; 2188};
2189 2189
2190static struct attribute_group knl_uncore_irp_format_group = { 2190static const struct attribute_group knl_uncore_irp_format_group = {
2191 .name = "format", 2191 .name = "format",
2192 .attrs = knl_uncore_irp_formats_attr, 2192 .attrs = knl_uncore_irp_formats_attr,
2193}; 2193};
@@ -2385,7 +2385,7 @@ static struct attribute *hswep_uncore_ubox_formats_attr[] = {
2385 NULL, 2385 NULL,
2386}; 2386};
2387 2387
2388static struct attribute_group hswep_uncore_ubox_format_group = { 2388static const struct attribute_group hswep_uncore_ubox_format_group = {
2389 .name = "format", 2389 .name = "format",
2390 .attrs = hswep_uncore_ubox_formats_attr, 2390 .attrs = hswep_uncore_ubox_formats_attr,
2391}; 2391};
@@ -2439,7 +2439,7 @@ static struct attribute *hswep_uncore_cbox_formats_attr[] = {
2439 NULL, 2439 NULL,
2440}; 2440};
2441 2441
2442static struct attribute_group hswep_uncore_cbox_format_group = { 2442static const struct attribute_group hswep_uncore_cbox_format_group = {
2443 .name = "format", 2443 .name = "format",
2444 .attrs = hswep_uncore_cbox_formats_attr, 2444 .attrs = hswep_uncore_cbox_formats_attr,
2445}; 2445};
@@ -2621,7 +2621,7 @@ static struct attribute *hswep_uncore_sbox_formats_attr[] = {
2621 NULL, 2621 NULL,
2622}; 2622};
2623 2623
2624static struct attribute_group hswep_uncore_sbox_format_group = { 2624static const struct attribute_group hswep_uncore_sbox_format_group = {
2625 .name = "format", 2625 .name = "format",
2626 .attrs = hswep_uncore_sbox_formats_attr, 2626 .attrs = hswep_uncore_sbox_formats_attr,
2627}; 2627};
@@ -3314,7 +3314,7 @@ static struct attribute *skx_uncore_cha_formats_attr[] = {
3314 NULL, 3314 NULL,
3315}; 3315};
3316 3316
3317static struct attribute_group skx_uncore_chabox_format_group = { 3317static const struct attribute_group skx_uncore_chabox_format_group = {
3318 .name = "format", 3318 .name = "format",
3319 .attrs = skx_uncore_cha_formats_attr, 3319 .attrs = skx_uncore_cha_formats_attr,
3320}; 3320};
@@ -3427,7 +3427,7 @@ static struct attribute *skx_uncore_iio_formats_attr[] = {
3427 NULL, 3427 NULL,
3428}; 3428};
3429 3429
3430static struct attribute_group skx_uncore_iio_format_group = { 3430static const struct attribute_group skx_uncore_iio_format_group = {
3431 .name = "format", 3431 .name = "format",
3432 .attrs = skx_uncore_iio_formats_attr, 3432 .attrs = skx_uncore_iio_formats_attr,
3433}; 3433};
@@ -3484,7 +3484,7 @@ static struct attribute *skx_uncore_formats_attr[] = {
3484 NULL, 3484 NULL,
3485}; 3485};
3486 3486
3487static struct attribute_group skx_uncore_format_group = { 3487static const struct attribute_group skx_uncore_format_group = {
3488 .name = "format", 3488 .name = "format",
3489 .attrs = skx_uncore_formats_attr, 3489 .attrs = skx_uncore_formats_attr,
3490}; 3490};
@@ -3605,7 +3605,7 @@ static struct attribute *skx_upi_uncore_formats_attr[] = {
3605 NULL, 3605 NULL,
3606}; 3606};
3607 3607
3608static struct attribute_group skx_upi_uncore_format_group = { 3608static const struct attribute_group skx_upi_uncore_format_group = {
3609 .name = "format", 3609 .name = "format",
3610 .attrs = skx_upi_uncore_formats_attr, 3610 .attrs = skx_upi_uncore_formats_attr,
3611}; 3611};
diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h
index ca3c48c0872f..5a28e8e55e36 100644
--- a/arch/x86/include/asm/cpufeatures.h
+++ b/arch/x86/include/asm/cpufeatures.h
@@ -286,7 +286,7 @@
286#define X86_FEATURE_PAUSEFILTER (15*32+10) /* filtered pause intercept */ 286#define X86_FEATURE_PAUSEFILTER (15*32+10) /* filtered pause intercept */
287#define X86_FEATURE_PFTHRESHOLD (15*32+12) /* pause filter threshold */ 287#define X86_FEATURE_PFTHRESHOLD (15*32+12) /* pause filter threshold */
288#define X86_FEATURE_AVIC (15*32+13) /* Virtual Interrupt Controller */ 288#define X86_FEATURE_AVIC (15*32+13) /* Virtual Interrupt Controller */
289#define X86_FEATURE_VIRTUAL_VMLOAD_VMSAVE (15*32+15) /* Virtual VMLOAD VMSAVE */ 289#define X86_FEATURE_V_VMSAVE_VMLOAD (15*32+15) /* Virtual VMSAVE VMLOAD */
290 290
291/* Intel-defined CPU features, CPUID level 0x00000007:0 (ecx), word 16 */ 291/* Intel-defined CPU features, CPUID level 0x00000007:0 (ecx), word 16 */
292#define X86_FEATURE_AVX512VBMI (16*32+ 1) /* AVX512 Vector Bit Manipulation instructions*/ 292#define X86_FEATURE_AVX512VBMI (16*32+ 1) /* AVX512 Vector Bit Manipulation instructions*/
diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
index 1c18d83d3f09..9aeb91935ce0 100644
--- a/arch/x86/include/asm/elf.h
+++ b/arch/x86/include/asm/elf.h
@@ -247,11 +247,11 @@ extern int force_personality32;
247 247
248/* 248/*
249 * This is the base location for PIE (ET_DYN with INTERP) loads. On 249 * This is the base location for PIE (ET_DYN with INTERP) loads. On
250 * 64-bit, this is raised to 4GB to leave the entire 32-bit address 250 * 64-bit, this is above 4GB to leave the entire 32-bit address
251 * space open for things that want to use the area for 32-bit pointers. 251 * space open for things that want to use the area for 32-bit pointers.
252 */ 252 */
253#define ELF_ET_DYN_BASE (mmap_is_ia32() ? 0x000400000UL : \ 253#define ELF_ET_DYN_BASE (mmap_is_ia32() ? 0x000400000UL : \
254 0x100000000UL) 254 (TASK_SIZE / 3 * 2))
255 255
256/* This yields a mask that user programs can use to figure out what 256/* This yields a mask that user programs can use to figure out what
257 instruction set this CPU supports. This could be done in user space, 257 instruction set this CPU supports. This could be done in user space,
diff --git a/arch/x86/kernel/cpu/aperfmperf.c b/arch/x86/kernel/cpu/aperfmperf.c
index 7cf7c70b6ef2..0ee83321a313 100644
--- a/arch/x86/kernel/cpu/aperfmperf.c
+++ b/arch/x86/kernel/cpu/aperfmperf.c
@@ -40,13 +40,16 @@ static void aperfmperf_snapshot_khz(void *dummy)
40 struct aperfmperf_sample *s = this_cpu_ptr(&samples); 40 struct aperfmperf_sample *s = this_cpu_ptr(&samples);
41 ktime_t now = ktime_get(); 41 ktime_t now = ktime_get();
42 s64 time_delta = ktime_ms_delta(now, s->time); 42 s64 time_delta = ktime_ms_delta(now, s->time);
43 unsigned long flags;
43 44
44 /* Don't bother re-computing within the cache threshold time. */ 45 /* Don't bother re-computing within the cache threshold time. */
45 if (time_delta < APERFMPERF_CACHE_THRESHOLD_MS) 46 if (time_delta < APERFMPERF_CACHE_THRESHOLD_MS)
46 return; 47 return;
47 48
49 local_irq_save(flags);
48 rdmsrl(MSR_IA32_APERF, aperf); 50 rdmsrl(MSR_IA32_APERF, aperf);
49 rdmsrl(MSR_IA32_MPERF, mperf); 51 rdmsrl(MSR_IA32_MPERF, mperf);
52 local_irq_restore(flags);
50 53
51 aperf_delta = aperf - s->aperf; 54 aperf_delta = aperf - s->aperf;
52 mperf_delta = mperf - s->mperf; 55 mperf_delta = mperf - s->mperf;
diff --git a/arch/x86/kernel/cpu/mcheck/therm_throt.c b/arch/x86/kernel/cpu/mcheck/therm_throt.c
index d7cc190ae457..f7370abd33c6 100644
--- a/arch/x86/kernel/cpu/mcheck/therm_throt.c
+++ b/arch/x86/kernel/cpu/mcheck/therm_throt.c
@@ -122,7 +122,7 @@ static struct attribute *thermal_throttle_attrs[] = {
122 NULL 122 NULL
123}; 123};
124 124
125static struct attribute_group thermal_attr_group = { 125static const struct attribute_group thermal_attr_group = {
126 .attrs = thermal_throttle_attrs, 126 .attrs = thermal_throttle_attrs,
127 .name = "thermal_throttle" 127 .name = "thermal_throttle"
128}; 128};
diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c
index 9cb98ee103db..86e8f0b2537b 100644
--- a/arch/x86/kernel/cpu/microcode/core.c
+++ b/arch/x86/kernel/cpu/microcode/core.c
@@ -561,7 +561,7 @@ static struct attribute *mc_default_attrs[] = {
561 NULL 561 NULL
562}; 562};
563 563
564static struct attribute_group mc_attr_group = { 564static const struct attribute_group mc_attr_group = {
565 .attrs = mc_default_attrs, 565 .attrs = mc_default_attrs,
566 .name = "microcode", 566 .name = "microcode",
567}; 567};
@@ -707,7 +707,7 @@ static struct attribute *cpu_root_microcode_attrs[] = {
707 NULL 707 NULL
708}; 708};
709 709
710static struct attribute_group cpu_root_microcode_group = { 710static const struct attribute_group cpu_root_microcode_group = {
711 .name = "microcode", 711 .name = "microcode",
712 .attrs = cpu_root_microcode_attrs, 712 .attrs = cpu_root_microcode_attrs,
713}; 713};
diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
index c5bb63be4ba1..40d5a8a75212 100644
--- a/arch/x86/kernel/cpu/mtrr/main.c
+++ b/arch/x86/kernel/cpu/mtrr/main.c
@@ -237,6 +237,18 @@ set_mtrr(unsigned int reg, unsigned long base, unsigned long size, mtrr_type typ
237 stop_machine(mtrr_rendezvous_handler, &data, cpu_online_mask); 237 stop_machine(mtrr_rendezvous_handler, &data, cpu_online_mask);
238} 238}
239 239
240static void set_mtrr_cpuslocked(unsigned int reg, unsigned long base,
241 unsigned long size, mtrr_type type)
242{
243 struct set_mtrr_data data = { .smp_reg = reg,
244 .smp_base = base,
245 .smp_size = size,
246 .smp_type = type
247 };
248
249 stop_machine_cpuslocked(mtrr_rendezvous_handler, &data, cpu_online_mask);
250}
251
240static void set_mtrr_from_inactive_cpu(unsigned int reg, unsigned long base, 252static void set_mtrr_from_inactive_cpu(unsigned int reg, unsigned long base,
241 unsigned long size, mtrr_type type) 253 unsigned long size, mtrr_type type)
242{ 254{
@@ -370,7 +382,7 @@ int mtrr_add_page(unsigned long base, unsigned long size,
370 /* Search for an empty MTRR */ 382 /* Search for an empty MTRR */
371 i = mtrr_if->get_free_region(base, size, replace); 383 i = mtrr_if->get_free_region(base, size, replace);
372 if (i >= 0) { 384 if (i >= 0) {
373 set_mtrr(i, base, size, type); 385 set_mtrr_cpuslocked(i, base, size, type);
374 if (likely(replace < 0)) { 386 if (likely(replace < 0)) {
375 mtrr_usage_table[i] = 1; 387 mtrr_usage_table[i] = 1;
376 } else { 388 } else {
@@ -378,7 +390,7 @@ int mtrr_add_page(unsigned long base, unsigned long size,
378 if (increment) 390 if (increment)
379 mtrr_usage_table[i]++; 391 mtrr_usage_table[i]++;
380 if (unlikely(replace != i)) { 392 if (unlikely(replace != i)) {
381 set_mtrr(replace, 0, 0, 0); 393 set_mtrr_cpuslocked(replace, 0, 0, 0);
382 mtrr_usage_table[replace] = 0; 394 mtrr_usage_table[replace] = 0;
383 } 395 }
384 } 396 }
@@ -506,7 +518,7 @@ int mtrr_del_page(int reg, unsigned long base, unsigned long size)
506 goto out; 518 goto out;
507 } 519 }
508 if (--mtrr_usage_table[reg] < 1) 520 if (--mtrr_usage_table[reg] < 1)
509 set_mtrr(reg, 0, 0, 0); 521 set_mtrr_cpuslocked(reg, 0, 0, 0);
510 error = reg; 522 error = reg;
511 out: 523 out:
512 mutex_unlock(&mtrr_mutex); 524 mutex_unlock(&mtrr_mutex);
diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
index 46c3c73e7f43..9ba79543d9ee 100644
--- a/arch/x86/kernel/head64.c
+++ b/arch/x86/kernel/head64.c
@@ -53,6 +53,7 @@ void __head __startup_64(unsigned long physaddr)
53 pudval_t *pud; 53 pudval_t *pud;
54 pmdval_t *pmd, pmd_entry; 54 pmdval_t *pmd, pmd_entry;
55 int i; 55 int i;
56 unsigned int *next_pgt_ptr;
56 57
57 /* Is the address too large? */ 58 /* Is the address too large? */
58 if (physaddr >> MAX_PHYSMEM_BITS) 59 if (physaddr >> MAX_PHYSMEM_BITS)
@@ -91,9 +92,9 @@ void __head __startup_64(unsigned long physaddr)
91 * creates a bunch of nonsense entries but that is fine -- 92 * creates a bunch of nonsense entries but that is fine --
92 * it avoids problems around wraparound. 93 * it avoids problems around wraparound.
93 */ 94 */
94 95 next_pgt_ptr = fixup_pointer(&next_early_pgt, physaddr);
95 pud = fixup_pointer(early_dynamic_pgts[next_early_pgt++], physaddr); 96 pud = fixup_pointer(early_dynamic_pgts[(*next_pgt_ptr)++], physaddr);
96 pmd = fixup_pointer(early_dynamic_pgts[next_early_pgt++], physaddr); 97 pmd = fixup_pointer(early_dynamic_pgts[(*next_pgt_ptr)++], physaddr);
97 98
98 if (IS_ENABLED(CONFIG_X86_5LEVEL)) { 99 if (IS_ENABLED(CONFIG_X86_5LEVEL)) {
99 p4d = fixup_pointer(early_dynamic_pgts[next_early_pgt++], physaddr); 100 p4d = fixup_pointer(early_dynamic_pgts[next_early_pgt++], physaddr);
diff --git a/arch/x86/kernel/ksysfs.c b/arch/x86/kernel/ksysfs.c
index 4afc67f5facc..06e1ff5562c0 100644
--- a/arch/x86/kernel/ksysfs.c
+++ b/arch/x86/kernel/ksysfs.c
@@ -55,7 +55,7 @@ static struct bin_attribute *boot_params_data_attrs[] = {
55 NULL, 55 NULL,
56}; 56};
57 57
58static struct attribute_group boot_params_attr_group = { 58static const struct attribute_group boot_params_attr_group = {
59 .attrs = boot_params_version_attrs, 59 .attrs = boot_params_version_attrs,
60 .bin_attrs = boot_params_data_attrs, 60 .bin_attrs = boot_params_data_attrs,
61}; 61};
@@ -202,7 +202,7 @@ static struct bin_attribute *setup_data_data_attrs[] = {
202 NULL, 202 NULL,
203}; 203};
204 204
205static struct attribute_group setup_data_attr_group = { 205static const struct attribute_group setup_data_attr_group = {
206 .attrs = setup_data_type_attrs, 206 .attrs = setup_data_type_attrs,
207 .bin_attrs = setup_data_data_attrs, 207 .bin_attrs = setup_data_data_attrs,
208}; 208};
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index b474c8de7fba..54b9e89d4d6b 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -971,7 +971,8 @@ void common_cpu_up(unsigned int cpu, struct task_struct *idle)
971 * Returns zero if CPU booted OK, else error code from 971 * Returns zero if CPU booted OK, else error code from
972 * ->wakeup_secondary_cpu. 972 * ->wakeup_secondary_cpu.
973 */ 973 */
974static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle) 974static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle,
975 int *cpu0_nmi_registered)
975{ 976{
976 volatile u32 *trampoline_status = 977 volatile u32 *trampoline_status =
977 (volatile u32 *) __va(real_mode_header->trampoline_status); 978 (volatile u32 *) __va(real_mode_header->trampoline_status);
@@ -979,7 +980,6 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
979 unsigned long start_ip = real_mode_header->trampoline_start; 980 unsigned long start_ip = real_mode_header->trampoline_start;
980 981
981 unsigned long boot_error = 0; 982 unsigned long boot_error = 0;
982 int cpu0_nmi_registered = 0;
983 unsigned long timeout; 983 unsigned long timeout;
984 984
985 idle->thread.sp = (unsigned long)task_pt_regs(idle); 985 idle->thread.sp = (unsigned long)task_pt_regs(idle);
@@ -1035,7 +1035,7 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
1035 boot_error = apic->wakeup_secondary_cpu(apicid, start_ip); 1035 boot_error = apic->wakeup_secondary_cpu(apicid, start_ip);
1036 else 1036 else
1037 boot_error = wakeup_cpu_via_init_nmi(cpu, start_ip, apicid, 1037 boot_error = wakeup_cpu_via_init_nmi(cpu, start_ip, apicid,
1038 &cpu0_nmi_registered); 1038 cpu0_nmi_registered);
1039 1039
1040 if (!boot_error) { 1040 if (!boot_error) {
1041 /* 1041 /*
@@ -1080,12 +1080,6 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
1080 */ 1080 */
1081 smpboot_restore_warm_reset_vector(); 1081 smpboot_restore_warm_reset_vector();
1082 } 1082 }
1083 /*
1084 * Clean up the nmi handler. Do this after the callin and callout sync
1085 * to avoid impact of possible long unregister time.
1086 */
1087 if (cpu0_nmi_registered)
1088 unregister_nmi_handler(NMI_LOCAL, "wake_cpu0");
1089 1083
1090 return boot_error; 1084 return boot_error;
1091} 1085}
@@ -1093,8 +1087,9 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
1093int native_cpu_up(unsigned int cpu, struct task_struct *tidle) 1087int native_cpu_up(unsigned int cpu, struct task_struct *tidle)
1094{ 1088{
1095 int apicid = apic->cpu_present_to_apicid(cpu); 1089 int apicid = apic->cpu_present_to_apicid(cpu);
1090 int cpu0_nmi_registered = 0;
1096 unsigned long flags; 1091 unsigned long flags;
1097 int err; 1092 int err, ret = 0;
1098 1093
1099 WARN_ON(irqs_disabled()); 1094 WARN_ON(irqs_disabled());
1100 1095
@@ -1131,10 +1126,11 @@ int native_cpu_up(unsigned int cpu, struct task_struct *tidle)
1131 1126
1132 common_cpu_up(cpu, tidle); 1127 common_cpu_up(cpu, tidle);
1133 1128
1134 err = do_boot_cpu(apicid, cpu, tidle); 1129 err = do_boot_cpu(apicid, cpu, tidle, &cpu0_nmi_registered);
1135 if (err) { 1130 if (err) {
1136 pr_err("do_boot_cpu failed(%d) to wakeup CPU#%u\n", err, cpu); 1131 pr_err("do_boot_cpu failed(%d) to wakeup CPU#%u\n", err, cpu);
1137 return -EIO; 1132 ret = -EIO;
1133 goto unreg_nmi;
1138 } 1134 }
1139 1135
1140 /* 1136 /*
@@ -1150,7 +1146,15 @@ int native_cpu_up(unsigned int cpu, struct task_struct *tidle)
1150 touch_nmi_watchdog(); 1146 touch_nmi_watchdog();
1151 } 1147 }
1152 1148
1153 return 0; 1149unreg_nmi:
1150 /*
1151 * Clean up the nmi handler. Do this after the callin and callout sync
1152 * to avoid impact of possible long unregister time.
1153 */
1154 if (cpu0_nmi_registered)
1155 unregister_nmi_handler(NMI_LOCAL, "wake_cpu0");
1156
1157 return ret;
1154} 1158}
1155 1159
1156/** 1160/**
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 1107626938cc..56ba05312759 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -1100,7 +1100,7 @@ static __init int svm_hardware_setup(void)
1100 1100
1101 if (vls) { 1101 if (vls) {
1102 if (!npt_enabled || 1102 if (!npt_enabled ||
1103 !boot_cpu_has(X86_FEATURE_VIRTUAL_VMLOAD_VMSAVE) || 1103 !boot_cpu_has(X86_FEATURE_V_VMSAVE_VMLOAD) ||
1104 !IS_ENABLED(CONFIG_X86_64)) { 1104 !IS_ENABLED(CONFIG_X86_64)) {
1105 vls = false; 1105 vls = false;
1106 } else { 1106 } else {
diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
index 229d04a83f85..a88cfbfbd078 100644
--- a/arch/x86/mm/mmap.c
+++ b/arch/x86/mm/mmap.c
@@ -50,8 +50,7 @@ unsigned long tasksize_64bit(void)
50static unsigned long stack_maxrandom_size(unsigned long task_size) 50static unsigned long stack_maxrandom_size(unsigned long task_size)
51{ 51{
52 unsigned long max = 0; 52 unsigned long max = 0;
53 if ((current->flags & PF_RANDOMIZE) && 53 if (current->flags & PF_RANDOMIZE) {
54 !(current->personality & ADDR_NO_RANDOMIZE)) {
55 max = (-1UL) & __STACK_RND_MASK(task_size == tasksize_32bit()); 54 max = (-1UL) & __STACK_RND_MASK(task_size == tasksize_32bit());
56 max <<= PAGE_SHIFT; 55 max <<= PAGE_SHIFT;
57 } 56 }
@@ -79,13 +78,13 @@ static int mmap_is_legacy(void)
79 78
80static unsigned long arch_rnd(unsigned int rndbits) 79static unsigned long arch_rnd(unsigned int rndbits)
81{ 80{
81 if (!(current->flags & PF_RANDOMIZE))
82 return 0;
82 return (get_random_long() & ((1UL << rndbits) - 1)) << PAGE_SHIFT; 83 return (get_random_long() & ((1UL << rndbits) - 1)) << PAGE_SHIFT;
83} 84}
84 85
85unsigned long arch_mmap_rnd(void) 86unsigned long arch_mmap_rnd(void)
86{ 87{
87 if (!(current->flags & PF_RANDOMIZE))
88 return 0;
89 return arch_rnd(mmap_is_ia32() ? mmap32_rnd_bits : mmap64_rnd_bits); 88 return arch_rnd(mmap_is_ia32() ? mmap32_rnd_bits : mmap64_rnd_bits);
90} 89}
91 90
diff --git a/arch/x86/platform/uv/tlb_uv.c b/arch/x86/platform/uv/tlb_uv.c
index 3e4bdb442fbc..f44c0bc95aa2 100644
--- a/arch/x86/platform/uv/tlb_uv.c
+++ b/arch/x86/platform/uv/tlb_uv.c
@@ -26,7 +26,7 @@
26static struct bau_operations ops __ro_after_init; 26static struct bau_operations ops __ro_after_init;
27 27
28/* timeouts in nanoseconds (indexed by UVH_AGING_PRESCALE_SEL urgency7 30:28) */ 28/* timeouts in nanoseconds (indexed by UVH_AGING_PRESCALE_SEL urgency7 30:28) */
29static int timeout_base_ns[] = { 29static const int timeout_base_ns[] = {
30 20, 30 20,
31 160, 31 160,
32 1280, 32 1280,
@@ -1216,7 +1216,7 @@ static struct bau_pq_entry *find_another_by_swack(struct bau_pq_entry *msg,
1216 * set a bit in the UVH_LB_BAU_INTD_SOFTWARE_ACKNOWLEDGE register. 1216 * set a bit in the UVH_LB_BAU_INTD_SOFTWARE_ACKNOWLEDGE register.
1217 * Such a message must be ignored. 1217 * Such a message must be ignored.
1218 */ 1218 */
1219void process_uv2_message(struct msg_desc *mdp, struct bau_control *bcp) 1219static void process_uv2_message(struct msg_desc *mdp, struct bau_control *bcp)
1220{ 1220{
1221 unsigned long mmr_image; 1221 unsigned long mmr_image;
1222 unsigned char swack_vec; 1222 unsigned char swack_vec;
diff --git a/block/blk-mq-pci.c b/block/blk-mq-pci.c
index 0c3354cf3552..76944e3271bf 100644
--- a/block/blk-mq-pci.c
+++ b/block/blk-mq-pci.c
@@ -36,12 +36,18 @@ int blk_mq_pci_map_queues(struct blk_mq_tag_set *set, struct pci_dev *pdev)
36 for (queue = 0; queue < set->nr_hw_queues; queue++) { 36 for (queue = 0; queue < set->nr_hw_queues; queue++) {
37 mask = pci_irq_get_affinity(pdev, queue); 37 mask = pci_irq_get_affinity(pdev, queue);
38 if (!mask) 38 if (!mask)
39 return -EINVAL; 39 goto fallback;
40 40
41 for_each_cpu(cpu, mask) 41 for_each_cpu(cpu, mask)
42 set->mq_map[cpu] = queue; 42 set->mq_map[cpu] = queue;
43 } 43 }
44 44
45 return 0; 45 return 0;
46
47fallback:
48 WARN_ON_ONCE(set->nr_hw_queues > 1);
49 for_each_possible_cpu(cpu)
50 set->mq_map[cpu] = 0;
51 return 0;
46} 52}
47EXPORT_SYMBOL_GPL(blk_mq_pci_map_queues); 53EXPORT_SYMBOL_GPL(blk_mq_pci_map_queues);
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 535cbdf32aab..4603b115e234 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -360,12 +360,12 @@ struct request *blk_mq_alloc_request(struct request_queue *q, unsigned int op,
360 return ERR_PTR(ret); 360 return ERR_PTR(ret);
361 361
362 rq = blk_mq_get_request(q, NULL, op, &alloc_data); 362 rq = blk_mq_get_request(q, NULL, op, &alloc_data);
363 blk_queue_exit(q);
363 364
364 if (!rq) 365 if (!rq)
365 return ERR_PTR(-EWOULDBLOCK); 366 return ERR_PTR(-EWOULDBLOCK);
366 367
367 blk_mq_put_ctx(alloc_data.ctx); 368 blk_mq_put_ctx(alloc_data.ctx);
368 blk_queue_exit(q);
369 369
370 rq->__data_len = 0; 370 rq->__data_len = 0;
371 rq->__sector = (sector_t) -1; 371 rq->__sector = (sector_t) -1;
@@ -411,12 +411,11 @@ struct request *blk_mq_alloc_request_hctx(struct request_queue *q,
411 alloc_data.ctx = __blk_mq_get_ctx(q, cpu); 411 alloc_data.ctx = __blk_mq_get_ctx(q, cpu);
412 412
413 rq = blk_mq_get_request(q, NULL, op, &alloc_data); 413 rq = blk_mq_get_request(q, NULL, op, &alloc_data);
414 blk_queue_exit(q);
414 415
415 if (!rq) 416 if (!rq)
416 return ERR_PTR(-EWOULDBLOCK); 417 return ERR_PTR(-EWOULDBLOCK);
417 418
418 blk_queue_exit(q);
419
420 return rq; 419 return rq;
421} 420}
422EXPORT_SYMBOL_GPL(blk_mq_alloc_request_hctx); 421EXPORT_SYMBOL_GPL(blk_mq_alloc_request_hctx);
diff --git a/drivers/acpi/acpica/nsxfeval.c b/drivers/acpi/acpica/nsxfeval.c
index 538c61677c10..783f4c838aee 100644
--- a/drivers/acpi/acpica/nsxfeval.c
+++ b/drivers/acpi/acpica/nsxfeval.c
@@ -100,9 +100,13 @@ acpi_evaluate_object_typed(acpi_handle handle,
100 free_buffer_on_error = TRUE; 100 free_buffer_on_error = TRUE;
101 } 101 }
102 102
103 status = acpi_get_handle(handle, pathname, &target_handle); 103 if (pathname) {
104 if (ACPI_FAILURE(status)) { 104 status = acpi_get_handle(handle, pathname, &target_handle);
105 return_ACPI_STATUS(status); 105 if (ACPI_FAILURE(status)) {
106 return_ACPI_STATUS(status);
107 }
108 } else {
109 target_handle = handle;
106 } 110 }
107 111
108 full_pathname = acpi_ns_get_external_pathname(target_handle); 112 full_pathname = acpi_ns_get_external_pathname(target_handle);
diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c
index 917c789f953d..476a52c60cf3 100644
--- a/drivers/acpi/property.c
+++ b/drivers/acpi/property.c
@@ -1047,7 +1047,7 @@ static struct fwnode_handle *acpi_graph_get_child_prop_value(
1047 fwnode_for_each_child_node(fwnode, child) { 1047 fwnode_for_each_child_node(fwnode, child) {
1048 u32 nr; 1048 u32 nr;
1049 1049
1050 if (!fwnode_property_read_u32(fwnode, prop_name, &nr)) 1050 if (fwnode_property_read_u32(child, prop_name, &nr))
1051 continue; 1051 continue;
1052 1052
1053 if (val == nr) 1053 if (val == nr)
diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
index 98e34e4c62b8..2468c28d4771 100644
--- a/drivers/block/xen-blkfront.c
+++ b/drivers/block/xen-blkfront.c
@@ -2075,9 +2075,9 @@ static int blkfront_resume(struct xenbus_device *dev)
2075 /* 2075 /*
2076 * Get the bios in the request so we can re-queue them. 2076 * Get the bios in the request so we can re-queue them.
2077 */ 2077 */
2078 if (req_op(shadow[i].request) == REQ_OP_FLUSH || 2078 if (req_op(shadow[j].request) == REQ_OP_FLUSH ||
2079 req_op(shadow[i].request) == REQ_OP_DISCARD || 2079 req_op(shadow[j].request) == REQ_OP_DISCARD ||
2080 req_op(shadow[i].request) == REQ_OP_SECURE_ERASE || 2080 req_op(shadow[j].request) == REQ_OP_SECURE_ERASE ||
2081 shadow[j].request->cmd_flags & REQ_FUA) { 2081 shadow[j].request->cmd_flags & REQ_FUA) {
2082 /* 2082 /*
2083 * Flush operations don't contain bios, so 2083 * Flush operations don't contain bios, so
diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
index fcae5ca6ac92..54a67f8a28eb 100644
--- a/drivers/clocksource/Kconfig
+++ b/drivers/clocksource/Kconfig
@@ -262,7 +262,7 @@ config CLKSRC_LPC32XX
262 262
263config CLKSRC_PISTACHIO 263config CLKSRC_PISTACHIO
264 bool "Clocksource for Pistachio SoC" if COMPILE_TEST 264 bool "Clocksource for Pistachio SoC" if COMPILE_TEST
265 depends on HAS_IOMEM 265 depends on GENERIC_CLOCKEVENTS && HAS_IOMEM
266 select TIMER_OF 266 select TIMER_OF
267 help 267 help
268 Enables the clocksource for the Pistachio SoC. 268 Enables the clocksource for the Pistachio SoC.
diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
index aae87c4c546e..72bbfccef113 100644
--- a/drivers/clocksource/arm_arch_timer.c
+++ b/drivers/clocksource/arm_arch_timer.c
@@ -1440,7 +1440,7 @@ static int __init arch_timer_mem_acpi_init(int platform_timer_count)
1440 * While unlikely, it's theoretically possible that none of the frames 1440 * While unlikely, it's theoretically possible that none of the frames
1441 * in a timer expose the combination of feature we want. 1441 * in a timer expose the combination of feature we want.
1442 */ 1442 */
1443 for (i = i; i < timer_count; i++) { 1443 for (i = 0; i < timer_count; i++) {
1444 timer = &timers[i]; 1444 timer = &timers[i];
1445 1445
1446 frame = arch_timer_mem_find_best_frame(timer); 1446 frame = arch_timer_mem_find_best_frame(timer);
diff --git a/drivers/clocksource/em_sti.c b/drivers/clocksource/em_sti.c
index bc48cbf6a795..269db74a0658 100644
--- a/drivers/clocksource/em_sti.c
+++ b/drivers/clocksource/em_sti.c
@@ -305,7 +305,7 @@ static int em_sti_probe(struct platform_device *pdev)
305 irq = platform_get_irq(pdev, 0); 305 irq = platform_get_irq(pdev, 0);
306 if (irq < 0) { 306 if (irq < 0) {
307 dev_err(&pdev->dev, "failed to get irq\n"); 307 dev_err(&pdev->dev, "failed to get irq\n");
308 return -EINVAL; 308 return irq;
309 } 309 }
310 310
311 /* map memory, let base point to the STI instance */ 311 /* map memory, let base point to the STI instance */
@@ -314,11 +314,12 @@ static int em_sti_probe(struct platform_device *pdev)
314 if (IS_ERR(p->base)) 314 if (IS_ERR(p->base))
315 return PTR_ERR(p->base); 315 return PTR_ERR(p->base);
316 316
317 if (devm_request_irq(&pdev->dev, irq, em_sti_interrupt, 317 ret = devm_request_irq(&pdev->dev, irq, em_sti_interrupt,
318 IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING, 318 IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING,
319 dev_name(&pdev->dev), p)) { 319 dev_name(&pdev->dev), p);
320 if (ret) {
320 dev_err(&pdev->dev, "failed to request low IRQ\n"); 321 dev_err(&pdev->dev, "failed to request low IRQ\n");
321 return -ENOENT; 322 return ret;
322 } 323 }
323 324
324 /* get hold of clock */ 325 /* get hold of clock */
diff --git a/drivers/clocksource/timer-of.c b/drivers/clocksource/timer-of.c
index d509b500a7b5..4d7aef9d9c15 100644
--- a/drivers/clocksource/timer-of.c
+++ b/drivers/clocksource/timer-of.c
@@ -128,9 +128,9 @@ static __init int timer_base_init(struct device_node *np,
128 const char *name = of_base->name ? of_base->name : np->full_name; 128 const char *name = of_base->name ? of_base->name : np->full_name;
129 129
130 of_base->base = of_io_request_and_map(np, of_base->index, name); 130 of_base->base = of_io_request_and_map(np, of_base->index, name);
131 if (!of_base->base) { 131 if (IS_ERR(of_base->base)) {
132 pr_err("Failed to iomap (%s)\n", name); 132 pr_err("Failed to iomap (%s)\n", name);
133 return -ENXIO; 133 return PTR_ERR(of_base->base);
134 } 134 }
135 135
136 return 0; 136 return 0;
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index 0566455f233e..65ee4fcace1f 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -1613,8 +1613,7 @@ static inline bool intel_pstate_sample(struct cpudata *cpu, u64 time)
1613 1613
1614static inline int32_t get_avg_frequency(struct cpudata *cpu) 1614static inline int32_t get_avg_frequency(struct cpudata *cpu)
1615{ 1615{
1616 return mul_ext_fp(cpu->sample.core_avg_perf, 1616 return mul_ext_fp(cpu->sample.core_avg_perf, cpu_khz);
1617 cpu->pstate.max_pstate_physical * cpu->pstate.scaling);
1618} 1617}
1619 1618
1620static inline int32_t get_avg_pstate(struct cpudata *cpu) 1619static inline int32_t get_avg_pstate(struct cpudata *cpu)
diff --git a/drivers/crypto/ixp4xx_crypto.c b/drivers/crypto/ixp4xx_crypto.c
index 427cbe012729..dadc4a808df5 100644
--- a/drivers/crypto/ixp4xx_crypto.c
+++ b/drivers/crypto/ixp4xx_crypto.c
@@ -1073,7 +1073,7 @@ static int aead_perform(struct aead_request *req, int encrypt,
1073 req_ctx->hmac_virt = dma_pool_alloc(buffer_pool, flags, 1073 req_ctx->hmac_virt = dma_pool_alloc(buffer_pool, flags,
1074 &crypt->icv_rev_aes); 1074 &crypt->icv_rev_aes);
1075 if (unlikely(!req_ctx->hmac_virt)) 1075 if (unlikely(!req_ctx->hmac_virt))
1076 goto free_buf_src; 1076 goto free_buf_dst;
1077 if (!encrypt) { 1077 if (!encrypt) {
1078 scatterwalk_map_and_copy(req_ctx->hmac_virt, 1078 scatterwalk_map_and_copy(req_ctx->hmac_virt,
1079 req->src, cryptlen, authsize, 0); 1079 req->src, cryptlen, authsize, 0);
@@ -1088,10 +1088,10 @@ static int aead_perform(struct aead_request *req, int encrypt,
1088 BUG_ON(qmgr_stat_overflow(SEND_QID)); 1088 BUG_ON(qmgr_stat_overflow(SEND_QID));
1089 return -EINPROGRESS; 1089 return -EINPROGRESS;
1090 1090
1091free_buf_src:
1092 free_buf_chain(dev, req_ctx->src, crypt->src_buf);
1093free_buf_dst: 1091free_buf_dst:
1094 free_buf_chain(dev, req_ctx->dst, crypt->dst_buf); 1092 free_buf_chain(dev, req_ctx->dst, crypt->dst_buf);
1093free_buf_src:
1094 free_buf_chain(dev, req_ctx->src, crypt->src_buf);
1095 crypt->ctl_flags = CTL_FLAG_UNUSED; 1095 crypt->ctl_flags = CTL_FLAG_UNUSED;
1096 return -ENOMEM; 1096 return -ENOMEM;
1097} 1097}
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c
index a6899180b265..c586f44312f9 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c
@@ -244,6 +244,12 @@ struct dma_fence *amdgpu_sync_peek_fence(struct amdgpu_sync *sync,
244 struct dma_fence *f = e->fence; 244 struct dma_fence *f = e->fence;
245 struct amd_sched_fence *s_fence = to_amd_sched_fence(f); 245 struct amd_sched_fence *s_fence = to_amd_sched_fence(f);
246 246
247 if (dma_fence_is_signaled(f)) {
248 hash_del(&e->node);
249 dma_fence_put(f);
250 kmem_cache_free(amdgpu_sync_slab, e);
251 continue;
252 }
247 if (ring && s_fence) { 253 if (ring && s_fence) {
248 /* For fences from the same ring it is sufficient 254 /* For fences from the same ring it is sufficient
249 * when they are scheduled. 255 * when they are scheduled.
@@ -256,13 +262,6 @@ struct dma_fence *amdgpu_sync_peek_fence(struct amdgpu_sync *sync,
256 } 262 }
257 } 263 }
258 264
259 if (dma_fence_is_signaled(f)) {
260 hash_del(&e->node);
261 dma_fence_put(f);
262 kmem_cache_free(amdgpu_sync_slab, e);
263 continue;
264 }
265
266 return f; 265 return f;
267 } 266 }
268 267
diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
index 00d8967c8512..d1bd53b73738 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -4580,7 +4580,7 @@ static void gen9_sseu_device_status(struct drm_i915_private *dev_priv,
4580 4580
4581 sseu->slice_mask |= BIT(s); 4581 sseu->slice_mask |= BIT(s);
4582 4582
4583 if (IS_GEN9_BC(dev_priv)) 4583 if (IS_GEN9_BC(dev_priv) || IS_CANNONLAKE(dev_priv))
4584 sseu->subslice_mask = 4584 sseu->subslice_mask =
4585 INTEL_INFO(dev_priv)->sseu.subslice_mask; 4585 INTEL_INFO(dev_priv)->sseu.subslice_mask;
4586 4586
diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c
index 39ed58a21fc1..e1e971ee2ed5 100644
--- a/drivers/gpu/drm/i915/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/i915_gem_context.c
@@ -688,19 +688,19 @@ static inline bool skip_rcs_switch(struct i915_hw_ppgtt *ppgtt,
688} 688}
689 689
690static bool 690static bool
691needs_pd_load_pre(struct i915_hw_ppgtt *ppgtt, 691needs_pd_load_pre(struct i915_hw_ppgtt *ppgtt, struct intel_engine_cs *engine)
692 struct intel_engine_cs *engine,
693 struct i915_gem_context *to)
694{ 692{
693 struct i915_gem_context *from = engine->legacy_active_context;
694
695 if (!ppgtt) 695 if (!ppgtt)
696 return false; 696 return false;
697 697
698 /* Always load the ppgtt on first use */ 698 /* Always load the ppgtt on first use */
699 if (!engine->legacy_active_context) 699 if (!from)
700 return true; 700 return true;
701 701
702 /* Same context without new entries, skip */ 702 /* Same context without new entries, skip */
703 if (engine->legacy_active_context == to && 703 if ((!from->ppgtt || from->ppgtt == ppgtt) &&
704 !(intel_engine_flag(engine) & ppgtt->pd_dirty_rings)) 704 !(intel_engine_flag(engine) & ppgtt->pd_dirty_rings))
705 return false; 705 return false;
706 706
@@ -744,7 +744,7 @@ static int do_rcs_switch(struct drm_i915_gem_request *req)
744 if (skip_rcs_switch(ppgtt, engine, to)) 744 if (skip_rcs_switch(ppgtt, engine, to))
745 return 0; 745 return 0;
746 746
747 if (needs_pd_load_pre(ppgtt, engine, to)) { 747 if (needs_pd_load_pre(ppgtt, engine)) {
748 /* Older GENs and non render rings still want the load first, 748 /* Older GENs and non render rings still want the load first,
749 * "PP_DCLV followed by PP_DIR_BASE register through Load 749 * "PP_DCLV followed by PP_DIR_BASE register through Load
750 * Register Immediate commands in Ring Buffer before submitting 750 * Register Immediate commands in Ring Buffer before submitting
@@ -841,7 +841,7 @@ int i915_switch_context(struct drm_i915_gem_request *req)
841 struct i915_hw_ppgtt *ppgtt = 841 struct i915_hw_ppgtt *ppgtt =
842 to->ppgtt ?: req->i915->mm.aliasing_ppgtt; 842 to->ppgtt ?: req->i915->mm.aliasing_ppgtt;
843 843
844 if (needs_pd_load_pre(ppgtt, engine, to)) { 844 if (needs_pd_load_pre(ppgtt, engine)) {
845 int ret; 845 int ret;
846 846
847 trace_switch_mm(engine, to); 847 trace_switch_mm(engine, to);
@@ -852,6 +852,7 @@ int i915_switch_context(struct drm_i915_gem_request *req)
852 ppgtt->pd_dirty_rings &= ~intel_engine_flag(engine); 852 ppgtt->pd_dirty_rings &= ~intel_engine_flag(engine);
853 } 853 }
854 854
855 engine->legacy_active_context = to;
855 return 0; 856 return 0;
856 } 857 }
857 858
diff --git a/drivers/gpu/drm/i915/i915_gem_render_state.c b/drivers/gpu/drm/i915/i915_gem_render_state.c
index 7032c542a9b1..4dd4c2159a92 100644
--- a/drivers/gpu/drm/i915/i915_gem_render_state.c
+++ b/drivers/gpu/drm/i915/i915_gem_render_state.c
@@ -242,6 +242,10 @@ int i915_gem_render_state_emit(struct drm_i915_gem_request *req)
242 goto err_unpin; 242 goto err_unpin;
243 } 243 }
244 244
245 ret = req->engine->emit_flush(req, EMIT_INVALIDATE);
246 if (ret)
247 goto err_unpin;
248
245 ret = req->engine->emit_bb_start(req, 249 ret = req->engine->emit_bb_start(req,
246 so->batch_offset, so->batch_size, 250 so->batch_offset, so->batch_size,
247 I915_DISPATCH_SECURE); 251 I915_DISPATCH_SECURE);
diff --git a/drivers/gpu/drm/i915/intel_ddi.c b/drivers/gpu/drm/i915/intel_ddi.c
index 9edeaaef77ad..d3b3252a8742 100644
--- a/drivers/gpu/drm/i915/intel_ddi.c
+++ b/drivers/gpu/drm/i915/intel_ddi.c
@@ -1762,7 +1762,7 @@ cnl_get_buf_trans_edp(struct drm_i915_private *dev_priv,
1762 if (dev_priv->vbt.edp.low_vswing) { 1762 if (dev_priv->vbt.edp.low_vswing) {
1763 if (voltage == VOLTAGE_INFO_0_85V) { 1763 if (voltage == VOLTAGE_INFO_0_85V) {
1764 *n_entries = ARRAY_SIZE(cnl_ddi_translations_edp_0_85V); 1764 *n_entries = ARRAY_SIZE(cnl_ddi_translations_edp_0_85V);
1765 return cnl_ddi_translations_dp_0_85V; 1765 return cnl_ddi_translations_edp_0_85V;
1766 } else if (voltage == VOLTAGE_INFO_0_95V) { 1766 } else if (voltage == VOLTAGE_INFO_0_95V) {
1767 *n_entries = ARRAY_SIZE(cnl_ddi_translations_edp_0_95V); 1767 *n_entries = ARRAY_SIZE(cnl_ddi_translations_edp_0_95V);
1768 return cnl_ddi_translations_edp_0_95V; 1768 return cnl_ddi_translations_edp_0_95V;
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 9471c88d449e..cc484b56eeaa 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -3485,6 +3485,13 @@ void intel_prepare_reset(struct drm_i915_private *dev_priv)
3485 !gpu_reset_clobbers_display(dev_priv)) 3485 !gpu_reset_clobbers_display(dev_priv))
3486 return; 3486 return;
3487 3487
3488 /* We have a modeset vs reset deadlock, defensively unbreak it.
3489 *
3490 * FIXME: We can do a _lot_ better, this is just a first iteration.
3491 */
3492 i915_gem_set_wedged(dev_priv);
3493 DRM_DEBUG_DRIVER("Wedging GPU to avoid deadlocks with pending modeset updates\n");
3494
3488 /* 3495 /*
3489 * Need mode_config.mutex so that we don't 3496 * Need mode_config.mutex so that we don't
3490 * trample ongoing ->detect() and whatnot. 3497 * trample ongoing ->detect() and whatnot.
diff --git a/drivers/gpu/drm/i915/intel_lrc.h b/drivers/gpu/drm/i915/intel_lrc.h
index 52b3a1fd4059..57ef5833c427 100644
--- a/drivers/gpu/drm/i915/intel_lrc.h
+++ b/drivers/gpu/drm/i915/intel_lrc.h
@@ -63,7 +63,6 @@ enum {
63}; 63};
64 64
65/* Logical Rings */ 65/* Logical Rings */
66void intel_logical_ring_stop(struct intel_engine_cs *engine);
67void intel_logical_ring_cleanup(struct intel_engine_cs *engine); 66void intel_logical_ring_cleanup(struct intel_engine_cs *engine);
68int logical_render_ring_init(struct intel_engine_cs *engine); 67int logical_render_ring_init(struct intel_engine_cs *engine);
69int logical_xcs_ring_init(struct intel_engine_cs *engine); 68int logical_xcs_ring_init(struct intel_engine_cs *engine);
diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c
index a5dfab6adf49..221468f77128 100644
--- a/drivers/infiniband/core/device.c
+++ b/drivers/infiniband/core/device.c
@@ -537,10 +537,11 @@ void ib_unregister_device(struct ib_device *device)
537 } 537 }
538 up_read(&lists_rwsem); 538 up_read(&lists_rwsem);
539 539
540 mutex_unlock(&device_mutex);
541
542 ib_device_unregister_rdmacg(device); 540 ib_device_unregister_rdmacg(device);
543 ib_device_unregister_sysfs(device); 541 ib_device_unregister_sysfs(device);
542
543 mutex_unlock(&device_mutex);
544
544 ib_cache_cleanup_one(device); 545 ib_cache_cleanup_one(device);
545 546
546 ib_security_destroy_port_pkey_list(device); 547 ib_security_destroy_port_pkey_list(device);
diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c
index c023e2c81b8f..5e530d2bee44 100644
--- a/drivers/infiniband/core/uverbs_main.c
+++ b/drivers/infiniband/core/uverbs_main.c
@@ -1153,7 +1153,6 @@ static void ib_uverbs_free_hw_resources(struct ib_uverbs_device *uverbs_dev,
1153 kref_get(&file->ref); 1153 kref_get(&file->ref);
1154 mutex_unlock(&uverbs_dev->lists_mutex); 1154 mutex_unlock(&uverbs_dev->lists_mutex);
1155 1155
1156 ib_uverbs_event_handler(&file->event_handler, &event);
1157 1156
1158 mutex_lock(&file->cleanup_mutex); 1157 mutex_lock(&file->cleanup_mutex);
1159 ucontext = file->ucontext; 1158 ucontext = file->ucontext;
@@ -1170,6 +1169,7 @@ static void ib_uverbs_free_hw_resources(struct ib_uverbs_device *uverbs_dev,
1170 * for example due to freeing the resources 1169 * for example due to freeing the resources
1171 * (e.g mmput). 1170 * (e.g mmput).
1172 */ 1171 */
1172 ib_uverbs_event_handler(&file->event_handler, &event);
1173 ib_dev->disassociate_ucontext(ucontext); 1173 ib_dev->disassociate_ucontext(ucontext);
1174 mutex_lock(&file->cleanup_mutex); 1174 mutex_lock(&file->cleanup_mutex);
1175 ib_uverbs_cleanup_ucontext(file, ucontext, true); 1175 ib_uverbs_cleanup_ucontext(file, ucontext, true);
diff --git a/drivers/infiniband/hw/cxgb4/mem.c b/drivers/infiniband/hw/cxgb4/mem.c
index 5332f06b99ba..c2fba76becd4 100644
--- a/drivers/infiniband/hw/cxgb4/mem.c
+++ b/drivers/infiniband/hw/cxgb4/mem.c
@@ -661,7 +661,7 @@ struct ib_mr *c4iw_alloc_mr(struct ib_pd *pd,
661 rhp = php->rhp; 661 rhp = php->rhp;
662 662
663 if (mr_type != IB_MR_TYPE_MEM_REG || 663 if (mr_type != IB_MR_TYPE_MEM_REG ||
664 max_num_sg > t4_max_fr_depth(&rhp->rdev.lldi.ulptx_memwrite_dsgl && 664 max_num_sg > t4_max_fr_depth(rhp->rdev.lldi.ulptx_memwrite_dsgl &&
665 use_dsgl)) 665 use_dsgl))
666 return ERR_PTR(-EINVAL); 666 return ERR_PTR(-EINVAL);
667 667
diff --git a/drivers/infiniband/hw/hns/hns_roce_ah.c b/drivers/infiniband/hw/hns/hns_roce_ah.c
index f78a733a63ec..d545302b8ef8 100644
--- a/drivers/infiniband/hw/hns/hns_roce_ah.c
+++ b/drivers/infiniband/hw/hns/hns_roce_ah.c
@@ -64,8 +64,10 @@ struct ib_ah *hns_roce_create_ah(struct ib_pd *ibpd,
64 } else { 64 } else {
65 u8 *dmac = rdma_ah_retrieve_dmac(ah_attr); 65 u8 *dmac = rdma_ah_retrieve_dmac(ah_attr);
66 66
67 if (!dmac) 67 if (!dmac) {
68 kfree(ah);
68 return ERR_PTR(-EINVAL); 69 return ERR_PTR(-EINVAL);
70 }
69 memcpy(ah->av.mac, dmac, ETH_ALEN); 71 memcpy(ah->av.mac, dmac, ETH_ALEN);
70 } 72 }
71 73
diff --git a/drivers/infiniband/hw/i40iw/i40iw_ctrl.c b/drivers/infiniband/hw/i40iw/i40iw_ctrl.c
index 9ec1ae9a82c9..a49ff2eb6fb3 100644
--- a/drivers/infiniband/hw/i40iw/i40iw_ctrl.c
+++ b/drivers/infiniband/hw/i40iw/i40iw_ctrl.c
@@ -130,20 +130,32 @@ static enum i40iw_status_code i40iw_sc_parse_fpm_commit_buf(
130 u64 base = 0; 130 u64 base = 0;
131 u32 i, j; 131 u32 i, j;
132 u32 k = 0; 132 u32 k = 0;
133 u32 low;
134 133
135 /* copy base values in obj_info */ 134 /* copy base values in obj_info */
136 for (i = I40IW_HMC_IW_QP, j = 0; 135 for (i = I40IW_HMC_IW_QP, j = 0; i <= I40IW_HMC_IW_PBLE; i++, j += 8) {
137 i <= I40IW_HMC_IW_PBLE; i++, j += 8) { 136 if ((i == I40IW_HMC_IW_SRQ) ||
137 (i == I40IW_HMC_IW_FSIMC) ||
138 (i == I40IW_HMC_IW_FSIAV)) {
139 info[i].base = 0;
140 info[i].cnt = 0;
141 continue;
142 }
138 get_64bit_val(buf, j, &temp); 143 get_64bit_val(buf, j, &temp);
139 info[i].base = RS_64_1(temp, 32) * 512; 144 info[i].base = RS_64_1(temp, 32) * 512;
140 if (info[i].base > base) { 145 if (info[i].base > base) {
141 base = info[i].base; 146 base = info[i].base;
142 k = i; 147 k = i;
143 } 148 }
144 low = (u32)(temp); 149 if (i == I40IW_HMC_IW_APBVT_ENTRY) {
145 if (low) 150 info[i].cnt = 1;
146 info[i].cnt = low; 151 continue;
152 }
153 if (i == I40IW_HMC_IW_QP)
154 info[i].cnt = (u32)RS_64(temp, I40IW_QUERY_FPM_MAX_QPS);
155 else if (i == I40IW_HMC_IW_CQ)
156 info[i].cnt = (u32)RS_64(temp, I40IW_QUERY_FPM_MAX_CQS);
157 else
158 info[i].cnt = (u32)(temp);
147 } 159 }
148 size = info[k].cnt * info[k].size + info[k].base; 160 size = info[k].cnt * info[k].size + info[k].base;
149 if (size & 0x1FFFFF) 161 if (size & 0x1FFFFF)
@@ -155,6 +167,31 @@ static enum i40iw_status_code i40iw_sc_parse_fpm_commit_buf(
155} 167}
156 168
157/** 169/**
170 * i40iw_sc_decode_fpm_query() - Decode a 64 bit value into max count and size
171 * @buf: ptr to fpm query buffer
172 * @buf_idx: index into buf
173 * @info: ptr to i40iw_hmc_obj_info struct
174 * @rsrc_idx: resource index into info
175 *
176 * Decode a 64 bit value from fpm query buffer into max count and size
177 */
178static u64 i40iw_sc_decode_fpm_query(u64 *buf,
179 u32 buf_idx,
180 struct i40iw_hmc_obj_info *obj_info,
181 u32 rsrc_idx)
182{
183 u64 temp;
184 u32 size;
185
186 get_64bit_val(buf, buf_idx, &temp);
187 obj_info[rsrc_idx].max_cnt = (u32)temp;
188 size = (u32)RS_64_1(temp, 32);
189 obj_info[rsrc_idx].size = LS_64_1(1, size);
190
191 return temp;
192}
193
194/**
158 * i40iw_sc_parse_fpm_query_buf() - parses fpm query buffer 195 * i40iw_sc_parse_fpm_query_buf() - parses fpm query buffer
159 * @buf: ptr to fpm query buffer 196 * @buf: ptr to fpm query buffer
160 * @info: ptr to i40iw_hmc_obj_info struct 197 * @info: ptr to i40iw_hmc_obj_info struct
@@ -168,9 +205,9 @@ static enum i40iw_status_code i40iw_sc_parse_fpm_query_buf(
168 struct i40iw_hmc_info *hmc_info, 205 struct i40iw_hmc_info *hmc_info,
169 struct i40iw_hmc_fpm_misc *hmc_fpm_misc) 206 struct i40iw_hmc_fpm_misc *hmc_fpm_misc)
170{ 207{
171 u64 temp;
172 struct i40iw_hmc_obj_info *obj_info; 208 struct i40iw_hmc_obj_info *obj_info;
173 u32 i, j, size; 209 u64 temp;
210 u32 size;
174 u16 max_pe_sds; 211 u16 max_pe_sds;
175 212
176 obj_info = hmc_info->hmc_obj; 213 obj_info = hmc_info->hmc_obj;
@@ -185,41 +222,52 @@ static enum i40iw_status_code i40iw_sc_parse_fpm_query_buf(
185 hmc_fpm_misc->max_sds = max_pe_sds; 222 hmc_fpm_misc->max_sds = max_pe_sds;
186 hmc_info->sd_table.sd_cnt = max_pe_sds + hmc_info->first_sd_index; 223 hmc_info->sd_table.sd_cnt = max_pe_sds + hmc_info->first_sd_index;
187 224
188 for (i = I40IW_HMC_IW_QP, j = 8; 225 get_64bit_val(buf, 8, &temp);
189 i <= I40IW_HMC_IW_ARP; i++, j += 8) { 226 obj_info[I40IW_HMC_IW_QP].max_cnt = (u32)RS_64(temp, I40IW_QUERY_FPM_MAX_QPS);
190 get_64bit_val(buf, j, &temp); 227 size = (u32)RS_64_1(temp, 32);
191 if (i == I40IW_HMC_IW_QP) 228 obj_info[I40IW_HMC_IW_QP].size = LS_64_1(1, size);
192 obj_info[i].max_cnt = (u32)RS_64(temp, I40IW_QUERY_FPM_MAX_QPS);
193 else if (i == I40IW_HMC_IW_CQ)
194 obj_info[i].max_cnt = (u32)RS_64(temp, I40IW_QUERY_FPM_MAX_CQS);
195 else
196 obj_info[i].max_cnt = (u32)temp;
197 229
198 size = (u32)RS_64_1(temp, 32); 230 get_64bit_val(buf, 16, &temp);
199 obj_info[i].size = ((u64)1 << size); 231 obj_info[I40IW_HMC_IW_CQ].max_cnt = (u32)RS_64(temp, I40IW_QUERY_FPM_MAX_CQS);
200 } 232 size = (u32)RS_64_1(temp, 32);
201 for (i = I40IW_HMC_IW_MR, j = 48; 233 obj_info[I40IW_HMC_IW_CQ].size = LS_64_1(1, size);
202 i <= I40IW_HMC_IW_PBLE; i++, j += 8) { 234
203 get_64bit_val(buf, j, &temp); 235 i40iw_sc_decode_fpm_query(buf, 32, obj_info, I40IW_HMC_IW_HTE);
204 obj_info[i].max_cnt = (u32)temp; 236 i40iw_sc_decode_fpm_query(buf, 40, obj_info, I40IW_HMC_IW_ARP);
205 size = (u32)RS_64_1(temp, 32); 237
206 obj_info[i].size = LS_64_1(1, size); 238 obj_info[I40IW_HMC_IW_APBVT_ENTRY].size = 8192;
207 } 239 obj_info[I40IW_HMC_IW_APBVT_ENTRY].max_cnt = 1;
240
241 i40iw_sc_decode_fpm_query(buf, 48, obj_info, I40IW_HMC_IW_MR);
242 i40iw_sc_decode_fpm_query(buf, 56, obj_info, I40IW_HMC_IW_XF);
208 243
209 get_64bit_val(buf, 120, &temp);
210 hmc_fpm_misc->max_ceqs = (u8)RS_64(temp, I40IW_QUERY_FPM_MAX_CEQS);
211 get_64bit_val(buf, 120, &temp);
212 hmc_fpm_misc->ht_multiplier = RS_64(temp, I40IW_QUERY_FPM_HTMULTIPLIER);
213 get_64bit_val(buf, 120, &temp);
214 hmc_fpm_misc->timer_bucket = RS_64(temp, I40IW_QUERY_FPM_TIMERBUCKET);
215 get_64bit_val(buf, 64, &temp); 244 get_64bit_val(buf, 64, &temp);
245 obj_info[I40IW_HMC_IW_XFFL].max_cnt = (u32)temp;
246 obj_info[I40IW_HMC_IW_XFFL].size = 4;
216 hmc_fpm_misc->xf_block_size = RS_64(temp, I40IW_QUERY_FPM_XFBLOCKSIZE); 247 hmc_fpm_misc->xf_block_size = RS_64(temp, I40IW_QUERY_FPM_XFBLOCKSIZE);
217 if (!hmc_fpm_misc->xf_block_size) 248 if (!hmc_fpm_misc->xf_block_size)
218 return I40IW_ERR_INVALID_SIZE; 249 return I40IW_ERR_INVALID_SIZE;
250
251 i40iw_sc_decode_fpm_query(buf, 72, obj_info, I40IW_HMC_IW_Q1);
252
219 get_64bit_val(buf, 80, &temp); 253 get_64bit_val(buf, 80, &temp);
254 obj_info[I40IW_HMC_IW_Q1FL].max_cnt = (u32)temp;
255 obj_info[I40IW_HMC_IW_Q1FL].size = 4;
220 hmc_fpm_misc->q1_block_size = RS_64(temp, I40IW_QUERY_FPM_Q1BLOCKSIZE); 256 hmc_fpm_misc->q1_block_size = RS_64(temp, I40IW_QUERY_FPM_Q1BLOCKSIZE);
221 if (!hmc_fpm_misc->q1_block_size) 257 if (!hmc_fpm_misc->q1_block_size)
222 return I40IW_ERR_INVALID_SIZE; 258 return I40IW_ERR_INVALID_SIZE;
259
260 i40iw_sc_decode_fpm_query(buf, 88, obj_info, I40IW_HMC_IW_TIMER);
261
262 get_64bit_val(buf, 112, &temp);
263 obj_info[I40IW_HMC_IW_PBLE].max_cnt = (u32)temp;
264 obj_info[I40IW_HMC_IW_PBLE].size = 8;
265
266 get_64bit_val(buf, 120, &temp);
267 hmc_fpm_misc->max_ceqs = (u8)RS_64(temp, I40IW_QUERY_FPM_MAX_CEQS);
268 hmc_fpm_misc->ht_multiplier = RS_64(temp, I40IW_QUERY_FPM_HTMULTIPLIER);
269 hmc_fpm_misc->timer_bucket = RS_64(temp, I40IW_QUERY_FPM_TIMERBUCKET);
270
223 return 0; 271 return 0;
224} 272}
225 273
@@ -3392,13 +3440,6 @@ enum i40iw_status_code i40iw_sc_init_iw_hmc(struct i40iw_sc_dev *dev, u8 hmc_fn_
3392 hmc_info->sd_table.sd_entry = virt_mem.va; 3440 hmc_info->sd_table.sd_entry = virt_mem.va;
3393 } 3441 }
3394 3442
3395 /* fill size of objects which are fixed */
3396 hmc_info->hmc_obj[I40IW_HMC_IW_XFFL].size = 4;
3397 hmc_info->hmc_obj[I40IW_HMC_IW_Q1FL].size = 4;
3398 hmc_info->hmc_obj[I40IW_HMC_IW_PBLE].size = 8;
3399 hmc_info->hmc_obj[I40IW_HMC_IW_APBVT_ENTRY].size = 8192;
3400 hmc_info->hmc_obj[I40IW_HMC_IW_APBVT_ENTRY].max_cnt = 1;
3401
3402 return ret_code; 3443 return ret_code;
3403} 3444}
3404 3445
@@ -4840,7 +4881,7 @@ void i40iw_vsi_stats_free(struct i40iw_sc_vsi *vsi)
4840{ 4881{
4841 u8 fcn_id = vsi->fcn_id; 4882 u8 fcn_id = vsi->fcn_id;
4842 4883
4843 if ((vsi->stats_fcn_id_alloc) && (fcn_id != I40IW_INVALID_FCN_ID)) 4884 if (vsi->stats_fcn_id_alloc && fcn_id < I40IW_MAX_STATS_COUNT)
4844 vsi->dev->fcn_id_array[fcn_id] = false; 4885 vsi->dev->fcn_id_array[fcn_id] = false;
4845 i40iw_hw_stats_stop_timer(vsi); 4886 i40iw_hw_stats_stop_timer(vsi);
4846} 4887}
diff --git a/drivers/infiniband/hw/i40iw/i40iw_d.h b/drivers/infiniband/hw/i40iw/i40iw_d.h
index a39ac12b6a7e..2ebaadbed379 100644
--- a/drivers/infiniband/hw/i40iw/i40iw_d.h
+++ b/drivers/infiniband/hw/i40iw/i40iw_d.h
@@ -1507,8 +1507,8 @@ enum {
1507 I40IW_CQ0_ALIGNMENT_MASK = (256 - 1), 1507 I40IW_CQ0_ALIGNMENT_MASK = (256 - 1),
1508 I40IW_HOST_CTX_ALIGNMENT_MASK = (4 - 1), 1508 I40IW_HOST_CTX_ALIGNMENT_MASK = (4 - 1),
1509 I40IW_SHADOWAREA_MASK = (128 - 1), 1509 I40IW_SHADOWAREA_MASK = (128 - 1),
1510 I40IW_FPM_QUERY_BUF_ALIGNMENT_MASK = 0, 1510 I40IW_FPM_QUERY_BUF_ALIGNMENT_MASK = (4 - 1),
1511 I40IW_FPM_COMMIT_BUF_ALIGNMENT_MASK = 0 1511 I40IW_FPM_COMMIT_BUF_ALIGNMENT_MASK = (4 - 1)
1512}; 1512};
1513 1513
1514enum i40iw_alignment { 1514enum i40iw_alignment {
diff --git a/drivers/infiniband/hw/i40iw/i40iw_puda.c b/drivers/infiniband/hw/i40iw/i40iw_puda.c
index 71050c5d29a0..7f5583d83622 100644
--- a/drivers/infiniband/hw/i40iw/i40iw_puda.c
+++ b/drivers/infiniband/hw/i40iw/i40iw_puda.c
@@ -685,7 +685,7 @@ static enum i40iw_status_code i40iw_puda_cq_create(struct i40iw_puda_rsrc *rsrc)
685 cqsize = rsrc->cq_size * (sizeof(struct i40iw_cqe)); 685 cqsize = rsrc->cq_size * (sizeof(struct i40iw_cqe));
686 tsize = cqsize + sizeof(struct i40iw_cq_shadow_area); 686 tsize = cqsize + sizeof(struct i40iw_cq_shadow_area);
687 ret = i40iw_allocate_dma_mem(dev->hw, &rsrc->cqmem, tsize, 687 ret = i40iw_allocate_dma_mem(dev->hw, &rsrc->cqmem, tsize,
688 I40IW_CQ0_ALIGNMENT_MASK); 688 I40IW_CQ0_ALIGNMENT);
689 if (ret) 689 if (ret)
690 return ret; 690 return ret;
691 691
diff --git a/drivers/infiniband/hw/i40iw/i40iw_status.h b/drivers/infiniband/hw/i40iw/i40iw_status.h
index 91c421762f06..f7013f11d808 100644
--- a/drivers/infiniband/hw/i40iw/i40iw_status.h
+++ b/drivers/infiniband/hw/i40iw/i40iw_status.h
@@ -62,7 +62,7 @@ enum i40iw_status_code {
62 I40IW_ERR_INVALID_ALIGNMENT = -23, 62 I40IW_ERR_INVALID_ALIGNMENT = -23,
63 I40IW_ERR_FLUSHED_QUEUE = -24, 63 I40IW_ERR_FLUSHED_QUEUE = -24,
64 I40IW_ERR_INVALID_PUSH_PAGE_INDEX = -25, 64 I40IW_ERR_INVALID_PUSH_PAGE_INDEX = -25,
65 I40IW_ERR_INVALID_IMM_DATA_SIZE = -26, 65 I40IW_ERR_INVALID_INLINE_DATA_SIZE = -26,
66 I40IW_ERR_TIMEOUT = -27, 66 I40IW_ERR_TIMEOUT = -27,
67 I40IW_ERR_OPCODE_MISMATCH = -28, 67 I40IW_ERR_OPCODE_MISMATCH = -28,
68 I40IW_ERR_CQP_COMPL_ERROR = -29, 68 I40IW_ERR_CQP_COMPL_ERROR = -29,
diff --git a/drivers/infiniband/hw/i40iw/i40iw_uk.c b/drivers/infiniband/hw/i40iw/i40iw_uk.c
index b0d3a0e8a9b5..1060725d18bc 100644
--- a/drivers/infiniband/hw/i40iw/i40iw_uk.c
+++ b/drivers/infiniband/hw/i40iw/i40iw_uk.c
@@ -435,7 +435,7 @@ static enum i40iw_status_code i40iw_inline_rdma_write(struct i40iw_qp_uk *qp,
435 435
436 op_info = &info->op.inline_rdma_write; 436 op_info = &info->op.inline_rdma_write;
437 if (op_info->len > I40IW_MAX_INLINE_DATA_SIZE) 437 if (op_info->len > I40IW_MAX_INLINE_DATA_SIZE)
438 return I40IW_ERR_INVALID_IMM_DATA_SIZE; 438 return I40IW_ERR_INVALID_INLINE_DATA_SIZE;
439 439
440 ret_code = i40iw_inline_data_size_to_wqesize(op_info->len, &wqe_size); 440 ret_code = i40iw_inline_data_size_to_wqesize(op_info->len, &wqe_size);
441 if (ret_code) 441 if (ret_code)
@@ -511,7 +511,7 @@ static enum i40iw_status_code i40iw_inline_send(struct i40iw_qp_uk *qp,
511 511
512 op_info = &info->op.inline_send; 512 op_info = &info->op.inline_send;
513 if (op_info->len > I40IW_MAX_INLINE_DATA_SIZE) 513 if (op_info->len > I40IW_MAX_INLINE_DATA_SIZE)
514 return I40IW_ERR_INVALID_IMM_DATA_SIZE; 514 return I40IW_ERR_INVALID_INLINE_DATA_SIZE;
515 515
516 ret_code = i40iw_inline_data_size_to_wqesize(op_info->len, &wqe_size); 516 ret_code = i40iw_inline_data_size_to_wqesize(op_info->len, &wqe_size);
517 if (ret_code) 517 if (ret_code)
@@ -784,7 +784,7 @@ static enum i40iw_status_code i40iw_cq_poll_completion(struct i40iw_cq_uk *cq,
784 get_64bit_val(cqe, 0, &qword0); 784 get_64bit_val(cqe, 0, &qword0);
785 get_64bit_val(cqe, 16, &qword2); 785 get_64bit_val(cqe, 16, &qword2);
786 786
787 info->tcp_seq_num = (u8)RS_64(qword0, I40IWCQ_TCPSEQNUM); 787 info->tcp_seq_num = (u32)RS_64(qword0, I40IWCQ_TCPSEQNUM);
788 788
789 info->qp_id = (u32)RS_64(qword2, I40IWCQ_QPID); 789 info->qp_id = (u32)RS_64(qword2, I40IWCQ_QPID);
790 790
@@ -1187,7 +1187,7 @@ enum i40iw_status_code i40iw_inline_data_size_to_wqesize(u32 data_size,
1187 u8 *wqe_size) 1187 u8 *wqe_size)
1188{ 1188{
1189 if (data_size > I40IW_MAX_INLINE_DATA_SIZE) 1189 if (data_size > I40IW_MAX_INLINE_DATA_SIZE)
1190 return I40IW_ERR_INVALID_IMM_DATA_SIZE; 1190 return I40IW_ERR_INVALID_INLINE_DATA_SIZE;
1191 1191
1192 if (data_size <= 16) 1192 if (data_size <= 16)
1193 *wqe_size = I40IW_QP_WQE_MIN_SIZE; 1193 *wqe_size = I40IW_QP_WQE_MIN_SIZE;
diff --git a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_cq.c b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_cq.c
index 69bda611d313..90aa326fd7c0 100644
--- a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_cq.c
+++ b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_cq.c
@@ -65,13 +65,28 @@ int pvrdma_req_notify_cq(struct ib_cq *ibcq,
65 struct pvrdma_dev *dev = to_vdev(ibcq->device); 65 struct pvrdma_dev *dev = to_vdev(ibcq->device);
66 struct pvrdma_cq *cq = to_vcq(ibcq); 66 struct pvrdma_cq *cq = to_vcq(ibcq);
67 u32 val = cq->cq_handle; 67 u32 val = cq->cq_handle;
68 unsigned long flags;
69 int has_data = 0;
68 70
69 val |= (notify_flags & IB_CQ_SOLICITED_MASK) == IB_CQ_SOLICITED ? 71 val |= (notify_flags & IB_CQ_SOLICITED_MASK) == IB_CQ_SOLICITED ?
70 PVRDMA_UAR_CQ_ARM_SOL : PVRDMA_UAR_CQ_ARM; 72 PVRDMA_UAR_CQ_ARM_SOL : PVRDMA_UAR_CQ_ARM;
71 73
74 spin_lock_irqsave(&cq->cq_lock, flags);
75
72 pvrdma_write_uar_cq(dev, val); 76 pvrdma_write_uar_cq(dev, val);
73 77
74 return 0; 78 if (notify_flags & IB_CQ_REPORT_MISSED_EVENTS) {
79 unsigned int head;
80
81 has_data = pvrdma_idx_ring_has_data(&cq->ring_state->rx,
82 cq->ibcq.cqe, &head);
83 if (unlikely(has_data == PVRDMA_INVALID_IDX))
84 dev_err(&dev->pdev->dev, "CQ ring state invalid\n");
85 }
86
87 spin_unlock_irqrestore(&cq->cq_lock, flags);
88
89 return has_data;
75} 90}
76 91
77/** 92/**
diff --git a/drivers/input/mouse/elan_i2c_core.c b/drivers/input/mouse/elan_i2c_core.c
index 3b616cb7c67f..714cf7f9b138 100644
--- a/drivers/input/mouse/elan_i2c_core.c
+++ b/drivers/input/mouse/elan_i2c_core.c
@@ -1248,6 +1248,10 @@ static const struct acpi_device_id elan_acpi_id[] = {
1248 { "ELAN0100", 0 }, 1248 { "ELAN0100", 0 },
1249 { "ELAN0600", 0 }, 1249 { "ELAN0600", 0 },
1250 { "ELAN0605", 0 }, 1250 { "ELAN0605", 0 },
1251 { "ELAN0608", 0 },
1252 { "ELAN0605", 0 },
1253 { "ELAN0609", 0 },
1254 { "ELAN060B", 0 },
1251 { "ELAN1000", 0 }, 1255 { "ELAN1000", 0 },
1252 { } 1256 { }
1253}; 1257};
diff --git a/drivers/input/mouse/trackpoint.c b/drivers/input/mouse/trackpoint.c
index 922ea02edcc3..20b5b21c1bba 100644
--- a/drivers/input/mouse/trackpoint.c
+++ b/drivers/input/mouse/trackpoint.c
@@ -380,8 +380,8 @@ int trackpoint_detect(struct psmouse *psmouse, bool set_properties)
380 return 0; 380 return 0;
381 381
382 if (trackpoint_read(ps2dev, TP_EXT_BTN, &button_info)) { 382 if (trackpoint_read(ps2dev, TP_EXT_BTN, &button_info)) {
383 psmouse_warn(psmouse, "failed to get extended button data\n"); 383 psmouse_warn(psmouse, "failed to get extended button data, assuming 3 buttons\n");
384 button_info = 0; 384 button_info = 0x33;
385 } 385 }
386 386
387 psmouse->private = kzalloc(sizeof(struct trackpoint_data), GFP_KERNEL); 387 psmouse->private = kzalloc(sizeof(struct trackpoint_data), GFP_KERNEL);
diff --git a/drivers/irqchip/irq-atmel-aic-common.c b/drivers/irqchip/irq-atmel-aic-common.c
index 28b26c80f4cf..072bd227b6c6 100644
--- a/drivers/irqchip/irq-atmel-aic-common.c
+++ b/drivers/irqchip/irq-atmel-aic-common.c
@@ -137,14 +137,14 @@ static void __init aic_common_ext_irq_of_init(struct irq_domain *domain)
137#define AT91_RTC_IMR 0x28 137#define AT91_RTC_IMR 0x28
138#define AT91_RTC_IRQ_MASK 0x1f 138#define AT91_RTC_IRQ_MASK 0x1f
139 139
140void __init aic_common_rtc_irq_fixup(struct device_node *root) 140void __init aic_common_rtc_irq_fixup(void)
141{ 141{
142 struct device_node *np; 142 struct device_node *np;
143 void __iomem *regs; 143 void __iomem *regs;
144 144
145 np = of_find_compatible_node(root, NULL, "atmel,at91rm9200-rtc"); 145 np = of_find_compatible_node(NULL, NULL, "atmel,at91rm9200-rtc");
146 if (!np) 146 if (!np)
147 np = of_find_compatible_node(root, NULL, 147 np = of_find_compatible_node(NULL, NULL,
148 "atmel,at91sam9x5-rtc"); 148 "atmel,at91sam9x5-rtc");
149 149
150 if (!np) 150 if (!np)
@@ -165,7 +165,7 @@ void __init aic_common_rtc_irq_fixup(struct device_node *root)
165#define AT91_RTT_ALMIEN (1 << 16) /* Alarm Interrupt Enable */ 165#define AT91_RTT_ALMIEN (1 << 16) /* Alarm Interrupt Enable */
166#define AT91_RTT_RTTINCIEN (1 << 17) /* Real Time Timer Increment Interrupt Enable */ 166#define AT91_RTT_RTTINCIEN (1 << 17) /* Real Time Timer Increment Interrupt Enable */
167 167
168void __init aic_common_rtt_irq_fixup(struct device_node *root) 168void __init aic_common_rtt_irq_fixup(void)
169{ 169{
170 struct device_node *np; 170 struct device_node *np;
171 void __iomem *regs; 171 void __iomem *regs;
@@ -196,11 +196,10 @@ static void __init aic_common_irq_fixup(const struct of_device_id *matches)
196 return; 196 return;
197 197
198 match = of_match_node(matches, root); 198 match = of_match_node(matches, root);
199 of_node_put(root);
200 199
201 if (match) { 200 if (match) {
202 void (*fixup)(struct device_node *) = match->data; 201 void (*fixup)(void) = match->data;
203 fixup(root); 202 fixup();
204 } 203 }
205 204
206 of_node_put(root); 205 of_node_put(root);
diff --git a/drivers/irqchip/irq-atmel-aic-common.h b/drivers/irqchip/irq-atmel-aic-common.h
index af60376d50de..242e62c1851e 100644
--- a/drivers/irqchip/irq-atmel-aic-common.h
+++ b/drivers/irqchip/irq-atmel-aic-common.h
@@ -33,8 +33,8 @@ struct irq_domain *__init aic_common_of_init(struct device_node *node,
33 const char *name, int nirqs, 33 const char *name, int nirqs,
34 const struct of_device_id *matches); 34 const struct of_device_id *matches);
35 35
36void __init aic_common_rtc_irq_fixup(struct device_node *root); 36void __init aic_common_rtc_irq_fixup(void);
37 37
38void __init aic_common_rtt_irq_fixup(struct device_node *root); 38void __init aic_common_rtt_irq_fixup(void);
39 39
40#endif /* __IRQ_ATMEL_AIC_COMMON_H */ 40#endif /* __IRQ_ATMEL_AIC_COMMON_H */
diff --git a/drivers/irqchip/irq-atmel-aic.c b/drivers/irqchip/irq-atmel-aic.c
index 37f952dd9fc9..bb1ad451392f 100644
--- a/drivers/irqchip/irq-atmel-aic.c
+++ b/drivers/irqchip/irq-atmel-aic.c
@@ -209,20 +209,20 @@ static const struct irq_domain_ops aic_irq_ops = {
209 .xlate = aic_irq_domain_xlate, 209 .xlate = aic_irq_domain_xlate,
210}; 210};
211 211
212static void __init at91rm9200_aic_irq_fixup(struct device_node *root) 212static void __init at91rm9200_aic_irq_fixup(void)
213{ 213{
214 aic_common_rtc_irq_fixup(root); 214 aic_common_rtc_irq_fixup();
215} 215}
216 216
217static void __init at91sam9260_aic_irq_fixup(struct device_node *root) 217static void __init at91sam9260_aic_irq_fixup(void)
218{ 218{
219 aic_common_rtt_irq_fixup(root); 219 aic_common_rtt_irq_fixup();
220} 220}
221 221
222static void __init at91sam9g45_aic_irq_fixup(struct device_node *root) 222static void __init at91sam9g45_aic_irq_fixup(void)
223{ 223{
224 aic_common_rtc_irq_fixup(root); 224 aic_common_rtc_irq_fixup();
225 aic_common_rtt_irq_fixup(root); 225 aic_common_rtt_irq_fixup();
226} 226}
227 227
228static const struct of_device_id aic_irq_fixups[] __initconst = { 228static const struct of_device_id aic_irq_fixups[] __initconst = {
diff --git a/drivers/irqchip/irq-atmel-aic5.c b/drivers/irqchip/irq-atmel-aic5.c
index c04ee9a23d09..6acad2ea0fb3 100644
--- a/drivers/irqchip/irq-atmel-aic5.c
+++ b/drivers/irqchip/irq-atmel-aic5.c
@@ -305,9 +305,9 @@ static const struct irq_domain_ops aic5_irq_ops = {
305 .xlate = aic5_irq_domain_xlate, 305 .xlate = aic5_irq_domain_xlate,
306}; 306};
307 307
308static void __init sama5d3_aic_irq_fixup(struct device_node *root) 308static void __init sama5d3_aic_irq_fixup(void)
309{ 309{
310 aic_common_rtc_irq_fixup(root); 310 aic_common_rtc_irq_fixup();
311} 311}
312 312
313static const struct of_device_id aic5_irq_fixups[] __initconst = { 313static const struct of_device_id aic5_irq_fixups[] __initconst = {
diff --git a/drivers/irqchip/irq-brcmstb-l2.c b/drivers/irqchip/irq-brcmstb-l2.c
index bddf169c4b37..b009b916a292 100644
--- a/drivers/irqchip/irq-brcmstb-l2.c
+++ b/drivers/irqchip/irq-brcmstb-l2.c
@@ -189,6 +189,7 @@ static int __init brcmstb_l2_intc_of_init(struct device_node *np,
189 189
190 ct->chip.irq_suspend = brcmstb_l2_intc_suspend; 190 ct->chip.irq_suspend = brcmstb_l2_intc_suspend;
191 ct->chip.irq_resume = brcmstb_l2_intc_resume; 191 ct->chip.irq_resume = brcmstb_l2_intc_resume;
192 ct->chip.irq_pm_shutdown = brcmstb_l2_intc_suspend;
192 193
193 if (data->can_wake) { 194 if (data->can_wake) {
194 /* This IRQ chip can wake the system, set all child interrupts 195 /* This IRQ chip can wake the system, set all child interrupts
diff --git a/drivers/irqchip/irq-gic-v3-its-platform-msi.c b/drivers/irqchip/irq-gic-v3-its-platform-msi.c
index 249240d9a425..833a90fe33ae 100644
--- a/drivers/irqchip/irq-gic-v3-its-platform-msi.c
+++ b/drivers/irqchip/irq-gic-v3-its-platform-msi.c
@@ -43,6 +43,7 @@ static int of_pmsi_get_dev_id(struct irq_domain *domain, struct device *dev,
43 *dev_id = args.args[0]; 43 *dev_id = args.args[0];
44 break; 44 break;
45 } 45 }
46 index++;
46 } while (!ret); 47 } while (!ret);
47 48
48 return ret; 49 return ret;
diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
index 68932873eebc..284738add89b 100644
--- a/drivers/irqchip/irq-gic-v3-its.c
+++ b/drivers/irqchip/irq-gic-v3-its.c
@@ -1835,7 +1835,7 @@ static int __init its_of_probe(struct device_node *node)
1835 1835
1836#define ACPI_GICV3_ITS_MEM_SIZE (SZ_128K) 1836#define ACPI_GICV3_ITS_MEM_SIZE (SZ_128K)
1837 1837
1838#if defined(CONFIG_ACPI_NUMA) && (ACPI_CA_VERSION >= 0x20170531) 1838#ifdef CONFIG_ACPI_NUMA
1839struct its_srat_map { 1839struct its_srat_map {
1840 /* numa node id */ 1840 /* numa node id */
1841 u32 numa_node; 1841 u32 numa_node;
@@ -1843,7 +1843,7 @@ struct its_srat_map {
1843 u32 its_id; 1843 u32 its_id;
1844}; 1844};
1845 1845
1846static struct its_srat_map its_srat_maps[MAX_NUMNODES] __initdata; 1846static struct its_srat_map *its_srat_maps __initdata;
1847static int its_in_srat __initdata; 1847static int its_in_srat __initdata;
1848 1848
1849static int __init acpi_get_its_numa_node(u32 its_id) 1849static int __init acpi_get_its_numa_node(u32 its_id)
@@ -1857,6 +1857,12 @@ static int __init acpi_get_its_numa_node(u32 its_id)
1857 return NUMA_NO_NODE; 1857 return NUMA_NO_NODE;
1858} 1858}
1859 1859
1860static int __init gic_acpi_match_srat_its(struct acpi_subtable_header *header,
1861 const unsigned long end)
1862{
1863 return 0;
1864}
1865
1860static int __init gic_acpi_parse_srat_its(struct acpi_subtable_header *header, 1866static int __init gic_acpi_parse_srat_its(struct acpi_subtable_header *header,
1861 const unsigned long end) 1867 const unsigned long end)
1862{ 1868{
@@ -1873,12 +1879,6 @@ static int __init gic_acpi_parse_srat_its(struct acpi_subtable_header *header,
1873 return -EINVAL; 1879 return -EINVAL;
1874 } 1880 }
1875 1881
1876 if (its_in_srat >= MAX_NUMNODES) {
1877 pr_err("SRAT: ITS affinity exceeding max count[%d]\n",
1878 MAX_NUMNODES);
1879 return -EINVAL;
1880 }
1881
1882 node = acpi_map_pxm_to_node(its_affinity->proximity_domain); 1882 node = acpi_map_pxm_to_node(its_affinity->proximity_domain);
1883 1883
1884 if (node == NUMA_NO_NODE || node >= MAX_NUMNODES) { 1884 if (node == NUMA_NO_NODE || node >= MAX_NUMNODES) {
@@ -1897,14 +1897,37 @@ static int __init gic_acpi_parse_srat_its(struct acpi_subtable_header *header,
1897 1897
1898static void __init acpi_table_parse_srat_its(void) 1898static void __init acpi_table_parse_srat_its(void)
1899{ 1899{
1900 int count;
1901
1902 count = acpi_table_parse_entries(ACPI_SIG_SRAT,
1903 sizeof(struct acpi_table_srat),
1904 ACPI_SRAT_TYPE_GIC_ITS_AFFINITY,
1905 gic_acpi_match_srat_its, 0);
1906 if (count <= 0)
1907 return;
1908
1909 its_srat_maps = kmalloc(count * sizeof(struct its_srat_map),
1910 GFP_KERNEL);
1911 if (!its_srat_maps) {
1912 pr_warn("SRAT: Failed to allocate memory for its_srat_maps!\n");
1913 return;
1914 }
1915
1900 acpi_table_parse_entries(ACPI_SIG_SRAT, 1916 acpi_table_parse_entries(ACPI_SIG_SRAT,
1901 sizeof(struct acpi_table_srat), 1917 sizeof(struct acpi_table_srat),
1902 ACPI_SRAT_TYPE_GIC_ITS_AFFINITY, 1918 ACPI_SRAT_TYPE_GIC_ITS_AFFINITY,
1903 gic_acpi_parse_srat_its, 0); 1919 gic_acpi_parse_srat_its, 0);
1904} 1920}
1921
1922/* free the its_srat_maps after ITS probing */
1923static void __init acpi_its_srat_maps_free(void)
1924{
1925 kfree(its_srat_maps);
1926}
1905#else 1927#else
1906static void __init acpi_table_parse_srat_its(void) { } 1928static void __init acpi_table_parse_srat_its(void) { }
1907static int __init acpi_get_its_numa_node(u32 its_id) { return NUMA_NO_NODE; } 1929static int __init acpi_get_its_numa_node(u32 its_id) { return NUMA_NO_NODE; }
1930static void __init acpi_its_srat_maps_free(void) { }
1908#endif 1931#endif
1909 1932
1910static int __init gic_acpi_parse_madt_its(struct acpi_subtable_header *header, 1933static int __init gic_acpi_parse_madt_its(struct acpi_subtable_header *header,
@@ -1951,6 +1974,7 @@ static void __init its_acpi_probe(void)
1951 acpi_table_parse_srat_its(); 1974 acpi_table_parse_srat_its();
1952 acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_TRANSLATOR, 1975 acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_TRANSLATOR,
1953 gic_acpi_parse_madt_its, 0); 1976 gic_acpi_parse_madt_its, 0);
1977 acpi_its_srat_maps_free();
1954} 1978}
1955#else 1979#else
1956static void __init its_acpi_probe(void) { } 1980static void __init its_acpi_probe(void) { }
diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c
index dbffb7ab6203..984c3ecfd22c 100644
--- a/drivers/irqchip/irq-gic-v3.c
+++ b/drivers/irqchip/irq-gic-v3.c
@@ -353,6 +353,8 @@ static asmlinkage void __exception_irq_entry gic_handle_irq(struct pt_regs *regs
353 353
354 if (static_key_true(&supports_deactivate)) 354 if (static_key_true(&supports_deactivate))
355 gic_write_eoir(irqnr); 355 gic_write_eoir(irqnr);
356 else
357 isb();
356 358
357 err = handle_domain_irq(gic_data.domain, irqnr, regs); 359 err = handle_domain_irq(gic_data.domain, irqnr, regs);
358 if (err) { 360 if (err) {
@@ -640,11 +642,16 @@ static void gic_smp_init(void)
640static int gic_set_affinity(struct irq_data *d, const struct cpumask *mask_val, 642static int gic_set_affinity(struct irq_data *d, const struct cpumask *mask_val,
641 bool force) 643 bool force)
642{ 644{
643 unsigned int cpu = cpumask_any_and(mask_val, cpu_online_mask); 645 unsigned int cpu;
644 void __iomem *reg; 646 void __iomem *reg;
645 int enabled; 647 int enabled;
646 u64 val; 648 u64 val;
647 649
650 if (force)
651 cpu = cpumask_first(mask_val);
652 else
653 cpu = cpumask_any_and(mask_val, cpu_online_mask);
654
648 if (cpu >= nr_cpu_ids) 655 if (cpu >= nr_cpu_ids)
649 return -EINVAL; 656 return -EINVAL;
650 657
@@ -831,8 +838,11 @@ static int gic_irq_domain_alloc(struct irq_domain *domain, unsigned int virq,
831 if (ret) 838 if (ret)
832 return ret; 839 return ret;
833 840
834 for (i = 0; i < nr_irqs; i++) 841 for (i = 0; i < nr_irqs; i++) {
835 gic_irq_domain_map(domain, virq + i, hwirq + i); 842 ret = gic_irq_domain_map(domain, virq + i, hwirq + i);
843 if (ret)
844 return ret;
845 }
836 846
837 return 0; 847 return 0;
838} 848}
diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
index 1b1df4f770bd..d3e7c43718b8 100644
--- a/drivers/irqchip/irq-gic.c
+++ b/drivers/irqchip/irq-gic.c
@@ -361,6 +361,7 @@ static void __exception_irq_entry gic_handle_irq(struct pt_regs *regs)
361 if (likely(irqnr > 15 && irqnr < 1020)) { 361 if (likely(irqnr > 15 && irqnr < 1020)) {
362 if (static_key_true(&supports_deactivate)) 362 if (static_key_true(&supports_deactivate))
363 writel_relaxed(irqstat, cpu_base + GIC_CPU_EOI); 363 writel_relaxed(irqstat, cpu_base + GIC_CPU_EOI);
364 isb();
364 handle_domain_irq(gic->domain, irqnr, regs); 365 handle_domain_irq(gic->domain, irqnr, regs);
365 continue; 366 continue;
366 } 367 }
@@ -401,10 +402,12 @@ static void gic_handle_cascade_irq(struct irq_desc *desc)
401 goto out; 402 goto out;
402 403
403 cascade_irq = irq_find_mapping(chip_data->domain, gic_irq); 404 cascade_irq = irq_find_mapping(chip_data->domain, gic_irq);
404 if (unlikely(gic_irq < 32 || gic_irq > 1020)) 405 if (unlikely(gic_irq < 32 || gic_irq > 1020)) {
405 handle_bad_irq(desc); 406 handle_bad_irq(desc);
406 else 407 } else {
408 isb();
407 generic_handle_irq(cascade_irq); 409 generic_handle_irq(cascade_irq);
410 }
408 411
409 out: 412 out:
410 chained_irq_exit(chip, desc); 413 chained_irq_exit(chip, desc);
@@ -1027,8 +1030,11 @@ static int gic_irq_domain_alloc(struct irq_domain *domain, unsigned int virq,
1027 if (ret) 1030 if (ret)
1028 return ret; 1031 return ret;
1029 1032
1030 for (i = 0; i < nr_irqs; i++) 1033 for (i = 0; i < nr_irqs; i++) {
1031 gic_irq_domain_map(domain, virq + i, hwirq + i); 1034 ret = gic_irq_domain_map(domain, virq + i, hwirq + i);
1035 if (ret)
1036 return ret;
1037 }
1032 1038
1033 return 0; 1039 return 0;
1034} 1040}
diff --git a/drivers/isdn/mISDN/fsm.c b/drivers/isdn/mISDN/fsm.c
index 78fc5d5e9051..92e6570b1143 100644
--- a/drivers/isdn/mISDN/fsm.c
+++ b/drivers/isdn/mISDN/fsm.c
@@ -26,7 +26,7 @@
26 26
27#define FSM_TIMER_DEBUG 0 27#define FSM_TIMER_DEBUG 0
28 28
29void 29int
30mISDN_FsmNew(struct Fsm *fsm, 30mISDN_FsmNew(struct Fsm *fsm,
31 struct FsmNode *fnlist, int fncount) 31 struct FsmNode *fnlist, int fncount)
32{ 32{
@@ -34,6 +34,8 @@ mISDN_FsmNew(struct Fsm *fsm,
34 34
35 fsm->jumpmatrix = kzalloc(sizeof(FSMFNPTR) * fsm->state_count * 35 fsm->jumpmatrix = kzalloc(sizeof(FSMFNPTR) * fsm->state_count *
36 fsm->event_count, GFP_KERNEL); 36 fsm->event_count, GFP_KERNEL);
37 if (fsm->jumpmatrix == NULL)
38 return -ENOMEM;
37 39
38 for (i = 0; i < fncount; i++) 40 for (i = 0; i < fncount; i++)
39 if ((fnlist[i].state >= fsm->state_count) || 41 if ((fnlist[i].state >= fsm->state_count) ||
@@ -45,6 +47,7 @@ mISDN_FsmNew(struct Fsm *fsm,
45 } else 47 } else
46 fsm->jumpmatrix[fsm->state_count * fnlist[i].event + 48 fsm->jumpmatrix[fsm->state_count * fnlist[i].event +
47 fnlist[i].state] = (FSMFNPTR) fnlist[i].routine; 49 fnlist[i].state] = (FSMFNPTR) fnlist[i].routine;
50 return 0;
48} 51}
49EXPORT_SYMBOL(mISDN_FsmNew); 52EXPORT_SYMBOL(mISDN_FsmNew);
50 53
diff --git a/drivers/isdn/mISDN/fsm.h b/drivers/isdn/mISDN/fsm.h
index 928f5be192c1..e1def8490221 100644
--- a/drivers/isdn/mISDN/fsm.h
+++ b/drivers/isdn/mISDN/fsm.h
@@ -55,7 +55,7 @@ struct FsmTimer {
55 void *arg; 55 void *arg;
56}; 56};
57 57
58extern void mISDN_FsmNew(struct Fsm *, struct FsmNode *, int); 58extern int mISDN_FsmNew(struct Fsm *, struct FsmNode *, int);
59extern void mISDN_FsmFree(struct Fsm *); 59extern void mISDN_FsmFree(struct Fsm *);
60extern int mISDN_FsmEvent(struct FsmInst *, int , void *); 60extern int mISDN_FsmEvent(struct FsmInst *, int , void *);
61extern void mISDN_FsmChangeState(struct FsmInst *, int); 61extern void mISDN_FsmChangeState(struct FsmInst *, int);
diff --git a/drivers/isdn/mISDN/layer1.c b/drivers/isdn/mISDN/layer1.c
index bebc57b72138..3192b0eb3944 100644
--- a/drivers/isdn/mISDN/layer1.c
+++ b/drivers/isdn/mISDN/layer1.c
@@ -414,8 +414,7 @@ l1_init(u_int *deb)
414 l1fsm_s.event_count = L1_EVENT_COUNT; 414 l1fsm_s.event_count = L1_EVENT_COUNT;
415 l1fsm_s.strEvent = strL1Event; 415 l1fsm_s.strEvent = strL1Event;
416 l1fsm_s.strState = strL1SState; 416 l1fsm_s.strState = strL1SState;
417 mISDN_FsmNew(&l1fsm_s, L1SFnList, ARRAY_SIZE(L1SFnList)); 417 return mISDN_FsmNew(&l1fsm_s, L1SFnList, ARRAY_SIZE(L1SFnList));
418 return 0;
419} 418}
420 419
421void 420void
diff --git a/drivers/isdn/mISDN/layer2.c b/drivers/isdn/mISDN/layer2.c
index 7243a6746f8b..9ff0903a0e89 100644
--- a/drivers/isdn/mISDN/layer2.c
+++ b/drivers/isdn/mISDN/layer2.c
@@ -2247,15 +2247,26 @@ static struct Bprotocol X75SLP = {
2247int 2247int
2248Isdnl2_Init(u_int *deb) 2248Isdnl2_Init(u_int *deb)
2249{ 2249{
2250 int res;
2250 debug = deb; 2251 debug = deb;
2251 mISDN_register_Bprotocol(&X75SLP); 2252 mISDN_register_Bprotocol(&X75SLP);
2252 l2fsm.state_count = L2_STATE_COUNT; 2253 l2fsm.state_count = L2_STATE_COUNT;
2253 l2fsm.event_count = L2_EVENT_COUNT; 2254 l2fsm.event_count = L2_EVENT_COUNT;
2254 l2fsm.strEvent = strL2Event; 2255 l2fsm.strEvent = strL2Event;
2255 l2fsm.strState = strL2State; 2256 l2fsm.strState = strL2State;
2256 mISDN_FsmNew(&l2fsm, L2FnList, ARRAY_SIZE(L2FnList)); 2257 res = mISDN_FsmNew(&l2fsm, L2FnList, ARRAY_SIZE(L2FnList));
2257 TEIInit(deb); 2258 if (res)
2259 goto error;
2260 res = TEIInit(deb);
2261 if (res)
2262 goto error_fsm;
2258 return 0; 2263 return 0;
2264
2265error_fsm:
2266 mISDN_FsmFree(&l2fsm);
2267error:
2268 mISDN_unregister_Bprotocol(&X75SLP);
2269 return res;
2259} 2270}
2260 2271
2261void 2272void
diff --git a/drivers/isdn/mISDN/tei.c b/drivers/isdn/mISDN/tei.c
index 908127efccf8..12d9e5f4beb1 100644
--- a/drivers/isdn/mISDN/tei.c
+++ b/drivers/isdn/mISDN/tei.c
@@ -1387,23 +1387,37 @@ create_teimanager(struct mISDNdevice *dev)
1387 1387
1388int TEIInit(u_int *deb) 1388int TEIInit(u_int *deb)
1389{ 1389{
1390 int res;
1390 debug = deb; 1391 debug = deb;
1391 teifsmu.state_count = TEI_STATE_COUNT; 1392 teifsmu.state_count = TEI_STATE_COUNT;
1392 teifsmu.event_count = TEI_EVENT_COUNT; 1393 teifsmu.event_count = TEI_EVENT_COUNT;
1393 teifsmu.strEvent = strTeiEvent; 1394 teifsmu.strEvent = strTeiEvent;
1394 teifsmu.strState = strTeiState; 1395 teifsmu.strState = strTeiState;
1395 mISDN_FsmNew(&teifsmu, TeiFnListUser, ARRAY_SIZE(TeiFnListUser)); 1396 res = mISDN_FsmNew(&teifsmu, TeiFnListUser, ARRAY_SIZE(TeiFnListUser));
1397 if (res)
1398 goto error;
1396 teifsmn.state_count = TEI_STATE_COUNT; 1399 teifsmn.state_count = TEI_STATE_COUNT;
1397 teifsmn.event_count = TEI_EVENT_COUNT; 1400 teifsmn.event_count = TEI_EVENT_COUNT;
1398 teifsmn.strEvent = strTeiEvent; 1401 teifsmn.strEvent = strTeiEvent;
1399 teifsmn.strState = strTeiState; 1402 teifsmn.strState = strTeiState;
1400 mISDN_FsmNew(&teifsmn, TeiFnListNet, ARRAY_SIZE(TeiFnListNet)); 1403 res = mISDN_FsmNew(&teifsmn, TeiFnListNet, ARRAY_SIZE(TeiFnListNet));
1404 if (res)
1405 goto error_smn;
1401 deactfsm.state_count = DEACT_STATE_COUNT; 1406 deactfsm.state_count = DEACT_STATE_COUNT;
1402 deactfsm.event_count = DEACT_EVENT_COUNT; 1407 deactfsm.event_count = DEACT_EVENT_COUNT;
1403 deactfsm.strEvent = strDeactEvent; 1408 deactfsm.strEvent = strDeactEvent;
1404 deactfsm.strState = strDeactState; 1409 deactfsm.strState = strDeactState;
1405 mISDN_FsmNew(&deactfsm, DeactFnList, ARRAY_SIZE(DeactFnList)); 1410 res = mISDN_FsmNew(&deactfsm, DeactFnList, ARRAY_SIZE(DeactFnList));
1411 if (res)
1412 goto error_deact;
1406 return 0; 1413 return 0;
1414
1415error_deact:
1416 mISDN_FsmFree(&teifsmn);
1417error_smn:
1418 mISDN_FsmFree(&teifsmu);
1419error:
1420 return res;
1407} 1421}
1408 1422
1409void TEIFree(void) 1423void TEIFree(void)
diff --git a/drivers/md/md.c b/drivers/md/md.c
index c99634612fc4..b01e458d31e9 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -7996,7 +7996,7 @@ bool md_write_start(struct mddev *mddev, struct bio *bi)
7996 if (mddev->safemode == 1) 7996 if (mddev->safemode == 1)
7997 mddev->safemode = 0; 7997 mddev->safemode = 0;
7998 /* sync_checkers is always 0 when writes_pending is in per-cpu mode */ 7998 /* sync_checkers is always 0 when writes_pending is in per-cpu mode */
7999 if (mddev->in_sync || !mddev->sync_checkers) { 7999 if (mddev->in_sync || mddev->sync_checkers) {
8000 spin_lock(&mddev->lock); 8000 spin_lock(&mddev->lock);
8001 if (mddev->in_sync) { 8001 if (mddev->in_sync) {
8002 mddev->in_sync = 0; 8002 mddev->in_sync = 0;
@@ -8656,6 +8656,9 @@ void md_check_recovery(struct mddev *mddev)
8656 if (mddev_trylock(mddev)) { 8656 if (mddev_trylock(mddev)) {
8657 int spares = 0; 8657 int spares = 0;
8658 8658
8659 if (!mddev->external && mddev->safemode == 1)
8660 mddev->safemode = 0;
8661
8659 if (mddev->ro) { 8662 if (mddev->ro) {
8660 struct md_rdev *rdev; 8663 struct md_rdev *rdev;
8661 if (!mddev->external && mddev->in_sync) 8664 if (!mddev->external && mddev->in_sync)
diff --git a/drivers/md/raid5-cache.c b/drivers/md/raid5-cache.c
index bfa1e907c472..2dcbafa8e66c 100644
--- a/drivers/md/raid5-cache.c
+++ b/drivers/md/raid5-cache.c
@@ -236,9 +236,10 @@ struct r5l_io_unit {
236 bool need_split_bio; 236 bool need_split_bio;
237 struct bio *split_bio; 237 struct bio *split_bio;
238 238
239 unsigned int has_flush:1; /* include flush request */ 239 unsigned int has_flush:1; /* include flush request */
240 unsigned int has_fua:1; /* include fua request */ 240 unsigned int has_fua:1; /* include fua request */
241 unsigned int has_null_flush:1; /* include empty flush request */ 241 unsigned int has_null_flush:1; /* include null flush request */
242 unsigned int has_flush_payload:1; /* include flush payload */
242 /* 243 /*
243 * io isn't sent yet, flush/fua request can only be submitted till it's 244 * io isn't sent yet, flush/fua request can only be submitted till it's
244 * the first IO in running_ios list 245 * the first IO in running_ios list
@@ -571,6 +572,8 @@ static void r5l_log_endio(struct bio *bio)
571 struct r5l_io_unit *io_deferred; 572 struct r5l_io_unit *io_deferred;
572 struct r5l_log *log = io->log; 573 struct r5l_log *log = io->log;
573 unsigned long flags; 574 unsigned long flags;
575 bool has_null_flush;
576 bool has_flush_payload;
574 577
575 if (bio->bi_status) 578 if (bio->bi_status)
576 md_error(log->rdev->mddev, log->rdev); 579 md_error(log->rdev->mddev, log->rdev);
@@ -580,6 +583,16 @@ static void r5l_log_endio(struct bio *bio)
580 583
581 spin_lock_irqsave(&log->io_list_lock, flags); 584 spin_lock_irqsave(&log->io_list_lock, flags);
582 __r5l_set_io_unit_state(io, IO_UNIT_IO_END); 585 __r5l_set_io_unit_state(io, IO_UNIT_IO_END);
586
587 /*
588 * if the io doesn't not have null_flush or flush payload,
589 * it is not safe to access it after releasing io_list_lock.
590 * Therefore, it is necessary to check the condition with
591 * the lock held.
592 */
593 has_null_flush = io->has_null_flush;
594 has_flush_payload = io->has_flush_payload;
595
583 if (log->need_cache_flush && !list_empty(&io->stripe_list)) 596 if (log->need_cache_flush && !list_empty(&io->stripe_list))
584 r5l_move_to_end_ios(log); 597 r5l_move_to_end_ios(log);
585 else 598 else
@@ -600,19 +613,23 @@ static void r5l_log_endio(struct bio *bio)
600 if (log->need_cache_flush) 613 if (log->need_cache_flush)
601 md_wakeup_thread(log->rdev->mddev->thread); 614 md_wakeup_thread(log->rdev->mddev->thread);
602 615
603 if (io->has_null_flush) { 616 /* finish flush only io_unit and PAYLOAD_FLUSH only io_unit */
617 if (has_null_flush) {
604 struct bio *bi; 618 struct bio *bi;
605 619
606 WARN_ON(bio_list_empty(&io->flush_barriers)); 620 WARN_ON(bio_list_empty(&io->flush_barriers));
607 while ((bi = bio_list_pop(&io->flush_barriers)) != NULL) { 621 while ((bi = bio_list_pop(&io->flush_barriers)) != NULL) {
608 bio_endio(bi); 622 bio_endio(bi);
609 atomic_dec(&io->pending_stripe); 623 if (atomic_dec_and_test(&io->pending_stripe)) {
624 __r5l_stripe_write_finished(io);
625 return;
626 }
610 } 627 }
611 } 628 }
612 629 /* decrease pending_stripe for flush payload */
613 /* finish flush only io_unit and PAYLOAD_FLUSH only io_unit */ 630 if (has_flush_payload)
614 if (atomic_read(&io->pending_stripe) == 0) 631 if (atomic_dec_and_test(&io->pending_stripe))
615 __r5l_stripe_write_finished(io); 632 __r5l_stripe_write_finished(io);
616} 633}
617 634
618static void r5l_do_submit_io(struct r5l_log *log, struct r5l_io_unit *io) 635static void r5l_do_submit_io(struct r5l_log *log, struct r5l_io_unit *io)
@@ -881,6 +898,11 @@ static void r5l_append_flush_payload(struct r5l_log *log, sector_t sect)
881 payload->size = cpu_to_le32(sizeof(__le64)); 898 payload->size = cpu_to_le32(sizeof(__le64));
882 payload->flush_stripes[0] = cpu_to_le64(sect); 899 payload->flush_stripes[0] = cpu_to_le64(sect);
883 io->meta_offset += meta_size; 900 io->meta_offset += meta_size;
901 /* multiple flush payloads count as one pending_stripe */
902 if (!io->has_flush_payload) {
903 io->has_flush_payload = 1;
904 atomic_inc(&io->pending_stripe);
905 }
884 mutex_unlock(&log->io_mutex); 906 mutex_unlock(&log->io_mutex);
885} 907}
886 908
@@ -2540,23 +2562,32 @@ static ssize_t r5c_journal_mode_show(struct mddev *mddev, char *page)
2540 */ 2562 */
2541int r5c_journal_mode_set(struct mddev *mddev, int mode) 2563int r5c_journal_mode_set(struct mddev *mddev, int mode)
2542{ 2564{
2543 struct r5conf *conf = mddev->private; 2565 struct r5conf *conf;
2544 struct r5l_log *log = conf->log; 2566 int err;
2545
2546 if (!log)
2547 return -ENODEV;
2548 2567
2549 if (mode < R5C_JOURNAL_MODE_WRITE_THROUGH || 2568 if (mode < R5C_JOURNAL_MODE_WRITE_THROUGH ||
2550 mode > R5C_JOURNAL_MODE_WRITE_BACK) 2569 mode > R5C_JOURNAL_MODE_WRITE_BACK)
2551 return -EINVAL; 2570 return -EINVAL;
2552 2571
2572 err = mddev_lock(mddev);
2573 if (err)
2574 return err;
2575 conf = mddev->private;
2576 if (!conf || !conf->log) {
2577 mddev_unlock(mddev);
2578 return -ENODEV;
2579 }
2580
2553 if (raid5_calc_degraded(conf) > 0 && 2581 if (raid5_calc_degraded(conf) > 0 &&
2554 mode == R5C_JOURNAL_MODE_WRITE_BACK) 2582 mode == R5C_JOURNAL_MODE_WRITE_BACK) {
2583 mddev_unlock(mddev);
2555 return -EINVAL; 2584 return -EINVAL;
2585 }
2556 2586
2557 mddev_suspend(mddev); 2587 mddev_suspend(mddev);
2558 conf->log->r5c_journal_mode = mode; 2588 conf->log->r5c_journal_mode = mode;
2559 mddev_resume(mddev); 2589 mddev_resume(mddev);
2590 mddev_unlock(mddev);
2560 2591
2561 pr_debug("md/raid:%s: setting r5c cache mode to %d: %s\n", 2592 pr_debug("md/raid:%s: setting r5c cache mode to %d: %s\n",
2562 mdname(mddev), mode, r5c_journal_mode_str[mode]); 2593 mdname(mddev), mode, r5c_journal_mode_str[mode]);
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 9bee6c1c70cc..fc63992ab0e0 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -1569,7 +1569,8 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
1569 new_slave->delay = 0; 1569 new_slave->delay = 0;
1570 new_slave->link_failure_count = 0; 1570 new_slave->link_failure_count = 0;
1571 1571
1572 if (bond_update_speed_duplex(new_slave)) 1572 if (bond_update_speed_duplex(new_slave) &&
1573 bond_needs_speed_duplex(bond))
1573 new_slave->link = BOND_LINK_DOWN; 1574 new_slave->link = BOND_LINK_DOWN;
1574 1575
1575 new_slave->last_rx = jiffies - 1576 new_slave->last_rx = jiffies -
@@ -2140,11 +2141,13 @@ static void bond_miimon_commit(struct bonding *bond)
2140 continue; 2141 continue;
2141 2142
2142 case BOND_LINK_UP: 2143 case BOND_LINK_UP:
2143 if (bond_update_speed_duplex(slave)) { 2144 if (bond_update_speed_duplex(slave) &&
2145 bond_needs_speed_duplex(bond)) {
2144 slave->link = BOND_LINK_DOWN; 2146 slave->link = BOND_LINK_DOWN;
2145 netdev_warn(bond->dev, 2147 if (net_ratelimit())
2146 "failed to get link speed/duplex for %s\n", 2148 netdev_warn(bond->dev,
2147 slave->dev->name); 2149 "failed to get link speed/duplex for %s\n",
2150 slave->dev->name);
2148 continue; 2151 continue;
2149 } 2152 }
2150 bond_set_slave_link_state(slave, BOND_LINK_UP, 2153 bond_set_slave_link_state(slave, BOND_LINK_UP,
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
index ef4be781fd05..09ea62ee96d3 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
@@ -529,6 +529,7 @@ enum { /* adapter flags */
529 USING_SOFT_PARAMS = (1 << 6), 529 USING_SOFT_PARAMS = (1 << 6),
530 MASTER_PF = (1 << 7), 530 MASTER_PF = (1 << 7),
531 FW_OFLD_CONN = (1 << 9), 531 FW_OFLD_CONN = (1 << 9),
532 ROOT_NO_RELAXED_ORDERING = (1 << 10),
532}; 533};
533 534
534enum { 535enum {
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index e403fa18f1b1..33bb8678833a 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -4654,11 +4654,6 @@ static void print_port_info(const struct net_device *dev)
4654 dev->name, adap->params.vpd.id, adap->name, buf); 4654 dev->name, adap->params.vpd.id, adap->name, buf);
4655} 4655}
4656 4656
4657static void enable_pcie_relaxed_ordering(struct pci_dev *dev)
4658{
4659 pcie_capability_set_word(dev, PCI_EXP_DEVCTL, PCI_EXP_DEVCTL_RELAX_EN);
4660}
4661
4662/* 4657/*
4663 * Free the following resources: 4658 * Free the following resources:
4664 * - memory used for tables 4659 * - memory used for tables
@@ -4908,7 +4903,6 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
4908 } 4903 }
4909 4904
4910 pci_enable_pcie_error_reporting(pdev); 4905 pci_enable_pcie_error_reporting(pdev);
4911 enable_pcie_relaxed_ordering(pdev);
4912 pci_set_master(pdev); 4906 pci_set_master(pdev);
4913 pci_save_state(pdev); 4907 pci_save_state(pdev);
4914 4908
@@ -4947,6 +4941,23 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
4947 adapter->msg_enable = DFLT_MSG_ENABLE; 4941 adapter->msg_enable = DFLT_MSG_ENABLE;
4948 memset(adapter->chan_map, 0xff, sizeof(adapter->chan_map)); 4942 memset(adapter->chan_map, 0xff, sizeof(adapter->chan_map));
4949 4943
4944 /* If possible, we use PCIe Relaxed Ordering Attribute to deliver
4945 * Ingress Packet Data to Free List Buffers in order to allow for
4946 * chipset performance optimizations between the Root Complex and
4947 * Memory Controllers. (Messages to the associated Ingress Queue
4948 * notifying new Packet Placement in the Free Lists Buffers will be
4949 * send without the Relaxed Ordering Attribute thus guaranteeing that
4950 * all preceding PCIe Transaction Layer Packets will be processed
4951 * first.) But some Root Complexes have various issues with Upstream
4952 * Transaction Layer Packets with the Relaxed Ordering Attribute set.
4953 * The PCIe devices which under the Root Complexes will be cleared the
4954 * Relaxed Ordering bit in the configuration space, So we check our
4955 * PCIe configuration space to see if it's flagged with advice against
4956 * using Relaxed Ordering.
4957 */
4958 if (!pcie_relaxed_ordering_enabled(pdev))
4959 adapter->flags |= ROOT_NO_RELAXED_ORDERING;
4960
4950 spin_lock_init(&adapter->stats_lock); 4961 spin_lock_init(&adapter->stats_lock);
4951 spin_lock_init(&adapter->tid_release_lock); 4962 spin_lock_init(&adapter->tid_release_lock);
4952 spin_lock_init(&adapter->win0_lock); 4963 spin_lock_init(&adapter->win0_lock);
diff --git a/drivers/net/ethernet/chelsio/cxgb4/sge.c b/drivers/net/ethernet/chelsio/cxgb4/sge.c
index ede12209f20b..4ef68f69b58c 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/sge.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/sge.c
@@ -2719,6 +2719,7 @@ int t4_sge_alloc_rxq(struct adapter *adap, struct sge_rspq *iq, bool fwevtq,
2719 struct fw_iq_cmd c; 2719 struct fw_iq_cmd c;
2720 struct sge *s = &adap->sge; 2720 struct sge *s = &adap->sge;
2721 struct port_info *pi = netdev_priv(dev); 2721 struct port_info *pi = netdev_priv(dev);
2722 int relaxed = !(adap->flags & ROOT_NO_RELAXED_ORDERING);
2722 2723
2723 /* Size needs to be multiple of 16, including status entry. */ 2724 /* Size needs to be multiple of 16, including status entry. */
2724 iq->size = roundup(iq->size, 16); 2725 iq->size = roundup(iq->size, 16);
@@ -2772,8 +2773,8 @@ int t4_sge_alloc_rxq(struct adapter *adap, struct sge_rspq *iq, bool fwevtq,
2772 2773
2773 flsz = fl->size / 8 + s->stat_len / sizeof(struct tx_desc); 2774 flsz = fl->size / 8 + s->stat_len / sizeof(struct tx_desc);
2774 c.iqns_to_fl0congen |= htonl(FW_IQ_CMD_FL0PACKEN_F | 2775 c.iqns_to_fl0congen |= htonl(FW_IQ_CMD_FL0PACKEN_F |
2775 FW_IQ_CMD_FL0FETCHRO_F | 2776 FW_IQ_CMD_FL0FETCHRO_V(relaxed) |
2776 FW_IQ_CMD_FL0DATARO_F | 2777 FW_IQ_CMD_FL0DATARO_V(relaxed) |
2777 FW_IQ_CMD_FL0PADEN_F); 2778 FW_IQ_CMD_FL0PADEN_F);
2778 if (cong >= 0) 2779 if (cong >= 0)
2779 c.iqns_to_fl0congen |= 2780 c.iqns_to_fl0congen |=
diff --git a/drivers/net/ethernet/chelsio/cxgb4vf/adapter.h b/drivers/net/ethernet/chelsio/cxgb4vf/adapter.h
index 109bc630408b..08c6ddb84a04 100644
--- a/drivers/net/ethernet/chelsio/cxgb4vf/adapter.h
+++ b/drivers/net/ethernet/chelsio/cxgb4vf/adapter.h
@@ -408,6 +408,7 @@ enum { /* adapter flags */
408 USING_MSI = (1UL << 1), 408 USING_MSI = (1UL << 1),
409 USING_MSIX = (1UL << 2), 409 USING_MSIX = (1UL << 2),
410 QUEUES_BOUND = (1UL << 3), 410 QUEUES_BOUND = (1UL << 3),
411 ROOT_NO_RELAXED_ORDERING = (1UL << 4),
411}; 412};
412 413
413/* 414/*
diff --git a/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c b/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
index ac7a150c54e9..2b85b874fd0d 100644
--- a/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
@@ -2888,6 +2888,24 @@ static int cxgb4vf_pci_probe(struct pci_dev *pdev,
2888 */ 2888 */
2889 adapter->name = pci_name(pdev); 2889 adapter->name = pci_name(pdev);
2890 adapter->msg_enable = DFLT_MSG_ENABLE; 2890 adapter->msg_enable = DFLT_MSG_ENABLE;
2891
2892 /* If possible, we use PCIe Relaxed Ordering Attribute to deliver
2893 * Ingress Packet Data to Free List Buffers in order to allow for
2894 * chipset performance optimizations between the Root Complex and
2895 * Memory Controllers. (Messages to the associated Ingress Queue
2896 * notifying new Packet Placement in the Free Lists Buffers will be
2897 * send without the Relaxed Ordering Attribute thus guaranteeing that
2898 * all preceding PCIe Transaction Layer Packets will be processed
2899 * first.) But some Root Complexes have various issues with Upstream
2900 * Transaction Layer Packets with the Relaxed Ordering Attribute set.
2901 * The PCIe devices which under the Root Complexes will be cleared the
2902 * Relaxed Ordering bit in the configuration space, So we check our
2903 * PCIe configuration space to see if it's flagged with advice against
2904 * using Relaxed Ordering.
2905 */
2906 if (!pcie_relaxed_ordering_enabled(pdev))
2907 adapter->flags |= ROOT_NO_RELAXED_ORDERING;
2908
2891 err = adap_init0(adapter); 2909 err = adap_init0(adapter);
2892 if (err) 2910 if (err)
2893 goto err_unmap_bar; 2911 goto err_unmap_bar;
diff --git a/drivers/net/ethernet/chelsio/cxgb4vf/sge.c b/drivers/net/ethernet/chelsio/cxgb4vf/sge.c
index e37dde2ba97f..05498e7f2840 100644
--- a/drivers/net/ethernet/chelsio/cxgb4vf/sge.c
+++ b/drivers/net/ethernet/chelsio/cxgb4vf/sge.c
@@ -2205,6 +2205,7 @@ int t4vf_sge_alloc_rxq(struct adapter *adapter, struct sge_rspq *rspq,
2205 struct port_info *pi = netdev_priv(dev); 2205 struct port_info *pi = netdev_priv(dev);
2206 struct fw_iq_cmd cmd, rpl; 2206 struct fw_iq_cmd cmd, rpl;
2207 int ret, iqandst, flsz = 0; 2207 int ret, iqandst, flsz = 0;
2208 int relaxed = !(adapter->flags & ROOT_NO_RELAXED_ORDERING);
2208 2209
2209 /* 2210 /*
2210 * If we're using MSI interrupts and we're not initializing the 2211 * If we're using MSI interrupts and we're not initializing the
@@ -2300,6 +2301,8 @@ int t4vf_sge_alloc_rxq(struct adapter *adapter, struct sge_rspq *rspq,
2300 cpu_to_be32( 2301 cpu_to_be32(
2301 FW_IQ_CMD_FL0HOSTFCMODE_V(SGE_HOSTFCMODE_NONE) | 2302 FW_IQ_CMD_FL0HOSTFCMODE_V(SGE_HOSTFCMODE_NONE) |
2302 FW_IQ_CMD_FL0PACKEN_F | 2303 FW_IQ_CMD_FL0PACKEN_F |
2304 FW_IQ_CMD_FL0FETCHRO_V(relaxed) |
2305 FW_IQ_CMD_FL0DATARO_V(relaxed) |
2303 FW_IQ_CMD_FL0PADEN_F); 2306 FW_IQ_CMD_FL0PADEN_F);
2304 2307
2305 /* In T6, for egress queue type FL there is internal overhead 2308 /* In T6, for egress queue type FL there is internal overhead
diff --git a/drivers/net/ethernet/netronome/nfp/flower/cmsg.c b/drivers/net/ethernet/netronome/nfp/flower/cmsg.c
index dd7fa9cf225f..b0837b58c3a1 100644
--- a/drivers/net/ethernet/netronome/nfp/flower/cmsg.c
+++ b/drivers/net/ethernet/netronome/nfp/flower/cmsg.c
@@ -115,14 +115,10 @@ nfp_flower_cmsg_portmod_rx(struct nfp_app *app, struct sk_buff *skb)
115 return; 115 return;
116 } 116 }
117 117
118 if (link) { 118 if (link)
119 netif_carrier_on(netdev); 119 netif_carrier_on(netdev);
120 rtnl_lock(); 120 else
121 dev_set_mtu(netdev, be16_to_cpu(msg->mtu));
122 rtnl_unlock();
123 } else {
124 netif_carrier_off(netdev); 121 netif_carrier_off(netdev);
125 }
126 rcu_read_unlock(); 122 rcu_read_unlock();
127} 123}
128 124
diff --git a/drivers/net/ethernet/sfc/mcdi_port.c b/drivers/net/ethernet/sfc/mcdi_port.c
index c905971c5f3a..990a63d7fcb7 100644
--- a/drivers/net/ethernet/sfc/mcdi_port.c
+++ b/drivers/net/ethernet/sfc/mcdi_port.c
@@ -938,7 +938,6 @@ enum efx_stats_action {
938static int efx_mcdi_mac_stats(struct efx_nic *efx, 938static int efx_mcdi_mac_stats(struct efx_nic *efx,
939 enum efx_stats_action action, int clear) 939 enum efx_stats_action action, int clear)
940{ 940{
941 struct efx_ef10_nic_data *nic_data = efx->nic_data;
942 MCDI_DECLARE_BUF(inbuf, MC_CMD_MAC_STATS_IN_LEN); 941 MCDI_DECLARE_BUF(inbuf, MC_CMD_MAC_STATS_IN_LEN);
943 int rc; 942 int rc;
944 int change = action == EFX_STATS_PULL ? 0 : 1; 943 int change = action == EFX_STATS_PULL ? 0 : 1;
@@ -960,7 +959,12 @@ static int efx_mcdi_mac_stats(struct efx_nic *efx,
960 MAC_STATS_IN_PERIODIC_NOEVENT, 1, 959 MAC_STATS_IN_PERIODIC_NOEVENT, 1,
961 MAC_STATS_IN_PERIOD_MS, period); 960 MAC_STATS_IN_PERIOD_MS, period);
962 MCDI_SET_DWORD(inbuf, MAC_STATS_IN_DMA_LEN, dma_len); 961 MCDI_SET_DWORD(inbuf, MAC_STATS_IN_DMA_LEN, dma_len);
963 MCDI_SET_DWORD(inbuf, MAC_STATS_IN_PORT_ID, nic_data->vport_id); 962
963 if (efx_nic_rev(efx) >= EFX_REV_HUNT_A0) {
964 struct efx_ef10_nic_data *nic_data = efx->nic_data;
965
966 MCDI_SET_DWORD(inbuf, MAC_STATS_IN_PORT_ID, nic_data->vport_id);
967 }
964 968
965 rc = efx_mcdi_rpc_quiet(efx, MC_CMD_MAC_STATS, inbuf, sizeof(inbuf), 969 rc = efx_mcdi_rpc_quiet(efx, MC_CMD_MAC_STATS, inbuf, sizeof(inbuf),
966 NULL, 0, NULL); 970 NULL, 0, NULL);
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
index db157a47000c..72ec711fcba2 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
@@ -204,6 +204,7 @@ int stmmac_mdio_register(struct net_device *ndev)
204 struct stmmac_priv *priv = netdev_priv(ndev); 204 struct stmmac_priv *priv = netdev_priv(ndev);
205 struct stmmac_mdio_bus_data *mdio_bus_data = priv->plat->mdio_bus_data; 205 struct stmmac_mdio_bus_data *mdio_bus_data = priv->plat->mdio_bus_data;
206 struct device_node *mdio_node = priv->plat->mdio_node; 206 struct device_node *mdio_node = priv->plat->mdio_node;
207 struct device *dev = ndev->dev.parent;
207 int addr, found; 208 int addr, found;
208 209
209 if (!mdio_bus_data) 210 if (!mdio_bus_data)
@@ -237,7 +238,7 @@ int stmmac_mdio_register(struct net_device *ndev)
237 else 238 else
238 err = mdiobus_register(new_bus); 239 err = mdiobus_register(new_bus);
239 if (err != 0) { 240 if (err != 0) {
240 netdev_err(ndev, "Cannot register the MDIO bus\n"); 241 dev_err(dev, "Cannot register the MDIO bus\n");
241 goto bus_register_fail; 242 goto bus_register_fail;
242 } 243 }
243 244
@@ -285,14 +286,12 @@ int stmmac_mdio_register(struct net_device *ndev)
285 irq_str = irq_num; 286 irq_str = irq_num;
286 break; 287 break;
287 } 288 }
288 netdev_info(ndev, "PHY ID %08x at %d IRQ %s (%s)%s\n", 289 phy_attached_info(phydev);
289 phydev->phy_id, addr, irq_str, phydev_name(phydev),
290 act ? " active" : "");
291 found = 1; 290 found = 1;
292 } 291 }
293 292
294 if (!found && !mdio_node) { 293 if (!found && !mdio_node) {
295 netdev_warn(ndev, "No PHY found\n"); 294 dev_warn(dev, "No PHY found\n");
296 mdiobus_unregister(new_bus); 295 mdiobus_unregister(new_bus);
297 mdiobus_free(new_bus); 296 mdiobus_free(new_bus);
298 return -ENODEV; 297 return -ENODEV;
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.c
index d21258d277ce..f1b60740e020 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.c
@@ -159,8 +159,10 @@ void brcmf_feat_attach(struct brcmf_pub *drvr)
159 159
160 brcmf_feat_firmware_capabilities(ifp); 160 brcmf_feat_firmware_capabilities(ifp);
161 memset(&gscan_cfg, 0, sizeof(gscan_cfg)); 161 memset(&gscan_cfg, 0, sizeof(gscan_cfg));
162 brcmf_feat_iovar_data_set(ifp, BRCMF_FEAT_GSCAN, "pfn_gscan_cfg", 162 if (drvr->bus_if->chip != BRCM_CC_43430_CHIP_ID)
163 &gscan_cfg, sizeof(gscan_cfg)); 163 brcmf_feat_iovar_data_set(ifp, BRCMF_FEAT_GSCAN,
164 "pfn_gscan_cfg",
165 &gscan_cfg, sizeof(gscan_cfg));
164 brcmf_feat_iovar_int_get(ifp, BRCMF_FEAT_PNO, "pfn"); 166 brcmf_feat_iovar_int_get(ifp, BRCMF_FEAT_PNO, "pfn");
165 if (drvr->bus_if->wowl_supported) 167 if (drvr->bus_if->wowl_supported)
166 brcmf_feat_iovar_int_get(ifp, BRCMF_FEAT_WOWL, "wowl"); 168 brcmf_feat_iovar_int_get(ifp, BRCMF_FEAT_WOWL, "wowl");
diff --git a/drivers/net/wireless/intel/iwlwifi/cfg/9000.c b/drivers/net/wireless/intel/iwlwifi/cfg/9000.c
index b4ecd1fe1374..97208ce19f92 100644
--- a/drivers/net/wireless/intel/iwlwifi/cfg/9000.c
+++ b/drivers/net/wireless/intel/iwlwifi/cfg/9000.c
@@ -154,7 +154,7 @@ static const struct iwl_tt_params iwl9000_tt_params = {
154const struct iwl_cfg iwl9160_2ac_cfg = { 154const struct iwl_cfg iwl9160_2ac_cfg = {
155 .name = "Intel(R) Dual Band Wireless AC 9160", 155 .name = "Intel(R) Dual Band Wireless AC 9160",
156 .fw_name_pre = IWL9260A_FW_PRE, 156 .fw_name_pre = IWL9260A_FW_PRE,
157 .fw_name_pre_next_step = IWL9260B_FW_PRE, 157 .fw_name_pre_b_or_c_step = IWL9260B_FW_PRE,
158 IWL_DEVICE_9000, 158 IWL_DEVICE_9000,
159 .ht_params = &iwl9000_ht_params, 159 .ht_params = &iwl9000_ht_params,
160 .nvm_ver = IWL9000_NVM_VERSION, 160 .nvm_ver = IWL9000_NVM_VERSION,
@@ -165,7 +165,7 @@ const struct iwl_cfg iwl9160_2ac_cfg = {
165const struct iwl_cfg iwl9260_2ac_cfg = { 165const struct iwl_cfg iwl9260_2ac_cfg = {
166 .name = "Intel(R) Dual Band Wireless AC 9260", 166 .name = "Intel(R) Dual Band Wireless AC 9260",
167 .fw_name_pre = IWL9260A_FW_PRE, 167 .fw_name_pre = IWL9260A_FW_PRE,
168 .fw_name_pre_next_step = IWL9260B_FW_PRE, 168 .fw_name_pre_b_or_c_step = IWL9260B_FW_PRE,
169 IWL_DEVICE_9000, 169 IWL_DEVICE_9000,
170 .ht_params = &iwl9000_ht_params, 170 .ht_params = &iwl9000_ht_params,
171 .nvm_ver = IWL9000_NVM_VERSION, 171 .nvm_ver = IWL9000_NVM_VERSION,
@@ -176,7 +176,7 @@ const struct iwl_cfg iwl9260_2ac_cfg = {
176const struct iwl_cfg iwl9270_2ac_cfg = { 176const struct iwl_cfg iwl9270_2ac_cfg = {
177 .name = "Intel(R) Dual Band Wireless AC 9270", 177 .name = "Intel(R) Dual Band Wireless AC 9270",
178 .fw_name_pre = IWL9260A_FW_PRE, 178 .fw_name_pre = IWL9260A_FW_PRE,
179 .fw_name_pre_next_step = IWL9260B_FW_PRE, 179 .fw_name_pre_b_or_c_step = IWL9260B_FW_PRE,
180 IWL_DEVICE_9000, 180 IWL_DEVICE_9000,
181 .ht_params = &iwl9000_ht_params, 181 .ht_params = &iwl9000_ht_params,
182 .nvm_ver = IWL9000_NVM_VERSION, 182 .nvm_ver = IWL9000_NVM_VERSION,
@@ -186,8 +186,8 @@ const struct iwl_cfg iwl9270_2ac_cfg = {
186 186
187const struct iwl_cfg iwl9460_2ac_cfg = { 187const struct iwl_cfg iwl9460_2ac_cfg = {
188 .name = "Intel(R) Dual Band Wireless AC 9460", 188 .name = "Intel(R) Dual Band Wireless AC 9460",
189 .fw_name_pre = IWL9000_FW_PRE, 189 .fw_name_pre = IWL9260A_FW_PRE,
190 .fw_name_pre_rf_next_step = IWL9000RFB_FW_PRE, 190 .fw_name_pre_b_or_c_step = IWL9260B_FW_PRE,
191 IWL_DEVICE_9000, 191 IWL_DEVICE_9000,
192 .ht_params = &iwl9000_ht_params, 192 .ht_params = &iwl9000_ht_params,
193 .nvm_ver = IWL9000_NVM_VERSION, 193 .nvm_ver = IWL9000_NVM_VERSION,
@@ -198,8 +198,8 @@ const struct iwl_cfg iwl9460_2ac_cfg = {
198 198
199const struct iwl_cfg iwl9560_2ac_cfg = { 199const struct iwl_cfg iwl9560_2ac_cfg = {
200 .name = "Intel(R) Dual Band Wireless AC 9560", 200 .name = "Intel(R) Dual Band Wireless AC 9560",
201 .fw_name_pre = IWL9000_FW_PRE, 201 .fw_name_pre = IWL9260A_FW_PRE,
202 .fw_name_pre_rf_next_step = IWL9000RFB_FW_PRE, 202 .fw_name_pre_b_or_c_step = IWL9260B_FW_PRE,
203 IWL_DEVICE_9000, 203 IWL_DEVICE_9000,
204 .ht_params = &iwl9000_ht_params, 204 .ht_params = &iwl9000_ht_params,
205 .nvm_ver = IWL9000_NVM_VERSION, 205 .nvm_ver = IWL9000_NVM_VERSION,
diff --git a/drivers/net/wireless/intel/iwlwifi/fw/file.h b/drivers/net/wireless/intel/iwlwifi/fw/file.h
index 0fa8c473f1e2..c73a6438ce8f 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/file.h
+++ b/drivers/net/wireless/intel/iwlwifi/fw/file.h
@@ -328,6 +328,7 @@ typedef unsigned int __bitwise iwl_ucode_tlv_capa_t;
328 * @IWL_UCODE_TLV_CAPA_TX_POWER_ACK: reduced TX power API has larger 328 * @IWL_UCODE_TLV_CAPA_TX_POWER_ACK: reduced TX power API has larger
329 * command size (command version 4) that supports toggling ACK TX 329 * command size (command version 4) that supports toggling ACK TX
330 * power reduction. 330 * power reduction.
331 * @IWL_UCODE_TLV_CAPA_MLME_OFFLOAD: supports MLME offload
331 * 332 *
332 * @NUM_IWL_UCODE_TLV_CAPA: number of bits used 333 * @NUM_IWL_UCODE_TLV_CAPA: number of bits used
333 */ 334 */
@@ -373,6 +374,7 @@ enum iwl_ucode_tlv_capa {
373 IWL_UCODE_TLV_CAPA_EXTEND_SHARED_MEM_CFG = (__force iwl_ucode_tlv_capa_t)80, 374 IWL_UCODE_TLV_CAPA_EXTEND_SHARED_MEM_CFG = (__force iwl_ucode_tlv_capa_t)80,
374 IWL_UCODE_TLV_CAPA_LQM_SUPPORT = (__force iwl_ucode_tlv_capa_t)81, 375 IWL_UCODE_TLV_CAPA_LQM_SUPPORT = (__force iwl_ucode_tlv_capa_t)81,
375 IWL_UCODE_TLV_CAPA_TX_POWER_ACK = (__force iwl_ucode_tlv_capa_t)84, 376 IWL_UCODE_TLV_CAPA_TX_POWER_ACK = (__force iwl_ucode_tlv_capa_t)84,
377 IWL_UCODE_TLV_CAPA_MLME_OFFLOAD = (__force iwl_ucode_tlv_capa_t)96,
376 378
377 NUM_IWL_UCODE_TLV_CAPA 379 NUM_IWL_UCODE_TLV_CAPA
378#ifdef __CHECKER__ 380#ifdef __CHECKER__
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-config.h b/drivers/net/wireless/intel/iwlwifi/iwl-config.h
index c52623cb7c2a..d19c74827fbb 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-config.h
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-config.h
@@ -276,10 +276,10 @@ struct iwl_pwr_tx_backoff {
276 * @fw_name_pre: Firmware filename prefix. The api version and extension 276 * @fw_name_pre: Firmware filename prefix. The api version and extension
277 * (.ucode) will be added to filename before loading from disk. The 277 * (.ucode) will be added to filename before loading from disk. The
278 * filename is constructed as fw_name_pre<api>.ucode. 278 * filename is constructed as fw_name_pre<api>.ucode.
279 * @fw_name_pre_next_step: same as @fw_name_pre, only for next step 279 * @fw_name_pre_b_or_c_step: same as @fw_name_pre, only for b or c steps
280 * (if supported) 280 * (if supported)
281 * @fw_name_pre_rf_next_step: same as @fw_name_pre_next_step, only for rf next 281 * @fw_name_pre_rf_next_step: same as @fw_name_pre_b_or_c_step, only for rf
282 * step. Supported only in integrated solutions. 282 * next step. Supported only in integrated solutions.
283 * @ucode_api_max: Highest version of uCode API supported by driver. 283 * @ucode_api_max: Highest version of uCode API supported by driver.
284 * @ucode_api_min: Lowest version of uCode API supported by driver. 284 * @ucode_api_min: Lowest version of uCode API supported by driver.
285 * @max_inst_size: The maximal length of the fw inst section 285 * @max_inst_size: The maximal length of the fw inst section
@@ -330,7 +330,7 @@ struct iwl_cfg {
330 /* params specific to an individual device within a device family */ 330 /* params specific to an individual device within a device family */
331 const char *name; 331 const char *name;
332 const char *fw_name_pre; 332 const char *fw_name_pre;
333 const char *fw_name_pre_next_step; 333 const char *fw_name_pre_b_or_c_step;
334 const char *fw_name_pre_rf_next_step; 334 const char *fw_name_pre_rf_next_step;
335 /* params not likely to change within a device family */ 335 /* params not likely to change within a device family */
336 const struct iwl_base_params *base_params; 336 const struct iwl_base_params *base_params;
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-drv.c b/drivers/net/wireless/intel/iwlwifi/iwl-drv.c
index 6fdb5921e17f..4e0f86fe0a6f 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-drv.c
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-drv.c
@@ -216,8 +216,9 @@ static int iwl_request_firmware(struct iwl_drv *drv, bool first)
216 const char *fw_pre_name; 216 const char *fw_pre_name;
217 217
218 if (drv->trans->cfg->device_family == IWL_DEVICE_FAMILY_9000 && 218 if (drv->trans->cfg->device_family == IWL_DEVICE_FAMILY_9000 &&
219 CSR_HW_REV_STEP(drv->trans->hw_rev) == SILICON_B_STEP) 219 (CSR_HW_REV_STEP(drv->trans->hw_rev) == SILICON_B_STEP ||
220 fw_pre_name = cfg->fw_name_pre_next_step; 220 CSR_HW_REV_STEP(drv->trans->hw_rev) == SILICON_C_STEP))
221 fw_pre_name = cfg->fw_name_pre_b_or_c_step;
221 else if (drv->trans->cfg->integrated && 222 else if (drv->trans->cfg->integrated &&
222 CSR_HW_RFID_STEP(drv->trans->hw_rf_id) == SILICON_B_STEP && 223 CSR_HW_RFID_STEP(drv->trans->hw_rf_id) == SILICON_B_STEP &&
223 cfg->fw_name_pre_rf_next_step) 224 cfg->fw_name_pre_rf_next_step)
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c b/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c
index 5c08f4d40f6a..3ee6767392b6 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c
@@ -785,7 +785,8 @@ iwl_parse_nvm_mcc_info(struct device *dev, const struct iwl_cfg *cfg,
785 int num_of_ch, __le32 *channels, u16 fw_mcc) 785 int num_of_ch, __le32 *channels, u16 fw_mcc)
786{ 786{
787 int ch_idx; 787 int ch_idx;
788 u16 ch_flags, prev_ch_flags = 0; 788 u16 ch_flags;
789 u32 reg_rule_flags, prev_reg_rule_flags = 0;
789 const u8 *nvm_chan = cfg->ext_nvm ? 790 const u8 *nvm_chan = cfg->ext_nvm ?
790 iwl_ext_nvm_channels : iwl_nvm_channels; 791 iwl_ext_nvm_channels : iwl_nvm_channels;
791 struct ieee80211_regdomain *regd; 792 struct ieee80211_regdomain *regd;
@@ -834,8 +835,11 @@ iwl_parse_nvm_mcc_info(struct device *dev, const struct iwl_cfg *cfg,
834 continue; 835 continue;
835 } 836 }
836 837
838 reg_rule_flags = iwl_nvm_get_regdom_bw_flags(nvm_chan, ch_idx,
839 ch_flags, cfg);
840
837 /* we can't continue the same rule */ 841 /* we can't continue the same rule */
838 if (ch_idx == 0 || prev_ch_flags != ch_flags || 842 if (ch_idx == 0 || prev_reg_rule_flags != reg_rule_flags ||
839 center_freq - prev_center_freq > 20) { 843 center_freq - prev_center_freq > 20) {
840 valid_rules++; 844 valid_rules++;
841 new_rule = true; 845 new_rule = true;
@@ -854,18 +858,17 @@ iwl_parse_nvm_mcc_info(struct device *dev, const struct iwl_cfg *cfg,
854 rule->power_rule.max_eirp = 858 rule->power_rule.max_eirp =
855 DBM_TO_MBM(IWL_DEFAULT_MAX_TX_POWER); 859 DBM_TO_MBM(IWL_DEFAULT_MAX_TX_POWER);
856 860
857 rule->flags = iwl_nvm_get_regdom_bw_flags(nvm_chan, ch_idx, 861 rule->flags = reg_rule_flags;
858 ch_flags, cfg);
859 862
860 /* rely on auto-calculation to merge BW of contiguous chans */ 863 /* rely on auto-calculation to merge BW of contiguous chans */
861 rule->flags |= NL80211_RRF_AUTO_BW; 864 rule->flags |= NL80211_RRF_AUTO_BW;
862 rule->freq_range.max_bandwidth_khz = 0; 865 rule->freq_range.max_bandwidth_khz = 0;
863 866
864 prev_ch_flags = ch_flags;
865 prev_center_freq = center_freq; 867 prev_center_freq = center_freq;
868 prev_reg_rule_flags = reg_rule_flags;
866 869
867 IWL_DEBUG_DEV(dev, IWL_DL_LAR, 870 IWL_DEBUG_DEV(dev, IWL_DL_LAR,
868 "Ch. %d [%sGHz] %s%s%s%s%s%s%s%s%s(0x%02x): Ad-Hoc %ssupported\n", 871 "Ch. %d [%sGHz] %s%s%s%s%s%s%s%s%s(0x%02x) reg_flags 0x%x: %s\n",
869 center_freq, 872 center_freq,
870 band == NL80211_BAND_5GHZ ? "5.2" : "2.4", 873 band == NL80211_BAND_5GHZ ? "5.2" : "2.4",
871 CHECK_AND_PRINT_I(VALID), 874 CHECK_AND_PRINT_I(VALID),
@@ -877,10 +880,10 @@ iwl_parse_nvm_mcc_info(struct device *dev, const struct iwl_cfg *cfg,
877 CHECK_AND_PRINT_I(160MHZ), 880 CHECK_AND_PRINT_I(160MHZ),
878 CHECK_AND_PRINT_I(INDOOR_ONLY), 881 CHECK_AND_PRINT_I(INDOOR_ONLY),
879 CHECK_AND_PRINT_I(GO_CONCURRENT), 882 CHECK_AND_PRINT_I(GO_CONCURRENT),
880 ch_flags, 883 ch_flags, reg_rule_flags,
881 ((ch_flags & NVM_CHANNEL_ACTIVE) && 884 ((ch_flags & NVM_CHANNEL_ACTIVE) &&
882 !(ch_flags & NVM_CHANNEL_RADAR)) 885 !(ch_flags & NVM_CHANNEL_RADAR))
883 ? "" : "not "); 886 ? "Ad-Hoc" : "");
884 } 887 }
885 888
886 regd->n_reg_rules = valid_rules; 889 regd->n_reg_rules = valid_rules;
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/fw.c b/drivers/net/wireless/intel/iwlwifi/mvm/fw.c
index 79e7a7a285dc..82863e9273eb 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/fw.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw.c
@@ -1275,8 +1275,10 @@ static int iwl_mvm_sar_get_wgds_table(struct iwl_mvm *mvm)
1275 1275
1276 entry = &wifi_pkg->package.elements[idx++]; 1276 entry = &wifi_pkg->package.elements[idx++];
1277 if ((entry->type != ACPI_TYPE_INTEGER) || 1277 if ((entry->type != ACPI_TYPE_INTEGER) ||
1278 (entry->integer.value > U8_MAX)) 1278 (entry->integer.value > U8_MAX)) {
1279 return -EINVAL; 1279 ret = -EINVAL;
1280 goto out_free;
1281 }
1280 1282
1281 mvm->geo_profiles[i].values[j] = entry->integer.value; 1283 mvm->geo_profiles[i].values[j] = entry->integer.value;
1282 } 1284 }
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
index c7b1e58e3384..ce901be5fba8 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
@@ -2597,8 +2597,18 @@ static void iwl_mvm_purge_deferred_tx_frames(struct iwl_mvm *mvm,
2597 spin_lock_bh(&mvm_sta->lock); 2597 spin_lock_bh(&mvm_sta->lock);
2598 for (i = 0; i <= IWL_MAX_TID_COUNT; i++) { 2598 for (i = 0; i <= IWL_MAX_TID_COUNT; i++) {
2599 tid_data = &mvm_sta->tid_data[i]; 2599 tid_data = &mvm_sta->tid_data[i];
2600 while ((skb = __skb_dequeue(&tid_data->deferred_tx_frames))) 2600
2601 while ((skb = __skb_dequeue(&tid_data->deferred_tx_frames))) {
2602 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
2603
2604 /*
2605 * The first deferred frame should've stopped the MAC
2606 * queues, so we should never get a second deferred
2607 * frame for the RA/TID.
2608 */
2609 iwl_mvm_start_mac_queues(mvm, info->hw_queue);
2601 ieee80211_free_txskb(mvm->hw, skb); 2610 ieee80211_free_txskb(mvm->hw, skb);
2611 }
2602 } 2612 }
2603 spin_unlock_bh(&mvm_sta->lock); 2613 spin_unlock_bh(&mvm_sta->lock);
2604} 2614}
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/rs.c b/drivers/net/wireless/intel/iwlwifi/mvm/rs.c
index 65beca3a457a..8999a1199d60 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/rs.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/rs.c
@@ -1291,7 +1291,7 @@ void iwl_mvm_rs_tx_status(struct iwl_mvm *mvm, struct ieee80211_sta *sta,
1291 * first index into rate scale table. 1291 * first index into rate scale table.
1292 */ 1292 */
1293 if (info->flags & IEEE80211_TX_STAT_AMPDU) { 1293 if (info->flags & IEEE80211_TX_STAT_AMPDU) {
1294 rs_collect_tpc_data(mvm, lq_sta, curr_tbl, lq_rate.index, 1294 rs_collect_tpc_data(mvm, lq_sta, curr_tbl, tx_resp_rate.index,
1295 info->status.ampdu_len, 1295 info->status.ampdu_len,
1296 info->status.ampdu_ack_len, 1296 info->status.ampdu_ack_len,
1297 reduced_txp); 1297 reduced_txp);
@@ -1312,7 +1312,7 @@ void iwl_mvm_rs_tx_status(struct iwl_mvm *mvm, struct ieee80211_sta *sta,
1312 if (info->status.ampdu_ack_len == 0) 1312 if (info->status.ampdu_ack_len == 0)
1313 info->status.ampdu_len = 1; 1313 info->status.ampdu_len = 1;
1314 1314
1315 rs_collect_tlc_data(mvm, lq_sta, curr_tbl, lq_rate.index, 1315 rs_collect_tlc_data(mvm, lq_sta, curr_tbl, tx_resp_rate.index,
1316 info->status.ampdu_len, 1316 info->status.ampdu_len,
1317 info->status.ampdu_ack_len); 1317 info->status.ampdu_ack_len);
1318 1318
@@ -1348,11 +1348,11 @@ void iwl_mvm_rs_tx_status(struct iwl_mvm *mvm, struct ieee80211_sta *sta,
1348 continue; 1348 continue;
1349 1349
1350 rs_collect_tpc_data(mvm, lq_sta, tmp_tbl, 1350 rs_collect_tpc_data(mvm, lq_sta, tmp_tbl,
1351 lq_rate.index, 1, 1351 tx_resp_rate.index, 1,
1352 i < retries ? 0 : legacy_success, 1352 i < retries ? 0 : legacy_success,
1353 reduced_txp); 1353 reduced_txp);
1354 rs_collect_tlc_data(mvm, lq_sta, tmp_tbl, 1354 rs_collect_tlc_data(mvm, lq_sta, tmp_tbl,
1355 lq_rate.index, 1, 1355 tx_resp_rate.index, 1,
1356 i < retries ? 0 : legacy_success); 1356 i < retries ? 0 : legacy_success);
1357 } 1357 }
1358 1358
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c b/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c
index f3e608196369..71c8b800ffa9 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c
@@ -636,9 +636,9 @@ static bool iwl_mvm_reorder(struct iwl_mvm *mvm,
636 636
637 baid_data = rcu_dereference(mvm->baid_map[baid]); 637 baid_data = rcu_dereference(mvm->baid_map[baid]);
638 if (!baid_data) { 638 if (!baid_data) {
639 WARN(!(reorder & IWL_RX_MPDU_REORDER_BA_OLD_SN), 639 IWL_DEBUG_RX(mvm,
640 "Received baid %d, but no data exists for this BAID\n", 640 "Got valid BAID but no baid allocated, bypass the re-ordering buffer. Baid %d reorder 0x%x\n",
641 baid); 641 baid, reorder);
642 return false; 642 return false;
643 } 643 }
644 644
@@ -759,7 +759,9 @@ static void iwl_mvm_agg_rx_received(struct iwl_mvm *mvm,
759 759
760 data = rcu_dereference(mvm->baid_map[baid]); 760 data = rcu_dereference(mvm->baid_map[baid]);
761 if (!data) { 761 if (!data) {
762 WARN_ON(!(reorder_data & IWL_RX_MPDU_REORDER_BA_OLD_SN)); 762 IWL_DEBUG_RX(mvm,
763 "Got valid BAID but no baid allocated, bypass the re-ordering buffer. Baid %d reorder 0x%x\n",
764 baid, reorder_data);
763 goto out; 765 goto out;
764 } 766 }
765 767
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/sta.c b/drivers/net/wireless/intel/iwlwifi/mvm/sta.c
index ab66b4394dfc..027ee5e72172 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/sta.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/sta.c
@@ -121,7 +121,8 @@ int iwl_mvm_sta_send_to_fw(struct iwl_mvm *mvm, struct ieee80211_sta *sta,
121 .mac_id_n_color = cpu_to_le32(mvm_sta->mac_id_n_color), 121 .mac_id_n_color = cpu_to_le32(mvm_sta->mac_id_n_color),
122 .add_modify = update ? 1 : 0, 122 .add_modify = update ? 1 : 0,
123 .station_flags_msk = cpu_to_le32(STA_FLG_FAT_EN_MSK | 123 .station_flags_msk = cpu_to_le32(STA_FLG_FAT_EN_MSK |
124 STA_FLG_MIMO_EN_MSK), 124 STA_FLG_MIMO_EN_MSK |
125 STA_FLG_RTS_MIMO_PROT),
125 .tid_disable_tx = cpu_to_le16(mvm_sta->tid_disable_agg), 126 .tid_disable_tx = cpu_to_le16(mvm_sta->tid_disable_agg),
126 }; 127 };
127 int ret; 128 int ret;
@@ -290,8 +291,8 @@ static void iwl_mvm_rx_agg_session_expired(unsigned long data)
290 goto unlock; 291 goto unlock;
291 292
292 mvm_sta = iwl_mvm_sta_from_mac80211(sta); 293 mvm_sta = iwl_mvm_sta_from_mac80211(sta);
293 ieee80211_stop_rx_ba_session_offl(mvm_sta->vif, 294 ieee80211_rx_ba_timer_expired(mvm_sta->vif,
294 sta->addr, ba_data->tid); 295 sta->addr, ba_data->tid);
295unlock: 296unlock:
296 rcu_read_unlock(); 297 rcu_read_unlock();
297} 298}
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/tx.c b/drivers/net/wireless/intel/iwlwifi/mvm/tx.c
index 60360ed73f26..5fcc9dd6be56 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/tx.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/tx.c
@@ -185,8 +185,14 @@ static u16 iwl_mvm_tx_csum(struct iwl_mvm *mvm, struct sk_buff *skb,
185 else 185 else
186 udp_hdr(skb)->check = 0; 186 udp_hdr(skb)->check = 0;
187 187
188 /* mac header len should include IV, size is in words */ 188 /*
189 if (info->control.hw_key) 189 * mac header len should include IV, size is in words unless
190 * the IV is added by the firmware like in WEP.
191 * In new Tx API, the IV is always added by the firmware.
192 */
193 if (!iwl_mvm_has_new_tx_api(mvm) && info->control.hw_key &&
194 info->control.hw_key->cipher != WLAN_CIPHER_SUITE_WEP40 &&
195 info->control.hw_key->cipher != WLAN_CIPHER_SUITE_WEP104)
190 mh_len += info->control.hw_key->iv_len; 196 mh_len += info->control.hw_key->iv_len;
191 mh_len /= 2; 197 mh_len /= 2;
192 offload_assist |= mh_len << TX_CMD_OFFLD_MH_SIZE; 198 offload_assist |= mh_len << TX_CMD_OFFLD_MH_SIZE;
@@ -1815,6 +1821,8 @@ void iwl_mvm_rx_ba_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb)
1815 struct iwl_mvm_tid_data *tid_data; 1821 struct iwl_mvm_tid_data *tid_data;
1816 struct iwl_mvm_sta *mvmsta; 1822 struct iwl_mvm_sta *mvmsta;
1817 1823
1824 ba_info.flags = IEEE80211_TX_STAT_AMPDU;
1825
1818 if (iwl_mvm_has_new_tx_api(mvm)) { 1826 if (iwl_mvm_has_new_tx_api(mvm)) {
1819 struct iwl_mvm_compressed_ba_notif *ba_res = 1827 struct iwl_mvm_compressed_ba_notif *ba_res =
1820 (void *)pkt->data; 1828 (void *)pkt->data;
diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/drv.c b/drivers/net/wireless/intel/iwlwifi/pcie/drv.c
index f16c1bb9bf94..84f4ba01e14f 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/drv.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/drv.c
@@ -510,9 +510,17 @@ static const struct pci_device_id iwl_hw_card_ids[] = {
510 510
511/* 9000 Series */ 511/* 9000 Series */
512 {IWL_PCI_DEVICE(0x271B, 0x0010, iwl9160_2ac_cfg)}, 512 {IWL_PCI_DEVICE(0x271B, 0x0010, iwl9160_2ac_cfg)},
513 {IWL_PCI_DEVICE(0x271B, 0x0014, iwl9160_2ac_cfg)},
514 {IWL_PCI_DEVICE(0x271B, 0x0210, iwl9160_2ac_cfg)},
513 {IWL_PCI_DEVICE(0x2526, 0x0000, iwl9260_2ac_cfg)}, 515 {IWL_PCI_DEVICE(0x2526, 0x0000, iwl9260_2ac_cfg)},
514 {IWL_PCI_DEVICE(0x2526, 0x0010, iwl9260_2ac_cfg)}, 516 {IWL_PCI_DEVICE(0x2526, 0x0010, iwl9260_2ac_cfg)},
517 {IWL_PCI_DEVICE(0x2526, 0x0014, iwl9260_2ac_cfg)},
518 {IWL_PCI_DEVICE(0x2526, 0xA014, iwl9260_2ac_cfg)},
519 {IWL_PCI_DEVICE(0x2526, 0x4010, iwl9260_2ac_cfg)},
520 {IWL_PCI_DEVICE(0x2526, 0x0210, iwl9260_2ac_cfg)},
521 {IWL_PCI_DEVICE(0x2526, 0x0214, iwl9260_2ac_cfg)},
515 {IWL_PCI_DEVICE(0x2526, 0x1410, iwl9270_2ac_cfg)}, 522 {IWL_PCI_DEVICE(0x2526, 0x1410, iwl9270_2ac_cfg)},
523 {IWL_PCI_DEVICE(0x2526, 0x1610, iwl9270_2ac_cfg)},
516 {IWL_PCI_DEVICE(0x9DF0, 0x0A10, iwl9460_2ac_cfg)}, 524 {IWL_PCI_DEVICE(0x9DF0, 0x0A10, iwl9460_2ac_cfg)},
517 {IWL_PCI_DEVICE(0x9DF0, 0x0010, iwl9460_2ac_cfg)}, 525 {IWL_PCI_DEVICE(0x9DF0, 0x0010, iwl9460_2ac_cfg)},
518 {IWL_PCI_DEVICE(0x9DF0, 0x0210, iwl9460_2ac_cfg)}, 526 {IWL_PCI_DEVICE(0x9DF0, 0x0210, iwl9460_2ac_cfg)},
@@ -527,10 +535,22 @@ static const struct pci_device_id iwl_hw_card_ids[] = {
527 {IWL_PCI_DEVICE(0x9DF0, 0x2A10, iwl9460_2ac_cfg)}, 535 {IWL_PCI_DEVICE(0x9DF0, 0x2A10, iwl9460_2ac_cfg)},
528 {IWL_PCI_DEVICE(0x30DC, 0x0060, iwl9460_2ac_cfg)}, 536 {IWL_PCI_DEVICE(0x30DC, 0x0060, iwl9460_2ac_cfg)},
529 {IWL_PCI_DEVICE(0x2526, 0x0060, iwl9460_2ac_cfg)}, 537 {IWL_PCI_DEVICE(0x2526, 0x0060, iwl9460_2ac_cfg)},
538 {IWL_PCI_DEVICE(0x2526, 0x0260, iwl9460_2ac_cfg)},
539 {IWL_PCI_DEVICE(0x2526, 0x0064, iwl9460_2ac_cfg)},
540 {IWL_PCI_DEVICE(0x2526, 0x00A4, iwl9460_2ac_cfg)},
541 {IWL_PCI_DEVICE(0x2526, 0x40A4, iwl9460_2ac_cfg)},
542 {IWL_PCI_DEVICE(0x2526, 0x02A4, iwl9460_2ac_cfg)},
543 {IWL_PCI_DEVICE(0x2526, 0x00A0, iwl9460_2ac_cfg)},
544 {IWL_PCI_DEVICE(0x2526, 0x02A0, iwl9460_2ac_cfg)},
530 {IWL_PCI_DEVICE(0x9DF0, 0x0060, iwl9460_2ac_cfg)}, 545 {IWL_PCI_DEVICE(0x9DF0, 0x0060, iwl9460_2ac_cfg)},
531 {IWL_PCI_DEVICE(0xA370, 0x0060, iwl9460_2ac_cfg)}, 546 {IWL_PCI_DEVICE(0xA370, 0x0060, iwl9460_2ac_cfg)},
532 {IWL_PCI_DEVICE(0x31DC, 0x0060, iwl9460_2ac_cfg)}, 547 {IWL_PCI_DEVICE(0x31DC, 0x0060, iwl9460_2ac_cfg)},
533 {IWL_PCI_DEVICE(0x2526, 0x0030, iwl9560_2ac_cfg)}, 548 {IWL_PCI_DEVICE(0x2526, 0x0030, iwl9560_2ac_cfg)},
549 {IWL_PCI_DEVICE(0x2526, 0x4030, iwl9560_2ac_cfg)},
550 {IWL_PCI_DEVICE(0x2526, 0x0230, iwl9560_2ac_cfg)},
551 {IWL_PCI_DEVICE(0x2526, 0x0234, iwl9560_2ac_cfg)},
552 {IWL_PCI_DEVICE(0x2526, 0x0238, iwl9560_2ac_cfg)},
553 {IWL_PCI_DEVICE(0x2526, 0x023C, iwl9560_2ac_cfg)},
534 {IWL_PCI_DEVICE(0x9DF0, 0x0030, iwl9560_2ac_cfg)}, 554 {IWL_PCI_DEVICE(0x9DF0, 0x0030, iwl9560_2ac_cfg)},
535 {IWL_PCI_DEVICE(0xA370, 0x0030, iwl9560_2ac_cfg)}, 555 {IWL_PCI_DEVICE(0xA370, 0x0030, iwl9560_2ac_cfg)},
536 {IWL_PCI_DEVICE(0x31DC, 0x0030, iwl9560_2ac_cfg)}, 556 {IWL_PCI_DEVICE(0x31DC, 0x0030, iwl9560_2ac_cfg)},
diff --git a/drivers/nvme/host/fabrics.c b/drivers/nvme/host/fabrics.c
index 2e582a240943..5f5cd306f76d 100644
--- a/drivers/nvme/host/fabrics.c
+++ b/drivers/nvme/host/fabrics.c
@@ -794,7 +794,8 @@ static int nvmf_check_allowed_opts(struct nvmf_ctrl_options *opts,
794 int i; 794 int i;
795 795
796 for (i = 0; i < ARRAY_SIZE(opt_tokens); i++) { 796 for (i = 0; i < ARRAY_SIZE(opt_tokens); i++) {
797 if (opt_tokens[i].token & ~allowed_opts) { 797 if ((opt_tokens[i].token & opts->mask) &&
798 (opt_tokens[i].token & ~allowed_opts)) {
798 pr_warn("invalid parameter '%s'\n", 799 pr_warn("invalid parameter '%s'\n",
799 opt_tokens[i].pattern); 800 opt_tokens[i].pattern);
800 } 801 }
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 74a124a06264..925467b31a33 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -801,6 +801,7 @@ static inline void nvme_handle_cqe(struct nvme_queue *nvmeq,
801 return; 801 return;
802 } 802 }
803 803
804 nvmeq->cqe_seen = 1;
804 req = blk_mq_tag_to_rq(*nvmeq->tags, cqe->command_id); 805 req = blk_mq_tag_to_rq(*nvmeq->tags, cqe->command_id);
805 nvme_end_request(req, cqe->status, cqe->result); 806 nvme_end_request(req, cqe->status, cqe->result);
806} 807}
@@ -830,10 +831,8 @@ static void nvme_process_cq(struct nvme_queue *nvmeq)
830 consumed++; 831 consumed++;
831 } 832 }
832 833
833 if (consumed) { 834 if (consumed)
834 nvme_ring_cq_doorbell(nvmeq); 835 nvme_ring_cq_doorbell(nvmeq);
835 nvmeq->cqe_seen = 1;
836 }
837} 836}
838 837
839static irqreturn_t nvme_irq(int irq, void *data) 838static irqreturn_t nvme_irq(int irq, void *data)
diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index 2d7a98ab53fb..a53bb6635b83 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -199,12 +199,6 @@ static void nvmet_execute_identify_ctrl(struct nvmet_req *req)
199 copy_and_pad(id->mn, sizeof(id->mn), model, sizeof(model) - 1); 199 copy_and_pad(id->mn, sizeof(id->mn), model, sizeof(model) - 1);
200 copy_and_pad(id->fr, sizeof(id->fr), UTS_RELEASE, strlen(UTS_RELEASE)); 200 copy_and_pad(id->fr, sizeof(id->fr), UTS_RELEASE, strlen(UTS_RELEASE));
201 201
202 memset(id->mn, ' ', sizeof(id->mn));
203 strncpy((char *)id->mn, "Linux", sizeof(id->mn));
204
205 memset(id->fr, ' ', sizeof(id->fr));
206 strncpy((char *)id->fr, UTS_RELEASE, sizeof(id->fr));
207
208 id->rab = 6; 202 id->rab = 6;
209 203
210 /* 204 /*
diff --git a/drivers/nvme/target/fc.c b/drivers/nvme/target/fc.c
index 1b7f2520a20d..309c84aa7595 100644
--- a/drivers/nvme/target/fc.c
+++ b/drivers/nvme/target/fc.c
@@ -394,7 +394,7 @@ nvmet_fc_free_ls_iodlist(struct nvmet_fc_tgtport *tgtport)
394static struct nvmet_fc_ls_iod * 394static struct nvmet_fc_ls_iod *
395nvmet_fc_alloc_ls_iod(struct nvmet_fc_tgtport *tgtport) 395nvmet_fc_alloc_ls_iod(struct nvmet_fc_tgtport *tgtport)
396{ 396{
397 static struct nvmet_fc_ls_iod *iod; 397 struct nvmet_fc_ls_iod *iod;
398 unsigned long flags; 398 unsigned long flags;
399 399
400 spin_lock_irqsave(&tgtport->lock, flags); 400 spin_lock_irqsave(&tgtport->lock, flags);
@@ -471,7 +471,7 @@ nvmet_fc_destroy_fcp_iodlist(struct nvmet_fc_tgtport *tgtport,
471static struct nvmet_fc_fcp_iod * 471static struct nvmet_fc_fcp_iod *
472nvmet_fc_alloc_fcp_iod(struct nvmet_fc_tgt_queue *queue) 472nvmet_fc_alloc_fcp_iod(struct nvmet_fc_tgt_queue *queue)
473{ 473{
474 static struct nvmet_fc_fcp_iod *fod; 474 struct nvmet_fc_fcp_iod *fod;
475 475
476 lockdep_assert_held(&queue->qlock); 476 lockdep_assert_held(&queue->qlock);
477 477
@@ -704,7 +704,7 @@ nvmet_fc_delete_target_queue(struct nvmet_fc_tgt_queue *queue)
704{ 704{
705 struct nvmet_fc_tgtport *tgtport = queue->assoc->tgtport; 705 struct nvmet_fc_tgtport *tgtport = queue->assoc->tgtport;
706 struct nvmet_fc_fcp_iod *fod = queue->fod; 706 struct nvmet_fc_fcp_iod *fod = queue->fod;
707 struct nvmet_fc_defer_fcp_req *deferfcp; 707 struct nvmet_fc_defer_fcp_req *deferfcp, *tempptr;
708 unsigned long flags; 708 unsigned long flags;
709 int i, writedataactive; 709 int i, writedataactive;
710 bool disconnect; 710 bool disconnect;
@@ -735,7 +735,8 @@ nvmet_fc_delete_target_queue(struct nvmet_fc_tgt_queue *queue)
735 } 735 }
736 736
737 /* Cleanup defer'ed IOs in queue */ 737 /* Cleanup defer'ed IOs in queue */
738 list_for_each_entry(deferfcp, &queue->avail_defer_list, req_list) { 738 list_for_each_entry_safe(deferfcp, tempptr, &queue->avail_defer_list,
739 req_list) {
739 list_del(&deferfcp->req_list); 740 list_del(&deferfcp->req_list);
740 kfree(deferfcp); 741 kfree(deferfcp);
741 } 742 }
diff --git a/drivers/of/device.c b/drivers/of/device.c
index 28c38c756f92..e0a28ea341fe 100644
--- a/drivers/of/device.c
+++ b/drivers/of/device.c
@@ -89,6 +89,7 @@ int of_dma_configure(struct device *dev, struct device_node *np)
89 bool coherent; 89 bool coherent;
90 unsigned long offset; 90 unsigned long offset;
91 const struct iommu_ops *iommu; 91 const struct iommu_ops *iommu;
92 u64 mask;
92 93
93 /* 94 /*
94 * Set default coherent_dma_mask to 32 bit. Drivers are expected to 95 * Set default coherent_dma_mask to 32 bit. Drivers are expected to
@@ -134,10 +135,9 @@ int of_dma_configure(struct device *dev, struct device_node *np)
134 * Limit coherent and dma mask based on size and default mask 135 * Limit coherent and dma mask based on size and default mask
135 * set by the driver. 136 * set by the driver.
136 */ 137 */
137 dev->coherent_dma_mask = min(dev->coherent_dma_mask, 138 mask = DMA_BIT_MASK(ilog2(dma_addr + size - 1) + 1);
138 DMA_BIT_MASK(ilog2(dma_addr + size))); 139 dev->coherent_dma_mask &= mask;
139 *dev->dma_mask = min((*dev->dma_mask), 140 *dev->dma_mask &= mask;
140 DMA_BIT_MASK(ilog2(dma_addr + size)));
141 141
142 coherent = of_dma_is_coherent(np); 142 coherent = of_dma_is_coherent(np);
143 dev_dbg(dev, "device is%sdma coherent\n", 143 dev_dbg(dev, "device is%sdma coherent\n",
diff --git a/drivers/parisc/dino.c b/drivers/parisc/dino.c
index 5c63b920b471..ed92c1254cff 100644
--- a/drivers/parisc/dino.c
+++ b/drivers/parisc/dino.c
@@ -956,7 +956,7 @@ static int __init dino_probe(struct parisc_device *dev)
956 956
957 dino_dev->hba.dev = dev; 957 dino_dev->hba.dev = dev;
958 dino_dev->hba.base_addr = ioremap_nocache(hpa, 4096); 958 dino_dev->hba.base_addr = ioremap_nocache(hpa, 4096);
959 dino_dev->hba.lmmio_space_offset = 0; /* CPU addrs == bus addrs */ 959 dino_dev->hba.lmmio_space_offset = PCI_F_EXTEND;
960 spin_lock_init(&dino_dev->dinosaur_pen); 960 spin_lock_init(&dino_dev->dinosaur_pen);
961 dino_dev->hba.iommu = ccio_get_iommu(dev); 961 dino_dev->hba.iommu = ccio_get_iommu(dev);
962 962
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index b4b7eab29400..da5570cf5c6a 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -522,10 +522,11 @@ struct pci_dev *pci_find_pcie_root_port(struct pci_dev *dev)
522 bridge = pci_upstream_bridge(bridge); 522 bridge = pci_upstream_bridge(bridge);
523 } 523 }
524 524
525 if (pci_pcie_type(highest_pcie_bridge) != PCI_EXP_TYPE_ROOT_PORT) 525 if (highest_pcie_bridge &&
526 return NULL; 526 pci_pcie_type(highest_pcie_bridge) == PCI_EXP_TYPE_ROOT_PORT)
527 return highest_pcie_bridge;
527 528
528 return highest_pcie_bridge; 529 return NULL;
529} 530}
530EXPORT_SYMBOL(pci_find_pcie_root_port); 531EXPORT_SYMBOL(pci_find_pcie_root_port);
531 532
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index c31310db0404..e6a917b4acd3 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1762,6 +1762,48 @@ static void pci_configure_extended_tags(struct pci_dev *dev)
1762 PCI_EXP_DEVCTL_EXT_TAG); 1762 PCI_EXP_DEVCTL_EXT_TAG);
1763} 1763}
1764 1764
1765/**
1766 * pcie_relaxed_ordering_enabled - Probe for PCIe relaxed ordering enable
1767 * @dev: PCI device to query
1768 *
1769 * Returns true if the device has enabled relaxed ordering attribute.
1770 */
1771bool pcie_relaxed_ordering_enabled(struct pci_dev *dev)
1772{
1773 u16 v;
1774
1775 pcie_capability_read_word(dev, PCI_EXP_DEVCTL, &v);
1776
1777 return !!(v & PCI_EXP_DEVCTL_RELAX_EN);
1778}
1779EXPORT_SYMBOL(pcie_relaxed_ordering_enabled);
1780
1781static void pci_configure_relaxed_ordering(struct pci_dev *dev)
1782{
1783 struct pci_dev *root;
1784
1785 /* PCI_EXP_DEVICE_RELAX_EN is RsvdP in VFs */
1786 if (dev->is_virtfn)
1787 return;
1788
1789 if (!pcie_relaxed_ordering_enabled(dev))
1790 return;
1791
1792 /*
1793 * For now, we only deal with Relaxed Ordering issues with Root
1794 * Ports. Peer-to-Peer DMA is another can of worms.
1795 */
1796 root = pci_find_pcie_root_port(dev);
1797 if (!root)
1798 return;
1799
1800 if (root->dev_flags & PCI_DEV_FLAGS_NO_RELAXED_ORDERING) {
1801 pcie_capability_clear_word(dev, PCI_EXP_DEVCTL,
1802 PCI_EXP_DEVCTL_RELAX_EN);
1803 dev_info(&dev->dev, "Disable Relaxed Ordering because the Root Port didn't support it\n");
1804 }
1805}
1806
1765static void pci_configure_device(struct pci_dev *dev) 1807static void pci_configure_device(struct pci_dev *dev)
1766{ 1808{
1767 struct hotplug_params hpp; 1809 struct hotplug_params hpp;
@@ -1769,6 +1811,7 @@ static void pci_configure_device(struct pci_dev *dev)
1769 1811
1770 pci_configure_mps(dev); 1812 pci_configure_mps(dev);
1771 pci_configure_extended_tags(dev); 1813 pci_configure_extended_tags(dev);
1814 pci_configure_relaxed_ordering(dev);
1772 1815
1773 memset(&hpp, 0, sizeof(hpp)); 1816 memset(&hpp, 0, sizeof(hpp));
1774 ret = pci_get_hp_params(dev, &hpp); 1817 ret = pci_get_hp_params(dev, &hpp);
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 6967c6b4cf6b..140760403f36 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -4016,6 +4016,95 @@ DECLARE_PCI_FIXUP_CLASS_EARLY(0x1797, 0x6869, PCI_CLASS_NOT_DEFINED, 8,
4016 quirk_tw686x_class); 4016 quirk_tw686x_class);
4017 4017
4018/* 4018/*
4019 * Some devices have problems with Transaction Layer Packets with the Relaxed
4020 * Ordering Attribute set. Such devices should mark themselves and other
4021 * Device Drivers should check before sending TLPs with RO set.
4022 */
4023static void quirk_relaxedordering_disable(struct pci_dev *dev)
4024{
4025 dev->dev_flags |= PCI_DEV_FLAGS_NO_RELAXED_ORDERING;
4026 dev_info(&dev->dev, "Disable Relaxed Ordering Attributes to avoid PCIe Completion erratum\n");
4027}
4028
4029/*
4030 * Intel Xeon processors based on Broadwell/Haswell microarchitecture Root
4031 * Complex has a Flow Control Credit issue which can cause performance
4032 * problems with Upstream Transaction Layer Packets with Relaxed Ordering set.
4033 */
4034DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f01, PCI_CLASS_NOT_DEFINED, 8,
4035 quirk_relaxedordering_disable);
4036DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f02, PCI_CLASS_NOT_DEFINED, 8,
4037 quirk_relaxedordering_disable);
4038DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f03, PCI_CLASS_NOT_DEFINED, 8,
4039 quirk_relaxedordering_disable);
4040DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f04, PCI_CLASS_NOT_DEFINED, 8,
4041 quirk_relaxedordering_disable);
4042DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f05, PCI_CLASS_NOT_DEFINED, 8,
4043 quirk_relaxedordering_disable);
4044DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f06, PCI_CLASS_NOT_DEFINED, 8,
4045 quirk_relaxedordering_disable);
4046DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f07, PCI_CLASS_NOT_DEFINED, 8,
4047 quirk_relaxedordering_disable);
4048DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f08, PCI_CLASS_NOT_DEFINED, 8,
4049 quirk_relaxedordering_disable);
4050DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f09, PCI_CLASS_NOT_DEFINED, 8,
4051 quirk_relaxedordering_disable);
4052DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f0a, PCI_CLASS_NOT_DEFINED, 8,
4053 quirk_relaxedordering_disable);
4054DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f0b, PCI_CLASS_NOT_DEFINED, 8,
4055 quirk_relaxedordering_disable);
4056DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f0c, PCI_CLASS_NOT_DEFINED, 8,
4057 quirk_relaxedordering_disable);
4058DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f0d, PCI_CLASS_NOT_DEFINED, 8,
4059 quirk_relaxedordering_disable);
4060DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f0e, PCI_CLASS_NOT_DEFINED, 8,
4061 quirk_relaxedordering_disable);
4062DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f01, PCI_CLASS_NOT_DEFINED, 8,
4063 quirk_relaxedordering_disable);
4064DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f02, PCI_CLASS_NOT_DEFINED, 8,
4065 quirk_relaxedordering_disable);
4066DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f03, PCI_CLASS_NOT_DEFINED, 8,
4067 quirk_relaxedordering_disable);
4068DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f04, PCI_CLASS_NOT_DEFINED, 8,
4069 quirk_relaxedordering_disable);
4070DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f05, PCI_CLASS_NOT_DEFINED, 8,
4071 quirk_relaxedordering_disable);
4072DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f06, PCI_CLASS_NOT_DEFINED, 8,
4073 quirk_relaxedordering_disable);
4074DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f07, PCI_CLASS_NOT_DEFINED, 8,
4075 quirk_relaxedordering_disable);
4076DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f08, PCI_CLASS_NOT_DEFINED, 8,
4077 quirk_relaxedordering_disable);
4078DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f09, PCI_CLASS_NOT_DEFINED, 8,
4079 quirk_relaxedordering_disable);
4080DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f0a, PCI_CLASS_NOT_DEFINED, 8,
4081 quirk_relaxedordering_disable);
4082DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f0b, PCI_CLASS_NOT_DEFINED, 8,
4083 quirk_relaxedordering_disable);
4084DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f0c, PCI_CLASS_NOT_DEFINED, 8,
4085 quirk_relaxedordering_disable);
4086DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f0d, PCI_CLASS_NOT_DEFINED, 8,
4087 quirk_relaxedordering_disable);
4088DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f0e, PCI_CLASS_NOT_DEFINED, 8,
4089 quirk_relaxedordering_disable);
4090
4091/*
4092 * The AMD ARM A1100 (AKA "SEATTLE") SoC has a bug in its PCIe Root Complex
4093 * where Upstream Transaction Layer Packets with the Relaxed Ordering
4094 * Attribute clear are allowed to bypass earlier TLPs with Relaxed Ordering
4095 * set. This is a violation of the PCIe 3.0 Transaction Ordering Rules
4096 * outlined in Section 2.4.1 (PCI Express(r) Base Specification Revision 3.0
4097 * November 10, 2010). As a result, on this platform we can't use Relaxed
4098 * Ordering for Upstream TLPs.
4099 */
4100DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_AMD, 0x1a00, PCI_CLASS_NOT_DEFINED, 8,
4101 quirk_relaxedordering_disable);
4102DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_AMD, 0x1a01, PCI_CLASS_NOT_DEFINED, 8,
4103 quirk_relaxedordering_disable);
4104DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_AMD, 0x1a02, PCI_CLASS_NOT_DEFINED, 8,
4105 quirk_relaxedordering_disable);
4106
4107/*
4019 * Per PCIe r3.0, sec 2.2.9, "Completion headers must supply the same 4108 * Per PCIe r3.0, sec 2.2.9, "Completion headers must supply the same
4020 * values for the Attribute as were supplied in the header of the 4109 * values for the Attribute as were supplied in the header of the
4021 * corresponding Request, except as explicitly allowed when IDO is used." 4110 * corresponding Request, except as explicitly allowed when IDO is used."
diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c
index b0c68d24db01..da5bdbdcce52 100644
--- a/drivers/scsi/ipr.c
+++ b/drivers/scsi/ipr.c
@@ -3351,6 +3351,16 @@ static void ipr_worker_thread(struct work_struct *work)
3351 return; 3351 return;
3352 } 3352 }
3353 3353
3354 if (ioa_cfg->scsi_unblock) {
3355 ioa_cfg->scsi_unblock = 0;
3356 ioa_cfg->scsi_blocked = 0;
3357 spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags);
3358 scsi_unblock_requests(ioa_cfg->host);
3359 spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags);
3360 if (ioa_cfg->scsi_blocked)
3361 scsi_block_requests(ioa_cfg->host);
3362 }
3363
3354 if (!ioa_cfg->scan_enabled) { 3364 if (!ioa_cfg->scan_enabled) {
3355 spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags); 3365 spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags);
3356 return; 3366 return;
@@ -7211,9 +7221,8 @@ static int ipr_ioa_bringdown_done(struct ipr_cmnd *ipr_cmd)
7211 ENTER; 7221 ENTER;
7212 if (!ioa_cfg->hrrq[IPR_INIT_HRRQ].removing_ioa) { 7222 if (!ioa_cfg->hrrq[IPR_INIT_HRRQ].removing_ioa) {
7213 ipr_trace; 7223 ipr_trace;
7214 spin_unlock_irq(ioa_cfg->host->host_lock); 7224 ioa_cfg->scsi_unblock = 1;
7215 scsi_unblock_requests(ioa_cfg->host); 7225 schedule_work(&ioa_cfg->work_q);
7216 spin_lock_irq(ioa_cfg->host->host_lock);
7217 } 7226 }
7218 7227
7219 ioa_cfg->in_reset_reload = 0; 7228 ioa_cfg->in_reset_reload = 0;
@@ -7287,13 +7296,7 @@ static int ipr_ioa_reset_done(struct ipr_cmnd *ipr_cmd)
7287 list_add_tail(&ipr_cmd->queue, &ipr_cmd->hrrq->hrrq_free_q); 7296 list_add_tail(&ipr_cmd->queue, &ipr_cmd->hrrq->hrrq_free_q);
7288 wake_up_all(&ioa_cfg->reset_wait_q); 7297 wake_up_all(&ioa_cfg->reset_wait_q);
7289 7298
7290 spin_unlock(ioa_cfg->host->host_lock); 7299 ioa_cfg->scsi_unblock = 1;
7291 scsi_unblock_requests(ioa_cfg->host);
7292 spin_lock(ioa_cfg->host->host_lock);
7293
7294 if (!ioa_cfg->hrrq[IPR_INIT_HRRQ].allow_cmds)
7295 scsi_block_requests(ioa_cfg->host);
7296
7297 schedule_work(&ioa_cfg->work_q); 7300 schedule_work(&ioa_cfg->work_q);
7298 LEAVE; 7301 LEAVE;
7299 return IPR_RC_JOB_RETURN; 7302 return IPR_RC_JOB_RETURN;
@@ -9249,8 +9252,11 @@ static void _ipr_initiate_ioa_reset(struct ipr_ioa_cfg *ioa_cfg,
9249 spin_unlock(&ioa_cfg->hrrq[i]._lock); 9252 spin_unlock(&ioa_cfg->hrrq[i]._lock);
9250 } 9253 }
9251 wmb(); 9254 wmb();
9252 if (!ioa_cfg->hrrq[IPR_INIT_HRRQ].removing_ioa) 9255 if (!ioa_cfg->hrrq[IPR_INIT_HRRQ].removing_ioa) {
9256 ioa_cfg->scsi_unblock = 0;
9257 ioa_cfg->scsi_blocked = 1;
9253 scsi_block_requests(ioa_cfg->host); 9258 scsi_block_requests(ioa_cfg->host);
9259 }
9254 9260
9255 ipr_cmd = ipr_get_free_ipr_cmnd(ioa_cfg); 9261 ipr_cmd = ipr_get_free_ipr_cmnd(ioa_cfg);
9256 ioa_cfg->reset_cmd = ipr_cmd; 9262 ioa_cfg->reset_cmd = ipr_cmd;
@@ -9306,9 +9312,8 @@ static void ipr_initiate_ioa_reset(struct ipr_ioa_cfg *ioa_cfg,
9306 wake_up_all(&ioa_cfg->reset_wait_q); 9312 wake_up_all(&ioa_cfg->reset_wait_q);
9307 9313
9308 if (!ioa_cfg->hrrq[IPR_INIT_HRRQ].removing_ioa) { 9314 if (!ioa_cfg->hrrq[IPR_INIT_HRRQ].removing_ioa) {
9309 spin_unlock_irq(ioa_cfg->host->host_lock); 9315 ioa_cfg->scsi_unblock = 1;
9310 scsi_unblock_requests(ioa_cfg->host); 9316 schedule_work(&ioa_cfg->work_q);
9311 spin_lock_irq(ioa_cfg->host->host_lock);
9312 } 9317 }
9313 return; 9318 return;
9314 } else { 9319 } else {
diff --git a/drivers/scsi/ipr.h b/drivers/scsi/ipr.h
index e98a87a65335..c7f0e9e3cd7d 100644
--- a/drivers/scsi/ipr.h
+++ b/drivers/scsi/ipr.h
@@ -1488,6 +1488,8 @@ struct ipr_ioa_cfg {
1488 u8 cfg_locked:1; 1488 u8 cfg_locked:1;
1489 u8 clear_isr:1; 1489 u8 clear_isr:1;
1490 u8 probe_done:1; 1490 u8 probe_done:1;
1491 u8 scsi_unblock:1;
1492 u8 scsi_blocked:1;
1491 1493
1492 u8 revid; 1494 u8 revid;
1493 1495
diff --git a/drivers/scsi/qla2xxx/qla_tmpl.c b/drivers/scsi/qla2xxx/qla_tmpl.c
index 33142610882f..b18646d6057f 100644
--- a/drivers/scsi/qla2xxx/qla_tmpl.c
+++ b/drivers/scsi/qla2xxx/qla_tmpl.c
@@ -401,9 +401,6 @@ qla27xx_fwdt_entry_t263(struct scsi_qla_host *vha,
401 for (i = 0; i < vha->hw->max_req_queues; i++) { 401 for (i = 0; i < vha->hw->max_req_queues; i++) {
402 struct req_que *req = vha->hw->req_q_map[i]; 402 struct req_que *req = vha->hw->req_q_map[i];
403 403
404 if (!test_bit(i, vha->hw->req_qid_map))
405 continue;
406
407 if (req || !buf) { 404 if (req || !buf) {
408 length = req ? 405 length = req ?
409 req->length : REQUEST_ENTRY_CNT_24XX; 406 req->length : REQUEST_ENTRY_CNT_24XX;
@@ -418,9 +415,6 @@ qla27xx_fwdt_entry_t263(struct scsi_qla_host *vha,
418 for (i = 0; i < vha->hw->max_rsp_queues; i++) { 415 for (i = 0; i < vha->hw->max_rsp_queues; i++) {
419 struct rsp_que *rsp = vha->hw->rsp_q_map[i]; 416 struct rsp_que *rsp = vha->hw->rsp_q_map[i];
420 417
421 if (!test_bit(i, vha->hw->rsp_qid_map))
422 continue;
423
424 if (rsp || !buf) { 418 if (rsp || !buf) {
425 length = rsp ? 419 length = rsp ?
426 rsp->length : RESPONSE_ENTRY_CNT_MQ; 420 rsp->length : RESPONSE_ENTRY_CNT_MQ;
@@ -660,9 +654,6 @@ qla27xx_fwdt_entry_t274(struct scsi_qla_host *vha,
660 for (i = 0; i < vha->hw->max_req_queues; i++) { 654 for (i = 0; i < vha->hw->max_req_queues; i++) {
661 struct req_que *req = vha->hw->req_q_map[i]; 655 struct req_que *req = vha->hw->req_q_map[i];
662 656
663 if (!test_bit(i, vha->hw->req_qid_map))
664 continue;
665
666 if (req || !buf) { 657 if (req || !buf) {
667 qla27xx_insert16(i, buf, len); 658 qla27xx_insert16(i, buf, len);
668 qla27xx_insert16(1, buf, len); 659 qla27xx_insert16(1, buf, len);
@@ -675,9 +666,6 @@ qla27xx_fwdt_entry_t274(struct scsi_qla_host *vha,
675 for (i = 0; i < vha->hw->max_rsp_queues; i++) { 666 for (i = 0; i < vha->hw->max_rsp_queues; i++) {
676 struct rsp_que *rsp = vha->hw->rsp_q_map[i]; 667 struct rsp_que *rsp = vha->hw->rsp_q_map[i];
677 668
678 if (!test_bit(i, vha->hw->rsp_qid_map))
679 continue;
680
681 if (rsp || !buf) { 669 if (rsp || !buf) {
682 qla27xx_insert16(i, buf, len); 670 qla27xx_insert16(i, buf, len);
683 qla27xx_insert16(1, buf, len); 671 qla27xx_insert16(1, buf, len);
diff --git a/drivers/scsi/ses.c b/drivers/scsi/ses.c
index f1cdf32d7514..8927f9f54ad9 100644
--- a/drivers/scsi/ses.c
+++ b/drivers/scsi/ses.c
@@ -99,7 +99,7 @@ static int ses_recv_diag(struct scsi_device *sdev, int page_code,
99 99
100 ret = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buf, bufflen, 100 ret = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buf, bufflen,
101 NULL, SES_TIMEOUT, SES_RETRIES, NULL); 101 NULL, SES_TIMEOUT, SES_RETRIES, NULL);
102 if (unlikely(!ret)) 102 if (unlikely(ret))
103 return ret; 103 return ret;
104 104
105 recv_page_code = ((unsigned char *)buf)[0]; 105 recv_page_code = ((unsigned char *)buf)[0];
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index 8e5013d9cad4..94e402ed30f6 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -4299,11 +4299,11 @@ static int st_probe(struct device *dev)
4299 kref_init(&tpnt->kref); 4299 kref_init(&tpnt->kref);
4300 tpnt->disk = disk; 4300 tpnt->disk = disk;
4301 disk->private_data = &tpnt->driver; 4301 disk->private_data = &tpnt->driver;
4302 disk->queue = SDp->request_queue;
4303 /* SCSI tape doesn't register this gendisk via add_disk(). Manually 4302 /* SCSI tape doesn't register this gendisk via add_disk(). Manually
4304 * take queue reference that release_disk() expects. */ 4303 * take queue reference that release_disk() expects. */
4305 if (!blk_get_queue(disk->queue)) 4304 if (!blk_get_queue(SDp->request_queue))
4306 goto out_put_disk; 4305 goto out_put_disk;
4306 disk->queue = SDp->request_queue;
4307 tpnt->driver = &st_template; 4307 tpnt->driver = &st_template;
4308 4308
4309 tpnt->device = SDp; 4309 tpnt->device = SDp;
diff --git a/drivers/soc/imx/gpcv2.c b/drivers/soc/imx/gpcv2.c
index 3039072911a5..afc7ecc3c187 100644
--- a/drivers/soc/imx/gpcv2.c
+++ b/drivers/soc/imx/gpcv2.c
@@ -200,16 +200,11 @@ static int imx7_pgc_domain_probe(struct platform_device *pdev)
200 200
201 domain->dev = &pdev->dev; 201 domain->dev = &pdev->dev;
202 202
203 ret = pm_genpd_init(&domain->genpd, NULL, true);
204 if (ret) {
205 dev_err(domain->dev, "Failed to init power domain\n");
206 return ret;
207 }
208
209 domain->regulator = devm_regulator_get_optional(domain->dev, "power"); 203 domain->regulator = devm_regulator_get_optional(domain->dev, "power");
210 if (IS_ERR(domain->regulator)) { 204 if (IS_ERR(domain->regulator)) {
211 if (PTR_ERR(domain->regulator) != -ENODEV) { 205 if (PTR_ERR(domain->regulator) != -ENODEV) {
212 dev_err(domain->dev, "Failed to get domain's regulator\n"); 206 if (PTR_ERR(domain->regulator) != -EPROBE_DEFER)
207 dev_err(domain->dev, "Failed to get domain's regulator\n");
213 return PTR_ERR(domain->regulator); 208 return PTR_ERR(domain->regulator);
214 } 209 }
215 } else { 210 } else {
@@ -217,6 +212,12 @@ static int imx7_pgc_domain_probe(struct platform_device *pdev)
217 domain->voltage, domain->voltage); 212 domain->voltage, domain->voltage);
218 } 213 }
219 214
215 ret = pm_genpd_init(&domain->genpd, NULL, true);
216 if (ret) {
217 dev_err(domain->dev, "Failed to init power domain\n");
218 return ret;
219 }
220
220 ret = of_genpd_add_provider_simple(domain->dev->of_node, 221 ret = of_genpd_add_provider_simple(domain->dev->of_node,
221 &domain->genpd); 222 &domain->genpd);
222 if (ret) { 223 if (ret) {
diff --git a/drivers/soc/ti/ti_sci_pm_domains.c b/drivers/soc/ti/ti_sci_pm_domains.c
index b0b283810e72..de31b9389e2e 100644
--- a/drivers/soc/ti/ti_sci_pm_domains.c
+++ b/drivers/soc/ti/ti_sci_pm_domains.c
@@ -176,6 +176,8 @@ static int ti_sci_pm_domain_probe(struct platform_device *pdev)
176 176
177 ti_sci_pd->dev = dev; 177 ti_sci_pd->dev = dev;
178 178
179 ti_sci_pd->pd.name = "ti_sci_pd";
180
179 ti_sci_pd->pd.attach_dev = ti_sci_pd_attach_dev; 181 ti_sci_pd->pd.attach_dev = ti_sci_pd_attach_dev;
180 ti_sci_pd->pd.detach_dev = ti_sci_pd_detach_dev; 182 ti_sci_pd->pd.detach_dev = ti_sci_pd_detach_dev;
181 183
diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
index 284749fb0f6b..1fc80ea87c13 100644
--- a/drivers/tty/pty.c
+++ b/drivers/tty/pty.c
@@ -793,6 +793,7 @@ static int ptmx_open(struct inode *inode, struct file *filp)
793 struct tty_struct *tty; 793 struct tty_struct *tty;
794 struct path *pts_path; 794 struct path *pts_path;
795 struct dentry *dentry; 795 struct dentry *dentry;
796 struct vfsmount *mnt;
796 int retval; 797 int retval;
797 int index; 798 int index;
798 799
@@ -805,7 +806,7 @@ static int ptmx_open(struct inode *inode, struct file *filp)
805 if (retval) 806 if (retval)
806 return retval; 807 return retval;
807 808
808 fsi = devpts_acquire(filp); 809 fsi = devpts_acquire(filp, &mnt);
809 if (IS_ERR(fsi)) { 810 if (IS_ERR(fsi)) {
810 retval = PTR_ERR(fsi); 811 retval = PTR_ERR(fsi);
811 goto out_free_file; 812 goto out_free_file;
@@ -849,7 +850,7 @@ static int ptmx_open(struct inode *inode, struct file *filp)
849 pts_path = kmalloc(sizeof(struct path), GFP_KERNEL); 850 pts_path = kmalloc(sizeof(struct path), GFP_KERNEL);
850 if (!pts_path) 851 if (!pts_path)
851 goto err_release; 852 goto err_release;
852 pts_path->mnt = filp->f_path.mnt; 853 pts_path->mnt = mnt;
853 pts_path->dentry = dentry; 854 pts_path->dentry = dentry;
854 path_get(pts_path); 855 path_get(pts_path);
855 tty->link->driver_data = pts_path; 856 tty->link->driver_data = pts_path;
@@ -866,6 +867,7 @@ err_path_put:
866 path_put(pts_path); 867 path_put(pts_path);
867 kfree(pts_path); 868 kfree(pts_path);
868err_release: 869err_release:
870 mntput(mnt);
869 tty_unlock(tty); 871 tty_unlock(tty);
870 // This will also put-ref the fsi 872 // This will also put-ref the fsi
871 tty_release(inode, filp); 873 tty_release(inode, filp);
@@ -874,6 +876,7 @@ out:
874 devpts_kill_index(fsi, index); 876 devpts_kill_index(fsi, index);
875out_put_fsi: 877out_put_fsi:
876 devpts_release(fsi); 878 devpts_release(fsi);
879 mntput(mnt);
877out_free_file: 880out_free_file:
878 tty_free_file(filp); 881 tty_free_file(filp);
879 return retval; 882 return retval;
diff --git a/drivers/xen/biomerge.c b/drivers/xen/biomerge.c
index 4da69dbf7dca..1bdd02a6d6ac 100644
--- a/drivers/xen/biomerge.c
+++ b/drivers/xen/biomerge.c
@@ -10,8 +10,7 @@ bool xen_biovec_phys_mergeable(const struct bio_vec *vec1,
10 unsigned long bfn1 = pfn_to_bfn(page_to_pfn(vec1->bv_page)); 10 unsigned long bfn1 = pfn_to_bfn(page_to_pfn(vec1->bv_page));
11 unsigned long bfn2 = pfn_to_bfn(page_to_pfn(vec2->bv_page)); 11 unsigned long bfn2 = pfn_to_bfn(page_to_pfn(vec2->bv_page));
12 12
13 return __BIOVEC_PHYS_MERGEABLE(vec1, vec2) && 13 return bfn1 + PFN_DOWN(vec1->bv_offset + vec1->bv_len) == bfn2;
14 ((bfn1 == bfn2) || ((bfn1+1) == bfn2));
15#else 14#else
16 /* 15 /*
17 * XXX: Add support for merging bio_vec when using different page 16 * XXX: Add support for merging bio_vec when using different page
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index 879ff9c7ffd0..6466153f2bf0 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -664,8 +664,7 @@ static unsigned long randomize_stack_top(unsigned long stack_top)
664{ 664{
665 unsigned long random_variable = 0; 665 unsigned long random_variable = 0;
666 666
667 if ((current->flags & PF_RANDOMIZE) && 667 if (current->flags & PF_RANDOMIZE) {
668 !(current->personality & ADDR_NO_RANDOMIZE)) {
669 random_variable = get_random_long(); 668 random_variable = get_random_long();
670 random_variable &= STACK_RND_MASK; 669 random_variable &= STACK_RND_MASK;
671 random_variable <<= PAGE_SHIFT; 670 random_variable <<= PAGE_SHIFT;
diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c
index 108df2e3602c..44dfbca9306f 100644
--- a/fs/devpts/inode.c
+++ b/fs/devpts/inode.c
@@ -133,7 +133,7 @@ static inline struct pts_fs_info *DEVPTS_SB(struct super_block *sb)
133 return sb->s_fs_info; 133 return sb->s_fs_info;
134} 134}
135 135
136struct pts_fs_info *devpts_acquire(struct file *filp) 136struct pts_fs_info *devpts_acquire(struct file *filp, struct vfsmount **ptsmnt)
137{ 137{
138 struct pts_fs_info *result; 138 struct pts_fs_info *result;
139 struct path path; 139 struct path path;
@@ -142,6 +142,7 @@ struct pts_fs_info *devpts_acquire(struct file *filp)
142 142
143 path = filp->f_path; 143 path = filp->f_path;
144 path_get(&path); 144 path_get(&path);
145 *ptsmnt = NULL;
145 146
146 /* Has the devpts filesystem already been found? */ 147 /* Has the devpts filesystem already been found? */
147 sb = path.mnt->mnt_sb; 148 sb = path.mnt->mnt_sb;
@@ -165,6 +166,7 @@ struct pts_fs_info *devpts_acquire(struct file *filp)
165 * pty code needs to hold extra references in case of last /dev/tty close 166 * pty code needs to hold extra references in case of last /dev/tty close
166 */ 167 */
167 atomic_inc(&sb->s_active); 168 atomic_inc(&sb->s_active);
169 *ptsmnt = mntget(path.mnt);
168 result = DEVPTS_SB(sb); 170 result = DEVPTS_SB(sb);
169 171
170out: 172out:
diff --git a/fs/iomap.c b/fs/iomap.c
index 039266128b7f..59cc98ad7577 100644
--- a/fs/iomap.c
+++ b/fs/iomap.c
@@ -278,7 +278,7 @@ iomap_dirty_actor(struct inode *inode, loff_t pos, loff_t length, void *data,
278 unsigned long bytes; /* Bytes to write to page */ 278 unsigned long bytes; /* Bytes to write to page */
279 279
280 offset = (pos & (PAGE_SIZE - 1)); 280 offset = (pos & (PAGE_SIZE - 1));
281 bytes = min_t(unsigned long, PAGE_SIZE - offset, length); 281 bytes = min_t(loff_t, PAGE_SIZE - offset, length);
282 282
283 rpage = __iomap_read_page(inode, pos); 283 rpage = __iomap_read_page(inode, pos);
284 if (IS_ERR(rpage)) 284 if (IS_ERR(rpage))
@@ -373,7 +373,7 @@ iomap_zero_range_actor(struct inode *inode, loff_t pos, loff_t count,
373 unsigned offset, bytes; 373 unsigned offset, bytes;
374 374
375 offset = pos & (PAGE_SIZE - 1); /* Within page */ 375 offset = pos & (PAGE_SIZE - 1); /* Within page */
376 bytes = min_t(unsigned, PAGE_SIZE - offset, count); 376 bytes = min_t(loff_t, PAGE_SIZE - offset, count);
377 377
378 if (IS_DAX(inode)) 378 if (IS_DAX(inode))
379 status = iomap_dax_zero(pos, offset, bytes, iomap); 379 status = iomap_dax_zero(pos, offset, bytes, iomap);
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
index 53a17496c5c5..566e6ef99f07 100644
--- a/fs/quota/dquot.c
+++ b/fs/quota/dquot.c
@@ -1124,6 +1124,10 @@ void dquot_free_reserved_space(struct dquot *dquot, qsize_t number)
1124 WARN_ON_ONCE(1); 1124 WARN_ON_ONCE(1);
1125 dquot->dq_dqb.dqb_rsvspace = 0; 1125 dquot->dq_dqb.dqb_rsvspace = 0;
1126 } 1126 }
1127 if (dquot->dq_dqb.dqb_curspace + dquot->dq_dqb.dqb_rsvspace <=
1128 dquot->dq_dqb.dqb_bsoftlimit)
1129 dquot->dq_dqb.dqb_btime = (time64_t) 0;
1130 clear_bit(DQ_BLKS_B, &dquot->dq_flags);
1127} 1131}
1128 1132
1129static void dquot_decr_inodes(struct dquot *dquot, qsize_t number) 1133static void dquot_decr_inodes(struct dquot *dquot, qsize_t number)
@@ -1145,7 +1149,8 @@ static void dquot_decr_space(struct dquot *dquot, qsize_t number)
1145 dquot->dq_dqb.dqb_curspace -= number; 1149 dquot->dq_dqb.dqb_curspace -= number;
1146 else 1150 else
1147 dquot->dq_dqb.dqb_curspace = 0; 1151 dquot->dq_dqb.dqb_curspace = 0;
1148 if (dquot->dq_dqb.dqb_curspace <= dquot->dq_dqb.dqb_bsoftlimit) 1152 if (dquot->dq_dqb.dqb_curspace + dquot->dq_dqb.dqb_rsvspace <=
1153 dquot->dq_dqb.dqb_bsoftlimit)
1149 dquot->dq_dqb.dqb_btime = (time64_t) 0; 1154 dquot->dq_dqb.dqb_btime = (time64_t) 0;
1150 clear_bit(DQ_BLKS_B, &dquot->dq_flags); 1155 clear_bit(DQ_BLKS_B, &dquot->dq_flags);
1151} 1156}
@@ -1381,14 +1386,18 @@ static int info_idq_free(struct dquot *dquot, qsize_t inodes)
1381 1386
1382static int info_bdq_free(struct dquot *dquot, qsize_t space) 1387static int info_bdq_free(struct dquot *dquot, qsize_t space)
1383{ 1388{
1389 qsize_t tspace;
1390
1391 tspace = dquot->dq_dqb.dqb_curspace + dquot->dq_dqb.dqb_rsvspace;
1392
1384 if (test_bit(DQ_FAKE_B, &dquot->dq_flags) || 1393 if (test_bit(DQ_FAKE_B, &dquot->dq_flags) ||
1385 dquot->dq_dqb.dqb_curspace <= dquot->dq_dqb.dqb_bsoftlimit) 1394 tspace <= dquot->dq_dqb.dqb_bsoftlimit)
1386 return QUOTA_NL_NOWARN; 1395 return QUOTA_NL_NOWARN;
1387 1396
1388 if (dquot->dq_dqb.dqb_curspace - space <= dquot->dq_dqb.dqb_bsoftlimit) 1397 if (tspace - space <= dquot->dq_dqb.dqb_bsoftlimit)
1389 return QUOTA_NL_BSOFTBELOW; 1398 return QUOTA_NL_BSOFTBELOW;
1390 if (dquot->dq_dqb.dqb_curspace >= dquot->dq_dqb.dqb_bhardlimit && 1399 if (tspace >= dquot->dq_dqb.dqb_bhardlimit &&
1391 dquot->dq_dqb.dqb_curspace - space < dquot->dq_dqb.dqb_bhardlimit) 1400 tspace - space < dquot->dq_dqb.dqb_bhardlimit)
1392 return QUOTA_NL_BHARDBELOW; 1401 return QUOTA_NL_BHARDBELOW;
1393 return QUOTA_NL_NOWARN; 1402 return QUOTA_NL_NOWARN;
1394} 1403}
@@ -2681,7 +2690,7 @@ static int do_set_dqblk(struct dquot *dquot, struct qc_dqblk *di)
2681 2690
2682 if (check_blim) { 2691 if (check_blim) {
2683 if (!dm->dqb_bsoftlimit || 2692 if (!dm->dqb_bsoftlimit ||
2684 dm->dqb_curspace < dm->dqb_bsoftlimit) { 2693 dm->dqb_curspace + dm->dqb_rsvspace < dm->dqb_bsoftlimit) {
2685 dm->dqb_btime = 0; 2694 dm->dqb_btime = 0;
2686 clear_bit(DQ_BLKS_B, &dquot->dq_flags); 2695 clear_bit(DQ_BLKS_B, &dquot->dq_flags);
2687 } else if (!(di->d_fieldmask & QC_SPC_TIMER)) 2696 } else if (!(di->d_fieldmask & QC_SPC_TIMER))
diff --git a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c
index ffd5a15d1bb6..abf5beaae907 100644
--- a/fs/xfs/libxfs/xfs_ialloc.c
+++ b/fs/xfs/libxfs/xfs_ialloc.c
@@ -1246,13 +1246,13 @@ xfs_dialloc_ag_inobt(
1246 1246
1247 /* free inodes to the left? */ 1247 /* free inodes to the left? */
1248 if (useleft && trec.ir_freecount) { 1248 if (useleft && trec.ir_freecount) {
1249 rec = trec;
1250 xfs_btree_del_cursor(cur, XFS_BTREE_NOERROR); 1249 xfs_btree_del_cursor(cur, XFS_BTREE_NOERROR);
1251 cur = tcur; 1250 cur = tcur;
1252 1251
1253 pag->pagl_leftrec = trec.ir_startino; 1252 pag->pagl_leftrec = trec.ir_startino;
1254 pag->pagl_rightrec = rec.ir_startino; 1253 pag->pagl_rightrec = rec.ir_startino;
1255 pag->pagl_pagino = pagino; 1254 pag->pagl_pagino = pagino;
1255 rec = trec;
1256 goto alloc_inode; 1256 goto alloc_inode;
1257 } 1257 }
1258 1258
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
index 0053bcf2b10a..4ebd0bafc914 100644
--- a/fs/xfs/xfs_log.c
+++ b/fs/xfs/xfs_log.c
@@ -749,9 +749,20 @@ xfs_log_mount_finish(
749 return 0; 749 return 0;
750 } 750 }
751 751
752 /*
753 * During the second phase of log recovery, we need iget and
754 * iput to behave like they do for an active filesystem.
755 * xfs_fs_drop_inode needs to be able to prevent the deletion
756 * of inodes before we're done replaying log items on those
757 * inodes. Turn it off immediately after recovery finishes
758 * so that we don't leak the quota inodes if subsequent mount
759 * activities fail.
760 */
761 mp->m_super->s_flags |= MS_ACTIVE;
752 error = xlog_recover_finish(mp->m_log); 762 error = xlog_recover_finish(mp->m_log);
753 if (!error) 763 if (!error)
754 xfs_log_work_queue(mp); 764 xfs_log_work_queue(mp);
765 mp->m_super->s_flags &= ~MS_ACTIVE;
755 766
756 return error; 767 return error;
757} 768}
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index 40d4e8b4e193..ea7d4b4e50d0 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -945,15 +945,6 @@ xfs_mountfs(
945 } 945 }
946 946
947 /* 947 /*
948 * During the second phase of log recovery, we need iget and
949 * iput to behave like they do for an active filesystem.
950 * xfs_fs_drop_inode needs to be able to prevent the deletion
951 * of inodes before we're done replaying log items on those
952 * inodes.
953 */
954 mp->m_super->s_flags |= MS_ACTIVE;
955
956 /*
957 * Finish recovering the file system. This part needed to be delayed 948 * Finish recovering the file system. This part needed to be delayed
958 * until after the root and real-time bitmap inodes were consistently 949 * until after the root and real-time bitmap inodes were consistently
959 * read in. 950 * read in.
@@ -1028,12 +1019,13 @@ xfs_mountfs(
1028 out_quota: 1019 out_quota:
1029 xfs_qm_unmount_quotas(mp); 1020 xfs_qm_unmount_quotas(mp);
1030 out_rtunmount: 1021 out_rtunmount:
1031 mp->m_super->s_flags &= ~MS_ACTIVE;
1032 xfs_rtunmount_inodes(mp); 1022 xfs_rtunmount_inodes(mp);
1033 out_rele_rip: 1023 out_rele_rip:
1034 IRELE(rip); 1024 IRELE(rip);
1035 cancel_delayed_work_sync(&mp->m_reclaim_work); 1025 cancel_delayed_work_sync(&mp->m_reclaim_work);
1036 xfs_reclaim_inodes(mp, SYNC_WAIT); 1026 xfs_reclaim_inodes(mp, SYNC_WAIT);
1027 /* Clean out dquots that might be in memory after quotacheck. */
1028 xfs_qm_unmount(mp);
1037 out_log_dealloc: 1029 out_log_dealloc:
1038 mp->m_flags |= XFS_MOUNT_UNMOUNTING; 1030 mp->m_flags |= XFS_MOUNT_UNMOUNTING;
1039 xfs_log_mount_cancel(mp); 1031 xfs_log_mount_cancel(mp);
diff --git a/include/linux/devpts_fs.h b/include/linux/devpts_fs.h
index 277ab9af9ac2..7883e901f65c 100644
--- a/include/linux/devpts_fs.h
+++ b/include/linux/devpts_fs.h
@@ -19,7 +19,7 @@
19 19
20struct pts_fs_info; 20struct pts_fs_info;
21 21
22struct pts_fs_info *devpts_acquire(struct file *); 22struct pts_fs_info *devpts_acquire(struct file *, struct vfsmount **ptsmnt);
23void devpts_release(struct pts_fs_info *); 23void devpts_release(struct pts_fs_info *);
24 24
25int devpts_new_index(struct pts_fs_info *); 25int devpts_new_index(struct pts_fs_info *);
diff --git a/include/linux/memblock.h b/include/linux/memblock.h
index 77d427974f57..bae11c7e7bf3 100644
--- a/include/linux/memblock.h
+++ b/include/linux/memblock.h
@@ -61,6 +61,7 @@ extern int memblock_debug;
61#ifdef CONFIG_ARCH_DISCARD_MEMBLOCK 61#ifdef CONFIG_ARCH_DISCARD_MEMBLOCK
62#define __init_memblock __meminit 62#define __init_memblock __meminit
63#define __initdata_memblock __meminitdata 63#define __initdata_memblock __meminitdata
64void memblock_discard(void);
64#else 65#else
65#define __init_memblock 66#define __init_memblock
66#define __initdata_memblock 67#define __initdata_memblock
@@ -74,8 +75,6 @@ phys_addr_t memblock_find_in_range_node(phys_addr_t size, phys_addr_t align,
74 int nid, ulong flags); 75 int nid, ulong flags);
75phys_addr_t memblock_find_in_range(phys_addr_t start, phys_addr_t end, 76phys_addr_t memblock_find_in_range(phys_addr_t start, phys_addr_t end,
76 phys_addr_t size, phys_addr_t align); 77 phys_addr_t size, phys_addr_t align);
77phys_addr_t get_allocated_memblock_reserved_regions_info(phys_addr_t *addr);
78phys_addr_t get_allocated_memblock_memory_regions_info(phys_addr_t *addr);
79void memblock_allow_resize(void); 78void memblock_allow_resize(void);
80int memblock_add_node(phys_addr_t base, phys_addr_t size, int nid); 79int memblock_add_node(phys_addr_t base, phys_addr_t size, int nid);
81int memblock_add(phys_addr_t base, phys_addr_t size); 80int memblock_add(phys_addr_t base, phys_addr_t size);
@@ -110,6 +109,9 @@ void __next_mem_range_rev(u64 *idx, int nid, ulong flags,
110void __next_reserved_mem_region(u64 *idx, phys_addr_t *out_start, 109void __next_reserved_mem_region(u64 *idx, phys_addr_t *out_start,
111 phys_addr_t *out_end); 110 phys_addr_t *out_end);
112 111
112void __memblock_free_early(phys_addr_t base, phys_addr_t size);
113void __memblock_free_late(phys_addr_t base, phys_addr_t size);
114
113/** 115/**
114 * for_each_mem_range - iterate through memblock areas from type_a and not 116 * for_each_mem_range - iterate through memblock areas from type_a and not
115 * included in type_b. Or just type_a if type_b is NULL. 117 * included in type_b. Or just type_a if type_b is NULL.
diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index 3914e3dd6168..9b15a4bcfa77 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -484,7 +484,8 @@ bool mem_cgroup_oom_synchronize(bool wait);
484extern int do_swap_account; 484extern int do_swap_account;
485#endif 485#endif
486 486
487void lock_page_memcg(struct page *page); 487struct mem_cgroup *lock_page_memcg(struct page *page);
488void __unlock_page_memcg(struct mem_cgroup *memcg);
488void unlock_page_memcg(struct page *page); 489void unlock_page_memcg(struct page *page);
489 490
490static inline unsigned long memcg_page_state(struct mem_cgroup *memcg, 491static inline unsigned long memcg_page_state(struct mem_cgroup *memcg,
@@ -809,7 +810,12 @@ mem_cgroup_print_oom_info(struct mem_cgroup *memcg, struct task_struct *p)
809{ 810{
810} 811}
811 812
812static inline void lock_page_memcg(struct page *page) 813static inline struct mem_cgroup *lock_page_memcg(struct page *page)
814{
815 return NULL;
816}
817
818static inline void __unlock_page_memcg(struct mem_cgroup *memcg)
813{ 819{
814} 820}
815 821
diff --git a/include/linux/net.h b/include/linux/net.h
index dda2cc939a53..ebeb48c92005 100644
--- a/include/linux/net.h
+++ b/include/linux/net.h
@@ -37,7 +37,7 @@ struct net;
37 37
38/* Historically, SOCKWQ_ASYNC_NOSPACE & SOCKWQ_ASYNC_WAITDATA were located 38/* Historically, SOCKWQ_ASYNC_NOSPACE & SOCKWQ_ASYNC_WAITDATA were located
39 * in sock->flags, but moved into sk->sk_wq->flags to be RCU protected. 39 * in sock->flags, but moved into sk->sk_wq->flags to be RCU protected.
40 * Eventually all flags will be in sk->sk_wq_flags. 40 * Eventually all flags will be in sk->sk_wq->flags.
41 */ 41 */
42#define SOCKWQ_ASYNC_NOSPACE 0 42#define SOCKWQ_ASYNC_NOSPACE 0
43#define SOCKWQ_ASYNC_WAITDATA 1 43#define SOCKWQ_ASYNC_WAITDATA 1
diff --git a/include/linux/nmi.h b/include/linux/nmi.h
index 8aa01fd859fb..a36abe2da13e 100644
--- a/include/linux/nmi.h
+++ b/include/linux/nmi.h
@@ -168,6 +168,14 @@ extern int sysctl_hardlockup_all_cpu_backtrace;
168#define sysctl_softlockup_all_cpu_backtrace 0 168#define sysctl_softlockup_all_cpu_backtrace 0
169#define sysctl_hardlockup_all_cpu_backtrace 0 169#define sysctl_hardlockup_all_cpu_backtrace 0
170#endif 170#endif
171
172#if defined(CONFIG_HARDLOCKUP_CHECK_TIMESTAMP) && \
173 defined(CONFIG_HARDLOCKUP_DETECTOR)
174void watchdog_update_hrtimer_threshold(u64 period);
175#else
176static inline void watchdog_update_hrtimer_threshold(u64 period) { }
177#endif
178
171extern bool is_hardlockup(void); 179extern bool is_hardlockup(void);
172struct ctl_table; 180struct ctl_table;
173extern int proc_watchdog(struct ctl_table *, int , 181extern int proc_watchdog(struct ctl_table *, int ,
diff --git a/include/linux/oom.h b/include/linux/oom.h
index 8a266e2be5a6..76aac4ce39bc 100644
--- a/include/linux/oom.h
+++ b/include/linux/oom.h
@@ -6,6 +6,8 @@
6#include <linux/types.h> 6#include <linux/types.h>
7#include <linux/nodemask.h> 7#include <linux/nodemask.h>
8#include <uapi/linux/oom.h> 8#include <uapi/linux/oom.h>
9#include <linux/sched/coredump.h> /* MMF_* */
10#include <linux/mm.h> /* VM_FAULT* */
9 11
10struct zonelist; 12struct zonelist;
11struct notifier_block; 13struct notifier_block;
@@ -63,6 +65,26 @@ static inline bool tsk_is_oom_victim(struct task_struct * tsk)
63 return tsk->signal->oom_mm; 65 return tsk->signal->oom_mm;
64} 66}
65 67
68/*
69 * Checks whether a page fault on the given mm is still reliable.
70 * This is no longer true if the oom reaper started to reap the
71 * address space which is reflected by MMF_UNSTABLE flag set in
72 * the mm. At that moment any !shared mapping would lose the content
73 * and could cause a memory corruption (zero pages instead of the
74 * original content).
75 *
76 * User should call this before establishing a page table entry for
77 * a !shared mapping and under the proper page table lock.
78 *
79 * Return 0 when the PF is safe VM_FAULT_SIGBUS otherwise.
80 */
81static inline int check_stable_address_space(struct mm_struct *mm)
82{
83 if (unlikely(test_bit(MMF_UNSTABLE, &mm->flags)))
84 return VM_FAULT_SIGBUS;
85 return 0;
86}
87
66extern unsigned long oom_badness(struct task_struct *p, 88extern unsigned long oom_badness(struct task_struct *p,
67 struct mem_cgroup *memcg, const nodemask_t *nodemask, 89 struct mem_cgroup *memcg, const nodemask_t *nodemask,
68 unsigned long totalpages); 90 unsigned long totalpages);
diff --git a/include/linux/pci.h b/include/linux/pci.h
index a75c13673852..f958d0732af6 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -188,6 +188,8 @@ enum pci_dev_flags {
188 * the direct_complete optimization. 188 * the direct_complete optimization.
189 */ 189 */
190 PCI_DEV_FLAGS_NEEDS_RESUME = (__force pci_dev_flags_t) (1 << 11), 190 PCI_DEV_FLAGS_NEEDS_RESUME = (__force pci_dev_flags_t) (1 << 11),
191 /* Don't use Relaxed Ordering for TLPs directed at this device */
192 PCI_DEV_FLAGS_NO_RELAXED_ORDERING = (__force pci_dev_flags_t) (1 << 12),
191}; 193};
192 194
193enum pci_irq_reroute_variant { 195enum pci_irq_reroute_variant {
@@ -1126,6 +1128,7 @@ bool pci_check_pme_status(struct pci_dev *dev);
1126void pci_pme_wakeup_bus(struct pci_bus *bus); 1128void pci_pme_wakeup_bus(struct pci_bus *bus);
1127void pci_d3cold_enable(struct pci_dev *dev); 1129void pci_d3cold_enable(struct pci_dev *dev);
1128void pci_d3cold_disable(struct pci_dev *dev); 1130void pci_d3cold_disable(struct pci_dev *dev);
1131bool pcie_relaxed_ordering_enabled(struct pci_dev *dev);
1129 1132
1130/* PCI Virtual Channel */ 1133/* PCI Virtual Channel */
1131int pci_save_vc_state(struct pci_dev *dev); 1134int pci_save_vc_state(struct pci_dev *dev);
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index a3b873fc59e4..b14095bcf4bb 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -310,8 +310,8 @@ struct pmu {
310 * Notification that the event was mapped or unmapped. Called 310 * Notification that the event was mapped or unmapped. Called
311 * in the context of the mapping task. 311 * in the context of the mapping task.
312 */ 312 */
313 void (*event_mapped) (struct perf_event *event); /*optional*/ 313 void (*event_mapped) (struct perf_event *event, struct mm_struct *mm); /* optional */
314 void (*event_unmapped) (struct perf_event *event); /*optional*/ 314 void (*event_unmapped) (struct perf_event *event, struct mm_struct *mm); /* optional */
315 315
316 /* 316 /*
317 * Flags for ->add()/->del()/ ->start()/->stop(). There are 317 * Flags for ->add()/->del()/ ->start()/->stop(). There are
diff --git a/include/linux/wait.h b/include/linux/wait.h
index 5b74e36c0ca8..dc19880c02f5 100644
--- a/include/linux/wait.h
+++ b/include/linux/wait.h
@@ -757,6 +757,43 @@ extern int do_wait_intr_irq(wait_queue_head_t *, wait_queue_entry_t *);
757 __ret; \ 757 __ret; \
758}) 758})
759 759
760#define __wait_event_killable_timeout(wq_head, condition, timeout) \
761 ___wait_event(wq_head, ___wait_cond_timeout(condition), \
762 TASK_KILLABLE, 0, timeout, \
763 __ret = schedule_timeout(__ret))
764
765/**
766 * wait_event_killable_timeout - sleep until a condition gets true or a timeout elapses
767 * @wq_head: the waitqueue to wait on
768 * @condition: a C expression for the event to wait for
769 * @timeout: timeout, in jiffies
770 *
771 * The process is put to sleep (TASK_KILLABLE) until the
772 * @condition evaluates to true or a kill signal is received.
773 * The @condition is checked each time the waitqueue @wq_head is woken up.
774 *
775 * wake_up() has to be called after changing any variable that could
776 * change the result of the wait condition.
777 *
778 * Returns:
779 * 0 if the @condition evaluated to %false after the @timeout elapsed,
780 * 1 if the @condition evaluated to %true after the @timeout elapsed,
781 * the remaining jiffies (at least 1) if the @condition evaluated
782 * to %true before the @timeout elapsed, or -%ERESTARTSYS if it was
783 * interrupted by a kill signal.
784 *
785 * Only kill signals interrupt this process.
786 */
787#define wait_event_killable_timeout(wq_head, condition, timeout) \
788({ \
789 long __ret = timeout; \
790 might_sleep(); \
791 if (!___wait_cond_timeout(condition)) \
792 __ret = __wait_event_killable_timeout(wq_head, \
793 condition, timeout); \
794 __ret; \
795})
796
760 797
761#define __wait_event_lock_irq(wq_head, condition, lock, cmd) \ 798#define __wait_event_lock_irq(wq_head, condition, lock, cmd) \
762 (void)___wait_event(wq_head, condition, TASK_UNINTERRUPTIBLE, 0, 0, \ 799 (void)___wait_event(wq_head, condition, TASK_UNINTERRUPTIBLE, 0, 0, \
diff --git a/include/net/addrconf.h b/include/net/addrconf.h
index 6df79e96a780..f44ff2476758 100644
--- a/include/net/addrconf.h
+++ b/include/net/addrconf.h
@@ -336,6 +336,16 @@ static inline void in6_dev_put(struct inet6_dev *idev)
336 in6_dev_finish_destroy(idev); 336 in6_dev_finish_destroy(idev);
337} 337}
338 338
339static inline void in6_dev_put_clear(struct inet6_dev **pidev)
340{
341 struct inet6_dev *idev = *pidev;
342
343 if (idev) {
344 in6_dev_put(idev);
345 *pidev = NULL;
346 }
347}
348
339static inline void __in6_dev_put(struct inet6_dev *idev) 349static inline void __in6_dev_put(struct inet6_dev *idev)
340{ 350{
341 refcount_dec(&idev->refcnt); 351 refcount_dec(&idev->refcnt);
diff --git a/include/net/bonding.h b/include/net/bonding.h
index b00508d22e0a..b2e68657a216 100644
--- a/include/net/bonding.h
+++ b/include/net/bonding.h
@@ -277,6 +277,11 @@ static inline bool bond_is_lb(const struct bonding *bond)
277 BOND_MODE(bond) == BOND_MODE_ALB; 277 BOND_MODE(bond) == BOND_MODE_ALB;
278} 278}
279 279
280static inline bool bond_needs_speed_duplex(const struct bonding *bond)
281{
282 return BOND_MODE(bond) == BOND_MODE_8023AD || bond_is_lb(bond);
283}
284
280static inline bool bond_is_nondyn_tlb(const struct bonding *bond) 285static inline bool bond_is_nondyn_tlb(const struct bonding *bond)
281{ 286{
282 return (BOND_MODE(bond) == BOND_MODE_TLB) && 287 return (BOND_MODE(bond) == BOND_MODE_TLB) &&
diff --git a/include/net/busy_poll.h b/include/net/busy_poll.h
index 8ffd434676b7..71c72a939bf8 100644
--- a/include/net/busy_poll.h
+++ b/include/net/busy_poll.h
@@ -29,18 +29,18 @@
29#include <linux/sched/signal.h> 29#include <linux/sched/signal.h>
30#include <net/ip.h> 30#include <net/ip.h>
31 31
32#ifdef CONFIG_NET_RX_BUSY_POLL
33
34struct napi_struct;
35extern unsigned int sysctl_net_busy_read __read_mostly;
36extern unsigned int sysctl_net_busy_poll __read_mostly;
37
38/* 0 - Reserved to indicate value not set 32/* 0 - Reserved to indicate value not set
39 * 1..NR_CPUS - Reserved for sender_cpu 33 * 1..NR_CPUS - Reserved for sender_cpu
40 * NR_CPUS+1..~0 - Region available for NAPI IDs 34 * NR_CPUS+1..~0 - Region available for NAPI IDs
41 */ 35 */
42#define MIN_NAPI_ID ((unsigned int)(NR_CPUS + 1)) 36#define MIN_NAPI_ID ((unsigned int)(NR_CPUS + 1))
43 37
38#ifdef CONFIG_NET_RX_BUSY_POLL
39
40struct napi_struct;
41extern unsigned int sysctl_net_busy_read __read_mostly;
42extern unsigned int sysctl_net_busy_poll __read_mostly;
43
44static inline bool net_busy_loop_on(void) 44static inline bool net_busy_loop_on(void)
45{ 45{
46 return sysctl_net_busy_poll; 46 return sysctl_net_busy_poll;
diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index b2b5419467cc..f8149ca192b4 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -5499,6 +5499,21 @@ static inline void ieee80211_stop_rx_ba_session_offl(struct ieee80211_vif *vif,
5499 ieee80211_manage_rx_ba_offl(vif, addr, tid + IEEE80211_NUM_TIDS); 5499 ieee80211_manage_rx_ba_offl(vif, addr, tid + IEEE80211_NUM_TIDS);
5500} 5500}
5501 5501
5502/**
5503 * ieee80211_rx_ba_timer_expired - stop a Rx BA session due to timeout
5504 *
5505 * Some device drivers do not offload AddBa/DelBa negotiation, but handle rx
5506 * buffer reording internally, and therefore also handle the session timer.
5507 *
5508 * Trigger the timeout flow, which sends a DelBa.
5509 *
5510 * @vif: &struct ieee80211_vif pointer from the add_interface callback
5511 * @addr: station mac address
5512 * @tid: the rx tid
5513 */
5514void ieee80211_rx_ba_timer_expired(struct ieee80211_vif *vif,
5515 const u8 *addr, unsigned int tid);
5516
5502/* Rate control API */ 5517/* Rate control API */
5503 5518
5504/** 5519/**
diff --git a/include/net/udp.h b/include/net/udp.h
index cc8036987dcb..586de4b811b5 100644
--- a/include/net/udp.h
+++ b/include/net/udp.h
@@ -366,12 +366,13 @@ static inline bool udp_skb_is_linear(struct sk_buff *skb)
366static inline int copy_linear_skb(struct sk_buff *skb, int len, int off, 366static inline int copy_linear_skb(struct sk_buff *skb, int len, int off,
367 struct iov_iter *to) 367 struct iov_iter *to)
368{ 368{
369 int n, copy = len - off; 369 int n;
370 370
371 n = copy_to_iter(skb->data + off, copy, to); 371 n = copy_to_iter(skb->data + off, len, to);
372 if (n == copy) 372 if (n == len)
373 return 0; 373 return 0;
374 374
375 iov_iter_revert(to, n);
375 return -EFAULT; 376 return -EFAULT;
376} 377}
377 378
diff --git a/kernel/audit_watch.c b/kernel/audit_watch.c
index 62d686d96581..9eb8b3511636 100644
--- a/kernel/audit_watch.c
+++ b/kernel/audit_watch.c
@@ -66,7 +66,7 @@ static struct fsnotify_group *audit_watch_group;
66 66
67/* fsnotify events we care about. */ 67/* fsnotify events we care about. */
68#define AUDIT_FS_WATCH (FS_MOVE | FS_CREATE | FS_DELETE | FS_DELETE_SELF |\ 68#define AUDIT_FS_WATCH (FS_MOVE | FS_CREATE | FS_DELETE | FS_DELETE_SELF |\
69 FS_MOVE_SELF | FS_EVENT_ON_CHILD) 69 FS_MOVE_SELF | FS_EVENT_ON_CHILD | FS_UNMOUNT)
70 70
71static void audit_free_parent(struct audit_parent *parent) 71static void audit_free_parent(struct audit_parent *parent)
72{ 72{
@@ -457,13 +457,15 @@ void audit_remove_watch_rule(struct audit_krule *krule)
457 list_del(&krule->rlist); 457 list_del(&krule->rlist);
458 458
459 if (list_empty(&watch->rules)) { 459 if (list_empty(&watch->rules)) {
460 /*
461 * audit_remove_watch() drops our reference to 'parent' which
462 * can get freed. Grab our own reference to be safe.
463 */
464 audit_get_parent(parent);
460 audit_remove_watch(watch); 465 audit_remove_watch(watch);
461 466 if (list_empty(&parent->watches))
462 if (list_empty(&parent->watches)) {
463 audit_get_parent(parent);
464 fsnotify_destroy_mark(&parent->mark, audit_watch_group); 467 fsnotify_destroy_mark(&parent->mark, audit_watch_group);
465 audit_put_parent(parent); 468 audit_put_parent(parent);
466 }
467 } 469 }
468} 470}
469 471
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 426c2ffba16d..ee20d4c546b5 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -2217,6 +2217,33 @@ static int group_can_go_on(struct perf_event *event,
2217 return can_add_hw; 2217 return can_add_hw;
2218} 2218}
2219 2219
2220/*
2221 * Complement to update_event_times(). This computes the tstamp_* values to
2222 * continue 'enabled' state from @now, and effectively discards the time
2223 * between the prior tstamp_stopped and now (as we were in the OFF state, or
2224 * just switched (context) time base).
2225 *
2226 * This further assumes '@event->state == INACTIVE' (we just came from OFF) and
2227 * cannot have been scheduled in yet. And going into INACTIVE state means
2228 * '@event->tstamp_stopped = @now'.
2229 *
2230 * Thus given the rules of update_event_times():
2231 *
2232 * total_time_enabled = tstamp_stopped - tstamp_enabled
2233 * total_time_running = tstamp_stopped - tstamp_running
2234 *
2235 * We can insert 'tstamp_stopped == now' and reverse them to compute new
2236 * tstamp_* values.
2237 */
2238static void __perf_event_enable_time(struct perf_event *event, u64 now)
2239{
2240 WARN_ON_ONCE(event->state != PERF_EVENT_STATE_INACTIVE);
2241
2242 event->tstamp_stopped = now;
2243 event->tstamp_enabled = now - event->total_time_enabled;
2244 event->tstamp_running = now - event->total_time_running;
2245}
2246
2220static void add_event_to_ctx(struct perf_event *event, 2247static void add_event_to_ctx(struct perf_event *event,
2221 struct perf_event_context *ctx) 2248 struct perf_event_context *ctx)
2222{ 2249{
@@ -2224,9 +2251,12 @@ static void add_event_to_ctx(struct perf_event *event,
2224 2251
2225 list_add_event(event, ctx); 2252 list_add_event(event, ctx);
2226 perf_group_attach(event); 2253 perf_group_attach(event);
2227 event->tstamp_enabled = tstamp; 2254 /*
2228 event->tstamp_running = tstamp; 2255 * We can be called with event->state == STATE_OFF when we create with
2229 event->tstamp_stopped = tstamp; 2256 * .disabled = 1. In that case the IOC_ENABLE will call this function.
2257 */
2258 if (event->state == PERF_EVENT_STATE_INACTIVE)
2259 __perf_event_enable_time(event, tstamp);
2230} 2260}
2231 2261
2232static void ctx_sched_out(struct perf_event_context *ctx, 2262static void ctx_sched_out(struct perf_event_context *ctx,
@@ -2471,10 +2501,11 @@ static void __perf_event_mark_enabled(struct perf_event *event)
2471 u64 tstamp = perf_event_time(event); 2501 u64 tstamp = perf_event_time(event);
2472 2502
2473 event->state = PERF_EVENT_STATE_INACTIVE; 2503 event->state = PERF_EVENT_STATE_INACTIVE;
2474 event->tstamp_enabled = tstamp - event->total_time_enabled; 2504 __perf_event_enable_time(event, tstamp);
2475 list_for_each_entry(sub, &event->sibling_list, group_entry) { 2505 list_for_each_entry(sub, &event->sibling_list, group_entry) {
2506 /* XXX should not be > INACTIVE if event isn't */
2476 if (sub->state >= PERF_EVENT_STATE_INACTIVE) 2507 if (sub->state >= PERF_EVENT_STATE_INACTIVE)
2477 sub->tstamp_enabled = tstamp - sub->total_time_enabled; 2508 __perf_event_enable_time(sub, tstamp);
2478 } 2509 }
2479} 2510}
2480 2511
@@ -5090,7 +5121,7 @@ static void perf_mmap_open(struct vm_area_struct *vma)
5090 atomic_inc(&event->rb->aux_mmap_count); 5121 atomic_inc(&event->rb->aux_mmap_count);
5091 5122
5092 if (event->pmu->event_mapped) 5123 if (event->pmu->event_mapped)
5093 event->pmu->event_mapped(event); 5124 event->pmu->event_mapped(event, vma->vm_mm);
5094} 5125}
5095 5126
5096static void perf_pmu_output_stop(struct perf_event *event); 5127static void perf_pmu_output_stop(struct perf_event *event);
@@ -5113,7 +5144,7 @@ static void perf_mmap_close(struct vm_area_struct *vma)
5113 unsigned long size = perf_data_size(rb); 5144 unsigned long size = perf_data_size(rb);
5114 5145
5115 if (event->pmu->event_unmapped) 5146 if (event->pmu->event_unmapped)
5116 event->pmu->event_unmapped(event); 5147 event->pmu->event_unmapped(event, vma->vm_mm);
5117 5148
5118 /* 5149 /*
5119 * rb->aux_mmap_count will always drop before rb->mmap_count and 5150 * rb->aux_mmap_count will always drop before rb->mmap_count and
@@ -5411,7 +5442,7 @@ aux_unlock:
5411 vma->vm_ops = &perf_mmap_vmops; 5442 vma->vm_ops = &perf_mmap_vmops;
5412 5443
5413 if (event->pmu->event_mapped) 5444 if (event->pmu->event_mapped)
5414 event->pmu->event_mapped(event); 5445 event->pmu->event_mapped(event, vma->vm_mm);
5415 5446
5416 return ret; 5447 return ret;
5417} 5448}
diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c
index a3cc37c0c85e..3675c6004f2a 100644
--- a/kernel/irq/chip.c
+++ b/kernel/irq/chip.c
@@ -1000,7 +1000,7 @@ EXPORT_SYMBOL_GPL(irq_set_chip_and_handler_name);
1000 1000
1001void irq_modify_status(unsigned int irq, unsigned long clr, unsigned long set) 1001void irq_modify_status(unsigned int irq, unsigned long clr, unsigned long set)
1002{ 1002{
1003 unsigned long flags; 1003 unsigned long flags, trigger, tmp;
1004 struct irq_desc *desc = irq_get_desc_lock(irq, &flags, 0); 1004 struct irq_desc *desc = irq_get_desc_lock(irq, &flags, 0);
1005 1005
1006 if (!desc) 1006 if (!desc)
@@ -1014,6 +1014,8 @@ void irq_modify_status(unsigned int irq, unsigned long clr, unsigned long set)
1014 1014
1015 irq_settings_clr_and_set(desc, clr, set); 1015 irq_settings_clr_and_set(desc, clr, set);
1016 1016
1017 trigger = irqd_get_trigger_type(&desc->irq_data);
1018
1017 irqd_clear(&desc->irq_data, IRQD_NO_BALANCING | IRQD_PER_CPU | 1019 irqd_clear(&desc->irq_data, IRQD_NO_BALANCING | IRQD_PER_CPU |
1018 IRQD_TRIGGER_MASK | IRQD_LEVEL | IRQD_MOVE_PCNTXT); 1020 IRQD_TRIGGER_MASK | IRQD_LEVEL | IRQD_MOVE_PCNTXT);
1019 if (irq_settings_has_no_balance_set(desc)) 1021 if (irq_settings_has_no_balance_set(desc))
@@ -1025,7 +1027,11 @@ void irq_modify_status(unsigned int irq, unsigned long clr, unsigned long set)
1025 if (irq_settings_is_level(desc)) 1027 if (irq_settings_is_level(desc))
1026 irqd_set(&desc->irq_data, IRQD_LEVEL); 1028 irqd_set(&desc->irq_data, IRQD_LEVEL);
1027 1029
1028 irqd_set(&desc->irq_data, irq_settings_get_trigger_mask(desc)); 1030 tmp = irq_settings_get_trigger_mask(desc);
1031 if (tmp != IRQ_TYPE_NONE)
1032 trigger = tmp;
1033
1034 irqd_set(&desc->irq_data, trigger);
1029 1035
1030 irq_put_desc_unlock(desc, flags); 1036 irq_put_desc_unlock(desc, flags);
1031} 1037}
diff --git a/kernel/irq/ipi.c b/kernel/irq/ipi.c
index 1a9abc1c8ea0..259a22aa9934 100644
--- a/kernel/irq/ipi.c
+++ b/kernel/irq/ipi.c
@@ -165,7 +165,7 @@ irq_hw_number_t ipi_get_hwirq(unsigned int irq, unsigned int cpu)
165 struct irq_data *data = irq_get_irq_data(irq); 165 struct irq_data *data = irq_get_irq_data(irq);
166 struct cpumask *ipimask = data ? irq_data_get_affinity_mask(data) : NULL; 166 struct cpumask *ipimask = data ? irq_data_get_affinity_mask(data) : NULL;
167 167
168 if (!data || !ipimask || cpu > nr_cpu_ids) 168 if (!data || !ipimask || cpu >= nr_cpu_ids)
169 return INVALID_HWIRQ; 169 return INVALID_HWIRQ;
170 170
171 if (!cpumask_test_cpu(cpu, ipimask)) 171 if (!cpumask_test_cpu(cpu, ipimask))
@@ -195,7 +195,7 @@ static int ipi_send_verify(struct irq_chip *chip, struct irq_data *data,
195 if (!chip->ipi_send_single && !chip->ipi_send_mask) 195 if (!chip->ipi_send_single && !chip->ipi_send_mask)
196 return -EINVAL; 196 return -EINVAL;
197 197
198 if (cpu > nr_cpu_ids) 198 if (cpu >= nr_cpu_ids)
199 return -EINVAL; 199 return -EINVAL;
200 200
201 if (dest) { 201 if (dest) {
diff --git a/kernel/kmod.c b/kernel/kmod.c
index 6d016c5d97c8..2f37acde640b 100644
--- a/kernel/kmod.c
+++ b/kernel/kmod.c
@@ -71,6 +71,18 @@ static atomic_t kmod_concurrent_max = ATOMIC_INIT(MAX_KMOD_CONCURRENT);
71static DECLARE_WAIT_QUEUE_HEAD(kmod_wq); 71static DECLARE_WAIT_QUEUE_HEAD(kmod_wq);
72 72
73/* 73/*
74 * This is a restriction on having *all* MAX_KMOD_CONCURRENT threads
75 * running at the same time without returning. When this happens we
76 * believe you've somehow ended up with a recursive module dependency
77 * creating a loop.
78 *
79 * We have no option but to fail.
80 *
81 * Userspace should proactively try to detect and prevent these.
82 */
83#define MAX_KMOD_ALL_BUSY_TIMEOUT 5
84
85/*
74 modprobe_path is set via /proc/sys. 86 modprobe_path is set via /proc/sys.
75*/ 87*/
76char modprobe_path[KMOD_PATH_LEN] = "/sbin/modprobe"; 88char modprobe_path[KMOD_PATH_LEN] = "/sbin/modprobe";
@@ -167,8 +179,17 @@ int __request_module(bool wait, const char *fmt, ...)
167 pr_warn_ratelimited("request_module: kmod_concurrent_max (%u) close to 0 (max_modprobes: %u), for module %s, throttling...", 179 pr_warn_ratelimited("request_module: kmod_concurrent_max (%u) close to 0 (max_modprobes: %u), for module %s, throttling...",
168 atomic_read(&kmod_concurrent_max), 180 atomic_read(&kmod_concurrent_max),
169 MAX_KMOD_CONCURRENT, module_name); 181 MAX_KMOD_CONCURRENT, module_name);
170 wait_event_interruptible(kmod_wq, 182 ret = wait_event_killable_timeout(kmod_wq,
171 atomic_dec_if_positive(&kmod_concurrent_max) >= 0); 183 atomic_dec_if_positive(&kmod_concurrent_max) >= 0,
184 MAX_KMOD_ALL_BUSY_TIMEOUT * HZ);
185 if (!ret) {
186 pr_warn_ratelimited("request_module: modprobe %s cannot be processed, kmod busy with %d threads for more than %d seconds now",
187 module_name, MAX_KMOD_CONCURRENT, MAX_KMOD_ALL_BUSY_TIMEOUT);
188 return -ETIME;
189 } else if (ret == -ERESTARTSYS) {
190 pr_warn_ratelimited("request_module: sigkill sent for modprobe %s, giving up", module_name);
191 return ret;
192 }
172 } 193 }
173 194
174 trace_module_request(module_name, wait, _RET_IP_); 195 trace_module_request(module_name, wait, _RET_IP_);
diff --git a/kernel/signal.c b/kernel/signal.c
index 7e33f8c583e6..ed804a470dcd 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -1194,7 +1194,11 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
1194 recalc_sigpending_and_wake(t); 1194 recalc_sigpending_and_wake(t);
1195 } 1195 }
1196 } 1196 }
1197 if (action->sa.sa_handler == SIG_DFL) 1197 /*
1198 * Don't clear SIGNAL_UNKILLABLE for traced tasks, users won't expect
1199 * debugging to leave init killable.
1200 */
1201 if (action->sa.sa_handler == SIG_DFL && !t->ptrace)
1198 t->signal->flags &= ~SIGNAL_UNKILLABLE; 1202 t->signal->flags &= ~SIGNAL_UNKILLABLE;
1199 ret = specific_send_sig_info(sig, info, t); 1203 ret = specific_send_sig_info(sig, info, t);
1200 spin_unlock_irqrestore(&t->sighand->siglock, flags); 1204 spin_unlock_irqrestore(&t->sighand->siglock, flags);
diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
index 37385193a608..dc498b605d5d 100644
--- a/kernel/trace/bpf_trace.c
+++ b/kernel/trace/bpf_trace.c
@@ -204,10 +204,36 @@ BPF_CALL_5(bpf_trace_printk, char *, fmt, u32, fmt_size, u64, arg1,
204 fmt_cnt++; 204 fmt_cnt++;
205 } 205 }
206 206
207 return __trace_printk(1/* fake ip will not be printed */, fmt, 207/* Horrid workaround for getting va_list handling working with different
208 mod[0] == 2 ? arg1 : mod[0] == 1 ? (long) arg1 : (u32) arg1, 208 * argument type combinations generically for 32 and 64 bit archs.
209 mod[1] == 2 ? arg2 : mod[1] == 1 ? (long) arg2 : (u32) arg2, 209 */
210 mod[2] == 2 ? arg3 : mod[2] == 1 ? (long) arg3 : (u32) arg3); 210#define __BPF_TP_EMIT() __BPF_ARG3_TP()
211#define __BPF_TP(...) \
212 __trace_printk(1 /* Fake ip will not be printed. */, \
213 fmt, ##__VA_ARGS__)
214
215#define __BPF_ARG1_TP(...) \
216 ((mod[0] == 2 || (mod[0] == 1 && __BITS_PER_LONG == 64)) \
217 ? __BPF_TP(arg1, ##__VA_ARGS__) \
218 : ((mod[0] == 1 || (mod[0] == 0 && __BITS_PER_LONG == 32)) \
219 ? __BPF_TP((long)arg1, ##__VA_ARGS__) \
220 : __BPF_TP((u32)arg1, ##__VA_ARGS__)))
221
222#define __BPF_ARG2_TP(...) \
223 ((mod[1] == 2 || (mod[1] == 1 && __BITS_PER_LONG == 64)) \
224 ? __BPF_ARG1_TP(arg2, ##__VA_ARGS__) \
225 : ((mod[1] == 1 || (mod[1] == 0 && __BITS_PER_LONG == 32)) \
226 ? __BPF_ARG1_TP((long)arg2, ##__VA_ARGS__) \
227 : __BPF_ARG1_TP((u32)arg2, ##__VA_ARGS__)))
228
229#define __BPF_ARG3_TP(...) \
230 ((mod[2] == 2 || (mod[2] == 1 && __BITS_PER_LONG == 64)) \
231 ? __BPF_ARG2_TP(arg3, ##__VA_ARGS__) \
232 : ((mod[2] == 1 || (mod[2] == 0 && __BITS_PER_LONG == 32)) \
233 ? __BPF_ARG2_TP((long)arg3, ##__VA_ARGS__) \
234 : __BPF_ARG2_TP((u32)arg3, ##__VA_ARGS__)))
235
236 return __BPF_TP_EMIT();
211} 237}
212 238
213static const struct bpf_func_proto bpf_trace_printk_proto = { 239static const struct bpf_func_proto bpf_trace_printk_proto = {
diff --git a/kernel/watchdog.c b/kernel/watchdog.c
index 06d3389bca0d..f5d52024f6b7 100644
--- a/kernel/watchdog.c
+++ b/kernel/watchdog.c
@@ -240,6 +240,7 @@ static void set_sample_period(void)
240 * hardlockup detector generates a warning 240 * hardlockup detector generates a warning
241 */ 241 */
242 sample_period = get_softlockup_thresh() * ((u64)NSEC_PER_SEC / 5); 242 sample_period = get_softlockup_thresh() * ((u64)NSEC_PER_SEC / 5);
243 watchdog_update_hrtimer_threshold(sample_period);
243} 244}
244 245
245/* Commands for resetting the watchdog */ 246/* Commands for resetting the watchdog */
diff --git a/kernel/watchdog_hld.c b/kernel/watchdog_hld.c
index 295a0d84934c..3a09ea1b1d3d 100644
--- a/kernel/watchdog_hld.c
+++ b/kernel/watchdog_hld.c
@@ -37,6 +37,62 @@ void arch_touch_nmi_watchdog(void)
37} 37}
38EXPORT_SYMBOL(arch_touch_nmi_watchdog); 38EXPORT_SYMBOL(arch_touch_nmi_watchdog);
39 39
40#ifdef CONFIG_HARDLOCKUP_CHECK_TIMESTAMP
41static DEFINE_PER_CPU(ktime_t, last_timestamp);
42static DEFINE_PER_CPU(unsigned int, nmi_rearmed);
43static ktime_t watchdog_hrtimer_sample_threshold __read_mostly;
44
45void watchdog_update_hrtimer_threshold(u64 period)
46{
47 /*
48 * The hrtimer runs with a period of (watchdog_threshold * 2) / 5
49 *
50 * So it runs effectively with 2.5 times the rate of the NMI
51 * watchdog. That means the hrtimer should fire 2-3 times before
52 * the NMI watchdog expires. The NMI watchdog on x86 is based on
53 * unhalted CPU cycles, so if Turbo-Mode is enabled the CPU cycles
54 * might run way faster than expected and the NMI fires in a
55 * smaller period than the one deduced from the nominal CPU
56 * frequency. Depending on the Turbo-Mode factor this might be fast
57 * enough to get the NMI period smaller than the hrtimer watchdog
58 * period and trigger false positives.
59 *
60 * The sample threshold is used to check in the NMI handler whether
61 * the minimum time between two NMI samples has elapsed. That
62 * prevents false positives.
63 *
64 * Set this to 4/5 of the actual watchdog threshold period so the
65 * hrtimer is guaranteed to fire at least once within the real
66 * watchdog threshold.
67 */
68 watchdog_hrtimer_sample_threshold = period * 2;
69}
70
71static bool watchdog_check_timestamp(void)
72{
73 ktime_t delta, now = ktime_get_mono_fast_ns();
74
75 delta = now - __this_cpu_read(last_timestamp);
76 if (delta < watchdog_hrtimer_sample_threshold) {
77 /*
78 * If ktime is jiffies based, a stalled timer would prevent
79 * jiffies from being incremented and the filter would look
80 * at a stale timestamp and never trigger.
81 */
82 if (__this_cpu_inc_return(nmi_rearmed) < 10)
83 return false;
84 }
85 __this_cpu_write(nmi_rearmed, 0);
86 __this_cpu_write(last_timestamp, now);
87 return true;
88}
89#else
90static inline bool watchdog_check_timestamp(void)
91{
92 return true;
93}
94#endif
95
40static struct perf_event_attr wd_hw_attr = { 96static struct perf_event_attr wd_hw_attr = {
41 .type = PERF_TYPE_HARDWARE, 97 .type = PERF_TYPE_HARDWARE,
42 .config = PERF_COUNT_HW_CPU_CYCLES, 98 .config = PERF_COUNT_HW_CPU_CYCLES,
@@ -61,6 +117,9 @@ static void watchdog_overflow_callback(struct perf_event *event,
61 return; 117 return;
62 } 118 }
63 119
120 if (!watchdog_check_timestamp())
121 return;
122
64 /* check for a hardlockup 123 /* check for a hardlockup
65 * This is done by making sure our timer interrupt 124 * This is done by making sure our timer interrupt
66 * is incrementing. The timer interrupt should have 125 * is incrementing. The timer interrupt should have
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 98fe715522e8..c617b9d1d6cb 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -798,6 +798,13 @@ config HARDLOCKUP_DETECTOR_PERF
798 select SOFTLOCKUP_DETECTOR 798 select SOFTLOCKUP_DETECTOR
799 799
800# 800#
801# Enables a timestamp based low pass filter to compensate for perf based
802# hard lockup detection which runs too fast due to turbo modes.
803#
804config HARDLOCKUP_CHECK_TIMESTAMP
805 bool
806
807#
801# arch/ can define HAVE_HARDLOCKUP_DETECTOR_ARCH to provide their own hard 808# arch/ can define HAVE_HARDLOCKUP_DETECTOR_ARCH to provide their own hard
802# lockup detector rather than the perf based detector. 809# lockup detector rather than the perf based detector.
803# 810#
diff --git a/mm/cma_debug.c b/mm/cma_debug.c
index 595b757bef72..c03ccbc405a0 100644
--- a/mm/cma_debug.c
+++ b/mm/cma_debug.c
@@ -167,7 +167,7 @@ static void cma_debugfs_add_one(struct cma *cma, int idx)
167 char name[16]; 167 char name[16];
168 int u32s; 168 int u32s;
169 169
170 sprintf(name, "cma-%s", cma->name); 170 scnprintf(name, sizeof(name), "cma-%s", cma->name);
171 171
172 tmp = debugfs_create_dir(name, cma_debugfs_root); 172 tmp = debugfs_create_dir(name, cma_debugfs_root);
173 173
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 216114f6ef0b..90731e3b7e58 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -32,6 +32,7 @@
32#include <linux/userfaultfd_k.h> 32#include <linux/userfaultfd_k.h>
33#include <linux/page_idle.h> 33#include <linux/page_idle.h>
34#include <linux/shmem_fs.h> 34#include <linux/shmem_fs.h>
35#include <linux/oom.h>
35 36
36#include <asm/tlb.h> 37#include <asm/tlb.h>
37#include <asm/pgalloc.h> 38#include <asm/pgalloc.h>
@@ -550,6 +551,7 @@ static int __do_huge_pmd_anonymous_page(struct vm_fault *vmf, struct page *page,
550 struct mem_cgroup *memcg; 551 struct mem_cgroup *memcg;
551 pgtable_t pgtable; 552 pgtable_t pgtable;
552 unsigned long haddr = vmf->address & HPAGE_PMD_MASK; 553 unsigned long haddr = vmf->address & HPAGE_PMD_MASK;
554 int ret = 0;
553 555
554 VM_BUG_ON_PAGE(!PageCompound(page), page); 556 VM_BUG_ON_PAGE(!PageCompound(page), page);
555 557
@@ -561,9 +563,8 @@ static int __do_huge_pmd_anonymous_page(struct vm_fault *vmf, struct page *page,
561 563
562 pgtable = pte_alloc_one(vma->vm_mm, haddr); 564 pgtable = pte_alloc_one(vma->vm_mm, haddr);
563 if (unlikely(!pgtable)) { 565 if (unlikely(!pgtable)) {
564 mem_cgroup_cancel_charge(page, memcg, true); 566 ret = VM_FAULT_OOM;
565 put_page(page); 567 goto release;
566 return VM_FAULT_OOM;
567 } 568 }
568 569
569 clear_huge_page(page, haddr, HPAGE_PMD_NR); 570 clear_huge_page(page, haddr, HPAGE_PMD_NR);
@@ -576,13 +577,14 @@ static int __do_huge_pmd_anonymous_page(struct vm_fault *vmf, struct page *page,
576 577
577 vmf->ptl = pmd_lock(vma->vm_mm, vmf->pmd); 578 vmf->ptl = pmd_lock(vma->vm_mm, vmf->pmd);
578 if (unlikely(!pmd_none(*vmf->pmd))) { 579 if (unlikely(!pmd_none(*vmf->pmd))) {
579 spin_unlock(vmf->ptl); 580 goto unlock_release;
580 mem_cgroup_cancel_charge(page, memcg, true);
581 put_page(page);
582 pte_free(vma->vm_mm, pgtable);
583 } else { 581 } else {
584 pmd_t entry; 582 pmd_t entry;
585 583
584 ret = check_stable_address_space(vma->vm_mm);
585 if (ret)
586 goto unlock_release;
587
586 /* Deliver the page fault to userland */ 588 /* Deliver the page fault to userland */
587 if (userfaultfd_missing(vma)) { 589 if (userfaultfd_missing(vma)) {
588 int ret; 590 int ret;
@@ -610,6 +612,15 @@ static int __do_huge_pmd_anonymous_page(struct vm_fault *vmf, struct page *page,
610 } 612 }
611 613
612 return 0; 614 return 0;
615unlock_release:
616 spin_unlock(vmf->ptl);
617release:
618 if (pgtable)
619 pte_free(vma->vm_mm, pgtable);
620 mem_cgroup_cancel_charge(page, memcg, true);
621 put_page(page);
622 return ret;
623
613} 624}
614 625
615/* 626/*
@@ -688,7 +699,10 @@ int do_huge_pmd_anonymous_page(struct vm_fault *vmf)
688 ret = 0; 699 ret = 0;
689 set = false; 700 set = false;
690 if (pmd_none(*vmf->pmd)) { 701 if (pmd_none(*vmf->pmd)) {
691 if (userfaultfd_missing(vma)) { 702 ret = check_stable_address_space(vma->vm_mm);
703 if (ret) {
704 spin_unlock(vmf->ptl);
705 } else if (userfaultfd_missing(vma)) {
692 spin_unlock(vmf->ptl); 706 spin_unlock(vmf->ptl);
693 ret = handle_userfault(vmf, VM_UFFD_MISSING); 707 ret = handle_userfault(vmf, VM_UFFD_MISSING);
694 VM_BUG_ON(ret & VM_FAULT_FALLBACK); 708 VM_BUG_ON(ret & VM_FAULT_FALLBACK);
diff --git a/mm/memblock.c b/mm/memblock.c
index 2cb25fe4452c..bf14aea6ab70 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -285,31 +285,27 @@ static void __init_memblock memblock_remove_region(struct memblock_type *type, u
285} 285}
286 286
287#ifdef CONFIG_ARCH_DISCARD_MEMBLOCK 287#ifdef CONFIG_ARCH_DISCARD_MEMBLOCK
288 288/**
289phys_addr_t __init_memblock get_allocated_memblock_reserved_regions_info( 289 * Discard memory and reserved arrays if they were allocated
290 phys_addr_t *addr) 290 */
291{ 291void __init memblock_discard(void)
292 if (memblock.reserved.regions == memblock_reserved_init_regions)
293 return 0;
294
295 *addr = __pa(memblock.reserved.regions);
296
297 return PAGE_ALIGN(sizeof(struct memblock_region) *
298 memblock.reserved.max);
299}
300
301phys_addr_t __init_memblock get_allocated_memblock_memory_regions_info(
302 phys_addr_t *addr)
303{ 292{
304 if (memblock.memory.regions == memblock_memory_init_regions) 293 phys_addr_t addr, size;
305 return 0;
306 294
307 *addr = __pa(memblock.memory.regions); 295 if (memblock.reserved.regions != memblock_reserved_init_regions) {
296 addr = __pa(memblock.reserved.regions);
297 size = PAGE_ALIGN(sizeof(struct memblock_region) *
298 memblock.reserved.max);
299 __memblock_free_late(addr, size);
300 }
308 301
309 return PAGE_ALIGN(sizeof(struct memblock_region) * 302 if (memblock.memory.regions == memblock_memory_init_regions) {
310 memblock.memory.max); 303 addr = __pa(memblock.memory.regions);
304 size = PAGE_ALIGN(sizeof(struct memblock_region) *
305 memblock.memory.max);
306 __memblock_free_late(addr, size);
307 }
311} 308}
312
313#endif 309#endif
314 310
315/** 311/**
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 3df3c04d73ab..e09741af816f 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1611,9 +1611,13 @@ cleanup:
1611 * @page: the page 1611 * @page: the page
1612 * 1612 *
1613 * This function protects unlocked LRU pages from being moved to 1613 * This function protects unlocked LRU pages from being moved to
1614 * another cgroup and stabilizes their page->mem_cgroup binding. 1614 * another cgroup.
1615 *
1616 * It ensures lifetime of the returned memcg. Caller is responsible
1617 * for the lifetime of the page; __unlock_page_memcg() is available
1618 * when @page might get freed inside the locked section.
1615 */ 1619 */
1616void lock_page_memcg(struct page *page) 1620struct mem_cgroup *lock_page_memcg(struct page *page)
1617{ 1621{
1618 struct mem_cgroup *memcg; 1622 struct mem_cgroup *memcg;
1619 unsigned long flags; 1623 unsigned long flags;
@@ -1622,18 +1626,24 @@ void lock_page_memcg(struct page *page)
1622 * The RCU lock is held throughout the transaction. The fast 1626 * The RCU lock is held throughout the transaction. The fast
1623 * path can get away without acquiring the memcg->move_lock 1627 * path can get away without acquiring the memcg->move_lock
1624 * because page moving starts with an RCU grace period. 1628 * because page moving starts with an RCU grace period.
1625 */ 1629 *
1630 * The RCU lock also protects the memcg from being freed when
1631 * the page state that is going to change is the only thing
1632 * preventing the page itself from being freed. E.g. writeback
1633 * doesn't hold a page reference and relies on PG_writeback to
1634 * keep off truncation, migration and so forth.
1635 */
1626 rcu_read_lock(); 1636 rcu_read_lock();
1627 1637
1628 if (mem_cgroup_disabled()) 1638 if (mem_cgroup_disabled())
1629 return; 1639 return NULL;
1630again: 1640again:
1631 memcg = page->mem_cgroup; 1641 memcg = page->mem_cgroup;
1632 if (unlikely(!memcg)) 1642 if (unlikely(!memcg))
1633 return; 1643 return NULL;
1634 1644
1635 if (atomic_read(&memcg->moving_account) <= 0) 1645 if (atomic_read(&memcg->moving_account) <= 0)
1636 return; 1646 return memcg;
1637 1647
1638 spin_lock_irqsave(&memcg->move_lock, flags); 1648 spin_lock_irqsave(&memcg->move_lock, flags);
1639 if (memcg != page->mem_cgroup) { 1649 if (memcg != page->mem_cgroup) {
@@ -1649,18 +1659,18 @@ again:
1649 memcg->move_lock_task = current; 1659 memcg->move_lock_task = current;
1650 memcg->move_lock_flags = flags; 1660 memcg->move_lock_flags = flags;
1651 1661
1652 return; 1662 return memcg;
1653} 1663}
1654EXPORT_SYMBOL(lock_page_memcg); 1664EXPORT_SYMBOL(lock_page_memcg);
1655 1665
1656/** 1666/**
1657 * unlock_page_memcg - unlock a page->mem_cgroup binding 1667 * __unlock_page_memcg - unlock and unpin a memcg
1658 * @page: the page 1668 * @memcg: the memcg
1669 *
1670 * Unlock and unpin a memcg returned by lock_page_memcg().
1659 */ 1671 */
1660void unlock_page_memcg(struct page *page) 1672void __unlock_page_memcg(struct mem_cgroup *memcg)
1661{ 1673{
1662 struct mem_cgroup *memcg = page->mem_cgroup;
1663
1664 if (memcg && memcg->move_lock_task == current) { 1674 if (memcg && memcg->move_lock_task == current) {
1665 unsigned long flags = memcg->move_lock_flags; 1675 unsigned long flags = memcg->move_lock_flags;
1666 1676
@@ -1672,6 +1682,15 @@ void unlock_page_memcg(struct page *page)
1672 1682
1673 rcu_read_unlock(); 1683 rcu_read_unlock();
1674} 1684}
1685
1686/**
1687 * unlock_page_memcg - unlock a page->mem_cgroup binding
1688 * @page: the page
1689 */
1690void unlock_page_memcg(struct page *page)
1691{
1692 __unlock_page_memcg(page->mem_cgroup);
1693}
1675EXPORT_SYMBOL(unlock_page_memcg); 1694EXPORT_SYMBOL(unlock_page_memcg);
1676 1695
1677/* 1696/*
diff --git a/mm/memory.c b/mm/memory.c
index e158f7ac6730..fe2fba27ded2 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -68,6 +68,7 @@
68#include <linux/debugfs.h> 68#include <linux/debugfs.h>
69#include <linux/userfaultfd_k.h> 69#include <linux/userfaultfd_k.h>
70#include <linux/dax.h> 70#include <linux/dax.h>
71#include <linux/oom.h>
71 72
72#include <asm/io.h> 73#include <asm/io.h>
73#include <asm/mmu_context.h> 74#include <asm/mmu_context.h>
@@ -2893,6 +2894,7 @@ static int do_anonymous_page(struct vm_fault *vmf)
2893 struct vm_area_struct *vma = vmf->vma; 2894 struct vm_area_struct *vma = vmf->vma;
2894 struct mem_cgroup *memcg; 2895 struct mem_cgroup *memcg;
2895 struct page *page; 2896 struct page *page;
2897 int ret = 0;
2896 pte_t entry; 2898 pte_t entry;
2897 2899
2898 /* File mapping without ->vm_ops ? */ 2900 /* File mapping without ->vm_ops ? */
@@ -2925,6 +2927,9 @@ static int do_anonymous_page(struct vm_fault *vmf)
2925 vmf->address, &vmf->ptl); 2927 vmf->address, &vmf->ptl);
2926 if (!pte_none(*vmf->pte)) 2928 if (!pte_none(*vmf->pte))
2927 goto unlock; 2929 goto unlock;
2930 ret = check_stable_address_space(vma->vm_mm);
2931 if (ret)
2932 goto unlock;
2928 /* Deliver the page fault to userland, check inside PT lock */ 2933 /* Deliver the page fault to userland, check inside PT lock */
2929 if (userfaultfd_missing(vma)) { 2934 if (userfaultfd_missing(vma)) {
2930 pte_unmap_unlock(vmf->pte, vmf->ptl); 2935 pte_unmap_unlock(vmf->pte, vmf->ptl);
@@ -2959,6 +2964,10 @@ static int do_anonymous_page(struct vm_fault *vmf)
2959 if (!pte_none(*vmf->pte)) 2964 if (!pte_none(*vmf->pte))
2960 goto release; 2965 goto release;
2961 2966
2967 ret = check_stable_address_space(vma->vm_mm);
2968 if (ret)
2969 goto release;
2970
2962 /* Deliver the page fault to userland, check inside PT lock */ 2971 /* Deliver the page fault to userland, check inside PT lock */
2963 if (userfaultfd_missing(vma)) { 2972 if (userfaultfd_missing(vma)) {
2964 pte_unmap_unlock(vmf->pte, vmf->ptl); 2973 pte_unmap_unlock(vmf->pte, vmf->ptl);
@@ -2978,7 +2987,7 @@ setpte:
2978 update_mmu_cache(vma, vmf->address, vmf->pte); 2987 update_mmu_cache(vma, vmf->address, vmf->pte);
2979unlock: 2988unlock:
2980 pte_unmap_unlock(vmf->pte, vmf->ptl); 2989 pte_unmap_unlock(vmf->pte, vmf->ptl);
2981 return 0; 2990 return ret;
2982release: 2991release:
2983 mem_cgroup_cancel_charge(page, memcg, false); 2992 mem_cgroup_cancel_charge(page, memcg, false);
2984 put_page(page); 2993 put_page(page);
@@ -3252,7 +3261,7 @@ int alloc_set_pte(struct vm_fault *vmf, struct mem_cgroup *memcg,
3252int finish_fault(struct vm_fault *vmf) 3261int finish_fault(struct vm_fault *vmf)
3253{ 3262{
3254 struct page *page; 3263 struct page *page;
3255 int ret; 3264 int ret = 0;
3256 3265
3257 /* Did we COW the page? */ 3266 /* Did we COW the page? */
3258 if ((vmf->flags & FAULT_FLAG_WRITE) && 3267 if ((vmf->flags & FAULT_FLAG_WRITE) &&
@@ -3260,7 +3269,15 @@ int finish_fault(struct vm_fault *vmf)
3260 page = vmf->cow_page; 3269 page = vmf->cow_page;
3261 else 3270 else
3262 page = vmf->page; 3271 page = vmf->page;
3263 ret = alloc_set_pte(vmf, vmf->memcg, page); 3272
3273 /*
3274 * check even for read faults because we might have lost our CoWed
3275 * page
3276 */
3277 if (!(vmf->vma->vm_flags & VM_SHARED))
3278 ret = check_stable_address_space(vmf->vma->vm_mm);
3279 if (!ret)
3280 ret = alloc_set_pte(vmf, vmf->memcg, page);
3264 if (vmf->pte) 3281 if (vmf->pte)
3265 pte_unmap_unlock(vmf->pte, vmf->ptl); 3282 pte_unmap_unlock(vmf->pte, vmf->ptl);
3266 return ret; 3283 return ret;
@@ -3900,19 +3917,6 @@ int handle_mm_fault(struct vm_area_struct *vma, unsigned long address,
3900 mem_cgroup_oom_synchronize(false); 3917 mem_cgroup_oom_synchronize(false);
3901 } 3918 }
3902 3919
3903 /*
3904 * This mm has been already reaped by the oom reaper and so the
3905 * refault cannot be trusted in general. Anonymous refaults would
3906 * lose data and give a zero page instead e.g. This is especially
3907 * problem for use_mm() because regular tasks will just die and
3908 * the corrupted data will not be visible anywhere while kthread
3909 * will outlive the oom victim and potentially propagate the date
3910 * further.
3911 */
3912 if (unlikely((current->flags & PF_KTHREAD) && !(ret & VM_FAULT_ERROR)
3913 && test_bit(MMF_UNSTABLE, &vma->vm_mm->flags)))
3914 ret = VM_FAULT_SIGBUS;
3915
3916 return ret; 3920 return ret;
3917} 3921}
3918EXPORT_SYMBOL_GPL(handle_mm_fault); 3922EXPORT_SYMBOL_GPL(handle_mm_fault);
diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index d911fa5cb2a7..618ab125228b 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -861,11 +861,6 @@ static long do_get_mempolicy(int *policy, nodemask_t *nmask,
861 *policy |= (pol->flags & MPOL_MODE_FLAGS); 861 *policy |= (pol->flags & MPOL_MODE_FLAGS);
862 } 862 }
863 863
864 if (vma) {
865 up_read(&current->mm->mmap_sem);
866 vma = NULL;
867 }
868
869 err = 0; 864 err = 0;
870 if (nmask) { 865 if (nmask) {
871 if (mpol_store_user_nodemask(pol)) { 866 if (mpol_store_user_nodemask(pol)) {
diff --git a/mm/migrate.c b/mm/migrate.c
index d68a41da6abb..e84eeb4e4356 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -41,6 +41,7 @@
41#include <linux/page_idle.h> 41#include <linux/page_idle.h>
42#include <linux/page_owner.h> 42#include <linux/page_owner.h>
43#include <linux/sched/mm.h> 43#include <linux/sched/mm.h>
44#include <linux/ptrace.h>
44 45
45#include <asm/tlbflush.h> 46#include <asm/tlbflush.h>
46 47
@@ -1652,7 +1653,6 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
1652 const int __user *, nodes, 1653 const int __user *, nodes,
1653 int __user *, status, int, flags) 1654 int __user *, status, int, flags)
1654{ 1655{
1655 const struct cred *cred = current_cred(), *tcred;
1656 struct task_struct *task; 1656 struct task_struct *task;
1657 struct mm_struct *mm; 1657 struct mm_struct *mm;
1658 int err; 1658 int err;
@@ -1676,14 +1676,9 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
1676 1676
1677 /* 1677 /*
1678 * Check if this process has the right to modify the specified 1678 * Check if this process has the right to modify the specified
1679 * process. The right exists if the process has administrative 1679 * process. Use the regular "ptrace_may_access()" checks.
1680 * capabilities, superuser privileges or the same
1681 * userid as the target process.
1682 */ 1680 */
1683 tcred = __task_cred(task); 1681 if (!ptrace_may_access(task, PTRACE_MODE_READ_REALCREDS)) {
1684 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
1685 !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
1686 !capable(CAP_SYS_NICE)) {
1687 rcu_read_unlock(); 1682 rcu_read_unlock();
1688 err = -EPERM; 1683 err = -EPERM;
1689 goto out; 1684 goto out;
diff --git a/mm/nobootmem.c b/mm/nobootmem.c
index 36454d0f96ee..3637809a18d0 100644
--- a/mm/nobootmem.c
+++ b/mm/nobootmem.c
@@ -146,22 +146,6 @@ static unsigned long __init free_low_memory_core_early(void)
146 NULL) 146 NULL)
147 count += __free_memory_core(start, end); 147 count += __free_memory_core(start, end);
148 148
149#ifdef CONFIG_ARCH_DISCARD_MEMBLOCK
150 {
151 phys_addr_t size;
152
153 /* Free memblock.reserved array if it was allocated */
154 size = get_allocated_memblock_reserved_regions_info(&start);
155 if (size)
156 count += __free_memory_core(start, start + size);
157
158 /* Free memblock.memory array if it was allocated */
159 size = get_allocated_memblock_memory_regions_info(&start);
160 if (size)
161 count += __free_memory_core(start, start + size);
162 }
163#endif
164
165 return count; 149 return count;
166} 150}
167 151
diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index 96e93b214d31..bf050ab025b7 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -2724,9 +2724,12 @@ EXPORT_SYMBOL(clear_page_dirty_for_io);
2724int test_clear_page_writeback(struct page *page) 2724int test_clear_page_writeback(struct page *page)
2725{ 2725{
2726 struct address_space *mapping = page_mapping(page); 2726 struct address_space *mapping = page_mapping(page);
2727 struct mem_cgroup *memcg;
2728 struct lruvec *lruvec;
2727 int ret; 2729 int ret;
2728 2730
2729 lock_page_memcg(page); 2731 memcg = lock_page_memcg(page);
2732 lruvec = mem_cgroup_page_lruvec(page, page_pgdat(page));
2730 if (mapping && mapping_use_writeback_tags(mapping)) { 2733 if (mapping && mapping_use_writeback_tags(mapping)) {
2731 struct inode *inode = mapping->host; 2734 struct inode *inode = mapping->host;
2732 struct backing_dev_info *bdi = inode_to_bdi(inode); 2735 struct backing_dev_info *bdi = inode_to_bdi(inode);
@@ -2754,12 +2757,18 @@ int test_clear_page_writeback(struct page *page)
2754 } else { 2757 } else {
2755 ret = TestClearPageWriteback(page); 2758 ret = TestClearPageWriteback(page);
2756 } 2759 }
2760 /*
2761 * NOTE: Page might be free now! Writeback doesn't hold a page
2762 * reference on its own, it relies on truncation to wait for
2763 * the clearing of PG_writeback. The below can only access
2764 * page state that is static across allocation cycles.
2765 */
2757 if (ret) { 2766 if (ret) {
2758 dec_lruvec_page_state(page, NR_WRITEBACK); 2767 dec_lruvec_state(lruvec, NR_WRITEBACK);
2759 dec_zone_page_state(page, NR_ZONE_WRITE_PENDING); 2768 dec_zone_page_state(page, NR_ZONE_WRITE_PENDING);
2760 inc_node_page_state(page, NR_WRITTEN); 2769 inc_node_page_state(page, NR_WRITTEN);
2761 } 2770 }
2762 unlock_page_memcg(page); 2771 __unlock_page_memcg(memcg);
2763 return ret; 2772 return ret;
2764} 2773}
2765 2774
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 6d00f746c2fd..1bad301820c7 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -1584,6 +1584,10 @@ void __init page_alloc_init_late(void)
1584 /* Reinit limits that are based on free pages after the kernel is up */ 1584 /* Reinit limits that are based on free pages after the kernel is up */
1585 files_maxfiles_init(); 1585 files_maxfiles_init();
1586#endif 1586#endif
1587#ifdef CONFIG_ARCH_DISCARD_MEMBLOCK
1588 /* Discard memblock private memory */
1589 memblock_discard();
1590#endif
1587 1591
1588 for_each_populated_zone(zone) 1592 for_each_populated_zone(zone)
1589 set_zone_contiguous(zone); 1593 set_zone_contiguous(zone);
diff --git a/mm/slub.c b/mm/slub.c
index 1d3f9835f4ea..e8b4e31162ca 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -5642,13 +5642,14 @@ static void sysfs_slab_remove_workfn(struct work_struct *work)
5642 * A cache is never shut down before deactivation is 5642 * A cache is never shut down before deactivation is
5643 * complete, so no need to worry about synchronization. 5643 * complete, so no need to worry about synchronization.
5644 */ 5644 */
5645 return; 5645 goto out;
5646 5646
5647#ifdef CONFIG_MEMCG 5647#ifdef CONFIG_MEMCG
5648 kset_unregister(s->memcg_kset); 5648 kset_unregister(s->memcg_kset);
5649#endif 5649#endif
5650 kobject_uevent(&s->kobj, KOBJ_REMOVE); 5650 kobject_uevent(&s->kobj, KOBJ_REMOVE);
5651 kobject_del(&s->kobj); 5651 kobject_del(&s->kobj);
5652out:
5652 kobject_put(&s->kobj); 5653 kobject_put(&s->kobj);
5653} 5654}
5654 5655
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 8698c1c86c4d..a47e3894c775 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -1671,7 +1671,10 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask,
1671 struct page **pages; 1671 struct page **pages;
1672 unsigned int nr_pages, array_size, i; 1672 unsigned int nr_pages, array_size, i;
1673 const gfp_t nested_gfp = (gfp_mask & GFP_RECLAIM_MASK) | __GFP_ZERO; 1673 const gfp_t nested_gfp = (gfp_mask & GFP_RECLAIM_MASK) | __GFP_ZERO;
1674 const gfp_t alloc_mask = gfp_mask | __GFP_HIGHMEM | __GFP_NOWARN; 1674 const gfp_t alloc_mask = gfp_mask | __GFP_NOWARN;
1675 const gfp_t highmem_mask = (gfp_mask & (GFP_DMA | GFP_DMA32)) ?
1676 0 :
1677 __GFP_HIGHMEM;
1675 1678
1676 nr_pages = get_vm_area_size(area) >> PAGE_SHIFT; 1679 nr_pages = get_vm_area_size(area) >> PAGE_SHIFT;
1677 array_size = (nr_pages * sizeof(struct page *)); 1680 array_size = (nr_pages * sizeof(struct page *));
@@ -1679,7 +1682,7 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask,
1679 area->nr_pages = nr_pages; 1682 area->nr_pages = nr_pages;
1680 /* Please note that the recursion is strictly bounded. */ 1683 /* Please note that the recursion is strictly bounded. */
1681 if (array_size > PAGE_SIZE) { 1684 if (array_size > PAGE_SIZE) {
1682 pages = __vmalloc_node(array_size, 1, nested_gfp|__GFP_HIGHMEM, 1685 pages = __vmalloc_node(array_size, 1, nested_gfp|highmem_mask,
1683 PAGE_KERNEL, node, area->caller); 1686 PAGE_KERNEL, node, area->caller);
1684 } else { 1687 } else {
1685 pages = kmalloc_node(array_size, nested_gfp, node); 1688 pages = kmalloc_node(array_size, nested_gfp, node);
@@ -1700,9 +1703,9 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask,
1700 } 1703 }
1701 1704
1702 if (node == NUMA_NO_NODE) 1705 if (node == NUMA_NO_NODE)
1703 page = alloc_page(alloc_mask); 1706 page = alloc_page(alloc_mask|highmem_mask);
1704 else 1707 else
1705 page = alloc_pages_node(node, alloc_mask, 0); 1708 page = alloc_pages_node(node, alloc_mask|highmem_mask, 0);
1706 1709
1707 if (unlikely(!page)) { 1710 if (unlikely(!page)) {
1708 /* Successfully allocated i pages, free them in __vunmap() */ 1711 /* Successfully allocated i pages, free them in __vunmap() */
@@ -1710,7 +1713,7 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask,
1710 goto fail; 1713 goto fail;
1711 } 1714 }
1712 area->pages[i] = page; 1715 area->pages[i] = page;
1713 if (gfpflags_allow_blocking(gfp_mask)) 1716 if (gfpflags_allow_blocking(gfp_mask|highmem_mask))
1714 cond_resched(); 1717 cond_resched();
1715 } 1718 }
1716 1719
diff --git a/net/core/filter.c b/net/core/filter.c
index f44fc22fd45a..6280a602604c 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -3505,6 +3505,7 @@ static u32 bpf_convert_ctx_access(enum bpf_access_type type,
3505 bpf_target_off(struct sk_buff, tc_index, 2, 3505 bpf_target_off(struct sk_buff, tc_index, 2,
3506 target_size)); 3506 target_size));
3507#else 3507#else
3508 *target_size = 2;
3508 if (type == BPF_WRITE) 3509 if (type == BPF_WRITE)
3509 *insn++ = BPF_MOV64_REG(si->dst_reg, si->dst_reg); 3510 *insn++ = BPF_MOV64_REG(si->dst_reg, si->dst_reg);
3510 else 3511 else
@@ -3520,6 +3521,7 @@ static u32 bpf_convert_ctx_access(enum bpf_access_type type,
3520 *insn++ = BPF_JMP_IMM(BPF_JGE, si->dst_reg, MIN_NAPI_ID, 1); 3521 *insn++ = BPF_JMP_IMM(BPF_JGE, si->dst_reg, MIN_NAPI_ID, 1);
3521 *insn++ = BPF_MOV64_IMM(si->dst_reg, 0); 3522 *insn++ = BPF_MOV64_IMM(si->dst_reg, 0);
3522#else 3523#else
3524 *target_size = 4;
3523 *insn++ = BPF_MOV64_IMM(si->dst_reg, 0); 3525 *insn++ = BPF_MOV64_IMM(si->dst_reg, 0);
3524#endif 3526#endif
3525 break; 3527 break;
diff --git a/net/dccp/proto.c b/net/dccp/proto.c
index 9fe25bf63296..86bc40ba6ba5 100644
--- a/net/dccp/proto.c
+++ b/net/dccp/proto.c
@@ -201,10 +201,7 @@ void dccp_destroy_sock(struct sock *sk)
201{ 201{
202 struct dccp_sock *dp = dccp_sk(sk); 202 struct dccp_sock *dp = dccp_sk(sk);
203 203
204 /* 204 __skb_queue_purge(&sk->sk_write_queue);
205 * DCCP doesn't use sk_write_queue, just sk_send_head
206 * for retransmissions
207 */
208 if (sk->sk_send_head != NULL) { 205 if (sk->sk_send_head != NULL) {
209 kfree_skb(sk->sk_send_head); 206 kfree_skb(sk->sk_send_head);
210 sk->sk_send_head = NULL; 207 sk->sk_send_head = NULL;
diff --git a/net/dsa/tag_ksz.c b/net/dsa/tag_ksz.c
index fab41de8e983..de66ca8e6201 100644
--- a/net/dsa/tag_ksz.c
+++ b/net/dsa/tag_ksz.c
@@ -42,6 +42,9 @@ static struct sk_buff *ksz_xmit(struct sk_buff *skb, struct net_device *dev)
42 padlen = (skb->len >= ETH_ZLEN) ? 0 : ETH_ZLEN - skb->len; 42 padlen = (skb->len >= ETH_ZLEN) ? 0 : ETH_ZLEN - skb->len;
43 43
44 if (skb_tailroom(skb) >= padlen + KSZ_INGRESS_TAG_LEN) { 44 if (skb_tailroom(skb) >= padlen + KSZ_INGRESS_TAG_LEN) {
45 if (skb_put_padto(skb, skb->len + padlen))
46 return NULL;
47
45 nskb = skb; 48 nskb = skb;
46 } else { 49 } else {
47 nskb = alloc_skb(NET_IP_ALIGN + skb->len + 50 nskb = alloc_skb(NET_IP_ALIGN + skb->len +
@@ -56,13 +59,15 @@ static struct sk_buff *ksz_xmit(struct sk_buff *skb, struct net_device *dev)
56 skb_set_transport_header(nskb, 59 skb_set_transport_header(nskb,
57 skb_transport_header(skb) - skb->head); 60 skb_transport_header(skb) - skb->head);
58 skb_copy_and_csum_dev(skb, skb_put(nskb, skb->len)); 61 skb_copy_and_csum_dev(skb, skb_put(nskb, skb->len));
62
63 if (skb_put_padto(nskb, nskb->len + padlen)) {
64 kfree_skb(nskb);
65 return NULL;
66 }
67
59 kfree_skb(skb); 68 kfree_skb(skb);
60 } 69 }
61 70
62 /* skb is freed when it fails */
63 if (skb_put_padto(nskb, nskb->len + padlen))
64 return NULL;
65
66 tag = skb_put(nskb, KSZ_INGRESS_TAG_LEN); 71 tag = skb_put(nskb, KSZ_INGRESS_TAG_LEN);
67 tag[0] = 0; 72 tag[0] = 0;
68 tag[1] = 1 << p->dp->index; /* destination port */ 73 tag[1] = 1 << p->dp->index; /* destination port */
diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
index b8d18171cca3..ec3a9ce281a6 100644
--- a/net/ipv4/fib_semantics.c
+++ b/net/ipv4/fib_semantics.c
@@ -1083,15 +1083,17 @@ struct fib_info *fib_create_info(struct fib_config *cfg,
1083 fi = kzalloc(sizeof(*fi)+nhs*sizeof(struct fib_nh), GFP_KERNEL); 1083 fi = kzalloc(sizeof(*fi)+nhs*sizeof(struct fib_nh), GFP_KERNEL);
1084 if (!fi) 1084 if (!fi)
1085 goto failure; 1085 goto failure;
1086 fib_info_cnt++;
1087 if (cfg->fc_mx) { 1086 if (cfg->fc_mx) {
1088 fi->fib_metrics = kzalloc(sizeof(*fi->fib_metrics), GFP_KERNEL); 1087 fi->fib_metrics = kzalloc(sizeof(*fi->fib_metrics), GFP_KERNEL);
1089 if (!fi->fib_metrics) 1088 if (unlikely(!fi->fib_metrics)) {
1090 goto failure; 1089 kfree(fi);
1090 return ERR_PTR(err);
1091 }
1091 atomic_set(&fi->fib_metrics->refcnt, 1); 1092 atomic_set(&fi->fib_metrics->refcnt, 1);
1092 } else 1093 } else {
1093 fi->fib_metrics = (struct dst_metrics *)&dst_default_metrics; 1094 fi->fib_metrics = (struct dst_metrics *)&dst_default_metrics;
1094 1095 }
1096 fib_info_cnt++;
1095 fi->fib_net = net; 1097 fi->fib_net = net;
1096 fi->fib_protocol = cfg->fc_protocol; 1098 fi->fib_protocol = cfg->fc_protocol;
1097 fi->fib_scope = cfg->fc_scope; 1099 fi->fib_scope = cfg->fc_scope;
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 0383e66f59bc..7effa62beed3 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -2750,12 +2750,13 @@ static int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh,
2750 err = 0; 2750 err = 0;
2751 if (IS_ERR(rt)) 2751 if (IS_ERR(rt))
2752 err = PTR_ERR(rt); 2752 err = PTR_ERR(rt);
2753 else
2754 skb_dst_set(skb, &rt->dst);
2753 } 2755 }
2754 2756
2755 if (err) 2757 if (err)
2756 goto errout_free; 2758 goto errout_free;
2757 2759
2758 skb_dst_set(skb, &rt->dst);
2759 if (rtm->rtm_flags & RTM_F_NOTIFY) 2760 if (rtm->rtm_flags & RTM_F_NOTIFY)
2760 rt->rt_flags |= RTCF_NOTIFY; 2761 rt->rt_flags |= RTCF_NOTIFY;
2761 2762
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index a20e7f03d5f7..e9252c7df809 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -1722,6 +1722,8 @@ process:
1722 */ 1722 */
1723 sock_hold(sk); 1723 sock_hold(sk);
1724 refcounted = true; 1724 refcounted = true;
1725 if (tcp_filter(sk, skb))
1726 goto discard_and_relse;
1725 nsk = tcp_check_req(sk, skb, req, false); 1727 nsk = tcp_check_req(sk, skb, req, false);
1726 if (!nsk) { 1728 if (!nsk) {
1727 reqsk_put(req); 1729 reqsk_put(req);
@@ -1729,8 +1731,6 @@ process:
1729 } 1731 }
1730 if (nsk == sk) { 1732 if (nsk == sk) {
1731 reqsk_put(req); 1733 reqsk_put(req);
1732 } else if (tcp_filter(sk, skb)) {
1733 goto discard_and_relse;
1734 } else if (tcp_child_process(sk, nsk, skb)) { 1734 } else if (tcp_child_process(sk, nsk, skb)) {
1735 tcp_v4_send_reset(nsk, skb); 1735 tcp_v4_send_reset(nsk, skb);
1736 goto discard_and_relse; 1736 goto discard_and_relse;
diff --git a/net/ipv4/tcp_ulp.c b/net/ipv4/tcp_ulp.c
index 2417f55374c5..6bb9e14c710a 100644
--- a/net/ipv4/tcp_ulp.c
+++ b/net/ipv4/tcp_ulp.c
@@ -122,14 +122,14 @@ int tcp_set_ulp(struct sock *sk, const char *name)
122 122
123 ulp_ops = __tcp_ulp_find_autoload(name); 123 ulp_ops = __tcp_ulp_find_autoload(name);
124 if (!ulp_ops) 124 if (!ulp_ops)
125 err = -ENOENT; 125 return -ENOENT;
126 else
127 err = ulp_ops->init(sk);
128 126
129 if (err) 127 err = ulp_ops->init(sk);
130 goto out; 128 if (err) {
129 module_put(ulp_ops->owner);
130 return err;
131 }
131 132
132 icsk->icsk_ulp_ops = ulp_ops; 133 icsk->icsk_ulp_ops = ulp_ops;
133 out: 134 return 0;
134 return err;
135} 135}
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index a640fbcba15d..94d6a13d47f0 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -417,14 +417,11 @@ static void ip6_dst_ifdown(struct dst_entry *dst, struct net_device *dev,
417 struct net_device *loopback_dev = 417 struct net_device *loopback_dev =
418 dev_net(dev)->loopback_dev; 418 dev_net(dev)->loopback_dev;
419 419
420 if (dev != loopback_dev) { 420 if (idev && idev->dev != loopback_dev) {
421 if (idev && idev->dev == dev) { 421 struct inet6_dev *loopback_idev = in6_dev_get(loopback_dev);
422 struct inet6_dev *loopback_idev = 422 if (loopback_idev) {
423 in6_dev_get(loopback_dev); 423 rt->rt6i_idev = loopback_idev;
424 if (loopback_idev) { 424 in6_dev_put(idev);
425 rt->rt6i_idev = loopback_idev;
426 in6_dev_put(idev);
427 }
428 } 425 }
429 } 426 }
430} 427}
@@ -3724,10 +3721,10 @@ static int ip6_route_dev_notify(struct notifier_block *this,
3724 /* NETDEV_UNREGISTER could be fired for multiple times by 3721 /* NETDEV_UNREGISTER could be fired for multiple times by
3725 * netdev_wait_allrefs(). Make sure we only call this once. 3722 * netdev_wait_allrefs(). Make sure we only call this once.
3726 */ 3723 */
3727 in6_dev_put(net->ipv6.ip6_null_entry->rt6i_idev); 3724 in6_dev_put_clear(&net->ipv6.ip6_null_entry->rt6i_idev);
3728#ifdef CONFIG_IPV6_MULTIPLE_TABLES 3725#ifdef CONFIG_IPV6_MULTIPLE_TABLES
3729 in6_dev_put(net->ipv6.ip6_prohibit_entry->rt6i_idev); 3726 in6_dev_put_clear(&net->ipv6.ip6_prohibit_entry->rt6i_idev);
3730 in6_dev_put(net->ipv6.ip6_blk_hole_entry->rt6i_idev); 3727 in6_dev_put_clear(&net->ipv6.ip6_blk_hole_entry->rt6i_idev);
3731#endif 3728#endif
3732 } 3729 }
3733 3730
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 2521690d62d6..206210125fd7 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -1456,6 +1456,8 @@ process:
1456 } 1456 }
1457 sock_hold(sk); 1457 sock_hold(sk);
1458 refcounted = true; 1458 refcounted = true;
1459 if (tcp_filter(sk, skb))
1460 goto discard_and_relse;
1459 nsk = tcp_check_req(sk, skb, req, false); 1461 nsk = tcp_check_req(sk, skb, req, false);
1460 if (!nsk) { 1462 if (!nsk) {
1461 reqsk_put(req); 1463 reqsk_put(req);
@@ -1464,8 +1466,6 @@ process:
1464 if (nsk == sk) { 1466 if (nsk == sk) {
1465 reqsk_put(req); 1467 reqsk_put(req);
1466 tcp_v6_restore_cb(skb); 1468 tcp_v6_restore_cb(skb);
1467 } else if (tcp_filter(sk, skb)) {
1468 goto discard_and_relse;
1469 } else if (tcp_child_process(sk, nsk, skb)) { 1469 } else if (tcp_child_process(sk, nsk, skb)) {
1470 tcp_v6_send_reset(nsk, skb); 1470 tcp_v6_send_reset(nsk, skb);
1471 goto discard_and_relse; 1471 goto discard_and_relse;
diff --git a/net/key/af_key.c b/net/key/af_key.c
index ca9d3ae665e7..98f4d8211b9a 100644
--- a/net/key/af_key.c
+++ b/net/key/af_key.c
@@ -228,7 +228,7 @@ static int pfkey_broadcast_one(struct sk_buff *skb, struct sk_buff **skb2,
228#define BROADCAST_ONE 1 228#define BROADCAST_ONE 1
229#define BROADCAST_REGISTERED 2 229#define BROADCAST_REGISTERED 2
230#define BROADCAST_PROMISC_ONLY 4 230#define BROADCAST_PROMISC_ONLY 4
231static int pfkey_broadcast(struct sk_buff *skb, 231static int pfkey_broadcast(struct sk_buff *skb, gfp_t allocation,
232 int broadcast_flags, struct sock *one_sk, 232 int broadcast_flags, struct sock *one_sk,
233 struct net *net) 233 struct net *net)
234{ 234{
@@ -278,7 +278,7 @@ static int pfkey_broadcast(struct sk_buff *skb,
278 rcu_read_unlock(); 278 rcu_read_unlock();
279 279
280 if (one_sk != NULL) 280 if (one_sk != NULL)
281 err = pfkey_broadcast_one(skb, &skb2, GFP_KERNEL, one_sk); 281 err = pfkey_broadcast_one(skb, &skb2, allocation, one_sk);
282 282
283 kfree_skb(skb2); 283 kfree_skb(skb2);
284 kfree_skb(skb); 284 kfree_skb(skb);
@@ -311,7 +311,7 @@ static int pfkey_do_dump(struct pfkey_sock *pfk)
311 hdr = (struct sadb_msg *) pfk->dump.skb->data; 311 hdr = (struct sadb_msg *) pfk->dump.skb->data;
312 hdr->sadb_msg_seq = 0; 312 hdr->sadb_msg_seq = 0;
313 hdr->sadb_msg_errno = rc; 313 hdr->sadb_msg_errno = rc;
314 pfkey_broadcast(pfk->dump.skb, BROADCAST_ONE, 314 pfkey_broadcast(pfk->dump.skb, GFP_ATOMIC, BROADCAST_ONE,
315 &pfk->sk, sock_net(&pfk->sk)); 315 &pfk->sk, sock_net(&pfk->sk));
316 pfk->dump.skb = NULL; 316 pfk->dump.skb = NULL;
317 } 317 }
@@ -355,7 +355,7 @@ static int pfkey_error(const struct sadb_msg *orig, int err, struct sock *sk)
355 hdr->sadb_msg_len = (sizeof(struct sadb_msg) / 355 hdr->sadb_msg_len = (sizeof(struct sadb_msg) /
356 sizeof(uint64_t)); 356 sizeof(uint64_t));
357 357
358 pfkey_broadcast(skb, BROADCAST_ONE, sk, sock_net(sk)); 358 pfkey_broadcast(skb, GFP_KERNEL, BROADCAST_ONE, sk, sock_net(sk));
359 359
360 return 0; 360 return 0;
361} 361}
@@ -1389,7 +1389,7 @@ static int pfkey_getspi(struct sock *sk, struct sk_buff *skb, const struct sadb_
1389 1389
1390 xfrm_state_put(x); 1390 xfrm_state_put(x);
1391 1391
1392 pfkey_broadcast(resp_skb, BROADCAST_ONE, sk, net); 1392 pfkey_broadcast(resp_skb, GFP_KERNEL, BROADCAST_ONE, sk, net);
1393 1393
1394 return 0; 1394 return 0;
1395} 1395}
@@ -1476,7 +1476,7 @@ static int key_notify_sa(struct xfrm_state *x, const struct km_event *c)
1476 hdr->sadb_msg_seq = c->seq; 1476 hdr->sadb_msg_seq = c->seq;
1477 hdr->sadb_msg_pid = c->portid; 1477 hdr->sadb_msg_pid = c->portid;
1478 1478
1479 pfkey_broadcast(skb, BROADCAST_ALL, NULL, xs_net(x)); 1479 pfkey_broadcast(skb, GFP_ATOMIC, BROADCAST_ALL, NULL, xs_net(x));
1480 1480
1481 return 0; 1481 return 0;
1482} 1482}
@@ -1589,7 +1589,7 @@ static int pfkey_get(struct sock *sk, struct sk_buff *skb, const struct sadb_msg
1589 out_hdr->sadb_msg_reserved = 0; 1589 out_hdr->sadb_msg_reserved = 0;
1590 out_hdr->sadb_msg_seq = hdr->sadb_msg_seq; 1590 out_hdr->sadb_msg_seq = hdr->sadb_msg_seq;
1591 out_hdr->sadb_msg_pid = hdr->sadb_msg_pid; 1591 out_hdr->sadb_msg_pid = hdr->sadb_msg_pid;
1592 pfkey_broadcast(out_skb, BROADCAST_ONE, sk, sock_net(sk)); 1592 pfkey_broadcast(out_skb, GFP_ATOMIC, BROADCAST_ONE, sk, sock_net(sk));
1593 1593
1594 return 0; 1594 return 0;
1595} 1595}
@@ -1694,8 +1694,8 @@ static int pfkey_register(struct sock *sk, struct sk_buff *skb, const struct sad
1694 return -ENOBUFS; 1694 return -ENOBUFS;
1695 } 1695 }
1696 1696
1697 pfkey_broadcast(supp_skb, BROADCAST_REGISTERED, sk, sock_net(sk)); 1697 pfkey_broadcast(supp_skb, GFP_KERNEL, BROADCAST_REGISTERED, sk,
1698 1698 sock_net(sk));
1699 return 0; 1699 return 0;
1700} 1700}
1701 1701
@@ -1712,7 +1712,8 @@ static int unicast_flush_resp(struct sock *sk, const struct sadb_msg *ihdr)
1712 hdr->sadb_msg_errno = (uint8_t) 0; 1712 hdr->sadb_msg_errno = (uint8_t) 0;
1713 hdr->sadb_msg_len = (sizeof(struct sadb_msg) / sizeof(uint64_t)); 1713 hdr->sadb_msg_len = (sizeof(struct sadb_msg) / sizeof(uint64_t));
1714 1714
1715 return pfkey_broadcast(skb, BROADCAST_ONE, sk, sock_net(sk)); 1715 return pfkey_broadcast(skb, GFP_ATOMIC, BROADCAST_ONE, sk,
1716 sock_net(sk));
1716} 1717}
1717 1718
1718static int key_notify_sa_flush(const struct km_event *c) 1719static int key_notify_sa_flush(const struct km_event *c)
@@ -1733,7 +1734,7 @@ static int key_notify_sa_flush(const struct km_event *c)
1733 hdr->sadb_msg_len = (sizeof(struct sadb_msg) / sizeof(uint64_t)); 1734 hdr->sadb_msg_len = (sizeof(struct sadb_msg) / sizeof(uint64_t));
1734 hdr->sadb_msg_reserved = 0; 1735 hdr->sadb_msg_reserved = 0;
1735 1736
1736 pfkey_broadcast(skb, BROADCAST_ALL, NULL, c->net); 1737 pfkey_broadcast(skb, GFP_ATOMIC, BROADCAST_ALL, NULL, c->net);
1737 1738
1738 return 0; 1739 return 0;
1739} 1740}
@@ -1790,7 +1791,7 @@ static int dump_sa(struct xfrm_state *x, int count, void *ptr)
1790 out_hdr->sadb_msg_pid = pfk->dump.msg_portid; 1791 out_hdr->sadb_msg_pid = pfk->dump.msg_portid;
1791 1792
1792 if (pfk->dump.skb) 1793 if (pfk->dump.skb)
1793 pfkey_broadcast(pfk->dump.skb, BROADCAST_ONE, 1794 pfkey_broadcast(pfk->dump.skb, GFP_ATOMIC, BROADCAST_ONE,
1794 &pfk->sk, sock_net(&pfk->sk)); 1795 &pfk->sk, sock_net(&pfk->sk));
1795 pfk->dump.skb = out_skb; 1796 pfk->dump.skb = out_skb;
1796 1797
@@ -1878,7 +1879,7 @@ static int pfkey_promisc(struct sock *sk, struct sk_buff *skb, const struct sadb
1878 new_hdr->sadb_msg_errno = 0; 1879 new_hdr->sadb_msg_errno = 0;
1879 } 1880 }
1880 1881
1881 pfkey_broadcast(skb, BROADCAST_ALL, NULL, sock_net(sk)); 1882 pfkey_broadcast(skb, GFP_KERNEL, BROADCAST_ALL, NULL, sock_net(sk));
1882 return 0; 1883 return 0;
1883} 1884}
1884 1885
@@ -2206,7 +2207,7 @@ static int key_notify_policy(struct xfrm_policy *xp, int dir, const struct km_ev
2206 out_hdr->sadb_msg_errno = 0; 2207 out_hdr->sadb_msg_errno = 0;
2207 out_hdr->sadb_msg_seq = c->seq; 2208 out_hdr->sadb_msg_seq = c->seq;
2208 out_hdr->sadb_msg_pid = c->portid; 2209 out_hdr->sadb_msg_pid = c->portid;
2209 pfkey_broadcast(out_skb, BROADCAST_ALL, NULL, xp_net(xp)); 2210 pfkey_broadcast(out_skb, GFP_ATOMIC, BROADCAST_ALL, NULL, xp_net(xp));
2210 return 0; 2211 return 0;
2211 2212
2212} 2213}
@@ -2426,7 +2427,7 @@ static int key_pol_get_resp(struct sock *sk, struct xfrm_policy *xp, const struc
2426 out_hdr->sadb_msg_errno = 0; 2427 out_hdr->sadb_msg_errno = 0;
2427 out_hdr->sadb_msg_seq = hdr->sadb_msg_seq; 2428 out_hdr->sadb_msg_seq = hdr->sadb_msg_seq;
2428 out_hdr->sadb_msg_pid = hdr->sadb_msg_pid; 2429 out_hdr->sadb_msg_pid = hdr->sadb_msg_pid;
2429 pfkey_broadcast(out_skb, BROADCAST_ONE, sk, xp_net(xp)); 2430 pfkey_broadcast(out_skb, GFP_ATOMIC, BROADCAST_ONE, sk, xp_net(xp));
2430 err = 0; 2431 err = 0;
2431 2432
2432out: 2433out:
@@ -2682,7 +2683,7 @@ static int dump_sp(struct xfrm_policy *xp, int dir, int count, void *ptr)
2682 out_hdr->sadb_msg_pid = pfk->dump.msg_portid; 2683 out_hdr->sadb_msg_pid = pfk->dump.msg_portid;
2683 2684
2684 if (pfk->dump.skb) 2685 if (pfk->dump.skb)
2685 pfkey_broadcast(pfk->dump.skb, BROADCAST_ONE, 2686 pfkey_broadcast(pfk->dump.skb, GFP_ATOMIC, BROADCAST_ONE,
2686 &pfk->sk, sock_net(&pfk->sk)); 2687 &pfk->sk, sock_net(&pfk->sk));
2687 pfk->dump.skb = out_skb; 2688 pfk->dump.skb = out_skb;
2688 2689
@@ -2739,7 +2740,7 @@ static int key_notify_policy_flush(const struct km_event *c)
2739 hdr->sadb_msg_satype = SADB_SATYPE_UNSPEC; 2740 hdr->sadb_msg_satype = SADB_SATYPE_UNSPEC;
2740 hdr->sadb_msg_len = (sizeof(struct sadb_msg) / sizeof(uint64_t)); 2741 hdr->sadb_msg_len = (sizeof(struct sadb_msg) / sizeof(uint64_t));
2741 hdr->sadb_msg_reserved = 0; 2742 hdr->sadb_msg_reserved = 0;
2742 pfkey_broadcast(skb_out, BROADCAST_ALL, NULL, c->net); 2743 pfkey_broadcast(skb_out, GFP_ATOMIC, BROADCAST_ALL, NULL, c->net);
2743 return 0; 2744 return 0;
2744 2745
2745} 2746}
@@ -2803,7 +2804,7 @@ static int pfkey_process(struct sock *sk, struct sk_buff *skb, const struct sadb
2803 void *ext_hdrs[SADB_EXT_MAX]; 2804 void *ext_hdrs[SADB_EXT_MAX];
2804 int err; 2805 int err;
2805 2806
2806 pfkey_broadcast(skb_clone(skb, GFP_KERNEL), 2807 pfkey_broadcast(skb_clone(skb, GFP_KERNEL), GFP_KERNEL,
2807 BROADCAST_PROMISC_ONLY, NULL, sock_net(sk)); 2808 BROADCAST_PROMISC_ONLY, NULL, sock_net(sk));
2808 2809
2809 memset(ext_hdrs, 0, sizeof(ext_hdrs)); 2810 memset(ext_hdrs, 0, sizeof(ext_hdrs));
@@ -3024,7 +3025,8 @@ static int key_notify_sa_expire(struct xfrm_state *x, const struct km_event *c)
3024 out_hdr->sadb_msg_seq = 0; 3025 out_hdr->sadb_msg_seq = 0;
3025 out_hdr->sadb_msg_pid = 0; 3026 out_hdr->sadb_msg_pid = 0;
3026 3027
3027 pfkey_broadcast(out_skb, BROADCAST_REGISTERED, NULL, xs_net(x)); 3028 pfkey_broadcast(out_skb, GFP_ATOMIC, BROADCAST_REGISTERED, NULL,
3029 xs_net(x));
3028 return 0; 3030 return 0;
3029} 3031}
3030 3032
@@ -3212,7 +3214,8 @@ static int pfkey_send_acquire(struct xfrm_state *x, struct xfrm_tmpl *t, struct
3212 xfrm_ctx->ctx_len); 3214 xfrm_ctx->ctx_len);
3213 } 3215 }
3214 3216
3215 return pfkey_broadcast(skb, BROADCAST_REGISTERED, NULL, xs_net(x)); 3217 return pfkey_broadcast(skb, GFP_ATOMIC, BROADCAST_REGISTERED, NULL,
3218 xs_net(x));
3216} 3219}
3217 3220
3218static struct xfrm_policy *pfkey_compile_policy(struct sock *sk, int opt, 3221static struct xfrm_policy *pfkey_compile_policy(struct sock *sk, int opt,
@@ -3408,7 +3411,8 @@ static int pfkey_send_new_mapping(struct xfrm_state *x, xfrm_address_t *ipaddr,
3408 n_port->sadb_x_nat_t_port_port = sport; 3411 n_port->sadb_x_nat_t_port_port = sport;
3409 n_port->sadb_x_nat_t_port_reserved = 0; 3412 n_port->sadb_x_nat_t_port_reserved = 0;
3410 3413
3411 return pfkey_broadcast(skb, BROADCAST_REGISTERED, NULL, xs_net(x)); 3414 return pfkey_broadcast(skb, GFP_ATOMIC, BROADCAST_REGISTERED, NULL,
3415 xs_net(x));
3412} 3416}
3413 3417
3414#ifdef CONFIG_NET_KEY_MIGRATE 3418#ifdef CONFIG_NET_KEY_MIGRATE
@@ -3599,7 +3603,7 @@ static int pfkey_send_migrate(const struct xfrm_selector *sel, u8 dir, u8 type,
3599 } 3603 }
3600 3604
3601 /* broadcast migrate message to sockets */ 3605 /* broadcast migrate message to sockets */
3602 pfkey_broadcast(skb, BROADCAST_ALL, NULL, &init_net); 3606 pfkey_broadcast(skb, GFP_ATOMIC, BROADCAST_ALL, NULL, &init_net);
3603 3607
3604 return 0; 3608 return 0;
3605 3609
diff --git a/net/mac80211/agg-rx.c b/net/mac80211/agg-rx.c
index 8708cbe8af5b..2b36eff5d97e 100644
--- a/net/mac80211/agg-rx.c
+++ b/net/mac80211/agg-rx.c
@@ -7,7 +7,7 @@
7 * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz> 7 * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz>
8 * Copyright 2007, Michael Wu <flamingice@sourmilk.net> 8 * Copyright 2007, Michael Wu <flamingice@sourmilk.net>
9 * Copyright 2007-2010, Intel Corporation 9 * Copyright 2007-2010, Intel Corporation
10 * Copyright(c) 2015 Intel Deutschland GmbH 10 * Copyright(c) 2015-2017 Intel Deutschland GmbH
11 * 11 *
12 * This program is free software; you can redistribute it and/or modify 12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2 as 13 * it under the terms of the GNU General Public License version 2 as
@@ -466,3 +466,23 @@ void ieee80211_manage_rx_ba_offl(struct ieee80211_vif *vif,
466 rcu_read_unlock(); 466 rcu_read_unlock();
467} 467}
468EXPORT_SYMBOL(ieee80211_manage_rx_ba_offl); 468EXPORT_SYMBOL(ieee80211_manage_rx_ba_offl);
469
470void ieee80211_rx_ba_timer_expired(struct ieee80211_vif *vif,
471 const u8 *addr, unsigned int tid)
472{
473 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
474 struct ieee80211_local *local = sdata->local;
475 struct sta_info *sta;
476
477 rcu_read_lock();
478 sta = sta_info_get_bss(sdata, addr);
479 if (!sta)
480 goto unlock;
481
482 set_bit(tid, sta->ampdu_mlme.tid_rx_timer_expired);
483 ieee80211_queue_work(&local->hw, &sta->ampdu_mlme.work);
484
485 unlock:
486 rcu_read_unlock();
487}
488EXPORT_SYMBOL(ieee80211_rx_ba_timer_expired);
diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
index bd24a550e0f9..a3fa144b8648 100644
--- a/net/sched/sch_api.c
+++ b/net/sched/sch_api.c
@@ -286,9 +286,6 @@ static struct Qdisc *qdisc_match_from_root(struct Qdisc *root, u32 handle)
286void qdisc_hash_add(struct Qdisc *q, bool invisible) 286void qdisc_hash_add(struct Qdisc *q, bool invisible)
287{ 287{
288 if ((q->parent != TC_H_ROOT) && !(q->flags & TCQ_F_INGRESS)) { 288 if ((q->parent != TC_H_ROOT) && !(q->flags & TCQ_F_INGRESS)) {
289 struct Qdisc *root = qdisc_dev(q)->qdisc;
290
291 WARN_ON_ONCE(root == &noop_qdisc);
292 ASSERT_RTNL(); 289 ASSERT_RTNL();
293 hash_add_rcu(qdisc_dev(q)->qdisc_hash, &q->hash, q->handle); 290 hash_add_rcu(qdisc_dev(q)->qdisc_hash, &q->hash, q->handle);
294 if (invisible) 291 if (invisible)
diff --git a/net/sched/sch_atm.c b/net/sched/sch_atm.c
index 572fe2584e48..c403c87aff7a 100644
--- a/net/sched/sch_atm.c
+++ b/net/sched/sch_atm.c
@@ -572,8 +572,10 @@ static void atm_tc_destroy(struct Qdisc *sch)
572 struct atm_flow_data *flow, *tmp; 572 struct atm_flow_data *flow, *tmp;
573 573
574 pr_debug("atm_tc_destroy(sch %p,[qdisc %p])\n", sch, p); 574 pr_debug("atm_tc_destroy(sch %p,[qdisc %p])\n", sch, p);
575 list_for_each_entry(flow, &p->flows, list) 575 list_for_each_entry(flow, &p->flows, list) {
576 tcf_block_put(flow->block); 576 tcf_block_put(flow->block);
577 flow->block = NULL;
578 }
577 579
578 list_for_each_entry_safe(flow, tmp, &p->flows, list) { 580 list_for_each_entry_safe(flow, tmp, &p->flows, list) {
579 if (flow->ref > 1) 581 if (flow->ref > 1)
diff --git a/net/sched/sch_cbq.c b/net/sched/sch_cbq.c
index 481036f6b54e..780db43300b1 100644
--- a/net/sched/sch_cbq.c
+++ b/net/sched/sch_cbq.c
@@ -1431,8 +1431,10 @@ static void cbq_destroy(struct Qdisc *sch)
1431 * be bound to classes which have been destroyed already. --TGR '04 1431 * be bound to classes which have been destroyed already. --TGR '04
1432 */ 1432 */
1433 for (h = 0; h < q->clhash.hashsize; h++) { 1433 for (h = 0; h < q->clhash.hashsize; h++) {
1434 hlist_for_each_entry(cl, &q->clhash.hash[h], common.hnode) 1434 hlist_for_each_entry(cl, &q->clhash.hash[h], common.hnode) {
1435 tcf_block_put(cl->block); 1435 tcf_block_put(cl->block);
1436 cl->block = NULL;
1437 }
1436 } 1438 }
1437 for (h = 0; h < q->clhash.hashsize; h++) { 1439 for (h = 0; h < q->clhash.hashsize; h++) {
1438 hlist_for_each_entry_safe(cl, next, &q->clhash.hash[h], 1440 hlist_for_each_entry_safe(cl, next, &q->clhash.hash[h],
diff --git a/net/sched/sch_hfsc.c b/net/sched/sch_hfsc.c
index b52f74610dc7..fd15200f8627 100644
--- a/net/sched/sch_hfsc.c
+++ b/net/sched/sch_hfsc.c
@@ -1428,6 +1428,10 @@ hfsc_init_qdisc(struct Qdisc *sch, struct nlattr *opt)
1428 return err; 1428 return err;
1429 q->eligible = RB_ROOT; 1429 q->eligible = RB_ROOT;
1430 1430
1431 err = tcf_block_get(&q->root.block, &q->root.filter_list);
1432 if (err)
1433 goto err_tcf;
1434
1431 q->root.cl_common.classid = sch->handle; 1435 q->root.cl_common.classid = sch->handle;
1432 q->root.refcnt = 1; 1436 q->root.refcnt = 1;
1433 q->root.sched = q; 1437 q->root.sched = q;
@@ -1447,6 +1451,10 @@ hfsc_init_qdisc(struct Qdisc *sch, struct nlattr *opt)
1447 qdisc_watchdog_init(&q->watchdog, sch); 1451 qdisc_watchdog_init(&q->watchdog, sch);
1448 1452
1449 return 0; 1453 return 0;
1454
1455err_tcf:
1456 qdisc_class_hash_destroy(&q->clhash);
1457 return err;
1450} 1458}
1451 1459
1452static int 1460static int
@@ -1522,8 +1530,10 @@ hfsc_destroy_qdisc(struct Qdisc *sch)
1522 unsigned int i; 1530 unsigned int i;
1523 1531
1524 for (i = 0; i < q->clhash.hashsize; i++) { 1532 for (i = 0; i < q->clhash.hashsize; i++) {
1525 hlist_for_each_entry(cl, &q->clhash.hash[i], cl_common.hnode) 1533 hlist_for_each_entry(cl, &q->clhash.hash[i], cl_common.hnode) {
1526 tcf_block_put(cl->block); 1534 tcf_block_put(cl->block);
1535 cl->block = NULL;
1536 }
1527 } 1537 }
1528 for (i = 0; i < q->clhash.hashsize; i++) { 1538 for (i = 0; i < q->clhash.hashsize; i++) {
1529 hlist_for_each_entry_safe(cl, next, &q->clhash.hash[i], 1539 hlist_for_each_entry_safe(cl, next, &q->clhash.hash[i],
diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c
index 203286ab4427..5d65ec5207e9 100644
--- a/net/sched/sch_htb.c
+++ b/net/sched/sch_htb.c
@@ -1258,8 +1258,10 @@ static void htb_destroy(struct Qdisc *sch)
1258 tcf_block_put(q->block); 1258 tcf_block_put(q->block);
1259 1259
1260 for (i = 0; i < q->clhash.hashsize; i++) { 1260 for (i = 0; i < q->clhash.hashsize; i++) {
1261 hlist_for_each_entry(cl, &q->clhash.hash[i], common.hnode) 1261 hlist_for_each_entry(cl, &q->clhash.hash[i], common.hnode) {
1262 tcf_block_put(cl->block); 1262 tcf_block_put(cl->block);
1263 cl->block = NULL;
1264 }
1263 } 1265 }
1264 for (i = 0; i < q->clhash.hashsize; i++) { 1266 for (i = 0; i < q->clhash.hashsize; i++) {
1265 hlist_for_each_entry_safe(cl, next, &q->clhash.hash[i], 1267 hlist_for_each_entry_safe(cl, next, &q->clhash.hash[i],
diff --git a/net/sched/sch_sfq.c b/net/sched/sch_sfq.c
index f80ea2cc5f1f..82469ef9655e 100644
--- a/net/sched/sch_sfq.c
+++ b/net/sched/sch_sfq.c
@@ -437,6 +437,7 @@ congestion_drop:
437 qdisc_drop(head, sch, to_free); 437 qdisc_drop(head, sch, to_free);
438 438
439 slot_queue_add(slot, skb); 439 slot_queue_add(slot, skb);
440 qdisc_tree_reduce_backlog(sch, 0, delta);
440 return NET_XMIT_CN; 441 return NET_XMIT_CN;
441 } 442 }
442 443
@@ -468,8 +469,10 @@ enqueue:
468 /* Return Congestion Notification only if we dropped a packet 469 /* Return Congestion Notification only if we dropped a packet
469 * from this flow. 470 * from this flow.
470 */ 471 */
471 if (qlen != slot->qlen) 472 if (qlen != slot->qlen) {
473 qdisc_tree_reduce_backlog(sch, 0, dropped - qdisc_pkt_len(skb));
472 return NET_XMIT_CN; 474 return NET_XMIT_CN;
475 }
473 476
474 /* As we dropped a packet, better let upper stack know this */ 477 /* As we dropped a packet, better let upper stack know this */
475 qdisc_tree_reduce_backlog(sch, 1, dropped); 478 qdisc_tree_reduce_backlog(sch, 1, dropped);
diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c
index d174ee3254ee..767e0537dde5 100644
--- a/net/tipc/bearer.c
+++ b/net/tipc/bearer.c
@@ -596,7 +596,7 @@ static int tipc_l2_rcv_msg(struct sk_buff *skb, struct net_device *dev,
596 rcu_read_lock(); 596 rcu_read_lock();
597 b = rcu_dereference_rtnl(dev->tipc_ptr); 597 b = rcu_dereference_rtnl(dev->tipc_ptr);
598 if (likely(b && test_bit(0, &b->up) && 598 if (likely(b && test_bit(0, &b->up) &&
599 (skb->pkt_type <= PACKET_BROADCAST))) { 599 (skb->pkt_type <= PACKET_MULTICAST))) {
600 skb->next = NULL; 600 skb->next = NULL;
601 tipc_rcv(dev_net(dev), skb, b); 601 tipc_rcv(dev_net(dev), skb, b);
602 rcu_read_unlock(); 602 rcu_read_unlock();
diff --git a/net/tipc/msg.c b/net/tipc/msg.c
index ab3087687a32..dcd90e6fa7c3 100644
--- a/net/tipc/msg.c
+++ b/net/tipc/msg.c
@@ -513,6 +513,7 @@ bool tipc_msg_reverse(u32 own_node, struct sk_buff **skb, int err)
513 513
514 /* Now reverse the concerned fields */ 514 /* Now reverse the concerned fields */
515 msg_set_errcode(hdr, err); 515 msg_set_errcode(hdr, err);
516 msg_set_non_seq(hdr, 0);
516 msg_set_origport(hdr, msg_destport(&ohdr)); 517 msg_set_origport(hdr, msg_destport(&ohdr));
517 msg_set_destport(hdr, msg_origport(&ohdr)); 518 msg_set_destport(hdr, msg_origport(&ohdr));
518 msg_set_destnode(hdr, msg_prevnode(&ohdr)); 519 msg_set_destnode(hdr, msg_prevnode(&ohdr));
diff --git a/sound/core/seq/Kconfig b/sound/core/seq/Kconfig
index a536760a94c2..45c1336c6597 100644
--- a/sound/core/seq/Kconfig
+++ b/sound/core/seq/Kconfig
@@ -47,10 +47,10 @@ config SND_SEQ_HRTIMER_DEFAULT
47 timer. 47 timer.
48 48
49config SND_SEQ_MIDI_EVENT 49config SND_SEQ_MIDI_EVENT
50 def_tristate SND_RAWMIDI 50 tristate
51 51
52config SND_SEQ_MIDI 52config SND_SEQ_MIDI
53 tristate 53 def_tristate SND_RAWMIDI
54 select SND_SEQ_MIDI_EVENT 54 select SND_SEQ_MIDI_EVENT
55 55
56config SND_SEQ_MIDI_EMUL 56config SND_SEQ_MIDI_EMUL
diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c
index 272c55fe17c8..ea2d0ae85bd3 100644
--- a/sound/core/seq/seq_clientmgr.c
+++ b/sound/core/seq/seq_clientmgr.c
@@ -1502,16 +1502,11 @@ static int snd_seq_ioctl_unsubscribe_port(struct snd_seq_client *client,
1502static int snd_seq_ioctl_create_queue(struct snd_seq_client *client, void *arg) 1502static int snd_seq_ioctl_create_queue(struct snd_seq_client *client, void *arg)
1503{ 1503{
1504 struct snd_seq_queue_info *info = arg; 1504 struct snd_seq_queue_info *info = arg;
1505 int result;
1506 struct snd_seq_queue *q; 1505 struct snd_seq_queue *q;
1507 1506
1508 result = snd_seq_queue_alloc(client->number, info->locked, info->flags); 1507 q = snd_seq_queue_alloc(client->number, info->locked, info->flags);
1509 if (result < 0) 1508 if (IS_ERR(q))
1510 return result; 1509 return PTR_ERR(q);
1511
1512 q = queueptr(result);
1513 if (q == NULL)
1514 return -EINVAL;
1515 1510
1516 info->queue = q->queue; 1511 info->queue = q->queue;
1517 info->locked = q->locked; 1512 info->locked = q->locked;
@@ -1521,7 +1516,7 @@ static int snd_seq_ioctl_create_queue(struct snd_seq_client *client, void *arg)
1521 if (!info->name[0]) 1516 if (!info->name[0])
1522 snprintf(info->name, sizeof(info->name), "Queue-%d", q->queue); 1517 snprintf(info->name, sizeof(info->name), "Queue-%d", q->queue);
1523 strlcpy(q->name, info->name, sizeof(q->name)); 1518 strlcpy(q->name, info->name, sizeof(q->name));
1524 queuefree(q); 1519 snd_use_lock_free(&q->use_lock);
1525 1520
1526 return 0; 1521 return 0;
1527} 1522}
diff --git a/sound/core/seq/seq_queue.c b/sound/core/seq/seq_queue.c
index 450c5187eecb..79e0c5604ef8 100644
--- a/sound/core/seq/seq_queue.c
+++ b/sound/core/seq/seq_queue.c
@@ -184,22 +184,26 @@ void __exit snd_seq_queues_delete(void)
184static void queue_use(struct snd_seq_queue *queue, int client, int use); 184static void queue_use(struct snd_seq_queue *queue, int client, int use);
185 185
186/* allocate a new queue - 186/* allocate a new queue -
187 * return queue index value or negative value for error 187 * return pointer to new queue or ERR_PTR(-errno) for error
188 * The new queue's use_lock is set to 1. It is the caller's responsibility to
189 * call snd_use_lock_free(&q->use_lock).
188 */ 190 */
189int snd_seq_queue_alloc(int client, int locked, unsigned int info_flags) 191struct snd_seq_queue *snd_seq_queue_alloc(int client, int locked, unsigned int info_flags)
190{ 192{
191 struct snd_seq_queue *q; 193 struct snd_seq_queue *q;
192 194
193 q = queue_new(client, locked); 195 q = queue_new(client, locked);
194 if (q == NULL) 196 if (q == NULL)
195 return -ENOMEM; 197 return ERR_PTR(-ENOMEM);
196 q->info_flags = info_flags; 198 q->info_flags = info_flags;
197 queue_use(q, client, 1); 199 queue_use(q, client, 1);
200 snd_use_lock_use(&q->use_lock);
198 if (queue_list_add(q) < 0) { 201 if (queue_list_add(q) < 0) {
202 snd_use_lock_free(&q->use_lock);
199 queue_delete(q); 203 queue_delete(q);
200 return -ENOMEM; 204 return ERR_PTR(-ENOMEM);
201 } 205 }
202 return q->queue; 206 return q;
203} 207}
204 208
205/* delete a queue - queue must be owned by the client */ 209/* delete a queue - queue must be owned by the client */
diff --git a/sound/core/seq/seq_queue.h b/sound/core/seq/seq_queue.h
index 30c8111477f6..719093489a2c 100644
--- a/sound/core/seq/seq_queue.h
+++ b/sound/core/seq/seq_queue.h
@@ -71,7 +71,7 @@ void snd_seq_queues_delete(void);
71 71
72 72
73/* create new queue (constructor) */ 73/* create new queue (constructor) */
74int snd_seq_queue_alloc(int client, int locked, unsigned int flags); 74struct snd_seq_queue *snd_seq_queue_alloc(int client, int locked, unsigned int flags);
75 75
76/* delete queue (destructor) */ 76/* delete queue (destructor) */
77int snd_seq_queue_delete(int client, int queueid); 77int snd_seq_queue_delete(int client, int queueid);
diff --git a/sound/pci/emu10k1/emufx.c b/sound/pci/emu10k1/emufx.c
index dc585959ca32..a2b56b188be4 100644
--- a/sound/pci/emu10k1/emufx.c
+++ b/sound/pci/emu10k1/emufx.c
@@ -698,10 +698,18 @@ static int copy_gctl(struct snd_emu10k1 *emu,
698{ 698{
699 struct snd_emu10k1_fx8010_control_old_gpr __user *octl; 699 struct snd_emu10k1_fx8010_control_old_gpr __user *octl;
700 700
701 if (emu->support_tlv) 701 if (emu->support_tlv) {
702 return copy_from_user(gctl, &_gctl[idx], sizeof(*gctl)); 702 if (in_kernel)
703 memcpy(gctl, (void *)&_gctl[idx], sizeof(*gctl));
704 else if (copy_from_user(gctl, &_gctl[idx], sizeof(*gctl)))
705 return -EFAULT;
706 return 0;
707 }
708
703 octl = (struct snd_emu10k1_fx8010_control_old_gpr __user *)_gctl; 709 octl = (struct snd_emu10k1_fx8010_control_old_gpr __user *)_gctl;
704 if (copy_from_user(gctl, &octl[idx], sizeof(*octl))) 710 if (in_kernel)
711 memcpy(gctl, (void *)&octl[idx], sizeof(*octl));
712 else if (copy_from_user(gctl, &octl[idx], sizeof(*octl)))
705 return -EFAULT; 713 return -EFAULT;
706 gctl->tlv = NULL; 714 gctl->tlv = NULL;
707 return 0; 715 return 0;
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index a91a9ef00c40..217bb582aff1 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -6647,7 +6647,6 @@ static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = {
6647 SND_HDA_PIN_QUIRK(0x10ec0299, 0x1028, "Dell", ALC269_FIXUP_DELL4_MIC_NO_PRESENCE, 6647 SND_HDA_PIN_QUIRK(0x10ec0299, 0x1028, "Dell", ALC269_FIXUP_DELL4_MIC_NO_PRESENCE,
6648 ALC225_STANDARD_PINS, 6648 ALC225_STANDARD_PINS,
6649 {0x12, 0xb7a60130}, 6649 {0x12, 0xb7a60130},
6650 {0x13, 0xb8a61140},
6651 {0x17, 0x90170110}), 6650 {0x17, 0x90170110}),
6652 {} 6651 {}
6653}; 6652};
diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
index 082736c539bc..e630813c5008 100644
--- a/sound/usb/mixer.c
+++ b/sound/usb/mixer.c
@@ -542,6 +542,8 @@ int snd_usb_mixer_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
542 542
543 if (size < sizeof(scale)) 543 if (size < sizeof(scale))
544 return -ENOMEM; 544 return -ENOMEM;
545 if (cval->min_mute)
546 scale[0] = SNDRV_CTL_TLVT_DB_MINMAX_MUTE;
545 scale[2] = cval->dBmin; 547 scale[2] = cval->dBmin;
546 scale[3] = cval->dBmax; 548 scale[3] = cval->dBmax;
547 if (copy_to_user(_tlv, scale, sizeof(scale))) 549 if (copy_to_user(_tlv, scale, sizeof(scale)))
diff --git a/sound/usb/mixer.h b/sound/usb/mixer.h
index 3417ef347e40..2b4b067646ab 100644
--- a/sound/usb/mixer.h
+++ b/sound/usb/mixer.h
@@ -64,6 +64,7 @@ struct usb_mixer_elem_info {
64 int cached; 64 int cached;
65 int cache_val[MAX_CHANNELS]; 65 int cache_val[MAX_CHANNELS];
66 u8 initialized; 66 u8 initialized;
67 u8 min_mute;
67 void *private_data; 68 void *private_data;
68}; 69};
69 70
diff --git a/sound/usb/mixer_quirks.c b/sound/usb/mixer_quirks.c
index e3d1dec48ee4..e1e7ce9ab217 100644
--- a/sound/usb/mixer_quirks.c
+++ b/sound/usb/mixer_quirks.c
@@ -1878,6 +1878,12 @@ void snd_usb_mixer_fu_apply_quirk(struct usb_mixer_interface *mixer,
1878 if (unitid == 7 && cval->control == UAC_FU_VOLUME) 1878 if (unitid == 7 && cval->control == UAC_FU_VOLUME)
1879 snd_dragonfly_quirk_db_scale(mixer, cval, kctl); 1879 snd_dragonfly_quirk_db_scale(mixer, cval, kctl);
1880 break; 1880 break;
1881 /* lowest playback value is muted on C-Media devices */
1882 case USB_ID(0x0d8c, 0x000c):
1883 case USB_ID(0x0d8c, 0x0014):
1884 if (strstr(kctl->id.name, "Playback"))
1885 cval->min_mute = 1;
1886 break;
1881 } 1887 }
1882} 1888}
1883 1889
diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c
index d7b0b0a3a2db..6a03f9697039 100644
--- a/sound/usb/quirks.c
+++ b/sound/usb/quirks.c
@@ -1142,6 +1142,7 @@ bool snd_usb_get_sample_rate_quirk(struct snd_usb_audio *chip)
1142 case USB_ID(0x0556, 0x0014): /* Phoenix Audio TMX320VC */ 1142 case USB_ID(0x0556, 0x0014): /* Phoenix Audio TMX320VC */
1143 case USB_ID(0x05A3, 0x9420): /* ELP HD USB Camera */ 1143 case USB_ID(0x05A3, 0x9420): /* ELP HD USB Camera */
1144 case USB_ID(0x074D, 0x3553): /* Outlaw RR2150 (Micronas UAC3553B) */ 1144 case USB_ID(0x074D, 0x3553): /* Outlaw RR2150 (Micronas UAC3553B) */
1145 case USB_ID(0x1395, 0x740a): /* Sennheiser DECT */
1145 case USB_ID(0x1901, 0x0191): /* GE B850V3 CP2114 audio interface */ 1146 case USB_ID(0x1901, 0x0191): /* GE B850V3 CP2114 audio interface */
1146 case USB_ID(0x1de7, 0x0013): /* Phoenix Audio MT202exe */ 1147 case USB_ID(0x1de7, 0x0013): /* Phoenix Audio MT202exe */
1147 case USB_ID(0x1de7, 0x0014): /* Phoenix Audio TMX320 */ 1148 case USB_ID(0x1de7, 0x0014): /* Phoenix Audio TMX320 */
@@ -1374,6 +1375,10 @@ u64 snd_usb_interface_dsd_format_quirks(struct snd_usb_audio *chip,
1374 } 1375 }
1375 } 1376 }
1376 break; 1377 break;
1378 case USB_ID(0x16d0, 0x0a23):
1379 if (fp->altsetting == 2)
1380 return SNDRV_PCM_FMTBIT_DSD_U32_BE;
1381 break;
1377 1382
1378 default: 1383 default:
1379 break; 1384 break;
diff --git a/tools/testing/selftests/futex/Makefile b/tools/testing/selftests/futex/Makefile
index e2fbb890aef9..7c647f619d63 100644
--- a/tools/testing/selftests/futex/Makefile
+++ b/tools/testing/selftests/futex/Makefile
@@ -14,7 +14,7 @@ all:
14 done 14 done
15 15
16override define RUN_TESTS 16override define RUN_TESTS
17 @if [ `dirname $(OUTPUT)` = $(PWD) ]; then ./run.sh; fi 17 $(OUTPUT)/run.sh
18endef 18endef
19 19
20override define INSTALL_RULE 20override define INSTALL_RULE
diff --git a/tools/testing/selftests/kmod/kmod.sh b/tools/testing/selftests/kmod/kmod.sh
index 8cecae9a8bca..7956ea3be667 100644..100755
--- a/tools/testing/selftests/kmod/kmod.sh
+++ b/tools/testing/selftests/kmod/kmod.sh
@@ -473,8 +473,8 @@ usage()
473 echo " all Runs all tests (default)" 473 echo " all Runs all tests (default)"
474 echo " -t Run test ID the number amount of times is recommended" 474 echo " -t Run test ID the number amount of times is recommended"
475 echo " -w Watch test ID run until it runs into an error" 475 echo " -w Watch test ID run until it runs into an error"
476 echo " -c Run test ID once" 476 echo " -s Run test ID once"
477 echo " -s Run test ID x test-count number of times" 477 echo " -c Run test ID x test-count number of times"
478 echo " -l List all test ID list" 478 echo " -l List all test ID list"
479 echo " -h|--help Help" 479 echo " -h|--help Help"
480 echo 480 echo
diff --git a/tools/testing/selftests/sysctl/sysctl.sh b/tools/testing/selftests/sysctl/sysctl.sh
index ec232c3cfcaa..ec232c3cfcaa 100644..100755
--- a/tools/testing/selftests/sysctl/sysctl.sh
+++ b/tools/testing/selftests/sysctl/sysctl.sh
diff --git a/tools/testing/selftests/timers/freq-step.c b/tools/testing/selftests/timers/freq-step.c
index e8c61830825a..22312eb4c941 100644
--- a/tools/testing/selftests/timers/freq-step.c
+++ b/tools/testing/selftests/timers/freq-step.c
@@ -229,10 +229,9 @@ static void init_test(void)
229 printf("CLOCK_MONOTONIC_RAW+CLOCK_MONOTONIC precision: %.0f ns\t\t", 229 printf("CLOCK_MONOTONIC_RAW+CLOCK_MONOTONIC precision: %.0f ns\t\t",
230 1e9 * precision); 230 1e9 * precision);
231 231
232 if (precision > MAX_PRECISION) { 232 if (precision > MAX_PRECISION)
233 printf("[SKIP]\n"); 233 ksft_exit_skip("precision: %.0f ns > MAX_PRECISION: %.0f ns\n",
234 ksft_exit_skip(); 234 1e9 * precision, 1e9 * MAX_PRECISION);
235 }
236 235
237 printf("[OK]\n"); 236 printf("[OK]\n");
238 srand(ts.tv_sec ^ ts.tv_nsec); 237 srand(ts.tv_sec ^ ts.tv_nsec);