Gentoo Archives: gentoo-commits

From: "Mike Pagano (mpagano)" <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] linux-patches r2149 - genpatches-2.6/trunk/3.3
Date: Wed, 06 Jun 2012 00:39:39
Message-Id: 20120606003916.C41252004B@flycatcher.gentoo.org
1 Author: mpagano
2 Date: 2012-06-06 00:39:15 +0000 (Wed, 06 Jun 2012)
3 New Revision: 2149
4
5 Added:
6 genpatches-2.6/trunk/3.3/1007_linux-3.3.8.patch
7 Modified:
8 genpatches-2.6/trunk/3.3/0000_README
9 Log:
10 Linux patch 3.3.8
11
12 Modified: genpatches-2.6/trunk/3.3/0000_README
13 ===================================================================
14 --- genpatches-2.6/trunk/3.3/0000_README 2012-06-04 22:58:55 UTC (rev 2148)
15 +++ genpatches-2.6/trunk/3.3/0000_README 2012-06-06 00:39:15 UTC (rev 2149)
16 @@ -68,6 +68,10 @@
17 From: http://www.kernel.org
18 Desc: Linux 3.3.7
19
20 +Patch: 1007_linux-3.3.8.patch
21 +From: http://www.kernel.org
22 +Desc: Linux 3.3.8
23 +
24 Patch: 1700_tsunami-modpost-include-fix.patch
25 From: https://bugs.gentoo.org/show_bug.cgi?id=415033
26 Desc: Patch to include module.h to fix modpost on Tsunami
27
28 Added: genpatches-2.6/trunk/3.3/1007_linux-3.3.8.patch
29 ===================================================================
30 --- genpatches-2.6/trunk/3.3/1007_linux-3.3.8.patch (rev 0)
31 +++ genpatches-2.6/trunk/3.3/1007_linux-3.3.8.patch 2012-06-06 00:39:15 UTC (rev 2149)
32 @@ -0,0 +1,4573 @@
33 +diff --git a/Documentation/HOWTO b/Documentation/HOWTO
34 +index f7ade3b..59c080f 100644
35 +--- a/Documentation/HOWTO
36 ++++ b/Documentation/HOWTO
37 +@@ -218,16 +218,16 @@ The development process
38 + Linux kernel development process currently consists of a few different
39 + main kernel "branches" and lots of different subsystem-specific kernel
40 + branches. These different branches are:
41 +- - main 2.6.x kernel tree
42 +- - 2.6.x.y -stable kernel tree
43 +- - 2.6.x -git kernel patches
44 ++ - main 3.x kernel tree
45 ++ - 3.x.y -stable kernel tree
46 ++ - 3.x -git kernel patches
47 + - subsystem specific kernel trees and patches
48 +- - the 2.6.x -next kernel tree for integration tests
49 ++ - the 3.x -next kernel tree for integration tests
50 +
51 +-2.6.x kernel tree
52 ++3.x kernel tree
53 + -----------------
54 +-2.6.x kernels are maintained by Linus Torvalds, and can be found on
55 +-kernel.org in the pub/linux/kernel/v2.6/ directory. Its development
56 ++3.x kernels are maintained by Linus Torvalds, and can be found on
57 ++kernel.org in the pub/linux/kernel/v3.x/ directory. Its development
58 + process is as follows:
59 + - As soon as a new kernel is released a two weeks window is open,
60 + during this period of time maintainers can submit big diffs to
61 +@@ -262,20 +262,20 @@ mailing list about kernel releases:
62 + released according to perceived bug status, not according to a
63 + preconceived timeline."
64 +
65 +-2.6.x.y -stable kernel tree
66 ++3.x.y -stable kernel tree
67 + ---------------------------
68 +-Kernels with 4-part versions are -stable kernels. They contain
69 ++Kernels with 3-part versions are -stable kernels. They contain
70 + relatively small and critical fixes for security problems or significant
71 +-regressions discovered in a given 2.6.x kernel.
72 ++regressions discovered in a given 3.x kernel.
73 +
74 + This is the recommended branch for users who want the most recent stable
75 + kernel and are not interested in helping test development/experimental
76 + versions.
77 +
78 +-If no 2.6.x.y kernel is available, then the highest numbered 2.6.x
79 ++If no 3.x.y kernel is available, then the highest numbered 3.x
80 + kernel is the current stable kernel.
81 +
82 +-2.6.x.y are maintained by the "stable" team <stable@×××××××××××.org>, and
83 ++3.x.y are maintained by the "stable" team <stable@×××××××××××.org>, and
84 + are released as needs dictate. The normal release period is approximately
85 + two weeks, but it can be longer if there are no pressing problems. A
86 + security-related problem, instead, can cause a release to happen almost
87 +@@ -285,7 +285,7 @@ The file Documentation/stable_kernel_rules.txt in the kernel tree
88 + documents what kinds of changes are acceptable for the -stable tree, and
89 + how the release process works.
90 +
91 +-2.6.x -git patches
92 ++3.x -git patches
93 + ------------------
94 + These are daily snapshots of Linus' kernel tree which are managed in a
95 + git repository (hence the name.) These patches are usually released
96 +@@ -317,13 +317,13 @@ revisions to it, and maintainers can mark patches as under review,
97 + accepted, or rejected. Most of these patchwork sites are listed at
98 + http://patchwork.kernel.org/.
99 +
100 +-2.6.x -next kernel tree for integration tests
101 ++3.x -next kernel tree for integration tests
102 + ---------------------------------------------
103 +-Before updates from subsystem trees are merged into the mainline 2.6.x
104 ++Before updates from subsystem trees are merged into the mainline 3.x
105 + tree, they need to be integration-tested. For this purpose, a special
106 + testing repository exists into which virtually all subsystem trees are
107 + pulled on an almost daily basis:
108 +- http://git.kernel.org/?p=linux/kernel/git/sfr/linux-next.git
109 ++ http://git.kernel.org/?p=linux/kernel/git/next/linux-next.git
110 + http://linux.f-seidel.de/linux-next/pmwiki/
111 +
112 + This way, the -next kernel gives a summary outlook onto what will be
113 +diff --git a/Makefile b/Makefile
114 +index 073f74f..db96149 100644
115 +--- a/Makefile
116 ++++ b/Makefile
117 +@@ -1,6 +1,6 @@
118 + VERSION = 3
119 + PATCHLEVEL = 3
120 +-SUBLEVEL = 7
121 ++SUBLEVEL = 8
122 + EXTRAVERSION =
123 + NAME = Saber-toothed Squirrel
124 +
125 +@@ -442,7 +442,7 @@ asm-generic:
126 +
127 + no-dot-config-targets := clean mrproper distclean \
128 + cscope gtags TAGS tags help %docs check% coccicheck \
129 +- include/linux/version.h headers_% archheaders \
130 ++ include/linux/version.h headers_% archheaders archscripts \
131 + kernelversion %src-pkg
132 +
133 + config-targets := 0
134 +@@ -979,7 +979,7 @@ prepare1: prepare2 include/linux/version.h include/generated/utsrelease.h \
135 + include/config/auto.conf
136 + $(cmd_crmodverdir)
137 +
138 +-archprepare: archheaders prepare1 scripts_basic
139 ++archprepare: archheaders archscripts prepare1 scripts_basic
140 +
141 + prepare0: archprepare FORCE
142 + $(Q)$(MAKE) $(build)=.
143 +@@ -1049,8 +1049,11 @@ hdr-dst = $(if $(KBUILD_HEADERS), dst=include/asm-$(hdr-arch), dst=include/asm)
144 + PHONY += archheaders
145 + archheaders:
146 +
147 ++PHONY += archscripts
148 ++archscripts:
149 ++
150 + PHONY += __headers
151 +-__headers: include/linux/version.h scripts_basic asm-generic archheaders FORCE
152 ++__headers: include/linux/version.h scripts_basic asm-generic archheaders archscripts FORCE
153 + $(Q)$(MAKE) $(build)=scripts build_unifdef
154 +
155 + PHONY += headers_install_all
156 +diff --git a/arch/arm/include/asm/cacheflush.h b/arch/arm/include/asm/cacheflush.h
157 +index d5d8d5c..1252a26 100644
158 +--- a/arch/arm/include/asm/cacheflush.h
159 ++++ b/arch/arm/include/asm/cacheflush.h
160 +@@ -249,7 +249,7 @@ extern void flush_cache_page(struct vm_area_struct *vma, unsigned long user_addr
161 + * Harvard caches are synchronised for the user space address range.
162 + * This is used for the ARM private sys_cacheflush system call.
163 + */
164 +-#define flush_cache_user_range(vma,start,end) \
165 ++#define flush_cache_user_range(start,end) \
166 + __cpuc_coherent_user_range((start) & PAGE_MASK, PAGE_ALIGN(end))
167 +
168 + /*
169 +diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
170 +index f84dfe6..504b28a 100644
171 +--- a/arch/arm/kernel/traps.c
172 ++++ b/arch/arm/kernel/traps.c
173 +@@ -491,7 +491,9 @@ do_cache_op(unsigned long start, unsigned long end, int flags)
174 + if (end > vma->vm_end)
175 + end = vma->vm_end;
176 +
177 +- flush_cache_user_range(vma, start, end);
178 ++ up_read(&mm->mmap_sem);
179 ++ flush_cache_user_range(start, end);
180 ++ return;
181 + }
182 + up_read(&mm->mmap_sem);
183 + }
184 +diff --git a/arch/parisc/include/asm/prefetch.h b/arch/parisc/include/asm/prefetch.h
185 +index c5edc60..1ee7c82 100644
186 +--- a/arch/parisc/include/asm/prefetch.h
187 ++++ b/arch/parisc/include/asm/prefetch.h
188 +@@ -21,7 +21,12 @@
189 + #define ARCH_HAS_PREFETCH
190 + static inline void prefetch(const void *addr)
191 + {
192 +- __asm__("ldw 0(%0), %%r0" : : "r" (addr));
193 ++ __asm__(
194 ++#ifndef CONFIG_PA20
195 ++ /* Need to avoid prefetch of NULL on PA7300LC */
196 ++ " extrw,u,= %0,31,32,%%r0\n"
197 ++#endif
198 ++ " ldw 0(%0), %%r0" : : "r" (addr));
199 + }
200 +
201 + /* LDD is a PA2.0 addition. */
202 +diff --git a/arch/parisc/kernel/entry.S b/arch/parisc/kernel/entry.S
203 +index 6f05944..5350342 100644
204 +--- a/arch/parisc/kernel/entry.S
205 ++++ b/arch/parisc/kernel/entry.S
206 +@@ -581,7 +581,11 @@
207 + */
208 + cmpiclr,= 0x01,\tmp,%r0
209 + ldi (_PAGE_DIRTY|_PAGE_READ|_PAGE_WRITE),\prot
210 ++#ifdef CONFIG_64BIT
211 + depd,z \prot,8,7,\prot
212 ++#else
213 ++ depw,z \prot,8,7,\prot
214 ++#endif
215 + /*
216 + * OK, it is in the temp alias region, check whether "from" or "to".
217 + * Check "subtle" note in pacache.S re: r23/r26.
218 +diff --git a/arch/parisc/kernel/pacache.S b/arch/parisc/kernel/pacache.S
219 +index 93ff3d9..5d7218a 100644
220 +--- a/arch/parisc/kernel/pacache.S
221 ++++ b/arch/parisc/kernel/pacache.S
222 +@@ -692,7 +692,7 @@ ENTRY(flush_icache_page_asm)
223 +
224 + /* Purge any old translation */
225 +
226 +- pitlb (%sr0,%r28)
227 ++ pitlb (%sr4,%r28)
228 +
229 + ldil L%icache_stride, %r1
230 + ldw R%icache_stride(%r1), %r1
231 +@@ -706,27 +706,29 @@ ENTRY(flush_icache_page_asm)
232 + sub %r25, %r1, %r25
233 +
234 +
235 +-1: fic,m %r1(%r28)
236 +- fic,m %r1(%r28)
237 +- fic,m %r1(%r28)
238 +- fic,m %r1(%r28)
239 +- fic,m %r1(%r28)
240 +- fic,m %r1(%r28)
241 +- fic,m %r1(%r28)
242 +- fic,m %r1(%r28)
243 +- fic,m %r1(%r28)
244 +- fic,m %r1(%r28)
245 +- fic,m %r1(%r28)
246 +- fic,m %r1(%r28)
247 +- fic,m %r1(%r28)
248 +- fic,m %r1(%r28)
249 +- fic,m %r1(%r28)
250 ++ /* fic only has the type 26 form on PA1.1, requiring an
251 ++ * explicit space specification, so use %sr4 */
252 ++1: fic,m %r1(%sr4,%r28)
253 ++ fic,m %r1(%sr4,%r28)
254 ++ fic,m %r1(%sr4,%r28)
255 ++ fic,m %r1(%sr4,%r28)
256 ++ fic,m %r1(%sr4,%r28)
257 ++ fic,m %r1(%sr4,%r28)
258 ++ fic,m %r1(%sr4,%r28)
259 ++ fic,m %r1(%sr4,%r28)
260 ++ fic,m %r1(%sr4,%r28)
261 ++ fic,m %r1(%sr4,%r28)
262 ++ fic,m %r1(%sr4,%r28)
263 ++ fic,m %r1(%sr4,%r28)
264 ++ fic,m %r1(%sr4,%r28)
265 ++ fic,m %r1(%sr4,%r28)
266 ++ fic,m %r1(%sr4,%r28)
267 + cmpb,COND(<<) %r28, %r25,1b
268 +- fic,m %r1(%r28)
269 ++ fic,m %r1(%sr4,%r28)
270 +
271 + sync
272 + bv %r0(%r2)
273 +- pitlb (%sr0,%r25)
274 ++ pitlb (%sr4,%r25)
275 + .exit
276 +
277 + .procend
278 +diff --git a/arch/powerpc/kernel/idle.c b/arch/powerpc/kernel/idle.c
279 +index 0a48bf5..b556964 100644
280 +--- a/arch/powerpc/kernel/idle.c
281 ++++ b/arch/powerpc/kernel/idle.c
282 +@@ -109,6 +109,9 @@ void cpu_idle(void)
283 + }
284 + }
285 +
286 ++static void do_nothing(void *unused)
287 ++{
288 ++}
289 +
290 + /*
291 + * cpu_idle_wait - Used to ensure that all the CPUs come out of the old
292 +@@ -119,16 +122,9 @@ void cpu_idle(void)
293 + */
294 + void cpu_idle_wait(void)
295 + {
296 +- int cpu;
297 + smp_mb();
298 +-
299 +- /* kick all the CPUs so that they exit out of old idle routine */
300 +- get_online_cpus();
301 +- for_each_online_cpu(cpu) {
302 +- if (cpu != smp_processor_id())
303 +- smp_send_reschedule(cpu);
304 +- }
305 +- put_online_cpus();
306 ++ /* kick all the CPUs so that they exit out of pm_idle */
307 ++ smp_call_function(do_nothing, NULL, 1);
308 + }
309 + EXPORT_SYMBOL_GPL(cpu_idle_wait);
310 +
311 +diff --git a/arch/s390/mm/fault.c b/arch/s390/mm/fault.c
312 +index e8fcd92..c6057f2 100644
313 +--- a/arch/s390/mm/fault.c
314 ++++ b/arch/s390/mm/fault.c
315 +@@ -574,6 +574,7 @@ static void pfault_interrupt(unsigned int ext_int_code,
316 + tsk->thread.pfault_wait = 0;
317 + list_del(&tsk->thread.list);
318 + wake_up_process(tsk);
319 ++ put_task_struct(tsk);
320 + } else {
321 + /* Completion interrupt was faster than initial
322 + * interrupt. Set pfault_wait to -1 so the initial
323 +@@ -588,14 +589,22 @@ static void pfault_interrupt(unsigned int ext_int_code,
324 + put_task_struct(tsk);
325 + } else {
326 + /* signal bit not set -> a real page is missing. */
327 +- if (tsk->thread.pfault_wait == -1) {
328 ++ if (tsk->thread.pfault_wait == 1) {
329 ++ /* Already on the list with a reference: put to sleep */
330 ++ set_task_state(tsk, TASK_UNINTERRUPTIBLE);
331 ++ set_tsk_need_resched(tsk);
332 ++ } else if (tsk->thread.pfault_wait == -1) {
333 + /* Completion interrupt was faster than the initial
334 + * interrupt (pfault_wait == -1). Set pfault_wait
335 + * back to zero and exit. */
336 + tsk->thread.pfault_wait = 0;
337 + } else {
338 + /* Initial interrupt arrived before completion
339 +- * interrupt. Let the task sleep. */
340 ++ * interrupt. Let the task sleep.
341 ++ * An extra task reference is needed since a different
342 ++ * cpu may set the task state to TASK_RUNNING again
343 ++ * before the scheduler is reached. */
344 ++ get_task_struct(tsk);
345 + tsk->thread.pfault_wait = 1;
346 + list_add(&tsk->thread.list, &pfault_list);
347 + set_task_state(tsk, TASK_UNINTERRUPTIBLE);
348 +@@ -620,6 +629,7 @@ static int __cpuinit pfault_cpu_notify(struct notifier_block *self,
349 + list_del(&thread->list);
350 + tsk = container_of(thread, struct task_struct, thread);
351 + wake_up_process(tsk);
352 ++ put_task_struct(tsk);
353 + }
354 + spin_unlock_irq(&pfault_lock);
355 + break;
356 +diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
357 +index ca5580e..312fd5f 100644
358 +--- a/arch/sparc/Kconfig
359 ++++ b/arch/sparc/Kconfig
360 +@@ -582,6 +582,9 @@ config SYSVIPC_COMPAT
361 + depends on COMPAT && SYSVIPC
362 + default y
363 +
364 ++config KEYS_COMPAT
365 ++ def_bool y if COMPAT && KEYS
366 ++
367 + endmenu
368 +
369 + source "net/Kconfig"
370 +diff --git a/arch/sparc/kernel/systbls_64.S b/arch/sparc/kernel/systbls_64.S
371 +index db86b1a..3a58e0d 100644
372 +--- a/arch/sparc/kernel/systbls_64.S
373 ++++ b/arch/sparc/kernel/systbls_64.S
374 +@@ -74,7 +74,7 @@ sys_call_table32:
375 + .word sys_timer_delete, compat_sys_timer_create, sys_ni_syscall, compat_sys_io_setup, sys_io_destroy
376 + /*270*/ .word sys32_io_submit, sys_io_cancel, compat_sys_io_getevents, sys32_mq_open, sys_mq_unlink
377 + .word compat_sys_mq_timedsend, compat_sys_mq_timedreceive, compat_sys_mq_notify, compat_sys_mq_getsetattr, compat_sys_waitid
378 +-/*280*/ .word sys32_tee, sys_add_key, sys_request_key, sys_keyctl, compat_sys_openat
379 ++/*280*/ .word sys32_tee, sys_add_key, sys_request_key, compat_sys_keyctl, compat_sys_openat
380 + .word sys_mkdirat, sys_mknodat, sys_fchownat, compat_sys_futimesat, compat_sys_fstatat64
381 + /*290*/ .word sys_unlinkat, sys_renameat, sys_linkat, sys_symlinkat, sys_readlinkat
382 + .word sys_fchmodat, sys_faccessat, compat_sys_pselect6, compat_sys_ppoll, sys_unshare
383 +diff --git a/arch/tile/Kconfig b/arch/tile/Kconfig
384 +index 11270ca..60e5be83 100644
385 +--- a/arch/tile/Kconfig
386 ++++ b/arch/tile/Kconfig
387 +@@ -11,6 +11,7 @@ config TILE
388 + select GENERIC_IRQ_PROBE
389 + select GENERIC_PENDING_IRQ if SMP
390 + select GENERIC_IRQ_SHOW
391 ++ select HAVE_SYSCALL_WRAPPERS if TILEGX
392 + select SYS_HYPERVISOR
393 + select ARCH_HAVE_NMI_SAFE_CMPXCHG if !M386
394 +
395 +diff --git a/arch/tile/include/asm/bitops.h b/arch/tile/include/asm/bitops.h
396 +index 16f1fa5..bd186c4 100644
397 +--- a/arch/tile/include/asm/bitops.h
398 ++++ b/arch/tile/include/asm/bitops.h
399 +@@ -77,6 +77,11 @@ static inline int ffs(int x)
400 + return __builtin_ffs(x);
401 + }
402 +
403 ++static inline int fls64(__u64 w)
404 ++{
405 ++ return (sizeof(__u64) * 8) - __builtin_clzll(w);
406 ++}
407 ++
408 + /**
409 + * fls - find last set bit in word
410 + * @x: the word to search
411 +@@ -90,12 +95,7 @@ static inline int ffs(int x)
412 + */
413 + static inline int fls(int x)
414 + {
415 +- return (sizeof(int) * 8) - __builtin_clz(x);
416 +-}
417 +-
418 +-static inline int fls64(__u64 w)
419 +-{
420 +- return (sizeof(__u64) * 8) - __builtin_clzll(w);
421 ++ return fls64((unsigned int) x);
422 + }
423 +
424 + static inline unsigned int __arch_hweight32(unsigned int w)
425 +diff --git a/arch/um/include/asm/pgtable.h b/arch/um/include/asm/pgtable.h
426 +index 41474fb..aa365c5 100644
427 +--- a/arch/um/include/asm/pgtable.h
428 ++++ b/arch/um/include/asm/pgtable.h
429 +@@ -271,6 +271,12 @@ static inline void set_pte(pte_t *pteptr, pte_t pteval)
430 + }
431 + #define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval)
432 +
433 ++#define __HAVE_ARCH_PTE_SAME
434 ++static inline int pte_same(pte_t pte_a, pte_t pte_b)
435 ++{
436 ++ return !((pte_val(pte_a) ^ pte_val(pte_b)) & ~_PAGE_NEWPAGE);
437 ++}
438 ++
439 + /*
440 + * Conversion functions: convert a page and protection to a page entry,
441 + * and a page entry and page directory to the page they refer to.
442 +@@ -346,11 +352,11 @@ extern pte_t *virt_to_pte(struct mm_struct *mm, unsigned long addr);
443 + #define update_mmu_cache(vma,address,ptep) do ; while (0)
444 +
445 + /* Encode and de-code a swap entry */
446 +-#define __swp_type(x) (((x).val >> 4) & 0x3f)
447 ++#define __swp_type(x) (((x).val >> 5) & 0x1f)
448 + #define __swp_offset(x) ((x).val >> 11)
449 +
450 + #define __swp_entry(type, offset) \
451 +- ((swp_entry_t) { ((type) << 4) | ((offset) << 11) })
452 ++ ((swp_entry_t) { ((type) << 5) | ((offset) << 11) })
453 + #define __pte_to_swp_entry(pte) \
454 + ((swp_entry_t) { pte_val(pte_mkuptodate(pte)) })
455 + #define __swp_entry_to_pte(x) ((pte_t) { (x).val })
456 +diff --git a/arch/x86/Makefile b/arch/x86/Makefile
457 +index 209ba12..015f0c5 100644
458 +--- a/arch/x86/Makefile
459 ++++ b/arch/x86/Makefile
460 +@@ -117,6 +117,9 @@ KBUILD_CFLAGS += $(call cc-option,-mno-sse -mno-mmx -mno-sse2 -mno-3dnow,)
461 + KBUILD_CFLAGS += $(mflags-y)
462 + KBUILD_AFLAGS += $(mflags-y)
463 +
464 ++archscripts:
465 ++ $(Q)$(MAKE) $(build)=arch/x86/tools relocs
466 ++
467 + ###
468 + # Syscall table generation
469 +
470 +@@ -186,6 +189,7 @@ archclean:
471 + $(Q)rm -rf $(objtree)/arch/i386
472 + $(Q)rm -rf $(objtree)/arch/x86_64
473 + $(Q)$(MAKE) $(clean)=$(boot)
474 ++ $(Q)$(MAKE) $(clean)=arch/x86/tools
475 +
476 + define archhelp
477 + echo '* bzImage - Compressed kernel image (arch/x86/boot/bzImage)'
478 +diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
479 +index fd55a2f..e398bb5 100644
480 +--- a/arch/x86/boot/compressed/Makefile
481 ++++ b/arch/x86/boot/compressed/Makefile
482 +@@ -40,13 +40,12 @@ OBJCOPYFLAGS_vmlinux.bin := -R .comment -S
483 + $(obj)/vmlinux.bin: vmlinux FORCE
484 + $(call if_changed,objcopy)
485 +
486 ++targets += vmlinux.bin.all vmlinux.relocs
487 +
488 +-targets += vmlinux.bin.all vmlinux.relocs relocs
489 +-hostprogs-$(CONFIG_X86_NEED_RELOCS) += relocs
490 +-
491 ++CMD_RELOCS = arch/x86/tools/relocs
492 + quiet_cmd_relocs = RELOCS $@
493 +- cmd_relocs = $(obj)/relocs $< > $@;$(obj)/relocs --abs-relocs $<
494 +-$(obj)/vmlinux.relocs: vmlinux $(obj)/relocs FORCE
495 ++ cmd_relocs = $(CMD_RELOCS) $< > $@;$(CMD_RELOCS) --abs-relocs $<
496 ++$(obj)/vmlinux.relocs: vmlinux FORCE
497 + $(call if_changed,relocs)
498 +
499 + vmlinux.bin.all-y := $(obj)/vmlinux.bin
500 +diff --git a/arch/x86/boot/compressed/relocs.c b/arch/x86/boot/compressed/relocs.c
501 +deleted file mode 100644
502 +index e77f4e4..0000000
503 +--- a/arch/x86/boot/compressed/relocs.c
504 ++++ /dev/null
505 +@@ -1,680 +0,0 @@
506 +-#include <stdio.h>
507 +-#include <stdarg.h>
508 +-#include <stdlib.h>
509 +-#include <stdint.h>
510 +-#include <string.h>
511 +-#include <errno.h>
512 +-#include <unistd.h>
513 +-#include <elf.h>
514 +-#include <byteswap.h>
515 +-#define USE_BSD
516 +-#include <endian.h>
517 +-#include <regex.h>
518 +-
519 +-static void die(char *fmt, ...);
520 +-
521 +-#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
522 +-static Elf32_Ehdr ehdr;
523 +-static unsigned long reloc_count, reloc_idx;
524 +-static unsigned long *relocs;
525 +-
526 +-struct section {
527 +- Elf32_Shdr shdr;
528 +- struct section *link;
529 +- Elf32_Sym *symtab;
530 +- Elf32_Rel *reltab;
531 +- char *strtab;
532 +-};
533 +-static struct section *secs;
534 +-
535 +-/*
536 +- * Following symbols have been audited. There values are constant and do
537 +- * not change if bzImage is loaded at a different physical address than
538 +- * the address for which it has been compiled. Don't warn user about
539 +- * absolute relocations present w.r.t these symbols.
540 +- */
541 +-static const char abs_sym_regex[] =
542 +- "^(xen_irq_disable_direct_reloc$|"
543 +- "xen_save_fl_direct_reloc$|"
544 +- "VDSO|"
545 +- "__crc_)";
546 +-static regex_t abs_sym_regex_c;
547 +-static int is_abs_reloc(const char *sym_name)
548 +-{
549 +- return !regexec(&abs_sym_regex_c, sym_name, 0, NULL, 0);
550 +-}
551 +-
552 +-/*
553 +- * These symbols are known to be relative, even if the linker marks them
554 +- * as absolute (typically defined outside any section in the linker script.)
555 +- */
556 +-static const char rel_sym_regex[] =
557 +- "^_end$";
558 +-static regex_t rel_sym_regex_c;
559 +-static int is_rel_reloc(const char *sym_name)
560 +-{
561 +- return !regexec(&rel_sym_regex_c, sym_name, 0, NULL, 0);
562 +-}
563 +-
564 +-static void regex_init(void)
565 +-{
566 +- char errbuf[128];
567 +- int err;
568 +-
569 +- err = regcomp(&abs_sym_regex_c, abs_sym_regex,
570 +- REG_EXTENDED|REG_NOSUB);
571 +- if (err) {
572 +- regerror(err, &abs_sym_regex_c, errbuf, sizeof errbuf);
573 +- die("%s", errbuf);
574 +- }
575 +-
576 +- err = regcomp(&rel_sym_regex_c, rel_sym_regex,
577 +- REG_EXTENDED|REG_NOSUB);
578 +- if (err) {
579 +- regerror(err, &rel_sym_regex_c, errbuf, sizeof errbuf);
580 +- die("%s", errbuf);
581 +- }
582 +-}
583 +-
584 +-static void die(char *fmt, ...)
585 +-{
586 +- va_list ap;
587 +- va_start(ap, fmt);
588 +- vfprintf(stderr, fmt, ap);
589 +- va_end(ap);
590 +- exit(1);
591 +-}
592 +-
593 +-static const char *sym_type(unsigned type)
594 +-{
595 +- static const char *type_name[] = {
596 +-#define SYM_TYPE(X) [X] = #X
597 +- SYM_TYPE(STT_NOTYPE),
598 +- SYM_TYPE(STT_OBJECT),
599 +- SYM_TYPE(STT_FUNC),
600 +- SYM_TYPE(STT_SECTION),
601 +- SYM_TYPE(STT_FILE),
602 +- SYM_TYPE(STT_COMMON),
603 +- SYM_TYPE(STT_TLS),
604 +-#undef SYM_TYPE
605 +- };
606 +- const char *name = "unknown sym type name";
607 +- if (type < ARRAY_SIZE(type_name)) {
608 +- name = type_name[type];
609 +- }
610 +- return name;
611 +-}
612 +-
613 +-static const char *sym_bind(unsigned bind)
614 +-{
615 +- static const char *bind_name[] = {
616 +-#define SYM_BIND(X) [X] = #X
617 +- SYM_BIND(STB_LOCAL),
618 +- SYM_BIND(STB_GLOBAL),
619 +- SYM_BIND(STB_WEAK),
620 +-#undef SYM_BIND
621 +- };
622 +- const char *name = "unknown sym bind name";
623 +- if (bind < ARRAY_SIZE(bind_name)) {
624 +- name = bind_name[bind];
625 +- }
626 +- return name;
627 +-}
628 +-
629 +-static const char *sym_visibility(unsigned visibility)
630 +-{
631 +- static const char *visibility_name[] = {
632 +-#define SYM_VISIBILITY(X) [X] = #X
633 +- SYM_VISIBILITY(STV_DEFAULT),
634 +- SYM_VISIBILITY(STV_INTERNAL),
635 +- SYM_VISIBILITY(STV_HIDDEN),
636 +- SYM_VISIBILITY(STV_PROTECTED),
637 +-#undef SYM_VISIBILITY
638 +- };
639 +- const char *name = "unknown sym visibility name";
640 +- if (visibility < ARRAY_SIZE(visibility_name)) {
641 +- name = visibility_name[visibility];
642 +- }
643 +- return name;
644 +-}
645 +-
646 +-static const char *rel_type(unsigned type)
647 +-{
648 +- static const char *type_name[] = {
649 +-#define REL_TYPE(X) [X] = #X
650 +- REL_TYPE(R_386_NONE),
651 +- REL_TYPE(R_386_32),
652 +- REL_TYPE(R_386_PC32),
653 +- REL_TYPE(R_386_GOT32),
654 +- REL_TYPE(R_386_PLT32),
655 +- REL_TYPE(R_386_COPY),
656 +- REL_TYPE(R_386_GLOB_DAT),
657 +- REL_TYPE(R_386_JMP_SLOT),
658 +- REL_TYPE(R_386_RELATIVE),
659 +- REL_TYPE(R_386_GOTOFF),
660 +- REL_TYPE(R_386_GOTPC),
661 +-#undef REL_TYPE
662 +- };
663 +- const char *name = "unknown type rel type name";
664 +- if (type < ARRAY_SIZE(type_name) && type_name[type]) {
665 +- name = type_name[type];
666 +- }
667 +- return name;
668 +-}
669 +-
670 +-static const char *sec_name(unsigned shndx)
671 +-{
672 +- const char *sec_strtab;
673 +- const char *name;
674 +- sec_strtab = secs[ehdr.e_shstrndx].strtab;
675 +- name = "<noname>";
676 +- if (shndx < ehdr.e_shnum) {
677 +- name = sec_strtab + secs[shndx].shdr.sh_name;
678 +- }
679 +- else if (shndx == SHN_ABS) {
680 +- name = "ABSOLUTE";
681 +- }
682 +- else if (shndx == SHN_COMMON) {
683 +- name = "COMMON";
684 +- }
685 +- return name;
686 +-}
687 +-
688 +-static const char *sym_name(const char *sym_strtab, Elf32_Sym *sym)
689 +-{
690 +- const char *name;
691 +- name = "<noname>";
692 +- if (sym->st_name) {
693 +- name = sym_strtab + sym->st_name;
694 +- }
695 +- else {
696 +- name = sec_name(secs[sym->st_shndx].shdr.sh_name);
697 +- }
698 +- return name;
699 +-}
700 +-
701 +-
702 +-
703 +-#if BYTE_ORDER == LITTLE_ENDIAN
704 +-#define le16_to_cpu(val) (val)
705 +-#define le32_to_cpu(val) (val)
706 +-#endif
707 +-#if BYTE_ORDER == BIG_ENDIAN
708 +-#define le16_to_cpu(val) bswap_16(val)
709 +-#define le32_to_cpu(val) bswap_32(val)
710 +-#endif
711 +-
712 +-static uint16_t elf16_to_cpu(uint16_t val)
713 +-{
714 +- return le16_to_cpu(val);
715 +-}
716 +-
717 +-static uint32_t elf32_to_cpu(uint32_t val)
718 +-{
719 +- return le32_to_cpu(val);
720 +-}
721 +-
722 +-static void read_ehdr(FILE *fp)
723 +-{
724 +- if (fread(&ehdr, sizeof(ehdr), 1, fp) != 1) {
725 +- die("Cannot read ELF header: %s\n",
726 +- strerror(errno));
727 +- }
728 +- if (memcmp(ehdr.e_ident, ELFMAG, SELFMAG) != 0) {
729 +- die("No ELF magic\n");
730 +- }
731 +- if (ehdr.e_ident[EI_CLASS] != ELFCLASS32) {
732 +- die("Not a 32 bit executable\n");
733 +- }
734 +- if (ehdr.e_ident[EI_DATA] != ELFDATA2LSB) {
735 +- die("Not a LSB ELF executable\n");
736 +- }
737 +- if (ehdr.e_ident[EI_VERSION] != EV_CURRENT) {
738 +- die("Unknown ELF version\n");
739 +- }
740 +- /* Convert the fields to native endian */
741 +- ehdr.e_type = elf16_to_cpu(ehdr.e_type);
742 +- ehdr.e_machine = elf16_to_cpu(ehdr.e_machine);
743 +- ehdr.e_version = elf32_to_cpu(ehdr.e_version);
744 +- ehdr.e_entry = elf32_to_cpu(ehdr.e_entry);
745 +- ehdr.e_phoff = elf32_to_cpu(ehdr.e_phoff);
746 +- ehdr.e_shoff = elf32_to_cpu(ehdr.e_shoff);
747 +- ehdr.e_flags = elf32_to_cpu(ehdr.e_flags);
748 +- ehdr.e_ehsize = elf16_to_cpu(ehdr.e_ehsize);
749 +- ehdr.e_phentsize = elf16_to_cpu(ehdr.e_phentsize);
750 +- ehdr.e_phnum = elf16_to_cpu(ehdr.e_phnum);
751 +- ehdr.e_shentsize = elf16_to_cpu(ehdr.e_shentsize);
752 +- ehdr.e_shnum = elf16_to_cpu(ehdr.e_shnum);
753 +- ehdr.e_shstrndx = elf16_to_cpu(ehdr.e_shstrndx);
754 +-
755 +- if ((ehdr.e_type != ET_EXEC) && (ehdr.e_type != ET_DYN)) {
756 +- die("Unsupported ELF header type\n");
757 +- }
758 +- if (ehdr.e_machine != EM_386) {
759 +- die("Not for x86\n");
760 +- }
761 +- if (ehdr.e_version != EV_CURRENT) {
762 +- die("Unknown ELF version\n");
763 +- }
764 +- if (ehdr.e_ehsize != sizeof(Elf32_Ehdr)) {
765 +- die("Bad Elf header size\n");
766 +- }
767 +- if (ehdr.e_phentsize != sizeof(Elf32_Phdr)) {
768 +- die("Bad program header entry\n");
769 +- }
770 +- if (ehdr.e_shentsize != sizeof(Elf32_Shdr)) {
771 +- die("Bad section header entry\n");
772 +- }
773 +- if (ehdr.e_shstrndx >= ehdr.e_shnum) {
774 +- die("String table index out of bounds\n");
775 +- }
776 +-}
777 +-
778 +-static void read_shdrs(FILE *fp)
779 +-{
780 +- int i;
781 +- Elf32_Shdr shdr;
782 +-
783 +- secs = calloc(ehdr.e_shnum, sizeof(struct section));
784 +- if (!secs) {
785 +- die("Unable to allocate %d section headers\n",
786 +- ehdr.e_shnum);
787 +- }
788 +- if (fseek(fp, ehdr.e_shoff, SEEK_SET) < 0) {
789 +- die("Seek to %d failed: %s\n",
790 +- ehdr.e_shoff, strerror(errno));
791 +- }
792 +- for (i = 0; i < ehdr.e_shnum; i++) {
793 +- struct section *sec = &secs[i];
794 +- if (fread(&shdr, sizeof shdr, 1, fp) != 1)
795 +- die("Cannot read ELF section headers %d/%d: %s\n",
796 +- i, ehdr.e_shnum, strerror(errno));
797 +- sec->shdr.sh_name = elf32_to_cpu(shdr.sh_name);
798 +- sec->shdr.sh_type = elf32_to_cpu(shdr.sh_type);
799 +- sec->shdr.sh_flags = elf32_to_cpu(shdr.sh_flags);
800 +- sec->shdr.sh_addr = elf32_to_cpu(shdr.sh_addr);
801 +- sec->shdr.sh_offset = elf32_to_cpu(shdr.sh_offset);
802 +- sec->shdr.sh_size = elf32_to_cpu(shdr.sh_size);
803 +- sec->shdr.sh_link = elf32_to_cpu(shdr.sh_link);
804 +- sec->shdr.sh_info = elf32_to_cpu(shdr.sh_info);
805 +- sec->shdr.sh_addralign = elf32_to_cpu(shdr.sh_addralign);
806 +- sec->shdr.sh_entsize = elf32_to_cpu(shdr.sh_entsize);
807 +- if (sec->shdr.sh_link < ehdr.e_shnum)
808 +- sec->link = &secs[sec->shdr.sh_link];
809 +- }
810 +-
811 +-}
812 +-
813 +-static void read_strtabs(FILE *fp)
814 +-{
815 +- int i;
816 +- for (i = 0; i < ehdr.e_shnum; i++) {
817 +- struct section *sec = &secs[i];
818 +- if (sec->shdr.sh_type != SHT_STRTAB) {
819 +- continue;
820 +- }
821 +- sec->strtab = malloc(sec->shdr.sh_size);
822 +- if (!sec->strtab) {
823 +- die("malloc of %d bytes for strtab failed\n",
824 +- sec->shdr.sh_size);
825 +- }
826 +- if (fseek(fp, sec->shdr.sh_offset, SEEK_SET) < 0) {
827 +- die("Seek to %d failed: %s\n",
828 +- sec->shdr.sh_offset, strerror(errno));
829 +- }
830 +- if (fread(sec->strtab, 1, sec->shdr.sh_size, fp)
831 +- != sec->shdr.sh_size) {
832 +- die("Cannot read symbol table: %s\n",
833 +- strerror(errno));
834 +- }
835 +- }
836 +-}
837 +-
838 +-static void read_symtabs(FILE *fp)
839 +-{
840 +- int i,j;
841 +- for (i = 0; i < ehdr.e_shnum; i++) {
842 +- struct section *sec = &secs[i];
843 +- if (sec->shdr.sh_type != SHT_SYMTAB) {
844 +- continue;
845 +- }
846 +- sec->symtab = malloc(sec->shdr.sh_size);
847 +- if (!sec->symtab) {
848 +- die("malloc of %d bytes for symtab failed\n",
849 +- sec->shdr.sh_size);
850 +- }
851 +- if (fseek(fp, sec->shdr.sh_offset, SEEK_SET) < 0) {
852 +- die("Seek to %d failed: %s\n",
853 +- sec->shdr.sh_offset, strerror(errno));
854 +- }
855 +- if (fread(sec->symtab, 1, sec->shdr.sh_size, fp)
856 +- != sec->shdr.sh_size) {
857 +- die("Cannot read symbol table: %s\n",
858 +- strerror(errno));
859 +- }
860 +- for (j = 0; j < sec->shdr.sh_size/sizeof(Elf32_Sym); j++) {
861 +- Elf32_Sym *sym = &sec->symtab[j];
862 +- sym->st_name = elf32_to_cpu(sym->st_name);
863 +- sym->st_value = elf32_to_cpu(sym->st_value);
864 +- sym->st_size = elf32_to_cpu(sym->st_size);
865 +- sym->st_shndx = elf16_to_cpu(sym->st_shndx);
866 +- }
867 +- }
868 +-}
869 +-
870 +-
871 +-static void read_relocs(FILE *fp)
872 +-{
873 +- int i,j;
874 +- for (i = 0; i < ehdr.e_shnum; i++) {
875 +- struct section *sec = &secs[i];
876 +- if (sec->shdr.sh_type != SHT_REL) {
877 +- continue;
878 +- }
879 +- sec->reltab = malloc(sec->shdr.sh_size);
880 +- if (!sec->reltab) {
881 +- die("malloc of %d bytes for relocs failed\n",
882 +- sec->shdr.sh_size);
883 +- }
884 +- if (fseek(fp, sec->shdr.sh_offset, SEEK_SET) < 0) {
885 +- die("Seek to %d failed: %s\n",
886 +- sec->shdr.sh_offset, strerror(errno));
887 +- }
888 +- if (fread(sec->reltab, 1, sec->shdr.sh_size, fp)
889 +- != sec->shdr.sh_size) {
890 +- die("Cannot read symbol table: %s\n",
891 +- strerror(errno));
892 +- }
893 +- for (j = 0; j < sec->shdr.sh_size/sizeof(Elf32_Rel); j++) {
894 +- Elf32_Rel *rel = &sec->reltab[j];
895 +- rel->r_offset = elf32_to_cpu(rel->r_offset);
896 +- rel->r_info = elf32_to_cpu(rel->r_info);
897 +- }
898 +- }
899 +-}
900 +-
901 +-
902 +-static void print_absolute_symbols(void)
903 +-{
904 +- int i;
905 +- printf("Absolute symbols\n");
906 +- printf(" Num: Value Size Type Bind Visibility Name\n");
907 +- for (i = 0; i < ehdr.e_shnum; i++) {
908 +- struct section *sec = &secs[i];
909 +- char *sym_strtab;
910 +- int j;
911 +-
912 +- if (sec->shdr.sh_type != SHT_SYMTAB) {
913 +- continue;
914 +- }
915 +- sym_strtab = sec->link->strtab;
916 +- for (j = 0; j < sec->shdr.sh_size/sizeof(Elf32_Sym); j++) {
917 +- Elf32_Sym *sym;
918 +- const char *name;
919 +- sym = &sec->symtab[j];
920 +- name = sym_name(sym_strtab, sym);
921 +- if (sym->st_shndx != SHN_ABS) {
922 +- continue;
923 +- }
924 +- printf("%5d %08x %5d %10s %10s %12s %s\n",
925 +- j, sym->st_value, sym->st_size,
926 +- sym_type(ELF32_ST_TYPE(sym->st_info)),
927 +- sym_bind(ELF32_ST_BIND(sym->st_info)),
928 +- sym_visibility(ELF32_ST_VISIBILITY(sym->st_other)),
929 +- name);
930 +- }
931 +- }
932 +- printf("\n");
933 +-}
934 +-
935 +-static void print_absolute_relocs(void)
936 +-{
937 +- int i, printed = 0;
938 +-
939 +- for (i = 0; i < ehdr.e_shnum; i++) {
940 +- struct section *sec = &secs[i];
941 +- struct section *sec_applies, *sec_symtab;
942 +- char *sym_strtab;
943 +- Elf32_Sym *sh_symtab;
944 +- int j;
945 +- if (sec->shdr.sh_type != SHT_REL) {
946 +- continue;
947 +- }
948 +- sec_symtab = sec->link;
949 +- sec_applies = &secs[sec->shdr.sh_info];
950 +- if (!(sec_applies->shdr.sh_flags & SHF_ALLOC)) {
951 +- continue;
952 +- }
953 +- sh_symtab = sec_symtab->symtab;
954 +- sym_strtab = sec_symtab->link->strtab;
955 +- for (j = 0; j < sec->shdr.sh_size/sizeof(Elf32_Rel); j++) {
956 +- Elf32_Rel *rel;
957 +- Elf32_Sym *sym;
958 +- const char *name;
959 +- rel = &sec->reltab[j];
960 +- sym = &sh_symtab[ELF32_R_SYM(rel->r_info)];
961 +- name = sym_name(sym_strtab, sym);
962 +- if (sym->st_shndx != SHN_ABS) {
963 +- continue;
964 +- }
965 +-
966 +- /* Absolute symbols are not relocated if bzImage is
967 +- * loaded at a non-compiled address. Display a warning
968 +- * to user at compile time about the absolute
969 +- * relocations present.
970 +- *
971 +- * User need to audit the code to make sure
972 +- * some symbols which should have been section
973 +- * relative have not become absolute because of some
974 +- * linker optimization or wrong programming usage.
975 +- *
976 +- * Before warning check if this absolute symbol
977 +- * relocation is harmless.
978 +- */
979 +- if (is_abs_reloc(name) || is_rel_reloc(name))
980 +- continue;
981 +-
982 +- if (!printed) {
983 +- printf("WARNING: Absolute relocations"
984 +- " present\n");
985 +- printf("Offset Info Type Sym.Value "
986 +- "Sym.Name\n");
987 +- printed = 1;
988 +- }
989 +-
990 +- printf("%08x %08x %10s %08x %s\n",
991 +- rel->r_offset,
992 +- rel->r_info,
993 +- rel_type(ELF32_R_TYPE(rel->r_info)),
994 +- sym->st_value,
995 +- name);
996 +- }
997 +- }
998 +-
999 +- if (printed)
1000 +- printf("\n");
1001 +-}
1002 +-
1003 +-static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym))
1004 +-{
1005 +- int i;
1006 +- /* Walk through the relocations */
1007 +- for (i = 0; i < ehdr.e_shnum; i++) {
1008 +- char *sym_strtab;
1009 +- Elf32_Sym *sh_symtab;
1010 +- struct section *sec_applies, *sec_symtab;
1011 +- int j;
1012 +- struct section *sec = &secs[i];
1013 +-
1014 +- if (sec->shdr.sh_type != SHT_REL) {
1015 +- continue;
1016 +- }
1017 +- sec_symtab = sec->link;
1018 +- sec_applies = &secs[sec->shdr.sh_info];
1019 +- if (!(sec_applies->shdr.sh_flags & SHF_ALLOC)) {
1020 +- continue;
1021 +- }
1022 +- sh_symtab = sec_symtab->symtab;
1023 +- sym_strtab = sec_symtab->link->strtab;
1024 +- for (j = 0; j < sec->shdr.sh_size/sizeof(Elf32_Rel); j++) {
1025 +- Elf32_Rel *rel;
1026 +- Elf32_Sym *sym;
1027 +- unsigned r_type;
1028 +- rel = &sec->reltab[j];
1029 +- sym = &sh_symtab[ELF32_R_SYM(rel->r_info)];
1030 +- r_type = ELF32_R_TYPE(rel->r_info);
1031 +- /* Don't visit relocations to absolute symbols */
1032 +- if (sym->st_shndx == SHN_ABS &&
1033 +- !is_rel_reloc(sym_name(sym_strtab, sym))) {
1034 +- continue;
1035 +- }
1036 +- switch (r_type) {
1037 +- case R_386_NONE:
1038 +- case R_386_PC32:
1039 +- /*
1040 +- * NONE can be ignored and and PC relative
1041 +- * relocations don't need to be adjusted.
1042 +- */
1043 +- break;
1044 +- case R_386_32:
1045 +- /* Visit relocations that need to be adjusted */
1046 +- visit(rel, sym);
1047 +- break;
1048 +- default:
1049 +- die("Unsupported relocation type: %s (%d)\n",
1050 +- rel_type(r_type), r_type);
1051 +- break;
1052 +- }
1053 +- }
1054 +- }
1055 +-}
1056 +-
1057 +-static void count_reloc(Elf32_Rel *rel, Elf32_Sym *sym)
1058 +-{
1059 +- reloc_count += 1;
1060 +-}
1061 +-
1062 +-static void collect_reloc(Elf32_Rel *rel, Elf32_Sym *sym)
1063 +-{
1064 +- /* Remember the address that needs to be adjusted. */
1065 +- relocs[reloc_idx++] = rel->r_offset;
1066 +-}
1067 +-
1068 +-static int cmp_relocs(const void *va, const void *vb)
1069 +-{
1070 +- const unsigned long *a, *b;
1071 +- a = va; b = vb;
1072 +- return (*a == *b)? 0 : (*a > *b)? 1 : -1;
1073 +-}
1074 +-
1075 +-static void emit_relocs(int as_text)
1076 +-{
1077 +- int i;
1078 +- /* Count how many relocations I have and allocate space for them. */
1079 +- reloc_count = 0;
1080 +- walk_relocs(count_reloc);
1081 +- relocs = malloc(reloc_count * sizeof(relocs[0]));
1082 +- if (!relocs) {
1083 +- die("malloc of %d entries for relocs failed\n",
1084 +- reloc_count);
1085 +- }
1086 +- /* Collect up the relocations */
1087 +- reloc_idx = 0;
1088 +- walk_relocs(collect_reloc);
1089 +-
1090 +- /* Order the relocations for more efficient processing */
1091 +- qsort(relocs, reloc_count, sizeof(relocs[0]), cmp_relocs);
1092 +-
1093 +- /* Print the relocations */
1094 +- if (as_text) {
1095 +- /* Print the relocations in a form suitable that
1096 +- * gas will like.
1097 +- */
1098 +- printf(".section \".data.reloc\",\"a\"\n");
1099 +- printf(".balign 4\n");
1100 +- for (i = 0; i < reloc_count; i++) {
1101 +- printf("\t .long 0x%08lx\n", relocs[i]);
1102 +- }
1103 +- printf("\n");
1104 +- }
1105 +- else {
1106 +- unsigned char buf[4];
1107 +- /* Print a stop */
1108 +- fwrite("\0\0\0\0", 4, 1, stdout);
1109 +- /* Now print each relocation */
1110 +- for (i = 0; i < reloc_count; i++) {
1111 +- buf[0] = (relocs[i] >> 0) & 0xff;
1112 +- buf[1] = (relocs[i] >> 8) & 0xff;
1113 +- buf[2] = (relocs[i] >> 16) & 0xff;
1114 +- buf[3] = (relocs[i] >> 24) & 0xff;
1115 +- fwrite(buf, 4, 1, stdout);
1116 +- }
1117 +- }
1118 +-}
1119 +-
1120 +-static void usage(void)
1121 +-{
1122 +- die("relocs [--abs-syms |--abs-relocs | --text] vmlinux\n");
1123 +-}
1124 +-
1125 +-int main(int argc, char **argv)
1126 +-{
1127 +- int show_absolute_syms, show_absolute_relocs;
1128 +- int as_text;
1129 +- const char *fname;
1130 +- FILE *fp;
1131 +- int i;
1132 +-
1133 +- regex_init();
1134 +-
1135 +- show_absolute_syms = 0;
1136 +- show_absolute_relocs = 0;
1137 +- as_text = 0;
1138 +- fname = NULL;
1139 +- for (i = 1; i < argc; i++) {
1140 +- char *arg = argv[i];
1141 +- if (*arg == '-') {
1142 +- if (strcmp(argv[1], "--abs-syms") == 0) {
1143 +- show_absolute_syms = 1;
1144 +- continue;
1145 +- }
1146 +-
1147 +- if (strcmp(argv[1], "--abs-relocs") == 0) {
1148 +- show_absolute_relocs = 1;
1149 +- continue;
1150 +- }
1151 +- else if (strcmp(argv[1], "--text") == 0) {
1152 +- as_text = 1;
1153 +- continue;
1154 +- }
1155 +- }
1156 +- else if (!fname) {
1157 +- fname = arg;
1158 +- continue;
1159 +- }
1160 +- usage();
1161 +- }
1162 +- if (!fname) {
1163 +- usage();
1164 +- }
1165 +- fp = fopen(fname, "r");
1166 +- if (!fp) {
1167 +- die("Cannot open %s: %s\n",
1168 +- fname, strerror(errno));
1169 +- }
1170 +- read_ehdr(fp);
1171 +- read_shdrs(fp);
1172 +- read_strtabs(fp);
1173 +- read_symtabs(fp);
1174 +- read_relocs(fp);
1175 +- if (show_absolute_syms) {
1176 +- print_absolute_symbols();
1177 +- return 0;
1178 +- }
1179 +- if (show_absolute_relocs) {
1180 +- print_absolute_relocs();
1181 +- return 0;
1182 +- }
1183 +- emit_relocs(as_text);
1184 +- return 0;
1185 +-}
1186 +diff --git a/arch/x86/kernel/cpu/mcheck/mce-severity.c b/arch/x86/kernel/cpu/mcheck/mce-severity.c
1187 +index 7395d5f..c9c9cfe 100644
1188 +--- a/arch/x86/kernel/cpu/mcheck/mce-severity.c
1189 ++++ b/arch/x86/kernel/cpu/mcheck/mce-severity.c
1190 +@@ -145,15 +145,19 @@ static struct severity {
1191 + };
1192 +
1193 + /*
1194 +- * If the EIPV bit is set, it means the saved IP is the
1195 +- * instruction which caused the MCE.
1196 ++ * If mcgstatus indicated that ip/cs on the stack were
1197 ++ * no good, then "m->cs" will be zero and we will have
1198 ++ * to assume the worst case (IN_KERNEL) as we actually
1199 ++ * have no idea what we were executing when the machine
1200 ++ * check hit.
1201 ++ * If we do have a good "m->cs" (or a faked one in the
1202 ++ * case we were executing in VM86 mode) we can use it to
1203 ++ * distinguish an exception taken in user from from one
1204 ++ * taken in the kernel.
1205 + */
1206 + static int error_context(struct mce *m)
1207 + {
1208 +- if (m->mcgstatus & MCG_STATUS_EIPV)
1209 +- return (m->ip && (m->cs & 3) == 3) ? IN_USER : IN_KERNEL;
1210 +- /* Unknown, assume kernel */
1211 +- return IN_KERNEL;
1212 ++ return ((m->cs & 3) == 3) ? IN_USER : IN_KERNEL;
1213 + }
1214 +
1215 + int mce_severity(struct mce *m, int tolerant, char **msg)
1216 +diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
1217 +index 5a11ae2..dee004f 100644
1218 +--- a/arch/x86/kernel/cpu/mcheck/mce.c
1219 ++++ b/arch/x86/kernel/cpu/mcheck/mce.c
1220 +@@ -437,6 +437,14 @@ static inline void mce_gather_info(struct mce *m, struct pt_regs *regs)
1221 + if (m->mcgstatus & (MCG_STATUS_RIPV|MCG_STATUS_EIPV)) {
1222 + m->ip = regs->ip;
1223 + m->cs = regs->cs;
1224 ++
1225 ++ /*
1226 ++ * When in VM86 mode make the cs look like ring 3
1227 ++ * always. This is a lie, but it's better than passing
1228 ++ * the additional vm86 bit around everywhere.
1229 ++ */
1230 ++ if (v8086_mode(regs))
1231 ++ m->cs |= 3;
1232 + }
1233 + /* Use accurate RIP reporting if available. */
1234 + if (rip_msr)
1235 +diff --git a/arch/x86/kernel/cpu/perf_event_amd.c b/arch/x86/kernel/cpu/perf_event_amd.c
1236 +index 67250a5..cdd5755 100644
1237 +--- a/arch/x86/kernel/cpu/perf_event_amd.c
1238 ++++ b/arch/x86/kernel/cpu/perf_event_amd.c
1239 +@@ -473,6 +473,7 @@ static __initconst const struct x86_pmu amd_pmu = {
1240 + * 0x023 DE PERF_CTL[2:0]
1241 + * 0x02D LS PERF_CTL[3]
1242 + * 0x02E LS PERF_CTL[3,0]
1243 ++ * 0x031 LS PERF_CTL[2:0] (**)
1244 + * 0x043 CU PERF_CTL[2:0]
1245 + * 0x045 CU PERF_CTL[2:0]
1246 + * 0x046 CU PERF_CTL[2:0]
1247 +@@ -486,10 +487,12 @@ static __initconst const struct x86_pmu amd_pmu = {
1248 + * 0x0DD LS PERF_CTL[5:0]
1249 + * 0x0DE LS PERF_CTL[5:0]
1250 + * 0x0DF LS PERF_CTL[5:0]
1251 ++ * 0x1C0 EX PERF_CTL[5:3]
1252 + * 0x1D6 EX PERF_CTL[5:0]
1253 + * 0x1D8 EX PERF_CTL[5:0]
1254 + *
1255 +- * (*) depending on the umask all FPU counters may be used
1256 ++ * (*) depending on the umask all FPU counters may be used
1257 ++ * (**) only one unitmask enabled at a time
1258 + */
1259 +
1260 + static struct event_constraint amd_f15_PMC0 = EVENT_CONSTRAINT(0, 0x01, 0);
1261 +@@ -539,6 +542,12 @@ amd_get_event_constraints_f15h(struct cpu_hw_events *cpuc, struct perf_event *ev
1262 + return &amd_f15_PMC3;
1263 + case 0x02E:
1264 + return &amd_f15_PMC30;
1265 ++ case 0x031:
1266 ++ if (hweight_long(hwc->config & ARCH_PERFMON_EVENTSEL_UMASK) <= 1)
1267 ++ return &amd_f15_PMC20;
1268 ++ return &emptyconstraint;
1269 ++ case 0x1C0:
1270 ++ return &amd_f15_PMC53;
1271 + default:
1272 + return &amd_f15_PMC50;
1273 + }
1274 +diff --git a/arch/x86/pci/xen.c b/arch/x86/pci/xen.c
1275 +index d99346e..4c262f6 100644
1276 +--- a/arch/x86/pci/xen.c
1277 ++++ b/arch/x86/pci/xen.c
1278 +@@ -64,6 +64,10 @@ static int xen_register_pirq(u32 gsi, int gsi_override, int triggering,
1279 + int shareable = 0;
1280 + char *name;
1281 +
1282 ++ irq = xen_irq_from_gsi(gsi);
1283 ++ if (irq > 0)
1284 ++ return irq;
1285 ++
1286 + if (set_pirq)
1287 + pirq = gsi;
1288 +
1289 +diff --git a/arch/x86/tools/.gitignore b/arch/x86/tools/.gitignore
1290 +new file mode 100644
1291 +index 0000000..be0ed06
1292 +--- /dev/null
1293 ++++ b/arch/x86/tools/.gitignore
1294 +@@ -0,0 +1 @@
1295 ++relocs
1296 +diff --git a/arch/x86/tools/Makefile b/arch/x86/tools/Makefile
1297 +index d511aa9..733057b 100644
1298 +--- a/arch/x86/tools/Makefile
1299 ++++ b/arch/x86/tools/Makefile
1300 +@@ -36,3 +36,7 @@ HOSTCFLAGS_insn_sanity.o := -Wall -I$(objtree)/arch/x86/lib/ -I$(srctree)/arch/x
1301 + $(obj)/test_get_len.o: $(srctree)/arch/x86/lib/insn.c $(srctree)/arch/x86/lib/inat.c $(srctree)/arch/x86/include/asm/inat_types.h $(srctree)/arch/x86/include/asm/inat.h $(srctree)/arch/x86/include/asm/insn.h $(objtree)/arch/x86/lib/inat-tables.c
1302 +
1303 + $(obj)/insn_sanity.o: $(srctree)/arch/x86/lib/insn.c $(srctree)/arch/x86/lib/inat.c $(srctree)/arch/x86/include/asm/inat_types.h $(srctree)/arch/x86/include/asm/inat.h $(srctree)/arch/x86/include/asm/insn.h $(objtree)/arch/x86/lib/inat-tables.c
1304 ++
1305 ++HOST_EXTRACFLAGS += -I$(srctree)/tools/include
1306 ++hostprogs-y += relocs
1307 ++relocs: $(obj)/relocs
1308 +diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
1309 +new file mode 100644
1310 +index 0000000..b685296
1311 +--- /dev/null
1312 ++++ b/arch/x86/tools/relocs.c
1313 +@@ -0,0 +1,818 @@
1314 ++#include <stdio.h>
1315 ++#include <stdarg.h>
1316 ++#include <stdlib.h>
1317 ++#include <stdint.h>
1318 ++#include <string.h>
1319 ++#include <errno.h>
1320 ++#include <unistd.h>
1321 ++#include <elf.h>
1322 ++#include <byteswap.h>
1323 ++#define USE_BSD
1324 ++#include <endian.h>
1325 ++#include <regex.h>
1326 ++#include <tools/le_byteshift.h>
1327 ++
1328 ++static void die(char *fmt, ...);
1329 ++
1330 ++#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
1331 ++static Elf32_Ehdr ehdr;
1332 ++static unsigned long reloc_count, reloc_idx;
1333 ++static unsigned long *relocs;
1334 ++static unsigned long reloc16_count, reloc16_idx;
1335 ++static unsigned long *relocs16;
1336 ++
1337 ++struct section {
1338 ++ Elf32_Shdr shdr;
1339 ++ struct section *link;
1340 ++ Elf32_Sym *symtab;
1341 ++ Elf32_Rel *reltab;
1342 ++ char *strtab;
1343 ++};
1344 ++static struct section *secs;
1345 ++
1346 ++enum symtype {
1347 ++ S_ABS,
1348 ++ S_REL,
1349 ++ S_SEG,
1350 ++ S_LIN,
1351 ++ S_NSYMTYPES
1352 ++};
1353 ++
1354 ++static const char * const sym_regex_kernel[S_NSYMTYPES] = {
1355 ++/*
1356 ++ * Following symbols have been audited. There values are constant and do
1357 ++ * not change if bzImage is loaded at a different physical address than
1358 ++ * the address for which it has been compiled. Don't warn user about
1359 ++ * absolute relocations present w.r.t these symbols.
1360 ++ */
1361 ++ [S_ABS] =
1362 ++ "^(xen_irq_disable_direct_reloc$|"
1363 ++ "xen_save_fl_direct_reloc$|"
1364 ++ "VDSO|"
1365 ++ "__crc_)",
1366 ++
1367 ++/*
1368 ++ * These symbols are known to be relative, even if the linker marks them
1369 ++ * as absolute (typically defined outside any section in the linker script.)
1370 ++ */
1371 ++ [S_REL] =
1372 ++ "^(__init_(begin|end)|"
1373 ++ "__x86_cpu_dev_(start|end)|"
1374 ++ "(__parainstructions|__alt_instructions)(|_end)|"
1375 ++ "(__iommu_table|__apicdrivers|__smp_locks)(|_end)|"
1376 ++ "__(start|end)_pci_.*|"
1377 ++ "__(start|end)_builtin_fw|"
1378 ++ "__(start|stop)___ksymtab(|_gpl|_unused|_unused_gpl|_gpl_future)|"
1379 ++ "__(start|stop)___kcrctab(|_gpl|_unused|_unused_gpl|_gpl_future)|"
1380 ++ "__(start|stop)___param|"
1381 ++ "__(start|stop)___modver|"
1382 ++ "__(start|stop)___bug_table|"
1383 ++ "__tracedata_(start|end)|"
1384 ++ "__(start|stop)_notes|"
1385 ++ "__end_rodata|"
1386 ++ "__initramfs_start|"
1387 ++ "(jiffies|jiffies_64)|"
1388 ++ "_end)$"
1389 ++};
1390 ++
1391 ++
1392 ++static const char * const sym_regex_realmode[S_NSYMTYPES] = {
1393 ++/*
1394 ++ * These are 16-bit segment symbols when compiling 16-bit code.
1395 ++ */
1396 ++ [S_SEG] =
1397 ++ "^real_mode_seg$",
1398 ++
1399 ++/*
1400 ++ * These are offsets belonging to segments, as opposed to linear addresses,
1401 ++ * when compiling 16-bit code.
1402 ++ */
1403 ++ [S_LIN] =
1404 ++ "^pa_",
1405 ++};
1406 ++
1407 ++static const char * const *sym_regex;
1408 ++
1409 ++static regex_t sym_regex_c[S_NSYMTYPES];
1410 ++static int is_reloc(enum symtype type, const char *sym_name)
1411 ++{
1412 ++ return sym_regex[type] &&
1413 ++ !regexec(&sym_regex_c[type], sym_name, 0, NULL, 0);
1414 ++}
1415 ++
1416 ++static void regex_init(int use_real_mode)
1417 ++{
1418 ++ char errbuf[128];
1419 ++ int err;
1420 ++ int i;
1421 ++
1422 ++ if (use_real_mode)
1423 ++ sym_regex = sym_regex_realmode;
1424 ++ else
1425 ++ sym_regex = sym_regex_kernel;
1426 ++
1427 ++ for (i = 0; i < S_NSYMTYPES; i++) {
1428 ++ if (!sym_regex[i])
1429 ++ continue;
1430 ++
1431 ++ err = regcomp(&sym_regex_c[i], sym_regex[i],
1432 ++ REG_EXTENDED|REG_NOSUB);
1433 ++
1434 ++ if (err) {
1435 ++ regerror(err, &sym_regex_c[i], errbuf, sizeof errbuf);
1436 ++ die("%s", errbuf);
1437 ++ }
1438 ++ }
1439 ++}
1440 ++
1441 ++static void die(char *fmt, ...)
1442 ++{
1443 ++ va_list ap;
1444 ++ va_start(ap, fmt);
1445 ++ vfprintf(stderr, fmt, ap);
1446 ++ va_end(ap);
1447 ++ exit(1);
1448 ++}
1449 ++
1450 ++static const char *sym_type(unsigned type)
1451 ++{
1452 ++ static const char *type_name[] = {
1453 ++#define SYM_TYPE(X) [X] = #X
1454 ++ SYM_TYPE(STT_NOTYPE),
1455 ++ SYM_TYPE(STT_OBJECT),
1456 ++ SYM_TYPE(STT_FUNC),
1457 ++ SYM_TYPE(STT_SECTION),
1458 ++ SYM_TYPE(STT_FILE),
1459 ++ SYM_TYPE(STT_COMMON),
1460 ++ SYM_TYPE(STT_TLS),
1461 ++#undef SYM_TYPE
1462 ++ };
1463 ++ const char *name = "unknown sym type name";
1464 ++ if (type < ARRAY_SIZE(type_name)) {
1465 ++ name = type_name[type];
1466 ++ }
1467 ++ return name;
1468 ++}
1469 ++
1470 ++static const char *sym_bind(unsigned bind)
1471 ++{
1472 ++ static const char *bind_name[] = {
1473 ++#define SYM_BIND(X) [X] = #X
1474 ++ SYM_BIND(STB_LOCAL),
1475 ++ SYM_BIND(STB_GLOBAL),
1476 ++ SYM_BIND(STB_WEAK),
1477 ++#undef SYM_BIND
1478 ++ };
1479 ++ const char *name = "unknown sym bind name";
1480 ++ if (bind < ARRAY_SIZE(bind_name)) {
1481 ++ name = bind_name[bind];
1482 ++ }
1483 ++ return name;
1484 ++}
1485 ++
1486 ++static const char *sym_visibility(unsigned visibility)
1487 ++{
1488 ++ static const char *visibility_name[] = {
1489 ++#define SYM_VISIBILITY(X) [X] = #X
1490 ++ SYM_VISIBILITY(STV_DEFAULT),
1491 ++ SYM_VISIBILITY(STV_INTERNAL),
1492 ++ SYM_VISIBILITY(STV_HIDDEN),
1493 ++ SYM_VISIBILITY(STV_PROTECTED),
1494 ++#undef SYM_VISIBILITY
1495 ++ };
1496 ++ const char *name = "unknown sym visibility name";
1497 ++ if (visibility < ARRAY_SIZE(visibility_name)) {
1498 ++ name = visibility_name[visibility];
1499 ++ }
1500 ++ return name;
1501 ++}
1502 ++
1503 ++static const char *rel_type(unsigned type)
1504 ++{
1505 ++ static const char *type_name[] = {
1506 ++#define REL_TYPE(X) [X] = #X
1507 ++ REL_TYPE(R_386_NONE),
1508 ++ REL_TYPE(R_386_32),
1509 ++ REL_TYPE(R_386_PC32),
1510 ++ REL_TYPE(R_386_GOT32),
1511 ++ REL_TYPE(R_386_PLT32),
1512 ++ REL_TYPE(R_386_COPY),
1513 ++ REL_TYPE(R_386_GLOB_DAT),
1514 ++ REL_TYPE(R_386_JMP_SLOT),
1515 ++ REL_TYPE(R_386_RELATIVE),
1516 ++ REL_TYPE(R_386_GOTOFF),
1517 ++ REL_TYPE(R_386_GOTPC),
1518 ++ REL_TYPE(R_386_8),
1519 ++ REL_TYPE(R_386_PC8),
1520 ++ REL_TYPE(R_386_16),
1521 ++ REL_TYPE(R_386_PC16),
1522 ++#undef REL_TYPE
1523 ++ };
1524 ++ const char *name = "unknown type rel type name";
1525 ++ if (type < ARRAY_SIZE(type_name) && type_name[type]) {
1526 ++ name = type_name[type];
1527 ++ }
1528 ++ return name;
1529 ++}
1530 ++
1531 ++static const char *sec_name(unsigned shndx)
1532 ++{
1533 ++ const char *sec_strtab;
1534 ++ const char *name;
1535 ++ sec_strtab = secs[ehdr.e_shstrndx].strtab;
1536 ++ name = "<noname>";
1537 ++ if (shndx < ehdr.e_shnum) {
1538 ++ name = sec_strtab + secs[shndx].shdr.sh_name;
1539 ++ }
1540 ++ else if (shndx == SHN_ABS) {
1541 ++ name = "ABSOLUTE";
1542 ++ }
1543 ++ else if (shndx == SHN_COMMON) {
1544 ++ name = "COMMON";
1545 ++ }
1546 ++ return name;
1547 ++}
1548 ++
1549 ++static const char *sym_name(const char *sym_strtab, Elf32_Sym *sym)
1550 ++{
1551 ++ const char *name;
1552 ++ name = "<noname>";
1553 ++ if (sym->st_name) {
1554 ++ name = sym_strtab + sym->st_name;
1555 ++ }
1556 ++ else {
1557 ++ name = sec_name(sym->st_shndx);
1558 ++ }
1559 ++ return name;
1560 ++}
1561 ++
1562 ++
1563 ++
1564 ++#if BYTE_ORDER == LITTLE_ENDIAN
1565 ++#define le16_to_cpu(val) (val)
1566 ++#define le32_to_cpu(val) (val)
1567 ++#endif
1568 ++#if BYTE_ORDER == BIG_ENDIAN
1569 ++#define le16_to_cpu(val) bswap_16(val)
1570 ++#define le32_to_cpu(val) bswap_32(val)
1571 ++#endif
1572 ++
1573 ++static uint16_t elf16_to_cpu(uint16_t val)
1574 ++{
1575 ++ return le16_to_cpu(val);
1576 ++}
1577 ++
1578 ++static uint32_t elf32_to_cpu(uint32_t val)
1579 ++{
1580 ++ return le32_to_cpu(val);
1581 ++}
1582 ++
1583 ++static void read_ehdr(FILE *fp)
1584 ++{
1585 ++ if (fread(&ehdr, sizeof(ehdr), 1, fp) != 1) {
1586 ++ die("Cannot read ELF header: %s\n",
1587 ++ strerror(errno));
1588 ++ }
1589 ++ if (memcmp(ehdr.e_ident, ELFMAG, SELFMAG) != 0) {
1590 ++ die("No ELF magic\n");
1591 ++ }
1592 ++ if (ehdr.e_ident[EI_CLASS] != ELFCLASS32) {
1593 ++ die("Not a 32 bit executable\n");
1594 ++ }
1595 ++ if (ehdr.e_ident[EI_DATA] != ELFDATA2LSB) {
1596 ++ die("Not a LSB ELF executable\n");
1597 ++ }
1598 ++ if (ehdr.e_ident[EI_VERSION] != EV_CURRENT) {
1599 ++ die("Unknown ELF version\n");
1600 ++ }
1601 ++ /* Convert the fields to native endian */
1602 ++ ehdr.e_type = elf16_to_cpu(ehdr.e_type);
1603 ++ ehdr.e_machine = elf16_to_cpu(ehdr.e_machine);
1604 ++ ehdr.e_version = elf32_to_cpu(ehdr.e_version);
1605 ++ ehdr.e_entry = elf32_to_cpu(ehdr.e_entry);
1606 ++ ehdr.e_phoff = elf32_to_cpu(ehdr.e_phoff);
1607 ++ ehdr.e_shoff = elf32_to_cpu(ehdr.e_shoff);
1608 ++ ehdr.e_flags = elf32_to_cpu(ehdr.e_flags);
1609 ++ ehdr.e_ehsize = elf16_to_cpu(ehdr.e_ehsize);
1610 ++ ehdr.e_phentsize = elf16_to_cpu(ehdr.e_phentsize);
1611 ++ ehdr.e_phnum = elf16_to_cpu(ehdr.e_phnum);
1612 ++ ehdr.e_shentsize = elf16_to_cpu(ehdr.e_shentsize);
1613 ++ ehdr.e_shnum = elf16_to_cpu(ehdr.e_shnum);
1614 ++ ehdr.e_shstrndx = elf16_to_cpu(ehdr.e_shstrndx);
1615 ++
1616 ++ if ((ehdr.e_type != ET_EXEC) && (ehdr.e_type != ET_DYN)) {
1617 ++ die("Unsupported ELF header type\n");
1618 ++ }
1619 ++ if (ehdr.e_machine != EM_386) {
1620 ++ die("Not for x86\n");
1621 ++ }
1622 ++ if (ehdr.e_version != EV_CURRENT) {
1623 ++ die("Unknown ELF version\n");
1624 ++ }
1625 ++ if (ehdr.e_ehsize != sizeof(Elf32_Ehdr)) {
1626 ++ die("Bad Elf header size\n");
1627 ++ }
1628 ++ if (ehdr.e_phentsize != sizeof(Elf32_Phdr)) {
1629 ++ die("Bad program header entry\n");
1630 ++ }
1631 ++ if (ehdr.e_shentsize != sizeof(Elf32_Shdr)) {
1632 ++ die("Bad section header entry\n");
1633 ++ }
1634 ++ if (ehdr.e_shstrndx >= ehdr.e_shnum) {
1635 ++ die("String table index out of bounds\n");
1636 ++ }
1637 ++}
1638 ++
1639 ++static void read_shdrs(FILE *fp)
1640 ++{
1641 ++ int i;
1642 ++ Elf32_Shdr shdr;
1643 ++
1644 ++ secs = calloc(ehdr.e_shnum, sizeof(struct section));
1645 ++ if (!secs) {
1646 ++ die("Unable to allocate %d section headers\n",
1647 ++ ehdr.e_shnum);
1648 ++ }
1649 ++ if (fseek(fp, ehdr.e_shoff, SEEK_SET) < 0) {
1650 ++ die("Seek to %d failed: %s\n",
1651 ++ ehdr.e_shoff, strerror(errno));
1652 ++ }
1653 ++ for (i = 0; i < ehdr.e_shnum; i++) {
1654 ++ struct section *sec = &secs[i];
1655 ++ if (fread(&shdr, sizeof shdr, 1, fp) != 1)
1656 ++ die("Cannot read ELF section headers %d/%d: %s\n",
1657 ++ i, ehdr.e_shnum, strerror(errno));
1658 ++ sec->shdr.sh_name = elf32_to_cpu(shdr.sh_name);
1659 ++ sec->shdr.sh_type = elf32_to_cpu(shdr.sh_type);
1660 ++ sec->shdr.sh_flags = elf32_to_cpu(shdr.sh_flags);
1661 ++ sec->shdr.sh_addr = elf32_to_cpu(shdr.sh_addr);
1662 ++ sec->shdr.sh_offset = elf32_to_cpu(shdr.sh_offset);
1663 ++ sec->shdr.sh_size = elf32_to_cpu(shdr.sh_size);
1664 ++ sec->shdr.sh_link = elf32_to_cpu(shdr.sh_link);
1665 ++ sec->shdr.sh_info = elf32_to_cpu(shdr.sh_info);
1666 ++ sec->shdr.sh_addralign = elf32_to_cpu(shdr.sh_addralign);
1667 ++ sec->shdr.sh_entsize = elf32_to_cpu(shdr.sh_entsize);
1668 ++ if (sec->shdr.sh_link < ehdr.e_shnum)
1669 ++ sec->link = &secs[sec->shdr.sh_link];
1670 ++ }
1671 ++
1672 ++}
1673 ++
1674 ++static void read_strtabs(FILE *fp)
1675 ++{
1676 ++ int i;
1677 ++ for (i = 0; i < ehdr.e_shnum; i++) {
1678 ++ struct section *sec = &secs[i];
1679 ++ if (sec->shdr.sh_type != SHT_STRTAB) {
1680 ++ continue;
1681 ++ }
1682 ++ sec->strtab = malloc(sec->shdr.sh_size);
1683 ++ if (!sec->strtab) {
1684 ++ die("malloc of %d bytes for strtab failed\n",
1685 ++ sec->shdr.sh_size);
1686 ++ }
1687 ++ if (fseek(fp, sec->shdr.sh_offset, SEEK_SET) < 0) {
1688 ++ die("Seek to %d failed: %s\n",
1689 ++ sec->shdr.sh_offset, strerror(errno));
1690 ++ }
1691 ++ if (fread(sec->strtab, 1, sec->shdr.sh_size, fp)
1692 ++ != sec->shdr.sh_size) {
1693 ++ die("Cannot read symbol table: %s\n",
1694 ++ strerror(errno));
1695 ++ }
1696 ++ }
1697 ++}
1698 ++
1699 ++static void read_symtabs(FILE *fp)
1700 ++{
1701 ++ int i,j;
1702 ++ for (i = 0; i < ehdr.e_shnum; i++) {
1703 ++ struct section *sec = &secs[i];
1704 ++ if (sec->shdr.sh_type != SHT_SYMTAB) {
1705 ++ continue;
1706 ++ }
1707 ++ sec->symtab = malloc(sec->shdr.sh_size);
1708 ++ if (!sec->symtab) {
1709 ++ die("malloc of %d bytes for symtab failed\n",
1710 ++ sec->shdr.sh_size);
1711 ++ }
1712 ++ if (fseek(fp, sec->shdr.sh_offset, SEEK_SET) < 0) {
1713 ++ die("Seek to %d failed: %s\n",
1714 ++ sec->shdr.sh_offset, strerror(errno));
1715 ++ }
1716 ++ if (fread(sec->symtab, 1, sec->shdr.sh_size, fp)
1717 ++ != sec->shdr.sh_size) {
1718 ++ die("Cannot read symbol table: %s\n",
1719 ++ strerror(errno));
1720 ++ }
1721 ++ for (j = 0; j < sec->shdr.sh_size/sizeof(Elf32_Sym); j++) {
1722 ++ Elf32_Sym *sym = &sec->symtab[j];
1723 ++ sym->st_name = elf32_to_cpu(sym->st_name);
1724 ++ sym->st_value = elf32_to_cpu(sym->st_value);
1725 ++ sym->st_size = elf32_to_cpu(sym->st_size);
1726 ++ sym->st_shndx = elf16_to_cpu(sym->st_shndx);
1727 ++ }
1728 ++ }
1729 ++}
1730 ++
1731 ++
1732 ++static void read_relocs(FILE *fp)
1733 ++{
1734 ++ int i,j;
1735 ++ for (i = 0; i < ehdr.e_shnum; i++) {
1736 ++ struct section *sec = &secs[i];
1737 ++ if (sec->shdr.sh_type != SHT_REL) {
1738 ++ continue;
1739 ++ }
1740 ++ sec->reltab = malloc(sec->shdr.sh_size);
1741 ++ if (!sec->reltab) {
1742 ++ die("malloc of %d bytes for relocs failed\n",
1743 ++ sec->shdr.sh_size);
1744 ++ }
1745 ++ if (fseek(fp, sec->shdr.sh_offset, SEEK_SET) < 0) {
1746 ++ die("Seek to %d failed: %s\n",
1747 ++ sec->shdr.sh_offset, strerror(errno));
1748 ++ }
1749 ++ if (fread(sec->reltab, 1, sec->shdr.sh_size, fp)
1750 ++ != sec->shdr.sh_size) {
1751 ++ die("Cannot read symbol table: %s\n",
1752 ++ strerror(errno));
1753 ++ }
1754 ++ for (j = 0; j < sec->shdr.sh_size/sizeof(Elf32_Rel); j++) {
1755 ++ Elf32_Rel *rel = &sec->reltab[j];
1756 ++ rel->r_offset = elf32_to_cpu(rel->r_offset);
1757 ++ rel->r_info = elf32_to_cpu(rel->r_info);
1758 ++ }
1759 ++ }
1760 ++}
1761 ++
1762 ++
1763 ++static void print_absolute_symbols(void)
1764 ++{
1765 ++ int i;
1766 ++ printf("Absolute symbols\n");
1767 ++ printf(" Num: Value Size Type Bind Visibility Name\n");
1768 ++ for (i = 0; i < ehdr.e_shnum; i++) {
1769 ++ struct section *sec = &secs[i];
1770 ++ char *sym_strtab;
1771 ++ int j;
1772 ++
1773 ++ if (sec->shdr.sh_type != SHT_SYMTAB) {
1774 ++ continue;
1775 ++ }
1776 ++ sym_strtab = sec->link->strtab;
1777 ++ for (j = 0; j < sec->shdr.sh_size/sizeof(Elf32_Sym); j++) {
1778 ++ Elf32_Sym *sym;
1779 ++ const char *name;
1780 ++ sym = &sec->symtab[j];
1781 ++ name = sym_name(sym_strtab, sym);
1782 ++ if (sym->st_shndx != SHN_ABS) {
1783 ++ continue;
1784 ++ }
1785 ++ printf("%5d %08x %5d %10s %10s %12s %s\n",
1786 ++ j, sym->st_value, sym->st_size,
1787 ++ sym_type(ELF32_ST_TYPE(sym->st_info)),
1788 ++ sym_bind(ELF32_ST_BIND(sym->st_info)),
1789 ++ sym_visibility(ELF32_ST_VISIBILITY(sym->st_other)),
1790 ++ name);
1791 ++ }
1792 ++ }
1793 ++ printf("\n");
1794 ++}
1795 ++
1796 ++static void print_absolute_relocs(void)
1797 ++{
1798 ++ int i, printed = 0;
1799 ++
1800 ++ for (i = 0; i < ehdr.e_shnum; i++) {
1801 ++ struct section *sec = &secs[i];
1802 ++ struct section *sec_applies, *sec_symtab;
1803 ++ char *sym_strtab;
1804 ++ Elf32_Sym *sh_symtab;
1805 ++ int j;
1806 ++ if (sec->shdr.sh_type != SHT_REL) {
1807 ++ continue;
1808 ++ }
1809 ++ sec_symtab = sec->link;
1810 ++ sec_applies = &secs[sec->shdr.sh_info];
1811 ++ if (!(sec_applies->shdr.sh_flags & SHF_ALLOC)) {
1812 ++ continue;
1813 ++ }
1814 ++ sh_symtab = sec_symtab->symtab;
1815 ++ sym_strtab = sec_symtab->link->strtab;
1816 ++ for (j = 0; j < sec->shdr.sh_size/sizeof(Elf32_Rel); j++) {
1817 ++ Elf32_Rel *rel;
1818 ++ Elf32_Sym *sym;
1819 ++ const char *name;
1820 ++ rel = &sec->reltab[j];
1821 ++ sym = &sh_symtab[ELF32_R_SYM(rel->r_info)];
1822 ++ name = sym_name(sym_strtab, sym);
1823 ++ if (sym->st_shndx != SHN_ABS) {
1824 ++ continue;
1825 ++ }
1826 ++
1827 ++ /* Absolute symbols are not relocated if bzImage is
1828 ++ * loaded at a non-compiled address. Display a warning
1829 ++ * to user at compile time about the absolute
1830 ++ * relocations present.
1831 ++ *
1832 ++ * User need to audit the code to make sure
1833 ++ * some symbols which should have been section
1834 ++ * relative have not become absolute because of some
1835 ++ * linker optimization or wrong programming usage.
1836 ++ *
1837 ++ * Before warning check if this absolute symbol
1838 ++ * relocation is harmless.
1839 ++ */
1840 ++ if (is_reloc(S_ABS, name) || is_reloc(S_REL, name))
1841 ++ continue;
1842 ++
1843 ++ if (!printed) {
1844 ++ printf("WARNING: Absolute relocations"
1845 ++ " present\n");
1846 ++ printf("Offset Info Type Sym.Value "
1847 ++ "Sym.Name\n");
1848 ++ printed = 1;
1849 ++ }
1850 ++
1851 ++ printf("%08x %08x %10s %08x %s\n",
1852 ++ rel->r_offset,
1853 ++ rel->r_info,
1854 ++ rel_type(ELF32_R_TYPE(rel->r_info)),
1855 ++ sym->st_value,
1856 ++ name);
1857 ++ }
1858 ++ }
1859 ++
1860 ++ if (printed)
1861 ++ printf("\n");
1862 ++}
1863 ++
1864 ++static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym),
1865 ++ int use_real_mode)
1866 ++{
1867 ++ int i;
1868 ++ /* Walk through the relocations */
1869 ++ for (i = 0; i < ehdr.e_shnum; i++) {
1870 ++ char *sym_strtab;
1871 ++ Elf32_Sym *sh_symtab;
1872 ++ struct section *sec_applies, *sec_symtab;
1873 ++ int j;
1874 ++ struct section *sec = &secs[i];
1875 ++
1876 ++ if (sec->shdr.sh_type != SHT_REL) {
1877 ++ continue;
1878 ++ }
1879 ++ sec_symtab = sec->link;
1880 ++ sec_applies = &secs[sec->shdr.sh_info];
1881 ++ if (!(sec_applies->shdr.sh_flags & SHF_ALLOC)) {
1882 ++ continue;
1883 ++ }
1884 ++ sh_symtab = sec_symtab->symtab;
1885 ++ sym_strtab = sec_symtab->link->strtab;
1886 ++ for (j = 0; j < sec->shdr.sh_size/sizeof(Elf32_Rel); j++) {
1887 ++ Elf32_Rel *rel;
1888 ++ Elf32_Sym *sym;
1889 ++ unsigned r_type;
1890 ++ const char *symname;
1891 ++ int shn_abs;
1892 ++
1893 ++ rel = &sec->reltab[j];
1894 ++ sym = &sh_symtab[ELF32_R_SYM(rel->r_info)];
1895 ++ r_type = ELF32_R_TYPE(rel->r_info);
1896 ++
1897 ++ shn_abs = sym->st_shndx == SHN_ABS;
1898 ++
1899 ++ switch (r_type) {
1900 ++ case R_386_NONE:
1901 ++ case R_386_PC32:
1902 ++ case R_386_PC16:
1903 ++ case R_386_PC8:
1904 ++ /*
1905 ++ * NONE can be ignored and and PC relative
1906 ++ * relocations don't need to be adjusted.
1907 ++ */
1908 ++ break;
1909 ++
1910 ++ case R_386_16:
1911 ++ symname = sym_name(sym_strtab, sym);
1912 ++ if (!use_real_mode)
1913 ++ goto bad;
1914 ++ if (shn_abs) {
1915 ++ if (is_reloc(S_ABS, symname))
1916 ++ break;
1917 ++ else if (!is_reloc(S_SEG, symname))
1918 ++ goto bad;
1919 ++ } else {
1920 ++ if (is_reloc(S_LIN, symname))
1921 ++ goto bad;
1922 ++ else
1923 ++ break;
1924 ++ }
1925 ++ visit(rel, sym);
1926 ++ break;
1927 ++
1928 ++ case R_386_32:
1929 ++ symname = sym_name(sym_strtab, sym);
1930 ++ if (shn_abs) {
1931 ++ if (is_reloc(S_ABS, symname))
1932 ++ break;
1933 ++ else if (!is_reloc(S_REL, symname))
1934 ++ goto bad;
1935 ++ } else {
1936 ++ if (use_real_mode &&
1937 ++ !is_reloc(S_LIN, symname))
1938 ++ break;
1939 ++ }
1940 ++ visit(rel, sym);
1941 ++ break;
1942 ++ default:
1943 ++ die("Unsupported relocation type: %s (%d)\n",
1944 ++ rel_type(r_type), r_type);
1945 ++ break;
1946 ++ bad:
1947 ++ symname = sym_name(sym_strtab, sym);
1948 ++ die("Invalid %s %s relocation: %s\n",
1949 ++ shn_abs ? "absolute" : "relative",
1950 ++ rel_type(r_type), symname);
1951 ++ }
1952 ++ }
1953 ++ }
1954 ++}
1955 ++
1956 ++static void count_reloc(Elf32_Rel *rel, Elf32_Sym *sym)
1957 ++{
1958 ++ if (ELF32_R_TYPE(rel->r_info) == R_386_16)
1959 ++ reloc16_count++;
1960 ++ else
1961 ++ reloc_count++;
1962 ++}
1963 ++
1964 ++static void collect_reloc(Elf32_Rel *rel, Elf32_Sym *sym)
1965 ++{
1966 ++ /* Remember the address that needs to be adjusted. */
1967 ++ if (ELF32_R_TYPE(rel->r_info) == R_386_16)
1968 ++ relocs16[reloc16_idx++] = rel->r_offset;
1969 ++ else
1970 ++ relocs[reloc_idx++] = rel->r_offset;
1971 ++}
1972 ++
1973 ++static int cmp_relocs(const void *va, const void *vb)
1974 ++{
1975 ++ const unsigned long *a, *b;
1976 ++ a = va; b = vb;
1977 ++ return (*a == *b)? 0 : (*a > *b)? 1 : -1;
1978 ++}
1979 ++
1980 ++static int write32(unsigned int v, FILE *f)
1981 ++{
1982 ++ unsigned char buf[4];
1983 ++
1984 ++ put_unaligned_le32(v, buf);
1985 ++ return fwrite(buf, 1, 4, f) == 4 ? 0 : -1;
1986 ++}
1987 ++
1988 ++static void emit_relocs(int as_text, int use_real_mode)
1989 ++{
1990 ++ int i;
1991 ++ /* Count how many relocations I have and allocate space for them. */
1992 ++ reloc_count = 0;
1993 ++ walk_relocs(count_reloc, use_real_mode);
1994 ++ relocs = malloc(reloc_count * sizeof(relocs[0]));
1995 ++ if (!relocs) {
1996 ++ die("malloc of %d entries for relocs failed\n",
1997 ++ reloc_count);
1998 ++ }
1999 ++
2000 ++ relocs16 = malloc(reloc16_count * sizeof(relocs[0]));
2001 ++ if (!relocs16) {
2002 ++ die("malloc of %d entries for relocs16 failed\n",
2003 ++ reloc16_count);
2004 ++ }
2005 ++ /* Collect up the relocations */
2006 ++ reloc_idx = 0;
2007 ++ walk_relocs(collect_reloc, use_real_mode);
2008 ++
2009 ++ if (reloc16_count && !use_real_mode)
2010 ++ die("Segment relocations found but --realmode not specified\n");
2011 ++
2012 ++ /* Order the relocations for more efficient processing */
2013 ++ qsort(relocs, reloc_count, sizeof(relocs[0]), cmp_relocs);
2014 ++ qsort(relocs16, reloc16_count, sizeof(relocs16[0]), cmp_relocs);
2015 ++
2016 ++ /* Print the relocations */
2017 ++ if (as_text) {
2018 ++ /* Print the relocations in a form suitable that
2019 ++ * gas will like.
2020 ++ */
2021 ++ printf(".section \".data.reloc\",\"a\"\n");
2022 ++ printf(".balign 4\n");
2023 ++ if (use_real_mode) {
2024 ++ printf("\t.long %lu\n", reloc16_count);
2025 ++ for (i = 0; i < reloc16_count; i++)
2026 ++ printf("\t.long 0x%08lx\n", relocs16[i]);
2027 ++ printf("\t.long %lu\n", reloc_count);
2028 ++ for (i = 0; i < reloc_count; i++) {
2029 ++ printf("\t.long 0x%08lx\n", relocs[i]);
2030 ++ }
2031 ++ } else {
2032 ++ /* Print a stop */
2033 ++ printf("\t.long 0x%08lx\n", (unsigned long)0);
2034 ++ for (i = 0; i < reloc_count; i++) {
2035 ++ printf("\t.long 0x%08lx\n", relocs[i]);
2036 ++ }
2037 ++ }
2038 ++
2039 ++ printf("\n");
2040 ++ }
2041 ++ else {
2042 ++ if (use_real_mode) {
2043 ++ write32(reloc16_count, stdout);
2044 ++ for (i = 0; i < reloc16_count; i++)
2045 ++ write32(relocs16[i], stdout);
2046 ++ write32(reloc_count, stdout);
2047 ++
2048 ++ /* Now print each relocation */
2049 ++ for (i = 0; i < reloc_count; i++)
2050 ++ write32(relocs[i], stdout);
2051 ++ } else {
2052 ++ /* Print a stop */
2053 ++ write32(0, stdout);
2054 ++
2055 ++ /* Now print each relocation */
2056 ++ for (i = 0; i < reloc_count; i++) {
2057 ++ write32(relocs[i], stdout);
2058 ++ }
2059 ++ }
2060 ++ }
2061 ++}
2062 ++
2063 ++static void usage(void)
2064 ++{
2065 ++ die("relocs [--abs-syms|--abs-relocs|--text|--realmode] vmlinux\n");
2066 ++}
2067 ++
2068 ++int main(int argc, char **argv)
2069 ++{
2070 ++ int show_absolute_syms, show_absolute_relocs;
2071 ++ int as_text, use_real_mode;
2072 ++ const char *fname;
2073 ++ FILE *fp;
2074 ++ int i;
2075 ++
2076 ++ show_absolute_syms = 0;
2077 ++ show_absolute_relocs = 0;
2078 ++ as_text = 0;
2079 ++ use_real_mode = 0;
2080 ++ fname = NULL;
2081 ++ for (i = 1; i < argc; i++) {
2082 ++ char *arg = argv[i];
2083 ++ if (*arg == '-') {
2084 ++ if (strcmp(arg, "--abs-syms") == 0) {
2085 ++ show_absolute_syms = 1;
2086 ++ continue;
2087 ++ }
2088 ++ if (strcmp(arg, "--abs-relocs") == 0) {
2089 ++ show_absolute_relocs = 1;
2090 ++ continue;
2091 ++ }
2092 ++ if (strcmp(arg, "--text") == 0) {
2093 ++ as_text = 1;
2094 ++ continue;
2095 ++ }
2096 ++ if (strcmp(arg, "--realmode") == 0) {
2097 ++ use_real_mode = 1;
2098 ++ continue;
2099 ++ }
2100 ++ }
2101 ++ else if (!fname) {
2102 ++ fname = arg;
2103 ++ continue;
2104 ++ }
2105 ++ usage();
2106 ++ }
2107 ++ if (!fname) {
2108 ++ usage();
2109 ++ }
2110 ++ regex_init(use_real_mode);
2111 ++ fp = fopen(fname, "r");
2112 ++ if (!fp) {
2113 ++ die("Cannot open %s: %s\n",
2114 ++ fname, strerror(errno));
2115 ++ }
2116 ++ read_ehdr(fp);
2117 ++ read_shdrs(fp);
2118 ++ read_strtabs(fp);
2119 ++ read_symtabs(fp);
2120 ++ read_relocs(fp);
2121 ++ if (show_absolute_syms) {
2122 ++ print_absolute_symbols();
2123 ++ return 0;
2124 ++ }
2125 ++ if (show_absolute_relocs) {
2126 ++ print_absolute_relocs();
2127 ++ return 0;
2128 ++ }
2129 ++ emit_relocs(as_text, use_real_mode);
2130 ++ return 0;
2131 ++}
2132 +diff --git a/block/genhd.c b/block/genhd.c
2133 +index df9816e..9cf5583 100644
2134 +--- a/block/genhd.c
2135 ++++ b/block/genhd.c
2136 +@@ -743,7 +743,7 @@ void __init printk_all_partitions(void)
2137 + struct hd_struct *part;
2138 + char name_buf[BDEVNAME_SIZE];
2139 + char devt_buf[BDEVT_SIZE];
2140 +- u8 uuid[PARTITION_META_INFO_UUIDLTH * 2 + 1];
2141 ++ char uuid_buf[PARTITION_META_INFO_UUIDLTH * 2 + 5];
2142 +
2143 + /*
2144 + * Don't show empty devices or things that have been
2145 +@@ -762,14 +762,16 @@ void __init printk_all_partitions(void)
2146 + while ((part = disk_part_iter_next(&piter))) {
2147 + bool is_part0 = part == &disk->part0;
2148 +
2149 +- uuid[0] = 0;
2150 ++ uuid_buf[0] = '\0';
2151 + if (part->info)
2152 +- part_unpack_uuid(part->info->uuid, uuid);
2153 ++ snprintf(uuid_buf, sizeof(uuid_buf), "%pU",
2154 ++ part->info->uuid);
2155 +
2156 + printk("%s%s %10llu %s %s", is_part0 ? "" : " ",
2157 + bdevt_str(part_devt(part), devt_buf),
2158 + (unsigned long long)part->nr_sects >> 1,
2159 +- disk_name(disk, part->partno, name_buf), uuid);
2160 ++ disk_name(disk, part->partno, name_buf),
2161 ++ uuid_buf);
2162 + if (is_part0) {
2163 + if (disk->driverfs_dev != NULL &&
2164 + disk->driverfs_dev->driver != NULL)
2165 +diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
2166 +index ddeb845..ea7ef70 100644
2167 +--- a/drivers/ata/ahci.c
2168 ++++ b/drivers/ata/ahci.c
2169 +@@ -386,6 +386,8 @@ static const struct pci_device_id ahci_pci_tbl[] = {
2170 + .driver_data = board_ahci_yes_fbs }, /* 88se9128 */
2171 + { PCI_DEVICE(0x1b4b, 0x9125),
2172 + .driver_data = board_ahci_yes_fbs }, /* 88se9125 */
2173 ++ { PCI_DEVICE(0x1b4b, 0x917a),
2174 ++ .driver_data = board_ahci_yes_fbs }, /* 88se9172 */
2175 + { PCI_DEVICE(0x1b4b, 0x91a3),
2176 + .driver_data = board_ahci_yes_fbs },
2177 +
2178 +diff --git a/drivers/ata/libata-transport.c b/drivers/ata/libata-transport.c
2179 +index 74aaee3..c341904 100644
2180 +--- a/drivers/ata/libata-transport.c
2181 ++++ b/drivers/ata/libata-transport.c
2182 +@@ -294,6 +294,7 @@ int ata_tport_add(struct device *parent,
2183 + device_enable_async_suspend(dev);
2184 + pm_runtime_set_active(dev);
2185 + pm_runtime_enable(dev);
2186 ++ pm_runtime_forbid(dev);
2187 +
2188 + transport_add_device(dev);
2189 + transport_configure_device(dev);
2190 +diff --git a/drivers/gpio/gpio-mpc8xxx.c b/drivers/gpio/gpio-mpc8xxx.c
2191 +index 5cd04b6..edcffd6 100644
2192 +--- a/drivers/gpio/gpio-mpc8xxx.c
2193 ++++ b/drivers/gpio/gpio-mpc8xxx.c
2194 +@@ -163,7 +163,8 @@ static void mpc8xxx_gpio_irq_cascade(unsigned int irq, struct irq_desc *desc)
2195 + if (mask)
2196 + generic_handle_irq(irq_linear_revmap(mpc8xxx_gc->irq,
2197 + 32 - ffs(mask)));
2198 +- chip->irq_eoi(&desc->irq_data);
2199 ++ if (chip->irq_eoi)
2200 ++ chip->irq_eoi(&desc->irq_data);
2201 + }
2202 +
2203 + static void mpc8xxx_irq_unmask(struct irq_data *d)
2204 +diff --git a/drivers/gpu/drm/gma500/psb_device.c b/drivers/gpu/drm/gma500/psb_device.c
2205 +index e5f5906..9bbb733 100644
2206 +--- a/drivers/gpu/drm/gma500/psb_device.c
2207 ++++ b/drivers/gpu/drm/gma500/psb_device.c
2208 +@@ -196,7 +196,8 @@ static int psb_save_display_registers(struct drm_device *dev)
2209 + }
2210 +
2211 + list_for_each_entry(connector, &dev->mode_config.connector_list, head)
2212 +- connector->funcs->save(connector);
2213 ++ if (connector->funcs->save)
2214 ++ connector->funcs->save(connector);
2215 +
2216 + mutex_unlock(&dev->mode_config.mutex);
2217 + return 0;
2218 +@@ -233,7 +234,8 @@ static int psb_restore_display_registers(struct drm_device *dev)
2219 + crtc->funcs->restore(crtc);
2220 +
2221 + list_for_each_entry(connector, &dev->mode_config.connector_list, head)
2222 +- connector->funcs->restore(connector);
2223 ++ if (connector->funcs->restore)
2224 ++ connector->funcs->restore(connector);
2225 +
2226 + mutex_unlock(&dev->mode_config.mutex);
2227 + return 0;
2228 +diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
2229 +index 5bd4361..307c5e6 100644
2230 +--- a/drivers/gpu/drm/i915/i915_irq.c
2231 ++++ b/drivers/gpu/drm/i915/i915_irq.c
2232 +@@ -424,14 +424,11 @@ static void gen6_pm_rps_work(struct work_struct *work)
2233 + mutex_unlock(&dev_priv->dev->struct_mutex);
2234 + }
2235 +
2236 +-static void pch_irq_handler(struct drm_device *dev)
2237 ++static void pch_irq_handler(struct drm_device *dev, u32 pch_iir)
2238 + {
2239 + drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
2240 +- u32 pch_iir;
2241 + int pipe;
2242 +
2243 +- pch_iir = I915_READ(SDEIIR);
2244 +-
2245 + if (pch_iir & SDE_AUDIO_POWER_MASK)
2246 + DRM_DEBUG_DRIVER("PCH audio power change on port %d\n",
2247 + (pch_iir & SDE_AUDIO_POWER_MASK) >>
2248 +@@ -529,7 +526,7 @@ static irqreturn_t ivybridge_irq_handler(DRM_IRQ_ARGS)
2249 + if (de_iir & DE_PCH_EVENT_IVB) {
2250 + if (pch_iir & SDE_HOTPLUG_MASK_CPT)
2251 + queue_work(dev_priv->wq, &dev_priv->hotplug_work);
2252 +- pch_irq_handler(dev);
2253 ++ pch_irq_handler(dev, pch_iir);
2254 + }
2255 +
2256 + if (pm_iir & GEN6_PM_DEFERRED_EVENTS) {
2257 +@@ -629,7 +626,7 @@ static irqreturn_t ironlake_irq_handler(DRM_IRQ_ARGS)
2258 + if (de_iir & DE_PCH_EVENT) {
2259 + if (pch_iir & hotplug_mask)
2260 + queue_work(dev_priv->wq, &dev_priv->hotplug_work);
2261 +- pch_irq_handler(dev);
2262 ++ pch_irq_handler(dev, pch_iir);
2263 + }
2264 +
2265 + if (de_iir & DE_PCU_EVENT) {
2266 +diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
2267 +index ac38d21..c0fdc31 100644
2268 +--- a/drivers/gpu/drm/i915/i915_reg.h
2269 ++++ b/drivers/gpu/drm/i915/i915_reg.h
2270 +@@ -570,6 +570,21 @@
2271 +
2272 + #define GEN6_BSD_RNCID 0x12198
2273 +
2274 ++#define GEN7_FF_THREAD_MODE 0x20a0
2275 ++#define GEN7_FF_SCHED_MASK 0x0077070
2276 ++#define GEN7_FF_TS_SCHED_HS1 (0x5<<16)
2277 ++#define GEN7_FF_TS_SCHED_HS0 (0x3<<16)
2278 ++#define GEN7_FF_TS_SCHED_LOAD_BALANCE (0x1<<16)
2279 ++#define GEN7_FF_TS_SCHED_HW (0x0<<16) /* Default */
2280 ++#define GEN7_FF_VS_SCHED_HS1 (0x5<<12)
2281 ++#define GEN7_FF_VS_SCHED_HS0 (0x3<<12)
2282 ++#define GEN7_FF_VS_SCHED_LOAD_BALANCE (0x1<<12) /* Default */
2283 ++#define GEN7_FF_VS_SCHED_HW (0x0<<12)
2284 ++#define GEN7_FF_DS_SCHED_HS1 (0x5<<4)
2285 ++#define GEN7_FF_DS_SCHED_HS0 (0x3<<4)
2286 ++#define GEN7_FF_DS_SCHED_LOAD_BALANCE (0x1<<4) /* Default */
2287 ++#define GEN7_FF_DS_SCHED_HW (0x0<<4)
2288 ++
2289 + /*
2290 + * Framebuffer compression (915+ only)
2291 + */
2292 +diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
2293 +index 2163818..9ab9b16 100644
2294 +--- a/drivers/gpu/drm/i915/intel_display.c
2295 ++++ b/drivers/gpu/drm/i915/intel_display.c
2296 +@@ -7496,10 +7496,11 @@ static void intel_sanitize_modesetting(struct drm_device *dev,
2297 + {
2298 + struct drm_i915_private *dev_priv = dev->dev_private;
2299 + u32 reg, val;
2300 ++ int i;
2301 +
2302 + /* Clear any frame start delays used for debugging left by the BIOS */
2303 +- for_each_pipe(pipe) {
2304 +- reg = PIPECONF(pipe);
2305 ++ for_each_pipe(i) {
2306 ++ reg = PIPECONF(i);
2307 + I915_WRITE(reg, I915_READ(reg) & ~PIPECONF_FRAME_START_DELAY_MASK);
2308 + }
2309 +
2310 +@@ -8467,6 +8468,18 @@ static void gen6_init_clock_gating(struct drm_device *dev)
2311 + }
2312 + }
2313 +
2314 ++static void gen7_setup_fixed_func_scheduler(struct drm_i915_private *dev_priv)
2315 ++{
2316 ++ uint32_t reg = I915_READ(GEN7_FF_THREAD_MODE);
2317 ++
2318 ++ reg &= ~GEN7_FF_SCHED_MASK;
2319 ++ reg |= GEN7_FF_TS_SCHED_HW;
2320 ++ reg |= GEN7_FF_VS_SCHED_HW;
2321 ++ reg |= GEN7_FF_DS_SCHED_HW;
2322 ++
2323 ++ I915_WRITE(GEN7_FF_THREAD_MODE, reg);
2324 ++}
2325 ++
2326 + static void ivybridge_init_clock_gating(struct drm_device *dev)
2327 + {
2328 + struct drm_i915_private *dev_priv = dev->dev_private;
2329 +@@ -8511,6 +8524,8 @@ static void ivybridge_init_clock_gating(struct drm_device *dev)
2330 + DISPPLANE_TRICKLE_FEED_DISABLE);
2331 + intel_flush_display_plane(dev_priv, pipe);
2332 + }
2333 ++
2334 ++ gen7_setup_fixed_func_scheduler(dev_priv);
2335 + }
2336 +
2337 + static void g4x_init_clock_gating(struct drm_device *dev)
2338 +diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
2339 +index ec54364..b1d919f 100644
2340 +--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
2341 ++++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
2342 +@@ -1035,7 +1035,7 @@ nouveau_ttm_fault_reserve_notify(struct ttm_buffer_object *bo)
2343 +
2344 + nvbo->placement.fpfn = 0;
2345 + nvbo->placement.lpfn = dev_priv->fb_mappable_pages;
2346 +- nouveau_bo_placement_set(nvbo, TTM_PL_VRAM, 0);
2347 ++ nouveau_bo_placement_set(nvbo, TTM_PL_FLAG_VRAM, 0);
2348 + return nouveau_bo_validate(nvbo, false, true, false);
2349 + }
2350 +
2351 +diff --git a/drivers/hid/hid-logitech-dj.c b/drivers/hid/hid-logitech-dj.c
2352 +index 38b12e4..2eac8c5 100644
2353 +--- a/drivers/hid/hid-logitech-dj.c
2354 ++++ b/drivers/hid/hid-logitech-dj.c
2355 +@@ -26,6 +26,7 @@
2356 + #include <linux/hid.h>
2357 + #include <linux/module.h>
2358 + #include <linux/usb.h>
2359 ++#include <asm/unaligned.h>
2360 + #include "usbhid/usbhid.h"
2361 + #include "hid-ids.h"
2362 + #include "hid-logitech-dj.h"
2363 +@@ -265,8 +266,8 @@ static void logi_dj_recv_add_djhid_device(struct dj_receiver_dev *djrcv_dev,
2364 + goto dj_device_allocate_fail;
2365 + }
2366 +
2367 +- dj_dev->reports_supported = le32_to_cpu(
2368 +- dj_report->report_params[DEVICE_PAIRED_RF_REPORT_TYPE]);
2369 ++ dj_dev->reports_supported = get_unaligned_le32(
2370 ++ dj_report->report_params + DEVICE_PAIRED_RF_REPORT_TYPE);
2371 + dj_dev->hdev = dj_hiddev;
2372 + dj_dev->dj_receiver_dev = djrcv_dev;
2373 + dj_dev->device_index = dj_report->device_index;
2374 +diff --git a/drivers/hid/hid-wiimote-core.c b/drivers/hid/hid-wiimote-core.c
2375 +index cac3589..84e2fbe 100644
2376 +--- a/drivers/hid/hid-wiimote-core.c
2377 ++++ b/drivers/hid/hid-wiimote-core.c
2378 +@@ -769,7 +769,7 @@ static void __ir_to_input(struct wiimote_data *wdata, const __u8 *ir,
2379 +
2380 + /*
2381 + * Basic IR data is encoded into 3 bytes. The first two bytes are the
2382 +- * upper 8 bit of the X/Y data, the 3rd byte contains the lower 2 bits
2383 ++ * lower 8 bit of the X/Y data, the 3rd byte contains the upper 2 bits
2384 + * of both.
2385 + * If data is packed, then the 3rd byte is put first and slightly
2386 + * reordered. This allows to interleave packed and non-packed data to
2387 +@@ -778,17 +778,11 @@ static void __ir_to_input(struct wiimote_data *wdata, const __u8 *ir,
2388 + */
2389 +
2390 + if (packed) {
2391 +- x = ir[1] << 2;
2392 +- y = ir[2] << 2;
2393 +-
2394 +- x |= ir[0] & 0x3;
2395 +- y |= (ir[0] >> 2) & 0x3;
2396 ++ x = ir[1] | ((ir[0] & 0x03) << 8);
2397 ++ y = ir[2] | ((ir[0] & 0x0c) << 6);
2398 + } else {
2399 +- x = ir[0] << 2;
2400 +- y = ir[1] << 2;
2401 +-
2402 +- x |= (ir[2] >> 4) & 0x3;
2403 +- y |= (ir[2] >> 6) & 0x3;
2404 ++ x = ir[0] | ((ir[2] & 0x30) << 4);
2405 ++ y = ir[1] | ((ir[2] & 0xc0) << 2);
2406 + }
2407 +
2408 + input_report_abs(wdata->ir, xid, x);
2409 +diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
2410 +index 5bf91db..4bbb883 100644
2411 +--- a/drivers/hid/usbhid/hid-core.c
2412 ++++ b/drivers/hid/usbhid/hid-core.c
2413 +@@ -399,6 +399,16 @@ static int hid_submit_ctrl(struct hid_device *hid)
2414 + * Output interrupt completion handler.
2415 + */
2416 +
2417 ++static int irq_out_pump_restart(struct hid_device *hid)
2418 ++{
2419 ++ struct usbhid_device *usbhid = hid->driver_data;
2420 ++
2421 ++ if (usbhid->outhead != usbhid->outtail)
2422 ++ return hid_submit_out(hid);
2423 ++ else
2424 ++ return -1;
2425 ++}
2426 ++
2427 + static void hid_irq_out(struct urb *urb)
2428 + {
2429 + struct hid_device *hid = urb->context;
2430 +@@ -428,7 +438,7 @@ static void hid_irq_out(struct urb *urb)
2431 + else
2432 + usbhid->outtail = (usbhid->outtail + 1) & (HID_OUTPUT_FIFO_SIZE - 1);
2433 +
2434 +- if (usbhid->outhead != usbhid->outtail && !hid_submit_out(hid)) {
2435 ++ if (!irq_out_pump_restart(hid)) {
2436 + /* Successfully submitted next urb in queue */
2437 + spin_unlock_irqrestore(&usbhid->lock, flags);
2438 + return;
2439 +@@ -443,6 +453,15 @@ static void hid_irq_out(struct urb *urb)
2440 + /*
2441 + * Control pipe completion handler.
2442 + */
2443 ++static int ctrl_pump_restart(struct hid_device *hid)
2444 ++{
2445 ++ struct usbhid_device *usbhid = hid->driver_data;
2446 ++
2447 ++ if (usbhid->ctrlhead != usbhid->ctrltail)
2448 ++ return hid_submit_ctrl(hid);
2449 ++ else
2450 ++ return -1;
2451 ++}
2452 +
2453 + static void hid_ctrl(struct urb *urb)
2454 + {
2455 +@@ -476,7 +495,7 @@ static void hid_ctrl(struct urb *urb)
2456 + else
2457 + usbhid->ctrltail = (usbhid->ctrltail + 1) & (HID_CONTROL_FIFO_SIZE - 1);
2458 +
2459 +- if (usbhid->ctrlhead != usbhid->ctrltail && !hid_submit_ctrl(hid)) {
2460 ++ if (!ctrl_pump_restart(hid)) {
2461 + /* Successfully submitted next urb in queue */
2462 + spin_unlock(&usbhid->lock);
2463 + return;
2464 +@@ -535,11 +554,27 @@ static void __usbhid_submit_report(struct hid_device *hid, struct hid_report *re
2465 + * the queue is known to run
2466 + * but an earlier request may be stuck
2467 + * we may need to time out
2468 +- * no race because this is called under
2469 ++ * no race because the URB is blocked under
2470 + * spinlock
2471 + */
2472 +- if (time_after(jiffies, usbhid->last_out + HZ * 5))
2473 ++ if (time_after(jiffies, usbhid->last_out + HZ * 5)) {
2474 ++ usb_block_urb(usbhid->urbout);
2475 ++ /* drop lock to not deadlock if the callback is called */
2476 ++ spin_unlock(&usbhid->lock);
2477 + usb_unlink_urb(usbhid->urbout);
2478 ++ spin_lock(&usbhid->lock);
2479 ++ usb_unblock_urb(usbhid->urbout);
2480 ++ /*
2481 ++ * if the unlinking has already completed
2482 ++ * the pump will have been stopped
2483 ++ * it must be restarted now
2484 ++ */
2485 ++ if (!test_bit(HID_OUT_RUNNING, &usbhid->iofl))
2486 ++ if (!irq_out_pump_restart(hid))
2487 ++ set_bit(HID_OUT_RUNNING, &usbhid->iofl);
2488 ++
2489 ++
2490 ++ }
2491 + }
2492 + return;
2493 + }
2494 +@@ -583,11 +618,25 @@ static void __usbhid_submit_report(struct hid_device *hid, struct hid_report *re
2495 + * the queue is known to run
2496 + * but an earlier request may be stuck
2497 + * we may need to time out
2498 +- * no race because this is called under
2499 ++ * no race because the URB is blocked under
2500 + * spinlock
2501 + */
2502 +- if (time_after(jiffies, usbhid->last_ctrl + HZ * 5))
2503 ++ if (time_after(jiffies, usbhid->last_ctrl + HZ * 5)) {
2504 ++ usb_block_urb(usbhid->urbctrl);
2505 ++ /* drop lock to not deadlock if the callback is called */
2506 ++ spin_unlock(&usbhid->lock);
2507 + usb_unlink_urb(usbhid->urbctrl);
2508 ++ spin_lock(&usbhid->lock);
2509 ++ usb_unblock_urb(usbhid->urbctrl);
2510 ++ /*
2511 ++ * if the unlinking has already completed
2512 ++ * the pump will have been stopped
2513 ++ * it must be restarted now
2514 ++ */
2515 ++ if (!test_bit(HID_CTRL_RUNNING, &usbhid->iofl))
2516 ++ if (!ctrl_pump_restart(hid))
2517 ++ set_bit(HID_CTRL_RUNNING, &usbhid->iofl);
2518 ++ }
2519 + }
2520 + }
2521 +
2522 +diff --git a/drivers/i2c/busses/i2c-davinci.c b/drivers/i2c/busses/i2c-davinci.c
2523 +index a76d85f..79b4bcb 100644
2524 +--- a/drivers/i2c/busses/i2c-davinci.c
2525 ++++ b/drivers/i2c/busses/i2c-davinci.c
2526 +@@ -755,7 +755,7 @@ static int davinci_i2c_remove(struct platform_device *pdev)
2527 + dev->clk = NULL;
2528 +
2529 + davinci_i2c_write_reg(dev, DAVINCI_I2C_MDR_REG, 0);
2530 +- free_irq(IRQ_I2C, dev);
2531 ++ free_irq(dev->irq, dev);
2532 + iounmap(dev->base);
2533 + kfree(dev);
2534 +
2535 +diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c
2536 +index 0ab4a95..a54a9c2 100644
2537 +--- a/drivers/i2c/busses/i2c-tegra.c
2538 ++++ b/drivers/i2c/busses/i2c-tegra.c
2539 +@@ -401,8 +401,6 @@ static irqreturn_t tegra_i2c_isr(int irq, void *dev_id)
2540 + disable_irq_nosync(i2c_dev->irq);
2541 + i2c_dev->irq_disabled = 1;
2542 + }
2543 +-
2544 +- complete(&i2c_dev->msg_complete);
2545 + goto err;
2546 + }
2547 +
2548 +@@ -411,7 +409,6 @@ static irqreturn_t tegra_i2c_isr(int irq, void *dev_id)
2549 + i2c_dev->msg_err |= I2C_ERR_NO_ACK;
2550 + if (status & I2C_INT_ARBITRATION_LOST)
2551 + i2c_dev->msg_err |= I2C_ERR_ARBITRATION_LOST;
2552 +- complete(&i2c_dev->msg_complete);
2553 + goto err;
2554 + }
2555 +
2556 +@@ -429,14 +426,14 @@ static irqreturn_t tegra_i2c_isr(int irq, void *dev_id)
2557 + tegra_i2c_mask_irq(i2c_dev, I2C_INT_TX_FIFO_DATA_REQ);
2558 + }
2559 +
2560 ++ i2c_writel(i2c_dev, status, I2C_INT_STATUS);
2561 ++ if (i2c_dev->is_dvc)
2562 ++ dvc_writel(i2c_dev, DVC_STATUS_I2C_DONE_INTR, DVC_STATUS);
2563 ++
2564 + if (status & I2C_INT_PACKET_XFER_COMPLETE) {
2565 + BUG_ON(i2c_dev->msg_buf_remaining);
2566 + complete(&i2c_dev->msg_complete);
2567 + }
2568 +-
2569 +- i2c_writel(i2c_dev, status, I2C_INT_STATUS);
2570 +- if (i2c_dev->is_dvc)
2571 +- dvc_writel(i2c_dev, DVC_STATUS_I2C_DONE_INTR, DVC_STATUS);
2572 + return IRQ_HANDLED;
2573 + err:
2574 + /* An error occurred, mask all interrupts */
2575 +@@ -446,6 +443,8 @@ err:
2576 + i2c_writel(i2c_dev, status, I2C_INT_STATUS);
2577 + if (i2c_dev->is_dvc)
2578 + dvc_writel(i2c_dev, DVC_STATUS_I2C_DONE_INTR, DVC_STATUS);
2579 ++
2580 ++ complete(&i2c_dev->msg_complete);
2581 + return IRQ_HANDLED;
2582 + }
2583 +
2584 +diff --git a/drivers/infiniband/core/umem.c b/drivers/infiniband/core/umem.c
2585 +index 71f0c0f..a841123 100644
2586 +--- a/drivers/infiniband/core/umem.c
2587 ++++ b/drivers/infiniband/core/umem.c
2588 +@@ -269,7 +269,7 @@ void ib_umem_release(struct ib_umem *umem)
2589 + } else
2590 + down_write(&mm->mmap_sem);
2591 +
2592 +- current->mm->locked_vm -= diff;
2593 ++ current->mm->pinned_vm -= diff;
2594 + up_write(&mm->mmap_sem);
2595 + mmput(mm);
2596 + kfree(umem);
2597 +diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c
2598 +index 0668bb3..d48d173 100644
2599 +--- a/drivers/infiniband/hw/cxgb4/cm.c
2600 ++++ b/drivers/infiniband/hw/cxgb4/cm.c
2601 +@@ -1593,7 +1593,7 @@ static int import_ep(struct c4iw_ep *ep, __be32 peer_ip, struct dst_entry *dst,
2602 + n, n->dev, 0);
2603 + if (!ep->l2t)
2604 + goto out;
2605 +- ep->mtu = dst_mtu(ep->dst);
2606 ++ ep->mtu = dst_mtu(dst);
2607 + ep->tx_chan = cxgb4_port_chan(n->dev);
2608 + ep->smac_idx = (cxgb4_port_viid(n->dev) & 0x7F) << 1;
2609 + step = cdev->rdev.lldi.ntxq /
2610 +@@ -2654,6 +2654,12 @@ static int peer_abort_intr(struct c4iw_dev *dev, struct sk_buff *skb)
2611 + unsigned int tid = GET_TID(req);
2612 +
2613 + ep = lookup_tid(t, tid);
2614 ++ if (!ep) {
2615 ++ printk(KERN_WARNING MOD
2616 ++ "Abort on non-existent endpoint, tid %d\n", tid);
2617 ++ kfree_skb(skb);
2618 ++ return 0;
2619 ++ }
2620 + if (is_neg_adv_abort(req->status)) {
2621 + PDBG("%s neg_adv_abort ep %p tid %u\n", __func__, ep,
2622 + ep->hwtid);
2623 +@@ -2665,11 +2671,8 @@ static int peer_abort_intr(struct c4iw_dev *dev, struct sk_buff *skb)
2624 +
2625 + /*
2626 + * Wake up any threads in rdma_init() or rdma_fini().
2627 +- * However, this is not needed if com state is just
2628 +- * MPA_REQ_SENT
2629 + */
2630 +- if (ep->com.state != MPA_REQ_SENT)
2631 +- c4iw_wake_up(&ep->com.wr_wait, -ECONNRESET);
2632 ++ c4iw_wake_up(&ep->com.wr_wait, -ECONNRESET);
2633 + sched(dev, skb);
2634 + return 0;
2635 + }
2636 +diff --git a/drivers/iommu/dmar.c b/drivers/iommu/dmar.c
2637 +index 35c1e17..97b2e21 100644
2638 +--- a/drivers/iommu/dmar.c
2639 ++++ b/drivers/iommu/dmar.c
2640 +@@ -1056,8 +1056,8 @@ static const char *intr_remap_fault_reasons[] =
2641 +
2642 + const char *dmar_get_fault_reason(u8 fault_reason, int *fault_type)
2643 + {
2644 +- if (fault_reason >= 0x20 && (fault_reason <= 0x20 +
2645 +- ARRAY_SIZE(intr_remap_fault_reasons))) {
2646 ++ if (fault_reason >= 0x20 && (fault_reason - 0x20 <
2647 ++ ARRAY_SIZE(intr_remap_fault_reasons))) {
2648 + *fault_type = INTR_REMAP;
2649 + return intr_remap_fault_reasons[fault_reason - 0x20];
2650 + } else if (fault_reason < ARRAY_SIZE(dma_remap_fault_reasons)) {
2651 +diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
2652 +index c9c6053..da50c7e 100644
2653 +--- a/drivers/iommu/intel-iommu.c
2654 ++++ b/drivers/iommu/intel-iommu.c
2655 +@@ -2280,12 +2280,6 @@ static int domain_add_dev_info(struct dmar_domain *domain,
2656 + if (!info)
2657 + return -ENOMEM;
2658 +
2659 +- ret = domain_context_mapping(domain, pdev, translation);
2660 +- if (ret) {
2661 +- free_devinfo_mem(info);
2662 +- return ret;
2663 +- }
2664 +-
2665 + info->segment = pci_domain_nr(pdev->bus);
2666 + info->bus = pdev->bus->number;
2667 + info->devfn = pdev->devfn;
2668 +@@ -2298,6 +2292,17 @@ static int domain_add_dev_info(struct dmar_domain *domain,
2669 + pdev->dev.archdata.iommu = info;
2670 + spin_unlock_irqrestore(&device_domain_lock, flags);
2671 +
2672 ++ ret = domain_context_mapping(domain, pdev, translation);
2673 ++ if (ret) {
2674 ++ spin_lock_irqsave(&device_domain_lock, flags);
2675 ++ list_del(&info->link);
2676 ++ list_del(&info->global);
2677 ++ pdev->dev.archdata.iommu = NULL;
2678 ++ spin_unlock_irqrestore(&device_domain_lock, flags);
2679 ++ free_devinfo_mem(info);
2680 ++ return ret;
2681 ++ }
2682 ++
2683 + return 0;
2684 + }
2685 +
2686 +diff --git a/drivers/isdn/gigaset/capi.c b/drivers/isdn/gigaset/capi.c
2687 +index 6d5ceee..5b80ef7 100644
2688 +--- a/drivers/isdn/gigaset/capi.c
2689 ++++ b/drivers/isdn/gigaset/capi.c
2690 +@@ -14,6 +14,7 @@
2691 + #include "gigaset.h"
2692 + #include <linux/proc_fs.h>
2693 + #include <linux/seq_file.h>
2694 ++#include <linux/ratelimit.h>
2695 + #include <linux/isdn/capilli.h>
2696 + #include <linux/isdn/capicmd.h>
2697 + #include <linux/isdn/capiutil.h>
2698 +@@ -223,10 +224,14 @@ get_appl(struct gigaset_capi_ctr *iif, u16 appl)
2699 + static inline void dump_cmsg(enum debuglevel level, const char *tag, _cmsg *p)
2700 + {
2701 + #ifdef CONFIG_GIGASET_DEBUG
2702 ++ /* dump at most 20 messages in 20 secs */
2703 ++ static DEFINE_RATELIMIT_STATE(msg_dump_ratelimit, 20 * HZ, 20);
2704 + _cdebbuf *cdb;
2705 +
2706 + if (!(gigaset_debuglevel & level))
2707 + return;
2708 ++ if (!___ratelimit(&msg_dump_ratelimit, tag))
2709 ++ return;
2710 +
2711 + cdb = capi_cmsg2str(p);
2712 + if (cdb) {
2713 +@@ -2059,12 +2064,6 @@ static void do_reset_b3_req(struct gigaset_capi_ctr *iif,
2714 + }
2715 +
2716 + /*
2717 +- * dump unsupported/ignored messages at most twice per minute,
2718 +- * some apps send those very frequently
2719 +- */
2720 +-static unsigned long ignored_msg_dump_time;
2721 +-
2722 +-/*
2723 + * unsupported CAPI message handler
2724 + */
2725 + static void do_unsupported(struct gigaset_capi_ctr *iif,
2726 +@@ -2073,8 +2072,7 @@ static void do_unsupported(struct gigaset_capi_ctr *iif,
2727 + {
2728 + /* decode message */
2729 + capi_message2cmsg(&iif->acmsg, skb->data);
2730 +- if (printk_timed_ratelimit(&ignored_msg_dump_time, 30 * 1000))
2731 +- dump_cmsg(DEBUG_CMD, __func__, &iif->acmsg);
2732 ++ dump_cmsg(DEBUG_CMD, __func__, &iif->acmsg);
2733 + send_conf(iif, ap, skb, CapiMessageNotSupportedInCurrentState);
2734 + }
2735 +
2736 +@@ -2085,11 +2083,9 @@ static void do_nothing(struct gigaset_capi_ctr *iif,
2737 + struct gigaset_capi_appl *ap,
2738 + struct sk_buff *skb)
2739 + {
2740 +- if (printk_timed_ratelimit(&ignored_msg_dump_time, 30 * 1000)) {
2741 +- /* decode message */
2742 +- capi_message2cmsg(&iif->acmsg, skb->data);
2743 +- dump_cmsg(DEBUG_CMD, __func__, &iif->acmsg);
2744 +- }
2745 ++ /* decode message */
2746 ++ capi_message2cmsg(&iif->acmsg, skb->data);
2747 ++ dump_cmsg(DEBUG_CMD, __func__, &iif->acmsg);
2748 + dev_kfree_skb_any(skb);
2749 + }
2750 +
2751 +diff --git a/drivers/md/md.c b/drivers/md/md.c
2752 +index 363aaf4..1ae4327 100644
2753 +--- a/drivers/md/md.c
2754 ++++ b/drivers/md/md.c
2755 +@@ -452,7 +452,7 @@ static void submit_flushes(struct work_struct *ws)
2756 + atomic_inc(&rdev->nr_pending);
2757 + atomic_inc(&rdev->nr_pending);
2758 + rcu_read_unlock();
2759 +- bi = bio_alloc_mddev(GFP_KERNEL, 0, mddev);
2760 ++ bi = bio_alloc_mddev(GFP_NOIO, 0, mddev);
2761 + bi->bi_end_io = md_end_flush;
2762 + bi->bi_private = rdev;
2763 + bi->bi_bdev = rdev->bdev;
2764 +diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c
2765 +index 7294bd1..ce454f0 100644
2766 +--- a/drivers/md/raid0.c
2767 ++++ b/drivers/md/raid0.c
2768 +@@ -609,6 +609,7 @@ static void *raid0_takeover_raid10(struct mddev *mddev)
2769 + static void *raid0_takeover_raid1(struct mddev *mddev)
2770 + {
2771 + struct r0conf *priv_conf;
2772 ++ int chunksect;
2773 +
2774 + /* Check layout:
2775 + * - (N - 1) mirror drives must be already faulty
2776 +@@ -619,10 +620,25 @@ static void *raid0_takeover_raid1(struct mddev *mddev)
2777 + return ERR_PTR(-EINVAL);
2778 + }
2779 +
2780 ++ /*
2781 ++ * a raid1 doesn't have the notion of chunk size, so
2782 ++ * figure out the largest suitable size we can use.
2783 ++ */
2784 ++ chunksect = 64 * 2; /* 64K by default */
2785 ++
2786 ++ /* The array must be an exact multiple of chunksize */
2787 ++ while (chunksect && (mddev->array_sectors & (chunksect - 1)))
2788 ++ chunksect >>= 1;
2789 ++
2790 ++ if ((chunksect << 9) < PAGE_SIZE)
2791 ++ /* array size does not allow a suitable chunk size */
2792 ++ return ERR_PTR(-EINVAL);
2793 ++
2794 + /* Set new parameters */
2795 + mddev->new_level = 0;
2796 + mddev->new_layout = 0;
2797 +- mddev->new_chunk_sectors = 128; /* by default set chunk size to 64k */
2798 ++ mddev->new_chunk_sectors = chunksect;
2799 ++ mddev->chunk_sectors = chunksect;
2800 + mddev->delta_disks = 1 - mddev->raid_disks;
2801 + mddev->raid_disks = 1;
2802 + /* make sure it will be not marked as dirty */
2803 +diff --git a/drivers/media/dvb/siano/smsusb.c b/drivers/media/dvb/siano/smsusb.c
2804 +index b1fe513..63c004a 100644
2805 +--- a/drivers/media/dvb/siano/smsusb.c
2806 ++++ b/drivers/media/dvb/siano/smsusb.c
2807 +@@ -542,6 +542,8 @@ static const struct usb_device_id smsusb_id_table[] __devinitconst = {
2808 + .driver_info = SMS1XXX_BOARD_HAUPPAUGE_WINDHAM },
2809 + { USB_DEVICE(0x2040, 0xc090),
2810 + .driver_info = SMS1XXX_BOARD_HAUPPAUGE_WINDHAM },
2811 ++ { USB_DEVICE(0x2040, 0xc0a0),
2812 ++ .driver_info = SMS1XXX_BOARD_HAUPPAUGE_WINDHAM },
2813 + { } /* Terminating entry */
2814 + };
2815 +
2816 +diff --git a/drivers/media/video/uvc/uvc_v4l2.c b/drivers/media/video/uvc/uvc_v4l2.c
2817 +index 2ae4f88..dca9f9b 100644
2818 +--- a/drivers/media/video/uvc/uvc_v4l2.c
2819 ++++ b/drivers/media/video/uvc/uvc_v4l2.c
2820 +@@ -686,7 +686,7 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
2821 + break;
2822 + }
2823 + pin = iterm->id;
2824 +- } else if (pin < selector->bNrInPins) {
2825 ++ } else if (index < selector->bNrInPins) {
2826 + pin = selector->baSourceID[index];
2827 + list_for_each_entry(iterm, &chain->entities, chain) {
2828 + if (!UVC_ENTITY_IS_ITERM(iterm))
2829 +diff --git a/drivers/mmc/core/cd-gpio.c b/drivers/mmc/core/cd-gpio.c
2830 +index 082202a..8c3e6f0 100644
2831 +--- a/drivers/mmc/core/cd-gpio.c
2832 ++++ b/drivers/mmc/core/cd-gpio.c
2833 +@@ -67,6 +67,9 @@ void mmc_cd_gpio_free(struct mmc_host *host)
2834 + {
2835 + struct mmc_cd_gpio *cd = host->hotplug.handler_priv;
2836 +
2837 ++ if (!cd)
2838 ++ return;
2839 ++
2840 + free_irq(host->hotplug.irq, host);
2841 + gpio_free(cd->gpio);
2842 + kfree(cd);
2843 +diff --git a/drivers/mmc/core/sdio.c b/drivers/mmc/core/sdio.c
2844 +index 2c7c83f..13d0e95 100644
2845 +--- a/drivers/mmc/core/sdio.c
2846 ++++ b/drivers/mmc/core/sdio.c
2847 +@@ -947,7 +947,7 @@ static int mmc_sdio_resume(struct mmc_host *host)
2848 + }
2849 +
2850 + if (!err && host->sdio_irqs)
2851 +- mmc_signal_sdio_irq(host);
2852 ++ wake_up_process(host->sdio_irq_thread);
2853 + mmc_release_host(host);
2854 +
2855 + /*
2856 +diff --git a/drivers/mmc/core/sdio_irq.c b/drivers/mmc/core/sdio_irq.c
2857 +index f573e7f..3d8ceb4 100644
2858 +--- a/drivers/mmc/core/sdio_irq.c
2859 ++++ b/drivers/mmc/core/sdio_irq.c
2860 +@@ -28,18 +28,20 @@
2861 +
2862 + #include "sdio_ops.h"
2863 +
2864 +-static int process_sdio_pending_irqs(struct mmc_card *card)
2865 ++static int process_sdio_pending_irqs(struct mmc_host *host)
2866 + {
2867 ++ struct mmc_card *card = host->card;
2868 + int i, ret, count;
2869 + unsigned char pending;
2870 + struct sdio_func *func;
2871 +
2872 + /*
2873 + * Optimization, if there is only 1 function interrupt registered
2874 +- * call irq handler directly
2875 ++ * and we know an IRQ was signaled then call irq handler directly.
2876 ++ * Otherwise do the full probe.
2877 + */
2878 + func = card->sdio_single_irq;
2879 +- if (func) {
2880 ++ if (func && host->sdio_irq_pending) {
2881 + func->irq_handler(func);
2882 + return 1;
2883 + }
2884 +@@ -116,7 +118,8 @@ static int sdio_irq_thread(void *_host)
2885 + ret = __mmc_claim_host(host, &host->sdio_irq_thread_abort);
2886 + if (ret)
2887 + break;
2888 +- ret = process_sdio_pending_irqs(host->card);
2889 ++ ret = process_sdio_pending_irqs(host);
2890 ++ host->sdio_irq_pending = false;
2891 + mmc_release_host(host);
2892 +
2893 + /*
2894 +diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
2895 +index fd0c661..56bbfdd 100644
2896 +--- a/drivers/mmc/host/omap_hsmmc.c
2897 ++++ b/drivers/mmc/host/omap_hsmmc.c
2898 +@@ -2034,7 +2034,7 @@ static int __init omap_hsmmc_probe(struct platform_device *pdev)
2899 + ret = request_threaded_irq(mmc_slot(host).card_detect_irq,
2900 + NULL,
2901 + omap_hsmmc_detect,
2902 +- IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
2903 ++ IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
2904 + mmc_hostname(mmc), host);
2905 + if (ret) {
2906 + dev_dbg(mmc_dev(host->mmc),
2907 +diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c
2908 +index 072ed59..9e2dfd5 100644
2909 +--- a/drivers/mtd/sm_ftl.c
2910 ++++ b/drivers/mtd/sm_ftl.c
2911 +@@ -1256,7 +1256,7 @@ static void sm_remove_dev(struct mtd_blktrans_dev *dev)
2912 +
2913 + static struct mtd_blktrans_ops sm_ftl_ops = {
2914 + .name = "smblk",
2915 +- .major = -1,
2916 ++ .major = 0,
2917 + .part_bits = SM_FTL_PARTN_BITS,
2918 + .blksize = SM_SECTOR_SIZE,
2919 + .getgeo = sm_getgeo,
2920 +diff --git a/drivers/net/wireless/b43legacy/main.c b/drivers/net/wireless/b43legacy/main.c
2921 +index 75e70bc..2609cbe 100644
2922 +--- a/drivers/net/wireless/b43legacy/main.c
2923 ++++ b/drivers/net/wireless/b43legacy/main.c
2924 +@@ -1564,8 +1564,6 @@ static int b43legacy_request_firmware(struct b43legacy_wldev *dev)
2925 + const char *filename;
2926 + int err;
2927 +
2928 +- /* do dummy read */
2929 +- ssb_read32(dev->dev, SSB_TMSHIGH);
2930 + if (!fw->ucode) {
2931 + if (rev == 2)
2932 + filename = "ucode2";
2933 +diff --git a/drivers/net/wireless/rtlwifi/pci.c b/drivers/net/wireless/rtlwifi/pci.c
2934 +index b588ca8..3c5e890 100644
2935 +--- a/drivers/net/wireless/rtlwifi/pci.c
2936 ++++ b/drivers/net/wireless/rtlwifi/pci.c
2937 +@@ -1865,14 +1865,6 @@ int __devinit rtl_pci_probe(struct pci_dev *pdev,
2938 + /*like read eeprom and so on */
2939 + rtlpriv->cfg->ops->read_eeprom_info(hw);
2940 +
2941 +- if (rtlpriv->cfg->ops->init_sw_vars(hw)) {
2942 +- RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
2943 +- ("Can't init_sw_vars.\n"));
2944 +- goto fail3;
2945 +- }
2946 +-
2947 +- rtlpriv->cfg->ops->init_sw_leds(hw);
2948 +-
2949 + /*aspm */
2950 + rtl_pci_init_aspm(hw);
2951 +
2952 +@@ -1892,6 +1884,15 @@ int __devinit rtl_pci_probe(struct pci_dev *pdev,
2953 + goto fail3;
2954 + }
2955 +
2956 ++ if (rtlpriv->cfg->ops->init_sw_vars(hw)) {
2957 ++ RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
2958 ++ ("Can't init_sw_vars.\n"));
2959 ++ err = -ENODEV;
2960 ++ goto fail3;
2961 ++ }
2962 ++
2963 ++ rtlpriv->cfg->ops->init_sw_leds(hw);
2964 ++
2965 + err = sysfs_create_group(&pdev->dev.kobj, &rtl_attribute_group);
2966 + if (err) {
2967 + RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
2968 +diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/sw.c b/drivers/net/wireless/rtlwifi/rtl8192de/sw.c
2969 +index 2afcfe3..2a69e10 100644
2970 +--- a/drivers/net/wireless/rtlwifi/rtl8192de/sw.c
2971 ++++ b/drivers/net/wireless/rtlwifi/rtl8192de/sw.c
2972 +@@ -94,7 +94,6 @@ static int rtl92d_init_sw_vars(struct ieee80211_hw *hw)
2973 + u8 tid;
2974 + struct rtl_priv *rtlpriv = rtl_priv(hw);
2975 + struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
2976 +- static int header_print;
2977 +
2978 + rtlpriv->dm.dm_initialgain_enable = true;
2979 + rtlpriv->dm.dm_flag = 0;
2980 +@@ -174,10 +173,6 @@ static int rtl92d_init_sw_vars(struct ieee80211_hw *hw)
2981 + for (tid = 0; tid < 8; tid++)
2982 + skb_queue_head_init(&rtlpriv->mac80211.skb_waitq[tid]);
2983 +
2984 +- /* Only load firmware for first MAC */
2985 +- if (header_print)
2986 +- return 0;
2987 +-
2988 + /* for firmware buf */
2989 + rtlpriv->rtlhal.pfirmware = vzalloc(0x8000);
2990 + if (!rtlpriv->rtlhal.pfirmware) {
2991 +@@ -189,7 +184,6 @@ static int rtl92d_init_sw_vars(struct ieee80211_hw *hw)
2992 + rtlpriv->max_fw_size = 0x8000;
2993 + pr_info("Driver for Realtek RTL8192DE WLAN interface\n");
2994 + pr_info("Loading firmware file %s\n", rtlpriv->cfg->fw_name);
2995 +- header_print++;
2996 +
2997 + /* request fw */
2998 + err = request_firmware_nowait(THIS_MODULE, 1, rtlpriv->cfg->fw_name,
2999 +diff --git a/drivers/net/wireless/rtlwifi/usb.c b/drivers/net/wireless/rtlwifi/usb.c
3000 +index 049e207..20b53ae 100644
3001 +--- a/drivers/net/wireless/rtlwifi/usb.c
3002 ++++ b/drivers/net/wireless/rtlwifi/usb.c
3003 +@@ -970,12 +970,6 @@ int __devinit rtl_usb_probe(struct usb_interface *intf,
3004 + rtlpriv->cfg->ops->read_chip_version(hw);
3005 + /*like read eeprom and so on */
3006 + rtlpriv->cfg->ops->read_eeprom_info(hw);
3007 +- if (rtlpriv->cfg->ops->init_sw_vars(hw)) {
3008 +- RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
3009 +- ("Can't init_sw_vars.\n"));
3010 +- goto error_out;
3011 +- }
3012 +- rtlpriv->cfg->ops->init_sw_leds(hw);
3013 + err = _rtl_usb_init(hw);
3014 + err = _rtl_usb_init_sw(hw);
3015 + /* Init mac80211 sw */
3016 +@@ -985,6 +979,12 @@ int __devinit rtl_usb_probe(struct usb_interface *intf,
3017 + ("Can't allocate sw for mac80211.\n"));
3018 + goto error_out;
3019 + }
3020 ++ if (rtlpriv->cfg->ops->init_sw_vars(hw)) {
3021 ++ RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
3022 ++ ("Can't init_sw_vars.\n"));
3023 ++ goto error_out;
3024 ++ }
3025 ++ rtlpriv->cfg->ops->init_sw_leds(hw);
3026 +
3027 + return 0;
3028 + error_out:
3029 +diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
3030 +index e9a83f8..9d4b03b 100644
3031 +--- a/drivers/regulator/core.c
3032 ++++ b/drivers/regulator/core.c
3033 +@@ -2877,6 +2877,8 @@ unset_supplies:
3034 + unset_regulator_supplies(rdev);
3035 +
3036 + scrub:
3037 ++ if (rdev->supply)
3038 ++ regulator_put(rdev->supply);
3039 + kfree(rdev->constraints);
3040 + device_unregister(&rdev->dev);
3041 + /* device core frees rdev */
3042 +diff --git a/drivers/rtc/rtc-pl031.c b/drivers/rtc/rtc-pl031.c
3043 +index ee5a561..0b4f87e 100644
3044 +--- a/drivers/rtc/rtc-pl031.c
3045 ++++ b/drivers/rtc/rtc-pl031.c
3046 +@@ -312,6 +312,7 @@ static int pl031_probe(struct amba_device *adev, const struct amba_id *id)
3047 + int ret;
3048 + struct pl031_local *ldata;
3049 + struct rtc_class_ops *ops = id->data;
3050 ++ unsigned long time;
3051 +
3052 + ret = amba_request_regions(adev, NULL);
3053 + if (ret)
3054 +@@ -343,6 +344,23 @@ static int pl031_probe(struct amba_device *adev, const struct amba_id *id)
3055 + writel(readl(ldata->base + RTC_CR) | RTC_CR_CWEN,
3056 + ldata->base + RTC_CR);
3057 +
3058 ++ /*
3059 ++ * On ST PL031 variants, the RTC reset value does not provide correct
3060 ++ * weekday for 2000-01-01. Correct the erroneous sunday to saturday.
3061 ++ */
3062 ++ if (ldata->hw_designer == AMBA_VENDOR_ST) {
3063 ++ if (readl(ldata->base + RTC_YDR) == 0x2000) {
3064 ++ time = readl(ldata->base + RTC_DR);
3065 ++ if ((time &
3066 ++ (RTC_MON_MASK | RTC_MDAY_MASK | RTC_WDAY_MASK))
3067 ++ == 0x02120000) {
3068 ++ time = time | (0x7 << RTC_WDAY_SHIFT);
3069 ++ writel(0x2000, ldata->base + RTC_YLR);
3070 ++ writel(time, ldata->base + RTC_LR);
3071 ++ }
3072 ++ }
3073 ++ }
3074 ++
3075 + ldata->rtc = rtc_device_register("pl031", &adev->dev, ops,
3076 + THIS_MODULE);
3077 + if (IS_ERR(ldata->rtc)) {
3078 +diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
3079 +index b96962c..e640b73 100644
3080 +--- a/drivers/scsi/hpsa.c
3081 ++++ b/drivers/scsi/hpsa.c
3082 +@@ -1676,30 +1676,26 @@ static void figure_bus_target_lun(struct ctlr_info *h,
3083 +
3084 + if (is_logical_dev_addr_mode(lunaddrbytes)) {
3085 + /* logical device */
3086 +- if (unlikely(is_scsi_rev_5(h))) {
3087 +- /* p1210m, logical drives lun assignments
3088 +- * match SCSI REPORT LUNS data.
3089 ++ lunid = le32_to_cpu(*((__le32 *) lunaddrbytes));
3090 ++ if (is_msa2xxx(h, device)) {
3091 ++ /* msa2xxx way, put logicals on bus 1
3092 ++ * and match target/lun numbers box
3093 ++ * reports.
3094 + */
3095 +- lunid = le32_to_cpu(*((__le32 *) lunaddrbytes));
3096 +- *bus = 0;
3097 +- *target = 0;
3098 +- *lun = (lunid & 0x3fff) + 1;
3099 ++ *bus = 1;
3100 ++ *target = (lunid >> 16) & 0x3fff;
3101 ++ *lun = lunid & 0x00ff;
3102 + } else {
3103 +- /* not p1210m... */
3104 +- lunid = le32_to_cpu(*((__le32 *) lunaddrbytes));
3105 +- if (is_msa2xxx(h, device)) {
3106 +- /* msa2xxx way, put logicals on bus 1
3107 +- * and match target/lun numbers box
3108 +- * reports.
3109 +- */
3110 +- *bus = 1;
3111 +- *target = (lunid >> 16) & 0x3fff;
3112 +- *lun = lunid & 0x00ff;
3113 ++ if (likely(is_scsi_rev_5(h))) {
3114 ++ /* All current smart arrays (circa 2011) */
3115 ++ *bus = 0;
3116 ++ *target = 0;
3117 ++ *lun = (lunid & 0x3fff) + 1;
3118 + } else {
3119 +- /* Traditional smart array way. */
3120 ++ /* Traditional old smart array way. */
3121 + *bus = 0;
3122 +- *lun = 0;
3123 + *target = lunid & 0x3fff;
3124 ++ *lun = 0;
3125 + }
3126 + }
3127 + } else {
3128 +diff --git a/drivers/scsi/isci/init.c b/drivers/scsi/isci/init.c
3129 +index 17c4c2c..ff12aef 100644
3130 +--- a/drivers/scsi/isci/init.c
3131 ++++ b/drivers/scsi/isci/init.c
3132 +@@ -481,7 +481,7 @@ static int __devinit isci_pci_probe(struct pci_dev *pdev, const struct pci_devic
3133 + if (!orom)
3134 + orom = isci_request_oprom(pdev);
3135 +
3136 +- for (i = 0; orom && i < ARRAY_SIZE(orom->ctrl); i++) {
3137 ++ for (i = 0; orom && i < num_controllers(pdev); i++) {
3138 + if (sci_oem_parameters_validate(&orom->ctrl[i],
3139 + orom->hdr.version)) {
3140 + dev_warn(&pdev->dev,
3141 +diff --git a/drivers/scsi/mpt2sas/mpt2sas_base.c b/drivers/scsi/mpt2sas/mpt2sas_base.c
3142 +index a78036f..37fd933 100644
3143 +--- a/drivers/scsi/mpt2sas/mpt2sas_base.c
3144 ++++ b/drivers/scsi/mpt2sas/mpt2sas_base.c
3145 +@@ -3340,7 +3340,7 @@ _base_get_port_facts(struct MPT2SAS_ADAPTER *ioc, int port, int sleep_flag)
3146 + }
3147 +
3148 + pfacts = &ioc->pfacts[port];
3149 +- memset(pfacts, 0, sizeof(Mpi2PortFactsReply_t));
3150 ++ memset(pfacts, 0, sizeof(struct mpt2sas_port_facts));
3151 + pfacts->PortNumber = mpi_reply.PortNumber;
3152 + pfacts->VP_ID = mpi_reply.VP_ID;
3153 + pfacts->VF_ID = mpi_reply.VF_ID;
3154 +@@ -3382,7 +3382,7 @@ _base_get_ioc_facts(struct MPT2SAS_ADAPTER *ioc, int sleep_flag)
3155 + }
3156 +
3157 + facts = &ioc->facts;
3158 +- memset(facts, 0, sizeof(Mpi2IOCFactsReply_t));
3159 ++ memset(facts, 0, sizeof(struct mpt2sas_facts));
3160 + facts->MsgVersion = le16_to_cpu(mpi_reply.MsgVersion);
3161 + facts->HeaderVersion = le16_to_cpu(mpi_reply.HeaderVersion);
3162 + facts->VP_ID = mpi_reply.VP_ID;
3163 +@@ -4259,7 +4259,7 @@ mpt2sas_base_attach(struct MPT2SAS_ADAPTER *ioc)
3164 + goto out_free_resources;
3165 +
3166 + ioc->pfacts = kcalloc(ioc->facts.NumberOfPorts,
3167 +- sizeof(Mpi2PortFactsReply_t), GFP_KERNEL);
3168 ++ sizeof(struct mpt2sas_port_facts), GFP_KERNEL);
3169 + if (!ioc->pfacts) {
3170 + r = -ENOMEM;
3171 + goto out_free_resources;
3172 +diff --git a/drivers/spi/spi-fsl-spi.c b/drivers/spi/spi-fsl-spi.c
3173 +index 24cacff..6a62934 100644
3174 +--- a/drivers/spi/spi-fsl-spi.c
3175 ++++ b/drivers/spi/spi-fsl-spi.c
3176 +@@ -139,10 +139,12 @@ static void fsl_spi_change_mode(struct spi_device *spi)
3177 + static void fsl_spi_chipselect(struct spi_device *spi, int value)
3178 + {
3179 + struct mpc8xxx_spi *mpc8xxx_spi = spi_master_get_devdata(spi->master);
3180 +- struct fsl_spi_platform_data *pdata = spi->dev.parent->platform_data;
3181 ++ struct fsl_spi_platform_data *pdata;
3182 + bool pol = spi->mode & SPI_CS_HIGH;
3183 + struct spi_mpc8xxx_cs *cs = spi->controller_state;
3184 +
3185 ++ pdata = spi->dev.parent->parent->platform_data;
3186 ++
3187 + if (value == BITBANG_CS_INACTIVE) {
3188 + if (pdata->cs_control)
3189 + pdata->cs_control(spi, !pol);
3190 +@@ -931,7 +933,7 @@ err:
3191 +
3192 + static void fsl_spi_cs_control(struct spi_device *spi, bool on)
3193 + {
3194 +- struct device *dev = spi->dev.parent;
3195 ++ struct device *dev = spi->dev.parent->parent;
3196 + struct mpc8xxx_spi_probe_info *pinfo = to_of_pinfo(dev->platform_data);
3197 + u16 cs = spi->chip_select;
3198 + int gpio = pinfo->gpios[cs];
3199 +diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c
3200 +index 9bcf87a..a796964 100644
3201 +--- a/drivers/staging/comedi/comedi_fops.c
3202 ++++ b/drivers/staging/comedi/comedi_fops.c
3203 +@@ -280,7 +280,7 @@ static int do_devconfig_ioctl(struct comedi_device *dev,
3204 + if (ret == 0) {
3205 + if (!try_module_get(dev->driver->module)) {
3206 + comedi_device_detach(dev);
3207 +- return -ENOSYS;
3208 ++ ret = -ENOSYS;
3209 + }
3210 + }
3211 +
3212 +diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c
3213 +index 858dca8..3614973 100644
3214 +--- a/drivers/tty/serial/8250/8250_pci.c
3215 ++++ b/drivers/tty/serial/8250/8250_pci.c
3216 +@@ -1609,54 +1609,72 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = {
3217 + {
3218 + .vendor = PCI_VENDOR_ID_INTEL,
3219 + .device = 0x8811,
3220 ++ .subvendor = PCI_ANY_ID,
3221 ++ .subdevice = PCI_ANY_ID,
3222 + .init = pci_eg20t_init,
3223 + .setup = pci_default_setup,
3224 + },
3225 + {
3226 + .vendor = PCI_VENDOR_ID_INTEL,
3227 + .device = 0x8812,
3228 ++ .subvendor = PCI_ANY_ID,
3229 ++ .subdevice = PCI_ANY_ID,
3230 + .init = pci_eg20t_init,
3231 + .setup = pci_default_setup,
3232 + },
3233 + {
3234 + .vendor = PCI_VENDOR_ID_INTEL,
3235 + .device = 0x8813,
3236 ++ .subvendor = PCI_ANY_ID,
3237 ++ .subdevice = PCI_ANY_ID,
3238 + .init = pci_eg20t_init,
3239 + .setup = pci_default_setup,
3240 + },
3241 + {
3242 + .vendor = PCI_VENDOR_ID_INTEL,
3243 + .device = 0x8814,
3244 ++ .subvendor = PCI_ANY_ID,
3245 ++ .subdevice = PCI_ANY_ID,
3246 + .init = pci_eg20t_init,
3247 + .setup = pci_default_setup,
3248 + },
3249 + {
3250 + .vendor = 0x10DB,
3251 + .device = 0x8027,
3252 ++ .subvendor = PCI_ANY_ID,
3253 ++ .subdevice = PCI_ANY_ID,
3254 + .init = pci_eg20t_init,
3255 + .setup = pci_default_setup,
3256 + },
3257 + {
3258 + .vendor = 0x10DB,
3259 + .device = 0x8028,
3260 ++ .subvendor = PCI_ANY_ID,
3261 ++ .subdevice = PCI_ANY_ID,
3262 + .init = pci_eg20t_init,
3263 + .setup = pci_default_setup,
3264 + },
3265 + {
3266 + .vendor = 0x10DB,
3267 + .device = 0x8029,
3268 ++ .subvendor = PCI_ANY_ID,
3269 ++ .subdevice = PCI_ANY_ID,
3270 + .init = pci_eg20t_init,
3271 + .setup = pci_default_setup,
3272 + },
3273 + {
3274 + .vendor = 0x10DB,
3275 + .device = 0x800C,
3276 ++ .subvendor = PCI_ANY_ID,
3277 ++ .subdevice = PCI_ANY_ID,
3278 + .init = pci_eg20t_init,
3279 + .setup = pci_default_setup,
3280 + },
3281 + {
3282 + .vendor = 0x10DB,
3283 + .device = 0x800D,
3284 ++ .subvendor = PCI_ANY_ID,
3285 ++ .subdevice = PCI_ANY_ID,
3286 + .init = pci_eg20t_init,
3287 + .setup = pci_default_setup,
3288 + },
3289 +diff --git a/drivers/tty/serial/mxs-auart.c b/drivers/tty/serial/mxs-auart.c
3290 +index 55fd362..039c054 100644
3291 +--- a/drivers/tty/serial/mxs-auart.c
3292 ++++ b/drivers/tty/serial/mxs-auart.c
3293 +@@ -369,6 +369,8 @@ static void mxs_auart_settermios(struct uart_port *u,
3294 +
3295 + writel(ctrl, u->membase + AUART_LINECTRL);
3296 + writel(ctrl2, u->membase + AUART_CTRL2);
3297 ++
3298 ++ uart_update_timeout(u, termios->c_cflag, baud);
3299 + }
3300 +
3301 + static irqreturn_t mxs_auart_irq_handle(int irq, void *context)
3302 +diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
3303 +index 1305618..8f5d0d8 100644
3304 +--- a/drivers/tty/serial/serial_core.c
3305 ++++ b/drivers/tty/serial/serial_core.c
3306 +@@ -2283,6 +2283,7 @@ void uart_unregister_driver(struct uart_driver *drv)
3307 + tty_unregister_driver(p);
3308 + put_tty_driver(p);
3309 + kfree(drv->state);
3310 ++ drv->state = NULL;
3311 + drv->tty_driver = NULL;
3312 + }
3313 +
3314 +diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c
3315 +index 7b45f66..e55adbb 100644
3316 +--- a/drivers/usb/class/cdc-wdm.c
3317 ++++ b/drivers/usb/class/cdc-wdm.c
3318 +@@ -500,7 +500,7 @@ static int wdm_flush(struct file *file, fl_owner_t id)
3319 + dev_err(&desc->intf->dev, "Error in flush path: %d\n",
3320 + desc->werr);
3321 +
3322 +- return desc->werr;
3323 ++ return usb_translate_errors(desc->werr);
3324 + }
3325 +
3326 + static unsigned int wdm_poll(struct file *file, struct poll_table_struct *wait)
3327 +@@ -511,7 +511,7 @@ static unsigned int wdm_poll(struct file *file, struct poll_table_struct *wait)
3328 +
3329 + spin_lock_irqsave(&desc->iuspin, flags);
3330 + if (test_bit(WDM_DISCONNECTING, &desc->flags)) {
3331 +- mask = POLLERR;
3332 ++ mask = POLLHUP | POLLERR;
3333 + spin_unlock_irqrestore(&desc->iuspin, flags);
3334 + goto desc_out;
3335 + }
3336 +diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
3337 +index 8df4b76..4e57772 100644
3338 +--- a/drivers/usb/core/devio.c
3339 ++++ b/drivers/usb/core/devio.c
3340 +@@ -333,17 +333,14 @@ static struct async *async_getcompleted(struct dev_state *ps)
3341 + static struct async *async_getpending(struct dev_state *ps,
3342 + void __user *userurb)
3343 + {
3344 +- unsigned long flags;
3345 + struct async *as;
3346 +
3347 +- spin_lock_irqsave(&ps->lock, flags);
3348 + list_for_each_entry(as, &ps->async_pending, asynclist)
3349 + if (as->userurb == userurb) {
3350 + list_del_init(&as->asynclist);
3351 +- spin_unlock_irqrestore(&ps->lock, flags);
3352 + return as;
3353 + }
3354 +- spin_unlock_irqrestore(&ps->lock, flags);
3355 ++
3356 + return NULL;
3357 + }
3358 +
3359 +@@ -398,6 +395,7 @@ static void cancel_bulk_urbs(struct dev_state *ps, unsigned bulk_addr)
3360 + __releases(ps->lock)
3361 + __acquires(ps->lock)
3362 + {
3363 ++ struct urb *urb;
3364 + struct async *as;
3365 +
3366 + /* Mark all the pending URBs that match bulk_addr, up to but not
3367 +@@ -420,8 +418,11 @@ __acquires(ps->lock)
3368 + list_for_each_entry(as, &ps->async_pending, asynclist) {
3369 + if (as->bulk_status == AS_UNLINK) {
3370 + as->bulk_status = 0; /* Only once */
3371 ++ urb = as->urb;
3372 ++ usb_get_urb(urb);
3373 + spin_unlock(&ps->lock); /* Allow completions */
3374 +- usb_unlink_urb(as->urb);
3375 ++ usb_unlink_urb(urb);
3376 ++ usb_put_urb(urb);
3377 + spin_lock(&ps->lock);
3378 + goto rescan;
3379 + }
3380 +@@ -472,6 +473,7 @@ static void async_completed(struct urb *urb)
3381 +
3382 + static void destroy_async(struct dev_state *ps, struct list_head *list)
3383 + {
3384 ++ struct urb *urb;
3385 + struct async *as;
3386 + unsigned long flags;
3387 +
3388 +@@ -479,10 +481,13 @@ static void destroy_async(struct dev_state *ps, struct list_head *list)
3389 + while (!list_empty(list)) {
3390 + as = list_entry(list->next, struct async, asynclist);
3391 + list_del_init(&as->asynclist);
3392 ++ urb = as->urb;
3393 ++ usb_get_urb(urb);
3394 +
3395 + /* drop the spinlock so the completion handler can run */
3396 + spin_unlock_irqrestore(&ps->lock, flags);
3397 +- usb_kill_urb(as->urb);
3398 ++ usb_kill_urb(urb);
3399 ++ usb_put_urb(urb);
3400 + spin_lock_irqsave(&ps->lock, flags);
3401 + }
3402 + spin_unlock_irqrestore(&ps->lock, flags);
3403 +@@ -1410,12 +1415,24 @@ static int proc_submiturb(struct dev_state *ps, void __user *arg)
3404 +
3405 + static int proc_unlinkurb(struct dev_state *ps, void __user *arg)
3406 + {
3407 ++ struct urb *urb;
3408 + struct async *as;
3409 ++ unsigned long flags;
3410 +
3411 ++ spin_lock_irqsave(&ps->lock, flags);
3412 + as = async_getpending(ps, arg);
3413 +- if (!as)
3414 ++ if (!as) {
3415 ++ spin_unlock_irqrestore(&ps->lock, flags);
3416 + return -EINVAL;
3417 +- usb_kill_urb(as->urb);
3418 ++ }
3419 ++
3420 ++ urb = as->urb;
3421 ++ usb_get_urb(urb);
3422 ++ spin_unlock_irqrestore(&ps->lock, flags);
3423 ++
3424 ++ usb_kill_urb(urb);
3425 ++ usb_put_urb(urb);
3426 ++
3427 + return 0;
3428 + }
3429 +
3430 +diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
3431 +index 95baf5d..ce5e147 100644
3432 +--- a/drivers/usb/core/hub.c
3433 ++++ b/drivers/usb/core/hub.c
3434 +@@ -2419,6 +2419,10 @@ int usb_port_suspend(struct usb_device *udev, pm_message_t msg)
3435 + NULL, 0,
3436 + USB_CTRL_SET_TIMEOUT);
3437 +
3438 ++ /* Try to enable USB2 hardware LPM again */
3439 ++ if (udev->usb2_hw_lpm_capable == 1)
3440 ++ usb_set_usb2_hardware_lpm(udev, 1);
3441 ++
3442 + /* System sleep transitions should never fail */
3443 + if (!PMSG_IS_AUTO(msg))
3444 + status = 0;
3445 +diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
3446 +index 4c65eb6..32d3adc 100644
3447 +--- a/drivers/usb/core/quirks.c
3448 ++++ b/drivers/usb/core/quirks.c
3449 +@@ -123,6 +123,9 @@ static const struct usb_device_id usb_quirk_list[] = {
3450 + /* Guillemot Webcam Hercules Dualpix Exchange*/
3451 + { USB_DEVICE(0x06f8, 0x3005), .driver_info = USB_QUIRK_RESET_RESUME },
3452 +
3453 ++ /* Midiman M-Audio Keystation 88es */
3454 ++ { USB_DEVICE(0x0763, 0x0192), .driver_info = USB_QUIRK_RESET_RESUME },
3455 ++
3456 + /* M-Systems Flash Disk Pioneers */
3457 + { USB_DEVICE(0x08ec, 0x1000), .driver_info = USB_QUIRK_RESET_RESUME },
3458 +
3459 +diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c
3460 +index 909625b..0f362cc 100644
3461 +--- a/drivers/usb/core/urb.c
3462 ++++ b/drivers/usb/core/urb.c
3463 +@@ -671,6 +671,27 @@ void usb_unpoison_urb(struct urb *urb)
3464 + EXPORT_SYMBOL_GPL(usb_unpoison_urb);
3465 +
3466 + /**
3467 ++ * usb_block_urb - reliably prevent further use of an URB
3468 ++ * @urb: pointer to URB to be blocked, may be NULL
3469 ++ *
3470 ++ * After the routine has run, attempts to resubmit the URB will fail
3471 ++ * with error -EPERM. Thus even if the URB's completion handler always
3472 ++ * tries to resubmit, it will not succeed and the URB will become idle.
3473 ++ *
3474 ++ * The URB must not be deallocated while this routine is running. In
3475 ++ * particular, when a driver calls this routine, it must insure that the
3476 ++ * completion handler cannot deallocate the URB.
3477 ++ */
3478 ++void usb_block_urb(struct urb *urb)
3479 ++{
3480 ++ if (!urb)
3481 ++ return;
3482 ++
3483 ++ atomic_inc(&urb->reject);
3484 ++}
3485 ++EXPORT_SYMBOL_GPL(usb_block_urb);
3486 ++
3487 ++/**
3488 + * usb_kill_anchored_urbs - cancel transfer requests en masse
3489 + * @anchor: anchor the requests are bound to
3490 + *
3491 +diff --git a/drivers/usb/gadget/fsl_udc_core.c b/drivers/usb/gadget/fsl_udc_core.c
3492 +index 6b5fdf9..cd81463 100644
3493 +--- a/drivers/usb/gadget/fsl_udc_core.c
3494 ++++ b/drivers/usb/gadget/fsl_udc_core.c
3495 +@@ -737,6 +737,8 @@ static void fsl_queue_td(struct fsl_ep *ep, struct fsl_req *req)
3496 + lastreq = list_entry(ep->queue.prev, struct fsl_req, queue);
3497 + lastreq->tail->next_td_ptr =
3498 + cpu_to_hc32(req->head->td_dma & DTD_ADDR_MASK);
3499 ++ /* Ensure dTD's next dtd pointer to be updated */
3500 ++ wmb();
3501 + /* Read prime bit, if 1 goto done */
3502 + if (fsl_readl(&dr_regs->endpointprime) & bitmask)
3503 + return;
3504 +diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
3505 +index fe8dc06..bc94d7b 100644
3506 +--- a/drivers/usb/host/ehci-pci.c
3507 ++++ b/drivers/usb/host/ehci-pci.c
3508 +@@ -368,7 +368,9 @@ static bool usb_is_intel_switchable_ehci(struct pci_dev *pdev)
3509 + {
3510 + return pdev->class == PCI_CLASS_SERIAL_USB_EHCI &&
3511 + pdev->vendor == PCI_VENDOR_ID_INTEL &&
3512 +- pdev->device == 0x1E26;
3513 ++ (pdev->device == 0x1E26 ||
3514 ++ pdev->device == 0x8C2D ||
3515 ++ pdev->device == 0x8C26);
3516 + }
3517 +
3518 + static void ehci_enable_xhci_companion(void)
3519 +diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
3520 +index 70b96ec..76a70f3 100644
3521 +--- a/drivers/usb/host/ohci-at91.c
3522 ++++ b/drivers/usb/host/ohci-at91.c
3523 +@@ -217,7 +217,7 @@ static void usb_hcd_at91_remove(struct usb_hcd *hcd,
3524 + /*-------------------------------------------------------------------------*/
3525 +
3526 + static int __devinit
3527 +-ohci_at91_start (struct usb_hcd *hcd)
3528 ++ohci_at91_reset (struct usb_hcd *hcd)
3529 + {
3530 + struct at91_usbh_data *board = hcd->self.controller->platform_data;
3531 + struct ohci_hcd *ohci = hcd_to_ohci (hcd);
3532 +@@ -227,6 +227,14 @@ ohci_at91_start (struct usb_hcd *hcd)
3533 + return ret;
3534 +
3535 + ohci->num_ports = board->ports;
3536 ++ return 0;
3537 ++}
3538 ++
3539 ++static int __devinit
3540 ++ohci_at91_start (struct usb_hcd *hcd)
3541 ++{
3542 ++ struct ohci_hcd *ohci = hcd_to_ohci (hcd);
3543 ++ int ret;
3544 +
3545 + if ((ret = ohci_run(ohci)) < 0) {
3546 + err("can't start %s", hcd->self.bus_name);
3547 +@@ -410,6 +418,7 @@ static const struct hc_driver ohci_at91_hc_driver = {
3548 + /*
3549 + * basic lifecycle operations
3550 + */
3551 ++ .reset = ohci_at91_reset,
3552 + .start = ohci_at91_start,
3553 + .stop = ohci_stop,
3554 + .shutdown = ohci_shutdown,
3555 +diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c
3556 +index 2afff88..833b3c6 100644
3557 +--- a/drivers/usb/host/pci-quirks.c
3558 ++++ b/drivers/usb/host/pci-quirks.c
3559 +@@ -9,6 +9,7 @@
3560 + */
3561 +
3562 + #include <linux/types.h>
3563 ++#include <linux/kconfig.h>
3564 + #include <linux/kernel.h>
3565 + #include <linux/pci.h>
3566 + #include <linux/init.h>
3567 +@@ -712,12 +713,28 @@ static int handshake(void __iomem *ptr, u32 mask, u32 done,
3568 + return -ETIMEDOUT;
3569 + }
3570 +
3571 +-bool usb_is_intel_switchable_xhci(struct pci_dev *pdev)
3572 ++#define PCI_DEVICE_ID_INTEL_LYNX_POINT_XHCI 0x8C31
3573 ++
3574 ++bool usb_is_intel_ppt_switchable_xhci(struct pci_dev *pdev)
3575 + {
3576 + return pdev->class == PCI_CLASS_SERIAL_USB_XHCI &&
3577 + pdev->vendor == PCI_VENDOR_ID_INTEL &&
3578 + pdev->device == PCI_DEVICE_ID_INTEL_PANTHERPOINT_XHCI;
3579 + }
3580 ++
3581 ++/* The Intel Lynx Point chipset also has switchable ports. */
3582 ++bool usb_is_intel_lpt_switchable_xhci(struct pci_dev *pdev)
3583 ++{
3584 ++ return pdev->class == PCI_CLASS_SERIAL_USB_XHCI &&
3585 ++ pdev->vendor == PCI_VENDOR_ID_INTEL &&
3586 ++ pdev->device == PCI_DEVICE_ID_INTEL_LYNX_POINT_XHCI;
3587 ++}
3588 ++
3589 ++bool usb_is_intel_switchable_xhci(struct pci_dev *pdev)
3590 ++{
3591 ++ return usb_is_intel_ppt_switchable_xhci(pdev) ||
3592 ++ usb_is_intel_lpt_switchable_xhci(pdev);
3593 ++}
3594 + EXPORT_SYMBOL_GPL(usb_is_intel_switchable_xhci);
3595 +
3596 + /*
3597 +@@ -742,6 +759,19 @@ void usb_enable_xhci_ports(struct pci_dev *xhci_pdev)
3598 + {
3599 + u32 ports_available;
3600 +
3601 ++ /* Don't switchover the ports if the user hasn't compiled the xHCI
3602 ++ * driver. Otherwise they will see "dead" USB ports that don't power
3603 ++ * the devices.
3604 ++ */
3605 ++ if (!IS_ENABLED(CONFIG_USB_XHCI_HCD)) {
3606 ++ dev_warn(&xhci_pdev->dev,
3607 ++ "CONFIG_USB_XHCI_HCD is turned off, "
3608 ++ "defaulting to EHCI.\n");
3609 ++ dev_warn(&xhci_pdev->dev,
3610 ++ "USB 3.0 devices will work at USB 2.0 speeds.\n");
3611 ++ return;
3612 ++ }
3613 ++
3614 + ports_available = 0xffffffff;
3615 + /* Write USB3_PSSEN, the USB 3.0 Port SuperSpeed Enable
3616 + * Register, to turn on SuperSpeed terminations for all
3617 +diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
3618 +index 4c1e721..fd7635f 100644
3619 +--- a/drivers/usb/host/xhci-mem.c
3620 ++++ b/drivers/usb/host/xhci-mem.c
3621 +@@ -1685,6 +1685,14 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci)
3622 + {
3623 + struct pci_dev *pdev = to_pci_dev(xhci_to_hcd(xhci)->self.controller);
3624 + struct dev_info *dev_info, *next;
3625 ++ struct list_head *tt_list_head;
3626 ++ struct list_head *tt;
3627 ++ struct list_head *endpoints;
3628 ++ struct list_head *ep, *q;
3629 ++ struct xhci_tt_bw_info *tt_info;
3630 ++ struct xhci_interval_bw_table *bwt;
3631 ++ struct xhci_virt_ep *virt_ep;
3632 ++
3633 + unsigned long flags;
3634 + int size;
3635 + int i;
3636 +@@ -1701,6 +1709,7 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci)
3637 + xhci->event_ring = NULL;
3638 + xhci_dbg(xhci, "Freed event ring\n");
3639 +
3640 ++ xhci->cmd_ring_reserved_trbs = 0;
3641 + if (xhci->cmd_ring)
3642 + xhci_ring_free(xhci, xhci->cmd_ring);
3643 + xhci->cmd_ring = NULL;
3644 +@@ -1743,8 +1752,26 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci)
3645 + }
3646 + spin_unlock_irqrestore(&xhci->lock, flags);
3647 +
3648 ++ bwt = &xhci->rh_bw->bw_table;
3649 ++ for (i = 0; i < XHCI_MAX_INTERVAL; i++) {
3650 ++ endpoints = &bwt->interval_bw[i].endpoints;
3651 ++ list_for_each_safe(ep, q, endpoints) {
3652 ++ virt_ep = list_entry(ep, struct xhci_virt_ep, bw_endpoint_list);
3653 ++ list_del(&virt_ep->bw_endpoint_list);
3654 ++ kfree(virt_ep);
3655 ++ }
3656 ++ }
3657 ++
3658 ++ tt_list_head = &xhci->rh_bw->tts;
3659 ++ list_for_each_safe(tt, q, tt_list_head) {
3660 ++ tt_info = list_entry(tt, struct xhci_tt_bw_info, tt_list);
3661 ++ list_del(tt);
3662 ++ kfree(tt_info);
3663 ++ }
3664 ++
3665 + xhci->num_usb2_ports = 0;
3666 + xhci->num_usb3_ports = 0;
3667 ++ xhci->num_active_eps = 0;
3668 + kfree(xhci->usb2_ports);
3669 + kfree(xhci->usb3_ports);
3670 + kfree(xhci->port_array);
3671 +diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
3672 +index 211296a..daf5754 100644
3673 +--- a/drivers/usb/host/xhci-pci.c
3674 ++++ b/drivers/usb/host/xhci-pci.c
3675 +@@ -72,6 +72,7 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
3676 + xhci_dbg(xhci, "QUIRK: Fresco Logic revision %u "
3677 + "has broken MSI implementation\n",
3678 + pdev->revision);
3679 ++ xhci->quirks |= XHCI_TRUST_TX_LENGTH;
3680 + }
3681 +
3682 + if (pdev->vendor == PCI_VENDOR_ID_NEC)
3683 +diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
3684 +index 6851bc2..dae7893 100644
3685 +--- a/drivers/usb/host/xhci-ring.c
3686 ++++ b/drivers/usb/host/xhci-ring.c
3687 +@@ -1722,8 +1722,12 @@ static int process_isoc_td(struct xhci_hcd *xhci, struct xhci_td *td,
3688 + /* handle completion code */
3689 + switch (trb_comp_code) {
3690 + case COMP_SUCCESS:
3691 +- frame->status = 0;
3692 +- break;
3693 ++ if (TRB_LEN(le32_to_cpu(event->transfer_len)) == 0) {
3694 ++ frame->status = 0;
3695 ++ break;
3696 ++ }
3697 ++ if ((xhci->quirks & XHCI_TRUST_TX_LENGTH))
3698 ++ trb_comp_code = COMP_SHORT_TX;
3699 + case COMP_SHORT_TX:
3700 + frame->status = td->urb->transfer_flags & URB_SHORT_NOT_OK ?
3701 + -EREMOTEIO : 0;
3702 +@@ -1739,6 +1743,7 @@ static int process_isoc_td(struct xhci_hcd *xhci, struct xhci_td *td,
3703 + break;
3704 + case COMP_DEV_ERR:
3705 + case COMP_STALL:
3706 ++ case COMP_TX_ERR:
3707 + frame->status = -EPROTO;
3708 + skip_td = true;
3709 + break;
3710 +@@ -1819,13 +1824,16 @@ static int process_bulk_intr_td(struct xhci_hcd *xhci, struct xhci_td *td,
3711 + switch (trb_comp_code) {
3712 + case COMP_SUCCESS:
3713 + /* Double check that the HW transferred everything. */
3714 +- if (event_trb != td->last_trb) {
3715 ++ if (event_trb != td->last_trb ||
3716 ++ TRB_LEN(le32_to_cpu(event->transfer_len)) != 0) {
3717 + xhci_warn(xhci, "WARN Successful completion "
3718 + "on short TX\n");
3719 + if (td->urb->transfer_flags & URB_SHORT_NOT_OK)
3720 + *status = -EREMOTEIO;
3721 + else
3722 + *status = 0;
3723 ++ if ((xhci->quirks & XHCI_TRUST_TX_LENGTH))
3724 ++ trb_comp_code = COMP_SHORT_TX;
3725 + } else {
3726 + *status = 0;
3727 + }
3728 +@@ -1984,6 +1992,13 @@ static int handle_tx_event(struct xhci_hcd *xhci,
3729 + * transfer type
3730 + */
3731 + case COMP_SUCCESS:
3732 ++ if (TRB_LEN(le32_to_cpu(event->transfer_len)) == 0)
3733 ++ break;
3734 ++ if (xhci->quirks & XHCI_TRUST_TX_LENGTH)
3735 ++ trb_comp_code = COMP_SHORT_TX;
3736 ++ else
3737 ++ xhci_warn(xhci, "WARN Successful completion on short TX: "
3738 ++ "needs XHCI_TRUST_TX_LENGTH quirk?\n");
3739 + case COMP_SHORT_TX:
3740 + break;
3741 + case COMP_STOP:
3742 +diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
3743 +index a947d70..d3d01c8 100644
3744 +--- a/drivers/usb/host/xhci.h
3745 ++++ b/drivers/usb/host/xhci.h
3746 +@@ -1466,6 +1466,7 @@ struct xhci_hcd {
3747 + #define XHCI_RESET_ON_RESUME (1 << 7)
3748 + #define XHCI_SW_BW_CHECKING (1 << 8)
3749 + #define XHCI_AMD_0x96_HOST (1 << 9)
3750 ++#define XHCI_TRUST_TX_LENGTH (1 << 10)
3751 + unsigned int num_active_eps;
3752 + unsigned int limit_active_eps;
3753 + /* There are two roothubs to keep track of bus suspend info for */
3754 +diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
3755 +index 959145b..8fe901d 100644
3756 +--- a/drivers/usb/misc/usbtest.c
3757 ++++ b/drivers/usb/misc/usbtest.c
3758 +@@ -1025,7 +1025,10 @@ test_ctrl_queue(struct usbtest_dev *dev, struct usbtest_param *param)
3759 + case 13: /* short read, resembling case 10 */
3760 + req.wValue = cpu_to_le16((USB_DT_CONFIG << 8) | 0);
3761 + /* last data packet "should" be DATA1, not DATA0 */
3762 +- len = 1024 - udev->descriptor.bMaxPacketSize0;
3763 ++ if (udev->speed == USB_SPEED_SUPER)
3764 ++ len = 1024 - 512;
3765 ++ else
3766 ++ len = 1024 - udev->descriptor.bMaxPacketSize0;
3767 + expected = -EREMOTEIO;
3768 + break;
3769 + case 14: /* short read; try to fill the last packet */
3770 +@@ -1384,11 +1387,15 @@ static int test_halt(struct usbtest_dev *tdev, int ep, struct urb *urb)
3771 +
3772 + static int halt_simple(struct usbtest_dev *dev)
3773 + {
3774 +- int ep;
3775 +- int retval = 0;
3776 +- struct urb *urb;
3777 ++ int ep;
3778 ++ int retval = 0;
3779 ++ struct urb *urb;
3780 ++ struct usb_device *udev = testdev_to_usbdev(dev);
3781 +
3782 +- urb = simple_alloc_urb(testdev_to_usbdev(dev), 0, 512);
3783 ++ if (udev->speed == USB_SPEED_SUPER)
3784 ++ urb = simple_alloc_urb(udev, 0, 1024);
3785 ++ else
3786 ++ urb = simple_alloc_urb(udev, 0, 512);
3787 + if (urb == NULL)
3788 + return -ENOMEM;
3789 +
3790 +diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
3791 +index 0ca65e4..f8817c1 100644
3792 +--- a/drivers/usb/serial/ftdi_sio.c
3793 ++++ b/drivers/usb/serial/ftdi_sio.c
3794 +@@ -809,6 +809,7 @@ static struct usb_device_id id_table_combined [] = {
3795 + .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
3796 + { USB_DEVICE(LARSENBRUSGAARD_VID, LB_ALTITRACK_PID) },
3797 + { USB_DEVICE(GN_OTOMETRICS_VID, AURICAL_USB_PID) },
3798 ++ { USB_DEVICE(PI_VID, PI_E861_PID) },
3799 + { USB_DEVICE(BAYER_VID, BAYER_CONTOUR_CABLE_PID) },
3800 + { USB_DEVICE(FTDI_VID, MARVELL_OPENRD_PID),
3801 + .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
3802 +diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h
3803 +index 0838baf8..f3c7c78 100644
3804 +--- a/drivers/usb/serial/ftdi_sio_ids.h
3805 ++++ b/drivers/usb/serial/ftdi_sio_ids.h
3806 +@@ -785,6 +785,14 @@
3807 + #define RTSYSTEMS_SERIAL_VX7_PID 0x9e52 /* Serial converter for VX-7 Radios using FT232RL */
3808 + #define RTSYSTEMS_CT29B_PID 0x9e54 /* CT29B Radio Cable */
3809 +
3810 ++
3811 ++/*
3812 ++ * Physik Instrumente
3813 ++ * http://www.physikinstrumente.com/en/products/
3814 ++ */
3815 ++#define PI_VID 0x1a72 /* Vendor ID */
3816 ++#define PI_E861_PID 0x1008 /* E-861 piezo controller USB connection */
3817 ++
3818 + /*
3819 + * Bayer Ascensia Contour blood glucose meter USB-converter cable.
3820 + * http://winglucofacts.com/cables/
3821 +diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c
3822 +index 75b838e..1bbe5f4 100644
3823 +--- a/drivers/usb/serial/ti_usb_3410_5052.c
3824 ++++ b/drivers/usb/serial/ti_usb_3410_5052.c
3825 +@@ -165,7 +165,7 @@ static unsigned int product_5052_count;
3826 + /* the array dimension is the number of default entries plus */
3827 + /* TI_EXTRA_VID_PID_COUNT user defined entries plus 1 terminating */
3828 + /* null entry */
3829 +-static struct usb_device_id ti_id_table_3410[14+TI_EXTRA_VID_PID_COUNT+1] = {
3830 ++static struct usb_device_id ti_id_table_3410[15+TI_EXTRA_VID_PID_COUNT+1] = {
3831 + { USB_DEVICE(TI_VENDOR_ID, TI_3410_PRODUCT_ID) },
3832 + { USB_DEVICE(TI_VENDOR_ID, TI_3410_EZ430_ID) },
3833 + { USB_DEVICE(MTS_VENDOR_ID, MTS_GSM_NO_FW_PRODUCT_ID) },
3834 +@@ -180,6 +180,7 @@ static struct usb_device_id ti_id_table_3410[14+TI_EXTRA_VID_PID_COUNT+1] = {
3835 + { USB_DEVICE(IBM_VENDOR_ID, IBM_454B_PRODUCT_ID) },
3836 + { USB_DEVICE(IBM_VENDOR_ID, IBM_454C_PRODUCT_ID) },
3837 + { USB_DEVICE(ABBOTT_VENDOR_ID, ABBOTT_PRODUCT_ID) },
3838 ++ { USB_DEVICE(TI_VENDOR_ID, FRI2_PRODUCT_ID) },
3839 + };
3840 +
3841 + static struct usb_device_id ti_id_table_5052[5+TI_EXTRA_VID_PID_COUNT+1] = {
3842 +@@ -189,7 +190,7 @@ static struct usb_device_id ti_id_table_5052[5+TI_EXTRA_VID_PID_COUNT+1] = {
3843 + { USB_DEVICE(TI_VENDOR_ID, TI_5052_FIRMWARE_PRODUCT_ID) },
3844 + };
3845 +
3846 +-static struct usb_device_id ti_id_table_combined[18+2*TI_EXTRA_VID_PID_COUNT+1] = {
3847 ++static struct usb_device_id ti_id_table_combined[19+2*TI_EXTRA_VID_PID_COUNT+1] = {
3848 + { USB_DEVICE(TI_VENDOR_ID, TI_3410_PRODUCT_ID) },
3849 + { USB_DEVICE(TI_VENDOR_ID, TI_3410_EZ430_ID) },
3850 + { USB_DEVICE(MTS_VENDOR_ID, MTS_GSM_NO_FW_PRODUCT_ID) },
3851 +@@ -208,6 +209,7 @@ static struct usb_device_id ti_id_table_combined[18+2*TI_EXTRA_VID_PID_COUNT+1]
3852 + { USB_DEVICE(IBM_VENDOR_ID, IBM_454B_PRODUCT_ID) },
3853 + { USB_DEVICE(IBM_VENDOR_ID, IBM_454C_PRODUCT_ID) },
3854 + { USB_DEVICE(ABBOTT_VENDOR_ID, ABBOTT_PRODUCT_ID) },
3855 ++ { USB_DEVICE(TI_VENDOR_ID, FRI2_PRODUCT_ID) },
3856 + { }
3857 + };
3858 +
3859 +diff --git a/drivers/usb/serial/ti_usb_3410_5052.h b/drivers/usb/serial/ti_usb_3410_5052.h
3860 +index f140f1b..b353e7e 100644
3861 +--- a/drivers/usb/serial/ti_usb_3410_5052.h
3862 ++++ b/drivers/usb/serial/ti_usb_3410_5052.h
3863 +@@ -37,6 +37,7 @@
3864 + #define TI_5152_BOOT_PRODUCT_ID 0x5152 /* no EEPROM, no firmware */
3865 + #define TI_5052_EEPROM_PRODUCT_ID 0x505A /* EEPROM, no firmware */
3866 + #define TI_5052_FIRMWARE_PRODUCT_ID 0x505F /* firmware is running */
3867 ++#define FRI2_PRODUCT_ID 0x5053 /* Fish River Island II */
3868 +
3869 + /* Multi-Tech vendor and product ids */
3870 + #define MTS_VENDOR_ID 0x06E0
3871 +diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
3872 +index 856ad92..8f3cbb8 100644
3873 +--- a/drivers/usb/storage/unusual_devs.h
3874 ++++ b/drivers/usb/storage/unusual_devs.h
3875 +@@ -1885,6 +1885,13 @@ UNUSUAL_DEV( 0x1652, 0x6600, 0x0201, 0x0201,
3876 + USB_SC_DEVICE, USB_PR_DEVICE, NULL,
3877 + US_FL_IGNORE_RESIDUE ),
3878 +
3879 ++/* Reported by Jesse Feddema <jdfeddema@×××××.com> */
3880 ++UNUSUAL_DEV( 0x177f, 0x0400, 0x0000, 0x0000,
3881 ++ "Yarvik",
3882 ++ "PMP400",
3883 ++ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
3884 ++ US_FL_BULK_IGNORE_TAG | US_FL_MAX_SECTORS_64 ),
3885 ++
3886 + /* Reported by Hans de Goede <hdegoede@××××××.com>
3887 + * These Appotech controllers are found in Picture Frames, they provide a
3888 + * (buggy) emulation of a cdrom drive which contains the windows software
3889 +diff --git a/drivers/video/udlfb.c b/drivers/video/udlfb.c
3890 +index a40c05e..5fd95e0 100644
3891 +--- a/drivers/video/udlfb.c
3892 ++++ b/drivers/video/udlfb.c
3893 +@@ -918,10 +918,6 @@ static void dlfb_free(struct kref *kref)
3894 + {
3895 + struct dlfb_data *dev = container_of(kref, struct dlfb_data, kref);
3896 +
3897 +- /* this function will wait for all in-flight urbs to complete */
3898 +- if (dev->urbs.count > 0)
3899 +- dlfb_free_urb_list(dev);
3900 +-
3901 + if (dev->backing_buffer)
3902 + vfree(dev->backing_buffer);
3903 +
3904 +@@ -940,35 +936,42 @@ static void dlfb_release_urb_work(struct work_struct *work)
3905 + up(&unode->dev->urbs.limit_sem);
3906 + }
3907 +
3908 +-static void dlfb_free_framebuffer_work(struct work_struct *work)
3909 ++static void dlfb_free_framebuffer(struct dlfb_data *dev)
3910 + {
3911 +- struct dlfb_data *dev = container_of(work, struct dlfb_data,
3912 +- free_framebuffer_work.work);
3913 + struct fb_info *info = dev->info;
3914 +- int node = info->node;
3915 +
3916 +- unregister_framebuffer(info);
3917 ++ if (info) {
3918 ++ int node = info->node;
3919 +
3920 +- if (info->cmap.len != 0)
3921 +- fb_dealloc_cmap(&info->cmap);
3922 +- if (info->monspecs.modedb)
3923 +- fb_destroy_modedb(info->monspecs.modedb);
3924 +- if (info->screen_base)
3925 +- vfree(info->screen_base);
3926 ++ unregister_framebuffer(info);
3927 +
3928 +- fb_destroy_modelist(&info->modelist);
3929 ++ if (info->cmap.len != 0)
3930 ++ fb_dealloc_cmap(&info->cmap);
3931 ++ if (info->monspecs.modedb)
3932 ++ fb_destroy_modedb(info->monspecs.modedb);
3933 ++ if (info->screen_base)
3934 ++ vfree(info->screen_base);
3935 ++
3936 ++ fb_destroy_modelist(&info->modelist);
3937 +
3938 +- dev->info = 0;
3939 ++ dev->info = NULL;
3940 +
3941 +- /* Assume info structure is freed after this point */
3942 +- framebuffer_release(info);
3943 ++ /* Assume info structure is freed after this point */
3944 ++ framebuffer_release(info);
3945 +
3946 +- pr_warn("fb_info for /dev/fb%d has been freed\n", node);
3947 ++ pr_warn("fb_info for /dev/fb%d has been freed\n", node);
3948 ++ }
3949 +
3950 + /* ref taken in probe() as part of registering framebfufer */
3951 + kref_put(&dev->kref, dlfb_free);
3952 + }
3953 +
3954 ++static void dlfb_free_framebuffer_work(struct work_struct *work)
3955 ++{
3956 ++ struct dlfb_data *dev = container_of(work, struct dlfb_data,
3957 ++ free_framebuffer_work.work);
3958 ++ dlfb_free_framebuffer(dev);
3959 ++}
3960 + /*
3961 + * Assumes caller is holding info->lock mutex (for open and release at least)
3962 + */
3963 +@@ -1570,14 +1573,15 @@ success:
3964 + kfree(buf);
3965 + return true;
3966 + }
3967 ++
3968 ++static void dlfb_init_framebuffer_work(struct work_struct *work);
3969 ++
3970 + static int dlfb_usb_probe(struct usb_interface *interface,
3971 + const struct usb_device_id *id)
3972 + {
3973 + struct usb_device *usbdev;
3974 + struct dlfb_data *dev = 0;
3975 +- struct fb_info *info = 0;
3976 + int retval = -ENOMEM;
3977 +- int i;
3978 +
3979 + /* usb initialization */
3980 +
3981 +@@ -1589,9 +1593,7 @@ static int dlfb_usb_probe(struct usb_interface *interface,
3982 + goto error;
3983 + }
3984 +
3985 +- /* we need to wait for both usb and fbdev to spin down on disconnect */
3986 + kref_init(&dev->kref); /* matching kref_put in usb .disconnect fn */
3987 +- kref_get(&dev->kref); /* matching kref_put in free_framebuffer_work */
3988 +
3989 + dev->udev = usbdev;
3990 + dev->gdev = &usbdev->dev; /* our generic struct device * */
3991 +@@ -1619,10 +1621,39 @@ static int dlfb_usb_probe(struct usb_interface *interface,
3992 + goto error;
3993 + }
3994 +
3995 ++ kref_get(&dev->kref); /* matching kref_put in free_framebuffer_work */
3996 ++
3997 + /* We don't register a new USB class. Our client interface is fbdev */
3998 +
3999 ++ /* Workitem keep things fast & simple during USB enumeration */
4000 ++ INIT_DELAYED_WORK(&dev->init_framebuffer_work,
4001 ++ dlfb_init_framebuffer_work);
4002 ++ schedule_delayed_work(&dev->init_framebuffer_work, 0);
4003 ++
4004 ++ return 0;
4005 ++
4006 ++error:
4007 ++ if (dev) {
4008 ++
4009 ++ kref_put(&dev->kref, dlfb_free); /* ref for framebuffer */
4010 ++ kref_put(&dev->kref, dlfb_free); /* last ref from kref_init */
4011 ++
4012 ++ /* dev has been deallocated. Do not dereference */
4013 ++ }
4014 ++
4015 ++ return retval;
4016 ++}
4017 ++
4018 ++static void dlfb_init_framebuffer_work(struct work_struct *work)
4019 ++{
4020 ++ struct dlfb_data *dev = container_of(work, struct dlfb_data,
4021 ++ init_framebuffer_work.work);
4022 ++ struct fb_info *info;
4023 ++ int retval;
4024 ++ int i;
4025 ++
4026 + /* allocates framebuffer driver structure, not framebuffer memory */
4027 +- info = framebuffer_alloc(0, &interface->dev);
4028 ++ info = framebuffer_alloc(0, dev->gdev);
4029 + if (!info) {
4030 + retval = -ENOMEM;
4031 + pr_err("framebuffer_alloc failed\n");
4032 +@@ -1668,15 +1699,13 @@ static int dlfb_usb_probe(struct usb_interface *interface,
4033 + for (i = 0; i < ARRAY_SIZE(fb_device_attrs); i++) {
4034 + retval = device_create_file(info->dev, &fb_device_attrs[i]);
4035 + if (retval) {
4036 +- pr_err("device_create_file failed %d\n", retval);
4037 +- goto err_del_attrs;
4038 ++ pr_warn("device_create_file failed %d\n", retval);
4039 + }
4040 + }
4041 +
4042 + retval = device_create_bin_file(info->dev, &edid_attr);
4043 + if (retval) {
4044 +- pr_err("device_create_bin_file failed %d\n", retval);
4045 +- goto err_del_attrs;
4046 ++ pr_warn("device_create_bin_file failed %d\n", retval);
4047 + }
4048 +
4049 + pr_info("DisplayLink USB device /dev/fb%d attached. %dx%d resolution."
4050 +@@ -1684,38 +1713,10 @@ static int dlfb_usb_probe(struct usb_interface *interface,
4051 + info->var.xres, info->var.yres,
4052 + ((dev->backing_buffer) ?
4053 + info->fix.smem_len * 2 : info->fix.smem_len) >> 10);
4054 +- return 0;
4055 +-
4056 +-err_del_attrs:
4057 +- for (i -= 1; i >= 0; i--)
4058 +- device_remove_file(info->dev, &fb_device_attrs[i]);
4059 ++ return;
4060 +
4061 + error:
4062 +- if (dev) {
4063 +-
4064 +- if (info) {
4065 +- if (info->cmap.len != 0)
4066 +- fb_dealloc_cmap(&info->cmap);
4067 +- if (info->monspecs.modedb)
4068 +- fb_destroy_modedb(info->monspecs.modedb);
4069 +- if (info->screen_base)
4070 +- vfree(info->screen_base);
4071 +-
4072 +- fb_destroy_modelist(&info->modelist);
4073 +-
4074 +- framebuffer_release(info);
4075 +- }
4076 +-
4077 +- if (dev->backing_buffer)
4078 +- vfree(dev->backing_buffer);
4079 +-
4080 +- kref_put(&dev->kref, dlfb_free); /* ref for framebuffer */
4081 +- kref_put(&dev->kref, dlfb_free); /* last ref from kref_init */
4082 +-
4083 +- /* dev has been deallocated. Do not dereference */
4084 +- }
4085 +-
4086 +- return retval;
4087 ++ dlfb_free_framebuffer(dev);
4088 + }
4089 +
4090 + static void dlfb_usb_disconnect(struct usb_interface *interface)
4091 +@@ -1735,12 +1736,24 @@ static void dlfb_usb_disconnect(struct usb_interface *interface)
4092 + /* When non-active we'll update virtual framebuffer, but no new urbs */
4093 + atomic_set(&dev->usb_active, 0);
4094 +
4095 +- /* remove udlfb's sysfs interfaces */
4096 +- for (i = 0; i < ARRAY_SIZE(fb_device_attrs); i++)
4097 +- device_remove_file(info->dev, &fb_device_attrs[i]);
4098 +- device_remove_bin_file(info->dev, &edid_attr);
4099 +- unlink_framebuffer(info);
4100 ++ /* this function will wait for all in-flight urbs to complete */
4101 ++ dlfb_free_urb_list(dev);
4102 ++
4103 ++ if (info) {
4104 ++
4105 ++ /* remove udlfb's sysfs interfaces */
4106 ++ for (i = 0; i < ARRAY_SIZE(fb_device_attrs); i++)
4107 ++ device_remove_file(info->dev, &fb_device_attrs[i]);
4108 ++ device_remove_bin_file(info->dev, &edid_attr);
4109 ++
4110 ++ /* it's safe to uncomment next line if your kernel
4111 ++ doesn't yet have this function exported */
4112 ++ unlink_framebuffer(info);
4113 ++ }
4114 ++
4115 + usb_set_intfdata(interface, NULL);
4116 ++ dev->udev = NULL;
4117 ++ dev->gdev = NULL;
4118 +
4119 + /* if clients still have us open, will be freed on last close */
4120 + if (dev->fb_count == 0)
4121 +@@ -1806,12 +1819,12 @@ static void dlfb_free_urb_list(struct dlfb_data *dev)
4122 + int ret;
4123 + unsigned long flags;
4124 +
4125 +- pr_notice("Waiting for completes and freeing all render urbs\n");
4126 ++ pr_notice("Freeing all render urbs\n");
4127 +
4128 + /* keep waiting and freeing, until we've got 'em all */
4129 + while (count--) {
4130 +
4131 +- /* Getting interrupted means a leak, but ok at shutdown*/
4132 ++ /* Getting interrupted means a leak, but ok at disconnect */
4133 + ret = down_interruptible(&dev->urbs.limit_sem);
4134 + if (ret)
4135 + break;
4136 +@@ -1833,6 +1846,7 @@ static void dlfb_free_urb_list(struct dlfb_data *dev)
4137 + kfree(node);
4138 + }
4139 +
4140 ++ dev->urbs.count = 0;
4141 + }
4142 +
4143 + static int dlfb_alloc_urb_list(struct dlfb_data *dev, int count, size_t size)
4144 +diff --git a/drivers/xen/events.c b/drivers/xen/events.c
4145 +index e5e5812..25ea05a 100644
4146 +--- a/drivers/xen/events.c
4147 ++++ b/drivers/xen/events.c
4148 +@@ -604,7 +604,7 @@ static void disable_pirq(struct irq_data *data)
4149 + disable_dynirq(data);
4150 + }
4151 +
4152 +-static int find_irq_by_gsi(unsigned gsi)
4153 ++int xen_irq_from_gsi(unsigned gsi)
4154 + {
4155 + struct irq_info *info;
4156 +
4157 +@@ -618,6 +618,7 @@ static int find_irq_by_gsi(unsigned gsi)
4158 +
4159 + return -1;
4160 + }
4161 ++EXPORT_SYMBOL_GPL(xen_irq_from_gsi);
4162 +
4163 + /*
4164 + * Do not make any assumptions regarding the relationship between the
4165 +@@ -637,7 +638,7 @@ int xen_bind_pirq_gsi_to_irq(unsigned gsi,
4166 +
4167 + mutex_lock(&irq_mapping_update_lock);
4168 +
4169 +- irq = find_irq_by_gsi(gsi);
4170 ++ irq = xen_irq_from_gsi(gsi);
4171 + if (irq != -1) {
4172 + printk(KERN_INFO "xen_map_pirq_gsi: returning irq %d for gsi %u\n",
4173 + irq, gsi);
4174 +diff --git a/fs/aio.c b/fs/aio.c
4175 +index b9d64d8..3b65ee7 100644
4176 +--- a/fs/aio.c
4177 ++++ b/fs/aio.c
4178 +@@ -1477,6 +1477,10 @@ static ssize_t aio_setup_vectored_rw(int type, struct kiocb *kiocb, bool compat)
4179 + if (ret < 0)
4180 + goto out;
4181 +
4182 ++ ret = rw_verify_area(type, kiocb->ki_filp, &kiocb->ki_pos, ret);
4183 ++ if (ret < 0)
4184 ++ goto out;
4185 ++
4186 + kiocb->ki_nr_segs = kiocb->ki_nbytes;
4187 + kiocb->ki_cur_seg = 0;
4188 + /* ki_nbytes/left now reflect bytes instead of segs */
4189 +@@ -1488,11 +1492,17 @@ out:
4190 + return ret;
4191 + }
4192 +
4193 +-static ssize_t aio_setup_single_vector(struct kiocb *kiocb)
4194 ++static ssize_t aio_setup_single_vector(int type, struct file * file, struct kiocb *kiocb)
4195 + {
4196 ++ int bytes;
4197 ++
4198 ++ bytes = rw_verify_area(type, file, &kiocb->ki_pos, kiocb->ki_left);
4199 ++ if (bytes < 0)
4200 ++ return bytes;
4201 ++
4202 + kiocb->ki_iovec = &kiocb->ki_inline_vec;
4203 + kiocb->ki_iovec->iov_base = kiocb->ki_buf;
4204 +- kiocb->ki_iovec->iov_len = kiocb->ki_left;
4205 ++ kiocb->ki_iovec->iov_len = bytes;
4206 + kiocb->ki_nr_segs = 1;
4207 + kiocb->ki_cur_seg = 0;
4208 + return 0;
4209 +@@ -1517,10 +1527,7 @@ static ssize_t aio_setup_iocb(struct kiocb *kiocb, bool compat)
4210 + if (unlikely(!access_ok(VERIFY_WRITE, kiocb->ki_buf,
4211 + kiocb->ki_left)))
4212 + break;
4213 +- ret = security_file_permission(file, MAY_READ);
4214 +- if (unlikely(ret))
4215 +- break;
4216 +- ret = aio_setup_single_vector(kiocb);
4217 ++ ret = aio_setup_single_vector(READ, file, kiocb);
4218 + if (ret)
4219 + break;
4220 + ret = -EINVAL;
4221 +@@ -1535,10 +1542,7 @@ static ssize_t aio_setup_iocb(struct kiocb *kiocb, bool compat)
4222 + if (unlikely(!access_ok(VERIFY_READ, kiocb->ki_buf,
4223 + kiocb->ki_left)))
4224 + break;
4225 +- ret = security_file_permission(file, MAY_WRITE);
4226 +- if (unlikely(ret))
4227 +- break;
4228 +- ret = aio_setup_single_vector(kiocb);
4229 ++ ret = aio_setup_single_vector(WRITE, file, kiocb);
4230 + if (ret)
4231 + break;
4232 + ret = -EINVAL;
4233 +@@ -1549,9 +1553,6 @@ static ssize_t aio_setup_iocb(struct kiocb *kiocb, bool compat)
4234 + ret = -EBADF;
4235 + if (unlikely(!(file->f_mode & FMODE_READ)))
4236 + break;
4237 +- ret = security_file_permission(file, MAY_READ);
4238 +- if (unlikely(ret))
4239 +- break;
4240 + ret = aio_setup_vectored_rw(READ, kiocb, compat);
4241 + if (ret)
4242 + break;
4243 +@@ -1563,9 +1564,6 @@ static ssize_t aio_setup_iocb(struct kiocb *kiocb, bool compat)
4244 + ret = -EBADF;
4245 + if (unlikely(!(file->f_mode & FMODE_WRITE)))
4246 + break;
4247 +- ret = security_file_permission(file, MAY_WRITE);
4248 +- if (unlikely(ret))
4249 +- break;
4250 + ret = aio_setup_vectored_rw(WRITE, kiocb, compat);
4251 + if (ret)
4252 + break;
4253 +diff --git a/fs/bio.c b/fs/bio.c
4254 +index b980ecd..4fc4dbb 100644
4255 +--- a/fs/bio.c
4256 ++++ b/fs/bio.c
4257 +@@ -505,9 +505,14 @@ EXPORT_SYMBOL(bio_clone);
4258 + int bio_get_nr_vecs(struct block_device *bdev)
4259 + {
4260 + struct request_queue *q = bdev_get_queue(bdev);
4261 +- return min_t(unsigned,
4262 ++ int nr_pages;
4263 ++
4264 ++ nr_pages = min_t(unsigned,
4265 + queue_max_segments(q),
4266 + queue_max_sectors(q) / (PAGE_SIZE >> 9) + 1);
4267 ++
4268 ++ return min_t(unsigned, nr_pages, BIO_MAX_PAGES);
4269 ++
4270 + }
4271 + EXPORT_SYMBOL(bio_get_nr_vecs);
4272 +
4273 +diff --git a/fs/block_dev.c b/fs/block_dev.c
4274 +index 5e9f198..236dd6c 100644
4275 +--- a/fs/block_dev.c
4276 ++++ b/fs/block_dev.c
4277 +@@ -69,7 +69,7 @@ static void bdev_inode_switch_bdi(struct inode *inode,
4278 + spin_unlock(&dst->wb.list_lock);
4279 + }
4280 +
4281 +-static sector_t max_block(struct block_device *bdev)
4282 ++sector_t blkdev_max_block(struct block_device *bdev)
4283 + {
4284 + sector_t retval = ~((sector_t)0);
4285 + loff_t sz = i_size_read(bdev->bd_inode);
4286 +@@ -162,7 +162,7 @@ static int
4287 + blkdev_get_block(struct inode *inode, sector_t iblock,
4288 + struct buffer_head *bh, int create)
4289 + {
4290 +- if (iblock >= max_block(I_BDEV(inode))) {
4291 ++ if (iblock >= blkdev_max_block(I_BDEV(inode))) {
4292 + if (create)
4293 + return -EIO;
4294 +
4295 +@@ -184,7 +184,7 @@ static int
4296 + blkdev_get_blocks(struct inode *inode, sector_t iblock,
4297 + struct buffer_head *bh, int create)
4298 + {
4299 +- sector_t end_block = max_block(I_BDEV(inode));
4300 ++ sector_t end_block = blkdev_max_block(I_BDEV(inode));
4301 + unsigned long max_blocks = bh->b_size >> inode->i_blkbits;
4302 +
4303 + if ((iblock + max_blocks) > end_block) {
4304 +diff --git a/fs/buffer.c b/fs/buffer.c
4305 +index 1a30db7..8a53000 100644
4306 +--- a/fs/buffer.c
4307 ++++ b/fs/buffer.c
4308 +@@ -921,6 +921,7 @@ init_page_buffers(struct page *page, struct block_device *bdev,
4309 + struct buffer_head *head = page_buffers(page);
4310 + struct buffer_head *bh = head;
4311 + int uptodate = PageUptodate(page);
4312 ++ sector_t end_block = blkdev_max_block(I_BDEV(bdev->bd_inode));
4313 +
4314 + do {
4315 + if (!buffer_mapped(bh)) {
4316 +@@ -929,7 +930,8 @@ init_page_buffers(struct page *page, struct block_device *bdev,
4317 + bh->b_blocknr = block;
4318 + if (uptodate)
4319 + set_buffer_uptodate(bh);
4320 +- set_buffer_mapped(bh);
4321 ++ if (block < end_block)
4322 ++ set_buffer_mapped(bh);
4323 + }
4324 + block++;
4325 + bh = bh->b_this_page;
4326 +diff --git a/include/linux/fs.h b/include/linux/fs.h
4327 +index f4b6e06..fd65e0d 100644
4328 +--- a/include/linux/fs.h
4329 ++++ b/include/linux/fs.h
4330 +@@ -2058,6 +2058,7 @@ extern void unregister_blkdev(unsigned int, const char *);
4331 + extern struct block_device *bdget(dev_t);
4332 + extern struct block_device *bdgrab(struct block_device *bdev);
4333 + extern void bd_set_size(struct block_device *, loff_t size);
4334 ++extern sector_t blkdev_max_block(struct block_device *bdev);
4335 + extern void bd_forget(struct inode *inode);
4336 + extern void bdput(struct block_device *);
4337 + extern void invalidate_bdev(struct block_device *);
4338 +diff --git a/include/linux/genhd.h b/include/linux/genhd.h
4339 +index e61d319..017a7fb 100644
4340 +--- a/include/linux/genhd.h
4341 ++++ b/include/linux/genhd.h
4342 +@@ -222,12 +222,6 @@ static inline void part_pack_uuid(const u8 *uuid_str, u8 *to)
4343 + }
4344 + }
4345 +
4346 +-static inline char *part_unpack_uuid(const u8 *uuid, char *out)
4347 +-{
4348 +- sprintf(out, "%pU", uuid);
4349 +- return out;
4350 +-}
4351 +-
4352 + static inline int disk_max_parts(struct gendisk *disk)
4353 + {
4354 + if (disk->flags & GENHD_FL_EXT_DEVT)
4355 +diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
4356 +index ee2b036..557aa4c 100644
4357 +--- a/include/linux/mmc/host.h
4358 ++++ b/include/linux/mmc/host.h
4359 +@@ -323,6 +323,7 @@ struct mmc_host {
4360 +
4361 + unsigned int sdio_irqs;
4362 + struct task_struct *sdio_irq_thread;
4363 ++ bool sdio_irq_pending;
4364 + atomic_t sdio_irq_thread_abort;
4365 +
4366 + mmc_pm_flag_t pm_flags; /* requested pm features */
4367 +@@ -378,6 +379,7 @@ extern int mmc_cache_ctrl(struct mmc_host *, u8);
4368 + static inline void mmc_signal_sdio_irq(struct mmc_host *host)
4369 + {
4370 + host->ops->enable_sdio_irq(host, 0);
4371 ++ host->sdio_irq_pending = true;
4372 + wake_up_process(host->sdio_irq_thread);
4373 + }
4374 +
4375 +diff --git a/include/linux/usb.h b/include/linux/usb.h
4376 +index 69d8457..c3ba767 100644
4377 +--- a/include/linux/usb.h
4378 ++++ b/include/linux/usb.h
4379 +@@ -1371,6 +1371,7 @@ extern int usb_unlink_urb(struct urb *urb);
4380 + extern void usb_kill_urb(struct urb *urb);
4381 + extern void usb_poison_urb(struct urb *urb);
4382 + extern void usb_unpoison_urb(struct urb *urb);
4383 ++extern void usb_block_urb(struct urb *urb);
4384 + extern void usb_kill_anchored_urbs(struct usb_anchor *anchor);
4385 + extern void usb_poison_anchored_urbs(struct usb_anchor *anchor);
4386 + extern void usb_unpoison_anchored_urbs(struct usb_anchor *anchor);
4387 +@@ -1383,6 +1384,8 @@ extern struct urb *usb_get_from_anchor(struct usb_anchor *anchor);
4388 + extern void usb_scuttle_anchored_urbs(struct usb_anchor *anchor);
4389 + extern int usb_anchor_empty(struct usb_anchor *anchor);
4390 +
4391 ++#define usb_unblock_urb usb_unpoison_urb
4392 ++
4393 + /**
4394 + * usb_urb_dir_in - check if an URB describes an IN transfer
4395 + * @urb: URB to be checked
4396 +diff --git a/include/video/udlfb.h b/include/video/udlfb.h
4397 +index c41f308..f9466fa 100644
4398 +--- a/include/video/udlfb.h
4399 ++++ b/include/video/udlfb.h
4400 +@@ -41,6 +41,7 @@ struct dlfb_data {
4401 + char *backing_buffer;
4402 + int fb_count;
4403 + bool virtualized; /* true when physical usb device not present */
4404 ++ struct delayed_work init_framebuffer_work;
4405 + struct delayed_work free_framebuffer_work;
4406 + atomic_t usb_active; /* 0 = update virtual buffer, but no usb traffic */
4407 + atomic_t lost_pixels; /* 1 = a render op failed. Need screen refresh */
4408 +diff --git a/include/xen/events.h b/include/xen/events.h
4409 +index 0f77370..04399b2 100644
4410 +--- a/include/xen/events.h
4411 ++++ b/include/xen/events.h
4412 +@@ -103,6 +103,9 @@ int xen_irq_from_pirq(unsigned pirq);
4413 + /* Return the pirq allocated to the irq. */
4414 + int xen_pirq_from_irq(unsigned irq);
4415 +
4416 ++/* Return the irq allocated to the gsi */
4417 ++int xen_irq_from_gsi(unsigned gsi);
4418 ++
4419 + /* Determine whether to ignore this IRQ if it is passed to a guest. */
4420 + int xen_test_irq_shared(int irq);
4421 +
4422 +diff --git a/init/main.c b/init/main.c
4423 +index ff49a6d..45a7bf5 100644
4424 +--- a/init/main.c
4425 ++++ b/init/main.c
4426 +@@ -558,9 +558,6 @@ asmlinkage void __init start_kernel(void)
4427 + early_boot_irqs_disabled = false;
4428 + local_irq_enable();
4429 +
4430 +- /* Interrupts are enabled now so all GFP allocations are safe. */
4431 +- gfp_allowed_mask = __GFP_BITS_MASK;
4432 +-
4433 + kmem_cache_init_late();
4434 +
4435 + /*
4436 +@@ -792,6 +789,10 @@ static int __init kernel_init(void * unused)
4437 + * Wait until kthreadd is all set-up.
4438 + */
4439 + wait_for_completion(&kthreadd_done);
4440 ++
4441 ++ /* Now the scheduler is fully set up and can do blocking allocations */
4442 ++ gfp_allowed_mask = __GFP_BITS_MASK;
4443 ++
4444 + /*
4445 + * init can allocate pages on any node
4446 + */
4447 +diff --git a/kernel/workqueue.c b/kernel/workqueue.c
4448 +index f2c5638..0c0af4a 100644
4449 +--- a/kernel/workqueue.c
4450 ++++ b/kernel/workqueue.c
4451 +@@ -1215,8 +1215,13 @@ static void worker_enter_idle(struct worker *worker)
4452 + } else
4453 + wake_up_all(&gcwq->trustee_wait);
4454 +
4455 +- /* sanity check nr_running */
4456 +- WARN_ON_ONCE(gcwq->nr_workers == gcwq->nr_idle &&
4457 ++ /*
4458 ++ * Sanity check nr_running. Because trustee releases gcwq->lock
4459 ++ * between setting %WORKER_ROGUE and zapping nr_running, the
4460 ++ * warning may trigger spuriously. Check iff trustee is idle.
4461 ++ */
4462 ++ WARN_ON_ONCE(gcwq->trustee_state == TRUSTEE_DONE &&
4463 ++ gcwq->nr_workers == gcwq->nr_idle &&
4464 + atomic_read(get_gcwq_nr_running(gcwq->cpu)));
4465 + }
4466 +
4467 +diff --git a/mm/mempolicy.c b/mm/mempolicy.c
4468 +index 0a37570..a8f97d5 100644
4469 +--- a/mm/mempolicy.c
4470 ++++ b/mm/mempolicy.c
4471 +@@ -607,27 +607,6 @@ check_range(struct mm_struct *mm, unsigned long start, unsigned long end,
4472 + return first;
4473 + }
4474 +
4475 +-/* Apply policy to a single VMA */
4476 +-static int policy_vma(struct vm_area_struct *vma, struct mempolicy *new)
4477 +-{
4478 +- int err = 0;
4479 +- struct mempolicy *old = vma->vm_policy;
4480 +-
4481 +- pr_debug("vma %lx-%lx/%lx vm_ops %p vm_file %p set_policy %p\n",
4482 +- vma->vm_start, vma->vm_end, vma->vm_pgoff,
4483 +- vma->vm_ops, vma->vm_file,
4484 +- vma->vm_ops ? vma->vm_ops->set_policy : NULL);
4485 +-
4486 +- if (vma->vm_ops && vma->vm_ops->set_policy)
4487 +- err = vma->vm_ops->set_policy(vma, new);
4488 +- if (!err) {
4489 +- mpol_get(new);
4490 +- vma->vm_policy = new;
4491 +- mpol_put(old);
4492 +- }
4493 +- return err;
4494 +-}
4495 +-
4496 + /* Step 2: apply policy to a range and do splits. */
4497 + static int mbind_range(struct mm_struct *mm, unsigned long start,
4498 + unsigned long end, struct mempolicy *new_pol)
4499 +@@ -676,9 +655,23 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
4500 + if (err)
4501 + goto out;
4502 + }
4503 +- err = policy_vma(vma, new_pol);
4504 +- if (err)
4505 +- goto out;
4506 ++
4507 ++ /*
4508 ++ * Apply policy to a single VMA. The reference counting of
4509 ++ * policy for vma_policy linkages has already been handled by
4510 ++ * vma_merge and split_vma as necessary. If this is a shared
4511 ++ * policy then ->set_policy will increment the reference count
4512 ++ * for an sp node.
4513 ++ */
4514 ++ pr_debug("vma %lx-%lx/%lx vm_ops %p vm_file %p set_policy %p\n",
4515 ++ vma->vm_start, vma->vm_end, vma->vm_pgoff,
4516 ++ vma->vm_ops, vma->vm_file,
4517 ++ vma->vm_ops ? vma->vm_ops->set_policy : NULL);
4518 ++ if (vma->vm_ops && vma->vm_ops->set_policy) {
4519 ++ err = vma->vm_ops->set_policy(vma, new_pol);
4520 ++ if (err)
4521 ++ goto out;
4522 ++ }
4523 + }
4524 +
4525 + out:
4526 +diff --git a/mm/swapfile.c b/mm/swapfile.c
4527 +index f31b29d..099c209 100644
4528 +--- a/mm/swapfile.c
4529 ++++ b/mm/swapfile.c
4530 +@@ -2103,7 +2103,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
4531 + p->flags |= SWP_SOLIDSTATE;
4532 + p->cluster_next = 1 + (random32() % p->highest_bit);
4533 + }
4534 +- if (discard_swap(p) == 0 && (swap_flags & SWAP_FLAG_DISCARD))
4535 ++ if ((swap_flags & SWAP_FLAG_DISCARD) && discard_swap(p) == 0)
4536 + p->flags |= SWP_DISCARDABLE;
4537 + }
4538 +
4539 +diff --git a/net/wireless/reg.c b/net/wireless/reg.c
4540 +index f65feaa..00777da 100644
4541 +--- a/net/wireless/reg.c
4542 ++++ b/net/wireless/reg.c
4543 +@@ -388,7 +388,15 @@ static void reg_regdb_query(const char *alpha2)
4544 +
4545 + schedule_work(&reg_regdb_work);
4546 + }
4547 ++
4548 ++/* Feel free to add any other sanity checks here */
4549 ++static void reg_regdb_size_check(void)
4550 ++{
4551 ++ /* We should ideally BUILD_BUG_ON() but then random builds would fail */
4552 ++ WARN_ONCE(!reg_regdb_size, "db.txt is empty, you should update it...");
4553 ++}
4554 + #else
4555 ++static inline void reg_regdb_size_check(void) {}
4556 + static inline void reg_regdb_query(const char *alpha2) {}
4557 + #endif /* CONFIG_CFG80211_INTERNAL_REGDB */
4558 +
4559 +@@ -2337,6 +2345,8 @@ int __init regulatory_init(void)
4560 + spin_lock_init(&reg_requests_lock);
4561 + spin_lock_init(&reg_pending_beacons_lock);
4562 +
4563 ++ reg_regdb_size_check();
4564 ++
4565 + cfg80211_regdomain = cfg80211_world_regdom;
4566 +
4567 + user_alpha2[0] = '9';
4568 +diff --git a/scripts/Makefile b/scripts/Makefile
4569 +index df7678f..3626666 100644
4570 +--- a/scripts/Makefile
4571 ++++ b/scripts/Makefile
4572 +@@ -8,6 +8,8 @@
4573 + # conmakehash: Create arrays for initializing the kernel console tables
4574 + # docproc: Used in Documentation/DocBook
4575 +
4576 ++HOST_EXTRACFLAGS += -I$(srctree)/tools/include
4577 ++
4578 + hostprogs-$(CONFIG_KALLSYMS) += kallsyms
4579 + hostprogs-$(CONFIG_LOGO) += pnmtologo
4580 + hostprogs-$(CONFIG_VT) += conmakehash
4581 +diff --git a/security/selinux/selinuxfs.c b/security/selinux/selinuxfs.c
4582 +index 48a7d00..ac1e99e 100644
4583 +--- a/security/selinux/selinuxfs.c
4584 ++++ b/security/selinux/selinuxfs.c
4585 +@@ -1232,6 +1232,7 @@ static int sel_make_bools(void)
4586 + kfree(bool_pending_names[i]);
4587 + kfree(bool_pending_names);
4588 + kfree(bool_pending_values);
4589 ++ bool_num = 0;
4590 + bool_pending_names = NULL;
4591 + bool_pending_values = NULL;
4592 +
4593 +diff --git a/tools/usb/ffs-test.c b/tools/usb/ffs-test.c
4594 +index b9c7986..f17dfee 100644
4595 +--- a/tools/usb/ffs-test.c
4596 ++++ b/tools/usb/ffs-test.c
4597 +@@ -324,7 +324,7 @@ static void *start_thread_helper(void *arg)
4598 +
4599 + ret = t->in(t, t->buf, t->buf_size);
4600 + if (ret > 0) {
4601 +- ret = t->out(t, t->buf, t->buf_size);
4602 ++ ret = t->out(t, t->buf, ret);
4603 + name = out_name;
4604 + op = "write";
4605 + } else {