Gentoo Archives: gentoo-commits

From: "Mike Pagano (mpagano)" <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] linux-patches r2386 - genpatches-2.6/trunk/3.10
Date: Tue, 21 May 2013 00:44:45
Message-Id: 20130521004433.0B2D82171D@flycatcher.gentoo.org
1 Author: mpagano
2 Date: 2013-05-21 00:44:32 +0000 (Tue, 21 May 2013)
3 New Revision: 2386
4
5 Removed:
6 genpatches-2.6/trunk/3.10/1000_linux-3.9.1.patch
7 genpatches-2.6/trunk/3.10/1001_linux-3.9.2.patch
8 genpatches-2.6/trunk/3.10/1002_linux-3.9.3.patch
9 Modified:
10 genpatches-2.6/trunk/3.10/0000_README
11 Log:
12 Remove 3.9 specific patches
13
14 Modified: genpatches-2.6/trunk/3.10/0000_README
15 ===================================================================
16 --- genpatches-2.6/trunk/3.10/0000_README 2013-05-21 00:40:11 UTC (rev 2385)
17 +++ genpatches-2.6/trunk/3.10/0000_README 2013-05-21 00:44:32 UTC (rev 2386)
18 @@ -39,18 +39,6 @@
19
20 Individual Patch Descriptions:
21 --------------------------------------------------------------------------
22 -Patch: 1000_linux-3.9.1.patch
23 -From: http://www.kernel.org
24 -Desc: Linux 3.9.1
25 -
26 -Patch: 1001_linux-3.9.2.patch
27 -From: http://www.kernel.org
28 -Desc: Linux 3.9.2
29 -
30 -Patch: 1002_linux-3.9.3.patch
31 -From: http://www.kernel.org
32 -Desc: Linux 3.9.3
33 -
34 Patch: 1500_XATTR_USER_PREFIX.patch
35 From: https://bugs.gentoo.org/show_bug.cgi?id=470644
36 Desc: Support for namespace user.pax.* on tmpfs.
37
38 Deleted: genpatches-2.6/trunk/3.10/1000_linux-3.9.1.patch
39 ===================================================================
40 --- genpatches-2.6/trunk/3.10/1000_linux-3.9.1.patch 2013-05-21 00:40:11 UTC (rev 2385)
41 +++ genpatches-2.6/trunk/3.10/1000_linux-3.9.1.patch 2013-05-21 00:44:32 UTC (rev 2386)
42 @@ -1,3415 +0,0 @@
43 -diff --git a/Makefile b/Makefile
44 -index 8fe6991..5fcb591 100644
45 ---- a/Makefile
46 -+++ b/Makefile
47 -@@ -1,6 +1,6 @@
48 - VERSION = 3
49 - PATCHLEVEL = 9
50 --SUBLEVEL = 0
51 -+SUBLEVEL = 1
52 - EXTRAVERSION =
53 - NAME = Unicycling Gorilla
54 -
55 -diff --git a/arch/arm/boot/dts/at91sam9260.dtsi b/arch/arm/boot/dts/at91sam9260.dtsi
56 -index cb7bcc5..02b70a4 100644
57 ---- a/arch/arm/boot/dts/at91sam9260.dtsi
58 -+++ b/arch/arm/boot/dts/at91sam9260.dtsi
59 -@@ -158,8 +158,8 @@
60 - usart1 {
61 - pinctrl_usart1: usart1-0 {
62 - atmel,pins =
63 -- <2 6 0x1 0x1 /* PB6 periph A with pullup */
64 -- 2 7 0x1 0x0>; /* PB7 periph A */
65 -+ <1 6 0x1 0x1 /* PB6 periph A with pullup */
66 -+ 1 7 0x1 0x0>; /* PB7 periph A */
67 - };
68 -
69 - pinctrl_usart1_rts: usart1_rts-0 {
70 -@@ -194,18 +194,18 @@
71 - usart3 {
72 - pinctrl_usart3: usart3-0 {
73 - atmel,pins =
74 -- <2 10 0x1 0x1 /* PB10 periph A with pullup */
75 -- 2 11 0x1 0x0>; /* PB11 periph A */
76 -+ <1 10 0x1 0x1 /* PB10 periph A with pullup */
77 -+ 1 11 0x1 0x0>; /* PB11 periph A */
78 - };
79 -
80 - pinctrl_usart3_rts: usart3_rts-0 {
81 - atmel,pins =
82 -- <3 8 0x2 0x0>; /* PB8 periph B */
83 -+ <2 8 0x2 0x0>; /* PC8 periph B */
84 - };
85 -
86 - pinctrl_usart3_cts: usart3_cts-0 {
87 - atmel,pins =
88 -- <3 10 0x2 0x0>; /* PB10 periph B */
89 -+ <2 10 0x2 0x0>; /* PC10 periph B */
90 - };
91 - };
92 -
93 -@@ -220,8 +220,8 @@
94 - uart1 {
95 - pinctrl_uart1: uart1-0 {
96 - atmel,pins =
97 -- <2 12 0x1 0x1 /* PB12 periph A with pullup */
98 -- 2 13 0x1 0x0>; /* PB13 periph A */
99 -+ <1 12 0x1 0x1 /* PB12 periph A with pullup */
100 -+ 1 13 0x1 0x0>; /* PB13 periph A */
101 - };
102 - };
103 -
104 -diff --git a/arch/arm/boot/dts/at91sam9g15.dtsi b/arch/arm/boot/dts/at91sam9g15.dtsi
105 -index fbe7a70..28467fd 100644
106 ---- a/arch/arm/boot/dts/at91sam9g15.dtsi
107 -+++ b/arch/arm/boot/dts/at91sam9g15.dtsi
108 -@@ -10,7 +10,7 @@
109 -
110 - / {
111 - model = "Atmel AT91SAM9G15 SoC";
112 -- compatible = "atmel, at91sam9g15, atmel,at91sam9x5";
113 -+ compatible = "atmel,at91sam9g15", "atmel,at91sam9x5";
114 -
115 - ahb {
116 - apb {
117 -diff --git a/arch/arm/boot/dts/at91sam9g15ek.dts b/arch/arm/boot/dts/at91sam9g15ek.dts
118 -index 86dd3f6..5427b2d 100644
119 ---- a/arch/arm/boot/dts/at91sam9g15ek.dts
120 -+++ b/arch/arm/boot/dts/at91sam9g15ek.dts
121 -@@ -11,6 +11,6 @@
122 - /include/ "at91sam9x5ek.dtsi"
123 -
124 - / {
125 -- model = "Atmel AT91SAM9G25-EK";
126 -+ model = "Atmel AT91SAM9G15-EK";
127 - compatible = "atmel,at91sam9g15ek", "atmel,at91sam9x5ek", "atmel,at91sam9x5", "atmel,at91sam9";
128 - };
129 -diff --git a/arch/arm/boot/dts/at91sam9g25.dtsi b/arch/arm/boot/dts/at91sam9g25.dtsi
130 -index 05a718f..5fd32df 100644
131 ---- a/arch/arm/boot/dts/at91sam9g25.dtsi
132 -+++ b/arch/arm/boot/dts/at91sam9g25.dtsi
133 -@@ -10,7 +10,7 @@
134 -
135 - / {
136 - model = "Atmel AT91SAM9G25 SoC";
137 -- compatible = "atmel, at91sam9g25, atmel,at91sam9x5";
138 -+ compatible = "atmel,at91sam9g25", "atmel,at91sam9x5";
139 -
140 - ahb {
141 - apb {
142 -diff --git a/arch/arm/boot/dts/at91sam9g35.dtsi b/arch/arm/boot/dts/at91sam9g35.dtsi
143 -index f9d14a7..d6fa8af 100644
144 ---- a/arch/arm/boot/dts/at91sam9g35.dtsi
145 -+++ b/arch/arm/boot/dts/at91sam9g35.dtsi
146 -@@ -10,7 +10,7 @@
147 -
148 - / {
149 - model = "Atmel AT91SAM9G35 SoC";
150 -- compatible = "atmel, at91sam9g35, atmel,at91sam9x5";
151 -+ compatible = "atmel,at91sam9g35", "atmel,at91sam9x5";
152 -
153 - ahb {
154 - apb {
155 -diff --git a/arch/arm/boot/dts/at91sam9x25.dtsi b/arch/arm/boot/dts/at91sam9x25.dtsi
156 -index 54eb33b..9ac2bc2 100644
157 ---- a/arch/arm/boot/dts/at91sam9x25.dtsi
158 -+++ b/arch/arm/boot/dts/at91sam9x25.dtsi
159 -@@ -10,7 +10,7 @@
160 -
161 - / {
162 - model = "Atmel AT91SAM9X25 SoC";
163 -- compatible = "atmel, at91sam9x25, atmel,at91sam9x5";
164 -+ compatible = "atmel,at91sam9x25", "atmel,at91sam9x5";
165 -
166 - ahb {
167 - apb {
168 -diff --git a/arch/arm/boot/dts/at91sam9x35.dtsi b/arch/arm/boot/dts/at91sam9x35.dtsi
169 -index fb102d6..ba67d83 100644
170 ---- a/arch/arm/boot/dts/at91sam9x35.dtsi
171 -+++ b/arch/arm/boot/dts/at91sam9x35.dtsi
172 -@@ -10,7 +10,7 @@
173 -
174 - / {
175 - model = "Atmel AT91SAM9X35 SoC";
176 -- compatible = "atmel, at91sam9x35, atmel,at91sam9x5";
177 -+ compatible = "atmel,at91sam9x35", "atmel,at91sam9x5";
178 -
179 - ahb {
180 - apb {
181 -diff --git a/arch/arm/boot/dts/at91sam9x5ek.dtsi b/arch/arm/boot/dts/at91sam9x5ek.dtsi
182 -index 8a7cf1d..ccab256 100644
183 ---- a/arch/arm/boot/dts/at91sam9x5ek.dtsi
184 -+++ b/arch/arm/boot/dts/at91sam9x5ek.dtsi
185 -@@ -13,7 +13,7 @@
186 - compatible = "atmel,at91sam9x5ek", "atmel,at91sam9x5", "atmel,at91sam9";
187 -
188 - chosen {
189 -- bootargs = "128M console=ttyS0,115200 root=/dev/mtdblock1 rw rootfstype=ubifs ubi.mtd=1 root=ubi0:rootfs";
190 -+ bootargs = "console=ttyS0,115200 root=/dev/mtdblock1 rw rootfstype=ubifs ubi.mtd=1 root=ubi0:rootfs";
191 - };
192 -
193 - ahb {
194 -diff --git a/arch/arm/configs/at91sam9g45_defconfig b/arch/arm/configs/at91sam9g45_defconfig
195 -index 606d48f..8aab786 100644
196 ---- a/arch/arm/configs/at91sam9g45_defconfig
197 -+++ b/arch/arm/configs/at91sam9g45_defconfig
198 -@@ -173,7 +173,6 @@ CONFIG_MMC=y
199 - # CONFIG_MMC_BLOCK_BOUNCE is not set
200 - CONFIG_SDIO_UART=m
201 - CONFIG_MMC_ATMELMCI=y
202 --CONFIG_MMC_ATMELMCI_DMA=y
203 - CONFIG_LEDS_ATMEL_PWM=y
204 - CONFIG_LEDS_GPIO=y
205 - CONFIG_LEDS_TRIGGER_TIMER=y
206 -diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
207 -index 80d6fc4..9bcd262 100644
208 ---- a/arch/arm/include/asm/pgtable.h
209 -+++ b/arch/arm/include/asm/pgtable.h
210 -@@ -61,6 +61,15 @@ extern void __pgd_error(const char *file, int line, pgd_t);
211 - #define FIRST_USER_ADDRESS PAGE_SIZE
212 -
213 - /*
214 -+ * Use TASK_SIZE as the ceiling argument for free_pgtables() and
215 -+ * free_pgd_range() to avoid freeing the modules pmd when LPAE is enabled (pmd
216 -+ * page shared between user and kernel).
217 -+ */
218 -+#ifdef CONFIG_ARM_LPAE
219 -+#define USER_PGTABLES_CEILING TASK_SIZE
220 -+#endif
221 -+
222 -+/*
223 - * The pgprot_* and protection_map entries will be fixed up in runtime
224 - * to include the cachable and bufferable bits based on memory policy,
225 - * as well as any architecture dependent bits like global/ASID and SMP
226 -diff --git a/arch/arm/mach-at91/setup.c b/arch/arm/mach-at91/setup.c
227 -index 4b67847..6b4608d 100644
228 ---- a/arch/arm/mach-at91/setup.c
229 -+++ b/arch/arm/mach-at91/setup.c
230 -@@ -333,7 +333,7 @@ static void at91_dt_rstc(void)
231 -
232 - of_id = of_match_node(rstc_ids, np);
233 - if (!of_id)
234 -- panic("AT91: rtsc no restart function availlable\n");
235 -+ panic("AT91: rtsc no restart function available\n");
236 -
237 - arm_pm_restart = of_id->data;
238 -
239 -diff --git a/arch/arm/mach-omap2/cpuidle34xx.c b/arch/arm/mach-omap2/cpuidle34xx.c
240 -index 80392fc..4f67a5b 100644
241 ---- a/arch/arm/mach-omap2/cpuidle34xx.c
242 -+++ b/arch/arm/mach-omap2/cpuidle34xx.c
243 -@@ -274,8 +274,9 @@ static int omap3_enter_idle_bm(struct cpuidle_device *dev,
244 - static DEFINE_PER_CPU(struct cpuidle_device, omap3_idle_dev);
245 -
246 - static struct cpuidle_driver omap3_idle_driver = {
247 -- .name = "omap3_idle",
248 -- .owner = THIS_MODULE,
249 -+ .name = "omap3_idle",
250 -+ .owner = THIS_MODULE,
251 -+ .en_core_tk_irqen = 1,
252 - .states = {
253 - {
254 - .enter = omap3_enter_idle_bm,
255 -diff --git a/arch/arm/mach-u300/include/mach/u300-regs.h b/arch/arm/mach-u300/include/mach/u300-regs.h
256 -index 1e49d90..0320495 100644
257 ---- a/arch/arm/mach-u300/include/mach/u300-regs.h
258 -+++ b/arch/arm/mach-u300/include/mach/u300-regs.h
259 -@@ -95,7 +95,7 @@
260 - #define U300_SPI_BASE (U300_FAST_PER_PHYS_BASE+0x6000)
261 -
262 - /* Fast UART1 on U335 only */
263 --#define U300_UART1_BASE (U300_SLOW_PER_PHYS_BASE+0x7000)
264 -+#define U300_UART1_BASE (U300_FAST_PER_PHYS_BASE+0x7000)
265 -
266 - /*
267 - * SLOW peripherals
268 -diff --git a/arch/avr32/configs/favr-32_defconfig b/arch/avr32/configs/favr-32_defconfig
269 -index 0421498..9791820 100644
270 ---- a/arch/avr32/configs/favr-32_defconfig
271 -+++ b/arch/avr32/configs/favr-32_defconfig
272 -@@ -122,7 +122,6 @@ CONFIG_USB_G_SERIAL=m
273 - CONFIG_USB_CDC_COMPOSITE=m
274 - CONFIG_MMC=y
275 - CONFIG_MMC_ATMELMCI=y
276 --CONFIG_MMC_ATMELMCI_DMA=y
277 - CONFIG_NEW_LEDS=y
278 - CONFIG_LEDS_CLASS=y
279 - CONFIG_LEDS_ATMEL_PWM=m
280 -diff --git a/arch/avr32/configs/merisc_defconfig b/arch/avr32/configs/merisc_defconfig
281 -index 3befab9..65de443 100644
282 ---- a/arch/avr32/configs/merisc_defconfig
283 -+++ b/arch/avr32/configs/merisc_defconfig
284 -@@ -102,7 +102,6 @@ CONFIG_FRAMEBUFFER_CONSOLE=y
285 - CONFIG_LOGO=y
286 - CONFIG_MMC=y
287 - CONFIG_MMC_ATMELMCI=y
288 --CONFIG_MMC_ATMELMCI_DMA=y
289 - CONFIG_NEW_LEDS=y
290 - CONFIG_LEDS_CLASS=y
291 - CONFIG_LEDS_ATMEL_PWM=y
292 -diff --git a/arch/ia64/include/asm/futex.h b/arch/ia64/include/asm/futex.h
293 -index d2bf1fd..76acbcd 100644
294 ---- a/arch/ia64/include/asm/futex.h
295 -+++ b/arch/ia64/include/asm/futex.h
296 -@@ -106,16 +106,15 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
297 - return -EFAULT;
298 -
299 - {
300 -- register unsigned long r8 __asm ("r8");
301 -+ register unsigned long r8 __asm ("r8") = 0;
302 - unsigned long prev;
303 - __asm__ __volatile__(
304 - " mf;; \n"
305 -- " mov %0=r0 \n"
306 - " mov ar.ccv=%4;; \n"
307 - "[1:] cmpxchg4.acq %1=[%2],%3,ar.ccv \n"
308 - " .xdata4 \"__ex_table\", 1b-., 2f-. \n"
309 - "[2:]"
310 -- : "=r" (r8), "=r" (prev)
311 -+ : "+r" (r8), "=&r" (prev)
312 - : "r" (uaddr), "r" (newval),
313 - "rO" ((long) (unsigned) oldval)
314 - : "memory");
315 -diff --git a/arch/ia64/include/asm/mca.h b/arch/ia64/include/asm/mca.h
316 -index 43f96ab..8c70961 100644
317 ---- a/arch/ia64/include/asm/mca.h
318 -+++ b/arch/ia64/include/asm/mca.h
319 -@@ -143,6 +143,7 @@ extern unsigned long __per_cpu_mca[NR_CPUS];
320 - extern int cpe_vector;
321 - extern int ia64_cpe_irq;
322 - extern void ia64_mca_init(void);
323 -+extern void ia64_mca_irq_init(void);
324 - extern void ia64_mca_cpu_init(void *);
325 - extern void ia64_os_mca_dispatch(void);
326 - extern void ia64_os_mca_dispatch_end(void);
327 -diff --git a/arch/ia64/kernel/irq.c b/arch/ia64/kernel/irq.c
328 -index ad69606..f2c41828 100644
329 ---- a/arch/ia64/kernel/irq.c
330 -+++ b/arch/ia64/kernel/irq.c
331 -@@ -23,6 +23,8 @@
332 - #include <linux/interrupt.h>
333 - #include <linux/kernel_stat.h>
334 -
335 -+#include <asm/mca.h>
336 -+
337 - /*
338 - * 'what should we do if we get a hw irq event on an illegal vector'.
339 - * each architecture has to answer this themselves.
340 -@@ -83,6 +85,12 @@ bool is_affinity_mask_valid(const struct cpumask *cpumask)
341 -
342 - #endif /* CONFIG_SMP */
343 -
344 -+int __init arch_early_irq_init(void)
345 -+{
346 -+ ia64_mca_irq_init();
347 -+ return 0;
348 -+}
349 -+
350 - #ifdef CONFIG_HOTPLUG_CPU
351 - unsigned int vectors_in_migration[NR_IRQS];
352 -
353 -diff --git a/arch/ia64/kernel/mca.c b/arch/ia64/kernel/mca.c
354 -index 65bf9cd..d7396db 100644
355 ---- a/arch/ia64/kernel/mca.c
356 -+++ b/arch/ia64/kernel/mca.c
357 -@@ -2074,22 +2074,16 @@ ia64_mca_init(void)
358 - printk(KERN_INFO "MCA related initialization done\n");
359 - }
360 -
361 -+
362 - /*
363 -- * ia64_mca_late_init
364 -- *
365 -- * Opportunity to setup things that require initialization later
366 -- * than ia64_mca_init. Setup a timer to poll for CPEs if the
367 -- * platform doesn't support an interrupt driven mechanism.
368 -- *
369 -- * Inputs : None
370 -- * Outputs : Status
371 -+ * These pieces cannot be done in ia64_mca_init() because it is called before
372 -+ * early_irq_init() which would wipe out our percpu irq registrations. But we
373 -+ * cannot leave them until ia64_mca_late_init() because by then all the other
374 -+ * processors have been brought online and have set their own CMC vectors to
375 -+ * point at a non-existant action. Called from arch_early_irq_init().
376 - */
377 --static int __init
378 --ia64_mca_late_init(void)
379 -+void __init ia64_mca_irq_init(void)
380 - {
381 -- if (!mca_init)
382 -- return 0;
383 --
384 - /*
385 - * Configure the CMCI/P vector and handler. Interrupts for CMC are
386 - * per-processor, so AP CMC interrupts are setup in smp_callin() (smpboot.c).
387 -@@ -2108,6 +2102,23 @@ ia64_mca_late_init(void)
388 - /* Setup the CPEI/P handler */
389 - register_percpu_irq(IA64_CPEP_VECTOR, &mca_cpep_irqaction);
390 - #endif
391 -+}
392 -+
393 -+/*
394 -+ * ia64_mca_late_init
395 -+ *
396 -+ * Opportunity to setup things that require initialization later
397 -+ * than ia64_mca_init. Setup a timer to poll for CPEs if the
398 -+ * platform doesn't support an interrupt driven mechanism.
399 -+ *
400 -+ * Inputs : None
401 -+ * Outputs : Status
402 -+ */
403 -+static int __init
404 -+ia64_mca_late_init(void)
405 -+{
406 -+ if (!mca_init)
407 -+ return 0;
408 -
409 - register_hotcpu_notifier(&mca_cpu_notifier);
410 -
411 -diff --git a/arch/ia64/kvm/vtlb.c b/arch/ia64/kvm/vtlb.c
412 -index 4332f7e..a7869f8 100644
413 ---- a/arch/ia64/kvm/vtlb.c
414 -+++ b/arch/ia64/kvm/vtlb.c
415 -@@ -256,7 +256,7 @@ u64 guest_vhpt_lookup(u64 iha, u64 *pte)
416 - "srlz.d;;"
417 - "ssm psr.i;;"
418 - "srlz.d;;"
419 -- : "=r"(ret) : "r"(iha), "r"(pte):"memory");
420 -+ : "=&r"(ret) : "r"(iha), "r"(pte) : "memory");
421 -
422 - return ret;
423 - }
424 -diff --git a/arch/powerpc/kernel/cpu_setup_power.S b/arch/powerpc/kernel/cpu_setup_power.S
425 -index ea847ab..1167008 100644
426 ---- a/arch/powerpc/kernel/cpu_setup_power.S
427 -+++ b/arch/powerpc/kernel/cpu_setup_power.S
428 -@@ -66,6 +66,7 @@ _GLOBAL(__restore_cpu_power8)
429 - bl __init_FSCR
430 - mfmsr r3
431 - rldicl. r0,r3,4,63
432 -+ mtlr r11
433 - beqlr
434 - li r0,0
435 - mtspr SPRN_LPID,r0
436 -diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
437 -index 56bd923..3bbe7ed 100644
438 ---- a/arch/powerpc/kernel/exceptions-64s.S
439 -+++ b/arch/powerpc/kernel/exceptions-64s.S
440 -@@ -797,7 +797,7 @@ hardware_interrupt_relon_hv:
441 - _MASKABLE_RELON_EXCEPTION_PSERIES(0x502, hardware_interrupt, EXC_HV, SOFTEN_TEST_HV)
442 - FTR_SECTION_ELSE
443 - _MASKABLE_RELON_EXCEPTION_PSERIES(0x500, hardware_interrupt, EXC_STD, SOFTEN_TEST_PR)
444 -- ALT_FTR_SECTION_END_IFSET(CPU_FTR_ARCH_206)
445 -+ ALT_FTR_SECTION_END_IFSET(CPU_FTR_HVMODE)
446 - STD_RELON_EXCEPTION_PSERIES(0x4600, 0x600, alignment)
447 - STD_RELON_EXCEPTION_PSERIES(0x4700, 0x700, program_check)
448 - STD_RELON_EXCEPTION_PSERIES(0x4800, 0x800, fp_unavailable)
449 -diff --git a/arch/powerpc/kernel/head_64.S b/arch/powerpc/kernel/head_64.S
450 -index 0886ae6..b61363d 100644
451 ---- a/arch/powerpc/kernel/head_64.S
452 -+++ b/arch/powerpc/kernel/head_64.S
453 -@@ -509,6 +509,7 @@ _GLOBAL(copy_and_flush)
454 - sync
455 - addi r5,r5,8
456 - addi r6,r6,8
457 -+ isync
458 - blr
459 -
460 - .align 8
461 -diff --git a/arch/powerpc/platforms/cell/spufs/inode.c b/arch/powerpc/platforms/cell/spufs/inode.c
462 -index 3f3bb4c..35f77a4 100644
463 ---- a/arch/powerpc/platforms/cell/spufs/inode.c
464 -+++ b/arch/powerpc/platforms/cell/spufs/inode.c
465 -@@ -99,6 +99,7 @@ spufs_new_inode(struct super_block *sb, umode_t mode)
466 - if (!inode)
467 - goto out;
468 -
469 -+ inode->i_ino = get_next_ino();
470 - inode->i_mode = mode;
471 - inode->i_uid = current_fsuid();
472 - inode->i_gid = current_fsgid();
473 -diff --git a/arch/x86/crypto/crc32c-pcl-intel-asm_64.S b/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
474 -index cf1a7ec..a59c643 100644
475 ---- a/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
476 -+++ b/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
477 -@@ -42,6 +42,7 @@
478 - * SOFTWARE.
479 - */
480 -
481 -+#include <asm/inst.h>
482 - #include <linux/linkage.h>
483 -
484 - ## ISCSI CRC 32 Implementation with crc32 and pclmulqdq Instruction
485 -@@ -225,10 +226,10 @@ LABEL crc_ %i
486 - movdqa (bufp), %xmm0 # 2 consts: K1:K2
487 -
488 - movq crc_init, %xmm1 # CRC for block 1
489 -- pclmulqdq $0x00,%xmm0,%xmm1 # Multiply by K2
490 -+ PCLMULQDQ 0x00,%xmm0,%xmm1 # Multiply by K2
491 -
492 - movq crc1, %xmm2 # CRC for block 2
493 -- pclmulqdq $0x10, %xmm0, %xmm2 # Multiply by K1
494 -+ PCLMULQDQ 0x10, %xmm0, %xmm2 # Multiply by K1
495 -
496 - pxor %xmm2,%xmm1
497 - movq %xmm1, %rax
498 -diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
499 -index c5e403f..1c68ccb 100644
500 ---- a/arch/x86/kernel/head64.c
501 -+++ b/arch/x86/kernel/head64.c
502 -@@ -34,6 +34,7 @@
503 - extern pgd_t early_level4_pgt[PTRS_PER_PGD];
504 - extern pmd_t early_dynamic_pgts[EARLY_DYNAMIC_PAGE_TABLES][PTRS_PER_PMD];
505 - static unsigned int __initdata next_early_pgt = 2;
506 -+pmdval_t __initdata early_pmd_flags = __PAGE_KERNEL_LARGE & ~(_PAGE_GLOBAL | _PAGE_NX);
507 -
508 - /* Wipe all early page tables except for the kernel symbol map */
509 - static void __init reset_early_page_tables(void)
510 -@@ -99,7 +100,7 @@ again:
511 - pmd_p[i] = 0;
512 - *pud_p = (pudval_t)pmd_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE;
513 - }
514 -- pmd = (physaddr & PMD_MASK) + (__PAGE_KERNEL_LARGE & ~_PAGE_GLOBAL);
515 -+ pmd = (physaddr & PMD_MASK) + early_pmd_flags;
516 - pmd_p[pmd_index(address)] = pmd;
517 -
518 - return 0;
519 -diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
520 -index 6859e96..08f7e80 100644
521 ---- a/arch/x86/kernel/head_64.S
522 -+++ b/arch/x86/kernel/head_64.S
523 -@@ -200,6 +200,7 @@ ENTRY(secondary_startup_64)
524 - btl $20,%edi /* No Execute supported? */
525 - jnc 1f
526 - btsl $_EFER_NX, %eax
527 -+ btsq $_PAGE_BIT_NX,early_pmd_flags(%rip)
528 - 1: wrmsr /* Make changes effective */
529 -
530 - /* Setup cr0 */
531 -diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
532 -index e4595f1..84b7789 100644
533 ---- a/arch/x86/kernel/irq.c
534 -+++ b/arch/x86/kernel/irq.c
535 -@@ -165,10 +165,6 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
536 - u64 arch_irq_stat(void)
537 - {
538 - u64 sum = atomic_read(&irq_err_count);
539 --
540 --#ifdef CONFIG_X86_IO_APIC
541 -- sum += atomic_read(&irq_mis_count);
542 --#endif
543 - return sum;
544 - }
545 -
546 -diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
547 -index a335cc6..a9c9d3e 100644
548 ---- a/arch/x86/kvm/emulate.c
549 -+++ b/arch/x86/kvm/emulate.c
550 -@@ -4162,6 +4162,10 @@ static int decode_operand(struct x86_emulate_ctxt *ctxt, struct operand *op,
551 - break;
552 - case OpMem8:
553 - ctxt->memop.bytes = 1;
554 -+ if (ctxt->memop.type == OP_REG) {
555 -+ ctxt->memop.addr.reg = decode_register(ctxt, ctxt->modrm_rm, 1);
556 -+ fetch_register_operand(&ctxt->memop);
557 -+ }
558 - goto mem_common;
559 - case OpMem16:
560 - ctxt->memop.bytes = 2;
561 -diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
562 -index c8e1c7b..2363127 100644
563 ---- a/arch/x86/xen/enlighten.c
564 -+++ b/arch/x86/xen/enlighten.c
565 -@@ -1589,8 +1589,11 @@ static int __cpuinit xen_hvm_cpu_notify(struct notifier_block *self,
566 - switch (action) {
567 - case CPU_UP_PREPARE:
568 - xen_vcpu_setup(cpu);
569 -- if (xen_have_vector_callback)
570 -+ if (xen_have_vector_callback) {
571 - xen_init_lock_cpu(cpu);
572 -+ if (xen_feature(XENFEAT_hvm_safe_pvclock))
573 -+ xen_setup_timer(cpu);
574 -+ }
575 - break;
576 - default:
577 - break;
578 -diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
579 -index 09ea61d..22c800a 100644
580 ---- a/arch/x86/xen/smp.c
581 -+++ b/arch/x86/xen/smp.c
582 -@@ -662,6 +662,8 @@ static void xen_hvm_cpu_die(unsigned int cpu)
583 - unbind_from_irqhandler(per_cpu(xen_debug_irq, cpu), NULL);
584 - unbind_from_irqhandler(per_cpu(xen_callfuncsingle_irq, cpu), NULL);
585 - unbind_from_irqhandler(per_cpu(xen_irq_work, cpu), NULL);
586 -+ xen_uninit_lock_cpu(cpu);
587 -+ xen_teardown_timer(cpu);
588 - native_cpu_die(cpu);
589 - }
590 -
591 -diff --git a/arch/x86/xen/time.c b/arch/x86/xen/time.c
592 -index 0296a95..054cc01 100644
593 ---- a/arch/x86/xen/time.c
594 -+++ b/arch/x86/xen/time.c
595 -@@ -497,7 +497,11 @@ static void xen_hvm_setup_cpu_clockevents(void)
596 - {
597 - int cpu = smp_processor_id();
598 - xen_setup_runstate_info(cpu);
599 -- xen_setup_timer(cpu);
600 -+ /*
601 -+ * xen_setup_timer(cpu) - snprintf is bad in atomic context. Hence
602 -+ * doing it xen_hvm_cpu_notify (which gets called by smp_init during
603 -+ * early bootup and also during CPU hotplug events).
604 -+ */
605 - xen_setup_cpu_clockevents();
606 - }
607 -
608 -diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
609 -index 586e7e9..bcb7a3b 100644
610 ---- a/drivers/acpi/osl.c
611 -+++ b/drivers/acpi/osl.c
612 -@@ -641,7 +641,7 @@ void __init acpi_initrd_override(void *data, size_t size)
613 - * Both memblock_reserve and e820_add_region (via arch_reserve_mem_area)
614 - * works fine.
615 - */
616 -- memblock_reserve(acpi_tables_addr, acpi_tables_addr + all_tables_size);
617 -+ memblock_reserve(acpi_tables_addr, all_tables_size);
618 - arch_reserve_mem_area(acpi_tables_addr, all_tables_size);
619 -
620 - p = early_ioremap(acpi_tables_addr, all_tables_size);
621 -diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
622 -index 6ae5e44..4241b8d 100644
623 ---- a/drivers/acpi/pci_root.c
624 -+++ b/drivers/acpi/pci_root.c
625 -@@ -201,8 +201,8 @@ static acpi_status acpi_pci_query_osc(struct acpi_pci_root *root,
626 - *control &= OSC_PCI_CONTROL_MASKS;
627 - capbuf[OSC_CONTROL_TYPE] = *control | root->osc_control_set;
628 - } else {
629 -- /* Run _OSC query for all possible controls. */
630 -- capbuf[OSC_CONTROL_TYPE] = OSC_PCI_CONTROL_MASKS;
631 -+ /* Run _OSC query only with existing controls. */
632 -+ capbuf[OSC_CONTROL_TYPE] = root->osc_control_set;
633 - }
634 -
635 - status = acpi_pci_run_osc(root->device->handle, capbuf, &result);
636 -diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
637 -index 8470771..a33821c 100644
638 ---- a/drivers/acpi/thermal.c
639 -+++ b/drivers/acpi/thermal.c
640 -@@ -723,9 +723,19 @@ static int thermal_get_trend(struct thermal_zone_device *thermal,
641 - return -EINVAL;
642 -
643 - if (type == THERMAL_TRIP_ACTIVE) {
644 -- /* aggressive active cooling */
645 -- *trend = THERMAL_TREND_RAISING;
646 -- return 0;
647 -+ unsigned long trip_temp;
648 -+ unsigned long temp = KELVIN_TO_MILLICELSIUS(tz->temperature,
649 -+ tz->kelvin_offset);
650 -+ if (thermal_get_trip_temp(thermal, trip, &trip_temp))
651 -+ return -EINVAL;
652 -+
653 -+ if (temp > trip_temp) {
654 -+ *trend = THERMAL_TREND_RAISING;
655 -+ return 0;
656 -+ } else {
657 -+ /* Fall back on default trend */
658 -+ return -EINVAL;
659 -+ }
660 - }
661 -
662 - /*
663 -diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c
664 -index 8a52dab..3badf18 100644
665 ---- a/drivers/ata/libata-acpi.c
666 -+++ b/drivers/ata/libata-acpi.c
667 -@@ -61,7 +61,8 @@ acpi_handle ata_ap_acpi_handle(struct ata_port *ap)
668 - if (ap->flags & ATA_FLAG_ACPI_SATA)
669 - return NULL;
670 -
671 -- return acpi_get_child(DEVICE_ACPI_HANDLE(ap->host->dev), ap->port_no);
672 -+ return ap->scsi_host ?
673 -+ DEVICE_ACPI_HANDLE(&ap->scsi_host->shost_gendev) : NULL;
674 - }
675 - EXPORT_SYMBOL(ata_ap_acpi_handle);
676 -
677 -@@ -240,28 +241,15 @@ void ata_acpi_dissociate(struct ata_host *host)
678 - }
679 - }
680 -
681 --/**
682 -- * ata_acpi_gtm - execute _GTM
683 -- * @ap: target ATA port
684 -- * @gtm: out parameter for _GTM result
685 -- *
686 -- * Evaluate _GTM and store the result in @gtm.
687 -- *
688 -- * LOCKING:
689 -- * EH context.
690 -- *
691 -- * RETURNS:
692 -- * 0 on success, -ENOENT if _GTM doesn't exist, -errno on failure.
693 -- */
694 --int ata_acpi_gtm(struct ata_port *ap, struct ata_acpi_gtm *gtm)
695 -+static int __ata_acpi_gtm(struct ata_port *ap, acpi_handle handle,
696 -+ struct ata_acpi_gtm *gtm)
697 - {
698 - struct acpi_buffer output = { .length = ACPI_ALLOCATE_BUFFER };
699 - union acpi_object *out_obj;
700 - acpi_status status;
701 - int rc = 0;
702 -
703 -- status = acpi_evaluate_object(ata_ap_acpi_handle(ap), "_GTM", NULL,
704 -- &output);
705 -+ status = acpi_evaluate_object(handle, "_GTM", NULL, &output);
706 -
707 - rc = -ENOENT;
708 - if (status == AE_NOT_FOUND)
709 -@@ -295,6 +283,27 @@ int ata_acpi_gtm(struct ata_port *ap, struct ata_acpi_gtm *gtm)
710 - return rc;
711 - }
712 -
713 -+/**
714 -+ * ata_acpi_gtm - execute _GTM
715 -+ * @ap: target ATA port
716 -+ * @gtm: out parameter for _GTM result
717 -+ *
718 -+ * Evaluate _GTM and store the result in @gtm.
719 -+ *
720 -+ * LOCKING:
721 -+ * EH context.
722 -+ *
723 -+ * RETURNS:
724 -+ * 0 on success, -ENOENT if _GTM doesn't exist, -errno on failure.
725 -+ */
726 -+int ata_acpi_gtm(struct ata_port *ap, struct ata_acpi_gtm *gtm)
727 -+{
728 -+ if (ata_ap_acpi_handle(ap))
729 -+ return __ata_acpi_gtm(ap, ata_ap_acpi_handle(ap), gtm);
730 -+ else
731 -+ return -EINVAL;
732 -+}
733 -+
734 - EXPORT_SYMBOL_GPL(ata_acpi_gtm);
735 -
736 - /**
737 -@@ -1080,7 +1089,7 @@ static int ata_acpi_bind_host(struct ata_port *ap, acpi_handle *handle)
738 - if (!*handle)
739 - return -ENODEV;
740 -
741 -- if (ata_acpi_gtm(ap, &ap->__acpi_init_gtm) == 0)
742 -+ if (__ata_acpi_gtm(ap, *handle, &ap->__acpi_init_gtm) == 0)
743 - ap->pflags |= ATA_PFLAG_INIT_GTM_VALID;
744 -
745 - return 0;
746 -diff --git a/drivers/ata/sata_highbank.c b/drivers/ata/sata_highbank.c
747 -index 5dba77c..b1a664a 100644
748 ---- a/drivers/ata/sata_highbank.c
749 -+++ b/drivers/ata/sata_highbank.c
750 -@@ -251,7 +251,7 @@ static const struct ata_port_info ahci_highbank_port_info = {
751 - };
752 -
753 - static struct scsi_host_template ahci_highbank_platform_sht = {
754 -- AHCI_SHT("highbank-ahci"),
755 -+ AHCI_SHT("sata_highbank"),
756 - };
757 -
758 - static const struct of_device_id ahci_of_match[] = {
759 -diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
760 -index 0d2e82f..7c3b3dc 100644
761 ---- a/drivers/char/tpm/tpm.c
762 -+++ b/drivers/char/tpm/tpm.c
763 -@@ -1337,7 +1337,7 @@ int tpm_pm_suspend(struct device *dev)
764 - {
765 - struct tpm_chip *chip = dev_get_drvdata(dev);
766 - struct tpm_cmd_t cmd;
767 -- int rc;
768 -+ int rc, try;
769 -
770 - u8 dummy_hash[TPM_DIGEST_SIZE] = { 0 };
771 -
772 -@@ -1355,9 +1355,32 @@ int tpm_pm_suspend(struct device *dev)
773 - }
774 -
775 - /* now do the actual savestate */
776 -- cmd.header.in = savestate_header;
777 -- rc = transmit_cmd(chip, &cmd, SAVESTATE_RESULT_SIZE,
778 -- "sending savestate before suspend");
779 -+ for (try = 0; try < TPM_RETRY; try++) {
780 -+ cmd.header.in = savestate_header;
781 -+ rc = transmit_cmd(chip, &cmd, SAVESTATE_RESULT_SIZE, NULL);
782 -+
783 -+ /*
784 -+ * If the TPM indicates that it is too busy to respond to
785 -+ * this command then retry before giving up. It can take
786 -+ * several seconds for this TPM to be ready.
787 -+ *
788 -+ * This can happen if the TPM has already been sent the
789 -+ * SaveState command before the driver has loaded. TCG 1.2
790 -+ * specification states that any communication after SaveState
791 -+ * may cause the TPM to invalidate previously saved state.
792 -+ */
793 -+ if (rc != TPM_WARN_RETRY)
794 -+ break;
795 -+ msleep(TPM_TIMEOUT_RETRY);
796 -+ }
797 -+
798 -+ if (rc)
799 -+ dev_err(chip->dev,
800 -+ "Error (%d) sending savestate before suspend\n", rc);
801 -+ else if (try > 0)
802 -+ dev_warn(chip->dev, "TPM savestate took %dms\n",
803 -+ try * TPM_TIMEOUT_RETRY);
804 -+
805 - return rc;
806 - }
807 - EXPORT_SYMBOL_GPL(tpm_pm_suspend);
808 -diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
809 -index 81b5201..0770d1d 100644
810 ---- a/drivers/char/tpm/tpm.h
811 -+++ b/drivers/char/tpm/tpm.h
812 -@@ -32,10 +32,12 @@ enum tpm_const {
813 - TPM_MINOR = 224, /* officially assigned */
814 - TPM_BUFSIZE = 4096,
815 - TPM_NUM_DEVICES = 256,
816 -+ TPM_RETRY = 50, /* 5 seconds */
817 - };
818 -
819 - enum tpm_timeout {
820 - TPM_TIMEOUT = 5, /* msecs */
821 -+ TPM_TIMEOUT_RETRY = 100 /* msecs */
822 - };
823 -
824 - /* TPM addresses */
825 -@@ -44,6 +46,7 @@ enum tpm_addr {
826 - TPM_ADDR = 0x4E,
827 - };
828 -
829 -+#define TPM_WARN_RETRY 0x800
830 - #define TPM_WARN_DOING_SELFTEST 0x802
831 - #define TPM_ERR_DEACTIVATED 0x6
832 - #define TPM_ERR_DISABLED 0x7
833 -diff --git a/drivers/hv/ring_buffer.c b/drivers/hv/ring_buffer.c
834 -index cafa72f..d6fbb577 100644
835 ---- a/drivers/hv/ring_buffer.c
836 -+++ b/drivers/hv/ring_buffer.c
837 -@@ -71,6 +71,7 @@ u32 hv_end_read(struct hv_ring_buffer_info *rbi)
838 -
839 - static bool hv_need_to_signal(u32 old_write, struct hv_ring_buffer_info *rbi)
840 - {
841 -+ smp_mb();
842 - if (rbi->ring_buffer->interrupt_mask)
843 - return false;
844 -
845 -diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c
846 -index 332c720..3d0f052 100644
847 ---- a/drivers/i2c/busses/i2c-xiic.c
848 -+++ b/drivers/i2c/busses/i2c-xiic.c
849 -@@ -312,10 +312,8 @@ static void xiic_fill_tx_fifo(struct xiic_i2c *i2c)
850 - /* last message in transfer -> STOP */
851 - data |= XIIC_TX_DYN_STOP_MASK;
852 - dev_dbg(i2c->adap.dev.parent, "%s TX STOP\n", __func__);
853 --
854 -- xiic_setreg16(i2c, XIIC_DTR_REG_OFFSET, data);
855 -- } else
856 -- xiic_setreg8(i2c, XIIC_DTR_REG_OFFSET, data);
857 -+ }
858 -+ xiic_setreg16(i2c, XIIC_DTR_REG_OFFSET, data);
859 - }
860 - }
861 -
862 -diff --git a/drivers/md/md.c b/drivers/md/md.c
863 -index aeceedf..a4a93b9 100644
864 ---- a/drivers/md/md.c
865 -+++ b/drivers/md/md.c
866 -@@ -1564,8 +1564,8 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
867 - sector, count, 1) == 0)
868 - return -EINVAL;
869 - }
870 -- } else if (sb->bblog_offset == 0)
871 -- rdev->badblocks.shift = -1;
872 -+ } else if (sb->bblog_offset != 0)
873 -+ rdev->badblocks.shift = 0;
874 -
875 - if (!refdev) {
876 - ret = 1;
877 -@@ -3221,7 +3221,7 @@ int md_rdev_init(struct md_rdev *rdev)
878 - * be used - I wonder if that matters
879 - */
880 - rdev->badblocks.count = 0;
881 -- rdev->badblocks.shift = 0;
882 -+ rdev->badblocks.shift = -1; /* disabled until explicitly enabled */
883 - rdev->badblocks.page = kmalloc(PAGE_SIZE, GFP_KERNEL);
884 - seqlock_init(&rdev->badblocks.lock);
885 - if (rdev->badblocks.page == NULL)
886 -@@ -3293,9 +3293,6 @@ static struct md_rdev *md_import_device(dev_t newdev, int super_format, int supe
887 - goto abort_free;
888 - }
889 - }
890 -- if (super_format == -1)
891 -- /* hot-add for 0.90, or non-persistent: so no badblocks */
892 -- rdev->badblocks.shift = -1;
893 -
894 - return rdev;
895 -
896 -diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
897 -index fd86b37..6af167f 100644
898 ---- a/drivers/md/raid1.c
899 -+++ b/drivers/md/raid1.c
900 -@@ -981,7 +981,12 @@ static void raid1_unplug(struct blk_plug_cb *cb, bool from_schedule)
901 - while (bio) { /* submit pending writes */
902 - struct bio *next = bio->bi_next;
903 - bio->bi_next = NULL;
904 -- generic_make_request(bio);
905 -+ if (unlikely((bio->bi_rw & REQ_DISCARD) &&
906 -+ !blk_queue_discard(bdev_get_queue(bio->bi_bdev))))
907 -+ /* Just ignore it */
908 -+ bio_endio(bio, 0);
909 -+ else
910 -+ generic_make_request(bio);
911 - bio = next;
912 - }
913 - kfree(plug);
914 -diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
915 -index 77b562d..46c14e5 100644
916 ---- a/drivers/md/raid10.c
917 -+++ b/drivers/md/raid10.c
918 -@@ -1133,7 +1133,12 @@ static void raid10_unplug(struct blk_plug_cb *cb, bool from_schedule)
919 - while (bio) { /* submit pending writes */
920 - struct bio *next = bio->bi_next;
921 - bio->bi_next = NULL;
922 -- generic_make_request(bio);
923 -+ if (unlikely((bio->bi_rw & REQ_DISCARD) &&
924 -+ !blk_queue_discard(bdev_get_queue(bio->bi_bdev))))
925 -+ /* Just ignore it */
926 -+ bio_endio(bio, 0);
927 -+ else
928 -+ generic_make_request(bio);
929 - bio = next;
930 - }
931 - kfree(plug);
932 -diff --git a/drivers/mfd/adp5520.c b/drivers/mfd/adp5520.c
933 -index 210dd03..6b40e0c 100644
934 ---- a/drivers/mfd/adp5520.c
935 -+++ b/drivers/mfd/adp5520.c
936 -@@ -36,6 +36,7 @@ struct adp5520_chip {
937 - struct blocking_notifier_head notifier_list;
938 - int irq;
939 - unsigned long id;
940 -+ uint8_t mode;
941 - };
942 -
943 - static int __adp5520_read(struct i2c_client *client,
944 -@@ -326,7 +327,10 @@ static int adp5520_suspend(struct device *dev)
945 - struct i2c_client *client = to_i2c_client(dev);
946 - struct adp5520_chip *chip = dev_get_drvdata(&client->dev);
947 -
948 -- adp5520_clr_bits(chip->dev, ADP5520_MODE_STATUS, ADP5520_nSTNBY);
949 -+ adp5520_read(chip->dev, ADP5520_MODE_STATUS, &chip->mode);
950 -+ /* All other bits are W1C */
951 -+ chip->mode &= ADP5520_BL_EN | ADP5520_DIM_EN | ADP5520_nSTNBY;
952 -+ adp5520_write(chip->dev, ADP5520_MODE_STATUS, 0);
953 - return 0;
954 - }
955 -
956 -@@ -335,7 +339,7 @@ static int adp5520_resume(struct device *dev)
957 - struct i2c_client *client = to_i2c_client(dev);
958 - struct adp5520_chip *chip = dev_get_drvdata(&client->dev);
959 -
960 -- adp5520_set_bits(chip->dev, ADP5520_MODE_STATUS, ADP5520_nSTNBY);
961 -+ adp5520_write(chip->dev, ADP5520_MODE_STATUS, chip->mode);
962 - return 0;
963 - }
964 - #endif
965 -diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
966 -index c8f3d6e..8ac5101 100644
967 ---- a/drivers/mmc/core/mmc.c
968 -+++ b/drivers/mmc/core/mmc.c
969 -@@ -368,13 +368,13 @@ static int mmc_read_ext_csd(struct mmc_card *card, u8 *ext_csd)
970 - ext_csd[EXT_CSD_SEC_FEATURE_SUPPORT];
971 - card->ext_csd.raw_trim_mult =
972 - ext_csd[EXT_CSD_TRIM_MULT];
973 -+ card->ext_csd.raw_partition_support = ext_csd[EXT_CSD_PARTITION_SUPPORT];
974 - if (card->ext_csd.rev >= 4) {
975 - /*
976 - * Enhanced area feature support -- check whether the eMMC
977 - * card has the Enhanced area enabled. If so, export enhanced
978 - * area offset and size to user by adding sysfs interface.
979 - */
980 -- card->ext_csd.raw_partition_support = ext_csd[EXT_CSD_PARTITION_SUPPORT];
981 - if ((ext_csd[EXT_CSD_PARTITION_SUPPORT] & 0x2) &&
982 - (ext_csd[EXT_CSD_PARTITION_ATTRIBUTE] & 0x1)) {
983 - hc_erase_grp_sz =
984 -diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig
985 -index d88219e..9c581c2 100644
986 ---- a/drivers/mmc/host/Kconfig
987 -+++ b/drivers/mmc/host/Kconfig
988 -@@ -300,16 +300,6 @@ config MMC_ATMELMCI
989 -
990 - If unsure, say N.
991 -
992 --config MMC_ATMELMCI_DMA
993 -- bool "Atmel MCI DMA support"
994 -- depends on MMC_ATMELMCI && (AVR32 || ARCH_AT91SAM9G45) && DMA_ENGINE
995 -- help
996 -- Say Y here to have the Atmel MCI driver use a DMA engine to
997 -- do data transfers and thus increase the throughput and
998 -- reduce the CPU utilization.
999 --
1000 -- If unsure, say N.
1001 --
1002 - config MMC_MSM
1003 - tristate "Qualcomm SDCC Controller Support"
1004 - depends on MMC && ARCH_MSM
1005 -diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
1006 -index 722af1d..e75774f 100644
1007 ---- a/drivers/mmc/host/atmel-mci.c
1008 -+++ b/drivers/mmc/host/atmel-mci.c
1009 -@@ -178,6 +178,7 @@ struct atmel_mci {
1010 - void __iomem *regs;
1011 -
1012 - struct scatterlist *sg;
1013 -+ unsigned int sg_len;
1014 - unsigned int pio_offset;
1015 - unsigned int *buffer;
1016 - unsigned int buf_size;
1017 -@@ -892,6 +893,7 @@ static u32 atmci_prepare_data(struct atmel_mci *host, struct mmc_data *data)
1018 - data->error = -EINPROGRESS;
1019 -
1020 - host->sg = data->sg;
1021 -+ host->sg_len = data->sg_len;
1022 - host->data = data;
1023 - host->data_chan = NULL;
1024 -
1025 -@@ -1826,7 +1828,8 @@ static void atmci_read_data_pio(struct atmel_mci *host)
1026 - if (offset == sg->length) {
1027 - flush_dcache_page(sg_page(sg));
1028 - host->sg = sg = sg_next(sg);
1029 -- if (!sg)
1030 -+ host->sg_len--;
1031 -+ if (!sg || !host->sg_len)
1032 - goto done;
1033 -
1034 - offset = 0;
1035 -@@ -1839,7 +1842,8 @@ static void atmci_read_data_pio(struct atmel_mci *host)
1036 -
1037 - flush_dcache_page(sg_page(sg));
1038 - host->sg = sg = sg_next(sg);
1039 -- if (!sg)
1040 -+ host->sg_len--;
1041 -+ if (!sg || !host->sg_len)
1042 - goto done;
1043 -
1044 - offset = 4 - remaining;
1045 -@@ -1890,7 +1894,8 @@ static void atmci_write_data_pio(struct atmel_mci *host)
1046 - nbytes += 4;
1047 - if (offset == sg->length) {
1048 - host->sg = sg = sg_next(sg);
1049 -- if (!sg)
1050 -+ host->sg_len--;
1051 -+ if (!sg || !host->sg_len)
1052 - goto done;
1053 -
1054 - offset = 0;
1055 -@@ -1904,7 +1909,8 @@ static void atmci_write_data_pio(struct atmel_mci *host)
1056 - nbytes += remaining;
1057 -
1058 - host->sg = sg = sg_next(sg);
1059 -- if (!sg) {
1060 -+ host->sg_len--;
1061 -+ if (!sg || !host->sg_len) {
1062 - atmci_writel(host, ATMCI_TDR, value);
1063 - goto done;
1064 - }
1065 -@@ -2487,10 +2493,8 @@ static int __exit atmci_remove(struct platform_device *pdev)
1066 - atmci_readl(host, ATMCI_SR);
1067 - clk_disable(host->mck);
1068 -
1069 --#ifdef CONFIG_MMC_ATMELMCI_DMA
1070 - if (host->dma.chan)
1071 - dma_release_channel(host->dma.chan);
1072 --#endif
1073 -
1074 - free_irq(platform_get_irq(pdev, 0), host);
1075 - iounmap(host->regs);
1076 -diff --git a/drivers/net/ethernet/freescale/gianfar_ptp.c b/drivers/net/ethernet/freescale/gianfar_ptp.c
1077 -index 2e5daee..a3f8a25 100644
1078 ---- a/drivers/net/ethernet/freescale/gianfar_ptp.c
1079 -+++ b/drivers/net/ethernet/freescale/gianfar_ptp.c
1080 -@@ -127,7 +127,6 @@ struct gianfar_ptp_registers {
1081 -
1082 - #define DRIVER "gianfar_ptp"
1083 - #define DEFAULT_CKSEL 1
1084 --#define N_ALARM 1 /* first alarm is used internally to reset fipers */
1085 - #define N_EXT_TS 2
1086 - #define REG_SIZE sizeof(struct gianfar_ptp_registers)
1087 -
1088 -@@ -410,7 +409,7 @@ static struct ptp_clock_info ptp_gianfar_caps = {
1089 - .owner = THIS_MODULE,
1090 - .name = "gianfar clock",
1091 - .max_adj = 512000,
1092 -- .n_alarm = N_ALARM,
1093 -+ .n_alarm = 0,
1094 - .n_ext_ts = N_EXT_TS,
1095 - .n_per_out = 0,
1096 - .pps = 1,
1097 -diff --git a/drivers/net/ethernet/intel/e1000e/ptp.c b/drivers/net/ethernet/intel/e1000e/ptp.c
1098 -index b477fa5..065f8c8 100644
1099 ---- a/drivers/net/ethernet/intel/e1000e/ptp.c
1100 -+++ b/drivers/net/ethernet/intel/e1000e/ptp.c
1101 -@@ -145,8 +145,7 @@ static int e1000e_phc_settime(struct ptp_clock_info *ptp,
1102 - unsigned long flags;
1103 - u64 ns;
1104 -
1105 -- ns = ts->tv_sec * NSEC_PER_SEC;
1106 -- ns += ts->tv_nsec;
1107 -+ ns = timespec_to_ns(ts);
1108 -
1109 - /* reset the timecounter */
1110 - spin_lock_irqsave(&adapter->systim_lock, flags);
1111 -diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
1112 -index 79f4a26..a892efd 100644
1113 ---- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
1114 -+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
1115 -@@ -2405,6 +2405,16 @@ static irqreturn_t ixgbe_msix_other(int irq, void *data)
1116 - * with the write to EICR.
1117 - */
1118 - eicr = IXGBE_READ_REG(hw, IXGBE_EICS);
1119 -+
1120 -+ /* The lower 16bits of the EICR register are for the queue interrupts
1121 -+ * which should be masked here in order to not accidently clear them if
1122 -+ * the bits are high when ixgbe_msix_other is called. There is a race
1123 -+ * condition otherwise which results in possible performance loss
1124 -+ * especially if the ixgbe_msix_other interrupt is triggering
1125 -+ * consistently (as it would when PPS is turned on for the X540 device)
1126 -+ */
1127 -+ eicr &= 0xFFFF0000;
1128 -+
1129 - IXGBE_WRITE_REG(hw, IXGBE_EICR, eicr);
1130 -
1131 - if (eicr & IXGBE_EICR_LSC)
1132 -diff --git a/drivers/net/wireless/iwlwifi/dvm/debugfs.c b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
1133 -index 20806ca..81d4071 100644
1134 ---- a/drivers/net/wireless/iwlwifi/dvm/debugfs.c
1135 -+++ b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
1136 -@@ -2237,15 +2237,15 @@ static ssize_t iwl_dbgfs_log_event_read(struct file *file,
1137 - size_t count, loff_t *ppos)
1138 - {
1139 - struct iwl_priv *priv = file->private_data;
1140 -- char *buf;
1141 -- int pos = 0;
1142 -- ssize_t ret = -ENOMEM;
1143 -+ char *buf = NULL;
1144 -+ ssize_t ret;
1145 -
1146 -- ret = pos = iwl_dump_nic_event_log(priv, true, &buf, true);
1147 -- if (buf) {
1148 -- ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
1149 -- kfree(buf);
1150 -- }
1151 -+ ret = iwl_dump_nic_event_log(priv, true, &buf, true);
1152 -+ if (ret < 0)
1153 -+ goto err;
1154 -+ ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret);
1155 -+err:
1156 -+ kfree(buf);
1157 - return ret;
1158 - }
1159 -
1160 -diff --git a/drivers/net/wireless/iwlwifi/dvm/sta.c b/drivers/net/wireless/iwlwifi/dvm/sta.c
1161 -index b775769..db183b4 100644
1162 ---- a/drivers/net/wireless/iwlwifi/dvm/sta.c
1163 -+++ b/drivers/net/wireless/iwlwifi/dvm/sta.c
1164 -@@ -695,6 +695,7 @@ void iwl_clear_ucode_stations(struct iwl_priv *priv,
1165 - void iwl_restore_stations(struct iwl_priv *priv, struct iwl_rxon_context *ctx)
1166 - {
1167 - struct iwl_addsta_cmd sta_cmd;
1168 -+ static const struct iwl_link_quality_cmd zero_lq = {};
1169 - struct iwl_link_quality_cmd lq;
1170 - int i;
1171 - bool found = false;
1172 -@@ -733,7 +734,9 @@ void iwl_restore_stations(struct iwl_priv *priv, struct iwl_rxon_context *ctx)
1173 - else
1174 - memcpy(&lq, priv->stations[i].lq,
1175 - sizeof(struct iwl_link_quality_cmd));
1176 -- send_lq = true;
1177 -+
1178 -+ if (!memcmp(&lq, &zero_lq, sizeof(lq)))
1179 -+ send_lq = true;
1180 - }
1181 - spin_unlock_bh(&priv->sta_lock);
1182 - ret = iwl_send_add_sta(priv, &sta_cmd, CMD_SYNC);
1183 -diff --git a/drivers/net/wireless/mwifiex/pcie.c b/drivers/net/wireless/mwifiex/pcie.c
1184 -index feb2046..f024fb0 100644
1185 ---- a/drivers/net/wireless/mwifiex/pcie.c
1186 -+++ b/drivers/net/wireless/mwifiex/pcie.c
1187 -@@ -2281,9 +2281,9 @@ static void mwifiex_pcie_cleanup(struct mwifiex_adapter *adapter)
1188 - if (pdev) {
1189 - pci_iounmap(pdev, card->pci_mmap);
1190 - pci_iounmap(pdev, card->pci_mmap1);
1191 --
1192 -- pci_release_regions(pdev);
1193 - pci_disable_device(pdev);
1194 -+ pci_release_region(pdev, 2);
1195 -+ pci_release_region(pdev, 0);
1196 - pci_set_drvdata(pdev, NULL);
1197 - }
1198 - }
1199 -diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
1200 -index a658b4b..92849e5 100644
1201 ---- a/drivers/net/wireless/rt2x00/rt2800lib.c
1202 -+++ b/drivers/net/wireless/rt2x00/rt2800lib.c
1203 -@@ -4436,6 +4436,8 @@ static int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev)
1204 -
1205 - if (!rt2x00_rt(rt2x00dev, RT5390) &&
1206 - !rt2x00_rt(rt2x00dev, RT5392)) {
1207 -+ u8 min_gain = rt2x00_rt(rt2x00dev, RT3070) ? 1 : 2;
1208 -+
1209 - rt2800_rfcsr_read(rt2x00dev, 17, &rfcsr);
1210 - rt2x00_set_field8(&rfcsr, RFCSR17_TX_LO1_EN, 0);
1211 - if (rt2x00_rt(rt2x00dev, RT3070) ||
1212 -@@ -4446,8 +4448,10 @@ static int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev)
1213 - &rt2x00dev->cap_flags))
1214 - rt2x00_set_field8(&rfcsr, RFCSR17_R, 1);
1215 - }
1216 -- rt2x00_set_field8(&rfcsr, RFCSR17_TXMIXER_GAIN,
1217 -- drv_data->txmixer_gain_24g);
1218 -+ if (drv_data->txmixer_gain_24g >= min_gain) {
1219 -+ rt2x00_set_field8(&rfcsr, RFCSR17_TXMIXER_GAIN,
1220 -+ drv_data->txmixer_gain_24g);
1221 -+ }
1222 - rt2800_rfcsr_write(rt2x00dev, 17, rfcsr);
1223 - }
1224 -
1225 -diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
1226 -index b099e00..fc9bd81 100644
1227 ---- a/drivers/pci/pci.c
1228 -+++ b/drivers/pci/pci.c
1229 -@@ -646,15 +646,11 @@ static int pci_platform_power_transition(struct pci_dev *dev, pci_power_t state)
1230 - error = platform_pci_set_power_state(dev, state);
1231 - if (!error)
1232 - pci_update_current_state(dev, state);
1233 -- /* Fall back to PCI_D0 if native PM is not supported */
1234 -- if (!dev->pm_cap)
1235 -- dev->current_state = PCI_D0;
1236 -- } else {
1237 -+ } else
1238 - error = -ENODEV;
1239 -- /* Fall back to PCI_D0 if native PM is not supported */
1240 -- if (!dev->pm_cap)
1241 -- dev->current_state = PCI_D0;
1242 -- }
1243 -+
1244 -+ if (error && !dev->pm_cap) /* Fall back to PCI_D0 */
1245 -+ dev->current_state = PCI_D0;
1246 -
1247 - return error;
1248 - }
1249 -diff --git a/drivers/rtc/rtc-at91rm9200.c b/drivers/rtc/rtc-at91rm9200.c
1250 -index 434ebc3..eebd8ac 100644
1251 ---- a/drivers/rtc/rtc-at91rm9200.c
1252 -+++ b/drivers/rtc/rtc-at91rm9200.c
1253 -@@ -297,7 +297,7 @@ static int __init at91_rtc_probe(struct platform_device *pdev)
1254 - "at91_rtc", pdev);
1255 - if (ret) {
1256 - dev_err(&pdev->dev, "IRQ %d already in use.\n", irq);
1257 -- return ret;
1258 -+ goto err_unmap;
1259 - }
1260 -
1261 - /* cpu init code should really have flagged this device as
1262 -@@ -309,13 +309,20 @@ static int __init at91_rtc_probe(struct platform_device *pdev)
1263 - rtc = rtc_device_register(pdev->name, &pdev->dev,
1264 - &at91_rtc_ops, THIS_MODULE);
1265 - if (IS_ERR(rtc)) {
1266 -- free_irq(irq, pdev);
1267 -- return PTR_ERR(rtc);
1268 -+ ret = PTR_ERR(rtc);
1269 -+ goto err_free_irq;
1270 - }
1271 - platform_set_drvdata(pdev, rtc);
1272 -
1273 - dev_info(&pdev->dev, "AT91 Real Time Clock driver.\n");
1274 - return 0;
1275 -+
1276 -+err_free_irq:
1277 -+ free_irq(irq, pdev);
1278 -+err_unmap:
1279 -+ iounmap(at91_rtc_regs);
1280 -+
1281 -+ return ret;
1282 - }
1283 -
1284 - /*
1285 -@@ -332,6 +339,7 @@ static int __exit at91_rtc_remove(struct platform_device *pdev)
1286 - free_irq(irq, pdev);
1287 -
1288 - rtc_device_unregister(rtc);
1289 -+ iounmap(at91_rtc_regs);
1290 - platform_set_drvdata(pdev, NULL);
1291 -
1292 - return 0;
1293 -diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
1294 -index af97c94..cc5bea9 100644
1295 ---- a/drivers/rtc/rtc-cmos.c
1296 -+++ b/drivers/rtc/rtc-cmos.c
1297 -@@ -804,9 +804,8 @@ static int cmos_suspend(struct device *dev)
1298 - mask = RTC_IRQMASK;
1299 - tmp &= ~mask;
1300 - CMOS_WRITE(tmp, RTC_CONTROL);
1301 -+ hpet_mask_rtc_irq_bit(mask);
1302 -
1303 -- /* shut down hpet emulation - we don't need it for alarm */
1304 -- hpet_mask_rtc_irq_bit(RTC_PIE|RTC_AIE|RTC_UIE);
1305 - cmos_checkintr(cmos, tmp);
1306 - }
1307 - spin_unlock_irq(&rtc_lock);
1308 -@@ -870,6 +869,7 @@ static int cmos_resume(struct device *dev)
1309 - rtc_update_irq(cmos->rtc, 1, mask);
1310 - tmp &= ~RTC_AIE;
1311 - hpet_mask_rtc_irq_bit(RTC_AIE);
1312 -+ hpet_rtc_timer_init();
1313 - } while (mask & RTC_AIE);
1314 - spin_unlock_irq(&rtc_lock);
1315 - }
1316 -diff --git a/drivers/s390/char/sclp_cmd.c b/drivers/s390/char/sclp_cmd.c
1317 -index cd79838..178836e 100644
1318 ---- a/drivers/s390/char/sclp_cmd.c
1319 -+++ b/drivers/s390/char/sclp_cmd.c
1320 -@@ -561,6 +561,8 @@ static void __init sclp_add_standby_memory(void)
1321 - add_memory_merged(0);
1322 - }
1323 -
1324 -+#define MEM_SCT_SIZE (1UL << SECTION_SIZE_BITS)
1325 -+
1326 - static void __init insert_increment(u16 rn, int standby, int assigned)
1327 - {
1328 - struct memory_increment *incr, *new_incr;
1329 -@@ -573,7 +575,7 @@ static void __init insert_increment(u16 rn, int standby, int assigned)
1330 - new_incr->rn = rn;
1331 - new_incr->standby = standby;
1332 - if (!standby)
1333 -- new_incr->usecount = 1;
1334 -+ new_incr->usecount = rzm > MEM_SCT_SIZE ? rzm/MEM_SCT_SIZE : 1;
1335 - last_rn = 0;
1336 - prev = &sclp_mem_list;
1337 - list_for_each_entry(incr, &sclp_mem_list, list) {
1338 -diff --git a/drivers/staging/zsmalloc/Kconfig b/drivers/staging/zsmalloc/Kconfig
1339 -index 9084565..7fab032 100644
1340 ---- a/drivers/staging/zsmalloc/Kconfig
1341 -+++ b/drivers/staging/zsmalloc/Kconfig
1342 -@@ -1,5 +1,5 @@
1343 - config ZSMALLOC
1344 -- tristate "Memory allocator for compressed pages"
1345 -+ bool "Memory allocator for compressed pages"
1346 - default n
1347 - help
1348 - zsmalloc is a slab-based memory allocator designed to store
1349 -diff --git a/drivers/staging/zsmalloc/zsmalloc-main.c b/drivers/staging/zsmalloc/zsmalloc-main.c
1350 -index e78d262..324e123 100644
1351 ---- a/drivers/staging/zsmalloc/zsmalloc-main.c
1352 -+++ b/drivers/staging/zsmalloc/zsmalloc-main.c
1353 -@@ -656,11 +656,8 @@ static inline void __zs_unmap_object(struct mapping_area *area,
1354 - struct page *pages[2], int off, int size)
1355 - {
1356 - unsigned long addr = (unsigned long)area->vm_addr;
1357 -- unsigned long end = addr + (PAGE_SIZE * 2);
1358 -
1359 -- flush_cache_vunmap(addr, end);
1360 -- unmap_kernel_range_noflush(addr, PAGE_SIZE * 2);
1361 -- flush_tlb_kernel_range(addr, end);
1362 -+ unmap_kernel_range(addr, PAGE_SIZE * 2);
1363 - }
1364 -
1365 - #else /* USE_PGTABLE_MAPPING */
1366 -diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
1367 -index c24b4db..125e0fd 100644
1368 ---- a/drivers/tty/pty.c
1369 -+++ b/drivers/tty/pty.c
1370 -@@ -682,6 +682,9 @@ static int ptmx_open(struct inode *inode, struct file *filp)
1371 -
1372 - nonseekable_open(inode, filp);
1373 -
1374 -+ /* We refuse fsnotify events on ptmx, since it's a shared resource */
1375 -+ filp->f_mode |= FMODE_NONOTIFY;
1376 -+
1377 - retval = tty_alloc_file(filp);
1378 - if (retval)
1379 - return retval;
1380 -diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
1381 -index a400002..8fbb6d2 100644
1382 ---- a/drivers/tty/serial/serial_core.c
1383 -+++ b/drivers/tty/serial/serial_core.c
1384 -@@ -1941,6 +1941,8 @@ int uart_suspend_port(struct uart_driver *drv, struct uart_port *uport)
1385 - mutex_unlock(&port->mutex);
1386 - return 0;
1387 - }
1388 -+ put_device(tty_dev);
1389 -+
1390 - if (console_suspend_enabled || !uart_console(uport))
1391 - uport->suspended = 1;
1392 -
1393 -@@ -2006,9 +2008,11 @@ int uart_resume_port(struct uart_driver *drv, struct uart_port *uport)
1394 - disable_irq_wake(uport->irq);
1395 - uport->irq_wake = 0;
1396 - }
1397 -+ put_device(tty_dev);
1398 - mutex_unlock(&port->mutex);
1399 - return 0;
1400 - }
1401 -+ put_device(tty_dev);
1402 - uport->suspended = 0;
1403 -
1404 - /*
1405 -diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
1406 -index b045268..a9cd0b9 100644
1407 ---- a/drivers/tty/tty_io.c
1408 -+++ b/drivers/tty/tty_io.c
1409 -@@ -941,10 +941,10 @@ void start_tty(struct tty_struct *tty)
1410 -
1411 - EXPORT_SYMBOL(start_tty);
1412 -
1413 -+/* We limit tty time update visibility to every 8 seconds or so. */
1414 - static void tty_update_time(struct timespec *time)
1415 - {
1416 -- unsigned long sec = get_seconds();
1417 -- sec -= sec % 60;
1418 -+ unsigned long sec = get_seconds() & ~7;
1419 - if ((long)(sec - time->tv_sec) > 0)
1420 - time->tv_sec = sec;
1421 - }
1422 -diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
1423 -index f64fbea..d86333b 100644
1424 ---- a/drivers/usb/chipidea/udc.c
1425 -+++ b/drivers/usb/chipidea/udc.c
1426 -@@ -461,6 +461,8 @@ static int _hardware_enqueue(struct ci13xxx_ep *mEp, struct ci13xxx_req *mReq)
1427 - mReq->ptr->page[i] =
1428 - (mReq->req.dma + i * CI13XXX_PAGE_SIZE) & ~TD_RESERVED_MASK;
1429 -
1430 -+ wmb();
1431 -+
1432 - if (!list_empty(&mEp->qh.queue)) {
1433 - struct ci13xxx_req *mReqPrev;
1434 - int n = hw_ep_bit(mEp->num, mEp->dir);
1435 -@@ -561,6 +563,12 @@ __acquires(mEp->lock)
1436 - struct ci13xxx_req *mReq = \
1437 - list_entry(mEp->qh.queue.next,
1438 - struct ci13xxx_req, queue);
1439 -+
1440 -+ if (mReq->zptr) {
1441 -+ dma_pool_free(mEp->td_pool, mReq->zptr, mReq->zdma);
1442 -+ mReq->zptr = NULL;
1443 -+ }
1444 -+
1445 - list_del_init(&mReq->queue);
1446 - mReq->req.status = -ESHUTDOWN;
1447 -
1448 -diff --git a/drivers/usb/chipidea/udc.h b/drivers/usb/chipidea/udc.h
1449 -index 4ff2384d..d12e8b5 100644
1450 ---- a/drivers/usb/chipidea/udc.h
1451 -+++ b/drivers/usb/chipidea/udc.h
1452 -@@ -40,7 +40,7 @@ struct ci13xxx_td {
1453 - #define TD_CURR_OFFSET (0x0FFFUL << 0)
1454 - #define TD_FRAME_NUM (0x07FFUL << 0)
1455 - #define TD_RESERVED_MASK (0x0FFFUL << 0)
1456 --} __attribute__ ((packed));
1457 -+} __attribute__ ((packed, aligned(4)));
1458 -
1459 - /* DMA layout of queue heads */
1460 - struct ci13xxx_qh {
1461 -@@ -57,7 +57,7 @@ struct ci13xxx_qh {
1462 - /* 9 */
1463 - u32 RESERVED;
1464 - struct usb_ctrlrequest setup;
1465 --} __attribute__ ((packed));
1466 -+} __attribute__ ((packed, aligned(4)));
1467 -
1468 - /**
1469 - * struct ci13xxx_req - usb request representation
1470 -diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
1471 -index 8823e98..caefc80 100644
1472 ---- a/drivers/usb/core/devio.c
1473 -+++ b/drivers/usb/core/devio.c
1474 -@@ -739,6 +739,8 @@ static int check_ctrlrecip(struct dev_state *ps, unsigned int requesttype,
1475 - index &= 0xff;
1476 - switch (requesttype & USB_RECIP_MASK) {
1477 - case USB_RECIP_ENDPOINT:
1478 -+ if ((index & ~USB_DIR_IN) == 0)
1479 -+ return 0;
1480 - ret = findintfep(ps->dev, index);
1481 - if (ret >= 0)
1482 - ret = checkintf(ps, ret);
1483 -diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
1484 -index 416a6dc..83b5a172 100644
1485 ---- a/drivers/usb/host/ehci-hcd.c
1486 -+++ b/drivers/usb/host/ehci-hcd.c
1487 -@@ -670,9 +670,6 @@ int ehci_setup(struct usb_hcd *hcd)
1488 - if (retval)
1489 - return retval;
1490 -
1491 -- if (ehci_is_TDI(ehci))
1492 -- tdi_reset(ehci);
1493 --
1494 - ehci_reset(ehci);
1495 -
1496 - return 0;
1497 -diff --git a/drivers/usb/misc/appledisplay.c b/drivers/usb/misc/appledisplay.c
1498 -index 0fc6e5f..ba6a5d6 100644
1499 ---- a/drivers/usb/misc/appledisplay.c
1500 -+++ b/drivers/usb/misc/appledisplay.c
1501 -@@ -63,6 +63,7 @@ static const struct usb_device_id appledisplay_table[] = {
1502 - { APPLEDISPLAY_DEVICE(0x9219) },
1503 - { APPLEDISPLAY_DEVICE(0x921c) },
1504 - { APPLEDISPLAY_DEVICE(0x921d) },
1505 -+ { APPLEDISPLAY_DEVICE(0x9236) },
1506 -
1507 - /* Terminating entry */
1508 - { }
1509 -diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
1510 -index 9886180..be2dcb0 100644
1511 ---- a/drivers/usb/serial/ftdi_sio.c
1512 -+++ b/drivers/usb/serial/ftdi_sio.c
1513 -@@ -189,6 +189,7 @@ static struct usb_device_id id_table_combined [] = {
1514 - { USB_DEVICE(FTDI_VID, FTDI_OPENDCC_THROTTLE_PID) },
1515 - { USB_DEVICE(FTDI_VID, FTDI_OPENDCC_GATEWAY_PID) },
1516 - { USB_DEVICE(FTDI_VID, FTDI_OPENDCC_GBM_PID) },
1517 -+ { USB_DEVICE(FTDI_VID, FTDI_OPENDCC_GBM_BOOST_PID) },
1518 - { USB_DEVICE(NEWPORT_VID, NEWPORT_AGILIS_PID) },
1519 - { USB_DEVICE(INTERBIOMETRICS_VID, INTERBIOMETRICS_IOBOARD_PID) },
1520 - { USB_DEVICE(INTERBIOMETRICS_VID, INTERBIOMETRICS_MINI_IOBOARD_PID) },
1521 -@@ -870,7 +871,9 @@ static struct usb_device_id id_table_combined [] = {
1522 - { USB_DEVICE(FTDI_VID, FTDI_DOTEC_PID) },
1523 - { USB_DEVICE(QIHARDWARE_VID, MILKYMISTONE_JTAGSERIAL_PID),
1524 - .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
1525 -- { USB_DEVICE(ST_VID, ST_STMCLT1030_PID),
1526 -+ { USB_DEVICE(ST_VID, ST_STMCLT_2232_PID),
1527 -+ .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
1528 -+ { USB_DEVICE(ST_VID, ST_STMCLT_4232_PID),
1529 - .driver_info = (kernel_ulong_t)&ftdi_stmclite_quirk },
1530 - { USB_DEVICE(FTDI_VID, FTDI_RF_R106) },
1531 - { USB_DEVICE(FTDI_VID, FTDI_DISTORTEC_JTAG_LOCK_PICK_PID),
1532 -@@ -1792,20 +1795,24 @@ static int ftdi_8u2232c_probe(struct usb_serial *serial)
1533 - }
1534 -
1535 - /*
1536 -- * First and second port on STMCLiteadaptors is reserved for JTAG interface
1537 -- * and the forth port for pio
1538 -+ * First two ports on JTAG adaptors using an FT4232 such as STMicroelectronics's
1539 -+ * ST Micro Connect Lite are reserved for JTAG or other non-UART interfaces and
1540 -+ * can be accessed from userspace.
1541 -+ * The next two ports are enabled as UARTs by default, where port 2 is
1542 -+ * a conventional RS-232 UART.
1543 - */
1544 - static int ftdi_stmclite_probe(struct usb_serial *serial)
1545 - {
1546 - struct usb_device *udev = serial->dev;
1547 - struct usb_interface *interface = serial->interface;
1548 -
1549 -- if (interface == udev->actconfig->interface[2])
1550 -- return 0;
1551 --
1552 -- dev_info(&udev->dev, "Ignoring serial port reserved for JTAG\n");
1553 -+ if (interface == udev->actconfig->interface[0] ||
1554 -+ interface == udev->actconfig->interface[1]) {
1555 -+ dev_info(&udev->dev, "Ignoring serial port reserved for JTAG\n");
1556 -+ return -ENODEV;
1557 -+ }
1558 -
1559 -- return -ENODEV;
1560 -+ return 0;
1561 - }
1562 -
1563 - /*
1564 -diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h
1565 -index e79861e..9852827 100644
1566 ---- a/drivers/usb/serial/ftdi_sio_ids.h
1567 -+++ b/drivers/usb/serial/ftdi_sio_ids.h
1568 -@@ -74,6 +74,7 @@
1569 - #define FTDI_OPENDCC_THROTTLE_PID 0xBFDA
1570 - #define FTDI_OPENDCC_GATEWAY_PID 0xBFDB
1571 - #define FTDI_OPENDCC_GBM_PID 0xBFDC
1572 -+#define FTDI_OPENDCC_GBM_BOOST_PID 0xBFDD
1573 -
1574 - /* NZR SEM 16+ USB (http://www.nzr.de) */
1575 - #define FTDI_NZR_SEM_USB_PID 0xC1E0 /* NZR SEM-LOG16+ */
1576 -@@ -1150,7 +1151,8 @@
1577 - * STMicroelectonics
1578 - */
1579 - #define ST_VID 0x0483
1580 --#define ST_STMCLT1030_PID 0x3747 /* ST Micro Connect Lite STMCLT1030 */
1581 -+#define ST_STMCLT_2232_PID 0x3746
1582 -+#define ST_STMCLT_4232_PID 0x3747
1583 -
1584 - /*
1585 - * Papouch products (http://www.papouch.com/)
1586 -diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c
1587 -index 7777172..38f2489 100644
1588 ---- a/drivers/usb/serial/io_ti.c
1589 -+++ b/drivers/usb/serial/io_ti.c
1590 -@@ -2392,7 +2392,7 @@ static int get_serial_info(struct edgeport_port *edge_port,
1591 -
1592 - cwait = edge_port->port->port.closing_wait;
1593 - if (cwait != ASYNC_CLOSING_WAIT_NONE)
1594 -- cwait = jiffies_to_msecs(closing_wait) / 10;
1595 -+ cwait = jiffies_to_msecs(cwait) / 10;
1596 -
1597 - memset(&tmp, 0, sizeof(tmp));
1598 -
1599 -diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
1600 -index 558adfc..bff059a 100644
1601 ---- a/drivers/usb/serial/option.c
1602 -+++ b/drivers/usb/serial/option.c
1603 -@@ -347,6 +347,7 @@ static void option_instat_callback(struct urb *urb);
1604 - /* Olivetti products */
1605 - #define OLIVETTI_VENDOR_ID 0x0b3c
1606 - #define OLIVETTI_PRODUCT_OLICARD100 0xc000
1607 -+#define OLIVETTI_PRODUCT_OLICARD145 0xc003
1608 -
1609 - /* Celot products */
1610 - #define CELOT_VENDOR_ID 0x211f
1611 -@@ -1273,6 +1274,7 @@ static const struct usb_device_id option_ids[] = {
1612 - { USB_DEVICE(SIEMENS_VENDOR_ID, CINTERION_PRODUCT_HC28_MDMNET) },
1613 -
1614 - { USB_DEVICE(OLIVETTI_VENDOR_ID, OLIVETTI_PRODUCT_OLICARD100) },
1615 -+ { USB_DEVICE(OLIVETTI_VENDOR_ID, OLIVETTI_PRODUCT_OLICARD145) },
1616 - { USB_DEVICE(CELOT_VENDOR_ID, CELOT_PRODUCT_CT680M) }, /* CT-650 CDMA 450 1xEVDO modem */
1617 - { USB_DEVICE(ONDA_VENDOR_ID, ONDA_MT825UP) }, /* ONDA MT825UP modem */
1618 - { USB_DEVICE_AND_INTERFACE_INFO(SAMSUNG_VENDOR_ID, SAMSUNG_PRODUCT_GT_B3730, USB_CLASS_CDC_DATA, 0x00, 0x00) }, /* Samsung GT-B3730 LTE USB modem.*/
1619 -@@ -1350,6 +1352,12 @@ static const struct usb_device_id option_ids[] = {
1620 - { USB_DEVICE(TPLINK_VENDOR_ID, TPLINK_PRODUCT_MA180),
1621 - .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
1622 - { USB_DEVICE(CHANGHONG_VENDOR_ID, CHANGHONG_PRODUCT_CH690) },
1623 -+ { USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x7d01, 0xff, 0x02, 0x01) }, /* D-Link DWM-156 (variant) */
1624 -+ { USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x7d01, 0xff, 0x00, 0x00) }, /* D-Link DWM-156 (variant) */
1625 -+ { USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x7d02, 0xff, 0x02, 0x01) },
1626 -+ { USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x7d02, 0xff, 0x00, 0x00) },
1627 -+ { USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x7d03, 0xff, 0x02, 0x01) },
1628 -+ { USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x7d03, 0xff, 0x00, 0x00) },
1629 - { } /* Terminating entry */
1630 - };
1631 - MODULE_DEVICE_TABLE(usb, option_ids);
1632 -diff --git a/drivers/usb/storage/cypress_atacb.c b/drivers/usb/storage/cypress_atacb.c
1633 -index 070b5c0..d944088 100644
1634 ---- a/drivers/usb/storage/cypress_atacb.c
1635 -+++ b/drivers/usb/storage/cypress_atacb.c
1636 -@@ -248,14 +248,26 @@ static int cypress_probe(struct usb_interface *intf,
1637 - {
1638 - struct us_data *us;
1639 - int result;
1640 -+ struct usb_device *device;
1641 -
1642 - result = usb_stor_probe1(&us, intf, id,
1643 - (id - cypress_usb_ids) + cypress_unusual_dev_list);
1644 - if (result)
1645 - return result;
1646 -
1647 -- us->protocol_name = "Transparent SCSI with Cypress ATACB";
1648 -- us->proto_handler = cypress_atacb_passthrough;
1649 -+ /* Among CY7C68300 chips, the A revision does not support Cypress ATACB
1650 -+ * Filter out this revision from EEPROM default descriptor values
1651 -+ */
1652 -+ device = interface_to_usbdev(intf);
1653 -+ if (device->descriptor.iManufacturer != 0x38 ||
1654 -+ device->descriptor.iProduct != 0x4e ||
1655 -+ device->descriptor.iSerialNumber != 0x64) {
1656 -+ us->protocol_name = "Transparent SCSI with Cypress ATACB";
1657 -+ us->proto_handler = cypress_atacb_passthrough;
1658 -+ } else {
1659 -+ us->protocol_name = "Transparent SCSI";
1660 -+ us->proto_handler = usb_stor_transparent_scsi_command;
1661 -+ }
1662 -
1663 - result = usb_stor_probe2(us);
1664 - return result;
1665 -diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
1666 -index 3cd6759..a92783e 100644
1667 ---- a/drivers/video/console/fbcon.c
1668 -+++ b/drivers/video/console/fbcon.c
1669 -@@ -1228,6 +1228,8 @@ static void fbcon_deinit(struct vc_data *vc)
1670 - finished:
1671 -
1672 - fbcon_free_font(p, free_font);
1673 -+ if (free_font)
1674 -+ vc->vc_font.data = NULL;
1675 -
1676 - if (!con_is_bound(&fb_con))
1677 - fbcon_exit();
1678 -diff --git a/fs/dcache.c b/fs/dcache.c
1679 -index e8bc342..e689268 100644
1680 ---- a/fs/dcache.c
1681 -+++ b/fs/dcache.c
1682 -@@ -1230,8 +1230,10 @@ void shrink_dcache_parent(struct dentry * parent)
1683 - LIST_HEAD(dispose);
1684 - int found;
1685 -
1686 -- while ((found = select_parent(parent, &dispose)) != 0)
1687 -+ while ((found = select_parent(parent, &dispose)) != 0) {
1688 - shrink_dentry_list(&dispose);
1689 -+ cond_resched();
1690 -+ }
1691 - }
1692 - EXPORT_SYMBOL(shrink_dcache_parent);
1693 -
1694 -diff --git a/fs/exec.c b/fs/exec.c
1695 -index a96a488..6d56ff2 100644
1696 ---- a/fs/exec.c
1697 -+++ b/fs/exec.c
1698 -@@ -613,7 +613,7 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
1699 - * when the old and new regions overlap clear from new_end.
1700 - */
1701 - free_pgd_range(&tlb, new_end, old_end, new_end,
1702 -- vma->vm_next ? vma->vm_next->vm_start : 0);
1703 -+ vma->vm_next ? vma->vm_next->vm_start : USER_PGTABLES_CEILING);
1704 - } else {
1705 - /*
1706 - * otherwise, clean from old_start; this is done to not touch
1707 -@@ -622,7 +622,7 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
1708 - * for the others its just a little faster.
1709 - */
1710 - free_pgd_range(&tlb, old_start, old_end, new_end,
1711 -- vma->vm_next ? vma->vm_next->vm_start : 0);
1712 -+ vma->vm_next ? vma->vm_next->vm_start : USER_PGTABLES_CEILING);
1713 - }
1714 - tlb_finish_mmu(&tlb, new_end, old_end);
1715 -
1716 -@@ -898,11 +898,13 @@ static int de_thread(struct task_struct *tsk)
1717 -
1718 - sig->notify_count = -1; /* for exit_notify() */
1719 - for (;;) {
1720 -+ threadgroup_change_begin(tsk);
1721 - write_lock_irq(&tasklist_lock);
1722 - if (likely(leader->exit_state))
1723 - break;
1724 - __set_current_state(TASK_KILLABLE);
1725 - write_unlock_irq(&tasklist_lock);
1726 -+ threadgroup_change_end(tsk);
1727 - schedule();
1728 - if (unlikely(__fatal_signal_pending(tsk)))
1729 - goto killed;
1730 -@@ -960,6 +962,7 @@ static int de_thread(struct task_struct *tsk)
1731 - if (unlikely(leader->ptrace))
1732 - __wake_up_parent(leader, leader->parent);
1733 - write_unlock_irq(&tasklist_lock);
1734 -+ threadgroup_change_end(tsk);
1735 -
1736 - release_task(leader);
1737 - }
1738 -diff --git a/fs/ext4/Kconfig b/fs/ext4/Kconfig
1739 -index 9873587..efea5d5 100644
1740 ---- a/fs/ext4/Kconfig
1741 -+++ b/fs/ext4/Kconfig
1742 -@@ -71,4 +71,5 @@ config EXT4_DEBUG
1743 - Enables run-time debugging support for the ext4 filesystem.
1744 -
1745 - If you select Y here, then you will be able to turn on debugging
1746 -- with a command such as "echo 1 > /sys/kernel/debug/ext4/mballoc-debug"
1747 -+ with a command such as:
1748 -+ echo 1 > /sys/module/ext4/parameters/mballoc_debug
1749 -diff --git a/fs/ext4/ext4_jbd2.h b/fs/ext4/ext4_jbd2.h
1750 -index 4c216b1..aeed0ba 100644
1751 ---- a/fs/ext4/ext4_jbd2.h
1752 -+++ b/fs/ext4/ext4_jbd2.h
1753 -@@ -194,16 +194,20 @@ static inline void ext4_journal_callback_add(handle_t *handle,
1754 - * ext4_journal_callback_del: delete a registered callback
1755 - * @handle: active journal transaction handle on which callback was registered
1756 - * @jce: registered journal callback entry to unregister
1757 -+ * Return true if object was sucessfully removed
1758 - */
1759 --static inline void ext4_journal_callback_del(handle_t *handle,
1760 -+static inline bool ext4_journal_callback_try_del(handle_t *handle,
1761 - struct ext4_journal_cb_entry *jce)
1762 - {
1763 -+ bool deleted;
1764 - struct ext4_sb_info *sbi =
1765 - EXT4_SB(handle->h_transaction->t_journal->j_private);
1766 -
1767 - spin_lock(&sbi->s_md_lock);
1768 -+ deleted = !list_empty(&jce->jce_list);
1769 - list_del_init(&jce->jce_list);
1770 - spin_unlock(&sbi->s_md_lock);
1771 -+ return deleted;
1772 - }
1773 -
1774 - int
1775 -diff --git a/fs/ext4/fsync.c b/fs/ext4/fsync.c
1776 -index 3278e64..e0ba8a4 100644
1777 ---- a/fs/ext4/fsync.c
1778 -+++ b/fs/ext4/fsync.c
1779 -@@ -166,8 +166,7 @@ int ext4_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
1780 - if (journal->j_flags & JBD2_BARRIER &&
1781 - !jbd2_trans_will_send_data_barrier(journal, commit_tid))
1782 - needs_barrier = true;
1783 -- jbd2_log_start_commit(journal, commit_tid);
1784 -- ret = jbd2_log_wait_commit(journal, commit_tid);
1785 -+ ret = jbd2_complete_transaction(journal, commit_tid);
1786 - if (needs_barrier) {
1787 - err = blkdev_issue_flush(inode->i_sb->s_bdev, GFP_KERNEL, NULL);
1788 - if (!ret)
1789 -diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
1790 -index b3a5213..d69e954 100644
1791 ---- a/fs/ext4/inode.c
1792 -+++ b/fs/ext4/inode.c
1793 -@@ -55,21 +55,21 @@ static __u32 ext4_inode_csum(struct inode *inode, struct ext4_inode *raw,
1794 - __u16 csum_hi = 0;
1795 - __u32 csum;
1796 -
1797 -- csum_lo = raw->i_checksum_lo;
1798 -+ csum_lo = le16_to_cpu(raw->i_checksum_lo);
1799 - raw->i_checksum_lo = 0;
1800 - if (EXT4_INODE_SIZE(inode->i_sb) > EXT4_GOOD_OLD_INODE_SIZE &&
1801 - EXT4_FITS_IN_INODE(raw, ei, i_checksum_hi)) {
1802 -- csum_hi = raw->i_checksum_hi;
1803 -+ csum_hi = le16_to_cpu(raw->i_checksum_hi);
1804 - raw->i_checksum_hi = 0;
1805 - }
1806 -
1807 - csum = ext4_chksum(sbi, ei->i_csum_seed, (__u8 *)raw,
1808 - EXT4_INODE_SIZE(inode->i_sb));
1809 -
1810 -- raw->i_checksum_lo = csum_lo;
1811 -+ raw->i_checksum_lo = cpu_to_le16(csum_lo);
1812 - if (EXT4_INODE_SIZE(inode->i_sb) > EXT4_GOOD_OLD_INODE_SIZE &&
1813 - EXT4_FITS_IN_INODE(raw, ei, i_checksum_hi))
1814 -- raw->i_checksum_hi = csum_hi;
1815 -+ raw->i_checksum_hi = cpu_to_le16(csum_hi);
1816 -
1817 - return csum;
1818 - }
1819 -@@ -210,8 +210,7 @@ void ext4_evict_inode(struct inode *inode)
1820 - journal_t *journal = EXT4_SB(inode->i_sb)->s_journal;
1821 - tid_t commit_tid = EXT4_I(inode)->i_datasync_tid;
1822 -
1823 -- jbd2_log_start_commit(journal, commit_tid);
1824 -- jbd2_log_wait_commit(journal, commit_tid);
1825 -+ jbd2_complete_transaction(journal, commit_tid);
1826 - filemap_write_and_wait(&inode->i_data);
1827 - }
1828 - truncate_inode_pages(&inode->i_data, 0);
1829 -diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
1830 -index ee6614b..cf3025c 100644
1831 ---- a/fs/ext4/mballoc.c
1832 -+++ b/fs/ext4/mballoc.c
1833 -@@ -4420,11 +4420,11 @@ ext4_mb_free_metadata(handle_t *handle, struct ext4_buddy *e4b,
1834 - node = rb_prev(new_node);
1835 - if (node) {
1836 - entry = rb_entry(node, struct ext4_free_data, efd_node);
1837 -- if (can_merge(entry, new_entry)) {
1838 -+ if (can_merge(entry, new_entry) &&
1839 -+ ext4_journal_callback_try_del(handle, &entry->efd_jce)) {
1840 - new_entry->efd_start_cluster = entry->efd_start_cluster;
1841 - new_entry->efd_count += entry->efd_count;
1842 - rb_erase(node, &(db->bb_free_root));
1843 -- ext4_journal_callback_del(handle, &entry->efd_jce);
1844 - kmem_cache_free(ext4_free_data_cachep, entry);
1845 - }
1846 - }
1847 -@@ -4432,10 +4432,10 @@ ext4_mb_free_metadata(handle_t *handle, struct ext4_buddy *e4b,
1848 - node = rb_next(new_node);
1849 - if (node) {
1850 - entry = rb_entry(node, struct ext4_free_data, efd_node);
1851 -- if (can_merge(new_entry, entry)) {
1852 -+ if (can_merge(new_entry, entry) &&
1853 -+ ext4_journal_callback_try_del(handle, &entry->efd_jce)) {
1854 - new_entry->efd_count += entry->efd_count;
1855 - rb_erase(node, &(db->bb_free_root));
1856 -- ext4_journal_callback_del(handle, &entry->efd_jce);
1857 - kmem_cache_free(ext4_free_data_cachep, entry);
1858 - }
1859 - }
1860 -diff --git a/fs/ext4/mmp.c b/fs/ext4/mmp.c
1861 -index f9b5515..b3b1f7d 100644
1862 ---- a/fs/ext4/mmp.c
1863 -+++ b/fs/ext4/mmp.c
1864 -@@ -7,7 +7,7 @@
1865 - #include "ext4.h"
1866 -
1867 - /* Checksumming functions */
1868 --static __u32 ext4_mmp_csum(struct super_block *sb, struct mmp_struct *mmp)
1869 -+static __le32 ext4_mmp_csum(struct super_block *sb, struct mmp_struct *mmp)
1870 - {
1871 - struct ext4_sb_info *sbi = EXT4_SB(sb);
1872 - int offset = offsetof(struct mmp_struct, mmp_checksum);
1873 -diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
1874 -index c169477..1357260 100644
1875 ---- a/fs/ext4/resize.c
1876 -+++ b/fs/ext4/resize.c
1877 -@@ -1341,6 +1341,8 @@ static void ext4_update_super(struct super_block *sb,
1878 -
1879 - /* Update the global fs size fields */
1880 - sbi->s_groups_count += flex_gd->count;
1881 -+ sbi->s_blockfile_groups = min_t(ext4_group_t, sbi->s_groups_count,
1882 -+ (EXT4_MAX_BLOCK_FILE_PHYS / EXT4_BLOCKS_PER_GROUP(sb)));
1883 -
1884 - /* Update the reserved block counts only once the new group is
1885 - * active. */
1886 -diff --git a/fs/ext4/super.c b/fs/ext4/super.c
1887 -index 5d6d5357..febbe0e 100644
1888 ---- a/fs/ext4/super.c
1889 -+++ b/fs/ext4/super.c
1890 -@@ -353,10 +353,13 @@ static void ext4_journal_commit_callback(journal_t *journal, transaction_t *txn)
1891 - struct super_block *sb = journal->j_private;
1892 - struct ext4_sb_info *sbi = EXT4_SB(sb);
1893 - int error = is_journal_aborted(journal);
1894 -- struct ext4_journal_cb_entry *jce, *tmp;
1895 -+ struct ext4_journal_cb_entry *jce;
1896 -
1897 -+ BUG_ON(txn->t_state == T_FINISHED);
1898 - spin_lock(&sbi->s_md_lock);
1899 -- list_for_each_entry_safe(jce, tmp, &txn->t_private_list, jce_list) {
1900 -+ while (!list_empty(&txn->t_private_list)) {
1901 -+ jce = list_entry(txn->t_private_list.next,
1902 -+ struct ext4_journal_cb_entry, jce_list);
1903 - list_del_init(&jce->jce_list);
1904 - spin_unlock(&sbi->s_md_lock);
1905 - jce->jce_func(sb, jce, error);
1906 -@@ -3698,6 +3701,9 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
1907 - sbi->s_err_report.function = print_daily_error_info;
1908 - sbi->s_err_report.data = (unsigned long) sb;
1909 -
1910 -+ /* Register extent status tree shrinker */
1911 -+ ext4_es_register_shrinker(sb);
1912 -+
1913 - err = percpu_counter_init(&sbi->s_freeclusters_counter,
1914 - ext4_count_free_clusters(sb));
1915 - if (!err) {
1916 -@@ -3723,9 +3729,6 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
1917 - sbi->s_max_writeback_mb_bump = 128;
1918 - sbi->s_extent_max_zeroout_kb = 32;
1919 -
1920 -- /* Register extent status tree shrinker */
1921 -- ext4_es_register_shrinker(sb);
1922 --
1923 - /*
1924 - * set up enough so that it can read an inode
1925 - */
1926 -@@ -4010,6 +4013,7 @@ failed_mount_wq:
1927 - sbi->s_journal = NULL;
1928 - }
1929 - failed_mount3:
1930 -+ ext4_es_unregister_shrinker(sb);
1931 - del_timer(&sbi->s_err_report);
1932 - if (sbi->s_flex_groups)
1933 - ext4_kvfree(sbi->s_flex_groups);
1934 -diff --git a/fs/fscache/stats.c b/fs/fscache/stats.c
1935 -index 8179e8b..40d13c7 100644
1936 ---- a/fs/fscache/stats.c
1937 -+++ b/fs/fscache/stats.c
1938 -@@ -287,5 +287,5 @@ const struct file_operations fscache_stats_fops = {
1939 - .open = fscache_stats_open,
1940 - .read = seq_read,
1941 - .llseek = seq_lseek,
1942 -- .release = seq_release,
1943 -+ .release = single_release,
1944 - };
1945 -diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c
1946 -index 750c701..0f53946 100644
1947 ---- a/fs/jbd2/commit.c
1948 -+++ b/fs/jbd2/commit.c
1949 -@@ -382,7 +382,7 @@ void jbd2_journal_commit_transaction(journal_t *journal)
1950 - int space_left = 0;
1951 - int first_tag = 0;
1952 - int tag_flag;
1953 -- int i, to_free = 0;
1954 -+ int i;
1955 - int tag_bytes = journal_tag_bytes(journal);
1956 - struct buffer_head *cbh = NULL; /* For transactional checksums */
1957 - __u32 crc32_sum = ~0;
1958 -@@ -1134,7 +1134,7 @@ restart_loop:
1959 - journal->j_stats.run.rs_blocks_logged += stats.run.rs_blocks_logged;
1960 - spin_unlock(&journal->j_history_lock);
1961 -
1962 -- commit_transaction->t_state = T_FINISHED;
1963 -+ commit_transaction->t_state = T_COMMIT_CALLBACK;
1964 - J_ASSERT(commit_transaction == journal->j_committing_transaction);
1965 - journal->j_commit_sequence = commit_transaction->t_tid;
1966 - journal->j_committing_transaction = NULL;
1967 -@@ -1149,38 +1149,44 @@ restart_loop:
1968 - journal->j_average_commit_time*3) / 4;
1969 - else
1970 - journal->j_average_commit_time = commit_time;
1971 -+
1972 - write_unlock(&journal->j_state_lock);
1973 -
1974 -- if (commit_transaction->t_checkpoint_list == NULL &&
1975 -- commit_transaction->t_checkpoint_io_list == NULL) {
1976 -- __jbd2_journal_drop_transaction(journal, commit_transaction);
1977 -- to_free = 1;
1978 -+ if (journal->j_checkpoint_transactions == NULL) {
1979 -+ journal->j_checkpoint_transactions = commit_transaction;
1980 -+ commit_transaction->t_cpnext = commit_transaction;
1981 -+ commit_transaction->t_cpprev = commit_transaction;
1982 - } else {
1983 -- if (journal->j_checkpoint_transactions == NULL) {
1984 -- journal->j_checkpoint_transactions = commit_transaction;
1985 -- commit_transaction->t_cpnext = commit_transaction;
1986 -- commit_transaction->t_cpprev = commit_transaction;
1987 -- } else {
1988 -- commit_transaction->t_cpnext =
1989 -- journal->j_checkpoint_transactions;
1990 -- commit_transaction->t_cpprev =
1991 -- commit_transaction->t_cpnext->t_cpprev;
1992 -- commit_transaction->t_cpnext->t_cpprev =
1993 -- commit_transaction;
1994 -- commit_transaction->t_cpprev->t_cpnext =
1995 -+ commit_transaction->t_cpnext =
1996 -+ journal->j_checkpoint_transactions;
1997 -+ commit_transaction->t_cpprev =
1998 -+ commit_transaction->t_cpnext->t_cpprev;
1999 -+ commit_transaction->t_cpnext->t_cpprev =
2000 -+ commit_transaction;
2001 -+ commit_transaction->t_cpprev->t_cpnext =
2002 - commit_transaction;
2003 -- }
2004 - }
2005 - spin_unlock(&journal->j_list_lock);
2006 --
2007 -+ /* Drop all spin_locks because commit_callback may be block.
2008 -+ * __journal_remove_checkpoint() can not destroy transaction
2009 -+ * under us because it is not marked as T_FINISHED yet */
2010 - if (journal->j_commit_callback)
2011 - journal->j_commit_callback(journal, commit_transaction);
2012 -
2013 - trace_jbd2_end_commit(journal, commit_transaction);
2014 - jbd_debug(1, "JBD2: commit %d complete, head %d\n",
2015 - journal->j_commit_sequence, journal->j_tail_sequence);
2016 -- if (to_free)
2017 -- jbd2_journal_free_transaction(commit_transaction);
2018 -
2019 -+ write_lock(&journal->j_state_lock);
2020 -+ spin_lock(&journal->j_list_lock);
2021 -+ commit_transaction->t_state = T_FINISHED;
2022 -+ /* Recheck checkpoint lists after j_list_lock was dropped */
2023 -+ if (commit_transaction->t_checkpoint_list == NULL &&
2024 -+ commit_transaction->t_checkpoint_io_list == NULL) {
2025 -+ __jbd2_journal_drop_transaction(journal, commit_transaction);
2026 -+ jbd2_journal_free_transaction(commit_transaction);
2027 -+ }
2028 -+ spin_unlock(&journal->j_list_lock);
2029 -+ write_unlock(&journal->j_state_lock);
2030 - wake_up(&journal->j_wait_done_commit);
2031 - }
2032 -diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
2033 -index ed10991..886ec2f 100644
2034 ---- a/fs/jbd2/journal.c
2035 -+++ b/fs/jbd2/journal.c
2036 -@@ -710,6 +710,37 @@ int jbd2_log_wait_commit(journal_t *journal, tid_t tid)
2037 - }
2038 -
2039 - /*
2040 -+ * When this function returns the transaction corresponding to tid
2041 -+ * will be completed. If the transaction has currently running, start
2042 -+ * committing that transaction before waiting for it to complete. If
2043 -+ * the transaction id is stale, it is by definition already completed,
2044 -+ * so just return SUCCESS.
2045 -+ */
2046 -+int jbd2_complete_transaction(journal_t *journal, tid_t tid)
2047 -+{
2048 -+ int need_to_wait = 1;
2049 -+
2050 -+ read_lock(&journal->j_state_lock);
2051 -+ if (journal->j_running_transaction &&
2052 -+ journal->j_running_transaction->t_tid == tid) {
2053 -+ if (journal->j_commit_request != tid) {
2054 -+ /* transaction not yet started, so request it */
2055 -+ read_unlock(&journal->j_state_lock);
2056 -+ jbd2_log_start_commit(journal, tid);
2057 -+ goto wait_commit;
2058 -+ }
2059 -+ } else if (!(journal->j_committing_transaction &&
2060 -+ journal->j_committing_transaction->t_tid == tid))
2061 -+ need_to_wait = 0;
2062 -+ read_unlock(&journal->j_state_lock);
2063 -+ if (!need_to_wait)
2064 -+ return 0;
2065 -+wait_commit:
2066 -+ return jbd2_log_wait_commit(journal, tid);
2067 -+}
2068 -+EXPORT_SYMBOL(jbd2_complete_transaction);
2069 -+
2070 -+/*
2071 - * Log buffer allocation routines:
2072 - */
2073 -
2074 -diff --git a/fs/lockd/clntlock.c b/fs/lockd/clntlock.c
2075 -index 0796c45..01bfe76 100644
2076 ---- a/fs/lockd/clntlock.c
2077 -+++ b/fs/lockd/clntlock.c
2078 -@@ -144,6 +144,9 @@ int nlmclnt_block(struct nlm_wait *block, struct nlm_rqst *req, long timeout)
2079 - timeout);
2080 - if (ret < 0)
2081 - return -ERESTARTSYS;
2082 -+ /* Reset the lock status after a server reboot so we resend */
2083 -+ if (block->b_status == nlm_lck_denied_grace_period)
2084 -+ block->b_status = nlm_lck_blocked;
2085 - req->a_res.status = block->b_status;
2086 - return 0;
2087 - }
2088 -diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
2089 -index 7e529c3..9760ecb 100644
2090 ---- a/fs/lockd/clntproc.c
2091 -+++ b/fs/lockd/clntproc.c
2092 -@@ -550,9 +550,6 @@ again:
2093 - status = nlmclnt_block(block, req, NLMCLNT_POLL_TIMEOUT);
2094 - if (status < 0)
2095 - break;
2096 -- /* Resend the blocking lock request after a server reboot */
2097 -- if (resp->status == nlm_lck_denied_grace_period)
2098 -- continue;
2099 - if (resp->status != nlm_lck_blocked)
2100 - break;
2101 - }
2102 -diff --git a/fs/namespace.c b/fs/namespace.c
2103 -index 341d3f5..e945b81 100644
2104 ---- a/fs/namespace.c
2105 -+++ b/fs/namespace.c
2106 -@@ -2238,12 +2238,11 @@ long do_mount(const char *dev_name, const char *dir_name,
2107 -
2108 - retval = security_sb_mount(dev_name, &path,
2109 - type_page, flags, data_page);
2110 -+ if (!retval && !may_mount())
2111 -+ retval = -EPERM;
2112 - if (retval)
2113 - goto dput_out;
2114 -
2115 -- if (!may_mount())
2116 -- return -EPERM;
2117 --
2118 - /* Default to relatime unless overriden */
2119 - if (!(flags & MS_NOATIME))
2120 - mnt_flags |= MNT_RELATIME;
2121 -diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
2122 -index 0ad025e..c7856a1 100644
2123 ---- a/fs/nfs/nfs4proc.c
2124 -+++ b/fs/nfs/nfs4proc.c
2125 -@@ -1380,6 +1380,12 @@ int nfs4_open_delegation_recall(struct nfs_open_context *ctx, struct nfs4_state
2126 - case -ENOMEM:
2127 - err = 0;
2128 - goto out;
2129 -+ case -NFS4ERR_DELAY:
2130 -+ case -NFS4ERR_GRACE:
2131 -+ set_bit(NFS_DELEGATED_STATE, &state->flags);
2132 -+ ssleep(1);
2133 -+ err = -EAGAIN;
2134 -+ goto out;
2135 - }
2136 - set_bit(NFS_DELEGATED_STATE, &state->flags);
2137 - err = nfs4_handle_exception(server, err, &exception);
2138 -@@ -5025,6 +5031,12 @@ int nfs4_lock_delegation_recall(struct nfs4_state *state, struct file_lock *fl)
2139 - nfs4_schedule_stateid_recovery(server, state);
2140 - err = 0;
2141 - goto out;
2142 -+ case -NFS4ERR_DELAY:
2143 -+ case -NFS4ERR_GRACE:
2144 -+ set_bit(NFS_DELEGATED_STATE, &state->flags);
2145 -+ ssleep(1);
2146 -+ err = -EAGAIN;
2147 -+ goto out;
2148 - case -ENOMEM:
2149 - case -NFS4ERR_DENIED:
2150 - /* kill_proc(fl->fl_pid, SIGLOST, 1); */
2151 -diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
2152 -index ae73175..8288b08 100644
2153 ---- a/fs/nfsd/nfs4proc.c
2154 -+++ b/fs/nfsd/nfs4proc.c
2155 -@@ -931,14 +931,14 @@ nfsd4_write(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
2156 - nfs4_lock_state();
2157 - status = nfs4_preprocess_stateid_op(SVC_NET(rqstp),
2158 - cstate, stateid, WR_STATE, &filp);
2159 -- if (filp)
2160 -- get_file(filp);
2161 -- nfs4_unlock_state();
2162 --
2163 - if (status) {
2164 -+ nfs4_unlock_state();
2165 - dprintk("NFSD: nfsd4_write: couldn't process stateid!\n");
2166 - return status;
2167 - }
2168 -+ if (filp)
2169 -+ get_file(filp);
2170 -+ nfs4_unlock_state();
2171 -
2172 - cnt = write->wr_buflen;
2173 - write->wr_how_written = write->wr_stable_how;
2174 -diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
2175 -index 2e27430..f9a5e62 100644
2176 ---- a/fs/nfsd/nfs4state.c
2177 -+++ b/fs/nfsd/nfs4state.c
2178 -@@ -210,13 +210,7 @@ static void __nfs4_file_put_access(struct nfs4_file *fp, int oflag)
2179 - {
2180 - if (atomic_dec_and_test(&fp->fi_access[oflag])) {
2181 - nfs4_file_put_fd(fp, oflag);
2182 -- /*
2183 -- * It's also safe to get rid of the RDWR open *if*
2184 -- * we no longer have need of the other kind of access
2185 -- * or if we already have the other kind of open:
2186 -- */
2187 -- if (fp->fi_fds[1-oflag]
2188 -- || atomic_read(&fp->fi_access[1 - oflag]) == 0)
2189 -+ if (atomic_read(&fp->fi_access[1 - oflag]) == 0)
2190 - nfs4_file_put_fd(fp, O_RDWR);
2191 - }
2192 - }
2193 -@@ -267,7 +261,7 @@ kmem_cache *slab)
2194 - min_stateid = 0;
2195 - return stid;
2196 - out_free:
2197 -- kfree(stid);
2198 -+ kmem_cache_free(slab, stid);
2199 - return NULL;
2200 - }
2201 -
2202 -diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
2203 -index a272007..6eb0dc5 100644
2204 ---- a/fs/nfsd/nfs4xdr.c
2205 -+++ b/fs/nfsd/nfs4xdr.c
2206 -@@ -344,10 +344,7 @@ nfsd4_decode_fattr(struct nfsd4_compoundargs *argp, u32 *bmval,
2207 - all 32 bits of 'nseconds'. */
2208 - READ_BUF(12);
2209 - len += 12;
2210 -- READ32(dummy32);
2211 -- if (dummy32)
2212 -- return nfserr_inval;
2213 -- READ32(iattr->ia_atime.tv_sec);
2214 -+ READ64(iattr->ia_atime.tv_sec);
2215 - READ32(iattr->ia_atime.tv_nsec);
2216 - if (iattr->ia_atime.tv_nsec >= (u32)1000000000)
2217 - return nfserr_inval;
2218 -@@ -370,10 +367,7 @@ nfsd4_decode_fattr(struct nfsd4_compoundargs *argp, u32 *bmval,
2219 - all 32 bits of 'nseconds'. */
2220 - READ_BUF(12);
2221 - len += 12;
2222 -- READ32(dummy32);
2223 -- if (dummy32)
2224 -- return nfserr_inval;
2225 -- READ32(iattr->ia_mtime.tv_sec);
2226 -+ READ64(iattr->ia_mtime.tv_sec);
2227 - READ32(iattr->ia_mtime.tv_nsec);
2228 - if (iattr->ia_mtime.tv_nsec >= (u32)1000000000)
2229 - return nfserr_inval;
2230 -@@ -2401,8 +2395,7 @@ out_acl:
2231 - if (bmval1 & FATTR4_WORD1_TIME_ACCESS) {
2232 - if ((buflen -= 12) < 0)
2233 - goto out_resource;
2234 -- WRITE32(0);
2235 -- WRITE32(stat.atime.tv_sec);
2236 -+ WRITE64((s64)stat.atime.tv_sec);
2237 - WRITE32(stat.atime.tv_nsec);
2238 - }
2239 - if (bmval1 & FATTR4_WORD1_TIME_DELTA) {
2240 -@@ -2415,15 +2408,13 @@ out_acl:
2241 - if (bmval1 & FATTR4_WORD1_TIME_METADATA) {
2242 - if ((buflen -= 12) < 0)
2243 - goto out_resource;
2244 -- WRITE32(0);
2245 -- WRITE32(stat.ctime.tv_sec);
2246 -+ WRITE64((s64)stat.ctime.tv_sec);
2247 - WRITE32(stat.ctime.tv_nsec);
2248 - }
2249 - if (bmval1 & FATTR4_WORD1_TIME_MODIFY) {
2250 - if ((buflen -= 12) < 0)
2251 - goto out_resource;
2252 -- WRITE32(0);
2253 -- WRITE32(stat.mtime.tv_sec);
2254 -+ WRITE64((s64)stat.mtime.tv_sec);
2255 - WRITE32(stat.mtime.tv_nsec);
2256 - }
2257 - if (bmval1 & FATTR4_WORD1_MOUNTED_ON_FILEID) {
2258 -diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c
2259 -index e0f7c12..5fe21d6 100644
2260 ---- a/fs/notify/inotify/inotify_user.c
2261 -+++ b/fs/notify/inotify/inotify_user.c
2262 -@@ -572,7 +572,6 @@ static int inotify_update_existing_watch(struct fsnotify_group *group,
2263 - int add = (arg & IN_MASK_ADD);
2264 - int ret;
2265 -
2266 -- /* don't allow invalid bits: we don't want flags set */
2267 - mask = inotify_arg_to_mask(arg);
2268 -
2269 - fsn_mark = fsnotify_find_inode_mark(group, inode);
2270 -@@ -623,7 +622,6 @@ static int inotify_new_watch(struct fsnotify_group *group,
2271 - struct idr *idr = &group->inotify_data.idr;
2272 - spinlock_t *idr_lock = &group->inotify_data.idr_lock;
2273 -
2274 -- /* don't allow invalid bits: we don't want flags set */
2275 - mask = inotify_arg_to_mask(arg);
2276 -
2277 - tmp_i_mark = kmem_cache_alloc(inotify_inode_mark_cachep, GFP_KERNEL);
2278 -@@ -751,6 +749,10 @@ SYSCALL_DEFINE3(inotify_add_watch, int, fd, const char __user *, pathname,
2279 - int ret;
2280 - unsigned flags = 0;
2281 -
2282 -+ /* don't allow invalid bits: we don't want flags set */
2283 -+ if (unlikely(!(mask & ALL_INOTIFY_BITS)))
2284 -+ return -EINVAL;
2285 -+
2286 - f = fdget(fd);
2287 - if (unlikely(!f.file))
2288 - return -EBADF;
2289 -diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
2290 -index e145126..6f31590 100644
2291 ---- a/fs/sysfs/dir.c
2292 -+++ b/fs/sysfs/dir.c
2293 -@@ -1012,6 +1012,7 @@ static int sysfs_readdir(struct file * filp, void * dirent, filldir_t filldir)
2294 - enum kobj_ns_type type;
2295 - const void *ns;
2296 - ino_t ino;
2297 -+ loff_t off;
2298 -
2299 - type = sysfs_ns_type(parent_sd);
2300 - ns = sysfs_info(dentry->d_sb)->ns[type];
2301 -@@ -1034,6 +1035,7 @@ static int sysfs_readdir(struct file * filp, void * dirent, filldir_t filldir)
2302 - return 0;
2303 - }
2304 - mutex_lock(&sysfs_mutex);
2305 -+ off = filp->f_pos;
2306 - for (pos = sysfs_dir_pos(ns, parent_sd, filp->f_pos, pos);
2307 - pos;
2308 - pos = sysfs_dir_next_pos(ns, parent_sd, filp->f_pos, pos)) {
2309 -@@ -1045,19 +1047,24 @@ static int sysfs_readdir(struct file * filp, void * dirent, filldir_t filldir)
2310 - len = strlen(name);
2311 - ino = pos->s_ino;
2312 - type = dt_type(pos);
2313 -- filp->f_pos = pos->s_hash;
2314 -+ off = filp->f_pos = pos->s_hash;
2315 - filp->private_data = sysfs_get(pos);
2316 -
2317 - mutex_unlock(&sysfs_mutex);
2318 -- ret = filldir(dirent, name, len, filp->f_pos, ino, type);
2319 -+ ret = filldir(dirent, name, len, off, ino, type);
2320 - mutex_lock(&sysfs_mutex);
2321 - if (ret < 0)
2322 - break;
2323 - }
2324 - mutex_unlock(&sysfs_mutex);
2325 -- if ((filp->f_pos > 1) && !pos) { /* EOF */
2326 -- filp->f_pos = INT_MAX;
2327 -+
2328 -+ /* don't reference last entry if its refcount is dropped */
2329 -+ if (!pos) {
2330 - filp->private_data = NULL;
2331 -+
2332 -+ /* EOF and not changed as 0 or 1 in read/write path */
2333 -+ if (off == filp->f_pos && off > 1)
2334 -+ filp->f_pos = INT_MAX;
2335 - }
2336 - return 0;
2337 - }
2338 -diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
2339 -index bfd8768..a59ff51 100644
2340 ---- a/include/asm-generic/pgtable.h
2341 -+++ b/include/asm-generic/pgtable.h
2342 -@@ -7,6 +7,16 @@
2343 - #include <linux/mm_types.h>
2344 - #include <linux/bug.h>
2345 -
2346 -+/*
2347 -+ * On almost all architectures and configurations, 0 can be used as the
2348 -+ * upper ceiling to free_pgtables(): on many architectures it has the same
2349 -+ * effect as using TASK_SIZE. However, there is one configuration which
2350 -+ * must impose a more careful limit, to avoid freeing kernel pgtables.
2351 -+ */
2352 -+#ifndef USER_PGTABLES_CEILING
2353 -+#define USER_PGTABLES_CEILING 0UL
2354 -+#endif
2355 -+
2356 - #ifndef __HAVE_ARCH_PTEP_SET_ACCESS_FLAGS
2357 - extern int ptep_set_access_flags(struct vm_area_struct *vma,
2358 - unsigned long address, pte_t *ptep,
2359 -diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
2360 -index 900af59..16d4d09 100644
2361 ---- a/include/linux/cgroup.h
2362 -+++ b/include/linux/cgroup.h
2363 -@@ -304,9 +304,6 @@ struct cftype {
2364 - /* CFTYPE_* flags */
2365 - unsigned int flags;
2366 -
2367 -- /* file xattrs */
2368 -- struct simple_xattrs xattrs;
2369 --
2370 - int (*open)(struct inode *inode, struct file *file);
2371 - ssize_t (*read)(struct cgroup *cgrp, struct cftype *cft,
2372 - struct file *file,
2373 -diff --git a/include/linux/ipc_namespace.h b/include/linux/ipc_namespace.h
2374 -index ae221a7..c4d870b 100644
2375 ---- a/include/linux/ipc_namespace.h
2376 -+++ b/include/linux/ipc_namespace.h
2377 -@@ -43,8 +43,8 @@ struct ipc_namespace {
2378 -
2379 - size_t shm_ctlmax;
2380 - size_t shm_ctlall;
2381 -+ unsigned long shm_tot;
2382 - int shm_ctlmni;
2383 -- int shm_tot;
2384 - /*
2385 - * Defines whether IPC_RMID is forced for _all_ shm segments regardless
2386 - * of shmctl()
2387 -diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h
2388 -index 50e5a5e..f9fe889 100644
2389 ---- a/include/linux/jbd2.h
2390 -+++ b/include/linux/jbd2.h
2391 -@@ -480,6 +480,7 @@ struct transaction_s
2392 - T_COMMIT,
2393 - T_COMMIT_DFLUSH,
2394 - T_COMMIT_JFLUSH,
2395 -+ T_COMMIT_CALLBACK,
2396 - T_FINISHED
2397 - } t_state;
2398 -
2399 -@@ -1200,6 +1201,7 @@ int __jbd2_log_start_commit(journal_t *journal, tid_t tid);
2400 - int jbd2_journal_start_commit(journal_t *journal, tid_t *tid);
2401 - int jbd2_journal_force_commit_nested(journal_t *journal);
2402 - int jbd2_log_wait_commit(journal_t *journal, tid_t tid);
2403 -+int jbd2_complete_transaction(journal_t *journal, tid_t tid);
2404 - int jbd2_log_do_checkpoint(journal_t *journal);
2405 - int jbd2_trans_will_send_data_barrier(journal_t *journal, tid_t tid);
2406 -
2407 -diff --git a/include/linux/sched.h b/include/linux/sched.h
2408 -index e692a02..be4e742 100644
2409 ---- a/include/linux/sched.h
2410 -+++ b/include/linux/sched.h
2411 -@@ -2413,27 +2413,18 @@ static inline void threadgroup_change_end(struct task_struct *tsk)
2412 - *
2413 - * Lock the threadgroup @tsk belongs to. No new task is allowed to enter
2414 - * and member tasks aren't allowed to exit (as indicated by PF_EXITING) or
2415 -- * perform exec. This is useful for cases where the threadgroup needs to
2416 -- * stay stable across blockable operations.
2417 -+ * change ->group_leader/pid. This is useful for cases where the threadgroup
2418 -+ * needs to stay stable across blockable operations.
2419 - *
2420 - * fork and exit paths explicitly call threadgroup_change_{begin|end}() for
2421 - * synchronization. While held, no new task will be added to threadgroup
2422 - * and no existing live task will have its PF_EXITING set.
2423 - *
2424 -- * During exec, a task goes and puts its thread group through unusual
2425 -- * changes. After de-threading, exclusive access is assumed to resources
2426 -- * which are usually shared by tasks in the same group - e.g. sighand may
2427 -- * be replaced with a new one. Also, the exec'ing task takes over group
2428 -- * leader role including its pid. Exclude these changes while locked by
2429 -- * grabbing cred_guard_mutex which is used to synchronize exec path.
2430 -+ * de_thread() does threadgroup_change_{begin|end}() when a non-leader
2431 -+ * sub-thread becomes a new leader.
2432 - */
2433 - static inline void threadgroup_lock(struct task_struct *tsk)
2434 - {
2435 -- /*
2436 -- * exec uses exit for de-threading nesting group_rwsem inside
2437 -- * cred_guard_mutex. Grab cred_guard_mutex first.
2438 -- */
2439 -- mutex_lock(&tsk->signal->cred_guard_mutex);
2440 - down_write(&tsk->signal->group_rwsem);
2441 - }
2442 -
2443 -@@ -2446,7 +2437,6 @@ static inline void threadgroup_lock(struct task_struct *tsk)
2444 - static inline void threadgroup_unlock(struct task_struct *tsk)
2445 - {
2446 - up_write(&tsk->signal->group_rwsem);
2447 -- mutex_unlock(&tsk->signal->cred_guard_mutex);
2448 - }
2449 - #else
2450 - static inline void threadgroup_change_begin(struct task_struct *tsk) {}
2451 -diff --git a/include/sound/emu10k1.h b/include/sound/emu10k1.h
2452 -index f841ba4..dfb42ca 100644
2453 ---- a/include/sound/emu10k1.h
2454 -+++ b/include/sound/emu10k1.h
2455 -@@ -1787,6 +1787,7 @@ struct snd_emu10k1 {
2456 - unsigned int next_free_voice;
2457 -
2458 - const struct firmware *firmware;
2459 -+ const struct firmware *dock_fw;
2460 -
2461 - #ifdef CONFIG_PM_SLEEP
2462 - unsigned int *saved_ptr;
2463 -diff --git a/ipc/shm.c b/ipc/shm.c
2464 -index cb858df..8247c49 100644
2465 ---- a/ipc/shm.c
2466 -+++ b/ipc/shm.c
2467 -@@ -462,7 +462,7 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
2468 - size_t size = params->u.size;
2469 - int error;
2470 - struct shmid_kernel *shp;
2471 -- int numpages = (size + PAGE_SIZE -1) >> PAGE_SHIFT;
2472 -+ size_t numpages = (size + PAGE_SIZE - 1) >> PAGE_SHIFT;
2473 - struct file * file;
2474 - char name[13];
2475 - int id;
2476 -diff --git a/kernel/cgroup.c b/kernel/cgroup.c
2477 -index a32f943..ba1f977 100644
2478 ---- a/kernel/cgroup.c
2479 -+++ b/kernel/cgroup.c
2480 -@@ -162,6 +162,9 @@ struct cfent {
2481 - struct list_head node;
2482 - struct dentry *dentry;
2483 - struct cftype *type;
2484 -+
2485 -+ /* file xattrs */
2486 -+ struct simple_xattrs xattrs;
2487 - };
2488 -
2489 - /*
2490 -@@ -910,13 +913,12 @@ static void cgroup_diput(struct dentry *dentry, struct inode *inode)
2491 - } else {
2492 - struct cfent *cfe = __d_cfe(dentry);
2493 - struct cgroup *cgrp = dentry->d_parent->d_fsdata;
2494 -- struct cftype *cft = cfe->type;
2495 -
2496 - WARN_ONCE(!list_empty(&cfe->node) &&
2497 - cgrp != &cgrp->root->top_cgroup,
2498 - "cfe still linked for %s\n", cfe->type->name);
2499 -+ simple_xattrs_free(&cfe->xattrs);
2500 - kfree(cfe);
2501 -- simple_xattrs_free(&cft->xattrs);
2502 - }
2503 - iput(inode);
2504 - }
2505 -@@ -2065,7 +2067,7 @@ static int cgroup_attach_proc(struct cgroup *cgrp, struct task_struct *leader)
2506 - if (!group)
2507 - return -ENOMEM;
2508 - /* pre-allocate to guarantee space while iterating in rcu read-side. */
2509 -- retval = flex_array_prealloc(group, 0, group_size - 1, GFP_KERNEL);
2510 -+ retval = flex_array_prealloc(group, 0, group_size, GFP_KERNEL);
2511 - if (retval)
2512 - goto out_free_group_list;
2513 -
2514 -@@ -2551,7 +2553,7 @@ static struct simple_xattrs *__d_xattrs(struct dentry *dentry)
2515 - if (S_ISDIR(dentry->d_inode->i_mode))
2516 - return &__d_cgrp(dentry)->xattrs;
2517 - else
2518 -- return &__d_cft(dentry)->xattrs;
2519 -+ return &__d_cfe(dentry)->xattrs;
2520 - }
2521 -
2522 - static inline int xattr_enabled(struct dentry *dentry)
2523 -@@ -2727,8 +2729,6 @@ static int cgroup_add_file(struct cgroup *cgrp, struct cgroup_subsys *subsys,
2524 - umode_t mode;
2525 - char name[MAX_CGROUP_TYPE_NAMELEN + MAX_CFTYPE_NAME + 2] = { 0 };
2526 -
2527 -- simple_xattrs_init(&cft->xattrs);
2528 --
2529 - if (subsys && !test_bit(ROOT_NOPREFIX, &cgrp->root->flags)) {
2530 - strcpy(name, subsys->name);
2531 - strcat(name, ".");
2532 -@@ -2753,6 +2753,7 @@ static int cgroup_add_file(struct cgroup *cgrp, struct cgroup_subsys *subsys,
2533 - cfe->type = (void *)cft;
2534 - cfe->dentry = dentry;
2535 - dentry->d_fsdata = cfe;
2536 -+ simple_xattrs_init(&cfe->xattrs);
2537 - list_add_tail(&cfe->node, &parent->files);
2538 - cfe = NULL;
2539 - }
2540 -diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
2541 -index 14be27f..7ef5556 100644
2542 ---- a/kernel/hrtimer.c
2543 -+++ b/kernel/hrtimer.c
2544 -@@ -276,6 +276,10 @@ ktime_t ktime_add_ns(const ktime_t kt, u64 nsec)
2545 - } else {
2546 - unsigned long rem = do_div(nsec, NSEC_PER_SEC);
2547 -
2548 -+ /* Make sure nsec fits into long */
2549 -+ if (unlikely(nsec > KTIME_SEC_MAX))
2550 -+ return (ktime_t){ .tv64 = KTIME_MAX };
2551 -+
2552 - tmp = ktime_set((long)nsec, rem);
2553 - }
2554 -
2555 -@@ -1310,6 +1314,8 @@ retry:
2556 -
2557 - expires = ktime_sub(hrtimer_get_expires(timer),
2558 - base->offset);
2559 -+ if (expires.tv64 < 0)
2560 -+ expires.tv64 = KTIME_MAX;
2561 - if (expires.tv64 < expires_next.tv64)
2562 - expires_next = expires;
2563 - break;
2564 -diff --git a/kernel/rcutree_trace.c b/kernel/rcutree_trace.c
2565 -index 0d095dc..93f8e8f 100644
2566 ---- a/kernel/rcutree_trace.c
2567 -+++ b/kernel/rcutree_trace.c
2568 -@@ -97,7 +97,7 @@ static const struct file_operations rcubarrier_fops = {
2569 - .open = rcubarrier_open,
2570 - .read = seq_read,
2571 - .llseek = no_llseek,
2572 -- .release = seq_release,
2573 -+ .release = single_release,
2574 - };
2575 -
2576 - #ifdef CONFIG_RCU_BOOST
2577 -@@ -208,7 +208,7 @@ static const struct file_operations rcuexp_fops = {
2578 - .open = rcuexp_open,
2579 - .read = seq_read,
2580 - .llseek = no_llseek,
2581 -- .release = seq_release,
2582 -+ .release = single_release,
2583 - };
2584 -
2585 - #ifdef CONFIG_RCU_BOOST
2586 -@@ -308,7 +308,7 @@ static const struct file_operations rcuhier_fops = {
2587 - .open = rcuhier_open,
2588 - .read = seq_read,
2589 - .llseek = no_llseek,
2590 -- .release = seq_release,
2591 -+ .release = single_release,
2592 - };
2593 -
2594 - static void show_one_rcugp(struct seq_file *m, struct rcu_state *rsp)
2595 -@@ -350,7 +350,7 @@ static const struct file_operations rcugp_fops = {
2596 - .open = rcugp_open,
2597 - .read = seq_read,
2598 - .llseek = no_llseek,
2599 -- .release = seq_release,
2600 -+ .release = single_release,
2601 - };
2602 -
2603 - static void print_one_rcu_pending(struct seq_file *m, struct rcu_data *rdp)
2604 -diff --git a/kernel/time/tick-broadcast.c b/kernel/time/tick-broadcast.c
2605 -index 7f32fe0..90ad470 100644
2606 ---- a/kernel/time/tick-broadcast.c
2607 -+++ b/kernel/time/tick-broadcast.c
2608 -@@ -67,6 +67,8 @@ static void tick_broadcast_start_periodic(struct clock_event_device *bc)
2609 - */
2610 - int tick_check_broadcast_device(struct clock_event_device *dev)
2611 - {
2612 -+ struct clock_event_device *cur = tick_broadcast_device.evtdev;
2613 -+
2614 - if ((dev->features & CLOCK_EVT_FEAT_DUMMY) ||
2615 - (tick_broadcast_device.evtdev &&
2616 - tick_broadcast_device.evtdev->rating >= dev->rating) ||
2617 -@@ -74,6 +76,8 @@ int tick_check_broadcast_device(struct clock_event_device *dev)
2618 - return 0;
2619 -
2620 - clockevents_exchange_device(tick_broadcast_device.evtdev, dev);
2621 -+ if (cur)
2622 -+ cur->event_handler = clockevents_handle_noop;
2623 - tick_broadcast_device.evtdev = dev;
2624 - if (!cpumask_empty(tick_get_broadcast_mask()))
2625 - tick_broadcast_start_periodic(dev);
2626 -diff --git a/kernel/time/tick-common.c b/kernel/time/tick-common.c
2627 -index b1600a6..7076b3f 100644
2628 ---- a/kernel/time/tick-common.c
2629 -+++ b/kernel/time/tick-common.c
2630 -@@ -323,6 +323,7 @@ static void tick_shutdown(unsigned int *cpup)
2631 - */
2632 - dev->mode = CLOCK_EVT_MODE_UNUSED;
2633 - clockevents_exchange_device(dev, NULL);
2634 -+ dev->event_handler = clockevents_handle_noop;
2635 - td->evtdev = NULL;
2636 - }
2637 - raw_spin_unlock_irqrestore(&tick_device_lock, flags);
2638 -diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
2639 -index b3fde6d..0a0e2a6 100644
2640 ---- a/kernel/trace/ftrace.c
2641 -+++ b/kernel/trace/ftrace.c
2642 -@@ -676,7 +676,7 @@ int ftrace_profile_pages_init(struct ftrace_profile_stat *stat)
2643 -
2644 - pages = DIV_ROUND_UP(functions, PROFILES_PER_PAGE);
2645 -
2646 -- for (i = 0; i < pages; i++) {
2647 -+ for (i = 1; i < pages; i++) {
2648 - pg->next = (void *)get_zeroed_page(GFP_KERNEL);
2649 - if (!pg->next)
2650 - goto out_free;
2651 -@@ -3736,7 +3736,8 @@ out:
2652 - if (fail)
2653 - return -EINVAL;
2654 -
2655 -- ftrace_graph_filter_enabled = 1;
2656 -+ ftrace_graph_filter_enabled = !!(*idx);
2657 -+
2658 - return 0;
2659 - }
2660 -
2661 -diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
2662 -index 66338c4..7713d1b 100644
2663 ---- a/kernel/trace/trace.c
2664 -+++ b/kernel/trace/trace.c
2665 -@@ -5028,6 +5028,8 @@ static __init int tracer_init_debugfs(void)
2666 - trace_access_lock_init();
2667 -
2668 - d_tracer = tracing_init_dentry();
2669 -+ if (!d_tracer)
2670 -+ return 0;
2671 -
2672 - trace_create_file("trace_options", 0644, d_tracer,
2673 - NULL, &tracing_iter_fops);
2674 -diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
2675 -index 83a8b5b..b20428c 100644
2676 ---- a/kernel/trace/trace_stack.c
2677 -+++ b/kernel/trace/trace_stack.c
2678 -@@ -20,13 +20,24 @@
2679 -
2680 - #define STACK_TRACE_ENTRIES 500
2681 -
2682 -+#ifdef CC_USING_FENTRY
2683 -+# define fentry 1
2684 -+#else
2685 -+# define fentry 0
2686 -+#endif
2687 -+
2688 - static unsigned long stack_dump_trace[STACK_TRACE_ENTRIES+1] =
2689 - { [0 ... (STACK_TRACE_ENTRIES)] = ULONG_MAX };
2690 - static unsigned stack_dump_index[STACK_TRACE_ENTRIES];
2691 -
2692 -+/*
2693 -+ * Reserve one entry for the passed in ip. This will allow
2694 -+ * us to remove most or all of the stack size overhead
2695 -+ * added by the stack tracer itself.
2696 -+ */
2697 - static struct stack_trace max_stack_trace = {
2698 -- .max_entries = STACK_TRACE_ENTRIES,
2699 -- .entries = stack_dump_trace,
2700 -+ .max_entries = STACK_TRACE_ENTRIES - 1,
2701 -+ .entries = &stack_dump_trace[1],
2702 - };
2703 -
2704 - static unsigned long max_stack_size;
2705 -@@ -39,25 +50,34 @@ static DEFINE_MUTEX(stack_sysctl_mutex);
2706 - int stack_tracer_enabled;
2707 - static int last_stack_tracer_enabled;
2708 -
2709 --static inline void check_stack(void)
2710 -+static inline void
2711 -+check_stack(unsigned long ip, unsigned long *stack)
2712 - {
2713 - unsigned long this_size, flags;
2714 - unsigned long *p, *top, *start;
2715 -+ static int tracer_frame;
2716 -+ int frame_size = ACCESS_ONCE(tracer_frame);
2717 - int i;
2718 -
2719 -- this_size = ((unsigned long)&this_size) & (THREAD_SIZE-1);
2720 -+ this_size = ((unsigned long)stack) & (THREAD_SIZE-1);
2721 - this_size = THREAD_SIZE - this_size;
2722 -+ /* Remove the frame of the tracer */
2723 -+ this_size -= frame_size;
2724 -
2725 - if (this_size <= max_stack_size)
2726 - return;
2727 -
2728 - /* we do not handle interrupt stacks yet */
2729 -- if (!object_is_on_stack(&this_size))
2730 -+ if (!object_is_on_stack(stack))
2731 - return;
2732 -
2733 - local_irq_save(flags);
2734 - arch_spin_lock(&max_stack_lock);
2735 -
2736 -+ /* In case another CPU set the tracer_frame on us */
2737 -+ if (unlikely(!frame_size))
2738 -+ this_size -= tracer_frame;
2739 -+
2740 - /* a race could have already updated it */
2741 - if (this_size <= max_stack_size)
2742 - goto out;
2743 -@@ -70,10 +90,18 @@ static inline void check_stack(void)
2744 - save_stack_trace(&max_stack_trace);
2745 -
2746 - /*
2747 -+ * Add the passed in ip from the function tracer.
2748 -+ * Searching for this on the stack will skip over
2749 -+ * most of the overhead from the stack tracer itself.
2750 -+ */
2751 -+ stack_dump_trace[0] = ip;
2752 -+ max_stack_trace.nr_entries++;
2753 -+
2754 -+ /*
2755 - * Now find where in the stack these are.
2756 - */
2757 - i = 0;
2758 -- start = &this_size;
2759 -+ start = stack;
2760 - top = (unsigned long *)
2761 - (((unsigned long)start & ~(THREAD_SIZE-1)) + THREAD_SIZE);
2762 -
2763 -@@ -97,6 +125,18 @@ static inline void check_stack(void)
2764 - found = 1;
2765 - /* Start the search from here */
2766 - start = p + 1;
2767 -+ /*
2768 -+ * We do not want to show the overhead
2769 -+ * of the stack tracer stack in the
2770 -+ * max stack. If we haven't figured
2771 -+ * out what that is, then figure it out
2772 -+ * now.
2773 -+ */
2774 -+ if (unlikely(!tracer_frame) && i == 1) {
2775 -+ tracer_frame = (p - stack) *
2776 -+ sizeof(unsigned long);
2777 -+ max_stack_size -= tracer_frame;
2778 -+ }
2779 - }
2780 - }
2781 -
2782 -@@ -113,6 +153,7 @@ static void
2783 - stack_trace_call(unsigned long ip, unsigned long parent_ip,
2784 - struct ftrace_ops *op, struct pt_regs *pt_regs)
2785 - {
2786 -+ unsigned long stack;
2787 - int cpu;
2788 -
2789 - preempt_disable_notrace();
2790 -@@ -122,7 +163,26 @@ stack_trace_call(unsigned long ip, unsigned long parent_ip,
2791 - if (per_cpu(trace_active, cpu)++ != 0)
2792 - goto out;
2793 -
2794 -- check_stack();
2795 -+ /*
2796 -+ * When fentry is used, the traced function does not get
2797 -+ * its stack frame set up, and we lose the parent.
2798 -+ * The ip is pretty useless because the function tracer
2799 -+ * was called before that function set up its stack frame.
2800 -+ * In this case, we use the parent ip.
2801 -+ *
2802 -+ * By adding the return address of either the parent ip
2803 -+ * or the current ip we can disregard most of the stack usage
2804 -+ * caused by the stack tracer itself.
2805 -+ *
2806 -+ * The function tracer always reports the address of where the
2807 -+ * mcount call was, but the stack will hold the return address.
2808 -+ */
2809 -+ if (fentry)
2810 -+ ip = parent_ip;
2811 -+ else
2812 -+ ip += MCOUNT_INSN_SIZE;
2813 -+
2814 -+ check_stack(ip, &stack);
2815 -
2816 - out:
2817 - per_cpu(trace_active, cpu)--;
2818 -@@ -371,6 +431,8 @@ static __init int stack_trace_init(void)
2819 - struct dentry *d_tracer;
2820 -
2821 - d_tracer = tracing_init_dentry();
2822 -+ if (!d_tracer)
2823 -+ return 0;
2824 -
2825 - trace_create_file("stack_max_size", 0644, d_tracer,
2826 - &max_stack_size, &stack_max_size_fops);
2827 -diff --git a/kernel/trace/trace_stat.c b/kernel/trace/trace_stat.c
2828 -index 96cffb2..847f88a 100644
2829 ---- a/kernel/trace/trace_stat.c
2830 -+++ b/kernel/trace/trace_stat.c
2831 -@@ -307,6 +307,8 @@ static int tracing_stat_init(void)
2832 - struct dentry *d_tracing;
2833 -
2834 - d_tracing = tracing_init_dentry();
2835 -+ if (!d_tracing)
2836 -+ return 0;
2837 -
2838 - stat_dir = debugfs_create_dir("trace_stat", d_tracing);
2839 - if (!stat_dir)
2840 -diff --git a/lib/oid_registry.c b/lib/oid_registry.c
2841 -index d8de11f..318f382 100644
2842 ---- a/lib/oid_registry.c
2843 -+++ b/lib/oid_registry.c
2844 -@@ -9,6 +9,7 @@
2845 - * 2 of the Licence, or (at your option) any later version.
2846 - */
2847 -
2848 -+#include <linux/module.h>
2849 - #include <linux/export.h>
2850 - #include <linux/oid_registry.h>
2851 - #include <linux/kernel.h>
2852 -@@ -16,6 +17,10 @@
2853 - #include <linux/bug.h>
2854 - #include "oid_registry_data.c"
2855 -
2856 -+MODULE_DESCRIPTION("OID Registry");
2857 -+MODULE_AUTHOR("Red Hat, Inc.");
2858 -+MODULE_LICENSE("GPL");
2859 -+
2860 - /**
2861 - * look_up_OID - Find an OID registration for the specified data
2862 - * @data: Binary representation of the OID
2863 -diff --git a/mm/mmap.c b/mm/mmap.c
2864 -index 0db0de1..033094b 100644
2865 ---- a/mm/mmap.c
2866 -+++ b/mm/mmap.c
2867 -@@ -2305,7 +2305,7 @@ static void unmap_region(struct mm_struct *mm,
2868 - update_hiwater_rss(mm);
2869 - unmap_vmas(&tlb, vma, start, end);
2870 - free_pgtables(&tlb, vma, prev ? prev->vm_end : FIRST_USER_ADDRESS,
2871 -- next ? next->vm_start : 0);
2872 -+ next ? next->vm_start : USER_PGTABLES_CEILING);
2873 - tlb_finish_mmu(&tlb, start, end);
2874 - }
2875 -
2876 -@@ -2685,7 +2685,7 @@ void exit_mmap(struct mm_struct *mm)
2877 - /* Use -1 here to ensure all VMAs in the mm are unmapped */
2878 - unmap_vmas(&tlb, vma, 0, -1);
2879 -
2880 -- free_pgtables(&tlb, vma, FIRST_USER_ADDRESS, 0);
2881 -+ free_pgtables(&tlb, vma, FIRST_USER_ADDRESS, USER_PGTABLES_CEILING);
2882 - tlb_finish_mmu(&tlb, 0, -1);
2883 -
2884 - /*
2885 -diff --git a/mm/page_io.c b/mm/page_io.c
2886 -index 78eee32..6182870 100644
2887 ---- a/mm/page_io.c
2888 -+++ b/mm/page_io.c
2889 -@@ -214,6 +214,7 @@ int swap_writepage(struct page *page, struct writeback_control *wbc)
2890 - kiocb.ki_left = PAGE_SIZE;
2891 - kiocb.ki_nbytes = PAGE_SIZE;
2892 -
2893 -+ set_page_writeback(page);
2894 - unlock_page(page);
2895 - ret = mapping->a_ops->direct_IO(KERNEL_WRITE,
2896 - &kiocb, &iov,
2897 -@@ -222,7 +223,23 @@ int swap_writepage(struct page *page, struct writeback_control *wbc)
2898 - if (ret == PAGE_SIZE) {
2899 - count_vm_event(PSWPOUT);
2900 - ret = 0;
2901 -+ } else {
2902 -+ /*
2903 -+ * In the case of swap-over-nfs, this can be a
2904 -+ * temporary failure if the system has limited
2905 -+ * memory for allocating transmit buffers.
2906 -+ * Mark the page dirty and avoid
2907 -+ * rotate_reclaimable_page but rate-limit the
2908 -+ * messages but do not flag PageError like
2909 -+ * the normal direct-to-bio case as it could
2910 -+ * be temporary.
2911 -+ */
2912 -+ set_page_dirty(page);
2913 -+ ClearPageReclaim(page);
2914 -+ pr_err_ratelimited("Write error on dio swapfile (%Lu)\n",
2915 -+ page_file_offset(page));
2916 - }
2917 -+ end_page_writeback(page);
2918 - return ret;
2919 - }
2920 -
2921 -diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
2922 -index a689360..843d8c4 100644
2923 ---- a/net/mac80211/cfg.c
2924 -+++ b/net/mac80211/cfg.c
2925 -@@ -1034,6 +1034,7 @@ static int ieee80211_stop_ap(struct wiphy *wiphy, struct net_device *dev)
2926 - list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list)
2927 - sta_info_flush_defer(vlan);
2928 - sta_info_flush_defer(sdata);
2929 -+ synchronize_net();
2930 - rcu_barrier();
2931 - list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list)
2932 - sta_info_flush_cleanup(vlan);
2933 -diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
2934 -index 9ed49ad..d51ca9d 100644
2935 ---- a/net/mac80211/iface.c
2936 -+++ b/net/mac80211/iface.c
2937 -@@ -844,11 +844,12 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
2938 - *
2939 - * sta_info_flush_cleanup() requires rcu_barrier()
2940 - * first to wait for the station call_rcu() calls
2941 -- * to complete, here we need at least sychronize_rcu()
2942 -- * it to wait for the RX path in case it is using the
2943 -+ * to complete, and we also need synchronize_rcu()
2944 -+ * to wait for the RX path in case it is using the
2945 - * interface and enqueuing frames at this very time on
2946 - * another CPU.
2947 - */
2948 -+ synchronize_rcu();
2949 - rcu_barrier();
2950 - sta_info_flush_cleanup(sdata);
2951 -
2952 -diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c
2953 -index d0275f3..835584c 100644
2954 ---- a/net/mac80211/pm.c
2955 -+++ b/net/mac80211/pm.c
2956 -@@ -53,8 +53,9 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
2957 - ieee80211_stop_queues_by_reason(hw,
2958 - IEEE80211_QUEUE_STOP_REASON_SUSPEND);
2959 -
2960 -- /* flush out all packets */
2961 -+ /* flush out all packets and station cleanup call_rcu()s */
2962 - synchronize_net();
2963 -+ rcu_barrier();
2964 -
2965 - drv_flush(local, false);
2966 -
2967 -diff --git a/net/wireless/reg.c b/net/wireless/reg.c
2968 -index 98532c00..6dee0ad 100644
2969 ---- a/net/wireless/reg.c
2970 -+++ b/net/wireless/reg.c
2971 -@@ -855,7 +855,7 @@ static void handle_channel(struct wiphy *wiphy,
2972 - return;
2973 -
2974 - REG_DBG_PRINT("Disabling freq %d MHz\n", chan->center_freq);
2975 -- chan->flags = IEEE80211_CHAN_DISABLED;
2976 -+ chan->flags |= IEEE80211_CHAN_DISABLED;
2977 - return;
2978 - }
2979 -
2980 -diff --git a/scripts/kconfig/streamline_config.pl b/scripts/kconfig/streamline_config.pl
2981 -index 3368939..68b85e1 100644
2982 ---- a/scripts/kconfig/streamline_config.pl
2983 -+++ b/scripts/kconfig/streamline_config.pl
2984 -@@ -156,7 +156,6 @@ sub read_kconfig {
2985 -
2986 - my $state = "NONE";
2987 - my $config;
2988 -- my @kconfigs;
2989 -
2990 - my $cont = 0;
2991 - my $line;
2992 -@@ -190,7 +189,13 @@ sub read_kconfig {
2993 -
2994 - # collect any Kconfig sources
2995 - if (/^source\s*"(.*)"/) {
2996 -- $kconfigs[$#kconfigs+1] = $1;
2997 -+ my $kconfig = $1;
2998 -+ # prevent reading twice.
2999 -+ if (!defined($read_kconfigs{$kconfig})) {
3000 -+ $read_kconfigs{$kconfig} = 1;
3001 -+ read_kconfig($kconfig);
3002 -+ }
3003 -+ next;
3004 - }
3005 -
3006 - # configs found
3007 -@@ -250,14 +255,6 @@ sub read_kconfig {
3008 - }
3009 - }
3010 - close($kinfile);
3011 --
3012 -- # read in any configs that were found.
3013 -- foreach my $kconfig (@kconfigs) {
3014 -- if (!defined($read_kconfigs{$kconfig})) {
3015 -- $read_kconfigs{$kconfig} = 1;
3016 -- read_kconfig($kconfig);
3017 -- }
3018 -- }
3019 - }
3020 -
3021 - if ($kconfig) {
3022 -diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c
3023 -index e6b0166..bdd888e 100644
3024 ---- a/sound/pci/emu10k1/emu10k1_main.c
3025 -+++ b/sound/pci/emu10k1/emu10k1_main.c
3026 -@@ -657,14 +657,14 @@ static int snd_emu10k1_cardbus_init(struct snd_emu10k1 *emu)
3027 - return 0;
3028 - }
3029 -
3030 --static int snd_emu1010_load_firmware(struct snd_emu10k1 *emu)
3031 -+static int snd_emu1010_load_firmware(struct snd_emu10k1 *emu,
3032 -+ const struct firmware *fw_entry)
3033 - {
3034 - int n, i;
3035 - int reg;
3036 - int value;
3037 - unsigned int write_post;
3038 - unsigned long flags;
3039 -- const struct firmware *fw_entry = emu->firmware;
3040 -
3041 - if (!fw_entry)
3042 - return -EIO;
3043 -@@ -725,9 +725,34 @@ static int emu1010_firmware_thread(void *data)
3044 - /* Return to Audio Dock programming mode */
3045 - snd_printk(KERN_INFO "emu1010: Loading Audio Dock Firmware\n");
3046 - snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, EMU_HANA_FPGA_CONFIG_AUDIODOCK);
3047 -- err = snd_emu1010_load_firmware(emu);
3048 -- if (err != 0)
3049 -- continue;
3050 -+
3051 -+ if (!emu->dock_fw) {
3052 -+ const char *filename = NULL;
3053 -+ switch (emu->card_capabilities->emu_model) {
3054 -+ case EMU_MODEL_EMU1010:
3055 -+ filename = DOCK_FILENAME;
3056 -+ break;
3057 -+ case EMU_MODEL_EMU1010B:
3058 -+ filename = MICRO_DOCK_FILENAME;
3059 -+ break;
3060 -+ case EMU_MODEL_EMU1616:
3061 -+ filename = MICRO_DOCK_FILENAME;
3062 -+ break;
3063 -+ }
3064 -+ if (filename) {
3065 -+ err = request_firmware(&emu->dock_fw,
3066 -+ filename,
3067 -+ &emu->pci->dev);
3068 -+ if (err)
3069 -+ continue;
3070 -+ }
3071 -+ }
3072 -+
3073 -+ if (emu->dock_fw) {
3074 -+ err = snd_emu1010_load_firmware(emu, emu->dock_fw);
3075 -+ if (err)
3076 -+ continue;
3077 -+ }
3078 -
3079 - snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, 0);
3080 - snd_emu1010_fpga_read(emu, EMU_HANA_IRQ_STATUS, &reg);
3081 -@@ -862,7 +887,7 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 *emu)
3082 - filename, emu->firmware->size);
3083 - }
3084 -
3085 -- err = snd_emu1010_load_firmware(emu);
3086 -+ err = snd_emu1010_load_firmware(emu, emu->firmware);
3087 - if (err != 0) {
3088 - snd_printk(KERN_INFO "emu1010: Loading Firmware failed\n");
3089 - return err;
3090 -@@ -1253,6 +1278,8 @@ static int snd_emu10k1_free(struct snd_emu10k1 *emu)
3091 - kthread_stop(emu->emu1010.firmware_thread);
3092 - if (emu->firmware)
3093 - release_firmware(emu->firmware);
3094 -+ if (emu->dock_fw)
3095 -+ release_firmware(emu->dock_fw);
3096 - if (emu->irq >= 0)
3097 - free_irq(emu->irq, emu);
3098 - /* remove reserved page */
3099 -diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c
3100 -index 2dbe767..d74500b 100644
3101 ---- a/sound/pci/hda/hda_generic.c
3102 -+++ b/sound/pci/hda/hda_generic.c
3103 -@@ -2072,6 +2072,14 @@ get_multiio_path(struct hda_codec *codec, int idx)
3104 -
3105 - static void update_automute_all(struct hda_codec *codec);
3106 -
3107 -+/* Default value to be passed as aamix argument for snd_hda_activate_path();
3108 -+ * used for output paths
3109 -+ */
3110 -+static bool aamix_default(struct hda_gen_spec *spec)
3111 -+{
3112 -+ return !spec->have_aamix_ctl || spec->aamix_mode;
3113 -+}
3114 -+
3115 - static int set_multi_io(struct hda_codec *codec, int idx, bool output)
3116 - {
3117 - struct hda_gen_spec *spec = codec->spec;
3118 -@@ -2087,11 +2095,11 @@ static int set_multi_io(struct hda_codec *codec, int idx, bool output)
3119 -
3120 - if (output) {
3121 - set_pin_target(codec, nid, PIN_OUT, true);
3122 -- snd_hda_activate_path(codec, path, true, true);
3123 -+ snd_hda_activate_path(codec, path, true, aamix_default(spec));
3124 - set_pin_eapd(codec, nid, true);
3125 - } else {
3126 - set_pin_eapd(codec, nid, false);
3127 -- snd_hda_activate_path(codec, path, false, true);
3128 -+ snd_hda_activate_path(codec, path, false, aamix_default(spec));
3129 - set_pin_target(codec, nid, spec->multi_io[idx].ctl_in, true);
3130 - path_power_down_sync(codec, path);
3131 - }
3132 -@@ -2182,8 +2190,8 @@ static void update_aamix_paths(struct hda_codec *codec, bool do_mix,
3133 - snd_hda_activate_path(codec, mix_path, true, true);
3134 - path_power_down_sync(codec, nomix_path);
3135 - } else {
3136 -- snd_hda_activate_path(codec, mix_path, false, true);
3137 -- snd_hda_activate_path(codec, nomix_path, true, true);
3138 -+ snd_hda_activate_path(codec, mix_path, false, false);
3139 -+ snd_hda_activate_path(codec, nomix_path, true, false);
3140 - path_power_down_sync(codec, mix_path);
3141 - }
3142 - }
3143 -@@ -4729,7 +4737,8 @@ static void set_output_and_unmute(struct hda_codec *codec, int path_idx)
3144 - return;
3145 - pin = path->path[path->depth - 1];
3146 - restore_pin_ctl(codec, pin);
3147 -- snd_hda_activate_path(codec, path, path->active, true);
3148 -+ snd_hda_activate_path(codec, path, path->active,
3149 -+ aamix_default(codec->spec));
3150 - set_pin_eapd(codec, pin, path->active);
3151 - }
3152 -
3153 -@@ -4779,7 +4788,8 @@ static void init_multi_io(struct hda_codec *codec)
3154 - if (!spec->multi_io[i].ctl_in)
3155 - spec->multi_io[i].ctl_in =
3156 - snd_hda_codec_get_pin_target(codec, pin);
3157 -- snd_hda_activate_path(codec, path, path->active, true);
3158 -+ snd_hda_activate_path(codec, path, path->active,
3159 -+ aamix_default(spec));
3160 - }
3161 - }
3162 -
3163 -diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
3164 -index f15c36b..fd1970c 100644
3165 ---- a/sound/pci/hda/patch_realtek.c
3166 -+++ b/sound/pci/hda/patch_realtek.c
3167 -@@ -2515,6 +2515,7 @@ enum {
3168 - ALC269_TYPE_ALC280,
3169 - ALC269_TYPE_ALC282,
3170 - ALC269_TYPE_ALC284,
3171 -+ ALC269_TYPE_ALC286,
3172 - };
3173 -
3174 - /*
3175 -@@ -2538,6 +2539,7 @@ static int alc269_parse_auto_config(struct hda_codec *codec)
3176 - case ALC269_TYPE_ALC269VB:
3177 - case ALC269_TYPE_ALC269VD:
3178 - case ALC269_TYPE_ALC282:
3179 -+ case ALC269_TYPE_ALC286:
3180 - ssids = alc269_ssids;
3181 - break;
3182 - default:
3183 -@@ -3172,6 +3174,9 @@ static int patch_alc269(struct hda_codec *codec)
3184 - case 0x10ec0292:
3185 - spec->codec_variant = ALC269_TYPE_ALC284;
3186 - break;
3187 -+ case 0x10ec0286:
3188 -+ spec->codec_variant = ALC269_TYPE_ALC286;
3189 -+ break;
3190 - }
3191 -
3192 - /* automatic parse from the BIOS config */
3193 -@@ -3878,6 +3883,7 @@ static const struct hda_codec_preset snd_hda_preset_realtek[] = {
3194 - { .id = 0x10ec0282, .name = "ALC282", .patch = patch_alc269 },
3195 - { .id = 0x10ec0283, .name = "ALC283", .patch = patch_alc269 },
3196 - { .id = 0x10ec0284, .name = "ALC284", .patch = patch_alc269 },
3197 -+ { .id = 0x10ec0286, .name = "ALC286", .patch = patch_alc269 },
3198 - { .id = 0x10ec0290, .name = "ALC290", .patch = patch_alc269 },
3199 - { .id = 0x10ec0292, .name = "ALC292", .patch = patch_alc269 },
3200 - { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
3201 -diff --git a/sound/soc/codecs/max98088.c b/sound/soc/codecs/max98088.c
3202 -index a4c16fd..5d36319 100644
3203 ---- a/sound/soc/codecs/max98088.c
3204 -+++ b/sound/soc/codecs/max98088.c
3205 -@@ -2006,7 +2006,7 @@ static int max98088_probe(struct snd_soc_codec *codec)
3206 - ret);
3207 - goto err_access;
3208 - }
3209 -- dev_info(codec->dev, "revision %c\n", ret + 'A');
3210 -+ dev_info(codec->dev, "revision %c\n", ret - 0x40 + 'A');
3211 -
3212 - snd_soc_write(codec, M98088_REG_51_PWR_SYS, M98088_PWRSV);
3213 -
3214 -diff --git a/sound/usb/6fire/pcm.c b/sound/usb/6fire/pcm.c
3215 -index e2ca12f..40dd50a 100644
3216 ---- a/sound/usb/6fire/pcm.c
3217 -+++ b/sound/usb/6fire/pcm.c
3218 -@@ -575,7 +575,6 @@ static void usb6fire_pcm_init_urb(struct pcm_urb *urb,
3219 - urb->instance.pipe = in ? usb_rcvisocpipe(chip->dev, ep)
3220 - : usb_sndisocpipe(chip->dev, ep);
3221 - urb->instance.interval = 1;
3222 -- urb->instance.transfer_flags = URB_ISO_ASAP;
3223 - urb->instance.complete = handler;
3224 - urb->instance.context = urb;
3225 - urb->instance.number_of_packets = PCM_N_PACKETS_PER_URB;
3226 -diff --git a/sound/usb/caiaq/audio.c b/sound/usb/caiaq/audio.c
3227 -index fde9a7a..b45e29b 100644
3228 ---- a/sound/usb/caiaq/audio.c
3229 -+++ b/sound/usb/caiaq/audio.c
3230 -@@ -670,7 +670,6 @@ static void read_completed(struct urb *urb)
3231 -
3232 - if (send_it) {
3233 - out->number_of_packets = outframe;
3234 -- out->transfer_flags = URB_ISO_ASAP;
3235 - usb_submit_urb(out, GFP_ATOMIC);
3236 - } else {
3237 - struct snd_usb_caiaq_cb_info *oinfo = out->context;
3238 -@@ -686,7 +685,6 @@ requeue:
3239 - }
3240 -
3241 - urb->number_of_packets = FRAMES_PER_URB;
3242 -- urb->transfer_flags = URB_ISO_ASAP;
3243 - usb_submit_urb(urb, GFP_ATOMIC);
3244 - }
3245 -
3246 -@@ -751,7 +749,6 @@ static struct urb **alloc_urbs(struct snd_usb_caiaqdev *dev, int dir, int *ret)
3247 - * BYTES_PER_FRAME;
3248 - urbs[i]->context = &dev->data_cb_info[i];
3249 - urbs[i]->interval = 1;
3250 -- urbs[i]->transfer_flags = URB_ISO_ASAP;
3251 - urbs[i]->number_of_packets = FRAMES_PER_URB;
3252 - urbs[i]->complete = (dir == SNDRV_PCM_STREAM_CAPTURE) ?
3253 - read_completed : write_completed;
3254 -diff --git a/sound/usb/card.c b/sound/usb/card.c
3255 -index 2da8ad7..b79b7dc 100644
3256 ---- a/sound/usb/card.c
3257 -+++ b/sound/usb/card.c
3258 -@@ -627,7 +627,9 @@ int snd_usb_autoresume(struct snd_usb_audio *chip)
3259 - int err = -ENODEV;
3260 -
3261 - down_read(&chip->shutdown_rwsem);
3262 -- if (!chip->shutdown && !chip->probing)
3263 -+ if (chip->probing)
3264 -+ err = 0;
3265 -+ else if (!chip->shutdown)
3266 - err = usb_autopm_get_interface(chip->pm_intf);
3267 - up_read(&chip->shutdown_rwsem);
3268 -
3269 -diff --git a/sound/usb/card.h b/sound/usb/card.h
3270 -index 8a751b4..d32ea41 100644
3271 ---- a/sound/usb/card.h
3272 -+++ b/sound/usb/card.h
3273 -@@ -116,6 +116,7 @@ struct snd_usb_substream {
3274 - unsigned int altset_idx; /* USB data format: index of alternate setting */
3275 - unsigned int txfr_quirk:1; /* allow sub-frame alignment */
3276 - unsigned int fmt_type; /* USB audio format type (1-3) */
3277 -+ unsigned int pkt_offset_adj; /* Bytes to drop from beginning of packets (for non-compliant devices) */
3278 -
3279 - unsigned int running: 1; /* running status */
3280 -
3281 -diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c
3282 -index 21049b8..63cca3a 100644
3283 ---- a/sound/usb/endpoint.c
3284 -+++ b/sound/usb/endpoint.c
3285 -@@ -677,7 +677,7 @@ static int data_ep_set_params(struct snd_usb_endpoint *ep,
3286 - if (!u->urb->transfer_buffer)
3287 - goto out_of_memory;
3288 - u->urb->pipe = ep->pipe;
3289 -- u->urb->transfer_flags = URB_ISO_ASAP | URB_NO_TRANSFER_DMA_MAP;
3290 -+ u->urb->transfer_flags = URB_NO_TRANSFER_DMA_MAP;
3291 - u->urb->interval = 1 << ep->datainterval;
3292 - u->urb->context = u;
3293 - u->urb->complete = snd_complete_urb;
3294 -@@ -716,8 +716,7 @@ static int sync_ep_set_params(struct snd_usb_endpoint *ep,
3295 - u->urb->transfer_dma = ep->sync_dma + i * 4;
3296 - u->urb->transfer_buffer_length = 4;
3297 - u->urb->pipe = ep->pipe;
3298 -- u->urb->transfer_flags = URB_ISO_ASAP |
3299 -- URB_NO_TRANSFER_DMA_MAP;
3300 -+ u->urb->transfer_flags = URB_NO_TRANSFER_DMA_MAP;
3301 - u->urb->number_of_packets = 1;
3302 - u->urb->interval = 1 << ep->syncinterval;
3303 - u->urb->context = u;
3304 -diff --git a/sound/usb/midi.c b/sound/usb/midi.c
3305 -index 34b9bb7..e5fee18 100644
3306 ---- a/sound/usb/midi.c
3307 -+++ b/sound/usb/midi.c
3308 -@@ -126,7 +126,6 @@ struct snd_usb_midi {
3309 - struct snd_usb_midi_in_endpoint *in;
3310 - } endpoints[MIDI_MAX_ENDPOINTS];
3311 - unsigned long input_triggered;
3312 -- bool autopm_reference;
3313 - unsigned int opened[2];
3314 - unsigned char disconnected;
3315 - unsigned char input_running;
3316 -@@ -1040,7 +1039,6 @@ static int substream_open(struct snd_rawmidi_substream *substream, int dir,
3317 - {
3318 - struct snd_usb_midi* umidi = substream->rmidi->private_data;
3319 - struct snd_kcontrol *ctl;
3320 -- int err;
3321 -
3322 - down_read(&umidi->disc_rwsem);
3323 - if (umidi->disconnected) {
3324 -@@ -1051,13 +1049,6 @@ static int substream_open(struct snd_rawmidi_substream *substream, int dir,
3325 - mutex_lock(&umidi->mutex);
3326 - if (open) {
3327 - if (!umidi->opened[0] && !umidi->opened[1]) {
3328 -- err = usb_autopm_get_interface(umidi->iface);
3329 -- umidi->autopm_reference = err >= 0;
3330 -- if (err < 0 && err != -EACCES) {
3331 -- mutex_unlock(&umidi->mutex);
3332 -- up_read(&umidi->disc_rwsem);
3333 -- return -EIO;
3334 -- }
3335 - if (umidi->roland_load_ctl) {
3336 - ctl = umidi->roland_load_ctl;
3337 - ctl->vd[0].access |= SNDRV_CTL_ELEM_ACCESS_INACTIVE;
3338 -@@ -1080,8 +1071,6 @@ static int substream_open(struct snd_rawmidi_substream *substream, int dir,
3339 - snd_ctl_notify(umidi->card,
3340 - SNDRV_CTL_EVENT_MASK_INFO, &ctl->id);
3341 - }
3342 -- if (umidi->autopm_reference)
3343 -- usb_autopm_put_interface(umidi->iface);
3344 - }
3345 - }
3346 - mutex_unlock(&umidi->mutex);
3347 -@@ -2256,6 +2245,8 @@ int snd_usbmidi_create(struct snd_card *card,
3348 - return err;
3349 - }
3350 -
3351 -+ usb_autopm_get_interface_no_resume(umidi->iface);
3352 -+
3353 - list_add_tail(&umidi->list, midi_list);
3354 - return 0;
3355 - }
3356 -diff --git a/sound/usb/misc/ua101.c b/sound/usb/misc/ua101.c
3357 -index 8b81cb5..6ad617b 100644
3358 ---- a/sound/usb/misc/ua101.c
3359 -+++ b/sound/usb/misc/ua101.c
3360 -@@ -1120,8 +1120,7 @@ static int alloc_stream_urbs(struct ua101 *ua, struct ua101_stream *stream,
3361 - usb_init_urb(&urb->urb);
3362 - urb->urb.dev = ua->dev;
3363 - urb->urb.pipe = stream->usb_pipe;
3364 -- urb->urb.transfer_flags = URB_ISO_ASAP |
3365 -- URB_NO_TRANSFER_DMA_MAP;
3366 -+ urb->urb.transfer_flags = URB_NO_TRANSFER_DMA_MAP;
3367 - urb->urb.transfer_buffer = addr;
3368 - urb->urb.transfer_dma = dma;
3369 - urb->urb.transfer_buffer_length = max_packet_size;
3370 -diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c
3371 -index f94397b..a481fea 100644
3372 ---- a/sound/usb/pcm.c
3373 -+++ b/sound/usb/pcm.c
3374 -@@ -1170,7 +1170,7 @@ static void retire_capture_urb(struct snd_usb_substream *subs,
3375 - stride = runtime->frame_bits >> 3;
3376 -
3377 - for (i = 0; i < urb->number_of_packets; i++) {
3378 -- cp = (unsigned char *)urb->transfer_buffer + urb->iso_frame_desc[i].offset;
3379 -+ cp = (unsigned char *)urb->transfer_buffer + urb->iso_frame_desc[i].offset + subs->pkt_offset_adj;
3380 - if (urb->iso_frame_desc[i].status && printk_ratelimit()) {
3381 - snd_printdd(KERN_ERR "frame %d active: %d\n", i, urb->iso_frame_desc[i].status);
3382 - // continue;
3383 -diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c
3384 -index 9c5ab22..0c7eb49 100644
3385 ---- a/sound/usb/quirks.c
3386 -+++ b/sound/usb/quirks.c
3387 -@@ -837,6 +837,7 @@ static void set_format_emu_quirk(struct snd_usb_substream *subs,
3388 - break;
3389 - }
3390 - snd_emuusb_set_samplerate(subs->stream->chip, emu_samplerate_id);
3391 -+ subs->pkt_offset_adj = (emu_samplerate_id >= EMU_QUIRK_SR_176400HZ) ? 4 : 0;
3392 - }
3393 -
3394 - void snd_usb_set_format_quirk(struct snd_usb_substream *subs,
3395 -diff --git a/sound/usb/stream.c b/sound/usb/stream.c
3396 -index ad181d5..cfc4d4e 100644
3397 ---- a/sound/usb/stream.c
3398 -+++ b/sound/usb/stream.c
3399 -@@ -94,6 +94,7 @@ static void snd_usb_init_substream(struct snd_usb_stream *as,
3400 - subs->dev = as->chip->dev;
3401 - subs->txfr_quirk = as->chip->txfr_quirk;
3402 - subs->speed = snd_usb_get_speed(subs->dev);
3403 -+ subs->pkt_offset_adj = 0;
3404 -
3405 - snd_usb_set_pcm_ops(as->pcm, stream);
3406 -
3407 -@@ -396,6 +397,14 @@ static int parse_uac_endpoint_attributes(struct snd_usb_audio *chip,
3408 - if (!csep && altsd->bNumEndpoints >= 2)
3409 - csep = snd_usb_find_desc(alts->endpoint[1].extra, alts->endpoint[1].extralen, NULL, USB_DT_CS_ENDPOINT);
3410 -
3411 -+ /*
3412 -+ * If we can't locate the USB_DT_CS_ENDPOINT descriptor in the extra
3413 -+ * bytes after the first endpoint, go search the entire interface.
3414 -+ * Some devices have it directly *before* the standard endpoint.
3415 -+ */
3416 -+ if (!csep)
3417 -+ csep = snd_usb_find_desc(alts->extra, alts->extralen, NULL, USB_DT_CS_ENDPOINT);
3418 -+
3419 - if (!csep || csep->bLength < 7 ||
3420 - csep->bDescriptorSubtype != UAC_EP_GENERAL) {
3421 - snd_printk(KERN_WARNING "%d:%u:%d : no or invalid"
3422 -diff --git a/sound/usb/usx2y/usb_stream.c b/sound/usb/usx2y/usb_stream.c
3423 -index 1e7a47a..bf618e1 100644
3424 ---- a/sound/usb/usx2y/usb_stream.c
3425 -+++ b/sound/usb/usx2y/usb_stream.c
3426 -@@ -69,7 +69,6 @@ static void init_pipe_urbs(struct usb_stream_kernel *sk, unsigned use_packsize,
3427 - ++u, transfer += transfer_length) {
3428 - struct urb *urb = urbs[u];
3429 - struct usb_iso_packet_descriptor *desc;
3430 -- urb->transfer_flags = URB_ISO_ASAP;
3431 - urb->transfer_buffer = transfer;
3432 - urb->dev = dev;
3433 - urb->pipe = pipe;
3434 -diff --git a/sound/usb/usx2y/usbusx2yaudio.c b/sound/usb/usx2y/usbusx2yaudio.c
3435 -index 520ef96..b376532 100644
3436 ---- a/sound/usb/usx2y/usbusx2yaudio.c
3437 -+++ b/sound/usb/usx2y/usbusx2yaudio.c
3438 -@@ -503,7 +503,6 @@ static int usX2Y_urbs_start(struct snd_usX2Y_substream *subs)
3439 - if (0 == i)
3440 - atomic_set(&subs->state, state_STARTING3);
3441 - urb->dev = usX2Y->dev;
3442 -- urb->transfer_flags = URB_ISO_ASAP;
3443 - for (pack = 0; pack < nr_of_packs(); pack++) {
3444 - urb->iso_frame_desc[pack].offset = subs->maxpacksize * pack;
3445 - urb->iso_frame_desc[pack].length = subs->maxpacksize;
3446 -diff --git a/sound/usb/usx2y/usx2yhwdeppcm.c b/sound/usb/usx2y/usx2yhwdeppcm.c
3447 -index cc56007..f2a1acd 100644
3448 ---- a/sound/usb/usx2y/usx2yhwdeppcm.c
3449 -+++ b/sound/usb/usx2y/usx2yhwdeppcm.c
3450 -@@ -443,7 +443,6 @@ static int usX2Y_usbpcm_urbs_start(struct snd_usX2Y_substream *subs)
3451 - if (0 == u)
3452 - atomic_set(&subs->state, state_STARTING3);
3453 - urb->dev = usX2Y->dev;
3454 -- urb->transfer_flags = URB_ISO_ASAP;
3455 - for (pack = 0; pack < nr_of_packs(); pack++) {
3456 - urb->iso_frame_desc[pack].offset = subs->maxpacksize * (pack + u * nr_of_packs());
3457 - urb->iso_frame_desc[pack].length = subs->maxpacksize;
3458
3459 Deleted: genpatches-2.6/trunk/3.10/1001_linux-3.9.2.patch
3460 ===================================================================
3461 --- genpatches-2.6/trunk/3.10/1001_linux-3.9.2.patch 2013-05-21 00:40:11 UTC (rev 2385)
3462 +++ genpatches-2.6/trunk/3.10/1001_linux-3.9.2.patch 2013-05-21 00:44:32 UTC (rev 2386)
3463 @@ -1,2950 +0,0 @@
3464 -diff --git a/Makefile b/Makefile
3465 -index 5fcb591..3e71511 100644
3466 ---- a/Makefile
3467 -+++ b/Makefile
3468 -@@ -1,6 +1,6 @@
3469 - VERSION = 3
3470 - PATCHLEVEL = 9
3471 --SUBLEVEL = 1
3472 -+SUBLEVEL = 2
3473 - EXTRAVERSION =
3474 - NAME = Unicycling Gorilla
3475 -
3476 -diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
3477 -index 8dc0605..99ce189 100644
3478 ---- a/arch/arm/xen/enlighten.c
3479 -+++ b/arch/arm/xen/enlighten.c
3480 -@@ -239,7 +239,7 @@ static int __init xen_init_events(void)
3481 - xen_init_IRQ();
3482 -
3483 - if (request_percpu_irq(xen_events_irq, xen_arm_callback,
3484 -- "events", xen_vcpu)) {
3485 -+ "events", &xen_vcpu)) {
3486 - pr_err("Error requesting IRQ %d\n", xen_events_irq);
3487 - return -EINVAL;
3488 - }
3489 -diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c
3490 -index afadae6..0782eaf 100644
3491 ---- a/arch/arm64/mm/fault.c
3492 -+++ b/arch/arm64/mm/fault.c
3493 -@@ -148,6 +148,7 @@ void do_bad_area(unsigned long addr, unsigned int esr, struct pt_regs *regs)
3494 - #define VM_FAULT_BADACCESS 0x020000
3495 -
3496 - #define ESR_WRITE (1 << 6)
3497 -+#define ESR_CM (1 << 8)
3498 - #define ESR_LNX_EXEC (1 << 24)
3499 -
3500 - /*
3501 -@@ -206,7 +207,7 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
3502 - struct task_struct *tsk;
3503 - struct mm_struct *mm;
3504 - int fault, sig, code;
3505 -- int write = esr & ESR_WRITE;
3506 -+ bool write = (esr & ESR_WRITE) && !(esr & ESR_CM);
3507 - unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE |
3508 - (write ? FAULT_FLAG_WRITE : 0);
3509 -
3510 -diff --git a/arch/powerpc/include/asm/ppc-opcode.h b/arch/powerpc/include/asm/ppc-opcode.h
3511 -index 8752bc8..8cbc6e5 100644
3512 ---- a/arch/powerpc/include/asm/ppc-opcode.h
3513 -+++ b/arch/powerpc/include/asm/ppc-opcode.h
3514 -@@ -113,6 +113,10 @@
3515 - #define PPC_INST_MFSPR_DSCR_MASK 0xfc1fffff
3516 - #define PPC_INST_MTSPR_DSCR 0x7c1103a6
3517 - #define PPC_INST_MTSPR_DSCR_MASK 0xfc1fffff
3518 -+#define PPC_INST_MFSPR_DSCR_USER 0x7c0302a6
3519 -+#define PPC_INST_MFSPR_DSCR_USER_MASK 0xfc1fffff
3520 -+#define PPC_INST_MTSPR_DSCR_USER 0x7c0303a6
3521 -+#define PPC_INST_MTSPR_DSCR_USER_MASK 0xfc1fffff
3522 - #define PPC_INST_SLBFEE 0x7c0007a7
3523 -
3524 - #define PPC_INST_STRING 0x7c00042a
3525 -diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
3526 -index 37cc40e..83efa2f 100644
3527 ---- a/arch/powerpc/kernel/traps.c
3528 -+++ b/arch/powerpc/kernel/traps.c
3529 -@@ -970,7 +970,10 @@ static int emulate_instruction(struct pt_regs *regs)
3530 -
3531 - #ifdef CONFIG_PPC64
3532 - /* Emulate the mfspr rD, DSCR. */
3533 -- if (((instword & PPC_INST_MFSPR_DSCR_MASK) == PPC_INST_MFSPR_DSCR) &&
3534 -+ if ((((instword & PPC_INST_MFSPR_DSCR_USER_MASK) ==
3535 -+ PPC_INST_MFSPR_DSCR_USER) ||
3536 -+ ((instword & PPC_INST_MFSPR_DSCR_MASK) ==
3537 -+ PPC_INST_MFSPR_DSCR)) &&
3538 - cpu_has_feature(CPU_FTR_DSCR)) {
3539 - PPC_WARN_EMULATED(mfdscr, regs);
3540 - rd = (instword >> 21) & 0x1f;
3541 -@@ -978,7 +981,10 @@ static int emulate_instruction(struct pt_regs *regs)
3542 - return 0;
3543 - }
3544 - /* Emulate the mtspr DSCR, rD. */
3545 -- if (((instword & PPC_INST_MTSPR_DSCR_MASK) == PPC_INST_MTSPR_DSCR) &&
3546 -+ if ((((instword & PPC_INST_MTSPR_DSCR_USER_MASK) ==
3547 -+ PPC_INST_MTSPR_DSCR_USER) ||
3548 -+ ((instword & PPC_INST_MTSPR_DSCR_MASK) ==
3549 -+ PPC_INST_MTSPR_DSCR)) &&
3550 - cpu_has_feature(CPU_FTR_DSCR)) {
3551 - PPC_WARN_EMULATED(mtdscr, regs);
3552 - rd = (instword >> 21) & 0x1f;
3553 -diff --git a/arch/powerpc/mm/hash_utils_64.c b/arch/powerpc/mm/hash_utils_64.c
3554 -index f410c3e..b75c52f 100644
3555 ---- a/arch/powerpc/mm/hash_utils_64.c
3556 -+++ b/arch/powerpc/mm/hash_utils_64.c
3557 -@@ -1191,6 +1191,7 @@ void flush_hash_page(unsigned long vpn, real_pte_t pte, int psize, int ssize,
3558 - * unmapping it first, it may see the speculated version.
3559 - */
3560 - if (local && cpu_has_feature(CPU_FTR_TM) &&
3561 -+ current->thread.regs &&
3562 - MSR_TM_ACTIVE(current->thread.regs->msr)) {
3563 - tm_enable();
3564 - tm_abort(TM_CAUSE_TLBI);
3565 -diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
3566 -index bba87ca..6a252c4 100644
3567 ---- a/arch/powerpc/mm/numa.c
3568 -+++ b/arch/powerpc/mm/numa.c
3569 -@@ -201,7 +201,7 @@ int __node_distance(int a, int b)
3570 - int distance = LOCAL_DISTANCE;
3571 -
3572 - if (!form1_affinity)
3573 -- return distance;
3574 -+ return ((a == b) ? LOCAL_DISTANCE : REMOTE_DISTANCE);
3575 -
3576 - for (i = 0; i < distance_ref_points_depth; i++) {
3577 - if (distance_lookup_table[a][i] == distance_lookup_table[b][i])
3578 -diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
3579 -index cc45deb..4a0a462 100644
3580 ---- a/arch/x86/kernel/cpu/perf_event_intel.c
3581 -+++ b/arch/x86/kernel/cpu/perf_event_intel.c
3582 -@@ -125,10 +125,15 @@ static struct event_constraint intel_ivb_event_constraints[] __read_mostly =
3583 - INTEL_UEVENT_CONSTRAINT(0x08a3, 0x4), /* CYCLE_ACTIVITY.CYCLES_L1D_PENDING */
3584 - INTEL_UEVENT_CONSTRAINT(0x0ca3, 0x4), /* CYCLE_ACTIVITY.STALLS_L1D_PENDING */
3585 - INTEL_UEVENT_CONSTRAINT(0x01c0, 0x2), /* INST_RETIRED.PREC_DIST */
3586 -- INTEL_EVENT_CONSTRAINT(0xd0, 0xf), /* MEM_UOPS_RETIRED.* */
3587 -- INTEL_EVENT_CONSTRAINT(0xd1, 0xf), /* MEM_LOAD_UOPS_RETIRED.* */
3588 -- INTEL_EVENT_CONSTRAINT(0xd2, 0xf), /* MEM_LOAD_UOPS_LLC_HIT_RETIRED.* */
3589 -- INTEL_EVENT_CONSTRAINT(0xd3, 0xf), /* MEM_LOAD_UOPS_LLC_MISS_RETIRED.* */
3590 -+ /*
3591 -+ * Errata BV98 -- MEM_*_RETIRED events can leak between counters of SMT
3592 -+ * siblings; disable these events because they can corrupt unrelated
3593 -+ * counters.
3594 -+ */
3595 -+ INTEL_EVENT_CONSTRAINT(0xd0, 0x0), /* MEM_UOPS_RETIRED.* */
3596 -+ INTEL_EVENT_CONSTRAINT(0xd1, 0x0), /* MEM_LOAD_UOPS_RETIRED.* */
3597 -+ INTEL_EVENT_CONSTRAINT(0xd2, 0x0), /* MEM_LOAD_UOPS_LLC_HIT_RETIRED.* */
3598 -+ INTEL_EVENT_CONSTRAINT(0xd3, 0x0), /* MEM_LOAD_UOPS_LLC_MISS_RETIRED.* */
3599 - EVENT_CONSTRAINT_END
3600 - };
3601 -
3602 -diff --git a/arch/x86/kernel/cpu/perf_event_intel_lbr.c b/arch/x86/kernel/cpu/perf_event_intel_lbr.c
3603 -index da02e9c..d978353 100644
3604 ---- a/arch/x86/kernel/cpu/perf_event_intel_lbr.c
3605 -+++ b/arch/x86/kernel/cpu/perf_event_intel_lbr.c
3606 -@@ -310,7 +310,7 @@ void intel_pmu_lbr_read(void)
3607 - * - in case there is no HW filter
3608 - * - in case the HW filter has errata or limitations
3609 - */
3610 --static void intel_pmu_setup_sw_lbr_filter(struct perf_event *event)
3611 -+static int intel_pmu_setup_sw_lbr_filter(struct perf_event *event)
3612 - {
3613 - u64 br_type = event->attr.branch_sample_type;
3614 - int mask = 0;
3615 -@@ -318,8 +318,11 @@ static void intel_pmu_setup_sw_lbr_filter(struct perf_event *event)
3616 - if (br_type & PERF_SAMPLE_BRANCH_USER)
3617 - mask |= X86_BR_USER;
3618 -
3619 -- if (br_type & PERF_SAMPLE_BRANCH_KERNEL)
3620 -+ if (br_type & PERF_SAMPLE_BRANCH_KERNEL) {
3621 -+ if (perf_paranoid_kernel() && !capable(CAP_SYS_ADMIN))
3622 -+ return -EACCES;
3623 - mask |= X86_BR_KERNEL;
3624 -+ }
3625 -
3626 - /* we ignore BRANCH_HV here */
3627 -
3628 -@@ -339,6 +342,8 @@ static void intel_pmu_setup_sw_lbr_filter(struct perf_event *event)
3629 - * be used by fixup code for some CPU
3630 - */
3631 - event->hw.branch_reg.reg = mask;
3632 -+
3633 -+ return 0;
3634 - }
3635 -
3636 - /*
3637 -@@ -386,7 +391,9 @@ int intel_pmu_setup_lbr_filter(struct perf_event *event)
3638 - /*
3639 - * setup SW LBR filter
3640 - */
3641 -- intel_pmu_setup_sw_lbr_filter(event);
3642 -+ ret = intel_pmu_setup_sw_lbr_filter(event);
3643 -+ if (ret)
3644 -+ return ret;
3645 -
3646 - /*
3647 - * setup HW LBR filter, if any
3648 -@@ -442,8 +449,18 @@ static int branch_type(unsigned long from, unsigned long to)
3649 - return X86_BR_NONE;
3650 -
3651 - addr = buf;
3652 -- } else
3653 -- addr = (void *)from;
3654 -+ } else {
3655 -+ /*
3656 -+ * The LBR logs any address in the IP, even if the IP just
3657 -+ * faulted. This means userspace can control the from address.
3658 -+ * Ensure we don't blindy read any address by validating it is
3659 -+ * a known text address.
3660 -+ */
3661 -+ if (kernel_text_address(from))
3662 -+ addr = (void *)from;
3663 -+ else
3664 -+ return X86_BR_NONE;
3665 -+ }
3666 -
3667 - /*
3668 - * decoder needs to know the ABI especially
3669 -diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
3670 -index b43200d..3e091f0 100644
3671 ---- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
3672 -+++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
3673 -@@ -2428,7 +2428,7 @@ static void __init uncore_types_exit(struct intel_uncore_type **types)
3674 - static int __init uncore_type_init(struct intel_uncore_type *type)
3675 - {
3676 - struct intel_uncore_pmu *pmus;
3677 -- struct attribute_group *events_group;
3678 -+ struct attribute_group *attr_group;
3679 - struct attribute **attrs;
3680 - int i, j;
3681 -
3682 -@@ -2455,19 +2455,19 @@ static int __init uncore_type_init(struct intel_uncore_type *type)
3683 - while (type->event_descs[i].attr.attr.name)
3684 - i++;
3685 -
3686 -- events_group = kzalloc(sizeof(struct attribute *) * (i + 1) +
3687 -- sizeof(*events_group), GFP_KERNEL);
3688 -- if (!events_group)
3689 -+ attr_group = kzalloc(sizeof(struct attribute *) * (i + 1) +
3690 -+ sizeof(*attr_group), GFP_KERNEL);
3691 -+ if (!attr_group)
3692 - goto fail;
3693 -
3694 -- attrs = (struct attribute **)(events_group + 1);
3695 -- events_group->name = "events";
3696 -- events_group->attrs = attrs;
3697 -+ attrs = (struct attribute **)(attr_group + 1);
3698 -+ attr_group->name = "events";
3699 -+ attr_group->attrs = attrs;
3700 -
3701 - for (j = 0; j < i; j++)
3702 - attrs[j] = &type->event_descs[j].attr.attr;
3703 -
3704 -- type->events_group = events_group;
3705 -+ type->events_group = attr_group;
3706 - }
3707 -
3708 - type->pmu_group = &uncore_pmu_attr_group;
3709 -@@ -2853,6 +2853,7 @@ static int __init uncore_cpu_init(void)
3710 - msr_uncores = nhm_msr_uncores;
3711 - break;
3712 - case 42: /* Sandy Bridge */
3713 -+ case 58: /* Ivy Bridge */
3714 - if (snb_uncore_cbox.num_boxes > max_cores)
3715 - snb_uncore_cbox.num_boxes = max_cores;
3716 - msr_uncores = snb_msr_uncores;
3717 -diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
3718 -index b2b9837..e8918ff 100644
3719 ---- a/block/blk-cgroup.c
3720 -+++ b/block/blk-cgroup.c
3721 -@@ -972,10 +972,10 @@ int blkcg_activate_policy(struct request_queue *q,
3722 - if (!new_blkg)
3723 - return -ENOMEM;
3724 -
3725 -- preloaded = !radix_tree_preload(GFP_KERNEL);
3726 --
3727 - blk_queue_bypass_start(q);
3728 -
3729 -+ preloaded = !radix_tree_preload(GFP_KERNEL);
3730 -+
3731 - /*
3732 - * Make sure the root blkg exists and count the existing blkgs. As
3733 - * @q is bypassing at this point, blkg_lookup_create() can't be
3734 -diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
3735 -index 5899a76..769d92e 100644
3736 ---- a/drivers/edac/edac_mc_sysfs.c
3737 -+++ b/drivers/edac/edac_mc_sysfs.c
3738 -@@ -327,17 +327,17 @@ static struct device_attribute *dynamic_csrow_dimm_attr[] = {
3739 - };
3740 -
3741 - /* possible dynamic channel ce_count attribute files */
3742 --DEVICE_CHANNEL(ch0_ce_count, S_IRUGO | S_IWUSR,
3743 -+DEVICE_CHANNEL(ch0_ce_count, S_IRUGO,
3744 - channel_ce_count_show, NULL, 0);
3745 --DEVICE_CHANNEL(ch1_ce_count, S_IRUGO | S_IWUSR,
3746 -+DEVICE_CHANNEL(ch1_ce_count, S_IRUGO,
3747 - channel_ce_count_show, NULL, 1);
3748 --DEVICE_CHANNEL(ch2_ce_count, S_IRUGO | S_IWUSR,
3749 -+DEVICE_CHANNEL(ch2_ce_count, S_IRUGO,
3750 - channel_ce_count_show, NULL, 2);
3751 --DEVICE_CHANNEL(ch3_ce_count, S_IRUGO | S_IWUSR,
3752 -+DEVICE_CHANNEL(ch3_ce_count, S_IRUGO,
3753 - channel_ce_count_show, NULL, 3);
3754 --DEVICE_CHANNEL(ch4_ce_count, S_IRUGO | S_IWUSR,
3755 -+DEVICE_CHANNEL(ch4_ce_count, S_IRUGO,
3756 - channel_ce_count_show, NULL, 4);
3757 --DEVICE_CHANNEL(ch5_ce_count, S_IRUGO | S_IWUSR,
3758 -+DEVICE_CHANNEL(ch5_ce_count, S_IRUGO,
3759 - channel_ce_count_show, NULL, 5);
3760 -
3761 - /* Total possible dynamic ce_count attribute file table */
3762 -diff --git a/drivers/gpu/drm/ast/ast_drv.h b/drivers/gpu/drm/ast/ast_drv.h
3763 -index 5284292..02e52d5 100644
3764 ---- a/drivers/gpu/drm/ast/ast_drv.h
3765 -+++ b/drivers/gpu/drm/ast/ast_drv.h
3766 -@@ -241,6 +241,8 @@ struct ast_fbdev {
3767 - void *sysram;
3768 - int size;
3769 - struct ttm_bo_kmap_obj mapping;
3770 -+ int x1, y1, x2, y2; /* dirty rect */
3771 -+ spinlock_t dirty_lock;
3772 - };
3773 -
3774 - #define to_ast_crtc(x) container_of(x, struct ast_crtc, base)
3775 -diff --git a/drivers/gpu/drm/ast/ast_fb.c b/drivers/gpu/drm/ast/ast_fb.c
3776 -index 34931fe..fbc0823 100644
3777 ---- a/drivers/gpu/drm/ast/ast_fb.c
3778 -+++ b/drivers/gpu/drm/ast/ast_fb.c
3779 -@@ -53,16 +53,52 @@ static void ast_dirty_update(struct ast_fbdev *afbdev,
3780 - int bpp = (afbdev->afb.base.bits_per_pixel + 7)/8;
3781 - int ret;
3782 - bool unmap = false;
3783 -+ bool store_for_later = false;
3784 -+ int x2, y2;
3785 -+ unsigned long flags;
3786 -
3787 - obj = afbdev->afb.obj;
3788 - bo = gem_to_ast_bo(obj);
3789 -
3790 -+ /*
3791 -+ * try and reserve the BO, if we fail with busy
3792 -+ * then the BO is being moved and we should
3793 -+ * store up the damage until later.
3794 -+ */
3795 - ret = ast_bo_reserve(bo, true);
3796 - if (ret) {
3797 -- DRM_ERROR("failed to reserve fb bo\n");
3798 -+ if (ret != -EBUSY)
3799 -+ return;
3800 -+
3801 -+ store_for_later = true;
3802 -+ }
3803 -+
3804 -+ x2 = x + width - 1;
3805 -+ y2 = y + height - 1;
3806 -+ spin_lock_irqsave(&afbdev->dirty_lock, flags);
3807 -+
3808 -+ if (afbdev->y1 < y)
3809 -+ y = afbdev->y1;
3810 -+ if (afbdev->y2 > y2)
3811 -+ y2 = afbdev->y2;
3812 -+ if (afbdev->x1 < x)
3813 -+ x = afbdev->x1;
3814 -+ if (afbdev->x2 > x2)
3815 -+ x2 = afbdev->x2;
3816 -+
3817 -+ if (store_for_later) {
3818 -+ afbdev->x1 = x;
3819 -+ afbdev->x2 = x2;
3820 -+ afbdev->y1 = y;
3821 -+ afbdev->y2 = y2;
3822 -+ spin_unlock_irqrestore(&afbdev->dirty_lock, flags);
3823 - return;
3824 - }
3825 -
3826 -+ afbdev->x1 = afbdev->y1 = INT_MAX;
3827 -+ afbdev->x2 = afbdev->y2 = 0;
3828 -+ spin_unlock_irqrestore(&afbdev->dirty_lock, flags);
3829 -+
3830 - if (!bo->kmap.virtual) {
3831 - ret = ttm_bo_kmap(&bo->bo, 0, bo->bo.num_pages, &bo->kmap);
3832 - if (ret) {
3833 -@@ -72,10 +108,10 @@ static void ast_dirty_update(struct ast_fbdev *afbdev,
3834 - }
3835 - unmap = true;
3836 - }
3837 -- for (i = y; i < y + height; i++) {
3838 -+ for (i = y; i <= y2; i++) {
3839 - /* assume equal stride for now */
3840 - src_offset = dst_offset = i * afbdev->afb.base.pitches[0] + (x * bpp);
3841 -- memcpy_toio(bo->kmap.virtual + src_offset, afbdev->sysram + src_offset, width * bpp);
3842 -+ memcpy_toio(bo->kmap.virtual + src_offset, afbdev->sysram + src_offset, (x2 - x + 1) * bpp);
3843 -
3844 - }
3845 - if (unmap)
3846 -@@ -292,6 +328,7 @@ int ast_fbdev_init(struct drm_device *dev)
3847 -
3848 - ast->fbdev = afbdev;
3849 - afbdev->helper.funcs = &ast_fb_helper_funcs;
3850 -+ spin_lock_init(&afbdev->dirty_lock);
3851 - ret = drm_fb_helper_init(dev, &afbdev->helper,
3852 - 1, 1);
3853 - if (ret) {
3854 -diff --git a/drivers/gpu/drm/ast/ast_ttm.c b/drivers/gpu/drm/ast/ast_ttm.c
3855 -index 3602731..09da339 100644
3856 ---- a/drivers/gpu/drm/ast/ast_ttm.c
3857 -+++ b/drivers/gpu/drm/ast/ast_ttm.c
3858 -@@ -316,7 +316,7 @@ int ast_bo_reserve(struct ast_bo *bo, bool no_wait)
3859 -
3860 - ret = ttm_bo_reserve(&bo->bo, true, no_wait, false, 0);
3861 - if (ret) {
3862 -- if (ret != -ERESTARTSYS)
3863 -+ if (ret != -ERESTARTSYS && ret != -EBUSY)
3864 - DRM_ERROR("reserve failed %p\n", bo);
3865 - return ret;
3866 - }
3867 -diff --git a/drivers/gpu/drm/cirrus/cirrus_drv.h b/drivers/gpu/drm/cirrus/cirrus_drv.h
3868 -index 6e0cc72..7ca0595 100644
3869 ---- a/drivers/gpu/drm/cirrus/cirrus_drv.h
3870 -+++ b/drivers/gpu/drm/cirrus/cirrus_drv.h
3871 -@@ -154,6 +154,8 @@ struct cirrus_fbdev {
3872 - struct list_head fbdev_list;
3873 - void *sysram;
3874 - int size;
3875 -+ int x1, y1, x2, y2; /* dirty rect */
3876 -+ spinlock_t dirty_lock;
3877 - };
3878 -
3879 - struct cirrus_bo {
3880 -diff --git a/drivers/gpu/drm/cirrus/cirrus_fbdev.c b/drivers/gpu/drm/cirrus/cirrus_fbdev.c
3881 -index e25afcc..3541b56 100644
3882 ---- a/drivers/gpu/drm/cirrus/cirrus_fbdev.c
3883 -+++ b/drivers/gpu/drm/cirrus/cirrus_fbdev.c
3884 -@@ -27,16 +27,51 @@ static void cirrus_dirty_update(struct cirrus_fbdev *afbdev,
3885 - int bpp = (afbdev->gfb.base.bits_per_pixel + 7)/8;
3886 - int ret;
3887 - bool unmap = false;
3888 -+ bool store_for_later = false;
3889 -+ int x2, y2;
3890 -+ unsigned long flags;
3891 -
3892 - obj = afbdev->gfb.obj;
3893 - bo = gem_to_cirrus_bo(obj);
3894 -
3895 -+ /*
3896 -+ * try and reserve the BO, if we fail with busy
3897 -+ * then the BO is being moved and we should
3898 -+ * store up the damage until later.
3899 -+ */
3900 - ret = cirrus_bo_reserve(bo, true);
3901 - if (ret) {
3902 -- DRM_ERROR("failed to reserve fb bo\n");
3903 -+ if (ret != -EBUSY)
3904 -+ return;
3905 -+ store_for_later = true;
3906 -+ }
3907 -+
3908 -+ x2 = x + width - 1;
3909 -+ y2 = y + height - 1;
3910 -+ spin_lock_irqsave(&afbdev->dirty_lock, flags);
3911 -+
3912 -+ if (afbdev->y1 < y)
3913 -+ y = afbdev->y1;
3914 -+ if (afbdev->y2 > y2)
3915 -+ y2 = afbdev->y2;
3916 -+ if (afbdev->x1 < x)
3917 -+ x = afbdev->x1;
3918 -+ if (afbdev->x2 > x2)
3919 -+ x2 = afbdev->x2;
3920 -+
3921 -+ if (store_for_later) {
3922 -+ afbdev->x1 = x;
3923 -+ afbdev->x2 = x2;
3924 -+ afbdev->y1 = y;
3925 -+ afbdev->y2 = y2;
3926 -+ spin_unlock_irqrestore(&afbdev->dirty_lock, flags);
3927 - return;
3928 - }
3929 -
3930 -+ afbdev->x1 = afbdev->y1 = INT_MAX;
3931 -+ afbdev->x2 = afbdev->y2 = 0;
3932 -+ spin_unlock_irqrestore(&afbdev->dirty_lock, flags);
3933 -+
3934 - if (!bo->kmap.virtual) {
3935 - ret = ttm_bo_kmap(&bo->bo, 0, bo->bo.num_pages, &bo->kmap);
3936 - if (ret) {
3937 -@@ -268,6 +303,7 @@ int cirrus_fbdev_init(struct cirrus_device *cdev)
3938 -
3939 - cdev->mode_info.gfbdev = gfbdev;
3940 - gfbdev->helper.funcs = &cirrus_fb_helper_funcs;
3941 -+ spin_lock_init(&gfbdev->dirty_lock);
3942 -
3943 - ret = drm_fb_helper_init(cdev->dev, &gfbdev->helper,
3944 - cdev->num_crtc, CIRRUSFB_CONN_LIMIT);
3945 -diff --git a/drivers/gpu/drm/cirrus/cirrus_ttm.c b/drivers/gpu/drm/cirrus/cirrus_ttm.c
3946 -index 1413a26..2ed8cfc 100644
3947 ---- a/drivers/gpu/drm/cirrus/cirrus_ttm.c
3948 -+++ b/drivers/gpu/drm/cirrus/cirrus_ttm.c
3949 -@@ -321,7 +321,7 @@ int cirrus_bo_reserve(struct cirrus_bo *bo, bool no_wait)
3950 -
3951 - ret = ttm_bo_reserve(&bo->bo, true, no_wait, false, 0);
3952 - if (ret) {
3953 -- if (ret != -ERESTARTSYS)
3954 -+ if (ret != -ERESTARTSYS && ret != -EBUSY)
3955 - DRM_ERROR("reserve failed %p\n", bo);
3956 - return ret;
3957 - }
3958 -diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
3959 -index af779ae..cf919e3 100644
3960 ---- a/drivers/gpu/drm/drm_gem.c
3961 -+++ b/drivers/gpu/drm/drm_gem.c
3962 -@@ -205,11 +205,11 @@ static void
3963 - drm_gem_remove_prime_handles(struct drm_gem_object *obj, struct drm_file *filp)
3964 - {
3965 - if (obj->import_attach) {
3966 -- drm_prime_remove_imported_buf_handle(&filp->prime,
3967 -+ drm_prime_remove_buf_handle(&filp->prime,
3968 - obj->import_attach->dmabuf);
3969 - }
3970 - if (obj->export_dma_buf) {
3971 -- drm_prime_remove_imported_buf_handle(&filp->prime,
3972 -+ drm_prime_remove_buf_handle(&filp->prime,
3973 - obj->export_dma_buf);
3974 - }
3975 - }
3976 -diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c
3977 -index 366910d..db767ca 100644
3978 ---- a/drivers/gpu/drm/drm_prime.c
3979 -+++ b/drivers/gpu/drm/drm_prime.c
3980 -@@ -62,6 +62,7 @@ struct drm_prime_member {
3981 - struct dma_buf *dma_buf;
3982 - uint32_t handle;
3983 - };
3984 -+static int drm_prime_add_buf_handle(struct drm_prime_file_private *prime_fpriv, struct dma_buf *dma_buf, uint32_t handle);
3985 -
3986 - static struct sg_table *drm_gem_map_dma_buf(struct dma_buf_attachment *attach,
3987 - enum dma_data_direction dir)
3988 -@@ -200,7 +201,8 @@ int drm_gem_prime_handle_to_fd(struct drm_device *dev,
3989 - {
3990 - struct drm_gem_object *obj;
3991 - void *buf;
3992 -- int ret;
3993 -+ int ret = 0;
3994 -+ struct dma_buf *dmabuf;
3995 -
3996 - obj = drm_gem_object_lookup(dev, file_priv, handle);
3997 - if (!obj)
3998 -@@ -209,43 +211,44 @@ int drm_gem_prime_handle_to_fd(struct drm_device *dev,
3999 - mutex_lock(&file_priv->prime.lock);
4000 - /* re-export the original imported object */
4001 - if (obj->import_attach) {
4002 -- get_dma_buf(obj->import_attach->dmabuf);
4003 -- *prime_fd = dma_buf_fd(obj->import_attach->dmabuf, flags);
4004 -- drm_gem_object_unreference_unlocked(obj);
4005 -- mutex_unlock(&file_priv->prime.lock);
4006 -- return 0;
4007 -+ dmabuf = obj->import_attach->dmabuf;
4008 -+ goto out_have_obj;
4009 - }
4010 -
4011 - if (obj->export_dma_buf) {
4012 -- get_dma_buf(obj->export_dma_buf);
4013 -- *prime_fd = dma_buf_fd(obj->export_dma_buf, flags);
4014 -- drm_gem_object_unreference_unlocked(obj);
4015 -- } else {
4016 -- buf = dev->driver->gem_prime_export(dev, obj, flags);
4017 -- if (IS_ERR(buf)) {
4018 -- /* normally the created dma-buf takes ownership of the ref,
4019 -- * but if that fails then drop the ref
4020 -- */
4021 -- drm_gem_object_unreference_unlocked(obj);
4022 -- mutex_unlock(&file_priv->prime.lock);
4023 -- return PTR_ERR(buf);
4024 -- }
4025 -- obj->export_dma_buf = buf;
4026 -- *prime_fd = dma_buf_fd(buf, flags);
4027 -+ dmabuf = obj->export_dma_buf;
4028 -+ goto out_have_obj;
4029 - }
4030 -+
4031 -+ buf = dev->driver->gem_prime_export(dev, obj, flags);
4032 -+ if (IS_ERR(buf)) {
4033 -+ /* normally the created dma-buf takes ownership of the ref,
4034 -+ * but if that fails then drop the ref
4035 -+ */
4036 -+ ret = PTR_ERR(buf);
4037 -+ goto out;
4038 -+ }
4039 -+ obj->export_dma_buf = buf;
4040 -+
4041 - /* if we've exported this buffer the cheat and add it to the import list
4042 - * so we get the correct handle back
4043 - */
4044 -- ret = drm_prime_add_imported_buf_handle(&file_priv->prime,
4045 -- obj->export_dma_buf, handle);
4046 -- if (ret) {
4047 -- drm_gem_object_unreference_unlocked(obj);
4048 -- mutex_unlock(&file_priv->prime.lock);
4049 -- return ret;
4050 -- }
4051 -+ ret = drm_prime_add_buf_handle(&file_priv->prime,
4052 -+ obj->export_dma_buf, handle);
4053 -+ if (ret)
4054 -+ goto out;
4055 -
4056 -+ *prime_fd = dma_buf_fd(buf, flags);
4057 - mutex_unlock(&file_priv->prime.lock);
4058 - return 0;
4059 -+
4060 -+out_have_obj:
4061 -+ get_dma_buf(dmabuf);
4062 -+ *prime_fd = dma_buf_fd(dmabuf, flags);
4063 -+out:
4064 -+ drm_gem_object_unreference_unlocked(obj);
4065 -+ mutex_unlock(&file_priv->prime.lock);
4066 -+ return ret;
4067 - }
4068 - EXPORT_SYMBOL(drm_gem_prime_handle_to_fd);
4069 -
4070 -@@ -268,7 +271,6 @@ struct drm_gem_object *drm_gem_prime_import(struct drm_device *dev,
4071 - * refcount on gem itself instead of f_count of dmabuf.
4072 - */
4073 - drm_gem_object_reference(obj);
4074 -- dma_buf_put(dma_buf);
4075 - return obj;
4076 - }
4077 - }
4078 -@@ -277,6 +279,8 @@ struct drm_gem_object *drm_gem_prime_import(struct drm_device *dev,
4079 - if (IS_ERR(attach))
4080 - return ERR_PTR(PTR_ERR(attach));
4081 -
4082 -+ get_dma_buf(dma_buf);
4083 -+
4084 - sgt = dma_buf_map_attachment(attach, DMA_BIDIRECTIONAL);
4085 - if (IS_ERR_OR_NULL(sgt)) {
4086 - ret = PTR_ERR(sgt);
4087 -@@ -297,6 +301,8 @@ fail_unmap:
4088 - dma_buf_unmap_attachment(attach, sgt, DMA_BIDIRECTIONAL);
4089 - fail_detach:
4090 - dma_buf_detach(dma_buf, attach);
4091 -+ dma_buf_put(dma_buf);
4092 -+
4093 - return ERR_PTR(ret);
4094 - }
4095 - EXPORT_SYMBOL(drm_gem_prime_import);
4096 -@@ -314,7 +320,7 @@ int drm_gem_prime_fd_to_handle(struct drm_device *dev,
4097 -
4098 - mutex_lock(&file_priv->prime.lock);
4099 -
4100 -- ret = drm_prime_lookup_imported_buf_handle(&file_priv->prime,
4101 -+ ret = drm_prime_lookup_buf_handle(&file_priv->prime,
4102 - dma_buf, handle);
4103 - if (!ret) {
4104 - ret = 0;
4105 -@@ -333,12 +339,15 @@ int drm_gem_prime_fd_to_handle(struct drm_device *dev,
4106 - if (ret)
4107 - goto out_put;
4108 -
4109 -- ret = drm_prime_add_imported_buf_handle(&file_priv->prime,
4110 -+ ret = drm_prime_add_buf_handle(&file_priv->prime,
4111 - dma_buf, *handle);
4112 - if (ret)
4113 - goto fail;
4114 -
4115 - mutex_unlock(&file_priv->prime.lock);
4116 -+
4117 -+ dma_buf_put(dma_buf);
4118 -+
4119 - return 0;
4120 -
4121 - fail:
4122 -@@ -491,7 +500,7 @@ void drm_prime_destroy_file_private(struct drm_prime_file_private *prime_fpriv)
4123 - }
4124 - EXPORT_SYMBOL(drm_prime_destroy_file_private);
4125 -
4126 --int drm_prime_add_imported_buf_handle(struct drm_prime_file_private *prime_fpriv, struct dma_buf *dma_buf, uint32_t handle)
4127 -+static int drm_prime_add_buf_handle(struct drm_prime_file_private *prime_fpriv, struct dma_buf *dma_buf, uint32_t handle)
4128 - {
4129 - struct drm_prime_member *member;
4130 -
4131 -@@ -499,14 +508,14 @@ int drm_prime_add_imported_buf_handle(struct drm_prime_file_private *prime_fpriv
4132 - if (!member)
4133 - return -ENOMEM;
4134 -
4135 -+ get_dma_buf(dma_buf);
4136 - member->dma_buf = dma_buf;
4137 - member->handle = handle;
4138 - list_add(&member->entry, &prime_fpriv->head);
4139 - return 0;
4140 - }
4141 --EXPORT_SYMBOL(drm_prime_add_imported_buf_handle);
4142 -
4143 --int drm_prime_lookup_imported_buf_handle(struct drm_prime_file_private *prime_fpriv, struct dma_buf *dma_buf, uint32_t *handle)
4144 -+int drm_prime_lookup_buf_handle(struct drm_prime_file_private *prime_fpriv, struct dma_buf *dma_buf, uint32_t *handle)
4145 - {
4146 - struct drm_prime_member *member;
4147 -
4148 -@@ -518,19 +527,20 @@ int drm_prime_lookup_imported_buf_handle(struct drm_prime_file_private *prime_fp
4149 - }
4150 - return -ENOENT;
4151 - }
4152 --EXPORT_SYMBOL(drm_prime_lookup_imported_buf_handle);
4153 -+EXPORT_SYMBOL(drm_prime_lookup_buf_handle);
4154 -
4155 --void drm_prime_remove_imported_buf_handle(struct drm_prime_file_private *prime_fpriv, struct dma_buf *dma_buf)
4156 -+void drm_prime_remove_buf_handle(struct drm_prime_file_private *prime_fpriv, struct dma_buf *dma_buf)
4157 - {
4158 - struct drm_prime_member *member, *safe;
4159 -
4160 - mutex_lock(&prime_fpriv->lock);
4161 - list_for_each_entry_safe(member, safe, &prime_fpriv->head, entry) {
4162 - if (member->dma_buf == dma_buf) {
4163 -+ dma_buf_put(dma_buf);
4164 - list_del(&member->entry);
4165 - kfree(member);
4166 - }
4167 - }
4168 - mutex_unlock(&prime_fpriv->lock);
4169 - }
4170 --EXPORT_SYMBOL(drm_prime_remove_imported_buf_handle);
4171 -+EXPORT_SYMBOL(drm_prime_remove_buf_handle);
4172 -diff --git a/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c b/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c
4173 -index ba0a3aa..ff7f2a8 100644
4174 ---- a/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c
4175 -+++ b/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c
4176 -@@ -235,7 +235,6 @@ struct drm_gem_object *exynos_dmabuf_prime_import(struct drm_device *drm_dev,
4177 - * refcount on gem itself instead of f_count of dmabuf.
4178 - */
4179 - drm_gem_object_reference(obj);
4180 -- dma_buf_put(dma_buf);
4181 - return obj;
4182 - }
4183 - }
4184 -@@ -244,6 +243,7 @@ struct drm_gem_object *exynos_dmabuf_prime_import(struct drm_device *drm_dev,
4185 - if (IS_ERR(attach))
4186 - return ERR_PTR(-EINVAL);
4187 -
4188 -+ get_dma_buf(dma_buf);
4189 -
4190 - sgt = dma_buf_map_attachment(attach, DMA_BIDIRECTIONAL);
4191 - if (IS_ERR_OR_NULL(sgt)) {
4192 -@@ -298,6 +298,8 @@ err_unmap_attach:
4193 - dma_buf_unmap_attachment(attach, sgt, DMA_BIDIRECTIONAL);
4194 - err_buf_detach:
4195 - dma_buf_detach(dma_buf, attach);
4196 -+ dma_buf_put(dma_buf);
4197 -+
4198 - return ERR_PTR(ret);
4199 - }
4200 -
4201 -diff --git a/drivers/gpu/drm/gma500/psb_irq.c b/drivers/gpu/drm/gma500/psb_irq.c
4202 -index 8652cdf..029eccf 100644
4203 ---- a/drivers/gpu/drm/gma500/psb_irq.c
4204 -+++ b/drivers/gpu/drm/gma500/psb_irq.c
4205 -@@ -211,7 +211,7 @@ irqreturn_t psb_irq_handler(DRM_IRQ_ARGS)
4206 -
4207 - vdc_stat = PSB_RVDC32(PSB_INT_IDENTITY_R);
4208 -
4209 -- if (vdc_stat & _PSB_PIPE_EVENT_FLAG)
4210 -+ if (vdc_stat & (_PSB_PIPE_EVENT_FLAG|_PSB_IRQ_ASLE))
4211 - dsp_int = 1;
4212 -
4213 - /* FIXME: Handle Medfield
4214 -diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
4215 -index 01769e2..ef99b1c 100644
4216 ---- a/drivers/gpu/drm/i915/i915_drv.h
4217 -+++ b/drivers/gpu/drm/i915/i915_drv.h
4218 -@@ -941,6 +941,7 @@ typedef struct drm_i915_private {
4219 - unsigned int int_crt_support:1;
4220 - unsigned int lvds_use_ssc:1;
4221 - unsigned int display_clock_mode:1;
4222 -+ unsigned int fdi_rx_polarity_inverted:1;
4223 - int lvds_ssc_freq;
4224 - unsigned int bios_lvds_val; /* initial [PCH_]LVDS reg val in VBIOS */
4225 - struct {
4226 -diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
4227 -index 0e207e6..73cb479 100644
4228 ---- a/drivers/gpu/drm/i915/i915_gem.c
4229 -+++ b/drivers/gpu/drm/i915/i915_gem.c
4230 -@@ -2678,17 +2678,35 @@ static inline int fence_number(struct drm_i915_private *dev_priv,
4231 - return fence - dev_priv->fence_regs;
4232 - }
4233 -
4234 -+static void i915_gem_write_fence__ipi(void *data)
4235 -+{
4236 -+ wbinvd();
4237 -+}
4238 -+
4239 - static void i915_gem_object_update_fence(struct drm_i915_gem_object *obj,
4240 - struct drm_i915_fence_reg *fence,
4241 - bool enable)
4242 - {
4243 -- struct drm_i915_private *dev_priv = obj->base.dev->dev_private;
4244 -- int reg = fence_number(dev_priv, fence);
4245 --
4246 -- i915_gem_write_fence(obj->base.dev, reg, enable ? obj : NULL);
4247 -+ struct drm_device *dev = obj->base.dev;
4248 -+ struct drm_i915_private *dev_priv = dev->dev_private;
4249 -+ int fence_reg = fence_number(dev_priv, fence);
4250 -+
4251 -+ /* In order to fully serialize access to the fenced region and
4252 -+ * the update to the fence register we need to take extreme
4253 -+ * measures on SNB+. In theory, the write to the fence register
4254 -+ * flushes all memory transactions before, and coupled with the
4255 -+ * mb() placed around the register write we serialise all memory
4256 -+ * operations with respect to the changes in the tiler. Yet, on
4257 -+ * SNB+ we need to take a step further and emit an explicit wbinvd()
4258 -+ * on each processor in order to manually flush all memory
4259 -+ * transactions before updating the fence register.
4260 -+ */
4261 -+ if (HAS_LLC(obj->base.dev))
4262 -+ on_each_cpu(i915_gem_write_fence__ipi, NULL, 1);
4263 -+ i915_gem_write_fence(dev, fence_reg, enable ? obj : NULL);
4264 -
4265 - if (enable) {
4266 -- obj->fence_reg = reg;
4267 -+ obj->fence_reg = fence_reg;
4268 - fence->obj = obj;
4269 - list_move_tail(&fence->lru_list, &dev_priv->mm.fence_list);
4270 - } else {
4271 -diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c
4272 -index 94d873a..a1e8ecb 100644
4273 ---- a/drivers/gpu/drm/i915/i915_gem_context.c
4274 -+++ b/drivers/gpu/drm/i915/i915_gem_context.c
4275 -@@ -152,6 +152,13 @@ create_hw_context(struct drm_device *dev,
4276 - return ERR_PTR(-ENOMEM);
4277 - }
4278 -
4279 -+ if (INTEL_INFO(dev)->gen >= 7) {
4280 -+ ret = i915_gem_object_set_cache_level(ctx->obj,
4281 -+ I915_CACHE_LLC_MLC);
4282 -+ if (ret)
4283 -+ goto err_out;
4284 -+ }
4285 -+
4286 - /* The ring associated with the context object is handled by the normal
4287 - * object tracking code. We give an initial ring value simple to pass an
4288 - * assertion in the context switch code.
4289 -diff --git a/drivers/gpu/drm/i915/i915_gem_dmabuf.c b/drivers/gpu/drm/i915/i915_gem_dmabuf.c
4290 -index 6a5af68..c303de1 100644
4291 ---- a/drivers/gpu/drm/i915/i915_gem_dmabuf.c
4292 -+++ b/drivers/gpu/drm/i915/i915_gem_dmabuf.c
4293 -@@ -271,7 +271,6 @@ struct drm_gem_object *i915_gem_prime_import(struct drm_device *dev,
4294 - * refcount on gem itself instead of f_count of dmabuf.
4295 - */
4296 - drm_gem_object_reference(&obj->base);
4297 -- dma_buf_put(dma_buf);
4298 - return &obj->base;
4299 - }
4300 - }
4301 -@@ -281,6 +280,8 @@ struct drm_gem_object *i915_gem_prime_import(struct drm_device *dev,
4302 - if (IS_ERR(attach))
4303 - return ERR_CAST(attach);
4304 -
4305 -+ get_dma_buf(dma_buf);
4306 -+
4307 - obj = i915_gem_object_alloc(dev);
4308 - if (obj == NULL) {
4309 - ret = -ENOMEM;
4310 -@@ -300,5 +301,7 @@ struct drm_gem_object *i915_gem_prime_import(struct drm_device *dev,
4311 -
4312 - fail_detach:
4313 - dma_buf_detach(dma_buf, attach);
4314 -+ dma_buf_put(dma_buf);
4315 -+
4316 - return ERR_PTR(ret);
4317 - }
4318 -diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
4319 -index 926a1e2..193c8d1 100644
4320 ---- a/drivers/gpu/drm/i915/i915_gem_gtt.c
4321 -+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
4322 -@@ -182,8 +182,7 @@ static int gen6_ppgtt_init(struct i915_hw_ppgtt *ppgtt)
4323 - /* ppgtt PDEs reside in the global gtt pagetable, which has 512*1024
4324 - * entries. For aliasing ppgtt support we just steal them at the end for
4325 - * now. */
4326 -- first_pd_entry_in_global_pt =
4327 -- gtt_total_entries(dev_priv->gtt) - I915_PPGTT_PD_ENTRIES;
4328 -+ first_pd_entry_in_global_pt = gtt_total_entries(dev_priv->gtt);
4329 -
4330 - ppgtt->num_pd_entries = I915_PPGTT_PD_ENTRIES;
4331 - ppgtt->clear_range = gen6_ppgtt_clear_range;
4332 -diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
4333 -index 848992f..c91124f 100644
4334 ---- a/drivers/gpu/drm/i915/i915_reg.h
4335 -+++ b/drivers/gpu/drm/i915/i915_reg.h
4336 -@@ -3827,7 +3827,7 @@
4337 - #define _TRANSB_CHICKEN2 0xf1064
4338 - #define TRANS_CHICKEN2(pipe) _PIPE(pipe, _TRANSA_CHICKEN2, _TRANSB_CHICKEN2)
4339 - #define TRANS_CHICKEN2_TIMING_OVERRIDE (1<<31)
4340 --
4341 -+#define TRANS_CHICKEN2_FDI_POLARITY_REVERSED (1<<29)
4342 -
4343 - #define SOUTH_CHICKEN1 0xc2000
4344 - #define FDIA_PHASE_SYNC_SHIFT_OVR 19
4345 -diff --git a/drivers/gpu/drm/i915/intel_bios.c b/drivers/gpu/drm/i915/intel_bios.c
4346 -index 55ffba1..bd83391 100644
4347 ---- a/drivers/gpu/drm/i915/intel_bios.c
4348 -+++ b/drivers/gpu/drm/i915/intel_bios.c
4349 -@@ -351,12 +351,14 @@ parse_general_features(struct drm_i915_private *dev_priv,
4350 - dev_priv->lvds_ssc_freq =
4351 - intel_bios_ssc_frequency(dev, general->ssc_freq);
4352 - dev_priv->display_clock_mode = general->display_clock_mode;
4353 -- DRM_DEBUG_KMS("BDB_GENERAL_FEATURES int_tv_support %d int_crt_support %d lvds_use_ssc %d lvds_ssc_freq %d display_clock_mode %d\n",
4354 -+ dev_priv->fdi_rx_polarity_inverted = general->fdi_rx_polarity_inverted;
4355 -+ DRM_DEBUG_KMS("BDB_GENERAL_FEATURES int_tv_support %d int_crt_support %d lvds_use_ssc %d lvds_ssc_freq %d display_clock_mode %d fdi_rx_polarity_inverted %d\n",
4356 - dev_priv->int_tv_support,
4357 - dev_priv->int_crt_support,
4358 - dev_priv->lvds_use_ssc,
4359 - dev_priv->lvds_ssc_freq,
4360 -- dev_priv->display_clock_mode);
4361 -+ dev_priv->display_clock_mode,
4362 -+ dev_priv->fdi_rx_polarity_inverted);
4363 - }
4364 - }
4365 -
4366 -diff --git a/drivers/gpu/drm/i915/intel_bios.h b/drivers/gpu/drm/i915/intel_bios.h
4367 -index 36e57f9..e088d6f 100644
4368 ---- a/drivers/gpu/drm/i915/intel_bios.h
4369 -+++ b/drivers/gpu/drm/i915/intel_bios.h
4370 -@@ -127,7 +127,9 @@ struct bdb_general_features {
4371 - /* bits 3 */
4372 - u8 disable_smooth_vision:1;
4373 - u8 single_dvi:1;
4374 -- u8 rsvd9:6; /* finish byte */
4375 -+ u8 rsvd9:1;
4376 -+ u8 fdi_rx_polarity_inverted:1;
4377 -+ u8 rsvd10:4; /* finish byte */
4378 -
4379 - /* bits 4 */
4380 - u8 legacy_monitor_detect;
4381 -diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
4382 -index b20d501..c2d173a 100644
4383 ---- a/drivers/gpu/drm/i915/intel_display.c
4384 -+++ b/drivers/gpu/drm/i915/intel_display.c
4385 -@@ -7589,22 +7589,25 @@ intel_modeset_affected_pipes(struct drm_crtc *crtc, unsigned *modeset_pipes,
4386 - if (crtc->enabled)
4387 - *prepare_pipes |= 1 << intel_crtc->pipe;
4388 -
4389 -- /* We only support modeset on one single crtc, hence we need to do that
4390 -- * only for the passed in crtc iff we change anything else than just
4391 -- * disable crtcs.
4392 -- *
4393 -- * This is actually not true, to be fully compatible with the old crtc
4394 -- * helper we automatically disable _any_ output (i.e. doesn't need to be
4395 -- * connected to the crtc we're modesetting on) if it's disconnected.
4396 -- * Which is a rather nutty api (since changed the output configuration
4397 -- * without userspace's explicit request can lead to confusion), but
4398 -- * alas. Hence we currently need to modeset on all pipes we prepare. */
4399 -+ /*
4400 -+ * For simplicity do a full modeset on any pipe where the output routing
4401 -+ * changed. We could be more clever, but that would require us to be
4402 -+ * more careful with calling the relevant encoder->mode_set functions.
4403 -+ */
4404 - if (*prepare_pipes)
4405 - *modeset_pipes = *prepare_pipes;
4406 -
4407 - /* ... and mask these out. */
4408 - *modeset_pipes &= ~(*disable_pipes);
4409 - *prepare_pipes &= ~(*disable_pipes);
4410 -+
4411 -+ /*
4412 -+ * HACK: We don't (yet) fully support global modesets. intel_set_config
4413 -+ * obies this rule, but the modeset restore mode of
4414 -+ * intel_modeset_setup_hw_state does not.
4415 -+ */
4416 -+ *modeset_pipes &= 1 << intel_crtc->pipe;
4417 -+ *prepare_pipes &= 1 << intel_crtc->pipe;
4418 - }
4419 -
4420 - static bool intel_crtc_in_use(struct drm_crtc *crtc)
4421 -@@ -7771,9 +7774,9 @@ intel_modeset_check_state(struct drm_device *dev)
4422 - }
4423 - }
4424 -
4425 --int intel_set_mode(struct drm_crtc *crtc,
4426 -- struct drm_display_mode *mode,
4427 -- int x, int y, struct drm_framebuffer *fb)
4428 -+static int __intel_set_mode(struct drm_crtc *crtc,
4429 -+ struct drm_display_mode *mode,
4430 -+ int x, int y, struct drm_framebuffer *fb)
4431 - {
4432 - struct drm_device *dev = crtc->dev;
4433 - drm_i915_private_t *dev_priv = dev->dev_private;
4434 -@@ -7863,8 +7866,6 @@ done:
4435 - if (ret && crtc->enabled) {
4436 - crtc->hwmode = *saved_hwmode;
4437 - crtc->mode = *saved_mode;
4438 -- } else {
4439 -- intel_modeset_check_state(dev);
4440 - }
4441 -
4442 - out:
4443 -@@ -7872,6 +7873,20 @@ out:
4444 - return ret;
4445 - }
4446 -
4447 -+int intel_set_mode(struct drm_crtc *crtc,
4448 -+ struct drm_display_mode *mode,
4449 -+ int x, int y, struct drm_framebuffer *fb)
4450 -+{
4451 -+ int ret;
4452 -+
4453 -+ ret = __intel_set_mode(crtc, mode, x, y, fb);
4454 -+
4455 -+ if (ret == 0)
4456 -+ intel_modeset_check_state(crtc->dev);
4457 -+
4458 -+ return ret;
4459 -+}
4460 -+
4461 - void intel_crtc_restore_mode(struct drm_crtc *crtc)
4462 - {
4463 - intel_set_mode(crtc, &crtc->mode, crtc->x, crtc->y, crtc->fb);
4464 -@@ -8314,7 +8329,7 @@ static void intel_setup_outputs(struct drm_device *dev)
4465 - I915_WRITE(PFIT_CONTROL, 0);
4466 - }
4467 -
4468 -- if (!(HAS_DDI(dev) && (I915_READ(DDI_BUF_CTL(PORT_A)) & DDI_A_4_LANES)))
4469 -+ if (!IS_ULT(dev))
4470 - intel_crt_init(dev);
4471 -
4472 - if (HAS_DDI(dev)) {
4473 -@@ -9172,8 +9187,16 @@ void intel_modeset_setup_hw_state(struct drm_device *dev,
4474 - }
4475 -
4476 - if (force_restore) {
4477 -+ /*
4478 -+ * We need to use raw interfaces for restoring state to avoid
4479 -+ * checking (bogus) intermediate states.
4480 -+ */
4481 - for_each_pipe(pipe) {
4482 -- intel_crtc_restore_mode(dev_priv->pipe_to_crtc_mapping[pipe]);
4483 -+ struct drm_crtc *crtc =
4484 -+ dev_priv->pipe_to_crtc_mapping[pipe];
4485 -+
4486 -+ __intel_set_mode(crtc, &crtc->mode, crtc->x, crtc->y,
4487 -+ crtc->fb);
4488 - }
4489 -
4490 - i915_redisable_vga(dev);
4491 -@@ -9236,6 +9259,9 @@ void intel_modeset_cleanup(struct drm_device *dev)
4492 - /* flush any delayed tasks or pending work */
4493 - flush_scheduled_work();
4494 -
4495 -+ /* destroy backlight, if any, before the connectors */
4496 -+ intel_panel_destroy_backlight(dev);
4497 -+
4498 - drm_mode_config_cleanup(dev);
4499 -
4500 - intel_cleanup_overlay(dev);
4501 -diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
4502 -index 8fc93f9..b8e17e5 100644
4503 ---- a/drivers/gpu/drm/i915/intel_dp.c
4504 -+++ b/drivers/gpu/drm/i915/intel_dp.c
4505 -@@ -2538,17 +2538,14 @@ done:
4506 - static void
4507 - intel_dp_destroy(struct drm_connector *connector)
4508 - {
4509 -- struct drm_device *dev = connector->dev;
4510 - struct intel_dp *intel_dp = intel_attached_dp(connector);
4511 - struct intel_connector *intel_connector = to_intel_connector(connector);
4512 -
4513 - if (!IS_ERR_OR_NULL(intel_connector->edid))
4514 - kfree(intel_connector->edid);
4515 -
4516 -- if (is_edp(intel_dp)) {
4517 -- intel_panel_destroy_backlight(dev);
4518 -+ if (is_edp(intel_dp))
4519 - intel_panel_fini(&intel_connector->panel);
4520 -- }
4521 -
4522 - drm_sysfs_connector_remove(connector);
4523 - drm_connector_cleanup(connector);
4524 -diff --git a/drivers/gpu/drm/i915/intel_dvo.c b/drivers/gpu/drm/i915/intel_dvo.c
4525 -index 00e70db..cc70b16 100644
4526 ---- a/drivers/gpu/drm/i915/intel_dvo.c
4527 -+++ b/drivers/gpu/drm/i915/intel_dvo.c
4528 -@@ -448,6 +448,7 @@ void intel_dvo_init(struct drm_device *dev)
4529 - const struct intel_dvo_device *dvo = &intel_dvo_devices[i];
4530 - struct i2c_adapter *i2c;
4531 - int gpio;
4532 -+ bool dvoinit;
4533 -
4534 - /* Allow the I2C driver info to specify the GPIO to be used in
4535 - * special cases, but otherwise default to what's defined
4536 -@@ -467,7 +468,17 @@ void intel_dvo_init(struct drm_device *dev)
4537 - i2c = intel_gmbus_get_adapter(dev_priv, gpio);
4538 -
4539 - intel_dvo->dev = *dvo;
4540 -- if (!dvo->dev_ops->init(&intel_dvo->dev, i2c))
4541 -+
4542 -+ /* GMBUS NAK handling seems to be unstable, hence let the
4543 -+ * transmitter detection run in bit banging mode for now.
4544 -+ */
4545 -+ intel_gmbus_force_bit(i2c, true);
4546 -+
4547 -+ dvoinit = dvo->dev_ops->init(&intel_dvo->dev, i2c);
4548 -+
4549 -+ intel_gmbus_force_bit(i2c, false);
4550 -+
4551 -+ if (!dvoinit)
4552 - continue;
4553 -
4554 - intel_encoder->type = INTEL_OUTPUT_DVO;
4555 -diff --git a/drivers/gpu/drm/i915/intel_lvds.c b/drivers/gpu/drm/i915/intel_lvds.c
4556 -index 3d1d974..e0d6985 100644
4557 ---- a/drivers/gpu/drm/i915/intel_lvds.c
4558 -+++ b/drivers/gpu/drm/i915/intel_lvds.c
4559 -@@ -618,7 +618,6 @@ static void intel_lvds_destroy(struct drm_connector *connector)
4560 - if (!IS_ERR_OR_NULL(lvds_connector->base.edid))
4561 - kfree(lvds_connector->base.edid);
4562 -
4563 -- intel_panel_destroy_backlight(connector->dev);
4564 - intel_panel_fini(&lvds_connector->base.panel);
4565 -
4566 - drm_sysfs_connector_remove(connector);
4567 -@@ -850,6 +849,14 @@ static const struct dmi_system_id intel_no_lvds[] = {
4568 - DMI_MATCH(DMI_PRODUCT_NAME, "X7SPA-H"),
4569 - },
4570 - },
4571 -+ {
4572 -+ .callback = intel_no_lvds_dmi_callback,
4573 -+ .ident = "Fujitsu Esprimo Q900",
4574 -+ .matches = {
4575 -+ DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
4576 -+ DMI_MATCH(DMI_PRODUCT_NAME, "ESPRIMO Q900"),
4577 -+ },
4578 -+ },
4579 -
4580 - { } /* terminating entry */
4581 - };
4582 -diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c
4583 -index bee8cb6..94d895b 100644
4584 ---- a/drivers/gpu/drm/i915/intel_panel.c
4585 -+++ b/drivers/gpu/drm/i915/intel_panel.c
4586 -@@ -422,6 +422,9 @@ int intel_panel_setup_backlight(struct drm_connector *connector)
4587 -
4588 - intel_panel_init_backlight(dev);
4589 -
4590 -+ if (WARN_ON(dev_priv->backlight))
4591 -+ return -ENODEV;
4592 -+
4593 - memset(&props, 0, sizeof(props));
4594 - props.type = BACKLIGHT_RAW;
4595 - props.max_brightness = _intel_panel_get_max_backlight(dev);
4596 -@@ -447,8 +450,10 @@ int intel_panel_setup_backlight(struct drm_connector *connector)
4597 - void intel_panel_destroy_backlight(struct drm_device *dev)
4598 - {
4599 - struct drm_i915_private *dev_priv = dev->dev_private;
4600 -- if (dev_priv->backlight)
4601 -+ if (dev_priv->backlight) {
4602 - backlight_device_unregister(dev_priv->backlight);
4603 -+ dev_priv->backlight = NULL;
4604 -+ }
4605 - }
4606 - #else
4607 - int intel_panel_setup_backlight(struct drm_connector *connector)
4608 -diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
4609 -index adca007..332b29e 100644
4610 ---- a/drivers/gpu/drm/i915/intel_pm.c
4611 -+++ b/drivers/gpu/drm/i915/intel_pm.c
4612 -@@ -3562,6 +3562,7 @@ static void cpt_init_clock_gating(struct drm_device *dev)
4613 - {
4614 - struct drm_i915_private *dev_priv = dev->dev_private;
4615 - int pipe;
4616 -+ uint32_t val;
4617 -
4618 - /*
4619 - * On Ibex Peak and Cougar Point, we need to disable clock
4620 -@@ -3574,8 +3575,12 @@ static void cpt_init_clock_gating(struct drm_device *dev)
4621 - /* The below fixes the weird display corruption, a few pixels shifted
4622 - * downward, on (only) LVDS of some HP laptops with IVY.
4623 - */
4624 -- for_each_pipe(pipe)
4625 -- I915_WRITE(TRANS_CHICKEN2(pipe), TRANS_CHICKEN2_TIMING_OVERRIDE);
4626 -+ for_each_pipe(pipe) {
4627 -+ val = TRANS_CHICKEN2_TIMING_OVERRIDE;
4628 -+ if (dev_priv->fdi_rx_polarity_inverted)
4629 -+ val |= TRANS_CHICKEN2_FDI_POLARITY_REVERSED;
4630 -+ I915_WRITE(TRANS_CHICKEN2(pipe), val);
4631 -+ }
4632 - /* WADP0ClockGatingDisable */
4633 - for_each_pipe(pipe) {
4634 - I915_WRITE(TRANS_CHICKEN1(pipe),
4635 -diff --git a/drivers/gpu/drm/i915/intel_sdvo.c b/drivers/gpu/drm/i915/intel_sdvo.c
4636 -index d07a8cd..d6df786 100644
4637 ---- a/drivers/gpu/drm/i915/intel_sdvo.c
4638 -+++ b/drivers/gpu/drm/i915/intel_sdvo.c
4639 -@@ -1235,11 +1235,13 @@ static bool intel_sdvo_get_hw_state(struct intel_encoder *encoder,
4640 - struct drm_device *dev = encoder->base.dev;
4641 - struct drm_i915_private *dev_priv = dev->dev_private;
4642 - struct intel_sdvo *intel_sdvo = to_intel_sdvo(&encoder->base);
4643 -+ u16 active_outputs;
4644 - u32 tmp;
4645 -
4646 - tmp = I915_READ(intel_sdvo->sdvo_reg);
4647 -+ intel_sdvo_get_active_outputs(intel_sdvo, &active_outputs);
4648 -
4649 -- if (!(tmp & SDVO_ENABLE))
4650 -+ if (!(tmp & SDVO_ENABLE) && (active_outputs == 0))
4651 - return false;
4652 -
4653 - if (HAS_PCH_CPT(dev))
4654 -@@ -2739,7 +2741,6 @@ bool intel_sdvo_init(struct drm_device *dev, uint32_t sdvo_reg, bool is_sdvob)
4655 - struct intel_sdvo *intel_sdvo;
4656 - u32 hotplug_mask;
4657 - int i;
4658 --
4659 - intel_sdvo = kzalloc(sizeof(struct intel_sdvo), GFP_KERNEL);
4660 - if (!intel_sdvo)
4661 - return false;
4662 -diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.h b/drivers/gpu/drm/mgag200/mgag200_drv.h
4663 -index 4d932c4..8065919 100644
4664 ---- a/drivers/gpu/drm/mgag200/mgag200_drv.h
4665 -+++ b/drivers/gpu/drm/mgag200/mgag200_drv.h
4666 -@@ -115,6 +115,8 @@ struct mga_fbdev {
4667 - void *sysram;
4668 - int size;
4669 - struct ttm_bo_kmap_obj mapping;
4670 -+ int x1, y1, x2, y2; /* dirty rect */
4671 -+ spinlock_t dirty_lock;
4672 - };
4673 -
4674 - struct mga_crtc {
4675 -diff --git a/drivers/gpu/drm/mgag200/mgag200_fb.c b/drivers/gpu/drm/mgag200/mgag200_fb.c
4676 -index d2253f6..b0dad27 100644
4677 ---- a/drivers/gpu/drm/mgag200/mgag200_fb.c
4678 -+++ b/drivers/gpu/drm/mgag200/mgag200_fb.c
4679 -@@ -29,16 +29,52 @@ static void mga_dirty_update(struct mga_fbdev *mfbdev,
4680 - int bpp = (mfbdev->mfb.base.bits_per_pixel + 7)/8;
4681 - int ret;
4682 - bool unmap = false;
4683 -+ bool store_for_later = false;
4684 -+ int x2, y2;
4685 -+ unsigned long flags;
4686 -
4687 - obj = mfbdev->mfb.obj;
4688 - bo = gem_to_mga_bo(obj);
4689 -
4690 -+ /*
4691 -+ * try and reserve the BO, if we fail with busy
4692 -+ * then the BO is being moved and we should
4693 -+ * store up the damage until later.
4694 -+ */
4695 - ret = mgag200_bo_reserve(bo, true);
4696 - if (ret) {
4697 -- DRM_ERROR("failed to reserve fb bo\n");
4698 -+ if (ret != -EBUSY)
4699 -+ return;
4700 -+
4701 -+ store_for_later = true;
4702 -+ }
4703 -+
4704 -+ x2 = x + width - 1;
4705 -+ y2 = y + height - 1;
4706 -+ spin_lock_irqsave(&mfbdev->dirty_lock, flags);
4707 -+
4708 -+ if (mfbdev->y1 < y)
4709 -+ y = mfbdev->y1;
4710 -+ if (mfbdev->y2 > y2)
4711 -+ y2 = mfbdev->y2;
4712 -+ if (mfbdev->x1 < x)
4713 -+ x = mfbdev->x1;
4714 -+ if (mfbdev->x2 > x2)
4715 -+ x2 = mfbdev->x2;
4716 -+
4717 -+ if (store_for_later) {
4718 -+ mfbdev->x1 = x;
4719 -+ mfbdev->x2 = x2;
4720 -+ mfbdev->y1 = y;
4721 -+ mfbdev->y2 = y2;
4722 -+ spin_unlock_irqrestore(&mfbdev->dirty_lock, flags);
4723 - return;
4724 - }
4725 -
4726 -+ mfbdev->x1 = mfbdev->y1 = INT_MAX;
4727 -+ mfbdev->x2 = mfbdev->y2 = 0;
4728 -+ spin_unlock_irqrestore(&mfbdev->dirty_lock, flags);
4729 -+
4730 - if (!bo->kmap.virtual) {
4731 - ret = ttm_bo_kmap(&bo->bo, 0, bo->bo.num_pages, &bo->kmap);
4732 - if (ret) {
4733 -@@ -48,10 +84,10 @@ static void mga_dirty_update(struct mga_fbdev *mfbdev,
4734 - }
4735 - unmap = true;
4736 - }
4737 -- for (i = y; i < y + height; i++) {
4738 -+ for (i = y; i <= y2; i++) {
4739 - /* assume equal stride for now */
4740 - src_offset = dst_offset = i * mfbdev->mfb.base.pitches[0] + (x * bpp);
4741 -- memcpy_toio(bo->kmap.virtual + src_offset, mfbdev->sysram + src_offset, width * bpp);
4742 -+ memcpy_toio(bo->kmap.virtual + src_offset, mfbdev->sysram + src_offset, (x2 - x + 1) * bpp);
4743 -
4744 - }
4745 - if (unmap)
4746 -@@ -255,6 +291,7 @@ int mgag200_fbdev_init(struct mga_device *mdev)
4747 -
4748 - mdev->mfbdev = mfbdev;
4749 - mfbdev->helper.funcs = &mga_fb_helper_funcs;
4750 -+ spin_lock_init(&mfbdev->dirty_lock);
4751 -
4752 - ret = drm_fb_helper_init(mdev->dev, &mfbdev->helper,
4753 - mdev->num_crtc, MGAG200FB_CONN_LIMIT);
4754 -diff --git a/drivers/gpu/drm/mgag200/mgag200_ttm.c b/drivers/gpu/drm/mgag200/mgag200_ttm.c
4755 -index 8fc9d92..401c989 100644
4756 ---- a/drivers/gpu/drm/mgag200/mgag200_ttm.c
4757 -+++ b/drivers/gpu/drm/mgag200/mgag200_ttm.c
4758 -@@ -315,8 +315,8 @@ int mgag200_bo_reserve(struct mgag200_bo *bo, bool no_wait)
4759 -
4760 - ret = ttm_bo_reserve(&bo->bo, true, no_wait, false, 0);
4761 - if (ret) {
4762 -- if (ret != -ERESTARTSYS)
4763 -- DRM_ERROR("reserve failed %p\n", bo);
4764 -+ if (ret != -ERESTARTSYS && ret != -EBUSY)
4765 -+ DRM_ERROR("reserve failed %p %d\n", bo, ret);
4766 - return ret;
4767 - }
4768 - return 0;
4769 -diff --git a/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c b/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c
4770 -index ac74d1b..1bdf7e1 100644
4771 ---- a/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c
4772 -+++ b/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c
4773 -@@ -212,7 +212,6 @@ struct drm_gem_object *omap_gem_prime_import(struct drm_device *dev,
4774 - * refcount on gem itself instead of f_count of dmabuf.
4775 - */
4776 - drm_gem_object_reference(obj);
4777 -- dma_buf_put(buffer);
4778 - return obj;
4779 - }
4780 - }
4781 -diff --git a/drivers/gpu/drm/radeon/atom.c b/drivers/gpu/drm/radeon/atom.c
4782 -index 46a9c37..fb441a7 100644
4783 ---- a/drivers/gpu/drm/radeon/atom.c
4784 -+++ b/drivers/gpu/drm/radeon/atom.c
4785 -@@ -1394,10 +1394,10 @@ int atom_allocate_fb_scratch(struct atom_context *ctx)
4786 - firmware_usage = (struct _ATOM_VRAM_USAGE_BY_FIRMWARE *)(ctx->bios + data_offset);
4787 -
4788 - DRM_DEBUG("atom firmware requested %08x %dkb\n",
4789 -- firmware_usage->asFirmwareVramReserveInfo[0].ulStartAddrUsedByFirmware,
4790 -- firmware_usage->asFirmwareVramReserveInfo[0].usFirmwareUseInKb);
4791 -+ le32_to_cpu(firmware_usage->asFirmwareVramReserveInfo[0].ulStartAddrUsedByFirmware),
4792 -+ le16_to_cpu(firmware_usage->asFirmwareVramReserveInfo[0].usFirmwareUseInKb));
4793 -
4794 -- usage_bytes = firmware_usage->asFirmwareVramReserveInfo[0].usFirmwareUseInKb * 1024;
4795 -+ usage_bytes = le16_to_cpu(firmware_usage->asFirmwareVramReserveInfo[0].usFirmwareUseInKb) * 1024;
4796 - }
4797 - ctx->scratch_size_bytes = 0;
4798 - if (usage_bytes == 0)
4799 -diff --git a/drivers/gpu/drm/radeon/atombios_crtc.c b/drivers/gpu/drm/radeon/atombios_crtc.c
4800 -index 21a892c..6d6fdb3 100644
4801 ---- a/drivers/gpu/drm/radeon/atombios_crtc.c
4802 -+++ b/drivers/gpu/drm/radeon/atombios_crtc.c
4803 -@@ -557,6 +557,9 @@ static u32 atombios_adjust_pll(struct drm_crtc *crtc,
4804 - /* use frac fb div on APUs */
4805 - if (ASIC_IS_DCE41(rdev) || ASIC_IS_DCE61(rdev))
4806 - radeon_crtc->pll_flags |= RADEON_PLL_USE_FRAC_FB_DIV;
4807 -+ /* use frac fb div on RS780/RS880 */
4808 -+ if ((rdev->family == CHIP_RS780) || (rdev->family == CHIP_RS880))
4809 -+ radeon_crtc->pll_flags |= RADEON_PLL_USE_FRAC_FB_DIV;
4810 - if (ASIC_IS_DCE32(rdev) && mode->clock > 165000)
4811 - radeon_crtc->pll_flags |= RADEON_PLL_USE_FRAC_FB_DIV;
4812 - } else {
4813 -diff --git a/drivers/gpu/drm/radeon/evergreen.c b/drivers/gpu/drm/radeon/evergreen.c
4814 -index 305a657..aeaa386 100644
4815 ---- a/drivers/gpu/drm/radeon/evergreen.c
4816 -+++ b/drivers/gpu/drm/radeon/evergreen.c
4817 -@@ -105,6 +105,27 @@ void evergreen_fix_pci_max_read_req_size(struct radeon_device *rdev)
4818 - }
4819 - }
4820 -
4821 -+static bool dce4_is_in_vblank(struct radeon_device *rdev, int crtc)
4822 -+{
4823 -+ if (RREG32(EVERGREEN_CRTC_STATUS + crtc_offsets[crtc]) & EVERGREEN_CRTC_V_BLANK)
4824 -+ return true;
4825 -+ else
4826 -+ return false;
4827 -+}
4828 -+
4829 -+static bool dce4_is_counter_moving(struct radeon_device *rdev, int crtc)
4830 -+{
4831 -+ u32 pos1, pos2;
4832 -+
4833 -+ pos1 = RREG32(EVERGREEN_CRTC_STATUS_POSITION + crtc_offsets[crtc]);
4834 -+ pos2 = RREG32(EVERGREEN_CRTC_STATUS_POSITION + crtc_offsets[crtc]);
4835 -+
4836 -+ if (pos1 != pos2)
4837 -+ return true;
4838 -+ else
4839 -+ return false;
4840 -+}
4841 -+
4842 - /**
4843 - * dce4_wait_for_vblank - vblank wait asic callback.
4844 - *
4845 -@@ -115,21 +136,28 @@ void evergreen_fix_pci_max_read_req_size(struct radeon_device *rdev)
4846 - */
4847 - void dce4_wait_for_vblank(struct radeon_device *rdev, int crtc)
4848 - {
4849 -- int i;
4850 -+ unsigned i = 0;
4851 -
4852 - if (crtc >= rdev->num_crtc)
4853 - return;
4854 -
4855 -- if (RREG32(EVERGREEN_CRTC_CONTROL + crtc_offsets[crtc]) & EVERGREEN_CRTC_MASTER_EN) {
4856 -- for (i = 0; i < rdev->usec_timeout; i++) {
4857 -- if (!(RREG32(EVERGREEN_CRTC_STATUS + crtc_offsets[crtc]) & EVERGREEN_CRTC_V_BLANK))
4858 -+ if (!(RREG32(EVERGREEN_CRTC_CONTROL + crtc_offsets[crtc]) & EVERGREEN_CRTC_MASTER_EN))
4859 -+ return;
4860 -+
4861 -+ /* depending on when we hit vblank, we may be close to active; if so,
4862 -+ * wait for another frame.
4863 -+ */
4864 -+ while (dce4_is_in_vblank(rdev, crtc)) {
4865 -+ if (i++ % 100 == 0) {
4866 -+ if (!dce4_is_counter_moving(rdev, crtc))
4867 - break;
4868 -- udelay(1);
4869 - }
4870 -- for (i = 0; i < rdev->usec_timeout; i++) {
4871 -- if (RREG32(EVERGREEN_CRTC_STATUS + crtc_offsets[crtc]) & EVERGREEN_CRTC_V_BLANK)
4872 -+ }
4873 -+
4874 -+ while (!dce4_is_in_vblank(rdev, crtc)) {
4875 -+ if (i++ % 100 == 0) {
4876 -+ if (!dce4_is_counter_moving(rdev, crtc))
4877 - break;
4878 -- udelay(1);
4879 - }
4880 - }
4881 - }
4882 -@@ -608,6 +636,16 @@ void evergreen_hpd_init(struct radeon_device *rdev)
4883 -
4884 - list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
4885 - struct radeon_connector *radeon_connector = to_radeon_connector(connector);
4886 -+
4887 -+ if (connector->connector_type == DRM_MODE_CONNECTOR_eDP ||
4888 -+ connector->connector_type == DRM_MODE_CONNECTOR_LVDS) {
4889 -+ /* don't try to enable hpd on eDP or LVDS avoid breaking the
4890 -+ * aux dp channel on imac and help (but not completely fix)
4891 -+ * https://bugzilla.redhat.com/show_bug.cgi?id=726143
4892 -+ * also avoid interrupt storms during dpms.
4893 -+ */
4894 -+ continue;
4895 -+ }
4896 - switch (radeon_connector->hpd.hpd) {
4897 - case RADEON_HPD_1:
4898 - WREG32(DC_HPD1_CONTROL, tmp);
4899 -@@ -1325,17 +1363,16 @@ void evergreen_mc_stop(struct radeon_device *rdev, struct evergreen_mc_save *sav
4900 - tmp = RREG32(EVERGREEN_CRTC_BLANK_CONTROL + crtc_offsets[i]);
4901 - if (!(tmp & EVERGREEN_CRTC_BLANK_DATA_EN)) {
4902 - radeon_wait_for_vblank(rdev, i);
4903 -- tmp |= EVERGREEN_CRTC_BLANK_DATA_EN;
4904 - WREG32(EVERGREEN_CRTC_UPDATE_LOCK + crtc_offsets[i], 1);
4905 -+ tmp |= EVERGREEN_CRTC_BLANK_DATA_EN;
4906 - WREG32(EVERGREEN_CRTC_BLANK_CONTROL + crtc_offsets[i], tmp);
4907 -- WREG32(EVERGREEN_CRTC_UPDATE_LOCK + crtc_offsets[i], 0);
4908 - }
4909 - } else {
4910 - tmp = RREG32(EVERGREEN_CRTC_CONTROL + crtc_offsets[i]);
4911 - if (!(tmp & EVERGREEN_CRTC_DISP_READ_REQUEST_DISABLE)) {
4912 - radeon_wait_for_vblank(rdev, i);
4913 -- tmp |= EVERGREEN_CRTC_DISP_READ_REQUEST_DISABLE;
4914 - WREG32(EVERGREEN_CRTC_UPDATE_LOCK + crtc_offsets[i], 1);
4915 -+ tmp |= EVERGREEN_CRTC_DISP_READ_REQUEST_DISABLE;
4916 - WREG32(EVERGREEN_CRTC_CONTROL + crtc_offsets[i], tmp);
4917 - WREG32(EVERGREEN_CRTC_UPDATE_LOCK + crtc_offsets[i], 0);
4918 - }
4919 -@@ -1347,6 +1384,15 @@ void evergreen_mc_stop(struct radeon_device *rdev, struct evergreen_mc_save *sav
4920 - break;
4921 - udelay(1);
4922 - }
4923 -+
4924 -+ /* XXX this is a hack to avoid strange behavior with EFI on certain systems */
4925 -+ WREG32(EVERGREEN_CRTC_UPDATE_LOCK + crtc_offsets[i], 1);
4926 -+ tmp = RREG32(EVERGREEN_CRTC_CONTROL + crtc_offsets[i]);
4927 -+ tmp &= ~EVERGREEN_CRTC_MASTER_EN;
4928 -+ WREG32(EVERGREEN_CRTC_CONTROL + crtc_offsets[i], tmp);
4929 -+ WREG32(EVERGREEN_CRTC_UPDATE_LOCK + crtc_offsets[i], 0);
4930 -+ save->crtc_enabled[i] = false;
4931 -+ /* ***** */
4932 - } else {
4933 - save->crtc_enabled[i] = false;
4934 - }
4935 -@@ -1364,6 +1410,22 @@ void evergreen_mc_stop(struct radeon_device *rdev, struct evergreen_mc_save *sav
4936 - }
4937 - /* wait for the MC to settle */
4938 - udelay(100);
4939 -+
4940 -+ /* lock double buffered regs */
4941 -+ for (i = 0; i < rdev->num_crtc; i++) {
4942 -+ if (save->crtc_enabled[i]) {
4943 -+ tmp = RREG32(EVERGREEN_GRPH_UPDATE + crtc_offsets[i]);
4944 -+ if (!(tmp & EVERGREEN_GRPH_UPDATE_LOCK)) {
4945 -+ tmp |= EVERGREEN_GRPH_UPDATE_LOCK;
4946 -+ WREG32(EVERGREEN_GRPH_UPDATE + crtc_offsets[i], tmp);
4947 -+ }
4948 -+ tmp = RREG32(EVERGREEN_MASTER_UPDATE_LOCK + crtc_offsets[i]);
4949 -+ if (!(tmp & 1)) {
4950 -+ tmp |= 1;
4951 -+ WREG32(EVERGREEN_MASTER_UPDATE_LOCK + crtc_offsets[i], tmp);
4952 -+ }
4953 -+ }
4954 -+ }
4955 - }
4956 -
4957 - void evergreen_mc_resume(struct radeon_device *rdev, struct evergreen_mc_save *save)
4958 -@@ -1385,6 +1447,33 @@ void evergreen_mc_resume(struct radeon_device *rdev, struct evergreen_mc_save *s
4959 - WREG32(EVERGREEN_VGA_MEMORY_BASE_ADDRESS_HIGH, upper_32_bits(rdev->mc.vram_start));
4960 - WREG32(EVERGREEN_VGA_MEMORY_BASE_ADDRESS, (u32)rdev->mc.vram_start);
4961 -
4962 -+ /* unlock regs and wait for update */
4963 -+ for (i = 0; i < rdev->num_crtc; i++) {
4964 -+ if (save->crtc_enabled[i]) {
4965 -+ tmp = RREG32(EVERGREEN_MASTER_UPDATE_MODE + crtc_offsets[i]);
4966 -+ if ((tmp & 0x3) != 0) {
4967 -+ tmp &= ~0x3;
4968 -+ WREG32(EVERGREEN_MASTER_UPDATE_MODE + crtc_offsets[i], tmp);
4969 -+ }
4970 -+ tmp = RREG32(EVERGREEN_GRPH_UPDATE + crtc_offsets[i]);
4971 -+ if (tmp & EVERGREEN_GRPH_UPDATE_LOCK) {
4972 -+ tmp &= ~EVERGREEN_GRPH_UPDATE_LOCK;
4973 -+ WREG32(EVERGREEN_GRPH_UPDATE + crtc_offsets[i], tmp);
4974 -+ }
4975 -+ tmp = RREG32(EVERGREEN_MASTER_UPDATE_LOCK + crtc_offsets[i]);
4976 -+ if (tmp & 1) {
4977 -+ tmp &= ~1;
4978 -+ WREG32(EVERGREEN_MASTER_UPDATE_LOCK + crtc_offsets[i], tmp);
4979 -+ }
4980 -+ for (j = 0; j < rdev->usec_timeout; j++) {
4981 -+ tmp = RREG32(EVERGREEN_GRPH_UPDATE + crtc_offsets[i]);
4982 -+ if ((tmp & EVERGREEN_GRPH_SURFACE_UPDATE_PENDING) == 0)
4983 -+ break;
4984 -+ udelay(1);
4985 -+ }
4986 -+ }
4987 -+ }
4988 -+
4989 - /* unblackout the MC */
4990 - tmp = RREG32(MC_SHARED_BLACKOUT_CNTL);
4991 - tmp &= ~BLACKOUT_MODE_MASK;
4992 -diff --git a/drivers/gpu/drm/radeon/evergreen_reg.h b/drivers/gpu/drm/radeon/evergreen_reg.h
4993 -index f585be1..881aba2 100644
4994 ---- a/drivers/gpu/drm/radeon/evergreen_reg.h
4995 -+++ b/drivers/gpu/drm/radeon/evergreen_reg.h
4996 -@@ -226,6 +226,8 @@
4997 - #define EVERGREEN_CRTC_STATUS_HV_COUNT 0x6ea0
4998 - #define EVERGREEN_MASTER_UPDATE_MODE 0x6ef8
4999 - #define EVERGREEN_CRTC_UPDATE_LOCK 0x6ed4
5000 -+#define EVERGREEN_MASTER_UPDATE_LOCK 0x6ef4
5001 -+#define EVERGREEN_MASTER_UPDATE_MODE 0x6ef8
5002 -
5003 - #define EVERGREEN_DC_GPIO_HPD_MASK 0x64b0
5004 - #define EVERGREEN_DC_GPIO_HPD_A 0x64b4
5005 -diff --git a/drivers/gpu/drm/radeon/ni.c b/drivers/gpu/drm/radeon/ni.c
5006 -index 27769e7..0a32d89 100644
5007 ---- a/drivers/gpu/drm/radeon/ni.c
5008 -+++ b/drivers/gpu/drm/radeon/ni.c
5009 -@@ -473,7 +473,8 @@ static void cayman_gpu_init(struct radeon_device *rdev)
5010 - (rdev->pdev->device == 0x990F) ||
5011 - (rdev->pdev->device == 0x9910) ||
5012 - (rdev->pdev->device == 0x9917) ||
5013 -- (rdev->pdev->device == 0x9999)) {
5014 -+ (rdev->pdev->device == 0x9999) ||
5015 -+ (rdev->pdev->device == 0x999C)) {
5016 - rdev->config.cayman.max_simds_per_se = 6;
5017 - rdev->config.cayman.max_backends_per_se = 2;
5018 - } else if ((rdev->pdev->device == 0x9903) ||
5019 -@@ -482,7 +483,8 @@ static void cayman_gpu_init(struct radeon_device *rdev)
5020 - (rdev->pdev->device == 0x990D) ||
5021 - (rdev->pdev->device == 0x990E) ||
5022 - (rdev->pdev->device == 0x9913) ||
5023 -- (rdev->pdev->device == 0x9918)) {
5024 -+ (rdev->pdev->device == 0x9918) ||
5025 -+ (rdev->pdev->device == 0x999D)) {
5026 - rdev->config.cayman.max_simds_per_se = 4;
5027 - rdev->config.cayman.max_backends_per_se = 2;
5028 - } else if ((rdev->pdev->device == 0x9919) ||
5029 -@@ -621,6 +623,8 @@ static void cayman_gpu_init(struct radeon_device *rdev)
5030 -
5031 - WREG32(GB_ADDR_CONFIG, gb_addr_config);
5032 - WREG32(DMIF_ADDR_CONFIG, gb_addr_config);
5033 -+ if (ASIC_IS_DCE6(rdev))
5034 -+ WREG32(DMIF_ADDR_CALC, gb_addr_config);
5035 - WREG32(HDP_ADDR_CONFIG, gb_addr_config);
5036 - WREG32(DMA_TILING_CONFIG + DMA0_REGISTER_OFFSET, gb_addr_config);
5037 - WREG32(DMA_TILING_CONFIG + DMA1_REGISTER_OFFSET, gb_addr_config);
5038 -diff --git a/drivers/gpu/drm/radeon/nid.h b/drivers/gpu/drm/radeon/nid.h
5039 -index 079dee2..445b235 100644
5040 ---- a/drivers/gpu/drm/radeon/nid.h
5041 -+++ b/drivers/gpu/drm/radeon/nid.h
5042 -@@ -45,6 +45,10 @@
5043 - #define ARUBA_GB_ADDR_CONFIG_GOLDEN 0x12010001
5044 -
5045 - #define DMIF_ADDR_CONFIG 0xBD4
5046 -+
5047 -+/* DCE6 only */
5048 -+#define DMIF_ADDR_CALC 0xC00
5049 -+
5050 - #define SRBM_GFX_CNTL 0x0E44
5051 - #define RINGID(x) (((x) & 0x3) << 0)
5052 - #define VMID(x) (((x) & 0x7) << 0)
5053 -diff --git a/drivers/gpu/drm/radeon/r100.c b/drivers/gpu/drm/radeon/r100.c
5054 -index 9db5853..4973bff 100644
5055 ---- a/drivers/gpu/drm/radeon/r100.c
5056 -+++ b/drivers/gpu/drm/radeon/r100.c
5057 -@@ -69,6 +69,38 @@ MODULE_FIRMWARE(FIRMWARE_R520);
5058 - * and others in some cases.
5059 - */
5060 -
5061 -+static bool r100_is_in_vblank(struct radeon_device *rdev, int crtc)
5062 -+{
5063 -+ if (crtc == 0) {
5064 -+ if (RREG32(RADEON_CRTC_STATUS) & RADEON_CRTC_VBLANK_CUR)
5065 -+ return true;
5066 -+ else
5067 -+ return false;
5068 -+ } else {
5069 -+ if (RREG32(RADEON_CRTC2_STATUS) & RADEON_CRTC2_VBLANK_CUR)
5070 -+ return true;
5071 -+ else
5072 -+ return false;
5073 -+ }
5074 -+}
5075 -+
5076 -+static bool r100_is_counter_moving(struct radeon_device *rdev, int crtc)
5077 -+{
5078 -+ u32 vline1, vline2;
5079 -+
5080 -+ if (crtc == 0) {
5081 -+ vline1 = (RREG32(RADEON_CRTC_VLINE_CRNT_VLINE) >> 16) & RADEON_CRTC_V_TOTAL;
5082 -+ vline2 = (RREG32(RADEON_CRTC_VLINE_CRNT_VLINE) >> 16) & RADEON_CRTC_V_TOTAL;
5083 -+ } else {
5084 -+ vline1 = (RREG32(RADEON_CRTC2_VLINE_CRNT_VLINE) >> 16) & RADEON_CRTC_V_TOTAL;
5085 -+ vline2 = (RREG32(RADEON_CRTC2_VLINE_CRNT_VLINE) >> 16) & RADEON_CRTC_V_TOTAL;
5086 -+ }
5087 -+ if (vline1 != vline2)
5088 -+ return true;
5089 -+ else
5090 -+ return false;
5091 -+}
5092 -+
5093 - /**
5094 - * r100_wait_for_vblank - vblank wait asic callback.
5095 - *
5096 -@@ -79,36 +111,33 @@ MODULE_FIRMWARE(FIRMWARE_R520);
5097 - */
5098 - void r100_wait_for_vblank(struct radeon_device *rdev, int crtc)
5099 - {
5100 -- int i;
5101 -+ unsigned i = 0;
5102 -
5103 - if (crtc >= rdev->num_crtc)
5104 - return;
5105 -
5106 - if (crtc == 0) {
5107 -- if (RREG32(RADEON_CRTC_GEN_CNTL) & RADEON_CRTC_EN) {
5108 -- for (i = 0; i < rdev->usec_timeout; i++) {
5109 -- if (!(RREG32(RADEON_CRTC_STATUS) & RADEON_CRTC_VBLANK_CUR))
5110 -- break;
5111 -- udelay(1);
5112 -- }
5113 -- for (i = 0; i < rdev->usec_timeout; i++) {
5114 -- if (RREG32(RADEON_CRTC_STATUS) & RADEON_CRTC_VBLANK_CUR)
5115 -- break;
5116 -- udelay(1);
5117 -- }
5118 -- }
5119 -+ if (!(RREG32(RADEON_CRTC_GEN_CNTL) & RADEON_CRTC_EN))
5120 -+ return;
5121 - } else {
5122 -- if (RREG32(RADEON_CRTC2_GEN_CNTL) & RADEON_CRTC2_EN) {
5123 -- for (i = 0; i < rdev->usec_timeout; i++) {
5124 -- if (!(RREG32(RADEON_CRTC2_STATUS) & RADEON_CRTC2_VBLANK_CUR))
5125 -- break;
5126 -- udelay(1);
5127 -- }
5128 -- for (i = 0; i < rdev->usec_timeout; i++) {
5129 -- if (RREG32(RADEON_CRTC2_STATUS) & RADEON_CRTC2_VBLANK_CUR)
5130 -- break;
5131 -- udelay(1);
5132 -- }
5133 -+ if (!(RREG32(RADEON_CRTC2_GEN_CNTL) & RADEON_CRTC2_EN))
5134 -+ return;
5135 -+ }
5136 -+
5137 -+ /* depending on when we hit vblank, we may be close to active; if so,
5138 -+ * wait for another frame.
5139 -+ */
5140 -+ while (r100_is_in_vblank(rdev, crtc)) {
5141 -+ if (i++ % 100 == 0) {
5142 -+ if (!r100_is_counter_moving(rdev, crtc))
5143 -+ break;
5144 -+ }
5145 -+ }
5146 -+
5147 -+ while (!r100_is_in_vblank(rdev, crtc)) {
5148 -+ if (i++ % 100 == 0) {
5149 -+ if (!r100_is_counter_moving(rdev, crtc))
5150 -+ break;
5151 - }
5152 - }
5153 - }
5154 -diff --git a/drivers/gpu/drm/radeon/r500_reg.h b/drivers/gpu/drm/radeon/r500_reg.h
5155 -index c0dc8d3..1dd0d32 100644
5156 ---- a/drivers/gpu/drm/radeon/r500_reg.h
5157 -+++ b/drivers/gpu/drm/radeon/r500_reg.h
5158 -@@ -358,7 +358,9 @@
5159 - #define AVIVO_D1CRTC_STATUS_HV_COUNT 0x60ac
5160 - #define AVIVO_D1CRTC_STEREO_CONTROL 0x60c4
5161 -
5162 -+#define AVIVO_D1MODE_MASTER_UPDATE_LOCK 0x60e0
5163 - #define AVIVO_D1MODE_MASTER_UPDATE_MODE 0x60e4
5164 -+#define AVIVO_D1CRTC_UPDATE_LOCK 0x60e8
5165 -
5166 - /* master controls */
5167 - #define AVIVO_DC_CRTC_MASTER_EN 0x60f8
5168 -diff --git a/drivers/gpu/drm/radeon/r600_hdmi.c b/drivers/gpu/drm/radeon/r600_hdmi.c
5169 -index 21ecc0e..8520833 100644
5170 ---- a/drivers/gpu/drm/radeon/r600_hdmi.c
5171 -+++ b/drivers/gpu/drm/radeon/r600_hdmi.c
5172 -@@ -433,7 +433,7 @@ void r600_hdmi_enable(struct drm_encoder *encoder)
5173 - offset = dig->afmt->offset;
5174 -
5175 - /* Older chipsets require setting HDMI and routing manually */
5176 -- if (rdev->family >= CHIP_R600 && !ASIC_IS_DCE3(rdev)) {
5177 -+ if (ASIC_IS_DCE2(rdev) && !ASIC_IS_DCE3(rdev)) {
5178 - hdmi = HDMI0_ERROR_ACK | HDMI0_ENABLE;
5179 - switch (radeon_encoder->encoder_id) {
5180 - case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_TMDS1:
5181 -@@ -501,7 +501,7 @@ void r600_hdmi_disable(struct drm_encoder *encoder)
5182 - radeon_irq_kms_disable_afmt(rdev, dig->afmt->id);
5183 -
5184 - /* Older chipsets not handled by AtomBIOS */
5185 -- if (rdev->family >= CHIP_R600 && !ASIC_IS_DCE3(rdev)) {
5186 -+ if (ASIC_IS_DCE2(rdev) && !ASIC_IS_DCE3(rdev)) {
5187 - switch (radeon_encoder->encoder_id) {
5188 - case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_TMDS1:
5189 - WREG32_P(AVIVO_TMDSA_CNTL, 0,
5190 -diff --git a/drivers/gpu/drm/radeon/radeon_atombios.c b/drivers/gpu/drm/radeon/radeon_atombios.c
5191 -index f22eb57..96168ef 100644
5192 ---- a/drivers/gpu/drm/radeon/radeon_atombios.c
5193 -+++ b/drivers/gpu/drm/radeon/radeon_atombios.c
5194 -@@ -2028,6 +2028,8 @@ static int radeon_atombios_parse_power_table_1_3(struct radeon_device *rdev)
5195 - num_modes = power_info->info.ucNumOfPowerModeEntries;
5196 - if (num_modes > ATOM_MAX_NUMBEROF_POWER_BLOCK)
5197 - num_modes = ATOM_MAX_NUMBEROF_POWER_BLOCK;
5198 -+ if (num_modes == 0)
5199 -+ return state_index;
5200 - rdev->pm.power_state = kzalloc(sizeof(struct radeon_power_state) * num_modes, GFP_KERNEL);
5201 - if (!rdev->pm.power_state)
5202 - return state_index;
5203 -@@ -2432,6 +2434,8 @@ static int radeon_atombios_parse_power_table_4_5(struct radeon_device *rdev)
5204 - power_info = (union power_info *)(mode_info->atom_context->bios + data_offset);
5205 -
5206 - radeon_atombios_add_pplib_thermal_controller(rdev, &power_info->pplib.sThermalController);
5207 -+ if (power_info->pplib.ucNumStates == 0)
5208 -+ return state_index;
5209 - rdev->pm.power_state = kzalloc(sizeof(struct radeon_power_state) *
5210 - power_info->pplib.ucNumStates, GFP_KERNEL);
5211 - if (!rdev->pm.power_state)
5212 -@@ -2514,6 +2518,7 @@ static int radeon_atombios_parse_power_table_6(struct radeon_device *rdev)
5213 - int index = GetIndexIntoMasterTable(DATA, PowerPlayInfo);
5214 - u16 data_offset;
5215 - u8 frev, crev;
5216 -+ u8 *power_state_offset;
5217 -
5218 - if (!atom_parse_data_header(mode_info->atom_context, index, NULL,
5219 - &frev, &crev, &data_offset))
5220 -@@ -2530,15 +2535,17 @@ static int radeon_atombios_parse_power_table_6(struct radeon_device *rdev)
5221 - non_clock_info_array = (struct _NonClockInfoArray *)
5222 - (mode_info->atom_context->bios + data_offset +
5223 - le16_to_cpu(power_info->pplib.usNonClockInfoArrayOffset));
5224 -+ if (state_array->ucNumEntries == 0)
5225 -+ return state_index;
5226 - rdev->pm.power_state = kzalloc(sizeof(struct radeon_power_state) *
5227 - state_array->ucNumEntries, GFP_KERNEL);
5228 - if (!rdev->pm.power_state)
5229 - return state_index;
5230 -+ power_state_offset = (u8 *)state_array->states;
5231 - for (i = 0; i < state_array->ucNumEntries; i++) {
5232 - mode_index = 0;
5233 -- power_state = (union pplib_power_state *)&state_array->states[i];
5234 -- /* XXX this might be an inagua bug... */
5235 -- non_clock_array_index = i; /* power_state->v2.nonClockInfoIndex */
5236 -+ power_state = (union pplib_power_state *)power_state_offset;
5237 -+ non_clock_array_index = power_state->v2.nonClockInfoIndex;
5238 - non_clock_info = (struct _ATOM_PPLIB_NONCLOCK_INFO *)
5239 - &non_clock_info_array->nonClockInfo[non_clock_array_index];
5240 - rdev->pm.power_state[i].clock_info = kzalloc(sizeof(struct radeon_pm_clock_info) *
5241 -@@ -2550,9 +2557,6 @@ static int radeon_atombios_parse_power_table_6(struct radeon_device *rdev)
5242 - if (power_state->v2.ucNumDPMLevels) {
5243 - for (j = 0; j < power_state->v2.ucNumDPMLevels; j++) {
5244 - clock_array_index = power_state->v2.clockInfoIndex[j];
5245 -- /* XXX this might be an inagua bug... */
5246 -- if (clock_array_index >= clock_info_array->ucNumEntries)
5247 -- continue;
5248 - clock_info = (union pplib_clock_info *)
5249 - &clock_info_array->clockInfo[clock_array_index * clock_info_array->ucEntrySize];
5250 - valid = radeon_atombios_parse_pplib_clock_info(rdev,
5251 -@@ -2574,6 +2578,7 @@ static int radeon_atombios_parse_power_table_6(struct radeon_device *rdev)
5252 - non_clock_info);
5253 - state_index++;
5254 - }
5255 -+ power_state_offset += 2 + power_state->v2.ucNumDPMLevels;
5256 - }
5257 - /* if multiple clock modes, mark the lowest as no display */
5258 - for (i = 0; i < state_index; i++) {
5259 -@@ -2620,7 +2625,9 @@ void radeon_atombios_get_power_modes(struct radeon_device *rdev)
5260 - default:
5261 - break;
5262 - }
5263 -- } else {
5264 -+ }
5265 -+
5266 -+ if (state_index == 0) {
5267 - rdev->pm.power_state = kzalloc(sizeof(struct radeon_power_state), GFP_KERNEL);
5268 - if (rdev->pm.power_state) {
5269 - rdev->pm.power_state[0].clock_info =
5270 -diff --git a/drivers/gpu/drm/radeon/radeon_kms.c b/drivers/gpu/drm/radeon/radeon_kms.c
5271 -index c75cb2c..c5b2765 100644
5272 ---- a/drivers/gpu/drm/radeon/radeon_kms.c
5273 -+++ b/drivers/gpu/drm/radeon/radeon_kms.c
5274 -@@ -50,9 +50,13 @@ int radeon_driver_unload_kms(struct drm_device *dev)
5275 -
5276 - if (rdev == NULL)
5277 - return 0;
5278 -+ if (rdev->rmmio == NULL)
5279 -+ goto done_free;
5280 - radeon_acpi_fini(rdev);
5281 - radeon_modeset_fini(rdev);
5282 - radeon_device_fini(rdev);
5283 -+
5284 -+done_free:
5285 - kfree(rdev);
5286 - dev->dev_private = NULL;
5287 - return 0;
5288 -diff --git a/drivers/gpu/drm/radeon/radeon_pm.c b/drivers/gpu/drm/radeon/radeon_pm.c
5289 -index 338fd6a..788c64c 100644
5290 ---- a/drivers/gpu/drm/radeon/radeon_pm.c
5291 -+++ b/drivers/gpu/drm/radeon/radeon_pm.c
5292 -@@ -843,7 +843,11 @@ static int radeon_debugfs_pm_info(struct seq_file *m, void *data)
5293 - struct radeon_device *rdev = dev->dev_private;
5294 -
5295 - seq_printf(m, "default engine clock: %u0 kHz\n", rdev->pm.default_sclk);
5296 -- seq_printf(m, "current engine clock: %u0 kHz\n", radeon_get_engine_clock(rdev));
5297 -+ /* radeon_get_engine_clock is not reliable on APUs so just print the current clock */
5298 -+ if ((rdev->family >= CHIP_PALM) && (rdev->flags & RADEON_IS_IGP))
5299 -+ seq_printf(m, "current engine clock: %u0 kHz\n", rdev->pm.current_sclk);
5300 -+ else
5301 -+ seq_printf(m, "current engine clock: %u0 kHz\n", radeon_get_engine_clock(rdev));
5302 - seq_printf(m, "default memory clock: %u0 kHz\n", rdev->pm.default_mclk);
5303 - if (rdev->asic->pm.get_memory_clock)
5304 - seq_printf(m, "current memory clock: %u0 kHz\n", radeon_get_memory_clock(rdev));
5305 -diff --git a/drivers/gpu/drm/radeon/radeon_ring.c b/drivers/gpu/drm/radeon/radeon_ring.c
5306 -index 8d58e26..1ef5eaa 100644
5307 ---- a/drivers/gpu/drm/radeon/radeon_ring.c
5308 -+++ b/drivers/gpu/drm/radeon/radeon_ring.c
5309 -@@ -180,7 +180,8 @@ int radeon_ib_schedule(struct radeon_device *rdev, struct radeon_ib *ib,
5310 - radeon_semaphore_free(rdev, &ib->semaphore, NULL);
5311 - }
5312 - /* if we can't remember our last VM flush then flush now! */
5313 -- if (ib->vm && !ib->vm->last_flush) {
5314 -+ /* XXX figure out why we have to flush for every IB */
5315 -+ if (ib->vm /*&& !ib->vm->last_flush*/) {
5316 - radeon_ring_vm_flush(rdev, ib->ring, ib->vm);
5317 - }
5318 - if (const_ib) {
5319 -diff --git a/drivers/gpu/drm/radeon/rs600.c b/drivers/gpu/drm/radeon/rs600.c
5320 -index 5a0fc74..46fa1b0 100644
5321 ---- a/drivers/gpu/drm/radeon/rs600.c
5322 -+++ b/drivers/gpu/drm/radeon/rs600.c
5323 -@@ -52,23 +52,59 @@ static const u32 crtc_offsets[2] =
5324 - AVIVO_D2CRTC_H_TOTAL - AVIVO_D1CRTC_H_TOTAL
5325 - };
5326 -
5327 -+static bool avivo_is_in_vblank(struct radeon_device *rdev, int crtc)
5328 -+{
5329 -+ if (RREG32(AVIVO_D1CRTC_STATUS + crtc_offsets[crtc]) & AVIVO_D1CRTC_V_BLANK)
5330 -+ return true;
5331 -+ else
5332 -+ return false;
5333 -+}
5334 -+
5335 -+static bool avivo_is_counter_moving(struct radeon_device *rdev, int crtc)
5336 -+{
5337 -+ u32 pos1, pos2;
5338 -+
5339 -+ pos1 = RREG32(AVIVO_D1CRTC_STATUS_POSITION + crtc_offsets[crtc]);
5340 -+ pos2 = RREG32(AVIVO_D1CRTC_STATUS_POSITION + crtc_offsets[crtc]);
5341 -+
5342 -+ if (pos1 != pos2)
5343 -+ return true;
5344 -+ else
5345 -+ return false;
5346 -+}
5347 -+
5348 -+/**
5349 -+ * avivo_wait_for_vblank - vblank wait asic callback.
5350 -+ *
5351 -+ * @rdev: radeon_device pointer
5352 -+ * @crtc: crtc to wait for vblank on
5353 -+ *
5354 -+ * Wait for vblank on the requested crtc (r5xx-r7xx).
5355 -+ */
5356 - void avivo_wait_for_vblank(struct radeon_device *rdev, int crtc)
5357 - {
5358 -- int i;
5359 -+ unsigned i = 0;
5360 -
5361 - if (crtc >= rdev->num_crtc)
5362 - return;
5363 -
5364 -- if (RREG32(AVIVO_D1CRTC_CONTROL + crtc_offsets[crtc]) & AVIVO_CRTC_EN) {
5365 -- for (i = 0; i < rdev->usec_timeout; i++) {
5366 -- if (!(RREG32(AVIVO_D1CRTC_STATUS + crtc_offsets[crtc]) & AVIVO_D1CRTC_V_BLANK))
5367 -+ if (!(RREG32(AVIVO_D1CRTC_CONTROL + crtc_offsets[crtc]) & AVIVO_CRTC_EN))
5368 -+ return;
5369 -+
5370 -+ /* depending on when we hit vblank, we may be close to active; if so,
5371 -+ * wait for another frame.
5372 -+ */
5373 -+ while (avivo_is_in_vblank(rdev, crtc)) {
5374 -+ if (i++ % 100 == 0) {
5375 -+ if (!avivo_is_counter_moving(rdev, crtc))
5376 - break;
5377 -- udelay(1);
5378 - }
5379 -- for (i = 0; i < rdev->usec_timeout; i++) {
5380 -- if (RREG32(AVIVO_D1CRTC_STATUS + crtc_offsets[crtc]) & AVIVO_D1CRTC_V_BLANK)
5381 -+ }
5382 -+
5383 -+ while (!avivo_is_in_vblank(rdev, crtc)) {
5384 -+ if (i++ % 100 == 0) {
5385 -+ if (!avivo_is_counter_moving(rdev, crtc))
5386 - break;
5387 -- udelay(1);
5388 - }
5389 - }
5390 - }
5391 -diff --git a/drivers/gpu/drm/radeon/rv515.c b/drivers/gpu/drm/radeon/rv515.c
5392 -index 435ed35..ffcba73 100644
5393 ---- a/drivers/gpu/drm/radeon/rv515.c
5394 -+++ b/drivers/gpu/drm/radeon/rv515.c
5395 -@@ -303,8 +303,10 @@ void rv515_mc_stop(struct radeon_device *rdev, struct rv515_mc_save *save)
5396 - tmp = RREG32(AVIVO_D1CRTC_CONTROL + crtc_offsets[i]);
5397 - if (!(tmp & AVIVO_CRTC_DISP_READ_REQUEST_DISABLE)) {
5398 - radeon_wait_for_vblank(rdev, i);
5399 -+ WREG32(AVIVO_D1CRTC_UPDATE_LOCK + crtc_offsets[i], 1);
5400 - tmp |= AVIVO_CRTC_DISP_READ_REQUEST_DISABLE;
5401 - WREG32(AVIVO_D1CRTC_CONTROL + crtc_offsets[i], tmp);
5402 -+ WREG32(AVIVO_D1CRTC_UPDATE_LOCK + crtc_offsets[i], 0);
5403 - }
5404 - /* wait for the next frame */
5405 - frame_count = radeon_get_vblank_counter(rdev, i);
5406 -@@ -313,6 +315,15 @@ void rv515_mc_stop(struct radeon_device *rdev, struct rv515_mc_save *save)
5407 - break;
5408 - udelay(1);
5409 - }
5410 -+
5411 -+ /* XXX this is a hack to avoid strange behavior with EFI on certain systems */
5412 -+ WREG32(AVIVO_D1CRTC_UPDATE_LOCK + crtc_offsets[i], 1);
5413 -+ tmp = RREG32(AVIVO_D1CRTC_CONTROL + crtc_offsets[i]);
5414 -+ tmp &= ~AVIVO_CRTC_EN;
5415 -+ WREG32(AVIVO_D1CRTC_CONTROL + crtc_offsets[i], tmp);
5416 -+ WREG32(AVIVO_D1CRTC_UPDATE_LOCK + crtc_offsets[i], 0);
5417 -+ save->crtc_enabled[i] = false;
5418 -+ /* ***** */
5419 - } else {
5420 - save->crtc_enabled[i] = false;
5421 - }
5422 -@@ -338,6 +349,22 @@ void rv515_mc_stop(struct radeon_device *rdev, struct rv515_mc_save *save)
5423 - }
5424 - /* wait for the MC to settle */
5425 - udelay(100);
5426 -+
5427 -+ /* lock double buffered regs */
5428 -+ for (i = 0; i < rdev->num_crtc; i++) {
5429 -+ if (save->crtc_enabled[i]) {
5430 -+ tmp = RREG32(AVIVO_D1GRPH_UPDATE + crtc_offsets[i]);
5431 -+ if (!(tmp & AVIVO_D1GRPH_UPDATE_LOCK)) {
5432 -+ tmp |= AVIVO_D1GRPH_UPDATE_LOCK;
5433 -+ WREG32(AVIVO_D1GRPH_UPDATE + crtc_offsets[i], tmp);
5434 -+ }
5435 -+ tmp = RREG32(AVIVO_D1MODE_MASTER_UPDATE_LOCK + crtc_offsets[i]);
5436 -+ if (!(tmp & 1)) {
5437 -+ tmp |= 1;
5438 -+ WREG32(AVIVO_D1MODE_MASTER_UPDATE_LOCK + crtc_offsets[i], tmp);
5439 -+ }
5440 -+ }
5441 -+ }
5442 - }
5443 -
5444 - void rv515_mc_resume(struct radeon_device *rdev, struct rv515_mc_save *save)
5445 -@@ -348,7 +375,7 @@ void rv515_mc_resume(struct radeon_device *rdev, struct rv515_mc_save *save)
5446 - /* update crtc base addresses */
5447 - for (i = 0; i < rdev->num_crtc; i++) {
5448 - if (rdev->family >= CHIP_RV770) {
5449 -- if (i == 1) {
5450 -+ if (i == 0) {
5451 - WREG32(R700_D1GRPH_PRIMARY_SURFACE_ADDRESS_HIGH,
5452 - upper_32_bits(rdev->mc.vram_start));
5453 - WREG32(R700_D1GRPH_SECONDARY_SURFACE_ADDRESS_HIGH,
5454 -@@ -367,6 +394,33 @@ void rv515_mc_resume(struct radeon_device *rdev, struct rv515_mc_save *save)
5455 - }
5456 - WREG32(R_000310_VGA_MEMORY_BASE_ADDRESS, (u32)rdev->mc.vram_start);
5457 -
5458 -+ /* unlock regs and wait for update */
5459 -+ for (i = 0; i < rdev->num_crtc; i++) {
5460 -+ if (save->crtc_enabled[i]) {
5461 -+ tmp = RREG32(AVIVO_D1MODE_MASTER_UPDATE_MODE + crtc_offsets[i]);
5462 -+ if ((tmp & 0x3) != 0) {
5463 -+ tmp &= ~0x3;
5464 -+ WREG32(AVIVO_D1MODE_MASTER_UPDATE_MODE + crtc_offsets[i], tmp);
5465 -+ }
5466 -+ tmp = RREG32(AVIVO_D1GRPH_UPDATE + crtc_offsets[i]);
5467 -+ if (tmp & AVIVO_D1GRPH_UPDATE_LOCK) {
5468 -+ tmp &= ~AVIVO_D1GRPH_UPDATE_LOCK;
5469 -+ WREG32(AVIVO_D1GRPH_UPDATE + crtc_offsets[i], tmp);
5470 -+ }
5471 -+ tmp = RREG32(AVIVO_D1MODE_MASTER_UPDATE_LOCK + crtc_offsets[i]);
5472 -+ if (tmp & 1) {
5473 -+ tmp &= ~1;
5474 -+ WREG32(AVIVO_D1MODE_MASTER_UPDATE_LOCK + crtc_offsets[i], tmp);
5475 -+ }
5476 -+ for (j = 0; j < rdev->usec_timeout; j++) {
5477 -+ tmp = RREG32(AVIVO_D1GRPH_UPDATE + crtc_offsets[i]);
5478 -+ if ((tmp & AVIVO_D1GRPH_SURFACE_UPDATE_PENDING) == 0)
5479 -+ break;
5480 -+ udelay(1);
5481 -+ }
5482 -+ }
5483 -+ }
5484 -+
5485 - if (rdev->family >= CHIP_R600) {
5486 - /* unblackout the MC */
5487 - if (rdev->family >= CHIP_RV770)
5488 -diff --git a/drivers/gpu/drm/radeon/si.c b/drivers/gpu/drm/radeon/si.c
5489 -index bafbe32..3dd7ecc 100644
5490 ---- a/drivers/gpu/drm/radeon/si.c
5491 -+++ b/drivers/gpu/drm/radeon/si.c
5492 -@@ -1463,7 +1463,7 @@ static void si_select_se_sh(struct radeon_device *rdev,
5493 - u32 data = INSTANCE_BROADCAST_WRITES;
5494 -
5495 - if ((se_num == 0xffffffff) && (sh_num == 0xffffffff))
5496 -- data = SH_BROADCAST_WRITES | SE_BROADCAST_WRITES;
5497 -+ data |= SH_BROADCAST_WRITES | SE_BROADCAST_WRITES;
5498 - else if (se_num == 0xffffffff)
5499 - data |= SE_BROADCAST_WRITES | SH_INDEX(sh_num);
5500 - else if (sh_num == 0xffffffff)
5501 -@@ -1765,6 +1765,7 @@ static void si_gpu_init(struct radeon_device *rdev)
5502 -
5503 - WREG32(GB_ADDR_CONFIG, gb_addr_config);
5504 - WREG32(DMIF_ADDR_CONFIG, gb_addr_config);
5505 -+ WREG32(DMIF_ADDR_CALC, gb_addr_config);
5506 - WREG32(HDP_ADDR_CONFIG, gb_addr_config);
5507 - WREG32(DMA_TILING_CONFIG + DMA0_REGISTER_OFFSET, gb_addr_config);
5508 - WREG32(DMA_TILING_CONFIG + DMA1_REGISTER_OFFSET, gb_addr_config);
5509 -diff --git a/drivers/gpu/drm/radeon/sid.h b/drivers/gpu/drm/radeon/sid.h
5510 -index 23fc08f..f84cff0 100644
5511 ---- a/drivers/gpu/drm/radeon/sid.h
5512 -+++ b/drivers/gpu/drm/radeon/sid.h
5513 -@@ -65,6 +65,8 @@
5514 -
5515 - #define DMIF_ADDR_CONFIG 0xBD4
5516 -
5517 -+#define DMIF_ADDR_CALC 0xC00
5518 -+
5519 - #define SRBM_STATUS 0xE50
5520 - #define GRBM_RQ_PENDING (1 << 5)
5521 - #define VMC_BUSY (1 << 8)
5522 -diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
5523 -index c5b592d..bfac582 100644
5524 ---- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
5525 -+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
5526 -@@ -75,7 +75,7 @@ static int modeset_init(struct drm_device *dev)
5527 - mod->funcs->modeset_init(mod, dev);
5528 - }
5529 -
5530 -- if ((priv->num_encoders = 0) || (priv->num_connectors == 0)) {
5531 -+ if ((priv->num_encoders == 0) || (priv->num_connectors == 0)) {
5532 - /* oh nos! */
5533 - dev_err(dev->dev, "no encoders/connectors found\n");
5534 - return -ENXIO;
5535 -diff --git a/drivers/gpu/drm/udl/udl_gem.c b/drivers/gpu/drm/udl/udl_gem.c
5536 -index 3816270..ef034fa 100644
5537 ---- a/drivers/gpu/drm/udl/udl_gem.c
5538 -+++ b/drivers/gpu/drm/udl/udl_gem.c
5539 -@@ -303,6 +303,8 @@ struct drm_gem_object *udl_gem_prime_import(struct drm_device *dev,
5540 - if (IS_ERR(attach))
5541 - return ERR_CAST(attach);
5542 -
5543 -+ get_dma_buf(dma_buf);
5544 -+
5545 - sg = dma_buf_map_attachment(attach, DMA_BIDIRECTIONAL);
5546 - if (IS_ERR(sg)) {
5547 - ret = PTR_ERR(sg);
5548 -@@ -322,5 +324,7 @@ fail_unmap:
5549 - dma_buf_unmap_attachment(attach, sg, DMA_BIDIRECTIONAL);
5550 - fail_detach:
5551 - dma_buf_detach(dma_buf, attach);
5552 -+ dma_buf_put(dma_buf);
5553 -+
5554 - return ERR_PTR(ret);
5555 - }
5556 -diff --git a/drivers/infiniband/hw/cxgb4/qp.c b/drivers/infiniband/hw/cxgb4/qp.c
5557 -index 70b1808..ed49ab3 100644
5558 ---- a/drivers/infiniband/hw/cxgb4/qp.c
5559 -+++ b/drivers/infiniband/hw/cxgb4/qp.c
5560 -@@ -100,6 +100,16 @@ static int alloc_host_sq(struct c4iw_rdev *rdev, struct t4_sq *sq)
5561 - return 0;
5562 - }
5563 -
5564 -+static int alloc_sq(struct c4iw_rdev *rdev, struct t4_sq *sq, int user)
5565 -+{
5566 -+ int ret = -ENOSYS;
5567 -+ if (user)
5568 -+ ret = alloc_oc_sq(rdev, sq);
5569 -+ if (ret)
5570 -+ ret = alloc_host_sq(rdev, sq);
5571 -+ return ret;
5572 -+}
5573 -+
5574 - static int destroy_qp(struct c4iw_rdev *rdev, struct t4_wq *wq,
5575 - struct c4iw_dev_ucontext *uctx)
5576 - {
5577 -@@ -168,18 +178,9 @@ static int create_qp(struct c4iw_rdev *rdev, struct t4_wq *wq,
5578 - goto free_sw_rq;
5579 - }
5580 -
5581 -- if (user) {
5582 -- ret = alloc_oc_sq(rdev, &wq->sq);
5583 -- if (ret)
5584 -- goto free_hwaddr;
5585 --
5586 -- ret = alloc_host_sq(rdev, &wq->sq);
5587 -- if (ret)
5588 -- goto free_sq;
5589 -- } else
5590 -- ret = alloc_host_sq(rdev, &wq->sq);
5591 -- if (ret)
5592 -- goto free_hwaddr;
5593 -+ ret = alloc_sq(rdev, &wq->sq, user);
5594 -+ if (ret)
5595 -+ goto free_hwaddr;
5596 - memset(wq->sq.queue, 0, wq->sq.memsize);
5597 - dma_unmap_addr_set(&wq->sq, mapping, wq->sq.dma_addr);
5598 -
5599 -diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
5600 -index b287ca3..cbb1645 100644
5601 ---- a/drivers/iommu/amd_iommu.c
5602 -+++ b/drivers/iommu/amd_iommu.c
5603 -@@ -3947,6 +3947,9 @@ static struct irq_remap_table *get_irq_table(u16 devid, bool ioapic)
5604 - if (!table)
5605 - goto out;
5606 -
5607 -+ /* Initialize table spin-lock */
5608 -+ spin_lock_init(&table->lock);
5609 -+
5610 - if (ioapic)
5611 - /* Keep the first 32 indexes free for IOAPIC interrupts */
5612 - table->min_index = 32;
5613 -diff --git a/drivers/net/ethernet/ibm/ibmveth.c b/drivers/net/ethernet/ibm/ibmveth.c
5614 -index c859771..f46dbef 100644
5615 ---- a/drivers/net/ethernet/ibm/ibmveth.c
5616 -+++ b/drivers/net/ethernet/ibm/ibmveth.c
5617 -@@ -1324,7 +1324,7 @@ static const struct net_device_ops ibmveth_netdev_ops = {
5618 -
5619 - static int ibmveth_probe(struct vio_dev *dev, const struct vio_device_id *id)
5620 - {
5621 -- int rc, i;
5622 -+ int rc, i, mac_len;
5623 - struct net_device *netdev;
5624 - struct ibmveth_adapter *adapter;
5625 - unsigned char *mac_addr_p;
5626 -@@ -1334,11 +1334,19 @@ static int ibmveth_probe(struct vio_dev *dev, const struct vio_device_id *id)
5627 - dev->unit_address);
5628 -
5629 - mac_addr_p = (unsigned char *)vio_get_attribute(dev, VETH_MAC_ADDR,
5630 -- NULL);
5631 -+ &mac_len);
5632 - if (!mac_addr_p) {
5633 - dev_err(&dev->dev, "Can't find VETH_MAC_ADDR attribute\n");
5634 - return -EINVAL;
5635 - }
5636 -+ /* Workaround for old/broken pHyp */
5637 -+ if (mac_len == 8)
5638 -+ mac_addr_p += 2;
5639 -+ else if (mac_len != 6) {
5640 -+ dev_err(&dev->dev, "VETH_MAC_ADDR attribute wrong len %d\n",
5641 -+ mac_len);
5642 -+ return -EINVAL;
5643 -+ }
5644 -
5645 - mcastFilterSize_p = (unsigned int *)vio_get_attribute(dev,
5646 - VETH_MCAST_FILTER_SIZE, NULL);
5647 -@@ -1363,17 +1371,6 @@ static int ibmveth_probe(struct vio_dev *dev, const struct vio_device_id *id)
5648 -
5649 - netif_napi_add(netdev, &adapter->napi, ibmveth_poll, 16);
5650 -
5651 -- /*
5652 -- * Some older boxes running PHYP non-natively have an OF that returns
5653 -- * a 8-byte local-mac-address field (and the first 2 bytes have to be
5654 -- * ignored) while newer boxes' OF return a 6-byte field. Note that
5655 -- * IEEE 1275 specifies that local-mac-address must be a 6-byte field.
5656 -- * The RPA doc specifies that the first byte must be 10b, so we'll
5657 -- * just look for it to solve this 8 vs. 6 byte field issue
5658 -- */
5659 -- if ((*mac_addr_p & 0x3) != 0x02)
5660 -- mac_addr_p += 2;
5661 --
5662 - adapter->mac_addr = 0;
5663 - memcpy(&adapter->mac_addr, mac_addr_p, 6);
5664 -
5665 -diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
5666 -index 4ecbe64..15ba8c4 100644
5667 ---- a/drivers/net/ethernet/realtek/r8169.c
5668 -+++ b/drivers/net/ethernet/realtek/r8169.c
5669 -@@ -5787,6 +5787,14 @@ static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb,
5670 - goto err_stop_0;
5671 - }
5672 -
5673 -+ /* 8168evl does not automatically pad to minimum length. */
5674 -+ if (unlikely(tp->mac_version == RTL_GIGA_MAC_VER_34 &&
5675 -+ skb->len < ETH_ZLEN)) {
5676 -+ if (skb_padto(skb, ETH_ZLEN))
5677 -+ goto err_update_stats;
5678 -+ skb_put(skb, ETH_ZLEN - skb->len);
5679 -+ }
5680 -+
5681 - if (unlikely(le32_to_cpu(txd->opts1) & DescOwn))
5682 - goto err_stop_0;
5683 -
5684 -@@ -5858,6 +5866,7 @@ err_dma_1:
5685 - rtl8169_unmap_tx_skb(d, tp->tx_skb + entry, txd);
5686 - err_dma_0:
5687 - dev_kfree_skb(skb);
5688 -+err_update_stats:
5689 - dev->stats.tx_dropped++;
5690 - return NETDEV_TX_OK;
5691 -
5692 -diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c
5693 -index 57136dc..299c53b 100644
5694 ---- a/drivers/net/usb/cdc_ether.c
5695 -+++ b/drivers/net/usb/cdc_ether.c
5696 -@@ -615,6 +615,13 @@ static const struct usb_device_id products [] = {
5697 - .driver_info = 0,
5698 - },
5699 -
5700 -+/* Dell Wireless 5804 (Novatel E371) - handled by qmi_wwan */
5701 -+{
5702 -+ USB_DEVICE_AND_INTERFACE_INFO(DELL_VENDOR_ID, 0x819b, USB_CLASS_COMM,
5703 -+ USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE),
5704 -+ .driver_info = 0,
5705 -+},
5706 -+
5707 - /* AnyDATA ADU960S - handled by qmi_wwan */
5708 - {
5709 - USB_DEVICE_AND_INTERFACE_INFO(0x16d5, 0x650a, USB_CLASS_COMM,
5710 -diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c
5711 -index 2a3579f..a7cafe4 100644
5712 ---- a/drivers/net/usb/qmi_wwan.c
5713 -+++ b/drivers/net/usb/qmi_wwan.c
5714 -@@ -496,6 +496,13 @@ static const struct usb_device_id products[] = {
5715 - USB_CDC_PROTO_NONE),
5716 - .driver_info = (unsigned long)&qmi_wwan_info,
5717 - },
5718 -+ { /* Dell Wireless 5804 (Novatel E371) */
5719 -+ USB_DEVICE_AND_INTERFACE_INFO(0x413C, 0x819b,
5720 -+ USB_CLASS_COMM,
5721 -+ USB_CDC_SUBCLASS_ETHERNET,
5722 -+ USB_CDC_PROTO_NONE),
5723 -+ .driver_info = (unsigned long)&qmi_wwan_info,
5724 -+ },
5725 - { /* ADU960S */
5726 - USB_DEVICE_AND_INTERFACE_INFO(0x16d5, 0x650a,
5727 - USB_CLASS_COMM,
5728 -diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c
5729 -index 8647dc6..f9c61fb 100644
5730 ---- a/drivers/pci/bus.c
5731 -+++ b/drivers/pci/bus.c
5732 -@@ -174,6 +174,7 @@ int pci_bus_add_device(struct pci_dev *dev)
5733 - * Can not put in pci_device_add yet because resources
5734 - * are not assigned yet for some devices.
5735 - */
5736 -+ pci_fixup_device(pci_fixup_final, dev);
5737 - pci_create_sysfs_dev_files(dev);
5738 -
5739 - dev->match_driver = true;
5740 -diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
5741 -index b494066..5427787 100644
5742 ---- a/drivers/pci/probe.c
5743 -+++ b/drivers/pci/probe.c
5744 -@@ -1339,7 +1339,6 @@ void pci_device_add(struct pci_dev *dev, struct pci_bus *bus)
5745 - list_add_tail(&dev->bus_list, &bus->devices);
5746 - up_write(&pci_bus_sem);
5747 -
5748 -- pci_fixup_device(pci_fixup_final, dev);
5749 - ret = pcibios_add_device(dev);
5750 - WARN_ON(ret < 0);
5751 -
5752 -diff --git a/drivers/pwm/pwm-spear.c b/drivers/pwm/pwm-spear.c
5753 -index 69a2d9e..3223b57 100644
5754 ---- a/drivers/pwm/pwm-spear.c
5755 -+++ b/drivers/pwm/pwm-spear.c
5756 -@@ -143,7 +143,7 @@ static int spear_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
5757 - u32 val;
5758 -
5759 - rc = clk_enable(pc->clk);
5760 -- if (!rc)
5761 -+ if (rc)
5762 - return rc;
5763 -
5764 - val = spear_pwm_readl(pc, pwm->hwpwm, PWMCR);
5765 -@@ -209,12 +209,12 @@ static int spear_pwm_probe(struct platform_device *pdev)
5766 - pc->chip.npwm = NUM_PWM;
5767 -
5768 - ret = clk_prepare(pc->clk);
5769 -- if (!ret)
5770 -+ if (ret)
5771 - return ret;
5772 -
5773 - if (of_device_is_compatible(np, "st,spear1340-pwm")) {
5774 - ret = clk_enable(pc->clk);
5775 -- if (!ret) {
5776 -+ if (ret) {
5777 - clk_unprepare(pc->clk);
5778 - return ret;
5779 - }
5780 -diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig
5781 -index c6d77e2..be6e121 100644
5782 ---- a/drivers/remoteproc/Kconfig
5783 -+++ b/drivers/remoteproc/Kconfig
5784 -@@ -6,6 +6,7 @@ config REMOTEPROC
5785 - depends on HAS_DMA
5786 - select FW_LOADER
5787 - select VIRTIO
5788 -+ select VIRTUALIZATION
5789 -
5790 - config OMAP_REMOTEPROC
5791 - tristate "OMAP remoteproc support"
5792 -diff --git a/drivers/rpmsg/Kconfig b/drivers/rpmsg/Kconfig
5793 -index f6e0ea6..69a2193 100644
5794 ---- a/drivers/rpmsg/Kconfig
5795 -+++ b/drivers/rpmsg/Kconfig
5796 -@@ -4,5 +4,6 @@ menu "Rpmsg drivers"
5797 - config RPMSG
5798 - tristate
5799 - select VIRTIO
5800 -+ select VIRTUALIZATION
5801 -
5802 - endmenu
5803 -diff --git a/fs/autofs4/expire.c b/fs/autofs4/expire.c
5804 -index 01443ce..13ddec9 100644
5805 ---- a/fs/autofs4/expire.c
5806 -+++ b/fs/autofs4/expire.c
5807 -@@ -61,15 +61,6 @@ static int autofs4_mount_busy(struct vfsmount *mnt, struct dentry *dentry)
5808 - /* This is an autofs submount, we can't expire it */
5809 - if (autofs_type_indirect(sbi->type))
5810 - goto done;
5811 --
5812 -- /*
5813 -- * Otherwise it's an offset mount and we need to check
5814 -- * if we can umount its mount, if there is one.
5815 -- */
5816 -- if (!d_mountpoint(path.dentry)) {
5817 -- status = 0;
5818 -- goto done;
5819 -- }
5820 - }
5821 -
5822 - /* Update the expiry counter if fs is busy */
5823 -diff --git a/fs/btrfs/delayed-ref.c b/fs/btrfs/delayed-ref.c
5824 -index b7a0641..116abec 100644
5825 ---- a/fs/btrfs/delayed-ref.c
5826 -+++ b/fs/btrfs/delayed-ref.c
5827 -@@ -40,16 +40,19 @@ struct kmem_cache *btrfs_delayed_extent_op_cachep;
5828 - * compare two delayed tree backrefs with same bytenr and type
5829 - */
5830 - static int comp_tree_refs(struct btrfs_delayed_tree_ref *ref2,
5831 -- struct btrfs_delayed_tree_ref *ref1)
5832 -+ struct btrfs_delayed_tree_ref *ref1, int type)
5833 - {
5834 -- if (ref1->root < ref2->root)
5835 -- return -1;
5836 -- if (ref1->root > ref2->root)
5837 -- return 1;
5838 -- if (ref1->parent < ref2->parent)
5839 -- return -1;
5840 -- if (ref1->parent > ref2->parent)
5841 -- return 1;
5842 -+ if (type == BTRFS_TREE_BLOCK_REF_KEY) {
5843 -+ if (ref1->root < ref2->root)
5844 -+ return -1;
5845 -+ if (ref1->root > ref2->root)
5846 -+ return 1;
5847 -+ } else {
5848 -+ if (ref1->parent < ref2->parent)
5849 -+ return -1;
5850 -+ if (ref1->parent > ref2->parent)
5851 -+ return 1;
5852 -+ }
5853 - return 0;
5854 - }
5855 -
5856 -@@ -113,7 +116,8 @@ static int comp_entry(struct btrfs_delayed_ref_node *ref2,
5857 - if (ref1->type == BTRFS_TREE_BLOCK_REF_KEY ||
5858 - ref1->type == BTRFS_SHARED_BLOCK_REF_KEY) {
5859 - return comp_tree_refs(btrfs_delayed_node_to_tree_ref(ref2),
5860 -- btrfs_delayed_node_to_tree_ref(ref1));
5861 -+ btrfs_delayed_node_to_tree_ref(ref1),
5862 -+ ref1->type);
5863 - } else if (ref1->type == BTRFS_EXTENT_DATA_REF_KEY ||
5864 - ref1->type == BTRFS_SHARED_DATA_REF_KEY) {
5865 - return comp_data_refs(btrfs_delayed_node_to_data_ref(ref2),
5866 -diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
5867 -index 09c58a3..cc6ce3e 100644
5868 ---- a/fs/btrfs/inode.c
5869 -+++ b/fs/btrfs/inode.c
5870 -@@ -6502,7 +6502,9 @@ out:
5871 - * block must be cow'd
5872 - */
5873 - static noinline int can_nocow_odirect(struct btrfs_trans_handle *trans,
5874 -- struct inode *inode, u64 offset, u64 len)
5875 -+ struct inode *inode, u64 offset, u64 *len,
5876 -+ u64 *orig_start, u64 *orig_block_len,
5877 -+ u64 *ram_bytes)
5878 - {
5879 - struct btrfs_path *path;
5880 - int ret;
5881 -@@ -6559,8 +6561,12 @@ static noinline int can_nocow_odirect(struct btrfs_trans_handle *trans,
5882 - disk_bytenr = btrfs_file_extent_disk_bytenr(leaf, fi);
5883 - backref_offset = btrfs_file_extent_offset(leaf, fi);
5884 -
5885 -+ *orig_start = key.offset - backref_offset;
5886 -+ *orig_block_len = btrfs_file_extent_disk_num_bytes(leaf, fi);
5887 -+ *ram_bytes = btrfs_file_extent_ram_bytes(leaf, fi);
5888 -+
5889 - extent_end = key.offset + btrfs_file_extent_num_bytes(leaf, fi);
5890 -- if (extent_end < offset + len) {
5891 -+ if (extent_end < offset + *len) {
5892 - /* extent doesn't include our full range, must cow */
5893 - goto out;
5894 - }
5895 -@@ -6584,13 +6590,14 @@ static noinline int can_nocow_odirect(struct btrfs_trans_handle *trans,
5896 - */
5897 - disk_bytenr += backref_offset;
5898 - disk_bytenr += offset - key.offset;
5899 -- num_bytes = min(offset + len, extent_end) - offset;
5900 -+ num_bytes = min(offset + *len, extent_end) - offset;
5901 - if (csum_exist_in_range(root, disk_bytenr, num_bytes))
5902 - goto out;
5903 - /*
5904 - * all of the above have passed, it is safe to overwrite this extent
5905 - * without cow
5906 - */
5907 -+ *len = num_bytes;
5908 - ret = 1;
5909 - out:
5910 - btrfs_free_path(path);
5911 -@@ -6789,7 +6796,7 @@ static int btrfs_get_blocks_direct(struct inode *inode, sector_t iblock,
5912 - em->block_start != EXTENT_MAP_HOLE)) {
5913 - int type;
5914 - int ret;
5915 -- u64 block_start;
5916 -+ u64 block_start, orig_start, orig_block_len, ram_bytes;
5917 -
5918 - if (test_bit(EXTENT_FLAG_PREALLOC, &em->flags))
5919 - type = BTRFS_ORDERED_PREALLOC;
5920 -@@ -6807,10 +6814,8 @@ static int btrfs_get_blocks_direct(struct inode *inode, sector_t iblock,
5921 - if (IS_ERR(trans))
5922 - goto must_cow;
5923 -
5924 -- if (can_nocow_odirect(trans, inode, start, len) == 1) {
5925 -- u64 orig_start = em->orig_start;
5926 -- u64 orig_block_len = em->orig_block_len;
5927 --
5928 -+ if (can_nocow_odirect(trans, inode, start, &len, &orig_start,
5929 -+ &orig_block_len, &ram_bytes) == 1) {
5930 - if (type == BTRFS_ORDERED_PREALLOC) {
5931 - free_extent_map(em);
5932 - em = create_pinned_em(inode, start, len,
5933 -diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
5934 -index 1357260..3beae6a 100644
5935 ---- a/fs/ext4/resize.c
5936 -+++ b/fs/ext4/resize.c
5937 -@@ -1882,6 +1882,10 @@ retry:
5938 - return 0;
5939 -
5940 - ext4_get_group_no_and_offset(sb, n_blocks_count - 1, &n_group, &offset);
5941 -+ if (n_group > (0xFFFFFFFFUL / EXT4_INODES_PER_GROUP(sb))) {
5942 -+ ext4_warning(sb, "resize would cause inodes_count overflow");
5943 -+ return -EINVAL;
5944 -+ }
5945 - ext4_get_group_no_and_offset(sb, o_blocks_count - 1, &o_group, &offset);
5946 -
5947 - n_desc_blocks = num_desc_blocks(sb, n_group + 1);
5948 -diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
5949 -index 523464e..a3f868a 100644
5950 ---- a/fs/hugetlbfs/inode.c
5951 -+++ b/fs/hugetlbfs/inode.c
5952 -@@ -909,11 +909,8 @@ static int can_do_hugetlb_shm(void)
5953 -
5954 - static int get_hstate_idx(int page_size_log)
5955 - {
5956 -- struct hstate *h;
5957 -+ struct hstate *h = hstate_sizelog(page_size_log);
5958 -
5959 -- if (!page_size_log)
5960 -- return default_hstate_idx;
5961 -- h = size_to_hstate(1 << page_size_log);
5962 - if (!h)
5963 - return -1;
5964 - return h - hstates;
5965 -@@ -929,9 +926,12 @@ static struct dentry_operations anon_ops = {
5966 - .d_dname = hugetlb_dname
5967 - };
5968 -
5969 --struct file *hugetlb_file_setup(const char *name, unsigned long addr,
5970 -- size_t size, vm_flags_t acctflag,
5971 -- struct user_struct **user,
5972 -+/*
5973 -+ * Note that size should be aligned to proper hugepage size in caller side,
5974 -+ * otherwise hugetlb_reserve_pages reserves one less hugepages than intended.
5975 -+ */
5976 -+struct file *hugetlb_file_setup(const char *name, size_t size,
5977 -+ vm_flags_t acctflag, struct user_struct **user,
5978 - int creat_flags, int page_size_log)
5979 - {
5980 - struct file *file = ERR_PTR(-ENOMEM);
5981 -@@ -939,8 +939,6 @@ struct file *hugetlb_file_setup(const char *name, unsigned long addr,
5982 - struct path path;
5983 - struct super_block *sb;
5984 - struct qstr quick_string;
5985 -- struct hstate *hstate;
5986 -- unsigned long num_pages;
5987 - int hstate_idx;
5988 -
5989 - hstate_idx = get_hstate_idx(page_size_log);
5990 -@@ -980,12 +978,10 @@ struct file *hugetlb_file_setup(const char *name, unsigned long addr,
5991 - if (!inode)
5992 - goto out_dentry;
5993 -
5994 -- hstate = hstate_inode(inode);
5995 -- size += addr & ~huge_page_mask(hstate);
5996 -- num_pages = ALIGN(size, huge_page_size(hstate)) >>
5997 -- huge_page_shift(hstate);
5998 - file = ERR_PTR(-ENOMEM);
5999 -- if (hugetlb_reserve_pages(inode, 0, num_pages, NULL, acctflag))
6000 -+ if (hugetlb_reserve_pages(inode, 0,
6001 -+ size >> huge_page_shift(hstate_inode(inode)), NULL,
6002 -+ acctflag))
6003 - goto out_inode;
6004 -
6005 - d_instantiate(path.dentry, inode);
6006 -diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
6007 -index c7856a1..0086401 100644
6008 ---- a/fs/nfs/nfs4proc.c
6009 -+++ b/fs/nfs/nfs4proc.c
6010 -@@ -4553,9 +4553,9 @@ static int nfs4_proc_unlck(struct nfs4_state *state, int cmd, struct file_lock *
6011 - if (status != 0)
6012 - goto out;
6013 - /* Is this a delegated lock? */
6014 -- if (test_bit(NFS_DELEGATED_STATE, &state->flags))
6015 -- goto out;
6016 - lsp = request->fl_u.nfs4_fl.owner;
6017 -+ if (test_bit(NFS_LOCK_INITIALIZED, &lsp->ls_flags) == 0)
6018 -+ goto out;
6019 - seqid = nfs_alloc_seqid(&lsp->ls_seqid, GFP_KERNEL);
6020 - status = -ENOMEM;
6021 - if (seqid == NULL)
6022 -diff --git a/include/drm/drmP.h b/include/drm/drmP.h
6023 -index 2d94d74..f1ce786 100644
6024 ---- a/include/drm/drmP.h
6025 -+++ b/include/drm/drmP.h
6026 -@@ -1593,9 +1593,8 @@ extern void drm_prime_gem_destroy(struct drm_gem_object *obj, struct sg_table *s
6027 -
6028 - void drm_prime_init_file_private(struct drm_prime_file_private *prime_fpriv);
6029 - void drm_prime_destroy_file_private(struct drm_prime_file_private *prime_fpriv);
6030 --int drm_prime_add_imported_buf_handle(struct drm_prime_file_private *prime_fpriv, struct dma_buf *dma_buf, uint32_t handle);
6031 --int drm_prime_lookup_imported_buf_handle(struct drm_prime_file_private *prime_fpriv, struct dma_buf *dma_buf, uint32_t *handle);
6032 --void drm_prime_remove_imported_buf_handle(struct drm_prime_file_private *prime_fpriv, struct dma_buf *dma_buf);
6033 -+int drm_prime_lookup_buf_handle(struct drm_prime_file_private *prime_fpriv, struct dma_buf *dma_buf, uint32_t *handle);
6034 -+void drm_prime_remove_buf_handle(struct drm_prime_file_private *prime_fpriv, struct dma_buf *dma_buf);
6035 -
6036 - int drm_prime_add_dma_buf(struct drm_device *dev, struct drm_gem_object *obj);
6037 - int drm_prime_lookup_obj(struct drm_device *dev, struct dma_buf *buf,
6038 -diff --git a/include/drm/drm_pciids.h b/include/drm/drm_pciids.h
6039 -index 918e8fe..c2af598 100644
6040 ---- a/include/drm/drm_pciids.h
6041 -+++ b/include/drm/drm_pciids.h
6042 -@@ -240,6 +240,7 @@
6043 - {0x1002, 0x6819, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PITCAIRN|RADEON_NEW_MEMMAP}, \
6044 - {0x1002, 0x6820, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
6045 - {0x1002, 0x6821, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
6046 -+ {0x1002, 0x6822, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
6047 - {0x1002, 0x6823, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
6048 - {0x1002, 0x6824, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
6049 - {0x1002, 0x6825, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
6050 -@@ -247,11 +248,13 @@
6051 - {0x1002, 0x6827, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
6052 - {0x1002, 0x6828, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_NEW_MEMMAP}, \
6053 - {0x1002, 0x6829, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_NEW_MEMMAP}, \
6054 -+ {0x1002, 0x682A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
6055 - {0x1002, 0x682B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
6056 - {0x1002, 0x682D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
6057 - {0x1002, 0x682F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
6058 - {0x1002, 0x6830, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
6059 - {0x1002, 0x6831, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
6060 -+ {0x1002, 0x6835, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_NEW_MEMMAP}, \
6061 - {0x1002, 0x6837, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_NEW_MEMMAP}, \
6062 - {0x1002, 0x6838, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_NEW_MEMMAP}, \
6063 - {0x1002, 0x6839, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_VERDE|RADEON_NEW_MEMMAP}, \
6064 -@@ -603,6 +606,8 @@
6065 - {0x1002, 0x9999, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_ARUBA|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
6066 - {0x1002, 0x999A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_ARUBA|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
6067 - {0x1002, 0x999B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_ARUBA|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
6068 -+ {0x1002, 0x999C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_ARUBA|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
6069 -+ {0x1002, 0x999D, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_ARUBA|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
6070 - {0x1002, 0x99A0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_ARUBA|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
6071 - {0x1002, 0x99A2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_ARUBA|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
6072 - {0x1002, 0x99A4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_ARUBA|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
6073 -diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
6074 -index 78feda9..33f358f 100644
6075 ---- a/include/linux/blkdev.h
6076 -+++ b/include/linux/blkdev.h
6077 -@@ -838,7 +838,7 @@ static inline unsigned int blk_queue_get_max_sectors(struct request_queue *q,
6078 - unsigned int cmd_flags)
6079 - {
6080 - if (unlikely(cmd_flags & REQ_DISCARD))
6081 -- return q->limits.max_discard_sectors;
6082 -+ return min(q->limits.max_discard_sectors, UINT_MAX >> 9);
6083 -
6084 - if (unlikely(cmd_flags & REQ_WRITE_SAME))
6085 - return q->limits.max_write_same_sectors;
6086 -diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
6087 -index 16e4e9a..df1ff7c 100644
6088 ---- a/include/linux/hugetlb.h
6089 -+++ b/include/linux/hugetlb.h
6090 -@@ -185,8 +185,7 @@ static inline struct hugetlbfs_sb_info *HUGETLBFS_SB(struct super_block *sb)
6091 -
6092 - extern const struct file_operations hugetlbfs_file_operations;
6093 - extern const struct vm_operations_struct hugetlb_vm_ops;
6094 --struct file *hugetlb_file_setup(const char *name, unsigned long addr,
6095 -- size_t size, vm_flags_t acct,
6096 -+struct file *hugetlb_file_setup(const char *name, size_t size, vm_flags_t acct,
6097 - struct user_struct **user, int creat_flags,
6098 - int page_size_log);
6099 -
6100 -@@ -205,8 +204,8 @@ static inline int is_file_hugepages(struct file *file)
6101 -
6102 - #define is_file_hugepages(file) 0
6103 - static inline struct file *
6104 --hugetlb_file_setup(const char *name, unsigned long addr, size_t size,
6105 -- vm_flags_t acctflag, struct user_struct **user, int creat_flags,
6106 -+hugetlb_file_setup(const char *name, size_t size, vm_flags_t acctflag,
6107 -+ struct user_struct **user, int creat_flags,
6108 - int page_size_log)
6109 - {
6110 - return ERR_PTR(-ENOSYS);
6111 -@@ -284,6 +283,13 @@ static inline struct hstate *hstate_file(struct file *f)
6112 - return hstate_inode(file_inode(f));
6113 - }
6114 -
6115 -+static inline struct hstate *hstate_sizelog(int page_size_log)
6116 -+{
6117 -+ if (!page_size_log)
6118 -+ return &default_hstate;
6119 -+ return size_to_hstate(1 << page_size_log);
6120 -+}
6121 -+
6122 - static inline struct hstate *hstate_vma(struct vm_area_struct *vma)
6123 - {
6124 - return hstate_file(vma->vm_file);
6125 -@@ -348,11 +354,12 @@ static inline int hstate_index(struct hstate *h)
6126 - return h - hstates;
6127 - }
6128 -
6129 --#else
6130 -+#else /* CONFIG_HUGETLB_PAGE */
6131 - struct hstate {};
6132 - #define alloc_huge_page_node(h, nid) NULL
6133 - #define alloc_bootmem_huge_page(h) NULL
6134 - #define hstate_file(f) NULL
6135 -+#define hstate_sizelog(s) NULL
6136 - #define hstate_vma(v) NULL
6137 - #define hstate_inode(i) NULL
6138 - #define huge_page_size(h) PAGE_SIZE
6139 -@@ -367,6 +374,6 @@ static inline unsigned int pages_per_huge_page(struct hstate *h)
6140 - }
6141 - #define hstate_index_to_shift(index) 0
6142 - #define hstate_index(h) 0
6143 --#endif
6144 -+#endif /* CONFIG_HUGETLB_PAGE */
6145 -
6146 - #endif /* _LINUX_HUGETLB_H */
6147 -diff --git a/ipc/shm.c b/ipc/shm.c
6148 -index 8247c49..34af1fe 100644
6149 ---- a/ipc/shm.c
6150 -+++ b/ipc/shm.c
6151 -@@ -491,10 +491,14 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
6152 -
6153 - sprintf (name, "SYSV%08x", key);
6154 - if (shmflg & SHM_HUGETLB) {
6155 -+ struct hstate *hs = hstate_sizelog((shmflg >> SHM_HUGE_SHIFT)
6156 -+ & SHM_HUGE_MASK);
6157 -+ size_t hugesize = ALIGN(size, huge_page_size(hs));
6158 -+
6159 - /* hugetlb_file_setup applies strict accounting */
6160 - if (shmflg & SHM_NORESERVE)
6161 - acctflag = VM_NORESERVE;
6162 -- file = hugetlb_file_setup(name, 0, size, acctflag,
6163 -+ file = hugetlb_file_setup(name, hugesize, acctflag,
6164 - &shp->mlock_user, HUGETLB_SHMFS_INODE,
6165 - (shmflg >> SHM_HUGE_SHIFT) & SHM_HUGE_MASK);
6166 - } else {
6167 -diff --git a/kernel/Makefile b/kernel/Makefile
6168 -index bbde5f1..5a51e6c 100644
6169 ---- a/kernel/Makefile
6170 -+++ b/kernel/Makefile
6171 -@@ -175,7 +175,7 @@ signing_key.priv signing_key.x509: x509.genkey
6172 - openssl req -new -nodes -utf8 -$(CONFIG_MODULE_SIG_HASH) -days 36500 \
6173 - -batch -x509 -config x509.genkey \
6174 - -outform DER -out signing_key.x509 \
6175 -- -keyout signing_key.priv
6176 -+ -keyout signing_key.priv 2>&1
6177 - @echo "###"
6178 - @echo "### Key pair generated."
6179 - @echo "###"
6180 -diff --git a/kernel/audit_tree.c b/kernel/audit_tree.c
6181 -index 642a89c..a291aa2 100644
6182 ---- a/kernel/audit_tree.c
6183 -+++ b/kernel/audit_tree.c
6184 -@@ -617,9 +617,9 @@ void audit_trim_trees(void)
6185 - }
6186 - spin_unlock(&hash_lock);
6187 - trim_marked(tree);
6188 -- put_tree(tree);
6189 - drop_collected_mounts(root_mnt);
6190 - skip_it:
6191 -+ put_tree(tree);
6192 - mutex_lock(&audit_filter_mutex);
6193 - }
6194 - list_del(&cursor);
6195 -diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
6196 -index 7713d1b..3f28192 100644
6197 ---- a/kernel/trace/trace.c
6198 -+++ b/kernel/trace/trace.c
6199 -@@ -5168,36 +5168,32 @@ void trace_init_global_iter(struct trace_iterator *iter)
6200 - iter->cpu_file = TRACE_PIPE_ALL_CPU;
6201 - }
6202 -
6203 --static void
6204 --__ftrace_dump(bool disable_tracing, enum ftrace_dump_mode oops_dump_mode)
6205 -+void ftrace_dump(enum ftrace_dump_mode oops_dump_mode)
6206 - {
6207 -- static arch_spinlock_t ftrace_dump_lock =
6208 -- (arch_spinlock_t)__ARCH_SPIN_LOCK_UNLOCKED;
6209 - /* use static because iter can be a bit big for the stack */
6210 - static struct trace_iterator iter;
6211 -+ static atomic_t dump_running;
6212 - unsigned int old_userobj;
6213 -- static int dump_ran;
6214 - unsigned long flags;
6215 - int cnt = 0, cpu;
6216 -
6217 -- /* only one dump */
6218 -- local_irq_save(flags);
6219 -- arch_spin_lock(&ftrace_dump_lock);
6220 -- if (dump_ran)
6221 -- goto out;
6222 --
6223 -- dump_ran = 1;
6224 -+ /* Only allow one dump user at a time. */
6225 -+ if (atomic_inc_return(&dump_running) != 1) {
6226 -+ atomic_dec(&dump_running);
6227 -+ return;
6228 -+ }
6229 -
6230 -+ /*
6231 -+ * Always turn off tracing when we dump.
6232 -+ * We don't need to show trace output of what happens
6233 -+ * between multiple crashes.
6234 -+ *
6235 -+ * If the user does a sysrq-z, then they can re-enable
6236 -+ * tracing with echo 1 > tracing_on.
6237 -+ */
6238 - tracing_off();
6239 -
6240 -- /* Did function tracer already get disabled? */
6241 -- if (ftrace_is_dead()) {
6242 -- printk("# WARNING: FUNCTION TRACING IS CORRUPTED\n");
6243 -- printk("# MAY BE MISSING FUNCTION EVENTS\n");
6244 -- }
6245 --
6246 -- if (disable_tracing)
6247 -- ftrace_kill();
6248 -+ local_irq_save(flags);
6249 -
6250 - /* Simulate the iterator */
6251 - trace_init_global_iter(&iter);
6252 -@@ -5227,6 +5223,12 @@ __ftrace_dump(bool disable_tracing, enum ftrace_dump_mode oops_dump_mode)
6253 -
6254 - printk(KERN_TRACE "Dumping ftrace buffer:\n");
6255 -
6256 -+ /* Did function tracer already get disabled? */
6257 -+ if (ftrace_is_dead()) {
6258 -+ printk("# WARNING: FUNCTION TRACING IS CORRUPTED\n");
6259 -+ printk("# MAY BE MISSING FUNCTION EVENTS\n");
6260 -+ }
6261 -+
6262 - /*
6263 - * We need to stop all tracing on all CPUS to read the
6264 - * the next buffer. This is a bit expensive, but is
6265 -@@ -5266,26 +5268,14 @@ __ftrace_dump(bool disable_tracing, enum ftrace_dump_mode oops_dump_mode)
6266 - printk(KERN_TRACE "---------------------------------\n");
6267 -
6268 - out_enable:
6269 -- /* Re-enable tracing if requested */
6270 -- if (!disable_tracing) {
6271 -- trace_flags |= old_userobj;
6272 -+ trace_flags |= old_userobj;
6273 -
6274 -- for_each_tracing_cpu(cpu) {
6275 -- atomic_dec(&iter.tr->data[cpu]->disabled);
6276 -- }
6277 -- tracing_on();
6278 -+ for_each_tracing_cpu(cpu) {
6279 -+ atomic_dec(&iter.tr->data[cpu]->disabled);
6280 - }
6281 --
6282 -- out:
6283 -- arch_spin_unlock(&ftrace_dump_lock);
6284 -+ atomic_dec(&dump_running);
6285 - local_irq_restore(flags);
6286 - }
6287 --
6288 --/* By default: disable tracing after the dump */
6289 --void ftrace_dump(enum ftrace_dump_mode oops_dump_mode)
6290 --{
6291 -- __ftrace_dump(true, oops_dump_mode);
6292 --}
6293 - EXPORT_SYMBOL_GPL(ftrace_dump);
6294 -
6295 - __init static int tracer_alloc_buffers(void)
6296 -diff --git a/kernel/trace/trace_selftest.c b/kernel/trace/trace_selftest.c
6297 -index 51c819c..eedc297 100644
6298 ---- a/kernel/trace/trace_selftest.c
6299 -+++ b/kernel/trace/trace_selftest.c
6300 -@@ -703,8 +703,6 @@ trace_selftest_startup_function(struct tracer *trace, struct trace_array *tr)
6301 - /* Maximum number of functions to trace before diagnosing a hang */
6302 - #define GRAPH_MAX_FUNC_TEST 100000000
6303 -
6304 --static void
6305 --__ftrace_dump(bool disable_tracing, enum ftrace_dump_mode oops_dump_mode);
6306 - static unsigned int graph_hang_thresh;
6307 -
6308 - /* Wrap the real function entry probe to avoid possible hanging */
6309 -@@ -714,8 +712,11 @@ static int trace_graph_entry_watchdog(struct ftrace_graph_ent *trace)
6310 - if (unlikely(++graph_hang_thresh > GRAPH_MAX_FUNC_TEST)) {
6311 - ftrace_graph_stop();
6312 - printk(KERN_WARNING "BUG: Function graph tracer hang!\n");
6313 -- if (ftrace_dump_on_oops)
6314 -- __ftrace_dump(false, DUMP_ALL);
6315 -+ if (ftrace_dump_on_oops) {
6316 -+ ftrace_dump(DUMP_ALL);
6317 -+ /* ftrace_dump() disables tracing */
6318 -+ tracing_on();
6319 -+ }
6320 - return 0;
6321 - }
6322 -
6323 -diff --git a/mm/mmap.c b/mm/mmap.c
6324 -index 033094b..e17fc06 100644
6325 ---- a/mm/mmap.c
6326 -+++ b/mm/mmap.c
6327 -@@ -1327,15 +1327,20 @@ SYSCALL_DEFINE6(mmap_pgoff, unsigned long, addr, unsigned long, len,
6328 - file = fget(fd);
6329 - if (!file)
6330 - goto out;
6331 -+ if (is_file_hugepages(file))
6332 -+ len = ALIGN(len, huge_page_size(hstate_file(file)));
6333 - } else if (flags & MAP_HUGETLB) {
6334 - struct user_struct *user = NULL;
6335 -+
6336 -+ len = ALIGN(len, huge_page_size(hstate_sizelog(
6337 -+ (flags >> MAP_HUGE_SHIFT) & MAP_HUGE_MASK)));
6338 - /*
6339 - * VM_NORESERVE is used because the reservations will be
6340 - * taken when vm_ops->mmap() is called
6341 - * A dummy user value is used because we are not locking
6342 - * memory so no accounting is necessary
6343 - */
6344 -- file = hugetlb_file_setup(HUGETLB_ANON_FILE, addr, len,
6345 -+ file = hugetlb_file_setup(HUGETLB_ANON_FILE, len,
6346 - VM_NORESERVE,
6347 - &user, HUGETLB_ANONHUGE_INODE,
6348 - (flags >> MAP_HUGE_SHIFT) & MAP_HUGE_MASK);
6349 -diff --git a/net/netfilter/ipvs/ip_vs_pe_sip.c b/net/netfilter/ipvs/ip_vs_pe_sip.c
6350 -index 12475ef..e5920fb 100644
6351 ---- a/net/netfilter/ipvs/ip_vs_pe_sip.c
6352 -+++ b/net/netfilter/ipvs/ip_vs_pe_sip.c
6353 -@@ -37,14 +37,10 @@ static int get_callid(const char *dptr, unsigned int dataoff,
6354 - if (ret > 0)
6355 - break;
6356 - if (!ret)
6357 -- return 0;
6358 -+ return -EINVAL;
6359 - dataoff += *matchoff;
6360 - }
6361 -
6362 -- /* Empty callid is useless */
6363 -- if (!*matchlen)
6364 -- return -EINVAL;
6365 --
6366 - /* Too large is useless */
6367 - if (*matchlen > IP_VS_PEDATA_MAXLEN)
6368 - return -EINVAL;
6369 -diff --git a/scripts/kconfig/list.h b/scripts/kconfig/list.h
6370 -index 0ae730b..b87206c 100644
6371 ---- a/scripts/kconfig/list.h
6372 -+++ b/scripts/kconfig/list.h
6373 -@@ -51,6 +51,19 @@ struct list_head {
6374 - pos = list_entry(pos->member.next, typeof(*pos), member))
6375 -
6376 - /**
6377 -+ * list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
6378 -+ * @pos: the type * to use as a loop cursor.
6379 -+ * @n: another type * to use as temporary storage
6380 -+ * @head: the head for your list.
6381 -+ * @member: the name of the list_struct within the struct.
6382 -+ */
6383 -+#define list_for_each_entry_safe(pos, n, head, member) \
6384 -+ for (pos = list_entry((head)->next, typeof(*pos), member), \
6385 -+ n = list_entry(pos->member.next, typeof(*pos), member); \
6386 -+ &pos->member != (head); \
6387 -+ pos = n, n = list_entry(n->member.next, typeof(*n), member))
6388 -+
6389 -+/**
6390 - * list_empty - tests whether a list is empty
6391 - * @head: the list to test.
6392 - */
6393 -diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c
6394 -index 566288a..c5418d6 100644
6395 ---- a/scripts/kconfig/mconf.c
6396 -+++ b/scripts/kconfig/mconf.c
6397 -@@ -389,6 +389,7 @@ again:
6398 - .targets = targets,
6399 - .keys = keys,
6400 - };
6401 -+ struct jump_key *pos, *tmp;
6402 -
6403 - res = get_relations_str(sym_arr, &head);
6404 - dres = show_textbox_ext(_("Search Results"), (char *)
6405 -@@ -402,6 +403,8 @@ again:
6406 - again = true;
6407 - }
6408 - str_free(&res);
6409 -+ list_for_each_entry_safe(pos, tmp, &head, entries)
6410 -+ free(pos);
6411 - } while (again);
6412 - free(sym_arr);
6413 - str_free(&title);
6414
6415 Deleted: genpatches-2.6/trunk/3.10/1002_linux-3.9.3.patch
6416 ===================================================================
6417 --- genpatches-2.6/trunk/3.10/1002_linux-3.9.3.patch 2013-05-21 00:40:11 UTC (rev 2385)
6418 +++ genpatches-2.6/trunk/3.10/1002_linux-3.9.3.patch 2013-05-21 00:44:32 UTC (rev 2386)
6419 @@ -1,3755 +0,0 @@
6420 -diff --git a/Makefile b/Makefile
6421 -index 3e71511..01003d4 100644
6422 ---- a/Makefile
6423 -+++ b/Makefile
6424 -@@ -1,6 +1,6 @@
6425 - VERSION = 3
6426 - PATCHLEVEL = 9
6427 --SUBLEVEL = 2
6428 -+SUBLEVEL = 3
6429 - EXTRAVERSION =
6430 - NAME = Unicycling Gorilla
6431 -
6432 -diff --git a/arch/arm/include/asm/cmpxchg.h b/arch/arm/include/asm/cmpxchg.h
6433 -index 7eb18c1..4f009c1 100644
6434 ---- a/arch/arm/include/asm/cmpxchg.h
6435 -+++ b/arch/arm/include/asm/cmpxchg.h
6436 -@@ -233,15 +233,15 @@ static inline unsigned long __cmpxchg_local(volatile void *ptr,
6437 - ((__typeof__(*(ptr)))atomic64_cmpxchg(container_of((ptr), \
6438 - atomic64_t, \
6439 - counter), \
6440 -- (unsigned long)(o), \
6441 -- (unsigned long)(n)))
6442 -+ (unsigned long long)(o), \
6443 -+ (unsigned long long)(n)))
6444 -
6445 - #define cmpxchg64_local(ptr, o, n) \
6446 - ((__typeof__(*(ptr)))local64_cmpxchg(container_of((ptr), \
6447 - local64_t, \
6448 - a), \
6449 -- (unsigned long)(o), \
6450 -- (unsigned long)(n)))
6451 -+ (unsigned long long)(o), \
6452 -+ (unsigned long long)(n)))
6453 -
6454 - #endif /* __LINUX_ARM_ARCH__ >= 6 */
6455 -
6456 -diff --git a/arch/arm/mach-exynos/include/mach/regs-pmu.h b/arch/arm/mach-exynos/include/mach/regs-pmu.h
6457 -index 3f30aa1..57344b7 100644
6458 ---- a/arch/arm/mach-exynos/include/mach/regs-pmu.h
6459 -+++ b/arch/arm/mach-exynos/include/mach/regs-pmu.h
6460 -@@ -344,6 +344,7 @@
6461 - #define EXYNOS5_FSYS_ARM_OPTION S5P_PMUREG(0x2208)
6462 - #define EXYNOS5_ISP_ARM_OPTION S5P_PMUREG(0x2288)
6463 - #define EXYNOS5_ARM_COMMON_OPTION S5P_PMUREG(0x2408)
6464 -+#define EXYNOS5_ARM_L2_OPTION S5P_PMUREG(0x2608)
6465 - #define EXYNOS5_TOP_PWR_OPTION S5P_PMUREG(0x2C48)
6466 - #define EXYNOS5_TOP_PWR_SYSMEM_OPTION S5P_PMUREG(0x2CC8)
6467 - #define EXYNOS5_JPEG_MEM_OPTION S5P_PMUREG(0x2F48)
6468 -diff --git a/arch/arm/mach-exynos/pmu.c b/arch/arm/mach-exynos/pmu.c
6469 -index daebc1a..97d6885 100644
6470 ---- a/arch/arm/mach-exynos/pmu.c
6471 -+++ b/arch/arm/mach-exynos/pmu.c
6472 -@@ -228,6 +228,7 @@ static struct exynos_pmu_conf exynos5250_pmu_config[] = {
6473 - { EXYNOS5_DIS_IRQ_ISP_ARM_CENTRAL_SYS_PWR_REG, { 0x0, 0x0, 0x0} },
6474 - { EXYNOS5_ARM_COMMON_SYS_PWR_REG, { 0x0, 0x0, 0x2} },
6475 - { EXYNOS5_ARM_L2_SYS_PWR_REG, { 0x3, 0x3, 0x3} },
6476 -+ { EXYNOS5_ARM_L2_OPTION, { 0x10, 0x10, 0x0 } },
6477 - { EXYNOS5_CMU_ACLKSTOP_SYS_PWR_REG, { 0x1, 0x0, 0x1} },
6478 - { EXYNOS5_CMU_SCLKSTOP_SYS_PWR_REG, { 0x1, 0x0, 0x1} },
6479 - { EXYNOS5_CMU_RESET_SYS_PWR_REG, { 0x1, 0x1, 0x0} },
6480 -@@ -353,11 +354,9 @@ static void exynos5_init_pmu(void)
6481 -
6482 - /*
6483 - * SKIP_DEACTIVATE_ACEACP_IN_PWDN_BITFIELD Enable
6484 -- * MANUAL_L2RSTDISABLE_CONTROL_BITFIELD Enable
6485 - */
6486 - tmp = __raw_readl(EXYNOS5_ARM_COMMON_OPTION);
6487 -- tmp |= (EXYNOS5_MANUAL_L2RSTDISABLE_CONTROL |
6488 -- EXYNOS5_SKIP_DEACTIVATE_ACEACP_IN_PWDN);
6489 -+ tmp |= EXYNOS5_SKIP_DEACTIVATE_ACEACP_IN_PWDN;
6490 - __raw_writel(tmp, EXYNOS5_ARM_COMMON_OPTION);
6491 -
6492 - /*
6493 -diff --git a/arch/arm/mach-omap2/board-rx51-peripherals.c b/arch/arm/mach-omap2/board-rx51-peripherals.c
6494 -index 3a077df..9bc9f19 100644
6495 ---- a/arch/arm/mach-omap2/board-rx51-peripherals.c
6496 -+++ b/arch/arm/mach-omap2/board-rx51-peripherals.c
6497 -@@ -73,11 +73,11 @@
6498 - #define LIS302_IRQ1_GPIO 181
6499 - #define LIS302_IRQ2_GPIO 180 /* Not yet in use */
6500 -
6501 --/* list all spi devices here */
6502 -+/* List all SPI devices here. Note that the list/probe order seems to matter! */
6503 - enum {
6504 - RX51_SPI_WL1251,
6505 -- RX51_SPI_MIPID, /* LCD panel */
6506 - RX51_SPI_TSC2005, /* Touch Controller */
6507 -+ RX51_SPI_MIPID, /* LCD panel */
6508 - };
6509 -
6510 - static struct wl12xx_platform_data wl1251_pdata;
6511 -diff --git a/arch/parisc/Makefile b/arch/parisc/Makefile
6512 -index 113e282..1976900 100644
6513 ---- a/arch/parisc/Makefile
6514 -+++ b/arch/parisc/Makefile
6515 -@@ -23,26 +23,21 @@ NM = sh $(srctree)/arch/parisc/nm
6516 - CHECKFLAGS += -D__hppa__=1
6517 - LIBGCC = $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name)
6518 -
6519 --MACHINE := $(shell uname -m)
6520 --ifeq ($(MACHINE),parisc*)
6521 --NATIVE := 1
6522 --endif
6523 --
6524 - ifdef CONFIG_64BIT
6525 - UTS_MACHINE := parisc64
6526 - CHECKFLAGS += -D__LP64__=1 -m64
6527 --WIDTH := 64
6528 -+CC_ARCHES = hppa64
6529 - else # 32-bit
6530 --WIDTH :=
6531 -+CC_ARCHES = hppa hppa2.0 hppa1.1
6532 - endif
6533 -
6534 --# attempt to help out folks who are cross-compiling
6535 --ifeq ($(NATIVE),1)
6536 --CROSS_COMPILE := hppa$(WIDTH)-linux-
6537 --else
6538 -- ifeq ($(CROSS_COMPILE),)
6539 -- CROSS_COMPILE := hppa$(WIDTH)-linux-gnu-
6540 -- endif
6541 -+ifneq ($(SUBARCH),$(UTS_MACHINE))
6542 -+ ifeq ($(CROSS_COMPILE),)
6543 -+ CC_SUFFIXES = linux linux-gnu unknown-linux-gnu
6544 -+ CROSS_COMPILE := $(call cc-cross-prefix, \
6545 -+ $(foreach a,$(CC_ARCHES), \
6546 -+ $(foreach s,$(CC_SUFFIXES),$(a)-$(s)-)))
6547 -+ endif
6548 - endif
6549 -
6550 - OBJCOPY_FLAGS =-O binary -R .note -R .comment -S
6551 -diff --git a/arch/parisc/kernel/entry.S b/arch/parisc/kernel/entry.S
6552 -index f33201b..897bce4 100644
6553 ---- a/arch/parisc/kernel/entry.S
6554 -+++ b/arch/parisc/kernel/entry.S
6555 -@@ -444,9 +444,41 @@
6556 - L2_ptep \pgd,\pte,\index,\va,\fault
6557 - .endm
6558 -
6559 -+ /* Acquire pa_dbit_lock lock. */
6560 -+ .macro dbit_lock spc,tmp,tmp1
6561 -+#ifdef CONFIG_SMP
6562 -+ cmpib,COND(=),n 0,\spc,2f
6563 -+ load32 PA(pa_dbit_lock),\tmp
6564 -+1: LDCW 0(\tmp),\tmp1
6565 -+ cmpib,COND(=) 0,\tmp1,1b
6566 -+ nop
6567 -+2:
6568 -+#endif
6569 -+ .endm
6570 -+
6571 -+ /* Release pa_dbit_lock lock without reloading lock address. */
6572 -+ .macro dbit_unlock0 spc,tmp
6573 -+#ifdef CONFIG_SMP
6574 -+ or,COND(=) %r0,\spc,%r0
6575 -+ stw \spc,0(\tmp)
6576 -+#endif
6577 -+ .endm
6578 -+
6579 -+ /* Release pa_dbit_lock lock. */
6580 -+ .macro dbit_unlock1 spc,tmp
6581 -+#ifdef CONFIG_SMP
6582 -+ load32 PA(pa_dbit_lock),\tmp
6583 -+ dbit_unlock0 \spc,\tmp
6584 -+#endif
6585 -+ .endm
6586 -+
6587 - /* Set the _PAGE_ACCESSED bit of the PTE. Be clever and
6588 - * don't needlessly dirty the cache line if it was already set */
6589 -- .macro update_ptep ptep,pte,tmp,tmp1
6590 -+ .macro update_ptep spc,ptep,pte,tmp,tmp1
6591 -+#ifdef CONFIG_SMP
6592 -+ or,COND(=) %r0,\spc,%r0
6593 -+ LDREG 0(\ptep),\pte
6594 -+#endif
6595 - ldi _PAGE_ACCESSED,\tmp1
6596 - or \tmp1,\pte,\tmp
6597 - and,COND(<>) \tmp1,\pte,%r0
6598 -@@ -455,7 +487,11 @@
6599 -
6600 - /* Set the dirty bit (and accessed bit). No need to be
6601 - * clever, this is only used from the dirty fault */
6602 -- .macro update_dirty ptep,pte,tmp
6603 -+ .macro update_dirty spc,ptep,pte,tmp
6604 -+#ifdef CONFIG_SMP
6605 -+ or,COND(=) %r0,\spc,%r0
6606 -+ LDREG 0(\ptep),\pte
6607 -+#endif
6608 - ldi _PAGE_ACCESSED|_PAGE_DIRTY,\tmp
6609 - or \tmp,\pte,\pte
6610 - STREG \pte,0(\ptep)
6611 -@@ -825,11 +861,6 @@ ENTRY(syscall_exit_rfi)
6612 - STREG %r19,PT_SR7(%r16)
6613 -
6614 - intr_return:
6615 -- /* NOTE: Need to enable interrupts incase we schedule. */
6616 -- ssm PSW_SM_I, %r0
6617 --
6618 --intr_check_resched:
6619 --
6620 - /* check for reschedule */
6621 - mfctl %cr30,%r1
6622 - LDREG TI_FLAGS(%r1),%r19 /* sched.h: TIF_NEED_RESCHED */
6623 -@@ -856,6 +887,11 @@ intr_check_sig:
6624 - LDREG PT_IASQ1(%r16), %r20
6625 - cmpib,COND(=),n 0,%r20,intr_restore /* backward */
6626 -
6627 -+ /* NOTE: We need to enable interrupts if we have to deliver
6628 -+ * signals. We used to do this earlier but it caused kernel
6629 -+ * stack overflows. */
6630 -+ ssm PSW_SM_I, %r0
6631 -+
6632 - copy %r0, %r25 /* long in_syscall = 0 */
6633 - #ifdef CONFIG_64BIT
6634 - ldo -16(%r30),%r29 /* Reference param save area */
6635 -@@ -907,6 +943,10 @@ intr_do_resched:
6636 - cmpib,COND(=) 0, %r20, intr_do_preempt
6637 - nop
6638 -
6639 -+ /* NOTE: We need to enable interrupts if we schedule. We used
6640 -+ * to do this earlier but it caused kernel stack overflows. */
6641 -+ ssm PSW_SM_I, %r0
6642 -+
6643 - #ifdef CONFIG_64BIT
6644 - ldo -16(%r30),%r29 /* Reference param save area */
6645 - #endif
6646 -@@ -1099,11 +1139,13 @@ dtlb_miss_20w:
6647 -
6648 - L3_ptep ptp,pte,t0,va,dtlb_check_alias_20w
6649 -
6650 -- update_ptep ptp,pte,t0,t1
6651 -+ dbit_lock spc,t0,t1
6652 -+ update_ptep spc,ptp,pte,t0,t1
6653 -
6654 - make_insert_tlb spc,pte,prot
6655 -
6656 - idtlbt pte,prot
6657 -+ dbit_unlock1 spc,t0
6658 -
6659 - rfir
6660 - nop
6661 -@@ -1123,11 +1165,13 @@ nadtlb_miss_20w:
6662 -
6663 - L3_ptep ptp,pte,t0,va,nadtlb_check_alias_20w
6664 -
6665 -- update_ptep ptp,pte,t0,t1
6666 -+ dbit_lock spc,t0,t1
6667 -+ update_ptep spc,ptp,pte,t0,t1
6668 -
6669 - make_insert_tlb spc,pte,prot
6670 -
6671 - idtlbt pte,prot
6672 -+ dbit_unlock1 spc,t0
6673 -
6674 - rfir
6675 - nop
6676 -@@ -1149,7 +1193,8 @@ dtlb_miss_11:
6677 -
6678 - L2_ptep ptp,pte,t0,va,dtlb_check_alias_11
6679 -
6680 -- update_ptep ptp,pte,t0,t1
6681 -+ dbit_lock spc,t0,t1
6682 -+ update_ptep spc,ptp,pte,t0,t1
6683 -
6684 - make_insert_tlb_11 spc,pte,prot
6685 -
6686 -@@ -1160,6 +1205,7 @@ dtlb_miss_11:
6687 - idtlbp prot,(%sr1,va)
6688 -
6689 - mtsp t0, %sr1 /* Restore sr1 */
6690 -+ dbit_unlock1 spc,t0
6691 -
6692 - rfir
6693 - nop
6694 -@@ -1180,7 +1226,8 @@ nadtlb_miss_11:
6695 -
6696 - L2_ptep ptp,pte,t0,va,nadtlb_check_alias_11
6697 -
6698 -- update_ptep ptp,pte,t0,t1
6699 -+ dbit_lock spc,t0,t1
6700 -+ update_ptep spc,ptp,pte,t0,t1
6701 -
6702 - make_insert_tlb_11 spc,pte,prot
6703 -
6704 -@@ -1192,6 +1239,7 @@ nadtlb_miss_11:
6705 - idtlbp prot,(%sr1,va)
6706 -
6707 - mtsp t0, %sr1 /* Restore sr1 */
6708 -+ dbit_unlock1 spc,t0
6709 -
6710 - rfir
6711 - nop
6712 -@@ -1212,13 +1260,15 @@ dtlb_miss_20:
6713 -
6714 - L2_ptep ptp,pte,t0,va,dtlb_check_alias_20
6715 -
6716 -- update_ptep ptp,pte,t0,t1
6717 -+ dbit_lock spc,t0,t1
6718 -+ update_ptep spc,ptp,pte,t0,t1
6719 -
6720 - make_insert_tlb spc,pte,prot
6721 -
6722 - f_extend pte,t0
6723 -
6724 - idtlbt pte,prot
6725 -+ dbit_unlock1 spc,t0
6726 -
6727 - rfir
6728 - nop
6729 -@@ -1238,13 +1288,15 @@ nadtlb_miss_20:
6730 -
6731 - L2_ptep ptp,pte,t0,va,nadtlb_check_alias_20
6732 -
6733 -- update_ptep ptp,pte,t0,t1
6734 -+ dbit_lock spc,t0,t1
6735 -+ update_ptep spc,ptp,pte,t0,t1
6736 -
6737 - make_insert_tlb spc,pte,prot
6738 -
6739 - f_extend pte,t0
6740 -
6741 - idtlbt pte,prot
6742 -+ dbit_unlock1 spc,t0
6743 -
6744 - rfir
6745 - nop
6746 -@@ -1345,11 +1397,13 @@ itlb_miss_20w:
6747 -
6748 - L3_ptep ptp,pte,t0,va,itlb_fault
6749 -
6750 -- update_ptep ptp,pte,t0,t1
6751 -+ dbit_lock spc,t0,t1
6752 -+ update_ptep spc,ptp,pte,t0,t1
6753 -
6754 - make_insert_tlb spc,pte,prot
6755 -
6756 - iitlbt pte,prot
6757 -+ dbit_unlock1 spc,t0
6758 -
6759 - rfir
6760 - nop
6761 -@@ -1367,11 +1421,13 @@ naitlb_miss_20w:
6762 -
6763 - L3_ptep ptp,pte,t0,va,naitlb_check_alias_20w
6764 -
6765 -- update_ptep ptp,pte,t0,t1
6766 -+ dbit_lock spc,t0,t1
6767 -+ update_ptep spc,ptp,pte,t0,t1
6768 -
6769 - make_insert_tlb spc,pte,prot
6770 -
6771 - iitlbt pte,prot
6772 -+ dbit_unlock1 spc,t0
6773 -
6774 - rfir
6775 - nop
6776 -@@ -1393,7 +1449,8 @@ itlb_miss_11:
6777 -
6778 - L2_ptep ptp,pte,t0,va,itlb_fault
6779 -
6780 -- update_ptep ptp,pte,t0,t1
6781 -+ dbit_lock spc,t0,t1
6782 -+ update_ptep spc,ptp,pte,t0,t1
6783 -
6784 - make_insert_tlb_11 spc,pte,prot
6785 -
6786 -@@ -1404,6 +1461,7 @@ itlb_miss_11:
6787 - iitlbp prot,(%sr1,va)
6788 -
6789 - mtsp t0, %sr1 /* Restore sr1 */
6790 -+ dbit_unlock1 spc,t0
6791 -
6792 - rfir
6793 - nop
6794 -@@ -1415,7 +1473,8 @@ naitlb_miss_11:
6795 -
6796 - L2_ptep ptp,pte,t0,va,naitlb_check_alias_11
6797 -
6798 -- update_ptep ptp,pte,t0,t1
6799 -+ dbit_lock spc,t0,t1
6800 -+ update_ptep spc,ptp,pte,t0,t1
6801 -
6802 - make_insert_tlb_11 spc,pte,prot
6803 -
6804 -@@ -1426,6 +1485,7 @@ naitlb_miss_11:
6805 - iitlbp prot,(%sr1,va)
6806 -
6807 - mtsp t0, %sr1 /* Restore sr1 */
6808 -+ dbit_unlock1 spc,t0
6809 -
6810 - rfir
6811 - nop
6812 -@@ -1447,13 +1507,15 @@ itlb_miss_20:
6813 -
6814 - L2_ptep ptp,pte,t0,va,itlb_fault
6815 -
6816 -- update_ptep ptp,pte,t0,t1
6817 -+ dbit_lock spc,t0,t1
6818 -+ update_ptep spc,ptp,pte,t0,t1
6819 -
6820 - make_insert_tlb spc,pte,prot
6821 -
6822 - f_extend pte,t0
6823 -
6824 - iitlbt pte,prot
6825 -+ dbit_unlock1 spc,t0
6826 -
6827 - rfir
6828 - nop
6829 -@@ -1465,13 +1527,15 @@ naitlb_miss_20:
6830 -
6831 - L2_ptep ptp,pte,t0,va,naitlb_check_alias_20
6832 -
6833 -- update_ptep ptp,pte,t0,t1
6834 -+ dbit_lock spc,t0,t1
6835 -+ update_ptep spc,ptp,pte,t0,t1
6836 -
6837 - make_insert_tlb spc,pte,prot
6838 -
6839 - f_extend pte,t0
6840 -
6841 - iitlbt pte,prot
6842 -+ dbit_unlock1 spc,t0
6843 -
6844 - rfir
6845 - nop
6846 -@@ -1495,29 +1559,13 @@ dbit_trap_20w:
6847 -
6848 - L3_ptep ptp,pte,t0,va,dbit_fault
6849 -
6850 --#ifdef CONFIG_SMP
6851 -- cmpib,COND(=),n 0,spc,dbit_nolock_20w
6852 -- load32 PA(pa_dbit_lock),t0
6853 --
6854 --dbit_spin_20w:
6855 -- LDCW 0(t0),t1
6856 -- cmpib,COND(=) 0,t1,dbit_spin_20w
6857 -- nop
6858 --
6859 --dbit_nolock_20w:
6860 --#endif
6861 -- update_dirty ptp,pte,t1
6862 -+ dbit_lock spc,t0,t1
6863 -+ update_dirty spc,ptp,pte,t1
6864 -
6865 - make_insert_tlb spc,pte,prot
6866 -
6867 - idtlbt pte,prot
6868 --#ifdef CONFIG_SMP
6869 -- cmpib,COND(=),n 0,spc,dbit_nounlock_20w
6870 -- ldi 1,t1
6871 -- stw t1,0(t0)
6872 --
6873 --dbit_nounlock_20w:
6874 --#endif
6875 -+ dbit_unlock0 spc,t0
6876 -
6877 - rfir
6878 - nop
6879 -@@ -1531,18 +1579,8 @@ dbit_trap_11:
6880 -
6881 - L2_ptep ptp,pte,t0,va,dbit_fault
6882 -
6883 --#ifdef CONFIG_SMP
6884 -- cmpib,COND(=),n 0,spc,dbit_nolock_11
6885 -- load32 PA(pa_dbit_lock),t0
6886 --
6887 --dbit_spin_11:
6888 -- LDCW 0(t0),t1
6889 -- cmpib,= 0,t1,dbit_spin_11
6890 -- nop
6891 --
6892 --dbit_nolock_11:
6893 --#endif
6894 -- update_dirty ptp,pte,t1
6895 -+ dbit_lock spc,t0,t1
6896 -+ update_dirty spc,ptp,pte,t1
6897 -
6898 - make_insert_tlb_11 spc,pte,prot
6899 -
6900 -@@ -1553,13 +1591,7 @@ dbit_nolock_11:
6901 - idtlbp prot,(%sr1,va)
6902 -
6903 - mtsp t1, %sr1 /* Restore sr1 */
6904 --#ifdef CONFIG_SMP
6905 -- cmpib,COND(=),n 0,spc,dbit_nounlock_11
6906 -- ldi 1,t1
6907 -- stw t1,0(t0)
6908 --
6909 --dbit_nounlock_11:
6910 --#endif
6911 -+ dbit_unlock0 spc,t0
6912 -
6913 - rfir
6914 - nop
6915 -@@ -1571,32 +1603,15 @@ dbit_trap_20:
6916 -
6917 - L2_ptep ptp,pte,t0,va,dbit_fault
6918 -
6919 --#ifdef CONFIG_SMP
6920 -- cmpib,COND(=),n 0,spc,dbit_nolock_20
6921 -- load32 PA(pa_dbit_lock),t0
6922 --
6923 --dbit_spin_20:
6924 -- LDCW 0(t0),t1
6925 -- cmpib,= 0,t1,dbit_spin_20
6926 -- nop
6927 --
6928 --dbit_nolock_20:
6929 --#endif
6930 -- update_dirty ptp,pte,t1
6931 -+ dbit_lock spc,t0,t1
6932 -+ update_dirty spc,ptp,pte,t1
6933 -
6934 - make_insert_tlb spc,pte,prot
6935 -
6936 - f_extend pte,t1
6937 -
6938 - idtlbt pte,prot
6939 --
6940 --#ifdef CONFIG_SMP
6941 -- cmpib,COND(=),n 0,spc,dbit_nounlock_20
6942 -- ldi 1,t1
6943 -- stw t1,0(t0)
6944 --
6945 --dbit_nounlock_20:
6946 --#endif
6947 -+ dbit_unlock0 spc,t0
6948 -
6949 - rfir
6950 - nop
6951 -@@ -1694,7 +1709,8 @@ ENTRY(sys_\name\()_wrapper)
6952 - ldo TASK_REGS(%r1),%r1
6953 - reg_save %r1
6954 - mfctl %cr27, %r28
6955 -- b sys_\name
6956 -+ ldil L%sys_\name, %r31
6957 -+ be R%sys_\name(%sr4,%r31)
6958 - STREG %r28, PT_CR27(%r1)
6959 - ENDPROC(sys_\name\()_wrapper)
6960 - .endm
6961 -diff --git a/arch/powerpc/include/asm/rtas.h b/arch/powerpc/include/asm/rtas.h
6962 -index aef00c6..ee38f29 100644
6963 ---- a/arch/powerpc/include/asm/rtas.h
6964 -+++ b/arch/powerpc/include/asm/rtas.h
6965 -@@ -262,6 +262,8 @@ extern void rtas_progress(char *s, unsigned short hex);
6966 - extern void rtas_initialize(void);
6967 - extern int rtas_suspend_cpu(struct rtas_suspend_me_data *data);
6968 - extern int rtas_suspend_last_cpu(struct rtas_suspend_me_data *data);
6969 -+extern int rtas_online_cpus_mask(cpumask_var_t cpus);
6970 -+extern int rtas_offline_cpus_mask(cpumask_var_t cpus);
6971 - extern int rtas_ibm_suspend_me(struct rtas_args *);
6972 -
6973 - struct rtc_time;
6974 -diff --git a/arch/powerpc/kernel/machine_kexec_64.c b/arch/powerpc/kernel/machine_kexec_64.c
6975 -index 466a290..611acdf 100644
6976 ---- a/arch/powerpc/kernel/machine_kexec_64.c
6977 -+++ b/arch/powerpc/kernel/machine_kexec_64.c
6978 -@@ -17,6 +17,7 @@
6979 - #include <linux/errno.h>
6980 - #include <linux/kernel.h>
6981 - #include <linux/cpu.h>
6982 -+#include <linux/hardirq.h>
6983 -
6984 - #include <asm/page.h>
6985 - #include <asm/current.h>
6986 -@@ -335,10 +336,13 @@ void default_machine_kexec(struct kimage *image)
6987 - pr_debug("kexec: Starting switchover sequence.\n");
6988 -
6989 - /* switch to a staticly allocated stack. Based on irq stack code.
6990 -+ * We setup preempt_count to avoid using VMX in memcpy.
6991 - * XXX: the task struct will likely be invalid once we do the copy!
6992 - */
6993 - kexec_stack.thread_info.task = current_thread_info()->task;
6994 - kexec_stack.thread_info.flags = 0;
6995 -+ kexec_stack.thread_info.preempt_count = HARDIRQ_OFFSET;
6996 -+ kexec_stack.thread_info.cpu = current_thread_info()->cpu;
6997 -
6998 - /* We need a static PACA, too; copy this CPU's PACA over and switch to
6999 - * it. Also poison per_cpu_offset to catch anyone using non-static
7000 -diff --git a/arch/powerpc/kernel/rtas.c b/arch/powerpc/kernel/rtas.c
7001 -index 1fd6e7b..52add6f 100644
7002 ---- a/arch/powerpc/kernel/rtas.c
7003 -+++ b/arch/powerpc/kernel/rtas.c
7004 -@@ -19,6 +19,7 @@
7005 - #include <linux/init.h>
7006 - #include <linux/capability.h>
7007 - #include <linux/delay.h>
7008 -+#include <linux/cpu.h>
7009 - #include <linux/smp.h>
7010 - #include <linux/completion.h>
7011 - #include <linux/cpumask.h>
7012 -@@ -807,6 +808,95 @@ static void rtas_percpu_suspend_me(void *info)
7013 - __rtas_suspend_cpu((struct rtas_suspend_me_data *)info, 1);
7014 - }
7015 -
7016 -+enum rtas_cpu_state {
7017 -+ DOWN,
7018 -+ UP,
7019 -+};
7020 -+
7021 -+#ifndef CONFIG_SMP
7022 -+static int rtas_cpu_state_change_mask(enum rtas_cpu_state state,
7023 -+ cpumask_var_t cpus)
7024 -+{
7025 -+ if (!cpumask_empty(cpus)) {
7026 -+ cpumask_clear(cpus);
7027 -+ return -EINVAL;
7028 -+ } else
7029 -+ return 0;
7030 -+}
7031 -+#else
7032 -+/* On return cpumask will be altered to indicate CPUs changed.
7033 -+ * CPUs with states changed will be set in the mask,
7034 -+ * CPUs with status unchanged will be unset in the mask. */
7035 -+static int rtas_cpu_state_change_mask(enum rtas_cpu_state state,
7036 -+ cpumask_var_t cpus)
7037 -+{
7038 -+ int cpu;
7039 -+ int cpuret = 0;
7040 -+ int ret = 0;
7041 -+
7042 -+ if (cpumask_empty(cpus))
7043 -+ return 0;
7044 -+
7045 -+ for_each_cpu(cpu, cpus) {
7046 -+ switch (state) {
7047 -+ case DOWN:
7048 -+ cpuret = cpu_down(cpu);
7049 -+ break;
7050 -+ case UP:
7051 -+ cpuret = cpu_up(cpu);
7052 -+ break;
7053 -+ }
7054 -+ if (cpuret) {
7055 -+ pr_debug("%s: cpu_%s for cpu#%d returned %d.\n",
7056 -+ __func__,
7057 -+ ((state == UP) ? "up" : "down"),
7058 -+ cpu, cpuret);
7059 -+ if (!ret)
7060 -+ ret = cpuret;
7061 -+ if (state == UP) {
7062 -+ /* clear bits for unchanged cpus, return */
7063 -+ cpumask_shift_right(cpus, cpus, cpu);
7064 -+ cpumask_shift_left(cpus, cpus, cpu);
7065 -+ break;
7066 -+ } else {
7067 -+ /* clear bit for unchanged cpu, continue */
7068 -+ cpumask_clear_cpu(cpu, cpus);
7069 -+ }
7070 -+ }
7071 -+ }
7072 -+
7073 -+ return ret;
7074 -+}
7075 -+#endif
7076 -+
7077 -+int rtas_online_cpus_mask(cpumask_var_t cpus)
7078 -+{
7079 -+ int ret;
7080 -+
7081 -+ ret = rtas_cpu_state_change_mask(UP, cpus);
7082 -+
7083 -+ if (ret) {
7084 -+ cpumask_var_t tmp_mask;
7085 -+
7086 -+ if (!alloc_cpumask_var(&tmp_mask, GFP_TEMPORARY))
7087 -+ return ret;
7088 -+
7089 -+ /* Use tmp_mask to preserve cpus mask from first failure */
7090 -+ cpumask_copy(tmp_mask, cpus);
7091 -+ rtas_offline_cpus_mask(tmp_mask);
7092 -+ free_cpumask_var(tmp_mask);
7093 -+ }
7094 -+
7095 -+ return ret;
7096 -+}
7097 -+EXPORT_SYMBOL(rtas_online_cpus_mask);
7098 -+
7099 -+int rtas_offline_cpus_mask(cpumask_var_t cpus)
7100 -+{
7101 -+ return rtas_cpu_state_change_mask(DOWN, cpus);
7102 -+}
7103 -+EXPORT_SYMBOL(rtas_offline_cpus_mask);
7104 -+
7105 - int rtas_ibm_suspend_me(struct rtas_args *args)
7106 - {
7107 - long state;
7108 -@@ -814,6 +904,8 @@ int rtas_ibm_suspend_me(struct rtas_args *args)
7109 - unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
7110 - struct rtas_suspend_me_data data;
7111 - DECLARE_COMPLETION_ONSTACK(done);
7112 -+ cpumask_var_t offline_mask;
7113 -+ int cpuret;
7114 -
7115 - if (!rtas_service_present("ibm,suspend-me"))
7116 - return -ENOSYS;
7117 -@@ -837,11 +929,24 @@ int rtas_ibm_suspend_me(struct rtas_args *args)
7118 - return 0;
7119 - }
7120 -
7121 -+ if (!alloc_cpumask_var(&offline_mask, GFP_TEMPORARY))
7122 -+ return -ENOMEM;
7123 -+
7124 - atomic_set(&data.working, 0);
7125 - atomic_set(&data.done, 0);
7126 - atomic_set(&data.error, 0);
7127 - data.token = rtas_token("ibm,suspend-me");
7128 - data.complete = &done;
7129 -+
7130 -+ /* All present CPUs must be online */
7131 -+ cpumask_andnot(offline_mask, cpu_present_mask, cpu_online_mask);
7132 -+ cpuret = rtas_online_cpus_mask(offline_mask);
7133 -+ if (cpuret) {
7134 -+ pr_err("%s: Could not bring present CPUs online.\n", __func__);
7135 -+ atomic_set(&data.error, cpuret);
7136 -+ goto out;
7137 -+ }
7138 -+
7139 - stop_topology_update();
7140 -
7141 - /* Call function on all CPUs. One of us will make the
7142 -@@ -857,6 +962,14 @@ int rtas_ibm_suspend_me(struct rtas_args *args)
7143 -
7144 - start_topology_update();
7145 -
7146 -+ /* Take down CPUs not online prior to suspend */
7147 -+ cpuret = rtas_offline_cpus_mask(offline_mask);
7148 -+ if (cpuret)
7149 -+ pr_warn("%s: Could not restore CPUs to offline state.\n",
7150 -+ __func__);
7151 -+
7152 -+out:
7153 -+ free_cpumask_var(offline_mask);
7154 - return atomic_read(&data.error);
7155 - }
7156 - #else /* CONFIG_PPC_PSERIES */
7157 -diff --git a/arch/powerpc/platforms/pseries/suspend.c b/arch/powerpc/platforms/pseries/suspend.c
7158 -index 47226e0..5f997e7 100644
7159 ---- a/arch/powerpc/platforms/pseries/suspend.c
7160 -+++ b/arch/powerpc/platforms/pseries/suspend.c
7161 -@@ -16,6 +16,7 @@
7162 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
7163 - */
7164 -
7165 -+#include <linux/cpu.h>
7166 - #include <linux/delay.h>
7167 - #include <linux/suspend.h>
7168 - #include <linux/stat.h>
7169 -@@ -126,11 +127,15 @@ static ssize_t store_hibernate(struct device *dev,
7170 - struct device_attribute *attr,
7171 - const char *buf, size_t count)
7172 - {
7173 -+ cpumask_var_t offline_mask;
7174 - int rc;
7175 -
7176 - if (!capable(CAP_SYS_ADMIN))
7177 - return -EPERM;
7178 -
7179 -+ if (!alloc_cpumask_var(&offline_mask, GFP_TEMPORARY))
7180 -+ return -ENOMEM;
7181 -+
7182 - stream_id = simple_strtoul(buf, NULL, 16);
7183 -
7184 - do {
7185 -@@ -140,15 +145,32 @@ static ssize_t store_hibernate(struct device *dev,
7186 - } while (rc == -EAGAIN);
7187 -
7188 - if (!rc) {
7189 -+ /* All present CPUs must be online */
7190 -+ cpumask_andnot(offline_mask, cpu_present_mask,
7191 -+ cpu_online_mask);
7192 -+ rc = rtas_online_cpus_mask(offline_mask);
7193 -+ if (rc) {
7194 -+ pr_err("%s: Could not bring present CPUs online.\n",
7195 -+ __func__);
7196 -+ goto out;
7197 -+ }
7198 -+
7199 - stop_topology_update();
7200 - rc = pm_suspend(PM_SUSPEND_MEM);
7201 - start_topology_update();
7202 -+
7203 -+ /* Take down CPUs not online prior to suspend */
7204 -+ if (!rtas_offline_cpus_mask(offline_mask))
7205 -+ pr_warn("%s: Could not restore CPUs to offline "
7206 -+ "state.\n", __func__);
7207 - }
7208 -
7209 - stream_id = 0;
7210 -
7211 - if (!rc)
7212 - rc = count;
7213 -+out:
7214 -+ free_cpumask_var(offline_mask);
7215 - return rc;
7216 - }
7217 -
7218 -diff --git a/arch/tile/Kconfig b/arch/tile/Kconfig
7219 -index 25877ae..41a2a0b 100644
7220 ---- a/arch/tile/Kconfig
7221 -+++ b/arch/tile/Kconfig
7222 -@@ -368,11 +368,17 @@ config HARDWALL
7223 - config KERNEL_PL
7224 - int "Processor protection level for kernel"
7225 - range 1 2
7226 -- default "1"
7227 -+ default 2 if TILEGX
7228 -+ default 1 if !TILEGX
7229 - ---help---
7230 -- This setting determines the processor protection level the
7231 -- kernel will be built to run at. Generally you should use
7232 -- the default value here.
7233 -+ Since MDE 4.2, the Tilera hypervisor runs the kernel
7234 -+ at PL2 by default. If running under an older hypervisor,
7235 -+ or as a KVM guest, you must run at PL1. (The current
7236 -+ hypervisor may also be recompiled with "make HV_PL=2" to
7237 -+ allow it to run a kernel at PL1, but clients running at PL1
7238 -+ are not expected to be supported indefinitely.)
7239 -+
7240 -+ If you're not sure, don't change the default.
7241 -
7242 - source "arch/tile/gxio/Kconfig"
7243 -
7244 -diff --git a/arch/tile/include/hv/hypervisor.h b/arch/tile/include/hv/hypervisor.h
7245 -index ccd847e..837dca5 100644
7246 ---- a/arch/tile/include/hv/hypervisor.h
7247 -+++ b/arch/tile/include/hv/hypervisor.h
7248 -@@ -107,7 +107,22 @@
7249 - #define HV_DISPATCH_ENTRY_SIZE 32
7250 -
7251 - /** Version of the hypervisor interface defined by this file */
7252 --#define _HV_VERSION 11
7253 -+#define _HV_VERSION 13
7254 -+
7255 -+/** Last version of the hypervisor interface with old hv_init() ABI.
7256 -+ *
7257 -+ * The change from version 12 to version 13 corresponds to launching
7258 -+ * the client by default at PL2 instead of PL1 (corresponding to the
7259 -+ * hv itself running at PL3 instead of PL2). To make this explicit,
7260 -+ * the hv_init() API was also extended so the client can report its
7261 -+ * desired PL, resulting in a more helpful failure diagnostic. If you
7262 -+ * call hv_init() with _HV_VERSION_OLD_HV_INIT and omit the client_pl
7263 -+ * argument, the hypervisor will assume client_pl = 1.
7264 -+ *
7265 -+ * Note that this is a deprecated solution and we do not expect to
7266 -+ * support clients of the Tilera hypervisor running at PL1 indefinitely.
7267 -+ */
7268 -+#define _HV_VERSION_OLD_HV_INIT 12
7269 -
7270 - /* Index into hypervisor interface dispatch code blocks.
7271 - *
7272 -@@ -377,7 +392,11 @@ typedef int HV_Errno;
7273 - #ifndef __ASSEMBLER__
7274 -
7275 - /** Pass HV_VERSION to hv_init to request this version of the interface. */
7276 --typedef enum { HV_VERSION = _HV_VERSION } HV_VersionNumber;
7277 -+typedef enum {
7278 -+ HV_VERSION = _HV_VERSION,
7279 -+ HV_VERSION_OLD_HV_INIT = _HV_VERSION_OLD_HV_INIT,
7280 -+
7281 -+} HV_VersionNumber;
7282 -
7283 - /** Initializes the hypervisor.
7284 - *
7285 -@@ -385,9 +404,11 @@ typedef enum { HV_VERSION = _HV_VERSION } HV_VersionNumber;
7286 - * that this program expects, typically HV_VERSION.
7287 - * @param chip_num Architecture number of the chip the client was built for.
7288 - * @param chip_rev_num Revision number of the chip the client was built for.
7289 -+ * @param client_pl Privilege level the client is built for
7290 -+ * (not required if interface_version_number == HV_VERSION_OLD_HV_INIT).
7291 - */
7292 - void hv_init(HV_VersionNumber interface_version_number,
7293 -- int chip_num, int chip_rev_num);
7294 -+ int chip_num, int chip_rev_num, int client_pl);
7295 -
7296 -
7297 - /** Queries we can make for hv_sysconf().
7298 -diff --git a/arch/tile/kernel/head_32.S b/arch/tile/kernel/head_32.S
7299 -index f71bfee..ac11530 100644
7300 ---- a/arch/tile/kernel/head_32.S
7301 -+++ b/arch/tile/kernel/head_32.S
7302 -@@ -38,7 +38,7 @@ ENTRY(_start)
7303 - movei r2, TILE_CHIP_REV
7304 - }
7305 - {
7306 -- moveli r0, _HV_VERSION
7307 -+ moveli r0, _HV_VERSION_OLD_HV_INIT
7308 - jal hv_init
7309 - }
7310 - /* Get a reasonable default ASID in r0 */
7311 -diff --git a/arch/tile/kernel/head_64.S b/arch/tile/kernel/head_64.S
7312 -index f9a2734..6093964 100644
7313 ---- a/arch/tile/kernel/head_64.S
7314 -+++ b/arch/tile/kernel/head_64.S
7315 -@@ -34,13 +34,19 @@
7316 - ENTRY(_start)
7317 - /* Notify the hypervisor of what version of the API we want */
7318 - {
7319 -+#if KERNEL_PL == 1 && _HV_VERSION == 13
7320 -+ /* Support older hypervisors by asking for API version 12. */
7321 -+ movei r0, _HV_VERSION_OLD_HV_INIT
7322 -+#else
7323 -+ movei r0, _HV_VERSION
7324 -+#endif
7325 - movei r1, TILE_CHIP
7326 -- movei r2, TILE_CHIP_REV
7327 - }
7328 - {
7329 -- moveli r0, _HV_VERSION
7330 -- jal hv_init
7331 -+ movei r2, TILE_CHIP_REV
7332 -+ movei r3, KERNEL_PL
7333 - }
7334 -+ jal hv_init
7335 - /* Get a reasonable default ASID in r0 */
7336 - {
7337 - move r0, zero
7338 -diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
7339 -index 15b5cef..6ef2a37 100644
7340 ---- a/arch/x86/Kconfig
7341 -+++ b/arch/x86/Kconfig
7342 -@@ -107,7 +107,6 @@ config X86
7343 - select GENERIC_CLOCKEVENTS_BROADCAST if X86_64 || (X86_32 && X86_LOCAL_APIC)
7344 - select GENERIC_TIME_VSYSCALL if X86_64
7345 - select KTIME_SCALAR if X86_32
7346 -- select ALWAYS_USE_PERSISTENT_CLOCK
7347 - select GENERIC_STRNCPY_FROM_USER
7348 - select GENERIC_STRNLEN_USER
7349 - select HAVE_CONTEXT_TRACKING if X86_64
7350 -diff --git a/arch/x86/kernel/microcode_intel_early.c b/arch/x86/kernel/microcode_intel_early.c
7351 -index d893e8e..2e9e128 100644
7352 ---- a/arch/x86/kernel/microcode_intel_early.c
7353 -+++ b/arch/x86/kernel/microcode_intel_early.c
7354 -@@ -487,6 +487,7 @@ static inline void show_saved_mc(void)
7355 - #endif
7356 -
7357 - #if defined(CONFIG_MICROCODE_INTEL_EARLY) && defined(CONFIG_HOTPLUG_CPU)
7358 -+static DEFINE_MUTEX(x86_cpu_microcode_mutex);
7359 - /*
7360 - * Save this mc into mc_saved_data. So it will be loaded early when a CPU is
7361 - * hot added or resumes.
7362 -@@ -507,7 +508,7 @@ int save_mc_for_early(u8 *mc)
7363 - * Hold hotplug lock so mc_saved_data is not accessed by a CPU in
7364 - * hotplug.
7365 - */
7366 -- cpu_hotplug_driver_lock();
7367 -+ mutex_lock(&x86_cpu_microcode_mutex);
7368 -
7369 - mc_saved_count_init = mc_saved_data.mc_saved_count;
7370 - mc_saved_count = mc_saved_data.mc_saved_count;
7371 -@@ -544,7 +545,7 @@ int save_mc_for_early(u8 *mc)
7372 - }
7373 -
7374 - out:
7375 -- cpu_hotplug_driver_unlock();
7376 -+ mutex_unlock(&x86_cpu_microcode_mutex);
7377 -
7378 - return ret;
7379 - }
7380 -diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
7381 -index a9c9d3e..59622c9 100644
7382 ---- a/arch/x86/kvm/emulate.c
7383 -+++ b/arch/x86/kvm/emulate.c
7384 -@@ -60,6 +60,7 @@
7385 - #define OpGS 25ull /* GS */
7386 - #define OpMem8 26ull /* 8-bit zero extended memory operand */
7387 - #define OpImm64 27ull /* Sign extended 16/32/64-bit immediate */
7388 -+#define OpXLat 28ull /* memory at BX/EBX/RBX + zero-extended AL */
7389 -
7390 - #define OpBits 5 /* Width of operand field */
7391 - #define OpMask ((1ull << OpBits) - 1)
7392 -@@ -99,6 +100,7 @@
7393 - #define SrcImmUByte (OpImmUByte << SrcShift)
7394 - #define SrcImmU (OpImmU << SrcShift)
7395 - #define SrcSI (OpSI << SrcShift)
7396 -+#define SrcXLat (OpXLat << SrcShift)
7397 - #define SrcImmFAddr (OpImmFAddr << SrcShift)
7398 - #define SrcMemFAddr (OpMemFAddr << SrcShift)
7399 - #define SrcAcc (OpAcc << SrcShift)
7400 -@@ -532,6 +534,9 @@ FOP_SETCC(setle)
7401 - FOP_SETCC(setnle)
7402 - FOP_END;
7403 -
7404 -+FOP_START(salc) "pushf; sbb %al, %al; popf \n\t" FOP_RET
7405 -+FOP_END;
7406 -+
7407 - #define __emulate_1op_rax_rdx(ctxt, _op, _suffix, _ex) \
7408 - do { \
7409 - unsigned long _tmp; \
7410 -@@ -2986,6 +2991,28 @@ static int em_das(struct x86_emulate_ctxt *ctxt)
7411 - return X86EMUL_CONTINUE;
7412 - }
7413 -
7414 -+static int em_aam(struct x86_emulate_ctxt *ctxt)
7415 -+{
7416 -+ u8 al, ah;
7417 -+
7418 -+ if (ctxt->src.val == 0)
7419 -+ return emulate_de(ctxt);
7420 -+
7421 -+ al = ctxt->dst.val & 0xff;
7422 -+ ah = al / ctxt->src.val;
7423 -+ al %= ctxt->src.val;
7424 -+
7425 -+ ctxt->dst.val = (ctxt->dst.val & 0xffff0000) | al | (ah << 8);
7426 -+
7427 -+ /* Set PF, ZF, SF */
7428 -+ ctxt->src.type = OP_IMM;
7429 -+ ctxt->src.val = 0;
7430 -+ ctxt->src.bytes = 1;
7431 -+ fastop(ctxt, em_or);
7432 -+
7433 -+ return X86EMUL_CONTINUE;
7434 -+}
7435 -+
7436 - static int em_aad(struct x86_emulate_ctxt *ctxt)
7437 - {
7438 - u8 al = ctxt->dst.val & 0xff;
7439 -@@ -3926,7 +3953,10 @@ static const struct opcode opcode_table[256] = {
7440 - /* 0xD0 - 0xD7 */
7441 - G(Src2One | ByteOp, group2), G(Src2One, group2),
7442 - G(Src2CL | ByteOp, group2), G(Src2CL, group2),
7443 -- N, I(DstAcc | SrcImmByte | No64, em_aad), N, N,
7444 -+ I(DstAcc | SrcImmUByte | No64, em_aam),
7445 -+ I(DstAcc | SrcImmUByte | No64, em_aad),
7446 -+ F(DstAcc | ByteOp | No64, em_salc),
7447 -+ I(DstAcc | SrcXLat | ByteOp, em_mov),
7448 - /* 0xD8 - 0xDF */
7449 - N, E(0, &escape_d9), N, E(0, &escape_db), N, E(0, &escape_dd), N, N,
7450 - /* 0xE0 - 0xE7 */
7451 -@@ -4188,6 +4218,16 @@ static int decode_operand(struct x86_emulate_ctxt *ctxt, struct operand *op,
7452 - op->val = 0;
7453 - op->count = 1;
7454 - break;
7455 -+ case OpXLat:
7456 -+ op->type = OP_MEM;
7457 -+ op->bytes = (ctxt->d & ByteOp) ? 1 : ctxt->op_bytes;
7458 -+ op->addr.mem.ea =
7459 -+ register_address(ctxt,
7460 -+ reg_read(ctxt, VCPU_REGS_RBX) +
7461 -+ (reg_read(ctxt, VCPU_REGS_RAX) & 0xff));
7462 -+ op->addr.mem.seg = seg_override(ctxt);
7463 -+ op->val = 0;
7464 -+ break;
7465 - case OpImmFAddr:
7466 - op->type = OP_IMM;
7467 - op->addr.mem.ea = ctxt->_eip;
7468 -diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
7469 -index 6667042..0af1807 100644
7470 ---- a/arch/x86/kvm/vmx.c
7471 -+++ b/arch/x86/kvm/vmx.c
7472 -@@ -5197,6 +5197,12 @@ static int handle_invalid_guest_state(struct kvm_vcpu *vcpu)
7473 - return 0;
7474 - }
7475 -
7476 -+ if (vcpu->arch.halt_request) {
7477 -+ vcpu->arch.halt_request = 0;
7478 -+ ret = kvm_emulate_halt(vcpu);
7479 -+ goto out;
7480 -+ }
7481 -+
7482 - if (signal_pending(current))
7483 - goto out;
7484 - if (need_resched())
7485 -diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
7486 -index 2363127..cf95e19 100644
7487 ---- a/arch/x86/xen/enlighten.c
7488 -+++ b/arch/x86/xen/enlighten.c
7489 -@@ -156,6 +156,21 @@ static void xen_vcpu_setup(int cpu)
7490 -
7491 - BUG_ON(HYPERVISOR_shared_info == &xen_dummy_shared_info);
7492 -
7493 -+ /*
7494 -+ * This path is called twice on PVHVM - first during bootup via
7495 -+ * smp_init -> xen_hvm_cpu_notify, and then if the VCPU is being
7496 -+ * hotplugged: cpu_up -> xen_hvm_cpu_notify.
7497 -+ * As we can only do the VCPUOP_register_vcpu_info once lets
7498 -+ * not over-write its result.
7499 -+ *
7500 -+ * For PV it is called during restore (xen_vcpu_restore) and bootup
7501 -+ * (xen_setup_vcpu_info_placement). The hotplug mechanism does not
7502 -+ * use this function.
7503 -+ */
7504 -+ if (xen_hvm_domain()) {
7505 -+ if (per_cpu(xen_vcpu, cpu) == &per_cpu(xen_vcpu_info, cpu))
7506 -+ return;
7507 -+ }
7508 - if (cpu < MAX_VIRT_CPUS)
7509 - per_cpu(xen_vcpu,cpu) = &HYPERVISOR_shared_info->vcpu_info[cpu];
7510 -
7511 -diff --git a/drivers/acpi/acpica/exfldio.c b/drivers/acpi/acpica/exfldio.c
7512 -index ec7f569..c84ee95 100644
7513 ---- a/drivers/acpi/acpica/exfldio.c
7514 -+++ b/drivers/acpi/acpica/exfldio.c
7515 -@@ -720,7 +720,19 @@ acpi_ex_extract_from_field(union acpi_operand_object *obj_desc,
7516 -
7517 - if ((obj_desc->common_field.start_field_bit_offset == 0) &&
7518 - (obj_desc->common_field.bit_length == access_bit_width)) {
7519 -- status = acpi_ex_field_datum_io(obj_desc, 0, buffer, ACPI_READ);
7520 -+ if (buffer_length >= sizeof(u64)) {
7521 -+ status =
7522 -+ acpi_ex_field_datum_io(obj_desc, 0, buffer,
7523 -+ ACPI_READ);
7524 -+ } else {
7525 -+ /* Use raw_datum (u64) to handle buffers < 64 bits */
7526 -+
7527 -+ status =
7528 -+ acpi_ex_field_datum_io(obj_desc, 0, &raw_datum,
7529 -+ ACPI_READ);
7530 -+ ACPI_MEMCPY(buffer, &raw_datum, buffer_length);
7531 -+ }
7532 -+
7533 - return_ACPI_STATUS(status);
7534 - }
7535 -
7536 -diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
7537 -index d45b287..edc0081 100644
7538 ---- a/drivers/acpi/ec.c
7539 -+++ b/drivers/acpi/ec.c
7540 -@@ -223,7 +223,7 @@ static int ec_check_sci_sync(struct acpi_ec *ec, u8 state)
7541 - static int ec_poll(struct acpi_ec *ec)
7542 - {
7543 - unsigned long flags;
7544 -- int repeat = 2; /* number of command restarts */
7545 -+ int repeat = 5; /* number of command restarts */
7546 - while (repeat--) {
7547 - unsigned long delay = jiffies +
7548 - msecs_to_jiffies(ec_delay);
7549 -@@ -241,8 +241,6 @@ static int ec_poll(struct acpi_ec *ec)
7550 - }
7551 - advance_transaction(ec, acpi_ec_read_status(ec));
7552 - } while (time_before(jiffies, delay));
7553 -- if (acpi_ec_read_status(ec) & ACPI_EC_FLAG_IBF)
7554 -- break;
7555 - pr_debug(PREFIX "controller reset, restart transaction\n");
7556 - spin_lock_irqsave(&ec->lock, flags);
7557 - start_transaction(ec);
7558 -diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
7559 -index e98da67..54d03d4 100644
7560 ---- a/drivers/block/drbd/drbd_main.c
7561 -+++ b/drivers/block/drbd/drbd_main.c
7562 -@@ -2795,6 +2795,7 @@ void drbd_free_bc(struct drbd_backing_dev *ldev)
7563 - blkdev_put(ldev->backing_bdev, FMODE_READ | FMODE_WRITE | FMODE_EXCL);
7564 - blkdev_put(ldev->md_bdev, FMODE_READ | FMODE_WRITE | FMODE_EXCL);
7565 -
7566 -+ kfree(ldev->disk_conf);
7567 - kfree(ldev);
7568 - }
7569 -
7570 -diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
7571 -index a9eccfc..2f5fffd 100644
7572 ---- a/drivers/block/drbd/drbd_receiver.c
7573 -+++ b/drivers/block/drbd/drbd_receiver.c
7574 -@@ -2661,7 +2661,6 @@ static int drbd_asb_recover_1p(struct drbd_conf *mdev) __must_hold(local)
7575 - if (hg == -1 && mdev->state.role == R_PRIMARY) {
7576 - enum drbd_state_rv rv2;
7577 -
7578 -- drbd_set_role(mdev, R_SECONDARY, 0);
7579 - /* drbd_change_state() does not sleep while in SS_IN_TRANSIENT_STATE,
7580 - * we might be here in C_WF_REPORT_PARAMS which is transient.
7581 - * we do not need to wait for the after state change work either. */
7582 -@@ -4659,8 +4658,8 @@ static int drbd_do_features(struct drbd_tconn *tconn)
7583 - #if !defined(CONFIG_CRYPTO_HMAC) && !defined(CONFIG_CRYPTO_HMAC_MODULE)
7584 - static int drbd_do_auth(struct drbd_tconn *tconn)
7585 - {
7586 -- dev_err(DEV, "This kernel was build without CONFIG_CRYPTO_HMAC.\n");
7587 -- dev_err(DEV, "You need to disable 'cram-hmac-alg' in drbd.conf.\n");
7588 -+ conn_err(tconn, "This kernel was build without CONFIG_CRYPTO_HMAC.\n");
7589 -+ conn_err(tconn, "You need to disable 'cram-hmac-alg' in drbd.conf.\n");
7590 - return -1;
7591 - }
7592 - #else
7593 -diff --git a/drivers/char/ipmi/ipmi_bt_sm.c b/drivers/char/ipmi/ipmi_bt_sm.c
7594 -index cdd4c09f..a22a7a5 100644
7595 ---- a/drivers/char/ipmi/ipmi_bt_sm.c
7596 -+++ b/drivers/char/ipmi/ipmi_bt_sm.c
7597 -@@ -95,9 +95,9 @@ struct si_sm_data {
7598 - enum bt_states state;
7599 - unsigned char seq; /* BT sequence number */
7600 - struct si_sm_io *io;
7601 -- unsigned char write_data[IPMI_MAX_MSG_LENGTH];
7602 -+ unsigned char write_data[IPMI_MAX_MSG_LENGTH + 2]; /* +2 for memcpy */
7603 - int write_count;
7604 -- unsigned char read_data[IPMI_MAX_MSG_LENGTH];
7605 -+ unsigned char read_data[IPMI_MAX_MSG_LENGTH + 2]; /* +2 for memcpy */
7606 - int read_count;
7607 - int truncated;
7608 - long timeout; /* microseconds countdown */
7609 -diff --git a/drivers/char/ipmi/ipmi_devintf.c b/drivers/char/ipmi/ipmi_devintf.c
7610 -index 9eb360f..d5a5f02 100644
7611 ---- a/drivers/char/ipmi/ipmi_devintf.c
7612 -+++ b/drivers/char/ipmi/ipmi_devintf.c
7613 -@@ -837,13 +837,25 @@ static long compat_ipmi_ioctl(struct file *filep, unsigned int cmd,
7614 - return ipmi_ioctl(filep, cmd, arg);
7615 - }
7616 - }
7617 -+
7618 -+static long unlocked_compat_ipmi_ioctl(struct file *filep, unsigned int cmd,
7619 -+ unsigned long arg)
7620 -+{
7621 -+ int ret;
7622 -+
7623 -+ mutex_lock(&ipmi_mutex);
7624 -+ ret = compat_ipmi_ioctl(filep, cmd, arg);
7625 -+ mutex_unlock(&ipmi_mutex);
7626 -+
7627 -+ return ret;
7628 -+}
7629 - #endif
7630 -
7631 - static const struct file_operations ipmi_fops = {
7632 - .owner = THIS_MODULE,
7633 - .unlocked_ioctl = ipmi_unlocked_ioctl,
7634 - #ifdef CONFIG_COMPAT
7635 -- .compat_ioctl = compat_ipmi_ioctl,
7636 -+ .compat_ioctl = unlocked_compat_ipmi_ioctl,
7637 - #endif
7638 - .open = ipmi_open,
7639 - .release = ipmi_release,
7640 -diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
7641 -index 6133ef5..d8a8c9b 100644
7642 ---- a/drivers/cpufreq/intel_pstate.c
7643 -+++ b/drivers/cpufreq/intel_pstate.c
7644 -@@ -48,12 +48,7 @@ static inline int32_t div_fp(int32_t x, int32_t y)
7645 - }
7646 -
7647 - struct sample {
7648 -- ktime_t start_time;
7649 -- ktime_t end_time;
7650 - int core_pct_busy;
7651 -- int pstate_pct_busy;
7652 -- u64 duration_us;
7653 -- u64 idletime_us;
7654 - u64 aperf;
7655 - u64 mperf;
7656 - int freq;
7657 -@@ -91,8 +86,6 @@ struct cpudata {
7658 - int min_pstate_count;
7659 - int idle_mode;
7660 -
7661 -- ktime_t prev_sample;
7662 -- u64 prev_idle_time_us;
7663 - u64 prev_aperf;
7664 - u64 prev_mperf;
7665 - int sample_ptr;
7666 -@@ -124,6 +117,8 @@ struct perf_limits {
7667 - int min_perf_pct;
7668 - int32_t max_perf;
7669 - int32_t min_perf;
7670 -+ int max_policy_pct;
7671 -+ int max_sysfs_pct;
7672 - };
7673 -
7674 - static struct perf_limits limits = {
7675 -@@ -132,6 +127,8 @@ static struct perf_limits limits = {
7676 - .max_perf = int_tofp(1),
7677 - .min_perf_pct = 0,
7678 - .min_perf = 0,
7679 -+ .max_policy_pct = 100,
7680 -+ .max_sysfs_pct = 100,
7681 - };
7682 -
7683 - static inline void pid_reset(struct _pid *pid, int setpoint, int busy,
7684 -@@ -302,7 +299,8 @@ static ssize_t store_max_perf_pct(struct kobject *a, struct attribute *b,
7685 - if (ret != 1)
7686 - return -EINVAL;
7687 -
7688 -- limits.max_perf_pct = clamp_t(int, input, 0 , 100);
7689 -+ limits.max_sysfs_pct = clamp_t(int, input, 0 , 100);
7690 -+ limits.max_perf_pct = min(limits.max_policy_pct, limits.max_sysfs_pct);
7691 - limits.max_perf = div_fp(int_tofp(limits.max_perf_pct), int_tofp(100));
7692 - return count;
7693 - }
7694 -@@ -450,48 +448,26 @@ static inline void intel_pstate_calc_busy(struct cpudata *cpu,
7695 - struct sample *sample)
7696 - {
7697 - u64 core_pct;
7698 -- sample->pstate_pct_busy = 100 - div64_u64(
7699 -- sample->idletime_us * 100,
7700 -- sample->duration_us);
7701 - core_pct = div64_u64(sample->aperf * 100, sample->mperf);
7702 - sample->freq = cpu->pstate.max_pstate * core_pct * 1000;
7703 -
7704 -- sample->core_pct_busy = div_s64((sample->pstate_pct_busy * core_pct),
7705 -- 100);
7706 -+ sample->core_pct_busy = core_pct;
7707 - }
7708 -
7709 - static inline void intel_pstate_sample(struct cpudata *cpu)
7710 - {
7711 -- ktime_t now;
7712 -- u64 idle_time_us;
7713 - u64 aperf, mperf;
7714 -
7715 -- now = ktime_get();
7716 -- idle_time_us = get_cpu_idle_time_us(cpu->cpu, NULL);
7717 --
7718 - rdmsrl(MSR_IA32_APERF, aperf);
7719 - rdmsrl(MSR_IA32_MPERF, mperf);
7720 -- /* for the first sample, don't actually record a sample, just
7721 -- * set the baseline */
7722 -- if (cpu->prev_idle_time_us > 0) {
7723 -- cpu->sample_ptr = (cpu->sample_ptr + 1) % SAMPLE_COUNT;
7724 -- cpu->samples[cpu->sample_ptr].start_time = cpu->prev_sample;
7725 -- cpu->samples[cpu->sample_ptr].end_time = now;
7726 -- cpu->samples[cpu->sample_ptr].duration_us =
7727 -- ktime_us_delta(now, cpu->prev_sample);
7728 -- cpu->samples[cpu->sample_ptr].idletime_us =
7729 -- idle_time_us - cpu->prev_idle_time_us;
7730 --
7731 -- cpu->samples[cpu->sample_ptr].aperf = aperf;
7732 -- cpu->samples[cpu->sample_ptr].mperf = mperf;
7733 -- cpu->samples[cpu->sample_ptr].aperf -= cpu->prev_aperf;
7734 -- cpu->samples[cpu->sample_ptr].mperf -= cpu->prev_mperf;
7735 --
7736 -- intel_pstate_calc_busy(cpu, &cpu->samples[cpu->sample_ptr]);
7737 -- }
7738 -+ cpu->sample_ptr = (cpu->sample_ptr + 1) % SAMPLE_COUNT;
7739 -+ cpu->samples[cpu->sample_ptr].aperf = aperf;
7740 -+ cpu->samples[cpu->sample_ptr].mperf = mperf;
7741 -+ cpu->samples[cpu->sample_ptr].aperf -= cpu->prev_aperf;
7742 -+ cpu->samples[cpu->sample_ptr].mperf -= cpu->prev_mperf;
7743 -+
7744 -+ intel_pstate_calc_busy(cpu, &cpu->samples[cpu->sample_ptr]);
7745 -
7746 -- cpu->prev_sample = now;
7747 -- cpu->prev_idle_time_us = idle_time_us;
7748 - cpu->prev_aperf = aperf;
7749 - cpu->prev_mperf = mperf;
7750 - }
7751 -@@ -575,22 +551,16 @@ static void intel_pstate_timer_func(unsigned long __data)
7752 - struct cpudata *cpu = (struct cpudata *) __data;
7753 -
7754 - intel_pstate_sample(cpu);
7755 -+ intel_pstate_adjust_busy_pstate(cpu);
7756 -
7757 -- if (!cpu->idle_mode)
7758 -- intel_pstate_adjust_busy_pstate(cpu);
7759 -- else
7760 -- intel_pstate_adjust_idle_pstate(cpu);
7761 --
7762 --#if defined(XPERF_FIX)
7763 - if (cpu->pstate.current_pstate == cpu->pstate.min_pstate) {
7764 - cpu->min_pstate_count++;
7765 - if (!(cpu->min_pstate_count % 5)) {
7766 - intel_pstate_set_pstate(cpu, cpu->pstate.max_pstate);
7767 -- intel_pstate_idle_mode(cpu);
7768 - }
7769 - } else
7770 - cpu->min_pstate_count = 0;
7771 --#endif
7772 -+
7773 - intel_pstate_set_sample_time(cpu);
7774 - }
7775 -
7776 -@@ -670,8 +640,9 @@ static int intel_pstate_set_policy(struct cpufreq_policy *policy)
7777 - limits.min_perf_pct = clamp_t(int, limits.min_perf_pct, 0 , 100);
7778 - limits.min_perf = div_fp(int_tofp(limits.min_perf_pct), int_tofp(100));
7779 -
7780 -- limits.max_perf_pct = policy->max * 100 / policy->cpuinfo.max_freq;
7781 -- limits.max_perf_pct = clamp_t(int, limits.max_perf_pct, 0 , 100);
7782 -+ limits.max_policy_pct = policy->max * 100 / policy->cpuinfo.max_freq;
7783 -+ limits.max_policy_pct = clamp_t(int, limits.max_policy_pct, 0 , 100);
7784 -+ limits.max_perf_pct = min(limits.max_policy_pct, limits.max_sysfs_pct);
7785 - limits.max_perf = div_fp(int_tofp(limits.max_perf_pct), int_tofp(100));
7786 -
7787 - if (policy->policy == CPUFREQ_POLICY_PERFORMANCE) {
7788 -diff --git a/drivers/dma/of-dma.c b/drivers/dma/of-dma.c
7789 -index 69d04d2..09c7ad1 100644
7790 ---- a/drivers/dma/of-dma.c
7791 -+++ b/drivers/dma/of-dma.c
7792 -@@ -93,6 +93,7 @@ int of_dma_controller_register(struct device_node *np,
7793 - {
7794 - struct of_dma *ofdma;
7795 - int nbcells;
7796 -+ const __be32 *prop;
7797 -
7798 - if (!np || !of_dma_xlate) {
7799 - pr_err("%s: not enough information provided\n", __func__);
7800 -@@ -103,8 +104,11 @@ int of_dma_controller_register(struct device_node *np,
7801 - if (!ofdma)
7802 - return -ENOMEM;
7803 -
7804 -- nbcells = be32_to_cpup(of_get_property(np, "#dma-cells", NULL));
7805 -- if (!nbcells) {
7806 -+ prop = of_get_property(np, "#dma-cells", NULL);
7807 -+ if (prop)
7808 -+ nbcells = be32_to_cpup(prop);
7809 -+
7810 -+ if (!prop || !nbcells) {
7811 - pr_err("%s: #dma-cells property is missing or invalid\n",
7812 - __func__);
7813 - kfree(ofdma);
7814 -diff --git a/drivers/dma/pch_dma.c b/drivers/dma/pch_dma.c
7815 -index d01faeb..ce3dc3e 100644
7816 ---- a/drivers/dma/pch_dma.c
7817 -+++ b/drivers/dma/pch_dma.c
7818 -@@ -476,7 +476,7 @@ static struct pch_dma_desc *pdc_desc_get(struct pch_dma_chan *pd_chan)
7819 - dev_dbg(chan2dev(&pd_chan->chan), "scanned %d descriptors\n", i);
7820 -
7821 - if (!ret) {
7822 -- ret = pdc_alloc_desc(&pd_chan->chan, GFP_NOIO);
7823 -+ ret = pdc_alloc_desc(&pd_chan->chan, GFP_ATOMIC);
7824 - if (ret) {
7825 - spin_lock(&pd_chan->lock);
7826 - pd_chan->descs_allocated++;
7827 -diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
7828 -index dd64a06..016c5d8 100644
7829 ---- a/drivers/gpu/drm/drm_crtc.c
7830 -+++ b/drivers/gpu/drm/drm_crtc.c
7831 -@@ -78,6 +78,10 @@ void drm_warn_on_modeset_not_all_locked(struct drm_device *dev)
7832 - {
7833 - struct drm_crtc *crtc;
7834 -
7835 -+ /* Locking is currently fubar in the panic handler. */
7836 -+ if (oops_in_progress)
7837 -+ return;
7838 -+
7839 - list_for_each_entry(crtc, &dev->mode_config.crtc_list, head)
7840 - WARN_ON(!mutex_is_locked(&crtc->mutex));
7841 -
7842 -diff --git a/drivers/gpu/drm/drm_mm.c b/drivers/gpu/drm/drm_mm.c
7843 -index db1e2d6..07cf99c 100644
7844 ---- a/drivers/gpu/drm/drm_mm.c
7845 -+++ b/drivers/gpu/drm/drm_mm.c
7846 -@@ -755,33 +755,35 @@ void drm_mm_debug_table(struct drm_mm *mm, const char *prefix)
7847 - EXPORT_SYMBOL(drm_mm_debug_table);
7848 -
7849 - #if defined(CONFIG_DEBUG_FS)
7850 --int drm_mm_dump_table(struct seq_file *m, struct drm_mm *mm)
7851 -+static unsigned long drm_mm_dump_hole(struct seq_file *m, struct drm_mm_node *entry)
7852 - {
7853 -- struct drm_mm_node *entry;
7854 -- unsigned long total_used = 0, total_free = 0, total = 0;
7855 - unsigned long hole_start, hole_end, hole_size;
7856 -
7857 -- hole_start = drm_mm_hole_node_start(&mm->head_node);
7858 -- hole_end = drm_mm_hole_node_end(&mm->head_node);
7859 -- hole_size = hole_end - hole_start;
7860 -- if (hole_size)
7861 -+ if (entry->hole_follows) {
7862 -+ hole_start = drm_mm_hole_node_start(entry);
7863 -+ hole_end = drm_mm_hole_node_end(entry);
7864 -+ hole_size = hole_end - hole_start;
7865 - seq_printf(m, "0x%08lx-0x%08lx: 0x%08lx: free\n",
7866 - hole_start, hole_end, hole_size);
7867 -- total_free += hole_size;
7868 -+ return hole_size;
7869 -+ }
7870 -+
7871 -+ return 0;
7872 -+}
7873 -+
7874 -+int drm_mm_dump_table(struct seq_file *m, struct drm_mm *mm)
7875 -+{
7876 -+ struct drm_mm_node *entry;
7877 -+ unsigned long total_used = 0, total_free = 0, total = 0;
7878 -+
7879 -+ total_free += drm_mm_dump_hole(m, &mm->head_node);
7880 -
7881 - drm_mm_for_each_node(entry, mm) {
7882 - seq_printf(m, "0x%08lx-0x%08lx: 0x%08lx: used\n",
7883 - entry->start, entry->start + entry->size,
7884 - entry->size);
7885 - total_used += entry->size;
7886 -- if (entry->hole_follows) {
7887 -- hole_start = drm_mm_hole_node_start(entry);
7888 -- hole_end = drm_mm_hole_node_end(entry);
7889 -- hole_size = hole_end - hole_start;
7890 -- seq_printf(m, "0x%08lx-0x%08lx: 0x%08lx: free\n",
7891 -- hole_start, hole_end, hole_size);
7892 -- total_free += hole_size;
7893 -- }
7894 -+ total_free += drm_mm_dump_hole(m, entry);
7895 - }
7896 - total = total_free + total_used;
7897 -
7898 -diff --git a/drivers/gpu/drm/i915/intel_fb.c b/drivers/gpu/drm/i915/intel_fb.c
7899 -index 981bdce..898832b 100644
7900 ---- a/drivers/gpu/drm/i915/intel_fb.c
7901 -+++ b/drivers/gpu/drm/i915/intel_fb.c
7902 -@@ -261,10 +261,22 @@ void intel_fbdev_fini(struct drm_device *dev)
7903 - void intel_fbdev_set_suspend(struct drm_device *dev, int state)
7904 - {
7905 - drm_i915_private_t *dev_priv = dev->dev_private;
7906 -- if (!dev_priv->fbdev)
7907 -+ struct intel_fbdev *ifbdev = dev_priv->fbdev;
7908 -+ struct fb_info *info;
7909 -+
7910 -+ if (!ifbdev)
7911 - return;
7912 -
7913 -- fb_set_suspend(dev_priv->fbdev->helper.fbdev, state);
7914 -+ info = ifbdev->helper.fbdev;
7915 -+
7916 -+ /* On resume from hibernation: If the object is shmemfs backed, it has
7917 -+ * been restored from swap. If the object is stolen however, it will be
7918 -+ * full of whatever garbage was left in there.
7919 -+ */
7920 -+ if (!state && ifbdev->ifb.obj->stolen)
7921 -+ memset_io(info->screen_base, 0, info->screen_size);
7922 -+
7923 -+ fb_set_suspend(info, state);
7924 - }
7925 -
7926 - MODULE_LICENSE("GPL and additional rights");
7927 -diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mgag200/mgag200_mode.c
7928 -index 78d8e91..713dd70 100644
7929 ---- a/drivers/gpu/drm/mgag200/mgag200_mode.c
7930 -+++ b/drivers/gpu/drm/mgag200/mgag200_mode.c
7931 -@@ -189,12 +189,12 @@ static int mga_g200wb_set_plls(struct mga_device *mdev, long clock)
7932 - WREG8(DAC_INDEX, MGA1064_PIX_CLK_CTL);
7933 - tmp = RREG8(DAC_DATA);
7934 - tmp |= MGA1064_PIX_CLK_CTL_CLK_DIS;
7935 -- WREG_DAC(MGA1064_PIX_CLK_CTL_CLK_DIS, tmp);
7936 -+ WREG8(DAC_DATA, tmp);
7937 -
7938 - WREG8(DAC_INDEX, MGA1064_REMHEADCTL);
7939 - tmp = RREG8(DAC_DATA);
7940 - tmp |= MGA1064_REMHEADCTL_CLKDIS;
7941 -- WREG_DAC(MGA1064_REMHEADCTL, tmp);
7942 -+ WREG8(DAC_DATA, tmp);
7943 -
7944 - /* select PLL Set C */
7945 - tmp = RREG8(MGAREG_MEM_MISC_READ);
7946 -@@ -204,7 +204,7 @@ static int mga_g200wb_set_plls(struct mga_device *mdev, long clock)
7947 - WREG8(DAC_INDEX, MGA1064_PIX_CLK_CTL);
7948 - tmp = RREG8(DAC_DATA);
7949 - tmp |= MGA1064_PIX_CLK_CTL_CLK_POW_DOWN | 0x80;
7950 -- WREG_DAC(MGA1064_PIX_CLK_CTL, tmp);
7951 -+ WREG8(DAC_DATA, tmp);
7952 -
7953 - udelay(500);
7954 -
7955 -@@ -212,7 +212,7 @@ static int mga_g200wb_set_plls(struct mga_device *mdev, long clock)
7956 - WREG8(DAC_INDEX, MGA1064_VREF_CTL);
7957 - tmp = RREG8(DAC_DATA);
7958 - tmp &= ~0x04;
7959 -- WREG_DAC(MGA1064_VREF_CTL, tmp);
7960 -+ WREG8(DAC_DATA, tmp);
7961 -
7962 - udelay(50);
7963 -
7964 -@@ -236,13 +236,13 @@ static int mga_g200wb_set_plls(struct mga_device *mdev, long clock)
7965 - tmp = RREG8(DAC_DATA);
7966 - tmp &= ~MGA1064_PIX_CLK_CTL_SEL_MSK;
7967 - tmp |= MGA1064_PIX_CLK_CTL_SEL_PLL;
7968 -- WREG_DAC(MGA1064_PIX_CLK_CTL, tmp);
7969 -+ WREG8(DAC_DATA, tmp);
7970 -
7971 - WREG8(DAC_INDEX, MGA1064_REMHEADCTL);
7972 - tmp = RREG8(DAC_DATA);
7973 - tmp &= ~MGA1064_REMHEADCTL_CLKSL_MSK;
7974 - tmp |= MGA1064_REMHEADCTL_CLKSL_PLL;
7975 -- WREG_DAC(MGA1064_REMHEADCTL, tmp);
7976 -+ WREG8(DAC_DATA, tmp);
7977 -
7978 - /* reset dotclock rate bit */
7979 - WREG8(MGAREG_SEQ_INDEX, 1);
7980 -@@ -253,7 +253,7 @@ static int mga_g200wb_set_plls(struct mga_device *mdev, long clock)
7981 - WREG8(DAC_INDEX, MGA1064_PIX_CLK_CTL);
7982 - tmp = RREG8(DAC_DATA);
7983 - tmp &= ~MGA1064_PIX_CLK_CTL_CLK_DIS;
7984 -- WREG_DAC(MGA1064_PIX_CLK_CTL, tmp);
7985 -+ WREG8(DAC_DATA, tmp);
7986 -
7987 - vcount = RREG8(MGAREG_VCOUNT);
7988 -
7989 -@@ -318,7 +318,7 @@ static int mga_g200ev_set_plls(struct mga_device *mdev, long clock)
7990 - WREG8(DAC_INDEX, MGA1064_PIX_CLK_CTL);
7991 - tmp = RREG8(DAC_DATA);
7992 - tmp |= MGA1064_PIX_CLK_CTL_CLK_DIS;
7993 -- WREG_DAC(MGA1064_PIX_CLK_CTL_CLK_DIS, tmp);
7994 -+ WREG8(DAC_DATA, tmp);
7995 -
7996 - tmp = RREG8(MGAREG_MEM_MISC_READ);
7997 - tmp |= 0x3 << 2;
7998 -@@ -326,12 +326,12 @@ static int mga_g200ev_set_plls(struct mga_device *mdev, long clock)
7999 -
8000 - WREG8(DAC_INDEX, MGA1064_PIX_PLL_STAT);
8001 - tmp = RREG8(DAC_DATA);
8002 -- WREG_DAC(MGA1064_PIX_PLL_STAT, tmp & ~0x40);
8003 -+ WREG8(DAC_DATA, tmp & ~0x40);
8004 -
8005 - WREG8(DAC_INDEX, MGA1064_PIX_CLK_CTL);
8006 - tmp = RREG8(DAC_DATA);
8007 - tmp |= MGA1064_PIX_CLK_CTL_CLK_POW_DOWN;
8008 -- WREG_DAC(MGA1064_PIX_CLK_CTL, tmp);
8009 -+ WREG8(DAC_DATA, tmp);
8010 -
8011 - WREG_DAC(MGA1064_EV_PIX_PLLC_M, m);
8012 - WREG_DAC(MGA1064_EV_PIX_PLLC_N, n);
8013 -@@ -342,7 +342,7 @@ static int mga_g200ev_set_plls(struct mga_device *mdev, long clock)
8014 - WREG8(DAC_INDEX, MGA1064_PIX_CLK_CTL);
8015 - tmp = RREG8(DAC_DATA);
8016 - tmp &= ~MGA1064_PIX_CLK_CTL_CLK_POW_DOWN;
8017 -- WREG_DAC(MGA1064_PIX_CLK_CTL, tmp);
8018 -+ WREG8(DAC_DATA, tmp);
8019 -
8020 - udelay(500);
8021 -
8022 -@@ -350,11 +350,11 @@ static int mga_g200ev_set_plls(struct mga_device *mdev, long clock)
8023 - tmp = RREG8(DAC_DATA);
8024 - tmp &= ~MGA1064_PIX_CLK_CTL_SEL_MSK;
8025 - tmp |= MGA1064_PIX_CLK_CTL_SEL_PLL;
8026 -- WREG_DAC(MGA1064_PIX_CLK_CTL, tmp);
8027 -+ WREG8(DAC_DATA, tmp);
8028 -
8029 - WREG8(DAC_INDEX, MGA1064_PIX_PLL_STAT);
8030 - tmp = RREG8(DAC_DATA);
8031 -- WREG_DAC(MGA1064_PIX_PLL_STAT, tmp | 0x40);
8032 -+ WREG8(DAC_DATA, tmp | 0x40);
8033 -
8034 - tmp = RREG8(MGAREG_MEM_MISC_READ);
8035 - tmp |= (0x3 << 2);
8036 -@@ -363,7 +363,7 @@ static int mga_g200ev_set_plls(struct mga_device *mdev, long clock)
8037 - WREG8(DAC_INDEX, MGA1064_PIX_CLK_CTL);
8038 - tmp = RREG8(DAC_DATA);
8039 - tmp &= ~MGA1064_PIX_CLK_CTL_CLK_DIS;
8040 -- WREG_DAC(MGA1064_PIX_CLK_CTL, tmp);
8041 -+ WREG8(DAC_DATA, tmp);
8042 -
8043 - return 0;
8044 - }
8045 -@@ -416,7 +416,7 @@ static int mga_g200eh_set_plls(struct mga_device *mdev, long clock)
8046 - WREG8(DAC_INDEX, MGA1064_PIX_CLK_CTL);
8047 - tmp = RREG8(DAC_DATA);
8048 - tmp |= MGA1064_PIX_CLK_CTL_CLK_DIS;
8049 -- WREG_DAC(MGA1064_PIX_CLK_CTL_CLK_DIS, tmp);
8050 -+ WREG8(DAC_DATA, tmp);
8051 -
8052 - tmp = RREG8(MGAREG_MEM_MISC_READ);
8053 - tmp |= 0x3 << 2;
8054 -@@ -425,7 +425,7 @@ static int mga_g200eh_set_plls(struct mga_device *mdev, long clock)
8055 - WREG8(DAC_INDEX, MGA1064_PIX_CLK_CTL);
8056 - tmp = RREG8(DAC_DATA);
8057 - tmp |= MGA1064_PIX_CLK_CTL_CLK_POW_DOWN;
8058 -- WREG_DAC(MGA1064_PIX_CLK_CTL, tmp);
8059 -+ WREG8(DAC_DATA, tmp);
8060 -
8061 - udelay(500);
8062 -
8063 -@@ -439,13 +439,13 @@ static int mga_g200eh_set_plls(struct mga_device *mdev, long clock)
8064 - tmp = RREG8(DAC_DATA);
8065 - tmp &= ~MGA1064_PIX_CLK_CTL_SEL_MSK;
8066 - tmp |= MGA1064_PIX_CLK_CTL_SEL_PLL;
8067 -- WREG_DAC(MGA1064_PIX_CLK_CTL, tmp);
8068 -+ WREG8(DAC_DATA, tmp);
8069 -
8070 - WREG8(DAC_INDEX, MGA1064_PIX_CLK_CTL);
8071 - tmp = RREG8(DAC_DATA);
8072 - tmp &= ~MGA1064_PIX_CLK_CTL_CLK_DIS;
8073 - tmp &= ~MGA1064_PIX_CLK_CTL_CLK_POW_DOWN;
8074 -- WREG_DAC(MGA1064_PIX_CLK_CTL, tmp);
8075 -+ WREG8(DAC_DATA, tmp);
8076 -
8077 - vcount = RREG8(MGAREG_VCOUNT);
8078 -
8079 -@@ -515,12 +515,12 @@ static int mga_g200er_set_plls(struct mga_device *mdev, long clock)
8080 - WREG8(DAC_INDEX, MGA1064_PIX_CLK_CTL);
8081 - tmp = RREG8(DAC_DATA);
8082 - tmp |= MGA1064_PIX_CLK_CTL_CLK_DIS;
8083 -- WREG_DAC(MGA1064_PIX_CLK_CTL_CLK_DIS, tmp);
8084 -+ WREG8(DAC_DATA, tmp);
8085 -
8086 - WREG8(DAC_INDEX, MGA1064_REMHEADCTL);
8087 - tmp = RREG8(DAC_DATA);
8088 - tmp |= MGA1064_REMHEADCTL_CLKDIS;
8089 -- WREG_DAC(MGA1064_REMHEADCTL, tmp);
8090 -+ WREG8(DAC_DATA, tmp);
8091 -
8092 - tmp = RREG8(MGAREG_MEM_MISC_READ);
8093 - tmp |= (0x3<<2) | 0xc0;
8094 -@@ -530,7 +530,7 @@ static int mga_g200er_set_plls(struct mga_device *mdev, long clock)
8095 - tmp = RREG8(DAC_DATA);
8096 - tmp &= ~MGA1064_PIX_CLK_CTL_CLK_DIS;
8097 - tmp |= MGA1064_PIX_CLK_CTL_CLK_POW_DOWN;
8098 -- WREG_DAC(MGA1064_PIX_CLK_CTL, tmp);
8099 -+ WREG8(DAC_DATA, tmp);
8100 -
8101 - udelay(500);
8102 -
8103 -@@ -657,12 +657,26 @@ static void mga_g200wb_commit(struct drm_crtc *crtc)
8104 - WREG_DAC(MGA1064_GEN_IO_DATA, tmp);
8105 - }
8106 -
8107 --
8108 -+/*
8109 -+ This is how the framebuffer base address is stored in g200 cards:
8110 -+ * Assume @offset is the gpu_addr variable of the framebuffer object
8111 -+ * Then addr is the number of _pixels_ (not bytes) from the start of
8112 -+ VRAM to the first pixel we want to display. (divided by 2 for 32bit
8113 -+ framebuffers)
8114 -+ * addr is stored in the CRTCEXT0, CRTCC and CRTCD registers
8115 -+ addr<20> -> CRTCEXT0<6>
8116 -+ addr<19-16> -> CRTCEXT0<3-0>
8117 -+ addr<15-8> -> CRTCC<7-0>
8118 -+ addr<7-0> -> CRTCD<7-0>
8119 -+ CRTCEXT0 has to be programmed last to trigger an update and make the
8120 -+ new addr variable take effect.
8121 -+ */
8122 - void mga_set_start_address(struct drm_crtc *crtc, unsigned offset)
8123 - {
8124 - struct mga_device *mdev = crtc->dev->dev_private;
8125 - u32 addr;
8126 - int count;
8127 -+ u8 crtcext0;
8128 -
8129 - while (RREG8(0x1fda) & 0x08);
8130 - while (!(RREG8(0x1fda) & 0x08));
8131 -@@ -670,10 +684,17 @@ void mga_set_start_address(struct drm_crtc *crtc, unsigned offset)
8132 - count = RREG8(MGAREG_VCOUNT) + 2;
8133 - while (RREG8(MGAREG_VCOUNT) < count);
8134 -
8135 -- addr = offset >> 2;
8136 -+ WREG8(MGAREG_CRTCEXT_INDEX, 0);
8137 -+ crtcext0 = RREG8(MGAREG_CRTCEXT_DATA);
8138 -+ crtcext0 &= 0xB0;
8139 -+ addr = offset / 8;
8140 -+ /* Can't store addresses any higher than that...
8141 -+ but we also don't have more than 16MB of memory, so it should be fine. */
8142 -+ WARN_ON(addr > 0x1fffff);
8143 -+ crtcext0 |= (!!(addr & (1<<20)))<<6;
8144 - WREG_CRT(0x0d, (u8)(addr & 0xff));
8145 - WREG_CRT(0x0c, (u8)(addr >> 8) & 0xff);
8146 -- WREG_CRT(0xaf, (u8)(addr >> 16) & 0xf);
8147 -+ WREG_ECRT(0x0, ((u8)(addr >> 16) & 0xf) | crtcext0);
8148 - }
8149 -
8150 -
8151 -diff --git a/drivers/gpu/drm/radeon/r300_cmdbuf.c b/drivers/gpu/drm/radeon/r300_cmdbuf.c
8152 -index 865e2c9..60170ea 100644
8153 ---- a/drivers/gpu/drm/radeon/r300_cmdbuf.c
8154 -+++ b/drivers/gpu/drm/radeon/r300_cmdbuf.c
8155 -@@ -75,7 +75,7 @@ static int r300_emit_cliprects(drm_radeon_private_t *dev_priv,
8156 - OUT_RING(CP_PACKET0(R300_RE_CLIPRECT_TL_0, nr * 2 - 1));
8157 -
8158 - for (i = 0; i < nr; ++i) {
8159 -- if (DRM_COPY_FROM_USER_UNCHECKED
8160 -+ if (DRM_COPY_FROM_USER
8161 - (&box, &cmdbuf->boxes[n + i], sizeof(box))) {
8162 - DRM_ERROR("copy cliprect faulted\n");
8163 - return -EFAULT;
8164 -diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
8165 -index 66a7f0f..96cf439 100644
8166 ---- a/drivers/gpu/drm/radeon/radeon_drv.c
8167 -+++ b/drivers/gpu/drm/radeon/radeon_drv.c
8168 -@@ -144,7 +144,7 @@ static inline void radeon_unregister_atpx_handler(void) {}
8169 - #endif
8170 -
8171 - int radeon_no_wb;
8172 --int radeon_modeset = 1;
8173 -+int radeon_modeset = -1;
8174 - int radeon_dynclks = -1;
8175 - int radeon_r4xx_atom = 0;
8176 - int radeon_agpmode = 0;
8177 -@@ -449,6 +449,16 @@ static struct pci_driver radeon_kms_pci_driver = {
8178 -
8179 - static int __init radeon_init(void)
8180 - {
8181 -+#ifdef CONFIG_VGA_CONSOLE
8182 -+ if (vgacon_text_force() && radeon_modeset == -1) {
8183 -+ DRM_INFO("VGACON disable radeon kernel modesetting.\n");
8184 -+ radeon_modeset = 0;
8185 -+ }
8186 -+#endif
8187 -+ /* set to modesetting by default if not nomodeset */
8188 -+ if (radeon_modeset == -1)
8189 -+ radeon_modeset = 1;
8190 -+
8191 - if (radeon_modeset == 1) {
8192 - DRM_INFO("radeon kernel modesetting enabled.\n");
8193 - driver = &kms_driver;
8194 -diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
8195 -index aa341d1..e6dbf09 100644
8196 ---- a/drivers/hid/hid-core.c
8197 -+++ b/drivers/hid/hid-core.c
8198 -@@ -1702,6 +1702,7 @@ static const struct hid_device_id hid_have_special_driver[] = {
8199 - { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_NAVIGATION_CONTROLLER) },
8200 - { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) },
8201 - { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE) },
8202 -+ { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_VAIO_VGP_MOUSE) },
8203 - { HID_USB_DEVICE(USB_VENDOR_ID_STEELSERIES, USB_DEVICE_ID_STEELSERIES_SRWS1) },
8204 - { HID_USB_DEVICE(USB_VENDOR_ID_SUNPLUS, USB_DEVICE_ID_SUNPLUS_WDESKTOP) },
8205 - { HID_USB_DEVICE(USB_VENDOR_ID_THINGM, USB_DEVICE_ID_BLINK1) },
8206 -diff --git a/drivers/md/dm-bufio.c b/drivers/md/dm-bufio.c
8207 -index c608313..0387e05 100644
8208 ---- a/drivers/md/dm-bufio.c
8209 -+++ b/drivers/md/dm-bufio.c
8210 -@@ -319,6 +319,9 @@ static void __cache_size_refresh(void)
8211 - static void *alloc_buffer_data(struct dm_bufio_client *c, gfp_t gfp_mask,
8212 - enum data_mode *data_mode)
8213 - {
8214 -+ unsigned noio_flag;
8215 -+ void *ptr;
8216 -+
8217 - if (c->block_size <= DM_BUFIO_BLOCK_SIZE_SLAB_LIMIT) {
8218 - *data_mode = DATA_MODE_SLAB;
8219 - return kmem_cache_alloc(DM_BUFIO_CACHE(c), gfp_mask);
8220 -@@ -332,7 +335,26 @@ static void *alloc_buffer_data(struct dm_bufio_client *c, gfp_t gfp_mask,
8221 - }
8222 -
8223 - *data_mode = DATA_MODE_VMALLOC;
8224 -- return __vmalloc(c->block_size, gfp_mask, PAGE_KERNEL);
8225 -+
8226 -+ /*
8227 -+ * __vmalloc allocates the data pages and auxiliary structures with
8228 -+ * gfp_flags that were specified, but pagetables are always allocated
8229 -+ * with GFP_KERNEL, no matter what was specified as gfp_mask.
8230 -+ *
8231 -+ * Consequently, we must set per-process flag PF_MEMALLOC_NOIO so that
8232 -+ * all allocations done by this process (including pagetables) are done
8233 -+ * as if GFP_NOIO was specified.
8234 -+ */
8235 -+
8236 -+ if (gfp_mask & __GFP_NORETRY)
8237 -+ noio_flag = memalloc_noio_save();
8238 -+
8239 -+ ptr = __vmalloc(c->block_size, gfp_mask, PAGE_KERNEL);
8240 -+
8241 -+ if (gfp_mask & __GFP_NORETRY)
8242 -+ memalloc_noio_restore(noio_flag);
8243 -+
8244 -+ return ptr;
8245 - }
8246 -
8247 - /*
8248 -diff --git a/drivers/md/dm-cache-target.c b/drivers/md/dm-cache-target.c
8249 -index 1074409..6feaba2 100644
8250 ---- a/drivers/md/dm-cache-target.c
8251 -+++ b/drivers/md/dm-cache-target.c
8252 -@@ -1971,6 +1971,7 @@ static int cache_create(struct cache_args *ca, struct cache **result)
8253 - atomic_set(&cache->nr_migrations, 0);
8254 - init_waitqueue_head(&cache->migration_wait);
8255 -
8256 -+ r = -ENOMEM;
8257 - cache->nr_dirty = 0;
8258 - cache->dirty_bitset = alloc_bitset(from_cblock(cache->cache_size));
8259 - if (!cache->dirty_bitset) {
8260 -diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c
8261 -index c0e0702..c434e5a 100644
8262 ---- a/drivers/md/dm-snap.c
8263 -+++ b/drivers/md/dm-snap.c
8264 -@@ -1121,6 +1121,7 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv)
8265 - s->pending_pool = mempool_create_slab_pool(MIN_IOS, pending_cache);
8266 - if (!s->pending_pool) {
8267 - ti->error = "Could not allocate mempool for pending exceptions";
8268 -+ r = -ENOMEM;
8269 - goto bad_pending_pool;
8270 - }
8271 -
8272 -diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
8273 -index d8837d3..7b8b2b9 100644
8274 ---- a/drivers/md/dm-stripe.c
8275 -+++ b/drivers/md/dm-stripe.c
8276 -@@ -94,7 +94,7 @@ static int get_stripe(struct dm_target *ti, struct stripe_c *sc,
8277 - static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
8278 - {
8279 - struct stripe_c *sc;
8280 -- sector_t width;
8281 -+ sector_t width, tmp_len;
8282 - uint32_t stripes;
8283 - uint32_t chunk_size;
8284 - int r;
8285 -@@ -116,15 +116,16 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
8286 - }
8287 -
8288 - width = ti->len;
8289 -- if (sector_div(width, chunk_size)) {
8290 -+ if (sector_div(width, stripes)) {
8291 - ti->error = "Target length not divisible by "
8292 -- "chunk size";
8293 -+ "number of stripes";
8294 - return -EINVAL;
8295 - }
8296 -
8297 -- if (sector_div(width, stripes)) {
8298 -+ tmp_len = width;
8299 -+ if (sector_div(tmp_len, chunk_size)) {
8300 - ti->error = "Target length not divisible by "
8301 -- "number of stripes";
8302 -+ "chunk size";
8303 - return -EINVAL;
8304 - }
8305 -
8306 -diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
8307 -index e50dad0..1ff252a 100644
8308 ---- a/drivers/md/dm-table.c
8309 -+++ b/drivers/md/dm-table.c
8310 -@@ -1442,7 +1442,7 @@ static bool dm_table_supports_write_same(struct dm_table *t)
8311 - return false;
8312 -
8313 - if (!ti->type->iterate_devices ||
8314 -- !ti->type->iterate_devices(ti, device_not_write_same_capable, NULL))
8315 -+ ti->type->iterate_devices(ti, device_not_write_same_capable, NULL))
8316 - return false;
8317 - }
8318 -
8319 -diff --git a/drivers/net/ethernet/3com/3c509.c b/drivers/net/ethernet/3com/3c509.c
8320 -index f36ff99..adb4bf5 100644
8321 ---- a/drivers/net/ethernet/3com/3c509.c
8322 -+++ b/drivers/net/ethernet/3com/3c509.c
8323 -@@ -306,6 +306,7 @@ static int el3_isa_match(struct device *pdev, unsigned int ndev)
8324 - if (!dev)
8325 - return -ENOMEM;
8326 -
8327 -+ SET_NETDEV_DEV(dev, pdev);
8328 - netdev_boot_setup_check(dev);
8329 -
8330 - if (!request_region(ioaddr, EL3_IO_EXTENT, "3c509-isa")) {
8331 -@@ -595,6 +596,7 @@ static int __init el3_eisa_probe (struct device *device)
8332 - return -ENOMEM;
8333 - }
8334 -
8335 -+ SET_NETDEV_DEV(dev, device);
8336 - netdev_boot_setup_check(dev);
8337 -
8338 - el3_dev_fill(dev, phys_addr, ioaddr, irq, if_port, EL3_EISA);
8339 -diff --git a/drivers/net/ethernet/3com/3c59x.c b/drivers/net/ethernet/3com/3c59x.c
8340 -index 1928e20..072c6f1 100644
8341 ---- a/drivers/net/ethernet/3com/3c59x.c
8342 -+++ b/drivers/net/ethernet/3com/3c59x.c
8343 -@@ -632,7 +632,6 @@ struct vortex_private {
8344 - pm_state_valid:1, /* pci_dev->saved_config_space has sane contents */
8345 - open:1,
8346 - medialock:1,
8347 -- must_free_region:1, /* Flag: if zero, Cardbus owns the I/O region */
8348 - large_frames:1, /* accept large frames */
8349 - handling_irq:1; /* private in_irq indicator */
8350 - /* {get|set}_wol operations are already serialized by rtnl.
8351 -@@ -951,7 +950,7 @@ static int vortex_eisa_remove(struct device *device)
8352 -
8353 - unregister_netdev(dev);
8354 - iowrite16(TotalReset|0x14, ioaddr + EL3_CMD);
8355 -- release_region(dev->base_addr, VORTEX_TOTAL_SIZE);
8356 -+ release_region(edev->base_addr, VORTEX_TOTAL_SIZE);
8357 -
8358 - free_netdev(dev);
8359 - return 0;
8360 -@@ -1012,6 +1011,12 @@ static int vortex_init_one(struct pci_dev *pdev,
8361 - if (rc < 0)
8362 - goto out;
8363 -
8364 -+ rc = pci_request_regions(pdev, DRV_NAME);
8365 -+ if (rc < 0) {
8366 -+ pci_disable_device(pdev);
8367 -+ goto out;
8368 -+ }
8369 -+
8370 - unit = vortex_cards_found;
8371 -
8372 - if (global_use_mmio < 0 && (unit >= MAX_UNITS || use_mmio[unit] < 0)) {
8373 -@@ -1027,6 +1032,7 @@ static int vortex_init_one(struct pci_dev *pdev,
8374 - if (!ioaddr) /* If mapping fails, fall-back to BAR 0... */
8375 - ioaddr = pci_iomap(pdev, 0, 0);
8376 - if (!ioaddr) {
8377 -+ pci_release_regions(pdev);
8378 - pci_disable_device(pdev);
8379 - rc = -ENOMEM;
8380 - goto out;
8381 -@@ -1036,6 +1042,7 @@ static int vortex_init_one(struct pci_dev *pdev,
8382 - ent->driver_data, unit);
8383 - if (rc < 0) {
8384 - pci_iounmap(pdev, ioaddr);
8385 -+ pci_release_regions(pdev);
8386 - pci_disable_device(pdev);
8387 - goto out;
8388 - }
8389 -@@ -1178,11 +1185,6 @@ static int vortex_probe1(struct device *gendev, void __iomem *ioaddr, int irq,
8390 -
8391 - /* PCI-only startup logic */
8392 - if (pdev) {
8393 -- /* EISA resources already marked, so only PCI needs to do this here */
8394 -- /* Ignore return value, because Cardbus drivers already allocate for us */
8395 -- if (request_region(dev->base_addr, vci->io_size, print_name) != NULL)
8396 -- vp->must_free_region = 1;
8397 --
8398 - /* enable bus-mastering if necessary */
8399 - if (vci->flags & PCI_USES_MASTER)
8400 - pci_set_master(pdev);
8401 -@@ -1220,7 +1222,7 @@ static int vortex_probe1(struct device *gendev, void __iomem *ioaddr, int irq,
8402 - &vp->rx_ring_dma);
8403 - retval = -ENOMEM;
8404 - if (!vp->rx_ring)
8405 -- goto free_region;
8406 -+ goto free_device;
8407 -
8408 - vp->tx_ring = (struct boom_tx_desc *)(vp->rx_ring + RX_RING_SIZE);
8409 - vp->tx_ring_dma = vp->rx_ring_dma + sizeof(struct boom_rx_desc) * RX_RING_SIZE;
8410 -@@ -1484,9 +1486,7 @@ free_ring:
8411 - + sizeof(struct boom_tx_desc) * TX_RING_SIZE,
8412 - vp->rx_ring,
8413 - vp->rx_ring_dma);
8414 --free_region:
8415 -- if (vp->must_free_region)
8416 -- release_region(dev->base_addr, vci->io_size);
8417 -+free_device:
8418 - free_netdev(dev);
8419 - pr_err(PFX "vortex_probe1 fails. Returns %d\n", retval);
8420 - out:
8421 -@@ -3254,8 +3254,9 @@ static void vortex_remove_one(struct pci_dev *pdev)
8422 - + sizeof(struct boom_tx_desc) * TX_RING_SIZE,
8423 - vp->rx_ring,
8424 - vp->rx_ring_dma);
8425 -- if (vp->must_free_region)
8426 -- release_region(dev->base_addr, vp->io_size);
8427 -+
8428 -+ pci_release_regions(pdev);
8429 -+
8430 - free_netdev(dev);
8431 - }
8432 -
8433 -diff --git a/drivers/net/ethernet/sfc/mcdi.c b/drivers/net/ethernet/sfc/mcdi.c
8434 -index 0095ce9..97dd8f18 100644
8435 ---- a/drivers/net/ethernet/sfc/mcdi.c
8436 -+++ b/drivers/net/ethernet/sfc/mcdi.c
8437 -@@ -667,7 +667,7 @@ fail:
8438 - int efx_mcdi_get_board_cfg(struct efx_nic *efx, u8 *mac_address,
8439 - u16 *fw_subtype_list, u32 *capabilities)
8440 - {
8441 -- uint8_t outbuf[MC_CMD_GET_BOARD_CFG_OUT_LENMIN];
8442 -+ uint8_t outbuf[MC_CMD_GET_BOARD_CFG_OUT_LENMAX];
8443 - size_t outlen, offset, i;
8444 - int port_num = efx_port_num(efx);
8445 - int rc;
8446 -diff --git a/drivers/net/ethernet/tile/tilegx.c b/drivers/net/ethernet/tile/tilegx.c
8447 -index 66e025a..f3c2d03 100644
8448 ---- a/drivers/net/ethernet/tile/tilegx.c
8449 -+++ b/drivers/net/ethernet/tile/tilegx.c
8450 -@@ -930,7 +930,7 @@ static int tile_net_setup_interrupts(struct net_device *dev)
8451 - if (info->has_iqueue) {
8452 - gxio_mpipe_request_notif_ring_interrupt(
8453 - &context, cpu_x(cpu), cpu_y(cpu),
8454 -- 1, ingress_irq, info->iqueue.ring);
8455 -+ KERNEL_PL, ingress_irq, info->iqueue.ring);
8456 - }
8457 - }
8458 -
8459 -diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
8460 -index 73abbc1..011062e 100644
8461 ---- a/drivers/net/macvlan.c
8462 -+++ b/drivers/net/macvlan.c
8463 -@@ -222,7 +222,8 @@ static rx_handler_result_t macvlan_handle_frame(struct sk_buff **pskb)
8464 - }
8465 -
8466 - if (port->passthru)
8467 -- vlan = list_first_entry(&port->vlans, struct macvlan_dev, list);
8468 -+ vlan = list_first_or_null_rcu(&port->vlans,
8469 -+ struct macvlan_dev, list);
8470 - else
8471 - vlan = macvlan_hash_lookup(port, eth->h_dest);
8472 - if (vlan == NULL)
8473 -@@ -807,7 +808,7 @@ int macvlan_common_newlink(struct net *src_net, struct net_device *dev,
8474 - if (err < 0)
8475 - goto upper_dev_unlink;
8476 -
8477 -- list_add_tail(&vlan->list, &port->vlans);
8478 -+ list_add_tail_rcu(&vlan->list, &port->vlans);
8479 - netif_stacked_transfer_operstate(lowerdev, dev);
8480 -
8481 - return 0;
8482 -@@ -835,7 +836,7 @@ void macvlan_dellink(struct net_device *dev, struct list_head *head)
8483 - {
8484 - struct macvlan_dev *vlan = netdev_priv(dev);
8485 -
8486 -- list_del(&vlan->list);
8487 -+ list_del_rcu(&vlan->list);
8488 - unregister_netdevice_queue(dev, head);
8489 - netdev_upper_dev_unlink(vlan->lowerdev, dev);
8490 - }
8491 -diff --git a/drivers/net/tun.c b/drivers/net/tun.c
8492 -index 729ed53..755fa9e 100644
8493 ---- a/drivers/net/tun.c
8494 -+++ b/drivers/net/tun.c
8495 -@@ -1471,14 +1471,17 @@ static int tun_recvmsg(struct kiocb *iocb, struct socket *sock,
8496 - if (!tun)
8497 - return -EBADFD;
8498 -
8499 -- if (flags & ~(MSG_DONTWAIT|MSG_TRUNC))
8500 -- return -EINVAL;
8501 -+ if (flags & ~(MSG_DONTWAIT|MSG_TRUNC)) {
8502 -+ ret = -EINVAL;
8503 -+ goto out;
8504 -+ }
8505 - ret = tun_do_read(tun, tfile, iocb, m->msg_iov, total_len,
8506 - flags & MSG_DONTWAIT);
8507 - if (ret > total_len) {
8508 - m->msg_flags |= MSG_TRUNC;
8509 - ret = flags & MSG_TRUNC ? ret : total_len;
8510 - }
8511 -+out:
8512 - tun_put(tun);
8513 - return ret;
8514 - }
8515 -diff --git a/drivers/net/usb/asix_common.c b/drivers/net/usb/asix_common.c
8516 -index f7f623a..577c72d 100644
8517 ---- a/drivers/net/usb/asix_common.c
8518 -+++ b/drivers/net/usb/asix_common.c
8519 -@@ -100,6 +100,9 @@ int asix_rx_fixup_internal(struct usbnet *dev, struct sk_buff *skb,
8520 - netdev_err(dev->net, "asix_rx_fixup() Bad RX Length %d\n",
8521 - rx->size);
8522 - kfree_skb(rx->ax_skb);
8523 -+ rx->ax_skb = NULL;
8524 -+ rx->size = 0U;
8525 -+
8526 - return 0;
8527 - }
8528 -
8529 -diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
8530 -index 988372d..e509c37 100644
8531 ---- a/drivers/net/wireless/ath/ath9k/main.c
8532 -+++ b/drivers/net/wireless/ath/ath9k/main.c
8533 -@@ -1308,6 +1308,7 @@ static int ath9k_sta_add(struct ieee80211_hw *hw,
8534 - struct ath_common *common = ath9k_hw_common(sc->sc_ah);
8535 - struct ath_node *an = (struct ath_node *) sta->drv_priv;
8536 - struct ieee80211_key_conf ps_key = { };
8537 -+ int key;
8538 -
8539 - ath_node_attach(sc, sta, vif);
8540 -
8541 -@@ -1315,7 +1316,9 @@ static int ath9k_sta_add(struct ieee80211_hw *hw,
8542 - vif->type != NL80211_IFTYPE_AP_VLAN)
8543 - return 0;
8544 -
8545 -- an->ps_key = ath_key_config(common, vif, sta, &ps_key);
8546 -+ key = ath_key_config(common, vif, sta, &ps_key);
8547 -+ if (key > 0)
8548 -+ an->ps_key = key;
8549 -
8550 - return 0;
8551 - }
8552 -@@ -1332,6 +1335,7 @@ static void ath9k_del_ps_key(struct ath_softc *sc,
8553 - return;
8554 -
8555 - ath_key_delete(common, &ps_key);
8556 -+ an->ps_key = 0;
8557 - }
8558 -
8559 - static int ath9k_sta_remove(struct ieee80211_hw *hw,
8560 -diff --git a/drivers/net/wireless/b43/dma.c b/drivers/net/wireless/b43/dma.c
8561 -index 1221469..ee3d640 100644
8562 ---- a/drivers/net/wireless/b43/dma.c
8563 -+++ b/drivers/net/wireless/b43/dma.c
8564 -@@ -1733,6 +1733,25 @@ drop_recycle_buffer:
8565 - sync_descbuffer_for_device(ring, dmaaddr, ring->rx_buffersize);
8566 - }
8567 -
8568 -+void b43_dma_handle_rx_overflow(struct b43_dmaring *ring)
8569 -+{
8570 -+ int current_slot, previous_slot;
8571 -+
8572 -+ B43_WARN_ON(ring->tx);
8573 -+
8574 -+ /* Device has filled all buffers, drop all packets and let TCP
8575 -+ * decrease speed.
8576 -+ * Decrement RX index by one will let the device to see all slots
8577 -+ * as free again
8578 -+ */
8579 -+ /*
8580 -+ *TODO: How to increase rx_drop in mac80211?
8581 -+ */
8582 -+ current_slot = ring->ops->get_current_rxslot(ring);
8583 -+ previous_slot = prev_slot(ring, current_slot);
8584 -+ ring->ops->set_current_rxslot(ring, previous_slot);
8585 -+}
8586 -+
8587 - void b43_dma_rx(struct b43_dmaring *ring)
8588 - {
8589 - const struct b43_dma_ops *ops = ring->ops;
8590 -diff --git a/drivers/net/wireless/b43/dma.h b/drivers/net/wireless/b43/dma.h
8591 -index 9fdd198..df8c8cd 100644
8592 ---- a/drivers/net/wireless/b43/dma.h
8593 -+++ b/drivers/net/wireless/b43/dma.h
8594 -@@ -9,7 +9,7 @@
8595 - /* DMA-Interrupt reasons. */
8596 - #define B43_DMAIRQ_FATALMASK ((1 << 10) | (1 << 11) | (1 << 12) \
8597 - | (1 << 14) | (1 << 15))
8598 --#define B43_DMAIRQ_NONFATALMASK (1 << 13)
8599 -+#define B43_DMAIRQ_RDESC_UFLOW (1 << 13)
8600 - #define B43_DMAIRQ_RX_DONE (1 << 16)
8601 -
8602 - /*** 32-bit DMA Engine. ***/
8603 -@@ -295,6 +295,8 @@ int b43_dma_tx(struct b43_wldev *dev,
8604 - void b43_dma_handle_txstatus(struct b43_wldev *dev,
8605 - const struct b43_txstatus *status);
8606 -
8607 -+void b43_dma_handle_rx_overflow(struct b43_dmaring *ring);
8608 -+
8609 - void b43_dma_rx(struct b43_dmaring *ring);
8610 -
8611 - void b43_dma_direct_fifo_rx(struct b43_wldev *dev,
8612 -diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c
8613 -index 0568273..64b637a 100644
8614 ---- a/drivers/net/wireless/b43/main.c
8615 -+++ b/drivers/net/wireless/b43/main.c
8616 -@@ -1895,30 +1895,18 @@ static void b43_do_interrupt_thread(struct b43_wldev *dev)
8617 - }
8618 - }
8619 -
8620 -- if (unlikely(merged_dma_reason & (B43_DMAIRQ_FATALMASK |
8621 -- B43_DMAIRQ_NONFATALMASK))) {
8622 -- if (merged_dma_reason & B43_DMAIRQ_FATALMASK) {
8623 -- b43err(dev->wl, "Fatal DMA error: "
8624 -- "0x%08X, 0x%08X, 0x%08X, "
8625 -- "0x%08X, 0x%08X, 0x%08X\n",
8626 -- dma_reason[0], dma_reason[1],
8627 -- dma_reason[2], dma_reason[3],
8628 -- dma_reason[4], dma_reason[5]);
8629 -- b43err(dev->wl, "This device does not support DMA "
8630 -+ if (unlikely(merged_dma_reason & (B43_DMAIRQ_FATALMASK))) {
8631 -+ b43err(dev->wl,
8632 -+ "Fatal DMA error: 0x%08X, 0x%08X, 0x%08X, 0x%08X, 0x%08X, 0x%08X\n",
8633 -+ dma_reason[0], dma_reason[1],
8634 -+ dma_reason[2], dma_reason[3],
8635 -+ dma_reason[4], dma_reason[5]);
8636 -+ b43err(dev->wl, "This device does not support DMA "
8637 - "on your system. It will now be switched to PIO.\n");
8638 -- /* Fall back to PIO transfers if we get fatal DMA errors! */
8639 -- dev->use_pio = true;
8640 -- b43_controller_restart(dev, "DMA error");
8641 -- return;
8642 -- }
8643 -- if (merged_dma_reason & B43_DMAIRQ_NONFATALMASK) {
8644 -- b43err(dev->wl, "DMA error: "
8645 -- "0x%08X, 0x%08X, 0x%08X, "
8646 -- "0x%08X, 0x%08X, 0x%08X\n",
8647 -- dma_reason[0], dma_reason[1],
8648 -- dma_reason[2], dma_reason[3],
8649 -- dma_reason[4], dma_reason[5]);
8650 -- }
8651 -+ /* Fall back to PIO transfers if we get fatal DMA errors! */
8652 -+ dev->use_pio = true;
8653 -+ b43_controller_restart(dev, "DMA error");
8654 -+ return;
8655 - }
8656 -
8657 - if (unlikely(reason & B43_IRQ_UCODE_DEBUG))
8658 -@@ -1937,6 +1925,11 @@ static void b43_do_interrupt_thread(struct b43_wldev *dev)
8659 - handle_irq_noise(dev);
8660 -
8661 - /* Check the DMA reason registers for received data. */
8662 -+ if (dma_reason[0] & B43_DMAIRQ_RDESC_UFLOW) {
8663 -+ if (B43_DEBUG)
8664 -+ b43warn(dev->wl, "RX descriptor underrun\n");
8665 -+ b43_dma_handle_rx_overflow(dev->dma.rx_ring);
8666 -+ }
8667 - if (dma_reason[0] & B43_DMAIRQ_RX_DONE) {
8668 - if (b43_using_pio_transfers(dev))
8669 - b43_pio_rx(dev->pio.rx_queue);
8670 -@@ -1994,7 +1987,7 @@ static irqreturn_t b43_do_interrupt(struct b43_wldev *dev)
8671 - return IRQ_NONE;
8672 -
8673 - dev->dma_reason[0] = b43_read32(dev, B43_MMIO_DMA0_REASON)
8674 -- & 0x0001DC00;
8675 -+ & 0x0001FC00;
8676 - dev->dma_reason[1] = b43_read32(dev, B43_MMIO_DMA1_REASON)
8677 - & 0x0000DC00;
8678 - dev->dma_reason[2] = b43_read32(dev, B43_MMIO_DMA2_REASON)
8679 -@@ -3126,7 +3119,7 @@ static int b43_chip_init(struct b43_wldev *dev)
8680 - b43_write32(dev, 0x018C, 0x02000000);
8681 - }
8682 - b43_write32(dev, B43_MMIO_GEN_IRQ_REASON, 0x00004000);
8683 -- b43_write32(dev, B43_MMIO_DMA0_IRQ_MASK, 0x0001DC00);
8684 -+ b43_write32(dev, B43_MMIO_DMA0_IRQ_MASK, 0x0001FC00);
8685 - b43_write32(dev, B43_MMIO_DMA1_IRQ_MASK, 0x0000DC00);
8686 - b43_write32(dev, B43_MMIO_DMA2_IRQ_MASK, 0x0000DC00);
8687 - b43_write32(dev, B43_MMIO_DMA3_IRQ_MASK, 0x0001DC00);
8688 -diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c
8689 -index 7941eb3..cbaa777 100644
8690 ---- a/drivers/net/wireless/iwlegacy/4965-mac.c
8691 -+++ b/drivers/net/wireless/iwlegacy/4965-mac.c
8692 -@@ -5740,8 +5740,7 @@ il4965_mac_setup_register(struct il_priv *il, u32 max_probe_length)
8693 - hw->flags =
8694 - IEEE80211_HW_SIGNAL_DBM | IEEE80211_HW_AMPDU_AGGREGATION |
8695 - IEEE80211_HW_NEED_DTIM_BEFORE_ASSOC | IEEE80211_HW_SPECTRUM_MGMT |
8696 -- IEEE80211_HW_REPORTS_TX_ACK_STATUS | IEEE80211_HW_SUPPORTS_PS |
8697 -- IEEE80211_HW_SUPPORTS_DYNAMIC_PS;
8698 -+ IEEE80211_HW_SUPPORTS_PS | IEEE80211_HW_SUPPORTS_DYNAMIC_PS;
8699 - if (il->cfg->sku & IL_SKU_N)
8700 - hw->flags |=
8701 - IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS |
8702 -diff --git a/drivers/net/wireless/mwifiex/cfg80211.c b/drivers/net/wireless/mwifiex/cfg80211.c
8703 -index 8aaf56a..c13f6e9 100644
8704 ---- a/drivers/net/wireless/mwifiex/cfg80211.c
8705 -+++ b/drivers/net/wireless/mwifiex/cfg80211.c
8706 -@@ -2280,9 +2280,6 @@ int mwifiex_del_virtual_intf(struct wiphy *wiphy, struct wireless_dev *wdev)
8707 - if (wdev->netdev->reg_state == NETREG_REGISTERED)
8708 - unregister_netdevice(wdev->netdev);
8709 -
8710 -- if (wdev->netdev->reg_state == NETREG_UNREGISTERED)
8711 -- free_netdev(wdev->netdev);
8712 --
8713 - /* Clear the priv in adapter */
8714 - priv->netdev = NULL;
8715 -
8716 -diff --git a/drivers/net/wireless/mwifiex/cmdevt.c b/drivers/net/wireless/mwifiex/cmdevt.c
8717 -index b5c8b96..aeade10 100644
8718 ---- a/drivers/net/wireless/mwifiex/cmdevt.c
8719 -+++ b/drivers/net/wireless/mwifiex/cmdevt.c
8720 -@@ -1176,6 +1176,7 @@ mwifiex_process_hs_config(struct mwifiex_adapter *adapter)
8721 - adapter->if_ops.wakeup(adapter);
8722 - adapter->hs_activated = false;
8723 - adapter->is_hs_configured = false;
8724 -+ adapter->is_suspended = false;
8725 - mwifiex_hs_activated_event(mwifiex_get_priv(adapter,
8726 - MWIFIEX_BSS_ROLE_ANY),
8727 - false);
8728 -diff --git a/drivers/net/wireless/mwifiex/main.c b/drivers/net/wireless/mwifiex/main.c
8729 -index 9c802ed..6d9bc63 100644
8730 ---- a/drivers/net/wireless/mwifiex/main.c
8731 -+++ b/drivers/net/wireless/mwifiex/main.c
8732 -@@ -646,6 +646,7 @@ void mwifiex_init_priv_params(struct mwifiex_private *priv,
8733 - struct net_device *dev)
8734 - {
8735 - dev->netdev_ops = &mwifiex_netdev_ops;
8736 -+ dev->destructor = free_netdev;
8737 - /* Initialize private structure */
8738 - priv->current_key_index = 0;
8739 - priv->media_connected = false;
8740 -diff --git a/drivers/net/wireless/mwifiex/sta_ioctl.c b/drivers/net/wireless/mwifiex/sta_ioctl.c
8741 -index 13100f8..fb420fe 100644
8742 ---- a/drivers/net/wireless/mwifiex/sta_ioctl.c
8743 -+++ b/drivers/net/wireless/mwifiex/sta_ioctl.c
8744 -@@ -99,7 +99,7 @@ int mwifiex_request_set_multicast_list(struct mwifiex_private *priv,
8745 - } else {
8746 - /* Multicast */
8747 - priv->curr_pkt_filter &= ~HostCmd_ACT_MAC_PROMISCUOUS_ENABLE;
8748 -- if (mcast_list->mode == MWIFIEX_MULTICAST_MODE) {
8749 -+ if (mcast_list->mode == MWIFIEX_ALL_MULTI_MODE) {
8750 - dev_dbg(priv->adapter->dev,
8751 - "info: Enabling All Multicast!\n");
8752 - priv->curr_pkt_filter |=
8753 -@@ -111,20 +111,11 @@ int mwifiex_request_set_multicast_list(struct mwifiex_private *priv,
8754 - dev_dbg(priv->adapter->dev,
8755 - "info: Set multicast list=%d\n",
8756 - mcast_list->num_multicast_addr);
8757 -- /* Set multicast addresses to firmware */
8758 -- if (old_pkt_filter == priv->curr_pkt_filter) {
8759 -- /* Send request to firmware */
8760 -- ret = mwifiex_send_cmd_async(priv,
8761 -- HostCmd_CMD_MAC_MULTICAST_ADR,
8762 -- HostCmd_ACT_GEN_SET, 0,
8763 -- mcast_list);
8764 -- } else {
8765 -- /* Send request to firmware */
8766 -- ret = mwifiex_send_cmd_async(priv,
8767 -- HostCmd_CMD_MAC_MULTICAST_ADR,
8768 -- HostCmd_ACT_GEN_SET, 0,
8769 -- mcast_list);
8770 -- }
8771 -+ /* Send multicast addresses to firmware */
8772 -+ ret = mwifiex_send_cmd_async(priv,
8773 -+ HostCmd_CMD_MAC_MULTICAST_ADR,
8774 -+ HostCmd_ACT_GEN_SET, 0,
8775 -+ mcast_list);
8776 - }
8777 - }
8778 - }
8779 -diff --git a/drivers/platform/x86/hp_accel.c b/drivers/platform/x86/hp_accel.c
8780 -index e64a7a8..a8e43cf 100644
8781 ---- a/drivers/platform/x86/hp_accel.c
8782 -+++ b/drivers/platform/x86/hp_accel.c
8783 -@@ -362,7 +362,8 @@ static int lis3lv02d_suspend(struct device *dev)
8784 -
8785 - static int lis3lv02d_resume(struct device *dev)
8786 - {
8787 -- return lis3lv02d_poweron(&lis3_dev);
8788 -+ lis3lv02d_poweron(&lis3_dev);
8789 -+ return 0;
8790 - }
8791 -
8792 - static SIMPLE_DEV_PM_OPS(hp_accel_pm, lis3lv02d_suspend, lis3lv02d_resume);
8793 -diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
8794 -index 79fbe38..9e95473 100644
8795 ---- a/drivers/rtc/Kconfig
8796 -+++ b/drivers/rtc/Kconfig
8797 -@@ -20,7 +20,6 @@ if RTC_CLASS
8798 - config RTC_HCTOSYS
8799 - bool "Set system time from RTC on startup and resume"
8800 - default y
8801 -- depends on !ALWAYS_USE_PERSISTENT_CLOCK
8802 - help
8803 - If you say yes here, the system time (wall clock) will be set using
8804 - the value read from a specified RTC device. This is useful to avoid
8805 -@@ -29,7 +28,6 @@ config RTC_HCTOSYS
8806 - config RTC_SYSTOHC
8807 - bool "Set the RTC time based on NTP synchronization"
8808 - default y
8809 -- depends on !ALWAYS_USE_PERSISTENT_CLOCK
8810 - help
8811 - If you say yes here, the system time (wall clock) will be stored
8812 - in the RTC specified by RTC_HCTOSYS_DEVICE approximately every 11
8813 -diff --git a/drivers/rtc/rtc-pcf2123.c b/drivers/rtc/rtc-pcf2123.c
8814 -index 02b742a..6dd6b38 100644
8815 ---- a/drivers/rtc/rtc-pcf2123.c
8816 -+++ b/drivers/rtc/rtc-pcf2123.c
8817 -@@ -265,6 +265,7 @@ static int pcf2123_probe(struct spi_device *spi)
8818 -
8819 - if (!(rxbuf[0] & 0x20)) {
8820 - dev_err(&spi->dev, "chip not found\n");
8821 -+ ret = -ENODEV;
8822 - goto kfree_exit;
8823 - }
8824 -
8825 -diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
8826 -index 7992635..82910cc 100644
8827 ---- a/drivers/scsi/sd.c
8828 -+++ b/drivers/scsi/sd.c
8829 -@@ -142,6 +142,7 @@ sd_store_cache_type(struct device *dev, struct device_attribute *attr,
8830 - char *buffer_data;
8831 - struct scsi_mode_data data;
8832 - struct scsi_sense_hdr sshdr;
8833 -+ const char *temp = "temporary ";
8834 - int len;
8835 -
8836 - if (sdp->type != TYPE_DISK)
8837 -@@ -150,6 +151,13 @@ sd_store_cache_type(struct device *dev, struct device_attribute *attr,
8838 - * it's not worth the risk */
8839 - return -EINVAL;
8840 -
8841 -+ if (strncmp(buf, temp, sizeof(temp) - 1) == 0) {
8842 -+ buf += sizeof(temp) - 1;
8843 -+ sdkp->cache_override = 1;
8844 -+ } else {
8845 -+ sdkp->cache_override = 0;
8846 -+ }
8847 -+
8848 - for (i = 0; i < ARRAY_SIZE(sd_cache_types); i++) {
8849 - len = strlen(sd_cache_types[i]);
8850 - if (strncmp(sd_cache_types[i], buf, len) == 0 &&
8851 -@@ -162,6 +170,13 @@ sd_store_cache_type(struct device *dev, struct device_attribute *attr,
8852 - return -EINVAL;
8853 - rcd = ct & 0x01 ? 1 : 0;
8854 - wce = ct & 0x02 ? 1 : 0;
8855 -+
8856 -+ if (sdkp->cache_override) {
8857 -+ sdkp->WCE = wce;
8858 -+ sdkp->RCD = rcd;
8859 -+ return count;
8860 -+ }
8861 -+
8862 - if (scsi_mode_sense(sdp, 0x08, 8, buffer, sizeof(buffer), SD_TIMEOUT,
8863 - SD_MAX_RETRIES, &data, NULL))
8864 - return -EINVAL;
8865 -@@ -2319,6 +2334,10 @@ sd_read_cache_type(struct scsi_disk *sdkp, unsigned char *buffer)
8866 - int old_rcd = sdkp->RCD;
8867 - int old_dpofua = sdkp->DPOFUA;
8868 -
8869 -+
8870 -+ if (sdkp->cache_override)
8871 -+ return;
8872 -+
8873 - first_len = 4;
8874 - if (sdp->skip_ms_page_8) {
8875 - if (sdp->type == TYPE_RBC)
8876 -@@ -2812,6 +2831,7 @@ static void sd_probe_async(void *data, async_cookie_t cookie)
8877 - sdkp->capacity = 0;
8878 - sdkp->media_present = 1;
8879 - sdkp->write_prot = 0;
8880 -+ sdkp->cache_override = 0;
8881 - sdkp->WCE = 0;
8882 - sdkp->RCD = 0;
8883 - sdkp->ATO = 0;
8884 -diff --git a/drivers/scsi/sd.h b/drivers/scsi/sd.h
8885 -index 74a1e4c..2386aeb 100644
8886 ---- a/drivers/scsi/sd.h
8887 -+++ b/drivers/scsi/sd.h
8888 -@@ -73,6 +73,7 @@ struct scsi_disk {
8889 - u8 protection_type;/* Data Integrity Field */
8890 - u8 provisioning_mode;
8891 - unsigned ATO : 1; /* state of disk ATO bit */
8892 -+ unsigned cache_override : 1; /* temp override of WCE,RCD */
8893 - unsigned WCE : 1; /* state of disk WCE bit */
8894 - unsigned RCD : 1; /* state of disk RCD bit, unused */
8895 - unsigned DPOFUA : 1; /* state of disk DPOFUA bit */
8896 -diff --git a/drivers/target/iscsi/iscsi_target_erl1.c b/drivers/target/iscsi/iscsi_target_erl1.c
8897 -index 0b52a23..805f3d2 100644
8898 ---- a/drivers/target/iscsi/iscsi_target_erl1.c
8899 -+++ b/drivers/target/iscsi/iscsi_target_erl1.c
8900 -@@ -819,7 +819,7 @@ static int iscsit_attach_ooo_cmdsn(
8901 - /*
8902 - * CmdSN is greater than the tail of the list.
8903 - */
8904 -- if (ooo_tail->cmdsn < ooo_cmdsn->cmdsn)
8905 -+ if (iscsi_sna_lt(ooo_tail->cmdsn, ooo_cmdsn->cmdsn))
8906 - list_add_tail(&ooo_cmdsn->ooo_list,
8907 - &sess->sess_ooo_cmdsn_list);
8908 - else {
8909 -@@ -829,11 +829,12 @@ static int iscsit_attach_ooo_cmdsn(
8910 - */
8911 - list_for_each_entry(ooo_tmp, &sess->sess_ooo_cmdsn_list,
8912 - ooo_list) {
8913 -- if (ooo_tmp->cmdsn < ooo_cmdsn->cmdsn)
8914 -+ if (iscsi_sna_lt(ooo_tmp->cmdsn, ooo_cmdsn->cmdsn))
8915 - continue;
8916 -
8917 -+ /* Insert before this entry */
8918 - list_add(&ooo_cmdsn->ooo_list,
8919 -- &ooo_tmp->ooo_list);
8920 -+ ooo_tmp->ooo_list.prev);
8921 - break;
8922 - }
8923 - }
8924 -diff --git a/drivers/target/target_core_file.c b/drivers/target/target_core_file.c
8925 -index 17a6acb..ca4b219 100644
8926 ---- a/drivers/target/target_core_file.c
8927 -+++ b/drivers/target/target_core_file.c
8928 -@@ -148,13 +148,8 @@ static int fd_configure_device(struct se_device *dev)
8929 - */
8930 - inode = file->f_mapping->host;
8931 - if (S_ISBLK(inode->i_mode)) {
8932 -- struct request_queue *q = bdev_get_queue(inode->i_bdev);
8933 - unsigned long long dev_size;
8934 -
8935 -- dev->dev_attrib.hw_block_size =
8936 -- bdev_logical_block_size(inode->i_bdev);
8937 -- dev->dev_attrib.hw_max_sectors = queue_max_hw_sectors(q);
8938 --
8939 - /*
8940 - * Determine the number of bytes from i_size_read() minus
8941 - * one (1) logical sector from underlying struct block_device
8942 -@@ -173,13 +168,12 @@ static int fd_configure_device(struct se_device *dev)
8943 - " block_device\n");
8944 - goto fail;
8945 - }
8946 --
8947 -- dev->dev_attrib.hw_block_size = FD_BLOCKSIZE;
8948 -- dev->dev_attrib.hw_max_sectors = FD_MAX_SECTORS;
8949 - }
8950 -
8951 - fd_dev->fd_block_size = dev->dev_attrib.hw_block_size;
8952 -
8953 -+ dev->dev_attrib.hw_block_size = FD_BLOCKSIZE;
8954 -+ dev->dev_attrib.hw_max_sectors = FD_MAX_SECTORS;
8955 - dev->dev_attrib.hw_queue_depth = FD_MAX_DEVICE_QUEUE_DEPTH;
8956 -
8957 - if (fd_dev->fbd_flags & FDBD_HAS_BUFFERED_IO_WCE) {
8958 -diff --git a/drivers/target/target_core_iblock.c b/drivers/target/target_core_iblock.c
8959 -index 8bcc514..e1af9d5 100644
8960 ---- a/drivers/target/target_core_iblock.c
8961 -+++ b/drivers/target/target_core_iblock.c
8962 -@@ -679,6 +679,8 @@ iblock_execute_rw(struct se_cmd *cmd)
8963 - rw = WRITE_FUA;
8964 - else if (!(q->flush_flags & REQ_FLUSH))
8965 - rw = WRITE_FUA;
8966 -+ else
8967 -+ rw = WRITE;
8968 - } else {
8969 - rw = WRITE;
8970 - }
8971 -diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
8972 -index 3243ea7..0d46276 100644
8973 ---- a/drivers/target/target_core_transport.c
8974 -+++ b/drivers/target/target_core_transport.c
8975 -@@ -2213,21 +2213,19 @@ static void target_release_cmd_kref(struct kref *kref)
8976 - {
8977 - struct se_cmd *se_cmd = container_of(kref, struct se_cmd, cmd_kref);
8978 - struct se_session *se_sess = se_cmd->se_sess;
8979 -- unsigned long flags;
8980 -
8981 -- spin_lock_irqsave(&se_sess->sess_cmd_lock, flags);
8982 - if (list_empty(&se_cmd->se_cmd_list)) {
8983 -- spin_unlock_irqrestore(&se_sess->sess_cmd_lock, flags);
8984 -+ spin_unlock(&se_sess->sess_cmd_lock);
8985 - se_cmd->se_tfo->release_cmd(se_cmd);
8986 - return;
8987 - }
8988 - if (se_sess->sess_tearing_down && se_cmd->cmd_wait_set) {
8989 -- spin_unlock_irqrestore(&se_sess->sess_cmd_lock, flags);
8990 -+ spin_unlock(&se_sess->sess_cmd_lock);
8991 - complete(&se_cmd->cmd_wait_comp);
8992 - return;
8993 - }
8994 - list_del(&se_cmd->se_cmd_list);
8995 -- spin_unlock_irqrestore(&se_sess->sess_cmd_lock, flags);
8996 -+ spin_unlock(&se_sess->sess_cmd_lock);
8997 -
8998 - se_cmd->se_tfo->release_cmd(se_cmd);
8999 - }
9000 -@@ -2238,7 +2236,8 @@ static void target_release_cmd_kref(struct kref *kref)
9001 - */
9002 - int target_put_sess_cmd(struct se_session *se_sess, struct se_cmd *se_cmd)
9003 - {
9004 -- return kref_put(&se_cmd->cmd_kref, target_release_cmd_kref);
9005 -+ return kref_put_spinlock_irqsave(&se_cmd->cmd_kref, target_release_cmd_kref,
9006 -+ &se_sess->sess_cmd_lock);
9007 - }
9008 - EXPORT_SYMBOL(target_put_sess_cmd);
9009 -
9010 -diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c
9011 -index 08b48bb..faf4e18 100644
9012 ---- a/drivers/watchdog/watchdog_dev.c
9013 -+++ b/drivers/watchdog/watchdog_dev.c
9014 -@@ -523,6 +523,7 @@ int watchdog_dev_register(struct watchdog_device *watchdog)
9015 - int err, devno;
9016 -
9017 - if (watchdog->id == 0) {
9018 -+ old_wdd = watchdog;
9019 - watchdog_miscdev.parent = watchdog->parent;
9020 - err = misc_register(&watchdog_miscdev);
9021 - if (err != 0) {
9022 -@@ -531,9 +532,9 @@ int watchdog_dev_register(struct watchdog_device *watchdog)
9023 - if (err == -EBUSY)
9024 - pr_err("%s: a legacy watchdog module is probably present.\n",
9025 - watchdog->info->identity);
9026 -+ old_wdd = NULL;
9027 - return err;
9028 - }
9029 -- old_wdd = watchdog;
9030 - }
9031 -
9032 - /* Fill in the data structures */
9033 -diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
9034 -index cf3025c..f3190ab 100644
9035 ---- a/fs/ext4/mballoc.c
9036 -+++ b/fs/ext4/mballoc.c
9037 -@@ -1994,7 +1994,11 @@ repeat:
9038 - group = ac->ac_g_ex.fe_group;
9039 -
9040 - for (i = 0; i < ngroups; group++, i++) {
9041 -- if (group == ngroups)
9042 -+ /*
9043 -+ * Artificially restricted ngroups for non-extent
9044 -+ * files makes group > ngroups possible on first loop.
9045 -+ */
9046 -+ if (group >= ngroups)
9047 - group = 0;
9048 -
9049 - /* This now checks without needing the buddy page */
9050 -diff --git a/fs/namei.c b/fs/namei.c
9051 -index 57ae9c8..85e40d1 100644
9052 ---- a/fs/namei.c
9053 -+++ b/fs/namei.c
9054 -@@ -2740,7 +2740,7 @@ static int do_last(struct nameidata *nd, struct path *path,
9055 - if (error)
9056 - return error;
9057 -
9058 -- audit_inode(name, dir, 0);
9059 -+ audit_inode(name, dir, LOOKUP_PARENT);
9060 - error = -EISDIR;
9061 - /* trailing slashes? */
9062 - if (nd->last.name[nd->last.len])
9063 -diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
9064 -index 8288b08..d401d01 100644
9065 ---- a/fs/nfsd/nfs4proc.c
9066 -+++ b/fs/nfsd/nfs4proc.c
9067 -@@ -271,6 +271,7 @@ static __be32
9068 - do_open_fhandle(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_open *open)
9069 - {
9070 - __be32 status;
9071 -+ int accmode = 0;
9072 -
9073 - /* We don't know the target directory, and therefore can not
9074 - * set the change info
9075 -@@ -284,9 +285,19 @@ do_open_fhandle(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_
9076 -
9077 - open->op_truncate = (open->op_iattr.ia_valid & ATTR_SIZE) &&
9078 - (open->op_iattr.ia_size == 0);
9079 -+ /*
9080 -+ * In the delegation case, the client is telling us about an
9081 -+ * open that it *already* performed locally, some time ago. We
9082 -+ * should let it succeed now if possible.
9083 -+ *
9084 -+ * In the case of a CLAIM_FH open, on the other hand, the client
9085 -+ * may be counting on us to enforce permissions (the Linux 4.1
9086 -+ * client uses this for normal opens, for example).
9087 -+ */
9088 -+ if (open->op_claim_type == NFS4_OPEN_CLAIM_DELEG_CUR_FH)
9089 -+ accmode = NFSD_MAY_OWNER_OVERRIDE;
9090 -
9091 -- status = do_open_permission(rqstp, current_fh, open,
9092 -- NFSD_MAY_OWNER_OVERRIDE);
9093 -+ status = do_open_permission(rqstp, current_fh, open, accmode);
9094 -
9095 - return status;
9096 - }
9097 -diff --git a/fs/nfsd/nfs4recover.c b/fs/nfsd/nfs4recover.c
9098 -index 899ca26..4e9a21d 100644
9099 ---- a/fs/nfsd/nfs4recover.c
9100 -+++ b/fs/nfsd/nfs4recover.c
9101 -@@ -146,7 +146,7 @@ out_no_tfm:
9102 - * then disable recovery tracking.
9103 - */
9104 - static void
9105 --legacy_recdir_name_error(int error)
9106 -+legacy_recdir_name_error(struct nfs4_client *clp, int error)
9107 - {
9108 - printk(KERN_ERR "NFSD: unable to generate recoverydir "
9109 - "name (%d).\n", error);
9110 -@@ -159,9 +159,7 @@ legacy_recdir_name_error(int error)
9111 - if (error == -ENOENT) {
9112 - printk(KERN_ERR "NFSD: disabling legacy clientid tracking. "
9113 - "Reboot recovery will not function correctly!\n");
9114 --
9115 -- /* the argument is ignored by the legacy exit function */
9116 -- nfsd4_client_tracking_exit(NULL);
9117 -+ nfsd4_client_tracking_exit(clp->net);
9118 - }
9119 - }
9120 -
9121 -@@ -184,7 +182,7 @@ nfsd4_create_clid_dir(struct nfs4_client *clp)
9122 -
9123 - status = nfs4_make_rec_clidname(dname, &clp->cl_name);
9124 - if (status)
9125 -- return legacy_recdir_name_error(status);
9126 -+ return legacy_recdir_name_error(clp, status);
9127 -
9128 - status = nfs4_save_creds(&original_cred);
9129 - if (status < 0)
9130 -@@ -341,7 +339,7 @@ nfsd4_remove_clid_dir(struct nfs4_client *clp)
9131 -
9132 - status = nfs4_make_rec_clidname(dname, &clp->cl_name);
9133 - if (status)
9134 -- return legacy_recdir_name_error(status);
9135 -+ return legacy_recdir_name_error(clp, status);
9136 -
9137 - status = mnt_want_write_file(nn->rec_file);
9138 - if (status)
9139 -@@ -601,7 +599,7 @@ nfsd4_check_legacy_client(struct nfs4_client *clp)
9140 -
9141 - status = nfs4_make_rec_clidname(dname, &clp->cl_name);
9142 - if (status) {
9143 -- legacy_recdir_name_error(status);
9144 -+ legacy_recdir_name_error(clp, status);
9145 - return status;
9146 - }
9147 -
9148 -diff --git a/include/linux/audit.h b/include/linux/audit.h
9149 -index 5a6d718..b4086cf 100644
9150 ---- a/include/linux/audit.h
9151 -+++ b/include/linux/audit.h
9152 -@@ -120,7 +120,7 @@ static inline void audit_syscall_entry(int arch, int major, unsigned long a0,
9153 - unsigned long a1, unsigned long a2,
9154 - unsigned long a3)
9155 - {
9156 -- if (unlikely(!audit_dummy_context()))
9157 -+ if (unlikely(current->audit_context))
9158 - __audit_syscall_entry(arch, major, a0, a1, a2, a3);
9159 - }
9160 - static inline void audit_syscall_exit(void *pt_regs)
9161 -@@ -390,6 +390,11 @@ static inline void audit_ptrace(struct task_struct *t)
9162 - #define audit_signals 0
9163 - #endif /* CONFIG_AUDITSYSCALL */
9164 -
9165 -+static inline bool audit_loginuid_set(struct task_struct *tsk)
9166 -+{
9167 -+ return uid_valid(audit_get_loginuid(tsk));
9168 -+}
9169 -+
9170 - #ifdef CONFIG_AUDIT
9171 - /* These are defined in audit.c */
9172 - /* Public API */
9173 -diff --git a/include/linux/kref.h b/include/linux/kref.h
9174 -index 4972e6e..7419c02 100644
9175 ---- a/include/linux/kref.h
9176 -+++ b/include/linux/kref.h
9177 -@@ -19,6 +19,7 @@
9178 - #include <linux/atomic.h>
9179 - #include <linux/kernel.h>
9180 - #include <linux/mutex.h>
9181 -+#include <linux/spinlock.h>
9182 -
9183 - struct kref {
9184 - atomic_t refcount;
9185 -@@ -95,6 +96,38 @@ static inline int kref_put(struct kref *kref, void (*release)(struct kref *kref)
9186 - return kref_sub(kref, 1, release);
9187 - }
9188 -
9189 -+/**
9190 -+ * kref_put_spinlock_irqsave - decrement refcount for object.
9191 -+ * @kref: object.
9192 -+ * @release: pointer to the function that will clean up the object when the
9193 -+ * last reference to the object is released.
9194 -+ * This pointer is required, and it is not acceptable to pass kfree
9195 -+ * in as this function.
9196 -+ * @lock: lock to take in release case
9197 -+ *
9198 -+ * Behaves identical to kref_put with one exception. If the reference count
9199 -+ * drops to zero, the lock will be taken atomically wrt dropping the reference
9200 -+ * count. The release function has to call spin_unlock() without _irqrestore.
9201 -+ */
9202 -+static inline int kref_put_spinlock_irqsave(struct kref *kref,
9203 -+ void (*release)(struct kref *kref),
9204 -+ spinlock_t *lock)
9205 -+{
9206 -+ unsigned long flags;
9207 -+
9208 -+ WARN_ON(release == NULL);
9209 -+ if (atomic_add_unless(&kref->refcount, -1, 1))
9210 -+ return 0;
9211 -+ spin_lock_irqsave(lock, flags);
9212 -+ if (atomic_dec_and_test(&kref->refcount)) {
9213 -+ release(kref);
9214 -+ local_irq_restore(flags);
9215 -+ return 1;
9216 -+ }
9217 -+ spin_unlock_irqrestore(lock, flags);
9218 -+ return 0;
9219 -+}
9220 -+
9221 - static inline int kref_put_mutex(struct kref *kref,
9222 - void (*release)(struct kref *kref),
9223 - struct mutex *lock)
9224 -diff --git a/include/linux/time.h b/include/linux/time.h
9225 -index d4835df..afcdc4b 100644
9226 ---- a/include/linux/time.h
9227 -+++ b/include/linux/time.h
9228 -@@ -117,14 +117,10 @@ static inline bool timespec_valid_strict(const struct timespec *ts)
9229 -
9230 - extern bool persistent_clock_exist;
9231 -
9232 --#ifdef ALWAYS_USE_PERSISTENT_CLOCK
9233 --#define has_persistent_clock() true
9234 --#else
9235 - static inline bool has_persistent_clock(void)
9236 - {
9237 - return persistent_clock_exist;
9238 - }
9239 --#endif
9240 -
9241 - extern void read_persistent_clock(struct timespec *ts);
9242 - extern void read_boot_clock(struct timespec *ts);
9243 -diff --git a/include/net/inet_frag.h b/include/net/inet_frag.h
9244 -index 0a1dcc2..ab3d0ac 100644
9245 ---- a/include/net/inet_frag.h
9246 -+++ b/include/net/inet_frag.h
9247 -@@ -135,14 +135,15 @@ static inline int sum_frag_mem_limit(struct netns_frags *nf)
9248 - static inline void inet_frag_lru_move(struct inet_frag_queue *q)
9249 - {
9250 - spin_lock(&q->net->lru_lock);
9251 -- list_move_tail(&q->lru_list, &q->net->lru_list);
9252 -+ if (!list_empty(&q->lru_list))
9253 -+ list_move_tail(&q->lru_list, &q->net->lru_list);
9254 - spin_unlock(&q->net->lru_lock);
9255 - }
9256 -
9257 - static inline void inet_frag_lru_del(struct inet_frag_queue *q)
9258 - {
9259 - spin_lock(&q->net->lru_lock);
9260 -- list_del(&q->lru_list);
9261 -+ list_del_init(&q->lru_list);
9262 - spin_unlock(&q->net->lru_lock);
9263 - }
9264 -
9265 -diff --git a/include/net/sock.h b/include/net/sock.h
9266 -index 14f6e9d..0be480a 100644
9267 ---- a/include/net/sock.h
9268 -+++ b/include/net/sock.h
9269 -@@ -865,6 +865,18 @@ struct inet_hashinfo;
9270 - struct raw_hashinfo;
9271 - struct module;
9272 -
9273 -+/*
9274 -+ * caches using SLAB_DESTROY_BY_RCU should let .next pointer from nulls nodes
9275 -+ * un-modified. Special care is taken when initializing object to zero.
9276 -+ */
9277 -+static inline void sk_prot_clear_nulls(struct sock *sk, int size)
9278 -+{
9279 -+ if (offsetof(struct sock, sk_node.next) != 0)
9280 -+ memset(sk, 0, offsetof(struct sock, sk_node.next));
9281 -+ memset(&sk->sk_node.pprev, 0,
9282 -+ size - offsetof(struct sock, sk_node.pprev));
9283 -+}
9284 -+
9285 - /* Networking protocol blocks we attach to sockets.
9286 - * socket layer -> transport layer interface
9287 - * transport -> network interface is defined by struct inet_proto
9288 -diff --git a/include/net/tcp.h b/include/net/tcp.h
9289 -index cf0694d..a345480 100644
9290 ---- a/include/net/tcp.h
9291 -+++ b/include/net/tcp.h
9292 -@@ -1049,6 +1049,7 @@ static inline bool tcp_prequeue(struct sock *sk, struct sk_buff *skb)
9293 - skb_queue_len(&tp->ucopy.prequeue) == 0)
9294 - return false;
9295 -
9296 -+ skb_dst_force(skb);
9297 - __skb_queue_tail(&tp->ucopy.prequeue, skb);
9298 - tp->ucopy.memory += skb->truesize;
9299 - if (tp->ucopy.memory > sk->sk_rcvbuf) {
9300 -diff --git a/include/uapi/linux/audit.h b/include/uapi/linux/audit.h
9301 -index 9f096f1..9554a19 100644
9302 ---- a/include/uapi/linux/audit.h
9303 -+++ b/include/uapi/linux/audit.h
9304 -@@ -246,6 +246,7 @@
9305 - #define AUDIT_OBJ_TYPE 21
9306 - #define AUDIT_OBJ_LEV_LOW 22
9307 - #define AUDIT_OBJ_LEV_HIGH 23
9308 -+#define AUDIT_LOGINUID_SET 24
9309 -
9310 - /* These are ONLY useful when checking
9311 - * at syscall exit time (AUDIT_AT_EXIT). */
9312 -diff --git a/include/uapi/linux/if_cablemodem.h b/include/uapi/linux/if_cablemodem.h
9313 -index 9ca1007..ee6b3c4 100644
9314 ---- a/include/uapi/linux/if_cablemodem.h
9315 -+++ b/include/uapi/linux/if_cablemodem.h
9316 -@@ -12,11 +12,11 @@
9317 - */
9318 -
9319 - /* some useful defines for sb1000.c e cmconfig.c - fv */
9320 --#define SIOCGCMSTATS SIOCDEVPRIVATE+0 /* get cable modem stats */
9321 --#define SIOCGCMFIRMWARE SIOCDEVPRIVATE+1 /* get cm firmware version */
9322 --#define SIOCGCMFREQUENCY SIOCDEVPRIVATE+2 /* get cable modem frequency */
9323 --#define SIOCSCMFREQUENCY SIOCDEVPRIVATE+3 /* set cable modem frequency */
9324 --#define SIOCGCMPIDS SIOCDEVPRIVATE+4 /* get cable modem PIDs */
9325 --#define SIOCSCMPIDS SIOCDEVPRIVATE+5 /* set cable modem PIDs */
9326 -+#define SIOCGCMSTATS (SIOCDEVPRIVATE+0) /* get cable modem stats */
9327 -+#define SIOCGCMFIRMWARE (SIOCDEVPRIVATE+1) /* get cm firmware version */
9328 -+#define SIOCGCMFREQUENCY (SIOCDEVPRIVATE+2) /* get cable modem frequency */
9329 -+#define SIOCSCMFREQUENCY (SIOCDEVPRIVATE+3) /* set cable modem frequency */
9330 -+#define SIOCGCMPIDS (SIOCDEVPRIVATE+4) /* get cable modem PIDs */
9331 -+#define SIOCSCMPIDS (SIOCDEVPRIVATE+5) /* set cable modem PIDs */
9332 -
9333 - #endif
9334 -diff --git a/include/uapi/linux/virtio_net.h b/include/uapi/linux/virtio_net.h
9335 -index a5a8c88..c520203 100644
9336 ---- a/include/uapi/linux/virtio_net.h
9337 -+++ b/include/uapi/linux/virtio_net.h
9338 -@@ -191,7 +191,7 @@ struct virtio_net_ctrl_mac {
9339 - * specified.
9340 - */
9341 - struct virtio_net_ctrl_mq {
9342 -- u16 virtqueue_pairs;
9343 -+ __u16 virtqueue_pairs;
9344 - };
9345 -
9346 - #define VIRTIO_NET_CTRL_MQ 4
9347 -diff --git a/ipc/shm.c b/ipc/shm.c
9348 -index 34af1fe..7e199fa 100644
9349 ---- a/ipc/shm.c
9350 -+++ b/ipc/shm.c
9351 -@@ -493,7 +493,13 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
9352 - if (shmflg & SHM_HUGETLB) {
9353 - struct hstate *hs = hstate_sizelog((shmflg >> SHM_HUGE_SHIFT)
9354 - & SHM_HUGE_MASK);
9355 -- size_t hugesize = ALIGN(size, huge_page_size(hs));
9356 -+ size_t hugesize;
9357 -+
9358 -+ if (!hs) {
9359 -+ error = -EINVAL;
9360 -+ goto no_file;
9361 -+ }
9362 -+ hugesize = ALIGN(size, huge_page_size(hs));
9363 -
9364 - /* hugetlb_file_setup applies strict accounting */
9365 - if (shmflg & SHM_NORESERVE)
9366 -diff --git a/kernel/auditfilter.c b/kernel/auditfilter.c
9367 -index f9fc54b..2bf508d 100644
9368 ---- a/kernel/auditfilter.c
9369 -+++ b/kernel/auditfilter.c
9370 -@@ -345,6 +345,12 @@ static struct audit_entry *audit_rule_to_entry(struct audit_rule *rule)
9371 - f->uid = INVALID_UID;
9372 - f->gid = INVALID_GID;
9373 -
9374 -+ /* Support legacy tests for a valid loginuid */
9375 -+ if ((f->type == AUDIT_LOGINUID) && (f->val == 4294967295U)) {
9376 -+ f->type = AUDIT_LOGINUID_SET;
9377 -+ f->val = 0;
9378 -+ }
9379 -+
9380 - err = -EINVAL;
9381 - if (f->op == Audit_bad)
9382 - goto exit_free;
9383 -@@ -352,6 +358,12 @@ static struct audit_entry *audit_rule_to_entry(struct audit_rule *rule)
9384 - switch(f->type) {
9385 - default:
9386 - goto exit_free;
9387 -+ case AUDIT_LOGINUID_SET:
9388 -+ if ((f->val != 0) && (f->val != 1))
9389 -+ goto exit_free;
9390 -+ if (f->op != Audit_not_equal && f->op != Audit_equal)
9391 -+ goto exit_free;
9392 -+ break;
9393 - case AUDIT_UID:
9394 - case AUDIT_EUID:
9395 - case AUDIT_SUID:
9396 -@@ -459,7 +471,20 @@ static struct audit_entry *audit_data_to_entry(struct audit_rule_data *data,
9397 - f->gid = INVALID_GID;
9398 - f->lsm_str = NULL;
9399 - f->lsm_rule = NULL;
9400 -- switch(f->type) {
9401 -+
9402 -+ /* Support legacy tests for a valid loginuid */
9403 -+ if ((f->type == AUDIT_LOGINUID) && (f->val == 4294967295U)) {
9404 -+ f->type = AUDIT_LOGINUID_SET;
9405 -+ f->val = 0;
9406 -+ }
9407 -+
9408 -+ switch (f->type) {
9409 -+ case AUDIT_LOGINUID_SET:
9410 -+ if ((f->val != 0) && (f->val != 1))
9411 -+ goto exit_free;
9412 -+ if (f->op != Audit_not_equal && f->op != Audit_equal)
9413 -+ goto exit_free;
9414 -+ break;
9415 - case AUDIT_UID:
9416 - case AUDIT_EUID:
9417 - case AUDIT_SUID:
9418 -@@ -1378,6 +1403,10 @@ static int audit_filter_user_rules(struct audit_krule *rule,
9419 - result = audit_uid_comparator(audit_get_loginuid(current),
9420 - f->op, f->uid);
9421 - break;
9422 -+ case AUDIT_LOGINUID_SET:
9423 -+ result = audit_comparator(audit_loginuid_set(current),
9424 -+ f->op, f->val);
9425 -+ break;
9426 - case AUDIT_SUBJ_USER:
9427 - case AUDIT_SUBJ_ROLE:
9428 - case AUDIT_SUBJ_TYPE:
9429 -diff --git a/kernel/auditsc.c b/kernel/auditsc.c
9430 -index a371f85..c4b72b0 100644
9431 ---- a/kernel/auditsc.c
9432 -+++ b/kernel/auditsc.c
9433 -@@ -742,6 +742,9 @@ static int audit_filter_rules(struct task_struct *tsk,
9434 - if (ctx)
9435 - result = audit_uid_comparator(tsk->loginuid, f->op, f->uid);
9436 - break;
9437 -+ case AUDIT_LOGINUID_SET:
9438 -+ result = audit_comparator(audit_loginuid_set(tsk), f->op, f->val);
9439 -+ break;
9440 - case AUDIT_SUBJ_USER:
9441 - case AUDIT_SUBJ_ROLE:
9442 - case AUDIT_SUBJ_TYPE:
9443 -@@ -2309,7 +2312,7 @@ int audit_set_loginuid(kuid_t loginuid)
9444 - unsigned int sessionid;
9445 -
9446 - #ifdef CONFIG_AUDIT_LOGINUID_IMMUTABLE
9447 -- if (uid_valid(task->loginuid))
9448 -+ if (audit_loginuid_set(task))
9449 - return -EPERM;
9450 - #else /* CONFIG_AUDIT_LOGINUID_IMMUTABLE */
9451 - if (!capable(CAP_AUDIT_CONTROL))
9452 -diff --git a/kernel/kmod.c b/kernel/kmod.c
9453 -index 56dd349..8985c87 100644
9454 ---- a/kernel/kmod.c
9455 -+++ b/kernel/kmod.c
9456 -@@ -570,6 +570,11 @@ int call_usermodehelper_exec(struct subprocess_info *sub_info, int wait)
9457 - int retval = 0;
9458 -
9459 - helper_lock();
9460 -+ if (!sub_info->path) {
9461 -+ retval = -EINVAL;
9462 -+ goto out;
9463 -+ }
9464 -+
9465 - if (sub_info->path[0] == '\0')
9466 - goto out;
9467 -
9468 -diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c
9469 -index e93cca9..6af50ad 100644
9470 ---- a/kernel/sched/cputime.c
9471 -+++ b/kernel/sched/cputime.c
9472 -@@ -521,18 +521,49 @@ EXPORT_SYMBOL_GPL(vtime_account_irq_enter);
9473 -
9474 - #else /* !CONFIG_VIRT_CPU_ACCOUNTING */
9475 -
9476 --static cputime_t scale_stime(cputime_t stime, cputime_t rtime, cputime_t total)
9477 -+/*
9478 -+ * Perform (stime * rtime) / total, but avoid multiplication overflow by
9479 -+ * loosing precision when the numbers are big.
9480 -+ */
9481 -+static cputime_t scale_stime(u64 stime, u64 rtime, u64 total)
9482 - {
9483 -- u64 temp = (__force u64) rtime;
9484 -+ u64 scaled;
9485 -
9486 -- temp *= (__force u64) stime;
9487 -+ for (;;) {
9488 -+ /* Make sure "rtime" is the bigger of stime/rtime */
9489 -+ if (stime > rtime) {
9490 -+ u64 tmp = rtime; rtime = stime; stime = tmp;
9491 -+ }
9492 -
9493 -- if (sizeof(cputime_t) == 4)
9494 -- temp = div_u64(temp, (__force u32) total);
9495 -- else
9496 -- temp = div64_u64(temp, (__force u64) total);
9497 -+ /* Make sure 'total' fits in 32 bits */
9498 -+ if (total >> 32)
9499 -+ goto drop_precision;
9500 -+
9501 -+ /* Does rtime (and thus stime) fit in 32 bits? */
9502 -+ if (!(rtime >> 32))
9503 -+ break;
9504 -
9505 -- return (__force cputime_t) temp;
9506 -+ /* Can we just balance rtime/stime rather than dropping bits? */
9507 -+ if (stime >> 31)
9508 -+ goto drop_precision;
9509 -+
9510 -+ /* We can grow stime and shrink rtime and try to make them both fit */
9511 -+ stime <<= 1;
9512 -+ rtime >>= 1;
9513 -+ continue;
9514 -+
9515 -+drop_precision:
9516 -+ /* We drop from rtime, it has more bits than stime */
9517 -+ rtime >>= 1;
9518 -+ total >>= 1;
9519 -+ }
9520 -+
9521 -+ /*
9522 -+ * Make sure gcc understands that this is a 32x32->64 multiply,
9523 -+ * followed by a 64/32->64 divide.
9524 -+ */
9525 -+ scaled = div_u64((u64) (u32) stime * (u64) (u32) rtime, (u32)total);
9526 -+ return (__force cputime_t) scaled;
9527 - }
9528 -
9529 - /*
9530 -@@ -543,7 +574,7 @@ static void cputime_adjust(struct task_cputime *curr,
9531 - struct cputime *prev,
9532 - cputime_t *ut, cputime_t *st)
9533 - {
9534 -- cputime_t rtime, stime, total;
9535 -+ cputime_t rtime, stime, utime, total;
9536 -
9537 - stime = curr->stime;
9538 - total = stime + curr->utime;
9539 -@@ -560,10 +591,22 @@ static void cputime_adjust(struct task_cputime *curr,
9540 - */
9541 - rtime = nsecs_to_cputime(curr->sum_exec_runtime);
9542 -
9543 -- if (total)
9544 -- stime = scale_stime(stime, rtime, total);
9545 -- else
9546 -+ /*
9547 -+ * Update userspace visible utime/stime values only if actual execution
9548 -+ * time is bigger than already exported. Note that can happen, that we
9549 -+ * provided bigger values due to scaling inaccuracy on big numbers.
9550 -+ */
9551 -+ if (prev->stime + prev->utime >= rtime)
9552 -+ goto out;
9553 -+
9554 -+ if (total) {
9555 -+ stime = scale_stime((__force u64)stime,
9556 -+ (__force u64)rtime, (__force u64)total);
9557 -+ utime = rtime - stime;
9558 -+ } else {
9559 - stime = rtime;
9560 -+ utime = 0;
9561 -+ }
9562 -
9563 - /*
9564 - * If the tick based count grows faster than the scheduler one,
9565 -@@ -571,8 +614,9 @@ static void cputime_adjust(struct task_cputime *curr,
9566 - * Let's enforce monotonicity.
9567 - */
9568 - prev->stime = max(prev->stime, stime);
9569 -- prev->utime = max(prev->utime, rtime - prev->stime);
9570 -+ prev->utime = max(prev->utime, utime);
9571 -
9572 -+out:
9573 - *ut = prev->utime;
9574 - *st = prev->stime;
9575 - }
9576 -diff --git a/kernel/time/Kconfig b/kernel/time/Kconfig
9577 -index 24510d8..b696922 100644
9578 ---- a/kernel/time/Kconfig
9579 -+++ b/kernel/time/Kconfig
9580 -@@ -12,11 +12,6 @@ config CLOCKSOURCE_WATCHDOG
9581 - config ARCH_CLOCKSOURCE_DATA
9582 - bool
9583 -
9584 --# Platforms has a persistent clock
9585 --config ALWAYS_USE_PERSISTENT_CLOCK
9586 -- bool
9587 -- default n
9588 --
9589 - # Timekeeping vsyscall support
9590 - config GENERIC_TIME_VSYSCALL
9591 - bool
9592 -diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
9593 -index a19a399..e717ad9 100644
9594 ---- a/kernel/time/tick-sched.c
9595 -+++ b/kernel/time/tick-sched.c
9596 -@@ -904,7 +904,7 @@ void tick_cancel_sched_timer(int cpu)
9597 - hrtimer_cancel(&ts->sched_timer);
9598 - # endif
9599 -
9600 -- ts->nohz_mode = NOHZ_MODE_INACTIVE;
9601 -+ memset(ts, 0, sizeof(*ts));
9602 - }
9603 - #endif
9604 -
9605 -diff --git a/kernel/timer.c b/kernel/timer.c
9606 -index dbf7a78..1b399c8 100644
9607 ---- a/kernel/timer.c
9608 -+++ b/kernel/timer.c
9609 -@@ -1678,12 +1678,12 @@ static int __cpuinit init_timers_cpu(int cpu)
9610 - boot_done = 1;
9611 - base = &boot_tvec_bases;
9612 - }
9613 -+ spin_lock_init(&base->lock);
9614 - tvec_base_done[cpu] = 1;
9615 - } else {
9616 - base = per_cpu(tvec_bases, cpu);
9617 - }
9618 -
9619 -- spin_lock_init(&base->lock);
9620 -
9621 - for (j = 0; j < TVN_SIZE; j++) {
9622 - INIT_LIST_HEAD(base->tv5.vec + j);
9623 -diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c
9624 -index e5b0ca8..5a8a53e 100644
9625 ---- a/kernel/trace/trace_events_filter.c
9626 -+++ b/kernel/trace/trace_events_filter.c
9627 -@@ -777,7 +777,11 @@ static int filter_set_pred(struct event_filter *filter,
9628 -
9629 - static void __free_preds(struct event_filter *filter)
9630 - {
9631 -+ int i;
9632 -+
9633 - if (filter->preds) {
9634 -+ for (i = 0; i < filter->n_preds; i++)
9635 -+ kfree(filter->preds[i].ops);
9636 - kfree(filter->preds);
9637 - filter->preds = NULL;
9638 - }
9639 -diff --git a/mm/mmap.c b/mm/mmap.c
9640 -index e17fc06..0dceed8 100644
9641 ---- a/mm/mmap.c
9642 -+++ b/mm/mmap.c
9643 -@@ -1331,9 +1331,13 @@ SYSCALL_DEFINE6(mmap_pgoff, unsigned long, addr, unsigned long, len,
9644 - len = ALIGN(len, huge_page_size(hstate_file(file)));
9645 - } else if (flags & MAP_HUGETLB) {
9646 - struct user_struct *user = NULL;
9647 -+ struct hstate *hs = hstate_sizelog((flags >> MAP_HUGE_SHIFT) &
9648 -+ SHM_HUGE_MASK);
9649 -
9650 -- len = ALIGN(len, huge_page_size(hstate_sizelog(
9651 -- (flags >> MAP_HUGE_SHIFT) & MAP_HUGE_MASK)));
9652 -+ if (!hs)
9653 -+ return -EINVAL;
9654 -+
9655 -+ len = ALIGN(len, huge_page_size(hs));
9656 - /*
9657 - * VM_NORESERVE is used because the reservations will be
9658 - * taken when vm_ops->mmap() is called
9659 -diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
9660 -index 19cf81b..63bd98c 100644
9661 ---- a/net/8021q/vlan_dev.c
9662 -+++ b/net/8021q/vlan_dev.c
9663 -@@ -627,7 +627,7 @@ static netdev_features_t vlan_dev_fix_features(struct net_device *dev,
9664 - netdev_features_t features)
9665 - {
9666 - struct net_device *real_dev = vlan_dev_priv(dev)->real_dev;
9667 -- u32 old_features = features;
9668 -+ netdev_features_t old_features = features;
9669 -
9670 - features &= real_dev->vlan_features;
9671 - features |= NETIF_F_RXCSUM;
9672 -diff --git a/net/bridge/br_stp_timer.c b/net/bridge/br_stp_timer.c
9673 -index c3530a8..950663d 100644
9674 ---- a/net/bridge/br_stp_timer.c
9675 -+++ b/net/bridge/br_stp_timer.c
9676 -@@ -107,7 +107,7 @@ static void br_tcn_timer_expired(unsigned long arg)
9677 -
9678 - br_debug(br, "tcn timer expired\n");
9679 - spin_lock(&br->lock);
9680 -- if (br->dev->flags & IFF_UP) {
9681 -+ if (!br_is_root_bridge(br) && (br->dev->flags & IFF_UP)) {
9682 - br_transmit_tcn(br);
9683 -
9684 - mod_timer(&br->tcn_timer,jiffies + br->bridge_hello_time);
9685 -diff --git a/net/core/dev.c b/net/core/dev.c
9686 -index b24ab0e9..9a278e9 100644
9687 ---- a/net/core/dev.c
9688 -+++ b/net/core/dev.c
9689 -@@ -2458,7 +2458,7 @@ EXPORT_SYMBOL(netif_skb_features);
9690 - * 2. skb is fragmented and the device does not support SG.
9691 - */
9692 - static inline int skb_needs_linearize(struct sk_buff *skb,
9693 -- int features)
9694 -+ netdev_features_t features)
9695 - {
9696 - return skb_is_nonlinear(skb) &&
9697 - ((skb_has_frag_list(skb) &&
9698 -diff --git a/net/core/ethtool.c b/net/core/ethtool.c
9699 -index 3e9b2c3..41f4bdf 100644
9700 ---- a/net/core/ethtool.c
9701 -+++ b/net/core/ethtool.c
9702 -@@ -1416,7 +1416,7 @@ int dev_ethtool(struct net *net, struct ifreq *ifr)
9703 - void __user *useraddr = ifr->ifr_data;
9704 - u32 ethcmd;
9705 - int rc;
9706 -- u32 old_features;
9707 -+ netdev_features_t old_features;
9708 -
9709 - if (!dev || !netif_device_present(dev))
9710 - return -ENODEV;
9711 -diff --git a/net/core/sock.c b/net/core/sock.c
9712 -index b261a79..1432266 100644
9713 ---- a/net/core/sock.c
9714 -+++ b/net/core/sock.c
9715 -@@ -1209,18 +1209,6 @@ static void sock_copy(struct sock *nsk, const struct sock *osk)
9716 - #endif
9717 - }
9718 -
9719 --/*
9720 -- * caches using SLAB_DESTROY_BY_RCU should let .next pointer from nulls nodes
9721 -- * un-modified. Special care is taken when initializing object to zero.
9722 -- */
9723 --static inline void sk_prot_clear_nulls(struct sock *sk, int size)
9724 --{
9725 -- if (offsetof(struct sock, sk_node.next) != 0)
9726 -- memset(sk, 0, offsetof(struct sock, sk_node.next));
9727 -- memset(&sk->sk_node.pprev, 0,
9728 -- size - offsetof(struct sock, sk_node.pprev));
9729 --}
9730 --
9731 - void sk_prot_clear_portaddr_nulls(struct sock *sk, int size)
9732 - {
9733 - unsigned long nulls1, nulls2;
9734 -diff --git a/net/ipv4/inet_fragment.c b/net/ipv4/inet_fragment.c
9735 -index f4fd23d..3211914 100644
9736 ---- a/net/ipv4/inet_fragment.c
9737 -+++ b/net/ipv4/inet_fragment.c
9738 -@@ -257,6 +257,7 @@ static struct inet_frag_queue *inet_frag_alloc(struct netns_frags *nf,
9739 - setup_timer(&q->timer, f->frag_expire, (unsigned long)q);
9740 - spin_lock_init(&q->lock);
9741 - atomic_set(&q->refcnt, 1);
9742 -+ INIT_LIST_HEAD(&q->lru_list);
9743 -
9744 - return q;
9745 - }
9746 -diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
9747 -index b83a49c..2f672e7 100644
9748 ---- a/net/ipv4/tcp_minisocks.c
9749 -+++ b/net/ipv4/tcp_minisocks.c
9750 -@@ -583,8 +583,13 @@ struct sock *tcp_check_req(struct sock *sk, struct sk_buff *skb,
9751 - *
9752 - * Note that even if there is new data in the SYN packet
9753 - * they will be thrown away too.
9754 -+ *
9755 -+ * Reset timer after retransmitting SYNACK, similar to
9756 -+ * the idea of fast retransmit in recovery.
9757 - */
9758 -- inet_rtx_syn_ack(sk, req);
9759 -+ if (!inet_rtx_syn_ack(sk, req))
9760 -+ req->expires = min(TCP_TIMEOUT_INIT << req->num_timeout,
9761 -+ TCP_RTO_MAX) + jiffies;
9762 - return NULL;
9763 - }
9764 -
9765 -diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
9766 -index e4efffe..95d13c7 100644
9767 ---- a/net/ipv6/ip6_gre.c
9768 -+++ b/net/ipv6/ip6_gre.c
9769 -@@ -1135,6 +1135,7 @@ static int ip6gre_tunnel_ioctl(struct net_device *dev,
9770 - }
9771 - if (t == NULL)
9772 - t = netdev_priv(dev);
9773 -+ memset(&p, 0, sizeof(p));
9774 - ip6gre_tnl_parm_to_user(&p, &t->parms);
9775 - if (copy_to_user(ifr->ifr_ifru.ifru_data, &p, sizeof(p)))
9776 - err = -EFAULT;
9777 -@@ -1182,6 +1183,7 @@ static int ip6gre_tunnel_ioctl(struct net_device *dev,
9778 - if (t) {
9779 - err = 0;
9780 -
9781 -+ memset(&p, 0, sizeof(p));
9782 - ip6gre_tnl_parm_to_user(&p, &t->parms);
9783 - if (copy_to_user(ifr->ifr_ifru.ifru_data, &p, sizeof(p)))
9784 - err = -EFAULT;
9785 -diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
9786 -index 46a5be8..0fce928 100644
9787 ---- a/net/ipv6/tcp_ipv6.c
9788 -+++ b/net/ipv6/tcp_ipv6.c
9789 -@@ -1937,6 +1937,17 @@ void tcp6_proc_exit(struct net *net)
9790 - }
9791 - #endif
9792 -
9793 -+static void tcp_v6_clear_sk(struct sock *sk, int size)
9794 -+{
9795 -+ struct inet_sock *inet = inet_sk(sk);
9796 -+
9797 -+ /* we do not want to clear pinet6 field, because of RCU lookups */
9798 -+ sk_prot_clear_nulls(sk, offsetof(struct inet_sock, pinet6));
9799 -+
9800 -+ size -= offsetof(struct inet_sock, pinet6) + sizeof(inet->pinet6);
9801 -+ memset(&inet->pinet6 + 1, 0, size);
9802 -+}
9803 -+
9804 - struct proto tcpv6_prot = {
9805 - .name = "TCPv6",
9806 - .owner = THIS_MODULE,
9807 -@@ -1980,6 +1991,7 @@ struct proto tcpv6_prot = {
9808 - #ifdef CONFIG_MEMCG_KMEM
9809 - .proto_cgroup = tcp_proto_cgroup,
9810 - #endif
9811 -+ .clear_sk = tcp_v6_clear_sk,
9812 - };
9813 -
9814 - static const struct inet6_protocol tcpv6_protocol = {
9815 -diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
9816 -index d8e5e85..27f0f8e 100644
9817 ---- a/net/ipv6/udp.c
9818 -+++ b/net/ipv6/udp.c
9819 -@@ -1422,6 +1422,17 @@ void udp6_proc_exit(struct net *net) {
9820 - }
9821 - #endif /* CONFIG_PROC_FS */
9822 -
9823 -+void udp_v6_clear_sk(struct sock *sk, int size)
9824 -+{
9825 -+ struct inet_sock *inet = inet_sk(sk);
9826 -+
9827 -+ /* we do not want to clear pinet6 field, because of RCU lookups */
9828 -+ sk_prot_clear_portaddr_nulls(sk, offsetof(struct inet_sock, pinet6));
9829 -+
9830 -+ size -= offsetof(struct inet_sock, pinet6) + sizeof(inet->pinet6);
9831 -+ memset(&inet->pinet6 + 1, 0, size);
9832 -+}
9833 -+
9834 - /* ------------------------------------------------------------------------ */
9835 -
9836 - struct proto udpv6_prot = {
9837 -@@ -1452,7 +1463,7 @@ struct proto udpv6_prot = {
9838 - .compat_setsockopt = compat_udpv6_setsockopt,
9839 - .compat_getsockopt = compat_udpv6_getsockopt,
9840 - #endif
9841 -- .clear_sk = sk_prot_clear_portaddr_nulls,
9842 -+ .clear_sk = udp_v6_clear_sk,
9843 - };
9844 -
9845 - static struct inet_protosw udpv6_protosw = {
9846 -diff --git a/net/ipv6/udp_impl.h b/net/ipv6/udp_impl.h
9847 -index d757104..4691ed5 100644
9848 ---- a/net/ipv6/udp_impl.h
9849 -+++ b/net/ipv6/udp_impl.h
9850 -@@ -31,6 +31,8 @@ extern int udpv6_recvmsg(struct kiocb *iocb, struct sock *sk,
9851 - extern int udpv6_queue_rcv_skb(struct sock * sk, struct sk_buff *skb);
9852 - extern void udpv6_destroy_sock(struct sock *sk);
9853 -
9854 -+extern void udp_v6_clear_sk(struct sock *sk, int size);
9855 -+
9856 - #ifdef CONFIG_PROC_FS
9857 - extern int udp6_seq_show(struct seq_file *seq, void *v);
9858 - #endif
9859 -diff --git a/net/ipv6/udplite.c b/net/ipv6/udplite.c
9860 -index 1d08e21..dfcc4be 100644
9861 ---- a/net/ipv6/udplite.c
9862 -+++ b/net/ipv6/udplite.c
9863 -@@ -56,7 +56,7 @@ struct proto udplitev6_prot = {
9864 - .compat_setsockopt = compat_udpv6_setsockopt,
9865 - .compat_getsockopt = compat_udpv6_getsockopt,
9866 - #endif
9867 -- .clear_sk = sk_prot_clear_portaddr_nulls,
9868 -+ .clear_sk = udp_v6_clear_sk,
9869 - };
9870 -
9871 - static struct inet_protosw udplite6_protosw = {
9872 -diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
9873 -index 4ef7bdb..23ed03d 100644
9874 ---- a/net/ipv6/xfrm6_policy.c
9875 -+++ b/net/ipv6/xfrm6_policy.c
9876 -@@ -103,8 +103,10 @@ static int xfrm6_fill_dst(struct xfrm_dst *xdst, struct net_device *dev,
9877 - dev_hold(dev);
9878 -
9879 - xdst->u.rt6.rt6i_idev = in6_dev_get(dev);
9880 -- if (!xdst->u.rt6.rt6i_idev)
9881 -+ if (!xdst->u.rt6.rt6i_idev) {
9882 -+ dev_put(dev);
9883 - return -ENODEV;
9884 -+ }
9885 -
9886 - rt6_transfer_peer(&xdst->u.rt6, rt);
9887 -
9888 -diff --git a/net/mac802154/mac802154.h b/net/mac802154/mac802154.h
9889 -index a4dcaf1..703c121 100644
9890 ---- a/net/mac802154/mac802154.h
9891 -+++ b/net/mac802154/mac802154.h
9892 -@@ -90,7 +90,7 @@ struct mac802154_sub_if_data {
9893 -
9894 - #define MAC802154_MAX_XMIT_ATTEMPTS 3
9895 -
9896 --#define MAC802154_CHAN_NONE (~(u8)0) /* No channel is assigned */
9897 -+#define MAC802154_CHAN_NONE 0xff /* No channel is assigned */
9898 -
9899 - extern struct ieee802154_reduced_mlme_ops mac802154_mlme_reduced;
9900 - extern struct ieee802154_mlme_ops mac802154_mlme_wpan;
9901 -diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
9902 -index 1d6793d..f83e172 100644
9903 ---- a/net/packet/af_packet.c
9904 -+++ b/net/packet/af_packet.c
9905 -@@ -693,36 +693,33 @@ static void prb_open_block(struct tpacket_kbdq_core *pkc1,
9906 -
9907 - smp_rmb();
9908 -
9909 -- if (likely(TP_STATUS_KERNEL == BLOCK_STATUS(pbd1))) {
9910 -+ /* We could have just memset this but we will lose the
9911 -+ * flexibility of making the priv area sticky
9912 -+ */
9913 -
9914 -- /* We could have just memset this but we will lose the
9915 -- * flexibility of making the priv area sticky
9916 -- */
9917 -- BLOCK_SNUM(pbd1) = pkc1->knxt_seq_num++;
9918 -- BLOCK_NUM_PKTS(pbd1) = 0;
9919 -- BLOCK_LEN(pbd1) = BLK_PLUS_PRIV(pkc1->blk_sizeof_priv);
9920 -- getnstimeofday(&ts);
9921 -- h1->ts_first_pkt.ts_sec = ts.tv_sec;
9922 -- h1->ts_first_pkt.ts_nsec = ts.tv_nsec;
9923 -- pkc1->pkblk_start = (char *)pbd1;
9924 -- pkc1->nxt_offset = pkc1->pkblk_start + BLK_PLUS_PRIV(pkc1->blk_sizeof_priv);
9925 -- BLOCK_O2FP(pbd1) = (__u32)BLK_PLUS_PRIV(pkc1->blk_sizeof_priv);
9926 -- BLOCK_O2PRIV(pbd1) = BLK_HDR_LEN;
9927 -- pbd1->version = pkc1->version;
9928 -- pkc1->prev = pkc1->nxt_offset;
9929 -- pkc1->pkblk_end = pkc1->pkblk_start + pkc1->kblk_size;
9930 -- prb_thaw_queue(pkc1);
9931 -- _prb_refresh_rx_retire_blk_timer(pkc1);
9932 -+ BLOCK_SNUM(pbd1) = pkc1->knxt_seq_num++;
9933 -+ BLOCK_NUM_PKTS(pbd1) = 0;
9934 -+ BLOCK_LEN(pbd1) = BLK_PLUS_PRIV(pkc1->blk_sizeof_priv);
9935 -
9936 -- smp_wmb();
9937 -+ getnstimeofday(&ts);
9938 -
9939 -- return;
9940 -- }
9941 -+ h1->ts_first_pkt.ts_sec = ts.tv_sec;
9942 -+ h1->ts_first_pkt.ts_nsec = ts.tv_nsec;
9943 -
9944 -- WARN(1, "ERROR block:%p is NOT FREE status:%d kactive_blk_num:%d\n",
9945 -- pbd1, BLOCK_STATUS(pbd1), pkc1->kactive_blk_num);
9946 -- dump_stack();
9947 -- BUG();
9948 -+ pkc1->pkblk_start = (char *)pbd1;
9949 -+ pkc1->nxt_offset = pkc1->pkblk_start + BLK_PLUS_PRIV(pkc1->blk_sizeof_priv);
9950 -+
9951 -+ BLOCK_O2FP(pbd1) = (__u32)BLK_PLUS_PRIV(pkc1->blk_sizeof_priv);
9952 -+ BLOCK_O2PRIV(pbd1) = BLK_HDR_LEN;
9953 -+
9954 -+ pbd1->version = pkc1->version;
9955 -+ pkc1->prev = pkc1->nxt_offset;
9956 -+ pkc1->pkblk_end = pkc1->pkblk_start + pkc1->kblk_size;
9957 -+
9958 -+ prb_thaw_queue(pkc1);
9959 -+ _prb_refresh_rx_retire_blk_timer(pkc1);
9960 -+
9961 -+ smp_wmb();
9962 - }
9963 -
9964 - /*
9965 -@@ -813,10 +810,6 @@ static void prb_retire_current_block(struct tpacket_kbdq_core *pkc,
9966 - prb_close_block(pkc, pbd, po, status);
9967 - return;
9968 - }
9969 --
9970 -- WARN(1, "ERROR-pbd[%d]:%p\n", pkc->kactive_blk_num, pbd);
9971 -- dump_stack();
9972 -- BUG();
9973 - }
9974 -
9975 - static int prb_curr_blk_in_use(struct tpacket_kbdq_core *pkc,
9976 -diff --git a/net/sched/act_ipt.c b/net/sched/act_ipt.c
9977 -index e0f6de6..60d88b6 100644
9978 ---- a/net/sched/act_ipt.c
9979 -+++ b/net/sched/act_ipt.c
9980 -@@ -8,7 +8,7 @@
9981 - * as published by the Free Software Foundation; either version
9982 - * 2 of the License, or (at your option) any later version.
9983 - *
9984 -- * Copyright: Jamal Hadi Salim (2002-4)
9985 -+ * Copyright: Jamal Hadi Salim (2002-13)
9986 - */
9987 -
9988 - #include <linux/types.h>
9989 -@@ -303,17 +303,44 @@ static struct tc_action_ops act_ipt_ops = {
9990 - .walk = tcf_generic_walker
9991 - };
9992 -
9993 --MODULE_AUTHOR("Jamal Hadi Salim(2002-4)");
9994 -+static struct tc_action_ops act_xt_ops = {
9995 -+ .kind = "xt",
9996 -+ .hinfo = &ipt_hash_info,
9997 -+ .type = TCA_ACT_IPT,
9998 -+ .capab = TCA_CAP_NONE,
9999 -+ .owner = THIS_MODULE,
10000 -+ .act = tcf_ipt,
10001 -+ .dump = tcf_ipt_dump,
10002 -+ .cleanup = tcf_ipt_cleanup,
10003 -+ .lookup = tcf_hash_search,
10004 -+ .init = tcf_ipt_init,
10005 -+ .walk = tcf_generic_walker
10006 -+};
10007 -+
10008 -+MODULE_AUTHOR("Jamal Hadi Salim(2002-13)");
10009 - MODULE_DESCRIPTION("Iptables target actions");
10010 - MODULE_LICENSE("GPL");
10011 -+MODULE_ALIAS("act_xt");
10012 -
10013 - static int __init ipt_init_module(void)
10014 - {
10015 -- return tcf_register_action(&act_ipt_ops);
10016 -+ int ret1, ret2;
10017 -+ ret1 = tcf_register_action(&act_xt_ops);
10018 -+ if (ret1 < 0)
10019 -+ printk("Failed to load xt action\n");
10020 -+ ret2 = tcf_register_action(&act_ipt_ops);
10021 -+ if (ret2 < 0)
10022 -+ printk("Failed to load ipt action\n");
10023 -+
10024 -+ if (ret1 < 0 && ret2 < 0)
10025 -+ return ret1;
10026 -+ else
10027 -+ return 0;
10028 - }
10029 -
10030 - static void __exit ipt_cleanup_module(void)
10031 - {
10032 -+ tcf_unregister_action(&act_xt_ops);
10033 - tcf_unregister_action(&act_ipt_ops);
10034 - }
10035 -
10036 -diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
10037 -index 7f93e2a..2e330e8 100644
10038 ---- a/net/vmw_vsock/af_vsock.c
10039 -+++ b/net/vmw_vsock/af_vsock.c
10040 -@@ -165,7 +165,7 @@ static struct list_head vsock_bind_table[VSOCK_HASH_SIZE + 1];
10041 - static struct list_head vsock_connected_table[VSOCK_HASH_SIZE];
10042 - static DEFINE_SPINLOCK(vsock_table_lock);
10043 -
10044 --static __init void vsock_init_tables(void)
10045 -+static void vsock_init_tables(void)
10046 - {
10047 - int i;
10048 -
10049 -diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
10050 -index 4aba764..c414cdd 100644
10051 ---- a/sound/pci/hda/hda_codec.c
10052 -+++ b/sound/pci/hda/hda_codec.c
10053 -@@ -681,6 +681,9 @@ int snd_hda_queue_unsol_event(struct hda_bus *bus, u32 res, u32 res_ex)
10054 - struct hda_bus_unsolicited *unsol;
10055 - unsigned int wp;
10056 -
10057 -+ if (!bus || !bus->workq)
10058 -+ return 0;
10059 -+
10060 - trace_hda_unsol_event(bus, res, res_ex);
10061 - unsol = bus->unsol;
10062 - if (!unsol)
10063 -@@ -1577,7 +1580,7 @@ void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid,
10064 - "NID=0x%x, stream=0x%x, channel=%d, format=0x%x\n",
10065 - nid, stream_tag, channel_id, format);
10066 - p = get_hda_cvt_setup(codec, nid);
10067 -- if (!p || p->active)
10068 -+ if (!p)
10069 - return;
10070 -
10071 - if (codec->pcm_format_first)
10072 -@@ -1624,7 +1627,7 @@ void __snd_hda_codec_cleanup_stream(struct hda_codec *codec, hda_nid_t nid,
10073 -
10074 - snd_printdd("hda_codec_cleanup_stream: NID=0x%x\n", nid);
10075 - p = get_hda_cvt_setup(codec, nid);
10076 -- if (p && p->active) {
10077 -+ if (p) {
10078 - /* here we just clear the active flag when do_now isn't set;
10079 - * actual clean-ups will be done later in
10080 - * purify_inactive_streams() called from snd_hda_codec_prpapre()
10081 -diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c
10082 -index 2a89d1ee..1e5a30f 100644
10083 ---- a/sound/pci/hda/patch_conexant.c
10084 -+++ b/sound/pci/hda/patch_conexant.c
10085 -@@ -64,6 +64,7 @@ struct conexant_spec {
10086 - /* extra EAPD pins */
10087 - unsigned int num_eapds;
10088 - hda_nid_t eapds[4];
10089 -+ bool dynamic_eapd;
10090 -
10091 - #ifdef ENABLE_CXT_STATIC_QUIRKS
10092 - const struct snd_kcontrol_new *mixers[5];
10093 -@@ -3152,7 +3153,7 @@ static void cx_auto_parse_eapd(struct hda_codec *codec)
10094 - * thus it might control over all pins.
10095 - */
10096 - if (spec->num_eapds > 2)
10097 -- spec->gen.own_eapd_ctl = 1;
10098 -+ spec->dynamic_eapd = 1;
10099 - }
10100 -
10101 - static void cx_auto_turn_eapd(struct hda_codec *codec, int num_pins,
10102 -@@ -3191,6 +3192,15 @@ static int cx_auto_build_controls(struct hda_codec *codec)
10103 - return 0;
10104 - }
10105 -
10106 -+static int cx_auto_init(struct hda_codec *codec)
10107 -+{
10108 -+ struct conexant_spec *spec = codec->spec;
10109 -+ snd_hda_gen_init(codec);
10110 -+ if (!spec->dynamic_eapd)
10111 -+ cx_auto_turn_eapd(codec, spec->num_eapds, spec->eapds, true);
10112 -+ return 0;
10113 -+}
10114 -+
10115 - static void cx_auto_free(struct hda_codec *codec)
10116 - {
10117 - snd_hda_detach_beep_device(codec);
10118 -@@ -3200,7 +3210,7 @@ static void cx_auto_free(struct hda_codec *codec)
10119 - static const struct hda_codec_ops cx_auto_patch_ops = {
10120 - .build_controls = cx_auto_build_controls,
10121 - .build_pcms = snd_hda_gen_build_pcms,
10122 -- .init = snd_hda_gen_init,
10123 -+ .init = cx_auto_init,
10124 - .free = cx_auto_free,
10125 - .unsol_event = snd_hda_jack_unsol_event,
10126 - #ifdef CONFIG_PM
10127 -@@ -3350,7 +3360,8 @@ static int patch_conexant_auto(struct hda_codec *codec)
10128 -
10129 - cx_auto_parse_beep(codec);
10130 - cx_auto_parse_eapd(codec);
10131 -- if (spec->gen.own_eapd_ctl)
10132 -+ spec->gen.own_eapd_ctl = 1;
10133 -+ if (spec->dynamic_eapd)
10134 - spec->gen.vmaster_mute.hook = cx_auto_vmaster_hook;
10135 -
10136 - switch (codec->vendor_id) {
10137 -diff --git a/sound/soc/codecs/da7213.c b/sound/soc/codecs/da7213.c
10138 -index 41230ad..4a6f1da 100644
10139 ---- a/sound/soc/codecs/da7213.c
10140 -+++ b/sound/soc/codecs/da7213.c
10141 -@@ -1488,17 +1488,17 @@ static int da7213_probe(struct snd_soc_codec *codec)
10142 - DA7213_DMIC_DATA_SEL_SHIFT);
10143 - break;
10144 - }
10145 -- switch (pdata->dmic_data_sel) {
10146 -+ switch (pdata->dmic_samplephase) {
10147 - case DA7213_DMIC_SAMPLE_ON_CLKEDGE:
10148 - case DA7213_DMIC_SAMPLE_BETWEEN_CLKEDGE:
10149 -- dmic_cfg |= (pdata->dmic_data_sel <<
10150 -+ dmic_cfg |= (pdata->dmic_samplephase <<
10151 - DA7213_DMIC_SAMPLEPHASE_SHIFT);
10152 - break;
10153 - }
10154 -- switch (pdata->dmic_data_sel) {
10155 -+ switch (pdata->dmic_clk_rate) {
10156 - case DA7213_DMIC_CLK_3_0MHZ:
10157 - case DA7213_DMIC_CLK_1_5MHZ:
10158 -- dmic_cfg |= (pdata->dmic_data_sel <<
10159 -+ dmic_cfg |= (pdata->dmic_clk_rate <<
10160 - DA7213_DMIC_CLK_RATE_SHIFT);
10161 - break;
10162 - }
10163 -diff --git a/sound/soc/codecs/wm8994.c b/sound/soc/codecs/wm8994.c
10164 -index c9bd445..e5f96c9 100644
10165 ---- a/sound/soc/codecs/wm8994.c
10166 -+++ b/sound/soc/codecs/wm8994.c
10167 -@@ -2841,6 +2841,7 @@ static int wm8994_aif3_hw_params(struct snd_pcm_substream *substream,
10168 - default:
10169 - return 0;
10170 - }
10171 -+ break;
10172 - default:
10173 - return 0;
10174 - }