Magellan Linux

Annotation of /trunk/kernel-magellan/patches-4.0/0102-4.0.3-all-fixes.patch

Parent Directory Parent Directory | Revision Log Revision Log


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