From c0527b1b21a67f271edcac482e10799a39aa015f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20Pe=C4=8Dovnik?= Date: Sun, 9 Feb 2020 13:52:35 +0100 Subject: [PATCH] Add upstream patches, briefly tested for stability. (#1791) --- config/kernel/linux-odroidxu4-legacy.config | 2 +- .../patch-4.14.167-168-alt.patch | 9416 +++++++++++++++++ .../odroidxu4-legacy/patch-4.14.168-169.patch | 1600 +++ .../odroidxu4-legacy/patch-4.14.169-170.patch | 3128 ++++++ 4 files changed, 14145 insertions(+), 1 deletion(-) create mode 100644 patch/kernel/odroidxu4-legacy/patch-4.14.167-168-alt.patch create mode 100644 patch/kernel/odroidxu4-legacy/patch-4.14.168-169.patch create mode 100644 patch/kernel/odroidxu4-legacy/patch-4.14.169-170.patch diff --git a/config/kernel/linux-odroidxu4-legacy.config b/config/kernel/linux-odroidxu4-legacy.config index 364e0c8919..c9c0b24829 100644 --- a/config/kernel/linux-odroidxu4-legacy.config +++ b/config/kernel/linux-odroidxu4-legacy.config @@ -1,6 +1,6 @@ # # Automatically generated file; DO NOT EDIT. -# Linux/arm 4.14.167 Kernel Configuration +# Linux/arm 4.14.170 Kernel Configuration # CONFIG_ARM=y CONFIG_ARM_HAS_SG_CHAIN=y diff --git a/patch/kernel/odroidxu4-legacy/patch-4.14.167-168-alt.patch b/patch/kernel/odroidxu4-legacy/patch-4.14.167-168-alt.patch new file mode 100644 index 0000000000..02279ee57b --- /dev/null +++ b/patch/kernel/odroidxu4-legacy/patch-4.14.167-168-alt.patch @@ -0,0 +1,9416 @@ +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/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 = , + , + ; +- 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 + #include + #include +-#include + #include + #include + #include +@@ -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 +- */ +- +-#include +-#include +-#include +- +-#include +-#include +-#include +-#include +- +-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 + #include + #include +-#include + + /* + * 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 + #include + ++#include ++#include ++ + /* 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 + #include + #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 + #include + #include +-#include + #include ++#include ++#include + + #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 + * +@@ -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 + #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 + #include + #include ++#include + + #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 + ++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 + #include + #include + #include +-#include ++#include + #include + + #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(); + } diff --git a/patch/kernel/odroidxu4-legacy/patch-4.14.168-169.patch b/patch/kernel/odroidxu4-legacy/patch-4.14.168-169.patch new file mode 100644 index 0000000000..c56331205d --- /dev/null +++ b/patch/kernel/odroidxu4-legacy/patch-4.14.168-169.patch @@ -0,0 +1,1600 @@ +diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt +index 933465eff40e..7e0a4be3503d 100644 +--- a/Documentation/admin-guide/kernel-parameters.txt ++++ b/Documentation/admin-guide/kernel-parameters.txt +@@ -1845,6 +1845,12 @@ + Built with CONFIG_DEBUG_KMEMLEAK_DEFAULT_OFF=y, + the default is off. + ++ kpti= [ARM64] Control page table isolation of user ++ and kernel address spaces. ++ Default: enabled on cores which need mitigation. ++ 0: force disabled ++ 1: force enabled ++ + kvm.ignore_msrs=[KVM] Ignore guest accesses to unhandled MSRs. + Default is 0 (don't ignore, but inject #GP) + +diff --git a/Makefile b/Makefile +index 1e74ba09cdda..795d93bfe156 100644 +--- a/Makefile ++++ b/Makefile +@@ -1,7 +1,7 @@ + # SPDX-License-Identifier: GPL-2.0 + VERSION = 4 + PATCHLEVEL = 14 +-SUBLEVEL = 168 ++SUBLEVEL = 169 + EXTRAVERSION = + NAME = Petit Gorille + +diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c +index 6b6368a56526..0e449ee11ac7 100644 +--- a/drivers/atm/firestream.c ++++ b/drivers/atm/firestream.c +@@ -927,6 +927,7 @@ static int fs_open(struct atm_vcc *atm_vcc) + } + if (!to) { + printk ("No more free channels for FS50..\n"); ++ kfree(vcc); + return -EBUSY; + } + vcc->channo = dev->channo; +@@ -937,6 +938,7 @@ static int fs_open(struct atm_vcc *atm_vcc) + if (((DO_DIRECTION(rxtp) && dev->atm_vccs[vcc->channo])) || + ( DO_DIRECTION(txtp) && test_bit (vcc->channo, dev->tx_inuse))) { + printk ("Channel is in use for FS155.\n"); ++ kfree(vcc); + return -EBUSY; + } + } +@@ -950,6 +952,7 @@ static int fs_open(struct atm_vcc *atm_vcc) + tc, sizeof (struct fs_transmit_config)); + if (!tc) { + fs_dprintk (FS_DEBUG_OPEN, "fs: can't alloc transmit_config.\n"); ++ kfree(vcc); + return -ENOMEM; + } + +diff --git a/drivers/hwmon/adt7475.c b/drivers/hwmon/adt7475.c +index 37db2eb66ed7..d7d1f2467100 100644 +--- a/drivers/hwmon/adt7475.c ++++ b/drivers/hwmon/adt7475.c +@@ -297,9 +297,10 @@ static inline u16 volt2reg(int channel, long volt, u8 bypass_attn) + long reg; + + if (bypass_attn & (1 << channel)) +- reg = (volt * 1024) / 2250; ++ reg = DIV_ROUND_CLOSEST(volt * 1024, 2250); + else +- reg = (volt * r[1] * 1024) / ((r[0] + r[1]) * 2250); ++ reg = DIV_ROUND_CLOSEST(volt * r[1] * 1024, ++ (r[0] + r[1]) * 2250); + return clamp_val(reg, 0, 1023) & (0xff << 2); + } + +diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c +index 7b53065e9882..652973d83a07 100644 +--- a/drivers/hwmon/hwmon.c ++++ b/drivers/hwmon/hwmon.c +@@ -51,6 +51,7 @@ struct hwmon_device_attribute { + + #define to_hwmon_attr(d) \ + container_of(d, struct hwmon_device_attribute, dev_attr) ++#define to_dev_attr(a) container_of(a, struct device_attribute, attr) + + /* + * Thermal zone information +@@ -58,7 +59,7 @@ struct hwmon_device_attribute { + * also provides the sensor index. + */ + struct hwmon_thermal_data { +- struct hwmon_device *hwdev; /* Reference to hwmon device */ ++ struct device *dev; /* Reference to hwmon device */ + int index; /* sensor index */ + }; + +@@ -95,9 +96,27 @@ static const struct attribute_group *hwmon_dev_attr_groups[] = { + NULL + }; + ++static void hwmon_free_attrs(struct attribute **attrs) ++{ ++ int i; ++ ++ for (i = 0; attrs[i]; i++) { ++ struct device_attribute *dattr = to_dev_attr(attrs[i]); ++ struct hwmon_device_attribute *hattr = to_hwmon_attr(dattr); ++ ++ kfree(hattr); ++ } ++ kfree(attrs); ++} ++ + static void hwmon_dev_release(struct device *dev) + { +- kfree(to_hwmon_device(dev)); ++ struct hwmon_device *hwdev = to_hwmon_device(dev); ++ ++ if (hwdev->group.attrs) ++ hwmon_free_attrs(hwdev->group.attrs); ++ kfree(hwdev->groups); ++ kfree(hwdev); + } + + static struct class hwmon_class = { +@@ -121,11 +140,11 @@ static DEFINE_IDA(hwmon_ida); + static int hwmon_thermal_get_temp(void *data, int *temp) + { + struct hwmon_thermal_data *tdata = data; +- struct hwmon_device *hwdev = tdata->hwdev; ++ struct hwmon_device *hwdev = to_hwmon_device(tdata->dev); + int ret; + long t; + +- ret = hwdev->chip->ops->read(&hwdev->dev, hwmon_temp, hwmon_temp_input, ++ ret = hwdev->chip->ops->read(tdata->dev, hwmon_temp, hwmon_temp_input, + tdata->index, &t); + if (ret < 0) + return ret; +@@ -139,26 +158,31 @@ static const struct thermal_zone_of_device_ops hwmon_thermal_ops = { + .get_temp = hwmon_thermal_get_temp, + }; + +-static int hwmon_thermal_add_sensor(struct device *dev, +- struct hwmon_device *hwdev, int index) ++static int hwmon_thermal_add_sensor(struct device *dev, int index) + { + struct hwmon_thermal_data *tdata; ++ struct thermal_zone_device *tzd; + + tdata = devm_kzalloc(dev, sizeof(*tdata), GFP_KERNEL); + if (!tdata) + return -ENOMEM; + +- tdata->hwdev = hwdev; ++ tdata->dev = dev; + tdata->index = index; + +- devm_thermal_zone_of_sensor_register(&hwdev->dev, index, tdata, +- &hwmon_thermal_ops); ++ tzd = devm_thermal_zone_of_sensor_register(dev, index, tdata, ++ &hwmon_thermal_ops); ++ /* ++ * If CONFIG_THERMAL_OF is disabled, this returns -ENODEV, ++ * so ignore that error but forward any other error. ++ */ ++ if (IS_ERR(tzd) && (PTR_ERR(tzd) != -ENODEV)) ++ return PTR_ERR(tzd); + + return 0; + } + #else +-static int hwmon_thermal_add_sensor(struct device *dev, +- struct hwmon_device *hwdev, int index) ++static int hwmon_thermal_add_sensor(struct device *dev, int index) + { + return 0; + } +@@ -235,8 +259,7 @@ static bool is_string_attr(enum hwmon_sensor_types type, u32 attr) + (type == hwmon_fan && attr == hwmon_fan_label); + } + +-static struct attribute *hwmon_genattr(struct device *dev, +- const void *drvdata, ++static struct attribute *hwmon_genattr(const void *drvdata, + enum hwmon_sensor_types type, + u32 attr, + int index, +@@ -264,7 +287,7 @@ static struct attribute *hwmon_genattr(struct device *dev, + if ((mode & S_IWUGO) && !ops->write) + return ERR_PTR(-EINVAL); + +- hattr = devm_kzalloc(dev, sizeof(*hattr), GFP_KERNEL); ++ hattr = kzalloc(sizeof(*hattr), GFP_KERNEL); + if (!hattr) + return ERR_PTR(-ENOMEM); + +@@ -467,8 +490,7 @@ static int hwmon_num_channel_attrs(const struct hwmon_channel_info *info) + return n; + } + +-static int hwmon_genattrs(struct device *dev, +- const void *drvdata, ++static int hwmon_genattrs(const void *drvdata, + struct attribute **attrs, + const struct hwmon_ops *ops, + const struct hwmon_channel_info *info) +@@ -494,7 +516,7 @@ static int hwmon_genattrs(struct device *dev, + attr_mask &= ~BIT(attr); + if (attr >= template_size) + return -EINVAL; +- a = hwmon_genattr(dev, drvdata, info->type, attr, i, ++ a = hwmon_genattr(drvdata, info->type, attr, i, + templates[attr], ops); + if (IS_ERR(a)) { + if (PTR_ERR(a) != -ENOENT) +@@ -508,8 +530,7 @@ static int hwmon_genattrs(struct device *dev, + } + + static struct attribute ** +-__hwmon_create_attrs(struct device *dev, const void *drvdata, +- const struct hwmon_chip_info *chip) ++__hwmon_create_attrs(const void *drvdata, const struct hwmon_chip_info *chip) + { + int ret, i, aindex = 0, nattrs = 0; + struct attribute **attrs; +@@ -520,15 +541,17 @@ __hwmon_create_attrs(struct device *dev, const void *drvdata, + if (nattrs == 0) + return ERR_PTR(-EINVAL); + +- attrs = devm_kcalloc(dev, nattrs + 1, sizeof(*attrs), GFP_KERNEL); ++ attrs = kcalloc(nattrs + 1, sizeof(*attrs), GFP_KERNEL); + if (!attrs) + return ERR_PTR(-ENOMEM); + + for (i = 0; chip->info[i]; i++) { +- ret = hwmon_genattrs(dev, drvdata, &attrs[aindex], chip->ops, ++ ret = hwmon_genattrs(drvdata, &attrs[aindex], chip->ops, + chip->info[i]); +- if (ret < 0) ++ if (ret < 0) { ++ hwmon_free_attrs(attrs); + return ERR_PTR(ret); ++ } + aindex += ret; + } + +@@ -570,14 +593,13 @@ __hwmon_device_register(struct device *dev, const char *name, void *drvdata, + for (i = 0; groups[i]; i++) + ngroups++; + +- hwdev->groups = devm_kcalloc(dev, ngroups, sizeof(*groups), +- GFP_KERNEL); ++ hwdev->groups = kcalloc(ngroups, sizeof(*groups), GFP_KERNEL); + if (!hwdev->groups) { + err = -ENOMEM; + goto free_hwmon; + } + +- attrs = __hwmon_create_attrs(dev, drvdata, chip); ++ attrs = __hwmon_create_attrs(drvdata, chip); + if (IS_ERR(attrs)) { + err = PTR_ERR(attrs); + goto free_hwmon; +@@ -621,8 +643,13 @@ __hwmon_device_register(struct device *dev, const char *name, void *drvdata, + if (!chip->ops->is_visible(drvdata, hwmon_temp, + hwmon_temp_input, j)) + continue; +- if (info[i]->config[j] & HWMON_T_INPUT) +- hwmon_thermal_add_sensor(dev, hwdev, j); ++ if (info[i]->config[j] & HWMON_T_INPUT) { ++ err = hwmon_thermal_add_sensor(hdev, j); ++ if (err) { ++ device_unregister(hdev); ++ goto ida_remove; ++ } ++ } + } + } + } +@@ -630,7 +657,7 @@ __hwmon_device_register(struct device *dev, const char *name, void *drvdata, + return hdev; + + free_hwmon: +- kfree(hwdev); ++ hwmon_dev_release(hdev); + ida_remove: + ida_simple_remove(&hwmon_ida, id); + return ERR_PTR(err); +diff --git a/drivers/hwmon/nct7802.c b/drivers/hwmon/nct7802.c +index 38ffbdb0a85f..779ec8fdfae0 100644 +--- a/drivers/hwmon/nct7802.c ++++ b/drivers/hwmon/nct7802.c +@@ -32,8 +32,8 @@ + static const u8 REG_VOLTAGE[5] = { 0x09, 0x0a, 0x0c, 0x0d, 0x0e }; + + static const u8 REG_VOLTAGE_LIMIT_LSB[2][5] = { +- { 0x40, 0x00, 0x42, 0x44, 0x46 }, +- { 0x3f, 0x00, 0x41, 0x43, 0x45 }, ++ { 0x46, 0x00, 0x40, 0x42, 0x44 }, ++ { 0x45, 0x00, 0x3f, 0x41, 0x43 }, + }; + + static const u8 REG_VOLTAGE_LIMIT_MSB[5] = { 0x48, 0x00, 0x47, 0x47, 0x48 }; +diff --git a/drivers/hwtracing/coresight/coresight-etb10.c b/drivers/hwtracing/coresight/coresight-etb10.c +index d14a9cb7959a..cb675a596302 100644 +--- a/drivers/hwtracing/coresight/coresight-etb10.c ++++ b/drivers/hwtracing/coresight/coresight-etb10.c +@@ -287,9 +287,7 @@ static void *etb_alloc_buffer(struct coresight_device *csdev, int cpu, + int node; + struct cs_buffers *buf; + +- if (cpu == -1) +- cpu = smp_processor_id(); +- node = cpu_to_node(cpu); ++ node = (cpu == -1) ? NUMA_NO_NODE : cpu_to_node(cpu); + + buf = kzalloc_node(sizeof(struct cs_buffers), GFP_KERNEL, node); + if (!buf) +diff --git a/drivers/hwtracing/coresight/coresight-tmc-etf.c b/drivers/hwtracing/coresight/coresight-tmc-etf.c +index 336194d059fe..0a00f4e941fb 100644 +--- a/drivers/hwtracing/coresight/coresight-tmc-etf.c ++++ b/drivers/hwtracing/coresight/coresight-tmc-etf.c +@@ -308,9 +308,7 @@ static void *tmc_alloc_etf_buffer(struct coresight_device *csdev, int cpu, + int node; + struct cs_buffers *buf; + +- if (cpu == -1) +- cpu = smp_processor_id(); +- node = cpu_to_node(cpu); ++ node = (cpu == -1) ? NUMA_NO_NODE : cpu_to_node(cpu); + + /* Allocate memory structure for interaction with Perf */ + buf = kzalloc_node(sizeof(struct cs_buffers), GFP_KERNEL, node); +diff --git a/drivers/infiniband/ulp/isert/ib_isert.c b/drivers/infiniband/ulp/isert/ib_isert.c +index ee3f630c9217..9b5691f306a2 100644 +--- a/drivers/infiniband/ulp/isert/ib_isert.c ++++ b/drivers/infiniband/ulp/isert/ib_isert.c +@@ -2582,17 +2582,6 @@ isert_wait4logout(struct isert_conn *isert_conn) + } + } + +-static void +-isert_wait4cmds(struct iscsi_conn *conn) +-{ +- isert_info("iscsi_conn %p\n", conn); +- +- if (conn->sess) { +- target_sess_cmd_list_set_waiting(conn->sess->se_sess); +- target_wait_for_sess_cmds(conn->sess->se_sess); +- } +-} +- + /** + * isert_put_unsol_pending_cmds() - Drop commands waiting for + * unsolicitate dataout +@@ -2640,7 +2629,6 @@ static void isert_wait_conn(struct iscsi_conn *conn) + + ib_drain_qp(isert_conn->qp); + isert_put_unsol_pending_cmds(conn); +- isert_wait4cmds(conn); + isert_wait4logout(isert_conn); + + queue_work(isert_release_wq, &isert_conn->release_work); +diff --git a/drivers/input/misc/keyspan_remote.c b/drivers/input/misc/keyspan_remote.c +index 77c47d6325fe..a9ee813eef10 100644 +--- a/drivers/input/misc/keyspan_remote.c ++++ b/drivers/input/misc/keyspan_remote.c +@@ -344,7 +344,8 @@ static int keyspan_setup(struct usb_device* dev) + int retval = 0; + + retval = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), +- 0x11, 0x40, 0x5601, 0x0, NULL, 0, 0); ++ 0x11, 0x40, 0x5601, 0x0, NULL, 0, ++ USB_CTRL_SET_TIMEOUT); + if (retval) { + dev_dbg(&dev->dev, "%s - failed to set bit rate due to error: %d\n", + __func__, retval); +@@ -352,7 +353,8 @@ static int keyspan_setup(struct usb_device* dev) + } + + retval = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), +- 0x44, 0x40, 0x0, 0x0, NULL, 0, 0); ++ 0x44, 0x40, 0x0, 0x0, NULL, 0, ++ USB_CTRL_SET_TIMEOUT); + if (retval) { + dev_dbg(&dev->dev, "%s - failed to set resume sensitivity due to error: %d\n", + __func__, retval); +@@ -360,7 +362,8 @@ static int keyspan_setup(struct usb_device* dev) + } + + retval = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), +- 0x22, 0x40, 0x0, 0x0, NULL, 0, 0); ++ 0x22, 0x40, 0x0, 0x0, NULL, 0, ++ USB_CTRL_SET_TIMEOUT); + if (retval) { + dev_dbg(&dev->dev, "%s - failed to turn receive on due to error: %d\n", + __func__, retval); +diff --git a/drivers/input/misc/pm8xxx-vibrator.c b/drivers/input/misc/pm8xxx-vibrator.c +index 7dd1c1fbe42a..27b3db154a33 100644 +--- a/drivers/input/misc/pm8xxx-vibrator.c ++++ b/drivers/input/misc/pm8xxx-vibrator.c +@@ -98,7 +98,7 @@ static int pm8xxx_vib_set(struct pm8xxx_vib *vib, bool on) + + if (regs->enable_mask) + rc = regmap_update_bits(vib->regmap, regs->enable_addr, +- on ? regs->enable_mask : 0, val); ++ regs->enable_mask, on ? ~0 : 0); + + return rc; + } +diff --git a/drivers/input/rmi4/rmi_smbus.c b/drivers/input/rmi4/rmi_smbus.c +index 4b2466cf2fb1..b6ccf39c6a7b 100644 +--- a/drivers/input/rmi4/rmi_smbus.c ++++ b/drivers/input/rmi4/rmi_smbus.c +@@ -166,6 +166,7 @@ static int rmi_smb_write_block(struct rmi_transport_dev *xport, u16 rmiaddr, + /* prepare to write next block of bytes */ + cur_len -= SMB_MAX_COUNT; + databuff += SMB_MAX_COUNT; ++ rmiaddr += SMB_MAX_COUNT; + } + exit: + mutex_unlock(&rmi_smb->page_mutex); +@@ -217,6 +218,7 @@ static int rmi_smb_read_block(struct rmi_transport_dev *xport, u16 rmiaddr, + /* prepare to read next block of bytes */ + cur_len -= SMB_MAX_COUNT; + databuff += SMB_MAX_COUNT; ++ rmiaddr += SMB_MAX_COUNT; + } + + retval = 0; +diff --git a/drivers/input/tablet/aiptek.c b/drivers/input/tablet/aiptek.c +index 0b55e1f375b3..fbe2df91aad3 100644 +--- a/drivers/input/tablet/aiptek.c ++++ b/drivers/input/tablet/aiptek.c +@@ -1822,14 +1822,14 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id) + input_set_abs_params(inputdev, ABS_WHEEL, AIPTEK_WHEEL_MIN, AIPTEK_WHEEL_MAX - 1, 0, 0); + + /* Verify that a device really has an endpoint */ +- if (intf->altsetting[0].desc.bNumEndpoints < 1) { ++ if (intf->cur_altsetting->desc.bNumEndpoints < 1) { + dev_err(&intf->dev, + "interface has %d endpoints, but must have minimum 1\n", +- intf->altsetting[0].desc.bNumEndpoints); ++ intf->cur_altsetting->desc.bNumEndpoints); + err = -EINVAL; + goto fail3; + } +- endpoint = &intf->altsetting[0].endpoint[0].desc; ++ endpoint = &intf->cur_altsetting->endpoint[0].desc; + + /* Go set up our URB, which is called when the tablet receives + * input. +diff --git a/drivers/input/tablet/gtco.c b/drivers/input/tablet/gtco.c +index 35031228a6d0..799c94dda651 100644 +--- a/drivers/input/tablet/gtco.c ++++ b/drivers/input/tablet/gtco.c +@@ -875,18 +875,14 @@ static int gtco_probe(struct usb_interface *usbinterface, + } + + /* Sanity check that a device has an endpoint */ +- if (usbinterface->altsetting[0].desc.bNumEndpoints < 1) { ++ if (usbinterface->cur_altsetting->desc.bNumEndpoints < 1) { + dev_err(&usbinterface->dev, + "Invalid number of endpoints\n"); + error = -EINVAL; + goto err_free_urb; + } + +- /* +- * The endpoint is always altsetting 0, we know this since we know +- * this device only has one interrupt endpoint +- */ +- endpoint = &usbinterface->altsetting[0].endpoint[0].desc; ++ endpoint = &usbinterface->cur_altsetting->endpoint[0].desc; + + /* Some debug */ + dev_dbg(&usbinterface->dev, "gtco # interfaces: %d\n", usbinterface->num_altsetting); +@@ -973,7 +969,7 @@ static int gtco_probe(struct usb_interface *usbinterface, + input_dev->dev.parent = &usbinterface->dev; + + /* Setup the URB, it will be posted later on open of input device */ +- endpoint = &usbinterface->altsetting[0].endpoint[0].desc; ++ endpoint = &usbinterface->cur_altsetting->endpoint[0].desc; + + usb_fill_int_urb(gtco->urbinfo, + udev, +diff --git a/drivers/input/tablet/pegasus_notetaker.c b/drivers/input/tablet/pegasus_notetaker.c +index 47de5a81172f..2319144802c9 100644 +--- a/drivers/input/tablet/pegasus_notetaker.c ++++ b/drivers/input/tablet/pegasus_notetaker.c +@@ -260,7 +260,7 @@ static int pegasus_probe(struct usb_interface *intf, + return -ENODEV; + + /* Sanity check that the device has an endpoint */ +- if (intf->altsetting[0].desc.bNumEndpoints < 1) { ++ if (intf->cur_altsetting->desc.bNumEndpoints < 1) { + dev_err(&intf->dev, "Invalid number of endpoints\n"); + return -EINVAL; + } +diff --git a/drivers/input/touchscreen/sun4i-ts.c b/drivers/input/touchscreen/sun4i-ts.c +index d2e14d9e5975..ab44eb0352d0 100644 +--- a/drivers/input/touchscreen/sun4i-ts.c ++++ b/drivers/input/touchscreen/sun4i-ts.c +@@ -246,6 +246,7 @@ static int sun4i_ts_probe(struct platform_device *pdev) + struct device *dev = &pdev->dev; + struct device_node *np = dev->of_node; + struct device *hwmon; ++ struct thermal_zone_device *thermal; + int error; + u32 reg; + bool ts_attached; +@@ -365,7 +366,10 @@ static int sun4i_ts_probe(struct platform_device *pdev) + if (IS_ERR(hwmon)) + return PTR_ERR(hwmon); + +- devm_thermal_zone_of_sensor_register(ts->dev, 0, ts, &sun4i_ts_tz_ops); ++ thermal = devm_thermal_zone_of_sensor_register(ts->dev, 0, ts, ++ &sun4i_ts_tz_ops); ++ if (IS_ERR(thermal)) ++ return PTR_ERR(thermal); + + writel(TEMP_IRQ_EN(1), ts->base + TP_INT_FIFOC); + +diff --git a/drivers/input/touchscreen/sur40.c b/drivers/input/touchscreen/sur40.c +index f16f8358c70a..98e03d0ca03c 100644 +--- a/drivers/input/touchscreen/sur40.c ++++ b/drivers/input/touchscreen/sur40.c +@@ -537,7 +537,7 @@ static int sur40_probe(struct usb_interface *interface, + int error; + + /* Check if we really have the right interface. */ +- iface_desc = &interface->altsetting[0]; ++ iface_desc = interface->cur_altsetting; + if (iface_desc->desc.bInterfaceClass != 0xFF) + return -ENODEV; + +diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c +index 0cabf31fb163..7eb76a1a2505 100644 +--- a/drivers/md/bitmap.c ++++ b/drivers/md/bitmap.c +@@ -1729,7 +1729,7 @@ void bitmap_flush(struct mddev *mddev) + /* + * free memory that was allocated + */ +-void bitmap_free(struct bitmap *bitmap) ++void md_bitmap_free(struct bitmap *bitmap) + { + unsigned long k, pages; + struct bitmap_page *bp; +@@ -1763,7 +1763,7 @@ void bitmap_free(struct bitmap *bitmap) + kfree(bp); + kfree(bitmap); + } +-EXPORT_SYMBOL(bitmap_free); ++EXPORT_SYMBOL(md_bitmap_free); + + void bitmap_wait_behind_writes(struct mddev *mddev) + { +@@ -1796,7 +1796,7 @@ void bitmap_destroy(struct mddev *mddev) + if (mddev->thread) + mddev->thread->timeout = MAX_SCHEDULE_TIMEOUT; + +- bitmap_free(bitmap); ++ md_bitmap_free(bitmap); + } + + /* +@@ -1887,7 +1887,7 @@ struct bitmap *bitmap_create(struct mddev *mddev, int slot) + + return bitmap; + error: +- bitmap_free(bitmap); ++ md_bitmap_free(bitmap); + return ERR_PTR(err); + } + +@@ -1958,7 +1958,7 @@ struct bitmap *get_bitmap_from_slot(struct mddev *mddev, int slot) + + rv = bitmap_init_from_disk(bitmap, 0); + if (rv) { +- bitmap_free(bitmap); ++ md_bitmap_free(bitmap); + return ERR_PTR(rv); + } + +diff --git a/drivers/md/bitmap.h b/drivers/md/bitmap.h +index 5df35ca90f58..dd53a978c5f2 100644 +--- a/drivers/md/bitmap.h ++++ b/drivers/md/bitmap.h +@@ -271,7 +271,7 @@ int bitmap_resize(struct bitmap *bitmap, sector_t blocks, + struct bitmap *get_bitmap_from_slot(struct mddev *mddev, int slot); + int bitmap_copy_from_slot(struct mddev *mddev, int slot, + sector_t *lo, sector_t *hi, bool clear_bits); +-void bitmap_free(struct bitmap *bitmap); ++void md_bitmap_free(struct bitmap *bitmap); + void bitmap_wait_behind_writes(struct mddev *mddev); + #endif + +diff --git a/drivers/md/md-cluster.c b/drivers/md/md-cluster.c +index 717aaffc227d..10057ac85476 100644 +--- a/drivers/md/md-cluster.c ++++ b/drivers/md/md-cluster.c +@@ -1128,7 +1128,7 @@ int cluster_check_sync_size(struct mddev *mddev) + bm_lockres = lockres_init(mddev, str, NULL, 1); + if (!bm_lockres) { + pr_err("md-cluster: Cannot initialize %s\n", str); +- bitmap_free(bitmap); ++ md_bitmap_free(bitmap); + return -1; + } + bm_lockres->flags |= DLM_LKF_NOQUEUE; +@@ -1142,11 +1142,11 @@ int cluster_check_sync_size(struct mddev *mddev) + sync_size = sb->sync_size; + else if (sync_size != sb->sync_size) { + kunmap_atomic(sb); +- bitmap_free(bitmap); ++ md_bitmap_free(bitmap); + return -1; + } + kunmap_atomic(sb); +- bitmap_free(bitmap); ++ md_bitmap_free(bitmap); + } + + return (my_sync_size == sync_size) ? 0 : -1; +diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c +index 7cafc8a57950..8eb52139684a 100644 +--- a/drivers/media/v4l2-core/v4l2-ioctl.c ++++ b/drivers/media/v4l2-core/v4l2-ioctl.c +@@ -1496,12 +1496,12 @@ static int v4l_s_fmt(const struct v4l2_ioctl_ops *ops, + case V4L2_BUF_TYPE_VBI_CAPTURE: + if (unlikely(!ops->vidioc_s_fmt_vbi_cap)) + break; +- CLEAR_AFTER_FIELD(p, fmt.vbi); ++ CLEAR_AFTER_FIELD(p, fmt.vbi.flags); + return ops->vidioc_s_fmt_vbi_cap(file, fh, arg); + case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE: + if (unlikely(!ops->vidioc_s_fmt_sliced_vbi_cap)) + break; +- CLEAR_AFTER_FIELD(p, fmt.sliced); ++ CLEAR_AFTER_FIELD(p, fmt.sliced.io_size); + return ops->vidioc_s_fmt_sliced_vbi_cap(file, fh, arg); + case V4L2_BUF_TYPE_VIDEO_OUTPUT: + if (unlikely(!ops->vidioc_s_fmt_vid_out)) +@@ -1524,22 +1524,22 @@ static int v4l_s_fmt(const struct v4l2_ioctl_ops *ops, + case V4L2_BUF_TYPE_VBI_OUTPUT: + if (unlikely(!ops->vidioc_s_fmt_vbi_out)) + break; +- CLEAR_AFTER_FIELD(p, fmt.vbi); ++ CLEAR_AFTER_FIELD(p, fmt.vbi.flags); + return ops->vidioc_s_fmt_vbi_out(file, fh, arg); + case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT: + if (unlikely(!ops->vidioc_s_fmt_sliced_vbi_out)) + break; +- CLEAR_AFTER_FIELD(p, fmt.sliced); ++ CLEAR_AFTER_FIELD(p, fmt.sliced.io_size); + return ops->vidioc_s_fmt_sliced_vbi_out(file, fh, arg); + case V4L2_BUF_TYPE_SDR_CAPTURE: + if (unlikely(!ops->vidioc_s_fmt_sdr_cap)) + break; +- CLEAR_AFTER_FIELD(p, fmt.sdr); ++ CLEAR_AFTER_FIELD(p, fmt.sdr.buffersize); + return ops->vidioc_s_fmt_sdr_cap(file, fh, arg); + case V4L2_BUF_TYPE_SDR_OUTPUT: + if (unlikely(!ops->vidioc_s_fmt_sdr_out)) + break; +- CLEAR_AFTER_FIELD(p, fmt.sdr); ++ CLEAR_AFTER_FIELD(p, fmt.sdr.buffersize); + return ops->vidioc_s_fmt_sdr_out(file, fh, arg); + case V4L2_BUF_TYPE_META_CAPTURE: + if (unlikely(!ops->vidioc_s_fmt_meta_cap)) +@@ -1583,12 +1583,12 @@ static int v4l_try_fmt(const struct v4l2_ioctl_ops *ops, + case V4L2_BUF_TYPE_VBI_CAPTURE: + if (unlikely(!ops->vidioc_try_fmt_vbi_cap)) + break; +- CLEAR_AFTER_FIELD(p, fmt.vbi); ++ CLEAR_AFTER_FIELD(p, fmt.vbi.flags); + return ops->vidioc_try_fmt_vbi_cap(file, fh, arg); + case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE: + if (unlikely(!ops->vidioc_try_fmt_sliced_vbi_cap)) + break; +- CLEAR_AFTER_FIELD(p, fmt.sliced); ++ CLEAR_AFTER_FIELD(p, fmt.sliced.io_size); + return ops->vidioc_try_fmt_sliced_vbi_cap(file, fh, arg); + case V4L2_BUF_TYPE_VIDEO_OUTPUT: + if (unlikely(!ops->vidioc_try_fmt_vid_out)) +@@ -1611,22 +1611,22 @@ static int v4l_try_fmt(const struct v4l2_ioctl_ops *ops, + case V4L2_BUF_TYPE_VBI_OUTPUT: + if (unlikely(!ops->vidioc_try_fmt_vbi_out)) + break; +- CLEAR_AFTER_FIELD(p, fmt.vbi); ++ CLEAR_AFTER_FIELD(p, fmt.vbi.flags); + return ops->vidioc_try_fmt_vbi_out(file, fh, arg); + case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT: + if (unlikely(!ops->vidioc_try_fmt_sliced_vbi_out)) + break; +- CLEAR_AFTER_FIELD(p, fmt.sliced); ++ CLEAR_AFTER_FIELD(p, fmt.sliced.io_size); + return ops->vidioc_try_fmt_sliced_vbi_out(file, fh, arg); + case V4L2_BUF_TYPE_SDR_CAPTURE: + if (unlikely(!ops->vidioc_try_fmt_sdr_cap)) + break; +- CLEAR_AFTER_FIELD(p, fmt.sdr); ++ CLEAR_AFTER_FIELD(p, fmt.sdr.buffersize); + return ops->vidioc_try_fmt_sdr_cap(file, fh, arg); + case V4L2_BUF_TYPE_SDR_OUTPUT: + if (unlikely(!ops->vidioc_try_fmt_sdr_out)) + break; +- CLEAR_AFTER_FIELD(p, fmt.sdr); ++ CLEAR_AFTER_FIELD(p, fmt.sdr.buffersize); + return ops->vidioc_try_fmt_sdr_out(file, fh, arg); + case V4L2_BUF_TYPE_META_CAPTURE: + if (unlikely(!ops->vidioc_try_fmt_meta_cap)) +diff --git a/drivers/mmc/host/sdhci-tegra.c b/drivers/mmc/host/sdhci-tegra.c +index ce3f344d2b66..d2b0a62bfce1 100644 +--- a/drivers/mmc/host/sdhci-tegra.c ++++ b/drivers/mmc/host/sdhci-tegra.c +@@ -177,7 +177,7 @@ static void tegra_sdhci_reset(struct sdhci_host *host, u8 mask) + misc_ctrl |= SDHCI_MISC_CTRL_ENABLE_DDR50; + if (soc_data->nvquirks & NVQUIRK_ENABLE_SDR104) + misc_ctrl |= SDHCI_MISC_CTRL_ENABLE_SDR104; +- if (soc_data->nvquirks & SDHCI_MISC_CTRL_ENABLE_SDR50) ++ if (soc_data->nvquirks & NVQUIRK_ENABLE_SDR50) + clk_ctrl |= SDHCI_CLOCK_CTRL_SDR50_TUNING_OVERRIDE; + } + +diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c +index 645775dd4edb..4f1c884c0b50 100644 +--- a/drivers/mmc/host/sdhci.c ++++ b/drivers/mmc/host/sdhci.c +@@ -3592,11 +3592,13 @@ int sdhci_setup_host(struct sdhci_host *host) + if (host->ops->get_min_clock) + mmc->f_min = host->ops->get_min_clock(host); + else if (host->version >= SDHCI_SPEC_300) { +- if (host->clk_mul) { +- mmc->f_min = (host->max_clk * host->clk_mul) / 1024; ++ if (host->clk_mul) + max_clk = host->max_clk * host->clk_mul; +- } else +- mmc->f_min = host->max_clk / SDHCI_MAX_DIV_SPEC_300; ++ /* ++ * Divided Clock Mode minimum clock rate is always less than ++ * Programmable Clock Mode minimum clock rate. ++ */ ++ mmc->f_min = host->max_clk / SDHCI_MAX_DIV_SPEC_300; + } else + mmc->f_min = host->max_clk / SDHCI_MAX_DIV_SPEC_200; + +diff --git a/drivers/net/can/slcan.c b/drivers/net/can/slcan.c +index a42737b4ac79..35564a9561b7 100644 +--- a/drivers/net/can/slcan.c ++++ b/drivers/net/can/slcan.c +@@ -343,9 +343,16 @@ static void slcan_transmit(struct work_struct *work) + */ + static void slcan_write_wakeup(struct tty_struct *tty) + { +- struct slcan *sl = tty->disc_data; ++ struct slcan *sl; ++ ++ rcu_read_lock(); ++ sl = rcu_dereference(tty->disc_data); ++ if (!sl) ++ goto out; + + schedule_work(&sl->tx_work); ++out: ++ rcu_read_unlock(); + } + + /* Send a can_frame to a TTY queue. */ +@@ -640,10 +647,11 @@ static void slcan_close(struct tty_struct *tty) + return; + + spin_lock_bh(&sl->lock); +- tty->disc_data = NULL; ++ rcu_assign_pointer(tty->disc_data, NULL); + sl->tty = NULL; + spin_unlock_bh(&sl->lock); + ++ synchronize_rcu(); + flush_work(&sl->tx_work); + + /* Flush network side */ +diff --git a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c +index 338683e5ef1e..b8779afb8550 100644 +--- a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c ++++ b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c +@@ -2449,6 +2449,8 @@ static int cxgb_extension_ioctl(struct net_device *dev, void __user *useraddr) + + if (!is_offload(adapter)) + return -EOPNOTSUPP; ++ if (!capable(CAP_NET_ADMIN)) ++ return -EPERM; + if (!(adapter->flags & FULL_INIT_DONE)) + return -EIO; /* need the memory controllers */ + if (copy_from_user(&t, useraddr, sizeof(t))) +diff --git a/drivers/net/gtp.c b/drivers/net/gtp.c +index 25be27826a22..3840f21dd635 100644 +--- a/drivers/net/gtp.c ++++ b/drivers/net/gtp.c +@@ -807,19 +807,21 @@ static struct sock *gtp_encap_enable_socket(int fd, int type, + return NULL; + } + +- if (sock->sk->sk_protocol != IPPROTO_UDP) { ++ sk = sock->sk; ++ if (sk->sk_protocol != IPPROTO_UDP || ++ sk->sk_type != SOCK_DGRAM || ++ (sk->sk_family != AF_INET && sk->sk_family != AF_INET6)) { + pr_debug("socket fd=%d not UDP\n", fd); + sk = ERR_PTR(-EINVAL); + goto out_sock; + } + +- lock_sock(sock->sk); +- if (sock->sk->sk_user_data) { ++ lock_sock(sk); ++ if (sk->sk_user_data) { + sk = ERR_PTR(-EBUSY); + goto out_rel_sock; + } + +- sk = sock->sk; + sock_hold(sk); + + tuncfg.sk_user_data = gtp; +diff --git a/drivers/net/slip/slip.c b/drivers/net/slip/slip.c +index d6dc00b4ba55..b07f367abd91 100644 +--- a/drivers/net/slip/slip.c ++++ b/drivers/net/slip/slip.c +@@ -452,9 +452,16 @@ static void slip_transmit(struct work_struct *work) + */ + static void slip_write_wakeup(struct tty_struct *tty) + { +- struct slip *sl = tty->disc_data; ++ struct slip *sl; ++ ++ rcu_read_lock(); ++ sl = rcu_dereference(tty->disc_data); ++ if (!sl) ++ goto out; + + schedule_work(&sl->tx_work); ++out: ++ rcu_read_unlock(); + } + + static void sl_tx_timeout(struct net_device *dev) +@@ -886,10 +893,11 @@ static void slip_close(struct tty_struct *tty) + return; + + spin_lock_bh(&sl->lock); +- tty->disc_data = NULL; ++ rcu_assign_pointer(tty->disc_data, NULL); + sl->tty = NULL; + spin_unlock_bh(&sl->lock); + ++ synchronize_rcu(); + flush_work(&sl->tx_work); + + /* VSV = very important to remove timers */ +diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c +index ee7194a9e231..b179a96ea08c 100644 +--- a/drivers/net/usb/lan78xx.c ++++ b/drivers/net/usb/lan78xx.c +@@ -31,6 +31,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -3525,6 +3526,19 @@ static void lan78xx_tx_timeout(struct net_device *net) + tasklet_schedule(&dev->bh); + } + ++static netdev_features_t lan78xx_features_check(struct sk_buff *skb, ++ struct net_device *netdev, ++ netdev_features_t features) ++{ ++ if (skb->len + TX_OVERHEAD > MAX_SINGLE_PACKET_SIZE) ++ features &= ~NETIF_F_GSO_MASK; ++ ++ features = vlan_features_check(skb, features); ++ features = vxlan_features_check(skb, features); ++ ++ return features; ++} ++ + static const struct net_device_ops lan78xx_netdev_ops = { + .ndo_open = lan78xx_open, + .ndo_stop = lan78xx_stop, +@@ -3538,6 +3552,7 @@ static const struct net_device_ops lan78xx_netdev_ops = { + .ndo_set_features = lan78xx_set_features, + .ndo_vlan_rx_add_vid = lan78xx_vlan_rx_add_vid, + .ndo_vlan_rx_kill_vid = lan78xx_vlan_rx_kill_vid, ++ .ndo_features_check = lan78xx_features_check, + }; + + static void lan78xx_stat_monitor(unsigned long param) +diff --git a/drivers/net/wireless/marvell/libertas/cfg.c b/drivers/net/wireless/marvell/libertas/cfg.c +index 9f3a7b512673..4ffc188d2ffd 100644 +--- a/drivers/net/wireless/marvell/libertas/cfg.c ++++ b/drivers/net/wireless/marvell/libertas/cfg.c +@@ -273,6 +273,10 @@ add_ie_rates(u8 *tlv, const u8 *ie, int *nrates) + int hw, ap, ap_max = ie[1]; + u8 hw_rate; + ++ if (ap_max > MAX_RATES) { ++ lbs_deb_assoc("invalid rates\n"); ++ return tlv; ++ } + /* Advance past IE header */ + ie += 2; + +@@ -1720,6 +1724,9 @@ static int lbs_ibss_join_existing(struct lbs_private *priv, + struct cmd_ds_802_11_ad_hoc_join cmd; + u8 preamble = RADIO_PREAMBLE_SHORT; + int ret = 0; ++ int hw, i; ++ u8 rates_max; ++ u8 *rates; + + /* TODO: set preamble based on scan result */ + ret = lbs_set_radio(priv, preamble, 1); +@@ -1778,9 +1785,12 @@ static int lbs_ibss_join_existing(struct lbs_private *priv, + if (!rates_eid) { + lbs_add_rates(cmd.bss.rates); + } else { +- int hw, i; +- u8 rates_max = rates_eid[1]; +- u8 *rates = cmd.bss.rates; ++ rates_max = rates_eid[1]; ++ if (rates_max > MAX_RATES) { ++ lbs_deb_join("invalid rates"); ++ goto out; ++ } ++ rates = cmd.bss.rates; + for (hw = 0; hw < ARRAY_SIZE(lbs_rates); hw++) { + u8 hw_rate = lbs_rates[hw].bitrate / 5; + for (i = 0; i < rates_max; i++) { +diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c +index b4d06bd9ed51..95d71e301a53 100644 +--- a/drivers/scsi/scsi_transport_iscsi.c ++++ b/drivers/scsi/scsi_transport_iscsi.c +@@ -37,6 +37,8 @@ + + #define ISCSI_TRANSPORT_VERSION "2.0-870" + ++#define ISCSI_SEND_MAX_ALLOWED 10 ++ + static int dbg_session; + module_param_named(debug_session, dbg_session, int, + S_IRUGO | S_IWUSR); +@@ -3680,6 +3682,7 @@ iscsi_if_rx(struct sk_buff *skb) + struct nlmsghdr *nlh; + struct iscsi_uevent *ev; + uint32_t group; ++ int retries = ISCSI_SEND_MAX_ALLOWED; + + nlh = nlmsg_hdr(skb); + if (nlh->nlmsg_len < sizeof(*nlh) + sizeof(*ev) || +@@ -3710,6 +3713,10 @@ iscsi_if_rx(struct sk_buff *skb) + break; + err = iscsi_if_send_reply(portid, nlh->nlmsg_type, + ev, sizeof(*ev)); ++ if (err == -EAGAIN && --retries < 0) { ++ printk(KERN_WARNING "Send reply failed, error %d\n", err); ++ break; ++ } + } while (err < 0 && err != -ECONNREFUSED && err != -ESRCH); + skb_pull(skb, rlen); + } +diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c +index 2955b856e9ec..e8c2afbb82e9 100644 +--- a/drivers/scsi/sd.c ++++ b/drivers/scsi/sd.c +@@ -1981,9 +1981,13 @@ static int sd_done(struct scsi_cmnd *SCpnt) + } + break; + case REQ_OP_ZONE_REPORT: ++ /* To avoid that the block layer performs an incorrect ++ * bio_advance() call and restart of the remainder of ++ * incomplete report zone BIOs, always indicate a full ++ * completion of REQ_OP_ZONE_REPORT. ++ */ + if (!result) { +- good_bytes = scsi_bufflen(SCpnt) +- - scsi_get_resid(SCpnt); ++ good_bytes = scsi_bufflen(SCpnt); + scsi_set_resid(SCpnt, 0); + } else { + good_bytes = 0; +diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c +index 21ce92ee1652..37d64acea5e1 100644 +--- a/drivers/target/iscsi/iscsi_target.c ++++ b/drivers/target/iscsi/iscsi_target.c +@@ -4155,9 +4155,6 @@ int iscsit_close_connection( + iscsit_stop_nopin_response_timer(conn); + iscsit_stop_nopin_timer(conn); + +- if (conn->conn_transport->iscsit_wait_conn) +- conn->conn_transport->iscsit_wait_conn(conn); +- + /* + * During Connection recovery drop unacknowledged out of order + * commands for this connection, and prepare the other commands +@@ -4243,6 +4240,9 @@ int iscsit_close_connection( + target_sess_cmd_list_set_waiting(sess->se_sess); + target_wait_for_sess_cmds(sess->se_sess); + ++ if (conn->conn_transport->iscsit_wait_conn) ++ conn->conn_transport->iscsit_wait_conn(conn); ++ + ahash_request_free(conn->conn_tx_hash); + if (conn->conn_rx_hash) { + struct crypto_ahash *tfm; +diff --git a/fs/namei.c b/fs/namei.c +index d1e467b7b9de..d648d6d2b635 100644 +--- a/fs/namei.c ++++ b/fs/namei.c +@@ -1023,7 +1023,8 @@ static int may_linkat(struct path *link) + * may_create_in_sticky - Check whether an O_CREAT open in a sticky directory + * should be allowed, or not, on files that already + * exist. +- * @dir: the sticky parent directory ++ * @dir_mode: mode bits of directory ++ * @dir_uid: owner of directory + * @inode: the inode of the file to open + * + * Block an O_CREAT open of a FIFO (or a regular file) when: +@@ -1039,18 +1040,18 @@ static int may_linkat(struct path *link) + * + * Returns 0 if the open is allowed, -ve on error. + */ +-static int may_create_in_sticky(struct dentry * const dir, ++static int may_create_in_sticky(umode_t dir_mode, kuid_t dir_uid, + struct inode * const inode) + { + if ((!sysctl_protected_fifos && S_ISFIFO(inode->i_mode)) || + (!sysctl_protected_regular && S_ISREG(inode->i_mode)) || +- likely(!(dir->d_inode->i_mode & S_ISVTX)) || +- uid_eq(inode->i_uid, dir->d_inode->i_uid) || ++ likely(!(dir_mode & S_ISVTX)) || ++ uid_eq(inode->i_uid, dir_uid) || + uid_eq(current_fsuid(), inode->i_uid)) + return 0; + +- if (likely(dir->d_inode->i_mode & 0002) || +- (dir->d_inode->i_mode & 0020 && ++ if (likely(dir_mode & 0002) || ++ (dir_mode & 0020 && + ((sysctl_protected_fifos >= 2 && S_ISFIFO(inode->i_mode)) || + (sysctl_protected_regular >= 2 && S_ISREG(inode->i_mode))))) { + return -EACCES; +@@ -3265,6 +3266,8 @@ static int do_last(struct nameidata *nd, + int *opened) + { + struct dentry *dir = nd->path.dentry; ++ kuid_t dir_uid = dir->d_inode->i_uid; ++ umode_t dir_mode = dir->d_inode->i_mode; + int open_flag = op->open_flag; + bool will_truncate = (open_flag & O_TRUNC) != 0; + bool got_write = false; +@@ -3400,7 +3403,7 @@ finish_open: + error = -EISDIR; + if (d_is_dir(nd->path.dentry)) + goto out; +- error = may_create_in_sticky(dir, ++ error = may_create_in_sticky(dir_mode, dir_uid, + d_backing_inode(nd->path.dentry)); + if (unlikely(error)) + goto out; +diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h +index aec255fb62aa..10a4dd02221d 100644 +--- a/include/linux/bitmap.h ++++ b/include/linux/bitmap.h +@@ -86,6 +86,14 @@ + * contain all bit positions from 0 to 'bits' - 1. + */ + ++/* ++ * Allocation and deallocation of bitmap. ++ * Provided in lib/bitmap.c to avoid circular dependency. ++ */ ++extern unsigned long *bitmap_alloc(unsigned int nbits, gfp_t flags); ++extern unsigned long *bitmap_zalloc(unsigned int nbits, gfp_t flags); ++extern void bitmap_free(const unsigned long *bitmap); ++ + /* + * lib/bitmap.c provides these functions: + */ +diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h +index 8818291815bc..31fc54757bf2 100644 +--- a/include/linux/netdevice.h ++++ b/include/linux/netdevice.h +@@ -3313,6 +3313,7 @@ int dev_set_alias(struct net_device *, const char *, size_t); + int dev_change_net_namespace(struct net_device *, struct net *, const char *); + int __dev_set_mtu(struct net_device *, int); + int dev_set_mtu(struct net_device *, int); ++int dev_validate_mtu(struct net_device *dev, int mtu); + void dev_set_group(struct net_device *, int); + int dev_set_mac_address(struct net_device *, struct sockaddr *); + int dev_change_carrier(struct net_device *, bool new_carrier); +diff --git a/include/linux/netfilter/ipset/ip_set.h b/include/linux/netfilter/ipset/ip_set.h +index 91a533bd3eb1..b7246b7e0bf4 100644 +--- a/include/linux/netfilter/ipset/ip_set.h ++++ b/include/linux/netfilter/ipset/ip_set.h +@@ -445,13 +445,6 @@ ip6addrptr(const struct sk_buff *skb, bool src, struct in6_addr *addr) + sizeof(*addr)); + } + +-/* Calculate the bytes required to store the inclusive range of a-b */ +-static inline int +-bitmap_bytes(u32 a, u32 b) +-{ +- return 4 * ((((b - a + 8) / 8) + 3) / 4); +-} +- + #include + #include + #include +diff --git a/include/trace/events/xen.h b/include/trace/events/xen.h +index 2ec9064a2bb7..e5150fc67e91 100644 +--- a/include/trace/events/xen.h ++++ b/include/trace/events/xen.h +@@ -66,7 +66,11 @@ TRACE_EVENT(xen_mc_callback, + TP_PROTO(xen_mc_callback_fn_t fn, void *data), + TP_ARGS(fn, data), + TP_STRUCT__entry( +- __field(xen_mc_callback_fn_t, fn) ++ /* ++ * Use field_struct to avoid is_signed_type() ++ * comparison of a function pointer. ++ */ ++ __field_struct(xen_mc_callback_fn_t, fn) + __field(void *, data) + ), + TP_fast_assign( +diff --git a/lib/bitmap.c b/lib/bitmap.c +index 2a9373ef4054..fbe38a83acb3 100644 +--- a/lib/bitmap.c ++++ b/lib/bitmap.c +@@ -13,6 +13,7 @@ + #include + #include + #include ++#include + #include + #include + +@@ -1212,3 +1213,22 @@ void bitmap_copy_le(unsigned long *dst, const unsigned long *src, unsigned int n + } + EXPORT_SYMBOL(bitmap_copy_le); + #endif ++ ++unsigned long *bitmap_alloc(unsigned int nbits, gfp_t flags) ++{ ++ return kmalloc_array(BITS_TO_LONGS(nbits), sizeof(unsigned long), ++ flags); ++} ++EXPORT_SYMBOL(bitmap_alloc); ++ ++unsigned long *bitmap_zalloc(unsigned int nbits, gfp_t flags) ++{ ++ return bitmap_alloc(nbits, flags | __GFP_ZERO); ++} ++EXPORT_SYMBOL(bitmap_zalloc); ++ ++void bitmap_free(const unsigned long *bitmap) ++{ ++ kfree(bitmap); ++} ++EXPORT_SYMBOL(bitmap_free); +diff --git a/net/core/dev.c b/net/core/dev.c +index f9f05b3df460..36d926d2d5f0 100644 +--- a/net/core/dev.c ++++ b/net/core/dev.c +@@ -6896,18 +6896,9 @@ int dev_set_mtu(struct net_device *dev, int new_mtu) + if (new_mtu == dev->mtu) + return 0; + +- /* MTU must be positive, and in range */ +- if (new_mtu < 0 || new_mtu < dev->min_mtu) { +- net_err_ratelimited("%s: Invalid MTU %d requested, hw min %d\n", +- dev->name, new_mtu, dev->min_mtu); +- return -EINVAL; +- } +- +- if (dev->max_mtu > 0 && new_mtu > dev->max_mtu) { +- net_err_ratelimited("%s: Invalid MTU %d requested, hw max %d\n", +- dev->name, new_mtu, dev->max_mtu); +- return -EINVAL; +- } ++ err = dev_validate_mtu(dev, new_mtu); ++ if (err) ++ return err; + + if (!netif_device_present(dev)) + return -ENODEV; +@@ -7667,8 +7658,10 @@ int register_netdevice(struct net_device *dev) + goto err_uninit; + + ret = netdev_register_kobject(dev); +- if (ret) ++ if (ret) { ++ dev->reg_state = NETREG_UNREGISTERED; + goto err_uninit; ++ } + dev->reg_state = NETREG_REGISTERED; + + __netdev_update_features(dev); +@@ -7767,6 +7760,23 @@ int init_dummy_netdev(struct net_device *dev) + EXPORT_SYMBOL_GPL(init_dummy_netdev); + + ++int dev_validate_mtu(struct net_device *dev, int new_mtu) ++{ ++ /* MTU must be positive, and in range */ ++ if (new_mtu < 0 || new_mtu < dev->min_mtu) { ++ net_err_ratelimited("%s: Invalid MTU %d requested, hw min %d\n", ++ dev->name, new_mtu, dev->min_mtu); ++ return -EINVAL; ++ } ++ ++ if (dev->max_mtu > 0 && new_mtu > dev->max_mtu) { ++ net_err_ratelimited("%s: Invalid MTU %d requested, hw max %d\n", ++ dev->name, new_mtu, dev->max_mtu); ++ return -EINVAL; ++ } ++ return 0; ++} ++ + /** + * register_netdev - register a network device + * @dev: device to register +diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c +index dee57c5ff738..baf771d2d088 100644 +--- a/net/core/net-sysfs.c ++++ b/net/core/net-sysfs.c +@@ -911,25 +911,30 @@ static int rx_queue_add_kobject(struct net_device *dev, int index) + struct kobject *kobj = &queue->kobj; + int error = 0; + ++ /* Kobject_put later will trigger rx_queue_release call which ++ * decreases dev refcount: Take that reference here ++ */ ++ dev_hold(queue->dev); ++ + kobj->kset = dev->queues_kset; + error = kobject_init_and_add(kobj, &rx_queue_ktype, NULL, + "rx-%u", index); + if (error) +- return error; +- +- dev_hold(queue->dev); ++ goto err; + + if (dev->sysfs_rx_queue_group) { + error = sysfs_create_group(kobj, dev->sysfs_rx_queue_group); +- if (error) { +- kobject_put(kobj); +- return error; +- } ++ if (error) ++ goto err; + } + + kobject_uevent(kobj, KOBJ_ADD); + + return error; ++ ++err: ++ kobject_put(kobj); ++ return error; + } + #endif /* CONFIG_SYSFS */ + +@@ -1322,25 +1327,29 @@ static int netdev_queue_add_kobject(struct net_device *dev, int index) + struct kobject *kobj = &queue->kobj; + int error = 0; + ++ /* Kobject_put later will trigger netdev_queue_release call ++ * which decreases dev refcount: Take that reference here ++ */ ++ dev_hold(queue->dev); ++ + kobj->kset = dev->queues_kset; + error = kobject_init_and_add(kobj, &netdev_queue_ktype, NULL, + "tx-%u", index); + if (error) +- return error; +- +- dev_hold(queue->dev); ++ goto err; + + #ifdef CONFIG_BQL + error = sysfs_create_group(kobj, &dql_group); +- if (error) { +- kobject_put(kobj); +- return error; +- } ++ if (error) ++ goto err; + #endif + + kobject_uevent(kobj, KOBJ_ADD); +- + return 0; ++ ++err: ++ kobject_put(kobj); ++ return error; + } + #endif /* CONFIG_SYSFS */ + +diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c +index b598e9909fec..7c479c1ffd77 100644 +--- a/net/core/rtnetlink.c ++++ b/net/core/rtnetlink.c +@@ -2466,8 +2466,17 @@ struct net_device *rtnl_create_link(struct net *net, + dev->rtnl_link_ops = ops; + dev->rtnl_link_state = RTNL_LINK_INITIALIZING; + +- if (tb[IFLA_MTU]) +- dev->mtu = nla_get_u32(tb[IFLA_MTU]); ++ if (tb[IFLA_MTU]) { ++ u32 mtu = nla_get_u32(tb[IFLA_MTU]); ++ int err; ++ ++ err = dev_validate_mtu(dev, mtu); ++ if (err) { ++ free_netdev(dev); ++ return ERR_PTR(err); ++ } ++ dev->mtu = mtu; ++ } + if (tb[IFLA_ADDRESS]) { + memcpy(dev->dev_addr, nla_data(tb[IFLA_ADDRESS]), + nla_len(tb[IFLA_ADDRESS])); +diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c +index f1784162acc2..404dc765f2bf 100644 +--- a/net/ipv4/ip_tunnel.c ++++ b/net/ipv4/ip_tunnel.c +@@ -1202,10 +1202,8 @@ int ip_tunnel_init(struct net_device *dev) + iph->version = 4; + iph->ihl = 5; + +- if (tunnel->collect_md) { +- dev->features |= NETIF_F_NETNS_LOCAL; ++ if (tunnel->collect_md) + netif_keep_dst(dev); +- } + return 0; + } + EXPORT_SYMBOL_GPL(ip_tunnel_init); +diff --git a/net/ipv4/tcp_bbr.c b/net/ipv4/tcp_bbr.c +index 06f247ca9197..434ad1e72447 100644 +--- a/net/ipv4/tcp_bbr.c ++++ b/net/ipv4/tcp_bbr.c +@@ -678,8 +678,7 @@ static void bbr_update_bw(struct sock *sk, const struct rate_sample *rs) + * bandwidth sample. Delivered is in packets and interval_us in uS and + * ratio will be <<1 for most connections. So delivered is first scaled. + */ +- bw = (u64)rs->delivered * BW_UNIT; +- do_div(bw, rs->interval_us); ++ bw = div64_long((u64)rs->delivered * BW_UNIT, rs->interval_us); + + /* If this sample is application-limited, it is likely to have a very + * low delivered count that represents application behavior rather than +diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c +index 5bc2788e6ba4..c2644405bab1 100644 +--- a/net/ipv6/ip6_tunnel.c ++++ b/net/ipv6/ip6_tunnel.c +@@ -1878,10 +1878,8 @@ static int ip6_tnl_dev_init(struct net_device *dev) + if (err) + return err; + ip6_tnl_link_config(t); +- if (t->parms.collect_md) { +- dev->features |= NETIF_F_NETNS_LOCAL; ++ if (t->parms.collect_md) + netif_keep_dst(dev); +- } + return 0; + } + +diff --git a/net/ipv6/seg6_local.c b/net/ipv6/seg6_local.c +index 825b8e01f947..9a01f72d907f 100644 +--- a/net/ipv6/seg6_local.c ++++ b/net/ipv6/seg6_local.c +@@ -27,6 +27,7 @@ + #include + #include + #include ++#include + #ifdef CONFIG_IPV6_SEG6_HMAC + #include + #endif +@@ -126,7 +127,8 @@ static bool decap_and_validate(struct sk_buff *skb, int proto) + + skb_reset_network_header(skb); + skb_reset_transport_header(skb); +- skb->encapsulation = 0; ++ if (iptunnel_pull_offloads(skb)) ++ return false; + + return true; + } +diff --git a/net/netfilter/ipset/ip_set_bitmap_gen.h b/net/netfilter/ipset/ip_set_bitmap_gen.h +index b0701f6259cc..3c0e345367a5 100644 +--- a/net/netfilter/ipset/ip_set_bitmap_gen.h ++++ b/net/netfilter/ipset/ip_set_bitmap_gen.h +@@ -79,7 +79,7 @@ mtype_flush(struct ip_set *set) + + if (set->extensions & IPSET_EXT_DESTROY) + mtype_ext_cleanup(set); +- memset(map->members, 0, map->memsize); ++ bitmap_zero(map->members, map->elements); + set->elements = 0; + set->ext_size = 0; + } +diff --git a/net/netfilter/ipset/ip_set_bitmap_ip.c b/net/netfilter/ipset/ip_set_bitmap_ip.c +index 4783efff0bde..a4c104a4977f 100644 +--- a/net/netfilter/ipset/ip_set_bitmap_ip.c ++++ b/net/netfilter/ipset/ip_set_bitmap_ip.c +@@ -40,7 +40,7 @@ MODULE_ALIAS("ip_set_bitmap:ip"); + + /* Type structure */ + struct bitmap_ip { +- void *members; /* the set members */ ++ unsigned long *members; /* the set members */ + u32 first_ip; /* host byte order, included in range */ + u32 last_ip; /* host byte order, included in range */ + u32 elements; /* number of max elements in the set */ +@@ -222,7 +222,7 @@ init_map_ip(struct ip_set *set, struct bitmap_ip *map, + u32 first_ip, u32 last_ip, + u32 elements, u32 hosts, u8 netmask) + { +- map->members = ip_set_alloc(map->memsize); ++ map->members = bitmap_zalloc(elements, GFP_KERNEL | __GFP_NOWARN); + if (!map->members) + return false; + map->first_ip = first_ip; +@@ -315,7 +315,7 @@ bitmap_ip_create(struct net *net, struct ip_set *set, struct nlattr *tb[], + if (!map) + return -ENOMEM; + +- map->memsize = bitmap_bytes(0, elements - 1); ++ map->memsize = BITS_TO_LONGS(elements) * sizeof(unsigned long); + set->variant = &bitmap_ip; + if (!init_map_ip(set, map, first_ip, last_ip, + elements, hosts, netmask)) { +diff --git a/net/netfilter/ipset/ip_set_bitmap_ipmac.c b/net/netfilter/ipset/ip_set_bitmap_ipmac.c +index 9a065f672d3a..8e58e7e34981 100644 +--- a/net/netfilter/ipset/ip_set_bitmap_ipmac.c ++++ b/net/netfilter/ipset/ip_set_bitmap_ipmac.c +@@ -46,7 +46,7 @@ enum { + + /* Type structure */ + struct bitmap_ipmac { +- void *members; /* the set members */ ++ unsigned long *members; /* the set members */ + u32 first_ip; /* host byte order, included in range */ + u32 last_ip; /* host byte order, included in range */ + u32 elements; /* number of max elements in the set */ +@@ -299,7 +299,7 @@ static bool + init_map_ipmac(struct ip_set *set, struct bitmap_ipmac *map, + u32 first_ip, u32 last_ip, u32 elements) + { +- map->members = ip_set_alloc(map->memsize); ++ map->members = bitmap_zalloc(elements, GFP_KERNEL | __GFP_NOWARN); + if (!map->members) + return false; + map->first_ip = first_ip; +@@ -363,7 +363,7 @@ bitmap_ipmac_create(struct net *net, struct ip_set *set, struct nlattr *tb[], + if (!map) + return -ENOMEM; + +- map->memsize = bitmap_bytes(0, elements - 1); ++ map->memsize = BITS_TO_LONGS(elements) * sizeof(unsigned long); + set->variant = &bitmap_ipmac; + if (!init_map_ipmac(set, map, first_ip, last_ip, elements)) { + kfree(map); +diff --git a/net/netfilter/ipset/ip_set_bitmap_port.c b/net/netfilter/ipset/ip_set_bitmap_port.c +index 7f0c733358a4..6771b362a123 100644 +--- a/net/netfilter/ipset/ip_set_bitmap_port.c ++++ b/net/netfilter/ipset/ip_set_bitmap_port.c +@@ -34,7 +34,7 @@ MODULE_ALIAS("ip_set_bitmap:port"); + + /* Type structure */ + struct bitmap_port { +- void *members; /* the set members */ ++ unsigned long *members; /* the set members */ + u16 first_port; /* host byte order, included in range */ + u16 last_port; /* host byte order, included in range */ + u32 elements; /* number of max elements in the set */ +@@ -207,7 +207,7 @@ static bool + init_map_port(struct ip_set *set, struct bitmap_port *map, + u16 first_port, u16 last_port) + { +- map->members = ip_set_alloc(map->memsize); ++ map->members = bitmap_zalloc(map->elements, GFP_KERNEL | __GFP_NOWARN); + if (!map->members) + return false; + map->first_port = first_port; +@@ -250,7 +250,7 @@ bitmap_port_create(struct net *net, struct ip_set *set, struct nlattr *tb[], + return -ENOMEM; + + map->elements = elements; +- map->memsize = bitmap_bytes(0, map->elements); ++ map->memsize = BITS_TO_LONGS(elements) * sizeof(unsigned long); + set->variant = &bitmap_port; + if (!init_map_port(set, map, first_port, last_port)) { + kfree(map); +diff --git a/net/sched/ematch.c b/net/sched/ematch.c +index 03b677bc0700..60f2354c1789 100644 +--- a/net/sched/ematch.c ++++ b/net/sched/ematch.c +@@ -267,12 +267,12 @@ static int tcf_em_validate(struct tcf_proto *tp, + } + em->data = (unsigned long) v; + } ++ em->datalen = data_len; + } + } + + em->matchid = em_hdr->matchid; + em->flags = em_hdr->flags; +- em->datalen = data_len; + em->net = net; + + err = 0; +diff --git a/net/x25/af_x25.c b/net/x25/af_x25.c +index a156b6dc3a72..f4fa33b84cde 100644 +--- a/net/x25/af_x25.c ++++ b/net/x25/af_x25.c +@@ -764,6 +764,10 @@ static int x25_connect(struct socket *sock, struct sockaddr *uaddr, + if (sk->sk_state == TCP_ESTABLISHED) + goto out; + ++ rc = -EALREADY; /* Do nothing if call is already in progress */ ++ if (sk->sk_state == TCP_SYN_SENT) ++ goto out; ++ + sk->sk_state = TCP_CLOSE; + sock->state = SS_UNCONNECTED; + +@@ -810,7 +814,7 @@ static int x25_connect(struct socket *sock, struct sockaddr *uaddr, + /* Now the loop */ + rc = -EINPROGRESS; + if (sk->sk_state != TCP_ESTABLISHED && (flags & O_NONBLOCK)) +- goto out_put_neigh; ++ goto out; + + rc = x25_wait_for_connection_establishment(sk); + if (rc) +diff --git a/scripts/recordmcount.c b/scripts/recordmcount.c +index 16e086dcc567..a4888e955466 100644 +--- a/scripts/recordmcount.c ++++ b/scripts/recordmcount.c +@@ -53,6 +53,10 @@ + #define R_AARCH64_ABS64 257 + #endif + ++#define R_ARM_PC24 1 ++#define R_ARM_THM_CALL 10 ++#define R_ARM_CALL 28 ++ + static int fd_map; /* File descriptor for file being modified. */ + static int mmap_failed; /* Boolean flag. */ + static char gpfx; /* prefix for global symbol name (sometimes '_') */ +@@ -428,6 +432,18 @@ is_mcounted_section_name(char const *const txtname) + #define RECORD_MCOUNT_64 + #include "recordmcount.h" + ++static int arm_is_fake_mcount(Elf32_Rel const *rp) ++{ ++ switch (ELF32_R_TYPE(w(rp->r_info))) { ++ case R_ARM_THM_CALL: ++ case R_ARM_CALL: ++ case R_ARM_PC24: ++ return 0; ++ } ++ ++ return 1; ++} ++ + /* 64-bit EM_MIPS has weird ELF64_Rela.r_info. + * http://techpubs.sgi.com/library/manuals/4000/007-4658-001/pdf/007-4658-001.pdf + * We interpret Table 29 Relocation Operation (Elf64_Rel, Elf64_Rela) [p.40] +@@ -529,6 +545,7 @@ do_file(char const *const fname) + altmcount = "__gnu_mcount_nc"; + make_nop = make_nop_arm; + rel_type_nop = R_ARM_NONE; ++ is_fake_mcount32 = arm_is_fake_mcount; + break; + case EM_AARCH64: + reltype = R_AARCH64_ABS64; diff --git a/patch/kernel/odroidxu4-legacy/patch-4.14.169-170.patch b/patch/kernel/odroidxu4-legacy/patch-4.14.169-170.patch new file mode 100644 index 0000000000..5f3c3d21e5 --- /dev/null +++ b/patch/kernel/odroidxu4-legacy/patch-4.14.169-170.patch @@ -0,0 +1,3128 @@ +diff --git a/Documentation/ABI/testing/sysfs-class-devfreq b/Documentation/ABI/testing/sysfs-class-devfreq +index ee39acacf6f8..335595a79866 100644 +--- a/Documentation/ABI/testing/sysfs-class-devfreq ++++ b/Documentation/ABI/testing/sysfs-class-devfreq +@@ -7,6 +7,13 @@ Description: + The name of devfreq object denoted as ... is same as the + name of device using devfreq. + ++What: /sys/class/devfreq/.../name ++Date: November 2019 ++Contact: Chanwoo Choi ++Description: ++ The /sys/class/devfreq/.../name shows the name of device ++ of the corresponding devfreq object. ++ + What: /sys/class/devfreq/.../governor + Date: September 2011 + Contact: MyungJoo Ham +diff --git a/Makefile b/Makefile +index 795d93bfe156..b614291199f8 100644 +--- a/Makefile ++++ b/Makefile +@@ -1,7 +1,7 @@ + # SPDX-License-Identifier: GPL-2.0 + VERSION = 4 + PATCHLEVEL = 14 +-SUBLEVEL = 169 ++SUBLEVEL = 170 + EXTRAVERSION = + NAME = Petit Gorille + +diff --git a/arch/arc/plat-eznps/Kconfig b/arch/arc/plat-eznps/Kconfig +index 8eff057efcae..ce908e2c5282 100644 +--- a/arch/arc/plat-eznps/Kconfig ++++ b/arch/arc/plat-eznps/Kconfig +@@ -7,7 +7,7 @@ + menuconfig ARC_PLAT_EZNPS + bool "\"EZchip\" ARC dev platform" + select CPU_BIG_ENDIAN +- select CLKSRC_NPS ++ select CLKSRC_NPS if !PHYS_ADDR_T_64BIT + select EZNPS_GIC + select EZCHIP_NPS_MANAGEMENT_ENET if ETHERNET + help +diff --git a/arch/arm/boot/dts/am335x-boneblack-common.dtsi b/arch/arm/boot/dts/am335x-boneblack-common.dtsi +index 325daae40278..485c27f039f5 100644 +--- a/arch/arm/boot/dts/am335x-boneblack-common.dtsi ++++ b/arch/arm/boot/dts/am335x-boneblack-common.dtsi +@@ -131,6 +131,11 @@ + }; + + / { ++ memory@80000000 { ++ device_type = "memory"; ++ reg = <0x80000000 0x20000000>; /* 512 MB */ ++ }; ++ + clk_mcasp0_fixed: clk_mcasp0_fixed { + #clock-cells = <0>; + compatible = "fixed-clock"; +diff --git a/arch/arm/boot/dts/am57xx-beagle-x15-common.dtsi b/arch/arm/boot/dts/am57xx-beagle-x15-common.dtsi +index 49aeecd312b4..d578a9f7e1a0 100644 +--- a/arch/arm/boot/dts/am57xx-beagle-x15-common.dtsi ++++ b/arch/arm/boot/dts/am57xx-beagle-x15-common.dtsi +@@ -32,6 +32,27 @@ + reg = <0x0 0x80000000 0x0 0x80000000>; + }; + ++ main_12v0: fixedregulator-main_12v0 { ++ /* main supply */ ++ compatible = "regulator-fixed"; ++ regulator-name = "main_12v0"; ++ regulator-min-microvolt = <12000000>; ++ regulator-max-microvolt = <12000000>; ++ regulator-always-on; ++ regulator-boot-on; ++ }; ++ ++ evm_5v0: fixedregulator-evm_5v0 { ++ /* Output of TPS54531D */ ++ compatible = "regulator-fixed"; ++ regulator-name = "evm_5v0"; ++ regulator-min-microvolt = <5000000>; ++ regulator-max-microvolt = <5000000>; ++ vin-supply = <&main_12v0>; ++ regulator-always-on; ++ regulator-boot-on; ++ }; ++ + vdd_3v3: fixedregulator-vdd_3v3 { + compatible = "regulator-fixed"; + regulator-name = "vdd_3v3"; +diff --git a/arch/arm/boot/dts/sun8i-a83t-cubietruck-plus.dts b/arch/arm/boot/dts/sun8i-a83t-cubietruck-plus.dts +index 716a205c6dbb..1fed3231f5c1 100644 +--- a/arch/arm/boot/dts/sun8i-a83t-cubietruck-plus.dts ++++ b/arch/arm/boot/dts/sun8i-a83t-cubietruck-plus.dts +@@ -90,7 +90,7 @@ + initial-mode = <1>; /* initialize in HUB mode */ + disabled-ports = <1>; + intn-gpios = <&pio 7 5 GPIO_ACTIVE_HIGH>; /* PH5 */ +- reset-gpios = <&pio 4 16 GPIO_ACTIVE_HIGH>; /* PE16 */ ++ reset-gpios = <&pio 4 16 GPIO_ACTIVE_LOW>; /* PE16 */ + connect-gpios = <&pio 4 17 GPIO_ACTIVE_HIGH>; /* PE17 */ + refclk-frequency = <19200000>; + }; +diff --git a/arch/arm/kernel/hyp-stub.S b/arch/arm/kernel/hyp-stub.S +index 82a942894fc0..83e463c05dcd 100644 +--- a/arch/arm/kernel/hyp-stub.S ++++ b/arch/arm/kernel/hyp-stub.S +@@ -159,10 +159,9 @@ ARM_BE8(orr r7, r7, #(1 << 25)) @ HSCTLR.EE + #if !defined(ZIMAGE) && defined(CONFIG_ARM_ARCH_TIMER) + @ make CNTP_* and CNTPCT accessible from PL1 + mrc p15, 0, r7, c0, c1, 1 @ ID_PFR1 +- lsr r7, #16 +- and r7, #0xf +- cmp r7, #1 +- bne 1f ++ ubfx r7, r7, #16, #4 ++ teq r7, #0 ++ beq 1f + mrc p15, 4, r7, c14, c1, 0 @ CNTHCTL + orr r7, r7, #3 @ PL1PCEN | PL1PCTEN + mcr p15, 4, r7, c14, c1, 0 @ CNTHCTL +diff --git a/arch/arm64/boot/Makefile b/arch/arm64/boot/Makefile +index 1f012c506434..cd3414898d10 100644 +--- a/arch/arm64/boot/Makefile ++++ b/arch/arm64/boot/Makefile +@@ -16,7 +16,7 @@ + + OBJCOPYFLAGS_Image :=-O binary -R .note -R .note.gnu.build-id -R .comment -S + +-targets := Image Image.gz ++targets := Image Image.bz2 Image.gz Image.lz4 Image.lzma Image.lzo + + $(obj)/Image: vmlinux FORCE + $(call if_changed,objcopy) +diff --git a/arch/powerpc/boot/dts/fsl/qoriq-fman3-0-10g-0-best-effort.dtsi b/arch/powerpc/boot/dts/fsl/qoriq-fman3-0-10g-0-best-effort.dtsi +index e1a961f05dcd..baa0c503e741 100644 +--- a/arch/powerpc/boot/dts/fsl/qoriq-fman3-0-10g-0-best-effort.dtsi ++++ b/arch/powerpc/boot/dts/fsl/qoriq-fman3-0-10g-0-best-effort.dtsi +@@ -63,6 +63,7 @@ fman@400000 { + #size-cells = <0>; + compatible = "fsl,fman-memac-mdio", "fsl,fman-xmdio"; + reg = <0xe1000 0x1000>; ++ fsl,erratum-a011043; /* must ignore read errors */ + + pcsphy0: ethernet-phy@0 { + reg = <0x0>; +diff --git a/arch/powerpc/boot/dts/fsl/qoriq-fman3-0-10g-0.dtsi b/arch/powerpc/boot/dts/fsl/qoriq-fman3-0-10g-0.dtsi +index c288f3c6c637..93095600e808 100644 +--- a/arch/powerpc/boot/dts/fsl/qoriq-fman3-0-10g-0.dtsi ++++ b/arch/powerpc/boot/dts/fsl/qoriq-fman3-0-10g-0.dtsi +@@ -60,6 +60,7 @@ fman@400000 { + #size-cells = <0>; + compatible = "fsl,fman-memac-mdio", "fsl,fman-xmdio"; + reg = <0xf1000 0x1000>; ++ fsl,erratum-a011043; /* must ignore read errors */ + + pcsphy6: ethernet-phy@0 { + reg = <0x0>; +diff --git a/arch/powerpc/boot/dts/fsl/qoriq-fman3-0-10g-1-best-effort.dtsi b/arch/powerpc/boot/dts/fsl/qoriq-fman3-0-10g-1-best-effort.dtsi +index 94f3e7175012..ff4bd38f0645 100644 +--- a/arch/powerpc/boot/dts/fsl/qoriq-fman3-0-10g-1-best-effort.dtsi ++++ b/arch/powerpc/boot/dts/fsl/qoriq-fman3-0-10g-1-best-effort.dtsi +@@ -63,6 +63,7 @@ fman@400000 { + #size-cells = <0>; + compatible = "fsl,fman-memac-mdio", "fsl,fman-xmdio"; + reg = <0xe3000 0x1000>; ++ fsl,erratum-a011043; /* must ignore read errors */ + + pcsphy1: ethernet-phy@0 { + reg = <0x0>; +diff --git a/arch/powerpc/boot/dts/fsl/qoriq-fman3-0-10g-1.dtsi b/arch/powerpc/boot/dts/fsl/qoriq-fman3-0-10g-1.dtsi +index 94a76982d214..1fa38ed6f59e 100644 +--- a/arch/powerpc/boot/dts/fsl/qoriq-fman3-0-10g-1.dtsi ++++ b/arch/powerpc/boot/dts/fsl/qoriq-fman3-0-10g-1.dtsi +@@ -60,6 +60,7 @@ fman@400000 { + #size-cells = <0>; + compatible = "fsl,fman-memac-mdio", "fsl,fman-xmdio"; + reg = <0xf3000 0x1000>; ++ fsl,erratum-a011043; /* must ignore read errors */ + + pcsphy7: ethernet-phy@0 { + reg = <0x0>; +diff --git a/arch/powerpc/boot/dts/fsl/qoriq-fman3-0-1g-0.dtsi b/arch/powerpc/boot/dts/fsl/qoriq-fman3-0-1g-0.dtsi +index b5ff5f71c6b8..a8cc9780c0c4 100644 +--- a/arch/powerpc/boot/dts/fsl/qoriq-fman3-0-1g-0.dtsi ++++ b/arch/powerpc/boot/dts/fsl/qoriq-fman3-0-1g-0.dtsi +@@ -59,6 +59,7 @@ fman@400000 { + #size-cells = <0>; + compatible = "fsl,fman-memac-mdio", "fsl,fman-xmdio"; + reg = <0xe1000 0x1000>; ++ fsl,erratum-a011043; /* must ignore read errors */ + + pcsphy0: ethernet-phy@0 { + reg = <0x0>; +diff --git a/arch/powerpc/boot/dts/fsl/qoriq-fman3-0-1g-1.dtsi b/arch/powerpc/boot/dts/fsl/qoriq-fman3-0-1g-1.dtsi +index ee44182c6348..8b8bd70c9382 100644 +--- a/arch/powerpc/boot/dts/fsl/qoriq-fman3-0-1g-1.dtsi ++++ b/arch/powerpc/boot/dts/fsl/qoriq-fman3-0-1g-1.dtsi +@@ -59,6 +59,7 @@ fman@400000 { + #size-cells = <0>; + compatible = "fsl,fman-memac-mdio", "fsl,fman-xmdio"; + reg = <0xe3000 0x1000>; ++ fsl,erratum-a011043; /* must ignore read errors */ + + pcsphy1: ethernet-phy@0 { + reg = <0x0>; +diff --git a/arch/powerpc/boot/dts/fsl/qoriq-fman3-0-1g-2.dtsi b/arch/powerpc/boot/dts/fsl/qoriq-fman3-0-1g-2.dtsi +index f05f0d775039..619c880b54d8 100644 +--- a/arch/powerpc/boot/dts/fsl/qoriq-fman3-0-1g-2.dtsi ++++ b/arch/powerpc/boot/dts/fsl/qoriq-fman3-0-1g-2.dtsi +@@ -59,6 +59,7 @@ fman@400000 { + #size-cells = <0>; + compatible = "fsl,fman-memac-mdio", "fsl,fman-xmdio"; + reg = <0xe5000 0x1000>; ++ fsl,erratum-a011043; /* must ignore read errors */ + + pcsphy2: ethernet-phy@0 { + reg = <0x0>; +diff --git a/arch/powerpc/boot/dts/fsl/qoriq-fman3-0-1g-3.dtsi b/arch/powerpc/boot/dts/fsl/qoriq-fman3-0-1g-3.dtsi +index a9114ec51075..d7ebb73a400d 100644 +--- a/arch/powerpc/boot/dts/fsl/qoriq-fman3-0-1g-3.dtsi ++++ b/arch/powerpc/boot/dts/fsl/qoriq-fman3-0-1g-3.dtsi +@@ -59,6 +59,7 @@ fman@400000 { + #size-cells = <0>; + compatible = "fsl,fman-memac-mdio", "fsl,fman-xmdio"; + reg = <0xe7000 0x1000>; ++ fsl,erratum-a011043; /* must ignore read errors */ + + pcsphy3: ethernet-phy@0 { + reg = <0x0>; +diff --git a/arch/powerpc/boot/dts/fsl/qoriq-fman3-0-1g-4.dtsi b/arch/powerpc/boot/dts/fsl/qoriq-fman3-0-1g-4.dtsi +index 44dd00ac7367..b151d696a069 100644 +--- a/arch/powerpc/boot/dts/fsl/qoriq-fman3-0-1g-4.dtsi ++++ b/arch/powerpc/boot/dts/fsl/qoriq-fman3-0-1g-4.dtsi +@@ -59,6 +59,7 @@ fman@400000 { + #size-cells = <0>; + compatible = "fsl,fman-memac-mdio", "fsl,fman-xmdio"; + reg = <0xe9000 0x1000>; ++ fsl,erratum-a011043; /* must ignore read errors */ + + pcsphy4: ethernet-phy@0 { + reg = <0x0>; +diff --git a/arch/powerpc/boot/dts/fsl/qoriq-fman3-0-1g-5.dtsi b/arch/powerpc/boot/dts/fsl/qoriq-fman3-0-1g-5.dtsi +index 5b1b84b58602..adc0ae0013a3 100644 +--- a/arch/powerpc/boot/dts/fsl/qoriq-fman3-0-1g-5.dtsi ++++ b/arch/powerpc/boot/dts/fsl/qoriq-fman3-0-1g-5.dtsi +@@ -59,6 +59,7 @@ fman@400000 { + #size-cells = <0>; + compatible = "fsl,fman-memac-mdio", "fsl,fman-xmdio"; + reg = <0xeb000 0x1000>; ++ fsl,erratum-a011043; /* must ignore read errors */ + + pcsphy5: ethernet-phy@0 { + reg = <0x0>; +diff --git a/arch/powerpc/boot/dts/fsl/qoriq-fman3-1-10g-0.dtsi b/arch/powerpc/boot/dts/fsl/qoriq-fman3-1-10g-0.dtsi +index 0e1daaef9e74..435047e0e250 100644 +--- a/arch/powerpc/boot/dts/fsl/qoriq-fman3-1-10g-0.dtsi ++++ b/arch/powerpc/boot/dts/fsl/qoriq-fman3-1-10g-0.dtsi +@@ -60,6 +60,7 @@ fman@500000 { + #size-cells = <0>; + compatible = "fsl,fman-memac-mdio", "fsl,fman-xmdio"; + reg = <0xf1000 0x1000>; ++ fsl,erratum-a011043; /* must ignore read errors */ + + pcsphy14: ethernet-phy@0 { + reg = <0x0>; +diff --git a/arch/powerpc/boot/dts/fsl/qoriq-fman3-1-10g-1.dtsi b/arch/powerpc/boot/dts/fsl/qoriq-fman3-1-10g-1.dtsi +index 68c5ef779266..c098657cca0a 100644 +--- a/arch/powerpc/boot/dts/fsl/qoriq-fman3-1-10g-1.dtsi ++++ b/arch/powerpc/boot/dts/fsl/qoriq-fman3-1-10g-1.dtsi +@@ -60,6 +60,7 @@ fman@500000 { + #size-cells = <0>; + compatible = "fsl,fman-memac-mdio", "fsl,fman-xmdio"; + reg = <0xf3000 0x1000>; ++ fsl,erratum-a011043; /* must ignore read errors */ + + pcsphy15: ethernet-phy@0 { + reg = <0x0>; +diff --git a/arch/powerpc/boot/dts/fsl/qoriq-fman3-1-1g-0.dtsi b/arch/powerpc/boot/dts/fsl/qoriq-fman3-1-1g-0.dtsi +index 605363cc1117..9d06824815f3 100644 +--- a/arch/powerpc/boot/dts/fsl/qoriq-fman3-1-1g-0.dtsi ++++ b/arch/powerpc/boot/dts/fsl/qoriq-fman3-1-1g-0.dtsi +@@ -59,6 +59,7 @@ fman@500000 { + #size-cells = <0>; + compatible = "fsl,fman-memac-mdio", "fsl,fman-xmdio"; + reg = <0xe1000 0x1000>; ++ fsl,erratum-a011043; /* must ignore read errors */ + + pcsphy8: ethernet-phy@0 { + reg = <0x0>; +diff --git a/arch/powerpc/boot/dts/fsl/qoriq-fman3-1-1g-1.dtsi b/arch/powerpc/boot/dts/fsl/qoriq-fman3-1-1g-1.dtsi +index 1955dfa13634..70e947730c4b 100644 +--- a/arch/powerpc/boot/dts/fsl/qoriq-fman3-1-1g-1.dtsi ++++ b/arch/powerpc/boot/dts/fsl/qoriq-fman3-1-1g-1.dtsi +@@ -59,6 +59,7 @@ fman@500000 { + #size-cells = <0>; + compatible = "fsl,fman-memac-mdio", "fsl,fman-xmdio"; + reg = <0xe3000 0x1000>; ++ fsl,erratum-a011043; /* must ignore read errors */ + + pcsphy9: ethernet-phy@0 { + reg = <0x0>; +diff --git a/arch/powerpc/boot/dts/fsl/qoriq-fman3-1-1g-2.dtsi b/arch/powerpc/boot/dts/fsl/qoriq-fman3-1-1g-2.dtsi +index 2c1476454ee0..ad96e6529595 100644 +--- a/arch/powerpc/boot/dts/fsl/qoriq-fman3-1-1g-2.dtsi ++++ b/arch/powerpc/boot/dts/fsl/qoriq-fman3-1-1g-2.dtsi +@@ -59,6 +59,7 @@ fman@500000 { + #size-cells = <0>; + compatible = "fsl,fman-memac-mdio", "fsl,fman-xmdio"; + reg = <0xe5000 0x1000>; ++ fsl,erratum-a011043; /* must ignore read errors */ + + pcsphy10: ethernet-phy@0 { + reg = <0x0>; +diff --git a/arch/powerpc/boot/dts/fsl/qoriq-fman3-1-1g-3.dtsi b/arch/powerpc/boot/dts/fsl/qoriq-fman3-1-1g-3.dtsi +index b8b541ff5fb0..034bc4b71f7a 100644 +--- a/arch/powerpc/boot/dts/fsl/qoriq-fman3-1-1g-3.dtsi ++++ b/arch/powerpc/boot/dts/fsl/qoriq-fman3-1-1g-3.dtsi +@@ -59,6 +59,7 @@ fman@500000 { + #size-cells = <0>; + compatible = "fsl,fman-memac-mdio", "fsl,fman-xmdio"; + reg = <0xe7000 0x1000>; ++ fsl,erratum-a011043; /* must ignore read errors */ + + pcsphy11: ethernet-phy@0 { + reg = <0x0>; +diff --git a/arch/powerpc/boot/dts/fsl/qoriq-fman3-1-1g-4.dtsi b/arch/powerpc/boot/dts/fsl/qoriq-fman3-1-1g-4.dtsi +index 4b2cfddd1b15..93ca23d82b39 100644 +--- a/arch/powerpc/boot/dts/fsl/qoriq-fman3-1-1g-4.dtsi ++++ b/arch/powerpc/boot/dts/fsl/qoriq-fman3-1-1g-4.dtsi +@@ -59,6 +59,7 @@ fman@500000 { + #size-cells = <0>; + compatible = "fsl,fman-memac-mdio", "fsl,fman-xmdio"; + reg = <0xe9000 0x1000>; ++ fsl,erratum-a011043; /* must ignore read errors */ + + pcsphy12: ethernet-phy@0 { + reg = <0x0>; +diff --git a/arch/powerpc/boot/dts/fsl/qoriq-fman3-1-1g-5.dtsi b/arch/powerpc/boot/dts/fsl/qoriq-fman3-1-1g-5.dtsi +index 0a52ddf7cc17..23b3117a2fd2 100644 +--- a/arch/powerpc/boot/dts/fsl/qoriq-fman3-1-1g-5.dtsi ++++ b/arch/powerpc/boot/dts/fsl/qoriq-fman3-1-1g-5.dtsi +@@ -59,6 +59,7 @@ fman@500000 { + #size-cells = <0>; + compatible = "fsl,fman-memac-mdio", "fsl,fman-xmdio"; + reg = <0xeb000 0x1000>; ++ fsl,erratum-a011043; /* must ignore read errors */ + + pcsphy13: ethernet-phy@0 { + reg = <0x0>; +diff --git a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c +index 2dae1b3c42fc..0ec30b2384c0 100644 +--- a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c ++++ b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c +@@ -1107,7 +1107,7 @@ static struct dentry *rdt_mount(struct file_system_type *fs_type, + + if (rdt_mon_capable) { + ret = mongroup_create_dir(rdtgroup_default.kn, +- NULL, "mon_groups", ++ &rdtgroup_default, "mon_groups", + &kn_mongrp); + if (ret) { + dentry = ERR_PTR(ret); +@@ -1260,7 +1260,11 @@ static void free_all_child_rdtgrp(struct rdtgroup *rdtgrp) + list_for_each_entry_safe(sentry, stmp, head, mon.crdtgrp_list) { + free_rmid(sentry->mon.rmid); + list_del(&sentry->mon.crdtgrp_list); +- kfree(sentry); ++ ++ if (atomic_read(&sentry->waitcount) != 0) ++ sentry->flags = RDT_DELETED; ++ else ++ kfree(sentry); + } + } + +@@ -1294,7 +1298,11 @@ static void rmdir_all_sub(void) + + kernfs_remove(rdtgrp->kn); + list_del(&rdtgrp->rdtgroup_list); +- kfree(rdtgrp); ++ ++ if (atomic_read(&rdtgrp->waitcount) != 0) ++ rdtgrp->flags = RDT_DELETED; ++ else ++ kfree(rdtgrp); + } + /* Notify online CPUs to update per cpu storage and PQR_ASSOC MSR */ + update_closid_rmid(cpu_online_mask, &rdtgroup_default); +@@ -1491,7 +1499,7 @@ static int mkdir_mondata_all(struct kernfs_node *parent_kn, + /* + * Create the mon_data directory first. + */ +- ret = mongroup_create_dir(parent_kn, NULL, "mon_data", &kn); ++ ret = mongroup_create_dir(parent_kn, prgrp, "mon_data", &kn); + if (ret) + return ret; + +@@ -1525,7 +1533,7 @@ static int mkdir_rdt_prepare(struct kernfs_node *parent_kn, + uint files = 0; + int ret; + +- prdtgrp = rdtgroup_kn_lock_live(prgrp_kn); ++ prdtgrp = rdtgroup_kn_lock_live(parent_kn); + if (!prdtgrp) { + ret = -ENODEV; + goto out_unlock; +@@ -1581,7 +1589,7 @@ static int mkdir_rdt_prepare(struct kernfs_node *parent_kn, + kernfs_activate(kn); + + /* +- * The caller unlocks the prgrp_kn upon success. ++ * The caller unlocks the parent_kn upon success. + */ + return 0; + +@@ -1592,7 +1600,7 @@ out_destroy: + out_free_rgrp: + kfree(rdtgrp); + out_unlock: +- rdtgroup_kn_unlock(prgrp_kn); ++ rdtgroup_kn_unlock(parent_kn); + return ret; + } + +@@ -1630,7 +1638,7 @@ static int rdtgroup_mkdir_mon(struct kernfs_node *parent_kn, + */ + list_add_tail(&rdtgrp->mon.crdtgrp_list, &prgrp->mon.crdtgrp_list); + +- rdtgroup_kn_unlock(prgrp_kn); ++ rdtgroup_kn_unlock(parent_kn); + return ret; + } + +@@ -1667,7 +1675,7 @@ static int rdtgroup_mkdir_ctrl_mon(struct kernfs_node *parent_kn, + * Create an empty mon_groups directory to hold the subset + * of tasks and cpus to monitor. + */ +- ret = mongroup_create_dir(kn, NULL, "mon_groups", NULL); ++ ret = mongroup_create_dir(kn, rdtgrp, "mon_groups", NULL); + if (ret) + goto out_id_free; + } +@@ -1680,7 +1688,7 @@ out_id_free: + out_common_fail: + mkdir_rdt_prepare_clean(rdtgrp); + out_unlock: +- rdtgroup_kn_unlock(prgrp_kn); ++ rdtgroup_kn_unlock(parent_kn); + return ret; + } + +@@ -1792,11 +1800,6 @@ static int rdtgroup_rmdir_ctrl(struct kernfs_node *kn, struct rdtgroup *rdtgrp, + closid_free(rdtgrp->closid); + free_rmid(rdtgrp->mon.rmid); + +- /* +- * Free all the child monitor group rmids. +- */ +- free_all_child_rdtgrp(rdtgrp); +- + list_del(&rdtgrp->rdtgroup_list); + + /* +@@ -1806,6 +1809,11 @@ static int rdtgroup_rmdir_ctrl(struct kernfs_node *kn, struct rdtgroup *rdtgrp, + kernfs_get(kn); + kernfs_remove(rdtgrp->kn); + ++ /* ++ * Free all the child monitor group rmids. ++ */ ++ free_all_child_rdtgrp(rdtgrp); ++ + return 0; + } + +diff --git a/crypto/af_alg.c b/crypto/af_alg.c +index 422bba808f73..0679c35adf55 100644 +--- a/crypto/af_alg.c ++++ b/crypto/af_alg.c +@@ -139,11 +139,13 @@ void af_alg_release_parent(struct sock *sk) + sk = ask->parent; + ask = alg_sk(sk); + +- lock_sock(sk); ++ local_bh_disable(); ++ bh_lock_sock(sk); + ask->nokey_refcnt -= nokey; + if (!last) + last = !--ask->refcnt; +- release_sock(sk); ++ bh_unlock_sock(sk); ++ local_bh_enable(); + + if (last) + sock_put(sk); +diff --git a/crypto/pcrypt.c b/crypto/pcrypt.c +index a5718c0a3dc4..1348541da463 100644 +--- a/crypto/pcrypt.c ++++ b/crypto/pcrypt.c +@@ -505,11 +505,12 @@ err: + + static void __exit pcrypt_exit(void) + { ++ crypto_unregister_template(&pcrypt_tmpl); ++ + pcrypt_fini_padata(&pencrypt); + pcrypt_fini_padata(&pdecrypt); + + kset_unregister(pcrypt_kset); +- crypto_unregister_template(&pcrypt_tmpl); + } + + module_init(pcrypt_init); +diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c +index ce47eb17901d..a106d15f6def 100644 +--- a/drivers/atm/eni.c ++++ b/drivers/atm/eni.c +@@ -372,7 +372,7 @@ static int do_rx_dma(struct atm_vcc *vcc,struct sk_buff *skb, + here = (eni_vcc->descr+skip) & (eni_vcc->words-1); + dma[j++] = (here << MID_DMA_COUNT_SHIFT) | (vcc->vci + << MID_DMA_VCI_SHIFT) | MID_DT_JK; +- j++; ++ dma[j++] = 0; + } + here = (eni_vcc->descr+size+skip) & (eni_vcc->words-1); + if (!eff) size += skip; +@@ -445,7 +445,7 @@ static int do_rx_dma(struct atm_vcc *vcc,struct sk_buff *skb, + if (size != eff) { + dma[j++] = (here << MID_DMA_COUNT_SHIFT) | + (vcc->vci << MID_DMA_VCI_SHIFT) | MID_DT_JK; +- j++; ++ dma[j++] = 0; + } + if (!j || j > 2*RX_DMA_BUF) { + printk(KERN_CRIT DEV_LABEL "!j or j too big!!!\n"); +diff --git a/drivers/char/ttyprintk.c b/drivers/char/ttyprintk.c +index 67549ce88cc9..774748497ace 100644 +--- a/drivers/char/ttyprintk.c ++++ b/drivers/char/ttyprintk.c +@@ -18,10 +18,11 @@ + #include + #include + #include ++#include + + struct ttyprintk_port { + struct tty_port port; +- struct mutex port_write_mutex; ++ spinlock_t spinlock; + }; + + static struct ttyprintk_port tpk_port; +@@ -100,11 +101,12 @@ static int tpk_open(struct tty_struct *tty, struct file *filp) + static void tpk_close(struct tty_struct *tty, struct file *filp) + { + struct ttyprintk_port *tpkp = tty->driver_data; ++ unsigned long flags; + +- mutex_lock(&tpkp->port_write_mutex); ++ spin_lock_irqsave(&tpkp->spinlock, flags); + /* flush tpk_printk buffer */ + tpk_printk(NULL, 0); +- mutex_unlock(&tpkp->port_write_mutex); ++ spin_unlock_irqrestore(&tpkp->spinlock, flags); + + tty_port_close(&tpkp->port, tty, filp); + } +@@ -116,13 +118,14 @@ static int tpk_write(struct tty_struct *tty, + const unsigned char *buf, int count) + { + struct ttyprintk_port *tpkp = tty->driver_data; ++ unsigned long flags; + int ret; + + + /* exclusive use of tpk_printk within this tty */ +- mutex_lock(&tpkp->port_write_mutex); ++ spin_lock_irqsave(&tpkp->spinlock, flags); + ret = tpk_printk(buf, count); +- mutex_unlock(&tpkp->port_write_mutex); ++ spin_unlock_irqrestore(&tpkp->spinlock, flags); + + return ret; + } +@@ -172,7 +175,7 @@ static int __init ttyprintk_init(void) + { + int ret = -ENOMEM; + +- mutex_init(&tpk_port.port_write_mutex); ++ spin_lock_init(&tpk_port.spinlock); + + ttyprintk_driver = tty_alloc_driver(1, + TTY_DRIVER_RESET_TERMIOS | +diff --git a/drivers/clk/mmp/clk-of-mmp2.c b/drivers/clk/mmp/clk-of-mmp2.c +index d083b860f083..10689d8cd386 100644 +--- a/drivers/clk/mmp/clk-of-mmp2.c ++++ b/drivers/clk/mmp/clk-of-mmp2.c +@@ -134,7 +134,7 @@ static DEFINE_SPINLOCK(ssp3_lock); + static const char *ssp_parent_names[] = {"vctcxo_4", "vctcxo_2", "vctcxo", "pll1_16"}; + + static DEFINE_SPINLOCK(timer_lock); +-static const char *timer_parent_names[] = {"clk32", "vctcxo_2", "vctcxo_4", "vctcxo"}; ++static const char *timer_parent_names[] = {"clk32", "vctcxo_4", "vctcxo_2", "vctcxo"}; + + static DEFINE_SPINLOCK(reset_lock); + +diff --git a/drivers/crypto/chelsio/chcr_algo.c b/drivers/crypto/chelsio/chcr_algo.c +index bb7b59fc5c08..8d39f3a07bf8 100644 +--- a/drivers/crypto/chelsio/chcr_algo.c ++++ b/drivers/crypto/chelsio/chcr_algo.c +@@ -2693,9 +2693,6 @@ static int chcr_gcm_setauthsize(struct crypto_aead *tfm, unsigned int authsize) + aeadctx->mayverify = VERIFY_SW; + break; + default: +- +- crypto_tfm_set_flags((struct crypto_tfm *) tfm, +- CRYPTO_TFM_RES_BAD_KEY_LEN); + return -EINVAL; + } + return crypto_aead_setauthsize(aeadctx->sw_cipher, authsize); +@@ -2720,8 +2717,6 @@ static int chcr_4106_4309_setauthsize(struct crypto_aead *tfm, + aeadctx->mayverify = VERIFY_HW; + break; + default: +- crypto_tfm_set_flags((struct crypto_tfm *)tfm, +- CRYPTO_TFM_RES_BAD_KEY_LEN); + return -EINVAL; + } + return crypto_aead_setauthsize(aeadctx->sw_cipher, authsize); +@@ -2762,8 +2757,6 @@ static int chcr_ccm_setauthsize(struct crypto_aead *tfm, + aeadctx->mayverify = VERIFY_HW; + break; + default: +- crypto_tfm_set_flags((struct crypto_tfm *)tfm, +- CRYPTO_TFM_RES_BAD_KEY_LEN); + return -EINVAL; + } + return crypto_aead_setauthsize(aeadctx->sw_cipher, authsize); +@@ -2790,8 +2783,7 @@ static int chcr_ccm_common_setkey(struct crypto_aead *aead, + ck_size = CHCR_KEYCTX_CIPHER_KEY_SIZE_256; + mk_size = CHCR_KEYCTX_MAC_KEY_SIZE_256; + } else { +- crypto_tfm_set_flags((struct crypto_tfm *)aead, +- CRYPTO_TFM_RES_BAD_KEY_LEN); ++ crypto_aead_set_flags(aead, CRYPTO_TFM_RES_BAD_KEY_LEN); + aeadctx->enckey_len = 0; + return -EINVAL; + } +@@ -2831,8 +2823,7 @@ static int chcr_aead_rfc4309_setkey(struct crypto_aead *aead, const u8 *key, + int error; + + if (keylen < 3) { +- crypto_tfm_set_flags((struct crypto_tfm *)aead, +- CRYPTO_TFM_RES_BAD_KEY_LEN); ++ crypto_aead_set_flags(aead, CRYPTO_TFM_RES_BAD_KEY_LEN); + aeadctx->enckey_len = 0; + return -EINVAL; + } +@@ -2883,8 +2874,7 @@ static int chcr_gcm_setkey(struct crypto_aead *aead, const u8 *key, + } else if (keylen == AES_KEYSIZE_256) { + ck_size = CHCR_KEYCTX_CIPHER_KEY_SIZE_256; + } else { +- crypto_tfm_set_flags((struct crypto_tfm *)aead, +- CRYPTO_TFM_RES_BAD_KEY_LEN); ++ crypto_aead_set_flags(aead, CRYPTO_TFM_RES_BAD_KEY_LEN); + pr_err("GCM: Invalid key length %d\n", keylen); + ret = -EINVAL; + goto out; +diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c +index ad18de955b6c..58ec3abfd321 100644 +--- a/drivers/devfreq/devfreq.c ++++ b/drivers/devfreq/devfreq.c +@@ -902,6 +902,14 @@ err_out: + } + EXPORT_SYMBOL(devfreq_remove_governor); + ++static ssize_t name_show(struct device *dev, ++ struct device_attribute *attr, char *buf) ++{ ++ struct devfreq *devfreq = to_devfreq(dev); ++ return sprintf(buf, "%s\n", dev_name(devfreq->dev.parent)); ++} ++static DEVICE_ATTR_RO(name); ++ + static ssize_t governor_show(struct device *dev, + struct device_attribute *attr, char *buf) + { +@@ -1200,6 +1208,7 @@ static ssize_t trans_stat_show(struct device *dev, + static DEVICE_ATTR_RO(trans_stat); + + static struct attribute *devfreq_attrs[] = { ++ &dev_attr_name.attr, + &dev_attr_governor.attr, + &dev_attr_available_governors.attr, + &dev_attr_cur_freq.attr, +diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig +index 2357d2f73c1a..8d2ab77c6581 100644 +--- a/drivers/gpio/Kconfig ++++ b/drivers/gpio/Kconfig +@@ -990,6 +990,7 @@ config GPIO_LP87565 + config GPIO_MAX77620 + tristate "GPIO support for PMIC MAX77620 and MAX20024" + depends on MFD_MAX77620 ++ select GPIOLIB_IRQCHIP + help + GPIO driver for MAX77620 and MAX20024 PMIC from Maxim Semiconductor. + MAX77620 PMIC has 8 pins that can be configured as GPIOs. The +diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h +index 1e2e6e58256a..9d372fa7c298 100644 +--- a/drivers/hid/hid-ids.h ++++ b/drivers/hid/hid-ids.h +@@ -1024,6 +1024,7 @@ + #define USB_DEVICE_ID_SYNAPTICS_LTS2 0x1d10 + #define USB_DEVICE_ID_SYNAPTICS_HD 0x0ac3 + #define USB_DEVICE_ID_SYNAPTICS_QUAD_HD 0x1ac3 ++#define USB_DEVICE_ID_SYNAPTICS_ACER_SWITCH5_012 0x2968 + #define USB_DEVICE_ID_SYNAPTICS_TP_V103 0x5710 + + #define USB_VENDOR_ID_TEXAS_INSTRUMENTS 0x2047 +diff --git a/drivers/hid/hid-ite.c b/drivers/hid/hid-ite.c +index 98b059d79bc8..2ce1eb0c9212 100644 +--- a/drivers/hid/hid-ite.c ++++ b/drivers/hid/hid-ite.c +@@ -43,6 +43,9 @@ static int ite_event(struct hid_device *hdev, struct hid_field *field, + static const struct hid_device_id ite_devices[] = { + { HID_USB_DEVICE(USB_VENDOR_ID_ITE, USB_DEVICE_ID_ITE8595) }, + { HID_USB_DEVICE(USB_VENDOR_ID_258A, USB_DEVICE_ID_258A_6A88) }, ++ /* ITE8595 USB kbd ctlr, with Synaptics touchpad connected to it. */ ++ { HID_USB_DEVICE(USB_VENDOR_ID_SYNAPTICS, ++ USB_DEVICE_ID_SYNAPTICS_ACER_SWITCH5_012) }, + { } + }; + MODULE_DEVICE_TABLE(hid, ite_devices); +diff --git a/drivers/media/radio/si470x/radio-si470x-i2c.c b/drivers/media/radio/si470x/radio-si470x-i2c.c +index b60fb6ed5aeb..527535614342 100644 +--- a/drivers/media/radio/si470x/radio-si470x-i2c.c ++++ b/drivers/media/radio/si470x/radio-si470x-i2c.c +@@ -453,10 +453,10 @@ static int si470x_i2c_remove(struct i2c_client *client) + + free_irq(client->irq, radio); + video_unregister_device(&radio->videodev); +- kfree(radio); + + v4l2_ctrl_handler_free(&radio->hdl); + v4l2_device_unregister(&radio->v4l2_dev); ++ kfree(radio); + return 0; + } + +diff --git a/drivers/media/usb/dvb-usb/af9005.c b/drivers/media/usb/dvb-usb/af9005.c +index c047a0bdf91f..66990a193bc5 100644 +--- a/drivers/media/usb/dvb-usb/af9005.c ++++ b/drivers/media/usb/dvb-usb/af9005.c +@@ -563,7 +563,7 @@ static int af9005_boot_packet(struct usb_device *udev, int type, u8 *reply, + u8 *buf, int size) + { + u16 checksum; +- int act_len, i, ret; ++ int act_len = 0, i, ret; + + memset(buf, 0, size); + buf[0] = (u8) (FW_BULKOUT_SIZE & 0xff); +diff --git a/drivers/media/usb/dvb-usb/digitv.c b/drivers/media/usb/dvb-usb/digitv.c +index 475a3c0cdee7..20d33f0544ed 100644 +--- a/drivers/media/usb/dvb-usb/digitv.c ++++ b/drivers/media/usb/dvb-usb/digitv.c +@@ -233,18 +233,22 @@ static struct rc_map_table rc_map_digitv_table[] = { + + static int digitv_rc_query(struct dvb_usb_device *d, u32 *event, int *state) + { +- int i; ++ int ret, i; + u8 key[5]; + u8 b[4] = { 0 }; + + *event = 0; + *state = REMOTE_NO_KEY_PRESSED; + +- digitv_ctrl_msg(d,USB_READ_REMOTE,0,NULL,0,&key[1],4); ++ ret = digitv_ctrl_msg(d, USB_READ_REMOTE, 0, NULL, 0, &key[1], 4); ++ if (ret) ++ return ret; + + /* Tell the device we've read the remote. Not sure how necessary + this is, but the Nebula SDK does it. */ +- digitv_ctrl_msg(d,USB_WRITE_REMOTE,0,b,4,NULL,0); ++ ret = digitv_ctrl_msg(d, USB_WRITE_REMOTE, 0, b, 4, NULL, 0); ++ if (ret) ++ return ret; + + /* if something is inside the buffer, simulate key press */ + if (key[1] != 0) +diff --git a/drivers/media/usb/dvb-usb/dvb-usb-urb.c b/drivers/media/usb/dvb-usb/dvb-usb-urb.c +index c1b4e94a37f8..2aabf90d8697 100644 +--- a/drivers/media/usb/dvb-usb/dvb-usb-urb.c ++++ b/drivers/media/usb/dvb-usb/dvb-usb-urb.c +@@ -12,7 +12,7 @@ + int dvb_usb_generic_rw(struct dvb_usb_device *d, u8 *wbuf, u16 wlen, u8 *rbuf, + u16 rlen, int delay_ms) + { +- int actlen,ret = -ENOMEM; ++ int actlen = 0, ret = -ENOMEM; + + if (!d || wbuf == NULL || wlen == 0) + return -EINVAL; +diff --git a/drivers/media/usb/gspca/gspca.c b/drivers/media/usb/gspca/gspca.c +index 0f141762abf1..87582be4a39d 100644 +--- a/drivers/media/usb/gspca/gspca.c ++++ b/drivers/media/usb/gspca/gspca.c +@@ -2038,7 +2038,7 @@ int gspca_dev_probe2(struct usb_interface *intf, + pr_err("couldn't kzalloc gspca struct\n"); + return -ENOMEM; + } +- gspca_dev->usb_buf = kmalloc(USB_BUF_SZ, GFP_KERNEL); ++ gspca_dev->usb_buf = kzalloc(USB_BUF_SZ, GFP_KERNEL); + if (!gspca_dev->usb_buf) { + pr_err("out of memory\n"); + ret = -ENOMEM; +diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c +index 94ad2fdd6ef0..05440b727261 100644 +--- a/drivers/net/dsa/bcm_sf2.c ++++ b/drivers/net/dsa/bcm_sf2.c +@@ -137,7 +137,7 @@ static void bcm_sf2_imp_setup(struct dsa_switch *ds, int port) + + /* Force link status for IMP port */ + reg = core_readl(priv, offset); +- reg |= (MII_SW_OR | LINK_STS); ++ reg |= (MII_SW_OR | LINK_STS | GMII_SPEED_UP_2G); + core_writel(priv, reg, offset); + + /* Enable Broadcast, Multicast, Unicast forwarding to IMP port */ +diff --git a/drivers/net/ethernet/broadcom/b44.c b/drivers/net/ethernet/broadcom/b44.c +index a1125d10c825..8b9a0ce1d29f 100644 +--- a/drivers/net/ethernet/broadcom/b44.c ++++ b/drivers/net/ethernet/broadcom/b44.c +@@ -1521,8 +1521,10 @@ static int b44_magic_pattern(u8 *macaddr, u8 *ppattern, u8 *pmask, int offset) + int ethaddr_bytes = ETH_ALEN; + + memset(ppattern + offset, 0xff, magicsync); +- for (j = 0; j < magicsync; j++) +- set_bit(len++, (unsigned long *) pmask); ++ for (j = 0; j < magicsync; j++) { ++ pmask[len >> 3] |= BIT(len & 7); ++ len++; ++ } + + for (j = 0; j < B44_MAX_PATTERNS; j++) { + if ((B44_PATTERN_SIZE - len) >= ETH_ALEN) +@@ -1534,7 +1536,8 @@ static int b44_magic_pattern(u8 *macaddr, u8 *ppattern, u8 *pmask, int offset) + for (k = 0; k< ethaddr_bytes; k++) { + ppattern[offset + magicsync + + (j * ETH_ALEN) + k] = macaddr[k]; +- set_bit(len++, (unsigned long *) pmask); ++ pmask[len >> 3] |= BIT(len & 7); ++ len++; + } + } + return len - 1; +diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c +index 38ee7692132c..7461e7b9eaae 100644 +--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c ++++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c +@@ -7402,11 +7402,23 @@ static bool bnxt_fltr_match(struct bnxt_ntuple_filter *f1, + struct flow_keys *keys1 = &f1->fkeys; + struct flow_keys *keys2 = &f2->fkeys; + +- if (keys1->addrs.v4addrs.src == keys2->addrs.v4addrs.src && +- keys1->addrs.v4addrs.dst == keys2->addrs.v4addrs.dst && +- keys1->ports.ports == keys2->ports.ports && +- keys1->basic.ip_proto == keys2->basic.ip_proto && +- keys1->basic.n_proto == keys2->basic.n_proto && ++ if (keys1->basic.n_proto != keys2->basic.n_proto || ++ keys1->basic.ip_proto != keys2->basic.ip_proto) ++ return false; ++ ++ if (keys1->basic.n_proto == htons(ETH_P_IP)) { ++ if (keys1->addrs.v4addrs.src != keys2->addrs.v4addrs.src || ++ keys1->addrs.v4addrs.dst != keys2->addrs.v4addrs.dst) ++ return false; ++ } else { ++ if (memcmp(&keys1->addrs.v6addrs.src, &keys2->addrs.v6addrs.src, ++ sizeof(keys1->addrs.v6addrs.src)) || ++ memcmp(&keys1->addrs.v6addrs.dst, &keys2->addrs.v6addrs.dst, ++ sizeof(keys1->addrs.v6addrs.dst))) ++ return false; ++ } ++ ++ if (keys1->ports.ports == keys2->ports.ports && + keys1->control.flags == keys2->control.flags && + ether_addr_equal(f1->src_mac_addr, f2->src_mac_addr) && + ether_addr_equal(f1->dst_mac_addr, f2->dst_mac_addr)) +diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c +index 9e5cd18e7358..8bd90ad15607 100644 +--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c ++++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c +@@ -66,8 +66,7 @@ static void *seq_tab_start(struct seq_file *seq, loff_t *pos) + static void *seq_tab_next(struct seq_file *seq, void *v, loff_t *pos) + { + v = seq_tab_get_idx(seq->private, *pos + 1); +- if (v) +- ++*pos; ++ ++(*pos); + return v; + } + +diff --git a/drivers/net/ethernet/chelsio/cxgb4/l2t.c b/drivers/net/ethernet/chelsio/cxgb4/l2t.c +index f7ef8871dd0b..67aa3c997417 100644 +--- a/drivers/net/ethernet/chelsio/cxgb4/l2t.c ++++ b/drivers/net/ethernet/chelsio/cxgb4/l2t.c +@@ -682,8 +682,7 @@ static void *l2t_seq_start(struct seq_file *seq, loff_t *pos) + static void *l2t_seq_next(struct seq_file *seq, void *v, loff_t *pos) + { + v = l2t_get_idx(seq, *pos); +- if (v) +- ++*pos; ++ ++(*pos); + return v; + } + +diff --git a/drivers/net/ethernet/freescale/fman/fman_memac.c b/drivers/net/ethernet/freescale/fman/fman_memac.c +index 75ce773c21a6..b33650a897f1 100644 +--- a/drivers/net/ethernet/freescale/fman/fman_memac.c ++++ b/drivers/net/ethernet/freescale/fman/fman_memac.c +@@ -110,7 +110,7 @@ do { \ + /* Interface Mode Register (IF_MODE) */ + + #define IF_MODE_MASK 0x00000003 /* 30-31 Mask on i/f mode bits */ +-#define IF_MODE_XGMII 0x00000000 /* 30-31 XGMII (10G) interface */ ++#define IF_MODE_10G 0x00000000 /* 30-31 10G interface */ + #define IF_MODE_GMII 0x00000002 /* 30-31 GMII (1G) interface */ + #define IF_MODE_RGMII 0x00000004 + #define IF_MODE_RGMII_AUTO 0x00008000 +@@ -439,7 +439,7 @@ static int init(struct memac_regs __iomem *regs, struct memac_cfg *cfg, + tmp = 0; + switch (phy_if) { + case PHY_INTERFACE_MODE_XGMII: +- tmp |= IF_MODE_XGMII; ++ tmp |= IF_MODE_10G; + break; + default: + tmp |= IF_MODE_GMII; +diff --git a/drivers/net/ethernet/freescale/xgmac_mdio.c b/drivers/net/ethernet/freescale/xgmac_mdio.c +index e03b30c60dcf..c82c85ef5fb3 100644 +--- a/drivers/net/ethernet/freescale/xgmac_mdio.c ++++ b/drivers/net/ethernet/freescale/xgmac_mdio.c +@@ -49,6 +49,7 @@ struct tgec_mdio_controller { + struct mdio_fsl_priv { + struct tgec_mdio_controller __iomem *mdio_base; + bool is_little_endian; ++ bool has_a011043; + }; + + static u32 xgmac_read32(void __iomem *regs, +@@ -226,7 +227,8 @@ static int xgmac_mdio_read(struct mii_bus *bus, int phy_id, int regnum) + return ret; + + /* Return all Fs if nothing was there */ +- if (xgmac_read32(®s->mdio_stat, endian) & MDIO_STAT_RD_ER) { ++ if ((xgmac_read32(®s->mdio_stat, endian) & MDIO_STAT_RD_ER) && ++ !priv->has_a011043) { + dev_err(&bus->dev, + "Error while reading PHY%d reg at %d.%hhu\n", + phy_id, dev_addr, regnum); +@@ -274,6 +276,9 @@ static int xgmac_mdio_probe(struct platform_device *pdev) + priv->is_little_endian = of_property_read_bool(pdev->dev.of_node, + "little-endian"); + ++ priv->has_a011043 = of_property_read_bool(pdev->dev.of_node, ++ "fsl,erratum-a011043"); ++ + ret = of_mdiobus_register(bus, np); + if (ret) { + dev_err(&pdev->dev, "cannot register MDIO bus\n"); +diff --git a/drivers/net/ethernet/intel/igb/e1000_82575.c b/drivers/net/ethernet/intel/igb/e1000_82575.c +index c37cc8bccf47..158c277ec353 100644 +--- a/drivers/net/ethernet/intel/igb/e1000_82575.c ++++ b/drivers/net/ethernet/intel/igb/e1000_82575.c +@@ -562,7 +562,7 @@ static s32 igb_set_sfp_media_type_82575(struct e1000_hw *hw) + dev_spec->module_plugged = true; + if (eth_flags->e1000_base_lx || eth_flags->e1000_base_sx) { + hw->phy.media_type = e1000_media_type_internal_serdes; +- } else if (eth_flags->e100_base_fx) { ++ } else if (eth_flags->e100_base_fx || eth_flags->e100_base_lx) { + dev_spec->sgmii_active = true; + hw->phy.media_type = e1000_media_type_internal_serdes; + } else if (eth_flags->e1000_base_t) { +@@ -689,14 +689,10 @@ static s32 igb_get_invariants_82575(struct e1000_hw *hw) + break; + } + +- /* do not change link mode for 100BaseFX */ +- if (dev_spec->eth_flags.e100_base_fx) +- break; +- + /* change current link mode setting */ + ctrl_ext &= ~E1000_CTRL_EXT_LINK_MODE_MASK; + +- if (hw->phy.media_type == e1000_media_type_copper) ++ if (dev_spec->sgmii_active) + ctrl_ext |= E1000_CTRL_EXT_LINK_MODE_SGMII; + else + ctrl_ext |= E1000_CTRL_EXT_LINK_MODE_PCIE_SERDES; +diff --git a/drivers/net/ethernet/intel/igb/igb_ethtool.c b/drivers/net/ethernet/intel/igb/igb_ethtool.c +index d06a8db514d4..82028ce355fb 100644 +--- a/drivers/net/ethernet/intel/igb/igb_ethtool.c ++++ b/drivers/net/ethernet/intel/igb/igb_ethtool.c +@@ -201,7 +201,7 @@ static int igb_get_link_ksettings(struct net_device *netdev, + advertising &= ~ADVERTISED_1000baseKX_Full; + } + } +- if (eth_flags->e100_base_fx) { ++ if (eth_flags->e100_base_fx || eth_flags->e100_base_lx) { + supported |= SUPPORTED_100baseT_Full; + advertising |= ADVERTISED_100baseT_Full; + } +diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +index e4c1e6345edd..ba184287e11f 100644 +--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c ++++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +@@ -5131,7 +5131,7 @@ static void ixgbe_fdir_filter_restore(struct ixgbe_adapter *adapter) + struct ixgbe_hw *hw = &adapter->hw; + struct hlist_node *node2; + struct ixgbe_fdir_filter *filter; +- u64 action; ++ u8 queue; + + spin_lock(&adapter->fdir_perfect_lock); + +@@ -5140,17 +5140,34 @@ static void ixgbe_fdir_filter_restore(struct ixgbe_adapter *adapter) + + hlist_for_each_entry_safe(filter, node2, + &adapter->fdir_filter_list, fdir_node) { +- action = filter->action; +- if (action != IXGBE_FDIR_DROP_QUEUE && action != 0) +- action = +- (action >> ETHTOOL_RX_FLOW_SPEC_RING_VF_OFF) - 1; ++ if (filter->action == IXGBE_FDIR_DROP_QUEUE) { ++ queue = IXGBE_FDIR_DROP_QUEUE; ++ } else { ++ u32 ring = ethtool_get_flow_spec_ring(filter->action); ++ u8 vf = ethtool_get_flow_spec_ring_vf(filter->action); ++ ++ if (!vf && (ring >= adapter->num_rx_queues)) { ++ e_err(drv, "FDIR restore failed without VF, ring: %u\n", ++ ring); ++ continue; ++ } else if (vf && ++ ((vf > adapter->num_vfs) || ++ ring >= adapter->num_rx_queues_per_pool)) { ++ e_err(drv, "FDIR restore failed with VF, vf: %hhu, ring: %u\n", ++ vf, ring); ++ continue; ++ } ++ ++ /* Map the ring onto the absolute queue index */ ++ if (!vf) ++ queue = adapter->rx_ring[ring]->reg_idx; ++ else ++ queue = ((vf - 1) * ++ adapter->num_rx_queues_per_pool) + ring; ++ } + + ixgbe_fdir_write_perfect_filter_82599(hw, +- &filter->filter, +- filter->sw_idx, +- (action == IXGBE_FDIR_DROP_QUEUE) ? +- IXGBE_FDIR_DROP_QUEUE : +- adapter->rx_ring[action]->reg_idx); ++ &filter->filter, filter->sw_idx, queue); + } + + spin_unlock(&adapter->fdir_perfect_lock); +diff --git a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c +index e238f6e85ab6..a7708e14aa5c 100644 +--- a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c ++++ b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c +@@ -1858,11 +1858,6 @@ static int ixgbevf_write_uc_addr_list(struct net_device *netdev) + struct ixgbe_hw *hw = &adapter->hw; + int count = 0; + +- if ((netdev_uc_count(netdev)) > 10) { +- pr_err("Too many unicast filters - No Space\n"); +- return -ENOSPC; +- } +- + if (!netdev_uc_empty(netdev)) { + struct netdev_hw_addr *ha; + +diff --git a/drivers/net/ethernet/natsemi/sonic.c b/drivers/net/ethernet/natsemi/sonic.c +index a051dddcbd76..254e6dbc4c6a 100644 +--- a/drivers/net/ethernet/natsemi/sonic.c ++++ b/drivers/net/ethernet/natsemi/sonic.c +@@ -50,6 +50,8 @@ static int sonic_open(struct net_device *dev) + if (sonic_debug > 2) + printk("sonic_open: initializing sonic driver.\n"); + ++ spin_lock_init(&lp->lock); ++ + for (i = 0; i < SONIC_NUM_RRS; i++) { + struct sk_buff *skb = netdev_alloc_skb(dev, SONIC_RBSIZE + 2); + if (skb == NULL) { +@@ -101,6 +103,24 @@ static int sonic_open(struct net_device *dev) + return 0; + } + ++/* Wait for the SONIC to become idle. */ ++static void sonic_quiesce(struct net_device *dev, u16 mask) ++{ ++ struct sonic_local * __maybe_unused lp = netdev_priv(dev); ++ int i; ++ u16 bits; ++ ++ for (i = 0; i < 1000; ++i) { ++ bits = SONIC_READ(SONIC_CMD) & mask; ++ if (!bits) ++ return; ++ if (irqs_disabled() || in_interrupt()) ++ udelay(20); ++ else ++ usleep_range(100, 200); ++ } ++ WARN_ONCE(1, "command deadline expired! 0x%04x\n", bits); ++} + + /* + * Close the SONIC device +@@ -118,6 +138,9 @@ static int sonic_close(struct net_device *dev) + /* + * stop the SONIC, disable interrupts + */ ++ SONIC_WRITE(SONIC_CMD, SONIC_CR_RXDIS); ++ sonic_quiesce(dev, SONIC_CR_ALL); ++ + SONIC_WRITE(SONIC_IMR, 0); + SONIC_WRITE(SONIC_ISR, 0x7fff); + SONIC_WRITE(SONIC_CMD, SONIC_CR_RST); +@@ -157,6 +180,9 @@ static void sonic_tx_timeout(struct net_device *dev) + * put the Sonic into software-reset mode and + * disable all interrupts before releasing DMA buffers + */ ++ SONIC_WRITE(SONIC_CMD, SONIC_CR_RXDIS); ++ sonic_quiesce(dev, SONIC_CR_ALL); ++ + SONIC_WRITE(SONIC_IMR, 0); + SONIC_WRITE(SONIC_ISR, 0x7fff); + SONIC_WRITE(SONIC_CMD, SONIC_CR_RST); +@@ -194,8 +220,6 @@ static void sonic_tx_timeout(struct net_device *dev) + * wake the tx queue + * Concurrently with all of this, the SONIC is potentially writing to + * the status flags of the TDs. +- * Until some mutual exclusion is added, this code will not work with SMP. However, +- * MIPS Jazz machines and m68k Macs were all uni-processor machines. + */ + + static int sonic_send_packet(struct sk_buff *skb, struct net_device *dev) +@@ -203,7 +227,8 @@ static int sonic_send_packet(struct sk_buff *skb, struct net_device *dev) + struct sonic_local *lp = netdev_priv(dev); + dma_addr_t laddr; + int length; +- int entry = lp->next_tx; ++ int entry; ++ unsigned long flags; + + if (sonic_debug > 2) + printk("sonic_send_packet: skb=%p, dev=%p\n", skb, dev); +@@ -226,6 +251,10 @@ static int sonic_send_packet(struct sk_buff *skb, struct net_device *dev) + return NETDEV_TX_OK; + } + ++ spin_lock_irqsave(&lp->lock, flags); ++ ++ entry = lp->next_tx; ++ + sonic_tda_put(dev, entry, SONIC_TD_STATUS, 0); /* clear status */ + sonic_tda_put(dev, entry, SONIC_TD_FRAG_COUNT, 1); /* single fragment */ + sonic_tda_put(dev, entry, SONIC_TD_PKTSIZE, length); /* length of packet */ +@@ -235,10 +264,6 @@ static int sonic_send_packet(struct sk_buff *skb, struct net_device *dev) + sonic_tda_put(dev, entry, SONIC_TD_LINK, + sonic_tda_get(dev, entry, SONIC_TD_LINK) | SONIC_EOL); + +- /* +- * Must set tx_skb[entry] only after clearing status, and +- * before clearing EOL and before stopping queue +- */ + wmb(); + lp->tx_len[entry] = length; + lp->tx_laddr[entry] = laddr; +@@ -263,6 +288,8 @@ static int sonic_send_packet(struct sk_buff *skb, struct net_device *dev) + + SONIC_WRITE(SONIC_CMD, SONIC_CR_TXP); + ++ spin_unlock_irqrestore(&lp->lock, flags); ++ + return NETDEV_TX_OK; + } + +@@ -275,9 +302,21 @@ static irqreturn_t sonic_interrupt(int irq, void *dev_id) + struct net_device *dev = dev_id; + struct sonic_local *lp = netdev_priv(dev); + int status; ++ unsigned long flags; ++ ++ /* The lock has two purposes. Firstly, it synchronizes sonic_interrupt() ++ * with sonic_send_packet() so that the two functions can share state. ++ * Secondly, it makes sonic_interrupt() re-entrant, as that is required ++ * by macsonic which must use two IRQs with different priority levels. ++ */ ++ spin_lock_irqsave(&lp->lock, flags); ++ ++ status = SONIC_READ(SONIC_ISR) & SONIC_IMR_DEFAULT; ++ if (!status) { ++ spin_unlock_irqrestore(&lp->lock, flags); + +- if (!(status = SONIC_READ(SONIC_ISR) & SONIC_IMR_DEFAULT)) + return IRQ_NONE; ++ } + + do { + if (status & SONIC_INT_PKTRX) { +@@ -292,11 +331,12 @@ static irqreturn_t sonic_interrupt(int irq, void *dev_id) + int td_status; + int freed_some = 0; + +- /* At this point, cur_tx is the index of a TD that is one of: +- * unallocated/freed (status set & tx_skb[entry] clear) +- * allocated and sent (status set & tx_skb[entry] set ) +- * allocated and not yet sent (status clear & tx_skb[entry] set ) +- * still being allocated by sonic_send_packet (status clear & tx_skb[entry] clear) ++ /* The state of a Transmit Descriptor may be inferred ++ * from { tx_skb[entry], td_status } as follows. ++ * { clear, clear } => the TD has never been used ++ * { set, clear } => the TD was handed to SONIC ++ * { set, set } => the TD was handed back ++ * { clear, set } => the TD is available for re-use + */ + + if (sonic_debug > 2) +@@ -398,10 +438,30 @@ static irqreturn_t sonic_interrupt(int irq, void *dev_id) + /* load CAM done */ + if (status & SONIC_INT_LCD) + SONIC_WRITE(SONIC_ISR, SONIC_INT_LCD); /* clear the interrupt */ +- } while((status = SONIC_READ(SONIC_ISR) & SONIC_IMR_DEFAULT)); ++ ++ status = SONIC_READ(SONIC_ISR) & SONIC_IMR_DEFAULT; ++ } while (status); ++ ++ spin_unlock_irqrestore(&lp->lock, flags); ++ + return IRQ_HANDLED; + } + ++/* Return the array index corresponding to a given Receive Buffer pointer. */ ++static int index_from_addr(struct sonic_local *lp, dma_addr_t addr, ++ unsigned int last) ++{ ++ unsigned int i = last; ++ ++ do { ++ i = (i + 1) & SONIC_RRS_MASK; ++ if (addr == lp->rx_laddr[i]) ++ return i; ++ } while (i != last); ++ ++ return -ENOENT; ++} ++ + /* + * We have a good packet(s), pass it/them up the network stack. + */ +@@ -421,6 +481,16 @@ static void sonic_rx(struct net_device *dev) + + status = sonic_rda_get(dev, entry, SONIC_RD_STATUS); + if (status & SONIC_RCR_PRX) { ++ u32 addr = (sonic_rda_get(dev, entry, ++ SONIC_RD_PKTPTR_H) << 16) | ++ sonic_rda_get(dev, entry, SONIC_RD_PKTPTR_L); ++ int i = index_from_addr(lp, addr, entry); ++ ++ if (i < 0) { ++ WARN_ONCE(1, "failed to find buffer!\n"); ++ break; ++ } ++ + /* Malloc up new buffer. */ + new_skb = netdev_alloc_skb(dev, SONIC_RBSIZE + 2); + if (new_skb == NULL) { +@@ -442,7 +512,7 @@ static void sonic_rx(struct net_device *dev) + + /* now we have a new skb to replace it, pass the used one up the stack */ + dma_unmap_single(lp->device, lp->rx_laddr[entry], SONIC_RBSIZE, DMA_FROM_DEVICE); +- used_skb = lp->rx_skb[entry]; ++ used_skb = lp->rx_skb[i]; + pkt_len = sonic_rda_get(dev, entry, SONIC_RD_PKTLEN); + skb_trim(used_skb, pkt_len); + used_skb->protocol = eth_type_trans(used_skb, dev); +@@ -451,13 +521,13 @@ static void sonic_rx(struct net_device *dev) + lp->stats.rx_bytes += pkt_len; + + /* and insert the new skb */ +- lp->rx_laddr[entry] = new_laddr; +- lp->rx_skb[entry] = new_skb; ++ lp->rx_laddr[i] = new_laddr; ++ lp->rx_skb[i] = new_skb; + + bufadr_l = (unsigned long)new_laddr & 0xffff; + bufadr_h = (unsigned long)new_laddr >> 16; +- sonic_rra_put(dev, entry, SONIC_RR_BUFADR_L, bufadr_l); +- sonic_rra_put(dev, entry, SONIC_RR_BUFADR_H, bufadr_h); ++ sonic_rra_put(dev, i, SONIC_RR_BUFADR_L, bufadr_l); ++ sonic_rra_put(dev, i, SONIC_RR_BUFADR_H, bufadr_h); + } else { + /* This should only happen, if we enable accepting broken packets. */ + lp->stats.rx_errors++; +@@ -592,6 +662,7 @@ static int sonic_init(struct net_device *dev) + */ + SONIC_WRITE(SONIC_CMD, 0); + SONIC_WRITE(SONIC_CMD, SONIC_CR_RXDIS); ++ sonic_quiesce(dev, SONIC_CR_ALL); + + /* + * initialize the receive resource area +diff --git a/drivers/net/ethernet/natsemi/sonic.h b/drivers/net/ethernet/natsemi/sonic.h +index 421b1a283fed..7dc011655e70 100644 +--- a/drivers/net/ethernet/natsemi/sonic.h ++++ b/drivers/net/ethernet/natsemi/sonic.h +@@ -110,6 +110,9 @@ + #define SONIC_CR_TXP 0x0002 + #define SONIC_CR_HTX 0x0001 + ++#define SONIC_CR_ALL (SONIC_CR_LCAM | SONIC_CR_RRRA | \ ++ SONIC_CR_RXEN | SONIC_CR_TXP) ++ + /* + * SONIC data configuration bits + */ +@@ -274,8 +277,9 @@ + #define SONIC_NUM_RDS SONIC_NUM_RRS /* number of receive descriptors */ + #define SONIC_NUM_TDS 16 /* number of transmit descriptors */ + +-#define SONIC_RDS_MASK (SONIC_NUM_RDS-1) +-#define SONIC_TDS_MASK (SONIC_NUM_TDS-1) ++#define SONIC_RRS_MASK (SONIC_NUM_RRS - 1) ++#define SONIC_RDS_MASK (SONIC_NUM_RDS - 1) ++#define SONIC_TDS_MASK (SONIC_NUM_TDS - 1) + + #define SONIC_RBSIZE 1520 /* size of one resource buffer */ + +@@ -321,6 +325,7 @@ struct sonic_local { + unsigned int next_tx; /* next free TD */ + struct device *device; /* generic device */ + struct net_device_stats stats; ++ spinlock_t lock; + }; + + #define TX_TIMEOUT (3 * HZ) +@@ -342,30 +347,30 @@ static void sonic_tx_timeout(struct net_device *dev); + as far as we can tell. */ + /* OpenBSD calls this "SWO". I'd like to think that sonic_buf_put() + is a much better name. */ +-static inline void sonic_buf_put(void* base, int bitmode, ++static inline void sonic_buf_put(u16 *base, int bitmode, + int offset, __u16 val) + { + if (bitmode) + #ifdef __BIG_ENDIAN +- ((__u16 *) base + (offset*2))[1] = val; ++ __raw_writew(val, base + (offset * 2) + 1); + #else +- ((__u16 *) base + (offset*2))[0] = val; ++ __raw_writew(val, base + (offset * 2) + 0); + #endif + else +- ((__u16 *) base)[offset] = val; ++ __raw_writew(val, base + (offset * 1) + 0); + } + +-static inline __u16 sonic_buf_get(void* base, int bitmode, ++static inline __u16 sonic_buf_get(u16 *base, int bitmode, + int offset) + { + if (bitmode) + #ifdef __BIG_ENDIAN +- return ((volatile __u16 *) base + (offset*2))[1]; ++ return __raw_readw(base + (offset * 2) + 1); + #else +- return ((volatile __u16 *) base + (offset*2))[0]; ++ return __raw_readw(base + (offset * 2) + 0); + #endif + else +- return ((volatile __u16 *) base)[offset]; ++ return __raw_readw(base + (offset * 1) + 0); + } + + /* Inlines that you should actually use for reading/writing DMA buffers */ +diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c +index a496390b8632..07f9067affc6 100644 +--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c ++++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c +@@ -2043,6 +2043,7 @@ static void qlcnic_83xx_exec_template_cmd(struct qlcnic_adapter *p_dev, + break; + } + entry += p_hdr->size; ++ cond_resched(); + } + p_dev->ahw->reset.seq_index = index; + } +diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c +index afa10a163da1..f34ae8c75bc5 100644 +--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c ++++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c +@@ -703,6 +703,7 @@ static u32 qlcnic_read_memory_test_agent(struct qlcnic_adapter *adapter, + addr += 16; + reg_read -= 16; + ret += 16; ++ cond_resched(); + } + out: + mutex_unlock(&adapter->ahw->mem_lock); +@@ -1383,6 +1384,7 @@ int qlcnic_dump_fw(struct qlcnic_adapter *adapter) + buf_offset += entry->hdr.cap_size; + entry_offset += entry->hdr.offset; + buffer = fw_dump->data + buf_offset; ++ cond_resched(); + } + + fw_dump->clr = 1; +diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c +index 4a984b76a60e..db70d4c5778a 100644 +--- a/drivers/net/usb/qmi_wwan.c ++++ b/drivers/net/usb/qmi_wwan.c +@@ -999,6 +999,7 @@ static const struct usb_device_id products[] = { + {QMI_QUIRK_QUECTEL_DYNCFG(0x2c7c, 0x0125)}, /* Quectel EC25, EC20 R2.0 Mini PCIe */ + {QMI_QUIRK_QUECTEL_DYNCFG(0x2c7c, 0x0306)}, /* Quectel EP06/EG06/EM06 */ + {QMI_QUIRK_QUECTEL_DYNCFG(0x2c7c, 0x0512)}, /* Quectel EG12/EM12 */ ++ {QMI_QUIRK_QUECTEL_DYNCFG(0x2c7c, 0x0800)}, /* Quectel RM500Q-GL */ + + /* 3. Combined interface devices matching on interface number */ + {QMI_FIXED_INTF(0x0408, 0xea42, 4)}, /* Yota / Megafon M100-1 */ +diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c +index 0083c60f5cdf..a7f9c1886bd4 100644 +--- a/drivers/net/usb/r8152.c ++++ b/drivers/net/usb/r8152.c +@@ -5244,6 +5244,11 @@ static int rtl8152_probe(struct usb_interface *intf, + + intf->needs_remote_wakeup = 1; + ++ if (!rtl_can_wakeup(tp)) ++ __rtl_set_wol(tp, 0); ++ else ++ tp->saved_wolopts = __rtl_get_wol(tp); ++ + tp->rtl_ops.init(tp); + queue_delayed_work(system_long_wq, &tp->hw_phy_work, 0); + set_ethernet_addr(tp); +@@ -5257,10 +5262,6 @@ static int rtl8152_probe(struct usb_interface *intf, + goto out1; + } + +- if (!rtl_can_wakeup(tp)) +- __rtl_set_wol(tp, 0); +- +- tp->saved_wolopts = __rtl_get_wol(tp); + if (tp->saved_wolopts) + device_set_wakeup_enable(&udev->dev, true); + else +diff --git a/drivers/net/wan/sdla.c b/drivers/net/wan/sdla.c +index 236c62538036..1eb329fc7241 100644 +--- a/drivers/net/wan/sdla.c ++++ b/drivers/net/wan/sdla.c +@@ -711,7 +711,7 @@ static netdev_tx_t sdla_transmit(struct sk_buff *skb, + + spin_lock_irqsave(&sdla_lock, flags); + SDLA_WINDOW(dev, addr); +- pbuf = (void *)(((int) dev->mem_start) + (addr & SDLA_ADDR_MASK)); ++ pbuf = (void *)(dev->mem_start + (addr & SDLA_ADDR_MASK)); + __sdla_write(dev, pbuf->buf_addr, skb->data, skb->len); + SDLA_WINDOW(dev, addr); + pbuf->opp_flag = 1; +diff --git a/drivers/net/wireless/ath/ath9k/hif_usb.c b/drivers/net/wireless/ath/ath9k/hif_usb.c +index c5f4dd808745..6f669166c263 100644 +--- a/drivers/net/wireless/ath/ath9k/hif_usb.c ++++ b/drivers/net/wireless/ath/ath9k/hif_usb.c +@@ -1214,7 +1214,7 @@ err_fw: + static int send_eject_command(struct usb_interface *interface) + { + struct usb_device *udev = interface_to_usbdev(interface); +- struct usb_host_interface *iface_desc = &interface->altsetting[0]; ++ struct usb_host_interface *iface_desc = interface->cur_altsetting; + struct usb_endpoint_descriptor *endpoint; + unsigned char *cmd; + u8 bulk_out_ep; +diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c +index be855aa32154..2eb5fe7367c6 100644 +--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c ++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c +@@ -1333,7 +1333,7 @@ brcmf_usb_probe(struct usb_interface *intf, const struct usb_device_id *id) + goto fail; + } + +- desc = &intf->altsetting[0].desc; ++ desc = &intf->cur_altsetting->desc; + if ((desc->bInterfaceClass != USB_CLASS_VENDOR_SPEC) || + (desc->bInterfaceSubClass != 2) || + (desc->bInterfaceProtocol != 0xff)) { +@@ -1346,7 +1346,7 @@ brcmf_usb_probe(struct usb_interface *intf, const struct usb_device_id *id) + + num_of_eps = desc->bNumEndpoints; + for (ep = 0; ep < num_of_eps; ep++) { +- endpoint = &intf->altsetting[0].endpoint[ep].desc; ++ endpoint = &intf->cur_altsetting->endpoint[ep].desc; + endpoint_num = usb_endpoint_num(endpoint); + if (!usb_endpoint_xfer_bulk(endpoint)) + continue; +diff --git a/drivers/net/wireless/cisco/airo.c b/drivers/net/wireless/cisco/airo.c +index fc49255bab00..f3f20abbe269 100644 +--- a/drivers/net/wireless/cisco/airo.c ++++ b/drivers/net/wireless/cisco/airo.c +@@ -7788,16 +7788,8 @@ static int readrids(struct net_device *dev, aironet_ioctl *comp) { + case AIROGVLIST: ridcode = RID_APLIST; break; + case AIROGDRVNAM: ridcode = RID_DRVNAME; break; + case AIROGEHTENC: ridcode = RID_ETHERENCAP; break; +- case AIROGWEPKTMP: ridcode = RID_WEP_TEMP; +- /* Only super-user can read WEP keys */ +- if (!capable(CAP_NET_ADMIN)) +- return -EPERM; +- break; +- case AIROGWEPKNV: ridcode = RID_WEP_PERM; +- /* Only super-user can read WEP keys */ +- if (!capable(CAP_NET_ADMIN)) +- return -EPERM; +- break; ++ case AIROGWEPKTMP: ridcode = RID_WEP_TEMP; break; ++ case AIROGWEPKNV: ridcode = RID_WEP_PERM; break; + case AIROGSTAT: ridcode = RID_STATUS; break; + case AIROGSTATSD32: ridcode = RID_STATSDELTA; break; + case AIROGSTATSC32: ridcode = RID_STATS; break; +@@ -7811,7 +7803,13 @@ static int readrids(struct net_device *dev, aironet_ioctl *comp) { + return -EINVAL; + } + +- if ((iobuf = kmalloc(RIDSIZE, GFP_KERNEL)) == NULL) ++ if (ridcode == RID_WEP_TEMP || ridcode == RID_WEP_PERM) { ++ /* Only super-user can read WEP keys */ ++ if (!capable(CAP_NET_ADMIN)) ++ return -EPERM; ++ } ++ ++ if ((iobuf = kzalloc(RIDSIZE, GFP_KERNEL)) == NULL) + return -ENOMEM; + + PC4500_readrid(ai,ridcode,iobuf,RIDSIZE, 1); +diff --git a/drivers/net/wireless/intersil/orinoco/orinoco_usb.c b/drivers/net/wireless/intersil/orinoco/orinoco_usb.c +index 56f6e3b71f48..95015d74b1c0 100644 +--- a/drivers/net/wireless/intersil/orinoco/orinoco_usb.c ++++ b/drivers/net/wireless/intersil/orinoco/orinoco_usb.c +@@ -1613,9 +1613,9 @@ static int ezusb_probe(struct usb_interface *interface, + /* set up the endpoint information */ + /* check out the endpoints */ + +- iface_desc = &interface->altsetting[0].desc; ++ iface_desc = &interface->cur_altsetting->desc; + for (i = 0; i < iface_desc->bNumEndpoints; ++i) { +- ep = &interface->altsetting[0].endpoint[i].desc; ++ ep = &interface->cur_altsetting->endpoint[i].desc; + + if (usb_endpoint_is_bulk_in(ep)) { + /* we found a bulk in endpoint */ +diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +index 73fc5952fd37..63f37fa72e4b 100644 +--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c ++++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +@@ -5921,7 +5921,7 @@ static int rtl8xxxu_parse_usb(struct rtl8xxxu_priv *priv, + u8 dir, xtype, num; + int ret = 0; + +- host_interface = &interface->altsetting[0]; ++ host_interface = interface->cur_altsetting; + interface_desc = &host_interface->desc; + endpoints = interface_desc->bNumEndpoints; + +diff --git a/drivers/net/wireless/rsi/rsi_91x_hal.c b/drivers/net/wireless/rsi/rsi_91x_hal.c +index 120b0ff545c1..d205947c4c55 100644 +--- a/drivers/net/wireless/rsi/rsi_91x_hal.c ++++ b/drivers/net/wireless/rsi/rsi_91x_hal.c +@@ -541,6 +541,7 @@ static int bl_cmd(struct rsi_hw *adapter, u8 cmd, u8 exp_resp, char *str) + bl_start_cmd_timer(adapter, timeout); + status = bl_write_cmd(adapter, cmd, exp_resp, ®out_val); + if (status < 0) { ++ bl_stop_cmd_timer(adapter); + rsi_dbg(ERR_ZONE, + "%s: Command %s (%0x) writing failed..\n", + __func__, str, cmd); +@@ -656,10 +657,9 @@ static int ping_pong_write(struct rsi_hw *adapter, u8 cmd, u8 *addr, u32 size) + } + + status = bl_cmd(adapter, cmd_req, cmd_resp, str); +- if (status) { +- bl_stop_cmd_timer(adapter); ++ if (status) + return status; +- } ++ + return 0; + } + +@@ -749,10 +749,9 @@ static int auto_fw_upgrade(struct rsi_hw *adapter, u8 *flash_content, + + status = bl_cmd(adapter, EOF_REACHED, FW_LOADING_SUCCESSFUL, + "EOF_REACHED"); +- if (status) { +- bl_stop_cmd_timer(adapter); ++ if (status) + return status; +- } ++ + rsi_dbg(INFO_ZONE, "FW loading is done and FW is running..\n"); + return 0; + } +@@ -773,6 +772,7 @@ static int rsi_load_firmware(struct rsi_hw *adapter) + status = hif_ops->master_reg_read(adapter, SWBL_REGOUT, + ®out_val, 2); + if (status < 0) { ++ bl_stop_cmd_timer(adapter); + rsi_dbg(ERR_ZONE, + "%s: REGOUT read failed\n", __func__); + return status; +diff --git a/drivers/net/wireless/rsi/rsi_91x_usb.c b/drivers/net/wireless/rsi/rsi_91x_usb.c +index f90c10b3c921..786a330bc470 100644 +--- a/drivers/net/wireless/rsi/rsi_91x_usb.c ++++ b/drivers/net/wireless/rsi/rsi_91x_usb.c +@@ -105,7 +105,7 @@ static int rsi_find_bulk_in_and_out_endpoints(struct usb_interface *interface, + __le16 buffer_size; + int ii, bep_found = 0; + +- iface_desc = &(interface->altsetting[0]); ++ iface_desc = interface->cur_altsetting; + + for (ii = 0; ii < iface_desc->desc.bNumEndpoints; ++ii) { + endpoint = &(iface_desc->endpoint[ii].desc); +diff --git a/drivers/net/wireless/zydas/zd1211rw/zd_usb.c b/drivers/net/wireless/zydas/zd1211rw/zd_usb.c +index c30bf118c67d..1e396eb26ccf 100644 +--- a/drivers/net/wireless/zydas/zd1211rw/zd_usb.c ++++ b/drivers/net/wireless/zydas/zd1211rw/zd_usb.c +@@ -1272,7 +1272,7 @@ static void print_id(struct usb_device *udev) + static int eject_installer(struct usb_interface *intf) + { + struct usb_device *udev = interface_to_usbdev(intf); +- struct usb_host_interface *iface_desc = &intf->altsetting[0]; ++ struct usb_host_interface *iface_desc = intf->cur_altsetting; + struct usb_endpoint_descriptor *endpoint; + unsigned char *cmd; + u8 bulk_out_ep; +diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c +index 90df085e9f92..e7ed051ec125 100644 +--- a/drivers/pci/quirks.c ++++ b/drivers/pci/quirks.c +@@ -4019,6 +4019,40 @@ static void quirk_mic_x200_dma_alias(struct pci_dev *pdev) + DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2260, quirk_mic_x200_dma_alias); + DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2264, quirk_mic_x200_dma_alias); + ++/* ++ * Intel Visual Compute Accelerator (VCA) is a family of PCIe add-in devices ++ * exposing computational units via Non Transparent Bridges (NTB, PEX 87xx). ++ * ++ * Similarly to MIC x200, we need to add DMA aliases to allow buffer access ++ * when IOMMU is enabled. These aliases allow computational unit access to ++ * host memory. These aliases mark the whole VCA device as one IOMMU ++ * group. ++ * ++ * All possible slot numbers (0x20) are used, since we are unable to tell ++ * what slot is used on other side. This quirk is intended for both host ++ * and computational unit sides. The VCA devices have up to five functions ++ * (four for DMA channels and one additional). ++ */ ++static void quirk_pex_vca_alias(struct pci_dev *pdev) ++{ ++ const unsigned int num_pci_slots = 0x20; ++ unsigned int slot; ++ ++ for (slot = 0; slot < num_pci_slots; slot++) { ++ pci_add_dma_alias(pdev, PCI_DEVFN(slot, 0x0)); ++ pci_add_dma_alias(pdev, PCI_DEVFN(slot, 0x1)); ++ pci_add_dma_alias(pdev, PCI_DEVFN(slot, 0x2)); ++ pci_add_dma_alias(pdev, PCI_DEVFN(slot, 0x3)); ++ pci_add_dma_alias(pdev, PCI_DEVFN(slot, 0x4)); ++ } ++} ++DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2954, quirk_pex_vca_alias); ++DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2955, quirk_pex_vca_alias); ++DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2956, quirk_pex_vca_alias); ++DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2958, quirk_pex_vca_alias); ++DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2959, quirk_pex_vca_alias); ++DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x295A, quirk_pex_vca_alias); ++ + /* + * The IOMMU and interrupt controller on Broadcom Vulcan/Cavium ThunderX2 are + * associated not at the root bus, but at a bridge below. This quirk avoids +diff --git a/drivers/phy/motorola/phy-cpcap-usb.c b/drivers/phy/motorola/phy-cpcap-usb.c +index 4ba3634009af..593c77dbde2e 100644 +--- a/drivers/phy/motorola/phy-cpcap-usb.c ++++ b/drivers/phy/motorola/phy-cpcap-usb.c +@@ -115,7 +115,7 @@ struct cpcap_usb_ints_state { + enum cpcap_gpio_mode { + CPCAP_DM_DP, + CPCAP_MDM_RX_TX, +- CPCAP_UNKNOWN, ++ CPCAP_UNKNOWN_DISABLED, /* Seems to disable USB lines */ + CPCAP_OTG_DM_DP, + }; + +@@ -379,7 +379,8 @@ static int cpcap_usb_set_uart_mode(struct cpcap_phy_ddata *ddata) + { + int error; + +- error = cpcap_usb_gpio_set_mode(ddata, CPCAP_DM_DP); ++ /* Disable lines to prevent glitches from waking up mdm6600 */ ++ error = cpcap_usb_gpio_set_mode(ddata, CPCAP_UNKNOWN_DISABLED); + if (error) + goto out_err; + +@@ -406,6 +407,11 @@ static int cpcap_usb_set_uart_mode(struct cpcap_phy_ddata *ddata) + if (error) + goto out_err; + ++ /* Enable UART mode */ ++ error = cpcap_usb_gpio_set_mode(ddata, CPCAP_DM_DP); ++ if (error) ++ goto out_err; ++ + return 0; + + out_err: +@@ -418,7 +424,8 @@ static int cpcap_usb_set_usb_mode(struct cpcap_phy_ddata *ddata) + { + int error; + +- error = cpcap_usb_gpio_set_mode(ddata, CPCAP_OTG_DM_DP); ++ /* Disable lines to prevent glitches from waking up mdm6600 */ ++ error = cpcap_usb_gpio_set_mode(ddata, CPCAP_UNKNOWN_DISABLED); + if (error) + return error; + +@@ -458,6 +465,11 @@ static int cpcap_usb_set_usb_mode(struct cpcap_phy_ddata *ddata) + if (error) + goto out_err; + ++ /* Enable USB mode */ ++ error = cpcap_usb_gpio_set_mode(ddata, CPCAP_OTG_DM_DP); ++ if (error) ++ goto out_err; ++ + return 0; + + out_err: +diff --git a/drivers/scsi/fnic/fnic_scsi.c b/drivers/scsi/fnic/fnic_scsi.c +index 242e2ee494a1..d79ac0b24f5a 100644 +--- a/drivers/scsi/fnic/fnic_scsi.c ++++ b/drivers/scsi/fnic/fnic_scsi.c +@@ -446,6 +446,9 @@ static int fnic_queuecommand_lck(struct scsi_cmnd *sc, void (*done)(struct scsi_ + if (unlikely(fnic_chk_state_flags_locked(fnic, FNIC_FLAGS_IO_BLOCKED))) + return SCSI_MLQUEUE_HOST_BUSY; + ++ if (unlikely(fnic_chk_state_flags_locked(fnic, FNIC_FLAGS_FWRESET))) ++ return SCSI_MLQUEUE_HOST_BUSY; ++ + rport = starget_to_rport(scsi_target(sc->device)); + if (!rport) { + FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, +diff --git a/drivers/soc/ti/wkup_m3_ipc.c b/drivers/soc/ti/wkup_m3_ipc.c +index 369aef5e7228..651827c6ee6f 100644 +--- a/drivers/soc/ti/wkup_m3_ipc.c ++++ b/drivers/soc/ti/wkup_m3_ipc.c +@@ -375,6 +375,8 @@ static void wkup_m3_rproc_boot_thread(struct wkup_m3_ipc *m3_ipc) + ret = rproc_boot(m3_ipc->rproc); + if (ret) + dev_err(dev, "rproc_boot failed\n"); ++ else ++ m3_ipc_state = m3_ipc; + + do_exit(0); + } +@@ -461,8 +463,6 @@ static int wkup_m3_ipc_probe(struct platform_device *pdev) + goto err_put_rproc; + } + +- m3_ipc_state = m3_ipc; +- + return 0; + + err_put_rproc: +diff --git a/drivers/spi/spi-dw.c b/drivers/spi/spi-dw.c +index b217c22ff72f..b461200871f8 100644 +--- a/drivers/spi/spi-dw.c ++++ b/drivers/spi/spi-dw.c +@@ -180,9 +180,11 @@ static inline u32 rx_max(struct dw_spi *dws) + + static void dw_writer(struct dw_spi *dws) + { +- u32 max = tx_max(dws); ++ u32 max; + u16 txw = 0; + ++ spin_lock(&dws->buf_lock); ++ max = tx_max(dws); + while (max--) { + /* Set the tx word if the transfer's original "tx" is not null */ + if (dws->tx_end - dws->len) { +@@ -194,13 +196,16 @@ static void dw_writer(struct dw_spi *dws) + dw_write_io_reg(dws, DW_SPI_DR, txw); + dws->tx += dws->n_bytes; + } ++ spin_unlock(&dws->buf_lock); + } + + static void dw_reader(struct dw_spi *dws) + { +- u32 max = rx_max(dws); ++ u32 max; + u16 rxw; + ++ spin_lock(&dws->buf_lock); ++ max = rx_max(dws); + while (max--) { + rxw = dw_read_io_reg(dws, DW_SPI_DR); + /* Care rx only if the transfer's original "rx" is not null */ +@@ -212,6 +217,7 @@ static void dw_reader(struct dw_spi *dws) + } + dws->rx += dws->n_bytes; + } ++ spin_unlock(&dws->buf_lock); + } + + static void int_error_stop(struct dw_spi *dws, const char *msg) +@@ -284,18 +290,20 @@ static int dw_spi_transfer_one(struct spi_master *master, + { + struct dw_spi *dws = spi_master_get_devdata(master); + struct chip_data *chip = spi_get_ctldata(spi); ++ unsigned long flags; + u8 imask = 0; + u16 txlevel = 0; + u32 cr0; + int ret; + + dws->dma_mapped = 0; +- ++ spin_lock_irqsave(&dws->buf_lock, flags); + dws->tx = (void *)transfer->tx_buf; + dws->tx_end = dws->tx + transfer->len; + dws->rx = transfer->rx_buf; + dws->rx_end = dws->rx + transfer->len; + dws->len = transfer->len; ++ spin_unlock_irqrestore(&dws->buf_lock, flags); + + spi_enable_chip(dws, 0); + +@@ -486,6 +494,7 @@ int dw_spi_add_host(struct device *dev, struct dw_spi *dws) + dws->type = SSI_MOTO_SPI; + dws->dma_inited = 0; + dws->dma_addr = (dma_addr_t)(dws->paddr + DW_SPI_DR); ++ spin_lock_init(&dws->buf_lock); + + ret = request_irq(dws->irq, dw_spi_irq, IRQF_SHARED, dev_name(dev), + master); +diff --git a/drivers/spi/spi-dw.h b/drivers/spi/spi-dw.h +index 5c07cf8f19e0..45fbf3ad591c 100644 +--- a/drivers/spi/spi-dw.h ++++ b/drivers/spi/spi-dw.h +@@ -117,6 +117,7 @@ struct dw_spi { + size_t len; + void *tx; + void *tx_end; ++ spinlock_t buf_lock; + void *rx; + void *rx_end; + int dma_mapped; +diff --git a/drivers/staging/most/aim-network/networking.c b/drivers/staging/most/aim-network/networking.c +index 936f013c350e..6398c27563c9 100644 +--- a/drivers/staging/most/aim-network/networking.c ++++ b/drivers/staging/most/aim-network/networking.c +@@ -85,6 +85,11 @@ static int skb_to_mamac(const struct sk_buff *skb, struct mbo *mbo) + unsigned int payload_len = skb->len - ETH_HLEN; + unsigned int mdp_len = payload_len + MDP_HDR_LEN; + ++ if (mdp_len < skb->len) { ++ pr_err("drop: too large packet! (%u)\n", skb->len); ++ return -EINVAL; ++ } ++ + if (mbo->buffer_length < mdp_len) { + pr_err("drop: too small buffer! (%d for %d)\n", + mbo->buffer_length, mdp_len); +@@ -132,6 +137,11 @@ static int skb_to_mep(const struct sk_buff *skb, struct mbo *mbo) + u8 *buff = mbo->virt_address; + unsigned int mep_len = skb->len + MEP_HDR_LEN; + ++ if (mep_len < skb->len) { ++ pr_err("drop: too large packet! (%u)\n", skb->len); ++ return -EINVAL; ++ } ++ + if (mbo->buffer_length < mep_len) { + pr_err("drop: too small buffer! (%d for %d)\n", + mbo->buffer_length, mep_len); +diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h +index 705fffa59da9..41a4f9555d07 100644 +--- a/drivers/staging/vt6656/device.h ++++ b/drivers/staging/vt6656/device.h +@@ -62,6 +62,8 @@ + #define RATE_AUTO 12 + + #define MAX_RATE 12 ++#define VNT_B_RATES (BIT(RATE_1M) | BIT(RATE_2M) |\ ++ BIT(RATE_5M) | BIT(RATE_11M)) + + /* + * device specific +diff --git a/drivers/staging/vt6656/int.c b/drivers/staging/vt6656/int.c +index c6ffbe0e2728..c521729c4192 100644 +--- a/drivers/staging/vt6656/int.c ++++ b/drivers/staging/vt6656/int.c +@@ -107,9 +107,11 @@ static int vnt_int_report_rate(struct vnt_private *priv, u8 pkt_no, u8 tsr) + + info->status.rates[0].count = tx_retry; + +- if (!(tsr & (TSR_TMO | TSR_RETRYTMO))) { ++ if (!(tsr & TSR_TMO)) { + info->status.rates[0].idx = idx; +- info->flags |= IEEE80211_TX_STAT_ACK; ++ ++ if (!(info->flags & IEEE80211_TX_CTL_NO_ACK)) ++ info->flags |= IEEE80211_TX_STAT_ACK; + } + + ieee80211_tx_status_irqsafe(priv->hw, context->skb); +diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c +index 645ea16b53d5..e8ccd800c94f 100644 +--- a/drivers/staging/vt6656/main_usb.c ++++ b/drivers/staging/vt6656/main_usb.c +@@ -977,6 +977,7 @@ vt6656_probe(struct usb_interface *intf, const struct usb_device_id *id) + ieee80211_hw_set(priv->hw, RX_INCLUDES_FCS); + ieee80211_hw_set(priv->hw, REPORTS_TX_ACK_STATUS); + ieee80211_hw_set(priv->hw, SUPPORTS_PS); ++ ieee80211_hw_set(priv->hw, PS_NULLFUNC_STACK); + + priv->hw->max_signal = 100; + +diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c +index a44abcce6fb4..f78f31ce6443 100644 +--- a/drivers/staging/vt6656/rxtx.c ++++ b/drivers/staging/vt6656/rxtx.c +@@ -288,11 +288,9 @@ static u16 vnt_rxtx_datahead_g(struct vnt_usb_send_context *tx_context, + PK_TYPE_11B, &buf->b); + + /* Get Duration and TimeStamp */ +- if (ieee80211_is_pspoll(hdr->frame_control)) { +- __le16 dur = cpu_to_le16(priv->current_aid | BIT(14) | BIT(15)); +- +- buf->duration_a = dur; +- buf->duration_b = dur; ++ if (ieee80211_is_nullfunc(hdr->frame_control)) { ++ buf->duration_a = hdr->duration_id; ++ buf->duration_b = hdr->duration_id; + } else { + buf->duration_a = vnt_get_duration_le(priv, + tx_context->pkt_type, need_ack); +@@ -381,10 +379,8 @@ static u16 vnt_rxtx_datahead_ab(struct vnt_usb_send_context *tx_context, + tx_context->pkt_type, &buf->ab); + + /* Get Duration and TimeStampOff */ +- if (ieee80211_is_pspoll(hdr->frame_control)) { +- __le16 dur = cpu_to_le16(priv->current_aid | BIT(14) | BIT(15)); +- +- buf->duration = dur; ++ if (ieee80211_is_nullfunc(hdr->frame_control)) { ++ buf->duration = hdr->duration_id; + } else { + buf->duration = vnt_get_duration_le(priv, tx_context->pkt_type, + need_ack); +@@ -825,10 +821,14 @@ int vnt_tx_packet(struct vnt_private *priv, struct sk_buff *skb) + if (info->band == NL80211_BAND_5GHZ) { + pkt_type = PK_TYPE_11A; + } else { +- if (tx_rate->flags & IEEE80211_TX_RC_USE_CTS_PROTECT) +- pkt_type = PK_TYPE_11GB; +- else +- pkt_type = PK_TYPE_11GA; ++ if (tx_rate->flags & IEEE80211_TX_RC_USE_CTS_PROTECT) { ++ if (priv->basic_rates & VNT_B_RATES) ++ pkt_type = PK_TYPE_11GB; ++ else ++ pkt_type = PK_TYPE_11GA; ++ } else { ++ pkt_type = PK_TYPE_11A; ++ } + } + } else { + pkt_type = PK_TYPE_11B; +diff --git a/drivers/staging/wlan-ng/prism2mgmt.c b/drivers/staging/wlan-ng/prism2mgmt.c +index c4aa9e7e7003..be89a0ee44bf 100644 +--- a/drivers/staging/wlan-ng/prism2mgmt.c ++++ b/drivers/staging/wlan-ng/prism2mgmt.c +@@ -945,7 +945,7 @@ int prism2mgmt_flashdl_state(struct wlandevice *wlandev, void *msgp) + } + } + +- return 0; ++ return result; + } + + /*---------------------------------------------------------------- +diff --git a/drivers/tee/optee/Kconfig b/drivers/tee/optee/Kconfig +index 0126de898036..108600c6eb56 100644 +--- a/drivers/tee/optee/Kconfig ++++ b/drivers/tee/optee/Kconfig +@@ -2,6 +2,7 @@ + config OPTEE + tristate "OP-TEE" + depends on HAVE_ARM_SMCCC ++ depends on MMU + help + This implements the OP-TEE Trusted Execution Environment (TEE) + driver. +diff --git a/drivers/tty/serial/8250/8250_bcm2835aux.c b/drivers/tty/serial/8250/8250_bcm2835aux.c +index a23c7da42ea8..7bbcae75e651 100644 +--- a/drivers/tty/serial/8250/8250_bcm2835aux.c ++++ b/drivers/tty/serial/8250/8250_bcm2835aux.c +@@ -119,7 +119,7 @@ static int bcm2835aux_serial_remove(struct platform_device *pdev) + { + struct bcm2835aux_data *data = platform_get_drvdata(pdev); + +- serial8250_unregister_port(data->uart.port.line); ++ serial8250_unregister_port(data->line); + clk_disable_unprepare(data->clk); + + return 0; +diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c +index a497b878c3e2..021899c58028 100644 +--- a/drivers/usb/dwc3/core.c ++++ b/drivers/usb/dwc3/core.c +@@ -1031,6 +1031,9 @@ static void dwc3_core_exit_mode(struct dwc3 *dwc) + /* do nothing */ + break; + } ++ ++ /* de-assert DRVVBUS for HOST and OTG mode */ ++ dwc3_set_prtcap(dwc, DWC3_GCTL_PRTCAP_DEVICE); + } + + static void dwc3_get_properties(struct dwc3 *dwc) +diff --git a/drivers/usb/serial/ir-usb.c b/drivers/usb/serial/ir-usb.c +index f9734a96d516..a3e3b4703f38 100644 +--- a/drivers/usb/serial/ir-usb.c ++++ b/drivers/usb/serial/ir-usb.c +@@ -49,9 +49,10 @@ static int buffer_size; + static int xbof = -1; + + static int ir_startup (struct usb_serial *serial); +-static int ir_open(struct tty_struct *tty, struct usb_serial_port *port); +-static int ir_prepare_write_buffer(struct usb_serial_port *port, +- void *dest, size_t size); ++static int ir_write(struct tty_struct *tty, struct usb_serial_port *port, ++ const unsigned char *buf, int count); ++static int ir_write_room(struct tty_struct *tty); ++static void ir_write_bulk_callback(struct urb *urb); + static void ir_process_read_urb(struct urb *urb); + static void ir_set_termios(struct tty_struct *tty, + struct usb_serial_port *port, struct ktermios *old_termios); +@@ -81,8 +82,9 @@ static struct usb_serial_driver ir_device = { + .num_ports = 1, + .set_termios = ir_set_termios, + .attach = ir_startup, +- .open = ir_open, +- .prepare_write_buffer = ir_prepare_write_buffer, ++ .write = ir_write, ++ .write_room = ir_write_room, ++ .write_bulk_callback = ir_write_bulk_callback, + .process_read_urb = ir_process_read_urb, + }; + +@@ -199,6 +201,9 @@ static int ir_startup(struct usb_serial *serial) + struct usb_irda_cs_descriptor *irda_desc; + int rates; + ++ if (serial->num_bulk_in < 1 || serial->num_bulk_out < 1) ++ return -ENODEV; ++ + irda_desc = irda_usb_find_class_desc(serial, 0); + if (!irda_desc) { + dev_err(&serial->dev->dev, +@@ -255,35 +260,102 @@ static int ir_startup(struct usb_serial *serial) + return 0; + } + +-static int ir_open(struct tty_struct *tty, struct usb_serial_port *port) ++static int ir_write(struct tty_struct *tty, struct usb_serial_port *port, ++ const unsigned char *buf, int count) + { +- int i; ++ struct urb *urb = NULL; ++ unsigned long flags; ++ int ret; + +- for (i = 0; i < ARRAY_SIZE(port->write_urbs); ++i) +- port->write_urbs[i]->transfer_flags = URB_ZERO_PACKET; ++ if (port->bulk_out_size == 0) ++ return -EINVAL; + +- /* Start reading from the device */ +- return usb_serial_generic_open(tty, port); +-} ++ if (count == 0) ++ return 0; + +-static int ir_prepare_write_buffer(struct usb_serial_port *port, +- void *dest, size_t size) +-{ +- unsigned char *buf = dest; +- int count; ++ count = min(count, port->bulk_out_size - 1); ++ ++ spin_lock_irqsave(&port->lock, flags); ++ if (__test_and_clear_bit(0, &port->write_urbs_free)) { ++ urb = port->write_urbs[0]; ++ port->tx_bytes += count; ++ } ++ spin_unlock_irqrestore(&port->lock, flags); ++ ++ if (!urb) ++ return 0; + + /* + * The first byte of the packet we send to the device contains an +- * inbound header which indicates an additional number of BOFs and ++ * outbound header which indicates an additional number of BOFs and + * a baud rate change. + * + * See section 5.4.2.2 of the USB IrDA spec. + */ +- *buf = ir_xbof | ir_baud; ++ *(u8 *)urb->transfer_buffer = ir_xbof | ir_baud; ++ ++ memcpy(urb->transfer_buffer + 1, buf, count); ++ ++ urb->transfer_buffer_length = count + 1; ++ urb->transfer_flags = URB_ZERO_PACKET; ++ ++ ret = usb_submit_urb(urb, GFP_ATOMIC); ++ if (ret) { ++ dev_err(&port->dev, "failed to submit write urb: %d\n", ret); ++ ++ spin_lock_irqsave(&port->lock, flags); ++ __set_bit(0, &port->write_urbs_free); ++ port->tx_bytes -= count; ++ spin_unlock_irqrestore(&port->lock, flags); ++ ++ return ret; ++ } ++ ++ return count; ++} ++ ++static void ir_write_bulk_callback(struct urb *urb) ++{ ++ struct usb_serial_port *port = urb->context; ++ int status = urb->status; ++ unsigned long flags; ++ ++ spin_lock_irqsave(&port->lock, flags); ++ __set_bit(0, &port->write_urbs_free); ++ port->tx_bytes -= urb->transfer_buffer_length - 1; ++ spin_unlock_irqrestore(&port->lock, flags); ++ ++ switch (status) { ++ case 0: ++ break; ++ case -ENOENT: ++ case -ECONNRESET: ++ case -ESHUTDOWN: ++ dev_dbg(&port->dev, "write urb stopped: %d\n", status); ++ return; ++ case -EPIPE: ++ dev_err(&port->dev, "write urb stopped: %d\n", status); ++ return; ++ default: ++ dev_err(&port->dev, "nonzero write-urb status: %d\n", status); ++ break; ++ } ++ ++ usb_serial_port_softint(port); ++} ++ ++static int ir_write_room(struct tty_struct *tty) ++{ ++ struct usb_serial_port *port = tty->driver_data; ++ int count = 0; ++ ++ if (port->bulk_out_size == 0) ++ return 0; ++ ++ if (test_bit(0, &port->write_urbs_free)) ++ count = port->bulk_out_size - 1; + +- count = kfifo_out_locked(&port->write_fifo, buf + 1, size - 1, +- &port->lock); +- return count + 1; ++ return count; + } + + static void ir_process_read_urb(struct urb *urb) +@@ -336,34 +408,34 @@ static void ir_set_termios(struct tty_struct *tty, + + switch (baud) { + case 2400: +- ir_baud = USB_IRDA_BR_2400; ++ ir_baud = USB_IRDA_LS_2400; + break; + case 9600: +- ir_baud = USB_IRDA_BR_9600; ++ ir_baud = USB_IRDA_LS_9600; + break; + case 19200: +- ir_baud = USB_IRDA_BR_19200; ++ ir_baud = USB_IRDA_LS_19200; + break; + case 38400: +- ir_baud = USB_IRDA_BR_38400; ++ ir_baud = USB_IRDA_LS_38400; + break; + case 57600: +- ir_baud = USB_IRDA_BR_57600; ++ ir_baud = USB_IRDA_LS_57600; + break; + case 115200: +- ir_baud = USB_IRDA_BR_115200; ++ ir_baud = USB_IRDA_LS_115200; + break; + case 576000: +- ir_baud = USB_IRDA_BR_576000; ++ ir_baud = USB_IRDA_LS_576000; + break; + case 1152000: +- ir_baud = USB_IRDA_BR_1152000; ++ ir_baud = USB_IRDA_LS_1152000; + break; + case 4000000: +- ir_baud = USB_IRDA_BR_4000000; ++ ir_baud = USB_IRDA_LS_4000000; + break; + default: +- ir_baud = USB_IRDA_BR_9600; ++ ir_baud = USB_IRDA_LS_9600; + baud = 9600; + } + +diff --git a/drivers/usb/storage/unusual_uas.h b/drivers/usb/storage/unusual_uas.h +index f15aa47c54a9..0eb8c67ee138 100644 +--- a/drivers/usb/storage/unusual_uas.h ++++ b/drivers/usb/storage/unusual_uas.h +@@ -163,12 +163,15 @@ UNUSUAL_DEV(0x2537, 0x1068, 0x0000, 0x9999, + USB_SC_DEVICE, USB_PR_DEVICE, NULL, + US_FL_IGNORE_UAS), + +-/* Reported-by: Takeo Nakayama */ ++/* ++ * Initially Reported-by: Takeo Nakayama ++ * UAS Ignore Reported by Steven Ellis ++ */ + UNUSUAL_DEV(0x357d, 0x7788, 0x0000, 0x9999, + "JMicron", + "JMS566", + USB_SC_DEVICE, USB_PR_DEVICE, NULL, +- US_FL_NO_REPORT_OPCODES), ++ US_FL_NO_REPORT_OPCODES | US_FL_IGNORE_UAS), + + /* Reported-by: Hans de Goede */ + UNUSUAL_DEV(0x4971, 0x1012, 0x0000, 0x9999, +diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig +index f55328a31629..fa15a683ae2d 100644 +--- a/drivers/watchdog/Kconfig ++++ b/drivers/watchdog/Kconfig +@@ -563,6 +563,7 @@ config MAX63XX_WATCHDOG + config MAX77620_WATCHDOG + tristate "Maxim Max77620 Watchdog Timer" + depends on MFD_MAX77620 || COMPILE_TEST ++ select WATCHDOG_CORE + help + This is the driver for the Max77620 watchdog timer. + Say 'Y' here to enable the watchdog timer support for +diff --git a/drivers/watchdog/rn5t618_wdt.c b/drivers/watchdog/rn5t618_wdt.c +index e60f55702ab7..d2e79cf70e77 100644 +--- a/drivers/watchdog/rn5t618_wdt.c ++++ b/drivers/watchdog/rn5t618_wdt.c +@@ -193,6 +193,7 @@ static struct platform_driver rn5t618_wdt_driver = { + + module_platform_driver(rn5t618_wdt_driver); + ++MODULE_ALIAS("platform:rn5t618-wdt"); + MODULE_AUTHOR("Beniamino Galvani "); + MODULE_DESCRIPTION("RN5T618 watchdog driver"); + MODULE_LICENSE("GPL v2"); +diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c +index 204d585e012a..3ab79fa00dc7 100644 +--- a/fs/btrfs/super.c ++++ b/fs/btrfs/super.c +@@ -2114,7 +2114,15 @@ static int btrfs_statfs(struct dentry *dentry, struct kstatfs *buf) + */ + thresh = 4 * 1024 * 1024; + +- if (!mixed && total_free_meta - thresh < block_rsv->size) ++ /* ++ * We only want to claim there's no available space if we can no longer ++ * allocate chunks for our metadata profile and our global reserve will ++ * not fit in the free metadata space. If we aren't ->full then we ++ * still can allocate chunks and thus are fine using the currently ++ * calculated f_bavail. ++ */ ++ if (!mixed && block_rsv->space_info->full && ++ total_free_meta - thresh < block_rsv->size) + buf->f_bavail = 0; + + buf->f_type = BTRFS_SUPER_MAGIC; +diff --git a/fs/ext4/super.c b/fs/ext4/super.c +index 1a0a56647974..93d8aa6ef661 100644 +--- a/fs/ext4/super.c ++++ b/fs/ext4/super.c +@@ -1782,6 +1782,13 @@ static int handle_mount_opt(struct super_block *sb, char *opt, int token, + arg = JBD2_DEFAULT_MAX_COMMIT_AGE; + sbi->s_commit_interval = HZ * arg; + } else if (token == Opt_debug_want_extra_isize) { ++ if ((arg & 1) || ++ (arg < 4) || ++ (arg > (sbi->s_inode_size - EXT4_GOOD_OLD_INODE_SIZE))) { ++ ext4_msg(sb, KERN_ERR, ++ "Invalid want_extra_isize %d", arg); ++ return -1; ++ } + sbi->s_want_extra_isize = arg; + } else if (token == Opt_max_batch_time) { + sbi->s_max_batch_time = arg; +@@ -3454,40 +3461,6 @@ int ext4_calculate_overhead(struct super_block *sb) + return 0; + } + +-static void ext4_clamp_want_extra_isize(struct super_block *sb) +-{ +- struct ext4_sb_info *sbi = EXT4_SB(sb); +- struct ext4_super_block *es = sbi->s_es; +- unsigned def_extra_isize = sizeof(struct ext4_inode) - +- EXT4_GOOD_OLD_INODE_SIZE; +- +- if (sbi->s_inode_size == EXT4_GOOD_OLD_INODE_SIZE) { +- sbi->s_want_extra_isize = 0; +- return; +- } +- if (sbi->s_want_extra_isize < 4) { +- sbi->s_want_extra_isize = def_extra_isize; +- if (ext4_has_feature_extra_isize(sb)) { +- if (sbi->s_want_extra_isize < +- le16_to_cpu(es->s_want_extra_isize)) +- sbi->s_want_extra_isize = +- le16_to_cpu(es->s_want_extra_isize); +- if (sbi->s_want_extra_isize < +- le16_to_cpu(es->s_min_extra_isize)) +- sbi->s_want_extra_isize = +- le16_to_cpu(es->s_min_extra_isize); +- } +- } +- /* Check if enough inode space is available */ +- if ((sbi->s_want_extra_isize > sbi->s_inode_size) || +- (EXT4_GOOD_OLD_INODE_SIZE + sbi->s_want_extra_isize > +- sbi->s_inode_size)) { +- sbi->s_want_extra_isize = def_extra_isize; +- ext4_msg(sb, KERN_INFO, +- "required extra inode space not available"); +- } +-} +- + static void ext4_set_resv_clusters(struct super_block *sb) + { + ext4_fsblk_t resv_clusters; +@@ -3695,6 +3668,65 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) + */ + sbi->s_li_wait_mult = EXT4_DEF_LI_WAIT_MULT; + ++ if (le32_to_cpu(es->s_rev_level) == EXT4_GOOD_OLD_REV) { ++ sbi->s_inode_size = EXT4_GOOD_OLD_INODE_SIZE; ++ sbi->s_first_ino = EXT4_GOOD_OLD_FIRST_INO; ++ } else { ++ sbi->s_inode_size = le16_to_cpu(es->s_inode_size); ++ sbi->s_first_ino = le32_to_cpu(es->s_first_ino); ++ if (sbi->s_first_ino < EXT4_GOOD_OLD_FIRST_INO) { ++ ext4_msg(sb, KERN_ERR, "invalid first ino: %u", ++ sbi->s_first_ino); ++ goto failed_mount; ++ } ++ if ((sbi->s_inode_size < EXT4_GOOD_OLD_INODE_SIZE) || ++ (!is_power_of_2(sbi->s_inode_size)) || ++ (sbi->s_inode_size > blocksize)) { ++ ext4_msg(sb, KERN_ERR, ++ "unsupported inode size: %d", ++ sbi->s_inode_size); ++ goto failed_mount; ++ } ++ /* ++ * i_atime_extra is the last extra field available for ++ * [acm]times in struct ext4_inode. Checking for that ++ * field should suffice to ensure we have extra space ++ * for all three. ++ */ ++ if (sbi->s_inode_size >= offsetof(struct ext4_inode, i_atime_extra) + ++ sizeof(((struct ext4_inode *)0)->i_atime_extra)) { ++ sb->s_time_gran = 1; ++ } else { ++ sb->s_time_gran = NSEC_PER_SEC; ++ } ++ } ++ if (sbi->s_inode_size > EXT4_GOOD_OLD_INODE_SIZE) { ++ sbi->s_want_extra_isize = sizeof(struct ext4_inode) - ++ EXT4_GOOD_OLD_INODE_SIZE; ++ if (ext4_has_feature_extra_isize(sb)) { ++ unsigned v, max = (sbi->s_inode_size - ++ EXT4_GOOD_OLD_INODE_SIZE); ++ ++ v = le16_to_cpu(es->s_want_extra_isize); ++ if (v > max) { ++ ext4_msg(sb, KERN_ERR, ++ "bad s_want_extra_isize: %d", v); ++ goto failed_mount; ++ } ++ if (sbi->s_want_extra_isize < v) ++ sbi->s_want_extra_isize = v; ++ ++ v = le16_to_cpu(es->s_min_extra_isize); ++ if (v > max) { ++ ext4_msg(sb, KERN_ERR, ++ "bad s_min_extra_isize: %d", v); ++ goto failed_mount; ++ } ++ if (sbi->s_want_extra_isize < v) ++ sbi->s_want_extra_isize = v; ++ } ++ } ++ + if (sbi->s_es->s_mount_opts[0]) { + char *s_mount_opts = kstrndup(sbi->s_es->s_mount_opts, + sizeof(sbi->s_es->s_mount_opts), +@@ -3893,29 +3925,6 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) + has_huge_files); + sb->s_maxbytes = ext4_max_size(sb->s_blocksize_bits, has_huge_files); + +- if (le32_to_cpu(es->s_rev_level) == EXT4_GOOD_OLD_REV) { +- sbi->s_inode_size = EXT4_GOOD_OLD_INODE_SIZE; +- sbi->s_first_ino = EXT4_GOOD_OLD_FIRST_INO; +- } else { +- sbi->s_inode_size = le16_to_cpu(es->s_inode_size); +- sbi->s_first_ino = le32_to_cpu(es->s_first_ino); +- if (sbi->s_first_ino < EXT4_GOOD_OLD_FIRST_INO) { +- ext4_msg(sb, KERN_ERR, "invalid first ino: %u", +- sbi->s_first_ino); +- goto failed_mount; +- } +- if ((sbi->s_inode_size < EXT4_GOOD_OLD_INODE_SIZE) || +- (!is_power_of_2(sbi->s_inode_size)) || +- (sbi->s_inode_size > blocksize)) { +- ext4_msg(sb, KERN_ERR, +- "unsupported inode size: %d", +- sbi->s_inode_size); +- goto failed_mount; +- } +- if (sbi->s_inode_size > EXT4_GOOD_OLD_INODE_SIZE) +- sb->s_time_gran = 1 << (EXT4_EPOCH_BITS - 2); +- } +- + sbi->s_desc_size = le16_to_cpu(es->s_desc_size); + if (ext4_has_feature_64bit(sb)) { + if (sbi->s_desc_size < EXT4_MIN_DESC_SIZE_64BIT || +@@ -4354,8 +4363,6 @@ no_journal: + if (ext4_setup_super(sb, es, sb_rdonly(sb))) + sb->s_flags |= MS_RDONLY; + +- ext4_clamp_want_extra_isize(sb); +- + ext4_set_resv_clusters(sb); + + err = ext4_setup_system_zone(sb); +@@ -5139,8 +5146,6 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data) + goto restore_opts; + } + +- ext4_clamp_want_extra_isize(sb); +- + if ((old_opts.s_mount_opt & EXT4_MOUNT_JOURNAL_CHECKSUM) ^ + test_opt(sb, JOURNAL_CHECKSUM)) { + ext4_msg(sb, KERN_ERR, "changing journal_checksum " +diff --git a/fs/namei.c b/fs/namei.c +index d648d6d2b635..f421f8d80f4d 100644 +--- a/fs/namei.c ++++ b/fs/namei.c +@@ -3266,8 +3266,8 @@ static int do_last(struct nameidata *nd, + int *opened) + { + struct dentry *dir = nd->path.dentry; +- kuid_t dir_uid = dir->d_inode->i_uid; +- umode_t dir_mode = dir->d_inode->i_mode; ++ kuid_t dir_uid = nd->inode->i_uid; ++ umode_t dir_mode = nd->inode->i_mode; + int open_flag = op->open_flag; + bool will_truncate = (open_flag & O_TRUNC) != 0; + bool got_write = false; +diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c +index cc0b22c72e83..5208d85dd30c 100644 +--- a/fs/reiserfs/super.c ++++ b/fs/reiserfs/super.c +@@ -629,6 +629,7 @@ static void reiserfs_put_super(struct super_block *s) + reiserfs_write_unlock(s); + mutex_destroy(&REISERFS_SB(s)->lock); + destroy_workqueue(REISERFS_SB(s)->commit_wq); ++ kfree(REISERFS_SB(s)->s_jdev); + kfree(s->s_fs_info); + s->s_fs_info = NULL; + } +@@ -2243,6 +2244,7 @@ error_unlocked: + kfree(qf_names[j]); + } + #endif ++ kfree(sbi->s_jdev); + kfree(sbi); + + s->s_fs_info = NULL; +diff --git a/include/linux/usb/irda.h b/include/linux/usb/irda.h +index 396d2b043e64..556a801efce3 100644 +--- a/include/linux/usb/irda.h ++++ b/include/linux/usb/irda.h +@@ -119,11 +119,22 @@ struct usb_irda_cs_descriptor { + * 6 - 115200 bps + * 7 - 576000 bps + * 8 - 1.152 Mbps +- * 9 - 5 mbps ++ * 9 - 4 Mbps + * 10..15 - Reserved + */ + #define USB_IRDA_STATUS_LINK_SPEED 0x0f + ++#define USB_IRDA_LS_NO_CHANGE 0 ++#define USB_IRDA_LS_2400 1 ++#define USB_IRDA_LS_9600 2 ++#define USB_IRDA_LS_19200 3 ++#define USB_IRDA_LS_38400 4 ++#define USB_IRDA_LS_57600 5 ++#define USB_IRDA_LS_115200 6 ++#define USB_IRDA_LS_576000 7 ++#define USB_IRDA_LS_1152000 8 ++#define USB_IRDA_LS_4000000 9 ++ + /* The following is a 4-bit value used only for + * outbound header: + * +diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h +index a4c8e9d7dd06..030eea38f258 100644 +--- a/include/net/cfg80211.h ++++ b/include/net/cfg80211.h +@@ -2843,6 +2843,9 @@ struct cfg80211_pmk_conf { + * + * @start_radar_detection: Start radar detection in the driver. + * ++ * @end_cac: End running CAC, probably because a related CAC ++ * was finished on another phy. ++ * + * @update_ft_ies: Provide updated Fast BSS Transition information to the + * driver. If the SME is in the driver/firmware, this information can be + * used in building Authentication and Reassociation Request frames. +@@ -3148,6 +3151,8 @@ struct cfg80211_ops { + struct net_device *dev, + struct cfg80211_chan_def *chandef, + u32 cac_time_ms); ++ void (*end_cac)(struct wiphy *wiphy, ++ struct net_device *dev); + int (*update_ft_ies)(struct wiphy *wiphy, struct net_device *dev, + struct cfg80211_update_ft_ies_params *ftie); + int (*crit_proto_start)(struct wiphy *wiphy, +diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c +index 2c57030f54aa..829943aad7be 100644 +--- a/kernel/cgroup/cgroup.c ++++ b/kernel/cgroup/cgroup.c +@@ -2884,8 +2884,6 @@ static int cgroup_apply_control_enable(struct cgroup *cgrp) + for_each_subsys(ss, ssid) { + struct cgroup_subsys_state *css = cgroup_css(dsct, ss); + +- WARN_ON_ONCE(css && percpu_ref_is_dying(&css->refcnt)); +- + if (!(cgroup_ss_mask(dsct) & (1 << ss->id))) + continue; + +@@ -2895,6 +2893,8 @@ static int cgroup_apply_control_enable(struct cgroup *cgrp) + return PTR_ERR(css); + } + ++ WARN_ON_ONCE(percpu_ref_is_dying(&css->refcnt)); ++ + if (css_visible(css)) { + ret = css_populate_dir(css); + if (ret) +@@ -2930,11 +2930,11 @@ static void cgroup_apply_control_disable(struct cgroup *cgrp) + for_each_subsys(ss, ssid) { + struct cgroup_subsys_state *css = cgroup_css(dsct, ss); + +- WARN_ON_ONCE(css && percpu_ref_is_dying(&css->refcnt)); +- + if (!css) + continue; + ++ WARN_ON_ONCE(percpu_ref_is_dying(&css->refcnt)); ++ + if (css->parent && + !(cgroup_ss_mask(dsct) & (1 << ss->id))) { + kill_css(css); +@@ -3221,7 +3221,8 @@ static ssize_t cgroup_type_write(struct kernfs_open_file *of, char *buf, + if (strcmp(strstrip(buf), "threaded")) + return -EINVAL; + +- cgrp = cgroup_kn_lock_live(of->kn, false); ++ /* drain dying csses before we re-apply (threaded) subtree control */ ++ cgrp = cgroup_kn_lock_live(of->kn, true); + if (!cgrp) + return -ENOENT; + +diff --git a/mm/mempolicy.c b/mm/mempolicy.c +index a37cfa88669e..1b34f2e35951 100644 +--- a/mm/mempolicy.c ++++ b/mm/mempolicy.c +@@ -2724,6 +2724,9 @@ int mpol_parse_str(char *str, struct mempolicy **mpol) + char *flags = strchr(str, '='); + int err = 1; + ++ if (flags) ++ *flags++ = '\0'; /* terminate mode string */ ++ + if (nodelist) { + /* NUL-terminate mode or flags string */ + *nodelist++ = '\0'; +@@ -2734,9 +2737,6 @@ int mpol_parse_str(char *str, struct mempolicy **mpol) + } else + nodes_clear(nodes); + +- if (flags) +- *flags++ = '\0'; /* terminate mode string */ +- + for (mode = 0; mode < MPOL_MAX; mode++) { + if (!strcmp(str, policy_modes[mode])) { + break; +diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c +index 4a05235929b9..93093d7c3824 100644 +--- a/net/bluetooth/hci_sock.c ++++ b/net/bluetooth/hci_sock.c +@@ -826,6 +826,8 @@ static int hci_sock_release(struct socket *sock) + if (!sk) + return 0; + ++ lock_sock(sk); ++ + switch (hci_pi(sk)->channel) { + case HCI_CHANNEL_MONITOR: + atomic_dec(&monitor_promisc); +@@ -873,6 +875,7 @@ static int hci_sock_release(struct socket *sock) + skb_queue_purge(&sk->sk_receive_queue); + skb_queue_purge(&sk->sk_write_queue); + ++ release_sock(sk); + sock_put(sk); + return 0; + } +diff --git a/net/core/utils.c b/net/core/utils.c +index 93066bd0305a..b1823e76b877 100644 +--- a/net/core/utils.c ++++ b/net/core/utils.c +@@ -419,6 +419,23 @@ void inet_proto_csum_replace4(__sum16 *sum, struct sk_buff *skb, + } + EXPORT_SYMBOL(inet_proto_csum_replace4); + ++/** ++ * inet_proto_csum_replace16 - update layer 4 header checksum field ++ * @sum: Layer 4 header checksum field ++ * @skb: sk_buff for the packet ++ * @from: old IPv6 address ++ * @to: new IPv6 address ++ * @pseudohdr: True if layer 4 header checksum includes pseudoheader ++ * ++ * Update layer 4 header as per the update in IPv6 src/dst address. ++ * ++ * There is no need to update skb->csum in this function, because update in two ++ * fields a.) IPv6 src/dst address and b.) L4 header checksum cancels each other ++ * for skb->csum calculation. Whereas inet_proto_csum_replace4 function needs to ++ * update skb->csum, because update in 3 fields a.) IPv4 src/dst address, ++ * b.) IPv4 Header checksum and c.) L4 header checksum results in same diff as ++ * L4 Header checksum for skb->csum calculation. ++ */ + void inet_proto_csum_replace16(__sum16 *sum, struct sk_buff *skb, + const __be32 *from, const __be32 *to, + bool pseudohdr) +@@ -430,9 +447,6 @@ void inet_proto_csum_replace16(__sum16 *sum, struct sk_buff *skb, + if (skb->ip_summed != CHECKSUM_PARTIAL) { + *sum = csum_fold(csum_partial(diff, sizeof(diff), + ~csum_unfold(*sum))); +- if (skb->ip_summed == CHECKSUM_COMPLETE && pseudohdr) +- skb->csum = ~csum_partial(diff, sizeof(diff), +- ~skb->csum); + } else if (pseudohdr) + *sum = ~csum_fold(csum_partial(diff, sizeof(diff), + csum_unfold(*sum))); +diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c +index 08c15dd42d93..59384ffe89f7 100644 +--- a/net/ipv4/ip_vti.c ++++ b/net/ipv4/ip_vti.c +@@ -208,8 +208,17 @@ static netdev_tx_t vti_xmit(struct sk_buff *skb, struct net_device *dev, + int mtu; + + if (!dst) { +- dev->stats.tx_carrier_errors++; +- goto tx_error_icmp; ++ struct rtable *rt; ++ ++ fl->u.ip4.flowi4_oif = dev->ifindex; ++ fl->u.ip4.flowi4_flags |= FLOWI_FLAG_ANYSRC; ++ rt = __ip_route_output_key(dev_net(dev), &fl->u.ip4); ++ if (IS_ERR(rt)) { ++ dev->stats.tx_carrier_errors++; ++ goto tx_error_icmp; ++ } ++ dst = &rt->dst; ++ skb_dst_set(skb, dst); + } + + dst_hold(dst); +diff --git a/net/ipv6/ip6_vti.c b/net/ipv6/ip6_vti.c +index 557fe3880a3f..396a0f61f5f8 100644 +--- a/net/ipv6/ip6_vti.c ++++ b/net/ipv6/ip6_vti.c +@@ -453,8 +453,17 @@ vti6_xmit(struct sk_buff *skb, struct net_device *dev, struct flowi *fl) + int err = -1; + int mtu; + +- if (!dst) +- goto tx_err_link_failure; ++ if (!dst) { ++ fl->u.ip6.flowi6_oif = dev->ifindex; ++ fl->u.ip6.flowi6_flags |= FLOWI_FLAG_ANYSRC; ++ dst = ip6_route_output(dev_net(dev), NULL, &fl->u.ip6); ++ if (dst->error) { ++ dst_release(dst); ++ dst = NULL; ++ goto tx_err_link_failure; ++ } ++ skb_dst_set(skb, dst); ++ } + + dst_hold(dst); + dst = xfrm_lookup(t->net, dst, fl, NULL, 0); +diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c +index d437007b15bb..b1484b8316e8 100644 +--- a/net/mac80211/cfg.c ++++ b/net/mac80211/cfg.c +@@ -2800,6 +2800,28 @@ static int ieee80211_start_radar_detection(struct wiphy *wiphy, + return err; + } + ++static void ieee80211_end_cac(struct wiphy *wiphy, ++ struct net_device *dev) ++{ ++ struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); ++ struct ieee80211_local *local = sdata->local; ++ ++ mutex_lock(&local->mtx); ++ list_for_each_entry(sdata, &local->interfaces, list) { ++ /* it might be waiting for the local->mtx, but then ++ * by the time it gets it, sdata->wdev.cac_started ++ * will no longer be true ++ */ ++ cancel_delayed_work(&sdata->dfs_cac_timer_work); ++ ++ if (sdata->wdev.cac_started) { ++ ieee80211_vif_release_channel(sdata); ++ sdata->wdev.cac_started = false; ++ } ++ } ++ mutex_unlock(&local->mtx); ++} ++ + static struct cfg80211_beacon_data * + cfg80211_beacon_dup(struct cfg80211_beacon_data *beacon) + { +@@ -3730,6 +3752,7 @@ const struct cfg80211_ops mac80211_config_ops = { + #endif + .get_channel = ieee80211_cfg_get_channel, + .start_radar_detection = ieee80211_start_radar_detection, ++ .end_cac = ieee80211_end_cac, + .channel_switch = ieee80211_channel_switch, + .set_qos_map = ieee80211_set_qos_map, + .set_ap_chanwidth = ieee80211_set_ap_chanwidth, +diff --git a/net/mac80211/mesh_hwmp.c b/net/mac80211/mesh_hwmp.c +index fab0764c315f..994dde6e5f9d 100644 +--- a/net/mac80211/mesh_hwmp.c ++++ b/net/mac80211/mesh_hwmp.c +@@ -326,6 +326,9 @@ static u32 airtime_link_metric_get(struct ieee80211_local *local, + unsigned long fail_avg = + ewma_mesh_fail_avg_read(&sta->mesh->fail_avg); + ++ if (sta->mesh->plink_state != NL80211_PLINK_ESTAB) ++ return MAX_METRIC; ++ + /* Try to get rate based on HW/SW RC algorithm. + * Rate is returned in units of Kbps, correct this + * to comply with airtime calculation units +diff --git a/net/mac80211/tkip.c b/net/mac80211/tkip.c +index b3622823bad2..ebd66e8f46b3 100644 +--- a/net/mac80211/tkip.c ++++ b/net/mac80211/tkip.c +@@ -266,9 +266,21 @@ int ieee80211_tkip_decrypt_data(struct crypto_cipher *tfm, + if ((keyid >> 6) != key->conf.keyidx) + return TKIP_DECRYPT_INVALID_KEYIDX; + +- if (rx_ctx->ctx.state != TKIP_STATE_NOT_INIT && +- (iv32 < rx_ctx->iv32 || +- (iv32 == rx_ctx->iv32 && iv16 <= rx_ctx->iv16))) ++ /* Reject replays if the received TSC is smaller than or equal to the ++ * last received value in a valid message, but with an exception for ++ * the case where a new key has been set and no valid frame using that ++ * key has yet received and the local RSC was initialized to 0. This ++ * exception allows the very first frame sent by the transmitter to be ++ * accepted even if that transmitter were to use TSC 0 (IEEE 802.11 ++ * described TSC to be initialized to 1 whenever a new key is taken into ++ * use). ++ */ ++ if (iv32 < rx_ctx->iv32 || ++ (iv32 == rx_ctx->iv32 && ++ (iv16 < rx_ctx->iv16 || ++ (iv16 == rx_ctx->iv16 && ++ (rx_ctx->iv32 || rx_ctx->iv16 || ++ rx_ctx->ctx.state != TKIP_STATE_NOT_INIT))))) + return TKIP_DECRYPT_REPLAY; + + if (only_iv) { +diff --git a/net/sched/ematch.c b/net/sched/ematch.c +index 60f2354c1789..a48dca26f178 100644 +--- a/net/sched/ematch.c ++++ b/net/sched/ematch.c +@@ -242,6 +242,9 @@ static int tcf_em_validate(struct tcf_proto *tp, + goto errout; + + if (em->ops->change) { ++ err = -EINVAL; ++ if (em_hdr->flags & TCF_EM_SIMPLE) ++ goto errout; + err = em->ops->change(net, data, data_len, em); + if (err < 0) + goto errout; +diff --git a/net/wireless/rdev-ops.h b/net/wireless/rdev-ops.h +index 249919bdfc64..4077bb3af440 100644 +--- a/net/wireless/rdev-ops.h ++++ b/net/wireless/rdev-ops.h +@@ -1143,6 +1143,16 @@ rdev_start_radar_detection(struct cfg80211_registered_device *rdev, + return ret; + } + ++static inline void ++rdev_end_cac(struct cfg80211_registered_device *rdev, ++ struct net_device *dev) ++{ ++ trace_rdev_end_cac(&rdev->wiphy, dev); ++ if (rdev->ops->end_cac) ++ rdev->ops->end_cac(&rdev->wiphy, dev); ++ trace_rdev_return_void(&rdev->wiphy); ++} ++ + static inline int + rdev_set_mcast_rate(struct cfg80211_registered_device *rdev, + struct net_device *dev, +diff --git a/net/wireless/reg.c b/net/wireless/reg.c +index 804eac073b6b..a520f433d476 100644 +--- a/net/wireless/reg.c ++++ b/net/wireless/reg.c +@@ -1718,14 +1718,15 @@ static void update_all_wiphy_regulatory(enum nl80211_reg_initiator initiator) + + static void handle_channel_custom(struct wiphy *wiphy, + struct ieee80211_channel *chan, +- const struct ieee80211_regdomain *regd) ++ const struct ieee80211_regdomain *regd, ++ u32 min_bw) + { + u32 bw_flags = 0; + const struct ieee80211_reg_rule *reg_rule = NULL; + const struct ieee80211_power_rule *power_rule = NULL; + u32 bw; + +- for (bw = MHZ_TO_KHZ(20); bw >= MHZ_TO_KHZ(5); bw = bw / 2) { ++ for (bw = MHZ_TO_KHZ(20); bw >= min_bw; bw = bw / 2) { + reg_rule = freq_reg_info_regd(MHZ_TO_KHZ(chan->center_freq), + regd, bw); + if (!IS_ERR(reg_rule)) +@@ -1781,8 +1782,14 @@ static void handle_band_custom(struct wiphy *wiphy, + if (!sband) + return; + ++ /* ++ * We currently assume that you always want at least 20 MHz, ++ * otherwise channel 12 might get enabled if this rule is ++ * compatible to US, which permits 2402 - 2472 MHz. ++ */ + for (i = 0; i < sband->n_channels; i++) +- handle_channel_custom(wiphy, &sband->channels[i], regd); ++ handle_channel_custom(wiphy, &sband->channels[i], regd, ++ MHZ_TO_KHZ(20)); + } + + /* Used by drivers prior to wiphy registration */ +@@ -3296,6 +3303,25 @@ bool regulatory_pre_cac_allowed(struct wiphy *wiphy) + return pre_cac_allowed; + } + ++static void cfg80211_check_and_end_cac(struct cfg80211_registered_device *rdev) ++{ ++ struct wireless_dev *wdev; ++ /* If we finished CAC or received radar, we should end any ++ * CAC running on the same channels. ++ * the check !cfg80211_chandef_dfs_usable contain 2 options: ++ * either all channels are available - those the CAC_FINISHED ++ * event has effected another wdev state, or there is a channel ++ * in unavailable state in wdev chandef - those the RADAR_DETECTED ++ * event has effected another wdev state. ++ * In both cases we should end the CAC on the wdev. ++ */ ++ list_for_each_entry(wdev, &rdev->wiphy.wdev_list, list) { ++ if (wdev->cac_started && ++ !cfg80211_chandef_dfs_usable(&rdev->wiphy, &wdev->chandef)) ++ rdev_end_cac(rdev, wdev->netdev); ++ } ++} ++ + void regulatory_propagate_dfs_state(struct wiphy *wiphy, + struct cfg80211_chan_def *chandef, + enum nl80211_dfs_state dfs_state, +@@ -3322,8 +3348,10 @@ void regulatory_propagate_dfs_state(struct wiphy *wiphy, + cfg80211_set_dfs_state(&rdev->wiphy, chandef, dfs_state); + + if (event == NL80211_RADAR_DETECTED || +- event == NL80211_RADAR_CAC_FINISHED) ++ event == NL80211_RADAR_CAC_FINISHED) { + cfg80211_sched_dfs_chan_update(rdev); ++ cfg80211_check_and_end_cac(rdev); ++ } + + nl80211_radar_notify(rdev, chandef, event, NULL, GFP_KERNEL); + } +diff --git a/net/wireless/trace.h b/net/wireless/trace.h +index f3353fe5b35b..cd0a1c7c185d 100644 +--- a/net/wireless/trace.h ++++ b/net/wireless/trace.h +@@ -607,6 +607,11 @@ DEFINE_EVENT(wiphy_netdev_evt, rdev_flush_pmksa, + TP_ARGS(wiphy, netdev) + ); + ++DEFINE_EVENT(wiphy_netdev_evt, rdev_end_cac, ++ TP_PROTO(struct wiphy *wiphy, struct net_device *netdev), ++ TP_ARGS(wiphy, netdev) ++); ++ + DECLARE_EVENT_CLASS(station_add_change, + TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, u8 *mac, + struct station_parameters *params), +diff --git a/net/wireless/wext-core.c b/net/wireless/wext-core.c +index 6cdb054484d6..5236a3c2c0cc 100644 +--- a/net/wireless/wext-core.c ++++ b/net/wireless/wext-core.c +@@ -659,7 +659,8 @@ struct iw_statistics *get_wireless_stats(struct net_device *dev) + return NULL; + } + +-static int iw_handler_get_iwstats(struct net_device * dev, ++/* noinline to avoid a bogus warning with -O3 */ ++static noinline int iw_handler_get_iwstats(struct net_device * dev, + struct iw_request_info * info, + union iwreq_data * wrqu, + char * extra) +diff --git a/sound/soc/sti/uniperif_player.c b/sound/soc/sti/uniperif_player.c +index d8b6936e544e..908f13623f8c 100644 +--- a/sound/soc/sti/uniperif_player.c ++++ b/sound/soc/sti/uniperif_player.c +@@ -226,7 +226,6 @@ static void uni_player_set_channel_status(struct uniperif *player, + * sampling frequency. If no sample rate is already specified, then + * set one. + */ +- mutex_lock(&player->ctrl_lock); + if (runtime) { + switch (runtime->rate) { + case 22050: +@@ -303,7 +302,6 @@ static void uni_player_set_channel_status(struct uniperif *player, + player->stream_settings.iec958.status[3 + (n * 4)] << 24; + SET_UNIPERIF_CHANNEL_STA_REGN(player, n, status); + } +- mutex_unlock(&player->ctrl_lock); + + /* Update the channel status */ + if (player->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0) +@@ -365,8 +363,10 @@ static int uni_player_prepare_iec958(struct uniperif *player, + + SET_UNIPERIF_CTRL_ZERO_STUFF_HW(player); + ++ mutex_lock(&player->ctrl_lock); + /* Update the channel status */ + uni_player_set_channel_status(player, runtime); ++ mutex_unlock(&player->ctrl_lock); + + /* Clear the user validity user bits */ + SET_UNIPERIF_USER_VALIDITY_VALIDITY_LR(player, 0); +@@ -598,7 +598,6 @@ static int uni_player_ctl_iec958_put(struct snd_kcontrol *kcontrol, + iec958->status[1] = ucontrol->value.iec958.status[1]; + iec958->status[2] = ucontrol->value.iec958.status[2]; + iec958->status[3] = ucontrol->value.iec958.status[3]; +- mutex_unlock(&player->ctrl_lock); + + spin_lock_irqsave(&player->irq_lock, flags); + if (player->substream && player->substream->runtime) +@@ -608,6 +607,8 @@ static int uni_player_ctl_iec958_put(struct snd_kcontrol *kcontrol, + uni_player_set_channel_status(player, NULL); + + spin_unlock_irqrestore(&player->irq_lock, flags); ++ mutex_unlock(&player->ctrl_lock); ++ + return 0; + } + +diff --git a/tools/include/linux/string.h b/tools/include/linux/string.h +index 6c3e2cc274c5..0ec646f127dc 100644 +--- a/tools/include/linux/string.h ++++ b/tools/include/linux/string.h +@@ -14,7 +14,15 @@ int strtobool(const char *s, bool *res); + * However uClibc headers also define __GLIBC__ hence the hack below + */ + #if defined(__GLIBC__) && !defined(__UCLIBC__) ++// pragma diagnostic was introduced in gcc 4.6 ++#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) ++#pragma GCC diagnostic push ++#pragma GCC diagnostic ignored "-Wredundant-decls" ++#endif + extern size_t strlcpy(char *dest, const char *src, size_t size); ++#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) ++#pragma GCC diagnostic pop ++#endif + #endif + + char *str_error_r(int errnum, char *buf, size_t buflen); +diff --git a/tools/lib/string.c b/tools/lib/string.c +index 93b3d4b6feac..ee0afcbdd696 100644 +--- a/tools/lib/string.c ++++ b/tools/lib/string.c +@@ -95,6 +95,10 @@ int strtobool(const char *s, bool *res) + * If libc has strlcpy() then that version will override this + * implementation: + */ ++#ifdef __clang__ ++#pragma clang diagnostic push ++#pragma clang diagnostic ignored "-Wignored-attributes" ++#endif + size_t __weak strlcpy(char *dest, const char *src, size_t size) + { + size_t ret = strlen(src); +@@ -106,3 +110,6 @@ size_t __weak strlcpy(char *dest, const char *src, size_t size) + } + return ret; + } ++#ifdef __clang__ ++#pragma clang diagnostic pop ++#endif +diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c +index bec7a2f1fb4d..264d458bfe2a 100644 +--- a/tools/perf/builtin-c2c.c ++++ b/tools/perf/builtin-c2c.c +@@ -528,8 +528,8 @@ tot_hitm_cmp(struct perf_hpp_fmt *fmt __maybe_unused, + { + struct c2c_hist_entry *c2c_left; + struct c2c_hist_entry *c2c_right; +- unsigned int tot_hitm_left; +- unsigned int tot_hitm_right; ++ uint64_t tot_hitm_left; ++ uint64_t tot_hitm_right; + + c2c_left = container_of(left, struct c2c_hist_entry, he); + c2c_right = container_of(right, struct c2c_hist_entry, he); +@@ -562,7 +562,8 @@ __f ## _cmp(struct perf_hpp_fmt *fmt __maybe_unused, \ + \ + c2c_left = container_of(left, struct c2c_hist_entry, he); \ + c2c_right = container_of(right, struct c2c_hist_entry, he); \ +- return c2c_left->stats.__f - c2c_right->stats.__f; \ ++ return (uint64_t) c2c_left->stats.__f - \ ++ (uint64_t) c2c_right->stats.__f; \ + } + + #define STAT_FN(__f) \ +@@ -615,7 +616,8 @@ ld_llcmiss_cmp(struct perf_hpp_fmt *fmt __maybe_unused, + c2c_left = container_of(left, struct c2c_hist_entry, he); + c2c_right = container_of(right, struct c2c_hist_entry, he); + +- return llc_miss(&c2c_left->stats) - llc_miss(&c2c_right->stats); ++ return (uint64_t) llc_miss(&c2c_left->stats) - ++ (uint64_t) llc_miss(&c2c_right->stats); + } + + static uint64_t total_records(struct c2c_stats *stats) +diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c +index 17b26661b2f6..429c3e140dc3 100644 +--- a/tools/perf/builtin-report.c ++++ b/tools/perf/builtin-report.c +@@ -342,10 +342,10 @@ static int report__setup_sample_type(struct report *rep) + PERF_SAMPLE_BRANCH_ANY)) + rep->nonany_branch_mode = true; + +-#ifndef HAVE_LIBUNWIND_SUPPORT ++#if !defined(HAVE_LIBUNWIND_SUPPORT) && !defined(HAVE_DWARF_SUPPORT) + if (dwarf_callchain_users) { +- ui__warning("Please install libunwind development packages " +- "during the perf build.\n"); ++ ui__warning("Please install libunwind or libdw " ++ "development packages during the perf build.\n"); + } + #endif +