Gentoo Archives: gentoo-commits

From: Mike Pagano <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:master commit in: /
Date: Tue, 23 Jun 2015 12:48:24
Message-Id: 1431606174.3c00c4432f861528e758a67ed7421c676afdbe8e.mpagano@gentoo
1 commit: 3c00c4432f861528e758a67ed7421c676afdbe8e
2 Author: Mike Pagano <mpagano <AT> gentoo <DOT> org>
3 AuthorDate: Thu May 14 12:22:54 2015 +0000
4 Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org>
5 CommitDate: Thu May 14 12:22:54 2015 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=3c00c443
7
8 Linux patch 4.0.3
9
10 0000_README | 4 +
11 1002_linux-4.0.3.patch | 2827 ++++++++++++++++++++++++++++++++++++++++++++++++
12 2 files changed, 2831 insertions(+)
13
14 diff --git a/0000_README b/0000_README
15 index 4fdafa3..b11f028 100644
16 --- a/0000_README
17 +++ b/0000_README
18 @@ -51,6 +51,10 @@ Patch: 1001_linux-4.0.2.patch
19 From: http://www.kernel.org
20 Desc: Linux 4.0.2
21
22 +Patch: 1002_linux-4.0.3.patch
23 +From: http://www.kernel.org
24 +Desc: Linux 4.0.3
25 +
26 Patch: 1500_XATTR_USER_PREFIX.patch
27 From: https://bugs.gentoo.org/show_bug.cgi?id=470644
28 Desc: Support for namespace user.pax.* on tmpfs.
29
30 diff --git a/1002_linux-4.0.3.patch b/1002_linux-4.0.3.patch
31 new file mode 100644
32 index 0000000..d137bf2
33 --- /dev/null
34 +++ b/1002_linux-4.0.3.patch
35 @@ -0,0 +1,2827 @@
36 +diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
37 +index bfcb1a62a7b4..4d68ec841304 100644
38 +--- a/Documentation/kernel-parameters.txt
39 ++++ b/Documentation/kernel-parameters.txt
40 +@@ -3746,6 +3746,8 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
41 + READ_CAPACITY_16 command);
42 + f = NO_REPORT_OPCODES (don't use report opcodes
43 + command, uas only);
44 ++ g = MAX_SECTORS_240 (don't transfer more than
45 ++ 240 sectors at a time, uas only);
46 + h = CAPACITY_HEURISTICS (decrease the
47 + reported device capacity by one
48 + sector if the number is odd);
49 +diff --git a/Makefile b/Makefile
50 +index 0649a6011a76..dc9f43a019d6 100644
51 +--- a/Makefile
52 ++++ b/Makefile
53 +@@ -1,6 +1,6 @@
54 + VERSION = 4
55 + PATCHLEVEL = 0
56 +-SUBLEVEL = 2
57 ++SUBLEVEL = 3
58 + EXTRAVERSION =
59 + NAME = Hurr durr I'ma sheep
60 +
61 +diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c
62 +index ef7d112f5ce0..b0bd4e5fd5cf 100644
63 +--- a/arch/arm64/mm/dma-mapping.c
64 ++++ b/arch/arm64/mm/dma-mapping.c
65 +@@ -67,8 +67,7 @@ static void *__alloc_from_pool(size_t size, struct page **ret_page, gfp_t flags)
66 +
67 + *ret_page = phys_to_page(phys);
68 + ptr = (void *)val;
69 +- if (flags & __GFP_ZERO)
70 +- memset(ptr, 0, size);
71 ++ memset(ptr, 0, size);
72 + }
73 +
74 + return ptr;
75 +@@ -105,7 +104,6 @@ static void *__dma_alloc_coherent(struct device *dev, size_t size,
76 + struct page *page;
77 + void *addr;
78 +
79 +- size = PAGE_ALIGN(size);
80 + page = dma_alloc_from_contiguous(dev, size >> PAGE_SHIFT,
81 + get_order(size));
82 + if (!page)
83 +@@ -113,8 +111,7 @@ static void *__dma_alloc_coherent(struct device *dev, size_t size,
84 +
85 + *dma_handle = phys_to_dma(dev, page_to_phys(page));
86 + addr = page_address(page);
87 +- if (flags & __GFP_ZERO)
88 +- memset(addr, 0, size);
89 ++ memset(addr, 0, size);
90 + return addr;
91 + } else {
92 + return swiotlb_alloc_coherent(dev, size, dma_handle, flags);
93 +@@ -195,6 +192,8 @@ static void __dma_free(struct device *dev, size_t size,
94 + {
95 + void *swiotlb_addr = phys_to_virt(dma_to_phys(dev, dma_handle));
96 +
97 ++ size = PAGE_ALIGN(size);
98 ++
99 + if (!is_device_dma_coherent(dev)) {
100 + if (__free_from_pool(vaddr, size))
101 + return;
102 +diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
103 +index c7a16904cd03..1a313c468d65 100644
104 +--- a/arch/mips/Kconfig
105 ++++ b/arch/mips/Kconfig
106 +@@ -2072,7 +2072,7 @@ config MIPSR2_TO_R6_EMULATOR
107 + help
108 + Choose this option if you want to run non-R6 MIPS userland code.
109 + Even if you say 'Y' here, the emulator will still be disabled by
110 +- default. You can enable it using the 'mipsr2emul' kernel option.
111 ++ default. You can enable it using the 'mipsr2emu' kernel option.
112 + The only reason this is a build-time option is to save ~14K from the
113 + final kernel image.
114 + comment "MIPS R2-to-R6 emulator is only available for UP kernels"
115 +@@ -2142,7 +2142,7 @@ config MIPS_CMP
116 +
117 + config MIPS_CPS
118 + bool "MIPS Coherent Processing System support"
119 +- depends on SYS_SUPPORTS_MIPS_CPS
120 ++ depends on SYS_SUPPORTS_MIPS_CPS && !64BIT
121 + select MIPS_CM
122 + select MIPS_CPC
123 + select MIPS_CPS_PM if HOTPLUG_CPU
124 +diff --git a/arch/mips/Makefile b/arch/mips/Makefile
125 +index 8f57fc72d62c..1b4dab1e6ab8 100644
126 +--- a/arch/mips/Makefile
127 ++++ b/arch/mips/Makefile
128 +@@ -197,11 +197,17 @@ endif
129 + # Warning: the 64-bit MIPS architecture does not support the `smartmips' extension
130 + # Pass -Wa,--no-warn to disable all assembler warnings until the kernel code has
131 + # been fixed properly.
132 +-mips-cflags := "$(cflags-y)"
133 +-cflags-$(CONFIG_CPU_HAS_SMARTMIPS) += $(call cc-option,$(mips-cflags),-msmartmips) -Wa,--no-warn
134 +-cflags-$(CONFIG_CPU_MICROMIPS) += $(call cc-option,$(mips-cflags),-mmicromips)
135 ++mips-cflags := $(cflags-y)
136 ++ifeq ($(CONFIG_CPU_HAS_SMARTMIPS),y)
137 ++smartmips-ase := $(call cc-option-yn,$(mips-cflags) -msmartmips)
138 ++cflags-$(smartmips-ase) += -msmartmips -Wa,--no-warn
139 ++endif
140 ++ifeq ($(CONFIG_CPU_MICROMIPS),y)
141 ++micromips-ase := $(call cc-option-yn,$(mips-cflags) -mmicromips)
142 ++cflags-$(micromips-ase) += -mmicromips
143 ++endif
144 + ifeq ($(CONFIG_CPU_HAS_MSA),y)
145 +-toolchain-msa := $(call cc-option-yn,-$(mips-cflags),mhard-float -mfp64 -Wa$(comma)-mmsa)
146 ++toolchain-msa := $(call cc-option-yn,$(mips-cflags) -mhard-float -mfp64 -Wa$(comma)-mmsa)
147 + cflags-$(toolchain-msa) += -DTOOLCHAIN_SUPPORTS_MSA
148 + endif
149 +
150 +diff --git a/arch/mips/bcm47xx/board.c b/arch/mips/bcm47xx/board.c
151 +index b3ae068ca4fa..3fd369d74444 100644
152 +--- a/arch/mips/bcm47xx/board.c
153 ++++ b/arch/mips/bcm47xx/board.c
154 +@@ -247,8 +247,8 @@ static __init const struct bcm47xx_board_type *bcm47xx_board_get_nvram(void)
155 + }
156 +
157 + if (bcm47xx_nvram_getenv("hardware_version", buf1, sizeof(buf1)) >= 0 &&
158 +- bcm47xx_nvram_getenv("boardtype", buf2, sizeof(buf2)) >= 0) {
159 +- for (e2 = bcm47xx_board_list_boot_hw; e2->value1; e2++) {
160 ++ bcm47xx_nvram_getenv("boardnum", buf2, sizeof(buf2)) >= 0) {
161 ++ for (e2 = bcm47xx_board_list_hw_version_num; e2->value1; e2++) {
162 + if (!strstarts(buf1, e2->value1) &&
163 + !strcmp(buf2, e2->value2))
164 + return &e2->board;
165 +diff --git a/arch/mips/bcm63xx/prom.c b/arch/mips/bcm63xx/prom.c
166 +index e1f27d653f60..7019e2967009 100644
167 +--- a/arch/mips/bcm63xx/prom.c
168 ++++ b/arch/mips/bcm63xx/prom.c
169 +@@ -17,7 +17,6 @@
170 + #include <bcm63xx_cpu.h>
171 + #include <bcm63xx_io.h>
172 + #include <bcm63xx_regs.h>
173 +-#include <bcm63xx_gpio.h>
174 +
175 + void __init prom_init(void)
176 + {
177 +@@ -53,9 +52,6 @@ void __init prom_init(void)
178 + reg &= ~mask;
179 + bcm_perf_writel(reg, PERF_CKCTL_REG);
180 +
181 +- /* register gpiochip */
182 +- bcm63xx_gpio_init();
183 +-
184 + /* do low level board init */
185 + board_prom_init();
186 +
187 +diff --git a/arch/mips/bcm63xx/setup.c b/arch/mips/bcm63xx/setup.c
188 +index 6660c7ddf87b..240fb4ffa55c 100644
189 +--- a/arch/mips/bcm63xx/setup.c
190 ++++ b/arch/mips/bcm63xx/setup.c
191 +@@ -20,6 +20,7 @@
192 + #include <bcm63xx_cpu.h>
193 + #include <bcm63xx_regs.h>
194 + #include <bcm63xx_io.h>
195 ++#include <bcm63xx_gpio.h>
196 +
197 + void bcm63xx_machine_halt(void)
198 + {
199 +@@ -160,6 +161,9 @@ void __init plat_mem_setup(void)
200 +
201 + int __init bcm63xx_register_devices(void)
202 + {
203 ++ /* register gpiochip */
204 ++ bcm63xx_gpio_init();
205 ++
206 + return board_register_devices();
207 + }
208 +
209 +diff --git a/arch/mips/cavium-octeon/dma-octeon.c b/arch/mips/cavium-octeon/dma-octeon.c
210 +index 7d8987818ccf..d8960d46417b 100644
211 +--- a/arch/mips/cavium-octeon/dma-octeon.c
212 ++++ b/arch/mips/cavium-octeon/dma-octeon.c
213 +@@ -306,7 +306,7 @@ void __init plat_swiotlb_setup(void)
214 + swiotlbsize = 64 * (1<<20);
215 + }
216 + #endif
217 +-#ifdef CONFIG_USB_OCTEON_OHCI
218 ++#ifdef CONFIG_USB_OHCI_HCD_PLATFORM
219 + /* OCTEON II ohci is only 32-bit. */
220 + if (OCTEON_IS_OCTEON2() && max_addr >= 0x100000000ul)
221 + swiotlbsize = 64 * (1<<20);
222 +diff --git a/arch/mips/cavium-octeon/setup.c b/arch/mips/cavium-octeon/setup.c
223 +index a42110e7edbc..a7f40820e567 100644
224 +--- a/arch/mips/cavium-octeon/setup.c
225 ++++ b/arch/mips/cavium-octeon/setup.c
226 +@@ -413,7 +413,10 @@ static void octeon_restart(char *command)
227 +
228 + mb();
229 + while (1)
230 +- cvmx_write_csr(CVMX_CIU_SOFT_RST, 1);
231 ++ if (OCTEON_IS_OCTEON3())
232 ++ cvmx_write_csr(CVMX_RST_SOFT_RST, 1);
233 ++ else
234 ++ cvmx_write_csr(CVMX_CIU_SOFT_RST, 1);
235 + }
236 +
237 +
238 +diff --git a/arch/mips/include/asm/cacheflush.h b/arch/mips/include/asm/cacheflush.h
239 +index e08381a37f8b..723229f4cf27 100644
240 +--- a/arch/mips/include/asm/cacheflush.h
241 ++++ b/arch/mips/include/asm/cacheflush.h
242 +@@ -29,6 +29,20 @@
243 + * - flush_icache_all() flush the entire instruction cache
244 + * - flush_data_cache_page() flushes a page from the data cache
245 + */
246 ++
247 ++ /*
248 ++ * This flag is used to indicate that the page pointed to by a pte
249 ++ * is dirty and requires cleaning before returning it to the user.
250 ++ */
251 ++#define PG_dcache_dirty PG_arch_1
252 ++
253 ++#define Page_dcache_dirty(page) \
254 ++ test_bit(PG_dcache_dirty, &(page)->flags)
255 ++#define SetPageDcacheDirty(page) \
256 ++ set_bit(PG_dcache_dirty, &(page)->flags)
257 ++#define ClearPageDcacheDirty(page) \
258 ++ clear_bit(PG_dcache_dirty, &(page)->flags)
259 ++
260 + extern void (*flush_cache_all)(void);
261 + extern void (*__flush_cache_all)(void);
262 + extern void (*flush_cache_mm)(struct mm_struct *mm);
263 +@@ -37,13 +51,15 @@ extern void (*flush_cache_range)(struct vm_area_struct *vma,
264 + unsigned long start, unsigned long end);
265 + extern void (*flush_cache_page)(struct vm_area_struct *vma, unsigned long page, unsigned long pfn);
266 + extern void __flush_dcache_page(struct page *page);
267 ++extern void __flush_icache_page(struct vm_area_struct *vma, struct page *page);
268 +
269 + #define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 1
270 + static inline void flush_dcache_page(struct page *page)
271 + {
272 +- if (cpu_has_dc_aliases || !cpu_has_ic_fills_f_dc)
273 ++ if (cpu_has_dc_aliases)
274 + __flush_dcache_page(page);
275 +-
276 ++ else if (!cpu_has_ic_fills_f_dc)
277 ++ SetPageDcacheDirty(page);
278 + }
279 +
280 + #define flush_dcache_mmap_lock(mapping) do { } while (0)
281 +@@ -61,6 +77,11 @@ static inline void flush_anon_page(struct vm_area_struct *vma,
282 + static inline void flush_icache_page(struct vm_area_struct *vma,
283 + struct page *page)
284 + {
285 ++ if (!cpu_has_ic_fills_f_dc && (vma->vm_flags & VM_EXEC) &&
286 ++ Page_dcache_dirty(page)) {
287 ++ __flush_icache_page(vma, page);
288 ++ ClearPageDcacheDirty(page);
289 ++ }
290 + }
291 +
292 + extern void (*flush_icache_range)(unsigned long start, unsigned long end);
293 +@@ -95,19 +116,6 @@ extern void (*flush_icache_all)(void);
294 + extern void (*local_flush_data_cache_page)(void * addr);
295 + extern void (*flush_data_cache_page)(unsigned long addr);
296 +
297 +-/*
298 +- * This flag is used to indicate that the page pointed to by a pte
299 +- * is dirty and requires cleaning before returning it to the user.
300 +- */
301 +-#define PG_dcache_dirty PG_arch_1
302 +-
303 +-#define Page_dcache_dirty(page) \
304 +- test_bit(PG_dcache_dirty, &(page)->flags)
305 +-#define SetPageDcacheDirty(page) \
306 +- set_bit(PG_dcache_dirty, &(page)->flags)
307 +-#define ClearPageDcacheDirty(page) \
308 +- clear_bit(PG_dcache_dirty, &(page)->flags)
309 +-
310 + /* Run kernel code uncached, useful for cache probing functions. */
311 + unsigned long run_uncached(void *func);
312 +
313 +diff --git a/arch/mips/include/asm/cpu-features.h b/arch/mips/include/asm/cpu-features.h
314 +index 0d8208de9a3f..345fd7f80730 100644
315 +--- a/arch/mips/include/asm/cpu-features.h
316 ++++ b/arch/mips/include/asm/cpu-features.h
317 +@@ -235,8 +235,39 @@
318 + /* MIPSR2 and MIPSR6 have a lot of similarities */
319 + #define cpu_has_mips_r2_r6 (cpu_has_mips_r2 | cpu_has_mips_r6)
320 +
321 ++/*
322 ++ * cpu_has_mips_r2_exec_hazard - return if IHB is required on current processor
323 ++ *
324 ++ * Returns non-zero value if the current processor implementation requires
325 ++ * an IHB instruction to deal with an instruction hazard as per MIPS R2
326 ++ * architecture specification, zero otherwise.
327 ++ */
328 + #ifndef cpu_has_mips_r2_exec_hazard
329 +-#define cpu_has_mips_r2_exec_hazard (cpu_has_mips_r2 | cpu_has_mips_r6)
330 ++#define cpu_has_mips_r2_exec_hazard \
331 ++({ \
332 ++ int __res; \
333 ++ \
334 ++ switch (current_cpu_type()) { \
335 ++ case CPU_M14KC: \
336 ++ case CPU_74K: \
337 ++ case CPU_1074K: \
338 ++ case CPU_PROAPTIV: \
339 ++ case CPU_P5600: \
340 ++ case CPU_M5150: \
341 ++ case CPU_QEMU_GENERIC: \
342 ++ case CPU_CAVIUM_OCTEON: \
343 ++ case CPU_CAVIUM_OCTEON_PLUS: \
344 ++ case CPU_CAVIUM_OCTEON2: \
345 ++ case CPU_CAVIUM_OCTEON3: \
346 ++ __res = 0; \
347 ++ break; \
348 ++ \
349 ++ default: \
350 ++ __res = 1; \
351 ++ } \
352 ++ \
353 ++ __res; \
354 ++})
355 + #endif
356 +
357 + /*
358 +diff --git a/arch/mips/include/asm/elf.h b/arch/mips/include/asm/elf.h
359 +index 535f196ffe02..694925a26924 100644
360 +--- a/arch/mips/include/asm/elf.h
361 ++++ b/arch/mips/include/asm/elf.h
362 +@@ -294,6 +294,9 @@ do { \
363 + if (personality(current->personality) != PER_LINUX) \
364 + set_personality(PER_LINUX); \
365 + \
366 ++ clear_thread_flag(TIF_HYBRID_FPREGS); \
367 ++ set_thread_flag(TIF_32BIT_FPREGS); \
368 ++ \
369 + mips_set_personality_fp(state); \
370 + \
371 + current->thread.abi = &mips_abi; \
372 +@@ -319,6 +322,8 @@ do { \
373 + do { \
374 + set_thread_flag(TIF_32BIT_REGS); \
375 + set_thread_flag(TIF_32BIT_ADDR); \
376 ++ clear_thread_flag(TIF_HYBRID_FPREGS); \
377 ++ set_thread_flag(TIF_32BIT_FPREGS); \
378 + \
379 + mips_set_personality_fp(state); \
380 + \
381 +diff --git a/arch/mips/include/asm/mach-cavium-octeon/cpu-feature-overrides.h b/arch/mips/include/asm/mach-cavium-octeon/cpu-feature-overrides.h
382 +index fa1f3cfbae8d..d68e685cde60 100644
383 +--- a/arch/mips/include/asm/mach-cavium-octeon/cpu-feature-overrides.h
384 ++++ b/arch/mips/include/asm/mach-cavium-octeon/cpu-feature-overrides.h
385 +@@ -50,7 +50,6 @@
386 + #define cpu_has_mips32r2 0
387 + #define cpu_has_mips64r1 0
388 + #define cpu_has_mips64r2 1
389 +-#define cpu_has_mips_r2_exec_hazard 0
390 + #define cpu_has_dsp 0
391 + #define cpu_has_dsp2 0
392 + #define cpu_has_mipsmt 0
393 +diff --git a/arch/mips/include/asm/octeon/cvmx.h b/arch/mips/include/asm/octeon/cvmx.h
394 +index 33db1c806b01..774bb45834cb 100644
395 +--- a/arch/mips/include/asm/octeon/cvmx.h
396 ++++ b/arch/mips/include/asm/octeon/cvmx.h
397 +@@ -436,14 +436,6 @@ static inline uint64_t cvmx_get_cycle_global(void)
398 +
399 + /***************************************************************************/
400 +
401 +-static inline void cvmx_reset_octeon(void)
402 +-{
403 +- union cvmx_ciu_soft_rst ciu_soft_rst;
404 +- ciu_soft_rst.u64 = 0;
405 +- ciu_soft_rst.s.soft_rst = 1;
406 +- cvmx_write_csr(CVMX_CIU_SOFT_RST, ciu_soft_rst.u64);
407 +-}
408 +-
409 + /* Return the number of cores available in the chip */
410 + static inline uint32_t cvmx_octeon_num_cores(void)
411 + {
412 +diff --git a/arch/mips/include/asm/octeon/pci-octeon.h b/arch/mips/include/asm/octeon/pci-octeon.h
413 +index 64ba56a02843..1884609741a8 100644
414 +--- a/arch/mips/include/asm/octeon/pci-octeon.h
415 ++++ b/arch/mips/include/asm/octeon/pci-octeon.h
416 +@@ -11,9 +11,6 @@
417 +
418 + #include <linux/pci.h>
419 +
420 +-/* Some PCI cards require delays when accessing config space. */
421 +-#define PCI_CONFIG_SPACE_DELAY 10000
422 +-
423 + /*
424 + * The physical memory base mapped by BAR1. 256MB at the end of the
425 + * first 4GB.
426 +diff --git a/arch/mips/include/asm/pgtable.h b/arch/mips/include/asm/pgtable.h
427 +index bef782c4a44b..f8f809fd6c6d 100644
428 +--- a/arch/mips/include/asm/pgtable.h
429 ++++ b/arch/mips/include/asm/pgtable.h
430 +@@ -127,10 +127,6 @@ do { \
431 + } \
432 + } while(0)
433 +
434 +-
435 +-extern void set_pte_at(struct mm_struct *mm, unsigned long addr, pte_t *ptep,
436 +- pte_t pteval);
437 +-
438 + #if defined(CONFIG_PHYS_ADDR_T_64BIT) && defined(CONFIG_CPU_MIPS32)
439 +
440 + #define pte_none(pte) (!(((pte).pte_low | (pte).pte_high) & ~_PAGE_GLOBAL))
441 +@@ -154,6 +150,7 @@ static inline void set_pte(pte_t *ptep, pte_t pte)
442 + }
443 + }
444 + }
445 ++#define set_pte_at(mm, addr, ptep, pteval) set_pte(ptep, pteval)
446 +
447 + static inline void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
448 + {
449 +@@ -192,6 +189,7 @@ static inline void set_pte(pte_t *ptep, pte_t pteval)
450 + }
451 + #endif
452 + }
453 ++#define set_pte_at(mm, addr, ptep, pteval) set_pte(ptep, pteval)
454 +
455 + static inline void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
456 + {
457 +@@ -407,12 +405,15 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
458 +
459 + extern void __update_tlb(struct vm_area_struct *vma, unsigned long address,
460 + pte_t pte);
461 ++extern void __update_cache(struct vm_area_struct *vma, unsigned long address,
462 ++ pte_t pte);
463 +
464 + static inline void update_mmu_cache(struct vm_area_struct *vma,
465 + unsigned long address, pte_t *ptep)
466 + {
467 + pte_t pte = *ptep;
468 + __update_tlb(vma, address, pte);
469 ++ __update_cache(vma, address, pte);
470 + }
471 +
472 + static inline void update_mmu_cache_pmd(struct vm_area_struct *vma,
473 +diff --git a/arch/mips/include/asm/r4kcache.h b/arch/mips/include/asm/r4kcache.h
474 +index 1b22d2da88a1..38902bf97adc 100644
475 +--- a/arch/mips/include/asm/r4kcache.h
476 ++++ b/arch/mips/include/asm/r4kcache.h
477 +@@ -12,6 +12,8 @@
478 + #ifndef _ASM_R4KCACHE_H
479 + #define _ASM_R4KCACHE_H
480 +
481 ++#include <linux/stringify.h>
482 ++
483 + #include <asm/asm.h>
484 + #include <asm/cacheops.h>
485 + #include <asm/compiler.h>
486 +@@ -344,7 +346,7 @@ static inline void invalidate_tcache_page(unsigned long addr)
487 + " cache %1, 0x0a0(%0); cache %1, 0x0b0(%0)\n" \
488 + " cache %1, 0x0c0(%0); cache %1, 0x0d0(%0)\n" \
489 + " cache %1, 0x0e0(%0); cache %1, 0x0f0(%0)\n" \
490 +- " addiu $1, $0, 0x100 \n" \
491 ++ " "__stringify(LONG_ADDIU)" $1, %0, 0x100 \n" \
492 + " cache %1, 0x000($1); cache %1, 0x010($1)\n" \
493 + " cache %1, 0x020($1); cache %1, 0x030($1)\n" \
494 + " cache %1, 0x040($1); cache %1, 0x050($1)\n" \
495 +@@ -368,17 +370,17 @@ static inline void invalidate_tcache_page(unsigned long addr)
496 + " cache %1, 0x040(%0); cache %1, 0x060(%0)\n" \
497 + " cache %1, 0x080(%0); cache %1, 0x0a0(%0)\n" \
498 + " cache %1, 0x0c0(%0); cache %1, 0x0e0(%0)\n" \
499 +- " addiu $1, %0, 0x100\n" \
500 ++ " "__stringify(LONG_ADDIU)" $1, %0, 0x100 \n" \
501 + " cache %1, 0x000($1); cache %1, 0x020($1)\n" \
502 + " cache %1, 0x040($1); cache %1, 0x060($1)\n" \
503 + " cache %1, 0x080($1); cache %1, 0x0a0($1)\n" \
504 + " cache %1, 0x0c0($1); cache %1, 0x0e0($1)\n" \
505 +- " addiu $1, $1, 0x100\n" \
506 ++ " "__stringify(LONG_ADDIU)" $1, $1, 0x100 \n" \
507 + " cache %1, 0x000($1); cache %1, 0x020($1)\n" \
508 + " cache %1, 0x040($1); cache %1, 0x060($1)\n" \
509 + " cache %1, 0x080($1); cache %1, 0x0a0($1)\n" \
510 + " cache %1, 0x0c0($1); cache %1, 0x0e0($1)\n" \
511 +- " addiu $1, $1, 0x100\n" \
512 ++ " "__stringify(LONG_ADDIU)" $1, $1, 0x100\n" \
513 + " cache %1, 0x000($1); cache %1, 0x020($1)\n" \
514 + " cache %1, 0x040($1); cache %1, 0x060($1)\n" \
515 + " cache %1, 0x080($1); cache %1, 0x0a0($1)\n" \
516 +@@ -396,25 +398,25 @@ static inline void invalidate_tcache_page(unsigned long addr)
517 + " .set noat\n" \
518 + " cache %1, 0x000(%0); cache %1, 0x040(%0)\n" \
519 + " cache %1, 0x080(%0); cache %1, 0x0c0(%0)\n" \
520 +- " addiu $1, %0, 0x100\n" \
521 ++ " "__stringify(LONG_ADDIU)" $1, %0, 0x100 \n" \
522 + " cache %1, 0x000($1); cache %1, 0x040($1)\n" \
523 + " cache %1, 0x080($1); cache %1, 0x0c0($1)\n" \
524 +- " addiu $1, %0, 0x100\n" \
525 ++ " "__stringify(LONG_ADDIU)" $1, $1, 0x100 \n" \
526 + " cache %1, 0x000($1); cache %1, 0x040($1)\n" \
527 + " cache %1, 0x080($1); cache %1, 0x0c0($1)\n" \
528 +- " addiu $1, %0, 0x100\n" \
529 ++ " "__stringify(LONG_ADDIU)" $1, $1, 0x100 \n" \
530 + " cache %1, 0x000($1); cache %1, 0x040($1)\n" \
531 + " cache %1, 0x080($1); cache %1, 0x0c0($1)\n" \
532 +- " addiu $1, %0, 0x100\n" \
533 ++ " "__stringify(LONG_ADDIU)" $1, $1, 0x100 \n" \
534 + " cache %1, 0x000($1); cache %1, 0x040($1)\n" \
535 + " cache %1, 0x080($1); cache %1, 0x0c0($1)\n" \
536 +- " addiu $1, %0, 0x100\n" \
537 ++ " "__stringify(LONG_ADDIU)" $1, $1, 0x100 \n" \
538 + " cache %1, 0x000($1); cache %1, 0x040($1)\n" \
539 + " cache %1, 0x080($1); cache %1, 0x0c0($1)\n" \
540 +- " addiu $1, %0, 0x100\n" \
541 ++ " "__stringify(LONG_ADDIU)" $1, $1, 0x100 \n" \
542 + " cache %1, 0x000($1); cache %1, 0x040($1)\n" \
543 + " cache %1, 0x080($1); cache %1, 0x0c0($1)\n" \
544 +- " addiu $1, %0, 0x100\n" \
545 ++ " "__stringify(LONG_ADDIU)" $1, $1, 0x100 \n" \
546 + " cache %1, 0x000($1); cache %1, 0x040($1)\n" \
547 + " cache %1, 0x080($1); cache %1, 0x0c0($1)\n" \
548 + " .set pop\n" \
549 +@@ -429,39 +431,38 @@ static inline void invalidate_tcache_page(unsigned long addr)
550 + " .set mips64r6\n" \
551 + " .set noat\n" \
552 + " cache %1, 0x000(%0); cache %1, 0x080(%0)\n" \
553 +- " addiu $1, %0, 0x100\n" \
554 +- " cache %1, 0x000(%0); cache %1, 0x080(%0)\n" \
555 +- " addiu $1, %0, 0x100\n" \
556 +- " cache %1, 0x000(%0); cache %1, 0x080(%0)\n" \
557 +- " addiu $1, %0, 0x100\n" \
558 +- " cache %1, 0x000(%0); cache %1, 0x080(%0)\n" \
559 +- " addiu $1, %0, 0x100\n" \
560 +- " cache %1, 0x000(%0); cache %1, 0x080(%0)\n" \
561 +- " addiu $1, %0, 0x100\n" \
562 +- " cache %1, 0x000(%0); cache %1, 0x080(%0)\n" \
563 +- " addiu $1, %0, 0x100\n" \
564 +- " cache %1, 0x000(%0); cache %1, 0x080(%0)\n" \
565 +- " addiu $1, %0, 0x100\n" \
566 +- " cache %1, 0x000(%0); cache %1, 0x080(%0)\n" \
567 +- " addiu $1, %0, 0x100\n" \
568 +- " cache %1, 0x000(%0); cache %1, 0x080(%0)\n" \
569 +- " addiu $1, %0, 0x100\n" \
570 +- " cache %1, 0x000(%0); cache %1, 0x080(%0)\n" \
571 +- " addiu $1, %0, 0x100\n" \
572 +- " cache %1, 0x000(%0); cache %1, 0x080(%0)\n" \
573 +- " addiu $1, %0, 0x100\n" \
574 +- " cache %1, 0x000(%0); cache %1, 0x080(%0)\n" \
575 +- " addiu $1, %0, 0x100\n" \
576 +- " cache %1, 0x000(%0); cache %1, 0x080(%0)\n" \
577 +- " addiu $1, %0, 0x100\n" \
578 +- " cache %1, 0x000(%0); cache %1, 0x080(%0)\n" \
579 +- " addiu $1, %0, 0x100\n" \
580 +- " cache %1, 0x000(%0); cache %1, 0x080(%0)\n" \
581 +- " addiu $1, %0, 0x100\n" \
582 +- " cache %1, 0x000(%0); cache %1, 0x080(%0)\n" \
583 +- " addiu $1, %0, 0x100\n" \
584 +- " cache %1, 0x000(%0); cache %1, 0x080(%0)\n" \
585 +- " addiu $1, %0, 0x100\n" \
586 ++ " "__stringify(LONG_ADDIU)" $1, %0, 0x100 \n" \
587 ++ " cache %1, 0x000($1); cache %1, 0x080($1)\n" \
588 ++ " "__stringify(LONG_ADDIU)" $1, $1, 0x100 \n" \
589 ++ " cache %1, 0x000($1); cache %1, 0x080($1)\n" \
590 ++ " "__stringify(LONG_ADDIU)" $1, $1, 0x100 \n" \
591 ++ " cache %1, 0x000($1); cache %1, 0x080($1)\n" \
592 ++ " "__stringify(LONG_ADDIU)" $1, $1, 0x100 \n" \
593 ++ " cache %1, 0x000($1); cache %1, 0x080($1)\n" \
594 ++ " "__stringify(LONG_ADDIU)" $1, $1, 0x100 \n" \
595 ++ " cache %1, 0x000($1); cache %1, 0x080($1)\n" \
596 ++ " "__stringify(LONG_ADDIU)" $1, $1, 0x100 \n" \
597 ++ " cache %1, 0x000($1); cache %1, 0x080($1)\n" \
598 ++ " "__stringify(LONG_ADDIU)" $1, $1, 0x100 \n" \
599 ++ " cache %1, 0x000($1); cache %1, 0x080($1)\n" \
600 ++ " "__stringify(LONG_ADDIU)" $1, $1, 0x100 \n" \
601 ++ " cache %1, 0x000($1); cache %1, 0x080($1)\n" \
602 ++ " "__stringify(LONG_ADDIU)" $1, $1, 0x100 \n" \
603 ++ " cache %1, 0x000($1); cache %1, 0x080($1)\n" \
604 ++ " "__stringify(LONG_ADDIU)" $1, $1, 0x100 \n" \
605 ++ " cache %1, 0x000($1); cache %1, 0x080($1)\n" \
606 ++ " "__stringify(LONG_ADDIU)" $1, $1, 0x100 \n" \
607 ++ " cache %1, 0x000($1); cache %1, 0x080($1)\n" \
608 ++ " "__stringify(LONG_ADDIU)" $1, $1, 0x100 \n" \
609 ++ " cache %1, 0x000($1); cache %1, 0x080($1)\n" \
610 ++ " "__stringify(LONG_ADDIU)" $1, $1, 0x100 \n" \
611 ++ " cache %1, 0x000($1); cache %1, 0x080($1)\n" \
612 ++ " "__stringify(LONG_ADDIU)" $1, $1, 0x100 \n" \
613 ++ " cache %1, 0x000($1); cache %1, 0x080($1)\n" \
614 ++ " "__stringify(LONG_ADDIU)" $1, $1, 0x100 \n" \
615 ++ " cache %1, 0x000($1); cache %1, 0x080($1)\n" \
616 ++ " "__stringify(LONG_ADDIU)" $1, $1, 0x100 \n" \
617 ++ " cache %1, 0x000($1); cache %1, 0x080($1)\n" \
618 + " .set pop\n" \
619 + : \
620 + : "r" (base), \
621 +diff --git a/arch/mips/include/asm/spinlock.h b/arch/mips/include/asm/spinlock.h
622 +index b4548690ade9..1fca2e0793dc 100644
623 +--- a/arch/mips/include/asm/spinlock.h
624 ++++ b/arch/mips/include/asm/spinlock.h
625 +@@ -263,7 +263,7 @@ static inline void arch_read_unlock(arch_rwlock_t *rw)
626 + if (R10000_LLSC_WAR) {
627 + __asm__ __volatile__(
628 + "1: ll %1, %2 # arch_read_unlock \n"
629 +- " addiu %1, 1 \n"
630 ++ " addiu %1, -1 \n"
631 + " sc %1, %0 \n"
632 + " beqzl %1, 1b \n"
633 + : "=" GCC_OFF_SMALL_ASM() (rw->lock), "=&r" (tmp)
634 +diff --git a/arch/mips/kernel/entry.S b/arch/mips/kernel/entry.S
635 +index af41ba6db960..7791840cf22c 100644
636 +--- a/arch/mips/kernel/entry.S
637 ++++ b/arch/mips/kernel/entry.S
638 +@@ -10,6 +10,7 @@
639 +
640 + #include <asm/asm.h>
641 + #include <asm/asmmacro.h>
642 ++#include <asm/compiler.h>
643 + #include <asm/regdef.h>
644 + #include <asm/mipsregs.h>
645 + #include <asm/stackframe.h>
646 +@@ -185,7 +186,7 @@ syscall_exit_work:
647 + * For C code use the inline version named instruction_hazard().
648 + */
649 + LEAF(mips_ihb)
650 +- .set mips32r2
651 ++ .set MIPS_ISA_LEVEL_RAW
652 + jr.hb ra
653 + nop
654 + END(mips_ihb)
655 +diff --git a/arch/mips/kernel/smp-cps.c b/arch/mips/kernel/smp-cps.c
656 +index bed7590e475f..d5589bedd0a4 100644
657 +--- a/arch/mips/kernel/smp-cps.c
658 ++++ b/arch/mips/kernel/smp-cps.c
659 +@@ -88,6 +88,12 @@ static void __init cps_smp_setup(void)
660 +
661 + /* Make core 0 coherent with everything */
662 + write_gcr_cl_coherence(0xff);
663 ++
664 ++#ifdef CONFIG_MIPS_MT_FPAFF
665 ++ /* If we have an FPU, enroll ourselves in the FPU-full mask */
666 ++ if (cpu_has_fpu)
667 ++ cpu_set(0, mt_fpu_cpumask);
668 ++#endif /* CONFIG_MIPS_MT_FPAFF */
669 + }
670 +
671 + static void __init cps_prepare_cpus(unsigned int max_cpus)
672 +diff --git a/arch/mips/mm/cache.c b/arch/mips/mm/cache.c
673 +index 7e3ea7766822..77d96db8253c 100644
674 +--- a/arch/mips/mm/cache.c
675 ++++ b/arch/mips/mm/cache.c
676 +@@ -119,36 +119,37 @@ void __flush_anon_page(struct page *page, unsigned long vmaddr)
677 +
678 + EXPORT_SYMBOL(__flush_anon_page);
679 +
680 +-static void mips_flush_dcache_from_pte(pte_t pteval, unsigned long address)
681 ++void __flush_icache_page(struct vm_area_struct *vma, struct page *page)
682 ++{
683 ++ unsigned long addr;
684 ++
685 ++ if (PageHighMem(page))
686 ++ return;
687 ++
688 ++ addr = (unsigned long) page_address(page);
689 ++ flush_data_cache_page(addr);
690 ++}
691 ++EXPORT_SYMBOL_GPL(__flush_icache_page);
692 ++
693 ++void __update_cache(struct vm_area_struct *vma, unsigned long address,
694 ++ pte_t pte)
695 + {
696 + struct page *page;
697 +- unsigned long pfn = pte_pfn(pteval);
698 ++ unsigned long pfn, addr;
699 ++ int exec = (vma->vm_flags & VM_EXEC) && !cpu_has_ic_fills_f_dc;
700 +
701 ++ pfn = pte_pfn(pte);
702 + if (unlikely(!pfn_valid(pfn)))
703 + return;
704 +-
705 + page = pfn_to_page(pfn);
706 + if (page_mapping(page) && Page_dcache_dirty(page)) {
707 +- unsigned long page_addr = (unsigned long) page_address(page);
708 +-
709 +- if (!cpu_has_ic_fills_f_dc ||
710 +- pages_do_alias(page_addr, address & PAGE_MASK))
711 +- flush_data_cache_page(page_addr);
712 ++ addr = (unsigned long) page_address(page);
713 ++ if (exec || pages_do_alias(addr, address & PAGE_MASK))
714 ++ flush_data_cache_page(addr);
715 + ClearPageDcacheDirty(page);
716 + }
717 + }
718 +
719 +-void set_pte_at(struct mm_struct *mm, unsigned long addr,
720 +- pte_t *ptep, pte_t pteval)
721 +-{
722 +- if (cpu_has_dc_aliases || !cpu_has_ic_fills_f_dc) {
723 +- if (pte_present(pteval))
724 +- mips_flush_dcache_from_pte(pteval, addr);
725 +- }
726 +-
727 +- set_pte(ptep, pteval);
728 +-}
729 +-
730 + unsigned long _page_cachable_default;
731 + EXPORT_SYMBOL(_page_cachable_default);
732 +
733 +diff --git a/arch/mips/mm/tlbex.c b/arch/mips/mm/tlbex.c
734 +index d75ff73a2012..a79fd0af0224 100644
735 +--- a/arch/mips/mm/tlbex.c
736 ++++ b/arch/mips/mm/tlbex.c
737 +@@ -501,26 +501,9 @@ static void build_tlb_write_entry(u32 **p, struct uasm_label **l,
738 + case tlb_indexed: tlbw = uasm_i_tlbwi; break;
739 + }
740 +
741 +- if (cpu_has_mips_r2_exec_hazard) {
742 +- /*
743 +- * The architecture spec says an ehb is required here,
744 +- * but a number of cores do not have the hazard and
745 +- * using an ehb causes an expensive pipeline stall.
746 +- */
747 +- switch (current_cpu_type()) {
748 +- case CPU_M14KC:
749 +- case CPU_74K:
750 +- case CPU_1074K:
751 +- case CPU_PROAPTIV:
752 +- case CPU_P5600:
753 +- case CPU_M5150:
754 +- case CPU_QEMU_GENERIC:
755 +- break;
756 +-
757 +- default:
758 ++ if (cpu_has_mips_r2_r6) {
759 ++ if (cpu_has_mips_r2_exec_hazard)
760 + uasm_i_ehb(p);
761 +- break;
762 +- }
763 + tlbw(p);
764 + return;
765 + }
766 +diff --git a/arch/mips/netlogic/xlp/ahci-init-xlp2.c b/arch/mips/netlogic/xlp/ahci-init-xlp2.c
767 +index c83dbf3689e2..7b066a44e679 100644
768 +--- a/arch/mips/netlogic/xlp/ahci-init-xlp2.c
769 ++++ b/arch/mips/netlogic/xlp/ahci-init-xlp2.c
770 +@@ -203,6 +203,7 @@ static u8 read_phy_reg(u64 regbase, u32 addr, u32 physel)
771 + static void config_sata_phy(u64 regbase)
772 + {
773 + u32 port, i, reg;
774 ++ u8 val;
775 +
776 + for (port = 0; port < 2; port++) {
777 + for (i = 0, reg = RXCDRCALFOSC0; reg <= CALDUTY; reg++, i++)
778 +@@ -210,6 +211,18 @@ static void config_sata_phy(u64 regbase)
779 +
780 + for (i = 0, reg = RXDPIF; reg <= PPMDRIFTMAX_HI; reg++, i++)
781 + write_phy_reg(regbase, reg, port, sata_phy_config2[i]);
782 ++
783 ++ /* Fix for PHY link up failures at lower temperatures */
784 ++ write_phy_reg(regbase, 0x800F, port, 0x1f);
785 ++
786 ++ val = read_phy_reg(regbase, 0x0029, port);
787 ++ write_phy_reg(regbase, 0x0029, port, val | (0x7 << 1));
788 ++
789 ++ val = read_phy_reg(regbase, 0x0056, port);
790 ++ write_phy_reg(regbase, 0x0056, port, val & ~(1 << 3));
791 ++
792 ++ val = read_phy_reg(regbase, 0x0018, port);
793 ++ write_phy_reg(regbase, 0x0018, port, val & ~(0x7 << 0));
794 + }
795 + }
796 +
797 +diff --git a/arch/mips/pci/Makefile b/arch/mips/pci/Makefile
798 +index 300591c6278d..2eda01e6e08f 100644
799 +--- a/arch/mips/pci/Makefile
800 ++++ b/arch/mips/pci/Makefile
801 +@@ -43,7 +43,7 @@ obj-$(CONFIG_SIBYTE_BCM1x80) += pci-bcm1480.o pci-bcm1480ht.o
802 + obj-$(CONFIG_SNI_RM) += fixup-sni.o ops-sni.o
803 + obj-$(CONFIG_LANTIQ) += fixup-lantiq.o
804 + obj-$(CONFIG_PCI_LANTIQ) += pci-lantiq.o ops-lantiq.o
805 +-obj-$(CONFIG_SOC_RT2880) += pci-rt2880.o
806 ++obj-$(CONFIG_SOC_RT288X) += pci-rt2880.o
807 + obj-$(CONFIG_SOC_RT3883) += pci-rt3883.o
808 + obj-$(CONFIG_TANBAC_TB0219) += fixup-tb0219.o
809 + obj-$(CONFIG_TANBAC_TB0226) += fixup-tb0226.o
810 +diff --git a/arch/mips/pci/pci-octeon.c b/arch/mips/pci/pci-octeon.c
811 +index a04af55d89f1..c258cd406fbb 100644
812 +--- a/arch/mips/pci/pci-octeon.c
813 ++++ b/arch/mips/pci/pci-octeon.c
814 +@@ -214,6 +214,8 @@ const char *octeon_get_pci_interrupts(void)
815 + return "AAABAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
816 + case CVMX_BOARD_TYPE_BBGW_REF:
817 + return "AABCD";
818 ++ case CVMX_BOARD_TYPE_CUST_DSR1000N:
819 ++ return "CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC";
820 + case CVMX_BOARD_TYPE_THUNDER:
821 + case CVMX_BOARD_TYPE_EBH3000:
822 + default:
823 +@@ -271,9 +273,6 @@ static int octeon_read_config(struct pci_bus *bus, unsigned int devfn,
824 + pci_addr.s.func = devfn & 0x7;
825 + pci_addr.s.reg = reg;
826 +
827 +-#if PCI_CONFIG_SPACE_DELAY
828 +- udelay(PCI_CONFIG_SPACE_DELAY);
829 +-#endif
830 + switch (size) {
831 + case 4:
832 + *val = le32_to_cpu(cvmx_read64_uint32(pci_addr.u64));
833 +@@ -308,9 +307,6 @@ static int octeon_write_config(struct pci_bus *bus, unsigned int devfn,
834 + pci_addr.s.func = devfn & 0x7;
835 + pci_addr.s.reg = reg;
836 +
837 +-#if PCI_CONFIG_SPACE_DELAY
838 +- udelay(PCI_CONFIG_SPACE_DELAY);
839 +-#endif
840 + switch (size) {
841 + case 4:
842 + cvmx_write64_uint32(pci_addr.u64, cpu_to_le32(val));
843 +diff --git a/arch/mips/pci/pcie-octeon.c b/arch/mips/pci/pcie-octeon.c
844 +index 1bb0b2bf8d6e..99f3db4f0a9b 100644
845 +--- a/arch/mips/pci/pcie-octeon.c
846 ++++ b/arch/mips/pci/pcie-octeon.c
847 +@@ -1762,14 +1762,6 @@ static int octeon_pcie_write_config(unsigned int pcie_port, struct pci_bus *bus,
848 + default:
849 + return PCIBIOS_FUNC_NOT_SUPPORTED;
850 + }
851 +-#if PCI_CONFIG_SPACE_DELAY
852 +- /*
853 +- * Delay on writes so that devices have time to come up. Some
854 +- * bridges need this to allow time for the secondary busses to
855 +- * work
856 +- */
857 +- udelay(PCI_CONFIG_SPACE_DELAY);
858 +-#endif
859 + return PCIBIOS_SUCCESSFUL;
860 + }
861 +
862 +diff --git a/arch/mips/ralink/Kconfig b/arch/mips/ralink/Kconfig
863 +index b1c52ca580f9..e9bc8c96174e 100644
864 +--- a/arch/mips/ralink/Kconfig
865 ++++ b/arch/mips/ralink/Kconfig
866 +@@ -7,6 +7,11 @@ config CLKEVT_RT3352
867 + select CLKSRC_OF
868 + select CLKSRC_MMIO
869 +
870 ++config RALINK_ILL_ACC
871 ++ bool
872 ++ depends on SOC_RT305X
873 ++ default y
874 ++
875 + choice
876 + prompt "Ralink SoC selection"
877 + default SOC_RT305X
878 +diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c
879 +index a7a3edd28beb..f23179e84128 100644
880 +--- a/drivers/acpi/sbs.c
881 ++++ b/drivers/acpi/sbs.c
882 +@@ -670,7 +670,7 @@ static int acpi_sbs_add(struct acpi_device *device)
883 + if (!sbs_manager_broken) {
884 + result = acpi_manager_get_info(sbs);
885 + if (!result) {
886 +- sbs->manager_present = 0;
887 ++ sbs->manager_present = 1;
888 + for (id = 0; id < MAX_SBS_BAT; ++id)
889 + if ((sbs->batteries_supported & (1 << id)))
890 + acpi_battery_add(sbs, id);
891 +diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
892 +index b40af3203089..b67066d0d9a6 100644
893 +--- a/drivers/block/rbd.c
894 ++++ b/drivers/block/rbd.c
895 +@@ -2264,6 +2264,11 @@ static bool rbd_img_obj_end_request(struct rbd_obj_request *obj_request)
896 + result, xferred);
897 + if (!img_request->result)
898 + img_request->result = result;
899 ++ /*
900 ++ * Need to end I/O on the entire obj_request worth of
901 ++ * bytes in case of error.
902 ++ */
903 ++ xferred = obj_request->length;
904 + }
905 +
906 + /* Image object requests don't own their page array */
907 +diff --git a/drivers/gpu/drm/radeon/atombios_crtc.c b/drivers/gpu/drm/radeon/atombios_crtc.c
908 +index 9bd56116fd5a..1afc0b419da2 100644
909 +--- a/drivers/gpu/drm/radeon/atombios_crtc.c
910 ++++ b/drivers/gpu/drm/radeon/atombios_crtc.c
911 +@@ -580,6 +580,9 @@ static u32 atombios_adjust_pll(struct drm_crtc *crtc,
912 + else
913 + radeon_crtc->pll_flags |= RADEON_PLL_PREFER_LOW_REF_DIV;
914 +
915 ++ /* if there is no audio, set MINM_OVER_MAXP */
916 ++ if (!drm_detect_monitor_audio(radeon_connector_edid(connector)))
917 ++ radeon_crtc->pll_flags |= RADEON_PLL_PREFER_MINM_OVER_MAXP;
918 + if (rdev->family < CHIP_RV770)
919 + radeon_crtc->pll_flags |= RADEON_PLL_PREFER_MINM_OVER_MAXP;
920 + /* use frac fb div on APUs */
921 +diff --git a/drivers/gpu/drm/radeon/atombios_encoders.c b/drivers/gpu/drm/radeon/atombios_encoders.c
922 +index c39c1d0d9d4e..f20eb32406d1 100644
923 +--- a/drivers/gpu/drm/radeon/atombios_encoders.c
924 ++++ b/drivers/gpu/drm/radeon/atombios_encoders.c
925 +@@ -1729,17 +1729,15 @@ radeon_atom_encoder_dpms(struct drm_encoder *encoder, int mode)
926 + struct drm_device *dev = encoder->dev;
927 + struct radeon_device *rdev = dev->dev_private;
928 + struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
929 +- struct drm_connector *connector = radeon_get_connector_for_encoder(encoder);
930 + int encoder_mode = atombios_get_encoder_mode(encoder);
931 +
932 + DRM_DEBUG_KMS("encoder dpms %d to mode %d, devices %08x, active_devices %08x\n",
933 + radeon_encoder->encoder_id, mode, radeon_encoder->devices,
934 + radeon_encoder->active_device);
935 +
936 +- if (connector && (radeon_audio != 0) &&
937 ++ if ((radeon_audio != 0) &&
938 + ((encoder_mode == ATOM_ENCODER_MODE_HDMI) ||
939 +- (ENCODER_MODE_IS_DP(encoder_mode) &&
940 +- drm_detect_monitor_audio(radeon_connector_edid(connector)))))
941 ++ ENCODER_MODE_IS_DP(encoder_mode)))
942 + radeon_audio_dpms(encoder, mode);
943 +
944 + switch (radeon_encoder->encoder_id) {
945 +diff --git a/drivers/gpu/drm/radeon/dce6_afmt.c b/drivers/gpu/drm/radeon/dce6_afmt.c
946 +index 3adc2afe32aa..68fd9fc677e3 100644
947 +--- a/drivers/gpu/drm/radeon/dce6_afmt.c
948 ++++ b/drivers/gpu/drm/radeon/dce6_afmt.c
949 +@@ -295,28 +295,3 @@ void dce6_dp_audio_set_dto(struct radeon_device *rdev,
950 + WREG32(DCCG_AUDIO_DTO1_MODULE, clock);
951 + }
952 + }
953 +-
954 +-void dce6_dp_enable(struct drm_encoder *encoder, bool enable)
955 +-{
956 +- struct drm_device *dev = encoder->dev;
957 +- struct radeon_device *rdev = dev->dev_private;
958 +- struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
959 +- struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
960 +-
961 +- if (!dig || !dig->afmt)
962 +- return;
963 +-
964 +- if (enable) {
965 +- WREG32(EVERGREEN_DP_SEC_TIMESTAMP + dig->afmt->offset,
966 +- EVERGREEN_DP_SEC_TIMESTAMP_MODE(1));
967 +- WREG32(EVERGREEN_DP_SEC_CNTL + dig->afmt->offset,
968 +- EVERGREEN_DP_SEC_ASP_ENABLE | /* Audio packet transmission */
969 +- EVERGREEN_DP_SEC_ATP_ENABLE | /* Audio timestamp packet transmission */
970 +- EVERGREEN_DP_SEC_AIP_ENABLE | /* Audio infoframe packet transmission */
971 +- EVERGREEN_DP_SEC_STREAM_ENABLE); /* Master enable for secondary stream engine */
972 +- } else {
973 +- WREG32(EVERGREEN_DP_SEC_CNTL + dig->afmt->offset, 0);
974 +- }
975 +-
976 +- dig->afmt->enabled = enable;
977 +-}
978 +diff --git a/drivers/gpu/drm/radeon/evergreen_hdmi.c b/drivers/gpu/drm/radeon/evergreen_hdmi.c
979 +index c18d4ecbd95d..0926739c9fa7 100644
980 +--- a/drivers/gpu/drm/radeon/evergreen_hdmi.c
981 ++++ b/drivers/gpu/drm/radeon/evergreen_hdmi.c
982 +@@ -219,13 +219,9 @@ void evergreen_set_avi_packet(struct radeon_device *rdev, u32 offset,
983 + WREG32(AFMT_AVI_INFO3 + offset,
984 + frame[0xC] | (frame[0xD] << 8) | (buffer[1] << 24));
985 +
986 +- WREG32_OR(HDMI_INFOFRAME_CONTROL0 + offset,
987 +- HDMI_AVI_INFO_SEND | /* enable AVI info frames */
988 +- HDMI_AVI_INFO_CONT); /* required for audio info values to be updated */
989 +-
990 + WREG32_P(HDMI_INFOFRAME_CONTROL1 + offset,
991 +- HDMI_AVI_INFO_LINE(2), /* anything other than 0 */
992 +- ~HDMI_AVI_INFO_LINE_MASK);
993 ++ HDMI_AVI_INFO_LINE(2), /* anything other than 0 */
994 ++ ~HDMI_AVI_INFO_LINE_MASK);
995 + }
996 +
997 + void dce4_hdmi_audio_set_dto(struct radeon_device *rdev,
998 +@@ -370,9 +366,13 @@ void dce4_set_audio_packet(struct drm_encoder *encoder, u32 offset)
999 + WREG32(AFMT_AUDIO_PACKET_CONTROL2 + offset,
1000 + AFMT_AUDIO_CHANNEL_ENABLE(0xff));
1001 +
1002 ++ WREG32(HDMI_AUDIO_PACKET_CONTROL + offset,
1003 ++ HDMI_AUDIO_DELAY_EN(1) | /* set the default audio delay */
1004 ++ HDMI_AUDIO_PACKETS_PER_LINE(3)); /* should be suffient for all audio modes and small enough for all hblanks */
1005 ++
1006 + /* allow 60958 channel status and send audio packets fields to be updated */
1007 +- WREG32(AFMT_AUDIO_PACKET_CONTROL + offset,
1008 +- AFMT_AUDIO_SAMPLE_SEND | AFMT_RESET_FIFO_WHEN_AUDIO_DIS | AFMT_60958_CS_UPDATE);
1009 ++ WREG32_OR(AFMT_AUDIO_PACKET_CONTROL + offset,
1010 ++ AFMT_RESET_FIFO_WHEN_AUDIO_DIS | AFMT_60958_CS_UPDATE);
1011 + }
1012 +
1013 +
1014 +@@ -398,17 +398,26 @@ void evergreen_hdmi_enable(struct drm_encoder *encoder, bool enable)
1015 + return;
1016 +
1017 + if (enable) {
1018 +- WREG32(HDMI_INFOFRAME_CONTROL1 + dig->afmt->offset,
1019 +- HDMI_AUDIO_INFO_LINE(2)); /* anything other than 0 */
1020 +-
1021 +- WREG32(HDMI_AUDIO_PACKET_CONTROL + dig->afmt->offset,
1022 +- HDMI_AUDIO_DELAY_EN(1) | /* set the default audio delay */
1023 +- HDMI_AUDIO_PACKETS_PER_LINE(3)); /* should be suffient for all audio modes and small enough for all hblanks */
1024 ++ struct drm_connector *connector = radeon_get_connector_for_encoder(encoder);
1025 +
1026 +- WREG32(HDMI_INFOFRAME_CONTROL0 + dig->afmt->offset,
1027 +- HDMI_AUDIO_INFO_SEND | /* enable audio info frames (frames won't be set until audio is enabled) */
1028 +- HDMI_AUDIO_INFO_CONT); /* required for audio info values to be updated */
1029 ++ if (drm_detect_monitor_audio(radeon_connector_edid(connector))) {
1030 ++ WREG32(HDMI_INFOFRAME_CONTROL0 + dig->afmt->offset,
1031 ++ HDMI_AVI_INFO_SEND | /* enable AVI info frames */
1032 ++ HDMI_AVI_INFO_CONT | /* required for audio info values to be updated */
1033 ++ HDMI_AUDIO_INFO_SEND | /* enable audio info frames (frames won't be set until audio is enabled) */
1034 ++ HDMI_AUDIO_INFO_CONT); /* required for audio info values to be updated */
1035 ++ WREG32_OR(AFMT_AUDIO_PACKET_CONTROL + dig->afmt->offset,
1036 ++ AFMT_AUDIO_SAMPLE_SEND);
1037 ++ } else {
1038 ++ WREG32(HDMI_INFOFRAME_CONTROL0 + dig->afmt->offset,
1039 ++ HDMI_AVI_INFO_SEND | /* enable AVI info frames */
1040 ++ HDMI_AVI_INFO_CONT); /* required for audio info values to be updated */
1041 ++ WREG32_AND(AFMT_AUDIO_PACKET_CONTROL + dig->afmt->offset,
1042 ++ ~AFMT_AUDIO_SAMPLE_SEND);
1043 ++ }
1044 + } else {
1045 ++ WREG32_AND(AFMT_AUDIO_PACKET_CONTROL + dig->afmt->offset,
1046 ++ ~AFMT_AUDIO_SAMPLE_SEND);
1047 + WREG32(HDMI_INFOFRAME_CONTROL0 + dig->afmt->offset, 0);
1048 + }
1049 +
1050 +@@ -424,20 +433,24 @@ void evergreen_dp_enable(struct drm_encoder *encoder, bool enable)
1051 + struct radeon_device *rdev = dev->dev_private;
1052 + struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
1053 + struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
1054 ++ struct drm_connector *connector = radeon_get_connector_for_encoder(encoder);
1055 +
1056 + if (!dig || !dig->afmt)
1057 + return;
1058 +
1059 +- if (enable) {
1060 ++ if (enable && drm_detect_monitor_audio(radeon_connector_edid(connector))) {
1061 + struct drm_connector *connector = radeon_get_connector_for_encoder(encoder);
1062 + struct radeon_connector *radeon_connector = to_radeon_connector(connector);
1063 + struct radeon_connector_atom_dig *dig_connector;
1064 + uint32_t val;
1065 +
1066 ++ WREG32_OR(AFMT_AUDIO_PACKET_CONTROL + dig->afmt->offset,
1067 ++ AFMT_AUDIO_SAMPLE_SEND);
1068 ++
1069 + WREG32(EVERGREEN_DP_SEC_TIMESTAMP + dig->afmt->offset,
1070 + EVERGREEN_DP_SEC_TIMESTAMP_MODE(1));
1071 +
1072 +- if (radeon_connector->con_priv) {
1073 ++ if (!ASIC_IS_DCE6(rdev) && radeon_connector->con_priv) {
1074 + dig_connector = radeon_connector->con_priv;
1075 + val = RREG32(EVERGREEN_DP_SEC_AUD_N + dig->afmt->offset);
1076 + val &= ~EVERGREEN_DP_SEC_N_BASE_MULTIPLE(0xf);
1077 +@@ -457,6 +470,8 @@ void evergreen_dp_enable(struct drm_encoder *encoder, bool enable)
1078 + EVERGREEN_DP_SEC_STREAM_ENABLE); /* Master enable for secondary stream engine */
1079 + } else {
1080 + WREG32(EVERGREEN_DP_SEC_CNTL + dig->afmt->offset, 0);
1081 ++ WREG32_AND(AFMT_AUDIO_PACKET_CONTROL + dig->afmt->offset,
1082 ++ ~AFMT_AUDIO_SAMPLE_SEND);
1083 + }
1084 +
1085 + dig->afmt->enabled = enable;
1086 +diff --git a/drivers/gpu/drm/radeon/r600_hdmi.c b/drivers/gpu/drm/radeon/r600_hdmi.c
1087 +index dd6606b8e23c..e85894ade95c 100644
1088 +--- a/drivers/gpu/drm/radeon/r600_hdmi.c
1089 ++++ b/drivers/gpu/drm/radeon/r600_hdmi.c
1090 +@@ -228,12 +228,13 @@ void r600_set_avi_packet(struct radeon_device *rdev, u32 offset,
1091 + WREG32(HDMI0_AVI_INFO3 + offset,
1092 + frame[0xC] | (frame[0xD] << 8) | (buffer[1] << 24));
1093 +
1094 ++ WREG32_OR(HDMI0_INFOFRAME_CONTROL1 + offset,
1095 ++ HDMI0_AVI_INFO_LINE(2)); /* anything other than 0 */
1096 ++
1097 + WREG32_OR(HDMI0_INFOFRAME_CONTROL0 + offset,
1098 +- HDMI0_AVI_INFO_SEND | /* enable AVI info frames */
1099 +- HDMI0_AVI_INFO_CONT); /* send AVI info frames every frame/field */
1100 ++ HDMI0_AVI_INFO_SEND | /* enable AVI info frames */
1101 ++ HDMI0_AVI_INFO_CONT); /* send AVI info frames every frame/field */
1102 +
1103 +- WREG32_OR(HDMI0_INFOFRAME_CONTROL1 + offset,
1104 +- HDMI0_AVI_INFO_LINE(2)); /* anything other than 0 */
1105 + }
1106 +
1107 + /*
1108 +diff --git a/drivers/gpu/drm/radeon/radeon_audio.c b/drivers/gpu/drm/radeon/radeon_audio.c
1109 +index b21ef69a34ac..b7d33a13db9f 100644
1110 +--- a/drivers/gpu/drm/radeon/radeon_audio.c
1111 ++++ b/drivers/gpu/drm/radeon/radeon_audio.c
1112 +@@ -102,7 +102,6 @@ static void radeon_audio_dp_mode_set(struct drm_encoder *encoder,
1113 + void r600_hdmi_enable(struct drm_encoder *encoder, bool enable);
1114 + void evergreen_hdmi_enable(struct drm_encoder *encoder, bool enable);
1115 + void evergreen_dp_enable(struct drm_encoder *encoder, bool enable);
1116 +-void dce6_dp_enable(struct drm_encoder *encoder, bool enable);
1117 +
1118 + static const u32 pin_offsets[7] =
1119 + {
1120 +@@ -240,7 +239,7 @@ static struct radeon_audio_funcs dce6_dp_funcs = {
1121 + .set_avi_packet = evergreen_set_avi_packet,
1122 + .set_audio_packet = dce4_set_audio_packet,
1123 + .mode_set = radeon_audio_dp_mode_set,
1124 +- .dpms = dce6_dp_enable,
1125 ++ .dpms = evergreen_dp_enable,
1126 + };
1127 +
1128 + static void radeon_audio_interface_init(struct radeon_device *rdev)
1129 +@@ -461,30 +460,33 @@ void radeon_audio_detect(struct drm_connector *connector,
1130 + if (!connector || !connector->encoder)
1131 + return;
1132 +
1133 ++ if (!radeon_encoder_is_digital(connector->encoder))
1134 ++ return;
1135 ++
1136 + rdev = connector->encoder->dev->dev_private;
1137 + radeon_encoder = to_radeon_encoder(connector->encoder);
1138 + dig = radeon_encoder->enc_priv;
1139 +
1140 +- if (status == connector_status_connected) {
1141 +- struct radeon_connector *radeon_connector;
1142 +- int sink_type;
1143 +-
1144 +- if (!drm_detect_monitor_audio(radeon_connector_edid(connector))) {
1145 +- radeon_encoder->audio = NULL;
1146 +- return;
1147 +- }
1148 ++ if (!dig->afmt)
1149 ++ return;
1150 +
1151 +- radeon_connector = to_radeon_connector(connector);
1152 +- sink_type = radeon_dp_getsinktype(radeon_connector);
1153 ++ if (status == connector_status_connected) {
1154 ++ struct radeon_connector *radeon_connector = to_radeon_connector(connector);
1155 +
1156 + if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort &&
1157 +- sink_type == CONNECTOR_OBJECT_ID_DISPLAYPORT)
1158 ++ radeon_dp_getsinktype(radeon_connector) ==
1159 ++ CONNECTOR_OBJECT_ID_DISPLAYPORT)
1160 + radeon_encoder->audio = rdev->audio.dp_funcs;
1161 + else
1162 + radeon_encoder->audio = rdev->audio.hdmi_funcs;
1163 +
1164 + dig->afmt->pin = radeon_audio_get_pin(connector->encoder);
1165 +- radeon_audio_enable(rdev, dig->afmt->pin, 0xf);
1166 ++ if (drm_detect_monitor_audio(radeon_connector_edid(connector))) {
1167 ++ radeon_audio_enable(rdev, dig->afmt->pin, 0xf);
1168 ++ } else {
1169 ++ radeon_audio_enable(rdev, dig->afmt->pin, 0);
1170 ++ dig->afmt->pin = NULL;
1171 ++ }
1172 + } else {
1173 + radeon_audio_enable(rdev, dig->afmt->pin, 0);
1174 + dig->afmt->pin = NULL;
1175 +diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c b/drivers/gpu/drm/radeon/radeon_connectors.c
1176 +index 27def67cb6be..27973e3faf0e 100644
1177 +--- a/drivers/gpu/drm/radeon/radeon_connectors.c
1178 ++++ b/drivers/gpu/drm/radeon/radeon_connectors.c
1179 +@@ -1333,8 +1333,10 @@ out:
1180 + /* updated in get modes as well since we need to know if it's analog or digital */
1181 + radeon_connector_update_scratch_regs(connector, ret);
1182 +
1183 +- if (radeon_audio != 0)
1184 ++ if (radeon_audio != 0) {
1185 ++ radeon_connector_get_edid(connector);
1186 + radeon_audio_detect(connector, ret);
1187 ++ }
1188 +
1189 + exit:
1190 + pm_runtime_mark_last_busy(connector->dev->dev);
1191 +@@ -1659,8 +1661,10 @@ radeon_dp_detect(struct drm_connector *connector, bool force)
1192 +
1193 + radeon_connector_update_scratch_regs(connector, ret);
1194 +
1195 +- if (radeon_audio != 0)
1196 ++ if (radeon_audio != 0) {
1197 ++ radeon_connector_get_edid(connector);
1198 + radeon_audio_detect(connector, ret);
1199 ++ }
1200 +
1201 + out:
1202 + pm_runtime_mark_last_busy(connector->dev->dev);
1203 +diff --git a/drivers/gpu/drm/radeon/radeon_cs.c b/drivers/gpu/drm/radeon/radeon_cs.c
1204 +index 4d0f96cc3da4..ab39b85e0f76 100644
1205 +--- a/drivers/gpu/drm/radeon/radeon_cs.c
1206 ++++ b/drivers/gpu/drm/radeon/radeon_cs.c
1207 +@@ -88,7 +88,7 @@ static int radeon_cs_parser_relocs(struct radeon_cs_parser *p)
1208 + p->dma_reloc_idx = 0;
1209 + /* FIXME: we assume that each relocs use 4 dwords */
1210 + p->nrelocs = chunk->length_dw / 4;
1211 +- p->relocs = kcalloc(p->nrelocs, sizeof(struct radeon_bo_list), GFP_KERNEL);
1212 ++ p->relocs = drm_calloc_large(p->nrelocs, sizeof(struct radeon_bo_list));
1213 + if (p->relocs == NULL) {
1214 + return -ENOMEM;
1215 + }
1216 +@@ -428,7 +428,7 @@ static void radeon_cs_parser_fini(struct radeon_cs_parser *parser, int error, bo
1217 + }
1218 + }
1219 + kfree(parser->track);
1220 +- kfree(parser->relocs);
1221 ++ drm_free_large(parser->relocs);
1222 + drm_free_large(parser->vm_bos);
1223 + for (i = 0; i < parser->nchunks; i++)
1224 + drm_free_large(parser->chunks[i].kdata);
1225 +diff --git a/drivers/gpu/drm/radeon/radeon_vm.c b/drivers/gpu/drm/radeon/radeon_vm.c
1226 +index 2a5a4a9e772d..de42fc4a22b8 100644
1227 +--- a/drivers/gpu/drm/radeon/radeon_vm.c
1228 ++++ b/drivers/gpu/drm/radeon/radeon_vm.c
1229 +@@ -473,6 +473,23 @@ int radeon_vm_bo_set_addr(struct radeon_device *rdev,
1230 + }
1231 +
1232 + mutex_lock(&vm->mutex);
1233 ++ soffset /= RADEON_GPU_PAGE_SIZE;
1234 ++ eoffset /= RADEON_GPU_PAGE_SIZE;
1235 ++ if (soffset || eoffset) {
1236 ++ struct interval_tree_node *it;
1237 ++ it = interval_tree_iter_first(&vm->va, soffset, eoffset - 1);
1238 ++ if (it && it != &bo_va->it) {
1239 ++ struct radeon_bo_va *tmp;
1240 ++ tmp = container_of(it, struct radeon_bo_va, it);
1241 ++ /* bo and tmp overlap, invalid offset */
1242 ++ dev_err(rdev->dev, "bo %p va 0x%010Lx conflict with "
1243 ++ "(bo %p 0x%010lx 0x%010lx)\n", bo_va->bo,
1244 ++ soffset, tmp->bo, tmp->it.start, tmp->it.last);
1245 ++ mutex_unlock(&vm->mutex);
1246 ++ return -EINVAL;
1247 ++ }
1248 ++ }
1249 ++
1250 + if (bo_va->it.start || bo_va->it.last) {
1251 + if (bo_va->addr) {
1252 + /* add a clone of the bo_va to clear the old address */
1253 +@@ -490,6 +507,8 @@ int radeon_vm_bo_set_addr(struct radeon_device *rdev,
1254 + spin_lock(&vm->status_lock);
1255 + list_add(&tmp->vm_status, &vm->freed);
1256 + spin_unlock(&vm->status_lock);
1257 ++
1258 ++ bo_va->addr = 0;
1259 + }
1260 +
1261 + interval_tree_remove(&bo_va->it, &vm->va);
1262 +@@ -497,21 +516,7 @@ int radeon_vm_bo_set_addr(struct radeon_device *rdev,
1263 + bo_va->it.last = 0;
1264 + }
1265 +
1266 +- soffset /= RADEON_GPU_PAGE_SIZE;
1267 +- eoffset /= RADEON_GPU_PAGE_SIZE;
1268 + if (soffset || eoffset) {
1269 +- struct interval_tree_node *it;
1270 +- it = interval_tree_iter_first(&vm->va, soffset, eoffset - 1);
1271 +- if (it) {
1272 +- struct radeon_bo_va *tmp;
1273 +- tmp = container_of(it, struct radeon_bo_va, it);
1274 +- /* bo and tmp overlap, invalid offset */
1275 +- dev_err(rdev->dev, "bo %p va 0x%010Lx conflict with "
1276 +- "(bo %p 0x%010lx 0x%010lx)\n", bo_va->bo,
1277 +- soffset, tmp->bo, tmp->it.start, tmp->it.last);
1278 +- mutex_unlock(&vm->mutex);
1279 +- return -EINVAL;
1280 +- }
1281 + bo_va->it.start = soffset;
1282 + bo_va->it.last = eoffset - 1;
1283 + interval_tree_insert(&bo_va->it, &vm->va);
1284 +@@ -1107,7 +1112,8 @@ void radeon_vm_bo_rmv(struct radeon_device *rdev,
1285 + list_del(&bo_va->bo_list);
1286 +
1287 + mutex_lock(&vm->mutex);
1288 +- interval_tree_remove(&bo_va->it, &vm->va);
1289 ++ if (bo_va->it.start || bo_va->it.last)
1290 ++ interval_tree_remove(&bo_va->it, &vm->va);
1291 + spin_lock(&vm->status_lock);
1292 + list_del(&bo_va->vm_status);
1293 +
1294 +diff --git a/drivers/gpu/drm/radeon/si_dpm.c b/drivers/gpu/drm/radeon/si_dpm.c
1295 +index 7be11651b7e6..9dbb3154d559 100644
1296 +--- a/drivers/gpu/drm/radeon/si_dpm.c
1297 ++++ b/drivers/gpu/drm/radeon/si_dpm.c
1298 +@@ -2924,6 +2924,7 @@ struct si_dpm_quirk {
1299 + static struct si_dpm_quirk si_dpm_quirk_list[] = {
1300 + /* PITCAIRN - https://bugs.freedesktop.org/show_bug.cgi?id=76490 */
1301 + { PCI_VENDOR_ID_ATI, 0x6810, 0x1462, 0x3036, 0, 120000 },
1302 ++ { PCI_VENDOR_ID_ATI, 0x6811, 0x174b, 0xe271, 0, 120000 },
1303 + { 0, 0, 0, 0 },
1304 + };
1305 +
1306 +diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
1307 +index 3736f71bdec5..18def3022f6e 100644
1308 +--- a/drivers/hv/channel_mgmt.c
1309 ++++ b/drivers/hv/channel_mgmt.c
1310 +@@ -787,7 +787,7 @@ int vmbus_request_offers(void)
1311 + {
1312 + struct vmbus_channel_message_header *msg;
1313 + struct vmbus_channel_msginfo *msginfo;
1314 +- int ret, t;
1315 ++ int ret;
1316 +
1317 + msginfo = kmalloc(sizeof(*msginfo) +
1318 + sizeof(struct vmbus_channel_message_header),
1319 +@@ -795,8 +795,6 @@ int vmbus_request_offers(void)
1320 + if (!msginfo)
1321 + return -ENOMEM;
1322 +
1323 +- init_completion(&msginfo->waitevent);
1324 +-
1325 + msg = (struct vmbus_channel_message_header *)msginfo->msg;
1326 +
1327 + msg->msgtype = CHANNELMSG_REQUESTOFFERS;
1328 +@@ -810,14 +808,6 @@ int vmbus_request_offers(void)
1329 + goto cleanup;
1330 + }
1331 +
1332 +- t = wait_for_completion_timeout(&msginfo->waitevent, 5*HZ);
1333 +- if (t == 0) {
1334 +- ret = -ETIMEDOUT;
1335 +- goto cleanup;
1336 +- }
1337 +-
1338 +-
1339 +-
1340 + cleanup:
1341 + kfree(msginfo);
1342 +
1343 +diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
1344 +index ee394dc68303..ec1ea8ba7aac 100644
1345 +--- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
1346 ++++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
1347 +@@ -492,7 +492,7 @@ int t4_memory_rw(struct adapter *adap, int win, int mtype, u32 addr,
1348 + memoffset = (mtype * (edc_size * 1024 * 1024));
1349 + else {
1350 + mc_size = EXT_MEM0_SIZE_G(t4_read_reg(adap,
1351 +- MA_EXT_MEMORY1_BAR_A));
1352 ++ MA_EXT_MEMORY0_BAR_A));
1353 + memoffset = (MEM_MC0 * edc_size + mc_size) * 1024 * 1024;
1354 + }
1355 +
1356 +diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
1357 +index 3485acf03014..2f1324bed7b3 100644
1358 +--- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
1359 ++++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
1360 +@@ -1467,6 +1467,7 @@ static void mlx4_en_service_task(struct work_struct *work)
1361 + if (mdev->dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_TS)
1362 + mlx4_en_ptp_overflow_check(mdev);
1363 +
1364 ++ mlx4_en_recover_from_oom(priv);
1365 + queue_delayed_work(mdev->workqueue, &priv->service_task,
1366 + SERVICE_TASK_DELAY);
1367 + }
1368 +diff --git a/drivers/net/ethernet/mellanox/mlx4/en_rx.c b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
1369 +index 698d60de1255..05ec5e151ded 100644
1370 +--- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c
1371 ++++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
1372 +@@ -244,6 +244,12 @@ static int mlx4_en_prepare_rx_desc(struct mlx4_en_priv *priv,
1373 + return mlx4_en_alloc_frags(priv, rx_desc, frags, ring->page_alloc, gfp);
1374 + }
1375 +
1376 ++static inline bool mlx4_en_is_ring_empty(struct mlx4_en_rx_ring *ring)
1377 ++{
1378 ++ BUG_ON((u32)(ring->prod - ring->cons) > ring->actual_size);
1379 ++ return ring->prod == ring->cons;
1380 ++}
1381 ++
1382 + static inline void mlx4_en_update_rx_prod_db(struct mlx4_en_rx_ring *ring)
1383 + {
1384 + *ring->wqres.db.db = cpu_to_be32(ring->prod & 0xffff);
1385 +@@ -315,8 +321,7 @@ static void mlx4_en_free_rx_buf(struct mlx4_en_priv *priv,
1386 + ring->cons, ring->prod);
1387 +
1388 + /* Unmap and free Rx buffers */
1389 +- BUG_ON((u32) (ring->prod - ring->cons) > ring->actual_size);
1390 +- while (ring->cons != ring->prod) {
1391 ++ while (!mlx4_en_is_ring_empty(ring)) {
1392 + index = ring->cons & ring->size_mask;
1393 + en_dbg(DRV, priv, "Processing descriptor:%d\n", index);
1394 + mlx4_en_free_rx_desc(priv, ring, index);
1395 +@@ -491,6 +496,23 @@ err_allocator:
1396 + return err;
1397 + }
1398 +
1399 ++/* We recover from out of memory by scheduling our napi poll
1400 ++ * function (mlx4_en_process_cq), which tries to allocate
1401 ++ * all missing RX buffers (call to mlx4_en_refill_rx_buffers).
1402 ++ */
1403 ++void mlx4_en_recover_from_oom(struct mlx4_en_priv *priv)
1404 ++{
1405 ++ int ring;
1406 ++
1407 ++ if (!priv->port_up)
1408 ++ return;
1409 ++
1410 ++ for (ring = 0; ring < priv->rx_ring_num; ring++) {
1411 ++ if (mlx4_en_is_ring_empty(priv->rx_ring[ring]))
1412 ++ napi_reschedule(&priv->rx_cq[ring]->napi);
1413 ++ }
1414 ++}
1415 ++
1416 + void mlx4_en_destroy_rx_ring(struct mlx4_en_priv *priv,
1417 + struct mlx4_en_rx_ring **pring,
1418 + u32 size, u16 stride)
1419 +diff --git a/drivers/net/ethernet/mellanox/mlx4/en_tx.c b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
1420 +index 55f9f5c5344e..8c234ec1d8aa 100644
1421 +--- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c
1422 ++++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
1423 +@@ -143,8 +143,10 @@ int mlx4_en_create_tx_ring(struct mlx4_en_priv *priv,
1424 + ring->hwtstamp_tx_type = priv->hwtstamp_config.tx_type;
1425 + ring->queue_index = queue_index;
1426 +
1427 +- if (queue_index < priv->num_tx_rings_p_up && cpu_online(queue_index))
1428 +- cpumask_set_cpu(queue_index, &ring->affinity_mask);
1429 ++ if (queue_index < priv->num_tx_rings_p_up)
1430 ++ cpumask_set_cpu_local_first(queue_index,
1431 ++ priv->mdev->dev->numa_node,
1432 ++ &ring->affinity_mask);
1433 +
1434 + *pring = ring;
1435 + return 0;
1436 +@@ -213,7 +215,7 @@ int mlx4_en_activate_tx_ring(struct mlx4_en_priv *priv,
1437 +
1438 + err = mlx4_qp_to_ready(mdev->dev, &ring->wqres.mtt, &ring->context,
1439 + &ring->qp, &ring->qp_state);
1440 +- if (!user_prio && cpu_online(ring->queue_index))
1441 ++ if (!cpumask_empty(&ring->affinity_mask))
1442 + netif_set_xps_queue(priv->dev, &ring->affinity_mask,
1443 + ring->queue_index);
1444 +
1445 +diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
1446 +index ebbe244e80dd..8687c8d54227 100644
1447 +--- a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
1448 ++++ b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
1449 +@@ -790,6 +790,7 @@ int mlx4_en_activate_tx_ring(struct mlx4_en_priv *priv,
1450 + void mlx4_en_deactivate_tx_ring(struct mlx4_en_priv *priv,
1451 + struct mlx4_en_tx_ring *ring);
1452 + void mlx4_en_set_num_rx_rings(struct mlx4_en_dev *mdev);
1453 ++void mlx4_en_recover_from_oom(struct mlx4_en_priv *priv);
1454 + int mlx4_en_create_rx_ring(struct mlx4_en_priv *priv,
1455 + struct mlx4_en_rx_ring **pring,
1456 + u32 size, u16 stride, int node);
1457 +diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c
1458 +index 7600639db4c4..add419d6ff34 100644
1459 +--- a/drivers/scsi/3w-9xxx.c
1460 ++++ b/drivers/scsi/3w-9xxx.c
1461 +@@ -149,7 +149,6 @@ static int twa_reset_sequence(TW_Device_Extension *tw_dev, int soft_reset);
1462 + static int twa_scsiop_execute_scsi(TW_Device_Extension *tw_dev, int request_id, char *cdb, int use_sg, TW_SG_Entry *sglistarg);
1463 + static void twa_scsiop_execute_scsi_complete(TW_Device_Extension *tw_dev, int request_id);
1464 + static char *twa_string_lookup(twa_message_type *table, unsigned int aen_code);
1465 +-static void twa_unmap_scsi_data(TW_Device_Extension *tw_dev, int request_id);
1466 +
1467 + /* Functions */
1468 +
1469 +@@ -1340,11 +1339,11 @@ static irqreturn_t twa_interrupt(int irq, void *dev_instance)
1470 + }
1471 +
1472 + /* Now complete the io */
1473 ++ scsi_dma_unmap(cmd);
1474 ++ cmd->scsi_done(cmd);
1475 + tw_dev->state[request_id] = TW_S_COMPLETED;
1476 + twa_free_request_id(tw_dev, request_id);
1477 + tw_dev->posted_request_count--;
1478 +- tw_dev->srb[request_id]->scsi_done(tw_dev->srb[request_id]);
1479 +- twa_unmap_scsi_data(tw_dev, request_id);
1480 + }
1481 +
1482 + /* Check for valid status after each drain */
1483 +@@ -1402,26 +1401,6 @@ static void twa_load_sgl(TW_Device_Extension *tw_dev, TW_Command_Full *full_comm
1484 + }
1485 + } /* End twa_load_sgl() */
1486 +
1487 +-/* This function will perform a pci-dma mapping for a scatter gather list */
1488 +-static int twa_map_scsi_sg_data(TW_Device_Extension *tw_dev, int request_id)
1489 +-{
1490 +- int use_sg;
1491 +- struct scsi_cmnd *cmd = tw_dev->srb[request_id];
1492 +-
1493 +- use_sg = scsi_dma_map(cmd);
1494 +- if (!use_sg)
1495 +- return 0;
1496 +- else if (use_sg < 0) {
1497 +- TW_PRINTK(tw_dev->host, TW_DRIVER, 0x1c, "Failed to map scatter gather list");
1498 +- return 0;
1499 +- }
1500 +-
1501 +- cmd->SCp.phase = TW_PHASE_SGLIST;
1502 +- cmd->SCp.have_data_in = use_sg;
1503 +-
1504 +- return use_sg;
1505 +-} /* End twa_map_scsi_sg_data() */
1506 +-
1507 + /* This function will poll for a response interrupt of a request */
1508 + static int twa_poll_response(TW_Device_Extension *tw_dev, int request_id, int seconds)
1509 + {
1510 +@@ -1600,9 +1579,11 @@ static int twa_reset_device_extension(TW_Device_Extension *tw_dev)
1511 + (tw_dev->state[i] != TW_S_INITIAL) &&
1512 + (tw_dev->state[i] != TW_S_COMPLETED)) {
1513 + if (tw_dev->srb[i]) {
1514 +- tw_dev->srb[i]->result = (DID_RESET << 16);
1515 +- tw_dev->srb[i]->scsi_done(tw_dev->srb[i]);
1516 +- twa_unmap_scsi_data(tw_dev, i);
1517 ++ struct scsi_cmnd *cmd = tw_dev->srb[i];
1518 ++
1519 ++ cmd->result = (DID_RESET << 16);
1520 ++ scsi_dma_unmap(cmd);
1521 ++ cmd->scsi_done(cmd);
1522 + }
1523 + }
1524 + }
1525 +@@ -1781,21 +1762,18 @@ static int twa_scsi_queue_lck(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_
1526 + /* Save the scsi command for use by the ISR */
1527 + tw_dev->srb[request_id] = SCpnt;
1528 +
1529 +- /* Initialize phase to zero */
1530 +- SCpnt->SCp.phase = TW_PHASE_INITIAL;
1531 +-
1532 + retval = twa_scsiop_execute_scsi(tw_dev, request_id, NULL, 0, NULL);
1533 + switch (retval) {
1534 + case SCSI_MLQUEUE_HOST_BUSY:
1535 ++ scsi_dma_unmap(SCpnt);
1536 + twa_free_request_id(tw_dev, request_id);
1537 +- twa_unmap_scsi_data(tw_dev, request_id);
1538 + break;
1539 + case 1:
1540 +- tw_dev->state[request_id] = TW_S_COMPLETED;
1541 +- twa_free_request_id(tw_dev, request_id);
1542 +- twa_unmap_scsi_data(tw_dev, request_id);
1543 + SCpnt->result = (DID_ERROR << 16);
1544 ++ scsi_dma_unmap(SCpnt);
1545 + done(SCpnt);
1546 ++ tw_dev->state[request_id] = TW_S_COMPLETED;
1547 ++ twa_free_request_id(tw_dev, request_id);
1548 + retval = 0;
1549 + }
1550 + out:
1551 +@@ -1863,8 +1841,8 @@ static int twa_scsiop_execute_scsi(TW_Device_Extension *tw_dev, int request_id,
1552 + command_packet->sg_list[0].address = TW_CPU_TO_SGL(tw_dev->generic_buffer_phys[request_id]);
1553 + command_packet->sg_list[0].length = cpu_to_le32(TW_MIN_SGL_LENGTH);
1554 + } else {
1555 +- sg_count = twa_map_scsi_sg_data(tw_dev, request_id);
1556 +- if (sg_count == 0)
1557 ++ sg_count = scsi_dma_map(srb);
1558 ++ if (sg_count < 0)
1559 + goto out;
1560 +
1561 + scsi_for_each_sg(srb, sg, sg_count, i) {
1562 +@@ -1979,15 +1957,6 @@ static char *twa_string_lookup(twa_message_type *table, unsigned int code)
1563 + return(table[index].text);
1564 + } /* End twa_string_lookup() */
1565 +
1566 +-/* This function will perform a pci-dma unmap */
1567 +-static void twa_unmap_scsi_data(TW_Device_Extension *tw_dev, int request_id)
1568 +-{
1569 +- struct scsi_cmnd *cmd = tw_dev->srb[request_id];
1570 +-
1571 +- if (cmd->SCp.phase == TW_PHASE_SGLIST)
1572 +- scsi_dma_unmap(cmd);
1573 +-} /* End twa_unmap_scsi_data() */
1574 +-
1575 + /* This function gets called when a disk is coming on-line */
1576 + static int twa_slave_configure(struct scsi_device *sdev)
1577 + {
1578 +diff --git a/drivers/scsi/3w-9xxx.h b/drivers/scsi/3w-9xxx.h
1579 +index 040f7214e5b7..0fdc83cfa0e1 100644
1580 +--- a/drivers/scsi/3w-9xxx.h
1581 ++++ b/drivers/scsi/3w-9xxx.h
1582 +@@ -324,11 +324,6 @@ static twa_message_type twa_error_table[] = {
1583 + #define TW_CURRENT_DRIVER_BUILD 0
1584 + #define TW_CURRENT_DRIVER_BRANCH 0
1585 +
1586 +-/* Phase defines */
1587 +-#define TW_PHASE_INITIAL 0
1588 +-#define TW_PHASE_SINGLE 1
1589 +-#define TW_PHASE_SGLIST 2
1590 +-
1591 + /* Misc defines */
1592 + #define TW_9550SX_DRAIN_COMPLETED 0xFFFF
1593 + #define TW_SECTOR_SIZE 512
1594 +diff --git a/drivers/scsi/3w-sas.c b/drivers/scsi/3w-sas.c
1595 +index 2361772d5909..f8374850f714 100644
1596 +--- a/drivers/scsi/3w-sas.c
1597 ++++ b/drivers/scsi/3w-sas.c
1598 +@@ -290,26 +290,6 @@ static int twl_post_command_packet(TW_Device_Extension *tw_dev, int request_id)
1599 + return 0;
1600 + } /* End twl_post_command_packet() */
1601 +
1602 +-/* This function will perform a pci-dma mapping for a scatter gather list */
1603 +-static int twl_map_scsi_sg_data(TW_Device_Extension *tw_dev, int request_id)
1604 +-{
1605 +- int use_sg;
1606 +- struct scsi_cmnd *cmd = tw_dev->srb[request_id];
1607 +-
1608 +- use_sg = scsi_dma_map(cmd);
1609 +- if (!use_sg)
1610 +- return 0;
1611 +- else if (use_sg < 0) {
1612 +- TW_PRINTK(tw_dev->host, TW_DRIVER, 0x1, "Failed to map scatter gather list");
1613 +- return 0;
1614 +- }
1615 +-
1616 +- cmd->SCp.phase = TW_PHASE_SGLIST;
1617 +- cmd->SCp.have_data_in = use_sg;
1618 +-
1619 +- return use_sg;
1620 +-} /* End twl_map_scsi_sg_data() */
1621 +-
1622 + /* This function hands scsi cdb's to the firmware */
1623 + static int twl_scsiop_execute_scsi(TW_Device_Extension *tw_dev, int request_id, char *cdb, int use_sg, TW_SG_Entry_ISO *sglistarg)
1624 + {
1625 +@@ -357,8 +337,8 @@ static int twl_scsiop_execute_scsi(TW_Device_Extension *tw_dev, int request_id,
1626 + if (!sglistarg) {
1627 + /* Map sglist from scsi layer to cmd packet */
1628 + if (scsi_sg_count(srb)) {
1629 +- sg_count = twl_map_scsi_sg_data(tw_dev, request_id);
1630 +- if (sg_count == 0)
1631 ++ sg_count = scsi_dma_map(srb);
1632 ++ if (sg_count <= 0)
1633 + goto out;
1634 +
1635 + scsi_for_each_sg(srb, sg, sg_count, i) {
1636 +@@ -1102,15 +1082,6 @@ out:
1637 + return retval;
1638 + } /* End twl_initialize_device_extension() */
1639 +
1640 +-/* This function will perform a pci-dma unmap */
1641 +-static void twl_unmap_scsi_data(TW_Device_Extension *tw_dev, int request_id)
1642 +-{
1643 +- struct scsi_cmnd *cmd = tw_dev->srb[request_id];
1644 +-
1645 +- if (cmd->SCp.phase == TW_PHASE_SGLIST)
1646 +- scsi_dma_unmap(cmd);
1647 +-} /* End twl_unmap_scsi_data() */
1648 +-
1649 + /* This function will handle attention interrupts */
1650 + static int twl_handle_attention_interrupt(TW_Device_Extension *tw_dev)
1651 + {
1652 +@@ -1251,11 +1222,11 @@ static irqreturn_t twl_interrupt(int irq, void *dev_instance)
1653 + }
1654 +
1655 + /* Now complete the io */
1656 ++ scsi_dma_unmap(cmd);
1657 ++ cmd->scsi_done(cmd);
1658 + tw_dev->state[request_id] = TW_S_COMPLETED;
1659 + twl_free_request_id(tw_dev, request_id);
1660 + tw_dev->posted_request_count--;
1661 +- tw_dev->srb[request_id]->scsi_done(tw_dev->srb[request_id]);
1662 +- twl_unmap_scsi_data(tw_dev, request_id);
1663 + }
1664 +
1665 + /* Check for another response interrupt */
1666 +@@ -1400,10 +1371,12 @@ static int twl_reset_device_extension(TW_Device_Extension *tw_dev, int ioctl_res
1667 + if ((tw_dev->state[i] != TW_S_FINISHED) &&
1668 + (tw_dev->state[i] != TW_S_INITIAL) &&
1669 + (tw_dev->state[i] != TW_S_COMPLETED)) {
1670 +- if (tw_dev->srb[i]) {
1671 +- tw_dev->srb[i]->result = (DID_RESET << 16);
1672 +- tw_dev->srb[i]->scsi_done(tw_dev->srb[i]);
1673 +- twl_unmap_scsi_data(tw_dev, i);
1674 ++ struct scsi_cmnd *cmd = tw_dev->srb[i];
1675 ++
1676 ++ if (cmd) {
1677 ++ cmd->result = (DID_RESET << 16);
1678 ++ scsi_dma_unmap(cmd);
1679 ++ cmd->scsi_done(cmd);
1680 + }
1681 + }
1682 + }
1683 +@@ -1507,9 +1480,6 @@ static int twl_scsi_queue_lck(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_
1684 + /* Save the scsi command for use by the ISR */
1685 + tw_dev->srb[request_id] = SCpnt;
1686 +
1687 +- /* Initialize phase to zero */
1688 +- SCpnt->SCp.phase = TW_PHASE_INITIAL;
1689 +-
1690 + retval = twl_scsiop_execute_scsi(tw_dev, request_id, NULL, 0, NULL);
1691 + if (retval) {
1692 + tw_dev->state[request_id] = TW_S_COMPLETED;
1693 +diff --git a/drivers/scsi/3w-sas.h b/drivers/scsi/3w-sas.h
1694 +index d474892701d4..fec6449c7595 100644
1695 +--- a/drivers/scsi/3w-sas.h
1696 ++++ b/drivers/scsi/3w-sas.h
1697 +@@ -103,10 +103,6 @@ static char *twl_aen_severity_table[] =
1698 + #define TW_CURRENT_DRIVER_BUILD 0
1699 + #define TW_CURRENT_DRIVER_BRANCH 0
1700 +
1701 +-/* Phase defines */
1702 +-#define TW_PHASE_INITIAL 0
1703 +-#define TW_PHASE_SGLIST 2
1704 +-
1705 + /* Misc defines */
1706 + #define TW_SECTOR_SIZE 512
1707 + #define TW_MAX_UNITS 32
1708 +diff --git a/drivers/scsi/3w-xxxx.c b/drivers/scsi/3w-xxxx.c
1709 +index c75f2048319f..2940bd769936 100644
1710 +--- a/drivers/scsi/3w-xxxx.c
1711 ++++ b/drivers/scsi/3w-xxxx.c
1712 +@@ -1271,32 +1271,6 @@ static int tw_initialize_device_extension(TW_Device_Extension *tw_dev)
1713 + return 0;
1714 + } /* End tw_initialize_device_extension() */
1715 +
1716 +-static int tw_map_scsi_sg_data(struct pci_dev *pdev, struct scsi_cmnd *cmd)
1717 +-{
1718 +- int use_sg;
1719 +-
1720 +- dprintk(KERN_WARNING "3w-xxxx: tw_map_scsi_sg_data()\n");
1721 +-
1722 +- use_sg = scsi_dma_map(cmd);
1723 +- if (use_sg < 0) {
1724 +- printk(KERN_WARNING "3w-xxxx: tw_map_scsi_sg_data(): pci_map_sg() failed.\n");
1725 +- return 0;
1726 +- }
1727 +-
1728 +- cmd->SCp.phase = TW_PHASE_SGLIST;
1729 +- cmd->SCp.have_data_in = use_sg;
1730 +-
1731 +- return use_sg;
1732 +-} /* End tw_map_scsi_sg_data() */
1733 +-
1734 +-static void tw_unmap_scsi_data(struct pci_dev *pdev, struct scsi_cmnd *cmd)
1735 +-{
1736 +- dprintk(KERN_WARNING "3w-xxxx: tw_unmap_scsi_data()\n");
1737 +-
1738 +- if (cmd->SCp.phase == TW_PHASE_SGLIST)
1739 +- scsi_dma_unmap(cmd);
1740 +-} /* End tw_unmap_scsi_data() */
1741 +-
1742 + /* This function will reset a device extension */
1743 + static int tw_reset_device_extension(TW_Device_Extension *tw_dev)
1744 + {
1745 +@@ -1319,8 +1293,8 @@ static int tw_reset_device_extension(TW_Device_Extension *tw_dev)
1746 + srb = tw_dev->srb[i];
1747 + if (srb != NULL) {
1748 + srb->result = (DID_RESET << 16);
1749 +- tw_dev->srb[i]->scsi_done(tw_dev->srb[i]);
1750 +- tw_unmap_scsi_data(tw_dev->tw_pci_dev, tw_dev->srb[i]);
1751 ++ scsi_dma_unmap(srb);
1752 ++ srb->scsi_done(srb);
1753 + }
1754 + }
1755 + }
1756 +@@ -1767,8 +1741,8 @@ static int tw_scsiop_read_write(TW_Device_Extension *tw_dev, int request_id)
1757 + command_packet->byte8.io.lba = lba;
1758 + command_packet->byte6.block_count = num_sectors;
1759 +
1760 +- use_sg = tw_map_scsi_sg_data(tw_dev->tw_pci_dev, tw_dev->srb[request_id]);
1761 +- if (!use_sg)
1762 ++ use_sg = scsi_dma_map(srb);
1763 ++ if (use_sg <= 0)
1764 + return 1;
1765 +
1766 + scsi_for_each_sg(tw_dev->srb[request_id], sg, use_sg, i) {
1767 +@@ -1955,9 +1929,6 @@ static int tw_scsi_queue_lck(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_c
1768 + /* Save the scsi command for use by the ISR */
1769 + tw_dev->srb[request_id] = SCpnt;
1770 +
1771 +- /* Initialize phase to zero */
1772 +- SCpnt->SCp.phase = TW_PHASE_INITIAL;
1773 +-
1774 + switch (*command) {
1775 + case READ_10:
1776 + case READ_6:
1777 +@@ -2185,12 +2156,11 @@ static irqreturn_t tw_interrupt(int irq, void *dev_instance)
1778 +
1779 + /* Now complete the io */
1780 + if ((error != TW_ISR_DONT_COMPLETE)) {
1781 ++ scsi_dma_unmap(tw_dev->srb[request_id]);
1782 ++ tw_dev->srb[request_id]->scsi_done(tw_dev->srb[request_id]);
1783 + tw_dev->state[request_id] = TW_S_COMPLETED;
1784 + tw_state_request_finish(tw_dev, request_id);
1785 + tw_dev->posted_request_count--;
1786 +- tw_dev->srb[request_id]->scsi_done(tw_dev->srb[request_id]);
1787 +-
1788 +- tw_unmap_scsi_data(tw_dev->tw_pci_dev, tw_dev->srb[request_id]);
1789 + }
1790 + }
1791 +
1792 +diff --git a/drivers/scsi/3w-xxxx.h b/drivers/scsi/3w-xxxx.h
1793 +index 29b0b84ed69e..6f65e663d393 100644
1794 +--- a/drivers/scsi/3w-xxxx.h
1795 ++++ b/drivers/scsi/3w-xxxx.h
1796 +@@ -195,11 +195,6 @@ static unsigned char tw_sense_table[][4] =
1797 + #define TW_AEN_SMART_FAIL 0x000F
1798 + #define TW_AEN_SBUF_FAIL 0x0024
1799 +
1800 +-/* Phase defines */
1801 +-#define TW_PHASE_INITIAL 0
1802 +-#define TW_PHASE_SINGLE 1
1803 +-#define TW_PHASE_SGLIST 2
1804 +-
1805 + /* Misc defines */
1806 + #define TW_ALIGNMENT_6000 64 /* 64 bytes */
1807 + #define TW_ALIGNMENT_7000 4 /* 4 bytes */
1808 +diff --git a/drivers/scsi/scsi_devinfo.c b/drivers/scsi/scsi_devinfo.c
1809 +index 262ab837a704..9f77d23239a2 100644
1810 +--- a/drivers/scsi/scsi_devinfo.c
1811 ++++ b/drivers/scsi/scsi_devinfo.c
1812 +@@ -226,6 +226,7 @@ static struct {
1813 + {"PIONEER", "CD-ROM DRM-624X", NULL, BLIST_FORCELUN | BLIST_SINGLELUN},
1814 + {"Promise", "VTrak E610f", NULL, BLIST_SPARSELUN | BLIST_NO_RSOC},
1815 + {"Promise", "", NULL, BLIST_SPARSELUN},
1816 ++ {"QNAP", "iSCSI Storage", NULL, BLIST_MAX_1024},
1817 + {"QUANTUM", "XP34301", "1071", BLIST_NOTQ},
1818 + {"REGAL", "CDC-4X", NULL, BLIST_MAX5LUN | BLIST_SINGLELUN},
1819 + {"SanDisk", "ImageMate CF-SD1", NULL, BLIST_FORCELUN},
1820 +diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
1821 +index 9c0a520d933c..3e6142f61499 100644
1822 +--- a/drivers/scsi/scsi_scan.c
1823 ++++ b/drivers/scsi/scsi_scan.c
1824 +@@ -897,6 +897,12 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result,
1825 + */
1826 + if (*bflags & BLIST_MAX_512)
1827 + blk_queue_max_hw_sectors(sdev->request_queue, 512);
1828 ++ /*
1829 ++ * Max 1024 sector transfer length for targets that report incorrect
1830 ++ * max/optimal lengths and relied on the old block layer safe default
1831 ++ */
1832 ++ else if (*bflags & BLIST_MAX_1024)
1833 ++ blk_queue_max_hw_sectors(sdev->request_queue, 1024);
1834 +
1835 + /*
1836 + * Some devices may not want to have a start command automatically
1837 +diff --git a/drivers/ssb/Kconfig b/drivers/ssb/Kconfig
1838 +index 75b3603906c1..f0d22cdb51cd 100644
1839 +--- a/drivers/ssb/Kconfig
1840 ++++ b/drivers/ssb/Kconfig
1841 +@@ -130,6 +130,7 @@ config SSB_DRIVER_MIPS
1842 + bool "SSB Broadcom MIPS core driver"
1843 + depends on SSB && MIPS
1844 + select SSB_SERIAL
1845 ++ select SSB_SFLASH
1846 + help
1847 + Driver for the Sonics Silicon Backplane attached
1848 + Broadcom MIPS core.
1849 +diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
1850 +index 4e959c43f680..6afce7eb3d74 100644
1851 +--- a/drivers/tty/serial/atmel_serial.c
1852 ++++ b/drivers/tty/serial/atmel_serial.c
1853 +@@ -880,6 +880,7 @@ static int atmel_prepare_tx_dma(struct uart_port *port)
1854 + config.direction = DMA_MEM_TO_DEV;
1855 + config.dst_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE;
1856 + config.dst_addr = port->mapbase + ATMEL_US_THR;
1857 ++ config.dst_maxburst = 1;
1858 +
1859 + ret = dmaengine_slave_config(atmel_port->chan_tx,
1860 + &config);
1861 +@@ -1059,6 +1060,7 @@ static int atmel_prepare_rx_dma(struct uart_port *port)
1862 + config.direction = DMA_DEV_TO_MEM;
1863 + config.src_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE;
1864 + config.src_addr = port->mapbase + ATMEL_US_RHR;
1865 ++ config.src_maxburst = 1;
1866 +
1867 + ret = dmaengine_slave_config(atmel_port->chan_rx,
1868 + &config);
1869 +diff --git a/drivers/tty/serial/of_serial.c b/drivers/tty/serial/of_serial.c
1870 +index 33fb94f78967..0a52c8b55a5f 100644
1871 +--- a/drivers/tty/serial/of_serial.c
1872 ++++ b/drivers/tty/serial/of_serial.c
1873 +@@ -344,7 +344,6 @@ static struct of_device_id of_platform_serial_table[] = {
1874 + { .compatible = "ibm,qpace-nwp-serial",
1875 + .data = (void *)PORT_NWPSERIAL, },
1876 + #endif
1877 +- { .type = "serial", .data = (void *)PORT_UNKNOWN, },
1878 + { /* end of list */ },
1879 + };
1880 +
1881 +diff --git a/drivers/tty/serial/uartlite.c b/drivers/tty/serial/uartlite.c
1882 +index 189f52e3111f..a0099a7f60d4 100644
1883 +--- a/drivers/tty/serial/uartlite.c
1884 ++++ b/drivers/tty/serial/uartlite.c
1885 +@@ -632,7 +632,8 @@ MODULE_DEVICE_TABLE(of, ulite_of_match);
1886 +
1887 + static int ulite_probe(struct platform_device *pdev)
1888 + {
1889 +- struct resource *res, *res2;
1890 ++ struct resource *res;
1891 ++ int irq;
1892 + int id = pdev->id;
1893 + #ifdef CONFIG_OF
1894 + const __be32 *prop;
1895 +@@ -646,11 +647,11 @@ static int ulite_probe(struct platform_device *pdev)
1896 + if (!res)
1897 + return -ENODEV;
1898 +
1899 +- res2 = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
1900 +- if (!res2)
1901 +- return -ENODEV;
1902 ++ irq = platform_get_irq(pdev, 0);
1903 ++ if (irq <= 0)
1904 ++ return -ENXIO;
1905 +
1906 +- return ulite_assign(&pdev->dev, id, res->start, res2->start);
1907 ++ return ulite_assign(&pdev->dev, id, res->start, irq);
1908 + }
1909 +
1910 + static int ulite_remove(struct platform_device *pdev)
1911 +diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c
1912 +index cff531a51a78..54853a02ce9e 100644
1913 +--- a/drivers/tty/serial/xilinx_uartps.c
1914 ++++ b/drivers/tty/serial/xilinx_uartps.c
1915 +@@ -1325,9 +1325,9 @@ static SIMPLE_DEV_PM_OPS(cdns_uart_dev_pm_ops, cdns_uart_suspend,
1916 + */
1917 + static int cdns_uart_probe(struct platform_device *pdev)
1918 + {
1919 +- int rc, id;
1920 ++ int rc, id, irq;
1921 + struct uart_port *port;
1922 +- struct resource *res, *res2;
1923 ++ struct resource *res;
1924 + struct cdns_uart *cdns_uart_data;
1925 +
1926 + cdns_uart_data = devm_kzalloc(&pdev->dev, sizeof(*cdns_uart_data),
1927 +@@ -1374,9 +1374,9 @@ static int cdns_uart_probe(struct platform_device *pdev)
1928 + goto err_out_clk_disable;
1929 + }
1930 +
1931 +- res2 = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
1932 +- if (!res2) {
1933 +- rc = -ENODEV;
1934 ++ irq = platform_get_irq(pdev, 0);
1935 ++ if (irq <= 0) {
1936 ++ rc = -ENXIO;
1937 + goto err_out_clk_disable;
1938 + }
1939 +
1940 +@@ -1405,7 +1405,7 @@ static int cdns_uart_probe(struct platform_device *pdev)
1941 + * and triggers invocation of the config_port() entry point.
1942 + */
1943 + port->mapbase = res->start;
1944 +- port->irq = res2->start;
1945 ++ port->irq = irq;
1946 + port->dev = &pdev->dev;
1947 + port->uartclk = clk_get_rate(cdns_uart_data->uartclk);
1948 + port->private_data = cdns_uart_data;
1949 +diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c
1950 +index 562e581f6765..3770330a2201 100644
1951 +--- a/drivers/usb/chipidea/otg_fsm.c
1952 ++++ b/drivers/usb/chipidea/otg_fsm.c
1953 +@@ -537,7 +537,6 @@ static int ci_otg_start_host(struct otg_fsm *fsm, int on)
1954 + {
1955 + struct ci_hdrc *ci = container_of(fsm, struct ci_hdrc, fsm);
1956 +
1957 +- mutex_unlock(&fsm->lock);
1958 + if (on) {
1959 + ci_role_stop(ci);
1960 + ci_role_start(ci, CI_ROLE_HOST);
1961 +@@ -546,7 +545,6 @@ static int ci_otg_start_host(struct otg_fsm *fsm, int on)
1962 + hw_device_reset(ci);
1963 + ci_role_start(ci, CI_ROLE_GADGET);
1964 + }
1965 +- mutex_lock(&fsm->lock);
1966 + return 0;
1967 + }
1968 +
1969 +@@ -554,12 +552,10 @@ static int ci_otg_start_gadget(struct otg_fsm *fsm, int on)
1970 + {
1971 + struct ci_hdrc *ci = container_of(fsm, struct ci_hdrc, fsm);
1972 +
1973 +- mutex_unlock(&fsm->lock);
1974 + if (on)
1975 + usb_gadget_vbus_connect(&ci->gadget);
1976 + else
1977 + usb_gadget_vbus_disconnect(&ci->gadget);
1978 +- mutex_lock(&fsm->lock);
1979 +
1980 + return 0;
1981 + }
1982 +diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
1983 +index 683617714e7c..220c0fd059bb 100644
1984 +--- a/drivers/usb/class/cdc-acm.c
1985 ++++ b/drivers/usb/class/cdc-acm.c
1986 +@@ -1133,11 +1133,16 @@ static int acm_probe(struct usb_interface *intf,
1987 + }
1988 +
1989 + while (buflen > 0) {
1990 ++ elength = buffer[0];
1991 ++ if (!elength) {
1992 ++ dev_err(&intf->dev, "skipping garbage byte\n");
1993 ++ elength = 1;
1994 ++ goto next_desc;
1995 ++ }
1996 + if (buffer[1] != USB_DT_CS_INTERFACE) {
1997 + dev_err(&intf->dev, "skipping garbage\n");
1998 + goto next_desc;
1999 + }
2000 +- elength = buffer[0];
2001 +
2002 + switch (buffer[2]) {
2003 + case USB_CDC_UNION_TYPE: /* we've found it */
2004 +diff --git a/drivers/usb/storage/uas-detect.h b/drivers/usb/storage/uas-detect.h
2005 +index 9893d696fc97..f58caa9e6a27 100644
2006 +--- a/drivers/usb/storage/uas-detect.h
2007 ++++ b/drivers/usb/storage/uas-detect.h
2008 +@@ -51,7 +51,8 @@ static int uas_find_endpoints(struct usb_host_interface *alt,
2009 + }
2010 +
2011 + static int uas_use_uas_driver(struct usb_interface *intf,
2012 +- const struct usb_device_id *id)
2013 ++ const struct usb_device_id *id,
2014 ++ unsigned long *flags_ret)
2015 + {
2016 + struct usb_host_endpoint *eps[4] = { };
2017 + struct usb_device *udev = interface_to_usbdev(intf);
2018 +@@ -73,7 +74,7 @@ static int uas_use_uas_driver(struct usb_interface *intf,
2019 + * this writing the following versions exist:
2020 + * ASM1051 - no uas support version
2021 + * ASM1051 - with broken (*) uas support
2022 +- * ASM1053 - with working uas support
2023 ++ * ASM1053 - with working uas support, but problems with large xfers
2024 + * ASM1153 - with working uas support
2025 + *
2026 + * Devices with these chips re-use a number of device-ids over the
2027 +@@ -103,6 +104,9 @@ static int uas_use_uas_driver(struct usb_interface *intf,
2028 + } else if (usb_ss_max_streams(&eps[1]->ss_ep_comp) == 32) {
2029 + /* Possibly an ASM1051, disable uas */
2030 + flags |= US_FL_IGNORE_UAS;
2031 ++ } else {
2032 ++ /* ASM1053, these have issues with large transfers */
2033 ++ flags |= US_FL_MAX_SECTORS_240;
2034 + }
2035 + }
2036 +
2037 +@@ -132,5 +136,8 @@ static int uas_use_uas_driver(struct usb_interface *intf,
2038 + return 0;
2039 + }
2040 +
2041 ++ if (flags_ret)
2042 ++ *flags_ret = flags;
2043 ++
2044 + return 1;
2045 + }
2046 +diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c
2047 +index 6cdabdc119a7..6d3122afeed3 100644
2048 +--- a/drivers/usb/storage/uas.c
2049 ++++ b/drivers/usb/storage/uas.c
2050 +@@ -759,7 +759,10 @@ static int uas_eh_bus_reset_handler(struct scsi_cmnd *cmnd)
2051 +
2052 + static int uas_slave_alloc(struct scsi_device *sdev)
2053 + {
2054 +- sdev->hostdata = (void *)sdev->host->hostdata;
2055 ++ struct uas_dev_info *devinfo =
2056 ++ (struct uas_dev_info *)sdev->host->hostdata;
2057 ++
2058 ++ sdev->hostdata = devinfo;
2059 +
2060 + /* USB has unusual DMA-alignment requirements: Although the
2061 + * starting address of each scatter-gather element doesn't matter,
2062 +@@ -778,6 +781,11 @@ static int uas_slave_alloc(struct scsi_device *sdev)
2063 + */
2064 + blk_queue_update_dma_alignment(sdev->request_queue, (512 - 1));
2065 +
2066 ++ if (devinfo->flags & US_FL_MAX_SECTORS_64)
2067 ++ blk_queue_max_hw_sectors(sdev->request_queue, 64);
2068 ++ else if (devinfo->flags & US_FL_MAX_SECTORS_240)
2069 ++ blk_queue_max_hw_sectors(sdev->request_queue, 240);
2070 ++
2071 + return 0;
2072 + }
2073 +
2074 +@@ -887,8 +895,9 @@ static int uas_probe(struct usb_interface *intf, const struct usb_device_id *id)
2075 + struct Scsi_Host *shost = NULL;
2076 + struct uas_dev_info *devinfo;
2077 + struct usb_device *udev = interface_to_usbdev(intf);
2078 ++ unsigned long dev_flags;
2079 +
2080 +- if (!uas_use_uas_driver(intf, id))
2081 ++ if (!uas_use_uas_driver(intf, id, &dev_flags))
2082 + return -ENODEV;
2083 +
2084 + if (uas_switch_interface(udev, intf))
2085 +@@ -910,8 +919,7 @@ static int uas_probe(struct usb_interface *intf, const struct usb_device_id *id)
2086 + devinfo->udev = udev;
2087 + devinfo->resetting = 0;
2088 + devinfo->shutdown = 0;
2089 +- devinfo->flags = id->driver_info;
2090 +- usb_stor_adjust_quirks(udev, &devinfo->flags);
2091 ++ devinfo->flags = dev_flags;
2092 + init_usb_anchor(&devinfo->cmd_urbs);
2093 + init_usb_anchor(&devinfo->sense_urbs);
2094 + init_usb_anchor(&devinfo->data_urbs);
2095 +diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
2096 +index 5600c33fcadb..6c10c888f35f 100644
2097 +--- a/drivers/usb/storage/usb.c
2098 ++++ b/drivers/usb/storage/usb.c
2099 +@@ -479,7 +479,8 @@ void usb_stor_adjust_quirks(struct usb_device *udev, unsigned long *fflags)
2100 + US_FL_SINGLE_LUN | US_FL_NO_WP_DETECT |
2101 + US_FL_NO_READ_DISC_INFO | US_FL_NO_READ_CAPACITY_16 |
2102 + US_FL_INITIAL_READ10 | US_FL_WRITE_CACHE |
2103 +- US_FL_NO_ATA_1X | US_FL_NO_REPORT_OPCODES);
2104 ++ US_FL_NO_ATA_1X | US_FL_NO_REPORT_OPCODES |
2105 ++ US_FL_MAX_SECTORS_240);
2106 +
2107 + p = quirks;
2108 + while (*p) {
2109 +@@ -520,6 +521,9 @@ void usb_stor_adjust_quirks(struct usb_device *udev, unsigned long *fflags)
2110 + case 'f':
2111 + f |= US_FL_NO_REPORT_OPCODES;
2112 + break;
2113 ++ case 'g':
2114 ++ f |= US_FL_MAX_SECTORS_240;
2115 ++ break;
2116 + case 'h':
2117 + f |= US_FL_CAPACITY_HEURISTICS;
2118 + break;
2119 +@@ -1080,7 +1084,7 @@ static int storage_probe(struct usb_interface *intf,
2120 +
2121 + /* If uas is enabled and this device can do uas then ignore it. */
2122 + #if IS_ENABLED(CONFIG_USB_UAS)
2123 +- if (uas_use_uas_driver(intf, id))
2124 ++ if (uas_use_uas_driver(intf, id, NULL))
2125 + return -ENXIO;
2126 + #endif
2127 +
2128 +diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
2129 +index f23d4be3280e..2b4c5423672d 100644
2130 +--- a/fs/btrfs/ioctl.c
2131 ++++ b/fs/btrfs/ioctl.c
2132 +@@ -2403,7 +2403,7 @@ static noinline int btrfs_ioctl_snap_destroy(struct file *file,
2133 + "Attempt to delete subvolume %llu during send",
2134 + dest->root_key.objectid);
2135 + err = -EPERM;
2136 +- goto out_dput;
2137 ++ goto out_unlock_inode;
2138 + }
2139 +
2140 + d_invalidate(dentry);
2141 +@@ -2498,6 +2498,7 @@ out_up_write:
2142 + root_flags & ~BTRFS_ROOT_SUBVOL_DEAD);
2143 + spin_unlock(&dest->root_item_lock);
2144 + }
2145 ++out_unlock_inode:
2146 + mutex_unlock(&inode->i_mutex);
2147 + if (!err) {
2148 + shrink_dcache_sb(root->fs_info->sb);
2149 +diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
2150 +index bed43081720f..16f6365f65e7 100644
2151 +--- a/fs/ext4/extents.c
2152 ++++ b/fs/ext4/extents.c
2153 +@@ -4934,13 +4934,6 @@ long ext4_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
2154 + if (ret)
2155 + return ret;
2156 +
2157 +- /*
2158 +- * currently supporting (pre)allocate mode for extent-based
2159 +- * files _only_
2160 +- */
2161 +- if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)))
2162 +- return -EOPNOTSUPP;
2163 +-
2164 + if (mode & FALLOC_FL_COLLAPSE_RANGE)
2165 + return ext4_collapse_range(inode, offset, len);
2166 +
2167 +@@ -4962,6 +4955,14 @@ long ext4_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
2168 +
2169 + mutex_lock(&inode->i_mutex);
2170 +
2171 ++ /*
2172 ++ * We only support preallocation for extent-based files only
2173 ++ */
2174 ++ if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))) {
2175 ++ ret = -EOPNOTSUPP;
2176 ++ goto out;
2177 ++ }
2178 ++
2179 + if (!(mode & FALLOC_FL_KEEP_SIZE) &&
2180 + offset + len > i_size_read(inode)) {
2181 + new_size = offset + len;
2182 +diff --git a/fs/ext4/extents_status.c b/fs/ext4/extents_status.c
2183 +index e04d45733976..9a0121376358 100644
2184 +--- a/fs/ext4/extents_status.c
2185 ++++ b/fs/ext4/extents_status.c
2186 +@@ -705,6 +705,14 @@ int ext4_es_insert_extent(struct inode *inode, ext4_lblk_t lblk,
2187 +
2188 + BUG_ON(end < lblk);
2189 +
2190 ++ if ((status & EXTENT_STATUS_DELAYED) &&
2191 ++ (status & EXTENT_STATUS_WRITTEN)) {
2192 ++ ext4_warning(inode->i_sb, "Inserting extent [%u/%u] as "
2193 ++ " delayed and written which can potentially "
2194 ++ " cause data loss.\n", lblk, len);
2195 ++ WARN_ON(1);
2196 ++ }
2197 ++
2198 + newes.es_lblk = lblk;
2199 + newes.es_len = len;
2200 + ext4_es_store_pblock_status(&newes, pblk, status);
2201 +diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
2202 +index 5cb9a212b86f..852cc521f327 100644
2203 +--- a/fs/ext4/inode.c
2204 ++++ b/fs/ext4/inode.c
2205 +@@ -534,6 +534,7 @@ int ext4_map_blocks(handle_t *handle, struct inode *inode,
2206 + status = map->m_flags & EXT4_MAP_UNWRITTEN ?
2207 + EXTENT_STATUS_UNWRITTEN : EXTENT_STATUS_WRITTEN;
2208 + if (!(flags & EXT4_GET_BLOCKS_DELALLOC_RESERVE) &&
2209 ++ !(status & EXTENT_STATUS_WRITTEN) &&
2210 + ext4_find_delalloc_range(inode, map->m_lblk,
2211 + map->m_lblk + map->m_len - 1))
2212 + status |= EXTENT_STATUS_DELAYED;
2213 +@@ -638,6 +639,7 @@ found:
2214 + status = map->m_flags & EXT4_MAP_UNWRITTEN ?
2215 + EXTENT_STATUS_UNWRITTEN : EXTENT_STATUS_WRITTEN;
2216 + if (!(flags & EXT4_GET_BLOCKS_DELALLOC_RESERVE) &&
2217 ++ !(status & EXTENT_STATUS_WRITTEN) &&
2218 + ext4_find_delalloc_range(inode, map->m_lblk,
2219 + map->m_lblk + map->m_len - 1))
2220 + status |= EXTENT_STATUS_DELAYED;
2221 +diff --git a/fs/hfsplus/xattr.c b/fs/hfsplus/xattr.c
2222 +index d98094a9f476..ff10f3decbc9 100644
2223 +--- a/fs/hfsplus/xattr.c
2224 ++++ b/fs/hfsplus/xattr.c
2225 +@@ -806,9 +806,6 @@ end_removexattr:
2226 + static int hfsplus_osx_getxattr(struct dentry *dentry, const char *name,
2227 + void *buffer, size_t size, int type)
2228 + {
2229 +- char *xattr_name;
2230 +- int res;
2231 +-
2232 + if (!strcmp(name, ""))
2233 + return -EINVAL;
2234 +
2235 +@@ -818,24 +815,19 @@ static int hfsplus_osx_getxattr(struct dentry *dentry, const char *name,
2236 + */
2237 + if (is_known_namespace(name))
2238 + return -EOPNOTSUPP;
2239 +- xattr_name = kmalloc(NLS_MAX_CHARSET_SIZE * HFSPLUS_ATTR_MAX_STRLEN
2240 +- + XATTR_MAC_OSX_PREFIX_LEN + 1, GFP_KERNEL);
2241 +- if (!xattr_name)
2242 +- return -ENOMEM;
2243 +- strcpy(xattr_name, XATTR_MAC_OSX_PREFIX);
2244 +- strcpy(xattr_name + XATTR_MAC_OSX_PREFIX_LEN, name);
2245 +
2246 +- res = hfsplus_getxattr(dentry, xattr_name, buffer, size);
2247 +- kfree(xattr_name);
2248 +- return res;
2249 ++ /*
2250 ++ * osx is the namespace we use to indicate an unprefixed
2251 ++ * attribute on the filesystem (like the ones that OS X
2252 ++ * creates), so we pass the name through unmodified (after
2253 ++ * ensuring it doesn't conflict with another namespace).
2254 ++ */
2255 ++ return hfsplus_getxattr(dentry, name, buffer, size);
2256 + }
2257 +
2258 + static int hfsplus_osx_setxattr(struct dentry *dentry, const char *name,
2259 + const void *buffer, size_t size, int flags, int type)
2260 + {
2261 +- char *xattr_name;
2262 +- int res;
2263 +-
2264 + if (!strcmp(name, ""))
2265 + return -EINVAL;
2266 +
2267 +@@ -845,16 +837,14 @@ static int hfsplus_osx_setxattr(struct dentry *dentry, const char *name,
2268 + */
2269 + if (is_known_namespace(name))
2270 + return -EOPNOTSUPP;
2271 +- xattr_name = kmalloc(NLS_MAX_CHARSET_SIZE * HFSPLUS_ATTR_MAX_STRLEN
2272 +- + XATTR_MAC_OSX_PREFIX_LEN + 1, GFP_KERNEL);
2273 +- if (!xattr_name)
2274 +- return -ENOMEM;
2275 +- strcpy(xattr_name, XATTR_MAC_OSX_PREFIX);
2276 +- strcpy(xattr_name + XATTR_MAC_OSX_PREFIX_LEN, name);
2277 +
2278 +- res = hfsplus_setxattr(dentry, xattr_name, buffer, size, flags);
2279 +- kfree(xattr_name);
2280 +- return res;
2281 ++ /*
2282 ++ * osx is the namespace we use to indicate an unprefixed
2283 ++ * attribute on the filesystem (like the ones that OS X
2284 ++ * creates), so we pass the name through unmodified (after
2285 ++ * ensuring it doesn't conflict with another namespace).
2286 ++ */
2287 ++ return hfsplus_setxattr(dentry, name, buffer, size, flags);
2288 + }
2289 +
2290 + static size_t hfsplus_osx_listxattr(struct dentry *dentry, char *list,
2291 +diff --git a/include/linux/usb_usual.h b/include/linux/usb_usual.h
2292 +index a7f2604c5f25..7f5f78bd15ad 100644
2293 +--- a/include/linux/usb_usual.h
2294 ++++ b/include/linux/usb_usual.h
2295 +@@ -77,6 +77,8 @@
2296 + /* Cannot handle ATA_12 or ATA_16 CDBs */ \
2297 + US_FLAG(NO_REPORT_OPCODES, 0x04000000) \
2298 + /* Cannot handle MI_REPORT_SUPPORTED_OPERATION_CODES */ \
2299 ++ US_FLAG(MAX_SECTORS_240, 0x08000000) \
2300 ++ /* Sets max_sectors to 240 */ \
2301 +
2302 + #define US_FLAG(name, value) US_FL_##name = value ,
2303 + enum { US_DO_ALL_FLAGS };
2304 +diff --git a/include/scsi/scsi_devinfo.h b/include/scsi/scsi_devinfo.h
2305 +index 183eaab7c380..96e3f56519e7 100644
2306 +--- a/include/scsi/scsi_devinfo.h
2307 ++++ b/include/scsi/scsi_devinfo.h
2308 +@@ -36,5 +36,6 @@
2309 + for sequential scan */
2310 + #define BLIST_TRY_VPD_PAGES 0x10000000 /* Attempt to read VPD pages */
2311 + #define BLIST_NO_RSOC 0x20000000 /* don't try to issue RSOC */
2312 ++#define BLIST_MAX_1024 0x40000000 /* maximum 1024 sector cdb length */
2313 +
2314 + #endif
2315 +diff --git a/include/sound/emu10k1.h b/include/sound/emu10k1.h
2316 +index 0de95ccb92cf..5bd134651f5e 100644
2317 +--- a/include/sound/emu10k1.h
2318 ++++ b/include/sound/emu10k1.h
2319 +@@ -41,7 +41,8 @@
2320 +
2321 + #define EMUPAGESIZE 4096
2322 + #define MAXREQVOICES 8
2323 +-#define MAXPAGES 8192
2324 ++#define MAXPAGES0 4096 /* 32 bit mode */
2325 ++#define MAXPAGES1 8192 /* 31 bit mode */
2326 + #define RESERVED 0
2327 + #define NUM_MIDI 16
2328 + #define NUM_G 64 /* use all channels */
2329 +@@ -50,8 +51,7 @@
2330 +
2331 + /* FIXME? - according to the OSS driver the EMU10K1 needs a 29 bit DMA mask */
2332 + #define EMU10K1_DMA_MASK 0x7fffffffUL /* 31bit */
2333 +-#define AUDIGY_DMA_MASK 0x7fffffffUL /* 31bit FIXME - 32 should work? */
2334 +- /* See ALSA bug #1276 - rlrevell */
2335 ++#define AUDIGY_DMA_MASK 0xffffffffUL /* 32bit mode */
2336 +
2337 + #define TMEMSIZE 256*1024
2338 + #define TMEMSIZEREG 4
2339 +@@ -466,8 +466,11 @@
2340 +
2341 + #define MAPB 0x0d /* Cache map B */
2342 +
2343 +-#define MAP_PTE_MASK 0xffffe000 /* The 19 MSBs of the PTE indexed by the PTI */
2344 +-#define MAP_PTI_MASK 0x00001fff /* The 13 bit index to one of the 8192 PTE dwords */
2345 ++#define MAP_PTE_MASK0 0xfffff000 /* The 20 MSBs of the PTE indexed by the PTI */
2346 ++#define MAP_PTI_MASK0 0x00000fff /* The 12 bit index to one of the 4096 PTE dwords */
2347 ++
2348 ++#define MAP_PTE_MASK1 0xffffe000 /* The 19 MSBs of the PTE indexed by the PTI */
2349 ++#define MAP_PTI_MASK1 0x00001fff /* The 13 bit index to one of the 8192 PTE dwords */
2350 +
2351 + /* 0x0e, 0x0f: Not used */
2352 +
2353 +@@ -1704,6 +1707,7 @@ struct snd_emu10k1 {
2354 + unsigned short model; /* subsystem id */
2355 + unsigned int card_type; /* EMU10K1_CARD_* */
2356 + unsigned int ecard_ctrl; /* ecard control bits */
2357 ++ unsigned int address_mode; /* address mode */
2358 + unsigned long dma_mask; /* PCI DMA mask */
2359 + unsigned int delay_pcm_irq; /* in samples */
2360 + int max_cache_pages; /* max memory size / PAGE_SIZE */
2361 +diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h
2362 +index 8d7416e46861..15355892a0ff 100644
2363 +--- a/include/sound/soc-dapm.h
2364 ++++ b/include/sound/soc-dapm.h
2365 +@@ -287,7 +287,7 @@ struct device;
2366 + .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | SNDRV_CTL_ELEM_ACCESS_READWRITE,\
2367 + .tlv.p = (tlv_array), \
2368 + .get = snd_soc_dapm_get_volsw, .put = snd_soc_dapm_put_volsw, \
2369 +- .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert, 0) }
2370 ++ .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert, 1) }
2371 + #define SOC_DAPM_SINGLE_TLV_VIRT(xname, max, tlv_array) \
2372 + SOC_DAPM_SINGLE(xname, SND_SOC_NOPM, 0, max, 0, tlv_array)
2373 + #define SOC_DAPM_ENUM(xname, xenum) \
2374 +diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
2375 +index a64e7a207d2b..0c5796eadae1 100644
2376 +--- a/kernel/bpf/core.c
2377 ++++ b/kernel/bpf/core.c
2378 +@@ -357,8 +357,8 @@ select_insn:
2379 + ALU64_MOD_X:
2380 + if (unlikely(SRC == 0))
2381 + return 0;
2382 +- tmp = DST;
2383 +- DST = do_div(tmp, SRC);
2384 ++ div64_u64_rem(DST, SRC, &tmp);
2385 ++ DST = tmp;
2386 + CONT;
2387 + ALU_MOD_X:
2388 + if (unlikely(SRC == 0))
2389 +@@ -367,8 +367,8 @@ select_insn:
2390 + DST = do_div(tmp, (u32) SRC);
2391 + CONT;
2392 + ALU64_MOD_K:
2393 +- tmp = DST;
2394 +- DST = do_div(tmp, IMM);
2395 ++ div64_u64_rem(DST, IMM, &tmp);
2396 ++ DST = tmp;
2397 + CONT;
2398 + ALU_MOD_K:
2399 + tmp = (u32) DST;
2400 +@@ -377,7 +377,7 @@ select_insn:
2401 + ALU64_DIV_X:
2402 + if (unlikely(SRC == 0))
2403 + return 0;
2404 +- do_div(DST, SRC);
2405 ++ DST = div64_u64(DST, SRC);
2406 + CONT;
2407 + ALU_DIV_X:
2408 + if (unlikely(SRC == 0))
2409 +@@ -387,7 +387,7 @@ select_insn:
2410 + DST = (u32) tmp;
2411 + CONT;
2412 + ALU64_DIV_K:
2413 +- do_div(DST, IMM);
2414 ++ DST = div64_u64(DST, IMM);
2415 + CONT;
2416 + ALU_DIV_K:
2417 + tmp = (u32) DST;
2418 +diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
2419 +index 208d5439e59b..787b0d699969 100644
2420 +--- a/net/ipv4/ping.c
2421 ++++ b/net/ipv4/ping.c
2422 +@@ -158,6 +158,7 @@ void ping_unhash(struct sock *sk)
2423 + if (sk_hashed(sk)) {
2424 + write_lock_bh(&ping_table.lock);
2425 + hlist_nulls_del(&sk->sk_nulls_node);
2426 ++ sk_nulls_node_init(&sk->sk_nulls_node);
2427 + sock_put(sk);
2428 + isk->inet_num = 0;
2429 + isk->inet_sport = 0;
2430 +diff --git a/net/ipv4/route.c b/net/ipv4/route.c
2431 +index ad5064362c5c..20fc0202cbbe 100644
2432 +--- a/net/ipv4/route.c
2433 ++++ b/net/ipv4/route.c
2434 +@@ -963,10 +963,7 @@ static void __ip_rt_update_pmtu(struct rtable *rt, struct flowi4 *fl4, u32 mtu)
2435 + if (dst_metric_locked(dst, RTAX_MTU))
2436 + return;
2437 +
2438 +- if (dst->dev->mtu < mtu)
2439 +- return;
2440 +-
2441 +- if (rt->rt_pmtu && rt->rt_pmtu < mtu)
2442 ++ if (ipv4_mtu(dst) < mtu)
2443 + return;
2444 +
2445 + if (mtu < ip_rt_min_pmtu)
2446 +diff --git a/sound/pci/emu10k1/emu10k1.c b/sound/pci/emu10k1/emu10k1.c
2447 +index 37d0220a094c..db7a2e5e4a14 100644
2448 +--- a/sound/pci/emu10k1/emu10k1.c
2449 ++++ b/sound/pci/emu10k1/emu10k1.c
2450 +@@ -183,8 +183,10 @@ static int snd_card_emu10k1_probe(struct pci_dev *pci,
2451 + }
2452 + #endif
2453 +
2454 +- strcpy(card->driver, emu->card_capabilities->driver);
2455 +- strcpy(card->shortname, emu->card_capabilities->name);
2456 ++ strlcpy(card->driver, emu->card_capabilities->driver,
2457 ++ sizeof(card->driver));
2458 ++ strlcpy(card->shortname, emu->card_capabilities->name,
2459 ++ sizeof(card->shortname));
2460 + snprintf(card->longname, sizeof(card->longname),
2461 + "%s (rev.%d, serial:0x%x) at 0x%lx, irq %i",
2462 + card->shortname, emu->revision, emu->serial, emu->port, emu->irq);
2463 +diff --git a/sound/pci/emu10k1/emu10k1_callback.c b/sound/pci/emu10k1/emu10k1_callback.c
2464 +index 874cd76c7b7f..d2c7ea3a7610 100644
2465 +--- a/sound/pci/emu10k1/emu10k1_callback.c
2466 ++++ b/sound/pci/emu10k1/emu10k1_callback.c
2467 +@@ -415,7 +415,7 @@ start_voice(struct snd_emux_voice *vp)
2468 + snd_emu10k1_ptr_write(hw, Z2, ch, 0);
2469 +
2470 + /* invalidate maps */
2471 +- temp = (hw->silent_page.addr << 1) | MAP_PTI_MASK;
2472 ++ temp = (hw->silent_page.addr << hw->address_mode) | (hw->address_mode ? MAP_PTI_MASK1 : MAP_PTI_MASK0);
2473 + snd_emu10k1_ptr_write(hw, MAPA, ch, temp);
2474 + snd_emu10k1_ptr_write(hw, MAPB, ch, temp);
2475 + #if 0
2476 +@@ -436,7 +436,7 @@ start_voice(struct snd_emux_voice *vp)
2477 + snd_emu10k1_ptr_write(hw, CDF, ch, sample);
2478 +
2479 + /* invalidate maps */
2480 +- temp = ((unsigned int)hw->silent_page.addr << 1) | MAP_PTI_MASK;
2481 ++ temp = ((unsigned int)hw->silent_page.addr << hw_address_mode) | (hw->address_mode ? MAP_PTI_MASK1 : MAP_PTI_MASK0);
2482 + snd_emu10k1_ptr_write(hw, MAPA, ch, temp);
2483 + snd_emu10k1_ptr_write(hw, MAPB, ch, temp);
2484 +
2485 +diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c
2486 +index b4458a630a7c..df9f5c7c9c77 100644
2487 +--- a/sound/pci/emu10k1/emu10k1_main.c
2488 ++++ b/sound/pci/emu10k1/emu10k1_main.c
2489 +@@ -282,7 +282,7 @@ static int snd_emu10k1_init(struct snd_emu10k1 *emu, int enable_ir, int resume)
2490 + snd_emu10k1_ptr_write(emu, TCB, 0, 0); /* taken from original driver */
2491 + snd_emu10k1_ptr_write(emu, TCBS, 0, 4); /* taken from original driver */
2492 +
2493 +- silent_page = (emu->silent_page.addr << 1) | MAP_PTI_MASK;
2494 ++ silent_page = (emu->silent_page.addr << emu->address_mode) | (emu->address_mode ? MAP_PTI_MASK1 : MAP_PTI_MASK0);
2495 + for (ch = 0; ch < NUM_G; ch++) {
2496 + snd_emu10k1_ptr_write(emu, MAPA, ch, silent_page);
2497 + snd_emu10k1_ptr_write(emu, MAPB, ch, silent_page);
2498 +@@ -348,6 +348,11 @@ static int snd_emu10k1_init(struct snd_emu10k1 *emu, int enable_ir, int resume)
2499 + outl(reg | A_IOCFG_GPOUT0, emu->port + A_IOCFG);
2500 + }
2501 +
2502 ++ if (emu->address_mode == 0) {
2503 ++ /* use 16M in 4G */
2504 ++ outl(inl(emu->port + HCFG) | HCFG_EXPANDED_MEM, emu->port + HCFG);
2505 ++ }
2506 ++
2507 + return 0;
2508 + }
2509 +
2510 +@@ -1421,7 +1426,7 @@ static struct snd_emu_chip_details emu_chip_details[] = {
2511 + *
2512 + */
2513 + {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x20011102,
2514 +- .driver = "Audigy2", .name = "SB Audigy 2 ZS Notebook [SB0530]",
2515 ++ .driver = "Audigy2", .name = "Audigy 2 ZS Notebook [SB0530]",
2516 + .id = "Audigy2",
2517 + .emu10k2_chip = 1,
2518 + .ca0108_chip = 1,
2519 +@@ -1571,7 +1576,7 @@ static struct snd_emu_chip_details emu_chip_details[] = {
2520 + .adc_1361t = 1, /* 24 bit capture instead of 16bit */
2521 + .ac97_chip = 1} ,
2522 + {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10051102,
2523 +- .driver = "Audigy2", .name = "SB Audigy 2 Platinum EX [SB0280]",
2524 ++ .driver = "Audigy2", .name = "Audigy 2 Platinum EX [SB0280]",
2525 + .id = "Audigy2",
2526 + .emu10k2_chip = 1,
2527 + .ca0102_chip = 1,
2528 +@@ -1877,8 +1882,10 @@ int snd_emu10k1_create(struct snd_card *card,
2529 +
2530 + is_audigy = emu->audigy = c->emu10k2_chip;
2531 +
2532 ++ /* set addressing mode */
2533 ++ emu->address_mode = is_audigy ? 0 : 1;
2534 + /* set the DMA transfer mask */
2535 +- emu->dma_mask = is_audigy ? AUDIGY_DMA_MASK : EMU10K1_DMA_MASK;
2536 ++ emu->dma_mask = emu->address_mode ? EMU10K1_DMA_MASK : AUDIGY_DMA_MASK;
2537 + if (pci_set_dma_mask(pci, emu->dma_mask) < 0 ||
2538 + pci_set_consistent_dma_mask(pci, emu->dma_mask) < 0) {
2539 + dev_err(card->dev,
2540 +@@ -1903,7 +1910,7 @@ int snd_emu10k1_create(struct snd_card *card,
2541 +
2542 + emu->max_cache_pages = max_cache_bytes >> PAGE_SHIFT;
2543 + if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci),
2544 +- 32 * 1024, &emu->ptb_pages) < 0) {
2545 ++ (emu->address_mode ? 32 : 16) * 1024, &emu->ptb_pages) < 0) {
2546 + err = -ENOMEM;
2547 + goto error;
2548 + }
2549 +@@ -2002,8 +2009,8 @@ int snd_emu10k1_create(struct snd_card *card,
2550 +
2551 + /* Clear silent pages and set up pointers */
2552 + memset(emu->silent_page.area, 0, PAGE_SIZE);
2553 +- silent_page = emu->silent_page.addr << 1;
2554 +- for (idx = 0; idx < MAXPAGES; idx++)
2555 ++ silent_page = emu->silent_page.addr << emu->address_mode;
2556 ++ for (idx = 0; idx < (emu->address_mode ? MAXPAGES1 : MAXPAGES0); idx++)
2557 + ((u32 *)emu->ptb_pages.area)[idx] = cpu_to_le32(silent_page | idx);
2558 +
2559 + /* set up voice indices */
2560 +diff --git a/sound/pci/emu10k1/emupcm.c b/sound/pci/emu10k1/emupcm.c
2561 +index 0dc07385af0e..14a305bd8a98 100644
2562 +--- a/sound/pci/emu10k1/emupcm.c
2563 ++++ b/sound/pci/emu10k1/emupcm.c
2564 +@@ -380,7 +380,7 @@ static void snd_emu10k1_pcm_init_voice(struct snd_emu10k1 *emu,
2565 + snd_emu10k1_ptr_write(emu, Z1, voice, 0);
2566 + snd_emu10k1_ptr_write(emu, Z2, voice, 0);
2567 + /* invalidate maps */
2568 +- silent_page = ((unsigned int)emu->silent_page.addr << 1) | MAP_PTI_MASK;
2569 ++ silent_page = ((unsigned int)emu->silent_page.addr << emu->address_mode) | (emu->address_mode ? MAP_PTI_MASK1 : MAP_PTI_MASK0);
2570 + snd_emu10k1_ptr_write(emu, MAPA, voice, silent_page);
2571 + snd_emu10k1_ptr_write(emu, MAPB, voice, silent_page);
2572 + /* modulation envelope */
2573 +diff --git a/sound/pci/emu10k1/memory.c b/sound/pci/emu10k1/memory.c
2574 +index c68e6dd2fa67..4f1f69be1865 100644
2575 +--- a/sound/pci/emu10k1/memory.c
2576 ++++ b/sound/pci/emu10k1/memory.c
2577 +@@ -34,10 +34,11 @@
2578 + * aligned pages in others
2579 + */
2580 + #define __set_ptb_entry(emu,page,addr) \
2581 +- (((u32 *)(emu)->ptb_pages.area)[page] = cpu_to_le32(((addr) << 1) | (page)))
2582 ++ (((u32 *)(emu)->ptb_pages.area)[page] = cpu_to_le32(((addr) << (emu->address_mode)) | (page)))
2583 +
2584 + #define UNIT_PAGES (PAGE_SIZE / EMUPAGESIZE)
2585 +-#define MAX_ALIGN_PAGES (MAXPAGES / UNIT_PAGES)
2586 ++#define MAX_ALIGN_PAGES0 (MAXPAGES0 / UNIT_PAGES)
2587 ++#define MAX_ALIGN_PAGES1 (MAXPAGES1 / UNIT_PAGES)
2588 + /* get aligned page from offset address */
2589 + #define get_aligned_page(offset) ((offset) >> PAGE_SHIFT)
2590 + /* get offset address from aligned page */
2591 +@@ -124,7 +125,7 @@ static int search_empty_map_area(struct snd_emu10k1 *emu, int npages, struct lis
2592 + }
2593 + page = blk->mapped_page + blk->pages;
2594 + }
2595 +- size = MAX_ALIGN_PAGES - page;
2596 ++ size = (emu->address_mode ? MAX_ALIGN_PAGES1 : MAX_ALIGN_PAGES0) - page;
2597 + if (size >= max_size) {
2598 + *nextp = pos;
2599 + return page;
2600 +@@ -181,7 +182,7 @@ static int unmap_memblk(struct snd_emu10k1 *emu, struct snd_emu10k1_memblk *blk)
2601 + q = get_emu10k1_memblk(p, mapped_link);
2602 + end_page = q->mapped_page;
2603 + } else
2604 +- end_page = MAX_ALIGN_PAGES;
2605 ++ end_page = (emu->address_mode ? MAX_ALIGN_PAGES1 : MAX_ALIGN_PAGES0);
2606 +
2607 + /* remove links */
2608 + list_del(&blk->mapped_link);
2609 +@@ -307,7 +308,7 @@ snd_emu10k1_alloc_pages(struct snd_emu10k1 *emu, struct snd_pcm_substream *subst
2610 + if (snd_BUG_ON(!emu))
2611 + return NULL;
2612 + if (snd_BUG_ON(runtime->dma_bytes <= 0 ||
2613 +- runtime->dma_bytes >= MAXPAGES * EMUPAGESIZE))
2614 ++ runtime->dma_bytes >= (emu->address_mode ? MAXPAGES1 : MAXPAGES0) * EMUPAGESIZE))
2615 + return NULL;
2616 + hdr = emu->memhdr;
2617 + if (snd_BUG_ON(!hdr))
2618 +diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
2619 +index 2fe86d2e1b09..a63a86332deb 100644
2620 +--- a/sound/pci/hda/hda_codec.c
2621 ++++ b/sound/pci/hda/hda_codec.c
2622 +@@ -3027,6 +3027,16 @@ static struct snd_kcontrol_new vmaster_mute_mode = {
2623 + .put = vmaster_mute_mode_put,
2624 + };
2625 +
2626 ++/* meta hook to call each driver's vmaster hook */
2627 ++static void vmaster_hook(void *private_data, int enabled)
2628 ++{
2629 ++ struct hda_vmaster_mute_hook *hook = private_data;
2630 ++
2631 ++ if (hook->mute_mode != HDA_VMUTE_FOLLOW_MASTER)
2632 ++ enabled = hook->mute_mode;
2633 ++ hook->hook(hook->codec, enabled);
2634 ++}
2635 ++
2636 + /**
2637 + * snd_hda_add_vmaster_hook - Add a vmaster hook for mute-LED
2638 + * @codec: the HDA codec
2639 +@@ -3045,9 +3055,9 @@ int snd_hda_add_vmaster_hook(struct hda_codec *codec,
2640 +
2641 + if (!hook->hook || !hook->sw_kctl)
2642 + return 0;
2643 +- snd_ctl_add_vmaster_hook(hook->sw_kctl, hook->hook, codec);
2644 + hook->codec = codec;
2645 + hook->mute_mode = HDA_VMUTE_FOLLOW_MASTER;
2646 ++ snd_ctl_add_vmaster_hook(hook->sw_kctl, vmaster_hook, hook);
2647 + if (!expose_enum_ctl)
2648 + return 0;
2649 + kctl = snd_ctl_new1(&vmaster_mute_mode, hook);
2650 +@@ -3073,14 +3083,7 @@ void snd_hda_sync_vmaster_hook(struct hda_vmaster_mute_hook *hook)
2651 + */
2652 + if (hook->codec->bus->shutdown)
2653 + return;
2654 +- switch (hook->mute_mode) {
2655 +- case HDA_VMUTE_FOLLOW_MASTER:
2656 +- snd_ctl_sync_vmaster_hook(hook->sw_kctl);
2657 +- break;
2658 +- default:
2659 +- hook->hook(hook->codec, hook->mute_mode);
2660 +- break;
2661 +- }
2662 ++ snd_ctl_sync_vmaster_hook(hook->sw_kctl);
2663 + }
2664 + EXPORT_SYMBOL_GPL(snd_hda_sync_vmaster_hook);
2665 +
2666 +diff --git a/sound/pci/hda/thinkpad_helper.c b/sound/pci/hda/thinkpad_helper.c
2667 +index 6ba0b5517c40..2341fc334163 100644
2668 +--- a/sound/pci/hda/thinkpad_helper.c
2669 ++++ b/sound/pci/hda/thinkpad_helper.c
2670 +@@ -72,6 +72,7 @@ static void hda_fixup_thinkpad_acpi(struct hda_codec *codec,
2671 + if (led_set_func(TPACPI_LED_MUTE, false) >= 0) {
2672 + old_vmaster_hook = spec->vmaster_mute.hook;
2673 + spec->vmaster_mute.hook = update_tpacpi_mute_led;
2674 ++ spec->vmaster_mute_enum = 1;
2675 + removefunc = false;
2676 + }
2677 + if (led_set_func(TPACPI_LED_MICMUTE, false) >= 0) {
2678 +diff --git a/sound/soc/codecs/rt5677.c b/sound/soc/codecs/rt5677.c
2679 +index fb9c20eace3f..97b33e96439a 100644
2680 +--- a/sound/soc/codecs/rt5677.c
2681 ++++ b/sound/soc/codecs/rt5677.c
2682 +@@ -62,6 +62,9 @@ static const struct reg_default init_list[] = {
2683 + {RT5677_PR_BASE + 0x1e, 0x0000},
2684 + {RT5677_PR_BASE + 0x12, 0x0eaa},
2685 + {RT5677_PR_BASE + 0x14, 0x018a},
2686 ++ {RT5677_PR_BASE + 0x15, 0x0490},
2687 ++ {RT5677_PR_BASE + 0x38, 0x0f71},
2688 ++ {RT5677_PR_BASE + 0x39, 0x0f71},
2689 + };
2690 + #define RT5677_INIT_REG_LEN ARRAY_SIZE(init_list)
2691 +
2692 +@@ -901,7 +904,7 @@ static int set_dmic_clk(struct snd_soc_dapm_widget *w,
2693 + {
2694 + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
2695 + struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
2696 +- int idx = rl6231_calc_dmic_clk(rt5677->sysclk);
2697 ++ int idx = rl6231_calc_dmic_clk(rt5677->lrck[RT5677_AIF1] << 8);
2698 +
2699 + if (idx < 0)
2700 + dev_err(codec->dev, "Failed to set DMIC clock\n");
2701 +diff --git a/sound/soc/codecs/tfa9879.c b/sound/soc/codecs/tfa9879.c
2702 +index 16f1b71edb55..aab0af681e8c 100644
2703 +--- a/sound/soc/codecs/tfa9879.c
2704 ++++ b/sound/soc/codecs/tfa9879.c
2705 +@@ -280,8 +280,8 @@ static int tfa9879_i2c_probe(struct i2c_client *i2c,
2706 + int i;
2707 +
2708 + tfa9879 = devm_kzalloc(&i2c->dev, sizeof(*tfa9879), GFP_KERNEL);
2709 +- if (IS_ERR(tfa9879))
2710 +- return PTR_ERR(tfa9879);
2711 ++ if (!tfa9879)
2712 ++ return -ENOMEM;
2713 +
2714 + i2c_set_clientdata(i2c, tfa9879);
2715 +
2716 +diff --git a/sound/soc/samsung/s3c24xx-i2s.c b/sound/soc/samsung/s3c24xx-i2s.c
2717 +index 326d3c3804e3..5bf723689692 100644
2718 +--- a/sound/soc/samsung/s3c24xx-i2s.c
2719 ++++ b/sound/soc/samsung/s3c24xx-i2s.c
2720 +@@ -461,8 +461,8 @@ static int s3c24xx_iis_dev_probe(struct platform_device *pdev)
2721 + return -ENOENT;
2722 + }
2723 + s3c24xx_i2s.regs = devm_ioremap_resource(&pdev->dev, res);
2724 +- if (s3c24xx_i2s.regs == NULL)
2725 +- return -ENXIO;
2726 ++ if (IS_ERR(s3c24xx_i2s.regs))
2727 ++ return PTR_ERR(s3c24xx_i2s.regs);
2728 +
2729 + s3c24xx_i2s_pcm_stereo_out.dma_addr = res->start + S3C2410_IISFIFO;
2730 + s3c24xx_i2s_pcm_stereo_in.dma_addr = res->start + S3C2410_IISFIFO;
2731 +diff --git a/sound/synth/emux/emux_oss.c b/sound/synth/emux/emux_oss.c
2732 +index ab37add269ae..82e350e9501c 100644
2733 +--- a/sound/synth/emux/emux_oss.c
2734 ++++ b/sound/synth/emux/emux_oss.c
2735 +@@ -118,12 +118,8 @@ snd_emux_open_seq_oss(struct snd_seq_oss_arg *arg, void *closure)
2736 + if (snd_BUG_ON(!arg || !emu))
2737 + return -ENXIO;
2738 +
2739 +- mutex_lock(&emu->register_mutex);
2740 +-
2741 +- if (!snd_emux_inc_count(emu)) {
2742 +- mutex_unlock(&emu->register_mutex);
2743 ++ if (!snd_emux_inc_count(emu))
2744 + return -EFAULT;
2745 +- }
2746 +
2747 + memset(&callback, 0, sizeof(callback));
2748 + callback.owner = THIS_MODULE;
2749 +@@ -135,7 +131,6 @@ snd_emux_open_seq_oss(struct snd_seq_oss_arg *arg, void *closure)
2750 + if (p == NULL) {
2751 + snd_printk(KERN_ERR "can't create port\n");
2752 + snd_emux_dec_count(emu);
2753 +- mutex_unlock(&emu->register_mutex);
2754 + return -ENOMEM;
2755 + }
2756 +
2757 +@@ -148,8 +143,6 @@ snd_emux_open_seq_oss(struct snd_seq_oss_arg *arg, void *closure)
2758 + reset_port_mode(p, arg->seq_mode);
2759 +
2760 + snd_emux_reset_port(p);
2761 +-
2762 +- mutex_unlock(&emu->register_mutex);
2763 + return 0;
2764 + }
2765 +
2766 +@@ -195,13 +188,11 @@ snd_emux_close_seq_oss(struct snd_seq_oss_arg *arg)
2767 + if (snd_BUG_ON(!emu))
2768 + return -ENXIO;
2769 +
2770 +- mutex_lock(&emu->register_mutex);
2771 + snd_emux_sounds_off_all(p);
2772 + snd_soundfont_close_check(emu->sflist, SF_CLIENT_NO(p->chset.port));
2773 + snd_seq_event_port_detach(p->chset.client, p->chset.port);
2774 + snd_emux_dec_count(emu);
2775 +
2776 +- mutex_unlock(&emu->register_mutex);
2777 + return 0;
2778 + }
2779 +
2780 +diff --git a/sound/synth/emux/emux_seq.c b/sound/synth/emux/emux_seq.c
2781 +index 7778b8e19782..a0209204ae48 100644
2782 +--- a/sound/synth/emux/emux_seq.c
2783 ++++ b/sound/synth/emux/emux_seq.c
2784 +@@ -124,12 +124,10 @@ snd_emux_detach_seq(struct snd_emux *emu)
2785 + if (emu->voices)
2786 + snd_emux_terminate_all(emu);
2787 +
2788 +- mutex_lock(&emu->register_mutex);
2789 + if (emu->client >= 0) {
2790 + snd_seq_delete_kernel_client(emu->client);
2791 + emu->client = -1;
2792 + }
2793 +- mutex_unlock(&emu->register_mutex);
2794 + }
2795 +
2796 +
2797 +@@ -269,8 +267,8 @@ snd_emux_event_input(struct snd_seq_event *ev, int direct, void *private_data,
2798 + /*
2799 + * increment usage count
2800 + */
2801 +-int
2802 +-snd_emux_inc_count(struct snd_emux *emu)
2803 ++static int
2804 ++__snd_emux_inc_count(struct snd_emux *emu)
2805 + {
2806 + emu->used++;
2807 + if (!try_module_get(emu->ops.owner))
2808 +@@ -284,12 +282,21 @@ snd_emux_inc_count(struct snd_emux *emu)
2809 + return 1;
2810 + }
2811 +
2812 ++int snd_emux_inc_count(struct snd_emux *emu)
2813 ++{
2814 ++ int ret;
2815 ++
2816 ++ mutex_lock(&emu->register_mutex);
2817 ++ ret = __snd_emux_inc_count(emu);
2818 ++ mutex_unlock(&emu->register_mutex);
2819 ++ return ret;
2820 ++}
2821 +
2822 + /*
2823 + * decrease usage count
2824 + */
2825 +-void
2826 +-snd_emux_dec_count(struct snd_emux *emu)
2827 ++static void
2828 ++__snd_emux_dec_count(struct snd_emux *emu)
2829 + {
2830 + module_put(emu->card->module);
2831 + emu->used--;
2832 +@@ -298,6 +305,12 @@ snd_emux_dec_count(struct snd_emux *emu)
2833 + module_put(emu->ops.owner);
2834 + }
2835 +
2836 ++void snd_emux_dec_count(struct snd_emux *emu)
2837 ++{
2838 ++ mutex_lock(&emu->register_mutex);
2839 ++ __snd_emux_dec_count(emu);
2840 ++ mutex_unlock(&emu->register_mutex);
2841 ++}
2842 +
2843 + /*
2844 + * Routine that is called upon a first use of a particular port
2845 +@@ -317,7 +330,7 @@ snd_emux_use(void *private_data, struct snd_seq_port_subscribe *info)
2846 +
2847 + mutex_lock(&emu->register_mutex);
2848 + snd_emux_init_port(p);
2849 +- snd_emux_inc_count(emu);
2850 ++ __snd_emux_inc_count(emu);
2851 + mutex_unlock(&emu->register_mutex);
2852 + return 0;
2853 + }
2854 +@@ -340,7 +353,7 @@ snd_emux_unuse(void *private_data, struct snd_seq_port_subscribe *info)
2855 +
2856 + mutex_lock(&emu->register_mutex);
2857 + snd_emux_sounds_off_all(p);
2858 +- snd_emux_dec_count(emu);
2859 ++ __snd_emux_dec_count(emu);
2860 + mutex_unlock(&emu->register_mutex);
2861 + return 0;
2862 + }