Gentoo Archives: gentoo-commits

From: Mike Pagano <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:3.4 commit in: /
Date: Wed, 27 Apr 2016 19:32:17
Message-Id: 1461785519.c0e453500c330875aef0cc8f1c5669781dc4ee16.mpagano@gentoo
1 commit: c0e453500c330875aef0cc8f1c5669781dc4ee16
2 Author: Mike Pagano <mpagano <AT> gentoo <DOT> org>
3 AuthorDate: Wed Apr 27 19:31:59 2016 +0000
4 Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org>
5 CommitDate: Wed Apr 27 19:31:59 2016 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=c0e45350
7
8 Linux patch 3.4.112
9
10 0000_README | 4 +
11 1111_linux-3.4.112.patch | 3175 ++++++++++++++++++++++++++++++++++++++++++++++
12 2 files changed, 3179 insertions(+)
13
14 diff --git a/0000_README b/0000_README
15 index efb1797..2dee9b4 100644
16 --- a/0000_README
17 +++ b/0000_README
18 @@ -483,6 +483,10 @@ Patch: 1110_linux-3.4.111.patch
19 From: http://www.kernel.org
20 Desc: Linux 3.4.111
21
22 +Patch: 1111_linux-3.4.112.patch
23 +From: http://www.kernel.org
24 +Desc: Linux 3.4.112
25 +
26 Patch: 1500_XATTR_USER_PREFIX.patch
27 From: https://bugs.gentoo.org/show_bug.cgi?id=470644
28 Desc: Support for namespace user.pax.* on tmpfs.
29
30 diff --git a/1111_linux-3.4.112.patch b/1111_linux-3.4.112.patch
31 new file mode 100644
32 index 0000000..0247885
33 --- /dev/null
34 +++ b/1111_linux-3.4.112.patch
35 @@ -0,0 +1,3175 @@
36 +diff --git a/Makefile b/Makefile
37 +index 8a3f507065f9..c63e1836d738 100644
38 +--- a/Makefile
39 ++++ b/Makefile
40 +@@ -1,6 +1,6 @@
41 + VERSION = 3
42 + PATCHLEVEL = 4
43 +-SUBLEVEL = 111
44 ++SUBLEVEL = 112
45 + EXTRAVERSION =
46 + NAME = Saber-toothed Squirrel
47 +
48 +diff --git a/arch/arm/Makefile b/arch/arm/Makefile
49 +index 1d6402cbf4b2..4533386a2c84 100644
50 +--- a/arch/arm/Makefile
51 ++++ b/arch/arm/Makefile
52 +@@ -53,6 +53,14 @@ endif
53 +
54 + comma = ,
55 +
56 ++#
57 ++# The Scalar Replacement of Aggregates (SRA) optimization pass in GCC 4.9 and
58 ++# later may result in code being generated that handles signed short and signed
59 ++# char struct members incorrectly. So disable it.
60 ++# (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65932)
61 ++#
62 ++KBUILD_CFLAGS += $(call cc-option,-fno-ipa-sra)
63 ++
64 + # This selects which instruction set is used.
65 + # Note that GCC does not numerically define an architecture version
66 + # macro, but instead defines a whole series of macros which makes
67 +diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
68 +index d68d1b694680..13579aa1494e 100644
69 +--- a/arch/arm/kernel/signal.c
70 ++++ b/arch/arm/kernel/signal.c
71 +@@ -437,12 +437,23 @@ setup_return(struct pt_regs *regs, struct k_sigaction *ka,
72 + */
73 + thumb = handler & 1;
74 +
75 ++#if __LINUX_ARM_ARCH__ >= 6
76 ++ /*
77 ++ * Clear the If-Then Thumb-2 execution state. ARM spec
78 ++ * requires this to be all 000s in ARM mode. Snapdragon
79 ++ * S4/Krait misbehaves on a Thumb=>ARM signal transition
80 ++ * without this.
81 ++ *
82 ++ * We must do this whenever we are running on a Thumb-2
83 ++ * capable CPU, which includes ARMv6T2. However, we elect
84 ++ * to do this whenever we're on an ARMv6 or later CPU for
85 ++ * simplicity.
86 ++ */
87 ++ cpsr &= ~PSR_IT_MASK;
88 ++#endif
89 ++
90 + if (thumb) {
91 + cpsr |= PSR_T_BIT;
92 +-#if __LINUX_ARM_ARCH__ >= 7
93 +- /* clear the If-Then Thumb-2 execution state */
94 +- cpsr &= ~PSR_IT_MASK;
95 +-#endif
96 + } else
97 + cpsr &= ~PSR_T_BIT;
98 + }
99 +diff --git a/arch/m68k/include/asm/linkage.h b/arch/m68k/include/asm/linkage.h
100 +index 5a822bb790f7..066e74f666ae 100644
101 +--- a/arch/m68k/include/asm/linkage.h
102 ++++ b/arch/m68k/include/asm/linkage.h
103 +@@ -4,4 +4,34 @@
104 + #define __ALIGN .align 4
105 + #define __ALIGN_STR ".align 4"
106 +
107 ++/*
108 ++ * Make sure the compiler doesn't do anything stupid with the
109 ++ * arguments on the stack - they are owned by the *caller*, not
110 ++ * the callee. This just fools gcc into not spilling into them,
111 ++ * and keeps it from doing tailcall recursion and/or using the
112 ++ * stack slots for temporaries, since they are live and "used"
113 ++ * all the way to the end of the function.
114 ++ */
115 ++#define asmlinkage_protect(n, ret, args...) \
116 ++ __asmlinkage_protect##n(ret, ##args)
117 ++#define __asmlinkage_protect_n(ret, args...) \
118 ++ __asm__ __volatile__ ("" : "=r" (ret) : "0" (ret), ##args)
119 ++#define __asmlinkage_protect0(ret) \
120 ++ __asmlinkage_protect_n(ret)
121 ++#define __asmlinkage_protect1(ret, arg1) \
122 ++ __asmlinkage_protect_n(ret, "m" (arg1))
123 ++#define __asmlinkage_protect2(ret, arg1, arg2) \
124 ++ __asmlinkage_protect_n(ret, "m" (arg1), "m" (arg2))
125 ++#define __asmlinkage_protect3(ret, arg1, arg2, arg3) \
126 ++ __asmlinkage_protect_n(ret, "m" (arg1), "m" (arg2), "m" (arg3))
127 ++#define __asmlinkage_protect4(ret, arg1, arg2, arg3, arg4) \
128 ++ __asmlinkage_protect_n(ret, "m" (arg1), "m" (arg2), "m" (arg3), \
129 ++ "m" (arg4))
130 ++#define __asmlinkage_protect5(ret, arg1, arg2, arg3, arg4, arg5) \
131 ++ __asmlinkage_protect_n(ret, "m" (arg1), "m" (arg2), "m" (arg3), \
132 ++ "m" (arg4), "m" (arg5))
133 ++#define __asmlinkage_protect6(ret, arg1, arg2, arg3, arg4, arg5, arg6) \
134 ++ __asmlinkage_protect_n(ret, "m" (arg1), "m" (arg2), "m" (arg3), \
135 ++ "m" (arg4), "m" (arg5), "m" (arg6))
136 ++
137 + #endif
138 +diff --git a/arch/mips/mm/dma-default.c b/arch/mips/mm/dma-default.c
139 +index 0eea2d2e8563..f395d5dd19b6 100644
140 +--- a/arch/mips/mm/dma-default.c
141 ++++ b/arch/mips/mm/dma-default.c
142 +@@ -71,7 +71,7 @@ static gfp_t massage_gfp_flags(const struct device *dev, gfp_t gfp)
143 + else
144 + #endif
145 + #if defined(CONFIG_ZONE_DMA) && !defined(CONFIG_ZONE_DMA32)
146 +- if (dev->coherent_dma_mask < DMA_BIT_MASK(64))
147 ++ if (dev->coherent_dma_mask < DMA_BIT_MASK(sizeof(phys_addr_t) * 8))
148 + dma_flag = __GFP_DMA;
149 + else
150 + #endif
151 +diff --git a/arch/powerpc/include/asm/rtas.h b/arch/powerpc/include/asm/rtas.h
152 +index 5e7e00889d6f..8e172066e4bc 100644
153 +--- a/arch/powerpc/include/asm/rtas.h
154 ++++ b/arch/powerpc/include/asm/rtas.h
155 +@@ -253,6 +253,7 @@ extern void rtas_power_off(void);
156 + extern void rtas_halt(void);
157 + extern void rtas_os_term(char *str);
158 + extern int rtas_get_sensor(int sensor, int index, int *state);
159 ++extern int rtas_get_sensor_fast(int sensor, int index, int *state);
160 + extern int rtas_get_power_level(int powerdomain, int *level);
161 + extern int rtas_set_power_level(int powerdomain, int level, int *setlevel);
162 + extern bool rtas_indicator_present(int token, int *maxindex);
163 +diff --git a/arch/powerpc/kernel/rtas.c b/arch/powerpc/kernel/rtas.c
164 +index 225e9f225126..8178294d6548 100644
165 +--- a/arch/powerpc/kernel/rtas.c
166 ++++ b/arch/powerpc/kernel/rtas.c
167 +@@ -585,6 +585,23 @@ int rtas_get_sensor(int sensor, int index, int *state)
168 + }
169 + EXPORT_SYMBOL(rtas_get_sensor);
170 +
171 ++int rtas_get_sensor_fast(int sensor, int index, int *state)
172 ++{
173 ++ int token = rtas_token("get-sensor-state");
174 ++ int rc;
175 ++
176 ++ if (token == RTAS_UNKNOWN_SERVICE)
177 ++ return -ENOENT;
178 ++
179 ++ rc = rtas_call(token, 2, 2, state, sensor, index);
180 ++ WARN_ON(rc == RTAS_BUSY || (rc >= RTAS_EXTENDED_DELAY_MIN &&
181 ++ rc <= RTAS_EXTENDED_DELAY_MAX));
182 ++
183 ++ if (rc < 0)
184 ++ return rtas_error_rc(rc);
185 ++ return rc;
186 ++}
187 ++
188 + bool rtas_indicator_present(int token, int *maxindex)
189 + {
190 + int proplen, count, i;
191 +@@ -1025,6 +1042,9 @@ asmlinkage int ppc_rtas(struct rtas_args __user *uargs)
192 + if (!capable(CAP_SYS_ADMIN))
193 + return -EPERM;
194 +
195 ++ if (!rtas.entry)
196 ++ return -EINVAL;
197 ++
198 + if (copy_from_user(&args, uargs, 3 * sizeof(u32)) != 0)
199 + return -EFAULT;
200 +
201 +diff --git a/arch/powerpc/platforms/powernv/pci.c b/arch/powerpc/platforms/powernv/pci.c
202 +index be3cfc5ceabb..5b127c8a4a7d 100644
203 +--- a/arch/powerpc/platforms/powernv/pci.c
204 ++++ b/arch/powerpc/platforms/powernv/pci.c
205 +@@ -137,6 +137,7 @@ static void pnv_teardown_msi_irqs(struct pci_dev *pdev)
206 + struct pci_controller *hose = pci_bus_to_host(pdev->bus);
207 + struct pnv_phb *phb = hose->private_data;
208 + struct msi_desc *entry;
209 ++ irq_hw_number_t hwirq;
210 +
211 + if (WARN_ON(!phb))
212 + return;
213 +@@ -144,9 +145,10 @@ static void pnv_teardown_msi_irqs(struct pci_dev *pdev)
214 + list_for_each_entry(entry, &pdev->msi_list, list) {
215 + if (entry->irq == NO_IRQ)
216 + continue;
217 ++ hwirq = virq_to_hw(entry->irq);
218 + irq_set_msi_desc(entry->irq, NULL);
219 +- pnv_put_msi(phb, virq_to_hw(entry->irq));
220 + irq_dispose_mapping(entry->irq);
221 ++ pnv_put_msi(phb, hwirq);
222 + }
223 + }
224 + #endif /* CONFIG_PCI_MSI */
225 +diff --git a/arch/powerpc/platforms/pseries/ras.c b/arch/powerpc/platforms/pseries/ras.c
226 +index c4dfccd3a3d9..2338e6e98483 100644
227 +--- a/arch/powerpc/platforms/pseries/ras.c
228 ++++ b/arch/powerpc/platforms/pseries/ras.c
229 +@@ -187,7 +187,8 @@ static irqreturn_t ras_epow_interrupt(int irq, void *dev_id)
230 + int state;
231 + int critical;
232 +
233 +- status = rtas_get_sensor(EPOW_SENSOR_TOKEN, EPOW_SENSOR_INDEX, &state);
234 ++ status = rtas_get_sensor_fast(EPOW_SENSOR_TOKEN, EPOW_SENSOR_INDEX,
235 ++ &state);
236 +
237 + if (state > 3)
238 + critical = 1; /* Time Critical */
239 +diff --git a/arch/powerpc/sysdev/fsl_msi.c b/arch/powerpc/sysdev/fsl_msi.c
240 +index 6e097de00e09..fd1a96b793c6 100644
241 +--- a/arch/powerpc/sysdev/fsl_msi.c
242 ++++ b/arch/powerpc/sysdev/fsl_msi.c
243 +@@ -108,15 +108,16 @@ static void fsl_teardown_msi_irqs(struct pci_dev *pdev)
244 + {
245 + struct msi_desc *entry;
246 + struct fsl_msi *msi_data;
247 ++ irq_hw_number_t hwirq;
248 +
249 + list_for_each_entry(entry, &pdev->msi_list, list) {
250 + if (entry->irq == NO_IRQ)
251 + continue;
252 ++ hwirq = virq_to_hw(entry->irq);
253 + msi_data = irq_get_chip_data(entry->irq);
254 + irq_set_msi_desc(entry->irq, NULL);
255 +- msi_bitmap_free_hwirqs(&msi_data->bitmap,
256 +- virq_to_hw(entry->irq), 1);
257 + irq_dispose_mapping(entry->irq);
258 ++ msi_bitmap_free_hwirqs(&msi_data->bitmap, hwirq, 1);
259 + }
260 +
261 + return;
262 +diff --git a/arch/powerpc/sysdev/mpic_pasemi_msi.c b/arch/powerpc/sysdev/mpic_pasemi_msi.c
263 +index 38e62382070c..e8736165a7c7 100644
264 +--- a/arch/powerpc/sysdev/mpic_pasemi_msi.c
265 ++++ b/arch/powerpc/sysdev/mpic_pasemi_msi.c
266 +@@ -74,6 +74,7 @@ static int pasemi_msi_check_device(struct pci_dev *pdev, int nvec, int type)
267 + static void pasemi_msi_teardown_msi_irqs(struct pci_dev *pdev)
268 + {
269 + struct msi_desc *entry;
270 ++ irq_hw_number_t hwirq;
271 +
272 + pr_debug("pasemi_msi_teardown_msi_irqs, pdev %p\n", pdev);
273 +
274 +@@ -81,10 +82,10 @@ static void pasemi_msi_teardown_msi_irqs(struct pci_dev *pdev)
275 + if (entry->irq == NO_IRQ)
276 + continue;
277 +
278 ++ hwirq = virq_to_hw(entry->irq);
279 + irq_set_msi_desc(entry->irq, NULL);
280 +- msi_bitmap_free_hwirqs(&msi_mpic->msi_bitmap,
281 +- virq_to_hw(entry->irq), ALLOC_CHUNK);
282 + irq_dispose_mapping(entry->irq);
283 ++ msi_bitmap_free_hwirqs(&msi_mpic->msi_bitmap, hwirq, ALLOC_CHUNK);
284 + }
285 +
286 + return;
287 +diff --git a/arch/powerpc/sysdev/mpic_u3msi.c b/arch/powerpc/sysdev/mpic_u3msi.c
288 +index 9a7aa0ed9c1c..dfc3486bf802 100644
289 +--- a/arch/powerpc/sysdev/mpic_u3msi.c
290 ++++ b/arch/powerpc/sysdev/mpic_u3msi.c
291 +@@ -124,15 +124,16 @@ static int u3msi_msi_check_device(struct pci_dev *pdev, int nvec, int type)
292 + static void u3msi_teardown_msi_irqs(struct pci_dev *pdev)
293 + {
294 + struct msi_desc *entry;
295 ++ irq_hw_number_t hwirq;
296 +
297 + list_for_each_entry(entry, &pdev->msi_list, list) {
298 + if (entry->irq == NO_IRQ)
299 + continue;
300 +
301 ++ hwirq = virq_to_hw(entry->irq);
302 + irq_set_msi_desc(entry->irq, NULL);
303 +- msi_bitmap_free_hwirqs(&msi_mpic->msi_bitmap,
304 +- virq_to_hw(entry->irq), 1);
305 + irq_dispose_mapping(entry->irq);
306 ++ msi_bitmap_free_hwirqs(&msi_mpic->msi_bitmap, hwirq, 1);
307 + }
308 +
309 + return;
310 +diff --git a/arch/powerpc/sysdev/ppc4xx_msi.c b/arch/powerpc/sysdev/ppc4xx_msi.c
311 +index 1c2d7af17bbe..4aae9c8dec48 100644
312 +--- a/arch/powerpc/sysdev/ppc4xx_msi.c
313 ++++ b/arch/powerpc/sysdev/ppc4xx_msi.c
314 +@@ -114,16 +114,17 @@ void ppc4xx_teardown_msi_irqs(struct pci_dev *dev)
315 + {
316 + struct msi_desc *entry;
317 + struct ppc4xx_msi *msi_data = &ppc4xx_msi;
318 ++ irq_hw_number_t hwirq;
319 +
320 + dev_dbg(&dev->dev, "PCIE-MSI: tearing down msi irqs\n");
321 +
322 + list_for_each_entry(entry, &dev->msi_list, list) {
323 + if (entry->irq == NO_IRQ)
324 + continue;
325 ++ hwirq = virq_to_hw(entry->irq);
326 + irq_set_msi_desc(entry->irq, NULL);
327 +- msi_bitmap_free_hwirqs(&msi_data->bitmap,
328 +- virq_to_hw(entry->irq), 1);
329 + irq_dispose_mapping(entry->irq);
330 ++ msi_bitmap_free_hwirqs(&msi_data->bitmap, hwirq, 1);
331 + }
332 + }
333 +
334 +diff --git a/arch/x86/crypto/ghash-clmulni-intel_glue.c b/arch/x86/crypto/ghash-clmulni-intel_glue.c
335 +index c07446d17463..21069e9a744e 100644
336 +--- a/arch/x86/crypto/ghash-clmulni-intel_glue.c
337 ++++ b/arch/x86/crypto/ghash-clmulni-intel_glue.c
338 +@@ -292,6 +292,7 @@ static struct ahash_alg ghash_async_alg = {
339 + .cra_name = "ghash",
340 + .cra_driver_name = "ghash-clmulni",
341 + .cra_priority = 400,
342 ++ .cra_ctxsize = sizeof(struct ghash_async_ctx),
343 + .cra_flags = CRYPTO_ALG_TYPE_AHASH | CRYPTO_ALG_ASYNC,
344 + .cra_blocksize = GHASH_BLOCK_SIZE,
345 + .cra_type = &crypto_ahash_type,
346 +diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h
347 +index e92e1e4d7a5e..033b8a075f69 100644
348 +--- a/arch/x86/include/asm/msr-index.h
349 ++++ b/arch/x86/include/asm/msr-index.h
350 +@@ -166,6 +166,7 @@
351 + /* C1E active bits in int pending message */
352 + #define K8_INTP_C1E_ACTIVE_MASK 0x18000000
353 + #define MSR_K8_TSEG_ADDR 0xc0010112
354 ++#define MSR_K8_TSEG_MASK 0xc0010113
355 + #define K8_MTRRFIXRANGE_DRAM_ENABLE 0x00040000 /* MtrrFixDramEn bit */
356 + #define K8_MTRRFIXRANGE_DRAM_MODIFY 0x00080000 /* MtrrFixDramModEn bit */
357 + #define K8_MTRR_RDMEM_WRMEM_MASK 0x18181818 /* Mask: RdMem|WrMem */
358 +diff --git a/arch/x86/include/asm/xen/hypervisor.h b/arch/x86/include/asm/xen/hypervisor.h
359 +index 66d0fff1ee84..fc500f97b39d 100644
360 +--- a/arch/x86/include/asm/xen/hypervisor.h
361 ++++ b/arch/x86/include/asm/xen/hypervisor.h
362 +@@ -72,4 +72,6 @@ static inline bool xen_x2apic_para_available(void)
363 + }
364 + #endif
365 +
366 ++extern void xen_set_iopl_mask(unsigned mask);
367 ++
368 + #endif /* _ASM_X86_XEN_HYPERVISOR_H */
369 +diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
370 +index d5d7313ed430..9f341bbe0c0f 100644
371 +--- a/arch/x86/kernel/process_64.c
372 ++++ b/arch/x86/kernel/process_64.c
373 +@@ -49,6 +49,7 @@
374 + #include <asm/syscalls.h>
375 + #include <asm/debugreg.h>
376 + #include <asm/switch_to.h>
377 ++#include <asm/xen/hypervisor.h>
378 +
379 + asmlinkage extern void ret_from_fork(void);
380 +
381 +@@ -419,6 +420,17 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
382 + task_thread_info(prev_p)->flags & _TIF_WORK_CTXSW_PREV))
383 + __switch_to_xtra(prev_p, next_p, tss);
384 +
385 ++#ifdef CONFIG_XEN
386 ++ /*
387 ++ * On Xen PV, IOPL bits in pt_regs->flags have no effect, and
388 ++ * current_pt_regs()->flags may not match the current task's
389 ++ * intended IOPL. We need to switch it manually.
390 ++ */
391 ++ if (unlikely(xen_pv_domain() &&
392 ++ prev->iopl != next->iopl))
393 ++ xen_set_iopl_mask(next->iopl);
394 ++#endif
395 ++
396 + return prev_p;
397 + }
398 +
399 +@@ -470,27 +482,59 @@ void set_personality_ia32(bool x32)
400 + }
401 + EXPORT_SYMBOL_GPL(set_personality_ia32);
402 +
403 ++/*
404 ++ * Called from fs/proc with a reference on @p to find the function
405 ++ * which called into schedule(). This needs to be done carefully
406 ++ * because the task might wake up and we might look at a stack
407 ++ * changing under us.
408 ++ */
409 + unsigned long get_wchan(struct task_struct *p)
410 + {
411 +- unsigned long stack;
412 +- u64 fp, ip;
413 ++ unsigned long start, bottom, top, sp, fp, ip;
414 + int count = 0;
415 +
416 + if (!p || p == current || p->state == TASK_RUNNING)
417 + return 0;
418 +- stack = (unsigned long)task_stack_page(p);
419 +- if (p->thread.sp < stack || p->thread.sp >= stack+THREAD_SIZE)
420 ++
421 ++ start = (unsigned long)task_stack_page(p);
422 ++ if (!start)
423 ++ return 0;
424 ++
425 ++ /*
426 ++ * Layout of the stack page:
427 ++ *
428 ++ * ----------- topmax = start + THREAD_SIZE - sizeof(unsigned long)
429 ++ * PADDING
430 ++ * ----------- top = topmax - TOP_OF_KERNEL_STACK_PADDING
431 ++ * stack
432 ++ * ----------- bottom = start + sizeof(thread_info)
433 ++ * thread_info
434 ++ * ----------- start
435 ++ *
436 ++ * The tasks stack pointer points at the location where the
437 ++ * framepointer is stored. The data on the stack is:
438 ++ * ... IP FP ... IP FP
439 ++ *
440 ++ * We need to read FP and IP, so we need to adjust the upper
441 ++ * bound by another unsigned long.
442 ++ */
443 ++ top = start + THREAD_SIZE;
444 ++ top -= 2 * sizeof(unsigned long);
445 ++ bottom = start + sizeof(struct thread_info);
446 ++
447 ++ sp = ACCESS_ONCE(p->thread.sp);
448 ++ if (sp < bottom || sp > top)
449 + return 0;
450 +- fp = *(u64 *)(p->thread.sp);
451 ++
452 ++ fp = ACCESS_ONCE(*(unsigned long *)sp);
453 + do {
454 +- if (fp < (unsigned long)stack ||
455 +- fp >= (unsigned long)stack+THREAD_SIZE)
456 ++ if (fp < bottom || fp > top)
457 + return 0;
458 +- ip = *(u64 *)(fp+8);
459 ++ ip = ACCESS_ONCE(*(unsigned long *)(fp + sizeof(unsigned long)));
460 + if (!in_sched_functions(ip))
461 + return ip;
462 +- fp = *(u64 *)fp;
463 +- } while (count++ < 16);
464 ++ fp = ACCESS_ONCE(*(unsigned long *)fp);
465 ++ } while (count++ < 16 && p->state != TASK_RUNNING);
466 + return 0;
467 + }
468 +
469 +diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
470 +index 8652aa408ae0..ffded61b4c22 100644
471 +--- a/arch/x86/kernel/tsc.c
472 ++++ b/arch/x86/kernel/tsc.c
473 +@@ -18,6 +18,7 @@
474 + #include <asm/hypervisor.h>
475 + #include <asm/nmi.h>
476 + #include <asm/x86_init.h>
477 ++#include <asm/geode.h>
478 +
479 + unsigned int __read_mostly cpu_khz; /* TSC clocks / usec, not used here */
480 + EXPORT_SYMBOL(cpu_khz);
481 +@@ -800,15 +801,17 @@ EXPORT_SYMBOL_GPL(mark_tsc_unstable);
482 +
483 + static void __init check_system_tsc_reliable(void)
484 + {
485 +-#ifdef CONFIG_MGEODE_LX
486 +- /* RTSC counts during suspend */
487 ++#if defined(CONFIG_MGEODEGX1) || defined(CONFIG_MGEODE_LX) || defined(CONFIG_X86_GENERIC)
488 ++ if (is_geode_lx()) {
489 ++ /* RTSC counts during suspend */
490 + #define RTSC_SUSP 0x100
491 +- unsigned long res_low, res_high;
492 ++ unsigned long res_low, res_high;
493 +
494 +- rdmsr_safe(MSR_GEODE_BUSCONT_CONF0, &res_low, &res_high);
495 +- /* Geode_LX - the OLPC CPU has a very reliable TSC */
496 +- if (res_low & RTSC_SUSP)
497 +- tsc_clocksource_reliable = 1;
498 ++ rdmsr_safe(MSR_GEODE_BUSCONT_CONF0, &res_low, &res_high);
499 ++ /* Geode_LX - the OLPC CPU has a very reliable TSC */
500 ++ if (res_low & RTSC_SUSP)
501 ++ tsc_clocksource_reliable = 1;
502 ++ }
503 + #endif
504 + if (boot_cpu_has(X86_FEATURE_TSC_RELIABLE))
505 + tsc_clocksource_reliable = 1;
506 +diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
507 +index 9cc83e287adf..32a652179a6d 100644
508 +--- a/arch/x86/kvm/x86.c
509 ++++ b/arch/x86/kvm/x86.c
510 +@@ -1914,6 +1914,8 @@ int kvm_get_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 *pdata)
511 + case MSR_IA32_LASTINTFROMIP:
512 + case MSR_IA32_LASTINTTOIP:
513 + case MSR_K8_SYSCFG:
514 ++ case MSR_K8_TSEG_ADDR:
515 ++ case MSR_K8_TSEG_MASK:
516 + case MSR_K7_HWCR:
517 + case MSR_VM_HSAVE_PA:
518 + case MSR_K7_EVNTSEL0:
519 +diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
520 +index 8ade106b879b..761c086778d3 100644
521 +--- a/arch/x86/xen/enlighten.c
522 ++++ b/arch/x86/xen/enlighten.c
523 +@@ -860,7 +860,7 @@ static void xen_load_sp0(struct tss_struct *tss,
524 + xen_mc_issue(PARAVIRT_LAZY_CPU);
525 + }
526 +
527 +-static void xen_set_iopl_mask(unsigned mask)
528 ++void xen_set_iopl_mask(unsigned mask)
529 + {
530 + struct physdev_set_iopl set_iopl;
531 +
532 +diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c
533 +index f8b02601887e..f60abe6d3351 100644
534 +--- a/arch/x86/xen/setup.c
535 ++++ b/arch/x86/xen/setup.c
536 +@@ -274,7 +274,7 @@ char * __init xen_memory_setup(void)
537 + xen_ignore_unusable(map, memmap.nr_entries);
538 +
539 + /* Make sure the Xen-supplied memory map is well-ordered. */
540 +- sanitize_e820_map(map, memmap.nr_entries, &memmap.nr_entries);
541 ++ sanitize_e820_map(map, ARRAY_SIZE(map), &memmap.nr_entries);
542 +
543 + max_pages = xen_get_max_pages();
544 + if (max_pages > max_pfn)
545 +diff --git a/crypto/ablkcipher.c b/crypto/ablkcipher.c
546 +index 45fe4109698e..4a9c499ea78a 100644
547 +--- a/crypto/ablkcipher.c
548 ++++ b/crypto/ablkcipher.c
549 +@@ -700,7 +700,7 @@ struct crypto_ablkcipher *crypto_alloc_ablkcipher(const char *alg_name,
550 + err:
551 + if (err != -EAGAIN)
552 + break;
553 +- if (signal_pending(current)) {
554 ++ if (fatal_signal_pending(current)) {
555 + err = -EINTR;
556 + break;
557 + }
558 +diff --git a/crypto/ahash.c b/crypto/ahash.c
559 +index 0ec05feea438..58241912a07f 100644
560 +--- a/crypto/ahash.c
561 ++++ b/crypto/ahash.c
562 +@@ -462,7 +462,8 @@ static int ahash_prepare_alg(struct ahash_alg *alg)
563 + struct crypto_alg *base = &alg->halg.base;
564 +
565 + if (alg->halg.digestsize > PAGE_SIZE / 8 ||
566 +- alg->halg.statesize > PAGE_SIZE / 8)
567 ++ alg->halg.statesize > PAGE_SIZE / 8 ||
568 ++ alg->halg.statesize == 0)
569 + return -EINVAL;
570 +
571 + base->cra_type = &crypto_ahash_type;
572 +diff --git a/crypto/algapi.c b/crypto/algapi.c
573 +index b4c046c39419..7bae610afef8 100644
574 +--- a/crypto/algapi.c
575 ++++ b/crypto/algapi.c
576 +@@ -342,7 +342,7 @@ static void crypto_wait_for_test(struct crypto_larval *larval)
577 + crypto_alg_tested(larval->alg.cra_driver_name, 0);
578 + }
579 +
580 +- err = wait_for_completion_interruptible(&larval->completion);
581 ++ err = wait_for_completion_killable(&larval->completion);
582 + WARN_ON(err);
583 +
584 + out:
585 +diff --git a/crypto/api.c b/crypto/api.c
586 +index 4f98dd5b1911..c9c2f47843d5 100644
587 +--- a/crypto/api.c
588 ++++ b/crypto/api.c
589 +@@ -178,7 +178,7 @@ static struct crypto_alg *crypto_larval_wait(struct crypto_alg *alg)
590 + struct crypto_larval *larval = (void *)alg;
591 + long timeout;
592 +
593 +- timeout = wait_for_completion_interruptible_timeout(
594 ++ timeout = wait_for_completion_killable_timeout(
595 + &larval->completion, 60 * HZ);
596 +
597 + alg = larval->adult;
598 +@@ -441,7 +441,7 @@ struct crypto_tfm *crypto_alloc_base(const char *alg_name, u32 type, u32 mask)
599 + err:
600 + if (err != -EAGAIN)
601 + break;
602 +- if (signal_pending(current)) {
603 ++ if (fatal_signal_pending(current)) {
604 + err = -EINTR;
605 + break;
606 + }
607 +@@ -558,7 +558,7 @@ void *crypto_alloc_tfm(const char *alg_name,
608 + err:
609 + if (err != -EAGAIN)
610 + break;
611 +- if (signal_pending(current)) {
612 ++ if (fatal_signal_pending(current)) {
613 + err = -EINTR;
614 + break;
615 + }
616 +diff --git a/crypto/crypto_user.c b/crypto/crypto_user.c
617 +index 910497bd72be..0c19d035729b 100644
618 +--- a/crypto/crypto_user.c
619 ++++ b/crypto/crypto_user.c
620 +@@ -350,7 +350,7 @@ static struct crypto_alg *crypto_user_aead_alg(const char *name, u32 type,
621 + err = PTR_ERR(alg);
622 + if (err != -EAGAIN)
623 + break;
624 +- if (signal_pending(current)) {
625 ++ if (fatal_signal_pending(current)) {
626 + err = -EINTR;
627 + break;
628 + }
629 +diff --git a/drivers/auxdisplay/ks0108.c b/drivers/auxdisplay/ks0108.c
630 +index 5b93852392b8..0d752851a1ee 100644
631 +--- a/drivers/auxdisplay/ks0108.c
632 ++++ b/drivers/auxdisplay/ks0108.c
633 +@@ -139,6 +139,7 @@ static int __init ks0108_init(void)
634 +
635 + ks0108_pardevice = parport_register_device(ks0108_parport, KS0108_NAME,
636 + NULL, NULL, NULL, PARPORT_DEV_EXCL, NULL);
637 ++ parport_put_port(ks0108_parport);
638 + if (ks0108_pardevice == NULL) {
639 + printk(KERN_ERR KS0108_NAME ": ERROR: "
640 + "parport didn't register new device\n");
641 +diff --git a/drivers/base/devres.c b/drivers/base/devres.c
642 +index 524bf96c289f..06c541dc4d50 100644
643 +--- a/drivers/base/devres.c
644 ++++ b/drivers/base/devres.c
645 +@@ -254,10 +254,10 @@ void * devres_get(struct device *dev, void *new_res,
646 + if (!dr) {
647 + add_dr(dev, &new_dr->node);
648 + dr = new_dr;
649 +- new_dr = NULL;
650 ++ new_res = NULL;
651 + }
652 + spin_unlock_irqrestore(&dev->devres_lock, flags);
653 +- devres_free(new_dr);
654 ++ devres_free(new_res);
655 +
656 + return dr->data;
657 + }
658 +diff --git a/drivers/base/platform.c b/drivers/base/platform.c
659 +index a1a722502587..5a1373330487 100644
660 +--- a/drivers/base/platform.c
661 ++++ b/drivers/base/platform.c
662 +@@ -311,9 +311,7 @@ int platform_device_add(struct platform_device *pdev)
663 + failed:
664 + while (--i >= 0) {
665 + struct resource *r = &pdev->resource[i];
666 +- unsigned long type = resource_type(r);
667 +-
668 +- if (type == IORESOURCE_MEM || type == IORESOURCE_IO)
669 ++ if (r->parent)
670 + release_resource(r);
671 + }
672 +
673 +@@ -338,9 +336,7 @@ void platform_device_del(struct platform_device *pdev)
674 +
675 + for (i = 0; i < pdev->num_resources; i++) {
676 + struct resource *r = &pdev->resource[i];
677 +- unsigned long type = resource_type(r);
678 +-
679 +- if (type == IORESOURCE_MEM || type == IORESOURCE_IO)
680 ++ if (r->parent)
681 + release_resource(r);
682 + }
683 + }
684 +diff --git a/drivers/base/regmap/regmap-debugfs.c b/drivers/base/regmap/regmap-debugfs.c
685 +index 1db12895110a..023a9d79e26a 100644
686 +--- a/drivers/base/regmap/regmap-debugfs.c
687 ++++ b/drivers/base/regmap/regmap-debugfs.c
688 +@@ -23,8 +23,7 @@ static struct dentry *regmap_debugfs_root;
689 + /* Calculate the length of a fixed format */
690 + static size_t regmap_calc_reg_len(int max_val, char *buf, size_t buf_size)
691 + {
692 +- snprintf(buf, buf_size, "%x", max_val);
693 +- return strlen(buf);
694 ++ return snprintf(NULL, 0, "%x", max_val);
695 + }
696 +
697 + static ssize_t regmap_name_read_file(struct file *file,
698 +@@ -205,7 +204,7 @@ static ssize_t regmap_access_read_file(struct file *file,
699 + /* If we're in the region the user is trying to read */
700 + if (p >= *ppos) {
701 + /* ...but not beyond it */
702 +- if (buf_pos >= count - 1 - tot_len)
703 ++ if (buf_pos + tot_len + 1 >= count)
704 + break;
705 +
706 + /* Format the register */
707 +diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
708 +index a81cdd7b9d83..16477b255d82 100644
709 +--- a/drivers/block/xen-blkfront.c
710 ++++ b/drivers/block/xen-blkfront.c
711 +@@ -1314,7 +1314,8 @@ static void blkback_changed(struct xenbus_device *dev,
712 + break;
713 + /* Missed the backend's Closing state -- fallthrough */
714 + case XenbusStateClosing:
715 +- blkfront_closing(info);
716 ++ if (info)
717 ++ blkfront_closing(info);
718 + break;
719 + }
720 + }
721 +diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
722 +index ed4b7481a865..93c5b2fdf9b4 100644
723 +--- a/drivers/gpu/drm/drm_crtc.c
724 ++++ b/drivers/gpu/drm/drm_crtc.c
725 +@@ -2945,7 +2945,7 @@ static struct drm_property_blob *drm_property_create_blob(struct drm_device *dev
726 + struct drm_property_blob *blob;
727 + int ret;
728 +
729 +- if (!length || !data)
730 ++ if (!length || length > ULONG_MAX - sizeof(struct drm_property_blob) || !data)
731 + return NULL;
732 +
733 + blob = kzalloc(sizeof(struct drm_property_blob)+length, GFP_KERNEL);
734 +diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
735 +index 2f46bbfbb1f8..b242534f57c5 100644
736 +--- a/drivers/gpu/drm/nouveau/nouveau_gem.c
737 ++++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
738 +@@ -172,11 +172,12 @@ nouveau_gem_info(struct drm_file *file_priv, struct drm_gem_object *gem,
739 + struct nouveau_bo *nvbo = nouveau_gem_object(gem);
740 + struct nouveau_vma *vma;
741 +
742 +- if (nvbo->bo.mem.mem_type == TTM_PL_TT)
743 ++ if (is_power_of_2(nvbo->valid_domains))
744 ++ rep->domain = nvbo->valid_domains;
745 ++ else if (nvbo->bo.mem.mem_type == TTM_PL_TT)
746 + rep->domain = NOUVEAU_GEM_DOMAIN_GART;
747 + else
748 + rep->domain = NOUVEAU_GEM_DOMAIN_VRAM;
749 +-
750 + rep->offset = nvbo->bo.offset;
751 + if (fpriv->vm) {
752 + vma = nouveau_bo_vma_find(nvbo, fpriv->vm);
753 +diff --git a/drivers/gpu/drm/radeon/radeon_combios.c b/drivers/gpu/drm/radeon/radeon_combios.c
754 +index b72eb507df64..69c2dd085722 100644
755 +--- a/drivers/gpu/drm/radeon/radeon_combios.c
756 ++++ b/drivers/gpu/drm/radeon/radeon_combios.c
757 +@@ -3399,6 +3399,14 @@ void radeon_combios_asic_init(struct drm_device *dev)
758 + rdev->pdev->subsystem_device == 0x30ae)
759 + return;
760 +
761 ++ /* quirk for rs4xx HP Compaq dc5750 Small Form Factor to make it resume
762 ++ * - it hangs on resume inside the dynclk 1 table.
763 ++ */
764 ++ if (rdev->family == CHIP_RS480 &&
765 ++ rdev->pdev->subsystem_vendor == 0x103c &&
766 ++ rdev->pdev->subsystem_device == 0x280a)
767 ++ return;
768 ++
769 + /* DYN CLK 1 */
770 + table = combios_get_table_offset(dev, COMBIOS_DYN_CLK_1_TABLE);
771 + if (table)
772 +diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c b/drivers/gpu/drm/radeon/radeon_connectors.c
773 +index 9184bbe7c602..9c5d96cb6e14 100644
774 +--- a/drivers/gpu/drm/radeon/radeon_connectors.c
775 ++++ b/drivers/gpu/drm/radeon/radeon_connectors.c
776 +@@ -82,6 +82,11 @@ void radeon_connector_hotplug(struct drm_connector *connector)
777 + if (!radeon_hpd_sense(rdev, radeon_connector->hpd.hpd)) {
778 + drm_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF);
779 + } else if (radeon_dp_needs_link_train(radeon_connector)) {
780 ++ /* Don't try to start link training before we
781 ++ * have the dpcd */
782 ++ if (!radeon_dp_getdpcd(radeon_connector))
783 ++ return;
784 ++
785 + /* set it to OFF so that drm_helper_connector_dpms()
786 + * won't return immediately since the current state
787 + * is ON at this point.
788 +diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
789 +index c889aaef3416..90104c6fc0a4 100644
790 +--- a/drivers/infiniband/core/cm.c
791 ++++ b/drivers/infiniband/core/cm.c
792 +@@ -856,6 +856,11 @@ retest:
793 + case IB_CM_SIDR_REQ_RCVD:
794 + spin_unlock_irq(&cm_id_priv->lock);
795 + cm_reject_sidr_req(cm_id_priv, IB_SIDR_REJECT);
796 ++ spin_lock_irq(&cm.lock);
797 ++ if (!RB_EMPTY_NODE(&cm_id_priv->sidr_id_node))
798 ++ rb_erase(&cm_id_priv->sidr_id_node,
799 ++ &cm.remote_sidr_table);
800 ++ spin_unlock_irq(&cm.lock);
801 + break;
802 + case IB_CM_REQ_SENT:
803 + ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg);
804 +@@ -3092,7 +3097,10 @@ int ib_send_cm_sidr_rep(struct ib_cm_id *cm_id,
805 + spin_unlock_irqrestore(&cm_id_priv->lock, flags);
806 +
807 + spin_lock_irqsave(&cm.lock, flags);
808 +- rb_erase(&cm_id_priv->sidr_id_node, &cm.remote_sidr_table);
809 ++ if (!RB_EMPTY_NODE(&cm_id_priv->sidr_id_node)) {
810 ++ rb_erase(&cm_id_priv->sidr_id_node, &cm.remote_sidr_table);
811 ++ RB_CLEAR_NODE(&cm_id_priv->sidr_id_node);
812 ++ }
813 + spin_unlock_irqrestore(&cm.lock, flags);
814 + return 0;
815 +
816 +diff --git a/drivers/infiniband/core/uverbs.h b/drivers/infiniband/core/uverbs.h
817 +index 5bcb2afd3dcb..228af1894dc9 100644
818 +--- a/drivers/infiniband/core/uverbs.h
819 ++++ b/drivers/infiniband/core/uverbs.h
820 +@@ -69,7 +69,7 @@
821 + */
822 +
823 + struct ib_uverbs_device {
824 +- struct kref ref;
825 ++ atomic_t refcount;
826 + int num_comp_vectors;
827 + struct completion comp;
828 + struct device *dev;
829 +@@ -78,6 +78,7 @@ struct ib_uverbs_device {
830 + struct cdev cdev;
831 + struct rb_root xrcd_tree;
832 + struct mutex xrcd_tree_mutex;
833 ++ struct kobject kobj;
834 + };
835 +
836 + struct ib_uverbs_event_file {
837 +diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
838 +index 4d27e4c3fe34..95885b49033a 100644
839 +--- a/drivers/infiniband/core/uverbs_cmd.c
840 ++++ b/drivers/infiniband/core/uverbs_cmd.c
841 +@@ -1979,6 +1979,12 @@ ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file,
842 + next->send_flags = user_wr->send_flags;
843 +
844 + if (is_ud) {
845 ++ if (next->opcode != IB_WR_SEND &&
846 ++ next->opcode != IB_WR_SEND_WITH_IMM) {
847 ++ ret = -EINVAL;
848 ++ goto out_put;
849 ++ }
850 ++
851 + next->wr.ud.ah = idr_read_ah(user_wr->wr.ud.ah,
852 + file->ucontext);
853 + if (!next->wr.ud.ah) {
854 +@@ -2015,9 +2021,11 @@ ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file,
855 + user_wr->wr.atomic.compare_add;
856 + next->wr.atomic.swap = user_wr->wr.atomic.swap;
857 + next->wr.atomic.rkey = user_wr->wr.atomic.rkey;
858 ++ case IB_WR_SEND:
859 + break;
860 + default:
861 +- break;
862 ++ ret = -EINVAL;
863 ++ goto out_put;
864 + }
865 + }
866 +
867 +diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c
868 +index 5b51e4e6e7f9..c8e766924385 100644
869 +--- a/drivers/infiniband/core/uverbs_main.c
870 ++++ b/drivers/infiniband/core/uverbs_main.c
871 +@@ -117,14 +117,18 @@ static ssize_t (*uverbs_cmd_table[])(struct ib_uverbs_file *file,
872 + static void ib_uverbs_add_one(struct ib_device *device);
873 + static void ib_uverbs_remove_one(struct ib_device *device);
874 +
875 +-static void ib_uverbs_release_dev(struct kref *ref)
876 ++static void ib_uverbs_release_dev(struct kobject *kobj)
877 + {
878 + struct ib_uverbs_device *dev =
879 +- container_of(ref, struct ib_uverbs_device, ref);
880 ++ container_of(kobj, struct ib_uverbs_device, kobj);
881 +
882 +- complete(&dev->comp);
883 ++ kfree(dev);
884 + }
885 +
886 ++static struct kobj_type ib_uverbs_dev_ktype = {
887 ++ .release = ib_uverbs_release_dev,
888 ++};
889 ++
890 + static void ib_uverbs_release_event_file(struct kref *ref)
891 + {
892 + struct ib_uverbs_event_file *file =
893 +@@ -273,13 +277,19 @@ static int ib_uverbs_cleanup_ucontext(struct ib_uverbs_file *file,
894 + return context->device->dealloc_ucontext(context);
895 + }
896 +
897 ++static void ib_uverbs_comp_dev(struct ib_uverbs_device *dev)
898 ++{
899 ++ complete(&dev->comp);
900 ++}
901 ++
902 + static void ib_uverbs_release_file(struct kref *ref)
903 + {
904 + struct ib_uverbs_file *file =
905 + container_of(ref, struct ib_uverbs_file, ref);
906 +
907 + module_put(file->device->ib_dev->owner);
908 +- kref_put(&file->device->ref, ib_uverbs_release_dev);
909 ++ if (atomic_dec_and_test(&file->device->refcount))
910 ++ ib_uverbs_comp_dev(file->device);
911 +
912 + kfree(file);
913 + }
914 +@@ -621,9 +631,7 @@ static int ib_uverbs_open(struct inode *inode, struct file *filp)
915 + int ret;
916 +
917 + dev = container_of(inode->i_cdev, struct ib_uverbs_device, cdev);
918 +- if (dev)
919 +- kref_get(&dev->ref);
920 +- else
921 ++ if (!atomic_inc_not_zero(&dev->refcount))
922 + return -ENXIO;
923 +
924 + if (!try_module_get(dev->ib_dev->owner)) {
925 +@@ -644,6 +652,7 @@ static int ib_uverbs_open(struct inode *inode, struct file *filp)
926 + mutex_init(&file->mutex);
927 +
928 + filp->private_data = file;
929 ++ kobject_get(&dev->kobj);
930 +
931 + return nonseekable_open(inode, filp);
932 +
933 +@@ -651,13 +660,16 @@ err_module:
934 + module_put(dev->ib_dev->owner);
935 +
936 + err:
937 +- kref_put(&dev->ref, ib_uverbs_release_dev);
938 ++ if (atomic_dec_and_test(&dev->refcount))
939 ++ ib_uverbs_comp_dev(dev);
940 ++
941 + return ret;
942 + }
943 +
944 + static int ib_uverbs_close(struct inode *inode, struct file *filp)
945 + {
946 + struct ib_uverbs_file *file = filp->private_data;
947 ++ struct ib_uverbs_device *dev = file->device;
948 +
949 + ib_uverbs_cleanup_ucontext(file, file->ucontext);
950 +
951 +@@ -665,6 +677,7 @@ static int ib_uverbs_close(struct inode *inode, struct file *filp)
952 + kref_put(&file->async_file->ref, ib_uverbs_release_event_file);
953 +
954 + kref_put(&file->ref, ib_uverbs_release_file);
955 ++ kobject_put(&dev->kobj);
956 +
957 + return 0;
958 + }
959 +@@ -760,10 +773,11 @@ static void ib_uverbs_add_one(struct ib_device *device)
960 + if (!uverbs_dev)
961 + return;
962 +
963 +- kref_init(&uverbs_dev->ref);
964 ++ atomic_set(&uverbs_dev->refcount, 1);
965 + init_completion(&uverbs_dev->comp);
966 + uverbs_dev->xrcd_tree = RB_ROOT;
967 + mutex_init(&uverbs_dev->xrcd_tree_mutex);
968 ++ kobject_init(&uverbs_dev->kobj, &ib_uverbs_dev_ktype);
969 +
970 + spin_lock(&map_lock);
971 + devnum = find_first_zero_bit(dev_map, IB_UVERBS_MAX_DEVICES);
972 +@@ -790,6 +804,7 @@ static void ib_uverbs_add_one(struct ib_device *device)
973 + cdev_init(&uverbs_dev->cdev, NULL);
974 + uverbs_dev->cdev.owner = THIS_MODULE;
975 + uverbs_dev->cdev.ops = device->mmap ? &uverbs_mmap_fops : &uverbs_fops;
976 ++ uverbs_dev->cdev.kobj.parent = &uverbs_dev->kobj;
977 + kobject_set_name(&uverbs_dev->cdev.kobj, "uverbs%d", uverbs_dev->devnum);
978 + if (cdev_add(&uverbs_dev->cdev, base, 1))
979 + goto err_cdev;
980 +@@ -820,9 +835,10 @@ err_cdev:
981 + clear_bit(devnum, overflow_map);
982 +
983 + err:
984 +- kref_put(&uverbs_dev->ref, ib_uverbs_release_dev);
985 ++ if (atomic_dec_and_test(&uverbs_dev->refcount))
986 ++ ib_uverbs_comp_dev(uverbs_dev);
987 + wait_for_completion(&uverbs_dev->comp);
988 +- kfree(uverbs_dev);
989 ++ kobject_put(&uverbs_dev->kobj);
990 + return;
991 + }
992 +
993 +@@ -842,9 +858,10 @@ static void ib_uverbs_remove_one(struct ib_device *device)
994 + else
995 + clear_bit(uverbs_dev->devnum - IB_UVERBS_MAX_DEVICES, overflow_map);
996 +
997 +- kref_put(&uverbs_dev->ref, ib_uverbs_release_dev);
998 ++ if (atomic_dec_and_test(&uverbs_dev->refcount))
999 ++ ib_uverbs_comp_dev(uverbs_dev);
1000 + wait_for_completion(&uverbs_dev->comp);
1001 +- kfree(uverbs_dev);
1002 ++ kobject_put(&uverbs_dev->kobj);
1003 + }
1004 +
1005 + static char *uverbs_devnode(struct device *dev, umode_t *mode)
1006 +diff --git a/drivers/infiniband/hw/mlx4/ah.c b/drivers/infiniband/hw/mlx4/ah.c
1007 +index a251becdaa98..890c23b3d714 100644
1008 +--- a/drivers/infiniband/hw/mlx4/ah.c
1009 ++++ b/drivers/infiniband/hw/mlx4/ah.c
1010 +@@ -169,9 +169,13 @@ int mlx4_ib_query_ah(struct ib_ah *ibah, struct ib_ah_attr *ah_attr)
1011 + enum rdma_link_layer ll;
1012 +
1013 + memset(ah_attr, 0, sizeof *ah_attr);
1014 +- ah_attr->sl = be32_to_cpu(ah->av.ib.sl_tclass_flowlabel) >> 28;
1015 + ah_attr->port_num = be32_to_cpu(ah->av.ib.port_pd) >> 24;
1016 + ll = rdma_port_get_link_layer(ibah->device, ah_attr->port_num);
1017 ++ if (ll == IB_LINK_LAYER_ETHERNET)
1018 ++ ah_attr->sl = be32_to_cpu(ah->av.eth.sl_tclass_flowlabel) >> 29;
1019 ++ else
1020 ++ ah_attr->sl = be32_to_cpu(ah->av.ib.sl_tclass_flowlabel) >> 28;
1021 ++
1022 + ah_attr->dlid = ll == IB_LINK_LAYER_INFINIBAND ? be16_to_cpu(ah->av.ib.dlid) : 0;
1023 + if (ah->av.ib.stat_rate)
1024 + ah_attr->static_rate = ah->av.ib.stat_rate - MLX4_STAT_RATE_OFFSET;
1025 +diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
1026 +index a55353c37b3d..30e6d5fa79d3 100644
1027 +--- a/drivers/iommu/amd_iommu.c
1028 ++++ b/drivers/iommu/amd_iommu.c
1029 +@@ -1931,8 +1931,8 @@ static void set_dte_entry(u16 devid, struct protection_domain *domain, bool ats)
1030 + static void clear_dte_entry(u16 devid)
1031 + {
1032 + /* remove entry from the device table seen by the hardware */
1033 +- amd_iommu_dev_table[devid].data[0] = IOMMU_PTE_P | IOMMU_PTE_TV;
1034 +- amd_iommu_dev_table[devid].data[1] = 0;
1035 ++ amd_iommu_dev_table[devid].data[0] = IOMMU_PTE_P | IOMMU_PTE_TV;
1036 ++ amd_iommu_dev_table[devid].data[1] &= DTE_FLAG_MASK;
1037 +
1038 + amd_iommu_apply_erratum_63(devid);
1039 + }
1040 +diff --git a/drivers/iommu/amd_iommu_types.h b/drivers/iommu/amd_iommu_types.h
1041 +index c4ffacb033f2..42f2090d31cc 100644
1042 +--- a/drivers/iommu/amd_iommu_types.h
1043 ++++ b/drivers/iommu/amd_iommu_types.h
1044 +@@ -277,6 +277,7 @@
1045 + #define IOMMU_PTE_IR (1ULL << 61)
1046 + #define IOMMU_PTE_IW (1ULL << 62)
1047 +
1048 ++#define DTE_FLAG_MASK (0x3ffULL << 32)
1049 + #define DTE_FLAG_IOTLB (0x01UL << 32)
1050 + #define DTE_FLAG_GV (0x01ULL << 55)
1051 + #define DTE_GLX_SHIFT (56)
1052 +diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
1053 +index 28af276cff9f..bd400f2a8d26 100644
1054 +--- a/drivers/iommu/intel-iommu.c
1055 ++++ b/drivers/iommu/intel-iommu.c
1056 +@@ -1827,13 +1827,20 @@ static int __domain_mapping(struct dmar_domain *domain, unsigned long iov_pfn,
1057 + return -ENOMEM;
1058 + /* It is large page*/
1059 + if (largepage_lvl > 1) {
1060 ++ unsigned long nr_superpages, end_pfn, lvl_pages;
1061 ++
1062 + pteval |= DMA_PTE_LARGE_PAGE;
1063 +- /* Ensure that old small page tables are removed to make room
1064 +- for superpage, if they exist. */
1065 +- dma_pte_clear_range(domain, iov_pfn,
1066 +- iov_pfn + lvl_to_nr_pages(largepage_lvl) - 1);
1067 +- dma_pte_free_pagetable(domain, iov_pfn,
1068 +- iov_pfn + lvl_to_nr_pages(largepage_lvl) - 1);
1069 ++ lvl_pages = lvl_to_nr_pages(largepage_lvl);
1070 ++
1071 ++ nr_superpages = sg_res / lvl_pages;
1072 ++ end_pfn = iov_pfn + nr_superpages * lvl_pages - 1;
1073 ++
1074 ++ /*
1075 ++ * Ensure that old small page tables are
1076 ++ * removed to make room for superpage(s).
1077 ++ */
1078 ++ dma_pte_clear_range(domain, iov_pfn, end_pfn);
1079 ++ dma_pte_free_pagetable(domain, iov_pfn, end_pfn);
1080 + } else {
1081 + pteval &= ~(uint64_t)DMA_PTE_LARGE_PAGE;
1082 + }
1083 +diff --git a/drivers/macintosh/windfarm_core.c b/drivers/macintosh/windfarm_core.c
1084 +index ce8897933a84..004fa10896fd 100644
1085 +--- a/drivers/macintosh/windfarm_core.c
1086 ++++ b/drivers/macintosh/windfarm_core.c
1087 +@@ -421,7 +421,7 @@ int wf_unregister_client(struct notifier_block *nb)
1088 + {
1089 + mutex_lock(&wf_lock);
1090 + blocking_notifier_chain_unregister(&wf_client_list, nb);
1091 +- wf_client_count++;
1092 ++ wf_client_count--;
1093 + if (wf_client_count == 0)
1094 + wf_stop_thread();
1095 + mutex_unlock(&wf_lock);
1096 +diff --git a/drivers/md/Kconfig b/drivers/md/Kconfig
1097 +index da4dc255bc54..518703048fa1 100644
1098 +--- a/drivers/md/Kconfig
1099 ++++ b/drivers/md/Kconfig
1100 +@@ -330,7 +330,7 @@ config DM_MULTIPATH
1101 + # of SCSI_DH if the latter isn't defined but if
1102 + # it is, DM_MULTIPATH must depend on it. We get a build
1103 + # error if SCSI_DH=m and DM_MULTIPATH=y
1104 +- depends on SCSI_DH || !SCSI_DH
1105 ++ depends on !SCSI_DH || SCSI
1106 + ---help---
1107 + Allow volume managers to support multipath hardware.
1108 +
1109 +diff --git a/drivers/md/md.c b/drivers/md/md.c
1110 +index a875348e819e..9085ba934df1 100644
1111 +--- a/drivers/md/md.c
1112 ++++ b/drivers/md/md.c
1113 +@@ -7954,6 +7954,7 @@ int rdev_set_badblocks(struct md_rdev *rdev, sector_t s, int sectors,
1114 + /* Make sure they get written out promptly */
1115 + sysfs_notify_dirent_safe(rdev->sysfs_state);
1116 + set_bit(MD_CHANGE_CLEAN, &rdev->mddev->flags);
1117 ++ set_bit(MD_CHANGE_PENDING, &rdev->mddev->flags);
1118 + md_wakeup_thread(rdev->mddev->thread);
1119 + }
1120 + return rv;
1121 +diff --git a/drivers/md/persistent-data/dm-btree.c b/drivers/md/persistent-data/dm-btree.c
1122 +index dddd5a47f97d..be86d59eaa90 100644
1123 +--- a/drivers/md/persistent-data/dm-btree.c
1124 ++++ b/drivers/md/persistent-data/dm-btree.c
1125 +@@ -502,7 +502,7 @@ static int btree_split_beneath(struct shadow_spine *s, uint64_t key)
1126 +
1127 + r = new_block(s->info, &right);
1128 + if (r < 0) {
1129 +- /* FIXME: put left */
1130 ++ unlock_block(s->info, left);
1131 + return r;
1132 + }
1133 +
1134 +diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c
1135 +index 06a0257e752a..1c9094de644f 100644
1136 +--- a/drivers/md/raid0.c
1137 ++++ b/drivers/md/raid0.c
1138 +@@ -88,6 +88,7 @@ static int create_strip_zones(struct mddev *mddev, struct r0conf **private_conf)
1139 + char b[BDEVNAME_SIZE];
1140 + char b2[BDEVNAME_SIZE];
1141 + struct r0conf *conf = kzalloc(sizeof(*conf), GFP_KERNEL);
1142 ++ unsigned short blksize = 512;
1143 +
1144 + if (!conf)
1145 + return -ENOMEM;
1146 +@@ -102,6 +103,9 @@ static int create_strip_zones(struct mddev *mddev, struct r0conf **private_conf)
1147 + sector_div(sectors, mddev->chunk_sectors);
1148 + rdev1->sectors = sectors * mddev->chunk_sectors;
1149 +
1150 ++ blksize = max(blksize, queue_logical_block_size(
1151 ++ rdev1->bdev->bd_disk->queue));
1152 ++
1153 + rdev_for_each(rdev2, mddev) {
1154 + pr_debug("md/raid0:%s: comparing %s(%llu)"
1155 + " with %s(%llu)\n",
1156 +@@ -138,6 +142,18 @@ static int create_strip_zones(struct mddev *mddev, struct r0conf **private_conf)
1157 + }
1158 + pr_debug("md/raid0:%s: FINAL %d zones\n",
1159 + mdname(mddev), conf->nr_strip_zones);
1160 ++ /*
1161 ++ * now since we have the hard sector sizes, we can make sure
1162 ++ * chunk size is a multiple of that sector size
1163 ++ */
1164 ++ if ((mddev->chunk_sectors << 9) % blksize) {
1165 ++ printk(KERN_ERR "md/raid0:%s: chunk_size of %d not multiple of block size %d\n",
1166 ++ mdname(mddev),
1167 ++ mddev->chunk_sectors << 9, blksize);
1168 ++ err = -EINVAL;
1169 ++ goto abort;
1170 ++ }
1171 ++
1172 + err = -ENOMEM;
1173 + conf->strip_zone = kzalloc(sizeof(struct strip_zone)*
1174 + conf->nr_strip_zones, GFP_KERNEL);
1175 +@@ -186,9 +202,6 @@ static int create_strip_zones(struct mddev *mddev, struct r0conf **private_conf)
1176 + }
1177 + dev[j] = rdev1;
1178 +
1179 +- disk_stack_limits(mddev->gendisk, rdev1->bdev,
1180 +- rdev1->data_offset << 9);
1181 +-
1182 + if (rdev1->bdev->bd_disk->queue->merge_bvec_fn)
1183 + conf->has_merge_bvec = 1;
1184 +
1185 +@@ -257,21 +270,6 @@ static int create_strip_zones(struct mddev *mddev, struct r0conf **private_conf)
1186 + mddev->queue->backing_dev_info.congested_fn = raid0_congested;
1187 + mddev->queue->backing_dev_info.congested_data = mddev;
1188 +
1189 +- /*
1190 +- * now since we have the hard sector sizes, we can make sure
1191 +- * chunk size is a multiple of that sector size
1192 +- */
1193 +- if ((mddev->chunk_sectors << 9) % queue_logical_block_size(mddev->queue)) {
1194 +- printk(KERN_ERR "md/raid0:%s: chunk_size of %d not valid\n",
1195 +- mdname(mddev),
1196 +- mddev->chunk_sectors << 9);
1197 +- goto abort;
1198 +- }
1199 +-
1200 +- blk_queue_io_min(mddev->queue, mddev->chunk_sectors << 9);
1201 +- blk_queue_io_opt(mddev->queue,
1202 +- (mddev->chunk_sectors << 9) * mddev->raid_disks);
1203 +-
1204 + pr_debug("md/raid0:%s: done.\n", mdname(mddev));
1205 + *private_conf = conf;
1206 +
1207 +@@ -432,6 +430,27 @@ static int raid0_run(struct mddev *mddev)
1208 + mddev->private = conf;
1209 + }
1210 + conf = mddev->private;
1211 ++ if (mddev->queue) {
1212 ++ struct md_rdev *rdev;
1213 ++ bool discard_supported = false;
1214 ++
1215 ++ blk_queue_max_hw_sectors(mddev->queue, mddev->chunk_sectors);
1216 ++
1217 ++ blk_queue_io_min(mddev->queue, mddev->chunk_sectors << 9);
1218 ++ blk_queue_io_opt(mddev->queue,
1219 ++ (mddev->chunk_sectors << 9) * mddev->raid_disks);
1220 ++
1221 ++ rdev_for_each(rdev, mddev) {
1222 ++ disk_stack_limits(mddev->gendisk, rdev->bdev,
1223 ++ rdev->data_offset << 9);
1224 ++ if (blk_queue_discard(bdev_get_queue(rdev->bdev)))
1225 ++ discard_supported = true;
1226 ++ }
1227 ++ if (!discard_supported)
1228 ++ queue_flag_clear_unlocked(QUEUE_FLAG_DISCARD, mddev->queue);
1229 ++ else
1230 ++ queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, mddev->queue);
1231 ++ }
1232 +
1233 + /* calculate array device size */
1234 + md_set_array_sectors(mddev, raid0_size(mddev, 0, 0));
1235 +diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
1236 +index 189eedbc3027..a548eed38937 100644
1237 +--- a/drivers/md/raid1.c
1238 ++++ b/drivers/md/raid1.c
1239 +@@ -1285,6 +1285,7 @@ static void error(struct mddev *mddev, struct md_rdev *rdev)
1240 + set_bit(Faulty, &rdev->flags);
1241 + spin_unlock_irqrestore(&conf->device_lock, flags);
1242 + set_bit(MD_CHANGE_DEVS, &mddev->flags);
1243 ++ set_bit(MD_CHANGE_PENDING, &mddev->flags);
1244 + printk(KERN_ALERT
1245 + "md/raid1:%s: Disk failure on %s, disabling device.\n"
1246 + "md/raid1:%s: Operation continuing on %d devices.\n",
1247 +@@ -2061,6 +2062,7 @@ static void handle_sync_write_finished(struct r1conf *conf, struct r1bio *r1_bio
1248 + static void handle_write_finished(struct r1conf *conf, struct r1bio *r1_bio)
1249 + {
1250 + int m;
1251 ++ bool fail = false;
1252 + for (m = 0; m < conf->raid_disks * 2 ; m++)
1253 + if (r1_bio->bios[m] == IO_MADE_GOOD) {
1254 + struct md_rdev *rdev = conf->mirrors[m].rdev;
1255 +@@ -2073,6 +2075,7 @@ static void handle_write_finished(struct r1conf *conf, struct r1bio *r1_bio)
1256 + * narrow down and record precise write
1257 + * errors.
1258 + */
1259 ++ fail = true;
1260 + if (!narrow_write_error(r1_bio, m)) {
1261 + md_error(conf->mddev,
1262 + conf->mirrors[m].rdev);
1263 +@@ -2082,9 +2085,17 @@ static void handle_write_finished(struct r1conf *conf, struct r1bio *r1_bio)
1264 + rdev_dec_pending(conf->mirrors[m].rdev,
1265 + conf->mddev);
1266 + }
1267 +- if (test_bit(R1BIO_WriteError, &r1_bio->state))
1268 +- close_write(r1_bio);
1269 +- raid_end_bio_io(r1_bio);
1270 ++ if (fail) {
1271 ++ spin_lock_irq(&conf->device_lock);
1272 ++ list_add(&r1_bio->retry_list, &conf->bio_end_io_list);
1273 ++ conf->nr_queued++;
1274 ++ spin_unlock_irq(&conf->device_lock);
1275 ++ md_wakeup_thread(conf->mddev->thread);
1276 ++ } else {
1277 ++ if (test_bit(R1BIO_WriteError, &r1_bio->state))
1278 ++ close_write(r1_bio);
1279 ++ raid_end_bio_io(r1_bio);
1280 ++ }
1281 + }
1282 +
1283 + static void handle_read_error(struct r1conf *conf, struct r1bio *r1_bio)
1284 +@@ -2187,6 +2198,29 @@ static void raid1d(struct mddev *mddev)
1285 +
1286 + md_check_recovery(mddev);
1287 +
1288 ++ if (!list_empty_careful(&conf->bio_end_io_list) &&
1289 ++ !test_bit(MD_CHANGE_PENDING, &mddev->flags)) {
1290 ++ LIST_HEAD(tmp);
1291 ++ spin_lock_irqsave(&conf->device_lock, flags);
1292 ++ if (!test_bit(MD_CHANGE_PENDING, &mddev->flags)) {
1293 ++ while (!list_empty(&conf->bio_end_io_list)) {
1294 ++ list_move(conf->bio_end_io_list.prev, &tmp);
1295 ++ conf->nr_queued--;
1296 ++ }
1297 ++ }
1298 ++ spin_unlock_irqrestore(&conf->device_lock, flags);
1299 ++ while (!list_empty(&tmp)) {
1300 ++ r1_bio = list_first_entry(&conf->bio_end_io_list,
1301 ++ struct r1bio, retry_list);
1302 ++ list_del(&r1_bio->retry_list);
1303 ++ if (mddev->degraded)
1304 ++ set_bit(R1BIO_Degraded, &r1_bio->state);
1305 ++ if (test_bit(R1BIO_WriteError, &r1_bio->state))
1306 ++ close_write(r1_bio);
1307 ++ raid_end_bio_io(r1_bio);
1308 ++ }
1309 ++ }
1310 ++
1311 + blk_start_plug(&plug);
1312 + for (;;) {
1313 +
1314 +@@ -2596,6 +2630,7 @@ static struct r1conf *setup_conf(struct mddev *mddev)
1315 + conf->raid_disks = mddev->raid_disks;
1316 + conf->mddev = mddev;
1317 + INIT_LIST_HEAD(&conf->retry_list);
1318 ++ INIT_LIST_HEAD(&conf->bio_end_io_list);
1319 +
1320 + spin_lock_init(&conf->resync_lock);
1321 + init_waitqueue_head(&conf->wait_barrier);
1322 +diff --git a/drivers/md/raid1.h b/drivers/md/raid1.h
1323 +index 80ded139314c..50086cf0eae1 100644
1324 +--- a/drivers/md/raid1.h
1325 ++++ b/drivers/md/raid1.h
1326 +@@ -48,6 +48,11 @@ struct r1conf {
1327 + * block, or anything else.
1328 + */
1329 + struct list_head retry_list;
1330 ++ /* A separate list of r1bio which just need raid_end_bio_io called.
1331 ++ * This mustn't happen for writes which had any errors if the superblock
1332 ++ * needs to be written.
1333 ++ */
1334 ++ struct list_head bio_end_io_list;
1335 +
1336 + /* queue pending writes to be submitted on unplug */
1337 + struct bio_list pending_bio_list;
1338 +diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
1339 +index 149426cd1e84..1b779805eeed 100644
1340 +--- a/drivers/md/raid10.c
1341 ++++ b/drivers/md/raid10.c
1342 +@@ -1463,6 +1463,7 @@ static void error(struct mddev *mddev, struct md_rdev *rdev)
1343 + set_bit(Blocked, &rdev->flags);
1344 + set_bit(Faulty, &rdev->flags);
1345 + set_bit(MD_CHANGE_DEVS, &mddev->flags);
1346 ++ set_bit(MD_CHANGE_PENDING, &mddev->flags);
1347 + printk(KERN_ALERT
1348 + "md/raid10:%s: Disk failure on %s, disabling device.\n"
1349 + "md/raid10:%s: Operation continuing on %d devices.\n",
1350 +@@ -2536,6 +2537,7 @@ static void handle_write_completed(struct r10conf *conf, struct r10bio *r10_bio)
1351 + }
1352 + put_buf(r10_bio);
1353 + } else {
1354 ++ bool fail = false;
1355 + for (m = 0; m < conf->copies; m++) {
1356 + int dev = r10_bio->devs[m].devnum;
1357 + struct bio *bio = r10_bio->devs[m].bio;
1358 +@@ -2548,6 +2550,7 @@ static void handle_write_completed(struct r10conf *conf, struct r10bio *r10_bio)
1359 + rdev_dec_pending(rdev, conf->mddev);
1360 + } else if (bio != NULL &&
1361 + !test_bit(BIO_UPTODATE, &bio->bi_flags)) {
1362 ++ fail = true;
1363 + if (!narrow_write_error(r10_bio, m)) {
1364 + md_error(conf->mddev, rdev);
1365 + set_bit(R10BIO_Degraded,
1366 +@@ -2565,10 +2568,17 @@ static void handle_write_completed(struct r10conf *conf, struct r10bio *r10_bio)
1367 + rdev_dec_pending(rdev, conf->mddev);
1368 + }
1369 + }
1370 +- if (test_bit(R10BIO_WriteError,
1371 +- &r10_bio->state))
1372 +- close_write(r10_bio);
1373 +- raid_end_bio_io(r10_bio);
1374 ++ if (fail) {
1375 ++ spin_lock_irq(&conf->device_lock);
1376 ++ list_add(&r10_bio->retry_list, &conf->bio_end_io_list);
1377 ++ spin_unlock_irq(&conf->device_lock);
1378 ++ md_wakeup_thread(conf->mddev->thread);
1379 ++ } else {
1380 ++ if (test_bit(R10BIO_WriteError,
1381 ++ &r10_bio->state))
1382 ++ close_write(r10_bio);
1383 ++ raid_end_bio_io(r10_bio);
1384 ++ }
1385 + }
1386 + }
1387 +
1388 +@@ -2582,6 +2592,29 @@ static void raid10d(struct mddev *mddev)
1389 +
1390 + md_check_recovery(mddev);
1391 +
1392 ++ if (!list_empty_careful(&conf->bio_end_io_list) &&
1393 ++ !test_bit(MD_CHANGE_PENDING, &mddev->flags)) {
1394 ++ LIST_HEAD(tmp);
1395 ++ spin_lock_irqsave(&conf->device_lock, flags);
1396 ++ if (!test_bit(MD_CHANGE_PENDING, &mddev->flags)) {
1397 ++ list_add(&tmp, &conf->bio_end_io_list);
1398 ++ list_del_init(&conf->bio_end_io_list);
1399 ++ }
1400 ++ spin_unlock_irqrestore(&conf->device_lock, flags);
1401 ++ while (!list_empty(&tmp)) {
1402 ++ r10_bio = list_first_entry(&conf->bio_end_io_list,
1403 ++ struct r10bio, retry_list);
1404 ++ list_del(&r10_bio->retry_list);
1405 ++ if (mddev->degraded)
1406 ++ set_bit(R10BIO_Degraded, &r10_bio->state);
1407 ++
1408 ++ if (test_bit(R10BIO_WriteError,
1409 ++ &r10_bio->state))
1410 ++ close_write(r10_bio);
1411 ++ raid_end_bio_io(r10_bio);
1412 ++ }
1413 ++ }
1414 ++
1415 + blk_start_plug(&plug);
1416 + for (;;) {
1417 +
1418 +@@ -3286,6 +3319,7 @@ static struct r10conf *setup_conf(struct mddev *mddev)
1419 +
1420 + spin_lock_init(&conf->device_lock);
1421 + INIT_LIST_HEAD(&conf->retry_list);
1422 ++ INIT_LIST_HEAD(&conf->bio_end_io_list);
1423 +
1424 + spin_lock_init(&conf->resync_lock);
1425 + init_waitqueue_head(&conf->wait_barrier);
1426 +diff --git a/drivers/md/raid10.h b/drivers/md/raid10.h
1427 +index 24d45b8af5c9..8085d90d1bef 100644
1428 +--- a/drivers/md/raid10.h
1429 ++++ b/drivers/md/raid10.h
1430 +@@ -42,6 +42,12 @@ struct r10conf {
1431 + sector_t chunk_mask;
1432 +
1433 + struct list_head retry_list;
1434 ++ /* A separate list of r1bio which just need raid_end_bio_io called.
1435 ++ * This mustn't happen for writes which had any errors if the superblock
1436 ++ * needs to be written.
1437 ++ */
1438 ++ struct list_head bio_end_io_list;
1439 ++
1440 + /* queue pending writes and submit them on unplug */
1441 + struct bio_list pending_bio_list;
1442 + int pending_count;
1443 +diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
1444 +index cec1f8c05e67..a7ff6b54793c 100644
1445 +--- a/drivers/media/rc/rc-main.c
1446 ++++ b/drivers/media/rc/rc-main.c
1447 +@@ -946,9 +946,6 @@ static int rc_dev_uevent(struct device *device, struct kobj_uevent_env *env)
1448 + {
1449 + struct rc_dev *dev = to_rc_dev(device);
1450 +
1451 +- if (!dev || !dev->input_dev)
1452 +- return -ENODEV;
1453 +-
1454 + if (dev->rc_map.name)
1455 + ADD_HOTPLUG_VAR("NAME=%s", dev->rc_map.name);
1456 + if (dev->driver_name)
1457 +diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c
1458 +index 43f1a0011a55..8f793ea1d23a 100644
1459 +--- a/drivers/mtd/ubi/io.c
1460 ++++ b/drivers/mtd/ubi/io.c
1461 +@@ -942,6 +942,11 @@ static int validate_vid_hdr(const struct ubi_device *ubi,
1462 + goto bad;
1463 + }
1464 +
1465 ++ if (data_size > ubi->leb_size) {
1466 ++ dbg_err("bad data_size");
1467 ++ goto bad;
1468 ++ }
1469 ++
1470 + if (vol_type == UBI_VID_STATIC) {
1471 + /*
1472 + * Although from high-level point of view static volumes may
1473 +diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c
1474 +index c015fc0a76d8..4105a508f215 100644
1475 +--- a/drivers/mtd/ubi/vtbl.c
1476 ++++ b/drivers/mtd/ubi/vtbl.c
1477 +@@ -656,6 +656,7 @@ static int init_volumes(struct ubi_device *ubi, const struct ubi_scan_info *si,
1478 + if (ubi->corr_peb_count)
1479 + ubi_err("%d PEBs are corrupted and not used",
1480 + ubi->corr_peb_count);
1481 ++ return -ENOSPC;
1482 + }
1483 + ubi->rsvd_pebs += reserved_pebs;
1484 + ubi->avail_pebs -= reserved_pebs;
1485 +diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c
1486 +index 284d144ff5a6..3e42cd6f7c77 100644
1487 +--- a/drivers/mtd/ubi/wl.c
1488 ++++ b/drivers/mtd/ubi/wl.c
1489 +@@ -1513,6 +1513,7 @@ int ubi_wl_init_scan(struct ubi_device *ubi, struct ubi_scan_info *si)
1490 + if (ubi->corr_peb_count)
1491 + ubi_err("%d PEBs are corrupted and not used",
1492 + ubi->corr_peb_count);
1493 ++ err = -ENOSPC;
1494 + goto out_free;
1495 + }
1496 + ubi->avail_pebs -= WL_RESERVED_PEBS;
1497 +diff --git a/drivers/net/wireless/ath/ath9k/init.c b/drivers/net/wireless/ath/ath9k/init.c
1498 +index cac5b256a1c7..37534a06b96b 100644
1499 +--- a/drivers/net/wireless/ath/ath9k/init.c
1500 ++++ b/drivers/net/wireless/ath/ath9k/init.c
1501 +@@ -683,6 +683,7 @@ void ath9k_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw)
1502 + hw->max_rate_tries = 10;
1503 + hw->sta_data_size = sizeof(struct ath_node);
1504 + hw->vif_data_size = sizeof(struct ath_vif);
1505 ++ hw->extra_tx_headroom = 4;
1506 +
1507 + hw->wiphy->available_antennas_rx = BIT(ah->caps.max_rxchains) - 1;
1508 + hw->wiphy->available_antennas_tx = BIT(ah->caps.max_txchains) - 1;
1509 +diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c
1510 +index 56f41c9409d1..6314e24c20ca 100644
1511 +--- a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c
1512 ++++ b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c
1513 +@@ -1063,7 +1063,7 @@ static void iwlagn_wowlan_program_keys(struct ieee80211_hw *hw,
1514 + u8 *pn = seq.ccmp.pn;
1515 +
1516 + ieee80211_get_key_rx_seq(key, i, &seq);
1517 +- aes_sc->pn = cpu_to_le64(
1518 ++ aes_sc[i].pn = cpu_to_le64(
1519 + (u64)pn[5] |
1520 + ((u64)pn[4] << 8) |
1521 + ((u64)pn[3] << 16) |
1522 +diff --git a/drivers/of/address.c b/drivers/of/address.c
1523 +index c059ce1dd338..f89fc0f5a6ca 100644
1524 +--- a/drivers/of/address.c
1525 ++++ b/drivers/of/address.c
1526 +@@ -604,10 +604,10 @@ struct device_node *of_find_matching_node_by_address(struct device_node *from,
1527 + struct resource res;
1528 +
1529 + while (dn) {
1530 +- if (of_address_to_resource(dn, 0, &res))
1531 +- continue;
1532 +- if (res.start == base_address)
1533 ++ if (!of_address_to_resource(dn, 0, &res) &&
1534 ++ res.start == base_address)
1535 + return dn;
1536 ++
1537 + dn = of_find_matching_node(dn, matches);
1538 + }
1539 +
1540 +diff --git a/drivers/pci/access.c b/drivers/pci/access.c
1541 +index 2a581642c237..f49d961cf54d 100644
1542 +--- a/drivers/pci/access.c
1543 ++++ b/drivers/pci/access.c
1544 +@@ -357,6 +357,56 @@ static const struct pci_vpd_ops pci_vpd_pci22_ops = {
1545 + .release = pci_vpd_pci22_release,
1546 + };
1547 +
1548 ++static ssize_t pci_vpd_f0_read(struct pci_dev *dev, loff_t pos, size_t count,
1549 ++ void *arg)
1550 ++{
1551 ++ struct pci_dev *tdev = pci_get_slot(dev->bus, PCI_SLOT(dev->devfn));
1552 ++ ssize_t ret;
1553 ++
1554 ++ if (!tdev)
1555 ++ return -ENODEV;
1556 ++
1557 ++ ret = pci_read_vpd(tdev, pos, count, arg);
1558 ++ pci_dev_put(tdev);
1559 ++ return ret;
1560 ++}
1561 ++
1562 ++static ssize_t pci_vpd_f0_write(struct pci_dev *dev, loff_t pos, size_t count,
1563 ++ const void *arg)
1564 ++{
1565 ++ struct pci_dev *tdev = pci_get_slot(dev->bus, PCI_SLOT(dev->devfn));
1566 ++ ssize_t ret;
1567 ++
1568 ++ if (!tdev)
1569 ++ return -ENODEV;
1570 ++
1571 ++ ret = pci_write_vpd(tdev, pos, count, arg);
1572 ++ pci_dev_put(tdev);
1573 ++ return ret;
1574 ++}
1575 ++
1576 ++static const struct pci_vpd_ops pci_vpd_f0_ops = {
1577 ++ .read = pci_vpd_f0_read,
1578 ++ .write = pci_vpd_f0_write,
1579 ++ .release = pci_vpd_pci22_release,
1580 ++};
1581 ++
1582 ++static int pci_vpd_f0_dev_check(struct pci_dev *dev)
1583 ++{
1584 ++ struct pci_dev *tdev = pci_get_slot(dev->bus, PCI_SLOT(dev->devfn));
1585 ++ int ret = 0;
1586 ++
1587 ++ if (!tdev)
1588 ++ return -ENODEV;
1589 ++ if (!tdev->vpd || !tdev->multifunction ||
1590 ++ dev->class != tdev->class || dev->vendor != tdev->vendor ||
1591 ++ dev->device != tdev->device)
1592 ++ ret = -ENODEV;
1593 ++
1594 ++ pci_dev_put(tdev);
1595 ++ return ret;
1596 ++}
1597 ++
1598 + int pci_vpd_pci22_init(struct pci_dev *dev)
1599 + {
1600 + struct pci_vpd_pci22 *vpd;
1601 +@@ -365,12 +415,21 @@ int pci_vpd_pci22_init(struct pci_dev *dev)
1602 + cap = pci_find_capability(dev, PCI_CAP_ID_VPD);
1603 + if (!cap)
1604 + return -ENODEV;
1605 ++ if (dev->dev_flags & PCI_DEV_FLAGS_VPD_REF_F0) {
1606 ++ int ret = pci_vpd_f0_dev_check(dev);
1607 ++
1608 ++ if (ret)
1609 ++ return ret;
1610 ++ }
1611 + vpd = kzalloc(sizeof(*vpd), GFP_ATOMIC);
1612 + if (!vpd)
1613 + return -ENOMEM;
1614 +
1615 + vpd->base.len = PCI_VPD_PCI22_SIZE;
1616 +- vpd->base.ops = &pci_vpd_pci22_ops;
1617 ++ if (dev->dev_flags & PCI_DEV_FLAGS_VPD_REF_F0)
1618 ++ vpd->base.ops = &pci_vpd_f0_ops;
1619 ++ else
1620 ++ vpd->base.ops = &pci_vpd_pci22_ops;
1621 + mutex_init(&vpd->lock);
1622 + vpd->cap = cap;
1623 + vpd->busy = false;
1624 +diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
1625 +index c0300242db86..3ce87c82f2b5 100644
1626 +--- a/drivers/pci/quirks.c
1627 ++++ b/drivers/pci/quirks.c
1628 +@@ -1883,6 +1883,15 @@ static void __devinit quirk_netmos(struct pci_dev *dev)
1629 + DECLARE_PCI_FIXUP_CLASS_HEADER(PCI_VENDOR_ID_NETMOS, PCI_ANY_ID,
1630 + PCI_CLASS_COMMUNICATION_SERIAL, 8, quirk_netmos);
1631 +
1632 ++static void quirk_f0_vpd_link(struct pci_dev *dev)
1633 ++{
1634 ++ if ((dev->class >> 8) != PCI_CLASS_NETWORK_ETHERNET ||
1635 ++ !dev->multifunction || !PCI_FUNC(dev->devfn))
1636 ++ return;
1637 ++ dev->dev_flags |= PCI_DEV_FLAGS_VPD_REF_F0;
1638 ++}
1639 ++DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, PCI_ANY_ID, quirk_f0_vpd_link);
1640 ++
1641 + static void __devinit quirk_e100_interrupt(struct pci_dev *dev)
1642 + {
1643 + u16 command, pmcsr;
1644 +@@ -2834,12 +2843,15 @@ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x3c28, vtd_mask_spec_errors);
1645 +
1646 + static void __devinit fixup_ti816x_class(struct pci_dev* dev)
1647 + {
1648 ++ u32 class = dev->class;
1649 ++
1650 + /* TI 816x devices do not have class code set when in PCIe boot mode */
1651 +- dev_info(&dev->dev, "Setting PCI class for 816x PCIe device\n");
1652 +- dev->class = PCI_CLASS_MULTIMEDIA_VIDEO;
1653 ++ dev->class = PCI_CLASS_MULTIMEDIA_VIDEO << 8;
1654 ++ dev_info(&dev->dev, "PCI class overridden (%#08x -> %#08x)\n",
1655 ++ class, dev->class);
1656 + }
1657 + DECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_TI, 0xb800,
1658 +- PCI_CLASS_NOT_DEFINED, 0, fixup_ti816x_class);
1659 ++ PCI_CLASS_NOT_DEFINED, 0, fixup_ti816x_class);
1660 +
1661 + /* Some PCIe devices do not work reliably with the claimed maximum
1662 + * payload size supported.
1663 +diff --git a/drivers/scsi/mvsas/mv_sas.c b/drivers/scsi/mvsas/mv_sas.c
1664 +index dbb8edfc8baa..06da698daebe 100644
1665 +--- a/drivers/scsi/mvsas/mv_sas.c
1666 ++++ b/drivers/scsi/mvsas/mv_sas.c
1667 +@@ -984,6 +984,8 @@ static void mvs_slot_free(struct mvs_info *mvi, u32 rx_desc)
1668 + static void mvs_slot_task_free(struct mvs_info *mvi, struct sas_task *task,
1669 + struct mvs_slot_info *slot, u32 slot_idx)
1670 + {
1671 ++ if (!slot)
1672 ++ return;
1673 + if (!slot->task)
1674 + return;
1675 + if (!sas_protocol_ata(task->task_proto))
1676 +diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c
1677 +index dc25bee8d33f..2ecc2d6464fb 100644
1678 +--- a/drivers/spi/spi-pxa2xx.c
1679 ++++ b/drivers/spi/spi-pxa2xx.c
1680 +@@ -799,6 +799,10 @@ static irqreturn_t ssp_int(int irq, void *dev_id)
1681 + if (!(sccr1_reg & SSCR1_TIE))
1682 + mask &= ~SSSR_TFS;
1683 +
1684 ++ /* Ignore RX timeout interrupt if it is disabled */
1685 ++ if (!(sccr1_reg & SSCR1_TINTE))
1686 ++ mask &= ~SSSR_TINT;
1687 ++
1688 + if (!(status & mask))
1689 + return IRQ_NONE;
1690 +
1691 +diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
1692 +index 3d8f662e4fe9..a3f31e9ab214 100644
1693 +--- a/drivers/spi/spi.c
1694 ++++ b/drivers/spi/spi.c
1695 +@@ -831,8 +831,7 @@ static struct class spi_master_class = {
1696 + *
1697 + * The caller is responsible for assigning the bus number and initializing
1698 + * the master's methods before calling spi_register_master(); and (after errors
1699 +- * adding the device) calling spi_master_put() and kfree() to prevent a memory
1700 +- * leak.
1701 ++ * adding the device) calling spi_master_put() to prevent a memory leak.
1702 + */
1703 + struct spi_master *spi_alloc_master(struct device *dev, unsigned size)
1704 + {
1705 +diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
1706 +index fa0376b38019..fc8822fccac1 100644
1707 +--- a/drivers/tty/n_tty.c
1708 ++++ b/drivers/tty/n_tty.c
1709 +@@ -1297,8 +1297,7 @@ handle_newline:
1710 + tty->canon_data++;
1711 + spin_unlock_irqrestore(&tty->read_lock, flags);
1712 + kill_fasync(&tty->fasync, SIGIO, POLL_IN);
1713 +- if (waitqueue_active(&tty->read_wait))
1714 +- wake_up_interruptible(&tty->read_wait);
1715 ++ wake_up_interruptible(&tty->read_wait);
1716 + return;
1717 + }
1718 + }
1719 +@@ -1421,8 +1420,7 @@ static void n_tty_receive_buf(struct tty_struct *tty, const unsigned char *cp,
1720 + if ((!tty->icanon && (tty->read_cnt >= tty->minimum_to_wake)) ||
1721 + L_EXTPROC(tty)) {
1722 + kill_fasync(&tty->fasync, SIGIO, POLL_IN);
1723 +- if (waitqueue_active(&tty->read_wait))
1724 +- wake_up_interruptible(&tty->read_wait);
1725 ++ wake_up_interruptible(&tty->read_wait);
1726 + }
1727 +
1728 + /*
1729 +diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
1730 +index 5f0b4a445b97..3ea41502a7bc 100644
1731 +--- a/drivers/tty/tty_io.c
1732 ++++ b/drivers/tty/tty_io.c
1733 +@@ -2018,8 +2018,24 @@ retry_open:
1734 + if (!noctty &&
1735 + current->signal->leader &&
1736 + !current->signal->tty &&
1737 +- tty->session == NULL)
1738 +- __proc_set_tty(current, tty);
1739 ++ tty->session == NULL) {
1740 ++ /*
1741 ++ * Don't let a process that only has write access to the tty
1742 ++ * obtain the privileges associated with having a tty as
1743 ++ * controlling terminal (being able to reopen it with full
1744 ++ * access through /dev/tty, being able to perform pushback).
1745 ++ * Many distributions set the group of all ttys to "tty" and
1746 ++ * grant write-only access to all terminals for setgid tty
1747 ++ * binaries, which should not imply full privileges on all ttys.
1748 ++ *
1749 ++ * This could theoretically break old code that performs open()
1750 ++ * on a write-only file descriptor. In that case, it might be
1751 ++ * necessary to also permit this if
1752 ++ * inode_permission(inode, MAY_READ) == 0.
1753 ++ */
1754 ++ if (filp->f_mode & FMODE_READ)
1755 ++ __proc_set_tty(current, tty);
1756 ++ }
1757 + spin_unlock_irq(&current->sighand->siglock);
1758 + tty_unlock();
1759 + mutex_unlock(&tty_mutex);
1760 +@@ -2308,7 +2324,7 @@ static int fionbio(struct file *file, int __user *p)
1761 + * Takes ->siglock() when updating signal->tty
1762 + */
1763 +
1764 +-static int tiocsctty(struct tty_struct *tty, int arg)
1765 ++static int tiocsctty(struct tty_struct *tty, struct file *file, int arg)
1766 + {
1767 + int ret = 0;
1768 + if (current->signal->leader && (task_session(current) == tty->session))
1769 +@@ -2341,6 +2357,13 @@ static int tiocsctty(struct tty_struct *tty, int arg)
1770 + goto unlock;
1771 + }
1772 + }
1773 ++
1774 ++ /* See the comment in tty_open(). */
1775 ++ if ((file->f_mode & FMODE_READ) == 0 && !capable(CAP_SYS_ADMIN)) {
1776 ++ ret = -EPERM;
1777 ++ goto unlock;
1778 ++ }
1779 ++
1780 + proc_set_tty(current, tty);
1781 + unlock:
1782 + mutex_unlock(&tty_mutex);
1783 +@@ -2695,7 +2718,7 @@ long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
1784 + no_tty();
1785 + return 0;
1786 + case TIOCSCTTY:
1787 +- return tiocsctty(tty, arg);
1788 ++ return tiocsctty(tty, file, arg);
1789 + case TIOCGPGRP:
1790 + return tiocgpgrp(tty, real_tty, p);
1791 + case TIOCSPGRP:
1792 +diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
1793 +index cc1004a2f9cd..bfc9b69122d0 100644
1794 +--- a/drivers/usb/core/config.c
1795 ++++ b/drivers/usb/core/config.c
1796 +@@ -114,16 +114,18 @@ static void usb_parse_ss_endpoint_companion(struct device *ddev, int cfgno,
1797 + cfgno, inum, asnum, ep->desc.bEndpointAddress);
1798 + ep->ss_ep_comp.bmAttributes = 16;
1799 + } else if (usb_endpoint_xfer_isoc(&ep->desc) &&
1800 +- desc->bmAttributes > 2) {
1801 ++ USB_SS_MULT(desc->bmAttributes) > 3) {
1802 + dev_warn(ddev, "Isoc endpoint has Mult of %d in "
1803 + "config %d interface %d altsetting %d ep %d: "
1804 +- "setting to 3\n", desc->bmAttributes + 1,
1805 ++ "setting to 3\n",
1806 ++ USB_SS_MULT(desc->bmAttributes),
1807 + cfgno, inum, asnum, ep->desc.bEndpointAddress);
1808 + ep->ss_ep_comp.bmAttributes = 2;
1809 + }
1810 +
1811 + if (usb_endpoint_xfer_isoc(&ep->desc))
1812 +- max_tx = (desc->bMaxBurst + 1) * (desc->bmAttributes + 1) *
1813 ++ max_tx = (desc->bMaxBurst + 1) *
1814 ++ (USB_SS_MULT(desc->bmAttributes)) *
1815 + usb_endpoint_maxp(&ep->desc);
1816 + else if (usb_endpoint_xfer_int(&ep->desc))
1817 + max_tx = usb_endpoint_maxp(&ep->desc) *
1818 +diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
1819 +index 9fac46d41f4d..fd8e60ee7df2 100644
1820 +--- a/drivers/usb/core/quirks.c
1821 ++++ b/drivers/usb/core/quirks.c
1822 +@@ -49,6 +49,13 @@ static const struct usb_device_id usb_quirk_list[] = {
1823 + /* Microsoft LifeCam-VX700 v2.0 */
1824 + { USB_DEVICE(0x045e, 0x0770), .driver_info = USB_QUIRK_RESET_RESUME },
1825 +
1826 ++ /* Logitech ConferenceCam CC3000e */
1827 ++ { USB_DEVICE(0x046d, 0x0847), .driver_info = USB_QUIRK_DELAY_INIT },
1828 ++ { USB_DEVICE(0x046d, 0x0848), .driver_info = USB_QUIRK_DELAY_INIT },
1829 ++
1830 ++ /* Logitech PTZ Pro Camera */
1831 ++ { USB_DEVICE(0x046d, 0x0853), .driver_info = USB_QUIRK_DELAY_INIT },
1832 ++
1833 + /* Logitech Quickcam Fusion */
1834 + { USB_DEVICE(0x046d, 0x08c1), .driver_info = USB_QUIRK_RESET_RESUME },
1835 +
1836 +@@ -73,6 +80,12 @@ static const struct usb_device_id usb_quirk_list[] = {
1837 + /* Philips PSC805 audio device */
1838 + { USB_DEVICE(0x0471, 0x0155), .driver_info = USB_QUIRK_RESET_RESUME },
1839 +
1840 ++ /* Plantronic Audio 655 DSP */
1841 ++ { USB_DEVICE(0x047f, 0xc008), .driver_info = USB_QUIRK_RESET_RESUME },
1842 ++
1843 ++ /* Plantronic Audio 648 USB */
1844 ++ { USB_DEVICE(0x047f, 0xc013), .driver_info = USB_QUIRK_RESET_RESUME },
1845 ++
1846 + /* Artisman Watchdog Dongle */
1847 + { USB_DEVICE(0x04b4, 0x0526), .driver_info =
1848 + USB_QUIRK_CONFIG_INTF_STRINGS },
1849 +diff --git a/drivers/usb/host/ehci-sysfs.c b/drivers/usb/host/ehci-sysfs.c
1850 +index 14ced00ba220..0659024290af 100644
1851 +--- a/drivers/usb/host/ehci-sysfs.c
1852 ++++ b/drivers/usb/host/ehci-sysfs.c
1853 +@@ -29,7 +29,7 @@ static ssize_t show_companion(struct device *dev,
1854 + int count = PAGE_SIZE;
1855 + char *ptr = buf;
1856 +
1857 +- ehci = hcd_to_ehci(bus_to_hcd(dev_get_drvdata(dev)));
1858 ++ ehci = hcd_to_ehci(dev_get_drvdata(dev));
1859 + nports = HCS_N_PORTS(ehci->hcs_params);
1860 +
1861 + for (index = 0; index < nports; ++index) {
1862 +@@ -54,7 +54,7 @@ static ssize_t store_companion(struct device *dev,
1863 + struct ehci_hcd *ehci;
1864 + int portnum, new_owner;
1865 +
1866 +- ehci = hcd_to_ehci(bus_to_hcd(dev_get_drvdata(dev)));
1867 ++ ehci = hcd_to_ehci(dev_get_drvdata(dev));
1868 + new_owner = PORT_OWNER; /* Owned by companion */
1869 + if (sscanf(buf, "%d", &portnum) != 1)
1870 + return -EINVAL;
1871 +@@ -85,7 +85,7 @@ static ssize_t show_uframe_periodic_max(struct device *dev,
1872 + struct ehci_hcd *ehci;
1873 + int n;
1874 +
1875 +- ehci = hcd_to_ehci(bus_to_hcd(dev_get_drvdata(dev)));
1876 ++ ehci = hcd_to_ehci(dev_get_drvdata(dev));
1877 + n = scnprintf(buf, PAGE_SIZE, "%d\n", ehci->uframe_periodic_max);
1878 + return n;
1879 + }
1880 +@@ -102,7 +102,7 @@ static ssize_t store_uframe_periodic_max(struct device *dev,
1881 + unsigned long flags;
1882 + ssize_t ret;
1883 +
1884 +- ehci = hcd_to_ehci(bus_to_hcd(dev_get_drvdata(dev)));
1885 ++ ehci = hcd_to_ehci(dev_get_drvdata(dev));
1886 + if (kstrtouint(buf, 0, &uframe_periodic_max) < 0)
1887 + return -EINVAL;
1888 +
1889 +diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
1890 +index 048cc382a7a9..cad4a174e3ed 100644
1891 +--- a/drivers/usb/host/xhci-mem.c
1892 ++++ b/drivers/usb/host/xhci-mem.c
1893 +@@ -1493,10 +1493,10 @@ int xhci_endpoint_init(struct xhci_hcd *xhci,
1894 + * use Event Data TRBs, and we don't chain in a link TRB on short
1895 + * transfers, we're basically dividing by 1.
1896 + *
1897 +- * xHCI 1.0 specification indicates that the Average TRB Length should
1898 +- * be set to 8 for control endpoints.
1899 ++ * xHCI 1.0 and 1.1 specification indicates that the Average TRB Length
1900 ++ * should be set to 8 for control endpoints.
1901 + */
1902 +- if (usb_endpoint_xfer_control(&ep->desc) && xhci->hci_version == 0x100)
1903 ++ if (usb_endpoint_xfer_control(&ep->desc) && xhci->hci_version >= 0x100)
1904 + ep_ctx->tx_info |= cpu_to_le32(AVG_TRB_LENGTH_FOR_EP(8));
1905 + else
1906 + ep_ctx->tx_info |=
1907 +diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
1908 +index 710b2e98b846..3053933732a1 100644
1909 +--- a/drivers/usb/host/xhci-pci.c
1910 ++++ b/drivers/usb/host/xhci-pci.c
1911 +@@ -121,6 +121,7 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
1912 + * PPT chipsets.
1913 + */
1914 + xhci->quirks |= XHCI_SPURIOUS_REBOOT;
1915 ++ xhci->quirks |= XHCI_SPURIOUS_WAKEUP;
1916 + }
1917 + if (pdev->vendor == PCI_VENDOR_ID_INTEL &&
1918 + (pdev->device == PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_XHCI ||
1919 +diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
1920 +index 5623785a300c..f38932857ffa 100644
1921 +--- a/drivers/usb/host/xhci-ring.c
1922 ++++ b/drivers/usb/host/xhci-ring.c
1923 +@@ -331,6 +331,15 @@ static int xhci_abort_cmd_ring(struct xhci_hcd *xhci)
1924 + ret = handshake(xhci, &xhci->op_regs->cmd_ring,
1925 + CMD_RING_RUNNING, 0, 5 * 1000 * 1000);
1926 + if (ret < 0) {
1927 ++ /* we are about to kill xhci, give it one more chance */
1928 ++ xhci_write_64(xhci, temp_64 | CMD_RING_ABORT,
1929 ++ &xhci->op_regs->cmd_ring);
1930 ++ udelay(1000);
1931 ++ ret = handshake(xhci, &xhci->op_regs->cmd_ring,
1932 ++ CMD_RING_RUNNING, 0, 3 * 1000 * 1000);
1933 ++ if (ret == 0)
1934 ++ return 0;
1935 ++
1936 + xhci_err(xhci, "Stopped the command ring failed, "
1937 + "maybe the host is dead\n");
1938 + xhci->xhc_state |= XHCI_STATE_DYING;
1939 +@@ -2331,6 +2340,7 @@ static int handle_tx_event(struct xhci_hcd *xhci,
1940 + u32 trb_comp_code;
1941 + int ret = 0;
1942 + int td_num = 0;
1943 ++ bool handling_skipped_tds = false;
1944 +
1945 + slot_id = TRB_TO_SLOT_ID(le32_to_cpu(event->flags));
1946 + xdev = xhci->devs[slot_id];
1947 +@@ -2464,6 +2474,10 @@ static int handle_tx_event(struct xhci_hcd *xhci,
1948 + ep->skip = true;
1949 + xhci_dbg(xhci, "Miss service interval error, set skip flag\n");
1950 + goto cleanup;
1951 ++ case COMP_PING_ERR:
1952 ++ ep->skip = true;
1953 ++ xhci_dbg(xhci, "No Ping response error, Skip one Isoc TD\n");
1954 ++ goto cleanup;
1955 + default:
1956 + if (xhci_is_vendor_info_code(xhci, trb_comp_code)) {
1957 + status = 0;
1958 +@@ -2595,13 +2609,18 @@ static int handle_tx_event(struct xhci_hcd *xhci,
1959 + ep, &status);
1960 +
1961 + cleanup:
1962 ++
1963 ++
1964 ++ handling_skipped_tds = ep->skip &&
1965 ++ trb_comp_code != COMP_MISSED_INT &&
1966 ++ trb_comp_code != COMP_PING_ERR;
1967 ++
1968 + /*
1969 +- * Do not update event ring dequeue pointer if ep->skip is set.
1970 +- * Will roll back to continue process missed tds.
1971 ++ * Do not update event ring dequeue pointer if we're in a loop
1972 ++ * processing missed tds.
1973 + */
1974 +- if (trb_comp_code == COMP_MISSED_INT || !ep->skip) {
1975 ++ if (!handling_skipped_tds)
1976 + inc_deq(xhci, xhci->event_ring);
1977 +- }
1978 +
1979 + if (ret) {
1980 + urb = td->urb;
1981 +@@ -2636,7 +2655,7 @@ cleanup:
1982 + * Process them as short transfer until reach the td pointed by
1983 + * the event.
1984 + */
1985 +- } while (ep->skip && trb_comp_code != COMP_MISSED_INT);
1986 ++ } while (handling_skipped_tds);
1987 +
1988 + return 0;
1989 + }
1990 +@@ -3487,8 +3506,8 @@ int xhci_queue_ctrl_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
1991 + if (start_cycle == 0)
1992 + field |= 0x1;
1993 +
1994 +- /* xHCI 1.0 6.4.1.2.1: Transfer Type field */
1995 +- if (xhci->hci_version == 0x100) {
1996 ++ /* xHCI 1.0/1.1 6.4.1.2.1: Transfer Type field */
1997 ++ if (xhci->hci_version >= 0x100) {
1998 + if (urb->transfer_buffer_length > 0) {
1999 + if (setup->bRequestType & USB_DIR_IN)
2000 + field |= TRB_TX_TYPE(TRB_DATA_IN);
2001 +diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
2002 +index fd52e1efd6ca..88be7a51df52 100644
2003 +--- a/drivers/usb/host/xhci.c
2004 ++++ b/drivers/usb/host/xhci.c
2005 +@@ -141,7 +141,8 @@ static int xhci_start(struct xhci_hcd *xhci)
2006 + "waited %u microseconds.\n",
2007 + XHCI_MAX_HALT_USEC);
2008 + if (!ret)
2009 +- xhci->xhc_state &= ~XHCI_STATE_HALTED;
2010 ++ xhci->xhc_state &= ~(XHCI_STATE_HALTED | XHCI_STATE_DYING);
2011 ++
2012 + return ret;
2013 + }
2014 +
2015 +diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
2016 +index 1e4899c2d5f1..4038789d61c0 100644
2017 +--- a/drivers/usb/serial/ftdi_sio.c
2018 ++++ b/drivers/usb/serial/ftdi_sio.c
2019 +@@ -629,6 +629,10 @@ static struct usb_device_id id_table_combined [] = {
2020 + { USB_DEVICE(FTDI_VID, FTDI_NT_ORIONLXM_PID),
2021 + .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
2022 + { USB_DEVICE(FTDI_VID, FTDI_SYNAPSE_SS200_PID) },
2023 ++ { USB_DEVICE(FTDI_VID, FTDI_CUSTOMWARE_MINIPLEX_PID) },
2024 ++ { USB_DEVICE(FTDI_VID, FTDI_CUSTOMWARE_MINIPLEX2_PID) },
2025 ++ { USB_DEVICE(FTDI_VID, FTDI_CUSTOMWARE_MINIPLEX2WI_PID) },
2026 ++ { USB_DEVICE(FTDI_VID, FTDI_CUSTOMWARE_MINIPLEX3_PID) },
2027 + /*
2028 + * ELV devices:
2029 + */
2030 +diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h
2031 +index 1fee973f100a..70b24c02b90d 100644
2032 +--- a/drivers/usb/serial/ftdi_sio_ids.h
2033 ++++ b/drivers/usb/serial/ftdi_sio_ids.h
2034 +@@ -568,6 +568,14 @@
2035 + */
2036 + #define FTDI_SYNAPSE_SS200_PID 0x9090 /* SS200 - SNAP Stick 200 */
2037 +
2038 ++/*
2039 ++ * CustomWare / ShipModul NMEA multiplexers product ids (FTDI_VID)
2040 ++ */
2041 ++#define FTDI_CUSTOMWARE_MINIPLEX_PID 0xfd48 /* MiniPlex first generation NMEA Multiplexer */
2042 ++#define FTDI_CUSTOMWARE_MINIPLEX2_PID 0xfd49 /* MiniPlex-USB and MiniPlex-2 series */
2043 ++#define FTDI_CUSTOMWARE_MINIPLEX2WI_PID 0xfd4a /* MiniPlex-2Wi */
2044 ++#define FTDI_CUSTOMWARE_MINIPLEX3_PID 0xfd4b /* MiniPlex-3 series */
2045 ++
2046 +
2047 + /********************************/
2048 + /** third-party VID/PID combos **/
2049 +diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
2050 +index 9e51325828bc..575c1902d38d 100644
2051 +--- a/fs/btrfs/inode.c
2052 ++++ b/fs/btrfs/inode.c
2053 +@@ -3685,7 +3685,8 @@ void btrfs_evict_inode(struct inode *inode)
2054 + goto no_delete;
2055 + }
2056 + /* do we really want it for ->i_nlink > 0 and zero btrfs_root_refs? */
2057 +- btrfs_wait_ordered_range(inode, 0, (u64)-1);
2058 ++ if (!special_file(inode->i_mode))
2059 ++ btrfs_wait_ordered_range(inode, 0, (u64)-1);
2060 +
2061 + if (root->fs_info->log_root_recovering) {
2062 + BUG_ON(!list_empty(&BTRFS_I(inode)->i_orphan));
2063 +diff --git a/fs/ceph/super.c b/fs/ceph/super.c
2064 +index f4fa5cf0cdf1..e5eacd9dd532 100644
2065 +--- a/fs/ceph/super.c
2066 ++++ b/fs/ceph/super.c
2067 +@@ -383,8 +383,10 @@ static int ceph_show_options(struct seq_file *m, struct dentry *root)
2068 + if (opt->flags & CEPH_OPT_NOCRC)
2069 + seq_puts(m, ",nocrc");
2070 +
2071 +- if (opt->name)
2072 +- seq_printf(m, ",name=%s", opt->name);
2073 ++ if (opt->name) {
2074 ++ seq_puts(m, ",name=");
2075 ++ seq_escape(m, opt->name, ", \t\n\\");
2076 ++ }
2077 + if (opt->key)
2078 + seq_puts(m, ",secret=<hidden>");
2079 +
2080 +@@ -429,7 +431,7 @@ static int ceph_show_options(struct seq_file *m, struct dentry *root)
2081 + if (fsopt->max_readdir_bytes != CEPH_MAX_READDIR_BYTES_DEFAULT)
2082 + seq_printf(m, ",readdir_max_bytes=%d", fsopt->max_readdir_bytes);
2083 + if (strcmp(fsopt->snapdir_name, CEPH_SNAPDIRNAME_DEFAULT))
2084 +- seq_printf(m, ",snapdirname=%s", fsopt->snapdir_name);
2085 ++ seq_show_option(m, "snapdirname", fsopt->snapdir_name);
2086 + return 0;
2087 + }
2088 +
2089 +diff --git a/fs/cifs/cifsencrypt.c b/fs/cifs/cifsencrypt.c
2090 +index 6dd3b61ea575..8431216eeb3c 100644
2091 +--- a/fs/cifs/cifsencrypt.c
2092 ++++ b/fs/cifs/cifsencrypt.c
2093 +@@ -388,6 +388,48 @@ find_domain_name(struct cifs_ses *ses, const struct nls_table *nls_cp)
2094 + return 0;
2095 + }
2096 +
2097 ++/* Server has provided av pairs/target info in the type 2 challenge
2098 ++ * packet and we have plucked it and stored within smb session.
2099 ++ * We parse that blob here to find the server given timestamp
2100 ++ * as part of ntlmv2 authentication (or local current time as
2101 ++ * default in case of failure)
2102 ++ */
2103 ++static __le64
2104 ++find_timestamp(struct cifs_ses *ses)
2105 ++{
2106 ++ unsigned int attrsize;
2107 ++ unsigned int type;
2108 ++ unsigned int onesize = sizeof(struct ntlmssp2_name);
2109 ++ unsigned char *blobptr;
2110 ++ unsigned char *blobend;
2111 ++ struct ntlmssp2_name *attrptr;
2112 ++
2113 ++ if (!ses->auth_key.len || !ses->auth_key.response)
2114 ++ return 0;
2115 ++
2116 ++ blobptr = ses->auth_key.response;
2117 ++ blobend = blobptr + ses->auth_key.len;
2118 ++
2119 ++ while (blobptr + onesize < blobend) {
2120 ++ attrptr = (struct ntlmssp2_name *) blobptr;
2121 ++ type = le16_to_cpu(attrptr->type);
2122 ++ if (type == NTLMSSP_AV_EOL)
2123 ++ break;
2124 ++ blobptr += 2; /* advance attr type */
2125 ++ attrsize = le16_to_cpu(attrptr->length);
2126 ++ blobptr += 2; /* advance attr size */
2127 ++ if (blobptr + attrsize > blobend)
2128 ++ break;
2129 ++ if (type == NTLMSSP_AV_TIMESTAMP) {
2130 ++ if (attrsize == sizeof(u64))
2131 ++ return *((__le64 *)blobptr);
2132 ++ }
2133 ++ blobptr += attrsize; /* advance attr value */
2134 ++ }
2135 ++
2136 ++ return cpu_to_le64(cifs_UnixTimeToNT(CURRENT_TIME));
2137 ++}
2138 ++
2139 + static int calc_ntlmv2_hash(struct cifs_ses *ses, char *ntlmv2_hash,
2140 + const struct nls_table *nls_cp)
2141 + {
2142 +@@ -549,6 +591,7 @@ setup_ntlmv2_rsp(struct cifs_ses *ses, const struct nls_table *nls_cp)
2143 + struct ntlmv2_resp *buf;
2144 + char ntlmv2_hash[16];
2145 + unsigned char *tiblob = NULL; /* target info blob */
2146 ++ __le64 rsp_timestamp;
2147 +
2148 + if (ses->server->secType == RawNTLMSSP) {
2149 + if (!ses->domainName) {
2150 +@@ -566,6 +609,12 @@ setup_ntlmv2_rsp(struct cifs_ses *ses, const struct nls_table *nls_cp)
2151 + }
2152 + }
2153 +
2154 ++ /* Must be within 5 minutes of the server (or in range +/-2h
2155 ++ * in case of Mac OS X), so simply carry over server timestamp
2156 ++ * (as Windows 7 does)
2157 ++ */
2158 ++ rsp_timestamp = find_timestamp(ses);
2159 ++
2160 + baselen = CIFS_SESS_KEY_SIZE + sizeof(struct ntlmv2_resp);
2161 + tilen = ses->auth_key.len;
2162 + tiblob = ses->auth_key.response;
2163 +@@ -583,7 +632,7 @@ setup_ntlmv2_rsp(struct cifs_ses *ses, const struct nls_table *nls_cp)
2164 + (ses->auth_key.response + CIFS_SESS_KEY_SIZE);
2165 + buf->blob_signature = cpu_to_le32(0x00000101);
2166 + buf->reserved = 0;
2167 +- buf->time = cpu_to_le64(cifs_UnixTimeToNT(CURRENT_TIME));
2168 ++ buf->time = rsp_timestamp;
2169 + get_random_bytes(&buf->client_chal, sizeof(buf->client_chal));
2170 + buf->reserved2 = 0;
2171 +
2172 +diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
2173 +index c0f65e84873e..5b730ba78ae3 100644
2174 +--- a/fs/cifs/cifsfs.c
2175 ++++ b/fs/cifs/cifsfs.c
2176 +@@ -373,10 +373,10 @@ cifs_show_options(struct seq_file *s, struct dentry *root)
2177 + if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MULTIUSER)
2178 + seq_printf(s, ",multiuser");
2179 + else if (tcon->ses->user_name)
2180 +- seq_printf(s, ",username=%s", tcon->ses->user_name);
2181 ++ seq_show_option(s, "username", tcon->ses->user_name);
2182 +
2183 + if (tcon->ses->domainName)
2184 +- seq_printf(s, ",domain=%s", tcon->ses->domainName);
2185 ++ seq_show_option(s, "domain", tcon->ses->domainName);
2186 +
2187 + if (srcaddr->sa_family != AF_UNSPEC) {
2188 + struct sockaddr_in *saddr4;
2189 +diff --git a/fs/ecryptfs/dentry.c b/fs/ecryptfs/dentry.c
2190 +index 534c1d46e69e..eba8f1d4ad33 100644
2191 +--- a/fs/ecryptfs/dentry.c
2192 ++++ b/fs/ecryptfs/dentry.c
2193 +@@ -55,26 +55,26 @@ static int ecryptfs_d_revalidate(struct dentry *dentry, struct nameidata *nd)
2194 +
2195 + lower_dentry = ecryptfs_dentry_to_lower(dentry);
2196 + lower_mnt = ecryptfs_dentry_to_lower_mnt(dentry);
2197 +- if (!lower_dentry->d_op || !lower_dentry->d_op->d_revalidate)
2198 +- goto out;
2199 +- if (nd) {
2200 +- dentry_save = nd->path.dentry;
2201 +- vfsmount_save = nd->path.mnt;
2202 +- nd->path.dentry = lower_dentry;
2203 +- nd->path.mnt = lower_mnt;
2204 +- }
2205 +- rc = lower_dentry->d_op->d_revalidate(lower_dentry, nd);
2206 +- if (nd) {
2207 +- nd->path.dentry = dentry_save;
2208 +- nd->path.mnt = vfsmount_save;
2209 ++ if (lower_dentry->d_op && lower_dentry->d_op->d_revalidate) {
2210 ++ if (nd) {
2211 ++ dentry_save = nd->path.dentry;
2212 ++ vfsmount_save = nd->path.mnt;
2213 ++ nd->path.dentry = lower_dentry;
2214 ++ nd->path.mnt = lower_mnt;
2215 ++ }
2216 ++ rc = lower_dentry->d_op->d_revalidate(lower_dentry, nd);
2217 ++ if (nd) {
2218 ++ nd->path.dentry = dentry_save;
2219 ++ nd->path.mnt = vfsmount_save;
2220 ++ }
2221 + }
2222 + if (dentry->d_inode) {
2223 +- struct inode *lower_inode =
2224 +- ecryptfs_inode_to_lower(dentry->d_inode);
2225 ++ struct inode *inode = dentry->d_inode;
2226 +
2227 +- fsstack_copy_attr_all(dentry->d_inode, lower_inode);
2228 ++ fsstack_copy_attr_all(inode, ecryptfs_inode_to_lower(inode));
2229 ++ if (!inode->i_nlink)
2230 ++ return 0;
2231 + }
2232 +-out:
2233 + return rc;
2234 + }
2235 +
2236 +diff --git a/fs/ext4/super.c b/fs/ext4/super.c
2237 +index 2e26a542c818..3de888c3894a 100644
2238 +--- a/fs/ext4/super.c
2239 ++++ b/fs/ext4/super.c
2240 +@@ -1682,10 +1682,10 @@ static inline void ext4_show_quota_options(struct seq_file *seq,
2241 + }
2242 +
2243 + if (sbi->s_qf_names[USRQUOTA])
2244 +- seq_printf(seq, ",usrjquota=%s", sbi->s_qf_names[USRQUOTA]);
2245 ++ seq_show_option(seq, "usrjquota", sbi->s_qf_names[USRQUOTA]);
2246 +
2247 + if (sbi->s_qf_names[GRPQUOTA])
2248 +- seq_printf(seq, ",grpjquota=%s", sbi->s_qf_names[GRPQUOTA]);
2249 ++ seq_show_option(seq, "grpjquota", sbi->s_qf_names[GRPQUOTA]);
2250 +
2251 + if (test_opt(sb, USRQUOTA))
2252 + seq_puts(seq, ",usrquota");
2253 +diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c
2254 +index 6172fa77ad59..4db9a9a31f29 100644
2255 +--- a/fs/gfs2/super.c
2256 ++++ b/fs/gfs2/super.c
2257 +@@ -1298,11 +1298,11 @@ static int gfs2_show_options(struct seq_file *s, struct dentry *root)
2258 + if (is_ancestor(root, sdp->sd_master_dir))
2259 + seq_printf(s, ",meta");
2260 + if (args->ar_lockproto[0])
2261 +- seq_printf(s, ",lockproto=%s", args->ar_lockproto);
2262 ++ seq_show_option(s, "lockproto", args->ar_lockproto);
2263 + if (args->ar_locktable[0])
2264 +- seq_printf(s, ",locktable=%s", args->ar_locktable);
2265 ++ seq_show_option(s, "locktable", args->ar_locktable);
2266 + if (args->ar_hostdata[0])
2267 +- seq_printf(s, ",hostdata=%s", args->ar_hostdata);
2268 ++ seq_show_option(s, "hostdata", args->ar_hostdata);
2269 + if (args->ar_spectator)
2270 + seq_printf(s, ",spectator");
2271 + if (args->ar_localflocks)
2272 +diff --git a/fs/hfs/bnode.c b/fs/hfs/bnode.c
2273 +index cdb41a1f6a64..8daea16ef544 100644
2274 +--- a/fs/hfs/bnode.c
2275 ++++ b/fs/hfs/bnode.c
2276 +@@ -287,7 +287,6 @@ static struct hfs_bnode *__hfs_bnode_create(struct hfs_btree *tree, u32 cnid)
2277 + page_cache_release(page);
2278 + goto fail;
2279 + }
2280 +- page_cache_release(page);
2281 + node->page[i] = page;
2282 + }
2283 +
2284 +@@ -397,11 +396,11 @@ node_error:
2285 +
2286 + void hfs_bnode_free(struct hfs_bnode *node)
2287 + {
2288 +- //int i;
2289 ++ int i;
2290 +
2291 +- //for (i = 0; i < node->tree->pages_per_bnode; i++)
2292 +- // if (node->page[i])
2293 +- // page_cache_release(node->page[i]);
2294 ++ for (i = 0; i < node->tree->pages_per_bnode; i++)
2295 ++ if (node->page[i])
2296 ++ page_cache_release(node->page[i]);
2297 + kfree(node);
2298 + }
2299 +
2300 +diff --git a/fs/hfs/brec.c b/fs/hfs/brec.c
2301 +index 92fb358ce824..db240c54a23a 100644
2302 +--- a/fs/hfs/brec.c
2303 ++++ b/fs/hfs/brec.c
2304 +@@ -132,13 +132,16 @@ skip:
2305 + hfs_bnode_write(node, entry, data_off + key_len, entry_len);
2306 + hfs_bnode_dump(node);
2307 +
2308 +- if (new_node) {
2309 +- /* update parent key if we inserted a key
2310 +- * at the start of the first node
2311 +- */
2312 +- if (!rec && new_node != node)
2313 +- hfs_brec_update_parent(fd);
2314 ++ /*
2315 ++ * update parent key if we inserted a key
2316 ++ * at the start of the node and it is not the new node
2317 ++ */
2318 ++ if (!rec && new_node != node) {
2319 ++ hfs_bnode_read_key(node, fd->search_key, data_off + size);
2320 ++ hfs_brec_update_parent(fd);
2321 ++ }
2322 +
2323 ++ if (new_node) {
2324 + hfs_bnode_put(fd->bnode);
2325 + if (!new_node->parent) {
2326 + hfs_btree_inc_height(tree);
2327 +@@ -167,9 +170,6 @@ skip:
2328 + goto again;
2329 + }
2330 +
2331 +- if (!rec)
2332 +- hfs_brec_update_parent(fd);
2333 +-
2334 + return 0;
2335 + }
2336 +
2337 +@@ -366,6 +366,8 @@ again:
2338 + if (IS_ERR(parent))
2339 + return PTR_ERR(parent);
2340 + __hfs_brec_find(parent, fd);
2341 ++ if (fd->record < 0)
2342 ++ return -ENOENT;
2343 + hfs_bnode_dump(parent);
2344 + rec = fd->record;
2345 +
2346 +diff --git a/fs/hfs/super.c b/fs/hfs/super.c
2347 +index 7b4c537d6e13..be0e218a333e 100644
2348 +--- a/fs/hfs/super.c
2349 ++++ b/fs/hfs/super.c
2350 +@@ -138,9 +138,9 @@ static int hfs_show_options(struct seq_file *seq, struct dentry *root)
2351 + struct hfs_sb_info *sbi = HFS_SB(root->d_sb);
2352 +
2353 + if (sbi->s_creator != cpu_to_be32(0x3f3f3f3f))
2354 +- seq_printf(seq, ",creator=%.4s", (char *)&sbi->s_creator);
2355 ++ seq_show_option_n(seq, "creator", (char *)&sbi->s_creator, 4);
2356 + if (sbi->s_type != cpu_to_be32(0x3f3f3f3f))
2357 +- seq_printf(seq, ",type=%.4s", (char *)&sbi->s_type);
2358 ++ seq_show_option_n(seq, "type", (char *)&sbi->s_type, 4);
2359 + seq_printf(seq, ",uid=%u,gid=%u", sbi->s_uid, sbi->s_gid);
2360 + if (sbi->s_file_umask != 0133)
2361 + seq_printf(seq, ",file_umask=%o", sbi->s_file_umask);
2362 +diff --git a/fs/hfsplus/bnode.c b/fs/hfsplus/bnode.c
2363 +index 1c42cc5b899f..a1e91092fc24 100644
2364 +--- a/fs/hfsplus/bnode.c
2365 ++++ b/fs/hfsplus/bnode.c
2366 +@@ -454,7 +454,6 @@ static struct hfs_bnode *__hfs_bnode_create(struct hfs_btree *tree, u32 cnid)
2367 + page_cache_release(page);
2368 + goto fail;
2369 + }
2370 +- page_cache_release(page);
2371 + node->page[i] = page;
2372 + }
2373 +
2374 +@@ -566,13 +565,11 @@ node_error:
2375 +
2376 + void hfs_bnode_free(struct hfs_bnode *node)
2377 + {
2378 +-#if 0
2379 + int i;
2380 +
2381 + for (i = 0; i < node->tree->pages_per_bnode; i++)
2382 + if (node->page[i])
2383 + page_cache_release(node->page[i]);
2384 +-#endif
2385 + kfree(node);
2386 + }
2387 +
2388 +diff --git a/fs/hfsplus/options.c b/fs/hfsplus/options.c
2389 +index 06fa5618600c..38e41d07d67f 100644
2390 +--- a/fs/hfsplus/options.c
2391 ++++ b/fs/hfsplus/options.c
2392 +@@ -211,9 +211,9 @@ int hfsplus_show_options(struct seq_file *seq, struct dentry *root)
2393 + struct hfsplus_sb_info *sbi = HFSPLUS_SB(root->d_sb);
2394 +
2395 + if (sbi->creator != HFSPLUS_DEF_CR_TYPE)
2396 +- seq_printf(seq, ",creator=%.4s", (char *)&sbi->creator);
2397 ++ seq_show_option_n(seq, "creator", (char *)&sbi->creator, 4);
2398 + if (sbi->type != HFSPLUS_DEF_CR_TYPE)
2399 +- seq_printf(seq, ",type=%.4s", (char *)&sbi->type);
2400 ++ seq_show_option_n(seq, "type", (char *)&sbi->type, 4);
2401 + seq_printf(seq, ",umask=%o,uid=%u,gid=%u", sbi->umask,
2402 + sbi->uid, sbi->gid);
2403 + if (sbi->part >= 0)
2404 +diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
2405 +index 07c516bfea76..fe63b15f54d2 100644
2406 +--- a/fs/hostfs/hostfs_kern.c
2407 ++++ b/fs/hostfs/hostfs_kern.c
2408 +@@ -264,7 +264,7 @@ static int hostfs_show_options(struct seq_file *seq, struct dentry *root)
2409 + size_t offset = strlen(root_ino) + 1;
2410 +
2411 + if (strlen(root_path) > offset)
2412 +- seq_printf(seq, ",%s", root_path + offset);
2413 ++ seq_show_option(seq, root_path + offset, NULL);
2414 +
2415 + return 0;
2416 + }
2417 +diff --git a/fs/hpfs/namei.c b/fs/hpfs/namei.c
2418 +index 30dd7b10b507..bdb86a8a802e 100644
2419 +--- a/fs/hpfs/namei.c
2420 ++++ b/fs/hpfs/namei.c
2421 +@@ -8,6 +8,17 @@
2422 + #include <linux/sched.h>
2423 + #include "hpfs_fn.h"
2424 +
2425 ++static void hpfs_update_directory_times(struct inode *dir)
2426 ++{
2427 ++ time_t t = get_seconds();
2428 ++ if (t == dir->i_mtime.tv_sec &&
2429 ++ t == dir->i_ctime.tv_sec)
2430 ++ return;
2431 ++ dir->i_mtime.tv_sec = dir->i_ctime.tv_sec = t;
2432 ++ dir->i_mtime.tv_nsec = dir->i_ctime.tv_nsec = 0;
2433 ++ hpfs_write_inode_nolock(dir);
2434 ++}
2435 ++
2436 + static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
2437 + {
2438 + const unsigned char *name = dentry->d_name.name;
2439 +@@ -99,6 +110,7 @@ static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
2440 + result->i_mode = mode | S_IFDIR;
2441 + hpfs_write_inode_nolock(result);
2442 + }
2443 ++ hpfs_update_directory_times(dir);
2444 + d_instantiate(dentry, result);
2445 + hpfs_unlock(dir->i_sb);
2446 + return 0;
2447 +@@ -187,6 +199,7 @@ static int hpfs_create(struct inode *dir, struct dentry *dentry, umode_t mode, s
2448 + result->i_mode = mode | S_IFREG;
2449 + hpfs_write_inode_nolock(result);
2450 + }
2451 ++ hpfs_update_directory_times(dir);
2452 + d_instantiate(dentry, result);
2453 + hpfs_unlock(dir->i_sb);
2454 + return 0;
2455 +@@ -262,6 +275,7 @@ static int hpfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, de
2456 + insert_inode_hash(result);
2457 +
2458 + hpfs_write_inode_nolock(result);
2459 ++ hpfs_update_directory_times(dir);
2460 + d_instantiate(dentry, result);
2461 + brelse(bh);
2462 + hpfs_unlock(dir->i_sb);
2463 +@@ -340,6 +354,7 @@ static int hpfs_symlink(struct inode *dir, struct dentry *dentry, const char *sy
2464 + insert_inode_hash(result);
2465 +
2466 + hpfs_write_inode_nolock(result);
2467 ++ hpfs_update_directory_times(dir);
2468 + d_instantiate(dentry, result);
2469 + hpfs_unlock(dir->i_sb);
2470 + return 0;
2471 +@@ -423,6 +438,8 @@ again:
2472 + out1:
2473 + hpfs_brelse4(&qbh);
2474 + out:
2475 ++ if (!err)
2476 ++ hpfs_update_directory_times(dir);
2477 + hpfs_unlock(dir->i_sb);
2478 + return err;
2479 + }
2480 +@@ -477,6 +494,8 @@ static int hpfs_rmdir(struct inode *dir, struct dentry *dentry)
2481 + out1:
2482 + hpfs_brelse4(&qbh);
2483 + out:
2484 ++ if (!err)
2485 ++ hpfs_update_directory_times(dir);
2486 + hpfs_unlock(dir->i_sb);
2487 + return err;
2488 + }
2489 +@@ -595,7 +614,7 @@ static int hpfs_rename(struct inode *old_dir, struct dentry *old_dentry,
2490 + goto end1;
2491 + }
2492 +
2493 +- end:
2494 ++end:
2495 + hpfs_i(i)->i_parent_dir = new_dir->i_ino;
2496 + if (S_ISDIR(i->i_mode)) {
2497 + inc_nlink(new_dir);
2498 +@@ -610,6 +629,10 @@ static int hpfs_rename(struct inode *old_dir, struct dentry *old_dentry,
2499 + brelse(bh);
2500 + }
2501 + end1:
2502 ++ if (!err) {
2503 ++ hpfs_update_directory_times(old_dir);
2504 ++ hpfs_update_directory_times(new_dir);
2505 ++ }
2506 + hpfs_unlock(i->i_sb);
2507 + return err;
2508 + }
2509 +diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
2510 +index 3d344ab0bdb3..92eff4da0062 100644
2511 +--- a/fs/nfs/nfs4proc.c
2512 ++++ b/fs/nfs/nfs4proc.c
2513 +@@ -1851,7 +1851,7 @@ static int _nfs4_do_open(struct inode *dir, struct dentry *dentry, fmode_t fmode
2514 + if (server->caps & NFS_CAP_POSIX_LOCK)
2515 + set_bit(NFS_STATE_POSIX_LOCKS, &state->flags);
2516 +
2517 +- if (opendata->o_arg.open_flags & O_EXCL) {
2518 ++ if ((opendata->o_arg.open_flags & (O_CREAT|O_EXCL)) == (O_CREAT|O_EXCL)) {
2519 + nfs4_exclusive_attrset(opendata, sattr);
2520 +
2521 + nfs_fattr_init(opendata->o_res.f_attr);
2522 +diff --git a/fs/ocfs2/dlm/dlmmaster.c b/fs/ocfs2/dlm/dlmmaster.c
2523 +index 7ba6ac187edd..8e48ba5f6549 100644
2524 +--- a/fs/ocfs2/dlm/dlmmaster.c
2525 ++++ b/fs/ocfs2/dlm/dlmmaster.c
2526 +@@ -1411,6 +1411,7 @@ int dlm_master_request_handler(struct o2net_msg *msg, u32 len, void *data,
2527 + int found, ret;
2528 + int set_maybe;
2529 + int dispatch_assert = 0;
2530 ++ int dispatched = 0;
2531 +
2532 + if (!dlm_grab(dlm))
2533 + return DLM_MASTER_RESP_NO;
2534 +@@ -1617,13 +1618,16 @@ send_response:
2535 + mlog(ML_ERROR, "failed to dispatch assert master work\n");
2536 + response = DLM_MASTER_RESP_ERROR;
2537 + dlm_lockres_put(res);
2538 ++ } else {
2539 ++ dispatched = 1;
2540 + }
2541 + } else {
2542 + if (res)
2543 + dlm_lockres_put(res);
2544 + }
2545 +
2546 +- dlm_put(dlm);
2547 ++ if (!dispatched)
2548 ++ dlm_put(dlm);
2549 + return response;
2550 + }
2551 +
2552 +@@ -2041,7 +2045,6 @@ int dlm_dispatch_assert_master(struct dlm_ctxt *dlm,
2553 +
2554 +
2555 + /* queue up work for dlm_assert_master_worker */
2556 +- dlm_grab(dlm); /* get an extra ref for the work item */
2557 + dlm_init_work_item(dlm, item, dlm_assert_master_worker, NULL);
2558 + item->u.am.lockres = res; /* already have a ref */
2559 + /* can optionally ignore node numbers higher than this node */
2560 +diff --git a/fs/ocfs2/dlm/dlmrecovery.c b/fs/ocfs2/dlm/dlmrecovery.c
2561 +index d15b0714ee3e..0e5013ed7f13 100644
2562 +--- a/fs/ocfs2/dlm/dlmrecovery.c
2563 ++++ b/fs/ocfs2/dlm/dlmrecovery.c
2564 +@@ -1689,6 +1689,7 @@ int dlm_master_requery_handler(struct o2net_msg *msg, u32 len, void *data,
2565 + unsigned int hash;
2566 + int master = DLM_LOCK_RES_OWNER_UNKNOWN;
2567 + u32 flags = DLM_ASSERT_MASTER_REQUERY;
2568 ++ int dispatched = 0;
2569 +
2570 + if (!dlm_grab(dlm)) {
2571 + /* since the domain has gone away on this
2572 +@@ -1710,6 +1711,8 @@ int dlm_master_requery_handler(struct o2net_msg *msg, u32 len, void *data,
2573 + mlog_errno(-ENOMEM);
2574 + /* retry!? */
2575 + BUG();
2576 ++ } else {
2577 ++ dispatched = 1;
2578 + }
2579 + } else /* put.. incase we are not the master */
2580 + dlm_lockres_put(res);
2581 +@@ -1717,7 +1720,8 @@ int dlm_master_requery_handler(struct o2net_msg *msg, u32 len, void *data,
2582 + }
2583 + spin_unlock(&dlm->spinlock);
2584 +
2585 +- dlm_put(dlm);
2586 ++ if (!dispatched)
2587 ++ dlm_put(dlm);
2588 + return master;
2589 + }
2590 +
2591 +diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
2592 +index 68f4541c2db9..91a0020a0ad3 100644
2593 +--- a/fs/ocfs2/super.c
2594 ++++ b/fs/ocfs2/super.c
2595 +@@ -1578,8 +1578,8 @@ static int ocfs2_show_options(struct seq_file *s, struct dentry *root)
2596 + seq_printf(s, ",localflocks,");
2597 +
2598 + if (osb->osb_cluster_stack[0])
2599 +- seq_printf(s, ",cluster_stack=%.*s", OCFS2_STACK_LABEL_LEN,
2600 +- osb->osb_cluster_stack);
2601 ++ seq_show_option_n(s, "cluster_stack", osb->osb_cluster_stack,
2602 ++ OCFS2_STACK_LABEL_LEN);
2603 + if (opts & OCFS2_MOUNT_USRQUOTA)
2604 + seq_printf(s, ",usrquota");
2605 + if (opts & OCFS2_MOUNT_GRPQUOTA)
2606 +diff --git a/fs/pipe.c b/fs/pipe.c
2607 +index abfb93525ca6..6049235e2a69 100644
2608 +--- a/fs/pipe.c
2609 ++++ b/fs/pipe.c
2610 +@@ -390,6 +390,7 @@ pipe_read(struct kiocb *iocb, const struct iovec *_iov,
2611 + void *addr;
2612 + size_t chars = buf->len, remaining;
2613 + int error, atomic;
2614 ++ int offset;
2615 +
2616 + if (chars > total_len)
2617 + chars = total_len;
2618 +@@ -403,9 +404,10 @@ pipe_read(struct kiocb *iocb, const struct iovec *_iov,
2619 +
2620 + atomic = !iov_fault_in_pages_write(iov, chars);
2621 + remaining = chars;
2622 ++ offset = buf->offset;
2623 + redo:
2624 + addr = ops->map(pipe, buf, atomic);
2625 +- error = pipe_iov_copy_to_user(iov, addr, &buf->offset,
2626 ++ error = pipe_iov_copy_to_user(iov, addr, &offset,
2627 + &remaining, atomic);
2628 + ops->unmap(pipe, buf, addr);
2629 + if (unlikely(error)) {
2630 +@@ -421,6 +423,7 @@ redo:
2631 + break;
2632 + }
2633 + ret += chars;
2634 ++ buf->offset += chars;
2635 + buf->len -= chars;
2636 +
2637 + /* Was it a packet buffer? Clean up and exit */
2638 +diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c
2639 +index 8169be93ac0f..e12357bb3090 100644
2640 +--- a/fs/reiserfs/super.c
2641 ++++ b/fs/reiserfs/super.c
2642 +@@ -645,18 +645,20 @@ static int reiserfs_show_options(struct seq_file *seq, struct dentry *root)
2643 + seq_puts(seq, ",acl");
2644 +
2645 + if (REISERFS_SB(s)->s_jdev)
2646 +- seq_printf(seq, ",jdev=%s", REISERFS_SB(s)->s_jdev);
2647 ++ seq_show_option(seq, "jdev", REISERFS_SB(s)->s_jdev);
2648 +
2649 + if (journal->j_max_commit_age != journal->j_default_max_commit_age)
2650 + seq_printf(seq, ",commit=%d", journal->j_max_commit_age);
2651 +
2652 + #ifdef CONFIG_QUOTA
2653 + if (REISERFS_SB(s)->s_qf_names[USRQUOTA])
2654 +- seq_printf(seq, ",usrjquota=%s", REISERFS_SB(s)->s_qf_names[USRQUOTA]);
2655 ++ seq_show_option(seq, "usrjquota",
2656 ++ REISERFS_SB(s)->s_qf_names[USRQUOTA]);
2657 + else if (opts & (1 << REISERFS_USRQUOTA))
2658 + seq_puts(seq, ",usrquota");
2659 + if (REISERFS_SB(s)->s_qf_names[GRPQUOTA])
2660 +- seq_printf(seq, ",grpjquota=%s", REISERFS_SB(s)->s_qf_names[GRPQUOTA]);
2661 ++ seq_show_option(seq, "grpjquota",
2662 ++ REISERFS_SB(s)->s_qf_names[GRPQUOTA]);
2663 + else if (opts & (1 << REISERFS_GRPQUOTA))
2664 + seq_puts(seq, ",grpquota");
2665 + if (REISERFS_SB(s)->s_jquota_fmt) {
2666 +diff --git a/fs/splice.c b/fs/splice.c
2667 +index 67c5210e7ce7..286417764d6b 100644
2668 +--- a/fs/splice.c
2669 ++++ b/fs/splice.c
2670 +@@ -1165,7 +1165,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
2671 + long ret, bytes;
2672 + umode_t i_mode;
2673 + size_t len;
2674 +- int i, flags;
2675 ++ int i, flags, more;
2676 +
2677 + /*
2678 + * We require the input being a regular file, as we don't want to
2679 +@@ -1208,6 +1208,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
2680 + * Don't block on output, we have to drain the direct pipe.
2681 + */
2682 + sd->flags &= ~SPLICE_F_NONBLOCK;
2683 ++ more = sd->flags & SPLICE_F_MORE;
2684 +
2685 + while (len) {
2686 + size_t read_len;
2687 +@@ -1221,6 +1222,15 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
2688 + sd->total_len = read_len;
2689 +
2690 + /*
2691 ++ * If more data is pending, set SPLICE_F_MORE
2692 ++ * If this is the last data and SPLICE_F_MORE was not set
2693 ++ * initially, clears it.
2694 ++ */
2695 ++ if (read_len < len)
2696 ++ sd->flags |= SPLICE_F_MORE;
2697 ++ else if (!more)
2698 ++ sd->flags &= ~SPLICE_F_MORE;
2699 ++ /*
2700 + * NOTE: nonblocking mode only applies to the input. We
2701 + * must not do the output in nonblocking mode as then we
2702 + * could get stuck data in the internal pipe:
2703 +diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
2704 +index dab9a5f6dfd6..d6c787dc261d 100644
2705 +--- a/fs/xfs/xfs_super.c
2706 ++++ b/fs/xfs/xfs_super.c
2707 +@@ -523,9 +523,9 @@ xfs_showargs(
2708 + seq_printf(m, "," MNTOPT_LOGBSIZE "=%dk", mp->m_logbsize >> 10);
2709 +
2710 + if (mp->m_logname)
2711 +- seq_printf(m, "," MNTOPT_LOGDEV "=%s", mp->m_logname);
2712 ++ seq_show_option(m, MNTOPT_LOGDEV, mp->m_logname);
2713 + if (mp->m_rtname)
2714 +- seq_printf(m, "," MNTOPT_RTDEV "=%s", mp->m_rtname);
2715 ++ seq_show_option(m, MNTOPT_RTDEV, mp->m_rtname);
2716 +
2717 + if (mp->m_dalign > 0)
2718 + seq_printf(m, "," MNTOPT_SUNIT "=%d",
2719 +diff --git a/include/linux/pci.h b/include/linux/pci.h
2720 +index 469c9536c5e5..579baf06f77d 100644
2721 +--- a/include/linux/pci.h
2722 ++++ b/include/linux/pci.h
2723 +@@ -176,6 +176,8 @@ enum pci_dev_flags {
2724 + PCI_DEV_FLAGS_NO_D3 = (__force pci_dev_flags_t) 2,
2725 + /* Provide indication device is assigned by a Virtual Machine Manager */
2726 + PCI_DEV_FLAGS_ASSIGNED = (__force pci_dev_flags_t) 4,
2727 ++ /* Get VPD from function 0 VPD */
2728 ++ PCI_DEV_FLAGS_VPD_REF_F0 = (__force pci_dev_flags_t) (1 << 8),
2729 + };
2730 +
2731 + enum pci_irq_reroute_variant {
2732 +diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
2733 +index fc61854f6224..149b92f05562 100644
2734 +--- a/include/linux/seq_file.h
2735 ++++ b/include/linux/seq_file.h
2736 +@@ -127,6 +127,41 @@ int seq_put_decimal_ull(struct seq_file *m, char delimiter,
2737 + int seq_put_decimal_ll(struct seq_file *m, char delimiter,
2738 + long long num);
2739 +
2740 ++/**
2741 ++ * seq_show_options - display mount options with appropriate escapes.
2742 ++ * @m: the seq_file handle
2743 ++ * @name: the mount option name
2744 ++ * @value: the mount option name's value, can be NULL
2745 ++ */
2746 ++static inline void seq_show_option(struct seq_file *m, const char *name,
2747 ++ const char *value)
2748 ++{
2749 ++ seq_putc(m, ',');
2750 ++ seq_escape(m, name, ",= \t\n\\");
2751 ++ if (value) {
2752 ++ seq_putc(m, '=');
2753 ++ seq_escape(m, value, ", \t\n\\");
2754 ++ }
2755 ++}
2756 ++
2757 ++/**
2758 ++ * seq_show_option_n - display mount options with appropriate escapes
2759 ++ * where @value must be a specific length.
2760 ++ * @m: the seq_file handle
2761 ++ * @name: the mount option name
2762 ++ * @value: the mount option name's value, cannot be NULL
2763 ++ * @length: the length of @value to display
2764 ++ *
2765 ++ * This is a macro since this uses "length" to define the size of the
2766 ++ * stack buffer.
2767 ++ */
2768 ++#define seq_show_option_n(m, name, value, length) { \
2769 ++ char val_buf[length + 1]; \
2770 ++ strncpy(val_buf, value, length); \
2771 ++ val_buf[length] = '\0'; \
2772 ++ seq_show_option(m, name, val_buf); \
2773 ++}
2774 ++
2775 + #define SEQ_START_TOKEN ((void *)1)
2776 + /*
2777 + * Helpers for iteration over list_head-s in seq_files
2778 +diff --git a/include/sound/wm8904.h b/include/sound/wm8904.h
2779 +index 898be3a8db9a..6d8f8fba3341 100644
2780 +--- a/include/sound/wm8904.h
2781 ++++ b/include/sound/wm8904.h
2782 +@@ -119,7 +119,7 @@
2783 + #define WM8904_MIC_REGS 2
2784 + #define WM8904_GPIO_REGS 4
2785 + #define WM8904_DRC_REGS 4
2786 +-#define WM8904_EQ_REGS 25
2787 ++#define WM8904_EQ_REGS 24
2788 +
2789 + /**
2790 + * DRC configurations are specified with a label and a set of register
2791 +diff --git a/kernel/cgroup.c b/kernel/cgroup.c
2792 +index 34eda955e887..7ff5702507a5 100644
2793 +--- a/kernel/cgroup.c
2794 ++++ b/kernel/cgroup.c
2795 +@@ -1071,15 +1071,16 @@ static int cgroup_show_options(struct seq_file *seq, struct dentry *dentry)
2796 +
2797 + mutex_lock(&cgroup_root_mutex);
2798 + for_each_subsys(root, ss)
2799 +- seq_printf(seq, ",%s", ss->name);
2800 ++ seq_show_option(seq, ss->name, NULL);
2801 + if (test_bit(ROOT_NOPREFIX, &root->flags))
2802 + seq_puts(seq, ",noprefix");
2803 + if (strlen(root->release_agent_path))
2804 +- seq_printf(seq, ",release_agent=%s", root->release_agent_path);
2805 ++ seq_show_option(seq, "release_agent",
2806 ++ root->release_agent_path);
2807 + if (clone_children(&root->top_cgroup))
2808 + seq_puts(seq, ",clone_children");
2809 + if (strlen(root->name))
2810 +- seq_printf(seq, ",name=%s", root->name);
2811 ++ seq_show_option(seq, "name", root->name);
2812 + mutex_unlock(&cgroup_root_mutex);
2813 + return 0;
2814 + }
2815 +diff --git a/kernel/irq/proc.c b/kernel/irq/proc.c
2816 +index fb655f5f9689..15374d0ac369 100644
2817 +--- a/kernel/irq/proc.c
2818 ++++ b/kernel/irq/proc.c
2819 +@@ -12,6 +12,7 @@
2820 + #include <linux/seq_file.h>
2821 + #include <linux/interrupt.h>
2822 + #include <linux/kernel_stat.h>
2823 ++#include <linux/mutex.h>
2824 +
2825 + #include "internals.h"
2826 +
2827 +@@ -326,18 +327,29 @@ void register_handler_proc(unsigned int irq, struct irqaction *action)
2828 +
2829 + void register_irq_proc(unsigned int irq, struct irq_desc *desc)
2830 + {
2831 ++ static DEFINE_MUTEX(register_lock);
2832 + char name [MAX_NAMELEN];
2833 +
2834 +- if (!root_irq_dir || (desc->irq_data.chip == &no_irq_chip) || desc->dir)
2835 ++ if (!root_irq_dir || (desc->irq_data.chip == &no_irq_chip))
2836 + return;
2837 +
2838 ++ /*
2839 ++ * irq directories are registered only when a handler is
2840 ++ * added, not when the descriptor is created, so multiple
2841 ++ * tasks might try to register at the same time.
2842 ++ */
2843 ++ mutex_lock(&register_lock);
2844 ++
2845 ++ if (desc->dir)
2846 ++ goto out_unlock;
2847 ++
2848 + memset(name, 0, MAX_NAMELEN);
2849 + sprintf(name, "%d", irq);
2850 +
2851 + /* create /proc/irq/1234 */
2852 + desc->dir = proc_mkdir(name, root_irq_dir);
2853 + if (!desc->dir)
2854 +- return;
2855 ++ goto out_unlock;
2856 +
2857 + #ifdef CONFIG_SMP
2858 + /* create /proc/irq/<irq>/smp_affinity */
2859 +@@ -358,6 +370,9 @@ void register_irq_proc(unsigned int irq, struct irq_desc *desc)
2860 +
2861 + proc_create_data("spurious", 0444, desc->dir,
2862 + &irq_spurious_proc_fops, (void *)(long)irq);
2863 ++
2864 ++out_unlock:
2865 ++ mutex_unlock(&register_lock);
2866 + }
2867 +
2868 + void unregister_irq_proc(unsigned int irq, struct irq_desc *desc)
2869 +diff --git a/kernel/module.c b/kernel/module.c
2870 +index 5e398961b7b5..18e0879de3c6 100644
2871 +--- a/kernel/module.c
2872 ++++ b/kernel/module.c
2873 +@@ -887,11 +887,15 @@ void symbol_put_addr(void *addr)
2874 + if (core_kernel_text(a))
2875 + return;
2876 +
2877 +- /* module_text_address is safe here: we're supposed to have reference
2878 +- * to module from symbol_get, so it can't go away. */
2879 ++ /*
2880 ++ * Even though we hold a reference on the module; we still need to
2881 ++ * disable preemption in order to safely traverse the data structure.
2882 ++ */
2883 ++ preempt_disable();
2884 + modaddr = __module_text_address(a);
2885 + BUG_ON(!modaddr);
2886 + module_put(modaddr);
2887 ++ preempt_enable();
2888 + }
2889 + EXPORT_SYMBOL_GPL(symbol_put_addr);
2890 +
2891 +diff --git a/kernel/sched/core.c b/kernel/sched/core.c
2892 +index 15be43522c8b..609a22630674 100644
2893 +--- a/kernel/sched/core.c
2894 ++++ b/kernel/sched/core.c
2895 +@@ -1949,11 +1949,11 @@ static void finish_task_switch(struct rq *rq, struct task_struct *prev)
2896 + * If a task dies, then it sets TASK_DEAD in tsk->state and calls
2897 + * schedule one last time. The schedule call will never return, and
2898 + * the scheduled task must drop that reference.
2899 +- * The test for TASK_DEAD must occur while the runqueue locks are
2900 +- * still held, otherwise prev could be scheduled on another cpu, die
2901 +- * there before we look at prev->state, and then the reference would
2902 +- * be dropped twice.
2903 +- * Manfred Spraul <manfred@××××××××××××.com>
2904 ++ *
2905 ++ * We must observe prev->state before clearing prev->on_cpu (in
2906 ++ * finish_lock_switch), otherwise a concurrent wakeup can get prev
2907 ++ * running on another CPU and we could rave with its RUNNING -> DEAD
2908 ++ * transition, resulting in a double drop.
2909 + */
2910 + prev_state = prev->state;
2911 + finish_arch_switch(prev);
2912 +diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
2913 +index 4a5e7398d77b..44f4058e9e6d 100644
2914 +--- a/kernel/sched/sched.h
2915 ++++ b/kernel/sched/sched.h
2916 +@@ -702,8 +702,10 @@ static inline void finish_lock_switch(struct rq *rq, struct task_struct *prev)
2917 + * After ->on_cpu is cleared, the task can be moved to a different CPU.
2918 + * We must ensure this doesn't happen until the switch is completely
2919 + * finished.
2920 ++ *
2921 ++ * Pairs with the control dependency and rmb in try_to_wake_up().
2922 + */
2923 +- smp_wmb();
2924 ++ smp_mb();
2925 + prev->on_cpu = 0;
2926 + #endif
2927 + #ifdef CONFIG_DEBUG_SPINLOCK
2928 +diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c
2929 +index c9583382141a..b3f54079287d 100644
2930 +--- a/kernel/time/clocksource.c
2931 ++++ b/kernel/time/clocksource.c
2932 +@@ -291,7 +291,7 @@ static void clocksource_watchdog(unsigned long data)
2933 + continue;
2934 +
2935 + /* Check the deviation from the watchdog clocksource. */
2936 +- if ((abs(cs_nsec - wd_nsec) > WATCHDOG_THRESHOLD)) {
2937 ++ if ((abs64(cs_nsec - wd_nsec) > WATCHDOG_THRESHOLD)) {
2938 + clocksource_unstable(cs, cs_nsec - wd_nsec);
2939 + continue;
2940 + }
2941 +diff --git a/mm/filemap.c b/mm/filemap.c
2942 +index 79c4b2b0b14e..448f9caa8695 100644
2943 +--- a/mm/filemap.c
2944 ++++ b/mm/filemap.c
2945 +@@ -2402,6 +2402,11 @@ again:
2946 + break;
2947 + }
2948 +
2949 ++ if (fatal_signal_pending(current)) {
2950 ++ status = -EINTR;
2951 ++ break;
2952 ++ }
2953 ++
2954 + status = a_ops->write_begin(file, mapping, pos, bytes, flags,
2955 + &page, &fsdata);
2956 + if (unlikely(status))
2957 +@@ -2442,10 +2447,6 @@ again:
2958 + written += copied;
2959 +
2960 + balance_dirty_pages_ratelimited(mapping);
2961 +- if (fatal_signal_pending(current)) {
2962 +- status = -EINTR;
2963 +- break;
2964 +- }
2965 + } while (iov_iter_count(i));
2966 +
2967 + return written ? written : status;
2968 +diff --git a/mm/hugetlb.c b/mm/hugetlb.c
2969 +index bc36e280ce8b..e622aab7fd8c 100644
2970 +--- a/mm/hugetlb.c
2971 ++++ b/mm/hugetlb.c
2972 +@@ -2504,6 +2504,14 @@ static int unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,
2973 + continue;
2974 +
2975 + /*
2976 ++ * Shared VMAs have their own reserves and do not affect
2977 ++ * MAP_PRIVATE accounting but it is possible that a shared
2978 ++ * VMA is using the same page so check and skip such VMAs.
2979 ++ */
2980 ++ if (iter_vma->vm_flags & VM_MAYSHARE)
2981 ++ continue;
2982 ++
2983 ++ /*
2984 + * Unmap the page from other VMAs without their own reserves.
2985 + * They get marked to be SIGKILLed if they fault in these
2986 + * areas. This is because a future no-page fault on this VMA
2987 +diff --git a/net/ipv6/xfrm6_output.c b/net/ipv6/xfrm6_output.c
2988 +index 8755a3079d0f..7fc10b915cd8 100644
2989 +--- a/net/ipv6/xfrm6_output.c
2990 ++++ b/net/ipv6/xfrm6_output.c
2991 +@@ -137,20 +137,24 @@ static int __xfrm6_output(struct sk_buff *skb)
2992 + struct dst_entry *dst = skb_dst(skb);
2993 + struct xfrm_state *x = dst->xfrm;
2994 + int mtu = ip6_skb_dst_mtu(skb);
2995 ++ bool toobig;
2996 +
2997 +- if (skb->len > mtu && xfrm6_local_dontfrag(skb)) {
2998 ++ if (x->props.mode != XFRM_MODE_TUNNEL)
2999 ++ goto skip_frag;
3000 ++
3001 ++ toobig = skb->len > mtu && !skb_is_gso(skb);
3002 ++
3003 ++ if (toobig && xfrm6_local_dontfrag(skb)) {
3004 + xfrm6_local_rxpmtu(skb, mtu);
3005 + return -EMSGSIZE;
3006 +- } else if (!skb->local_df && skb->len > mtu && skb->sk) {
3007 ++ } else if (!skb->local_df && toobig && skb->sk) {
3008 + xfrm6_local_error(skb, mtu);
3009 + return -EMSGSIZE;
3010 + }
3011 +
3012 +- if (x->props.mode == XFRM_MODE_TUNNEL &&
3013 +- ((skb->len > mtu && !skb_is_gso(skb)) ||
3014 +- dst_allfrag(skb_dst(skb)))) {
3015 ++ if (toobig || dst_allfrag(skb_dst(skb)))
3016 + return ip6_fragment(skb, x->outer_mode->afinfo->output_finish);
3017 +- }
3018 ++skip_frag:
3019 + return x->outer_mode->afinfo->output_finish(skb);
3020 + }
3021 +
3022 +diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
3023 +index f4f24bee99c2..67cd0f1a1bab 100644
3024 +--- a/net/mac80211/tx.c
3025 ++++ b/net/mac80211/tx.c
3026 +@@ -284,9 +284,6 @@ ieee80211_tx_h_check_assoc(struct ieee80211_tx_data *tx)
3027 + if (tx->sdata->vif.type == NL80211_IFTYPE_WDS)
3028 + return TX_CONTINUE;
3029 +
3030 +- if (tx->sdata->vif.type == NL80211_IFTYPE_MESH_POINT)
3031 +- return TX_CONTINUE;
3032 +-
3033 + if (tx->flags & IEEE80211_TX_PS_BUFFERED)
3034 + return TX_CONTINUE;
3035 +
3036 +diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
3037 +index 42eb7ba0b903..897a5f14c61e 100644
3038 +--- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
3039 ++++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
3040 +@@ -545,6 +545,7 @@ static int send_reply(struct svcxprt_rdma *rdma,
3041 + {
3042 + struct ib_send_wr send_wr;
3043 + struct ib_send_wr inv_wr;
3044 ++ u32 xdr_off;
3045 + int sge_no;
3046 + int sge_bytes;
3047 + int page_no;
3048 +@@ -584,8 +585,8 @@ static int send_reply(struct svcxprt_rdma *rdma,
3049 + ctxt->direction = DMA_TO_DEVICE;
3050 +
3051 + /* Map the payload indicated by 'byte_count' */
3052 ++ xdr_off = 0;
3053 + for (sge_no = 1; byte_count && sge_no < vec->count; sge_no++) {
3054 +- int xdr_off = 0;
3055 + sge_bytes = min_t(size_t, vec->sge[sge_no].iov_len, byte_count);
3056 + byte_count -= sge_bytes;
3057 + if (!vec->frmr) {
3058 +@@ -623,6 +624,14 @@ static int send_reply(struct svcxprt_rdma *rdma,
3059 + if (page_no+1 >= sge_no)
3060 + ctxt->sge[page_no+1].length = 0;
3061 + }
3062 ++
3063 ++ /* The loop above bumps sc_dma_used for each sge. The
3064 ++ * xdr_buf.tail gets a separate sge, but resides in the
3065 ++ * same page as xdr_buf.head. Don't count it twice.
3066 ++ */
3067 ++ if (sge_no > ctxt->count)
3068 ++ atomic_dec(&rdma->sc_dma_used);
3069 ++
3070 + BUG_ON(sge_no > rdma->sc_max_sge);
3071 + memset(&send_wr, 0, sizeof send_wr);
3072 + ctxt->wr_op = IB_WR_SEND;
3073 +diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
3074 +index 31275e52c667..d4a564fec093 100644
3075 +--- a/net/sunrpc/xprtsock.c
3076 ++++ b/net/sunrpc/xprtsock.c
3077 +@@ -811,6 +811,7 @@ static void xs_reset_transport(struct sock_xprt *transport)
3078 + {
3079 + struct socket *sock = transport->sock;
3080 + struct sock *sk = transport->inet;
3081 ++ struct rpc_xprt *xprt = &transport->xprt;
3082 +
3083 + if (sk == NULL)
3084 + return;
3085 +@@ -824,6 +825,7 @@ static void xs_reset_transport(struct sock_xprt *transport)
3086 + sk->sk_user_data = NULL;
3087 +
3088 + xs_restore_old_callbacks(transport, sk);
3089 ++ xprt_clear_connected(xprt);
3090 + write_unlock_bh(&sk->sk_callback_lock);
3091 +
3092 + sk->sk_no_check = 0;
3093 +diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
3094 +index cbae6d392087..312d2fb598d7 100644
3095 +--- a/security/selinux/hooks.c
3096 ++++ b/security/selinux/hooks.c
3097 +@@ -1012,7 +1012,7 @@ static void selinux_write_opts(struct seq_file *m,
3098 + seq_puts(m, prefix);
3099 + if (has_comma)
3100 + seq_putc(m, '\"');
3101 +- seq_puts(m, opts->mnt_opts[i]);
3102 ++ seq_escape(m, opts->mnt_opts[i], "\"\n\\");
3103 + if (has_comma)
3104 + seq_putc(m, '\"');
3105 + }
3106 +diff --git a/sound/arm/Kconfig b/sound/arm/Kconfig
3107 +index 885683a3b0bd..e0406211716b 100644
3108 +--- a/sound/arm/Kconfig
3109 ++++ b/sound/arm/Kconfig
3110 +@@ -9,6 +9,14 @@ menuconfig SND_ARM
3111 + Drivers that are implemented on ASoC can be found in
3112 + "ALSA for SoC audio support" section.
3113 +
3114 ++config SND_PXA2XX_LIB
3115 ++ tristate
3116 ++ select SND_AC97_CODEC if SND_PXA2XX_LIB_AC97
3117 ++ select SND_DMAENGINE_PCM
3118 ++
3119 ++config SND_PXA2XX_LIB_AC97
3120 ++ bool
3121 ++
3122 + if SND_ARM
3123 +
3124 + config SND_ARMAACI
3125 +@@ -21,13 +29,6 @@ config SND_PXA2XX_PCM
3126 + tristate
3127 + select SND_PCM
3128 +
3129 +-config SND_PXA2XX_LIB
3130 +- tristate
3131 +- select SND_AC97_CODEC if SND_PXA2XX_LIB_AC97
3132 +-
3133 +-config SND_PXA2XX_LIB_AC97
3134 +- bool
3135 +-
3136 + config SND_PXA2XX_AC97
3137 + tristate "AC97 driver for the Intel PXA2xx chip"
3138 + depends on ARCH_PXA
3139 +diff --git a/sound/soc/pxa/Kconfig b/sound/soc/pxa/Kconfig
3140 +index a0f7d3cfa470..23deb67b8b4e 100644
3141 +--- a/sound/soc/pxa/Kconfig
3142 ++++ b/sound/soc/pxa/Kconfig
3143 +@@ -1,7 +1,6 @@
3144 + config SND_PXA2XX_SOC
3145 + tristate "SoC Audio for the Intel PXA2xx chip"
3146 + depends on ARCH_PXA
3147 +- select SND_ARM
3148 + select SND_PXA2XX_LIB
3149 + help
3150 + Say Y or M if you want to add support for codecs attached to
3151 +@@ -15,7 +14,6 @@ config SND_PXA2XX_AC97
3152 + config SND_PXA2XX_SOC_AC97
3153 + tristate
3154 + select AC97_BUS
3155 +- select SND_ARM
3156 + select SND_PXA2XX_LIB_AC97
3157 + select SND_SOC_AC97_BUS
3158 +
3159 +diff --git a/sound/synth/emux/emux_oss.c b/sound/synth/emux/emux_oss.c
3160 +index daf61abc3670..646b66703bd8 100644
3161 +--- a/sound/synth/emux/emux_oss.c
3162 ++++ b/sound/synth/emux/emux_oss.c
3163 +@@ -69,7 +69,8 @@ snd_emux_init_seq_oss(struct snd_emux *emu)
3164 + struct snd_seq_oss_reg *arg;
3165 + struct snd_seq_device *dev;
3166 +
3167 +- if (snd_seq_device_new(emu->card, 0, SNDRV_SEQ_DEV_ID_OSS,
3168 ++ /* using device#1 here for avoiding conflicts with OPL3 */
3169 ++ if (snd_seq_device_new(emu->card, 1, SNDRV_SEQ_DEV_ID_OSS,
3170 + sizeof(struct snd_seq_oss_reg), &dev) < 0)
3171 + return;
3172 +
3173 +diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
3174 +index c0b70c697a36..5a4482c2a7d5 100644
3175 +--- a/tools/perf/util/header.c
3176 ++++ b/tools/perf/util/header.c
3177 +@@ -1060,25 +1060,19 @@ static void print_cpudesc(struct perf_header *ph, int fd, FILE *fp)
3178 + static void print_nrcpus(struct perf_header *ph, int fd, FILE *fp)
3179 + {
3180 + ssize_t ret;
3181 +- u32 nr;
3182 ++ u32 nr[2];
3183 +
3184 + ret = read(fd, &nr, sizeof(nr));
3185 + if (ret != (ssize_t)sizeof(nr))
3186 +- nr = -1; /* interpreted as error */
3187 ++ nr[0] = nr[1] = -1; /* interpreted as error */
3188 +
3189 +- if (ph->needs_swap)
3190 +- nr = bswap_32(nr);
3191 +-
3192 +- fprintf(fp, "# nrcpus online : %u\n", nr);
3193 +-
3194 +- ret = read(fd, &nr, sizeof(nr));
3195 +- if (ret != (ssize_t)sizeof(nr))
3196 +- nr = -1; /* interpreted as error */
3197 +-
3198 +- if (ph->needs_swap)
3199 +- nr = bswap_32(nr);
3200 ++ if (ph->needs_swap) {
3201 ++ nr[0] = bswap_32(nr[0]);
3202 ++ nr[1] = bswap_32(nr[1]);
3203 ++ }
3204 +
3205 +- fprintf(fp, "# nrcpus avail : %u\n", nr);
3206 ++ fprintf(fp, "# nrcpus online : %u\n", nr[1]);
3207 ++ fprintf(fp, "# nrcpus avail : %u\n", nr[0]);
3208 + }
3209 +
3210 + static void print_version(struct perf_header *ph, int fd, FILE *fp)