diff options
-rw-r--r-- | 0000_README | 4 | ||||
-rw-r--r-- | 1167_linux-4.14.168.patch | 9493 |
2 files changed, 9497 insertions, 0 deletions
diff --git a/0000_README b/0000_README index 89f313a7..ea6db7d3 100644 --- a/0000_README +++ b/0000_README @@ -711,6 +711,10 @@ Patch: 1166_linux-4.14.167.patch From: https://www.kernel.org Desc: Linux 4.14.167 +Patch: 1167_linux-4.14.168.patch +From: https://www.kernel.org +Desc: Linux 4.14.168 + Patch: 1500_XATTR_USER_PREFIX.patch From: https://bugs.gentoo.org/show_bug.cgi?id=470644 Desc: Support for namespace user.pax.* on tmpfs. diff --git a/1167_linux-4.14.168.patch b/1167_linux-4.14.168.patch new file mode 100644 index 00000000..a7c21905 --- /dev/null +++ b/1167_linux-4.14.168.patch @@ -0,0 +1,9493 @@ +diff --git a/Makefile b/Makefile +index 3e8eaabf2bcb..1e74ba09cdda 100644 +--- a/Makefile ++++ b/Makefile +@@ -1,7 +1,7 @@ + # SPDX-License-Identifier: GPL-2.0 + VERSION = 4 + PATCHLEVEL = 14 +-SUBLEVEL = 167 ++SUBLEVEL = 168 + EXTRAVERSION = + NAME = Petit Gorille + +@@ -971,6 +971,7 @@ ifdef CONFIG_STACK_VALIDATION + endif + endif + ++PHONY += prepare0 + + ifeq ($(KBUILD_EXTMOD),) + core-y += kernel/ certs/ mm/ fs/ ipc/ security/ crypto/ block/ +@@ -1065,8 +1066,7 @@ include/config/kernel.release: include/config/auto.conf FORCE + # archprepare is used in arch Makefiles and when processed asm symlink, + # version.h and scripts_basic is processed / created. + +-# Listed in dependency order +-PHONY += prepare archprepare prepare0 prepare1 prepare2 prepare3 ++PHONY += prepare archprepare prepare1 prepare2 prepare3 + + # prepare3 is used to check if we are building in a separate output directory, + # and if so do: +diff --git a/arch/arm/boot/dts/lpc3250-phy3250.dts b/arch/arm/boot/dts/lpc3250-phy3250.dts +index b7bd3a110a8d..dd0bdf765599 100644 +--- a/arch/arm/boot/dts/lpc3250-phy3250.dts ++++ b/arch/arm/boot/dts/lpc3250-phy3250.dts +@@ -49,8 +49,8 @@ + sd_reg: regulator@2 { + compatible = "regulator-fixed"; + regulator-name = "sd_reg"; +- regulator-min-microvolt = <1800000>; +- regulator-max-microvolt = <1800000>; ++ regulator-min-microvolt = <3300000>; ++ regulator-max-microvolt = <3300000>; + gpio = <&gpio 5 5 0>; + enable-active-high; + }; +diff --git a/arch/arm/boot/dts/lpc32xx.dtsi b/arch/arm/boot/dts/lpc32xx.dtsi +index d077bd2b9583..c5b119ddb70b 100644 +--- a/arch/arm/boot/dts/lpc32xx.dtsi ++++ b/arch/arm/boot/dts/lpc32xx.dtsi +@@ -139,11 +139,11 @@ + }; + + clcd: clcd@31040000 { +- compatible = "arm,pl110", "arm,primecell"; ++ compatible = "arm,pl111", "arm,primecell"; + reg = <0x31040000 0x1000>; + interrupts = <14 IRQ_TYPE_LEVEL_HIGH>; +- clocks = <&clk LPC32XX_CLK_LCD>; +- clock-names = "apb_pclk"; ++ clocks = <&clk LPC32XX_CLK_LCD>, <&clk LPC32XX_CLK_LCD>; ++ clock-names = "clcdclk", "apb_pclk"; + status = "disabled"; + }; + +@@ -462,7 +462,9 @@ + key: key@40050000 { + compatible = "nxp,lpc3220-key"; + reg = <0x40050000 0x1000>; +- interrupts = <54 IRQ_TYPE_LEVEL_HIGH>; ++ clocks = <&clk LPC32XX_CLK_KEY>; ++ interrupt-parent = <&sic1>; ++ interrupts = <22 IRQ_TYPE_LEVEL_HIGH>; + status = "disabled"; + }; + +diff --git a/arch/arm/boot/dts/ls1021a-twr.dts b/arch/arm/boot/dts/ls1021a-twr.dts +index 44715c8ef756..72a3fc63d0ec 100644 +--- a/arch/arm/boot/dts/ls1021a-twr.dts ++++ b/arch/arm/boot/dts/ls1021a-twr.dts +@@ -143,7 +143,7 @@ + }; + + &enet0 { +- tbi-handle = <&tbi1>; ++ tbi-handle = <&tbi0>; + phy-handle = <&sgmii_phy2>; + phy-connection-type = "sgmii"; + status = "okay"; +@@ -222,6 +222,13 @@ + sgmii_phy2: ethernet-phy@2 { + reg = <0x2>; + }; ++ tbi0: tbi-phy@1f { ++ reg = <0x1f>; ++ device_type = "tbi-phy"; ++ }; ++}; ++ ++&mdio1 { + tbi1: tbi-phy@1f { + reg = <0x1f>; + device_type = "tbi-phy"; +diff --git a/arch/arm/boot/dts/ls1021a.dtsi b/arch/arm/boot/dts/ls1021a.dtsi +index 2d20f60947b9..1343c86988c5 100644 +--- a/arch/arm/boot/dts/ls1021a.dtsi ++++ b/arch/arm/boot/dts/ls1021a.dtsi +@@ -562,13 +562,22 @@ + }; + + mdio0: mdio@2d24000 { +- compatible = "gianfar"; ++ compatible = "fsl,etsec2-mdio"; + device_type = "mdio"; + #address-cells = <1>; + #size-cells = <0>; + reg = <0x0 0x2d24000 0x0 0x4000>; + }; + ++ mdio1: mdio@2d64000 { ++ compatible = "fsl,etsec2-mdio"; ++ device_type = "mdio"; ++ #address-cells = <1>; ++ #size-cells = <0>; ++ reg = <0x0 0x2d64000 0x0 0x4000>, ++ <0x0 0x2d50030 0x0 0x4>; ++ }; ++ + ptp_clock@2d10e00 { + compatible = "fsl,etsec-ptp"; + reg = <0x0 0x2d10e00 0x0 0xb0>; +diff --git a/arch/arm/boot/dts/stm32h743i-eval.dts b/arch/arm/boot/dts/stm32h743i-eval.dts +index 6c07786e7ddb..0d98b2865bd7 100644 +--- a/arch/arm/boot/dts/stm32h743i-eval.dts ++++ b/arch/arm/boot/dts/stm32h743i-eval.dts +@@ -71,6 +71,7 @@ + }; + + &adc_12 { ++ vdda-supply = <&vdda>; + vref-supply = <&vdda>; + status = "okay"; + adc1: adc@0 { +diff --git a/arch/arm/boot/dts/sun8i-h3-beelink-x2.dts b/arch/arm/boot/dts/sun8i-h3-beelink-x2.dts +index 10da56e86ab8..21b38c386f1b 100644 +--- a/arch/arm/boot/dts/sun8i-h3-beelink-x2.dts ++++ b/arch/arm/boot/dts/sun8i-h3-beelink-x2.dts +@@ -79,6 +79,8 @@ + wifi_pwrseq: wifi_pwrseq { + compatible = "mmc-pwrseq-simple"; + reset-gpios = <&r_pio 0 7 GPIO_ACTIVE_LOW>; /* PL7 */ ++ clocks = <&rtc 1>; ++ clock-names = "ext_clock"; + }; + + sound_spdif { +@@ -128,6 +130,8 @@ + pinctrl-names = "default"; + pinctrl-0 = <&mmc1_pins_a>; + vmmc-supply = <®_vcc3v3>; ++ vqmmc-supply = <®_vcc3v3>; ++ mmc-pwrseq = <&wifi_pwrseq>; + bus-width = <4>; + non-removable; + status = "okay"; +diff --git a/arch/arm/common/mcpm_entry.c b/arch/arm/common/mcpm_entry.c +index 2b913f17d50f..c24a55b0deac 100644 +--- a/arch/arm/common/mcpm_entry.c ++++ b/arch/arm/common/mcpm_entry.c +@@ -379,7 +379,7 @@ static int __init nocache_trampoline(unsigned long _arg) + unsigned int cluster = MPIDR_AFFINITY_LEVEL(mpidr, 1); + phys_reset_t phys_reset; + +- mcpm_set_entry_vector(cpu, cluster, cpu_resume); ++ mcpm_set_entry_vector(cpu, cluster, cpu_resume_no_hyp); + setup_mm_for_reboot(); + + __mcpm_cpu_going_down(cpu, cluster); +diff --git a/arch/arm/include/asm/suspend.h b/arch/arm/include/asm/suspend.h +index 452bbdcbcc83..506314265c6f 100644 +--- a/arch/arm/include/asm/suspend.h ++++ b/arch/arm/include/asm/suspend.h +@@ -10,6 +10,7 @@ struct sleep_save_sp { + }; + + extern void cpu_resume(void); ++extern void cpu_resume_no_hyp(void); + extern void cpu_resume_arm(void); + extern int cpu_suspend(unsigned long, int (*)(unsigned long)); + +diff --git a/arch/arm/kernel/hyp-stub.S b/arch/arm/kernel/hyp-stub.S +index 60146e32619a..82a942894fc0 100644 +--- a/arch/arm/kernel/hyp-stub.S ++++ b/arch/arm/kernel/hyp-stub.S +@@ -180,8 +180,8 @@ ARM_BE8(orr r7, r7, #(1 << 25)) @ HSCTLR.EE + @ Check whether GICv3 system registers are available + mrc p15, 0, r7, c0, c1, 1 @ ID_PFR1 + ubfx r7, r7, #28, #4 +- cmp r7, #1 +- bne 2f ++ teq r7, #0 ++ beq 2f + + @ Enable system register accesses + mrc p15, 4, r7, c12, c9, 5 @ ICC_HSRE +diff --git a/arch/arm/kernel/sleep.S b/arch/arm/kernel/sleep.S +index a8257fc9cf2a..5dc8b80bb693 100644 +--- a/arch/arm/kernel/sleep.S ++++ b/arch/arm/kernel/sleep.S +@@ -120,6 +120,14 @@ ENDPROC(cpu_resume_after_mmu) + .text + .align + ++#ifdef CONFIG_MCPM ++ .arm ++THUMB( .thumb ) ++ENTRY(cpu_resume_no_hyp) ++ARM_BE8(setend be) @ ensure we are in BE mode ++ b no_hyp ++#endif ++ + #ifdef CONFIG_MMU + .arm + ENTRY(cpu_resume_arm) +@@ -135,6 +143,7 @@ ARM_BE8(setend be) @ ensure we are in BE mode + bl __hyp_stub_install_secondary + #endif + safe_svcmode_maskall r1 ++no_hyp: + mov r1, #0 + ALT_SMP(mrc p15, 0, r0, c0, c0, 5) + ALT_UP_B(1f) +@@ -163,6 +172,9 @@ ENDPROC(cpu_resume) + + #ifdef CONFIG_MMU + ENDPROC(cpu_resume_arm) ++#endif ++#ifdef CONFIG_MCPM ++ENDPROC(cpu_resume_no_hyp) + #endif + + .align 2 +diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c +index 45c8f2ef4e23..9274a484c6a3 100644 +--- a/arch/arm/mach-omap2/omap_hwmod.c ++++ b/arch/arm/mach-omap2/omap_hwmod.c +@@ -2530,7 +2530,7 @@ static void _setup_iclk_autoidle(struct omap_hwmod *oh) + */ + static int _setup_reset(struct omap_hwmod *oh) + { +- int r; ++ int r = 0; + + if (oh->_state != _HWMOD_STATE_INITIALIZED) + return -EINVAL; +diff --git a/arch/arm/mach-rpc/irq.c b/arch/arm/mach-rpc/irq.c +index b8a61cb11207..7f0f40178634 100644 +--- a/arch/arm/mach-rpc/irq.c ++++ b/arch/arm/mach-rpc/irq.c +@@ -118,7 +118,7 @@ extern unsigned char rpc_default_fiq_start, rpc_default_fiq_end; + + void __init rpc_init_irq(void) + { +- unsigned int irq, clr, set = 0; ++ unsigned int irq, clr, set; + + iomd_writeb(0, IOMD_IRQMASKA); + iomd_writeb(0, IOMD_IRQMASKB); +@@ -130,6 +130,7 @@ void __init rpc_init_irq(void) + + for (irq = 0; irq < NR_IRQS; irq++) { + clr = IRQ_NOREQUEST; ++ set = 0; + + if (irq <= 6 || (irq >= 9 && irq <= 15)) + clr |= IRQ_NOPROBE; +diff --git a/arch/arm/plat-pxa/ssp.c b/arch/arm/plat-pxa/ssp.c +index b92673efffff..97bd43c16cd8 100644 +--- a/arch/arm/plat-pxa/ssp.c ++++ b/arch/arm/plat-pxa/ssp.c +@@ -230,18 +230,12 @@ static int pxa_ssp_probe(struct platform_device *pdev) + + static int pxa_ssp_remove(struct platform_device *pdev) + { +- struct resource *res; + struct ssp_device *ssp; + + ssp = platform_get_drvdata(pdev); + if (ssp == NULL) + return -ENODEV; + +- res = platform_get_resource(pdev, IORESOURCE_MEM, 0); +- release_mem_region(res->start, resource_size(res)); +- +- clk_put(ssp->clk); +- + mutex_lock(&ssp_lock); + list_del(&ssp->node); + mutex_unlock(&ssp_lock); +diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi +index 8c8db1b057df..788a6f8c5994 100644 +--- a/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi ++++ b/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi +@@ -274,7 +274,8 @@ + interrupts = <GIC_SPI 11 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 17 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 21 IRQ_TYPE_LEVEL_HIGH>; +- clocks = <&ccu 58>; ++ clocks = <&ccu 58>, <&osc24M>, <&rtc 0>; ++ clock-names = "apb", "hosc", "losc"; + gpio-controller; + #gpio-cells = <3>; + interrupt-controller; +diff --git a/arch/arm64/boot/dts/amlogic/meson-gxl-s905x-libretech-cc.dts b/arch/arm64/boot/dts/amlogic/meson-gxl-s905x-libretech-cc.dts +index e2c71753e327..407d32f4fe73 100644 +--- a/arch/arm64/boot/dts/amlogic/meson-gxl-s905x-libretech-cc.dts ++++ b/arch/arm64/boot/dts/amlogic/meson-gxl-s905x-libretech-cc.dts +@@ -226,7 +226,6 @@ + cap-mmc-highspeed; + mmc-ddr-3_3v; + max-frequency = <50000000>; +- non-removable; + disable-wp; + + mmc-pwrseq = <&emmc_pwrseq>; +diff --git a/arch/arm64/boot/dts/arm/juno-clocks.dtsi b/arch/arm64/boot/dts/arm/juno-clocks.dtsi +index e5e265dfa902..2870b5eeb198 100644 +--- a/arch/arm64/boot/dts/arm/juno-clocks.dtsi ++++ b/arch/arm64/boot/dts/arm/juno-clocks.dtsi +@@ -8,10 +8,10 @@ + */ + / { + /* SoC fixed clocks */ +- soc_uartclk: refclk7273800hz { ++ soc_uartclk: refclk7372800hz { + compatible = "fixed-clock"; + #clock-cells = <0>; +- clock-frequency = <7273800>; ++ clock-frequency = <7372800>; + clock-output-names = "juno:uartclk"; + }; + +diff --git a/arch/arm64/boot/dts/qcom/apq8016-sbc.dtsi b/arch/arm64/boot/dts/qcom/apq8016-sbc.dtsi +index b6b44fdf7fac..c1028b47edde 100644 +--- a/arch/arm64/boot/dts/qcom/apq8016-sbc.dtsi ++++ b/arch/arm64/boot/dts/qcom/apq8016-sbc.dtsi +@@ -458,6 +458,8 @@ + l11 { + regulator-min-microvolt = <1750000>; + regulator-max-microvolt = <3337000>; ++ regulator-allow-set-load; ++ regulator-system-load = <200000>; + }; + + l12 { +diff --git a/arch/m68k/amiga/cia.c b/arch/m68k/amiga/cia.c +index 2081b8cd5591..b9aee983e6f4 100644 +--- a/arch/m68k/amiga/cia.c ++++ b/arch/m68k/amiga/cia.c +@@ -88,10 +88,19 @@ static irqreturn_t cia_handler(int irq, void *dev_id) + struct ciabase *base = dev_id; + int mach_irq; + unsigned char ints; ++ unsigned long flags; + ++ /* Interrupts get disabled while the timer irq flag is cleared and ++ * the timer interrupt serviced. ++ */ + mach_irq = base->cia_irq; ++ local_irq_save(flags); + ints = cia_set_irq(base, CIA_ICR_ALL); + amiga_custom.intreq = base->int_mask; ++ if (ints & 1) ++ generic_handle_irq(mach_irq); ++ local_irq_restore(flags); ++ mach_irq++, ints >>= 1; + for (; ints; mach_irq++, ints >>= 1) { + if (ints & 1) + generic_handle_irq(mach_irq); +diff --git a/arch/m68k/atari/ataints.c b/arch/m68k/atari/ataints.c +index 3d2b63bedf05..56f02ea2c248 100644 +--- a/arch/m68k/atari/ataints.c ++++ b/arch/m68k/atari/ataints.c +@@ -142,7 +142,7 @@ struct mfptimerbase { + .name = "MFP Timer D" + }; + +-static irqreturn_t mfptimer_handler(int irq, void *dev_id) ++static irqreturn_t mfp_timer_d_handler(int irq, void *dev_id) + { + struct mfptimerbase *base = dev_id; + int mach_irq; +@@ -344,7 +344,7 @@ void __init atari_init_IRQ(void) + st_mfp.tim_ct_cd = (st_mfp.tim_ct_cd & 0xf0) | 0x6; + + /* request timer D dispatch handler */ +- if (request_irq(IRQ_MFP_TIMD, mfptimer_handler, IRQF_SHARED, ++ if (request_irq(IRQ_MFP_TIMD, mfp_timer_d_handler, IRQF_SHARED, + stmfp_base.name, &stmfp_base)) + pr_err("Couldn't register %s interrupt\n", stmfp_base.name); + +diff --git a/arch/m68k/atari/time.c b/arch/m68k/atari/time.c +index c549b48174ec..972181c1fe4b 100644 +--- a/arch/m68k/atari/time.c ++++ b/arch/m68k/atari/time.c +@@ -24,6 +24,18 @@ + DEFINE_SPINLOCK(rtc_lock); + EXPORT_SYMBOL_GPL(rtc_lock); + ++static irqreturn_t mfp_timer_c_handler(int irq, void *dev_id) ++{ ++ irq_handler_t timer_routine = dev_id; ++ unsigned long flags; ++ ++ local_irq_save(flags); ++ timer_routine(0, NULL); ++ local_irq_restore(flags); ++ ++ return IRQ_HANDLED; ++} ++ + void __init + atari_sched_init(irq_handler_t timer_routine) + { +@@ -32,7 +44,8 @@ atari_sched_init(irq_handler_t timer_routine) + /* start timer C, div = 1:100 */ + st_mfp.tim_ct_cd = (st_mfp.tim_ct_cd & 15) | 0x60; + /* install interrupt service routine for MFP Timer C */ +- if (request_irq(IRQ_MFP_TIMC, timer_routine, 0, "timer", timer_routine)) ++ if (request_irq(IRQ_MFP_TIMC, mfp_timer_c_handler, 0, "timer", ++ timer_routine)) + pr_err("Couldn't register timer interrupt\n"); + } + +diff --git a/arch/m68k/bvme6000/config.c b/arch/m68k/bvme6000/config.c +index 2cfff4765040..0e602c32b246 100644 +--- a/arch/m68k/bvme6000/config.c ++++ b/arch/m68k/bvme6000/config.c +@@ -45,11 +45,6 @@ extern int bvme6000_set_clock_mmss (unsigned long); + extern void bvme6000_reset (void); + void bvme6000_set_vectors (void); + +-/* Save tick handler routine pointer, will point to xtime_update() in +- * kernel/timer/timekeeping.c, called via bvme6000_process_int() */ +- +-static irq_handler_t tick_handler; +- + + int __init bvme6000_parse_bootinfo(const struct bi_record *bi) + { +@@ -159,12 +154,18 @@ irqreturn_t bvme6000_abort_int (int irq, void *dev_id) + + static irqreturn_t bvme6000_timer_int (int irq, void *dev_id) + { ++ irq_handler_t timer_routine = dev_id; ++ unsigned long flags; + volatile RtcPtr_t rtc = (RtcPtr_t)BVME_RTC_BASE; +- unsigned char msr = rtc->msr & 0xc0; ++ unsigned char msr; + ++ local_irq_save(flags); ++ msr = rtc->msr & 0xc0; + rtc->msr = msr | 0x20; /* Ack the interrupt */ ++ timer_routine(0, NULL); ++ local_irq_restore(flags); + +- return tick_handler(irq, dev_id); ++ return IRQ_HANDLED; + } + + /* +@@ -183,9 +184,8 @@ void bvme6000_sched_init (irq_handler_t timer_routine) + + rtc->msr = 0; /* Ensure timer registers accessible */ + +- tick_handler = timer_routine; +- if (request_irq(BVME_IRQ_RTC, bvme6000_timer_int, 0, +- "timer", bvme6000_timer_int)) ++ if (request_irq(BVME_IRQ_RTC, bvme6000_timer_int, 0, "timer", ++ timer_routine)) + panic ("Couldn't register timer int"); + + rtc->t1cr_omr = 0x04; /* Mode 2, ext clk */ +diff --git a/arch/m68k/hp300/time.c b/arch/m68k/hp300/time.c +index 289d928a46cb..d30b03ea93a2 100644 +--- a/arch/m68k/hp300/time.c ++++ b/arch/m68k/hp300/time.c +@@ -38,13 +38,19 @@ + + static irqreturn_t hp300_tick(int irq, void *dev_id) + { ++ irq_handler_t timer_routine = dev_id; ++ unsigned long flags; + unsigned long tmp; +- irq_handler_t vector = dev_id; ++ ++ local_irq_save(flags); + in_8(CLOCKBASE + CLKSR); + asm volatile ("movpw %1@(5),%0" : "=d" (tmp) : "a" (CLOCKBASE)); ++ timer_routine(0, NULL); ++ local_irq_restore(flags); ++ + /* Turn off the network and SCSI leds */ + blinken_leds(0, 0xe0); +- return vector(irq, NULL); ++ return IRQ_HANDLED; + } + + u32 hp300_gettimeoffset(void) +diff --git a/arch/m68k/mac/via.c b/arch/m68k/mac/via.c +index 9f59a662ace5..863806e6775a 100644 +--- a/arch/m68k/mac/via.c ++++ b/arch/m68k/mac/via.c +@@ -54,16 +54,6 @@ static __u8 rbv_clear; + + static int gIER,gIFR,gBufA,gBufB; + +-/* +- * Timer defs. +- */ +- +-#define TICK_SIZE 10000 +-#define MAC_CLOCK_TICK (783300/HZ) /* ticks per HZ */ +-#define MAC_CLOCK_LOW (MAC_CLOCK_TICK&0xFF) +-#define MAC_CLOCK_HIGH (MAC_CLOCK_TICK>>8) +- +- + /* + * On Macs with a genuine VIA chip there is no way to mask an individual slot + * interrupt. This limitation also seems to apply to VIA clone logic cores in +@@ -278,22 +268,6 @@ void __init via_init(void) + } + } + +-/* +- * Start the 100 Hz clock +- */ +- +-void __init via_init_clock(irq_handler_t func) +-{ +- via1[vACR] |= 0x40; +- via1[vT1LL] = MAC_CLOCK_LOW; +- via1[vT1LH] = MAC_CLOCK_HIGH; +- via1[vT1CL] = MAC_CLOCK_LOW; +- via1[vT1CH] = MAC_CLOCK_HIGH; +- +- if (request_irq(IRQ_MAC_TIMER_1, func, 0, "timer", func)) +- pr_err("Couldn't register %s interrupt\n", "timer"); +-} +- + /* + * Debugging dump, used in various places to see what's going on. + */ +@@ -321,29 +295,6 @@ void via_debug_dump(void) + } + } + +-/* +- * This is always executed with interrupts disabled. +- * +- * TBI: get time offset between scheduling timer ticks +- */ +- +-u32 mac_gettimeoffset(void) +-{ +- unsigned long ticks, offset = 0; +- +- /* read VIA1 timer 2 current value */ +- ticks = via1[vT1CL] | (via1[vT1CH] << 8); +- /* The probability of underflow is less than 2% */ +- if (ticks > MAC_CLOCK_TICK - MAC_CLOCK_TICK / 50) +- /* Check for pending timer interrupt in VIA1 IFR */ +- if (via1[vIFR] & 0x40) offset = TICK_SIZE; +- +- ticks = MAC_CLOCK_TICK - ticks; +- ticks = ticks * 10000L / MAC_CLOCK_TICK; +- +- return (ticks + offset) * 1000; +-} +- + /* + * Flush the L2 cache on Macs that have it by flipping + * the system into 24-bit mode for an instant. +@@ -447,6 +398,8 @@ void via_nubus_irq_shutdown(int irq) + * via6522.c :-), disable/pending masks added. + */ + ++#define VIA_TIMER_1_INT BIT(6) ++ + void via1_irq(struct irq_desc *desc) + { + int irq_num; +@@ -456,6 +409,21 @@ void via1_irq(struct irq_desc *desc) + if (!events) + return; + ++ irq_num = IRQ_MAC_TIMER_1; ++ irq_bit = VIA_TIMER_1_INT; ++ if (events & irq_bit) { ++ unsigned long flags; ++ ++ local_irq_save(flags); ++ via1[vIFR] = irq_bit; ++ generic_handle_irq(irq_num); ++ local_irq_restore(flags); ++ ++ events &= ~irq_bit; ++ if (!events) ++ return; ++ } ++ + irq_num = VIA1_SOURCE_BASE; + irq_bit = 1; + do { +@@ -612,3 +580,56 @@ int via2_scsi_drq_pending(void) + return via2[gIFR] & (1 << IRQ_IDX(IRQ_MAC_SCSIDRQ)); + } + EXPORT_SYMBOL(via2_scsi_drq_pending); ++ ++/* timer and clock source */ ++ ++#define VIA_CLOCK_FREQ 783360 /* VIA "phase 2" clock in Hz */ ++#define VIA_TIMER_INTERVAL (1000000 / HZ) /* microseconds per jiffy */ ++#define VIA_TIMER_CYCLES (VIA_CLOCK_FREQ / HZ) /* clock cycles per jiffy */ ++ ++#define VIA_TC (VIA_TIMER_CYCLES - 2) /* including 0 and -1 */ ++#define VIA_TC_LOW (VIA_TC & 0xFF) ++#define VIA_TC_HIGH (VIA_TC >> 8) ++ ++void __init via_init_clock(irq_handler_t timer_routine) ++{ ++ if (request_irq(IRQ_MAC_TIMER_1, timer_routine, 0, "timer", NULL)) { ++ pr_err("Couldn't register %s interrupt\n", "timer"); ++ return; ++ } ++ ++ via1[vT1LL] = VIA_TC_LOW; ++ via1[vT1LH] = VIA_TC_HIGH; ++ via1[vT1CL] = VIA_TC_LOW; ++ via1[vT1CH] = VIA_TC_HIGH; ++ via1[vACR] |= 0x40; ++} ++ ++u32 mac_gettimeoffset(void) ++{ ++ unsigned long flags; ++ u8 count_high; ++ u16 count, offset = 0; ++ ++ /* ++ * Timer counter wrap-around is detected with the timer interrupt flag ++ * but reading the counter low byte (vT1CL) would reset the flag. ++ * Also, accessing both counter registers is essentially a data race. ++ * These problems are avoided by ignoring the low byte. Clock accuracy ++ * is 256 times worse (error can reach 0.327 ms) but CPU overhead is ++ * reduced by avoiding slow VIA register accesses. ++ */ ++ ++ local_irq_save(flags); ++ count_high = via1[vT1CH]; ++ if (count_high == 0xFF) ++ count_high = 0; ++ if (count_high > 0 && (via1[vIFR] & VIA_TIMER_1_INT)) ++ offset = VIA_TIMER_CYCLES; ++ local_irq_restore(flags); ++ ++ count = count_high << 8; ++ count = VIA_TIMER_CYCLES - count + offset; ++ ++ return ((count * VIA_TIMER_INTERVAL) / VIA_TIMER_CYCLES) * 1000; ++} +diff --git a/arch/m68k/mvme147/config.c b/arch/m68k/mvme147/config.c +index 8778612d1f31..78ae803c833e 100644 +--- a/arch/m68k/mvme147/config.c ++++ b/arch/m68k/mvme147/config.c +@@ -46,11 +46,6 @@ extern void mvme147_reset (void); + + static int bcd2int (unsigned char b); + +-/* Save tick handler routine pointer, will point to xtime_update() in +- * kernel/time/timekeeping.c, called via mvme147_process_int() */ +- +-irq_handler_t tick_handler; +- + + int __init mvme147_parse_bootinfo(const struct bi_record *bi) + { +@@ -106,16 +101,23 @@ void __init config_mvme147(void) + + static irqreturn_t mvme147_timer_int (int irq, void *dev_id) + { ++ irq_handler_t timer_routine = dev_id; ++ unsigned long flags; ++ ++ local_irq_save(flags); + m147_pcc->t1_int_cntrl = PCC_TIMER_INT_CLR; + m147_pcc->t1_int_cntrl = PCC_INT_ENAB|PCC_LEVEL_TIMER1; +- return tick_handler(irq, dev_id); ++ timer_routine(0, NULL); ++ local_irq_restore(flags); ++ ++ return IRQ_HANDLED; + } + + + void mvme147_sched_init (irq_handler_t timer_routine) + { +- tick_handler = timer_routine; +- if (request_irq(PCC_IRQ_TIMER1, mvme147_timer_int, 0, "timer 1", NULL)) ++ if (request_irq(PCC_IRQ_TIMER1, mvme147_timer_int, 0, "timer 1", ++ timer_routine)) + pr_err("Couldn't register timer interrupt\n"); + + /* Init the clock with a value */ +diff --git a/arch/m68k/mvme16x/config.c b/arch/m68k/mvme16x/config.c +index 6fa06d4d16bf..3116dd576bb3 100644 +--- a/arch/m68k/mvme16x/config.c ++++ b/arch/m68k/mvme16x/config.c +@@ -51,11 +51,6 @@ extern void mvme16x_reset (void); + + int bcd2int (unsigned char b); + +-/* Save tick handler routine pointer, will point to xtime_update() in +- * kernel/time/timekeeping.c, called via mvme16x_process_int() */ +- +-static irq_handler_t tick_handler; +- + + unsigned short mvme16x_config; + EXPORT_SYMBOL(mvme16x_config); +@@ -354,8 +349,15 @@ static irqreturn_t mvme16x_abort_int (int irq, void *dev_id) + + static irqreturn_t mvme16x_timer_int (int irq, void *dev_id) + { +- *(volatile unsigned char *)0xfff4201b |= 8; +- return tick_handler(irq, dev_id); ++ irq_handler_t timer_routine = dev_id; ++ unsigned long flags; ++ ++ local_irq_save(flags); ++ *(volatile unsigned char *)0xfff4201b |= 8; ++ timer_routine(0, NULL); ++ local_irq_restore(flags); ++ ++ return IRQ_HANDLED; + } + + void mvme16x_sched_init (irq_handler_t timer_routine) +@@ -363,14 +365,13 @@ void mvme16x_sched_init (irq_handler_t timer_routine) + uint16_t brdno = be16_to_cpu(mvme_bdid.brdno); + int irq; + +- tick_handler = timer_routine; + /* Using PCCchip2 or MC2 chip tick timer 1 */ + *(volatile unsigned long *)0xfff42008 = 0; + *(volatile unsigned long *)0xfff42004 = 10000; /* 10ms */ + *(volatile unsigned char *)0xfff42017 |= 3; + *(volatile unsigned char *)0xfff4201b = 0x16; +- if (request_irq(MVME16x_IRQ_TIMER, mvme16x_timer_int, 0, +- "timer", mvme16x_timer_int)) ++ if (request_irq(MVME16x_IRQ_TIMER, mvme16x_timer_int, 0, "timer", ++ timer_routine)) + panic ("Couldn't register timer int"); + + if (brdno == 0x0162 || brdno == 0x172) +diff --git a/arch/m68k/q40/q40ints.c b/arch/m68k/q40/q40ints.c +index 3e7603202977..1c696906c159 100644 +--- a/arch/m68k/q40/q40ints.c ++++ b/arch/m68k/q40/q40ints.c +@@ -127,10 +127,10 @@ void q40_mksound(unsigned int hz, unsigned int ticks) + sound_ticks = ticks << 1; + } + +-static irq_handler_t q40_timer_routine; +- +-static irqreturn_t q40_timer_int (int irq, void * dev) ++static irqreturn_t q40_timer_int(int irq, void *dev_id) + { ++ irq_handler_t timer_routine = dev_id; ++ + ql_ticks = ql_ticks ? 0 : 1; + if (sound_ticks) { + unsigned char sval=(sound_ticks & 1) ? 128-SVOL : 128+SVOL; +@@ -139,8 +139,13 @@ static irqreturn_t q40_timer_int (int irq, void * dev) + *DAC_RIGHT=sval; + } + +- if (!ql_ticks) +- q40_timer_routine(irq, dev); ++ if (!ql_ticks) { ++ unsigned long flags; ++ ++ local_irq_save(flags); ++ timer_routine(0, NULL); ++ local_irq_restore(flags); ++ } + return IRQ_HANDLED; + } + +@@ -148,11 +153,9 @@ void q40_sched_init (irq_handler_t timer_routine) + { + int timer_irq; + +- q40_timer_routine = timer_routine; + timer_irq = Q40_IRQ_FRAME; + +- if (request_irq(timer_irq, q40_timer_int, 0, +- "timer", q40_timer_int)) ++ if (request_irq(timer_irq, q40_timer_int, 0, "timer", timer_routine)) + panic("Couldn't register timer int"); + + master_outb(-1, FRAME_CLEAR_REG); +diff --git a/arch/m68k/sun3/sun3ints.c b/arch/m68k/sun3/sun3ints.c +index 6bbca30c9188..a5824abb4a39 100644 +--- a/arch/m68k/sun3/sun3ints.c ++++ b/arch/m68k/sun3/sun3ints.c +@@ -61,8 +61,10 @@ static irqreturn_t sun3_int7(int irq, void *dev_id) + + static irqreturn_t sun3_int5(int irq, void *dev_id) + { ++ unsigned long flags; + unsigned int cnt; + ++ local_irq_save(flags); + #ifdef CONFIG_SUN3 + intersil_clear(); + #endif +@@ -76,6 +78,7 @@ static irqreturn_t sun3_int5(int irq, void *dev_id) + cnt = kstat_irqs_cpu(irq, 0); + if (!(cnt % 20)) + sun3_leds(led_pattern[cnt % 160 / 20]); ++ local_irq_restore(flags); + return IRQ_HANDLED; + } + +diff --git a/arch/m68k/sun3x/time.c b/arch/m68k/sun3x/time.c +index 7a2c53d9f779..48b43903253e 100644 +--- a/arch/m68k/sun3x/time.c ++++ b/arch/m68k/sun3x/time.c +@@ -78,15 +78,19 @@ u32 sun3x_gettimeoffset(void) + } + + #if 0 +-static void sun3x_timer_tick(int irq, void *dev_id, struct pt_regs *regs) ++static irqreturn_t sun3x_timer_tick(int irq, void *dev_id) + { +- void (*vector)(int, void *, struct pt_regs *) = dev_id; ++ irq_handler_t timer_routine = dev_id; ++ unsigned long flags; + +- /* Clear the pending interrupt - pulse the enable line low */ +- disable_irq(5); +- enable_irq(5); ++ local_irq_save(flags); ++ /* Clear the pending interrupt - pulse the enable line low */ ++ disable_irq(5); ++ enable_irq(5); ++ timer_routine(0, NULL); ++ local_irq_restore(flags); + +- vector(irq, NULL, regs); ++ return IRQ_HANDLED; + } + #endif + +diff --git a/arch/mips/bcm63xx/Makefile b/arch/mips/bcm63xx/Makefile +index c69f297fc1df..d89651e538f6 100644 +--- a/arch/mips/bcm63xx/Makefile ++++ b/arch/mips/bcm63xx/Makefile +@@ -1,8 +1,8 @@ + # SPDX-License-Identifier: GPL-2.0 + obj-y += clk.o cpu.o cs.o gpio.o irq.o nvram.o prom.o reset.o \ +- setup.o timer.o dev-dsp.o dev-enet.o dev-flash.o \ +- dev-pcmcia.o dev-rng.o dev-spi.o dev-hsspi.o dev-uart.o \ +- dev-wdt.o dev-usb-usbd.o ++ setup.o timer.o dev-enet.o dev-flash.o dev-pcmcia.o \ ++ dev-rng.o dev-spi.o dev-hsspi.o dev-uart.o dev-wdt.o \ ++ dev-usb-usbd.o + obj-$(CONFIG_EARLY_PRINTK) += early_printk.o + + obj-y += boards/ +diff --git a/arch/mips/bcm63xx/boards/board_bcm963xx.c b/arch/mips/bcm63xx/boards/board_bcm963xx.c +index b2097c0d2ed7..36ec3dc2c999 100644 +--- a/arch/mips/bcm63xx/boards/board_bcm963xx.c ++++ b/arch/mips/bcm63xx/boards/board_bcm963xx.c +@@ -23,7 +23,6 @@ + #include <bcm63xx_nvram.h> + #include <bcm63xx_dev_pci.h> + #include <bcm63xx_dev_enet.h> +-#include <bcm63xx_dev_dsp.h> + #include <bcm63xx_dev_flash.h> + #include <bcm63xx_dev_hsspi.h> + #include <bcm63xx_dev_pcmcia.h> +@@ -289,14 +288,6 @@ static struct board_info __initdata board_96348gw_10 = { + .has_pccard = 1, + .has_ehci0 = 1, + +- .has_dsp = 1, +- .dsp = { +- .gpio_rst = 6, +- .gpio_int = 34, +- .cs = 2, +- .ext_irq = 2, +- }, +- + .leds = { + { + .name = "adsl-fail", +@@ -401,14 +392,6 @@ static struct board_info __initdata board_96348gw = { + + .has_ohci0 = 1, + +- .has_dsp = 1, +- .dsp = { +- .gpio_rst = 6, +- .gpio_int = 34, +- .ext_irq = 2, +- .cs = 2, +- }, +- + .leds = { + { + .name = "adsl-fail", +@@ -898,9 +881,6 @@ int __init board_register_devices(void) + if (board.has_usbd) + bcm63xx_usbd_register(&board.usbd); + +- if (board.has_dsp) +- bcm63xx_dsp_register(&board.dsp); +- + /* Generate MAC address for WLAN and register our SPROM, + * do this after registering enet devices + */ +diff --git a/arch/mips/bcm63xx/dev-dsp.c b/arch/mips/bcm63xx/dev-dsp.c +deleted file mode 100644 +index 5bb5b154c9bd..000000000000 +--- a/arch/mips/bcm63xx/dev-dsp.c ++++ /dev/null +@@ -1,56 +0,0 @@ +-/* +- * Broadcom BCM63xx VoIP DSP registration +- * +- * This file is subject to the terms and conditions of the GNU General Public +- * License. See the file "COPYING" in the main directory of this archive +- * for more details. +- * +- * Copyright (C) 2009 Florian Fainelli <florian@openwrt.org> +- */ +- +-#include <linux/init.h> +-#include <linux/kernel.h> +-#include <linux/platform_device.h> +- +-#include <bcm63xx_cpu.h> +-#include <bcm63xx_dev_dsp.h> +-#include <bcm63xx_regs.h> +-#include <bcm63xx_io.h> +- +-static struct resource voip_dsp_resources[] = { +- { +- .start = -1, /* filled at runtime */ +- .end = -1, /* filled at runtime */ +- .flags = IORESOURCE_MEM, +- }, +- { +- .start = -1, /* filled at runtime */ +- .flags = IORESOURCE_IRQ, +- }, +-}; +- +-static struct platform_device bcm63xx_voip_dsp_device = { +- .name = "bcm63xx-voip-dsp", +- .id = -1, +- .num_resources = ARRAY_SIZE(voip_dsp_resources), +- .resource = voip_dsp_resources, +-}; +- +-int __init bcm63xx_dsp_register(const struct bcm63xx_dsp_platform_data *pd) +-{ +- struct bcm63xx_dsp_platform_data *dpd; +- u32 val; +- +- /* Get the memory window */ +- val = bcm_mpi_readl(MPI_CSBASE_REG(pd->cs - 1)); +- val &= MPI_CSBASE_BASE_MASK; +- voip_dsp_resources[0].start = val; +- voip_dsp_resources[0].end = val + 0xFFFFFFF; +- voip_dsp_resources[1].start = pd->ext_irq; +- +- /* copy given platform data */ +- dpd = bcm63xx_voip_dsp_device.dev.platform_data; +- memcpy(dpd, pd, sizeof (*pd)); +- +- return platform_device_register(&bcm63xx_voip_dsp_device); +-} +diff --git a/arch/mips/include/asm/io.h b/arch/mips/include/asm/io.h +index 57b34257be2b..98eb15b0524c 100644 +--- a/arch/mips/include/asm/io.h ++++ b/arch/mips/include/asm/io.h +@@ -60,21 +60,11 @@ + * instruction, so the lower 16 bits must be zero. Should be true on + * on any sane architecture; generic code does not use this assumption. + */ +-extern const unsigned long mips_io_port_base; ++extern unsigned long mips_io_port_base; + +-/* +- * Gcc will generate code to load the value of mips_io_port_base after each +- * function call which may be fairly wasteful in some cases. So we don't +- * play quite by the book. We tell gcc mips_io_port_base is a long variable +- * which solves the code generation issue. Now we need to violate the +- * aliasing rules a little to make initialization possible and finally we +- * will need the barrier() to fight side effects of the aliasing chat. +- * This trickery will eventually collapse under gcc's optimizer. Oh well. +- */ + static inline void set_io_port_base(unsigned long base) + { +- * (unsigned long *) &mips_io_port_base = base; +- barrier(); ++ mips_io_port_base = base; + } + + /* +diff --git a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_dsp.h b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_dsp.h +deleted file mode 100644 +index 4e4970787371..000000000000 +--- a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_dsp.h ++++ /dev/null +@@ -1,14 +0,0 @@ +-/* SPDX-License-Identifier: GPL-2.0 */ +-#ifndef __BCM63XX_DSP_H +-#define __BCM63XX_DSP_H +- +-struct bcm63xx_dsp_platform_data { +- unsigned gpio_rst; +- unsigned gpio_int; +- unsigned cs; +- unsigned ext_irq; +-}; +- +-int __init bcm63xx_dsp_register(const struct bcm63xx_dsp_platform_data *pd); +- +-#endif /* __BCM63XX_DSP_H */ +diff --git a/arch/mips/include/asm/mach-bcm63xx/board_bcm963xx.h b/arch/mips/include/asm/mach-bcm63xx/board_bcm963xx.h +index 5e5b1bc4a324..830f53f28e3f 100644 +--- a/arch/mips/include/asm/mach-bcm63xx/board_bcm963xx.h ++++ b/arch/mips/include/asm/mach-bcm63xx/board_bcm963xx.h +@@ -7,7 +7,6 @@ + #include <linux/leds.h> + #include <bcm63xx_dev_enet.h> + #include <bcm63xx_dev_usb_usbd.h> +-#include <bcm63xx_dev_dsp.h> + + /* + * flash mapping +@@ -31,7 +30,6 @@ struct board_info { + unsigned int has_ohci0:1; + unsigned int has_ehci0:1; + unsigned int has_usbd:1; +- unsigned int has_dsp:1; + unsigned int has_uart0:1; + unsigned int has_uart1:1; + +@@ -43,9 +41,6 @@ struct board_info { + /* USB config */ + struct bcm63xx_usbd_platform_data usbd; + +- /* DSP config */ +- struct bcm63xx_dsp_platform_data dsp; +- + /* GPIO LEDs */ + struct gpio_led leds[5]; + +diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c +index 795caa763da3..05ed4ed411c7 100644 +--- a/arch/mips/kernel/setup.c ++++ b/arch/mips/kernel/setup.c +@@ -75,7 +75,7 @@ static char __initdata builtin_cmdline[COMMAND_LINE_SIZE] = CONFIG_CMDLINE; + * mips_io_port_base is the begin of the address space to which x86 style + * I/O ports are mapped. + */ +-const unsigned long mips_io_port_base = -1; ++unsigned long mips_io_port_base = -1; + EXPORT_SYMBOL(mips_io_port_base); + + static struct resource code_resource = { .name = "Kernel code", }; +diff --git a/arch/nios2/kernel/nios2_ksyms.c b/arch/nios2/kernel/nios2_ksyms.c +index bf2f55d10a4d..4e704046a150 100644 +--- a/arch/nios2/kernel/nios2_ksyms.c ++++ b/arch/nios2/kernel/nios2_ksyms.c +@@ -9,12 +9,20 @@ + #include <linux/export.h> + #include <linux/string.h> + ++#include <asm/cacheflush.h> ++#include <asm/pgtable.h> ++ + /* string functions */ + + EXPORT_SYMBOL(memcpy); + EXPORT_SYMBOL(memset); + EXPORT_SYMBOL(memmove); + ++/* memory management */ ++ ++EXPORT_SYMBOL(empty_zero_page); ++EXPORT_SYMBOL(flush_icache_range); ++ + /* + * libgcc functions - functions that are used internally by the + * compiler... (prototypes are not correct though, but that +@@ -31,3 +39,7 @@ DECLARE_EXPORT(__udivsi3); + DECLARE_EXPORT(__umoddi3); + DECLARE_EXPORT(__umodsi3); + DECLARE_EXPORT(__muldi3); ++DECLARE_EXPORT(__ucmpdi2); ++DECLARE_EXPORT(__lshrdi3); ++DECLARE_EXPORT(__ashldi3); ++DECLARE_EXPORT(__ashrdi3); +diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile +index 0f04c878113e..9c78ef298257 100644 +--- a/arch/powerpc/Makefile ++++ b/arch/powerpc/Makefile +@@ -385,7 +385,9 @@ vdso_install: + ifeq ($(CONFIG_PPC64),y) + $(Q)$(MAKE) $(build)=arch/$(ARCH)/kernel/vdso64 $@ + endif ++ifdef CONFIG_VDSO32 + $(Q)$(MAKE) $(build)=arch/$(ARCH)/kernel/vdso32 $@ ++endif + + archclean: + $(Q)$(MAKE) $(clean)=$(boot) +diff --git a/arch/powerpc/include/asm/archrandom.h b/arch/powerpc/include/asm/archrandom.h +index 9c63b596e6ce..a09595f00cab 100644 +--- a/arch/powerpc/include/asm/archrandom.h ++++ b/arch/powerpc/include/asm/archrandom.h +@@ -28,7 +28,7 @@ static inline int arch_get_random_seed_int(unsigned int *v) + unsigned long val; + int rc; + +- rc = arch_get_random_long(&val); ++ rc = arch_get_random_seed_long(&val); + if (rc) + *v = val; + +diff --git a/arch/powerpc/kernel/cacheinfo.c b/arch/powerpc/kernel/cacheinfo.c +index a8f20e5928e1..9edb45430133 100644 +--- a/arch/powerpc/kernel/cacheinfo.c ++++ b/arch/powerpc/kernel/cacheinfo.c +@@ -865,4 +865,25 @@ void cacheinfo_cpu_offline(unsigned int cpu_id) + if (cache) + cache_cpu_clear(cache, cpu_id); + } ++ ++void cacheinfo_teardown(void) ++{ ++ unsigned int cpu; ++ ++ lockdep_assert_cpus_held(); ++ ++ for_each_online_cpu(cpu) ++ cacheinfo_cpu_offline(cpu); ++} ++ ++void cacheinfo_rebuild(void) ++{ ++ unsigned int cpu; ++ ++ lockdep_assert_cpus_held(); ++ ++ for_each_online_cpu(cpu) ++ cacheinfo_cpu_online(cpu); ++} ++ + #endif /* (CONFIG_PPC_PSERIES && CONFIG_SUSPEND) || CONFIG_HOTPLUG_CPU */ +diff --git a/arch/powerpc/kernel/cacheinfo.h b/arch/powerpc/kernel/cacheinfo.h +index 955f5e999f1b..52bd3fc6642d 100644 +--- a/arch/powerpc/kernel/cacheinfo.h ++++ b/arch/powerpc/kernel/cacheinfo.h +@@ -6,4 +6,8 @@ + extern void cacheinfo_cpu_online(unsigned int cpu_id); + extern void cacheinfo_cpu_offline(unsigned int cpu_id); + ++/* Allow migration/suspend to tear down and rebuild the hierarchy. */ ++extern void cacheinfo_teardown(void); ++extern void cacheinfo_rebuild(void); ++ + #endif /* _PPC_CACHEINFO_H */ +diff --git a/arch/powerpc/kernel/dt_cpu_ftrs.c b/arch/powerpc/kernel/dt_cpu_ftrs.c +index 2357df60de95..7ed2b1b6643c 100644 +--- a/arch/powerpc/kernel/dt_cpu_ftrs.c ++++ b/arch/powerpc/kernel/dt_cpu_ftrs.c +@@ -705,8 +705,10 @@ static bool __init cpufeatures_process_feature(struct dt_cpu_feature *f) + m = &dt_cpu_feature_match_table[i]; + if (!strcmp(f->name, m->name)) { + known = true; +- if (m->enable(f)) ++ if (m->enable(f)) { ++ cur_cpu_spec->cpu_features |= m->cpu_ftr_bit_mask; + break; ++ } + + pr_info("not enabling: %s (disabled or unsupported by kernel)\n", + f->name); +@@ -714,17 +716,12 @@ static bool __init cpufeatures_process_feature(struct dt_cpu_feature *f) + } + } + +- if (!known && enable_unknown) { +- if (!feat_try_enable_unknown(f)) { +- pr_info("not enabling: %s (unknown and unsupported by kernel)\n", +- f->name); +- return false; +- } ++ if (!known && (!enable_unknown || !feat_try_enable_unknown(f))) { ++ pr_info("not enabling: %s (unknown and unsupported by kernel)\n", ++ f->name); ++ return false; + } + +- if (m->cpu_ftr_bit_mask) +- cur_cpu_spec->cpu_features |= m->cpu_ftr_bit_mask; +- + if (known) + pr_debug("enabling: %s\n", f->name); + else +diff --git a/arch/powerpc/kvm/book3s_64_vio.c b/arch/powerpc/kvm/book3s_64_vio.c +index 5e4446296021..ef6a58838e7c 100644 +--- a/arch/powerpc/kvm/book3s_64_vio.c ++++ b/arch/powerpc/kvm/book3s_64_vio.c +@@ -134,7 +134,6 @@ extern void kvm_spapr_tce_release_iommu_group(struct kvm *kvm, + continue; + + kref_put(&stit->kref, kvm_spapr_tce_liobn_put); +- return; + } + } + } +diff --git a/arch/powerpc/mm/dump_hashpagetable.c b/arch/powerpc/mm/dump_hashpagetable.c +index 5c4c93dcff19..f666d74f05f5 100644 +--- a/arch/powerpc/mm/dump_hashpagetable.c ++++ b/arch/powerpc/mm/dump_hashpagetable.c +@@ -343,7 +343,7 @@ static unsigned long hpte_find(struct pg_state *st, unsigned long ea, int psize) + + /* Look in secondary table */ + if (slot == -1) +- slot = base_hpte_find(ea, psize, true, &v, &r); ++ slot = base_hpte_find(ea, psize, false, &v, &r); + + /* No entry found */ + if (slot == -1) +diff --git a/arch/powerpc/platforms/pseries/mobility.c b/arch/powerpc/platforms/pseries/mobility.c +index 9739a055e5f7..2d3668acb6ef 100644 +--- a/arch/powerpc/platforms/pseries/mobility.c ++++ b/arch/powerpc/platforms/pseries/mobility.c +@@ -23,6 +23,7 @@ + #include <asm/machdep.h> + #include <asm/rtas.h> + #include "pseries.h" ++#include "../../kernel/cacheinfo.h" + + static struct kobject *mobility_kobj; + +@@ -359,11 +360,20 @@ void post_mobility_fixup(void) + */ + cpus_read_lock(); + ++ /* ++ * It's common for the destination firmware to replace cache ++ * nodes. Release all of the cacheinfo hierarchy's references ++ * before updating the device tree. ++ */ ++ cacheinfo_teardown(); ++ + rc = pseries_devicetree_update(MIGRATION_SCOPE); + if (rc) + printk(KERN_ERR "Post-mobility device tree update " + "failed: %d\n", rc); + ++ cacheinfo_rebuild(); ++ + cpus_read_unlock(); + + /* Possibly switch to a new RFI flush type */ +diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug +index 6293a8768a91..bec0952c5595 100644 +--- a/arch/x86/Kconfig.debug ++++ b/arch/x86/Kconfig.debug +@@ -189,7 +189,7 @@ config HAVE_MMIOTRACE_SUPPORT + + config X86_DECODER_SELFTEST + bool "x86 instruction decoder selftest" +- depends on DEBUG_KERNEL && KPROBES ++ depends on DEBUG_KERNEL && INSTRUCTION_DECODER + depends on !COMPILE_TEST + ---help--- + Perform x86 instruction decoder selftests at build time. +diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c +index 8e36f249646e..904e18bb38c5 100644 +--- a/arch/x86/kernel/kgdb.c ++++ b/arch/x86/kernel/kgdb.c +@@ -438,7 +438,7 @@ static void kgdb_disable_hw_debug(struct pt_regs *regs) + */ + void kgdb_roundup_cpus(unsigned long flags) + { +- apic->send_IPI_allbutself(APIC_DM_NMI); ++ apic->send_IPI_allbutself(NMI_VECTOR); + } + #endif + +diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c +index 5400a24e1a8c..c5d7b4ae17ca 100644 +--- a/arch/x86/mm/tlb.c ++++ b/arch/x86/mm/tlb.c +@@ -651,9 +651,6 @@ void native_flush_tlb_others(const struct cpumask *cpumask, + * that UV should be updated so that smp_call_function_many(), + * etc, are optimal on UV. + */ +- unsigned int cpu; +- +- cpu = smp_processor_id(); + cpumask = uv_flush_tlb_others(cpumask, info); + if (cpumask) + smp_call_function_many(cpumask, flush_tlb_func_remote, +diff --git a/block/blk-merge.c b/block/blk-merge.c +index f61b50a01bc7..415b5dafd9e6 100644 +--- a/block/blk-merge.c ++++ b/block/blk-merge.c +@@ -299,13 +299,7 @@ void blk_recalc_rq_segments(struct request *rq) + + void blk_recount_segments(struct request_queue *q, struct bio *bio) + { +- unsigned short seg_cnt; +- +- /* estimate segment number by bi_vcnt for non-cloned bio */ +- if (bio_flagged(bio, BIO_CLONED)) +- seg_cnt = bio_segments(bio); +- else +- seg_cnt = bio->bi_vcnt; ++ unsigned short seg_cnt = bio_segments(bio); + + if (test_bit(QUEUE_FLAG_NO_SG_MERGE, &q->queue_flags) && + (seg_cnt < queue_max_segments(q))) +diff --git a/crypto/pcrypt.c b/crypto/pcrypt.c +index f8ec3d4ba4a8..a5718c0a3dc4 100644 +--- a/crypto/pcrypt.c ++++ b/crypto/pcrypt.c +@@ -394,7 +394,7 @@ static int pcrypt_sysfs_add(struct padata_instance *pinst, const char *name) + int ret; + + pinst->kobj.kset = pcrypt_kset; +- ret = kobject_add(&pinst->kobj, NULL, name); ++ ret = kobject_add(&pinst->kobj, NULL, "%s", name); + if (!ret) + kobject_uevent(&pinst->kobj, KOBJ_ADD); + +diff --git a/crypto/tgr192.c b/crypto/tgr192.c +index 321bc6ff2a9d..904c8444aa0a 100644 +--- a/crypto/tgr192.c ++++ b/crypto/tgr192.c +@@ -25,8 +25,9 @@ + #include <linux/init.h> + #include <linux/module.h> + #include <linux/mm.h> +-#include <asm/byteorder.h> + #include <linux/types.h> ++#include <asm/byteorder.h> ++#include <asm/unaligned.h> + + #define TGR192_DIGEST_SIZE 24 + #define TGR160_DIGEST_SIZE 20 +@@ -468,10 +469,9 @@ static void tgr192_transform(struct tgr192_ctx *tctx, const u8 * data) + u64 a, b, c, aa, bb, cc; + u64 x[8]; + int i; +- const __le64 *ptr = (const __le64 *)data; + + for (i = 0; i < 8; i++) +- x[i] = le64_to_cpu(ptr[i]); ++ x[i] = get_unaligned_le64(data + i * sizeof(__le64)); + + /* save */ + a = aa = tctx->a; +diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c +index cda9a0b5bdaa..7473ff46de66 100644 +--- a/drivers/ata/libahci.c ++++ b/drivers/ata/libahci.c +@@ -191,7 +191,6 @@ struct ata_port_operations ahci_pmp_retry_srst_ops = { + EXPORT_SYMBOL_GPL(ahci_pmp_retry_srst_ops); + + static bool ahci_em_messages __read_mostly = true; +-EXPORT_SYMBOL_GPL(ahci_em_messages); + module_param(ahci_em_messages, bool, 0444); + /* add other LED protocol types when they become supported */ + MODULE_PARM_DESC(ahci_em_messages, +diff --git a/drivers/base/core.c b/drivers/base/core.c +index 2b0a1054535c..93c2fc58013e 100644 +--- a/drivers/base/core.c ++++ b/drivers/base/core.c +@@ -180,11 +180,20 @@ struct device_link *device_link_add(struct device *consumer, + struct device *supplier, u32 flags) + { + struct device_link *link; ++ bool rpm_put_supplier = false; + + if (!consumer || !supplier || + ((flags & DL_FLAG_STATELESS) && (flags & DL_FLAG_AUTOREMOVE))) + return NULL; + ++ if (flags & DL_FLAG_PM_RUNTIME && flags & DL_FLAG_RPM_ACTIVE) { ++ if (pm_runtime_get_sync(supplier) < 0) { ++ pm_runtime_put_noidle(supplier); ++ return NULL; ++ } ++ rpm_put_supplier = true; ++ } ++ + device_links_write_lock(); + device_pm_lock(); + +@@ -209,13 +218,8 @@ struct device_link *device_link_add(struct device *consumer, + + if (flags & DL_FLAG_PM_RUNTIME) { + if (flags & DL_FLAG_RPM_ACTIVE) { +- if (pm_runtime_get_sync(supplier) < 0) { +- pm_runtime_put_noidle(supplier); +- kfree(link); +- link = NULL; +- goto out; +- } + link->rpm_active = true; ++ rpm_put_supplier = false; + } + pm_runtime_new_link(consumer); + /* +@@ -286,6 +290,10 @@ struct device_link *device_link_add(struct device *consumer, + out: + device_pm_unlock(); + device_links_write_unlock(); ++ ++ if (rpm_put_supplier) ++ pm_runtime_put(supplier); ++ + return link; + } + EXPORT_SYMBOL_GPL(device_link_add); +diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c +index df53e2b3296b..877b2a1767a5 100644 +--- a/drivers/base/power/wakeup.c ++++ b/drivers/base/power/wakeup.c +@@ -877,7 +877,7 @@ EXPORT_SYMBOL_GPL(pm_system_wakeup); + + void pm_system_cancel_wakeup(void) + { +- atomic_dec(&pm_abort_suspend); ++ atomic_dec_if_positive(&pm_abort_suspend); + } + + void pm_wakeup_clear(bool reset) +diff --git a/drivers/bcma/driver_pci.c b/drivers/bcma/driver_pci.c +index f499a469e66d..12b2cc9a3fbe 100644 +--- a/drivers/bcma/driver_pci.c ++++ b/drivers/bcma/driver_pci.c +@@ -78,7 +78,7 @@ static u16 bcma_pcie_mdio_read(struct bcma_drv_pci *pc, u16 device, u8 address) + v |= (address << BCMA_CORE_PCI_MDIODATA_REGADDR_SHF_OLD); + } + +- v = BCMA_CORE_PCI_MDIODATA_START; ++ v |= BCMA_CORE_PCI_MDIODATA_START; + v |= BCMA_CORE_PCI_MDIODATA_READ; + v |= BCMA_CORE_PCI_MDIODATA_TA; + +@@ -121,7 +121,7 @@ static void bcma_pcie_mdio_write(struct bcma_drv_pci *pc, u16 device, + v |= (address << BCMA_CORE_PCI_MDIODATA_REGADDR_SHF_OLD); + } + +- v = BCMA_CORE_PCI_MDIODATA_START; ++ v |= BCMA_CORE_PCI_MDIODATA_START; + v |= BCMA_CORE_PCI_MDIODATA_WRITE; + v |= BCMA_CORE_PCI_MDIODATA_TA; + v |= data; +diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c +index 7ea13b5497fd..b998e3abca7a 100644 +--- a/drivers/block/drbd/drbd_main.c ++++ b/drivers/block/drbd/drbd_main.c +@@ -334,6 +334,8 @@ static int drbd_thread_setup(void *arg) + thi->name[0], + resource->name); + ++ allow_kernel_signal(DRBD_SIGKILL); ++ allow_kernel_signal(SIGXCPU); + restart: + retval = thi->function(thi); + +diff --git a/drivers/clk/clk-highbank.c b/drivers/clk/clk-highbank.c +index 727ed8e1bb72..8e4581004695 100644 +--- a/drivers/clk/clk-highbank.c ++++ b/drivers/clk/clk-highbank.c +@@ -293,6 +293,7 @@ static __init struct clk *hb_clk_init(struct device_node *node, const struct clk + /* Map system registers */ + srnp = of_find_compatible_node(NULL, NULL, "calxeda,hb-sregs"); + hb_clk->reg = of_iomap(srnp, 0); ++ of_node_put(srnp); + BUG_ON(!hb_clk->reg); + hb_clk->reg += reg; + +diff --git a/drivers/clk/clk-qoriq.c b/drivers/clk/clk-qoriq.c +index 1a292519d84f..999a90a16609 100644 +--- a/drivers/clk/clk-qoriq.c ++++ b/drivers/clk/clk-qoriq.c +@@ -1382,6 +1382,7 @@ static void __init clockgen_init(struct device_node *np) + pr_err("%s: Couldn't map %pOF regs\n", __func__, + guts); + } ++ of_node_put(guts); + } + + } +diff --git a/drivers/clk/imx/clk-imx6q.c b/drivers/clk/imx/clk-imx6q.c +index 8eb93eb2f857..e0547654cb7b 100644 +--- a/drivers/clk/imx/clk-imx6q.c ++++ b/drivers/clk/imx/clk-imx6q.c +@@ -431,6 +431,7 @@ static void __init imx6q_clocks_init(struct device_node *ccm_node) + np = of_find_compatible_node(NULL, NULL, "fsl,imx6q-anatop"); + anatop_base = base = of_iomap(np, 0); + WARN_ON(!base); ++ of_node_put(np); + + /* Audio/video PLL post dividers do not work on i.MX6q revision 1.0 */ + if (clk_on_imx6q() && imx_get_soc_revision() == IMX_CHIP_REVISION_1_0) { +diff --git a/drivers/clk/imx/clk-imx6sx.c b/drivers/clk/imx/clk-imx6sx.c +index e6d389e333d7..baa07553a0dd 100644 +--- a/drivers/clk/imx/clk-imx6sx.c ++++ b/drivers/clk/imx/clk-imx6sx.c +@@ -164,6 +164,7 @@ static void __init imx6sx_clocks_init(struct device_node *ccm_node) + np = of_find_compatible_node(NULL, NULL, "fsl,imx6sx-anatop"); + base = of_iomap(np, 0); + WARN_ON(!base); ++ of_node_put(np); + + clks[IMX6SX_PLL1_BYPASS_SRC] = imx_clk_mux("pll1_bypass_src", base + 0x00, 14, 1, pll_bypass_src_sels, ARRAY_SIZE(pll_bypass_src_sels)); + clks[IMX6SX_PLL2_BYPASS_SRC] = imx_clk_mux("pll2_bypass_src", base + 0x30, 14, 1, pll_bypass_src_sels, ARRAY_SIZE(pll_bypass_src_sels)); +diff --git a/drivers/clk/imx/clk-imx7d.c b/drivers/clk/imx/clk-imx7d.c +index 0ac9b30c8b90..9f5e5b9d4a25 100644 +--- a/drivers/clk/imx/clk-imx7d.c ++++ b/drivers/clk/imx/clk-imx7d.c +@@ -416,6 +416,7 @@ static void __init imx7d_clocks_init(struct device_node *ccm_node) + np = of_find_compatible_node(NULL, NULL, "fsl,imx7d-anatop"); + base = of_iomap(np, 0); + WARN_ON(!base); ++ of_node_put(np); + + clks[IMX7D_PLL_ARM_MAIN_SRC] = imx_clk_mux("pll_arm_main_src", base + 0x60, 14, 2, pll_bypass_src_sel, ARRAY_SIZE(pll_bypass_src_sel)); + clks[IMX7D_PLL_DRAM_MAIN_SRC] = imx_clk_mux("pll_dram_main_src", base + 0x70, 14, 2, pll_bypass_src_sel, ARRAY_SIZE(pll_bypass_src_sel)); +diff --git a/drivers/clk/imx/clk-vf610.c b/drivers/clk/imx/clk-vf610.c +index 6dae54325a91..a334667c450a 100644 +--- a/drivers/clk/imx/clk-vf610.c ++++ b/drivers/clk/imx/clk-vf610.c +@@ -203,6 +203,7 @@ static void __init vf610_clocks_init(struct device_node *ccm_node) + np = of_find_compatible_node(NULL, NULL, "fsl,vf610-anatop"); + anatop_base = of_iomap(np, 0); + BUG_ON(!anatop_base); ++ of_node_put(np); + + np = ccm_node; + ccm_base = of_iomap(np, 0); +diff --git a/drivers/clk/mvebu/armada-370.c b/drivers/clk/mvebu/armada-370.c +index 2c7c1085f883..8fdfa97900cd 100644 +--- a/drivers/clk/mvebu/armada-370.c ++++ b/drivers/clk/mvebu/armada-370.c +@@ -177,8 +177,10 @@ static void __init a370_clk_init(struct device_node *np) + + mvebu_coreclk_setup(np, &a370_coreclks); + +- if (cgnp) ++ if (cgnp) { + mvebu_clk_gating_setup(cgnp, a370_gating_desc); ++ of_node_put(cgnp); ++ } + } + CLK_OF_DECLARE(a370_clk, "marvell,armada-370-core-clock", a370_clk_init); + +diff --git a/drivers/clk/mvebu/armada-xp.c b/drivers/clk/mvebu/armada-xp.c +index 0ec44ae9a2a2..df529982adc9 100644 +--- a/drivers/clk/mvebu/armada-xp.c ++++ b/drivers/clk/mvebu/armada-xp.c +@@ -228,7 +228,9 @@ static void __init axp_clk_init(struct device_node *np) + + mvebu_coreclk_setup(np, &axp_coreclks); + +- if (cgnp) ++ if (cgnp) { + mvebu_clk_gating_setup(cgnp, axp_gating_desc); ++ of_node_put(cgnp); ++ } + } + CLK_OF_DECLARE(axp_clk, "marvell,armada-xp-core-clock", axp_clk_init); +diff --git a/drivers/clk/mvebu/dove.c b/drivers/clk/mvebu/dove.c +index 59fad9546c84..5f258c9bb68b 100644 +--- a/drivers/clk/mvebu/dove.c ++++ b/drivers/clk/mvebu/dove.c +@@ -190,10 +190,14 @@ static void __init dove_clk_init(struct device_node *np) + + mvebu_coreclk_setup(np, &dove_coreclks); + +- if (ddnp) ++ if (ddnp) { + dove_divider_clk_init(ddnp); ++ of_node_put(ddnp); ++ } + +- if (cgnp) ++ if (cgnp) { + mvebu_clk_gating_setup(cgnp, dove_gating_desc); ++ of_node_put(cgnp); ++ } + } + CLK_OF_DECLARE(dove_clk, "marvell,dove-core-clock", dove_clk_init); +diff --git a/drivers/clk/mvebu/kirkwood.c b/drivers/clk/mvebu/kirkwood.c +index a2a8d614039d..890ebf623261 100644 +--- a/drivers/clk/mvebu/kirkwood.c ++++ b/drivers/clk/mvebu/kirkwood.c +@@ -333,6 +333,8 @@ static void __init kirkwood_clk_init(struct device_node *np) + if (cgnp) { + mvebu_clk_gating_setup(cgnp, kirkwood_gating_desc); + kirkwood_clk_muxing_setup(cgnp, kirkwood_mux_desc); ++ ++ of_node_put(cgnp); + } + } + CLK_OF_DECLARE(kirkwood_clk, "marvell,kirkwood-core-clock", +diff --git a/drivers/clk/mvebu/mv98dx3236.c b/drivers/clk/mvebu/mv98dx3236.c +index 6e203af73cac..c8a0d03d2cd6 100644 +--- a/drivers/clk/mvebu/mv98dx3236.c ++++ b/drivers/clk/mvebu/mv98dx3236.c +@@ -174,7 +174,9 @@ static void __init mv98dx3236_clk_init(struct device_node *np) + + mvebu_coreclk_setup(np, &mv98dx3236_core_clocks); + +- if (cgnp) ++ if (cgnp) { + mvebu_clk_gating_setup(cgnp, mv98dx3236_gating_desc); ++ of_node_put(cgnp); ++ } + } + CLK_OF_DECLARE(mv98dx3236_clk, "marvell,mv98dx3236-core-clock", mv98dx3236_clk_init); +diff --git a/drivers/clk/qcom/gcc-msm8996.c b/drivers/clk/qcom/gcc-msm8996.c +index 7ddec886fcd3..c0b043b1bd24 100644 +--- a/drivers/clk/qcom/gcc-msm8996.c ++++ b/drivers/clk/qcom/gcc-msm8996.c +@@ -140,22 +140,6 @@ static const char * const gcc_xo_gpll0_gpll4_gpll0_early_div[] = { + "gpll0_early_div" + }; + +-static const struct parent_map gcc_xo_gpll0_gpll2_gpll3_gpll0_early_div_map[] = { +- { P_XO, 0 }, +- { P_GPLL0, 1 }, +- { P_GPLL2, 2 }, +- { P_GPLL3, 3 }, +- { P_GPLL0_EARLY_DIV, 6 } +-}; +- +-static const char * const gcc_xo_gpll0_gpll2_gpll3_gpll0_early_div[] = { +- "xo", +- "gpll0", +- "gpll2", +- "gpll3", +- "gpll0_early_div" +-}; +- + static const struct parent_map gcc_xo_gpll0_gpll1_early_div_gpll1_gpll4_gpll0_early_div_map[] = { + { P_XO, 0 }, + { P_GPLL0, 1 }, +@@ -194,26 +178,6 @@ static const char * const gcc_xo_gpll0_gpll2_gpll3_gpll1_gpll2_early_gpll0_early + "gpll0_early_div" + }; + +-static const struct parent_map gcc_xo_gpll0_gpll2_gpll3_gpll1_gpll4_gpll0_early_div_map[] = { +- { P_XO, 0 }, +- { P_GPLL0, 1 }, +- { P_GPLL2, 2 }, +- { P_GPLL3, 3 }, +- { P_GPLL1, 4 }, +- { P_GPLL4, 5 }, +- { P_GPLL0_EARLY_DIV, 6 } +-}; +- +-static const char * const gcc_xo_gpll0_gpll2_gpll3_gpll1_gpll4_gpll0_early_div[] = { +- "xo", +- "gpll0", +- "gpll2", +- "gpll3", +- "gpll1", +- "gpll4", +- "gpll0_early_div" +-}; +- + static struct clk_fixed_factor xo = { + .mult = 1, + .div = 1, +diff --git a/drivers/clk/samsung/clk-exynos4.c b/drivers/clk/samsung/clk-exynos4.c +index d8d3cb67b402..3d3026221927 100644 +--- a/drivers/clk/samsung/clk-exynos4.c ++++ b/drivers/clk/samsung/clk-exynos4.c +@@ -1240,6 +1240,7 @@ static unsigned long __init exynos4_get_xom(void) + xom = readl(chipid_base + 8); + + iounmap(chipid_base); ++ of_node_put(np); + } + + return xom; +diff --git a/drivers/clk/socfpga/clk-pll-a10.c b/drivers/clk/socfpga/clk-pll-a10.c +index 35fabe1a32c3..269467e8e07e 100644 +--- a/drivers/clk/socfpga/clk-pll-a10.c ++++ b/drivers/clk/socfpga/clk-pll-a10.c +@@ -95,6 +95,7 @@ static struct clk * __init __socfpga_pll_init(struct device_node *node, + + clkmgr_np = of_find_compatible_node(NULL, NULL, "altr,clk-mgr"); + clk_mgr_a10_base_addr = of_iomap(clkmgr_np, 0); ++ of_node_put(clkmgr_np); + BUG_ON(!clk_mgr_a10_base_addr); + pll_clk->hw.reg = clk_mgr_a10_base_addr + reg; + +diff --git a/drivers/clk/socfpga/clk-pll.c b/drivers/clk/socfpga/clk-pll.c +index c7f463172e4b..b4b44e9b5901 100644 +--- a/drivers/clk/socfpga/clk-pll.c ++++ b/drivers/clk/socfpga/clk-pll.c +@@ -100,6 +100,7 @@ static __init struct clk *__socfpga_pll_init(struct device_node *node, + + clkmgr_np = of_find_compatible_node(NULL, NULL, "altr,clk-mgr"); + clk_mgr_base_addr = of_iomap(clkmgr_np, 0); ++ of_node_put(clkmgr_np); + BUG_ON(!clk_mgr_base_addr); + pll_clk->hw.reg = clk_mgr_base_addr + reg; + +diff --git a/drivers/clk/sunxi-ng/ccu-sun8i-a23.c b/drivers/clk/sunxi-ng/ccu-sun8i-a23.c +index d93b452f0df9..1cef040ebe82 100644 +--- a/drivers/clk/sunxi-ng/ccu-sun8i-a23.c ++++ b/drivers/clk/sunxi-ng/ccu-sun8i-a23.c +@@ -132,7 +132,7 @@ static SUNXI_CCU_NKM_WITH_GATE_LOCK(pll_mipi_clk, "pll-mipi", + 8, 4, /* N */ + 4, 2, /* K */ + 0, 4, /* M */ +- BIT(31), /* gate */ ++ BIT(31) | BIT(23) | BIT(22), /* gate */ + BIT(28), /* lock */ + CLK_SET_RATE_UNGATE); + +diff --git a/drivers/clk/sunxi-ng/ccu-sun8i-v3s.c b/drivers/clk/sunxi-ng/ccu-sun8i-v3s.c +index 9e3f4088724b..c7f9d974b10d 100644 +--- a/drivers/clk/sunxi-ng/ccu-sun8i-v3s.c ++++ b/drivers/clk/sunxi-ng/ccu-sun8i-v3s.c +@@ -84,7 +84,7 @@ static SUNXI_CCU_NM_WITH_FRAC_GATE_LOCK(pll_ve_clk, "pll-ve", + BIT(28), /* lock */ + 0); + +-static SUNXI_CCU_NKM_WITH_GATE_LOCK(pll_ddr_clk, "pll-ddr", ++static SUNXI_CCU_NKM_WITH_GATE_LOCK(pll_ddr0_clk, "pll-ddr0", + "osc24M", 0x020, + 8, 5, /* N */ + 4, 2, /* K */ +@@ -123,6 +123,14 @@ static SUNXI_CCU_NK_WITH_GATE_LOCK_POSTDIV(pll_periph1_clk, "pll-periph1", + 2, /* post-div */ + 0); + ++static SUNXI_CCU_NM_WITH_GATE_LOCK(pll_ddr1_clk, "pll-ddr1", ++ "osc24M", 0x04c, ++ 8, 7, /* N */ ++ 0, 2, /* M */ ++ BIT(31), /* gate */ ++ BIT(28), /* lock */ ++ 0); ++ + static const char * const cpu_parents[] = { "osc32k", "osc24M", + "pll-cpu", "pll-cpu" }; + static SUNXI_CCU_MUX(cpu_clk, "cpu", cpu_parents, +@@ -310,7 +318,8 @@ static SUNXI_CCU_GATE(usb_phy0_clk, "usb-phy0", "osc24M", + static SUNXI_CCU_GATE(usb_ohci0_clk, "usb-ohci0", "osc24M", + 0x0cc, BIT(16), 0); + +-static const char * const dram_parents[] = { "pll-ddr", "pll-periph0-2x" }; ++static const char * const dram_parents[] = { "pll-ddr0", "pll-ddr1", ++ "pll-periph0-2x" }; + static SUNXI_CCU_M_WITH_MUX(dram_clk, "dram", dram_parents, + 0x0f4, 0, 4, 20, 2, CLK_IS_CRITICAL); + +@@ -369,10 +378,11 @@ static struct ccu_common *sun8i_v3s_ccu_clks[] = { + &pll_audio_base_clk.common, + &pll_video_clk.common, + &pll_ve_clk.common, +- &pll_ddr_clk.common, ++ &pll_ddr0_clk.common, + &pll_periph0_clk.common, + &pll_isp_clk.common, + &pll_periph1_clk.common, ++ &pll_ddr1_clk.common, + &cpu_clk.common, + &axi_clk.common, + &ahb1_clk.common, +@@ -457,11 +467,12 @@ static struct clk_hw_onecell_data sun8i_v3s_hw_clks = { + [CLK_PLL_AUDIO_8X] = &pll_audio_8x_clk.hw, + [CLK_PLL_VIDEO] = &pll_video_clk.common.hw, + [CLK_PLL_VE] = &pll_ve_clk.common.hw, +- [CLK_PLL_DDR] = &pll_ddr_clk.common.hw, ++ [CLK_PLL_DDR0] = &pll_ddr0_clk.common.hw, + [CLK_PLL_PERIPH0] = &pll_periph0_clk.common.hw, + [CLK_PLL_PERIPH0_2X] = &pll_periph0_2x_clk.hw, + [CLK_PLL_ISP] = &pll_isp_clk.common.hw, + [CLK_PLL_PERIPH1] = &pll_periph1_clk.common.hw, ++ [CLK_PLL_DDR1] = &pll_ddr1_clk.common.hw, + [CLK_CPU] = &cpu_clk.common.hw, + [CLK_AXI] = &axi_clk.common.hw, + [CLK_AHB1] = &ahb1_clk.common.hw, +diff --git a/drivers/clk/sunxi-ng/ccu-sun8i-v3s.h b/drivers/clk/sunxi-ng/ccu-sun8i-v3s.h +index 4a4d36fdad96..a091b7217dfd 100644 +--- a/drivers/clk/sunxi-ng/ccu-sun8i-v3s.h ++++ b/drivers/clk/sunxi-ng/ccu-sun8i-v3s.h +@@ -29,7 +29,7 @@ + #define CLK_PLL_AUDIO_8X 5 + #define CLK_PLL_VIDEO 6 + #define CLK_PLL_VE 7 +-#define CLK_PLL_DDR 8 ++#define CLK_PLL_DDR0 8 + #define CLK_PLL_PERIPH0 9 + #define CLK_PLL_PERIPH0_2X 10 + #define CLK_PLL_ISP 11 +@@ -58,6 +58,8 @@ + + /* And the GPU module clock is exported */ + +-#define CLK_NUMBER (CLK_MIPI_CSI + 1) ++#define CLK_PLL_DDR1 74 ++ ++#define CLK_NUMBER (CLK_PLL_DDR1 + 1) + + #endif /* _CCU_SUN8I_H3_H_ */ +diff --git a/drivers/clocksource/exynos_mct.c b/drivers/clocksource/exynos_mct.c +index aaf5bfa9bd9c..e3ae041ac30e 100644 +--- a/drivers/clocksource/exynos_mct.c ++++ b/drivers/clocksource/exynos_mct.c +@@ -563,7 +563,19 @@ static int __init exynos4_timer_resources(struct device_node *np, void __iomem * + return 0; + + out_irq: +- free_percpu_irq(mct_irqs[MCT_L0_IRQ], &percpu_mct_tick); ++ if (mct_int_type == MCT_INT_PPI) { ++ free_percpu_irq(mct_irqs[MCT_L0_IRQ], &percpu_mct_tick); ++ } else { ++ for_each_possible_cpu(cpu) { ++ struct mct_clock_event_device *pcpu_mevt = ++ per_cpu_ptr(&percpu_mct_tick, cpu); ++ ++ if (pcpu_mevt->evt.irq != -1) { ++ free_irq(pcpu_mevt->evt.irq, pcpu_mevt); ++ pcpu_mevt->evt.irq = -1; ++ } ++ } ++ } + return err; + } + +diff --git a/drivers/clocksource/timer-sun5i.c b/drivers/clocksource/timer-sun5i.c +index 2a3fe83ec337..6f4a9a8faccc 100644 +--- a/drivers/clocksource/timer-sun5i.c ++++ b/drivers/clocksource/timer-sun5i.c +@@ -202,6 +202,11 @@ static int __init sun5i_setup_clocksource(struct device_node *node, + } + + rate = clk_get_rate(clk); ++ if (!rate) { ++ pr_err("Couldn't get parent clock rate\n"); ++ ret = -EINVAL; ++ goto err_disable_clk; ++ } + + cs->timer.base = base; + cs->timer.clk = clk; +@@ -275,6 +280,11 @@ static int __init sun5i_setup_clockevent(struct device_node *node, void __iomem + } + + rate = clk_get_rate(clk); ++ if (!rate) { ++ pr_err("Couldn't get parent clock rate\n"); ++ ret = -EINVAL; ++ goto err_disable_clk; ++ } + + ce->timer.base = base; + ce->timer.ticks_per_jiffy = DIV_ROUND_UP(rate, HZ); +diff --git a/drivers/cpufreq/brcmstb-avs-cpufreq.c b/drivers/cpufreq/brcmstb-avs-cpufreq.c +index 7281a2c19c36..39c462711eae 100644 +--- a/drivers/cpufreq/brcmstb-avs-cpufreq.c ++++ b/drivers/cpufreq/brcmstb-avs-cpufreq.c +@@ -468,12 +468,12 @@ static int brcm_avs_set_pstate(struct private_data *priv, unsigned int pstate) + return __issue_avs_command(priv, AVS_CMD_SET_PSTATE, true, args); + } + +-static unsigned long brcm_avs_get_voltage(void __iomem *base) ++static u32 brcm_avs_get_voltage(void __iomem *base) + { + return readl(base + AVS_MBOX_VOLTAGE1); + } + +-static unsigned long brcm_avs_get_frequency(void __iomem *base) ++static u32 brcm_avs_get_frequency(void __iomem *base) + { + return readl(base + AVS_MBOX_FREQUENCY) * 1000; /* in kHz */ + } +@@ -762,8 +762,8 @@ static bool brcm_avs_is_firmware_loaded(struct private_data *priv) + rc = brcm_avs_get_pmap(priv, NULL); + magic = readl(priv->base + AVS_MBOX_MAGIC); + +- return (magic == AVS_FIRMWARE_MAGIC) && (rc != -ENOTSUPP) && +- (rc != -EINVAL); ++ return (magic == AVS_FIRMWARE_MAGIC) && ((rc != -ENOTSUPP) || ++ (rc != -EINVAL)); + } + + static unsigned int brcm_avs_cpufreq_get(unsigned int cpu) +@@ -973,14 +973,14 @@ static ssize_t show_brcm_avs_voltage(struct cpufreq_policy *policy, char *buf) + { + struct private_data *priv = policy->driver_data; + +- return sprintf(buf, "0x%08lx\n", brcm_avs_get_voltage(priv->base)); ++ return sprintf(buf, "0x%08x\n", brcm_avs_get_voltage(priv->base)); + } + + static ssize_t show_brcm_avs_frequency(struct cpufreq_policy *policy, char *buf) + { + struct private_data *priv = policy->driver_data; + +- return sprintf(buf, "0x%08lx\n", brcm_avs_get_frequency(priv->base)); ++ return sprintf(buf, "0x%08x\n", brcm_avs_get_frequency(priv->base)); + } + + cpufreq_freq_attr_ro(brcm_avs_pstate); +diff --git a/drivers/crypto/amcc/crypto4xx_trng.h b/drivers/crypto/amcc/crypto4xx_trng.h +index 931d22531f51..7bbda51b7337 100644 +--- a/drivers/crypto/amcc/crypto4xx_trng.h ++++ b/drivers/crypto/amcc/crypto4xx_trng.h +@@ -26,9 +26,9 @@ void ppc4xx_trng_probe(struct crypto4xx_core_device *core_dev); + void ppc4xx_trng_remove(struct crypto4xx_core_device *core_dev); + #else + static inline void ppc4xx_trng_probe( +- struct crypto4xx_device *dev __maybe_unused) { } ++ struct crypto4xx_core_device *dev __maybe_unused) { } + static inline void ppc4xx_trng_remove( +- struct crypto4xx_device *dev __maybe_unused) { } ++ struct crypto4xx_core_device *dev __maybe_unused) { } + #endif + + #endif +diff --git a/drivers/crypto/bcm/cipher.c b/drivers/crypto/bcm/cipher.c +index 84422435f39b..279e907590e9 100644 +--- a/drivers/crypto/bcm/cipher.c ++++ b/drivers/crypto/bcm/cipher.c +@@ -718,7 +718,7 @@ static int handle_ahash_req(struct iproc_reqctx_s *rctx) + */ + unsigned int new_data_len; + +- unsigned int chunk_start = 0; ++ unsigned int __maybe_unused chunk_start = 0; + u32 db_size; /* Length of data field, incl gcm and hash padding */ + int pad_len = 0; /* total pad len, including gcm, hash, stat padding */ + u32 data_pad_len = 0; /* length of GCM/CCM padding */ +@@ -1676,8 +1676,6 @@ static void spu_rx_callback(struct mbox_client *cl, void *msg) + struct spu_hw *spu = &iproc_priv.spu; + struct brcm_message *mssg = msg; + struct iproc_reqctx_s *rctx; +- struct iproc_ctx_s *ctx; +- struct crypto_async_request *areq; + int err = 0; + + rctx = mssg->ctx; +@@ -1687,8 +1685,6 @@ static void spu_rx_callback(struct mbox_client *cl, void *msg) + err = -EFAULT; + goto cb_finish; + } +- areq = rctx->parent; +- ctx = rctx->ctx; + + /* process the SPU status */ + err = spu->spu_status_process(rctx->msg_buf.rx_stat); +diff --git a/drivers/crypto/caam/caamrng.c b/drivers/crypto/caam/caamrng.c +index fde07d4ff019..ff6718a11e9e 100644 +--- a/drivers/crypto/caam/caamrng.c ++++ b/drivers/crypto/caam/caamrng.c +@@ -353,7 +353,10 @@ static int __init caam_rng_init(void) + goto free_rng_ctx; + + dev_info(dev, "registering rng-caam\n"); +- return hwrng_register(&caam_rng); ++ ++ err = hwrng_register(&caam_rng); ++ if (!err) ++ return err; + + free_rng_ctx: + kfree(rng_ctx); +diff --git a/drivers/crypto/caam/error.c b/drivers/crypto/caam/error.c +index 8da88beb1abb..832ba2afdcd5 100644 +--- a/drivers/crypto/caam/error.c ++++ b/drivers/crypto/caam/error.c +@@ -22,7 +22,7 @@ void caam_dump_sg(const char *level, const char *prefix_str, int prefix_type, + size_t len; + void *buf; + +- for (it = sg; it && tlen > 0 ; it = sg_next(sg)) { ++ for (it = sg; it && tlen > 0 ; it = sg_next(it)) { + /* + * make sure the scatterlist's page + * has a valid virtual memory mapping +diff --git a/drivers/crypto/ccp/ccp-crypto-aes.c b/drivers/crypto/ccp/ccp-crypto-aes.c +index 89291c15015c..3f768699332b 100644 +--- a/drivers/crypto/ccp/ccp-crypto-aes.c ++++ b/drivers/crypto/ccp/ccp-crypto-aes.c +@@ -1,7 +1,8 @@ ++// SPDX-License-Identifier: GPL-2.0 + /* + * AMD Cryptographic Coprocessor (CCP) AES crypto API support + * +- * Copyright (C) 2013,2016 Advanced Micro Devices, Inc. ++ * Copyright (C) 2013-2019 Advanced Micro Devices, Inc. + * + * Author: Tom Lendacky <thomas.lendacky@amd.com> + * +@@ -79,8 +80,7 @@ static int ccp_aes_crypt(struct ablkcipher_request *req, bool encrypt) + return -EINVAL; + + if (((ctx->u.aes.mode == CCP_AES_MODE_ECB) || +- (ctx->u.aes.mode == CCP_AES_MODE_CBC) || +- (ctx->u.aes.mode == CCP_AES_MODE_CFB)) && ++ (ctx->u.aes.mode == CCP_AES_MODE_CBC)) && + (req->nbytes & (AES_BLOCK_SIZE - 1))) + return -EINVAL; + +@@ -291,7 +291,7 @@ static struct ccp_aes_def aes_algs[] = { + .version = CCP_VERSION(3, 0), + .name = "cfb(aes)", + .driver_name = "cfb-aes-ccp", +- .blocksize = AES_BLOCK_SIZE, ++ .blocksize = 1, + .ivsize = AES_BLOCK_SIZE, + .alg_defaults = &ccp_aes_defaults, + }, +diff --git a/drivers/crypto/ccp/ccp-ops.c b/drivers/crypto/ccp/ccp-ops.c +index 1e2e42106dee..330853a2702f 100644 +--- a/drivers/crypto/ccp/ccp-ops.c ++++ b/drivers/crypto/ccp/ccp-ops.c +@@ -458,8 +458,8 @@ static int ccp_copy_from_sb(struct ccp_cmd_queue *cmd_q, + return ccp_copy_to_from_sb(cmd_q, wa, jobid, sb, byte_swap, true); + } + +-static int ccp_run_aes_cmac_cmd(struct ccp_cmd_queue *cmd_q, +- struct ccp_cmd *cmd) ++static noinline_for_stack int ++ccp_run_aes_cmac_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd) + { + struct ccp_aes_engine *aes = &cmd->u.aes; + struct ccp_dm_workarea key, ctx; +@@ -614,8 +614,8 @@ e_key: + return ret; + } + +-static int ccp_run_aes_gcm_cmd(struct ccp_cmd_queue *cmd_q, +- struct ccp_cmd *cmd) ++static noinline_for_stack int ++ccp_run_aes_gcm_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd) + { + struct ccp_aes_engine *aes = &cmd->u.aes; + struct ccp_dm_workarea key, ctx, final_wa, tag; +@@ -897,7 +897,8 @@ e_key: + return ret; + } + +-static int ccp_run_aes_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd) ++static noinline_for_stack int ++ccp_run_aes_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd) + { + struct ccp_aes_engine *aes = &cmd->u.aes; + struct ccp_dm_workarea key, ctx; +@@ -907,12 +908,6 @@ static int ccp_run_aes_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd) + bool in_place = false; + int ret; + +- if (aes->mode == CCP_AES_MODE_CMAC) +- return ccp_run_aes_cmac_cmd(cmd_q, cmd); +- +- if (aes->mode == CCP_AES_MODE_GCM) +- return ccp_run_aes_gcm_cmd(cmd_q, cmd); +- + if (!((aes->key_len == AES_KEYSIZE_128) || + (aes->key_len == AES_KEYSIZE_192) || + (aes->key_len == AES_KEYSIZE_256))) +@@ -1080,8 +1075,8 @@ e_key: + return ret; + } + +-static int ccp_run_xts_aes_cmd(struct ccp_cmd_queue *cmd_q, +- struct ccp_cmd *cmd) ++static noinline_for_stack int ++ccp_run_xts_aes_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd) + { + struct ccp_xts_aes_engine *xts = &cmd->u.xts; + struct ccp_dm_workarea key, ctx; +@@ -1280,7 +1275,8 @@ e_key: + return ret; + } + +-static int ccp_run_des3_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd) ++static noinline_for_stack int ++ccp_run_des3_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd) + { + struct ccp_des3_engine *des3 = &cmd->u.des3; + +@@ -1293,6 +1289,9 @@ static int ccp_run_des3_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd) + int ret; + + /* Error checks */ ++ if (cmd_q->ccp->vdata->version < CCP_VERSION(5, 0)) ++ return -EINVAL; ++ + if (!cmd_q->ccp->vdata->perform->des3) + return -EINVAL; + +@@ -1375,8 +1374,6 @@ static int ccp_run_des3_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd) + * passthru option to convert from big endian to little endian. + */ + if (des3->mode != CCP_DES3_MODE_ECB) { +- u32 load_mode; +- + op.sb_ctx = cmd_q->sb_ctx; + + ret = ccp_init_dm_workarea(&ctx, cmd_q, +@@ -1392,12 +1389,8 @@ static int ccp_run_des3_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd) + if (ret) + goto e_ctx; + +- if (cmd_q->ccp->vdata->version == CCP_VERSION(3, 0)) +- load_mode = CCP_PASSTHRU_BYTESWAP_NOOP; +- else +- load_mode = CCP_PASSTHRU_BYTESWAP_256BIT; + ret = ccp_copy_to_sb(cmd_q, &ctx, op.jobid, op.sb_ctx, +- load_mode); ++ CCP_PASSTHRU_BYTESWAP_256BIT); + if (ret) { + cmd->engine_error = cmd_q->cmd_error; + goto e_ctx; +@@ -1459,10 +1452,6 @@ static int ccp_run_des3_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd) + } + + /* ...but we only need the last DES3_EDE_BLOCK_SIZE bytes */ +- if (cmd_q->ccp->vdata->version == CCP_VERSION(3, 0)) +- dm_offset = CCP_SB_BYTES - des3->iv_len; +- else +- dm_offset = 0; + ccp_get_dm_area(&ctx, dm_offset, des3->iv, 0, + DES3_EDE_BLOCK_SIZE); + } +@@ -1483,7 +1472,8 @@ e_key: + return ret; + } + +-static int ccp_run_sha_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd) ++static noinline_for_stack int ++ccp_run_sha_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd) + { + struct ccp_sha_engine *sha = &cmd->u.sha; + struct ccp_dm_workarea ctx; +@@ -1827,7 +1817,8 @@ e_ctx: + return ret; + } + +-static int ccp_run_rsa_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd) ++static noinline_for_stack int ++ccp_run_rsa_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd) + { + struct ccp_rsa_engine *rsa = &cmd->u.rsa; + struct ccp_dm_workarea exp, src, dst; +@@ -1958,8 +1949,8 @@ e_sb: + return ret; + } + +-static int ccp_run_passthru_cmd(struct ccp_cmd_queue *cmd_q, +- struct ccp_cmd *cmd) ++static noinline_for_stack int ++ccp_run_passthru_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd) + { + struct ccp_passthru_engine *pt = &cmd->u.passthru; + struct ccp_dm_workarea mask; +@@ -2090,7 +2081,8 @@ e_mask: + return ret; + } + +-static int ccp_run_passthru_nomap_cmd(struct ccp_cmd_queue *cmd_q, ++static noinline_for_stack int ++ccp_run_passthru_nomap_cmd(struct ccp_cmd_queue *cmd_q, + struct ccp_cmd *cmd) + { + struct ccp_passthru_nomap_engine *pt = &cmd->u.passthru_nomap; +@@ -2431,7 +2423,8 @@ e_src: + return ret; + } + +-static int ccp_run_ecc_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd) ++static noinline_for_stack int ++ccp_run_ecc_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd) + { + struct ccp_ecc_engine *ecc = &cmd->u.ecc; + +@@ -2468,7 +2461,17 @@ int ccp_run_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd) + + switch (cmd->engine) { + case CCP_ENGINE_AES: +- ret = ccp_run_aes_cmd(cmd_q, cmd); ++ switch (cmd->u.aes.mode) { ++ case CCP_AES_MODE_CMAC: ++ ret = ccp_run_aes_cmac_cmd(cmd_q, cmd); ++ break; ++ case CCP_AES_MODE_GCM: ++ ret = ccp_run_aes_gcm_cmd(cmd_q, cmd); ++ break; ++ default: ++ ret = ccp_run_aes_cmd(cmd_q, cmd); ++ break; ++ } + break; + case CCP_ENGINE_XTS_AES_128: + ret = ccp_run_xts_aes_cmd(cmd_q, cmd); +diff --git a/drivers/crypto/sunxi-ss/sun4i-ss-hash.c b/drivers/crypto/sunxi-ss/sun4i-ss-hash.c +index 1a724263761b..2d178e013535 100644 +--- a/drivers/crypto/sunxi-ss/sun4i-ss-hash.c ++++ b/drivers/crypto/sunxi-ss/sun4i-ss-hash.c +@@ -179,7 +179,7 @@ static int sun4i_hash(struct ahash_request *areq) + */ + unsigned int i = 0, end, fill, min_fill, nwait, nbw = 0, j = 0, todo; + unsigned int in_i = 0; +- u32 spaces, rx_cnt = SS_RX_DEFAULT, bf[32] = {0}, wb = 0, v, ivmode = 0; ++ u32 spaces, rx_cnt = SS_RX_DEFAULT, bf[32] = {0}, v, ivmode = 0; + struct sun4i_req_ctx *op = ahash_request_ctx(areq); + struct crypto_ahash *tfm = crypto_ahash_reqtfm(areq); + struct sun4i_tfm_ctx *tfmctx = crypto_ahash_ctx(tfm); +@@ -188,6 +188,7 @@ static int sun4i_hash(struct ahash_request *areq) + struct sg_mapping_iter mi; + int in_r, err = 0; + size_t copied = 0; ++ __le32 wb = 0; + + dev_dbg(ss->dev, "%s %s bc=%llu len=%u mode=%x wl=%u h0=%0x", + __func__, crypto_tfm_alg_name(areq->base.tfm), +@@ -399,7 +400,7 @@ hash_final: + + nbw = op->len - 4 * nwait; + if (nbw) { +- wb = *(u32 *)(op->buf + nwait * 4); ++ wb = cpu_to_le32(*(u32 *)(op->buf + nwait * 4)); + wb &= GENMASK((nbw * 8) - 1, 0); + + op->byte_count += nbw; +@@ -408,7 +409,7 @@ hash_final: + + /* write the remaining bytes of the nbw buffer */ + wb |= ((1 << 7) << (nbw * 8)); +- bf[j++] = wb; ++ bf[j++] = le32_to_cpu(wb); + + /* + * number of space to pad to obtain 64o minus 8(size) minus 4 (final 1) +@@ -427,13 +428,13 @@ hash_final: + + /* write the length of data */ + if (op->mode == SS_OP_SHA1) { +- __be64 bits = cpu_to_be64(op->byte_count << 3); +- bf[j++] = lower_32_bits(bits); +- bf[j++] = upper_32_bits(bits); ++ __be64 *bits = (__be64 *)&bf[j]; ++ *bits = cpu_to_be64(op->byte_count << 3); ++ j += 2; + } else { +- __le64 bits = op->byte_count << 3; +- bf[j++] = lower_32_bits(bits); +- bf[j++] = upper_32_bits(bits); ++ __le64 *bits = (__le64 *)&bf[j]; ++ *bits = cpu_to_le64(op->byte_count << 3); ++ j += 2; + } + writesl(ss->base + SS_RXFIFO, bf, j); + +@@ -475,7 +476,7 @@ hash_final: + } + } else { + for (i = 0; i < 4; i++) { +- v = readl(ss->base + SS_MD0 + i * 4); ++ v = cpu_to_le32(readl(ss->base + SS_MD0 + i * 4)); + memcpy(areq->result + i * 4, &v, 4); + } + } +diff --git a/drivers/dma/dma-axi-dmac.c b/drivers/dma/dma-axi-dmac.c +index 7f0b9aa15867..9887f2a14aa9 100644 +--- a/drivers/dma/dma-axi-dmac.c ++++ b/drivers/dma/dma-axi-dmac.c +@@ -451,7 +451,7 @@ static struct dma_async_tx_descriptor *axi_dmac_prep_interleaved( + + if (chan->hw_2d) { + if (!axi_dmac_check_len(chan, xt->sgl[0].size) || +- !axi_dmac_check_len(chan, xt->numf)) ++ xt->numf == 0) + return NULL; + if (xt->sgl[0].size + dst_icg > chan->max_length || + xt->sgl[0].size + src_icg > chan->max_length) +diff --git a/drivers/dma/dw/platform.c b/drivers/dma/dw/platform.c +index 46a519e07195..b408c07662f5 100644 +--- a/drivers/dma/dw/platform.c ++++ b/drivers/dma/dw/platform.c +@@ -87,13 +87,20 @@ static void dw_dma_acpi_controller_register(struct dw_dma *dw) + dma_cap_set(DMA_SLAVE, info->dma_cap); + info->filter_fn = dw_dma_acpi_filter; + +- ret = devm_acpi_dma_controller_register(dev, acpi_dma_simple_xlate, +- info); ++ ret = acpi_dma_controller_register(dev, acpi_dma_simple_xlate, info); + if (ret) + dev_err(dev, "could not register acpi_dma_controller\n"); + } ++ ++static void dw_dma_acpi_controller_free(struct dw_dma *dw) ++{ ++ struct device *dev = dw->dma.dev; ++ ++ acpi_dma_controller_free(dev); ++} + #else /* !CONFIG_ACPI */ + static inline void dw_dma_acpi_controller_register(struct dw_dma *dw) {} ++static inline void dw_dma_acpi_controller_free(struct dw_dma *dw) {} + #endif /* !CONFIG_ACPI */ + + #ifdef CONFIG_OF +@@ -249,6 +256,9 @@ static int dw_remove(struct platform_device *pdev) + { + struct dw_dma_chip *chip = platform_get_drvdata(pdev); + ++ if (ACPI_HANDLE(&pdev->dev)) ++ dw_dma_acpi_controller_free(chip->dw); ++ + if (pdev->dev.of_node) + of_dma_controller_free(pdev->dev.of_node); + +diff --git a/drivers/dma/edma.c b/drivers/dma/edma.c +index 519c24465dea..57a49fe713fd 100644 +--- a/drivers/dma/edma.c ++++ b/drivers/dma/edma.c +@@ -2340,8 +2340,10 @@ static int edma_probe(struct platform_device *pdev) + + ecc->tc_list = devm_kcalloc(dev, ecc->num_tc, + sizeof(*ecc->tc_list), GFP_KERNEL); +- if (!ecc->tc_list) +- return -ENOMEM; ++ if (!ecc->tc_list) { ++ ret = -ENOMEM; ++ goto err_reg1; ++ } + + for (i = 0;; i++) { + ret = of_parse_phandle_with_fixed_args(node, "ti,tptcs", +diff --git a/drivers/dma/hsu/hsu.c b/drivers/dma/hsu/hsu.c +index 29d04ca71d52..15525a2b8ebd 100644 +--- a/drivers/dma/hsu/hsu.c ++++ b/drivers/dma/hsu/hsu.c +@@ -64,10 +64,10 @@ static void hsu_dma_chan_start(struct hsu_dma_chan *hsuc) + + if (hsuc->direction == DMA_MEM_TO_DEV) { + bsr = config->dst_maxburst; +- mtsr = config->src_addr_width; ++ mtsr = config->dst_addr_width; + } else if (hsuc->direction == DMA_DEV_TO_MEM) { + bsr = config->src_maxburst; +- mtsr = config->dst_addr_width; ++ mtsr = config->src_addr_width; + } + + hsu_chan_disable(hsuc); +diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c +index 0fc12a8783e3..99f3f22ed647 100644 +--- a/drivers/dma/imx-sdma.c ++++ b/drivers/dma/imx-sdma.c +@@ -1441,6 +1441,14 @@ static void sdma_add_scripts(struct sdma_engine *sdma, + if (!sdma->script_number) + sdma->script_number = SDMA_SCRIPT_ADDRS_ARRAY_SIZE_V1; + ++ if (sdma->script_number > sizeof(struct sdma_script_start_addrs) ++ / sizeof(s32)) { ++ dev_err(sdma->dev, ++ "SDMA script number %d not match with firmware.\n", ++ sdma->script_number); ++ return; ++ } ++ + for (i = 0; i < sdma->script_number; i++) + if (addr_arr[i] > 0) + saddr_arr[i] = addr_arr[i]; +diff --git a/drivers/dma/mv_xor.c b/drivers/dma/mv_xor.c +index 1993889003fd..1c57577f49fe 100644 +--- a/drivers/dma/mv_xor.c ++++ b/drivers/dma/mv_xor.c +@@ -1059,6 +1059,7 @@ mv_xor_channel_add(struct mv_xor_device *xordev, + mv_chan->op_in_desc = XOR_MODE_IN_DESC; + + dma_dev = &mv_chan->dmadev; ++ dma_dev->dev = &pdev->dev; + mv_chan->xordev = xordev; + + /* +@@ -1091,7 +1092,6 @@ mv_xor_channel_add(struct mv_xor_device *xordev, + dma_dev->device_free_chan_resources = mv_xor_free_chan_resources; + dma_dev->device_tx_status = mv_xor_status; + dma_dev->device_issue_pending = mv_xor_issue_pending; +- dma_dev->dev = &pdev->dev; + + /* set prep routines based on capability */ + if (dma_has_cap(DMA_INTERRUPT, dma_dev->cap_mask)) +diff --git a/drivers/dma/tegra210-adma.c b/drivers/dma/tegra210-adma.c +index 09b6756366c3..4f4733d831a1 100644 +--- a/drivers/dma/tegra210-adma.c ++++ b/drivers/dma/tegra210-adma.c +@@ -98,6 +98,7 @@ struct tegra_adma_chan_regs { + unsigned int src_addr; + unsigned int trg_addr; + unsigned int fifo_ctrl; ++ unsigned int cmd; + unsigned int tc; + }; + +@@ -127,6 +128,7 @@ struct tegra_adma_chan { + enum dma_transfer_direction sreq_dir; + unsigned int sreq_index; + bool sreq_reserved; ++ struct tegra_adma_chan_regs ch_regs; + + /* Transfer count and position info */ + unsigned int tx_buf_count; +@@ -635,8 +637,30 @@ static struct dma_chan *tegra_dma_of_xlate(struct of_phandle_args *dma_spec, + static int tegra_adma_runtime_suspend(struct device *dev) + { + struct tegra_adma *tdma = dev_get_drvdata(dev); ++ struct tegra_adma_chan_regs *ch_reg; ++ struct tegra_adma_chan *tdc; ++ int i; + + tdma->global_cmd = tdma_read(tdma, ADMA_GLOBAL_CMD); ++ if (!tdma->global_cmd) ++ goto clk_disable; ++ ++ for (i = 0; i < tdma->nr_channels; i++) { ++ tdc = &tdma->channels[i]; ++ ch_reg = &tdc->ch_regs; ++ ch_reg->cmd = tdma_ch_read(tdc, ADMA_CH_CMD); ++ /* skip if channel is not active */ ++ if (!ch_reg->cmd) ++ continue; ++ ch_reg->tc = tdma_ch_read(tdc, ADMA_CH_TC); ++ ch_reg->src_addr = tdma_ch_read(tdc, ADMA_CH_LOWER_SRC_ADDR); ++ ch_reg->trg_addr = tdma_ch_read(tdc, ADMA_CH_LOWER_TRG_ADDR); ++ ch_reg->ctrl = tdma_ch_read(tdc, ADMA_CH_CTRL); ++ ch_reg->fifo_ctrl = tdma_ch_read(tdc, ADMA_CH_FIFO_CTRL); ++ ch_reg->config = tdma_ch_read(tdc, ADMA_CH_CONFIG); ++ } ++ ++clk_disable: + clk_disable_unprepare(tdma->ahub_clk); + + return 0; +@@ -645,7 +669,9 @@ static int tegra_adma_runtime_suspend(struct device *dev) + static int tegra_adma_runtime_resume(struct device *dev) + { + struct tegra_adma *tdma = dev_get_drvdata(dev); +- int ret; ++ struct tegra_adma_chan_regs *ch_reg; ++ struct tegra_adma_chan *tdc; ++ int ret, i; + + ret = clk_prepare_enable(tdma->ahub_clk); + if (ret) { +@@ -654,6 +680,24 @@ static int tegra_adma_runtime_resume(struct device *dev) + } + tdma_write(tdma, ADMA_GLOBAL_CMD, tdma->global_cmd); + ++ if (!tdma->global_cmd) ++ return 0; ++ ++ for (i = 0; i < tdma->nr_channels; i++) { ++ tdc = &tdma->channels[i]; ++ ch_reg = &tdc->ch_regs; ++ /* skip if channel was not active earlier */ ++ if (!ch_reg->cmd) ++ continue; ++ tdma_ch_write(tdc, ADMA_CH_TC, ch_reg->tc); ++ tdma_ch_write(tdc, ADMA_CH_LOWER_SRC_ADDR, ch_reg->src_addr); ++ tdma_ch_write(tdc, ADMA_CH_LOWER_TRG_ADDR, ch_reg->trg_addr); ++ tdma_ch_write(tdc, ADMA_CH_CTRL, ch_reg->ctrl); ++ tdma_ch_write(tdc, ADMA_CH_FIFO_CTRL, ch_reg->fifo_ctrl); ++ tdma_ch_write(tdc, ADMA_CH_CONFIG, ch_reg->config); ++ tdma_ch_write(tdc, ADMA_CH_CMD, ch_reg->cmd); ++ } ++ + return 0; + } + +@@ -700,16 +744,6 @@ static int tegra_adma_probe(struct platform_device *pdev) + return PTR_ERR(tdma->ahub_clk); + } + +- pm_runtime_enable(&pdev->dev); +- +- ret = pm_runtime_get_sync(&pdev->dev); +- if (ret < 0) +- goto rpm_disable; +- +- ret = tegra_adma_init(tdma); +- if (ret) +- goto rpm_put; +- + INIT_LIST_HEAD(&tdma->dma_dev.channels); + for (i = 0; i < tdma->nr_channels; i++) { + struct tegra_adma_chan *tdc = &tdma->channels[i]; +@@ -727,6 +761,16 @@ static int tegra_adma_probe(struct platform_device *pdev) + tdc->tdma = tdma; + } + ++ pm_runtime_enable(&pdev->dev); ++ ++ ret = pm_runtime_get_sync(&pdev->dev); ++ if (ret < 0) ++ goto rpm_disable; ++ ++ ret = tegra_adma_init(tdma); ++ if (ret) ++ goto rpm_put; ++ + dma_cap_set(DMA_SLAVE, tdma->dma_dev.cap_mask); + dma_cap_set(DMA_PRIVATE, tdma->dma_dev.cap_mask); + dma_cap_set(DMA_CYCLIC, tdma->dma_dev.cap_mask); +@@ -768,13 +812,13 @@ static int tegra_adma_probe(struct platform_device *pdev) + + dma_remove: + dma_async_device_unregister(&tdma->dma_dev); +-irq_dispose: +- while (--i >= 0) +- irq_dispose_mapping(tdma->channels[i].irq); + rpm_put: + pm_runtime_put_sync(&pdev->dev); + rpm_disable: + pm_runtime_disable(&pdev->dev); ++irq_dispose: ++ while (--i >= 0) ++ irq_dispose_mapping(tdma->channels[i].irq); + + return ret; + } +diff --git a/drivers/edac/edac_mc.c b/drivers/edac/edac_mc.c +index f7fa05fee45a..329021189c38 100644 +--- a/drivers/edac/edac_mc.c ++++ b/drivers/edac/edac_mc.c +@@ -680,22 +680,18 @@ static int del_mc_from_global_list(struct mem_ctl_info *mci) + + struct mem_ctl_info *edac_mc_find(int idx) + { +- struct mem_ctl_info *mci = NULL; ++ struct mem_ctl_info *mci; + struct list_head *item; + + mutex_lock(&mem_ctls_mutex); + + list_for_each(item, &mc_devices) { + mci = list_entry(item, struct mem_ctl_info, link); +- +- if (mci->mc_idx >= idx) { +- if (mci->mc_idx == idx) { +- goto unlock; +- } +- break; +- } ++ if (mci->mc_idx == idx) ++ goto unlock; + } + ++ mci = NULL; + unlock: + mutex_unlock(&mem_ctls_mutex); + return mci; +diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c +index c8c83f84aced..9d94c306c8ca 100644 +--- a/drivers/gpu/drm/drm_dp_mst_topology.c ++++ b/drivers/gpu/drm/drm_dp_mst_topology.c +@@ -982,9 +982,20 @@ static struct drm_dp_mst_port *drm_dp_mst_get_port_ref_locked(struct drm_dp_mst_ + static struct drm_dp_mst_port *drm_dp_get_validated_port_ref(struct drm_dp_mst_topology_mgr *mgr, struct drm_dp_mst_port *port) + { + struct drm_dp_mst_port *rport = NULL; ++ + mutex_lock(&mgr->lock); +- if (mgr->mst_primary) +- rport = drm_dp_mst_get_port_ref_locked(mgr->mst_primary, port); ++ /* ++ * Port may or may not be 'valid' but we don't care about that when ++ * destroying the port and we are guaranteed that the port pointer ++ * will be valid until we've finished ++ */ ++ if (current_work() == &mgr->destroy_connector_work) { ++ kref_get(&port->kref); ++ rport = port; ++ } else if (mgr->mst_primary) { ++ rport = drm_dp_mst_get_port_ref_locked(mgr->mst_primary, ++ port); ++ } + mutex_unlock(&mgr->lock); + return rport; + } +diff --git a/drivers/gpu/drm/etnaviv/etnaviv_dump.c b/drivers/gpu/drm/etnaviv/etnaviv_dump.c +index 2d955d7d7b6d..e154e6fb64da 100644 +--- a/drivers/gpu/drm/etnaviv/etnaviv_dump.c ++++ b/drivers/gpu/drm/etnaviv/etnaviv_dump.c +@@ -207,7 +207,7 @@ void etnaviv_core_dump(struct etnaviv_gpu *gpu) + mutex_lock(&obj->lock); + pages = etnaviv_gem_get_pages(obj); + mutex_unlock(&obj->lock); +- if (pages) { ++ if (!IS_ERR(pages)) { + int j; + + iter.hdr->data[0] = bomap - bomap_start; +diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c b/drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c +index ae884723e9b1..880b95511b98 100644 +--- a/drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c ++++ b/drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c +@@ -26,7 +26,7 @@ struct sg_table *etnaviv_gem_prime_get_sg_table(struct drm_gem_object *obj) + int npages = obj->size >> PAGE_SHIFT; + + if (WARN_ON(!etnaviv_obj->pages)) /* should have already pinned! */ +- return NULL; ++ return ERR_PTR(-EINVAL); + + return drm_prime_pages_to_sg(etnaviv_obj->pages, npages); + } +diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_fbdev.c b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_fbdev.c +index 8bd29075ae4e..edcca1761500 100644 +--- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_fbdev.c ++++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_fbdev.c +@@ -71,7 +71,6 @@ static int hibmc_drm_fb_create(struct drm_fb_helper *helper, + DRM_DEBUG_DRIVER("surface width(%d), height(%d) and bpp(%d)\n", + sizes->surface_width, sizes->surface_height, + sizes->surface_bpp); +- sizes->surface_depth = 32; + + bytes_per_pixel = DIV_ROUND_UP(sizes->surface_bpp, 8); + +diff --git a/drivers/gpu/drm/msm/adreno/a3xx_gpu.c b/drivers/gpu/drm/msm/adreno/a3xx_gpu.c +index 7791313405b5..c8671b1578c6 100644 +--- a/drivers/gpu/drm/msm/adreno/a3xx_gpu.c ++++ b/drivers/gpu/drm/msm/adreno/a3xx_gpu.c +@@ -394,19 +394,17 @@ static const unsigned int a3xx_registers[] = { + 0x2200, 0x2212, 0x2214, 0x2217, 0x221a, 0x221a, 0x2240, 0x227e, + 0x2280, 0x228b, 0x22c0, 0x22c0, 0x22c4, 0x22ce, 0x22d0, 0x22d8, + 0x22df, 0x22e6, 0x22e8, 0x22e9, 0x22ec, 0x22ec, 0x22f0, 0x22f7, +- 0x22ff, 0x22ff, 0x2340, 0x2343, 0x2348, 0x2349, 0x2350, 0x2356, +- 0x2360, 0x2360, 0x2440, 0x2440, 0x2444, 0x2444, 0x2448, 0x244d, +- 0x2468, 0x2469, 0x246c, 0x246d, 0x2470, 0x2470, 0x2472, 0x2472, +- 0x2474, 0x2475, 0x2479, 0x247a, 0x24c0, 0x24d3, 0x24e4, 0x24ef, +- 0x2500, 0x2509, 0x250c, 0x250c, 0x250e, 0x250e, 0x2510, 0x2511, +- 0x2514, 0x2515, 0x25e4, 0x25e4, 0x25ea, 0x25ea, 0x25ec, 0x25ed, +- 0x25f0, 0x25f0, 0x2600, 0x2612, 0x2614, 0x2617, 0x261a, 0x261a, +- 0x2640, 0x267e, 0x2680, 0x268b, 0x26c0, 0x26c0, 0x26c4, 0x26ce, +- 0x26d0, 0x26d8, 0x26df, 0x26e6, 0x26e8, 0x26e9, 0x26ec, 0x26ec, +- 0x26f0, 0x26f7, 0x26ff, 0x26ff, 0x2740, 0x2743, 0x2748, 0x2749, +- 0x2750, 0x2756, 0x2760, 0x2760, 0x300c, 0x300e, 0x301c, 0x301d, +- 0x302a, 0x302a, 0x302c, 0x302d, 0x3030, 0x3031, 0x3034, 0x3036, +- 0x303c, 0x303c, 0x305e, 0x305f, ++ 0x22ff, 0x22ff, 0x2340, 0x2343, 0x2440, 0x2440, 0x2444, 0x2444, ++ 0x2448, 0x244d, 0x2468, 0x2469, 0x246c, 0x246d, 0x2470, 0x2470, ++ 0x2472, 0x2472, 0x2474, 0x2475, 0x2479, 0x247a, 0x24c0, 0x24d3, ++ 0x24e4, 0x24ef, 0x2500, 0x2509, 0x250c, 0x250c, 0x250e, 0x250e, ++ 0x2510, 0x2511, 0x2514, 0x2515, 0x25e4, 0x25e4, 0x25ea, 0x25ea, ++ 0x25ec, 0x25ed, 0x25f0, 0x25f0, 0x2600, 0x2612, 0x2614, 0x2617, ++ 0x261a, 0x261a, 0x2640, 0x267e, 0x2680, 0x268b, 0x26c0, 0x26c0, ++ 0x26c4, 0x26ce, 0x26d0, 0x26d8, 0x26df, 0x26e6, 0x26e8, 0x26e9, ++ 0x26ec, 0x26ec, 0x26f0, 0x26f7, 0x26ff, 0x26ff, 0x2740, 0x2743, ++ 0x300c, 0x300e, 0x301c, 0x301d, 0x302a, 0x302a, 0x302c, 0x302d, ++ 0x3030, 0x3031, 0x3034, 0x3036, 0x303c, 0x303c, 0x305e, 0x305f, + ~0 /* sentinel */ + }; + +diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c +index a9a0b56f1fbc..b9cb7c09e05a 100644 +--- a/drivers/gpu/drm/msm/dsi/dsi_host.c ++++ b/drivers/gpu/drm/msm/dsi/dsi_host.c +@@ -34,6 +34,8 @@ + #include "dsi_cfg.h" + #include "msm_kms.h" + ++#define DSI_RESET_TOGGLE_DELAY_MS 20 ++ + static int dsi_get_version(const void __iomem *base, u32 *major, u32 *minor) + { + u32 ver; +@@ -906,7 +908,7 @@ static void dsi_sw_reset(struct msm_dsi_host *msm_host) + wmb(); /* clocks need to be enabled before reset */ + + dsi_write(msm_host, REG_DSI_RESET, 1); +- wmb(); /* make sure reset happen */ ++ msleep(DSI_RESET_TOGGLE_DELAY_MS); /* make sure reset happen */ + dsi_write(msm_host, REG_DSI_RESET, 0); + } + +@@ -1288,7 +1290,7 @@ static void dsi_sw_reset_restore(struct msm_dsi_host *msm_host) + + /* dsi controller can only be reset while clocks are running */ + dsi_write(msm_host, REG_DSI_RESET, 1); +- wmb(); /* make sure reset happen */ ++ msleep(DSI_RESET_TOGGLE_DELAY_MS); /* make sure reset happen */ + dsi_write(msm_host, REG_DSI_RESET, 0); + wmb(); /* controller out of reset */ + dsi_write(msm_host, REG_DSI_CTRL, data0); +diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_cfg.c b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_cfg.c +index 824067d2d427..42f0ecb0cf35 100644 +--- a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_cfg.c ++++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_cfg.c +@@ -635,7 +635,7 @@ fail: + if (cfg_handler) + mdp5_cfg_destroy(cfg_handler); + +- return NULL; ++ return ERR_PTR(ret); + } + + static struct mdp5_cfg_platform *mdp5_get_config(struct platform_device *dev) +diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/fb/gddr3.c b/drivers/gpu/drm/nouveau/nvkm/subdev/fb/gddr3.c +index 60ece0a8a2e1..1d2d6bae73cd 100644 +--- a/drivers/gpu/drm/nouveau/nvkm/subdev/fb/gddr3.c ++++ b/drivers/gpu/drm/nouveau/nvkm/subdev/fb/gddr3.c +@@ -87,7 +87,7 @@ nvkm_gddr3_calc(struct nvkm_ram *ram) + WR = (ram->next->bios.timing[2] & 0x007f0000) >> 16; + /* XXX: Get these values from the VBIOS instead */ + DLL = !(ram->mr[1] & 0x1); +- RON = !(ram->mr[1] & 0x300) >> 8; ++ RON = !((ram->mr[1] & 0x300) >> 8); + break; + default: + return -ENOSYS; +diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/memx.c b/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/memx.c +index 11b28b086a06..7b052879af72 100644 +--- a/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/memx.c ++++ b/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/memx.c +@@ -88,10 +88,10 @@ nvkm_memx_fini(struct nvkm_memx **pmemx, bool exec) + if (exec) { + nvkm_pmu_send(pmu, reply, PROC_MEMX, MEMX_MSG_EXEC, + memx->base, finish); ++ nvkm_debug(subdev, "Exec took %uns, PMU_IN %08x\n", ++ reply[0], reply[1]); + } + +- nvkm_debug(subdev, "Exec took %uns, PMU_IN %08x\n", +- reply[0], reply[1]); + kfree(memx); + return 0; + } +diff --git a/drivers/gpu/drm/radeon/cik.c b/drivers/gpu/drm/radeon/cik.c +index ce8b353b5753..ba31c7674fcd 100644 +--- a/drivers/gpu/drm/radeon/cik.c ++++ b/drivers/gpu/drm/radeon/cik.c +@@ -7012,8 +7012,8 @@ static int cik_irq_init(struct radeon_device *rdev) + } + + /* setup interrupt control */ +- /* XXX this should actually be a bus address, not an MC address. same on older asics */ +- WREG32(INTERRUPT_CNTL2, rdev->ih.gpu_addr >> 8); ++ /* set dummy read address to dummy page address */ ++ WREG32(INTERRUPT_CNTL2, rdev->dummy_page.addr >> 8); + interrupt_cntl = RREG32(INTERRUPT_CNTL); + /* IH_DUMMY_RD_OVERRIDE=0 - dummy read disabled with msi, enabled without msi + * IH_DUMMY_RD_OVERRIDE=1 - dummy read controlled by IH_DUMMY_RD_EN +diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c +index e06e2d8feab3..a724bb87cfad 100644 +--- a/drivers/gpu/drm/radeon/r600.c ++++ b/drivers/gpu/drm/radeon/r600.c +@@ -3690,8 +3690,8 @@ int r600_irq_init(struct radeon_device *rdev) + } + + /* setup interrupt control */ +- /* set dummy read address to ring address */ +- WREG32(INTERRUPT_CNTL2, rdev->ih.gpu_addr >> 8); ++ /* set dummy read address to dummy page address */ ++ WREG32(INTERRUPT_CNTL2, rdev->dummy_page.addr >> 8); + interrupt_cntl = RREG32(INTERRUPT_CNTL); + /* IH_DUMMY_RD_OVERRIDE=0 - dummy read disabled with msi, enabled without msi + * IH_DUMMY_RD_OVERRIDE=1 - dummy read controlled by IH_DUMMY_RD_EN +diff --git a/drivers/gpu/drm/radeon/si.c b/drivers/gpu/drm/radeon/si.c +index 1907c950d76f..1144cafea9ac 100644 +--- a/drivers/gpu/drm/radeon/si.c ++++ b/drivers/gpu/drm/radeon/si.c +@@ -5993,8 +5993,8 @@ static int si_irq_init(struct radeon_device *rdev) + } + + /* setup interrupt control */ +- /* set dummy read address to ring address */ +- WREG32(INTERRUPT_CNTL2, rdev->ih.gpu_addr >> 8); ++ /* set dummy read address to dummy page address */ ++ WREG32(INTERRUPT_CNTL2, rdev->dummy_page.addr >> 8); + interrupt_cntl = RREG32(INTERRUPT_CNTL); + /* IH_DUMMY_RD_OVERRIDE=0 - dummy read disabled with msi, enabled without msi + * IH_DUMMY_RD_OVERRIDE=1 - dummy read controlled by IH_DUMMY_RD_EN +diff --git a/drivers/gpu/drm/shmobile/shmob_drm_drv.c b/drivers/gpu/drm/shmobile/shmob_drm_drv.c +index 592572554eb0..58d8a98c749b 100644 +--- a/drivers/gpu/drm/shmobile/shmob_drm_drv.c ++++ b/drivers/gpu/drm/shmobile/shmob_drm_drv.c +@@ -233,8 +233,8 @@ static int shmob_drm_probe(struct platform_device *pdev) + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + sdev->mmio = devm_ioremap_resource(&pdev->dev, res); +- if (sdev->mmio == NULL) +- return -ENOMEM; ++ if (IS_ERR(sdev->mmio)) ++ return PTR_ERR(sdev->mmio); + + ret = shmob_drm_setup_clocks(sdev, pdata->clk_source); + if (ret < 0) +diff --git a/drivers/gpu/drm/sti/sti_hda.c b/drivers/gpu/drm/sti/sti_hda.c +index cf65e32b5090..0399bb18d387 100644 +--- a/drivers/gpu/drm/sti/sti_hda.c ++++ b/drivers/gpu/drm/sti/sti_hda.c +@@ -721,7 +721,6 @@ static int sti_hda_bind(struct device *dev, struct device *master, void *data) + return 0; + + err_sysfs: +- drm_bridge_remove(bridge); + return -EINVAL; + } + +diff --git a/drivers/gpu/drm/sti/sti_hdmi.c b/drivers/gpu/drm/sti/sti_hdmi.c +index 30f02d2fdd03..bbb195a92e93 100644 +--- a/drivers/gpu/drm/sti/sti_hdmi.c ++++ b/drivers/gpu/drm/sti/sti_hdmi.c +@@ -1314,7 +1314,6 @@ static int sti_hdmi_bind(struct device *dev, struct device *master, void *data) + return 0; + + err_sysfs: +- drm_bridge_remove(bridge); + hdmi->drm_connector = NULL; + return -EINVAL; + } +diff --git a/drivers/gpu/drm/sun4i/sun4i_hdmi_tmds_clk.c b/drivers/gpu/drm/sun4i/sun4i_hdmi_tmds_clk.c +index 5cf2527bffc8..d7a8fea94557 100644 +--- a/drivers/gpu/drm/sun4i/sun4i_hdmi_tmds_clk.c ++++ b/drivers/gpu/drm/sun4i/sun4i_hdmi_tmds_clk.c +@@ -50,7 +50,7 @@ static unsigned long sun4i_tmds_calc_divider(unsigned long rate, + (rate - tmp_rate) < (rate - best_rate)) { + best_rate = tmp_rate; + best_m = m; +- is_double = d; ++ is_double = (d == 2) ? true : false; + } + } + } +diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c +index 21c2de81f3e3..a3be65e689fd 100644 +--- a/drivers/gpu/drm/virtio/virtgpu_vq.c ++++ b/drivers/gpu/drm/virtio/virtgpu_vq.c +@@ -648,11 +648,11 @@ int virtio_gpu_cmd_get_capset(struct virtio_gpu_device *vgdev, + { + struct virtio_gpu_get_capset *cmd_p; + struct virtio_gpu_vbuffer *vbuf; +- int max_size = vgdev->capsets[idx].max_size; ++ int max_size; + struct virtio_gpu_drv_cap_cache *cache_ent; + void *resp_buf; + +- if (idx > vgdev->num_capsets) ++ if (idx >= vgdev->num_capsets) + return -EINVAL; + + if (version > vgdev->capsets[idx].max_version) +@@ -662,6 +662,7 @@ int virtio_gpu_cmd_get_capset(struct virtio_gpu_device *vgdev, + if (!cache_ent) + return -ENOMEM; + ++ max_size = vgdev->capsets[idx].max_size; + cache_ent->caps_cache = kmalloc(max_size, GFP_KERNEL); + if (!cache_ent->caps_cache) { + kfree(cache_ent); +diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c +index 005ffb5ffa92..1737bb5fbaaf 100644 +--- a/drivers/hwmon/lm75.c ++++ b/drivers/hwmon/lm75.c +@@ -165,7 +165,7 @@ static int lm75_write(struct device *dev, enum hwmon_sensor_types type, + temp = DIV_ROUND_CLOSEST(temp << (resolution - 8), + 1000) << (16 - resolution); + +- return regmap_write(data->regmap, reg, temp); ++ return regmap_write(data->regmap, reg, (u16)temp); + } + + static umode_t lm75_is_visible(const void *data, enum hwmon_sensor_types type, +diff --git a/drivers/hwmon/pmbus/tps53679.c b/drivers/hwmon/pmbus/tps53679.c +index 85b515cd9df0..2bc352c5357f 100644 +--- a/drivers/hwmon/pmbus/tps53679.c ++++ b/drivers/hwmon/pmbus/tps53679.c +@@ -80,7 +80,14 @@ static struct pmbus_driver_info tps53679_info = { + static int tps53679_probe(struct i2c_client *client, + const struct i2c_device_id *id) + { +- return pmbus_do_probe(client, id, &tps53679_info); ++ struct pmbus_driver_info *info; ++ ++ info = devm_kmemdup(&client->dev, &tps53679_info, sizeof(*info), ++ GFP_KERNEL); ++ if (!info) ++ return -ENOMEM; ++ ++ return pmbus_do_probe(client, id, info); + } + + static const struct i2c_device_id tps53679_id[] = { +diff --git a/drivers/hwmon/shtc1.c b/drivers/hwmon/shtc1.c +index decd7df995ab..2a18539591ea 100644 +--- a/drivers/hwmon/shtc1.c ++++ b/drivers/hwmon/shtc1.c +@@ -38,7 +38,7 @@ static const unsigned char shtc1_cmd_read_id_reg[] = { 0xef, 0xc8 }; + + /* constants for reading the ID register */ + #define SHTC1_ID 0x07 +-#define SHTC1_ID_REG_MASK 0x1f ++#define SHTC1_ID_REG_MASK 0x3f + + /* delays for non-blocking i2c commands, both in us */ + #define SHTC1_NONBLOCKING_WAIT_TIME_HPM 14400 +diff --git a/drivers/hwmon/w83627hf.c b/drivers/hwmon/w83627hf.c +index 8ac89d0781cc..a575e1cdb81a 100644 +--- a/drivers/hwmon/w83627hf.c ++++ b/drivers/hwmon/w83627hf.c +@@ -130,17 +130,23 @@ superio_select(struct w83627hf_sio_data *sio, int ld) + outb(ld, sio->sioaddr + 1); + } + +-static inline void ++static inline int + superio_enter(struct w83627hf_sio_data *sio) + { ++ if (!request_muxed_region(sio->sioaddr, 2, DRVNAME)) ++ return -EBUSY; ++ + outb(0x87, sio->sioaddr); + outb(0x87, sio->sioaddr); ++ ++ return 0; + } + + static inline void + superio_exit(struct w83627hf_sio_data *sio) + { + outb(0xAA, sio->sioaddr); ++ release_region(sio->sioaddr, 2); + } + + #define W627_DEVID 0x52 +@@ -1278,7 +1284,7 @@ static DEVICE_ATTR_RO(name); + static int __init w83627hf_find(int sioaddr, unsigned short *addr, + struct w83627hf_sio_data *sio_data) + { +- int err = -ENODEV; ++ int err; + u16 val; + + static __initconst char *const names[] = { +@@ -1290,7 +1296,11 @@ static int __init w83627hf_find(int sioaddr, unsigned short *addr, + }; + + sio_data->sioaddr = sioaddr; +- superio_enter(sio_data); ++ err = superio_enter(sio_data); ++ if (err) ++ return err; ++ ++ err = -ENODEV; + val = force_id ? force_id : superio_inb(sio_data, DEVID); + switch (val) { + case W627_DEVID: +@@ -1644,9 +1654,21 @@ static int w83627thf_read_gpio5(struct platform_device *pdev) + struct w83627hf_sio_data *sio_data = dev_get_platdata(&pdev->dev); + int res = 0xff, sel; + +- superio_enter(sio_data); ++ if (superio_enter(sio_data)) { ++ /* ++ * Some other driver reserved the address space for itself. ++ * We don't want to fail driver instantiation because of that, ++ * so display a warning and keep going. ++ */ ++ dev_warn(&pdev->dev, ++ "Can not read VID data: Failed to enable SuperIO access\n"); ++ return res; ++ } ++ + superio_select(sio_data, W83627HF_LD_GPIO5); + ++ res = 0xff; ++ + /* Make sure these GPIO pins are enabled */ + if (!(superio_inb(sio_data, W83627THF_GPIO5_EN) & (1<<3))) { + dev_dbg(&pdev->dev, "GPIO5 disabled, no VID function\n"); +@@ -1677,7 +1699,17 @@ static int w83687thf_read_vid(struct platform_device *pdev) + struct w83627hf_sio_data *sio_data = dev_get_platdata(&pdev->dev); + int res = 0xff; + +- superio_enter(sio_data); ++ if (superio_enter(sio_data)) { ++ /* ++ * Some other driver reserved the address space for itself. ++ * We don't want to fail driver instantiation because of that, ++ * so display a warning and keep going. ++ */ ++ dev_warn(&pdev->dev, ++ "Can not read VID data: Failed to enable SuperIO access\n"); ++ return res; ++ } ++ + superio_select(sio_data, W83627HF_LD_HWM); + + /* Make sure these GPIO pins are enabled */ +diff --git a/drivers/iio/dac/ad5380.c b/drivers/iio/dac/ad5380.c +index 97d2c5111f43..8bf7fc626a9d 100644 +--- a/drivers/iio/dac/ad5380.c ++++ b/drivers/iio/dac/ad5380.c +@@ -221,7 +221,7 @@ static int ad5380_read_raw(struct iio_dev *indio_dev, + if (ret) + return ret; + *val >>= chan->scan_type.shift; +- val -= (1 << chan->scan_type.realbits) / 2; ++ *val -= (1 << chan->scan_type.realbits) / 2; + return IIO_VAL_INT; + case IIO_CHAN_INFO_SCALE: + *val = 2 * st->vref; +diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c +index fc4630e4acdd..1614f6f3677c 100644 +--- a/drivers/infiniband/core/cma.c ++++ b/drivers/infiniband/core/cma.c +@@ -2789,7 +2789,7 @@ static void addr_handler(int status, struct sockaddr *src_addr, + if (status) + pr_debug_ratelimited("RDMA CM: ADDR_ERROR: failed to acquire device. status %d\n", + status); +- } else { ++ } else if (status) { + pr_debug_ratelimited("RDMA CM: ADDR_ERROR: failed to resolve IP. status %d\n", status); + } + +diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c +index bb36cdf82a8d..7eb1cc1b1aa0 100644 +--- a/drivers/infiniband/hw/cxgb4/cm.c ++++ b/drivers/infiniband/hw/cxgb4/cm.c +@@ -2056,7 +2056,7 @@ static int import_ep(struct c4iw_ep *ep, int iptype, __u8 *peer_ip, + } else { + pdev = get_real_dev(n->dev); + ep->l2t = cxgb4_l2t_get(cdev->rdev.lldi.l2t, +- n, pdev, 0); ++ n, pdev, rt_tos2priority(tos)); + if (!ep->l2t) + goto out; + ep->mtu = dst_mtu(dst); +@@ -2147,7 +2147,8 @@ static int c4iw_reconnect(struct c4iw_ep *ep) + laddr6->sin6_addr.s6_addr, + raddr6->sin6_addr.s6_addr, + laddr6->sin6_port, +- raddr6->sin6_port, 0, ++ raddr6->sin6_port, ++ ep->com.cm_id->tos, + raddr6->sin6_scope_id); + iptype = 6; + ra = (__u8 *)&raddr6->sin6_addr; +@@ -2923,15 +2924,18 @@ static int terminate(struct c4iw_dev *dev, struct sk_buff *skb) + ep = get_ep_from_tid(dev, tid); + BUG_ON(!ep); + +- if (ep && ep->com.qp) { +- pr_warn("TERM received tid %u qpid %u\n", +- tid, ep->com.qp->wq.sq.qid); +- attrs.next_state = C4IW_QP_STATE_TERMINATE; +- c4iw_modify_qp(ep->com.qp->rhp, ep->com.qp, +- C4IW_QP_ATTR_NEXT_STATE, &attrs, 1); ++ if (ep) { ++ if (ep->com.qp) { ++ pr_warn("TERM received tid %u qpid %u\n", tid, ++ ep->com.qp->wq.sq.qid); ++ attrs.next_state = C4IW_QP_STATE_TERMINATE; ++ c4iw_modify_qp(ep->com.qp->rhp, ep->com.qp, ++ C4IW_QP_ATTR_NEXT_STATE, &attrs, 1); ++ } ++ ++ c4iw_put_ep(&ep->com); + } else + pr_warn("TERM received tid %u no ep/qp\n", tid); +- c4iw_put_ep(&ep->com); + + return 0; + } +@@ -3295,7 +3299,7 @@ int c4iw_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param) + laddr6->sin6_addr.s6_addr, + raddr6->sin6_addr.s6_addr, + laddr6->sin6_port, +- raddr6->sin6_port, 0, ++ raddr6->sin6_port, cm_id->tos, + raddr6->sin6_scope_id); + } + if (!ep->dst) { +diff --git a/drivers/infiniband/hw/hfi1/chip.c b/drivers/infiniband/hw/hfi1/chip.c +index 9f78bb07744c..4a0b7c003477 100644 +--- a/drivers/infiniband/hw/hfi1/chip.c ++++ b/drivers/infiniband/hw/hfi1/chip.c +@@ -10552,12 +10552,29 @@ void set_link_down_reason(struct hfi1_pportdata *ppd, u8 lcl_reason, + } + } + +-/* +- * Verify if BCT for data VLs is non-zero. ++/** ++ * data_vls_operational() - Verify if data VL BCT credits and MTU ++ * are both set. ++ * @ppd: pointer to hfi1_pportdata structure ++ * ++ * Return: true - Ok, false -otherwise. + */ + static inline bool data_vls_operational(struct hfi1_pportdata *ppd) + { +- return !!ppd->actual_vls_operational; ++ int i; ++ u64 reg; ++ ++ if (!ppd->actual_vls_operational) ++ return false; ++ ++ for (i = 0; i < ppd->vls_supported; i++) { ++ reg = read_csr(ppd->dd, SEND_CM_CREDIT_VL + (8 * i)); ++ if ((reg && !ppd->dd->vld[i].mtu) || ++ (!reg && ppd->dd->vld[i].mtu)) ++ return false; ++ } ++ ++ return true; + } + + /* +@@ -10662,7 +10679,8 @@ int set_link_state(struct hfi1_pportdata *ppd, u32 state) + + if (!data_vls_operational(ppd)) { + dd_dev_err(dd, +- "%s: data VLs not operational\n", __func__); ++ "%s: Invalid data VL credits or mtu\n", ++ __func__); + ret = -EINVAL; + break; + } +diff --git a/drivers/infiniband/hw/hns/hns_roce_qp.c b/drivers/infiniband/hw/hns/hns_roce_qp.c +index 3a37d26889df..281e9987ffc8 100644 +--- a/drivers/infiniband/hw/hns/hns_roce_qp.c ++++ b/drivers/infiniband/hw/hns/hns_roce_qp.c +@@ -241,7 +241,6 @@ void hns_roce_qp_free(struct hns_roce_dev *hr_dev, struct hns_roce_qp *hr_qp) + + if ((hr_qp->ibqp.qp_type) != IB_QPT_GSI) { + hns_roce_table_put(hr_dev, &qp_table->irrl_table, hr_qp->qpn); +- hns_roce_table_put(hr_dev, &qp_table->qp_table, hr_qp->qpn); + } + } + +diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c +index 5a7dcb5afe6e..84c962820aa2 100644 +--- a/drivers/infiniband/hw/mlx5/qp.c ++++ b/drivers/infiniband/hw/mlx5/qp.c +@@ -2357,6 +2357,11 @@ static enum mlx5_qp_optpar opt_mask[MLX5_QP_NUM_STATE][MLX5_QP_NUM_STATE][MLX5_Q + [MLX5_QP_ST_UD] = MLX5_QP_OPTPAR_PKEY_INDEX | + MLX5_QP_OPTPAR_Q_KEY | + MLX5_QP_OPTPAR_PRI_PORT, ++ [MLX5_QP_ST_XRC] = MLX5_QP_OPTPAR_RRE | ++ MLX5_QP_OPTPAR_RAE | ++ MLX5_QP_OPTPAR_RWE | ++ MLX5_QP_OPTPAR_PKEY_INDEX | ++ MLX5_QP_OPTPAR_PRI_PORT, + }, + [MLX5_QP_STATE_RTR] = { + [MLX5_QP_ST_RC] = MLX5_QP_OPTPAR_ALT_ADDR_PATH | +@@ -2390,6 +2395,12 @@ static enum mlx5_qp_optpar opt_mask[MLX5_QP_NUM_STATE][MLX5_QP_NUM_STATE][MLX5_Q + MLX5_QP_OPTPAR_RWE | + MLX5_QP_OPTPAR_PM_STATE, + [MLX5_QP_ST_UD] = MLX5_QP_OPTPAR_Q_KEY, ++ [MLX5_QP_ST_XRC] = MLX5_QP_OPTPAR_ALT_ADDR_PATH | ++ MLX5_QP_OPTPAR_RRE | ++ MLX5_QP_OPTPAR_RAE | ++ MLX5_QP_OPTPAR_RWE | ++ MLX5_QP_OPTPAR_PM_STATE | ++ MLX5_QP_OPTPAR_RNR_TIMEOUT, + }, + }, + [MLX5_QP_STATE_RTS] = { +@@ -2406,6 +2417,12 @@ static enum mlx5_qp_optpar opt_mask[MLX5_QP_NUM_STATE][MLX5_QP_NUM_STATE][MLX5_Q + [MLX5_QP_ST_UD] = MLX5_QP_OPTPAR_Q_KEY | + MLX5_QP_OPTPAR_SRQN | + MLX5_QP_OPTPAR_CQN_RCV, ++ [MLX5_QP_ST_XRC] = MLX5_QP_OPTPAR_RRE | ++ MLX5_QP_OPTPAR_RAE | ++ MLX5_QP_OPTPAR_RWE | ++ MLX5_QP_OPTPAR_RNR_TIMEOUT | ++ MLX5_QP_OPTPAR_PM_STATE | ++ MLX5_QP_OPTPAR_ALT_ADDR_PATH, + }, + }, + [MLX5_QP_STATE_SQER] = { +@@ -2417,6 +2434,10 @@ static enum mlx5_qp_optpar opt_mask[MLX5_QP_NUM_STATE][MLX5_QP_NUM_STATE][MLX5_Q + MLX5_QP_OPTPAR_RWE | + MLX5_QP_OPTPAR_RAE | + MLX5_QP_OPTPAR_RRE, ++ [MLX5_QP_ST_XRC] = MLX5_QP_OPTPAR_RNR_TIMEOUT | ++ MLX5_QP_OPTPAR_RWE | ++ MLX5_QP_OPTPAR_RAE | ++ MLX5_QP_OPTPAR_RRE, + }, + }, + }; +diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +index 27d5e8d9f08d..7683d13dad3d 100644 +--- a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c ++++ b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +@@ -55,7 +55,7 @@ + + int ocrdma_query_pkey(struct ib_device *ibdev, u8 port, u16 index, u16 *pkey) + { +- if (index > 1) ++ if (index > 0) + return -EINVAL; + + *pkey = 0xffff; +diff --git a/drivers/infiniband/hw/qedr/verbs.c b/drivers/infiniband/hw/qedr/verbs.c +index 656e7c1a4449..6ae72accae3d 100644 +--- a/drivers/infiniband/hw/qedr/verbs.c ++++ b/drivers/infiniband/hw/qedr/verbs.c +@@ -63,7 +63,7 @@ static inline int qedr_ib_copy_to_udata(struct ib_udata *udata, void *src, + + int qedr_query_pkey(struct ib_device *ibdev, u8 port, u16 index, u16 *pkey) + { +- if (index > QEDR_ROCE_PKEY_TABLE_LEN) ++ if (index >= QEDR_ROCE_PKEY_TABLE_LEN) + return -EINVAL; + + *pkey = QEDR_ROCE_PKEY_DEFAULT; +@@ -178,54 +178,47 @@ int qedr_query_device(struct ib_device *ibdev, + return 0; + } + +-#define QEDR_SPEED_SDR (1) +-#define QEDR_SPEED_DDR (2) +-#define QEDR_SPEED_QDR (4) +-#define QEDR_SPEED_FDR10 (8) +-#define QEDR_SPEED_FDR (16) +-#define QEDR_SPEED_EDR (32) +- + static inline void get_link_speed_and_width(int speed, u8 *ib_speed, + u8 *ib_width) + { + switch (speed) { + case 1000: +- *ib_speed = QEDR_SPEED_SDR; ++ *ib_speed = IB_SPEED_SDR; + *ib_width = IB_WIDTH_1X; + break; + case 10000: +- *ib_speed = QEDR_SPEED_QDR; ++ *ib_speed = IB_SPEED_QDR; + *ib_width = IB_WIDTH_1X; + break; + + case 20000: +- *ib_speed = QEDR_SPEED_DDR; ++ *ib_speed = IB_SPEED_DDR; + *ib_width = IB_WIDTH_4X; + break; + + case 25000: +- *ib_speed = QEDR_SPEED_EDR; ++ *ib_speed = IB_SPEED_EDR; + *ib_width = IB_WIDTH_1X; + break; + + case 40000: +- *ib_speed = QEDR_SPEED_QDR; ++ *ib_speed = IB_SPEED_QDR; + *ib_width = IB_WIDTH_4X; + break; + + case 50000: +- *ib_speed = QEDR_SPEED_QDR; +- *ib_width = IB_WIDTH_4X; ++ *ib_speed = IB_SPEED_HDR; ++ *ib_width = IB_WIDTH_1X; + break; + + case 100000: +- *ib_speed = QEDR_SPEED_EDR; ++ *ib_speed = IB_SPEED_EDR; + *ib_width = IB_WIDTH_4X; + break; + + default: + /* Unsupported */ +- *ib_speed = QEDR_SPEED_SDR; ++ *ib_speed = IB_SPEED_SDR; + *ib_width = IB_WIDTH_1X; + } + } +diff --git a/drivers/infiniband/hw/usnic/usnic_ib_verbs.c b/drivers/infiniband/hw/usnic/usnic_ib_verbs.c +index fdfa25059723..2602c7375d58 100644 +--- a/drivers/infiniband/hw/usnic/usnic_ib_verbs.c ++++ b/drivers/infiniband/hw/usnic/usnic_ib_verbs.c +@@ -423,7 +423,7 @@ struct net_device *usnic_get_netdev(struct ib_device *device, u8 port_num) + int usnic_ib_query_pkey(struct ib_device *ibdev, u8 port, u16 index, + u16 *pkey) + { +- if (index > 1) ++ if (index > 0) + return -EINVAL; + + *pkey = 0xffff; +diff --git a/drivers/infiniband/sw/rxe/rxe_cq.c b/drivers/infiniband/sw/rxe/rxe_cq.c +index c4aabf78dc90..f6e036ded046 100644 +--- a/drivers/infiniband/sw/rxe/rxe_cq.c ++++ b/drivers/infiniband/sw/rxe/rxe_cq.c +@@ -30,7 +30,7 @@ + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +- ++#include <linux/vmalloc.h> + #include "rxe.h" + #include "rxe_loc.h" + #include "rxe_queue.h" +@@ -97,7 +97,7 @@ int rxe_cq_from_init(struct rxe_dev *rxe, struct rxe_cq *cq, int cqe, + err = do_mmap_info(rxe, udata, false, context, cq->queue->buf, + cq->queue->buf_size, &cq->queue->ip); + if (err) { +- kvfree(cq->queue->buf); ++ vfree(cq->queue->buf); + kfree(cq->queue); + return err; + } +diff --git a/drivers/infiniband/sw/rxe/rxe_pool.c b/drivers/infiniband/sw/rxe/rxe_pool.c +index b4a8acc7bb7d..0e2425f28233 100644 +--- a/drivers/infiniband/sw/rxe/rxe_pool.c ++++ b/drivers/infiniband/sw/rxe/rxe_pool.c +@@ -112,6 +112,18 @@ static inline struct kmem_cache *pool_cache(struct rxe_pool *pool) + return rxe_type_info[pool->type].cache; + } + ++static void rxe_cache_clean(size_t cnt) ++{ ++ int i; ++ struct rxe_type_info *type; ++ ++ for (i = 0; i < cnt; i++) { ++ type = &rxe_type_info[i]; ++ kmem_cache_destroy(type->cache); ++ type->cache = NULL; ++ } ++} ++ + int rxe_cache_init(void) + { + int err; +@@ -136,24 +148,14 @@ int rxe_cache_init(void) + return 0; + + err1: +- while (--i >= 0) { +- kmem_cache_destroy(type->cache); +- type->cache = NULL; +- } ++ rxe_cache_clean(i); + + return err; + } + + void rxe_cache_exit(void) + { +- int i; +- struct rxe_type_info *type; +- +- for (i = 0; i < RXE_NUM_TYPES; i++) { +- type = &rxe_type_info[i]; +- kmem_cache_destroy(type->cache); +- type->cache = NULL; +- } ++ rxe_cache_clean(RXE_NUM_TYPES); + } + + static int rxe_pool_init_index(struct rxe_pool *pool, u32 max, u32 min) +diff --git a/drivers/infiniband/sw/rxe/rxe_qp.c b/drivers/infiniband/sw/rxe/rxe_qp.c +index aeea994b04c4..25055a68a2c0 100644 +--- a/drivers/infiniband/sw/rxe/rxe_qp.c ++++ b/drivers/infiniband/sw/rxe/rxe_qp.c +@@ -34,6 +34,7 @@ + #include <linux/skbuff.h> + #include <linux/delay.h> + #include <linux/sched.h> ++#include <linux/vmalloc.h> + + #include "rxe.h" + #include "rxe_loc.h" +@@ -255,7 +256,7 @@ static int rxe_qp_init_req(struct rxe_dev *rxe, struct rxe_qp *qp, + qp->sq.queue->buf_size, &qp->sq.queue->ip); + + if (err) { +- kvfree(qp->sq.queue->buf); ++ vfree(qp->sq.queue->buf); + kfree(qp->sq.queue); + return err; + } +@@ -308,7 +309,7 @@ static int rxe_qp_init_resp(struct rxe_dev *rxe, struct rxe_qp *qp, + qp->rq.queue->buf_size, + &qp->rq.queue->ip); + if (err) { +- kvfree(qp->rq.queue->buf); ++ vfree(qp->rq.queue->buf); + kfree(qp->rq.queue); + return err; + } +diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.h b/drivers/infiniband/ulp/iser/iscsi_iser.h +index c1ae4aeae2f9..46dfc6ae9d1c 100644 +--- a/drivers/infiniband/ulp/iser/iscsi_iser.h ++++ b/drivers/infiniband/ulp/iser/iscsi_iser.h +@@ -197,7 +197,7 @@ struct iser_data_buf { + struct scatterlist *sg; + int size; + unsigned long data_len; +- unsigned int dma_nents; ++ int dma_nents; + }; + + /* fwd declarations */ +diff --git a/drivers/infiniband/ulp/iser/iser_memory.c b/drivers/infiniband/ulp/iser/iser_memory.c +index 322209d5ff58..19883169e7b7 100644 +--- a/drivers/infiniband/ulp/iser/iser_memory.c ++++ b/drivers/infiniband/ulp/iser/iser_memory.c +@@ -240,8 +240,8 @@ int iser_fast_reg_fmr(struct iscsi_iser_task *iser_task, + page_vec->npages = 0; + page_vec->fake_mr.page_size = SIZE_4K; + plen = ib_sg_to_pages(&page_vec->fake_mr, mem->sg, +- mem->size, NULL, iser_set_page); +- if (unlikely(plen < mem->size)) { ++ mem->dma_nents, NULL, iser_set_page); ++ if (unlikely(plen < mem->dma_nents)) { + iser_err("page vec too short to hold this SG\n"); + iser_data_buf_dump(mem, device->ib_device); + iser_dump_page_vec(page_vec); +@@ -450,10 +450,10 @@ static int iser_fast_reg_mr(struct iscsi_iser_task *iser_task, + + ib_update_fast_reg_key(mr, ib_inc_rkey(mr->rkey)); + +- n = ib_map_mr_sg(mr, mem->sg, mem->size, NULL, SIZE_4K); +- if (unlikely(n != mem->size)) { ++ n = ib_map_mr_sg(mr, mem->sg, mem->dma_nents, NULL, SIZE_4K); ++ if (unlikely(n != mem->dma_nents)) { + iser_err("failed to map sg (%d/%d)\n", +- n, mem->size); ++ n, mem->dma_nents); + return n < 0 ? n : -EINVAL; + } + +diff --git a/drivers/input/keyboard/nomadik-ske-keypad.c b/drivers/input/keyboard/nomadik-ske-keypad.c +index 8567ee47761e..ae3b04557074 100644 +--- a/drivers/input/keyboard/nomadik-ske-keypad.c ++++ b/drivers/input/keyboard/nomadik-ske-keypad.c +@@ -100,7 +100,7 @@ static int __init ske_keypad_chip_init(struct ske_keypad *keypad) + while ((readl(keypad->reg_base + SKE_RIS) != 0x00000000) && timeout--) + cpu_relax(); + +- if (!timeout) ++ if (timeout == -1) + return -EINVAL; + + /* +diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c +index d09c24825734..778f167be2d3 100644 +--- a/drivers/iommu/amd_iommu.c ++++ b/drivers/iommu/amd_iommu.c +@@ -2160,6 +2160,8 @@ skip_ats_check: + */ + domain_flush_tlb_pde(domain); + ++ domain_flush_complete(domain); ++ + return ret; + } + +diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c +index 6a3cf4d0bd5e..4d2920988d60 100644 +--- a/drivers/iommu/amd_iommu_init.c ++++ b/drivers/iommu/amd_iommu_init.c +@@ -420,6 +420,9 @@ static void iommu_enable(struct amd_iommu *iommu) + + static void iommu_disable(struct amd_iommu *iommu) + { ++ if (!iommu->mmio_base) ++ return; ++ + /* Disable command buffer */ + iommu_feature_disable(iommu, CONTROL_CMDBUF_EN); + +diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c +index 523d0889c2a4..b48666849dbe 100644 +--- a/drivers/iommu/intel-iommu.c ++++ b/drivers/iommu/intel-iommu.c +@@ -442,7 +442,6 @@ struct dmar_rmrr_unit { + u64 end_address; /* reserved end address */ + struct dmar_dev_scope *devices; /* target devices */ + int devices_cnt; /* target device count */ +- struct iommu_resv_region *resv; /* reserved region handle */ + }; + + struct dmar_atsr_unit { +@@ -3361,9 +3360,12 @@ static int __init init_dmars(void) + iommu_identity_mapping |= IDENTMAP_ALL; + + #ifdef CONFIG_INTEL_IOMMU_BROKEN_GFX_WA +- iommu_identity_mapping |= IDENTMAP_GFX; ++ dmar_map_gfx = 0; + #endif + ++ if (!dmar_map_gfx) ++ iommu_identity_mapping |= IDENTMAP_GFX; ++ + check_tylersburg_isoch(); + + if (iommu_identity_mapping) { +@@ -4168,7 +4170,6 @@ static inline void init_iommu_pm_ops(void) {} + int __init dmar_parse_one_rmrr(struct acpi_dmar_header *header, void *arg) + { + struct acpi_dmar_reserved_memory *rmrr; +- int prot = DMA_PTE_READ|DMA_PTE_WRITE; + struct dmar_rmrr_unit *rmrru; + size_t length; + +@@ -4182,22 +4183,16 @@ int __init dmar_parse_one_rmrr(struct acpi_dmar_header *header, void *arg) + rmrru->end_address = rmrr->end_address; + + length = rmrr->end_address - rmrr->base_address + 1; +- rmrru->resv = iommu_alloc_resv_region(rmrr->base_address, length, prot, +- IOMMU_RESV_DIRECT); +- if (!rmrru->resv) +- goto free_rmrru; + + rmrru->devices = dmar_alloc_dev_scope((void *)(rmrr + 1), + ((void *)rmrr) + rmrr->header.length, + &rmrru->devices_cnt); + if (rmrru->devices_cnt && rmrru->devices == NULL) +- goto free_all; ++ goto free_rmrru; + + list_add(&rmrru->list, &dmar_rmrr_units); + + return 0; +-free_all: +- kfree(rmrru->resv); + free_rmrru: + kfree(rmrru); + out: +@@ -4415,7 +4410,6 @@ static void intel_iommu_free_dmars(void) + list_for_each_entry_safe(rmrru, rmrr_n, &dmar_rmrr_units, list) { + list_del(&rmrru->list); + dmar_free_dev_scope(&rmrru->devices, &rmrru->devices_cnt); +- kfree(rmrru->resv); + kfree(rmrru); + } + +@@ -5183,22 +5177,33 @@ static void intel_iommu_remove_device(struct device *dev) + static void intel_iommu_get_resv_regions(struct device *device, + struct list_head *head) + { ++ int prot = DMA_PTE_READ | DMA_PTE_WRITE; + struct iommu_resv_region *reg; + struct dmar_rmrr_unit *rmrr; + struct device *i_dev; + int i; + +- rcu_read_lock(); ++ down_read(&dmar_global_lock); + for_each_rmrr_units(rmrr) { + for_each_active_dev_scope(rmrr->devices, rmrr->devices_cnt, + i, i_dev) { ++ struct iommu_resv_region *resv; ++ size_t length; ++ + if (i_dev != device) + continue; + +- list_add_tail(&rmrr->resv->list, head); ++ length = rmrr->end_address - rmrr->base_address + 1; ++ resv = iommu_alloc_resv_region(rmrr->base_address, ++ length, prot, ++ IOMMU_RESV_DIRECT); ++ if (!resv) ++ break; ++ ++ list_add_tail(&resv->list, head); + } + } +- rcu_read_unlock(); ++ up_read(&dmar_global_lock); + + reg = iommu_alloc_resv_region(IOAPIC_RANGE_START, + IOAPIC_RANGE_END - IOAPIC_RANGE_START + 1, +@@ -5213,10 +5218,8 @@ static void intel_iommu_put_resv_regions(struct device *dev, + { + struct iommu_resv_region *entry, *next; + +- list_for_each_entry_safe(entry, next, head, list) { +- if (entry->type == IOMMU_RESV_MSI) +- kfree(entry); +- } ++ list_for_each_entry_safe(entry, next, head, list) ++ kfree(entry); + } + + #ifdef CONFIG_INTEL_IOMMU_SVM +diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c +index 4b761678a18b..2c48a9d6d91e 100644 +--- a/drivers/iommu/iommu.c ++++ b/drivers/iommu/iommu.c +@@ -1856,9 +1856,9 @@ int iommu_request_dm_for_dev(struct device *dev) + int ret; + + /* Device must already be in a group before calling this function */ +- group = iommu_group_get_for_dev(dev); +- if (IS_ERR(group)) +- return PTR_ERR(group); ++ group = iommu_group_get(dev); ++ if (!group) ++ return -EINVAL; + + mutex_lock(&group->mutex); + +diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c +index c30f62700431..0f99e95a1a73 100644 +--- a/drivers/iommu/mtk_iommu.c ++++ b/drivers/iommu/mtk_iommu.c +@@ -115,6 +115,30 @@ struct mtk_iommu_domain { + + static struct iommu_ops mtk_iommu_ops; + ++/* ++ * In M4U 4GB mode, the physical address is remapped as below: ++ * ++ * CPU Physical address: ++ * ==================== ++ * ++ * 0 1G 2G 3G 4G 5G ++ * |---A---|---B---|---C---|---D---|---E---| ++ * +--I/O--+------------Memory-------------+ ++ * ++ * IOMMU output physical address: ++ * ============================= ++ * ++ * 4G 5G 6G 7G 8G ++ * |---E---|---B---|---C---|---D---| ++ * +------------Memory-------------+ ++ * ++ * The Region 'A'(I/O) can NOT be mapped by M4U; For Region 'B'/'C'/'D', the ++ * bit32 of the CPU physical address always is needed to set, and for Region ++ * 'E', the CPU physical address keep as is. ++ * Additionally, The iommu consumers always use the CPU phyiscal address. ++ */ ++#define MTK_IOMMU_4GB_MODE_REMAP_BASE 0x40000000 ++ + static LIST_HEAD(m4ulist); /* List all the M4U HWs */ + + #define for_each_m4u(data) list_for_each_entry(data, &m4ulist, list) +@@ -404,7 +428,7 @@ static phys_addr_t mtk_iommu_iova_to_phys(struct iommu_domain *domain, + pa = dom->iop->iova_to_phys(dom->iop, iova); + spin_unlock_irqrestore(&dom->pgtlock, flags); + +- if (data->enable_4GB) ++ if (data->enable_4GB && pa < MTK_IOMMU_4GB_MODE_REMAP_BASE) + pa |= BIT_ULL(32); + + return pa; +diff --git a/drivers/lightnvm/pblk-rb.c b/drivers/lightnvm/pblk-rb.c +index c0dd17a82170..73de2deaba67 100644 +--- a/drivers/lightnvm/pblk-rb.c ++++ b/drivers/lightnvm/pblk-rb.c +@@ -825,8 +825,8 @@ int pblk_rb_tear_down_check(struct pblk_rb *rb) + } + + out: +- spin_unlock(&rb->w_lock); + spin_unlock_irq(&rb->s_lock); ++ spin_unlock(&rb->w_lock); + + return ret; + } +diff --git a/drivers/media/i2c/ov2659.c b/drivers/media/i2c/ov2659.c +index 44b0584eb8a6..e7768ed1ff9c 100644 +--- a/drivers/media/i2c/ov2659.c ++++ b/drivers/media/i2c/ov2659.c +@@ -1136,7 +1136,7 @@ static int ov2659_set_fmt(struct v4l2_subdev *sd, + mf = v4l2_subdev_get_try_format(sd, cfg, fmt->pad); + *mf = fmt->format; + #else +- return -ENOTTY; ++ ret = -ENOTTY; + #endif + } else { + s64 val; +diff --git a/drivers/media/pci/cx18/cx18-fileops.c b/drivers/media/pci/cx18/cx18-fileops.c +index 98467b2089fa..099d59b992c1 100644 +--- a/drivers/media/pci/cx18/cx18-fileops.c ++++ b/drivers/media/pci/cx18/cx18-fileops.c +@@ -484,7 +484,7 @@ static ssize_t cx18_read_pos(struct cx18_stream *s, char __user *ubuf, + + CX18_DEBUG_HI_FILE("read %zd from %s, got %zd\n", count, s->name, rc); + if (rc > 0) +- pos += rc; ++ *pos += rc; + return rc; + } + +diff --git a/drivers/media/pci/cx23885/cx23885-dvb.c b/drivers/media/pci/cx23885/cx23885-dvb.c +index e795ddeb7fe2..60f122edaefb 100644 +--- a/drivers/media/pci/cx23885/cx23885-dvb.c ++++ b/drivers/media/pci/cx23885/cx23885-dvb.c +@@ -1460,8 +1460,9 @@ static int dvb_register(struct cx23885_tsport *port) + if (fe0->dvb.frontend != NULL) { + struct i2c_adapter *tun_i2c; + +- fe0->dvb.frontend->sec_priv = kmalloc(sizeof(dib7000p_ops), GFP_KERNEL); +- memcpy(fe0->dvb.frontend->sec_priv, &dib7000p_ops, sizeof(dib7000p_ops)); ++ fe0->dvb.frontend->sec_priv = kmemdup(&dib7000p_ops, sizeof(dib7000p_ops), GFP_KERNEL); ++ if (!fe0->dvb.frontend->sec_priv) ++ return -ENOMEM; + tun_i2c = dib7000p_ops.get_i2c_master(fe0->dvb.frontend, DIBX000_I2C_INTERFACE_TUNER, 1); + if (!dvb_attach(dib0070_attach, fe0->dvb.frontend, tun_i2c, &dib7070p_dib0070_config)) + return -ENODEV; +diff --git a/drivers/media/pci/ivtv/ivtv-fileops.c b/drivers/media/pci/ivtv/ivtv-fileops.c +index c9bd018e53de..e2b19c3eaa87 100644 +--- a/drivers/media/pci/ivtv/ivtv-fileops.c ++++ b/drivers/media/pci/ivtv/ivtv-fileops.c +@@ -420,7 +420,7 @@ static ssize_t ivtv_read_pos(struct ivtv_stream *s, char __user *ubuf, size_t co + + IVTV_DEBUG_HI_FILE("read %zd from %s, got %zd\n", count, s->name, rc); + if (rc > 0) +- pos += rc; ++ *pos += rc; + return rc; + } + +diff --git a/drivers/media/pci/tw5864/tw5864-video.c b/drivers/media/pci/tw5864/tw5864-video.c +index e7bd2b8484e3..ee1230440b39 100644 +--- a/drivers/media/pci/tw5864/tw5864-video.c ++++ b/drivers/media/pci/tw5864/tw5864-video.c +@@ -1395,13 +1395,13 @@ static void tw5864_handle_frame(struct tw5864_h264_frame *frame) + input->vb = NULL; + spin_unlock_irqrestore(&input->slock, flags); + +- v4l2_buf = to_vb2_v4l2_buffer(&vb->vb.vb2_buf); +- + if (!vb) { /* Gone because of disabling */ + dev_dbg(&dev->pci->dev, "vb is empty, dropping frame\n"); + return; + } + ++ v4l2_buf = to_vb2_v4l2_buffer(&vb->vb.vb2_buf); ++ + /* + * Check for space. + * Mind the overhead of startcode emulation prevention. +diff --git a/drivers/media/platform/atmel/atmel-isi.c b/drivers/media/platform/atmel/atmel-isi.c +index 891fa2505efa..2f962a3418f6 100644 +--- a/drivers/media/platform/atmel/atmel-isi.c ++++ b/drivers/media/platform/atmel/atmel-isi.c +@@ -496,7 +496,7 @@ static void stop_streaming(struct vb2_queue *vq) + spin_unlock_irq(&isi->irqlock); + + if (!isi->enable_preview_path) { +- timeout = jiffies + FRAME_INTERVAL_MILLI_SEC * HZ; ++ timeout = jiffies + (FRAME_INTERVAL_MILLI_SEC * HZ) / 1000; + /* Wait until the end of the current frame. */ + while ((isi_readl(isi, ISI_STATUS) & ISI_CTRL_CDC) && + time_before(jiffies, timeout)) +diff --git a/drivers/media/platform/davinci/isif.c b/drivers/media/platform/davinci/isif.c +index 90d0f13283ae..12065ad1ac45 100644 +--- a/drivers/media/platform/davinci/isif.c ++++ b/drivers/media/platform/davinci/isif.c +@@ -886,9 +886,7 @@ static int isif_set_hw_if_params(struct vpfe_hw_if_param *params) + static int isif_config_ycbcr(void) + { + struct isif_ycbcr_config *params = &isif_cfg.ycbcr; +- struct vpss_pg_frame_size frame_size; + u32 modeset = 0, ccdcfg = 0; +- struct vpss_sync_pol sync; + + dev_dbg(isif_cfg.dev, "\nStarting isif_config_ycbcr..."); + +@@ -976,13 +974,6 @@ static int isif_config_ycbcr(void) + /* two fields are interleaved in memory */ + regw(0x00000249, SDOFST); + +- /* Setup test pattern if enabled */ +- if (isif_cfg.bayer.config_params.test_pat_gen) { +- sync.ccdpg_hdpol = params->hd_pol; +- sync.ccdpg_vdpol = params->vd_pol; +- dm365_vpss_set_sync_pol(sync); +- dm365_vpss_set_pg_frame_size(frame_size); +- } + return 0; + } + +diff --git a/drivers/media/platform/davinci/vpbe.c b/drivers/media/platform/davinci/vpbe.c +index 1d3c13e36904..915af9ca4711 100644 +--- a/drivers/media/platform/davinci/vpbe.c ++++ b/drivers/media/platform/davinci/vpbe.c +@@ -126,7 +126,7 @@ static int vpbe_enum_outputs(struct vpbe_device *vpbe_dev, + struct v4l2_output *output) + { + struct vpbe_config *cfg = vpbe_dev->cfg; +- int temp_index = output->index; ++ unsigned int temp_index = output->index; + + if (temp_index >= cfg->num_outputs) + return -EINVAL; +diff --git a/drivers/media/platform/omap/omap_vout.c b/drivers/media/platform/omap/omap_vout.c +index 4d29860d27b4..18604b608ab2 100644 +--- a/drivers/media/platform/omap/omap_vout.c ++++ b/drivers/media/platform/omap/omap_vout.c +@@ -1527,23 +1527,20 @@ static int vidioc_dqbuf(struct file *file, void *fh, struct v4l2_buffer *b) + unsigned long size; + struct videobuf_buffer *vb; + +- vb = q->bufs[b->index]; +- + if (!vout->streaming) + return -EINVAL; + +- if (file->f_flags & O_NONBLOCK) +- /* Call videobuf_dqbuf for non blocking mode */ +- ret = videobuf_dqbuf(q, (struct v4l2_buffer *)b, 1); +- else +- /* Call videobuf_dqbuf for blocking mode */ +- ret = videobuf_dqbuf(q, (struct v4l2_buffer *)b, 0); ++ ret = videobuf_dqbuf(q, b, !!(file->f_flags & O_NONBLOCK)); ++ if (ret) ++ return ret; ++ ++ vb = q->bufs[b->index]; + + addr = (unsigned long) vout->buf_phy_addr[vb->i]; + size = (unsigned long) vb->size; + dma_unmap_single(vout->vid_dev->v4l2_dev.dev, addr, + size, DMA_TO_DEVICE); +- return ret; ++ return 0; + } + + static int vidioc_streamon(struct file *file, void *fh, enum v4l2_buf_type i) +diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c +index 4568e68e15fa..85a5e33600c0 100644 +--- a/drivers/media/platform/s5p-jpeg/jpeg-core.c ++++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c +@@ -2005,7 +2005,7 @@ static int s5p_jpeg_controls_create(struct s5p_jpeg_ctx *ctx) + + v4l2_ctrl_new_std(&ctx->ctrl_handler, &s5p_jpeg_ctrl_ops, + V4L2_CID_JPEG_RESTART_INTERVAL, +- 0, 3, 0xffff, 0); ++ 0, 0xffff, 1, 0); + if (ctx->jpeg->variant->version == SJPEG_S5P) + mask = ~0x06; /* 422, 420 */ + } +diff --git a/drivers/media/platform/vivid/vivid-osd.c b/drivers/media/platform/vivid/vivid-osd.c +index bdc380b14e0c..a95b7c56569e 100644 +--- a/drivers/media/platform/vivid/vivid-osd.c ++++ b/drivers/media/platform/vivid/vivid-osd.c +@@ -167,7 +167,7 @@ static int _vivid_fb_check_var(struct fb_var_screeninfo *var, struct vivid_dev * + var->nonstd = 0; + + var->vmode &= ~FB_VMODE_MASK; +- var->vmode = FB_VMODE_NONINTERLACED; ++ var->vmode |= FB_VMODE_NONINTERLACED; + + /* Dummy values */ + var->hsync_len = 24; +diff --git a/drivers/media/radio/wl128x/fmdrv_common.c b/drivers/media/radio/wl128x/fmdrv_common.c +index 26895ae42fcf..2d20d908e280 100644 +--- a/drivers/media/radio/wl128x/fmdrv_common.c ++++ b/drivers/media/radio/wl128x/fmdrv_common.c +@@ -1271,8 +1271,9 @@ static int fm_download_firmware(struct fmdev *fmdev, const u8 *fw_name) + + switch (action->type) { + case ACTION_SEND_COMMAND: /* Send */ +- if (fmc_send_cmd(fmdev, 0, 0, action->data, +- action->size, NULL, NULL)) ++ ret = fmc_send_cmd(fmdev, 0, 0, action->data, ++ action->size, NULL, NULL); ++ if (ret) + goto rel_fw; + + cmd_cnt++; +diff --git a/drivers/mfd/intel-lpss-pci.c b/drivers/mfd/intel-lpss-pci.c +index 2b7e8eeaa59e..0504761516f7 100644 +--- a/drivers/mfd/intel-lpss-pci.c ++++ b/drivers/mfd/intel-lpss-pci.c +@@ -126,6 +126,18 @@ static const struct intel_lpss_platform_info apl_i2c_info = { + .properties = apl_i2c_properties, + }; + ++static struct property_entry glk_i2c_properties[] = { ++ PROPERTY_ENTRY_U32("i2c-sda-hold-time-ns", 313), ++ PROPERTY_ENTRY_U32("i2c-sda-falling-time-ns", 171), ++ PROPERTY_ENTRY_U32("i2c-scl-falling-time-ns", 290), ++ { }, ++}; ++ ++static const struct intel_lpss_platform_info glk_i2c_info = { ++ .clk_rate = 133000000, ++ .properties = glk_i2c_properties, ++}; ++ + static const struct intel_lpss_platform_info cnl_i2c_info = { + .clk_rate = 216000000, + .properties = spt_i2c_properties, +@@ -165,14 +177,14 @@ static const struct pci_device_id intel_lpss_pci_ids[] = { + { PCI_VDEVICE(INTEL, 0x1ac6), (kernel_ulong_t)&bxt_info }, + { PCI_VDEVICE(INTEL, 0x1aee), (kernel_ulong_t)&bxt_uart_info }, + /* GLK */ +- { PCI_VDEVICE(INTEL, 0x31ac), (kernel_ulong_t)&bxt_i2c_info }, +- { PCI_VDEVICE(INTEL, 0x31ae), (kernel_ulong_t)&bxt_i2c_info }, +- { PCI_VDEVICE(INTEL, 0x31b0), (kernel_ulong_t)&bxt_i2c_info }, +- { PCI_VDEVICE(INTEL, 0x31b2), (kernel_ulong_t)&bxt_i2c_info }, +- { PCI_VDEVICE(INTEL, 0x31b4), (kernel_ulong_t)&bxt_i2c_info }, +- { PCI_VDEVICE(INTEL, 0x31b6), (kernel_ulong_t)&bxt_i2c_info }, +- { PCI_VDEVICE(INTEL, 0x31b8), (kernel_ulong_t)&bxt_i2c_info }, +- { PCI_VDEVICE(INTEL, 0x31ba), (kernel_ulong_t)&bxt_i2c_info }, ++ { PCI_VDEVICE(INTEL, 0x31ac), (kernel_ulong_t)&glk_i2c_info }, ++ { PCI_VDEVICE(INTEL, 0x31ae), (kernel_ulong_t)&glk_i2c_info }, ++ { PCI_VDEVICE(INTEL, 0x31b0), (kernel_ulong_t)&glk_i2c_info }, ++ { PCI_VDEVICE(INTEL, 0x31b2), (kernel_ulong_t)&glk_i2c_info }, ++ { PCI_VDEVICE(INTEL, 0x31b4), (kernel_ulong_t)&glk_i2c_info }, ++ { PCI_VDEVICE(INTEL, 0x31b6), (kernel_ulong_t)&glk_i2c_info }, ++ { PCI_VDEVICE(INTEL, 0x31b8), (kernel_ulong_t)&glk_i2c_info }, ++ { PCI_VDEVICE(INTEL, 0x31ba), (kernel_ulong_t)&glk_i2c_info }, + { PCI_VDEVICE(INTEL, 0x31bc), (kernel_ulong_t)&bxt_uart_info }, + { PCI_VDEVICE(INTEL, 0x31be), (kernel_ulong_t)&bxt_uart_info }, + { PCI_VDEVICE(INTEL, 0x31c0), (kernel_ulong_t)&bxt_uart_info }, +diff --git a/drivers/mfd/intel-lpss.c b/drivers/mfd/intel-lpss.c +index b5c4f8f974aa..9ed573e232c0 100644 +--- a/drivers/mfd/intel-lpss.c ++++ b/drivers/mfd/intel-lpss.c +@@ -541,6 +541,7 @@ module_init(intel_lpss_init); + + static void __exit intel_lpss_exit(void) + { ++ ida_destroy(&intel_lpss_devid_ida); + debugfs_remove(intel_lpss_debugfs); + } + module_exit(intel_lpss_exit); +diff --git a/drivers/misc/mic/card/mic_x100.c b/drivers/misc/mic/card/mic_x100.c +index b9f0710ffa6b..4007adc666f3 100644 +--- a/drivers/misc/mic/card/mic_x100.c ++++ b/drivers/misc/mic/card/mic_x100.c +@@ -249,6 +249,9 @@ static int __init mic_probe(struct platform_device *pdev) + mdrv->dev = &pdev->dev; + snprintf(mdrv->name, sizeof(mic_driver_name), mic_driver_name); + ++ /* FIXME: use dma_set_mask_and_coherent() and check result */ ++ dma_coerce_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); ++ + mdev->mmio.pa = MIC_X100_MMIO_BASE; + mdev->mmio.len = MIC_X100_MMIO_LEN; + mdev->mmio.va = devm_ioremap(&pdev->dev, MIC_X100_MMIO_BASE, +@@ -294,18 +297,6 @@ static void mic_platform_shutdown(struct platform_device *pdev) + mic_remove(pdev); + } + +-static u64 mic_dma_mask = DMA_BIT_MASK(64); +- +-static struct platform_device mic_platform_dev = { +- .name = mic_driver_name, +- .id = 0, +- .num_resources = 0, +- .dev = { +- .dma_mask = &mic_dma_mask, +- .coherent_dma_mask = DMA_BIT_MASK(64), +- }, +-}; +- + static struct platform_driver __refdata mic_platform_driver = { + .probe = mic_probe, + .remove = mic_remove, +@@ -315,6 +306,8 @@ static struct platform_driver __refdata mic_platform_driver = { + }, + }; + ++static struct platform_device *mic_platform_dev; ++ + static int __init mic_init(void) + { + int ret; +@@ -328,9 +321,12 @@ static int __init mic_init(void) + + request_module("mic_x100_dma"); + mic_init_card_debugfs(); +- ret = platform_device_register(&mic_platform_dev); ++ ++ mic_platform_dev = platform_device_register_simple(mic_driver_name, ++ 0, NULL, 0); ++ ret = PTR_ERR_OR_ZERO(mic_platform_dev); + if (ret) { +- pr_err("platform_device_register ret %d\n", ret); ++ pr_err("platform_device_register_full ret %d\n", ret); + goto cleanup_debugfs; + } + ret = platform_driver_register(&mic_platform_driver); +@@ -341,7 +337,7 @@ static int __init mic_init(void) + return ret; + + device_unregister: +- platform_device_unregister(&mic_platform_dev); ++ platform_device_unregister(mic_platform_dev); + cleanup_debugfs: + mic_exit_card_debugfs(); + done: +@@ -351,7 +347,7 @@ done: + static void __exit mic_exit(void) + { + platform_driver_unregister(&mic_platform_driver); +- platform_device_unregister(&mic_platform_dev); ++ platform_device_unregister(mic_platform_dev); + mic_exit_card_debugfs(); + } + +diff --git a/drivers/misc/sgi-xp/xpc_partition.c b/drivers/misc/sgi-xp/xpc_partition.c +index 6956f7e7d439..ca5f0102daef 100644 +--- a/drivers/misc/sgi-xp/xpc_partition.c ++++ b/drivers/misc/sgi-xp/xpc_partition.c +@@ -70,7 +70,7 @@ xpc_get_rsvd_page_pa(int nasid) + unsigned long rp_pa = nasid; /* seed with nasid */ + size_t len = 0; + size_t buf_len = 0; +- void *buf = buf; ++ void *buf = NULL; + void *buf_base = NULL; + enum xp_retval (*get_partition_rsvd_page_pa) + (void *, u64 *, unsigned long *, size_t *) = +diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c +index ad88deb2e8f3..3740fb0052a4 100644 +--- a/drivers/mmc/core/host.c ++++ b/drivers/mmc/core/host.c +@@ -376,8 +376,6 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev) + + if (mmc_gpio_alloc(host)) { + put_device(&host->class_dev); +- ida_simple_remove(&mmc_host_ida, host->index); +- kfree(host); + return NULL; + } + +diff --git a/drivers/mmc/core/quirks.h b/drivers/mmc/core/quirks.h +index 5153577754f0..09897abb79ed 100644 +--- a/drivers/mmc/core/quirks.h ++++ b/drivers/mmc/core/quirks.h +@@ -119,7 +119,14 @@ static const struct mmc_fixup mmc_ext_csd_fixups[] = { + END_FIXUP + }; + ++ + static const struct mmc_fixup sdio_fixup_methods[] = { ++ SDIO_FIXUP(SDIO_VENDOR_ID_TI_WL1251, SDIO_DEVICE_ID_TI_WL1251, ++ add_quirk, MMC_QUIRK_NONSTD_FUNC_IF), ++ ++ SDIO_FIXUP(SDIO_VENDOR_ID_TI_WL1251, SDIO_DEVICE_ID_TI_WL1251, ++ add_quirk, MMC_QUIRK_DISABLE_CD), ++ + SDIO_FIXUP(SDIO_VENDOR_ID_TI, SDIO_DEVICE_ID_TI_WL1271, + add_quirk, MMC_QUIRK_NONSTD_FUNC_IF), + +diff --git a/drivers/mmc/host/sdhci-brcmstb.c b/drivers/mmc/host/sdhci-brcmstb.c +index 552bddc5096c..1cd10356fc14 100644 +--- a/drivers/mmc/host/sdhci-brcmstb.c ++++ b/drivers/mmc/host/sdhci-brcmstb.c +@@ -55,7 +55,9 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev) + } + + sdhci_get_of_property(pdev); +- mmc_of_parse(host->mmc); ++ res = mmc_of_parse(host->mmc); ++ if (res) ++ goto err; + + /* + * Supply the existing CAPS, but clear the UHS modes. This +diff --git a/drivers/net/dsa/qca8k.c b/drivers/net/dsa/qca8k.c +index 8e49974ffa0e..8ee59b20b47a 100644 +--- a/drivers/net/dsa/qca8k.c ++++ b/drivers/net/dsa/qca8k.c +@@ -459,6 +459,18 @@ qca8k_set_pad_ctrl(struct qca8k_priv *priv, int port, int mode) + qca8k_write(priv, QCA8K_REG_PORT5_PAD_CTRL, + QCA8K_PORT_PAD_RGMII_RX_DELAY_EN); + break; ++ case PHY_INTERFACE_MODE_RGMII_ID: ++ /* RGMII_ID needs internal delay. This is enabled through ++ * PORT5_PAD_CTRL for all ports, rather than individual port ++ * registers ++ */ ++ qca8k_write(priv, reg, ++ QCA8K_PORT_PAD_RGMII_EN | ++ QCA8K_PORT_PAD_RGMII_TX_DELAY(QCA8K_MAX_DELAY) | ++ QCA8K_PORT_PAD_RGMII_RX_DELAY(QCA8K_MAX_DELAY)); ++ qca8k_write(priv, QCA8K_REG_PORT5_PAD_CTRL, ++ QCA8K_PORT_PAD_RGMII_RX_DELAY_EN); ++ break; + case PHY_INTERFACE_MODE_SGMII: + qca8k_write(priv, reg, QCA8K_PORT_PAD_SGMII_EN); + break; +diff --git a/drivers/net/dsa/qca8k.h b/drivers/net/dsa/qca8k.h +index 613fe5c50236..d146e54c8a6c 100644 +--- a/drivers/net/dsa/qca8k.h ++++ b/drivers/net/dsa/qca8k.h +@@ -40,6 +40,7 @@ + ((0x8 + (x & 0x3)) << 22) + #define QCA8K_PORT_PAD_RGMII_RX_DELAY(x) \ + ((0x10 + (x & 0x3)) << 20) ++#define QCA8K_MAX_DELAY 3 + #define QCA8K_PORT_PAD_RGMII_RX_DELAY_EN BIT(24) + #define QCA8K_PORT_PAD_SGMII_EN BIT(7) + #define QCA8K_REG_MODULE_EN 0x030 +diff --git a/drivers/net/ethernet/amazon/ena/ena_com.c b/drivers/net/ethernet/amazon/ena/ena_com.c +index 1a4ffc5d3da4..10e6053f6671 100644 +--- a/drivers/net/ethernet/amazon/ena/ena_com.c ++++ b/drivers/net/ethernet/amazon/ena/ena_com.c +@@ -2002,7 +2002,7 @@ int ena_com_set_hash_function(struct ena_com_dev *ena_dev) + if (unlikely(ret)) + return ret; + +- if (get_resp.u.flow_hash_func.supported_func & (1 << rss->hash_func)) { ++ if (!(get_resp.u.flow_hash_func.supported_func & BIT(rss->hash_func))) { + pr_err("Func hash %d isn't supported by device, abort\n", + rss->hash_func); + return -EOPNOTSUPP; +@@ -2087,6 +2087,7 @@ int ena_com_fill_hash_function(struct ena_com_dev *ena_dev, + return -EINVAL; + } + ++ rss->hash_func = func; + rc = ena_com_set_hash_function(ena_dev); + + /* Restore the old function */ +diff --git a/drivers/net/ethernet/amazon/ena/ena_ethtool.c b/drivers/net/ethernet/amazon/ena/ena_ethtool.c +index 967020fb26ee..a2f02c23fe14 100644 +--- a/drivers/net/ethernet/amazon/ena/ena_ethtool.c ++++ b/drivers/net/ethernet/amazon/ena/ena_ethtool.c +@@ -694,8 +694,8 @@ static int ena_set_rxfh(struct net_device *netdev, const u32 *indir, + if (indir) { + for (i = 0; i < ENA_RX_RSS_TABLE_SIZE; i++) { + rc = ena_com_indirect_table_fill_entry(ena_dev, +- ENA_IO_RXQ_IDX(indir[i]), +- i); ++ i, ++ ENA_IO_RXQ_IDX(indir[i])); + if (unlikely(rc)) { + netif_err(adapter, drv, netdev, + "Cannot fill indirect table (index is too large)\n"); +diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c b/drivers/net/ethernet/amazon/ena/ena_netdev.c +index d22b138c2b09..518ff393a026 100644 +--- a/drivers/net/ethernet/amazon/ena/ena_netdev.c ++++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c +@@ -1796,6 +1796,7 @@ err_setup_rx: + err_setup_tx: + ena_free_io_irq(adapter); + err_req_irq: ++ ena_del_napi(adapter); + + return rc; + } +diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_vec.c b/drivers/net/ethernet/aquantia/atlantic/aq_vec.c +index 5fecc9a099ef..bb2894a333f2 100644 +--- a/drivers/net/ethernet/aquantia/atlantic/aq_vec.c ++++ b/drivers/net/ethernet/aquantia/atlantic/aq_vec.c +@@ -310,15 +310,13 @@ irqreturn_t aq_vec_isr_legacy(int irq, void *private) + { + struct aq_vec_s *self = private; + u64 irq_mask = 0U; +- irqreturn_t err = 0; ++ int err; + +- if (!self) { +- err = -EINVAL; +- goto err_exit; +- } ++ if (!self) ++ return IRQ_NONE; + err = self->aq_hw_ops->hw_irq_read(self->aq_hw, &irq_mask); + if (err < 0) +- goto err_exit; ++ return IRQ_NONE; + + if (irq_mask) { + self->aq_hw_ops->hw_irq_disable(self->aq_hw, +@@ -326,11 +324,10 @@ irqreturn_t aq_vec_isr_legacy(int irq, void *private) + napi_schedule(&self->napi); + } else { + self->aq_hw_ops->hw_irq_enable(self->aq_hw, 1U); +- err = IRQ_NONE; ++ return IRQ_NONE; + } + +-err_exit: +- return err >= 0 ? IRQ_HANDLED : IRQ_NONE; ++ return IRQ_HANDLED; + } + + cpumask_t *aq_vec_get_affinity_mask(struct aq_vec_s *self) +diff --git a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_a0.c b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_a0.c +index b0abd187cead..b83ee74d2839 100644 +--- a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_a0.c ++++ b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_a0.c +@@ -182,8 +182,8 @@ static int hw_atl_a0_hw_rss_set(struct aq_hw_s *self, + u32 i = 0U; + u32 num_rss_queues = max(1U, self->aq_nic_cfg->num_rss_queues); + int err = 0; +- u16 bitary[(HW_ATL_A0_RSS_REDIRECTION_MAX * +- HW_ATL_A0_RSS_REDIRECTION_BITS / 16U)]; ++ u16 bitary[1 + (HW_ATL_A0_RSS_REDIRECTION_MAX * ++ HW_ATL_A0_RSS_REDIRECTION_BITS / 16U)]; + + memset(bitary, 0, sizeof(bitary)); + +diff --git a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c +index 236325f48ec9..1c1bb074f664 100644 +--- a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c ++++ b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c +@@ -183,8 +183,8 @@ static int hw_atl_b0_hw_rss_set(struct aq_hw_s *self, + u32 i = 0U; + u32 num_rss_queues = max(1U, self->aq_nic_cfg->num_rss_queues); + int err = 0; +- u16 bitary[(HW_ATL_B0_RSS_REDIRECTION_MAX * +- HW_ATL_B0_RSS_REDIRECTION_BITS / 16U)]; ++ u16 bitary[1 + (HW_ATL_B0_RSS_REDIRECTION_MAX * ++ HW_ATL_B0_RSS_REDIRECTION_BITS / 16U)]; + + memset(bitary, 0, sizeof(bitary)); + +diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c +index 79018fea7be2..69b2f99b0c19 100644 +--- a/drivers/net/ethernet/broadcom/bcmsysport.c ++++ b/drivers/net/ethernet/broadcom/bcmsysport.c +@@ -2116,7 +2116,7 @@ static int bcm_sysport_probe(struct platform_device *pdev) + + priv->phy_interface = of_get_phy_mode(dn); + /* Default to GMII interface mode */ +- if (priv->phy_interface < 0) ++ if ((int)priv->phy_interface < 0) + priv->phy_interface = PHY_INTERFACE_MODE_GMII; + + /* In the case of a fixed PHY, the DT node associated +diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +index fc8e185718a1..3c78cd1cdd6f 100644 +--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c ++++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +@@ -1667,21 +1667,19 @@ static int bnxt_flash_package_from_file(struct net_device *dev, + mutex_lock(&bp->hwrm_cmd_lock); + hwrm_err = _hwrm_send_message(bp, &install, sizeof(install), + INSTALL_PACKAGE_TIMEOUT); +- if (hwrm_err) +- goto flash_pkg_exit; +- +- if (resp->error_code) { ++ if (hwrm_err) { + u8 error_code = ((struct hwrm_err_output *)resp)->cmd_err; + +- if (error_code == NVM_INSTALL_UPDATE_CMD_ERR_CODE_FRAG_ERR) { ++ if (resp->error_code && error_code == ++ NVM_INSTALL_UPDATE_CMD_ERR_CODE_FRAG_ERR) { + install.flags |= cpu_to_le16( + NVM_INSTALL_UPDATE_REQ_FLAGS_ALLOWED_TO_DEFRAG); + hwrm_err = _hwrm_send_message(bp, &install, + sizeof(install), + INSTALL_PACKAGE_TIMEOUT); +- if (hwrm_err) +- goto flash_pkg_exit; + } ++ if (hwrm_err) ++ goto flash_pkg_exit; + } + + if (resp->result) { +@@ -2463,7 +2461,7 @@ static void bnxt_self_test(struct net_device *dev, struct ethtool_test *etest, + bool offline = false; + u8 test_results = 0; + u8 test_mask = 0; +- int rc, i; ++ int rc = 0, i; + + if (!bp->num_tests || !BNXT_SINGLE_PF(bp)) + return; +@@ -2521,9 +2519,9 @@ static void bnxt_self_test(struct net_device *dev, struct ethtool_test *etest, + } + bnxt_hwrm_phy_loopback(bp, false); + bnxt_half_close_nic(bp); +- bnxt_open_nic(bp, false, true); ++ rc = bnxt_open_nic(bp, false, true); + } +- if (bnxt_test_irq(bp)) { ++ if (rc || bnxt_test_irq(bp)) { + buf[BNXT_IRQ_TEST_IDX] = 1; + etest->flags |= ETH_TEST_FL_FAILED; + } +diff --git a/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c b/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c +index aab6fb10af94..6adf6831d120 100644 +--- a/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c ++++ b/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c +@@ -1202,7 +1202,7 @@ static int hix5hd2_dev_probe(struct platform_device *pdev) + goto err_free_mdio; + + priv->phy_mode = of_get_phy_mode(node); +- if (priv->phy_mode < 0) { ++ if ((int)priv->phy_mode < 0) { + netdev_err(ndev, "not find phy-mode\n"); + ret = -EINVAL; + goto err_mdiobus; +diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h +index 9fcfd9395424..a4c5e72d6012 100644 +--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h ++++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h +@@ -480,7 +480,7 @@ struct hclge_vport { + u16 alloc_rss_size; + + u16 qs_offset; +- u16 bw_limit; /* VSI BW Limit (0 = disabled) */ ++ u32 bw_limit; /* VSI BW Limit (0 = disabled) */ + u8 dwrr; + + int vport_id; +diff --git a/drivers/net/ethernet/ibm/ehea/ehea_main.c b/drivers/net/ethernet/ibm/ehea/ehea_main.c +index 30cbdf0fed59..373deb247ac0 100644 +--- a/drivers/net/ethernet/ibm/ehea/ehea_main.c ++++ b/drivers/net/ethernet/ibm/ehea/ehea_main.c +@@ -1475,7 +1475,7 @@ static int ehea_init_port_res(struct ehea_port *port, struct ehea_port_res *pr, + + memset(pr, 0, sizeof(struct ehea_port_res)); + +- pr->tx_bytes = rx_bytes; ++ pr->tx_bytes = tx_bytes; + pr->tx_packets = tx_packets; + pr->rx_bytes = rx_bytes; + pr->rx_packets = rx_packets; +diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +index 0edfd199937d..e4c1e6345edd 100644 +--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c ++++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +@@ -1871,13 +1871,7 @@ static void ixgbe_pull_tail(struct ixgbe_ring *rx_ring, + static void ixgbe_dma_sync_frag(struct ixgbe_ring *rx_ring, + struct sk_buff *skb) + { +- /* if the page was released unmap it, else just sync our portion */ +- if (unlikely(IXGBE_CB(skb)->page_released)) { +- dma_unmap_page_attrs(rx_ring->dev, IXGBE_CB(skb)->dma, +- ixgbe_rx_pg_size(rx_ring), +- DMA_FROM_DEVICE, +- IXGBE_RX_DMA_ATTR); +- } else if (ring_uses_build_skb(rx_ring)) { ++ if (ring_uses_build_skb(rx_ring)) { + unsigned long offset = (unsigned long)(skb->data) & ~PAGE_MASK; + + dma_sync_single_range_for_cpu(rx_ring->dev, +@@ -1894,6 +1888,14 @@ static void ixgbe_dma_sync_frag(struct ixgbe_ring *rx_ring, + skb_frag_size(frag), + DMA_FROM_DEVICE); + } ++ ++ /* If the page was released, just unmap it. */ ++ if (unlikely(IXGBE_CB(skb)->page_released)) { ++ dma_unmap_page_attrs(rx_ring->dev, IXGBE_CB(skb)->dma, ++ ixgbe_rx_pg_size(rx_ring), ++ DMA_FROM_DEVICE, ++ IXGBE_RX_DMA_ATTR); ++ } + } + + /** +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/qp.c b/drivers/net/ethernet/mellanox/mlx5/core/qp.c +index 5f091c6ea049..b92d5690287b 100644 +--- a/drivers/net/ethernet/mellanox/mlx5/core/qp.c ++++ b/drivers/net/ethernet/mellanox/mlx5/core/qp.c +@@ -44,14 +44,15 @@ static struct mlx5_core_rsc_common *mlx5_get_rsc(struct mlx5_core_dev *dev, + { + struct mlx5_qp_table *table = &dev->priv.qp_table; + struct mlx5_core_rsc_common *common; ++ unsigned long flags; + +- spin_lock(&table->lock); ++ spin_lock_irqsave(&table->lock, flags); + + common = radix_tree_lookup(&table->tree, rsn); + if (common) + atomic_inc(&common->refcount); + +- spin_unlock(&table->lock); ++ spin_unlock_irqrestore(&table->lock, flags); + + if (!common) { + mlx5_core_warn(dev, "Async event for bogus resource 0x%x\n", +diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h +index 8ab7a4f98a07..e7974ba06432 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/reg.h ++++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h +@@ -2452,7 +2452,7 @@ static inline void mlxsw_reg_qtct_pack(char *payload, u8 local_port, + * Configures the ETS elements. + */ + #define MLXSW_REG_QEEC_ID 0x400D +-#define MLXSW_REG_QEEC_LEN 0x1C ++#define MLXSW_REG_QEEC_LEN 0x20 + + MLXSW_REG_DEFINE(qeec, MLXSW_REG_QEEC_ID, MLXSW_REG_QEEC_LEN); + +@@ -2494,6 +2494,15 @@ MLXSW_ITEM32(reg, qeec, element_index, 0x04, 0, 8); + */ + MLXSW_ITEM32(reg, qeec, next_element_index, 0x08, 0, 8); + ++/* reg_qeec_mise ++ * Min shaper configuration enable. Enables configuration of the min ++ * shaper on this ETS element ++ * 0 - Disable ++ * 1 - Enable ++ * Access: RW ++ */ ++MLXSW_ITEM32(reg, qeec, mise, 0x0C, 31, 1); ++ + enum { + MLXSW_REG_QEEC_BYTES_MODE, + MLXSW_REG_QEEC_PACKETS_MODE, +@@ -2510,6 +2519,17 @@ enum { + */ + MLXSW_ITEM32(reg, qeec, pb, 0x0C, 28, 1); + ++/* The smallest permitted min shaper rate. */ ++#define MLXSW_REG_QEEC_MIS_MIN 200000 /* Kbps */ ++ ++/* reg_qeec_min_shaper_rate ++ * Min shaper information rate. ++ * For CPU port, can only be configured for port hierarchy. ++ * When in bytes mode, value is specified in units of 1000bps. ++ * Access: RW ++ */ ++MLXSW_ITEM32(reg, qeec, min_shaper_rate, 0x0C, 0, 28); ++ + /* reg_qeec_mase + * Max shaper configuration enable. Enables configuration of the max + * shaper on this ETS element. +diff --git a/drivers/net/ethernet/natsemi/sonic.c b/drivers/net/ethernet/natsemi/sonic.c +index 23821540ab07..a051dddcbd76 100644 +--- a/drivers/net/ethernet/natsemi/sonic.c ++++ b/drivers/net/ethernet/natsemi/sonic.c +@@ -221,9 +221,9 @@ static int sonic_send_packet(struct sk_buff *skb, struct net_device *dev) + + laddr = dma_map_single(lp->device, skb->data, length, DMA_TO_DEVICE); + if (!laddr) { +- printk(KERN_ERR "%s: failed to map tx DMA buffer.\n", dev->name); +- dev_kfree_skb(skb); +- return NETDEV_TX_BUSY; ++ pr_err_ratelimited("%s: failed to map tx DMA buffer.\n", dev->name); ++ dev_kfree_skb_any(skb); ++ return NETDEV_TX_OK; + } + + sonic_tda_put(dev, entry, SONIC_TD_STATUS, 0); /* clear status */ +diff --git a/drivers/net/ethernet/pasemi/pasemi_mac.c b/drivers/net/ethernet/pasemi/pasemi_mac.c +index 49591d9c2e1b..c9b4ac9d3330 100644 +--- a/drivers/net/ethernet/pasemi/pasemi_mac.c ++++ b/drivers/net/ethernet/pasemi/pasemi_mac.c +@@ -1053,7 +1053,6 @@ static int pasemi_mac_phy_init(struct net_device *dev) + + dn = pci_device_to_OF_node(mac->pdev); + phy_dn = of_parse_phandle(dn, "phy-handle", 0); +- of_node_put(phy_dn); + + mac->link = 0; + mac->speed = 0; +@@ -1062,6 +1061,7 @@ static int pasemi_mac_phy_init(struct net_device *dev) + phydev = of_phy_connect(dev, phy_dn, &pasemi_adjust_link, 0, + PHY_INTERFACE_MODE_SGMII); + ++ of_node_put(phy_dn); + if (!phydev) { + printk(KERN_ERR "%s: Could not attach to phy\n", dev->name); + return -ENODEV; +diff --git a/drivers/net/ethernet/qlogic/qed/qed_iwarp.c b/drivers/net/ethernet/qlogic/qed/qed_iwarp.c +index bb09f5a9846f..38d0f62bf037 100644 +--- a/drivers/net/ethernet/qlogic/qed/qed_iwarp.c ++++ b/drivers/net/ethernet/qlogic/qed/qed_iwarp.c +@@ -509,7 +509,8 @@ int qed_iwarp_destroy_qp(struct qed_hwfn *p_hwfn, struct qed_rdma_qp *qp) + + /* Make sure ep is closed before returning and freeing memory. */ + if (ep) { +- while (ep->state != QED_IWARP_EP_CLOSED && wait_count++ < 200) ++ while (READ_ONCE(ep->state) != QED_IWARP_EP_CLOSED && ++ wait_count++ < 200) + msleep(100); + + if (ep->state != QED_IWARP_EP_CLOSED) +@@ -991,8 +992,6 @@ qed_iwarp_mpa_complete(struct qed_hwfn *p_hwfn, + + params.ep_context = ep; + +- ep->state = QED_IWARP_EP_CLOSED; +- + switch (fw_return_code) { + case RDMA_RETURN_OK: + ep->qp->max_rd_atomic_req = ep->cm_info.ord; +@@ -1052,6 +1051,10 @@ qed_iwarp_mpa_complete(struct qed_hwfn *p_hwfn, + break; + } + ++ if (fw_return_code != RDMA_RETURN_OK) ++ /* paired with READ_ONCE in destroy_qp */ ++ smp_store_release(&ep->state, QED_IWARP_EP_CLOSED); ++ + ep->event_cb(ep->cb_context, ¶ms); + + /* on passive side, if there is no associated QP (REJECT) we need to +@@ -2069,7 +2072,9 @@ void qed_iwarp_qp_in_error(struct qed_hwfn *p_hwfn, + params.status = (fw_return_code == IWARP_QP_IN_ERROR_GOOD_CLOSE) ? + 0 : -ECONNRESET; + +- ep->state = QED_IWARP_EP_CLOSED; ++ /* paired with READ_ONCE in destroy_qp */ ++ smp_store_release(&ep->state, QED_IWARP_EP_CLOSED); ++ + spin_lock_bh(&p_hwfn->p_rdma_info->iwarp.iw_lock); + list_del(&ep->list_entry); + spin_unlock_bh(&p_hwfn->p_rdma_info->iwarp.iw_lock); +@@ -2157,7 +2162,8 @@ qed_iwarp_tcp_connect_unsuccessful(struct qed_hwfn *p_hwfn, + params.event = QED_IWARP_EVENT_ACTIVE_COMPLETE; + params.ep_context = ep; + params.cm_info = &ep->cm_info; +- ep->state = QED_IWARP_EP_CLOSED; ++ /* paired with READ_ONCE in destroy_qp */ ++ smp_store_release(&ep->state, QED_IWARP_EP_CLOSED); + + switch (fw_return_code) { + case IWARP_CONN_ERROR_TCP_CONNECT_INVALID_PACKET: +diff --git a/drivers/net/ethernet/qlogic/qed/qed_l2.c b/drivers/net/ethernet/qlogic/qed/qed_l2.c +index 62cde3854a5c..5d7adedac68d 100644 +--- a/drivers/net/ethernet/qlogic/qed/qed_l2.c ++++ b/drivers/net/ethernet/qlogic/qed/qed_l2.c +@@ -1629,10 +1629,9 @@ static void __qed_get_vport_pstats_addrlen(struct qed_hwfn *p_hwfn, + } + } + +-static void __qed_get_vport_pstats(struct qed_hwfn *p_hwfn, +- struct qed_ptt *p_ptt, +- struct qed_eth_stats *p_stats, +- u16 statistics_bin) ++static noinline_for_stack void ++__qed_get_vport_pstats(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt, ++ struct qed_eth_stats *p_stats, u16 statistics_bin) + { + struct eth_pstorm_per_queue_stat pstats; + u32 pstats_addr = 0, pstats_len = 0; +@@ -1659,10 +1658,9 @@ static void __qed_get_vport_pstats(struct qed_hwfn *p_hwfn, + HILO_64_REGPAIR(pstats.error_drop_pkts); + } + +-static void __qed_get_vport_tstats(struct qed_hwfn *p_hwfn, +- struct qed_ptt *p_ptt, +- struct qed_eth_stats *p_stats, +- u16 statistics_bin) ++static noinline_for_stack void ++__qed_get_vport_tstats(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt, ++ struct qed_eth_stats *p_stats, u16 statistics_bin) + { + struct tstorm_per_port_stat tstats; + u32 tstats_addr, tstats_len; +@@ -1705,10 +1703,9 @@ static void __qed_get_vport_ustats_addrlen(struct qed_hwfn *p_hwfn, + } + } + +-static void __qed_get_vport_ustats(struct qed_hwfn *p_hwfn, +- struct qed_ptt *p_ptt, +- struct qed_eth_stats *p_stats, +- u16 statistics_bin) ++static noinline_for_stack ++void __qed_get_vport_ustats(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt, ++ struct qed_eth_stats *p_stats, u16 statistics_bin) + { + struct eth_ustorm_per_queue_stat ustats; + u32 ustats_addr = 0, ustats_len = 0; +@@ -1747,10 +1744,9 @@ static void __qed_get_vport_mstats_addrlen(struct qed_hwfn *p_hwfn, + } + } + +-static void __qed_get_vport_mstats(struct qed_hwfn *p_hwfn, +- struct qed_ptt *p_ptt, +- struct qed_eth_stats *p_stats, +- u16 statistics_bin) ++static noinline_for_stack void ++__qed_get_vport_mstats(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt, ++ struct qed_eth_stats *p_stats, u16 statistics_bin) + { + struct eth_mstorm_per_queue_stat mstats; + u32 mstats_addr = 0, mstats_len = 0; +@@ -1776,9 +1772,9 @@ static void __qed_get_vport_mstats(struct qed_hwfn *p_hwfn, + HILO_64_REGPAIR(mstats.tpa_coalesced_bytes); + } + +-static void __qed_get_vport_port_stats(struct qed_hwfn *p_hwfn, +- struct qed_ptt *p_ptt, +- struct qed_eth_stats *p_stats) ++static noinline_for_stack void ++__qed_get_vport_port_stats(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt, ++ struct qed_eth_stats *p_stats) + { + struct qed_eth_stats_common *p_common = &p_stats->common; + struct port_stats port_stats; +diff --git a/drivers/net/ethernet/qualcomm/qca_spi.c b/drivers/net/ethernet/qualcomm/qca_spi.c +index 275fc6f154a7..1c87178fc485 100644 +--- a/drivers/net/ethernet/qualcomm/qca_spi.c ++++ b/drivers/net/ethernet/qualcomm/qca_spi.c +@@ -475,7 +475,6 @@ qcaspi_qca7k_sync(struct qcaspi *qca, int event) + u16 signature = 0; + u16 spi_config; + u16 wrbuf_space = 0; +- static u16 reset_count; + + if (event == QCASPI_EVENT_CPUON) { + /* Read signature twice, if not valid +@@ -528,13 +527,13 @@ qcaspi_qca7k_sync(struct qcaspi *qca, int event) + + qca->sync = QCASPI_SYNC_RESET; + qca->stats.trig_reset++; +- reset_count = 0; ++ qca->reset_count = 0; + break; + case QCASPI_SYNC_RESET: +- reset_count++; ++ qca->reset_count++; + netdev_dbg(qca->net_dev, "sync: waiting for CPU on, count %u.\n", +- reset_count); +- if (reset_count >= QCASPI_RESET_TIMEOUT) { ++ qca->reset_count); ++ if (qca->reset_count >= QCASPI_RESET_TIMEOUT) { + /* reset did not seem to take place, try again */ + qca->sync = QCASPI_SYNC_UNKNOWN; + qca->stats.reset_timeout++; +diff --git a/drivers/net/ethernet/qualcomm/qca_spi.h b/drivers/net/ethernet/qualcomm/qca_spi.h +index fc0e98726b36..719c41227f22 100644 +--- a/drivers/net/ethernet/qualcomm/qca_spi.h ++++ b/drivers/net/ethernet/qualcomm/qca_spi.h +@@ -92,6 +92,7 @@ struct qcaspi { + + unsigned int intr_req; + unsigned int intr_svc; ++ u16 reset_count; + + #ifdef CONFIG_DEBUG_FS + struct dentry *device_root; +diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c +index 9b1906a65e11..25f3b2ad26e9 100644 +--- a/drivers/net/ethernet/renesas/sh_eth.c ++++ b/drivers/net/ethernet/renesas/sh_eth.c +@@ -3046,12 +3046,16 @@ static struct sh_eth_plat_data *sh_eth_parse_dt(struct device *dev) + struct device_node *np = dev->of_node; + struct sh_eth_plat_data *pdata; + const char *mac_addr; ++ int ret; + + pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); + if (!pdata) + return NULL; + +- pdata->phy_interface = of_get_phy_mode(np); ++ ret = of_get_phy_mode(np); ++ if (ret < 0) ++ return NULL; ++ pdata->phy_interface = ret; + + mac_addr = of_get_mac_address(np); + if (mac_addr) +diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c +index 866444b6c82f..11a4a81b0397 100644 +--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c ++++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c +@@ -203,7 +203,7 @@ static int ipq806x_gmac_of_parse(struct ipq806x_gmac *gmac) + struct device *dev = &gmac->pdev->dev; + + gmac->phy_mode = of_get_phy_mode(dev->of_node); +- if (gmac->phy_mode < 0) { ++ if ((int)gmac->phy_mode < 0) { + dev_err(dev, "missing phy mode property\n"); + return -EINVAL; + } +diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c +index 8be4b32544ef..d71d3c1c85ee 100644 +--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c ++++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c +@@ -285,7 +285,7 @@ static int meson8b_dwmac_probe(struct platform_device *pdev) + + dwmac->pdev = pdev; + dwmac->phy_mode = of_get_phy_mode(pdev->dev.of_node); +- if (dwmac->phy_mode < 0) { ++ if ((int)dwmac->phy_mode < 0) { + dev_err(&pdev->dev, "missing phy-mode property\n"); + ret = -EINVAL; + goto err_remove_config_dt; +diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +index 8445af580cb6..e5566c121525 100644 +--- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c ++++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +@@ -438,7 +438,7 @@ static void dwmac4_set_filter(struct mac_device_info *hw, + } + + /* Handle multiple unicast addresses */ +- if (netdev_uc_count(dev) > GMAC_MAX_PERFECT_ADDRESSES) { ++ if (netdev_uc_count(dev) > hw->unicast_filter_entries) { + /* Switch to promiscuous mode if more than 128 addrs + * are required + */ +diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c +index e471a903c654..1c1d6a942822 100644 +--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c ++++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c +@@ -154,7 +154,7 @@ static int stmmac_enable(struct ptp_clock_info *ptp, + /* structure describing a PTP hardware clock */ + static const struct ptp_clock_info stmmac_ptp_clock_ops = { + .owner = THIS_MODULE, +- .name = "stmmac_ptp_clock", ++ .name = "stmmac ptp", + .max_adj = 62500000, + .n_alarm = 0, + .n_ext_ts = 0, +diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c +index 9ccd08a051f6..1152d74433f6 100644 +--- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c ++++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c +@@ -1574,7 +1574,7 @@ static int axienet_probe(struct platform_device *pdev) + } + } else { + lp->phy_mode = of_get_phy_mode(pdev->dev.of_node); +- if (lp->phy_mode < 0) { ++ if ((int)lp->phy_mode < 0) { + ret = -EINVAL; + goto free_netdev; + } +diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c +index a89de5752a8c..14451e14d99d 100644 +--- a/drivers/net/hyperv/netvsc_drv.c ++++ b/drivers/net/hyperv/netvsc_drv.c +@@ -282,9 +282,9 @@ static inline u32 netvsc_get_hash( + else if (flow.basic.n_proto == htons(ETH_P_IPV6)) + hash = jhash2((u32 *)&flow.addrs.v6addrs, 8, hashrnd); + else +- hash = 0; ++ return 0; + +- skb_set_hash(skb, hash, PKT_HASH_TYPE_L3); ++ __skb_set_sw_hash(skb, hash, false); + } + + return hash; +@@ -802,8 +802,7 @@ static struct sk_buff *netvsc_alloc_recv_skb(struct net_device *net, + skb->protocol == htons(ETH_P_IP)) + netvsc_comp_ipcsum(skb); + +- /* Do L4 checksum offload if enabled and present. +- */ ++ /* Do L4 checksum offload if enabled and present. */ + if (csum_info && (net->features & NETIF_F_RXCSUM)) { + if (csum_info->receive.tcp_checksum_succeeded || + csum_info->receive.udp_checksum_succeeded) +@@ -1840,6 +1839,12 @@ static rx_handler_result_t netvsc_vf_handle_frame(struct sk_buff **pskb) + struct netvsc_vf_pcpu_stats *pcpu_stats + = this_cpu_ptr(ndev_ctx->vf_stats); + ++ skb = skb_share_check(skb, GFP_ATOMIC); ++ if (unlikely(!skb)) ++ return RX_HANDLER_CONSUMED; ++ ++ *pskb = skb; ++ + skb->dev = ndev; + + u64_stats_update_begin(&pcpu_stats->syncp); +diff --git a/drivers/net/phy/fixed_phy.c b/drivers/net/phy/fixed_phy.c +index eb5167210681..3ab2eb677a59 100644 +--- a/drivers/net/phy/fixed_phy.c ++++ b/drivers/net/phy/fixed_phy.c +@@ -67,11 +67,11 @@ static int fixed_mdio_read(struct mii_bus *bus, int phy_addr, int reg_num) + do { + s = read_seqcount_begin(&fp->seqcount); + /* Issue callback if user registered it. */ +- if (fp->link_update) { ++ if (fp->link_update) + fp->link_update(fp->phydev->attached_dev, + &fp->status); +- fixed_phy_update(fp); +- } ++ /* Check the GPIO for change in status */ ++ fixed_phy_update(fp); + state = fp->status; + } while (read_seqcount_retry(&fp->seqcount, s)); + +diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c +index a98c227a4c2e..99dae55cd334 100644 +--- a/drivers/net/phy/phy_device.c ++++ b/drivers/net/phy/phy_device.c +@@ -76,7 +76,7 @@ static LIST_HEAD(phy_fixup_list); + static DEFINE_MUTEX(phy_fixup_lock); + + #ifdef CONFIG_PM +-static bool mdio_bus_phy_may_suspend(struct phy_device *phydev) ++static bool mdio_bus_phy_may_suspend(struct phy_device *phydev, bool suspend) + { + struct device_driver *drv = phydev->mdio.dev.driver; + struct phy_driver *phydrv = to_phy_driver(drv); +@@ -88,10 +88,11 @@ static bool mdio_bus_phy_may_suspend(struct phy_device *phydev) + /* PHY not attached? May suspend if the PHY has not already been + * suspended as part of a prior call to phy_disconnect() -> + * phy_detach() -> phy_suspend() because the parent netdev might be the +- * MDIO bus driver and clock gated at this point. ++ * MDIO bus driver and clock gated at this point. Also may resume if ++ * PHY is not attached. + */ + if (!netdev) +- return !phydev->suspended; ++ return suspend ? !phydev->suspended : phydev->suspended; + + /* Don't suspend PHY if the attached netdev parent may wakeup. + * The parent may point to a PCI device, as in tg3 driver. +@@ -121,7 +122,7 @@ static int mdio_bus_phy_suspend(struct device *dev) + if (phydev->attached_dev && phydev->adjust_link) + phy_stop_machine(phydev); + +- if (!mdio_bus_phy_may_suspend(phydev)) ++ if (!mdio_bus_phy_may_suspend(phydev, true)) + return 0; + + return phy_suspend(phydev); +@@ -132,7 +133,7 @@ static int mdio_bus_phy_resume(struct device *dev) + struct phy_device *phydev = to_phy_device(dev); + int ret; + +- if (!mdio_bus_phy_may_suspend(phydev)) ++ if (!mdio_bus_phy_may_suspend(phydev, false)) + goto no_resume; + + ret = phy_resume(phydev); +diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c +index 5aa7d5091f4d..4d97a7b5fe3c 100644 +--- a/drivers/net/vxlan.c ++++ b/drivers/net/vxlan.c +@@ -3494,7 +3494,6 @@ static int vxlan_changelink(struct net_device *dev, struct nlattr *tb[], + struct vxlan_rdst *dst = &vxlan->default_dst; + struct vxlan_rdst old_dst; + struct vxlan_config conf; +- struct vxlan_fdb *f = NULL; + int err; + + err = vxlan_nl2conf(tb, data, +@@ -3520,19 +3519,19 @@ static int vxlan_changelink(struct net_device *dev, struct nlattr *tb[], + old_dst.remote_ifindex, 0); + + if (!vxlan_addr_any(&dst->remote_ip)) { +- err = vxlan_fdb_create(vxlan, all_zeros_mac, ++ err = vxlan_fdb_update(vxlan, all_zeros_mac, + &dst->remote_ip, + NUD_REACHABLE | NUD_PERMANENT, ++ NLM_F_APPEND | NLM_F_CREATE, + vxlan->cfg.dst_port, + dst->remote_vni, + dst->remote_vni, + dst->remote_ifindex, +- NTF_SELF, &f); ++ NTF_SELF); + if (err) { + spin_unlock_bh(&vxlan->hash_lock); + return err; + } +- vxlan_fdb_notify(vxlan, f, first_remote_rtnl(f), RTM_NEWNEIGH); + } + spin_unlock_bh(&vxlan->hash_lock); + } +diff --git a/drivers/net/wireless/ath/ath10k/sdio.c b/drivers/net/wireless/ath/ath10k/sdio.c +index 0a1248ebccf5..f49b21b137c1 100644 +--- a/drivers/net/wireless/ath/ath10k/sdio.c ++++ b/drivers/net/wireless/ath/ath10k/sdio.c +@@ -392,16 +392,11 @@ static int ath10k_sdio_mbox_rx_process_packet(struct ath10k *ar, + struct ath10k_htc_hdr *htc_hdr = (struct ath10k_htc_hdr *)skb->data; + bool trailer_present = htc_hdr->flags & ATH10K_HTC_FLAG_TRAILER_PRESENT; + enum ath10k_htc_ep_id eid; +- u16 payload_len; + u8 *trailer; + int ret; + +- payload_len = le16_to_cpu(htc_hdr->len); +- skb->len = payload_len + sizeof(struct ath10k_htc_hdr); +- + if (trailer_present) { +- trailer = skb->data + sizeof(*htc_hdr) + +- payload_len - htc_hdr->trailer_len; ++ trailer = skb->data + skb->len - htc_hdr->trailer_len; + + eid = pipe_id_to_eid(htc_hdr->eid); + +@@ -635,13 +630,31 @@ static int ath10k_sdio_mbox_rx_packet(struct ath10k *ar, + { + struct ath10k_sdio *ar_sdio = ath10k_sdio_priv(ar); + struct sk_buff *skb = pkt->skb; ++ struct ath10k_htc_hdr *htc_hdr; + int ret; + + ret = ath10k_sdio_readsb(ar, ar_sdio->mbox_info.htc_addr, + skb->data, pkt->alloc_len); ++ if (ret) ++ goto out; ++ ++ /* Update actual length. The original length may be incorrect, ++ * as the FW will bundle multiple packets as long as their sizes ++ * fit within the same aligned length (pkt->alloc_len). ++ */ ++ htc_hdr = (struct ath10k_htc_hdr *)skb->data; ++ pkt->act_len = le16_to_cpu(htc_hdr->len) + sizeof(*htc_hdr); ++ if (pkt->act_len > pkt->alloc_len) { ++ ath10k_warn(ar, "rx packet too large (%zu > %zu)\n", ++ pkt->act_len, pkt->alloc_len); ++ ret = -EMSGSIZE; ++ goto out; ++ } ++ ++ skb_put(skb, pkt->act_len); ++ ++out: + pkt->status = ret; +- if (!ret) +- skb_put(skb, pkt->act_len); + + return ret; + } +diff --git a/drivers/net/wireless/ath/ath9k/dynack.c b/drivers/net/wireless/ath/ath9k/dynack.c +index 6e236a485431..71b4888b30e7 100644 +--- a/drivers/net/wireless/ath/ath9k/dynack.c ++++ b/drivers/net/wireless/ath/ath9k/dynack.c +@@ -300,9 +300,9 @@ void ath_dynack_node_init(struct ath_hw *ah, struct ath_node *an) + + an->ackto = ackto; + +- spin_lock(&da->qlock); ++ spin_lock_bh(&da->qlock); + list_add_tail(&an->list, &da->nodes); +- spin_unlock(&da->qlock); ++ spin_unlock_bh(&da->qlock); + } + EXPORT_SYMBOL(ath_dynack_node_init); + +@@ -316,9 +316,9 @@ void ath_dynack_node_deinit(struct ath_hw *ah, struct ath_node *an) + { + struct ath_dynack *da = &ah->dynack; + +- spin_lock(&da->qlock); ++ spin_lock_bh(&da->qlock); + list_del(&an->list); +- spin_unlock(&da->qlock); ++ spin_unlock_bh(&da->qlock); + } + EXPORT_SYMBOL(ath_dynack_node_deinit); + +diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/fw.c b/drivers/net/wireless/intel/iwlwifi/mvm/fw.c +index 78228f870f8f..754dcc1c1f40 100644 +--- a/drivers/net/wireless/intel/iwlwifi/mvm/fw.c ++++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw.c +@@ -107,12 +107,12 @@ static int iwl_send_rss_cfg_cmd(struct iwl_mvm *mvm) + int i; + struct iwl_rss_config_cmd cmd = { + .flags = cpu_to_le32(IWL_RSS_ENABLE), +- .hash_mask = IWL_RSS_HASH_TYPE_IPV4_TCP | +- IWL_RSS_HASH_TYPE_IPV4_UDP | +- IWL_RSS_HASH_TYPE_IPV4_PAYLOAD | +- IWL_RSS_HASH_TYPE_IPV6_TCP | +- IWL_RSS_HASH_TYPE_IPV6_UDP | +- IWL_RSS_HASH_TYPE_IPV6_PAYLOAD, ++ .hash_mask = BIT(IWL_RSS_HASH_TYPE_IPV4_TCP) | ++ BIT(IWL_RSS_HASH_TYPE_IPV4_UDP) | ++ BIT(IWL_RSS_HASH_TYPE_IPV4_PAYLOAD) | ++ BIT(IWL_RSS_HASH_TYPE_IPV6_TCP) | ++ BIT(IWL_RSS_HASH_TYPE_IPV6_UDP) | ++ BIT(IWL_RSS_HASH_TYPE_IPV6_PAYLOAD), + }; + + if (mvm->trans->num_rx_queues == 1) +diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c b/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c +index 7fb8bbaf2142..1a12e829e98b 100644 +--- a/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c ++++ b/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c +@@ -871,12 +871,12 @@ void iwl_mvm_rx_mpdu_mq(struct iwl_mvm *mvm, struct napi_struct *napi, + bool toggle_bit = phy_info & IWL_RX_MPDU_PHY_AMPDU_TOGGLE; + + rx_status->flag |= RX_FLAG_AMPDU_DETAILS; +- rx_status->ampdu_reference = mvm->ampdu_ref; + /* toggle is switched whenever new aggregation starts */ + if (toggle_bit != mvm->ampdu_toggle) { + mvm->ampdu_ref++; + mvm->ampdu_toggle = toggle_bit; + } ++ rx_status->ampdu_reference = mvm->ampdu_ref; + } + + rcu_read_lock(); +diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/sta.c b/drivers/net/wireless/intel/iwlwifi/mvm/sta.c +index 0cfdbaa2af3a..684c0f65a052 100644 +--- a/drivers/net/wireless/intel/iwlwifi/mvm/sta.c ++++ b/drivers/net/wireless/intel/iwlwifi/mvm/sta.c +@@ -2417,7 +2417,7 @@ int iwl_mvm_sta_tx_agg_start(struct iwl_mvm *mvm, struct ieee80211_vif *vif, + struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta); + struct iwl_mvm_tid_data *tid_data; + u16 normalized_ssn; +- int txq_id; ++ u16 txq_id; + int ret; + + if (WARN_ON_ONCE(tid >= IWL_MAX_TID_COUNT)) +@@ -2452,17 +2452,24 @@ int iwl_mvm_sta_tx_agg_start(struct iwl_mvm *mvm, struct ieee80211_vif *vif, + */ + txq_id = mvmsta->tid_data[tid].txq_id; + if (txq_id == IWL_MVM_INVALID_QUEUE) { +- txq_id = iwl_mvm_find_free_queue(mvm, mvmsta->sta_id, +- IWL_MVM_DQA_MIN_DATA_QUEUE, +- IWL_MVM_DQA_MAX_DATA_QUEUE); +- if (txq_id < 0) { +- ret = txq_id; ++ ret = iwl_mvm_find_free_queue(mvm, mvmsta->sta_id, ++ IWL_MVM_DQA_MIN_DATA_QUEUE, ++ IWL_MVM_DQA_MAX_DATA_QUEUE); ++ if (ret < 0) { + IWL_ERR(mvm, "Failed to allocate agg queue\n"); + goto release_locks; + } + ++ txq_id = ret; ++ + /* TXQ hasn't yet been enabled, so mark it only as reserved */ + mvm->queue_info[txq_id].status = IWL_MVM_QUEUE_RESERVED; ++ } else if (WARN_ON(txq_id >= IWL_MAX_HW_QUEUES)) { ++ ret = -ENXIO; ++ IWL_ERR(mvm, "tid_id %d out of range (0, %d)!\n", ++ tid, IWL_MAX_HW_QUEUES - 1); ++ goto out; ++ + } else if (unlikely(mvm->queue_info[txq_id].status == + IWL_MVM_QUEUE_SHARED)) { + ret = -ENXIO; +diff --git a/drivers/net/wireless/marvell/libertas_tf/cmd.c b/drivers/net/wireless/marvell/libertas_tf/cmd.c +index 909ac3685010..2b193f1257a5 100644 +--- a/drivers/net/wireless/marvell/libertas_tf/cmd.c ++++ b/drivers/net/wireless/marvell/libertas_tf/cmd.c +@@ -69,7 +69,7 @@ static void lbtf_geo_init(struct lbtf_private *priv) + break; + } + +- for (ch = priv->range.start; ch < priv->range.end; ch++) ++ for (ch = range->start; ch < range->end; ch++) + priv->channels[CHAN_TO_IDX(ch)].flags = 0; + } + +diff --git a/drivers/net/wireless/mediatek/mt7601u/phy.c b/drivers/net/wireless/mediatek/mt7601u/phy.c +index ca09a5d4305e..71a47459bf8a 100644 +--- a/drivers/net/wireless/mediatek/mt7601u/phy.c ++++ b/drivers/net/wireless/mediatek/mt7601u/phy.c +@@ -221,7 +221,7 @@ int mt7601u_wait_bbp_ready(struct mt7601u_dev *dev) + + do { + val = mt7601u_bbp_rr(dev, MT_BBP_REG_VERSION); +- if (val && ~val) ++ if (val && val != 0xff) + break; + } while (--i); + +diff --git a/drivers/ntb/hw/idt/ntb_hw_idt.c b/drivers/ntb/hw/idt/ntb_hw_idt.c +index d44d7ef38fe8..b68e2cad74cc 100644 +--- a/drivers/ntb/hw/idt/ntb_hw_idt.c ++++ b/drivers/ntb/hw/idt/ntb_hw_idt.c +@@ -1105,9 +1105,9 @@ static struct idt_mw_cfg *idt_scan_mws(struct idt_ntb_dev *ndev, int port, + } + + /* Allocate memory for memory window descriptors */ +- ret_mws = devm_kcalloc(&ndev->ntb.pdev->dev, *mw_cnt, +- sizeof(*ret_mws), GFP_KERNEL); +- if (IS_ERR_OR_NULL(ret_mws)) ++ ret_mws = devm_kcalloc(&ndev->ntb.pdev->dev, *mw_cnt, sizeof(*ret_mws), ++ GFP_KERNEL); ++ if (!ret_mws) + return ERR_PTR(-ENOMEM); + + /* Copy the info of detected memory windows */ +@@ -2393,7 +2393,7 @@ static struct idt_ntb_dev *idt_create_dev(struct pci_dev *pdev, + + /* Allocate memory for the IDT PCIe-device descriptor */ + ndev = devm_kzalloc(&pdev->dev, sizeof(*ndev), GFP_KERNEL); +- if (IS_ERR_OR_NULL(ndev)) { ++ if (!ndev) { + dev_err(&pdev->dev, "Memory allocation failed for descriptor"); + return ERR_PTR(-ENOMEM); + } +diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c +index cd11cced3678..3788c053a0b1 100644 +--- a/drivers/nvme/host/pci.c ++++ b/drivers/nvme/host/pci.c +@@ -2274,7 +2274,7 @@ static int nvme_pci_reg_write32(struct nvme_ctrl *ctrl, u32 off, u32 val) + + static int nvme_pci_reg_read64(struct nvme_ctrl *ctrl, u32 off, u64 *val) + { +- *val = readq(to_nvme_dev(ctrl)->bar + off); ++ *val = lo_hi_readq(to_nvme_dev(ctrl)->bar + off); + return 0; + } + +diff --git a/drivers/nvmem/imx-ocotp.c b/drivers/nvmem/imx-ocotp.c +index 193ca8fd350a..0c8c3b9bb6a7 100644 +--- a/drivers/nvmem/imx-ocotp.c ++++ b/drivers/nvmem/imx-ocotp.c +@@ -199,7 +199,8 @@ static int imx_ocotp_write(void *context, unsigned int offset, void *val, + strobe_prog = clk_rate / (1000000000 / 10000) + 2 * (DEF_RELAX + 1) - 1; + strobe_read = clk_rate / (1000000000 / 40) + 2 * (DEF_RELAX + 1) - 1; + +- timing = strobe_prog & 0x00000FFF; ++ timing = readl(priv->base + IMX_OCOTP_ADDR_TIMING) & 0x0FC00000; ++ timing |= strobe_prog & 0x00000FFF; + timing |= (relax << 12) & 0x0000F000; + timing |= (strobe_read << 16) & 0x003F0000; + +diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c +index 8c1819230ed2..fe26697d3bd7 100644 +--- a/drivers/of/of_mdio.c ++++ b/drivers/of/of_mdio.c +@@ -358,7 +358,7 @@ struct phy_device *of_phy_get_and_connect(struct net_device *dev, + struct phy_device *phy; + + iface = of_get_phy_mode(np); +- if (iface < 0) ++ if ((int)iface < 0) + return NULL; + + phy_np = of_parse_phandle(np, "phy-handle", 0); +diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c b/drivers/pci/endpoint/functions/pci-epf-test.c +index f9308c2f22e6..c2541a772abc 100644 +--- a/drivers/pci/endpoint/functions/pci-epf-test.c ++++ b/drivers/pci/endpoint/functions/pci-epf-test.c +@@ -177,7 +177,7 @@ static int pci_epf_test_read(struct pci_epf_test *epf_test) + goto err_map_addr; + } + +- memcpy(buf, src_addr, reg->size); ++ memcpy_fromio(buf, src_addr, reg->size); + + crc32 = crc32_le(~0, buf, reg->size); + if (crc32 != reg->checksum) +@@ -231,7 +231,7 @@ static int pci_epf_test_write(struct pci_epf_test *epf_test) + get_random_bytes(buf, reg->size); + reg->checksum = crc32_le(~0, buf, reg->size); + +- memcpy(dst_addr, buf, reg->size); ++ memcpy_toio(dst_addr, buf, reg->size); + + /* + * wait 1ms inorder for the write to complete. Without this delay L3 +diff --git a/drivers/pci/host/pcie-iproc.c b/drivers/pci/host/pcie-iproc.c +index c0ecc9f35667..8f8dac0155d6 100644 +--- a/drivers/pci/host/pcie-iproc.c ++++ b/drivers/pci/host/pcie-iproc.c +@@ -573,14 +573,6 @@ static void __iomem *iproc_pcie_map_cfg_bus(struct iproc_pcie *pcie, + return (pcie->base + offset); + } + +- /* +- * PAXC is connected to an internally emulated EP within the SoC. It +- * allows only one device. +- */ +- if (pcie->ep_is_internal) +- if (slot > 0) +- return NULL; +- + return iproc_pcie_map_ep_cfg_reg(pcie, busno, slot, fn, where); + } + +diff --git a/drivers/pci/switch/switchtec.c b/drivers/pci/switch/switchtec.c +index 0941555b84a5..73dba2739849 100644 +--- a/drivers/pci/switch/switchtec.c ++++ b/drivers/pci/switch/switchtec.c +@@ -399,10 +399,6 @@ static void mrpc_cmd_submit(struct switchtec_dev *stdev) + stuser->data, stuser->data_len); + iowrite32(stuser->cmd, &stdev->mmio_mrpc->cmd); + +- stuser->status = ioread32(&stdev->mmio_mrpc->status); +- if (stuser->status != SWITCHTEC_MRPC_STATUS_INPROGRESS) +- mrpc_complete_cmd(stdev); +- + schedule_delayed_work(&stdev->mrpc_timeout, + msecs_to_jiffies(500)); + } +diff --git a/drivers/pinctrl/bcm/pinctrl-iproc-gpio.c b/drivers/pinctrl/bcm/pinctrl-iproc-gpio.c +index 85a8c97d9dfe..5fe419e468ec 100644 +--- a/drivers/pinctrl/bcm/pinctrl-iproc-gpio.c ++++ b/drivers/pinctrl/bcm/pinctrl-iproc-gpio.c +@@ -54,8 +54,12 @@ + /* drive strength control for ASIU GPIO */ + #define IPROC_GPIO_ASIU_DRV0_CTRL_OFFSET 0x58 + +-/* drive strength control for CCM/CRMU (AON) GPIO */ +-#define IPROC_GPIO_DRV0_CTRL_OFFSET 0x00 ++/* pinconf for CCM GPIO */ ++#define IPROC_GPIO_PULL_DN_OFFSET 0x10 ++#define IPROC_GPIO_PULL_UP_OFFSET 0x14 ++ ++/* pinconf for CRMU(aon) GPIO and CCM GPIO*/ ++#define IPROC_GPIO_DRV_CTRL_OFFSET 0x00 + + #define GPIO_BANK_SIZE 0x200 + #define NGPIOS_PER_BANK 32 +@@ -76,6 +80,12 @@ enum iproc_pinconf_param { + IPROC_PINCON_MAX, + }; + ++enum iproc_pinconf_ctrl_type { ++ IOCTRL_TYPE_AON = 1, ++ IOCTRL_TYPE_CDRU, ++ IOCTRL_TYPE_INVALID, ++}; ++ + /* + * Iproc GPIO core + * +@@ -100,6 +110,7 @@ struct iproc_gpio { + + void __iomem *base; + void __iomem *io_ctrl; ++ enum iproc_pinconf_ctrl_type io_ctrl_type; + + raw_spinlock_t lock; + +@@ -461,20 +472,44 @@ static const struct pinctrl_ops iproc_pctrl_ops = { + static int iproc_gpio_set_pull(struct iproc_gpio *chip, unsigned gpio, + bool disable, bool pull_up) + { ++ void __iomem *base; + unsigned long flags; ++ unsigned int shift; ++ u32 val_1, val_2; + + raw_spin_lock_irqsave(&chip->lock, flags); +- +- if (disable) { +- iproc_set_bit(chip, IPROC_GPIO_RES_EN_OFFSET, gpio, false); ++ if (chip->io_ctrl_type == IOCTRL_TYPE_CDRU) { ++ base = chip->io_ctrl; ++ shift = IPROC_GPIO_SHIFT(gpio); ++ ++ val_1 = readl(base + IPROC_GPIO_PULL_UP_OFFSET); ++ val_2 = readl(base + IPROC_GPIO_PULL_DN_OFFSET); ++ if (disable) { ++ /* no pull-up or pull-down */ ++ val_1 &= ~BIT(shift); ++ val_2 &= ~BIT(shift); ++ } else if (pull_up) { ++ val_1 |= BIT(shift); ++ val_2 &= ~BIT(shift); ++ } else { ++ val_1 &= ~BIT(shift); ++ val_2 |= BIT(shift); ++ } ++ writel(val_1, base + IPROC_GPIO_PULL_UP_OFFSET); ++ writel(val_2, base + IPROC_GPIO_PULL_DN_OFFSET); + } else { +- iproc_set_bit(chip, IPROC_GPIO_PAD_RES_OFFSET, gpio, +- pull_up); +- iproc_set_bit(chip, IPROC_GPIO_RES_EN_OFFSET, gpio, true); ++ if (disable) { ++ iproc_set_bit(chip, IPROC_GPIO_RES_EN_OFFSET, gpio, ++ false); ++ } else { ++ iproc_set_bit(chip, IPROC_GPIO_PAD_RES_OFFSET, gpio, ++ pull_up); ++ iproc_set_bit(chip, IPROC_GPIO_RES_EN_OFFSET, gpio, ++ true); ++ } + } + + raw_spin_unlock_irqrestore(&chip->lock, flags); +- + dev_dbg(chip->dev, "gpio:%u set pullup:%d\n", gpio, pull_up); + + return 0; +@@ -483,14 +518,35 @@ static int iproc_gpio_set_pull(struct iproc_gpio *chip, unsigned gpio, + static void iproc_gpio_get_pull(struct iproc_gpio *chip, unsigned gpio, + bool *disable, bool *pull_up) + { ++ void __iomem *base; + unsigned long flags; ++ unsigned int shift; ++ u32 val_1, val_2; + + raw_spin_lock_irqsave(&chip->lock, flags); +- *disable = !iproc_get_bit(chip, IPROC_GPIO_RES_EN_OFFSET, gpio); +- *pull_up = iproc_get_bit(chip, IPROC_GPIO_PAD_RES_OFFSET, gpio); ++ if (chip->io_ctrl_type == IOCTRL_TYPE_CDRU) { ++ base = chip->io_ctrl; ++ shift = IPROC_GPIO_SHIFT(gpio); ++ ++ val_1 = readl(base + IPROC_GPIO_PULL_UP_OFFSET) & BIT(shift); ++ val_2 = readl(base + IPROC_GPIO_PULL_DN_OFFSET) & BIT(shift); ++ ++ *pull_up = val_1 ? true : false; ++ *disable = (val_1 | val_2) ? false : true; ++ ++ } else { ++ *disable = !iproc_get_bit(chip, IPROC_GPIO_RES_EN_OFFSET, gpio); ++ *pull_up = iproc_get_bit(chip, IPROC_GPIO_PAD_RES_OFFSET, gpio); ++ } + raw_spin_unlock_irqrestore(&chip->lock, flags); + } + ++#define DRV_STRENGTH_OFFSET(gpio, bit, type) ((type) == IOCTRL_TYPE_AON ? \ ++ ((2 - (bit)) * 4 + IPROC_GPIO_DRV_CTRL_OFFSET) : \ ++ ((type) == IOCTRL_TYPE_CDRU) ? \ ++ ((bit) * 4 + IPROC_GPIO_DRV_CTRL_OFFSET) : \ ++ ((bit) * 4 + IPROC_GPIO_REG(gpio, IPROC_GPIO_ASIU_DRV0_CTRL_OFFSET))) ++ + static int iproc_gpio_set_strength(struct iproc_gpio *chip, unsigned gpio, + unsigned strength) + { +@@ -505,11 +561,8 @@ static int iproc_gpio_set_strength(struct iproc_gpio *chip, unsigned gpio, + + if (chip->io_ctrl) { + base = chip->io_ctrl; +- offset = IPROC_GPIO_DRV0_CTRL_OFFSET; + } else { + base = chip->base; +- offset = IPROC_GPIO_REG(gpio, +- IPROC_GPIO_ASIU_DRV0_CTRL_OFFSET); + } + + shift = IPROC_GPIO_SHIFT(gpio); +@@ -520,11 +573,11 @@ static int iproc_gpio_set_strength(struct iproc_gpio *chip, unsigned gpio, + raw_spin_lock_irqsave(&chip->lock, flags); + strength = (strength / 2) - 1; + for (i = 0; i < GPIO_DRV_STRENGTH_BITS; i++) { ++ offset = DRV_STRENGTH_OFFSET(gpio, i, chip->io_ctrl_type); + val = readl(base + offset); + val &= ~BIT(shift); + val |= ((strength >> i) & 0x1) << shift; + writel(val, base + offset); +- offset += 4; + } + raw_spin_unlock_irqrestore(&chip->lock, flags); + +@@ -541,11 +594,8 @@ static int iproc_gpio_get_strength(struct iproc_gpio *chip, unsigned gpio, + + if (chip->io_ctrl) { + base = chip->io_ctrl; +- offset = IPROC_GPIO_DRV0_CTRL_OFFSET; + } else { + base = chip->base; +- offset = IPROC_GPIO_REG(gpio, +- IPROC_GPIO_ASIU_DRV0_CTRL_OFFSET); + } + + shift = IPROC_GPIO_SHIFT(gpio); +@@ -553,10 +603,10 @@ static int iproc_gpio_get_strength(struct iproc_gpio *chip, unsigned gpio, + raw_spin_lock_irqsave(&chip->lock, flags); + *strength = 0; + for (i = 0; i < GPIO_DRV_STRENGTH_BITS; i++) { ++ offset = DRV_STRENGTH_OFFSET(gpio, i, chip->io_ctrl_type); + val = readl(base + offset) & BIT(shift); + val >>= shift; + *strength += (val << i); +- offset += 4; + } + + /* convert to mA */ +@@ -734,6 +784,7 @@ static int iproc_gpio_probe(struct platform_device *pdev) + u32 ngpios, pinconf_disable_mask = 0; + int irq, ret; + bool no_pinconf = false; ++ enum iproc_pinconf_ctrl_type io_ctrl_type = IOCTRL_TYPE_INVALID; + + /* NSP does not support drive strength config */ + if (of_device_is_compatible(dev->of_node, "brcm,iproc-nsp-gpio")) +@@ -764,8 +815,15 @@ static int iproc_gpio_probe(struct platform_device *pdev) + dev_err(dev, "unable to map I/O memory\n"); + return PTR_ERR(chip->io_ctrl); + } ++ if (of_device_is_compatible(dev->of_node, ++ "brcm,cygnus-ccm-gpio")) ++ io_ctrl_type = IOCTRL_TYPE_CDRU; ++ else ++ io_ctrl_type = IOCTRL_TYPE_AON; + } + ++ chip->io_ctrl_type = io_ctrl_type; ++ + if (of_property_read_u32(dev->of_node, "ngpios", &ngpios)) { + dev_err(&pdev->dev, "missing ngpios DT property\n"); + return -ENODEV; +diff --git a/drivers/pinctrl/sh-pfc/pfc-emev2.c b/drivers/pinctrl/sh-pfc/pfc-emev2.c +index 1cbbe04d7df6..eafd8edbcbe9 100644 +--- a/drivers/pinctrl/sh-pfc/pfc-emev2.c ++++ b/drivers/pinctrl/sh-pfc/pfc-emev2.c +@@ -1263,6 +1263,14 @@ static const char * const dtv_groups[] = { + "dtv_b", + }; + ++static const char * const err_rst_reqb_groups[] = { ++ "err_rst_reqb", ++}; ++ ++static const char * const ext_clki_groups[] = { ++ "ext_clki", ++}; ++ + static const char * const iic0_groups[] = { + "iic0", + }; +@@ -1285,6 +1293,10 @@ static const char * const lcd_groups[] = { + "yuv3", + }; + ++static const char * const lowpwr_groups[] = { ++ "lowpwr", ++}; ++ + static const char * const ntsc_groups[] = { + "ntsc_clk", + "ntsc_data", +@@ -1298,6 +1310,10 @@ static const char * const pwm1_groups[] = { + "pwm1", + }; + ++static const char * const ref_clko_groups[] = { ++ "ref_clko", ++}; ++ + static const char * const sd_groups[] = { + "sd_cki", + }; +@@ -1391,13 +1407,17 @@ static const struct sh_pfc_function pinmux_functions[] = { + SH_PFC_FUNCTION(cam), + SH_PFC_FUNCTION(cf), + SH_PFC_FUNCTION(dtv), ++ SH_PFC_FUNCTION(err_rst_reqb), ++ SH_PFC_FUNCTION(ext_clki), + SH_PFC_FUNCTION(iic0), + SH_PFC_FUNCTION(iic1), + SH_PFC_FUNCTION(jtag), + SH_PFC_FUNCTION(lcd), ++ SH_PFC_FUNCTION(lowpwr), + SH_PFC_FUNCTION(ntsc), + SH_PFC_FUNCTION(pwm0), + SH_PFC_FUNCTION(pwm1), ++ SH_PFC_FUNCTION(ref_clko), + SH_PFC_FUNCTION(sd), + SH_PFC_FUNCTION(sdi0), + SH_PFC_FUNCTION(sdi1), +diff --git a/drivers/pinctrl/sh-pfc/pfc-r8a7740.c b/drivers/pinctrl/sh-pfc/pfc-r8a7740.c +index 35f436bcb849..e9739dbcb356 100644 +--- a/drivers/pinctrl/sh-pfc/pfc-r8a7740.c ++++ b/drivers/pinctrl/sh-pfc/pfc-r8a7740.c +@@ -1982,7 +1982,7 @@ static const unsigned int gether_gmii_pins[] = { + */ + 185, 186, 187, 188, 189, 190, 191, 192, 174, 161, 204, + 171, 170, 169, 168, 167, 166, 173, 172, 176, 184, 183, 203, +- 205, 163, 206, 207, ++ 205, 163, 206, 207, 158, + }; + static const unsigned int gether_gmii_mux[] = { + ET_ERXD0_MARK, ET_ERXD1_MARK, ET_ERXD2_MARK, ET_ERXD3_MARK, +@@ -2154,6 +2154,7 @@ static const unsigned int lcd0_data24_1_mux[] = { + LCD0_D0_MARK, LCD0_D1_MARK, LCD0_D2_MARK, LCD0_D3_MARK, + LCD0_D4_MARK, LCD0_D5_MARK, LCD0_D6_MARK, LCD0_D7_MARK, + LCD0_D8_MARK, LCD0_D9_MARK, LCD0_D10_MARK, LCD0_D11_MARK, ++ LCD0_D12_MARK, LCD0_D13_MARK, LCD0_D14_MARK, LCD0_D15_MARK, + LCD0_D16_MARK, LCD0_D17_MARK, LCD0_D18_PORT163_MARK, + LCD0_D19_PORT162_MARK, LCD0_D20_PORT161_MARK, LCD0_D21_PORT158_MARK, + LCD0_D22_PORT160_MARK, LCD0_D23_PORT159_MARK, +diff --git a/drivers/pinctrl/sh-pfc/pfc-r8a7791.c b/drivers/pinctrl/sh-pfc/pfc-r8a7791.c +index c01ef02d326b..e4774b220040 100644 +--- a/drivers/pinctrl/sh-pfc/pfc-r8a7791.c ++++ b/drivers/pinctrl/sh-pfc/pfc-r8a7791.c +@@ -3220,8 +3220,7 @@ static const unsigned int qspi_data4_b_pins[] = { + RCAR_GP_PIN(6, 4), + }; + static const unsigned int qspi_data4_b_mux[] = { +- SPCLK_B_MARK, MOSI_IO0_B_MARK, MISO_IO1_B_MARK, +- IO2_B_MARK, IO3_B_MARK, SSL_B_MARK, ++ MOSI_IO0_B_MARK, MISO_IO1_B_MARK, IO2_B_MARK, IO3_B_MARK, + }; + /* - SCIF0 ------------------------------------------------------------------ */ + static const unsigned int scif0_data_pins[] = { +@@ -4349,17 +4348,14 @@ static const unsigned int vin1_b_data18_pins[] = { + }; + static const unsigned int vin1_b_data18_mux[] = { + /* B */ +- VI1_DATA0_B_MARK, VI1_DATA1_B_MARK, + VI1_DATA2_B_MARK, VI1_DATA3_B_MARK, + VI1_DATA4_B_MARK, VI1_DATA5_B_MARK, + VI1_DATA6_B_MARK, VI1_DATA7_B_MARK, + /* G */ +- VI1_G0_B_MARK, VI1_G1_B_MARK, + VI1_G2_B_MARK, VI1_G3_B_MARK, + VI1_G4_B_MARK, VI1_G5_B_MARK, + VI1_G6_B_MARK, VI1_G7_B_MARK, + /* R */ +- VI1_R0_B_MARK, VI1_R1_B_MARK, + VI1_R2_B_MARK, VI1_R3_B_MARK, + VI1_R4_B_MARK, VI1_R5_B_MARK, + VI1_R6_B_MARK, VI1_R7_B_MARK, +@@ -5213,7 +5209,7 @@ static const char * const scifb2_groups[] = { + "scifb2_data_b", + "scifb2_clk_b", + "scifb2_ctrl_b", +- "scifb0_data_c", ++ "scifb2_data_c", + "scifb2_clk_c", + "scifb2_data_d", + }; +diff --git a/drivers/pinctrl/sh-pfc/pfc-r8a7792.c b/drivers/pinctrl/sh-pfc/pfc-r8a7792.c +index cc3597f66605..46c41ca6ea38 100644 +--- a/drivers/pinctrl/sh-pfc/pfc-r8a7792.c ++++ b/drivers/pinctrl/sh-pfc/pfc-r8a7792.c +@@ -1916,6 +1916,7 @@ static const char * const vin1_groups[] = { + "vin1_data8", + "vin1_data24_b", + "vin1_data20_b", ++ "vin1_data18_b", + "vin1_data16_b", + "vin1_sync", + "vin1_field", +diff --git a/drivers/pinctrl/sh-pfc/pfc-r8a7794.c b/drivers/pinctrl/sh-pfc/pfc-r8a7794.c +index a0ed220071f5..93bdd3e8fb67 100644 +--- a/drivers/pinctrl/sh-pfc/pfc-r8a7794.c ++++ b/drivers/pinctrl/sh-pfc/pfc-r8a7794.c +@@ -4742,7 +4742,7 @@ static const struct pinmux_cfg_reg pinmux_config_regs[] = { + FN_AVB_MDC, FN_SSI_SDATA6_B, 0, 0, } + }, + { PINMUX_CFG_REG_VAR("IPSR9", 0xE6060044, 32, +- 1, 3, 3, 3, 3, 2, 2, 3, 3, 3, 3, 3, 3) { ++ 1, 3, 3, 3, 3, 2, 2, 3, 3, 3, 3, 3) { + /* IP9_31 [1] */ + 0, 0, + /* IP9_30_28 [3] */ +diff --git a/drivers/pinctrl/sh-pfc/pfc-r8a77995.c b/drivers/pinctrl/sh-pfc/pfc-r8a77995.c +index 4f5ee1d7317d..36421df1b326 100644 +--- a/drivers/pinctrl/sh-pfc/pfc-r8a77995.c ++++ b/drivers/pinctrl/sh-pfc/pfc-r8a77995.c +@@ -391,10 +391,10 @@ FM(IP12_31_28) IP12_31_28 \ + #define MOD_SEL0_27 FM(SEL_MSIOF3_0) FM(SEL_MSIOF3_1) + #define MOD_SEL0_26 FM(SEL_HSCIF3_0) FM(SEL_HSCIF3_1) + #define MOD_SEL0_25 FM(SEL_SCIF4_0) FM(SEL_SCIF4_1) +-#define MOD_SEL0_24_23 FM(SEL_PWM0_0) FM(SEL_PWM0_1) FM(SEL_PWM0_2) FM(SEL_PWM0_3) +-#define MOD_SEL0_22_21 FM(SEL_PWM1_0) FM(SEL_PWM1_1) FM(SEL_PWM1_2) FM(SEL_PWM1_3) +-#define MOD_SEL0_20_19 FM(SEL_PWM2_0) FM(SEL_PWM2_1) FM(SEL_PWM2_2) FM(SEL_PWM2_3) +-#define MOD_SEL0_18_17 FM(SEL_PWM3_0) FM(SEL_PWM3_1) FM(SEL_PWM3_2) FM(SEL_PWM3_3) ++#define MOD_SEL0_24_23 FM(SEL_PWM0_0) FM(SEL_PWM0_1) FM(SEL_PWM0_2) F_(0, 0) ++#define MOD_SEL0_22_21 FM(SEL_PWM1_0) FM(SEL_PWM1_1) FM(SEL_PWM1_2) F_(0, 0) ++#define MOD_SEL0_20_19 FM(SEL_PWM2_0) FM(SEL_PWM2_1) FM(SEL_PWM2_2) F_(0, 0) ++#define MOD_SEL0_18_17 FM(SEL_PWM3_0) FM(SEL_PWM3_1) FM(SEL_PWM3_2) F_(0, 0) + #define MOD_SEL0_15 FM(SEL_IRQ_0_0) FM(SEL_IRQ_0_1) + #define MOD_SEL0_14 FM(SEL_IRQ_1_0) FM(SEL_IRQ_1_1) + #define MOD_SEL0_13 FM(SEL_IRQ_2_0) FM(SEL_IRQ_2_1) +diff --git a/drivers/pinctrl/sh-pfc/pfc-sh7269.c b/drivers/pinctrl/sh-pfc/pfc-sh7269.c +index a50d22bef1f4..cfdb4fc177c3 100644 +--- a/drivers/pinctrl/sh-pfc/pfc-sh7269.c ++++ b/drivers/pinctrl/sh-pfc/pfc-sh7269.c +@@ -2119,7 +2119,7 @@ static const struct pinmux_cfg_reg pinmux_config_regs[] = { + }, + + { PINMUX_CFG_REG("PCIOR0", 0xfffe3852, 16, 1) { +- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ++ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + PC8_IN, PC8_OUT, + PC7_IN, PC7_OUT, + PC6_IN, PC6_OUT, +diff --git a/drivers/pinctrl/sh-pfc/pfc-sh73a0.c b/drivers/pinctrl/sh-pfc/pfc-sh73a0.c +index d25e6f674d0a..6dca760f9f28 100644 +--- a/drivers/pinctrl/sh-pfc/pfc-sh73a0.c ++++ b/drivers/pinctrl/sh-pfc/pfc-sh73a0.c +@@ -3086,6 +3086,7 @@ static const unsigned int tpu4_to2_mux[] = { + }; + static const unsigned int tpu4_to3_pins[] = { + /* TO */ ++ PIN_NUMBER(6, 26), + }; + static const unsigned int tpu4_to3_mux[] = { + TPU4TO3_MARK, +@@ -3366,7 +3367,8 @@ static const char * const fsic_groups[] = { + "fsic_sclk_out", + "fsic_data_in", + "fsic_data_out", +- "fsic_spdif", ++ "fsic_spdif_0", ++ "fsic_spdif_1", + }; + + static const char * const fsid_groups[] = { +diff --git a/drivers/pinctrl/sh-pfc/pfc-sh7734.c b/drivers/pinctrl/sh-pfc/pfc-sh7734.c +index 3eccc9b3ca84..c691e5e9d9de 100644 +--- a/drivers/pinctrl/sh-pfc/pfc-sh7734.c ++++ b/drivers/pinctrl/sh-pfc/pfc-sh7734.c +@@ -2231,13 +2231,13 @@ static const struct pinmux_cfg_reg pinmux_config_regs[] = { + FN_LCD_CL1_B, 0, 0, + /* IP10_5_3 [3] */ + FN_SSI_WS23, FN_VI1_5_B, FN_TX1_D, FN_HSCK0_C, FN_FALE_B, +- FN_LCD_DON_B, 0, 0, 0, ++ FN_LCD_DON_B, 0, 0, + /* IP10_2_0 [3] */ + FN_SSI_SCK23, FN_VI1_4_B, FN_RX1_D, FN_FCLE_B, + FN_LCD_DATA15_B, 0, 0, 0 } + }, + { PINMUX_CFG_REG_VAR("IPSR11", 0xFFFC0048, 32, +- 3, 1, 2, 2, 2, 3, 3, 1, 2, 3, 3, 1, 1, 1, 1) { ++ 3, 1, 2, 3, 2, 2, 3, 3, 1, 2, 3, 3, 1, 1, 1, 1) { + /* IP11_31_29 [3] */ + 0, 0, 0, 0, 0, 0, 0, 0, + /* IP11_28 [1] */ +diff --git a/drivers/platform/mips/cpu_hwmon.c b/drivers/platform/mips/cpu_hwmon.c +index 322de58eebaf..02484ae9a116 100644 +--- a/drivers/platform/mips/cpu_hwmon.c ++++ b/drivers/platform/mips/cpu_hwmon.c +@@ -158,7 +158,7 @@ static int __init loongson_hwmon_init(void) + + cpu_hwmon_dev = hwmon_device_register(NULL); + if (IS_ERR(cpu_hwmon_dev)) { +- ret = -ENOMEM; ++ ret = PTR_ERR(cpu_hwmon_dev); + pr_err("hwmon_device_register fail!\n"); + goto fail_hwmon_device_register; + } +diff --git a/drivers/platform/x86/alienware-wmi.c b/drivers/platform/x86/alienware-wmi.c +index e335b18da20f..2c82188f8486 100644 +--- a/drivers/platform/x86/alienware-wmi.c ++++ b/drivers/platform/x86/alienware-wmi.c +@@ -505,23 +505,22 @@ static acpi_status alienware_wmax_command(struct wmax_basic_args *in_args, + + input.length = (acpi_size) sizeof(*in_args); + input.pointer = in_args; +- if (out_data != NULL) { ++ if (out_data) { + output.length = ACPI_ALLOCATE_BUFFER; + output.pointer = NULL; + status = wmi_evaluate_method(WMAX_CONTROL_GUID, 0, + command, &input, &output); +- } else ++ if (ACPI_SUCCESS(status)) { ++ obj = (union acpi_object *)output.pointer; ++ if (obj && obj->type == ACPI_TYPE_INTEGER) ++ *out_data = (u32)obj->integer.value; ++ } ++ kfree(output.pointer); ++ } else { + status = wmi_evaluate_method(WMAX_CONTROL_GUID, 0, + command, &input, NULL); +- +- if (ACPI_SUCCESS(status) && out_data != NULL) { +- obj = (union acpi_object *)output.pointer; +- if (obj && obj->type == ACPI_TYPE_INTEGER) +- *out_data = (u32) obj->integer.value; + } +- kfree(output.pointer); + return status; +- + } + + /* +@@ -571,7 +570,7 @@ static ssize_t show_hdmi_source(struct device *dev, + return scnprintf(buf, PAGE_SIZE, + "input [gpu] unknown\n"); + } +- pr_err("alienware-wmi: unknown HDMI source status: %d\n", out_data); ++ pr_err("alienware-wmi: unknown HDMI source status: %u\n", status); + return scnprintf(buf, PAGE_SIZE, "input gpu [unknown]\n"); + } + +diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c +index 7f8fa42a1084..a56e997816b2 100644 +--- a/drivers/platform/x86/wmi.c ++++ b/drivers/platform/x86/wmi.c +@@ -748,6 +748,9 @@ static int wmi_dev_match(struct device *dev, struct device_driver *driver) + struct wmi_block *wblock = dev_to_wblock(dev); + const struct wmi_device_id *id = wmi_driver->id_table; + ++ if (id == NULL) ++ return 0; ++ + while (id->guid_string) { + uuid_le driver_guid; + +diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c +index 3226faebe0a0..0f1a0efd5926 100644 +--- a/drivers/power/supply/power_supply_core.c ++++ b/drivers/power/supply/power_supply_core.c +@@ -891,14 +891,14 @@ __power_supply_register(struct device *parent, + } + + spin_lock_init(&psy->changed_lock); +- rc = device_init_wakeup(dev, ws); +- if (rc) +- goto wakeup_init_failed; +- + rc = device_add(dev); + if (rc) + goto device_add_failed; + ++ rc = device_init_wakeup(dev, ws); ++ if (rc) ++ goto wakeup_init_failed; ++ + rc = psy_register_thermal(psy); + if (rc) + goto register_thermal_failed; +@@ -935,8 +935,8 @@ register_cooler_failed: + psy_unregister_thermal(psy); + register_thermal_failed: + device_del(dev); +-device_add_failed: + wakeup_init_failed: ++device_add_failed: + check_supplies_failed: + dev_set_name_failed: + put_device(dev); +diff --git a/drivers/pwm/pwm-lpss.c b/drivers/pwm/pwm-lpss.c +index 1e69c1c9ec09..7a4a6406cf69 100644 +--- a/drivers/pwm/pwm-lpss.c ++++ b/drivers/pwm/pwm-lpss.c +@@ -216,6 +216,12 @@ EXPORT_SYMBOL_GPL(pwm_lpss_probe); + + int pwm_lpss_remove(struct pwm_lpss_chip *lpwm) + { ++ int i; ++ ++ for (i = 0; i < lpwm->info->npwm; i++) { ++ if (pwm_is_enabled(&lpwm->chip.pwms[i])) ++ pm_runtime_put(lpwm->chip.dev); ++ } + return pwmchip_remove(&lpwm->chip); + } + EXPORT_SYMBOL_GPL(pwm_lpss_remove); +diff --git a/drivers/pwm/pwm-meson.c b/drivers/pwm/pwm-meson.c +index 9b79cbc7a715..3d2c36963a4f 100644 +--- a/drivers/pwm/pwm-meson.c ++++ b/drivers/pwm/pwm-meson.c +@@ -188,7 +188,7 @@ static int meson_pwm_calc(struct meson_pwm *meson, + do_div(fin_ps, fin_freq); + + /* Calc pre_div with the period */ +- for (pre_div = 0; pre_div < MISC_CLK_DIV_MASK; pre_div++) { ++ for (pre_div = 0; pre_div <= MISC_CLK_DIV_MASK; pre_div++) { + cnt = DIV_ROUND_CLOSEST_ULL((u64)period * 1000, + fin_ps * (pre_div + 1)); + dev_dbg(meson->chip.dev, "fin_ps=%llu pre_div=%u cnt=%u\n", +@@ -197,7 +197,7 @@ static int meson_pwm_calc(struct meson_pwm *meson, + break; + } + +- if (pre_div == MISC_CLK_DIV_MASK) { ++ if (pre_div > MISC_CLK_DIV_MASK) { + dev_err(meson->chip.dev, "unable to get period pre_div\n"); + return -EINVAL; + } +@@ -325,11 +325,6 @@ static int meson_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, + if (state->period != channel->state.period || + state->duty_cycle != channel->state.duty_cycle || + state->polarity != channel->state.polarity) { +- if (channel->state.enabled) { +- meson_pwm_disable(meson, pwm->hwpwm); +- channel->state.enabled = false; +- } +- + if (state->polarity != channel->state.polarity) { + if (state->polarity == PWM_POLARITY_NORMAL) + meson->inverter_mask |= BIT(pwm->hwpwm); +diff --git a/drivers/rapidio/rio_cm.c b/drivers/rapidio/rio_cm.c +index ef989a15aefc..b29fc258eeba 100644 +--- a/drivers/rapidio/rio_cm.c ++++ b/drivers/rapidio/rio_cm.c +@@ -1215,7 +1215,9 @@ static int riocm_ch_listen(u16 ch_id) + riocm_debug(CHOP, "(ch_%d)", ch_id); + + ch = riocm_get_channel(ch_id); +- if (!ch || !riocm_cmp_exch(ch, RIO_CM_CHAN_BOUND, RIO_CM_LISTEN)) ++ if (!ch) ++ return -EINVAL; ++ if (!riocm_cmp_exch(ch, RIO_CM_CHAN_BOUND, RIO_CM_LISTEN)) + ret = -EINVAL; + riocm_put_channel(ch); + return ret; +diff --git a/drivers/regulator/lp87565-regulator.c b/drivers/regulator/lp87565-regulator.c +index cfdbe294fb6a..32d4e6ec2e19 100644 +--- a/drivers/regulator/lp87565-regulator.c ++++ b/drivers/regulator/lp87565-regulator.c +@@ -188,7 +188,7 @@ static int lp87565_regulator_probe(struct platform_device *pdev) + struct lp87565 *lp87565 = dev_get_drvdata(pdev->dev.parent); + struct regulator_config config = { }; + struct regulator_dev *rdev; +- int i, min_idx = LP87565_BUCK_1, max_idx = LP87565_BUCK_3; ++ int i, min_idx = LP87565_BUCK_0, max_idx = LP87565_BUCK_3; + + platform_set_drvdata(pdev, lp87565); + +diff --git a/drivers/regulator/pv88060-regulator.c b/drivers/regulator/pv88060-regulator.c +index a9446056435f..1f2d8180506b 100644 +--- a/drivers/regulator/pv88060-regulator.c ++++ b/drivers/regulator/pv88060-regulator.c +@@ -135,7 +135,7 @@ static int pv88060_set_current_limit(struct regulator_dev *rdev, int min, + int i; + + /* search for closest to maximum */ +- for (i = info->n_current_limits; i >= 0; i--) { ++ for (i = info->n_current_limits - 1; i >= 0; i--) { + if (min <= info->current_limits[i] + && max >= info->current_limits[i]) { + return regmap_update_bits(rdev->regmap, +diff --git a/drivers/regulator/pv88080-regulator.c b/drivers/regulator/pv88080-regulator.c +index 9a08cb2de501..6770e4de2097 100644 +--- a/drivers/regulator/pv88080-regulator.c ++++ b/drivers/regulator/pv88080-regulator.c +@@ -279,7 +279,7 @@ static int pv88080_set_current_limit(struct regulator_dev *rdev, int min, + int i; + + /* search for closest to maximum */ +- for (i = info->n_current_limits; i >= 0; i--) { ++ for (i = info->n_current_limits - 1; i >= 0; i--) { + if (min <= info->current_limits[i] + && max >= info->current_limits[i]) { + return regmap_update_bits(rdev->regmap, +diff --git a/drivers/regulator/pv88090-regulator.c b/drivers/regulator/pv88090-regulator.c +index 7a0c15957bd0..2302b0df7630 100644 +--- a/drivers/regulator/pv88090-regulator.c ++++ b/drivers/regulator/pv88090-regulator.c +@@ -157,7 +157,7 @@ static int pv88090_set_current_limit(struct regulator_dev *rdev, int min, + int i; + + /* search for closest to maximum */ +- for (i = info->n_current_limits; i >= 0; i--) { ++ for (i = info->n_current_limits - 1; i >= 0; i--) { + if (min <= info->current_limits[i] + && max >= info->current_limits[i]) { + return regmap_update_bits(rdev->regmap, +diff --git a/drivers/regulator/tps65086-regulator.c b/drivers/regulator/tps65086-regulator.c +index 45e96e154690..5a5e9b5bf4be 100644 +--- a/drivers/regulator/tps65086-regulator.c ++++ b/drivers/regulator/tps65086-regulator.c +@@ -90,8 +90,8 @@ static const struct regulator_linear_range tps65086_buck345_25mv_ranges[] = { + static const struct regulator_linear_range tps65086_ldoa1_ranges[] = { + REGULATOR_LINEAR_RANGE(1350000, 0x0, 0x0, 0), + REGULATOR_LINEAR_RANGE(1500000, 0x1, 0x7, 100000), +- REGULATOR_LINEAR_RANGE(2300000, 0x8, 0xA, 100000), +- REGULATOR_LINEAR_RANGE(2700000, 0xB, 0xD, 150000), ++ REGULATOR_LINEAR_RANGE(2300000, 0x8, 0xB, 100000), ++ REGULATOR_LINEAR_RANGE(2850000, 0xC, 0xD, 150000), + REGULATOR_LINEAR_RANGE(3300000, 0xE, 0xE, 0), + }; + +diff --git a/drivers/regulator/wm831x-dcdc.c b/drivers/regulator/wm831x-dcdc.c +index 5a5bc4bb08d2..df591435d12a 100644 +--- a/drivers/regulator/wm831x-dcdc.c ++++ b/drivers/regulator/wm831x-dcdc.c +@@ -327,8 +327,8 @@ static int wm831x_buckv_get_voltage_sel(struct regulator_dev *rdev) + } + + /* Current limit options */ +-static u16 wm831x_dcdc_ilim[] = { +- 125, 250, 375, 500, 625, 750, 875, 1000 ++static const unsigned int wm831x_dcdc_ilim[] = { ++ 125000, 250000, 375000, 500000, 625000, 750000, 875000, 1000000 + }; + + static int wm831x_buckv_set_current_limit(struct regulator_dev *rdev, +diff --git a/drivers/rtc/rtc-88pm80x.c b/drivers/rtc/rtc-88pm80x.c +index 466bf7f9a285..7da2a1fb50f8 100644 +--- a/drivers/rtc/rtc-88pm80x.c ++++ b/drivers/rtc/rtc-88pm80x.c +@@ -116,12 +116,14 @@ static int pm80x_rtc_read_time(struct device *dev, struct rtc_time *tm) + unsigned char buf[4]; + unsigned long ticks, base, data; + regmap_raw_read(info->map, PM800_RTC_EXPIRE2_1, buf, 4); +- base = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0]; ++ base = ((unsigned long)buf[3] << 24) | (buf[2] << 16) | ++ (buf[1] << 8) | buf[0]; + dev_dbg(info->dev, "%x-%x-%x-%x\n", buf[0], buf[1], buf[2], buf[3]); + + /* load 32-bit read-only counter */ + regmap_raw_read(info->map, PM800_RTC_COUNTER1, buf, 4); +- data = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0]; ++ data = ((unsigned long)buf[3] << 24) | (buf[2] << 16) | ++ (buf[1] << 8) | buf[0]; + ticks = base + data; + dev_dbg(info->dev, "get base:0x%lx, RO count:0x%lx, ticks:0x%lx\n", + base, data, ticks); +@@ -144,7 +146,8 @@ static int pm80x_rtc_set_time(struct device *dev, struct rtc_time *tm) + + /* load 32-bit read-only counter */ + regmap_raw_read(info->map, PM800_RTC_COUNTER1, buf, 4); +- data = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0]; ++ data = ((unsigned long)buf[3] << 24) | (buf[2] << 16) | ++ (buf[1] << 8) | buf[0]; + base = ticks - data; + dev_dbg(info->dev, "set base:0x%lx, RO count:0x%lx, ticks:0x%lx\n", + base, data, ticks); +@@ -165,11 +168,13 @@ static int pm80x_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) + int ret; + + regmap_raw_read(info->map, PM800_RTC_EXPIRE2_1, buf, 4); +- base = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0]; ++ base = ((unsigned long)buf[3] << 24) | (buf[2] << 16) | ++ (buf[1] << 8) | buf[0]; + dev_dbg(info->dev, "%x-%x-%x-%x\n", buf[0], buf[1], buf[2], buf[3]); + + regmap_raw_read(info->map, PM800_RTC_EXPIRE1_1, buf, 4); +- data = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0]; ++ data = ((unsigned long)buf[3] << 24) | (buf[2] << 16) | ++ (buf[1] << 8) | buf[0]; + ticks = base + data; + dev_dbg(info->dev, "get base:0x%lx, RO count:0x%lx, ticks:0x%lx\n", + base, data, ticks); +@@ -192,12 +197,14 @@ static int pm80x_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) + regmap_update_bits(info->map, PM800_RTC_CONTROL, PM800_ALARM1_EN, 0); + + regmap_raw_read(info->map, PM800_RTC_EXPIRE2_1, buf, 4); +- base = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0]; ++ base = ((unsigned long)buf[3] << 24) | (buf[2] << 16) | ++ (buf[1] << 8) | buf[0]; + dev_dbg(info->dev, "%x-%x-%x-%x\n", buf[0], buf[1], buf[2], buf[3]); + + /* load 32-bit read-only counter */ + regmap_raw_read(info->map, PM800_RTC_COUNTER1, buf, 4); +- data = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0]; ++ data = ((unsigned long)buf[3] << 24) | (buf[2] << 16) | ++ (buf[1] << 8) | buf[0]; + ticks = base + data; + dev_dbg(info->dev, "get base:0x%lx, RO count:0x%lx, ticks:0x%lx\n", + base, data, ticks); +diff --git a/drivers/rtc/rtc-88pm860x.c b/drivers/rtc/rtc-88pm860x.c +index 166faae3a59c..7d3e5168fcef 100644 +--- a/drivers/rtc/rtc-88pm860x.c ++++ b/drivers/rtc/rtc-88pm860x.c +@@ -115,11 +115,13 @@ static int pm860x_rtc_read_time(struct device *dev, struct rtc_time *tm) + pm860x_page_bulk_read(info->i2c, REG0_ADDR, 8, buf); + dev_dbg(info->dev, "%x-%x-%x-%x-%x-%x-%x-%x\n", buf[0], buf[1], + buf[2], buf[3], buf[4], buf[5], buf[6], buf[7]); +- base = (buf[1] << 24) | (buf[3] << 16) | (buf[5] << 8) | buf[7]; ++ base = ((unsigned long)buf[1] << 24) | (buf[3] << 16) | ++ (buf[5] << 8) | buf[7]; + + /* load 32-bit read-only counter */ + pm860x_bulk_read(info->i2c, PM8607_RTC_COUNTER1, 4, buf); +- data = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0]; ++ data = ((unsigned long)buf[3] << 24) | (buf[2] << 16) | ++ (buf[1] << 8) | buf[0]; + ticks = base + data; + dev_dbg(info->dev, "get base:0x%lx, RO count:0x%lx, ticks:0x%lx\n", + base, data, ticks); +@@ -145,7 +147,8 @@ static int pm860x_rtc_set_time(struct device *dev, struct rtc_time *tm) + + /* load 32-bit read-only counter */ + pm860x_bulk_read(info->i2c, PM8607_RTC_COUNTER1, 4, buf); +- data = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0]; ++ data = ((unsigned long)buf[3] << 24) | (buf[2] << 16) | ++ (buf[1] << 8) | buf[0]; + base = ticks - data; + dev_dbg(info->dev, "set base:0x%lx, RO count:0x%lx, ticks:0x%lx\n", + base, data, ticks); +@@ -170,10 +173,12 @@ static int pm860x_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) + pm860x_page_bulk_read(info->i2c, REG0_ADDR, 8, buf); + dev_dbg(info->dev, "%x-%x-%x-%x-%x-%x-%x-%x\n", buf[0], buf[1], + buf[2], buf[3], buf[4], buf[5], buf[6], buf[7]); +- base = (buf[1] << 24) | (buf[3] << 16) | (buf[5] << 8) | buf[7]; ++ base = ((unsigned long)buf[1] << 24) | (buf[3] << 16) | ++ (buf[5] << 8) | buf[7]; + + pm860x_bulk_read(info->i2c, PM8607_RTC_EXPIRE1, 4, buf); +- data = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0]; ++ data = ((unsigned long)buf[3] << 24) | (buf[2] << 16) | ++ (buf[1] << 8) | buf[0]; + ticks = base + data; + dev_dbg(info->dev, "get base:0x%lx, RO count:0x%lx, ticks:0x%lx\n", + base, data, ticks); +@@ -198,11 +203,13 @@ static int pm860x_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) + pm860x_page_bulk_read(info->i2c, REG0_ADDR, 8, buf); + dev_dbg(info->dev, "%x-%x-%x-%x-%x-%x-%x-%x\n", buf[0], buf[1], + buf[2], buf[3], buf[4], buf[5], buf[6], buf[7]); +- base = (buf[1] << 24) | (buf[3] << 16) | (buf[5] << 8) | buf[7]; ++ base = ((unsigned long)buf[1] << 24) | (buf[3] << 16) | ++ (buf[5] << 8) | buf[7]; + + /* load 32-bit read-only counter */ + pm860x_bulk_read(info->i2c, PM8607_RTC_COUNTER1, 4, buf); +- data = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0]; ++ data = ((unsigned long)buf[3] << 24) | (buf[2] << 16) | ++ (buf[1] << 8) | buf[0]; + ticks = base + data; + dev_dbg(info->dev, "get base:0x%lx, RO count:0x%lx, ticks:0x%lx\n", + base, data, ticks); +diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c +index e7d9215c9201..8d45d93b1db6 100644 +--- a/drivers/rtc/rtc-ds1307.c ++++ b/drivers/rtc/rtc-ds1307.c +@@ -733,8 +733,8 @@ static int rx8130_set_alarm(struct device *dev, struct rtc_wkalrm *t) + if (ret < 0) + return ret; + +- ctl[0] &= ~RX8130_REG_EXTENSION_WADA; +- ctl[1] |= RX8130_REG_FLAG_AF; ++ ctl[0] &= RX8130_REG_EXTENSION_WADA; ++ ctl[1] &= ~RX8130_REG_FLAG_AF; + ctl[2] &= ~RX8130_REG_CONTROL0_AIE; + + ret = regmap_bulk_write(ds1307->regmap, RX8130_REG_EXTENSION, ctl, +@@ -757,8 +757,7 @@ static int rx8130_set_alarm(struct device *dev, struct rtc_wkalrm *t) + + ctl[2] |= RX8130_REG_CONTROL0_AIE; + +- return regmap_bulk_write(ds1307->regmap, RX8130_REG_EXTENSION, ctl, +- sizeof(ctl)); ++ return regmap_write(ds1307->regmap, RX8130_REG_CONTROL0, ctl[2]); + } + + static int rx8130_alarm_irq_enable(struct device *dev, unsigned int enabled) +diff --git a/drivers/rtc/rtc-ds1672.c b/drivers/rtc/rtc-ds1672.c +index 9caaccccaa57..b1ebca099b0d 100644 +--- a/drivers/rtc/rtc-ds1672.c ++++ b/drivers/rtc/rtc-ds1672.c +@@ -58,7 +58,8 @@ static int ds1672_get_datetime(struct i2c_client *client, struct rtc_time *tm) + "%s: raw read data - counters=%02x,%02x,%02x,%02x\n", + __func__, buf[0], buf[1], buf[2], buf[3]); + +- time = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0]; ++ time = ((unsigned long)buf[3] << 24) | (buf[2] << 16) | ++ (buf[1] << 8) | buf[0]; + + rtc_time_to_tm(time, tm); + +diff --git a/drivers/rtc/rtc-mc146818-lib.c b/drivers/rtc/rtc-mc146818-lib.c +index 2f1772a358ca..18a6f15e313d 100644 +--- a/drivers/rtc/rtc-mc146818-lib.c ++++ b/drivers/rtc/rtc-mc146818-lib.c +@@ -82,7 +82,7 @@ unsigned int mc146818_get_time(struct rtc_time *time) + time->tm_year += real_year - 72; + #endif + +- if (century) ++ if (century > 20) + time->tm_year += (century - 19) * 100; + + /* +diff --git a/drivers/rtc/rtc-pcf2127.c b/drivers/rtc/rtc-pcf2127.c +index 9f1b14bf91ae..367e0f803440 100644 +--- a/drivers/rtc/rtc-pcf2127.c ++++ b/drivers/rtc/rtc-pcf2127.c +@@ -52,20 +52,14 @@ static int pcf2127_rtc_read_time(struct device *dev, struct rtc_time *tm) + struct pcf2127 *pcf2127 = dev_get_drvdata(dev); + unsigned char buf[10]; + int ret; +- int i; + +- for (i = 0; i <= PCF2127_REG_CTRL3; i++) { +- ret = regmap_read(pcf2127->regmap, PCF2127_REG_CTRL1 + i, +- (unsigned int *)(buf + i)); +- if (ret) { +- dev_err(dev, "%s: read error\n", __func__); +- return ret; +- } +- } +- +- ret = regmap_bulk_read(pcf2127->regmap, PCF2127_REG_SC, +- (buf + PCF2127_REG_SC), +- ARRAY_SIZE(buf) - PCF2127_REG_SC); ++ /* ++ * Avoid reading CTRL2 register as it causes WD_VAL register ++ * value to reset to 0 which means watchdog is stopped. ++ */ ++ ret = regmap_bulk_read(pcf2127->regmap, PCF2127_REG_CTRL3, ++ (buf + PCF2127_REG_CTRL3), ++ ARRAY_SIZE(buf) - PCF2127_REG_CTRL3); + if (ret) { + dev_err(dev, "%s: read error\n", __func__); + return ret; +@@ -86,14 +80,12 @@ static int pcf2127_rtc_read_time(struct device *dev, struct rtc_time *tm) + } + + dev_dbg(dev, +- "%s: raw data is cr1=%02x, cr2=%02x, cr3=%02x, " +- "sec=%02x, min=%02x, hr=%02x, " ++ "%s: raw data is cr3=%02x, sec=%02x, min=%02x, hr=%02x, " + "mday=%02x, wday=%02x, mon=%02x, year=%02x\n", +- __func__, +- buf[0], buf[1], buf[2], +- buf[3], buf[4], buf[5], +- buf[6], buf[7], buf[8], buf[9]); +- ++ __func__, buf[PCF2127_REG_CTRL3], buf[PCF2127_REG_SC], ++ buf[PCF2127_REG_MN], buf[PCF2127_REG_HR], ++ buf[PCF2127_REG_DM], buf[PCF2127_REG_DW], ++ buf[PCF2127_REG_MO], buf[PCF2127_REG_YR]); + + tm->tm_sec = bcd2bin(buf[PCF2127_REG_SC] & 0x7F); + tm->tm_min = bcd2bin(buf[PCF2127_REG_MN] & 0x7F); +diff --git a/drivers/rtc/rtc-pcf8563.c b/drivers/rtc/rtc-pcf8563.c +index 8c836c51a508..4d0b81f9805f 100644 +--- a/drivers/rtc/rtc-pcf8563.c ++++ b/drivers/rtc/rtc-pcf8563.c +@@ -563,7 +563,6 @@ static int pcf8563_probe(struct i2c_client *client, + struct pcf8563 *pcf8563; + int err; + unsigned char buf; +- unsigned char alm_pending; + + dev_dbg(&client->dev, "%s\n", __func__); + +@@ -587,13 +586,13 @@ static int pcf8563_probe(struct i2c_client *client, + return err; + } + +- err = pcf8563_get_alarm_mode(client, NULL, &alm_pending); +- if (err) { +- dev_err(&client->dev, "%s: read error\n", __func__); ++ /* Clear flags and disable interrupts */ ++ buf = 0; ++ err = pcf8563_write_block_data(client, PCF8563_REG_ST2, 1, &buf); ++ if (err < 0) { ++ dev_err(&client->dev, "%s: write error\n", __func__); + return err; + } +- if (alm_pending) +- pcf8563_set_alarm_mode(client, 0); + + pcf8563->rtc = devm_rtc_device_register(&client->dev, + pcf8563_driver.driver.name, +@@ -605,7 +604,7 @@ static int pcf8563_probe(struct i2c_client *client, + if (client->irq > 0) { + err = devm_request_threaded_irq(&client->dev, client->irq, + NULL, pcf8563_irq, +- IRQF_SHARED|IRQF_ONESHOT|IRQF_TRIGGER_FALLING, ++ IRQF_SHARED | IRQF_ONESHOT | IRQF_TRIGGER_LOW, + pcf8563_driver.driver.name, client); + if (err) { + dev_err(&client->dev, "unable to request IRQ %d\n", +diff --git a/drivers/rtc/rtc-pm8xxx.c b/drivers/rtc/rtc-pm8xxx.c +index fac835530671..a1b4b0ed1f19 100644 +--- a/drivers/rtc/rtc-pm8xxx.c ++++ b/drivers/rtc/rtc-pm8xxx.c +@@ -186,7 +186,8 @@ static int pm8xxx_rtc_read_time(struct device *dev, struct rtc_time *tm) + } + } + +- secs = value[0] | (value[1] << 8) | (value[2] << 16) | (value[3] << 24); ++ secs = value[0] | (value[1] << 8) | (value[2] << 16) | ++ ((unsigned long)value[3] << 24); + + rtc_time_to_tm(secs, tm); + +@@ -267,7 +268,8 @@ static int pm8xxx_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm) + return rc; + } + +- secs = value[0] | (value[1] << 8) | (value[2] << 16) | (value[3] << 24); ++ secs = value[0] | (value[1] << 8) | (value[2] << 16) | ++ ((unsigned long)value[3] << 24); + + rtc_time_to_tm(secs, &alarm->time); + +diff --git a/drivers/scsi/fnic/fnic_isr.c b/drivers/scsi/fnic/fnic_isr.c +index 4e3a50202e8c..d28088218c36 100644 +--- a/drivers/scsi/fnic/fnic_isr.c ++++ b/drivers/scsi/fnic/fnic_isr.c +@@ -254,7 +254,7 @@ int fnic_set_intr_mode(struct fnic *fnic) + int vecs = n + m + o + 1; + + if (pci_alloc_irq_vectors(fnic->pdev, vecs, vecs, +- PCI_IRQ_MSIX) < 0) { ++ PCI_IRQ_MSIX) == vecs) { + fnic->rq_count = n; + fnic->raw_wq_count = m; + fnic->wq_copy_count = o; +@@ -280,7 +280,7 @@ int fnic_set_intr_mode(struct fnic *fnic) + fnic->wq_copy_count >= 1 && + fnic->cq_count >= 3 && + fnic->intr_count >= 1 && +- pci_alloc_irq_vectors(fnic->pdev, 1, 1, PCI_IRQ_MSI) < 0) { ++ pci_alloc_irq_vectors(fnic->pdev, 1, 1, PCI_IRQ_MSI) == 1) { + fnic->rq_count = 1; + fnic->raw_wq_count = 1; + fnic->wq_copy_count = 1; +diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c +index 42bcf7f3a0f9..6ba257cbc6d9 100644 +--- a/drivers/scsi/libfc/fc_exch.c ++++ b/drivers/scsi/libfc/fc_exch.c +@@ -2603,7 +2603,7 @@ void fc_exch_recv(struct fc_lport *lport, struct fc_frame *fp) + + /* lport lock ? */ + if (!lport || lport->state == LPORT_ST_DISABLED) { +- FC_LPORT_DBG(lport, "Receiving frames for an lport that " ++ FC_LIBFC_DBG("Receiving frames for an lport that " + "has not been initialized correctly\n"); + fc_frame_free(fp); + return; +diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c +index 577513649afb..6abad63b127a 100644 +--- a/drivers/scsi/megaraid/megaraid_sas_base.c ++++ b/drivers/scsi/megaraid/megaraid_sas_base.c +@@ -3823,12 +3823,12 @@ megasas_transition_to_ready(struct megasas_instance *instance, int ocr) + /* + * The cur_state should not last for more than max_wait secs + */ +- for (i = 0; i < max_wait; i++) { ++ for (i = 0; i < max_wait * 50; i++) { + curr_abs_state = instance->instancet-> + read_fw_status_reg(instance->reg_set); + + if (abs_state == curr_abs_state) { +- msleep(1000); ++ msleep(20); + } else + break; + } +diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c +index 5617bb18c233..5f9d4dbc4a98 100644 +--- a/drivers/scsi/qla2xxx/qla_os.c ++++ b/drivers/scsi/qla2xxx/qla_os.c +@@ -6714,8 +6714,7 @@ qla2x00_module_init(void) + /* Initialize target kmem_cache and mem_pools */ + ret = qlt_init(); + if (ret < 0) { +- kmem_cache_destroy(srb_cachep); +- return ret; ++ goto destroy_cache; + } else if (ret > 0) { + /* + * If initiator mode is explictly disabled by qlt_init(), +@@ -6736,11 +6735,10 @@ qla2x00_module_init(void) + qla2xxx_transport_template = + fc_attach_transport(&qla2xxx_transport_functions); + if (!qla2xxx_transport_template) { +- kmem_cache_destroy(srb_cachep); + ql_log(ql_log_fatal, NULL, 0x0002, + "fc_attach_transport failed...Failing load!.\n"); +- qlt_exit(); +- return -ENODEV; ++ ret = -ENODEV; ++ goto qlt_exit; + } + + apidev_major = register_chrdev(0, QLA2XXX_APIDEV, &apidev_fops); +@@ -6752,27 +6750,37 @@ qla2x00_module_init(void) + qla2xxx_transport_vport_template = + fc_attach_transport(&qla2xxx_transport_vport_functions); + if (!qla2xxx_transport_vport_template) { +- kmem_cache_destroy(srb_cachep); +- qlt_exit(); +- fc_release_transport(qla2xxx_transport_template); + ql_log(ql_log_fatal, NULL, 0x0004, + "fc_attach_transport vport failed...Failing load!.\n"); +- return -ENODEV; ++ ret = -ENODEV; ++ goto unreg_chrdev; + } + ql_log(ql_log_info, NULL, 0x0005, + "QLogic Fibre Channel HBA Driver: %s.\n", + qla2x00_version_str); + ret = pci_register_driver(&qla2xxx_pci_driver); + if (ret) { +- kmem_cache_destroy(srb_cachep); +- qlt_exit(); +- fc_release_transport(qla2xxx_transport_template); +- fc_release_transport(qla2xxx_transport_vport_template); + ql_log(ql_log_fatal, NULL, 0x0006, + "pci_register_driver failed...ret=%d Failing load!.\n", + ret); ++ goto release_vport_transport; + } + return ret; ++ ++release_vport_transport: ++ fc_release_transport(qla2xxx_transport_vport_template); ++ ++unreg_chrdev: ++ if (apidev_major >= 0) ++ unregister_chrdev(apidev_major, QLA2XXX_APIDEV); ++ fc_release_transport(qla2xxx_transport_template); ++ ++qlt_exit: ++ qlt_exit(); ++ ++destroy_cache: ++ kmem_cache_destroy(srb_cachep); ++ return ret; + } + + /** +diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c +index 55227d20496a..21011c5fddeb 100644 +--- a/drivers/scsi/qla2xxx/qla_target.c ++++ b/drivers/scsi/qla2xxx/qla_target.c +@@ -2122,14 +2122,14 @@ void qlt_send_resp_ctio(struct qla_qpair *qpair, struct qla_tgt_cmd *cmd, + ctio->u.status1.scsi_status |= + cpu_to_le16(SS_RESIDUAL_UNDER); + +- /* Response code and sense key */ +- put_unaligned_le32(((0x70 << 24) | (sense_key << 8)), +- (&ctio->u.status1.sense_data)[0]); ++ /* Fixed format sense data. */ ++ ctio->u.status1.sense_data[0] = 0x70; ++ ctio->u.status1.sense_data[2] = sense_key; + /* Additional sense length */ +- put_unaligned_le32(0x0a, (&ctio->u.status1.sense_data)[1]); ++ ctio->u.status1.sense_data[7] = 0xa; + /* ASC and ASCQ */ +- put_unaligned_le32(((asc << 24) | (ascq << 16)), +- (&ctio->u.status1.sense_data)[3]); ++ ctio->u.status1.sense_data[12] = asc; ++ ctio->u.status1.sense_data[13] = ascq; + + /* Memory Barrier */ + wmb(); +@@ -2179,7 +2179,7 @@ void qlt_xmit_tm_rsp(struct qla_tgt_mgmt_cmd *mcmd) + mcmd->orig_iocb.imm_ntfy.u.isp24.status_subcode == + ELS_TPRLO) { + ql_dbg(ql_dbg_disc, vha, 0x2106, +- "TM response logo %phC status %#x state %#x", ++ "TM response logo %8phC status %#x state %#x", + mcmd->sess->port_name, mcmd->fc_tm_rsp, + mcmd->flags); + qlt_schedule_sess_for_deletion_lock(mcmd->sess); +diff --git a/drivers/soc/fsl/qe/gpio.c b/drivers/soc/fsl/qe/gpio.c +index 3b27075c21a7..5cbc5ce5ac15 100644 +--- a/drivers/soc/fsl/qe/gpio.c ++++ b/drivers/soc/fsl/qe/gpio.c +@@ -152,8 +152,10 @@ struct qe_pin *qe_pin_request(struct device_node *np, int index) + if (err < 0) + goto err0; + gc = gpio_to_chip(err); +- if (WARN_ON(!gc)) ++ if (WARN_ON(!gc)) { ++ err = -ENODEV; + goto err0; ++ } + + if (!of_device_is_compatible(gc->of_node, "fsl,mpc8323-qe-pario-bank")) { + pr_debug("%s: tried to get a non-qe pin\n", __func__); +diff --git a/drivers/spi/spi-bcm2835aux.c b/drivers/spi/spi-bcm2835aux.c +index 5c89bbb05441..e075712c501e 100644 +--- a/drivers/spi/spi-bcm2835aux.c ++++ b/drivers/spi/spi-bcm2835aux.c +@@ -416,7 +416,18 @@ static int bcm2835aux_spi_probe(struct platform_device *pdev) + platform_set_drvdata(pdev, master); + master->mode_bits = (SPI_CPOL | SPI_CS_HIGH | SPI_NO_CS); + master->bits_per_word_mask = SPI_BPW_MASK(8); +- master->num_chipselect = -1; ++ /* even though the driver never officially supported native CS ++ * allow a single native CS for legacy DT support purposes when ++ * no cs-gpio is configured. ++ * Known limitations for native cs are: ++ * * multiple chip-selects: cs0-cs2 are all simultaniously asserted ++ * whenever there is a transfer - this even includes SPI_NO_CS ++ * * SPI_CS_HIGH: is ignores - cs are always asserted low ++ * * cs_change: cs is deasserted after each spi_transfer ++ * * cs_delay_usec: cs is always deasserted one SCK cycle after ++ * a spi_transfer ++ */ ++ master->num_chipselect = 1; + master->transfer_one = bcm2835aux_spi_transfer_one; + master->handle_err = bcm2835aux_spi_handle_err; + master->prepare_message = bcm2835aux_spi_prepare_message; +diff --git a/drivers/spi/spi-cadence.c b/drivers/spi/spi-cadence.c +index 02bd1eba045b..d08ad93d97a1 100644 +--- a/drivers/spi/spi-cadence.c ++++ b/drivers/spi/spi-cadence.c +@@ -584,11 +584,6 @@ static int cdns_spi_probe(struct platform_device *pdev) + goto clk_dis_apb; + } + +- pm_runtime_use_autosuspend(&pdev->dev); +- pm_runtime_set_autosuspend_delay(&pdev->dev, SPI_AUTOSUSPEND_TIMEOUT); +- pm_runtime_set_active(&pdev->dev); +- pm_runtime_enable(&pdev->dev); +- + ret = of_property_read_u32(pdev->dev.of_node, "num-cs", &num_cs); + if (ret < 0) + master->num_chipselect = CDNS_SPI_DEFAULT_NUM_CS; +@@ -603,8 +598,10 @@ static int cdns_spi_probe(struct platform_device *pdev) + /* SPI controller initializations */ + cdns_spi_init_hw(xspi); + +- pm_runtime_mark_last_busy(&pdev->dev); +- pm_runtime_put_autosuspend(&pdev->dev); ++ pm_runtime_set_active(&pdev->dev); ++ pm_runtime_enable(&pdev->dev); ++ pm_runtime_use_autosuspend(&pdev->dev); ++ pm_runtime_set_autosuspend_delay(&pdev->dev, SPI_AUTOSUSPEND_TIMEOUT); + + irq = platform_get_irq(pdev, 0); + if (irq <= 0) { +diff --git a/drivers/spi/spi-fsl-spi.c b/drivers/spi/spi-fsl-spi.c +index 8b79e36fab21..cd784552de7f 100644 +--- a/drivers/spi/spi-fsl-spi.c ++++ b/drivers/spi/spi-fsl-spi.c +@@ -407,7 +407,6 @@ static int fsl_spi_do_one_msg(struct spi_master *master, + } + + m->status = status; +- spi_finalize_current_message(master); + + if (status || !cs_change) { + ndelay(nsecs); +@@ -415,6 +414,7 @@ static int fsl_spi_do_one_msg(struct spi_master *master, + } + + fsl_spi_setup_transfer(spi, NULL); ++ spi_finalize_current_message(master); + return 0; + } + +diff --git a/drivers/spi/spi-tegra114.c b/drivers/spi/spi-tegra114.c +index 2ad04796ef29..84ff0c507f0b 100644 +--- a/drivers/spi/spi-tegra114.c ++++ b/drivers/spi/spi-tegra114.c +@@ -307,10 +307,16 @@ static unsigned tegra_spi_fill_tx_fifo_from_client_txbuf( + x |= (u32)(*tx_buf++) << (i * 8); + tegra_spi_writel(tspi, x, SPI_TX_FIFO); + } ++ ++ tspi->cur_tx_pos += written_words * tspi->bytes_per_word; + } else { ++ unsigned int write_bytes; + max_n_32bit = min(tspi->curr_dma_words, tx_empty_count); + written_words = max_n_32bit; + nbytes = written_words * tspi->bytes_per_word; ++ if (nbytes > t->len - tspi->cur_pos) ++ nbytes = t->len - tspi->cur_pos; ++ write_bytes = nbytes; + for (count = 0; count < max_n_32bit; count++) { + u32 x = 0; + +@@ -319,8 +325,10 @@ static unsigned tegra_spi_fill_tx_fifo_from_client_txbuf( + x |= (u32)(*tx_buf++) << (i * 8); + tegra_spi_writel(tspi, x, SPI_TX_FIFO); + } ++ ++ tspi->cur_tx_pos += write_bytes; + } +- tspi->cur_tx_pos += written_words * tspi->bytes_per_word; ++ + return written_words; + } + +@@ -344,20 +352,27 @@ static unsigned int tegra_spi_read_rx_fifo_to_client_rxbuf( + for (i = 0; len && (i < 4); i++, len--) + *rx_buf++ = (x >> i*8) & 0xFF; + } +- tspi->cur_rx_pos += tspi->curr_dma_words * tspi->bytes_per_word; + read_words += tspi->curr_dma_words; ++ tspi->cur_rx_pos += tspi->curr_dma_words * tspi->bytes_per_word; + } else { + u32 rx_mask = ((u32)1 << t->bits_per_word) - 1; ++ u8 bytes_per_word = tspi->bytes_per_word; ++ unsigned int read_bytes; + ++ len = rx_full_count * bytes_per_word; ++ if (len > t->len - tspi->cur_pos) ++ len = t->len - tspi->cur_pos; ++ read_bytes = len; + for (count = 0; count < rx_full_count; count++) { + u32 x = tegra_spi_readl(tspi, SPI_RX_FIFO) & rx_mask; + +- for (i = 0; (i < tspi->bytes_per_word); i++) ++ for (i = 0; len && (i < bytes_per_word); i++, len--) + *rx_buf++ = (x >> (i*8)) & 0xFF; + } +- tspi->cur_rx_pos += rx_full_count * tspi->bytes_per_word; + read_words += rx_full_count; ++ tspi->cur_rx_pos += read_bytes; + } ++ + return read_words; + } + +@@ -372,12 +387,17 @@ static void tegra_spi_copy_client_txbuf_to_spi_txbuf( + unsigned len = tspi->curr_dma_words * tspi->bytes_per_word; + + memcpy(tspi->tx_dma_buf, t->tx_buf + tspi->cur_pos, len); ++ tspi->cur_tx_pos += tspi->curr_dma_words * tspi->bytes_per_word; + } else { + unsigned int i; + unsigned int count; + u8 *tx_buf = (u8 *)t->tx_buf + tspi->cur_tx_pos; + unsigned consume = tspi->curr_dma_words * tspi->bytes_per_word; ++ unsigned int write_bytes; + ++ if (consume > t->len - tspi->cur_pos) ++ consume = t->len - tspi->cur_pos; ++ write_bytes = consume; + for (count = 0; count < tspi->curr_dma_words; count++) { + u32 x = 0; + +@@ -386,8 +406,9 @@ static void tegra_spi_copy_client_txbuf_to_spi_txbuf( + x |= (u32)(*tx_buf++) << (i * 8); + tspi->tx_dma_buf[count] = x; + } ++ ++ tspi->cur_tx_pos += write_bytes; + } +- tspi->cur_tx_pos += tspi->curr_dma_words * tspi->bytes_per_word; + + /* Make the dma buffer to read by dma */ + dma_sync_single_for_device(tspi->dev, tspi->tx_dma_phys, +@@ -405,20 +426,28 @@ static void tegra_spi_copy_spi_rxbuf_to_client_rxbuf( + unsigned len = tspi->curr_dma_words * tspi->bytes_per_word; + + memcpy(t->rx_buf + tspi->cur_rx_pos, tspi->rx_dma_buf, len); ++ tspi->cur_rx_pos += tspi->curr_dma_words * tspi->bytes_per_word; + } else { + unsigned int i; + unsigned int count; + unsigned char *rx_buf = t->rx_buf + tspi->cur_rx_pos; + u32 rx_mask = ((u32)1 << t->bits_per_word) - 1; ++ unsigned consume = tspi->curr_dma_words * tspi->bytes_per_word; ++ unsigned int read_bytes; + ++ if (consume > t->len - tspi->cur_pos) ++ consume = t->len - tspi->cur_pos; ++ read_bytes = consume; + for (count = 0; count < tspi->curr_dma_words; count++) { + u32 x = tspi->rx_dma_buf[count] & rx_mask; + +- for (i = 0; (i < tspi->bytes_per_word); i++) ++ for (i = 0; consume && (i < tspi->bytes_per_word); ++ i++, consume--) + *rx_buf++ = (x >> (i*8)) & 0xFF; + } ++ ++ tspi->cur_rx_pos += read_bytes; + } +- tspi->cur_rx_pos += tspi->curr_dma_words * tspi->bytes_per_word; + + /* Make the dma buffer to read by dma */ + dma_sync_single_for_device(tspi->dev, tspi->rx_dma_phys, +@@ -470,22 +499,39 @@ static int tegra_spi_start_rx_dma(struct tegra_spi_data *tspi, int len) + return 0; + } + +-static int tegra_spi_start_dma_based_transfer( +- struct tegra_spi_data *tspi, struct spi_transfer *t) ++static int tegra_spi_flush_fifos(struct tegra_spi_data *tspi) + { +- u32 val; +- unsigned int len; +- int ret = 0; ++ unsigned long timeout = jiffies + HZ; + u32 status; + +- /* Make sure that Rx and Tx fifo are empty */ + status = tegra_spi_readl(tspi, SPI_FIFO_STATUS); + if ((status & SPI_FIFO_EMPTY) != SPI_FIFO_EMPTY) { +- dev_err(tspi->dev, "Rx/Tx fifo are not empty status 0x%08x\n", +- (unsigned)status); +- return -EIO; ++ status |= SPI_RX_FIFO_FLUSH | SPI_TX_FIFO_FLUSH; ++ tegra_spi_writel(tspi, status, SPI_FIFO_STATUS); ++ while ((status & SPI_FIFO_EMPTY) != SPI_FIFO_EMPTY) { ++ status = tegra_spi_readl(tspi, SPI_FIFO_STATUS); ++ if (time_after(jiffies, timeout)) { ++ dev_err(tspi->dev, ++ "timeout waiting for fifo flush\n"); ++ return -EIO; ++ } ++ ++ udelay(1); ++ } + } + ++ return 0; ++} ++ ++static int tegra_spi_start_dma_based_transfer( ++ struct tegra_spi_data *tspi, struct spi_transfer *t) ++{ ++ u32 val; ++ unsigned int len; ++ int ret = 0; ++ u8 dma_burst; ++ struct dma_slave_config dma_sconfig = {0}; ++ + val = SPI_DMA_BLK_SET(tspi->curr_dma_words - 1); + tegra_spi_writel(tspi, val, SPI_DMA_BLK); + +@@ -496,12 +542,16 @@ static int tegra_spi_start_dma_based_transfer( + len = tspi->curr_dma_words * 4; + + /* Set attention level based on length of transfer */ +- if (len & 0xF) ++ if (len & 0xF) { + val |= SPI_TX_TRIG_1 | SPI_RX_TRIG_1; +- else if (((len) >> 4) & 0x1) ++ dma_burst = 1; ++ } else if (((len) >> 4) & 0x1) { + val |= SPI_TX_TRIG_4 | SPI_RX_TRIG_4; +- else ++ dma_burst = 4; ++ } else { + val |= SPI_TX_TRIG_8 | SPI_RX_TRIG_8; ++ dma_burst = 8; ++ } + + if (tspi->cur_direction & DATA_DIR_TX) + val |= SPI_IE_TX; +@@ -512,7 +562,18 @@ static int tegra_spi_start_dma_based_transfer( + tegra_spi_writel(tspi, val, SPI_DMA_CTL); + tspi->dma_control_reg = val; + ++ dma_sconfig.device_fc = true; + if (tspi->cur_direction & DATA_DIR_TX) { ++ dma_sconfig.dst_addr = tspi->phys + SPI_TX_FIFO; ++ dma_sconfig.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; ++ dma_sconfig.dst_maxburst = dma_burst; ++ ret = dmaengine_slave_config(tspi->tx_dma_chan, &dma_sconfig); ++ if (ret < 0) { ++ dev_err(tspi->dev, ++ "DMA slave config failed: %d\n", ret); ++ return ret; ++ } ++ + tegra_spi_copy_client_txbuf_to_spi_txbuf(tspi, t); + ret = tegra_spi_start_tx_dma(tspi, len); + if (ret < 0) { +@@ -523,6 +584,16 @@ static int tegra_spi_start_dma_based_transfer( + } + + if (tspi->cur_direction & DATA_DIR_RX) { ++ dma_sconfig.src_addr = tspi->phys + SPI_RX_FIFO; ++ dma_sconfig.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; ++ dma_sconfig.src_maxburst = dma_burst; ++ ret = dmaengine_slave_config(tspi->rx_dma_chan, &dma_sconfig); ++ if (ret < 0) { ++ dev_err(tspi->dev, ++ "DMA slave config failed: %d\n", ret); ++ return ret; ++ } ++ + /* Make the dma buffer to read by dma */ + dma_sync_single_for_device(tspi->dev, tspi->rx_dma_phys, + tspi->dma_buf_size, DMA_FROM_DEVICE); +@@ -582,7 +653,6 @@ static int tegra_spi_init_dma_param(struct tegra_spi_data *tspi, + u32 *dma_buf; + dma_addr_t dma_phys; + int ret; +- struct dma_slave_config dma_sconfig; + + dma_chan = dma_request_slave_channel_reason(tspi->dev, + dma_to_memory ? "rx" : "tx"); +@@ -602,19 +672,6 @@ static int tegra_spi_init_dma_param(struct tegra_spi_data *tspi, + return -ENOMEM; + } + +- if (dma_to_memory) { +- dma_sconfig.src_addr = tspi->phys + SPI_RX_FIFO; +- dma_sconfig.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; +- dma_sconfig.src_maxburst = 0; +- } else { +- dma_sconfig.dst_addr = tspi->phys + SPI_TX_FIFO; +- dma_sconfig.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; +- dma_sconfig.dst_maxburst = 0; +- } +- +- ret = dmaengine_slave_config(dma_chan, &dma_sconfig); +- if (ret) +- goto scrub; + if (dma_to_memory) { + tspi->rx_dma_chan = dma_chan; + tspi->rx_dma_buf = dma_buf; +@@ -625,11 +682,6 @@ static int tegra_spi_init_dma_param(struct tegra_spi_data *tspi, + tspi->tx_dma_phys = dma_phys; + } + return 0; +- +-scrub: +- dma_free_coherent(tspi->dev, tspi->dma_buf_size, dma_buf, dma_phys); +- dma_release_channel(dma_chan); +- return ret; + } + + static void tegra_spi_deinit_dma_param(struct tegra_spi_data *tspi, +@@ -730,6 +782,8 @@ static int tegra_spi_start_transfer_one(struct spi_device *spi, + + if (tspi->is_packed) + command1 |= SPI_PACKED; ++ else ++ command1 &= ~SPI_PACKED; + + command1 &= ~(SPI_CS_SEL_MASK | SPI_TX_EN | SPI_RX_EN); + tspi->cur_direction = 0; +@@ -748,6 +802,9 @@ static int tegra_spi_start_transfer_one(struct spi_device *spi, + dev_dbg(tspi->dev, "The def 0x%x and written 0x%x\n", + tspi->def_command1_reg, (unsigned)command1); + ++ ret = tegra_spi_flush_fifos(tspi); ++ if (ret < 0) ++ return ret; + if (total_fifo_words > SPI_FIFO_DEPTH) + ret = tegra_spi_start_dma_based_transfer(tspi, t); + else +@@ -838,7 +895,17 @@ static int tegra_spi_transfer_one_message(struct spi_master *master, + if (WARN_ON(ret == 0)) { + dev_err(tspi->dev, + "spi transfer timeout, err %d\n", ret); ++ if (tspi->is_curr_dma_xfer && ++ (tspi->cur_direction & DATA_DIR_TX)) ++ dmaengine_terminate_all(tspi->tx_dma_chan); ++ if (tspi->is_curr_dma_xfer && ++ (tspi->cur_direction & DATA_DIR_RX)) ++ dmaengine_terminate_all(tspi->rx_dma_chan); + ret = -EIO; ++ tegra_spi_flush_fifos(tspi); ++ reset_control_assert(tspi->rst); ++ udelay(2); ++ reset_control_deassert(tspi->rst); + goto complete_xfer; + } + +@@ -889,6 +956,7 @@ static irqreturn_t handle_cpu_based_xfer(struct tegra_spi_data *tspi) + tspi->status_reg); + dev_err(tspi->dev, "CpuXfer 0x%08x:0x%08x\n", + tspi->command1_reg, tspi->dma_control_reg); ++ tegra_spi_flush_fifos(tspi); + reset_control_assert(tspi->rst); + udelay(2); + reset_control_deassert(tspi->rst); +@@ -961,6 +1029,7 @@ static irqreturn_t handle_dma_based_xfer(struct tegra_spi_data *tspi) + tspi->status_reg); + dev_err(tspi->dev, "DmaXfer 0x%08x:0x%08x\n", + tspi->command1_reg, tspi->dma_control_reg); ++ tegra_spi_flush_fifos(tspi); + reset_control_assert(tspi->rst); + udelay(2); + reset_control_deassert(tspi->rst); +diff --git a/drivers/spi/spi-topcliff-pch.c b/drivers/spi/spi-topcliff-pch.c +index 4389ab80c23e..fa730a871d25 100644 +--- a/drivers/spi/spi-topcliff-pch.c ++++ b/drivers/spi/spi-topcliff-pch.c +@@ -1008,6 +1008,9 @@ static void pch_spi_handle_dma(struct pch_spi_data *data, int *bpw) + + /* RX */ + dma->sg_rx_p = kcalloc(num, sizeof(*dma->sg_rx_p), GFP_ATOMIC); ++ if (!dma->sg_rx_p) ++ return; ++ + sg_init_table(dma->sg_rx_p, num); /* Initialize SG table */ + /* offset, length setting */ + sg = dma->sg_rx_p; +@@ -1068,6 +1071,9 @@ static void pch_spi_handle_dma(struct pch_spi_data *data, int *bpw) + } + + dma->sg_tx_p = kcalloc(num, sizeof(*dma->sg_tx_p), GFP_ATOMIC); ++ if (!dma->sg_tx_p) ++ return; ++ + sg_init_table(dma->sg_tx_p, num); /* Initialize SG table */ + /* offset, length setting */ + sg = dma->sg_tx_p; +diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c +index 36361bdf934a..2f82dcb1fd06 100644 +--- a/drivers/staging/comedi/drivers/ni_mio_common.c ++++ b/drivers/staging/comedi/drivers/ni_mio_common.c +@@ -4991,7 +4991,10 @@ static int ni_valid_rtsi_output_source(struct comedi_device *dev, + case NI_RTSI_OUTPUT_G_SRC0: + case NI_RTSI_OUTPUT_G_GATE0: + case NI_RTSI_OUTPUT_RGOUT0: +- case NI_RTSI_OUTPUT_RTSI_BRD_0: ++ case NI_RTSI_OUTPUT_RTSI_BRD(0): ++ case NI_RTSI_OUTPUT_RTSI_BRD(1): ++ case NI_RTSI_OUTPUT_RTSI_BRD(2): ++ case NI_RTSI_OUTPUT_RTSI_BRD(3): + return 1; + case NI_RTSI_OUTPUT_RTSI_OSC: + return (devpriv->is_m_series) ? 1 : 0; +@@ -5012,11 +5015,18 @@ static int ni_set_rtsi_routing(struct comedi_device *dev, + devpriv->rtsi_trig_a_output_reg |= NISTC_RTSI_TRIG(chan, src); + ni_stc_writew(dev, devpriv->rtsi_trig_a_output_reg, + NISTC_RTSI_TRIGA_OUT_REG); +- } else if (chan < 8) { ++ } else if (chan < NISTC_RTSI_TRIG_NUM_CHAN(devpriv->is_m_series)) { + devpriv->rtsi_trig_b_output_reg &= ~NISTC_RTSI_TRIG_MASK(chan); + devpriv->rtsi_trig_b_output_reg |= NISTC_RTSI_TRIG(chan, src); + ni_stc_writew(dev, devpriv->rtsi_trig_b_output_reg, + NISTC_RTSI_TRIGB_OUT_REG); ++ } else if (chan != NISTC_RTSI_TRIG_OLD_CLK_CHAN) { ++ /* probably should never reach this, since the ++ * ni_valid_rtsi_output_source above errors out if chan is too ++ * high ++ */ ++ dev_err(dev->class_dev, "%s: unknown rtsi channel\n", __func__); ++ return -EINVAL; + } + return 2; + } +@@ -5032,12 +5042,12 @@ static unsigned int ni_get_rtsi_routing(struct comedi_device *dev, + } else if (chan < NISTC_RTSI_TRIG_NUM_CHAN(devpriv->is_m_series)) { + return NISTC_RTSI_TRIG_TO_SRC(chan, + devpriv->rtsi_trig_b_output_reg); +- } else { +- if (chan == NISTC_RTSI_TRIG_OLD_CLK_CHAN) +- return NI_RTSI_OUTPUT_RTSI_OSC; +- dev_err(dev->class_dev, "bug! should never get here?\n"); +- return 0; ++ } else if (chan == NISTC_RTSI_TRIG_OLD_CLK_CHAN) { ++ return NI_RTSI_OUTPUT_RTSI_OSC; + } ++ ++ dev_err(dev->class_dev, "%s: unknown rtsi channel\n", __func__); ++ return -EINVAL; + } + + static int ni_rtsi_insn_config(struct comedi_device *dev, +diff --git a/drivers/staging/greybus/light.c b/drivers/staging/greybus/light.c +index 0f538b8c3a07..4e7575147775 100644 +--- a/drivers/staging/greybus/light.c ++++ b/drivers/staging/greybus/light.c +@@ -1103,21 +1103,21 @@ static void gb_lights_channel_release(struct gb_channel *channel) + static void gb_lights_light_release(struct gb_light *light) + { + int i; +- int count; + + light->ready = false; + +- count = light->channels_count; +- + if (light->has_flash) + gb_lights_light_v4l2_unregister(light); ++ light->has_flash = false; + +- for (i = 0; i < count; i++) { ++ for (i = 0; i < light->channels_count; i++) + gb_lights_channel_release(&light->channels[i]); +- light->channels_count--; +- } ++ light->channels_count = 0; ++ + kfree(light->channels); ++ light->channels = NULL; + kfree(light->name); ++ light->name = NULL; + } + + static void gb_lights_release(struct gb_lights *glights) +diff --git a/drivers/staging/most/aim-cdev/cdev.c b/drivers/staging/most/aim-cdev/cdev.c +index 1e5cbc893496..d000b6ff8a7d 100644 +--- a/drivers/staging/most/aim-cdev/cdev.c ++++ b/drivers/staging/most/aim-cdev/cdev.c +@@ -455,7 +455,9 @@ static int aim_probe(struct most_interface *iface, int channel_id, + c->devno = MKDEV(major, current_minor); + cdev_init(&c->cdev, &channel_fops); + c->cdev.owner = THIS_MODULE; +- cdev_add(&c->cdev, c->devno, 1); ++ retval = cdev_add(&c->cdev, c->devno, 1); ++ if (retval < 0) ++ goto err_free_c; + c->iface = iface; + c->cfg = cfg; + c->channel_id = channel_id; +@@ -491,6 +493,7 @@ error_create_device: + list_del(&c->list); + error_alloc_kfifo: + cdev_del(&c->cdev); ++err_free_c: + kfree(c); + error_alloc_channel: + ida_simple_remove(&minor_id, current_minor); +diff --git a/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_func_88xx.c b/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_func_88xx.c +index 544f638ed3ef..65edd14a1147 100644 +--- a/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_func_88xx.c ++++ b/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_func_88xx.c +@@ -2492,8 +2492,11 @@ halmac_parse_psd_data_88xx(struct halmac_adapter *halmac_adapter, u8 *c2h_buf, + segment_size = (u8)PSD_DATA_GET_SEGMENT_SIZE(c2h_buf); + psd_set->data_size = total_size; + +- if (!psd_set->data) ++ if (!psd_set->data) { + psd_set->data = kzalloc(psd_set->data_size, GFP_KERNEL); ++ if (!psd_set->data) ++ return HALMAC_RET_MALLOC_FAIL; ++ } + + if (segment_id == 0) + psd_set->segment_size = segment_size; +diff --git a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c +index 377da037f31c..b521752d9aa0 100644 +--- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c ++++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c +@@ -1849,6 +1849,12 @@ static int __init bm2835_mmal_init(void) + num_cameras = get_num_cameras(instance, + resolutions, + MAX_BCM2835_CAMERAS); ++ ++ if (num_cameras < 1) { ++ ret = -ENODEV; ++ goto cleanup_mmal; ++ } ++ + if (num_cameras > MAX_BCM2835_CAMERAS) + num_cameras = MAX_BCM2835_CAMERAS; + +@@ -1948,6 +1954,9 @@ cleanup_gdev: + pr_info("%s: error %d while loading driver\n", + BM2835_MMAL_MODULE_NAME, ret); + ++cleanup_mmal: ++ vchiq_mmal_finalise(instance); ++ + return ret; + } + +diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c +index 92b52d2314b5..cebef8e5a43d 100644 +--- a/drivers/target/target_core_device.c ++++ b/drivers/target/target_core_device.c +@@ -85,7 +85,7 @@ transport_lookup_cmd_lun(struct se_cmd *se_cmd, u64 unpacked_lun) + goto out_unlock; + } + +- se_cmd->se_lun = rcu_dereference(deve->se_lun); ++ se_cmd->se_lun = se_lun; + se_cmd->pr_res_key = deve->pr_res_key; + se_cmd->orig_fe_lun = unpacked_lun; + se_cmd->se_cmd_flags |= SCF_SE_LUN_CMD; +@@ -176,7 +176,7 @@ int transport_lookup_tmr_lun(struct se_cmd *se_cmd, u64 unpacked_lun) + goto out_unlock; + } + +- se_cmd->se_lun = rcu_dereference(deve->se_lun); ++ se_cmd->se_lun = se_lun; + se_cmd->pr_res_key = deve->pr_res_key; + se_cmd->orig_fe_lun = unpacked_lun; + se_cmd->se_cmd_flags |= SCF_SE_LUN_CMD; +diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c +index 908a8014cf76..aed995ec2c90 100644 +--- a/drivers/thermal/cpu_cooling.c ++++ b/drivers/thermal/cpu_cooling.c +@@ -514,7 +514,7 @@ static int cpufreq_get_requested_power(struct thermal_cooling_device *cdev, + load = 0; + + total_load += load; +- if (trace_thermal_power_cpu_limit_enabled() && load_cpu) ++ if (load_cpu) + load_cpu[i] = load; + + i++; +diff --git a/drivers/thermal/mtk_thermal.c b/drivers/thermal/mtk_thermal.c +index 1e61c09153c9..76b92083744c 100644 +--- a/drivers/thermal/mtk_thermal.c ++++ b/drivers/thermal/mtk_thermal.c +@@ -407,7 +407,8 @@ static int mtk_thermal_bank_temperature(struct mtk_thermal_bank *bank) + u32 raw; + + for (i = 0; i < conf->bank_data[bank->id].num_sensors; i++) { +- raw = readl(mt->thermal_base + conf->msr[i]); ++ raw = readl(mt->thermal_base + ++ conf->msr[conf->bank_data[bank->id].sensors[i]]); + + temp = raw_to_mcelsius(mt, + conf->bank_data[bank->id].sensors[i], +@@ -544,7 +545,8 @@ static void mtk_thermal_init_bank(struct mtk_thermal *mt, int num, + + for (i = 0; i < conf->bank_data[num].num_sensors; i++) + writel(conf->sensor_mux_values[conf->bank_data[num].sensors[i]], +- mt->thermal_base + conf->adcpnp[i]); ++ mt->thermal_base + ++ conf->adcpnp[conf->bank_data[num].sensors[i]]); + + writel((1 << conf->bank_data[num].num_sensors) - 1, + mt->thermal_base + TEMP_MONCTL0); +diff --git a/drivers/tty/ipwireless/hardware.c b/drivers/tty/ipwireless/hardware.c +index a6b8240af6cd..960e9375a1a9 100644 +--- a/drivers/tty/ipwireless/hardware.c ++++ b/drivers/tty/ipwireless/hardware.c +@@ -1516,6 +1516,8 @@ static void ipw_send_setup_packet(struct ipw_hardware *hw) + sizeof(struct ipw_setup_get_version_query_packet), + ADDR_SETUP_PROT, TL_PROTOCOLID_SETUP, + TL_SETUP_SIGNO_GET_VERSION_QRY); ++ if (!ver_packet) ++ return; + ver_packet->header.length = sizeof(struct tl_setup_get_version_qry); + + /* +diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c +index fb2dcb3f8591..16422987ab0f 100644 +--- a/drivers/tty/serial/fsl_lpuart.c ++++ b/drivers/tty/serial/fsl_lpuart.c +@@ -532,26 +532,26 @@ static int lpuart32_poll_init(struct uart_port *port) + spin_lock_irqsave(&sport->port.lock, flags); + + /* Disable Rx & Tx */ +- writel(0, sport->port.membase + UARTCTRL); ++ lpuart32_write(&sport->port, UARTCTRL, 0); + +- temp = readl(sport->port.membase + UARTFIFO); ++ temp = lpuart32_read(&sport->port, UARTFIFO); + + /* Enable Rx and Tx FIFO */ +- writel(temp | UARTFIFO_RXFE | UARTFIFO_TXFE, +- sport->port.membase + UARTFIFO); ++ lpuart32_write(&sport->port, UARTFIFO, ++ temp | UARTFIFO_RXFE | UARTFIFO_TXFE); + + /* flush Tx and Rx FIFO */ +- writel(UARTFIFO_TXFLUSH | UARTFIFO_RXFLUSH, +- sport->port.membase + UARTFIFO); ++ lpuart32_write(&sport->port, UARTFIFO, ++ UARTFIFO_TXFLUSH | UARTFIFO_RXFLUSH); + + /* explicitly clear RDRF */ +- if (readl(sport->port.membase + UARTSTAT) & UARTSTAT_RDRF) { +- readl(sport->port.membase + UARTDATA); +- writel(UARTFIFO_RXUF, sport->port.membase + UARTFIFO); ++ if (lpuart32_read(&sport->port, UARTSTAT) & UARTSTAT_RDRF) { ++ lpuart32_read(&sport->port, UARTDATA); ++ lpuart32_write(&sport->port, UARTFIFO, UARTFIFO_RXUF); + } + + /* Enable Rx and Tx */ +- writel(UARTCTRL_RE | UARTCTRL_TE, sport->port.membase + UARTCTRL); ++ lpuart32_write(&sport->port, UARTCTRL, UARTCTRL_RE | UARTCTRL_TE); + spin_unlock_irqrestore(&sport->port.lock, flags); + + return 0; +@@ -559,18 +559,18 @@ static int lpuart32_poll_init(struct uart_port *port) + + static void lpuart32_poll_put_char(struct uart_port *port, unsigned char c) + { +- while (!(readl(port->membase + UARTSTAT) & UARTSTAT_TDRE)) ++ while (!(lpuart32_read(port, UARTSTAT) & UARTSTAT_TDRE)) + barrier(); + +- writel(c, port->membase + UARTDATA); ++ lpuart32_write(port, UARTDATA, c); + } + + static int lpuart32_poll_get_char(struct uart_port *port) + { +- if (!(readl(port->membase + UARTSTAT) & UARTSTAT_RDRF)) ++ if (!(lpuart32_read(port, UARTSTAT) & UARTSTAT_RDRF)) + return NO_POLL_CHAR; + +- return readl(port->membase + UARTDATA); ++ return lpuart32_read(port, UARTDATA); + } + #endif + +diff --git a/drivers/tty/serial/stm32-usart.c b/drivers/tty/serial/stm32-usart.c +index 03a583264d9e..1e854e1851fb 100644 +--- a/drivers/tty/serial/stm32-usart.c ++++ b/drivers/tty/serial/stm32-usart.c +@@ -118,35 +118,51 @@ static void stm32_receive_chars(struct uart_port *port, bool threaded) + + while (stm32_pending_rx(port, &sr, &stm32_port->last_res, threaded)) { + sr |= USART_SR_DUMMY_RX; +- c = stm32_get_char(port, &sr, &stm32_port->last_res); + flag = TTY_NORMAL; +- port->icount.rx++; + ++ /* ++ * Status bits has to be cleared before reading the RDR: ++ * In FIFO mode, reading the RDR will pop the next data ++ * (if any) along with its status bits into the SR. ++ * Not doing so leads to misalignement between RDR and SR, ++ * and clear status bits of the next rx data. ++ * ++ * Clear errors flags for stm32f7 and stm32h7 compatible ++ * devices. On stm32f4 compatible devices, the error bit is ++ * cleared by the sequence [read SR - read DR]. ++ */ ++ if ((sr & USART_SR_ERR_MASK) && ofs->icr != UNDEF_REG) ++ writel_relaxed(sr & USART_SR_ERR_MASK, ++ port->membase + ofs->icr); ++ ++ c = stm32_get_char(port, &sr, &stm32_port->last_res); ++ port->icount.rx++; + if (sr & USART_SR_ERR_MASK) { +- if (sr & USART_SR_LBD) { +- port->icount.brk++; +- if (uart_handle_break(port)) +- continue; +- } else if (sr & USART_SR_ORE) { +- if (ofs->icr != UNDEF_REG) +- writel_relaxed(USART_ICR_ORECF, +- port->membase + +- ofs->icr); ++ if (sr & USART_SR_ORE) { + port->icount.overrun++; + } else if (sr & USART_SR_PE) { + port->icount.parity++; + } else if (sr & USART_SR_FE) { +- port->icount.frame++; ++ /* Break detection if character is null */ ++ if (!c) { ++ port->icount.brk++; ++ if (uart_handle_break(port)) ++ continue; ++ } else { ++ port->icount.frame++; ++ } + } + + sr &= port->read_status_mask; + +- if (sr & USART_SR_LBD) +- flag = TTY_BREAK; +- else if (sr & USART_SR_PE) ++ if (sr & USART_SR_PE) { + flag = TTY_PARITY; +- else if (sr & USART_SR_FE) +- flag = TTY_FRAME; ++ } else if (sr & USART_SR_FE) { ++ if (!c) ++ flag = TTY_BREAK; ++ else ++ flag = TTY_FRAME; ++ } + } + + if (uart_handle_sysrq_char(port, c)) +@@ -164,21 +180,6 @@ static void stm32_tx_dma_complete(void *arg) + struct uart_port *port = arg; + struct stm32_port *stm32port = to_stm32_port(port); + struct stm32_usart_offsets *ofs = &stm32port->info->ofs; +- unsigned int isr; +- int ret; +- +- ret = readl_relaxed_poll_timeout_atomic(port->membase + ofs->isr, +- isr, +- (isr & USART_SR_TC), +- 10, 100000); +- +- if (ret) +- dev_err(port->dev, "terminal count not set\n"); +- +- if (ofs->icr == UNDEF_REG) +- stm32_clr_bits(port, ofs->isr, USART_SR_TC); +- else +- stm32_set_bits(port, ofs->icr, USART_CR_TC); + + stm32_clr_bits(port, ofs->cr3, USART_CR3_DMAT); + stm32port->tx_dma_busy = false; +@@ -270,7 +271,6 @@ static void stm32_transmit_chars_dma(struct uart_port *port) + /* Issue pending DMA TX requests */ + dma_async_issue_pending(stm32port->tx_ch); + +- stm32_clr_bits(port, ofs->isr, USART_SR_TC); + stm32_set_bits(port, ofs->cr3, USART_CR3_DMAT); + + xmit->tail = (xmit->tail + count) & (UART_XMIT_SIZE - 1); +@@ -294,15 +294,15 @@ static void stm32_transmit_chars(struct uart_port *port) + return; + } + +- if (uart_tx_stopped(port)) { +- stm32_stop_tx(port); ++ if (uart_circ_empty(xmit) || uart_tx_stopped(port)) { ++ stm32_clr_bits(port, ofs->cr1, USART_CR1_TXEIE); + return; + } + +- if (uart_circ_empty(xmit)) { +- stm32_stop_tx(port); +- return; +- } ++ if (ofs->icr == UNDEF_REG) ++ stm32_clr_bits(port, ofs->isr, USART_SR_TC); ++ else ++ writel_relaxed(USART_ICR_TCCF, port->membase + ofs->icr); + + if (stm32_port->tx_ch) + stm32_transmit_chars_dma(port); +@@ -313,7 +313,7 @@ static void stm32_transmit_chars(struct uart_port *port) + uart_write_wakeup(port); + + if (uart_circ_empty(xmit)) +- stm32_stop_tx(port); ++ stm32_clr_bits(port, ofs->cr1, USART_CR1_TXEIE); + } + + static irqreturn_t stm32_interrupt(int irq, void *ptr) +@@ -447,7 +447,6 @@ static int stm32_startup(struct uart_port *port) + { + struct stm32_port *stm32_port = to_stm32_port(port); + struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; +- struct stm32_usart_config *cfg = &stm32_port->info->cfg; + const char *name = to_platform_device(port->dev)->name; + u32 val; + int ret; +@@ -458,15 +457,6 @@ static int stm32_startup(struct uart_port *port) + if (ret) + return ret; + +- if (cfg->has_wakeup && stm32_port->wakeirq >= 0) { +- ret = dev_pm_set_dedicated_wake_irq(port->dev, +- stm32_port->wakeirq); +- if (ret) { +- free_irq(port->irq, port); +- return ret; +- } +- } +- + val = USART_CR1_RXNEIE | USART_CR1_TE | USART_CR1_RE; + if (stm32_port->fifoen) + val |= USART_CR1_FIFOEN; +@@ -480,15 +470,23 @@ static void stm32_shutdown(struct uart_port *port) + struct stm32_port *stm32_port = to_stm32_port(port); + struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; + struct stm32_usart_config *cfg = &stm32_port->info->cfg; +- u32 val; ++ u32 val, isr; ++ int ret; + + val = USART_CR1_TXEIE | USART_CR1_RXNEIE | USART_CR1_TE | USART_CR1_RE; + val |= BIT(cfg->uart_enable_bit); + if (stm32_port->fifoen) + val |= USART_CR1_FIFOEN; ++ ++ ret = readl_relaxed_poll_timeout(port->membase + ofs->isr, ++ isr, (isr & USART_SR_TC), ++ 10, 100000); ++ ++ if (ret) ++ dev_err(port->dev, "transmission complete not set\n"); ++ + stm32_clr_bits(port, ofs->cr1, val); + +- dev_pm_clear_wake_irq(port->dev); + free_irq(port->irq, port); + } + +@@ -569,14 +567,14 @@ static void stm32_set_termios(struct uart_port *port, struct ktermios *termios, + if (termios->c_iflag & INPCK) + port->read_status_mask |= USART_SR_PE | USART_SR_FE; + if (termios->c_iflag & (IGNBRK | BRKINT | PARMRK)) +- port->read_status_mask |= USART_SR_LBD; ++ port->read_status_mask |= USART_SR_FE; + + /* Characters to ignore */ + port->ignore_status_mask = 0; + if (termios->c_iflag & IGNPAR) + port->ignore_status_mask = USART_SR_PE | USART_SR_FE; + if (termios->c_iflag & IGNBRK) { +- port->ignore_status_mask |= USART_SR_LBD; ++ port->ignore_status_mask |= USART_SR_FE; + /* + * If we're ignoring parity and break indicators, + * ignore overruns too (for real raw support). +@@ -895,11 +893,18 @@ static int stm32_serial_probe(struct platform_device *pdev) + ret = device_init_wakeup(&pdev->dev, true); + if (ret) + goto err_uninit; ++ ++ ret = dev_pm_set_dedicated_wake_irq(&pdev->dev, ++ stm32port->wakeirq); ++ if (ret) ++ goto err_nowup; ++ ++ device_set_wakeup_enable(&pdev->dev, false); + } + + ret = uart_add_one_port(&stm32_usart_driver, &stm32port->port); + if (ret) +- goto err_nowup; ++ goto err_wirq; + + ret = stm32_of_dma_rx_probe(stm32port, pdev); + if (ret) +@@ -913,6 +918,10 @@ static int stm32_serial_probe(struct platform_device *pdev) + + return 0; + ++err_wirq: ++ if (stm32port->info->cfg.has_wakeup && stm32port->wakeirq >= 0) ++ dev_pm_clear_wake_irq(&pdev->dev); ++ + err_nowup: + if (stm32port->info->cfg.has_wakeup && stm32port->wakeirq >= 0) + device_init_wakeup(&pdev->dev, false); +@@ -950,8 +959,10 @@ static int stm32_serial_remove(struct platform_device *pdev) + TX_BUF_L, stm32_port->tx_buf, + stm32_port->tx_dma_buf); + +- if (cfg->has_wakeup && stm32_port->wakeirq >= 0) ++ if (cfg->has_wakeup && stm32_port->wakeirq >= 0) { ++ dev_pm_clear_wake_irq(&pdev->dev); + device_init_wakeup(&pdev->dev, false); ++ } + + clk_disable_unprepare(stm32_port->clk); + +diff --git a/drivers/tty/serial/stm32-usart.h b/drivers/tty/serial/stm32-usart.h +index ffc0c5285e51..9d087881913a 100644 +--- a/drivers/tty/serial/stm32-usart.h ++++ b/drivers/tty/serial/stm32-usart.h +@@ -108,7 +108,6 @@ struct stm32_usart_info stm32h7_info = { + #define USART_SR_RXNE BIT(5) + #define USART_SR_TC BIT(6) + #define USART_SR_TXE BIT(7) +-#define USART_SR_LBD BIT(8) + #define USART_SR_CTSIF BIT(9) + #define USART_SR_CTS BIT(10) /* F7 */ + #define USART_SR_RTOF BIT(11) /* F7 */ +@@ -120,8 +119,7 @@ struct stm32_usart_info stm32h7_info = { + #define USART_SR_SBKF BIT(18) /* F7 */ + #define USART_SR_WUF BIT(20) /* H7 */ + #define USART_SR_TEACK BIT(21) /* F7 */ +-#define USART_SR_ERR_MASK (USART_SR_LBD | USART_SR_ORE | \ +- USART_SR_FE | USART_SR_PE) ++#define USART_SR_ERR_MASK (USART_SR_ORE | USART_SR_FE | USART_SR_PE) + /* Dummy bits */ + #define USART_SR_DUMMY_RX BIT(16) + +@@ -166,8 +164,6 @@ struct stm32_usart_info stm32h7_info = { + /* USART_CR2 */ + #define USART_CR2_ADD_MASK GENMASK(3, 0) /* F4 */ + #define USART_CR2_ADDM7 BIT(4) /* F7 */ +-#define USART_CR2_LBDL BIT(5) +-#define USART_CR2_LBDIE BIT(6) + #define USART_CR2_LBCL BIT(8) + #define USART_CR2_CPHA BIT(9) + #define USART_CR2_CPOL BIT(10) +@@ -224,12 +220,10 @@ struct stm32_usart_info stm32h7_info = { + + /* USART_ICR */ + #define USART_ICR_PECF BIT(0) /* F7 */ +-#define USART_ICR_FFECF BIT(1) /* F7 */ +-#define USART_ICR_NCF BIT(2) /* F7 */ ++#define USART_ICR_FECF BIT(1) /* F7 */ + #define USART_ICR_ORECF BIT(3) /* F7 */ + #define USART_ICR_IDLECF BIT(4) /* F7 */ + #define USART_ICR_TCCF BIT(6) /* F7 */ +-#define USART_ICR_LBDCF BIT(8) /* F7 */ + #define USART_ICR_CTSCF BIT(9) /* F7 */ + #define USART_ICR_RTOCF BIT(11) /* F7 */ + #define USART_ICR_EOBCF BIT(12) /* F7 */ +diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c +index fb5c9701b1fb..7c18536a3742 100644 +--- a/drivers/uio/uio.c ++++ b/drivers/uio/uio.c +@@ -939,9 +939,12 @@ int __uio_register_device(struct module *owner, + atomic_set(&idev->event, 0); + + ret = uio_get_minor(idev); +- if (ret) ++ if (ret) { ++ kfree(idev); + return ret; ++ } + ++ device_initialize(&idev->dev); + idev->dev.devt = MKDEV(uio_major, idev->minor); + idev->dev.class = &uio_class; + idev->dev.parent = parent; +@@ -952,7 +955,7 @@ int __uio_register_device(struct module *owner, + if (ret) + goto err_device_create; + +- ret = device_register(&idev->dev); ++ ret = device_add(&idev->dev); + if (ret) + goto err_device_create; + +@@ -984,9 +987,10 @@ int __uio_register_device(struct module *owner, + err_request_irq: + uio_dev_del_attributes(idev); + err_uio_dev_add_attributes: +- device_unregister(&idev->dev); ++ device_del(&idev->dev); + err_device_create: + uio_free_minor(idev); ++ put_device(&idev->dev); + return ret; + } + EXPORT_SYMBOL_GPL(__uio_register_device); +diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c +index a593cdfc897f..d5d42dccda10 100644 +--- a/drivers/usb/class/cdc-wdm.c ++++ b/drivers/usb/class/cdc-wdm.c +@@ -1085,7 +1085,7 @@ static int wdm_post_reset(struct usb_interface *intf) + rv = recover_from_urb_loss(desc); + mutex_unlock(&desc->wlock); + mutex_unlock(&desc->rlock); +- return 0; ++ return rv; + } + + static struct usb_driver wdm_driver = { +diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c +index e164439b2154..4af9a1c652ed 100644 +--- a/drivers/usb/dwc2/gadget.c ++++ b/drivers/usb/dwc2/gadget.c +@@ -2276,6 +2276,7 @@ static unsigned int dwc2_gadget_get_xfersize_ddma(struct dwc2_hsotg_ep *hs_ep) + if (status & DEV_DMA_STS_MASK) + dev_err(hsotg->dev, "descriptor %d closed with %x\n", + i, status & DEV_DMA_STS_MASK); ++ desc++; + } + + return bytes_rem; +diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c +index d1363f3fabfa..3bb38d9dc45b 100644 +--- a/drivers/usb/host/xhci-hub.c ++++ b/drivers/usb/host/xhci-hub.c +@@ -1118,7 +1118,7 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, + } + port_li = readl(port_array[wIndex] + PORTLI); + status = xhci_get_ext_port_status(temp, port_li); +- put_unaligned_le32(cpu_to_le32(status), &buf[4]); ++ put_unaligned_le32(status, &buf[4]); + } + break; + case SetPortFeature: +diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig +index 85a92d0813dd..440238061edd 100644 +--- a/drivers/usb/phy/Kconfig ++++ b/drivers/usb/phy/Kconfig +@@ -20,7 +20,7 @@ config AB8500_USB + in host mode, low speed. + + config FSL_USB2_OTG +- bool "Freescale USB OTG Transceiver Driver" ++ tristate "Freescale USB OTG Transceiver Driver" + depends on USB_EHCI_FSL && USB_FSL_USB2 && USB_OTG_FSM=y && PM + depends on USB_GADGET || !USB_GADGET # if USB_GADGET=m, this can't be 'y' + select USB_PHY +diff --git a/drivers/usb/phy/phy-twl6030-usb.c b/drivers/usb/phy/phy-twl6030-usb.c +index b5dc077ed7d3..8e14fa221191 100644 +--- a/drivers/usb/phy/phy-twl6030-usb.c ++++ b/drivers/usb/phy/phy-twl6030-usb.c +@@ -413,7 +413,7 @@ static int twl6030_usb_remove(struct platform_device *pdev) + { + struct twl6030_usb *twl = platform_get_drvdata(pdev); + +- cancel_delayed_work(&twl->get_status_work); ++ cancel_delayed_work_sync(&twl->get_status_work); + twl6030_interrupt_mask(TWL6030_USBOTG_INT_MASK, + REG_INT_MSK_LINE_C); + twl6030_interrupt_mask(TWL6030_USBOTG_INT_MASK, +diff --git a/drivers/vfio/mdev/mdev_core.c b/drivers/vfio/mdev/mdev_core.c +index 0212f0ee8aea..e052f62fdea7 100644 +--- a/drivers/vfio/mdev/mdev_core.c ++++ b/drivers/vfio/mdev/mdev_core.c +@@ -150,10 +150,10 @@ static int mdev_device_remove_ops(struct mdev_device *mdev, bool force_remove) + + static int mdev_device_remove_cb(struct device *dev, void *data) + { +- if (!dev_is_mdev(dev)) +- return 0; ++ if (dev_is_mdev(dev)) ++ mdev_device_remove(dev, true); + +- return mdev_device_remove(dev, data ? *(bool *)data : true); ++ return 0; + } + + /* +@@ -182,6 +182,7 @@ int mdev_register_device(struct device *dev, const struct mdev_parent_ops *ops) + /* Check for duplicate */ + parent = __find_parent_device(dev); + if (parent) { ++ parent = NULL; + ret = -EEXIST; + goto add_dev_err; + } +@@ -240,7 +241,6 @@ EXPORT_SYMBOL(mdev_register_device); + void mdev_unregister_device(struct device *dev) + { + struct mdev_parent *parent; +- bool force_remove = true; + + mutex_lock(&parent_list_lock); + parent = __find_parent_device(dev); +@@ -254,8 +254,7 @@ void mdev_unregister_device(struct device *dev) + list_del(&parent->next); + class_compat_remove_link(mdev_bus_compat_class, dev, NULL); + +- device_for_each_child(dev, (void *)&force_remove, +- mdev_device_remove_cb); ++ device_for_each_child(dev, NULL, mdev_device_remove_cb); + + parent_remove_sysfs_files(parent); + +diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c +index 9bd3e7911af2..550ab7707b57 100644 +--- a/drivers/vfio/pci/vfio_pci.c ++++ b/drivers/vfio/pci/vfio_pci.c +@@ -717,6 +717,7 @@ static long vfio_pci_ioctl(void *device_data, + { + void __iomem *io; + size_t size; ++ u16 orig_cmd; + + info.offset = VFIO_PCI_INDEX_TO_OFFSET(info.index); + info.flags = 0; +@@ -732,15 +733,23 @@ static long vfio_pci_ioctl(void *device_data, + break; + } + +- /* Is it really there? */ ++ /* ++ * Is it really there? Enable memory decode for ++ * implicit access in pci_map_rom(). ++ */ ++ pci_read_config_word(pdev, PCI_COMMAND, &orig_cmd); ++ pci_write_config_word(pdev, PCI_COMMAND, ++ orig_cmd | PCI_COMMAND_MEMORY); ++ + io = pci_map_rom(pdev, &size); +- if (!io || !size) { ++ if (io) { ++ info.flags = VFIO_REGION_INFO_FLAG_READ; ++ pci_unmap_rom(pdev, io); ++ } else { + info.size = 0; +- break; + } +- pci_unmap_rom(pdev, io); + +- info.flags = VFIO_REGION_INFO_FLAG_READ; ++ pci_write_config_word(pdev, PCI_COMMAND, orig_cmd); + break; + } + case VFIO_PCI_VGA_REGION_INDEX: +diff --git a/drivers/video/backlight/lm3630a_bl.c b/drivers/video/backlight/lm3630a_bl.c +index 2030a6b77a09..ef2553f452ca 100644 +--- a/drivers/video/backlight/lm3630a_bl.c ++++ b/drivers/video/backlight/lm3630a_bl.c +@@ -201,7 +201,7 @@ static int lm3630a_bank_a_update_status(struct backlight_device *bl) + LM3630A_LEDA_ENABLE, LM3630A_LEDA_ENABLE); + if (ret < 0) + goto out_i2c_err; +- return bl->props.brightness; ++ return 0; + + out_i2c_err: + dev_err(pchip->dev, "i2c failed to access\n"); +@@ -278,7 +278,7 @@ static int lm3630a_bank_b_update_status(struct backlight_device *bl) + LM3630A_LEDB_ENABLE, LM3630A_LEDB_ENABLE); + if (ret < 0) + goto out_i2c_err; +- return bl->props.brightness; ++ return 0; + + out_i2c_err: + dev_err(pchip->dev, "i2c failed to access REG_CTRL\n"); +diff --git a/drivers/video/fbdev/chipsfb.c b/drivers/video/fbdev/chipsfb.c +index f103665cad43..f9b366d17587 100644 +--- a/drivers/video/fbdev/chipsfb.c ++++ b/drivers/video/fbdev/chipsfb.c +@@ -350,7 +350,7 @@ static void init_chips(struct fb_info *p, unsigned long addr) + static int chipsfb_pci_init(struct pci_dev *dp, const struct pci_device_id *ent) + { + struct fb_info *p; +- unsigned long addr, size; ++ unsigned long addr; + unsigned short cmd; + int rc = -ENODEV; + +@@ -362,7 +362,6 @@ static int chipsfb_pci_init(struct pci_dev *dp, const struct pci_device_id *ent) + if ((dp->resource[0].flags & IORESOURCE_MEM) == 0) + goto err_disable; + addr = pci_resource_start(dp, 0); +- size = pci_resource_len(dp, 0); + if (addr == 0) + goto err_disable; + +diff --git a/drivers/xen/cpu_hotplug.c b/drivers/xen/cpu_hotplug.c +index b1357aa4bc55..f192b6f42da9 100644 +--- a/drivers/xen/cpu_hotplug.c ++++ b/drivers/xen/cpu_hotplug.c +@@ -54,7 +54,7 @@ static int vcpu_online(unsigned int cpu) + } + static void vcpu_hotplug(unsigned int cpu) + { +- if (!cpu_possible(cpu)) ++ if (cpu >= nr_cpu_ids || !cpu_possible(cpu)) + return; + + switch (vcpu_online(cpu)) { +diff --git a/drivers/xen/pvcalls-back.c b/drivers/xen/pvcalls-back.c +index abd6dbc29ac2..58be15c27b6d 100644 +--- a/drivers/xen/pvcalls-back.c ++++ b/drivers/xen/pvcalls-back.c +@@ -792,7 +792,7 @@ static int pvcalls_back_poll(struct xenbus_device *dev, + mappass->reqcopy = *req; + icsk = inet_csk(mappass->sock->sk); + queue = &icsk->icsk_accept_queue; +- data = queue->rskq_accept_head != NULL; ++ data = READ_ONCE(queue->rskq_accept_head) != NULL; + if (data) { + mappass->reqcopy.cmd = 0; + ret = 0; +diff --git a/fs/affs/super.c b/fs/affs/super.c +index 884bedab7266..789a1c7db5d8 100644 +--- a/fs/affs/super.c ++++ b/fs/affs/super.c +@@ -559,14 +559,9 @@ affs_remount(struct super_block *sb, int *flags, char *data) + int root_block; + unsigned long mount_flags; + int res = 0; +- char *new_opts; + char volume[32]; + char *prefix = NULL; + +- new_opts = kstrdup(data, GFP_KERNEL); +- if (data && !new_opts) +- return -ENOMEM; +- + pr_debug("%s(flags=0x%x,opts=\"%s\")\n", __func__, *flags, data); + + sync_filesystem(sb); +@@ -577,7 +572,6 @@ affs_remount(struct super_block *sb, int *flags, char *data) + &blocksize, &prefix, volume, + &mount_flags)) { + kfree(prefix); +- kfree(new_opts); + return -EINVAL; + } + +diff --git a/fs/afs/super.c b/fs/afs/super.c +index 689173c0a682..f8529ddbd587 100644 +--- a/fs/afs/super.c ++++ b/fs/afs/super.c +@@ -359,6 +359,7 @@ static int afs_fill_super(struct super_block *sb, + /* fill in the superblock */ + sb->s_blocksize = PAGE_SIZE; + sb->s_blocksize_bits = PAGE_SHIFT; ++ sb->s_maxbytes = MAX_LFS_FILESIZE; + sb->s_magic = AFS_FS_MAGIC; + sb->s_op = &afs_super_ops; + sb->s_xattr = afs_xattr_handlers; +diff --git a/fs/afs/xattr.c b/fs/afs/xattr.c +index 2830e4f48d85..7c6b62a94e7e 100644 +--- a/fs/afs/xattr.c ++++ b/fs/afs/xattr.c +@@ -50,7 +50,7 @@ static int afs_xattr_get_cell(const struct xattr_handler *handler, + return namelen; + if (namelen > size) + return -ERANGE; +- memcpy(buffer, cell->name, size); ++ memcpy(buffer, cell->name, namelen); + return namelen; + } + +@@ -104,7 +104,7 @@ static int afs_xattr_get_volume(const struct xattr_handler *handler, + return namelen; + if (namelen > size) + return -ERANGE; +- memcpy(buffer, volname, size); ++ memcpy(buffer, volname, namelen); + return namelen; + } + +diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c +index 97be32da857a..c68ce3412dc1 100644 +--- a/fs/btrfs/file.c ++++ b/fs/btrfs/file.c +@@ -1882,7 +1882,7 @@ static ssize_t btrfs_file_write_iter(struct kiocb *iocb, + bool sync = (file->f_flags & O_DSYNC) || IS_SYNC(file->f_mapping->host); + ssize_t err; + loff_t pos; +- size_t count = iov_iter_count(from); ++ size_t count; + loff_t oldsize; + int clean_page = 0; + +@@ -1904,6 +1904,7 @@ static ssize_t btrfs_file_write_iter(struct kiocb *iocb, + } + + pos = iocb->ki_pos; ++ count = iov_iter_count(from); + if (iocb->ki_flags & IOCB_NOWAIT) { + /* + * We will allocate space in case nodatacow is not set, +diff --git a/fs/btrfs/inode-map.c b/fs/btrfs/inode-map.c +index d02019747d00..2ae32451fb5b 100644 +--- a/fs/btrfs/inode-map.c ++++ b/fs/btrfs/inode-map.c +@@ -26,6 +26,19 @@ + #include "inode-map.h" + #include "transaction.h" + ++static void fail_caching_thread(struct btrfs_root *root) ++{ ++ struct btrfs_fs_info *fs_info = root->fs_info; ++ ++ btrfs_warn(fs_info, "failed to start inode caching task"); ++ btrfs_clear_pending_and_info(fs_info, INODE_MAP_CACHE, ++ "disabling inode map caching"); ++ spin_lock(&root->ino_cache_lock); ++ root->ino_cache_state = BTRFS_CACHE_ERROR; ++ spin_unlock(&root->ino_cache_lock); ++ wake_up(&root->ino_cache_wait); ++} ++ + static int caching_kthread(void *data) + { + struct btrfs_root *root = data; +@@ -42,8 +55,10 @@ static int caching_kthread(void *data) + return 0; + + path = btrfs_alloc_path(); +- if (!path) ++ if (!path) { ++ fail_caching_thread(root); + return -ENOMEM; ++ } + + /* Since the commit root is read-only, we can safely skip locking. */ + path->skip_locking = 1; +@@ -159,6 +174,7 @@ static void start_caching(struct btrfs_root *root) + spin_lock(&root->ino_cache_lock); + root->ino_cache_state = BTRFS_CACHE_FINISHED; + spin_unlock(&root->ino_cache_lock); ++ wake_up(&root->ino_cache_wait); + return; + } + +@@ -177,11 +193,8 @@ static void start_caching(struct btrfs_root *root) + + tsk = kthread_run(caching_kthread, root, "btrfs-ino-cache-%llu", + root->root_key.objectid); +- if (IS_ERR(tsk)) { +- btrfs_warn(fs_info, "failed to start inode caching task"); +- btrfs_clear_pending_and_info(fs_info, INODE_MAP_CACHE, +- "disabling inode map caching"); +- } ++ if (IS_ERR(tsk)) ++ fail_caching_thread(root); + } + + int btrfs_find_free_ino(struct btrfs_root *root, u64 *objectid) +@@ -199,11 +212,14 @@ again: + + wait_event(root->ino_cache_wait, + root->ino_cache_state == BTRFS_CACHE_FINISHED || ++ root->ino_cache_state == BTRFS_CACHE_ERROR || + root->free_ino_ctl->free_space > 0); + + if (root->ino_cache_state == BTRFS_CACHE_FINISHED && + root->free_ino_ctl->free_space == 0) + return -ENOSPC; ++ else if (root->ino_cache_state == BTRFS_CACHE_ERROR) ++ return btrfs_find_free_objectid(root, objectid); + else + goto again; + } +diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c +index f523a9ca9574..f0b1279a7de6 100644 +--- a/fs/cifs/connect.c ++++ b/fs/cifs/connect.c +@@ -921,6 +921,7 @@ cifs_demultiplex_thread(void *p) + mempool_resize(cifs_req_poolp, length + cifs_min_rcv); + + set_freezable(); ++ allow_kernel_signal(SIGKILL); + while (server->tcpStatus != CifsExiting) { + if (try_to_freeze()) + continue; +@@ -2320,7 +2321,7 @@ cifs_put_tcp_session(struct TCP_Server_Info *server, int from_reconnect) + + task = xchg(&server->tsk, NULL); + if (task) +- force_sig(SIGKILL, task); ++ send_sig(SIGKILL, task, 1); + } + + static struct TCP_Server_Info * +diff --git a/fs/exportfs/expfs.c b/fs/exportfs/expfs.c +index a561ae17cf43..c08960040dd0 100644 +--- a/fs/exportfs/expfs.c ++++ b/fs/exportfs/expfs.c +@@ -147,6 +147,7 @@ static struct dentry *reconnect_one(struct vfsmount *mnt, + tmp = lookup_one_len_unlocked(nbuf, parent, strlen(nbuf)); + if (IS_ERR(tmp)) { + dprintk("%s: lookup failed: %d\n", __func__, PTR_ERR(tmp)); ++ err = PTR_ERR(tmp); + goto out_err; + } + if (tmp != dentry) { +diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c +index 137c752ab985..6064bcb8572b 100644 +--- a/fs/ext4/inline.c ++++ b/fs/ext4/inline.c +@@ -1425,7 +1425,7 @@ int htree_inlinedir_to_tree(struct file *dir_file, + err = ext4_htree_store_dirent(dir_file, hinfo->hash, + hinfo->minor_hash, de, &tmp_str); + if (err) { +- count = err; ++ ret = err; + goto out; + } + count++; +diff --git a/fs/jfs/jfs_txnmgr.c b/fs/jfs/jfs_txnmgr.c +index 4d973524c887..224ef034004b 100644 +--- a/fs/jfs/jfs_txnmgr.c ++++ b/fs/jfs/jfs_txnmgr.c +@@ -1928,8 +1928,7 @@ static void xtLog(struct jfs_log * log, struct tblock * tblk, struct lrd * lrd, + * header ? + */ + if (tlck->type & tlckTRUNCATE) { +- /* This odd declaration suppresses a bogus gcc warning */ +- pxd_t pxd = pxd; /* truncated extent of xad */ ++ pxd_t pxd; /* truncated extent of xad */ + int twm; + + /* +diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c +index 04d57e11577e..09b3bcb86d32 100644 +--- a/fs/nfs/delegation.c ++++ b/fs/nfs/delegation.c +@@ -234,6 +234,8 @@ static struct inode *nfs_delegation_grab_inode(struct nfs_delegation *delegation + spin_lock(&delegation->lock); + if (delegation->inode != NULL) + inode = igrab(delegation->inode); ++ if (!inode) ++ set_bit(NFS_DELEGATION_INODE_FREEING, &delegation->flags); + spin_unlock(&delegation->lock); + return inode; + } +@@ -863,10 +865,11 @@ restart: + list_for_each_entry_rcu(server, &clp->cl_superblocks, client_link) { + list_for_each_entry_rcu(delegation, &server->delegations, + super_list) { +- if (test_bit(NFS_DELEGATION_RETURNING, +- &delegation->flags)) +- continue; +- if (test_bit(NFS_DELEGATION_NEED_RECLAIM, ++ if (test_bit(NFS_DELEGATION_INODE_FREEING, ++ &delegation->flags) || ++ test_bit(NFS_DELEGATION_RETURNING, ++ &delegation->flags) || ++ test_bit(NFS_DELEGATION_NEED_RECLAIM, + &delegation->flags) == 0) + continue; + if (!nfs_sb_active(server->super)) +@@ -971,10 +974,11 @@ restart: + list_for_each_entry_rcu(server, &clp->cl_superblocks, client_link) { + list_for_each_entry_rcu(delegation, &server->delegations, + super_list) { +- if (test_bit(NFS_DELEGATION_RETURNING, +- &delegation->flags)) +- continue; +- if (test_bit(NFS_DELEGATION_TEST_EXPIRED, ++ if (test_bit(NFS_DELEGATION_INODE_FREEING, ++ &delegation->flags) || ++ test_bit(NFS_DELEGATION_RETURNING, ++ &delegation->flags) || ++ test_bit(NFS_DELEGATION_TEST_EXPIRED, + &delegation->flags) == 0) + continue; + if (!nfs_sb_active(server->super)) +diff --git a/fs/nfs/delegation.h b/fs/nfs/delegation.h +index df41d16dc6ab..510c9edcc712 100644 +--- a/fs/nfs/delegation.h ++++ b/fs/nfs/delegation.h +@@ -34,6 +34,7 @@ enum { + NFS_DELEGATION_RETURNING, + NFS_DELEGATION_REVOKED, + NFS_DELEGATION_TEST_EXPIRED, ++ NFS_DELEGATION_INODE_FREEING, + }; + + int nfs_inode_set_delegation(struct inode *inode, struct rpc_cred *cred, struct nfs_openres *res); +diff --git a/fs/nfs/flexfilelayout/flexfilelayout.h b/fs/nfs/flexfilelayout/flexfilelayout.h +index d6515f1584f3..d78ec99b6c4c 100644 +--- a/fs/nfs/flexfilelayout/flexfilelayout.h ++++ b/fs/nfs/flexfilelayout/flexfilelayout.h +@@ -131,16 +131,6 @@ FF_LAYOUT_LSEG(struct pnfs_layout_segment *lseg) + generic_hdr); + } + +-static inline struct nfs4_deviceid_node * +-FF_LAYOUT_DEVID_NODE(struct pnfs_layout_segment *lseg, u32 idx) +-{ +- if (idx >= FF_LAYOUT_LSEG(lseg)->mirror_array_cnt || +- FF_LAYOUT_LSEG(lseg)->mirror_array[idx] == NULL || +- FF_LAYOUT_LSEG(lseg)->mirror_array[idx]->mirror_ds == NULL) +- return NULL; +- return &FF_LAYOUT_LSEG(lseg)->mirror_array[idx]->mirror_ds->id_node; +-} +- + static inline struct nfs4_ff_layout_ds * + FF_LAYOUT_MIRROR_DS(struct nfs4_deviceid_node *node) + { +@@ -150,9 +140,25 @@ FF_LAYOUT_MIRROR_DS(struct nfs4_deviceid_node *node) + static inline struct nfs4_ff_layout_mirror * + FF_LAYOUT_COMP(struct pnfs_layout_segment *lseg, u32 idx) + { +- if (idx >= FF_LAYOUT_LSEG(lseg)->mirror_array_cnt) +- return NULL; +- return FF_LAYOUT_LSEG(lseg)->mirror_array[idx]; ++ struct nfs4_ff_layout_segment *fls = FF_LAYOUT_LSEG(lseg); ++ ++ if (idx < fls->mirror_array_cnt) ++ return fls->mirror_array[idx]; ++ return NULL; ++} ++ ++static inline struct nfs4_deviceid_node * ++FF_LAYOUT_DEVID_NODE(struct pnfs_layout_segment *lseg, u32 idx) ++{ ++ struct nfs4_ff_layout_mirror *mirror = FF_LAYOUT_COMP(lseg, idx); ++ ++ if (mirror != NULL) { ++ struct nfs4_ff_layout_ds *mirror_ds = mirror->mirror_ds; ++ ++ if (!IS_ERR_OR_NULL(mirror_ds)) ++ return &mirror_ds->id_node; ++ } ++ return NULL; + } + + static inline u32 +diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c +index ec04cce31814..83abf3dd7351 100644 +--- a/fs/nfs/pnfs.c ++++ b/fs/nfs/pnfs.c +@@ -725,22 +725,35 @@ static int + pnfs_layout_bulk_destroy_byserver_locked(struct nfs_client *clp, + struct nfs_server *server, + struct list_head *layout_list) ++ __must_hold(&clp->cl_lock) ++ __must_hold(RCU) + { + struct pnfs_layout_hdr *lo, *next; + struct inode *inode; + + list_for_each_entry_safe(lo, next, &server->layouts, plh_layouts) { +- if (test_bit(NFS_LAYOUT_INVALID_STID, &lo->plh_flags)) ++ if (test_bit(NFS_LAYOUT_INVALID_STID, &lo->plh_flags) || ++ test_bit(NFS_LAYOUT_INODE_FREEING, &lo->plh_flags) || ++ !list_empty(&lo->plh_bulk_destroy)) + continue; ++ /* If the sb is being destroyed, just bail */ ++ if (!nfs_sb_active(server->super)) ++ break; + inode = igrab(lo->plh_inode); +- if (inode == NULL) +- continue; +- list_del_init(&lo->plh_layouts); +- if (pnfs_layout_add_bulk_destroy_list(inode, layout_list)) +- continue; +- rcu_read_unlock(); +- spin_unlock(&clp->cl_lock); +- iput(inode); ++ if (inode != NULL) { ++ list_del_init(&lo->plh_layouts); ++ if (pnfs_layout_add_bulk_destroy_list(inode, ++ layout_list)) ++ continue; ++ rcu_read_unlock(); ++ spin_unlock(&clp->cl_lock); ++ iput(inode); ++ } else { ++ rcu_read_unlock(); ++ spin_unlock(&clp->cl_lock); ++ set_bit(NFS_LAYOUT_INODE_FREEING, &lo->plh_flags); ++ } ++ nfs_sb_deactive(server->super); + spin_lock(&clp->cl_lock); + rcu_read_lock(); + return -EAGAIN; +@@ -778,7 +791,7 @@ pnfs_layout_free_bulk_destroy_list(struct list_head *layout_list, + /* Free all lsegs that are attached to commit buckets */ + nfs_commit_inode(inode, 0); + pnfs_put_layout_hdr(lo); +- iput(inode); ++ nfs_iput_and_deactive(inode); + } + return ret; + } +diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h +index 87f144f14d1e..965d657086c8 100644 +--- a/fs/nfs/pnfs.h ++++ b/fs/nfs/pnfs.h +@@ -99,6 +99,7 @@ enum { + NFS_LAYOUT_RETURN_REQUESTED, /* Return this layout ASAP */ + NFS_LAYOUT_INVALID_STID, /* layout stateid id is invalid */ + NFS_LAYOUT_FIRST_LAYOUTGET, /* Serialize first layoutget */ ++ NFS_LAYOUT_INODE_FREEING, /* The inode is being freed */ + }; + + enum layoutdriver_policy_flags { +diff --git a/fs/nfs/super.c b/fs/nfs/super.c +index f464f8d9060c..470b761839a5 100644 +--- a/fs/nfs/super.c ++++ b/fs/nfs/super.c +@@ -1925,7 +1925,7 @@ static int nfs_parse_devname(const char *dev_name, + /* kill possible hostname list: not supported */ + comma = strchr(dev_name, ','); + if (comma != NULL && comma < end) +- *comma = 0; ++ len = comma - dev_name; + } + + if (len > maxnamlen) +diff --git a/fs/nfs/write.c b/fs/nfs/write.c +index 01b9d9341b54..ed3f5afc4ff7 100644 +--- a/fs/nfs/write.c ++++ b/fs/nfs/write.c +@@ -643,7 +643,7 @@ out: + return ret; + out_launder: + nfs_write_error_remove_page(req); +- return ret; ++ return 0; + } + + static int nfs_do_writepage(struct page *page, struct writeback_control *wbc, +diff --git a/fs/xfs/xfs_quotaops.c b/fs/xfs/xfs_quotaops.c +index a65108594a07..21bc6d2d23ca 100644 +--- a/fs/xfs/xfs_quotaops.c ++++ b/fs/xfs/xfs_quotaops.c +@@ -214,6 +214,9 @@ xfs_fs_rm_xquota( + if (XFS_IS_QUOTA_ON(mp)) + return -EINVAL; + ++ if (uflags & ~(FS_USER_QUOTA | FS_GROUP_QUOTA | FS_PROJ_QUOTA)) ++ return -EINVAL; ++ + if (uflags & FS_USER_QUOTA) + flags |= XFS_DQ_USER; + if (uflags & FS_GROUP_QUOTA) +diff --git a/include/linux/device.h b/include/linux/device.h +index 66fe271c2544..0b2e67014a83 100644 +--- a/include/linux/device.h ++++ b/include/linux/device.h +@@ -682,7 +682,8 @@ extern unsigned long devm_get_free_pages(struct device *dev, + gfp_t gfp_mask, unsigned int order); + extern void devm_free_pages(struct device *dev, unsigned long addr); + +-void __iomem *devm_ioremap_resource(struct device *dev, struct resource *res); ++void __iomem *devm_ioremap_resource(struct device *dev, ++ const struct resource *res); + + /* allows to add/remove a custom action to devres stack */ + int devm_add_action(struct device *dev, void (*action)(void *), void *data); +diff --git a/include/linux/irqchip/arm-gic-v3.h b/include/linux/irqchip/arm-gic-v3.h +index 845ff8c51564..0fe1fdedb8a1 100644 +--- a/include/linux/irqchip/arm-gic-v3.h ++++ b/include/linux/irqchip/arm-gic-v3.h +@@ -152,7 +152,7 @@ + #define GICR_PROPBASER_nCnB GIC_BASER_CACHEABILITY(GICR_PROPBASER, INNER, nCnB) + #define GICR_PROPBASER_nC GIC_BASER_CACHEABILITY(GICR_PROPBASER, INNER, nC) + #define GICR_PROPBASER_RaWt GIC_BASER_CACHEABILITY(GICR_PROPBASER, INNER, RaWt) +-#define GICR_PROPBASER_RaWb GIC_BASER_CACHEABILITY(GICR_PROPBASER, INNER, RaWt) ++#define GICR_PROPBASER_RaWb GIC_BASER_CACHEABILITY(GICR_PROPBASER, INNER, RaWb) + #define GICR_PROPBASER_WaWt GIC_BASER_CACHEABILITY(GICR_PROPBASER, INNER, WaWt) + #define GICR_PROPBASER_WaWb GIC_BASER_CACHEABILITY(GICR_PROPBASER, INNER, WaWb) + #define GICR_PROPBASER_RaWaWt GIC_BASER_CACHEABILITY(GICR_PROPBASER, INNER, RaWaWt) +@@ -179,7 +179,7 @@ + #define GICR_PENDBASER_nCnB GIC_BASER_CACHEABILITY(GICR_PENDBASER, INNER, nCnB) + #define GICR_PENDBASER_nC GIC_BASER_CACHEABILITY(GICR_PENDBASER, INNER, nC) + #define GICR_PENDBASER_RaWt GIC_BASER_CACHEABILITY(GICR_PENDBASER, INNER, RaWt) +-#define GICR_PENDBASER_RaWb GIC_BASER_CACHEABILITY(GICR_PENDBASER, INNER, RaWt) ++#define GICR_PENDBASER_RaWb GIC_BASER_CACHEABILITY(GICR_PENDBASER, INNER, RaWb) + #define GICR_PENDBASER_WaWt GIC_BASER_CACHEABILITY(GICR_PENDBASER, INNER, WaWt) + #define GICR_PENDBASER_WaWb GIC_BASER_CACHEABILITY(GICR_PENDBASER, INNER, WaWb) + #define GICR_PENDBASER_RaWaWt GIC_BASER_CACHEABILITY(GICR_PENDBASER, INNER, RaWaWt) +@@ -238,7 +238,7 @@ + #define GICR_VPROPBASER_nCnB GIC_BASER_CACHEABILITY(GICR_VPROPBASER, INNER, nCnB) + #define GICR_VPROPBASER_nC GIC_BASER_CACHEABILITY(GICR_VPROPBASER, INNER, nC) + #define GICR_VPROPBASER_RaWt GIC_BASER_CACHEABILITY(GICR_VPROPBASER, INNER, RaWt) +-#define GICR_VPROPBASER_RaWb GIC_BASER_CACHEABILITY(GICR_VPROPBASER, INNER, RaWt) ++#define GICR_VPROPBASER_RaWb GIC_BASER_CACHEABILITY(GICR_VPROPBASER, INNER, RaWb) + #define GICR_VPROPBASER_WaWt GIC_BASER_CACHEABILITY(GICR_VPROPBASER, INNER, WaWt) + #define GICR_VPROPBASER_WaWb GIC_BASER_CACHEABILITY(GICR_VPROPBASER, INNER, WaWb) + #define GICR_VPROPBASER_RaWaWt GIC_BASER_CACHEABILITY(GICR_VPROPBASER, INNER, RaWaWt) +@@ -264,7 +264,7 @@ + #define GICR_VPENDBASER_nCnB GIC_BASER_CACHEABILITY(GICR_VPENDBASER, INNER, nCnB) + #define GICR_VPENDBASER_nC GIC_BASER_CACHEABILITY(GICR_VPENDBASER, INNER, nC) + #define GICR_VPENDBASER_RaWt GIC_BASER_CACHEABILITY(GICR_VPENDBASER, INNER, RaWt) +-#define GICR_VPENDBASER_RaWb GIC_BASER_CACHEABILITY(GICR_VPENDBASER, INNER, RaWt) ++#define GICR_VPENDBASER_RaWb GIC_BASER_CACHEABILITY(GICR_VPENDBASER, INNER, RaWb) + #define GICR_VPENDBASER_WaWt GIC_BASER_CACHEABILITY(GICR_VPENDBASER, INNER, WaWt) + #define GICR_VPENDBASER_WaWb GIC_BASER_CACHEABILITY(GICR_VPENDBASER, INNER, WaWb) + #define GICR_VPENDBASER_RaWaWt GIC_BASER_CACHEABILITY(GICR_VPENDBASER, INNER, RaWaWt) +@@ -337,7 +337,7 @@ + #define GITS_CBASER_nCnB GIC_BASER_CACHEABILITY(GITS_CBASER, INNER, nCnB) + #define GITS_CBASER_nC GIC_BASER_CACHEABILITY(GITS_CBASER, INNER, nC) + #define GITS_CBASER_RaWt GIC_BASER_CACHEABILITY(GITS_CBASER, INNER, RaWt) +-#define GITS_CBASER_RaWb GIC_BASER_CACHEABILITY(GITS_CBASER, INNER, RaWt) ++#define GITS_CBASER_RaWb GIC_BASER_CACHEABILITY(GITS_CBASER, INNER, RaWb) + #define GITS_CBASER_WaWt GIC_BASER_CACHEABILITY(GITS_CBASER, INNER, WaWt) + #define GITS_CBASER_WaWb GIC_BASER_CACHEABILITY(GITS_CBASER, INNER, WaWb) + #define GITS_CBASER_RaWaWt GIC_BASER_CACHEABILITY(GITS_CBASER, INNER, RaWaWt) +@@ -361,7 +361,7 @@ + #define GITS_BASER_nCnB GIC_BASER_CACHEABILITY(GITS_BASER, INNER, nCnB) + #define GITS_BASER_nC GIC_BASER_CACHEABILITY(GITS_BASER, INNER, nC) + #define GITS_BASER_RaWt GIC_BASER_CACHEABILITY(GITS_BASER, INNER, RaWt) +-#define GITS_BASER_RaWb GIC_BASER_CACHEABILITY(GITS_BASER, INNER, RaWt) ++#define GITS_BASER_RaWb GIC_BASER_CACHEABILITY(GITS_BASER, INNER, RaWb) + #define GITS_BASER_WaWt GIC_BASER_CACHEABILITY(GITS_BASER, INNER, WaWt) + #define GITS_BASER_WaWb GIC_BASER_CACHEABILITY(GITS_BASER, INNER, WaWb) + #define GITS_BASER_RaWaWt GIC_BASER_CACHEABILITY(GITS_BASER, INNER, RaWaWt) +diff --git a/include/linux/mlx5/mlx5_ifc.h b/include/linux/mlx5/mlx5_ifc.h +index 1d793d86d55f..6ffa181598e6 100644 +--- a/include/linux/mlx5/mlx5_ifc.h ++++ b/include/linux/mlx5/mlx5_ifc.h +@@ -8671,8 +8671,6 @@ struct mlx5_ifc_query_lag_out_bits { + + u8 syndrome[0x20]; + +- u8 reserved_at_40[0x40]; +- + struct mlx5_ifc_lagc_bits ctx; + }; + +diff --git a/include/linux/mmc/sdio_ids.h b/include/linux/mmc/sdio_ids.h +index 0a7abe8a407f..68bbbd9edc08 100644 +--- a/include/linux/mmc/sdio_ids.h ++++ b/include/linux/mmc/sdio_ids.h +@@ -67,6 +67,8 @@ + + #define SDIO_VENDOR_ID_TI 0x0097 + #define SDIO_DEVICE_ID_TI_WL1271 0x4076 ++#define SDIO_VENDOR_ID_TI_WL1251 0x104c ++#define SDIO_DEVICE_ID_TI_WL1251 0x9066 + + #define SDIO_VENDOR_ID_STE 0x0020 + #define SDIO_DEVICE_ID_STE_CW1200 0x2280 +diff --git a/include/linux/platform_data/dma-imx-sdma.h b/include/linux/platform_data/dma-imx-sdma.h +index 6eaa53cef0bd..30e676b36b24 100644 +--- a/include/linux/platform_data/dma-imx-sdma.h ++++ b/include/linux/platform_data/dma-imx-sdma.h +@@ -51,7 +51,10 @@ struct sdma_script_start_addrs { + /* End of v2 array */ + s32 zcanfd_2_mcu_addr; + s32 zqspi_2_mcu_addr; ++ s32 mcu_2_ecspi_addr; + /* End of v3 array */ ++ s32 mcu_2_zqspi_addr; ++ /* End of v4 array */ + }; + + /** +diff --git a/include/linux/signal.h b/include/linux/signal.h +index 843bd62b1ead..c4e3eb89a622 100644 +--- a/include/linux/signal.h ++++ b/include/linux/signal.h +@@ -268,6 +268,9 @@ extern void signal_setup_done(int failed, struct ksignal *ksig, int stepping); + extern void exit_signals(struct task_struct *tsk); + extern void kernel_sigaction(int, __sighandler_t); + ++#define SIG_KTHREAD ((__force __sighandler_t)2) ++#define SIG_KTHREAD_KERNEL ((__force __sighandler_t)3) ++ + static inline void allow_signal(int sig) + { + /* +@@ -275,7 +278,17 @@ static inline void allow_signal(int sig) + * know it'll be handled, so that they don't get converted to + * SIGKILL or just silently dropped. + */ +- kernel_sigaction(sig, (__force __sighandler_t)2); ++ kernel_sigaction(sig, SIG_KTHREAD); ++} ++ ++static inline void allow_kernel_signal(int sig) ++{ ++ /* ++ * Kernel threads handle their own signals. Let the signal code ++ * know signals sent by the kernel will be handled, so that they ++ * don't get silently dropped. ++ */ ++ kernel_sigaction(sig, SIG_KTHREAD_KERNEL); + } + + static inline void disallow_signal(int sig) +diff --git a/include/media/davinci/vpbe.h b/include/media/davinci/vpbe.h +index 79a566d7defd..180a05e91497 100644 +--- a/include/media/davinci/vpbe.h ++++ b/include/media/davinci/vpbe.h +@@ -92,7 +92,7 @@ struct vpbe_config { + struct encoder_config_info *ext_encoders; + /* amplifier information goes here */ + struct amp_config_info *amp; +- int num_outputs; ++ unsigned int num_outputs; + /* Order is venc outputs followed by LCD and then external encoders */ + struct vpbe_output *outputs; + }; +diff --git a/include/net/request_sock.h b/include/net/request_sock.h +index 23e22054aa60..04aa2c7d35c4 100644 +--- a/include/net/request_sock.h ++++ b/include/net/request_sock.h +@@ -181,7 +181,7 @@ void reqsk_fastopen_remove(struct sock *sk, struct request_sock *req, + + static inline bool reqsk_queue_empty(const struct request_sock_queue *queue) + { +- return queue->rskq_accept_head == NULL; ++ return READ_ONCE(queue->rskq_accept_head) == NULL; + } + + static inline struct request_sock *reqsk_queue_remove(struct request_sock_queue *queue, +@@ -193,7 +193,7 @@ static inline struct request_sock *reqsk_queue_remove(struct request_sock_queue + req = queue->rskq_accept_head; + if (req) { + sk_acceptq_removed(parent); +- queue->rskq_accept_head = req->dl_next; ++ WRITE_ONCE(queue->rskq_accept_head, req->dl_next); + if (queue->rskq_accept_head == NULL) + queue->rskq_accept_tail = NULL; + } +diff --git a/include/net/tcp.h b/include/net/tcp.h +index 00d10f0e1194..c96302310314 100644 +--- a/include/net/tcp.h ++++ b/include/net/tcp.h +@@ -289,7 +289,7 @@ static inline bool tcp_under_memory_pressure(const struct sock *sk) + mem_cgroup_under_socket_pressure(sk->sk_memcg)) + return true; + +- return tcp_memory_pressure; ++ return READ_ONCE(tcp_memory_pressure); + } + /* + * The next routines deal with comparing 32 bit unsigned ints +diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c +index 993db6b2348e..15d902daeef6 100644 +--- a/kernel/debug/kdb/kdb_main.c ++++ b/kernel/debug/kdb/kdb_main.c +@@ -2634,7 +2634,7 @@ static int kdb_per_cpu(int argc, const char **argv) + diag = kdbgetularg(argv[3], &whichcpu); + if (diag) + return diag; +- if (!cpu_online(whichcpu)) { ++ if (whichcpu >= nr_cpu_ids || !cpu_online(whichcpu)) { + kdb_printf("cpu %ld is not online\n", whichcpu); + return KDB_BADCPUNUM; + } +diff --git a/kernel/events/core.c b/kernel/events/core.c +index ea4f3f7a0c6f..2ac73b4cb8a9 100644 +--- a/kernel/events/core.c ++++ b/kernel/events/core.c +@@ -4762,6 +4762,9 @@ static int perf_event_period(struct perf_event *event, u64 __user *arg) + if (perf_event_check_period(event, value)) + return -EINVAL; + ++ if (!event->attr.freq && (value & (1ULL << 63))) ++ return -EINVAL; ++ + event_function_call(event, __perf_event_period, &value); + + return 0; +diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c +index ac4644e92b49..0f0e7975a309 100644 +--- a/kernel/irq/irqdomain.c ++++ b/kernel/irq/irqdomain.c +@@ -147,6 +147,7 @@ struct irq_domain *__irq_domain_add(struct fwnode_handle *fwnode, int size, + switch (fwid->type) { + case IRQCHIP_FWNODE_NAMED: + case IRQCHIP_FWNODE_NAMED_ID: ++ domain->fwnode = fwnode; + domain->name = kstrdup(fwid->name, GFP_KERNEL); + if (!domain->name) { + kfree(domain); +diff --git a/kernel/signal.c b/kernel/signal.c +index c9b203875001..8fee1f2eba2f 100644 +--- a/kernel/signal.c ++++ b/kernel/signal.c +@@ -85,6 +85,11 @@ static int sig_task_ignored(struct task_struct *t, int sig, bool force) + handler == SIG_DFL && !(force && sig_kernel_only(sig))) + return 1; + ++ /* Only allow kernel generated signals to this kthread */ ++ if (unlikely((t->flags & PF_KTHREAD) && ++ (handler == SIG_KTHREAD_KERNEL) && !force)) ++ return true; ++ + return sig_handler_ignored(handler, sig); + } + +diff --git a/lib/devres.c b/lib/devres.c +index 5f2aedd58bc5..40a8b12a8b6b 100644 +--- a/lib/devres.c ++++ b/lib/devres.c +@@ -132,7 +132,8 @@ EXPORT_SYMBOL(devm_iounmap); + * if (IS_ERR(base)) + * return PTR_ERR(base); + */ +-void __iomem *devm_ioremap_resource(struct device *dev, struct resource *res) ++void __iomem *devm_ioremap_resource(struct device *dev, ++ const struct resource *res) + { + resource_size_t size; + const char *name; +diff --git a/lib/kfifo.c b/lib/kfifo.c +index 90ba1eb1df06..a94227c55551 100644 +--- a/lib/kfifo.c ++++ b/lib/kfifo.c +@@ -82,7 +82,8 @@ int __kfifo_init(struct __kfifo *fifo, void *buffer, + { + size /= esize; + +- size = roundup_pow_of_two(size); ++ if (!is_power_of_2(size)) ++ size = rounddown_pow_of_two(size); + + fifo->in = 0; + fifo->out = 0; +diff --git a/net/6lowpan/nhc.c b/net/6lowpan/nhc.c +index 4fa2fdda174d..9e56fb98f33c 100644 +--- a/net/6lowpan/nhc.c ++++ b/net/6lowpan/nhc.c +@@ -18,7 +18,7 @@ + #include "nhc.h" + + static struct rb_root rb_root = RB_ROOT; +-static struct lowpan_nhc *lowpan_nexthdr_nhcs[NEXTHDR_MAX]; ++static struct lowpan_nhc *lowpan_nexthdr_nhcs[NEXTHDR_MAX + 1]; + static DEFINE_SPINLOCK(lowpan_nhc_lock); + + static int lowpan_nhc_insert(struct lowpan_nhc *nhc) +diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c +index 35a670ec9077..a1834ad7422c 100644 +--- a/net/bridge/netfilter/ebtables.c ++++ b/net/bridge/netfilter/ebtables.c +@@ -2164,7 +2164,9 @@ static int compat_copy_entries(unsigned char *data, unsigned int size_user, + if (ret < 0) + return ret; + +- WARN_ON(size_remaining); ++ if (size_remaining) ++ return -EINVAL; ++ + return state->buf_kern_offset; + } + +diff --git a/net/core/neighbour.c b/net/core/neighbour.c +index 16ac50b1b9a7..567e431813e5 100644 +--- a/net/core/neighbour.c ++++ b/net/core/neighbour.c +@@ -1877,8 +1877,8 @@ static int neightbl_fill_info(struct sk_buff *skb, struct neigh_table *tbl, + goto nla_put_failure; + { + unsigned long now = jiffies; +- unsigned int flush_delta = now - tbl->last_flush; +- unsigned int rand_delta = now - tbl->last_rand; ++ long flush_delta = now - tbl->last_flush; ++ long rand_delta = now - tbl->last_rand; + struct neigh_hash_table *nht; + struct ndt_config ndc = { + .ndtc_key_len = tbl->key_len, +diff --git a/net/core/sock.c b/net/core/sock.c +index 90ccbbf9e6b0..03ca2f638eb4 100644 +--- a/net/core/sock.c ++++ b/net/core/sock.c +@@ -2165,8 +2165,8 @@ static void sk_leave_memory_pressure(struct sock *sk) + } else { + unsigned long *memory_pressure = sk->sk_prot->memory_pressure; + +- if (memory_pressure && *memory_pressure) +- *memory_pressure = 0; ++ if (memory_pressure && READ_ONCE(*memory_pressure)) ++ WRITE_ONCE(*memory_pressure, 0); + } + } + +diff --git a/net/ieee802154/6lowpan/reassembly.c b/net/ieee802154/6lowpan/reassembly.c +index ec7a5da56129..e873a6a007f2 100644 +--- a/net/ieee802154/6lowpan/reassembly.c ++++ b/net/ieee802154/6lowpan/reassembly.c +@@ -634,7 +634,7 @@ err_sysctl: + + void lowpan_net_frag_exit(void) + { +- inet_frags_fini(&lowpan_frags); + lowpan_frags_sysctl_unregister(); + unregister_pernet_subsys(&lowpan_frags_ops); ++ inet_frags_fini(&lowpan_frags); + } +diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c +index f7224c4fc30f..da55ce62fe50 100644 +--- a/net/ipv4/inet_connection_sock.c ++++ b/net/ipv4/inet_connection_sock.c +@@ -936,7 +936,7 @@ struct sock *inet_csk_reqsk_queue_add(struct sock *sk, + req->sk = child; + req->dl_next = NULL; + if (queue->rskq_accept_head == NULL) +- queue->rskq_accept_head = req; ++ WRITE_ONCE(queue->rskq_accept_head, req); + else + queue->rskq_accept_tail->dl_next = req; + queue->rskq_accept_tail = req; +diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c +index 8f07655718f3..db1eceda2359 100644 +--- a/net/ipv4/tcp.c ++++ b/net/ipv4/tcp.c +@@ -328,7 +328,7 @@ void tcp_enter_memory_pressure(struct sock *sk) + { + unsigned long val; + +- if (tcp_memory_pressure) ++ if (READ_ONCE(tcp_memory_pressure)) + return; + val = jiffies; + +@@ -343,7 +343,7 @@ void tcp_leave_memory_pressure(struct sock *sk) + { + unsigned long val; + +- if (!tcp_memory_pressure) ++ if (!READ_ONCE(tcp_memory_pressure)) + return; + val = xchg(&tcp_memory_pressure, 0); + if (val) +diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c +index fe797b29ca89..6dea6e92e686 100644 +--- a/net/ipv6/reassembly.c ++++ b/net/ipv6/reassembly.c +@@ -593,8 +593,8 @@ err_protocol: + + void ipv6_frag_exit(void) + { +- inet_frags_fini(&ip6_frags); + ip6_frags_sysctl_unregister(); + unregister_pernet_subsys(&ip6_frags_ops); + inet6_del_protocol(&frag_protocol, IPPROTO_FRAGMENT); ++ inet_frags_fini(&ip6_frags); + } +diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c +index ca98276c2709..7a9cbc9502d9 100644 +--- a/net/iucv/af_iucv.c ++++ b/net/iucv/af_iucv.c +@@ -2446,6 +2446,13 @@ out: + return err; + } + ++static void afiucv_iucv_exit(void) ++{ ++ device_unregister(af_iucv_dev); ++ driver_unregister(&af_iucv_driver); ++ pr_iucv->iucv_unregister(&af_iucv_handler, 0); ++} ++ + static int __init afiucv_init(void) + { + int err; +@@ -2479,11 +2486,18 @@ static int __init afiucv_init(void) + err = afiucv_iucv_init(); + if (err) + goto out_sock; +- } else +- register_netdevice_notifier(&afiucv_netdev_notifier); ++ } ++ ++ err = register_netdevice_notifier(&afiucv_netdev_notifier); ++ if (err) ++ goto out_notifier; ++ + dev_add_pack(&iucv_packet_type); + return 0; + ++out_notifier: ++ if (pr_iucv) ++ afiucv_iucv_exit(); + out_sock: + sock_unregister(PF_IUCV); + out_proto: +@@ -2497,12 +2511,11 @@ out: + static void __exit afiucv_exit(void) + { + if (pr_iucv) { +- device_unregister(af_iucv_dev); +- driver_unregister(&af_iucv_driver); +- pr_iucv->iucv_unregister(&af_iucv_handler, 0); ++ afiucv_iucv_exit(); + symbol_put(iucv_if); +- } else +- unregister_netdevice_notifier(&afiucv_netdev_notifier); ++ } ++ ++ unregister_netdevice_notifier(&afiucv_netdev_notifier); + dev_remove_pack(&iucv_packet_type); + sock_unregister(PF_IUCV); + proto_unregister(&iucv_proto); +diff --git a/net/l2tp/l2tp_core.c b/net/l2tp/l2tp_core.c +index e494f04819e9..b9be0360ab94 100644 +--- a/net/l2tp/l2tp_core.c ++++ b/net/l2tp/l2tp_core.c +@@ -1892,7 +1892,8 @@ static __net_exit void l2tp_exit_net(struct net *net) + } + rcu_read_unlock_bh(); + +- flush_workqueue(l2tp_wq); ++ if (l2tp_wq) ++ flush_workqueue(l2tp_wq); + rcu_barrier(); + } + +diff --git a/net/llc/af_llc.c b/net/llc/af_llc.c +index 2e472d5c3ea4..d552e8819713 100644 +--- a/net/llc/af_llc.c ++++ b/net/llc/af_llc.c +@@ -113,22 +113,26 @@ static inline u8 llc_ui_header_len(struct sock *sk, struct sockaddr_llc *addr) + * + * Send data via reliable llc2 connection. + * Returns 0 upon success, non-zero if action did not succeed. ++ * ++ * This function always consumes a reference to the skb. + */ + static int llc_ui_send_data(struct sock* sk, struct sk_buff *skb, int noblock) + { + struct llc_sock* llc = llc_sk(sk); +- int rc = 0; + + if (unlikely(llc_data_accept_state(llc->state) || + llc->remote_busy_flag || + llc->p_flag)) { + long timeout = sock_sndtimeo(sk, noblock); ++ int rc; + + rc = llc_ui_wait_for_busy_core(sk, timeout); ++ if (rc) { ++ kfree_skb(skb); ++ return rc; ++ } + } +- if (unlikely(!rc)) +- rc = llc_build_and_send_pkt(sk, skb); +- return rc; ++ return llc_build_and_send_pkt(sk, skb); + } + + static void llc_ui_sk_init(struct socket *sock, struct sock *sk) +@@ -900,7 +904,7 @@ static int llc_ui_sendmsg(struct socket *sock, struct msghdr *msg, size_t len) + DECLARE_SOCKADDR(struct sockaddr_llc *, addr, msg->msg_name); + int flags = msg->msg_flags; + int noblock = flags & MSG_DONTWAIT; +- struct sk_buff *skb; ++ struct sk_buff *skb = NULL; + size_t size = 0; + int rc = -EINVAL, copied = 0, hdrlen; + +@@ -909,10 +913,10 @@ static int llc_ui_sendmsg(struct socket *sock, struct msghdr *msg, size_t len) + lock_sock(sk); + if (addr) { + if (msg->msg_namelen < sizeof(*addr)) +- goto release; ++ goto out; + } else { + if (llc_ui_addr_null(&llc->addr)) +- goto release; ++ goto out; + addr = &llc->addr; + } + /* must bind connection to sap if user hasn't done it. */ +@@ -920,7 +924,7 @@ static int llc_ui_sendmsg(struct socket *sock, struct msghdr *msg, size_t len) + /* bind to sap with null dev, exclusive. */ + rc = llc_ui_autobind(sock, addr); + if (rc) +- goto release; ++ goto out; + } + hdrlen = llc->dev->hard_header_len + llc_ui_header_len(sk, addr); + size = hdrlen + len; +@@ -929,12 +933,12 @@ static int llc_ui_sendmsg(struct socket *sock, struct msghdr *msg, size_t len) + copied = size - hdrlen; + rc = -EINVAL; + if (copied < 0) +- goto release; ++ goto out; + release_sock(sk); + skb = sock_alloc_send_skb(sk, size, noblock, &rc); + lock_sock(sk); + if (!skb) +- goto release; ++ goto out; + skb->dev = llc->dev; + skb->protocol = llc_proto_type(addr->sllc_arphrd); + skb_reserve(skb, hdrlen); +@@ -944,29 +948,31 @@ static int llc_ui_sendmsg(struct socket *sock, struct msghdr *msg, size_t len) + if (sk->sk_type == SOCK_DGRAM || addr->sllc_ua) { + llc_build_and_send_ui_pkt(llc->sap, skb, addr->sllc_mac, + addr->sllc_sap); ++ skb = NULL; + goto out; + } + if (addr->sllc_test) { + llc_build_and_send_test_pkt(llc->sap, skb, addr->sllc_mac, + addr->sllc_sap); ++ skb = NULL; + goto out; + } + if (addr->sllc_xid) { + llc_build_and_send_xid_pkt(llc->sap, skb, addr->sllc_mac, + addr->sllc_sap); ++ skb = NULL; + goto out; + } + rc = -ENOPROTOOPT; + if (!(sk->sk_type == SOCK_STREAM && !addr->sllc_ua)) + goto out; + rc = llc_ui_send_data(sk, skb, noblock); ++ skb = NULL; + out: +- if (rc) { +- kfree_skb(skb); +-release: ++ kfree_skb(skb); ++ if (rc) + dprintk("%s: failed sending from %02X to %02X: %d\n", + __func__, llc->laddr.lsap, llc->daddr.lsap, rc); +- } + release_sock(sk); + return rc ? : copied; + } +diff --git a/net/llc/llc_conn.c b/net/llc/llc_conn.c +index 444c13e752a0..7fbc682aff04 100644 +--- a/net/llc/llc_conn.c ++++ b/net/llc/llc_conn.c +@@ -55,6 +55,8 @@ int sysctl_llc2_busy_timeout = LLC2_BUSY_TIME * HZ; + * (executing it's actions and changing state), upper layer will be + * indicated or confirmed, if needed. Returns 0 for success, 1 for + * failure. The socket lock has to be held before calling this function. ++ * ++ * This function always consumes a reference to the skb. + */ + int llc_conn_state_process(struct sock *sk, struct sk_buff *skb) + { +@@ -62,12 +64,6 @@ int llc_conn_state_process(struct sock *sk, struct sk_buff *skb) + struct llc_sock *llc = llc_sk(skb->sk); + struct llc_conn_state_ev *ev = llc_conn_ev(skb); + +- /* +- * We have to hold the skb, because llc_conn_service will kfree it in +- * the sending path and we need to look at the skb->cb, where we encode +- * llc_conn_state_ev. +- */ +- skb_get(skb); + ev->ind_prim = ev->cfm_prim = 0; + /* + * Send event to state machine +@@ -75,21 +71,12 @@ int llc_conn_state_process(struct sock *sk, struct sk_buff *skb) + rc = llc_conn_service(skb->sk, skb); + if (unlikely(rc != 0)) { + printk(KERN_ERR "%s: llc_conn_service failed\n", __func__); +- goto out_kfree_skb; +- } +- +- if (unlikely(!ev->ind_prim && !ev->cfm_prim)) { +- /* indicate or confirm not required */ +- if (!skb->next) +- goto out_kfree_skb; + goto out_skb_put; + } + +- if (unlikely(ev->ind_prim && ev->cfm_prim)) /* Paranoia */ +- skb_get(skb); +- + switch (ev->ind_prim) { + case LLC_DATA_PRIM: ++ skb_get(skb); + llc_save_primitive(sk, skb, LLC_DATA_PRIM); + if (unlikely(sock_queue_rcv_skb(sk, skb))) { + /* +@@ -106,6 +93,7 @@ int llc_conn_state_process(struct sock *sk, struct sk_buff *skb) + * skb->sk pointing to the newly created struct sock in + * llc_conn_handler. -acme + */ ++ skb_get(skb); + skb_queue_tail(&sk->sk_receive_queue, skb); + sk->sk_state_change(sk); + break; +@@ -121,7 +109,6 @@ int llc_conn_state_process(struct sock *sk, struct sk_buff *skb) + sk->sk_state_change(sk); + } + } +- kfree_skb(skb); + sock_put(sk); + break; + case LLC_RESET_PRIM: +@@ -130,14 +117,11 @@ int llc_conn_state_process(struct sock *sk, struct sk_buff *skb) + * RESET is not being notified to upper layers for now + */ + printk(KERN_INFO "%s: received a reset ind!\n", __func__); +- kfree_skb(skb); + break; + default: +- if (ev->ind_prim) { ++ if (ev->ind_prim) + printk(KERN_INFO "%s: received unknown %d prim!\n", + __func__, ev->ind_prim); +- kfree_skb(skb); +- } + /* No indication */ + break; + } +@@ -179,15 +163,12 @@ int llc_conn_state_process(struct sock *sk, struct sk_buff *skb) + printk(KERN_INFO "%s: received a reset conf!\n", __func__); + break; + default: +- if (ev->cfm_prim) { ++ if (ev->cfm_prim) + printk(KERN_INFO "%s: received unknown %d prim!\n", + __func__, ev->cfm_prim); +- break; +- } +- goto out_skb_put; /* No confirmation */ ++ /* No confirmation */ ++ break; + } +-out_kfree_skb: +- kfree_skb(skb); + out_skb_put: + kfree_skb(skb); + return rc; +diff --git a/net/llc/llc_if.c b/net/llc/llc_if.c +index 6daf391b3e84..fc4d2bd8816f 100644 +--- a/net/llc/llc_if.c ++++ b/net/llc/llc_if.c +@@ -38,6 +38,8 @@ + * closed and -EBUSY when sending data is not permitted in this state or + * LLC has send an I pdu with p bit set to 1 and is waiting for it's + * response. ++ * ++ * This function always consumes a reference to the skb. + */ + int llc_build_and_send_pkt(struct sock *sk, struct sk_buff *skb) + { +@@ -46,20 +48,22 @@ int llc_build_and_send_pkt(struct sock *sk, struct sk_buff *skb) + struct llc_sock *llc = llc_sk(sk); + + if (unlikely(llc->state == LLC_CONN_STATE_ADM)) +- goto out; ++ goto out_free; + rc = -EBUSY; + if (unlikely(llc_data_accept_state(llc->state) || /* data_conn_refuse */ + llc->p_flag)) { + llc->failed_data_req = 1; +- goto out; ++ goto out_free; + } + ev = llc_conn_ev(skb); + ev->type = LLC_CONN_EV_TYPE_PRIM; + ev->prim = LLC_DATA_PRIM; + ev->prim_type = LLC_PRIM_TYPE_REQ; + skb->dev = llc->dev; +- rc = llc_conn_state_process(sk, skb); +-out: ++ return llc_conn_state_process(sk, skb); ++ ++out_free: ++ kfree_skb(skb); + return rc; + } + +diff --git a/net/mac80211/rc80211_minstrel_ht.c b/net/mac80211/rc80211_minstrel_ht.c +index e57811e4b91f..7ba4272642c9 100644 +--- a/net/mac80211/rc80211_minstrel_ht.c ++++ b/net/mac80211/rc80211_minstrel_ht.c +@@ -529,7 +529,7 @@ minstrel_ht_update_stats(struct minstrel_priv *mp, struct minstrel_ht_sta *mi) + + /* (re)Initialize group rate indexes */ + for(j = 0; j < MAX_THR_RATES; j++) +- tmp_group_tp_rate[j] = group; ++ tmp_group_tp_rate[j] = MCS_GROUP_RATES * group; + + for (i = 0; i < MCS_GROUP_RATES; i++) { + if (!(mi->supported[group] & BIT(i))) +diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c +index 4a6b3c7b35e3..31000622376d 100644 +--- a/net/mac80211/rx.c ++++ b/net/mac80211/rx.c +@@ -3227,9 +3227,18 @@ ieee80211_rx_h_mgmt(struct ieee80211_rx_data *rx) + case cpu_to_le16(IEEE80211_STYPE_PROBE_RESP): + /* process for all: mesh, mlme, ibss */ + break; ++ case cpu_to_le16(IEEE80211_STYPE_DEAUTH): ++ if (is_multicast_ether_addr(mgmt->da) && ++ !is_broadcast_ether_addr(mgmt->da)) ++ return RX_DROP_MONITOR; ++ ++ /* process only for station/IBSS */ ++ if (sdata->vif.type != NL80211_IFTYPE_STATION && ++ sdata->vif.type != NL80211_IFTYPE_ADHOC) ++ return RX_DROP_MONITOR; ++ break; + case cpu_to_le16(IEEE80211_STYPE_ASSOC_RESP): + case cpu_to_le16(IEEE80211_STYPE_REASSOC_RESP): +- case cpu_to_le16(IEEE80211_STYPE_DEAUTH): + case cpu_to_le16(IEEE80211_STYPE_DISASSOC): + if (is_multicast_ether_addr(mgmt->da) && + !is_broadcast_ether_addr(mgmt->da)) +diff --git a/net/mpls/mpls_iptunnel.c b/net/mpls/mpls_iptunnel.c +index 6e558a419f60..6c01166f972b 100644 +--- a/net/mpls/mpls_iptunnel.c ++++ b/net/mpls/mpls_iptunnel.c +@@ -28,7 +28,7 @@ + #include "internal.h" + + static const struct nla_policy mpls_iptunnel_policy[MPLS_IPTUNNEL_MAX + 1] = { +- [MPLS_IPTUNNEL_DST] = { .type = NLA_U32 }, ++ [MPLS_IPTUNNEL_DST] = { .len = sizeof(u32) }, + [MPLS_IPTUNNEL_TTL] = { .type = NLA_U8 }, + }; + +diff --git a/net/netfilter/nft_set_hash.c b/net/netfilter/nft_set_hash.c +index 33aa2ac3a62e..73f8f99b1193 100644 +--- a/net/netfilter/nft_set_hash.c ++++ b/net/netfilter/nft_set_hash.c +@@ -442,6 +442,23 @@ static bool nft_hash_lookup_fast(const struct net *net, + return false; + } + ++static u32 nft_jhash(const struct nft_set *set, const struct nft_hash *priv, ++ const struct nft_set_ext *ext) ++{ ++ const struct nft_data *key = nft_set_ext_key(ext); ++ u32 hash, k1; ++ ++ if (set->klen == 4) { ++ k1 = *(u32 *)key; ++ hash = jhash_1word(k1, priv->seed); ++ } else { ++ hash = jhash(key, set->klen, priv->seed); ++ } ++ hash = reciprocal_scale(hash, priv->buckets); ++ ++ return hash; ++} ++ + static int nft_hash_insert(const struct net *net, const struct nft_set *set, + const struct nft_set_elem *elem, + struct nft_set_ext **ext) +@@ -451,8 +468,7 @@ static int nft_hash_insert(const struct net *net, const struct nft_set *set, + u8 genmask = nft_genmask_next(net); + u32 hash; + +- hash = jhash(nft_set_ext_key(&this->ext), set->klen, priv->seed); +- hash = reciprocal_scale(hash, priv->buckets); ++ hash = nft_jhash(set, priv, &this->ext); + hlist_for_each_entry(he, &priv->table[hash], node) { + if (!memcmp(nft_set_ext_key(&this->ext), + nft_set_ext_key(&he->ext), set->klen) && +@@ -491,8 +507,7 @@ static void *nft_hash_deactivate(const struct net *net, + u8 genmask = nft_genmask_next(net); + u32 hash; + +- hash = jhash(nft_set_ext_key(&this->ext), set->klen, priv->seed); +- hash = reciprocal_scale(hash, priv->buckets); ++ hash = nft_jhash(set, priv, &this->ext); + hlist_for_each_entry(he, &priv->table[hash], node) { + if (!memcmp(nft_set_ext_key(&this->ext), &elem->key.val, + set->klen) || +diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c +index 4e1058159b08..46b7fac82775 100644 +--- a/net/packet/af_packet.c ++++ b/net/packet/af_packet.c +@@ -1337,15 +1337,21 @@ static void packet_sock_destruct(struct sock *sk) + + static bool fanout_flow_is_huge(struct packet_sock *po, struct sk_buff *skb) + { +- u32 rxhash; ++ u32 *history = po->rollover->history; ++ u32 victim, rxhash; + int i, count = 0; + + rxhash = skb_get_hash(skb); + for (i = 0; i < ROLLOVER_HLEN; i++) +- if (po->rollover->history[i] == rxhash) ++ if (READ_ONCE(history[i]) == rxhash) + count++; + +- po->rollover->history[prandom_u32() % ROLLOVER_HLEN] = rxhash; ++ victim = prandom_u32() % ROLLOVER_HLEN; ++ ++ /* Avoid dirtying the cache line if possible */ ++ if (READ_ONCE(history[victim]) != rxhash) ++ WRITE_ONCE(history[victim], rxhash); ++ + return count > (ROLLOVER_HLEN >> 1); + } + +@@ -3407,20 +3413,29 @@ static int packet_recvmsg(struct socket *sock, struct msghdr *msg, size_t len, + sock_recv_ts_and_drops(msg, sk, skb); + + if (msg->msg_name) { ++ int copy_len; ++ + /* If the address length field is there to be filled + * in, we fill it in now. + */ + if (sock->type == SOCK_PACKET) { + __sockaddr_check_size(sizeof(struct sockaddr_pkt)); + msg->msg_namelen = sizeof(struct sockaddr_pkt); ++ copy_len = msg->msg_namelen; + } else { + struct sockaddr_ll *sll = &PACKET_SKB_CB(skb)->sa.ll; + + msg->msg_namelen = sll->sll_halen + + offsetof(struct sockaddr_ll, sll_addr); ++ copy_len = msg->msg_namelen; ++ if (msg->msg_namelen < sizeof(struct sockaddr_ll)) { ++ memset(msg->msg_name + ++ offsetof(struct sockaddr_ll, sll_addr), ++ 0, sizeof(sll->sll_addr)); ++ msg->msg_namelen = sizeof(struct sockaddr_ll); ++ } + } +- memcpy(msg->msg_name, &PACKET_SKB_CB(skb)->sa, +- msg->msg_namelen); ++ memcpy(msg->msg_name, &PACKET_SKB_CB(skb)->sa, copy_len); + } + + if (pkt_sk(sk)->auxdata) { +diff --git a/net/rds/ib_stats.c b/net/rds/ib_stats.c +index 9252ad126335..ac46d8961b61 100644 +--- a/net/rds/ib_stats.c ++++ b/net/rds/ib_stats.c +@@ -42,7 +42,7 @@ DEFINE_PER_CPU_SHARED_ALIGNED(struct rds_ib_statistics, rds_ib_stats); + static const char *const rds_ib_stat_names[] = { + "ib_connect_raced", + "ib_listen_closed_stale", +- "s_ib_evt_handler_call", ++ "ib_evt_handler_call", + "ib_tasklet_call", + "ib_tx_cq_event", + "ib_tx_ring_full", +diff --git a/net/rds/stats.c b/net/rds/stats.c +index 73be187d389e..6bbab4d74c4f 100644 +--- a/net/rds/stats.c ++++ b/net/rds/stats.c +@@ -76,6 +76,8 @@ static const char *const rds_stat_names[] = { + "cong_update_received", + "cong_send_error", + "cong_send_blocked", ++ "recv_bytes_added_to_sock", ++ "recv_bytes_freed_fromsock", + }; + + void rds_stats_info_copy(struct rds_info_iterator *iter, +diff --git a/net/rxrpc/output.c b/net/rxrpc/output.c +index 5b67cb5d47f0..edddbacf33bc 100644 +--- a/net/rxrpc/output.c ++++ b/net/rxrpc/output.c +@@ -404,6 +404,9 @@ send_fragmentable: + } + break; + #endif ++ ++ default: ++ BUG(); + } + + up_write(&conn->params.local->defrag_sem); +diff --git a/net/sched/act_mirred.c b/net/sched/act_mirred.c +index 529bb064c4a4..dcfaa4f9c7c5 100644 +--- a/net/sched/act_mirred.c ++++ b/net/sched/act_mirred.c +@@ -371,7 +371,11 @@ static int __init mirred_init_module(void) + return err; + + pr_info("Mirror/redirect action on\n"); +- return tcf_register_action(&act_mirred_ops, &mirred_net_ops); ++ err = tcf_register_action(&act_mirred_ops, &mirred_net_ops); ++ if (err) ++ unregister_netdevice_notifier(&mirred_device_notifier); ++ ++ return err; + } + + static void __exit mirred_cleanup_module(void) +diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c +index 6266121a03f9..328b043edf07 100644 +--- a/net/sched/sch_netem.c ++++ b/net/sched/sch_netem.c +@@ -431,8 +431,7 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch, + struct netem_skb_cb *cb; + struct sk_buff *skb2; + struct sk_buff *segs = NULL; +- unsigned int len = 0, last_len, prev_len = qdisc_pkt_len(skb); +- int nb = 0; ++ unsigned int prev_len = qdisc_pkt_len(skb); + int count = 1; + int rc = NET_XMIT_SUCCESS; + int rc_drop = NET_XMIT_DROP; +@@ -489,6 +488,7 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch, + segs = netem_segment(skb, sch, to_free); + if (!segs) + return rc_drop; ++ qdisc_skb_cb(segs)->pkt_len = segs->len; + } else { + segs = skb; + } +@@ -504,6 +504,7 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch, + if (skb->ip_summed == CHECKSUM_PARTIAL && + skb_checksum_help(skb)) { + qdisc_drop(skb, sch, to_free); ++ skb = NULL; + goto finish_segs; + } + +@@ -579,6 +580,12 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch, + + finish_segs: + if (segs) { ++ unsigned int len, last_len; ++ int nb; ++ ++ len = skb ? skb->len : 0; ++ nb = skb ? 1 : 0; ++ + while (segs) { + skb2 = segs->next; + segs->next = NULL; +@@ -594,9 +601,10 @@ finish_segs: + } + segs = skb2; + } +- sch->q.qlen += nb; +- if (nb > 1) +- qdisc_tree_reduce_backlog(sch, 1 - nb, prev_len - len); ++ /* Parent qdiscs accounted for 1 skb of size @prev_len */ ++ qdisc_tree_reduce_backlog(sch, -(nb - 1), -(len - prev_len)); ++ } else if (!skb) { ++ return NET_XMIT_DROP; + } + return NET_XMIT_SUCCESS; + } +diff --git a/net/tipc/link.c b/net/tipc/link.c +index da749916faac..82e4e0e152d1 100644 +--- a/net/tipc/link.c ++++ b/net/tipc/link.c +@@ -811,18 +811,31 @@ static int link_schedule_user(struct tipc_link *l, struct tipc_msg *hdr) + */ + void link_prepare_wakeup(struct tipc_link *l) + { ++ struct sk_buff_head *wakeupq = &l->wakeupq; ++ struct sk_buff_head *inputq = l->inputq; + struct sk_buff *skb, *tmp; +- int imp, i = 0; ++ struct sk_buff_head tmpq; ++ int avail[5] = {0,}; ++ int imp = 0; ++ ++ __skb_queue_head_init(&tmpq); + +- skb_queue_walk_safe(&l->wakeupq, skb, tmp) { ++ for (; imp <= TIPC_SYSTEM_IMPORTANCE; imp++) ++ avail[imp] = l->backlog[imp].limit - l->backlog[imp].len; ++ ++ skb_queue_walk_safe(wakeupq, skb, tmp) { + imp = TIPC_SKB_CB(skb)->chain_imp; +- if (l->backlog[imp].len < l->backlog[imp].limit) { +- skb_unlink(skb, &l->wakeupq); +- skb_queue_tail(l->inputq, skb); +- } else if (i++ > 10) { +- break; +- } ++ if (avail[imp] <= 0) ++ continue; ++ avail[imp]--; ++ __skb_unlink(skb, wakeupq); ++ __skb_queue_tail(&tmpq, skb); + } ++ ++ spin_lock_bh(&inputq->lock); ++ skb_queue_splice_tail(&tmpq, inputq); ++ spin_unlock_bh(&inputq->lock); ++ + } + + void tipc_link_reset(struct tipc_link *l) +diff --git a/net/tipc/node.c b/net/tipc/node.c +index 42e9bdcc4bb6..82f8f69f4d6b 100644 +--- a/net/tipc/node.c ++++ b/net/tipc/node.c +@@ -688,10 +688,10 @@ static void __tipc_node_link_down(struct tipc_node *n, int *bearer_id, + static void tipc_node_link_down(struct tipc_node *n, int bearer_id, bool delete) + { + struct tipc_link_entry *le = &n->links[bearer_id]; ++ struct tipc_media_addr *maddr = NULL; + struct tipc_link *l = le->link; +- struct tipc_media_addr *maddr; +- struct sk_buff_head xmitq; + int old_bearer_id = bearer_id; ++ struct sk_buff_head xmitq; + + if (!l) + return; +@@ -713,7 +713,8 @@ static void tipc_node_link_down(struct tipc_node *n, int bearer_id, bool delete) + tipc_node_write_unlock(n); + if (delete) + tipc_mon_remove_peer(n->net, n->addr, old_bearer_id); +- tipc_bearer_xmit(n->net, bearer_id, &xmitq, maddr); ++ if (!skb_queue_empty(&xmitq)) ++ tipc_bearer_xmit(n->net, bearer_id, &xmitq, maddr); + tipc_sk_rcv(n->net, &le->inputq); + } + +diff --git a/net/tipc/socket.c b/net/tipc/socket.c +index 21929ba196eb..d9ec6335c7dc 100644 +--- a/net/tipc/socket.c ++++ b/net/tipc/socket.c +@@ -487,7 +487,7 @@ static void __tipc_shutdown(struct socket *sock, int error) + struct sock *sk = sock->sk; + struct tipc_sock *tsk = tipc_sk(sk); + struct net *net = sock_net(sk); +- long timeout = CONN_TIMEOUT_DEFAULT; ++ long timeout = msecs_to_jiffies(CONN_TIMEOUT_DEFAULT); + u32 dnode = tsk_peer_node(tsk); + struct sk_buff *skb; + +diff --git a/net/tipc/sysctl.c b/net/tipc/sysctl.c +index 1a779b1e8510..40f6d82083d7 100644 +--- a/net/tipc/sysctl.c ++++ b/net/tipc/sysctl.c +@@ -37,6 +37,8 @@ + + #include <linux/sysctl.h> + ++static int zero; ++static int one = 1; + static struct ctl_table_header *tipc_ctl_hdr; + + static struct ctl_table tipc_table[] = { +@@ -45,14 +47,16 @@ static struct ctl_table tipc_table[] = { + .data = &sysctl_tipc_rmem, + .maxlen = sizeof(sysctl_tipc_rmem), + .mode = 0644, +- .proc_handler = proc_dointvec, ++ .proc_handler = proc_dointvec_minmax, ++ .extra1 = &one, + }, + { + .procname = "named_timeout", + .data = &sysctl_tipc_named_timeout, + .maxlen = sizeof(sysctl_tipc_named_timeout), + .mode = 0644, +- .proc_handler = proc_dointvec, ++ .proc_handler = proc_dointvec_minmax, ++ .extra1 = &zero, + }, + {} + }; +diff --git a/security/apparmor/include/context.h b/security/apparmor/include/context.h +index 6ae07e9aaa17..812cdec9dd3b 100644 +--- a/security/apparmor/include/context.h ++++ b/security/apparmor/include/context.h +@@ -191,6 +191,8 @@ static inline struct aa_label *begin_current_label_crit_section(void) + { + struct aa_label *label = aa_current_raw_label(); + ++ might_sleep(); ++ + if (label_is_stale(label)) { + label = aa_get_newest_label(label); + if (aa_replace_current_label(label) == 0) +diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c +index 1346ee5be04f..4f08023101f3 100644 +--- a/security/apparmor/lsm.c ++++ b/security/apparmor/lsm.c +@@ -108,12 +108,12 @@ static int apparmor_ptrace_access_check(struct task_struct *child, + struct aa_label *tracer, *tracee; + int error; + +- tracer = begin_current_label_crit_section(); ++ tracer = __begin_current_label_crit_section(); + tracee = aa_get_task_label(child); + error = aa_may_ptrace(tracer, tracee, + mode == PTRACE_MODE_READ ? AA_PTRACE_READ : AA_PTRACE_TRACE); + aa_put_label(tracee); +- end_current_label_crit_section(tracer); ++ __end_current_label_crit_section(tracer); + + return error; + } +diff --git a/security/keys/key.c b/security/keys/key.c +index 87172f99f73e..17244f5f54c6 100644 +--- a/security/keys/key.c ++++ b/security/keys/key.c +@@ -297,6 +297,7 @@ struct key *key_alloc(struct key_type *type, const char *desc, + key->gid = gid; + key->perm = perm; + key->restrict_link = restrict_link; ++ key->last_used_at = ktime_get_real_seconds(); + + if (!(flags & KEY_ALLOC_NOT_IN_QUOTA)) + key->flags |= 1 << KEY_FLAG_IN_QUOTA; +diff --git a/sound/aoa/codecs/onyx.c b/sound/aoa/codecs/onyx.c +index d2d96ca082b7..6224fd3bbf7c 100644 +--- a/sound/aoa/codecs/onyx.c ++++ b/sound/aoa/codecs/onyx.c +@@ -74,8 +74,10 @@ static int onyx_read_register(struct onyx *onyx, u8 reg, u8 *value) + return 0; + } + v = i2c_smbus_read_byte_data(onyx->i2c, reg); +- if (v < 0) ++ if (v < 0) { ++ *value = 0; + return -1; ++ } + *value = (u8)v; + onyx->cache[ONYX_REG_CONTROL-FIRSTREGISTER] = *value; + return 0; +diff --git a/sound/pci/hda/hda_controller.h b/sound/pci/hda/hda_controller.h +index 8a9dd4767b1e..63cc10604afc 100644 +--- a/sound/pci/hda/hda_controller.h ++++ b/sound/pci/hda/hda_controller.h +@@ -176,11 +176,10 @@ struct azx { + #define azx_bus(chip) (&(chip)->bus.core) + #define bus_to_azx(_bus) container_of(_bus, struct azx, bus.core) + +-#ifdef CONFIG_X86 +-#define azx_snoop(chip) ((chip)->snoop) +-#else +-#define azx_snoop(chip) true +-#endif ++static inline bool azx_snoop(struct azx *chip) ++{ ++ return !IS_ENABLED(CONFIG_X86) || chip->snoop; ++} + + /* + * macros for easy use +diff --git a/sound/soc/codecs/cs4349.c b/sound/soc/codecs/cs4349.c +index 0a749c79ef57..1d38e53dc95c 100644 +--- a/sound/soc/codecs/cs4349.c ++++ b/sound/soc/codecs/cs4349.c +@@ -380,6 +380,7 @@ static struct i2c_driver cs4349_i2c_driver = { + .driver = { + .name = "cs4349", + .of_match_table = cs4349_of_match, ++ .pm = &cs4349_runtime_pm, + }, + .id_table = cs4349_i2c_id, + .probe = cs4349_i2c_probe, +diff --git a/sound/soc/codecs/es8328.c b/sound/soc/codecs/es8328.c +index bcdb8914ec16..e2f44fa46262 100644 +--- a/sound/soc/codecs/es8328.c ++++ b/sound/soc/codecs/es8328.c +@@ -231,7 +231,7 @@ static const struct soc_enum es8328_rline_enum = + ARRAY_SIZE(es8328_line_texts), + es8328_line_texts); + static const struct snd_kcontrol_new es8328_right_line_controls = +- SOC_DAPM_ENUM("Route", es8328_lline_enum); ++ SOC_DAPM_ENUM("Route", es8328_rline_enum); + + /* Left Mixer */ + static const struct snd_kcontrol_new es8328_left_mixer_controls[] = { +diff --git a/sound/soc/codecs/wm8737.c b/sound/soc/codecs/wm8737.c +index f0cb1c4afe3c..c5a8d758f58b 100644 +--- a/sound/soc/codecs/wm8737.c ++++ b/sound/soc/codecs/wm8737.c +@@ -170,7 +170,7 @@ SOC_DOUBLE("Polarity Invert Switch", WM8737_ADC_CONTROL, 5, 6, 1, 0), + SOC_SINGLE("3D Switch", WM8737_3D_ENHANCE, 0, 1, 0), + SOC_SINGLE("3D Depth", WM8737_3D_ENHANCE, 1, 15, 0), + SOC_ENUM("3D Low Cut-off", low_3d), +-SOC_ENUM("3D High Cut-off", low_3d), ++SOC_ENUM("3D High Cut-off", high_3d), + SOC_SINGLE_TLV("3D ADC Volume", WM8737_3D_ENHANCE, 7, 1, 1, adc_tlv), + + SOC_SINGLE("Noise Gate Switch", WM8737_NOISE_GATE, 0, 1, 0), +diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c +index 07bac9ea65c4..e10e03800cce 100644 +--- a/sound/soc/davinci/davinci-mcasp.c ++++ b/sound/soc/davinci/davinci-mcasp.c +@@ -882,14 +882,13 @@ static int mcasp_i2s_hw_param(struct davinci_mcasp *mcasp, int stream, + active_slots = hweight32(mcasp->tdm_mask[stream]); + active_serializers = (channels + active_slots - 1) / + active_slots; +- if (active_serializers == 1) { ++ if (active_serializers == 1) + active_slots = channels; +- for (i = 0; i < total_slots; i++) { +- if ((1 << i) & mcasp->tdm_mask[stream]) { +- mask |= (1 << i); +- if (--active_slots <= 0) +- break; +- } ++ for (i = 0; i < total_slots; i++) { ++ if ((1 << i) & mcasp->tdm_mask[stream]) { ++ mask |= (1 << i); ++ if (--active_slots <= 0) ++ break; + } + } + } else { +diff --git a/sound/soc/fsl/imx-sgtl5000.c b/sound/soc/fsl/imx-sgtl5000.c +index 8e525f7ac08d..3d99a8579c99 100644 +--- a/sound/soc/fsl/imx-sgtl5000.c ++++ b/sound/soc/fsl/imx-sgtl5000.c +@@ -119,7 +119,8 @@ static int imx_sgtl5000_probe(struct platform_device *pdev) + codec_dev = of_find_i2c_device_by_node(codec_np); + if (!codec_dev) { + dev_err(&pdev->dev, "failed to find codec platform device\n"); +- return -EPROBE_DEFER; ++ ret = -EPROBE_DEFER; ++ goto fail; + } + + data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); +diff --git a/sound/soc/qcom/apq8016_sbc.c b/sound/soc/qcom/apq8016_sbc.c +index d49adc822a11..8e6b88d68ca6 100644 +--- a/sound/soc/qcom/apq8016_sbc.c ++++ b/sound/soc/qcom/apq8016_sbc.c +@@ -163,41 +163,52 @@ static struct apq8016_sbc_data *apq8016_sbc_parse_of(struct snd_soc_card *card) + + if (!cpu || !codec) { + dev_err(dev, "Can't find cpu/codec DT node\n"); +- return ERR_PTR(-EINVAL); ++ ret = -EINVAL; ++ goto error; + } + + link->cpu_of_node = of_parse_phandle(cpu, "sound-dai", 0); + if (!link->cpu_of_node) { + dev_err(card->dev, "error getting cpu phandle\n"); +- return ERR_PTR(-EINVAL); ++ ret = -EINVAL; ++ goto error; + } + + ret = snd_soc_of_get_dai_name(cpu, &link->cpu_dai_name); + if (ret) { + dev_err(card->dev, "error getting cpu dai name\n"); +- return ERR_PTR(ret); ++ goto error; + } + + ret = snd_soc_of_get_dai_link_codecs(dev, codec, link); + + if (ret < 0) { + dev_err(card->dev, "error getting codec dai name\n"); +- return ERR_PTR(ret); ++ goto error; + } + + link->platform_of_node = link->cpu_of_node; + ret = of_property_read_string(np, "link-name", &link->name); + if (ret) { + dev_err(card->dev, "error getting codec dai_link name\n"); +- return ERR_PTR(ret); ++ goto error; + } + + link->stream_name = link->name; + link->init = apq8016_sbc_dai_init; + link++; ++ ++ of_node_put(cpu); ++ of_node_put(codec); + } + + return data; ++ ++ error: ++ of_node_put(np); ++ of_node_put(cpu); ++ of_node_put(codec); ++ return ERR_PTR(ret); + } + + static const struct snd_soc_dapm_widget apq8016_sbc_dapm_widgets[] = { +diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c +index 24047375c2fb..70e1a60a2e98 100644 +--- a/sound/soc/soc-pcm.c ++++ b/sound/soc/soc-pcm.c +@@ -48,8 +48,8 @@ static bool snd_soc_dai_stream_valid(struct snd_soc_dai *dai, int stream) + else + codec_stream = &dai->driver->capture; + +- /* If the codec specifies any rate at all, it supports the stream. */ +- return codec_stream->rates; ++ /* If the codec specifies any channels at all, it supports the stream */ ++ return codec_stream->channels_min; + } + + /** +diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c +index da0a2083e12a..d2802fd8c1dd 100644 +--- a/sound/soc/sunxi/sun4i-i2s.c ++++ b/sound/soc/sunxi/sun4i-i2s.c +@@ -80,8 +80,8 @@ + #define SUN4I_I2S_CLK_DIV_MCLK_MASK GENMASK(3, 0) + #define SUN4I_I2S_CLK_DIV_MCLK(mclk) ((mclk) << 0) + +-#define SUN4I_I2S_RX_CNT_REG 0x28 +-#define SUN4I_I2S_TX_CNT_REG 0x2c ++#define SUN4I_I2S_TX_CNT_REG 0x28 ++#define SUN4I_I2S_RX_CNT_REG 0x2c + + #define SUN4I_I2S_TX_CHAN_SEL_REG 0x30 + #define SUN4I_I2S_CHAN_SEL(num_chan) (((num_chan) - 1) << 0) +diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c +index 044193b2364d..e6e4c3b9d9d3 100644 +--- a/sound/usb/mixer.c ++++ b/sound/usb/mixer.c +@@ -2632,7 +2632,9 @@ int snd_usb_create_mixer(struct snd_usb_audio *chip, int ctrlif, + (err = snd_usb_mixer_status_create(mixer)) < 0) + goto _error; + +- snd_usb_mixer_apply_create_quirk(mixer); ++ err = snd_usb_mixer_apply_create_quirk(mixer); ++ if (err < 0) ++ goto _error; + + err = snd_device_new(chip->card, SNDRV_DEV_CODEC, mixer, &dev_ops); + if (err < 0) +diff --git a/sound/usb/quirks-table.h b/sound/usb/quirks-table.h +index d32727c74a16..c892b4d1e733 100644 +--- a/sound/usb/quirks-table.h ++++ b/sound/usb/quirks-table.h +@@ -3293,19 +3293,14 @@ AU0828_DEVICE(0x2040, 0x7270, "Hauppauge", "HVR-950Q"), + .ifnum = 0, + .type = QUIRK_AUDIO_STANDARD_MIXER, + }, +- /* Capture */ +- { +- .ifnum = 1, +- .type = QUIRK_IGNORE_INTERFACE, +- }, + /* Playback */ + { +- .ifnum = 2, ++ .ifnum = 1, + .type = QUIRK_AUDIO_FIXED_ENDPOINT, + .data = &(const struct audioformat) { + .formats = SNDRV_PCM_FMTBIT_S16_LE, + .channels = 2, +- .iface = 2, ++ .iface = 1, + .altsetting = 1, + .altset_idx = 1, + .attributes = UAC_EP_CS_ATTR_FILL_MAX | +diff --git a/tools/testing/selftests/ipc/msgque.c b/tools/testing/selftests/ipc/msgque.c +index ee9382bdfadc..c5587844fbb8 100644 +--- a/tools/testing/selftests/ipc/msgque.c ++++ b/tools/testing/selftests/ipc/msgque.c +@@ -1,9 +1,10 @@ + // SPDX-License-Identifier: GPL-2.0 ++#define _GNU_SOURCE + #include <stdlib.h> + #include <stdio.h> + #include <string.h> + #include <errno.h> +-#include <linux/msg.h> ++#include <sys/msg.h> + #include <fcntl.h> + + #include "../kselftest.h" +@@ -73,7 +74,7 @@ int restore_queue(struct msgque_data *msgque) + return 0; + + destroy: +- if (msgctl(id, IPC_RMID, 0)) ++ if (msgctl(id, IPC_RMID, NULL)) + printf("Failed to destroy queue: %d\n", -errno); + return ret; + } +@@ -120,7 +121,7 @@ int check_and_destroy_queue(struct msgque_data *msgque) + + ret = 0; + err: +- if (msgctl(msgque->msq_id, IPC_RMID, 0)) { ++ if (msgctl(msgque->msq_id, IPC_RMID, NULL)) { + printf("Failed to destroy queue: %d\n", -errno); + return -errno; + } +@@ -129,7 +130,7 @@ err: + + int dump_queue(struct msgque_data *msgque) + { +- struct msqid64_ds ds; ++ struct msqid_ds ds; + int kern_id; + int i, ret; + +@@ -246,7 +247,7 @@ int main(int argc, char **argv) + return ksft_exit_pass(); + + err_destroy: +- if (msgctl(msgque.msq_id, IPC_RMID, 0)) { ++ if (msgctl(msgque.msq_id, IPC_RMID, NULL)) { + printf("Failed to destroy queue: %d\n", -errno); + return ksft_exit_fail(); + } |