Gentoo Archives: gentoo-commits

From: "Tom Wijsman (tomwij)" <tomwij@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] linux-patches r2595 - in genpatches-2.6/trunk: . 3.10 3.11 3.12 3.2 3.4
Date: Fri, 29 Nov 2013 23:44:39
Message-Id: 20131129234430.198802004B@flycatcher.gentoo.org
1 Author: tomwij
2 Date: 2013-11-29 23:44:29 +0000 (Fri, 29 Nov 2013)
3 New Revision: 2595
4
5 Added:
6 genpatches-2.6/trunk/3.10/1020_linux-3.10.21.patch
7 genpatches-2.6/trunk/3.11/1009_linux-3.11.10.patch
8 genpatches-2.6/trunk/3.12/1001_linux-3.12.2.patch
9 genpatches-2.6/trunk/3.2/
10 genpatches-2.6/trunk/3.2/1051_linux-3.2.52.patch
11 genpatches-2.6/trunk/3.4/1070_linux-3.4.71.patch
12 Modified:
13 genpatches-2.6/trunk/3.10/0000_README
14 genpatches-2.6/trunk/3.11/0000_README
15 genpatches-2.6/trunk/3.12/0000_README
16 genpatches-2.6/trunk/3.2/0000_README
17 genpatches-2.6/trunk/3.4/0000_README
18 Log:
19 Added back 3.2 branch as it is still long term. Linux patches 3.2.52, 3.4.71, 3.10.21, 3.11.10 and 3.12.2.
20
21 Modified: genpatches-2.6/trunk/3.10/0000_README
22 ===================================================================
23 --- genpatches-2.6/trunk/3.10/0000_README 2013-11-26 00:34:31 UTC (rev 2594)
24 +++ genpatches-2.6/trunk/3.10/0000_README 2013-11-29 23:44:29 UTC (rev 2595)
25 @@ -122,6 +122,10 @@
26 From: http://www.kernel.org
27 Desc: Linux 3.10.20
28
29 +Patch: 1020_linux-3.10.21.patch
30 +From: http://www.kernel.org
31 +Desc: Linux 3.10.21
32 +
33 Patch: 1500_XATTR_USER_PREFIX.patch
34 From: https://bugs.gentoo.org/show_bug.cgi?id=470644
35 Desc: Support for namespace user.pax.* on tmpfs.
36
37 Added: genpatches-2.6/trunk/3.10/1020_linux-3.10.21.patch
38 ===================================================================
39 --- genpatches-2.6/trunk/3.10/1020_linux-3.10.21.patch (rev 0)
40 +++ genpatches-2.6/trunk/3.10/1020_linux-3.10.21.patch 2013-11-29 23:44:29 UTC (rev 2595)
41 @@ -0,0 +1,2728 @@
42 +diff --git a/Makefile b/Makefile
43 +index ba784b7b0f51..c0635fbab87f 100644
44 +--- a/Makefile
45 ++++ b/Makefile
46 +@@ -1,6 +1,6 @@
47 + VERSION = 3
48 + PATCHLEVEL = 10
49 +-SUBLEVEL = 20
50 ++SUBLEVEL = 21
51 + EXTRAVERSION =
52 + NAME = TOSSUG Baby Fish
53 +
54 +diff --git a/arch/arm/kvm/mmu.c b/arch/arm/kvm/mmu.c
55 +index 84ba67b982c0..e04613906f1b 100644
56 +--- a/arch/arm/kvm/mmu.c
57 ++++ b/arch/arm/kvm/mmu.c
58 +@@ -313,6 +313,17 @@ out:
59 + return err;
60 + }
61 +
62 ++static phys_addr_t kvm_kaddr_to_phys(void *kaddr)
63 ++{
64 ++ if (!is_vmalloc_addr(kaddr)) {
65 ++ BUG_ON(!virt_addr_valid(kaddr));
66 ++ return __pa(kaddr);
67 ++ } else {
68 ++ return page_to_phys(vmalloc_to_page(kaddr)) +
69 ++ offset_in_page(kaddr);
70 ++ }
71 ++}
72 ++
73 + /**
74 + * create_hyp_mappings - duplicate a kernel virtual address range in Hyp mode
75 + * @from: The virtual kernel start address of the range
76 +@@ -324,16 +335,27 @@ out:
77 + */
78 + int create_hyp_mappings(void *from, void *to)
79 + {
80 +- unsigned long phys_addr = virt_to_phys(from);
81 ++ phys_addr_t phys_addr;
82 ++ unsigned long virt_addr;
83 + unsigned long start = KERN_TO_HYP((unsigned long)from);
84 + unsigned long end = KERN_TO_HYP((unsigned long)to);
85 +
86 +- /* Check for a valid kernel memory mapping */
87 +- if (!virt_addr_valid(from) || !virt_addr_valid(to - 1))
88 +- return -EINVAL;
89 ++ start = start & PAGE_MASK;
90 ++ end = PAGE_ALIGN(end);
91 +
92 +- return __create_hyp_mappings(hyp_pgd, start, end,
93 +- __phys_to_pfn(phys_addr), PAGE_HYP);
94 ++ for (virt_addr = start; virt_addr < end; virt_addr += PAGE_SIZE) {
95 ++ int err;
96 ++
97 ++ phys_addr = kvm_kaddr_to_phys(from + virt_addr - start);
98 ++ err = __create_hyp_mappings(hyp_pgd, virt_addr,
99 ++ virt_addr + PAGE_SIZE,
100 ++ __phys_to_pfn(phys_addr),
101 ++ PAGE_HYP);
102 ++ if (err)
103 ++ return err;
104 ++ }
105 ++
106 ++ return 0;
107 + }
108 +
109 + /**
110 +diff --git a/arch/cris/include/asm/io.h b/arch/cris/include/asm/io.h
111 +index ac12ae2b9286..db9a16c704f3 100644
112 +--- a/arch/cris/include/asm/io.h
113 ++++ b/arch/cris/include/asm/io.h
114 +@@ -3,6 +3,7 @@
115 +
116 + #include <asm/page.h> /* for __va, __pa */
117 + #include <arch/io.h>
118 ++#include <asm-generic/iomap.h>
119 + #include <linux/kernel.h>
120 +
121 + struct cris_io_operations
122 +diff --git a/arch/ia64/include/asm/processor.h b/arch/ia64/include/asm/processor.h
123 +index e0a899a1a8a6..5a84b3a50741 100644
124 +--- a/arch/ia64/include/asm/processor.h
125 ++++ b/arch/ia64/include/asm/processor.h
126 +@@ -319,7 +319,7 @@ struct thread_struct {
127 + regs->loadrs = 0; \
128 + regs->r8 = get_dumpable(current->mm); /* set "don't zap registers" flag */ \
129 + regs->r12 = new_sp - 16; /* allocate 16 byte scratch area */ \
130 +- if (unlikely(!get_dumpable(current->mm))) { \
131 ++ if (unlikely(get_dumpable(current->mm) != SUID_DUMP_USER)) { \
132 + /* \
133 + * Zap scratch regs to avoid leaking bits between processes with different \
134 + * uid/privileges. \
135 +diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
136 +index 0f83122e6676..323309963cd3 100644
137 +--- a/arch/powerpc/kernel/signal_32.c
138 ++++ b/arch/powerpc/kernel/signal_32.c
139 +@@ -454,7 +454,15 @@ static int save_user_regs(struct pt_regs *regs, struct mcontext __user *frame,
140 + if (copy_vsx_to_user(&frame->mc_vsregs, current))
141 + return 1;
142 + msr |= MSR_VSX;
143 +- }
144 ++ } else if (!ctx_has_vsx_region)
145 ++ /*
146 ++ * With a small context structure we can't hold the VSX
147 ++ * registers, hence clear the MSR value to indicate the state
148 ++ * was not saved.
149 ++ */
150 ++ msr &= ~MSR_VSX;
151 ++
152 ++
153 + #endif /* CONFIG_VSX */
154 + #ifdef CONFIG_SPE
155 + /* save spe registers */
156 +diff --git a/arch/powerpc/kernel/vio.c b/arch/powerpc/kernel/vio.c
157 +index 2d845d8199fc..56d2e72c85de 100644
158 +--- a/arch/powerpc/kernel/vio.c
159 ++++ b/arch/powerpc/kernel/vio.c
160 +@@ -1530,12 +1530,12 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
161 +
162 + dn = dev->of_node;
163 + if (!dn) {
164 +- strcat(buf, "\n");
165 ++ strcpy(buf, "\n");
166 + return strlen(buf);
167 + }
168 + cp = of_get_property(dn, "compatible", NULL);
169 + if (!cp) {
170 +- strcat(buf, "\n");
171 ++ strcpy(buf, "\n");
172 + return strlen(buf);
173 + }
174 +
175 +diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c
176 +index 3e99c149271a..7ce9cf3b6988 100644
177 +--- a/arch/powerpc/mm/slice.c
178 ++++ b/arch/powerpc/mm/slice.c
179 +@@ -258,7 +258,7 @@ static bool slice_scan_available(unsigned long addr,
180 + slice = GET_HIGH_SLICE_INDEX(addr);
181 + *boundary_addr = (slice + end) ?
182 + ((slice + end) << SLICE_HIGH_SHIFT) : SLICE_LOW_TOP;
183 +- return !!(available.high_slices & (1u << slice));
184 ++ return !!(available.high_slices & (1ul << slice));
185 + }
186 + }
187 +
188 +diff --git a/arch/powerpc/platforms/52xx/Kconfig b/arch/powerpc/platforms/52xx/Kconfig
189 +index 90f4496017e4..af54174801f7 100644
190 +--- a/arch/powerpc/platforms/52xx/Kconfig
191 ++++ b/arch/powerpc/platforms/52xx/Kconfig
192 +@@ -57,5 +57,5 @@ config PPC_MPC5200_BUGFIX
193 +
194 + config PPC_MPC5200_LPBFIFO
195 + tristate "MPC5200 LocalPlus bus FIFO driver"
196 +- depends on PPC_MPC52xx
197 ++ depends on PPC_MPC52xx && PPC_BESTCOMM
198 + select PPC_BESTCOMM_GEN_BD
199 +diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
200 +index 7816beff1db8..f75607c93e8a 100644
201 +--- a/arch/powerpc/platforms/powernv/pci-ioda.c
202 ++++ b/arch/powerpc/platforms/powernv/pci-ioda.c
203 +@@ -151,13 +151,23 @@ static int pnv_ioda_configure_pe(struct pnv_phb *phb, struct pnv_ioda_pe *pe)
204 + rid_end = pe->rid + 1;
205 + }
206 +
207 +- /* Associate PE in PELT */
208 ++ /*
209 ++ * Associate PE in PELT. We need add the PE into the
210 ++ * corresponding PELT-V as well. Otherwise, the error
211 ++ * originated from the PE might contribute to other
212 ++ * PEs.
213 ++ */
214 + rc = opal_pci_set_pe(phb->opal_id, pe->pe_number, pe->rid,
215 + bcomp, dcomp, fcomp, OPAL_MAP_PE);
216 + if (rc) {
217 + pe_err(pe, "OPAL error %ld trying to setup PELT table\n", rc);
218 + return -ENXIO;
219 + }
220 ++
221 ++ rc = opal_pci_set_peltv(phb->opal_id, pe->pe_number,
222 ++ pe->pe_number, OPAL_ADD_PE_TO_DOMAIN);
223 ++ if (rc)
224 ++ pe_warn(pe, "OPAL error %d adding self to PELTV\n", rc);
225 + opal_pci_eeh_freeze_clear(phb->opal_id, pe->pe_number,
226 + OPAL_EEH_ACTION_CLEAR_FREEZE_ALL);
227 +
228 +diff --git a/arch/s390/crypto/aes_s390.c b/arch/s390/crypto/aes_s390.c
229 +index b4dbade8ca24..2e4b5be31a1b 100644
230 +--- a/arch/s390/crypto/aes_s390.c
231 ++++ b/arch/s390/crypto/aes_s390.c
232 +@@ -35,7 +35,6 @@ static u8 *ctrblk;
233 + static char keylen_flag;
234 +
235 + struct s390_aes_ctx {
236 +- u8 iv[AES_BLOCK_SIZE];
237 + u8 key[AES_MAX_KEY_SIZE];
238 + long enc;
239 + long dec;
240 +@@ -441,30 +440,36 @@ static int cbc_aes_set_key(struct crypto_tfm *tfm, const u8 *in_key,
241 + return aes_set_key(tfm, in_key, key_len);
242 + }
243 +
244 +-static int cbc_aes_crypt(struct blkcipher_desc *desc, long func, void *param,
245 ++static int cbc_aes_crypt(struct blkcipher_desc *desc, long func,
246 + struct blkcipher_walk *walk)
247 + {
248 ++ struct s390_aes_ctx *sctx = crypto_blkcipher_ctx(desc->tfm);
249 + int ret = blkcipher_walk_virt(desc, walk);
250 + unsigned int nbytes = walk->nbytes;
251 ++ struct {
252 ++ u8 iv[AES_BLOCK_SIZE];
253 ++ u8 key[AES_MAX_KEY_SIZE];
254 ++ } param;
255 +
256 + if (!nbytes)
257 + goto out;
258 +
259 +- memcpy(param, walk->iv, AES_BLOCK_SIZE);
260 ++ memcpy(param.iv, walk->iv, AES_BLOCK_SIZE);
261 ++ memcpy(param.key, sctx->key, sctx->key_len);
262 + do {
263 + /* only use complete blocks */
264 + unsigned int n = nbytes & ~(AES_BLOCK_SIZE - 1);
265 + u8 *out = walk->dst.virt.addr;
266 + u8 *in = walk->src.virt.addr;
267 +
268 +- ret = crypt_s390_kmc(func, param, out, in, n);
269 ++ ret = crypt_s390_kmc(func, &param, out, in, n);
270 + if (ret < 0 || ret != n)
271 + return -EIO;
272 +
273 + nbytes &= AES_BLOCK_SIZE - 1;
274 + ret = blkcipher_walk_done(desc, walk, nbytes);
275 + } while ((nbytes = walk->nbytes));
276 +- memcpy(walk->iv, param, AES_BLOCK_SIZE);
277 ++ memcpy(walk->iv, param.iv, AES_BLOCK_SIZE);
278 +
279 + out:
280 + return ret;
281 +@@ -481,7 +486,7 @@ static int cbc_aes_encrypt(struct blkcipher_desc *desc,
282 + return fallback_blk_enc(desc, dst, src, nbytes);
283 +
284 + blkcipher_walk_init(&walk, dst, src, nbytes);
285 +- return cbc_aes_crypt(desc, sctx->enc, sctx->iv, &walk);
286 ++ return cbc_aes_crypt(desc, sctx->enc, &walk);
287 + }
288 +
289 + static int cbc_aes_decrypt(struct blkcipher_desc *desc,
290 +@@ -495,7 +500,7 @@ static int cbc_aes_decrypt(struct blkcipher_desc *desc,
291 + return fallback_blk_dec(desc, dst, src, nbytes);
292 +
293 + blkcipher_walk_init(&walk, dst, src, nbytes);
294 +- return cbc_aes_crypt(desc, sctx->dec, sctx->iv, &walk);
295 ++ return cbc_aes_crypt(desc, sctx->dec, &walk);
296 + }
297 +
298 + static struct crypto_alg cbc_aes_alg = {
299 +diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c
300 +index 4f977d0d25c2..14647fe09d0c 100644
301 +--- a/arch/s390/kernel/smp.c
302 ++++ b/arch/s390/kernel/smp.c
303 +@@ -933,7 +933,7 @@ static ssize_t show_idle_count(struct device *dev,
304 + idle_count = ACCESS_ONCE(idle->idle_count);
305 + if (ACCESS_ONCE(idle->clock_idle_enter))
306 + idle_count++;
307 +- } while ((sequence & 1) || (idle->sequence != sequence));
308 ++ } while ((sequence & 1) || (ACCESS_ONCE(idle->sequence) != sequence));
309 + return sprintf(buf, "%llu\n", idle_count);
310 + }
311 + static DEVICE_ATTR(idle_count, 0444, show_idle_count, NULL);
312 +@@ -951,7 +951,7 @@ static ssize_t show_idle_time(struct device *dev,
313 + idle_time = ACCESS_ONCE(idle->idle_time);
314 + idle_enter = ACCESS_ONCE(idle->clock_idle_enter);
315 + idle_exit = ACCESS_ONCE(idle->clock_idle_exit);
316 +- } while ((sequence & 1) || (idle->sequence != sequence));
317 ++ } while ((sequence & 1) || (ACCESS_ONCE(idle->sequence) != sequence));
318 + idle_time += idle_enter ? ((idle_exit ? : now) - idle_enter) : 0;
319 + return sprintf(buf, "%llu\n", idle_time >> 12);
320 + }
321 +diff --git a/arch/s390/kernel/vtime.c b/arch/s390/kernel/vtime.c
322 +index 3fb09359eda6..737d50caa4fe 100644
323 +--- a/arch/s390/kernel/vtime.c
324 ++++ b/arch/s390/kernel/vtime.c
325 +@@ -190,7 +190,7 @@ cputime64_t s390_get_idle_time(int cpu)
326 + sequence = ACCESS_ONCE(idle->sequence);
327 + idle_enter = ACCESS_ONCE(idle->clock_idle_enter);
328 + idle_exit = ACCESS_ONCE(idle->clock_idle_exit);
329 +- } while ((sequence & 1) || (idle->sequence != sequence));
330 ++ } while ((sequence & 1) || (ACCESS_ONCE(idle->sequence) != sequence));
331 + return idle_enter ? ((idle_exit ?: now) - idle_enter) : 0;
332 + }
333 +
334 +diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
335 +index 42a392a9fd02..d4bdd253fea7 100644
336 +--- a/arch/x86/kernel/ftrace.c
337 ++++ b/arch/x86/kernel/ftrace.c
338 +@@ -248,6 +248,15 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
339 + return ret;
340 + }
341 +
342 ++static int is_ftrace_caller(unsigned long ip)
343 ++{
344 ++ if (ip == (unsigned long)(&ftrace_call) ||
345 ++ ip == (unsigned long)(&ftrace_regs_call))
346 ++ return 1;
347 ++
348 ++ return 0;
349 ++}
350 ++
351 + /*
352 + * A breakpoint was added to the code address we are about to
353 + * modify, and this is the handle that will just skip over it.
354 +@@ -257,10 +266,13 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
355 + */
356 + int ftrace_int3_handler(struct pt_regs *regs)
357 + {
358 ++ unsigned long ip;
359 ++
360 + if (WARN_ON_ONCE(!regs))
361 + return 0;
362 +
363 +- if (!ftrace_location(regs->ip - 1))
364 ++ ip = regs->ip - 1;
365 ++ if (!ftrace_location(ip) && !is_ftrace_caller(ip))
366 + return 0;
367 +
368 + regs->ip += MCOUNT_INSN_SIZE - 1;
369 +diff --git a/arch/x86/kernel/microcode_amd.c b/arch/x86/kernel/microcode_amd.c
370 +index efdec7cd8e01..b516dfb411ec 100644
371 +--- a/arch/x86/kernel/microcode_amd.c
372 ++++ b/arch/x86/kernel/microcode_amd.c
373 +@@ -430,7 +430,7 @@ static enum ucode_state request_microcode_amd(int cpu, struct device *device,
374 + snprintf(fw_name, sizeof(fw_name), "amd-ucode/microcode_amd_fam%.2xh.bin", c->x86);
375 +
376 + if (request_firmware(&fw, (const char *)fw_name, device)) {
377 +- pr_err("failed to load file %s\n", fw_name);
378 ++ pr_debug("failed to load file %s\n", fw_name);
379 + goto out;
380 + }
381 +
382 +diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
383 +index 81a5f5e8f142..59b90379cb6a 100644
384 +--- a/arch/x86/kernel/process.c
385 ++++ b/arch/x86/kernel/process.c
386 +@@ -391,9 +391,9 @@ static void amd_e400_idle(void)
387 + * The switch back from broadcast mode needs to be
388 + * called with interrupts disabled.
389 + */
390 +- local_irq_disable();
391 +- clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_EXIT, &cpu);
392 +- local_irq_enable();
393 ++ local_irq_disable();
394 ++ clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_EXIT, &cpu);
395 ++ local_irq_enable();
396 + } else
397 + default_idle();
398 + }
399 +diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
400 +index 5953dcea752d..5484d54582ca 100644
401 +--- a/arch/x86/kvm/emulate.c
402 ++++ b/arch/x86/kvm/emulate.c
403 +@@ -4207,7 +4207,10 @@ static int decode_operand(struct x86_emulate_ctxt *ctxt, struct operand *op,
404 + case OpMem8:
405 + ctxt->memop.bytes = 1;
406 + if (ctxt->memop.type == OP_REG) {
407 +- ctxt->memop.addr.reg = decode_register(ctxt, ctxt->modrm_rm, 1);
408 ++ int highbyte_regs = ctxt->rex_prefix == 0;
409 ++
410 ++ ctxt->memop.addr.reg = decode_register(ctxt, ctxt->modrm_rm,
411 ++ highbyte_regs);
412 + fetch_register_operand(&ctxt->memop);
413 + }
414 + goto mem_common;
415 +diff --git a/block/blk-core.c b/block/blk-core.c
416 +index d5745b5833c9..45f3a51f6b56 100644
417 +--- a/block/blk-core.c
418 ++++ b/block/blk-core.c
419 +@@ -2229,6 +2229,7 @@ void blk_start_request(struct request *req)
420 + if (unlikely(blk_bidi_rq(req)))
421 + req->next_rq->resid_len = blk_rq_bytes(req->next_rq);
422 +
423 ++ BUG_ON(test_bit(REQ_ATOM_COMPLETE, &req->atomic_flags));
424 + blk_add_timer(req);
425 + }
426 + EXPORT_SYMBOL(blk_start_request);
427 +diff --git a/block/blk-settings.c b/block/blk-settings.c
428 +index c50ecf0ea3b1..53309333c2f0 100644
429 +--- a/block/blk-settings.c
430 ++++ b/block/blk-settings.c
431 +@@ -144,6 +144,7 @@ void blk_set_stacking_limits(struct queue_limits *lim)
432 + lim->discard_zeroes_data = 1;
433 + lim->max_segments = USHRT_MAX;
434 + lim->max_hw_sectors = UINT_MAX;
435 ++ lim->max_segment_size = UINT_MAX;
436 + lim->max_sectors = UINT_MAX;
437 + lim->max_write_same_sectors = UINT_MAX;
438 + }
439 +diff --git a/block/blk-timeout.c b/block/blk-timeout.c
440 +index 6e4744cbfb56..5a6296ef9a81 100644
441 +--- a/block/blk-timeout.c
442 ++++ b/block/blk-timeout.c
443 +@@ -90,8 +90,8 @@ static void blk_rq_timed_out(struct request *req)
444 + __blk_complete_request(req);
445 + break;
446 + case BLK_EH_RESET_TIMER:
447 +- blk_clear_rq_complete(req);
448 + blk_add_timer(req);
449 ++ blk_clear_rq_complete(req);
450 + break;
451 + case BLK_EH_NOT_HANDLED:
452 + /*
453 +@@ -173,7 +173,6 @@ void blk_add_timer(struct request *req)
454 + return;
455 +
456 + BUG_ON(!list_empty(&req->timeout_list));
457 +- BUG_ON(test_bit(REQ_ATOM_COMPLETE, &req->atomic_flags));
458 +
459 + /*
460 + * Some LLDs, like scsi, peek at the timeout to prevent a
461 +diff --git a/crypto/ansi_cprng.c b/crypto/ansi_cprng.c
462 +index c0bb3778f1ae..666f1962a160 100644
463 +--- a/crypto/ansi_cprng.c
464 ++++ b/crypto/ansi_cprng.c
465 +@@ -230,11 +230,11 @@ remainder:
466 + */
467 + if (byte_count < DEFAULT_BLK_SZ) {
468 + empty_rbuf:
469 +- for (; ctx->rand_data_valid < DEFAULT_BLK_SZ;
470 +- ctx->rand_data_valid++) {
471 ++ while (ctx->rand_data_valid < DEFAULT_BLK_SZ) {
472 + *ptr = ctx->rand_data[ctx->rand_data_valid];
473 + ptr++;
474 + byte_count--;
475 ++ ctx->rand_data_valid++;
476 + if (byte_count == 0)
477 + goto done;
478 + }
479 +diff --git a/drivers/acpi/acpica/exoparg1.c b/drivers/acpi/acpica/exoparg1.c
480 +index b60c877f5906..c3241b188434 100644
481 +--- a/drivers/acpi/acpica/exoparg1.c
482 ++++ b/drivers/acpi/acpica/exoparg1.c
483 +@@ -963,10 +963,17 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
484 + */
485 + return_desc =
486 + *(operand[0]->reference.where);
487 +- if (return_desc) {
488 +- acpi_ut_add_reference
489 +- (return_desc);
490 ++ if (!return_desc) {
491 ++ /*
492 ++ * Element is NULL, do not allow the dereference.
493 ++ * This provides compatibility with other ACPI
494 ++ * implementations.
495 ++ */
496 ++ return_ACPI_STATUS
497 ++ (AE_AML_UNINITIALIZED_ELEMENT);
498 + }
499 ++
500 ++ acpi_ut_add_reference(return_desc);
501 + break;
502 +
503 + default:
504 +@@ -991,11 +998,40 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
505 + acpi_namespace_node
506 + *)
507 + return_desc);
508 +- }
509 ++ if (!return_desc) {
510 ++ break;
511 ++ }
512 +
513 +- /* Add another reference to the object! */
514 ++ /*
515 ++ * June 2013:
516 ++ * buffer_fields/field_units require additional resolution
517 ++ */
518 ++ switch (return_desc->common.type) {
519 ++ case ACPI_TYPE_BUFFER_FIELD:
520 ++ case ACPI_TYPE_LOCAL_REGION_FIELD:
521 ++ case ACPI_TYPE_LOCAL_BANK_FIELD:
522 ++ case ACPI_TYPE_LOCAL_INDEX_FIELD:
523 +
524 +- acpi_ut_add_reference(return_desc);
525 ++ status =
526 ++ acpi_ex_read_data_from_field
527 ++ (walk_state, return_desc,
528 ++ &temp_desc);
529 ++ if (ACPI_FAILURE(status)) {
530 ++ goto cleanup;
531 ++ }
532 ++
533 ++ return_desc = temp_desc;
534 ++ break;
535 ++
536 ++ default:
537 ++
538 ++ /* Add another reference to the object */
539 ++
540 ++ acpi_ut_add_reference
541 ++ (return_desc);
542 ++ break;
543 ++ }
544 ++ }
545 + break;
546 +
547 + default:
548 +diff --git a/drivers/acpi/acpica/exstore.c b/drivers/acpi/acpica/exstore.c
549 +index 93c6049c2d75..b1ad39443cb6 100644
550 +--- a/drivers/acpi/acpica/exstore.c
551 ++++ b/drivers/acpi/acpica/exstore.c
552 +@@ -57,6 +57,11 @@ acpi_ex_store_object_to_index(union acpi_operand_object *val_desc,
553 + union acpi_operand_object *dest_desc,
554 + struct acpi_walk_state *walk_state);
555 +
556 ++static acpi_status
557 ++acpi_ex_store_direct_to_node(union acpi_operand_object *source_desc,
558 ++ struct acpi_namespace_node *node,
559 ++ struct acpi_walk_state *walk_state);
560 ++
561 + /*******************************************************************************
562 + *
563 + * FUNCTION: acpi_ex_store
564 +@@ -376,7 +381,11 @@ acpi_ex_store_object_to_index(union acpi_operand_object *source_desc,
565 + * When storing into an object the data is converted to the
566 + * target object type then stored in the object. This means
567 + * that the target object type (for an initialized target) will
568 +- * not be changed by a store operation.
569 ++ * not be changed by a store operation. A copy_object can change
570 ++ * the target type, however.
571 ++ *
572 ++ * The implicit_conversion flag is set to NO/FALSE only when
573 ++ * storing to an arg_x -- as per the rules of the ACPI spec.
574 + *
575 + * Assumes parameters are already validated.
576 + *
577 +@@ -400,7 +409,7 @@ acpi_ex_store_object_to_node(union acpi_operand_object *source_desc,
578 + target_type = acpi_ns_get_type(node);
579 + target_desc = acpi_ns_get_attached_object(node);
580 +
581 +- ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Storing %p(%s) into node %p(%s)\n",
582 ++ ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Storing %p (%s) to node %p (%s)\n",
583 + source_desc,
584 + acpi_ut_get_object_type_name(source_desc), node,
585 + acpi_ut_get_type_name(target_type)));
586 +@@ -414,46 +423,31 @@ acpi_ex_store_object_to_node(union acpi_operand_object *source_desc,
587 + return_ACPI_STATUS(status);
588 + }
589 +
590 +- /* If no implicit conversion, drop into the default case below */
591 +-
592 +- if ((!implicit_conversion) ||
593 +- ((walk_state->opcode == AML_COPY_OP) &&
594 +- (target_type != ACPI_TYPE_LOCAL_REGION_FIELD) &&
595 +- (target_type != ACPI_TYPE_LOCAL_BANK_FIELD) &&
596 +- (target_type != ACPI_TYPE_LOCAL_INDEX_FIELD))) {
597 +- /*
598 +- * Force execution of default (no implicit conversion). Note:
599 +- * copy_object does not perform an implicit conversion, as per the ACPI
600 +- * spec -- except in case of region/bank/index fields -- because these
601 +- * objects must retain their original type permanently.
602 +- */
603 +- target_type = ACPI_TYPE_ANY;
604 +- }
605 +-
606 + /* Do the actual store operation */
607 +
608 + switch (target_type) {
609 +- case ACPI_TYPE_BUFFER_FIELD:
610 +- case ACPI_TYPE_LOCAL_REGION_FIELD:
611 +- case ACPI_TYPE_LOCAL_BANK_FIELD:
612 +- case ACPI_TYPE_LOCAL_INDEX_FIELD:
613 +-
614 +- /* For fields, copy the source data to the target field. */
615 +-
616 +- status = acpi_ex_write_data_to_field(source_desc, target_desc,
617 +- &walk_state->result_obj);
618 +- break;
619 +-
620 + case ACPI_TYPE_INTEGER:
621 + case ACPI_TYPE_STRING:
622 + case ACPI_TYPE_BUFFER:
623 +
624 + /*
625 +- * These target types are all of type Integer/String/Buffer, and
626 +- * therefore support implicit conversion before the store.
627 +- *
628 +- * Copy and/or convert the source object to a new target object
629 ++ * The simple data types all support implicit source operand
630 ++ * conversion before the store.
631 + */
632 ++
633 ++ if ((walk_state->opcode == AML_COPY_OP) || !implicit_conversion) {
634 ++ /*
635 ++ * However, copy_object and Stores to arg_x do not perform
636 ++ * an implicit conversion, as per the ACPI specification.
637 ++ * A direct store is performed instead.
638 ++ */
639 ++ status = acpi_ex_store_direct_to_node(source_desc, node,
640 ++ walk_state);
641 ++ break;
642 ++ }
643 ++
644 ++ /* Store with implicit source operand conversion support */
645 ++
646 + status =
647 + acpi_ex_store_object_to_object(source_desc, target_desc,
648 + &new_desc, walk_state);
649 +@@ -467,13 +461,12 @@ acpi_ex_store_object_to_node(union acpi_operand_object *source_desc,
650 + * the Name's type to that of the value being stored in it.
651 + * source_desc reference count is incremented by attach_object.
652 + *
653 +- * Note: This may change the type of the node if an explicit store
654 +- * has been performed such that the node/object type has been
655 +- * changed.
656 ++ * Note: This may change the type of the node if an explicit
657 ++ * store has been performed such that the node/object type
658 ++ * has been changed.
659 + */
660 +- status =
661 +- acpi_ns_attach_object(node, new_desc,
662 +- new_desc->common.type);
663 ++ status = acpi_ns_attach_object(node, new_desc,
664 ++ new_desc->common.type);
665 +
666 + ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
667 + "Store %s into %s via Convert/Attach\n",
668 +@@ -484,38 +477,83 @@ acpi_ex_store_object_to_node(union acpi_operand_object *source_desc,
669 + }
670 + break;
671 +
672 +- default:
673 +-
674 +- ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
675 +- "Storing [%s] (%p) directly into node [%s] (%p)"
676 +- " with no implicit conversion\n",
677 +- acpi_ut_get_object_type_name(source_desc),
678 +- source_desc,
679 +- acpi_ut_get_object_type_name(target_desc),
680 +- node));
681 ++ case ACPI_TYPE_BUFFER_FIELD:
682 ++ case ACPI_TYPE_LOCAL_REGION_FIELD:
683 ++ case ACPI_TYPE_LOCAL_BANK_FIELD:
684 ++ case ACPI_TYPE_LOCAL_INDEX_FIELD:
685 ++ /*
686 ++ * For all fields, always write the source data to the target
687 ++ * field. Any required implicit source operand conversion is
688 ++ * performed in the function below as necessary. Note, field
689 ++ * objects must retain their original type permanently.
690 ++ */
691 ++ status = acpi_ex_write_data_to_field(source_desc, target_desc,
692 ++ &walk_state->result_obj);
693 ++ break;
694 +
695 ++ default:
696 + /*
697 + * No conversions for all other types. Directly store a copy of
698 +- * the source object. NOTE: This is a departure from the ACPI
699 +- * spec, which states "If conversion is impossible, abort the
700 +- * running control method".
701 ++ * the source object. This is the ACPI spec-defined behavior for
702 ++ * the copy_object operator.
703 + *
704 +- * This code implements "If conversion is impossible, treat the
705 +- * Store operation as a CopyObject".
706 ++ * NOTE: For the Store operator, this is a departure from the
707 ++ * ACPI spec, which states "If conversion is impossible, abort
708 ++ * the running control method". Instead, this code implements
709 ++ * "If conversion is impossible, treat the Store operation as
710 ++ * a CopyObject".
711 + */
712 +- status =
713 +- acpi_ut_copy_iobject_to_iobject(source_desc, &new_desc,
714 +- walk_state);
715 +- if (ACPI_FAILURE(status)) {
716 +- return_ACPI_STATUS(status);
717 +- }
718 +-
719 +- status =
720 +- acpi_ns_attach_object(node, new_desc,
721 +- new_desc->common.type);
722 +- acpi_ut_remove_reference(new_desc);
723 ++ status = acpi_ex_store_direct_to_node(source_desc, node,
724 ++ walk_state);
725 + break;
726 + }
727 +
728 + return_ACPI_STATUS(status);
729 + }
730 ++
731 ++/*******************************************************************************
732 ++ *
733 ++ * FUNCTION: acpi_ex_store_direct_to_node
734 ++ *
735 ++ * PARAMETERS: source_desc - Value to be stored
736 ++ * node - Named object to receive the value
737 ++ * walk_state - Current walk state
738 ++ *
739 ++ * RETURN: Status
740 ++ *
741 ++ * DESCRIPTION: "Store" an object directly to a node. This involves a copy
742 ++ * and an attach.
743 ++ *
744 ++ ******************************************************************************/
745 ++
746 ++static acpi_status
747 ++acpi_ex_store_direct_to_node(union acpi_operand_object *source_desc,
748 ++ struct acpi_namespace_node *node,
749 ++ struct acpi_walk_state *walk_state)
750 ++{
751 ++ acpi_status status;
752 ++ union acpi_operand_object *new_desc;
753 ++
754 ++ ACPI_FUNCTION_TRACE(ex_store_direct_to_node);
755 ++
756 ++ ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
757 ++ "Storing [%s] (%p) directly into node [%s] (%p)"
758 ++ " with no implicit conversion\n",
759 ++ acpi_ut_get_object_type_name(source_desc),
760 ++ source_desc, acpi_ut_get_type_name(node->type),
761 ++ node));
762 ++
763 ++ /* Copy the source object to a new object */
764 ++
765 ++ status =
766 ++ acpi_ut_copy_iobject_to_iobject(source_desc, &new_desc, walk_state);
767 ++ if (ACPI_FAILURE(status)) {
768 ++ return_ACPI_STATUS(status);
769 ++ }
770 ++
771 ++ /* Attach the new object to the node */
772 ++
773 ++ status = acpi_ns_attach_object(node, new_desc, new_desc->common.type);
774 ++ acpi_ut_remove_reference(new_desc);
775 ++ return_ACPI_STATUS(status);
776 ++}
777 +diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
778 +index 45af90a1ec1b..1ad5a4f9e0c3 100644
779 +--- a/drivers/acpi/ec.c
780 ++++ b/drivers/acpi/ec.c
781 +@@ -175,9 +175,10 @@ static void start_transaction(struct acpi_ec *ec)
782 + static void advance_transaction(struct acpi_ec *ec, u8 status)
783 + {
784 + unsigned long flags;
785 +- struct transaction *t = ec->curr;
786 ++ struct transaction *t;
787 +
788 + spin_lock_irqsave(&ec->lock, flags);
789 ++ t = ec->curr;
790 + if (!t)
791 + goto unlock;
792 + if (t->wlen > t->wi) {
793 +diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
794 +index e427dc516c76..e36842b9e1fa 100644
795 +--- a/drivers/acpi/pci_root.c
796 ++++ b/drivers/acpi/pci_root.c
797 +@@ -614,9 +614,12 @@ static void handle_root_bridge_removal(struct acpi_device *device)
798 + ej_event->device = device;
799 + ej_event->event = ACPI_NOTIFY_EJECT_REQUEST;
800 +
801 ++ get_device(&device->dev);
802 + status = acpi_os_hotplug_execute(acpi_bus_hot_remove_device, ej_event);
803 +- if (ACPI_FAILURE(status))
804 ++ if (ACPI_FAILURE(status)) {
805 ++ put_device(&device->dev);
806 + kfree(ej_event);
807 ++ }
808 + }
809 +
810 + static void _handle_hotplug_event_root(struct work_struct *work)
811 +diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
812 +index eb133c77aadb..4056d3175178 100644
813 +--- a/drivers/acpi/processor_idle.c
814 ++++ b/drivers/acpi/processor_idle.c
815 +@@ -121,17 +121,10 @@ static struct dmi_system_id __cpuinitdata processor_power_dmi_table[] = {
816 + */
817 + static void acpi_safe_halt(void)
818 + {
819 +- current_thread_info()->status &= ~TS_POLLING;
820 +- /*
821 +- * TS_POLLING-cleared state must be visible before we
822 +- * test NEED_RESCHED:
823 +- */
824 +- smp_mb();
825 +- if (!need_resched()) {
826 ++ if (!tif_need_resched()) {
827 + safe_halt();
828 + local_irq_disable();
829 + }
830 +- current_thread_info()->status |= TS_POLLING;
831 + }
832 +
833 + #ifdef ARCH_APICTIMER_STOPS_ON_C3
834 +@@ -739,6 +732,11 @@ static int acpi_idle_enter_c1(struct cpuidle_device *dev,
835 + if (unlikely(!pr))
836 + return -EINVAL;
837 +
838 ++ if (cx->entry_method == ACPI_CSTATE_FFH) {
839 ++ if (current_set_polling_and_test())
840 ++ return -EINVAL;
841 ++ }
842 ++
843 + lapic_timer_state_broadcast(pr, cx, 1);
844 + acpi_idle_do_entry(cx);
845 +
846 +@@ -792,18 +790,9 @@ static int acpi_idle_enter_simple(struct cpuidle_device *dev,
847 + if (unlikely(!pr))
848 + return -EINVAL;
849 +
850 +- if (cx->entry_method != ACPI_CSTATE_FFH) {
851 +- current_thread_info()->status &= ~TS_POLLING;
852 +- /*
853 +- * TS_POLLING-cleared state must be visible before we test
854 +- * NEED_RESCHED:
855 +- */
856 +- smp_mb();
857 +-
858 +- if (unlikely(need_resched())) {
859 +- current_thread_info()->status |= TS_POLLING;
860 ++ if (cx->entry_method == ACPI_CSTATE_FFH) {
861 ++ if (current_set_polling_and_test())
862 + return -EINVAL;
863 +- }
864 + }
865 +
866 + /*
867 +@@ -821,9 +810,6 @@ static int acpi_idle_enter_simple(struct cpuidle_device *dev,
868 +
869 + sched_clock_idle_wakeup_event(0);
870 +
871 +- if (cx->entry_method != ACPI_CSTATE_FFH)
872 +- current_thread_info()->status |= TS_POLLING;
873 +-
874 + lapic_timer_state_broadcast(pr, cx, 0);
875 + return index;
876 + }
877 +@@ -860,18 +846,9 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev,
878 + }
879 + }
880 +
881 +- if (cx->entry_method != ACPI_CSTATE_FFH) {
882 +- current_thread_info()->status &= ~TS_POLLING;
883 +- /*
884 +- * TS_POLLING-cleared state must be visible before we test
885 +- * NEED_RESCHED:
886 +- */
887 +- smp_mb();
888 +-
889 +- if (unlikely(need_resched())) {
890 +- current_thread_info()->status |= TS_POLLING;
891 ++ if (cx->entry_method == ACPI_CSTATE_FFH) {
892 ++ if (current_set_polling_and_test())
893 + return -EINVAL;
894 +- }
895 + }
896 +
897 + acpi_unlazy_tlb(smp_processor_id());
898 +@@ -917,9 +894,6 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev,
899 +
900 + sched_clock_idle_wakeup_event(0);
901 +
902 +- if (cx->entry_method != ACPI_CSTATE_FFH)
903 +- current_thread_info()->status |= TS_POLLING;
904 +-
905 + lapic_timer_state_broadcast(pr, cx, 0);
906 + return index;
907 + }
908 +diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
909 +index af658b2ff279..362f0c2aa1ea 100644
910 +--- a/drivers/acpi/scan.c
911 ++++ b/drivers/acpi/scan.c
912 +@@ -244,8 +244,6 @@ static void acpi_scan_bus_device_check(acpi_handle handle, u32 ost_source)
913 + goto out;
914 + }
915 + }
916 +- acpi_evaluate_hotplug_ost(handle, ost_source,
917 +- ACPI_OST_SC_INSERT_IN_PROGRESS, NULL);
918 + error = acpi_bus_scan(handle);
919 + if (error) {
920 + acpi_handle_warn(handle, "Namespace scan failure\n");
921 +diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
922 +index 0e4b96b62c75..055dfdfd7348 100644
923 +--- a/drivers/acpi/video.c
924 ++++ b/drivers/acpi/video.c
925 +@@ -846,7 +846,7 @@ acpi_video_init_brightness(struct acpi_video_device *device)
926 + for (i = 2; i < br->count; i++)
927 + if (level_old == br->levels[i])
928 + break;
929 +- if (i == br->count)
930 ++ if (i == br->count || !level)
931 + level = max_level;
932 + }
933 +
934 +diff --git a/drivers/block/brd.c b/drivers/block/brd.c
935 +index 9bf4371755f2..d91f1a56e861 100644
936 +--- a/drivers/block/brd.c
937 ++++ b/drivers/block/brd.c
938 +@@ -545,7 +545,7 @@ static struct kobject *brd_probe(dev_t dev, int *part, void *data)
939 +
940 + mutex_lock(&brd_devices_mutex);
941 + brd = brd_init_one(MINOR(dev) >> part_shift);
942 +- kobj = brd ? get_disk(brd->brd_disk) : ERR_PTR(-ENOMEM);
943 ++ kobj = brd ? get_disk(brd->brd_disk) : NULL;
944 + mutex_unlock(&brd_devices_mutex);
945 +
946 + *part = 0;
947 +diff --git a/drivers/block/loop.c b/drivers/block/loop.c
948 +index d92d50fd84b7..00559736cee4 100644
949 +--- a/drivers/block/loop.c
950 ++++ b/drivers/block/loop.c
951 +@@ -1741,7 +1741,7 @@ static struct kobject *loop_probe(dev_t dev, int *part, void *data)
952 + if (err < 0)
953 + err = loop_add(&lo, MINOR(dev) >> part_shift);
954 + if (err < 0)
955 +- kobj = ERR_PTR(err);
956 ++ kobj = NULL;
957 + else
958 + kobj = get_disk(lo->lo_disk);
959 + mutex_unlock(&loop_index_mutex);
960 +diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
961 +index b95159b33c39..eb760a218da4 100644
962 +--- a/drivers/firmware/dmi_scan.c
963 ++++ b/drivers/firmware/dmi_scan.c
964 +@@ -551,9 +551,15 @@ static bool dmi_matches(const struct dmi_system_id *dmi)
965 + int s = dmi->matches[i].slot;
966 + if (s == DMI_NONE)
967 + break;
968 +- if (dmi_ident[s]
969 +- && strstr(dmi_ident[s], dmi->matches[i].substr))
970 +- continue;
971 ++ if (dmi_ident[s]) {
972 ++ if (!dmi->matches[i].exact_match &&
973 ++ strstr(dmi_ident[s], dmi->matches[i].substr))
974 ++ continue;
975 ++ else if (dmi->matches[i].exact_match &&
976 ++ !strcmp(dmi_ident[s], dmi->matches[i].substr))
977 ++ continue;
978 ++ }
979 ++
980 + /* No match */
981 + return false;
982 + }
983 +diff --git a/drivers/gpu/drm/i915/intel_lvds.c b/drivers/gpu/drm/i915/intel_lvds.c
984 +index 29412cc89c7a..f77d42f74427 100644
985 +--- a/drivers/gpu/drm/i915/intel_lvds.c
986 ++++ b/drivers/gpu/drm/i915/intel_lvds.c
987 +@@ -869,6 +869,30 @@ static const struct dmi_system_id intel_no_lvds[] = {
988 + DMI_MATCH(DMI_PRODUCT_NAME, "ESPRIMO Q900"),
989 + },
990 + },
991 ++ {
992 ++ .callback = intel_no_lvds_dmi_callback,
993 ++ .ident = "Intel D410PT",
994 ++ .matches = {
995 ++ DMI_MATCH(DMI_BOARD_VENDOR, "Intel"),
996 ++ DMI_MATCH(DMI_BOARD_NAME, "D410PT"),
997 ++ },
998 ++ },
999 ++ {
1000 ++ .callback = intel_no_lvds_dmi_callback,
1001 ++ .ident = "Intel D425KT",
1002 ++ .matches = {
1003 ++ DMI_MATCH(DMI_BOARD_VENDOR, "Intel"),
1004 ++ DMI_EXACT_MATCH(DMI_BOARD_NAME, "D425KT"),
1005 ++ },
1006 ++ },
1007 ++ {
1008 ++ .callback = intel_no_lvds_dmi_callback,
1009 ++ .ident = "Intel D510MO",
1010 ++ .matches = {
1011 ++ DMI_MATCH(DMI_BOARD_VENDOR, "Intel"),
1012 ++ DMI_EXACT_MATCH(DMI_BOARD_NAME, "D510MO"),
1013 ++ },
1014 ++ },
1015 +
1016 + { } /* terminating entry */
1017 + };
1018 +diff --git a/drivers/gpu/drm/nouveau/core/engine/disp/hdanva3.c b/drivers/gpu/drm/nouveau/core/engine/disp/hdanva3.c
1019 +index 373dbcc523b2..a19e7d79b847 100644
1020 +--- a/drivers/gpu/drm/nouveau/core/engine/disp/hdanva3.c
1021 ++++ b/drivers/gpu/drm/nouveau/core/engine/disp/hdanva3.c
1022 +@@ -36,6 +36,8 @@ nva3_hda_eld(struct nv50_disp_priv *priv, int or, u8 *data, u32 size)
1023 + if (data && data[0]) {
1024 + for (i = 0; i < size; i++)
1025 + nv_wr32(priv, 0x61c440 + soff, (i << 8) | data[i]);
1026 ++ for (; i < 0x60; i++)
1027 ++ nv_wr32(priv, 0x61c440 + soff, (i << 8));
1028 + nv_mask(priv, 0x61c448 + soff, 0x80000003, 0x80000003);
1029 + } else
1030 + if (data) {
1031 +diff --git a/drivers/gpu/drm/nouveau/core/engine/disp/hdanvd0.c b/drivers/gpu/drm/nouveau/core/engine/disp/hdanvd0.c
1032 +index dc57e24fc1df..717639386ced 100644
1033 +--- a/drivers/gpu/drm/nouveau/core/engine/disp/hdanvd0.c
1034 ++++ b/drivers/gpu/drm/nouveau/core/engine/disp/hdanvd0.c
1035 +@@ -41,6 +41,8 @@ nvd0_hda_eld(struct nv50_disp_priv *priv, int or, u8 *data, u32 size)
1036 + if (data && data[0]) {
1037 + for (i = 0; i < size; i++)
1038 + nv_wr32(priv, 0x10ec00 + soff, (i << 8) | data[i]);
1039 ++ for (; i < 0x60; i++)
1040 ++ nv_wr32(priv, 0x10ec00 + soff, (i << 8));
1041 + nv_mask(priv, 0x10ec10 + soff, 0x80000003, 0x80000003);
1042 + } else
1043 + if (data) {
1044 +diff --git a/drivers/gpu/drm/nouveau/core/engine/disp/sornv50.c b/drivers/gpu/drm/nouveau/core/engine/disp/sornv50.c
1045 +index ab1e918469a8..526b75242899 100644
1046 +--- a/drivers/gpu/drm/nouveau/core/engine/disp/sornv50.c
1047 ++++ b/drivers/gpu/drm/nouveau/core/engine/disp/sornv50.c
1048 +@@ -47,14 +47,8 @@ int
1049 + nv50_sor_mthd(struct nouveau_object *object, u32 mthd, void *args, u32 size)
1050 + {
1051 + struct nv50_disp_priv *priv = (void *)object->engine;
1052 +- struct nouveau_bios *bios = nouveau_bios(priv);
1053 +- const u16 type = (mthd & NV50_DISP_SOR_MTHD_TYPE) >> 12;
1054 + const u8 head = (mthd & NV50_DISP_SOR_MTHD_HEAD) >> 3;
1055 +- const u8 link = (mthd & NV50_DISP_SOR_MTHD_LINK) >> 2;
1056 + const u8 or = (mthd & NV50_DISP_SOR_MTHD_OR);
1057 +- const u16 mask = (0x0100 << head) | (0x0040 << link) | (0x0001 << or);
1058 +- struct dcb_output outp;
1059 +- u8 ver, hdr;
1060 + u32 data;
1061 + int ret = -EINVAL;
1062 +
1063 +@@ -62,8 +56,6 @@ nv50_sor_mthd(struct nouveau_object *object, u32 mthd, void *args, u32 size)
1064 + return -EINVAL;
1065 + data = *(u32 *)args;
1066 +
1067 +- if (type && !dcb_outp_match(bios, type, mask, &ver, &hdr, &outp))
1068 +- return -ENODEV;
1069 +
1070 + switch (mthd & ~0x3f) {
1071 + case NV50_DISP_SOR_PWR:
1072 +diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
1073 +index 8eeb141c85ac..74813130d211 100644
1074 +--- a/drivers/hwmon/lm90.c
1075 ++++ b/drivers/hwmon/lm90.c
1076 +@@ -278,7 +278,7 @@ static const struct lm90_params lm90_params[] = {
1077 + [max6696] = {
1078 + .flags = LM90_HAVE_EMERGENCY
1079 + | LM90_HAVE_EMERGENCY_ALARM | LM90_HAVE_TEMP3,
1080 +- .alert_alarms = 0x187c,
1081 ++ .alert_alarms = 0x1c7c,
1082 + .max_convrate = 6,
1083 + .reg_local_ext = MAX6657_REG_R_LOCAL_TEMPL,
1084 + },
1085 +@@ -1500,19 +1500,22 @@ static void lm90_alert(struct i2c_client *client, unsigned int flag)
1086 + if ((alarms & 0x7f) == 0 && (alarms2 & 0xfe) == 0) {
1087 + dev_info(&client->dev, "Everything OK\n");
1088 + } else {
1089 +- if (alarms & 0x61)
1090 ++ if ((alarms & 0x61) || (alarms2 & 0x80))
1091 + dev_warn(&client->dev,
1092 + "temp%d out of range, please check!\n", 1);
1093 +- if (alarms & 0x1a)
1094 ++ if ((alarms & 0x1a) || (alarms2 & 0x20))
1095 + dev_warn(&client->dev,
1096 + "temp%d out of range, please check!\n", 2);
1097 + if (alarms & 0x04)
1098 + dev_warn(&client->dev,
1099 + "temp%d diode open, please check!\n", 2);
1100 +
1101 +- if (alarms2 & 0x18)
1102 ++ if (alarms2 & 0x5a)
1103 + dev_warn(&client->dev,
1104 + "temp%d out of range, please check!\n", 3);
1105 ++ if (alarms2 & 0x04)
1106 ++ dev_warn(&client->dev,
1107 ++ "temp%d diode open, please check!\n", 3);
1108 +
1109 + /*
1110 + * Disable ALERT# output, because these chips don't implement
1111 +diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c
1112 +index fa6964d8681a..f116d664b473 100644
1113 +--- a/drivers/idle/intel_idle.c
1114 ++++ b/drivers/idle/intel_idle.c
1115 +@@ -359,7 +359,7 @@ static int intel_idle(struct cpuidle_device *dev,
1116 + if (!(lapic_timer_reliable_states & (1 << (cstate))))
1117 + clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_ENTER, &cpu);
1118 +
1119 +- if (!need_resched()) {
1120 ++ if (!current_set_polling_and_test()) {
1121 +
1122 + __monitor((void *)&current_thread_info()->flags, 0, 0);
1123 + smp_mb();
1124 +diff --git a/drivers/misc/mei/nfc.c b/drivers/misc/mei/nfc.c
1125 +index d0c6907dfd92..994ca4aff1a3 100644
1126 +--- a/drivers/misc/mei/nfc.c
1127 ++++ b/drivers/misc/mei/nfc.c
1128 +@@ -485,8 +485,11 @@ int mei_nfc_host_init(struct mei_device *dev)
1129 + if (ndev->cl_info)
1130 + return 0;
1131 +
1132 +- cl_info = mei_cl_allocate(dev);
1133 +- cl = mei_cl_allocate(dev);
1134 ++ ndev->cl_info = mei_cl_allocate(dev);
1135 ++ ndev->cl = mei_cl_allocate(dev);
1136 ++
1137 ++ cl = ndev->cl;
1138 ++ cl_info = ndev->cl_info;
1139 +
1140 + if (!cl || !cl_info) {
1141 + ret = -ENOMEM;
1142 +@@ -527,10 +530,9 @@ int mei_nfc_host_init(struct mei_device *dev)
1143 +
1144 + cl->device_uuid = mei_nfc_guid;
1145 +
1146 ++
1147 + list_add_tail(&cl->device_link, &dev->device_list);
1148 +
1149 +- ndev->cl_info = cl_info;
1150 +- ndev->cl = cl;
1151 + ndev->req_id = 1;
1152 +
1153 + INIT_WORK(&ndev->init_work, mei_nfc_init);
1154 +diff --git a/drivers/net/can/c_can/c_can.c b/drivers/net/can/c_can/c_can.c
1155 +index a668cd491cb3..e3fc07cf2f62 100644
1156 +--- a/drivers/net/can/c_can/c_can.c
1157 ++++ b/drivers/net/can/c_can/c_can.c
1158 +@@ -814,9 +814,6 @@ static int c_can_do_rx_poll(struct net_device *dev, int quota)
1159 + msg_ctrl_save = priv->read_reg(priv,
1160 + C_CAN_IFACE(MSGCTRL_REG, 0));
1161 +
1162 +- if (msg_ctrl_save & IF_MCONT_EOB)
1163 +- return num_rx_pkts;
1164 +-
1165 + if (msg_ctrl_save & IF_MCONT_MSGLST) {
1166 + c_can_handle_lost_msg_obj(dev, 0, msg_obj);
1167 + num_rx_pkts++;
1168 +@@ -824,6 +821,9 @@ static int c_can_do_rx_poll(struct net_device *dev, int quota)
1169 + continue;
1170 + }
1171 +
1172 ++ if (msg_ctrl_save & IF_MCONT_EOB)
1173 ++ return num_rx_pkts;
1174 ++
1175 + if (!(msg_ctrl_save & IF_MCONT_NEWDAT))
1176 + continue;
1177 +
1178 +diff --git a/drivers/net/can/usb/kvaser_usb.c b/drivers/net/can/usb/kvaser_usb.c
1179 +index 3b9546588240..4b2d5ed62b11 100644
1180 +--- a/drivers/net/can/usb/kvaser_usb.c
1181 ++++ b/drivers/net/can/usb/kvaser_usb.c
1182 +@@ -1544,9 +1544,9 @@ static int kvaser_usb_init_one(struct usb_interface *intf,
1183 + return 0;
1184 + }
1185 +
1186 +-static void kvaser_usb_get_endpoints(const struct usb_interface *intf,
1187 +- struct usb_endpoint_descriptor **in,
1188 +- struct usb_endpoint_descriptor **out)
1189 ++static int kvaser_usb_get_endpoints(const struct usb_interface *intf,
1190 ++ struct usb_endpoint_descriptor **in,
1191 ++ struct usb_endpoint_descriptor **out)
1192 + {
1193 + const struct usb_host_interface *iface_desc;
1194 + struct usb_endpoint_descriptor *endpoint;
1195 +@@ -1557,12 +1557,18 @@ static void kvaser_usb_get_endpoints(const struct usb_interface *intf,
1196 + for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {
1197 + endpoint = &iface_desc->endpoint[i].desc;
1198 +
1199 +- if (usb_endpoint_is_bulk_in(endpoint))
1200 ++ if (!*in && usb_endpoint_is_bulk_in(endpoint))
1201 + *in = endpoint;
1202 +
1203 +- if (usb_endpoint_is_bulk_out(endpoint))
1204 ++ if (!*out && usb_endpoint_is_bulk_out(endpoint))
1205 + *out = endpoint;
1206 ++
1207 ++ /* use first bulk endpoint for in and out */
1208 ++ if (*in && *out)
1209 ++ return 0;
1210 + }
1211 ++
1212 ++ return -ENODEV;
1213 + }
1214 +
1215 + static int kvaser_usb_probe(struct usb_interface *intf,
1216 +@@ -1576,8 +1582,8 @@ static int kvaser_usb_probe(struct usb_interface *intf,
1217 + if (!dev)
1218 + return -ENOMEM;
1219 +
1220 +- kvaser_usb_get_endpoints(intf, &dev->bulk_in, &dev->bulk_out);
1221 +- if (!dev->bulk_in || !dev->bulk_out) {
1222 ++ err = kvaser_usb_get_endpoints(intf, &dev->bulk_in, &dev->bulk_out);
1223 ++ if (err) {
1224 + dev_err(&intf->dev, "Cannot get usb endpoint(s)");
1225 + return err;
1226 + }
1227 +diff --git a/drivers/net/wireless/libertas/debugfs.c b/drivers/net/wireless/libertas/debugfs.c
1228 +index 668dd27616a0..cc6a0a586f0b 100644
1229 +--- a/drivers/net/wireless/libertas/debugfs.c
1230 ++++ b/drivers/net/wireless/libertas/debugfs.c
1231 +@@ -913,7 +913,10 @@ static ssize_t lbs_debugfs_write(struct file *f, const char __user *buf,
1232 + char *p2;
1233 + struct debug_data *d = f->private_data;
1234 +
1235 +- pdata = kmalloc(cnt, GFP_KERNEL);
1236 ++ if (cnt == 0)
1237 ++ return 0;
1238 ++
1239 ++ pdata = kmalloc(cnt + 1, GFP_KERNEL);
1240 + if (pdata == NULL)
1241 + return 0;
1242 +
1243 +@@ -922,6 +925,7 @@ static ssize_t lbs_debugfs_write(struct file *f, const char __user *buf,
1244 + kfree(pdata);
1245 + return 0;
1246 + }
1247 ++ pdata[cnt] = '\0';
1248 +
1249 + p0 = pdata;
1250 + for (i = 0; i < num_of_items; i++) {
1251 +diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
1252 +index f281971919f5..12652d204f7e 100644
1253 +--- a/drivers/net/wireless/rt2x00/rt2800lib.c
1254 ++++ b/drivers/net/wireless/rt2x00/rt2800lib.c
1255 +@@ -3400,10 +3400,13 @@ void rt2800_link_tuner(struct rt2x00_dev *rt2x00dev, struct link_qual *qual,
1256 +
1257 + vgc = rt2800_get_default_vgc(rt2x00dev);
1258 +
1259 +- if (rt2x00_rt(rt2x00dev, RT5592) && qual->rssi > -65)
1260 +- vgc += 0x20;
1261 +- else if (qual->rssi > -80)
1262 +- vgc += 0x10;
1263 ++ if (rt2x00_rt(rt2x00dev, RT5592)) {
1264 ++ if (qual->rssi > -65)
1265 ++ vgc += 0x20;
1266 ++ } else {
1267 ++ if (qual->rssi > -80)
1268 ++ vgc += 0x10;
1269 ++ }
1270 +
1271 + rt2800_set_vgc(rt2x00dev, qual, vgc);
1272 + }
1273 +diff --git a/drivers/net/wireless/rt2x00/rt2800usb.c b/drivers/net/wireless/rt2x00/rt2800usb.c
1274 +index ac854d75bd6c..9ef0711a5cc1 100644
1275 +--- a/drivers/net/wireless/rt2x00/rt2800usb.c
1276 ++++ b/drivers/net/wireless/rt2x00/rt2800usb.c
1277 +@@ -148,6 +148,8 @@ static bool rt2800usb_txstatus_timeout(struct rt2x00_dev *rt2x00dev)
1278 + return false;
1279 + }
1280 +
1281 ++#define TXSTATUS_READ_INTERVAL 1000000
1282 ++
1283 + static bool rt2800usb_tx_sta_fifo_read_completed(struct rt2x00_dev *rt2x00dev,
1284 + int urb_status, u32 tx_status)
1285 + {
1286 +@@ -176,8 +178,9 @@ static bool rt2800usb_tx_sta_fifo_read_completed(struct rt2x00_dev *rt2x00dev,
1287 + queue_work(rt2x00dev->workqueue, &rt2x00dev->txdone_work);
1288 +
1289 + if (rt2800usb_txstatus_pending(rt2x00dev)) {
1290 +- /* Read register after 250 us */
1291 +- hrtimer_start(&rt2x00dev->txstatus_timer, ktime_set(0, 250000),
1292 ++ /* Read register after 1 ms */
1293 ++ hrtimer_start(&rt2x00dev->txstatus_timer,
1294 ++ ktime_set(0, TXSTATUS_READ_INTERVAL),
1295 + HRTIMER_MODE_REL);
1296 + return false;
1297 + }
1298 +@@ -202,8 +205,9 @@ static void rt2800usb_async_read_tx_status(struct rt2x00_dev *rt2x00dev)
1299 + if (test_and_set_bit(TX_STATUS_READING, &rt2x00dev->flags))
1300 + return;
1301 +
1302 +- /* Read TX_STA_FIFO register after 500 us */
1303 +- hrtimer_start(&rt2x00dev->txstatus_timer, ktime_set(0, 500000),
1304 ++ /* Read TX_STA_FIFO register after 2 ms */
1305 ++ hrtimer_start(&rt2x00dev->txstatus_timer,
1306 ++ ktime_set(0, 2*TXSTATUS_READ_INTERVAL),
1307 + HRTIMER_MODE_REL);
1308 + }
1309 +
1310 +diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c b/drivers/net/wireless/rt2x00/rt2x00dev.c
1311 +index 90dc14336980..a2889d1cfe37 100644
1312 +--- a/drivers/net/wireless/rt2x00/rt2x00dev.c
1313 ++++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
1314 +@@ -181,6 +181,7 @@ static void rt2x00lib_autowakeup(struct work_struct *work)
1315 + static void rt2x00lib_bc_buffer_iter(void *data, u8 *mac,
1316 + struct ieee80211_vif *vif)
1317 + {
1318 ++ struct ieee80211_tx_control control = {};
1319 + struct rt2x00_dev *rt2x00dev = data;
1320 + struct sk_buff *skb;
1321 +
1322 +@@ -195,7 +196,7 @@ static void rt2x00lib_bc_buffer_iter(void *data, u8 *mac,
1323 + */
1324 + skb = ieee80211_get_buffered_bc(rt2x00dev->hw, vif);
1325 + while (skb) {
1326 +- rt2x00mac_tx(rt2x00dev->hw, NULL, skb);
1327 ++ rt2x00mac_tx(rt2x00dev->hw, &control, skb);
1328 + skb = ieee80211_get_buffered_bc(rt2x00dev->hw, vif);
1329 + }
1330 + }
1331 +diff --git a/drivers/net/wireless/rt2x00/rt2x00lib.h b/drivers/net/wireless/rt2x00/rt2x00lib.h
1332 +index a0935987fa3a..7f40ab8e1bd8 100644
1333 +--- a/drivers/net/wireless/rt2x00/rt2x00lib.h
1334 ++++ b/drivers/net/wireless/rt2x00/rt2x00lib.h
1335 +@@ -146,7 +146,7 @@ void rt2x00queue_remove_l2pad(struct sk_buff *skb, unsigned int header_length);
1336 + * @local: frame is not from mac80211
1337 + */
1338 + int rt2x00queue_write_tx_frame(struct data_queue *queue, struct sk_buff *skb,
1339 +- bool local);
1340 ++ struct ieee80211_sta *sta, bool local);
1341 +
1342 + /**
1343 + * rt2x00queue_update_beacon - Send new beacon from mac80211
1344 +diff --git a/drivers/net/wireless/rt2x00/rt2x00mac.c b/drivers/net/wireless/rt2x00/rt2x00mac.c
1345 +index f883802f3505..f8cff1f0b6b7 100644
1346 +--- a/drivers/net/wireless/rt2x00/rt2x00mac.c
1347 ++++ b/drivers/net/wireless/rt2x00/rt2x00mac.c
1348 +@@ -90,7 +90,7 @@ static int rt2x00mac_tx_rts_cts(struct rt2x00_dev *rt2x00dev,
1349 + frag_skb->data, data_length, tx_info,
1350 + (struct ieee80211_rts *)(skb->data));
1351 +
1352 +- retval = rt2x00queue_write_tx_frame(queue, skb, true);
1353 ++ retval = rt2x00queue_write_tx_frame(queue, skb, NULL, true);
1354 + if (retval) {
1355 + dev_kfree_skb_any(skb);
1356 + rt2x00_warn(rt2x00dev, "Failed to send RTS/CTS frame\n");
1357 +@@ -151,7 +151,7 @@ void rt2x00mac_tx(struct ieee80211_hw *hw,
1358 + goto exit_fail;
1359 + }
1360 +
1361 +- if (unlikely(rt2x00queue_write_tx_frame(queue, skb, false)))
1362 ++ if (unlikely(rt2x00queue_write_tx_frame(queue, skb, control->sta, false)))
1363 + goto exit_fail;
1364 +
1365 + /*
1366 +@@ -754,6 +754,9 @@ void rt2x00mac_flush(struct ieee80211_hw *hw, u32 queues, bool drop)
1367 + struct rt2x00_dev *rt2x00dev = hw->priv;
1368 + struct data_queue *queue;
1369 +
1370 ++ if (!test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags))
1371 ++ return;
1372 ++
1373 + tx_queue_for_each(rt2x00dev, queue)
1374 + rt2x00queue_flush_queue(queue, drop);
1375 + }
1376 +diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
1377 +index d955741e48ff..1f17f5b64625 100644
1378 +--- a/drivers/net/wireless/rt2x00/rt2x00queue.c
1379 ++++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
1380 +@@ -635,7 +635,7 @@ static void rt2x00queue_bar_check(struct queue_entry *entry)
1381 + }
1382 +
1383 + int rt2x00queue_write_tx_frame(struct data_queue *queue, struct sk_buff *skb,
1384 +- bool local)
1385 ++ struct ieee80211_sta *sta, bool local)
1386 + {
1387 + struct ieee80211_tx_info *tx_info;
1388 + struct queue_entry *entry;
1389 +@@ -649,7 +649,7 @@ int rt2x00queue_write_tx_frame(struct data_queue *queue, struct sk_buff *skb,
1390 + * after that we are free to use the skb->cb array
1391 + * for our information.
1392 + */
1393 +- rt2x00queue_create_tx_descriptor(queue->rt2x00dev, skb, &txdesc, NULL);
1394 ++ rt2x00queue_create_tx_descriptor(queue->rt2x00dev, skb, &txdesc, sta);
1395 +
1396 + /*
1397 + * All information is retrieved from the skb->cb array,
1398 +diff --git a/drivers/pci/access.c b/drivers/pci/access.c
1399 +index 1cc23661f79b..061da8c3ab4b 100644
1400 +--- a/drivers/pci/access.c
1401 ++++ b/drivers/pci/access.c
1402 +@@ -484,28 +484,29 @@ static inline bool pcie_cap_has_lnkctl(const struct pci_dev *dev)
1403 + {
1404 + int type = pci_pcie_type(dev);
1405 +
1406 +- return pcie_cap_version(dev) > 1 ||
1407 ++ return type == PCI_EXP_TYPE_ENDPOINT ||
1408 ++ type == PCI_EXP_TYPE_LEG_END ||
1409 + type == PCI_EXP_TYPE_ROOT_PORT ||
1410 +- type == PCI_EXP_TYPE_ENDPOINT ||
1411 +- type == PCI_EXP_TYPE_LEG_END;
1412 ++ type == PCI_EXP_TYPE_UPSTREAM ||
1413 ++ type == PCI_EXP_TYPE_DOWNSTREAM ||
1414 ++ type == PCI_EXP_TYPE_PCI_BRIDGE ||
1415 ++ type == PCI_EXP_TYPE_PCIE_BRIDGE;
1416 + }
1417 +
1418 + static inline bool pcie_cap_has_sltctl(const struct pci_dev *dev)
1419 + {
1420 + int type = pci_pcie_type(dev);
1421 +
1422 +- return pcie_cap_version(dev) > 1 ||
1423 +- type == PCI_EXP_TYPE_ROOT_PORT ||
1424 +- (type == PCI_EXP_TYPE_DOWNSTREAM &&
1425 +- pcie_caps_reg(dev) & PCI_EXP_FLAGS_SLOT);
1426 ++ return (type == PCI_EXP_TYPE_ROOT_PORT ||
1427 ++ type == PCI_EXP_TYPE_DOWNSTREAM) &&
1428 ++ pcie_caps_reg(dev) & PCI_EXP_FLAGS_SLOT;
1429 + }
1430 +
1431 + static inline bool pcie_cap_has_rtctl(const struct pci_dev *dev)
1432 + {
1433 + int type = pci_pcie_type(dev);
1434 +
1435 +- return pcie_cap_version(dev) > 1 ||
1436 +- type == PCI_EXP_TYPE_ROOT_PORT ||
1437 ++ return type == PCI_EXP_TYPE_ROOT_PORT ||
1438 + type == PCI_EXP_TYPE_RC_EC;
1439 + }
1440 +
1441 +diff --git a/drivers/scsi/aacraid/commctrl.c b/drivers/scsi/aacraid/commctrl.c
1442 +index 1ef041bc60c8..ee6caddd978c 100644
1443 +--- a/drivers/scsi/aacraid/commctrl.c
1444 ++++ b/drivers/scsi/aacraid/commctrl.c
1445 +@@ -510,7 +510,8 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
1446 + goto cleanup;
1447 + }
1448 +
1449 +- if (fibsize > (dev->max_fib_size - sizeof(struct aac_fibhdr))) {
1450 ++ if ((fibsize < (sizeof(struct user_aac_srb) - sizeof(struct user_sgentry))) ||
1451 ++ (fibsize > (dev->max_fib_size - sizeof(struct aac_fibhdr)))) {
1452 + rcode = -EINVAL;
1453 + goto cleanup;
1454 + }
1455 +diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
1456 +index c8b9fa0e9275..1424a8988849 100644
1457 +--- a/drivers/usb/core/hub.c
1458 ++++ b/drivers/usb/core/hub.c
1459 +@@ -1129,6 +1129,11 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type)
1460 + usb_clear_port_feature(hub->hdev, port1,
1461 + USB_PORT_FEAT_C_ENABLE);
1462 + }
1463 ++ if (portchange & USB_PORT_STAT_C_RESET) {
1464 ++ need_debounce_delay = true;
1465 ++ usb_clear_port_feature(hub->hdev, port1,
1466 ++ USB_PORT_FEAT_C_RESET);
1467 ++ }
1468 + if ((portchange & USB_PORT_STAT_C_BH_RESET) &&
1469 + hub_is_superspeed(hub->hdev)) {
1470 + need_debounce_delay = true;
1471 +diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
1472 +index 2c1749da1f7e..8b3d0abe7e14 100644
1473 +--- a/drivers/usb/serial/mos7840.c
1474 ++++ b/drivers/usb/serial/mos7840.c
1475 +@@ -1593,7 +1593,11 @@ static int mos7840_tiocmget(struct tty_struct *tty)
1476 + return -ENODEV;
1477 +
1478 + status = mos7840_get_uart_reg(port, MODEM_STATUS_REGISTER, &msr);
1479 ++ if (status != 1)
1480 ++ return -EIO;
1481 + status = mos7840_get_uart_reg(port, MODEM_CONTROL_REGISTER, &mcr);
1482 ++ if (status != 1)
1483 ++ return -EIO;
1484 + result = ((mcr & MCR_DTR) ? TIOCM_DTR : 0)
1485 + | ((mcr & MCR_RTS) ? TIOCM_RTS : 0)
1486 + | ((mcr & MCR_LOOPBACK) ? TIOCM_LOOP : 0)
1487 +diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
1488 +index 7aabc6ad4e9b..fa38d076697d 100644
1489 +--- a/fs/configfs/dir.c
1490 ++++ b/fs/configfs/dir.c
1491 +@@ -56,10 +56,19 @@ static void configfs_d_iput(struct dentry * dentry,
1492 + struct configfs_dirent *sd = dentry->d_fsdata;
1493 +
1494 + if (sd) {
1495 +- BUG_ON(sd->s_dentry != dentry);
1496 + /* Coordinate with configfs_readdir */
1497 + spin_lock(&configfs_dirent_lock);
1498 +- sd->s_dentry = NULL;
1499 ++ /* Coordinate with configfs_attach_attr where will increase
1500 ++ * sd->s_count and update sd->s_dentry to new allocated one.
1501 ++ * Only set sd->dentry to null when this dentry is the only
1502 ++ * sd owner.
1503 ++ * If not do so, configfs_d_iput may run just after
1504 ++ * configfs_attach_attr and set sd->s_dentry to null
1505 ++ * even it's still in use.
1506 ++ */
1507 ++ if (atomic_read(&sd->s_count) <= 2)
1508 ++ sd->s_dentry = NULL;
1509 ++
1510 + spin_unlock(&configfs_dirent_lock);
1511 + configfs_put(sd);
1512 + }
1513 +@@ -426,8 +435,11 @@ static int configfs_attach_attr(struct configfs_dirent * sd, struct dentry * den
1514 + struct configfs_attribute * attr = sd->s_element;
1515 + int error;
1516 +
1517 ++ spin_lock(&configfs_dirent_lock);
1518 + dentry->d_fsdata = configfs_get(sd);
1519 + sd->s_dentry = dentry;
1520 ++ spin_unlock(&configfs_dirent_lock);
1521 ++
1522 + error = configfs_create(dentry, (attr->ca_mode & S_IALLUGO) | S_IFREG,
1523 + configfs_init_file);
1524 + if (error) {
1525 +diff --git a/fs/exec.c b/fs/exec.c
1526 +index 1f446705636b..bb60cda5ee30 100644
1527 +--- a/fs/exec.c
1528 ++++ b/fs/exec.c
1529 +@@ -1669,6 +1669,12 @@ int __get_dumpable(unsigned long mm_flags)
1530 + return (ret > SUID_DUMP_USER) ? SUID_DUMP_ROOT : ret;
1531 + }
1532 +
1533 ++/*
1534 ++ * This returns the actual value of the suid_dumpable flag. For things
1535 ++ * that are using this for checking for privilege transitions, it must
1536 ++ * test against SUID_DUMP_USER rather than treating it as a boolean
1537 ++ * value.
1538 ++ */
1539 + int get_dumpable(struct mm_struct *mm)
1540 + {
1541 + return __get_dumpable(mm->flags);
1542 +diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
1543 +index d7ba5616989c..e78b8c2656ee 100644
1544 +--- a/fs/nfs/nfs4proc.c
1545 ++++ b/fs/nfs/nfs4proc.c
1546 +@@ -1160,29 +1160,24 @@ _nfs4_opendata_reclaim_to_nfs4_state(struct nfs4_opendata *data)
1547 + int ret;
1548 +
1549 + if (!data->rpc_done) {
1550 +- ret = data->rpc_status;
1551 +- goto err;
1552 ++ if (data->rpc_status) {
1553 ++ ret = data->rpc_status;
1554 ++ goto err;
1555 ++ }
1556 ++ /* cached opens have already been processed */
1557 ++ goto update;
1558 + }
1559 +
1560 +- ret = -ESTALE;
1561 +- if (!(data->f_attr.valid & NFS_ATTR_FATTR_TYPE) ||
1562 +- !(data->f_attr.valid & NFS_ATTR_FATTR_FILEID) ||
1563 +- !(data->f_attr.valid & NFS_ATTR_FATTR_CHANGE))
1564 +- goto err;
1565 +-
1566 +- ret = -ENOMEM;
1567 +- state = nfs4_get_open_state(inode, data->owner);
1568 +- if (state == NULL)
1569 +- goto err;
1570 +-
1571 + ret = nfs_refresh_inode(inode, &data->f_attr);
1572 + if (ret)
1573 + goto err;
1574 +
1575 + if (data->o_res.delegation_type != 0)
1576 + nfs4_opendata_check_deleg(data, state);
1577 ++update:
1578 + update_open_stateid(state, &data->o_res.stateid, NULL,
1579 + data->o_arg.fmode);
1580 ++ atomic_inc(&state->count);
1581 +
1582 + return state;
1583 + err:
1584 +@@ -4572,6 +4567,7 @@ static int _nfs4_proc_getlk(struct nfs4_state *state, int cmd, struct file_lock
1585 + status = 0;
1586 + }
1587 + request->fl_ops->fl_release_private(request);
1588 ++ request->fl_ops = NULL;
1589 + out:
1590 + return status;
1591 + }
1592 +diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c
1593 +index 5f38ea36e266..af51cf9bf2e3 100644
1594 +--- a/fs/nfsd/export.c
1595 ++++ b/fs/nfsd/export.c
1596 +@@ -536,16 +536,12 @@ static int svc_export_parse(struct cache_detail *cd, char *mesg, int mlen)
1597 + if (err)
1598 + goto out3;
1599 + exp.ex_anon_uid= make_kuid(&init_user_ns, an_int);
1600 +- if (!uid_valid(exp.ex_anon_uid))
1601 +- goto out3;
1602 +
1603 + /* anon gid */
1604 + err = get_int(&mesg, &an_int);
1605 + if (err)
1606 + goto out3;
1607 + exp.ex_anon_gid= make_kgid(&init_user_ns, an_int);
1608 +- if (!gid_valid(exp.ex_anon_gid))
1609 +- goto out3;
1610 +
1611 + /* fsid */
1612 + err = get_int(&mesg, &an_int);
1613 +@@ -583,6 +579,17 @@ static int svc_export_parse(struct cache_detail *cd, char *mesg, int mlen)
1614 + exp.ex_uuid);
1615 + if (err)
1616 + goto out4;
1617 ++ /*
1618 ++ * For some reason exportfs has been passing down an
1619 ++ * invalid (-1) uid & gid on the "dummy" export which it
1620 ++ * uses to test export support. To make sure exportfs
1621 ++ * sees errors from check_export we therefore need to
1622 ++ * delay these checks till after check_export:
1623 ++ */
1624 ++ if (!uid_valid(exp.ex_anon_uid))
1625 ++ goto out4;
1626 ++ if (!gid_valid(exp.ex_anon_gid))
1627 ++ goto out4;
1628 + }
1629 +
1630 + expp = svc_export_lookup(&exp);
1631 +diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
1632 +index baf149a85263..62fd6616801d 100644
1633 +--- a/fs/nfsd/vfs.c
1634 ++++ b/fs/nfsd/vfs.c
1635 +@@ -297,41 +297,12 @@ commit_metadata(struct svc_fh *fhp)
1636 + }
1637 +
1638 + /*
1639 +- * Set various file attributes.
1640 +- * N.B. After this call fhp needs an fh_put
1641 ++ * Go over the attributes and take care of the small differences between
1642 ++ * NFS semantics and what Linux expects.
1643 + */
1644 +-__be32
1645 +-nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap,
1646 +- int check_guard, time_t guardtime)
1647 ++static void
1648 ++nfsd_sanitize_attrs(struct inode *inode, struct iattr *iap)
1649 + {
1650 +- struct dentry *dentry;
1651 +- struct inode *inode;
1652 +- int accmode = NFSD_MAY_SATTR;
1653 +- umode_t ftype = 0;
1654 +- __be32 err;
1655 +- int host_err;
1656 +- int size_change = 0;
1657 +-
1658 +- if (iap->ia_valid & (ATTR_ATIME | ATTR_MTIME | ATTR_SIZE))
1659 +- accmode |= NFSD_MAY_WRITE|NFSD_MAY_OWNER_OVERRIDE;
1660 +- if (iap->ia_valid & ATTR_SIZE)
1661 +- ftype = S_IFREG;
1662 +-
1663 +- /* Get inode */
1664 +- err = fh_verify(rqstp, fhp, ftype, accmode);
1665 +- if (err)
1666 +- goto out;
1667 +-
1668 +- dentry = fhp->fh_dentry;
1669 +- inode = dentry->d_inode;
1670 +-
1671 +- /* Ignore any mode updates on symlinks */
1672 +- if (S_ISLNK(inode->i_mode))
1673 +- iap->ia_valid &= ~ATTR_MODE;
1674 +-
1675 +- if (!iap->ia_valid)
1676 +- goto out;
1677 +-
1678 + /*
1679 + * NFSv2 does not differentiate between "set-[ac]time-to-now"
1680 + * which only requires access, and "set-[ac]time-to-X" which
1681 +@@ -341,8 +312,7 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap,
1682 + * convert to "set to now" instead of "set to explicit time"
1683 + *
1684 + * We only call inode_change_ok as the last test as technically
1685 +- * it is not an interface that we should be using. It is only
1686 +- * valid if the filesystem does not define it's own i_op->setattr.
1687 ++ * it is not an interface that we should be using.
1688 + */
1689 + #define BOTH_TIME_SET (ATTR_ATIME_SET | ATTR_MTIME_SET)
1690 + #define MAX_TOUCH_TIME_ERROR (30*60)
1691 +@@ -368,30 +338,6 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap,
1692 + iap->ia_valid &= ~BOTH_TIME_SET;
1693 + }
1694 + }
1695 +-
1696 +- /*
1697 +- * The size case is special.
1698 +- * It changes the file as well as the attributes.
1699 +- */
1700 +- if (iap->ia_valid & ATTR_SIZE) {
1701 +- if (iap->ia_size < inode->i_size) {
1702 +- err = nfsd_permission(rqstp, fhp->fh_export, dentry,
1703 +- NFSD_MAY_TRUNC|NFSD_MAY_OWNER_OVERRIDE);
1704 +- if (err)
1705 +- goto out;
1706 +- }
1707 +-
1708 +- host_err = get_write_access(inode);
1709 +- if (host_err)
1710 +- goto out_nfserr;
1711 +-
1712 +- size_change = 1;
1713 +- host_err = locks_verify_truncate(inode, NULL, iap->ia_size);
1714 +- if (host_err) {
1715 +- put_write_access(inode);
1716 +- goto out_nfserr;
1717 +- }
1718 +- }
1719 +
1720 + /* sanitize the mode change */
1721 + if (iap->ia_valid & ATTR_MODE) {
1722 +@@ -414,32 +360,111 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap,
1723 + iap->ia_valid |= (ATTR_KILL_SUID | ATTR_KILL_SGID);
1724 + }
1725 + }
1726 ++}
1727 +
1728 +- /* Change the attributes. */
1729 ++static __be32
1730 ++nfsd_get_write_access(struct svc_rqst *rqstp, struct svc_fh *fhp,
1731 ++ struct iattr *iap)
1732 ++{
1733 ++ struct inode *inode = fhp->fh_dentry->d_inode;
1734 ++ int host_err;
1735 +
1736 +- iap->ia_valid |= ATTR_CTIME;
1737 ++ if (iap->ia_size < inode->i_size) {
1738 ++ __be32 err;
1739 +
1740 +- err = nfserr_notsync;
1741 +- if (!check_guard || guardtime == inode->i_ctime.tv_sec) {
1742 +- host_err = nfsd_break_lease(inode);
1743 +- if (host_err)
1744 +- goto out_nfserr;
1745 +- fh_lock(fhp);
1746 ++ err = nfsd_permission(rqstp, fhp->fh_export, fhp->fh_dentry,
1747 ++ NFSD_MAY_TRUNC | NFSD_MAY_OWNER_OVERRIDE);
1748 ++ if (err)
1749 ++ return err;
1750 ++ }
1751 +
1752 +- host_err = notify_change(dentry, iap);
1753 +- err = nfserrno(host_err);
1754 +- fh_unlock(fhp);
1755 ++ host_err = get_write_access(inode);
1756 ++ if (host_err)
1757 ++ goto out_nfserrno;
1758 ++
1759 ++ host_err = locks_verify_truncate(inode, NULL, iap->ia_size);
1760 ++ if (host_err)
1761 ++ goto out_put_write_access;
1762 ++ return 0;
1763 ++
1764 ++out_put_write_access:
1765 ++ put_write_access(inode);
1766 ++out_nfserrno:
1767 ++ return nfserrno(host_err);
1768 ++}
1769 ++
1770 ++/*
1771 ++ * Set various file attributes. After this call fhp needs an fh_put.
1772 ++ */
1773 ++__be32
1774 ++nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap,
1775 ++ int check_guard, time_t guardtime)
1776 ++{
1777 ++ struct dentry *dentry;
1778 ++ struct inode *inode;
1779 ++ int accmode = NFSD_MAY_SATTR;
1780 ++ umode_t ftype = 0;
1781 ++ __be32 err;
1782 ++ int host_err;
1783 ++ int size_change = 0;
1784 ++
1785 ++ if (iap->ia_valid & (ATTR_ATIME | ATTR_MTIME | ATTR_SIZE))
1786 ++ accmode |= NFSD_MAY_WRITE|NFSD_MAY_OWNER_OVERRIDE;
1787 ++ if (iap->ia_valid & ATTR_SIZE)
1788 ++ ftype = S_IFREG;
1789 ++
1790 ++ /* Get inode */
1791 ++ err = fh_verify(rqstp, fhp, ftype, accmode);
1792 ++ if (err)
1793 ++ goto out;
1794 ++
1795 ++ dentry = fhp->fh_dentry;
1796 ++ inode = dentry->d_inode;
1797 ++
1798 ++ /* Ignore any mode updates on symlinks */
1799 ++ if (S_ISLNK(inode->i_mode))
1800 ++ iap->ia_valid &= ~ATTR_MODE;
1801 ++
1802 ++ if (!iap->ia_valid)
1803 ++ goto out;
1804 ++
1805 ++ nfsd_sanitize_attrs(inode, iap);
1806 ++
1807 ++ /*
1808 ++ * The size case is special, it changes the file in addition to the
1809 ++ * attributes.
1810 ++ */
1811 ++ if (iap->ia_valid & ATTR_SIZE) {
1812 ++ err = nfsd_get_write_access(rqstp, fhp, iap);
1813 ++ if (err)
1814 ++ goto out;
1815 ++ size_change = 1;
1816 + }
1817 ++
1818 ++ iap->ia_valid |= ATTR_CTIME;
1819 ++
1820 ++ if (check_guard && guardtime != inode->i_ctime.tv_sec) {
1821 ++ err = nfserr_notsync;
1822 ++ goto out_put_write_access;
1823 ++ }
1824 ++
1825 ++ host_err = nfsd_break_lease(inode);
1826 ++ if (host_err)
1827 ++ goto out_put_write_access_nfserror;
1828 ++
1829 ++ fh_lock(fhp);
1830 ++ host_err = notify_change(dentry, iap);
1831 ++ fh_unlock(fhp);
1832 ++
1833 ++out_put_write_access_nfserror:
1834 ++ err = nfserrno(host_err);
1835 ++out_put_write_access:
1836 + if (size_change)
1837 + put_write_access(inode);
1838 + if (!err)
1839 + commit_metadata(fhp);
1840 + out:
1841 + return err;
1842 +-
1843 +-out_nfserr:
1844 +- err = nfserrno(host_err);
1845 +- goto out;
1846 + }
1847 +
1848 + #if defined(CONFIG_NFSD_V2_ACL) || \
1849 +diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
1850 +index 70cf138690e9..df97ca4aae52 100644
1851 +--- a/include/linux/binfmts.h
1852 ++++ b/include/linux/binfmts.h
1853 +@@ -99,9 +99,6 @@ extern void setup_new_exec(struct linux_binprm * bprm);
1854 + extern void would_dump(struct linux_binprm *, struct file *);
1855 +
1856 + extern int suid_dumpable;
1857 +-#define SUID_DUMP_DISABLE 0 /* No setuid dumping */
1858 +-#define SUID_DUMP_USER 1 /* Dump as user of process */
1859 +-#define SUID_DUMP_ROOT 2 /* Dump as root */
1860 +
1861 + /* Stack area protections */
1862 + #define EXSTACK_DEFAULT 0 /* Whatever the arch defaults to */
1863 +diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
1864 +index b508016fb76d..b3bd7e737e8b 100644
1865 +--- a/include/linux/mod_devicetable.h
1866 ++++ b/include/linux/mod_devicetable.h
1867 +@@ -456,7 +456,8 @@ enum dmi_field {
1868 + };
1869 +
1870 + struct dmi_strmatch {
1871 +- unsigned char slot;
1872 ++ unsigned char slot:7;
1873 ++ unsigned char exact_match:1;
1874 + char substr[79];
1875 + };
1876 +
1877 +@@ -474,7 +475,8 @@ struct dmi_system_id {
1878 + */
1879 + #define dmi_device_id dmi_system_id
1880 +
1881 +-#define DMI_MATCH(a, b) { a, b }
1882 ++#define DMI_MATCH(a, b) { .slot = a, .substr = b }
1883 ++#define DMI_EXACT_MATCH(a, b) { .slot = a, .substr = b, .exact_match = 1 }
1884 +
1885 + #define PLATFORM_NAME_SIZE 20
1886 + #define PLATFORM_MODULE_PREFIX "platform:"
1887 +diff --git a/include/linux/sched.h b/include/linux/sched.h
1888 +index 178a8d909f14..597c8ab005a0 100644
1889 +--- a/include/linux/sched.h
1890 ++++ b/include/linux/sched.h
1891 +@@ -332,6 +332,10 @@ static inline void arch_pick_mmap_layout(struct mm_struct *mm) {}
1892 + extern void set_dumpable(struct mm_struct *mm, int value);
1893 + extern int get_dumpable(struct mm_struct *mm);
1894 +
1895 ++#define SUID_DUMP_DISABLE 0 /* No setuid dumping */
1896 ++#define SUID_DUMP_USER 1 /* Dump as user of process */
1897 ++#define SUID_DUMP_ROOT 2 /* Dump as root */
1898 ++
1899 + /* mm flags */
1900 + /* dumpable bits */
1901 + #define MMF_DUMPABLE 0 /* core dump is permitted */
1902 +@@ -2469,34 +2473,98 @@ static inline int tsk_is_polling(struct task_struct *p)
1903 + {
1904 + return task_thread_info(p)->status & TS_POLLING;
1905 + }
1906 +-static inline void current_set_polling(void)
1907 ++static inline void __current_set_polling(void)
1908 + {
1909 + current_thread_info()->status |= TS_POLLING;
1910 + }
1911 +
1912 +-static inline void current_clr_polling(void)
1913 ++static inline bool __must_check current_set_polling_and_test(void)
1914 ++{
1915 ++ __current_set_polling();
1916 ++
1917 ++ /*
1918 ++ * Polling state must be visible before we test NEED_RESCHED,
1919 ++ * paired by resched_task()
1920 ++ */
1921 ++ smp_mb();
1922 ++
1923 ++ return unlikely(tif_need_resched());
1924 ++}
1925 ++
1926 ++static inline void __current_clr_polling(void)
1927 + {
1928 + current_thread_info()->status &= ~TS_POLLING;
1929 +- smp_mb__after_clear_bit();
1930 ++}
1931 ++
1932 ++static inline bool __must_check current_clr_polling_and_test(void)
1933 ++{
1934 ++ __current_clr_polling();
1935 ++
1936 ++ /*
1937 ++ * Polling state must be visible before we test NEED_RESCHED,
1938 ++ * paired by resched_task()
1939 ++ */
1940 ++ smp_mb();
1941 ++
1942 ++ return unlikely(tif_need_resched());
1943 + }
1944 + #elif defined(TIF_POLLING_NRFLAG)
1945 + static inline int tsk_is_polling(struct task_struct *p)
1946 + {
1947 + return test_tsk_thread_flag(p, TIF_POLLING_NRFLAG);
1948 + }
1949 +-static inline void current_set_polling(void)
1950 ++
1951 ++static inline void __current_set_polling(void)
1952 + {
1953 + set_thread_flag(TIF_POLLING_NRFLAG);
1954 + }
1955 +
1956 +-static inline void current_clr_polling(void)
1957 ++static inline bool __must_check current_set_polling_and_test(void)
1958 ++{
1959 ++ __current_set_polling();
1960 ++
1961 ++ /*
1962 ++ * Polling state must be visible before we test NEED_RESCHED,
1963 ++ * paired by resched_task()
1964 ++ *
1965 ++ * XXX: assumes set/clear bit are identical barrier wise.
1966 ++ */
1967 ++ smp_mb__after_clear_bit();
1968 ++
1969 ++ return unlikely(tif_need_resched());
1970 ++}
1971 ++
1972 ++static inline void __current_clr_polling(void)
1973 + {
1974 + clear_thread_flag(TIF_POLLING_NRFLAG);
1975 + }
1976 ++
1977 ++static inline bool __must_check current_clr_polling_and_test(void)
1978 ++{
1979 ++ __current_clr_polling();
1980 ++
1981 ++ /*
1982 ++ * Polling state must be visible before we test NEED_RESCHED,
1983 ++ * paired by resched_task()
1984 ++ */
1985 ++ smp_mb__after_clear_bit();
1986 ++
1987 ++ return unlikely(tif_need_resched());
1988 ++}
1989 ++
1990 + #else
1991 + static inline int tsk_is_polling(struct task_struct *p) { return 0; }
1992 +-static inline void current_set_polling(void) { }
1993 +-static inline void current_clr_polling(void) { }
1994 ++static inline void __current_set_polling(void) { }
1995 ++static inline void __current_clr_polling(void) { }
1996 ++
1997 ++static inline bool __must_check current_set_polling_and_test(void)
1998 ++{
1999 ++ return unlikely(tif_need_resched());
2000 ++}
2001 ++static inline bool __must_check current_clr_polling_and_test(void)
2002 ++{
2003 ++ return unlikely(tif_need_resched());
2004 ++}
2005 + #endif
2006 +
2007 + /*
2008 +diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
2009 +index e7e04736802f..4ae6f32c8033 100644
2010 +--- a/include/linux/thread_info.h
2011 ++++ b/include/linux/thread_info.h
2012 +@@ -107,6 +107,8 @@ static inline int test_ti_thread_flag(struct thread_info *ti, int flag)
2013 + #define set_need_resched() set_thread_flag(TIF_NEED_RESCHED)
2014 + #define clear_need_resched() clear_thread_flag(TIF_NEED_RESCHED)
2015 +
2016 ++#define tif_need_resched() test_thread_flag(TIF_NEED_RESCHED)
2017 ++
2018 + #if defined TIF_RESTORE_SIGMASK && !defined HAVE_SET_RESTORE_SIGMASK
2019 + /*
2020 + * An arch can define its own version of set_restore_sigmask() to get the
2021 +diff --git a/include/sound/compress_driver.h b/include/sound/compress_driver.h
2022 +index 9031a26249b5..ae6c3b8ed2f5 100644
2023 +--- a/include/sound/compress_driver.h
2024 ++++ b/include/sound/compress_driver.h
2025 +@@ -171,4 +171,13 @@ static inline void snd_compr_fragment_elapsed(struct snd_compr_stream *stream)
2026 + wake_up(&stream->runtime->sleep);
2027 + }
2028 +
2029 ++static inline void snd_compr_drain_notify(struct snd_compr_stream *stream)
2030 ++{
2031 ++ if (snd_BUG_ON(!stream))
2032 ++ return;
2033 ++
2034 ++ stream->runtime->state = SNDRV_PCM_STATE_SETUP;
2035 ++ wake_up(&stream->runtime->sleep);
2036 ++}
2037 ++
2038 + #endif
2039 +diff --git a/ipc/shm.c b/ipc/shm.c
2040 +index 7b87bea5245b..6dc55af8a29b 100644
2041 +--- a/ipc/shm.c
2042 ++++ b/ipc/shm.c
2043 +@@ -208,15 +208,18 @@ static void shm_open(struct vm_area_struct *vma)
2044 + */
2045 + static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp)
2046 + {
2047 ++ struct file *shm_file;
2048 ++
2049 ++ shm_file = shp->shm_file;
2050 ++ shp->shm_file = NULL;
2051 + ns->shm_tot -= (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
2052 + shm_rmid(ns, shp);
2053 + shm_unlock(shp);
2054 +- if (!is_file_hugepages(shp->shm_file))
2055 +- shmem_lock(shp->shm_file, 0, shp->mlock_user);
2056 ++ if (!is_file_hugepages(shm_file))
2057 ++ shmem_lock(shm_file, 0, shp->mlock_user);
2058 + else if (shp->mlock_user)
2059 +- user_shm_unlock(file_inode(shp->shm_file)->i_size,
2060 +- shp->mlock_user);
2061 +- fput (shp->shm_file);
2062 ++ user_shm_unlock(file_inode(shm_file)->i_size, shp->mlock_user);
2063 ++ fput(shm_file);
2064 + ipc_rcu_putref(shp, shm_rcu_free);
2065 + }
2066 +
2067 +@@ -974,15 +977,25 @@ SYSCALL_DEFINE3(shmctl, int, shmid, int, cmd, struct shmid_ds __user *, buf)
2068 + ipc_lock_object(&shp->shm_perm);
2069 + if (!ns_capable(ns->user_ns, CAP_IPC_LOCK)) {
2070 + kuid_t euid = current_euid();
2071 +- err = -EPERM;
2072 + if (!uid_eq(euid, shp->shm_perm.uid) &&
2073 +- !uid_eq(euid, shp->shm_perm.cuid))
2074 ++ !uid_eq(euid, shp->shm_perm.cuid)) {
2075 ++ err = -EPERM;
2076 + goto out_unlock0;
2077 +- if (cmd == SHM_LOCK && !rlimit(RLIMIT_MEMLOCK))
2078 ++ }
2079 ++ if (cmd == SHM_LOCK && !rlimit(RLIMIT_MEMLOCK)) {
2080 ++ err = -EPERM;
2081 + goto out_unlock0;
2082 ++ }
2083 + }
2084 +
2085 + shm_file = shp->shm_file;
2086 ++
2087 ++ /* check if shm_destroy() is tearing down shp */
2088 ++ if (shm_file == NULL) {
2089 ++ err = -EIDRM;
2090 ++ goto out_unlock0;
2091 ++ }
2092 ++
2093 + if (is_file_hugepages(shm_file))
2094 + goto out_unlock0;
2095 +
2096 +@@ -1101,6 +1114,14 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
2097 + goto out_unlock;
2098 +
2099 + ipc_lock_object(&shp->shm_perm);
2100 ++
2101 ++ /* check if shm_destroy() is tearing down shp */
2102 ++ if (shp->shm_file == NULL) {
2103 ++ ipc_unlock_object(&shp->shm_perm);
2104 ++ err = -EIDRM;
2105 ++ goto out_unlock;
2106 ++ }
2107 ++
2108 + path = shp->shm_file->f_path;
2109 + path_get(&path);
2110 + shp->shm_nattch++;
2111 +diff --git a/kernel/cpu/idle.c b/kernel/cpu/idle.c
2112 +index e695c0a0bcb5..c261409500e4 100644
2113 +--- a/kernel/cpu/idle.c
2114 ++++ b/kernel/cpu/idle.c
2115 +@@ -44,7 +44,7 @@ static inline int cpu_idle_poll(void)
2116 + rcu_idle_enter();
2117 + trace_cpu_idle_rcuidle(0, smp_processor_id());
2118 + local_irq_enable();
2119 +- while (!need_resched())
2120 ++ while (!tif_need_resched())
2121 + cpu_relax();
2122 + trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, smp_processor_id());
2123 + rcu_idle_exit();
2124 +@@ -92,8 +92,7 @@ static void cpu_idle_loop(void)
2125 + if (cpu_idle_force_poll || tick_check_broadcast_expired()) {
2126 + cpu_idle_poll();
2127 + } else {
2128 +- current_clr_polling();
2129 +- if (!need_resched()) {
2130 ++ if (!current_clr_polling_and_test()) {
2131 + stop_critical_timings();
2132 + rcu_idle_enter();
2133 + arch_cpu_idle();
2134 +@@ -103,7 +102,7 @@ static void cpu_idle_loop(void)
2135 + } else {
2136 + local_irq_enable();
2137 + }
2138 +- current_set_polling();
2139 ++ __current_set_polling();
2140 + }
2141 + arch_cpu_idle_exit();
2142 + }
2143 +@@ -129,7 +128,7 @@ void cpu_startup_entry(enum cpuhp_state state)
2144 + */
2145 + boot_init_stack_canary();
2146 + #endif
2147 +- current_set_polling();
2148 ++ __current_set_polling();
2149 + arch_cpu_idle_prepare();
2150 + cpu_idle_loop();
2151 + }
2152 +diff --git a/kernel/ptrace.c b/kernel/ptrace.c
2153 +index 335a7ae697f5..afadcf7b4a22 100644
2154 +--- a/kernel/ptrace.c
2155 ++++ b/kernel/ptrace.c
2156 +@@ -257,7 +257,8 @@ ok:
2157 + if (task->mm)
2158 + dumpable = get_dumpable(task->mm);
2159 + rcu_read_lock();
2160 +- if (!dumpable && !ptrace_has_cap(__task_cred(task)->user_ns, mode)) {
2161 ++ if (dumpable != SUID_DUMP_USER &&
2162 ++ !ptrace_has_cap(__task_cred(task)->user_ns, mode)) {
2163 + rcu_read_unlock();
2164 + return -EPERM;
2165 + }
2166 +diff --git a/kernel/trace/trace_event_perf.c b/kernel/trace/trace_event_perf.c
2167 +index 84b1e045faba..8354dc81ae64 100644
2168 +--- a/kernel/trace/trace_event_perf.c
2169 ++++ b/kernel/trace/trace_event_perf.c
2170 +@@ -26,7 +26,7 @@ static int perf_trace_event_perm(struct ftrace_event_call *tp_event,
2171 + {
2172 + /* The ftrace function trace is allowed only for root. */
2173 + if (ftrace_event_is_function(tp_event) &&
2174 +- perf_paranoid_kernel() && !capable(CAP_SYS_ADMIN))
2175 ++ perf_paranoid_tracepoint_raw() && !capable(CAP_SYS_ADMIN))
2176 + return -EPERM;
2177 +
2178 + /* No tracing, just counting, so no obvious leak */
2179 +diff --git a/mm/slub.c b/mm/slub.c
2180 +index 57707f01bcfb..c34bd44e8be9 100644
2181 +--- a/mm/slub.c
2182 ++++ b/mm/slub.c
2183 +@@ -1201,8 +1201,8 @@ static unsigned long kmem_cache_flags(unsigned long object_size,
2184 + /*
2185 + * Enable debugging if selected on the kernel commandline.
2186 + */
2187 +- if (slub_debug && (!slub_debug_slabs ||
2188 +- !strncmp(slub_debug_slabs, name, strlen(slub_debug_slabs))))
2189 ++ if (slub_debug && (!slub_debug_slabs || (name &&
2190 ++ !strncmp(slub_debug_slabs, name, strlen(slub_debug_slabs)))))
2191 + flags |= slub_debug;
2192 +
2193 + return flags;
2194 +diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
2195 +index 426f8fcc4c6c..5b1bf7b530f1 100644
2196 +--- a/net/sunrpc/clnt.c
2197 ++++ b/net/sunrpc/clnt.c
2198 +@@ -1407,9 +1407,9 @@ call_refreshresult(struct rpc_task *task)
2199 + return;
2200 + case -ETIMEDOUT:
2201 + rpc_delay(task, 3*HZ);
2202 +- case -EKEYEXPIRED:
2203 + case -EAGAIN:
2204 + status = -EACCES;
2205 ++ case -EKEYEXPIRED:
2206 + if (!task->tk_cred_retry)
2207 + break;
2208 + task->tk_cred_retry--;
2209 +diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
2210 +index ffd50348a509..8a0e04d0928a 100644
2211 +--- a/net/sunrpc/xprtsock.c
2212 ++++ b/net/sunrpc/xprtsock.c
2213 +@@ -391,8 +391,10 @@ static int xs_send_kvec(struct socket *sock, struct sockaddr *addr, int addrlen,
2214 + return kernel_sendmsg(sock, &msg, NULL, 0, 0);
2215 + }
2216 +
2217 +-static int xs_send_pagedata(struct socket *sock, struct xdr_buf *xdr, unsigned int base, int more)
2218 ++static int xs_send_pagedata(struct socket *sock, struct xdr_buf *xdr, unsigned int base, int more, bool zerocopy)
2219 + {
2220 ++ ssize_t (*do_sendpage)(struct socket *sock, struct page *page,
2221 ++ int offset, size_t size, int flags);
2222 + struct page **ppage;
2223 + unsigned int remainder;
2224 + int err, sent = 0;
2225 +@@ -401,6 +403,9 @@ static int xs_send_pagedata(struct socket *sock, struct xdr_buf *xdr, unsigned i
2226 + base += xdr->page_base;
2227 + ppage = xdr->pages + (base >> PAGE_SHIFT);
2228 + base &= ~PAGE_MASK;
2229 ++ do_sendpage = sock->ops->sendpage;
2230 ++ if (!zerocopy)
2231 ++ do_sendpage = sock_no_sendpage;
2232 + for(;;) {
2233 + unsigned int len = min_t(unsigned int, PAGE_SIZE - base, remainder);
2234 + int flags = XS_SENDMSG_FLAGS;
2235 +@@ -408,7 +413,7 @@ static int xs_send_pagedata(struct socket *sock, struct xdr_buf *xdr, unsigned i
2236 + remainder -= len;
2237 + if (remainder != 0 || more)
2238 + flags |= MSG_MORE;
2239 +- err = sock->ops->sendpage(sock, *ppage, base, len, flags);
2240 ++ err = do_sendpage(sock, *ppage, base, len, flags);
2241 + if (remainder == 0 || err != len)
2242 + break;
2243 + sent += err;
2244 +@@ -429,9 +434,10 @@ static int xs_send_pagedata(struct socket *sock, struct xdr_buf *xdr, unsigned i
2245 + * @addrlen: UDP only -- length of destination address
2246 + * @xdr: buffer containing this request
2247 + * @base: starting position in the buffer
2248 ++ * @zerocopy: true if it is safe to use sendpage()
2249 + *
2250 + */
2251 +-static int xs_sendpages(struct socket *sock, struct sockaddr *addr, int addrlen, struct xdr_buf *xdr, unsigned int base)
2252 ++static int xs_sendpages(struct socket *sock, struct sockaddr *addr, int addrlen, struct xdr_buf *xdr, unsigned int base, bool zerocopy)
2253 + {
2254 + unsigned int remainder = xdr->len - base;
2255 + int err, sent = 0;
2256 +@@ -459,7 +465,7 @@ static int xs_sendpages(struct socket *sock, struct sockaddr *addr, int addrlen,
2257 + if (base < xdr->page_len) {
2258 + unsigned int len = xdr->page_len - base;
2259 + remainder -= len;
2260 +- err = xs_send_pagedata(sock, xdr, base, remainder != 0);
2261 ++ err = xs_send_pagedata(sock, xdr, base, remainder != 0, zerocopy);
2262 + if (remainder == 0 || err != len)
2263 + goto out;
2264 + sent += err;
2265 +@@ -562,7 +568,7 @@ static int xs_local_send_request(struct rpc_task *task)
2266 + req->rq_svec->iov_base, req->rq_svec->iov_len);
2267 +
2268 + status = xs_sendpages(transport->sock, NULL, 0,
2269 +- xdr, req->rq_bytes_sent);
2270 ++ xdr, req->rq_bytes_sent, true);
2271 + dprintk("RPC: %s(%u) = %d\n",
2272 + __func__, xdr->len - req->rq_bytes_sent, status);
2273 + if (likely(status >= 0)) {
2274 +@@ -618,7 +624,7 @@ static int xs_udp_send_request(struct rpc_task *task)
2275 + status = xs_sendpages(transport->sock,
2276 + xs_addr(xprt),
2277 + xprt->addrlen, xdr,
2278 +- req->rq_bytes_sent);
2279 ++ req->rq_bytes_sent, true);
2280 +
2281 + dprintk("RPC: xs_udp_send_request(%u) = %d\n",
2282 + xdr->len - req->rq_bytes_sent, status);
2283 +@@ -689,6 +695,7 @@ static int xs_tcp_send_request(struct rpc_task *task)
2284 + struct rpc_xprt *xprt = req->rq_xprt;
2285 + struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt);
2286 + struct xdr_buf *xdr = &req->rq_snd_buf;
2287 ++ bool zerocopy = true;
2288 + int status;
2289 +
2290 + xs_encode_stream_record_marker(&req->rq_snd_buf);
2291 +@@ -696,13 +703,20 @@ static int xs_tcp_send_request(struct rpc_task *task)
2292 + xs_pktdump("packet data:",
2293 + req->rq_svec->iov_base,
2294 + req->rq_svec->iov_len);
2295 ++ /* Don't use zero copy if this is a resend. If the RPC call
2296 ++ * completes while the socket holds a reference to the pages,
2297 ++ * then we may end up resending corrupted data.
2298 ++ */
2299 ++ if (task->tk_flags & RPC_TASK_SENT)
2300 ++ zerocopy = false;
2301 +
2302 + /* Continue transmitting the packet/record. We must be careful
2303 + * to cope with writespace callbacks arriving _after_ we have
2304 + * called sendmsg(). */
2305 + while (1) {
2306 + status = xs_sendpages(transport->sock,
2307 +- NULL, 0, xdr, req->rq_bytes_sent);
2308 ++ NULL, 0, xdr, req->rq_bytes_sent,
2309 ++ zerocopy);
2310 +
2311 + dprintk("RPC: xs_tcp_send_request(%u) = %d\n",
2312 + xdr->len - req->rq_bytes_sent, status);
2313 +diff --git a/security/integrity/ima/ima_policy.c b/security/integrity/ima/ima_policy.c
2314 +index 399433ad614e..a9c3d3cd1990 100644
2315 +--- a/security/integrity/ima/ima_policy.c
2316 ++++ b/security/integrity/ima/ima_policy.c
2317 +@@ -73,7 +73,6 @@ static struct ima_rule_entry default_rules[] = {
2318 + {.action = DONT_MEASURE,.fsmagic = SYSFS_MAGIC,.flags = IMA_FSMAGIC},
2319 + {.action = DONT_MEASURE,.fsmagic = DEBUGFS_MAGIC,.flags = IMA_FSMAGIC},
2320 + {.action = DONT_MEASURE,.fsmagic = TMPFS_MAGIC,.flags = IMA_FSMAGIC},
2321 +- {.action = DONT_MEASURE,.fsmagic = RAMFS_MAGIC,.flags = IMA_FSMAGIC},
2322 + {.action = DONT_MEASURE,.fsmagic = DEVPTS_SUPER_MAGIC,.flags = IMA_FSMAGIC},
2323 + {.action = DONT_MEASURE,.fsmagic = BINFMTFS_MAGIC,.flags = IMA_FSMAGIC},
2324 + {.action = DONT_MEASURE,.fsmagic = SECURITYFS_MAGIC,.flags = IMA_FSMAGIC},
2325 +diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c
2326 +index 5863ba6dd12b..19799931c51d 100644
2327 +--- a/sound/core/compress_offload.c
2328 ++++ b/sound/core/compress_offload.c
2329 +@@ -668,14 +668,48 @@ static int snd_compr_stop(struct snd_compr_stream *stream)
2330 + return -EPERM;
2331 + retval = stream->ops->trigger(stream, SNDRV_PCM_TRIGGER_STOP);
2332 + if (!retval) {
2333 +- stream->runtime->state = SNDRV_PCM_STATE_SETUP;
2334 +- wake_up(&stream->runtime->sleep);
2335 ++ snd_compr_drain_notify(stream);
2336 + stream->runtime->total_bytes_available = 0;
2337 + stream->runtime->total_bytes_transferred = 0;
2338 + }
2339 + return retval;
2340 + }
2341 +
2342 ++static int snd_compress_wait_for_drain(struct snd_compr_stream *stream)
2343 ++{
2344 ++ int ret;
2345 ++
2346 ++ /*
2347 ++ * We are called with lock held. So drop the lock while we wait for
2348 ++ * drain complete notfication from the driver
2349 ++ *
2350 ++ * It is expected that driver will notify the drain completion and then
2351 ++ * stream will be moved to SETUP state, even if draining resulted in an
2352 ++ * error. We can trigger next track after this.
2353 ++ */
2354 ++ stream->runtime->state = SNDRV_PCM_STATE_DRAINING;
2355 ++ mutex_unlock(&stream->device->lock);
2356 ++
2357 ++ /* we wait for drain to complete here, drain can return when
2358 ++ * interruption occurred, wait returned error or success.
2359 ++ * For the first two cases we don't do anything different here and
2360 ++ * return after waking up
2361 ++ */
2362 ++
2363 ++ ret = wait_event_interruptible(stream->runtime->sleep,
2364 ++ (stream->runtime->state != SNDRV_PCM_STATE_DRAINING));
2365 ++ if (ret == -ERESTARTSYS)
2366 ++ pr_debug("wait aborted by a signal");
2367 ++ else if (ret)
2368 ++ pr_debug("wait for drain failed with %d\n", ret);
2369 ++
2370 ++
2371 ++ wake_up(&stream->runtime->sleep);
2372 ++ mutex_lock(&stream->device->lock);
2373 ++
2374 ++ return ret;
2375 ++}
2376 ++
2377 + static int snd_compr_drain(struct snd_compr_stream *stream)
2378 + {
2379 + int retval;
2380 +@@ -683,12 +717,15 @@ static int snd_compr_drain(struct snd_compr_stream *stream)
2381 + if (stream->runtime->state == SNDRV_PCM_STATE_PREPARED ||
2382 + stream->runtime->state == SNDRV_PCM_STATE_SETUP)
2383 + return -EPERM;
2384 ++
2385 + retval = stream->ops->trigger(stream, SND_COMPR_TRIGGER_DRAIN);
2386 +- if (!retval) {
2387 +- stream->runtime->state = SNDRV_PCM_STATE_DRAINING;
2388 ++ if (retval) {
2389 ++ pr_debug("SND_COMPR_TRIGGER_DRAIN failed %d\n", retval);
2390 + wake_up(&stream->runtime->sleep);
2391 ++ return retval;
2392 + }
2393 +- return retval;
2394 ++
2395 ++ return snd_compress_wait_for_drain(stream);
2396 + }
2397 +
2398 + static int snd_compr_next_track(struct snd_compr_stream *stream)
2399 +@@ -724,9 +761,14 @@ static int snd_compr_partial_drain(struct snd_compr_stream *stream)
2400 + return -EPERM;
2401 +
2402 + retval = stream->ops->trigger(stream, SND_COMPR_TRIGGER_PARTIAL_DRAIN);
2403 ++ if (retval) {
2404 ++ pr_debug("Partial drain returned failure\n");
2405 ++ wake_up(&stream->runtime->sleep);
2406 ++ return retval;
2407 ++ }
2408 +
2409 + stream->next_track = false;
2410 +- return retval;
2411 ++ return snd_compress_wait_for_drain(stream);
2412 + }
2413 +
2414 + static long snd_compr_ioctl(struct file *f, unsigned int cmd, unsigned long arg)
2415 +diff --git a/sound/isa/msnd/msnd_pinnacle.c b/sound/isa/msnd/msnd_pinnacle.c
2416 +index ddabb406b14c..3a7946ebbe23 100644
2417 +--- a/sound/isa/msnd/msnd_pinnacle.c
2418 ++++ b/sound/isa/msnd/msnd_pinnacle.c
2419 +@@ -73,9 +73,11 @@
2420 + #ifdef MSND_CLASSIC
2421 + # include "msnd_classic.h"
2422 + # define LOGNAME "msnd_classic"
2423 ++# define DEV_NAME "msnd-classic"
2424 + #else
2425 + # include "msnd_pinnacle.h"
2426 + # define LOGNAME "snd_msnd_pinnacle"
2427 ++# define DEV_NAME "msnd-pinnacle"
2428 + #endif
2429 +
2430 + static void set_default_audio_parameters(struct snd_msnd *chip)
2431 +@@ -1068,8 +1070,6 @@ static int snd_msnd_isa_remove(struct device *pdev, unsigned int dev)
2432 + return 0;
2433 + }
2434 +
2435 +-#define DEV_NAME "msnd-pinnacle"
2436 +-
2437 + static struct isa_driver snd_msnd_driver = {
2438 + .match = snd_msnd_isa_match,
2439 + .probe = snd_msnd_isa_probe,
2440 +diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
2441 +index 31461ba32d3c..aeefec74a061 100644
2442 +--- a/sound/pci/hda/hda_codec.c
2443 ++++ b/sound/pci/hda/hda_codec.c
2444 +@@ -2517,9 +2517,6 @@ int snd_hda_codec_reset(struct hda_codec *codec)
2445 + cancel_delayed_work_sync(&codec->jackpoll_work);
2446 + #ifdef CONFIG_PM
2447 + cancel_delayed_work_sync(&codec->power_work);
2448 +- codec->power_on = 0;
2449 +- codec->power_transition = 0;
2450 +- codec->power_jiffies = jiffies;
2451 + flush_workqueue(bus->workq);
2452 + #endif
2453 + snd_hda_ctls_clear(codec);
2454 +@@ -3927,6 +3924,10 @@ static void hda_call_codec_resume(struct hda_codec *codec)
2455 + * in the resume / power-save sequence
2456 + */
2457 + hda_keep_power_on(codec);
2458 ++ if (codec->pm_down_notified) {
2459 ++ codec->pm_down_notified = 0;
2460 ++ hda_call_pm_notify(codec->bus, true);
2461 ++ }
2462 + hda_set_power_state(codec, AC_PWRST_D0);
2463 + restore_shutup_pins(codec);
2464 + hda_exec_init_verbs(codec);
2465 +diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c
2466 +index d0cc796f778a..26ed56f00b7c 100644
2467 +--- a/sound/pci/hda/hda_generic.c
2468 ++++ b/sound/pci/hda/hda_generic.c
2469 +@@ -786,10 +786,10 @@ static void set_pin_eapd(struct hda_codec *codec, hda_nid_t pin, bool enable)
2470 + if (spec->own_eapd_ctl ||
2471 + !(snd_hda_query_pin_caps(codec, pin) & AC_PINCAP_EAPD))
2472 + return;
2473 +- if (codec->inv_eapd)
2474 +- enable = !enable;
2475 + if (spec->keep_eapd_on && !enable)
2476 + return;
2477 ++ if (codec->inv_eapd)
2478 ++ enable = !enable;
2479 + snd_hda_codec_update_cache(codec, pin, 0,
2480 + AC_VERB_SET_EAPD_BTLENABLE,
2481 + enable ? 0x02 : 0x00);
2482 +diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c
2483 +index d97f0d61a15b..e17b55a95bc5 100644
2484 +--- a/sound/pci/hda/patch_analog.c
2485 ++++ b/sound/pci/hda/patch_analog.c
2486 +@@ -1197,8 +1197,12 @@ static int alloc_ad_spec(struct hda_codec *codec)
2487 + static void ad_fixup_inv_jack_detect(struct hda_codec *codec,
2488 + const struct hda_fixup *fix, int action)
2489 + {
2490 +- if (action == HDA_FIXUP_ACT_PRE_PROBE)
2491 ++ struct ad198x_spec *spec = codec->spec;
2492 ++
2493 ++ if (action == HDA_FIXUP_ACT_PRE_PROBE) {
2494 + codec->inv_jack_detect = 1;
2495 ++ spec->gen.keep_eapd_on = 1;
2496 ++ }
2497 + }
2498 +
2499 + enum {
2500 +diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c
2501 +index c96e1945059d..1868d3a6e310 100644
2502 +--- a/sound/pci/hda/patch_conexant.c
2503 ++++ b/sound/pci/hda/patch_conexant.c
2504 +@@ -3491,6 +3491,8 @@ static const struct hda_codec_preset snd_hda_preset_conexant[] = {
2505 + .patch = patch_conexant_auto },
2506 + { .id = 0x14f15115, .name = "CX20757",
2507 + .patch = patch_conexant_auto },
2508 ++ { .id = 0x14f151d7, .name = "CX20952",
2509 ++ .patch = patch_conexant_auto },
2510 + {} /* terminator */
2511 + };
2512 +
2513 +@@ -3517,6 +3519,7 @@ MODULE_ALIAS("snd-hda-codec-id:14f15111");
2514 + MODULE_ALIAS("snd-hda-codec-id:14f15113");
2515 + MODULE_ALIAS("snd-hda-codec-id:14f15114");
2516 + MODULE_ALIAS("snd-hda-codec-id:14f15115");
2517 ++MODULE_ALIAS("snd-hda-codec-id:14f151d7");
2518 +
2519 + MODULE_LICENSE("GPL");
2520 + MODULE_DESCRIPTION("Conexant HD-audio codec");
2521 +diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
2522 +index 4496e0ab693d..8bce044583ed 100644
2523 +--- a/sound/pci/hda/patch_realtek.c
2524 ++++ b/sound/pci/hda/patch_realtek.c
2525 +@@ -1037,6 +1037,7 @@ enum {
2526 + ALC880_FIXUP_UNIWILL,
2527 + ALC880_FIXUP_UNIWILL_DIG,
2528 + ALC880_FIXUP_Z71V,
2529 ++ ALC880_FIXUP_ASUS_W5A,
2530 + ALC880_FIXUP_3ST_BASE,
2531 + ALC880_FIXUP_3ST,
2532 + ALC880_FIXUP_3ST_DIG,
2533 +@@ -1207,6 +1208,26 @@ static const struct hda_fixup alc880_fixups[] = {
2534 + { }
2535 + }
2536 + },
2537 ++ [ALC880_FIXUP_ASUS_W5A] = {
2538 ++ .type = HDA_FIXUP_PINS,
2539 ++ .v.pins = (const struct hda_pintbl[]) {
2540 ++ /* set up the whole pins as BIOS is utterly broken */
2541 ++ { 0x14, 0x0121411f }, /* HP */
2542 ++ { 0x15, 0x411111f0 }, /* N/A */
2543 ++ { 0x16, 0x411111f0 }, /* N/A */
2544 ++ { 0x17, 0x411111f0 }, /* N/A */
2545 ++ { 0x18, 0x90a60160 }, /* mic */
2546 ++ { 0x19, 0x411111f0 }, /* N/A */
2547 ++ { 0x1a, 0x411111f0 }, /* N/A */
2548 ++ { 0x1b, 0x411111f0 }, /* N/A */
2549 ++ { 0x1c, 0x411111f0 }, /* N/A */
2550 ++ { 0x1d, 0x411111f0 }, /* N/A */
2551 ++ { 0x1e, 0xb743111e }, /* SPDIF out */
2552 ++ { }
2553 ++ },
2554 ++ .chained = true,
2555 ++ .chain_id = ALC880_FIXUP_GPIO1,
2556 ++ },
2557 + [ALC880_FIXUP_3ST_BASE] = {
2558 + .type = HDA_FIXUP_PINS,
2559 + .v.pins = (const struct hda_pintbl[]) {
2560 +@@ -1328,6 +1349,7 @@ static const struct hda_fixup alc880_fixups[] = {
2561 +
2562 + static const struct snd_pci_quirk alc880_fixup_tbl[] = {
2563 + SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_FIXUP_W810),
2564 ++ SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS W5A", ALC880_FIXUP_ASUS_W5A),
2565 + SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_FIXUP_Z71V),
2566 + SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_FIXUP_GPIO1),
2567 + SND_PCI_QUIRK(0x1558, 0x5401, "Clevo GPIO2", ALC880_FIXUP_GPIO2),
2568 +@@ -1473,6 +1495,7 @@ enum {
2569 + ALC260_FIXUP_KN1,
2570 + ALC260_FIXUP_FSC_S7020,
2571 + ALC260_FIXUP_FSC_S7020_JWSE,
2572 ++ ALC260_FIXUP_VAIO_PINS,
2573 + };
2574 +
2575 + static void alc260_gpio1_automute(struct hda_codec *codec)
2576 +@@ -1613,6 +1636,24 @@ static const struct hda_fixup alc260_fixups[] = {
2577 + .chained = true,
2578 + .chain_id = ALC260_FIXUP_FSC_S7020,
2579 + },
2580 ++ [ALC260_FIXUP_VAIO_PINS] = {
2581 ++ .type = HDA_FIXUP_PINS,
2582 ++ .v.pins = (const struct hda_pintbl[]) {
2583 ++ /* Pin configs are missing completely on some VAIOs */
2584 ++ { 0x0f, 0x01211020 },
2585 ++ { 0x10, 0x0001003f },
2586 ++ { 0x11, 0x411111f0 },
2587 ++ { 0x12, 0x01a15930 },
2588 ++ { 0x13, 0x411111f0 },
2589 ++ { 0x14, 0x411111f0 },
2590 ++ { 0x15, 0x411111f0 },
2591 ++ { 0x16, 0x411111f0 },
2592 ++ { 0x17, 0x411111f0 },
2593 ++ { 0x18, 0x411111f0 },
2594 ++ { 0x19, 0x411111f0 },
2595 ++ { }
2596 ++ }
2597 ++ },
2598 + };
2599 +
2600 + static const struct snd_pci_quirk alc260_fixup_tbl[] = {
2601 +@@ -1621,6 +1662,8 @@ static const struct snd_pci_quirk alc260_fixup_tbl[] = {
2602 + SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_FIXUP_GPIO1),
2603 + SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", ALC260_FIXUP_HP_DC5750),
2604 + SND_PCI_QUIRK(0x103c, 0x30ba, "HP Presario B1900", ALC260_FIXUP_HP_B1900),
2605 ++ SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_FIXUP_VAIO_PINS),
2606 ++ SND_PCI_QUIRK(0x104d, 0x81e2, "Sony VAIO TX", ALC260_FIXUP_HP_PIN_0F),
2607 + SND_PCI_QUIRK(0x10cf, 0x1326, "FSC LifeBook S7020", ALC260_FIXUP_FSC_S7020),
2608 + SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FIXUP_GPIO1),
2609 + SND_PCI_QUIRK(0x152d, 0x0729, "Quanta KN1", ALC260_FIXUP_KN1),
2610 +@@ -2380,6 +2423,7 @@ static const struct hda_verb alc268_beep_init_verbs[] = {
2611 + enum {
2612 + ALC268_FIXUP_INV_DMIC,
2613 + ALC268_FIXUP_HP_EAPD,
2614 ++ ALC268_FIXUP_SPDIF,
2615 + };
2616 +
2617 + static const struct hda_fixup alc268_fixups[] = {
2618 +@@ -2394,6 +2438,13 @@ static const struct hda_fixup alc268_fixups[] = {
2619 + {}
2620 + }
2621 + },
2622 ++ [ALC268_FIXUP_SPDIF] = {
2623 ++ .type = HDA_FIXUP_PINS,
2624 ++ .v.pins = (const struct hda_pintbl[]) {
2625 ++ { 0x1e, 0x014b1180 }, /* enable SPDIF out */
2626 ++ {}
2627 ++ }
2628 ++ },
2629 + };
2630 +
2631 + static const struct hda_model_fixup alc268_fixup_models[] = {
2632 +@@ -2403,6 +2454,7 @@ static const struct hda_model_fixup alc268_fixup_models[] = {
2633 + };
2634 +
2635 + static const struct snd_pci_quirk alc268_fixup_tbl[] = {
2636 ++ SND_PCI_QUIRK(0x1025, 0x0139, "Acer TravelMate 6293", ALC268_FIXUP_SPDIF),
2637 + SND_PCI_QUIRK(0x1025, 0x015b, "Acer AOA 150 (ZG5)", ALC268_FIXUP_INV_DMIC),
2638 + /* below is codec SSID since multiple Toshiba laptops have the
2639 + * same PCI SSID 1179:ff00
2640 +@@ -2531,6 +2583,7 @@ enum {
2641 + ALC269_TYPE_ALC282,
2642 + ALC269_TYPE_ALC284,
2643 + ALC269_TYPE_ALC286,
2644 ++ ALC269_TYPE_ALC255,
2645 + };
2646 +
2647 + /*
2648 +@@ -2555,6 +2608,7 @@ static int alc269_parse_auto_config(struct hda_codec *codec)
2649 + case ALC269_TYPE_ALC269VD:
2650 + case ALC269_TYPE_ALC282:
2651 + case ALC269_TYPE_ALC286:
2652 ++ case ALC269_TYPE_ALC255:
2653 + ssids = alc269_ssids;
2654 + break;
2655 + default:
2656 +@@ -2754,6 +2808,23 @@ static void alc269_fixup_mic_mute_hook(void *private_data, int enabled)
2657 + snd_hda_set_pin_ctl_cache(codec, spec->mute_led_nid, pinval);
2658 + }
2659 +
2660 ++/* Make sure the led works even in runtime suspend */
2661 ++static unsigned int led_power_filter(struct hda_codec *codec,
2662 ++ hda_nid_t nid,
2663 ++ unsigned int power_state)
2664 ++{
2665 ++ struct alc_spec *spec = codec->spec;
2666 ++
2667 ++ if (power_state != AC_PWRST_D3 || nid != spec->mute_led_nid)
2668 ++ return power_state;
2669 ++
2670 ++ /* Set pin ctl again, it might have just been set to 0 */
2671 ++ snd_hda_set_pin_ctl(codec, nid,
2672 ++ snd_hda_codec_get_pin_target(codec, nid));
2673 ++
2674 ++ return AC_PWRST_D0;
2675 ++}
2676 ++
2677 + static void alc269_fixup_hp_mute_led(struct hda_codec *codec,
2678 + const struct hda_fixup *fix, int action)
2679 + {
2680 +@@ -2773,6 +2844,7 @@ static void alc269_fixup_hp_mute_led(struct hda_codec *codec,
2681 + spec->mute_led_nid = pin - 0x0a + 0x18;
2682 + spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook;
2683 + spec->gen.vmaster_mute_enum = 1;
2684 ++ codec->power_filter = led_power_filter;
2685 + snd_printd("Detected mute LED for %x:%d\n", spec->mute_led_nid,
2686 + spec->mute_led_polarity);
2687 + break;
2688 +@@ -2788,6 +2860,7 @@ static void alc269_fixup_hp_mute_led_mic1(struct hda_codec *codec,
2689 + spec->mute_led_nid = 0x18;
2690 + spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook;
2691 + spec->gen.vmaster_mute_enum = 1;
2692 ++ codec->power_filter = led_power_filter;
2693 + }
2694 + }
2695 +
2696 +@@ -2800,6 +2873,7 @@ static void alc269_fixup_hp_mute_led_mic2(struct hda_codec *codec,
2697 + spec->mute_led_nid = 0x19;
2698 + spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook;
2699 + spec->gen.vmaster_mute_enum = 1;
2700 ++ codec->power_filter = led_power_filter;
2701 + }
2702 + }
2703 +
2704 +@@ -3040,8 +3114,10 @@ static void alc_update_headset_mode(struct hda_codec *codec)
2705 + else
2706 + new_headset_mode = ALC_HEADSET_MODE_HEADPHONE;
2707 +
2708 +- if (new_headset_mode == spec->current_headset_mode)
2709 ++ if (new_headset_mode == spec->current_headset_mode) {
2710 ++ snd_hda_gen_update_outputs(codec);
2711 + return;
2712 ++ }
2713 +
2714 + switch (new_headset_mode) {
2715 + case ALC_HEADSET_MODE_UNPLUGGED:
2716 +@@ -3545,6 +3621,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
2717 + SND_PCI_QUIRK(0x1028, 0x0608, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
2718 + SND_PCI_QUIRK(0x1028, 0x0609, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
2719 + SND_PCI_QUIRK(0x1028, 0x0613, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
2720 ++ SND_PCI_QUIRK(0x1028, 0x0614, "Dell Inspiron 3135", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
2721 + SND_PCI_QUIRK(0x1028, 0x0616, "Dell Vostro 5470", ALC290_FIXUP_MONO_SPEAKERS),
2722 + SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC2),
2723 + SND_PCI_QUIRK(0x103c, 0x18e6, "HP", ALC269_FIXUP_HP_GPIO_LED),
2724 +@@ -3765,6 +3842,9 @@ static int patch_alc269(struct hda_codec *codec)
2725 + case 0x10ec0286:
2726 + spec->codec_variant = ALC269_TYPE_ALC286;
2727 + break;
2728 ++ case 0x10ec0255:
2729 ++ spec->codec_variant = ALC269_TYPE_ALC255;
2730 ++ break;
2731 + }
2732 +
2733 + /* automatic parse from the BIOS config */
2734 +@@ -4472,6 +4552,7 @@ static int patch_alc680(struct hda_codec *codec)
2735 + static const struct hda_codec_preset snd_hda_preset_realtek[] = {
2736 + { .id = 0x10ec0221, .name = "ALC221", .patch = patch_alc269 },
2737 + { .id = 0x10ec0233, .name = "ALC233", .patch = patch_alc269 },
2738 ++ { .id = 0x10ec0255, .name = "ALC255", .patch = patch_alc269 },
2739 + { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
2740 + { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
2741 + { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
2742 +diff --git a/sound/usb/6fire/chip.c b/sound/usb/6fire/chip.c
2743 +index 4394ae796356..0716ba691398 100644
2744 +--- a/sound/usb/6fire/chip.c
2745 ++++ b/sound/usb/6fire/chip.c
2746 +@@ -101,7 +101,7 @@ static int usb6fire_chip_probe(struct usb_interface *intf,
2747 + usb_set_intfdata(intf, chips[i]);
2748 + mutex_unlock(&register_mutex);
2749 + return 0;
2750 +- } else if (regidx < 0)
2751 ++ } else if (!devices[i] && regidx < 0)
2752 + regidx = i;
2753 + }
2754 + if (regidx < 0) {
2755 +diff --git a/virt/kvm/iommu.c b/virt/kvm/iommu.c
2756 +index 72a130bc448a..c329c8fc57f4 100644
2757 +--- a/virt/kvm/iommu.c
2758 ++++ b/virt/kvm/iommu.c
2759 +@@ -103,6 +103,10 @@ int kvm_iommu_map_pages(struct kvm *kvm, struct kvm_memory_slot *slot)
2760 + while ((gfn << PAGE_SHIFT) & (page_size - 1))
2761 + page_size >>= 1;
2762 +
2763 ++ /* Make sure hva is aligned to the page size we want to map */
2764 ++ while (__gfn_to_hva_memslot(slot, gfn) & (page_size - 1))
2765 ++ page_size >>= 1;
2766 ++
2767 + /*
2768 + * Pin all pages we are about to map in memory. This is
2769 + * important because we unmap and unpin in 4kb steps later.
2770
2771 Modified: genpatches-2.6/trunk/3.11/0000_README
2772 ===================================================================
2773 --- genpatches-2.6/trunk/3.11/0000_README 2013-11-26 00:34:31 UTC (rev 2594)
2774 +++ genpatches-2.6/trunk/3.11/0000_README 2013-11-29 23:44:29 UTC (rev 2595)
2775 @@ -78,6 +78,10 @@
2776 From: http://www.kernel.org
2777 Desc: Linux 3.11.9
2778
2779 +Patch: 1009_linux-3.11.10.patch
2780 +From: http://www.kernel.org
2781 +Desc: Linux 3.11.10
2782 +
2783 Patch: 1500_XATTR_USER_PREFIX.patch
2784 From: https://bugs.gentoo.org/show_bug.cgi?id=470644
2785 Desc: Support for namespace user.pax.* on tmpfs.
2786
2787 Added: genpatches-2.6/trunk/3.11/1009_linux-3.11.10.patch
2788 ===================================================================
2789 --- genpatches-2.6/trunk/3.11/1009_linux-3.11.10.patch (rev 0)
2790 +++ genpatches-2.6/trunk/3.11/1009_linux-3.11.10.patch 2013-11-29 23:44:29 UTC (rev 2595)
2791 @@ -0,0 +1,1424 @@
2792 +diff --git a/Makefile b/Makefile
2793 +index 06379bd78b64..7feb3ad77387 100644
2794 +--- a/Makefile
2795 ++++ b/Makefile
2796 +@@ -1,6 +1,6 @@
2797 + VERSION = 3
2798 + PATCHLEVEL = 11
2799 +-SUBLEVEL = 9
2800 ++SUBLEVEL = 10
2801 + EXTRAVERSION =
2802 + NAME = Linux for Workgroups
2803 +
2804 +diff --git a/arch/ia64/include/asm/processor.h b/arch/ia64/include/asm/processor.h
2805 +index e0a899a1a8a6..5a84b3a50741 100644
2806 +--- a/arch/ia64/include/asm/processor.h
2807 ++++ b/arch/ia64/include/asm/processor.h
2808 +@@ -319,7 +319,7 @@ struct thread_struct {
2809 + regs->loadrs = 0; \
2810 + regs->r8 = get_dumpable(current->mm); /* set "don't zap registers" flag */ \
2811 + regs->r12 = new_sp - 16; /* allocate 16 byte scratch area */ \
2812 +- if (unlikely(!get_dumpable(current->mm))) { \
2813 ++ if (unlikely(get_dumpable(current->mm) != SUID_DUMP_USER)) { \
2814 + /* \
2815 + * Zap scratch regs to avoid leaking bits between processes with different \
2816 + * uid/privileges. \
2817 +diff --git a/arch/s390/crypto/aes_s390.c b/arch/s390/crypto/aes_s390.c
2818 +index b4dbade8ca24..2e4b5be31a1b 100644
2819 +--- a/arch/s390/crypto/aes_s390.c
2820 ++++ b/arch/s390/crypto/aes_s390.c
2821 +@@ -35,7 +35,6 @@ static u8 *ctrblk;
2822 + static char keylen_flag;
2823 +
2824 + struct s390_aes_ctx {
2825 +- u8 iv[AES_BLOCK_SIZE];
2826 + u8 key[AES_MAX_KEY_SIZE];
2827 + long enc;
2828 + long dec;
2829 +@@ -441,30 +440,36 @@ static int cbc_aes_set_key(struct crypto_tfm *tfm, const u8 *in_key,
2830 + return aes_set_key(tfm, in_key, key_len);
2831 + }
2832 +
2833 +-static int cbc_aes_crypt(struct blkcipher_desc *desc, long func, void *param,
2834 ++static int cbc_aes_crypt(struct blkcipher_desc *desc, long func,
2835 + struct blkcipher_walk *walk)
2836 + {
2837 ++ struct s390_aes_ctx *sctx = crypto_blkcipher_ctx(desc->tfm);
2838 + int ret = blkcipher_walk_virt(desc, walk);
2839 + unsigned int nbytes = walk->nbytes;
2840 ++ struct {
2841 ++ u8 iv[AES_BLOCK_SIZE];
2842 ++ u8 key[AES_MAX_KEY_SIZE];
2843 ++ } param;
2844 +
2845 + if (!nbytes)
2846 + goto out;
2847 +
2848 +- memcpy(param, walk->iv, AES_BLOCK_SIZE);
2849 ++ memcpy(param.iv, walk->iv, AES_BLOCK_SIZE);
2850 ++ memcpy(param.key, sctx->key, sctx->key_len);
2851 + do {
2852 + /* only use complete blocks */
2853 + unsigned int n = nbytes & ~(AES_BLOCK_SIZE - 1);
2854 + u8 *out = walk->dst.virt.addr;
2855 + u8 *in = walk->src.virt.addr;
2856 +
2857 +- ret = crypt_s390_kmc(func, param, out, in, n);
2858 ++ ret = crypt_s390_kmc(func, &param, out, in, n);
2859 + if (ret < 0 || ret != n)
2860 + return -EIO;
2861 +
2862 + nbytes &= AES_BLOCK_SIZE - 1;
2863 + ret = blkcipher_walk_done(desc, walk, nbytes);
2864 + } while ((nbytes = walk->nbytes));
2865 +- memcpy(walk->iv, param, AES_BLOCK_SIZE);
2866 ++ memcpy(walk->iv, param.iv, AES_BLOCK_SIZE);
2867 +
2868 + out:
2869 + return ret;
2870 +@@ -481,7 +486,7 @@ static int cbc_aes_encrypt(struct blkcipher_desc *desc,
2871 + return fallback_blk_enc(desc, dst, src, nbytes);
2872 +
2873 + blkcipher_walk_init(&walk, dst, src, nbytes);
2874 +- return cbc_aes_crypt(desc, sctx->enc, sctx->iv, &walk);
2875 ++ return cbc_aes_crypt(desc, sctx->enc, &walk);
2876 + }
2877 +
2878 + static int cbc_aes_decrypt(struct blkcipher_desc *desc,
2879 +@@ -495,7 +500,7 @@ static int cbc_aes_decrypt(struct blkcipher_desc *desc,
2880 + return fallback_blk_dec(desc, dst, src, nbytes);
2881 +
2882 + blkcipher_walk_init(&walk, dst, src, nbytes);
2883 +- return cbc_aes_crypt(desc, sctx->dec, sctx->iv, &walk);
2884 ++ return cbc_aes_crypt(desc, sctx->dec, &walk);
2885 + }
2886 +
2887 + static struct crypto_alg cbc_aes_alg = {
2888 +diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
2889 +index 83369e5a1d27..0b586c0ef7c3 100644
2890 +--- a/arch/x86/kernel/process.c
2891 ++++ b/arch/x86/kernel/process.c
2892 +@@ -391,9 +391,9 @@ static void amd_e400_idle(void)
2893 + * The switch back from broadcast mode needs to be
2894 + * called with interrupts disabled.
2895 + */
2896 +- local_irq_disable();
2897 +- clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_EXIT, &cpu);
2898 +- local_irq_enable();
2899 ++ local_irq_disable();
2900 ++ clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_EXIT, &cpu);
2901 ++ local_irq_enable();
2902 + } else
2903 + default_idle();
2904 + }
2905 +diff --git a/crypto/ansi_cprng.c b/crypto/ansi_cprng.c
2906 +index c0bb3778f1ae..666f1962a160 100644
2907 +--- a/crypto/ansi_cprng.c
2908 ++++ b/crypto/ansi_cprng.c
2909 +@@ -230,11 +230,11 @@ remainder:
2910 + */
2911 + if (byte_count < DEFAULT_BLK_SZ) {
2912 + empty_rbuf:
2913 +- for (; ctx->rand_data_valid < DEFAULT_BLK_SZ;
2914 +- ctx->rand_data_valid++) {
2915 ++ while (ctx->rand_data_valid < DEFAULT_BLK_SZ) {
2916 + *ptr = ctx->rand_data[ctx->rand_data_valid];
2917 + ptr++;
2918 + byte_count--;
2919 ++ ctx->rand_data_valid++;
2920 + if (byte_count == 0)
2921 + goto done;
2922 + }
2923 +diff --git a/drivers/acpi/acpica/exoparg1.c b/drivers/acpi/acpica/exoparg1.c
2924 +index 814b4a3d656a..2cdd41d8ade6 100644
2925 +--- a/drivers/acpi/acpica/exoparg1.c
2926 ++++ b/drivers/acpi/acpica/exoparg1.c
2927 +@@ -962,10 +962,17 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
2928 + */
2929 + return_desc =
2930 + *(operand[0]->reference.where);
2931 +- if (return_desc) {
2932 +- acpi_ut_add_reference
2933 +- (return_desc);
2934 ++ if (!return_desc) {
2935 ++ /*
2936 ++ * Element is NULL, do not allow the dereference.
2937 ++ * This provides compatibility with other ACPI
2938 ++ * implementations.
2939 ++ */
2940 ++ return_ACPI_STATUS
2941 ++ (AE_AML_UNINITIALIZED_ELEMENT);
2942 + }
2943 ++
2944 ++ acpi_ut_add_reference(return_desc);
2945 + break;
2946 +
2947 + default:
2948 +@@ -990,11 +997,40 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
2949 + acpi_namespace_node
2950 + *)
2951 + return_desc);
2952 +- }
2953 ++ if (!return_desc) {
2954 ++ break;
2955 ++ }
2956 +
2957 +- /* Add another reference to the object! */
2958 ++ /*
2959 ++ * June 2013:
2960 ++ * buffer_fields/field_units require additional resolution
2961 ++ */
2962 ++ switch (return_desc->common.type) {
2963 ++ case ACPI_TYPE_BUFFER_FIELD:
2964 ++ case ACPI_TYPE_LOCAL_REGION_FIELD:
2965 ++ case ACPI_TYPE_LOCAL_BANK_FIELD:
2966 ++ case ACPI_TYPE_LOCAL_INDEX_FIELD:
2967 +
2968 +- acpi_ut_add_reference(return_desc);
2969 ++ status =
2970 ++ acpi_ex_read_data_from_field
2971 ++ (walk_state, return_desc,
2972 ++ &temp_desc);
2973 ++ if (ACPI_FAILURE(status)) {
2974 ++ goto cleanup;
2975 ++ }
2976 ++
2977 ++ return_desc = temp_desc;
2978 ++ break;
2979 ++
2980 ++ default:
2981 ++
2982 ++ /* Add another reference to the object */
2983 ++
2984 ++ acpi_ut_add_reference
2985 ++ (return_desc);
2986 ++ break;
2987 ++ }
2988 ++ }
2989 + break;
2990 +
2991 + default:
2992 +diff --git a/drivers/acpi/acpica/exstore.c b/drivers/acpi/acpica/exstore.c
2993 +index 2bdba6f7d762..f0b09bf9887d 100644
2994 +--- a/drivers/acpi/acpica/exstore.c
2995 ++++ b/drivers/acpi/acpica/exstore.c
2996 +@@ -57,6 +57,11 @@ acpi_ex_store_object_to_index(union acpi_operand_object *val_desc,
2997 + union acpi_operand_object *dest_desc,
2998 + struct acpi_walk_state *walk_state);
2999 +
3000 ++static acpi_status
3001 ++acpi_ex_store_direct_to_node(union acpi_operand_object *source_desc,
3002 ++ struct acpi_namespace_node *node,
3003 ++ struct acpi_walk_state *walk_state);
3004 ++
3005 + /*******************************************************************************
3006 + *
3007 + * FUNCTION: acpi_ex_store
3008 +@@ -375,7 +380,11 @@ acpi_ex_store_object_to_index(union acpi_operand_object *source_desc,
3009 + * When storing into an object the data is converted to the
3010 + * target object type then stored in the object. This means
3011 + * that the target object type (for an initialized target) will
3012 +- * not be changed by a store operation.
3013 ++ * not be changed by a store operation. A copy_object can change
3014 ++ * the target type, however.
3015 ++ *
3016 ++ * The implicit_conversion flag is set to NO/FALSE only when
3017 ++ * storing to an arg_x -- as per the rules of the ACPI spec.
3018 + *
3019 + * Assumes parameters are already validated.
3020 + *
3021 +@@ -399,7 +408,7 @@ acpi_ex_store_object_to_node(union acpi_operand_object *source_desc,
3022 + target_type = acpi_ns_get_type(node);
3023 + target_desc = acpi_ns_get_attached_object(node);
3024 +
3025 +- ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Storing %p(%s) into node %p(%s)\n",
3026 ++ ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Storing %p (%s) to node %p (%s)\n",
3027 + source_desc,
3028 + acpi_ut_get_object_type_name(source_desc), node,
3029 + acpi_ut_get_type_name(target_type)));
3030 +@@ -413,45 +422,30 @@ acpi_ex_store_object_to_node(union acpi_operand_object *source_desc,
3031 + return_ACPI_STATUS(status);
3032 + }
3033 +
3034 +- /* If no implicit conversion, drop into the default case below */
3035 +-
3036 +- if ((!implicit_conversion) ||
3037 +- ((walk_state->opcode == AML_COPY_OP) &&
3038 +- (target_type != ACPI_TYPE_LOCAL_REGION_FIELD) &&
3039 +- (target_type != ACPI_TYPE_LOCAL_BANK_FIELD) &&
3040 +- (target_type != ACPI_TYPE_LOCAL_INDEX_FIELD))) {
3041 +- /*
3042 +- * Force execution of default (no implicit conversion). Note:
3043 +- * copy_object does not perform an implicit conversion, as per the ACPI
3044 +- * spec -- except in case of region/bank/index fields -- because these
3045 +- * objects must retain their original type permanently.
3046 +- */
3047 +- target_type = ACPI_TYPE_ANY;
3048 +- }
3049 +-
3050 + /* Do the actual store operation */
3051 +
3052 + switch (target_type) {
3053 +- case ACPI_TYPE_BUFFER_FIELD:
3054 +- case ACPI_TYPE_LOCAL_REGION_FIELD:
3055 +- case ACPI_TYPE_LOCAL_BANK_FIELD:
3056 +- case ACPI_TYPE_LOCAL_INDEX_FIELD:
3057 +-
3058 +- /* For fields, copy the source data to the target field. */
3059 +-
3060 +- status = acpi_ex_write_data_to_field(source_desc, target_desc,
3061 +- &walk_state->result_obj);
3062 +- break;
3063 +-
3064 + case ACPI_TYPE_INTEGER:
3065 + case ACPI_TYPE_STRING:
3066 + case ACPI_TYPE_BUFFER:
3067 + /*
3068 +- * These target types are all of type Integer/String/Buffer, and
3069 +- * therefore support implicit conversion before the store.
3070 +- *
3071 +- * Copy and/or convert the source object to a new target object
3072 ++ * The simple data types all support implicit source operand
3073 ++ * conversion before the store.
3074 + */
3075 ++
3076 ++ if ((walk_state->opcode == AML_COPY_OP) || !implicit_conversion) {
3077 ++ /*
3078 ++ * However, copy_object and Stores to arg_x do not perform
3079 ++ * an implicit conversion, as per the ACPI specification.
3080 ++ * A direct store is performed instead.
3081 ++ */
3082 ++ status = acpi_ex_store_direct_to_node(source_desc, node,
3083 ++ walk_state);
3084 ++ break;
3085 ++ }
3086 ++
3087 ++ /* Store with implicit source operand conversion support */
3088 ++
3089 + status =
3090 + acpi_ex_store_object_to_object(source_desc, target_desc,
3091 + &new_desc, walk_state);
3092 +@@ -465,13 +459,12 @@ acpi_ex_store_object_to_node(union acpi_operand_object *source_desc,
3093 + * the Name's type to that of the value being stored in it.
3094 + * source_desc reference count is incremented by attach_object.
3095 + *
3096 +- * Note: This may change the type of the node if an explicit store
3097 +- * has been performed such that the node/object type has been
3098 +- * changed.
3099 ++ * Note: This may change the type of the node if an explicit
3100 ++ * store has been performed such that the node/object type
3101 ++ * has been changed.
3102 + */
3103 +- status =
3104 +- acpi_ns_attach_object(node, new_desc,
3105 +- new_desc->common.type);
3106 ++ status = acpi_ns_attach_object(node, new_desc,
3107 ++ new_desc->common.type);
3108 +
3109 + ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
3110 + "Store %s into %s via Convert/Attach\n",
3111 +@@ -482,38 +475,83 @@ acpi_ex_store_object_to_node(union acpi_operand_object *source_desc,
3112 + }
3113 + break;
3114 +
3115 +- default:
3116 +-
3117 +- ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
3118 +- "Storing [%s] (%p) directly into node [%s] (%p)"
3119 +- " with no implicit conversion\n",
3120 +- acpi_ut_get_object_type_name(source_desc),
3121 +- source_desc,
3122 +- acpi_ut_get_object_type_name(target_desc),
3123 +- node));
3124 ++ case ACPI_TYPE_BUFFER_FIELD:
3125 ++ case ACPI_TYPE_LOCAL_REGION_FIELD:
3126 ++ case ACPI_TYPE_LOCAL_BANK_FIELD:
3127 ++ case ACPI_TYPE_LOCAL_INDEX_FIELD:
3128 ++ /*
3129 ++ * For all fields, always write the source data to the target
3130 ++ * field. Any required implicit source operand conversion is
3131 ++ * performed in the function below as necessary. Note, field
3132 ++ * objects must retain their original type permanently.
3133 ++ */
3134 ++ status = acpi_ex_write_data_to_field(source_desc, target_desc,
3135 ++ &walk_state->result_obj);
3136 ++ break;
3137 +
3138 ++ default:
3139 + /*
3140 + * No conversions for all other types. Directly store a copy of
3141 +- * the source object. NOTE: This is a departure from the ACPI
3142 +- * spec, which states "If conversion is impossible, abort the
3143 +- * running control method".
3144 ++ * the source object. This is the ACPI spec-defined behavior for
3145 ++ * the copy_object operator.
3146 + *
3147 +- * This code implements "If conversion is impossible, treat the
3148 +- * Store operation as a CopyObject".
3149 ++ * NOTE: For the Store operator, this is a departure from the
3150 ++ * ACPI spec, which states "If conversion is impossible, abort
3151 ++ * the running control method". Instead, this code implements
3152 ++ * "If conversion is impossible, treat the Store operation as
3153 ++ * a CopyObject".
3154 + */
3155 +- status =
3156 +- acpi_ut_copy_iobject_to_iobject(source_desc, &new_desc,
3157 +- walk_state);
3158 +- if (ACPI_FAILURE(status)) {
3159 +- return_ACPI_STATUS(status);
3160 +- }
3161 +-
3162 +- status =
3163 +- acpi_ns_attach_object(node, new_desc,
3164 +- new_desc->common.type);
3165 +- acpi_ut_remove_reference(new_desc);
3166 ++ status = acpi_ex_store_direct_to_node(source_desc, node,
3167 ++ walk_state);
3168 + break;
3169 + }
3170 +
3171 + return_ACPI_STATUS(status);
3172 + }
3173 ++
3174 ++/*******************************************************************************
3175 ++ *
3176 ++ * FUNCTION: acpi_ex_store_direct_to_node
3177 ++ *
3178 ++ * PARAMETERS: source_desc - Value to be stored
3179 ++ * node - Named object to receive the value
3180 ++ * walk_state - Current walk state
3181 ++ *
3182 ++ * RETURN: Status
3183 ++ *
3184 ++ * DESCRIPTION: "Store" an object directly to a node. This involves a copy
3185 ++ * and an attach.
3186 ++ *
3187 ++ ******************************************************************************/
3188 ++
3189 ++static acpi_status
3190 ++acpi_ex_store_direct_to_node(union acpi_operand_object *source_desc,
3191 ++ struct acpi_namespace_node *node,
3192 ++ struct acpi_walk_state *walk_state)
3193 ++{
3194 ++ acpi_status status;
3195 ++ union acpi_operand_object *new_desc;
3196 ++
3197 ++ ACPI_FUNCTION_TRACE(ex_store_direct_to_node);
3198 ++
3199 ++ ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
3200 ++ "Storing [%s] (%p) directly into node [%s] (%p)"
3201 ++ " with no implicit conversion\n",
3202 ++ acpi_ut_get_object_type_name(source_desc),
3203 ++ source_desc, acpi_ut_get_type_name(node->type),
3204 ++ node));
3205 ++
3206 ++ /* Copy the source object to a new object */
3207 ++
3208 ++ status =
3209 ++ acpi_ut_copy_iobject_to_iobject(source_desc, &new_desc, walk_state);
3210 ++ if (ACPI_FAILURE(status)) {
3211 ++ return_ACPI_STATUS(status);
3212 ++ }
3213 ++
3214 ++ /* Attach the new object to the node */
3215 ++
3216 ++ status = acpi_ns_attach_object(node, new_desc, new_desc->common.type);
3217 ++ acpi_ut_remove_reference(new_desc);
3218 ++ return_ACPI_STATUS(status);
3219 ++}
3220 +diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
3221 +index 45af90a1ec1b..1ad5a4f9e0c3 100644
3222 +--- a/drivers/acpi/ec.c
3223 ++++ b/drivers/acpi/ec.c
3224 +@@ -175,9 +175,10 @@ static void start_transaction(struct acpi_ec *ec)
3225 + static void advance_transaction(struct acpi_ec *ec, u8 status)
3226 + {
3227 + unsigned long flags;
3228 +- struct transaction *t = ec->curr;
3229 ++ struct transaction *t;
3230 +
3231 + spin_lock_irqsave(&ec->lock, flags);
3232 ++ t = ec->curr;
3233 + if (!t)
3234 + goto unlock;
3235 + if (t->wlen > t->wi) {
3236 +diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
3237 +index a67853e3c419..7dbe92cb7cb8 100644
3238 +--- a/drivers/acpi/pci_root.c
3239 ++++ b/drivers/acpi/pci_root.c
3240 +@@ -611,9 +611,12 @@ static void handle_root_bridge_removal(struct acpi_device *device)
3241 + ej_event->device = device;
3242 + ej_event->event = ACPI_NOTIFY_EJECT_REQUEST;
3243 +
3244 ++ get_device(&device->dev);
3245 + status = acpi_os_hotplug_execute(acpi_bus_hot_remove_device, ej_event);
3246 +- if (ACPI_FAILURE(status))
3247 ++ if (ACPI_FAILURE(status)) {
3248 ++ put_device(&device->dev);
3249 + kfree(ej_event);
3250 ++ }
3251 + }
3252 +
3253 + static void _handle_hotplug_event_root(struct work_struct *work)
3254 +diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
3255 +index f98dd00b51a9..c7414a545a4f 100644
3256 +--- a/drivers/acpi/processor_idle.c
3257 ++++ b/drivers/acpi/processor_idle.c
3258 +@@ -119,17 +119,10 @@ static struct dmi_system_id processor_power_dmi_table[] = {
3259 + */
3260 + static void acpi_safe_halt(void)
3261 + {
3262 +- current_thread_info()->status &= ~TS_POLLING;
3263 +- /*
3264 +- * TS_POLLING-cleared state must be visible before we
3265 +- * test NEED_RESCHED:
3266 +- */
3267 +- smp_mb();
3268 +- if (!need_resched()) {
3269 ++ if (!tif_need_resched()) {
3270 + safe_halt();
3271 + local_irq_disable();
3272 + }
3273 +- current_thread_info()->status |= TS_POLLING;
3274 + }
3275 +
3276 + #ifdef ARCH_APICTIMER_STOPS_ON_C3
3277 +@@ -737,6 +730,11 @@ static int acpi_idle_enter_c1(struct cpuidle_device *dev,
3278 + if (unlikely(!pr))
3279 + return -EINVAL;
3280 +
3281 ++ if (cx->entry_method == ACPI_CSTATE_FFH) {
3282 ++ if (current_set_polling_and_test())
3283 ++ return -EINVAL;
3284 ++ }
3285 ++
3286 + lapic_timer_state_broadcast(pr, cx, 1);
3287 + acpi_idle_do_entry(cx);
3288 +
3289 +@@ -790,18 +788,9 @@ static int acpi_idle_enter_simple(struct cpuidle_device *dev,
3290 + if (unlikely(!pr))
3291 + return -EINVAL;
3292 +
3293 +- if (cx->entry_method != ACPI_CSTATE_FFH) {
3294 +- current_thread_info()->status &= ~TS_POLLING;
3295 +- /*
3296 +- * TS_POLLING-cleared state must be visible before we test
3297 +- * NEED_RESCHED:
3298 +- */
3299 +- smp_mb();
3300 +-
3301 +- if (unlikely(need_resched())) {
3302 +- current_thread_info()->status |= TS_POLLING;
3303 ++ if (cx->entry_method == ACPI_CSTATE_FFH) {
3304 ++ if (current_set_polling_and_test())
3305 + return -EINVAL;
3306 +- }
3307 + }
3308 +
3309 + /*
3310 +@@ -819,9 +808,6 @@ static int acpi_idle_enter_simple(struct cpuidle_device *dev,
3311 +
3312 + sched_clock_idle_wakeup_event(0);
3313 +
3314 +- if (cx->entry_method != ACPI_CSTATE_FFH)
3315 +- current_thread_info()->status |= TS_POLLING;
3316 +-
3317 + lapic_timer_state_broadcast(pr, cx, 0);
3318 + return index;
3319 + }
3320 +@@ -858,18 +844,9 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev,
3321 + }
3322 + }
3323 +
3324 +- if (cx->entry_method != ACPI_CSTATE_FFH) {
3325 +- current_thread_info()->status &= ~TS_POLLING;
3326 +- /*
3327 +- * TS_POLLING-cleared state must be visible before we test
3328 +- * NEED_RESCHED:
3329 +- */
3330 +- smp_mb();
3331 +-
3332 +- if (unlikely(need_resched())) {
3333 +- current_thread_info()->status |= TS_POLLING;
3334 ++ if (cx->entry_method == ACPI_CSTATE_FFH) {
3335 ++ if (current_set_polling_and_test())
3336 + return -EINVAL;
3337 +- }
3338 + }
3339 +
3340 + acpi_unlazy_tlb(smp_processor_id());
3341 +@@ -915,9 +892,6 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev,
3342 +
3343 + sched_clock_idle_wakeup_event(0);
3344 +
3345 +- if (cx->entry_method != ACPI_CSTATE_FFH)
3346 +- current_thread_info()->status |= TS_POLLING;
3347 +-
3348 + lapic_timer_state_broadcast(pr, cx, 0);
3349 + return index;
3350 + }
3351 +diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
3352 +index 8a46c924effd..0ebb955bc03a 100644
3353 +--- a/drivers/acpi/scan.c
3354 ++++ b/drivers/acpi/scan.c
3355 +@@ -359,8 +359,6 @@ static void acpi_scan_bus_device_check(acpi_handle handle, u32 ost_source)
3356 + goto out;
3357 + }
3358 + }
3359 +- acpi_evaluate_hotplug_ost(handle, ost_source,
3360 +- ACPI_OST_SC_INSERT_IN_PROGRESS, NULL);
3361 + error = acpi_bus_scan(handle);
3362 + if (error) {
3363 + acpi_handle_warn(handle, "Namespace scan failure\n");
3364 +diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
3365 +index 3270d3c8ba4e..28e5184b565b 100644
3366 +--- a/drivers/acpi/video.c
3367 ++++ b/drivers/acpi/video.c
3368 +@@ -848,7 +848,7 @@ acpi_video_init_brightness(struct acpi_video_device *device)
3369 + for (i = 2; i < br->count; i++)
3370 + if (level_old == br->levels[i])
3371 + break;
3372 +- if (i == br->count)
3373 ++ if (i == br->count || !level)
3374 + level = max_level;
3375 + }
3376 +
3377 +diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
3378 +index 3221a55dddad..58491f1b2799 100644
3379 +--- a/drivers/bluetooth/btusb.c
3380 ++++ b/drivers/bluetooth/btusb.c
3381 +@@ -1625,7 +1625,6 @@ static struct usb_driver btusb_driver = {
3382 + #ifdef CONFIG_PM
3383 + .suspend = btusb_suspend,
3384 + .resume = btusb_resume,
3385 +- .reset_resume = btusb_resume,
3386 + #endif
3387 + .id_table = btusb_table,
3388 + .supports_autosuspend = 1,
3389 +diff --git a/drivers/gpu/drm/nouveau/core/engine/graph/ctxnvc1.c b/drivers/gpu/drm/nouveau/core/engine/graph/ctxnvc1.c
3390 +index e5be3ee7f172..71b4283f7fad 100644
3391 +--- a/drivers/gpu/drm/nouveau/core/engine/graph/ctxnvc1.c
3392 ++++ b/drivers/gpu/drm/nouveau/core/engine/graph/ctxnvc1.c
3393 +@@ -587,6 +587,7 @@ nvc1_grctx_init_unk58xx[] = {
3394 + { 0x405870, 4, 0x04, 0x00000001 },
3395 + { 0x405a00, 2, 0x04, 0x00000000 },
3396 + { 0x405a18, 1, 0x04, 0x00000000 },
3397 ++ {}
3398 + };
3399 +
3400 + static struct nvc0_graph_init
3401 +@@ -598,6 +599,7 @@ nvc1_grctx_init_rop[] = {
3402 + { 0x408904, 1, 0x04, 0x62000001 },
3403 + { 0x408908, 1, 0x04, 0x00c80929 },
3404 + { 0x408980, 1, 0x04, 0x0000011d },
3405 ++ {}
3406 + };
3407 +
3408 + static struct nvc0_graph_init
3409 +@@ -671,6 +673,7 @@ nvc1_grctx_init_gpc_0[] = {
3410 + { 0x419000, 1, 0x04, 0x00000780 },
3411 + { 0x419004, 2, 0x04, 0x00000000 },
3412 + { 0x419014, 1, 0x04, 0x00000004 },
3413 ++ {}
3414 + };
3415 +
3416 + static struct nvc0_graph_init
3417 +@@ -717,6 +720,7 @@ nvc1_grctx_init_tpc[] = {
3418 + { 0x419e98, 1, 0x04, 0x00000000 },
3419 + { 0x419ee0, 1, 0x04, 0x00011110 },
3420 + { 0x419f30, 11, 0x04, 0x00000000 },
3421 ++ {}
3422 + };
3423 +
3424 + void
3425 +diff --git a/drivers/gpu/drm/nouveau/core/engine/graph/ctxnvd7.c b/drivers/gpu/drm/nouveau/core/engine/graph/ctxnvd7.c
3426 +index 438e78410808..c4740d528532 100644
3427 +--- a/drivers/gpu/drm/nouveau/core/engine/graph/ctxnvd7.c
3428 ++++ b/drivers/gpu/drm/nouveau/core/engine/graph/ctxnvd7.c
3429 +@@ -258,6 +258,7 @@ nvd7_grctx_init_hub[] = {
3430 + nvc0_grctx_init_unk78xx,
3431 + nvc0_grctx_init_unk80xx,
3432 + nvd9_grctx_init_rop,
3433 ++ NULL
3434 + };
3435 +
3436 + struct nvc0_graph_init *
3437 +diff --git a/drivers/gpu/drm/nouveau/core/engine/graph/ctxnvd9.c b/drivers/gpu/drm/nouveau/core/engine/graph/ctxnvd9.c
3438 +index 818a4751df46..a1102cbf2fdc 100644
3439 +--- a/drivers/gpu/drm/nouveau/core/engine/graph/ctxnvd9.c
3440 ++++ b/drivers/gpu/drm/nouveau/core/engine/graph/ctxnvd9.c
3441 +@@ -466,6 +466,7 @@ nvd9_grctx_init_hub[] = {
3442 + nvc0_grctx_init_unk78xx,
3443 + nvc0_grctx_init_unk80xx,
3444 + nvd9_grctx_init_rop,
3445 ++ NULL
3446 + };
3447 +
3448 + struct nvc0_graph_init *
3449 +diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
3450 +index 461f47b6691e..6f1b5e6b44a0 100644
3451 +--- a/drivers/hv/channel_mgmt.c
3452 ++++ b/drivers/hv/channel_mgmt.c
3453 +@@ -172,7 +172,8 @@ static void vmbus_process_rescind_offer(struct work_struct *work)
3454 + struct vmbus_channel *primary_channel;
3455 + struct vmbus_channel_relid_released msg;
3456 +
3457 +- vmbus_device_unregister(channel->device_obj);
3458 ++ if (channel->device_obj)
3459 ++ vmbus_device_unregister(channel->device_obj);
3460 + memset(&msg, 0, sizeof(struct vmbus_channel_relid_released));
3461 + msg.child_relid = channel->offermsg.child_relid;
3462 + msg.header.msgtype = CHANNELMSG_RELID_RELEASED;
3463 +@@ -185,7 +186,7 @@ static void vmbus_process_rescind_offer(struct work_struct *work)
3464 + } else {
3465 + primary_channel = channel->primary_channel;
3466 + spin_lock_irqsave(&primary_channel->sc_lock, flags);
3467 +- list_del(&channel->listentry);
3468 ++ list_del(&channel->sc_list);
3469 + spin_unlock_irqrestore(&primary_channel->sc_lock, flags);
3470 + }
3471 + free_channel(channel);
3472 +diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c
3473 +index fa6964d8681a..f116d664b473 100644
3474 +--- a/drivers/idle/intel_idle.c
3475 ++++ b/drivers/idle/intel_idle.c
3476 +@@ -359,7 +359,7 @@ static int intel_idle(struct cpuidle_device *dev,
3477 + if (!(lapic_timer_reliable_states & (1 << (cstate))))
3478 + clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_ENTER, &cpu);
3479 +
3480 +- if (!need_resched()) {
3481 ++ if (!current_set_polling_and_test()) {
3482 +
3483 + __monitor((void *)&current_thread_info()->flags, 0, 0);
3484 + smp_mb();
3485 +diff --git a/drivers/net/can/c_can/c_can.c b/drivers/net/can/c_can/c_can.c
3486 +index a668cd491cb3..e3fc07cf2f62 100644
3487 +--- a/drivers/net/can/c_can/c_can.c
3488 ++++ b/drivers/net/can/c_can/c_can.c
3489 +@@ -814,9 +814,6 @@ static int c_can_do_rx_poll(struct net_device *dev, int quota)
3490 + msg_ctrl_save = priv->read_reg(priv,
3491 + C_CAN_IFACE(MSGCTRL_REG, 0));
3492 +
3493 +- if (msg_ctrl_save & IF_MCONT_EOB)
3494 +- return num_rx_pkts;
3495 +-
3496 + if (msg_ctrl_save & IF_MCONT_MSGLST) {
3497 + c_can_handle_lost_msg_obj(dev, 0, msg_obj);
3498 + num_rx_pkts++;
3499 +@@ -824,6 +821,9 @@ static int c_can_do_rx_poll(struct net_device *dev, int quota)
3500 + continue;
3501 + }
3502 +
3503 ++ if (msg_ctrl_save & IF_MCONT_EOB)
3504 ++ return num_rx_pkts;
3505 ++
3506 + if (!(msg_ctrl_save & IF_MCONT_NEWDAT))
3507 + continue;
3508 +
3509 +diff --git a/drivers/net/can/usb/kvaser_usb.c b/drivers/net/can/usb/kvaser_usb.c
3510 +index 3b9546588240..4b2d5ed62b11 100644
3511 +--- a/drivers/net/can/usb/kvaser_usb.c
3512 ++++ b/drivers/net/can/usb/kvaser_usb.c
3513 +@@ -1544,9 +1544,9 @@ static int kvaser_usb_init_one(struct usb_interface *intf,
3514 + return 0;
3515 + }
3516 +
3517 +-static void kvaser_usb_get_endpoints(const struct usb_interface *intf,
3518 +- struct usb_endpoint_descriptor **in,
3519 +- struct usb_endpoint_descriptor **out)
3520 ++static int kvaser_usb_get_endpoints(const struct usb_interface *intf,
3521 ++ struct usb_endpoint_descriptor **in,
3522 ++ struct usb_endpoint_descriptor **out)
3523 + {
3524 + const struct usb_host_interface *iface_desc;
3525 + struct usb_endpoint_descriptor *endpoint;
3526 +@@ -1557,12 +1557,18 @@ static void kvaser_usb_get_endpoints(const struct usb_interface *intf,
3527 + for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {
3528 + endpoint = &iface_desc->endpoint[i].desc;
3529 +
3530 +- if (usb_endpoint_is_bulk_in(endpoint))
3531 ++ if (!*in && usb_endpoint_is_bulk_in(endpoint))
3532 + *in = endpoint;
3533 +
3534 +- if (usb_endpoint_is_bulk_out(endpoint))
3535 ++ if (!*out && usb_endpoint_is_bulk_out(endpoint))
3536 + *out = endpoint;
3537 ++
3538 ++ /* use first bulk endpoint for in and out */
3539 ++ if (*in && *out)
3540 ++ return 0;
3541 + }
3542 ++
3543 ++ return -ENODEV;
3544 + }
3545 +
3546 + static int kvaser_usb_probe(struct usb_interface *intf,
3547 +@@ -1576,8 +1582,8 @@ static int kvaser_usb_probe(struct usb_interface *intf,
3548 + if (!dev)
3549 + return -ENOMEM;
3550 +
3551 +- kvaser_usb_get_endpoints(intf, &dev->bulk_in, &dev->bulk_out);
3552 +- if (!dev->bulk_in || !dev->bulk_out) {
3553 ++ err = kvaser_usb_get_endpoints(intf, &dev->bulk_in, &dev->bulk_out);
3554 ++ if (err) {
3555 + dev_err(&intf->dev, "Cannot get usb endpoint(s)");
3556 + return err;
3557 + }
3558 +diff --git a/drivers/net/ethernet/atheros/alx/main.c b/drivers/net/ethernet/atheros/alx/main.c
3559 +index 027398ebbba6..934057d81f52 100644
3560 +--- a/drivers/net/ethernet/atheros/alx/main.c
3561 ++++ b/drivers/net/ethernet/atheros/alx/main.c
3562 +@@ -1394,6 +1394,9 @@ static int alx_resume(struct device *dev)
3563 + {
3564 + struct pci_dev *pdev = to_pci_dev(dev);
3565 + struct alx_priv *alx = pci_get_drvdata(pdev);
3566 ++ struct alx_hw *hw = &alx->hw;
3567 ++
3568 ++ alx_reset_phy(hw);
3569 +
3570 + if (!netif_running(alx->dev))
3571 + return 0;
3572 +diff --git a/drivers/net/wireless/libertas/debugfs.c b/drivers/net/wireless/libertas/debugfs.c
3573 +index 668dd27616a0..cc6a0a586f0b 100644
3574 +--- a/drivers/net/wireless/libertas/debugfs.c
3575 ++++ b/drivers/net/wireless/libertas/debugfs.c
3576 +@@ -913,7 +913,10 @@ static ssize_t lbs_debugfs_write(struct file *f, const char __user *buf,
3577 + char *p2;
3578 + struct debug_data *d = f->private_data;
3579 +
3580 +- pdata = kmalloc(cnt, GFP_KERNEL);
3581 ++ if (cnt == 0)
3582 ++ return 0;
3583 ++
3584 ++ pdata = kmalloc(cnt + 1, GFP_KERNEL);
3585 + if (pdata == NULL)
3586 + return 0;
3587 +
3588 +@@ -922,6 +925,7 @@ static ssize_t lbs_debugfs_write(struct file *f, const char __user *buf,
3589 + kfree(pdata);
3590 + return 0;
3591 + }
3592 ++ pdata[cnt] = '\0';
3593 +
3594 + p0 = pdata;
3595 + for (i = 0; i < num_of_items; i++) {
3596 +diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
3597 +index 39d8863c7337..b389cba532e2 100644
3598 +--- a/drivers/net/wireless/rt2x00/rt2800lib.c
3599 ++++ b/drivers/net/wireless/rt2x00/rt2800lib.c
3600 +@@ -3423,10 +3423,13 @@ void rt2800_link_tuner(struct rt2x00_dev *rt2x00dev, struct link_qual *qual,
3601 +
3602 + vgc = rt2800_get_default_vgc(rt2x00dev);
3603 +
3604 +- if (rt2x00_rt(rt2x00dev, RT5592) && qual->rssi > -65)
3605 +- vgc += 0x20;
3606 +- else if (qual->rssi > -80)
3607 +- vgc += 0x10;
3608 ++ if (rt2x00_rt(rt2x00dev, RT5592)) {
3609 ++ if (qual->rssi > -65)
3610 ++ vgc += 0x20;
3611 ++ } else {
3612 ++ if (qual->rssi > -80)
3613 ++ vgc += 0x10;
3614 ++ }
3615 +
3616 + rt2800_set_vgc(rt2x00dev, qual, vgc);
3617 + }
3618 +diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c b/drivers/net/wireless/rt2x00/rt2x00dev.c
3619 +index b16521e6bf4a..e418d32882e8 100644
3620 +--- a/drivers/net/wireless/rt2x00/rt2x00dev.c
3621 ++++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
3622 +@@ -181,6 +181,7 @@ static void rt2x00lib_autowakeup(struct work_struct *work)
3623 + static void rt2x00lib_bc_buffer_iter(void *data, u8 *mac,
3624 + struct ieee80211_vif *vif)
3625 + {
3626 ++ struct ieee80211_tx_control control = {};
3627 + struct rt2x00_dev *rt2x00dev = data;
3628 + struct sk_buff *skb;
3629 +
3630 +@@ -195,7 +196,7 @@ static void rt2x00lib_bc_buffer_iter(void *data, u8 *mac,
3631 + */
3632 + skb = ieee80211_get_buffered_bc(rt2x00dev->hw, vif);
3633 + while (skb) {
3634 +- rt2x00mac_tx(rt2x00dev->hw, NULL, skb);
3635 ++ rt2x00mac_tx(rt2x00dev->hw, &control, skb);
3636 + skb = ieee80211_get_buffered_bc(rt2x00dev->hw, vif);
3637 + }
3638 + }
3639 +diff --git a/drivers/net/wireless/rt2x00/rt2x00lib.h b/drivers/net/wireless/rt2x00/rt2x00lib.h
3640 +index a0935987fa3a..7f40ab8e1bd8 100644
3641 +--- a/drivers/net/wireless/rt2x00/rt2x00lib.h
3642 ++++ b/drivers/net/wireless/rt2x00/rt2x00lib.h
3643 +@@ -146,7 +146,7 @@ void rt2x00queue_remove_l2pad(struct sk_buff *skb, unsigned int header_length);
3644 + * @local: frame is not from mac80211
3645 + */
3646 + int rt2x00queue_write_tx_frame(struct data_queue *queue, struct sk_buff *skb,
3647 +- bool local);
3648 ++ struct ieee80211_sta *sta, bool local);
3649 +
3650 + /**
3651 + * rt2x00queue_update_beacon - Send new beacon from mac80211
3652 +diff --git a/drivers/net/wireless/rt2x00/rt2x00mac.c b/drivers/net/wireless/rt2x00/rt2x00mac.c
3653 +index f883802f3505..f8cff1f0b6b7 100644
3654 +--- a/drivers/net/wireless/rt2x00/rt2x00mac.c
3655 ++++ b/drivers/net/wireless/rt2x00/rt2x00mac.c
3656 +@@ -90,7 +90,7 @@ static int rt2x00mac_tx_rts_cts(struct rt2x00_dev *rt2x00dev,
3657 + frag_skb->data, data_length, tx_info,
3658 + (struct ieee80211_rts *)(skb->data));
3659 +
3660 +- retval = rt2x00queue_write_tx_frame(queue, skb, true);
3661 ++ retval = rt2x00queue_write_tx_frame(queue, skb, NULL, true);
3662 + if (retval) {
3663 + dev_kfree_skb_any(skb);
3664 + rt2x00_warn(rt2x00dev, "Failed to send RTS/CTS frame\n");
3665 +@@ -151,7 +151,7 @@ void rt2x00mac_tx(struct ieee80211_hw *hw,
3666 + goto exit_fail;
3667 + }
3668 +
3669 +- if (unlikely(rt2x00queue_write_tx_frame(queue, skb, false)))
3670 ++ if (unlikely(rt2x00queue_write_tx_frame(queue, skb, control->sta, false)))
3671 + goto exit_fail;
3672 +
3673 + /*
3674 +@@ -754,6 +754,9 @@ void rt2x00mac_flush(struct ieee80211_hw *hw, u32 queues, bool drop)
3675 + struct rt2x00_dev *rt2x00dev = hw->priv;
3676 + struct data_queue *queue;
3677 +
3678 ++ if (!test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags))
3679 ++ return;
3680 ++
3681 + tx_queue_for_each(rt2x00dev, queue)
3682 + rt2x00queue_flush_queue(queue, drop);
3683 + }
3684 +diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
3685 +index aa95c6cf3545..f541c92e4290 100644
3686 +--- a/drivers/net/wireless/rt2x00/rt2x00queue.c
3687 ++++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
3688 +@@ -635,7 +635,7 @@ static void rt2x00queue_bar_check(struct queue_entry *entry)
3689 + }
3690 +
3691 + int rt2x00queue_write_tx_frame(struct data_queue *queue, struct sk_buff *skb,
3692 +- bool local)
3693 ++ struct ieee80211_sta *sta, bool local)
3694 + {
3695 + struct ieee80211_tx_info *tx_info;
3696 + struct queue_entry *entry;
3697 +@@ -649,7 +649,7 @@ int rt2x00queue_write_tx_frame(struct data_queue *queue, struct sk_buff *skb,
3698 + * after that we are free to use the skb->cb array
3699 + * for our information.
3700 + */
3701 +- rt2x00queue_create_tx_descriptor(queue->rt2x00dev, skb, &txdesc, NULL);
3702 ++ rt2x00queue_create_tx_descriptor(queue->rt2x00dev, skb, &txdesc, sta);
3703 +
3704 + /*
3705 + * All information is retrieved from the skb->cb array,
3706 +diff --git a/drivers/pci/access.c b/drivers/pci/access.c
3707 +index 1cc23661f79b..061da8c3ab4b 100644
3708 +--- a/drivers/pci/access.c
3709 ++++ b/drivers/pci/access.c
3710 +@@ -484,28 +484,29 @@ static inline bool pcie_cap_has_lnkctl(const struct pci_dev *dev)
3711 + {
3712 + int type = pci_pcie_type(dev);
3713 +
3714 +- return pcie_cap_version(dev) > 1 ||
3715 ++ return type == PCI_EXP_TYPE_ENDPOINT ||
3716 ++ type == PCI_EXP_TYPE_LEG_END ||
3717 + type == PCI_EXP_TYPE_ROOT_PORT ||
3718 +- type == PCI_EXP_TYPE_ENDPOINT ||
3719 +- type == PCI_EXP_TYPE_LEG_END;
3720 ++ type == PCI_EXP_TYPE_UPSTREAM ||
3721 ++ type == PCI_EXP_TYPE_DOWNSTREAM ||
3722 ++ type == PCI_EXP_TYPE_PCI_BRIDGE ||
3723 ++ type == PCI_EXP_TYPE_PCIE_BRIDGE;
3724 + }
3725 +
3726 + static inline bool pcie_cap_has_sltctl(const struct pci_dev *dev)
3727 + {
3728 + int type = pci_pcie_type(dev);
3729 +
3730 +- return pcie_cap_version(dev) > 1 ||
3731 +- type == PCI_EXP_TYPE_ROOT_PORT ||
3732 +- (type == PCI_EXP_TYPE_DOWNSTREAM &&
3733 +- pcie_caps_reg(dev) & PCI_EXP_FLAGS_SLOT);
3734 ++ return (type == PCI_EXP_TYPE_ROOT_PORT ||
3735 ++ type == PCI_EXP_TYPE_DOWNSTREAM) &&
3736 ++ pcie_caps_reg(dev) & PCI_EXP_FLAGS_SLOT;
3737 + }
3738 +
3739 + static inline bool pcie_cap_has_rtctl(const struct pci_dev *dev)
3740 + {
3741 + int type = pci_pcie_type(dev);
3742 +
3743 +- return pcie_cap_version(dev) > 1 ||
3744 +- type == PCI_EXP_TYPE_ROOT_PORT ||
3745 ++ return type == PCI_EXP_TYPE_ROOT_PORT ||
3746 + type == PCI_EXP_TYPE_RC_EC;
3747 + }
3748 +
3749 +diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
3750 +index 54d31c0a9840..99eeaf40d641 100644
3751 +--- a/drivers/platform/x86/thinkpad_acpi.c
3752 ++++ b/drivers/platform/x86/thinkpad_acpi.c
3753 +@@ -6438,7 +6438,12 @@ static struct ibm_struct brightness_driver_data = {
3754 + #define TPACPI_ALSA_SHRTNAME "ThinkPad Console Audio Control"
3755 + #define TPACPI_ALSA_MIXERNAME TPACPI_ALSA_SHRTNAME
3756 +
3757 +-static int alsa_index = ~((1 << (SNDRV_CARDS - 3)) - 1); /* last three slots */
3758 ++#if SNDRV_CARDS <= 32
3759 ++#define DEFAULT_ALSA_IDX ~((1 << (SNDRV_CARDS - 3)) - 1)
3760 ++#else
3761 ++#define DEFAULT_ALSA_IDX ~((1 << (32 - 3)) - 1)
3762 ++#endif
3763 ++static int alsa_index = DEFAULT_ALSA_IDX; /* last three slots */
3764 + static char *alsa_id = "ThinkPadEC";
3765 + static bool alsa_enable = SNDRV_DEFAULT_ENABLE1;
3766 +
3767 +diff --git a/drivers/scsi/aacraid/commctrl.c b/drivers/scsi/aacraid/commctrl.c
3768 +index d85ac1a9d2c0..fbcd48d0bfc3 100644
3769 +--- a/drivers/scsi/aacraid/commctrl.c
3770 ++++ b/drivers/scsi/aacraid/commctrl.c
3771 +@@ -511,7 +511,8 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
3772 + goto cleanup;
3773 + }
3774 +
3775 +- if (fibsize > (dev->max_fib_size - sizeof(struct aac_fibhdr))) {
3776 ++ if ((fibsize < (sizeof(struct user_aac_srb) - sizeof(struct user_sgentry))) ||
3777 ++ (fibsize > (dev->max_fib_size - sizeof(struct aac_fibhdr)))) {
3778 + rcode = -EINVAL;
3779 + goto cleanup;
3780 + }
3781 +diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c
3782 +index f4a197b2d1fd..ea85f71eabfb 100644
3783 +--- a/drivers/staging/comedi/comedi_fops.c
3784 ++++ b/drivers/staging/comedi/comedi_fops.c
3785 +@@ -543,7 +543,7 @@ void *comedi_alloc_spriv(struct comedi_subdevice *s, size_t size)
3786 + {
3787 + s->private = kzalloc(size, GFP_KERNEL);
3788 + if (s->private)
3789 +- comedi_set_subdevice_runflags(s, ~0, SRF_FREE_SPRIV);
3790 ++ s->runflags |= SRF_FREE_SPRIV;
3791 + return s->private;
3792 + }
3793 + EXPORT_SYMBOL_GPL(comedi_alloc_spriv);
3794 +@@ -1485,7 +1485,8 @@ static int do_cmd_ioctl(struct comedi_device *dev,
3795 + if (async->cmd.flags & TRIG_WAKE_EOS)
3796 + async->cb_mask |= COMEDI_CB_EOS;
3797 +
3798 +- comedi_set_subdevice_runflags(s, ~0, SRF_USER | SRF_RUNNING);
3799 ++ comedi_set_subdevice_runflags(s, SRF_USER | SRF_ERROR | SRF_RUNNING,
3800 ++ SRF_USER | SRF_RUNNING);
3801 +
3802 + /* set s->busy _after_ setting SRF_RUNNING flag to avoid race with
3803 + * comedi_read() or comedi_write() */
3804 +diff --git a/drivers/staging/zram/zram_drv.c b/drivers/staging/zram/zram_drv.c
3805 +index 8f54c503ea04..ee6b4356f222 100644
3806 +--- a/drivers/staging/zram/zram_drv.c
3807 ++++ b/drivers/staging/zram/zram_drv.c
3808 +@@ -647,6 +647,9 @@ static ssize_t reset_store(struct device *dev,
3809 + zram = dev_to_zram(dev);
3810 + bdev = bdget_disk(zram->disk, 0);
3811 +
3812 ++ if (!bdev)
3813 ++ return -ENOMEM;
3814 ++
3815 + /* Do not reset an active device! */
3816 + if (bdev->bd_holders)
3817 + return -EBUSY;
3818 +@@ -659,8 +662,7 @@ static ssize_t reset_store(struct device *dev,
3819 + return -EINVAL;
3820 +
3821 + /* Make sure all pending I/O is finished */
3822 +- if (bdev)
3823 +- fsync_bdev(bdev);
3824 ++ fsync_bdev(bdev);
3825 +
3826 + zram_reset_device(zram, true);
3827 + return len;
3828 +diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
3829 +index 3bac4693c038..23dc9d1dc99e 100644
3830 +--- a/drivers/usb/serial/mos7840.c
3831 ++++ b/drivers/usb/serial/mos7840.c
3832 +@@ -1580,7 +1580,11 @@ static int mos7840_tiocmget(struct tty_struct *tty)
3833 + return -ENODEV;
3834 +
3835 + status = mos7840_get_uart_reg(port, MODEM_STATUS_REGISTER, &msr);
3836 ++ if (status != 1)
3837 ++ return -EIO;
3838 + status = mos7840_get_uart_reg(port, MODEM_CONTROL_REGISTER, &mcr);
3839 ++ if (status != 1)
3840 ++ return -EIO;
3841 + result = ((mcr & MCR_DTR) ? TIOCM_DTR : 0)
3842 + | ((mcr & MCR_RTS) ? TIOCM_RTS : 0)
3843 + | ((mcr & MCR_LOOPBACK) ? TIOCM_LOOP : 0)
3844 +diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
3845 +index 4576c03a0912..3702d4503ea1 100644
3846 +--- a/fs/btrfs/relocation.c
3847 ++++ b/fs/btrfs/relocation.c
3848 +@@ -4462,6 +4462,7 @@ int btrfs_reloc_clone_csums(struct inode *inode, u64 file_pos, u64 len)
3849 + struct btrfs_root *root = BTRFS_I(inode)->root;
3850 + int ret;
3851 + u64 disk_bytenr;
3852 ++ u64 new_bytenr;
3853 + LIST_HEAD(list);
3854 +
3855 + ordered = btrfs_lookup_ordered_extent(inode, file_pos);
3856 +@@ -4473,13 +4474,24 @@ int btrfs_reloc_clone_csums(struct inode *inode, u64 file_pos, u64 len)
3857 + if (ret)
3858 + goto out;
3859 +
3860 +- disk_bytenr = ordered->start;
3861 + while (!list_empty(&list)) {
3862 + sums = list_entry(list.next, struct btrfs_ordered_sum, list);
3863 + list_del_init(&sums->list);
3864 +
3865 +- sums->bytenr = disk_bytenr;
3866 +- disk_bytenr += sums->len;
3867 ++ /*
3868 ++ * We need to offset the new_bytenr based on where the csum is.
3869 ++ * We need to do this because we will read in entire prealloc
3870 ++ * extents but we may have written to say the middle of the
3871 ++ * prealloc extent, so we need to make sure the csum goes with
3872 ++ * the right disk offset.
3873 ++ *
3874 ++ * We can do this because the data reloc inode refers strictly
3875 ++ * to the on disk bytes, so we don't have to worry about
3876 ++ * disk_len vs real len like with real inodes since it's all
3877 ++ * disk length.
3878 ++ */
3879 ++ new_bytenr = ordered->start + (sums->bytenr - disk_bytenr);
3880 ++ sums->bytenr = new_bytenr;
3881 +
3882 + btrfs_add_ordered_sum(inode, ordered, sums);
3883 + }
3884 +diff --git a/fs/exec.c b/fs/exec.c
3885 +index fd774c7cb483..e72f6bbbde2e 100644
3886 +--- a/fs/exec.c
3887 ++++ b/fs/exec.c
3888 +@@ -1670,6 +1670,12 @@ int __get_dumpable(unsigned long mm_flags)
3889 + return (ret > SUID_DUMP_USER) ? SUID_DUMP_ROOT : ret;
3890 + }
3891 +
3892 ++/*
3893 ++ * This returns the actual value of the suid_dumpable flag. For things
3894 ++ * that are using this for checking for privilege transitions, it must
3895 ++ * test against SUID_DUMP_USER rather than treating it as a boolean
3896 ++ * value.
3897 ++ */
3898 + int get_dumpable(struct mm_struct *mm)
3899 + {
3900 + return __get_dumpable(mm->flags);
3901 +diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
3902 +index 70cf138690e9..df97ca4aae52 100644
3903 +--- a/include/linux/binfmts.h
3904 ++++ b/include/linux/binfmts.h
3905 +@@ -99,9 +99,6 @@ extern void setup_new_exec(struct linux_binprm * bprm);
3906 + extern void would_dump(struct linux_binprm *, struct file *);
3907 +
3908 + extern int suid_dumpable;
3909 +-#define SUID_DUMP_DISABLE 0 /* No setuid dumping */
3910 +-#define SUID_DUMP_USER 1 /* Dump as user of process */
3911 +-#define SUID_DUMP_ROOT 2 /* Dump as root */
3912 +
3913 + /* Stack area protections */
3914 + #define EXSTACK_DEFAULT 0 /* Whatever the arch defaults to */
3915 +diff --git a/include/linux/sched.h b/include/linux/sched.h
3916 +index 078066daffd4..e057ea09c851 100644
3917 +--- a/include/linux/sched.h
3918 ++++ b/include/linux/sched.h
3919 +@@ -330,6 +330,10 @@ static inline void arch_pick_mmap_layout(struct mm_struct *mm) {}
3920 + extern void set_dumpable(struct mm_struct *mm, int value);
3921 + extern int get_dumpable(struct mm_struct *mm);
3922 +
3923 ++#define SUID_DUMP_DISABLE 0 /* No setuid dumping */
3924 ++#define SUID_DUMP_USER 1 /* Dump as user of process */
3925 ++#define SUID_DUMP_ROOT 2 /* Dump as root */
3926 ++
3927 + /* mm flags */
3928 + /* dumpable bits */
3929 + #define MMF_DUMPABLE 0 /* core dump is permitted */
3930 +@@ -2473,34 +2477,98 @@ static inline int tsk_is_polling(struct task_struct *p)
3931 + {
3932 + return task_thread_info(p)->status & TS_POLLING;
3933 + }
3934 +-static inline void current_set_polling(void)
3935 ++static inline void __current_set_polling(void)
3936 + {
3937 + current_thread_info()->status |= TS_POLLING;
3938 + }
3939 +
3940 +-static inline void current_clr_polling(void)
3941 ++static inline bool __must_check current_set_polling_and_test(void)
3942 ++{
3943 ++ __current_set_polling();
3944 ++
3945 ++ /*
3946 ++ * Polling state must be visible before we test NEED_RESCHED,
3947 ++ * paired by resched_task()
3948 ++ */
3949 ++ smp_mb();
3950 ++
3951 ++ return unlikely(tif_need_resched());
3952 ++}
3953 ++
3954 ++static inline void __current_clr_polling(void)
3955 + {
3956 + current_thread_info()->status &= ~TS_POLLING;
3957 +- smp_mb__after_clear_bit();
3958 ++}
3959 ++
3960 ++static inline bool __must_check current_clr_polling_and_test(void)
3961 ++{
3962 ++ __current_clr_polling();
3963 ++
3964 ++ /*
3965 ++ * Polling state must be visible before we test NEED_RESCHED,
3966 ++ * paired by resched_task()
3967 ++ */
3968 ++ smp_mb();
3969 ++
3970 ++ return unlikely(tif_need_resched());
3971 + }
3972 + #elif defined(TIF_POLLING_NRFLAG)
3973 + static inline int tsk_is_polling(struct task_struct *p)
3974 + {
3975 + return test_tsk_thread_flag(p, TIF_POLLING_NRFLAG);
3976 + }
3977 +-static inline void current_set_polling(void)
3978 ++
3979 ++static inline void __current_set_polling(void)
3980 + {
3981 + set_thread_flag(TIF_POLLING_NRFLAG);
3982 + }
3983 +
3984 +-static inline void current_clr_polling(void)
3985 ++static inline bool __must_check current_set_polling_and_test(void)
3986 ++{
3987 ++ __current_set_polling();
3988 ++
3989 ++ /*
3990 ++ * Polling state must be visible before we test NEED_RESCHED,
3991 ++ * paired by resched_task()
3992 ++ *
3993 ++ * XXX: assumes set/clear bit are identical barrier wise.
3994 ++ */
3995 ++ smp_mb__after_clear_bit();
3996 ++
3997 ++ return unlikely(tif_need_resched());
3998 ++}
3999 ++
4000 ++static inline void __current_clr_polling(void)
4001 + {
4002 + clear_thread_flag(TIF_POLLING_NRFLAG);
4003 + }
4004 ++
4005 ++static inline bool __must_check current_clr_polling_and_test(void)
4006 ++{
4007 ++ __current_clr_polling();
4008 ++
4009 ++ /*
4010 ++ * Polling state must be visible before we test NEED_RESCHED,
4011 ++ * paired by resched_task()
4012 ++ */
4013 ++ smp_mb__after_clear_bit();
4014 ++
4015 ++ return unlikely(tif_need_resched());
4016 ++}
4017 ++
4018 + #else
4019 + static inline int tsk_is_polling(struct task_struct *p) { return 0; }
4020 +-static inline void current_set_polling(void) { }
4021 +-static inline void current_clr_polling(void) { }
4022 ++static inline void __current_set_polling(void) { }
4023 ++static inline void __current_clr_polling(void) { }
4024 ++
4025 ++static inline bool __must_check current_set_polling_and_test(void)
4026 ++{
4027 ++ return unlikely(tif_need_resched());
4028 ++}
4029 ++static inline bool __must_check current_clr_polling_and_test(void)
4030 ++{
4031 ++ return unlikely(tif_need_resched());
4032 ++}
4033 + #endif
4034 +
4035 + /*
4036 +diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
4037 +index e7e04736802f..4ae6f32c8033 100644
4038 +--- a/include/linux/thread_info.h
4039 ++++ b/include/linux/thread_info.h
4040 +@@ -107,6 +107,8 @@ static inline int test_ti_thread_flag(struct thread_info *ti, int flag)
4041 + #define set_need_resched() set_thread_flag(TIF_NEED_RESCHED)
4042 + #define clear_need_resched() clear_thread_flag(TIF_NEED_RESCHED)
4043 +
4044 ++#define tif_need_resched() test_thread_flag(TIF_NEED_RESCHED)
4045 ++
4046 + #if defined TIF_RESTORE_SIGMASK && !defined HAVE_SET_RESTORE_SIGMASK
4047 + /*
4048 + * An arch can define its own version of set_restore_sigmask() to get the
4049 +diff --git a/ipc/shm.c b/ipc/shm.c
4050 +index d69739610fd4..7a51443a51d6 100644
4051 +--- a/ipc/shm.c
4052 ++++ b/ipc/shm.c
4053 +@@ -208,15 +208,18 @@ static void shm_open(struct vm_area_struct *vma)
4054 + */
4055 + static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp)
4056 + {
4057 ++ struct file *shm_file;
4058 ++
4059 ++ shm_file = shp->shm_file;
4060 ++ shp->shm_file = NULL;
4061 + ns->shm_tot -= (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
4062 + shm_rmid(ns, shp);
4063 + shm_unlock(shp);
4064 +- if (!is_file_hugepages(shp->shm_file))
4065 +- shmem_lock(shp->shm_file, 0, shp->mlock_user);
4066 ++ if (!is_file_hugepages(shm_file))
4067 ++ shmem_lock(shm_file, 0, shp->mlock_user);
4068 + else if (shp->mlock_user)
4069 +- user_shm_unlock(file_inode(shp->shm_file)->i_size,
4070 +- shp->mlock_user);
4071 +- fput (shp->shm_file);
4072 ++ user_shm_unlock(file_inode(shm_file)->i_size, shp->mlock_user);
4073 ++ fput(shm_file);
4074 + ipc_rcu_putref(shp, shm_rcu_free);
4075 + }
4076 +
4077 +@@ -974,15 +977,25 @@ SYSCALL_DEFINE3(shmctl, int, shmid, int, cmd, struct shmid_ds __user *, buf)
4078 + ipc_lock_object(&shp->shm_perm);
4079 + if (!ns_capable(ns->user_ns, CAP_IPC_LOCK)) {
4080 + kuid_t euid = current_euid();
4081 +- err = -EPERM;
4082 + if (!uid_eq(euid, shp->shm_perm.uid) &&
4083 +- !uid_eq(euid, shp->shm_perm.cuid))
4084 ++ !uid_eq(euid, shp->shm_perm.cuid)) {
4085 ++ err = -EPERM;
4086 + goto out_unlock0;
4087 +- if (cmd == SHM_LOCK && !rlimit(RLIMIT_MEMLOCK))
4088 ++ }
4089 ++ if (cmd == SHM_LOCK && !rlimit(RLIMIT_MEMLOCK)) {
4090 ++ err = -EPERM;
4091 + goto out_unlock0;
4092 ++ }
4093 + }
4094 +
4095 + shm_file = shp->shm_file;
4096 ++
4097 ++ /* check if shm_destroy() is tearing down shp */
4098 ++ if (shm_file == NULL) {
4099 ++ err = -EIDRM;
4100 ++ goto out_unlock0;
4101 ++ }
4102 ++
4103 + if (is_file_hugepages(shm_file))
4104 + goto out_unlock0;
4105 +
4106 +@@ -1101,6 +1114,14 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
4107 + goto out_unlock;
4108 +
4109 + ipc_lock_object(&shp->shm_perm);
4110 ++
4111 ++ /* check if shm_destroy() is tearing down shp */
4112 ++ if (shp->shm_file == NULL) {
4113 ++ ipc_unlock_object(&shp->shm_perm);
4114 ++ err = -EIDRM;
4115 ++ goto out_unlock;
4116 ++ }
4117 ++
4118 + path = shp->shm_file->f_path;
4119 + path_get(&path);
4120 + shp->shm_nattch++;
4121 +diff --git a/kernel/cpu/idle.c b/kernel/cpu/idle.c
4122 +index e695c0a0bcb5..c261409500e4 100644
4123 +--- a/kernel/cpu/idle.c
4124 ++++ b/kernel/cpu/idle.c
4125 +@@ -44,7 +44,7 @@ static inline int cpu_idle_poll(void)
4126 + rcu_idle_enter();
4127 + trace_cpu_idle_rcuidle(0, smp_processor_id());
4128 + local_irq_enable();
4129 +- while (!need_resched())
4130 ++ while (!tif_need_resched())
4131 + cpu_relax();
4132 + trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, smp_processor_id());
4133 + rcu_idle_exit();
4134 +@@ -92,8 +92,7 @@ static void cpu_idle_loop(void)
4135 + if (cpu_idle_force_poll || tick_check_broadcast_expired()) {
4136 + cpu_idle_poll();
4137 + } else {
4138 +- current_clr_polling();
4139 +- if (!need_resched()) {
4140 ++ if (!current_clr_polling_and_test()) {
4141 + stop_critical_timings();
4142 + rcu_idle_enter();
4143 + arch_cpu_idle();
4144 +@@ -103,7 +102,7 @@ static void cpu_idle_loop(void)
4145 + } else {
4146 + local_irq_enable();
4147 + }
4148 +- current_set_polling();
4149 ++ __current_set_polling();
4150 + }
4151 + arch_cpu_idle_exit();
4152 + }
4153 +@@ -129,7 +128,7 @@ void cpu_startup_entry(enum cpuhp_state state)
4154 + */
4155 + boot_init_stack_canary();
4156 + #endif
4157 +- current_set_polling();
4158 ++ __current_set_polling();
4159 + arch_cpu_idle_prepare();
4160 + cpu_idle_loop();
4161 + }
4162 +diff --git a/kernel/ptrace.c b/kernel/ptrace.c
4163 +index a146ee327f6a..cf021a03019c 100644
4164 +--- a/kernel/ptrace.c
4165 ++++ b/kernel/ptrace.c
4166 +@@ -257,7 +257,8 @@ ok:
4167 + if (task->mm)
4168 + dumpable = get_dumpable(task->mm);
4169 + rcu_read_lock();
4170 +- if (!dumpable && !ptrace_has_cap(__task_cred(task)->user_ns, mode)) {
4171 ++ if (dumpable != SUID_DUMP_USER &&
4172 ++ !ptrace_has_cap(__task_cred(task)->user_ns, mode)) {
4173 + rcu_read_unlock();
4174 + return -EPERM;
4175 + }
4176 +diff --git a/kernel/trace/trace_event_perf.c b/kernel/trace/trace_event_perf.c
4177 +index 80c36bcf66e8..78e27e3b52ac 100644
4178 +--- a/kernel/trace/trace_event_perf.c
4179 ++++ b/kernel/trace/trace_event_perf.c
4180 +@@ -26,7 +26,7 @@ static int perf_trace_event_perm(struct ftrace_event_call *tp_event,
4181 + {
4182 + /* The ftrace function trace is allowed only for root. */
4183 + if (ftrace_event_is_function(tp_event) &&
4184 +- perf_paranoid_kernel() && !capable(CAP_SYS_ADMIN))
4185 ++ perf_paranoid_tracepoint_raw() && !capable(CAP_SYS_ADMIN))
4186 + return -EPERM;
4187 +
4188 + /* No tracing, just counting, so no obvious leak */
4189 +diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
4190 +index ecbc4e3d83ad..b5449656a383 100644
4191 +--- a/net/sunrpc/clnt.c
4192 ++++ b/net/sunrpc/clnt.c
4193 +@@ -1423,9 +1423,9 @@ call_refreshresult(struct rpc_task *task)
4194 + return;
4195 + case -ETIMEDOUT:
4196 + rpc_delay(task, 3*HZ);
4197 +- case -EKEYEXPIRED:
4198 + case -EAGAIN:
4199 + status = -EACCES;
4200 ++ case -EKEYEXPIRED:
4201 + if (!task->tk_cred_retry)
4202 + break;
4203 + task->tk_cred_retry--;
4204 +diff --git a/security/integrity/ima/ima_policy.c b/security/integrity/ima/ima_policy.c
4205 +index 399433ad614e..a9c3d3cd1990 100644
4206 +--- a/security/integrity/ima/ima_policy.c
4207 ++++ b/security/integrity/ima/ima_policy.c
4208 +@@ -73,7 +73,6 @@ static struct ima_rule_entry default_rules[] = {
4209 + {.action = DONT_MEASURE,.fsmagic = SYSFS_MAGIC,.flags = IMA_FSMAGIC},
4210 + {.action = DONT_MEASURE,.fsmagic = DEBUGFS_MAGIC,.flags = IMA_FSMAGIC},
4211 + {.action = DONT_MEASURE,.fsmagic = TMPFS_MAGIC,.flags = IMA_FSMAGIC},
4212 +- {.action = DONT_MEASURE,.fsmagic = RAMFS_MAGIC,.flags = IMA_FSMAGIC},
4213 + {.action = DONT_MEASURE,.fsmagic = DEVPTS_SUPER_MAGIC,.flags = IMA_FSMAGIC},
4214 + {.action = DONT_MEASURE,.fsmagic = BINFMTFS_MAGIC,.flags = IMA_FSMAGIC},
4215 + {.action = DONT_MEASURE,.fsmagic = SECURITYFS_MAGIC,.flags = IMA_FSMAGIC},
4216
4217 Modified: genpatches-2.6/trunk/3.12/0000_README
4218 ===================================================================
4219 --- genpatches-2.6/trunk/3.12/0000_README 2013-11-26 00:34:31 UTC (rev 2594)
4220 +++ genpatches-2.6/trunk/3.12/0000_README 2013-11-29 23:44:29 UTC (rev 2595)
4221 @@ -46,6 +46,10 @@
4222 From: http://www.kernel.org
4223 Desc: Linux 3.12.1
4224
4225 +Patch: 1001_linux-3.12.2.patch
4226 +From: http://www.kernel.org
4227 +Desc: Linux 3.12.2
4228 +
4229 Patch: 1500_XATTR_USER_PREFIX.patch
4230 From: https://bugs.gentoo.org/show_bug.cgi?id=470644
4231 Desc: Support for namespace user.pax.* on tmpfs.
4232
4233 Added: genpatches-2.6/trunk/3.12/1001_linux-3.12.2.patch
4234 ===================================================================
4235 --- genpatches-2.6/trunk/3.12/1001_linux-3.12.2.patch (rev 0)
4236 +++ genpatches-2.6/trunk/3.12/1001_linux-3.12.2.patch 2013-11-29 23:44:29 UTC (rev 2595)
4237 @@ -0,0 +1,3790 @@
4238 +diff --git a/Makefile b/Makefile
4239 +index eb29ec754a9e..e6e72b629da7 100644
4240 +--- a/Makefile
4241 ++++ b/Makefile
4242 +@@ -1,6 +1,6 @@
4243 + VERSION = 3
4244 + PATCHLEVEL = 12
4245 +-SUBLEVEL = 1
4246 ++SUBLEVEL = 2
4247 + EXTRAVERSION =
4248 + NAME = One Giant Leap for Frogkind
4249 +
4250 +diff --git a/arch/arm/kvm/mmu.c b/arch/arm/kvm/mmu.c
4251 +index b0de86b56c13..cb79a5dd6d96 100644
4252 +--- a/arch/arm/kvm/mmu.c
4253 ++++ b/arch/arm/kvm/mmu.c
4254 +@@ -307,6 +307,17 @@ out:
4255 + return err;
4256 + }
4257 +
4258 ++static phys_addr_t kvm_kaddr_to_phys(void *kaddr)
4259 ++{
4260 ++ if (!is_vmalloc_addr(kaddr)) {
4261 ++ BUG_ON(!virt_addr_valid(kaddr));
4262 ++ return __pa(kaddr);
4263 ++ } else {
4264 ++ return page_to_phys(vmalloc_to_page(kaddr)) +
4265 ++ offset_in_page(kaddr);
4266 ++ }
4267 ++}
4268 ++
4269 + /**
4270 + * create_hyp_mappings - duplicate a kernel virtual address range in Hyp mode
4271 + * @from: The virtual kernel start address of the range
4272 +@@ -318,16 +329,27 @@ out:
4273 + */
4274 + int create_hyp_mappings(void *from, void *to)
4275 + {
4276 +- unsigned long phys_addr = virt_to_phys(from);
4277 ++ phys_addr_t phys_addr;
4278 ++ unsigned long virt_addr;
4279 + unsigned long start = KERN_TO_HYP((unsigned long)from);
4280 + unsigned long end = KERN_TO_HYP((unsigned long)to);
4281 +
4282 +- /* Check for a valid kernel memory mapping */
4283 +- if (!virt_addr_valid(from) || !virt_addr_valid(to - 1))
4284 +- return -EINVAL;
4285 ++ start = start & PAGE_MASK;
4286 ++ end = PAGE_ALIGN(end);
4287 +
4288 +- return __create_hyp_mappings(hyp_pgd, start, end,
4289 +- __phys_to_pfn(phys_addr), PAGE_HYP);
4290 ++ for (virt_addr = start; virt_addr < end; virt_addr += PAGE_SIZE) {
4291 ++ int err;
4292 ++
4293 ++ phys_addr = kvm_kaddr_to_phys(from + virt_addr - start);
4294 ++ err = __create_hyp_mappings(hyp_pgd, virt_addr,
4295 ++ virt_addr + PAGE_SIZE,
4296 ++ __phys_to_pfn(phys_addr),
4297 ++ PAGE_HYP);
4298 ++ if (err)
4299 ++ return err;
4300 ++ }
4301 ++
4302 ++ return 0;
4303 + }
4304 +
4305 + /**
4306 +diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
4307 +index d9ee0ff094d4..3d5db8c83b3c 100644
4308 +--- a/arch/arm/mach-omap2/omap_hwmod.c
4309 ++++ b/arch/arm/mach-omap2/omap_hwmod.c
4310 +@@ -2361,21 +2361,23 @@ static struct device_node *of_dev_hwmod_lookup(struct device_node *np,
4311 + * Cache the virtual address used by the MPU to access this IP block's
4312 + * registers. This address is needed early so the OCP registers that
4313 + * are part of the device's address space can be ioremapped properly.
4314 +- * No return value.
4315 ++ *
4316 ++ * Returns 0 on success, -EINVAL if an invalid hwmod is passed, and
4317 ++ * -ENXIO on absent or invalid register target address space.
4318 + */
4319 +-static void __init _init_mpu_rt_base(struct omap_hwmod *oh, void *data)
4320 ++static int __init _init_mpu_rt_base(struct omap_hwmod *oh, void *data)
4321 + {
4322 + struct omap_hwmod_addr_space *mem;
4323 + void __iomem *va_start = NULL;
4324 + struct device_node *np;
4325 +
4326 + if (!oh)
4327 +- return;
4328 ++ return -EINVAL;
4329 +
4330 + _save_mpu_port_index(oh);
4331 +
4332 + if (oh->_int_flags & _HWMOD_NO_MPU_PORT)
4333 +- return;
4334 ++ return -ENXIO;
4335 +
4336 + mem = _find_mpu_rt_addr_space(oh);
4337 + if (!mem) {
4338 +@@ -2384,7 +2386,7 @@ static void __init _init_mpu_rt_base(struct omap_hwmod *oh, void *data)
4339 +
4340 + /* Extract the IO space from device tree blob */
4341 + if (!of_have_populated_dt())
4342 +- return;
4343 ++ return -ENXIO;
4344 +
4345 + np = of_dev_hwmod_lookup(of_find_node_by_name(NULL, "ocp"), oh);
4346 + if (np)
4347 +@@ -2395,13 +2397,14 @@ static void __init _init_mpu_rt_base(struct omap_hwmod *oh, void *data)
4348 +
4349 + if (!va_start) {
4350 + pr_err("omap_hwmod: %s: Could not ioremap\n", oh->name);
4351 +- return;
4352 ++ return -ENXIO;
4353 + }
4354 +
4355 + pr_debug("omap_hwmod: %s: MPU register target at va %p\n",
4356 + oh->name, va_start);
4357 +
4358 + oh->_mpu_rt_va = va_start;
4359 ++ return 0;
4360 + }
4361 +
4362 + /**
4363 +@@ -2414,8 +2417,8 @@ static void __init _init_mpu_rt_base(struct omap_hwmod *oh, void *data)
4364 + * registered at this point. This is the first of two phases for
4365 + * hwmod initialization. Code called here does not touch any hardware
4366 + * registers, it simply prepares internal data structures. Returns 0
4367 +- * upon success or if the hwmod isn't registered, or -EINVAL upon
4368 +- * failure.
4369 ++ * upon success or if the hwmod isn't registered or if the hwmod's
4370 ++ * address space is not defined, or -EINVAL upon failure.
4371 + */
4372 + static int __init _init(struct omap_hwmod *oh, void *data)
4373 + {
4374 +@@ -2424,8 +2427,14 @@ static int __init _init(struct omap_hwmod *oh, void *data)
4375 + if (oh->_state != _HWMOD_STATE_REGISTERED)
4376 + return 0;
4377 +
4378 +- if (oh->class->sysc)
4379 +- _init_mpu_rt_base(oh, NULL);
4380 ++ if (oh->class->sysc) {
4381 ++ r = _init_mpu_rt_base(oh, NULL);
4382 ++ if (r < 0) {
4383 ++ WARN(1, "omap_hwmod: %s: doesn't have mpu register target base\n",
4384 ++ oh->name);
4385 ++ return 0;
4386 ++ }
4387 ++ }
4388 +
4389 + r = _init_clocks(oh, NULL);
4390 + if (r < 0) {
4391 +diff --git a/arch/cris/include/asm/io.h b/arch/cris/include/asm/io.h
4392 +index 5d3047e5563b..4353cf239a13 100644
4393 +--- a/arch/cris/include/asm/io.h
4394 ++++ b/arch/cris/include/asm/io.h
4395 +@@ -3,6 +3,7 @@
4396 +
4397 + #include <asm/page.h> /* for __va, __pa */
4398 + #include <arch/io.h>
4399 ++#include <asm-generic/iomap.h>
4400 + #include <linux/kernel.h>
4401 +
4402 + struct cris_io_operations
4403 +diff --git a/arch/ia64/include/asm/processor.h b/arch/ia64/include/asm/processor.h
4404 +index e0a899a1a8a6..5a84b3a50741 100644
4405 +--- a/arch/ia64/include/asm/processor.h
4406 ++++ b/arch/ia64/include/asm/processor.h
4407 +@@ -319,7 +319,7 @@ struct thread_struct {
4408 + regs->loadrs = 0; \
4409 + regs->r8 = get_dumpable(current->mm); /* set "don't zap registers" flag */ \
4410 + regs->r12 = new_sp - 16; /* allocate 16 byte scratch area */ \
4411 +- if (unlikely(!get_dumpable(current->mm))) { \
4412 ++ if (unlikely(get_dumpable(current->mm) != SUID_DUMP_USER)) { \
4413 + /* \
4414 + * Zap scratch regs to avoid leaking bits between processes with different \
4415 + * uid/privileges. \
4416 +diff --git a/arch/powerpc/kernel/eeh.c b/arch/powerpc/kernel/eeh.c
4417 +index 55593ee2d5aa..c766cf575520 100644
4418 +--- a/arch/powerpc/kernel/eeh.c
4419 ++++ b/arch/powerpc/kernel/eeh.c
4420 +@@ -687,6 +687,15 @@ void eeh_save_bars(struct eeh_dev *edev)
4421 +
4422 + for (i = 0; i < 16; i++)
4423 + eeh_ops->read_config(dn, i * 4, 4, &edev->config_space[i]);
4424 ++
4425 ++ /*
4426 ++ * For PCI bridges including root port, we need enable bus
4427 ++ * master explicitly. Otherwise, it can't fetch IODA table
4428 ++ * entries correctly. So we cache the bit in advance so that
4429 ++ * we can restore it after reset, either PHB range or PE range.
4430 ++ */
4431 ++ if (edev->mode & EEH_DEV_BRIDGE)
4432 ++ edev->config_space[1] |= PCI_COMMAND_MASTER;
4433 + }
4434 +
4435 + /**
4436 +diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
4437 +index bebdf1a1a540..36d49e6b7c4c 100644
4438 +--- a/arch/powerpc/kernel/signal_32.c
4439 ++++ b/arch/powerpc/kernel/signal_32.c
4440 +@@ -457,7 +457,15 @@ static int save_user_regs(struct pt_regs *regs, struct mcontext __user *frame,
4441 + if (copy_vsx_to_user(&frame->mc_vsregs, current))
4442 + return 1;
4443 + msr |= MSR_VSX;
4444 +- }
4445 ++ } else if (!ctx_has_vsx_region)
4446 ++ /*
4447 ++ * With a small context structure we can't hold the VSX
4448 ++ * registers, hence clear the MSR value to indicate the state
4449 ++ * was not saved.
4450 ++ */
4451 ++ msr &= ~MSR_VSX;
4452 ++
4453 ++
4454 + #endif /* CONFIG_VSX */
4455 + #ifdef CONFIG_SPE
4456 + /* save spe registers */
4457 +diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c
4458 +index 192b051df97e..b3b144121cc9 100644
4459 +--- a/arch/powerpc/kernel/time.c
4460 ++++ b/arch/powerpc/kernel/time.c
4461 +@@ -213,8 +213,6 @@ static u64 scan_dispatch_log(u64 stop_tb)
4462 + if (i == be64_to_cpu(vpa->dtl_idx))
4463 + return 0;
4464 + while (i < be64_to_cpu(vpa->dtl_idx)) {
4465 +- if (dtl_consumer)
4466 +- dtl_consumer(dtl, i);
4467 + dtb = be64_to_cpu(dtl->timebase);
4468 + tb_delta = be32_to_cpu(dtl->enqueue_to_dispatch_time) +
4469 + be32_to_cpu(dtl->ready_to_enqueue_time);
4470 +@@ -227,6 +225,8 @@ static u64 scan_dispatch_log(u64 stop_tb)
4471 + }
4472 + if (dtb > stop_tb)
4473 + break;
4474 ++ if (dtl_consumer)
4475 ++ dtl_consumer(dtl, i);
4476 + stolen += tb_delta;
4477 + ++i;
4478 + ++dtl;
4479 +diff --git a/arch/powerpc/kernel/vio.c b/arch/powerpc/kernel/vio.c
4480 +index d38cc08b16c7..cb92d8204ec7 100644
4481 +--- a/arch/powerpc/kernel/vio.c
4482 ++++ b/arch/powerpc/kernel/vio.c
4483 +@@ -1531,12 +1531,12 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
4484 +
4485 + dn = dev->of_node;
4486 + if (!dn) {
4487 +- strcat(buf, "\n");
4488 ++ strcpy(buf, "\n");
4489 + return strlen(buf);
4490 + }
4491 + cp = of_get_property(dn, "compatible", NULL);
4492 + if (!cp) {
4493 +- strcat(buf, "\n");
4494 ++ strcpy(buf, "\n");
4495 + return strlen(buf);
4496 + }
4497 +
4498 +diff --git a/arch/powerpc/mm/gup.c b/arch/powerpc/mm/gup.c
4499 +index 6936547018b8..c5f734e20b0f 100644
4500 +--- a/arch/powerpc/mm/gup.c
4501 ++++ b/arch/powerpc/mm/gup.c
4502 +@@ -123,6 +123,7 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
4503 + struct mm_struct *mm = current->mm;
4504 + unsigned long addr, len, end;
4505 + unsigned long next;
4506 ++ unsigned long flags;
4507 + pgd_t *pgdp;
4508 + int nr = 0;
4509 +
4510 +@@ -156,7 +157,7 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
4511 + * So long as we atomically load page table pointers versus teardown,
4512 + * we can follow the address down to the the page and take a ref on it.
4513 + */
4514 +- local_irq_disable();
4515 ++ local_irq_save(flags);
4516 +
4517 + pgdp = pgd_offset(mm, addr);
4518 + do {
4519 +@@ -179,7 +180,7 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
4520 + break;
4521 + } while (pgdp++, addr = next, addr != end);
4522 +
4523 +- local_irq_enable();
4524 ++ local_irq_restore(flags);
4525 +
4526 + return nr;
4527 + }
4528 +diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c
4529 +index 3e99c149271a..7ce9cf3b6988 100644
4530 +--- a/arch/powerpc/mm/slice.c
4531 ++++ b/arch/powerpc/mm/slice.c
4532 +@@ -258,7 +258,7 @@ static bool slice_scan_available(unsigned long addr,
4533 + slice = GET_HIGH_SLICE_INDEX(addr);
4534 + *boundary_addr = (slice + end) ?
4535 + ((slice + end) << SLICE_HIGH_SHIFT) : SLICE_LOW_TOP;
4536 +- return !!(available.high_slices & (1u << slice));
4537 ++ return !!(available.high_slices & (1ul << slice));
4538 + }
4539 + }
4540 +
4541 +diff --git a/arch/powerpc/platforms/512x/mpc512x_shared.c b/arch/powerpc/platforms/512x/mpc512x_shared.c
4542 +index a82a41b4fd91..1a7b1d0f41df 100644
4543 +--- a/arch/powerpc/platforms/512x/mpc512x_shared.c
4544 ++++ b/arch/powerpc/platforms/512x/mpc512x_shared.c
4545 +@@ -303,6 +303,9 @@ void __init mpc512x_setup_diu(void)
4546 + diu_ops.release_bootmem = mpc512x_release_bootmem;
4547 + }
4548 +
4549 ++#else
4550 ++void __init mpc512x_setup_diu(void) { /* EMPTY */ }
4551 ++void __init mpc512x_init_diu(void) { /* EMPTY */ }
4552 + #endif
4553 +
4554 + void __init mpc512x_init_IRQ(void)
4555 +diff --git a/arch/powerpc/platforms/52xx/Kconfig b/arch/powerpc/platforms/52xx/Kconfig
4556 +index 90f4496017e4..af54174801f7 100644
4557 +--- a/arch/powerpc/platforms/52xx/Kconfig
4558 ++++ b/arch/powerpc/platforms/52xx/Kconfig
4559 +@@ -57,5 +57,5 @@ config PPC_MPC5200_BUGFIX
4560 +
4561 + config PPC_MPC5200_LPBFIFO
4562 + tristate "MPC5200 LocalPlus bus FIFO driver"
4563 +- depends on PPC_MPC52xx
4564 ++ depends on PPC_MPC52xx && PPC_BESTCOMM
4565 + select PPC_BESTCOMM_GEN_BD
4566 +diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
4567 +index 74a5a5773b1f..930e1fe78214 100644
4568 +--- a/arch/powerpc/platforms/powernv/pci-ioda.c
4569 ++++ b/arch/powerpc/platforms/powernv/pci-ioda.c
4570 +@@ -153,13 +153,23 @@ static int pnv_ioda_configure_pe(struct pnv_phb *phb, struct pnv_ioda_pe *pe)
4571 + rid_end = pe->rid + 1;
4572 + }
4573 +
4574 +- /* Associate PE in PELT */
4575 ++ /*
4576 ++ * Associate PE in PELT. We need add the PE into the
4577 ++ * corresponding PELT-V as well. Otherwise, the error
4578 ++ * originated from the PE might contribute to other
4579 ++ * PEs.
4580 ++ */
4581 + rc = opal_pci_set_pe(phb->opal_id, pe->pe_number, pe->rid,
4582 + bcomp, dcomp, fcomp, OPAL_MAP_PE);
4583 + if (rc) {
4584 + pe_err(pe, "OPAL error %ld trying to setup PELT table\n", rc);
4585 + return -ENXIO;
4586 + }
4587 ++
4588 ++ rc = opal_pci_set_peltv(phb->opal_id, pe->pe_number,
4589 ++ pe->pe_number, OPAL_ADD_PE_TO_DOMAIN);
4590 ++ if (rc)
4591 ++ pe_warn(pe, "OPAL error %d adding self to PELTV\n", rc);
4592 + opal_pci_eeh_freeze_clear(phb->opal_id, pe->pe_number,
4593 + OPAL_EEH_ACTION_CLEAR_FREEZE_ALL);
4594 +
4595 +diff --git a/arch/s390/crypto/aes_s390.c b/arch/s390/crypto/aes_s390.c
4596 +index b4dbade8ca24..2e4b5be31a1b 100644
4597 +--- a/arch/s390/crypto/aes_s390.c
4598 ++++ b/arch/s390/crypto/aes_s390.c
4599 +@@ -35,7 +35,6 @@ static u8 *ctrblk;
4600 + static char keylen_flag;
4601 +
4602 + struct s390_aes_ctx {
4603 +- u8 iv[AES_BLOCK_SIZE];
4604 + u8 key[AES_MAX_KEY_SIZE];
4605 + long enc;
4606 + long dec;
4607 +@@ -441,30 +440,36 @@ static int cbc_aes_set_key(struct crypto_tfm *tfm, const u8 *in_key,
4608 + return aes_set_key(tfm, in_key, key_len);
4609 + }
4610 +
4611 +-static int cbc_aes_crypt(struct blkcipher_desc *desc, long func, void *param,
4612 ++static int cbc_aes_crypt(struct blkcipher_desc *desc, long func,
4613 + struct blkcipher_walk *walk)
4614 + {
4615 ++ struct s390_aes_ctx *sctx = crypto_blkcipher_ctx(desc->tfm);
4616 + int ret = blkcipher_walk_virt(desc, walk);
4617 + unsigned int nbytes = walk->nbytes;
4618 ++ struct {
4619 ++ u8 iv[AES_BLOCK_SIZE];
4620 ++ u8 key[AES_MAX_KEY_SIZE];
4621 ++ } param;
4622 +
4623 + if (!nbytes)
4624 + goto out;
4625 +
4626 +- memcpy(param, walk->iv, AES_BLOCK_SIZE);
4627 ++ memcpy(param.iv, walk->iv, AES_BLOCK_SIZE);
4628 ++ memcpy(param.key, sctx->key, sctx->key_len);
4629 + do {
4630 + /* only use complete blocks */
4631 + unsigned int n = nbytes & ~(AES_BLOCK_SIZE - 1);
4632 + u8 *out = walk->dst.virt.addr;
4633 + u8 *in = walk->src.virt.addr;
4634 +
4635 +- ret = crypt_s390_kmc(func, param, out, in, n);
4636 ++ ret = crypt_s390_kmc(func, &param, out, in, n);
4637 + if (ret < 0 || ret != n)
4638 + return -EIO;
4639 +
4640 + nbytes &= AES_BLOCK_SIZE - 1;
4641 + ret = blkcipher_walk_done(desc, walk, nbytes);
4642 + } while ((nbytes = walk->nbytes));
4643 +- memcpy(walk->iv, param, AES_BLOCK_SIZE);
4644 ++ memcpy(walk->iv, param.iv, AES_BLOCK_SIZE);
4645 +
4646 + out:
4647 + return ret;
4648 +@@ -481,7 +486,7 @@ static int cbc_aes_encrypt(struct blkcipher_desc *desc,
4649 + return fallback_blk_enc(desc, dst, src, nbytes);
4650 +
4651 + blkcipher_walk_init(&walk, dst, src, nbytes);
4652 +- return cbc_aes_crypt(desc, sctx->enc, sctx->iv, &walk);
4653 ++ return cbc_aes_crypt(desc, sctx->enc, &walk);
4654 + }
4655 +
4656 + static int cbc_aes_decrypt(struct blkcipher_desc *desc,
4657 +@@ -495,7 +500,7 @@ static int cbc_aes_decrypt(struct blkcipher_desc *desc,
4658 + return fallback_blk_dec(desc, dst, src, nbytes);
4659 +
4660 + blkcipher_walk_init(&walk, dst, src, nbytes);
4661 +- return cbc_aes_crypt(desc, sctx->dec, sctx->iv, &walk);
4662 ++ return cbc_aes_crypt(desc, sctx->dec, &walk);
4663 + }
4664 +
4665 + static struct crypto_alg cbc_aes_alg = {
4666 +diff --git a/arch/s390/include/asm/timex.h b/arch/s390/include/asm/timex.h
4667 +index 819b94d22720..8beee1cceba4 100644
4668 +--- a/arch/s390/include/asm/timex.h
4669 ++++ b/arch/s390/include/asm/timex.h
4670 +@@ -71,9 +71,11 @@ static inline void local_tick_enable(unsigned long long comp)
4671 +
4672 + typedef unsigned long long cycles_t;
4673 +
4674 +-static inline void get_tod_clock_ext(char *clk)
4675 ++static inline void get_tod_clock_ext(char clk[16])
4676 + {
4677 +- asm volatile("stcke %0" : "=Q" (*clk) : : "cc");
4678 ++ typedef struct { char _[sizeof(clk)]; } addrtype;
4679 ++
4680 ++ asm volatile("stcke %0" : "=Q" (*(addrtype *) clk) : : "cc");
4681 + }
4682 +
4683 + static inline unsigned long long get_tod_clock(void)
4684 +diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c
4685 +index 1a4313a1b60f..93439cd04406 100644
4686 +--- a/arch/s390/kernel/smp.c
4687 ++++ b/arch/s390/kernel/smp.c
4688 +@@ -929,7 +929,7 @@ static ssize_t show_idle_count(struct device *dev,
4689 + idle_count = ACCESS_ONCE(idle->idle_count);
4690 + if (ACCESS_ONCE(idle->clock_idle_enter))
4691 + idle_count++;
4692 +- } while ((sequence & 1) || (idle->sequence != sequence));
4693 ++ } while ((sequence & 1) || (ACCESS_ONCE(idle->sequence) != sequence));
4694 + return sprintf(buf, "%llu\n", idle_count);
4695 + }
4696 + static DEVICE_ATTR(idle_count, 0444, show_idle_count, NULL);
4697 +@@ -947,7 +947,7 @@ static ssize_t show_idle_time(struct device *dev,
4698 + idle_time = ACCESS_ONCE(idle->idle_time);
4699 + idle_enter = ACCESS_ONCE(idle->clock_idle_enter);
4700 + idle_exit = ACCESS_ONCE(idle->clock_idle_exit);
4701 +- } while ((sequence & 1) || (idle->sequence != sequence));
4702 ++ } while ((sequence & 1) || (ACCESS_ONCE(idle->sequence) != sequence));
4703 + idle_time += idle_enter ? ((idle_exit ? : now) - idle_enter) : 0;
4704 + return sprintf(buf, "%llu\n", idle_time >> 12);
4705 + }
4706 +diff --git a/arch/s390/kernel/vtime.c b/arch/s390/kernel/vtime.c
4707 +index abcfab55f99b..bb06a76040bf 100644
4708 +--- a/arch/s390/kernel/vtime.c
4709 ++++ b/arch/s390/kernel/vtime.c
4710 +@@ -191,7 +191,7 @@ cputime64_t s390_get_idle_time(int cpu)
4711 + sequence = ACCESS_ONCE(idle->sequence);
4712 + idle_enter = ACCESS_ONCE(idle->clock_idle_enter);
4713 + idle_exit = ACCESS_ONCE(idle->clock_idle_exit);
4714 +- } while ((sequence & 1) || (idle->sequence != sequence));
4715 ++ } while ((sequence & 1) || (ACCESS_ONCE(idle->sequence) != sequence));
4716 + return idle_enter ? ((idle_exit ?: now) - idle_enter) : 0;
4717 + }
4718 +
4719 +diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
4720 +index e0e0841eef45..18677a90d6a3 100644
4721 +--- a/arch/x86/kernel/crash.c
4722 ++++ b/arch/x86/kernel/crash.c
4723 +@@ -127,12 +127,12 @@ void native_machine_crash_shutdown(struct pt_regs *regs)
4724 + cpu_emergency_vmxoff();
4725 + cpu_emergency_svm_disable();
4726 +
4727 +- lapic_shutdown();
4728 + #ifdef CONFIG_X86_IO_APIC
4729 + /* Prevent crash_kexec() from deadlocking on ioapic_lock. */
4730 + ioapic_zap_locks();
4731 + disable_IO_APIC();
4732 + #endif
4733 ++ lapic_shutdown();
4734 + #ifdef CONFIG_HPET_TIMER
4735 + hpet_disable();
4736 + #endif
4737 +diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
4738 +index 42a392a9fd02..d4bdd253fea7 100644
4739 +--- a/arch/x86/kernel/ftrace.c
4740 ++++ b/arch/x86/kernel/ftrace.c
4741 +@@ -248,6 +248,15 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
4742 + return ret;
4743 + }
4744 +
4745 ++static int is_ftrace_caller(unsigned long ip)
4746 ++{
4747 ++ if (ip == (unsigned long)(&ftrace_call) ||
4748 ++ ip == (unsigned long)(&ftrace_regs_call))
4749 ++ return 1;
4750 ++
4751 ++ return 0;
4752 ++}
4753 ++
4754 + /*
4755 + * A breakpoint was added to the code address we are about to
4756 + * modify, and this is the handle that will just skip over it.
4757 +@@ -257,10 +266,13 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
4758 + */
4759 + int ftrace_int3_handler(struct pt_regs *regs)
4760 + {
4761 ++ unsigned long ip;
4762 ++
4763 + if (WARN_ON_ONCE(!regs))
4764 + return 0;
4765 +
4766 +- if (!ftrace_location(regs->ip - 1))
4767 ++ ip = regs->ip - 1;
4768 ++ if (!ftrace_location(ip) && !is_ftrace_caller(ip))
4769 + return 0;
4770 +
4771 + regs->ip += MCOUNT_INSN_SIZE - 1;
4772 +diff --git a/arch/x86/kernel/microcode_amd.c b/arch/x86/kernel/microcode_amd.c
4773 +index af99f71aeb7f..c3d4cc972eca 100644
4774 +--- a/arch/x86/kernel/microcode_amd.c
4775 ++++ b/arch/x86/kernel/microcode_amd.c
4776 +@@ -431,7 +431,7 @@ static enum ucode_state request_microcode_amd(int cpu, struct device *device,
4777 + snprintf(fw_name, sizeof(fw_name), "amd-ucode/microcode_amd_fam%.2xh.bin", c->x86);
4778 +
4779 + if (request_firmware(&fw, (const char *)fw_name, device)) {
4780 +- pr_err("failed to load file %s\n", fw_name);
4781 ++ pr_debug("failed to load file %s\n", fw_name);
4782 + goto out;
4783 + }
4784 +
4785 +diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
4786 +index c83516be1052..3fb8d95ab8b5 100644
4787 +--- a/arch/x86/kernel/process.c
4788 ++++ b/arch/x86/kernel/process.c
4789 +@@ -391,9 +391,9 @@ static void amd_e400_idle(void)
4790 + * The switch back from broadcast mode needs to be
4791 + * called with interrupts disabled.
4792 + */
4793 +- local_irq_disable();
4794 +- clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_EXIT, &cpu);
4795 +- local_irq_enable();
4796 ++ local_irq_disable();
4797 ++ clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_EXIT, &cpu);
4798 ++ local_irq_enable();
4799 + } else
4800 + default_idle();
4801 + }
4802 +diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
4803 +index 7e920bff99a3..618ce264b237 100644
4804 +--- a/arch/x86/kernel/reboot.c
4805 ++++ b/arch/x86/kernel/reboot.c
4806 +@@ -550,6 +550,10 @@ static void native_machine_emergency_restart(void)
4807 + void native_machine_shutdown(void)
4808 + {
4809 + /* Stop the cpus and apics */
4810 ++#ifdef CONFIG_X86_IO_APIC
4811 ++ disable_IO_APIC();
4812 ++#endif
4813 ++
4814 + #ifdef CONFIG_SMP
4815 + /*
4816 + * Stop all of the others. Also disable the local irq to
4817 +@@ -562,10 +566,6 @@ void native_machine_shutdown(void)
4818 +
4819 + lapic_shutdown();
4820 +
4821 +-#ifdef CONFIG_X86_IO_APIC
4822 +- disable_IO_APIC();
4823 +-#endif
4824 +-
4825 + #ifdef CONFIG_HPET_TIMER
4826 + hpet_disable();
4827 + #endif
4828 +diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
4829 +index ddc3f3d2afdb..92e6f4a8ba0e 100644
4830 +--- a/arch/x86/kvm/emulate.c
4831 ++++ b/arch/x86/kvm/emulate.c
4832 +@@ -4040,7 +4040,10 @@ static int decode_operand(struct x86_emulate_ctxt *ctxt, struct operand *op,
4833 + case OpMem8:
4834 + ctxt->memop.bytes = 1;
4835 + if (ctxt->memop.type == OP_REG) {
4836 +- ctxt->memop.addr.reg = decode_register(ctxt, ctxt->modrm_rm, 1);
4837 ++ int highbyte_regs = ctxt->rex_prefix == 0;
4838 ++
4839 ++ ctxt->memop.addr.reg = decode_register(ctxt, ctxt->modrm_rm,
4840 ++ highbyte_regs);
4841 + fetch_register_operand(&ctxt->memop);
4842 + }
4843 + goto mem_common;
4844 +diff --git a/block/blk-core.c b/block/blk-core.c
4845 +index 0a00e4ecf87c..5e00b5a58f6a 100644
4846 +--- a/block/blk-core.c
4847 ++++ b/block/blk-core.c
4848 +@@ -2227,6 +2227,7 @@ void blk_start_request(struct request *req)
4849 + if (unlikely(blk_bidi_rq(req)))
4850 + req->next_rq->resid_len = blk_rq_bytes(req->next_rq);
4851 +
4852 ++ BUG_ON(test_bit(REQ_ATOM_COMPLETE, &req->atomic_flags));
4853 + blk_add_timer(req);
4854 + }
4855 + EXPORT_SYMBOL(blk_start_request);
4856 +diff --git a/block/blk-settings.c b/block/blk-settings.c
4857 +index c50ecf0ea3b1..53309333c2f0 100644
4858 +--- a/block/blk-settings.c
4859 ++++ b/block/blk-settings.c
4860 +@@ -144,6 +144,7 @@ void blk_set_stacking_limits(struct queue_limits *lim)
4861 + lim->discard_zeroes_data = 1;
4862 + lim->max_segments = USHRT_MAX;
4863 + lim->max_hw_sectors = UINT_MAX;
4864 ++ lim->max_segment_size = UINT_MAX;
4865 + lim->max_sectors = UINT_MAX;
4866 + lim->max_write_same_sectors = UINT_MAX;
4867 + }
4868 +diff --git a/block/blk-timeout.c b/block/blk-timeout.c
4869 +index 65f103563969..655ba909cd6a 100644
4870 +--- a/block/blk-timeout.c
4871 ++++ b/block/blk-timeout.c
4872 +@@ -91,8 +91,8 @@ static void blk_rq_timed_out(struct request *req)
4873 + __blk_complete_request(req);
4874 + break;
4875 + case BLK_EH_RESET_TIMER:
4876 +- blk_clear_rq_complete(req);
4877 + blk_add_timer(req);
4878 ++ blk_clear_rq_complete(req);
4879 + break;
4880 + case BLK_EH_NOT_HANDLED:
4881 + /*
4882 +@@ -174,7 +174,6 @@ void blk_add_timer(struct request *req)
4883 + return;
4884 +
4885 + BUG_ON(!list_empty(&req->timeout_list));
4886 +- BUG_ON(test_bit(REQ_ATOM_COMPLETE, &req->atomic_flags));
4887 +
4888 + /*
4889 + * Some LLDs, like scsi, peek at the timeout to prevent a
4890 +diff --git a/crypto/ansi_cprng.c b/crypto/ansi_cprng.c
4891 +index c0bb3778f1ae..666f1962a160 100644
4892 +--- a/crypto/ansi_cprng.c
4893 ++++ b/crypto/ansi_cprng.c
4894 +@@ -230,11 +230,11 @@ remainder:
4895 + */
4896 + if (byte_count < DEFAULT_BLK_SZ) {
4897 + empty_rbuf:
4898 +- for (; ctx->rand_data_valid < DEFAULT_BLK_SZ;
4899 +- ctx->rand_data_valid++) {
4900 ++ while (ctx->rand_data_valid < DEFAULT_BLK_SZ) {
4901 + *ptr = ctx->rand_data[ctx->rand_data_valid];
4902 + ptr++;
4903 + byte_count--;
4904 ++ ctx->rand_data_valid++;
4905 + if (byte_count == 0)
4906 + goto done;
4907 + }
4908 +diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
4909 +index a06d98374705..15986f32009e 100644
4910 +--- a/drivers/acpi/ec.c
4911 ++++ b/drivers/acpi/ec.c
4912 +@@ -175,9 +175,10 @@ static void start_transaction(struct acpi_ec *ec)
4913 + static void advance_transaction(struct acpi_ec *ec, u8 status)
4914 + {
4915 + unsigned long flags;
4916 +- struct transaction *t = ec->curr;
4917 ++ struct transaction *t;
4918 +
4919 + spin_lock_irqsave(&ec->lock, flags);
4920 ++ t = ec->curr;
4921 + if (!t)
4922 + goto unlock;
4923 + if (t->wlen > t->wi) {
4924 +diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
4925 +index d3874f425653..d7e53ea53d6c 100644
4926 +--- a/drivers/acpi/pci_root.c
4927 ++++ b/drivers/acpi/pci_root.c
4928 +@@ -608,9 +608,12 @@ static void handle_root_bridge_removal(struct acpi_device *device)
4929 + ej_event->device = device;
4930 + ej_event->event = ACPI_NOTIFY_EJECT_REQUEST;
4931 +
4932 ++ get_device(&device->dev);
4933 + status = acpi_os_hotplug_execute(acpi_bus_hot_remove_device, ej_event);
4934 +- if (ACPI_FAILURE(status))
4935 ++ if (ACPI_FAILURE(status)) {
4936 ++ put_device(&device->dev);
4937 + kfree(ej_event);
4938 ++ }
4939 + }
4940 +
4941 + static void _handle_hotplug_event_root(struct work_struct *work)
4942 +diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
4943 +index f98dd00b51a9..c7414a545a4f 100644
4944 +--- a/drivers/acpi/processor_idle.c
4945 ++++ b/drivers/acpi/processor_idle.c
4946 +@@ -119,17 +119,10 @@ static struct dmi_system_id processor_power_dmi_table[] = {
4947 + */
4948 + static void acpi_safe_halt(void)
4949 + {
4950 +- current_thread_info()->status &= ~TS_POLLING;
4951 +- /*
4952 +- * TS_POLLING-cleared state must be visible before we
4953 +- * test NEED_RESCHED:
4954 +- */
4955 +- smp_mb();
4956 +- if (!need_resched()) {
4957 ++ if (!tif_need_resched()) {
4958 + safe_halt();
4959 + local_irq_disable();
4960 + }
4961 +- current_thread_info()->status |= TS_POLLING;
4962 + }
4963 +
4964 + #ifdef ARCH_APICTIMER_STOPS_ON_C3
4965 +@@ -737,6 +730,11 @@ static int acpi_idle_enter_c1(struct cpuidle_device *dev,
4966 + if (unlikely(!pr))
4967 + return -EINVAL;
4968 +
4969 ++ if (cx->entry_method == ACPI_CSTATE_FFH) {
4970 ++ if (current_set_polling_and_test())
4971 ++ return -EINVAL;
4972 ++ }
4973 ++
4974 + lapic_timer_state_broadcast(pr, cx, 1);
4975 + acpi_idle_do_entry(cx);
4976 +
4977 +@@ -790,18 +788,9 @@ static int acpi_idle_enter_simple(struct cpuidle_device *dev,
4978 + if (unlikely(!pr))
4979 + return -EINVAL;
4980 +
4981 +- if (cx->entry_method != ACPI_CSTATE_FFH) {
4982 +- current_thread_info()->status &= ~TS_POLLING;
4983 +- /*
4984 +- * TS_POLLING-cleared state must be visible before we test
4985 +- * NEED_RESCHED:
4986 +- */
4987 +- smp_mb();
4988 +-
4989 +- if (unlikely(need_resched())) {
4990 +- current_thread_info()->status |= TS_POLLING;
4991 ++ if (cx->entry_method == ACPI_CSTATE_FFH) {
4992 ++ if (current_set_polling_and_test())
4993 + return -EINVAL;
4994 +- }
4995 + }
4996 +
4997 + /*
4998 +@@ -819,9 +808,6 @@ static int acpi_idle_enter_simple(struct cpuidle_device *dev,
4999 +
5000 + sched_clock_idle_wakeup_event(0);
5001 +
5002 +- if (cx->entry_method != ACPI_CSTATE_FFH)
5003 +- current_thread_info()->status |= TS_POLLING;
5004 +-
5005 + lapic_timer_state_broadcast(pr, cx, 0);
5006 + return index;
5007 + }
5008 +@@ -858,18 +844,9 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev,
5009 + }
5010 + }
5011 +
5012 +- if (cx->entry_method != ACPI_CSTATE_FFH) {
5013 +- current_thread_info()->status &= ~TS_POLLING;
5014 +- /*
5015 +- * TS_POLLING-cleared state must be visible before we test
5016 +- * NEED_RESCHED:
5017 +- */
5018 +- smp_mb();
5019 +-
5020 +- if (unlikely(need_resched())) {
5021 +- current_thread_info()->status |= TS_POLLING;
5022 ++ if (cx->entry_method == ACPI_CSTATE_FFH) {
5023 ++ if (current_set_polling_and_test())
5024 + return -EINVAL;
5025 +- }
5026 + }
5027 +
5028 + acpi_unlazy_tlb(smp_processor_id());
5029 +@@ -915,9 +892,6 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev,
5030 +
5031 + sched_clock_idle_wakeup_event(0);
5032 +
5033 +- if (cx->entry_method != ACPI_CSTATE_FFH)
5034 +- current_thread_info()->status |= TS_POLLING;
5035 +-
5036 + lapic_timer_state_broadcast(pr, cx, 0);
5037 + return index;
5038 + }
5039 +diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
5040 +index fee8a297c7d9..3601738ef6f4 100644
5041 +--- a/drivers/acpi/scan.c
5042 ++++ b/drivers/acpi/scan.c
5043 +@@ -331,8 +331,6 @@ static void acpi_scan_bus_device_check(acpi_handle handle, u32 ost_source)
5044 + goto out;
5045 + }
5046 + }
5047 +- acpi_evaluate_hotplug_ost(handle, ost_source,
5048 +- ACPI_OST_SC_INSERT_IN_PROGRESS, NULL);
5049 + error = acpi_bus_scan(handle);
5050 + if (error) {
5051 + acpi_handle_warn(handle, "Namespace scan failure\n");
5052 +diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
5053 +index aebcf6355df4..f193285968f8 100644
5054 +--- a/drivers/acpi/video.c
5055 ++++ b/drivers/acpi/video.c
5056 +@@ -832,7 +832,7 @@ acpi_video_init_brightness(struct acpi_video_device *device)
5057 + for (i = 2; i < br->count; i++)
5058 + if (level_old == br->levels[i])
5059 + break;
5060 +- if (i == br->count)
5061 ++ if (i == br->count || !level)
5062 + level = max_level;
5063 + }
5064 +
5065 +diff --git a/drivers/block/brd.c b/drivers/block/brd.c
5066 +index 9bf4371755f2..d91f1a56e861 100644
5067 +--- a/drivers/block/brd.c
5068 ++++ b/drivers/block/brd.c
5069 +@@ -545,7 +545,7 @@ static struct kobject *brd_probe(dev_t dev, int *part, void *data)
5070 +
5071 + mutex_lock(&brd_devices_mutex);
5072 + brd = brd_init_one(MINOR(dev) >> part_shift);
5073 +- kobj = brd ? get_disk(brd->brd_disk) : ERR_PTR(-ENOMEM);
5074 ++ kobj = brd ? get_disk(brd->brd_disk) : NULL;
5075 + mutex_unlock(&brd_devices_mutex);
5076 +
5077 + *part = 0;
5078 +diff --git a/drivers/block/loop.c b/drivers/block/loop.c
5079 +index 40e715531aa6..2f036ca4b6ee 100644
5080 +--- a/drivers/block/loop.c
5081 ++++ b/drivers/block/loop.c
5082 +@@ -1741,7 +1741,7 @@ static struct kobject *loop_probe(dev_t dev, int *part, void *data)
5083 + if (err < 0)
5084 + err = loop_add(&lo, MINOR(dev) >> part_shift);
5085 + if (err < 0)
5086 +- kobj = ERR_PTR(err);
5087 ++ kobj = NULL;
5088 + else
5089 + kobj = get_disk(lo->lo_disk);
5090 + mutex_unlock(&loop_index_mutex);
5091 +diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
5092 +index f3dfc0a88fdc..d593c99121c3 100644
5093 +--- a/drivers/bluetooth/btusb.c
5094 ++++ b/drivers/bluetooth/btusb.c
5095 +@@ -1628,7 +1628,6 @@ static struct usb_driver btusb_driver = {
5096 + #ifdef CONFIG_PM
5097 + .suspend = btusb_suspend,
5098 + .resume = btusb_resume,
5099 +- .reset_resume = btusb_resume,
5100 + #endif
5101 + .id_table = btusb_table,
5102 + .supports_autosuspend = 1,
5103 +diff --git a/drivers/gpu/drm/nouveau/core/engine/graph/ctxnvc1.c b/drivers/gpu/drm/nouveau/core/engine/graph/ctxnvc1.c
5104 +index e5be3ee7f172..71b4283f7fad 100644
5105 +--- a/drivers/gpu/drm/nouveau/core/engine/graph/ctxnvc1.c
5106 ++++ b/drivers/gpu/drm/nouveau/core/engine/graph/ctxnvc1.c
5107 +@@ -587,6 +587,7 @@ nvc1_grctx_init_unk58xx[] = {
5108 + { 0x405870, 4, 0x04, 0x00000001 },
5109 + { 0x405a00, 2, 0x04, 0x00000000 },
5110 + { 0x405a18, 1, 0x04, 0x00000000 },
5111 ++ {}
5112 + };
5113 +
5114 + static struct nvc0_graph_init
5115 +@@ -598,6 +599,7 @@ nvc1_grctx_init_rop[] = {
5116 + { 0x408904, 1, 0x04, 0x62000001 },
5117 + { 0x408908, 1, 0x04, 0x00c80929 },
5118 + { 0x408980, 1, 0x04, 0x0000011d },
5119 ++ {}
5120 + };
5121 +
5122 + static struct nvc0_graph_init
5123 +@@ -671,6 +673,7 @@ nvc1_grctx_init_gpc_0[] = {
5124 + { 0x419000, 1, 0x04, 0x00000780 },
5125 + { 0x419004, 2, 0x04, 0x00000000 },
5126 + { 0x419014, 1, 0x04, 0x00000004 },
5127 ++ {}
5128 + };
5129 +
5130 + static struct nvc0_graph_init
5131 +@@ -717,6 +720,7 @@ nvc1_grctx_init_tpc[] = {
5132 + { 0x419e98, 1, 0x04, 0x00000000 },
5133 + { 0x419ee0, 1, 0x04, 0x00011110 },
5134 + { 0x419f30, 11, 0x04, 0x00000000 },
5135 ++ {}
5136 + };
5137 +
5138 + void
5139 +diff --git a/drivers/gpu/drm/nouveau/core/engine/graph/ctxnvd7.c b/drivers/gpu/drm/nouveau/core/engine/graph/ctxnvd7.c
5140 +index 438e78410808..c4740d528532 100644
5141 +--- a/drivers/gpu/drm/nouveau/core/engine/graph/ctxnvd7.c
5142 ++++ b/drivers/gpu/drm/nouveau/core/engine/graph/ctxnvd7.c
5143 +@@ -258,6 +258,7 @@ nvd7_grctx_init_hub[] = {
5144 + nvc0_grctx_init_unk78xx,
5145 + nvc0_grctx_init_unk80xx,
5146 + nvd9_grctx_init_rop,
5147 ++ NULL
5148 + };
5149 +
5150 + struct nvc0_graph_init *
5151 +diff --git a/drivers/gpu/drm/nouveau/core/engine/graph/ctxnvd9.c b/drivers/gpu/drm/nouveau/core/engine/graph/ctxnvd9.c
5152 +index 818a4751df46..a1102cbf2fdc 100644
5153 +--- a/drivers/gpu/drm/nouveau/core/engine/graph/ctxnvd9.c
5154 ++++ b/drivers/gpu/drm/nouveau/core/engine/graph/ctxnvd9.c
5155 +@@ -466,6 +466,7 @@ nvd9_grctx_init_hub[] = {
5156 + nvc0_grctx_init_unk78xx,
5157 + nvc0_grctx_init_unk80xx,
5158 + nvd9_grctx_init_rop,
5159 ++ NULL
5160 + };
5161 +
5162 + struct nvc0_graph_init *
5163 +diff --git a/drivers/gpu/drm/shmobile/Kconfig b/drivers/gpu/drm/shmobile/Kconfig
5164 +index ca498d151a76..5240690b96c3 100644
5165 +--- a/drivers/gpu/drm/shmobile/Kconfig
5166 ++++ b/drivers/gpu/drm/shmobile/Kconfig
5167 +@@ -1,6 +1,7 @@
5168 + config DRM_SHMOBILE
5169 + tristate "DRM Support for SH Mobile"
5170 + depends on DRM && (ARM || SUPERH)
5171 ++ select BACKLIGHT_CLASS_DEVICE
5172 + select DRM_KMS_HELPER
5173 + select DRM_KMS_CMA_HELPER
5174 + select DRM_GEM_CMA_HELPER
5175 +diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
5176 +index bbff5f200bef..fa920469bf10 100644
5177 +--- a/drivers/hv/channel_mgmt.c
5178 ++++ b/drivers/hv/channel_mgmt.c
5179 +@@ -203,7 +203,8 @@ static void vmbus_process_rescind_offer(struct work_struct *work)
5180 + struct vmbus_channel *primary_channel;
5181 + struct vmbus_channel_relid_released msg;
5182 +
5183 +- vmbus_device_unregister(channel->device_obj);
5184 ++ if (channel->device_obj)
5185 ++ vmbus_device_unregister(channel->device_obj);
5186 + memset(&msg, 0, sizeof(struct vmbus_channel_relid_released));
5187 + msg.child_relid = channel->offermsg.child_relid;
5188 + msg.header.msgtype = CHANNELMSG_RELID_RELEASED;
5189 +@@ -216,7 +217,7 @@ static void vmbus_process_rescind_offer(struct work_struct *work)
5190 + } else {
5191 + primary_channel = channel->primary_channel;
5192 + spin_lock_irqsave(&primary_channel->sc_lock, flags);
5193 +- list_del(&channel->listentry);
5194 ++ list_del(&channel->sc_list);
5195 + spin_unlock_irqrestore(&primary_channel->sc_lock, flags);
5196 + }
5197 + free_channel(channel);
5198 +diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
5199 +index cdff74282955..14e36c114d61 100644
5200 +--- a/drivers/hwmon/lm90.c
5201 ++++ b/drivers/hwmon/lm90.c
5202 +@@ -278,7 +278,7 @@ static const struct lm90_params lm90_params[] = {
5203 + [max6696] = {
5204 + .flags = LM90_HAVE_EMERGENCY
5205 + | LM90_HAVE_EMERGENCY_ALARM | LM90_HAVE_TEMP3,
5206 +- .alert_alarms = 0x187c,
5207 ++ .alert_alarms = 0x1c7c,
5208 + .max_convrate = 6,
5209 + .reg_local_ext = MAX6657_REG_R_LOCAL_TEMPL,
5210 + },
5211 +@@ -1500,19 +1500,22 @@ static void lm90_alert(struct i2c_client *client, unsigned int flag)
5212 + if ((alarms & 0x7f) == 0 && (alarms2 & 0xfe) == 0) {
5213 + dev_info(&client->dev, "Everything OK\n");
5214 + } else {
5215 +- if (alarms & 0x61)
5216 ++ if ((alarms & 0x61) || (alarms2 & 0x80))
5217 + dev_warn(&client->dev,
5218 + "temp%d out of range, please check!\n", 1);
5219 +- if (alarms & 0x1a)
5220 ++ if ((alarms & 0x1a) || (alarms2 & 0x20))
5221 + dev_warn(&client->dev,
5222 + "temp%d out of range, please check!\n", 2);
5223 + if (alarms & 0x04)
5224 + dev_warn(&client->dev,
5225 + "temp%d diode open, please check!\n", 2);
5226 +
5227 +- if (alarms2 & 0x18)
5228 ++ if (alarms2 & 0x5a)
5229 + dev_warn(&client->dev,
5230 + "temp%d out of range, please check!\n", 3);
5231 ++ if (alarms2 & 0x04)
5232 ++ dev_warn(&client->dev,
5233 ++ "temp%d diode open, please check!\n", 3);
5234 +
5235 + /*
5236 + * Disable ALERT# output, because these chips don't implement
5237 +diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c
5238 +index fa6964d8681a..f116d664b473 100644
5239 +--- a/drivers/idle/intel_idle.c
5240 ++++ b/drivers/idle/intel_idle.c
5241 +@@ -359,7 +359,7 @@ static int intel_idle(struct cpuidle_device *dev,
5242 + if (!(lapic_timer_reliable_states & (1 << (cstate))))
5243 + clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_ENTER, &cpu);
5244 +
5245 +- if (!need_resched()) {
5246 ++ if (!current_set_polling_and_test()) {
5247 +
5248 + __monitor((void *)&current_thread_info()->flags, 0, 0);
5249 + smp_mb();
5250 +diff --git a/drivers/memstick/core/ms_block.c b/drivers/memstick/core/ms_block.c
5251 +index 08e70232062f..9188ef5d677e 100644
5252 +--- a/drivers/memstick/core/ms_block.c
5253 ++++ b/drivers/memstick/core/ms_block.c
5254 +@@ -401,7 +401,7 @@ again:
5255 + sizeof(struct ms_status_register)))
5256 + return 0;
5257 +
5258 +- msb->state = MSB_RP_RECEIVE_OOB_READ;
5259 ++ msb->state = MSB_RP_RECIVE_STATUS_REG;
5260 + return 0;
5261 +
5262 + case MSB_RP_RECIVE_STATUS_REG:
5263 +diff --git a/drivers/misc/lkdtm.c b/drivers/misc/lkdtm.c
5264 +index 2fc0586ce3bb..9cbd0370ca44 100644
5265 +--- a/drivers/misc/lkdtm.c
5266 ++++ b/drivers/misc/lkdtm.c
5267 +@@ -297,6 +297,14 @@ static void do_nothing(void)
5268 + return;
5269 + }
5270 +
5271 ++static noinline void corrupt_stack(void)
5272 ++{
5273 ++ /* Use default char array length that triggers stack protection. */
5274 ++ char data[8];
5275 ++
5276 ++ memset((void *)data, 0, 64);
5277 ++}
5278 ++
5279 + static void execute_location(void *dst)
5280 + {
5281 + void (*func)(void) = dst;
5282 +@@ -327,13 +335,9 @@ static void lkdtm_do_action(enum ctype which)
5283 + case CT_OVERFLOW:
5284 + (void) recursive_loop(0);
5285 + break;
5286 +- case CT_CORRUPT_STACK: {
5287 +- /* Make sure the compiler creates and uses an 8 char array. */
5288 +- volatile char data[8];
5289 +-
5290 +- memset((void *)data, 0, 64);
5291 ++ case CT_CORRUPT_STACK:
5292 ++ corrupt_stack();
5293 + break;
5294 +- }
5295 + case CT_UNALIGNED_LOAD_STORE_WRITE: {
5296 + static u8 data[5] __attribute__((aligned(4))) = {1, 2,
5297 + 3, 4, 5};
5298 +diff --git a/drivers/misc/mei/nfc.c b/drivers/misc/mei/nfc.c
5299 +index d0c6907dfd92..994ca4aff1a3 100644
5300 +--- a/drivers/misc/mei/nfc.c
5301 ++++ b/drivers/misc/mei/nfc.c
5302 +@@ -485,8 +485,11 @@ int mei_nfc_host_init(struct mei_device *dev)
5303 + if (ndev->cl_info)
5304 + return 0;
5305 +
5306 +- cl_info = mei_cl_allocate(dev);
5307 +- cl = mei_cl_allocate(dev);
5308 ++ ndev->cl_info = mei_cl_allocate(dev);
5309 ++ ndev->cl = mei_cl_allocate(dev);
5310 ++
5311 ++ cl = ndev->cl;
5312 ++ cl_info = ndev->cl_info;
5313 +
5314 + if (!cl || !cl_info) {
5315 + ret = -ENOMEM;
5316 +@@ -527,10 +530,9 @@ int mei_nfc_host_init(struct mei_device *dev)
5317 +
5318 + cl->device_uuid = mei_nfc_guid;
5319 +
5320 ++
5321 + list_add_tail(&cl->device_link, &dev->device_list);
5322 +
5323 +- ndev->cl_info = cl_info;
5324 +- ndev->cl = cl;
5325 + ndev->req_id = 1;
5326 +
5327 + INIT_WORK(&ndev->init_work, mei_nfc_init);
5328 +diff --git a/drivers/net/can/c_can/c_can.c b/drivers/net/can/c_can/c_can.c
5329 +index a668cd491cb3..e3fc07cf2f62 100644
5330 +--- a/drivers/net/can/c_can/c_can.c
5331 ++++ b/drivers/net/can/c_can/c_can.c
5332 +@@ -814,9 +814,6 @@ static int c_can_do_rx_poll(struct net_device *dev, int quota)
5333 + msg_ctrl_save = priv->read_reg(priv,
5334 + C_CAN_IFACE(MSGCTRL_REG, 0));
5335 +
5336 +- if (msg_ctrl_save & IF_MCONT_EOB)
5337 +- return num_rx_pkts;
5338 +-
5339 + if (msg_ctrl_save & IF_MCONT_MSGLST) {
5340 + c_can_handle_lost_msg_obj(dev, 0, msg_obj);
5341 + num_rx_pkts++;
5342 +@@ -824,6 +821,9 @@ static int c_can_do_rx_poll(struct net_device *dev, int quota)
5343 + continue;
5344 + }
5345 +
5346 ++ if (msg_ctrl_save & IF_MCONT_EOB)
5347 ++ return num_rx_pkts;
5348 ++
5349 + if (!(msg_ctrl_save & IF_MCONT_NEWDAT))
5350 + continue;
5351 +
5352 +diff --git a/drivers/net/can/usb/kvaser_usb.c b/drivers/net/can/usb/kvaser_usb.c
5353 +index 3b9546588240..4b2d5ed62b11 100644
5354 +--- a/drivers/net/can/usb/kvaser_usb.c
5355 ++++ b/drivers/net/can/usb/kvaser_usb.c
5356 +@@ -1544,9 +1544,9 @@ static int kvaser_usb_init_one(struct usb_interface *intf,
5357 + return 0;
5358 + }
5359 +
5360 +-static void kvaser_usb_get_endpoints(const struct usb_interface *intf,
5361 +- struct usb_endpoint_descriptor **in,
5362 +- struct usb_endpoint_descriptor **out)
5363 ++static int kvaser_usb_get_endpoints(const struct usb_interface *intf,
5364 ++ struct usb_endpoint_descriptor **in,
5365 ++ struct usb_endpoint_descriptor **out)
5366 + {
5367 + const struct usb_host_interface *iface_desc;
5368 + struct usb_endpoint_descriptor *endpoint;
5369 +@@ -1557,12 +1557,18 @@ static void kvaser_usb_get_endpoints(const struct usb_interface *intf,
5370 + for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {
5371 + endpoint = &iface_desc->endpoint[i].desc;
5372 +
5373 +- if (usb_endpoint_is_bulk_in(endpoint))
5374 ++ if (!*in && usb_endpoint_is_bulk_in(endpoint))
5375 + *in = endpoint;
5376 +
5377 +- if (usb_endpoint_is_bulk_out(endpoint))
5378 ++ if (!*out && usb_endpoint_is_bulk_out(endpoint))
5379 + *out = endpoint;
5380 ++
5381 ++ /* use first bulk endpoint for in and out */
5382 ++ if (*in && *out)
5383 ++ return 0;
5384 + }
5385 ++
5386 ++ return -ENODEV;
5387 + }
5388 +
5389 + static int kvaser_usb_probe(struct usb_interface *intf,
5390 +@@ -1576,8 +1582,8 @@ static int kvaser_usb_probe(struct usb_interface *intf,
5391 + if (!dev)
5392 + return -ENOMEM;
5393 +
5394 +- kvaser_usb_get_endpoints(intf, &dev->bulk_in, &dev->bulk_out);
5395 +- if (!dev->bulk_in || !dev->bulk_out) {
5396 ++ err = kvaser_usb_get_endpoints(intf, &dev->bulk_in, &dev->bulk_out);
5397 ++ if (err) {
5398 + dev_err(&intf->dev, "Cannot get usb endpoint(s)");
5399 + return err;
5400 + }
5401 +diff --git a/drivers/net/ethernet/atheros/alx/main.c b/drivers/net/ethernet/atheros/alx/main.c
5402 +index fc95b235e210..6305a5d29db2 100644
5403 +--- a/drivers/net/ethernet/atheros/alx/main.c
5404 ++++ b/drivers/net/ethernet/atheros/alx/main.c
5405 +@@ -1389,6 +1389,9 @@ static int alx_resume(struct device *dev)
5406 + {
5407 + struct pci_dev *pdev = to_pci_dev(dev);
5408 + struct alx_priv *alx = pci_get_drvdata(pdev);
5409 ++ struct alx_hw *hw = &alx->hw;
5410 ++
5411 ++ alx_reset_phy(hw);
5412 +
5413 + if (!netif_running(alx->dev))
5414 + return 0;
5415 +diff --git a/drivers/net/wireless/libertas/debugfs.c b/drivers/net/wireless/libertas/debugfs.c
5416 +index 668dd27616a0..cc6a0a586f0b 100644
5417 +--- a/drivers/net/wireless/libertas/debugfs.c
5418 ++++ b/drivers/net/wireless/libertas/debugfs.c
5419 +@@ -913,7 +913,10 @@ static ssize_t lbs_debugfs_write(struct file *f, const char __user *buf,
5420 + char *p2;
5421 + struct debug_data *d = f->private_data;
5422 +
5423 +- pdata = kmalloc(cnt, GFP_KERNEL);
5424 ++ if (cnt == 0)
5425 ++ return 0;
5426 ++
5427 ++ pdata = kmalloc(cnt + 1, GFP_KERNEL);
5428 + if (pdata == NULL)
5429 + return 0;
5430 +
5431 +@@ -922,6 +925,7 @@ static ssize_t lbs_debugfs_write(struct file *f, const char __user *buf,
5432 + kfree(pdata);
5433 + return 0;
5434 + }
5435 ++ pdata[cnt] = '\0';
5436 +
5437 + p0 = pdata;
5438 + for (i = 0; i < num_of_items; i++) {
5439 +diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
5440 +index 88ce656f96cd..14007870302b 100644
5441 +--- a/drivers/net/wireless/rt2x00/rt2800lib.c
5442 ++++ b/drivers/net/wireless/rt2x00/rt2800lib.c
5443 +@@ -4461,10 +4461,13 @@ void rt2800_link_tuner(struct rt2x00_dev *rt2x00dev, struct link_qual *qual,
5444 +
5445 + vgc = rt2800_get_default_vgc(rt2x00dev);
5446 +
5447 +- if (rt2x00_rt(rt2x00dev, RT5592) && qual->rssi > -65)
5448 +- vgc += 0x20;
5449 +- else if (qual->rssi > -80)
5450 +- vgc += 0x10;
5451 ++ if (rt2x00_rt(rt2x00dev, RT5592)) {
5452 ++ if (qual->rssi > -65)
5453 ++ vgc += 0x20;
5454 ++ } else {
5455 ++ if (qual->rssi > -80)
5456 ++ vgc += 0x10;
5457 ++ }
5458 +
5459 + rt2800_set_vgc(rt2x00dev, qual, vgc);
5460 + }
5461 +diff --git a/drivers/net/wireless/rt2x00/rt2800usb.c b/drivers/net/wireless/rt2x00/rt2800usb.c
5462 +index 96961b9a395c..4feb35aef990 100644
5463 +--- a/drivers/net/wireless/rt2x00/rt2800usb.c
5464 ++++ b/drivers/net/wireless/rt2x00/rt2800usb.c
5465 +@@ -148,6 +148,8 @@ static bool rt2800usb_txstatus_timeout(struct rt2x00_dev *rt2x00dev)
5466 + return false;
5467 + }
5468 +
5469 ++#define TXSTATUS_READ_INTERVAL 1000000
5470 ++
5471 + static bool rt2800usb_tx_sta_fifo_read_completed(struct rt2x00_dev *rt2x00dev,
5472 + int urb_status, u32 tx_status)
5473 + {
5474 +@@ -176,8 +178,9 @@ static bool rt2800usb_tx_sta_fifo_read_completed(struct rt2x00_dev *rt2x00dev,
5475 + queue_work(rt2x00dev->workqueue, &rt2x00dev->txdone_work);
5476 +
5477 + if (rt2800usb_txstatus_pending(rt2x00dev)) {
5478 +- /* Read register after 250 us */
5479 +- hrtimer_start(&rt2x00dev->txstatus_timer, ktime_set(0, 250000),
5480 ++ /* Read register after 1 ms */
5481 ++ hrtimer_start(&rt2x00dev->txstatus_timer,
5482 ++ ktime_set(0, TXSTATUS_READ_INTERVAL),
5483 + HRTIMER_MODE_REL);
5484 + return false;
5485 + }
5486 +@@ -202,8 +205,9 @@ static void rt2800usb_async_read_tx_status(struct rt2x00_dev *rt2x00dev)
5487 + if (test_and_set_bit(TX_STATUS_READING, &rt2x00dev->flags))
5488 + return;
5489 +
5490 +- /* Read TX_STA_FIFO register after 500 us */
5491 +- hrtimer_start(&rt2x00dev->txstatus_timer, ktime_set(0, 500000),
5492 ++ /* Read TX_STA_FIFO register after 2 ms */
5493 ++ hrtimer_start(&rt2x00dev->txstatus_timer,
5494 ++ ktime_set(0, 2*TXSTATUS_READ_INTERVAL),
5495 + HRTIMER_MODE_REL);
5496 + }
5497 +
5498 +diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c b/drivers/net/wireless/rt2x00/rt2x00dev.c
5499 +index 712eea9d398f..f12e909cbb48 100644
5500 +--- a/drivers/net/wireless/rt2x00/rt2x00dev.c
5501 ++++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
5502 +@@ -181,6 +181,7 @@ static void rt2x00lib_autowakeup(struct work_struct *work)
5503 + static void rt2x00lib_bc_buffer_iter(void *data, u8 *mac,
5504 + struct ieee80211_vif *vif)
5505 + {
5506 ++ struct ieee80211_tx_control control = {};
5507 + struct rt2x00_dev *rt2x00dev = data;
5508 + struct sk_buff *skb;
5509 +
5510 +@@ -195,7 +196,7 @@ static void rt2x00lib_bc_buffer_iter(void *data, u8 *mac,
5511 + */
5512 + skb = ieee80211_get_buffered_bc(rt2x00dev->hw, vif);
5513 + while (skb) {
5514 +- rt2x00mac_tx(rt2x00dev->hw, NULL, skb);
5515 ++ rt2x00mac_tx(rt2x00dev->hw, &control, skb);
5516 + skb = ieee80211_get_buffered_bc(rt2x00dev->hw, vif);
5517 + }
5518 + }
5519 +diff --git a/drivers/net/wireless/rt2x00/rt2x00lib.h b/drivers/net/wireless/rt2x00/rt2x00lib.h
5520 +index a0935987fa3a..7f40ab8e1bd8 100644
5521 +--- a/drivers/net/wireless/rt2x00/rt2x00lib.h
5522 ++++ b/drivers/net/wireless/rt2x00/rt2x00lib.h
5523 +@@ -146,7 +146,7 @@ void rt2x00queue_remove_l2pad(struct sk_buff *skb, unsigned int header_length);
5524 + * @local: frame is not from mac80211
5525 + */
5526 + int rt2x00queue_write_tx_frame(struct data_queue *queue, struct sk_buff *skb,
5527 +- bool local);
5528 ++ struct ieee80211_sta *sta, bool local);
5529 +
5530 + /**
5531 + * rt2x00queue_update_beacon - Send new beacon from mac80211
5532 +diff --git a/drivers/net/wireless/rt2x00/rt2x00mac.c b/drivers/net/wireless/rt2x00/rt2x00mac.c
5533 +index f883802f3505..f8cff1f0b6b7 100644
5534 +--- a/drivers/net/wireless/rt2x00/rt2x00mac.c
5535 ++++ b/drivers/net/wireless/rt2x00/rt2x00mac.c
5536 +@@ -90,7 +90,7 @@ static int rt2x00mac_tx_rts_cts(struct rt2x00_dev *rt2x00dev,
5537 + frag_skb->data, data_length, tx_info,
5538 + (struct ieee80211_rts *)(skb->data));
5539 +
5540 +- retval = rt2x00queue_write_tx_frame(queue, skb, true);
5541 ++ retval = rt2x00queue_write_tx_frame(queue, skb, NULL, true);
5542 + if (retval) {
5543 + dev_kfree_skb_any(skb);
5544 + rt2x00_warn(rt2x00dev, "Failed to send RTS/CTS frame\n");
5545 +@@ -151,7 +151,7 @@ void rt2x00mac_tx(struct ieee80211_hw *hw,
5546 + goto exit_fail;
5547 + }
5548 +
5549 +- if (unlikely(rt2x00queue_write_tx_frame(queue, skb, false)))
5550 ++ if (unlikely(rt2x00queue_write_tx_frame(queue, skb, control->sta, false)))
5551 + goto exit_fail;
5552 +
5553 + /*
5554 +@@ -754,6 +754,9 @@ void rt2x00mac_flush(struct ieee80211_hw *hw, u32 queues, bool drop)
5555 + struct rt2x00_dev *rt2x00dev = hw->priv;
5556 + struct data_queue *queue;
5557 +
5558 ++ if (!test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags))
5559 ++ return;
5560 ++
5561 + tx_queue_for_each(rt2x00dev, queue)
5562 + rt2x00queue_flush_queue(queue, drop);
5563 + }
5564 +diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
5565 +index 6c8a33b6ee22..66a2db8c260d 100644
5566 +--- a/drivers/net/wireless/rt2x00/rt2x00queue.c
5567 ++++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
5568 +@@ -635,7 +635,7 @@ static void rt2x00queue_bar_check(struct queue_entry *entry)
5569 + }
5570 +
5571 + int rt2x00queue_write_tx_frame(struct data_queue *queue, struct sk_buff *skb,
5572 +- bool local)
5573 ++ struct ieee80211_sta *sta, bool local)
5574 + {
5575 + struct ieee80211_tx_info *tx_info;
5576 + struct queue_entry *entry;
5577 +@@ -649,7 +649,7 @@ int rt2x00queue_write_tx_frame(struct data_queue *queue, struct sk_buff *skb,
5578 + * after that we are free to use the skb->cb array
5579 + * for our information.
5580 + */
5581 +- rt2x00queue_create_tx_descriptor(queue->rt2x00dev, skb, &txdesc, NULL);
5582 ++ rt2x00queue_create_tx_descriptor(queue->rt2x00dev, skb, &txdesc, sta);
5583 +
5584 + /*
5585 + * All information is retrieved from the skb->cb array,
5586 +diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
5587 +index 03ca6c139f1a..4e86e9767ba6 100644
5588 +--- a/drivers/platform/x86/thinkpad_acpi.c
5589 ++++ b/drivers/platform/x86/thinkpad_acpi.c
5590 +@@ -6420,7 +6420,12 @@ static struct ibm_struct brightness_driver_data = {
5591 + #define TPACPI_ALSA_SHRTNAME "ThinkPad Console Audio Control"
5592 + #define TPACPI_ALSA_MIXERNAME TPACPI_ALSA_SHRTNAME
5593 +
5594 +-static int alsa_index = ~((1 << (SNDRV_CARDS - 3)) - 1); /* last three slots */
5595 ++#if SNDRV_CARDS <= 32
5596 ++#define DEFAULT_ALSA_IDX ~((1 << (SNDRV_CARDS - 3)) - 1)
5597 ++#else
5598 ++#define DEFAULT_ALSA_IDX ~((1 << (32 - 3)) - 1)
5599 ++#endif
5600 ++static int alsa_index = DEFAULT_ALSA_IDX; /* last three slots */
5601 + static char *alsa_id = "ThinkPadEC";
5602 + static bool alsa_enable = SNDRV_DEFAULT_ENABLE1;
5603 +
5604 +diff --git a/drivers/scsi/aacraid/commctrl.c b/drivers/scsi/aacraid/commctrl.c
5605 +index d85ac1a9d2c0..fbcd48d0bfc3 100644
5606 +--- a/drivers/scsi/aacraid/commctrl.c
5607 ++++ b/drivers/scsi/aacraid/commctrl.c
5608 +@@ -511,7 +511,8 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
5609 + goto cleanup;
5610 + }
5611 +
5612 +- if (fibsize > (dev->max_fib_size - sizeof(struct aac_fibhdr))) {
5613 ++ if ((fibsize < (sizeof(struct user_aac_srb) - sizeof(struct user_sgentry))) ||
5614 ++ (fibsize > (dev->max_fib_size - sizeof(struct aac_fibhdr)))) {
5615 + rcode = -EINVAL;
5616 + goto cleanup;
5617 + }
5618 +diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c
5619 +index 8e76ddca0999..5a5e9c915c25 100644
5620 +--- a/drivers/staging/android/ashmem.c
5621 ++++ b/drivers/staging/android/ashmem.c
5622 +@@ -706,7 +706,7 @@ static long ashmem_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
5623 + .gfp_mask = GFP_KERNEL,
5624 + .nr_to_scan = LONG_MAX,
5625 + };
5626 +-
5627 ++ ret = ashmem_shrink_count(&ashmem_shrinker, &sc);
5628 + nodes_setall(sc.nodes_to_scan);
5629 + ashmem_shrink_scan(&ashmem_shrinker, &sc);
5630 + }
5631 +diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c
5632 +index 1636c7ca57e2..a3af4699eb4d 100644
5633 +--- a/drivers/staging/comedi/comedi_fops.c
5634 ++++ b/drivers/staging/comedi/comedi_fops.c
5635 +@@ -543,7 +543,7 @@ void *comedi_alloc_spriv(struct comedi_subdevice *s, size_t size)
5636 + {
5637 + s->private = kzalloc(size, GFP_KERNEL);
5638 + if (s->private)
5639 +- comedi_set_subdevice_runflags(s, ~0, SRF_FREE_SPRIV);
5640 ++ s->runflags |= SRF_FREE_SPRIV;
5641 + return s->private;
5642 + }
5643 + EXPORT_SYMBOL_GPL(comedi_alloc_spriv);
5644 +@@ -1485,7 +1485,8 @@ static int do_cmd_ioctl(struct comedi_device *dev,
5645 + if (async->cmd.flags & TRIG_WAKE_EOS)
5646 + async->cb_mask |= COMEDI_CB_EOS;
5647 +
5648 +- comedi_set_subdevice_runflags(s, ~0, SRF_USER | SRF_RUNNING);
5649 ++ comedi_set_subdevice_runflags(s, SRF_USER | SRF_ERROR | SRF_RUNNING,
5650 ++ SRF_USER | SRF_RUNNING);
5651 +
5652 + /* set s->busy _after_ setting SRF_RUNNING flag to avoid race with
5653 + * comedi_read() or comedi_write() */
5654 +diff --git a/drivers/staging/rtl8188eu/os_dep/os_intfs.c b/drivers/staging/rtl8188eu/os_dep/os_intfs.c
5655 +index 63bc913eba6d..8b2b4a8d1f08 100644
5656 +--- a/drivers/staging/rtl8188eu/os_dep/os_intfs.c
5657 ++++ b/drivers/staging/rtl8188eu/os_dep/os_intfs.c
5658 +@@ -707,6 +707,10 @@ int rtw_init_netdev_name(struct net_device *pnetdev, const char *ifname)
5659 + return 0;
5660 + }
5661 +
5662 ++static const struct device_type wlan_type = {
5663 ++ .name = "wlan",
5664 ++};
5665 ++
5666 + struct net_device *rtw_init_netdev(struct adapter *old_padapter)
5667 + {
5668 + struct adapter *padapter;
5669 +@@ -722,6 +726,7 @@ struct net_device *rtw_init_netdev(struct adapter *old_padapter)
5670 + if (!pnetdev)
5671 + return NULL;
5672 +
5673 ++ pnetdev->dev.type = &wlan_type;
5674 + padapter = rtw_netdev_priv(pnetdev);
5675 + padapter->pnetdev = pnetdev;
5676 + DBG_88E("register rtw_netdev_ops to netdev_ops\n");
5677 +diff --git a/drivers/staging/zram/zram_drv.c b/drivers/staging/zram/zram_drv.c
5678 +index 2c4ed52ca849..012ba15ec490 100644
5679 +--- a/drivers/staging/zram/zram_drv.c
5680 ++++ b/drivers/staging/zram/zram_drv.c
5681 +@@ -648,6 +648,9 @@ static ssize_t reset_store(struct device *dev,
5682 + zram = dev_to_zram(dev);
5683 + bdev = bdget_disk(zram->disk, 0);
5684 +
5685 ++ if (!bdev)
5686 ++ return -ENOMEM;
5687 ++
5688 + /* Do not reset an active device! */
5689 + if (bdev->bd_holders)
5690 + return -EBUSY;
5691 +@@ -660,8 +663,7 @@ static ssize_t reset_store(struct device *dev,
5692 + return -EINVAL;
5693 +
5694 + /* Make sure all pending I/O is finished */
5695 +- if (bdev)
5696 +- fsync_bdev(bdev);
5697 ++ fsync_bdev(bdev);
5698 +
5699 + zram_reset_device(zram, true);
5700 + return len;
5701 +diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
5702 +index f7841d44feda..689433cdef25 100644
5703 +--- a/drivers/usb/core/driver.c
5704 ++++ b/drivers/usb/core/driver.c
5705 +@@ -1790,6 +1790,9 @@ int usb_set_usb2_hardware_lpm(struct usb_device *udev, int enable)
5706 + struct usb_hcd *hcd = bus_to_hcd(udev->bus);
5707 + int ret = -EPERM;
5708 +
5709 ++ if (enable && !udev->usb2_hw_lpm_allowed)
5710 ++ return 0;
5711 ++
5712 + if (hcd->driver->set_usb2_hw_lpm) {
5713 + ret = hcd->driver->set_usb2_hw_lpm(hcd, udev, enable);
5714 + if (!ret)
5715 +diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
5716 +index 879651cb6b45..243c6729c320 100644
5717 +--- a/drivers/usb/core/hub.c
5718 ++++ b/drivers/usb/core/hub.c
5719 +@@ -1135,6 +1135,11 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type)
5720 + usb_clear_port_feature(hub->hdev, port1,
5721 + USB_PORT_FEAT_C_ENABLE);
5722 + }
5723 ++ if (portchange & USB_PORT_STAT_C_RESET) {
5724 ++ need_debounce_delay = true;
5725 ++ usb_clear_port_feature(hub->hdev, port1,
5726 ++ USB_PORT_FEAT_C_RESET);
5727 ++ }
5728 + if ((portchange & USB_PORT_STAT_C_BH_RESET) &&
5729 + hub_is_superspeed(hub->hdev)) {
5730 + need_debounce_delay = true;
5731 +@@ -3954,6 +3959,32 @@ static int hub_set_address(struct usb_device *udev, int devnum)
5732 + return retval;
5733 + }
5734 +
5735 ++/*
5736 ++ * There are reports of USB 3.0 devices that say they support USB 2.0 Link PM
5737 ++ * when they're plugged into a USB 2.0 port, but they don't work when LPM is
5738 ++ * enabled.
5739 ++ *
5740 ++ * Only enable USB 2.0 Link PM if the port is internal (hardwired), or the
5741 ++ * device says it supports the new USB 2.0 Link PM errata by setting the BESL
5742 ++ * support bit in the BOS descriptor.
5743 ++ */
5744 ++static void hub_set_initial_usb2_lpm_policy(struct usb_device *udev)
5745 ++{
5746 ++ int connect_type;
5747 ++
5748 ++ if (!udev->usb2_hw_lpm_capable)
5749 ++ return;
5750 ++
5751 ++ connect_type = usb_get_hub_port_connect_type(udev->parent,
5752 ++ udev->portnum);
5753 ++
5754 ++ if ((udev->bos->ext_cap->bmAttributes & USB_BESL_SUPPORT) ||
5755 ++ connect_type == USB_PORT_CONNECT_TYPE_HARD_WIRED) {
5756 ++ udev->usb2_hw_lpm_allowed = 1;
5757 ++ usb_set_usb2_hardware_lpm(udev, 1);
5758 ++ }
5759 ++}
5760 ++
5761 + /* Reset device, (re)assign address, get device descriptor.
5762 + * Device connection must be stable, no more debouncing needed.
5763 + * Returns device in USB_STATE_ADDRESS, except on error.
5764 +@@ -4247,6 +4278,7 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
5765 + /* notify HCD that we have a device connected and addressed */
5766 + if (hcd->driver->update_device)
5767 + hcd->driver->update_device(hcd, udev);
5768 ++ hub_set_initial_usb2_lpm_policy(udev);
5769 + fail:
5770 + if (retval) {
5771 + hub_port_disable(hub, port1, 0);
5772 +@@ -5091,6 +5123,12 @@ static int usb_reset_and_verify_device(struct usb_device *udev)
5773 + }
5774 + parent_hub = usb_hub_to_struct_hub(parent_hdev);
5775 +
5776 ++ /* Disable USB2 hardware LPM.
5777 ++ * It will be re-enabled by the enumeration process.
5778 ++ */
5779 ++ if (udev->usb2_hw_lpm_enabled == 1)
5780 ++ usb_set_usb2_hardware_lpm(udev, 0);
5781 ++
5782 + bos = udev->bos;
5783 + udev->bos = NULL;
5784 +
5785 +@@ -5198,6 +5236,7 @@ static int usb_reset_and_verify_device(struct usb_device *udev)
5786 +
5787 + done:
5788 + /* Now that the alt settings are re-installed, enable LTM and LPM. */
5789 ++ usb_set_usb2_hardware_lpm(udev, 1);
5790 + usb_unlocked_enable_lpm(udev);
5791 + usb_enable_ltm(udev);
5792 + usb_release_bos_descriptor(udev);
5793 +diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
5794 +index 6d2c8edb1ffe..ca516ac0f234 100644
5795 +--- a/drivers/usb/core/sysfs.c
5796 ++++ b/drivers/usb/core/sysfs.c
5797 +@@ -449,7 +449,7 @@ static ssize_t usb2_hardware_lpm_show(struct device *dev,
5798 + struct usb_device *udev = to_usb_device(dev);
5799 + const char *p;
5800 +
5801 +- if (udev->usb2_hw_lpm_enabled == 1)
5802 ++ if (udev->usb2_hw_lpm_allowed == 1)
5803 + p = "enabled";
5804 + else
5805 + p = "disabled";
5806 +@@ -469,8 +469,10 @@ static ssize_t usb2_hardware_lpm_store(struct device *dev,
5807 +
5808 + ret = strtobool(buf, &value);
5809 +
5810 +- if (!ret)
5811 ++ if (!ret) {
5812 ++ udev->usb2_hw_lpm_allowed = value;
5813 + ret = usb_set_usb2_hardware_lpm(udev, value);
5814 ++ }
5815 +
5816 + usb_unlock_device(udev);
5817 +
5818 +diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
5819 +index 83bcd13622c3..49b8bd063fab 100644
5820 +--- a/drivers/usb/host/xhci-mem.c
5821 ++++ b/drivers/usb/host/xhci-mem.c
5822 +@@ -1693,9 +1693,7 @@ void xhci_free_command(struct xhci_hcd *xhci,
5823 + void xhci_mem_cleanup(struct xhci_hcd *xhci)
5824 + {
5825 + struct pci_dev *pdev = to_pci_dev(xhci_to_hcd(xhci)->self.controller);
5826 +- struct dev_info *dev_info, *next;
5827 + struct xhci_cd *cur_cd, *next_cd;
5828 +- unsigned long flags;
5829 + int size;
5830 + int i, j, num_ports;
5831 +
5832 +@@ -1756,13 +1754,6 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci)
5833 +
5834 + scratchpad_free(xhci);
5835 +
5836 +- spin_lock_irqsave(&xhci->lock, flags);
5837 +- list_for_each_entry_safe(dev_info, next, &xhci->lpm_failed_devs, list) {
5838 +- list_del(&dev_info->list);
5839 +- kfree(dev_info);
5840 +- }
5841 +- spin_unlock_irqrestore(&xhci->lock, flags);
5842 +-
5843 + if (!xhci->rh_bw)
5844 + goto no_bw;
5845 +
5846 +@@ -2231,7 +2222,6 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
5847 + u32 page_size, temp;
5848 + int i;
5849 +
5850 +- INIT_LIST_HEAD(&xhci->lpm_failed_devs);
5851 + INIT_LIST_HEAD(&xhci->cancel_cmd_list);
5852 +
5853 + page_size = xhci_readl(xhci, &xhci->op_regs->page_size);
5854 +diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
5855 +index 6e0d886bcce5..ed6c186a5393 100644
5856 +--- a/drivers/usb/host/xhci.c
5857 ++++ b/drivers/usb/host/xhci.c
5858 +@@ -4025,133 +4025,6 @@ static int xhci_calculate_usb2_hw_lpm_params(struct usb_device *udev)
5859 + return PORT_BESLD(besld) | PORT_L1_TIMEOUT(l1) | PORT_HIRDM(hirdm);
5860 + }
5861 +
5862 +-static int xhci_usb2_software_lpm_test(struct usb_hcd *hcd,
5863 +- struct usb_device *udev)
5864 +-{
5865 +- struct xhci_hcd *xhci = hcd_to_xhci(hcd);
5866 +- struct dev_info *dev_info;
5867 +- __le32 __iomem **port_array;
5868 +- __le32 __iomem *addr, *pm_addr;
5869 +- u32 temp, dev_id;
5870 +- unsigned int port_num;
5871 +- unsigned long flags;
5872 +- int hird;
5873 +- int ret;
5874 +-
5875 +- if (hcd->speed == HCD_USB3 || !xhci->sw_lpm_support ||
5876 +- !udev->lpm_capable)
5877 +- return -EINVAL;
5878 +-
5879 +- /* we only support lpm for non-hub device connected to root hub yet */
5880 +- if (!udev->parent || udev->parent->parent ||
5881 +- udev->descriptor.bDeviceClass == USB_CLASS_HUB)
5882 +- return -EINVAL;
5883 +-
5884 +- spin_lock_irqsave(&xhci->lock, flags);
5885 +-
5886 +- /* Look for devices in lpm_failed_devs list */
5887 +- dev_id = le16_to_cpu(udev->descriptor.idVendor) << 16 |
5888 +- le16_to_cpu(udev->descriptor.idProduct);
5889 +- list_for_each_entry(dev_info, &xhci->lpm_failed_devs, list) {
5890 +- if (dev_info->dev_id == dev_id) {
5891 +- ret = -EINVAL;
5892 +- goto finish;
5893 +- }
5894 +- }
5895 +-
5896 +- port_array = xhci->usb2_ports;
5897 +- port_num = udev->portnum - 1;
5898 +-
5899 +- if (port_num > HCS_MAX_PORTS(xhci->hcs_params1)) {
5900 +- xhci_dbg(xhci, "invalid port number %d\n", udev->portnum);
5901 +- ret = -EINVAL;
5902 +- goto finish;
5903 +- }
5904 +-
5905 +- /*
5906 +- * Test USB 2.0 software LPM.
5907 +- * FIXME: some xHCI 1.0 hosts may implement a new register to set up
5908 +- * hardware-controlled USB 2.0 LPM. See section 5.4.11 and 4.23.5.1.1.1
5909 +- * in the June 2011 errata release.
5910 +- */
5911 +- xhci_dbg(xhci, "test port %d software LPM\n", port_num);
5912 +- /*
5913 +- * Set L1 Device Slot and HIRD/BESL.
5914 +- * Check device's USB 2.0 extension descriptor to determine whether
5915 +- * HIRD or BESL shoule be used. See USB2.0 LPM errata.
5916 +- */
5917 +- pm_addr = port_array[port_num] + PORTPMSC;
5918 +- hird = xhci_calculate_hird_besl(xhci, udev);
5919 +- temp = PORT_L1DS(udev->slot_id) | PORT_HIRD(hird);
5920 +- xhci_writel(xhci, temp, pm_addr);
5921 +-
5922 +- /* Set port link state to U2(L1) */
5923 +- addr = port_array[port_num];
5924 +- xhci_set_link_state(xhci, port_array, port_num, XDEV_U2);
5925 +-
5926 +- /* wait for ACK */
5927 +- spin_unlock_irqrestore(&xhci->lock, flags);
5928 +- msleep(10);
5929 +- spin_lock_irqsave(&xhci->lock, flags);
5930 +-
5931 +- /* Check L1 Status */
5932 +- ret = xhci_handshake(xhci, pm_addr,
5933 +- PORT_L1S_MASK, PORT_L1S_SUCCESS, 125);
5934 +- if (ret != -ETIMEDOUT) {
5935 +- /* enter L1 successfully */
5936 +- temp = xhci_readl(xhci, addr);
5937 +- xhci_dbg(xhci, "port %d entered L1 state, port status 0x%x\n",
5938 +- port_num, temp);
5939 +- ret = 0;
5940 +- } else {
5941 +- temp = xhci_readl(xhci, pm_addr);
5942 +- xhci_dbg(xhci, "port %d software lpm failed, L1 status %d\n",
5943 +- port_num, temp & PORT_L1S_MASK);
5944 +- ret = -EINVAL;
5945 +- }
5946 +-
5947 +- /* Resume the port */
5948 +- xhci_set_link_state(xhci, port_array, port_num, XDEV_U0);
5949 +-
5950 +- spin_unlock_irqrestore(&xhci->lock, flags);
5951 +- msleep(10);
5952 +- spin_lock_irqsave(&xhci->lock, flags);
5953 +-
5954 +- /* Clear PLC */
5955 +- xhci_test_and_clear_bit(xhci, port_array, port_num, PORT_PLC);
5956 +-
5957 +- /* Check PORTSC to make sure the device is in the right state */
5958 +- if (!ret) {
5959 +- temp = xhci_readl(xhci, addr);
5960 +- xhci_dbg(xhci, "resumed port %d status 0x%x\n", port_num, temp);
5961 +- if (!(temp & PORT_CONNECT) || !(temp & PORT_PE) ||
5962 +- (temp & PORT_PLS_MASK) != XDEV_U0) {
5963 +- xhci_dbg(xhci, "port L1 resume fail\n");
5964 +- ret = -EINVAL;
5965 +- }
5966 +- }
5967 +-
5968 +- if (ret) {
5969 +- /* Insert dev to lpm_failed_devs list */
5970 +- xhci_warn(xhci, "device LPM test failed, may disconnect and "
5971 +- "re-enumerate\n");
5972 +- dev_info = kzalloc(sizeof(struct dev_info), GFP_ATOMIC);
5973 +- if (!dev_info) {
5974 +- ret = -ENOMEM;
5975 +- goto finish;
5976 +- }
5977 +- dev_info->dev_id = dev_id;
5978 +- INIT_LIST_HEAD(&dev_info->list);
5979 +- list_add(&dev_info->list, &xhci->lpm_failed_devs);
5980 +- } else {
5981 +- xhci_ring_device(xhci, udev->slot_id);
5982 +- }
5983 +-
5984 +-finish:
5985 +- spin_unlock_irqrestore(&xhci->lock, flags);
5986 +- return ret;
5987 +-}
5988 +-
5989 + int xhci_set_usb2_hardware_lpm(struct usb_hcd *hcd,
5990 + struct usb_device *udev, int enable)
5991 + {
5992 +@@ -4228,7 +4101,7 @@ int xhci_set_usb2_hardware_lpm(struct usb_hcd *hcd,
5993 + }
5994 +
5995 + pm_val &= ~PORT_HIRD_MASK;
5996 +- pm_val |= PORT_HIRD(hird) | PORT_RWE;
5997 ++ pm_val |= PORT_HIRD(hird) | PORT_RWE | PORT_L1DS(udev->slot_id);
5998 + xhci_writel(xhci, pm_val, pm_addr);
5999 + pm_val = xhci_readl(xhci, pm_addr);
6000 + pm_val |= PORT_HLE;
6001 +@@ -4236,7 +4109,7 @@ int xhci_set_usb2_hardware_lpm(struct usb_hcd *hcd,
6002 + /* flush write */
6003 + xhci_readl(xhci, pm_addr);
6004 + } else {
6005 +- pm_val &= ~(PORT_HLE | PORT_RWE | PORT_HIRD_MASK);
6006 ++ pm_val &= ~(PORT_HLE | PORT_RWE | PORT_HIRD_MASK | PORT_L1DS_MASK);
6007 + xhci_writel(xhci, pm_val, pm_addr);
6008 + /* flush write */
6009 + xhci_readl(xhci, pm_addr);
6010 +@@ -4279,24 +4152,26 @@ static int xhci_check_usb2_port_capability(struct xhci_hcd *xhci, int port,
6011 + int xhci_update_device(struct usb_hcd *hcd, struct usb_device *udev)
6012 + {
6013 + struct xhci_hcd *xhci = hcd_to_xhci(hcd);
6014 +- int ret;
6015 + int portnum = udev->portnum - 1;
6016 +
6017 +- ret = xhci_usb2_software_lpm_test(hcd, udev);
6018 +- if (!ret) {
6019 +- xhci_dbg(xhci, "software LPM test succeed\n");
6020 +- if (xhci->hw_lpm_support == 1 &&
6021 +- xhci_check_usb2_port_capability(xhci, portnum, XHCI_HLC)) {
6022 +- udev->usb2_hw_lpm_capable = 1;
6023 +- udev->l1_params.timeout = XHCI_L1_TIMEOUT;
6024 +- udev->l1_params.besl = XHCI_DEFAULT_BESL;
6025 +- if (xhci_check_usb2_port_capability(xhci, portnum,
6026 +- XHCI_BLC))
6027 +- udev->usb2_hw_lpm_besl_capable = 1;
6028 +- ret = xhci_set_usb2_hardware_lpm(hcd, udev, 1);
6029 +- if (!ret)
6030 +- udev->usb2_hw_lpm_enabled = 1;
6031 +- }
6032 ++ if (hcd->speed == HCD_USB3 || !xhci->sw_lpm_support ||
6033 ++ !udev->lpm_capable)
6034 ++ return 0;
6035 ++
6036 ++ /* we only support lpm for non-hub device connected to root hub yet */
6037 ++ if (!udev->parent || udev->parent->parent ||
6038 ++ udev->descriptor.bDeviceClass == USB_CLASS_HUB)
6039 ++ return 0;
6040 ++
6041 ++ if (xhci->hw_lpm_support == 1 &&
6042 ++ xhci_check_usb2_port_capability(
6043 ++ xhci, portnum, XHCI_HLC)) {
6044 ++ udev->usb2_hw_lpm_capable = 1;
6045 ++ udev->l1_params.timeout = XHCI_L1_TIMEOUT;
6046 ++ udev->l1_params.besl = XHCI_DEFAULT_BESL;
6047 ++ if (xhci_check_usb2_port_capability(xhci, portnum,
6048 ++ XHCI_BLC))
6049 ++ udev->usb2_hw_lpm_besl_capable = 1;
6050 + }
6051 +
6052 + return 0;
6053 +diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
6054 +index 941d5f59e4dc..ed3a425de8ce 100644
6055 +--- a/drivers/usb/host/xhci.h
6056 ++++ b/drivers/usb/host/xhci.h
6057 +@@ -383,6 +383,7 @@ struct xhci_op_regs {
6058 + #define PORT_RWE (1 << 3)
6059 + #define PORT_HIRD(p) (((p) & 0xf) << 4)
6060 + #define PORT_HIRD_MASK (0xf << 4)
6061 ++#define PORT_L1DS_MASK (0xff << 8)
6062 + #define PORT_L1DS(p) (((p) & 0xff) << 8)
6063 + #define PORT_HLE (1 << 16)
6064 +
6065 +diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
6066 +index cd70cc886171..0d0d11880968 100644
6067 +--- a/drivers/usb/musb/musb_core.c
6068 ++++ b/drivers/usb/musb/musb_core.c
6069 +@@ -1809,6 +1809,7 @@ static void musb_free(struct musb *musb)
6070 + disable_irq_wake(musb->nIrq);
6071 + free_irq(musb->nIrq, musb);
6072 + }
6073 ++ cancel_work_sync(&musb->irq_work);
6074 + if (musb->dma_controller)
6075 + dma_controller_destroy(musb->dma_controller);
6076 +
6077 +@@ -1946,6 +1947,8 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl)
6078 + if (status < 0)
6079 + goto fail3;
6080 + status = musb_gadget_setup(musb);
6081 ++ if (status)
6082 ++ musb_host_cleanup(musb);
6083 + break;
6084 + default:
6085 + dev_err(dev, "unsupported port mode %d\n", musb->port_mode);
6086 +@@ -1972,6 +1975,7 @@ fail5:
6087 +
6088 + fail4:
6089 + musb_gadget_cleanup(musb);
6090 ++ musb_host_cleanup(musb);
6091 +
6092 + fail3:
6093 + if (musb->dma_controller)
6094 +diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
6095 +index bd4138d80a48..1edee7906b73 100644
6096 +--- a/drivers/usb/musb/musb_dsps.c
6097 ++++ b/drivers/usb/musb/musb_dsps.c
6098 +@@ -121,6 +121,7 @@ struct dsps_glue {
6099 + unsigned long last_timer; /* last timer data for each instance */
6100 + };
6101 +
6102 ++static void dsps_musb_try_idle(struct musb *musb, unsigned long timeout);
6103 + /**
6104 + * dsps_musb_enable - enable interrupts
6105 + */
6106 +@@ -143,6 +144,7 @@ static void dsps_musb_enable(struct musb *musb)
6107 + /* Force the DRVVBUS IRQ so we can start polling for ID change. */
6108 + dsps_writel(reg_base, wrp->coreintr_set,
6109 + (1 << wrp->drvvbus) << wrp->usb_shift);
6110 ++ dsps_musb_try_idle(musb, 0);
6111 + }
6112 +
6113 + /**
6114 +@@ -171,6 +173,7 @@ static void otg_timer(unsigned long _musb)
6115 + const struct dsps_musb_wrapper *wrp = glue->wrp;
6116 + u8 devctl;
6117 + unsigned long flags;
6118 ++ int skip_session = 0;
6119 +
6120 + /*
6121 + * We poll because DSPS IP's won't expose several OTG-critical
6122 +@@ -183,10 +186,12 @@ static void otg_timer(unsigned long _musb)
6123 + spin_lock_irqsave(&musb->lock, flags);
6124 + switch (musb->xceiv->state) {
6125 + case OTG_STATE_A_WAIT_BCON:
6126 +- devctl &= ~MUSB_DEVCTL_SESSION;
6127 +- dsps_writeb(musb->mregs, MUSB_DEVCTL, devctl);
6128 ++ dsps_writeb(musb->mregs, MUSB_DEVCTL, 0);
6129 ++ skip_session = 1;
6130 ++ /* fall */
6131 +
6132 +- devctl = dsps_readb(musb->mregs, MUSB_DEVCTL);
6133 ++ case OTG_STATE_A_IDLE:
6134 ++ case OTG_STATE_B_IDLE:
6135 + if (devctl & MUSB_DEVCTL_BDEVICE) {
6136 + musb->xceiv->state = OTG_STATE_B_IDLE;
6137 + MUSB_DEV_MODE(musb);
6138 +@@ -194,20 +199,15 @@ static void otg_timer(unsigned long _musb)
6139 + musb->xceiv->state = OTG_STATE_A_IDLE;
6140 + MUSB_HST_MODE(musb);
6141 + }
6142 ++ if (!(devctl & MUSB_DEVCTL_SESSION) && !skip_session)
6143 ++ dsps_writeb(mregs, MUSB_DEVCTL, MUSB_DEVCTL_SESSION);
6144 ++ mod_timer(&glue->timer, jiffies + wrp->poll_seconds * HZ);
6145 + break;
6146 + case OTG_STATE_A_WAIT_VFALL:
6147 + musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
6148 + dsps_writel(musb->ctrl_base, wrp->coreintr_set,
6149 + MUSB_INTR_VBUSERROR << wrp->usb_shift);
6150 + break;
6151 +- case OTG_STATE_B_IDLE:
6152 +- devctl = dsps_readb(mregs, MUSB_DEVCTL);
6153 +- if (devctl & MUSB_DEVCTL_BDEVICE)
6154 +- mod_timer(&glue->timer,
6155 +- jiffies + wrp->poll_seconds * HZ);
6156 +- else
6157 +- musb->xceiv->state = OTG_STATE_A_IDLE;
6158 +- break;
6159 + default:
6160 + break;
6161 + }
6162 +@@ -234,6 +234,9 @@ static void dsps_musb_try_idle(struct musb *musb, unsigned long timeout)
6163 + if (musb->port_mode == MUSB_PORT_MODE_HOST)
6164 + return;
6165 +
6166 ++ if (!musb->g.dev.driver)
6167 ++ return;
6168 ++
6169 + if (time_after(glue->last_timer, timeout) &&
6170 + timer_pending(&glue->timer)) {
6171 + dev_dbg(musb->controller,
6172 +diff --git a/drivers/usb/musb/musb_virthub.c b/drivers/usb/musb/musb_virthub.c
6173 +index d1d6b83aabca..9af6bba5eac9 100644
6174 +--- a/drivers/usb/musb/musb_virthub.c
6175 ++++ b/drivers/usb/musb/musb_virthub.c
6176 +@@ -220,6 +220,23 @@ int musb_hub_status_data(struct usb_hcd *hcd, char *buf)
6177 + return retval;
6178 + }
6179 +
6180 ++static int musb_has_gadget(struct musb *musb)
6181 ++{
6182 ++ /*
6183 ++ * In host-only mode we start a connection right away. In OTG mode
6184 ++ * we have to wait until we loaded a gadget. We don't really need a
6185 ++ * gadget if we operate as a host but we should not start a session
6186 ++ * as a device without a gadget or else we explode.
6187 ++ */
6188 ++#ifdef CONFIG_USB_MUSB_HOST
6189 ++ return 1;
6190 ++#else
6191 ++ if (musb->port_mode == MUSB_PORT_MODE_HOST)
6192 ++ return 1;
6193 ++ return musb->g.dev.driver != NULL;
6194 ++#endif
6195 ++}
6196 ++
6197 + int musb_hub_control(
6198 + struct usb_hcd *hcd,
6199 + u16 typeReq,
6200 +@@ -362,7 +379,7 @@ int musb_hub_control(
6201 + * initialization logic, e.g. for OTG, or change any
6202 + * logic relating to VBUS power-up.
6203 + */
6204 +- if (!hcd->self.is_b_host)
6205 ++ if (!hcd->self.is_b_host && musb_has_gadget(musb))
6206 + musb_start(musb);
6207 + break;
6208 + case USB_PORT_FEAT_RESET:
6209 +diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
6210 +index fdf953539c62..e5bdd987b9e8 100644
6211 +--- a/drivers/usb/serial/mos7840.c
6212 ++++ b/drivers/usb/serial/mos7840.c
6213 +@@ -1532,7 +1532,11 @@ static int mos7840_tiocmget(struct tty_struct *tty)
6214 + return -ENODEV;
6215 +
6216 + status = mos7840_get_uart_reg(port, MODEM_STATUS_REGISTER, &msr);
6217 ++ if (status != 1)
6218 ++ return -EIO;
6219 + status = mos7840_get_uart_reg(port, MODEM_CONTROL_REGISTER, &mcr);
6220 ++ if (status != 1)
6221 ++ return -EIO;
6222 + result = ((mcr & MCR_DTR) ? TIOCM_DTR : 0)
6223 + | ((mcr & MCR_RTS) ? TIOCM_RTS : 0)
6224 + | ((mcr & MCR_LOOPBACK) ? TIOCM_LOOP : 0)
6225 +diff --git a/drivers/usb/wusbcore/wa-rpipe.c b/drivers/usb/wusbcore/wa-rpipe.c
6226 +index fd4f1ce6256a..b5e4fc19dec0 100644
6227 +--- a/drivers/usb/wusbcore/wa-rpipe.c
6228 ++++ b/drivers/usb/wusbcore/wa-rpipe.c
6229 +@@ -333,7 +333,10 @@ static int rpipe_aim(struct wa_rpipe *rpipe, struct wahc *wa,
6230 + /* FIXME: compute so seg_size > ep->maxpktsize */
6231 + rpipe->descr.wBlocks = cpu_to_le16(16); /* given */
6232 + /* ep0 maxpktsize is 0x200 (WUSB1.0[4.8.1]) */
6233 +- rpipe->descr.wMaxPacketSize = cpu_to_le16(ep->desc.wMaxPacketSize);
6234 ++ if (usb_endpoint_xfer_isoc(&ep->desc))
6235 ++ rpipe->descr.wMaxPacketSize = epcd->wOverTheAirPacketSize;
6236 ++ else
6237 ++ rpipe->descr.wMaxPacketSize = ep->desc.wMaxPacketSize;
6238 +
6239 + rpipe->descr.hwa_bMaxBurst = max(min_t(unsigned int,
6240 + epcd->bMaxBurst, 16U), 1U);
6241 +diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
6242 +index 4a355726151e..26450d850f14 100644
6243 +--- a/fs/btrfs/relocation.c
6244 ++++ b/fs/btrfs/relocation.c
6245 +@@ -4481,6 +4481,7 @@ int btrfs_reloc_clone_csums(struct inode *inode, u64 file_pos, u64 len)
6246 + struct btrfs_root *root = BTRFS_I(inode)->root;
6247 + int ret;
6248 + u64 disk_bytenr;
6249 ++ u64 new_bytenr;
6250 + LIST_HEAD(list);
6251 +
6252 + ordered = btrfs_lookup_ordered_extent(inode, file_pos);
6253 +@@ -4492,13 +4493,24 @@ int btrfs_reloc_clone_csums(struct inode *inode, u64 file_pos, u64 len)
6254 + if (ret)
6255 + goto out;
6256 +
6257 +- disk_bytenr = ordered->start;
6258 + while (!list_empty(&list)) {
6259 + sums = list_entry(list.next, struct btrfs_ordered_sum, list);
6260 + list_del_init(&sums->list);
6261 +
6262 +- sums->bytenr = disk_bytenr;
6263 +- disk_bytenr += sums->len;
6264 ++ /*
6265 ++ * We need to offset the new_bytenr based on where the csum is.
6266 ++ * We need to do this because we will read in entire prealloc
6267 ++ * extents but we may have written to say the middle of the
6268 ++ * prealloc extent, so we need to make sure the csum goes with
6269 ++ * the right disk offset.
6270 ++ *
6271 ++ * We can do this because the data reloc inode refers strictly
6272 ++ * to the on disk bytes, so we don't have to worry about
6273 ++ * disk_len vs real len like with real inodes since it's all
6274 ++ * disk length.
6275 ++ */
6276 ++ new_bytenr = ordered->start + (sums->bytenr - disk_bytenr);
6277 ++ sums->bytenr = new_bytenr;
6278 +
6279 + btrfs_add_ordered_sum(inode, ordered, sums);
6280 + }
6281 +diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
6282 +index 277bd1be21fd..511d41546791 100644
6283 +--- a/fs/configfs/dir.c
6284 ++++ b/fs/configfs/dir.c
6285 +@@ -56,10 +56,19 @@ static void configfs_d_iput(struct dentry * dentry,
6286 + struct configfs_dirent *sd = dentry->d_fsdata;
6287 +
6288 + if (sd) {
6289 +- BUG_ON(sd->s_dentry != dentry);
6290 + /* Coordinate with configfs_readdir */
6291 + spin_lock(&configfs_dirent_lock);
6292 +- sd->s_dentry = NULL;
6293 ++ /* Coordinate with configfs_attach_attr where will increase
6294 ++ * sd->s_count and update sd->s_dentry to new allocated one.
6295 ++ * Only set sd->dentry to null when this dentry is the only
6296 ++ * sd owner.
6297 ++ * If not do so, configfs_d_iput may run just after
6298 ++ * configfs_attach_attr and set sd->s_dentry to null
6299 ++ * even it's still in use.
6300 ++ */
6301 ++ if (atomic_read(&sd->s_count) <= 2)
6302 ++ sd->s_dentry = NULL;
6303 ++
6304 + spin_unlock(&configfs_dirent_lock);
6305 + configfs_put(sd);
6306 + }
6307 +@@ -426,8 +435,11 @@ static int configfs_attach_attr(struct configfs_dirent * sd, struct dentry * den
6308 + struct configfs_attribute * attr = sd->s_element;
6309 + int error;
6310 +
6311 ++ spin_lock(&configfs_dirent_lock);
6312 + dentry->d_fsdata = configfs_get(sd);
6313 + sd->s_dentry = dentry;
6314 ++ spin_unlock(&configfs_dirent_lock);
6315 ++
6316 + error = configfs_create(dentry, (attr->ca_mode & S_IALLUGO) | S_IFREG,
6317 + configfs_init_file);
6318 + if (error) {
6319 +diff --git a/fs/dcache.c b/fs/dcache.c
6320 +index ae6ebb88ceff..89f96719a29b 100644
6321 +--- a/fs/dcache.c
6322 ++++ b/fs/dcache.c
6323 +@@ -2881,9 +2881,9 @@ static int prepend_path(const struct path *path,
6324 + const struct path *root,
6325 + char **buffer, int *buflen)
6326 + {
6327 +- struct dentry *dentry = path->dentry;
6328 +- struct vfsmount *vfsmnt = path->mnt;
6329 +- struct mount *mnt = real_mount(vfsmnt);
6330 ++ struct dentry *dentry;
6331 ++ struct vfsmount *vfsmnt;
6332 ++ struct mount *mnt;
6333 + int error = 0;
6334 + unsigned seq = 0;
6335 + char *bptr;
6336 +@@ -2893,6 +2893,9 @@ static int prepend_path(const struct path *path,
6337 + restart:
6338 + bptr = *buffer;
6339 + blen = *buflen;
6340 ++ dentry = path->dentry;
6341 ++ vfsmnt = path->mnt;
6342 ++ mnt = real_mount(vfsmnt);
6343 + read_seqbegin_or_lock(&rename_lock, &seq);
6344 + while (dentry != root->dentry || vfsmnt != root->mnt) {
6345 + struct dentry * parent;
6346 +diff --git a/fs/exec.c b/fs/exec.c
6347 +index 8875dd10ae7a..bb8afc1d1df4 100644
6348 +--- a/fs/exec.c
6349 ++++ b/fs/exec.c
6350 +@@ -1668,6 +1668,12 @@ int __get_dumpable(unsigned long mm_flags)
6351 + return (ret > SUID_DUMP_USER) ? SUID_DUMP_ROOT : ret;
6352 + }
6353 +
6354 ++/*
6355 ++ * This returns the actual value of the suid_dumpable flag. For things
6356 ++ * that are using this for checking for privilege transitions, it must
6357 ++ * test against SUID_DUMP_USER rather than treating it as a boolean
6358 ++ * value.
6359 ++ */
6360 + int get_dumpable(struct mm_struct *mm)
6361 + {
6362 + return __get_dumpable(mm->flags);
6363 +diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
6364 +index ced3257f06e8..968d4c56e5eb 100644
6365 +--- a/fs/gfs2/inode.c
6366 ++++ b/fs/gfs2/inode.c
6367 +@@ -584,17 +584,17 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
6368 + if (!IS_ERR(inode)) {
6369 + d = d_splice_alias(inode, dentry);
6370 + error = 0;
6371 +- if (file && !IS_ERR(d)) {
6372 +- if (d == NULL)
6373 +- d = dentry;
6374 +- if (S_ISREG(inode->i_mode))
6375 +- error = finish_open(file, d, gfs2_open_common, opened);
6376 +- else
6377 ++ if (file) {
6378 ++ if (S_ISREG(inode->i_mode)) {
6379 ++ WARN_ON(d != NULL);
6380 ++ error = finish_open(file, dentry, gfs2_open_common, opened);
6381 ++ } else {
6382 + error = finish_no_open(file, d);
6383 ++ }
6384 ++ } else {
6385 ++ dput(d);
6386 + }
6387 + gfs2_glock_dq_uninit(ghs);
6388 +- if (IS_ERR(d))
6389 +- return PTR_ERR(d);
6390 + return error;
6391 + } else if (error != -ENOENT) {
6392 + goto fail_gunlock;
6393 +@@ -781,8 +781,10 @@ static struct dentry *__gfs2_lookup(struct inode *dir, struct dentry *dentry,
6394 + error = finish_open(file, dentry, gfs2_open_common, opened);
6395 +
6396 + gfs2_glock_dq_uninit(&gh);
6397 +- if (error)
6398 ++ if (error) {
6399 ++ dput(d);
6400 + return ERR_PTR(error);
6401 ++ }
6402 + return d;
6403 + }
6404 +
6405 +@@ -1163,14 +1165,16 @@ static int gfs2_atomic_open(struct inode *dir, struct dentry *dentry,
6406 + d = __gfs2_lookup(dir, dentry, file, opened);
6407 + if (IS_ERR(d))
6408 + return PTR_ERR(d);
6409 +- if (d == NULL)
6410 +- d = dentry;
6411 +- if (d->d_inode) {
6412 ++ if (d != NULL)
6413 ++ dentry = d;
6414 ++ if (dentry->d_inode) {
6415 + if (!(*opened & FILE_OPENED))
6416 +- return finish_no_open(file, d);
6417 ++ return finish_no_open(file, dentry);
6418 ++ dput(d);
6419 + return 0;
6420 + }
6421 +
6422 ++ BUG_ON(d != NULL);
6423 + if (!(flags & O_CREAT))
6424 + return -ENOENT;
6425 +
6426 +diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
6427 +index d53d6785cba2..3b115653d422 100644
6428 +--- a/fs/nfs/nfs4proc.c
6429 ++++ b/fs/nfs/nfs4proc.c
6430 +@@ -1318,21 +1318,14 @@ _nfs4_opendata_reclaim_to_nfs4_state(struct nfs4_opendata *data)
6431 + int ret;
6432 +
6433 + if (!data->rpc_done) {
6434 +- ret = data->rpc_status;
6435 +- goto err;
6436 ++ if (data->rpc_status) {
6437 ++ ret = data->rpc_status;
6438 ++ goto err;
6439 ++ }
6440 ++ /* cached opens have already been processed */
6441 ++ goto update;
6442 + }
6443 +
6444 +- ret = -ESTALE;
6445 +- if (!(data->f_attr.valid & NFS_ATTR_FATTR_TYPE) ||
6446 +- !(data->f_attr.valid & NFS_ATTR_FATTR_FILEID) ||
6447 +- !(data->f_attr.valid & NFS_ATTR_FATTR_CHANGE))
6448 +- goto err;
6449 +-
6450 +- ret = -ENOMEM;
6451 +- state = nfs4_get_open_state(inode, data->owner);
6452 +- if (state == NULL)
6453 +- goto err;
6454 +-
6455 + ret = nfs_refresh_inode(inode, &data->f_attr);
6456 + if (ret)
6457 + goto err;
6458 +@@ -1341,8 +1334,10 @@ _nfs4_opendata_reclaim_to_nfs4_state(struct nfs4_opendata *data)
6459 +
6460 + if (data->o_res.delegation_type != 0)
6461 + nfs4_opendata_check_deleg(data, state);
6462 ++update:
6463 + update_open_stateid(state, &data->o_res.stateid, NULL,
6464 + data->o_arg.fmode);
6465 ++ atomic_inc(&state->count);
6466 +
6467 + return state;
6468 + err:
6469 +@@ -4575,7 +4570,7 @@ static int _nfs4_get_security_label(struct inode *inode, void *buf,
6470 + struct nfs4_label label = {0, 0, buflen, buf};
6471 +
6472 + u32 bitmask[3] = { 0, 0, FATTR4_WORD2_SECURITY_LABEL };
6473 +- struct nfs4_getattr_arg args = {
6474 ++ struct nfs4_getattr_arg arg = {
6475 + .fh = NFS_FH(inode),
6476 + .bitmask = bitmask,
6477 + };
6478 +@@ -4586,14 +4581,14 @@ static int _nfs4_get_security_label(struct inode *inode, void *buf,
6479 + };
6480 + struct rpc_message msg = {
6481 + .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_GETATTR],
6482 +- .rpc_argp = &args,
6483 ++ .rpc_argp = &arg,
6484 + .rpc_resp = &res,
6485 + };
6486 + int ret;
6487 +
6488 + nfs_fattr_init(&fattr);
6489 +
6490 +- ret = rpc_call_sync(server->client, &msg, 0);
6491 ++ ret = nfs4_call_sync(server->client, server, &msg, &arg.seq_args, &res.seq_res, 0);
6492 + if (ret)
6493 + return ret;
6494 + if (!(fattr.valid & NFS_ATTR_FATTR_V4_SECURITY_LABEL))
6495 +@@ -4630,7 +4625,7 @@ static int _nfs4_do_set_security_label(struct inode *inode,
6496 + struct iattr sattr = {0};
6497 + struct nfs_server *server = NFS_SERVER(inode);
6498 + const u32 bitmask[3] = { 0, 0, FATTR4_WORD2_SECURITY_LABEL };
6499 +- struct nfs_setattrargs args = {
6500 ++ struct nfs_setattrargs arg = {
6501 + .fh = NFS_FH(inode),
6502 + .iap = &sattr,
6503 + .server = server,
6504 +@@ -4644,14 +4639,14 @@ static int _nfs4_do_set_security_label(struct inode *inode,
6505 + };
6506 + struct rpc_message msg = {
6507 + .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_SETATTR],
6508 +- .rpc_argp = &args,
6509 ++ .rpc_argp = &arg,
6510 + .rpc_resp = &res,
6511 + };
6512 + int status;
6513 +
6514 +- nfs4_stateid_copy(&args.stateid, &zero_stateid);
6515 ++ nfs4_stateid_copy(&arg.stateid, &zero_stateid);
6516 +
6517 +- status = rpc_call_sync(server->client, &msg, 0);
6518 ++ status = nfs4_call_sync(server->client, server, &msg, &arg.seq_args, &res.seq_res, 1);
6519 + if (status)
6520 + dprintk("%s failed: %d\n", __func__, status);
6521 +
6522 +@@ -5106,6 +5101,7 @@ static int _nfs4_proc_getlk(struct nfs4_state *state, int cmd, struct file_lock
6523 + status = 0;
6524 + }
6525 + request->fl_ops->fl_release_private(request);
6526 ++ request->fl_ops = NULL;
6527 + out:
6528 + return status;
6529 + }
6530 +diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
6531 +index cc14cbb78b73..ebced8d71157 100644
6532 +--- a/fs/nfs/nfs4state.c
6533 ++++ b/fs/nfs/nfs4state.c
6534 +@@ -1422,7 +1422,7 @@ restart:
6535 + if (status >= 0) {
6536 + status = nfs4_reclaim_locks(state, ops);
6537 + if (status >= 0) {
6538 +- if (test_bit(NFS_DELEGATED_STATE, &state->flags) != 0) {
6539 ++ if (!test_bit(NFS_DELEGATED_STATE, &state->flags)) {
6540 + spin_lock(&state->state_lock);
6541 + list_for_each_entry(lock, &state->lock_states, ls_locks) {
6542 + if (!test_bit(NFS_LOCK_INITIALIZED, &lock->ls_flags))
6543 +@@ -1881,10 +1881,15 @@ again:
6544 + nfs4_root_machine_cred(clp);
6545 + goto again;
6546 + }
6547 +- if (i > 2)
6548 ++ if (clnt->cl_auth->au_flavor == RPC_AUTH_UNIX)
6549 + break;
6550 + case -NFS4ERR_CLID_INUSE:
6551 + case -NFS4ERR_WRONGSEC:
6552 ++ /* No point in retrying if we already used RPC_AUTH_UNIX */
6553 ++ if (clnt->cl_auth->au_flavor == RPC_AUTH_UNIX) {
6554 ++ status = -EPERM;
6555 ++ break;
6556 ++ }
6557 + clnt = rpc_clone_client_set_auth(clnt, RPC_AUTH_UNIX);
6558 + if (IS_ERR(clnt)) {
6559 + status = PTR_ERR(clnt);
6560 +diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c
6561 +index 5f38ea36e266..af51cf9bf2e3 100644
6562 +--- a/fs/nfsd/export.c
6563 ++++ b/fs/nfsd/export.c
6564 +@@ -536,16 +536,12 @@ static int svc_export_parse(struct cache_detail *cd, char *mesg, int mlen)
6565 + if (err)
6566 + goto out3;
6567 + exp.ex_anon_uid= make_kuid(&init_user_ns, an_int);
6568 +- if (!uid_valid(exp.ex_anon_uid))
6569 +- goto out3;
6570 +
6571 + /* anon gid */
6572 + err = get_int(&mesg, &an_int);
6573 + if (err)
6574 + goto out3;
6575 + exp.ex_anon_gid= make_kgid(&init_user_ns, an_int);
6576 +- if (!gid_valid(exp.ex_anon_gid))
6577 +- goto out3;
6578 +
6579 + /* fsid */
6580 + err = get_int(&mesg, &an_int);
6581 +@@ -583,6 +579,17 @@ static int svc_export_parse(struct cache_detail *cd, char *mesg, int mlen)
6582 + exp.ex_uuid);
6583 + if (err)
6584 + goto out4;
6585 ++ /*
6586 ++ * For some reason exportfs has been passing down an
6587 ++ * invalid (-1) uid & gid on the "dummy" export which it
6588 ++ * uses to test export support. To make sure exportfs
6589 ++ * sees errors from check_export we therefore need to
6590 ++ * delay these checks till after check_export:
6591 ++ */
6592 ++ if (!uid_valid(exp.ex_anon_uid))
6593 ++ goto out4;
6594 ++ if (!gid_valid(exp.ex_anon_gid))
6595 ++ goto out4;
6596 + }
6597 +
6598 + expp = svc_export_lookup(&exp);
6599 +diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
6600 +index d9454fe5653f..ecc735e30bea 100644
6601 +--- a/fs/nfsd/nfs4xdr.c
6602 ++++ b/fs/nfsd/nfs4xdr.c
6603 +@@ -141,8 +141,8 @@ xdr_error: \
6604 +
6605 + static void next_decode_page(struct nfsd4_compoundargs *argp)
6606 + {
6607 +- argp->pagelist++;
6608 + argp->p = page_address(argp->pagelist[0]);
6609 ++ argp->pagelist++;
6610 + if (argp->pagelen < PAGE_SIZE) {
6611 + argp->end = argp->p + (argp->pagelen>>2);
6612 + argp->pagelen = 0;
6613 +@@ -411,6 +411,7 @@ nfsd4_decode_fattr(struct nfsd4_compoundargs *argp, u32 *bmval,
6614 + label->data = kzalloc(dummy32 + 1, GFP_KERNEL);
6615 + if (!label->data)
6616 + return nfserr_jukebox;
6617 ++ label->len = dummy32;
6618 + defer_free(argp, kfree, label->data);
6619 + memcpy(label->data, buf, dummy32);
6620 + }
6621 +@@ -1208,6 +1209,7 @@ nfsd4_decode_write(struct nfsd4_compoundargs *argp, struct nfsd4_write *write)
6622 + len -= pages * PAGE_SIZE;
6623 +
6624 + argp->p = (__be32 *)page_address(argp->pagelist[0]);
6625 ++ argp->pagelist++;
6626 + argp->end = argp->p + XDR_QUADLEN(PAGE_SIZE);
6627 + }
6628 + argp->p += XDR_QUADLEN(len);
6629 +diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
6630 +index c827acb0e943..72cb28e73ca0 100644
6631 +--- a/fs/nfsd/vfs.c
6632 ++++ b/fs/nfsd/vfs.c
6633 +@@ -298,41 +298,12 @@ commit_metadata(struct svc_fh *fhp)
6634 + }
6635 +
6636 + /*
6637 +- * Set various file attributes.
6638 +- * N.B. After this call fhp needs an fh_put
6639 ++ * Go over the attributes and take care of the small differences between
6640 ++ * NFS semantics and what Linux expects.
6641 + */
6642 +-__be32
6643 +-nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap,
6644 +- int check_guard, time_t guardtime)
6645 ++static void
6646 ++nfsd_sanitize_attrs(struct inode *inode, struct iattr *iap)
6647 + {
6648 +- struct dentry *dentry;
6649 +- struct inode *inode;
6650 +- int accmode = NFSD_MAY_SATTR;
6651 +- umode_t ftype = 0;
6652 +- __be32 err;
6653 +- int host_err;
6654 +- int size_change = 0;
6655 +-
6656 +- if (iap->ia_valid & (ATTR_ATIME | ATTR_MTIME | ATTR_SIZE))
6657 +- accmode |= NFSD_MAY_WRITE|NFSD_MAY_OWNER_OVERRIDE;
6658 +- if (iap->ia_valid & ATTR_SIZE)
6659 +- ftype = S_IFREG;
6660 +-
6661 +- /* Get inode */
6662 +- err = fh_verify(rqstp, fhp, ftype, accmode);
6663 +- if (err)
6664 +- goto out;
6665 +-
6666 +- dentry = fhp->fh_dentry;
6667 +- inode = dentry->d_inode;
6668 +-
6669 +- /* Ignore any mode updates on symlinks */
6670 +- if (S_ISLNK(inode->i_mode))
6671 +- iap->ia_valid &= ~ATTR_MODE;
6672 +-
6673 +- if (!iap->ia_valid)
6674 +- goto out;
6675 +-
6676 + /*
6677 + * NFSv2 does not differentiate between "set-[ac]time-to-now"
6678 + * which only requires access, and "set-[ac]time-to-X" which
6679 +@@ -342,8 +313,7 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap,
6680 + * convert to "set to now" instead of "set to explicit time"
6681 + *
6682 + * We only call inode_change_ok as the last test as technically
6683 +- * it is not an interface that we should be using. It is only
6684 +- * valid if the filesystem does not define it's own i_op->setattr.
6685 ++ * it is not an interface that we should be using.
6686 + */
6687 + #define BOTH_TIME_SET (ATTR_ATIME_SET | ATTR_MTIME_SET)
6688 + #define MAX_TOUCH_TIME_ERROR (30*60)
6689 +@@ -369,30 +339,6 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap,
6690 + iap->ia_valid &= ~BOTH_TIME_SET;
6691 + }
6692 + }
6693 +-
6694 +- /*
6695 +- * The size case is special.
6696 +- * It changes the file as well as the attributes.
6697 +- */
6698 +- if (iap->ia_valid & ATTR_SIZE) {
6699 +- if (iap->ia_size < inode->i_size) {
6700 +- err = nfsd_permission(rqstp, fhp->fh_export, dentry,
6701 +- NFSD_MAY_TRUNC|NFSD_MAY_OWNER_OVERRIDE);
6702 +- if (err)
6703 +- goto out;
6704 +- }
6705 +-
6706 +- host_err = get_write_access(inode);
6707 +- if (host_err)
6708 +- goto out_nfserr;
6709 +-
6710 +- size_change = 1;
6711 +- host_err = locks_verify_truncate(inode, NULL, iap->ia_size);
6712 +- if (host_err) {
6713 +- put_write_access(inode);
6714 +- goto out_nfserr;
6715 +- }
6716 +- }
6717 +
6718 + /* sanitize the mode change */
6719 + if (iap->ia_valid & ATTR_MODE) {
6720 +@@ -415,32 +361,111 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap,
6721 + iap->ia_valid |= (ATTR_KILL_SUID | ATTR_KILL_SGID);
6722 + }
6723 + }
6724 ++}
6725 +
6726 +- /* Change the attributes. */
6727 ++static __be32
6728 ++nfsd_get_write_access(struct svc_rqst *rqstp, struct svc_fh *fhp,
6729 ++ struct iattr *iap)
6730 ++{
6731 ++ struct inode *inode = fhp->fh_dentry->d_inode;
6732 ++ int host_err;
6733 +
6734 +- iap->ia_valid |= ATTR_CTIME;
6735 ++ if (iap->ia_size < inode->i_size) {
6736 ++ __be32 err;
6737 +
6738 +- err = nfserr_notsync;
6739 +- if (!check_guard || guardtime == inode->i_ctime.tv_sec) {
6740 +- host_err = nfsd_break_lease(inode);
6741 +- if (host_err)
6742 +- goto out_nfserr;
6743 +- fh_lock(fhp);
6744 ++ err = nfsd_permission(rqstp, fhp->fh_export, fhp->fh_dentry,
6745 ++ NFSD_MAY_TRUNC | NFSD_MAY_OWNER_OVERRIDE);
6746 ++ if (err)
6747 ++ return err;
6748 ++ }
6749 +
6750 +- host_err = notify_change(dentry, iap);
6751 +- err = nfserrno(host_err);
6752 +- fh_unlock(fhp);
6753 ++ host_err = get_write_access(inode);
6754 ++ if (host_err)
6755 ++ goto out_nfserrno;
6756 ++
6757 ++ host_err = locks_verify_truncate(inode, NULL, iap->ia_size);
6758 ++ if (host_err)
6759 ++ goto out_put_write_access;
6760 ++ return 0;
6761 ++
6762 ++out_put_write_access:
6763 ++ put_write_access(inode);
6764 ++out_nfserrno:
6765 ++ return nfserrno(host_err);
6766 ++}
6767 ++
6768 ++/*
6769 ++ * Set various file attributes. After this call fhp needs an fh_put.
6770 ++ */
6771 ++__be32
6772 ++nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap,
6773 ++ int check_guard, time_t guardtime)
6774 ++{
6775 ++ struct dentry *dentry;
6776 ++ struct inode *inode;
6777 ++ int accmode = NFSD_MAY_SATTR;
6778 ++ umode_t ftype = 0;
6779 ++ __be32 err;
6780 ++ int host_err;
6781 ++ int size_change = 0;
6782 ++
6783 ++ if (iap->ia_valid & (ATTR_ATIME | ATTR_MTIME | ATTR_SIZE))
6784 ++ accmode |= NFSD_MAY_WRITE|NFSD_MAY_OWNER_OVERRIDE;
6785 ++ if (iap->ia_valid & ATTR_SIZE)
6786 ++ ftype = S_IFREG;
6787 ++
6788 ++ /* Get inode */
6789 ++ err = fh_verify(rqstp, fhp, ftype, accmode);
6790 ++ if (err)
6791 ++ goto out;
6792 ++
6793 ++ dentry = fhp->fh_dentry;
6794 ++ inode = dentry->d_inode;
6795 ++
6796 ++ /* Ignore any mode updates on symlinks */
6797 ++ if (S_ISLNK(inode->i_mode))
6798 ++ iap->ia_valid &= ~ATTR_MODE;
6799 ++
6800 ++ if (!iap->ia_valid)
6801 ++ goto out;
6802 ++
6803 ++ nfsd_sanitize_attrs(inode, iap);
6804 ++
6805 ++ /*
6806 ++ * The size case is special, it changes the file in addition to the
6807 ++ * attributes.
6808 ++ */
6809 ++ if (iap->ia_valid & ATTR_SIZE) {
6810 ++ err = nfsd_get_write_access(rqstp, fhp, iap);
6811 ++ if (err)
6812 ++ goto out;
6813 ++ size_change = 1;
6814 + }
6815 ++
6816 ++ iap->ia_valid |= ATTR_CTIME;
6817 ++
6818 ++ if (check_guard && guardtime != inode->i_ctime.tv_sec) {
6819 ++ err = nfserr_notsync;
6820 ++ goto out_put_write_access;
6821 ++ }
6822 ++
6823 ++ host_err = nfsd_break_lease(inode);
6824 ++ if (host_err)
6825 ++ goto out_put_write_access_nfserror;
6826 ++
6827 ++ fh_lock(fhp);
6828 ++ host_err = notify_change(dentry, iap);
6829 ++ fh_unlock(fhp);
6830 ++
6831 ++out_put_write_access_nfserror:
6832 ++ err = nfserrno(host_err);
6833 ++out_put_write_access:
6834 + if (size_change)
6835 + put_write_access(inode);
6836 + if (!err)
6837 + commit_metadata(fhp);
6838 + out:
6839 + return err;
6840 +-
6841 +-out_nfserr:
6842 +- err = nfserrno(host_err);
6843 +- goto out;
6844 + }
6845 +
6846 + #if defined(CONFIG_NFSD_V2_ACL) || \
6847 +diff --git a/fs/xfs/xfs_sb.c b/fs/xfs/xfs_sb.c
6848 +index a5b59d92eb70..039708122038 100644
6849 +--- a/fs/xfs/xfs_sb.c
6850 ++++ b/fs/xfs/xfs_sb.c
6851 +@@ -596,6 +596,11 @@ xfs_sb_verify(
6852 + * single bit error could clear the feature bit and unused parts of the
6853 + * superblock are supposed to be zero. Hence a non-null crc field indicates that
6854 + * we've potentially lost a feature bit and we should check it anyway.
6855 ++ *
6856 ++ * However, past bugs (i.e. in growfs) left non-zeroed regions beyond the
6857 ++ * last field in V4 secondary superblocks. So for secondary superblocks,
6858 ++ * we are more forgiving, and ignore CRC failures if the primary doesn't
6859 ++ * indicate that the fs version is V5.
6860 + */
6861 + static void
6862 + xfs_sb_read_verify(
6863 +@@ -616,8 +621,12 @@ xfs_sb_read_verify(
6864 +
6865 + if (!xfs_verify_cksum(bp->b_addr, be16_to_cpu(dsb->sb_sectsize),
6866 + offsetof(struct xfs_sb, sb_crc))) {
6867 +- error = EFSCORRUPTED;
6868 +- goto out_error;
6869 ++ /* Only fail bad secondaries on a known V5 filesystem */
6870 ++ if (bp->b_bn != XFS_SB_DADDR &&
6871 ++ xfs_sb_version_hascrc(&mp->m_sb)) {
6872 ++ error = EFSCORRUPTED;
6873 ++ goto out_error;
6874 ++ }
6875 + }
6876 + }
6877 + error = xfs_sb_verify(bp, true);
6878 +diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
6879 +index e8112ae50531..7554fd410bcc 100644
6880 +--- a/include/linux/binfmts.h
6881 ++++ b/include/linux/binfmts.h
6882 +@@ -99,9 +99,6 @@ extern void setup_new_exec(struct linux_binprm * bprm);
6883 + extern void would_dump(struct linux_binprm *, struct file *);
6884 +
6885 + extern int suid_dumpable;
6886 +-#define SUID_DUMP_DISABLE 0 /* No setuid dumping */
6887 +-#define SUID_DUMP_USER 1 /* Dump as user of process */
6888 +-#define SUID_DUMP_ROOT 2 /* Dump as root */
6889 +
6890 + /* Stack area protections */
6891 + #define EXSTACK_DEFAULT 0 /* Whatever the arch defaults to */
6892 +diff --git a/include/linux/nfs4.h b/include/linux/nfs4.h
6893 +index e36dee52f224..3859ddbecb5f 100644
6894 +--- a/include/linux/nfs4.h
6895 ++++ b/include/linux/nfs4.h
6896 +@@ -395,7 +395,7 @@ enum lock_type4 {
6897 + #define FATTR4_WORD1_FS_LAYOUT_TYPES (1UL << 30)
6898 + #define FATTR4_WORD2_LAYOUT_BLKSIZE (1UL << 1)
6899 + #define FATTR4_WORD2_MDSTHRESHOLD (1UL << 4)
6900 +-#define FATTR4_WORD2_SECURITY_LABEL (1UL << 17)
6901 ++#define FATTR4_WORD2_SECURITY_LABEL (1UL << 16)
6902 +
6903 + /* MDS threshold bitmap bits */
6904 + #define THRESHOLD_RD (1UL << 0)
6905 +diff --git a/include/linux/sched.h b/include/linux/sched.h
6906 +index e27baeeda3f4..b1e963efbde8 100644
6907 +--- a/include/linux/sched.h
6908 ++++ b/include/linux/sched.h
6909 +@@ -322,6 +322,10 @@ static inline void arch_pick_mmap_layout(struct mm_struct *mm) {}
6910 + extern void set_dumpable(struct mm_struct *mm, int value);
6911 + extern int get_dumpable(struct mm_struct *mm);
6912 +
6913 ++#define SUID_DUMP_DISABLE 0 /* No setuid dumping */
6914 ++#define SUID_DUMP_USER 1 /* Dump as user of process */
6915 ++#define SUID_DUMP_ROOT 2 /* Dump as root */
6916 ++
6917 + /* mm flags */
6918 + /* dumpable bits */
6919 + #define MMF_DUMPABLE 0 /* core dump is permitted */
6920 +@@ -2474,34 +2478,98 @@ static inline int tsk_is_polling(struct task_struct *p)
6921 + {
6922 + return task_thread_info(p)->status & TS_POLLING;
6923 + }
6924 +-static inline void current_set_polling(void)
6925 ++static inline void __current_set_polling(void)
6926 + {
6927 + current_thread_info()->status |= TS_POLLING;
6928 + }
6929 +
6930 +-static inline void current_clr_polling(void)
6931 ++static inline bool __must_check current_set_polling_and_test(void)
6932 ++{
6933 ++ __current_set_polling();
6934 ++
6935 ++ /*
6936 ++ * Polling state must be visible before we test NEED_RESCHED,
6937 ++ * paired by resched_task()
6938 ++ */
6939 ++ smp_mb();
6940 ++
6941 ++ return unlikely(tif_need_resched());
6942 ++}
6943 ++
6944 ++static inline void __current_clr_polling(void)
6945 + {
6946 + current_thread_info()->status &= ~TS_POLLING;
6947 +- smp_mb__after_clear_bit();
6948 ++}
6949 ++
6950 ++static inline bool __must_check current_clr_polling_and_test(void)
6951 ++{
6952 ++ __current_clr_polling();
6953 ++
6954 ++ /*
6955 ++ * Polling state must be visible before we test NEED_RESCHED,
6956 ++ * paired by resched_task()
6957 ++ */
6958 ++ smp_mb();
6959 ++
6960 ++ return unlikely(tif_need_resched());
6961 + }
6962 + #elif defined(TIF_POLLING_NRFLAG)
6963 + static inline int tsk_is_polling(struct task_struct *p)
6964 + {
6965 + return test_tsk_thread_flag(p, TIF_POLLING_NRFLAG);
6966 + }
6967 +-static inline void current_set_polling(void)
6968 ++
6969 ++static inline void __current_set_polling(void)
6970 + {
6971 + set_thread_flag(TIF_POLLING_NRFLAG);
6972 + }
6973 +
6974 +-static inline void current_clr_polling(void)
6975 ++static inline bool __must_check current_set_polling_and_test(void)
6976 ++{
6977 ++ __current_set_polling();
6978 ++
6979 ++ /*
6980 ++ * Polling state must be visible before we test NEED_RESCHED,
6981 ++ * paired by resched_task()
6982 ++ *
6983 ++ * XXX: assumes set/clear bit are identical barrier wise.
6984 ++ */
6985 ++ smp_mb__after_clear_bit();
6986 ++
6987 ++ return unlikely(tif_need_resched());
6988 ++}
6989 ++
6990 ++static inline void __current_clr_polling(void)
6991 + {
6992 + clear_thread_flag(TIF_POLLING_NRFLAG);
6993 + }
6994 ++
6995 ++static inline bool __must_check current_clr_polling_and_test(void)
6996 ++{
6997 ++ __current_clr_polling();
6998 ++
6999 ++ /*
7000 ++ * Polling state must be visible before we test NEED_RESCHED,
7001 ++ * paired by resched_task()
7002 ++ */
7003 ++ smp_mb__after_clear_bit();
7004 ++
7005 ++ return unlikely(tif_need_resched());
7006 ++}
7007 ++
7008 + #else
7009 + static inline int tsk_is_polling(struct task_struct *p) { return 0; }
7010 +-static inline void current_set_polling(void) { }
7011 +-static inline void current_clr_polling(void) { }
7012 ++static inline void __current_set_polling(void) { }
7013 ++static inline void __current_clr_polling(void) { }
7014 ++
7015 ++static inline bool __must_check current_set_polling_and_test(void)
7016 ++{
7017 ++ return unlikely(tif_need_resched());
7018 ++}
7019 ++static inline bool __must_check current_clr_polling_and_test(void)
7020 ++{
7021 ++ return unlikely(tif_need_resched());
7022 ++}
7023 + #endif
7024 +
7025 + /*
7026 +diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
7027 +index e7e04736802f..4ae6f32c8033 100644
7028 +--- a/include/linux/thread_info.h
7029 ++++ b/include/linux/thread_info.h
7030 +@@ -107,6 +107,8 @@ static inline int test_ti_thread_flag(struct thread_info *ti, int flag)
7031 + #define set_need_resched() set_thread_flag(TIF_NEED_RESCHED)
7032 + #define clear_need_resched() clear_thread_flag(TIF_NEED_RESCHED)
7033 +
7034 ++#define tif_need_resched() test_thread_flag(TIF_NEED_RESCHED)
7035 ++
7036 + #if defined TIF_RESTORE_SIGMASK && !defined HAVE_SET_RESTORE_SIGMASK
7037 + /*
7038 + * An arch can define its own version of set_restore_sigmask() to get the
7039 +diff --git a/include/linux/usb.h b/include/linux/usb.h
7040 +index 001629cd1a97..39cfa0aca91f 100644
7041 +--- a/include/linux/usb.h
7042 ++++ b/include/linux/usb.h
7043 +@@ -475,7 +475,8 @@ struct usb3_lpm_parameters {
7044 + * @lpm_capable: device supports LPM
7045 + * @usb2_hw_lpm_capable: device can perform USB2 hardware LPM
7046 + * @usb2_hw_lpm_besl_capable: device can perform USB2 hardware BESL LPM
7047 +- * @usb2_hw_lpm_enabled: USB2 hardware LPM enabled
7048 ++ * @usb2_hw_lpm_enabled: USB2 hardware LPM is enabled
7049 ++ * @usb2_hw_lpm_allowed: Userspace allows USB 2.0 LPM to be enabled
7050 + * @usb3_lpm_enabled: USB3 hardware LPM enabled
7051 + * @string_langid: language ID for strings
7052 + * @product: iProduct string, if present (static)
7053 +@@ -548,6 +549,7 @@ struct usb_device {
7054 + unsigned usb2_hw_lpm_capable:1;
7055 + unsigned usb2_hw_lpm_besl_capable:1;
7056 + unsigned usb2_hw_lpm_enabled:1;
7057 ++ unsigned usb2_hw_lpm_allowed:1;
7058 + unsigned usb3_lpm_enabled:1;
7059 + int string_langid;
7060 +
7061 +diff --git a/include/sound/compress_driver.h b/include/sound/compress_driver.h
7062 +index 9031a26249b5..ae6c3b8ed2f5 100644
7063 +--- a/include/sound/compress_driver.h
7064 ++++ b/include/sound/compress_driver.h
7065 +@@ -171,4 +171,13 @@ static inline void snd_compr_fragment_elapsed(struct snd_compr_stream *stream)
7066 + wake_up(&stream->runtime->sleep);
7067 + }
7068 +
7069 ++static inline void snd_compr_drain_notify(struct snd_compr_stream *stream)
7070 ++{
7071 ++ if (snd_BUG_ON(!stream))
7072 ++ return;
7073 ++
7074 ++ stream->runtime->state = SNDRV_PCM_STATE_SETUP;
7075 ++ wake_up(&stream->runtime->sleep);
7076 ++}
7077 ++
7078 + #endif
7079 +diff --git a/ipc/shm.c b/ipc/shm.c
7080 +index d69739610fd4..7a51443a51d6 100644
7081 +--- a/ipc/shm.c
7082 ++++ b/ipc/shm.c
7083 +@@ -208,15 +208,18 @@ static void shm_open(struct vm_area_struct *vma)
7084 + */
7085 + static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp)
7086 + {
7087 ++ struct file *shm_file;
7088 ++
7089 ++ shm_file = shp->shm_file;
7090 ++ shp->shm_file = NULL;
7091 + ns->shm_tot -= (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
7092 + shm_rmid(ns, shp);
7093 + shm_unlock(shp);
7094 +- if (!is_file_hugepages(shp->shm_file))
7095 +- shmem_lock(shp->shm_file, 0, shp->mlock_user);
7096 ++ if (!is_file_hugepages(shm_file))
7097 ++ shmem_lock(shm_file, 0, shp->mlock_user);
7098 + else if (shp->mlock_user)
7099 +- user_shm_unlock(file_inode(shp->shm_file)->i_size,
7100 +- shp->mlock_user);
7101 +- fput (shp->shm_file);
7102 ++ user_shm_unlock(file_inode(shm_file)->i_size, shp->mlock_user);
7103 ++ fput(shm_file);
7104 + ipc_rcu_putref(shp, shm_rcu_free);
7105 + }
7106 +
7107 +@@ -974,15 +977,25 @@ SYSCALL_DEFINE3(shmctl, int, shmid, int, cmd, struct shmid_ds __user *, buf)
7108 + ipc_lock_object(&shp->shm_perm);
7109 + if (!ns_capable(ns->user_ns, CAP_IPC_LOCK)) {
7110 + kuid_t euid = current_euid();
7111 +- err = -EPERM;
7112 + if (!uid_eq(euid, shp->shm_perm.uid) &&
7113 +- !uid_eq(euid, shp->shm_perm.cuid))
7114 ++ !uid_eq(euid, shp->shm_perm.cuid)) {
7115 ++ err = -EPERM;
7116 + goto out_unlock0;
7117 +- if (cmd == SHM_LOCK && !rlimit(RLIMIT_MEMLOCK))
7118 ++ }
7119 ++ if (cmd == SHM_LOCK && !rlimit(RLIMIT_MEMLOCK)) {
7120 ++ err = -EPERM;
7121 + goto out_unlock0;
7122 ++ }
7123 + }
7124 +
7125 + shm_file = shp->shm_file;
7126 ++
7127 ++ /* check if shm_destroy() is tearing down shp */
7128 ++ if (shm_file == NULL) {
7129 ++ err = -EIDRM;
7130 ++ goto out_unlock0;
7131 ++ }
7132 ++
7133 + if (is_file_hugepages(shm_file))
7134 + goto out_unlock0;
7135 +
7136 +@@ -1101,6 +1114,14 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
7137 + goto out_unlock;
7138 +
7139 + ipc_lock_object(&shp->shm_perm);
7140 ++
7141 ++ /* check if shm_destroy() is tearing down shp */
7142 ++ if (shp->shm_file == NULL) {
7143 ++ ipc_unlock_object(&shp->shm_perm);
7144 ++ err = -EIDRM;
7145 ++ goto out_unlock;
7146 ++ }
7147 ++
7148 + path = shp->shm_file->f_path;
7149 + path_get(&path);
7150 + shp->shm_nattch++;
7151 +diff --git a/kernel/cpu/idle.c b/kernel/cpu/idle.c
7152 +index e695c0a0bcb5..c261409500e4 100644
7153 +--- a/kernel/cpu/idle.c
7154 ++++ b/kernel/cpu/idle.c
7155 +@@ -44,7 +44,7 @@ static inline int cpu_idle_poll(void)
7156 + rcu_idle_enter();
7157 + trace_cpu_idle_rcuidle(0, smp_processor_id());
7158 + local_irq_enable();
7159 +- while (!need_resched())
7160 ++ while (!tif_need_resched())
7161 + cpu_relax();
7162 + trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, smp_processor_id());
7163 + rcu_idle_exit();
7164 +@@ -92,8 +92,7 @@ static void cpu_idle_loop(void)
7165 + if (cpu_idle_force_poll || tick_check_broadcast_expired()) {
7166 + cpu_idle_poll();
7167 + } else {
7168 +- current_clr_polling();
7169 +- if (!need_resched()) {
7170 ++ if (!current_clr_polling_and_test()) {
7171 + stop_critical_timings();
7172 + rcu_idle_enter();
7173 + arch_cpu_idle();
7174 +@@ -103,7 +102,7 @@ static void cpu_idle_loop(void)
7175 + } else {
7176 + local_irq_enable();
7177 + }
7178 +- current_set_polling();
7179 ++ __current_set_polling();
7180 + }
7181 + arch_cpu_idle_exit();
7182 + }
7183 +@@ -129,7 +128,7 @@ void cpu_startup_entry(enum cpuhp_state state)
7184 + */
7185 + boot_init_stack_canary();
7186 + #endif
7187 +- current_set_polling();
7188 ++ __current_set_polling();
7189 + arch_cpu_idle_prepare();
7190 + cpu_idle_loop();
7191 + }
7192 +diff --git a/kernel/ptrace.c b/kernel/ptrace.c
7193 +index dd562e9aa2c8..1f4bcb3cc21c 100644
7194 +--- a/kernel/ptrace.c
7195 ++++ b/kernel/ptrace.c
7196 +@@ -257,7 +257,8 @@ ok:
7197 + if (task->mm)
7198 + dumpable = get_dumpable(task->mm);
7199 + rcu_read_lock();
7200 +- if (!dumpable && !ptrace_has_cap(__task_cred(task)->user_ns, mode)) {
7201 ++ if (dumpable != SUID_DUMP_USER &&
7202 ++ !ptrace_has_cap(__task_cred(task)->user_ns, mode)) {
7203 + rcu_read_unlock();
7204 + return -EPERM;
7205 + }
7206 +diff --git a/kernel/trace/trace_event_perf.c b/kernel/trace/trace_event_perf.c
7207 +index 80c36bcf66e8..78e27e3b52ac 100644
7208 +--- a/kernel/trace/trace_event_perf.c
7209 ++++ b/kernel/trace/trace_event_perf.c
7210 +@@ -26,7 +26,7 @@ static int perf_trace_event_perm(struct ftrace_event_call *tp_event,
7211 + {
7212 + /* The ftrace function trace is allowed only for root. */
7213 + if (ftrace_event_is_function(tp_event) &&
7214 +- perf_paranoid_kernel() && !capable(CAP_SYS_ADMIN))
7215 ++ perf_paranoid_tracepoint_raw() && !capable(CAP_SYS_ADMIN))
7216 + return -EPERM;
7217 +
7218 + /* No tracing, just counting, so no obvious leak */
7219 +diff --git a/mm/slub.c b/mm/slub.c
7220 +index c3eb3d3ca835..96f21691b67c 100644
7221 +--- a/mm/slub.c
7222 ++++ b/mm/slub.c
7223 +@@ -1217,8 +1217,8 @@ static unsigned long kmem_cache_flags(unsigned long object_size,
7224 + /*
7225 + * Enable debugging if selected on the kernel commandline.
7226 + */
7227 +- if (slub_debug && (!slub_debug_slabs ||
7228 +- !strncmp(slub_debug_slabs, name, strlen(slub_debug_slabs))))
7229 ++ if (slub_debug && (!slub_debug_slabs || (name &&
7230 ++ !strncmp(slub_debug_slabs, name, strlen(slub_debug_slabs)))))
7231 + flags |= slub_debug;
7232 +
7233 + return flags;
7234 +diff --git a/net/sunrpc/auth_gss/auth_gss.c b/net/sunrpc/auth_gss/auth_gss.c
7235 +index 084656671d6e..cc24323d3045 100644
7236 +--- a/net/sunrpc/auth_gss/auth_gss.c
7237 ++++ b/net/sunrpc/auth_gss/auth_gss.c
7238 +@@ -482,6 +482,7 @@ gss_alloc_msg(struct gss_auth *gss_auth,
7239 + switch (vers) {
7240 + case 0:
7241 + gss_encode_v0_msg(gss_msg);
7242 ++ break;
7243 + default:
7244 + gss_encode_v1_msg(gss_msg, service_name, gss_auth->target_name);
7245 + };
7246 +diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
7247 +index 77479606a971..941d19f8c999 100644
7248 +--- a/net/sunrpc/clnt.c
7249 ++++ b/net/sunrpc/clnt.c
7250 +@@ -656,14 +656,16 @@ EXPORT_SYMBOL_GPL(rpc_shutdown_client);
7251 + /*
7252 + * Free an RPC client
7253 + */
7254 +-static void
7255 ++static struct rpc_clnt *
7256 + rpc_free_client(struct rpc_clnt *clnt)
7257 + {
7258 ++ struct rpc_clnt *parent = NULL;
7259 ++
7260 + dprintk_rcu("RPC: destroying %s client for %s\n",
7261 + clnt->cl_program->name,
7262 + rcu_dereference(clnt->cl_xprt)->servername);
7263 + if (clnt->cl_parent != clnt)
7264 +- rpc_release_client(clnt->cl_parent);
7265 ++ parent = clnt->cl_parent;
7266 + rpc_clnt_remove_pipedir(clnt);
7267 + rpc_unregister_client(clnt);
7268 + rpc_free_iostats(clnt->cl_metrics);
7269 +@@ -672,18 +674,17 @@ rpc_free_client(struct rpc_clnt *clnt)
7270 + rpciod_down();
7271 + rpc_free_clid(clnt);
7272 + kfree(clnt);
7273 ++ return parent;
7274 + }
7275 +
7276 + /*
7277 + * Free an RPC client
7278 + */
7279 +-static void
7280 ++static struct rpc_clnt *
7281 + rpc_free_auth(struct rpc_clnt *clnt)
7282 + {
7283 +- if (clnt->cl_auth == NULL) {
7284 +- rpc_free_client(clnt);
7285 +- return;
7286 +- }
7287 ++ if (clnt->cl_auth == NULL)
7288 ++ return rpc_free_client(clnt);
7289 +
7290 + /*
7291 + * Note: RPCSEC_GSS may need to send NULL RPC calls in order to
7292 +@@ -694,7 +695,8 @@ rpc_free_auth(struct rpc_clnt *clnt)
7293 + rpcauth_release(clnt->cl_auth);
7294 + clnt->cl_auth = NULL;
7295 + if (atomic_dec_and_test(&clnt->cl_count))
7296 +- rpc_free_client(clnt);
7297 ++ return rpc_free_client(clnt);
7298 ++ return NULL;
7299 + }
7300 +
7301 + /*
7302 +@@ -705,10 +707,13 @@ rpc_release_client(struct rpc_clnt *clnt)
7303 + {
7304 + dprintk("RPC: rpc_release_client(%p)\n", clnt);
7305 +
7306 +- if (list_empty(&clnt->cl_tasks))
7307 +- wake_up(&destroy_wait);
7308 +- if (atomic_dec_and_test(&clnt->cl_count))
7309 +- rpc_free_auth(clnt);
7310 ++ do {
7311 ++ if (list_empty(&clnt->cl_tasks))
7312 ++ wake_up(&destroy_wait);
7313 ++ if (!atomic_dec_and_test(&clnt->cl_count))
7314 ++ break;
7315 ++ clnt = rpc_free_auth(clnt);
7316 ++ } while (clnt != NULL);
7317 + }
7318 + EXPORT_SYMBOL_GPL(rpc_release_client);
7319 +
7320 +diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
7321 +index ee03d35677d9..b752e1de2e7d 100644
7322 +--- a/net/sunrpc/xprtsock.c
7323 ++++ b/net/sunrpc/xprtsock.c
7324 +@@ -393,8 +393,10 @@ static int xs_send_kvec(struct socket *sock, struct sockaddr *addr, int addrlen,
7325 + return kernel_sendmsg(sock, &msg, NULL, 0, 0);
7326 + }
7327 +
7328 +-static int xs_send_pagedata(struct socket *sock, struct xdr_buf *xdr, unsigned int base, int more)
7329 ++static int xs_send_pagedata(struct socket *sock, struct xdr_buf *xdr, unsigned int base, int more, bool zerocopy)
7330 + {
7331 ++ ssize_t (*do_sendpage)(struct socket *sock, struct page *page,
7332 ++ int offset, size_t size, int flags);
7333 + struct page **ppage;
7334 + unsigned int remainder;
7335 + int err, sent = 0;
7336 +@@ -403,6 +405,9 @@ static int xs_send_pagedata(struct socket *sock, struct xdr_buf *xdr, unsigned i
7337 + base += xdr->page_base;
7338 + ppage = xdr->pages + (base >> PAGE_SHIFT);
7339 + base &= ~PAGE_MASK;
7340 ++ do_sendpage = sock->ops->sendpage;
7341 ++ if (!zerocopy)
7342 ++ do_sendpage = sock_no_sendpage;
7343 + for(;;) {
7344 + unsigned int len = min_t(unsigned int, PAGE_SIZE - base, remainder);
7345 + int flags = XS_SENDMSG_FLAGS;
7346 +@@ -410,7 +415,7 @@ static int xs_send_pagedata(struct socket *sock, struct xdr_buf *xdr, unsigned i
7347 + remainder -= len;
7348 + if (remainder != 0 || more)
7349 + flags |= MSG_MORE;
7350 +- err = sock->ops->sendpage(sock, *ppage, base, len, flags);
7351 ++ err = do_sendpage(sock, *ppage, base, len, flags);
7352 + if (remainder == 0 || err != len)
7353 + break;
7354 + sent += err;
7355 +@@ -431,9 +436,10 @@ static int xs_send_pagedata(struct socket *sock, struct xdr_buf *xdr, unsigned i
7356 + * @addrlen: UDP only -- length of destination address
7357 + * @xdr: buffer containing this request
7358 + * @base: starting position in the buffer
7359 ++ * @zerocopy: true if it is safe to use sendpage()
7360 + *
7361 + */
7362 +-static int xs_sendpages(struct socket *sock, struct sockaddr *addr, int addrlen, struct xdr_buf *xdr, unsigned int base)
7363 ++static int xs_sendpages(struct socket *sock, struct sockaddr *addr, int addrlen, struct xdr_buf *xdr, unsigned int base, bool zerocopy)
7364 + {
7365 + unsigned int remainder = xdr->len - base;
7366 + int err, sent = 0;
7367 +@@ -461,7 +467,7 @@ static int xs_sendpages(struct socket *sock, struct sockaddr *addr, int addrlen,
7368 + if (base < xdr->page_len) {
7369 + unsigned int len = xdr->page_len - base;
7370 + remainder -= len;
7371 +- err = xs_send_pagedata(sock, xdr, base, remainder != 0);
7372 ++ err = xs_send_pagedata(sock, xdr, base, remainder != 0, zerocopy);
7373 + if (remainder == 0 || err != len)
7374 + goto out;
7375 + sent += err;
7376 +@@ -564,7 +570,7 @@ static int xs_local_send_request(struct rpc_task *task)
7377 + req->rq_svec->iov_base, req->rq_svec->iov_len);
7378 +
7379 + status = xs_sendpages(transport->sock, NULL, 0,
7380 +- xdr, req->rq_bytes_sent);
7381 ++ xdr, req->rq_bytes_sent, true);
7382 + dprintk("RPC: %s(%u) = %d\n",
7383 + __func__, xdr->len - req->rq_bytes_sent, status);
7384 + if (likely(status >= 0)) {
7385 +@@ -620,7 +626,7 @@ static int xs_udp_send_request(struct rpc_task *task)
7386 + status = xs_sendpages(transport->sock,
7387 + xs_addr(xprt),
7388 + xprt->addrlen, xdr,
7389 +- req->rq_bytes_sent);
7390 ++ req->rq_bytes_sent, true);
7391 +
7392 + dprintk("RPC: xs_udp_send_request(%u) = %d\n",
7393 + xdr->len - req->rq_bytes_sent, status);
7394 +@@ -693,6 +699,7 @@ static int xs_tcp_send_request(struct rpc_task *task)
7395 + struct rpc_xprt *xprt = req->rq_xprt;
7396 + struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt);
7397 + struct xdr_buf *xdr = &req->rq_snd_buf;
7398 ++ bool zerocopy = true;
7399 + int status;
7400 +
7401 + xs_encode_stream_record_marker(&req->rq_snd_buf);
7402 +@@ -700,13 +707,20 @@ static int xs_tcp_send_request(struct rpc_task *task)
7403 + xs_pktdump("packet data:",
7404 + req->rq_svec->iov_base,
7405 + req->rq_svec->iov_len);
7406 ++ /* Don't use zero copy if this is a resend. If the RPC call
7407 ++ * completes while the socket holds a reference to the pages,
7408 ++ * then we may end up resending corrupted data.
7409 ++ */
7410 ++ if (task->tk_flags & RPC_TASK_SENT)
7411 ++ zerocopy = false;
7412 +
7413 + /* Continue transmitting the packet/record. We must be careful
7414 + * to cope with writespace callbacks arriving _after_ we have
7415 + * called sendmsg(). */
7416 + while (1) {
7417 + status = xs_sendpages(transport->sock,
7418 +- NULL, 0, xdr, req->rq_bytes_sent);
7419 ++ NULL, 0, xdr, req->rq_bytes_sent,
7420 ++ zerocopy);
7421 +
7422 + dprintk("RPC: xs_tcp_send_request(%u) = %d\n",
7423 + xdr->len - req->rq_bytes_sent, status);
7424 +diff --git a/security/integrity/ima/ima_policy.c b/security/integrity/ima/ima_policy.c
7425 +index 399433ad614e..a9c3d3cd1990 100644
7426 +--- a/security/integrity/ima/ima_policy.c
7427 ++++ b/security/integrity/ima/ima_policy.c
7428 +@@ -73,7 +73,6 @@ static struct ima_rule_entry default_rules[] = {
7429 + {.action = DONT_MEASURE,.fsmagic = SYSFS_MAGIC,.flags = IMA_FSMAGIC},
7430 + {.action = DONT_MEASURE,.fsmagic = DEBUGFS_MAGIC,.flags = IMA_FSMAGIC},
7431 + {.action = DONT_MEASURE,.fsmagic = TMPFS_MAGIC,.flags = IMA_FSMAGIC},
7432 +- {.action = DONT_MEASURE,.fsmagic = RAMFS_MAGIC,.flags = IMA_FSMAGIC},
7433 + {.action = DONT_MEASURE,.fsmagic = DEVPTS_SUPER_MAGIC,.flags = IMA_FSMAGIC},
7434 + {.action = DONT_MEASURE,.fsmagic = BINFMTFS_MAGIC,.flags = IMA_FSMAGIC},
7435 + {.action = DONT_MEASURE,.fsmagic = SECURITYFS_MAGIC,.flags = IMA_FSMAGIC},
7436 +diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c
7437 +index bea523a5d852..d9af6387f37c 100644
7438 +--- a/sound/core/compress_offload.c
7439 ++++ b/sound/core/compress_offload.c
7440 +@@ -680,14 +680,48 @@ static int snd_compr_stop(struct snd_compr_stream *stream)
7441 + return -EPERM;
7442 + retval = stream->ops->trigger(stream, SNDRV_PCM_TRIGGER_STOP);
7443 + if (!retval) {
7444 +- stream->runtime->state = SNDRV_PCM_STATE_SETUP;
7445 +- wake_up(&stream->runtime->sleep);
7446 ++ snd_compr_drain_notify(stream);
7447 + stream->runtime->total_bytes_available = 0;
7448 + stream->runtime->total_bytes_transferred = 0;
7449 + }
7450 + return retval;
7451 + }
7452 +
7453 ++static int snd_compress_wait_for_drain(struct snd_compr_stream *stream)
7454 ++{
7455 ++ int ret;
7456 ++
7457 ++ /*
7458 ++ * We are called with lock held. So drop the lock while we wait for
7459 ++ * drain complete notfication from the driver
7460 ++ *
7461 ++ * It is expected that driver will notify the drain completion and then
7462 ++ * stream will be moved to SETUP state, even if draining resulted in an
7463 ++ * error. We can trigger next track after this.
7464 ++ */
7465 ++ stream->runtime->state = SNDRV_PCM_STATE_DRAINING;
7466 ++ mutex_unlock(&stream->device->lock);
7467 ++
7468 ++ /* we wait for drain to complete here, drain can return when
7469 ++ * interruption occurred, wait returned error or success.
7470 ++ * For the first two cases we don't do anything different here and
7471 ++ * return after waking up
7472 ++ */
7473 ++
7474 ++ ret = wait_event_interruptible(stream->runtime->sleep,
7475 ++ (stream->runtime->state != SNDRV_PCM_STATE_DRAINING));
7476 ++ if (ret == -ERESTARTSYS)
7477 ++ pr_debug("wait aborted by a signal");
7478 ++ else if (ret)
7479 ++ pr_debug("wait for drain failed with %d\n", ret);
7480 ++
7481 ++
7482 ++ wake_up(&stream->runtime->sleep);
7483 ++ mutex_lock(&stream->device->lock);
7484 ++
7485 ++ return ret;
7486 ++}
7487 ++
7488 + static int snd_compr_drain(struct snd_compr_stream *stream)
7489 + {
7490 + int retval;
7491 +@@ -695,12 +729,15 @@ static int snd_compr_drain(struct snd_compr_stream *stream)
7492 + if (stream->runtime->state == SNDRV_PCM_STATE_PREPARED ||
7493 + stream->runtime->state == SNDRV_PCM_STATE_SETUP)
7494 + return -EPERM;
7495 ++
7496 + retval = stream->ops->trigger(stream, SND_COMPR_TRIGGER_DRAIN);
7497 +- if (!retval) {
7498 +- stream->runtime->state = SNDRV_PCM_STATE_DRAINING;
7499 ++ if (retval) {
7500 ++ pr_debug("SND_COMPR_TRIGGER_DRAIN failed %d\n", retval);
7501 + wake_up(&stream->runtime->sleep);
7502 ++ return retval;
7503 + }
7504 +- return retval;
7505 ++
7506 ++ return snd_compress_wait_for_drain(stream);
7507 + }
7508 +
7509 + static int snd_compr_next_track(struct snd_compr_stream *stream)
7510 +@@ -736,9 +773,14 @@ static int snd_compr_partial_drain(struct snd_compr_stream *stream)
7511 + return -EPERM;
7512 +
7513 + retval = stream->ops->trigger(stream, SND_COMPR_TRIGGER_PARTIAL_DRAIN);
7514 ++ if (retval) {
7515 ++ pr_debug("Partial drain returned failure\n");
7516 ++ wake_up(&stream->runtime->sleep);
7517 ++ return retval;
7518 ++ }
7519 +
7520 + stream->next_track = false;
7521 +- return retval;
7522 ++ return snd_compress_wait_for_drain(stream);
7523 + }
7524 +
7525 + static long snd_compr_ioctl(struct file *f, unsigned int cmd, unsigned long arg)
7526 +diff --git a/sound/drivers/pcsp/pcsp.c b/sound/drivers/pcsp/pcsp.c
7527 +index 1c19cd7ad26e..83b8a9a9163e 100644
7528 +--- a/sound/drivers/pcsp/pcsp.c
7529 ++++ b/sound/drivers/pcsp/pcsp.c
7530 +@@ -187,8 +187,8 @@ static int pcsp_probe(struct platform_device *dev)
7531 + static int pcsp_remove(struct platform_device *dev)
7532 + {
7533 + struct snd_pcsp *chip = platform_get_drvdata(dev);
7534 +- alsa_card_pcsp_exit(chip);
7535 + pcspkr_input_remove(chip->input_dev);
7536 ++ alsa_card_pcsp_exit(chip);
7537 + return 0;
7538 + }
7539 +
7540 +diff --git a/sound/isa/msnd/msnd_pinnacle.c b/sound/isa/msnd/msnd_pinnacle.c
7541 +index 81aeb934261a..0a90bd6ae232 100644
7542 +--- a/sound/isa/msnd/msnd_pinnacle.c
7543 ++++ b/sound/isa/msnd/msnd_pinnacle.c
7544 +@@ -73,9 +73,11 @@
7545 + #ifdef MSND_CLASSIC
7546 + # include "msnd_classic.h"
7547 + # define LOGNAME "msnd_classic"
7548 ++# define DEV_NAME "msnd-classic"
7549 + #else
7550 + # include "msnd_pinnacle.h"
7551 + # define LOGNAME "snd_msnd_pinnacle"
7552 ++# define DEV_NAME "msnd-pinnacle"
7553 + #endif
7554 +
7555 + static void set_default_audio_parameters(struct snd_msnd *chip)
7556 +@@ -1067,8 +1069,6 @@ static int snd_msnd_isa_remove(struct device *pdev, unsigned int dev)
7557 + return 0;
7558 + }
7559 +
7560 +-#define DEV_NAME "msnd-pinnacle"
7561 +-
7562 + static struct isa_driver snd_msnd_driver = {
7563 + .match = snd_msnd_isa_match,
7564 + .probe = snd_msnd_isa_probe,
7565 +diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
7566 +index 748c6a941963..e938a68625ea 100644
7567 +--- a/sound/pci/hda/hda_codec.c
7568 ++++ b/sound/pci/hda/hda_codec.c
7569 +@@ -2579,9 +2579,6 @@ int snd_hda_codec_reset(struct hda_codec *codec)
7570 + cancel_delayed_work_sync(&codec->jackpoll_work);
7571 + #ifdef CONFIG_PM
7572 + cancel_delayed_work_sync(&codec->power_work);
7573 +- codec->power_on = 0;
7574 +- codec->power_transition = 0;
7575 +- codec->power_jiffies = jiffies;
7576 + flush_workqueue(bus->workq);
7577 + #endif
7578 + snd_hda_ctls_clear(codec);
7579 +@@ -3991,6 +3988,10 @@ static void hda_call_codec_resume(struct hda_codec *codec)
7580 + * in the resume / power-save sequence
7581 + */
7582 + hda_keep_power_on(codec);
7583 ++ if (codec->pm_down_notified) {
7584 ++ codec->pm_down_notified = 0;
7585 ++ hda_call_pm_notify(codec->bus, true);
7586 ++ }
7587 + hda_set_power_state(codec, AC_PWRST_D0);
7588 + restore_shutup_pins(codec);
7589 + hda_exec_init_verbs(codec);
7590 +diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c
7591 +index b7c89dff7066..3067ed4fe3b2 100644
7592 +--- a/sound/pci/hda/hda_generic.c
7593 ++++ b/sound/pci/hda/hda_generic.c
7594 +@@ -549,11 +549,15 @@ static hda_nid_t look_for_out_mute_nid(struct hda_codec *codec,
7595 + static hda_nid_t look_for_out_vol_nid(struct hda_codec *codec,
7596 + struct nid_path *path)
7597 + {
7598 ++ struct hda_gen_spec *spec = codec->spec;
7599 + int i;
7600 +
7601 + for (i = path->depth - 1; i >= 0; i--) {
7602 +- if (nid_has_volume(codec, path->path[i], HDA_OUTPUT))
7603 +- return path->path[i];
7604 ++ hda_nid_t nid = path->path[i];
7605 ++ if ((spec->out_vol_mask >> nid) & 1)
7606 ++ continue;
7607 ++ if (nid_has_volume(codec, nid, HDA_OUTPUT))
7608 ++ return nid;
7609 + }
7610 + return 0;
7611 + }
7612 +@@ -792,10 +796,10 @@ static void set_pin_eapd(struct hda_codec *codec, hda_nid_t pin, bool enable)
7613 + if (spec->own_eapd_ctl ||
7614 + !(snd_hda_query_pin_caps(codec, pin) & AC_PINCAP_EAPD))
7615 + return;
7616 +- if (codec->inv_eapd)
7617 +- enable = !enable;
7618 + if (spec->keep_eapd_on && !enable)
7619 + return;
7620 ++ if (codec->inv_eapd)
7621 ++ enable = !enable;
7622 + snd_hda_codec_update_cache(codec, pin, 0,
7623 + AC_VERB_SET_EAPD_BTLENABLE,
7624 + enable ? 0x02 : 0x00);
7625 +diff --git a/sound/pci/hda/hda_generic.h b/sound/pci/hda/hda_generic.h
7626 +index 48d44026705b..7e45cb44d151 100644
7627 +--- a/sound/pci/hda/hda_generic.h
7628 ++++ b/sound/pci/hda/hda_generic.h
7629 +@@ -242,6 +242,9 @@ struct hda_gen_spec {
7630 + /* additional mute flags (only effective with auto_mute_via_amp=1) */
7631 + u64 mute_bits;
7632 +
7633 ++ /* bitmask for skipping volume controls */
7634 ++ u64 out_vol_mask;
7635 ++
7636 + /* badness tables for output path evaluations */
7637 + const struct badness_table *main_out_badness;
7638 + const struct badness_table *extra_out_badness;
7639 +diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
7640 +index 6e61a019aa5e..a63aff2ca594 100644
7641 +--- a/sound/pci/hda/hda_intel.c
7642 ++++ b/sound/pci/hda/hda_intel.c
7643 +@@ -612,6 +612,11 @@ enum {
7644 + #define AZX_DCAPS_INTEL_PCH \
7645 + (AZX_DCAPS_INTEL_PCH_NOPM | AZX_DCAPS_PM_RUNTIME)
7646 +
7647 ++#define AZX_DCAPS_INTEL_HASWELL \
7648 ++ (AZX_DCAPS_SCH_SNOOP | AZX_DCAPS_ALIGN_BUFSIZE | \
7649 ++ AZX_DCAPS_COUNT_LPIB_DELAY | AZX_DCAPS_PM_RUNTIME | \
7650 ++ AZX_DCAPS_I915_POWERWELL)
7651 ++
7652 + /* quirks for ATI SB / AMD Hudson */
7653 + #define AZX_DCAPS_PRESET_ATI_SB \
7654 + (AZX_DCAPS_ATI_SNOOP | AZX_DCAPS_NO_TCSEL | \
7655 +@@ -3987,14 +3992,11 @@ static DEFINE_PCI_DEVICE_TABLE(azx_ids) = {
7656 + .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_INTEL_PCH },
7657 + /* Haswell */
7658 + { PCI_DEVICE(0x8086, 0x0a0c),
7659 +- .driver_data = AZX_DRIVER_SCH | AZX_DCAPS_INTEL_PCH |
7660 +- AZX_DCAPS_I915_POWERWELL },
7661 ++ .driver_data = AZX_DRIVER_SCH | AZX_DCAPS_INTEL_HASWELL },
7662 + { PCI_DEVICE(0x8086, 0x0c0c),
7663 +- .driver_data = AZX_DRIVER_SCH | AZX_DCAPS_INTEL_PCH |
7664 +- AZX_DCAPS_I915_POWERWELL },
7665 ++ .driver_data = AZX_DRIVER_SCH | AZX_DCAPS_INTEL_HASWELL },
7666 + { PCI_DEVICE(0x8086, 0x0d0c),
7667 +- .driver_data = AZX_DRIVER_SCH | AZX_DCAPS_INTEL_PCH |
7668 +- AZX_DCAPS_I915_POWERWELL },
7669 ++ .driver_data = AZX_DRIVER_SCH | AZX_DCAPS_INTEL_HASWELL },
7670 + /* 5 Series/3400 */
7671 + { PCI_DEVICE(0x8086, 0x3b56),
7672 + .driver_data = AZX_DRIVER_SCH | AZX_DCAPS_INTEL_PCH_NOPM },
7673 +diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c
7674 +index 2aa2f579b4d6..a52d2a1a5e83 100644
7675 +--- a/sound/pci/hda/patch_analog.c
7676 ++++ b/sound/pci/hda/patch_analog.c
7677 +@@ -219,8 +219,12 @@ static int alloc_ad_spec(struct hda_codec *codec)
7678 + static void ad_fixup_inv_jack_detect(struct hda_codec *codec,
7679 + const struct hda_fixup *fix, int action)
7680 + {
7681 +- if (action == HDA_FIXUP_ACT_PRE_PROBE)
7682 ++ struct ad198x_spec *spec = codec->spec;
7683 ++
7684 ++ if (action == HDA_FIXUP_ACT_PRE_PROBE) {
7685 + codec->inv_jack_detect = 1;
7686 ++ spec->gen.keep_eapd_on = 1;
7687 ++ }
7688 + }
7689 +
7690 + enum {
7691 +diff --git a/sound/pci/hda/patch_cirrus.c b/sound/pci/hda/patch_cirrus.c
7692 +index 18d972501585..072755c8289c 100644
7693 +--- a/sound/pci/hda/patch_cirrus.c
7694 ++++ b/sound/pci/hda/patch_cirrus.c
7695 +@@ -597,6 +597,7 @@ static int patch_cs420x(struct hda_codec *codec)
7696 + * Its layout is no longer compatible with CS4206/CS4207
7697 + */
7698 + enum {
7699 ++ CS4208_MAC_AUTO,
7700 + CS4208_MBA6,
7701 + CS4208_GPIO0,
7702 + };
7703 +@@ -608,7 +609,12 @@ static const struct hda_model_fixup cs4208_models[] = {
7704 + };
7705 +
7706 + static const struct snd_pci_quirk cs4208_fixup_tbl[] = {
7707 +- /* codec SSID */
7708 ++ SND_PCI_QUIRK_VENDOR(0x106b, "Apple", CS4208_MAC_AUTO),
7709 ++ {} /* terminator */
7710 ++};
7711 ++
7712 ++/* codec SSID matching */
7713 ++static const struct snd_pci_quirk cs4208_mac_fixup_tbl[] = {
7714 + SND_PCI_QUIRK(0x106b, 0x7100, "MacBookAir 6,1", CS4208_MBA6),
7715 + SND_PCI_QUIRK(0x106b, 0x7200, "MacBookAir 6,2", CS4208_MBA6),
7716 + {} /* terminator */
7717 +@@ -626,6 +632,20 @@ static void cs4208_fixup_gpio0(struct hda_codec *codec,
7718 + }
7719 + }
7720 +
7721 ++static const struct hda_fixup cs4208_fixups[];
7722 ++
7723 ++/* remap the fixup from codec SSID and apply it */
7724 ++static void cs4208_fixup_mac(struct hda_codec *codec,
7725 ++ const struct hda_fixup *fix, int action)
7726 ++{
7727 ++ if (action != HDA_FIXUP_ACT_PRE_PROBE)
7728 ++ return;
7729 ++ snd_hda_pick_fixup(codec, NULL, cs4208_mac_fixup_tbl, cs4208_fixups);
7730 ++ if (codec->fixup_id < 0 || codec->fixup_id == CS4208_MAC_AUTO)
7731 ++ codec->fixup_id = CS4208_GPIO0; /* default fixup */
7732 ++ snd_hda_apply_fixup(codec, action);
7733 ++}
7734 ++
7735 + static const struct hda_fixup cs4208_fixups[] = {
7736 + [CS4208_MBA6] = {
7737 + .type = HDA_FIXUP_PINS,
7738 +@@ -637,6 +657,10 @@ static const struct hda_fixup cs4208_fixups[] = {
7739 + .type = HDA_FIXUP_FUNC,
7740 + .v.func = cs4208_fixup_gpio0,
7741 + },
7742 ++ [CS4208_MAC_AUTO] = {
7743 ++ .type = HDA_FIXUP_FUNC,
7744 ++ .v.func = cs4208_fixup_mac,
7745 ++ },
7746 + };
7747 +
7748 + /* correct the 0dB offset of input pins */
7749 +@@ -660,6 +684,8 @@ static int patch_cs4208(struct hda_codec *codec)
7750 + return -ENOMEM;
7751 +
7752 + spec->gen.automute_hook = cs_automute;
7753 ++ /* exclude NID 0x10 (HP) from output volumes due to different steps */
7754 ++ spec->gen.out_vol_mask = 1ULL << 0x10;
7755 +
7756 + snd_hda_pick_fixup(codec, cs4208_models, cs4208_fixup_tbl,
7757 + cs4208_fixups);
7758 +diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c
7759 +index ec68eaea0336..96f07ce56603 100644
7760 +--- a/sound/pci/hda/patch_conexant.c
7761 ++++ b/sound/pci/hda/patch_conexant.c
7762 +@@ -3568,6 +3568,8 @@ static const struct hda_codec_preset snd_hda_preset_conexant[] = {
7763 + .patch = patch_conexant_auto },
7764 + { .id = 0x14f15115, .name = "CX20757",
7765 + .patch = patch_conexant_auto },
7766 ++ { .id = 0x14f151d7, .name = "CX20952",
7767 ++ .patch = patch_conexant_auto },
7768 + {} /* terminator */
7769 + };
7770 +
7771 +@@ -3594,6 +3596,7 @@ MODULE_ALIAS("snd-hda-codec-id:14f15111");
7772 + MODULE_ALIAS("snd-hda-codec-id:14f15113");
7773 + MODULE_ALIAS("snd-hda-codec-id:14f15114");
7774 + MODULE_ALIAS("snd-hda-codec-id:14f15115");
7775 ++MODULE_ALIAS("snd-hda-codec-id:14f151d7");
7776 +
7777 + MODULE_LICENSE("GPL");
7778 + MODULE_DESCRIPTION("Conexant HD-audio codec");
7779 +diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
7780 +index 8ad554312b69..2f39631f54c8 100644
7781 +--- a/sound/pci/hda/patch_realtek.c
7782 ++++ b/sound/pci/hda/patch_realtek.c
7783 +@@ -1043,6 +1043,7 @@ enum {
7784 + ALC880_FIXUP_UNIWILL,
7785 + ALC880_FIXUP_UNIWILL_DIG,
7786 + ALC880_FIXUP_Z71V,
7787 ++ ALC880_FIXUP_ASUS_W5A,
7788 + ALC880_FIXUP_3ST_BASE,
7789 + ALC880_FIXUP_3ST,
7790 + ALC880_FIXUP_3ST_DIG,
7791 +@@ -1213,6 +1214,26 @@ static const struct hda_fixup alc880_fixups[] = {
7792 + { }
7793 + }
7794 + },
7795 ++ [ALC880_FIXUP_ASUS_W5A] = {
7796 ++ .type = HDA_FIXUP_PINS,
7797 ++ .v.pins = (const struct hda_pintbl[]) {
7798 ++ /* set up the whole pins as BIOS is utterly broken */
7799 ++ { 0x14, 0x0121411f }, /* HP */
7800 ++ { 0x15, 0x411111f0 }, /* N/A */
7801 ++ { 0x16, 0x411111f0 }, /* N/A */
7802 ++ { 0x17, 0x411111f0 }, /* N/A */
7803 ++ { 0x18, 0x90a60160 }, /* mic */
7804 ++ { 0x19, 0x411111f0 }, /* N/A */
7805 ++ { 0x1a, 0x411111f0 }, /* N/A */
7806 ++ { 0x1b, 0x411111f0 }, /* N/A */
7807 ++ { 0x1c, 0x411111f0 }, /* N/A */
7808 ++ { 0x1d, 0x411111f0 }, /* N/A */
7809 ++ { 0x1e, 0xb743111e }, /* SPDIF out */
7810 ++ { }
7811 ++ },
7812 ++ .chained = true,
7813 ++ .chain_id = ALC880_FIXUP_GPIO1,
7814 ++ },
7815 + [ALC880_FIXUP_3ST_BASE] = {
7816 + .type = HDA_FIXUP_PINS,
7817 + .v.pins = (const struct hda_pintbl[]) {
7818 +@@ -1334,6 +1355,7 @@ static const struct hda_fixup alc880_fixups[] = {
7819 +
7820 + static const struct snd_pci_quirk alc880_fixup_tbl[] = {
7821 + SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_FIXUP_W810),
7822 ++ SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS W5A", ALC880_FIXUP_ASUS_W5A),
7823 + SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_FIXUP_Z71V),
7824 + SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_FIXUP_GPIO1),
7825 + SND_PCI_QUIRK(0x1558, 0x5401, "Clevo GPIO2", ALC880_FIXUP_GPIO2),
7826 +@@ -1479,6 +1501,7 @@ enum {
7827 + ALC260_FIXUP_KN1,
7828 + ALC260_FIXUP_FSC_S7020,
7829 + ALC260_FIXUP_FSC_S7020_JWSE,
7830 ++ ALC260_FIXUP_VAIO_PINS,
7831 + };
7832 +
7833 + static void alc260_gpio1_automute(struct hda_codec *codec)
7834 +@@ -1619,6 +1642,24 @@ static const struct hda_fixup alc260_fixups[] = {
7835 + .chained = true,
7836 + .chain_id = ALC260_FIXUP_FSC_S7020,
7837 + },
7838 ++ [ALC260_FIXUP_VAIO_PINS] = {
7839 ++ .type = HDA_FIXUP_PINS,
7840 ++ .v.pins = (const struct hda_pintbl[]) {
7841 ++ /* Pin configs are missing completely on some VAIOs */
7842 ++ { 0x0f, 0x01211020 },
7843 ++ { 0x10, 0x0001003f },
7844 ++ { 0x11, 0x411111f0 },
7845 ++ { 0x12, 0x01a15930 },
7846 ++ { 0x13, 0x411111f0 },
7847 ++ { 0x14, 0x411111f0 },
7848 ++ { 0x15, 0x411111f0 },
7849 ++ { 0x16, 0x411111f0 },
7850 ++ { 0x17, 0x411111f0 },
7851 ++ { 0x18, 0x411111f0 },
7852 ++ { 0x19, 0x411111f0 },
7853 ++ { }
7854 ++ }
7855 ++ },
7856 + };
7857 +
7858 + static const struct snd_pci_quirk alc260_fixup_tbl[] = {
7859 +@@ -1627,6 +1668,8 @@ static const struct snd_pci_quirk alc260_fixup_tbl[] = {
7860 + SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_FIXUP_GPIO1),
7861 + SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", ALC260_FIXUP_HP_DC5750),
7862 + SND_PCI_QUIRK(0x103c, 0x30ba, "HP Presario B1900", ALC260_FIXUP_HP_B1900),
7863 ++ SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_FIXUP_VAIO_PINS),
7864 ++ SND_PCI_QUIRK(0x104d, 0x81e2, "Sony VAIO TX", ALC260_FIXUP_HP_PIN_0F),
7865 + SND_PCI_QUIRK(0x10cf, 0x1326, "FSC LifeBook S7020", ALC260_FIXUP_FSC_S7020),
7866 + SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FIXUP_GPIO1),
7867 + SND_PCI_QUIRK(0x152d, 0x0729, "Quanta KN1", ALC260_FIXUP_KN1),
7868 +@@ -2388,6 +2431,7 @@ static const struct hda_verb alc268_beep_init_verbs[] = {
7869 + enum {
7870 + ALC268_FIXUP_INV_DMIC,
7871 + ALC268_FIXUP_HP_EAPD,
7872 ++ ALC268_FIXUP_SPDIF,
7873 + };
7874 +
7875 + static const struct hda_fixup alc268_fixups[] = {
7876 +@@ -2402,6 +2446,13 @@ static const struct hda_fixup alc268_fixups[] = {
7877 + {}
7878 + }
7879 + },
7880 ++ [ALC268_FIXUP_SPDIF] = {
7881 ++ .type = HDA_FIXUP_PINS,
7882 ++ .v.pins = (const struct hda_pintbl[]) {
7883 ++ { 0x1e, 0x014b1180 }, /* enable SPDIF out */
7884 ++ {}
7885 ++ }
7886 ++ },
7887 + };
7888 +
7889 + static const struct hda_model_fixup alc268_fixup_models[] = {
7890 +@@ -2411,6 +2462,7 @@ static const struct hda_model_fixup alc268_fixup_models[] = {
7891 + };
7892 +
7893 + static const struct snd_pci_quirk alc268_fixup_tbl[] = {
7894 ++ SND_PCI_QUIRK(0x1025, 0x0139, "Acer TravelMate 6293", ALC268_FIXUP_SPDIF),
7895 + SND_PCI_QUIRK(0x1025, 0x015b, "Acer AOA 150 (ZG5)", ALC268_FIXUP_INV_DMIC),
7896 + /* below is codec SSID since multiple Toshiba laptops have the
7897 + * same PCI SSID 1179:ff00
7898 +@@ -2540,6 +2592,7 @@ enum {
7899 + ALC269_TYPE_ALC283,
7900 + ALC269_TYPE_ALC284,
7901 + ALC269_TYPE_ALC286,
7902 ++ ALC269_TYPE_ALC255,
7903 + };
7904 +
7905 + /*
7906 +@@ -2565,6 +2618,7 @@ static int alc269_parse_auto_config(struct hda_codec *codec)
7907 + case ALC269_TYPE_ALC282:
7908 + case ALC269_TYPE_ALC283:
7909 + case ALC269_TYPE_ALC286:
7910 ++ case ALC269_TYPE_ALC255:
7911 + ssids = alc269_ssids;
7912 + break;
7913 + default:
7914 +@@ -2944,6 +2998,23 @@ static void alc269_fixup_mic_mute_hook(void *private_data, int enabled)
7915 + snd_hda_set_pin_ctl_cache(codec, spec->mute_led_nid, pinval);
7916 + }
7917 +
7918 ++/* Make sure the led works even in runtime suspend */
7919 ++static unsigned int led_power_filter(struct hda_codec *codec,
7920 ++ hda_nid_t nid,
7921 ++ unsigned int power_state)
7922 ++{
7923 ++ struct alc_spec *spec = codec->spec;
7924 ++
7925 ++ if (power_state != AC_PWRST_D3 || nid != spec->mute_led_nid)
7926 ++ return power_state;
7927 ++
7928 ++ /* Set pin ctl again, it might have just been set to 0 */
7929 ++ snd_hda_set_pin_ctl(codec, nid,
7930 ++ snd_hda_codec_get_pin_target(codec, nid));
7931 ++
7932 ++ return AC_PWRST_D0;
7933 ++}
7934 ++
7935 + static void alc269_fixup_hp_mute_led(struct hda_codec *codec,
7936 + const struct hda_fixup *fix, int action)
7937 + {
7938 +@@ -2963,6 +3034,7 @@ static void alc269_fixup_hp_mute_led(struct hda_codec *codec,
7939 + spec->mute_led_nid = pin - 0x0a + 0x18;
7940 + spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook;
7941 + spec->gen.vmaster_mute_enum = 1;
7942 ++ codec->power_filter = led_power_filter;
7943 + snd_printd("Detected mute LED for %x:%d\n", spec->mute_led_nid,
7944 + spec->mute_led_polarity);
7945 + break;
7946 +@@ -2978,6 +3050,7 @@ static void alc269_fixup_hp_mute_led_mic1(struct hda_codec *codec,
7947 + spec->mute_led_nid = 0x18;
7948 + spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook;
7949 + spec->gen.vmaster_mute_enum = 1;
7950 ++ codec->power_filter = led_power_filter;
7951 + }
7952 + }
7953 +
7954 +@@ -2990,6 +3063,7 @@ static void alc269_fixup_hp_mute_led_mic2(struct hda_codec *codec,
7955 + spec->mute_led_nid = 0x19;
7956 + spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook;
7957 + spec->gen.vmaster_mute_enum = 1;
7958 ++ codec->power_filter = led_power_filter;
7959 + }
7960 + }
7961 +
7962 +@@ -3230,8 +3304,10 @@ static void alc_update_headset_mode(struct hda_codec *codec)
7963 + else
7964 + new_headset_mode = ALC_HEADSET_MODE_HEADPHONE;
7965 +
7966 +- if (new_headset_mode == spec->current_headset_mode)
7967 ++ if (new_headset_mode == spec->current_headset_mode) {
7968 ++ snd_hda_gen_update_outputs(codec);
7969 + return;
7970 ++ }
7971 +
7972 + switch (new_headset_mode) {
7973 + case ALC_HEADSET_MODE_UNPLUGGED:
7974 +@@ -3895,6 +3971,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
7975 + SND_PCI_QUIRK(0x1028, 0x0608, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
7976 + SND_PCI_QUIRK(0x1028, 0x0609, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
7977 + SND_PCI_QUIRK(0x1028, 0x0613, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
7978 ++ SND_PCI_QUIRK(0x1028, 0x0614, "Dell Inspiron 3135", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
7979 + SND_PCI_QUIRK(0x1028, 0x0616, "Dell Vostro 5470", ALC290_FIXUP_MONO_SPEAKERS),
7980 + SND_PCI_QUIRK(0x1028, 0x15cc, "Dell X5 Precision", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
7981 + SND_PCI_QUIRK(0x1028, 0x15cd, "Dell X5 Precision", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
7982 +@@ -4128,6 +4205,9 @@ static int patch_alc269(struct hda_codec *codec)
7983 + case 0x10ec0286:
7984 + spec->codec_variant = ALC269_TYPE_ALC286;
7985 + break;
7986 ++ case 0x10ec0255:
7987 ++ spec->codec_variant = ALC269_TYPE_ALC255;
7988 ++ break;
7989 + }
7990 +
7991 + if (snd_hda_codec_read(codec, 0x51, 0, AC_VERB_PARAMETERS, 0) == 0x10ec5505) {
7992 +@@ -4842,6 +4922,7 @@ static int patch_alc680(struct hda_codec *codec)
7993 + static const struct hda_codec_preset snd_hda_preset_realtek[] = {
7994 + { .id = 0x10ec0221, .name = "ALC221", .patch = patch_alc269 },
7995 + { .id = 0x10ec0233, .name = "ALC233", .patch = patch_alc269 },
7996 ++ { .id = 0x10ec0255, .name = "ALC255", .patch = patch_alc269 },
7997 + { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
7998 + { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
7999 + { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
8000 +diff --git a/sound/usb/6fire/chip.c b/sound/usb/6fire/chip.c
8001 +index c39c77978468..66edc4a7917f 100644
8002 +--- a/sound/usb/6fire/chip.c
8003 ++++ b/sound/usb/6fire/chip.c
8004 +@@ -101,7 +101,7 @@ static int usb6fire_chip_probe(struct usb_interface *intf,
8005 + usb_set_intfdata(intf, chips[i]);
8006 + mutex_unlock(&register_mutex);
8007 + return 0;
8008 +- } else if (regidx < 0)
8009 ++ } else if (!devices[i] && regidx < 0)
8010 + regidx = i;
8011 + }
8012 + if (regidx < 0) {
8013 +diff --git a/virt/kvm/iommu.c b/virt/kvm/iommu.c
8014 +index 72a130bc448a..c329c8fc57f4 100644
8015 +--- a/virt/kvm/iommu.c
8016 ++++ b/virt/kvm/iommu.c
8017 +@@ -103,6 +103,10 @@ int kvm_iommu_map_pages(struct kvm *kvm, struct kvm_memory_slot *slot)
8018 + while ((gfn << PAGE_SHIFT) & (page_size - 1))
8019 + page_size >>= 1;
8020 +
8021 ++ /* Make sure hva is aligned to the page size we want to map */
8022 ++ while (__gfn_to_hva_memslot(slot, gfn) & (page_size - 1))
8023 ++ page_size >>= 1;
8024 ++
8025 + /*
8026 + * Pin all pages we are about to map in memory. This is
8027 + * important because we unmap and unpin in 4kb steps later.
8028
8029 Modified: genpatches-2.6/trunk/3.2/0000_README
8030 ===================================================================
8031 --- genpatches-2.6/trunk/3.2/0000_README 2013-11-14 16:37:35 UTC (rev 2581)
8032 +++ genpatches-2.6/trunk/3.2/0000_README 2013-11-29 23:44:29 UTC (rev 2595)
8033 @@ -244,6 +244,10 @@
8034 From: http://www.kernel.org
8035 Desc: Linux 3.2.51
8036
8037 +Patch: 1051_linux-3.2.52.patch
8038 +From: http://www.kernel.org
8039 +Desc: Linux 3.2.52
8040 +
8041 Patch: 1500_XATTR_USER_PREFIX.patch
8042 From: https://bugs.gentoo.org/show_bug.cgi?id=470644
8043 Desc: Support for namespace user.pax.* on tmpfs.
8044
8045 Added: genpatches-2.6/trunk/3.2/1051_linux-3.2.52.patch
8046 ===================================================================
8047 --- genpatches-2.6/trunk/3.2/1051_linux-3.2.52.patch (rev 0)
8048 +++ genpatches-2.6/trunk/3.2/1051_linux-3.2.52.patch 2013-11-29 23:44:29 UTC (rev 2595)
8049 @@ -0,0 +1,5221 @@
8050 +diff --git a/Makefile b/Makefile
8051 +index 0f1193666ddb..1dd2c094a3d3 100644
8052 +--- a/Makefile
8053 ++++ b/Makefile
8054 +@@ -1,6 +1,6 @@
8055 + VERSION = 3
8056 + PATCHLEVEL = 2
8057 +-SUBLEVEL = 51
8058 ++SUBLEVEL = 52
8059 + EXTRAVERSION =
8060 + NAME = Saber-toothed Squirrel
8061 +
8062 +diff --git a/arch/arm/mach-versatile/pci.c b/arch/arm/mach-versatile/pci.c
8063 +index c898deb3ada0..189ed0069dee 100644
8064 +--- a/arch/arm/mach-versatile/pci.c
8065 ++++ b/arch/arm/mach-versatile/pci.c
8066 +@@ -43,9 +43,9 @@
8067 + #define PCI_IMAP0 __IO_ADDRESS(VERSATILE_PCI_CORE_BASE+0x0)
8068 + #define PCI_IMAP1 __IO_ADDRESS(VERSATILE_PCI_CORE_BASE+0x4)
8069 + #define PCI_IMAP2 __IO_ADDRESS(VERSATILE_PCI_CORE_BASE+0x8)
8070 +-#define PCI_SMAP0 __IO_ADDRESS(VERSATILE_PCI_CORE_BASE+0x10)
8071 +-#define PCI_SMAP1 __IO_ADDRESS(VERSATILE_PCI_CORE_BASE+0x14)
8072 +-#define PCI_SMAP2 __IO_ADDRESS(VERSATILE_PCI_CORE_BASE+0x18)
8073 ++#define PCI_SMAP0 __IO_ADDRESS(VERSATILE_PCI_CORE_BASE+0x14)
8074 ++#define PCI_SMAP1 __IO_ADDRESS(VERSATILE_PCI_CORE_BASE+0x18)
8075 ++#define PCI_SMAP2 __IO_ADDRESS(VERSATILE_PCI_CORE_BASE+0x1c)
8076 + #define PCI_SELFID __IO_ADDRESS(VERSATILE_PCI_CORE_BASE+0xc)
8077 +
8078 + #define DEVICE_ID_OFFSET 0x00
8079 +diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
8080 +index fbdd12ea3a58..cc3f35dc102a 100644
8081 +--- a/arch/arm/mm/init.c
8082 ++++ b/arch/arm/mm/init.c
8083 +@@ -98,6 +98,9 @@ void show_mem(unsigned int filter)
8084 + printk("Mem-info:\n");
8085 + show_free_areas(filter);
8086 +
8087 ++ if (filter & SHOW_MEM_FILTER_PAGE_COUNT)
8088 ++ return;
8089 ++
8090 + for_each_bank (i, mi) {
8091 + struct membank *bank = &mi->bank[i];
8092 + unsigned int pfn1, pfn2;
8093 +diff --git a/arch/ia64/mm/contig.c b/arch/ia64/mm/contig.c
8094 +index f114a3b14c6a..ce6e7a80945e 100644
8095 +--- a/arch/ia64/mm/contig.c
8096 ++++ b/arch/ia64/mm/contig.c
8097 +@@ -46,6 +46,8 @@ void show_mem(unsigned int filter)
8098 + printk(KERN_INFO "Mem-info:\n");
8099 + show_free_areas(filter);
8100 + printk(KERN_INFO "Node memory in pages:\n");
8101 ++ if (filter & SHOW_MEM_FILTER_PAGE_COUNT)
8102 ++ return;
8103 + for_each_online_pgdat(pgdat) {
8104 + unsigned long present;
8105 + unsigned long flags;
8106 +diff --git a/arch/ia64/mm/discontig.c b/arch/ia64/mm/discontig.c
8107 +index c641333cd997..2230817b4e93 100644
8108 +--- a/arch/ia64/mm/discontig.c
8109 ++++ b/arch/ia64/mm/discontig.c
8110 +@@ -623,6 +623,8 @@ void show_mem(unsigned int filter)
8111 +
8112 + printk(KERN_INFO "Mem-info:\n");
8113 + show_free_areas(filter);
8114 ++ if (filter & SHOW_MEM_FILTER_PAGE_COUNT)
8115 ++ return;
8116 + printk(KERN_INFO "Node memory in pages:\n");
8117 + for_each_online_pgdat(pgdat) {
8118 + unsigned long present;
8119 +diff --git a/arch/m68k/kernel/vmlinux-nommu.lds b/arch/m68k/kernel/vmlinux-nommu.lds
8120 +new file mode 100644
8121 +index 000000000000..40e02d9c38b4
8122 +--- /dev/null
8123 ++++ b/arch/m68k/kernel/vmlinux-nommu.lds
8124 +@@ -0,0 +1,93 @@
8125 ++/*
8126 ++ * vmlinux.lds.S -- master linker script for m68knommu arch
8127 ++ *
8128 ++ * (C) Copyright 2002-2012, Greg Ungerer <gerg@××××××××.com>
8129 ++ *
8130 ++ * This linker script is equipped to build either ROM loaded or RAM
8131 ++ * run kernels.
8132 ++ */
8133 ++
8134 ++#if defined(CONFIG_RAMKERNEL)
8135 ++#define KTEXT_ADDR CONFIG_KERNELBASE
8136 ++#endif
8137 ++#if defined(CONFIG_ROMKERNEL)
8138 ++#define KTEXT_ADDR CONFIG_ROMSTART
8139 ++#define KDATA_ADDR CONFIG_KERNELBASE
8140 ++#define LOAD_OFFSET KDATA_ADDR + (ADDR(.text) + SIZEOF(.text))
8141 ++#endif
8142 ++
8143 ++#include <asm/page.h>
8144 ++#include <asm/thread_info.h>
8145 ++#include <asm-generic/vmlinux.lds.h>
8146 ++
8147 ++OUTPUT_ARCH(m68k)
8148 ++ENTRY(_start)
8149 ++
8150 ++jiffies = jiffies_64 + 4;
8151 ++
8152 ++SECTIONS {
8153 ++
8154 ++#ifdef CONFIG_ROMVEC
8155 ++ . = CONFIG_ROMVEC;
8156 ++ .romvec : {
8157 ++ __rom_start = .;
8158 ++ _romvec = .;
8159 ++ *(.romvec)
8160 ++ *(.data..initvect)
8161 ++ }
8162 ++#endif
8163 ++
8164 ++ . = KTEXT_ADDR;
8165 ++
8166 ++ _text = .;
8167 ++ _stext = .;
8168 ++ .text : {
8169 ++ HEAD_TEXT
8170 ++ TEXT_TEXT
8171 ++ SCHED_TEXT
8172 ++ LOCK_TEXT
8173 ++ *(.fixup)
8174 ++ . = ALIGN(16);
8175 ++ }
8176 ++ _etext = .;
8177 ++
8178 ++#ifdef KDATA_ADDR
8179 ++ . = KDATA_ADDR;
8180 ++#endif
8181 ++
8182 ++ _sdata = .;
8183 ++ RO_DATA_SECTION(PAGE_SIZE)
8184 ++ RW_DATA_SECTION(16, PAGE_SIZE, THREAD_SIZE)
8185 ++ _edata = .;
8186 ++
8187 ++ EXCEPTION_TABLE(16)
8188 ++ NOTES
8189 ++
8190 ++ . = ALIGN(PAGE_SIZE);
8191 ++ __init_begin = .;
8192 ++ INIT_TEXT_SECTION(PAGE_SIZE)
8193 ++ INIT_DATA_SECTION(16)
8194 ++ PERCPU_SECTION(16)
8195 ++ .m68k_fixup : {
8196 ++ __start_fixup = .;
8197 ++ *(.m68k_fixup)
8198 ++ __stop_fixup = .;
8199 ++ }
8200 ++ .init.data : {
8201 ++ . = ALIGN(PAGE_SIZE);
8202 ++ __init_end = .;
8203 ++ }
8204 ++
8205 ++ _sbss = .;
8206 ++ BSS_SECTION(0, 0, 0)
8207 ++ _ebss = .;
8208 ++
8209 ++ _end = .;
8210 ++
8211 ++ STABS_DEBUG
8212 ++ .comment 0 : { *(.comment) }
8213 ++
8214 ++ /* Sections to be discarded */
8215 ++ DISCARDS
8216 ++}
8217 ++
8218 +diff --git a/arch/m68k/kernel/vmlinux.lds.S b/arch/m68k/kernel/vmlinux.lds.S
8219 +index 030dabf0bc53..69ec79638870 100644
8220 +--- a/arch/m68k/kernel/vmlinux.lds.S
8221 ++++ b/arch/m68k/kernel/vmlinux.lds.S
8222 +@@ -1,5 +1,14 @@
8223 +-#ifdef CONFIG_MMU
8224 +-#include "vmlinux.lds_mm.S"
8225 ++#if defined(CONFIG_MMU) && !defined(CONFIG_COLDFIRE)
8226 ++PHDRS
8227 ++{
8228 ++ text PT_LOAD FILEHDR PHDRS FLAGS (7);
8229 ++ data PT_LOAD FLAGS (7);
8230 ++}
8231 ++#ifdef CONFIG_SUN3
8232 ++#include "vmlinux-sun3.lds"
8233 + #else
8234 +-#include "vmlinux.lds_no.S"
8235 ++#include "vmlinux-std.lds"
8236 ++#endif
8237 ++#else
8238 ++#include "vmlinux-nommu.lds"
8239 + #endif
8240 +diff --git a/arch/m68k/kernel/vmlinux.lds_mm.S b/arch/m68k/kernel/vmlinux.lds_mm.S
8241 +deleted file mode 100644
8242 +index 99ba315bd0a8..000000000000
8243 +--- a/arch/m68k/kernel/vmlinux.lds_mm.S
8244 ++++ /dev/null
8245 +@@ -1,10 +0,0 @@
8246 +-PHDRS
8247 +-{
8248 +- text PT_LOAD FILEHDR PHDRS FLAGS (7);
8249 +- data PT_LOAD FLAGS (7);
8250 +-}
8251 +-#ifdef CONFIG_SUN3
8252 +-#include "vmlinux-sun3.lds"
8253 +-#else
8254 +-#include "vmlinux-std.lds"
8255 +-#endif
8256 +diff --git a/arch/m68k/kernel/vmlinux.lds_no.S b/arch/m68k/kernel/vmlinux.lds_no.S
8257 +deleted file mode 100644
8258 +index 4e2389340837..000000000000
8259 +--- a/arch/m68k/kernel/vmlinux.lds_no.S
8260 ++++ /dev/null
8261 +@@ -1,187 +0,0 @@
8262 +-/*
8263 +- * vmlinux.lds.S -- master linker script for m68knommu arch
8264 +- *
8265 +- * (C) Copyright 2002-2006, Greg Ungerer <gerg@××××××××.com>
8266 +- *
8267 +- * This linker script is equipped to build either ROM loaded or RAM
8268 +- * run kernels.
8269 +- */
8270 +-
8271 +-#include <asm-generic/vmlinux.lds.h>
8272 +-#include <asm/page.h>
8273 +-#include <asm/thread_info.h>
8274 +-
8275 +-#if defined(CONFIG_RAMKERNEL)
8276 +-#define RAM_START CONFIG_KERNELBASE
8277 +-#define RAM_LENGTH (CONFIG_RAMBASE + CONFIG_RAMSIZE - CONFIG_KERNELBASE)
8278 +-#define TEXT ram
8279 +-#define DATA ram
8280 +-#define INIT ram
8281 +-#define BSSS ram
8282 +-#endif
8283 +-#if defined(CONFIG_ROMKERNEL) || defined(CONFIG_HIMEMKERNEL)
8284 +-#define RAM_START CONFIG_RAMBASE
8285 +-#define RAM_LENGTH CONFIG_RAMSIZE
8286 +-#define ROMVEC_START CONFIG_ROMVEC
8287 +-#define ROMVEC_LENGTH CONFIG_ROMVECSIZE
8288 +-#define ROM_START CONFIG_ROMSTART
8289 +-#define ROM_LENGTH CONFIG_ROMSIZE
8290 +-#define TEXT rom
8291 +-#define DATA ram
8292 +-#define INIT ram
8293 +-#define BSSS ram
8294 +-#endif
8295 +-
8296 +-#ifndef DATA_ADDR
8297 +-#define DATA_ADDR
8298 +-#endif
8299 +-
8300 +-
8301 +-OUTPUT_ARCH(m68k)
8302 +-ENTRY(_start)
8303 +-
8304 +-MEMORY {
8305 +- ram : ORIGIN = RAM_START, LENGTH = RAM_LENGTH
8306 +-#ifdef ROM_START
8307 +- romvec : ORIGIN = ROMVEC_START, LENGTH = ROMVEC_LENGTH
8308 +- rom : ORIGIN = ROM_START, LENGTH = ROM_LENGTH
8309 +-#endif
8310 +-}
8311 +-
8312 +-jiffies = jiffies_64 + 4;
8313 +-
8314 +-SECTIONS {
8315 +-
8316 +-#ifdef ROMVEC_START
8317 +- . = ROMVEC_START ;
8318 +- .romvec : {
8319 +- __rom_start = . ;
8320 +- _romvec = .;
8321 +- *(.data..initvect)
8322 +- } > romvec
8323 +-#endif
8324 +-
8325 +- .text : {
8326 +- _text = .;
8327 +- _stext = . ;
8328 +- HEAD_TEXT
8329 +- TEXT_TEXT
8330 +- SCHED_TEXT
8331 +- LOCK_TEXT
8332 +- *(.text..lock)
8333 +-
8334 +- . = ALIGN(16); /* Exception table */
8335 +- __start___ex_table = .;
8336 +- *(__ex_table)
8337 +- __stop___ex_table = .;
8338 +-
8339 +- *(.rodata) *(.rodata.*)
8340 +- *(__vermagic) /* Kernel version magic */
8341 +- *(.rodata1)
8342 +- *(.rodata.str1.1)
8343 +-
8344 +- /* Kernel symbol table: Normal symbols */
8345 +- . = ALIGN(4);
8346 +- __start___ksymtab = .;
8347 +- *(SORT(___ksymtab+*))
8348 +- __stop___ksymtab = .;
8349 +-
8350 +- /* Kernel symbol table: GPL-only symbols */
8351 +- __start___ksymtab_gpl = .;
8352 +- *(SORT(___ksymtab_gpl+*))
8353 +- __stop___ksymtab_gpl = .;
8354 +-
8355 +- /* Kernel symbol table: Normal unused symbols */
8356 +- __start___ksymtab_unused = .;
8357 +- *(SORT(___ksymtab_unused+*))
8358 +- __stop___ksymtab_unused = .;
8359 +-
8360 +- /* Kernel symbol table: GPL-only unused symbols */
8361 +- __start___ksymtab_unused_gpl = .;
8362 +- *(SORT(___ksymtab_unused_gpl+*))
8363 +- __stop___ksymtab_unused_gpl = .;
8364 +-
8365 +- /* Kernel symbol table: GPL-future symbols */
8366 +- __start___ksymtab_gpl_future = .;
8367 +- *(SORT(___ksymtab_gpl_future+*))
8368 +- __stop___ksymtab_gpl_future = .;
8369 +-
8370 +- /* Kernel symbol table: Normal symbols */
8371 +- __start___kcrctab = .;
8372 +- *(SORT(___kcrctab+*))
8373 +- __stop___kcrctab = .;
8374 +-
8375 +- /* Kernel symbol table: GPL-only symbols */
8376 +- __start___kcrctab_gpl = .;
8377 +- *(SORT(___kcrctab_gpl+*))
8378 +- __stop___kcrctab_gpl = .;
8379 +-
8380 +- /* Kernel symbol table: Normal unused symbols */
8381 +- __start___kcrctab_unused = .;
8382 +- *(SORT(___kcrctab_unused+*))
8383 +- __stop___kcrctab_unused = .;
8384 +-
8385 +- /* Kernel symbol table: GPL-only unused symbols */
8386 +- __start___kcrctab_unused_gpl = .;
8387 +- *(SORT(___kcrctab_unused_gpl+*))
8388 +- __stop___kcrctab_unused_gpl = .;
8389 +-
8390 +- /* Kernel symbol table: GPL-future symbols */
8391 +- __start___kcrctab_gpl_future = .;
8392 +- *(SORT(___kcrctab_gpl_future+*))
8393 +- __stop___kcrctab_gpl_future = .;
8394 +-
8395 +- /* Kernel symbol table: strings */
8396 +- *(__ksymtab_strings)
8397 +-
8398 +- /* Built-in module parameters */
8399 +- . = ALIGN(4) ;
8400 +- __start___param = .;
8401 +- *(__param)
8402 +- __stop___param = .;
8403 +-
8404 +- /* Built-in module versions */
8405 +- . = ALIGN(4) ;
8406 +- __start___modver = .;
8407 +- *(__modver)
8408 +- __stop___modver = .;
8409 +-
8410 +- . = ALIGN(4) ;
8411 +- _etext = . ;
8412 +- } > TEXT
8413 +-
8414 +- .data DATA_ADDR : {
8415 +- . = ALIGN(4);
8416 +- _sdata = . ;
8417 +- DATA_DATA
8418 +- CACHELINE_ALIGNED_DATA(32)
8419 +- PAGE_ALIGNED_DATA(PAGE_SIZE)
8420 +- *(.data..shared_aligned)
8421 +- INIT_TASK_DATA(THREAD_SIZE)
8422 +- _edata = . ;
8423 +- } > DATA
8424 +-
8425 +- .init.text : {
8426 +- . = ALIGN(PAGE_SIZE);
8427 +- __init_begin = .;
8428 +- } > INIT
8429 +- INIT_TEXT_SECTION(PAGE_SIZE) > INIT
8430 +- INIT_DATA_SECTION(16) > INIT
8431 +- .init.data : {
8432 +- . = ALIGN(PAGE_SIZE);
8433 +- __init_end = .;
8434 +- } > INIT
8435 +-
8436 +- .bss : {
8437 +- . = ALIGN(4);
8438 +- _sbss = . ;
8439 +- *(.bss)
8440 +- *(COMMON)
8441 +- . = ALIGN(4) ;
8442 +- _ebss = . ;
8443 +- _end = . ;
8444 +- } > BSSS
8445 +-
8446 +- DISCARDS
8447 +-}
8448 +-
8449 +diff --git a/arch/parisc/mm/init.c b/arch/parisc/mm/init.c
8450 +index 82f364e209fc..0b621625a6fb 100644
8451 +--- a/arch/parisc/mm/init.c
8452 ++++ b/arch/parisc/mm/init.c
8453 +@@ -685,6 +685,8 @@ void show_mem(unsigned int filter)
8454 +
8455 + printk(KERN_INFO "Mem-info:\n");
8456 + show_free_areas(filter);
8457 ++ if (filter & SHOW_MEM_FILTER_PAGE_COUNT)
8458 ++ return;
8459 + #ifndef CONFIG_DISCONTIGMEM
8460 + i = max_mapnr;
8461 + while (i-- > 0) {
8462 +diff --git a/arch/powerpc/kernel/align.c b/arch/powerpc/kernel/align.c
8463 +index 8184ee97e484..3fcbae0fa4a0 100644
8464 +--- a/arch/powerpc/kernel/align.c
8465 ++++ b/arch/powerpc/kernel/align.c
8466 +@@ -764,6 +764,16 @@ int fix_alignment(struct pt_regs *regs)
8467 + nb = aligninfo[instr].len;
8468 + flags = aligninfo[instr].flags;
8469 +
8470 ++ /* ldbrx/stdbrx overlap lfs/stfs in the DSISR unfortunately */
8471 ++ if (IS_XFORM(instruction) && ((instruction >> 1) & 0x3ff) == 532) {
8472 ++ nb = 8;
8473 ++ flags = LD+SW;
8474 ++ } else if (IS_XFORM(instruction) &&
8475 ++ ((instruction >> 1) & 0x3ff) == 660) {
8476 ++ nb = 8;
8477 ++ flags = ST+SW;
8478 ++ }
8479 ++
8480 + /* Byteswap little endian loads and stores */
8481 + swiz = 0;
8482 + if (regs->msr & MSR_LE) {
8483 +diff --git a/arch/powerpc/kernel/iommu.c b/arch/powerpc/kernel/iommu.c
8484 +index 0cfcf98aafca..d0b205cd1126 100644
8485 +--- a/arch/powerpc/kernel/iommu.c
8486 ++++ b/arch/powerpc/kernel/iommu.c
8487 +@@ -495,7 +495,7 @@ struct iommu_table *iommu_init_table(struct iommu_table *tbl, int nid)
8488 + /* number of bytes needed for the bitmap */
8489 + sz = (tbl->it_size + 7) >> 3;
8490 +
8491 +- page = alloc_pages_node(nid, GFP_ATOMIC, get_order(sz));
8492 ++ page = alloc_pages_node(nid, GFP_KERNEL, get_order(sz));
8493 + if (!page)
8494 + panic("iommu_init_table: Can't allocate %ld bytes\n", sz);
8495 + tbl->it_map = page_address(page);
8496 +diff --git a/arch/powerpc/kernel/lparcfg.c b/arch/powerpc/kernel/lparcfg.c
8497 +index 826681dc342a..26af24bbaed4 100644
8498 +--- a/arch/powerpc/kernel/lparcfg.c
8499 ++++ b/arch/powerpc/kernel/lparcfg.c
8500 +@@ -375,6 +375,7 @@ static void parse_system_parameter_string(struct seq_file *m)
8501 + __pa(rtas_data_buf),
8502 + RTAS_DATA_BUF_SIZE);
8503 + memcpy(local_buffer, rtas_data_buf, SPLPAR_MAXLENGTH);
8504 ++ local_buffer[SPLPAR_MAXLENGTH - 1] = '\0';
8505 + spin_unlock(&rtas_data_buf_lock);
8506 +
8507 + if (call_status != 0) {
8508 +diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c
8509 +index 55be64db0ae0..ca683a18943b 100644
8510 +--- a/arch/powerpc/kernel/sysfs.c
8511 ++++ b/arch/powerpc/kernel/sysfs.c
8512 +@@ -18,6 +18,7 @@
8513 + #include <asm/machdep.h>
8514 + #include <asm/smp.h>
8515 + #include <asm/pmc.h>
8516 ++#include <asm/firmware.h>
8517 +
8518 + #include "cacheinfo.h"
8519 +
8520 +@@ -178,14 +179,24 @@ SYSFS_PMCSETUP(purr, SPRN_PURR);
8521 + SYSFS_PMCSETUP(spurr, SPRN_SPURR);
8522 + SYSFS_PMCSETUP(dscr, SPRN_DSCR);
8523 +
8524 ++/*
8525 ++ Lets only enable read for phyp resources and
8526 ++ enable write when needed with a separate function.
8527 ++ Lets be conservative and default to pseries.
8528 ++*/
8529 + static SYSDEV_ATTR(mmcra, 0600, show_mmcra, store_mmcra);
8530 + static SYSDEV_ATTR(spurr, 0600, show_spurr, NULL);
8531 + static SYSDEV_ATTR(dscr, 0600, show_dscr, store_dscr);
8532 +-static SYSDEV_ATTR(purr, 0600, show_purr, store_purr);
8533 ++static SYSDEV_ATTR(purr, 0400, show_purr, store_purr);
8534 +
8535 + unsigned long dscr_default = 0;
8536 + EXPORT_SYMBOL(dscr_default);
8537 +
8538 ++static void add_write_permission_dev_attr(struct sysdev_attribute *attr)
8539 ++{
8540 ++ attr->attr.mode |= 0200;
8541 ++}
8542 ++
8543 + static ssize_t show_dscr_default(struct sysdev_class *class,
8544 + struct sysdev_class_attribute *attr, char *buf)
8545 + {
8546 +@@ -394,8 +405,11 @@ static void __cpuinit register_cpu_online(unsigned int cpu)
8547 + if (cpu_has_feature(CPU_FTR_MMCRA))
8548 + sysdev_create_file(s, &attr_mmcra);
8549 +
8550 +- if (cpu_has_feature(CPU_FTR_PURR))
8551 ++ if (cpu_has_feature(CPU_FTR_PURR)) {
8552 ++ if (!firmware_has_feature(FW_FEATURE_LPAR))
8553 ++ add_write_permission_dev_attr(&attr_purr);
8554 + sysdev_create_file(s, &attr_purr);
8555 ++ }
8556 +
8557 + if (cpu_has_feature(CPU_FTR_SPURR))
8558 + sysdev_create_file(s, &attr_spurr);
8559 +diff --git a/arch/powerpc/lib/checksum_64.S b/arch/powerpc/lib/checksum_64.S
8560 +index 18245af38aea..3cdbc648d979 100644
8561 +--- a/arch/powerpc/lib/checksum_64.S
8562 ++++ b/arch/powerpc/lib/checksum_64.S
8563 +@@ -229,19 +229,35 @@ _GLOBAL(csum_partial)
8564 + blr
8565 +
8566 +
8567 +- .macro source
8568 ++ .macro srcnr
8569 + 100:
8570 + .section __ex_table,"a"
8571 + .align 3
8572 +- .llong 100b,.Lsrc_error
8573 ++ .llong 100b,.Lsrc_error_nr
8574 + .previous
8575 + .endm
8576 +
8577 +- .macro dest
8578 ++ .macro source
8579 ++150:
8580 ++ .section __ex_table,"a"
8581 ++ .align 3
8582 ++ .llong 150b,.Lsrc_error
8583 ++ .previous
8584 ++ .endm
8585 ++
8586 ++ .macro dstnr
8587 + 200:
8588 + .section __ex_table,"a"
8589 + .align 3
8590 +- .llong 200b,.Ldest_error
8591 ++ .llong 200b,.Ldest_error_nr
8592 ++ .previous
8593 ++ .endm
8594 ++
8595 ++ .macro dest
8596 ++250:
8597 ++ .section __ex_table,"a"
8598 ++ .align 3
8599 ++ .llong 250b,.Ldest_error
8600 + .previous
8601 + .endm
8602 +
8603 +@@ -272,16 +288,16 @@ _GLOBAL(csum_partial_copy_generic)
8604 + rldicl. r6,r3,64-1,64-2 /* r6 = (r3 & 0x3) >> 1 */
8605 + beq .Lcopy_aligned
8606 +
8607 +- li r7,4
8608 +- sub r6,r7,r6
8609 ++ li r9,4
8610 ++ sub r6,r9,r6
8611 + mtctr r6
8612 +
8613 + 1:
8614 +-source; lhz r6,0(r3) /* align to doubleword */
8615 ++srcnr; lhz r6,0(r3) /* align to doubleword */
8616 + subi r5,r5,2
8617 + addi r3,r3,2
8618 + adde r0,r0,r6
8619 +-dest; sth r6,0(r4)
8620 ++dstnr; sth r6,0(r4)
8621 + addi r4,r4,2
8622 + bdnz 1b
8623 +
8624 +@@ -395,10 +411,10 @@ dest; std r16,56(r4)
8625 +
8626 + mtctr r6
8627 + 3:
8628 +-source; ld r6,0(r3)
8629 ++srcnr; ld r6,0(r3)
8630 + addi r3,r3,8
8631 + adde r0,r0,r6
8632 +-dest; std r6,0(r4)
8633 ++dstnr; std r6,0(r4)
8634 + addi r4,r4,8
8635 + bdnz 3b
8636 +
8637 +@@ -408,10 +424,10 @@ dest; std r6,0(r4)
8638 + srdi. r6,r5,2
8639 + beq .Lcopy_tail_halfword
8640 +
8641 +-source; lwz r6,0(r3)
8642 ++srcnr; lwz r6,0(r3)
8643 + addi r3,r3,4
8644 + adde r0,r0,r6
8645 +-dest; stw r6,0(r4)
8646 ++dstnr; stw r6,0(r4)
8647 + addi r4,r4,4
8648 + subi r5,r5,4
8649 +
8650 +@@ -419,10 +435,10 @@ dest; stw r6,0(r4)
8651 + srdi. r6,r5,1
8652 + beq .Lcopy_tail_byte
8653 +
8654 +-source; lhz r6,0(r3)
8655 ++srcnr; lhz r6,0(r3)
8656 + addi r3,r3,2
8657 + adde r0,r0,r6
8658 +-dest; sth r6,0(r4)
8659 ++dstnr; sth r6,0(r4)
8660 + addi r4,r4,2
8661 + subi r5,r5,2
8662 +
8663 +@@ -430,10 +446,10 @@ dest; sth r6,0(r4)
8664 + andi. r6,r5,1
8665 + beq .Lcopy_finish
8666 +
8667 +-source; lbz r6,0(r3)
8668 ++srcnr; lbz r6,0(r3)
8669 + sldi r9,r6,8 /* Pad the byte out to 16 bits */
8670 + adde r0,r0,r9
8671 +-dest; stb r6,0(r4)
8672 ++dstnr; stb r6,0(r4)
8673 +
8674 + .Lcopy_finish:
8675 + addze r0,r0 /* add in final carry */
8676 +@@ -443,6 +459,11 @@ dest; stb r6,0(r4)
8677 + blr
8678 +
8679 + .Lsrc_error:
8680 ++ ld r14,STK_REG(r14)(r1)
8681 ++ ld r15,STK_REG(r15)(r1)
8682 ++ ld r16,STK_REG(r16)(r1)
8683 ++ addi r1,r1,STACKFRAMESIZE
8684 ++.Lsrc_error_nr:
8685 + cmpdi 0,r7,0
8686 + beqlr
8687 + li r6,-EFAULT
8688 +@@ -450,6 +471,11 @@ dest; stb r6,0(r4)
8689 + blr
8690 +
8691 + .Ldest_error:
8692 ++ ld r14,STK_REG(r14)(r1)
8693 ++ ld r15,STK_REG(r15)(r1)
8694 ++ ld r16,STK_REG(r16)(r1)
8695 ++ addi r1,r1,STACKFRAMESIZE
8696 ++.Ldest_error_nr:
8697 + cmpdi 0,r8,0
8698 + beqlr
8699 + li r6,-EFAULT
8700 +diff --git a/arch/sparc/kernel/entry.S b/arch/sparc/kernel/entry.S
8701 +index f445e98463e6..cfabc3d8821e 100644
8702 +--- a/arch/sparc/kernel/entry.S
8703 ++++ b/arch/sparc/kernel/entry.S
8704 +@@ -1177,7 +1177,7 @@ sys_sigreturn:
8705 + nop
8706 +
8707 + call syscall_trace
8708 +- nop
8709 ++ mov 1, %o1
8710 +
8711 + 1:
8712 + /* We don't want to muck with user registers like a
8713 +diff --git a/arch/sparc/kernel/ktlb.S b/arch/sparc/kernel/ktlb.S
8714 +index 79f310364849..7c0073500173 100644
8715 +--- a/arch/sparc/kernel/ktlb.S
8716 ++++ b/arch/sparc/kernel/ktlb.S
8717 +@@ -25,11 +25,10 @@ kvmap_itlb:
8718 + */
8719 + kvmap_itlb_4v:
8720 +
8721 +-kvmap_itlb_nonlinear:
8722 + /* Catch kernel NULL pointer calls. */
8723 + sethi %hi(PAGE_SIZE), %g5
8724 + cmp %g4, %g5
8725 +- bleu,pn %xcc, kvmap_dtlb_longpath
8726 ++ blu,pn %xcc, kvmap_itlb_longpath
8727 + nop
8728 +
8729 + KERN_TSB_LOOKUP_TL1(%g4, %g6, %g5, %g1, %g2, %g3, kvmap_itlb_load)
8730 +diff --git a/arch/sparc/kernel/syscalls.S b/arch/sparc/kernel/syscalls.S
8731 +index 7f5f65d0b3fd..817187d42777 100644
8732 +--- a/arch/sparc/kernel/syscalls.S
8733 ++++ b/arch/sparc/kernel/syscalls.S
8734 +@@ -147,7 +147,7 @@ linux_syscall_trace32:
8735 + srl %i4, 0, %o4
8736 + srl %i1, 0, %o1
8737 + srl %i2, 0, %o2
8738 +- ba,pt %xcc, 2f
8739 ++ ba,pt %xcc, 5f
8740 + srl %i3, 0, %o3
8741 +
8742 + linux_syscall_trace:
8743 +@@ -177,13 +177,13 @@ linux_sparc_syscall32:
8744 + srl %i1, 0, %o1 ! IEU0 Group
8745 + ldx [%g6 + TI_FLAGS], %l0 ! Load
8746 +
8747 +- srl %i5, 0, %o5 ! IEU1
8748 ++ srl %i3, 0, %o3 ! IEU0
8749 + srl %i2, 0, %o2 ! IEU0 Group
8750 + andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8751 + bne,pn %icc, linux_syscall_trace32 ! CTI
8752 + mov %i0, %l5 ! IEU1
8753 +- call %l7 ! CTI Group brk forced
8754 +- srl %i3, 0, %o3 ! IEU0
8755 ++5: call %l7 ! CTI Group brk forced
8756 ++ srl %i5, 0, %o5 ! IEU1
8757 + ba,a,pt %xcc, 3f
8758 +
8759 + /* Linux native system calls enter here... */
8760 +diff --git a/arch/sparc/kernel/trampoline_64.S b/arch/sparc/kernel/trampoline_64.S
8761 +index da1b781b5e65..8fa84a3897cb 100644
8762 +--- a/arch/sparc/kernel/trampoline_64.S
8763 ++++ b/arch/sparc/kernel/trampoline_64.S
8764 +@@ -131,7 +131,6 @@ startup_continue:
8765 + clr %l5
8766 + sethi %hi(num_kernel_image_mappings), %l6
8767 + lduw [%l6 + %lo(num_kernel_image_mappings)], %l6
8768 +- add %l6, 1, %l6
8769 +
8770 + mov 15, %l7
8771 + BRANCH_IF_ANY_CHEETAH(g1,g5,2f)
8772 +@@ -224,7 +223,6 @@ niagara_lock_tlb:
8773 + clr %l5
8774 + sethi %hi(num_kernel_image_mappings), %l6
8775 + lduw [%l6 + %lo(num_kernel_image_mappings)], %l6
8776 +- add %l6, 1, %l6
8777 +
8778 + 1:
8779 + mov HV_FAST_MMU_MAP_PERM_ADDR, %o5
8780 +diff --git a/arch/sparc/lib/ksyms.c b/arch/sparc/lib/ksyms.c
8781 +index 1b30bb3bfdb1..fbb800533032 100644
8782 +--- a/arch/sparc/lib/ksyms.c
8783 ++++ b/arch/sparc/lib/ksyms.c
8784 +@@ -131,15 +131,6 @@ EXPORT_SYMBOL(___copy_from_user);
8785 + EXPORT_SYMBOL(___copy_in_user);
8786 + EXPORT_SYMBOL(__clear_user);
8787 +
8788 +-/* RW semaphores */
8789 +-EXPORT_SYMBOL(__down_read);
8790 +-EXPORT_SYMBOL(__down_read_trylock);
8791 +-EXPORT_SYMBOL(__down_write);
8792 +-EXPORT_SYMBOL(__down_write_trylock);
8793 +-EXPORT_SYMBOL(__up_read);
8794 +-EXPORT_SYMBOL(__up_write);
8795 +-EXPORT_SYMBOL(__downgrade_write);
8796 +-
8797 + /* Atomic counter implementation. */
8798 + EXPORT_SYMBOL(atomic_add);
8799 + EXPORT_SYMBOL(atomic_add_ret);
8800 +diff --git a/arch/unicore32/mm/init.c b/arch/unicore32/mm/init.c
8801 +index 3b379cddbc64..d1af4ed5694d 100644
8802 +--- a/arch/unicore32/mm/init.c
8803 ++++ b/arch/unicore32/mm/init.c
8804 +@@ -65,6 +65,9 @@ void show_mem(unsigned int filter)
8805 + printk(KERN_DEFAULT "Mem-info:\n");
8806 + show_free_areas(filter);
8807 +
8808 ++ if (filter & SHOW_MEM_FILTER_PAGE_COUNT)
8809 ++ return;
8810 ++
8811 + for_each_bank(i, mi) {
8812 + struct membank *bank = &mi->bank[i];
8813 + unsigned int pfn1, pfn2;
8814 +diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
8815 +index 47f4e5ff55ac..a4e1b4bd4953 100644
8816 +--- a/arch/x86/kernel/reboot.c
8817 ++++ b/arch/x86/kernel/reboot.c
8818 +@@ -468,6 +468,22 @@ static struct dmi_system_id __initdata pci_reboot_dmi_table[] = {
8819 + DMI_MATCH(DMI_PRODUCT_NAME, "Precision M6600"),
8820 + },
8821 + },
8822 ++ { /* Handle problems with rebooting on the Dell PowerEdge C6100. */
8823 ++ .callback = set_pci_reboot,
8824 ++ .ident = "Dell PowerEdge C6100",
8825 ++ .matches = {
8826 ++ DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
8827 ++ DMI_MATCH(DMI_PRODUCT_NAME, "C6100"),
8828 ++ },
8829 ++ },
8830 ++ { /* Some C6100 machines were shipped with vendor being 'Dell'. */
8831 ++ .callback = set_pci_reboot,
8832 ++ .ident = "Dell PowerEdge C6100",
8833 ++ .matches = {
8834 ++ DMI_MATCH(DMI_SYS_VENDOR, "Dell"),
8835 ++ DMI_MATCH(DMI_PRODUCT_NAME, "C6100"),
8836 ++ },
8837 ++ },
8838 + { }
8839 + };
8840 +
8841 +diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
8842 +index f9537e3044ff..a18d20d52740 100644
8843 +--- a/arch/x86/platform/efi/efi.c
8844 ++++ b/arch/x86/platform/efi/efi.c
8845 +@@ -703,10 +703,13 @@ void __init efi_enter_virtual_mode(void)
8846 +
8847 + for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) {
8848 + md = p;
8849 +- if (!(md->attribute & EFI_MEMORY_RUNTIME) &&
8850 +- md->type != EFI_BOOT_SERVICES_CODE &&
8851 +- md->type != EFI_BOOT_SERVICES_DATA)
8852 +- continue;
8853 ++ if (!(md->attribute & EFI_MEMORY_RUNTIME)) {
8854 ++#ifdef CONFIG_X86_64
8855 ++ if (md->type != EFI_BOOT_SERVICES_CODE &&
8856 ++ md->type != EFI_BOOT_SERVICES_DATA)
8857 ++#endif
8858 ++ continue;
8859 ++ }
8860 +
8861 + size = md->num_pages << EFI_PAGE_SHIFT;
8862 + end = md->phys_addr + size;
8863 +diff --git a/crypto/api.c b/crypto/api.c
8864 +index 033a7147e5eb..cea3cf6c9897 100644
8865 +--- a/crypto/api.c
8866 ++++ b/crypto/api.c
8867 +@@ -34,6 +34,8 @@ EXPORT_SYMBOL_GPL(crypto_alg_sem);
8868 + BLOCKING_NOTIFIER_HEAD(crypto_chain);
8869 + EXPORT_SYMBOL_GPL(crypto_chain);
8870 +
8871 ++static struct crypto_alg *crypto_larval_wait(struct crypto_alg *alg);
8872 ++
8873 + static inline struct crypto_alg *crypto_alg_get(struct crypto_alg *alg)
8874 + {
8875 + atomic_inc(&alg->cra_refcnt);
8876 +@@ -150,8 +152,11 @@ static struct crypto_alg *crypto_larval_add(const char *name, u32 type,
8877 + }
8878 + up_write(&crypto_alg_sem);
8879 +
8880 +- if (alg != &larval->alg)
8881 ++ if (alg != &larval->alg) {
8882 + kfree(larval);
8883 ++ if (crypto_is_larval(alg))
8884 ++ alg = crypto_larval_wait(alg);
8885 ++ }
8886 +
8887 + return alg;
8888 + }
8889 +diff --git a/drivers/acpi/acpi_ipmi.c b/drivers/acpi/acpi_ipmi.c
8890 +index f40acef80269..a6977e12d574 100644
8891 +--- a/drivers/acpi/acpi_ipmi.c
8892 ++++ b/drivers/acpi/acpi_ipmi.c
8893 +@@ -39,6 +39,7 @@
8894 + #include <linux/ipmi.h>
8895 + #include <linux/device.h>
8896 + #include <linux/pnp.h>
8897 ++#include <linux/spinlock.h>
8898 +
8899 + MODULE_AUTHOR("Zhao Yakui");
8900 + MODULE_DESCRIPTION("ACPI IPMI Opregion driver");
8901 +@@ -57,7 +58,7 @@ struct acpi_ipmi_device {
8902 + struct list_head head;
8903 + /* the IPMI request message list */
8904 + struct list_head tx_msg_list;
8905 +- struct mutex tx_msg_lock;
8906 ++ spinlock_t tx_msg_lock;
8907 + acpi_handle handle;
8908 + struct pnp_dev *pnp_dev;
8909 + ipmi_user_t user_interface;
8910 +@@ -147,6 +148,7 @@ static void acpi_format_ipmi_msg(struct acpi_ipmi_msg *tx_msg,
8911 + struct kernel_ipmi_msg *msg;
8912 + struct acpi_ipmi_buffer *buffer;
8913 + struct acpi_ipmi_device *device;
8914 ++ unsigned long flags;
8915 +
8916 + msg = &tx_msg->tx_message;
8917 + /*
8918 +@@ -177,10 +179,10 @@ static void acpi_format_ipmi_msg(struct acpi_ipmi_msg *tx_msg,
8919 +
8920 + /* Get the msgid */
8921 + device = tx_msg->device;
8922 +- mutex_lock(&device->tx_msg_lock);
8923 ++ spin_lock_irqsave(&device->tx_msg_lock, flags);
8924 + device->curr_msgid++;
8925 + tx_msg->tx_msgid = device->curr_msgid;
8926 +- mutex_unlock(&device->tx_msg_lock);
8927 ++ spin_unlock_irqrestore(&device->tx_msg_lock, flags);
8928 + }
8929 +
8930 + static void acpi_format_ipmi_response(struct acpi_ipmi_msg *msg,
8931 +@@ -242,6 +244,7 @@ static void ipmi_msg_handler(struct ipmi_recv_msg *msg, void *user_msg_data)
8932 + int msg_found = 0;
8933 + struct acpi_ipmi_msg *tx_msg;
8934 + struct pnp_dev *pnp_dev = ipmi_device->pnp_dev;
8935 ++ unsigned long flags;
8936 +
8937 + if (msg->user != ipmi_device->user_interface) {
8938 + dev_warn(&pnp_dev->dev, "Unexpected response is returned. "
8939 +@@ -250,7 +253,7 @@ static void ipmi_msg_handler(struct ipmi_recv_msg *msg, void *user_msg_data)
8940 + ipmi_free_recv_msg(msg);
8941 + return;
8942 + }
8943 +- mutex_lock(&ipmi_device->tx_msg_lock);
8944 ++ spin_lock_irqsave(&ipmi_device->tx_msg_lock, flags);
8945 + list_for_each_entry(tx_msg, &ipmi_device->tx_msg_list, head) {
8946 + if (msg->msgid == tx_msg->tx_msgid) {
8947 + msg_found = 1;
8948 +@@ -258,7 +261,7 @@ static void ipmi_msg_handler(struct ipmi_recv_msg *msg, void *user_msg_data)
8949 + }
8950 + }
8951 +
8952 +- mutex_unlock(&ipmi_device->tx_msg_lock);
8953 ++ spin_unlock_irqrestore(&ipmi_device->tx_msg_lock, flags);
8954 + if (!msg_found) {
8955 + dev_warn(&pnp_dev->dev, "Unexpected response (msg id %ld) is "
8956 + "returned.\n", msg->msgid);
8957 +@@ -378,6 +381,7 @@ acpi_ipmi_space_handler(u32 function, acpi_physical_address address,
8958 + struct acpi_ipmi_device *ipmi_device = handler_context;
8959 + int err, rem_time;
8960 + acpi_status status;
8961 ++ unsigned long flags;
8962 + /*
8963 + * IPMI opregion message.
8964 + * IPMI message is firstly written to the BMC and system software
8965 +@@ -395,9 +399,9 @@ acpi_ipmi_space_handler(u32 function, acpi_physical_address address,
8966 + return AE_NO_MEMORY;
8967 +
8968 + acpi_format_ipmi_msg(tx_msg, address, value);
8969 +- mutex_lock(&ipmi_device->tx_msg_lock);
8970 ++ spin_lock_irqsave(&ipmi_device->tx_msg_lock, flags);
8971 + list_add_tail(&tx_msg->head, &ipmi_device->tx_msg_list);
8972 +- mutex_unlock(&ipmi_device->tx_msg_lock);
8973 ++ spin_unlock_irqrestore(&ipmi_device->tx_msg_lock, flags);
8974 + err = ipmi_request_settime(ipmi_device->user_interface,
8975 + &tx_msg->addr,
8976 + tx_msg->tx_msgid,
8977 +@@ -413,9 +417,9 @@ acpi_ipmi_space_handler(u32 function, acpi_physical_address address,
8978 + status = AE_OK;
8979 +
8980 + end_label:
8981 +- mutex_lock(&ipmi_device->tx_msg_lock);
8982 ++ spin_lock_irqsave(&ipmi_device->tx_msg_lock, flags);
8983 + list_del(&tx_msg->head);
8984 +- mutex_unlock(&ipmi_device->tx_msg_lock);
8985 ++ spin_unlock_irqrestore(&ipmi_device->tx_msg_lock, flags);
8986 + kfree(tx_msg);
8987 + return status;
8988 + }
8989 +@@ -457,7 +461,7 @@ static void acpi_add_ipmi_device(struct acpi_ipmi_device *ipmi_device)
8990 +
8991 + INIT_LIST_HEAD(&ipmi_device->head);
8992 +
8993 +- mutex_init(&ipmi_device->tx_msg_lock);
8994 ++ spin_lock_init(&ipmi_device->tx_msg_lock);
8995 + INIT_LIST_HEAD(&ipmi_device->tx_msg_list);
8996 + ipmi_install_space_handler(ipmi_device);
8997 +
8998 +diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
8999 +index 51de186a8bfd..8176b82b2e4c 100644
9000 +--- a/drivers/acpi/ec.c
9001 ++++ b/drivers/acpi/ec.c
9002 +@@ -964,6 +964,10 @@ static struct dmi_system_id __initdata ec_dmi_table[] = {
9003 + ec_enlarge_storm_threshold, "CLEVO hardware", {
9004 + DMI_MATCH(DMI_SYS_VENDOR, "CLEVO Co."),
9005 + DMI_MATCH(DMI_PRODUCT_NAME, "M720T/M730T"),}, NULL},
9006 ++ {
9007 ++ ec_validate_ecdt, "ASUS hardware", {
9008 ++ DMI_MATCH(DMI_SYS_VENDOR, "ASUSTek Computer Inc."),
9009 ++ DMI_MATCH(DMI_PRODUCT_NAME, "L4R"),}, NULL},
9010 + {},
9011 + };
9012 +
9013 +diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
9014 +index d3446f628d54..d7ad86536b3e 100644
9015 +--- a/drivers/block/cciss.c
9016 ++++ b/drivers/block/cciss.c
9017 +@@ -1186,6 +1186,7 @@ static int cciss_ioctl32_passthru(struct block_device *bdev, fmode_t mode,
9018 + int err;
9019 + u32 cp;
9020 +
9021 ++ memset(&arg64, 0, sizeof(arg64));
9022 + err = 0;
9023 + err |=
9024 + copy_from_user(&arg64.LUN_info, &arg32->LUN_info,
9025 +diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
9026 +index 9125bbeacd4d..504bc16e4506 100644
9027 +--- a/drivers/block/cpqarray.c
9028 ++++ b/drivers/block/cpqarray.c
9029 +@@ -1195,6 +1195,7 @@ out_passthru:
9030 + ida_pci_info_struct pciinfo;
9031 +
9032 + if (!arg) return -EINVAL;
9033 ++ memset(&pciinfo, 0, sizeof(pciinfo));
9034 + pciinfo.bus = host->pci_dev->bus->number;
9035 + pciinfo.dev_fn = host->pci_dev->devfn;
9036 + pciinfo.board_id = host->board_id;
9037 +diff --git a/drivers/bluetooth/ath3k.c b/drivers/bluetooth/ath3k.c
9038 +index bde72f714789..3539f9b1e002 100644
9039 +--- a/drivers/bluetooth/ath3k.c
9040 ++++ b/drivers/bluetooth/ath3k.c
9041 +@@ -84,6 +84,7 @@ static struct usb_device_id ath3k_table[] = {
9042 + { USB_DEVICE(0x04CA, 0x3008) },
9043 + { USB_DEVICE(0x13d3, 0x3362) },
9044 + { USB_DEVICE(0x0CF3, 0xE004) },
9045 ++ { USB_DEVICE(0x0CF3, 0xE005) },
9046 + { USB_DEVICE(0x0930, 0x0219) },
9047 + { USB_DEVICE(0x0489, 0xe057) },
9048 + { USB_DEVICE(0x13d3, 0x3393) },
9049 +@@ -125,6 +126,7 @@ static struct usb_device_id ath3k_blist_tbl[] = {
9050 + { USB_DEVICE(0x04ca, 0x3008), .driver_info = BTUSB_ATH3012 },
9051 + { USB_DEVICE(0x13d3, 0x3362), .driver_info = BTUSB_ATH3012 },
9052 + { USB_DEVICE(0x0cf3, 0xe004), .driver_info = BTUSB_ATH3012 },
9053 ++ { USB_DEVICE(0x0cf3, 0xe005), .driver_info = BTUSB_ATH3012 },
9054 + { USB_DEVICE(0x0930, 0x0219), .driver_info = BTUSB_ATH3012 },
9055 + { USB_DEVICE(0x0489, 0xe057), .driver_info = BTUSB_ATH3012 },
9056 + { USB_DEVICE(0x13d3, 0x3393), .driver_info = BTUSB_ATH3012 },
9057 +diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
9058 +index 1bd3924c332a..f18b5a28f10c 100644
9059 +--- a/drivers/bluetooth/btusb.c
9060 ++++ b/drivers/bluetooth/btusb.c
9061 +@@ -108,6 +108,7 @@ static struct usb_device_id btusb_table[] = {
9062 +
9063 + /* Broadcom BCM20702A0 */
9064 + { USB_DEVICE(0x0b05, 0x17b5) },
9065 ++ { USB_DEVICE(0x0b05, 0x17cb) },
9066 + { USB_DEVICE(0x04ca, 0x2003) },
9067 + { USB_DEVICE(0x0489, 0xe042) },
9068 + { USB_DEVICE(0x413c, 0x8197) },
9069 +@@ -154,6 +155,7 @@ static struct usb_device_id blacklist_table[] = {
9070 + { USB_DEVICE(0x04ca, 0x3008), .driver_info = BTUSB_ATH3012 },
9071 + { USB_DEVICE(0x13d3, 0x3362), .driver_info = BTUSB_ATH3012 },
9072 + { USB_DEVICE(0x0cf3, 0xe004), .driver_info = BTUSB_ATH3012 },
9073 ++ { USB_DEVICE(0x0cf3, 0xe005), .driver_info = BTUSB_ATH3012 },
9074 + { USB_DEVICE(0x0930, 0x0219), .driver_info = BTUSB_ATH3012 },
9075 + { USB_DEVICE(0x0489, 0xe057), .driver_info = BTUSB_ATH3012 },
9076 + { USB_DEVICE(0x13d3, 0x3393), .driver_info = BTUSB_ATH3012 },
9077 +diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
9078 +index 7211f67d5bf4..72f460e22b76 100644
9079 +--- a/drivers/gpu/drm/drm_edid.c
9080 ++++ b/drivers/gpu/drm/drm_edid.c
9081 +@@ -125,6 +125,9 @@ static struct edid_quirk {
9082 +
9083 + /* ViewSonic VA2026w */
9084 + { "VSC", 5020, EDID_QUIRK_FORCE_REDUCED_BLANKING },
9085 ++
9086 ++ /* Medion MD 30217 PG */
9087 ++ { "MED", 0x7b8, EDID_QUIRK_PREFER_LARGE_75 },
9088 + };
9089 +
9090 + /*** DDC fetch and block validation ***/
9091 +diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
9092 +index a07ccab34016..72163e87f0da 100644
9093 +--- a/drivers/gpu/drm/i915/intel_dp.c
9094 ++++ b/drivers/gpu/drm/i915/intel_dp.c
9095 +@@ -621,7 +621,18 @@ intel_dp_i2c_aux_ch(struct i2c_adapter *adapter, int mode,
9096 + DRM_DEBUG_KMS("aux_ch native nack\n");
9097 + return -EREMOTEIO;
9098 + case AUX_NATIVE_REPLY_DEFER:
9099 +- udelay(100);
9100 ++ /*
9101 ++ * For now, just give more slack to branch devices. We
9102 ++ * could check the DPCD for I2C bit rate capabilities,
9103 ++ * and if available, adjust the interval. We could also
9104 ++ * be more careful with DP-to-Legacy adapters where a
9105 ++ * long legacy cable may force very low I2C bit rates.
9106 ++ */
9107 ++ if (intel_dp->dpcd[DP_DOWNSTREAMPORT_PRESENT] &
9108 ++ DP_DWN_STRM_PORT_PRESENT)
9109 ++ usleep_range(500, 600);
9110 ++ else
9111 ++ usleep_range(300, 400);
9112 + continue;
9113 + default:
9114 + DRM_ERROR("aux_ch invalid native reply 0x%02x\n",
9115 +diff --git a/drivers/gpu/drm/i915/intel_opregion.c b/drivers/gpu/drm/i915/intel_opregion.c
9116 +index cffb0071f877..356a252e6861 100644
9117 +--- a/drivers/gpu/drm/i915/intel_opregion.c
9118 ++++ b/drivers/gpu/drm/i915/intel_opregion.c
9119 +@@ -161,7 +161,7 @@ static u32 asle_set_backlight(struct drm_device *dev, u32 bclp)
9120 +
9121 + max = intel_panel_get_max_backlight(dev);
9122 + intel_panel_set_backlight(dev, bclp * max / 255);
9123 +- asle->cblv = (bclp*0x64)/0xff | ASLE_CBLV_VALID;
9124 ++ asle->cblv = DIV_ROUND_UP(bclp * 100, 255) | ASLE_CBLV_VALID;
9125 +
9126 + return 0;
9127 + }
9128 +diff --git a/drivers/gpu/drm/radeon/atombios_encoders.c b/drivers/gpu/drm/radeon/atombios_encoders.c
9129 +index f0dc04b3c70b..317129406451 100644
9130 +--- a/drivers/gpu/drm/radeon/atombios_encoders.c
9131 ++++ b/drivers/gpu/drm/radeon/atombios_encoders.c
9132 +@@ -1385,8 +1385,12 @@ radeon_atom_encoder_dpms_dig(struct drm_encoder *encoder, int mode)
9133 + atombios_dig_encoder_setup(encoder, ATOM_ENABLE, 0);
9134 + atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_SETUP, 0, 0);
9135 + atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_ENABLE, 0, 0);
9136 +- /* some early dce3.2 boards have a bug in their transmitter control table */
9137 +- if ((rdev->family != CHIP_RV710) && (rdev->family != CHIP_RV730))
9138 ++ /* some dce3.x boards have a bug in their transmitter control table.
9139 ++ * ACTION_ENABLE_OUTPUT can probably be dropped since ACTION_ENABLE
9140 ++ * does the same thing and more.
9141 ++ */
9142 ++ if ((rdev->family != CHIP_RV710) && (rdev->family != CHIP_RV730) &&
9143 ++ (rdev->family != CHIP_RS880))
9144 + atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_ENABLE_OUTPUT, 0, 0);
9145 + }
9146 + if (ENCODER_MODE_IS_DP(atombios_get_encoder_mode(encoder)) && connector) {
9147 +diff --git a/drivers/gpu/drm/radeon/evergreen.c b/drivers/gpu/drm/radeon/evergreen.c
9148 +index f5962a0832f9..a68057a03c6d 100644
9149 +--- a/drivers/gpu/drm/radeon/evergreen.c
9150 ++++ b/drivers/gpu/drm/radeon/evergreen.c
9151 +@@ -501,7 +501,8 @@ static u32 evergreen_line_buffer_adjust(struct radeon_device *rdev,
9152 + struct drm_display_mode *mode,
9153 + struct drm_display_mode *other_mode)
9154 + {
9155 +- u32 tmp;
9156 ++ u32 tmp, buffer_alloc, i;
9157 ++ u32 pipe_offset = radeon_crtc->crtc_id * 0x20;
9158 + /*
9159 + * Line Buffer Setup
9160 + * There are 3 line buffers, each one shared by 2 display controllers.
9161 +@@ -524,18 +525,34 @@ static u32 evergreen_line_buffer_adjust(struct radeon_device *rdev,
9162 + * non-linked crtcs for maximum line buffer allocation.
9163 + */
9164 + if (radeon_crtc->base.enabled && mode) {
9165 +- if (other_mode)
9166 ++ if (other_mode) {
9167 + tmp = 0; /* 1/2 */
9168 +- else
9169 ++ buffer_alloc = 1;
9170 ++ } else {
9171 + tmp = 2; /* whole */
9172 +- } else
9173 ++ buffer_alloc = 2;
9174 ++ }
9175 ++ } else {
9176 + tmp = 0;
9177 ++ buffer_alloc = 0;
9178 ++ }
9179 +
9180 + /* second controller of the pair uses second half of the lb */
9181 + if (radeon_crtc->crtc_id % 2)
9182 + tmp += 4;
9183 + WREG32(DC_LB_MEMORY_SPLIT + radeon_crtc->crtc_offset, tmp);
9184 +
9185 ++ if (ASIC_IS_DCE41(rdev) || ASIC_IS_DCE5(rdev)) {
9186 ++ WREG32(PIPE0_DMIF_BUFFER_CONTROL + pipe_offset,
9187 ++ DMIF_BUFFERS_ALLOCATED(buffer_alloc));
9188 ++ for (i = 0; i < rdev->usec_timeout; i++) {
9189 ++ if (RREG32(PIPE0_DMIF_BUFFER_CONTROL + pipe_offset) &
9190 ++ DMIF_BUFFERS_ALLOCATED_COMPLETED)
9191 ++ break;
9192 ++ udelay(1);
9193 ++ }
9194 ++ }
9195 ++
9196 + if (radeon_crtc->base.enabled && mode) {
9197 + switch (tmp) {
9198 + case 0:
9199 +diff --git a/drivers/gpu/drm/radeon/evergreend.h b/drivers/gpu/drm/radeon/evergreend.h
9200 +index fe44a953bac9..47f3bd2753f7 100644
9201 +--- a/drivers/gpu/drm/radeon/evergreend.h
9202 ++++ b/drivers/gpu/drm/radeon/evergreend.h
9203 +@@ -459,6 +459,10 @@
9204 + # define LATENCY_LOW_WATERMARK(x) ((x) << 0)
9205 + # define LATENCY_HIGH_WATERMARK(x) ((x) << 16)
9206 +
9207 ++#define PIPE0_DMIF_BUFFER_CONTROL 0x0ca0
9208 ++# define DMIF_BUFFERS_ALLOCATED(x) ((x) << 0)
9209 ++# define DMIF_BUFFERS_ALLOCATED_COMPLETED (1 << 4)
9210 ++
9211 + #define IH_RB_CNTL 0x3e00
9212 + # define IH_RB_ENABLE (1 << 0)
9213 + # define IH_IB_SIZE(x) ((x) << 1) /* log2 */
9214 +diff --git a/drivers/gpu/drm/radeon/radeon_atombios.c b/drivers/gpu/drm/radeon/radeon_atombios.c
9215 +index 383b38ebb048..cda89c6b74f8 100644
9216 +--- a/drivers/gpu/drm/radeon/radeon_atombios.c
9217 ++++ b/drivers/gpu/drm/radeon/radeon_atombios.c
9218 +@@ -709,13 +709,16 @@ bool radeon_get_atom_connector_info_from_object_table(struct drm_device *dev)
9219 + (ATOM_SRC_DST_TABLE_FOR_ONE_OBJECT *)
9220 + (ctx->bios + data_offset +
9221 + le16_to_cpu(router_obj->asObjects[k].usSrcDstTableOffset));
9222 ++ u8 *num_dst_objs = (u8 *)
9223 ++ ((u8 *)router_src_dst_table + 1 +
9224 ++ (router_src_dst_table->ucNumberOfSrc * 2));
9225 ++ u16 *dst_objs = (u16 *)(num_dst_objs + 1);
9226 + int enum_id;
9227 +
9228 + router.router_id = router_obj_id;
9229 +- for (enum_id = 0; enum_id < router_src_dst_table->ucNumberOfDst;
9230 +- enum_id++) {
9231 ++ for (enum_id = 0; enum_id < (*num_dst_objs); enum_id++) {
9232 + if (le16_to_cpu(path->usConnObjectId) ==
9233 +- le16_to_cpu(router_src_dst_table->usDstObjectID[enum_id]))
9234 ++ le16_to_cpu(dst_objs[enum_id]))
9235 + break;
9236 + }
9237 +
9238 +@@ -1616,7 +1619,9 @@ struct radeon_encoder_atom_dig *radeon_atombios_get_lvds_info(struct
9239 + kfree(edid);
9240 + }
9241 + }
9242 +- record += sizeof(ATOM_FAKE_EDID_PATCH_RECORD);
9243 ++ record += fake_edid_record->ucFakeEDIDLength ?
9244 ++ fake_edid_record->ucFakeEDIDLength + 2 :
9245 ++ sizeof(ATOM_FAKE_EDID_PATCH_RECORD);
9246 + break;
9247 + case LCD_PANEL_RESOLUTION_RECORD_TYPE:
9248 + panel_res_record = (ATOM_PANEL_RESOLUTION_PATCH_RECORD *)record;
9249 +diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c b/drivers/gpu/drm/radeon/radeon_connectors.c
9250 +index 6fd53b644dfc..b101843bff73 100644
9251 +--- a/drivers/gpu/drm/radeon/radeon_connectors.c
9252 ++++ b/drivers/gpu/drm/radeon/radeon_connectors.c
9253 +@@ -1387,6 +1387,24 @@ struct drm_connector_funcs radeon_dp_connector_funcs = {
9254 + .force = radeon_dvi_force,
9255 + };
9256 +
9257 ++static const struct drm_connector_funcs radeon_edp_connector_funcs = {
9258 ++ .dpms = drm_helper_connector_dpms,
9259 ++ .detect = radeon_dp_detect,
9260 ++ .fill_modes = drm_helper_probe_single_connector_modes,
9261 ++ .set_property = radeon_lvds_set_property,
9262 ++ .destroy = radeon_dp_connector_destroy,
9263 ++ .force = radeon_dvi_force,
9264 ++};
9265 ++
9266 ++static const struct drm_connector_funcs radeon_lvds_bridge_connector_funcs = {
9267 ++ .dpms = drm_helper_connector_dpms,
9268 ++ .detect = radeon_dp_detect,
9269 ++ .fill_modes = drm_helper_probe_single_connector_modes,
9270 ++ .set_property = radeon_lvds_set_property,
9271 ++ .destroy = radeon_dp_connector_destroy,
9272 ++ .force = radeon_dvi_force,
9273 ++};
9274 ++
9275 + void
9276 + radeon_add_atom_connector(struct drm_device *dev,
9277 + uint32_t connector_id,
9278 +@@ -1478,8 +1496,6 @@ radeon_add_atom_connector(struct drm_device *dev,
9279 + goto failed;
9280 + radeon_dig_connector->igp_lane_info = igp_lane_info;
9281 + radeon_connector->con_priv = radeon_dig_connector;
9282 +- drm_connector_init(dev, &radeon_connector->base, &radeon_dp_connector_funcs, connector_type);
9283 +- drm_connector_helper_add(&radeon_connector->base, &radeon_dp_connector_helper_funcs);
9284 + if (i2c_bus->valid) {
9285 + /* add DP i2c bus */
9286 + if (connector_type == DRM_MODE_CONNECTOR_eDP)
9287 +@@ -1496,6 +1512,10 @@ radeon_add_atom_connector(struct drm_device *dev,
9288 + case DRM_MODE_CONNECTOR_VGA:
9289 + case DRM_MODE_CONNECTOR_DVIA:
9290 + default:
9291 ++ drm_connector_init(dev, &radeon_connector->base,
9292 ++ &radeon_dp_connector_funcs, connector_type);
9293 ++ drm_connector_helper_add(&radeon_connector->base,
9294 ++ &radeon_dp_connector_helper_funcs);
9295 + connector->interlace_allowed = true;
9296 + connector->doublescan_allowed = true;
9297 + radeon_connector->dac_load_detect = true;
9298 +@@ -1508,6 +1528,10 @@ radeon_add_atom_connector(struct drm_device *dev,
9299 + case DRM_MODE_CONNECTOR_HDMIA:
9300 + case DRM_MODE_CONNECTOR_HDMIB:
9301 + case DRM_MODE_CONNECTOR_DisplayPort:
9302 ++ drm_connector_init(dev, &radeon_connector->base,
9303 ++ &radeon_dp_connector_funcs, connector_type);
9304 ++ drm_connector_helper_add(&radeon_connector->base,
9305 ++ &radeon_dp_connector_helper_funcs);
9306 + drm_connector_attach_property(&radeon_connector->base,
9307 + rdev->mode_info.underscan_property,
9308 + UNDERSCAN_OFF);
9309 +@@ -1532,6 +1556,10 @@ radeon_add_atom_connector(struct drm_device *dev,
9310 + break;
9311 + case DRM_MODE_CONNECTOR_LVDS:
9312 + case DRM_MODE_CONNECTOR_eDP:
9313 ++ drm_connector_init(dev, &radeon_connector->base,
9314 ++ &radeon_lvds_bridge_connector_funcs, connector_type);
9315 ++ drm_connector_helper_add(&radeon_connector->base,
9316 ++ &radeon_dp_connector_helper_funcs);
9317 + drm_connector_attach_property(&radeon_connector->base,
9318 + dev->mode_config.scaling_mode_property,
9319 + DRM_MODE_SCALE_FULLSCREEN);
9320 +@@ -1695,7 +1723,7 @@ radeon_add_atom_connector(struct drm_device *dev,
9321 + goto failed;
9322 + radeon_dig_connector->igp_lane_info = igp_lane_info;
9323 + radeon_connector->con_priv = radeon_dig_connector;
9324 +- drm_connector_init(dev, &radeon_connector->base, &radeon_dp_connector_funcs, connector_type);
9325 ++ drm_connector_init(dev, &radeon_connector->base, &radeon_edp_connector_funcs, connector_type);
9326 + drm_connector_helper_add(&radeon_connector->base, &radeon_dp_connector_helper_funcs);
9327 + if (i2c_bus->valid) {
9328 + /* add DP i2c bus */
9329 +diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
9330 +index cd94abb1d776..8cde84b666d5 100644
9331 +--- a/drivers/gpu/drm/radeon/radeon_device.c
9332 ++++ b/drivers/gpu/drm/radeon/radeon_device.c
9333 +@@ -818,10 +818,16 @@ int radeon_device_init(struct radeon_device *rdev,
9334 + return r;
9335 + }
9336 + if (radeon_testing) {
9337 +- radeon_test_moves(rdev);
9338 ++ if (rdev->accel_working)
9339 ++ radeon_test_moves(rdev);
9340 ++ else
9341 ++ DRM_INFO("radeon: acceleration disabled, skipping move tests\n");
9342 + }
9343 + if (radeon_benchmarking) {
9344 +- radeon_benchmark(rdev, radeon_benchmarking);
9345 ++ if (rdev->accel_working)
9346 ++ radeon_benchmark(rdev, radeon_benchmarking);
9347 ++ else
9348 ++ DRM_INFO("radeon: acceleration disabled, skipping benchmarks\n");
9349 + }
9350 + return 0;
9351 + }
9352 +diff --git a/drivers/gpu/drm/radeon/rs400.c b/drivers/gpu/drm/radeon/rs400.c
9353 +index 4dd9512fcc5d..c0874341b1a0 100644
9354 +--- a/drivers/gpu/drm/radeon/rs400.c
9355 ++++ b/drivers/gpu/drm/radeon/rs400.c
9356 +@@ -174,10 +174,13 @@ int rs400_gart_enable(struct radeon_device *rdev)
9357 + /* FIXME: according to doc we should set HIDE_MMCFG_BAR=0,
9358 + * AGPMODE30=0 & AGP30ENHANCED=0 in NB_CNTL */
9359 + if ((rdev->family == CHIP_RS690) || (rdev->family == CHIP_RS740)) {
9360 +- WREG32_MC(RS480_MC_MISC_CNTL,
9361 +- (RS480_GART_INDEX_REG_EN | RS690_BLOCK_GFX_D3_EN));
9362 ++ tmp = RREG32_MC(RS480_MC_MISC_CNTL);
9363 ++ tmp |= RS480_GART_INDEX_REG_EN | RS690_BLOCK_GFX_D3_EN;
9364 ++ WREG32_MC(RS480_MC_MISC_CNTL, tmp);
9365 + } else {
9366 +- WREG32_MC(RS480_MC_MISC_CNTL, RS480_GART_INDEX_REG_EN);
9367 ++ tmp = RREG32_MC(RS480_MC_MISC_CNTL);
9368 ++ tmp |= RS480_GART_INDEX_REG_EN;
9369 ++ WREG32_MC(RS480_MC_MISC_CNTL, tmp);
9370 + }
9371 + /* Enable gart */
9372 + WREG32_MC(RS480_AGP_ADDRESS_SPACE_SIZE, (RS480_GART_EN | size_reg));
9373 +diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
9374 +index 611aafc20f90..9ac4389ecfa2 100644
9375 +--- a/drivers/hid/hid-core.c
9376 ++++ b/drivers/hid/hid-core.c
9377 +@@ -59,6 +59,8 @@ struct hid_report *hid_register_report(struct hid_device *device, unsigned type,
9378 + struct hid_report_enum *report_enum = device->report_enum + type;
9379 + struct hid_report *report;
9380 +
9381 ++ if (id >= HID_MAX_IDS)
9382 ++ return NULL;
9383 + if (report_enum->report_id_hash[id])
9384 + return report_enum->report_id_hash[id];
9385 +
9386 +@@ -216,9 +218,9 @@ static int hid_add_field(struct hid_parser *parser, unsigned report_type, unsign
9387 + {
9388 + struct hid_report *report;
9389 + struct hid_field *field;
9390 +- int usages;
9391 ++ unsigned usages;
9392 + unsigned offset;
9393 +- int i;
9394 ++ unsigned i;
9395 +
9396 + report = hid_register_report(parser->device, report_type, parser->global.report_id);
9397 + if (!report) {
9398 +@@ -237,7 +239,8 @@ static int hid_add_field(struct hid_parser *parser, unsigned report_type, unsign
9399 + if (!parser->local.usage_index) /* Ignore padding fields */
9400 + return 0;
9401 +
9402 +- usages = max_t(int, parser->local.usage_index, parser->global.report_count);
9403 ++ usages = max_t(unsigned, parser->local.usage_index,
9404 ++ parser->global.report_count);
9405 +
9406 + field = hid_register_field(report, usages, parser->global.report_count);
9407 + if (!field)
9408 +@@ -248,7 +251,7 @@ static int hid_add_field(struct hid_parser *parser, unsigned report_type, unsign
9409 + field->application = hid_lookup_collection(parser, HID_COLLECTION_APPLICATION);
9410 +
9411 + for (i = 0; i < usages; i++) {
9412 +- int j = i;
9413 ++ unsigned j = i;
9414 + /* Duplicate the last usage we parsed if we have excess values */
9415 + if (i >= parser->local.usage_index)
9416 + j = parser->local.usage_index - 1;
9417 +@@ -380,8 +383,10 @@ static int hid_parser_global(struct hid_parser *parser, struct hid_item *item)
9418 +
9419 + case HID_GLOBAL_ITEM_TAG_REPORT_ID:
9420 + parser->global.report_id = item_udata(item);
9421 +- if (parser->global.report_id == 0) {
9422 +- dbg_hid("report_id 0 is invalid\n");
9423 ++ if (parser->global.report_id == 0 ||
9424 ++ parser->global.report_id >= HID_MAX_IDS) {
9425 ++ dbg_hid("report_id %u is invalid\n",
9426 ++ parser->global.report_id);
9427 + return -1;
9428 + }
9429 + return 0;
9430 +@@ -552,7 +557,7 @@ static void hid_device_release(struct device *dev)
9431 + for (i = 0; i < HID_REPORT_TYPES; i++) {
9432 + struct hid_report_enum *report_enum = device->report_enum + i;
9433 +
9434 +- for (j = 0; j < 256; j++) {
9435 ++ for (j = 0; j < HID_MAX_IDS; j++) {
9436 + struct hid_report *report = report_enum->report_id_hash[j];
9437 + if (report)
9438 + hid_free_report(report);
9439 +@@ -710,6 +715,64 @@ err:
9440 + }
9441 + EXPORT_SYMBOL_GPL(hid_parse_report);
9442 +
9443 ++static const char * const hid_report_names[] = {
9444 ++ "HID_INPUT_REPORT",
9445 ++ "HID_OUTPUT_REPORT",
9446 ++ "HID_FEATURE_REPORT",
9447 ++};
9448 ++/**
9449 ++ * hid_validate_values - validate existing device report's value indexes
9450 ++ *
9451 ++ * @device: hid device
9452 ++ * @type: which report type to examine
9453 ++ * @id: which report ID to examine (0 for first)
9454 ++ * @field_index: which report field to examine
9455 ++ * @report_counts: expected number of values
9456 ++ *
9457 ++ * Validate the number of values in a given field of a given report, after
9458 ++ * parsing.
9459 ++ */
9460 ++struct hid_report *hid_validate_values(struct hid_device *hid,
9461 ++ unsigned int type, unsigned int id,
9462 ++ unsigned int field_index,
9463 ++ unsigned int report_counts)
9464 ++{
9465 ++ struct hid_report *report;
9466 ++
9467 ++ if (type > HID_FEATURE_REPORT) {
9468 ++ hid_err(hid, "invalid HID report type %u\n", type);
9469 ++ return NULL;
9470 ++ }
9471 ++
9472 ++ if (id >= HID_MAX_IDS) {
9473 ++ hid_err(hid, "invalid HID report id %u\n", id);
9474 ++ return NULL;
9475 ++ }
9476 ++
9477 ++ /*
9478 ++ * Explicitly not using hid_get_report() here since it depends on
9479 ++ * ->numbered being checked, which may not always be the case when
9480 ++ * drivers go to access report values.
9481 ++ */
9482 ++ report = hid->report_enum[type].report_id_hash[id];
9483 ++ if (!report) {
9484 ++ hid_err(hid, "missing %s %u\n", hid_report_names[type], id);
9485 ++ return NULL;
9486 ++ }
9487 ++ if (report->maxfield <= field_index) {
9488 ++ hid_err(hid, "not enough fields in %s %u\n",
9489 ++ hid_report_names[type], id);
9490 ++ return NULL;
9491 ++ }
9492 ++ if (report->field[field_index]->report_count < report_counts) {
9493 ++ hid_err(hid, "not enough values in %s %u field %u\n",
9494 ++ hid_report_names[type], id, field_index);
9495 ++ return NULL;
9496 ++ }
9497 ++ return report;
9498 ++}
9499 ++EXPORT_SYMBOL_GPL(hid_validate_values);
9500 ++
9501 + /*
9502 + * Convert a signed n-bit integer to signed 32-bit integer. Common
9503 + * cases are done through the compiler, the screwed things has to be
9504 +@@ -990,7 +1053,12 @@ EXPORT_SYMBOL_GPL(hid_output_report);
9505 +
9506 + int hid_set_field(struct hid_field *field, unsigned offset, __s32 value)
9507 + {
9508 +- unsigned size = field->report_size;
9509 ++ unsigned size;
9510 ++
9511 ++ if (!field)
9512 ++ return -1;
9513 ++
9514 ++ size = field->report_size;
9515 +
9516 + hid_dump_input(field->report->device, field->usage + offset, value);
9517 +
9518 +diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
9519 +index 08075f274339..ca2b3e6c4e9f 100644
9520 +--- a/drivers/hid/hid-ids.h
9521 ++++ b/drivers/hid/hid-ids.h
9522 +@@ -581,6 +581,7 @@
9523 + #define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_16 0x0012
9524 + #define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_17 0x0013
9525 + #define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_18 0x0014
9526 ++#define USB_DEVICE_ID_NTRIG_DUOSENSE 0x1500
9527 +
9528 + #define USB_VENDOR_ID_ONTRAK 0x0a07
9529 + #define USB_DEVICE_ID_ONTRAK_ADU100 0x0064
9530 +diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
9531 +index f333139d1a48..95c79a365c98 100644
9532 +--- a/drivers/hid/hid-input.c
9533 ++++ b/drivers/hid/hid-input.c
9534 +@@ -284,6 +284,10 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
9535 + if (field->flags & HID_MAIN_ITEM_CONSTANT)
9536 + goto ignore;
9537 +
9538 ++ /* Ignore if report count is out of bounds. */
9539 ++ if (field->report_count < 1)
9540 ++ goto ignore;
9541 ++
9542 + /* only LED usages are supported in output fields */
9543 + if (field->report_type == HID_OUTPUT_REPORT &&
9544 + (usage->hid & HID_USAGE_PAGE) != HID_UP_LED) {
9545 +@@ -887,10 +891,15 @@ static void report_features(struct hid_device *hid)
9546 +
9547 + rep_enum = &hid->report_enum[HID_FEATURE_REPORT];
9548 + list_for_each_entry(rep, &rep_enum->report_list, list)
9549 +- for (i = 0; i < rep->maxfield; i++)
9550 ++ for (i = 0; i < rep->maxfield; i++) {
9551 ++ /* Ignore if report count is out of bounds. */
9552 ++ if (rep->field[i]->report_count < 1)
9553 ++ continue;
9554 ++
9555 + for (j = 0; j < rep->field[i]->maxusage; j++)
9556 + drv->feature_mapping(hid, rep->field[i],
9557 + rep->field[i]->usage + j);
9558 ++ }
9559 + }
9560 +
9561 + /*
9562 +diff --git a/drivers/hid/hid-lg2ff.c b/drivers/hid/hid-lg2ff.c
9563 +index 3c31bc650e5d..128f0117c7a7 100644
9564 +--- a/drivers/hid/hid-lg2ff.c
9565 ++++ b/drivers/hid/hid-lg2ff.c
9566 +@@ -66,26 +66,13 @@ int lg2ff_init(struct hid_device *hid)
9567 + struct hid_report *report;
9568 + struct hid_input *hidinput = list_entry(hid->inputs.next,
9569 + struct hid_input, list);
9570 +- struct list_head *report_list =
9571 +- &hid->report_enum[HID_OUTPUT_REPORT].report_list;
9572 + struct input_dev *dev = hidinput->input;
9573 + int error;
9574 +
9575 +- if (list_empty(report_list)) {
9576 +- hid_err(hid, "no output report found\n");
9577 ++ /* Check that the report looks ok */
9578 ++ report = hid_validate_values(hid, HID_OUTPUT_REPORT, 0, 0, 7);
9579 ++ if (!report)
9580 + return -ENODEV;
9581 +- }
9582 +-
9583 +- report = list_entry(report_list->next, struct hid_report, list);
9584 +-
9585 +- if (report->maxfield < 1) {
9586 +- hid_err(hid, "output report is empty\n");
9587 +- return -ENODEV;
9588 +- }
9589 +- if (report->field[0]->report_count < 7) {
9590 +- hid_err(hid, "not enough values in the field\n");
9591 +- return -ENODEV;
9592 +- }
9593 +
9594 + lg2ff = kmalloc(sizeof(struct lg2ff_device), GFP_KERNEL);
9595 + if (!lg2ff)
9596 +diff --git a/drivers/hid/hid-lg3ff.c b/drivers/hid/hid-lg3ff.c
9597 +index f98644c26c1d..91f981ff5601 100644
9598 +--- a/drivers/hid/hid-lg3ff.c
9599 ++++ b/drivers/hid/hid-lg3ff.c
9600 +@@ -68,10 +68,11 @@ static int hid_lg3ff_play(struct input_dev *dev, void *data,
9601 + int x, y;
9602 +
9603 + /*
9604 +- * Maxusage should always be 63 (maximum fields)
9605 +- * likely a better way to ensure this data is clean
9606 ++ * Available values in the field should always be 63, but we only use up to
9607 ++ * 35. Instead, clear the entire area, however big it is.
9608 + */
9609 +- memset(report->field[0]->value, 0, sizeof(__s32)*report->field[0]->maxusage);
9610 ++ memset(report->field[0]->value, 0,
9611 ++ sizeof(__s32) * report->field[0]->report_count);
9612 +
9613 + switch (effect->type) {
9614 + case FF_CONSTANT:
9615 +@@ -131,32 +132,14 @@ static const signed short ff3_joystick_ac[] = {
9616 + int lg3ff_init(struct hid_device *hid)
9617 + {
9618 + struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list);
9619 +- struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list;
9620 + struct input_dev *dev = hidinput->input;
9621 +- struct hid_report *report;
9622 +- struct hid_field *field;
9623 + const signed short *ff_bits = ff3_joystick_ac;
9624 + int error;
9625 + int i;
9626 +
9627 +- /* Find the report to use */
9628 +- if (list_empty(report_list)) {
9629 +- hid_err(hid, "No output report found\n");
9630 +- return -1;
9631 +- }
9632 +-
9633 + /* Check that the report looks ok */
9634 +- report = list_entry(report_list->next, struct hid_report, list);
9635 +- if (!report) {
9636 +- hid_err(hid, "NULL output report\n");
9637 +- return -1;
9638 +- }
9639 +-
9640 +- field = report->field[0];
9641 +- if (!field) {
9642 +- hid_err(hid, "NULL field\n");
9643 +- return -1;
9644 +- }
9645 ++ if (!hid_validate_values(hid, HID_OUTPUT_REPORT, 0, 0, 35))
9646 ++ return -ENODEV;
9647 +
9648 + /* Assume single fixed device G940 */
9649 + for (i = 0; ff_bits[i] >= 0; i++)
9650 +diff --git a/drivers/hid/hid-lg4ff.c b/drivers/hid/hid-lg4ff.c
9651 +index 103f30d93f76..5c6bf4b5c533 100644
9652 +--- a/drivers/hid/hid-lg4ff.c
9653 ++++ b/drivers/hid/hid-lg4ff.c
9654 +@@ -339,33 +339,15 @@ static ssize_t lg4ff_range_store(struct device *dev, struct device_attribute *at
9655 + int lg4ff_init(struct hid_device *hid)
9656 + {
9657 + struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list);
9658 +- struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list;
9659 + struct input_dev *dev = hidinput->input;
9660 +- struct hid_report *report;
9661 +- struct hid_field *field;
9662 + struct lg4ff_device_entry *entry;
9663 + struct usb_device_descriptor *udesc;
9664 + int error, i, j;
9665 + __u16 bcdDevice, rev_maj, rev_min;
9666 +
9667 +- /* Find the report to use */
9668 +- if (list_empty(report_list)) {
9669 +- hid_err(hid, "No output report found\n");
9670 +- return -1;
9671 +- }
9672 +-
9673 + /* Check that the report looks ok */
9674 +- report = list_entry(report_list->next, struct hid_report, list);
9675 +- if (!report) {
9676 +- hid_err(hid, "NULL output report\n");
9677 ++ if (!hid_validate_values(hid, HID_OUTPUT_REPORT, 0, 0, 7))
9678 + return -1;
9679 +- }
9680 +-
9681 +- field = report->field[0];
9682 +- if (!field) {
9683 +- hid_err(hid, "NULL field\n");
9684 +- return -1;
9685 +- }
9686 +
9687 + /* Check what wheel has been connected */
9688 + for (i = 0; i < ARRAY_SIZE(lg4ff_devices); i++) {
9689 +diff --git a/drivers/hid/hid-lgff.c b/drivers/hid/hid-lgff.c
9690 +index 27bc54f92f44..1d978daa70d7 100644
9691 +--- a/drivers/hid/hid-lgff.c
9692 ++++ b/drivers/hid/hid-lgff.c
9693 +@@ -130,27 +130,14 @@ static void hid_lgff_set_autocenter(struct input_dev *dev, u16 magnitude)
9694 + int lgff_init(struct hid_device* hid)
9695 + {
9696 + struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list);
9697 +- struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list;
9698 + struct input_dev *dev = hidinput->input;
9699 +- struct hid_report *report;
9700 +- struct hid_field *field;
9701 + const signed short *ff_bits = ff_joystick;
9702 + int error;
9703 + int i;
9704 +
9705 +- /* Find the report to use */
9706 +- if (list_empty(report_list)) {
9707 +- hid_err(hid, "No output report found\n");
9708 +- return -1;
9709 +- }
9710 +-
9711 + /* Check that the report looks ok */
9712 +- report = list_entry(report_list->next, struct hid_report, list);
9713 +- field = report->field[0];
9714 +- if (!field) {
9715 +- hid_err(hid, "NULL field\n");
9716 +- return -1;
9717 +- }
9718 ++ if (!hid_validate_values(hid, HID_OUTPUT_REPORT, 0, 0, 7))
9719 ++ return -ENODEV;
9720 +
9721 + for (i = 0; i < ARRAY_SIZE(devices); i++) {
9722 + if (dev->id.vendor == devices[i].idVendor &&
9723 +diff --git a/drivers/hid/hid-logitech-dj.c b/drivers/hid/hid-logitech-dj.c
9724 +index 8821ecc9751f..828a0dd2a5ab 100644
9725 +--- a/drivers/hid/hid-logitech-dj.c
9726 ++++ b/drivers/hid/hid-logitech-dj.c
9727 +@@ -791,6 +791,12 @@ static int logi_dj_probe(struct hid_device *hdev,
9728 + goto hid_parse_fail;
9729 + }
9730 +
9731 ++ if (!hid_validate_values(hdev, HID_OUTPUT_REPORT, REPORT_ID_DJ_SHORT,
9732 ++ 0, DJREPORT_SHORT_LENGTH - 1)) {
9733 ++ retval = -ENODEV;
9734 ++ goto hid_parse_fail;
9735 ++ }
9736 ++
9737 + /* Starts the usb device and connects to upper interfaces hiddev and
9738 + * hidraw */
9739 + retval = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
9740 +diff --git a/drivers/hid/hid-ntrig.c b/drivers/hid/hid-ntrig.c
9741 +index 9fae2ebdd758..48cba8570469 100644
9742 +--- a/drivers/hid/hid-ntrig.c
9743 ++++ b/drivers/hid/hid-ntrig.c
9744 +@@ -115,7 +115,8 @@ static inline int ntrig_get_mode(struct hid_device *hdev)
9745 + struct hid_report *report = hdev->report_enum[HID_FEATURE_REPORT].
9746 + report_id_hash[0x0d];
9747 +
9748 +- if (!report)
9749 ++ if (!report || report->maxfield < 1 ||
9750 ++ report->field[0]->report_count < 1)
9751 + return -EINVAL;
9752 +
9753 + usbhid_submit_report(hdev, report, USB_DIR_IN);
9754 +diff --git a/drivers/hid/hid-picolcd.c b/drivers/hid/hid-picolcd.c
9755 +index 01e7d2cd7c26..1daeacabc832 100644
9756 +--- a/drivers/hid/hid-picolcd.c
9757 ++++ b/drivers/hid/hid-picolcd.c
9758 +@@ -1424,7 +1424,7 @@ static ssize_t picolcd_operation_mode_store(struct device *dev,
9759 + buf += 10;
9760 + cnt -= 10;
9761 + }
9762 +- if (!report)
9763 ++ if (!report || report->maxfield != 1)
9764 + return -EINVAL;
9765 +
9766 + while (cnt > 0 && (buf[cnt-1] == '\n' || buf[cnt-1] == '\r'))
9767 +diff --git a/drivers/hid/hid-pl.c b/drivers/hid/hid-pl.c
9768 +index 070f93a5c11b..12786cdcbedd 100644
9769 +--- a/drivers/hid/hid-pl.c
9770 ++++ b/drivers/hid/hid-pl.c
9771 +@@ -129,8 +129,14 @@ static int plff_init(struct hid_device *hid)
9772 + strong = &report->field[0]->value[2];
9773 + weak = &report->field[0]->value[3];
9774 + debug("detected single-field device");
9775 +- } else if (report->maxfield >= 4 && report->field[0]->maxusage == 1 &&
9776 +- report->field[0]->usage[0].hid == (HID_UP_LED | 0x43)) {
9777 ++ } else if (report->field[0]->maxusage == 1 &&
9778 ++ report->field[0]->usage[0].hid ==
9779 ++ (HID_UP_LED | 0x43) &&
9780 ++ report->maxfield >= 4 &&
9781 ++ report->field[0]->report_count >= 1 &&
9782 ++ report->field[1]->report_count >= 1 &&
9783 ++ report->field[2]->report_count >= 1 &&
9784 ++ report->field[3]->report_count >= 1) {
9785 + report->field[0]->value[0] = 0x00;
9786 + report->field[1]->value[0] = 0x00;
9787 + strong = &report->field[2]->value[0];
9788 +diff --git a/drivers/hid/hid-speedlink.c b/drivers/hid/hid-speedlink.c
9789 +index 602013741718..2b03c9baac35 100644
9790 +--- a/drivers/hid/hid-speedlink.c
9791 ++++ b/drivers/hid/hid-speedlink.c
9792 +@@ -3,7 +3,7 @@
9793 + * Fixes "jumpy" cursor and removes nonexistent keyboard LEDS from
9794 + * the HID descriptor.
9795 + *
9796 +- * Copyright (c) 2011 Stefan Kriwanek <mail@××××××××××××××.de>
9797 ++ * Copyright (c) 2011, 2013 Stefan Kriwanek <dev@××××××××××××××.de>
9798 + */
9799 +
9800 + /*
9801 +@@ -48,8 +48,13 @@ static int speedlink_event(struct hid_device *hdev, struct hid_field *field,
9802 + struct hid_usage *usage, __s32 value)
9803 + {
9804 + /* No other conditions due to usage_table. */
9805 +- /* Fix "jumpy" cursor (invalid events sent by device). */
9806 +- if (value == 256)
9807 ++
9808 ++ /* This fixes the "jumpy" cursor occuring due to invalid events sent
9809 ++ * by the device. Some devices only send them with value==+256, others
9810 ++ * don't. However, catching abs(value)>=256 is restrictive enough not
9811 ++ * to interfere with devices that were bug-free (has been tested).
9812 ++ */
9813 ++ if (abs(value) >= 256)
9814 + return 1;
9815 + /* Drop useless distance 0 events (on button clicks etc.) as well */
9816 + if (value == 0)
9817 +diff --git a/drivers/hid/hid-zpff.c b/drivers/hid/hid-zpff.c
9818 +index f6ba81df71bd..f348f7f6526b 100644
9819 +--- a/drivers/hid/hid-zpff.c
9820 ++++ b/drivers/hid/hid-zpff.c
9821 +@@ -70,21 +70,13 @@ static int zpff_init(struct hid_device *hid)
9822 + struct hid_report *report;
9823 + struct hid_input *hidinput = list_entry(hid->inputs.next,
9824 + struct hid_input, list);
9825 +- struct list_head *report_list =
9826 +- &hid->report_enum[HID_OUTPUT_REPORT].report_list;
9827 + struct input_dev *dev = hidinput->input;
9828 +- int error;
9829 ++ int i, error;
9830 +
9831 +- if (list_empty(report_list)) {
9832 +- hid_err(hid, "no output report found\n");
9833 +- return -ENODEV;
9834 +- }
9835 +-
9836 +- report = list_entry(report_list->next, struct hid_report, list);
9837 +-
9838 +- if (report->maxfield < 4) {
9839 +- hid_err(hid, "not enough fields in report\n");
9840 +- return -ENODEV;
9841 ++ for (i = 0; i < 4; i++) {
9842 ++ report = hid_validate_values(hid, HID_OUTPUT_REPORT, 0, i, 1);
9843 ++ if (!report)
9844 ++ return -ENODEV;
9845 + }
9846 +
9847 + zpff = kzalloc(sizeof(struct zpff_device), GFP_KERNEL);
9848 +diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c
9849 +index 17d15bb610d1..9e50f61933c4 100644
9850 +--- a/drivers/hid/hidraw.c
9851 ++++ b/drivers/hid/hidraw.c
9852 +@@ -42,7 +42,6 @@ static struct cdev hidraw_cdev;
9853 + static struct class *hidraw_class;
9854 + static struct hidraw *hidraw_table[HIDRAW_MAX_DEVICES];
9855 + static DEFINE_MUTEX(minors_lock);
9856 +-static void drop_ref(struct hidraw *hid, int exists_bit);
9857 +
9858 + static ssize_t hidraw_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos)
9859 + {
9860 +@@ -296,14 +295,37 @@ out:
9861 +
9862 + }
9863 +
9864 ++static void drop_ref(struct hidraw *hidraw, int exists_bit)
9865 ++{
9866 ++ if (exists_bit) {
9867 ++ hid_hw_close(hidraw->hid);
9868 ++ hidraw->exist = 0;
9869 ++ if (hidraw->open)
9870 ++ wake_up_interruptible(&hidraw->wait);
9871 ++ } else {
9872 ++ --hidraw->open;
9873 ++ }
9874 ++
9875 ++ if (!hidraw->open && !hidraw->exist) {
9876 ++ device_destroy(hidraw_class, MKDEV(hidraw_major, hidraw->minor));
9877 ++ hidraw_table[hidraw->minor] = NULL;
9878 ++ kfree(hidraw);
9879 ++ }
9880 ++}
9881 ++
9882 + static int hidraw_release(struct inode * inode, struct file * file)
9883 + {
9884 + unsigned int minor = iminor(inode);
9885 + struct hidraw_list *list = file->private_data;
9886 +
9887 +- drop_ref(hidraw_table[minor], 0);
9888 ++ mutex_lock(&minors_lock);
9889 ++
9890 + list_del(&list->node);
9891 + kfree(list);
9892 ++
9893 ++ drop_ref(hidraw_table[minor], 0);
9894 ++
9895 ++ mutex_unlock(&minors_lock);
9896 + return 0;
9897 + }
9898 +
9899 +@@ -506,7 +528,12 @@ EXPORT_SYMBOL_GPL(hidraw_connect);
9900 + void hidraw_disconnect(struct hid_device *hid)
9901 + {
9902 + struct hidraw *hidraw = hid->hidraw;
9903 ++
9904 ++ mutex_lock(&minors_lock);
9905 ++
9906 + drop_ref(hidraw, 1);
9907 ++
9908 ++ mutex_unlock(&minors_lock);
9909 + }
9910 + EXPORT_SYMBOL_GPL(hidraw_disconnect);
9911 +
9912 +@@ -555,23 +582,3 @@ void hidraw_exit(void)
9913 + unregister_chrdev_region(dev_id, HIDRAW_MAX_DEVICES);
9914 +
9915 + }
9916 +-
9917 +-static void drop_ref(struct hidraw *hidraw, int exists_bit)
9918 +-{
9919 +- mutex_lock(&minors_lock);
9920 +- if (exists_bit) {
9921 +- hid_hw_close(hidraw->hid);
9922 +- hidraw->exist = 0;
9923 +- if (hidraw->open)
9924 +- wake_up_interruptible(&hidraw->wait);
9925 +- } else {
9926 +- --hidraw->open;
9927 +- }
9928 +-
9929 +- if (!hidraw->open && !hidraw->exist) {
9930 +- device_destroy(hidraw_class, MKDEV(hidraw_major, hidraw->minor));
9931 +- hidraw_table[hidraw->minor] = NULL;
9932 +- kfree(hidraw);
9933 +- }
9934 +- mutex_unlock(&minors_lock);
9935 +-}
9936 +diff --git a/drivers/hid/usbhid/hid-quirks.c b/drivers/hid/usbhid/hid-quirks.c
9937 +index 96a1e0f70724..f98fbad966e7 100644
9938 +--- a/drivers/hid/usbhid/hid-quirks.c
9939 ++++ b/drivers/hid/usbhid/hid-quirks.c
9940 +@@ -99,6 +99,8 @@ static const struct hid_blacklist {
9941 + { USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_MULTI_TOUCH, HID_QUIRK_MULTI_INPUT },
9942 + { USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_WIRELESS, HID_QUIRK_MULTI_INPUT },
9943 + { USB_VENDOR_ID_SIGMA_MICRO, USB_DEVICE_ID_SIGMA_MICRO_KEYBOARD, HID_QUIRK_NO_INIT_REPORTS },
9944 ++ { USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_DUOSENSE, HID_QUIRK_NO_INIT_REPORTS },
9945 ++
9946 + { 0, 0 }
9947 + };
9948 +
9949 +diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
9950 +index d99aa8484777..30cac58422b7 100644
9951 +--- a/drivers/hwmon/applesmc.c
9952 ++++ b/drivers/hwmon/applesmc.c
9953 +@@ -344,8 +344,10 @@ static int applesmc_get_lower_bound(unsigned int *lo, const char *key)
9954 + while (begin != end) {
9955 + int middle = begin + (end - begin) / 2;
9956 + entry = applesmc_get_entry_by_index(middle);
9957 +- if (IS_ERR(entry))
9958 ++ if (IS_ERR(entry)) {
9959 ++ *lo = 0;
9960 + return PTR_ERR(entry);
9961 ++ }
9962 + if (strcmp(entry->key, key) < 0)
9963 + begin = middle + 1;
9964 + else
9965 +@@ -364,8 +366,10 @@ static int applesmc_get_upper_bound(unsigned int *hi, const char *key)
9966 + while (begin != end) {
9967 + int middle = begin + (end - begin) / 2;
9968 + entry = applesmc_get_entry_by_index(middle);
9969 +- if (IS_ERR(entry))
9970 ++ if (IS_ERR(entry)) {
9971 ++ *hi = smcreg.key_count;
9972 + return PTR_ERR(entry);
9973 ++ }
9974 + if (strcmp(key, entry->key) < 0)
9975 + end = middle;
9976 + else
9977 +@@ -485,16 +489,25 @@ static int applesmc_init_smcreg_try(void)
9978 + {
9979 + struct applesmc_registers *s = &smcreg;
9980 + bool left_light_sensor, right_light_sensor;
9981 ++ unsigned int count;
9982 + u8 tmp[1];
9983 + int ret;
9984 +
9985 + if (s->init_complete)
9986 + return 0;
9987 +
9988 +- ret = read_register_count(&s->key_count);
9989 ++ ret = read_register_count(&count);
9990 + if (ret)
9991 + return ret;
9992 +
9993 ++ if (s->cache && s->key_count != count) {
9994 ++ pr_warn("key count changed from %d to %d\n",
9995 ++ s->key_count, count);
9996 ++ kfree(s->cache);
9997 ++ s->cache = NULL;
9998 ++ }
9999 ++ s->key_count = count;
10000 ++
10001 + if (!s->cache)
10002 + s->cache = kcalloc(s->key_count, sizeof(*s->cache), GFP_KERNEL);
10003 + if (!s->cache)
10004 +diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
10005 +index f44a06740a6e..b4a4aaf81793 100644
10006 +--- a/drivers/iommu/intel-iommu.c
10007 ++++ b/drivers/iommu/intel-iommu.c
10008 +@@ -861,56 +861,54 @@ static int dma_pte_clear_range(struct dmar_domain *domain,
10009 + return order;
10010 + }
10011 +
10012 ++static void dma_pte_free_level(struct dmar_domain *domain, int level,
10013 ++ struct dma_pte *pte, unsigned long pfn,
10014 ++ unsigned long start_pfn, unsigned long last_pfn)
10015 ++{
10016 ++ pfn = max(start_pfn, pfn);
10017 ++ pte = &pte[pfn_level_offset(pfn, level)];
10018 ++
10019 ++ do {
10020 ++ unsigned long level_pfn;
10021 ++ struct dma_pte *level_pte;
10022 ++
10023 ++ if (!dma_pte_present(pte) || dma_pte_superpage(pte))
10024 ++ goto next;
10025 ++
10026 ++ level_pfn = pfn & level_mask(level - 1);
10027 ++ level_pte = phys_to_virt(dma_pte_addr(pte));
10028 ++
10029 ++ if (level > 2)
10030 ++ dma_pte_free_level(domain, level - 1, level_pte,
10031 ++ level_pfn, start_pfn, last_pfn);
10032 ++
10033 ++ /* If range covers entire pagetable, free it */
10034 ++ if (!(start_pfn > level_pfn ||
10035 ++ last_pfn < level_pfn + level_size(level))) {
10036 ++ dma_clear_pte(pte);
10037 ++ domain_flush_cache(domain, pte, sizeof(*pte));
10038 ++ free_pgtable_page(level_pte);
10039 ++ }
10040 ++next:
10041 ++ pfn += level_size(level);
10042 ++ } while (!first_pte_in_page(++pte) && pfn <= last_pfn);
10043 ++}
10044 ++
10045 + /* free page table pages. last level pte should already be cleared */
10046 + static void dma_pte_free_pagetable(struct dmar_domain *domain,
10047 + unsigned long start_pfn,
10048 + unsigned long last_pfn)
10049 + {
10050 + int addr_width = agaw_to_width(domain->agaw) - VTD_PAGE_SHIFT;
10051 +- struct dma_pte *first_pte, *pte;
10052 +- int total = agaw_to_level(domain->agaw);
10053 +- int level;
10054 +- unsigned long tmp;
10055 +- int large_page = 2;
10056 +
10057 + BUG_ON(addr_width < BITS_PER_LONG && start_pfn >> addr_width);
10058 + BUG_ON(addr_width < BITS_PER_LONG && last_pfn >> addr_width);
10059 + BUG_ON(start_pfn > last_pfn);
10060 +
10061 + /* We don't need lock here; nobody else touches the iova range */
10062 +- level = 2;
10063 +- while (level <= total) {
10064 +- tmp = align_to_level(start_pfn, level);
10065 +-
10066 +- /* If we can't even clear one PTE at this level, we're done */
10067 +- if (tmp + level_size(level) - 1 > last_pfn)
10068 +- return;
10069 +-
10070 +- do {
10071 +- large_page = level;
10072 +- first_pte = pte = dma_pfn_level_pte(domain, tmp, level, &large_page);
10073 +- if (large_page > level)
10074 +- level = large_page + 1;
10075 +- if (!pte) {
10076 +- tmp = align_to_level(tmp + 1, level + 1);
10077 +- continue;
10078 +- }
10079 +- do {
10080 +- if (dma_pte_present(pte)) {
10081 +- free_pgtable_page(phys_to_virt(dma_pte_addr(pte)));
10082 +- dma_clear_pte(pte);
10083 +- }
10084 +- pte++;
10085 +- tmp += level_size(level);
10086 +- } while (!first_pte_in_page(pte) &&
10087 +- tmp + level_size(level) - 1 <= last_pfn);
10088 ++ dma_pte_free_level(domain, agaw_to_level(domain->agaw),
10089 ++ domain->pgd, 0, start_pfn, last_pfn);
10090 +
10091 +- domain_flush_cache(domain, first_pte,
10092 +- (void *)pte - (void *)first_pte);
10093 +-
10094 +- } while (tmp && tmp + level_size(level) - 1 <= last_pfn);
10095 +- level++;
10096 +- }
10097 + /* free pgd */
10098 + if (start_pfn == 0 && last_pfn == DOMAIN_MAX_PFN(domain->gaw)) {
10099 + free_pgtable_page(domain->pgd);
10100 +diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c
10101 +index b4aaa7bf98a3..5c303168157a 100644
10102 +--- a/drivers/md/dm-snap.c
10103 ++++ b/drivers/md/dm-snap.c
10104 +@@ -721,17 +721,16 @@ static int calc_max_buckets(void)
10105 + */
10106 + static int init_hash_tables(struct dm_snapshot *s)
10107 + {
10108 +- sector_t hash_size, cow_dev_size, origin_dev_size, max_buckets;
10109 ++ sector_t hash_size, cow_dev_size, max_buckets;
10110 +
10111 + /*
10112 + * Calculate based on the size of the original volume or
10113 + * the COW volume...
10114 + */
10115 + cow_dev_size = get_dev_size(s->cow->bdev);
10116 +- origin_dev_size = get_dev_size(s->origin->bdev);
10117 + max_buckets = calc_max_buckets();
10118 +
10119 +- hash_size = min(origin_dev_size, cow_dev_size) >> s->store->chunk_shift;
10120 ++ hash_size = cow_dev_size >> s->store->chunk_shift;
10121 + hash_size = min(hash_size, max_buckets);
10122 +
10123 + if (hash_size < 64)
10124 +diff --git a/drivers/media/video/hdpvr/hdpvr-core.c b/drivers/media/video/hdpvr/hdpvr-core.c
10125 +index 441dacf642bb..060353eac9bb 100644
10126 +--- a/drivers/media/video/hdpvr/hdpvr-core.c
10127 ++++ b/drivers/media/video/hdpvr/hdpvr-core.c
10128 +@@ -297,6 +297,11 @@ static int hdpvr_probe(struct usb_interface *interface,
10129 +
10130 + dev->workqueue = 0;
10131 +
10132 ++ /* init video transfer queues first of all */
10133 ++ /* to prevent oops in hdpvr_delete() on error paths */
10134 ++ INIT_LIST_HEAD(&dev->free_buff_list);
10135 ++ INIT_LIST_HEAD(&dev->rec_buff_list);
10136 ++
10137 + /* register v4l2_device early so it can be used for printks */
10138 + if (v4l2_device_register(&interface->dev, &dev->v4l2_dev)) {
10139 + err("v4l2_device_register failed");
10140 +@@ -319,10 +324,6 @@ static int hdpvr_probe(struct usb_interface *interface,
10141 + if (!dev->workqueue)
10142 + goto error;
10143 +
10144 +- /* init video transfer queues */
10145 +- INIT_LIST_HEAD(&dev->free_buff_list);
10146 +- INIT_LIST_HEAD(&dev->rec_buff_list);
10147 +-
10148 + dev->options = hdpvr_default_options;
10149 +
10150 + if (default_video_input < HDPVR_VIDEO_INPUTS)
10151 +@@ -373,12 +374,6 @@ static int hdpvr_probe(struct usb_interface *interface,
10152 + }
10153 + mutex_unlock(&dev->io_mutex);
10154 +
10155 +- if (hdpvr_register_videodev(dev, &interface->dev,
10156 +- video_nr[atomic_inc_return(&dev_nr)])) {
10157 +- v4l2_err(&dev->v4l2_dev, "registering videodev failed\n");
10158 +- goto error;
10159 +- }
10160 +-
10161 + #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
10162 + retval = hdpvr_register_i2c_adapter(dev);
10163 + if (retval < 0) {
10164 +@@ -399,6 +394,13 @@ static int hdpvr_probe(struct usb_interface *interface,
10165 + }
10166 + #endif
10167 +
10168 ++ retval = hdpvr_register_videodev(dev, &interface->dev,
10169 ++ video_nr[atomic_inc_return(&dev_nr)]);
10170 ++ if (retval < 0) {
10171 ++ v4l2_err(&dev->v4l2_dev, "registering videodev failed\n");
10172 ++ goto reg_fail;
10173 ++ }
10174 ++
10175 + /* let the user know what node this device is now attached to */
10176 + v4l2_info(&dev->v4l2_dev, "device now attached to %s\n",
10177 + video_device_node_name(dev->video_dev));
10178 +diff --git a/drivers/mmc/host/tmio_mmc_dma.c b/drivers/mmc/host/tmio_mmc_dma.c
10179 +index 86f259cdfcbc..be9e74d687b9 100644
10180 +--- a/drivers/mmc/host/tmio_mmc_dma.c
10181 ++++ b/drivers/mmc/host/tmio_mmc_dma.c
10182 +@@ -92,6 +92,7 @@ static void tmio_mmc_start_dma_rx(struct tmio_mmc_host *host)
10183 + pio:
10184 + if (!desc) {
10185 + /* DMA failed, fall back to PIO */
10186 ++ tmio_mmc_enable_dma(host, false);
10187 + if (ret >= 0)
10188 + ret = -EIO;
10189 + host->chan_rx = NULL;
10190 +@@ -104,7 +105,6 @@ pio:
10191 + }
10192 + dev_warn(&host->pdev->dev,
10193 + "DMA failed: %d, falling back to PIO\n", ret);
10194 +- tmio_mmc_enable_dma(host, false);
10195 + }
10196 +
10197 + dev_dbg(&host->pdev->dev, "%s(): desc %p, cookie %d, sg[%d]\n", __func__,
10198 +@@ -173,6 +173,7 @@ static void tmio_mmc_start_dma_tx(struct tmio_mmc_host *host)
10199 + pio:
10200 + if (!desc) {
10201 + /* DMA failed, fall back to PIO */
10202 ++ tmio_mmc_enable_dma(host, false);
10203 + if (ret >= 0)
10204 + ret = -EIO;
10205 + host->chan_tx = NULL;
10206 +@@ -185,7 +186,6 @@ pio:
10207 + }
10208 + dev_warn(&host->pdev->dev,
10209 + "DMA failed: %d, falling back to PIO\n", ret);
10210 +- tmio_mmc_enable_dma(host, false);
10211 + }
10212 +
10213 + dev_dbg(&host->pdev->dev, "%s(): desc %p, cookie %d\n", __func__,
10214 +diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
10215 +index b436b84de123..1bf36ac44a10 100644
10216 +--- a/drivers/net/bonding/bond_main.c
10217 ++++ b/drivers/net/bonding/bond_main.c
10218 +@@ -1911,6 +1911,7 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev)
10219 + struct bonding *bond = netdev_priv(bond_dev);
10220 + struct slave *slave, *oldcurrent;
10221 + struct sockaddr addr;
10222 ++ int old_flags = bond_dev->flags;
10223 + u32 old_features = bond_dev->features;
10224 +
10225 + /* slave is not a slave or master is not master of this slave */
10226 +@@ -2041,12 +2042,18 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev)
10227 + * already taken care of above when we detached the slave
10228 + */
10229 + if (!USES_PRIMARY(bond->params.mode)) {
10230 +- /* unset promiscuity level from slave */
10231 +- if (bond_dev->flags & IFF_PROMISC)
10232 ++ /* unset promiscuity level from slave
10233 ++ * NOTE: The NETDEV_CHANGEADDR call above may change the value
10234 ++ * of the IFF_PROMISC flag in the bond_dev, but we need the
10235 ++ * value of that flag before that change, as that was the value
10236 ++ * when this slave was attached, so we cache at the start of the
10237 ++ * function and use it here. Same goes for ALLMULTI below
10238 ++ */
10239 ++ if (old_flags & IFF_PROMISC)
10240 + dev_set_promiscuity(slave_dev, -1);
10241 +
10242 + /* unset allmulti level from slave */
10243 +- if (bond_dev->flags & IFF_ALLMULTI)
10244 ++ if (old_flags & IFF_ALLMULTI)
10245 + dev_set_allmulti(slave_dev, -1);
10246 +
10247 + /* flush master's mc_list from slave */
10248 +diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
10249 +index e59d006e98e1..bb828c24ce6f 100644
10250 +--- a/drivers/net/can/flexcan.c
10251 ++++ b/drivers/net/can/flexcan.c
10252 +@@ -60,7 +60,7 @@
10253 + #define FLEXCAN_MCR_BCC BIT(16)
10254 + #define FLEXCAN_MCR_LPRIO_EN BIT(13)
10255 + #define FLEXCAN_MCR_AEN BIT(12)
10256 +-#define FLEXCAN_MCR_MAXMB(x) ((x) & 0xf)
10257 ++#define FLEXCAN_MCR_MAXMB(x) ((x) & 0x1f)
10258 + #define FLEXCAN_MCR_IDAM_A (0 << 8)
10259 + #define FLEXCAN_MCR_IDAM_B (1 << 8)
10260 + #define FLEXCAN_MCR_IDAM_C (2 << 8)
10261 +@@ -666,7 +666,6 @@ static int flexcan_chip_start(struct net_device *dev)
10262 + {
10263 + struct flexcan_priv *priv = netdev_priv(dev);
10264 + struct flexcan_regs __iomem *regs = priv->base;
10265 +- unsigned int i;
10266 + int err;
10267 + u32 reg_mcr, reg_ctrl;
10268 +
10269 +@@ -700,9 +699,11 @@ static int flexcan_chip_start(struct net_device *dev)
10270 + *
10271 + */
10272 + reg_mcr = flexcan_read(&regs->mcr);
10273 ++ reg_mcr &= ~FLEXCAN_MCR_MAXMB(0xff);
10274 + reg_mcr |= FLEXCAN_MCR_FRZ | FLEXCAN_MCR_FEN | FLEXCAN_MCR_HALT |
10275 + FLEXCAN_MCR_SUPV | FLEXCAN_MCR_WRN_EN |
10276 +- FLEXCAN_MCR_IDAM_C;
10277 ++ FLEXCAN_MCR_IDAM_C |
10278 ++ FLEXCAN_MCR_MAXMB(FLEXCAN_TX_BUF_ID);
10279 + dev_dbg(dev->dev.parent, "%s: writing mcr=0x%08x", __func__, reg_mcr);
10280 + flexcan_write(reg_mcr, &regs->mcr);
10281 +
10282 +@@ -732,16 +733,9 @@ static int flexcan_chip_start(struct net_device *dev)
10283 + dev_dbg(dev->dev.parent, "%s: writing ctrl=0x%08x", __func__, reg_ctrl);
10284 + flexcan_write(reg_ctrl, &regs->ctrl);
10285 +
10286 +- for (i = 0; i < ARRAY_SIZE(regs->cantxfg); i++) {
10287 +- flexcan_write(0, &regs->cantxfg[i].can_ctrl);
10288 +- flexcan_write(0, &regs->cantxfg[i].can_id);
10289 +- flexcan_write(0, &regs->cantxfg[i].data[0]);
10290 +- flexcan_write(0, &regs->cantxfg[i].data[1]);
10291 +-
10292 +- /* put MB into rx queue */
10293 +- flexcan_write(FLEXCAN_MB_CNT_CODE(0x4),
10294 +- &regs->cantxfg[i].can_ctrl);
10295 +- }
10296 ++ /* Abort any pending TX, mark Mailbox as INACTIVE */
10297 ++ flexcan_write(FLEXCAN_MB_CNT_CODE(0x4),
10298 ++ &regs->cantxfg[FLEXCAN_TX_BUF_ID].can_ctrl);
10299 +
10300 + /* acceptance mask/acceptance code (accept everything) */
10301 + flexcan_write(0x0, &regs->rxgmask);
10302 +diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c
10303 +index d0722a7d480b..fb9e7d34bcf2 100644
10304 +--- a/drivers/net/ethernet/freescale/gianfar.c
10305 ++++ b/drivers/net/ethernet/freescale/gianfar.c
10306 +@@ -397,7 +397,13 @@ static void gfar_init_mac(struct net_device *ndev)
10307 + if (ndev->features & NETIF_F_IP_CSUM)
10308 + tctrl |= TCTRL_INIT_CSUM;
10309 +
10310 +- tctrl |= TCTRL_TXSCHED_PRIO;
10311 ++ if (priv->prio_sched_en)
10312 ++ tctrl |= TCTRL_TXSCHED_PRIO;
10313 ++ else {
10314 ++ tctrl |= TCTRL_TXSCHED_WRRS;
10315 ++ gfar_write(&regs->tr03wt, DEFAULT_WRRS_WEIGHT);
10316 ++ gfar_write(&regs->tr47wt, DEFAULT_WRRS_WEIGHT);
10317 ++ }
10318 +
10319 + gfar_write(&regs->tctrl, tctrl);
10320 +
10321 +@@ -1157,6 +1163,9 @@ static int gfar_probe(struct platform_device *ofdev)
10322 + priv->rx_filer_enable = 1;
10323 + /* Enable most messages by default */
10324 + priv->msg_enable = (NETIF_MSG_IFUP << 1 ) - 1;
10325 ++ /* use pritority h/w tx queue scheduling for single queue devices */
10326 ++ if (priv->num_tx_queues == 1)
10327 ++ priv->prio_sched_en = 1;
10328 +
10329 + /* Carrier starts down, phylib will bring it up */
10330 + netif_carrier_off(dev);
10331 +diff --git a/drivers/net/ethernet/freescale/gianfar.h b/drivers/net/ethernet/freescale/gianfar.h
10332 +index 9aa43773e8e3..abeb79a67aee 100644
10333 +--- a/drivers/net/ethernet/freescale/gianfar.h
10334 ++++ b/drivers/net/ethernet/freescale/gianfar.h
10335 +@@ -304,8 +304,16 @@ extern const char gfar_driver_version[];
10336 + #define TCTRL_TFCPAUSE 0x00000008
10337 + #define TCTRL_TXSCHED_MASK 0x00000006
10338 + #define TCTRL_TXSCHED_INIT 0x00000000
10339 ++/* priority scheduling */
10340 + #define TCTRL_TXSCHED_PRIO 0x00000002
10341 ++/* weighted round-robin scheduling (WRRS) */
10342 + #define TCTRL_TXSCHED_WRRS 0x00000004
10343 ++/* default WRRS weight and policy setting,
10344 ++ * tailored to the tr03wt and tr47wt registers:
10345 ++ * equal weight for all Tx Qs, measured in 64byte units
10346 ++ */
10347 ++#define DEFAULT_WRRS_WEIGHT 0x18181818
10348 ++
10349 + #define TCTRL_INIT_CSUM (TCTRL_TUCSEN | TCTRL_IPCSEN)
10350 +
10351 + #define IEVENT_INIT_CLEAR 0xffffffff
10352 +@@ -1101,7 +1109,8 @@ struct gfar_private {
10353 + extended_hash:1,
10354 + bd_stash_en:1,
10355 + rx_filer_enable:1,
10356 +- wol_en:1; /* Wake-on-LAN enabled */
10357 ++ wol_en:1, /* Wake-on-LAN enabled */
10358 ++ prio_sched_en:1; /* Enable priorty based Tx scheduling in Hw */
10359 + unsigned short padding;
10360 +
10361 + /* PHY stuff */
10362 +diff --git a/drivers/net/ethernet/realtek/8139cp.c b/drivers/net/ethernet/realtek/8139cp.c
10363 +index 8f47907fd270..4236b82f9e35 100644
10364 +--- a/drivers/net/ethernet/realtek/8139cp.c
10365 ++++ b/drivers/net/ethernet/realtek/8139cp.c
10366 +@@ -478,7 +478,7 @@ rx_status_loop:
10367 +
10368 + while (1) {
10369 + u32 status, len;
10370 +- dma_addr_t mapping;
10371 ++ dma_addr_t mapping, new_mapping;
10372 + struct sk_buff *skb, *new_skb;
10373 + struct cp_desc *desc;
10374 + const unsigned buflen = cp->rx_buf_sz;
10375 +@@ -520,6 +520,14 @@ rx_status_loop:
10376 + goto rx_next;
10377 + }
10378 +
10379 ++ new_mapping = dma_map_single(&cp->pdev->dev, new_skb->data, buflen,
10380 ++ PCI_DMA_FROMDEVICE);
10381 ++ if (dma_mapping_error(&cp->pdev->dev, new_mapping)) {
10382 ++ dev->stats.rx_dropped++;
10383 ++ kfree_skb(new_skb);
10384 ++ goto rx_next;
10385 ++ }
10386 ++
10387 + dma_unmap_single(&cp->pdev->dev, mapping,
10388 + buflen, PCI_DMA_FROMDEVICE);
10389 +
10390 +@@ -531,12 +539,11 @@ rx_status_loop:
10391 +
10392 + skb_put(skb, len);
10393 +
10394 +- mapping = dma_map_single(&cp->pdev->dev, new_skb->data, buflen,
10395 +- PCI_DMA_FROMDEVICE);
10396 + cp->rx_skb[rx_tail] = new_skb;
10397 +
10398 + cp_rx_skb(cp, skb, desc);
10399 + rx++;
10400 ++ mapping = new_mapping;
10401 +
10402 + rx_next:
10403 + cp->rx_ring[rx_tail].opts2 = 0;
10404 +@@ -704,6 +711,22 @@ static inline u32 cp_tx_vlan_tag(struct sk_buff *skb)
10405 + TxVlanTag | swab16(vlan_tx_tag_get(skb)) : 0x00;
10406 + }
10407 +
10408 ++static void unwind_tx_frag_mapping(struct cp_private *cp, struct sk_buff *skb,
10409 ++ int first, int entry_last)
10410 ++{
10411 ++ int frag, index;
10412 ++ struct cp_desc *txd;
10413 ++ skb_frag_t *this_frag;
10414 ++ for (frag = 0; frag+first < entry_last; frag++) {
10415 ++ index = first+frag;
10416 ++ cp->tx_skb[index] = NULL;
10417 ++ txd = &cp->tx_ring[index];
10418 ++ this_frag = &skb_shinfo(skb)->frags[frag];
10419 ++ dma_unmap_single(&cp->pdev->dev, le64_to_cpu(txd->addr),
10420 ++ skb_frag_size(this_frag), PCI_DMA_TODEVICE);
10421 ++ }
10422 ++}
10423 ++
10424 + static netdev_tx_t cp_start_xmit (struct sk_buff *skb,
10425 + struct net_device *dev)
10426 + {
10427 +@@ -737,6 +760,9 @@ static netdev_tx_t cp_start_xmit (struct sk_buff *skb,
10428 +
10429 + len = skb->len;
10430 + mapping = dma_map_single(&cp->pdev->dev, skb->data, len, PCI_DMA_TODEVICE);
10431 ++ if (dma_mapping_error(&cp->pdev->dev, mapping))
10432 ++ goto out_dma_error;
10433 ++
10434 + txd->opts2 = opts2;
10435 + txd->addr = cpu_to_le64(mapping);
10436 + wmb();
10437 +@@ -774,6 +800,9 @@ static netdev_tx_t cp_start_xmit (struct sk_buff *skb,
10438 + first_len = skb_headlen(skb);
10439 + first_mapping = dma_map_single(&cp->pdev->dev, skb->data,
10440 + first_len, PCI_DMA_TODEVICE);
10441 ++ if (dma_mapping_error(&cp->pdev->dev, first_mapping))
10442 ++ goto out_dma_error;
10443 ++
10444 + cp->tx_skb[entry] = skb;
10445 + entry = NEXT_TX(entry);
10446 +
10447 +@@ -787,6 +816,11 @@ static netdev_tx_t cp_start_xmit (struct sk_buff *skb,
10448 + mapping = dma_map_single(&cp->pdev->dev,
10449 + skb_frag_address(this_frag),
10450 + len, PCI_DMA_TODEVICE);
10451 ++ if (dma_mapping_error(&cp->pdev->dev, mapping)) {
10452 ++ unwind_tx_frag_mapping(cp, skb, first_entry, entry);
10453 ++ goto out_dma_error;
10454 ++ }
10455 ++
10456 + eor = (entry == (CP_TX_RING_SIZE - 1)) ? RingEnd : 0;
10457 +
10458 + ctrl = eor | len | DescOwn;
10459 +@@ -845,11 +879,16 @@ static netdev_tx_t cp_start_xmit (struct sk_buff *skb,
10460 + if (TX_BUFFS_AVAIL(cp) <= (MAX_SKB_FRAGS + 1))
10461 + netif_stop_queue(dev);
10462 +
10463 ++out_unlock:
10464 + spin_unlock_irqrestore(&cp->lock, intr_flags);
10465 +
10466 + cpw8(TxPoll, NormalTxPoll);
10467 +
10468 + return NETDEV_TX_OK;
10469 ++out_dma_error:
10470 ++ kfree_skb(skb);
10471 ++ cp->dev->stats.tx_dropped++;
10472 ++ goto out_unlock;
10473 + }
10474 +
10475 + /* Set or clear the multicast filter for this adaptor.
10476 +@@ -1023,6 +1062,10 @@ static int cp_refill_rx(struct cp_private *cp)
10477 +
10478 + mapping = dma_map_single(&cp->pdev->dev, skb->data,
10479 + cp->rx_buf_sz, PCI_DMA_FROMDEVICE);
10480 ++ if (dma_mapping_error(&cp->pdev->dev, mapping)) {
10481 ++ kfree_skb(skb);
10482 ++ goto err_out;
10483 ++ }
10484 + cp->rx_skb[i] = skb;
10485 +
10486 + cp->rx_ring[i].opts2 = 0;
10487 +diff --git a/drivers/net/ethernet/sfc/rx.c b/drivers/net/ethernet/sfc/rx.c
10488 +index 9ce8665b53bf..c231b3f67b2b 100644
10489 +--- a/drivers/net/ethernet/sfc/rx.c
10490 ++++ b/drivers/net/ethernet/sfc/rx.c
10491 +@@ -312,8 +312,9 @@ static void efx_resurrect_rx_buffer(struct efx_rx_queue *rx_queue,
10492 +
10493 + index = rx_queue->added_count & rx_queue->ptr_mask;
10494 + new_buf = efx_rx_buffer(rx_queue, index);
10495 +- new_buf->dma_addr = rx_buf->dma_addr ^ (PAGE_SIZE >> 1);
10496 + new_buf->u.page = rx_buf->u.page;
10497 ++ new_buf->page_offset = rx_buf->page_offset ^ (PAGE_SIZE >> 1);
10498 ++ new_buf->dma_addr = state->dma_addr + new_buf->page_offset;
10499 + new_buf->len = rx_buf->len;
10500 + new_buf->is_page = true;
10501 + ++rx_queue->added_count;
10502 +diff --git a/drivers/net/ethernet/via/via-rhine.c b/drivers/net/ethernet/via/via-rhine.c
10503 +index f34dd99fe579..f37e0aee27c6 100644
10504 +--- a/drivers/net/ethernet/via/via-rhine.c
10505 ++++ b/drivers/net/ethernet/via/via-rhine.c
10506 +@@ -32,7 +32,7 @@
10507 + #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
10508 +
10509 + #define DRV_NAME "via-rhine"
10510 +-#define DRV_VERSION "1.5.0"
10511 ++#define DRV_VERSION "1.5.1"
10512 + #define DRV_RELDATE "2010-10-09"
10513 +
10514 +
10515 +@@ -1518,7 +1518,12 @@ static netdev_tx_t rhine_start_tx(struct sk_buff *skb,
10516 + cpu_to_le32(TXDESC | (skb->len >= ETH_ZLEN ? skb->len : ETH_ZLEN));
10517 +
10518 + if (unlikely(vlan_tx_tag_present(skb))) {
10519 +- rp->tx_ring[entry].tx_status = cpu_to_le32((vlan_tx_tag_get(skb)) << 16);
10520 ++ u16 vid_pcp = vlan_tx_tag_get(skb);
10521 ++
10522 ++ /* drop CFI/DEI bit, register needs VID and PCP */
10523 ++ vid_pcp = (vid_pcp & VLAN_VID_MASK) |
10524 ++ ((vid_pcp & VLAN_PRIO_MASK) >> 1);
10525 ++ rp->tx_ring[entry].tx_status = cpu_to_le32((vid_pcp) << 16);
10526 + /* request tagging */
10527 + rp->tx_ring[entry].desc_length |= cpu_to_le32(0x020000);
10528 + }
10529 +diff --git a/drivers/net/ethernet/xilinx/ll_temac_main.c b/drivers/net/ethernet/xilinx/ll_temac_main.c
10530 +index 2681b53820ee..e26945d9dea4 100644
10531 +--- a/drivers/net/ethernet/xilinx/ll_temac_main.c
10532 ++++ b/drivers/net/ethernet/xilinx/ll_temac_main.c
10533 +@@ -308,6 +308,12 @@ static int temac_dma_bd_init(struct net_device *ndev)
10534 + lp->rx_bd_p + (sizeof(*lp->rx_bd_v) * (RX_BD_NUM - 1)));
10535 + lp->dma_out(lp, TX_CURDESC_PTR, lp->tx_bd_p);
10536 +
10537 ++ /* Init descriptor indexes */
10538 ++ lp->tx_bd_ci = 0;
10539 ++ lp->tx_bd_next = 0;
10540 ++ lp->tx_bd_tail = 0;
10541 ++ lp->rx_bd_ci = 0;
10542 ++
10543 + return 0;
10544 +
10545 + out:
10546 +diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
10547 +index 96b9e3c93ce1..b0f901518b76 100644
10548 +--- a/drivers/net/macvtap.c
10549 ++++ b/drivers/net/macvtap.c
10550 +@@ -641,6 +641,28 @@ static int macvtap_skb_to_vnet_hdr(const struct sk_buff *skb,
10551 + return 0;
10552 + }
10553 +
10554 ++static unsigned long iov_pages(const struct iovec *iv, int offset,
10555 ++ unsigned long nr_segs)
10556 ++{
10557 ++ unsigned long seg, base;
10558 ++ int pages = 0, len, size;
10559 ++
10560 ++ while (nr_segs && (offset >= iv->iov_len)) {
10561 ++ offset -= iv->iov_len;
10562 ++ ++iv;
10563 ++ --nr_segs;
10564 ++ }
10565 ++
10566 ++ for (seg = 0; seg < nr_segs; seg++) {
10567 ++ base = (unsigned long)iv[seg].iov_base + offset;
10568 ++ len = iv[seg].iov_len - offset;
10569 ++ size = ((base & ~PAGE_MASK) + len + ~PAGE_MASK) >> PAGE_SHIFT;
10570 ++ pages += size;
10571 ++ offset = 0;
10572 ++ }
10573 ++
10574 ++ return pages;
10575 ++}
10576 +
10577 + /* Get packet from user space buffer */
10578 + static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m,
10579 +@@ -687,31 +709,15 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m,
10580 + if (unlikely(count > UIO_MAXIOV))
10581 + goto err;
10582 +
10583 +- if (m && m->msg_control && sock_flag(&q->sk, SOCK_ZEROCOPY))
10584 +- zerocopy = true;
10585 +-
10586 +- if (zerocopy) {
10587 +- /* Userspace may produce vectors with count greater than
10588 +- * MAX_SKB_FRAGS, so we need to linearize parts of the skb
10589 +- * to let the rest of data to be fit in the frags.
10590 +- */
10591 +- if (count > MAX_SKB_FRAGS) {
10592 +- copylen = iov_length(iv, count - MAX_SKB_FRAGS);
10593 +- if (copylen < vnet_hdr_len)
10594 +- copylen = 0;
10595 +- else
10596 +- copylen -= vnet_hdr_len;
10597 +- }
10598 +- /* There are 256 bytes to be copied in skb, so there is enough
10599 +- * room for skb expand head in case it is used.
10600 +- * The rest buffer is mapped from userspace.
10601 +- */
10602 +- if (copylen < vnet_hdr.hdr_len)
10603 +- copylen = vnet_hdr.hdr_len;
10604 +- if (!copylen)
10605 +- copylen = GOODCOPY_LEN;
10606 ++ if (m && m->msg_control && sock_flag(&q->sk, SOCK_ZEROCOPY)) {
10607 ++ copylen = vnet_hdr.hdr_len ? vnet_hdr.hdr_len : GOODCOPY_LEN;
10608 + linear = copylen;
10609 +- } else {
10610 ++ if (iov_pages(iv, vnet_hdr_len + copylen, count)
10611 ++ <= MAX_SKB_FRAGS)
10612 ++ zerocopy = true;
10613 ++ }
10614 ++
10615 ++ if (!zerocopy) {
10616 + copylen = len;
10617 + linear = vnet_hdr.hdr_len;
10618 + }
10619 +@@ -723,9 +729,15 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m,
10620 +
10621 + if (zerocopy)
10622 + err = zerocopy_sg_from_iovec(skb, iv, vnet_hdr_len, count);
10623 +- else
10624 ++ else {
10625 + err = skb_copy_datagram_from_iovec(skb, 0, iv, vnet_hdr_len,
10626 + len);
10627 ++ if (!err && m && m->msg_control) {
10628 ++ struct ubuf_info *uarg = m->msg_control;
10629 ++ uarg->callback(uarg);
10630 ++ }
10631 ++ }
10632 ++
10633 + if (err)
10634 + goto err_kfree;
10635 +
10636 +diff --git a/drivers/net/ppp/pptp.c b/drivers/net/ppp/pptp.c
10637 +index ad6a9d91dfdd..2b349d3355f4 100644
10638 +--- a/drivers/net/ppp/pptp.c
10639 ++++ b/drivers/net/ppp/pptp.c
10640 +@@ -281,7 +281,7 @@ static int pptp_xmit(struct ppp_channel *chan, struct sk_buff *skb)
10641 + nf_reset(skb);
10642 +
10643 + skb->ip_summed = CHECKSUM_NONE;
10644 +- ip_select_ident(iph, &rt->dst, NULL);
10645 ++ ip_select_ident(skb, &rt->dst, NULL);
10646 + ip_send_check(iph);
10647 +
10648 + ip_local_out(skb);
10649 +diff --git a/drivers/net/tun.c b/drivers/net/tun.c
10650 +index f4c5de6e3ed0..ee1aab0805d1 100644
10651 +--- a/drivers/net/tun.c
10652 ++++ b/drivers/net/tun.c
10653 +@@ -614,8 +614,9 @@ static ssize_t tun_get_user(struct tun_struct *tun,
10654 + int offset = 0;
10655 +
10656 + if (!(tun->flags & TUN_NO_PI)) {
10657 +- if ((len -= sizeof(pi)) > count)
10658 ++ if (len < sizeof(pi))
10659 + return -EINVAL;
10660 ++ len -= sizeof(pi);
10661 +
10662 + if (memcpy_fromiovecend((void *)&pi, iv, 0, sizeof(pi)))
10663 + return -EFAULT;
10664 +@@ -623,8 +624,9 @@ static ssize_t tun_get_user(struct tun_struct *tun,
10665 + }
10666 +
10667 + if (tun->flags & TUN_VNET_HDR) {
10668 +- if ((len -= tun->vnet_hdr_sz) > count)
10669 ++ if (len < tun->vnet_hdr_sz)
10670 + return -EINVAL;
10671 ++ len -= tun->vnet_hdr_sz;
10672 +
10673 + if (memcpy_fromiovecend((void *)&gso, iv, offset, sizeof(gso)))
10674 + return -EFAULT;
10675 +diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c
10676 +index 2ba40cf85251..43aa06b3f7c6 100644
10677 +--- a/drivers/net/usb/cdc_ether.c
10678 ++++ b/drivers/net/usb/cdc_ether.c
10679 +@@ -615,6 +615,11 @@ static const struct usb_device_id products [] = {
10680 + .bInterfaceProtocol = USB_CDC_PROTO_NONE,
10681 + .driver_info = (unsigned long)&wwan_info,
10682 + }, {
10683 ++ /* Telit modules */
10684 ++ USB_VENDOR_AND_INTERFACE_INFO(0x1bc7, USB_CLASS_COMM,
10685 ++ USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE),
10686 ++ .driver_info = (kernel_ulong_t) &wwan_info,
10687 ++}, {
10688 + USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ETHERNET,
10689 + USB_CDC_PROTO_NONE),
10690 + .driver_info = (unsigned long) &cdc_info,
10691 +diff --git a/drivers/net/usb/dm9601.c b/drivers/net/usb/dm9601.c
10692 +index fbc0e4def767..136ecf32a5d5 100644
10693 +--- a/drivers/net/usb/dm9601.c
10694 ++++ b/drivers/net/usb/dm9601.c
10695 +@@ -384,7 +384,7 @@ static void dm9601_set_multicast(struct net_device *net)
10696 + rx_ctl |= 0x02;
10697 + } else if (net->flags & IFF_ALLMULTI ||
10698 + netdev_mc_count(net) > DM_MAX_MCAST) {
10699 +- rx_ctl |= 0x04;
10700 ++ rx_ctl |= 0x08;
10701 + } else if (!netdev_mc_empty(net)) {
10702 + struct netdev_hw_addr *ha;
10703 +
10704 +diff --git a/drivers/net/wireless/ath/ath9k/ar9003_phy.c b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
10705 +index 73be7ff149f9..f146824e676d 100644
10706 +--- a/drivers/net/wireless/ath/ath9k/ar9003_phy.c
10707 ++++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
10708 +@@ -1016,6 +1016,10 @@ static bool ar9003_hw_ani_control(struct ath_hw *ah,
10709 + * is_on == 0 means MRC CCK is OFF (more noise imm)
10710 + */
10711 + bool is_on = param ? 1 : 0;
10712 ++
10713 ++ if (ah->caps.rx_chainmask == 1)
10714 ++ break;
10715 ++
10716 + REG_RMW_FIELD(ah, AR_PHY_MRC_CCK_CTRL,
10717 + AR_PHY_MRC_CCK_ENABLE, is_on);
10718 + REG_RMW_FIELD(ah, AR_PHY_MRC_CCK_CTRL,
10719 +diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h
10720 +index 1c269f50822b..7c70cf2b5d1a 100644
10721 +--- a/drivers/net/wireless/ath/ath9k/ath9k.h
10722 ++++ b/drivers/net/wireless/ath/ath9k/ath9k.h
10723 +@@ -77,10 +77,6 @@ struct ath_config {
10724 + sizeof(struct ath_buf_state)); \
10725 + } while (0)
10726 +
10727 +-#define ATH_RXBUF_RESET(_bf) do { \
10728 +- (_bf)->bf_stale = false; \
10729 +- } while (0)
10730 +-
10731 + /**
10732 + * enum buffer_type - Buffer type flags
10733 + *
10734 +@@ -308,6 +304,7 @@ struct ath_rx {
10735 + struct ath_buf *rx_bufptr;
10736 + struct ath_rx_edma rx_edma[ATH9K_RX_QUEUE_MAX];
10737 +
10738 ++ struct ath_buf *buf_hold;
10739 + struct sk_buff *frag;
10740 + };
10741 +
10742 +diff --git a/drivers/net/wireless/ath/ath9k/recv.c b/drivers/net/wireless/ath/ath9k/recv.c
10743 +index d171a7242e4a..8326c1402ea7 100644
10744 +--- a/drivers/net/wireless/ath/ath9k/recv.c
10745 ++++ b/drivers/net/wireless/ath/ath9k/recv.c
10746 +@@ -78,8 +78,6 @@ static void ath_rx_buf_link(struct ath_softc *sc, struct ath_buf *bf)
10747 + struct ath_desc *ds;
10748 + struct sk_buff *skb;
10749 +
10750 +- ATH_RXBUF_RESET(bf);
10751 +-
10752 + ds = bf->bf_desc;
10753 + ds->ds_link = 0; /* link to null */
10754 + ds->ds_data = bf->bf_buf_addr;
10755 +@@ -106,6 +104,14 @@ static void ath_rx_buf_link(struct ath_softc *sc, struct ath_buf *bf)
10756 + sc->rx.rxlink = &ds->ds_link;
10757 + }
10758 +
10759 ++static void ath_rx_buf_relink(struct ath_softc *sc, struct ath_buf *bf)
10760 ++{
10761 ++ if (sc->rx.buf_hold)
10762 ++ ath_rx_buf_link(sc, sc->rx.buf_hold);
10763 ++
10764 ++ sc->rx.buf_hold = bf;
10765 ++}
10766 ++
10767 + static void ath_setdefantenna(struct ath_softc *sc, u32 antenna)
10768 + {
10769 + /* XXX block beacon interrupts */
10770 +@@ -153,7 +159,6 @@ static bool ath_rx_edma_buf_link(struct ath_softc *sc,
10771 +
10772 + skb = bf->bf_mpdu;
10773 +
10774 +- ATH_RXBUF_RESET(bf);
10775 + memset(skb->data, 0, ah->caps.rx_status_len);
10776 + dma_sync_single_for_device(sc->dev, bf->bf_buf_addr,
10777 + ah->caps.rx_status_len, DMA_TO_DEVICE);
10778 +@@ -492,6 +497,7 @@ int ath_startrecv(struct ath_softc *sc)
10779 + if (list_empty(&sc->rx.rxbuf))
10780 + goto start_recv;
10781 +
10782 ++ sc->rx.buf_hold = NULL;
10783 + sc->rx.rxlink = NULL;
10784 + list_for_each_entry_safe(bf, tbf, &sc->rx.rxbuf, list) {
10785 + ath_rx_buf_link(sc, bf);
10786 +@@ -742,6 +748,9 @@ static struct ath_buf *ath_get_next_rx_buf(struct ath_softc *sc,
10787 + }
10788 +
10789 + bf = list_first_entry(&sc->rx.rxbuf, struct ath_buf, list);
10790 ++ if (bf == sc->rx.buf_hold)
10791 ++ return NULL;
10792 ++
10793 + ds = bf->bf_desc;
10794 +
10795 + /*
10796 +@@ -1974,7 +1983,7 @@ requeue:
10797 + if (edma) {
10798 + ath_rx_edma_buf_link(sc, qtype);
10799 + } else {
10800 +- ath_rx_buf_link(sc, bf);
10801 ++ ath_rx_buf_relink(sc, bf);
10802 + ath9k_hw_rxena(ah);
10803 + }
10804 + } while (1);
10805 +diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c
10806 +index 18da10047712..126ed31affe1 100644
10807 +--- a/drivers/net/wireless/ath/ath9k/xmit.c
10808 ++++ b/drivers/net/wireless/ath/ath9k/xmit.c
10809 +@@ -2423,6 +2423,7 @@ void ath_tx_node_init(struct ath_softc *sc, struct ath_node *an)
10810 + for (acno = 0, ac = &an->ac[acno];
10811 + acno < WME_NUM_AC; acno++, ac++) {
10812 + ac->sched = false;
10813 ++ ac->clear_ps_filter = true;
10814 + ac->txq = sc->tx.txq_map[acno];
10815 + INIT_LIST_HEAD(&ac->tid_q);
10816 + }
10817 +diff --git a/drivers/net/wireless/p54/p54usb.c b/drivers/net/wireless/p54/p54usb.c
10818 +index 564218ca4853..078449385882 100644
10819 +--- a/drivers/net/wireless/p54/p54usb.c
10820 ++++ b/drivers/net/wireless/p54/p54usb.c
10821 +@@ -83,6 +83,7 @@ static struct usb_device_id p54u_table[] = {
10822 + {USB_DEVICE(0x06a9, 0x000e)}, /* Westell 802.11g USB (A90-211WG-01) */
10823 + {USB_DEVICE(0x06b9, 0x0121)}, /* Thomson SpeedTouch 121g */
10824 + {USB_DEVICE(0x0707, 0xee13)}, /* SMC 2862W-G version 2 */
10825 ++ {USB_DEVICE(0x07aa, 0x0020)}, /* Corega WLUSB2GTST USB */
10826 + {USB_DEVICE(0x0803, 0x4310)}, /* Zoom 4410a */
10827 + {USB_DEVICE(0x083a, 0x4521)}, /* Siemens Gigaset USB Adapter 54 version 2 */
10828 + {USB_DEVICE(0x083a, 0x4531)}, /* T-Com Sinus 154 data II */
10829 +diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
10830 +index 67cbe5a1a928..8fb8c9e75688 100644
10831 +--- a/drivers/net/wireless/rt2x00/rt2800lib.c
10832 ++++ b/drivers/net/wireless/rt2x00/rt2800lib.c
10833 +@@ -2067,6 +2067,13 @@ static int rt2800_get_gain_calibration_delta(struct rt2x00_dev *rt2x00dev)
10834 + int i;
10835 +
10836 + /*
10837 ++ * First check if temperature compensation is supported.
10838 ++ */
10839 ++ rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1, &eeprom);
10840 ++ if (!rt2x00_get_field16(eeprom, EEPROM_NIC_CONF1_EXTERNAL_TX_ALC))
10841 ++ return 0;
10842 ++
10843 ++ /*
10844 + * Read TSSI boundaries for temperature compensation from
10845 + * the EEPROM.
10846 + *
10847 +diff --git a/drivers/net/wireless/rtlwifi/wifi.h b/drivers/net/wireless/rtlwifi/wifi.h
10848 +index deb87e959e02..82baaa25dc41 100644
10849 +--- a/drivers/net/wireless/rtlwifi/wifi.h
10850 ++++ b/drivers/net/wireless/rtlwifi/wifi.h
10851 +@@ -1630,7 +1630,7 @@ struct rtl_priv {
10852 + that it points to the data allocated
10853 + beyond this structure like:
10854 + rtl_pci_priv or rtl_usb_priv */
10855 +- u8 priv[0];
10856 ++ u8 priv[0] __aligned(sizeof(void *));
10857 + };
10858 +
10859 + #define rtl_priv(hw) (((struct rtl_priv *)(hw)->priv))
10860 +diff --git a/drivers/of/base.c b/drivers/of/base.c
10861 +index 9b6588ef0673..37639a644563 100644
10862 +--- a/drivers/of/base.c
10863 ++++ b/drivers/of/base.c
10864 +@@ -1189,6 +1189,7 @@ void of_alias_scan(void * (*dt_alloc)(u64 size, u64 align))
10865 + ap = dt_alloc(sizeof(*ap) + len + 1, 4);
10866 + if (!ap)
10867 + continue;
10868 ++ memset(ap, 0, sizeof(*ap) + len + 1);
10869 + ap->alias = start;
10870 + of_alias_add(ap, np, id, start, len);
10871 + }
10872 +diff --git a/drivers/scsi/esp_scsi.c b/drivers/scsi/esp_scsi.c
10873 +index 394ed9e79fd4..4aa30d86ca99 100644
10874 +--- a/drivers/scsi/esp_scsi.c
10875 ++++ b/drivers/scsi/esp_scsi.c
10876 +@@ -530,7 +530,7 @@ static int esp_need_to_nego_sync(struct esp_target_data *tp)
10877 + static int esp_alloc_lun_tag(struct esp_cmd_entry *ent,
10878 + struct esp_lun_data *lp)
10879 + {
10880 +- if (!ent->tag[0]) {
10881 ++ if (!ent->orig_tag[0]) {
10882 + /* Non-tagged, slot already taken? */
10883 + if (lp->non_tagged_cmd)
10884 + return -EBUSY;
10885 +@@ -564,9 +564,9 @@ static int esp_alloc_lun_tag(struct esp_cmd_entry *ent,
10886 + return -EBUSY;
10887 + }
10888 +
10889 +- BUG_ON(lp->tagged_cmds[ent->tag[1]]);
10890 ++ BUG_ON(lp->tagged_cmds[ent->orig_tag[1]]);
10891 +
10892 +- lp->tagged_cmds[ent->tag[1]] = ent;
10893 ++ lp->tagged_cmds[ent->orig_tag[1]] = ent;
10894 + lp->num_tagged++;
10895 +
10896 + return 0;
10897 +@@ -575,9 +575,9 @@ static int esp_alloc_lun_tag(struct esp_cmd_entry *ent,
10898 + static void esp_free_lun_tag(struct esp_cmd_entry *ent,
10899 + struct esp_lun_data *lp)
10900 + {
10901 +- if (ent->tag[0]) {
10902 +- BUG_ON(lp->tagged_cmds[ent->tag[1]] != ent);
10903 +- lp->tagged_cmds[ent->tag[1]] = NULL;
10904 ++ if (ent->orig_tag[0]) {
10905 ++ BUG_ON(lp->tagged_cmds[ent->orig_tag[1]] != ent);
10906 ++ lp->tagged_cmds[ent->orig_tag[1]] = NULL;
10907 + lp->num_tagged--;
10908 + } else {
10909 + BUG_ON(lp->non_tagged_cmd != ent);
10910 +@@ -667,6 +667,8 @@ static struct esp_cmd_entry *find_and_prep_issuable_command(struct esp *esp)
10911 + ent->tag[0] = 0;
10912 + ent->tag[1] = 0;
10913 + }
10914 ++ ent->orig_tag[0] = ent->tag[0];
10915 ++ ent->orig_tag[1] = ent->tag[1];
10916 +
10917 + if (esp_alloc_lun_tag(ent, lp) < 0)
10918 + continue;
10919 +diff --git a/drivers/scsi/esp_scsi.h b/drivers/scsi/esp_scsi.h
10920 +index 28e22acf87ea..cd68805e8d78 100644
10921 +--- a/drivers/scsi/esp_scsi.h
10922 ++++ b/drivers/scsi/esp_scsi.h
10923 +@@ -271,6 +271,7 @@ struct esp_cmd_entry {
10924 + #define ESP_CMD_FLAG_AUTOSENSE 0x04 /* Doing automatic REQUEST_SENSE */
10925 +
10926 + u8 tag[2];
10927 ++ u8 orig_tag[2];
10928 +
10929 + u8 status;
10930 + u8 message;
10931 +diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
10932 +index 96029e6d027f..c8744588e6b7 100644
10933 +--- a/drivers/scsi/scsi_transport_iscsi.c
10934 ++++ b/drivers/scsi/scsi_transport_iscsi.c
10935 +@@ -2105,7 +2105,7 @@ iscsi_if_rx(struct sk_buff *skb)
10936 + break;
10937 + err = iscsi_if_send_reply(group, nlh->nlmsg_seq,
10938 + nlh->nlmsg_type, 0, 0, ev, sizeof(*ev));
10939 +- } while (err < 0 && err != -ECONNREFUSED);
10940 ++ } while (err < 0 && err != -ECONNREFUSED && err != -ESRCH);
10941 + skb_pull(skb, rlen);
10942 + }
10943 + mutex_unlock(&rx_queue_mutex);
10944 +diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
10945 +index 17603daf9b57..f6d2b62ec005 100644
10946 +--- a/drivers/scsi/sd.c
10947 ++++ b/drivers/scsi/sd.c
10948 +@@ -2136,14 +2136,9 @@ sd_read_cache_type(struct scsi_disk *sdkp, unsigned char *buffer)
10949 + }
10950 + }
10951 +
10952 +- if (modepage == 0x3F) {
10953 +- sd_printk(KERN_ERR, sdkp, "No Caching mode page "
10954 +- "present\n");
10955 +- goto defaults;
10956 +- } else if ((buffer[offset] & 0x3f) != modepage) {
10957 +- sd_printk(KERN_ERR, sdkp, "Got wrong page\n");
10958 +- goto defaults;
10959 +- }
10960 ++ sd_printk(KERN_ERR, sdkp, "No Caching mode page found\n");
10961 ++ goto defaults;
10962 ++
10963 + Page_found:
10964 + if (modepage == 8) {
10965 + sdkp->WCE = ((buffer[offset + 2] & 0x04) != 0);
10966 +diff --git a/drivers/staging/comedi/drivers/dt282x.c b/drivers/staging/comedi/drivers/dt282x.c
10967 +index 95ebc267bb74..e3adb382d721 100644
10968 +--- a/drivers/staging/comedi/drivers/dt282x.c
10969 ++++ b/drivers/staging/comedi/drivers/dt282x.c
10970 +@@ -407,8 +407,9 @@ struct dt282x_private {
10971 + } \
10972 + udelay(5); \
10973 + } \
10974 +- if (_i) \
10975 ++ if (_i) { \
10976 + b \
10977 ++ } \
10978 + } while (0)
10979 +
10980 + static int dt282x_attach(struct comedi_device *dev,
10981 +diff --git a/drivers/staging/comedi/drivers/ni_65xx.c b/drivers/staging/comedi/drivers/ni_65xx.c
10982 +index 403fc0997d37..8b564ad17319 100644
10983 +--- a/drivers/staging/comedi/drivers/ni_65xx.c
10984 ++++ b/drivers/staging/comedi/drivers/ni_65xx.c
10985 +@@ -411,29 +411,25 @@ static int ni_65xx_dio_insn_bits(struct comedi_device *dev,
10986 + struct comedi_subdevice *s,
10987 + struct comedi_insn *insn, unsigned int *data)
10988 + {
10989 +- unsigned base_bitfield_channel;
10990 +- const unsigned max_ports_per_bitfield = 5;
10991 ++ int base_bitfield_channel;
10992 + unsigned read_bits = 0;
10993 +- unsigned j;
10994 ++ int last_port_offset = ni_65xx_port_by_channel(s->n_chan - 1);
10995 ++ int port_offset;
10996 ++
10997 + if (insn->n != 2)
10998 + return -EINVAL;
10999 + base_bitfield_channel = CR_CHAN(insn->chanspec);
11000 +- for (j = 0; j < max_ports_per_bitfield; ++j) {
11001 +- const unsigned port_offset =
11002 +- ni_65xx_port_by_channel(base_bitfield_channel) + j;
11003 +- const unsigned port =
11004 +- sprivate(s)->base_port + port_offset;
11005 +- unsigned base_port_channel;
11006 ++ for (port_offset = ni_65xx_port_by_channel(base_bitfield_channel);
11007 ++ port_offset <= last_port_offset; port_offset++) {
11008 ++ unsigned port = sprivate(s)->base_port + port_offset;
11009 ++ int base_port_channel = port_offset * ni_65xx_channels_per_port;
11010 + unsigned port_mask, port_data, port_read_bits;
11011 +- int bitshift;
11012 +- if (port >= ni_65xx_total_num_ports(board(dev)))
11013 ++ int bitshift = base_port_channel - base_bitfield_channel;
11014 ++
11015 ++ if (bitshift >= 32)
11016 + break;
11017 +- base_port_channel = port_offset * ni_65xx_channels_per_port;
11018 + port_mask = data[0];
11019 + port_data = data[1];
11020 +- bitshift = base_port_channel - base_bitfield_channel;
11021 +- if (bitshift >= 32 || bitshift <= -32)
11022 +- break;
11023 + if (bitshift > 0) {
11024 + port_mask >>= bitshift;
11025 + port_data >>= bitshift;
11026 +diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c
11027 +index 754d54e8d4a8..f680766ae1e7 100644
11028 +--- a/drivers/staging/vt6656/main_usb.c
11029 ++++ b/drivers/staging/vt6656/main_usb.c
11030 +@@ -1221,6 +1221,8 @@ device_release_WPADEV(pDevice);
11031 + memset(pMgmt->abyCurrBSSID, 0, 6);
11032 + pMgmt->eCurrState = WMAC_STATE_IDLE;
11033 +
11034 ++ pDevice->flags &= ~DEVICE_FLAGS_OPENED;
11035 ++
11036 + device_free_tx_bufs(pDevice);
11037 + device_free_rx_bufs(pDevice);
11038 + device_free_int_bufs(pDevice);
11039 +@@ -1232,7 +1234,6 @@ device_release_WPADEV(pDevice);
11040 + usb_free_urb(pDevice->pInterruptURB);
11041 +
11042 + BSSvClearNodeDBTable(pDevice, 0);
11043 +- pDevice->flags &=(~DEVICE_FLAGS_OPENED);
11044 +
11045 + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "device_close2 \n");
11046 +
11047 +diff --git a/drivers/staging/zram/zram_drv.c b/drivers/staging/zram/zram_drv.c
11048 +index 926d483139b8..d197b3ecfbb4 100644
11049 +--- a/drivers/staging/zram/zram_drv.c
11050 ++++ b/drivers/staging/zram/zram_drv.c
11051 +@@ -709,9 +709,7 @@ static void zram_slot_free_notify(struct block_device *bdev,
11052 + struct zram *zram;
11053 +
11054 + zram = bdev->bd_disk->private_data;
11055 +- down_write(&zram->lock);
11056 + zram_free_page(zram, index);
11057 +- up_write(&zram->lock);
11058 + zram_stat64_inc(zram, &zram->stats.notify_free);
11059 + }
11060 +
11061 +diff --git a/drivers/staging/zram/zram_drv.h b/drivers/staging/zram/zram_drv.h
11062 +index 87f2fec1bc94..e5cd2469b6a0 100644
11063 +--- a/drivers/staging/zram/zram_drv.h
11064 ++++ b/drivers/staging/zram/zram_drv.h
11065 +@@ -107,9 +107,8 @@ struct zram {
11066 + void *compress_buffer;
11067 + struct table *table;
11068 + spinlock_t stat64_lock; /* protect 64-bit stats */
11069 +- struct rw_semaphore lock; /* protect compression buffers, table,
11070 +- * 32bit stat counters against concurrent
11071 +- * notifications, reads and writes */
11072 ++ struct rw_semaphore lock; /* protect compression buffers and table
11073 ++ * against concurrent read and writes */
11074 + struct request_queue *queue;
11075 + struct gendisk *disk;
11076 + int init_done;
11077 +diff --git a/drivers/tty/serial/pch_uart.c b/drivers/tty/serial/pch_uart.c
11078 +index c0b487284d9b..f5440a7da589 100644
11079 +--- a/drivers/tty/serial/pch_uart.c
11080 ++++ b/drivers/tty/serial/pch_uart.c
11081 +@@ -552,11 +552,12 @@ static int dma_push_rx(struct eg20t_port *priv, int size)
11082 + dev_warn(port->dev, "Rx overrun: dropping %u bytes\n",
11083 + size - room);
11084 + if (!room)
11085 +- return room;
11086 ++ goto out;
11087 +
11088 + tty_insert_flip_string(tty, sg_virt(&priv->sg_rx), size);
11089 +
11090 + port->icount.rx += room;
11091 ++out:
11092 + tty_kref_put(tty);
11093 +
11094 + return room;
11095 +@@ -970,6 +971,8 @@ static void pch_uart_err_ir(struct eg20t_port *priv, unsigned int lsr)
11096 + if (tty == NULL) {
11097 + for (i = 0; error_msg[i] != NULL; i++)
11098 + dev_err(&priv->pdev->dev, error_msg[i]);
11099 ++ } else {
11100 ++ tty_kref_put(tty);
11101 + }
11102 + }
11103 +
11104 +diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c
11105 +index fe8c04b739be..06dfb4fb331f 100644
11106 +--- a/drivers/usb/class/cdc-wdm.c
11107 ++++ b/drivers/usb/class/cdc-wdm.c
11108 +@@ -187,6 +187,7 @@ skip_error:
11109 + static void wdm_int_callback(struct urb *urb)
11110 + {
11111 + int rv = 0;
11112 ++ int responding;
11113 + int status = urb->status;
11114 + struct wdm_device *desc;
11115 + struct usb_ctrlrequest *req;
11116 +@@ -260,8 +261,8 @@ static void wdm_int_callback(struct urb *urb)
11117 + desc->response->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
11118 + spin_lock(&desc->iuspin);
11119 + clear_bit(WDM_READ, &desc->flags);
11120 +- set_bit(WDM_RESPONDING, &desc->flags);
11121 +- if (!test_bit(WDM_DISCONNECTING, &desc->flags)
11122 ++ responding = test_and_set_bit(WDM_RESPONDING, &desc->flags);
11123 ++ if (!responding && !test_bit(WDM_DISCONNECTING, &desc->flags)
11124 + && !test_bit(WDM_SUSPENDING, &desc->flags)) {
11125 + rv = usb_submit_urb(desc->response, GFP_ATOMIC);
11126 + dev_dbg(&desc->intf->dev, "%s: usb_submit_urb %d",
11127 +@@ -658,16 +659,20 @@ static void wdm_rxwork(struct work_struct *work)
11128 + {
11129 + struct wdm_device *desc = container_of(work, struct wdm_device, rxwork);
11130 + unsigned long flags;
11131 +- int rv;
11132 ++ int rv = 0;
11133 ++ int responding;
11134 +
11135 + spin_lock_irqsave(&desc->iuspin, flags);
11136 + if (test_bit(WDM_DISCONNECTING, &desc->flags)) {
11137 + spin_unlock_irqrestore(&desc->iuspin, flags);
11138 + } else {
11139 ++ responding = test_and_set_bit(WDM_RESPONDING, &desc->flags);
11140 + spin_unlock_irqrestore(&desc->iuspin, flags);
11141 +- rv = usb_submit_urb(desc->response, GFP_KERNEL);
11142 ++ if (!responding)
11143 ++ rv = usb_submit_urb(desc->response, GFP_KERNEL);
11144 + if (rv < 0 && rv != -EPERM) {
11145 + spin_lock_irqsave(&desc->iuspin, flags);
11146 ++ clear_bit(WDM_RESPONDING, &desc->flags);
11147 + if (!test_bit(WDM_DISCONNECTING, &desc->flags))
11148 + schedule_work(&desc->rxwork);
11149 + spin_unlock_irqrestore(&desc->iuspin, flags);
11150 +diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
11151 +index f4bdd0ce8d56..78609d302625 100644
11152 +--- a/drivers/usb/core/config.c
11153 ++++ b/drivers/usb/core/config.c
11154 +@@ -424,7 +424,8 @@ static int usb_parse_configuration(struct usb_device *dev, int cfgidx,
11155 +
11156 + memcpy(&config->desc, buffer, USB_DT_CONFIG_SIZE);
11157 + if (config->desc.bDescriptorType != USB_DT_CONFIG ||
11158 +- config->desc.bLength < USB_DT_CONFIG_SIZE) {
11159 ++ config->desc.bLength < USB_DT_CONFIG_SIZE ||
11160 ++ config->desc.bLength > size) {
11161 + dev_err(ddev, "invalid descriptor for config index %d: "
11162 + "type = 0x%X, length = %d\n", cfgidx,
11163 + config->desc.bDescriptorType, config->desc.bLength);
11164 +diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
11165 +index 22f770abc399..49257b3053da 100644
11166 +--- a/drivers/usb/core/devio.c
11167 ++++ b/drivers/usb/core/devio.c
11168 +@@ -646,6 +646,22 @@ static int check_ctrlrecip(struct dev_state *ps, unsigned int requesttype,
11169 + if ((index & ~USB_DIR_IN) == 0)
11170 + return 0;
11171 + ret = findintfep(ps->dev, index);
11172 ++ if (ret < 0) {
11173 ++ /*
11174 ++ * Some not fully compliant Win apps seem to get
11175 ++ * index wrong and have the endpoint number here
11176 ++ * rather than the endpoint address (with the
11177 ++ * correct direction). Win does let this through,
11178 ++ * so we'll not reject it here but leave it to
11179 ++ * the device to not break KVM. But we warn.
11180 ++ */
11181 ++ ret = findintfep(ps->dev, index ^ 0x80);
11182 ++ if (ret >= 0)
11183 ++ dev_info(&ps->dev->dev,
11184 ++ "%s: process %i (%s) requesting ep %02x but needs %02x\n",
11185 ++ __func__, task_pid_nr(current),
11186 ++ current->comm, index, index ^ 0x80);
11187 ++ }
11188 + if (ret >= 0)
11189 + ret = checkintf(ps, ret);
11190 + break;
11191 +diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
11192 +index 2768a7e7cf2e..a5ea85ff5c0d 100644
11193 +--- a/drivers/usb/core/hub.c
11194 ++++ b/drivers/usb/core/hub.c
11195 +@@ -3749,7 +3749,8 @@ static void hub_events(void)
11196 + hub->hdev->children[i - 1];
11197 +
11198 + dev_dbg(hub_dev, "warm reset port %d\n", i);
11199 +- if (!udev) {
11200 ++ if (!udev || !(portstatus &
11201 ++ USB_PORT_STAT_CONNECTION)) {
11202 + status = hub_port_reset(hub, i,
11203 + NULL, HUB_BH_RESET_TIME,
11204 + true);
11205 +@@ -3759,8 +3760,8 @@ static void hub_events(void)
11206 + usb_lock_device(udev);
11207 + status = usb_reset_device(udev);
11208 + usb_unlock_device(udev);
11209 ++ connect_change = 0;
11210 + }
11211 +- connect_change = 0;
11212 + }
11213 +
11214 + if (connect_change)
11215 +diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c
11216 +index f77c00042685..9edc582b7679 100644
11217 +--- a/drivers/usb/dwc3/dwc3-pci.c
11218 ++++ b/drivers/usb/dwc3/dwc3-pci.c
11219 +@@ -45,6 +45,8 @@
11220 + /* FIXME define these in <linux/pci_ids.h> */
11221 + #define PCI_VENDOR_ID_SYNOPSYS 0x16c3
11222 + #define PCI_DEVICE_ID_SYNOPSYS_HAPSUSB3 0xabcd
11223 ++#define PCI_DEVICE_ID_INTEL_BYT 0x0f37
11224 ++#define PCI_DEVICE_ID_INTEL_MRFLD 0x119e
11225 +
11226 + #define DWC3_PCI_DEVS_POSSIBLE 32
11227 +
11228 +@@ -191,6 +193,8 @@ static DEFINE_PCI_DEVICE_TABLE(dwc3_pci_id_table) = {
11229 + PCI_DEVICE(PCI_VENDOR_ID_SYNOPSYS,
11230 + PCI_DEVICE_ID_SYNOPSYS_HAPSUSB3),
11231 + },
11232 ++ { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BYT), },
11233 ++ { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_MRFLD), },
11234 + { } /* Terminating Entry */
11235 + };
11236 + MODULE_DEVICE_TABLE(pci, dwc3_pci_id_table);
11237 +diff --git a/drivers/usb/host/ehci-mxc.c b/drivers/usb/host/ehci-mxc.c
11238 +index 55978fcfa4b2..08744737c5ab 100644
11239 +--- a/drivers/usb/host/ehci-mxc.c
11240 ++++ b/drivers/usb/host/ehci-mxc.c
11241 +@@ -296,7 +296,7 @@ static int __exit ehci_mxc_drv_remove(struct platform_device *pdev)
11242 + if (pdata && pdata->exit)
11243 + pdata->exit(pdev);
11244 +
11245 +- if (pdata->otg)
11246 ++ if (pdata && pdata->otg)
11247 + otg_shutdown(pdata->otg);
11248 +
11249 + usb_remove_hcd(hcd);
11250 +diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
11251 +index b71e22e73263..29c042111714 100644
11252 +--- a/drivers/usb/host/ehci-pci.c
11253 ++++ b/drivers/usb/host/ehci-pci.c
11254 +@@ -543,7 +543,7 @@ static struct pci_driver ehci_pci_driver = {
11255 + .remove = usb_hcd_pci_remove,
11256 + .shutdown = usb_hcd_pci_shutdown,
11257 +
11258 +-#ifdef CONFIG_PM_SLEEP
11259 ++#ifdef CONFIG_PM
11260 + .driver = {
11261 + .pm = &usb_hcd_pci_pm_ops
11262 + },
11263 +diff --git a/drivers/usb/host/ohci-pci.c b/drivers/usb/host/ohci-pci.c
11264 +index bc01b064585a..839cb648d248 100644
11265 +--- a/drivers/usb/host/ohci-pci.c
11266 ++++ b/drivers/usb/host/ohci-pci.c
11267 +@@ -413,7 +413,7 @@ static struct pci_driver ohci_pci_driver = {
11268 + .remove = usb_hcd_pci_remove,
11269 + .shutdown = usb_hcd_pci_shutdown,
11270 +
11271 +-#ifdef CONFIG_PM_SLEEP
11272 ++#ifdef CONFIG_PM
11273 + .driver = {
11274 + .pm = &usb_hcd_pci_pm_ops
11275 + },
11276 +diff --git a/drivers/usb/host/uhci-pci.c b/drivers/usb/host/uhci-pci.c
11277 +index c300bd2f7d1c..0f228c46eeda 100644
11278 +--- a/drivers/usb/host/uhci-pci.c
11279 ++++ b/drivers/usb/host/uhci-pci.c
11280 +@@ -293,7 +293,7 @@ static struct pci_driver uhci_pci_driver = {
11281 + .remove = usb_hcd_pci_remove,
11282 + .shutdown = uhci_shutdown,
11283 +
11284 +-#ifdef CONFIG_PM_SLEEP
11285 ++#ifdef CONFIG_PM
11286 + .driver = {
11287 + .pm = &usb_hcd_pci_pm_ops
11288 + },
11289 +diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
11290 +index 79d27209c563..61b06688c916 100644
11291 +--- a/drivers/usb/host/xhci-pci.c
11292 ++++ b/drivers/usb/host/xhci-pci.c
11293 +@@ -330,7 +330,7 @@ static struct pci_driver xhci_pci_driver = {
11294 + /* suspend and resume implemented later */
11295 +
11296 + .shutdown = usb_hcd_pci_shutdown,
11297 +-#ifdef CONFIG_PM_SLEEP
11298 ++#ifdef CONFIG_PM
11299 + .driver = {
11300 + .pm = &usb_hcd_pci_pm_ops
11301 + },
11302 +diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
11303 +index 633476e25bbc..2b4f42bac98f 100644
11304 +--- a/drivers/usb/host/xhci-ring.c
11305 ++++ b/drivers/usb/host/xhci-ring.c
11306 +@@ -879,8 +879,12 @@ remove_finished_td:
11307 + /* Otherwise ring the doorbell(s) to restart queued transfers */
11308 + ring_doorbell_for_active_rings(xhci, slot_id, ep_index);
11309 + }
11310 +- ep->stopped_td = NULL;
11311 +- ep->stopped_trb = NULL;
11312 ++
11313 ++ /* Clear stopped_td and stopped_trb if endpoint is not halted */
11314 ++ if (!(ep->ep_state & EP_HALTED)) {
11315 ++ ep->stopped_td = NULL;
11316 ++ ep->stopped_trb = NULL;
11317 ++ }
11318 +
11319 + /*
11320 + * Drop the lock and complete the URBs in the cancelled TD list.
11321 +diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
11322 +index 6e1c92a11eb0..629aa743e45b 100644
11323 +--- a/drivers/usb/host/xhci.c
11324 ++++ b/drivers/usb/host/xhci.c
11325 +@@ -3484,10 +3484,21 @@ void xhci_free_dev(struct usb_hcd *hcd, struct usb_device *udev)
11326 + {
11327 + struct xhci_hcd *xhci = hcd_to_xhci(hcd);
11328 + struct xhci_virt_device *virt_dev;
11329 ++ struct device *dev = hcd->self.controller;
11330 + unsigned long flags;
11331 + u32 state;
11332 + int i, ret;
11333 +
11334 ++#ifndef CONFIG_USB_DEFAULT_PERSIST
11335 ++ /*
11336 ++ * We called pm_runtime_get_noresume when the device was attached.
11337 ++ * Decrement the counter here to allow controller to runtime suspend
11338 ++ * if no devices remain.
11339 ++ */
11340 ++ if (xhci->quirks & XHCI_RESET_ON_RESUME)
11341 ++ pm_runtime_put_noidle(dev);
11342 ++#endif
11343 ++
11344 + ret = xhci_check_args(hcd, udev, NULL, 0, true, __func__);
11345 + /* If the host is halted due to driver unload, we still need to free the
11346 + * device.
11347 +@@ -3559,6 +3570,7 @@ static int xhci_reserve_host_control_ep_resources(struct xhci_hcd *xhci)
11348 + int xhci_alloc_dev(struct usb_hcd *hcd, struct usb_device *udev)
11349 + {
11350 + struct xhci_hcd *xhci = hcd_to_xhci(hcd);
11351 ++ struct device *dev = hcd->self.controller;
11352 + unsigned long flags;
11353 + int timeleft;
11354 + int ret;
11355 +@@ -3611,6 +3623,16 @@ int xhci_alloc_dev(struct usb_hcd *hcd, struct usb_device *udev)
11356 + goto disable_slot;
11357 + }
11358 + udev->slot_id = xhci->slot_id;
11359 ++
11360 ++#ifndef CONFIG_USB_DEFAULT_PERSIST
11361 ++ /*
11362 ++ * If resetting upon resume, we can't put the controller into runtime
11363 ++ * suspend if there is a device attached.
11364 ++ */
11365 ++ if (xhci->quirks & XHCI_RESET_ON_RESUME)
11366 ++ pm_runtime_get_noresume(dev);
11367 ++#endif
11368 ++
11369 + /* Is this a LS or FS device under a HS hub? */
11370 + /* Hub or peripherial? */
11371 + return 1;
11372 +diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c
11373 +index 9270d5c919cf..8e02ff2b7d7f 100644
11374 +--- a/drivers/usb/serial/mos7720.c
11375 ++++ b/drivers/usb/serial/mos7720.c
11376 +@@ -383,7 +383,7 @@ static int write_parport_reg_nonblock(struct mos7715_parport *mos_parport,
11377 + kfree(urbtrack);
11378 + return -ENOMEM;
11379 + }
11380 +- urbtrack->setup = kmalloc(sizeof(*urbtrack->setup), GFP_KERNEL);
11381 ++ urbtrack->setup = kmalloc(sizeof(*urbtrack->setup), GFP_ATOMIC);
11382 + if (!urbtrack->setup) {
11383 + usb_free_urb(urbtrack->urb);
11384 + kfree(urbtrack);
11385 +@@ -391,8 +391,8 @@ static int write_parport_reg_nonblock(struct mos7715_parport *mos_parport,
11386 + }
11387 + urbtrack->setup->bRequestType = (__u8)0x40;
11388 + urbtrack->setup->bRequest = (__u8)0x0e;
11389 +- urbtrack->setup->wValue = get_reg_value(reg, dummy);
11390 +- urbtrack->setup->wIndex = get_reg_index(reg);
11391 ++ urbtrack->setup->wValue = cpu_to_le16(get_reg_value(reg, dummy));
11392 ++ urbtrack->setup->wIndex = cpu_to_le16(get_reg_index(reg));
11393 + urbtrack->setup->wLength = 0;
11394 + usb_fill_control_urb(urbtrack->urb, usbdev,
11395 + usb_sndctrlpipe(usbdev, 0),
11396 +diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
11397 +index c2103f404b3c..536c4ad2f5b7 100644
11398 +--- a/drivers/usb/serial/option.c
11399 ++++ b/drivers/usb/serial/option.c
11400 +@@ -81,6 +81,7 @@ static void option_instat_callback(struct urb *urb);
11401 +
11402 + #define HUAWEI_VENDOR_ID 0x12D1
11403 + #define HUAWEI_PRODUCT_E173 0x140C
11404 ++#define HUAWEI_PRODUCT_E1750 0x1406
11405 + #define HUAWEI_PRODUCT_K4505 0x1464
11406 + #define HUAWEI_PRODUCT_K3765 0x1465
11407 + #define HUAWEI_PRODUCT_K4605 0x14C6
11408 +@@ -581,6 +582,8 @@ static const struct usb_device_id option_ids[] = {
11409 + { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0x1c23, USB_CLASS_COMM, 0x02, 0xff) },
11410 + { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E173, 0xff, 0xff, 0xff),
11411 + .driver_info = (kernel_ulong_t) &net_intf1_blacklist },
11412 ++ { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1750, 0xff, 0xff, 0xff),
11413 ++ .driver_info = (kernel_ulong_t) &net_intf2_blacklist },
11414 + { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0x1441, USB_CLASS_COMM, 0x02, 0xff) },
11415 + { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0x1442, USB_CLASS_COMM, 0x02, 0xff) },
11416 + { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_K4505, 0xff, 0xff, 0xff),
11417 +diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c
11418 +index bf1c094f4ebf..b657de614a06 100644
11419 +--- a/drivers/xen/grant-table.c
11420 ++++ b/drivers/xen/grant-table.c
11421 +@@ -355,9 +355,18 @@ void gnttab_request_free_callback(struct gnttab_free_callback *callback,
11422 + void (*fn)(void *), void *arg, u16 count)
11423 + {
11424 + unsigned long flags;
11425 ++ struct gnttab_free_callback *cb;
11426 ++
11427 + spin_lock_irqsave(&gnttab_list_lock, flags);
11428 +- if (callback->next)
11429 +- goto out;
11430 ++
11431 ++ /* Check if the callback is already on the list */
11432 ++ cb = gnttab_free_callback_list;
11433 ++ while (cb) {
11434 ++ if (cb == callback)
11435 ++ goto out;
11436 ++ cb = cb->next;
11437 ++ }
11438 ++
11439 + callback->fn = fn;
11440 + callback->arg = arg;
11441 + callback->count = count;
11442 +diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
11443 +index f3a257d7a985..fb001cde0af3 100644
11444 +--- a/fs/debugfs/inode.c
11445 ++++ b/fs/debugfs/inode.c
11446 +@@ -380,8 +380,7 @@ EXPORT_SYMBOL_GPL(debugfs_remove);
11447 + */
11448 + void debugfs_remove_recursive(struct dentry *dentry)
11449 + {
11450 +- struct dentry *child;
11451 +- struct dentry *parent;
11452 ++ struct dentry *child, *next, *parent;
11453 +
11454 + if (!dentry)
11455 + return;
11456 +@@ -391,61 +390,37 @@ void debugfs_remove_recursive(struct dentry *dentry)
11457 + return;
11458 +
11459 + parent = dentry;
11460 ++ down:
11461 + mutex_lock(&parent->d_inode->i_mutex);
11462 ++ list_for_each_entry_safe(child, next, &parent->d_subdirs, d_u.d_child) {
11463 ++ if (!debugfs_positive(child))
11464 ++ continue;
11465 +
11466 +- while (1) {
11467 +- /*
11468 +- * When all dentries under "parent" has been removed,
11469 +- * walk up the tree until we reach our starting point.
11470 +- */
11471 +- if (list_empty(&parent->d_subdirs)) {
11472 +- mutex_unlock(&parent->d_inode->i_mutex);
11473 +- if (parent == dentry)
11474 +- break;
11475 +- parent = parent->d_parent;
11476 +- mutex_lock(&parent->d_inode->i_mutex);
11477 +- }
11478 +- child = list_entry(parent->d_subdirs.next, struct dentry,
11479 +- d_u.d_child);
11480 +- next_sibling:
11481 +-
11482 +- /*
11483 +- * If "child" isn't empty, walk down the tree and
11484 +- * remove all its descendants first.
11485 +- */
11486 ++ /* perhaps simple_empty(child) makes more sense */
11487 + if (!list_empty(&child->d_subdirs)) {
11488 + mutex_unlock(&parent->d_inode->i_mutex);
11489 + parent = child;
11490 +- mutex_lock(&parent->d_inode->i_mutex);
11491 +- continue;
11492 +- }
11493 +- __debugfs_remove(child, parent);
11494 +- if (parent->d_subdirs.next == &child->d_u.d_child) {
11495 +- /*
11496 +- * Try the next sibling.
11497 +- */
11498 +- if (child->d_u.d_child.next != &parent->d_subdirs) {
11499 +- child = list_entry(child->d_u.d_child.next,
11500 +- struct dentry,
11501 +- d_u.d_child);
11502 +- goto next_sibling;
11503 +- }
11504 +-
11505 +- /*
11506 +- * Avoid infinite loop if we fail to remove
11507 +- * one dentry.
11508 +- */
11509 +- mutex_unlock(&parent->d_inode->i_mutex);
11510 +- break;
11511 ++ goto down;
11512 + }
11513 +- simple_release_fs(&debugfs_mount, &debugfs_mount_count);
11514 ++ up:
11515 ++ if (!__debugfs_remove(child, parent))
11516 ++ simple_release_fs(&debugfs_mount, &debugfs_mount_count);
11517 + }
11518 +
11519 +- parent = dentry->d_parent;
11520 ++ mutex_unlock(&parent->d_inode->i_mutex);
11521 ++ child = parent;
11522 ++ parent = parent->d_parent;
11523 + mutex_lock(&parent->d_inode->i_mutex);
11524 +- __debugfs_remove(dentry, parent);
11525 ++
11526 ++ if (child != dentry) {
11527 ++ next = list_entry(child->d_u.d_child.next, struct dentry,
11528 ++ d_u.d_child);
11529 ++ goto up;
11530 ++ }
11531 ++
11532 ++ if (!__debugfs_remove(child, parent))
11533 ++ simple_release_fs(&debugfs_mount, &debugfs_mount_count);
11534 + mutex_unlock(&parent->d_inode->i_mutex);
11535 +- simple_release_fs(&debugfs_mount, &debugfs_mount_count);
11536 + }
11537 + EXPORT_SYMBOL_GPL(debugfs_remove_recursive);
11538 +
11539 +diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
11540 +index 3ca3b7fabb1b..2e0e34f957cc 100644
11541 +--- a/fs/ext4/namei.c
11542 ++++ b/fs/ext4/namei.c
11543 +@@ -2054,7 +2054,8 @@ int ext4_orphan_del(handle_t *handle, struct inode *inode)
11544 + int err = 0;
11545 +
11546 + /* ext4_handle_valid() assumes a valid handle_t pointer */
11547 +- if (handle && !ext4_handle_valid(handle))
11548 ++ if (handle && !ext4_handle_valid(handle) &&
11549 ++ !(EXT4_SB(inode->i_sb)->s_mount_state & EXT4_ORPHAN_FS))
11550 + return 0;
11551 +
11552 + mutex_lock(&EXT4_SB(inode->i_sb)->s_orphan_lock);
11553 +diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
11554 +index 5ef7afb9cf3e..06e2f73e64a8 100644
11555 +--- a/fs/fuse/dir.c
11556 ++++ b/fs/fuse/dir.c
11557 +@@ -1063,6 +1063,8 @@ static int parse_dirfile(char *buf, size_t nbytes, struct file *file,
11558 + return -EIO;
11559 + if (reclen > nbytes)
11560 + break;
11561 ++ if (memchr(dirent->name, '/', dirent->namelen) != NULL)
11562 ++ return -EIO;
11563 +
11564 + over = filldir(dstbuf, dirent->name, dirent->namelen,
11565 + file->f_pos, dirent->ino, dirent->type);
11566 +@@ -1282,6 +1284,7 @@ static int fuse_do_setattr(struct dentry *entry, struct iattr *attr,
11567 + {
11568 + struct inode *inode = entry->d_inode;
11569 + struct fuse_conn *fc = get_fuse_conn(inode);
11570 ++ struct fuse_inode *fi = get_fuse_inode(inode);
11571 + struct fuse_req *req;
11572 + struct fuse_setattr_in inarg;
11573 + struct fuse_attr_out outarg;
11574 +@@ -1312,8 +1315,10 @@ static int fuse_do_setattr(struct dentry *entry, struct iattr *attr,
11575 + if (IS_ERR(req))
11576 + return PTR_ERR(req);
11577 +
11578 +- if (is_truncate)
11579 ++ if (is_truncate) {
11580 + fuse_set_nowrite(inode);
11581 ++ set_bit(FUSE_I_SIZE_UNSTABLE, &fi->state);
11582 ++ }
11583 +
11584 + memset(&inarg, 0, sizeof(inarg));
11585 + memset(&outarg, 0, sizeof(outarg));
11586 +@@ -1375,12 +1380,14 @@ static int fuse_do_setattr(struct dentry *entry, struct iattr *attr,
11587 + invalidate_inode_pages2(inode->i_mapping);
11588 + }
11589 +
11590 ++ clear_bit(FUSE_I_SIZE_UNSTABLE, &fi->state);
11591 + return 0;
11592 +
11593 + error:
11594 + if (is_truncate)
11595 + fuse_release_nowrite(inode);
11596 +
11597 ++ clear_bit(FUSE_I_SIZE_UNSTABLE, &fi->state);
11598 + return err;
11599 + }
11600 +
11601 +@@ -1439,6 +1446,8 @@ static int fuse_setxattr(struct dentry *entry, const char *name,
11602 + fc->no_setxattr = 1;
11603 + err = -EOPNOTSUPP;
11604 + }
11605 ++ if (!err)
11606 ++ fuse_invalidate_attr(inode);
11607 + return err;
11608 + }
11609 +
11610 +@@ -1568,6 +1577,8 @@ static int fuse_removexattr(struct dentry *entry, const char *name)
11611 + fc->no_removexattr = 1;
11612 + err = -EOPNOTSUPP;
11613 + }
11614 ++ if (!err)
11615 ++ fuse_invalidate_attr(inode);
11616 + return err;
11617 + }
11618 +
11619 +diff --git a/fs/fuse/file.c b/fs/fuse/file.c
11620 +index 5242006b9515..510d4aa26686 100644
11621 +--- a/fs/fuse/file.c
11622 ++++ b/fs/fuse/file.c
11623 +@@ -519,7 +519,8 @@ static void fuse_read_update_size(struct inode *inode, loff_t size,
11624 + struct fuse_inode *fi = get_fuse_inode(inode);
11625 +
11626 + spin_lock(&fc->lock);
11627 +- if (attr_ver == fi->attr_version && size < inode->i_size) {
11628 ++ if (attr_ver == fi->attr_version && size < inode->i_size &&
11629 ++ !test_bit(FUSE_I_SIZE_UNSTABLE, &fi->state)) {
11630 + fi->attr_version = ++fc->attr_version;
11631 + i_size_write(inode, size);
11632 + }
11633 +@@ -881,12 +882,16 @@ static ssize_t fuse_perform_write(struct file *file,
11634 + {
11635 + struct inode *inode = mapping->host;
11636 + struct fuse_conn *fc = get_fuse_conn(inode);
11637 ++ struct fuse_inode *fi = get_fuse_inode(inode);
11638 + int err = 0;
11639 + ssize_t res = 0;
11640 +
11641 + if (is_bad_inode(inode))
11642 + return -EIO;
11643 +
11644 ++ if (inode->i_size < pos + iov_iter_count(ii))
11645 ++ set_bit(FUSE_I_SIZE_UNSTABLE, &fi->state);
11646 ++
11647 + do {
11648 + struct fuse_req *req;
11649 + ssize_t count;
11650 +@@ -921,6 +926,7 @@ static ssize_t fuse_perform_write(struct file *file,
11651 + if (res > 0)
11652 + fuse_write_update_size(inode, pos);
11653 +
11654 ++ clear_bit(FUSE_I_SIZE_UNSTABLE, &fi->state);
11655 + fuse_invalidate_attr(inode);
11656 +
11657 + return res > 0 ? res : err;
11658 +@@ -1251,7 +1257,6 @@ static int fuse_writepage_locked(struct page *page)
11659 +
11660 + inc_bdi_stat(mapping->backing_dev_info, BDI_WRITEBACK);
11661 + inc_zone_page_state(tmp_page, NR_WRITEBACK_TEMP);
11662 +- end_page_writeback(page);
11663 +
11664 + spin_lock(&fc->lock);
11665 + list_add(&req->writepages_entry, &fi->writepages);
11666 +@@ -1259,6 +1264,8 @@ static int fuse_writepage_locked(struct page *page)
11667 + fuse_flush_writepages(inode);
11668 + spin_unlock(&fc->lock);
11669 +
11670 ++ end_page_writeback(page);
11671 ++
11672 + return 0;
11673 +
11674 + err_free:
11675 +diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
11676 +index 89c4a58bc364..52ffd2496fb5 100644
11677 +--- a/fs/fuse/fuse_i.h
11678 ++++ b/fs/fuse/fuse_i.h
11679 +@@ -103,6 +103,15 @@ struct fuse_inode {
11680 +
11681 + /** List of writepage requestst (pending or sent) */
11682 + struct list_head writepages;
11683 ++
11684 ++ /** Miscellaneous bits describing inode state */
11685 ++ unsigned long state;
11686 ++};
11687 ++
11688 ++/** FUSE inode state bits */
11689 ++enum {
11690 ++ /** An operation changing file size is in progress */
11691 ++ FUSE_I_SIZE_UNSTABLE,
11692 + };
11693 +
11694 + struct fuse_conn;
11695 +diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
11696 +index 1f82d953305c..912c250b314a 100644
11697 +--- a/fs/fuse/inode.c
11698 ++++ b/fs/fuse/inode.c
11699 +@@ -92,6 +92,7 @@ static struct inode *fuse_alloc_inode(struct super_block *sb)
11700 + fi->attr_version = 0;
11701 + fi->writectr = 0;
11702 + fi->orig_ino = 0;
11703 ++ fi->state = 0;
11704 + INIT_LIST_HEAD(&fi->write_files);
11705 + INIT_LIST_HEAD(&fi->queued_writes);
11706 + INIT_LIST_HEAD(&fi->writepages);
11707 +@@ -200,7 +201,8 @@ void fuse_change_attributes(struct inode *inode, struct fuse_attr *attr,
11708 + loff_t oldsize;
11709 +
11710 + spin_lock(&fc->lock);
11711 +- if (attr_version != 0 && fi->attr_version > attr_version) {
11712 ++ if ((attr_version != 0 && fi->attr_version > attr_version) ||
11713 ++ test_bit(FUSE_I_SIZE_UNSTABLE, &fi->state)) {
11714 + spin_unlock(&fc->lock);
11715 + return;
11716 + }
11717 +diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c
11718 +index f950059525fc..a5f25a70c015 100644
11719 +--- a/fs/isofs/inode.c
11720 ++++ b/fs/isofs/inode.c
11721 +@@ -120,8 +120,8 @@ static void destroy_inodecache(void)
11722 +
11723 + static int isofs_remount(struct super_block *sb, int *flags, char *data)
11724 + {
11725 +- /* we probably want a lot more here */
11726 +- *flags |= MS_RDONLY;
11727 ++ if (!(*flags & MS_RDONLY))
11728 ++ return -EROFS;
11729 + return 0;
11730 + }
11731 +
11732 +@@ -770,15 +770,6 @@ root_found:
11733 + */
11734 + s->s_maxbytes = 0x80000000000LL;
11735 +
11736 +- /*
11737 +- * The CDROM is read-only, has no nodes (devices) on it, and since
11738 +- * all of the files appear to be owned by root, we really do not want
11739 +- * to allow suid. (suid or devices will not show up unless we have
11740 +- * Rock Ridge extensions)
11741 +- */
11742 +-
11743 +- s->s_flags |= MS_RDONLY /* | MS_NODEV | MS_NOSUID */;
11744 +-
11745 + /* Set this for reference. Its not currently used except on write
11746 + which we don't have .. */
11747 +
11748 +@@ -1535,6 +1526,9 @@ struct inode *isofs_iget(struct super_block *sb,
11749 + static struct dentry *isofs_mount(struct file_system_type *fs_type,
11750 + int flags, const char *dev_name, void *data)
11751 + {
11752 ++ /* We don't support read-write mounts */
11753 ++ if (!(flags & MS_RDONLY))
11754 ++ return ERR_PTR(-EACCES);
11755 + return mount_bdev(fs_type, flags, dev_name, data, isofs_fill_super);
11756 + }
11757 +
11758 +diff --git a/fs/nilfs2/page.c b/fs/nilfs2/page.c
11759 +index 65221a04c6f0..16eacece560f 100644
11760 +--- a/fs/nilfs2/page.c
11761 ++++ b/fs/nilfs2/page.c
11762 +@@ -94,6 +94,7 @@ void nilfs_forget_buffer(struct buffer_head *bh)
11763 + clear_buffer_nilfs_volatile(bh);
11764 + clear_buffer_nilfs_checked(bh);
11765 + clear_buffer_nilfs_redirected(bh);
11766 ++ clear_buffer_async_write(bh);
11767 + clear_buffer_dirty(bh);
11768 + if (nilfs_page_buffers_clean(page))
11769 + __nilfs_clear_page_dirty(page);
11770 +@@ -390,6 +391,7 @@ void nilfs_clear_dirty_pages(struct address_space *mapping)
11771 + bh = head = page_buffers(page);
11772 + do {
11773 + lock_buffer(bh);
11774 ++ clear_buffer_async_write(bh);
11775 + clear_buffer_dirty(bh);
11776 + clear_buffer_nilfs_volatile(bh);
11777 + clear_buffer_nilfs_checked(bh);
11778 +diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c
11779 +index 6f24e67162c0..233d3ed264fa 100644
11780 +--- a/fs/nilfs2/segment.c
11781 ++++ b/fs/nilfs2/segment.c
11782 +@@ -662,7 +662,7 @@ static size_t nilfs_lookup_dirty_data_buffers(struct inode *inode,
11783 +
11784 + bh = head = page_buffers(page);
11785 + do {
11786 +- if (!buffer_dirty(bh))
11787 ++ if (!buffer_dirty(bh) || buffer_async_write(bh))
11788 + continue;
11789 + get_bh(bh);
11790 + list_add_tail(&bh->b_assoc_buffers, listp);
11791 +@@ -696,7 +696,8 @@ static void nilfs_lookup_dirty_node_buffers(struct inode *inode,
11792 + for (i = 0; i < pagevec_count(&pvec); i++) {
11793 + bh = head = page_buffers(pvec.pages[i]);
11794 + do {
11795 +- if (buffer_dirty(bh)) {
11796 ++ if (buffer_dirty(bh) &&
11797 ++ !buffer_async_write(bh)) {
11798 + get_bh(bh);
11799 + list_add_tail(&bh->b_assoc_buffers,
11800 + listp);
11801 +@@ -1576,6 +1577,7 @@ static void nilfs_segctor_prepare_write(struct nilfs_sc_info *sci)
11802 +
11803 + list_for_each_entry(bh, &segbuf->sb_segsum_buffers,
11804 + b_assoc_buffers) {
11805 ++ set_buffer_async_write(bh);
11806 + if (bh->b_page != bd_page) {
11807 + if (bd_page) {
11808 + lock_page(bd_page);
11809 +@@ -1589,6 +1591,7 @@ static void nilfs_segctor_prepare_write(struct nilfs_sc_info *sci)
11810 +
11811 + list_for_each_entry(bh, &segbuf->sb_payload_buffers,
11812 + b_assoc_buffers) {
11813 ++ set_buffer_async_write(bh);
11814 + if (bh == segbuf->sb_super_root) {
11815 + if (bh->b_page != bd_page) {
11816 + lock_page(bd_page);
11817 +@@ -1674,6 +1677,7 @@ static void nilfs_abort_logs(struct list_head *logs, int err)
11818 + list_for_each_entry(segbuf, logs, sb_list) {
11819 + list_for_each_entry(bh, &segbuf->sb_segsum_buffers,
11820 + b_assoc_buffers) {
11821 ++ clear_buffer_async_write(bh);
11822 + if (bh->b_page != bd_page) {
11823 + if (bd_page)
11824 + end_page_writeback(bd_page);
11825 +@@ -1683,6 +1687,7 @@ static void nilfs_abort_logs(struct list_head *logs, int err)
11826 +
11827 + list_for_each_entry(bh, &segbuf->sb_payload_buffers,
11828 + b_assoc_buffers) {
11829 ++ clear_buffer_async_write(bh);
11830 + if (bh == segbuf->sb_super_root) {
11831 + if (bh->b_page != bd_page) {
11832 + end_page_writeback(bd_page);
11833 +@@ -1752,6 +1757,7 @@ static void nilfs_segctor_complete_write(struct nilfs_sc_info *sci)
11834 + b_assoc_buffers) {
11835 + set_buffer_uptodate(bh);
11836 + clear_buffer_dirty(bh);
11837 ++ clear_buffer_async_write(bh);
11838 + if (bh->b_page != bd_page) {
11839 + if (bd_page)
11840 + end_page_writeback(bd_page);
11841 +@@ -1773,6 +1779,7 @@ static void nilfs_segctor_complete_write(struct nilfs_sc_info *sci)
11842 + b_assoc_buffers) {
11843 + set_buffer_uptodate(bh);
11844 + clear_buffer_dirty(bh);
11845 ++ clear_buffer_async_write(bh);
11846 + clear_buffer_delay(bh);
11847 + clear_buffer_nilfs_volatile(bh);
11848 + clear_buffer_nilfs_redirected(bh);
11849 +diff --git a/fs/notify/fanotify/fanotify.c b/fs/notify/fanotify/fanotify.c
11850 +index a50636025364..0c2f9122b262 100644
11851 +--- a/fs/notify/fanotify/fanotify.c
11852 ++++ b/fs/notify/fanotify/fanotify.c
11853 +@@ -18,6 +18,12 @@ static bool should_merge(struct fsnotify_event *old, struct fsnotify_event *new)
11854 + old->tgid == new->tgid) {
11855 + switch (old->data_type) {
11856 + case (FSNOTIFY_EVENT_PATH):
11857 ++#ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS
11858 ++ /* dont merge two permission events */
11859 ++ if ((old->mask & FAN_ALL_PERM_EVENTS) &&
11860 ++ (new->mask & FAN_ALL_PERM_EVENTS))
11861 ++ return false;
11862 ++#endif
11863 + if ((old->path.mnt == new->path.mnt) &&
11864 + (old->path.dentry == new->path.dentry))
11865 + return true;
11866 +diff --git a/fs/ocfs2/extent_map.c b/fs/ocfs2/extent_map.c
11867 +index 7eb1c0c7c166..cf228479879d 100644
11868 +--- a/fs/ocfs2/extent_map.c
11869 ++++ b/fs/ocfs2/extent_map.c
11870 +@@ -782,7 +782,6 @@ int ocfs2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
11871 + cpos = map_start >> osb->s_clustersize_bits;
11872 + mapping_end = ocfs2_clusters_for_bytes(inode->i_sb,
11873 + map_start + map_len);
11874 +- mapping_end -= cpos;
11875 + is_last = 0;
11876 + while (cpos < mapping_end && !is_last) {
11877 + u32 fe_flags;
11878 +diff --git a/include/linux/hid.h b/include/linux/hid.h
11879 +index 331e2ef7eaa5..19fe719ace3e 100644
11880 +--- a/include/linux/hid.h
11881 ++++ b/include/linux/hid.h
11882 +@@ -416,10 +416,12 @@ struct hid_report {
11883 + struct hid_device *device; /* associated device */
11884 + };
11885 +
11886 ++#define HID_MAX_IDS 256
11887 ++
11888 + struct hid_report_enum {
11889 + unsigned numbered;
11890 + struct list_head report_list;
11891 +- struct hid_report *report_id_hash[256];
11892 ++ struct hid_report *report_id_hash[HID_MAX_IDS];
11893 + };
11894 +
11895 + #define HID_REPORT_TYPES 3
11896 +@@ -716,6 +718,10 @@ void hid_output_report(struct hid_report *report, __u8 *data);
11897 + struct hid_device *hid_allocate_device(void);
11898 + struct hid_report *hid_register_report(struct hid_device *device, unsigned type, unsigned id);
11899 + int hid_parse_report(struct hid_device *hid, __u8 *start, unsigned size);
11900 ++struct hid_report *hid_validate_values(struct hid_device *hid,
11901 ++ unsigned int type, unsigned int id,
11902 ++ unsigned int field_index,
11903 ++ unsigned int report_counts);
11904 + int hid_check_keys_pressed(struct hid_device *hid);
11905 + int hid_connect(struct hid_device *hid, unsigned int connect_mask);
11906 + void hid_disconnect(struct hid_device *hid);
11907 +diff --git a/include/linux/icmpv6.h b/include/linux/icmpv6.h
11908 +index ba45e6bc0764..f5a21d0a22ba 100644
11909 +--- a/include/linux/icmpv6.h
11910 ++++ b/include/linux/icmpv6.h
11911 +@@ -123,6 +123,8 @@ static inline struct icmp6hdr *icmp6_hdr(const struct sk_buff *skb)
11912 + #define ICMPV6_NOT_NEIGHBOUR 2
11913 + #define ICMPV6_ADDR_UNREACH 3
11914 + #define ICMPV6_PORT_UNREACH 4
11915 ++#define ICMPV6_POLICY_FAIL 5
11916 ++#define ICMPV6_REJECT_ROUTE 6
11917 +
11918 + /*
11919 + * Codes for Time Exceeded
11920 +diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h
11921 +index 0c997767429a..84b1447481b5 100644
11922 +--- a/include/linux/ipv6.h
11923 ++++ b/include/linux/ipv6.h
11924 +@@ -255,6 +255,7 @@ struct inet6_skb_parm {
11925 + #define IP6SKB_XFRM_TRANSFORMED 1
11926 + #define IP6SKB_FORWARDED 2
11927 + #define IP6SKB_REROUTED 4
11928 ++#define IP6SKB_FRAGMENTED 16
11929 + };
11930 +
11931 + #define IP6CB(skb) ((struct inet6_skb_parm*)((skb)->cb))
11932 +diff --git a/include/linux/mm.h b/include/linux/mm.h
11933 +index d0493f6064f3..305fd756fc4f 100644
11934 +--- a/include/linux/mm.h
11935 ++++ b/include/linux/mm.h
11936 +@@ -865,7 +865,8 @@ extern void pagefault_out_of_memory(void);
11937 + * Flags passed to show_mem() and show_free_areas() to suppress output in
11938 + * various contexts.
11939 + */
11940 +-#define SHOW_MEM_FILTER_NODES (0x0001u) /* filter disallowed nodes */
11941 ++#define SHOW_MEM_FILTER_NODES (0x0001u) /* disallowed nodes */
11942 ++#define SHOW_MEM_FILTER_PAGE_COUNT (0x0002u) /* page type count */
11943 +
11944 + extern void show_free_areas(unsigned int flags);
11945 + extern bool skip_free_areas_node(unsigned int flags, int nid);
11946 +diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
11947 +index 3cfcfea6bfc9..eeb6a29ee1e1 100644
11948 +--- a/include/linux/perf_event.h
11949 ++++ b/include/linux/perf_event.h
11950 +@@ -927,7 +927,7 @@ struct perf_cpu_context {
11951 + int exclusive;
11952 + struct list_head rotation_list;
11953 + int jiffies_interval;
11954 +- struct pmu *active_pmu;
11955 ++ struct pmu *unique_pmu;
11956 + struct perf_cgroup *cgrp;
11957 + };
11958 +
11959 +diff --git a/include/linux/rculist.h b/include/linux/rculist.h
11960 +index 6f95e241ed68..3863352656e7 100644
11961 +--- a/include/linux/rculist.h
11962 ++++ b/include/linux/rculist.h
11963 +@@ -254,8 +254,9 @@ static inline void list_splice_init_rcu(struct list_head *list,
11964 + */
11965 + #define list_first_or_null_rcu(ptr, type, member) \
11966 + ({struct list_head *__ptr = (ptr); \
11967 +- struct list_head __rcu *__next = list_next_rcu(__ptr); \
11968 +- likely(__ptr != __next) ? container_of(__next, type, member) : NULL; \
11969 ++ struct list_head *__next = ACCESS_ONCE(__ptr->next); \
11970 ++ likely(__ptr != __next) ? \
11971 ++ list_entry_rcu(__next, type, member) : NULL; \
11972 + })
11973 +
11974 + /**
11975 +diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h
11976 +index 03354d557b79..0daa46b82043 100644
11977 +--- a/include/linux/usb/hcd.h
11978 ++++ b/include/linux/usb/hcd.h
11979 +@@ -395,7 +395,7 @@ extern int usb_hcd_pci_probe(struct pci_dev *dev,
11980 + extern void usb_hcd_pci_remove(struct pci_dev *dev);
11981 + extern void usb_hcd_pci_shutdown(struct pci_dev *dev);
11982 +
11983 +-#ifdef CONFIG_PM_SLEEP
11984 ++#ifdef CONFIG_PM
11985 + extern const struct dev_pm_ops usb_hcd_pci_pm_ops;
11986 + #endif
11987 + #endif /* CONFIG_PCI */
11988 +diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
11989 +index e9ff3fc5e688..34b06dadca05 100644
11990 +--- a/include/net/inetpeer.h
11991 ++++ b/include/net/inetpeer.h
11992 +@@ -41,6 +41,10 @@ struct inet_peer {
11993 + u32 pmtu_orig;
11994 + u32 pmtu_learned;
11995 + struct inetpeer_addr_base redirect_learned;
11996 ++ union {
11997 ++ struct list_head gc_list;
11998 ++ struct rcu_head gc_rcu;
11999 ++ };
12000 + /*
12001 + * Once inet_peer is queued for deletion (refcnt == -1), following fields
12002 + * are not available: rid, ip_id_count, tcp_ts, tcp_ts_stamp
12003 +@@ -96,6 +100,8 @@ static inline struct inet_peer *inet_getpeer_v6(const struct in6_addr *v6daddr,
12004 + extern void inet_putpeer(struct inet_peer *p);
12005 + extern bool inet_peer_xrlim_allow(struct inet_peer *peer, int timeout);
12006 +
12007 ++extern void inetpeer_invalidate_tree(int family);
12008 ++
12009 + /*
12010 + * temporary check to make sure we dont access rid, ip_id_count, tcp_ts,
12011 + * tcp_ts_stamp if no refcount is taken on inet_peer
12012 +diff --git a/include/net/ip.h b/include/net/ip.h
12013 +index eca0ef7a495e..06aed72023f7 100644
12014 +--- a/include/net/ip.h
12015 ++++ b/include/net/ip.h
12016 +@@ -266,9 +266,11 @@ int ip_dont_fragment(struct sock *sk, struct dst_entry *dst)
12017 +
12018 + extern void __ip_select_ident(struct iphdr *iph, struct dst_entry *dst, int more);
12019 +
12020 +-static inline void ip_select_ident(struct iphdr *iph, struct dst_entry *dst, struct sock *sk)
12021 ++static inline void ip_select_ident(struct sk_buff *skb, struct dst_entry *dst, struct sock *sk)
12022 + {
12023 +- if (iph->frag_off & htons(IP_DF)) {
12024 ++ struct iphdr *iph = ip_hdr(skb);
12025 ++
12026 ++ if ((iph->frag_off & htons(IP_DF)) && !skb->local_df) {
12027 + /* This is only to work around buggy Windows95/2000
12028 + * VJ compression implementations. If the ID field
12029 + * does not change, they drop every other packet in
12030 +@@ -280,9 +282,11 @@ static inline void ip_select_ident(struct iphdr *iph, struct dst_entry *dst, str
12031 + __ip_select_ident(iph, dst, 0);
12032 + }
12033 +
12034 +-static inline void ip_select_ident_more(struct iphdr *iph, struct dst_entry *dst, struct sock *sk, int more)
12035 ++static inline void ip_select_ident_more(struct sk_buff *skb, struct dst_entry *dst, struct sock *sk, int more)
12036 + {
12037 +- if (iph->frag_off & htons(IP_DF)) {
12038 ++ struct iphdr *iph = ip_hdr(skb);
12039 ++
12040 ++ if ((iph->frag_off & htons(IP_DF)) && !skb->local_df) {
12041 + if (sk && inet_sk(sk)->inet_daddr) {
12042 + iph->id = htons(inet_sk(sk)->inet_id);
12043 + inet_sk(sk)->inet_id += 1 + more;
12044 +diff --git a/include/net/ipip.h b/include/net/ipip.h
12045 +index a32654d52730..4dccfe3bf731 100644
12046 +--- a/include/net/ipip.h
12047 ++++ b/include/net/ipip.h
12048 +@@ -50,7 +50,7 @@ struct ip_tunnel_prl_entry {
12049 + int pkt_len = skb->len - skb_transport_offset(skb); \
12050 + \
12051 + skb->ip_summed = CHECKSUM_NONE; \
12052 +- ip_select_ident(iph, &rt->dst, NULL); \
12053 ++ ip_select_ident(skb, &rt->dst, NULL); \
12054 + \
12055 + err = ip_local_out(skb); \
12056 + if (likely(net_xmit_eval(err) == 0)) { \
12057 +diff --git a/kernel/cgroup.c b/kernel/cgroup.c
12058 +index d2a01fee0d42..2a1ffb7b1915 100644
12059 +--- a/kernel/cgroup.c
12060 ++++ b/kernel/cgroup.c
12061 +@@ -3504,6 +3504,7 @@ static int cgroup_write_event_control(struct cgroup *cgrp, struct cftype *cft,
12062 + const char *buffer)
12063 + {
12064 + struct cgroup_event *event = NULL;
12065 ++ struct cgroup *cgrp_cfile;
12066 + unsigned int efd, cfd;
12067 + struct file *efile = NULL;
12068 + struct file *cfile = NULL;
12069 +@@ -3559,6 +3560,16 @@ static int cgroup_write_event_control(struct cgroup *cgrp, struct cftype *cft,
12070 + goto fail;
12071 + }
12072 +
12073 ++ /*
12074 ++ * The file to be monitored must be in the same cgroup as
12075 ++ * cgroup.event_control is.
12076 ++ */
12077 ++ cgrp_cfile = __d_cgrp(cfile->f_dentry->d_parent);
12078 ++ if (cgrp_cfile != cgrp) {
12079 ++ ret = -EINVAL;
12080 ++ goto fail;
12081 ++ }
12082 ++
12083 + if (!event->cft->register_event || !event->cft->unregister_event) {
12084 + ret = -EINVAL;
12085 + goto fail;
12086 +diff --git a/kernel/events/core.c b/kernel/events/core.c
12087 +index 5bbe443b0177..83d5621b7d90 100644
12088 +--- a/kernel/events/core.c
12089 ++++ b/kernel/events/core.c
12090 +@@ -242,9 +242,9 @@ perf_cgroup_match(struct perf_event *event)
12091 + return !event->cgrp || event->cgrp == cpuctx->cgrp;
12092 + }
12093 +
12094 +-static inline void perf_get_cgroup(struct perf_event *event)
12095 ++static inline bool perf_tryget_cgroup(struct perf_event *event)
12096 + {
12097 +- css_get(&event->cgrp->css);
12098 ++ return css_tryget(&event->cgrp->css);
12099 + }
12100 +
12101 + static inline void perf_put_cgroup(struct perf_event *event)
12102 +@@ -360,6 +360,8 @@ void perf_cgroup_switch(struct task_struct *task, int mode)
12103 +
12104 + list_for_each_entry_rcu(pmu, &pmus, entry) {
12105 + cpuctx = this_cpu_ptr(pmu->pmu_cpu_context);
12106 ++ if (cpuctx->unique_pmu != pmu)
12107 ++ continue; /* ensure we process each cpuctx once */
12108 +
12109 + /*
12110 + * perf_cgroup_events says at least one
12111 +@@ -383,9 +385,10 @@ void perf_cgroup_switch(struct task_struct *task, int mode)
12112 +
12113 + if (mode & PERF_CGROUP_SWIN) {
12114 + WARN_ON_ONCE(cpuctx->cgrp);
12115 +- /* set cgrp before ctxsw in to
12116 +- * allow event_filter_match() to not
12117 +- * have to pass task around
12118 ++ /*
12119 ++ * set cgrp before ctxsw in to allow
12120 ++ * event_filter_match() to not have to pass
12121 ++ * task around
12122 + */
12123 + cpuctx->cgrp = perf_cgroup_from_task(task);
12124 + cpu_ctx_sched_in(cpuctx, EVENT_ALL, task);
12125 +@@ -473,7 +476,11 @@ static inline int perf_cgroup_connect(int fd, struct perf_event *event,
12126 + event->cgrp = cgrp;
12127 +
12128 + /* must be done before we fput() the file */
12129 +- perf_get_cgroup(event);
12130 ++ if (!perf_tryget_cgroup(event)) {
12131 ++ event->cgrp = NULL;
12132 ++ ret = -ENOENT;
12133 ++ goto out;
12134 ++ }
12135 +
12136 + /*
12137 + * all events in a group must monitor
12138 +@@ -4377,7 +4384,7 @@ static void perf_event_task_event(struct perf_task_event *task_event)
12139 + rcu_read_lock();
12140 + list_for_each_entry_rcu(pmu, &pmus, entry) {
12141 + cpuctx = get_cpu_ptr(pmu->pmu_cpu_context);
12142 +- if (cpuctx->active_pmu != pmu)
12143 ++ if (cpuctx->unique_pmu != pmu)
12144 + goto next;
12145 + perf_event_task_ctx(&cpuctx->ctx, task_event);
12146 +
12147 +@@ -4523,7 +4530,7 @@ static void perf_event_comm_event(struct perf_comm_event *comm_event)
12148 + rcu_read_lock();
12149 + list_for_each_entry_rcu(pmu, &pmus, entry) {
12150 + cpuctx = get_cpu_ptr(pmu->pmu_cpu_context);
12151 +- if (cpuctx->active_pmu != pmu)
12152 ++ if (cpuctx->unique_pmu != pmu)
12153 + goto next;
12154 + perf_event_comm_ctx(&cpuctx->ctx, comm_event);
12155 +
12156 +@@ -4719,7 +4726,7 @@ got_name:
12157 + rcu_read_lock();
12158 + list_for_each_entry_rcu(pmu, &pmus, entry) {
12159 + cpuctx = get_cpu_ptr(pmu->pmu_cpu_context);
12160 +- if (cpuctx->active_pmu != pmu)
12161 ++ if (cpuctx->unique_pmu != pmu)
12162 + goto next;
12163 + perf_event_mmap_ctx(&cpuctx->ctx, mmap_event,
12164 + vma->vm_flags & VM_EXEC);
12165 +@@ -5741,8 +5748,8 @@ static void update_pmu_context(struct pmu *pmu, struct pmu *old_pmu)
12166 +
12167 + cpuctx = per_cpu_ptr(pmu->pmu_cpu_context, cpu);
12168 +
12169 +- if (cpuctx->active_pmu == old_pmu)
12170 +- cpuctx->active_pmu = pmu;
12171 ++ if (cpuctx->unique_pmu == old_pmu)
12172 ++ cpuctx->unique_pmu = pmu;
12173 + }
12174 + }
12175 +
12176 +@@ -5877,7 +5884,7 @@ skip_type:
12177 + cpuctx->ctx.pmu = pmu;
12178 + cpuctx->jiffies_interval = 1;
12179 + INIT_LIST_HEAD(&cpuctx->rotation_list);
12180 +- cpuctx->active_pmu = pmu;
12181 ++ cpuctx->unique_pmu = pmu;
12182 + }
12183 +
12184 + got_cpu_context:
12185 +diff --git a/kernel/sched_fair.c b/kernel/sched_fair.c
12186 +index 59474c5ecf6c..c261da7ddc71 100644
12187 +--- a/kernel/sched_fair.c
12188 ++++ b/kernel/sched_fair.c
12189 +@@ -4890,11 +4890,15 @@ static void task_fork_fair(struct task_struct *p)
12190 +
12191 + update_rq_clock(rq);
12192 +
12193 +- if (unlikely(task_cpu(p) != this_cpu)) {
12194 +- rcu_read_lock();
12195 +- __set_task_cpu(p, this_cpu);
12196 +- rcu_read_unlock();
12197 +- }
12198 ++ /*
12199 ++ * Not only the cpu but also the task_group of the parent might have
12200 ++ * been changed after parent->se.parent,cfs_rq were copied to
12201 ++ * child->se.parent,cfs_rq. So call __set_task_cpu() to make those
12202 ++ * of child point to valid ones.
12203 ++ */
12204 ++ rcu_read_lock();
12205 ++ __set_task_cpu(p, this_cpu);
12206 ++ rcu_read_unlock();
12207 +
12208 + update_curr(cfs_rq);
12209 +
12210 +diff --git a/lib/show_mem.c b/lib/show_mem.c
12211 +index 4407f8c9b1f7..b7c72311ad0c 100644
12212 +--- a/lib/show_mem.c
12213 ++++ b/lib/show_mem.c
12214 +@@ -18,6 +18,9 @@ void show_mem(unsigned int filter)
12215 + printk("Mem-Info:\n");
12216 + show_free_areas(filter);
12217 +
12218 ++ if (filter & SHOW_MEM_FILTER_PAGE_COUNT)
12219 ++ return;
12220 ++
12221 + for_each_online_pgdat(pgdat) {
12222 + unsigned long i, flags;
12223 +
12224 +diff --git a/mm/huge_memory.c b/mm/huge_memory.c
12225 +index d80ac4bb0971..ed0ed8a41fba 100644
12226 +--- a/mm/huge_memory.c
12227 ++++ b/mm/huge_memory.c
12228 +@@ -1882,6 +1882,8 @@ static void collapse_huge_page(struct mm_struct *mm,
12229 + goto out;
12230 +
12231 + vma = find_vma(mm, address);
12232 ++ if (!vma)
12233 ++ goto out;
12234 + hstart = (vma->vm_start + ~HPAGE_PMD_MASK) & HPAGE_PMD_MASK;
12235 + hend = vma->vm_end & HPAGE_PMD_MASK;
12236 + if (address < hstart || address + HPAGE_PMD_SIZE > hend)
12237 +diff --git a/mm/memcontrol.c b/mm/memcontrol.c
12238 +index d027a2489a9f..204de6ab6292 100644
12239 +--- a/mm/memcontrol.c
12240 ++++ b/mm/memcontrol.c
12241 +@@ -4385,7 +4385,13 @@ static int compare_thresholds(const void *a, const void *b)
12242 + const struct mem_cgroup_threshold *_a = a;
12243 + const struct mem_cgroup_threshold *_b = b;
12244 +
12245 +- return _a->threshold - _b->threshold;
12246 ++ if (_a->threshold > _b->threshold)
12247 ++ return 1;
12248 ++
12249 ++ if (_a->threshold < _b->threshold)
12250 ++ return -1;
12251 ++
12252 ++ return 0;
12253 + }
12254 +
12255 + static int mem_cgroup_oom_notify_cb(struct mem_cgroup *memcg)
12256 +diff --git a/mm/page_alloc.c b/mm/page_alloc.c
12257 +index b5afea28cf83..d8762b234d2a 100644
12258 +--- a/mm/page_alloc.c
12259 ++++ b/mm/page_alloc.c
12260 +@@ -1760,6 +1760,13 @@ void warn_alloc_failed(gfp_t gfp_mask, int order, const char *fmt, ...)
12261 + return;
12262 +
12263 + /*
12264 ++ * Walking all memory to count page types is very expensive and should
12265 ++ * be inhibited in non-blockable contexts.
12266 ++ */
12267 ++ if (!(gfp_mask & __GFP_WAIT))
12268 ++ filter |= SHOW_MEM_FILTER_PAGE_COUNT;
12269 ++
12270 ++ /*
12271 + * This documents exceptions given to allocations in certain
12272 + * contexts that are allowed to allocate outside current's set
12273 + * of allowed nodes.
12274 +diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c
12275 +index b81500c680af..a06deca97f0e 100644
12276 +--- a/net/bridge/br_multicast.c
12277 ++++ b/net/bridge/br_multicast.c
12278 +@@ -1155,7 +1155,8 @@ static int br_ip6_multicast_query(struct net_bridge *br,
12279 + mld2q = (struct mld2_query *)icmp6_hdr(skb);
12280 + if (!mld2q->mld2q_nsrcs)
12281 + group = &mld2q->mld2q_mca;
12282 +- max_delay = mld2q->mld2q_mrc ? MLDV2_MRC(mld2q->mld2q_mrc) : 1;
12283 ++
12284 ++ max_delay = max(msecs_to_jiffies(MLDV2_MRC(ntohs(mld2q->mld2q_mrc))), 1UL);
12285 + }
12286 +
12287 + if (!group)
12288 +diff --git a/net/bridge/br_stp.c b/net/bridge/br_stp.c
12289 +index dd147d78a588..8ac946f32f9a 100644
12290 +--- a/net/bridge/br_stp.c
12291 ++++ b/net/bridge/br_stp.c
12292 +@@ -189,7 +189,7 @@ static void br_record_config_information(struct net_bridge_port *p,
12293 + p->designated_age = jiffies + bpdu->message_age;
12294 +
12295 + mod_timer(&p->message_age_timer, jiffies
12296 +- + (p->br->max_age - bpdu->message_age));
12297 ++ + (bpdu->max_age - bpdu->message_age));
12298 + }
12299 +
12300 + /* called under bridge lock */
12301 +diff --git a/net/caif/cfctrl.c b/net/caif/cfctrl.c
12302 +index 5cf52225692e..84efbe4aa06a 100644
12303 +--- a/net/caif/cfctrl.c
12304 ++++ b/net/caif/cfctrl.c
12305 +@@ -288,9 +288,10 @@ int cfctrl_linkup_request(struct cflayer *layer,
12306 +
12307 + count = cfctrl_cancel_req(&cfctrl->serv.layer,
12308 + user_layer);
12309 +- if (count != 1)
12310 ++ if (count != 1) {
12311 + pr_err("Could not remove request (%d)", count);
12312 + return -ENODEV;
12313 ++ }
12314 + }
12315 + return 0;
12316 + }
12317 +diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
12318 +index f4f3f58f5234..a70f426c6d6f 100644
12319 +--- a/net/ceph/osd_client.c
12320 ++++ b/net/ceph/osd_client.c
12321 +@@ -1719,6 +1719,8 @@ int ceph_osdc_start_request(struct ceph_osd_client *osdc,
12322 + dout("osdc_start_request failed map, "
12323 + " will retry %lld\n", req->r_tid);
12324 + rc = 0;
12325 ++ } else {
12326 ++ __unregister_request(osdc, req);
12327 + }
12328 + goto out_unlock;
12329 + }
12330 +diff --git a/net/core/netpoll.c b/net/core/netpoll.c
12331 +index db4bb7a9ca78..9649cead0028 100644
12332 +--- a/net/core/netpoll.c
12333 ++++ b/net/core/netpoll.c
12334 +@@ -923,15 +923,14 @@ EXPORT_SYMBOL_GPL(__netpoll_cleanup);
12335 +
12336 + void netpoll_cleanup(struct netpoll *np)
12337 + {
12338 +- if (!np->dev)
12339 +- return;
12340 +-
12341 + rtnl_lock();
12342 ++ if (!np->dev)
12343 ++ goto out;
12344 + __netpoll_cleanup(np);
12345 +- rtnl_unlock();
12346 +-
12347 + dev_put(np->dev);
12348 + np->dev = NULL;
12349 ++out:
12350 ++ rtnl_unlock();
12351 + }
12352 + EXPORT_SYMBOL(netpoll_cleanup);
12353 +
12354 +diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
12355 +index 77a65f031488..f0bdd36f207e 100644
12356 +--- a/net/core/sysctl_net_core.c
12357 ++++ b/net/core/sysctl_net_core.c
12358 +@@ -19,6 +19,9 @@
12359 + #include <net/sock.h>
12360 + #include <net/net_ratelimit.h>
12361 +
12362 ++static int zero = 0;
12363 ++static int ushort_max = USHRT_MAX;
12364 ++
12365 + #ifdef CONFIG_RPS
12366 + static int rps_sock_flow_sysctl(ctl_table *table, int write,
12367 + void __user *buffer, size_t *lenp, loff_t *ppos)
12368 +@@ -192,7 +195,9 @@ static struct ctl_table netns_core_table[] = {
12369 + .data = &init_net.core.sysctl_somaxconn,
12370 + .maxlen = sizeof(int),
12371 + .mode = 0644,
12372 +- .proc_handler = proc_dointvec
12373 ++ .extra1 = &zero,
12374 ++ .extra2 = &ushort_max,
12375 ++ .proc_handler = proc_dointvec_minmax
12376 + },
12377 + { }
12378 + };
12379 +diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
12380 +index cd2d639541bc..c7c6724c0d6e 100644
12381 +--- a/net/ipv4/fib_trie.c
12382 ++++ b/net/ipv4/fib_trie.c
12383 +@@ -72,7 +72,6 @@
12384 + #include <linux/init.h>
12385 + #include <linux/list.h>
12386 + #include <linux/slab.h>
12387 +-#include <linux/prefetch.h>
12388 + #include <linux/export.h>
12389 + #include <net/net_namespace.h>
12390 + #include <net/ip.h>
12391 +@@ -1773,10 +1772,8 @@ static struct leaf *leaf_walk_rcu(struct tnode *p, struct rt_trie_node *c)
12392 + if (!c)
12393 + continue;
12394 +
12395 +- if (IS_LEAF(c)) {
12396 +- prefetch(rcu_dereference_rtnl(p->child[idx]));
12397 ++ if (IS_LEAF(c))
12398 + return (struct leaf *) c;
12399 +- }
12400 +
12401 + /* Rescan start scanning in new node */
12402 + p = (struct tnode *) c;
12403 +diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
12404 +index c8989a71bbd9..75b086029ec9 100644
12405 +--- a/net/ipv4/igmp.c
12406 ++++ b/net/ipv4/igmp.c
12407 +@@ -342,7 +342,7 @@ static struct sk_buff *igmpv3_newpack(struct net_device *dev, int size)
12408 + pip->saddr = fl4.saddr;
12409 + pip->protocol = IPPROTO_IGMP;
12410 + pip->tot_len = 0; /* filled in later */
12411 +- ip_select_ident(pip, &rt->dst, NULL);
12412 ++ ip_select_ident(skb, &rt->dst, NULL);
12413 + ((u8*)&pip[1])[0] = IPOPT_RA;
12414 + ((u8*)&pip[1])[1] = 4;
12415 + ((u8*)&pip[1])[2] = 0;
12416 +@@ -683,7 +683,7 @@ static int igmp_send_report(struct in_device *in_dev, struct ip_mc_list *pmc,
12417 + iph->daddr = dst;
12418 + iph->saddr = fl4.saddr;
12419 + iph->protocol = IPPROTO_IGMP;
12420 +- ip_select_ident(iph, &rt->dst, NULL);
12421 ++ ip_select_ident(skb, &rt->dst, NULL);
12422 + ((u8*)&iph[1])[0] = IPOPT_RA;
12423 + ((u8*)&iph[1])[1] = 4;
12424 + ((u8*)&iph[1])[2] = 0;
12425 +@@ -705,7 +705,7 @@ static void igmp_gq_timer_expire(unsigned long data)
12426 +
12427 + in_dev->mr_gq_running = 0;
12428 + igmpv3_send_report(in_dev, NULL);
12429 +- __in_dev_put(in_dev);
12430 ++ in_dev_put(in_dev);
12431 + }
12432 +
12433 + static void igmp_ifc_timer_expire(unsigned long data)
12434 +@@ -717,7 +717,7 @@ static void igmp_ifc_timer_expire(unsigned long data)
12435 + in_dev->mr_ifc_count--;
12436 + igmp_ifc_start_timer(in_dev, IGMP_Unsolicited_Report_Interval);
12437 + }
12438 +- __in_dev_put(in_dev);
12439 ++ in_dev_put(in_dev);
12440 + }
12441 +
12442 + static void igmp_ifc_event(struct in_device *in_dev)
12443 +diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
12444 +index 86f13c67ea85..58c4e696a6a7 100644
12445 +--- a/net/ipv4/inetpeer.c
12446 ++++ b/net/ipv4/inetpeer.c
12447 +@@ -17,6 +17,7 @@
12448 + #include <linux/kernel.h>
12449 + #include <linux/mm.h>
12450 + #include <linux/net.h>
12451 ++#include <linux/workqueue.h>
12452 + #include <net/ip.h>
12453 + #include <net/inetpeer.h>
12454 + #include <net/secure_seq.h>
12455 +@@ -31,8 +32,8 @@
12456 + * At the moment of writing this notes identifier of IP packets is generated
12457 + * to be unpredictable using this code only for packets subjected
12458 + * (actually or potentially) to defragmentation. I.e. DF packets less than
12459 +- * PMTU in size uses a constant ID and do not use this code (see
12460 +- * ip_select_ident() in include/net/ip.h).
12461 ++ * PMTU in size when local fragmentation is disabled use a constant ID and do
12462 ++ * not use this code (see ip_select_ident() in include/net/ip.h).
12463 + *
12464 + * Route cache entries hold references to our nodes.
12465 + * New cache entries get references via lookup by destination IP address in
12466 +@@ -66,6 +67,11 @@
12467 +
12468 + static struct kmem_cache *peer_cachep __read_mostly;
12469 +
12470 ++static LIST_HEAD(gc_list);
12471 ++static const int gc_delay = 60 * HZ;
12472 ++static struct delayed_work gc_work;
12473 ++static DEFINE_SPINLOCK(gc_lock);
12474 ++
12475 + #define node_height(x) x->avl_height
12476 +
12477 + #define peer_avl_empty ((struct inet_peer *)&peer_fake_node)
12478 +@@ -102,6 +108,50 @@ int inet_peer_threshold __read_mostly = 65536 + 128; /* start to throw entries m
12479 + int inet_peer_minttl __read_mostly = 120 * HZ; /* TTL under high load: 120 sec */
12480 + int inet_peer_maxttl __read_mostly = 10 * 60 * HZ; /* usual time to live: 10 min */
12481 +
12482 ++static void inetpeer_gc_worker(struct work_struct *work)
12483 ++{
12484 ++ struct inet_peer *p, *n;
12485 ++ LIST_HEAD(list);
12486 ++
12487 ++ spin_lock_bh(&gc_lock);
12488 ++ list_replace_init(&gc_list, &list);
12489 ++ spin_unlock_bh(&gc_lock);
12490 ++
12491 ++ if (list_empty(&list))
12492 ++ return;
12493 ++
12494 ++ list_for_each_entry_safe(p, n, &list, gc_list) {
12495 ++
12496 ++ if(need_resched())
12497 ++ cond_resched();
12498 ++
12499 ++ if (p->avl_left != peer_avl_empty) {
12500 ++ list_add_tail(&p->avl_left->gc_list, &list);
12501 ++ p->avl_left = peer_avl_empty;
12502 ++ }
12503 ++
12504 ++ if (p->avl_right != peer_avl_empty) {
12505 ++ list_add_tail(&p->avl_right->gc_list, &list);
12506 ++ p->avl_right = peer_avl_empty;
12507 ++ }
12508 ++
12509 ++ n = list_entry(p->gc_list.next, struct inet_peer, gc_list);
12510 ++
12511 ++ if (!atomic_read(&p->refcnt)) {
12512 ++ list_del(&p->gc_list);
12513 ++ kmem_cache_free(peer_cachep, p);
12514 ++ }
12515 ++ }
12516 ++
12517 ++ if (list_empty(&list))
12518 ++ return;
12519 ++
12520 ++ spin_lock_bh(&gc_lock);
12521 ++ list_splice(&list, &gc_list);
12522 ++ spin_unlock_bh(&gc_lock);
12523 ++
12524 ++ schedule_delayed_work(&gc_work, gc_delay);
12525 ++}
12526 +
12527 + /* Called from ip_output.c:ip_init */
12528 + void __init inet_initpeers(void)
12529 +@@ -126,6 +176,7 @@ void __init inet_initpeers(void)
12530 + 0, SLAB_HWCACHE_ALIGN | SLAB_PANIC,
12531 + NULL);
12532 +
12533 ++ INIT_DELAYED_WORK_DEFERRABLE(&gc_work, inetpeer_gc_worker);
12534 + }
12535 +
12536 + static int addr_compare(const struct inetpeer_addr *a,
12537 +@@ -448,7 +499,7 @@ relookup:
12538 + p->pmtu_expires = 0;
12539 + p->pmtu_orig = 0;
12540 + memset(&p->redirect_learned, 0, sizeof(p->redirect_learned));
12541 +-
12542 ++ INIT_LIST_HEAD(&p->gc_list);
12543 +
12544 + /* Link the node. */
12545 + link_to_pool(p, base);
12546 +@@ -508,3 +559,38 @@ bool inet_peer_xrlim_allow(struct inet_peer *peer, int timeout)
12547 + return rc;
12548 + }
12549 + EXPORT_SYMBOL(inet_peer_xrlim_allow);
12550 ++
12551 ++static void inetpeer_inval_rcu(struct rcu_head *head)
12552 ++{
12553 ++ struct inet_peer *p = container_of(head, struct inet_peer, gc_rcu);
12554 ++
12555 ++ spin_lock_bh(&gc_lock);
12556 ++ list_add_tail(&p->gc_list, &gc_list);
12557 ++ spin_unlock_bh(&gc_lock);
12558 ++
12559 ++ schedule_delayed_work(&gc_work, gc_delay);
12560 ++}
12561 ++
12562 ++void inetpeer_invalidate_tree(int family)
12563 ++{
12564 ++ struct inet_peer *old, *new, *prev;
12565 ++ struct inet_peer_base *base = family_to_base(family);
12566 ++
12567 ++ write_seqlock_bh(&base->lock);
12568 ++
12569 ++ old = base->root;
12570 ++ if (old == peer_avl_empty_rcu)
12571 ++ goto out;
12572 ++
12573 ++ new = peer_avl_empty_rcu;
12574 ++
12575 ++ prev = cmpxchg(&base->root, old, new);
12576 ++ if (prev == old) {
12577 ++ base->total = 0;
12578 ++ call_rcu(&prev->gc_rcu, inetpeer_inval_rcu);
12579 ++ }
12580 ++
12581 ++out:
12582 ++ write_sequnlock_bh(&base->lock);
12583 ++}
12584 ++EXPORT_SYMBOL(inetpeer_invalidate_tree);
12585 +diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
12586 +index 0bc95f3977d2..daf408e8633c 100644
12587 +--- a/net/ipv4/ip_output.c
12588 ++++ b/net/ipv4/ip_output.c
12589 +@@ -162,7 +162,7 @@ int ip_build_and_send_pkt(struct sk_buff *skb, struct sock *sk,
12590 + iph->daddr = (opt && opt->opt.srr ? opt->opt.faddr : daddr);
12591 + iph->saddr = saddr;
12592 + iph->protocol = sk->sk_protocol;
12593 +- ip_select_ident(iph, &rt->dst, sk);
12594 ++ ip_select_ident(skb, &rt->dst, sk);
12595 +
12596 + if (opt && opt->opt.optlen) {
12597 + iph->ihl += opt->opt.optlen>>2;
12598 +@@ -390,7 +390,7 @@ packet_routed:
12599 + ip_options_build(skb, &inet_opt->opt, inet->inet_daddr, rt, 0);
12600 + }
12601 +
12602 +- ip_select_ident_more(iph, &rt->dst, sk,
12603 ++ ip_select_ident_more(skb, &rt->dst, sk,
12604 + (skb_shinfo(skb)->gso_segs ?: 1) - 1);
12605 +
12606 + skb->priority = sk->sk_priority;
12607 +@@ -1334,7 +1334,7 @@ struct sk_buff *__ip_make_skb(struct sock *sk,
12608 + iph->ihl = 5;
12609 + iph->tos = inet->tos;
12610 + iph->frag_off = df;
12611 +- ip_select_ident(iph, &rt->dst, sk);
12612 ++ ip_select_ident(skb, &rt->dst, sk);
12613 + iph->ttl = ttl;
12614 + iph->protocol = sk->sk_protocol;
12615 + iph->saddr = fl4->saddr;
12616 +diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
12617 +index 006439403213..b5e64e4c0646 100644
12618 +--- a/net/ipv4/ipmr.c
12619 ++++ b/net/ipv4/ipmr.c
12620 +@@ -1576,7 +1576,7 @@ static void ip_encap(struct sk_buff *skb, __be32 saddr, __be32 daddr)
12621 + iph->protocol = IPPROTO_IPIP;
12622 + iph->ihl = 5;
12623 + iph->tot_len = htons(skb->len);
12624 +- ip_select_ident(iph, skb_dst(skb), NULL);
12625 ++ ip_select_ident(skb, skb_dst(skb), NULL);
12626 + ip_send_check(iph);
12627 +
12628 + memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt));
12629 +diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
12630 +index e1d4f30bb718..28150145ce02 100644
12631 +--- a/net/ipv4/raw.c
12632 ++++ b/net/ipv4/raw.c
12633 +@@ -380,7 +380,7 @@ static int raw_send_hdrinc(struct sock *sk, struct flowi4 *fl4,
12634 + iph->check = 0;
12635 + iph->tot_len = htons(length);
12636 + if (!iph->id)
12637 +- ip_select_ident(iph, &rt->dst, NULL);
12638 ++ ip_select_ident(skb, &rt->dst, NULL);
12639 +
12640 + iph->check = ip_fast_csum((unsigned char *)iph, iph->ihl);
12641 + }
12642 +diff --git a/net/ipv4/route.c b/net/ipv4/route.c
12643 +index 94cdbc55ca7e..c45a155a3296 100644
12644 +--- a/net/ipv4/route.c
12645 ++++ b/net/ipv4/route.c
12646 +@@ -939,6 +939,7 @@ static void rt_cache_invalidate(struct net *net)
12647 + get_random_bytes(&shuffle, sizeof(shuffle));
12648 + atomic_add(shuffle + 1U, &net->ipv4.rt_genid);
12649 + redirect_genid++;
12650 ++ inetpeer_invalidate_tree(AF_INET);
12651 + }
12652 +
12653 + /*
12654 +diff --git a/net/ipv4/tcp_cubic.c b/net/ipv4/tcp_cubic.c
12655 +index f376b05cca81..b78eac2b7079 100644
12656 +--- a/net/ipv4/tcp_cubic.c
12657 ++++ b/net/ipv4/tcp_cubic.c
12658 +@@ -204,8 +204,8 @@ static u32 cubic_root(u64 a)
12659 + */
12660 + static inline void bictcp_update(struct bictcp *ca, u32 cwnd)
12661 + {
12662 +- u64 offs;
12663 +- u32 delta, t, bic_target, max_cnt;
12664 ++ u32 delta, bic_target, max_cnt;
12665 ++ u64 offs, t;
12666 +
12667 + ca->ack_cnt++; /* count the number of ACKs */
12668 +
12669 +@@ -248,9 +248,11 @@ static inline void bictcp_update(struct bictcp *ca, u32 cwnd)
12670 + * if the cwnd < 1 million packets !!!
12671 + */
12672 +
12673 ++ t = (s32)(tcp_time_stamp - ca->epoch_start);
12674 ++ t += msecs_to_jiffies(ca->delay_min >> 3);
12675 + /* change the unit from HZ to bictcp_HZ */
12676 +- t = ((tcp_time_stamp + msecs_to_jiffies(ca->delay_min>>3)
12677 +- - ca->epoch_start) << BICTCP_HZ) / HZ;
12678 ++ t <<= BICTCP_HZ;
12679 ++ do_div(t, HZ);
12680 +
12681 + if (t < ca->bic_K) /* t - K */
12682 + offs = ca->bic_K - t;
12683 +@@ -412,7 +414,7 @@ static void bictcp_acked(struct sock *sk, u32 cnt, s32 rtt_us)
12684 + return;
12685 +
12686 + /* Discard delay samples right after fast recovery */
12687 +- if ((s32)(tcp_time_stamp - ca->epoch_start) < HZ)
12688 ++ if (ca->epoch_start && (s32)(tcp_time_stamp - ca->epoch_start) < HZ)
12689 + return;
12690 +
12691 + delay = (rtt_us << 3) / USEC_PER_MSEC;
12692 +diff --git a/net/ipv4/xfrm4_mode_tunnel.c b/net/ipv4/xfrm4_mode_tunnel.c
12693 +index ed4bf11ef9f4..938553efbf8e 100644
12694 +--- a/net/ipv4/xfrm4_mode_tunnel.c
12695 ++++ b/net/ipv4/xfrm4_mode_tunnel.c
12696 +@@ -54,7 +54,7 @@ static int xfrm4_mode_tunnel_output(struct xfrm_state *x, struct sk_buff *skb)
12697 +
12698 + top_iph->frag_off = (flags & XFRM_STATE_NOPMTUDISC) ?
12699 + 0 : (XFRM_MODE_SKB_CB(skb)->frag_off & htons(IP_DF));
12700 +- ip_select_ident(top_iph, dst->child, NULL);
12701 ++ ip_select_ident(skb, dst->child, NULL);
12702 +
12703 + top_iph->ttl = ip4_dst_hoplimit(dst->child);
12704 +
12705 +diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
12706 +index 314bda227495..5d41293a6005 100644
12707 +--- a/net/ipv6/addrconf.c
12708 ++++ b/net/ipv6/addrconf.c
12709 +@@ -913,12 +913,10 @@ retry:
12710 + if (ifp->flags & IFA_F_OPTIMISTIC)
12711 + addr_flags |= IFA_F_OPTIMISTIC;
12712 +
12713 +- ift = !max_addresses ||
12714 +- ipv6_count_addresses(idev) < max_addresses ?
12715 +- ipv6_add_addr(idev, &addr, tmp_plen,
12716 +- ipv6_addr_type(&addr)&IPV6_ADDR_SCOPE_MASK,
12717 +- addr_flags) : NULL;
12718 +- if (!ift || IS_ERR(ift)) {
12719 ++ ift = ipv6_add_addr(idev, &addr, tmp_plen,
12720 ++ ipv6_addr_type(&addr)&IPV6_ADDR_SCOPE_MASK,
12721 ++ addr_flags);
12722 ++ if (IS_ERR(ift)) {
12723 + in6_ifa_put(ifp);
12724 + in6_dev_put(idev);
12725 + printk(KERN_INFO
12726 +diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
12727 +index 90868fb42757..d50545371b55 100644
12728 +--- a/net/ipv6/icmp.c
12729 ++++ b/net/ipv6/icmp.c
12730 +@@ -911,6 +911,14 @@ static const struct icmp6_err {
12731 + .err = ECONNREFUSED,
12732 + .fatal = 1,
12733 + },
12734 ++ { /* POLICY_FAIL */
12735 ++ .err = EACCES,
12736 ++ .fatal = 1,
12737 ++ },
12738 ++ { /* REJECT_ROUTE */
12739 ++ .err = EACCES,
12740 ++ .fatal = 1,
12741 ++ },
12742 + };
12743 +
12744 + int icmpv6_err_convert(u8 type, u8 code, int *err)
12745 +@@ -922,7 +930,7 @@ int icmpv6_err_convert(u8 type, u8 code, int *err)
12746 + switch (type) {
12747 + case ICMPV6_DEST_UNREACH:
12748 + fatal = 1;
12749 +- if (code <= ICMPV6_PORT_UNREACH) {
12750 ++ if (code < ARRAY_SIZE(tab_unreach)) {
12751 + *err = tab_unreach[code].err;
12752 + fatal = tab_unreach[code].fatal;
12753 + }
12754 +diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
12755 +index 93718f3db79b..443724f54724 100644
12756 +--- a/net/ipv6/ip6_fib.c
12757 ++++ b/net/ipv6/ip6_fib.c
12758 +@@ -862,14 +862,22 @@ static struct fib6_node * fib6_lookup_1(struct fib6_node *root,
12759 +
12760 + if (ipv6_prefix_equal(&key->addr, args->addr, key->plen)) {
12761 + #ifdef CONFIG_IPV6_SUBTREES
12762 +- if (fn->subtree)
12763 +- fn = fib6_lookup_1(fn->subtree, args + 1);
12764 ++ if (fn->subtree) {
12765 ++ struct fib6_node *sfn;
12766 ++ sfn = fib6_lookup_1(fn->subtree,
12767 ++ args + 1);
12768 ++ if (!sfn)
12769 ++ goto backtrack;
12770 ++ fn = sfn;
12771 ++ }
12772 + #endif
12773 +- if (!fn || fn->fn_flags & RTN_RTINFO)
12774 ++ if (fn->fn_flags & RTN_RTINFO)
12775 + return fn;
12776 + }
12777 + }
12778 +-
12779 ++#ifdef CONFIG_IPV6_SUBTREES
12780 ++backtrack:
12781 ++#endif
12782 + if (fn->fn_flags & RTN_ROOT)
12783 + break;
12784 +
12785 +diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
12786 +index db6004364313..91d0711caec6 100644
12787 +--- a/net/ipv6/ip6_output.c
12788 ++++ b/net/ipv6/ip6_output.c
12789 +@@ -1125,6 +1125,8 @@ static inline int ip6_ufo_append_data(struct sock *sk,
12790 + * udp datagram
12791 + */
12792 + if ((skb = skb_peek_tail(&sk->sk_write_queue)) == NULL) {
12793 ++ struct frag_hdr fhdr;
12794 ++
12795 + skb = sock_alloc_send_skb(sk,
12796 + hh_len + fragheaderlen + transhdrlen + 20,
12797 + (flags & MSG_DONTWAIT), &err);
12798 +@@ -1145,12 +1147,6 @@ static inline int ip6_ufo_append_data(struct sock *sk,
12799 +
12800 + skb->ip_summed = CHECKSUM_PARTIAL;
12801 + skb->csum = 0;
12802 +- }
12803 +-
12804 +- err = skb_append_datato_frags(sk,skb, getfrag, from,
12805 +- (length - transhdrlen));
12806 +- if (!err) {
12807 +- struct frag_hdr fhdr;
12808 +
12809 + /* Specify the length of each IPv6 datagram fragment.
12810 + * It has to be a multiple of 8.
12811 +@@ -1161,15 +1157,10 @@ static inline int ip6_ufo_append_data(struct sock *sk,
12812 + ipv6_select_ident(&fhdr, rt);
12813 + skb_shinfo(skb)->ip6_frag_id = fhdr.identification;
12814 + __skb_queue_tail(&sk->sk_write_queue, skb);
12815 +-
12816 +- return 0;
12817 + }
12818 +- /* There is not enough support do UPD LSO,
12819 +- * so follow normal path
12820 +- */
12821 +- kfree_skb(skb);
12822 +
12823 +- return err;
12824 ++ return skb_append_datato_frags(sk, skb, getfrag, from,
12825 ++ (length - transhdrlen));
12826 + }
12827 +
12828 + static inline struct ipv6_opt_hdr *ip6_opt_dup(struct ipv6_opt_hdr *src,
12829 +@@ -1342,27 +1333,27 @@ int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to,
12830 + * --yoshfuji
12831 + */
12832 +
12833 +- cork->length += length;
12834 +- if (length > mtu) {
12835 +- int proto = sk->sk_protocol;
12836 +- if (dontfrag && (proto == IPPROTO_UDP || proto == IPPROTO_RAW)){
12837 +- ipv6_local_rxpmtu(sk, fl6, mtu-exthdrlen);
12838 +- return -EMSGSIZE;
12839 +- }
12840 +-
12841 +- if (proto == IPPROTO_UDP &&
12842 +- (rt->dst.dev->features & NETIF_F_UFO)) {
12843 ++ if ((length > mtu) && dontfrag && (sk->sk_protocol == IPPROTO_UDP ||
12844 ++ sk->sk_protocol == IPPROTO_RAW)) {
12845 ++ ipv6_local_rxpmtu(sk, fl6, mtu-exthdrlen);
12846 ++ return -EMSGSIZE;
12847 ++ }
12848 +
12849 +- err = ip6_ufo_append_data(sk, getfrag, from, length,
12850 +- hh_len, fragheaderlen,
12851 +- transhdrlen, mtu, flags, rt);
12852 +- if (err)
12853 +- goto error;
12854 +- return 0;
12855 +- }
12856 ++ skb = skb_peek_tail(&sk->sk_write_queue);
12857 ++ cork->length += length;
12858 ++ if (((length > mtu) ||
12859 ++ (skb && skb_is_gso(skb))) &&
12860 ++ (sk->sk_protocol == IPPROTO_UDP) &&
12861 ++ (rt->dst.dev->features & NETIF_F_UFO)) {
12862 ++ err = ip6_ufo_append_data(sk, getfrag, from, length,
12863 ++ hh_len, fragheaderlen,
12864 ++ transhdrlen, mtu, flags, rt);
12865 ++ if (err)
12866 ++ goto error;
12867 ++ return 0;
12868 + }
12869 +
12870 +- if ((skb = skb_peek_tail(&sk->sk_write_queue)) == NULL)
12871 ++ if (!skb)
12872 + goto alloc_new_skb;
12873 +
12874 + while (length > 0) {
12875 +diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
12876 +index c7ec4bb0c0f5..d20a9be8334e 100644
12877 +--- a/net/ipv6/mcast.c
12878 ++++ b/net/ipv6/mcast.c
12879 +@@ -2159,7 +2159,7 @@ static void mld_gq_timer_expire(unsigned long data)
12880 +
12881 + idev->mc_gq_running = 0;
12882 + mld_send_report(idev, NULL);
12883 +- __in6_dev_put(idev);
12884 ++ in6_dev_put(idev);
12885 + }
12886 +
12887 + static void mld_ifc_timer_expire(unsigned long data)
12888 +@@ -2172,7 +2172,7 @@ static void mld_ifc_timer_expire(unsigned long data)
12889 + if (idev->mc_ifc_count)
12890 + mld_ifc_start_timer(idev, idev->mc_maxdelay);
12891 + }
12892 +- __in6_dev_put(idev);
12893 ++ in6_dev_put(idev);
12894 + }
12895 +
12896 + static void mld_ifc_event(struct inet6_dev *idev)
12897 +diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
12898 +index 9ffc37f600a4..bc55358fc789 100644
12899 +--- a/net/ipv6/ndisc.c
12900 ++++ b/net/ipv6/ndisc.c
12901 +@@ -447,7 +447,6 @@ struct sk_buff *ndisc_build_skb(struct net_device *dev,
12902 + struct sk_buff *skb;
12903 + struct icmp6hdr *hdr;
12904 + int len;
12905 +- int err;
12906 + u8 *opt;
12907 +
12908 + if (!dev->addr_len)
12909 +@@ -457,14 +456,12 @@ struct sk_buff *ndisc_build_skb(struct net_device *dev,
12910 + if (llinfo)
12911 + len += ndisc_opt_addr_space(dev);
12912 +
12913 +- skb = sock_alloc_send_skb(sk,
12914 +- (MAX_HEADER + sizeof(struct ipv6hdr) +
12915 +- len + LL_ALLOCATED_SPACE(dev)),
12916 +- 1, &err);
12917 ++ skb = alloc_skb((MAX_HEADER + sizeof(struct ipv6hdr) +
12918 ++ len + LL_ALLOCATED_SPACE(dev)), GFP_ATOMIC);
12919 + if (!skb) {
12920 + ND_PRINTK0(KERN_ERR
12921 +- "ICMPv6 ND: %s() failed to allocate an skb, err=%d.\n",
12922 +- __func__, err);
12923 ++ "ICMPv6 ND: %s() failed to allocate an skb.\n",
12924 ++ __func__);
12925 + return NULL;
12926 + }
12927 +
12928 +@@ -492,6 +489,11 @@ struct sk_buff *ndisc_build_skb(struct net_device *dev,
12929 + csum_partial(hdr,
12930 + len, 0));
12931 +
12932 ++ /* Manually assign socket ownership as we avoid calling
12933 ++ * sock_alloc_send_pskb() to bypass wmem buffer limits
12934 ++ */
12935 ++ skb_set_owner_w(skb, sk);
12936 ++
12937 + return skb;
12938 + }
12939 +
12940 +diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
12941 +index 411fe2ceb9bb..eba5deb79fe3 100644
12942 +--- a/net/ipv6/reassembly.c
12943 ++++ b/net/ipv6/reassembly.c
12944 +@@ -517,6 +517,7 @@ static int ip6_frag_reasm(struct frag_queue *fq, struct sk_buff *prev,
12945 + head->tstamp = fq->q.stamp;
12946 + ipv6_hdr(head)->payload_len = htons(payload_len);
12947 + IP6CB(head)->nhoff = nhoff;
12948 ++ IP6CB(head)->flags |= IP6SKB_FRAGMENTED;
12949 +
12950 + /* Yes, and fold redundant checksum back. 8) */
12951 + if (head->ip_summed == CHECKSUM_COMPLETE)
12952 +@@ -552,6 +553,9 @@ static int ipv6_frag_rcv(struct sk_buff *skb)
12953 + const struct ipv6hdr *hdr = ipv6_hdr(skb);
12954 + struct net *net = dev_net(skb_dst(skb)->dev);
12955 +
12956 ++ if (IP6CB(skb)->flags & IP6SKB_FRAGMENTED)
12957 ++ goto fail_hdr;
12958 ++
12959 + IP6_INC_STATS_BH(net, ip6_dst_idev(skb_dst(skb)), IPSTATS_MIB_REASMREQDS);
12960 +
12961 + /* Jumbo payload inhibits frag. header */
12962 +@@ -572,6 +576,7 @@ static int ipv6_frag_rcv(struct sk_buff *skb)
12963 + ip6_dst_idev(skb_dst(skb)), IPSTATS_MIB_REASMOKS);
12964 +
12965 + IP6CB(skb)->nhoff = (u8 *)fhdr - skb_network_header(skb);
12966 ++ IP6CB(skb)->flags |= IP6SKB_FRAGMENTED;
12967 + return 1;
12968 + }
12969 +
12970 +diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
12971 +index aa2d7206ee8a..38c08136baa2 100644
12972 +--- a/net/netfilter/ipvs/ip_vs_xmit.c
12973 ++++ b/net/netfilter/ipvs/ip_vs_xmit.c
12974 +@@ -853,7 +853,7 @@ ip_vs_tunnel_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
12975 + iph->daddr = cp->daddr.ip;
12976 + iph->saddr = saddr;
12977 + iph->ttl = old_iph->ttl;
12978 +- ip_select_ident(iph, &rt->dst, NULL);
12979 ++ ip_select_ident(skb, &rt->dst, NULL);
12980 +
12981 + /* Another hack: avoid icmp_send in ip_fragment */
12982 + skb->local_df = 1;
12983 +diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c
12984 +index f08b9166119b..caa5affa4b29 100644
12985 +--- a/net/sched/sch_htb.c
12986 ++++ b/net/sched/sch_htb.c
12987 +@@ -86,7 +86,7 @@ struct htb_class {
12988 + unsigned int children;
12989 + struct htb_class *parent; /* parent class */
12990 +
12991 +- int prio; /* these two are used only by leaves... */
12992 ++ u32 prio; /* these two are used only by leaves... */
12993 + int quantum; /* but stored for parent-to-leaf return */
12994 +
12995 + union {
12996 +diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
12997 +index 810427833bcd..0b6a3913ef53 100644
12998 +--- a/net/sctp/ipv6.c
12999 ++++ b/net/sctp/ipv6.c
13000 +@@ -205,45 +205,24 @@ out:
13001 + in6_dev_put(idev);
13002 + }
13003 +
13004 +-/* Based on tcp_v6_xmit() in tcp_ipv6.c. */
13005 + static int sctp_v6_xmit(struct sk_buff *skb, struct sctp_transport *transport)
13006 + {
13007 + struct sock *sk = skb->sk;
13008 + struct ipv6_pinfo *np = inet6_sk(sk);
13009 +- struct flowi6 fl6;
13010 +-
13011 +- memset(&fl6, 0, sizeof(fl6));
13012 +-
13013 +- fl6.flowi6_proto = sk->sk_protocol;
13014 +-
13015 +- /* Fill in the dest address from the route entry passed with the skb
13016 +- * and the source address from the transport.
13017 +- */
13018 +- ipv6_addr_copy(&fl6.daddr, &transport->ipaddr.v6.sin6_addr);
13019 +- ipv6_addr_copy(&fl6.saddr, &transport->saddr.v6.sin6_addr);
13020 +-
13021 +- fl6.flowlabel = np->flow_label;
13022 +- IP6_ECN_flow_xmit(sk, fl6.flowlabel);
13023 +- if (ipv6_addr_type(&fl6.saddr) & IPV6_ADDR_LINKLOCAL)
13024 +- fl6.flowi6_oif = transport->saddr.v6.sin6_scope_id;
13025 +- else
13026 +- fl6.flowi6_oif = sk->sk_bound_dev_if;
13027 +-
13028 +- if (np->opt && np->opt->srcrt) {
13029 +- struct rt0_hdr *rt0 = (struct rt0_hdr *) np->opt->srcrt;
13030 +- ipv6_addr_copy(&fl6.daddr, rt0->addr);
13031 +- }
13032 ++ struct flowi6 *fl6 = &transport->fl.u.ip6;
13033 +
13034 + SCTP_DEBUG_PRINTK("%s: skb:%p, len:%d, src:%pI6 dst:%pI6\n",
13035 + __func__, skb, skb->len,
13036 +- &fl6.saddr, &fl6.daddr);
13037 ++ &fl6->saddr, &fl6->daddr);
13038 +
13039 +- SCTP_INC_STATS(SCTP_MIB_OUTSCTPPACKS);
13040 ++ IP6_ECN_flow_xmit(sk, fl6->flowlabel);
13041 +
13042 + if (!(transport->param_flags & SPP_PMTUD_ENABLE))
13043 + skb->local_df = 1;
13044 +
13045 +- return ip6_xmit(sk, skb, &fl6, np->opt, np->tclass);
13046 ++ SCTP_INC_STATS(SCTP_MIB_OUTSCTPPACKS);
13047 ++
13048 ++ return ip6_xmit(sk, skb, fl6, np->opt, np->tclass);
13049 + }
13050 +
13051 + /* Returns the dst cache entry for the given source and destination ip
13052 +@@ -256,10 +235,12 @@ static void sctp_v6_get_dst(struct sctp_transport *t, union sctp_addr *saddr,
13053 + struct dst_entry *dst = NULL;
13054 + struct flowi6 *fl6 = &fl->u.ip6;
13055 + struct sctp_bind_addr *bp;
13056 ++ struct ipv6_pinfo *np = inet6_sk(sk);
13057 + struct sctp_sockaddr_entry *laddr;
13058 + union sctp_addr *baddr = NULL;
13059 + union sctp_addr *daddr = &t->ipaddr;
13060 + union sctp_addr dst_saddr;
13061 ++ struct in6_addr *final_p, final;
13062 + __u8 matchlen = 0;
13063 + __u8 bmatchlen;
13064 + sctp_scope_t scope;
13065 +@@ -282,7 +263,8 @@ static void sctp_v6_get_dst(struct sctp_transport *t, union sctp_addr *saddr,
13066 + SCTP_DEBUG_PRINTK("SRC=%pI6 - ", &fl6->saddr);
13067 + }
13068 +
13069 +- dst = ip6_dst_lookup_flow(sk, fl6, NULL, false);
13070 ++ final_p = fl6_update_dst(fl6, np->opt, &final);
13071 ++ dst = ip6_dst_lookup_flow(sk, fl6, final_p, false);
13072 + if (!asoc || saddr)
13073 + goto out;
13074 +
13075 +@@ -333,10 +315,12 @@ static void sctp_v6_get_dst(struct sctp_transport *t, union sctp_addr *saddr,
13076 + }
13077 + }
13078 + rcu_read_unlock();
13079 ++
13080 + if (baddr) {
13081 + ipv6_addr_copy(&fl6->saddr, &baddr->v6.sin6_addr);
13082 + fl6->fl6_sport = baddr->v6.sin6_port;
13083 +- dst = ip6_dst_lookup_flow(sk, fl6, NULL, false);
13084 ++ final_p = fl6_update_dst(fl6, np->opt, &final);
13085 ++ dst = ip6_dst_lookup_flow(sk, fl6, final_p, false);
13086 + }
13087 +
13088 + out:
13089 +diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
13090 +index 9032d5001a9e..76388b083f28 100644
13091 +--- a/net/sctp/sm_sideeffect.c
13092 ++++ b/net/sctp/sm_sideeffect.c
13093 +@@ -1604,9 +1604,8 @@ static int sctp_cmd_interpreter(sctp_event_t event_type,
13094 + asoc->outqueue.outstanding_bytes;
13095 + sackh.num_gap_ack_blocks = 0;
13096 + sackh.num_dup_tsns = 0;
13097 +- chunk->subh.sack_hdr = &sackh;
13098 + sctp_add_cmd_sf(commands, SCTP_CMD_PROCESS_SACK,
13099 +- SCTP_CHUNK(chunk));
13100 ++ SCTP_SACKH(&sackh));
13101 + break;
13102 +
13103 + case SCTP_CMD_DISCARD_PACKET:
13104 +diff --git a/net/sctp/socket.c b/net/sctp/socket.c
13105 +index ba0108f8b833..c53d01e0a2cf 100644
13106 +--- a/net/sctp/socket.c
13107 ++++ b/net/sctp/socket.c
13108 +@@ -814,6 +814,9 @@ static int sctp_send_asconf_del_ip(struct sock *sk,
13109 + goto skip_mkasconf;
13110 + }
13111 +
13112 ++ if (laddr == NULL)
13113 ++ return -EINVAL;
13114 ++
13115 + /* We do not need RCU protection throughout this loop
13116 + * because this is done under a socket lock from the
13117 + * setsockopt call.
13118 +diff --git a/net/tipc/eth_media.c b/net/tipc/eth_media.c
13119 +index e728d4ce2a1b..a224a38f0218 100644
13120 +--- a/net/tipc/eth_media.c
13121 ++++ b/net/tipc/eth_media.c
13122 +@@ -53,6 +53,7 @@ struct eth_bearer {
13123 + struct tipc_bearer *bearer;
13124 + struct net_device *dev;
13125 + struct packet_type tipc_packet_type;
13126 ++ struct work_struct setup;
13127 + };
13128 +
13129 + static struct eth_bearer eth_bearers[MAX_ETH_BEARERS];
13130 +@@ -121,6 +122,17 @@ static int recv_msg(struct sk_buff *buf, struct net_device *dev,
13131 + }
13132 +
13133 + /**
13134 ++ * setup_bearer - setup association between Ethernet bearer and interface
13135 ++ */
13136 ++static void setup_bearer(struct work_struct *work)
13137 ++{
13138 ++ struct eth_bearer *eb_ptr =
13139 ++ container_of(work, struct eth_bearer, setup);
13140 ++
13141 ++ dev_add_pack(&eb_ptr->tipc_packet_type);
13142 ++}
13143 ++
13144 ++/**
13145 + * enable_bearer - attach TIPC bearer to an Ethernet interface
13146 + */
13147 +
13148 +@@ -164,7 +176,8 @@ static int enable_bearer(struct tipc_bearer *tb_ptr)
13149 + eb_ptr->tipc_packet_type.func = recv_msg;
13150 + eb_ptr->tipc_packet_type.af_packet_priv = eb_ptr;
13151 + INIT_LIST_HEAD(&(eb_ptr->tipc_packet_type.list));
13152 +- dev_add_pack(&eb_ptr->tipc_packet_type);
13153 ++ INIT_WORK(&eb_ptr->setup, setup_bearer);
13154 ++ schedule_work(&eb_ptr->setup);
13155 +
13156 + /* Associate TIPC bearer with Ethernet bearer */
13157 +
13158 +diff --git a/scripts/kernel-doc b/scripts/kernel-doc
13159 +index d793001929cf..ba3d9dfada52 100755
13160 +--- a/scripts/kernel-doc
13161 ++++ b/scripts/kernel-doc
13162 +@@ -2044,6 +2044,9 @@ sub process_file($) {
13163 +
13164 + $section_counter = 0;
13165 + while (<IN>) {
13166 ++ while (s/\\\s*$//) {
13167 ++ $_ .= <IN>;
13168 ++ }
13169 + if ($state == 0) {
13170 + if (/$doc_start/o) {
13171 + $state = 1; # next line is always the function name
13172 +diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
13173 +index a166a857956a..7ebe4b772fe4 100644
13174 +--- a/sound/pci/hda/hda_intel.c
13175 ++++ b/sound/pci/hda/hda_intel.c
13176 +@@ -2621,6 +2621,7 @@ static struct snd_pci_quirk msi_black_list[] __devinitdata = {
13177 + SND_PCI_QUIRK(0x1043, 0x81f2, "ASUS", 0), /* Athlon64 X2 + nvidia */
13178 + SND_PCI_QUIRK(0x1043, 0x81f6, "ASUS", 0), /* nvidia */
13179 + SND_PCI_QUIRK(0x1043, 0x822d, "ASUS", 0), /* Athlon64 X2 + nvidia MCP55 */
13180 ++ SND_PCI_QUIRK(0x1179, 0xfb44, "Toshiba Satellite C870", 0), /* AMD Hudson */
13181 + SND_PCI_QUIRK(0x1849, 0x0888, "ASRock", 0), /* Athlon64 X2 + nvidia */
13182 + SND_PCI_QUIRK(0xa0a0, 0x0575, "Aopen MZ915-M", 0), /* ICH6 */
13183 + {}
13184 +diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
13185 +index 55d9b302ef41..05f097a67a69 100644
13186 +--- a/sound/pci/hda/patch_hdmi.c
13187 ++++ b/sound/pci/hda/patch_hdmi.c
13188 +@@ -512,6 +512,17 @@ static int hdmi_channel_allocation(struct hdmi_eld *eld, int channels)
13189 + }
13190 + }
13191 +
13192 ++ if (!ca) {
13193 ++ /* if there was no match, select the regular ALSA channel
13194 ++ * allocation with the matching number of channels */
13195 ++ for (i = 0; i < ARRAY_SIZE(channel_allocations); i++) {
13196 ++ if (channels == channel_allocations[i].channels) {
13197 ++ ca = channel_allocations[i].ca_index;
13198 ++ break;
13199 ++ }
13200 ++ }
13201 ++ }
13202 ++
13203 + snd_print_channel_allocation(eld->spk_alloc, buf, sizeof(buf));
13204 + snd_printdd("HDMI: select CA 0x%x for %d-channel allocation: %s\n",
13205 + ca, channels, buf);
13206 +diff --git a/sound/soc/codecs/88pm860x-codec.c b/sound/soc/codecs/88pm860x-codec.c
13207 +index 5ca122e51183..290f4d361ecc 100644
13208 +--- a/sound/soc/codecs/88pm860x-codec.c
13209 ++++ b/sound/soc/codecs/88pm860x-codec.c
13210 +@@ -351,6 +351,9 @@ static int snd_soc_put_volsw_2r_st(struct snd_kcontrol *kcontrol,
13211 + val = ucontrol->value.integer.value[0];
13212 + val2 = ucontrol->value.integer.value[1];
13213 +
13214 ++ if (val >= ARRAY_SIZE(st_table) || val2 >= ARRAY_SIZE(st_table))
13215 ++ return -EINVAL;
13216 ++
13217 + err = snd_soc_update_bits(codec, reg, 0x3f, st_table[val].m);
13218 + if (err < 0)
13219 + return err;
13220 +diff --git a/sound/soc/codecs/max98095.c b/sound/soc/codecs/max98095.c
13221 +index 26d7b089fb9c..a52c15bcb778 100644
13222 +--- a/sound/soc/codecs/max98095.c
13223 ++++ b/sound/soc/codecs/max98095.c
13224 +@@ -1861,7 +1861,7 @@ static int max98095_put_eq_enum(struct snd_kcontrol *kcontrol,
13225 + struct max98095_pdata *pdata = max98095->pdata;
13226 + int channel = max98095_get_eq_channel(kcontrol->id.name);
13227 + struct max98095_cdata *cdata;
13228 +- int sel = ucontrol->value.integer.value[0];
13229 ++ unsigned int sel = ucontrol->value.integer.value[0];
13230 + struct max98095_eq_cfg *coef_set;
13231 + int fs, best, best_val, i;
13232 + int regmask, regsave;
13233 +@@ -2014,7 +2014,7 @@ static int max98095_put_bq_enum(struct snd_kcontrol *kcontrol,
13234 + struct max98095_pdata *pdata = max98095->pdata;
13235 + int channel = max98095_get_bq_channel(codec, kcontrol->id.name);
13236 + struct max98095_cdata *cdata;
13237 +- int sel = ucontrol->value.integer.value[0];
13238 ++ unsigned int sel = ucontrol->value.integer.value[0];
13239 + struct max98095_biquad_cfg *coef_set;
13240 + int fs, best, best_val, i;
13241 + int regmask, regsave;
13242 +diff --git a/sound/soc/codecs/wm8960.c b/sound/soc/codecs/wm8960.c
13243 +index 2df253c18568..ef96ca6bfbe1 100644
13244 +--- a/sound/soc/codecs/wm8960.c
13245 ++++ b/sound/soc/codecs/wm8960.c
13246 +@@ -805,9 +805,9 @@ static int wm8960_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id,
13247 + if (pll_div.k) {
13248 + reg |= 0x20;
13249 +
13250 +- snd_soc_write(codec, WM8960_PLL2, (pll_div.k >> 18) & 0x3f);
13251 +- snd_soc_write(codec, WM8960_PLL3, (pll_div.k >> 9) & 0x1ff);
13252 +- snd_soc_write(codec, WM8960_PLL4, pll_div.k & 0x1ff);
13253 ++ snd_soc_write(codec, WM8960_PLL2, (pll_div.k >> 16) & 0xff);
13254 ++ snd_soc_write(codec, WM8960_PLL3, (pll_div.k >> 8) & 0xff);
13255 ++ snd_soc_write(codec, WM8960_PLL4, pll_div.k & 0xff);
13256 + }
13257 + snd_soc_write(codec, WM8960_PLL1, reg);
13258 +
13259 +diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
13260 +index 42dffa07f819..f7a7b9d1d4c0 100644
13261 +--- a/tools/perf/util/map.c
13262 ++++ b/tools/perf/util/map.c
13263 +@@ -16,6 +16,7 @@ const char *map_type__name[MAP__NR_TYPES] = {
13264 + static inline int is_anon_memory(const char *filename)
13265 + {
13266 + return !strcmp(filename, "//anon") ||
13267 ++ !strcmp(filename, "/dev/zero (deleted)") ||
13268 + !strcmp(filename, "/anon_hugepage (deleted)");
13269 + }
13270 +
13271
13272 Modified: genpatches-2.6/trunk/3.4/0000_README
13273 ===================================================================
13274 --- genpatches-2.6/trunk/3.4/0000_README 2013-11-26 00:34:31 UTC (rev 2594)
13275 +++ genpatches-2.6/trunk/3.4/0000_README 2013-11-29 23:44:29 UTC (rev 2595)
13276 @@ -319,6 +319,10 @@
13277 From: http://www.kernel.org
13278 Desc: Linux 3.4.70
13279
13280 +Patch: 1070_linux-3.4.71.patch
13281 +From: http://www.kernel.org
13282 +Desc: Linux 3.4.71
13283 +
13284 Patch: 1500_XATTR_USER_PREFIX.patch
13285 From: https://bugs.gentoo.org/show_bug.cgi?id=470644
13286 Desc: Support for namespace user.pax.* on tmpfs.
13287
13288 Added: genpatches-2.6/trunk/3.4/1070_linux-3.4.71.patch
13289 ===================================================================
13290 --- genpatches-2.6/trunk/3.4/1070_linux-3.4.71.patch (rev 0)
13291 +++ genpatches-2.6/trunk/3.4/1070_linux-3.4.71.patch 2013-11-29 23:44:29 UTC (rev 2595)
13292 @@ -0,0 +1,1738 @@
13293 +diff --git a/Makefile b/Makefile
13294 +index d7c0a3833a2b..05ace57061d6 100644
13295 +--- a/Makefile
13296 ++++ b/Makefile
13297 +@@ -1,6 +1,6 @@
13298 + VERSION = 3
13299 + PATCHLEVEL = 4
13300 +-SUBLEVEL = 70
13301 ++SUBLEVEL = 71
13302 + EXTRAVERSION =
13303 + NAME = Saber-toothed Squirrel
13304 +
13305 +diff --git a/arch/cris/include/asm/io.h b/arch/cris/include/asm/io.h
13306 +index ac12ae2b9286..db9a16c704f3 100644
13307 +--- a/arch/cris/include/asm/io.h
13308 ++++ b/arch/cris/include/asm/io.h
13309 +@@ -3,6 +3,7 @@
13310 +
13311 + #include <asm/page.h> /* for __va, __pa */
13312 + #include <arch/io.h>
13313 ++#include <asm-generic/iomap.h>
13314 + #include <linux/kernel.h>
13315 +
13316 + struct cris_io_operations
13317 +diff --git a/arch/ia64/include/asm/processor.h b/arch/ia64/include/asm/processor.h
13318 +index 483f6c6a4238..2d0cb8e8eedd 100644
13319 +--- a/arch/ia64/include/asm/processor.h
13320 ++++ b/arch/ia64/include/asm/processor.h
13321 +@@ -322,7 +322,7 @@ struct thread_struct {
13322 + regs->loadrs = 0; \
13323 + regs->r8 = get_dumpable(current->mm); /* set "don't zap registers" flag */ \
13324 + regs->r12 = new_sp - 16; /* allocate 16 byte scratch area */ \
13325 +- if (unlikely(!get_dumpable(current->mm))) { \
13326 ++ if (unlikely(get_dumpable(current->mm) != SUID_DUMP_USER)) { \
13327 + /* \
13328 + * Zap scratch regs to avoid leaking bits between processes with different \
13329 + * uid/privileges. \
13330 +diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
13331 +index 45eb998557f8..e6de787956ce 100644
13332 +--- a/arch/powerpc/kernel/signal_32.c
13333 ++++ b/arch/powerpc/kernel/signal_32.c
13334 +@@ -459,7 +459,15 @@ static int save_user_regs(struct pt_regs *regs, struct mcontext __user *frame,
13335 + if (copy_vsx_to_user(&frame->mc_vsregs, current))
13336 + return 1;
13337 + msr |= MSR_VSX;
13338 +- }
13339 ++ } else if (!ctx_has_vsx_region)
13340 ++ /*
13341 ++ * With a small context structure we can't hold the VSX
13342 ++ * registers, hence clear the MSR value to indicate the state
13343 ++ * was not saved.
13344 ++ */
13345 ++ msr &= ~MSR_VSX;
13346 ++
13347 ++
13348 + #endif /* CONFIG_VSX */
13349 + #ifdef CONFIG_SPE
13350 + /* save spe registers */
13351 +diff --git a/arch/powerpc/kernel/vio.c b/arch/powerpc/kernel/vio.c
13352 +index cfe0069bcfc8..fcf89bff1177 100644
13353 +--- a/arch/powerpc/kernel/vio.c
13354 ++++ b/arch/powerpc/kernel/vio.c
13355 +@@ -1342,12 +1342,12 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
13356 +
13357 + dn = dev->of_node;
13358 + if (!dn) {
13359 +- strcat(buf, "\n");
13360 ++ strcpy(buf, "\n");
13361 + return strlen(buf);
13362 + }
13363 + cp = of_get_property(dn, "compatible", NULL);
13364 + if (!cp) {
13365 +- strcat(buf, "\n");
13366 ++ strcpy(buf, "\n");
13367 + return strlen(buf);
13368 + }
13369 +
13370 +diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
13371 +index fbdd74dac3ac..5da8e8df5922 100644
13372 +--- a/arch/powerpc/platforms/powernv/pci-ioda.c
13373 ++++ b/arch/powerpc/platforms/powernv/pci-ioda.c
13374 +@@ -613,13 +613,23 @@ static int __devinit pnv_ioda_configure_pe(struct pnv_phb *phb,
13375 + rid_end = pe->rid + 1;
13376 + }
13377 +
13378 +- /* Associate PE in PELT */
13379 ++ /*
13380 ++ * Associate PE in PELT. We need add the PE into the
13381 ++ * corresponding PELT-V as well. Otherwise, the error
13382 ++ * originated from the PE might contribute to other
13383 ++ * PEs.
13384 ++ */
13385 + rc = opal_pci_set_pe(phb->opal_id, pe->pe_number, pe->rid,
13386 + bcomp, dcomp, fcomp, OPAL_MAP_PE);
13387 + if (rc) {
13388 + pe_err(pe, "OPAL error %ld trying to setup PELT table\n", rc);
13389 + return -ENXIO;
13390 + }
13391 ++
13392 ++ rc = opal_pci_set_peltv(phb->opal_id, pe->pe_number,
13393 ++ pe->pe_number, OPAL_ADD_PE_TO_DOMAIN);
13394 ++ if (rc)
13395 ++ pe_warn(pe, "OPAL error %d adding self to PELTV\n", rc);
13396 + opal_pci_eeh_freeze_clear(phb->opal_id, pe->pe_number,
13397 + OPAL_EEH_ACTION_CLEAR_FREEZE_ALL);
13398 +
13399 +diff --git a/arch/x86/kernel/microcode_amd.c b/arch/x86/kernel/microcode_amd.c
13400 +index 5d8cf0d6796c..b316ffe8ab59 100644
13401 +--- a/arch/x86/kernel/microcode_amd.c
13402 ++++ b/arch/x86/kernel/microcode_amd.c
13403 +@@ -338,7 +338,7 @@ static enum ucode_state request_microcode_amd(int cpu, struct device *device)
13404 + snprintf(fw_name, sizeof(fw_name), "amd-ucode/microcode_amd_fam%.2xh.bin", c->x86);
13405 +
13406 + if (request_firmware(&fw, (const char *)fw_name, device)) {
13407 +- pr_err("failed to load file %s\n", fw_name);
13408 ++ pr_debug("failed to load file %s\n", fw_name);
13409 + goto out;
13410 + }
13411 +
13412 +diff --git a/block/blk-core.c b/block/blk-core.c
13413 +index 85fd41003434..a02cfb7e4123 100644
13414 +--- a/block/blk-core.c
13415 ++++ b/block/blk-core.c
13416 +@@ -2041,6 +2041,7 @@ void blk_start_request(struct request *req)
13417 + if (unlikely(blk_bidi_rq(req)))
13418 + req->next_rq->resid_len = blk_rq_bytes(req->next_rq);
13419 +
13420 ++ BUG_ON(test_bit(REQ_ATOM_COMPLETE, &req->atomic_flags));
13421 + blk_add_timer(req);
13422 + }
13423 + EXPORT_SYMBOL(blk_start_request);
13424 +diff --git a/block/blk-settings.c b/block/blk-settings.c
13425 +index d3234fc494ad..b74cc58bc038 100644
13426 +--- a/block/blk-settings.c
13427 ++++ b/block/blk-settings.c
13428 +@@ -143,6 +143,7 @@ void blk_set_stacking_limits(struct queue_limits *lim)
13429 + lim->discard_zeroes_data = 1;
13430 + lim->max_segments = USHRT_MAX;
13431 + lim->max_hw_sectors = UINT_MAX;
13432 ++ lim->max_segment_size = UINT_MAX;
13433 +
13434 + lim->max_sectors = BLK_DEF_MAX_SECTORS;
13435 + }
13436 +diff --git a/block/blk-timeout.c b/block/blk-timeout.c
13437 +index 780354888958..b1182ea52427 100644
13438 +--- a/block/blk-timeout.c
13439 ++++ b/block/blk-timeout.c
13440 +@@ -90,8 +90,8 @@ static void blk_rq_timed_out(struct request *req)
13441 + __blk_complete_request(req);
13442 + break;
13443 + case BLK_EH_RESET_TIMER:
13444 +- blk_clear_rq_complete(req);
13445 + blk_add_timer(req);
13446 ++ blk_clear_rq_complete(req);
13447 + break;
13448 + case BLK_EH_NOT_HANDLED:
13449 + /*
13450 +@@ -173,7 +173,6 @@ void blk_add_timer(struct request *req)
13451 + return;
13452 +
13453 + BUG_ON(!list_empty(&req->timeout_list));
13454 +- BUG_ON(test_bit(REQ_ATOM_COMPLETE, &req->atomic_flags));
13455 +
13456 + /*
13457 + * Some LLDs, like scsi, peek at the timeout to prevent a
13458 +diff --git a/crypto/ansi_cprng.c b/crypto/ansi_cprng.c
13459 +index 6ddd99e6114b..c21f761b65b5 100644
13460 +--- a/crypto/ansi_cprng.c
13461 ++++ b/crypto/ansi_cprng.c
13462 +@@ -230,11 +230,11 @@ remainder:
13463 + */
13464 + if (byte_count < DEFAULT_BLK_SZ) {
13465 + empty_rbuf:
13466 +- for (; ctx->rand_data_valid < DEFAULT_BLK_SZ;
13467 +- ctx->rand_data_valid++) {
13468 ++ while (ctx->rand_data_valid < DEFAULT_BLK_SZ) {
13469 + *ptr = ctx->rand_data[ctx->rand_data_valid];
13470 + ptr++;
13471 + byte_count--;
13472 ++ ctx->rand_data_valid++;
13473 + if (byte_count == 0)
13474 + goto done;
13475 + }
13476 +diff --git a/drivers/acpi/acpica/exoparg1.c b/drivers/acpi/acpica/exoparg1.c
13477 +index 9ba8c73cea16..fe2f9d95d0f8 100644
13478 +--- a/drivers/acpi/acpica/exoparg1.c
13479 ++++ b/drivers/acpi/acpica/exoparg1.c
13480 +@@ -970,10 +970,17 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
13481 + */
13482 + return_desc =
13483 + *(operand[0]->reference.where);
13484 +- if (return_desc) {
13485 +- acpi_ut_add_reference
13486 +- (return_desc);
13487 ++ if (!return_desc) {
13488 ++ /*
13489 ++ * Element is NULL, do not allow the dereference.
13490 ++ * This provides compatibility with other ACPI
13491 ++ * implementations.
13492 ++ */
13493 ++ return_ACPI_STATUS
13494 ++ (AE_AML_UNINITIALIZED_ELEMENT);
13495 + }
13496 ++
13497 ++ acpi_ut_add_reference(return_desc);
13498 + break;
13499 +
13500 + default:
13501 +@@ -998,11 +1005,40 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
13502 + acpi_namespace_node
13503 + *)
13504 + return_desc);
13505 +- }
13506 ++ if (!return_desc) {
13507 ++ break;
13508 ++ }
13509 +
13510 +- /* Add another reference to the object! */
13511 ++ /*
13512 ++ * June 2013:
13513 ++ * buffer_fields/field_units require additional resolution
13514 ++ */
13515 ++ switch (return_desc->common.type) {
13516 ++ case ACPI_TYPE_BUFFER_FIELD:
13517 ++ case ACPI_TYPE_LOCAL_REGION_FIELD:
13518 ++ case ACPI_TYPE_LOCAL_BANK_FIELD:
13519 ++ case ACPI_TYPE_LOCAL_INDEX_FIELD:
13520 +
13521 +- acpi_ut_add_reference(return_desc);
13522 ++ status =
13523 ++ acpi_ex_read_data_from_field
13524 ++ (walk_state, return_desc,
13525 ++ &temp_desc);
13526 ++ if (ACPI_FAILURE(status)) {
13527 ++ goto cleanup;
13528 ++ }
13529 ++
13530 ++ return_desc = temp_desc;
13531 ++ break;
13532 ++
13533 ++ default:
13534 ++
13535 ++ /* Add another reference to the object */
13536 ++
13537 ++ acpi_ut_add_reference
13538 ++ (return_desc);
13539 ++ break;
13540 ++ }
13541 ++ }
13542 + break;
13543 +
13544 + default:
13545 +diff --git a/drivers/acpi/acpica/exstore.c b/drivers/acpi/acpica/exstore.c
13546 +index c6cf843cc4c9..9806f4be7b88 100644
13547 +--- a/drivers/acpi/acpica/exstore.c
13548 ++++ b/drivers/acpi/acpica/exstore.c
13549 +@@ -57,6 +57,11 @@ acpi_ex_store_object_to_index(union acpi_operand_object *val_desc,
13550 + union acpi_operand_object *dest_desc,
13551 + struct acpi_walk_state *walk_state);
13552 +
13553 ++static acpi_status
13554 ++acpi_ex_store_direct_to_node(union acpi_operand_object *source_desc,
13555 ++ struct acpi_namespace_node *node,
13556 ++ struct acpi_walk_state *walk_state);
13557 ++
13558 + /*******************************************************************************
13559 + *
13560 + * FUNCTION: acpi_ex_store
13561 +@@ -376,7 +381,11 @@ acpi_ex_store_object_to_index(union acpi_operand_object *source_desc,
13562 + * When storing into an object the data is converted to the
13563 + * target object type then stored in the object. This means
13564 + * that the target object type (for an initialized target) will
13565 +- * not be changed by a store operation.
13566 ++ * not be changed by a store operation. A copy_object can change
13567 ++ * the target type, however.
13568 ++ *
13569 ++ * The implicit_conversion flag is set to NO/FALSE only when
13570 ++ * storing to an arg_x -- as per the rules of the ACPI spec.
13571 + *
13572 + * Assumes parameters are already validated.
13573 + *
13574 +@@ -400,7 +409,7 @@ acpi_ex_store_object_to_node(union acpi_operand_object *source_desc,
13575 + target_type = acpi_ns_get_type(node);
13576 + target_desc = acpi_ns_get_attached_object(node);
13577 +
13578 +- ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Storing %p(%s) into node %p(%s)\n",
13579 ++ ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Storing %p (%s) to node %p (%s)\n",
13580 + source_desc,
13581 + acpi_ut_get_object_type_name(source_desc), node,
13582 + acpi_ut_get_type_name(target_type)));
13583 +@@ -414,46 +423,31 @@ acpi_ex_store_object_to_node(union acpi_operand_object *source_desc,
13584 + return_ACPI_STATUS(status);
13585 + }
13586 +
13587 +- /* If no implicit conversion, drop into the default case below */
13588 +-
13589 +- if ((!implicit_conversion) ||
13590 +- ((walk_state->opcode == AML_COPY_OP) &&
13591 +- (target_type != ACPI_TYPE_LOCAL_REGION_FIELD) &&
13592 +- (target_type != ACPI_TYPE_LOCAL_BANK_FIELD) &&
13593 +- (target_type != ACPI_TYPE_LOCAL_INDEX_FIELD))) {
13594 +- /*
13595 +- * Force execution of default (no implicit conversion). Note:
13596 +- * copy_object does not perform an implicit conversion, as per the ACPI
13597 +- * spec -- except in case of region/bank/index fields -- because these
13598 +- * objects must retain their original type permanently.
13599 +- */
13600 +- target_type = ACPI_TYPE_ANY;
13601 +- }
13602 +-
13603 + /* Do the actual store operation */
13604 +
13605 + switch (target_type) {
13606 +- case ACPI_TYPE_BUFFER_FIELD:
13607 +- case ACPI_TYPE_LOCAL_REGION_FIELD:
13608 +- case ACPI_TYPE_LOCAL_BANK_FIELD:
13609 +- case ACPI_TYPE_LOCAL_INDEX_FIELD:
13610 +-
13611 +- /* For fields, copy the source data to the target field. */
13612 +-
13613 +- status = acpi_ex_write_data_to_field(source_desc, target_desc,
13614 +- &walk_state->result_obj);
13615 +- break;
13616 +-
13617 + case ACPI_TYPE_INTEGER:
13618 + case ACPI_TYPE_STRING:
13619 + case ACPI_TYPE_BUFFER:
13620 +
13621 + /*
13622 +- * These target types are all of type Integer/String/Buffer, and
13623 +- * therefore support implicit conversion before the store.
13624 +- *
13625 +- * Copy and/or convert the source object to a new target object
13626 ++ * The simple data types all support implicit source operand
13627 ++ * conversion before the store.
13628 + */
13629 ++
13630 ++ if ((walk_state->opcode == AML_COPY_OP) || !implicit_conversion) {
13631 ++ /*
13632 ++ * However, copy_object and Stores to arg_x do not perform
13633 ++ * an implicit conversion, as per the ACPI specification.
13634 ++ * A direct store is performed instead.
13635 ++ */
13636 ++ status = acpi_ex_store_direct_to_node(source_desc, node,
13637 ++ walk_state);
13638 ++ break;
13639 ++ }
13640 ++
13641 ++ /* Store with implicit source operand conversion support */
13642 ++
13643 + status =
13644 + acpi_ex_store_object_to_object(source_desc, target_desc,
13645 + &new_desc, walk_state);
13646 +@@ -467,13 +461,12 @@ acpi_ex_store_object_to_node(union acpi_operand_object *source_desc,
13647 + * the Name's type to that of the value being stored in it.
13648 + * source_desc reference count is incremented by attach_object.
13649 + *
13650 +- * Note: This may change the type of the node if an explicit store
13651 +- * has been performed such that the node/object type has been
13652 +- * changed.
13653 ++ * Note: This may change the type of the node if an explicit
13654 ++ * store has been performed such that the node/object type
13655 ++ * has been changed.
13656 + */
13657 +- status =
13658 +- acpi_ns_attach_object(node, new_desc,
13659 +- new_desc->common.type);
13660 ++ status = acpi_ns_attach_object(node, new_desc,
13661 ++ new_desc->common.type);
13662 +
13663 + ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
13664 + "Store %s into %s via Convert/Attach\n",
13665 +@@ -484,19 +477,83 @@ acpi_ex_store_object_to_node(union acpi_operand_object *source_desc,
13666 + }
13667 + break;
13668 +
13669 ++ case ACPI_TYPE_BUFFER_FIELD:
13670 ++ case ACPI_TYPE_LOCAL_REGION_FIELD:
13671 ++ case ACPI_TYPE_LOCAL_BANK_FIELD:
13672 ++ case ACPI_TYPE_LOCAL_INDEX_FIELD:
13673 ++ /*
13674 ++ * For all fields, always write the source data to the target
13675 ++ * field. Any required implicit source operand conversion is
13676 ++ * performed in the function below as necessary. Note, field
13677 ++ * objects must retain their original type permanently.
13678 ++ */
13679 ++ status = acpi_ex_write_data_to_field(source_desc, target_desc,
13680 ++ &walk_state->result_obj);
13681 ++ break;
13682 ++
13683 + default:
13684 ++ /*
13685 ++ * No conversions for all other types. Directly store a copy of
13686 ++ * the source object. This is the ACPI spec-defined behavior for
13687 ++ * the copy_object operator.
13688 ++ *
13689 ++ * NOTE: For the Store operator, this is a departure from the
13690 ++ * ACPI spec, which states "If conversion is impossible, abort
13691 ++ * the running control method". Instead, this code implements
13692 ++ * "If conversion is impossible, treat the Store operation as
13693 ++ * a CopyObject".
13694 ++ */
13695 ++ status = acpi_ex_store_direct_to_node(source_desc, node,
13696 ++ walk_state);
13697 ++ break;
13698 ++ }
13699 +
13700 +- ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
13701 +- "Storing %s (%p) directly into node (%p) with no implicit conversion\n",
13702 +- acpi_ut_get_object_type_name(source_desc),
13703 +- source_desc, node));
13704 ++ return_ACPI_STATUS(status);
13705 ++}
13706 +
13707 +- /* No conversions for all other types. Just attach the source object */
13708 ++/*******************************************************************************
13709 ++ *
13710 ++ * FUNCTION: acpi_ex_store_direct_to_node
13711 ++ *
13712 ++ * PARAMETERS: source_desc - Value to be stored
13713 ++ * node - Named object to receive the value
13714 ++ * walk_state - Current walk state
13715 ++ *
13716 ++ * RETURN: Status
13717 ++ *
13718 ++ * DESCRIPTION: "Store" an object directly to a node. This involves a copy
13719 ++ * and an attach.
13720 ++ *
13721 ++ ******************************************************************************/
13722 +
13723 +- status = acpi_ns_attach_object(node, source_desc,
13724 +- source_desc->common.type);
13725 +- break;
13726 ++static acpi_status
13727 ++acpi_ex_store_direct_to_node(union acpi_operand_object *source_desc,
13728 ++ struct acpi_namespace_node *node,
13729 ++ struct acpi_walk_state *walk_state)
13730 ++{
13731 ++ acpi_status status;
13732 ++ union acpi_operand_object *new_desc;
13733 ++
13734 ++ ACPI_FUNCTION_TRACE(ex_store_direct_to_node);
13735 ++
13736 ++ ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
13737 ++ "Storing [%s] (%p) directly into node [%s] (%p)"
13738 ++ " with no implicit conversion\n",
13739 ++ acpi_ut_get_object_type_name(source_desc),
13740 ++ source_desc, acpi_ut_get_type_name(node->type),
13741 ++ node));
13742 ++
13743 ++ /* Copy the source object to a new object */
13744 ++
13745 ++ status =
13746 ++ acpi_ut_copy_iobject_to_iobject(source_desc, &new_desc, walk_state);
13747 ++ if (ACPI_FAILURE(status)) {
13748 ++ return_ACPI_STATUS(status);
13749 + }
13750 +
13751 ++ /* Attach the new object to the node */
13752 ++
13753 ++ status = acpi_ns_attach_object(node, new_desc, new_desc->common.type);
13754 ++ acpi_ut_remove_reference(new_desc);
13755 + return_ACPI_STATUS(status);
13756 + }
13757 +diff --git a/drivers/block/brd.c b/drivers/block/brd.c
13758 +index 4e8213aa02fd..a7d70e2a8d74 100644
13759 +--- a/drivers/block/brd.c
13760 ++++ b/drivers/block/brd.c
13761 +@@ -546,7 +546,7 @@ static struct kobject *brd_probe(dev_t dev, int *part, void *data)
13762 +
13763 + mutex_lock(&brd_devices_mutex);
13764 + brd = brd_init_one(MINOR(dev) >> part_shift);
13765 +- kobj = brd ? get_disk(brd->brd_disk) : ERR_PTR(-ENOMEM);
13766 ++ kobj = brd ? get_disk(brd->brd_disk) : NULL;
13767 + mutex_unlock(&brd_devices_mutex);
13768 +
13769 + *part = 0;
13770 +diff --git a/drivers/block/loop.c b/drivers/block/loop.c
13771 +index 179b5b408cb3..a4ddbae2e100 100644
13772 +--- a/drivers/block/loop.c
13773 ++++ b/drivers/block/loop.c
13774 +@@ -1743,7 +1743,7 @@ static struct kobject *loop_probe(dev_t dev, int *part, void *data)
13775 + if (err < 0)
13776 + err = loop_add(&lo, MINOR(dev) >> part_shift);
13777 + if (err < 0)
13778 +- kobj = ERR_PTR(err);
13779 ++ kobj = NULL;
13780 + else
13781 + kobj = get_disk(lo->lo_disk);
13782 + mutex_unlock(&loop_index_mutex);
13783 +diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
13784 +index 22b14a68e35e..1f4f94103c55 100644
13785 +--- a/drivers/hwmon/lm90.c
13786 ++++ b/drivers/hwmon/lm90.c
13787 +@@ -278,7 +278,7 @@ static const struct lm90_params lm90_params[] = {
13788 + [max6696] = {
13789 + .flags = LM90_HAVE_EMERGENCY
13790 + | LM90_HAVE_EMERGENCY_ALARM | LM90_HAVE_TEMP3,
13791 +- .alert_alarms = 0x187c,
13792 ++ .alert_alarms = 0x1c7c,
13793 + .max_convrate = 6,
13794 + .reg_local_ext = MAX6657_REG_R_LOCAL_TEMPL,
13795 + },
13796 +@@ -1504,19 +1504,22 @@ static void lm90_alert(struct i2c_client *client, unsigned int flag)
13797 + if ((alarms & 0x7f) == 0 && (alarms2 & 0xfe) == 0) {
13798 + dev_info(&client->dev, "Everything OK\n");
13799 + } else {
13800 +- if (alarms & 0x61)
13801 ++ if ((alarms & 0x61) || (alarms2 & 0x80))
13802 + dev_warn(&client->dev,
13803 + "temp%d out of range, please check!\n", 1);
13804 +- if (alarms & 0x1a)
13805 ++ if ((alarms & 0x1a) || (alarms2 & 0x20))
13806 + dev_warn(&client->dev,
13807 + "temp%d out of range, please check!\n", 2);
13808 + if (alarms & 0x04)
13809 + dev_warn(&client->dev,
13810 + "temp%d diode open, please check!\n", 2);
13811 +
13812 +- if (alarms2 & 0x18)
13813 ++ if (alarms2 & 0x5a)
13814 + dev_warn(&client->dev,
13815 + "temp%d out of range, please check!\n", 3);
13816 ++ if (alarms2 & 0x04)
13817 ++ dev_warn(&client->dev,
13818 ++ "temp%d diode open, please check!\n", 3);
13819 +
13820 + /*
13821 + * Disable ALERT# output, because these chips don't implement
13822 +diff --git a/drivers/net/can/c_can/c_can.c b/drivers/net/can/c_can/c_can.c
13823 +index 21a3d77ea7e2..77405b4e8636 100644
13824 +--- a/drivers/net/can/c_can/c_can.c
13825 ++++ b/drivers/net/can/c_can/c_can.c
13826 +@@ -760,9 +760,6 @@ static int c_can_do_rx_poll(struct net_device *dev, int quota)
13827 + msg_ctrl_save = priv->read_reg(priv,
13828 + &priv->regs->ifregs[0].msg_cntrl);
13829 +
13830 +- if (msg_ctrl_save & IF_MCONT_EOB)
13831 +- return num_rx_pkts;
13832 +-
13833 + if (msg_ctrl_save & IF_MCONT_MSGLST) {
13834 + c_can_handle_lost_msg_obj(dev, 0, msg_obj);
13835 + num_rx_pkts++;
13836 +@@ -770,6 +767,9 @@ static int c_can_do_rx_poll(struct net_device *dev, int quota)
13837 + continue;
13838 + }
13839 +
13840 ++ if (msg_ctrl_save & IF_MCONT_EOB)
13841 ++ return num_rx_pkts;
13842 ++
13843 + if (!(msg_ctrl_save & IF_MCONT_NEWDAT))
13844 + continue;
13845 +
13846 +diff --git a/drivers/net/ethernet/realtek/8139cp.c b/drivers/net/ethernet/realtek/8139cp.c
13847 +index 1b4404725b8c..effb3b71ce75 100644
13848 +--- a/drivers/net/ethernet/realtek/8139cp.c
13849 ++++ b/drivers/net/ethernet/realtek/8139cp.c
13850 +@@ -1232,6 +1232,7 @@ static void cp_tx_timeout(struct net_device *dev)
13851 + cp_clean_rings(cp);
13852 + rc = cp_init_rings(cp);
13853 + cp_start_hw(cp);
13854 ++ cp_enable_irq(cp);
13855 +
13856 + netif_wake_queue(dev);
13857 +
13858 +diff --git a/drivers/net/wireless/libertas/debugfs.c b/drivers/net/wireless/libertas/debugfs.c
13859 +index a06cc283e23d..0b48430d6ad0 100644
13860 +--- a/drivers/net/wireless/libertas/debugfs.c
13861 ++++ b/drivers/net/wireless/libertas/debugfs.c
13862 +@@ -913,7 +913,10 @@ static ssize_t lbs_debugfs_write(struct file *f, const char __user *buf,
13863 + char *p2;
13864 + struct debug_data *d = f->private_data;
13865 +
13866 +- pdata = kmalloc(cnt, GFP_KERNEL);
13867 ++ if (cnt == 0)
13868 ++ return 0;
13869 ++
13870 ++ pdata = kmalloc(cnt + 1, GFP_KERNEL);
13871 + if (pdata == NULL)
13872 + return 0;
13873 +
13874 +@@ -922,6 +925,7 @@ static ssize_t lbs_debugfs_write(struct file *f, const char __user *buf,
13875 + kfree(pdata);
13876 + return 0;
13877 + }
13878 ++ pdata[cnt] = '\0';
13879 +
13880 + p0 = pdata;
13881 + for (i = 0; i < num_of_items; i++) {
13882 +diff --git a/drivers/net/wireless/rt2x00/rt2800usb.c b/drivers/net/wireless/rt2x00/rt2800usb.c
13883 +index 65cb4250259f..6eec862fea28 100644
13884 +--- a/drivers/net/wireless/rt2x00/rt2800usb.c
13885 ++++ b/drivers/net/wireless/rt2x00/rt2800usb.c
13886 +@@ -143,6 +143,8 @@ static bool rt2800usb_txstatus_timeout(struct rt2x00_dev *rt2x00dev)
13887 + return false;
13888 + }
13889 +
13890 ++#define TXSTATUS_READ_INTERVAL 1000000
13891 ++
13892 + static bool rt2800usb_tx_sta_fifo_read_completed(struct rt2x00_dev *rt2x00dev,
13893 + int urb_status, u32 tx_status)
13894 + {
13895 +@@ -170,8 +172,9 @@ static bool rt2800usb_tx_sta_fifo_read_completed(struct rt2x00_dev *rt2x00dev,
13896 + queue_work(rt2x00dev->workqueue, &rt2x00dev->txdone_work);
13897 +
13898 + if (rt2800usb_txstatus_pending(rt2x00dev)) {
13899 +- /* Read register after 250 us */
13900 +- hrtimer_start(&rt2x00dev->txstatus_timer, ktime_set(0, 250000),
13901 ++ /* Read register after 1 ms */
13902 ++ hrtimer_start(&rt2x00dev->txstatus_timer,
13903 ++ ktime_set(0, TXSTATUS_READ_INTERVAL),
13904 + HRTIMER_MODE_REL);
13905 + return false;
13906 + }
13907 +@@ -196,8 +199,9 @@ static void rt2800usb_async_read_tx_status(struct rt2x00_dev *rt2x00dev)
13908 + if (test_and_set_bit(TX_STATUS_READING, &rt2x00dev->flags))
13909 + return;
13910 +
13911 +- /* Read TX_STA_FIFO register after 500 us */
13912 +- hrtimer_start(&rt2x00dev->txstatus_timer, ktime_set(0, 500000),
13913 ++ /* Read TX_STA_FIFO register after 2 ms */
13914 ++ hrtimer_start(&rt2x00dev->txstatus_timer,
13915 ++ ktime_set(0, 2*TXSTATUS_READ_INTERVAL),
13916 + HRTIMER_MODE_REL);
13917 + }
13918 +
13919 +diff --git a/drivers/net/wireless/rt2x00/rt2x00mac.c b/drivers/net/wireless/rt2x00/rt2x00mac.c
13920 +index a8885f060060..6701f2d71274 100644
13921 +--- a/drivers/net/wireless/rt2x00/rt2x00mac.c
13922 ++++ b/drivers/net/wireless/rt2x00/rt2x00mac.c
13923 +@@ -771,6 +771,9 @@ void rt2x00mac_flush(struct ieee80211_hw *hw, bool drop)
13924 + struct rt2x00_dev *rt2x00dev = hw->priv;
13925 + struct data_queue *queue;
13926 +
13927 ++ if (!test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags))
13928 ++ return;
13929 ++
13930 + tx_queue_for_each(rt2x00dev, queue)
13931 + rt2x00queue_flush_queue(queue, drop);
13932 + }
13933 +diff --git a/drivers/scsi/aacraid/commctrl.c b/drivers/scsi/aacraid/commctrl.c
13934 +index 0bd38da4ada0..05fbc3ded9b5 100644
13935 +--- a/drivers/scsi/aacraid/commctrl.c
13936 ++++ b/drivers/scsi/aacraid/commctrl.c
13937 +@@ -508,7 +508,8 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
13938 + goto cleanup;
13939 + }
13940 +
13941 +- if (fibsize > (dev->max_fib_size - sizeof(struct aac_fibhdr))) {
13942 ++ if ((fibsize < (sizeof(struct user_aac_srb) - sizeof(struct user_sgentry))) ||
13943 ++ (fibsize > (dev->max_fib_size - sizeof(struct aac_fibhdr)))) {
13944 + rcode = -EINVAL;
13945 + goto cleanup;
13946 + }
13947 +diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
13948 +index a783d533a1a6..715075291834 100644
13949 +--- a/drivers/uio/uio.c
13950 ++++ b/drivers/uio/uio.c
13951 +@@ -650,16 +650,30 @@ static int uio_mmap_physical(struct vm_area_struct *vma)
13952 + {
13953 + struct uio_device *idev = vma->vm_private_data;
13954 + int mi = uio_find_mem_index(vma);
13955 ++ struct uio_mem *mem;
13956 + if (mi < 0)
13957 + return -EINVAL;
13958 ++ mem = idev->info->mem + mi;
13959 ++
13960 ++ if (vma->vm_end - vma->vm_start > mem->size)
13961 ++ return -EINVAL;
13962 +
13963 + vma->vm_flags |= VM_IO | VM_RESERVED;
13964 +
13965 + vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
13966 +
13967 ++ /*
13968 ++ * We cannot use the vm_iomap_memory() helper here,
13969 ++ * because vma->vm_pgoff is the map index we looked
13970 ++ * up above in uio_find_mem_index(), rather than an
13971 ++ * actual page offset into the mmap.
13972 ++ *
13973 ++ * So we just do the physical mmap without a page
13974 ++ * offset.
13975 ++ */
13976 + return remap_pfn_range(vma,
13977 + vma->vm_start,
13978 +- idev->info->mem[mi].addr >> PAGE_SHIFT,
13979 ++ mem->addr >> PAGE_SHIFT,
13980 + vma->vm_end - vma->vm_start,
13981 + vma->vm_page_prot);
13982 + }
13983 +diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
13984 +index c8542356898b..91293b68df5a 100644
13985 +--- a/drivers/usb/serial/mos7840.c
13986 ++++ b/drivers/usb/serial/mos7840.c
13987 +@@ -1664,7 +1664,11 @@ static int mos7840_tiocmget(struct tty_struct *tty)
13988 + return -ENODEV;
13989 +
13990 + status = mos7840_get_uart_reg(port, MODEM_STATUS_REGISTER, &msr);
13991 ++ if (status != 1)
13992 ++ return -EIO;
13993 + status = mos7840_get_uart_reg(port, MODEM_CONTROL_REGISTER, &mcr);
13994 ++ if (status != 1)
13995 ++ return -EIO;
13996 + result = ((mcr & MCR_DTR) ? TIOCM_DTR : 0)
13997 + | ((mcr & MCR_RTS) ? TIOCM_RTS : 0)
13998 + | ((mcr & MCR_LOOPBACK) ? TIOCM_LOOP : 0)
13999 +diff --git a/drivers/video/au1100fb.c b/drivers/video/au1100fb.c
14000 +index ffbce4525468..612c1c7cb31b 100644
14001 +--- a/drivers/video/au1100fb.c
14002 ++++ b/drivers/video/au1100fb.c
14003 +@@ -375,39 +375,15 @@ void au1100fb_fb_rotate(struct fb_info *fbi, int angle)
14004 + int au1100fb_fb_mmap(struct fb_info *fbi, struct vm_area_struct *vma)
14005 + {
14006 + struct au1100fb_device *fbdev;
14007 +- unsigned int len;
14008 +- unsigned long start=0, off;
14009 +
14010 + fbdev = to_au1100fb_device(fbi);
14011 +
14012 +- if (vma->vm_pgoff > (~0UL >> PAGE_SHIFT)) {
14013 +- return -EINVAL;
14014 +- }
14015 +-
14016 +- start = fbdev->fb_phys & PAGE_MASK;
14017 +- len = PAGE_ALIGN((start & ~PAGE_MASK) + fbdev->fb_len);
14018 +-
14019 +- off = vma->vm_pgoff << PAGE_SHIFT;
14020 +-
14021 +- if ((vma->vm_end - vma->vm_start + off) > len) {
14022 +- return -EINVAL;
14023 +- }
14024 +-
14025 +- off += start;
14026 +- vma->vm_pgoff = off >> PAGE_SHIFT;
14027 +-
14028 + vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
14029 + pgprot_val(vma->vm_page_prot) |= (6 << 9); //CCA=6
14030 +
14031 + vma->vm_flags |= VM_IO;
14032 +
14033 +- if (io_remap_pfn_range(vma, vma->vm_start, off >> PAGE_SHIFT,
14034 +- vma->vm_end - vma->vm_start,
14035 +- vma->vm_page_prot)) {
14036 +- return -EAGAIN;
14037 +- }
14038 +-
14039 +- return 0;
14040 ++ return vm_iomap_memory(vma, fbdev->fb_phys, fbdev->fb_len);
14041 + }
14042 +
14043 + static struct fb_ops au1100fb_ops =
14044 +diff --git a/drivers/video/au1200fb.c b/drivers/video/au1200fb.c
14045 +index 7ca79f02056e..117be3d9b854 100644
14046 +--- a/drivers/video/au1200fb.c
14047 ++++ b/drivers/video/au1200fb.c
14048 +@@ -1233,36 +1233,15 @@ static int au1200fb_fb_blank(int blank_mode, struct fb_info *fbi)
14049 + * method mainly to allow the use of the TLB streaming flag (CCA=6)
14050 + */
14051 + static int au1200fb_fb_mmap(struct fb_info *info, struct vm_area_struct *vma)
14052 +-
14053 + {
14054 +- unsigned int len;
14055 +- unsigned long start=0, off;
14056 + struct au1200fb_device *fbdev = info->par;
14057 +
14058 +- if (vma->vm_pgoff > (~0UL >> PAGE_SHIFT)) {
14059 +- return -EINVAL;
14060 +- }
14061 +-
14062 +- start = fbdev->fb_phys & PAGE_MASK;
14063 +- len = PAGE_ALIGN((start & ~PAGE_MASK) + fbdev->fb_len);
14064 +-
14065 +- off = vma->vm_pgoff << PAGE_SHIFT;
14066 +-
14067 +- if ((vma->vm_end - vma->vm_start + off) > len) {
14068 +- return -EINVAL;
14069 +- }
14070 +-
14071 +- off += start;
14072 +- vma->vm_pgoff = off >> PAGE_SHIFT;
14073 +-
14074 + vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
14075 + pgprot_val(vma->vm_page_prot) |= _CACHE_MASK; /* CCA=7 */
14076 +
14077 + vma->vm_flags |= VM_IO;
14078 +
14079 +- return io_remap_pfn_range(vma, vma->vm_start, off >> PAGE_SHIFT,
14080 +- vma->vm_end - vma->vm_start,
14081 +- vma->vm_page_prot);
14082 ++ return vm_iomap_memory(vma, fbdev->fb_phys, fbdev->fb_len);
14083 +
14084 + return 0;
14085 + }
14086 +diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
14087 +index 7e6c52d8a207..c91f6d1bf64f 100644
14088 +--- a/fs/configfs/dir.c
14089 ++++ b/fs/configfs/dir.c
14090 +@@ -56,10 +56,19 @@ static void configfs_d_iput(struct dentry * dentry,
14091 + struct configfs_dirent *sd = dentry->d_fsdata;
14092 +
14093 + if (sd) {
14094 +- BUG_ON(sd->s_dentry != dentry);
14095 + /* Coordinate with configfs_readdir */
14096 + spin_lock(&configfs_dirent_lock);
14097 +- sd->s_dentry = NULL;
14098 ++ /* Coordinate with configfs_attach_attr where will increase
14099 ++ * sd->s_count and update sd->s_dentry to new allocated one.
14100 ++ * Only set sd->dentry to null when this dentry is the only
14101 ++ * sd owner.
14102 ++ * If not do so, configfs_d_iput may run just after
14103 ++ * configfs_attach_attr and set sd->s_dentry to null
14104 ++ * even it's still in use.
14105 ++ */
14106 ++ if (atomic_read(&sd->s_count) <= 2)
14107 ++ sd->s_dentry = NULL;
14108 ++
14109 + spin_unlock(&configfs_dirent_lock);
14110 + configfs_put(sd);
14111 + }
14112 +@@ -426,8 +435,11 @@ static int configfs_attach_attr(struct configfs_dirent * sd, struct dentry * den
14113 + struct configfs_attribute * attr = sd->s_element;
14114 + int error;
14115 +
14116 ++ spin_lock(&configfs_dirent_lock);
14117 + dentry->d_fsdata = configfs_get(sd);
14118 + sd->s_dentry = dentry;
14119 ++ spin_unlock(&configfs_dirent_lock);
14120 ++
14121 + error = configfs_create(dentry, (attr->ca_mode & S_IALLUGO) | S_IFREG,
14122 + configfs_init_file);
14123 + if (error) {
14124 +diff --git a/fs/dcache.c b/fs/dcache.c
14125 +index 9d39de40909d..09e2eda55c57 100644
14126 +--- a/fs/dcache.c
14127 ++++ b/fs/dcache.c
14128 +@@ -2513,7 +2513,6 @@ static int prepend_path(const struct path *path,
14129 + bool slash = false;
14130 + int error = 0;
14131 +
14132 +- br_read_lock(vfsmount_lock);
14133 + while (dentry != root->dentry || vfsmnt != root->mnt) {
14134 + struct dentry * parent;
14135 +
14136 +@@ -2543,8 +2542,6 @@ static int prepend_path(const struct path *path,
14137 + if (!error && !slash)
14138 + error = prepend(buffer, buflen, "/", 1);
14139 +
14140 +-out:
14141 +- br_read_unlock(vfsmount_lock);
14142 + return error;
14143 +
14144 + global_root:
14145 +@@ -2561,7 +2558,7 @@ global_root:
14146 + error = prepend(buffer, buflen, "/", 1);
14147 + if (!error)
14148 + error = real_mount(vfsmnt)->mnt_ns ? 1 : 2;
14149 +- goto out;
14150 ++ return error;
14151 + }
14152 +
14153 + /**
14154 +@@ -2588,9 +2585,11 @@ char *__d_path(const struct path *path,
14155 + int error;
14156 +
14157 + prepend(&res, &buflen, "\0", 1);
14158 ++ br_read_lock(vfsmount_lock);
14159 + write_seqlock(&rename_lock);
14160 + error = prepend_path(path, root, &res, &buflen);
14161 + write_sequnlock(&rename_lock);
14162 ++ br_read_unlock(vfsmount_lock);
14163 +
14164 + if (error < 0)
14165 + return ERR_PTR(error);
14166 +@@ -2607,9 +2606,11 @@ char *d_absolute_path(const struct path *path,
14167 + int error;
14168 +
14169 + prepend(&res, &buflen, "\0", 1);
14170 ++ br_read_lock(vfsmount_lock);
14171 + write_seqlock(&rename_lock);
14172 + error = prepend_path(path, &root, &res, &buflen);
14173 + write_sequnlock(&rename_lock);
14174 ++ br_read_unlock(vfsmount_lock);
14175 +
14176 + if (error > 1)
14177 + error = -EINVAL;
14178 +@@ -2673,11 +2674,13 @@ char *d_path(const struct path *path, char *buf, int buflen)
14179 + return path->dentry->d_op->d_dname(path->dentry, buf, buflen);
14180 +
14181 + get_fs_root(current->fs, &root);
14182 ++ br_read_lock(vfsmount_lock);
14183 + write_seqlock(&rename_lock);
14184 + error = path_with_deleted(path, &root, &res, &buflen);
14185 ++ write_sequnlock(&rename_lock);
14186 ++ br_read_unlock(vfsmount_lock);
14187 + if (error < 0)
14188 + res = ERR_PTR(error);
14189 +- write_sequnlock(&rename_lock);
14190 + path_put(&root);
14191 + return res;
14192 + }
14193 +@@ -2832,6 +2835,7 @@ SYSCALL_DEFINE2(getcwd, char __user *, buf, unsigned long, size)
14194 + get_fs_root_and_pwd(current->fs, &root, &pwd);
14195 +
14196 + error = -ENOENT;
14197 ++ br_read_lock(vfsmount_lock);
14198 + write_seqlock(&rename_lock);
14199 + if (!d_unlinked(pwd.dentry)) {
14200 + unsigned long len;
14201 +@@ -2841,6 +2845,7 @@ SYSCALL_DEFINE2(getcwd, char __user *, buf, unsigned long, size)
14202 + prepend(&cwd, &buflen, "\0", 1);
14203 + error = prepend_path(&pwd, &root, &cwd, &buflen);
14204 + write_sequnlock(&rename_lock);
14205 ++ br_read_unlock(vfsmount_lock);
14206 +
14207 + if (error < 0)
14208 + goto out;
14209 +@@ -2861,6 +2866,7 @@ SYSCALL_DEFINE2(getcwd, char __user *, buf, unsigned long, size)
14210 + }
14211 + } else {
14212 + write_sequnlock(&rename_lock);
14213 ++ br_read_unlock(vfsmount_lock);
14214 + }
14215 +
14216 + out:
14217 +diff --git a/fs/exec.c b/fs/exec.c
14218 +index 0ea0b4c476d8..5b9dfbe84b19 100644
14219 +--- a/fs/exec.c
14220 ++++ b/fs/exec.c
14221 +@@ -909,11 +909,13 @@ static int de_thread(struct task_struct *tsk)
14222 +
14223 + sig->notify_count = -1; /* for exit_notify() */
14224 + for (;;) {
14225 ++ threadgroup_change_begin(tsk);
14226 + write_lock_irq(&tasklist_lock);
14227 + if (likely(leader->exit_state))
14228 + break;
14229 + __set_current_state(TASK_UNINTERRUPTIBLE);
14230 + write_unlock_irq(&tasklist_lock);
14231 ++ threadgroup_change_end(tsk);
14232 + schedule();
14233 + }
14234 +
14235 +@@ -969,6 +971,7 @@ static int de_thread(struct task_struct *tsk)
14236 + if (unlikely(leader->ptrace))
14237 + __wake_up_parent(leader, leader->parent);
14238 + write_unlock_irq(&tasklist_lock);
14239 ++ threadgroup_change_end(tsk);
14240 +
14241 + release_task(leader);
14242 + }
14243 +@@ -2024,6 +2027,12 @@ static int __get_dumpable(unsigned long mm_flags)
14244 + return (ret >= 2) ? 2 : ret;
14245 + }
14246 +
14247 ++/*
14248 ++ * This returns the actual value of the suid_dumpable flag. For things
14249 ++ * that are using this for checking for privilege transitions, it must
14250 ++ * test against SUID_DUMP_USER rather than treating it as a boolean
14251 ++ * value.
14252 ++ */
14253 + int get_dumpable(struct mm_struct *mm)
14254 + {
14255 + return __get_dumpable(mm->flags);
14256 +diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
14257 +index edf411988bf3..9bb4e5c541b0 100644
14258 +--- a/fs/nfs/inode.c
14259 ++++ b/fs/nfs/inode.c
14260 +@@ -224,6 +224,8 @@ nfs_find_actor(struct inode *inode, void *opaque)
14261 +
14262 + if (NFS_FILEID(inode) != fattr->fileid)
14263 + return 0;
14264 ++ if ((S_IFMT & inode->i_mode) != (S_IFMT & fattr->mode))
14265 ++ return 0;
14266 + if (nfs_compare_fh(NFS_FH(inode), fh))
14267 + return 0;
14268 + if (is_bad_inode(inode) || NFS_STALE(inode))
14269 +diff --git a/fs/nfs/nfs3proc.c b/fs/nfs/nfs3proc.c
14270 +index a7a043d272da..51017baa67af 100644
14271 +--- a/fs/nfs/nfs3proc.c
14272 ++++ b/fs/nfs/nfs3proc.c
14273 +@@ -24,14 +24,14 @@
14274 +
14275 + #define NFSDBG_FACILITY NFSDBG_PROC
14276 +
14277 +-/* A wrapper to handle the EJUKEBOX and EKEYEXPIRED error messages */
14278 ++/* A wrapper to handle the EJUKEBOX error messages */
14279 + static int
14280 + nfs3_rpc_wrapper(struct rpc_clnt *clnt, struct rpc_message *msg, int flags)
14281 + {
14282 + int res;
14283 + do {
14284 + res = rpc_call_sync(clnt, msg, flags);
14285 +- if (res != -EJUKEBOX && res != -EKEYEXPIRED)
14286 ++ if (res != -EJUKEBOX)
14287 + break;
14288 + freezable_schedule_timeout_killable(NFS_JUKEBOX_RETRY_TIME);
14289 + res = -ERESTARTSYS;
14290 +@@ -44,7 +44,7 @@ nfs3_rpc_wrapper(struct rpc_clnt *clnt, struct rpc_message *msg, int flags)
14291 + static int
14292 + nfs3_async_handle_jukebox(struct rpc_task *task, struct inode *inode)
14293 + {
14294 +- if (task->tk_status != -EJUKEBOX && task->tk_status != -EKEYEXPIRED)
14295 ++ if (task->tk_status != -EJUKEBOX)
14296 + return 0;
14297 + if (task->tk_status == -EJUKEBOX)
14298 + nfs_inc_stats(inode, NFSIOS_DELAY);
14299 +diff --git a/fs/nfs/nfs4filelayout.c b/fs/nfs/nfs4filelayout.c
14300 +index 5acfd9ea8a31..4d64d5b85e56 100644
14301 +--- a/fs/nfs/nfs4filelayout.c
14302 ++++ b/fs/nfs/nfs4filelayout.c
14303 +@@ -122,7 +122,6 @@ static int filelayout_async_handle_error(struct rpc_task *task,
14304 + break;
14305 + case -NFS4ERR_DELAY:
14306 + case -NFS4ERR_GRACE:
14307 +- case -EKEYEXPIRED:
14308 + rpc_delay(task, FILELAYOUT_POLL_RETRY_MAX);
14309 + break;
14310 + case -NFS4ERR_RETRY_UNCACHED_REP:
14311 +diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
14312 +index d121c67f87d0..cabddb5da071 100644
14313 +--- a/fs/nfs/nfs4proc.c
14314 ++++ b/fs/nfs/nfs4proc.c
14315 +@@ -319,7 +319,6 @@ static int nfs4_handle_exception(struct nfs_server *server, int errorcode, struc
14316 + }
14317 + case -NFS4ERR_GRACE:
14318 + case -NFS4ERR_DELAY:
14319 +- case -EKEYEXPIRED:
14320 + ret = nfs4_delay(server->client, &exception->timeout);
14321 + if (ret != 0)
14322 + break;
14323 +@@ -1352,13 +1351,6 @@ int nfs4_open_delegation_recall(struct nfs_open_context *ctx, struct nfs4_state
14324 + nfs_inode_find_state_and_recover(state->inode,
14325 + stateid);
14326 + nfs4_schedule_stateid_recovery(server, state);
14327 +- case -EKEYEXPIRED:
14328 +- /*
14329 +- * User RPCSEC_GSS context has expired.
14330 +- * We cannot recover this stateid now, so
14331 +- * skip it and allow recovery thread to
14332 +- * proceed.
14333 +- */
14334 + case -ENOMEM:
14335 + err = 0;
14336 + goto out;
14337 +@@ -3924,7 +3916,6 @@ nfs4_async_handle_error(struct rpc_task *task, const struct nfs_server *server,
14338 + case -NFS4ERR_DELAY:
14339 + nfs_inc_server_stats(server, NFSIOS_DELAY);
14340 + case -NFS4ERR_GRACE:
14341 +- case -EKEYEXPIRED:
14342 + rpc_delay(task, NFS4_POLL_RETRY_MAX);
14343 + task->tk_status = 0;
14344 + return -EAGAIN;
14345 +@@ -4216,6 +4207,7 @@ static int _nfs4_proc_getlk(struct nfs4_state *state, int cmd, struct file_lock
14346 + status = 0;
14347 + }
14348 + request->fl_ops->fl_release_private(request);
14349 ++ request->fl_ops = NULL;
14350 + out:
14351 + return status;
14352 + }
14353 +@@ -4871,15 +4863,6 @@ int nfs4_lock_delegation_recall(struct nfs4_state *state, struct file_lock *fl)
14354 + nfs4_schedule_stateid_recovery(server, state);
14355 + err = 0;
14356 + goto out;
14357 +- case -EKEYEXPIRED:
14358 +- /*
14359 +- * User RPCSEC_GSS context has expired.
14360 +- * We cannot recover this stateid now, so
14361 +- * skip it and allow recovery thread to
14362 +- * proceed.
14363 +- */
14364 +- err = 0;
14365 +- goto out;
14366 + case -ENOMEM:
14367 + case -NFS4ERR_DENIED:
14368 + /* kill_proc(fl->fl_pid, SIGLOST, 1); */
14369 +diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
14370 +index 7f0fcfc1fe9d..e46579471ccc 100644
14371 +--- a/fs/nfs/nfs4state.c
14372 ++++ b/fs/nfs/nfs4state.c
14373 +@@ -1298,14 +1298,6 @@ restart:
14374 + /* Mark the file as being 'closed' */
14375 + state->state = 0;
14376 + break;
14377 +- case -EKEYEXPIRED:
14378 +- /*
14379 +- * User RPCSEC_GSS context has expired.
14380 +- * We cannot recover this stateid now, so
14381 +- * skip it and allow recovery thread to
14382 +- * proceed.
14383 +- */
14384 +- break;
14385 + case -NFS4ERR_ADMIN_REVOKED:
14386 + case -NFS4ERR_STALE_STATEID:
14387 + case -NFS4ERR_BAD_STATEID:
14388 +@@ -1458,14 +1450,6 @@ static void nfs4_state_start_reclaim_nograce(struct nfs_client *clp)
14389 + nfs4_state_mark_reclaim_helper(clp, nfs4_state_mark_reclaim_nograce);
14390 + }
14391 +
14392 +-static void nfs4_warn_keyexpired(const char *s)
14393 +-{
14394 +- printk_ratelimited(KERN_WARNING "Error: state manager"
14395 +- " encountered RPCSEC_GSS session"
14396 +- " expired against NFSv4 server %s.\n",
14397 +- s);
14398 +-}
14399 +-
14400 + static int nfs4_recovery_handle_error(struct nfs_client *clp, int error)
14401 + {
14402 + switch (error) {
14403 +@@ -1497,10 +1481,6 @@ static int nfs4_recovery_handle_error(struct nfs_client *clp, int error)
14404 + set_bit(NFS4CLNT_SESSION_RESET, &clp->cl_state);
14405 + /* Zero session reset errors */
14406 + break;
14407 +- case -EKEYEXPIRED:
14408 +- /* Nothing we can do */
14409 +- nfs4_warn_keyexpired(clp->cl_hostname);
14410 +- break;
14411 + default:
14412 + return error;
14413 + }
14414 +@@ -1745,7 +1725,6 @@ static void nfs4_set_lease_expired(struct nfs_client *clp, int status)
14415 + break;
14416 +
14417 + case -EKEYEXPIRED:
14418 +- nfs4_warn_keyexpired(clp->cl_hostname);
14419 + case -NFS4ERR_NOT_SAME: /* FixMe: implement recovery
14420 + * in nfs4_exchange_id */
14421 + default:
14422 +diff --git a/fs/nfs/proc.c b/fs/nfs/proc.c
14423 +index b63b6f4d14fb..af9947e35fcb 100644
14424 +--- a/fs/nfs/proc.c
14425 ++++ b/fs/nfs/proc.c
14426 +@@ -47,39 +47,6 @@
14427 + #define NFSDBG_FACILITY NFSDBG_PROC
14428 +
14429 + /*
14430 +- * wrapper to handle the -EKEYEXPIRED error message. This should generally
14431 +- * only happen if using krb5 auth and a user's TGT expires. NFSv2 doesn't
14432 +- * support the NFSERR_JUKEBOX error code, but we handle this situation in the
14433 +- * same way that we handle that error with NFSv3.
14434 +- */
14435 +-static int
14436 +-nfs_rpc_wrapper(struct rpc_clnt *clnt, struct rpc_message *msg, int flags)
14437 +-{
14438 +- int res;
14439 +- do {
14440 +- res = rpc_call_sync(clnt, msg, flags);
14441 +- if (res != -EKEYEXPIRED)
14442 +- break;
14443 +- freezable_schedule_timeout_killable(NFS_JUKEBOX_RETRY_TIME);
14444 +- res = -ERESTARTSYS;
14445 +- } while (!fatal_signal_pending(current));
14446 +- return res;
14447 +-}
14448 +-
14449 +-#define rpc_call_sync(clnt, msg, flags) nfs_rpc_wrapper(clnt, msg, flags)
14450 +-
14451 +-static int
14452 +-nfs_async_handle_expired_key(struct rpc_task *task)
14453 +-{
14454 +- if (task->tk_status != -EKEYEXPIRED)
14455 +- return 0;
14456 +- task->tk_status = 0;
14457 +- rpc_restart_call(task);
14458 +- rpc_delay(task, NFS_JUKEBOX_RETRY_TIME);
14459 +- return 1;
14460 +-}
14461 +-
14462 +-/*
14463 + * Bare-bones access to getattr: this is for nfs_read_super.
14464 + */
14465 + static int
14466 +@@ -365,8 +332,6 @@ static void nfs_proc_unlink_rpc_prepare(struct rpc_task *task, struct nfs_unlink
14467 +
14468 + static int nfs_proc_unlink_done(struct rpc_task *task, struct inode *dir)
14469 + {
14470 +- if (nfs_async_handle_expired_key(task))
14471 +- return 0;
14472 + nfs_mark_for_revalidate(dir);
14473 + return 1;
14474 + }
14475 +@@ -386,8 +351,6 @@ static int
14476 + nfs_proc_rename_done(struct rpc_task *task, struct inode *old_dir,
14477 + struct inode *new_dir)
14478 + {
14479 +- if (nfs_async_handle_expired_key(task))
14480 +- return 0;
14481 + nfs_mark_for_revalidate(old_dir);
14482 + nfs_mark_for_revalidate(new_dir);
14483 + return 1;
14484 +@@ -641,9 +604,6 @@ nfs_proc_pathconf(struct nfs_server *server, struct nfs_fh *fhandle,
14485 +
14486 + static int nfs_read_done(struct rpc_task *task, struct nfs_read_data *data)
14487 + {
14488 +- if (nfs_async_handle_expired_key(task))
14489 +- return -EAGAIN;
14490 +-
14491 + nfs_invalidate_atime(data->inode);
14492 + if (task->tk_status >= 0) {
14493 + nfs_refresh_inode(data->inode, data->res.fattr);
14494 +@@ -668,9 +628,6 @@ static void nfs_proc_read_rpc_prepare(struct rpc_task *task, struct nfs_read_dat
14495 +
14496 + static int nfs_write_done(struct rpc_task *task, struct nfs_write_data *data)
14497 + {
14498 +- if (nfs_async_handle_expired_key(task))
14499 +- return -EAGAIN;
14500 +-
14501 + if (task->tk_status >= 0)
14502 + nfs_post_op_update_inode_force_wcc(data->inode, data->res.fattr);
14503 + return 0;
14504 +diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
14505 +index f03160106b95..026a873e3f6c 100644
14506 +--- a/fs/nfsd/vfs.c
14507 ++++ b/fs/nfsd/vfs.c
14508 +@@ -297,41 +297,12 @@ commit_metadata(struct svc_fh *fhp)
14509 + }
14510 +
14511 + /*
14512 +- * Set various file attributes.
14513 +- * N.B. After this call fhp needs an fh_put
14514 ++ * Go over the attributes and take care of the small differences between
14515 ++ * NFS semantics and what Linux expects.
14516 + */
14517 +-__be32
14518 +-nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap,
14519 +- int check_guard, time_t guardtime)
14520 ++static void
14521 ++nfsd_sanitize_attrs(struct inode *inode, struct iattr *iap)
14522 + {
14523 +- struct dentry *dentry;
14524 +- struct inode *inode;
14525 +- int accmode = NFSD_MAY_SATTR;
14526 +- umode_t ftype = 0;
14527 +- __be32 err;
14528 +- int host_err;
14529 +- int size_change = 0;
14530 +-
14531 +- if (iap->ia_valid & (ATTR_ATIME | ATTR_MTIME | ATTR_SIZE))
14532 +- accmode |= NFSD_MAY_WRITE|NFSD_MAY_OWNER_OVERRIDE;
14533 +- if (iap->ia_valid & ATTR_SIZE)
14534 +- ftype = S_IFREG;
14535 +-
14536 +- /* Get inode */
14537 +- err = fh_verify(rqstp, fhp, ftype, accmode);
14538 +- if (err)
14539 +- goto out;
14540 +-
14541 +- dentry = fhp->fh_dentry;
14542 +- inode = dentry->d_inode;
14543 +-
14544 +- /* Ignore any mode updates on symlinks */
14545 +- if (S_ISLNK(inode->i_mode))
14546 +- iap->ia_valid &= ~ATTR_MODE;
14547 +-
14548 +- if (!iap->ia_valid)
14549 +- goto out;
14550 +-
14551 + /*
14552 + * NFSv2 does not differentiate between "set-[ac]time-to-now"
14553 + * which only requires access, and "set-[ac]time-to-X" which
14554 +@@ -341,8 +312,7 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap,
14555 + * convert to "set to now" instead of "set to explicit time"
14556 + *
14557 + * We only call inode_change_ok as the last test as technically
14558 +- * it is not an interface that we should be using. It is only
14559 +- * valid if the filesystem does not define it's own i_op->setattr.
14560 ++ * it is not an interface that we should be using.
14561 + */
14562 + #define BOTH_TIME_SET (ATTR_ATIME_SET | ATTR_MTIME_SET)
14563 + #define MAX_TOUCH_TIME_ERROR (30*60)
14564 +@@ -368,30 +338,6 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap,
14565 + iap->ia_valid &= ~BOTH_TIME_SET;
14566 + }
14567 + }
14568 +-
14569 +- /*
14570 +- * The size case is special.
14571 +- * It changes the file as well as the attributes.
14572 +- */
14573 +- if (iap->ia_valid & ATTR_SIZE) {
14574 +- if (iap->ia_size < inode->i_size) {
14575 +- err = nfsd_permission(rqstp, fhp->fh_export, dentry,
14576 +- NFSD_MAY_TRUNC|NFSD_MAY_OWNER_OVERRIDE);
14577 +- if (err)
14578 +- goto out;
14579 +- }
14580 +-
14581 +- host_err = get_write_access(inode);
14582 +- if (host_err)
14583 +- goto out_nfserr;
14584 +-
14585 +- size_change = 1;
14586 +- host_err = locks_verify_truncate(inode, NULL, iap->ia_size);
14587 +- if (host_err) {
14588 +- put_write_access(inode);
14589 +- goto out_nfserr;
14590 +- }
14591 +- }
14592 +
14593 + /* sanitize the mode change */
14594 + if (iap->ia_valid & ATTR_MODE) {
14595 +@@ -414,32 +360,111 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap,
14596 + iap->ia_valid |= (ATTR_KILL_SUID | ATTR_KILL_SGID);
14597 + }
14598 + }
14599 ++}
14600 +
14601 +- /* Change the attributes. */
14602 ++static __be32
14603 ++nfsd_get_write_access(struct svc_rqst *rqstp, struct svc_fh *fhp,
14604 ++ struct iattr *iap)
14605 ++{
14606 ++ struct inode *inode = fhp->fh_dentry->d_inode;
14607 ++ int host_err;
14608 +
14609 +- iap->ia_valid |= ATTR_CTIME;
14610 ++ if (iap->ia_size < inode->i_size) {
14611 ++ __be32 err;
14612 +
14613 +- err = nfserr_notsync;
14614 +- if (!check_guard || guardtime == inode->i_ctime.tv_sec) {
14615 +- host_err = nfsd_break_lease(inode);
14616 +- if (host_err)
14617 +- goto out_nfserr;
14618 +- fh_lock(fhp);
14619 ++ err = nfsd_permission(rqstp, fhp->fh_export, fhp->fh_dentry,
14620 ++ NFSD_MAY_TRUNC | NFSD_MAY_OWNER_OVERRIDE);
14621 ++ if (err)
14622 ++ return err;
14623 ++ }
14624 +
14625 +- host_err = notify_change(dentry, iap);
14626 +- err = nfserrno(host_err);
14627 +- fh_unlock(fhp);
14628 ++ host_err = get_write_access(inode);
14629 ++ if (host_err)
14630 ++ goto out_nfserrno;
14631 ++
14632 ++ host_err = locks_verify_truncate(inode, NULL, iap->ia_size);
14633 ++ if (host_err)
14634 ++ goto out_put_write_access;
14635 ++ return 0;
14636 ++
14637 ++out_put_write_access:
14638 ++ put_write_access(inode);
14639 ++out_nfserrno:
14640 ++ return nfserrno(host_err);
14641 ++}
14642 ++
14643 ++/*
14644 ++ * Set various file attributes. After this call fhp needs an fh_put.
14645 ++ */
14646 ++__be32
14647 ++nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap,
14648 ++ int check_guard, time_t guardtime)
14649 ++{
14650 ++ struct dentry *dentry;
14651 ++ struct inode *inode;
14652 ++ int accmode = NFSD_MAY_SATTR;
14653 ++ umode_t ftype = 0;
14654 ++ __be32 err;
14655 ++ int host_err;
14656 ++ int size_change = 0;
14657 ++
14658 ++ if (iap->ia_valid & (ATTR_ATIME | ATTR_MTIME | ATTR_SIZE))
14659 ++ accmode |= NFSD_MAY_WRITE|NFSD_MAY_OWNER_OVERRIDE;
14660 ++ if (iap->ia_valid & ATTR_SIZE)
14661 ++ ftype = S_IFREG;
14662 ++
14663 ++ /* Get inode */
14664 ++ err = fh_verify(rqstp, fhp, ftype, accmode);
14665 ++ if (err)
14666 ++ goto out;
14667 ++
14668 ++ dentry = fhp->fh_dentry;
14669 ++ inode = dentry->d_inode;
14670 ++
14671 ++ /* Ignore any mode updates on symlinks */
14672 ++ if (S_ISLNK(inode->i_mode))
14673 ++ iap->ia_valid &= ~ATTR_MODE;
14674 ++
14675 ++ if (!iap->ia_valid)
14676 ++ goto out;
14677 ++
14678 ++ nfsd_sanitize_attrs(inode, iap);
14679 ++
14680 ++ /*
14681 ++ * The size case is special, it changes the file in addition to the
14682 ++ * attributes.
14683 ++ */
14684 ++ if (iap->ia_valid & ATTR_SIZE) {
14685 ++ err = nfsd_get_write_access(rqstp, fhp, iap);
14686 ++ if (err)
14687 ++ goto out;
14688 ++ size_change = 1;
14689 + }
14690 ++
14691 ++ iap->ia_valid |= ATTR_CTIME;
14692 ++
14693 ++ if (check_guard && guardtime != inode->i_ctime.tv_sec) {
14694 ++ err = nfserr_notsync;
14695 ++ goto out_put_write_access;
14696 ++ }
14697 ++
14698 ++ host_err = nfsd_break_lease(inode);
14699 ++ if (host_err)
14700 ++ goto out_put_write_access_nfserror;
14701 ++
14702 ++ fh_lock(fhp);
14703 ++ host_err = notify_change(dentry, iap);
14704 ++ fh_unlock(fhp);
14705 ++
14706 ++out_put_write_access_nfserror:
14707 ++ err = nfserrno(host_err);
14708 ++out_put_write_access:
14709 + if (size_change)
14710 + put_write_access(inode);
14711 + if (!err)
14712 + commit_metadata(fhp);
14713 + out:
14714 + return err;
14715 +-
14716 +-out_nfserr:
14717 +- err = nfserrno(host_err);
14718 +- goto out;
14719 + }
14720 +
14721 + #if defined(CONFIG_NFSD_V2_ACL) || \
14722 +diff --git a/fs/proc/inode.c b/fs/proc/inode.c
14723 +index 205c92280838..6c61f119f608 100644
14724 +--- a/fs/proc/inode.c
14725 ++++ b/fs/proc/inode.c
14726 +@@ -443,12 +443,10 @@ static const struct file_operations proc_reg_file_ops_no_compat = {
14727 +
14728 + struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
14729 + {
14730 +- struct inode * inode;
14731 ++ struct inode *inode = new_inode_pseudo(sb);
14732 +
14733 +- inode = iget_locked(sb, de->low_ino);
14734 +- if (!inode)
14735 +- return NULL;
14736 +- if (inode->i_state & I_NEW) {
14737 ++ if (inode) {
14738 ++ inode->i_ino = de->low_ino;
14739 + inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
14740 + PROC_I(inode)->fd = 0;
14741 + PROC_I(inode)->pde = de;
14742 +@@ -477,9 +475,7 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
14743 + inode->i_fop = de->proc_fops;
14744 + }
14745 + }
14746 +- unlock_new_inode(inode);
14747 +- } else
14748 +- pde_put(de);
14749 ++ }
14750 + return inode;
14751 + }
14752 +
14753 +diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
14754 +index 5bab59b1034e..424b381c96f1 100644
14755 +--- a/include/linux/binfmts.h
14756 ++++ b/include/linux/binfmts.h
14757 +@@ -113,9 +113,6 @@ extern void setup_new_exec(struct linux_binprm * bprm);
14758 + extern void would_dump(struct linux_binprm *, struct file *);
14759 +
14760 + extern int suid_dumpable;
14761 +-#define SUID_DUMP_DISABLE 0 /* No setuid dumping */
14762 +-#define SUID_DUMP_USER 1 /* Dump as user of process */
14763 +-#define SUID_DUMP_ROOT 2 /* Dump as root */
14764 +
14765 + /* Stack area protections */
14766 + #define EXSTACK_DEFAULT 0 /* Whatever the arch defaults to */
14767 +diff --git a/include/linux/fs.h b/include/linux/fs.h
14768 +index 25c40b9f848a..210c347425e8 100644
14769 +--- a/include/linux/fs.h
14770 ++++ b/include/linux/fs.h
14771 +@@ -915,9 +915,11 @@ static inline loff_t i_size_read(const struct inode *inode)
14772 + static inline void i_size_write(struct inode *inode, loff_t i_size)
14773 + {
14774 + #if BITS_PER_LONG==32 && defined(CONFIG_SMP)
14775 ++ preempt_disable();
14776 + write_seqcount_begin(&inode->i_size_seqcount);
14777 + inode->i_size = i_size;
14778 + write_seqcount_end(&inode->i_size_seqcount);
14779 ++ preempt_enable();
14780 + #elif BITS_PER_LONG==32 && defined(CONFIG_PREEMPT)
14781 + preempt_disable();
14782 + inode->i_size = i_size;
14783 +diff --git a/include/linux/sched.h b/include/linux/sched.h
14784 +index 3dd0efbb70f2..e132a2d24740 100644
14785 +--- a/include/linux/sched.h
14786 ++++ b/include/linux/sched.h
14787 +@@ -404,6 +404,10 @@ static inline void arch_pick_mmap_layout(struct mm_struct *mm) {}
14788 + extern void set_dumpable(struct mm_struct *mm, int value);
14789 + extern int get_dumpable(struct mm_struct *mm);
14790 +
14791 ++#define SUID_DUMP_DISABLE 0 /* No setuid dumping */
14792 ++#define SUID_DUMP_USER 1 /* Dump as user of process */
14793 ++#define SUID_DUMP_ROOT 2 /* Dump as root */
14794 ++
14795 + /* mm flags */
14796 + /* dumpable bits */
14797 + #define MMF_DUMPABLE 0 /* core dump is permitted */
14798 +@@ -2466,27 +2470,18 @@ static inline void threadgroup_change_end(struct task_struct *tsk)
14799 + *
14800 + * Lock the threadgroup @tsk belongs to. No new task is allowed to enter
14801 + * and member tasks aren't allowed to exit (as indicated by PF_EXITING) or
14802 +- * perform exec. This is useful for cases where the threadgroup needs to
14803 +- * stay stable across blockable operations.
14804 ++ * change ->group_leader/pid. This is useful for cases where the threadgroup
14805 ++ * needs to stay stable across blockable operations.
14806 + *
14807 + * fork and exit paths explicitly call threadgroup_change_{begin|end}() for
14808 + * synchronization. While held, no new task will be added to threadgroup
14809 + * and no existing live task will have its PF_EXITING set.
14810 + *
14811 +- * During exec, a task goes and puts its thread group through unusual
14812 +- * changes. After de-threading, exclusive access is assumed to resources
14813 +- * which are usually shared by tasks in the same group - e.g. sighand may
14814 +- * be replaced with a new one. Also, the exec'ing task takes over group
14815 +- * leader role including its pid. Exclude these changes while locked by
14816 +- * grabbing cred_guard_mutex which is used to synchronize exec path.
14817 ++ * de_thread() does threadgroup_change_{begin|end}() when a non-leader
14818 ++ * sub-thread becomes a new leader.
14819 + */
14820 + static inline void threadgroup_lock(struct task_struct *tsk)
14821 + {
14822 +- /*
14823 +- * exec uses exit for de-threading nesting group_rwsem inside
14824 +- * cred_guard_mutex. Grab cred_guard_mutex first.
14825 +- */
14826 +- mutex_lock(&tsk->signal->cred_guard_mutex);
14827 + down_write(&tsk->signal->group_rwsem);
14828 + }
14829 +
14830 +@@ -2499,7 +2494,6 @@ static inline void threadgroup_lock(struct task_struct *tsk)
14831 + static inline void threadgroup_unlock(struct task_struct *tsk)
14832 + {
14833 + up_write(&tsk->signal->group_rwsem);
14834 +- mutex_unlock(&tsk->signal->cred_guard_mutex);
14835 + }
14836 + #else
14837 + static inline void threadgroup_change_begin(struct task_struct *tsk) {}
14838 +diff --git a/kernel/ptrace.c b/kernel/ptrace.c
14839 +index daf4394d1aba..a1432369be50 100644
14840 +--- a/kernel/ptrace.c
14841 ++++ b/kernel/ptrace.c
14842 +@@ -254,7 +254,8 @@ ok:
14843 + smp_rmb();
14844 + if (task->mm)
14845 + dumpable = get_dumpable(task->mm);
14846 +- if (!dumpable && !ptrace_has_cap(task_user_ns(task), mode))
14847 ++ if (dumpable != SUID_DUMP_USER &&
14848 ++ !ptrace_has_cap(task_user_ns(task), mode))
14849 + return -EPERM;
14850 +
14851 + return security_ptrace_access_check(task, mode);
14852 +diff --git a/kernel/trace/trace_event_perf.c b/kernel/trace/trace_event_perf.c
14853 +index fee3752ae8f6..d01adb77449c 100644
14854 +--- a/kernel/trace/trace_event_perf.c
14855 ++++ b/kernel/trace/trace_event_perf.c
14856 +@@ -26,7 +26,7 @@ static int perf_trace_event_perm(struct ftrace_event_call *tp_event,
14857 + {
14858 + /* The ftrace function trace is allowed only for root. */
14859 + if (ftrace_event_is_function(tp_event) &&
14860 +- perf_paranoid_kernel() && !capable(CAP_SYS_ADMIN))
14861 ++ perf_paranoid_tracepoint_raw() && !capable(CAP_SYS_ADMIN))
14862 + return -EPERM;
14863 +
14864 + /* No tracing, just counting, so no obvious leak */
14865 +diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
14866 +index a28a2111297e..f21486a2ac48 100644
14867 +--- a/net/sunrpc/clnt.c
14868 ++++ b/net/sunrpc/clnt.c
14869 +@@ -1338,6 +1338,7 @@ call_refreshresult(struct rpc_task *task)
14870 + rpc_delay(task, 3*HZ);
14871 + case -EAGAIN:
14872 + status = -EACCES;
14873 ++ case -EKEYEXPIRED:
14874 + if (!task->tk_cred_retry)
14875 + break;
14876 + task->tk_cred_retry--;
14877 +diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
14878 +index 79064471cd01..31f981d700a3 100644
14879 +--- a/net/sunrpc/xprtsock.c
14880 ++++ b/net/sunrpc/xprtsock.c
14881 +@@ -390,8 +390,10 @@ static int xs_send_kvec(struct socket *sock, struct sockaddr *addr, int addrlen,
14882 + return kernel_sendmsg(sock, &msg, NULL, 0, 0);
14883 + }
14884 +
14885 +-static int xs_send_pagedata(struct socket *sock, struct xdr_buf *xdr, unsigned int base, int more)
14886 ++static int xs_send_pagedata(struct socket *sock, struct xdr_buf *xdr, unsigned int base, int more, bool zerocopy)
14887 + {
14888 ++ ssize_t (*do_sendpage)(struct socket *sock, struct page *page,
14889 ++ int offset, size_t size, int flags);
14890 + struct page **ppage;
14891 + unsigned int remainder;
14892 + int err, sent = 0;
14893 +@@ -400,6 +402,9 @@ static int xs_send_pagedata(struct socket *sock, struct xdr_buf *xdr, unsigned i
14894 + base += xdr->page_base;
14895 + ppage = xdr->pages + (base >> PAGE_SHIFT);
14896 + base &= ~PAGE_MASK;
14897 ++ do_sendpage = sock->ops->sendpage;
14898 ++ if (!zerocopy)
14899 ++ do_sendpage = sock_no_sendpage;
14900 + for(;;) {
14901 + unsigned int len = min_t(unsigned int, PAGE_SIZE - base, remainder);
14902 + int flags = XS_SENDMSG_FLAGS;
14903 +@@ -407,7 +412,7 @@ static int xs_send_pagedata(struct socket *sock, struct xdr_buf *xdr, unsigned i
14904 + remainder -= len;
14905 + if (remainder != 0 || more)
14906 + flags |= MSG_MORE;
14907 +- err = sock->ops->sendpage(sock, *ppage, base, len, flags);
14908 ++ err = do_sendpage(sock, *ppage, base, len, flags);
14909 + if (remainder == 0 || err != len)
14910 + break;
14911 + sent += err;
14912 +@@ -428,9 +433,10 @@ static int xs_send_pagedata(struct socket *sock, struct xdr_buf *xdr, unsigned i
14913 + * @addrlen: UDP only -- length of destination address
14914 + * @xdr: buffer containing this request
14915 + * @base: starting position in the buffer
14916 ++ * @zerocopy: true if it is safe to use sendpage()
14917 + *
14918 + */
14919 +-static int xs_sendpages(struct socket *sock, struct sockaddr *addr, int addrlen, struct xdr_buf *xdr, unsigned int base)
14920 ++static int xs_sendpages(struct socket *sock, struct sockaddr *addr, int addrlen, struct xdr_buf *xdr, unsigned int base, bool zerocopy)
14921 + {
14922 + unsigned int remainder = xdr->len - base;
14923 + int err, sent = 0;
14924 +@@ -458,7 +464,7 @@ static int xs_sendpages(struct socket *sock, struct sockaddr *addr, int addrlen,
14925 + if (base < xdr->page_len) {
14926 + unsigned int len = xdr->page_len - base;
14927 + remainder -= len;
14928 +- err = xs_send_pagedata(sock, xdr, base, remainder != 0);
14929 ++ err = xs_send_pagedata(sock, xdr, base, remainder != 0, zerocopy);
14930 + if (remainder == 0 || err != len)
14931 + goto out;
14932 + sent += err;
14933 +@@ -561,7 +567,7 @@ static int xs_local_send_request(struct rpc_task *task)
14934 + req->rq_svec->iov_base, req->rq_svec->iov_len);
14935 +
14936 + status = xs_sendpages(transport->sock, NULL, 0,
14937 +- xdr, req->rq_bytes_sent);
14938 ++ xdr, req->rq_bytes_sent, true);
14939 + dprintk("RPC: %s(%u) = %d\n",
14940 + __func__, xdr->len - req->rq_bytes_sent, status);
14941 + if (likely(status >= 0)) {
14942 +@@ -617,7 +623,7 @@ static int xs_udp_send_request(struct rpc_task *task)
14943 + status = xs_sendpages(transport->sock,
14944 + xs_addr(xprt),
14945 + xprt->addrlen, xdr,
14946 +- req->rq_bytes_sent);
14947 ++ req->rq_bytes_sent, true);
14948 +
14949 + dprintk("RPC: xs_udp_send_request(%u) = %d\n",
14950 + xdr->len - req->rq_bytes_sent, status);
14951 +@@ -688,6 +694,7 @@ static int xs_tcp_send_request(struct rpc_task *task)
14952 + struct rpc_xprt *xprt = req->rq_xprt;
14953 + struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt);
14954 + struct xdr_buf *xdr = &req->rq_snd_buf;
14955 ++ bool zerocopy = true;
14956 + int status;
14957 +
14958 + xs_encode_stream_record_marker(&req->rq_snd_buf);
14959 +@@ -695,13 +702,20 @@ static int xs_tcp_send_request(struct rpc_task *task)
14960 + xs_pktdump("packet data:",
14961 + req->rq_svec->iov_base,
14962 + req->rq_svec->iov_len);
14963 ++ /* Don't use zero copy if this is a resend. If the RPC call
14964 ++ * completes while the socket holds a reference to the pages,
14965 ++ * then we may end up resending corrupted data.
14966 ++ */
14967 ++ if (task->tk_flags & RPC_TASK_SENT)
14968 ++ zerocopy = false;
14969 +
14970 + /* Continue transmitting the packet/record. We must be careful
14971 + * to cope with writespace callbacks arriving _after_ we have
14972 + * called sendmsg(). */
14973 + while (1) {
14974 + status = xs_sendpages(transport->sock,
14975 +- NULL, 0, xdr, req->rq_bytes_sent);
14976 ++ NULL, 0, xdr, req->rq_bytes_sent,
14977 ++ zerocopy);
14978 +
14979 + dprintk("RPC: xs_tcp_send_request(%u) = %d\n",
14980 + xdr->len - req->rq_bytes_sent, status);
14981 +diff --git a/security/integrity/ima/ima_policy.c b/security/integrity/ima/ima_policy.c
14982 +index d8edff209bf3..d6aab27c8584 100644
14983 +--- a/security/integrity/ima/ima_policy.c
14984 ++++ b/security/integrity/ima/ima_policy.c
14985 +@@ -62,7 +62,6 @@ static struct ima_measure_rule_entry default_rules[] = {
14986 + {.action = DONT_MEASURE,.fsmagic = SYSFS_MAGIC,.flags = IMA_FSMAGIC},
14987 + {.action = DONT_MEASURE,.fsmagic = DEBUGFS_MAGIC,.flags = IMA_FSMAGIC},
14988 + {.action = DONT_MEASURE,.fsmagic = TMPFS_MAGIC,.flags = IMA_FSMAGIC},
14989 +- {.action = DONT_MEASURE,.fsmagic = RAMFS_MAGIC,.flags = IMA_FSMAGIC},
14990 + {.action = DONT_MEASURE,.fsmagic = SECURITYFS_MAGIC,.flags = IMA_FSMAGIC},
14991 + {.action = DONT_MEASURE,.fsmagic = SELINUX_MAGIC,.flags = IMA_FSMAGIC},
14992 + {.action = MEASURE,.func = FILE_MMAP,.mask = MAY_EXEC,
14993 +diff --git a/sound/isa/msnd/msnd_pinnacle.c b/sound/isa/msnd/msnd_pinnacle.c
14994 +index 29cc8e162b02..a7d6a52a4f81 100644
14995 +--- a/sound/isa/msnd/msnd_pinnacle.c
14996 ++++ b/sound/isa/msnd/msnd_pinnacle.c
14997 +@@ -73,9 +73,11 @@
14998 + #ifdef MSND_CLASSIC
14999 + # include "msnd_classic.h"
15000 + # define LOGNAME "msnd_classic"
15001 ++# define DEV_NAME "msnd-classic"
15002 + #else
15003 + # include "msnd_pinnacle.h"
15004 + # define LOGNAME "snd_msnd_pinnacle"
15005 ++# define DEV_NAME "msnd-pinnacle"
15006 + #endif
15007 +
15008 + static void __devinit set_default_audio_parameters(struct snd_msnd *chip)
15009 +@@ -1068,8 +1070,6 @@ static int __devexit snd_msnd_isa_remove(struct device *pdev, unsigned int dev)
15010 + return 0;
15011 + }
15012 +
15013 +-#define DEV_NAME "msnd-pinnacle"
15014 +-
15015 + static struct isa_driver snd_msnd_driver = {
15016 + .match = snd_msnd_isa_match,
15017 + .probe = snd_msnd_isa_probe,
15018 +diff --git a/sound/usb/6fire/chip.c b/sound/usb/6fire/chip.c
15019 +index fc8cc823e438..f8033485db93 100644
15020 +--- a/sound/usb/6fire/chip.c
15021 ++++ b/sound/usb/6fire/chip.c
15022 +@@ -101,7 +101,7 @@ static int __devinit usb6fire_chip_probe(struct usb_interface *intf,
15023 + usb_set_intfdata(intf, chips[i]);
15024 + mutex_unlock(&register_mutex);
15025 + return 0;
15026 +- } else if (regidx < 0)
15027 ++ } else if (!devices[i] && regidx < 0)
15028 + regidx = i;
15029 + }
15030 + if (regidx < 0) {