Magellan Linux

Contents of /trunk/kernel-alx/patches-4.4/0121-4.4.22-all-fixes.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2833 - (show annotations) (download)
Thu Oct 13 09:53:54 2016 UTC (7 years, 7 months ago) by niro
File size: 127595 byte(s)
-linux-4.4.22
1 diff --git a/Documentation/devicetree/bindings/iio/adc/rockchip-saradc.txt b/Documentation/devicetree/bindings/iio/adc/rockchip-saradc.txt
2 index a9a5fe19ff2a..ec9d65682702 100644
3 --- a/Documentation/devicetree/bindings/iio/adc/rockchip-saradc.txt
4 +++ b/Documentation/devicetree/bindings/iio/adc/rockchip-saradc.txt
5 @@ -12,6 +12,11 @@ Required properties:
6 - vref-supply: The regulator supply ADC reference voltage.
7 - #io-channel-cells: Should be 1, see ../iio-bindings.txt
8
9 +Optional properties:
10 +- resets: Must contain an entry for each entry in reset-names if need support
11 + this option. See ../reset/reset.txt for details.
12 +- reset-names: Must include the name "saradc-apb".
13 +
14 Example:
15 saradc: saradc@2006c000 {
16 compatible = "rockchip,saradc";
17 @@ -19,6 +24,8 @@ Example:
18 interrupts = <GIC_SPI 26 IRQ_TYPE_LEVEL_HIGH>;
19 clocks = <&cru SCLK_SARADC>, <&cru PCLK_SARADC>;
20 clock-names = "saradc", "apb_pclk";
21 + resets = <&cru SRST_SARADC>;
22 + reset-names = "saradc-apb";
23 #io-channel-cells = <1>;
24 vref-supply = <&vcc18>;
25 };
26 diff --git a/Documentation/mic/mpssd/mpssd.c b/Documentation/mic/mpssd/mpssd.c
27 index aaeafa18d99b..c99a75968c01 100644
28 --- a/Documentation/mic/mpssd/mpssd.c
29 +++ b/Documentation/mic/mpssd/mpssd.c
30 @@ -1538,9 +1538,9 @@ set_cmdline(struct mic_info *mic)
31
32 len = snprintf(buffer, PATH_MAX,
33 "clocksource=tsc highres=off nohz=off ");
34 - len += snprintf(buffer + len, PATH_MAX,
35 + len += snprintf(buffer + len, PATH_MAX - len,
36 "cpufreq_on;corec6_off;pc3_off;pc6_off ");
37 - len += snprintf(buffer + len, PATH_MAX,
38 + len += snprintf(buffer + len, PATH_MAX - len,
39 "ifcfg=static;address,172.31.%d.1;netmask,255.255.255.0",
40 mic->id + 1);
41
42 diff --git a/Makefile b/Makefile
43 index d1cc9e0b7473..a6512f4eec9f 100644
44 --- a/Makefile
45 +++ b/Makefile
46 @@ -1,6 +1,6 @@
47 VERSION = 4
48 PATCHLEVEL = 4
49 -SUBLEVEL = 21
50 +SUBLEVEL = 22
51 EXTRAVERSION =
52 NAME = Blurry Fish Butt
53
54 diff --git a/arch/alpha/include/asm/uaccess.h b/arch/alpha/include/asm/uaccess.h
55 index 9b0d40093c9a..c0ddbbf73400 100644
56 --- a/arch/alpha/include/asm/uaccess.h
57 +++ b/arch/alpha/include/asm/uaccess.h
58 @@ -371,14 +371,6 @@ __copy_tofrom_user_nocheck(void *to, const void *from, long len)
59 return __cu_len;
60 }
61
62 -extern inline long
63 -__copy_tofrom_user(void *to, const void *from, long len, const void __user *validate)
64 -{
65 - if (__access_ok((unsigned long)validate, len, get_fs()))
66 - len = __copy_tofrom_user_nocheck(to, from, len);
67 - return len;
68 -}
69 -
70 #define __copy_to_user(to, from, n) \
71 ({ \
72 __chk_user_ptr(to); \
73 @@ -393,17 +385,22 @@ __copy_tofrom_user(void *to, const void *from, long len, const void __user *vali
74 #define __copy_to_user_inatomic __copy_to_user
75 #define __copy_from_user_inatomic __copy_from_user
76
77 -
78 extern inline long
79 copy_to_user(void __user *to, const void *from, long n)
80 {
81 - return __copy_tofrom_user((__force void *)to, from, n, to);
82 + if (likely(__access_ok((unsigned long)to, n, get_fs())))
83 + n = __copy_tofrom_user_nocheck((__force void *)to, from, n);
84 + return n;
85 }
86
87 extern inline long
88 copy_from_user(void *to, const void __user *from, long n)
89 {
90 - return __copy_tofrom_user(to, (__force void *)from, n, from);
91 + if (likely(__access_ok((unsigned long)from, n, get_fs())))
92 + n = __copy_tofrom_user_nocheck(to, (__force void *)from, n);
93 + else
94 + memset(to, 0, n);
95 + return n;
96 }
97
98 extern void __do_clear_user(void);
99 diff --git a/arch/arc/include/asm/pgtable.h b/arch/arc/include/asm/pgtable.h
100 index 3cab04255ae0..e5fec320f158 100644
101 --- a/arch/arc/include/asm/pgtable.h
102 +++ b/arch/arc/include/asm/pgtable.h
103 @@ -277,8 +277,7 @@ static inline void pmd_set(pmd_t *pmdp, pte_t *ptep)
104
105 #define mk_pte(page, prot) pfn_pte(page_to_pfn(page), prot)
106 #define pte_pfn(pte) (pte_val(pte) >> PAGE_SHIFT)
107 -#define pfn_pte(pfn, prot) (__pte(((pte_t)(pfn) << PAGE_SHIFT) | \
108 - pgprot_val(prot)))
109 +#define pfn_pte(pfn, prot) (__pte(((pfn) << PAGE_SHIFT) | pgprot_val(prot)))
110 #define __pte_index(addr) (((addr) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
111
112 /*
113 diff --git a/arch/arc/include/asm/uaccess.h b/arch/arc/include/asm/uaccess.h
114 index d1da6032b715..d4d8df706efa 100644
115 --- a/arch/arc/include/asm/uaccess.h
116 +++ b/arch/arc/include/asm/uaccess.h
117 @@ -83,7 +83,10 @@
118 "2: ;nop\n" \
119 " .section .fixup, \"ax\"\n" \
120 " .align 4\n" \
121 - "3: mov %0, %3\n" \
122 + "3: # return -EFAULT\n" \
123 + " mov %0, %3\n" \
124 + " # zero out dst ptr\n" \
125 + " mov %1, 0\n" \
126 " j 2b\n" \
127 " .previous\n" \
128 " .section __ex_table, \"a\"\n" \
129 @@ -101,7 +104,11 @@
130 "2: ;nop\n" \
131 " .section .fixup, \"ax\"\n" \
132 " .align 4\n" \
133 - "3: mov %0, %3\n" \
134 + "3: # return -EFAULT\n" \
135 + " mov %0, %3\n" \
136 + " # zero out dst ptr\n" \
137 + " mov %1, 0\n" \
138 + " mov %R1, 0\n" \
139 " j 2b\n" \
140 " .previous\n" \
141 " .section __ex_table, \"a\"\n" \
142 diff --git a/arch/arm/boot/dts/imx6qdl.dtsi b/arch/arm/boot/dts/imx6qdl.dtsi
143 index 2b6cc8bf3c5c..e6af41c4bbc1 100644
144 --- a/arch/arm/boot/dts/imx6qdl.dtsi
145 +++ b/arch/arm/boot/dts/imx6qdl.dtsi
146 @@ -221,7 +221,7 @@
147 clocks = <&clks IMX6QDL_CLK_SPDIF_GCLK>, <&clks IMX6QDL_CLK_OSC>,
148 <&clks IMX6QDL_CLK_SPDIF>, <&clks IMX6QDL_CLK_ASRC>,
149 <&clks IMX6QDL_CLK_DUMMY>, <&clks IMX6QDL_CLK_ESAI_EXTAL>,
150 - <&clks IMX6QDL_CLK_IPG>, <&clks IMX6QDL_CLK_MLB>,
151 + <&clks IMX6QDL_CLK_IPG>, <&clks IMX6QDL_CLK_DUMMY>,
152 <&clks IMX6QDL_CLK_DUMMY>, <&clks IMX6QDL_CLK_SPBA>;
153 clock-names = "core", "rxtx0",
154 "rxtx1", "rxtx2",
155 diff --git a/arch/arm/boot/dts/kirkwood-ib62x0.dts b/arch/arm/boot/dts/kirkwood-ib62x0.dts
156 index bfa5edde179c..2c1e7f09205f 100644
157 --- a/arch/arm/boot/dts/kirkwood-ib62x0.dts
158 +++ b/arch/arm/boot/dts/kirkwood-ib62x0.dts
159 @@ -113,7 +113,7 @@
160
161 partition@e0000 {
162 label = "u-boot environment";
163 - reg = <0xe0000 0x100000>;
164 + reg = <0xe0000 0x20000>;
165 };
166
167 partition@100000 {
168 diff --git a/arch/arm/boot/dts/omap3-overo-base.dtsi b/arch/arm/boot/dts/omap3-overo-base.dtsi
169 index a29ad16cc9bb..64c5af30c1d0 100644
170 --- a/arch/arm/boot/dts/omap3-overo-base.dtsi
171 +++ b/arch/arm/boot/dts/omap3-overo-base.dtsi
172 @@ -223,7 +223,9 @@
173 };
174
175 &gpmc {
176 - ranges = <0 0 0x00000000 0x20000000>;
177 + ranges = <0 0 0x30000000 0x1000000>, /* CS0 */
178 + <4 0 0x2b000000 0x1000000>, /* CS4 */
179 + <5 0 0x2c000000 0x1000000>; /* CS5 */
180
181 nand@0,0 {
182 linux,mtd-name= "micron,mt29c4g96maz";
183 diff --git a/arch/arm/boot/dts/omap3-overo-chestnut43-common.dtsi b/arch/arm/boot/dts/omap3-overo-chestnut43-common.dtsi
184 index 17b82f82638a..64047788216b 100644
185 --- a/arch/arm/boot/dts/omap3-overo-chestnut43-common.dtsi
186 +++ b/arch/arm/boot/dts/omap3-overo-chestnut43-common.dtsi
187 @@ -55,8 +55,6 @@
188 #include "omap-gpmc-smsc9221.dtsi"
189
190 &gpmc {
191 - ranges = <5 0 0x2c000000 0x1000000>; /* CS5 */
192 -
193 ethernet@gpmc {
194 reg = <5 0 0xff>;
195 interrupt-parent = <&gpio6>;
196 diff --git a/arch/arm/boot/dts/omap3-overo-tobi-common.dtsi b/arch/arm/boot/dts/omap3-overo-tobi-common.dtsi
197 index 9e24b6a1d07b..1b304e2f1bd2 100644
198 --- a/arch/arm/boot/dts/omap3-overo-tobi-common.dtsi
199 +++ b/arch/arm/boot/dts/omap3-overo-tobi-common.dtsi
200 @@ -27,8 +27,6 @@
201 #include "omap-gpmc-smsc9221.dtsi"
202
203 &gpmc {
204 - ranges = <5 0 0x2c000000 0x1000000>; /* CS5 */
205 -
206 ethernet@gpmc {
207 reg = <5 0 0xff>;
208 interrupt-parent = <&gpio6>;
209 diff --git a/arch/arm/boot/dts/omap3-overo-tobiduo-common.dtsi b/arch/arm/boot/dts/omap3-overo-tobiduo-common.dtsi
210 index 334109e14613..82e98ee3023a 100644
211 --- a/arch/arm/boot/dts/omap3-overo-tobiduo-common.dtsi
212 +++ b/arch/arm/boot/dts/omap3-overo-tobiduo-common.dtsi
213 @@ -15,9 +15,6 @@
214 #include "omap-gpmc-smsc9221.dtsi"
215
216 &gpmc {
217 - ranges = <4 0 0x2b000000 0x1000000>, /* CS4 */
218 - <5 0 0x2c000000 0x1000000>; /* CS5 */
219 -
220 smsc1: ethernet@gpmc {
221 reg = <5 0 0xff>;
222 interrupt-parent = <&gpio6>;
223 diff --git a/arch/arm/boot/dts/stih407-family.dtsi b/arch/arm/boot/dts/stih407-family.dtsi
224 index 81f81214cdf9..bbf95375cf99 100644
225 --- a/arch/arm/boot/dts/stih407-family.dtsi
226 +++ b/arch/arm/boot/dts/stih407-family.dtsi
227 @@ -497,8 +497,9 @@
228 interrupt-names = "mmcirq";
229 pinctrl-names = "default";
230 pinctrl-0 = <&pinctrl_mmc0>;
231 - clock-names = "mmc";
232 - clocks = <&clk_s_c0_flexgen CLK_MMC_0>;
233 + clock-names = "mmc", "icn";
234 + clocks = <&clk_s_c0_flexgen CLK_MMC_0>,
235 + <&clk_s_c0_flexgen CLK_RX_ICN_HVA>;
236 bus-width = <8>;
237 non-removable;
238 };
239 @@ -512,8 +513,9 @@
240 interrupt-names = "mmcirq";
241 pinctrl-names = "default";
242 pinctrl-0 = <&pinctrl_sd1>;
243 - clock-names = "mmc";
244 - clocks = <&clk_s_c0_flexgen CLK_MMC_1>;
245 + clock-names = "mmc", "icn";
246 + clocks = <&clk_s_c0_flexgen CLK_MMC_1>,
247 + <&clk_s_c0_flexgen CLK_RX_ICN_HVA>;
248 resets = <&softreset STIH407_MMC1_SOFTRESET>;
249 bus-width = <4>;
250 };
251 diff --git a/arch/arm/boot/dts/stih410.dtsi b/arch/arm/boot/dts/stih410.dtsi
252 index 18ed1ad10d32..40318869c733 100644
253 --- a/arch/arm/boot/dts/stih410.dtsi
254 +++ b/arch/arm/boot/dts/stih410.dtsi
255 @@ -41,7 +41,8 @@
256 compatible = "st,st-ohci-300x";
257 reg = <0x9a03c00 0x100>;
258 interrupts = <GIC_SPI 180 IRQ_TYPE_NONE>;
259 - clocks = <&clk_s_c0_flexgen CLK_TX_ICN_DISP_0>;
260 + clocks = <&clk_s_c0_flexgen CLK_TX_ICN_DISP_0>,
261 + <&clk_s_c0_flexgen CLK_RX_ICN_DISP_0>;
262 resets = <&powerdown STIH407_USB2_PORT0_POWERDOWN>,
263 <&softreset STIH407_USB2_PORT0_SOFTRESET>;
264 reset-names = "power", "softreset";
265 @@ -57,7 +58,8 @@
266 interrupts = <GIC_SPI 151 IRQ_TYPE_NONE>;
267 pinctrl-names = "default";
268 pinctrl-0 = <&pinctrl_usb0>;
269 - clocks = <&clk_s_c0_flexgen CLK_TX_ICN_DISP_0>;
270 + clocks = <&clk_s_c0_flexgen CLK_TX_ICN_DISP_0>,
271 + <&clk_s_c0_flexgen CLK_RX_ICN_DISP_0>;
272 resets = <&powerdown STIH407_USB2_PORT0_POWERDOWN>,
273 <&softreset STIH407_USB2_PORT0_SOFTRESET>;
274 reset-names = "power", "softreset";
275 @@ -71,7 +73,8 @@
276 compatible = "st,st-ohci-300x";
277 reg = <0x9a83c00 0x100>;
278 interrupts = <GIC_SPI 181 IRQ_TYPE_NONE>;
279 - clocks = <&clk_s_c0_flexgen CLK_TX_ICN_DISP_0>;
280 + clocks = <&clk_s_c0_flexgen CLK_TX_ICN_DISP_0>,
281 + <&clk_s_c0_flexgen CLK_RX_ICN_DISP_0>;
282 resets = <&powerdown STIH407_USB2_PORT1_POWERDOWN>,
283 <&softreset STIH407_USB2_PORT1_SOFTRESET>;
284 reset-names = "power", "softreset";
285 @@ -87,7 +90,8 @@
286 interrupts = <GIC_SPI 153 IRQ_TYPE_NONE>;
287 pinctrl-names = "default";
288 pinctrl-0 = <&pinctrl_usb1>;
289 - clocks = <&clk_s_c0_flexgen CLK_TX_ICN_DISP_0>;
290 + clocks = <&clk_s_c0_flexgen CLK_TX_ICN_DISP_0>,
291 + <&clk_s_c0_flexgen CLK_RX_ICN_DISP_0>;
292 resets = <&powerdown STIH407_USB2_PORT1_POWERDOWN>,
293 <&softreset STIH407_USB2_PORT1_SOFTRESET>;
294 reset-names = "power", "softreset";
295 diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
296 index e06fd299de08..d7bef2144760 100644
297 --- a/arch/arm/kvm/arm.c
298 +++ b/arch/arm/kvm/arm.c
299 @@ -155,8 +155,6 @@ void kvm_arch_destroy_vm(struct kvm *kvm)
300 {
301 int i;
302
303 - kvm_free_stage2_pgd(kvm);
304 -
305 for (i = 0; i < KVM_MAX_VCPUS; ++i) {
306 if (kvm->vcpus[i]) {
307 kvm_arch_vcpu_free(kvm->vcpus[i]);
308 diff --git a/arch/arm/kvm/mmu.c b/arch/arm/kvm/mmu.c
309 index 12d727fae0a7..11b6595c2672 100644
310 --- a/arch/arm/kvm/mmu.c
311 +++ b/arch/arm/kvm/mmu.c
312 @@ -1852,6 +1852,7 @@ void kvm_arch_memslots_updated(struct kvm *kvm, struct kvm_memslots *slots)
313
314 void kvm_arch_flush_shadow_all(struct kvm *kvm)
315 {
316 + kvm_free_stage2_pgd(kvm);
317 }
318
319 void kvm_arch_flush_shadow_memslot(struct kvm *kvm,
320 diff --git a/arch/arm/mach-imx/pm-imx6.c b/arch/arm/mach-imx/pm-imx6.c
321 index 4470376af5f8..a19d20f23e71 100644
322 --- a/arch/arm/mach-imx/pm-imx6.c
323 +++ b/arch/arm/mach-imx/pm-imx6.c
324 @@ -295,7 +295,7 @@ int imx6_set_lpm(enum mxc_cpu_pwr_mode mode)
325 val &= ~BM_CLPCR_SBYOS;
326 if (cpu_is_imx6sl())
327 val |= BM_CLPCR_BYPASS_PMIC_READY;
328 - if (cpu_is_imx6sl() || cpu_is_imx6sx())
329 + if (cpu_is_imx6sl() || cpu_is_imx6sx() || cpu_is_imx6ul())
330 val |= BM_CLPCR_BYP_MMDC_CH0_LPM_HS;
331 else
332 val |= BM_CLPCR_BYP_MMDC_CH1_LPM_HS;
333 @@ -310,7 +310,7 @@ int imx6_set_lpm(enum mxc_cpu_pwr_mode mode)
334 val |= 0x3 << BP_CLPCR_STBY_COUNT;
335 val |= BM_CLPCR_VSTBY;
336 val |= BM_CLPCR_SBYOS;
337 - if (cpu_is_imx6sl())
338 + if (cpu_is_imx6sl() || cpu_is_imx6sx())
339 val |= BM_CLPCR_BYPASS_PMIC_READY;
340 if (cpu_is_imx6sl() || cpu_is_imx6sx() || cpu_is_imx6ul())
341 val |= BM_CLPCR_BYP_MMDC_CH0_LPM_HS;
342 diff --git a/arch/arm/mach-omap2/omap_hwmod_33xx_43xx_ipblock_data.c b/arch/arm/mach-omap2/omap_hwmod_33xx_43xx_ipblock_data.c
343 index 907a452b78ea..b31ad596be79 100644
344 --- a/arch/arm/mach-omap2/omap_hwmod_33xx_43xx_ipblock_data.c
345 +++ b/arch/arm/mach-omap2/omap_hwmod_33xx_43xx_ipblock_data.c
346 @@ -1474,6 +1474,7 @@ static void omap_hwmod_am43xx_rst(void)
347 {
348 RSTCTRL(am33xx_pruss_hwmod, AM43XX_RM_PER_RSTCTRL_OFFSET);
349 RSTCTRL(am33xx_gfx_hwmod, AM43XX_RM_GFX_RSTCTRL_OFFSET);
350 + RSTST(am33xx_pruss_hwmod, AM43XX_RM_PER_RSTST_OFFSET);
351 RSTST(am33xx_gfx_hwmod, AM43XX_RM_GFX_RSTST_OFFSET);
352 }
353
354 diff --git a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
355 index aff78d5198d2..131f8967589b 100644
356 --- a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
357 +++ b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
358 @@ -723,8 +723,20 @@ static struct omap_hwmod omap3xxx_dss_dispc_hwmod = {
359 * display serial interface controller
360 */
361
362 +static struct omap_hwmod_class_sysconfig omap3xxx_dsi_sysc = {
363 + .rev_offs = 0x0000,
364 + .sysc_offs = 0x0010,
365 + .syss_offs = 0x0014,
366 + .sysc_flags = (SYSC_HAS_AUTOIDLE | SYSC_HAS_CLOCKACTIVITY |
367 + SYSC_HAS_ENAWAKEUP | SYSC_HAS_SIDLEMODE |
368 + SYSC_HAS_SOFTRESET | SYSS_HAS_RESET_STATUS),
369 + .idlemodes = (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART),
370 + .sysc_fields = &omap_hwmod_sysc_type1,
371 +};
372 +
373 static struct omap_hwmod_class omap3xxx_dsi_hwmod_class = {
374 .name = "dsi",
375 + .sysc = &omap3xxx_dsi_sysc,
376 };
377
378 static struct omap_hwmod_irq_info omap3xxx_dsi1_irqs[] = {
379 diff --git a/arch/arm/mach-omap2/prcm43xx.h b/arch/arm/mach-omap2/prcm43xx.h
380 index 7c34c44eb0ae..babb5db5a3a4 100644
381 --- a/arch/arm/mach-omap2/prcm43xx.h
382 +++ b/arch/arm/mach-omap2/prcm43xx.h
383 @@ -39,6 +39,7 @@
384
385 /* RM RSTST offsets */
386 #define AM43XX_RM_GFX_RSTST_OFFSET 0x0014
387 +#define AM43XX_RM_PER_RSTST_OFFSET 0x0014
388 #define AM43XX_RM_WKUP_RSTST_OFFSET 0x0014
389
390 /* CM instances */
391 diff --git a/arch/arm64/include/asm/spinlock.h b/arch/arm64/include/asm/spinlock.h
392 index c85e96d174a5..499e8de33a00 100644
393 --- a/arch/arm64/include/asm/spinlock.h
394 +++ b/arch/arm64/include/asm/spinlock.h
395 @@ -312,4 +312,14 @@ static inline int arch_read_trylock(arch_rwlock_t *rw)
396 #define arch_read_relax(lock) cpu_relax()
397 #define arch_write_relax(lock) cpu_relax()
398
399 +/*
400 + * Accesses appearing in program order before a spin_lock() operation
401 + * can be reordered with accesses inside the critical section, by virtue
402 + * of arch_spin_lock being constructed using acquire semantics.
403 + *
404 + * In cases where this is problematic (e.g. try_to_wake_up), an
405 + * smp_mb__before_spinlock() can restore the required ordering.
406 + */
407 +#define smp_mb__before_spinlock() smp_mb()
408 +
409 #endif /* __ASM_SPINLOCK_H */
410 diff --git a/arch/avr32/include/asm/uaccess.h b/arch/avr32/include/asm/uaccess.h
411 index 68cf638faf48..b1ec1fa06463 100644
412 --- a/arch/avr32/include/asm/uaccess.h
413 +++ b/arch/avr32/include/asm/uaccess.h
414 @@ -74,7 +74,7 @@ extern __kernel_size_t __copy_user(void *to, const void *from,
415
416 extern __kernel_size_t copy_to_user(void __user *to, const void *from,
417 __kernel_size_t n);
418 -extern __kernel_size_t copy_from_user(void *to, const void __user *from,
419 +extern __kernel_size_t ___copy_from_user(void *to, const void __user *from,
420 __kernel_size_t n);
421
422 static inline __kernel_size_t __copy_to_user(void __user *to, const void *from,
423 @@ -88,6 +88,15 @@ static inline __kernel_size_t __copy_from_user(void *to,
424 {
425 return __copy_user(to, (const void __force *)from, n);
426 }
427 +static inline __kernel_size_t copy_from_user(void *to,
428 + const void __user *from,
429 + __kernel_size_t n)
430 +{
431 + size_t res = ___copy_from_user(to, from, n);
432 + if (unlikely(res))
433 + memset(to + (n - res), 0, res);
434 + return res;
435 +}
436
437 #define __copy_to_user_inatomic __copy_to_user
438 #define __copy_from_user_inatomic __copy_from_user
439 diff --git a/arch/avr32/kernel/avr32_ksyms.c b/arch/avr32/kernel/avr32_ksyms.c
440 index d93ead02daed..7c6cf14f0985 100644
441 --- a/arch/avr32/kernel/avr32_ksyms.c
442 +++ b/arch/avr32/kernel/avr32_ksyms.c
443 @@ -36,7 +36,7 @@ EXPORT_SYMBOL(copy_page);
444 /*
445 * Userspace access stuff.
446 */
447 -EXPORT_SYMBOL(copy_from_user);
448 +EXPORT_SYMBOL(___copy_from_user);
449 EXPORT_SYMBOL(copy_to_user);
450 EXPORT_SYMBOL(__copy_user);
451 EXPORT_SYMBOL(strncpy_from_user);
452 diff --git a/arch/avr32/lib/copy_user.S b/arch/avr32/lib/copy_user.S
453 index ea59c04b07de..075373471da1 100644
454 --- a/arch/avr32/lib/copy_user.S
455 +++ b/arch/avr32/lib/copy_user.S
456 @@ -23,13 +23,13 @@
457 */
458 .text
459 .align 1
460 - .global copy_from_user
461 - .type copy_from_user, @function
462 -copy_from_user:
463 + .global ___copy_from_user
464 + .type ___copy_from_user, @function
465 +___copy_from_user:
466 branch_if_kernel r8, __copy_user
467 ret_if_privileged r8, r11, r10, r10
468 rjmp __copy_user
469 - .size copy_from_user, . - copy_from_user
470 + .size ___copy_from_user, . - ___copy_from_user
471
472 .global copy_to_user
473 .type copy_to_user, @function
474 diff --git a/arch/blackfin/include/asm/uaccess.h b/arch/blackfin/include/asm/uaccess.h
475 index 90612a7f2cf3..8cd0184ea9ef 100644
476 --- a/arch/blackfin/include/asm/uaccess.h
477 +++ b/arch/blackfin/include/asm/uaccess.h
478 @@ -177,11 +177,12 @@ static inline int bad_user_access_length(void)
479 static inline unsigned long __must_check
480 copy_from_user(void *to, const void __user *from, unsigned long n)
481 {
482 - if (access_ok(VERIFY_READ, from, n))
483 + if (likely(access_ok(VERIFY_READ, from, n))) {
484 memcpy(to, (const void __force *)from, n);
485 - else
486 - return n;
487 - return 0;
488 + return 0;
489 + }
490 + memset(to, 0, n);
491 + return n;
492 }
493
494 static inline unsigned long __must_check
495 diff --git a/arch/cris/include/asm/uaccess.h b/arch/cris/include/asm/uaccess.h
496 index e3530d0f13ee..56c7d5750abd 100644
497 --- a/arch/cris/include/asm/uaccess.h
498 +++ b/arch/cris/include/asm/uaccess.h
499 @@ -194,30 +194,6 @@ extern unsigned long __copy_user(void __user *to, const void *from, unsigned lon
500 extern unsigned long __copy_user_zeroing(void *to, const void __user *from, unsigned long n);
501 extern unsigned long __do_clear_user(void __user *to, unsigned long n);
502
503 -static inline unsigned long
504 -__generic_copy_to_user(void __user *to, const void *from, unsigned long n)
505 -{
506 - if (access_ok(VERIFY_WRITE, to, n))
507 - return __copy_user(to, from, n);
508 - return n;
509 -}
510 -
511 -static inline unsigned long
512 -__generic_copy_from_user(void *to, const void __user *from, unsigned long n)
513 -{
514 - if (access_ok(VERIFY_READ, from, n))
515 - return __copy_user_zeroing(to, from, n);
516 - return n;
517 -}
518 -
519 -static inline unsigned long
520 -__generic_clear_user(void __user *to, unsigned long n)
521 -{
522 - if (access_ok(VERIFY_WRITE, to, n))
523 - return __do_clear_user(to, n);
524 - return n;
525 -}
526 -
527 static inline long
528 __strncpy_from_user(char *dst, const char __user *src, long count)
529 {
530 @@ -282,7 +258,7 @@ __constant_copy_from_user(void *to, const void __user *from, unsigned long n)
531 else if (n == 24)
532 __asm_copy_from_user_24(to, from, ret);
533 else
534 - ret = __generic_copy_from_user(to, from, n);
535 + ret = __copy_user_zeroing(to, from, n);
536
537 return ret;
538 }
539 @@ -333,7 +309,7 @@ __constant_copy_to_user(void __user *to, const void *from, unsigned long n)
540 else if (n == 24)
541 __asm_copy_to_user_24(to, from, ret);
542 else
543 - ret = __generic_copy_to_user(to, from, n);
544 + ret = __copy_user(to, from, n);
545
546 return ret;
547 }
548 @@ -366,26 +342,43 @@ __constant_clear_user(void __user *to, unsigned long n)
549 else if (n == 24)
550 __asm_clear_24(to, ret);
551 else
552 - ret = __generic_clear_user(to, n);
553 + ret = __do_clear_user(to, n);
554
555 return ret;
556 }
557
558
559 -#define clear_user(to, n) \
560 - (__builtin_constant_p(n) ? \
561 - __constant_clear_user(to, n) : \
562 - __generic_clear_user(to, n))
563 +static inline size_t clear_user(void __user *to, size_t n)
564 +{
565 + if (unlikely(!access_ok(VERIFY_WRITE, to, n)))
566 + return n;
567 + if (__builtin_constant_p(n))
568 + return __constant_clear_user(to, n);
569 + else
570 + return __do_clear_user(to, n);
571 +}
572
573 -#define copy_from_user(to, from, n) \
574 - (__builtin_constant_p(n) ? \
575 - __constant_copy_from_user(to, from, n) : \
576 - __generic_copy_from_user(to, from, n))
577 +static inline size_t copy_from_user(void *to, const void __user *from, size_t n)
578 +{
579 + if (unlikely(!access_ok(VERIFY_READ, from, n))) {
580 + memset(to, 0, n);
581 + return n;
582 + }
583 + if (__builtin_constant_p(n))
584 + return __constant_copy_from_user(to, from, n);
585 + else
586 + return __copy_user_zeroing(to, from, n);
587 +}
588
589 -#define copy_to_user(to, from, n) \
590 - (__builtin_constant_p(n) ? \
591 - __constant_copy_to_user(to, from, n) : \
592 - __generic_copy_to_user(to, from, n))
593 +static inline size_t copy_to_user(void __user *to, const void *from, size_t n)
594 +{
595 + if (unlikely(!access_ok(VERIFY_WRITE, to, n)))
596 + return n;
597 + if (__builtin_constant_p(n))
598 + return __constant_copy_to_user(to, from, n);
599 + else
600 + return __copy_user(to, from, n);
601 +}
602
603 /* We let the __ versions of copy_from/to_user inline, because they're often
604 * used in fast paths and have only a small space overhead.
605 diff --git a/arch/frv/include/asm/uaccess.h b/arch/frv/include/asm/uaccess.h
606 index 3ac9a59d65d4..87d9e34c5df8 100644
607 --- a/arch/frv/include/asm/uaccess.h
608 +++ b/arch/frv/include/asm/uaccess.h
609 @@ -263,19 +263,25 @@ do { \
610 extern long __memset_user(void *dst, unsigned long count);
611 extern long __memcpy_user(void *dst, const void *src, unsigned long count);
612
613 -#define clear_user(dst,count) __memset_user(____force(dst), (count))
614 +#define __clear_user(dst,count) __memset_user(____force(dst), (count))
615 #define __copy_from_user_inatomic(to, from, n) __memcpy_user((to), ____force(from), (n))
616 #define __copy_to_user_inatomic(to, from, n) __memcpy_user(____force(to), (from), (n))
617
618 #else
619
620 -#define clear_user(dst,count) (memset(____force(dst), 0, (count)), 0)
621 +#define __clear_user(dst,count) (memset(____force(dst), 0, (count)), 0)
622 #define __copy_from_user_inatomic(to, from, n) (memcpy((to), ____force(from), (n)), 0)
623 #define __copy_to_user_inatomic(to, from, n) (memcpy(____force(to), (from), (n)), 0)
624
625 #endif
626
627 -#define __clear_user clear_user
628 +static inline unsigned long __must_check
629 +clear_user(void __user *to, unsigned long n)
630 +{
631 + if (likely(__access_ok(to, n)))
632 + n = __clear_user(to, n);
633 + return n;
634 +}
635
636 static inline unsigned long __must_check
637 __copy_to_user(void __user *to, const void *from, unsigned long n)
638 diff --git a/arch/hexagon/include/asm/uaccess.h b/arch/hexagon/include/asm/uaccess.h
639 index f000a382bc7f..f61cfb28e9f2 100644
640 --- a/arch/hexagon/include/asm/uaccess.h
641 +++ b/arch/hexagon/include/asm/uaccess.h
642 @@ -103,7 +103,8 @@ static inline long hexagon_strncpy_from_user(char *dst, const char __user *src,
643 {
644 long res = __strnlen_user(src, n);
645
646 - /* return from strnlen can't be zero -- that would be rubbish. */
647 + if (unlikely(!res))
648 + return -EFAULT;
649
650 if (res > n) {
651 copy_from_user(dst, src, n);
652 diff --git a/arch/ia64/include/asm/uaccess.h b/arch/ia64/include/asm/uaccess.h
653 index 4f3fb6ccbf21..40c2027a2bf4 100644
654 --- a/arch/ia64/include/asm/uaccess.h
655 +++ b/arch/ia64/include/asm/uaccess.h
656 @@ -263,17 +263,15 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
657 __cu_len; \
658 })
659
660 -#define copy_from_user(to, from, n) \
661 -({ \
662 - void *__cu_to = (to); \
663 - const void __user *__cu_from = (from); \
664 - long __cu_len = (n); \
665 - \
666 - __chk_user_ptr(__cu_from); \
667 - if (__access_ok(__cu_from, __cu_len, get_fs())) \
668 - __cu_len = __copy_user((__force void __user *) __cu_to, __cu_from, __cu_len); \
669 - __cu_len; \
670 -})
671 +static inline unsigned long
672 +copy_from_user(void *to, const void __user *from, unsigned long n)
673 +{
674 + if (likely(__access_ok(from, n, get_fs())))
675 + n = __copy_user((__force void __user *) to, from, n);
676 + else
677 + memset(to, 0, n);
678 + return n;
679 +}
680
681 #define __copy_in_user(to, from, size) __copy_user((to), (from), (size))
682
683 diff --git a/arch/m32r/include/asm/uaccess.h b/arch/m32r/include/asm/uaccess.h
684 index cac7014daef3..6f8982157a75 100644
685 --- a/arch/m32r/include/asm/uaccess.h
686 +++ b/arch/m32r/include/asm/uaccess.h
687 @@ -219,7 +219,7 @@ extern int fixup_exception(struct pt_regs *regs);
688 #define __get_user_nocheck(x, ptr, size) \
689 ({ \
690 long __gu_err = 0; \
691 - unsigned long __gu_val; \
692 + unsigned long __gu_val = 0; \
693 might_fault(); \
694 __get_user_size(__gu_val, (ptr), (size), __gu_err); \
695 (x) = (__force __typeof__(*(ptr)))__gu_val; \
696 diff --git a/arch/metag/include/asm/uaccess.h b/arch/metag/include/asm/uaccess.h
697 index 8282cbce7e39..273e61225c27 100644
698 --- a/arch/metag/include/asm/uaccess.h
699 +++ b/arch/metag/include/asm/uaccess.h
700 @@ -204,8 +204,9 @@ extern unsigned long __must_check __copy_user_zeroing(void *to,
701 static inline unsigned long
702 copy_from_user(void *to, const void __user *from, unsigned long n)
703 {
704 - if (access_ok(VERIFY_READ, from, n))
705 + if (likely(access_ok(VERIFY_READ, from, n)))
706 return __copy_user_zeroing(to, from, n);
707 + memset(to, 0, n);
708 return n;
709 }
710
711 diff --git a/arch/microblaze/include/asm/uaccess.h b/arch/microblaze/include/asm/uaccess.h
712 index 331b0d35f89c..826676778094 100644
713 --- a/arch/microblaze/include/asm/uaccess.h
714 +++ b/arch/microblaze/include/asm/uaccess.h
715 @@ -227,7 +227,7 @@ extern long __user_bad(void);
716
717 #define __get_user(x, ptr) \
718 ({ \
719 - unsigned long __gu_val; \
720 + unsigned long __gu_val = 0; \
721 /*unsigned long __gu_ptr = (unsigned long)(ptr);*/ \
722 long __gu_err; \
723 switch (sizeof(*(ptr))) { \
724 @@ -373,10 +373,13 @@ extern long __user_bad(void);
725 static inline long copy_from_user(void *to,
726 const void __user *from, unsigned long n)
727 {
728 + unsigned long res = n;
729 might_fault();
730 - if (access_ok(VERIFY_READ, from, n))
731 - return __copy_from_user(to, from, n);
732 - return n;
733 + if (likely(access_ok(VERIFY_READ, from, n)))
734 + res = __copy_from_user(to, from, n);
735 + if (unlikely(res))
736 + memset(to + (n - res), 0, res);
737 + return res;
738 }
739
740 #define __copy_to_user(to, from, n) \
741 diff --git a/arch/mips/include/asm/uaccess.h b/arch/mips/include/asm/uaccess.h
742 index 095ecafe6bd3..c74c32ccc647 100644
743 --- a/arch/mips/include/asm/uaccess.h
744 +++ b/arch/mips/include/asm/uaccess.h
745 @@ -14,6 +14,7 @@
746 #include <linux/kernel.h>
747 #include <linux/errno.h>
748 #include <linux/thread_info.h>
749 +#include <linux/string.h>
750 #include <asm/asm-eva.h>
751
752 /*
753 @@ -1170,6 +1171,8 @@ extern size_t __copy_in_user_eva(void *__to, const void *__from, size_t __n);
754 __cu_len = __invoke_copy_from_user(__cu_to, \
755 __cu_from, \
756 __cu_len); \
757 + } else { \
758 + memset(__cu_to, 0, __cu_len); \
759 } \
760 } \
761 __cu_len; \
762 diff --git a/arch/mips/kvm/tlb.c b/arch/mips/kvm/tlb.c
763 index 7a7ed9ca01bb..eff71c75dc27 100644
764 --- a/arch/mips/kvm/tlb.c
765 +++ b/arch/mips/kvm/tlb.c
766 @@ -152,7 +152,7 @@ static int kvm_mips_map_page(struct kvm *kvm, gfn_t gfn)
767 srcu_idx = srcu_read_lock(&kvm->srcu);
768 pfn = kvm_mips_gfn_to_pfn(kvm, gfn);
769
770 - if (kvm_mips_is_error_pfn(pfn)) {
771 + if (is_error_noslot_pfn(pfn)) {
772 kvm_err("Couldn't get pfn for gfn %#" PRIx64 "!\n", gfn);
773 err = -EFAULT;
774 goto out;
775 diff --git a/arch/mn10300/include/asm/uaccess.h b/arch/mn10300/include/asm/uaccess.h
776 index 537278746a15..4af43d9ba495 100644
777 --- a/arch/mn10300/include/asm/uaccess.h
778 +++ b/arch/mn10300/include/asm/uaccess.h
779 @@ -181,6 +181,7 @@ struct __large_struct { unsigned long buf[100]; };
780 "2:\n" \
781 " .section .fixup,\"ax\"\n" \
782 "3:\n\t" \
783 + " mov 0,%1\n" \
784 " mov %3,%0\n" \
785 " jmp 2b\n" \
786 " .previous\n" \
787 diff --git a/arch/mn10300/lib/usercopy.c b/arch/mn10300/lib/usercopy.c
788 index 7826e6c364e7..ce8899e5e171 100644
789 --- a/arch/mn10300/lib/usercopy.c
790 +++ b/arch/mn10300/lib/usercopy.c
791 @@ -9,7 +9,7 @@
792 * as published by the Free Software Foundation; either version
793 * 2 of the Licence, or (at your option) any later version.
794 */
795 -#include <asm/uaccess.h>
796 +#include <linux/uaccess.h>
797
798 unsigned long
799 __generic_copy_to_user(void *to, const void *from, unsigned long n)
800 @@ -24,6 +24,8 @@ __generic_copy_from_user(void *to, const void *from, unsigned long n)
801 {
802 if (access_ok(VERIFY_READ, from, n))
803 __copy_user_zeroing(to, from, n);
804 + else
805 + memset(to, 0, n);
806 return n;
807 }
808
809 diff --git a/arch/nios2/include/asm/uaccess.h b/arch/nios2/include/asm/uaccess.h
810 index caa51ff85a3c..0ab82324c817 100644
811 --- a/arch/nios2/include/asm/uaccess.h
812 +++ b/arch/nios2/include/asm/uaccess.h
813 @@ -102,9 +102,12 @@ extern long __copy_to_user(void __user *to, const void *from, unsigned long n);
814 static inline long copy_from_user(void *to, const void __user *from,
815 unsigned long n)
816 {
817 - if (!access_ok(VERIFY_READ, from, n))
818 - return n;
819 - return __copy_from_user(to, from, n);
820 + unsigned long res = n;
821 + if (access_ok(VERIFY_READ, from, n))
822 + res = __copy_from_user(to, from, n);
823 + if (unlikely(res))
824 + memset(to + (n - res), 0, res);
825 + return res;
826 }
827
828 static inline long copy_to_user(void __user *to, const void *from,
829 @@ -139,7 +142,7 @@ extern long strnlen_user(const char __user *s, long n);
830
831 #define __get_user_unknown(val, size, ptr, err) do { \
832 err = 0; \
833 - if (copy_from_user(&(val), ptr, size)) { \
834 + if (__copy_from_user(&(val), ptr, size)) { \
835 err = -EFAULT; \
836 } \
837 } while (0)
838 @@ -166,7 +169,7 @@ do { \
839 ({ \
840 long __gu_err = -EFAULT; \
841 const __typeof__(*(ptr)) __user *__gu_ptr = (ptr); \
842 - unsigned long __gu_val; \
843 + unsigned long __gu_val = 0; \
844 __get_user_common(__gu_val, sizeof(*(ptr)), __gu_ptr, __gu_err);\
845 (x) = (__force __typeof__(x))__gu_val; \
846 __gu_err; \
847 diff --git a/arch/openrisc/include/asm/uaccess.h b/arch/openrisc/include/asm/uaccess.h
848 index a6bd07ca3d6c..5cc6b4f1b795 100644
849 --- a/arch/openrisc/include/asm/uaccess.h
850 +++ b/arch/openrisc/include/asm/uaccess.h
851 @@ -273,28 +273,20 @@ __copy_tofrom_user(void *to, const void *from, unsigned long size);
852 static inline unsigned long
853 copy_from_user(void *to, const void *from, unsigned long n)
854 {
855 - unsigned long over;
856 -
857 - if (access_ok(VERIFY_READ, from, n))
858 - return __copy_tofrom_user(to, from, n);
859 - if ((unsigned long)from < TASK_SIZE) {
860 - over = (unsigned long)from + n - TASK_SIZE;
861 - return __copy_tofrom_user(to, from, n - over) + over;
862 - }
863 - return n;
864 + unsigned long res = n;
865 +
866 + if (likely(access_ok(VERIFY_READ, from, n)))
867 + res = __copy_tofrom_user(to, from, n);
868 + if (unlikely(res))
869 + memset(to + (n - res), 0, res);
870 + return res;
871 }
872
873 static inline unsigned long
874 copy_to_user(void *to, const void *from, unsigned long n)
875 {
876 - unsigned long over;
877 -
878 - if (access_ok(VERIFY_WRITE, to, n))
879 - return __copy_tofrom_user(to, from, n);
880 - if ((unsigned long)to < TASK_SIZE) {
881 - over = (unsigned long)to + n - TASK_SIZE;
882 - return __copy_tofrom_user(to, from, n - over) + over;
883 - }
884 + if (likely(access_ok(VERIFY_WRITE, to, n)))
885 + n = __copy_tofrom_user(to, from, n);
886 return n;
887 }
888
889 @@ -303,13 +295,8 @@ extern unsigned long __clear_user(void *addr, unsigned long size);
890 static inline __must_check unsigned long
891 clear_user(void *addr, unsigned long size)
892 {
893 -
894 - if (access_ok(VERIFY_WRITE, addr, size))
895 - return __clear_user(addr, size);
896 - if ((unsigned long)addr < TASK_SIZE) {
897 - unsigned long over = (unsigned long)addr + size - TASK_SIZE;
898 - return __clear_user(addr, size - over) + over;
899 - }
900 + if (likely(access_ok(VERIFY_WRITE, addr, size)))
901 + size = __clear_user(addr, size);
902 return size;
903 }
904
905 diff --git a/arch/parisc/include/asm/uaccess.h b/arch/parisc/include/asm/uaccess.h
906 index 1960b87c1c8b..4ad51465890b 100644
907 --- a/arch/parisc/include/asm/uaccess.h
908 +++ b/arch/parisc/include/asm/uaccess.h
909 @@ -10,6 +10,7 @@
910 #include <asm-generic/uaccess-unaligned.h>
911
912 #include <linux/bug.h>
913 +#include <linux/string.h>
914
915 #define VERIFY_READ 0
916 #define VERIFY_WRITE 1
917 @@ -245,13 +246,14 @@ static inline unsigned long __must_check copy_from_user(void *to,
918 unsigned long n)
919 {
920 int sz = __compiletime_object_size(to);
921 - int ret = -EFAULT;
922 + unsigned long ret = n;
923
924 if (likely(sz == -1 || !__builtin_constant_p(n) || sz >= n))
925 ret = __copy_from_user(to, from, n);
926 else
927 copy_from_user_overflow();
928 -
929 + if (unlikely(ret))
930 + memset(to + (n - ret), 0, ret);
931 return ret;
932 }
933
934 diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
935 index 2a8ebae0936b..a5ffe0207c16 100644
936 --- a/arch/powerpc/include/asm/uaccess.h
937 +++ b/arch/powerpc/include/asm/uaccess.h
938 @@ -323,30 +323,17 @@ extern unsigned long __copy_tofrom_user(void __user *to,
939 static inline unsigned long copy_from_user(void *to,
940 const void __user *from, unsigned long n)
941 {
942 - unsigned long over;
943 -
944 - if (access_ok(VERIFY_READ, from, n))
945 + if (likely(access_ok(VERIFY_READ, from, n)))
946 return __copy_tofrom_user((__force void __user *)to, from, n);
947 - if ((unsigned long)from < TASK_SIZE) {
948 - over = (unsigned long)from + n - TASK_SIZE;
949 - return __copy_tofrom_user((__force void __user *)to, from,
950 - n - over) + over;
951 - }
952 + memset(to, 0, n);
953 return n;
954 }
955
956 static inline unsigned long copy_to_user(void __user *to,
957 const void *from, unsigned long n)
958 {
959 - unsigned long over;
960 -
961 if (access_ok(VERIFY_WRITE, to, n))
962 return __copy_tofrom_user(to, (__force void __user *)from, n);
963 - if ((unsigned long)to < TASK_SIZE) {
964 - over = (unsigned long)to + n - TASK_SIZE;
965 - return __copy_tofrom_user(to, (__force void __user *)from,
966 - n - over) + over;
967 - }
968 return n;
969 }
970
971 @@ -437,10 +424,6 @@ static inline unsigned long clear_user(void __user *addr, unsigned long size)
972 might_fault();
973 if (likely(access_ok(VERIFY_WRITE, addr, size)))
974 return __clear_user(addr, size);
975 - if ((unsigned long)addr < TASK_SIZE) {
976 - unsigned long over = (unsigned long)addr + size - TASK_SIZE;
977 - return __clear_user(addr, size - over) + over;
978 - }
979 return size;
980 }
981
982 diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S
983 index a94f155db78e..edba294620db 100644
984 --- a/arch/powerpc/kernel/entry_64.S
985 +++ b/arch/powerpc/kernel/entry_64.S
986 @@ -334,13 +334,13 @@ syscall_exit_work:
987 tabort_syscall:
988 /* Firstly we need to enable TM in the kernel */
989 mfmsr r10
990 - li r13, 1
991 - rldimi r10, r13, MSR_TM_LG, 63-MSR_TM_LG
992 + li r9, 1
993 + rldimi r10, r9, MSR_TM_LG, 63-MSR_TM_LG
994 mtmsrd r10, 0
995
996 /* tabort, this dooms the transaction, nothing else */
997 - li r13, (TM_CAUSE_SYSCALL|TM_CAUSE_PERSISTENT)
998 - TABORT(R13)
999 + li r9, (TM_CAUSE_SYSCALL|TM_CAUSE_PERSISTENT)
1000 + TABORT(R9)
1001
1002 /*
1003 * Return directly to userspace. We have corrupted user register state,
1004 @@ -348,8 +348,8 @@ tabort_syscall:
1005 * resume after the tbegin of the aborted transaction with the
1006 * checkpointed register state.
1007 */
1008 - li r13, MSR_RI
1009 - andc r10, r10, r13
1010 + li r9, MSR_RI
1011 + andc r10, r10, r9
1012 mtmsrd r10, 1
1013 mtspr SPRN_SRR0, r11
1014 mtspr SPRN_SRR1, r12
1015 diff --git a/arch/powerpc/mm/slb_low.S b/arch/powerpc/mm/slb_low.S
1016 index 736d18b3cefd..4c48b487698c 100644
1017 --- a/arch/powerpc/mm/slb_low.S
1018 +++ b/arch/powerpc/mm/slb_low.S
1019 @@ -113,7 +113,12 @@ BEGIN_FTR_SECTION
1020 END_MMU_FTR_SECTION_IFCLR(MMU_FTR_1T_SEGMENT)
1021 b slb_finish_load_1T
1022
1023 -0:
1024 +0: /*
1025 + * For userspace addresses, make sure this is region 0.
1026 + */
1027 + cmpdi r9, 0
1028 + bne 8f
1029 +
1030 /* when using slices, we extract the psize off the slice bitmaps
1031 * and then we need to get the sllp encoding off the mmu_psize_defs
1032 * array.
1033 diff --git a/arch/powerpc/platforms/powernv/opal-dump.c b/arch/powerpc/platforms/powernv/opal-dump.c
1034 index 2ee96431f736..4c827826c05e 100644
1035 --- a/arch/powerpc/platforms/powernv/opal-dump.c
1036 +++ b/arch/powerpc/platforms/powernv/opal-dump.c
1037 @@ -370,6 +370,7 @@ static irqreturn_t process_dump(int irq, void *data)
1038 uint32_t dump_id, dump_size, dump_type;
1039 struct dump_obj *dump;
1040 char name[22];
1041 + struct kobject *kobj;
1042
1043 rc = dump_read_info(&dump_id, &dump_size, &dump_type);
1044 if (rc != OPAL_SUCCESS)
1045 @@ -381,8 +382,12 @@ static irqreturn_t process_dump(int irq, void *data)
1046 * that gracefully and not create two conflicting
1047 * entries.
1048 */
1049 - if (kset_find_obj(dump_kset, name))
1050 + kobj = kset_find_obj(dump_kset, name);
1051 + if (kobj) {
1052 + /* Drop reference added by kset_find_obj() */
1053 + kobject_put(kobj);
1054 return 0;
1055 + }
1056
1057 dump = create_dump_obj(dump_id, dump_size, dump_type);
1058 if (!dump)
1059 diff --git a/arch/powerpc/platforms/powernv/opal-elog.c b/arch/powerpc/platforms/powernv/opal-elog.c
1060 index 37f959bf392e..f2344cbd2f46 100644
1061 --- a/arch/powerpc/platforms/powernv/opal-elog.c
1062 +++ b/arch/powerpc/platforms/powernv/opal-elog.c
1063 @@ -247,6 +247,7 @@ static irqreturn_t elog_event(int irq, void *data)
1064 uint64_t elog_type;
1065 int rc;
1066 char name[2+16+1];
1067 + struct kobject *kobj;
1068
1069 rc = opal_get_elog_size(&id, &size, &type);
1070 if (rc != OPAL_SUCCESS) {
1071 @@ -269,8 +270,12 @@ static irqreturn_t elog_event(int irq, void *data)
1072 * that gracefully and not create two conflicting
1073 * entries.
1074 */
1075 - if (kset_find_obj(elog_kset, name))
1076 + kobj = kset_find_obj(elog_kset, name);
1077 + if (kobj) {
1078 + /* Drop reference added by kset_find_obj() */
1079 + kobject_put(kobj);
1080 return IRQ_HANDLED;
1081 + }
1082
1083 create_elog_obj(log_id, elog_size, elog_type);
1084
1085 diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h
1086 index 9dd4cc47ddc7..5c7381c5ad7f 100644
1087 --- a/arch/s390/include/asm/uaccess.h
1088 +++ b/arch/s390/include/asm/uaccess.h
1089 @@ -215,28 +215,28 @@ int __put_user_bad(void) __attribute__((noreturn));
1090 __chk_user_ptr(ptr); \
1091 switch (sizeof(*(ptr))) { \
1092 case 1: { \
1093 - unsigned char __x; \
1094 + unsigned char __x = 0; \
1095 __gu_err = __get_user_fn(&__x, ptr, \
1096 sizeof(*(ptr))); \
1097 (x) = *(__force __typeof__(*(ptr)) *) &__x; \
1098 break; \
1099 }; \
1100 case 2: { \
1101 - unsigned short __x; \
1102 + unsigned short __x = 0; \
1103 __gu_err = __get_user_fn(&__x, ptr, \
1104 sizeof(*(ptr))); \
1105 (x) = *(__force __typeof__(*(ptr)) *) &__x; \
1106 break; \
1107 }; \
1108 case 4: { \
1109 - unsigned int __x; \
1110 + unsigned int __x = 0; \
1111 __gu_err = __get_user_fn(&__x, ptr, \
1112 sizeof(*(ptr))); \
1113 (x) = *(__force __typeof__(*(ptr)) *) &__x; \
1114 break; \
1115 }; \
1116 case 8: { \
1117 - unsigned long long __x; \
1118 + unsigned long long __x = 0; \
1119 __gu_err = __get_user_fn(&__x, ptr, \
1120 sizeof(*(ptr))); \
1121 (x) = *(__force __typeof__(*(ptr)) *) &__x; \
1122 diff --git a/arch/score/include/asm/uaccess.h b/arch/score/include/asm/uaccess.h
1123 index 20a3591225cc..01aec8ccde83 100644
1124 --- a/arch/score/include/asm/uaccess.h
1125 +++ b/arch/score/include/asm/uaccess.h
1126 @@ -163,7 +163,7 @@ do { \
1127 __get_user_asm(val, "lw", ptr); \
1128 break; \
1129 case 8: \
1130 - if ((copy_from_user((void *)&val, ptr, 8)) == 0) \
1131 + if (__copy_from_user((void *)&val, ptr, 8) == 0) \
1132 __gu_err = 0; \
1133 else \
1134 __gu_err = -EFAULT; \
1135 @@ -188,6 +188,8 @@ do { \
1136 \
1137 if (likely(access_ok(VERIFY_READ, __gu_ptr, size))) \
1138 __get_user_common((x), size, __gu_ptr); \
1139 + else \
1140 + (x) = 0; \
1141 \
1142 __gu_err; \
1143 })
1144 @@ -201,6 +203,7 @@ do { \
1145 "2:\n" \
1146 ".section .fixup,\"ax\"\n" \
1147 "3:li %0, %4\n" \
1148 + "li %1, 0\n" \
1149 "j 2b\n" \
1150 ".previous\n" \
1151 ".section __ex_table,\"a\"\n" \
1152 @@ -298,35 +301,34 @@ extern int __copy_tofrom_user(void *to, const void *from, unsigned long len);
1153 static inline unsigned long
1154 copy_from_user(void *to, const void *from, unsigned long len)
1155 {
1156 - unsigned long over;
1157 + unsigned long res = len;
1158
1159 - if (access_ok(VERIFY_READ, from, len))
1160 - return __copy_tofrom_user(to, from, len);
1161 + if (likely(access_ok(VERIFY_READ, from, len)))
1162 + res = __copy_tofrom_user(to, from, len);
1163
1164 - if ((unsigned long)from < TASK_SIZE) {
1165 - over = (unsigned long)from + len - TASK_SIZE;
1166 - return __copy_tofrom_user(to, from, len - over) + over;
1167 - }
1168 - return len;
1169 + if (unlikely(res))
1170 + memset(to + (len - res), 0, res);
1171 +
1172 + return res;
1173 }
1174
1175 static inline unsigned long
1176 copy_to_user(void *to, const void *from, unsigned long len)
1177 {
1178 - unsigned long over;
1179 -
1180 - if (access_ok(VERIFY_WRITE, to, len))
1181 - return __copy_tofrom_user(to, from, len);
1182 + if (likely(access_ok(VERIFY_WRITE, to, len)))
1183 + len = __copy_tofrom_user(to, from, len);
1184
1185 - if ((unsigned long)to < TASK_SIZE) {
1186 - over = (unsigned long)to + len - TASK_SIZE;
1187 - return __copy_tofrom_user(to, from, len - over) + over;
1188 - }
1189 return len;
1190 }
1191
1192 -#define __copy_from_user(to, from, len) \
1193 - __copy_tofrom_user((to), (from), (len))
1194 +static inline unsigned long
1195 +__copy_from_user(void *to, const void *from, unsigned long len)
1196 +{
1197 + unsigned long left = __copy_tofrom_user(to, from, len);
1198 + if (unlikely(left))
1199 + memset(to + (len - left), 0, left);
1200 + return left;
1201 +}
1202
1203 #define __copy_to_user(to, from, len) \
1204 __copy_tofrom_user((to), (from), (len))
1205 @@ -340,17 +342,17 @@ __copy_to_user_inatomic(void *to, const void *from, unsigned long len)
1206 static inline unsigned long
1207 __copy_from_user_inatomic(void *to, const void *from, unsigned long len)
1208 {
1209 - return __copy_from_user(to, from, len);
1210 + return __copy_tofrom_user(to, from, len);
1211 }
1212
1213 -#define __copy_in_user(to, from, len) __copy_from_user(to, from, len)
1214 +#define __copy_in_user(to, from, len) __copy_tofrom_user(to, from, len)
1215
1216 static inline unsigned long
1217 copy_in_user(void *to, const void *from, unsigned long len)
1218 {
1219 if (access_ok(VERIFY_READ, from, len) &&
1220 access_ok(VERFITY_WRITE, to, len))
1221 - return copy_from_user(to, from, len);
1222 + return __copy_tofrom_user(to, from, len);
1223 }
1224
1225 /*
1226 diff --git a/arch/sh/include/asm/uaccess.h b/arch/sh/include/asm/uaccess.h
1227 index a49635c51266..92ade79ac427 100644
1228 --- a/arch/sh/include/asm/uaccess.h
1229 +++ b/arch/sh/include/asm/uaccess.h
1230 @@ -151,7 +151,10 @@ copy_from_user(void *to, const void __user *from, unsigned long n)
1231 __kernel_size_t __copy_size = (__kernel_size_t) n;
1232
1233 if (__copy_size && __access_ok(__copy_from, __copy_size))
1234 - return __copy_user(to, from, __copy_size);
1235 + __copy_size = __copy_user(to, from, __copy_size);
1236 +
1237 + if (unlikely(__copy_size))
1238 + memset(to + (n - __copy_size), 0, __copy_size);
1239
1240 return __copy_size;
1241 }
1242 diff --git a/arch/sh/include/asm/uaccess_64.h b/arch/sh/include/asm/uaccess_64.h
1243 index c01376c76b86..ca5073dd4596 100644
1244 --- a/arch/sh/include/asm/uaccess_64.h
1245 +++ b/arch/sh/include/asm/uaccess_64.h
1246 @@ -24,6 +24,7 @@
1247 #define __get_user_size(x,ptr,size,retval) \
1248 do { \
1249 retval = 0; \
1250 + x = 0; \
1251 switch (size) { \
1252 case 1: \
1253 retval = __get_user_asm_b((void *)&x, \
1254 diff --git a/arch/sparc/include/asm/uaccess_32.h b/arch/sparc/include/asm/uaccess_32.h
1255 index 64ee103dc29d..dfb542c7cc71 100644
1256 --- a/arch/sparc/include/asm/uaccess_32.h
1257 +++ b/arch/sparc/include/asm/uaccess_32.h
1258 @@ -328,8 +328,10 @@ static inline unsigned long copy_from_user(void *to, const void __user *from, un
1259 {
1260 if (n && __access_ok((unsigned long) from, n))
1261 return __copy_user((__force void __user *) to, from, n);
1262 - else
1263 + else {
1264 + memset(to, 0, n);
1265 return n;
1266 + }
1267 }
1268
1269 static inline unsigned long __copy_from_user(void *to, const void __user *from, unsigned long n)
1270 diff --git a/arch/x86/configs/tiny.config b/arch/x86/configs/tiny.config
1271 index 4e2ecfa23c15..4b429df40d7a 100644
1272 --- a/arch/x86/configs/tiny.config
1273 +++ b/arch/x86/configs/tiny.config
1274 @@ -1 +1,3 @@
1275 CONFIG_NOHIGHMEM=y
1276 +# CONFIG_HIGHMEM4G is not set
1277 +# CONFIG_HIGHMEM64G is not set
1278 diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
1279 index 09b1b0ab94b7..d42252ce9b4d 100644
1280 --- a/arch/x86/include/asm/uaccess.h
1281 +++ b/arch/x86/include/asm/uaccess.h
1282 @@ -394,7 +394,11 @@ do { \
1283 #define __get_user_asm_ex(x, addr, itype, rtype, ltype) \
1284 asm volatile("1: mov"itype" %1,%"rtype"0\n" \
1285 "2:\n" \
1286 - _ASM_EXTABLE_EX(1b, 2b) \
1287 + ".section .fixup,\"ax\"\n" \
1288 + "3:xor"itype" %"rtype"0,%"rtype"0\n" \
1289 + " jmp 2b\n" \
1290 + ".previous\n" \
1291 + _ASM_EXTABLE_EX(1b, 3b) \
1292 : ltype(x) : "m" (__m(addr)))
1293
1294 #define __put_user_nocheck(x, ptr, size) \
1295 diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
1296 index a8816b325162..6cb5834062a3 100644
1297 --- a/arch/x86/kernel/cpu/amd.c
1298 +++ b/arch/x86/kernel/cpu/amd.c
1299 @@ -656,6 +656,17 @@ static void init_amd_gh(struct cpuinfo_x86 *c)
1300 set_cpu_bug(c, X86_BUG_AMD_TLB_MMATCH);
1301 }
1302
1303 +#define MSR_AMD64_DE_CFG 0xC0011029
1304 +
1305 +static void init_amd_ln(struct cpuinfo_x86 *c)
1306 +{
1307 + /*
1308 + * Apply erratum 665 fix unconditionally so machines without a BIOS
1309 + * fix work.
1310 + */
1311 + msr_set_bit(MSR_AMD64_DE_CFG, 31);
1312 +}
1313 +
1314 static void init_amd_bd(struct cpuinfo_x86 *c)
1315 {
1316 u64 value;
1317 @@ -713,6 +724,7 @@ static void init_amd(struct cpuinfo_x86 *c)
1318 case 6: init_amd_k7(c); break;
1319 case 0xf: init_amd_k8(c); break;
1320 case 0x10: init_amd_gh(c); break;
1321 + case 0x12: init_amd_ln(c); break;
1322 case 0x15: init_amd_bd(c); break;
1323 }
1324
1325 diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
1326 index c2130aef3f9d..f534a0e3af53 100644
1327 --- a/arch/x86/kernel/paravirt.c
1328 +++ b/arch/x86/kernel/paravirt.c
1329 @@ -55,12 +55,12 @@ asm (".pushsection .entry.text, \"ax\"\n"
1330 ".popsection");
1331
1332 /* identity function, which can be inlined */
1333 -u32 _paravirt_ident_32(u32 x)
1334 +u32 notrace _paravirt_ident_32(u32 x)
1335 {
1336 return x;
1337 }
1338
1339 -u64 _paravirt_ident_64(u64 x)
1340 +u64 notrace _paravirt_ident_64(u64 x)
1341 {
1342 return x;
1343 }
1344 diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
1345 index be222666b1c2..d7cb9577fa31 100644
1346 --- a/arch/x86/kvm/x86.c
1347 +++ b/arch/x86/kvm/x86.c
1348 @@ -2735,7 +2735,6 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
1349 }
1350
1351 kvm_make_request(KVM_REQ_STEAL_UPDATE, vcpu);
1352 - vcpu->arch.switch_db_regs |= KVM_DEBUGREG_RELOAD;
1353 }
1354
1355 void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu)
1356 diff --git a/crypto/cryptd.c b/crypto/cryptd.c
1357 index c81861b1350b..e7aa904cb20b 100644
1358 --- a/crypto/cryptd.c
1359 +++ b/crypto/cryptd.c
1360 @@ -594,9 +594,14 @@ static int cryptd_hash_export(struct ahash_request *req, void *out)
1361
1362 static int cryptd_hash_import(struct ahash_request *req, const void *in)
1363 {
1364 - struct cryptd_hash_request_ctx *rctx = ahash_request_ctx(req);
1365 + struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
1366 + struct cryptd_hash_ctx *ctx = crypto_ahash_ctx(tfm);
1367 + struct shash_desc *desc = cryptd_shash_desc(req);
1368 +
1369 + desc->tfm = ctx->child;
1370 + desc->flags = req->base.flags;
1371
1372 - return crypto_shash_import(&rctx->desc, in);
1373 + return crypto_shash_import(desc, in);
1374 }
1375
1376 static int cryptd_create_hash(struct crypto_template *tmpl, struct rtattr **tb,
1377 diff --git a/drivers/bus/arm-ccn.c b/drivers/bus/arm-ccn.c
1378 index 7082c7268845..0f54cb7ddcbb 100644
1379 --- a/drivers/bus/arm-ccn.c
1380 +++ b/drivers/bus/arm-ccn.c
1381 @@ -187,6 +187,7 @@ struct arm_ccn {
1382 struct arm_ccn_component *xp;
1383
1384 struct arm_ccn_dt dt;
1385 + int mn_id;
1386 };
1387
1388
1389 @@ -326,6 +327,7 @@ struct arm_ccn_pmu_event {
1390 static ssize_t arm_ccn_pmu_event_show(struct device *dev,
1391 struct device_attribute *attr, char *buf)
1392 {
1393 + struct arm_ccn *ccn = pmu_to_arm_ccn(dev_get_drvdata(dev));
1394 struct arm_ccn_pmu_event *event = container_of(attr,
1395 struct arm_ccn_pmu_event, attr);
1396 ssize_t res;
1397 @@ -352,6 +354,9 @@ static ssize_t arm_ccn_pmu_event_show(struct device *dev,
1398 res += snprintf(buf + res, PAGE_SIZE - res,
1399 ",cmp_l=?,cmp_h=?,mask=?");
1400 break;
1401 + case CCN_TYPE_MN:
1402 + res += snprintf(buf + res, PAGE_SIZE - res, ",node=%d", ccn->mn_id);
1403 + break;
1404 default:
1405 res += snprintf(buf + res, PAGE_SIZE - res, ",node=?");
1406 break;
1407 @@ -381,9 +386,9 @@ static umode_t arm_ccn_pmu_events_is_visible(struct kobject *kobj,
1408 }
1409
1410 static struct arm_ccn_pmu_event arm_ccn_pmu_events[] = {
1411 - CCN_EVENT_MN(eobarrier, "dir=0,vc=0,cmp_h=0x1c00", CCN_IDX_MASK_OPCODE),
1412 - CCN_EVENT_MN(ecbarrier, "dir=0,vc=0,cmp_h=0x1e00", CCN_IDX_MASK_OPCODE),
1413 - CCN_EVENT_MN(dvmop, "dir=0,vc=0,cmp_h=0x2800", CCN_IDX_MASK_OPCODE),
1414 + CCN_EVENT_MN(eobarrier, "dir=1,vc=0,cmp_h=0x1c00", CCN_IDX_MASK_OPCODE),
1415 + CCN_EVENT_MN(ecbarrier, "dir=1,vc=0,cmp_h=0x1e00", CCN_IDX_MASK_OPCODE),
1416 + CCN_EVENT_MN(dvmop, "dir=1,vc=0,cmp_h=0x2800", CCN_IDX_MASK_OPCODE),
1417 CCN_EVENT_HNI(txdatflits, "dir=1,vc=3", CCN_IDX_MASK_ANY),
1418 CCN_EVENT_HNI(rxdatflits, "dir=0,vc=3", CCN_IDX_MASK_ANY),
1419 CCN_EVENT_HNI(txreqflits, "dir=1,vc=0", CCN_IDX_MASK_ANY),
1420 @@ -757,6 +762,12 @@ static int arm_ccn_pmu_event_init(struct perf_event *event)
1421
1422 /* Validate node/xp vs topology */
1423 switch (type) {
1424 + case CCN_TYPE_MN:
1425 + if (node_xp != ccn->mn_id) {
1426 + dev_warn(ccn->dev, "Invalid MN ID %d!\n", node_xp);
1427 + return -EINVAL;
1428 + }
1429 + break;
1430 case CCN_TYPE_XP:
1431 if (node_xp >= ccn->num_xps) {
1432 dev_warn(ccn->dev, "Invalid XP ID %d!\n", node_xp);
1433 @@ -884,6 +895,10 @@ static void arm_ccn_pmu_xp_dt_config(struct perf_event *event, int enable)
1434 struct arm_ccn_component *xp;
1435 u32 val, dt_cfg;
1436
1437 + /* Nothing to do for cycle counter */
1438 + if (hw->idx == CCN_IDX_PMU_CYCLE_COUNTER)
1439 + return;
1440 +
1441 if (CCN_CONFIG_TYPE(event->attr.config) == CCN_TYPE_XP)
1442 xp = &ccn->xp[CCN_CONFIG_XP(event->attr.config)];
1443 else
1444 @@ -986,7 +1001,7 @@ static void arm_ccn_pmu_xp_watchpoint_config(struct perf_event *event)
1445
1446 /* Comparison values */
1447 writel(cmp_l & 0xffffffff, source->base + CCN_XP_DT_CMP_VAL_L(wp));
1448 - writel((cmp_l >> 32) & 0xefffffff,
1449 + writel((cmp_l >> 32) & 0x7fffffff,
1450 source->base + CCN_XP_DT_CMP_VAL_L(wp) + 4);
1451 writel(cmp_h & 0xffffffff, source->base + CCN_XP_DT_CMP_VAL_H(wp));
1452 writel((cmp_h >> 32) & 0x0fffffff,
1453 @@ -994,7 +1009,7 @@ static void arm_ccn_pmu_xp_watchpoint_config(struct perf_event *event)
1454
1455 /* Mask */
1456 writel(mask_l & 0xffffffff, source->base + CCN_XP_DT_CMP_MASK_L(wp));
1457 - writel((mask_l >> 32) & 0xefffffff,
1458 + writel((mask_l >> 32) & 0x7fffffff,
1459 source->base + CCN_XP_DT_CMP_MASK_L(wp) + 4);
1460 writel(mask_h & 0xffffffff, source->base + CCN_XP_DT_CMP_MASK_H(wp));
1461 writel((mask_h >> 32) & 0x0fffffff,
1462 @@ -1368,6 +1383,8 @@ static int arm_ccn_init_nodes(struct arm_ccn *ccn, int region,
1463
1464 switch (type) {
1465 case CCN_TYPE_MN:
1466 + ccn->mn_id = id;
1467 + return 0;
1468 case CCN_TYPE_DT:
1469 return 0;
1470 case CCN_TYPE_XP:
1471 diff --git a/drivers/clocksource/sun4i_timer.c b/drivers/clocksource/sun4i_timer.c
1472 index 6f3719d73390..e84877a2cacc 100644
1473 --- a/drivers/clocksource/sun4i_timer.c
1474 +++ b/drivers/clocksource/sun4i_timer.c
1475 @@ -123,12 +123,16 @@ static struct clock_event_device sun4i_clockevent = {
1476 .set_next_event = sun4i_clkevt_next_event,
1477 };
1478
1479 +static void sun4i_timer_clear_interrupt(void)
1480 +{
1481 + writel(TIMER_IRQ_EN(0), timer_base + TIMER_IRQ_ST_REG);
1482 +}
1483
1484 static irqreturn_t sun4i_timer_interrupt(int irq, void *dev_id)
1485 {
1486 struct clock_event_device *evt = (struct clock_event_device *)dev_id;
1487
1488 - writel(0x1, timer_base + TIMER_IRQ_ST_REG);
1489 + sun4i_timer_clear_interrupt();
1490 evt->event_handler(evt);
1491
1492 return IRQ_HANDLED;
1493 @@ -193,6 +197,9 @@ static void __init sun4i_timer_init(struct device_node *node)
1494 /* Make sure timer is stopped before playing with interrupts */
1495 sun4i_clkevt_time_stop(0);
1496
1497 + /* clear timer0 interrupt */
1498 + sun4i_timer_clear_interrupt();
1499 +
1500 sun4i_clockevent.cpumask = cpu_possible_mask;
1501 sun4i_clockevent.irq = irq;
1502
1503 diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
1504 index 59d1269626b1..e231176cb66b 100644
1505 --- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
1506 +++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
1507 @@ -316,19 +316,19 @@ atmel_hlcdc_plane_update_pos_and_size(struct atmel_hlcdc_plane *plane,
1508 u32 *coeff_tab = heo_upscaling_ycoef;
1509 u32 max_memsize;
1510
1511 - if (state->crtc_w < state->src_w)
1512 + if (state->crtc_h < state->src_h)
1513 coeff_tab = heo_downscaling_ycoef;
1514 for (i = 0; i < ARRAY_SIZE(heo_upscaling_ycoef); i++)
1515 atmel_hlcdc_layer_update_cfg(&plane->layer,
1516 33 + i,
1517 0xffffffff,
1518 coeff_tab[i]);
1519 - factor = ((8 * 256 * state->src_w) - (256 * 4)) /
1520 - state->crtc_w;
1521 + factor = ((8 * 256 * state->src_h) - (256 * 4)) /
1522 + state->crtc_h;
1523 factor++;
1524 - max_memsize = ((factor * state->crtc_w) + (256 * 4)) /
1525 + max_memsize = ((factor * state->crtc_h) + (256 * 4)) /
1526 2048;
1527 - if (max_memsize > state->src_w)
1528 + if (max_memsize > state->src_h)
1529 factor--;
1530 factor_reg |= (factor << 16) | 0x80000000;
1531 }
1532 diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
1533 index 57676f8d7ecf..a6289752be16 100644
1534 --- a/drivers/gpu/drm/drm_ioc32.c
1535 +++ b/drivers/gpu/drm/drm_ioc32.c
1536 @@ -1015,6 +1015,7 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
1537 return 0;
1538 }
1539
1540 +#if defined(CONFIG_X86) || defined(CONFIG_IA64)
1541 typedef struct drm_mode_fb_cmd232 {
1542 u32 fb_id;
1543 u32 width;
1544 @@ -1071,6 +1072,7 @@ static int compat_drm_mode_addfb2(struct file *file, unsigned int cmd,
1545
1546 return 0;
1547 }
1548 +#endif
1549
1550 static drm_ioctl_compat_t *drm_compat_ioctls[] = {
1551 [DRM_IOCTL_NR(DRM_IOCTL_VERSION32)] = compat_drm_version,
1552 @@ -1104,7 +1106,9 @@ static drm_ioctl_compat_t *drm_compat_ioctls[] = {
1553 [DRM_IOCTL_NR(DRM_IOCTL_UPDATE_DRAW32)] = compat_drm_update_draw,
1554 #endif
1555 [DRM_IOCTL_NR(DRM_IOCTL_WAIT_VBLANK32)] = compat_drm_wait_vblank,
1556 +#if defined(CONFIG_X86) || defined(CONFIG_IA64)
1557 [DRM_IOCTL_NR(DRM_IOCTL_MODE_ADDFB232)] = compat_drm_mode_addfb2,
1558 +#endif
1559 };
1560
1561 /**
1562 diff --git a/drivers/gpu/drm/gma500/cdv_intel_dp.c b/drivers/gpu/drm/gma500/cdv_intel_dp.c
1563 index 17cea400ae32..d3de377dc857 100644
1564 --- a/drivers/gpu/drm/gma500/cdv_intel_dp.c
1565 +++ b/drivers/gpu/drm/gma500/cdv_intel_dp.c
1566 @@ -220,7 +220,7 @@ i2c_dp_aux_prepare_bus(struct i2c_adapter *adapter)
1567 * FIXME: This is the old dp aux helper, gma500 is the last driver that needs to
1568 * be ported over to the new helper code in drm_dp_helper.c like i915 or radeon.
1569 */
1570 -static int __deprecated
1571 +static int
1572 i2c_dp_aux_add_bus(struct i2c_adapter *adapter)
1573 {
1574 int error;
1575 diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
1576 index a3254c3bcc7c..909d1d71d130 100644
1577 --- a/drivers/gpu/drm/i915/intel_display.c
1578 +++ b/drivers/gpu/drm/i915/intel_display.c
1579 @@ -2950,13 +2950,13 @@ u32 intel_fb_stride_alignment(struct drm_device *dev, uint64_t fb_modifier,
1580 }
1581 }
1582
1583 -unsigned long intel_plane_obj_offset(struct intel_plane *intel_plane,
1584 - struct drm_i915_gem_object *obj,
1585 - unsigned int plane)
1586 +u32 intel_plane_obj_offset(struct intel_plane *intel_plane,
1587 + struct drm_i915_gem_object *obj,
1588 + unsigned int plane)
1589 {
1590 const struct i915_ggtt_view *view = &i915_ggtt_view_normal;
1591 struct i915_vma *vma;
1592 - unsigned char *offset;
1593 + u64 offset;
1594
1595 if (intel_rotation_90_or_270(intel_plane->base.state->rotation))
1596 view = &i915_ggtt_view_rotated;
1597 @@ -2966,14 +2966,16 @@ unsigned long intel_plane_obj_offset(struct intel_plane *intel_plane,
1598 view->type))
1599 return -1;
1600
1601 - offset = (unsigned char *)vma->node.start;
1602 + offset = vma->node.start;
1603
1604 if (plane == 1) {
1605 offset += vma->ggtt_view.rotation_info.uv_start_page *
1606 PAGE_SIZE;
1607 }
1608
1609 - return (unsigned long)offset;
1610 + WARN_ON(upper_32_bits(offset));
1611 +
1612 + return lower_32_bits(offset);
1613 }
1614
1615 static void skl_detach_scaler(struct intel_crtc *intel_crtc, int id)
1616 @@ -3099,7 +3101,7 @@ static void skylake_update_primary_plane(struct drm_crtc *crtc,
1617 u32 tile_height, plane_offset, plane_size;
1618 unsigned int rotation;
1619 int x_offset, y_offset;
1620 - unsigned long surf_addr;
1621 + u32 surf_addr;
1622 struct intel_crtc_state *crtc_state = intel_crtc->config;
1623 struct intel_plane_state *plane_state;
1624 int src_x = 0, src_y = 0, src_w = 0, src_h = 0;
1625 diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
1626 index 67f72a7ee7cb..41442e619595 100644
1627 --- a/drivers/gpu/drm/i915/intel_drv.h
1628 +++ b/drivers/gpu/drm/i915/intel_drv.h
1629 @@ -1177,9 +1177,9 @@ void intel_modeset_preclose(struct drm_device *dev, struct drm_file *file);
1630 int skl_update_scaler_crtc(struct intel_crtc_state *crtc_state);
1631 int skl_max_scale(struct intel_crtc *crtc, struct intel_crtc_state *crtc_state);
1632
1633 -unsigned long intel_plane_obj_offset(struct intel_plane *intel_plane,
1634 - struct drm_i915_gem_object *obj,
1635 - unsigned int plane);
1636 +u32 intel_plane_obj_offset(struct intel_plane *intel_plane,
1637 + struct drm_i915_gem_object *obj,
1638 + unsigned int plane);
1639
1640 u32 skl_plane_ctl_format(uint32_t pixel_format);
1641 u32 skl_plane_ctl_tiling(uint64_t fb_modifier);
1642 diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c
1643 index 56dc132e8e20..2cc6aa072f4c 100644
1644 --- a/drivers/gpu/drm/i915/intel_sprite.c
1645 +++ b/drivers/gpu/drm/i915/intel_sprite.c
1646 @@ -195,7 +195,7 @@ skl_update_plane(struct drm_plane *drm_plane, struct drm_crtc *crtc,
1647 int pixel_size = drm_format_plane_cpp(fb->pixel_format, 0);
1648 const struct drm_intel_sprite_colorkey *key =
1649 &to_intel_plane_state(drm_plane->state)->ckey;
1650 - unsigned long surf_addr;
1651 + u32 surf_addr;
1652 u32 tile_height, plane_offset, plane_size;
1653 unsigned int rotation;
1654 int x_offset, y_offset;
1655 diff --git a/drivers/iio/accel/bmc150-accel-core.c b/drivers/iio/accel/bmc150-accel-core.c
1656 index 291c61a41c9a..fa24d5196615 100644
1657 --- a/drivers/iio/accel/bmc150-accel-core.c
1658 +++ b/drivers/iio/accel/bmc150-accel-core.c
1659 @@ -68,6 +68,9 @@
1660 #define BMC150_ACCEL_REG_PMU_BW 0x10
1661 #define BMC150_ACCEL_DEF_BW 125
1662
1663 +#define BMC150_ACCEL_REG_RESET 0x14
1664 +#define BMC150_ACCEL_RESET_VAL 0xB6
1665 +
1666 #define BMC150_ACCEL_REG_INT_MAP_0 0x19
1667 #define BMC150_ACCEL_INT_MAP_0_BIT_SLOPE BIT(2)
1668
1669 @@ -1487,6 +1490,14 @@ static int bmc150_accel_chip_init(struct bmc150_accel_data *data)
1670 int ret, i;
1671 unsigned int val;
1672
1673 + /*
1674 + * Reset chip to get it in a known good state. A delay of 1.8ms after
1675 + * reset is required according to the data sheets of supported chips.
1676 + */
1677 + regmap_write(data->regmap, BMC150_ACCEL_REG_RESET,
1678 + BMC150_ACCEL_RESET_VAL);
1679 + usleep_range(1800, 2500);
1680 +
1681 ret = regmap_read(data->regmap, BMC150_ACCEL_REG_CHIP_ID, &val);
1682 if (ret < 0) {
1683 dev_err(data->dev,
1684 diff --git a/drivers/iio/accel/kxsd9.c b/drivers/iio/accel/kxsd9.c
1685 index 3a9f106787d2..9d72d4bcf5e9 100644
1686 --- a/drivers/iio/accel/kxsd9.c
1687 +++ b/drivers/iio/accel/kxsd9.c
1688 @@ -160,11 +160,13 @@ static int kxsd9_read_raw(struct iio_dev *indio_dev,
1689 if (ret < 0)
1690 goto error_ret;
1691 *val = ret;
1692 + ret = IIO_VAL_INT;
1693 break;
1694 case IIO_CHAN_INFO_SCALE:
1695 ret = spi_w8r8(st->us, KXSD9_READ(KXSD9_REG_CTRL_C));
1696 if (ret < 0)
1697 goto error_ret;
1698 + *val = 0;
1699 *val2 = kxsd9_micro_scales[ret & KXSD9_FS_MASK];
1700 ret = IIO_VAL_INT_PLUS_MICRO;
1701 break;
1702 diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
1703 index 1e7aded53117..bda6bbe4479c 100644
1704 --- a/drivers/iio/adc/Kconfig
1705 +++ b/drivers/iio/adc/Kconfig
1706 @@ -306,6 +306,7 @@ config QCOM_SPMI_VADC
1707 config ROCKCHIP_SARADC
1708 tristate "Rockchip SARADC driver"
1709 depends on ARCH_ROCKCHIP || (ARM && COMPILE_TEST)
1710 + depends on RESET_CONTROLLER
1711 help
1712 Say yes here to build support for the SARADC found in SoCs from
1713 Rockchip.
1714 diff --git a/drivers/iio/adc/ad799x.c b/drivers/iio/adc/ad799x.c
1715 index 01d71588d752..ba82de25a797 100644
1716 --- a/drivers/iio/adc/ad799x.c
1717 +++ b/drivers/iio/adc/ad799x.c
1718 @@ -533,6 +533,7 @@ static struct attribute_group ad799x_event_attrs_group = {
1719 static const struct iio_info ad7991_info = {
1720 .read_raw = &ad799x_read_raw,
1721 .driver_module = THIS_MODULE,
1722 + .update_scan_mode = ad799x_update_scan_mode,
1723 };
1724
1725 static const struct iio_info ad7993_4_7_8_noirq_info = {
1726 diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
1727 index 7b40925dd4ff..93986f0590ef 100644
1728 --- a/drivers/iio/adc/at91_adc.c
1729 +++ b/drivers/iio/adc/at91_adc.c
1730 @@ -381,8 +381,8 @@ static irqreturn_t at91_adc_rl_interrupt(int irq, void *private)
1731 st->ts_bufferedmeasure = false;
1732 input_report_key(st->ts_input, BTN_TOUCH, 0);
1733 input_sync(st->ts_input);
1734 - } else if (status & AT91_ADC_EOC(3)) {
1735 - /* Conversion finished */
1736 + } else if (status & AT91_ADC_EOC(3) && st->ts_input) {
1737 + /* Conversion finished and we've a touchscreen */
1738 if (st->ts_bufferedmeasure) {
1739 /*
1740 * Last measurement is always discarded, since it can
1741 diff --git a/drivers/iio/adc/rockchip_saradc.c b/drivers/iio/adc/rockchip_saradc.c
1742 index 9c311c1e1ac7..dffff64b5989 100644
1743 --- a/drivers/iio/adc/rockchip_saradc.c
1744 +++ b/drivers/iio/adc/rockchip_saradc.c
1745 @@ -21,6 +21,8 @@
1746 #include <linux/of_device.h>
1747 #include <linux/clk.h>
1748 #include <linux/completion.h>
1749 +#include <linux/delay.h>
1750 +#include <linux/reset.h>
1751 #include <linux/regulator/consumer.h>
1752 #include <linux/iio/iio.h>
1753
1754 @@ -53,6 +55,7 @@ struct rockchip_saradc {
1755 struct clk *clk;
1756 struct completion completion;
1757 struct regulator *vref;
1758 + struct reset_control *reset;
1759 const struct rockchip_saradc_data *data;
1760 u16 last_val;
1761 };
1762 @@ -171,6 +174,16 @@ static const struct of_device_id rockchip_saradc_match[] = {
1763 };
1764 MODULE_DEVICE_TABLE(of, rockchip_saradc_match);
1765
1766 +/**
1767 + * Reset SARADC Controller.
1768 + */
1769 +static void rockchip_saradc_reset_controller(struct reset_control *reset)
1770 +{
1771 + reset_control_assert(reset);
1772 + usleep_range(10, 20);
1773 + reset_control_deassert(reset);
1774 +}
1775 +
1776 static int rockchip_saradc_probe(struct platform_device *pdev)
1777 {
1778 struct rockchip_saradc *info = NULL;
1779 @@ -199,6 +212,20 @@ static int rockchip_saradc_probe(struct platform_device *pdev)
1780 if (IS_ERR(info->regs))
1781 return PTR_ERR(info->regs);
1782
1783 + /*
1784 + * The reset should be an optional property, as it should work
1785 + * with old devicetrees as well
1786 + */
1787 + info->reset = devm_reset_control_get(&pdev->dev, "saradc-apb");
1788 + if (IS_ERR(info->reset)) {
1789 + ret = PTR_ERR(info->reset);
1790 + if (ret != -ENOENT)
1791 + return ret;
1792 +
1793 + dev_dbg(&pdev->dev, "no reset control found\n");
1794 + info->reset = NULL;
1795 + }
1796 +
1797 init_completion(&info->completion);
1798
1799 irq = platform_get_irq(pdev, 0);
1800 @@ -233,6 +260,9 @@ static int rockchip_saradc_probe(struct platform_device *pdev)
1801 return PTR_ERR(info->vref);
1802 }
1803
1804 + if (info->reset)
1805 + rockchip_saradc_reset_controller(info->reset);
1806 +
1807 /*
1808 * Use a default value for the converter clock.
1809 * This may become user-configurable in the future.
1810 diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c
1811 index c1e05532d437..0470fc843d4e 100644
1812 --- a/drivers/iio/adc/ti_am335x_adc.c
1813 +++ b/drivers/iio/adc/ti_am335x_adc.c
1814 @@ -32,6 +32,7 @@
1815
1816 struct tiadc_device {
1817 struct ti_tscadc_dev *mfd_tscadc;
1818 + struct mutex fifo1_lock; /* to protect fifo access */
1819 int channels;
1820 u8 channel_line[8];
1821 u8 channel_step[8];
1822 @@ -360,6 +361,7 @@ static int tiadc_read_raw(struct iio_dev *indio_dev,
1823 int *val, int *val2, long mask)
1824 {
1825 struct tiadc_device *adc_dev = iio_priv(indio_dev);
1826 + int ret = IIO_VAL_INT;
1827 int i, map_val;
1828 unsigned int fifo1count, read, stepid;
1829 bool found = false;
1830 @@ -373,13 +375,14 @@ static int tiadc_read_raw(struct iio_dev *indio_dev,
1831 if (!step_en)
1832 return -EINVAL;
1833
1834 + mutex_lock(&adc_dev->fifo1_lock);
1835 fifo1count = tiadc_readl(adc_dev, REG_FIFO1CNT);
1836 while (fifo1count--)
1837 tiadc_readl(adc_dev, REG_FIFO1);
1838
1839 am335x_tsc_se_set_once(adc_dev->mfd_tscadc, step_en);
1840
1841 - timeout = jiffies + usecs_to_jiffies
1842 + timeout = jiffies + msecs_to_jiffies
1843 (IDLE_TIMEOUT * adc_dev->channels);
1844 /* Wait for Fifo threshold interrupt */
1845 while (1) {
1846 @@ -389,7 +392,8 @@ static int tiadc_read_raw(struct iio_dev *indio_dev,
1847
1848 if (time_after(jiffies, timeout)) {
1849 am335x_tsc_se_adc_done(adc_dev->mfd_tscadc);
1850 - return -EAGAIN;
1851 + ret = -EAGAIN;
1852 + goto err_unlock;
1853 }
1854 }
1855 map_val = adc_dev->channel_step[chan->scan_index];
1856 @@ -415,8 +419,11 @@ static int tiadc_read_raw(struct iio_dev *indio_dev,
1857 am335x_tsc_se_adc_done(adc_dev->mfd_tscadc);
1858
1859 if (found == false)
1860 - return -EBUSY;
1861 - return IIO_VAL_INT;
1862 + ret = -EBUSY;
1863 +
1864 +err_unlock:
1865 + mutex_unlock(&adc_dev->fifo1_lock);
1866 + return ret;
1867 }
1868
1869 static const struct iio_info tiadc_info = {
1870 @@ -485,6 +492,7 @@ static int tiadc_probe(struct platform_device *pdev)
1871
1872 tiadc_step_config(indio_dev);
1873 tiadc_writel(adc_dev, REG_FIFO1THR, FIFO1_THRESHOLD);
1874 + mutex_init(&adc_dev->fifo1_lock);
1875
1876 err = tiadc_channel_init(indio_dev, adc_dev->channels);
1877 if (err < 0)
1878 diff --git a/drivers/iio/common/hid-sensors/hid-sensor-attributes.c b/drivers/iio/common/hid-sensors/hid-sensor-attributes.c
1879 index e81f434760f4..dc33c1dd5191 100644
1880 --- a/drivers/iio/common/hid-sensors/hid-sensor-attributes.c
1881 +++ b/drivers/iio/common/hid-sensors/hid-sensor-attributes.c
1882 @@ -56,8 +56,8 @@ static struct {
1883 {HID_USAGE_SENSOR_ALS, 0, 1, 0},
1884 {HID_USAGE_SENSOR_ALS, HID_USAGE_SENSOR_UNITS_LUX, 1, 0},
1885
1886 - {HID_USAGE_SENSOR_PRESSURE, 0, 100000, 0},
1887 - {HID_USAGE_SENSOR_PRESSURE, HID_USAGE_SENSOR_UNITS_PASCAL, 1, 0},
1888 + {HID_USAGE_SENSOR_PRESSURE, 0, 100, 0},
1889 + {HID_USAGE_SENSOR_PRESSURE, HID_USAGE_SENSOR_UNITS_PASCAL, 0, 1000},
1890 };
1891
1892 static int pow_10(unsigned power)
1893 diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
1894 index 7afd226a3321..32bb036069eb 100644
1895 --- a/drivers/iio/industrialio-buffer.c
1896 +++ b/drivers/iio/industrialio-buffer.c
1897 @@ -110,7 +110,7 @@ ssize_t iio_buffer_read_first_n_outer(struct file *filp, char __user *buf,
1898 DEFINE_WAIT_FUNC(wait, woken_wake_function);
1899 size_t datum_size;
1900 size_t to_wait;
1901 - int ret;
1902 + int ret = 0;
1903
1904 if (!indio_dev->info)
1905 return -ENODEV;
1906 @@ -153,7 +153,7 @@ ssize_t iio_buffer_read_first_n_outer(struct file *filp, char __user *buf,
1907 ret = rb->access->read_first_n(rb, n, buf);
1908 if (ret == 0 && (filp->f_flags & O_NONBLOCK))
1909 ret = -EAGAIN;
1910 - } while (ret == 0);
1911 + } while (ret == 0);
1912 remove_wait_queue(&rb->pollq, &wait);
1913
1914 return ret;
1915 diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
1916 index 159ede61f793..7ede941e9301 100644
1917 --- a/drivers/iio/industrialio-core.c
1918 +++ b/drivers/iio/industrialio-core.c
1919 @@ -447,9 +447,8 @@ ssize_t iio_format_value(char *buf, unsigned int type, int size, int *vals)
1920 return sprintf(buf, "%d.%09u\n", vals[0], vals[1]);
1921 case IIO_VAL_FRACTIONAL:
1922 tmp = div_s64((s64)vals[0] * 1000000000LL, vals[1]);
1923 - vals[1] = do_div(tmp, 1000000000LL);
1924 - vals[0] = tmp;
1925 - return sprintf(buf, "%d.%09u\n", vals[0], vals[1]);
1926 + vals[0] = (int)div_s64_rem(tmp, 1000000000, &vals[1]);
1927 + return sprintf(buf, "%d.%09u\n", vals[0], abs(vals[1]));
1928 case IIO_VAL_FRACTIONAL_LOG2:
1929 tmp = (s64)vals[0] * 1000000000LL >> vals[1];
1930 vals[1] = do_div(tmp, 1000000000LL);
1931 diff --git a/drivers/iio/proximity/as3935.c b/drivers/iio/proximity/as3935.c
1932 index e2f926cdcad2..a0aedda7dfd7 100644
1933 --- a/drivers/iio/proximity/as3935.c
1934 +++ b/drivers/iio/proximity/as3935.c
1935 @@ -392,7 +392,7 @@ static int as3935_probe(struct spi_device *spi)
1936 return ret;
1937 }
1938
1939 - ret = iio_triggered_buffer_setup(indio_dev, NULL,
1940 + ret = iio_triggered_buffer_setup(indio_dev, iio_pollfunc_store_time,
1941 &as3935_trigger_handler, NULL);
1942
1943 if (ret) {
1944 diff --git a/drivers/infiniband/core/uverbs.h b/drivers/infiniband/core/uverbs.h
1945 index 94bbd8c155fc..a2d19d136099 100644
1946 --- a/drivers/infiniband/core/uverbs.h
1947 +++ b/drivers/infiniband/core/uverbs.h
1948 @@ -116,6 +116,7 @@ struct ib_uverbs_event_file {
1949 struct ib_uverbs_file {
1950 struct kref ref;
1951 struct mutex mutex;
1952 + struct mutex cleanup_mutex; /* protect cleanup */
1953 struct ib_uverbs_device *device;
1954 struct ib_ucontext *ucontext;
1955 struct ib_event_handler event_handler;
1956 diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c
1957 index 24f3ca2c4ad7..d625c82d6c82 100644
1958 --- a/drivers/infiniband/core/uverbs_main.c
1959 +++ b/drivers/infiniband/core/uverbs_main.c
1960 @@ -922,6 +922,7 @@ static int ib_uverbs_open(struct inode *inode, struct file *filp)
1961 file->async_file = NULL;
1962 kref_init(&file->ref);
1963 mutex_init(&file->mutex);
1964 + mutex_init(&file->cleanup_mutex);
1965
1966 filp->private_data = file;
1967 kobject_get(&dev->kobj);
1968 @@ -947,18 +948,20 @@ static int ib_uverbs_close(struct inode *inode, struct file *filp)
1969 {
1970 struct ib_uverbs_file *file = filp->private_data;
1971 struct ib_uverbs_device *dev = file->device;
1972 - struct ib_ucontext *ucontext = NULL;
1973 +
1974 + mutex_lock(&file->cleanup_mutex);
1975 + if (file->ucontext) {
1976 + ib_uverbs_cleanup_ucontext(file, file->ucontext);
1977 + file->ucontext = NULL;
1978 + }
1979 + mutex_unlock(&file->cleanup_mutex);
1980
1981 mutex_lock(&file->device->lists_mutex);
1982 - ucontext = file->ucontext;
1983 - file->ucontext = NULL;
1984 if (!file->is_closed) {
1985 list_del(&file->list);
1986 file->is_closed = 1;
1987 }
1988 mutex_unlock(&file->device->lists_mutex);
1989 - if (ucontext)
1990 - ib_uverbs_cleanup_ucontext(file, ucontext);
1991
1992 if (file->async_file)
1993 kref_put(&file->async_file->ref, ib_uverbs_release_event_file);
1994 @@ -1172,22 +1175,30 @@ static void ib_uverbs_free_hw_resources(struct ib_uverbs_device *uverbs_dev,
1995 mutex_lock(&uverbs_dev->lists_mutex);
1996 while (!list_empty(&uverbs_dev->uverbs_file_list)) {
1997 struct ib_ucontext *ucontext;
1998 -
1999 file = list_first_entry(&uverbs_dev->uverbs_file_list,
2000 struct ib_uverbs_file, list);
2001 file->is_closed = 1;
2002 - ucontext = file->ucontext;
2003 list_del(&file->list);
2004 - file->ucontext = NULL;
2005 kref_get(&file->ref);
2006 mutex_unlock(&uverbs_dev->lists_mutex);
2007 - /* We must release the mutex before going ahead and calling
2008 - * disassociate_ucontext. disassociate_ucontext might end up
2009 - * indirectly calling uverbs_close, for example due to freeing
2010 - * the resources (e.g mmput).
2011 - */
2012 +
2013 ib_uverbs_event_handler(&file->event_handler, &event);
2014 +
2015 + mutex_lock(&file->cleanup_mutex);
2016 + ucontext = file->ucontext;
2017 + file->ucontext = NULL;
2018 + mutex_unlock(&file->cleanup_mutex);
2019 +
2020 + /* At this point ib_uverbs_close cannot be running
2021 + * ib_uverbs_cleanup_ucontext
2022 + */
2023 if (ucontext) {
2024 + /* We must release the mutex before going ahead and
2025 + * calling disassociate_ucontext. disassociate_ucontext
2026 + * might end up indirectly calling uverbs_close,
2027 + * for example due to freeing the resources
2028 + * (e.g mmput).
2029 + */
2030 ib_dev->disassociate_ucontext(ucontext);
2031 ib_uverbs_cleanup_ucontext(file, ucontext);
2032 }
2033 diff --git a/drivers/irqchip/irq-atmel-aic.c b/drivers/irqchip/irq-atmel-aic.c
2034 index 8a0c7f288198..981c3959da59 100644
2035 --- a/drivers/irqchip/irq-atmel-aic.c
2036 +++ b/drivers/irqchip/irq-atmel-aic.c
2037 @@ -176,6 +176,7 @@ static int aic_irq_domain_xlate(struct irq_domain *d,
2038 {
2039 struct irq_domain_chip_generic *dgc = d->gc;
2040 struct irq_chip_generic *gc;
2041 + unsigned long flags;
2042 unsigned smr;
2043 int idx;
2044 int ret;
2045 @@ -194,12 +195,12 @@ static int aic_irq_domain_xlate(struct irq_domain *d,
2046
2047 gc = dgc->gc[idx];
2048
2049 - irq_gc_lock(gc);
2050 + irq_gc_lock_irqsave(gc, flags);
2051 smr = irq_reg_readl(gc, AT91_AIC_SMR(*out_hwirq));
2052 ret = aic_common_set_priority(intspec[2], &smr);
2053 if (!ret)
2054 irq_reg_writel(gc, smr, AT91_AIC_SMR(*out_hwirq));
2055 - irq_gc_unlock(gc);
2056 + irq_gc_unlock_irqrestore(gc, flags);
2057
2058 return ret;
2059 }
2060 diff --git a/drivers/irqchip/irq-atmel-aic5.c b/drivers/irqchip/irq-atmel-aic5.c
2061 index 62bb840c613f..7dee71bde350 100644
2062 --- a/drivers/irqchip/irq-atmel-aic5.c
2063 +++ b/drivers/irqchip/irq-atmel-aic5.c
2064 @@ -258,6 +258,7 @@ static int aic5_irq_domain_xlate(struct irq_domain *d,
2065 unsigned int *out_type)
2066 {
2067 struct irq_chip_generic *bgc = irq_get_domain_generic_chip(d, 0);
2068 + unsigned long flags;
2069 unsigned smr;
2070 int ret;
2071
2072 @@ -269,13 +270,13 @@ static int aic5_irq_domain_xlate(struct irq_domain *d,
2073 if (ret)
2074 return ret;
2075
2076 - irq_gc_lock(bgc);
2077 + irq_gc_lock_irqsave(bgc, flags);
2078 irq_reg_writel(bgc, *out_hwirq, AT91_AIC5_SSR);
2079 smr = irq_reg_readl(bgc, AT91_AIC5_SMR);
2080 ret = aic_common_set_priority(intspec[2], &smr);
2081 if (!ret)
2082 irq_reg_writel(bgc, intspec[2] | smr, AT91_AIC5_SMR);
2083 - irq_gc_unlock(bgc);
2084 + irq_gc_unlock_irqrestore(bgc, flags);
2085
2086 return ret;
2087 }
2088 diff --git a/drivers/lightnvm/rrpc.c b/drivers/lightnvm/rrpc.c
2089 index a9859489acf6..596347f345db 100644
2090 --- a/drivers/lightnvm/rrpc.c
2091 +++ b/drivers/lightnvm/rrpc.c
2092 @@ -287,8 +287,10 @@ static int rrpc_move_valid_pages(struct rrpc *rrpc, struct rrpc_block *rblk)
2093 }
2094
2095 page = mempool_alloc(rrpc->page_pool, GFP_NOIO);
2096 - if (!page)
2097 + if (!page) {
2098 + bio_put(bio);
2099 return -ENOMEM;
2100 + }
2101
2102 while ((slot = find_first_zero_bit(rblk->invalid_pages,
2103 nr_pgs_per_blk)) < nr_pgs_per_blk) {
2104 diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
2105 index 3147c8d09ea8..51eda7235e32 100644
2106 --- a/drivers/md/dm-crypt.c
2107 +++ b/drivers/md/dm-crypt.c
2108 @@ -1920,6 +1920,13 @@ static int crypt_map(struct dm_target *ti, struct bio *bio)
2109 return DM_MAPIO_REMAPPED;
2110 }
2111
2112 + /*
2113 + * Check if bio is too large, split as needed.
2114 + */
2115 + if (unlikely(bio->bi_iter.bi_size > (BIO_MAX_PAGES << PAGE_SHIFT)) &&
2116 + bio_data_dir(bio) == WRITE)
2117 + dm_accept_partial_bio(bio, ((BIO_MAX_PAGES << PAGE_SHIFT) >> SECTOR_SHIFT));
2118 +
2119 io = dm_per_bio_data(bio, cc->per_bio_data_size);
2120 crypt_io_init(io, cc, bio, dm_target_offset(ti, bio->bi_iter.bi_sector));
2121 io->ctx.req = (struct ablkcipher_request *)(io + 1);
2122 diff --git a/drivers/md/dm-flakey.c b/drivers/md/dm-flakey.c
2123 index cd0a93df4cb7..8e9e928dafba 100644
2124 --- a/drivers/md/dm-flakey.c
2125 +++ b/drivers/md/dm-flakey.c
2126 @@ -289,15 +289,13 @@ static int flakey_map(struct dm_target *ti, struct bio *bio)
2127 pb->bio_submitted = true;
2128
2129 /*
2130 - * Map reads as normal only if corrupt_bio_byte set.
2131 + * Error reads if neither corrupt_bio_byte or drop_writes are set.
2132 + * Otherwise, flakey_end_io() will decide if the reads should be modified.
2133 */
2134 if (bio_data_dir(bio) == READ) {
2135 - /* If flags were specified, only corrupt those that match. */
2136 - if (fc->corrupt_bio_byte && (fc->corrupt_bio_rw == READ) &&
2137 - all_corrupt_bio_flags_match(bio, fc))
2138 - goto map_bio;
2139 - else
2140 + if (!fc->corrupt_bio_byte && !test_bit(DROP_WRITES, &fc->flags))
2141 return -EIO;
2142 + goto map_bio;
2143 }
2144
2145 /*
2146 @@ -334,14 +332,21 @@ static int flakey_end_io(struct dm_target *ti, struct bio *bio, int error)
2147 struct flakey_c *fc = ti->private;
2148 struct per_bio_data *pb = dm_per_bio_data(bio, sizeof(struct per_bio_data));
2149
2150 - /*
2151 - * Corrupt successful READs while in down state.
2152 - */
2153 if (!error && pb->bio_submitted && (bio_data_dir(bio) == READ)) {
2154 - if (fc->corrupt_bio_byte)
2155 + if (fc->corrupt_bio_byte && (fc->corrupt_bio_rw == READ) &&
2156 + all_corrupt_bio_flags_match(bio, fc)) {
2157 + /*
2158 + * Corrupt successful matching READs while in down state.
2159 + */
2160 corrupt_bio_data(bio, fc);
2161 - else
2162 +
2163 + } else if (!test_bit(DROP_WRITES, &fc->flags)) {
2164 + /*
2165 + * Error read during the down_interval if drop_writes
2166 + * wasn't configured.
2167 + */
2168 return -EIO;
2169 + }
2170 }
2171
2172 return error;
2173 diff --git a/drivers/md/dm-log-writes.c b/drivers/md/dm-log-writes.c
2174 index 624589d51c2c..d8956b4a7b09 100644
2175 --- a/drivers/md/dm-log-writes.c
2176 +++ b/drivers/md/dm-log-writes.c
2177 @@ -258,12 +258,12 @@ static int log_one_block(struct log_writes_c *lc,
2178 goto out;
2179 sector++;
2180
2181 + atomic_inc(&lc->io_blocks);
2182 bio = bio_alloc(GFP_KERNEL, block->vec_cnt);
2183 if (!bio) {
2184 DMERR("Couldn't alloc log bio");
2185 goto error;
2186 }
2187 - atomic_inc(&lc->io_blocks);
2188 bio->bi_iter.bi_size = 0;
2189 bio->bi_iter.bi_sector = sector;
2190 bio->bi_bdev = lc->logdev->bdev;
2191 @@ -456,9 +456,9 @@ static int log_writes_ctr(struct dm_target *ti, unsigned int argc, char **argv)
2192 goto bad;
2193 }
2194
2195 - ret = -EINVAL;
2196 lc->log_kthread = kthread_run(log_writes_kthread, lc, "log-write");
2197 - if (!lc->log_kthread) {
2198 + if (IS_ERR(lc->log_kthread)) {
2199 + ret = PTR_ERR(lc->log_kthread);
2200 ti->error = "Couldn't alloc kthread";
2201 dm_put_device(ti, lc->dev);
2202 dm_put_device(ti, lc->logdev);
2203 diff --git a/drivers/md/md.c b/drivers/md/md.c
2204 index c57fdf847b47..c1c7d4fb4b77 100644
2205 --- a/drivers/md/md.c
2206 +++ b/drivers/md/md.c
2207 @@ -7572,16 +7572,12 @@ EXPORT_SYMBOL(unregister_md_cluster_operations);
2208
2209 int md_setup_cluster(struct mddev *mddev, int nodes)
2210 {
2211 - int err;
2212 -
2213 - err = request_module("md-cluster");
2214 - if (err) {
2215 - pr_err("md-cluster module not found.\n");
2216 - return -ENOENT;
2217 - }
2218 -
2219 + if (!md_cluster_ops)
2220 + request_module("md-cluster");
2221 spin_lock(&pers_lock);
2222 + /* ensure module won't be unloaded */
2223 if (!md_cluster_ops || !try_module_get(md_cluster_mod)) {
2224 + pr_err("can't find md-cluster module or get it's reference.\n");
2225 spin_unlock(&pers_lock);
2226 return -ENOENT;
2227 }
2228 diff --git a/drivers/mmc/host/dw_mmc-pltfm.c b/drivers/mmc/host/dw_mmc-pltfm.c
2229 index 7e1d13b68b06..81bdeeb05a4d 100644
2230 --- a/drivers/mmc/host/dw_mmc-pltfm.c
2231 +++ b/drivers/mmc/host/dw_mmc-pltfm.c
2232 @@ -60,7 +60,7 @@ int dw_mci_pltfm_register(struct platform_device *pdev,
2233
2234 regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
2235 /* Get registers' physical base address */
2236 - host->phy_regs = (void *)(regs->start);
2237 + host->phy_regs = regs->start;
2238 host->regs = devm_ioremap_resource(&pdev->dev, regs);
2239 if (IS_ERR(host->regs))
2240 return PTR_ERR(host->regs);
2241 diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
2242 index 7a6cedbe48a8..fb204ee6ff89 100644
2243 --- a/drivers/mmc/host/dw_mmc.c
2244 +++ b/drivers/mmc/host/dw_mmc.c
2245 @@ -699,7 +699,7 @@ static int dw_mci_edmac_start_dma(struct dw_mci *host,
2246 int ret = 0;
2247
2248 /* Set external dma config: burst size, burst width */
2249 - cfg.dst_addr = (dma_addr_t)(host->phy_regs + fifo_offset);
2250 + cfg.dst_addr = host->phy_regs + fifo_offset;
2251 cfg.src_addr = cfg.dst_addr;
2252 cfg.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
2253 cfg.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
2254 diff --git a/drivers/net/ethernet/cavium/thunder/nic_reg.h b/drivers/net/ethernet/cavium/thunder/nic_reg.h
2255 index afb10e326b4f..fab35a593898 100644
2256 --- a/drivers/net/ethernet/cavium/thunder/nic_reg.h
2257 +++ b/drivers/net/ethernet/cavium/thunder/nic_reg.h
2258 @@ -170,7 +170,6 @@
2259 #define NIC_QSET_SQ_0_7_DOOR (0x010838)
2260 #define NIC_QSET_SQ_0_7_STATUS (0x010840)
2261 #define NIC_QSET_SQ_0_7_DEBUG (0x010848)
2262 -#define NIC_QSET_SQ_0_7_CNM_CHG (0x010860)
2263 #define NIC_QSET_SQ_0_7_STAT_0_1 (0x010900)
2264
2265 #define NIC_QSET_RBDR_0_1_CFG (0x010C00)
2266 diff --git a/drivers/net/ethernet/cavium/thunder/nicvf_ethtool.c b/drivers/net/ethernet/cavium/thunder/nicvf_ethtool.c
2267 index a12b2e38cf61..ff1d777f3ed9 100644
2268 --- a/drivers/net/ethernet/cavium/thunder/nicvf_ethtool.c
2269 +++ b/drivers/net/ethernet/cavium/thunder/nicvf_ethtool.c
2270 @@ -380,7 +380,10 @@ static void nicvf_get_regs(struct net_device *dev,
2271 p[i++] = nicvf_queue_reg_read(nic, NIC_QSET_SQ_0_7_DOOR, q);
2272 p[i++] = nicvf_queue_reg_read(nic, NIC_QSET_SQ_0_7_STATUS, q);
2273 p[i++] = nicvf_queue_reg_read(nic, NIC_QSET_SQ_0_7_DEBUG, q);
2274 - p[i++] = nicvf_queue_reg_read(nic, NIC_QSET_SQ_0_7_CNM_CHG, q);
2275 + /* Padding, was NIC_QSET_SQ_0_7_CNM_CHG, which
2276 + * produces bus errors when read
2277 + */
2278 + p[i++] = 0;
2279 p[i++] = nicvf_queue_reg_read(nic, NIC_QSET_SQ_0_7_STAT_0_1, q);
2280 reg_offset = NIC_QSET_SQ_0_7_STAT_0_1 | (1 << 3);
2281 p[i++] = nicvf_queue_reg_read(nic, reg_offset, q);
2282 diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
2283 index d184e682e636..8c5d2cf9c979 100644
2284 --- a/drivers/net/wireless/ath/ath9k/main.c
2285 +++ b/drivers/net/wireless/ath/ath9k/main.c
2286 @@ -1550,13 +1550,13 @@ static int ath9k_sta_state(struct ieee80211_hw *hw,
2287 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
2288 int ret = 0;
2289
2290 - if (old_state == IEEE80211_STA_AUTH &&
2291 - new_state == IEEE80211_STA_ASSOC) {
2292 + if (old_state == IEEE80211_STA_NOTEXIST &&
2293 + new_state == IEEE80211_STA_NONE) {
2294 ret = ath9k_sta_add(hw, vif, sta);
2295 ath_dbg(common, CONFIG,
2296 "Add station: %pM\n", sta->addr);
2297 - } else if (old_state == IEEE80211_STA_ASSOC &&
2298 - new_state == IEEE80211_STA_AUTH) {
2299 + } else if (old_state == IEEE80211_STA_NONE &&
2300 + new_state == IEEE80211_STA_NOTEXIST) {
2301 ret = ath9k_sta_remove(hw, vif, sta);
2302 ath_dbg(common, CONFIG,
2303 "Remove station: %pM\n", sta->addr);
2304 diff --git a/drivers/pinctrl/pinctrl-at91-pio4.c b/drivers/pinctrl/pinctrl-at91-pio4.c
2305 index b3235fd2950c..271cca63e9bd 100644
2306 --- a/drivers/pinctrl/pinctrl-at91-pio4.c
2307 +++ b/drivers/pinctrl/pinctrl-at91-pio4.c
2308 @@ -1002,7 +1002,7 @@ static int atmel_pinctrl_probe(struct platform_device *pdev)
2309 atmel_pioctrl->irqs[i] = res->start;
2310 irq_set_chained_handler(res->start, atmel_gpio_irq_handler);
2311 irq_set_handler_data(res->start, atmel_pioctrl);
2312 - dev_dbg(dev, "bank %i: hwirq=%u\n", i, res->start);
2313 + dev_dbg(dev, "bank %i: irq=%pr\n", i, res);
2314 }
2315
2316 atmel_pioctrl->irq_domain = irq_domain_add_linear(dev->of_node,
2317 diff --git a/drivers/pinctrl/pinctrl-pistachio.c b/drivers/pinctrl/pinctrl-pistachio.c
2318 index 6b1a47f8c096..98a459b1c095 100644
2319 --- a/drivers/pinctrl/pinctrl-pistachio.c
2320 +++ b/drivers/pinctrl/pinctrl-pistachio.c
2321 @@ -809,17 +809,17 @@ static const struct pistachio_pin_group pistachio_groups[] = {
2322 PADS_FUNCTION_SELECT2, 12, 0x3),
2323 MFIO_MUX_PIN_GROUP(83, MIPS_PLL_LOCK, MIPS_TRACE_DATA, USB_DEBUG,
2324 PADS_FUNCTION_SELECT2, 14, 0x3),
2325 - MFIO_MUX_PIN_GROUP(84, SYS_PLL_LOCK, MIPS_TRACE_DATA, USB_DEBUG,
2326 + MFIO_MUX_PIN_GROUP(84, AUDIO_PLL_LOCK, MIPS_TRACE_DATA, USB_DEBUG,
2327 PADS_FUNCTION_SELECT2, 16, 0x3),
2328 - MFIO_MUX_PIN_GROUP(85, WIFI_PLL_LOCK, MIPS_TRACE_DATA, SDHOST_DEBUG,
2329 + MFIO_MUX_PIN_GROUP(85, RPU_V_PLL_LOCK, MIPS_TRACE_DATA, SDHOST_DEBUG,
2330 PADS_FUNCTION_SELECT2, 18, 0x3),
2331 - MFIO_MUX_PIN_GROUP(86, BT_PLL_LOCK, MIPS_TRACE_DATA, SDHOST_DEBUG,
2332 + MFIO_MUX_PIN_GROUP(86, RPU_L_PLL_LOCK, MIPS_TRACE_DATA, SDHOST_DEBUG,
2333 PADS_FUNCTION_SELECT2, 20, 0x3),
2334 - MFIO_MUX_PIN_GROUP(87, RPU_V_PLL_LOCK, DREQ2, SOCIF_DEBUG,
2335 + MFIO_MUX_PIN_GROUP(87, SYS_PLL_LOCK, DREQ2, SOCIF_DEBUG,
2336 PADS_FUNCTION_SELECT2, 22, 0x3),
2337 - MFIO_MUX_PIN_GROUP(88, RPU_L_PLL_LOCK, DREQ3, SOCIF_DEBUG,
2338 + MFIO_MUX_PIN_GROUP(88, WIFI_PLL_LOCK, DREQ3, SOCIF_DEBUG,
2339 PADS_FUNCTION_SELECT2, 24, 0x3),
2340 - MFIO_MUX_PIN_GROUP(89, AUDIO_PLL_LOCK, DREQ4, DREQ5,
2341 + MFIO_MUX_PIN_GROUP(89, BT_PLL_LOCK, DREQ4, DREQ5,
2342 PADS_FUNCTION_SELECT2, 26, 0x3),
2343 PIN_GROUP(TCK, "tck"),
2344 PIN_GROUP(TRSTN, "trstn"),
2345 diff --git a/drivers/pinctrl/sunxi/pinctrl-sun8i-a23.c b/drivers/pinctrl/sunxi/pinctrl-sun8i-a23.c
2346 index 55083d278bb1..51fbf85301be 100644
2347 --- a/drivers/pinctrl/sunxi/pinctrl-sun8i-a23.c
2348 +++ b/drivers/pinctrl/sunxi/pinctrl-sun8i-a23.c
2349 @@ -485,12 +485,12 @@ static const struct sunxi_desc_pin sun8i_a23_pins[] = {
2350 SUNXI_PIN(SUNXI_PINCTRL_PIN(G, 8),
2351 SUNXI_FUNCTION(0x0, "gpio_in"),
2352 SUNXI_FUNCTION(0x1, "gpio_out"),
2353 - SUNXI_FUNCTION(0x2, "uart2"), /* RTS */
2354 + SUNXI_FUNCTION(0x2, "uart1"), /* RTS */
2355 SUNXI_FUNCTION_IRQ_BANK(0x4, 2, 8)), /* PG_EINT8 */
2356 SUNXI_PIN(SUNXI_PINCTRL_PIN(G, 9),
2357 SUNXI_FUNCTION(0x0, "gpio_in"),
2358 SUNXI_FUNCTION(0x1, "gpio_out"),
2359 - SUNXI_FUNCTION(0x2, "uart2"), /* CTS */
2360 + SUNXI_FUNCTION(0x2, "uart1"), /* CTS */
2361 SUNXI_FUNCTION_IRQ_BANK(0x4, 2, 9)), /* PG_EINT9 */
2362 SUNXI_PIN(SUNXI_PINCTRL_PIN(G, 10),
2363 SUNXI_FUNCTION(0x0, "gpio_in"),
2364 diff --git a/drivers/pinctrl/sunxi/pinctrl-sun8i-a33.c b/drivers/pinctrl/sunxi/pinctrl-sun8i-a33.c
2365 index 8b381d69df86..584cdedea7a4 100644
2366 --- a/drivers/pinctrl/sunxi/pinctrl-sun8i-a33.c
2367 +++ b/drivers/pinctrl/sunxi/pinctrl-sun8i-a33.c
2368 @@ -407,12 +407,12 @@ static const struct sunxi_desc_pin sun8i_a33_pins[] = {
2369 SUNXI_PIN(SUNXI_PINCTRL_PIN(G, 8),
2370 SUNXI_FUNCTION(0x0, "gpio_in"),
2371 SUNXI_FUNCTION(0x1, "gpio_out"),
2372 - SUNXI_FUNCTION(0x2, "uart2"), /* RTS */
2373 + SUNXI_FUNCTION(0x2, "uart1"), /* RTS */
2374 SUNXI_FUNCTION_IRQ_BANK(0x4, 1, 8)), /* PG_EINT8 */
2375 SUNXI_PIN(SUNXI_PINCTRL_PIN(G, 9),
2376 SUNXI_FUNCTION(0x0, "gpio_in"),
2377 SUNXI_FUNCTION(0x1, "gpio_out"),
2378 - SUNXI_FUNCTION(0x2, "uart2"), /* CTS */
2379 + SUNXI_FUNCTION(0x2, "uart1"), /* CTS */
2380 SUNXI_FUNCTION_IRQ_BANK(0x4, 1, 9)), /* PG_EINT9 */
2381 SUNXI_PIN(SUNXI_PINCTRL_PIN(G, 10),
2382 SUNXI_FUNCTION(0x0, "gpio_in"),
2383 diff --git a/drivers/soc/qcom/spm.c b/drivers/soc/qcom/spm.c
2384 index b04b05a0904e..65bce1eecaf8 100644
2385 --- a/drivers/soc/qcom/spm.c
2386 +++ b/drivers/soc/qcom/spm.c
2387 @@ -288,7 +288,7 @@ static struct spm_driver_data *spm_get_drv(struct platform_device *pdev,
2388 struct spm_driver_data *drv = NULL;
2389 struct device_node *cpu_node, *saw_node;
2390 int cpu;
2391 - bool found;
2392 + bool found = 0;
2393
2394 for_each_possible_cpu(cpu) {
2395 cpu_node = of_cpu_device_node_get(cpu);
2396 diff --git a/drivers/tty/serial/8250/8250_mid.c b/drivers/tty/serial/8250/8250_mid.c
2397 index ed489880e62b..83b3988eb6b2 100644
2398 --- a/drivers/tty/serial/8250/8250_mid.c
2399 +++ b/drivers/tty/serial/8250/8250_mid.c
2400 @@ -149,6 +149,9 @@ static void mid8250_set_termios(struct uart_port *p,
2401 unsigned long w = BIT(24) - 1;
2402 unsigned long mul, div;
2403
2404 + /* Gracefully handle the B0 case: fall back to B9600 */
2405 + fuart = fuart ? fuart : 9600 * 16;
2406 +
2407 if (mid->board->freq < fuart) {
2408 /* Find prescaler value that satisfies Fuart < Fref */
2409 if (mid->board->freq > baud)
2410 diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c
2411 index c1d4a8fa9be8..029de3f99752 100644
2412 --- a/drivers/tty/serial/8250/8250_pci.c
2413 +++ b/drivers/tty/serial/8250/8250_pci.c
2414 @@ -1952,6 +1952,43 @@ pci_wch_ch38x_setup(struct serial_private *priv,
2415 #define PCI_DEVICE_ID_PERICOM_PI7C9X7954 0x7954
2416 #define PCI_DEVICE_ID_PERICOM_PI7C9X7958 0x7958
2417
2418 +#define PCI_VENDOR_ID_ACCESIO 0x494f
2419 +#define PCI_DEVICE_ID_ACCESIO_PCIE_COM_2SDB 0x1051
2420 +#define PCI_DEVICE_ID_ACCESIO_MPCIE_COM_2S 0x1053
2421 +#define PCI_DEVICE_ID_ACCESIO_PCIE_COM_4SDB 0x105C
2422 +#define PCI_DEVICE_ID_ACCESIO_MPCIE_COM_4S 0x105E
2423 +#define PCI_DEVICE_ID_ACCESIO_PCIE_COM232_2DB 0x1091
2424 +#define PCI_DEVICE_ID_ACCESIO_MPCIE_COM232_2 0x1093
2425 +#define PCI_DEVICE_ID_ACCESIO_PCIE_COM232_4DB 0x1099
2426 +#define PCI_DEVICE_ID_ACCESIO_MPCIE_COM232_4 0x109B
2427 +#define PCI_DEVICE_ID_ACCESIO_PCIE_COM_2SMDB 0x10D1
2428 +#define PCI_DEVICE_ID_ACCESIO_MPCIE_COM_2SM 0x10D3
2429 +#define PCI_DEVICE_ID_ACCESIO_PCIE_COM_4SMDB 0x10DA
2430 +#define PCI_DEVICE_ID_ACCESIO_MPCIE_COM_4SM 0x10DC
2431 +#define PCI_DEVICE_ID_ACCESIO_MPCIE_ICM485_1 0x1108
2432 +#define PCI_DEVICE_ID_ACCESIO_MPCIE_ICM422_2 0x1110
2433 +#define PCI_DEVICE_ID_ACCESIO_MPCIE_ICM485_2 0x1111
2434 +#define PCI_DEVICE_ID_ACCESIO_MPCIE_ICM422_4 0x1118
2435 +#define PCI_DEVICE_ID_ACCESIO_MPCIE_ICM485_4 0x1119
2436 +#define PCI_DEVICE_ID_ACCESIO_PCIE_ICM_2S 0x1152
2437 +#define PCI_DEVICE_ID_ACCESIO_PCIE_ICM_4S 0x115A
2438 +#define PCI_DEVICE_ID_ACCESIO_PCIE_ICM232_2 0x1190
2439 +#define PCI_DEVICE_ID_ACCESIO_MPCIE_ICM232_2 0x1191
2440 +#define PCI_DEVICE_ID_ACCESIO_PCIE_ICM232_4 0x1198
2441 +#define PCI_DEVICE_ID_ACCESIO_MPCIE_ICM232_4 0x1199
2442 +#define PCI_DEVICE_ID_ACCESIO_PCIE_ICM_2SM 0x11D0
2443 +#define PCI_DEVICE_ID_ACCESIO_PCIE_COM422_4 0x105A
2444 +#define PCI_DEVICE_ID_ACCESIO_PCIE_COM485_4 0x105B
2445 +#define PCI_DEVICE_ID_ACCESIO_PCIE_COM422_8 0x106A
2446 +#define PCI_DEVICE_ID_ACCESIO_PCIE_COM485_8 0x106B
2447 +#define PCI_DEVICE_ID_ACCESIO_PCIE_COM232_4 0x1098
2448 +#define PCI_DEVICE_ID_ACCESIO_PCIE_COM232_8 0x10A9
2449 +#define PCI_DEVICE_ID_ACCESIO_PCIE_COM_4SM 0x10D9
2450 +#define PCI_DEVICE_ID_ACCESIO_PCIE_COM_8SM 0x10E9
2451 +#define PCI_DEVICE_ID_ACCESIO_PCIE_ICM_4SM 0x11D8
2452 +
2453 +
2454 +
2455 /* Unknown vendors/cards - this should not be in linux/pci_ids.h */
2456 #define PCI_SUBDEVICE_ID_UNKNOWN_0x1584 0x1584
2457 #define PCI_SUBDEVICE_ID_UNKNOWN_0x1588 0x1588
2458 @@ -5120,6 +5157,108 @@ static struct pci_device_id serial_pci_tbl[] = {
2459 0,
2460 0, pbn_pericom_PI7C9X7958 },
2461 /*
2462 + * ACCES I/O Products quad
2463 + */
2464 + { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM_2SDB,
2465 + PCI_ANY_ID, PCI_ANY_ID, 0, 0,
2466 + pbn_pericom_PI7C9X7954 },
2467 + { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_COM_2S,
2468 + PCI_ANY_ID, PCI_ANY_ID, 0, 0,
2469 + pbn_pericom_PI7C9X7954 },
2470 + { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM_4SDB,
2471 + PCI_ANY_ID, PCI_ANY_ID, 0, 0,
2472 + pbn_pericom_PI7C9X7954 },
2473 + { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_COM_4S,
2474 + PCI_ANY_ID, PCI_ANY_ID, 0, 0,
2475 + pbn_pericom_PI7C9X7954 },
2476 + { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM232_2DB,
2477 + PCI_ANY_ID, PCI_ANY_ID, 0, 0,
2478 + pbn_pericom_PI7C9X7954 },
2479 + { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_COM232_2,
2480 + PCI_ANY_ID, PCI_ANY_ID, 0, 0,
2481 + pbn_pericom_PI7C9X7954 },
2482 + { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM232_4DB,
2483 + PCI_ANY_ID, PCI_ANY_ID, 0, 0,
2484 + pbn_pericom_PI7C9X7954 },
2485 + { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_COM232_4,
2486 + PCI_ANY_ID, PCI_ANY_ID, 0, 0,
2487 + pbn_pericom_PI7C9X7954 },
2488 + { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM_2SMDB,
2489 + PCI_ANY_ID, PCI_ANY_ID, 0, 0,
2490 + pbn_pericom_PI7C9X7954 },
2491 + { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_COM_2SM,
2492 + PCI_ANY_ID, PCI_ANY_ID, 0, 0,
2493 + pbn_pericom_PI7C9X7954 },
2494 + { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM_4SMDB,
2495 + PCI_ANY_ID, PCI_ANY_ID, 0, 0,
2496 + pbn_pericom_PI7C9X7954 },
2497 + { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_COM_4SM,
2498 + PCI_ANY_ID, PCI_ANY_ID, 0, 0,
2499 + pbn_pericom_PI7C9X7954 },
2500 + { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_ICM485_1,
2501 + PCI_ANY_ID, PCI_ANY_ID, 0, 0,
2502 + pbn_pericom_PI7C9X7954 },
2503 + { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_ICM422_2,
2504 + PCI_ANY_ID, PCI_ANY_ID, 0, 0,
2505 + pbn_pericom_PI7C9X7954 },
2506 + { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_ICM485_2,
2507 + PCI_ANY_ID, PCI_ANY_ID, 0, 0,
2508 + pbn_pericom_PI7C9X7954 },
2509 + { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_ICM422_4,
2510 + PCI_ANY_ID, PCI_ANY_ID, 0, 0,
2511 + pbn_pericom_PI7C9X7954 },
2512 + { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_ICM485_4,
2513 + PCI_ANY_ID, PCI_ANY_ID, 0, 0,
2514 + pbn_pericom_PI7C9X7954 },
2515 + { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_ICM_2S,
2516 + PCI_ANY_ID, PCI_ANY_ID, 0, 0,
2517 + pbn_pericom_PI7C9X7954 },
2518 + { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_ICM_4S,
2519 + PCI_ANY_ID, PCI_ANY_ID, 0, 0,
2520 + pbn_pericom_PI7C9X7954 },
2521 + { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_ICM232_2,
2522 + PCI_ANY_ID, PCI_ANY_ID, 0, 0,
2523 + pbn_pericom_PI7C9X7954 },
2524 + { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_ICM232_2,
2525 + PCI_ANY_ID, PCI_ANY_ID, 0, 0,
2526 + pbn_pericom_PI7C9X7954 },
2527 + { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_ICM232_4,
2528 + PCI_ANY_ID, PCI_ANY_ID, 0, 0,
2529 + pbn_pericom_PI7C9X7954 },
2530 + { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_MPCIE_ICM232_4,
2531 + PCI_ANY_ID, PCI_ANY_ID, 0, 0,
2532 + pbn_pericom_PI7C9X7954 },
2533 + { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_ICM_2SM,
2534 + PCI_ANY_ID, PCI_ANY_ID, 0, 0,
2535 + pbn_pericom_PI7C9X7954 },
2536 + { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM422_4,
2537 + PCI_ANY_ID, PCI_ANY_ID, 0, 0,
2538 + pbn_pericom_PI7C9X7958 },
2539 + { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM485_4,
2540 + PCI_ANY_ID, PCI_ANY_ID, 0, 0,
2541 + pbn_pericom_PI7C9X7958 },
2542 + { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM422_8,
2543 + PCI_ANY_ID, PCI_ANY_ID, 0, 0,
2544 + pbn_pericom_PI7C9X7958 },
2545 + { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM485_8,
2546 + PCI_ANY_ID, PCI_ANY_ID, 0, 0,
2547 + pbn_pericom_PI7C9X7958 },
2548 + { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM232_4,
2549 + PCI_ANY_ID, PCI_ANY_ID, 0, 0,
2550 + pbn_pericom_PI7C9X7958 },
2551 + { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM232_8,
2552 + PCI_ANY_ID, PCI_ANY_ID, 0, 0,
2553 + pbn_pericom_PI7C9X7958 },
2554 + { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM_4SM,
2555 + PCI_ANY_ID, PCI_ANY_ID, 0, 0,
2556 + pbn_pericom_PI7C9X7958 },
2557 + { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_COM_8SM,
2558 + PCI_ANY_ID, PCI_ANY_ID, 0, 0,
2559 + pbn_pericom_PI7C9X7958 },
2560 + { PCI_VENDOR_ID_ACCESIO, PCI_DEVICE_ID_ACCESIO_PCIE_ICM_4SM,
2561 + PCI_ANY_ID, PCI_ANY_ID, 0, 0,
2562 + pbn_pericom_PI7C9X7958 },
2563 + /*
2564 * Topic TP560 Data/Fax/Voice 56k modem (reported by Evan Clarke)
2565 */
2566 { PCI_VENDOR_ID_TOPIC, PCI_DEVICE_ID_TOPIC_TP560,
2567 diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
2568 index ca367b05e440..68fc5fce4cc5 100644
2569 --- a/drivers/usb/chipidea/udc.c
2570 +++ b/drivers/usb/chipidea/udc.c
2571 @@ -939,6 +939,15 @@ static int isr_setup_status_phase(struct ci_hdrc *ci)
2572 int retval;
2573 struct ci_hw_ep *hwep;
2574
2575 + /*
2576 + * Unexpected USB controller behavior, caused by bad signal integrity
2577 + * or ground reference problems, can lead to isr_setup_status_phase
2578 + * being called with ci->status equal to NULL.
2579 + * If this situation occurs, you should review your USB hardware design.
2580 + */
2581 + if (WARN_ON_ONCE(!ci->status))
2582 + return -EPIPE;
2583 +
2584 hwep = (ci->ep0_dir == TX) ? ci->ep0out : ci->ep0in;
2585 ci->status->context = ci;
2586 ci->status->complete = isr_setup_status_complete;
2587 diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
2588 index 80c8d90d8b75..ff44cfa26af8 100644
2589 --- a/drivers/usb/core/config.c
2590 +++ b/drivers/usb/core/config.c
2591 @@ -211,8 +211,10 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno, int inum,
2592 memcpy(&endpoint->desc, d, n);
2593 INIT_LIST_HEAD(&endpoint->urb_list);
2594
2595 - /* Fix up bInterval values outside the legal range. Use 32 ms if no
2596 - * proper value can be guessed. */
2597 + /*
2598 + * Fix up bInterval values outside the legal range.
2599 + * Use 10 or 8 ms if no proper value can be guessed.
2600 + */
2601 i = 0; /* i = min, j = max, n = default */
2602 j = 255;
2603 if (usb_endpoint_xfer_int(d)) {
2604 @@ -221,13 +223,15 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno, int inum,
2605 case USB_SPEED_SUPER_PLUS:
2606 case USB_SPEED_SUPER:
2607 case USB_SPEED_HIGH:
2608 - /* Many device manufacturers are using full-speed
2609 + /*
2610 + * Many device manufacturers are using full-speed
2611 * bInterval values in high-speed interrupt endpoint
2612 - * descriptors. Try to fix those and fall back to a
2613 - * 32 ms default value otherwise. */
2614 + * descriptors. Try to fix those and fall back to an
2615 + * 8-ms default value otherwise.
2616 + */
2617 n = fls(d->bInterval*8);
2618 if (n == 0)
2619 - n = 9; /* 32 ms = 2^(9-1) uframes */
2620 + n = 7; /* 8 ms = 2^(7-1) uframes */
2621 j = 16;
2622
2623 /*
2624 @@ -242,10 +246,12 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno, int inum,
2625 }
2626 break;
2627 default: /* USB_SPEED_FULL or _LOW */
2628 - /* For low-speed, 10 ms is the official minimum.
2629 + /*
2630 + * For low-speed, 10 ms is the official minimum.
2631 * But some "overclocked" devices might want faster
2632 - * polling so we'll allow it. */
2633 - n = 32;
2634 + * polling so we'll allow it.
2635 + */
2636 + n = 10;
2637 break;
2638 }
2639 } else if (usb_endpoint_xfer_isoc(d)) {
2640 @@ -253,10 +259,10 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno, int inum,
2641 j = 16;
2642 switch (to_usb_device(ddev)->speed) {
2643 case USB_SPEED_HIGH:
2644 - n = 9; /* 32 ms = 2^(9-1) uframes */
2645 + n = 7; /* 8 ms = 2^(7-1) uframes */
2646 break;
2647 default: /* USB_SPEED_FULL */
2648 - n = 6; /* 32 ms = 2^(6-1) frames */
2649 + n = 4; /* 8 ms = 2^(4-1) frames */
2650 break;
2651 }
2652 }
2653 diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
2654 index 1f37b89e7267..62a5c8d5e028 100644
2655 --- a/drivers/usb/host/xhci-ring.c
2656 +++ b/drivers/usb/host/xhci-ring.c
2657 @@ -846,6 +846,10 @@ void xhci_stop_endpoint_command_watchdog(unsigned long arg)
2658 spin_lock_irqsave(&xhci->lock, flags);
2659
2660 ep->stop_cmds_pending--;
2661 + if (xhci->xhc_state & XHCI_STATE_REMOVING) {
2662 + spin_unlock_irqrestore(&xhci->lock, flags);
2663 + return;
2664 + }
2665 if (xhci->xhc_state & XHCI_STATE_DYING) {
2666 xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb,
2667 "Stop EP timer ran, but another timer marked "
2668 @@ -899,7 +903,7 @@ void xhci_stop_endpoint_command_watchdog(unsigned long arg)
2669 spin_unlock_irqrestore(&xhci->lock, flags);
2670 xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb,
2671 "Calling usb_hc_died()");
2672 - usb_hc_died(xhci_to_hcd(xhci)->primary_hcd);
2673 + usb_hc_died(xhci_to_hcd(xhci));
2674 xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb,
2675 "xHCI host controller is dead.");
2676 }
2677 diff --git a/drivers/usb/renesas_usbhs/mod.c b/drivers/usb/renesas_usbhs/mod.c
2678 index d4be5d594896..28965ef4f824 100644
2679 --- a/drivers/usb/renesas_usbhs/mod.c
2680 +++ b/drivers/usb/renesas_usbhs/mod.c
2681 @@ -282,9 +282,16 @@ static irqreturn_t usbhs_interrupt(int irq, void *data)
2682 if (usbhs_mod_is_host(priv))
2683 usbhs_write(priv, INTSTS1, ~irq_state.intsts1 & INTSTS1_MAGIC);
2684
2685 - usbhs_write(priv, BRDYSTS, ~irq_state.brdysts);
2686 + /*
2687 + * The driver should not clear the xxxSTS after the line of
2688 + * "call irq callback functions" because each "if" statement is
2689 + * possible to call the callback function for avoiding any side effects.
2690 + */
2691 + if (irq_state.intsts0 & BRDY)
2692 + usbhs_write(priv, BRDYSTS, ~irq_state.brdysts);
2693 usbhs_write(priv, NRDYSTS, ~irq_state.nrdysts);
2694 - usbhs_write(priv, BEMPSTS, ~irq_state.bempsts);
2695 + if (irq_state.intsts0 & BEMP)
2696 + usbhs_write(priv, BEMPSTS, ~irq_state.bempsts);
2697
2698 /*
2699 * call irq callback functions
2700 diff --git a/drivers/usb/serial/usb-serial-simple.c b/drivers/usb/serial/usb-serial-simple.c
2701 index a204782ae530..e98b6e57b703 100644
2702 --- a/drivers/usb/serial/usb-serial-simple.c
2703 +++ b/drivers/usb/serial/usb-serial-simple.c
2704 @@ -54,7 +54,8 @@ DEVICE(funsoft, FUNSOFT_IDS);
2705 /* Infineon Flashloader driver */
2706 #define FLASHLOADER_IDS() \
2707 { USB_DEVICE_INTERFACE_CLASS(0x058b, 0x0041, USB_CLASS_CDC_DATA) }, \
2708 - { USB_DEVICE(0x8087, 0x0716) }
2709 + { USB_DEVICE(0x8087, 0x0716) }, \
2710 + { USB_DEVICE(0x8087, 0x0801) }
2711 DEVICE(flashloader, FLASHLOADER_IDS);
2712
2713 /* Google Serial USB SubClass */
2714 diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
2715 index 0e044d7ee721..1415f6d58633 100644
2716 --- a/fs/btrfs/tree-log.c
2717 +++ b/fs/btrfs/tree-log.c
2718 @@ -2850,6 +2850,7 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
2719
2720 if (log_root_tree->log_transid_committed >= root_log_ctx.log_transid) {
2721 blk_finish_plug(&plug);
2722 + list_del_init(&root_log_ctx.list);
2723 mutex_unlock(&log_root_tree->log_mutex);
2724 ret = root_log_ctx.log_ret;
2725 goto out;
2726 diff --git a/fs/ext4/crypto_policy.c b/fs/ext4/crypto_policy.c
2727 index ad050698143f..8a9feb341f31 100644
2728 --- a/fs/ext4/crypto_policy.c
2729 +++ b/fs/ext4/crypto_policy.c
2730 @@ -102,6 +102,9 @@ static int ext4_create_encryption_context_from_policy(
2731 int ext4_process_policy(const struct ext4_encryption_policy *policy,
2732 struct inode *inode)
2733 {
2734 + if (!inode_owner_or_capable(inode))
2735 + return -EACCES;
2736 +
2737 if (policy->version != 0)
2738 return -EINVAL;
2739
2740 diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
2741 index 5e872fd40e5e..1fb12f9c97a6 100644
2742 --- a/fs/ext4/ioctl.c
2743 +++ b/fs/ext4/ioctl.c
2744 @@ -629,7 +629,13 @@ resizefs_out:
2745 goto encryption_policy_out;
2746 }
2747
2748 + err = mnt_want_write_file(filp);
2749 + if (err)
2750 + goto encryption_policy_out;
2751 +
2752 err = ext4_process_policy(&policy, inode);
2753 +
2754 + mnt_drop_write_file(filp);
2755 encryption_policy_out:
2756 return err;
2757 #else
2758 diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
2759 index c4dcac8a018d..3c7f0c44cfb3 100644
2760 --- a/fs/ext4/mballoc.c
2761 +++ b/fs/ext4/mballoc.c
2762 @@ -815,7 +815,7 @@ static void mb_regenerate_buddy(struct ext4_buddy *e4b)
2763 * for this page; do not hold this lock when calling this routine!
2764 */
2765
2766 -static int ext4_mb_init_cache(struct page *page, char *incore)
2767 +static int ext4_mb_init_cache(struct page *page, char *incore, gfp_t gfp)
2768 {
2769 ext4_group_t ngroups;
2770 int blocksize;
2771 @@ -848,7 +848,7 @@ static int ext4_mb_init_cache(struct page *page, char *incore)
2772 /* allocate buffer_heads to read bitmaps */
2773 if (groups_per_page > 1) {
2774 i = sizeof(struct buffer_head *) * groups_per_page;
2775 - bh = kzalloc(i, GFP_NOFS);
2776 + bh = kzalloc(i, gfp);
2777 if (bh == NULL) {
2778 err = -ENOMEM;
2779 goto out;
2780 @@ -983,7 +983,7 @@ out:
2781 * are on the same page e4b->bd_buddy_page is NULL and return value is 0.
2782 */
2783 static int ext4_mb_get_buddy_page_lock(struct super_block *sb,
2784 - ext4_group_t group, struct ext4_buddy *e4b)
2785 + ext4_group_t group, struct ext4_buddy *e4b, gfp_t gfp)
2786 {
2787 struct inode *inode = EXT4_SB(sb)->s_buddy_cache;
2788 int block, pnum, poff;
2789 @@ -1002,7 +1002,7 @@ static int ext4_mb_get_buddy_page_lock(struct super_block *sb,
2790 block = group * 2;
2791 pnum = block / blocks_per_page;
2792 poff = block % blocks_per_page;
2793 - page = find_or_create_page(inode->i_mapping, pnum, GFP_NOFS);
2794 + page = find_or_create_page(inode->i_mapping, pnum, gfp);
2795 if (!page)
2796 return -ENOMEM;
2797 BUG_ON(page->mapping != inode->i_mapping);
2798 @@ -1016,7 +1016,7 @@ static int ext4_mb_get_buddy_page_lock(struct super_block *sb,
2799
2800 block++;
2801 pnum = block / blocks_per_page;
2802 - page = find_or_create_page(inode->i_mapping, pnum, GFP_NOFS);
2803 + page = find_or_create_page(inode->i_mapping, pnum, gfp);
2804 if (!page)
2805 return -ENOMEM;
2806 BUG_ON(page->mapping != inode->i_mapping);
2807 @@ -1042,7 +1042,7 @@ static void ext4_mb_put_buddy_page_lock(struct ext4_buddy *e4b)
2808 * calling this routine!
2809 */
2810 static noinline_for_stack
2811 -int ext4_mb_init_group(struct super_block *sb, ext4_group_t group)
2812 +int ext4_mb_init_group(struct super_block *sb, ext4_group_t group, gfp_t gfp)
2813 {
2814
2815 struct ext4_group_info *this_grp;
2816 @@ -1062,7 +1062,7 @@ int ext4_mb_init_group(struct super_block *sb, ext4_group_t group)
2817 * The call to ext4_mb_get_buddy_page_lock will mark the
2818 * page accessed.
2819 */
2820 - ret = ext4_mb_get_buddy_page_lock(sb, group, &e4b);
2821 + ret = ext4_mb_get_buddy_page_lock(sb, group, &e4b, gfp);
2822 if (ret || !EXT4_MB_GRP_NEED_INIT(this_grp)) {
2823 /*
2824 * somebody initialized the group
2825 @@ -1072,7 +1072,7 @@ int ext4_mb_init_group(struct super_block *sb, ext4_group_t group)
2826 }
2827
2828 page = e4b.bd_bitmap_page;
2829 - ret = ext4_mb_init_cache(page, NULL);
2830 + ret = ext4_mb_init_cache(page, NULL, gfp);
2831 if (ret)
2832 goto err;
2833 if (!PageUptodate(page)) {
2834 @@ -1091,7 +1091,7 @@ int ext4_mb_init_group(struct super_block *sb, ext4_group_t group)
2835 }
2836 /* init buddy cache */
2837 page = e4b.bd_buddy_page;
2838 - ret = ext4_mb_init_cache(page, e4b.bd_bitmap);
2839 + ret = ext4_mb_init_cache(page, e4b.bd_bitmap, gfp);
2840 if (ret)
2841 goto err;
2842 if (!PageUptodate(page)) {
2843 @@ -1109,8 +1109,8 @@ err:
2844 * calling this routine!
2845 */
2846 static noinline_for_stack int
2847 -ext4_mb_load_buddy(struct super_block *sb, ext4_group_t group,
2848 - struct ext4_buddy *e4b)
2849 +ext4_mb_load_buddy_gfp(struct super_block *sb, ext4_group_t group,
2850 + struct ext4_buddy *e4b, gfp_t gfp)
2851 {
2852 int blocks_per_page;
2853 int block;
2854 @@ -1140,7 +1140,7 @@ ext4_mb_load_buddy(struct super_block *sb, ext4_group_t group,
2855 * we need full data about the group
2856 * to make a good selection
2857 */
2858 - ret = ext4_mb_init_group(sb, group);
2859 + ret = ext4_mb_init_group(sb, group, gfp);
2860 if (ret)
2861 return ret;
2862 }
2863 @@ -1168,11 +1168,11 @@ ext4_mb_load_buddy(struct super_block *sb, ext4_group_t group,
2864 * wait for it to initialize.
2865 */
2866 page_cache_release(page);
2867 - page = find_or_create_page(inode->i_mapping, pnum, GFP_NOFS);
2868 + page = find_or_create_page(inode->i_mapping, pnum, gfp);
2869 if (page) {
2870 BUG_ON(page->mapping != inode->i_mapping);
2871 if (!PageUptodate(page)) {
2872 - ret = ext4_mb_init_cache(page, NULL);
2873 + ret = ext4_mb_init_cache(page, NULL, gfp);
2874 if (ret) {
2875 unlock_page(page);
2876 goto err;
2877 @@ -1204,11 +1204,12 @@ ext4_mb_load_buddy(struct super_block *sb, ext4_group_t group,
2878 if (page == NULL || !PageUptodate(page)) {
2879 if (page)
2880 page_cache_release(page);
2881 - page = find_or_create_page(inode->i_mapping, pnum, GFP_NOFS);
2882 + page = find_or_create_page(inode->i_mapping, pnum, gfp);
2883 if (page) {
2884 BUG_ON(page->mapping != inode->i_mapping);
2885 if (!PageUptodate(page)) {
2886 - ret = ext4_mb_init_cache(page, e4b->bd_bitmap);
2887 + ret = ext4_mb_init_cache(page, e4b->bd_bitmap,
2888 + gfp);
2889 if (ret) {
2890 unlock_page(page);
2891 goto err;
2892 @@ -1247,6 +1248,12 @@ err:
2893 return ret;
2894 }
2895
2896 +static int ext4_mb_load_buddy(struct super_block *sb, ext4_group_t group,
2897 + struct ext4_buddy *e4b)
2898 +{
2899 + return ext4_mb_load_buddy_gfp(sb, group, e4b, GFP_NOFS);
2900 +}
2901 +
2902 static void ext4_mb_unload_buddy(struct ext4_buddy *e4b)
2903 {
2904 if (e4b->bd_bitmap_page)
2905 @@ -2047,7 +2054,7 @@ static int ext4_mb_good_group(struct ext4_allocation_context *ac,
2906
2907 /* We only do this if the grp has never been initialized */
2908 if (unlikely(EXT4_MB_GRP_NEED_INIT(grp))) {
2909 - int ret = ext4_mb_init_group(ac->ac_sb, group);
2910 + int ret = ext4_mb_init_group(ac->ac_sb, group, GFP_NOFS);
2911 if (ret)
2912 return ret;
2913 }
2914 @@ -4808,7 +4815,9 @@ do_more:
2915 #endif
2916 trace_ext4_mballoc_free(sb, inode, block_group, bit, count_clusters);
2917
2918 - err = ext4_mb_load_buddy(sb, block_group, &e4b);
2919 + /* __GFP_NOFAIL: retry infinitely, ignore TIF_MEMDIE and memcg limit. */
2920 + err = ext4_mb_load_buddy_gfp(sb, block_group, &e4b,
2921 + GFP_NOFS|__GFP_NOFAIL);
2922 if (err)
2923 goto error_return;
2924
2925 @@ -5210,7 +5219,7 @@ int ext4_trim_fs(struct super_block *sb, struct fstrim_range *range)
2926 grp = ext4_get_group_info(sb, group);
2927 /* We only do this if the grp has never been initialized */
2928 if (unlikely(EXT4_MB_GRP_NEED_INIT(grp))) {
2929 - ret = ext4_mb_init_group(sb, group);
2930 + ret = ext4_mb_init_group(sb, group, GFP_NOFS);
2931 if (ret)
2932 break;
2933 }
2934 diff --git a/fs/f2fs/crypto_policy.c b/fs/f2fs/crypto_policy.c
2935 index d4a96af513c2..e504f548b64e 100644
2936 --- a/fs/f2fs/crypto_policy.c
2937 +++ b/fs/f2fs/crypto_policy.c
2938 @@ -89,6 +89,9 @@ static int f2fs_create_encryption_context_from_policy(
2939 int f2fs_process_policy(const struct f2fs_encryption_policy *policy,
2940 struct inode *inode)
2941 {
2942 + if (!inode_owner_or_capable(inode))
2943 + return -EACCES;
2944 +
2945 if (policy->version != 0)
2946 return -EINVAL;
2947
2948 diff --git a/fs/fuse/file.c b/fs/fuse/file.c
2949 index d58d4c0af0ce..682e79965c16 100644
2950 --- a/fs/fuse/file.c
2951 +++ b/fs/fuse/file.c
2952 @@ -540,13 +540,13 @@ void fuse_read_fill(struct fuse_req *req, struct file *file, loff_t pos,
2953 req->out.args[0].size = count;
2954 }
2955
2956 -static void fuse_release_user_pages(struct fuse_req *req, int write)
2957 +static void fuse_release_user_pages(struct fuse_req *req, bool should_dirty)
2958 {
2959 unsigned i;
2960
2961 for (i = 0; i < req->num_pages; i++) {
2962 struct page *page = req->pages[i];
2963 - if (write)
2964 + if (should_dirty)
2965 set_page_dirty_lock(page);
2966 put_page(page);
2967 }
2968 @@ -1331,6 +1331,7 @@ ssize_t fuse_direct_io(struct fuse_io_priv *io, struct iov_iter *iter,
2969 loff_t *ppos, int flags)
2970 {
2971 int write = flags & FUSE_DIO_WRITE;
2972 + bool should_dirty = !write && iter_is_iovec(iter);
2973 int cuse = flags & FUSE_DIO_CUSE;
2974 struct file *file = io->file;
2975 struct inode *inode = file->f_mapping->host;
2976 @@ -1375,7 +1376,7 @@ ssize_t fuse_direct_io(struct fuse_io_priv *io, struct iov_iter *iter,
2977 nres = fuse_send_read(req, io, pos, nbytes, owner);
2978
2979 if (!io->async)
2980 - fuse_release_user_pages(req, !write);
2981 + fuse_release_user_pages(req, should_dirty);
2982 if (req->out.h.error) {
2983 if (!res)
2984 res = req->out.h.error;
2985 diff --git a/fs/kernfs/file.c b/fs/kernfs/file.c
2986 index 7247252ee9b1..6e9a912d394c 100644
2987 --- a/fs/kernfs/file.c
2988 +++ b/fs/kernfs/file.c
2989 @@ -833,21 +833,35 @@ repeat:
2990 mutex_lock(&kernfs_mutex);
2991
2992 list_for_each_entry(info, &kernfs_root(kn)->supers, node) {
2993 + struct kernfs_node *parent;
2994 struct inode *inode;
2995 - struct dentry *dentry;
2996
2997 + /*
2998 + * We want fsnotify_modify() on @kn but as the
2999 + * modifications aren't originating from userland don't
3000 + * have the matching @file available. Look up the inodes
3001 + * and generate the events manually.
3002 + */
3003 inode = ilookup(info->sb, kn->ino);
3004 if (!inode)
3005 continue;
3006
3007 - dentry = d_find_any_alias(inode);
3008 - if (dentry) {
3009 - fsnotify_parent(NULL, dentry, FS_MODIFY);
3010 - fsnotify(inode, FS_MODIFY, inode, FSNOTIFY_EVENT_INODE,
3011 - NULL, 0);
3012 - dput(dentry);
3013 + parent = kernfs_get_parent(kn);
3014 + if (parent) {
3015 + struct inode *p_inode;
3016 +
3017 + p_inode = ilookup(info->sb, parent->ino);
3018 + if (p_inode) {
3019 + fsnotify(p_inode, FS_MODIFY | FS_EVENT_ON_CHILD,
3020 + inode, FSNOTIFY_EVENT_INODE, kn->name, 0);
3021 + iput(p_inode);
3022 + }
3023 +
3024 + kernfs_put(parent);
3025 }
3026
3027 + fsnotify(inode, FS_MODIFY, inode, FSNOTIFY_EVENT_INODE,
3028 + kn->name, 0);
3029 iput(inode);
3030 }
3031
3032 diff --git a/fs/nfs/callback.c b/fs/nfs/callback.c
3033 index a7f2e6e33305..52a28311e2a4 100644
3034 --- a/fs/nfs/callback.c
3035 +++ b/fs/nfs/callback.c
3036 @@ -275,6 +275,7 @@ static int nfs_callback_up_net(int minorversion, struct svc_serv *serv,
3037 err_socks:
3038 svc_rpcb_cleanup(serv, net);
3039 err_bind:
3040 + nn->cb_users[minorversion]--;
3041 dprintk("NFS: Couldn't create callback socket: err = %d; "
3042 "net = %p\n", ret, net);
3043 return ret;
3044 diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
3045 index fc215ab4dcd5..3c69299c01ab 100644
3046 --- a/fs/nfs/nfs4proc.c
3047 +++ b/fs/nfs/nfs4proc.c
3048 @@ -7424,12 +7424,20 @@ static int _nfs4_proc_create_session(struct nfs_client *clp,
3049 status = rpc_call_sync(session->clp->cl_rpcclient, &msg, RPC_TASK_TIMEOUT);
3050 trace_nfs4_create_session(clp, status);
3051
3052 + switch (status) {
3053 + case -NFS4ERR_STALE_CLIENTID:
3054 + case -NFS4ERR_DELAY:
3055 + case -ETIMEDOUT:
3056 + case -EACCES:
3057 + case -EAGAIN:
3058 + goto out;
3059 + };
3060 +
3061 + clp->cl_seqid++;
3062 if (!status) {
3063 /* Verify the session's negotiated channel_attrs values */
3064 status = nfs4_verify_channel_attrs(&args, &res);
3065 /* Increment the clientid slot sequence id */
3066 - if (clp->cl_seqid == res.seqid)
3067 - clp->cl_seqid++;
3068 if (status)
3069 goto out;
3070 nfs4_update_session(session, &res);
3071 diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
3072 index bec0384499f7..5cd3568eea06 100644
3073 --- a/fs/nfs/pnfs.c
3074 +++ b/fs/nfs/pnfs.c
3075 @@ -365,6 +365,9 @@ pnfs_layout_need_return(struct pnfs_layout_hdr *lo,
3076 static bool
3077 pnfs_prepare_layoutreturn(struct pnfs_layout_hdr *lo)
3078 {
3079 + /* Serialise LAYOUTGET/LAYOUTRETURN */
3080 + if (atomic_read(&lo->plh_outstanding) != 0)
3081 + return false;
3082 if (test_and_set_bit(NFS_LAYOUT_RETURN, &lo->plh_flags))
3083 return false;
3084 lo->plh_return_iomode = 0;
3085 @@ -1530,6 +1533,7 @@ pnfs_update_layout(struct inode *ino,
3086 goto out;
3087
3088 lookup_again:
3089 + nfs4_client_recover_expired_lease(clp);
3090 first = false;
3091 spin_lock(&ino->i_lock);
3092 lo = pnfs_find_alloc_layout(ino, ctx, gfp_flags);
3093 diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
3094 index f7ea624780a7..55638110cb06 100644
3095 --- a/fs/nfsd/nfs4state.c
3096 +++ b/fs/nfsd/nfs4state.c
3097 @@ -1200,27 +1200,6 @@ free_ol_stateid_reaplist(struct list_head *reaplist)
3098 }
3099 }
3100
3101 -static void release_lockowner(struct nfs4_lockowner *lo)
3102 -{
3103 - struct nfs4_client *clp = lo->lo_owner.so_client;
3104 - struct nfs4_ol_stateid *stp;
3105 - struct list_head reaplist;
3106 -
3107 - INIT_LIST_HEAD(&reaplist);
3108 -
3109 - spin_lock(&clp->cl_lock);
3110 - unhash_lockowner_locked(lo);
3111 - while (!list_empty(&lo->lo_owner.so_stateids)) {
3112 - stp = list_first_entry(&lo->lo_owner.so_stateids,
3113 - struct nfs4_ol_stateid, st_perstateowner);
3114 - WARN_ON(!unhash_lock_stateid(stp));
3115 - put_ol_stateid_locked(stp, &reaplist);
3116 - }
3117 - spin_unlock(&clp->cl_lock);
3118 - free_ol_stateid_reaplist(&reaplist);
3119 - nfs4_put_stateowner(&lo->lo_owner);
3120 -}
3121 -
3122 static void release_open_stateid_locks(struct nfs4_ol_stateid *open_stp,
3123 struct list_head *reaplist)
3124 {
3125 @@ -5952,6 +5931,7 @@ nfsd4_release_lockowner(struct svc_rqst *rqstp,
3126 __be32 status;
3127 struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id);
3128 struct nfs4_client *clp;
3129 + LIST_HEAD (reaplist);
3130
3131 dprintk("nfsd4_release_lockowner clientid: (%08x/%08x):\n",
3132 clid->cl_boot, clid->cl_id);
3133 @@ -5982,9 +5962,23 @@ nfsd4_release_lockowner(struct svc_rqst *rqstp,
3134 nfs4_get_stateowner(sop);
3135 break;
3136 }
3137 + if (!lo) {
3138 + spin_unlock(&clp->cl_lock);
3139 + return status;
3140 + }
3141 +
3142 + unhash_lockowner_locked(lo);
3143 + while (!list_empty(&lo->lo_owner.so_stateids)) {
3144 + stp = list_first_entry(&lo->lo_owner.so_stateids,
3145 + struct nfs4_ol_stateid,
3146 + st_perstateowner);
3147 + WARN_ON(!unhash_lock_stateid(stp));
3148 + put_ol_stateid_locked(stp, &reaplist);
3149 + }
3150 spin_unlock(&clp->cl_lock);
3151 - if (lo)
3152 - release_lockowner(lo);
3153 + free_ol_stateid_reaplist(&reaplist);
3154 + nfs4_put_stateowner(&lo->lo_owner);
3155 +
3156 return status;
3157 }
3158
3159 diff --git a/fs/proc/base.c b/fs/proc/base.c
3160 index e8bbf6cdb437..d2b8c754f627 100644
3161 --- a/fs/proc/base.c
3162 +++ b/fs/proc/base.c
3163 @@ -1545,18 +1545,13 @@ static const struct file_operations proc_pid_set_comm_operations = {
3164 static int proc_exe_link(struct dentry *dentry, struct path *exe_path)
3165 {
3166 struct task_struct *task;
3167 - struct mm_struct *mm;
3168 struct file *exe_file;
3169
3170 task = get_proc_task(d_inode(dentry));
3171 if (!task)
3172 return -ENOENT;
3173 - mm = get_task_mm(task);
3174 + exe_file = get_task_exe_file(task);
3175 put_task_struct(task);
3176 - if (!mm)
3177 - return -ENOENT;
3178 - exe_file = get_mm_exe_file(mm);
3179 - mmput(mm);
3180 if (exe_file) {
3181 *exe_path = exe_file->f_path;
3182 path_get(&exe_file->f_path);
3183 diff --git a/include/asm-generic/uaccess.h b/include/asm-generic/uaccess.h
3184 index 1bfa602958f2..32901d11f8c4 100644
3185 --- a/include/asm-generic/uaccess.h
3186 +++ b/include/asm-generic/uaccess.h
3187 @@ -230,14 +230,18 @@ extern int __put_user_bad(void) __attribute__((noreturn));
3188 might_fault(); \
3189 access_ok(VERIFY_READ, __p, sizeof(*ptr)) ? \
3190 __get_user((x), (__typeof__(*(ptr)) *)__p) : \
3191 - -EFAULT; \
3192 + ((x) = (__typeof__(*(ptr)))0,-EFAULT); \
3193 })
3194
3195 #ifndef __get_user_fn
3196 static inline int __get_user_fn(size_t size, const void __user *ptr, void *x)
3197 {
3198 - size = __copy_from_user(x, ptr, size);
3199 - return size ? -EFAULT : size;
3200 + size_t n = __copy_from_user(x, ptr, size);
3201 + if (unlikely(n)) {
3202 + memset(x + (size - n), 0, n);
3203 + return -EFAULT;
3204 + }
3205 + return 0;
3206 }
3207
3208 #define __get_user_fn(sz, u, k) __get_user_fn(sz, u, k)
3209 @@ -257,11 +261,13 @@ extern int __get_user_bad(void) __attribute__((noreturn));
3210 static inline long copy_from_user(void *to,
3211 const void __user * from, unsigned long n)
3212 {
3213 + unsigned long res = n;
3214 might_fault();
3215 - if (access_ok(VERIFY_READ, from, n))
3216 - return __copy_from_user(to, from, n);
3217 - else
3218 - return n;
3219 + if (likely(access_ok(VERIFY_READ, from, n)))
3220 + res = __copy_from_user(to, from, n);
3221 + if (unlikely(res))
3222 + memset(to + (n - res), 0, res);
3223 + return res;
3224 }
3225
3226 static inline long copy_to_user(void __user *to,
3227 diff --git a/include/linux/irq.h b/include/linux/irq.h
3228 index 3c1c96786248..f7cade00c525 100644
3229 --- a/include/linux/irq.h
3230 +++ b/include/linux/irq.h
3231 @@ -916,6 +916,16 @@ static inline void irq_gc_lock(struct irq_chip_generic *gc) { }
3232 static inline void irq_gc_unlock(struct irq_chip_generic *gc) { }
3233 #endif
3234
3235 +/*
3236 + * The irqsave variants are for usage in non interrupt code. Do not use
3237 + * them in irq_chip callbacks. Use irq_gc_lock() instead.
3238 + */
3239 +#define irq_gc_lock_irqsave(gc, flags) \
3240 + raw_spin_lock_irqsave(&(gc)->lock, flags)
3241 +
3242 +#define irq_gc_unlock_irqrestore(gc, flags) \
3243 + raw_spin_unlock_irqrestore(&(gc)->lock, flags)
3244 +
3245 static inline void irq_reg_writel(struct irq_chip_generic *gc,
3246 u32 val, int reg_offset)
3247 {
3248 diff --git a/include/linux/mfd/ti_am335x_tscadc.h b/include/linux/mfd/ti_am335x_tscadc.h
3249 index 1fd50dcfe47c..175c82699e9d 100644
3250 --- a/include/linux/mfd/ti_am335x_tscadc.h
3251 +++ b/include/linux/mfd/ti_am335x_tscadc.h
3252 @@ -138,16 +138,16 @@
3253 /*
3254 * time in us for processing a single channel, calculated as follows:
3255 *
3256 - * num cycles = open delay + (sample delay + conv time) * averaging
3257 + * max num cycles = open delay + (sample delay + conv time) * averaging
3258 *
3259 - * num cycles: 152 + (1 + 13) * 16 = 376
3260 + * max num cycles: 262143 + (255 + 13) * 16 = 266431
3261 *
3262 * clock frequency: 26MHz / 8 = 3.25MHz
3263 * clock period: 1 / 3.25MHz = 308ns
3264 *
3265 - * processing time: 376 * 308ns = 116us
3266 + * max processing time: 266431 * 308ns = 83ms(approx)
3267 */
3268 -#define IDLE_TIMEOUT 116 /* microsec */
3269 +#define IDLE_TIMEOUT 83 /* milliseconds */
3270
3271 #define TSCADC_CELLS 2
3272
3273 diff --git a/include/linux/mm.h b/include/linux/mm.h
3274 index 8a761248d01e..cfebb742ee18 100644
3275 --- a/include/linux/mm.h
3276 +++ b/include/linux/mm.h
3277 @@ -1898,6 +1898,7 @@ extern void mm_drop_all_locks(struct mm_struct *mm);
3278
3279 extern void set_mm_exe_file(struct mm_struct *mm, struct file *new_exe_file);
3280 extern struct file *get_mm_exe_file(struct mm_struct *mm);
3281 +extern struct file *get_task_exe_file(struct task_struct *task);
3282
3283 extern int may_expand_vm(struct mm_struct *mm, unsigned long npages);
3284 extern struct vm_area_struct *_install_special_mapping(struct mm_struct *mm,
3285 diff --git a/include/linux/mmc/dw_mmc.h b/include/linux/mmc/dw_mmc.h
3286 index f67b2ec18e6d..7776afb0ffa5 100644
3287 --- a/include/linux/mmc/dw_mmc.h
3288 +++ b/include/linux/mmc/dw_mmc.h
3289 @@ -172,7 +172,7 @@ struct dw_mci {
3290 /* For edmac */
3291 struct dw_mci_dma_slave *dms;
3292 /* Registers's physical base address */
3293 - void *phy_regs;
3294 + resource_size_t phy_regs;
3295
3296 u32 cmd_status;
3297 u32 data_status;
3298 diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
3299 index 04c068e55353..b97d6823ef3c 100644
3300 --- a/include/linux/netdevice.h
3301 +++ b/include/linux/netdevice.h
3302 @@ -511,7 +511,6 @@ static inline void napi_enable(struct napi_struct *n)
3303 clear_bit(NAPI_STATE_NPSVC, &n->state);
3304 }
3305
3306 -#ifdef CONFIG_SMP
3307 /**
3308 * napi_synchronize - wait until NAPI is not running
3309 * @n: napi context
3310 @@ -522,12 +521,12 @@ static inline void napi_enable(struct napi_struct *n)
3311 */
3312 static inline void napi_synchronize(const struct napi_struct *n)
3313 {
3314 - while (test_bit(NAPI_STATE_SCHED, &n->state))
3315 - msleep(1);
3316 + if (IS_ENABLED(CONFIG_SMP))
3317 + while (test_bit(NAPI_STATE_SCHED, &n->state))
3318 + msleep(1);
3319 + else
3320 + barrier();
3321 }
3322 -#else
3323 -# define napi_synchronize(n) barrier()
3324 -#endif
3325
3326 enum netdev_queue_state_t {
3327 __QUEUE_STATE_DRV_XOFF,
3328 diff --git a/include/linux/uio.h b/include/linux/uio.h
3329 index 8b01e1c3c614..5f9c59da978b 100644
3330 --- a/include/linux/uio.h
3331 +++ b/include/linux/uio.h
3332 @@ -76,7 +76,7 @@ size_t iov_iter_copy_from_user_atomic(struct page *page,
3333 struct iov_iter *i, unsigned long offset, size_t bytes);
3334 void iov_iter_advance(struct iov_iter *i, size_t bytes);
3335 int iov_iter_fault_in_readable(struct iov_iter *i, size_t bytes);
3336 -int iov_iter_fault_in_multipages_readable(struct iov_iter *i, size_t bytes);
3337 +#define iov_iter_fault_in_multipages_readable iov_iter_fault_in_readable
3338 size_t iov_iter_single_seg_count(const struct iov_iter *i);
3339 size_t copy_page_to_iter(struct page *page, size_t offset, size_t bytes,
3340 struct iov_iter *i);
3341 diff --git a/kernel/audit_watch.c b/kernel/audit_watch.c
3342 index 656c7e93ac0d..939945a5649c 100644
3343 --- a/kernel/audit_watch.c
3344 +++ b/kernel/audit_watch.c
3345 @@ -19,6 +19,7 @@
3346 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
3347 */
3348
3349 +#include <linux/file.h>
3350 #include <linux/kernel.h>
3351 #include <linux/audit.h>
3352 #include <linux/kthread.h>
3353 @@ -544,10 +545,11 @@ int audit_exe_compare(struct task_struct *tsk, struct audit_fsnotify_mark *mark)
3354 unsigned long ino;
3355 dev_t dev;
3356
3357 - rcu_read_lock();
3358 - exe_file = rcu_dereference(tsk->mm->exe_file);
3359 + exe_file = get_task_exe_file(tsk);
3360 + if (!exe_file)
3361 + return 0;
3362 ino = exe_file->f_inode->i_ino;
3363 dev = exe_file->f_inode->i_sb->s_dev;
3364 - rcu_read_unlock();
3365 + fput(exe_file);
3366 return audit_mark_compare(mark, ino, dev);
3367 }
3368 diff --git a/kernel/configs/tiny.config b/kernel/configs/tiny.config
3369 index c2de56ab0fce..7fa0c4ae6394 100644
3370 --- a/kernel/configs/tiny.config
3371 +++ b/kernel/configs/tiny.config
3372 @@ -1,4 +1,12 @@
3373 +# CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE is not set
3374 CONFIG_CC_OPTIMIZE_FOR_SIZE=y
3375 +# CONFIG_KERNEL_GZIP is not set
3376 +# CONFIG_KERNEL_BZIP2 is not set
3377 +# CONFIG_KERNEL_LZMA is not set
3378 CONFIG_KERNEL_XZ=y
3379 +# CONFIG_KERNEL_LZO is not set
3380 +# CONFIG_KERNEL_LZ4 is not set
3381 CONFIG_OPTIMIZE_INLINING=y
3382 +# CONFIG_SLAB is not set
3383 +# CONFIG_SLUB is not set
3384 CONFIG_SLOB=y
3385 diff --git a/kernel/cpuset.c b/kernel/cpuset.c
3386 index 11eaf14b52c2..e120bd983ad0 100644
3387 --- a/kernel/cpuset.c
3388 +++ b/kernel/cpuset.c
3389 @@ -2074,6 +2074,20 @@ static void cpuset_bind(struct cgroup_subsys_state *root_css)
3390 mutex_unlock(&cpuset_mutex);
3391 }
3392
3393 +/*
3394 + * Make sure the new task conform to the current state of its parent,
3395 + * which could have been changed by cpuset just after it inherits the
3396 + * state from the parent and before it sits on the cgroup's task list.
3397 + */
3398 +void cpuset_fork(struct task_struct *task)
3399 +{
3400 + if (task_css_is_root(task, cpuset_cgrp_id))
3401 + return;
3402 +
3403 + set_cpus_allowed_ptr(task, &current->cpus_allowed);
3404 + task->mems_allowed = current->mems_allowed;
3405 +}
3406 +
3407 struct cgroup_subsys cpuset_cgrp_subsys = {
3408 .css_alloc = cpuset_css_alloc,
3409 .css_online = cpuset_css_online,
3410 @@ -2084,6 +2098,7 @@ struct cgroup_subsys cpuset_cgrp_subsys = {
3411 .attach = cpuset_attach,
3412 .post_attach = cpuset_post_attach,
3413 .bind = cpuset_bind,
3414 + .fork = cpuset_fork,
3415 .legacy_cftypes = files,
3416 .early_init = 1,
3417 };
3418 diff --git a/kernel/fork.c b/kernel/fork.c
3419 index c485cb156772..8860d1f50d24 100644
3420 --- a/kernel/fork.c
3421 +++ b/kernel/fork.c
3422 @@ -764,6 +764,29 @@ struct file *get_mm_exe_file(struct mm_struct *mm)
3423 EXPORT_SYMBOL(get_mm_exe_file);
3424
3425 /**
3426 + * get_task_exe_file - acquire a reference to the task's executable file
3427 + *
3428 + * Returns %NULL if task's mm (if any) has no associated executable file or
3429 + * this is a kernel thread with borrowed mm (see the comment above get_task_mm).
3430 + * User must release file via fput().
3431 + */
3432 +struct file *get_task_exe_file(struct task_struct *task)
3433 +{
3434 + struct file *exe_file = NULL;
3435 + struct mm_struct *mm;
3436 +
3437 + task_lock(task);
3438 + mm = task->mm;
3439 + if (mm) {
3440 + if (!(task->flags & PF_KTHREAD))
3441 + exe_file = get_mm_exe_file(mm);
3442 + }
3443 + task_unlock(task);
3444 + return exe_file;
3445 +}
3446 +EXPORT_SYMBOL(get_task_exe_file);
3447 +
3448 +/**
3449 * get_task_mm - acquire a reference to the task's mm
3450 *
3451 * Returns %NULL if the task has no mm. Checks PF_KTHREAD (meaning
3452 diff --git a/kernel/irq/msi.c b/kernel/irq/msi.c
3453 index 4b21779d5163..cd6009006510 100644
3454 --- a/kernel/irq/msi.c
3455 +++ b/kernel/irq/msi.c
3456 @@ -298,6 +298,7 @@ int msi_domain_alloc_irqs(struct irq_domain *domain, struct device *dev,
3457 ops->msi_finish(&arg, 0);
3458
3459 for_each_msi_entry(desc, dev) {
3460 + virq = desc->irq;
3461 if (desc->nvec_used == 1)
3462 dev_dbg(dev, "irq %d for MSI\n", virq);
3463 else
3464 diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c
3465 index b70ada0028d2..6030efd4a188 100644
3466 --- a/kernel/kexec_file.c
3467 +++ b/kernel/kexec_file.c
3468 @@ -934,7 +934,10 @@ int kexec_load_purgatory(struct kimage *image, unsigned long min,
3469 return 0;
3470 out:
3471 vfree(pi->sechdrs);
3472 + pi->sechdrs = NULL;
3473 +
3474 vfree(pi->purgatory_buf);
3475 + pi->purgatory_buf = NULL;
3476 return ret;
3477 }
3478
3479 diff --git a/kernel/sched/core.c b/kernel/sched/core.c
3480 index ea863bc22caf..20253dbc8610 100644
3481 --- a/kernel/sched/core.c
3482 +++ b/kernel/sched/core.c
3483 @@ -1945,6 +1945,28 @@ try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags)
3484 success = 1; /* we're going to change ->state */
3485 cpu = task_cpu(p);
3486
3487 + /*
3488 + * Ensure we load p->on_rq _after_ p->state, otherwise it would
3489 + * be possible to, falsely, observe p->on_rq == 0 and get stuck
3490 + * in smp_cond_load_acquire() below.
3491 + *
3492 + * sched_ttwu_pending() try_to_wake_up()
3493 + * [S] p->on_rq = 1; [L] P->state
3494 + * UNLOCK rq->lock -----.
3495 + * \
3496 + * +--- RMB
3497 + * schedule() /
3498 + * LOCK rq->lock -----'
3499 + * UNLOCK rq->lock
3500 + *
3501 + * [task p]
3502 + * [S] p->state = UNINTERRUPTIBLE [L] p->on_rq
3503 + *
3504 + * Pairs with the UNLOCK+LOCK on rq->lock from the
3505 + * last wakeup of our task and the schedule that got our task
3506 + * current.
3507 + */
3508 + smp_rmb();
3509 if (p->on_rq && ttwu_remote(p, wake_flags))
3510 goto stat;
3511
3512 diff --git a/lib/iov_iter.c b/lib/iov_iter.c
3513 index 75232ad0a5e7..daca582a8ed0 100644
3514 --- a/lib/iov_iter.c
3515 +++ b/lib/iov_iter.c
3516 @@ -298,33 +298,13 @@ done:
3517 }
3518
3519 /*
3520 - * Fault in the first iovec of the given iov_iter, to a maximum length
3521 - * of bytes. Returns 0 on success, or non-zero if the memory could not be
3522 - * accessed (ie. because it is an invalid address).
3523 - *
3524 - * writev-intensive code may want this to prefault several iovecs -- that
3525 - * would be possible (callers must not rely on the fact that _only_ the
3526 - * first iovec will be faulted with the current implementation).
3527 - */
3528 -int iov_iter_fault_in_readable(struct iov_iter *i, size_t bytes)
3529 -{
3530 - if (!(i->type & (ITER_BVEC|ITER_KVEC))) {
3531 - char __user *buf = i->iov->iov_base + i->iov_offset;
3532 - bytes = min(bytes, i->iov->iov_len - i->iov_offset);
3533 - return fault_in_pages_readable(buf, bytes);
3534 - }
3535 - return 0;
3536 -}
3537 -EXPORT_SYMBOL(iov_iter_fault_in_readable);
3538 -
3539 -/*
3540 * Fault in one or more iovecs of the given iov_iter, to a maximum length of
3541 * bytes. For each iovec, fault in each page that constitutes the iovec.
3542 *
3543 * Return 0 on success, or non-zero if the memory could not be accessed (i.e.
3544 * because it is an invalid address).
3545 */
3546 -int iov_iter_fault_in_multipages_readable(struct iov_iter *i, size_t bytes)
3547 +int iov_iter_fault_in_readable(struct iov_iter *i, size_t bytes)
3548 {
3549 size_t skip = i->iov_offset;
3550 const struct iovec *iov;
3551 @@ -341,7 +321,7 @@ int iov_iter_fault_in_multipages_readable(struct iov_iter *i, size_t bytes)
3552 }
3553 return 0;
3554 }
3555 -EXPORT_SYMBOL(iov_iter_fault_in_multipages_readable);
3556 +EXPORT_SYMBOL(iov_iter_fault_in_readable);
3557
3558 void iov_iter_init(struct iov_iter *i, int direction,
3559 const struct iovec *iov, unsigned long nr_segs,
3560 diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
3561 index e8d3da0817d3..036b39eb1220 100644
3562 --- a/net/ipv6/addrconf.c
3563 +++ b/net/ipv6/addrconf.c
3564 @@ -1898,6 +1898,7 @@ errdad:
3565 spin_unlock_bh(&ifp->lock);
3566
3567 addrconf_mod_dad_work(ifp, 0);
3568 + in6_ifa_put(ifp);
3569 }
3570
3571 /* Join to solicited addr multicast group.
3572 @@ -3609,6 +3610,7 @@ static void addrconf_dad_work(struct work_struct *w)
3573 addrconf_dad_begin(ifp);
3574 goto out;
3575 } else if (action == DAD_ABORT) {
3576 + in6_ifa_hold(ifp);
3577 addrconf_dad_stop(ifp, 1);
3578 goto out;
3579 }
3580 diff --git a/net/tipc/link.c b/net/tipc/link.c
3581 index 91aea071ab27..72268eac4ec7 100644
3582 --- a/net/tipc/link.c
3583 +++ b/net/tipc/link.c
3584 @@ -1262,6 +1262,8 @@ static int tipc_link_proto_rcv(struct tipc_link *l, struct sk_buff *skb,
3585 /* fall thru' */
3586
3587 case ACTIVATE_MSG:
3588 + skb_linearize(skb);
3589 + hdr = buf_msg(skb);
3590
3591 /* Complete own link name with peer's interface name */
3592 if_name = strrchr(l->name, ':') + 1;
3593 diff --git a/net/tipc/name_distr.c b/net/tipc/name_distr.c
3594 index c07612bab95c..f51c8bdbea1c 100644
3595 --- a/net/tipc/name_distr.c
3596 +++ b/net/tipc/name_distr.c
3597 @@ -397,6 +397,7 @@ void tipc_named_rcv(struct net *net, struct sk_buff_head *inputq)
3598
3599 spin_lock_bh(&tn->nametbl_lock);
3600 for (skb = skb_dequeue(inputq); skb; skb = skb_dequeue(inputq)) {
3601 + skb_linearize(skb);
3602 msg = buf_msg(skb);
3603 mtype = msg_type(msg);
3604 item = (struct distr_item *)msg_data(msg);
3605 diff --git a/net/tipc/udp_media.c b/net/tipc/udp_media.c
3606 index 70c03271b798..6af78c6276b4 100644
3607 --- a/net/tipc/udp_media.c
3608 +++ b/net/tipc/udp_media.c
3609 @@ -48,7 +48,6 @@
3610 #include <linux/tipc_netlink.h>
3611 #include "core.h"
3612 #include "bearer.h"
3613 -#include "msg.h"
3614
3615 /* IANA assigned UDP port */
3616 #define UDP_PORT_DEFAULT 6118
3617 @@ -224,10 +223,6 @@ static int tipc_udp_recv(struct sock *sk, struct sk_buff *skb)
3618 {
3619 struct udp_bearer *ub;
3620 struct tipc_bearer *b;
3621 - int usr = msg_user(buf_msg(skb));
3622 -
3623 - if ((usr == LINK_PROTOCOL) || (usr == NAME_DISTRIBUTOR))
3624 - skb_linearize(skb);
3625
3626 ub = rcu_dereference_sk_user_data(sk);
3627 if (!ub) {
3628 diff --git a/net/wireless/wext-core.c b/net/wireless/wext-core.c
3629 index c753211cb83f..b50ee5d622e1 100644
3630 --- a/net/wireless/wext-core.c
3631 +++ b/net/wireless/wext-core.c
3632 @@ -955,29 +955,8 @@ static int wireless_process_ioctl(struct net *net, struct ifreq *ifr,
3633 return private(dev, iwr, cmd, info, handler);
3634 }
3635 /* Old driver API : call driver ioctl handler */
3636 - if (dev->netdev_ops->ndo_do_ioctl) {
3637 -#ifdef CONFIG_COMPAT
3638 - if (info->flags & IW_REQUEST_FLAG_COMPAT) {
3639 - int ret = 0;
3640 - struct iwreq iwr_lcl;
3641 - struct compat_iw_point *iwp_compat = (void *) &iwr->u.data;
3642 -
3643 - memcpy(&iwr_lcl, iwr, sizeof(struct iwreq));
3644 - iwr_lcl.u.data.pointer = compat_ptr(iwp_compat->pointer);
3645 - iwr_lcl.u.data.length = iwp_compat->length;
3646 - iwr_lcl.u.data.flags = iwp_compat->flags;
3647 -
3648 - ret = dev->netdev_ops->ndo_do_ioctl(dev, (void *) &iwr_lcl, cmd);
3649 -
3650 - iwp_compat->pointer = ptr_to_compat(iwr_lcl.u.data.pointer);
3651 - iwp_compat->length = iwr_lcl.u.data.length;
3652 - iwp_compat->flags = iwr_lcl.u.data.flags;
3653 -
3654 - return ret;
3655 - } else
3656 -#endif
3657 - return dev->netdev_ops->ndo_do_ioctl(dev, ifr, cmd);
3658 - }
3659 + if (dev->netdev_ops->ndo_do_ioctl)
3660 + return dev->netdev_ops->ndo_do_ioctl(dev, ifr, cmd);
3661 return -EOPNOTSUPP;
3662 }
3663