aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2013-02-06 15:19:42 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2013-02-07 11:35:08 +0000
commit34b2f63a52387974644ddb8224019fb87b007751 (patch)
tree4ffc8c555fdfe424968fe13b05c586add37c95db
parenta2240c195d6ca389ca5386172e045aa2069fe940 (diff)
downloadalpine_aports-34b2f63a52387974644ddb8224019fb87b007751.tar.bz2
alpine_aports-34b2f63a52387974644ddb8224019fb87b007751.tar.xz
alpine_aports-34b2f63a52387974644ddb8224019fb87b007751.zip
main/linux-vserver: add stable fixes from 3.4.28-3.4.29
(cherry picked from commit a350b578ab7629be9b13c6d6500dd854e87baf96)
-rw-r--r--main/linux-vserver/APKBUILD6
-rw-r--r--main/linux-vserver/patch-3.6.11-al3.patch10296
2 files changed, 10299 insertions, 3 deletions
diff --git a/main/linux-vserver/APKBUILD b/main/linux-vserver/APKBUILD
index 073acc0726..206dfb64c4 100644
--- a/main/linux-vserver/APKBUILD
+++ b/main/linux-vserver/APKBUILD
@@ -3,7 +3,7 @@
3_flavor=vserver 3_flavor=vserver
4pkgname=linux-${_flavor} 4pkgname=linux-${_flavor}
5pkgver=3.6.11 5pkgver=3.6.11
6pkgrel=1 6pkgrel=2
7_vsver=vs2.3.4.6 7_vsver=vs2.3.4.6
8 8
9if [ "${pkgver##*.*.*}" = "$pkgver" ]; then 9if [ "${pkgver##*.*.*}" = "$pkgver" ]; then
@@ -21,7 +21,7 @@ _config=${config:-kernelconfig.${CARCH}}
21install= 21install=
22source="http://www.kernel.org/pub/linux/kernel/v3.x/linux-$_kernver.tar.xz 22source="http://www.kernel.org/pub/linux/kernel/v3.x/linux-$_kernver.tar.xz
23 http://www.kernel.org/pub/linux/kernel/v3.x/patch-$pkgver.xz 23 http://www.kernel.org/pub/linux/kernel/v3.x/patch-$pkgver.xz
24 patch-3.6.11-al2.patch 24 patch-3.6.11-al3.patch
25 patch-$pkgver-$_vsver.diff 25 patch-$pkgver-$_vsver.diff
26 kernelconfig.x86 26 kernelconfig.x86
27 kernelconfig.x86_64 27 kernelconfig.x86_64
@@ -138,7 +138,7 @@ dev() {
138 138
139md5sums="1a1760420eac802c541a20ab51a093d1 linux-3.6.tar.xz 139md5sums="1a1760420eac802c541a20ab51a093d1 linux-3.6.tar.xz
140bd4bba74093405887d521309a74c19e9 patch-3.6.11.xz 140bd4bba74093405887d521309a74c19e9 patch-3.6.11.xz
1414d225839f004e4133c5fa48b7ca0ddf5 patch-3.6.11-al2.patch 141ca40e52ffe0519221fc07c25bedfc346 patch-3.6.11-al3.patch
14227809872b8bc0dffce4e383d68d1c989 patch-3.6.11-vs2.3.4.6.diff 14227809872b8bc0dffce4e383d68d1c989 patch-3.6.11-vs2.3.4.6.diff
143b28263bb0d529a80d4f13fbdd76520b2 kernelconfig.x86 143b28263bb0d529a80d4f13fbdd76520b2 kernelconfig.x86
1441e9e12d5bd63552127331b875a554992 kernelconfig.x86_64" 1441e9e12d5bd63552127331b875a554992 kernelconfig.x86_64"
diff --git a/main/linux-vserver/patch-3.6.11-al3.patch b/main/linux-vserver/patch-3.6.11-al3.patch
new file mode 100644
index 0000000000..91e87fef2f
--- /dev/null
+++ b/main/linux-vserver/patch-3.6.11-al3.patch
@@ -0,0 +1,10296 @@
1diff --git a/arch/arm/kernel/swp_emulate.c b/arch/arm/kernel/swp_emulate.c
2index df74518..ab1017b 100644
3--- a/arch/arm/kernel/swp_emulate.c
4+++ b/arch/arm/kernel/swp_emulate.c
5@@ -109,10 +109,12 @@ static void set_segfault(struct pt_regs *regs, unsigned long addr)
6 {
7 siginfo_t info;
8
9+ down_read(&current->mm->mmap_sem);
10 if (find_vma(current->mm, addr) == NULL)
11 info.si_code = SEGV_MAPERR;
12 else
13 info.si_code = SEGV_ACCERR;
14+ up_read(&current->mm->mmap_sem);
15
16 info.si_signo = SIGSEGV;
17 info.si_errno = 0;
18diff --git a/arch/arm/mach-at91/setup.c b/arch/arm/mach-at91/setup.c
19index bd0e88c..c2ff99c 100644
20--- a/arch/arm/mach-at91/setup.c
21+++ b/arch/arm/mach-at91/setup.c
22@@ -104,6 +104,8 @@ static void __init soc_detect(u32 dbgu_base)
23 switch (socid) {
24 case ARCH_ID_AT91RM9200:
25 at91_soc_initdata.type = AT91_SOC_RM9200;
26+ if (at91_soc_initdata.subtype == AT91_SOC_SUBTYPE_NONE)
27+ at91_soc_initdata.subtype = AT91_SOC_RM9200_BGA;
28 at91_boot_soc = at91rm9200_soc;
29 break;
30
31diff --git a/arch/arm/mach-pxa/include/mach/mfp-pxa27x.h b/arch/arm/mach-pxa/include/mach/mfp-pxa27x.h
32index a611ad3..b6132aa 100644
33--- a/arch/arm/mach-pxa/include/mach/mfp-pxa27x.h
34+++ b/arch/arm/mach-pxa/include/mach/mfp-pxa27x.h
35@@ -463,6 +463,9 @@
36 GPIO76_LCD_PCLK, \
37 GPIO77_LCD_BIAS
38
39+/* these enable a work-around for a hw bug in pxa27x during ac97 warm reset */
40+#define GPIO113_AC97_nRESET_GPIO_HIGH MFP_CFG_OUT(GPIO113, AF0, DEFAULT)
41+#define GPIO95_AC97_nRESET_GPIO_HIGH MFP_CFG_OUT(GPIO95, AF0, DEFAULT)
42
43 extern int keypad_set_wake(unsigned int on);
44 #endif /* __ASM_ARCH_MFP_PXA27X_H */
45diff --git a/arch/arm/mach-pxa/pxa27x.c b/arch/arm/mach-pxa/pxa27x.c
46index 4726c24..a2fe795 100644
47--- a/arch/arm/mach-pxa/pxa27x.c
48+++ b/arch/arm/mach-pxa/pxa27x.c
49@@ -47,9 +47,9 @@ void pxa27x_clear_otgph(void)
50 EXPORT_SYMBOL(pxa27x_clear_otgph);
51
52 static unsigned long ac97_reset_config[] = {
53- GPIO113_GPIO,
54+ GPIO113_AC97_nRESET_GPIO_HIGH,
55 GPIO113_AC97_nRESET,
56- GPIO95_GPIO,
57+ GPIO95_AC97_nRESET_GPIO_HIGH,
58 GPIO95_AC97_nRESET,
59 };
60
61diff --git a/arch/arm/mach-realview/include/mach/board-eb.h b/arch/arm/mach-realview/include/mach/board-eb.h
62index 124bce6..a301e61 100644
63--- a/arch/arm/mach-realview/include/mach/board-eb.h
64+++ b/arch/arm/mach-realview/include/mach/board-eb.h
65@@ -47,7 +47,7 @@
66 #define REALVIEW_EB_USB_BASE 0x4F000000 /* USB */
67
68 #ifdef CONFIG_REALVIEW_EB_ARM11MP_REVB
69-#define REALVIEW_EB11MP_PRIV_MEM_BASE 0x1F000000
70+#define REALVIEW_EB11MP_PRIV_MEM_BASE 0x10100000
71 #define REALVIEW_EB11MP_L220_BASE 0x10102000 /* L220 registers */
72 #define REALVIEW_EB11MP_SYS_PLD_CTRL1 0xD8 /* Register offset for MPCore sysctl */
73 #else
74diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
75index 13f555d..357fc03 100644
76--- a/arch/arm/mm/dma-mapping.c
77+++ b/arch/arm/mm/dma-mapping.c
78@@ -729,25 +729,27 @@ static void dma_cache_maint_page(struct page *page, unsigned long offset,
79 size_t size, enum dma_data_direction dir,
80 void (*op)(const void *, size_t, int))
81 {
82+ unsigned long pfn;
83+ size_t left = size;
84+
85+ pfn = page_to_pfn(page) + offset / PAGE_SIZE;
86+ offset %= PAGE_SIZE;
87+
88 /*
89 * A single sg entry may refer to multiple physically contiguous
90 * pages. But we still need to process highmem pages individually.
91 * If highmem is not configured then the bulk of this loop gets
92 * optimized out.
93 */
94- size_t left = size;
95 do {
96 size_t len = left;
97 void *vaddr;
98
99+ page = pfn_to_page(pfn);
100+
101 if (PageHighMem(page)) {
102- if (len + offset > PAGE_SIZE) {
103- if (offset >= PAGE_SIZE) {
104- page += offset / PAGE_SIZE;
105- offset %= PAGE_SIZE;
106- }
107+ if (len + offset > PAGE_SIZE)
108 len = PAGE_SIZE - offset;
109- }
110 vaddr = kmap_high_get(page);
111 if (vaddr) {
112 vaddr += offset;
113@@ -764,7 +766,7 @@ static void dma_cache_maint_page(struct page *page, unsigned long offset,
114 op(vaddr, len, dir);
115 }
116 offset = 0;
117- page++;
118+ pfn++;
119 left -= len;
120 } while (left);
121 }
122diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
123index c2fa21d..b68b531 100644
124--- a/arch/arm/mm/mmu.c
125+++ b/arch/arm/mm/mmu.c
126@@ -498,7 +498,7 @@ static void __init build_mem_type_table(void)
127 #endif
128
129 for (i = 0; i < 16; i++) {
130- unsigned long v = pgprot_val(protection_map[i]);
131+ pteval_t v = pgprot_val(protection_map[i]);
132 protection_map[i] = __pgprot(v | user_pgprot);
133 }
134
135diff --git a/arch/arm/vfp/entry.S b/arch/arm/vfp/entry.S
136index cc926c9..323ce1a 100644
137--- a/arch/arm/vfp/entry.S
138+++ b/arch/arm/vfp/entry.S
139@@ -22,7 +22,7 @@
140 @ IRQs disabled.
141 @
142 ENTRY(do_vfp)
143-#ifdef CONFIG_PREEMPT
144+#ifdef CONFIG_PREEMPT_COUNT
145 ldr r4, [r10, #TI_PREEMPT] @ get preempt count
146 add r11, r4, #1 @ increment it
147 str r11, [r10, #TI_PREEMPT]
148@@ -35,7 +35,7 @@ ENTRY(do_vfp)
149 ENDPROC(do_vfp)
150
151 ENTRY(vfp_null_entry)
152-#ifdef CONFIG_PREEMPT
153+#ifdef CONFIG_PREEMPT_COUNT
154 get_thread_info r10
155 ldr r4, [r10, #TI_PREEMPT] @ get preempt count
156 sub r11, r4, #1 @ decrement it
157@@ -53,7 +53,7 @@ ENDPROC(vfp_null_entry)
158
159 __INIT
160 ENTRY(vfp_testing_entry)
161-#ifdef CONFIG_PREEMPT
162+#ifdef CONFIG_PREEMPT_COUNT
163 get_thread_info r10
164 ldr r4, [r10, #TI_PREEMPT] @ get preempt count
165 sub r11, r4, #1 @ decrement it
166diff --git a/arch/arm/vfp/vfphw.S b/arch/arm/vfp/vfphw.S
167index ea0349f..dd5e56f 100644
168--- a/arch/arm/vfp/vfphw.S
169+++ b/arch/arm/vfp/vfphw.S
170@@ -168,7 +168,7 @@ vfp_hw_state_valid:
171 @ else it's one 32-bit instruction, so
172 @ always subtract 4 from the following
173 @ instruction address.
174-#ifdef CONFIG_PREEMPT
175+#ifdef CONFIG_PREEMPT_COUNT
176 get_thread_info r10
177 ldr r4, [r10, #TI_PREEMPT] @ get preempt count
178 sub r11, r4, #1 @ decrement it
179@@ -192,7 +192,7 @@ look_for_VFP_exceptions:
180 @ not recognised by VFP
181
182 DBGSTR "not VFP"
183-#ifdef CONFIG_PREEMPT
184+#ifdef CONFIG_PREEMPT_COUNT
185 get_thread_info r10
186 ldr r4, [r10, #TI_PREEMPT] @ get preempt count
187 sub r11, r4, #1 @ decrement it
188diff --git a/arch/cris/include/asm/io.h b/arch/cris/include/asm/io.h
189index 32567bc..ac12ae2 100644
190--- a/arch/cris/include/asm/io.h
191+++ b/arch/cris/include/asm/io.h
192@@ -133,12 +133,39 @@ static inline void writel(unsigned int b, volatile void __iomem *addr)
193 #define insb(port,addr,count) (cris_iops ? cris_iops->read_io(port,addr,1,count) : 0)
194 #define insw(port,addr,count) (cris_iops ? cris_iops->read_io(port,addr,2,count) : 0)
195 #define insl(port,addr,count) (cris_iops ? cris_iops->read_io(port,addr,4,count) : 0)
196-#define outb(data,port) if (cris_iops) cris_iops->write_io(port,(void*)(unsigned)data,1,1)
197-#define outw(data,port) if (cris_iops) cris_iops->write_io(port,(void*)(unsigned)data,2,1)
198-#define outl(data,port) if (cris_iops) cris_iops->write_io(port,(void*)(unsigned)data,4,1)
199-#define outsb(port,addr,count) if(cris_iops) cris_iops->write_io(port,(void*)addr,1,count)
200-#define outsw(port,addr,count) if(cris_iops) cris_iops->write_io(port,(void*)addr,2,count)
201-#define outsl(port,addr,count) if(cris_iops) cris_iops->write_io(port,(void*)addr,3,count)
202+static inline void outb(unsigned char data, unsigned int port)
203+{
204+ if (cris_iops)
205+ cris_iops->write_io(port, (void *) &data, 1, 1);
206+}
207+static inline void outw(unsigned short data, unsigned int port)
208+{
209+ if (cris_iops)
210+ cris_iops->write_io(port, (void *) &data, 2, 1);
211+}
212+static inline void outl(unsigned int data, unsigned int port)
213+{
214+ if (cris_iops)
215+ cris_iops->write_io(port, (void *) &data, 4, 1);
216+}
217+static inline void outsb(unsigned int port, const void *addr,
218+ unsigned long count)
219+{
220+ if (cris_iops)
221+ cris_iops->write_io(port, (void *)addr, 1, count);
222+}
223+static inline void outsw(unsigned int port, const void *addr,
224+ unsigned long count)
225+{
226+ if (cris_iops)
227+ cris_iops->write_io(port, (void *)addr, 2, count);
228+}
229+static inline void outsl(unsigned int port, const void *addr,
230+ unsigned long count)
231+{
232+ if (cris_iops)
233+ cris_iops->write_io(port, (void *)addr, 4, count);
234+}
235
236 /*
237 * Convert a physical pointer to a virtual kernel pointer for /dev/mem
238diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
239index e9a5fd7..69b17a9 100644
240--- a/arch/mips/kernel/process.c
241+++ b/arch/mips/kernel/process.c
242@@ -72,9 +72,7 @@ void __noreturn cpu_idle(void)
243 }
244 }
245 #ifdef CONFIG_HOTPLUG_CPU
246- if (!cpu_online(cpu) && !cpu_isset(cpu, cpu_callin_map) &&
247- (system_state == SYSTEM_RUNNING ||
248- system_state == SYSTEM_BOOTING))
249+ if (!cpu_online(cpu) && !cpu_isset(cpu, cpu_callin_map))
250 play_dead();
251 #endif
252 rcu_idle_exit();
253diff --git a/arch/powerpc/kernel/head_64.S b/arch/powerpc/kernel/head_64.S
254index 58bddee..9e07bd0 100644
255--- a/arch/powerpc/kernel/head_64.S
256+++ b/arch/powerpc/kernel/head_64.S
257@@ -422,7 +422,7 @@ _STATIC(__after_prom_start)
258 tovirt(r6,r6) /* on booke, we already run at PAGE_OFFSET */
259 #endif
260
261-#ifdef CONFIG_CRASH_DUMP
262+#ifdef CONFIG_RELOCATABLE
263 /*
264 * Check if the kernel has to be running as relocatable kernel based on the
265 * variable __run_at_load, if it is set the kernel is treated as relocatable
266diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c
267index e49e931..5395666 100644
268--- a/arch/powerpc/kernel/time.c
269+++ b/arch/powerpc/kernel/time.c
270@@ -759,13 +759,8 @@ void update_vsyscall(struct timespec *wall_time, struct timespec *wtm,
271
272 void update_vsyscall_tz(void)
273 {
274- /* Make userspace gettimeofday spin until we're done. */
275- ++vdso_data->tb_update_count;
276- smp_mb();
277 vdso_data->tz_minuteswest = sys_tz.tz_minuteswest;
278 vdso_data->tz_dsttime = sys_tz.tz_dsttime;
279- smp_mb();
280- ++vdso_data->tb_update_count;
281 }
282
283 static void __init clocksource_init(void)
284diff --git a/arch/powerpc/kvm/44x_emulate.c b/arch/powerpc/kvm/44x_emulate.c
285index c8c6157..c39cd0b 100644
286--- a/arch/powerpc/kvm/44x_emulate.c
287+++ b/arch/powerpc/kvm/44x_emulate.c
288@@ -76,6 +76,7 @@ int kvmppc_core_emulate_op(struct kvm_run *run, struct kvm_vcpu *vcpu,
289 run->dcr.dcrn = dcrn;
290 run->dcr.data = 0;
291 run->dcr.is_write = 0;
292+ vcpu->arch.dcr_is_write = 0;
293 vcpu->arch.io_gpr = rt;
294 vcpu->arch.dcr_needed = 1;
295 kvmppc_account_exit(vcpu, DCR_EXITS);
296@@ -94,6 +95,7 @@ int kvmppc_core_emulate_op(struct kvm_run *run, struct kvm_vcpu *vcpu,
297 run->dcr.dcrn = dcrn;
298 run->dcr.data = kvmppc_get_gpr(vcpu, rs);
299 run->dcr.is_write = 1;
300+ vcpu->arch.dcr_is_write = 1;
301 vcpu->arch.dcr_needed = 1;
302 kvmppc_account_exit(vcpu, DCR_EXITS);
303 emulated = EMULATE_DO_DCR;
304diff --git a/arch/powerpc/platforms/40x/ppc40x_simple.c b/arch/powerpc/platforms/40x/ppc40x_simple.c
305index 9761206..f0eee75 100644
306--- a/arch/powerpc/platforms/40x/ppc40x_simple.c
307+++ b/arch/powerpc/platforms/40x/ppc40x_simple.c
308@@ -57,7 +57,8 @@ static const char *board[] __initdata = {
309 "amcc,makalu",
310 "apm,klondike",
311 "est,hotfoot",
312- "plathome,obs600"
313+ "plathome,obs600",
314+ NULL
315 };
316
317 static int __init ppc40x_probe(void)
318diff --git a/arch/s390/include/asm/timex.h b/arch/s390/include/asm/timex.h
319index fba4d66..4c060bb 100644
320--- a/arch/s390/include/asm/timex.h
321+++ b/arch/s390/include/asm/timex.h
322@@ -128,4 +128,32 @@ static inline unsigned long long get_clock_monotonic(void)
323 return get_clock_xt() - sched_clock_base_cc;
324 }
325
326+/**
327+ * tod_to_ns - convert a TOD format value to nanoseconds
328+ * @todval: to be converted TOD format value
329+ * Returns: number of nanoseconds that correspond to the TOD format value
330+ *
331+ * Converting a 64 Bit TOD format value to nanoseconds means that the value
332+ * must be divided by 4.096. In order to achieve that we multiply with 125
333+ * and divide by 512:
334+ *
335+ * ns = (todval * 125) >> 9;
336+ *
337+ * In order to avoid an overflow with the multiplication we can rewrite this.
338+ * With a split todval == 2^32 * th + tl (th upper 32 bits, tl lower 32 bits)
339+ * we end up with
340+ *
341+ * ns = ((2^32 * th + tl) * 125 ) >> 9;
342+ * -> ns = (2^23 * th * 125) + ((tl * 125) >> 9);
343+ *
344+ */
345+static inline unsigned long long tod_to_ns(unsigned long long todval)
346+{
347+ unsigned long long ns;
348+
349+ ns = ((todval >> 32) << 23) * 125;
350+ ns += ((todval & 0xffffffff) * 125) >> 9;
351+ return ns;
352+}
353+
354 #endif
355diff --git a/arch/s390/kernel/time.c b/arch/s390/kernel/time.c
356index dcec960..0cb14ba 100644
357--- a/arch/s390/kernel/time.c
358+++ b/arch/s390/kernel/time.c
359@@ -63,7 +63,7 @@ static DEFINE_PER_CPU(struct clock_event_device, comparators);
360 */
361 unsigned long long notrace __kprobes sched_clock(void)
362 {
363- return (get_clock_monotonic() * 125) >> 9;
364+ return tod_to_ns(get_clock_monotonic());
365 }
366
367 /*
368diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c
369index b7bc1aa..a80b585 100644
370--- a/arch/s390/kvm/interrupt.c
371+++ b/arch/s390/kvm/interrupt.c
372@@ -390,7 +390,7 @@ int kvm_s390_handle_wait(struct kvm_vcpu *vcpu)
373 return 0;
374 }
375
376- sltime = ((vcpu->arch.sie_block->ckc - now)*125)>>9;
377+ sltime = tod_to_ns(vcpu->arch.sie_block->ckc - now);
378
379 hrtimer_start(&vcpu->arch.ckc_timer, ktime_set (0, sltime) , HRTIMER_MODE_REL);
380 VCPU_EVENT(vcpu, 5, "enabled wait via clock comparator: %llx ns", sltime);
381diff --git a/arch/sh/include/asm/elf.h b/arch/sh/include/asm/elf.h
382index f38112b..978b7fd 100644
383--- a/arch/sh/include/asm/elf.h
384+++ b/arch/sh/include/asm/elf.h
385@@ -202,9 +202,9 @@ extern void __kernel_vsyscall;
386 if (vdso_enabled) \
387 NEW_AUX_ENT(AT_SYSINFO_EHDR, VDSO_BASE); \
388 else \
389- NEW_AUX_ENT(AT_IGNORE, 0);
390+ NEW_AUX_ENT(AT_IGNORE, 0)
391 #else
392-#define VSYSCALL_AUX_ENT
393+#define VSYSCALL_AUX_ENT NEW_AUX_ENT(AT_IGNORE, 0)
394 #endif /* CONFIG_VSYSCALL */
395
396 #ifdef CONFIG_SH_FPU
397diff --git a/arch/sparc/include/asm/hugetlb.h b/arch/sparc/include/asm/hugetlb.h
398index 1770610..f368cef 100644
399--- a/arch/sparc/include/asm/hugetlb.h
400+++ b/arch/sparc/include/asm/hugetlb.h
401@@ -58,14 +58,20 @@ static inline pte_t huge_pte_wrprotect(pte_t pte)
402 static inline void huge_ptep_set_wrprotect(struct mm_struct *mm,
403 unsigned long addr, pte_t *ptep)
404 {
405- ptep_set_wrprotect(mm, addr, ptep);
406+ pte_t old_pte = *ptep;
407+ set_huge_pte_at(mm, addr, ptep, pte_wrprotect(old_pte));
408 }
409
410 static inline int huge_ptep_set_access_flags(struct vm_area_struct *vma,
411 unsigned long addr, pte_t *ptep,
412 pte_t pte, int dirty)
413 {
414- return ptep_set_access_flags(vma, addr, ptep, pte, dirty);
415+ int changed = !pte_same(*ptep, pte);
416+ if (changed) {
417+ set_huge_pte_at(vma->vm_mm, addr, ptep, pte);
418+ flush_tlb_page(vma, addr);
419+ }
420+ return changed;
421 }
422
423 static inline pte_t huge_ptep_get(pte_t *ptep)
424diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
425index 8f8e8ee..2a6919e 100644
426--- a/arch/x86/kernel/entry_32.S
427+++ b/arch/x86/kernel/entry_32.S
428@@ -1065,7 +1065,6 @@ ENTRY(xen_failsafe_callback)
429 lea 16(%esp),%esp
430 CFI_ADJUST_CFA_OFFSET -16
431 jz 5f
432- addl $16,%esp
433 jmp iret_exc
434 5: pushl_cfi $-1 /* orig_ax = -1 => not a system call */
435 SAVE_ALL
436diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
437index eb11369..8563b64 100644
438--- a/arch/x86/kernel/msr.c
439+++ b/arch/x86/kernel/msr.c
440@@ -174,6 +174,9 @@ static int msr_open(struct inode *inode, struct file *file)
441 unsigned int cpu;
442 struct cpuinfo_x86 *c;
443
444+ if (!capable(CAP_SYS_RAWIO))
445+ return -EPERM;
446+
447 cpu = iminor(file->f_path.dentry->d_inode);
448 if (cpu >= nr_cpu_ids || !cpu_online(cpu))
449 return -ENXIO; /* No such CPU */
450diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
451index 5cee802..b328612 100644
452--- a/arch/x86/kernel/setup.c
453+++ b/arch/x86/kernel/setup.c
454@@ -613,6 +613,83 @@ static __init void reserve_ibft_region(void)
455
456 static unsigned reserve_low = CONFIG_X86_RESERVE_LOW << 10;
457
458+static bool __init snb_gfx_workaround_needed(void)
459+{
460+#ifdef CONFIG_PCI
461+ int i;
462+ u16 vendor, devid;
463+ static const u16 snb_ids[] = {
464+ 0x0102,
465+ 0x0112,
466+ 0x0122,
467+ 0x0106,
468+ 0x0116,
469+ 0x0126,
470+ 0x010a,
471+ };
472+
473+ /* Assume no if something weird is going on with PCI */
474+ if (!early_pci_allowed())
475+ return false;
476+
477+ vendor = read_pci_config_16(0, 2, 0, PCI_VENDOR_ID);
478+ if (vendor != 0x8086)
479+ return false;
480+
481+ devid = read_pci_config_16(0, 2, 0, PCI_DEVICE_ID);
482+ for (i = 0; i < ARRAY_SIZE(snb_ids); i++)
483+ if (devid == snb_ids[i])
484+ return true;
485+#endif
486+
487+ return false;
488+}
489+
490+/*
491+ * Sandy Bridge graphics has trouble with certain ranges, exclude
492+ * them from allocation.
493+ */
494+static void __init trim_snb_memory(void)
495+{
496+ static const unsigned long bad_pages[] = {
497+ 0x20050000,
498+ 0x20110000,
499+ 0x20130000,
500+ 0x20138000,
501+ 0x40004000,
502+ };
503+ int i;
504+
505+ if (!snb_gfx_workaround_needed())
506+ return;
507+
508+ printk(KERN_DEBUG "reserving inaccessible SNB gfx pages\n");
509+
510+ /*
511+ * Reserve all memory below the 1 MB mark that has not
512+ * already been reserved.
513+ */
514+ memblock_reserve(0, 1<<20);
515+
516+ for (i = 0; i < ARRAY_SIZE(bad_pages); i++) {
517+ if (memblock_reserve(bad_pages[i], PAGE_SIZE))
518+ printk(KERN_WARNING "failed to reserve 0x%08lx\n",
519+ bad_pages[i]);
520+ }
521+}
522+
523+/*
524+ * Here we put platform-specific memory range workarounds, i.e.
525+ * memory known to be corrupt or otherwise in need to be reserved on
526+ * specific platforms.
527+ *
528+ * If this gets used more widely it could use a real dispatch mechanism.
529+ */
530+static void __init trim_platform_memory_ranges(void)
531+{
532+ trim_snb_memory();
533+}
534+
535 static void __init trim_bios_range(void)
536 {
537 /*
538@@ -633,6 +710,7 @@ static void __init trim_bios_range(void)
539 * take them out.
540 */
541 e820_remove_range(BIOS_BEGIN, BIOS_END - BIOS_BEGIN, E820_RAM, 1);
542+
543 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
544 }
545
546@@ -911,6 +989,8 @@ void __init setup_arch(char **cmdline_p)
547
548 setup_real_mode();
549
550+ trim_platform_memory_ranges();
551+
552 init_gbpages();
553
554 /* max_pfn_mapped is updated here */
555diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
556index 72d8899..6825327 100644
557--- a/arch/x86/platform/efi/efi.c
558+++ b/arch/x86/platform/efi/efi.c
559@@ -900,7 +900,7 @@ void __init efi_enter_virtual_mode(void)
560 *
561 * Call EFI services through wrapper functions.
562 */
563- efi.runtime_version = efi_systab.fw_revision;
564+ efi.runtime_version = efi_systab.hdr.revision;
565 efi.get_time = virt_efi_get_time;
566 efi.set_time = virt_efi_set_time;
567 efi.get_wakeup_time = virt_efi_get_wakeup_time;
568diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c
569index ac3aa54..0fba86d 100644
570--- a/arch/x86/platform/efi/efi_64.c
571+++ b/arch/x86/platform/efi/efi_64.c
572@@ -38,7 +38,7 @@
573 #include <asm/cacheflush.h>
574 #include <asm/fixmap.h>
575
576-static pgd_t save_pgd __initdata;
577+static pgd_t *save_pgd __initdata;
578 static unsigned long efi_flags __initdata;
579
580 static void __init early_code_mapping_set_exec(int executable)
581@@ -61,12 +61,20 @@ static void __init early_code_mapping_set_exec(int executable)
582 void __init efi_call_phys_prelog(void)
583 {
584 unsigned long vaddress;
585+ int pgd;
586+ int n_pgds;
587
588 early_code_mapping_set_exec(1);
589 local_irq_save(efi_flags);
590- vaddress = (unsigned long)__va(0x0UL);
591- save_pgd = *pgd_offset_k(0x0UL);
592- set_pgd(pgd_offset_k(0x0UL), *pgd_offset_k(vaddress));
593+
594+ n_pgds = DIV_ROUND_UP((max_pfn << PAGE_SHIFT), PGDIR_SIZE);
595+ save_pgd = kmalloc(n_pgds * sizeof(pgd_t), GFP_KERNEL);
596+
597+ for (pgd = 0; pgd < n_pgds; pgd++) {
598+ save_pgd[pgd] = *pgd_offset_k(pgd * PGDIR_SIZE);
599+ vaddress = (unsigned long)__va(pgd * PGDIR_SIZE);
600+ set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), *pgd_offset_k(vaddress));
601+ }
602 __flush_tlb_all();
603 }
604
605@@ -75,7 +83,11 @@ void __init efi_call_phys_epilog(void)
606 /*
607 * After the lock is released, the original page table is restored.
608 */
609- set_pgd(pgd_offset_k(0x0UL), save_pgd);
610+ int pgd;
611+ int n_pgds = DIV_ROUND_UP((max_pfn << PAGE_SHIFT) , PGDIR_SIZE);
612+ for (pgd = 0; pgd < n_pgds; pgd++)
613+ set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), save_pgd[pgd]);
614+ kfree(save_pgd);
615 __flush_tlb_all();
616 local_irq_restore(efi_flags);
617 early_code_mapping_set_exec(0);
618diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
619index ad3730b..aac684d 100644
620--- a/drivers/acpi/processor_idle.c
621+++ b/drivers/acpi/processor_idle.c
622@@ -1009,6 +1009,9 @@ static int acpi_processor_setup_cpuidle_cx(struct acpi_processor *pr)
623 return -EINVAL;
624 }
625
626+ if (!dev)
627+ return -EINVAL;
628+
629 dev->cpu = pr->id;
630
631 if (max_cstate == 0)
632@@ -1196,6 +1199,7 @@ int acpi_processor_cst_has_changed(struct acpi_processor *pr)
633 }
634
635 /* Populate Updated C-state information */
636+ acpi_processor_get_power_info(pr);
637 acpi_processor_setup_cpuidle_states(pr);
638
639 /* Enable all cpuidle devices */
640diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
641index d1ecca2..f1fcaca 100644
642--- a/drivers/acpi/scan.c
643+++ b/drivers/acpi/scan.c
644@@ -807,8 +807,8 @@ acpi_bus_extract_wakeup_device_power_package(acpi_handle handle,
645 static void acpi_bus_set_run_wake_flags(struct acpi_device *device)
646 {
647 struct acpi_device_id button_device_ids[] = {
648- {"PNP0C0D", 0},
649 {"PNP0C0C", 0},
650+ {"PNP0C0D", 0},
651 {"PNP0C0E", 0},
652 {"", 0},
653 };
654@@ -820,6 +820,11 @@ static void acpi_bus_set_run_wake_flags(struct acpi_device *device)
655 /* Power button, Lid switch always enable wakeup */
656 if (!acpi_match_device_ids(device, button_device_ids)) {
657 device->wakeup.flags.run_wake = 1;
658+ if (!acpi_match_device_ids(device, &button_device_ids[1])) {
659+ /* Do not use Lid/sleep button for S5 wakeup */
660+ if (device->wakeup.sleep_state == ACPI_STATE_S5)
661+ device->wakeup.sleep_state = ACPI_STATE_S4;
662+ }
663 device_set_wakeup_capable(&device->dev, true);
664 return;
665 }
666@@ -1175,7 +1180,7 @@ static void acpi_device_set_id(struct acpi_device *device)
667 acpi_add_id(device, ACPI_DOCK_HID);
668 else if (!acpi_ibm_smbus_match(device))
669 acpi_add_id(device, ACPI_SMBUS_IBM_HID);
670- else if (!acpi_device_hid(device) &&
671+ else if (list_empty(&device->pnp.ids) &&
672 ACPI_IS_ROOT_DEVICE(device->parent)) {
673 acpi_add_id(device, ACPI_BUS_HID); /* \_SB, LNXSYBUS */
674 strcpy(device->pnp.device_name, ACPI_BUS_DEVICE_NAME);
675diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
676index 847ed55..813aa38 100644
677--- a/drivers/acpi/sleep.c
678+++ b/drivers/acpi/sleep.c
679@@ -109,6 +109,180 @@ void __init acpi_old_suspend_ordering(void)
680 old_suspend_ordering = true;
681 }
682
683+static int __init init_old_suspend_ordering(const struct dmi_system_id *d)
684+{
685+ acpi_old_suspend_ordering();
686+ return 0;
687+}
688+
689+static int __init init_nvs_nosave(const struct dmi_system_id *d)
690+{
691+ acpi_nvs_nosave();
692+ return 0;
693+}
694+
695+static struct dmi_system_id __initdata acpisleep_dmi_table[] = {
696+ {
697+ .callback = init_old_suspend_ordering,
698+ .ident = "Abit KN9 (nForce4 variant)",
699+ .matches = {
700+ DMI_MATCH(DMI_BOARD_VENDOR, "http://www.abit.com.tw/"),
701+ DMI_MATCH(DMI_BOARD_NAME, "KN9 Series(NF-CK804)"),
702+ },
703+ },
704+ {
705+ .callback = init_old_suspend_ordering,
706+ .ident = "HP xw4600 Workstation",
707+ .matches = {
708+ DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
709+ DMI_MATCH(DMI_PRODUCT_NAME, "HP xw4600 Workstation"),
710+ },
711+ },
712+ {
713+ .callback = init_old_suspend_ordering,
714+ .ident = "Asus Pundit P1-AH2 (M2N8L motherboard)",
715+ .matches = {
716+ DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTek Computer INC."),
717+ DMI_MATCH(DMI_BOARD_NAME, "M2N8L"),
718+ },
719+ },
720+ {
721+ .callback = init_old_suspend_ordering,
722+ .ident = "Panasonic CF51-2L",
723+ .matches = {
724+ DMI_MATCH(DMI_BOARD_VENDOR,
725+ "Matsushita Electric Industrial Co.,Ltd."),
726+ DMI_MATCH(DMI_BOARD_NAME, "CF51-2L"),
727+ },
728+ },
729+ {
730+ .callback = init_nvs_nosave,
731+ .ident = "Sony Vaio VGN-FW21E",
732+ .matches = {
733+ DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
734+ DMI_MATCH(DMI_PRODUCT_NAME, "VGN-FW21E"),
735+ },
736+ },
737+ {
738+ .callback = init_nvs_nosave,
739+ .ident = "Sony Vaio VPCEB17FX",
740+ .matches = {
741+ DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
742+ DMI_MATCH(DMI_PRODUCT_NAME, "VPCEB17FX"),
743+ },
744+ },
745+ {
746+ .callback = init_nvs_nosave,
747+ .ident = "Sony Vaio VGN-SR11M",
748+ .matches = {
749+ DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
750+ DMI_MATCH(DMI_PRODUCT_NAME, "VGN-SR11M"),
751+ },
752+ },
753+ {
754+ .callback = init_nvs_nosave,
755+ .ident = "Everex StepNote Series",
756+ .matches = {
757+ DMI_MATCH(DMI_SYS_VENDOR, "Everex Systems, Inc."),
758+ DMI_MATCH(DMI_PRODUCT_NAME, "Everex StepNote Series"),
759+ },
760+ },
761+ {
762+ .callback = init_nvs_nosave,
763+ .ident = "Sony Vaio VPCEB1Z1E",
764+ .matches = {
765+ DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
766+ DMI_MATCH(DMI_PRODUCT_NAME, "VPCEB1Z1E"),
767+ },
768+ },
769+ {
770+ .callback = init_nvs_nosave,
771+ .ident = "Sony Vaio VGN-NW130D",
772+ .matches = {
773+ DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
774+ DMI_MATCH(DMI_PRODUCT_NAME, "VGN-NW130D"),
775+ },
776+ },
777+ {
778+ .callback = init_nvs_nosave,
779+ .ident = "Sony Vaio VPCCW29FX",
780+ .matches = {
781+ DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
782+ DMI_MATCH(DMI_PRODUCT_NAME, "VPCCW29FX"),
783+ },
784+ },
785+ {
786+ .callback = init_nvs_nosave,
787+ .ident = "Averatec AV1020-ED2",
788+ .matches = {
789+ DMI_MATCH(DMI_SYS_VENDOR, "AVERATEC"),
790+ DMI_MATCH(DMI_PRODUCT_NAME, "1000 Series"),
791+ },
792+ },
793+ {
794+ .callback = init_old_suspend_ordering,
795+ .ident = "Asus A8N-SLI DELUXE",
796+ .matches = {
797+ DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
798+ DMI_MATCH(DMI_BOARD_NAME, "A8N-SLI DELUXE"),
799+ },
800+ },
801+ {
802+ .callback = init_old_suspend_ordering,
803+ .ident = "Asus A8N-SLI Premium",
804+ .matches = {
805+ DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
806+ DMI_MATCH(DMI_BOARD_NAME, "A8N-SLI Premium"),
807+ },
808+ },
809+ {
810+ .callback = init_nvs_nosave,
811+ .ident = "Sony Vaio VGN-SR26GN_P",
812+ .matches = {
813+ DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
814+ DMI_MATCH(DMI_PRODUCT_NAME, "VGN-SR26GN_P"),
815+ },
816+ },
817+ {
818+ .callback = init_nvs_nosave,
819+ .ident = "Sony Vaio VPCEB1S1E",
820+ .matches = {
821+ DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
822+ DMI_MATCH(DMI_PRODUCT_NAME, "VPCEB1S1E"),
823+ },
824+ },
825+ {
826+ .callback = init_nvs_nosave,
827+ .ident = "Sony Vaio VGN-FW520F",
828+ .matches = {
829+ DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
830+ DMI_MATCH(DMI_PRODUCT_NAME, "VGN-FW520F"),
831+ },
832+ },
833+ {
834+ .callback = init_nvs_nosave,
835+ .ident = "Asus K54C",
836+ .matches = {
837+ DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer Inc."),
838+ DMI_MATCH(DMI_PRODUCT_NAME, "K54C"),
839+ },
840+ },
841+ {
842+ .callback = init_nvs_nosave,
843+ .ident = "Asus K54HR",
844+ .matches = {
845+ DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer Inc."),
846+ DMI_MATCH(DMI_PRODUCT_NAME, "K54HR"),
847+ },
848+ },
849+ {},
850+};
851+
852+static void acpi_sleep_dmi_check(void)
853+{
854+ dmi_check_system(acpisleep_dmi_table);
855+}
856+
857 /**
858 * acpi_pm_freeze - Disable the GPEs and suspend EC transactions.
859 */
860@@ -224,6 +398,7 @@ static void acpi_pm_end(void)
861 }
862 #else /* !CONFIG_ACPI_SLEEP */
863 #define acpi_target_sleep_state ACPI_STATE_S0
864+static inline void acpi_sleep_dmi_check(void) {}
865 #endif /* CONFIG_ACPI_SLEEP */
866
867 #ifdef CONFIG_SUSPEND
868@@ -382,175 +557,6 @@ static const struct platform_suspend_ops acpi_suspend_ops_old = {
869 .end = acpi_pm_end,
870 .recover = acpi_pm_finish,
871 };
872-
873-static int __init init_old_suspend_ordering(const struct dmi_system_id *d)
874-{
875- old_suspend_ordering = true;
876- return 0;
877-}
878-
879-static int __init init_nvs_nosave(const struct dmi_system_id *d)
880-{
881- acpi_nvs_nosave();
882- return 0;
883-}
884-
885-static struct dmi_system_id __initdata acpisleep_dmi_table[] = {
886- {
887- .callback = init_old_suspend_ordering,
888- .ident = "Abit KN9 (nForce4 variant)",
889- .matches = {
890- DMI_MATCH(DMI_BOARD_VENDOR, "http://www.abit.com.tw/"),
891- DMI_MATCH(DMI_BOARD_NAME, "KN9 Series(NF-CK804)"),
892- },
893- },
894- {
895- .callback = init_old_suspend_ordering,
896- .ident = "HP xw4600 Workstation",
897- .matches = {
898- DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
899- DMI_MATCH(DMI_PRODUCT_NAME, "HP xw4600 Workstation"),
900- },
901- },
902- {
903- .callback = init_old_suspend_ordering,
904- .ident = "Asus Pundit P1-AH2 (M2N8L motherboard)",
905- .matches = {
906- DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTek Computer INC."),
907- DMI_MATCH(DMI_BOARD_NAME, "M2N8L"),
908- },
909- },
910- {
911- .callback = init_old_suspend_ordering,
912- .ident = "Panasonic CF51-2L",
913- .matches = {
914- DMI_MATCH(DMI_BOARD_VENDOR,
915- "Matsushita Electric Industrial Co.,Ltd."),
916- DMI_MATCH(DMI_BOARD_NAME, "CF51-2L"),
917- },
918- },
919- {
920- .callback = init_nvs_nosave,
921- .ident = "Sony Vaio VGN-FW21E",
922- .matches = {
923- DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
924- DMI_MATCH(DMI_PRODUCT_NAME, "VGN-FW21E"),
925- },
926- },
927- {
928- .callback = init_nvs_nosave,
929- .ident = "Sony Vaio VPCEB17FX",
930- .matches = {
931- DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
932- DMI_MATCH(DMI_PRODUCT_NAME, "VPCEB17FX"),
933- },
934- },
935- {
936- .callback = init_nvs_nosave,
937- .ident = "Sony Vaio VGN-SR11M",
938- .matches = {
939- DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
940- DMI_MATCH(DMI_PRODUCT_NAME, "VGN-SR11M"),
941- },
942- },
943- {
944- .callback = init_nvs_nosave,
945- .ident = "Everex StepNote Series",
946- .matches = {
947- DMI_MATCH(DMI_SYS_VENDOR, "Everex Systems, Inc."),
948- DMI_MATCH(DMI_PRODUCT_NAME, "Everex StepNote Series"),
949- },
950- },
951- {
952- .callback = init_nvs_nosave,
953- .ident = "Sony Vaio VPCEB1Z1E",
954- .matches = {
955- DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
956- DMI_MATCH(DMI_PRODUCT_NAME, "VPCEB1Z1E"),
957- },
958- },
959- {
960- .callback = init_nvs_nosave,
961- .ident = "Sony Vaio VGN-NW130D",
962- .matches = {
963- DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
964- DMI_MATCH(DMI_PRODUCT_NAME, "VGN-NW130D"),
965- },
966- },
967- {
968- .callback = init_nvs_nosave,
969- .ident = "Sony Vaio VPCCW29FX",
970- .matches = {
971- DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
972- DMI_MATCH(DMI_PRODUCT_NAME, "VPCCW29FX"),
973- },
974- },
975- {
976- .callback = init_nvs_nosave,
977- .ident = "Averatec AV1020-ED2",
978- .matches = {
979- DMI_MATCH(DMI_SYS_VENDOR, "AVERATEC"),
980- DMI_MATCH(DMI_PRODUCT_NAME, "1000 Series"),
981- },
982- },
983- {
984- .callback = init_old_suspend_ordering,
985- .ident = "Asus A8N-SLI DELUXE",
986- .matches = {
987- DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
988- DMI_MATCH(DMI_BOARD_NAME, "A8N-SLI DELUXE"),
989- },
990- },
991- {
992- .callback = init_old_suspend_ordering,
993- .ident = "Asus A8N-SLI Premium",
994- .matches = {
995- DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
996- DMI_MATCH(DMI_BOARD_NAME, "A8N-SLI Premium"),
997- },
998- },
999- {
1000- .callback = init_nvs_nosave,
1001- .ident = "Sony Vaio VGN-SR26GN_P",
1002- .matches = {
1003- DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
1004- DMI_MATCH(DMI_PRODUCT_NAME, "VGN-SR26GN_P"),
1005- },
1006- },
1007- {
1008- .callback = init_nvs_nosave,
1009- .ident = "Sony Vaio VPCEB1S1E",
1010- .matches = {
1011- DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
1012- DMI_MATCH(DMI_PRODUCT_NAME, "VPCEB1S1E"),
1013- },
1014- },
1015- {
1016- .callback = init_nvs_nosave,
1017- .ident = "Sony Vaio VGN-FW520F",
1018- .matches = {
1019- DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
1020- DMI_MATCH(DMI_PRODUCT_NAME, "VGN-FW520F"),
1021- },
1022- },
1023- {
1024- .callback = init_nvs_nosave,
1025- .ident = "Asus K54C",
1026- .matches = {
1027- DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer Inc."),
1028- DMI_MATCH(DMI_PRODUCT_NAME, "K54C"),
1029- },
1030- },
1031- {
1032- .callback = init_nvs_nosave,
1033- .ident = "Asus K54HR",
1034- .matches = {
1035- DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer Inc."),
1036- DMI_MATCH(DMI_PRODUCT_NAME, "K54HR"),
1037- },
1038- },
1039- {},
1040-};
1041 #endif /* CONFIG_SUSPEND */
1042
1043 #ifdef CONFIG_HIBERNATION
1044@@ -881,13 +887,13 @@ int __init acpi_sleep_init(void)
1045 u8 type_a, type_b;
1046 #ifdef CONFIG_SUSPEND
1047 int i = 0;
1048-
1049- dmi_check_system(acpisleep_dmi_table);
1050 #endif
1051
1052 if (acpi_disabled)
1053 return 0;
1054
1055+ acpi_sleep_dmi_check();
1056+
1057 sleep_states[ACPI_STATE_S0] = 1;
1058 printk(KERN_INFO PREFIX "(supports S0");
1059
1060diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
1061index 7862d17..4979127 100644
1062--- a/drivers/ata/ahci.c
1063+++ b/drivers/ata/ahci.c
1064@@ -53,6 +53,7 @@
1065
1066 enum {
1067 AHCI_PCI_BAR_STA2X11 = 0,
1068+ AHCI_PCI_BAR_ENMOTUS = 2,
1069 AHCI_PCI_BAR_STANDARD = 5,
1070 };
1071
1072@@ -410,6 +411,9 @@ static const struct pci_device_id ahci_pci_tbl[] = {
1073 { PCI_VDEVICE(ASMEDIA, 0x0611), board_ahci }, /* ASM1061 */
1074 { PCI_VDEVICE(ASMEDIA, 0x0612), board_ahci }, /* ASM1062 */
1075
1076+ /* Enmotus */
1077+ { PCI_DEVICE(0x1c44, 0x8000), board_ahci },
1078+
1079 /* Generic, PCI class code for AHCI */
1080 { PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
1081 PCI_CLASS_STORAGE_SATA_AHCI, 0xffffff, board_ahci },
1082@@ -1098,9 +1102,11 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1083 dev_info(&pdev->dev,
1084 "PDC42819 can only drive SATA devices with this driver\n");
1085
1086- /* The Connext uses non-standard BAR */
1087+ /* Both Connext and Enmotus devices use non-standard BARs */
1088 if (pdev->vendor == PCI_VENDOR_ID_STMICRO && pdev->device == 0xCC06)
1089 ahci_pci_bar = AHCI_PCI_BAR_STA2X11;
1090+ else if (pdev->vendor == 0x1c44 && pdev->device == 0x8000)
1091+ ahci_pci_bar = AHCI_PCI_BAR_ENMOTUS;
1092
1093 /* acquire resources */
1094 rc = pcim_enable_device(pdev);
1095diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
1096index 8e1039c..8789aef 100644
1097--- a/drivers/ata/libata-core.c
1098+++ b/drivers/ata/libata-core.c
1099@@ -2541,6 +2541,7 @@ int ata_bus_probe(struct ata_port *ap)
1100 * bus as we may be talking too fast.
1101 */
1102 dev->pio_mode = XFER_PIO_0;
1103+ dev->dma_mode = 0xff;
1104
1105 /* If the controller has a pio mode setup function
1106 * then use it to set the chipset to rights. Don't
1107diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
1108index 7d4535e..105e31f 100644
1109--- a/drivers/ata/libata-eh.c
1110+++ b/drivers/ata/libata-eh.c
1111@@ -2653,6 +2653,7 @@ int ata_eh_reset(struct ata_link *link, int classify,
1112 * bus as we may be talking too fast.
1113 */
1114 dev->pio_mode = XFER_PIO_0;
1115+ dev->dma_mode = 0xff;
1116
1117 /* If the controller has a pio mode setup function
1118 * then use it to set the chipset to rights. Don't
1119diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
1120index 8ec81ca..9f8b751 100644
1121--- a/drivers/ata/libata-scsi.c
1122+++ b/drivers/ata/libata-scsi.c
1123@@ -309,7 +309,8 @@ ata_scsi_activity_show(struct device *dev, struct device_attribute *attr,
1124 struct ata_port *ap = ata_shost_to_port(sdev->host);
1125 struct ata_device *atadev = ata_scsi_find_dev(ap, sdev);
1126
1127- if (ap->ops->sw_activity_show && (ap->flags & ATA_FLAG_SW_ACTIVITY))
1128+ if (atadev && ap->ops->sw_activity_show &&
1129+ (ap->flags & ATA_FLAG_SW_ACTIVITY))
1130 return ap->ops->sw_activity_show(atadev, buf);
1131 return -EINVAL;
1132 }
1133@@ -324,7 +325,8 @@ ata_scsi_activity_store(struct device *dev, struct device_attribute *attr,
1134 enum sw_activity val;
1135 int rc;
1136
1137- if (ap->ops->sw_activity_store && (ap->flags & ATA_FLAG_SW_ACTIVITY)) {
1138+ if (atadev && ap->ops->sw_activity_store &&
1139+ (ap->flags & ATA_FLAG_SW_ACTIVITY)) {
1140 val = simple_strtoul(buf, NULL, 0);
1141 switch (val) {
1142 case OFF: case BLINK_ON: case BLINK_OFF:
1143diff --git a/drivers/ata/sata_promise.c b/drivers/ata/sata_promise.c
1144index 489c817..fb0dd87 100644
1145--- a/drivers/ata/sata_promise.c
1146+++ b/drivers/ata/sata_promise.c
1147@@ -147,6 +147,10 @@ struct pdc_port_priv {
1148 dma_addr_t pkt_dma;
1149 };
1150
1151+struct pdc_host_priv {
1152+ spinlock_t hard_reset_lock;
1153+};
1154+
1155 static int pdc_sata_scr_read(struct ata_link *link, unsigned int sc_reg, u32 *val);
1156 static int pdc_sata_scr_write(struct ata_link *link, unsigned int sc_reg, u32 val);
1157 static int pdc_ata_init_one(struct pci_dev *pdev, const struct pci_device_id *ent);
1158@@ -801,9 +805,10 @@ static void pdc_hard_reset_port(struct ata_port *ap)
1159 void __iomem *host_mmio = ap->host->iomap[PDC_MMIO_BAR];
1160 void __iomem *pcictl_b1_mmio = host_mmio + PDC_PCI_CTL + 1;
1161 unsigned int ata_no = pdc_ata_port_to_ata_no(ap);
1162+ struct pdc_host_priv *hpriv = ap->host->private_data;
1163 u8 tmp;
1164
1165- spin_lock(&ap->host->lock);
1166+ spin_lock(&hpriv->hard_reset_lock);
1167
1168 tmp = readb(pcictl_b1_mmio);
1169 tmp &= ~(0x10 << ata_no);
1170@@ -814,7 +819,7 @@ static void pdc_hard_reset_port(struct ata_port *ap)
1171 writeb(tmp, pcictl_b1_mmio);
1172 readb(pcictl_b1_mmio); /* flush */
1173
1174- spin_unlock(&ap->host->lock);
1175+ spin_unlock(&hpriv->hard_reset_lock);
1176 }
1177
1178 static int pdc_sata_hardreset(struct ata_link *link, unsigned int *class,
1179@@ -1182,6 +1187,7 @@ static int pdc_ata_init_one(struct pci_dev *pdev,
1180 const struct ata_port_info *pi = &pdc_port_info[ent->driver_data];
1181 const struct ata_port_info *ppi[PDC_MAX_PORTS];
1182 struct ata_host *host;
1183+ struct pdc_host_priv *hpriv;
1184 void __iomem *host_mmio;
1185 int n_ports, i, rc;
1186 int is_sataii_tx4;
1187@@ -1218,6 +1224,11 @@ static int pdc_ata_init_one(struct pci_dev *pdev,
1188 dev_err(&pdev->dev, "failed to allocate host\n");
1189 return -ENOMEM;
1190 }
1191+ hpriv = devm_kzalloc(&pdev->dev, sizeof *hpriv, GFP_KERNEL);
1192+ if (!hpriv)
1193+ return -ENOMEM;
1194+ spin_lock_init(&hpriv->hard_reset_lock);
1195+ host->private_data = hpriv;
1196 host->iomap = pcim_iomap_table(pdev);
1197
1198 is_sataii_tx4 = pdc_is_sataii_tx4(pi->flags);
1199diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
1200index 9851093..1853a45 100644
1201--- a/drivers/atm/solos-pci.c
1202+++ b/drivers/atm/solos-pci.c
1203@@ -967,10 +967,11 @@ static uint32_t fpga_tx(struct solos_card *card)
1204 for (port = 0; tx_pending; tx_pending >>= 1, port++) {
1205 if (tx_pending & 1) {
1206 struct sk_buff *oldskb = card->tx_skb[port];
1207- if (oldskb)
1208+ if (oldskb) {
1209 pci_unmap_single(card->dev, SKB_CB(oldskb)->dma_addr,
1210 oldskb->len, PCI_DMA_TODEVICE);
1211-
1212+ card->tx_skb[port] = NULL;
1213+ }
1214 spin_lock(&card->tx_queue_lock);
1215 skb = skb_dequeue(&card->tx_queue[port]);
1216 if (!skb)
1217diff --git a/drivers/base/regmap/regmap-debugfs.c b/drivers/base/regmap/regmap-debugfs.c
1218index bb1ff17..c394041 100644
1219--- a/drivers/base/regmap/regmap-debugfs.c
1220+++ b/drivers/base/regmap/regmap-debugfs.c
1221@@ -90,7 +90,7 @@ static ssize_t regmap_map_read_file(struct file *file, char __user *user_buf,
1222 /* If we're in the region the user is trying to read */
1223 if (p >= *ppos) {
1224 /* ...but not beyond it */
1225- if (buf_pos >= count - 1 - tot_len)
1226+ if (buf_pos + 1 + tot_len >= count)
1227 break;
1228
1229 /* Format the register */
1230diff --git a/drivers/bcma/driver_mips.c b/drivers/bcma/driver_mips.c
1231index cc65b45..b4e83b8 100644
1232--- a/drivers/bcma/driver_mips.c
1233+++ b/drivers/bcma/driver_mips.c
1234@@ -115,7 +115,7 @@ static void bcma_core_mips_set_irq(struct bcma_device *dev, unsigned int irq)
1235 bcma_read32(mdev, BCMA_MIPS_MIPS74K_INTMASK(0)) &
1236 ~(1 << irqflag));
1237 else
1238- bcma_write32(mdev, BCMA_MIPS_MIPS74K_INTMASK(irq), 0);
1239+ bcma_write32(mdev, BCMA_MIPS_MIPS74K_INTMASK(oldirq), 0);
1240
1241 /* assign the new one */
1242 if (irq == 0) {
1243diff --git a/drivers/block/aoe/aoe.h b/drivers/block/aoe/aoe.h
1244index db195ab..e49ddd0 100644
1245--- a/drivers/block/aoe/aoe.h
1246+++ b/drivers/block/aoe/aoe.h
1247@@ -1,5 +1,5 @@
1248 /* Copyright (c) 2007 Coraid, Inc. See COPYING for GPL terms. */
1249-#define VERSION "47"
1250+#define VERSION "47q"
1251 #define AOE_MAJOR 152
1252 #define DEVICE_NAME "aoe"
1253
1254diff --git a/drivers/block/aoe/aoeblk.c b/drivers/block/aoe/aoeblk.c
1255index 321de7b..7eca463 100644
1256--- a/drivers/block/aoe/aoeblk.c
1257+++ b/drivers/block/aoe/aoeblk.c
1258@@ -276,8 +276,6 @@ aoeblk_gdalloc(void *vp)
1259 goto err_mempool;
1260 blk_queue_make_request(d->blkq, aoeblk_make_request);
1261 d->blkq->backing_dev_info.name = "aoe";
1262- if (bdi_init(&d->blkq->backing_dev_info))
1263- goto err_blkq;
1264 spin_lock_irqsave(&d->lock, flags);
1265 gd->major = AOE_MAJOR;
1266 gd->first_minor = d->sysminor * AOE_PARTITIONS;
1267@@ -298,9 +296,6 @@ aoeblk_gdalloc(void *vp)
1268 aoedisk_add_sysfs(d);
1269 return;
1270
1271-err_blkq:
1272- blk_cleanup_queue(d->blkq);
1273- d->blkq = NULL;
1274 err_mempool:
1275 mempool_destroy(d->bufpool);
1276 err_disk:
1277diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
1278index 54a55f0..7aac910 100644
1279--- a/drivers/block/rbd.c
1280+++ b/drivers/block/rbd.c
1281@@ -69,7 +69,7 @@
1282 #define DEV_NAME_LEN 32
1283 #define MAX_INT_FORMAT_WIDTH ((5 * sizeof (int)) / 2 + 1)
1284
1285-#define RBD_NOTIFY_TIMEOUT_DEFAULT 10
1286+#define RBD_READ_ONLY_DEFAULT false
1287
1288 /*
1289 * block device image metadata (in-memory version)
1290@@ -91,7 +91,7 @@ struct rbd_image_header {
1291 };
1292
1293 struct rbd_options {
1294- int notify_timeout;
1295+ bool read_only;
1296 };
1297
1298 /*
1299@@ -177,7 +177,7 @@ struct rbd_device {
1300 u64 snap_id; /* current snapshot id */
1301 /* whether the snap_id this device reads from still exists */
1302 bool snap_exists;
1303- int read_only;
1304+ bool read_only;
1305
1306 struct list_head node;
1307
1308@@ -186,6 +186,7 @@ struct rbd_device {
1309
1310 /* sysfs related */
1311 struct device dev;
1312+ unsigned long open_count;
1313 };
1314
1315 static DEFINE_MUTEX(ctl_mutex); /* Serialize open/close/setup/teardown */
1316@@ -249,8 +250,11 @@ static int rbd_open(struct block_device *bdev, fmode_t mode)
1317 if ((mode & FMODE_WRITE) && rbd_dev->read_only)
1318 return -EROFS;
1319
1320+ mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING);
1321 rbd_get_dev(rbd_dev);
1322 set_device_ro(bdev, rbd_dev->read_only);
1323+ rbd_dev->open_count++;
1324+ mutex_unlock(&ctl_mutex);
1325
1326 return 0;
1327 }
1328@@ -259,7 +263,11 @@ static int rbd_release(struct gendisk *disk, fmode_t mode)
1329 {
1330 struct rbd_device *rbd_dev = disk->private_data;
1331
1332+ mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING);
1333+ BUG_ON(!rbd_dev->open_count);
1334+ rbd_dev->open_count--;
1335 rbd_put_dev(rbd_dev);
1336+ mutex_unlock(&ctl_mutex);
1337
1338 return 0;
1339 }
1340@@ -341,17 +349,24 @@ static struct rbd_client *__rbd_client_find(struct ceph_options *ceph_opts)
1341 * mount options
1342 */
1343 enum {
1344- Opt_notify_timeout,
1345 Opt_last_int,
1346 /* int args above */
1347 Opt_last_string,
1348 /* string args above */
1349+ Opt_read_only,
1350+ Opt_read_write,
1351+ /* Boolean args above */
1352+ Opt_last_bool,
1353 };
1354
1355 static match_table_t rbd_opts_tokens = {
1356- {Opt_notify_timeout, "notify_timeout=%d"},
1357 /* int args above */
1358 /* string args above */
1359+ {Opt_read_only, "read_only"},
1360+ {Opt_read_only, "ro"}, /* Alternate spelling */
1361+ {Opt_read_write, "read_write"},
1362+ {Opt_read_write, "rw"}, /* Alternate spelling */
1363+ /* Boolean args above */
1364 {-1, NULL}
1365 };
1366
1367@@ -376,13 +391,18 @@ static int parse_rbd_opts_token(char *c, void *private)
1368 } else if (token > Opt_last_int && token < Opt_last_string) {
1369 dout("got string token %d val %s\n", token,
1370 argstr[0].from);
1371+ } else if (token > Opt_last_string && token < Opt_last_bool) {
1372+ dout("got Boolean token %d\n", token);
1373 } else {
1374 dout("got token %d\n", token);
1375 }
1376
1377 switch (token) {
1378- case Opt_notify_timeout:
1379- rbd_opts->notify_timeout = intval;
1380+ case Opt_read_only:
1381+ rbd_opts->read_only = true;
1382+ break;
1383+ case Opt_read_write:
1384+ rbd_opts->read_only = false;
1385 break;
1386 default:
1387 BUG_ON(token);
1388@@ -406,7 +426,7 @@ static struct rbd_client *rbd_get_client(const char *mon_addr,
1389 if (!rbd_opts)
1390 return ERR_PTR(-ENOMEM);
1391
1392- rbd_opts->notify_timeout = RBD_NOTIFY_TIMEOUT_DEFAULT;
1393+ rbd_opts->read_only = RBD_READ_ONLY_DEFAULT;
1394
1395 ceph_opts = ceph_parse_options(options, mon_addr,
1396 mon_addr + mon_addr_len,
1397@@ -606,7 +626,7 @@ static int rbd_header_set_snap(struct rbd_device *rbd_dev, u64 *size)
1398 sizeof (RBD_SNAP_HEAD_NAME))) {
1399 rbd_dev->snap_id = CEPH_NOSNAP;
1400 rbd_dev->snap_exists = false;
1401- rbd_dev->read_only = 0;
1402+ rbd_dev->read_only = rbd_dev->rbd_opts.read_only;
1403 if (size)
1404 *size = rbd_dev->header.image_size;
1405 } else {
1406@@ -618,7 +638,7 @@ static int rbd_header_set_snap(struct rbd_device *rbd_dev, u64 *size)
1407 goto done;
1408 rbd_dev->snap_id = snap_id;
1409 rbd_dev->snap_exists = true;
1410- rbd_dev->read_only = 1;
1411+ rbd_dev->read_only = true; /* No choice for snapshots */
1412 }
1413
1414 ret = 0;
1415@@ -938,8 +958,9 @@ static int rbd_do_request(struct request *rq,
1416 layout->fl_stripe_count = cpu_to_le32(1);
1417 layout->fl_object_size = cpu_to_le32(1 << RBD_MAX_OBJ_ORDER);
1418 layout->fl_pg_pool = cpu_to_le32(rbd_dev->pool_id);
1419- ceph_calc_raw_layout(osdc, layout, snapid, ofs, &len, &bno,
1420- req, ops);
1421+ ret = ceph_calc_raw_layout(osdc, layout, snapid, ofs, &len, &bno,
1422+ req, ops);
1423+ rbd_assert(ret == 0);
1424
1425 ceph_osdc_build_request(req, ofs, &len,
1426 ops,
1427@@ -2260,8 +2281,8 @@ static void rbd_id_put(struct rbd_device *rbd_dev)
1428 struct rbd_device *rbd_dev;
1429
1430 rbd_dev = list_entry(tmp, struct rbd_device, node);
1431- if (rbd_id > max_id)
1432- max_id = rbd_id;
1433+ if (rbd_dev->id > max_id)
1434+ max_id = rbd_dev->id;
1435 }
1436 spin_unlock(&rbd_dev_list_lock);
1437
1438@@ -2623,6 +2644,11 @@ static ssize_t rbd_remove(struct bus_type *bus,
1439 goto done;
1440 }
1441
1442+ if (rbd_dev->open_count) {
1443+ ret = -EBUSY;
1444+ goto done;
1445+ }
1446+
1447 __rbd_remove_all_snaps(rbd_dev);
1448 rbd_bus_del_dev(rbd_dev);
1449
1450diff --git a/drivers/bluetooth/ath3k.c b/drivers/bluetooth/ath3k.c
1451index fc2de55..b00000e 100644
1452--- a/drivers/bluetooth/ath3k.c
1453+++ b/drivers/bluetooth/ath3k.c
1454@@ -67,6 +67,7 @@ static struct usb_device_id ath3k_table[] = {
1455 { USB_DEVICE(0x13d3, 0x3304) },
1456 { USB_DEVICE(0x0930, 0x0215) },
1457 { USB_DEVICE(0x0489, 0xE03D) },
1458+ { USB_DEVICE(0x0489, 0xE027) },
1459
1460 /* Atheros AR9285 Malbec with sflash firmware */
1461 { USB_DEVICE(0x03F0, 0x311D) },
1462diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
1463index 654e248..e023c65 100644
1464--- a/drivers/bluetooth/btusb.c
1465+++ b/drivers/bluetooth/btusb.c
1466@@ -123,6 +123,7 @@ static struct usb_device_id blacklist_table[] = {
1467 { USB_DEVICE(0x13d3, 0x3304), .driver_info = BTUSB_IGNORE },
1468 { USB_DEVICE(0x0930, 0x0215), .driver_info = BTUSB_IGNORE },
1469 { USB_DEVICE(0x0489, 0xe03d), .driver_info = BTUSB_IGNORE },
1470+ { USB_DEVICE(0x0489, 0xe027), .driver_info = BTUSB_IGNORE },
1471
1472 /* Atheros AR9285 Malbec with sflash firmware */
1473 { USB_DEVICE(0x03f0, 0x311d), .driver_info = BTUSB_IGNORE },
1474diff --git a/drivers/dma/ioat/dma_v3.c b/drivers/dma/ioat/dma_v3.c
1475index f7f1dc6..ed0e8b7 100644
1476--- a/drivers/dma/ioat/dma_v3.c
1477+++ b/drivers/dma/ioat/dma_v3.c
1478@@ -951,7 +951,7 @@ static int __devinit ioat_xor_val_self_test(struct ioatdma_device *device)
1479 goto free_resources;
1480 }
1481 }
1482- dma_sync_single_for_device(dev, dest_dma, PAGE_SIZE, DMA_TO_DEVICE);
1483+ dma_sync_single_for_device(dev, dest_dma, PAGE_SIZE, DMA_FROM_DEVICE);
1484
1485 /* skip validate if the capability is not present */
1486 if (!dma_has_cap(DMA_XOR_VAL, dma_chan->device->cap_mask))
1487diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
1488index e164c55..1bfb207 100644
1489--- a/drivers/edac/edac_pci_sysfs.c
1490+++ b/drivers/edac/edac_pci_sysfs.c
1491@@ -256,7 +256,7 @@ static ssize_t edac_pci_dev_store(struct kobject *kobj,
1492 struct edac_pci_dev_attribute *edac_pci_dev;
1493 edac_pci_dev = (struct edac_pci_dev_attribute *)attr;
1494
1495- if (edac_pci_dev->show)
1496+ if (edac_pci_dev->store)
1497 return edac_pci_dev->store(edac_pci_dev->value, buffer, count);
1498 return -EIO;
1499 }
1500diff --git a/drivers/firewire/net.c b/drivers/firewire/net.c
1501index 08c6749..638e1f7 100644
1502--- a/drivers/firewire/net.c
1503+++ b/drivers/firewire/net.c
1504@@ -861,8 +861,8 @@ static void fwnet_receive_broadcast(struct fw_iso_context *context,
1505 if (specifier_id == IANA_SPECIFIER_ID && ver == RFC2734_SW_VERSION) {
1506 buf_ptr += 2;
1507 length -= IEEE1394_GASP_HDR_SIZE;
1508- fwnet_incoming_packet(dev, buf_ptr, length,
1509- source_node_id, -1, true);
1510+ fwnet_incoming_packet(dev, buf_ptr, length, source_node_id,
1511+ context->card->generation, true);
1512 }
1513
1514 packet.payload_length = dev->rcv_buffer_size;
1515@@ -958,7 +958,12 @@ static void fwnet_transmit_packet_done(struct fwnet_packet_task *ptask)
1516 break;
1517 }
1518
1519- skb_pull(skb, ptask->max_payload);
1520+ if (ptask->dest_node == IEEE1394_ALL_NODES) {
1521+ skb_pull(skb,
1522+ ptask->max_payload + IEEE1394_GASP_HDR_SIZE);
1523+ } else {
1524+ skb_pull(skb, ptask->max_payload);
1525+ }
1526 if (ptask->outstanding_pkts > 1) {
1527 fwnet_make_sf_hdr(&ptask->hdr, RFC2374_HDR_INTFRAG,
1528 dg_size, fg_off, datagram_label);
1529@@ -1062,7 +1067,7 @@ static int fwnet_send_packet(struct fwnet_packet_task *ptask)
1530 smp_rmb();
1531 node_id = dev->card->node_id;
1532
1533- p = skb_push(ptask->skb, 8);
1534+ p = skb_push(ptask->skb, IEEE1394_GASP_HDR_SIZE);
1535 put_unaligned_be32(node_id << 16 | IANA_SPECIFIER_ID >> 8, p);
1536 put_unaligned_be32((IANA_SPECIFIER_ID & 0xff) << 24
1537 | RFC2734_SW_VERSION, &p[4]);
1538diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
1539index b298158..fd3ae62 100644
1540--- a/drivers/firmware/dmi_scan.c
1541+++ b/drivers/firmware/dmi_scan.c
1542@@ -16,6 +16,7 @@
1543 */
1544 static char dmi_empty_string[] = " ";
1545
1546+static u16 __initdata dmi_ver;
1547 /*
1548 * Catch too early calls to dmi_check_system():
1549 */
1550@@ -118,12 +119,12 @@ static int __init dmi_walk_early(void (*decode)(const struct dmi_header *,
1551 return 0;
1552 }
1553
1554-static int __init dmi_checksum(const u8 *buf)
1555+static int __init dmi_checksum(const u8 *buf, u8 len)
1556 {
1557 u8 sum = 0;
1558 int a;
1559
1560- for (a = 0; a < 15; a++)
1561+ for (a = 0; a < len; a++)
1562 sum += buf[a];
1563
1564 return sum == 0;
1565@@ -161,8 +162,10 @@ static void __init dmi_save_uuid(const struct dmi_header *dm, int slot, int inde
1566 return;
1567
1568 for (i = 0; i < 16 && (is_ff || is_00); i++) {
1569- if(d[i] != 0x00) is_ff = 0;
1570- if(d[i] != 0xFF) is_00 = 0;
1571+ if (d[i] != 0x00)
1572+ is_00 = 0;
1573+ if (d[i] != 0xFF)
1574+ is_ff = 0;
1575 }
1576
1577 if (is_ff || is_00)
1578@@ -172,7 +175,15 @@ static void __init dmi_save_uuid(const struct dmi_header *dm, int slot, int inde
1579 if (!s)
1580 return;
1581
1582- sprintf(s, "%pUB", d);
1583+ /*
1584+ * As of version 2.6 of the SMBIOS specification, the first 3 fields of
1585+ * the UUID are supposed to be little-endian encoded. The specification
1586+ * says that this is the defacto standard.
1587+ */
1588+ if (dmi_ver >= 0x0206)
1589+ sprintf(s, "%pUL", d);
1590+ else
1591+ sprintf(s, "%pUB", d);
1592
1593 dmi_ident[slot] = s;
1594 }
1595@@ -404,29 +415,57 @@ static int __init dmi_present(const char __iomem *p)
1596 u8 buf[15];
1597
1598 memcpy_fromio(buf, p, 15);
1599- if ((memcmp(buf, "_DMI_", 5) == 0) && dmi_checksum(buf)) {
1600+ if (dmi_checksum(buf, 15)) {
1601 dmi_num = (buf[13] << 8) | buf[12];
1602 dmi_len = (buf[7] << 8) | buf[6];
1603 dmi_base = (buf[11] << 24) | (buf[10] << 16) |
1604 (buf[9] << 8) | buf[8];
1605
1606- /*
1607- * DMI version 0.0 means that the real version is taken from
1608- * the SMBIOS version, which we don't know at this point.
1609- */
1610- if (buf[14] != 0)
1611- printk(KERN_INFO "DMI %d.%d present.\n",
1612- buf[14] >> 4, buf[14] & 0xF);
1613- else
1614- printk(KERN_INFO "DMI present.\n");
1615 if (dmi_walk_early(dmi_decode) == 0) {
1616+ if (dmi_ver)
1617+ pr_info("SMBIOS %d.%d present.\n",
1618+ dmi_ver >> 8, dmi_ver & 0xFF);
1619+ else {
1620+ dmi_ver = (buf[14] & 0xF0) << 4 |
1621+ (buf[14] & 0x0F);
1622+ pr_info("Legacy DMI %d.%d present.\n",
1623+ dmi_ver >> 8, dmi_ver & 0xFF);
1624+ }
1625 dmi_dump_ids();
1626 return 0;
1627 }
1628 }
1629+ dmi_ver = 0;
1630 return 1;
1631 }
1632
1633+static int __init smbios_present(const char __iomem *p)
1634+{
1635+ u8 buf[32];
1636+ int offset = 0;
1637+
1638+ memcpy_fromio(buf, p, 32);
1639+ if ((buf[5] < 32) && dmi_checksum(buf, buf[5])) {
1640+ dmi_ver = (buf[6] << 8) + buf[7];
1641+
1642+ /* Some BIOS report weird SMBIOS version, fix that up */
1643+ switch (dmi_ver) {
1644+ case 0x021F:
1645+ case 0x0221:
1646+ pr_debug("SMBIOS version fixup(2.%d->2.%d)\n",
1647+ dmi_ver & 0xFF, 3);
1648+ dmi_ver = 0x0203;
1649+ break;
1650+ case 0x0233:
1651+ pr_debug("SMBIOS version fixup(2.%d->2.%d)\n", 51, 6);
1652+ dmi_ver = 0x0206;
1653+ break;
1654+ }
1655+ offset = 16;
1656+ }
1657+ return dmi_present(buf + offset);
1658+}
1659+
1660 void __init dmi_scan_machine(void)
1661 {
1662 char __iomem *p, *q;
1663@@ -444,7 +483,7 @@ void __init dmi_scan_machine(void)
1664 if (p == NULL)
1665 goto error;
1666
1667- rc = dmi_present(p + 0x10); /* offset of _DMI_ string */
1668+ rc = smbios_present(p);
1669 dmi_iounmap(p, 32);
1670 if (!rc) {
1671 dmi_available = 1;
1672@@ -462,7 +501,12 @@ void __init dmi_scan_machine(void)
1673 goto error;
1674
1675 for (q = p; q < p + 0x10000; q += 16) {
1676- rc = dmi_present(q);
1677+ if (memcmp(q, "_SM_", 4) == 0 && q - p <= 0xFFE0)
1678+ rc = smbios_present(q);
1679+ else if (memcmp(q, "_DMI_", 5) == 0)
1680+ rc = dmi_present(q);
1681+ else
1682+ continue;
1683 if (!rc) {
1684 dmi_available = 1;
1685 dmi_iounmap(p, 0x10000);
1686diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
1687index cdf46b5..d8bb392 100644
1688--- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
1689+++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
1690@@ -749,6 +749,8 @@ i915_gem_execbuffer_relocate_slow(struct drm_device *dev,
1691 total = 0;
1692 for (i = 0; i < count; i++) {
1693 struct drm_i915_gem_relocation_entry __user *user_relocs;
1694+ u64 invalid_offset = (u64)-1;
1695+ int j;
1696
1697 user_relocs = (void __user *)(uintptr_t)exec[i].relocs_ptr;
1698
1699@@ -759,6 +761,25 @@ i915_gem_execbuffer_relocate_slow(struct drm_device *dev,
1700 goto err;
1701 }
1702
1703+ /* As we do not update the known relocation offsets after
1704+ * relocating (due to the complexities in lock handling),
1705+ * we need to mark them as invalid now so that we force the
1706+ * relocation processing next time. Just in case the target
1707+ * object is evicted and then rebound into its old
1708+ * presumed_offset before the next execbuffer - if that
1709+ * happened we would make the mistake of assuming that the
1710+ * relocations were valid.
1711+ */
1712+ for (j = 0; j < exec[i].relocation_count; j++) {
1713+ if (copy_to_user(&user_relocs[j].presumed_offset,
1714+ &invalid_offset,
1715+ sizeof(invalid_offset))) {
1716+ ret = -EFAULT;
1717+ mutex_lock(&dev->struct_mutex);
1718+ goto err;
1719+ }
1720+ }
1721+
1722 reloc_offset[i] = total;
1723 total += exec[i].relocation_count;
1724 }
1725diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
1726index f02cfad..380e7da 100644
1727--- a/drivers/gpu/drm/i915/i915_reg.h
1728+++ b/drivers/gpu/drm/i915/i915_reg.h
1729@@ -506,6 +506,7 @@
1730 * the enables for writing to the corresponding low bit.
1731 */
1732 #define _3D_CHICKEN 0x02084
1733+#define _3D_CHICKEN_HIZ_PLANE_DISABLE_MSAA_4X_SNB (1 << 10)
1734 #define _3D_CHICKEN2 0x0208c
1735 /* Disables pipelining of read flushes past the SF-WIZ interface.
1736 * Required on all Ironlake steppings according to the B-Spec, but the
1737@@ -3274,6 +3275,8 @@
1738 #define _PFA_CTL_1 0x68080
1739 #define _PFB_CTL_1 0x68880
1740 #define PF_ENABLE (1<<31)
1741+#define PF_PIPE_SEL_MASK_IVB (3<<29)
1742+#define PF_PIPE_SEL_IVB(pipe) ((pipe)<<29)
1743 #define PF_FILTER_MASK (3<<23)
1744 #define PF_FILTER_PROGRAMMED (0<<23)
1745 #define PF_FILTER_MED_3x3 (1<<23)
1746diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
1747index 0777c79..81e013f 100644
1748--- a/drivers/gpu/drm/i915/intel_display.c
1749+++ b/drivers/gpu/drm/i915/intel_display.c
1750@@ -2347,18 +2347,6 @@ static void intel_fdi_normal_train(struct drm_crtc *crtc)
1751 FDI_FE_ERRC_ENABLE);
1752 }
1753
1754-static void cpt_phase_pointer_enable(struct drm_device *dev, int pipe)
1755-{
1756- struct drm_i915_private *dev_priv = dev->dev_private;
1757- u32 flags = I915_READ(SOUTH_CHICKEN1);
1758-
1759- flags |= FDI_PHASE_SYNC_OVR(pipe);
1760- I915_WRITE(SOUTH_CHICKEN1, flags); /* once to unlock... */
1761- flags |= FDI_PHASE_SYNC_EN(pipe);
1762- I915_WRITE(SOUTH_CHICKEN1, flags); /* then again to enable */
1763- POSTING_READ(SOUTH_CHICKEN1);
1764-}
1765-
1766 /* The FDI link training functions for ILK/Ibexpeak. */
1767 static void ironlake_fdi_link_train(struct drm_crtc *crtc)
1768 {
1769@@ -2509,9 +2497,6 @@ static void gen6_fdi_link_train(struct drm_crtc *crtc)
1770 POSTING_READ(reg);
1771 udelay(150);
1772
1773- if (HAS_PCH_CPT(dev))
1774- cpt_phase_pointer_enable(dev, pipe);
1775-
1776 for (i = 0; i < 4; i++) {
1777 reg = FDI_TX_CTL(pipe);
1778 temp = I915_READ(reg);
1779@@ -2638,9 +2623,6 @@ static void ivb_manual_fdi_link_train(struct drm_crtc *crtc)
1780 POSTING_READ(reg);
1781 udelay(150);
1782
1783- if (HAS_PCH_CPT(dev))
1784- cpt_phase_pointer_enable(dev, pipe);
1785-
1786 for (i = 0; i < 4; i++) {
1787 reg = FDI_TX_CTL(pipe);
1788 temp = I915_READ(reg);
1789@@ -2754,17 +2736,6 @@ static void ironlake_fdi_pll_enable(struct drm_crtc *crtc)
1790 }
1791 }
1792
1793-static void cpt_phase_pointer_disable(struct drm_device *dev, int pipe)
1794-{
1795- struct drm_i915_private *dev_priv = dev->dev_private;
1796- u32 flags = I915_READ(SOUTH_CHICKEN1);
1797-
1798- flags &= ~(FDI_PHASE_SYNC_EN(pipe));
1799- I915_WRITE(SOUTH_CHICKEN1, flags); /* once to disable... */
1800- flags &= ~(FDI_PHASE_SYNC_OVR(pipe));
1801- I915_WRITE(SOUTH_CHICKEN1, flags); /* then again to lock */
1802- POSTING_READ(SOUTH_CHICKEN1);
1803-}
1804 static void ironlake_fdi_disable(struct drm_crtc *crtc)
1805 {
1806 struct drm_device *dev = crtc->dev;
1807@@ -2794,8 +2765,6 @@ static void ironlake_fdi_disable(struct drm_crtc *crtc)
1808 I915_WRITE(FDI_RX_CHICKEN(pipe),
1809 I915_READ(FDI_RX_CHICKEN(pipe) &
1810 ~FDI_RX_PHASE_SYNC_POINTER_EN));
1811- } else if (HAS_PCH_CPT(dev)) {
1812- cpt_phase_pointer_disable(dev, pipe);
1813 }
1814
1815 /* still set train pattern 1 */
1816@@ -3233,7 +3202,11 @@ static void ironlake_crtc_enable(struct drm_crtc *crtc)
1817 * as some pre-programmed values are broken,
1818 * e.g. x201.
1819 */
1820- I915_WRITE(PF_CTL(pipe), PF_ENABLE | PF_FILTER_MED_3x3);
1821+ if (IS_IVYBRIDGE(dev))
1822+ I915_WRITE(PF_CTL(pipe), PF_ENABLE | PF_FILTER_MED_3x3 |
1823+ PF_PIPE_SEL_IVB(pipe));
1824+ else
1825+ I915_WRITE(PF_CTL(pipe), PF_ENABLE | PF_FILTER_MED_3x3);
1826 I915_WRITE(PF_WIN_POS(pipe), dev_priv->pch_pf_pos);
1827 I915_WRITE(PF_WIN_SZ(pipe), dev_priv->pch_pf_size);
1828 }
1829diff --git a/drivers/gpu/drm/i915/intel_lvds.c b/drivers/gpu/drm/i915/intel_lvds.c
1830index 0c52448..2e6448c 100644
1831--- a/drivers/gpu/drm/i915/intel_lvds.c
1832+++ b/drivers/gpu/drm/i915/intel_lvds.c
1833@@ -774,14 +774,6 @@ static const struct dmi_system_id intel_no_lvds[] = {
1834 },
1835 {
1836 .callback = intel_no_lvds_dmi_callback,
1837- .ident = "ZOTAC ZBOXSD-ID12/ID13",
1838- .matches = {
1839- DMI_MATCH(DMI_BOARD_VENDOR, "ZOTAC"),
1840- DMI_MATCH(DMI_BOARD_NAME, "ZBOXSD-ID12/ID13"),
1841- },
1842- },
1843- {
1844- .callback = intel_no_lvds_dmi_callback,
1845 .ident = "Gigabyte GA-D525TUD",
1846 .matches = {
1847 DMI_MATCH(DMI_BOARD_VENDOR, "Gigabyte Technology Co., Ltd."),
1848diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
1849index c23c9ea..572b2ca 100644
1850--- a/drivers/gpu/drm/i915/intel_pm.c
1851+++ b/drivers/gpu/drm/i915/intel_pm.c
1852@@ -3324,6 +3324,10 @@ static void gen6_init_clock_gating(struct drm_device *dev)
1853 I915_READ(ILK_DISPLAY_CHICKEN2) |
1854 ILK_ELPIN_409_SELECT);
1855
1856+ /* WaDisableHiZPlanesWhenMSAAEnabled */
1857+ I915_WRITE(_3D_CHICKEN,
1858+ _MASKED_BIT_ENABLE(_3D_CHICKEN_HIZ_PLANE_DISABLE_MSAA_4X_SNB));
1859+
1860 I915_WRITE(WM3_LP_ILK, 0);
1861 I915_WRITE(WM2_LP_ILK, 0);
1862 I915_WRITE(WM1_LP_ILK, 0);
1863diff --git a/drivers/gpu/drm/nouveau/nv04_dfp.c b/drivers/gpu/drm/nouveau/nv04_dfp.c
1864index 89640f2..2b59f41 100644
1865--- a/drivers/gpu/drm/nouveau/nv04_dfp.c
1866+++ b/drivers/gpu/drm/nouveau/nv04_dfp.c
1867@@ -504,7 +504,7 @@ static void nv04_dfp_update_backlight(struct drm_encoder *encoder, int mode)
1868
1869 static inline bool is_powersaving_dpms(int mode)
1870 {
1871- return (mode != DRM_MODE_DPMS_ON);
1872+ return mode != DRM_MODE_DPMS_ON && mode != NV_DPMS_CLEARED;
1873 }
1874
1875 static void nv04_lvds_dpms(struct drm_encoder *encoder, int mode)
1876diff --git a/drivers/gpu/drm/radeon/atombios_encoders.c b/drivers/gpu/drm/radeon/atombios_encoders.c
1877index 2eb418e..e53a91b 100644
1878--- a/drivers/gpu/drm/radeon/atombios_encoders.c
1879+++ b/drivers/gpu/drm/radeon/atombios_encoders.c
1880@@ -95,7 +95,7 @@ static bool radeon_atom_mode_fixup(struct drm_encoder *encoder,
1881 ((radeon_encoder->active_device & (ATOM_DEVICE_DFP_SUPPORT | ATOM_DEVICE_LCD_SUPPORT)) ||
1882 (radeon_encoder_get_dp_bridge_encoder_id(encoder) != ENCODER_OBJECT_ID_NONE))) {
1883 struct drm_connector *connector = radeon_get_connector_for_encoder(encoder);
1884- radeon_dp_set_link_config(connector, mode);
1885+ radeon_dp_set_link_config(connector, adjusted_mode);
1886 }
1887
1888 return true;
1889diff --git a/drivers/gpu/drm/radeon/evergreen_cs.c b/drivers/gpu/drm/radeon/evergreen_cs.c
1890index 4a33cdc..bf849ea 100644
1891--- a/drivers/gpu/drm/radeon/evergreen_cs.c
1892+++ b/drivers/gpu/drm/radeon/evergreen_cs.c
1893@@ -2724,6 +2724,7 @@ static bool evergreen_vm_reg_valid(u32 reg)
1894
1895 /* check config regs */
1896 switch (reg) {
1897+ case WAIT_UNTIL:
1898 case GRBM_GFX_INDEX:
1899 case CP_STRMOUT_CNTL:
1900 case CP_COHER_CNTL:
1901diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c b/drivers/gpu/drm/radeon/radeon_connectors.c
1902index 895e628..a7e797c 100644
1903--- a/drivers/gpu/drm/radeon/radeon_connectors.c
1904+++ b/drivers/gpu/drm/radeon/radeon_connectors.c
1905@@ -745,7 +745,7 @@ radeon_vga_detect(struct drm_connector *connector, bool force)
1906 ret = connector_status_disconnected;
1907
1908 if (radeon_connector->ddc_bus)
1909- dret = radeon_ddc_probe(radeon_connector);
1910+ dret = radeon_ddc_probe(radeon_connector, false);
1911 if (dret) {
1912 radeon_connector->detected_by_load = false;
1913 if (radeon_connector->edid) {
1914@@ -951,7 +951,7 @@ radeon_dvi_detect(struct drm_connector *connector, bool force)
1915 return connector->status;
1916
1917 if (radeon_connector->ddc_bus)
1918- dret = radeon_ddc_probe(radeon_connector);
1919+ dret = radeon_ddc_probe(radeon_connector, false);
1920 if (dret) {
1921 radeon_connector->detected_by_load = false;
1922 if (radeon_connector->edid) {
1923@@ -1391,7 +1391,8 @@ radeon_dp_detect(struct drm_connector *connector, bool force)
1924 if (encoder) {
1925 /* setup ddc on the bridge */
1926 radeon_atom_ext_encoder_setup_ddc(encoder);
1927- if (radeon_ddc_probe(radeon_connector)) /* try DDC */
1928+ /* bridge chips are always aux */
1929+ if (radeon_ddc_probe(radeon_connector, true)) /* try DDC */
1930 ret = connector_status_connected;
1931 else if (radeon_connector->dac_load_detect) { /* try load detection */
1932 struct drm_encoder_helper_funcs *encoder_funcs = encoder->helper_private;
1933@@ -1409,7 +1410,8 @@ radeon_dp_detect(struct drm_connector *connector, bool force)
1934 if (radeon_dp_getdpcd(radeon_connector))
1935 ret = connector_status_connected;
1936 } else {
1937- if (radeon_ddc_probe(radeon_connector))
1938+ /* try non-aux ddc (DP to DVI/HMDI/etc. adapter) */
1939+ if (radeon_ddc_probe(radeon_connector, false))
1940 ret = connector_status_connected;
1941 }
1942 }
1943diff --git a/drivers/gpu/drm/radeon/radeon_cursor.c b/drivers/gpu/drm/radeon/radeon_cursor.c
1944index 8794744..f1b951d 100644
1945--- a/drivers/gpu/drm/radeon/radeon_cursor.c
1946+++ b/drivers/gpu/drm/radeon/radeon_cursor.c
1947@@ -240,7 +240,8 @@ int radeon_crtc_cursor_move(struct drm_crtc *crtc,
1948 y = 0;
1949 }
1950
1951- if (ASIC_IS_AVIVO(rdev)) {
1952+ /* fixed on DCE6 and newer */
1953+ if (ASIC_IS_AVIVO(rdev) && !ASIC_IS_DCE6(rdev)) {
1954 int i = 0;
1955 struct drm_crtc *crtc_p;
1956
1957diff --git a/drivers/gpu/drm/radeon/radeon_display.c b/drivers/gpu/drm/radeon/radeon_display.c
1958index 7ddef8f..9bd2569 100644
1959--- a/drivers/gpu/drm/radeon/radeon_display.c
1960+++ b/drivers/gpu/drm/radeon/radeon_display.c
1961@@ -695,10 +695,15 @@ int radeon_ddc_get_modes(struct radeon_connector *radeon_connector)
1962 if (radeon_connector->router.ddc_valid)
1963 radeon_router_select_ddc_port(radeon_connector);
1964
1965- if ((radeon_connector->base.connector_type == DRM_MODE_CONNECTOR_DisplayPort) ||
1966- (radeon_connector->base.connector_type == DRM_MODE_CONNECTOR_eDP) ||
1967- (radeon_connector_encoder_get_dp_bridge_encoder_id(&radeon_connector->base) !=
1968- ENCODER_OBJECT_ID_NONE)) {
1969+ if (radeon_connector_encoder_get_dp_bridge_encoder_id(&radeon_connector->base) !=
1970+ ENCODER_OBJECT_ID_NONE) {
1971+ struct radeon_connector_atom_dig *dig = radeon_connector->con_priv;
1972+
1973+ if (dig->dp_i2c_bus)
1974+ radeon_connector->edid = drm_get_edid(&radeon_connector->base,
1975+ &dig->dp_i2c_bus->adapter);
1976+ } else if ((radeon_connector->base.connector_type == DRM_MODE_CONNECTOR_DisplayPort) ||
1977+ (radeon_connector->base.connector_type == DRM_MODE_CONNECTOR_eDP)) {
1978 struct radeon_connector_atom_dig *dig = radeon_connector->con_priv;
1979
1980 if ((dig->dp_sink_type == CONNECTOR_OBJECT_ID_DISPLAYPORT ||
1981@@ -1113,7 +1118,7 @@ radeon_user_framebuffer_create(struct drm_device *dev,
1982 if (ret) {
1983 kfree(radeon_fb);
1984 drm_gem_object_unreference_unlocked(obj);
1985- return NULL;
1986+ return ERR_PTR(ret);
1987 }
1988
1989 return &radeon_fb->base;
1990diff --git a/drivers/gpu/drm/radeon/radeon_i2c.c b/drivers/gpu/drm/radeon/radeon_i2c.c
1991index 3edec1c..6076e85 100644
1992--- a/drivers/gpu/drm/radeon/radeon_i2c.c
1993+++ b/drivers/gpu/drm/radeon/radeon_i2c.c
1994@@ -39,7 +39,7 @@ extern u32 radeon_atom_hw_i2c_func(struct i2c_adapter *adap);
1995 * radeon_ddc_probe
1996 *
1997 */
1998-bool radeon_ddc_probe(struct radeon_connector *radeon_connector)
1999+bool radeon_ddc_probe(struct radeon_connector *radeon_connector, bool use_aux)
2000 {
2001 u8 out = 0x0;
2002 u8 buf[8];
2003@@ -63,7 +63,13 @@ bool radeon_ddc_probe(struct radeon_connector *radeon_connector)
2004 if (radeon_connector->router.ddc_valid)
2005 radeon_router_select_ddc_port(radeon_connector);
2006
2007- ret = i2c_transfer(&radeon_connector->ddc_bus->adapter, msgs, 2);
2008+ if (use_aux) {
2009+ struct radeon_connector_atom_dig *dig = radeon_connector->con_priv;
2010+ ret = i2c_transfer(&dig->dp_i2c_bus->adapter, msgs, 2);
2011+ } else {
2012+ ret = i2c_transfer(&radeon_connector->ddc_bus->adapter, msgs, 2);
2013+ }
2014+
2015 if (ret != 2)
2016 /* Couldn't find an accessible DDC on this connector */
2017 return false;
2018diff --git a/drivers/gpu/drm/radeon/radeon_legacy_encoders.c b/drivers/gpu/drm/radeon/radeon_legacy_encoders.c
2019index dd402bb..9633dbb 100644
2020--- a/drivers/gpu/drm/radeon/radeon_legacy_encoders.c
2021+++ b/drivers/gpu/drm/radeon/radeon_legacy_encoders.c
2022@@ -618,6 +618,14 @@ static enum drm_connector_status radeon_legacy_primary_dac_detect(struct drm_enc
2023 enum drm_connector_status found = connector_status_disconnected;
2024 bool color = true;
2025
2026+ /* just don't bother on RN50 those chip are often connected to remoting
2027+ * console hw and often we get failure to load detect those. So to make
2028+ * everyone happy report the encoder as always connected.
2029+ */
2030+ if (ASIC_IS_RN50(rdev)) {
2031+ return connector_status_connected;
2032+ }
2033+
2034 /* save the regs we need */
2035 vclk_ecp_cntl = RREG32_PLL(RADEON_VCLK_ECP_CNTL);
2036 crtc_ext_cntl = RREG32(RADEON_CRTC_EXT_CNTL);
2037diff --git a/drivers/gpu/drm/radeon/radeon_mode.h b/drivers/gpu/drm/radeon/radeon_mode.h
2038index d569789..485d16e 100644
2039--- a/drivers/gpu/drm/radeon/radeon_mode.h
2040+++ b/drivers/gpu/drm/radeon/radeon_mode.h
2041@@ -534,7 +534,7 @@ extern void radeon_i2c_put_byte(struct radeon_i2c_chan *i2c,
2042 u8 val);
2043 extern void radeon_router_select_ddc_port(struct radeon_connector *radeon_connector);
2044 extern void radeon_router_select_cd_port(struct radeon_connector *radeon_connector);
2045-extern bool radeon_ddc_probe(struct radeon_connector *radeon_connector);
2046+extern bool radeon_ddc_probe(struct radeon_connector *radeon_connector, bool use_aux);
2047 extern int radeon_ddc_get_modes(struct radeon_connector *radeon_connector);
2048
2049 extern struct drm_encoder *radeon_best_encoder(struct drm_connector *connector);
2050diff --git a/drivers/gpu/drm/udl/udl_connector.c b/drivers/gpu/drm/udl/udl_connector.c
2051index 8d9dc44..3234224 100644
2052--- a/drivers/gpu/drm/udl/udl_connector.c
2053+++ b/drivers/gpu/drm/udl/udl_connector.c
2054@@ -22,13 +22,17 @@
2055 static u8 *udl_get_edid(struct udl_device *udl)
2056 {
2057 u8 *block;
2058- char rbuf[3];
2059+ char *rbuf;
2060 int ret, i;
2061
2062 block = kmalloc(EDID_LENGTH, GFP_KERNEL);
2063 if (block == NULL)
2064 return NULL;
2065
2066+ rbuf = kmalloc(2, GFP_KERNEL);
2067+ if (rbuf == NULL)
2068+ goto error;
2069+
2070 for (i = 0; i < EDID_LENGTH; i++) {
2071 ret = usb_control_msg(udl->ddev->usbdev,
2072 usb_rcvctrlpipe(udl->ddev->usbdev, 0), (0x02),
2073@@ -36,16 +40,17 @@ static u8 *udl_get_edid(struct udl_device *udl)
2074 HZ);
2075 if (ret < 1) {
2076 DRM_ERROR("Read EDID byte %d failed err %x\n", i, ret);
2077- i--;
2078 goto error;
2079 }
2080 block[i] = rbuf[1];
2081 }
2082
2083+ kfree(rbuf);
2084 return block;
2085
2086 error:
2087 kfree(block);
2088+ kfree(rbuf);
2089 return NULL;
2090 }
2091
2092@@ -59,6 +64,14 @@ static int udl_get_modes(struct drm_connector *connector)
2093
2094 connector->display_info.raw_edid = (char *)edid;
2095
2096+ /*
2097+ * We only read the main block, but if the monitor reports extension
2098+ * blocks then the drm edid code expects them to be present, so patch
2099+ * the extension count to 0.
2100+ */
2101+ edid->checksum += edid->extensions;
2102+ edid->extensions = 0;
2103+
2104 drm_mode_connector_update_edid_property(connector, edid);
2105 ret = drm_add_edid_modes(connector, edid);
2106 connector->display_info.raw_edid = NULL;
2107diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
2108index 5de3bb3..10ef742 100644
2109--- a/drivers/hid/hid-core.c
2110+++ b/drivers/hid/hid-core.c
2111@@ -1528,6 +1528,7 @@ static const struct hid_device_id hid_have_special_driver[] = {
2112 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI) },
2113 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO) },
2114 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS) },
2115+ { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ANSI) },
2116 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ISO) },
2117 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) },
2118 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) },
2119diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
2120index ab8ce9f..2a3f007 100644
2121--- a/drivers/hid/hid-ids.h
2122+++ b/drivers/hid/hid-ids.h
2123@@ -681,6 +681,9 @@
2124 #define USB_VENDOR_ID_SIGMA_MICRO 0x1c4f
2125 #define USB_DEVICE_ID_SIGMA_MICRO_KEYBOARD 0x0002
2126
2127+#define USB_VENDOR_ID_SIGMATEL 0x066F
2128+#define USB_DEVICE_ID_SIGMATEL_STMP3780 0x3780
2129+
2130 #define USB_VENDOR_ID_SKYCABLE 0x1223
2131 #define USB_DEVICE_ID_SKYCABLE_WIRELESS_PRESENTER 0x3F07
2132
2133diff --git a/drivers/hid/usbhid/hid-quirks.c b/drivers/hid/usbhid/hid-quirks.c
2134index 8865fa3..eb55cef 100644
2135--- a/drivers/hid/usbhid/hid-quirks.c
2136+++ b/drivers/hid/usbhid/hid-quirks.c
2137@@ -79,6 +79,7 @@ static const struct hid_blacklist {
2138 { USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_PIXART_IMAGING_INC_OPTICAL_TOUCH_SCREEN, HID_QUIRK_NOGET },
2139 { USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH_3008, HID_QUIRK_NOGET },
2140 { USB_VENDOR_ID_SENNHEISER, USB_DEVICE_ID_SENNHEISER_BTD500USB, HID_QUIRK_NOGET },
2141+ { USB_VENDOR_ID_SIGMATEL, USB_DEVICE_ID_SIGMATEL_STMP3780, HID_QUIRK_NOGET },
2142 { USB_VENDOR_ID_SUN, USB_DEVICE_ID_RARITAN_KVM_DONGLE, HID_QUIRK_NOGET },
2143 { USB_VENDOR_ID_SYMBOL, USB_DEVICE_ID_SYMBOL_SCANNER_1, HID_QUIRK_NOGET },
2144 { USB_VENDOR_ID_SYMBOL, USB_DEVICE_ID_SYMBOL_SCANNER_2, HID_QUIRK_NOGET },
2145diff --git a/drivers/hwmon/lm73.c b/drivers/hwmon/lm73.c
2146index 8fa2632..7272176 100644
2147--- a/drivers/hwmon/lm73.c
2148+++ b/drivers/hwmon/lm73.c
2149@@ -49,6 +49,7 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *da,
2150 struct i2c_client *client = to_i2c_client(dev);
2151 long temp;
2152 short value;
2153+ s32 err;
2154
2155 int status = kstrtol(buf, 10, &temp);
2156 if (status < 0)
2157@@ -57,8 +58,8 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *da,
2158 /* Write value */
2159 value = (short) SENSORS_LIMIT(temp/250, (LM73_TEMP_MIN*4),
2160 (LM73_TEMP_MAX*4)) << 5;
2161- i2c_smbus_write_word_swapped(client, attr->index, value);
2162- return count;
2163+ err = i2c_smbus_write_word_swapped(client, attr->index, value);
2164+ return (err < 0) ? err : count;
2165 }
2166
2167 static ssize_t show_temp(struct device *dev, struct device_attribute *da,
2168@@ -66,11 +67,16 @@ static ssize_t show_temp(struct device *dev, struct device_attribute *da,
2169 {
2170 struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
2171 struct i2c_client *client = to_i2c_client(dev);
2172+ int temp;
2173+
2174+ s32 err = i2c_smbus_read_word_swapped(client, attr->index);
2175+ if (err < 0)
2176+ return err;
2177+
2178 /* use integer division instead of equivalent right shift to
2179 guarantee arithmetic shift and preserve the sign */
2180- int temp = ((s16) (i2c_smbus_read_word_swapped(client,
2181- attr->index))*250) / 32;
2182- return sprintf(buf, "%d\n", temp);
2183+ temp = (((s16) err) * 250) / 32;
2184+ return scnprintf(buf, PAGE_SIZE, "%d\n", temp);
2185 }
2186
2187
2188diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h
2189index c438e46..3f41d9f 100644
2190--- a/drivers/infiniband/hw/nes/nes.h
2191+++ b/drivers/infiniband/hw/nes/nes.h
2192@@ -524,6 +524,7 @@ void nes_iwarp_ce_handler(struct nes_device *, struct nes_hw_cq *);
2193 int nes_destroy_cqp(struct nes_device *);
2194 int nes_nic_cm_xmit(struct sk_buff *, struct net_device *);
2195 void nes_recheck_link_status(struct work_struct *work);
2196+void nes_terminate_timeout(unsigned long context);
2197
2198 /* nes_nic.c */
2199 struct net_device *nes_netdev_init(struct nes_device *, void __iomem *);
2200diff --git a/drivers/infiniband/hw/nes/nes_hw.c b/drivers/infiniband/hw/nes/nes_hw.c
2201index d42c9f4..96801c3 100644
2202--- a/drivers/infiniband/hw/nes/nes_hw.c
2203+++ b/drivers/infiniband/hw/nes/nes_hw.c
2204@@ -75,7 +75,6 @@ static void nes_process_iwarp_aeqe(struct nes_device *nesdev,
2205 static void process_critical_error(struct nes_device *nesdev);
2206 static void nes_process_mac_intr(struct nes_device *nesdev, u32 mac_number);
2207 static unsigned int nes_reset_adapter_ne020(struct nes_device *nesdev, u8 *OneG_Mode);
2208-static void nes_terminate_timeout(unsigned long context);
2209 static void nes_terminate_start_timer(struct nes_qp *nesqp);
2210
2211 #ifdef CONFIG_INFINIBAND_NES_DEBUG
2212@@ -3522,7 +3521,7 @@ static void nes_terminate_received(struct nes_device *nesdev,
2213 }
2214
2215 /* Timeout routine in case terminate fails to complete */
2216-static void nes_terminate_timeout(unsigned long context)
2217+void nes_terminate_timeout(unsigned long context)
2218 {
2219 struct nes_qp *nesqp = (struct nes_qp *)(unsigned long)context;
2220
2221@@ -3532,11 +3531,7 @@ static void nes_terminate_timeout(unsigned long context)
2222 /* Set a timer in case hw cannot complete the terminate sequence */
2223 static void nes_terminate_start_timer(struct nes_qp *nesqp)
2224 {
2225- init_timer(&nesqp->terminate_timer);
2226- nesqp->terminate_timer.function = nes_terminate_timeout;
2227- nesqp->terminate_timer.expires = jiffies + HZ;
2228- nesqp->terminate_timer.data = (unsigned long)nesqp;
2229- add_timer(&nesqp->terminate_timer);
2230+ mod_timer(&nesqp->terminate_timer, (jiffies + HZ));
2231 }
2232
2233 /**
2234diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
2235index 8b8812d..da84ea3 100644
2236--- a/drivers/infiniband/hw/nes/nes_verbs.c
2237+++ b/drivers/infiniband/hw/nes/nes_verbs.c
2238@@ -1404,6 +1404,9 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
2239 }
2240
2241 nesqp->sig_all = (init_attr->sq_sig_type == IB_SIGNAL_ALL_WR);
2242+ init_timer(&nesqp->terminate_timer);
2243+ nesqp->terminate_timer.function = nes_terminate_timeout;
2244+ nesqp->terminate_timer.data = (unsigned long)nesqp;
2245
2246 /* update the QP table */
2247 nesdev->nesadapter->qp_table[nesqp->hwqp.qp_id-NES_FIRST_QPN] = nesqp;
2248@@ -1413,7 +1416,6 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
2249 return &nesqp->ibqp;
2250 }
2251
2252-
2253 /**
2254 * nes_clean_cq
2255 */
2256@@ -2559,6 +2561,11 @@ static struct ib_mr *nes_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
2257 return ibmr;
2258 case IWNES_MEMREG_TYPE_QP:
2259 case IWNES_MEMREG_TYPE_CQ:
2260+ if (!region->length) {
2261+ nes_debug(NES_DBG_MR, "Unable to register zero length region for CQ\n");
2262+ ib_umem_release(region);
2263+ return ERR_PTR(-EINVAL);
2264+ }
2265 nespbl = kzalloc(sizeof(*nespbl), GFP_KERNEL);
2266 if (!nespbl) {
2267 nes_debug(NES_DBG_MR, "Unable to allocate PBL\n");
2268diff --git a/drivers/input/joystick/walkera0701.c b/drivers/input/joystick/walkera0701.c
2269index 4dfa1ee..f8f892b 100644
2270--- a/drivers/input/joystick/walkera0701.c
2271+++ b/drivers/input/joystick/walkera0701.c
2272@@ -196,6 +196,7 @@ static void walkera0701_close(struct input_dev *dev)
2273 struct walkera_dev *w = input_get_drvdata(dev);
2274
2275 parport_disable_irq(w->parport);
2276+ hrtimer_cancel(&w->timer);
2277 }
2278
2279 static int walkera0701_connect(struct walkera_dev *w, int parport)
2280@@ -224,6 +225,9 @@ static int walkera0701_connect(struct walkera_dev *w, int parport)
2281 if (parport_claim(w->pardevice))
2282 goto init_err1;
2283
2284+ hrtimer_init(&w->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
2285+ w->timer.function = timer_handler;
2286+
2287 w->input_dev = input_allocate_device();
2288 if (!w->input_dev)
2289 goto init_err2;
2290@@ -254,8 +258,6 @@ static int walkera0701_connect(struct walkera_dev *w, int parport)
2291 if (err)
2292 goto init_err3;
2293
2294- hrtimer_init(&w->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
2295- w->timer.function = timer_handler;
2296 return 0;
2297
2298 init_err3:
2299@@ -271,7 +273,6 @@ static int walkera0701_connect(struct walkera_dev *w, int parport)
2300
2301 static void walkera0701_disconnect(struct walkera_dev *w)
2302 {
2303- hrtimer_cancel(&w->timer);
2304 input_unregister_device(w->input_dev);
2305 parport_release(w->pardevice);
2306 parport_unregister_device(w->pardevice);
2307diff --git a/drivers/input/mouse/sentelic.c b/drivers/input/mouse/sentelic.c
2308index a261d85..c4c9218 100644
2309--- a/drivers/input/mouse/sentelic.c
2310+++ b/drivers/input/mouse/sentelic.c
2311@@ -791,7 +791,7 @@ static psmouse_ret_t fsp_process_byte(struct psmouse *psmouse)
2312 fsp_set_slot(dev, 0, fgrs > 0, abs_x, abs_y);
2313 fsp_set_slot(dev, 1, false, 0, 0);
2314 }
2315- if (fgrs > 0) {
2316+ if (fgrs == 1 || (fgrs == 2 && !(packet[0] & FSP_PB0_MFMC_FGR2))) {
2317 input_report_abs(dev, ABS_X, abs_x);
2318 input_report_abs(dev, ABS_Y, abs_y);
2319 }
2320diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h
2321index d6cc77a..5f306f7 100644
2322--- a/drivers/input/serio/i8042-x86ia64io.h
2323+++ b/drivers/input/serio/i8042-x86ia64io.h
2324@@ -921,6 +921,7 @@ static int __init i8042_platform_init(void)
2325 int retval;
2326
2327 #ifdef CONFIG_X86
2328+ u8 a20_on = 0xdf;
2329 /* Just return if pre-detection shows no i8042 controller exist */
2330 if (!x86_platform.i8042_detect())
2331 return -ENODEV;
2332@@ -960,6 +961,14 @@ static int __init i8042_platform_init(void)
2333
2334 if (dmi_check_system(i8042_dmi_dritek_table))
2335 i8042_dritek = true;
2336+
2337+ /*
2338+ * A20 was already enabled during early kernel init. But some buggy
2339+ * BIOSes (in MSI Laptops) require A20 to be enabled using 8042 to
2340+ * resume from S3. So we do it here and hope that nothing breaks.
2341+ */
2342+ i8042_command(&a20_on, 0x10d1);
2343+ i8042_command(NULL, 0x00ff); /* Null command for SMM firmware */
2344 #endif /* CONFIG_X86 */
2345
2346 return retval;
2347diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c
2348index 18a89b7..e69ece6 100644
2349--- a/drivers/iommu/amd_iommu_init.c
2350+++ b/drivers/iommu/amd_iommu_init.c
2351@@ -906,6 +906,38 @@ static void __init free_iommu_all(void)
2352 }
2353
2354 /*
2355+ * Family15h Model 10h-1fh erratum 746 (IOMMU Logging May Stall Translations)
2356+ * Workaround:
2357+ * BIOS should disable L2B micellaneous clock gating by setting
2358+ * L2_L2B_CK_GATE_CONTROL[CKGateL2BMiscDisable](D0F2xF4_x90[2]) = 1b
2359+ */
2360+static void __init amd_iommu_erratum_746_workaround(struct amd_iommu *iommu)
2361+{
2362+ u32 value;
2363+
2364+ if ((boot_cpu_data.x86 != 0x15) ||
2365+ (boot_cpu_data.x86_model < 0x10) ||
2366+ (boot_cpu_data.x86_model > 0x1f))
2367+ return;
2368+
2369+ pci_write_config_dword(iommu->dev, 0xf0, 0x90);
2370+ pci_read_config_dword(iommu->dev, 0xf4, &value);
2371+
2372+ if (value & BIT(2))
2373+ return;
2374+
2375+ /* Select NB indirect register 0x90 and enable writing */
2376+ pci_write_config_dword(iommu->dev, 0xf0, 0x90 | (1 << 8));
2377+
2378+ pci_write_config_dword(iommu->dev, 0xf4, value | 0x4);
2379+ pr_info("AMD-Vi: Applying erratum 746 workaround for IOMMU at %s\n",
2380+ dev_name(&iommu->dev->dev));
2381+
2382+ /* Clear the enable writing bit */
2383+ pci_write_config_dword(iommu->dev, 0xf0, 0x90);
2384+}
2385+
2386+/*
2387 * This function clues the initialization function for one IOMMU
2388 * together and also allocates the command buffer and programs the
2389 * hardware. It does NOT enable the IOMMU. This is done afterwards.
2390@@ -1092,6 +1124,8 @@ static int iommu_init_pci(struct amd_iommu *iommu)
2391 iommu->stored_l2[i] = iommu_read_l2(iommu, i);
2392 }
2393
2394+ amd_iommu_erratum_746_workaround(iommu);
2395+
2396 return pci_enable_device(iommu->dev);
2397 }
2398
2399diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
2400index 554e6ac..04fb7af 100644
2401--- a/drivers/iommu/intel-iommu.c
2402+++ b/drivers/iommu/intel-iommu.c
2403@@ -1827,10 +1827,17 @@ static int __domain_mapping(struct dmar_domain *domain, unsigned long iov_pfn,
2404 if (!pte)
2405 return -ENOMEM;
2406 /* It is large page*/
2407- if (largepage_lvl > 1)
2408+ if (largepage_lvl > 1) {
2409 pteval |= DMA_PTE_LARGE_PAGE;
2410- else
2411+ /* Ensure that old small page tables are removed to make room
2412+ for superpage, if they exist. */
2413+ dma_pte_clear_range(domain, iov_pfn,
2414+ iov_pfn + lvl_to_nr_pages(largepage_lvl) - 1);
2415+ dma_pte_free_pagetable(domain, iov_pfn,
2416+ iov_pfn + lvl_to_nr_pages(largepage_lvl) - 1);
2417+ } else {
2418 pteval &= ~(uint64_t)DMA_PTE_LARGE_PAGE;
2419+ }
2420
2421 }
2422 /* We don't need lock here, nobody else
2423@@ -2320,8 +2327,39 @@ static int domain_add_dev_info(struct dmar_domain *domain,
2424 return 0;
2425 }
2426
2427+static bool device_has_rmrr(struct pci_dev *dev)
2428+{
2429+ struct dmar_rmrr_unit *rmrr;
2430+ int i;
2431+
2432+ for_each_rmrr_units(rmrr) {
2433+ for (i = 0; i < rmrr->devices_cnt; i++) {
2434+ /*
2435+ * Return TRUE if this RMRR contains the device that
2436+ * is passed in.
2437+ */
2438+ if (rmrr->devices[i] == dev)
2439+ return true;
2440+ }
2441+ }
2442+ return false;
2443+}
2444+
2445 static int iommu_should_identity_map(struct pci_dev *pdev, int startup)
2446 {
2447+
2448+ /*
2449+ * We want to prevent any device associated with an RMRR from
2450+ * getting placed into the SI Domain. This is done because
2451+ * problems exist when devices are moved in and out of domains
2452+ * and their respective RMRR info is lost. We exempt USB devices
2453+ * from this process due to their usage of RMRRs that are known
2454+ * to not be needed after BIOS hand-off to OS.
2455+ */
2456+ if (device_has_rmrr(pdev) &&
2457+ (pdev->class >> 8) != PCI_CLASS_SERIAL_USB)
2458+ return 0;
2459+
2460 if ((iommu_identity_mapping & IDENTMAP_AZALIA) && IS_AZALIA(pdev))
2461 return 1;
2462
2463@@ -4196,6 +4234,21 @@ static struct iommu_ops intel_iommu_ops = {
2464 .pgsize_bitmap = INTEL_IOMMU_PGSIZES,
2465 };
2466
2467+static void __devinit quirk_iommu_g4x_gfx(struct pci_dev *dev)
2468+{
2469+ /* G4x/GM45 integrated gfx dmar support is totally busted. */
2470+ printk(KERN_INFO "DMAR: Disabling IOMMU for graphics on this chipset\n");
2471+ dmar_map_gfx = 0;
2472+}
2473+
2474+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2a40, quirk_iommu_g4x_gfx);
2475+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2e00, quirk_iommu_g4x_gfx);
2476+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2e10, quirk_iommu_g4x_gfx);
2477+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2e20, quirk_iommu_g4x_gfx);
2478+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2e30, quirk_iommu_g4x_gfx);
2479+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2e40, quirk_iommu_g4x_gfx);
2480+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2e90, quirk_iommu_g4x_gfx);
2481+
2482 static void __devinit quirk_iommu_rwbf(struct pci_dev *dev)
2483 {
2484 /*
2485@@ -4204,12 +4257,6 @@ static void __devinit quirk_iommu_rwbf(struct pci_dev *dev)
2486 */
2487 printk(KERN_INFO "DMAR: Forcing write-buffer flush capability\n");
2488 rwbf_quirk = 1;
2489-
2490- /* https://bugzilla.redhat.com/show_bug.cgi?id=538163 */
2491- if (dev->revision == 0x07) {
2492- printk(KERN_INFO "DMAR: Disabling IOMMU for graphics on this chipset\n");
2493- dmar_map_gfx = 0;
2494- }
2495 }
2496
2497 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2a40, quirk_iommu_rwbf);
2498diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
2499index afd9598..a651d52 100644
2500--- a/drivers/md/dm-ioctl.c
2501+++ b/drivers/md/dm-ioctl.c
2502@@ -1566,6 +1566,14 @@ static int copy_params(struct dm_ioctl __user *user, struct dm_ioctl **param)
2503 if (copy_from_user(dmi, user, tmp.data_size))
2504 goto bad;
2505
2506+ /*
2507+ * Abort if something changed the ioctl data while it was being copied.
2508+ */
2509+ if (dmi->data_size != tmp.data_size) {
2510+ DMERR("rejecting ioctl: data size modified while processing parameters");
2511+ goto bad;
2512+ }
2513+
2514 /* Wipe the user buffer so we do not return it to userspace */
2515 if (secure_data && clear_user(user, tmp.data_size))
2516 goto bad;
2517diff --git a/drivers/md/persistent-data/dm-btree-internal.h b/drivers/md/persistent-data/dm-btree-internal.h
2518index 5709bfe..accbb05 100644
2519--- a/drivers/md/persistent-data/dm-btree-internal.h
2520+++ b/drivers/md/persistent-data/dm-btree-internal.h
2521@@ -36,13 +36,13 @@ struct node_header {
2522 __le32 padding;
2523 } __packed;
2524
2525-struct node {
2526+struct btree_node {
2527 struct node_header header;
2528 __le64 keys[0];
2529 } __packed;
2530
2531
2532-void inc_children(struct dm_transaction_manager *tm, struct node *n,
2533+void inc_children(struct dm_transaction_manager *tm, struct btree_node *n,
2534 struct dm_btree_value_type *vt);
2535
2536 int new_block(struct dm_btree_info *info, struct dm_block **result);
2537@@ -64,7 +64,7 @@ struct ro_spine {
2538 void init_ro_spine(struct ro_spine *s, struct dm_btree_info *info);
2539 int exit_ro_spine(struct ro_spine *s);
2540 int ro_step(struct ro_spine *s, dm_block_t new_child);
2541-struct node *ro_node(struct ro_spine *s);
2542+struct btree_node *ro_node(struct ro_spine *s);
2543
2544 struct shadow_spine {
2545 struct dm_btree_info *info;
2546@@ -98,17 +98,17 @@ int shadow_root(struct shadow_spine *s);
2547 /*
2548 * Some inlines.
2549 */
2550-static inline __le64 *key_ptr(struct node *n, uint32_t index)
2551+static inline __le64 *key_ptr(struct btree_node *n, uint32_t index)
2552 {
2553 return n->keys + index;
2554 }
2555
2556-static inline void *value_base(struct node *n)
2557+static inline void *value_base(struct btree_node *n)
2558 {
2559 return &n->keys[le32_to_cpu(n->header.max_entries)];
2560 }
2561
2562-static inline void *value_ptr(struct node *n, uint32_t index)
2563+static inline void *value_ptr(struct btree_node *n, uint32_t index)
2564 {
2565 uint32_t value_size = le32_to_cpu(n->header.value_size);
2566 return value_base(n) + (value_size * index);
2567@@ -117,7 +117,7 @@ static inline void *value_ptr(struct node *n, uint32_t index)
2568 /*
2569 * Assumes the values are suitably-aligned and converts to core format.
2570 */
2571-static inline uint64_t value64(struct node *n, uint32_t index)
2572+static inline uint64_t value64(struct btree_node *n, uint32_t index)
2573 {
2574 __le64 *values_le = value_base(n);
2575
2576@@ -127,7 +127,7 @@ static inline uint64_t value64(struct node *n, uint32_t index)
2577 /*
2578 * Searching for a key within a single node.
2579 */
2580-int lower_bound(struct node *n, uint64_t key);
2581+int lower_bound(struct btree_node *n, uint64_t key);
2582
2583 extern struct dm_block_validator btree_node_validator;
2584
2585diff --git a/drivers/md/persistent-data/dm-btree-remove.c b/drivers/md/persistent-data/dm-btree-remove.c
2586index aa71e23..c4f2813 100644
2587--- a/drivers/md/persistent-data/dm-btree-remove.c
2588+++ b/drivers/md/persistent-data/dm-btree-remove.c
2589@@ -53,7 +53,7 @@
2590 /*
2591 * Some little utilities for moving node data around.
2592 */
2593-static void node_shift(struct node *n, int shift)
2594+static void node_shift(struct btree_node *n, int shift)
2595 {
2596 uint32_t nr_entries = le32_to_cpu(n->header.nr_entries);
2597 uint32_t value_size = le32_to_cpu(n->header.value_size);
2598@@ -79,7 +79,7 @@ static void node_shift(struct node *n, int shift)
2599 }
2600 }
2601
2602-static void node_copy(struct node *left, struct node *right, int shift)
2603+static void node_copy(struct btree_node *left, struct btree_node *right, int shift)
2604 {
2605 uint32_t nr_left = le32_to_cpu(left->header.nr_entries);
2606 uint32_t value_size = le32_to_cpu(left->header.value_size);
2607@@ -108,7 +108,7 @@ static void node_copy(struct node *left, struct node *right, int shift)
2608 /*
2609 * Delete a specific entry from a leaf node.
2610 */
2611-static void delete_at(struct node *n, unsigned index)
2612+static void delete_at(struct btree_node *n, unsigned index)
2613 {
2614 unsigned nr_entries = le32_to_cpu(n->header.nr_entries);
2615 unsigned nr_to_copy = nr_entries - (index + 1);
2616@@ -128,7 +128,7 @@ static void delete_at(struct node *n, unsigned index)
2617 n->header.nr_entries = cpu_to_le32(nr_entries - 1);
2618 }
2619
2620-static unsigned merge_threshold(struct node *n)
2621+static unsigned merge_threshold(struct btree_node *n)
2622 {
2623 return le32_to_cpu(n->header.max_entries) / 3;
2624 }
2625@@ -136,7 +136,7 @@ static unsigned merge_threshold(struct node *n)
2626 struct child {
2627 unsigned index;
2628 struct dm_block *block;
2629- struct node *n;
2630+ struct btree_node *n;
2631 };
2632
2633 static struct dm_btree_value_type le64_type = {
2634@@ -147,7 +147,7 @@ static struct dm_btree_value_type le64_type = {
2635 .equal = NULL
2636 };
2637
2638-static int init_child(struct dm_btree_info *info, struct node *parent,
2639+static int init_child(struct dm_btree_info *info, struct btree_node *parent,
2640 unsigned index, struct child *result)
2641 {
2642 int r, inc;
2643@@ -177,7 +177,7 @@ static int exit_child(struct dm_btree_info *info, struct child *c)
2644 return dm_tm_unlock(info->tm, c->block);
2645 }
2646
2647-static void shift(struct node *left, struct node *right, int count)
2648+static void shift(struct btree_node *left, struct btree_node *right, int count)
2649 {
2650 uint32_t nr_left = le32_to_cpu(left->header.nr_entries);
2651 uint32_t nr_right = le32_to_cpu(right->header.nr_entries);
2652@@ -203,11 +203,11 @@ static void shift(struct node *left, struct node *right, int count)
2653 right->header.nr_entries = cpu_to_le32(nr_right + count);
2654 }
2655
2656-static void __rebalance2(struct dm_btree_info *info, struct node *parent,
2657+static void __rebalance2(struct dm_btree_info *info, struct btree_node *parent,
2658 struct child *l, struct child *r)
2659 {
2660- struct node *left = l->n;
2661- struct node *right = r->n;
2662+ struct btree_node *left = l->n;
2663+ struct btree_node *right = r->n;
2664 uint32_t nr_left = le32_to_cpu(left->header.nr_entries);
2665 uint32_t nr_right = le32_to_cpu(right->header.nr_entries);
2666 unsigned threshold = 2 * merge_threshold(left) + 1;
2667@@ -239,7 +239,7 @@ static int rebalance2(struct shadow_spine *s, struct dm_btree_info *info,
2668 unsigned left_index)
2669 {
2670 int r;
2671- struct node *parent;
2672+ struct btree_node *parent;
2673 struct child left, right;
2674
2675 parent = dm_block_data(shadow_current(s));
2676@@ -270,9 +270,9 @@ static int rebalance2(struct shadow_spine *s, struct dm_btree_info *info,
2677 * in right, then rebalance2. This wastes some cpu, but I want something
2678 * simple atm.
2679 */
2680-static void delete_center_node(struct dm_btree_info *info, struct node *parent,
2681+static void delete_center_node(struct dm_btree_info *info, struct btree_node *parent,
2682 struct child *l, struct child *c, struct child *r,
2683- struct node *left, struct node *center, struct node *right,
2684+ struct btree_node *left, struct btree_node *center, struct btree_node *right,
2685 uint32_t nr_left, uint32_t nr_center, uint32_t nr_right)
2686 {
2687 uint32_t max_entries = le32_to_cpu(left->header.max_entries);
2688@@ -301,9 +301,9 @@ static void delete_center_node(struct dm_btree_info *info, struct node *parent,
2689 /*
2690 * Redistributes entries among 3 sibling nodes.
2691 */
2692-static void redistribute3(struct dm_btree_info *info, struct node *parent,
2693+static void redistribute3(struct dm_btree_info *info, struct btree_node *parent,
2694 struct child *l, struct child *c, struct child *r,
2695- struct node *left, struct node *center, struct node *right,
2696+ struct btree_node *left, struct btree_node *center, struct btree_node *right,
2697 uint32_t nr_left, uint32_t nr_center, uint32_t nr_right)
2698 {
2699 int s;
2700@@ -343,12 +343,12 @@ static void redistribute3(struct dm_btree_info *info, struct node *parent,
2701 *key_ptr(parent, r->index) = right->keys[0];
2702 }
2703
2704-static void __rebalance3(struct dm_btree_info *info, struct node *parent,
2705+static void __rebalance3(struct dm_btree_info *info, struct btree_node *parent,
2706 struct child *l, struct child *c, struct child *r)
2707 {
2708- struct node *left = l->n;
2709- struct node *center = c->n;
2710- struct node *right = r->n;
2711+ struct btree_node *left = l->n;
2712+ struct btree_node *center = c->n;
2713+ struct btree_node *right = r->n;
2714
2715 uint32_t nr_left = le32_to_cpu(left->header.nr_entries);
2716 uint32_t nr_center = le32_to_cpu(center->header.nr_entries);
2717@@ -371,7 +371,7 @@ static int rebalance3(struct shadow_spine *s, struct dm_btree_info *info,
2718 unsigned left_index)
2719 {
2720 int r;
2721- struct node *parent = dm_block_data(shadow_current(s));
2722+ struct btree_node *parent = dm_block_data(shadow_current(s));
2723 struct child left, center, right;
2724
2725 /*
2726@@ -421,7 +421,7 @@ static int get_nr_entries(struct dm_transaction_manager *tm,
2727 {
2728 int r;
2729 struct dm_block *block;
2730- struct node *n;
2731+ struct btree_node *n;
2732
2733 r = dm_tm_read_lock(tm, b, &btree_node_validator, &block);
2734 if (r)
2735@@ -438,7 +438,7 @@ static int rebalance_children(struct shadow_spine *s,
2736 {
2737 int i, r, has_left_sibling, has_right_sibling;
2738 uint32_t child_entries;
2739- struct node *n;
2740+ struct btree_node *n;
2741
2742 n = dm_block_data(shadow_current(s));
2743
2744@@ -483,7 +483,7 @@ static int rebalance_children(struct shadow_spine *s,
2745 return r;
2746 }
2747
2748-static int do_leaf(struct node *n, uint64_t key, unsigned *index)
2749+static int do_leaf(struct btree_node *n, uint64_t key, unsigned *index)
2750 {
2751 int i = lower_bound(n, key);
2752
2753@@ -506,7 +506,7 @@ static int remove_raw(struct shadow_spine *s, struct dm_btree_info *info,
2754 uint64_t key, unsigned *index)
2755 {
2756 int i = *index, r;
2757- struct node *n;
2758+ struct btree_node *n;
2759
2760 for (;;) {
2761 r = shadow_step(s, root, vt);
2762@@ -556,7 +556,7 @@ int dm_btree_remove(struct dm_btree_info *info, dm_block_t root,
2763 unsigned level, last_level = info->levels - 1;
2764 int index = 0, r = 0;
2765 struct shadow_spine spine;
2766- struct node *n;
2767+ struct btree_node *n;
2768
2769 init_shadow_spine(&spine, info);
2770 for (level = 0; level < info->levels; level++) {
2771diff --git a/drivers/md/persistent-data/dm-btree-spine.c b/drivers/md/persistent-data/dm-btree-spine.c
2772index d9a7912..2f0805c 100644
2773--- a/drivers/md/persistent-data/dm-btree-spine.c
2774+++ b/drivers/md/persistent-data/dm-btree-spine.c
2775@@ -23,7 +23,7 @@ static void node_prepare_for_write(struct dm_block_validator *v,
2776 struct dm_block *b,
2777 size_t block_size)
2778 {
2779- struct node *n = dm_block_data(b);
2780+ struct btree_node *n = dm_block_data(b);
2781 struct node_header *h = &n->header;
2782
2783 h->blocknr = cpu_to_le64(dm_block_location(b));
2784@@ -38,7 +38,7 @@ static int node_check(struct dm_block_validator *v,
2785 struct dm_block *b,
2786 size_t block_size)
2787 {
2788- struct node *n = dm_block_data(b);
2789+ struct btree_node *n = dm_block_data(b);
2790 struct node_header *h = &n->header;
2791 size_t value_size;
2792 __le32 csum_disk;
2793@@ -164,7 +164,7 @@ int ro_step(struct ro_spine *s, dm_block_t new_child)
2794 return r;
2795 }
2796
2797-struct node *ro_node(struct ro_spine *s)
2798+struct btree_node *ro_node(struct ro_spine *s)
2799 {
2800 struct dm_block *block;
2801
2802diff --git a/drivers/md/persistent-data/dm-btree.c b/drivers/md/persistent-data/dm-btree.c
2803index d12b2cc..371f3d4 100644
2804--- a/drivers/md/persistent-data/dm-btree.c
2805+++ b/drivers/md/persistent-data/dm-btree.c
2806@@ -38,7 +38,7 @@ static void array_insert(void *base, size_t elt_size, unsigned nr_elts,
2807 /*----------------------------------------------------------------*/
2808
2809 /* makes the assumption that no two keys are the same. */
2810-static int bsearch(struct node *n, uint64_t key, int want_hi)
2811+static int bsearch(struct btree_node *n, uint64_t key, int want_hi)
2812 {
2813 int lo = -1, hi = le32_to_cpu(n->header.nr_entries);
2814
2815@@ -58,12 +58,12 @@ static int bsearch(struct node *n, uint64_t key, int want_hi)
2816 return want_hi ? hi : lo;
2817 }
2818
2819-int lower_bound(struct node *n, uint64_t key)
2820+int lower_bound(struct btree_node *n, uint64_t key)
2821 {
2822 return bsearch(n, key, 0);
2823 }
2824
2825-void inc_children(struct dm_transaction_manager *tm, struct node *n,
2826+void inc_children(struct dm_transaction_manager *tm, struct btree_node *n,
2827 struct dm_btree_value_type *vt)
2828 {
2829 unsigned i;
2830@@ -77,7 +77,7 @@ void inc_children(struct dm_transaction_manager *tm, struct node *n,
2831 vt->inc(vt->context, value_ptr(n, i));
2832 }
2833
2834-static int insert_at(size_t value_size, struct node *node, unsigned index,
2835+static int insert_at(size_t value_size, struct btree_node *node, unsigned index,
2836 uint64_t key, void *value)
2837 __dm_written_to_disk(value)
2838 {
2839@@ -122,7 +122,7 @@ int dm_btree_empty(struct dm_btree_info *info, dm_block_t *root)
2840 {
2841 int r;
2842 struct dm_block *b;
2843- struct node *n;
2844+ struct btree_node *n;
2845 size_t block_size;
2846 uint32_t max_entries;
2847
2848@@ -154,7 +154,7 @@ EXPORT_SYMBOL_GPL(dm_btree_empty);
2849 #define MAX_SPINE_DEPTH 64
2850 struct frame {
2851 struct dm_block *b;
2852- struct node *n;
2853+ struct btree_node *n;
2854 unsigned level;
2855 unsigned nr_children;
2856 unsigned current_child;
2857@@ -295,7 +295,7 @@ EXPORT_SYMBOL_GPL(dm_btree_del);
2858 /*----------------------------------------------------------------*/
2859
2860 static int btree_lookup_raw(struct ro_spine *s, dm_block_t block, uint64_t key,
2861- int (*search_fn)(struct node *, uint64_t),
2862+ int (*search_fn)(struct btree_node *, uint64_t),
2863 uint64_t *result_key, void *v, size_t value_size)
2864 {
2865 int i, r;
2866@@ -406,7 +406,7 @@ static int btree_split_sibling(struct shadow_spine *s, dm_block_t root,
2867 size_t size;
2868 unsigned nr_left, nr_right;
2869 struct dm_block *left, *right, *parent;
2870- struct node *ln, *rn, *pn;
2871+ struct btree_node *ln, *rn, *pn;
2872 __le64 location;
2873
2874 left = shadow_current(s);
2875@@ -491,7 +491,7 @@ static int btree_split_beneath(struct shadow_spine *s, uint64_t key)
2876 size_t size;
2877 unsigned nr_left, nr_right;
2878 struct dm_block *left, *right, *new_parent;
2879- struct node *pn, *ln, *rn;
2880+ struct btree_node *pn, *ln, *rn;
2881 __le64 val;
2882
2883 new_parent = shadow_current(s);
2884@@ -576,7 +576,7 @@ static int btree_insert_raw(struct shadow_spine *s, dm_block_t root,
2885 uint64_t key, unsigned *index)
2886 {
2887 int r, i = *index, top = 1;
2888- struct node *node;
2889+ struct btree_node *node;
2890
2891 for (;;) {
2892 r = shadow_step(s, root, vt);
2893@@ -643,7 +643,7 @@ static int insert(struct dm_btree_info *info, dm_block_t root,
2894 unsigned level, index = -1, last_level = info->levels - 1;
2895 dm_block_t block = root;
2896 struct shadow_spine spine;
2897- struct node *n;
2898+ struct btree_node *n;
2899 struct dm_btree_value_type le64_type;
2900
2901 le64_type.context = NULL;
2902diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c
2903index f8b7771..7604f4e 100644
2904--- a/drivers/mfd/mfd-core.c
2905+++ b/drivers/mfd/mfd-core.c
2906@@ -21,6 +21,10 @@
2907 #include <linux/irqdomain.h>
2908 #include <linux/of.h>
2909
2910+static struct device_type mfd_dev_type = {
2911+ .name = "mfd_device",
2912+};
2913+
2914 int mfd_cell_enable(struct platform_device *pdev)
2915 {
2916 const struct mfd_cell *cell = mfd_get_cell(pdev);
2917@@ -91,6 +95,7 @@ static int mfd_add_device(struct device *parent, int id,
2918 goto fail_device;
2919
2920 pdev->dev.parent = parent;
2921+ pdev->dev.type = &mfd_dev_type;
2922
2923 if (parent->of_node && cell->of_compatible) {
2924 for_each_child_of_node(parent->of_node, np) {
2925@@ -204,10 +209,16 @@ EXPORT_SYMBOL(mfd_add_devices);
2926
2927 static int mfd_remove_devices_fn(struct device *dev, void *c)
2928 {
2929- struct platform_device *pdev = to_platform_device(dev);
2930- const struct mfd_cell *cell = mfd_get_cell(pdev);
2931+ struct platform_device *pdev;
2932+ const struct mfd_cell *cell;
2933 atomic_t **usage_count = c;
2934
2935+ if (dev->type != &mfd_dev_type)
2936+ return 0;
2937+
2938+ pdev = to_platform_device(dev);
2939+ cell = mfd_get_cell(pdev);
2940+
2941 /* find the base address of usage_count pointers (for freeing) */
2942 if (!*usage_count || (cell->usage_count < *usage_count))
2943 *usage_count = cell->usage_count;
2944diff --git a/drivers/mfd/wm8994-core.c b/drivers/mfd/wm8994-core.c
2945index 2febf88..38de846 100644
2946--- a/drivers/mfd/wm8994-core.c
2947+++ b/drivers/mfd/wm8994-core.c
2948@@ -557,6 +557,7 @@ static __devinit int wm8994_device_init(struct wm8994 *wm8994, int irq)
2949 case 1:
2950 case 2:
2951 case 3:
2952+ case 4:
2953 regmap_patch = wm1811_reva_patch;
2954 patch_regs = ARRAY_SIZE(wm1811_reva_patch);
2955 break;
2956diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c
2957index 8d082b4..d971817 100644
2958--- a/drivers/misc/sgi-xp/xpc_main.c
2959+++ b/drivers/misc/sgi-xp/xpc_main.c
2960@@ -53,6 +53,10 @@
2961 #include <linux/kthread.h>
2962 #include "xpc.h"
2963
2964+#ifdef CONFIG_X86_64
2965+#include <asm/traps.h>
2966+#endif
2967+
2968 /* define two XPC debug device structures to be used with dev_dbg() et al */
2969
2970 struct device_driver xpc_dbg_name = {
2971@@ -1079,6 +1083,9 @@ xpc_system_reboot(struct notifier_block *nb, unsigned long event, void *unused)
2972 return NOTIFY_DONE;
2973 }
2974
2975+/* Used to only allow one cpu to complete disconnect */
2976+static unsigned int xpc_die_disconnecting;
2977+
2978 /*
2979 * Notify other partitions to deactivate from us by first disengaging from all
2980 * references to our memory.
2981@@ -1092,6 +1099,9 @@ xpc_die_deactivate(void)
2982 long keep_waiting;
2983 long wait_to_print;
2984
2985+ if (cmpxchg(&xpc_die_disconnecting, 0, 1))
2986+ return;
2987+
2988 /* keep xpc_hb_checker thread from doing anything (just in case) */
2989 xpc_exiting = 1;
2990
2991@@ -1159,7 +1169,7 @@ xpc_die_deactivate(void)
2992 * about the lack of a heartbeat.
2993 */
2994 static int
2995-xpc_system_die(struct notifier_block *nb, unsigned long event, void *unused)
2996+xpc_system_die(struct notifier_block *nb, unsigned long event, void *_die_args)
2997 {
2998 #ifdef CONFIG_IA64 /* !!! temporary kludge */
2999 switch (event) {
3000@@ -1191,7 +1201,27 @@ xpc_system_die(struct notifier_block *nb, unsigned long event, void *unused)
3001 break;
3002 }
3003 #else
3004- xpc_die_deactivate();
3005+ struct die_args *die_args = _die_args;
3006+
3007+ switch (event) {
3008+ case DIE_TRAP:
3009+ if (die_args->trapnr == X86_TRAP_DF)
3010+ xpc_die_deactivate();
3011+
3012+ if (((die_args->trapnr == X86_TRAP_MF) ||
3013+ (die_args->trapnr == X86_TRAP_XF)) &&
3014+ !user_mode_vm(die_args->regs))
3015+ xpc_die_deactivate();
3016+
3017+ break;
3018+ case DIE_INT3:
3019+ case DIE_DEBUG:
3020+ break;
3021+ case DIE_OOPS:
3022+ case DIE_GPF:
3023+ default:
3024+ xpc_die_deactivate();
3025+ }
3026 #endif
3027
3028 return NOTIFY_DONE;
3029diff --git a/drivers/mtd/nand/cs553x_nand.c b/drivers/mtd/nand/cs553x_nand.c
3030index adb6c3e..2cdeab8 100644
3031--- a/drivers/mtd/nand/cs553x_nand.c
3032+++ b/drivers/mtd/nand/cs553x_nand.c
3033@@ -237,6 +237,7 @@ static int __init cs553x_init_one(int cs, int mmio, unsigned long adr)
3034 this->ecc.hwctl = cs_enable_hwecc;
3035 this->ecc.calculate = cs_calculate_ecc;
3036 this->ecc.correct = nand_correct_data;
3037+ this->ecc.strength = 1;
3038
3039 /* Enable the following for a flash based bad block table */
3040 this->bbt_options = NAND_BBT_USE_FLASH;
3041@@ -247,8 +248,6 @@ static int __init cs553x_init_one(int cs, int mmio, unsigned long adr)
3042 goto out_ior;
3043 }
3044
3045- this->ecc.strength = 1;
3046-
3047 new_mtd->name = kasprintf(GFP_KERNEL, "cs553x_nand_cs%d", cs);
3048
3049 cs553x_mtd[cs] = new_mtd;
3050diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-lib.c b/drivers/mtd/nand/gpmi-nand/gpmi-lib.c
3051index a1f4332..b27e215 100644
3052--- a/drivers/mtd/nand/gpmi-nand/gpmi-lib.c
3053+++ b/drivers/mtd/nand/gpmi-nand/gpmi-lib.c
3054@@ -136,6 +136,15 @@ int gpmi_init(struct gpmi_nand_data *this)
3055 if (ret)
3056 goto err_out;
3057
3058+ /*
3059+ * Reset BCH here, too. We got failures otherwise :(
3060+ * See later BCH reset for explanation of MX23 handling
3061+ */
3062+ ret = gpmi_reset_block(r->bch_regs, GPMI_IS_MX23(this));
3063+ if (ret)
3064+ goto err_out;
3065+
3066+
3067 /* Choose NAND mode. */
3068 writel(BM_GPMI_CTRL1_GPMI_MODE, r->gpmi_regs + HW_GPMI_CTRL1_CLR);
3069
3070diff --git a/drivers/net/can/c_can/c_can.c b/drivers/net/can/c_can/c_can.c
3071index 4c538e3..f56a48e 100644
3072--- a/drivers/net/can/c_can/c_can.c
3073+++ b/drivers/net/can/c_can/c_can.c
3074@@ -918,7 +918,7 @@ static int c_can_handle_bus_err(struct net_device *dev,
3075 break;
3076 case LEC_ACK_ERROR:
3077 netdev_dbg(dev, "ack error\n");
3078- cf->data[2] |= (CAN_ERR_PROT_LOC_ACK |
3079+ cf->data[3] |= (CAN_ERR_PROT_LOC_ACK |
3080 CAN_ERR_PROT_LOC_ACK_DEL);
3081 break;
3082 case LEC_BIT1_ERROR:
3083@@ -931,7 +931,7 @@ static int c_can_handle_bus_err(struct net_device *dev,
3084 break;
3085 case LEC_CRC_ERROR:
3086 netdev_dbg(dev, "CRC error\n");
3087- cf->data[2] |= (CAN_ERR_PROT_LOC_CRC_SEQ |
3088+ cf->data[3] |= (CAN_ERR_PROT_LOC_CRC_SEQ |
3089 CAN_ERR_PROT_LOC_CRC_DEL);
3090 break;
3091 default:
3092diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c
3093index 963e2cc..8233e5e 100644
3094--- a/drivers/net/can/dev.c
3095+++ b/drivers/net/can/dev.c
3096@@ -609,8 +609,7 @@ void close_candev(struct net_device *dev)
3097 {
3098 struct can_priv *priv = netdev_priv(dev);
3099
3100- if (del_timer_sync(&priv->restart_timer))
3101- dev_put(dev);
3102+ del_timer_sync(&priv->restart_timer);
3103 can_flush_echo_skb(dev);
3104 }
3105 EXPORT_SYMBOL_GPL(close_candev);
3106diff --git a/drivers/net/can/pch_can.c b/drivers/net/can/pch_can.c
3107index 48b3d62..7a43d4d 100644
3108--- a/drivers/net/can/pch_can.c
3109+++ b/drivers/net/can/pch_can.c
3110@@ -560,7 +560,7 @@ static void pch_can_error(struct net_device *ndev, u32 status)
3111 stats->rx_errors++;
3112 break;
3113 case PCH_CRC_ERR:
3114- cf->data[2] |= CAN_ERR_PROT_LOC_CRC_SEQ |
3115+ cf->data[3] |= CAN_ERR_PROT_LOC_CRC_SEQ |
3116 CAN_ERR_PROT_LOC_CRC_DEL;
3117 priv->can.can_stats.bus_error++;
3118 stats->rx_errors++;
3119diff --git a/drivers/net/can/ti_hecc.c b/drivers/net/can/ti_hecc.c
3120index 9ded21e..44996a9 100644
3121--- a/drivers/net/can/ti_hecc.c
3122+++ b/drivers/net/can/ti_hecc.c
3123@@ -746,12 +746,12 @@ static int ti_hecc_error(struct net_device *ndev, int int_status,
3124 }
3125 if (err_status & HECC_CANES_CRCE) {
3126 hecc_set_bit(priv, HECC_CANES, HECC_CANES_CRCE);
3127- cf->data[2] |= CAN_ERR_PROT_LOC_CRC_SEQ |
3128+ cf->data[3] |= CAN_ERR_PROT_LOC_CRC_SEQ |
3129 CAN_ERR_PROT_LOC_CRC_DEL;
3130 }
3131 if (err_status & HECC_CANES_ACKE) {
3132 hecc_set_bit(priv, HECC_CANES, HECC_CANES_ACKE);
3133- cf->data[2] |= CAN_ERR_PROT_LOC_ACK |
3134+ cf->data[3] |= CAN_ERR_PROT_LOC_ACK |
3135 CAN_ERR_PROT_LOC_ACK_DEL;
3136 }
3137 }
3138diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
3139index 48cc4fb..b1b8e96 100644
3140--- a/drivers/net/ethernet/intel/igb/igb_main.c
3141+++ b/drivers/net/ethernet/intel/igb/igb_main.c
3142@@ -936,17 +936,18 @@ static int igb_request_msix(struct igb_adapter *adapter)
3143 {
3144 struct net_device *netdev = adapter->netdev;
3145 struct e1000_hw *hw = &adapter->hw;
3146- int i, err = 0, vector = 0;
3147+ int i, err = 0, vector = 0, free_vector = 0;
3148
3149 err = request_irq(adapter->msix_entries[vector].vector,
3150 igb_msix_other, 0, netdev->name, adapter);
3151 if (err)
3152- goto out;
3153- vector++;
3154+ goto err_out;
3155
3156 for (i = 0; i < adapter->num_q_vectors; i++) {
3157 struct igb_q_vector *q_vector = adapter->q_vector[i];
3158
3159+ vector++;
3160+
3161 q_vector->itr_register = hw->hw_addr + E1000_EITR(vector);
3162
3163 if (q_vector->rx.ring && q_vector->tx.ring)
3164@@ -965,13 +966,22 @@ static int igb_request_msix(struct igb_adapter *adapter)
3165 igb_msix_ring, 0, q_vector->name,
3166 q_vector);
3167 if (err)
3168- goto out;
3169- vector++;
3170+ goto err_free;
3171 }
3172
3173 igb_configure_msix(adapter);
3174 return 0;
3175-out:
3176+
3177+err_free:
3178+ /* free already assigned IRQs */
3179+ free_irq(adapter->msix_entries[free_vector++].vector, adapter);
3180+
3181+ vector--;
3182+ for (i = 0; i < vector; i++) {
3183+ free_irq(adapter->msix_entries[free_vector++].vector,
3184+ adapter->q_vector[i]);
3185+ }
3186+err_out:
3187 return err;
3188 }
3189
3190diff --git a/drivers/net/wimax/i2400m/i2400m-usb.h b/drivers/net/wimax/i2400m/i2400m-usb.h
3191index 6650fde..9f1e947 100644
3192--- a/drivers/net/wimax/i2400m/i2400m-usb.h
3193+++ b/drivers/net/wimax/i2400m/i2400m-usb.h
3194@@ -152,6 +152,9 @@ enum {
3195 /* Device IDs */
3196 USB_DEVICE_ID_I6050 = 0x0186,
3197 USB_DEVICE_ID_I6050_2 = 0x0188,
3198+ USB_DEVICE_ID_I6150 = 0x07d6,
3199+ USB_DEVICE_ID_I6150_2 = 0x07d7,
3200+ USB_DEVICE_ID_I6150_3 = 0x07d9,
3201 USB_DEVICE_ID_I6250 = 0x0187,
3202 };
3203
3204diff --git a/drivers/net/wimax/i2400m/usb.c b/drivers/net/wimax/i2400m/usb.c
3205index 713d033..080f363 100644
3206--- a/drivers/net/wimax/i2400m/usb.c
3207+++ b/drivers/net/wimax/i2400m/usb.c
3208@@ -510,6 +510,9 @@ int i2400mu_probe(struct usb_interface *iface,
3209 switch (id->idProduct) {
3210 case USB_DEVICE_ID_I6050:
3211 case USB_DEVICE_ID_I6050_2:
3212+ case USB_DEVICE_ID_I6150:
3213+ case USB_DEVICE_ID_I6150_2:
3214+ case USB_DEVICE_ID_I6150_3:
3215 case USB_DEVICE_ID_I6250:
3216 i2400mu->i6050 = 1;
3217 break;
3218@@ -759,6 +762,9 @@ static
3219 struct usb_device_id i2400mu_id_table[] = {
3220 { USB_DEVICE(0x8086, USB_DEVICE_ID_I6050) },
3221 { USB_DEVICE(0x8086, USB_DEVICE_ID_I6050_2) },
3222+ { USB_DEVICE(0x8087, USB_DEVICE_ID_I6150) },
3223+ { USB_DEVICE(0x8087, USB_DEVICE_ID_I6150_2) },
3224+ { USB_DEVICE(0x8087, USB_DEVICE_ID_I6150_3) },
3225 { USB_DEVICE(0x8086, USB_DEVICE_ID_I6250) },
3226 { USB_DEVICE(0x8086, 0x0181) },
3227 { USB_DEVICE(0x8086, 0x1403) },
3228diff --git a/drivers/net/wireless/ath/ath5k/base.c b/drivers/net/wireless/ath/ath5k/base.c
3229index 2aab20e..68a4046 100644
3230--- a/drivers/net/wireless/ath/ath5k/base.c
3231+++ b/drivers/net/wireless/ath/ath5k/base.c
3232@@ -848,7 +848,7 @@ ath5k_txbuf_free_skb(struct ath5k_hw *ah, struct ath5k_buf *bf)
3233 return;
3234 dma_unmap_single(ah->dev, bf->skbaddr, bf->skb->len,
3235 DMA_TO_DEVICE);
3236- dev_kfree_skb_any(bf->skb);
3237+ ieee80211_free_txskb(ah->hw, bf->skb);
3238 bf->skb = NULL;
3239 bf->skbaddr = 0;
3240 bf->desc->ds_data = 0;
3241@@ -1575,7 +1575,7 @@ ath5k_tx_queue(struct ieee80211_hw *hw, struct sk_buff *skb,
3242 return;
3243
3244 drop_packet:
3245- dev_kfree_skb_any(skb);
3246+ ieee80211_free_txskb(hw, skb);
3247 }
3248
3249 static void
3250diff --git a/drivers/net/wireless/ath/ath5k/mac80211-ops.c b/drivers/net/wireless/ath/ath5k/mac80211-ops.c
3251index d56453e..b010a77 100644
3252--- a/drivers/net/wireless/ath/ath5k/mac80211-ops.c
3253+++ b/drivers/net/wireless/ath/ath5k/mac80211-ops.c
3254@@ -61,7 +61,7 @@ ath5k_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
3255 u16 qnum = skb_get_queue_mapping(skb);
3256
3257 if (WARN_ON(qnum >= ah->ah_capabilities.cap_queues.q_tx_num)) {
3258- dev_kfree_skb_any(skb);
3259+ ieee80211_free_txskb(hw, skb);
3260 return;
3261 }
3262
3263diff --git a/drivers/net/wireless/ath/ath9k/ar9003_2p2_initvals.h b/drivers/net/wireless/ath/ath9k/ar9003_2p2_initvals.h
3264index 6f7cf49..262e1e0 100644
3265--- a/drivers/net/wireless/ath/ath9k/ar9003_2p2_initvals.h
3266+++ b/drivers/net/wireless/ath/ath9k/ar9003_2p2_initvals.h
3267@@ -534,98 +534,98 @@ static const u32 ar9300_2p2_baseband_core[][2] = {
3268
3269 static const u32 ar9300Modes_high_power_tx_gain_table_2p2[][5] = {
3270 /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */
3271- {0x0000a2dc, 0x00033800, 0x00033800, 0x03aaa352, 0x03aaa352},
3272- {0x0000a2e0, 0x0003c000, 0x0003c000, 0x03ccc584, 0x03ccc584},
3273- {0x0000a2e4, 0x03fc0000, 0x03fc0000, 0x03f0f800, 0x03f0f800},
3274+ {0x0000a2dc, 0x0380c7fc, 0x0380c7fc, 0x03aaa352, 0x03aaa352},
3275+ {0x0000a2e0, 0x0000f800, 0x0000f800, 0x03ccc584, 0x03ccc584},
3276+ {0x0000a2e4, 0x03ff0000, 0x03ff0000, 0x03f0f800, 0x03f0f800},
3277 {0x0000a2e8, 0x00000000, 0x00000000, 0x03ff0000, 0x03ff0000},
3278- {0x0000a410, 0x000050d9, 0x000050d9, 0x000050d9, 0x000050d9},
3279- {0x0000a500, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
3280- {0x0000a504, 0x06000003, 0x06000003, 0x04000002, 0x04000002},
3281- {0x0000a508, 0x0a000020, 0x0a000020, 0x08000004, 0x08000004},
3282- {0x0000a50c, 0x10000023, 0x10000023, 0x0b000200, 0x0b000200},
3283- {0x0000a510, 0x16000220, 0x16000220, 0x0f000202, 0x0f000202},
3284- {0x0000a514, 0x1c000223, 0x1c000223, 0x12000400, 0x12000400},
3285- {0x0000a518, 0x21002220, 0x21002220, 0x16000402, 0x16000402},
3286- {0x0000a51c, 0x27002223, 0x27002223, 0x19000404, 0x19000404},
3287- {0x0000a520, 0x2b022220, 0x2b022220, 0x1c000603, 0x1c000603},
3288- {0x0000a524, 0x2f022222, 0x2f022222, 0x21000a02, 0x21000a02},
3289- {0x0000a528, 0x34022225, 0x34022225, 0x25000a04, 0x25000a04},
3290- {0x0000a52c, 0x3a02222a, 0x3a02222a, 0x28000a20, 0x28000a20},
3291- {0x0000a530, 0x3e02222c, 0x3e02222c, 0x2c000e20, 0x2c000e20},
3292- {0x0000a534, 0x4202242a, 0x4202242a, 0x30000e22, 0x30000e22},
3293- {0x0000a538, 0x4702244a, 0x4702244a, 0x34000e24, 0x34000e24},
3294- {0x0000a53c, 0x4b02244c, 0x4b02244c, 0x38001640, 0x38001640},
3295- {0x0000a540, 0x4e02246c, 0x4e02246c, 0x3c001660, 0x3c001660},
3296- {0x0000a544, 0x52022470, 0x52022470, 0x3f001861, 0x3f001861},
3297- {0x0000a548, 0x55022490, 0x55022490, 0x43001a81, 0x43001a81},
3298- {0x0000a54c, 0x59022492, 0x59022492, 0x47001a83, 0x47001a83},
3299- {0x0000a550, 0x5d022692, 0x5d022692, 0x4a001c84, 0x4a001c84},
3300- {0x0000a554, 0x61022892, 0x61022892, 0x4e001ce3, 0x4e001ce3},
3301- {0x0000a558, 0x65024890, 0x65024890, 0x52001ce5, 0x52001ce5},
3302- {0x0000a55c, 0x69024892, 0x69024892, 0x56001ce9, 0x56001ce9},
3303- {0x0000a560, 0x6e024c92, 0x6e024c92, 0x5a001ceb, 0x5a001ceb},
3304- {0x0000a564, 0x74026e92, 0x74026e92, 0x5d001eec, 0x5d001eec},
3305- {0x0000a568, 0x74026e92, 0x74026e92, 0x5d001eec, 0x5d001eec},
3306- {0x0000a56c, 0x74026e92, 0x74026e92, 0x5d001eec, 0x5d001eec},
3307- {0x0000a570, 0x74026e92, 0x74026e92, 0x5d001eec, 0x5d001eec},
3308- {0x0000a574, 0x74026e92, 0x74026e92, 0x5d001eec, 0x5d001eec},
3309- {0x0000a578, 0x74026e92, 0x74026e92, 0x5d001eec, 0x5d001eec},
3310- {0x0000a57c, 0x74026e92, 0x74026e92, 0x5d001eec, 0x5d001eec},
3311- {0x0000a580, 0x00800000, 0x00800000, 0x00800000, 0x00800000},
3312- {0x0000a584, 0x06800003, 0x06800003, 0x04800002, 0x04800002},
3313- {0x0000a588, 0x0a800020, 0x0a800020, 0x08800004, 0x08800004},
3314- {0x0000a58c, 0x10800023, 0x10800023, 0x0b800200, 0x0b800200},
3315- {0x0000a590, 0x16800220, 0x16800220, 0x0f800202, 0x0f800202},
3316- {0x0000a594, 0x1c800223, 0x1c800223, 0x12800400, 0x12800400},
3317- {0x0000a598, 0x21802220, 0x21802220, 0x16800402, 0x16800402},
3318- {0x0000a59c, 0x27802223, 0x27802223, 0x19800404, 0x19800404},
3319- {0x0000a5a0, 0x2b822220, 0x2b822220, 0x1c800603, 0x1c800603},
3320- {0x0000a5a4, 0x2f822222, 0x2f822222, 0x21800a02, 0x21800a02},
3321- {0x0000a5a8, 0x34822225, 0x34822225, 0x25800a04, 0x25800a04},
3322- {0x0000a5ac, 0x3a82222a, 0x3a82222a, 0x28800a20, 0x28800a20},
3323- {0x0000a5b0, 0x3e82222c, 0x3e82222c, 0x2c800e20, 0x2c800e20},
3324- {0x0000a5b4, 0x4282242a, 0x4282242a, 0x30800e22, 0x30800e22},
3325- {0x0000a5b8, 0x4782244a, 0x4782244a, 0x34800e24, 0x34800e24},
3326- {0x0000a5bc, 0x4b82244c, 0x4b82244c, 0x38801640, 0x38801640},
3327- {0x0000a5c0, 0x4e82246c, 0x4e82246c, 0x3c801660, 0x3c801660},
3328- {0x0000a5c4, 0x52822470, 0x52822470, 0x3f801861, 0x3f801861},
3329- {0x0000a5c8, 0x55822490, 0x55822490, 0x43801a81, 0x43801a81},
3330- {0x0000a5cc, 0x59822492, 0x59822492, 0x47801a83, 0x47801a83},
3331- {0x0000a5d0, 0x5d822692, 0x5d822692, 0x4a801c84, 0x4a801c84},
3332- {0x0000a5d4, 0x61822892, 0x61822892, 0x4e801ce3, 0x4e801ce3},
3333- {0x0000a5d8, 0x65824890, 0x65824890, 0x52801ce5, 0x52801ce5},
3334- {0x0000a5dc, 0x69824892, 0x69824892, 0x56801ce9, 0x56801ce9},
3335- {0x0000a5e0, 0x6e824c92, 0x6e824c92, 0x5a801ceb, 0x5a801ceb},
3336- {0x0000a5e4, 0x74826e92, 0x74826e92, 0x5d801eec, 0x5d801eec},
3337- {0x0000a5e8, 0x74826e92, 0x74826e92, 0x5d801eec, 0x5d801eec},
3338- {0x0000a5ec, 0x74826e92, 0x74826e92, 0x5d801eec, 0x5d801eec},
3339- {0x0000a5f0, 0x74826e92, 0x74826e92, 0x5d801eec, 0x5d801eec},
3340- {0x0000a5f4, 0x74826e92, 0x74826e92, 0x5d801eec, 0x5d801eec},
3341- {0x0000a5f8, 0x74826e92, 0x74826e92, 0x5d801eec, 0x5d801eec},
3342- {0x0000a5fc, 0x74826e92, 0x74826e92, 0x5d801eec, 0x5d801eec},
3343+ {0x0000a410, 0x000050d8, 0x000050d8, 0x000050d9, 0x000050d9},
3344+ {0x0000a500, 0x00002220, 0x00002220, 0x00000000, 0x00000000},
3345+ {0x0000a504, 0x04002222, 0x04002222, 0x04000002, 0x04000002},
3346+ {0x0000a508, 0x09002421, 0x09002421, 0x08000004, 0x08000004},
3347+ {0x0000a50c, 0x0d002621, 0x0d002621, 0x0b000200, 0x0b000200},
3348+ {0x0000a510, 0x13004620, 0x13004620, 0x0f000202, 0x0f000202},
3349+ {0x0000a514, 0x19004a20, 0x19004a20, 0x11000400, 0x11000400},
3350+ {0x0000a518, 0x1d004e20, 0x1d004e20, 0x15000402, 0x15000402},
3351+ {0x0000a51c, 0x21005420, 0x21005420, 0x19000404, 0x19000404},
3352+ {0x0000a520, 0x26005e20, 0x26005e20, 0x1b000603, 0x1b000603},
3353+ {0x0000a524, 0x2b005e40, 0x2b005e40, 0x1f000a02, 0x1f000a02},
3354+ {0x0000a528, 0x2f005e42, 0x2f005e42, 0x23000a04, 0x23000a04},
3355+ {0x0000a52c, 0x33005e44, 0x33005e44, 0x26000a20, 0x26000a20},
3356+ {0x0000a530, 0x38005e65, 0x38005e65, 0x2a000e20, 0x2a000e20},
3357+ {0x0000a534, 0x3c005e69, 0x3c005e69, 0x2e000e22, 0x2e000e22},
3358+ {0x0000a538, 0x40005e6b, 0x40005e6b, 0x31000e24, 0x31000e24},
3359+ {0x0000a53c, 0x44005e6d, 0x44005e6d, 0x34001640, 0x34001640},
3360+ {0x0000a540, 0x49005e72, 0x49005e72, 0x38001660, 0x38001660},
3361+ {0x0000a544, 0x4e005eb2, 0x4e005eb2, 0x3b001861, 0x3b001861},
3362+ {0x0000a548, 0x53005f12, 0x53005f12, 0x3e001a81, 0x3e001a81},
3363+ {0x0000a54c, 0x59025eb2, 0x59025eb2, 0x42001a83, 0x42001a83},
3364+ {0x0000a550, 0x5e025f12, 0x5e025f12, 0x44001c84, 0x44001c84},
3365+ {0x0000a554, 0x61027f12, 0x61027f12, 0x48001ce3, 0x48001ce3},
3366+ {0x0000a558, 0x6702bf12, 0x6702bf12, 0x4c001ce5, 0x4c001ce5},
3367+ {0x0000a55c, 0x6b02bf14, 0x6b02bf14, 0x50001ce9, 0x50001ce9},
3368+ {0x0000a560, 0x6f02bf16, 0x6f02bf16, 0x54001ceb, 0x54001ceb},
3369+ {0x0000a564, 0x6f02bf16, 0x6f02bf16, 0x56001eec, 0x56001eec},
3370+ {0x0000a568, 0x6f02bf16, 0x6f02bf16, 0x56001eec, 0x56001eec},
3371+ {0x0000a56c, 0x6f02bf16, 0x6f02bf16, 0x56001eec, 0x56001eec},
3372+ {0x0000a570, 0x6f02bf16, 0x6f02bf16, 0x56001eec, 0x56001eec},
3373+ {0x0000a574, 0x6f02bf16, 0x6f02bf16, 0x56001eec, 0x56001eec},
3374+ {0x0000a578, 0x6f02bf16, 0x6f02bf16, 0x56001eec, 0x56001eec},
3375+ {0x0000a57c, 0x6f02bf16, 0x6f02bf16, 0x56001eec, 0x56001eec},
3376+ {0x0000a580, 0x00802220, 0x00802220, 0x00800000, 0x00800000},
3377+ {0x0000a584, 0x04802222, 0x04802222, 0x04800002, 0x04800002},
3378+ {0x0000a588, 0x09802421, 0x09802421, 0x08800004, 0x08800004},
3379+ {0x0000a58c, 0x0d802621, 0x0d802621, 0x0b800200, 0x0b800200},
3380+ {0x0000a590, 0x13804620, 0x13804620, 0x0f800202, 0x0f800202},
3381+ {0x0000a594, 0x19804a20, 0x19804a20, 0x11800400, 0x11800400},
3382+ {0x0000a598, 0x1d804e20, 0x1d804e20, 0x15800402, 0x15800402},
3383+ {0x0000a59c, 0x21805420, 0x21805420, 0x19800404, 0x19800404},
3384+ {0x0000a5a0, 0x26805e20, 0x26805e20, 0x1b800603, 0x1b800603},
3385+ {0x0000a5a4, 0x2b805e40, 0x2b805e40, 0x1f800a02, 0x1f800a02},
3386+ {0x0000a5a8, 0x2f805e42, 0x2f805e42, 0x23800a04, 0x23800a04},
3387+ {0x0000a5ac, 0x33805e44, 0x33805e44, 0x26800a20, 0x26800a20},
3388+ {0x0000a5b0, 0x38805e65, 0x38805e65, 0x2a800e20, 0x2a800e20},
3389+ {0x0000a5b4, 0x3c805e69, 0x3c805e69, 0x2e800e22, 0x2e800e22},
3390+ {0x0000a5b8, 0x40805e6b, 0x40805e6b, 0x31800e24, 0x31800e24},
3391+ {0x0000a5bc, 0x44805e6d, 0x44805e6d, 0x34801640, 0x34801640},
3392+ {0x0000a5c0, 0x49805e72, 0x49805e72, 0x38801660, 0x38801660},
3393+ {0x0000a5c4, 0x4e805eb2, 0x4e805eb2, 0x3b801861, 0x3b801861},
3394+ {0x0000a5c8, 0x53805f12, 0x53805f12, 0x3e801a81, 0x3e801a81},
3395+ {0x0000a5cc, 0x59825eb2, 0x59825eb2, 0x42801a83, 0x42801a83},
3396+ {0x0000a5d0, 0x5e825f12, 0x5e825f12, 0x44801c84, 0x44801c84},
3397+ {0x0000a5d4, 0x61827f12, 0x61827f12, 0x48801ce3, 0x48801ce3},
3398+ {0x0000a5d8, 0x6782bf12, 0x6782bf12, 0x4c801ce5, 0x4c801ce5},
3399+ {0x0000a5dc, 0x6b82bf14, 0x6b82bf14, 0x50801ce9, 0x50801ce9},
3400+ {0x0000a5e0, 0x6f82bf16, 0x6f82bf16, 0x54801ceb, 0x54801ceb},
3401+ {0x0000a5e4, 0x6f82bf16, 0x6f82bf16, 0x56801eec, 0x56801eec},
3402+ {0x0000a5e8, 0x6f82bf16, 0x6f82bf16, 0x56801eec, 0x56801eec},
3403+ {0x0000a5ec, 0x6f82bf16, 0x6f82bf16, 0x56801eec, 0x56801eec},
3404+ {0x0000a5f0, 0x6f82bf16, 0x6f82bf16, 0x56801eec, 0x56801eec},
3405+ {0x0000a5f4, 0x6f82bf16, 0x6f82bf16, 0x56801eec, 0x56801eec},
3406+ {0x0000a5f8, 0x6f82bf16, 0x6f82bf16, 0x56801eec, 0x56801eec},
3407+ {0x0000a5fc, 0x6f82bf16, 0x6f82bf16, 0x56801eec, 0x56801eec},
3408 {0x0000a600, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
3409 {0x0000a604, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
3410 {0x0000a608, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
3411 {0x0000a60c, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
3412- {0x0000a610, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
3413- {0x0000a614, 0x02004000, 0x02004000, 0x01404000, 0x01404000},
3414- {0x0000a618, 0x02004801, 0x02004801, 0x01404501, 0x01404501},
3415- {0x0000a61c, 0x02808a02, 0x02808a02, 0x02008501, 0x02008501},
3416- {0x0000a620, 0x0380ce03, 0x0380ce03, 0x0280ca03, 0x0280ca03},
3417- {0x0000a624, 0x04411104, 0x04411104, 0x03010c04, 0x03010c04},
3418- {0x0000a628, 0x04411104, 0x04411104, 0x04014c04, 0x04014c04},
3419- {0x0000a62c, 0x04411104, 0x04411104, 0x04015005, 0x04015005},
3420- {0x0000a630, 0x04411104, 0x04411104, 0x04015005, 0x04015005},
3421- {0x0000a634, 0x04411104, 0x04411104, 0x04015005, 0x04015005},
3422- {0x0000a638, 0x04411104, 0x04411104, 0x04015005, 0x04015005},
3423- {0x0000a63c, 0x04411104, 0x04411104, 0x04015005, 0x04015005},
3424- {0x0000b2dc, 0x00033800, 0x00033800, 0x03aaa352, 0x03aaa352},
3425- {0x0000b2e0, 0x0003c000, 0x0003c000, 0x03ccc584, 0x03ccc584},
3426- {0x0000b2e4, 0x03fc0000, 0x03fc0000, 0x03f0f800, 0x03f0f800},
3427+ {0x0000a610, 0x00804000, 0x00804000, 0x00000000, 0x00000000},
3428+ {0x0000a614, 0x00804201, 0x00804201, 0x01404000, 0x01404000},
3429+ {0x0000a618, 0x0280c802, 0x0280c802, 0x01404501, 0x01404501},
3430+ {0x0000a61c, 0x0280ca03, 0x0280ca03, 0x02008501, 0x02008501},
3431+ {0x0000a620, 0x04c15104, 0x04c15104, 0x0280ca03, 0x0280ca03},
3432+ {0x0000a624, 0x04c15305, 0x04c15305, 0x03010c04, 0x03010c04},
3433+ {0x0000a628, 0x04c15305, 0x04c15305, 0x04014c04, 0x04014c04},
3434+ {0x0000a62c, 0x04c15305, 0x04c15305, 0x04015005, 0x04015005},
3435+ {0x0000a630, 0x04c15305, 0x04c15305, 0x04015005, 0x04015005},
3436+ {0x0000a634, 0x04c15305, 0x04c15305, 0x04015005, 0x04015005},
3437+ {0x0000a638, 0x04c15305, 0x04c15305, 0x04015005, 0x04015005},
3438+ {0x0000a63c, 0x04c15305, 0x04c15305, 0x04015005, 0x04015005},
3439+ {0x0000b2dc, 0x0380c7fc, 0x0380c7fc, 0x03aaa352, 0x03aaa352},
3440+ {0x0000b2e0, 0x0000f800, 0x0000f800, 0x03ccc584, 0x03ccc584},
3441+ {0x0000b2e4, 0x03ff0000, 0x03ff0000, 0x03f0f800, 0x03f0f800},
3442 {0x0000b2e8, 0x00000000, 0x00000000, 0x03ff0000, 0x03ff0000},
3443- {0x0000c2dc, 0x00033800, 0x00033800, 0x03aaa352, 0x03aaa352},
3444- {0x0000c2e0, 0x0003c000, 0x0003c000, 0x03ccc584, 0x03ccc584},
3445- {0x0000c2e4, 0x03fc0000, 0x03fc0000, 0x03f0f800, 0x03f0f800},
3446+ {0x0000c2dc, 0x0380c7fc, 0x0380c7fc, 0x03aaa352, 0x03aaa352},
3447+ {0x0000c2e0, 0x0000f800, 0x0000f800, 0x03ccc584, 0x03ccc584},
3448+ {0x0000c2e4, 0x03ff0000, 0x03ff0000, 0x03f0f800, 0x03f0f800},
3449 {0x0000c2e8, 0x00000000, 0x00000000, 0x03ff0000, 0x03ff0000},
3450 {0x00016044, 0x012492d4, 0x012492d4, 0x012492d4, 0x012492d4},
3451 {0x00016048, 0x66480001, 0x66480001, 0x66480001, 0x66480001},
3452diff --git a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.h b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.h
3453index 3a1ff55..a633aea 100644
3454--- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.h
3455+++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.h
3456@@ -68,13 +68,13 @@
3457 #define AR9300_BASE_ADDR 0x3ff
3458 #define AR9300_BASE_ADDR_512 0x1ff
3459
3460-#define AR9300_OTP_BASE 0x14000
3461-#define AR9300_OTP_STATUS 0x15f18
3462+#define AR9300_OTP_BASE (AR_SREV_9340(ah) ? 0x30000 : 0x14000)
3463+#define AR9300_OTP_STATUS (AR_SREV_9340(ah) ? 0x30018 : 0x15f18)
3464 #define AR9300_OTP_STATUS_TYPE 0x7
3465 #define AR9300_OTP_STATUS_VALID 0x4
3466 #define AR9300_OTP_STATUS_ACCESS_BUSY 0x2
3467 #define AR9300_OTP_STATUS_SM_BUSY 0x1
3468-#define AR9300_OTP_READ_DATA 0x15f1c
3469+#define AR9300_OTP_READ_DATA (AR_SREV_9340(ah) ? 0x3001c : 0x15f1c)
3470
3471 enum targetPowerHTRates {
3472 HT_TARGET_RATE_0_8_16,
3473diff --git a/drivers/net/wireless/ath/ath9k/beacon.c b/drivers/net/wireless/ath/ath9k/beacon.c
3474index 1b48414..4527d0d 100644
3475--- a/drivers/net/wireless/ath/ath9k/beacon.c
3476+++ b/drivers/net/wireless/ath/ath9k/beacon.c
3477@@ -147,6 +147,7 @@ static struct ath_buf *ath9k_beacon_generate(struct ieee80211_hw *hw,
3478 skb->len, DMA_TO_DEVICE);
3479 dev_kfree_skb_any(skb);
3480 bf->bf_buf_addr = 0;
3481+ bf->bf_mpdu = NULL;
3482 }
3483
3484 skb = ieee80211_beacon_get(hw, vif);
3485diff --git a/drivers/net/wireless/ath/ath9k/calib.c b/drivers/net/wireless/ath/ath9k/calib.c
3486index e5cceb0..bbd249d 100644
3487--- a/drivers/net/wireless/ath/ath9k/calib.c
3488+++ b/drivers/net/wireless/ath/ath9k/calib.c
3489@@ -69,6 +69,7 @@ s16 ath9k_hw_getchan_noise(struct ath_hw *ah, struct ath9k_channel *chan)
3490
3491 if (chan && chan->noisefloor) {
3492 s8 delta = chan->noisefloor -
3493+ ATH9K_NF_CAL_NOISE_THRESH -
3494 ath9k_hw_get_default_nf(ah, chan);
3495 if (delta > 0)
3496 noise += delta;
3497diff --git a/drivers/net/wireless/ath/ath9k/calib.h b/drivers/net/wireless/ath/ath9k/calib.h
3498index 1060c19..60dcb6c 100644
3499--- a/drivers/net/wireless/ath/ath9k/calib.h
3500+++ b/drivers/net/wireless/ath/ath9k/calib.h
3501@@ -21,6 +21,9 @@
3502
3503 #define AR_PHY_CCA_FILTERWINDOW_LENGTH 5
3504
3505+/* Internal noise floor can vary by about 6db depending on the frequency */
3506+#define ATH9K_NF_CAL_NOISE_THRESH 6
3507+
3508 #define NUM_NF_READINGS 6
3509 #define ATH9K_NF_CAL_HIST_MAX 5
3510
3511diff --git a/drivers/net/wireless/ath/ath9k/htc_hst.c b/drivers/net/wireless/ath/ath9k/htc_hst.c
3512index 4a9570d..aac4a40 100644
3513--- a/drivers/net/wireless/ath/ath9k/htc_hst.c
3514+++ b/drivers/net/wireless/ath/ath9k/htc_hst.c
3515@@ -344,6 +344,8 @@ void ath9k_htc_txcompletion_cb(struct htc_target *htc_handle,
3516 endpoint->ep_callbacks.tx(endpoint->ep_callbacks.priv,
3517 skb, htc_hdr->endpoint_id,
3518 txok);
3519+ } else {
3520+ kfree_skb(skb);
3521 }
3522 }
3523
3524diff --git a/drivers/net/wireless/ath/ath9k/recv.c b/drivers/net/wireless/ath/ath9k/recv.c
3525index 4480c0c..6b12d48 100644
3526--- a/drivers/net/wireless/ath/ath9k/recv.c
3527+++ b/drivers/net/wireless/ath/ath9k/recv.c
3528@@ -744,6 +744,7 @@ static struct ath_buf *ath_get_next_rx_buf(struct ath_softc *sc,
3529 return NULL;
3530 }
3531
3532+ list_del(&bf->list);
3533 if (!bf->bf_mpdu)
3534 return bf;
3535
3536@@ -1251,14 +1252,15 @@ requeue_drop_frag:
3537 sc->rx.frag = NULL;
3538 }
3539 requeue:
3540+ list_add_tail(&bf->list, &sc->rx.rxbuf);
3541+ if (flush)
3542+ continue;
3543+
3544 if (edma) {
3545- list_add_tail(&bf->list, &sc->rx.rxbuf);
3546 ath_rx_edma_buf_link(sc, qtype);
3547 } else {
3548- list_move_tail(&bf->list, &sc->rx.rxbuf);
3549 ath_rx_buf_link(sc, bf);
3550- if (!flush)
3551- ath9k_hw_rxena(ah);
3552+ ath9k_hw_rxena(ah);
3553 }
3554 } while (1);
3555
3556diff --git a/drivers/net/wireless/b43/b43.h b/drivers/net/wireless/b43/b43.h
3557index 7c899fc..ac593ab 100644
3558--- a/drivers/net/wireless/b43/b43.h
3559+++ b/drivers/net/wireless/b43/b43.h
3560@@ -7,6 +7,7 @@
3561 #include <linux/hw_random.h>
3562 #include <linux/bcma/bcma.h>
3563 #include <linux/ssb/ssb.h>
3564+#include <linux/completion.h>
3565 #include <net/mac80211.h>
3566
3567 #include "debugfs.h"
3568@@ -718,6 +719,10 @@ enum b43_firmware_file_type {
3569 struct b43_request_fw_context {
3570 /* The device we are requesting the fw for. */
3571 struct b43_wldev *dev;
3572+ /* a completion event structure needed if this call is asynchronous */
3573+ struct completion fw_load_complete;
3574+ /* a pointer to the firmware object */
3575+ const struct firmware *blob;
3576 /* The type of firmware to request. */
3577 enum b43_firmware_file_type req_type;
3578 /* Error messages for each firmware type. */
3579diff --git a/drivers/net/wireless/b43/dma.c b/drivers/net/wireless/b43/dma.c
3580index 777cd74..38bc5a7 100644
3581--- a/drivers/net/wireless/b43/dma.c
3582+++ b/drivers/net/wireless/b43/dma.c
3583@@ -409,7 +409,10 @@ static inline
3584 struct b43_dmadesc_meta *meta)
3585 {
3586 if (meta->skb) {
3587- dev_kfree_skb_any(meta->skb);
3588+ if (ring->tx)
3589+ ieee80211_free_txskb(ring->dev->wl->hw, meta->skb);
3590+ else
3591+ dev_kfree_skb_any(meta->skb);
3592 meta->skb = NULL;
3593 }
3594 }
3595@@ -1454,7 +1457,7 @@ int b43_dma_tx(struct b43_wldev *dev, struct sk_buff *skb)
3596 if (unlikely(err == -ENOKEY)) {
3597 /* Drop this packet, as we don't have the encryption key
3598 * anymore and must not transmit it unencrypted. */
3599- dev_kfree_skb_any(skb);
3600+ ieee80211_free_txskb(dev->wl->hw, skb);
3601 err = 0;
3602 goto out;
3603 }
3604diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c
3605index 46d9d4e..b70bc2d 100644
3606--- a/drivers/net/wireless/b43/main.c
3607+++ b/drivers/net/wireless/b43/main.c
3608@@ -2088,11 +2088,18 @@ static void b43_print_fw_helptext(struct b43_wl *wl, bool error)
3609 b43warn(wl, text);
3610 }
3611
3612+static void b43_fw_cb(const struct firmware *firmware, void *context)
3613+{
3614+ struct b43_request_fw_context *ctx = context;
3615+
3616+ ctx->blob = firmware;
3617+ complete(&ctx->fw_load_complete);
3618+}
3619+
3620 int b43_do_request_fw(struct b43_request_fw_context *ctx,
3621 const char *name,
3622- struct b43_firmware_file *fw)
3623+ struct b43_firmware_file *fw, bool async)
3624 {
3625- const struct firmware *blob;
3626 struct b43_fw_header *hdr;
3627 u32 size;
3628 int err;
3629@@ -2131,11 +2138,31 @@ int b43_do_request_fw(struct b43_request_fw_context *ctx,
3630 B43_WARN_ON(1);
3631 return -ENOSYS;
3632 }
3633- err = request_firmware(&blob, ctx->fwname, ctx->dev->dev->dev);
3634+ if (async) {
3635+ /* do this part asynchronously */
3636+ init_completion(&ctx->fw_load_complete);
3637+ err = request_firmware_nowait(THIS_MODULE, 1, ctx->fwname,
3638+ ctx->dev->dev->dev, GFP_KERNEL,
3639+ ctx, b43_fw_cb);
3640+ if (err < 0) {
3641+ pr_err("Unable to load firmware\n");
3642+ return err;
3643+ }
3644+ /* stall here until fw ready */
3645+ wait_for_completion(&ctx->fw_load_complete);
3646+ if (ctx->blob)
3647+ goto fw_ready;
3648+ /* On some ARM systems, the async request will fail, but the next sync
3649+ * request works. For this reason, we dall through here
3650+ */
3651+ }
3652+ err = request_firmware(&ctx->blob, ctx->fwname,
3653+ ctx->dev->dev->dev);
3654 if (err == -ENOENT) {
3655 snprintf(ctx->errors[ctx->req_type],
3656 sizeof(ctx->errors[ctx->req_type]),
3657- "Firmware file \"%s\" not found\n", ctx->fwname);
3658+ "Firmware file \"%s\" not found\n",
3659+ ctx->fwname);
3660 return err;
3661 } else if (err) {
3662 snprintf(ctx->errors[ctx->req_type],
3663@@ -2144,14 +2171,15 @@ int b43_do_request_fw(struct b43_request_fw_context *ctx,
3664 ctx->fwname, err);
3665 return err;
3666 }
3667- if (blob->size < sizeof(struct b43_fw_header))
3668+fw_ready:
3669+ if (ctx->blob->size < sizeof(struct b43_fw_header))
3670 goto err_format;
3671- hdr = (struct b43_fw_header *)(blob->data);
3672+ hdr = (struct b43_fw_header *)(ctx->blob->data);
3673 switch (hdr->type) {
3674 case B43_FW_TYPE_UCODE:
3675 case B43_FW_TYPE_PCM:
3676 size = be32_to_cpu(hdr->size);
3677- if (size != blob->size - sizeof(struct b43_fw_header))
3678+ if (size != ctx->blob->size - sizeof(struct b43_fw_header))
3679 goto err_format;
3680 /* fallthrough */
3681 case B43_FW_TYPE_IV:
3682@@ -2162,7 +2190,7 @@ int b43_do_request_fw(struct b43_request_fw_context *ctx,
3683 goto err_format;
3684 }
3685
3686- fw->data = blob;
3687+ fw->data = ctx->blob;
3688 fw->filename = name;
3689 fw->type = ctx->req_type;
3690
3691@@ -2172,7 +2200,7 @@ err_format:
3692 snprintf(ctx->errors[ctx->req_type],
3693 sizeof(ctx->errors[ctx->req_type]),
3694 "Firmware file \"%s\" format error.\n", ctx->fwname);
3695- release_firmware(blob);
3696+ release_firmware(ctx->blob);
3697
3698 return -EPROTO;
3699 }
3700@@ -2223,7 +2251,7 @@ static int b43_try_request_fw(struct b43_request_fw_context *ctx)
3701 goto err_no_ucode;
3702 }
3703 }
3704- err = b43_do_request_fw(ctx, filename, &fw->ucode);
3705+ err = b43_do_request_fw(ctx, filename, &fw->ucode, true);
3706 if (err)
3707 goto err_load;
3708
3709@@ -2235,7 +2263,7 @@ static int b43_try_request_fw(struct b43_request_fw_context *ctx)
3710 else
3711 goto err_no_pcm;
3712 fw->pcm_request_failed = false;
3713- err = b43_do_request_fw(ctx, filename, &fw->pcm);
3714+ err = b43_do_request_fw(ctx, filename, &fw->pcm, false);
3715 if (err == -ENOENT) {
3716 /* We did not find a PCM file? Not fatal, but
3717 * core rev <= 10 must do without hwcrypto then. */
3718@@ -2296,7 +2324,7 @@ static int b43_try_request_fw(struct b43_request_fw_context *ctx)
3719 default:
3720 goto err_no_initvals;
3721 }
3722- err = b43_do_request_fw(ctx, filename, &fw->initvals);
3723+ err = b43_do_request_fw(ctx, filename, &fw->initvals, false);
3724 if (err)
3725 goto err_load;
3726
3727@@ -2355,7 +2383,7 @@ static int b43_try_request_fw(struct b43_request_fw_context *ctx)
3728 default:
3729 goto err_no_initvals;
3730 }
3731- err = b43_do_request_fw(ctx, filename, &fw->initvals_band);
3732+ err = b43_do_request_fw(ctx, filename, &fw->initvals_band, false);
3733 if (err)
3734 goto err_load;
3735
3736@@ -3397,7 +3425,7 @@ static void b43_tx_work(struct work_struct *work)
3737 break;
3738 }
3739 if (unlikely(err))
3740- dev_kfree_skb(skb); /* Drop it */
3741+ ieee80211_free_txskb(wl->hw, skb);
3742 err = 0;
3743 }
3744
3745@@ -3418,7 +3446,7 @@ static void b43_op_tx(struct ieee80211_hw *hw,
3746
3747 if (unlikely(skb->len < 2 + 2 + 6)) {
3748 /* Too short, this can't be a valid frame. */
3749- dev_kfree_skb_any(skb);
3750+ ieee80211_free_txskb(hw, skb);
3751 return;
3752 }
3753 B43_WARN_ON(skb_shinfo(skb)->nr_frags);
3754@@ -4228,8 +4256,12 @@ redo:
3755
3756 /* Drain all TX queues. */
3757 for (queue_num = 0; queue_num < B43_QOS_QUEUE_NUM; queue_num++) {
3758- while (skb_queue_len(&wl->tx_queue[queue_num]))
3759- dev_kfree_skb(skb_dequeue(&wl->tx_queue[queue_num]));
3760+ while (skb_queue_len(&wl->tx_queue[queue_num])) {
3761+ struct sk_buff *skb;
3762+
3763+ skb = skb_dequeue(&wl->tx_queue[queue_num]);
3764+ ieee80211_free_txskb(wl->hw, skb);
3765+ }
3766 }
3767
3768 b43_mac_suspend(dev);
3769diff --git a/drivers/net/wireless/b43/main.h b/drivers/net/wireless/b43/main.h
3770index 8c684cd..abac25e 100644
3771--- a/drivers/net/wireless/b43/main.h
3772+++ b/drivers/net/wireless/b43/main.h
3773@@ -137,9 +137,8 @@ void b43_mac_phy_clock_set(struct b43_wldev *dev, bool on);
3774
3775
3776 struct b43_request_fw_context;
3777-int b43_do_request_fw(struct b43_request_fw_context *ctx,
3778- const char *name,
3779- struct b43_firmware_file *fw);
3780+int b43_do_request_fw(struct b43_request_fw_context *ctx, const char *name,
3781+ struct b43_firmware_file *fw, bool async);
3782 void b43_do_release_fw(struct b43_firmware_file *fw);
3783
3784 #endif /* B43_MAIN_H_ */
3785diff --git a/drivers/net/wireless/b43/pio.c b/drivers/net/wireless/b43/pio.c
3786index 3533ab8..a73ff8c 100644
3787--- a/drivers/net/wireless/b43/pio.c
3788+++ b/drivers/net/wireless/b43/pio.c
3789@@ -196,7 +196,7 @@ static void b43_pio_cancel_tx_packets(struct b43_pio_txqueue *q)
3790 for (i = 0; i < ARRAY_SIZE(q->packets); i++) {
3791 pack = &(q->packets[i]);
3792 if (pack->skb) {
3793- dev_kfree_skb_any(pack->skb);
3794+ ieee80211_free_txskb(q->dev->wl->hw, pack->skb);
3795 pack->skb = NULL;
3796 }
3797 }
3798@@ -552,7 +552,7 @@ int b43_pio_tx(struct b43_wldev *dev, struct sk_buff *skb)
3799 if (unlikely(err == -ENOKEY)) {
3800 /* Drop this packet, as we don't have the encryption key
3801 * anymore and must not transmit it unencrypted. */
3802- dev_kfree_skb_any(skb);
3803+ ieee80211_free_txskb(dev->wl->hw, skb);
3804 err = 0;
3805 goto out;
3806 }
3807diff --git a/drivers/net/wireless/b43legacy/b43legacy.h b/drivers/net/wireless/b43legacy/b43legacy.h
3808index a29da67..482476f 100644
3809--- a/drivers/net/wireless/b43legacy/b43legacy.h
3810+++ b/drivers/net/wireless/b43legacy/b43legacy.h
3811@@ -13,6 +13,7 @@
3812
3813 #include <linux/ssb/ssb.h>
3814 #include <linux/ssb/ssb_driver_chipcommon.h>
3815+#include <linux/completion.h>
3816
3817 #include <net/mac80211.h>
3818
3819@@ -733,6 +734,10 @@ struct b43legacy_wldev {
3820
3821 /* Firmware data */
3822 struct b43legacy_firmware fw;
3823+ const struct firmware *fwp; /* needed to pass fw pointer */
3824+
3825+ /* completion struct for firmware loading */
3826+ struct completion fw_load_complete;
3827
3828 /* Devicelist in struct b43legacy_wl (all 802.11 cores) */
3829 struct list_head list;
3830diff --git a/drivers/net/wireless/b43legacy/main.c b/drivers/net/wireless/b43legacy/main.c
3831index 0ef08e0..aa87fb7 100644
3832--- a/drivers/net/wireless/b43legacy/main.c
3833+++ b/drivers/net/wireless/b43legacy/main.c
3834@@ -1513,9 +1513,17 @@ static void b43legacy_print_fw_helptext(struct b43legacy_wl *wl)
3835 "and download the correct firmware (version 3).\n");
3836 }
3837
3838+static void b43legacy_fw_cb(const struct firmware *firmware, void *context)
3839+{
3840+ struct b43legacy_wldev *dev = context;
3841+
3842+ dev->fwp = firmware;
3843+ complete(&dev->fw_load_complete);
3844+}
3845+
3846 static int do_request_fw(struct b43legacy_wldev *dev,
3847 const char *name,
3848- const struct firmware **fw)
3849+ const struct firmware **fw, bool async)
3850 {
3851 char path[sizeof(modparam_fwpostfix) + 32];
3852 struct b43legacy_fw_header *hdr;
3853@@ -1528,7 +1536,24 @@ static int do_request_fw(struct b43legacy_wldev *dev,
3854 snprintf(path, ARRAY_SIZE(path),
3855 "b43legacy%s/%s.fw",
3856 modparam_fwpostfix, name);
3857- err = request_firmware(fw, path, dev->dev->dev);
3858+ b43legacyinfo(dev->wl, "Loading firmware %s\n", path);
3859+ if (async) {
3860+ init_completion(&dev->fw_load_complete);
3861+ err = request_firmware_nowait(THIS_MODULE, 1, path,
3862+ dev->dev->dev, GFP_KERNEL,
3863+ dev, b43legacy_fw_cb);
3864+ if (err) {
3865+ b43legacyerr(dev->wl, "Unable to load firmware\n");
3866+ return err;
3867+ }
3868+ /* stall here until fw ready */
3869+ wait_for_completion(&dev->fw_load_complete);
3870+ if (!dev->fwp)
3871+ err = -EINVAL;
3872+ *fw = dev->fwp;
3873+ } else {
3874+ err = request_firmware(fw, path, dev->dev->dev);
3875+ }
3876 if (err) {
3877 b43legacyerr(dev->wl, "Firmware file \"%s\" not found "
3878 "or load failed.\n", path);
3879@@ -1580,7 +1605,7 @@ static void b43legacy_request_firmware(struct work_struct *work)
3880 filename = "ucode4";
3881 else
3882 filename = "ucode5";
3883- err = do_request_fw(dev, filename, &fw->ucode);
3884+ err = do_request_fw(dev, filename, &fw->ucode, true);
3885 if (err)
3886 goto err_load;
3887 }
3888@@ -1589,7 +1614,7 @@ static void b43legacy_request_firmware(struct work_struct *work)
3889 filename = "pcm4";
3890 else
3891 filename = "pcm5";
3892- err = do_request_fw(dev, filename, &fw->pcm);
3893+ err = do_request_fw(dev, filename, &fw->pcm, false);
3894 if (err)
3895 goto err_load;
3896 }
3897@@ -1607,7 +1632,7 @@ static void b43legacy_request_firmware(struct work_struct *work)
3898 default:
3899 goto err_no_initvals;
3900 }
3901- err = do_request_fw(dev, filename, &fw->initvals);
3902+ err = do_request_fw(dev, filename, &fw->initvals, false);
3903 if (err)
3904 goto err_load;
3905 }
3906@@ -1627,7 +1652,7 @@ static void b43legacy_request_firmware(struct work_struct *work)
3907 default:
3908 goto err_no_initvals;
3909 }
3910- err = do_request_fw(dev, filename, &fw->initvals_band);
3911+ err = do_request_fw(dev, filename, &fw->initvals_band, false);
3912 if (err)
3913 goto err_load;
3914 }
3915diff --git a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
3916index a5edebe..c110674 100644
3917--- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
3918+++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
3919@@ -1394,9 +1394,10 @@ void brcms_add_timer(struct brcms_timer *t, uint ms, int periodic)
3920 #endif
3921 t->ms = ms;
3922 t->periodic = (bool) periodic;
3923- t->set = true;
3924-
3925- atomic_inc(&t->wl->callbacks);
3926+ if (!t->set) {
3927+ t->set = true;
3928+ atomic_inc(&t->wl->callbacks);
3929+ }
3930
3931 ieee80211_queue_delayed_work(hw, &t->dly_wrk, msecs_to_jiffies(ms));
3932 }
3933diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c
3934index 0370403..27eccd9 100644
3935--- a/drivers/net/wireless/iwlegacy/common.c
3936+++ b/drivers/net/wireless/iwlegacy/common.c
3937@@ -3957,17 +3957,21 @@ il_connection_init_rx_config(struct il_priv *il)
3938
3939 memset(&il->staging, 0, sizeof(il->staging));
3940
3941- if (!il->vif) {
3942+ switch (il->iw_mode) {
3943+ case NL80211_IFTYPE_UNSPECIFIED:
3944 il->staging.dev_type = RXON_DEV_TYPE_ESS;
3945- } else if (il->vif->type == NL80211_IFTYPE_STATION) {
3946+ break;
3947+ case NL80211_IFTYPE_STATION:
3948 il->staging.dev_type = RXON_DEV_TYPE_ESS;
3949 il->staging.filter_flags = RXON_FILTER_ACCEPT_GRP_MSK;
3950- } else if (il->vif->type == NL80211_IFTYPE_ADHOC) {
3951+ break;
3952+ case NL80211_IFTYPE_ADHOC:
3953 il->staging.dev_type = RXON_DEV_TYPE_IBSS;
3954 il->staging.flags = RXON_FLG_SHORT_PREAMBLE_MSK;
3955 il->staging.filter_flags =
3956 RXON_FILTER_BCON_AWARE_MSK | RXON_FILTER_ACCEPT_GRP_MSK;
3957- } else {
3958+ break;
3959+ default:
3960 IL_ERR("Unsupported interface type %d\n", il->vif->type);
3961 return;
3962 }
3963@@ -4550,8 +4554,7 @@ out:
3964 EXPORT_SYMBOL(il_mac_add_interface);
3965
3966 static void
3967-il_teardown_interface(struct il_priv *il, struct ieee80211_vif *vif,
3968- bool mode_change)
3969+il_teardown_interface(struct il_priv *il, struct ieee80211_vif *vif)
3970 {
3971 lockdep_assert_held(&il->mutex);
3972
3973@@ -4560,9 +4563,7 @@ il_teardown_interface(struct il_priv *il, struct ieee80211_vif *vif,
3974 il_force_scan_end(il);
3975 }
3976
3977- if (!mode_change)
3978- il_set_mode(il);
3979-
3980+ il_set_mode(il);
3981 }
3982
3983 void
3984@@ -4575,8 +4576,8 @@ il_mac_remove_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
3985
3986 WARN_ON(il->vif != vif);
3987 il->vif = NULL;
3988-
3989- il_teardown_interface(il, vif, false);
3990+ il->iw_mode = NL80211_IFTYPE_UNSPECIFIED;
3991+ il_teardown_interface(il, vif);
3992 memset(il->bssid, 0, ETH_ALEN);
3993
3994 D_MAC80211("leave\n");
3995@@ -4685,18 +4686,10 @@ il_mac_change_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
3996 }
3997
3998 /* success */
3999- il_teardown_interface(il, vif, true);
4000 vif->type = newtype;
4001 vif->p2p = false;
4002- err = il_set_mode(il);
4003- WARN_ON(err);
4004- /*
4005- * We've switched internally, but submitting to the
4006- * device may have failed for some reason. Mask this
4007- * error, because otherwise mac80211 will not switch
4008- * (and set the interface type back) and we'll be
4009- * out of sync with it.
4010- */
4011+ il->iw_mode = newtype;
4012+ il_teardown_interface(il, vif);
4013 err = 0;
4014
4015 out:
4016diff --git a/drivers/net/wireless/mwifiex/pcie.c b/drivers/net/wireless/mwifiex/pcie.c
4017index 13fbc4e..b879e13 100644
4018--- a/drivers/net/wireless/mwifiex/pcie.c
4019+++ b/drivers/net/wireless/mwifiex/pcie.c
4020@@ -161,7 +161,7 @@ static int mwifiex_pcie_suspend(struct pci_dev *pdev, pm_message_t state)
4021
4022 if (pdev) {
4023 card = (struct pcie_service_card *) pci_get_drvdata(pdev);
4024- if (!card || card->adapter) {
4025+ if (!card || !card->adapter) {
4026 pr_err("Card or adapter structure is not valid\n");
4027 return 0;
4028 }
4029diff --git a/drivers/net/wireless/mwifiex/sta_ioctl.c b/drivers/net/wireless/mwifiex/sta_ioctl.c
4030index fb21360..8951285 100644
4031--- a/drivers/net/wireless/mwifiex/sta_ioctl.c
4032+++ b/drivers/net/wireless/mwifiex/sta_ioctl.c
4033@@ -53,7 +53,6 @@ int mwifiex_copy_mcast_addr(struct mwifiex_multicast_list *mlist,
4034 */
4035 int mwifiex_wait_queue_complete(struct mwifiex_adapter *adapter)
4036 {
4037- bool cancel_flag = false;
4038 int status;
4039 struct cmd_ctrl_node *cmd_queued;
4040
4041@@ -67,14 +66,11 @@ int mwifiex_wait_queue_complete(struct mwifiex_adapter *adapter)
4042 atomic_inc(&adapter->cmd_pending);
4043
4044 /* Wait for completion */
4045- wait_event_interruptible(adapter->cmd_wait_q.wait,
4046- *(cmd_queued->condition));
4047- if (!*(cmd_queued->condition))
4048- cancel_flag = true;
4049-
4050- if (cancel_flag) {
4051- mwifiex_cancel_pending_ioctl(adapter);
4052- dev_dbg(adapter->dev, "cmd cancel\n");
4053+ status = wait_event_interruptible(adapter->cmd_wait_q.wait,
4054+ *(cmd_queued->condition));
4055+ if (status) {
4056+ dev_err(adapter->dev, "cmd_wait_q terminated: %d\n", status);
4057+ return status;
4058 }
4059
4060 status = adapter->cmd_wait_q.status;
4061@@ -427,8 +423,11 @@ int mwifiex_enable_hs(struct mwifiex_adapter *adapter)
4062 return false;
4063 }
4064
4065- wait_event_interruptible(adapter->hs_activate_wait_q,
4066- adapter->hs_activate_wait_q_woken);
4067+ if (wait_event_interruptible(adapter->hs_activate_wait_q,
4068+ adapter->hs_activate_wait_q_woken)) {
4069+ dev_err(adapter->dev, "hs_activate_wait_q terminated\n");
4070+ return false;
4071+ }
4072
4073 return true;
4074 }
4075diff --git a/drivers/net/wireless/p54/p54usb.c b/drivers/net/wireless/p54/p54usb.c
4076index effb044..4191294 100644
4077--- a/drivers/net/wireless/p54/p54usb.c
4078+++ b/drivers/net/wireless/p54/p54usb.c
4079@@ -47,6 +47,7 @@ static struct usb_device_id p54u_table[] = {
4080 {USB_DEVICE(0x0411, 0x0050)}, /* Buffalo WLI2-USB2-G54 */
4081 {USB_DEVICE(0x045e, 0x00c2)}, /* Microsoft MN-710 */
4082 {USB_DEVICE(0x0506, 0x0a11)}, /* 3COM 3CRWE254G72 */
4083+ {USB_DEVICE(0x0675, 0x0530)}, /* DrayTek Vigor 530 */
4084 {USB_DEVICE(0x06b9, 0x0120)}, /* Thomson SpeedTouch 120g */
4085 {USB_DEVICE(0x0707, 0xee06)}, /* SMC 2862W-G */
4086 {USB_DEVICE(0x07aa, 0x001c)}, /* Corega CG-WLUSB2GT */
4087@@ -82,6 +83,8 @@ static struct usb_device_id p54u_table[] = {
4088 {USB_DEVICE(0x06a9, 0x000e)}, /* Westell 802.11g USB (A90-211WG-01) */
4089 {USB_DEVICE(0x06b9, 0x0121)}, /* Thomson SpeedTouch 121g */
4090 {USB_DEVICE(0x0707, 0xee13)}, /* SMC 2862W-G version 2 */
4091+ {USB_DEVICE(0x0803, 0x4310)}, /* Zoom 4410a */
4092+ {USB_DEVICE(0x083a, 0x4503)}, /* T-Com Sinus 154 data II */
4093 {USB_DEVICE(0x083a, 0x4521)}, /* Siemens Gigaset USB Adapter 54 version 2 */
4094 {USB_DEVICE(0x083a, 0xc501)}, /* Zoom Wireless-G 4410 */
4095 {USB_DEVICE(0x083a, 0xf503)}, /* Accton FD7050E ver 1010ec */
4096@@ -101,6 +104,7 @@ static struct usb_device_id p54u_table[] = {
4097 {USB_DEVICE(0x13B1, 0x000C)}, /* Linksys WUSB54AG */
4098 {USB_DEVICE(0x1413, 0x5400)}, /* Telsey 802.11g USB2.0 Adapter */
4099 {USB_DEVICE(0x1435, 0x0427)}, /* Inventel UR054G */
4100+ /* {USB_DEVICE(0x15a9, 0x0002)}, * Also SparkLAN WL-682 with 3887 */
4101 {USB_DEVICE(0x1668, 0x1050)}, /* Actiontec 802UIG-1 */
4102 {USB_DEVICE(0x1740, 0x1000)}, /* Senao NUB-350 */
4103 {USB_DEVICE(0x2001, 0x3704)}, /* DLink DWL-G122 rev A2 */
4104diff --git a/drivers/net/wireless/rtlwifi/usb.c b/drivers/net/wireless/rtlwifi/usb.c
4105index aa970fc..8fa144f 100644
4106--- a/drivers/net/wireless/rtlwifi/usb.c
4107+++ b/drivers/net/wireless/rtlwifi/usb.c
4108@@ -210,17 +210,16 @@ static void _usb_writeN_sync(struct rtl_priv *rtlpriv, u32 addr, void *data,
4109 u16 index = REALTEK_USB_VENQT_CMD_IDX;
4110 int pipe = usb_sndctrlpipe(udev, 0); /* write_out */
4111 u8 *buffer;
4112- dma_addr_t dma_addr;
4113
4114- wvalue = (u16)(addr&0x0000ffff);
4115- buffer = usb_alloc_coherent(udev, (size_t)len, GFP_ATOMIC, &dma_addr);
4116+ wvalue = (u16)(addr & 0x0000ffff);
4117+ buffer = kmalloc(len, GFP_ATOMIC);
4118 if (!buffer)
4119 return;
4120 memcpy(buffer, data, len);
4121 usb_control_msg(udev, pipe, request, reqtype, wvalue,
4122 index, buffer, len, 50);
4123
4124- usb_free_coherent(udev, (size_t)len, buffer, dma_addr);
4125+ kfree(buffer);
4126 }
4127
4128 static void _rtl_usb_io_handler_init(struct device *dev,
4129diff --git a/drivers/pci/hotplug/pciehp.h b/drivers/pci/hotplug/pciehp.h
4130index 26ffd3e..2c113de 100644
4131--- a/drivers/pci/hotplug/pciehp.h
4132+++ b/drivers/pci/hotplug/pciehp.h
4133@@ -44,7 +44,6 @@ extern bool pciehp_poll_mode;
4134 extern int pciehp_poll_time;
4135 extern bool pciehp_debug;
4136 extern bool pciehp_force;
4137-extern struct workqueue_struct *pciehp_wq;
4138
4139 #define dbg(format, arg...) \
4140 do { \
4141@@ -78,6 +77,7 @@ struct slot {
4142 struct hotplug_slot *hotplug_slot;
4143 struct delayed_work work; /* work for button event */
4144 struct mutex lock;
4145+ struct workqueue_struct *wq;
4146 };
4147
4148 struct event_info {
4149diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
4150index 365c6b9..9e39df9 100644
4151--- a/drivers/pci/hotplug/pciehp_core.c
4152+++ b/drivers/pci/hotplug/pciehp_core.c
4153@@ -42,7 +42,6 @@ bool pciehp_debug;
4154 bool pciehp_poll_mode;
4155 int pciehp_poll_time;
4156 bool pciehp_force;
4157-struct workqueue_struct *pciehp_wq;
4158
4159 #define DRIVER_VERSION "0.4"
4160 #define DRIVER_AUTHOR "Dan Zink <dan.zink@compaq.com>, Greg Kroah-Hartman <greg@kroah.com>, Dely Sy <dely.l.sy@intel.com>"
4161@@ -340,18 +339,13 @@ static int __init pcied_init(void)
4162 {
4163 int retval = 0;
4164
4165- pciehp_wq = alloc_workqueue("pciehp", 0, 0);
4166- if (!pciehp_wq)
4167- return -ENOMEM;
4168-
4169 pciehp_firmware_init();
4170 retval = pcie_port_service_register(&hpdriver_portdrv);
4171 dbg("pcie_port_service_register = %d\n", retval);
4172 info(DRIVER_DESC " version: " DRIVER_VERSION "\n");
4173- if (retval) {
4174- destroy_workqueue(pciehp_wq);
4175+ if (retval)
4176 dbg("Failure to register service\n");
4177- }
4178+
4179 return retval;
4180 }
4181
4182@@ -359,7 +353,6 @@ static void __exit pcied_cleanup(void)
4183 {
4184 dbg("unload_pciehpd()\n");
4185 pcie_port_service_unregister(&hpdriver_portdrv);
4186- destroy_workqueue(pciehp_wq);
4187 info(DRIVER_DESC " version: " DRIVER_VERSION " unloaded\n");
4188 }
4189
4190diff --git a/drivers/pci/hotplug/pciehp_ctrl.c b/drivers/pci/hotplug/pciehp_ctrl.c
4191index 27f4429..38f0186 100644
4192--- a/drivers/pci/hotplug/pciehp_ctrl.c
4193+++ b/drivers/pci/hotplug/pciehp_ctrl.c
4194@@ -49,7 +49,7 @@ static int queue_interrupt_event(struct slot *p_slot, u32 event_type)
4195 info->p_slot = p_slot;
4196 INIT_WORK(&info->work, interrupt_event_handler);
4197
4198- queue_work(pciehp_wq, &info->work);
4199+ queue_work(p_slot->wq, &info->work);
4200
4201 return 0;
4202 }
4203@@ -344,7 +344,7 @@ void pciehp_queue_pushbutton_work(struct work_struct *work)
4204 kfree(info);
4205 goto out;
4206 }
4207- queue_work(pciehp_wq, &info->work);
4208+ queue_work(p_slot->wq, &info->work);
4209 out:
4210 mutex_unlock(&p_slot->lock);
4211 }
4212@@ -377,7 +377,7 @@ static void handle_button_press_event(struct slot *p_slot)
4213 if (ATTN_LED(ctrl))
4214 pciehp_set_attention_status(p_slot, 0);
4215
4216- queue_delayed_work(pciehp_wq, &p_slot->work, 5*HZ);
4217+ queue_delayed_work(p_slot->wq, &p_slot->work, 5*HZ);
4218 break;
4219 case BLINKINGOFF_STATE:
4220 case BLINKINGON_STATE:
4221@@ -439,7 +439,7 @@ static void handle_surprise_event(struct slot *p_slot)
4222 else
4223 p_slot->state = POWERON_STATE;
4224
4225- queue_work(pciehp_wq, &info->work);
4226+ queue_work(p_slot->wq, &info->work);
4227 }
4228
4229 static void interrupt_event_handler(struct work_struct *work)
4230diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c
4231index 302451e..61632c5 100644
4232--- a/drivers/pci/hotplug/pciehp_hpc.c
4233+++ b/drivers/pci/hotplug/pciehp_hpc.c
4234@@ -773,23 +773,32 @@ static void pcie_shutdown_notification(struct controller *ctrl)
4235 static int pcie_init_slot(struct controller *ctrl)
4236 {
4237 struct slot *slot;
4238+ char name[32];
4239
4240 slot = kzalloc(sizeof(*slot), GFP_KERNEL);
4241 if (!slot)
4242 return -ENOMEM;
4243
4244+ snprintf(name, sizeof(name), "pciehp-%u", PSN(ctrl));
4245+ slot->wq = alloc_workqueue(name, 0, 0);
4246+ if (!slot->wq)
4247+ goto abort;
4248+
4249 slot->ctrl = ctrl;
4250 mutex_init(&slot->lock);
4251 INIT_DELAYED_WORK(&slot->work, pciehp_queue_pushbutton_work);
4252 ctrl->slot = slot;
4253 return 0;
4254+abort:
4255+ kfree(slot);
4256+ return -ENOMEM;
4257 }
4258
4259 static void pcie_cleanup_slot(struct controller *ctrl)
4260 {
4261 struct slot *slot = ctrl->slot;
4262 cancel_delayed_work(&slot->work);
4263- flush_workqueue(pciehp_wq);
4264+ destroy_workqueue(slot->wq);
4265 kfree(slot);
4266 }
4267
4268diff --git a/drivers/pci/hotplug/shpchp.h b/drivers/pci/hotplug/shpchp.h
4269index ca64932..1b69d95 100644
4270--- a/drivers/pci/hotplug/shpchp.h
4271+++ b/drivers/pci/hotplug/shpchp.h
4272@@ -47,7 +47,6 @@ extern bool shpchp_poll_mode;
4273 extern int shpchp_poll_time;
4274 extern bool shpchp_debug;
4275 extern struct workqueue_struct *shpchp_wq;
4276-extern struct workqueue_struct *shpchp_ordered_wq;
4277
4278 #define dbg(format, arg...) \
4279 do { \
4280diff --git a/drivers/pci/hotplug/shpchp_core.c b/drivers/pci/hotplug/shpchp_core.c
4281index b6de307..8c6d645 100644
4282--- a/drivers/pci/hotplug/shpchp_core.c
4283+++ b/drivers/pci/hotplug/shpchp_core.c
4284@@ -40,7 +40,6 @@ bool shpchp_debug;
4285 bool shpchp_poll_mode;
4286 int shpchp_poll_time;
4287 struct workqueue_struct *shpchp_wq;
4288-struct workqueue_struct *shpchp_ordered_wq;
4289
4290 #define DRIVER_VERSION "0.4"
4291 #define DRIVER_AUTHOR "Dan Zink <dan.zink@compaq.com>, Greg Kroah-Hartman <greg@kroah.com>, Dely Sy <dely.l.sy@intel.com>"
4292@@ -181,7 +180,6 @@ void cleanup_slots(struct controller *ctrl)
4293 list_del(&slot->slot_list);
4294 cancel_delayed_work(&slot->work);
4295 flush_workqueue(shpchp_wq);
4296- flush_workqueue(shpchp_ordered_wq);
4297 pci_hp_deregister(slot->hotplug_slot);
4298 }
4299 }
4300@@ -370,17 +368,10 @@ static int __init shpcd_init(void)
4301 if (!shpchp_wq)
4302 return -ENOMEM;
4303
4304- shpchp_ordered_wq = alloc_ordered_workqueue("shpchp_ordered", 0);
4305- if (!shpchp_ordered_wq) {
4306- destroy_workqueue(shpchp_wq);
4307- return -ENOMEM;
4308- }
4309-
4310 retval = pci_register_driver(&shpc_driver);
4311 dbg("%s: pci_register_driver = %d\n", __func__, retval);
4312 info(DRIVER_DESC " version: " DRIVER_VERSION "\n");
4313 if (retval) {
4314- destroy_workqueue(shpchp_ordered_wq);
4315 destroy_workqueue(shpchp_wq);
4316 }
4317 return retval;
4318@@ -390,7 +381,6 @@ static void __exit shpcd_cleanup(void)
4319 {
4320 dbg("unload_shpchpd()\n");
4321 pci_unregister_driver(&shpc_driver);
4322- destroy_workqueue(shpchp_ordered_wq);
4323 destroy_workqueue(shpchp_wq);
4324 info(DRIVER_DESC " version: " DRIVER_VERSION " unloaded\n");
4325 }
4326diff --git a/drivers/pci/hotplug/shpchp_ctrl.c b/drivers/pci/hotplug/shpchp_ctrl.c
4327index f9b5a52..fd2cae9 100644
4328--- a/drivers/pci/hotplug/shpchp_ctrl.c
4329+++ b/drivers/pci/hotplug/shpchp_ctrl.c
4330@@ -453,7 +453,7 @@ void shpchp_queue_pushbutton_work(struct work_struct *work)
4331 kfree(info);
4332 goto out;
4333 }
4334- queue_work(shpchp_ordered_wq, &info->work);
4335+ queue_work(shpchp_wq, &info->work);
4336 out:
4337 mutex_unlock(&p_slot->lock);
4338 }
4339diff --git a/drivers/pci/pcie/aer/aerdrv_core.c b/drivers/pci/pcie/aer/aerdrv_core.c
4340index 1b7d05d..b0c92a5 100644
4341--- a/drivers/pci/pcie/aer/aerdrv_core.c
4342+++ b/drivers/pci/pcie/aer/aerdrv_core.c
4343@@ -649,6 +649,7 @@ static void aer_recover_work_func(struct work_struct *work)
4344 continue;
4345 }
4346 do_recovery(pdev, entry.severity);
4347+ pci_dev_put(pdev);
4348 }
4349 }
4350 #endif
4351diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
4352index b500840..474f22f 100644
4353--- a/drivers/pci/pcie/aspm.c
4354+++ b/drivers/pci/pcie/aspm.c
4355@@ -798,6 +798,9 @@ void pcie_clear_aspm(struct pci_bus *bus)
4356 {
4357 struct pci_dev *child;
4358
4359+ if (aspm_force)
4360+ return;
4361+
4362 /*
4363 * Clear any ASPM setup that the firmware has carried out on this bus
4364 */
4365diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
4366index 5155317..161e7f0 100644
4367--- a/drivers/pci/quirks.c
4368+++ b/drivers/pci/quirks.c
4369@@ -2686,7 +2686,7 @@ static void ricoh_mmc_fixup_r5c832(struct pci_dev *dev)
4370 if (PCI_FUNC(dev->devfn))
4371 return;
4372 /*
4373- * RICOH 0xe823 SD/MMC card reader fails to recognize
4374+ * RICOH 0xe822 and 0xe823 SD/MMC card readers fail to recognize
4375 * certain types of SD/MMC cards. Lowering the SD base
4376 * clock frequency from 200Mhz to 50Mhz fixes this issue.
4377 *
4378@@ -2697,7 +2697,8 @@ static void ricoh_mmc_fixup_r5c832(struct pci_dev *dev)
4379 * 0xf9 - Key register for 0x150
4380 * 0xfc - key register for 0xe1
4381 */
4382- if (dev->device == PCI_DEVICE_ID_RICOH_R5CE823) {
4383+ if (dev->device == PCI_DEVICE_ID_RICOH_R5CE822 ||
4384+ dev->device == PCI_DEVICE_ID_RICOH_R5CE823) {
4385 pci_write_config_byte(dev, 0xf9, 0xfc);
4386 pci_write_config_byte(dev, 0x150, 0x10);
4387 pci_write_config_byte(dev, 0xf9, 0x00);
4388@@ -2724,6 +2725,8 @@ static void ricoh_mmc_fixup_r5c832(struct pci_dev *dev)
4389 }
4390 DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_R5C832, ricoh_mmc_fixup_r5c832);
4391 DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_R5C832, ricoh_mmc_fixup_r5c832);
4392+DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_R5CE822, ricoh_mmc_fixup_r5c832);
4393+DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_R5CE822, ricoh_mmc_fixup_r5c832);
4394 DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_R5CE823, ricoh_mmc_fixup_r5c832);
4395 DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_R5CE823, ricoh_mmc_fixup_r5c832);
4396 #endif /*CONFIG_MMC_RICOH_MMC*/
4397diff --git a/drivers/platform/x86/samsung-laptop.c b/drivers/platform/x86/samsung-laptop.c
4398index dd90d15..71623a2 100644
4399--- a/drivers/platform/x86/samsung-laptop.c
4400+++ b/drivers/platform/x86/samsung-laptop.c
4401@@ -1523,6 +1523,16 @@ static struct dmi_system_id __initdata samsung_dmi_table[] = {
4402 },
4403 .driver_data = &samsung_broken_acpi_video,
4404 },
4405+ {
4406+ .callback = samsung_dmi_matched,
4407+ .ident = "N250P",
4408+ .matches = {
4409+ DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
4410+ DMI_MATCH(DMI_PRODUCT_NAME, "N250P"),
4411+ DMI_MATCH(DMI_BOARD_NAME, "N250P"),
4412+ },
4413+ .driver_data = &samsung_broken_acpi_video,
4414+ },
4415 { },
4416 };
4417 MODULE_DEVICE_TABLE(dmi, samsung_dmi_table);
4418diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c
4419index e49871d..3c5c353 100644
4420--- a/drivers/pnp/pnpacpi/core.c
4421+++ b/drivers/pnp/pnpacpi/core.c
4422@@ -58,7 +58,7 @@ static inline int __init is_exclusive_device(struct acpi_device *dev)
4423 if (!(('0' <= (c) && (c) <= '9') || ('A' <= (c) && (c) <= 'F'))) \
4424 return 0
4425 #define TEST_ALPHA(c) \
4426- if (!('@' <= (c) || (c) <= 'Z')) \
4427+ if (!('A' <= (c) && (c) <= 'Z')) \
4428 return 0
4429 static int __init ispnpidacpi(const char *id)
4430 {
4431diff --git a/drivers/regulator/wm831x-dcdc.c b/drivers/regulator/wm831x-dcdc.c
4432index 7413885..d4b9b1e 100644
4433--- a/drivers/regulator/wm831x-dcdc.c
4434+++ b/drivers/regulator/wm831x-dcdc.c
4435@@ -290,7 +290,7 @@ static int wm831x_buckv_set_voltage_sel(struct regulator_dev *rdev,
4436 if (vsel > dcdc->dvs_vsel) {
4437 ret = wm831x_set_bits(wm831x, dvs_reg,
4438 WM831X_DC1_DVS_VSEL_MASK,
4439- dcdc->dvs_vsel);
4440+ vsel);
4441 if (ret == 0)
4442 dcdc->dvs_vsel = vsel;
4443 else
4444diff --git a/drivers/rtc/rtc-vt8500.c b/drivers/rtc/rtc-vt8500.c
4445index 9e94fb1..44878da 100644
4446--- a/drivers/rtc/rtc-vt8500.c
4447+++ b/drivers/rtc/rtc-vt8500.c
4448@@ -69,7 +69,7 @@
4449 | ALARM_SEC_BIT)
4450
4451 #define VT8500_RTC_CR_ENABLE (1 << 0) /* Enable RTC */
4452-#define VT8500_RTC_CR_24H (1 << 1) /* 24h time format */
4453+#define VT8500_RTC_CR_12H (1 << 1) /* 12h time format */
4454 #define VT8500_RTC_CR_SM_ENABLE (1 << 2) /* Enable periodic irqs */
4455 #define VT8500_RTC_CR_SM_SEC (1 << 3) /* 0: 1Hz/60, 1: 1Hz */
4456 #define VT8500_RTC_CR_CALIB (1 << 4) /* Enable calibration */
4457@@ -118,7 +118,7 @@ static int vt8500_rtc_read_time(struct device *dev, struct rtc_time *tm)
4458 tm->tm_min = bcd2bin((time & TIME_MIN_MASK) >> TIME_MIN_S);
4459 tm->tm_hour = bcd2bin((time & TIME_HOUR_MASK) >> TIME_HOUR_S);
4460 tm->tm_mday = bcd2bin(date & DATE_DAY_MASK);
4461- tm->tm_mon = bcd2bin((date & DATE_MONTH_MASK) >> DATE_MONTH_S);
4462+ tm->tm_mon = bcd2bin((date & DATE_MONTH_MASK) >> DATE_MONTH_S) - 1;
4463 tm->tm_year = bcd2bin((date & DATE_YEAR_MASK) >> DATE_YEAR_S)
4464 + ((date >> DATE_CENTURY_S) & 1 ? 200 : 100);
4465 tm->tm_wday = (time & TIME_DOW_MASK) >> TIME_DOW_S;
4466@@ -137,8 +137,9 @@ static int vt8500_rtc_set_time(struct device *dev, struct rtc_time *tm)
4467 }
4468
4469 writel((bin2bcd(tm->tm_year - 100) << DATE_YEAR_S)
4470- | (bin2bcd(tm->tm_mon) << DATE_MONTH_S)
4471- | (bin2bcd(tm->tm_mday)),
4472+ | (bin2bcd(tm->tm_mon + 1) << DATE_MONTH_S)
4473+ | (bin2bcd(tm->tm_mday))
4474+ | ((tm->tm_year >= 200) << DATE_CENTURY_S),
4475 vt8500_rtc->regbase + VT8500_RTC_DS);
4476 writel((bin2bcd(tm->tm_wday) << TIME_DOW_S)
4477 | (bin2bcd(tm->tm_hour) << TIME_HOUR_S)
4478@@ -248,7 +249,7 @@ static int __devinit vt8500_rtc_probe(struct platform_device *pdev)
4479 }
4480
4481 /* Enable RTC and set it to 24-hour mode */
4482- writel(VT8500_RTC_CR_ENABLE | VT8500_RTC_CR_24H,
4483+ writel(VT8500_RTC_CR_ENABLE,
4484 vt8500_rtc->regbase + VT8500_RTC_CR);
4485
4486 vt8500_rtc->rtc = rtc_device_register("vt8500-rtc", &pdev->dev,
4487diff --git a/drivers/s390/cio/device_pgid.c b/drivers/s390/cio/device_pgid.c
4488index 368368f..908d287 100644
4489--- a/drivers/s390/cio/device_pgid.c
4490+++ b/drivers/s390/cio/device_pgid.c
4491@@ -234,7 +234,7 @@ static int pgid_cmp(struct pgid *p1, struct pgid *p2)
4492 * Determine pathgroup state from PGID data.
4493 */
4494 static void pgid_analyze(struct ccw_device *cdev, struct pgid **p,
4495- int *mismatch, int *reserved, u8 *reset)
4496+ int *mismatch, u8 *reserved, u8 *reset)
4497 {
4498 struct pgid *pgid = &cdev->private->pgid[0];
4499 struct pgid *first = NULL;
4500@@ -248,7 +248,7 @@ static void pgid_analyze(struct ccw_device *cdev, struct pgid **p,
4501 if ((cdev->private->pgid_valid_mask & lpm) == 0)
4502 continue;
4503 if (pgid->inf.ps.state2 == SNID_STATE2_RESVD_ELSE)
4504- *reserved = 1;
4505+ *reserved |= lpm;
4506 if (pgid_is_reset(pgid)) {
4507 *reset |= lpm;
4508 continue;
4509@@ -316,14 +316,14 @@ static void snid_done(struct ccw_device *cdev, int rc)
4510 struct subchannel *sch = to_subchannel(cdev->dev.parent);
4511 struct pgid *pgid;
4512 int mismatch = 0;
4513- int reserved = 0;
4514+ u8 reserved = 0;
4515 u8 reset = 0;
4516 u8 donepm;
4517
4518 if (rc)
4519 goto out;
4520 pgid_analyze(cdev, &pgid, &mismatch, &reserved, &reset);
4521- if (reserved)
4522+ if (reserved == cdev->private->pgid_valid_mask)
4523 rc = -EUSERS;
4524 else if (mismatch)
4525 rc = -EOPNOTSUPP;
4526@@ -336,7 +336,7 @@ static void snid_done(struct ccw_device *cdev, int rc)
4527 }
4528 out:
4529 CIO_MSG_EVENT(2, "snid: device 0.%x.%04x: rc=%d pvm=%02x vpm=%02x "
4530- "todo=%02x mism=%d rsvd=%d reset=%02x\n", id->ssid,
4531+ "todo=%02x mism=%d rsvd=%02x reset=%02x\n", id->ssid,
4532 id->devno, rc, cdev->private->pgid_valid_mask, sch->vpm,
4533 cdev->private->pgid_todo_mask, mismatch, reserved, reset);
4534 switch (rc) {
4535diff --git a/drivers/scsi/mvsas/mv_94xx.h b/drivers/scsi/mvsas/mv_94xx.h
4536index 8f7eb4f..487aa6f 100644
4537--- a/drivers/scsi/mvsas/mv_94xx.h
4538+++ b/drivers/scsi/mvsas/mv_94xx.h
4539@@ -258,21 +258,11 @@ enum sas_sata_phy_regs {
4540 #define SPI_ADDR_VLD_94XX (1U << 1)
4541 #define SPI_CTRL_SpiStart_94XX (1U << 0)
4542
4543-#define mv_ffc(x) ffz(x)
4544-
4545 static inline int
4546 mv_ffc64(u64 v)
4547 {
4548- int i;
4549- i = mv_ffc((u32)v);
4550- if (i >= 0)
4551- return i;
4552- i = mv_ffc((u32)(v>>32));
4553-
4554- if (i != 0)
4555- return 32 + i;
4556-
4557- return -1;
4558+ u64 x = ~v;
4559+ return x ? __ffs64(x) : -1;
4560 }
4561
4562 #define r_reg_set_enable(i) \
4563diff --git a/drivers/scsi/mvsas/mv_sas.c b/drivers/scsi/mvsas/mv_sas.c
4564index 4539d59..a3776d6 100644
4565--- a/drivers/scsi/mvsas/mv_sas.c
4566+++ b/drivers/scsi/mvsas/mv_sas.c
4567@@ -1629,7 +1629,7 @@ int mvs_abort_task(struct sas_task *task)
4568 mv_dprintk("mvs_abort_task() mvi=%p task=%p "
4569 "slot=%p slot_idx=x%x\n",
4570 mvi, task, slot, slot_idx);
4571- mvs_tmf_timedout((unsigned long)task);
4572+ task->task_state_flags |= SAS_TASK_STATE_ABORTED;
4573 mvs_slot_task_free(mvi, task, slot, slot_idx);
4574 rc = TMF_RESP_FUNC_COMPLETE;
4575 goto out;
4576diff --git a/drivers/scsi/mvsas/mv_sas.h b/drivers/scsi/mvsas/mv_sas.h
4577index c04a4f5..da24955 100644
4578--- a/drivers/scsi/mvsas/mv_sas.h
4579+++ b/drivers/scsi/mvsas/mv_sas.h
4580@@ -69,7 +69,7 @@ extern struct kmem_cache *mvs_task_list_cache;
4581 #define DEV_IS_EXPANDER(type) \
4582 ((type == EDGE_DEV) || (type == FANOUT_DEV))
4583
4584-#define bit(n) ((u32)1 << n)
4585+#define bit(n) ((u64)1 << n)
4586
4587 #define for_each_phy(__lseq_mask, __mc, __lseq) \
4588 for ((__mc) = (__lseq_mask), (__lseq) = 0; \
4589diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
4590index fb8cd38..0076210 100644
4591--- a/drivers/scsi/qla2xxx/qla_os.c
4592+++ b/drivers/scsi/qla2xxx/qla_os.c
4593@@ -3801,9 +3801,9 @@ qla2x00_do_dpc(void *data)
4594 "ISP abort end.\n");
4595 }
4596
4597- if (test_bit(FCPORT_UPDATE_NEEDED, &base_vha->dpc_flags)) {
4598+ if (test_and_clear_bit(FCPORT_UPDATE_NEEDED,
4599+ &base_vha->dpc_flags)) {
4600 qla2x00_update_fcports(base_vha);
4601- clear_bit(FCPORT_UPDATE_NEEDED, &base_vha->dpc_flags);
4602 }
4603
4604 if (test_bit(SCR_PENDING, &base_vha->dpc_flags)) {
4605diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
4606index ce5224c..931a7d9 100644
4607--- a/drivers/scsi/scsi_sysfs.c
4608+++ b/drivers/scsi/scsi_sysfs.c
4609@@ -247,11 +247,11 @@ show_shost_active_mode(struct device *dev,
4610
4611 static DEVICE_ATTR(active_mode, S_IRUGO | S_IWUSR, show_shost_active_mode, NULL);
4612
4613-static int check_reset_type(char *str)
4614+static int check_reset_type(const char *str)
4615 {
4616- if (strncmp(str, "adapter", 10) == 0)
4617+ if (sysfs_streq(str, "adapter"))
4618 return SCSI_ADAPTER_RESET;
4619- else if (strncmp(str, "firmware", 10) == 0)
4620+ else if (sysfs_streq(str, "firmware"))
4621 return SCSI_FIRMWARE_RESET;
4622 else
4623 return 0;
4624@@ -264,12 +264,9 @@ store_host_reset(struct device *dev, struct device_attribute *attr,
4625 struct Scsi_Host *shost = class_to_shost(dev);
4626 struct scsi_host_template *sht = shost->hostt;
4627 int ret = -EINVAL;
4628- char str[10];
4629 int type;
4630
4631- sscanf(buf, "%s", str);
4632- type = check_reset_type(str);
4633-
4634+ type = check_reset_type(buf);
4635 if (!type)
4636 goto exit_store_host_reset;
4637
4638diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
4639index 4df73e5..8afedd6 100644
4640--- a/drivers/scsi/sd.c
4641+++ b/drivers/scsi/sd.c
4642@@ -2926,10 +2926,6 @@ static int __init init_sd(void)
4643 if (err)
4644 goto err_out;
4645
4646- err = scsi_register_driver(&sd_template.gendrv);
4647- if (err)
4648- goto err_out_class;
4649-
4650 sd_cdb_cache = kmem_cache_create("sd_ext_cdb", SD_EXT_CDB_SIZE,
4651 0, 0, NULL);
4652 if (!sd_cdb_cache) {
4653@@ -2943,8 +2939,15 @@ static int __init init_sd(void)
4654 goto err_out_cache;
4655 }
4656
4657+ err = scsi_register_driver(&sd_template.gendrv);
4658+ if (err)
4659+ goto err_out_driver;
4660+
4661 return 0;
4662
4663+err_out_driver:
4664+ mempool_destroy(sd_cdb_pool);
4665+
4666 err_out_cache:
4667 kmem_cache_destroy(sd_cdb_cache);
4668
4669@@ -2967,10 +2970,10 @@ static void __exit exit_sd(void)
4670
4671 SCSI_LOG_HLQUEUE(3, printk("exit_sd: exiting sd driver\n"));
4672
4673+ scsi_unregister_driver(&sd_template.gendrv);
4674 mempool_destroy(sd_cdb_pool);
4675 kmem_cache_destroy(sd_cdb_cache);
4676
4677- scsi_unregister_driver(&sd_template.gendrv);
4678 class_unregister(&sd_disk_class);
4679
4680 for (i = 0; i < SD_MAJORS; i++)
4681diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig
4682index 6cee785..2701546 100644
4683--- a/drivers/staging/comedi/Kconfig
4684+++ b/drivers/staging/comedi/Kconfig
4685@@ -444,6 +444,7 @@ config COMEDI_ADQ12B
4686
4687 config COMEDI_NI_AT_A2150
4688 tristate "NI AT-A2150 ISA card support"
4689+ select COMEDI_FC
4690 depends on VIRT_TO_BUS
4691 ---help---
4692 Enable support for National Instruments AT-A2150 cards
4693diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c
4694index 41dea18..260441c 100644
4695--- a/drivers/staging/comedi/comedi_fops.c
4696+++ b/drivers/staging/comedi/comedi_fops.c
4697@@ -1547,6 +1547,9 @@ static long comedi_unlocked_ioctl(struct file *file, unsigned int cmd,
4698 if (cmd == COMEDI_DEVCONFIG) {
4699 rc = do_devconfig_ioctl(dev,
4700 (struct comedi_devconfig __user *)arg);
4701+ if (rc == 0)
4702+ /* Evade comedi_auto_unconfig(). */
4703+ dev_file_info->hardware_device = NULL;
4704 goto done;
4705 }
4706
4707diff --git a/drivers/staging/comedi/drivers/comedi_test.c b/drivers/staging/comedi/drivers/comedi_test.c
4708index 523a809..e38bd64 100644
4709--- a/drivers/staging/comedi/drivers/comedi_test.c
4710+++ b/drivers/staging/comedi/drivers/comedi_test.c
4711@@ -396,7 +396,7 @@ static int waveform_ai_cancel(struct comedi_device *dev,
4712 struct comedi_subdevice *s)
4713 {
4714 devpriv->timer_running = 0;
4715- del_timer(&devpriv->timer);
4716+ del_timer_sync(&devpriv->timer);
4717 return 0;
4718 }
4719
4720diff --git a/drivers/staging/comedi/drivers/ni_pcimio.c b/drivers/staging/comedi/drivers/ni_pcimio.c
4721index 89f4d43..af5007c 100644
4722--- a/drivers/staging/comedi/drivers/ni_pcimio.c
4723+++ b/drivers/staging/comedi/drivers/ni_pcimio.c
4724@@ -963,7 +963,7 @@ static const struct ni_board_struct ni_boards[] = {
4725 .ao_range_table = &range_ni_M_625x_ao,
4726 .reg_type = ni_reg_625x,
4727 .ao_unipolar = 0,
4728- .ao_speed = 357,
4729+ .ao_speed = 350,
4730 .num_p0_dio_channels = 8,
4731 .caldac = {caldac_none},
4732 .has_8255 = 0,
4733@@ -982,7 +982,7 @@ static const struct ni_board_struct ni_boards[] = {
4734 .ao_range_table = &range_ni_M_625x_ao,
4735 .reg_type = ni_reg_625x,
4736 .ao_unipolar = 0,
4737- .ao_speed = 357,
4738+ .ao_speed = 350,
4739 .num_p0_dio_channels = 8,
4740 .caldac = {caldac_none},
4741 .has_8255 = 0,
4742@@ -1001,7 +1001,7 @@ static const struct ni_board_struct ni_boards[] = {
4743 .ao_range_table = &range_ni_M_625x_ao,
4744 .reg_type = ni_reg_625x,
4745 .ao_unipolar = 0,
4746- .ao_speed = 357,
4747+ .ao_speed = 350,
4748 .num_p0_dio_channels = 8,
4749 .caldac = {caldac_none},
4750 .has_8255 = 0,
4751@@ -1037,7 +1037,7 @@ static const struct ni_board_struct ni_boards[] = {
4752 .ao_range_table = &range_ni_M_625x_ao,
4753 .reg_type = ni_reg_625x,
4754 .ao_unipolar = 0,
4755- .ao_speed = 357,
4756+ .ao_speed = 350,
4757 .num_p0_dio_channels = 32,
4758 .caldac = {caldac_none},
4759 .has_8255 = 0,
4760@@ -1056,7 +1056,7 @@ static const struct ni_board_struct ni_boards[] = {
4761 .ao_range_table = &range_ni_M_625x_ao,
4762 .reg_type = ni_reg_625x,
4763 .ao_unipolar = 0,
4764- .ao_speed = 357,
4765+ .ao_speed = 350,
4766 .num_p0_dio_channels = 32,
4767 .caldac = {caldac_none},
4768 .has_8255 = 0,
4769@@ -1092,7 +1092,7 @@ static const struct ni_board_struct ni_boards[] = {
4770 .ao_range_table = &range_ni_M_628x_ao,
4771 .reg_type = ni_reg_628x,
4772 .ao_unipolar = 1,
4773- .ao_speed = 357,
4774+ .ao_speed = 350,
4775 .num_p0_dio_channels = 8,
4776 .caldac = {caldac_none},
4777 .has_8255 = 0,
4778@@ -1111,7 +1111,7 @@ static const struct ni_board_struct ni_boards[] = {
4779 .ao_range_table = &range_ni_M_628x_ao,
4780 .reg_type = ni_reg_628x,
4781 .ao_unipolar = 1,
4782- .ao_speed = 357,
4783+ .ao_speed = 350,
4784 .num_p0_dio_channels = 8,
4785 .caldac = {caldac_none},
4786 .has_8255 = 0,
4787@@ -1147,7 +1147,7 @@ static const struct ni_board_struct ni_boards[] = {
4788 .ao_range_table = &range_ni_M_628x_ao,
4789 .reg_type = ni_reg_628x,
4790 .ao_unipolar = 1,
4791- .ao_speed = 357,
4792+ .ao_speed = 350,
4793 .num_p0_dio_channels = 32,
4794 .caldac = {caldac_none},
4795 .has_8255 = 0,
4796diff --git a/drivers/staging/rtl8712/usb_intf.c b/drivers/staging/rtl8712/usb_intf.c
4797index c758c40..ad53781 100644
4798--- a/drivers/staging/rtl8712/usb_intf.c
4799+++ b/drivers/staging/rtl8712/usb_intf.c
4800@@ -64,6 +64,8 @@ static struct usb_device_id rtl871x_usb_id_tbl[] = {
4801 {USB_DEVICE(0x0B05, 0x1791)}, /* 11n mode disable */
4802 /* Belkin */
4803 {USB_DEVICE(0x050D, 0x945A)},
4804+ /* ISY IWL - Belkin clone */
4805+ {USB_DEVICE(0x050D, 0x11F1)},
4806 /* Corega */
4807 {USB_DEVICE(0x07AA, 0x0047)},
4808 /* D-Link */
4809diff --git a/drivers/staging/speakup/synth.c b/drivers/staging/speakup/synth.c
4810index df95337..7616f05 100644
4811--- a/drivers/staging/speakup/synth.c
4812+++ b/drivers/staging/speakup/synth.c
4813@@ -342,7 +342,7 @@ int synth_init(char *synth_name)
4814
4815 mutex_lock(&spk_mutex);
4816 /* First, check if we already have it loaded. */
4817- for (i = 0; synths[i] != NULL && i < MAXSYNTHS; i++)
4818+ for (i = 0; i < MAXSYNTHS && synths[i] != NULL; i++)
4819 if (strcmp(synths[i]->name, synth_name) == 0)
4820 synth = synths[i];
4821
4822@@ -423,7 +423,7 @@ int synth_add(struct spk_synth *in_synth)
4823 int i;
4824 int status = 0;
4825 mutex_lock(&spk_mutex);
4826- for (i = 0; synths[i] != NULL && i < MAXSYNTHS; i++)
4827+ for (i = 0; i < MAXSYNTHS && synths[i] != NULL; i++)
4828 /* synth_remove() is responsible for rotating the array down */
4829 if (in_synth == synths[i]) {
4830 mutex_unlock(&spk_mutex);
4831diff --git a/drivers/staging/vt6656/bssdb.h b/drivers/staging/vt6656/bssdb.h
4832index 6b2ec39..806cbf7 100644
4833--- a/drivers/staging/vt6656/bssdb.h
4834+++ b/drivers/staging/vt6656/bssdb.h
4835@@ -90,7 +90,6 @@ typedef struct tagSRSNCapObject {
4836 } SRSNCapObject, *PSRSNCapObject;
4837
4838 // BSS info(AP)
4839-#pragma pack(1)
4840 typedef struct tagKnownBSS {
4841 // BSS info
4842 BOOL bActive;
4843diff --git a/drivers/staging/vt6656/dpc.c b/drivers/staging/vt6656/dpc.c
4844index 3aa895e..a510b29 100644
4845--- a/drivers/staging/vt6656/dpc.c
4846+++ b/drivers/staging/vt6656/dpc.c
4847@@ -1238,7 +1238,7 @@ static BOOL s_bHandleRxEncryption (
4848
4849 PayloadLen -= (WLAN_HDR_ADDR3_LEN + 8 + 4); // 24 is 802.11 header, 8 is IV&ExtIV, 4 is crc
4850 *pdwRxTSC47_16 = cpu_to_le32(*(PDWORD)(pbyIV + 4));
4851- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ExtIV: %lx\n",*pdwRxTSC47_16);
4852+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ExtIV: %x\n", *pdwRxTSC47_16);
4853 if (byDecMode == KEY_CTL_TKIP) {
4854 *pwRxTSC15_0 = cpu_to_le16(MAKEWORD(*(pbyIV+2), *pbyIV));
4855 } else {
4856@@ -1349,7 +1349,7 @@ static BOOL s_bHostWepRxEncryption (
4857
4858 PayloadLen -= (WLAN_HDR_ADDR3_LEN + 8 + 4); // 24 is 802.11 header, 8 is IV&ExtIV, 4 is crc
4859 *pdwRxTSC47_16 = cpu_to_le32(*(PDWORD)(pbyIV + 4));
4860- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ExtIV: %lx\n",*pdwRxTSC47_16);
4861+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ExtIV: %x\n", *pdwRxTSC47_16);
4862
4863 if (byDecMode == KEY_CTL_TKIP) {
4864 *pwRxTSC15_0 = cpu_to_le16(MAKEWORD(*(pbyIV+2), *pbyIV));
4865diff --git a/drivers/staging/vt6656/int.h b/drivers/staging/vt6656/int.h
4866index 3734e2c..91ceb77 100644
4867--- a/drivers/staging/vt6656/int.h
4868+++ b/drivers/staging/vt6656/int.h
4869@@ -34,7 +34,6 @@
4870 #include "device.h"
4871
4872 /*--------------------- Export Definitions -------------------------*/
4873-#pragma pack(1)
4874 typedef struct tagSINTData {
4875 BYTE byTSR0;
4876 BYTE byPkt0;
4877diff --git a/drivers/staging/vt6656/iocmd.h b/drivers/staging/vt6656/iocmd.h
4878index 22710ce..ae6e2d2 100644
4879--- a/drivers/staging/vt6656/iocmd.h
4880+++ b/drivers/staging/vt6656/iocmd.h
4881@@ -95,13 +95,12 @@ typedef enum tagWZONETYPE {
4882 // Ioctl interface structure
4883 // Command structure
4884 //
4885-#pragma pack(1)
4886 typedef struct tagSCmdRequest {
4887 u8 name[16];
4888 void *data;
4889 u16 wResult;
4890 u16 wCmdCode;
4891-} SCmdRequest, *PSCmdRequest;
4892+} __packed SCmdRequest, *PSCmdRequest;
4893
4894 //
4895 // Scan
4896@@ -111,7 +110,7 @@ typedef struct tagSCmdScan {
4897
4898 u8 ssid[SSID_MAXLEN + 2];
4899
4900-} SCmdScan, *PSCmdScan;
4901+} __packed SCmdScan, *PSCmdScan;
4902
4903 //
4904 // BSS Join
4905@@ -126,7 +125,7 @@ typedef struct tagSCmdBSSJoin {
4906 BOOL bPSEnable;
4907 BOOL bShareKeyAuth;
4908
4909-} SCmdBSSJoin, *PSCmdBSSJoin;
4910+} __packed SCmdBSSJoin, *PSCmdBSSJoin;
4911
4912 //
4913 // Zonetype Setting
4914@@ -137,7 +136,7 @@ typedef struct tagSCmdZoneTypeSet {
4915 BOOL bWrite;
4916 WZONETYPE ZoneType;
4917
4918-} SCmdZoneTypeSet, *PSCmdZoneTypeSet;
4919+} __packed SCmdZoneTypeSet, *PSCmdZoneTypeSet;
4920
4921 typedef struct tagSWPAResult {
4922 char ifname[100];
4923@@ -145,7 +144,7 @@ typedef struct tagSWPAResult {
4924 u8 key_mgmt;
4925 u8 eap_type;
4926 BOOL authenticated;
4927-} SWPAResult, *PSWPAResult;
4928+} __packed SWPAResult, *PSWPAResult;
4929
4930 typedef struct tagSCmdStartAP {
4931
4932@@ -157,7 +156,7 @@ typedef struct tagSCmdStartAP {
4933 BOOL bShareKeyAuth;
4934 u8 byBasicRate;
4935
4936-} SCmdStartAP, *PSCmdStartAP;
4937+} __packed SCmdStartAP, *PSCmdStartAP;
4938
4939 typedef struct tagSCmdSetWEP {
4940
4941@@ -167,7 +166,7 @@ typedef struct tagSCmdSetWEP {
4942 BOOL bWepKeyAvailable[WEP_NKEYS];
4943 u32 auWepKeyLength[WEP_NKEYS];
4944
4945-} SCmdSetWEP, *PSCmdSetWEP;
4946+} __packed SCmdSetWEP, *PSCmdSetWEP;
4947
4948 typedef struct tagSBSSIDItem {
4949
4950@@ -180,14 +179,14 @@ typedef struct tagSBSSIDItem {
4951 BOOL bWEPOn;
4952 u32 uRSSI;
4953
4954-} SBSSIDItem;
4955+} __packed SBSSIDItem;
4956
4957
4958 typedef struct tagSBSSIDList {
4959
4960 u32 uItem;
4961 SBSSIDItem sBSSIDList[0];
4962-} SBSSIDList, *PSBSSIDList;
4963+} __packed SBSSIDList, *PSBSSIDList;
4964
4965
4966 typedef struct tagSNodeItem {
4967@@ -208,7 +207,7 @@ typedef struct tagSNodeItem {
4968 u32 uTxAttempts;
4969 u16 wFailureRatio;
4970
4971-} SNodeItem;
4972+} __packed SNodeItem;
4973
4974
4975 typedef struct tagSNodeList {
4976@@ -216,7 +215,7 @@ typedef struct tagSNodeList {
4977 u32 uItem;
4978 SNodeItem sNodeList[0];
4979
4980-} SNodeList, *PSNodeList;
4981+} __packed SNodeList, *PSNodeList;
4982
4983
4984 typedef struct tagSCmdLinkStatus {
4985@@ -229,7 +228,7 @@ typedef struct tagSCmdLinkStatus {
4986 u32 uChannel;
4987 u32 uLinkRate;
4988
4989-} SCmdLinkStatus, *PSCmdLinkStatus;
4990+} __packed SCmdLinkStatus, *PSCmdLinkStatus;
4991
4992 //
4993 // 802.11 counter
4994@@ -247,7 +246,7 @@ typedef struct tagSDot11MIBCount {
4995 u32 ReceivedFragmentCount;
4996 u32 MulticastReceivedFrameCount;
4997 u32 FCSErrorCount;
4998-} SDot11MIBCount, *PSDot11MIBCount;
4999+} __packed SDot11MIBCount, *PSDot11MIBCount;
5000
5001
5002
5003@@ -355,13 +354,13 @@ typedef struct tagSStatMIBCount {
5004 u32 ullTxBroadcastBytes[2];
5005 u32 ullTxMulticastBytes[2];
5006 u32 ullTxDirectedBytes[2];
5007-} SStatMIBCount, *PSStatMIBCount;
5008+} __packed SStatMIBCount, *PSStatMIBCount;
5009
5010 typedef struct tagSCmdValue {
5011
5012 u32 dwValue;
5013
5014-} SCmdValue, *PSCmdValue;
5015+} __packed SCmdValue, *PSCmdValue;
5016
5017 //
5018 // hostapd & viawget ioctl related
5019@@ -431,7 +430,7 @@ struct viawget_hostapd_param {
5020 u8 ssid[32];
5021 } scan_req;
5022 } u;
5023-};
5024+} __packed;
5025
5026 /*--------------------- Export Classes ----------------------------*/
5027
5028diff --git a/drivers/staging/vt6656/iowpa.h b/drivers/staging/vt6656/iowpa.h
5029index 959c886..2522dde 100644
5030--- a/drivers/staging/vt6656/iowpa.h
5031+++ b/drivers/staging/vt6656/iowpa.h
5032@@ -67,12 +67,11 @@ enum {
5033
5034
5035
5036-#pragma pack(1)
5037 typedef struct viawget_wpa_header {
5038 u8 type;
5039 u16 req_ie_len;
5040 u16 resp_ie_len;
5041-} viawget_wpa_header;
5042+} __packed viawget_wpa_header;
5043
5044 struct viawget_wpa_param {
5045 u32 cmd;
5046@@ -113,9 +112,8 @@ struct viawget_wpa_param {
5047 u8 *buf;
5048 } scan_results;
5049 } u;
5050-};
5051+} __packed;
5052
5053-#pragma pack(1)
5054 struct viawget_scan_result {
5055 u8 bssid[6];
5056 u8 ssid[32];
5057@@ -130,7 +128,7 @@ struct viawget_scan_result {
5058 int noise;
5059 int level;
5060 int maxrate;
5061-};
5062+} __packed;
5063
5064 /*--------------------- Export Classes ----------------------------*/
5065
5066diff --git a/drivers/staging/vt6656/key.c b/drivers/staging/vt6656/key.c
5067index ee62a06..ba3a561 100644
5068--- a/drivers/staging/vt6656/key.c
5069+++ b/drivers/staging/vt6656/key.c
5070@@ -223,7 +223,7 @@ BOOL KeybSetKey(
5071 PSKeyManagement pTable,
5072 PBYTE pbyBSSID,
5073 DWORD dwKeyIndex,
5074- unsigned long uKeyLength,
5075+ u32 uKeyLength,
5076 PQWORD pKeyRSC,
5077 PBYTE pbyKey,
5078 BYTE byKeyDecMode
5079@@ -235,7 +235,8 @@ BOOL KeybSetKey(
5080 PSKeyItem pKey;
5081 unsigned int uKeyIdx;
5082
5083- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Enter KeybSetKey: %lX\n", dwKeyIndex);
5084+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO
5085+ "Enter KeybSetKey: %X\n", dwKeyIndex);
5086
5087 j = (MAX_KEY_TABLE-1);
5088 for (i=0;i<(MAX_KEY_TABLE-1);i++) {
5089@@ -261,7 +262,9 @@ BOOL KeybSetKey(
5090 if ((dwKeyIndex & TRANSMIT_KEY) != 0) {
5091 // Group transmit key
5092 pTable->KeyTable[i].dwGTKeyIndex = dwKeyIndex;
5093- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Group transmit key(R)[%lX]: %d\n", pTable->KeyTable[i].dwGTKeyIndex, i);
5094+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO
5095+ "Group transmit key(R)[%X]: %d\n",
5096+ pTable->KeyTable[i].dwGTKeyIndex, i);
5097 }
5098 pTable->KeyTable[i].wKeyCtl &= 0xFF0F; // clear group key control filed
5099 pTable->KeyTable[i].wKeyCtl |= (byKeyDecMode << 4);
5100@@ -302,9 +305,12 @@ BOOL KeybSetKey(
5101 }
5102 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\n");
5103
5104- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->dwTSC47_16: %lx\n ", pKey->dwTSC47_16);
5105- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->wTSC15_0: %x\n ", pKey->wTSC15_0);
5106- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->dwKeyIndex: %lx\n ", pKey->dwKeyIndex);
5107+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->dwTSC47_16: %x\n ",
5108+ pKey->dwTSC47_16);
5109+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->wTSC15_0: %x\n ",
5110+ pKey->wTSC15_0);
5111+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->dwKeyIndex: %x\n ",
5112+ pKey->dwKeyIndex);
5113
5114 return (TRUE);
5115 }
5116@@ -326,7 +332,9 @@ BOOL KeybSetKey(
5117 if ((dwKeyIndex & TRANSMIT_KEY) != 0) {
5118 // Group transmit key
5119 pTable->KeyTable[j].dwGTKeyIndex = dwKeyIndex;
5120- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Group transmit key(N)[%lX]: %d\n", pTable->KeyTable[j].dwGTKeyIndex, j);
5121+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO
5122+ "Group transmit key(N)[%X]: %d\n",
5123+ pTable->KeyTable[j].dwGTKeyIndex, j);
5124 }
5125 pTable->KeyTable[j].wKeyCtl &= 0xFF0F; // clear group key control filed
5126 pTable->KeyTable[j].wKeyCtl |= (byKeyDecMode << 4);
5127@@ -367,9 +375,11 @@ BOOL KeybSetKey(
5128 }
5129 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\n");
5130
5131- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->dwTSC47_16: %lx\n ", pKey->dwTSC47_16);
5132+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->dwTSC47_16: %x\n ",
5133+ pKey->dwTSC47_16);
5134 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->wTSC15_0: %x\n ", pKey->wTSC15_0);
5135- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->dwKeyIndex: %lx\n ", pKey->dwKeyIndex);
5136+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->dwKeyIndex: %x\n ",
5137+ pKey->dwKeyIndex);
5138
5139 return (TRUE);
5140 }
5141@@ -597,7 +607,8 @@ BOOL KeybGetTransmitKey(PSKeyManagement pTable, PBYTE pbyBSSID, DWORD dwKeyType,
5142 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"%x ", pTable->KeyTable[i].abyBSSID[ii]);
5143 }
5144 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\n");
5145- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"dwGTKeyIndex: %lX\n", pTable->KeyTable[i].dwGTKeyIndex);
5146+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"dwGTKeyIndex: %X\n",
5147+ pTable->KeyTable[i].dwGTKeyIndex);
5148
5149 return (TRUE);
5150 }
5151@@ -664,7 +675,7 @@ BOOL KeybSetDefaultKey(
5152 void *pDeviceHandler,
5153 PSKeyManagement pTable,
5154 DWORD dwKeyIndex,
5155- unsigned long uKeyLength,
5156+ u32 uKeyLength,
5157 PQWORD pKeyRSC,
5158 PBYTE pbyKey,
5159 BYTE byKeyDecMode
5160@@ -696,7 +707,10 @@ BOOL KeybSetDefaultKey(
5161 if ((dwKeyIndex & TRANSMIT_KEY) != 0) {
5162 // Group transmit key
5163 pTable->KeyTable[MAX_KEY_TABLE-1].dwGTKeyIndex = dwKeyIndex;
5164- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Group transmit key(R)[%lX]: %d\n", pTable->KeyTable[MAX_KEY_TABLE-1].dwGTKeyIndex, MAX_KEY_TABLE-1);
5165+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO
5166+ "Group transmit key(R)[%X]: %d\n",
5167+ pTable->KeyTable[MAX_KEY_TABLE-1].dwGTKeyIndex,
5168+ MAX_KEY_TABLE-1);
5169
5170 }
5171 pTable->KeyTable[MAX_KEY_TABLE-1].wKeyCtl &= 0x7F00; // clear all key control filed
5172@@ -747,9 +761,11 @@ BOOL KeybSetDefaultKey(
5173 }
5174 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\n");
5175
5176- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->dwTSC47_16: %lx\n", pKey->dwTSC47_16);
5177+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->dwTSC47_16: %x\n",
5178+ pKey->dwTSC47_16);
5179 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->wTSC15_0: %x\n", pKey->wTSC15_0);
5180- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->dwKeyIndex: %lx\n", pKey->dwKeyIndex);
5181+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey->dwKeyIndex: %x\n",
5182+ pKey->dwKeyIndex);
5183
5184 return (TRUE);
5185 }
5186@@ -775,7 +791,7 @@ BOOL KeybSetAllGroupKey(
5187 void *pDeviceHandler,
5188 PSKeyManagement pTable,
5189 DWORD dwKeyIndex,
5190- unsigned long uKeyLength,
5191+ u32 uKeyLength,
5192 PQWORD pKeyRSC,
5193 PBYTE pbyKey,
5194 BYTE byKeyDecMode
5195@@ -787,7 +803,8 @@ BOOL KeybSetAllGroupKey(
5196 PSKeyItem pKey;
5197 unsigned int uKeyIdx;
5198
5199- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Enter KeybSetAllGroupKey: %lX\n", dwKeyIndex);
5200+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Enter KeybSetAllGroupKey: %X\n",
5201+ dwKeyIndex);
5202
5203
5204 if ((dwKeyIndex & PAIRWISE_KEY) != 0) { // Pairwise key
5205@@ -804,7 +821,9 @@ BOOL KeybSetAllGroupKey(
5206 if ((dwKeyIndex & TRANSMIT_KEY) != 0) {
5207 // Group transmit key
5208 pTable->KeyTable[i].dwGTKeyIndex = dwKeyIndex;
5209- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Group transmit key(R)[%lX]: %d\n", pTable->KeyTable[i].dwGTKeyIndex, i);
5210+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO
5211+ "Group transmit key(R)[%X]: %d\n",
5212+ pTable->KeyTable[i].dwGTKeyIndex, i);
5213
5214 }
5215 pTable->KeyTable[i].wKeyCtl &= 0xFF0F; // clear group key control filed
5216diff --git a/drivers/staging/vt6656/key.h b/drivers/staging/vt6656/key.h
5217index f749c7a..bd35d39 100644
5218--- a/drivers/staging/vt6656/key.h
5219+++ b/drivers/staging/vt6656/key.h
5220@@ -58,7 +58,7 @@
5221 typedef struct tagSKeyItem
5222 {
5223 BOOL bKeyValid;
5224- unsigned long uKeyLength;
5225+ u32 uKeyLength;
5226 BYTE abyKey[MAX_KEY_LEN];
5227 QWORD KeyRSC;
5228 DWORD dwTSC47_16;
5229@@ -107,7 +107,7 @@ BOOL KeybSetKey(
5230 PSKeyManagement pTable,
5231 PBYTE pbyBSSID,
5232 DWORD dwKeyIndex,
5233- unsigned long uKeyLength,
5234+ u32 uKeyLength,
5235 PQWORD pKeyRSC,
5236 PBYTE pbyKey,
5237 BYTE byKeyDecMode
5238@@ -146,7 +146,7 @@ BOOL KeybSetDefaultKey(
5239 void *pDeviceHandler,
5240 PSKeyManagement pTable,
5241 DWORD dwKeyIndex,
5242- unsigned long uKeyLength,
5243+ u32 uKeyLength,
5244 PQWORD pKeyRSC,
5245 PBYTE pbyKey,
5246 BYTE byKeyDecMode
5247@@ -156,7 +156,7 @@ BOOL KeybSetAllGroupKey(
5248 void *pDeviceHandler,
5249 PSKeyManagement pTable,
5250 DWORD dwKeyIndex,
5251- unsigned long uKeyLength,
5252+ u32 uKeyLength,
5253 PQWORD pKeyRSC,
5254 PBYTE pbyKey,
5255 BYTE byKeyDecMode
5256diff --git a/drivers/staging/vt6656/mac.c b/drivers/staging/vt6656/mac.c
5257index af4a29d..8fddc7b 100644
5258--- a/drivers/staging/vt6656/mac.c
5259+++ b/drivers/staging/vt6656/mac.c
5260@@ -260,7 +260,8 @@ BYTE pbyData[24];
5261 dwData1 <<= 16;
5262 dwData1 |= MAKEWORD(*(pbyAddr+4), *(pbyAddr+5));
5263
5264- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"1. wOffset: %d, Data: %lX, KeyCtl:%X\n", wOffset, dwData1, wKeyCtl);
5265+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"1. wOffset: %d, Data: %X,"\
5266+ " KeyCtl:%X\n", wOffset, dwData1, wKeyCtl);
5267
5268 //VNSvOutPortW(dwIoBase + MAC_REG_MISCFFNDEX, wOffset);
5269 //VNSvOutPortD(dwIoBase + MAC_REG_MISCFFDATA, dwData);
5270@@ -277,7 +278,8 @@ BYTE pbyData[24];
5271 dwData2 <<= 8;
5272 dwData2 |= *(pbyAddr+0);
5273
5274- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"2. wOffset: %d, Data: %lX\n", wOffset, dwData2);
5275+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"2. wOffset: %d, Data: %X\n",
5276+ wOffset, dwData2);
5277
5278 //VNSvOutPortW(dwIoBase + MAC_REG_MISCFFNDEX, wOffset);
5279 //VNSvOutPortD(dwIoBase + MAC_REG_MISCFFDATA, dwData);
5280diff --git a/drivers/staging/vt6656/rf.c b/drivers/staging/vt6656/rf.c
5281index 3fd0478..8cf0881 100644
5282--- a/drivers/staging/vt6656/rf.c
5283+++ b/drivers/staging/vt6656/rf.c
5284@@ -769,6 +769,9 @@ BYTE byPwr = pDevice->byCCKPwr;
5285 return TRUE;
5286 }
5287
5288+ if (uCH == 0)
5289+ return -EINVAL;
5290+
5291 switch (uRATE) {
5292 case RATE_1M:
5293 case RATE_2M:
5294diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c
5295index b6e04e7..7a56929 100644
5296--- a/drivers/staging/vt6656/rxtx.c
5297+++ b/drivers/staging/vt6656/rxtx.c
5298@@ -375,7 +375,8 @@ s_vFillTxKey (
5299 *(pbyIVHead+3) = (BYTE)(((pDevice->byKeyIndex << 6) & 0xc0) | 0x20); // 0x20 is ExtIV
5300 // Append IV&ExtIV after Mac Header
5301 *pdwExtIV = cpu_to_le32(pTransmitKey->dwTSC47_16);
5302- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"vFillTxKey()---- pdwExtIV: %lx\n", *pdwExtIV);
5303+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"vFillTxKey()---- pdwExtIV: %x\n",
5304+ *pdwExtIV);
5305
5306 } else if (pTransmitKey->byCipherSuite == KEY_CTL_CCMP) {
5307 pTransmitKey->wTSC15_0++;
5308@@ -1751,7 +1752,8 @@ s_bPacketToWirelessUsb(
5309 MIC_vAppend((PBYTE)&(psEthHeader->abyDstAddr[0]), 12);
5310 dwMIC_Priority = 0;
5311 MIC_vAppend((PBYTE)&dwMIC_Priority, 4);
5312- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"MIC KEY: %lX, %lX\n", dwMICKey0, dwMICKey1);
5313+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"MIC KEY: %X, %X\n",
5314+ dwMICKey0, dwMICKey1);
5315
5316 ///////////////////////////////////////////////////////////////////
5317
5318@@ -2633,7 +2635,8 @@ vDMA0_tx_80211(PSDevice pDevice, struct sk_buff *skb) {
5319 MIC_vAppend((PBYTE)&(sEthHeader.abyDstAddr[0]), 12);
5320 dwMIC_Priority = 0;
5321 MIC_vAppend((PBYTE)&dwMIC_Priority, 4);
5322- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"DMA0_tx_8021:MIC KEY: %lX, %lX\n", dwMICKey0, dwMICKey1);
5323+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"DMA0_tx_8021:MIC KEY:"\
5324+ " %X, %X\n", dwMICKey0, dwMICKey1);
5325
5326 uLength = cbHeaderSize + cbMacHdLen + uPadding + cbIVlen;
5327
5328@@ -2653,7 +2656,8 @@ vDMA0_tx_80211(PSDevice pDevice, struct sk_buff *skb) {
5329
5330 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"uLength: %d, %d\n", uLength, cbFrameBodySize);
5331 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"cbReqCount:%d, %d, %d, %d\n", cbReqCount, cbHeaderSize, uPadding, cbIVlen);
5332- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"MIC:%lx, %lx\n", *pdwMIC_L, *pdwMIC_R);
5333+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"MIC:%x, %x\n",
5334+ *pdwMIC_L, *pdwMIC_R);
5335
5336 }
5337
5338@@ -3027,7 +3031,8 @@ int nsDMA_tx_packet(PSDevice pDevice, unsigned int uDMAIdx, struct sk_buff *skb)
5339 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"error: KEY is GTK!!~~\n");
5340 }
5341 else {
5342- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Find PTK [%lX]\n", pTransmitKey->dwKeyIndex);
5343+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Find PTK [%X]\n",
5344+ pTransmitKey->dwKeyIndex);
5345 bNeedEncryption = TRUE;
5346 }
5347 }
5348@@ -3041,7 +3046,8 @@ int nsDMA_tx_packet(PSDevice pDevice, unsigned int uDMAIdx, struct sk_buff *skb)
5349 if (pDevice->bEnableHostWEP) {
5350 if ((uNodeIndex != 0) &&
5351 (pMgmt->sNodeDBTable[uNodeIndex].dwKeyIndex & PAIRWISE_KEY)) {
5352- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Find PTK [%lX]\n", pTransmitKey->dwKeyIndex);
5353+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Find PTK [%X]\n",
5354+ pTransmitKey->dwKeyIndex);
5355 bNeedEncryption = TRUE;
5356 }
5357 }
5358diff --git a/drivers/staging/vt6656/ttype.h b/drivers/staging/vt6656/ttype.h
5359index 8e9450e..dfbf747 100644
5360--- a/drivers/staging/vt6656/ttype.h
5361+++ b/drivers/staging/vt6656/ttype.h
5362@@ -29,6 +29,8 @@
5363 #ifndef __TTYPE_H__
5364 #define __TTYPE_H__
5365
5366+#include <linux/types.h>
5367+
5368 /******* Common definitions and typedefs ***********************************/
5369
5370 typedef int BOOL;
5371@@ -42,17 +44,17 @@ typedef int BOOL;
5372
5373 /****** Simple typedefs ***************************************************/
5374
5375-typedef unsigned char BYTE; // 8-bit
5376-typedef unsigned short WORD; // 16-bit
5377-typedef unsigned long DWORD; // 32-bit
5378+typedef u8 BYTE;
5379+typedef u16 WORD;
5380+typedef u32 DWORD;
5381
5382 // QWORD is for those situation that we want
5383 // an 8-byte-aligned 8 byte long structure
5384 // which is NOT really a floating point number.
5385 typedef union tagUQuadWord {
5386 struct {
5387- DWORD dwLowDword;
5388- DWORD dwHighDword;
5389+ u32 dwLowDword;
5390+ u32 dwHighDword;
5391 } u;
5392 double DoNotUseThisField;
5393 } UQuadWord;
5394@@ -60,8 +62,8 @@ typedef UQuadWord QWORD; // 64-bit
5395
5396 /****** Common pointer types ***********************************************/
5397
5398-typedef unsigned long ULONG_PTR; // 32-bit
5399-typedef unsigned long DWORD_PTR; // 32-bit
5400+typedef u32 ULONG_PTR;
5401+typedef u32 DWORD_PTR;
5402
5403 // boolean pointer
5404
5405diff --git a/drivers/staging/vt6656/wcmd.c b/drivers/staging/vt6656/wcmd.c
5406index 9d2caa8..2225b9e 100644
5407--- a/drivers/staging/vt6656/wcmd.c
5408+++ b/drivers/staging/vt6656/wcmd.c
5409@@ -316,17 +316,19 @@ s_MgrMakeProbeRequest(
5410 return pTxPacket;
5411 }
5412
5413-void vCommandTimerWait(void *hDeviceContext, unsigned int MSecond)
5414+void vCommandTimerWait(void *hDeviceContext, unsigned long MSecond)
5415 {
5416- PSDevice pDevice = (PSDevice)hDeviceContext;
5417+ PSDevice pDevice = (PSDevice)hDeviceContext;
5418
5419- init_timer(&pDevice->sTimerCommand);
5420- pDevice->sTimerCommand.data = (unsigned long)pDevice;
5421- pDevice->sTimerCommand.function = (TimerFunction)vRunCommand;
5422- // RUN_AT :1 msec ~= (HZ/1024)
5423- pDevice->sTimerCommand.expires = (unsigned int)RUN_AT((MSecond * HZ) >> 10);
5424- add_timer(&pDevice->sTimerCommand);
5425- return;
5426+ init_timer(&pDevice->sTimerCommand);
5427+
5428+ pDevice->sTimerCommand.data = (unsigned long)pDevice;
5429+ pDevice->sTimerCommand.function = (TimerFunction)vRunCommand;
5430+ pDevice->sTimerCommand.expires = RUN_AT((MSecond * HZ) / 1000);
5431+
5432+ add_timer(&pDevice->sTimerCommand);
5433+
5434+ return;
5435 }
5436
5437 void vRunCommand(void *hDeviceContext)
5438diff --git a/drivers/staging/vt6656/wpa2.h b/drivers/staging/vt6656/wpa2.h
5439index 46c2959..c359252 100644
5440--- a/drivers/staging/vt6656/wpa2.h
5441+++ b/drivers/staging/vt6656/wpa2.h
5442@@ -45,8 +45,8 @@ typedef struct tagsPMKIDInfo {
5443 } PMKIDInfo, *PPMKIDInfo;
5444
5445 typedef struct tagSPMKIDCache {
5446- unsigned long BSSIDInfoCount;
5447- PMKIDInfo BSSIDInfo[MAX_PMKID_CACHE];
5448+ u32 BSSIDInfoCount;
5449+ PMKIDInfo BSSIDInfo[MAX_PMKID_CACHE];
5450 } SPMKIDCache, *PSPMKIDCache;
5451
5452
5453diff --git a/drivers/staging/wlan-ng/prism2mgmt.c b/drivers/staging/wlan-ng/prism2mgmt.c
5454index 4efa9bc..89bfd85 100644
5455--- a/drivers/staging/wlan-ng/prism2mgmt.c
5456+++ b/drivers/staging/wlan-ng/prism2mgmt.c
5457@@ -406,7 +406,7 @@ int prism2mgmt_scan_results(wlandevice_t *wlandev, void *msgp)
5458 /* SSID */
5459 req->ssid.status = P80211ENUM_msgitem_status_data_ok;
5460 req->ssid.data.len = le16_to_cpu(item->ssid.len);
5461- req->ssid.data.len = min_t(u16, req->ssid.data.len, WLAN_BSSID_LEN);
5462+ req->ssid.data.len = min_t(u16, req->ssid.data.len, WLAN_SSID_MAXLEN);
5463 memcpy(req->ssid.data.data, item->ssid.data, req->ssid.data.len);
5464
5465 /* supported rates */
5466diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
5467index 6b6f50a..5bafd2d 100644
5468--- a/drivers/target/iscsi/iscsi_target.c
5469+++ b/drivers/target/iscsi/iscsi_target.c
5470@@ -2384,7 +2384,7 @@ static void iscsit_build_conn_drop_async_message(struct iscsi_conn *conn)
5471 if (!conn_p)
5472 return;
5473
5474- cmd = iscsit_allocate_cmd(conn_p, GFP_KERNEL);
5475+ cmd = iscsit_allocate_cmd(conn_p, GFP_ATOMIC);
5476 if (!cmd) {
5477 iscsit_dec_conn_usage_count(conn_p);
5478 return;
5479diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
5480index 68d4c10..f141b4f 100644
5481--- a/drivers/target/target_core_device.c
5482+++ b/drivers/target/target_core_device.c
5483@@ -1622,6 +1622,7 @@ int core_dev_setup_virtual_lun0(void)
5484 ret = PTR_ERR(dev);
5485 goto out;
5486 }
5487+ dev->dev_link_magic = SE_DEV_LINK_MAGIC;
5488 se_dev->se_dev_ptr = dev;
5489 g_lun0_dev = dev;
5490
5491diff --git a/drivers/target/target_core_fabric_configfs.c b/drivers/target/target_core_fabric_configfs.c
5492index ea479e5..c0dd776 100644
5493--- a/drivers/target/target_core_fabric_configfs.c
5494+++ b/drivers/target/target_core_fabric_configfs.c
5495@@ -72,6 +72,12 @@ static int target_fabric_mappedlun_link(
5496 struct se_portal_group *se_tpg;
5497 struct config_item *nacl_ci, *tpg_ci, *tpg_ci_s, *wwn_ci, *wwn_ci_s;
5498 int ret = 0, lun_access;
5499+
5500+ if (lun->lun_link_magic != SE_LUN_LINK_MAGIC) {
5501+ pr_err("Bad lun->lun_link_magic, not a valid lun_ci pointer:"
5502+ " %p to struct lun: %p\n", lun_ci, lun);
5503+ return -EFAULT;
5504+ }
5505 /*
5506 * Ensure that the source port exists
5507 */
5508@@ -763,6 +769,11 @@ static int target_fabric_port_link(
5509 ret = -ENODEV;
5510 goto out;
5511 }
5512+ if (dev->dev_link_magic != SE_DEV_LINK_MAGIC) {
5513+ pr_err("Bad dev->dev_link_magic, not a valid se_dev_ci pointer:"
5514+ " %p to struct se_device: %p\n", se_dev_ci, dev);
5515+ return -EFAULT;
5516+ }
5517
5518 lun_p = core_dev_add_lun(se_tpg, dev, lun->unpacked_lun);
5519 if (IS_ERR(lun_p)) {
5520diff --git a/drivers/target/target_core_tpg.c b/drivers/target/target_core_tpg.c
5521index b8628a5..8dfe6f5 100644
5522--- a/drivers/target/target_core_tpg.c
5523+++ b/drivers/target/target_core_tpg.c
5524@@ -672,6 +672,7 @@ int core_tpg_register(
5525 for (i = 0; i < TRANSPORT_MAX_LUNS_PER_TPG; i++) {
5526 lun = se_tpg->tpg_lun_list[i];
5527 lun->unpacked_lun = i;
5528+ lun->lun_link_magic = SE_LUN_LINK_MAGIC;
5529 lun->lun_status = TRANSPORT_LUN_STATUS_FREE;
5530 atomic_set(&lun->lun_acl_count, 0);
5531 init_completion(&lun->lun_shutdown_comp);
5532diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
5533index c87ef74..65e6320 100644
5534--- a/drivers/target/target_core_transport.c
5535+++ b/drivers/target/target_core_transport.c
5536@@ -1085,6 +1085,7 @@ struct se_device *transport_add_device_to_core_hba(
5537 dev->se_hba = hba;
5538 dev->se_sub_dev = se_dev;
5539 dev->transport = transport;
5540+ dev->dev_link_magic = SE_DEV_LINK_MAGIC;
5541 INIT_LIST_HEAD(&dev->dev_list);
5542 INIT_LIST_HEAD(&dev->dev_sep_list);
5543 INIT_LIST_HEAD(&dev->dev_tmr_list);
5544@@ -1553,6 +1554,8 @@ static void target_complete_tmr_failure(struct work_struct *work)
5545
5546 se_cmd->se_tmr_req->response = TMR_LUN_DOES_NOT_EXIST;
5547 se_cmd->se_tfo->queue_tm_rsp(se_cmd);
5548+
5549+ transport_cmd_check_stop_to_fabric(se_cmd);
5550 }
5551
5552 /**
5553diff --git a/drivers/target/tcm_fc/tfc_sess.c b/drivers/target/tcm_fc/tfc_sess.c
5554index 3c9e5b5..230d8ec 100644
5555--- a/drivers/target/tcm_fc/tfc_sess.c
5556+++ b/drivers/target/tcm_fc/tfc_sess.c
5557@@ -356,11 +356,11 @@ static int ft_prli_locked(struct fc_rport_priv *rdata, u32 spp_len,
5558
5559 tport = ft_tport_create(rdata->local_port);
5560 if (!tport)
5561- return 0; /* not a target for this local port */
5562+ goto not_target; /* not a target for this local port */
5563
5564 acl = ft_acl_get(tport->tpg, rdata);
5565 if (!acl)
5566- return 0;
5567+ goto not_target; /* no target for this remote */
5568
5569 if (!rspp)
5570 goto fill;
5571@@ -397,12 +397,18 @@ static int ft_prli_locked(struct fc_rport_priv *rdata, u32 spp_len,
5572
5573 /*
5574 * OR in our service parameters with other provider (initiator), if any.
5575- * TBD XXX - indicate RETRY capability?
5576 */
5577 fill:
5578 fcp_parm = ntohl(spp->spp_params);
5579+ fcp_parm &= ~FCP_SPPF_RETRY;
5580 spp->spp_params = htonl(fcp_parm | FCP_SPPF_TARG_FCN);
5581 return FC_SPP_RESP_ACK;
5582+
5583+not_target:
5584+ fcp_parm = ntohl(spp->spp_params);
5585+ fcp_parm &= ~FCP_SPPF_TARG_FCN;
5586+ spp->spp_params = htonl(fcp_parm);
5587+ return 0;
5588 }
5589
5590 /**
5591@@ -431,7 +437,6 @@ static void ft_sess_rcu_free(struct rcu_head *rcu)
5592 {
5593 struct ft_sess *sess = container_of(rcu, struct ft_sess, rcu);
5594
5595- transport_deregister_session(sess->se_sess);
5596 kfree(sess);
5597 }
5598
5599@@ -439,6 +444,7 @@ static void ft_sess_free(struct kref *kref)
5600 {
5601 struct ft_sess *sess = container_of(kref, struct ft_sess, kref);
5602
5603+ transport_deregister_session(sess->se_sess);
5604 call_rcu(&sess->rcu, ft_sess_rcu_free);
5605 }
5606
5607diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c
5608index f574eef..b6dc908 100644
5609--- a/drivers/tty/serial/8250/8250_dw.c
5610+++ b/drivers/tty/serial/8250/8250_dw.c
5611@@ -79,7 +79,7 @@ static int dw8250_handle_irq(struct uart_port *p)
5612 } else if ((iir & UART_IIR_BUSY) == UART_IIR_BUSY) {
5613 /* Clear the USR and write the LCR again. */
5614 (void)p->serial_in(p, UART_USR);
5615- p->serial_out(p, d->last_lcr, UART_LCR);
5616+ p->serial_out(p, UART_LCR, d->last_lcr);
5617
5618 return 1;
5619 }
5620diff --git a/drivers/tty/serial/ifx6x60.c b/drivers/tty/serial/ifx6x60.c
5621index 3ad079f..f43156f 100644
5622--- a/drivers/tty/serial/ifx6x60.c
5623+++ b/drivers/tty/serial/ifx6x60.c
5624@@ -552,6 +552,7 @@ static void ifx_port_shutdown(struct tty_port *port)
5625 container_of(port, struct ifx_spi_device, tty_port);
5626
5627 mrdy_set_low(ifx_dev);
5628+ del_timer(&ifx_dev->spi_timer);
5629 clear_bit(IFX_SPI_STATE_TIMER_PENDING, &ifx_dev->flags);
5630 tasklet_kill(&ifx_dev->io_work_tasklet);
5631 }
5632diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
5633index 89c752a..d775bc9 100644
5634--- a/drivers/usb/class/cdc-acm.c
5635+++ b/drivers/usb/class/cdc-acm.c
5636@@ -1602,6 +1602,9 @@ static const struct usb_device_id acm_ids[] = {
5637 { USB_DEVICE(0x0572, 0x1340), /* Conexant CX93010-2x UCMxx */
5638 .driver_info = NO_UNION_NORMAL,
5639 },
5640+ { USB_DEVICE(0x05f9, 0x4002), /* PSC Scanning, Magellan 800i */
5641+ .driver_info = NO_UNION_NORMAL,
5642+ },
5643 { USB_DEVICE(0x1bbb, 0x0003), /* Alcatel OT-I650 */
5644 .driver_info = NO_UNION_NORMAL, /* reports zero length descriptor */
5645 },
5646diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
5647index fe7faf0..3736c65 100644
5648--- a/drivers/usb/core/hub.c
5649+++ b/drivers/usb/core/hub.c
5650@@ -867,6 +867,60 @@ static int hub_hub_status(struct usb_hub *hub,
5651 return ret;
5652 }
5653
5654+static int hub_set_port_link_state(struct usb_hub *hub, int port1,
5655+ unsigned int link_status)
5656+{
5657+ return set_port_feature(hub->hdev,
5658+ port1 | (link_status << 3),
5659+ USB_PORT_FEAT_LINK_STATE);
5660+}
5661+
5662+/*
5663+ * If USB 3.0 ports are placed into the Disabled state, they will no longer
5664+ * detect any device connects or disconnects. This is generally not what the
5665+ * USB core wants, since it expects a disabled port to produce a port status
5666+ * change event when a new device connects.
5667+ *
5668+ * Instead, set the link state to Disabled, wait for the link to settle into
5669+ * that state, clear any change bits, and then put the port into the RxDetect
5670+ * state.
5671+ */
5672+static int hub_usb3_port_disable(struct usb_hub *hub, int port1)
5673+{
5674+ int ret;
5675+ int total_time;
5676+ u16 portchange, portstatus;
5677+
5678+ if (!hub_is_superspeed(hub->hdev))
5679+ return -EINVAL;
5680+
5681+ ret = hub_set_port_link_state(hub, port1, USB_SS_PORT_LS_SS_DISABLED);
5682+ if (ret) {
5683+ dev_err(hub->intfdev, "cannot disable port %d (err = %d)\n",
5684+ port1, ret);
5685+ return ret;
5686+ }
5687+
5688+ /* Wait for the link to enter the disabled state. */
5689+ for (total_time = 0; ; total_time += HUB_DEBOUNCE_STEP) {
5690+ ret = hub_port_status(hub, port1, &portstatus, &portchange);
5691+ if (ret < 0)
5692+ return ret;
5693+
5694+ if ((portstatus & USB_PORT_STAT_LINK_STATE) ==
5695+ USB_SS_PORT_LS_SS_DISABLED)
5696+ break;
5697+ if (total_time >= HUB_DEBOUNCE_TIMEOUT)
5698+ break;
5699+ msleep(HUB_DEBOUNCE_STEP);
5700+ }
5701+ if (total_time >= HUB_DEBOUNCE_TIMEOUT)
5702+ dev_warn(hub->intfdev, "Could not disable port %d after %d ms\n",
5703+ port1, total_time);
5704+
5705+ return hub_set_port_link_state(hub, port1, USB_SS_PORT_LS_RX_DETECT);
5706+}
5707+
5708 static int hub_port_disable(struct usb_hub *hub, int port1, int set_state)
5709 {
5710 struct usb_device *hdev = hub->hdev;
5711@@ -875,8 +929,13 @@ static int hub_port_disable(struct usb_hub *hub, int port1, int set_state)
5712 if (hdev->children[port1-1] && set_state)
5713 usb_set_device_state(hdev->children[port1-1],
5714 USB_STATE_NOTATTACHED);
5715- if (!hub->error && !hub_is_superspeed(hub->hdev))
5716- ret = clear_port_feature(hdev, port1, USB_PORT_FEAT_ENABLE);
5717+ if (!hub->error) {
5718+ if (hub_is_superspeed(hub->hdev))
5719+ ret = hub_usb3_port_disable(hub, port1);
5720+ else
5721+ ret = clear_port_feature(hdev, port1,
5722+ USB_PORT_FEAT_ENABLE);
5723+ }
5724 if (ret)
5725 dev_err(hub->intfdev, "cannot disable port %d (err = %d)\n",
5726 port1, ret);
5727@@ -2339,7 +2398,7 @@ static unsigned hub_is_wusb(struct usb_hub *hub)
5728 #define HUB_SHORT_RESET_TIME 10
5729 #define HUB_BH_RESET_TIME 50
5730 #define HUB_LONG_RESET_TIME 200
5731-#define HUB_RESET_TIMEOUT 500
5732+#define HUB_RESET_TIMEOUT 800
5733
5734 static int hub_port_reset(struct usb_hub *hub, int port1,
5735 struct usb_device *udev, unsigned int delay, bool warm);
5736@@ -2374,6 +2433,10 @@ static int hub_port_wait_reset(struct usb_hub *hub, int port1,
5737 if (ret < 0)
5738 return ret;
5739
5740+ /* The port state is unknown until the reset completes. */
5741+ if ((portstatus & USB_PORT_STAT_RESET))
5742+ goto delay;
5743+
5744 /*
5745 * Some buggy devices require a warm reset to be issued even
5746 * when the port appears not to be connected.
5747@@ -2419,11 +2482,7 @@ static int hub_port_wait_reset(struct usb_hub *hub, int port1,
5748 if ((portchange & USB_PORT_STAT_C_CONNECTION))
5749 return -ENOTCONN;
5750
5751- /* if we`ve finished resetting, then break out of
5752- * the loop
5753- */
5754- if (!(portstatus & USB_PORT_STAT_RESET) &&
5755- (portstatus & USB_PORT_STAT_ENABLE)) {
5756+ if ((portstatus & USB_PORT_STAT_ENABLE)) {
5757 if (hub_is_wusb(hub))
5758 udev->speed = USB_SPEED_WIRELESS;
5759 else if (hub_is_superspeed(hub->hdev))
5760@@ -2437,10 +2496,15 @@ static int hub_port_wait_reset(struct usb_hub *hub, int port1,
5761 return 0;
5762 }
5763 } else {
5764- if (portchange & USB_PORT_STAT_C_BH_RESET)
5765- return 0;
5766+ if (!(portstatus & USB_PORT_STAT_CONNECTION) ||
5767+ hub_port_warm_reset_required(hub,
5768+ portstatus))
5769+ return -ENOTCONN;
5770+
5771+ return 0;
5772 }
5773
5774+delay:
5775 /* switch to the long delay after two short delay failures */
5776 if (delay_time >= 2 * HUB_SHORT_RESET_TIME)
5777 delay = HUB_LONG_RESET_TIME;
5778@@ -2464,14 +2528,11 @@ static void hub_port_finish_reset(struct usb_hub *hub, int port1,
5779 msleep(10 + 40);
5780 update_devnum(udev, 0);
5781 hcd = bus_to_hcd(udev->bus);
5782- if (hcd->driver->reset_device) {
5783- *status = hcd->driver->reset_device(hcd, udev);
5784- if (*status < 0) {
5785- dev_err(&udev->dev, "Cannot reset "
5786- "HCD device state\n");
5787- break;
5788- }
5789- }
5790+ /* The xHC may think the device is already reset,
5791+ * so ignore the status.
5792+ */
5793+ if (hcd->driver->reset_device)
5794+ hcd->driver->reset_device(hcd, udev);
5795 }
5796 /* FALL THROUGH */
5797 case -ENOTCONN:
5798@@ -2479,16 +2540,16 @@ static void hub_port_finish_reset(struct usb_hub *hub, int port1,
5799 clear_port_feature(hub->hdev,
5800 port1, USB_PORT_FEAT_C_RESET);
5801 /* FIXME need disconnect() for NOTATTACHED device */
5802- if (warm) {
5803+ if (hub_is_superspeed(hub->hdev)) {
5804 clear_port_feature(hub->hdev, port1,
5805 USB_PORT_FEAT_C_BH_PORT_RESET);
5806 clear_port_feature(hub->hdev, port1,
5807 USB_PORT_FEAT_C_PORT_LINK_STATE);
5808- } else {
5809+ }
5810+ if (!warm)
5811 usb_set_device_state(udev, *status
5812 ? USB_STATE_NOTATTACHED
5813 : USB_STATE_DEFAULT);
5814- }
5815 break;
5816 }
5817 }
5818@@ -2837,7 +2898,7 @@ int usb_port_suspend(struct usb_device *udev, pm_message_t msg)
5819 static int finish_port_resume(struct usb_device *udev)
5820 {
5821 int status = 0;
5822- u16 devstatus;
5823+ u16 devstatus = 0;
5824
5825 /* caller owns the udev device lock */
5826 dev_dbg(&udev->dev, "%s\n",
5827@@ -2882,7 +2943,13 @@ static int finish_port_resume(struct usb_device *udev)
5828 if (status) {
5829 dev_dbg(&udev->dev, "gone after usb resume? status %d\n",
5830 status);
5831- } else if (udev->actconfig) {
5832+ /*
5833+ * There are a few quirky devices which violate the standard
5834+ * by claiming to have remote wakeup enabled after a reset,
5835+ * which crash if the feature is cleared, hence check for
5836+ * udev->reset_resume
5837+ */
5838+ } else if (udev->actconfig && !udev->reset_resume) {
5839 le16_to_cpus(&devstatus);
5840 if (devstatus & (1 << USB_DEVICE_REMOTE_WAKEUP)) {
5841 status = usb_control_msg(udev,
5842@@ -4511,9 +4578,14 @@ static void hub_events(void)
5843 * SS.Inactive state.
5844 */
5845 if (hub_port_warm_reset_required(hub, portstatus)) {
5846+ int status;
5847+
5848 dev_dbg(hub_dev, "warm reset port %d\n", i);
5849- hub_port_reset(hub, i, NULL,
5850+ status = hub_port_reset(hub, i, NULL,
5851 HUB_BH_RESET_TIME, true);
5852+ if (status < 0)
5853+ hub_port_disable(hub, i, 1);
5854+ connect_change = 0;
5855 }
5856
5857 if (connect_change)
5858diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
5859index 0ab7da2..583150b 100644
5860--- a/drivers/usb/core/message.c
5861+++ b/drivers/usb/core/message.c
5862@@ -1808,29 +1808,8 @@ free_interfaces:
5863 goto free_interfaces;
5864 }
5865
5866- ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
5867- USB_REQ_SET_CONFIGURATION, 0, configuration, 0,
5868- NULL, 0, USB_CTRL_SET_TIMEOUT);
5869- if (ret < 0) {
5870- /* All the old state is gone, so what else can we do?
5871- * The device is probably useless now anyway.
5872- */
5873- cp = NULL;
5874- }
5875-
5876- dev->actconfig = cp;
5877- if (!cp) {
5878- usb_set_device_state(dev, USB_STATE_ADDRESS);
5879- usb_hcd_alloc_bandwidth(dev, NULL, NULL, NULL);
5880- /* Leave LPM disabled while the device is unconfigured. */
5881- mutex_unlock(hcd->bandwidth_mutex);
5882- usb_autosuspend_device(dev);
5883- goto free_interfaces;
5884- }
5885- mutex_unlock(hcd->bandwidth_mutex);
5886- usb_set_device_state(dev, USB_STATE_CONFIGURED);
5887-
5888- /* Initialize the new interface structures and the
5889+ /*
5890+ * Initialize the new interface structures and the
5891 * hc/hcd/usbcore interface/endpoint state.
5892 */
5893 for (i = 0; i < nintf; ++i) {
5894@@ -1874,6 +1853,35 @@ free_interfaces:
5895 }
5896 kfree(new_interfaces);
5897
5898+ ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
5899+ USB_REQ_SET_CONFIGURATION, 0, configuration, 0,
5900+ NULL, 0, USB_CTRL_SET_TIMEOUT);
5901+ if (ret < 0 && cp) {
5902+ /*
5903+ * All the old state is gone, so what else can we do?
5904+ * The device is probably useless now anyway.
5905+ */
5906+ usb_hcd_alloc_bandwidth(dev, NULL, NULL, NULL);
5907+ for (i = 0; i < nintf; ++i) {
5908+ usb_disable_interface(dev, cp->interface[i], true);
5909+ put_device(&cp->interface[i]->dev);
5910+ cp->interface[i] = NULL;
5911+ }
5912+ cp = NULL;
5913+ }
5914+
5915+ dev->actconfig = cp;
5916+ mutex_unlock(hcd->bandwidth_mutex);
5917+
5918+ if (!cp) {
5919+ usb_set_device_state(dev, USB_STATE_ADDRESS);
5920+
5921+ /* Leave LPM disabled while the device is unconfigured. */
5922+ usb_autosuspend_device(dev);
5923+ return ret;
5924+ }
5925+ usb_set_device_state(dev, USB_STATE_CONFIGURED);
5926+
5927 if (cp->string == NULL &&
5928 !(dev->quirks & USB_QUIRK_CONFIG_INTF_STRINGS))
5929 cp->string = usb_cache_string(dev, cp->desc.iConfiguration);
5930diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
5931index eb0fd10..b6c4084 100644
5932--- a/drivers/usb/dwc3/gadget.c
5933+++ b/drivers/usb/dwc3/gadget.c
5934@@ -1619,6 +1619,7 @@ static int __devinit dwc3_gadget_init_endpoints(struct dwc3 *dwc)
5935
5936 if (epnum == 0 || epnum == 1) {
5937 dep->endpoint.maxpacket = 512;
5938+ dep->endpoint.maxburst = 1;
5939 dep->endpoint.ops = &dwc3_gadget_ep0_ops;
5940 if (!epnum)
5941 dwc->gadget.ep0 = &dep->endpoint;
5942diff --git a/drivers/usb/gadget/dummy_hcd.c b/drivers/usb/gadget/dummy_hcd.c
5943index afdbb1c..4ad1f1c 100644
5944--- a/drivers/usb/gadget/dummy_hcd.c
5945+++ b/drivers/usb/gadget/dummy_hcd.c
5946@@ -126,10 +126,7 @@ static const char ep0name[] = "ep0";
5947 static const char *const ep_name[] = {
5948 ep0name, /* everyone has ep0 */
5949
5950- /* act like a net2280: high speed, six configurable endpoints */
5951- "ep-a", "ep-b", "ep-c", "ep-d", "ep-e", "ep-f",
5952-
5953- /* or like pxa250: fifteen fixed function endpoints */
5954+ /* act like a pxa250: fifteen fixed function endpoints */
5955 "ep1in-bulk", "ep2out-bulk", "ep3in-iso", "ep4out-iso", "ep5in-int",
5956 "ep6in-bulk", "ep7out-bulk", "ep8in-iso", "ep9out-iso", "ep10in-int",
5957 "ep11in-bulk", "ep12out-bulk", "ep13in-iso", "ep14out-iso",
5958@@ -137,6 +134,10 @@ static const char *const ep_name[] = {
5959
5960 /* or like sa1100: two fixed function endpoints */
5961 "ep1out-bulk", "ep2in-bulk",
5962+
5963+ /* and now some generic EPs so we have enough in multi config */
5964+ "ep3out", "ep4in", "ep5out", "ep6out", "ep7in", "ep8out", "ep9in",
5965+ "ep10out", "ep11out", "ep12in", "ep13out", "ep14in", "ep15out",
5966 };
5967 #define DUMMY_ENDPOINTS ARRAY_SIZE(ep_name)
5968
5969diff --git a/drivers/usb/gadget/f_ecm.c b/drivers/usb/gadget/f_ecm.c
5970index 30b908f..672c66a 100644
5971--- a/drivers/usb/gadget/f_ecm.c
5972+++ b/drivers/usb/gadget/f_ecm.c
5973@@ -808,9 +808,9 @@ fail:
5974 /* we might as well release our claims on endpoints */
5975 if (ecm->notify)
5976 ecm->notify->driver_data = NULL;
5977- if (ecm->port.out_ep->desc)
5978+ if (ecm->port.out_ep)
5979 ecm->port.out_ep->driver_data = NULL;
5980- if (ecm->port.in_ep->desc)
5981+ if (ecm->port.in_ep)
5982 ecm->port.in_ep->driver_data = NULL;
5983
5984 ERROR(cdev, "%s: can't bind, err %d\n", f->name, status);
5985diff --git a/drivers/usb/gadget/f_eem.c b/drivers/usb/gadget/f_eem.c
5986index 1a7b2dd..a9cf2052 100644
5987--- a/drivers/usb/gadget/f_eem.c
5988+++ b/drivers/usb/gadget/f_eem.c
5989@@ -319,10 +319,9 @@ fail:
5990 if (f->hs_descriptors)
5991 usb_free_descriptors(f->hs_descriptors);
5992
5993- /* we might as well release our claims on endpoints */
5994- if (eem->port.out_ep->desc)
5995+ if (eem->port.out_ep)
5996 eem->port.out_ep->driver_data = NULL;
5997- if (eem->port.in_ep->desc)
5998+ if (eem->port.in_ep)
5999 eem->port.in_ep->driver_data = NULL;
6000
6001 ERROR(cdev, "%s: can't bind, err %d\n", f->name, status);
6002diff --git a/drivers/usb/gadget/f_midi.c b/drivers/usb/gadget/f_midi.c
6003index 2f7e8f2..1bf9596 100644
6004--- a/drivers/usb/gadget/f_midi.c
6005+++ b/drivers/usb/gadget/f_midi.c
6006@@ -416,6 +416,7 @@ static void f_midi_unbind(struct usb_configuration *c, struct usb_function *f)
6007 midi->id = NULL;
6008
6009 usb_free_descriptors(f->descriptors);
6010+ usb_free_descriptors(f->hs_descriptors);
6011 kfree(midi);
6012 }
6013
6014diff --git a/drivers/usb/gadget/f_ncm.c b/drivers/usb/gadget/f_ncm.c
6015index aab8ede..d7811ae 100644
6016--- a/drivers/usb/gadget/f_ncm.c
6017+++ b/drivers/usb/gadget/f_ncm.c
6018@@ -1259,9 +1259,9 @@ fail:
6019 /* we might as well release our claims on endpoints */
6020 if (ncm->notify)
6021 ncm->notify->driver_data = NULL;
6022- if (ncm->port.out_ep->desc)
6023+ if (ncm->port.out_ep)
6024 ncm->port.out_ep->driver_data = NULL;
6025- if (ncm->port.in_ep->desc)
6026+ if (ncm->port.in_ep)
6027 ncm->port.in_ep->driver_data = NULL;
6028
6029 ERROR(cdev, "%s: can't bind, err %d\n", f->name, status);
6030diff --git a/drivers/usb/gadget/f_phonet.c b/drivers/usb/gadget/f_phonet.c
6031index 8ee9268..a6c19a4 100644
6032--- a/drivers/usb/gadget/f_phonet.c
6033+++ b/drivers/usb/gadget/f_phonet.c
6034@@ -531,7 +531,7 @@ int pn_bind(struct usb_configuration *c, struct usb_function *f)
6035
6036 req = usb_ep_alloc_request(fp->out_ep, GFP_KERNEL);
6037 if (!req)
6038- goto err;
6039+ goto err_req;
6040
6041 req->complete = pn_rx_complete;
6042 fp->out_reqv[i] = req;
6043@@ -540,14 +540,18 @@ int pn_bind(struct usb_configuration *c, struct usb_function *f)
6044 /* Outgoing USB requests */
6045 fp->in_req = usb_ep_alloc_request(fp->in_ep, GFP_KERNEL);
6046 if (!fp->in_req)
6047- goto err;
6048+ goto err_req;
6049
6050 INFO(cdev, "USB CDC Phonet function\n");
6051 INFO(cdev, "using %s, OUT %s, IN %s\n", cdev->gadget->name,
6052 fp->out_ep->name, fp->in_ep->name);
6053 return 0;
6054
6055+err_req:
6056+ for (i = 0; i < phonet_rxq_size && fp->out_reqv[i]; i++)
6057+ usb_ep_free_request(fp->out_ep, fp->out_reqv[i]);
6058 err:
6059+
6060 if (fp->out_ep)
6061 fp->out_ep->driver_data = NULL;
6062 if (fp->in_ep)
6063diff --git a/drivers/usb/gadget/f_rndis.c b/drivers/usb/gadget/f_rndis.c
6064index b1681e4..47953fe 100644
6065--- a/drivers/usb/gadget/f_rndis.c
6066+++ b/drivers/usb/gadget/f_rndis.c
6067@@ -803,9 +803,9 @@ fail:
6068 /* we might as well release our claims on endpoints */
6069 if (rndis->notify)
6070 rndis->notify->driver_data = NULL;
6071- if (rndis->port.out_ep->desc)
6072+ if (rndis->port.out_ep)
6073 rndis->port.out_ep->driver_data = NULL;
6074- if (rndis->port.in_ep->desc)
6075+ if (rndis->port.in_ep)
6076 rndis->port.in_ep->driver_data = NULL;
6077
6078 ERROR(cdev, "%s: can't bind, err %d\n", f->name, status);
6079diff --git a/drivers/usb/gadget/f_subset.c b/drivers/usb/gadget/f_subset.c
6080index 21ab474..e5bb966 100644
6081--- a/drivers/usb/gadget/f_subset.c
6082+++ b/drivers/usb/gadget/f_subset.c
6083@@ -370,9 +370,9 @@ fail:
6084 usb_free_descriptors(f->hs_descriptors);
6085
6086 /* we might as well release our claims on endpoints */
6087- if (geth->port.out_ep->desc)
6088+ if (geth->port.out_ep)
6089 geth->port.out_ep->driver_data = NULL;
6090- if (geth->port.in_ep->desc)
6091+ if (geth->port.in_ep)
6092 geth->port.in_ep->driver_data = NULL;
6093
6094 ERROR(cdev, "%s: can't bind, err %d\n", f->name, status);
6095diff --git a/drivers/usb/gadget/f_uvc.c b/drivers/usb/gadget/f_uvc.c
6096index 2a8bf06..10f13c1 100644
6097--- a/drivers/usb/gadget/f_uvc.c
6098+++ b/drivers/usb/gadget/f_uvc.c
6099@@ -417,7 +417,6 @@ uvc_register_video(struct uvc_device *uvc)
6100 return -ENOMEM;
6101
6102 video->parent = &cdev->gadget->dev;
6103- video->minor = -1;
6104 video->fops = &uvc_v4l2_fops;
6105 video->release = video_device_release;
6106 strncpy(video->name, cdev->gadget->name, sizeof(video->name));
6107@@ -577,23 +576,12 @@ uvc_function_unbind(struct usb_configuration *c, struct usb_function *f)
6108
6109 INFO(cdev, "uvc_function_unbind\n");
6110
6111- if (uvc->vdev) {
6112- if (uvc->vdev->minor == -1)
6113- video_device_release(uvc->vdev);
6114- else
6115- video_unregister_device(uvc->vdev);
6116- uvc->vdev = NULL;
6117- }
6118-
6119- if (uvc->control_ep)
6120- uvc->control_ep->driver_data = NULL;
6121- if (uvc->video.ep)
6122- uvc->video.ep->driver_data = NULL;
6123+ video_unregister_device(uvc->vdev);
6124+ uvc->control_ep->driver_data = NULL;
6125+ uvc->video.ep->driver_data = NULL;
6126
6127- if (uvc->control_req) {
6128- usb_ep_free_request(cdev->gadget->ep0, uvc->control_req);
6129- kfree(uvc->control_buf);
6130- }
6131+ usb_ep_free_request(cdev->gadget->ep0, uvc->control_req);
6132+ kfree(uvc->control_buf);
6133
6134 kfree(f->descriptors);
6135 kfree(f->hs_descriptors);
6136@@ -740,7 +728,22 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f)
6137 return 0;
6138
6139 error:
6140- uvc_function_unbind(c, f);
6141+ if (uvc->vdev)
6142+ video_device_release(uvc->vdev);
6143+
6144+ if (uvc->control_ep)
6145+ uvc->control_ep->driver_data = NULL;
6146+ if (uvc->video.ep)
6147+ uvc->video.ep->driver_data = NULL;
6148+
6149+ if (uvc->control_req) {
6150+ usb_ep_free_request(cdev->gadget->ep0, uvc->control_req);
6151+ kfree(uvc->control_buf);
6152+ }
6153+
6154+ kfree(f->descriptors);
6155+ kfree(f->hs_descriptors);
6156+ kfree(f->ss_descriptors);
6157 return ret;
6158 }
6159
6160diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
6161index 2cb7d37..f42b68e 100644
6162--- a/drivers/usb/host/ehci-pci.c
6163+++ b/drivers/usb/host/ehci-pci.c
6164@@ -334,7 +334,8 @@ static bool usb_is_intel_switchable_ehci(struct pci_dev *pdev)
6165 pdev->vendor == PCI_VENDOR_ID_INTEL &&
6166 (pdev->device == 0x1E26 ||
6167 pdev->device == 0x8C2D ||
6168- pdev->device == 0x8C26);
6169+ pdev->device == 0x8C26 ||
6170+ pdev->device == 0x9C26);
6171 }
6172
6173 static void ehci_enable_xhci_companion(void)
6174diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c
6175index 39f9e4a..eb5563a 100644
6176--- a/drivers/usb/host/pci-quirks.c
6177+++ b/drivers/usb/host/pci-quirks.c
6178@@ -723,6 +723,7 @@ static int handshake(void __iomem *ptr, u32 mask, u32 done,
6179 }
6180
6181 #define PCI_DEVICE_ID_INTEL_LYNX_POINT_XHCI 0x8C31
6182+#define PCI_DEVICE_ID_INTEL_LYNX_POINT_LP_XHCI 0x9C31
6183
6184 bool usb_is_intel_ppt_switchable_xhci(struct pci_dev *pdev)
6185 {
6186@@ -736,7 +737,8 @@ bool usb_is_intel_lpt_switchable_xhci(struct pci_dev *pdev)
6187 {
6188 return pdev->class == PCI_CLASS_SERIAL_USB_XHCI &&
6189 pdev->vendor == PCI_VENDOR_ID_INTEL &&
6190- pdev->device == PCI_DEVICE_ID_INTEL_LYNX_POINT_XHCI;
6191+ (pdev->device == PCI_DEVICE_ID_INTEL_LYNX_POINT_XHCI ||
6192+ pdev->device == PCI_DEVICE_ID_INTEL_LYNX_POINT_LP_XHCI);
6193 }
6194
6195 bool usb_is_intel_switchable_xhci(struct pci_dev *pdev)
6196diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c
6197index e4db350..3fe069f 100644
6198--- a/drivers/usb/host/uhci-hcd.c
6199+++ b/drivers/usb/host/uhci-hcd.c
6200@@ -447,6 +447,10 @@ static irqreturn_t uhci_irq(struct usb_hcd *hcd)
6201 return IRQ_NONE;
6202 uhci_writew(uhci, status, USBSTS); /* Clear it */
6203
6204+ spin_lock(&uhci->lock);
6205+ if (unlikely(!uhci->is_initialized)) /* not yet configured */
6206+ goto done;
6207+
6208 if (status & ~(USBSTS_USBINT | USBSTS_ERROR | USBSTS_RD)) {
6209 if (status & USBSTS_HSE)
6210 dev_err(uhci_dev(uhci), "host system error, "
6211@@ -455,7 +459,6 @@ static irqreturn_t uhci_irq(struct usb_hcd *hcd)
6212 dev_err(uhci_dev(uhci), "host controller process "
6213 "error, something bad happened!\n");
6214 if (status & USBSTS_HCH) {
6215- spin_lock(&uhci->lock);
6216 if (uhci->rh_state >= UHCI_RH_RUNNING) {
6217 dev_err(uhci_dev(uhci),
6218 "host controller halted, "
6219@@ -473,15 +476,15 @@ static irqreturn_t uhci_irq(struct usb_hcd *hcd)
6220 * pending unlinks */
6221 mod_timer(&hcd->rh_timer, jiffies);
6222 }
6223- spin_unlock(&uhci->lock);
6224 }
6225 }
6226
6227- if (status & USBSTS_RD)
6228+ if (status & USBSTS_RD) {
6229+ spin_unlock(&uhci->lock);
6230 usb_hcd_poll_rh_status(hcd);
6231- else {
6232- spin_lock(&uhci->lock);
6233+ } else {
6234 uhci_scan_schedule(uhci);
6235+ done:
6236 spin_unlock(&uhci->lock);
6237 }
6238
6239@@ -662,9 +665,9 @@ static int uhci_start(struct usb_hcd *hcd)
6240 */
6241 mb();
6242
6243+ spin_lock_irq(&uhci->lock);
6244 configure_hc(uhci);
6245 uhci->is_initialized = 1;
6246- spin_lock_irq(&uhci->lock);
6247 start_rh(uhci);
6248 spin_unlock_irq(&uhci->lock);
6249 return 0;
6250diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
6251index d5eb357..abb9772 100644
6252--- a/drivers/usb/host/xhci-hub.c
6253+++ b/drivers/usb/host/xhci-hub.c
6254@@ -762,12 +762,39 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
6255 break;
6256 case USB_PORT_FEAT_LINK_STATE:
6257 temp = xhci_readl(xhci, port_array[wIndex]);
6258+
6259+ /* Disable port */
6260+ if (link_state == USB_SS_PORT_LS_SS_DISABLED) {
6261+ xhci_dbg(xhci, "Disable port %d\n", wIndex);
6262+ temp = xhci_port_state_to_neutral(temp);
6263+ /*
6264+ * Clear all change bits, so that we get a new
6265+ * connection event.
6266+ */
6267+ temp |= PORT_CSC | PORT_PEC | PORT_WRC |
6268+ PORT_OCC | PORT_RC | PORT_PLC |
6269+ PORT_CEC;
6270+ xhci_writel(xhci, temp | PORT_PE,
6271+ port_array[wIndex]);
6272+ temp = xhci_readl(xhci, port_array[wIndex]);
6273+ break;
6274+ }
6275+
6276+ /* Put link in RxDetect (enable port) */
6277+ if (link_state == USB_SS_PORT_LS_RX_DETECT) {
6278+ xhci_dbg(xhci, "Enable port %d\n", wIndex);
6279+ xhci_set_link_state(xhci, port_array, wIndex,
6280+ link_state);
6281+ temp = xhci_readl(xhci, port_array[wIndex]);
6282+ break;
6283+ }
6284+
6285 /* Software should not attempt to set
6286- * port link state above '5' (Rx.Detect) and the port
6287+ * port link state above '3' (U3) and the port
6288 * must be enabled.
6289 */
6290 if ((temp & PORT_PE) == 0 ||
6291- (link_state > USB_SS_PORT_LS_RX_DETECT)) {
6292+ (link_state > USB_SS_PORT_LS_U3)) {
6293 xhci_warn(xhci, "Cannot set link state.\n");
6294 goto error;
6295 }
6296@@ -938,6 +965,7 @@ int xhci_hub_status_data(struct usb_hcd *hcd, char *buf)
6297 int max_ports;
6298 __le32 __iomem **port_array;
6299 struct xhci_bus_state *bus_state;
6300+ bool reset_change = false;
6301
6302 max_ports = xhci_get_ports(hcd, &port_array);
6303 bus_state = &xhci->bus_state[hcd_index(hcd)];
6304@@ -969,6 +997,12 @@ int xhci_hub_status_data(struct usb_hcd *hcd, char *buf)
6305 buf[(i + 1) / 8] |= 1 << (i + 1) % 8;
6306 status = 1;
6307 }
6308+ if ((temp & PORT_RC))
6309+ reset_change = true;
6310+ }
6311+ if (!status && !reset_change) {
6312+ xhci_dbg(xhci, "%s: stopping port polling.\n", __func__);
6313+ clear_bit(HCD_FLAG_POLL_RH, &hcd->flags);
6314 }
6315 spin_unlock_irqrestore(&xhci->lock, flags);
6316 return status ? retval : 0;
6317diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
6318index 487bc08..35616ff 100644
6319--- a/drivers/usb/host/xhci-mem.c
6320+++ b/drivers/usb/host/xhci-mem.c
6321@@ -205,7 +205,12 @@ static int xhci_alloc_segments_for_ring(struct xhci_hcd *xhci,
6322
6323 next = xhci_segment_alloc(xhci, cycle_state, flags);
6324 if (!next) {
6325- xhci_free_segments_for_ring(xhci, *first);
6326+ prev = *first;
6327+ while (prev) {
6328+ next = prev->next;
6329+ xhci_segment_free(xhci, prev);
6330+ prev = next;
6331+ }
6332 return -ENOMEM;
6333 }
6334 xhci_link_segments(xhci, prev, next, type);
6335@@ -258,7 +263,7 @@ static struct xhci_ring *xhci_ring_alloc(struct xhci_hcd *xhci,
6336 return ring;
6337
6338 fail:
6339- xhci_ring_free(xhci, ring);
6340+ kfree(ring);
6341 return NULL;
6342 }
6343
6344@@ -1245,6 +1250,8 @@ static unsigned int xhci_microframes_to_exponent(struct usb_device *udev,
6345 static unsigned int xhci_parse_microframe_interval(struct usb_device *udev,
6346 struct usb_host_endpoint *ep)
6347 {
6348+ if (ep->desc.bInterval == 0)
6349+ return 0;
6350 return xhci_microframes_to_exponent(udev, ep,
6351 ep->desc.bInterval, 0, 15);
6352 }
6353diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
6354index 4f1e265..7024536 100644
6355--- a/drivers/usb/host/xhci-ring.c
6356+++ b/drivers/usb/host/xhci-ring.c
6357@@ -1725,6 +1725,15 @@ cleanup:
6358 if (bogus_port_status)
6359 return;
6360
6361+ /*
6362+ * xHCI port-status-change events occur when the "or" of all the
6363+ * status-change bits in the portsc register changes from 0 to 1.
6364+ * New status changes won't cause an event if any other change
6365+ * bits are still set. When an event occurs, switch over to
6366+ * polling to avoid losing status changes.
6367+ */
6368+ xhci_dbg(xhci, "%s: starting port polling.\n", __func__);
6369+ set_bit(HCD_FLAG_POLL_RH, &hcd->flags);
6370 spin_unlock(&xhci->lock);
6371 /* Pass this up to the core */
6372 usb_hcd_poll_rh_status(hcd);
6373@@ -3069,11 +3078,11 @@ static u32 xhci_td_remainder(unsigned int remainder)
6374 }
6375
6376 /*
6377- * For xHCI 1.0 host controllers, TD size is the number of packets remaining in
6378- * the TD (*not* including this TRB).
6379+ * For xHCI 1.0 host controllers, TD size is the number of max packet sized
6380+ * packets remaining in the TD (*not* including this TRB).
6381 *
6382 * Total TD packet count = total_packet_count =
6383- * roundup(TD size in bytes / wMaxPacketSize)
6384+ * DIV_ROUND_UP(TD size in bytes / wMaxPacketSize)
6385 *
6386 * Packets transferred up to and including this TRB = packets_transferred =
6387 * rounddown(total bytes transferred including this TRB / wMaxPacketSize)
6388@@ -3081,15 +3090,16 @@ static u32 xhci_td_remainder(unsigned int remainder)
6389 * TD size = total_packet_count - packets_transferred
6390 *
6391 * It must fit in bits 21:17, so it can't be bigger than 31.
6392+ * The last TRB in a TD must have the TD size set to zero.
6393 */
6394-
6395 static u32 xhci_v1_0_td_remainder(int running_total, int trb_buff_len,
6396- unsigned int total_packet_count, struct urb *urb)
6397+ unsigned int total_packet_count, struct urb *urb,
6398+ unsigned int num_trbs_left)
6399 {
6400 int packets_transferred;
6401
6402 /* One TRB with a zero-length data packet. */
6403- if (running_total == 0 && trb_buff_len == 0)
6404+ if (num_trbs_left == 0 || (running_total == 0 && trb_buff_len == 0))
6405 return 0;
6406
6407 /* All the TRB queueing functions don't count the current TRB in
6408@@ -3098,7 +3108,9 @@ static u32 xhci_v1_0_td_remainder(int running_total, int trb_buff_len,
6409 packets_transferred = (running_total + trb_buff_len) /
6410 usb_endpoint_maxp(&urb->ep->desc);
6411
6412- return xhci_td_remainder(total_packet_count - packets_transferred);
6413+ if ((total_packet_count - packets_transferred) > 31)
6414+ return 31 << 17;
6415+ return (total_packet_count - packets_transferred) << 17;
6416 }
6417
6418 static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
6419@@ -3125,7 +3137,7 @@ static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
6420
6421 num_trbs = count_sg_trbs_needed(xhci, urb);
6422 num_sgs = urb->num_mapped_sgs;
6423- total_packet_count = roundup(urb->transfer_buffer_length,
6424+ total_packet_count = DIV_ROUND_UP(urb->transfer_buffer_length,
6425 usb_endpoint_maxp(&urb->ep->desc));
6426
6427 trb_buff_len = prepare_transfer(xhci, xhci->devs[slot_id],
6428@@ -3208,7 +3220,8 @@ static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
6429 running_total);
6430 } else {
6431 remainder = xhci_v1_0_td_remainder(running_total,
6432- trb_buff_len, total_packet_count, urb);
6433+ trb_buff_len, total_packet_count, urb,
6434+ num_trbs - 1);
6435 }
6436 length_field = TRB_LEN(trb_buff_len) |
6437 remainder |
6438@@ -3316,7 +3329,7 @@ int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
6439 start_cycle = ep_ring->cycle_state;
6440
6441 running_total = 0;
6442- total_packet_count = roundup(urb->transfer_buffer_length,
6443+ total_packet_count = DIV_ROUND_UP(urb->transfer_buffer_length,
6444 usb_endpoint_maxp(&urb->ep->desc));
6445 /* How much data is in the first TRB? */
6446 addr = (u64) urb->transfer_dma;
6447@@ -3362,7 +3375,8 @@ int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
6448 running_total);
6449 } else {
6450 remainder = xhci_v1_0_td_remainder(running_total,
6451- trb_buff_len, total_packet_count, urb);
6452+ trb_buff_len, total_packet_count, urb,
6453+ num_trbs - 1);
6454 }
6455 length_field = TRB_LEN(trb_buff_len) |
6456 remainder |
6457@@ -3625,7 +3639,7 @@ static int xhci_queue_isoc_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
6458 addr = start_addr + urb->iso_frame_desc[i].offset;
6459 td_len = urb->iso_frame_desc[i].length;
6460 td_remain_len = td_len;
6461- total_packet_count = roundup(td_len,
6462+ total_packet_count = DIV_ROUND_UP(td_len,
6463 usb_endpoint_maxp(&urb->ep->desc));
6464 /* A zero-length transfer still involves at least one packet. */
6465 if (total_packet_count == 0)
6466@@ -3704,7 +3718,8 @@ static int xhci_queue_isoc_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
6467 } else {
6468 remainder = xhci_v1_0_td_remainder(
6469 running_total, trb_buff_len,
6470- total_packet_count, urb);
6471+ total_packet_count, urb,
6472+ (trbs_per_td - j - 1));
6473 }
6474 length_field = TRB_LEN(trb_buff_len) |
6475 remainder |
6476diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
6477index a6e910b..b6586e3 100644
6478--- a/drivers/usb/host/xhci.c
6479+++ b/drivers/usb/host/xhci.c
6480@@ -480,7 +480,7 @@ static bool compliance_mode_recovery_timer_quirk_check(void)
6481 if (strstr(dmi_product_name, "Z420") ||
6482 strstr(dmi_product_name, "Z620") ||
6483 strstr(dmi_product_name, "Z820") ||
6484- strstr(dmi_product_name, "Z1"))
6485+ strstr(dmi_product_name, "Z1 Workstation"))
6486 return true;
6487
6488 return false;
6489@@ -880,6 +880,11 @@ int xhci_suspend(struct xhci_hcd *xhci)
6490 struct usb_hcd *hcd = xhci_to_hcd(xhci);
6491 u32 command;
6492
6493+ /* Don't poll the roothubs on bus suspend. */
6494+ xhci_dbg(xhci, "%s: stopping port polling.\n", __func__);
6495+ clear_bit(HCD_FLAG_POLL_RH, &hcd->flags);
6496+ del_timer_sync(&hcd->rh_timer);
6497+
6498 spin_lock_irq(&xhci->lock);
6499 clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
6500 clear_bit(HCD_FLAG_HW_ACCESSIBLE, &xhci->shared_hcd->flags);
6501@@ -1064,6 +1069,11 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
6502 if (xhci->quirks & XHCI_COMP_MODE_QUIRK)
6503 compliance_mode_recovery_timer_init(xhci);
6504
6505+ /* Re-enable port polling. */
6506+ xhci_dbg(xhci, "%s: starting port polling.\n", __func__);
6507+ set_bit(HCD_FLAG_POLL_RH, &hcd->flags);
6508+ usb_hcd_poll_rh_status(hcd);
6509+
6510 return retval;
6511 }
6512 #endif /* CONFIG_PM */
6513@@ -2253,7 +2263,7 @@ static bool xhci_is_async_ep(unsigned int ep_type)
6514
6515 static bool xhci_is_sync_in_ep(unsigned int ep_type)
6516 {
6517- return (ep_type == ISOC_IN_EP || ep_type != INT_IN_EP);
6518+ return (ep_type == ISOC_IN_EP || ep_type == INT_IN_EP);
6519 }
6520
6521 static unsigned int xhci_get_ss_bw_consumed(struct xhci_bw_info *ep_bw)
6522diff --git a/drivers/usb/musb/cppi_dma.c b/drivers/usb/musb/cppi_dma.c
6523index 8637c1f..c5835e8 100644
6524--- a/drivers/usb/musb/cppi_dma.c
6525+++ b/drivers/usb/musb/cppi_dma.c
6526@@ -1314,6 +1314,7 @@ irqreturn_t cppi_interrupt(int irq, void *dev_id)
6527
6528 return IRQ_HANDLED;
6529 }
6530+EXPORT_SYMBOL_GPL(cppi_interrupt);
6531
6532 /* Instantiate a software object representing a DMA controller. */
6533 struct dma_controller *__init
6534diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
6535index 26f1bef..c5630c2 100644
6536--- a/drivers/usb/musb/musb_core.c
6537+++ b/drivers/usb/musb/musb_core.c
6538@@ -2402,10 +2402,7 @@ static int __init musb_init(void)
6539 if (usb_disabled())
6540 return 0;
6541
6542- pr_info("%s: version " MUSB_VERSION ", "
6543- "?dma?"
6544- ", "
6545- "otg (peripheral+host)",
6546+ pr_info("%s: version " MUSB_VERSION ", ?dma?, otg (peripheral+host)\n",
6547 musb_driver_name);
6548 return platform_driver_register(&musb_driver);
6549 }
6550diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
6551index 360bdeb..653139b 100644
6552--- a/drivers/usb/serial/ftdi_sio.c
6553+++ b/drivers/usb/serial/ftdi_sio.c
6554@@ -881,6 +881,8 @@ static struct usb_device_id id_table_combined [] = {
6555 { USB_DEVICE(FTDI_VID, FTDI_DISTORTEC_JTAG_LOCK_PICK_PID),
6556 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
6557 { USB_DEVICE(FTDI_VID, FTDI_LUMEL_PD12_PID) },
6558+ /* Crucible Devices */
6559+ { USB_DEVICE(FTDI_VID, FTDI_CT_COMET_PID) },
6560 { }, /* Optional parameter entry */
6561 { } /* Terminating entry */
6562 };
6563diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h
6564index 049b6e7..fa5d560 100644
6565--- a/drivers/usb/serial/ftdi_sio_ids.h
6566+++ b/drivers/usb/serial/ftdi_sio_ids.h
6567@@ -1259,3 +1259,9 @@
6568 * ATI command output: Cinterion MC55i
6569 */
6570 #define FTDI_CINTERION_MC55I_PID 0xA951
6571+
6572+/*
6573+ * Product: Comet Caller ID decoder
6574+ * Manufacturer: Crucible Technologies
6575+ */
6576+#define FTDI_CT_COMET_PID 0x8e08
6577diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
6578index 56fed62..a3eac65 100644
6579--- a/drivers/usb/serial/option.c
6580+++ b/drivers/usb/serial/option.c
6581@@ -289,6 +289,7 @@ static void option_instat_callback(struct urb *urb);
6582 #define ALCATEL_VENDOR_ID 0x1bbb
6583 #define ALCATEL_PRODUCT_X060S_X200 0x0000
6584 #define ALCATEL_PRODUCT_X220_X500D 0x0017
6585+#define ALCATEL_PRODUCT_L100V 0x011e
6586
6587 #define PIRELLI_VENDOR_ID 0x1266
6588 #define PIRELLI_PRODUCT_C100_1 0x1002
6589@@ -430,9 +431,12 @@ static void option_instat_callback(struct urb *urb);
6590 #define MEDIATEK_VENDOR_ID 0x0e8d
6591 #define MEDIATEK_PRODUCT_DC_1COM 0x00a0
6592 #define MEDIATEK_PRODUCT_DC_4COM 0x00a5
6593+#define MEDIATEK_PRODUCT_DC_4COM2 0x00a7
6594 #define MEDIATEK_PRODUCT_DC_5COM 0x00a4
6595 #define MEDIATEK_PRODUCT_7208_1COM 0x7101
6596 #define MEDIATEK_PRODUCT_7208_2COM 0x7102
6597+#define MEDIATEK_PRODUCT_7103_2COM 0x7103
6598+#define MEDIATEK_PRODUCT_7106_2COM 0x7106
6599 #define MEDIATEK_PRODUCT_FP_1COM 0x0003
6600 #define MEDIATEK_PRODUCT_FP_2COM 0x0023
6601 #define MEDIATEK_PRODUCT_FPDC_1COM 0x0043
6602@@ -442,6 +446,14 @@ static void option_instat_callback(struct urb *urb);
6603 #define CELLIENT_VENDOR_ID 0x2692
6604 #define CELLIENT_PRODUCT_MEN200 0x9005
6605
6606+/* Hyundai Petatel Inc. products */
6607+#define PETATEL_VENDOR_ID 0x1ff4
6608+#define PETATEL_PRODUCT_NP10T 0x600e
6609+
6610+/* TP-LINK Incorporated products */
6611+#define TPLINK_VENDOR_ID 0x2357
6612+#define TPLINK_PRODUCT_MA180 0x0201
6613+
6614 /* some devices interfaces need special handling due to a number of reasons */
6615 enum option_blacklist_reason {
6616 OPTION_BLACKLIST_NONE = 0,
6617@@ -923,8 +935,10 @@ static const struct usb_device_id option_ids[] = {
6618 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0254, 0xff, 0xff, 0xff) },
6619 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0257, 0xff, 0xff, 0xff), /* ZTE MF821 */
6620 .driver_info = (kernel_ulong_t)&net_intf3_blacklist },
6621- { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0265, 0xff, 0xff, 0xff) },
6622- { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0284, 0xff, 0xff, 0xff) },
6623+ { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0265, 0xff, 0xff, 0xff), /* ONDA MT8205 */
6624+ .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
6625+ { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0284, 0xff, 0xff, 0xff), /* ZTE MF880 */
6626+ .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
6627 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0317, 0xff, 0xff, 0xff) },
6628 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0326, 0xff, 0xff, 0xff),
6629 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
6630@@ -1191,6 +1205,8 @@ static const struct usb_device_id option_ids[] = {
6631 .driver_info = (kernel_ulong_t)&alcatel_x200_blacklist
6632 },
6633 { USB_DEVICE(ALCATEL_VENDOR_ID, ALCATEL_PRODUCT_X220_X500D) },
6634+ { USB_DEVICE(ALCATEL_VENDOR_ID, ALCATEL_PRODUCT_L100V),
6635+ .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
6636 { USB_DEVICE(AIRPLUS_VENDOR_ID, AIRPLUS_PRODUCT_MCD650) },
6637 { USB_DEVICE(TLAYTECH_VENDOR_ID, TLAYTECH_PRODUCT_TEU800) },
6638 { USB_DEVICE(LONGCHEER_VENDOR_ID, FOUR_G_SYSTEMS_PRODUCT_W14),
6639@@ -1295,7 +1311,14 @@ static const struct usb_device_id option_ids[] = {
6640 { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, MEDIATEK_PRODUCT_FP_2COM, 0x0a, 0x00, 0x00) },
6641 { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, MEDIATEK_PRODUCT_FPDC_1COM, 0x0a, 0x00, 0x00) },
6642 { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, MEDIATEK_PRODUCT_FPDC_2COM, 0x0a, 0x00, 0x00) },
6643+ { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, MEDIATEK_PRODUCT_7103_2COM, 0xff, 0x00, 0x00) },
6644+ { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, MEDIATEK_PRODUCT_7106_2COM, 0x02, 0x02, 0x01) },
6645+ { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, MEDIATEK_PRODUCT_DC_4COM2, 0xff, 0x02, 0x01) },
6646+ { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, MEDIATEK_PRODUCT_DC_4COM2, 0xff, 0x00, 0x00) },
6647 { USB_DEVICE(CELLIENT_VENDOR_ID, CELLIENT_PRODUCT_MEN200) },
6648+ { USB_DEVICE(PETATEL_VENDOR_ID, PETATEL_PRODUCT_NP10T) },
6649+ { USB_DEVICE(TPLINK_VENDOR_ID, TPLINK_PRODUCT_MA180),
6650+ .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
6651 { } /* Terminating entry */
6652 };
6653 MODULE_DEVICE_TABLE(usb, option_ids);
6654diff --git a/drivers/video/mxsfb.c b/drivers/video/mxsfb.c
6655index 49619b4..f2a49ef 100644
6656--- a/drivers/video/mxsfb.c
6657+++ b/drivers/video/mxsfb.c
6658@@ -369,7 +369,8 @@ static void mxsfb_disable_controller(struct fb_info *fb_info)
6659 loop--;
6660 }
6661
6662- writel(VDCTRL4_SYNC_SIGNALS_ON, host->base + LCDC_VDCTRL4 + REG_CLR);
6663+ reg = readl(host->base + LCDC_VDCTRL4);
6664+ writel(reg & ~VDCTRL4_SYNC_SIGNALS_ON, host->base + LCDC_VDCTRL4);
6665
6666 clk_disable_unprepare(host->clk);
6667
6668diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
6669index 5aa43c3..52bfd07 100644
6670--- a/drivers/virtio/virtio_ring.c
6671+++ b/drivers/virtio/virtio_ring.c
6672@@ -132,6 +132,13 @@ static int vring_add_indirect(struct vring_virtqueue *vq,
6673 unsigned head;
6674 int i;
6675
6676+ /*
6677+ * We require lowmem mappings for the descriptors because
6678+ * otherwise virt_to_phys will give us bogus addresses in the
6679+ * virtqueue.
6680+ */
6681+ gfp &= ~(__GFP_HIGHMEM | __GFP_HIGH);
6682+
6683 desc = kmalloc((out + in) * sizeof(struct vring_desc), gfp);
6684 if (!desc)
6685 return -ENOMEM;
6686diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c
6687index 0067266..22be735 100644
6688--- a/drivers/xen/grant-table.c
6689+++ b/drivers/xen/grant-table.c
6690@@ -54,10 +54,6 @@
6691 /* External tools reserve first few grant table entries. */
6692 #define NR_RESERVED_ENTRIES 8
6693 #define GNTTAB_LIST_END 0xffffffff
6694-#define GREFS_PER_GRANT_FRAME \
6695-(grant_table_version == 1 ? \
6696-(PAGE_SIZE / sizeof(struct grant_entry_v1)) : \
6697-(PAGE_SIZE / sizeof(union grant_entry_v2)))
6698
6699 static grant_ref_t **gnttab_list;
6700 static unsigned int nr_grant_frames;
6701@@ -152,6 +148,7 @@ static struct gnttab_ops *gnttab_interface;
6702 static grant_status_t *grstatus;
6703
6704 static int grant_table_version;
6705+static int grefs_per_grant_frame;
6706
6707 static struct gnttab_free_callback *gnttab_free_callback_list;
6708
6709@@ -766,12 +763,14 @@ static int grow_gnttab_list(unsigned int more_frames)
6710 unsigned int new_nr_grant_frames, extra_entries, i;
6711 unsigned int nr_glist_frames, new_nr_glist_frames;
6712
6713+ BUG_ON(grefs_per_grant_frame == 0);
6714+
6715 new_nr_grant_frames = nr_grant_frames + more_frames;
6716- extra_entries = more_frames * GREFS_PER_GRANT_FRAME;
6717+ extra_entries = more_frames * grefs_per_grant_frame;
6718
6719- nr_glist_frames = (nr_grant_frames * GREFS_PER_GRANT_FRAME + RPP - 1) / RPP;
6720+ nr_glist_frames = (nr_grant_frames * grefs_per_grant_frame + RPP - 1) / RPP;
6721 new_nr_glist_frames =
6722- (new_nr_grant_frames * GREFS_PER_GRANT_FRAME + RPP - 1) / RPP;
6723+ (new_nr_grant_frames * grefs_per_grant_frame + RPP - 1) / RPP;
6724 for (i = nr_glist_frames; i < new_nr_glist_frames; i++) {
6725 gnttab_list[i] = (grant_ref_t *)__get_free_page(GFP_ATOMIC);
6726 if (!gnttab_list[i])
6727@@ -779,12 +778,12 @@ static int grow_gnttab_list(unsigned int more_frames)
6728 }
6729
6730
6731- for (i = GREFS_PER_GRANT_FRAME * nr_grant_frames;
6732- i < GREFS_PER_GRANT_FRAME * new_nr_grant_frames - 1; i++)
6733+ for (i = grefs_per_grant_frame * nr_grant_frames;
6734+ i < grefs_per_grant_frame * new_nr_grant_frames - 1; i++)
6735 gnttab_entry(i) = i + 1;
6736
6737 gnttab_entry(i) = gnttab_free_head;
6738- gnttab_free_head = GREFS_PER_GRANT_FRAME * nr_grant_frames;
6739+ gnttab_free_head = grefs_per_grant_frame * nr_grant_frames;
6740 gnttab_free_count += extra_entries;
6741
6742 nr_grant_frames = new_nr_grant_frames;
6743@@ -904,7 +903,8 @@ EXPORT_SYMBOL_GPL(gnttab_unmap_refs);
6744
6745 static unsigned nr_status_frames(unsigned nr_grant_frames)
6746 {
6747- return (nr_grant_frames * GREFS_PER_GRANT_FRAME + SPP - 1) / SPP;
6748+ BUG_ON(grefs_per_grant_frame == 0);
6749+ return (nr_grant_frames * grefs_per_grant_frame + SPP - 1) / SPP;
6750 }
6751
6752 static int gnttab_map_frames_v1(unsigned long *frames, unsigned int nr_gframes)
6753@@ -1062,6 +1062,7 @@ static void gnttab_request_version(void)
6754 rc = HYPERVISOR_grant_table_op(GNTTABOP_set_version, &gsv, 1);
6755 if (rc == 0 && gsv.version == 2) {
6756 grant_table_version = 2;
6757+ grefs_per_grant_frame = PAGE_SIZE / sizeof(union grant_entry_v2);
6758 gnttab_interface = &gnttab_v2_ops;
6759 } else if (grant_table_version == 2) {
6760 /*
6761@@ -1074,17 +1075,17 @@ static void gnttab_request_version(void)
6762 panic("we need grant tables version 2, but only version 1 is available");
6763 } else {
6764 grant_table_version = 1;
6765+ grefs_per_grant_frame = PAGE_SIZE / sizeof(struct grant_entry_v1);
6766 gnttab_interface = &gnttab_v1_ops;
6767 }
6768 printk(KERN_INFO "Grant tables using version %d layout.\n",
6769 grant_table_version);
6770 }
6771
6772-int gnttab_resume(void)
6773+static int gnttab_setup(void)
6774 {
6775 unsigned int max_nr_gframes;
6776
6777- gnttab_request_version();
6778 max_nr_gframes = gnttab_max_grant_frames();
6779 if (max_nr_gframes < nr_grant_frames)
6780 return -ENOSYS;
6781@@ -1107,6 +1108,12 @@ int gnttab_resume(void)
6782 return 0;
6783 }
6784
6785+int gnttab_resume(void)
6786+{
6787+ gnttab_request_version();
6788+ return gnttab_setup();
6789+}
6790+
6791 int gnttab_suspend(void)
6792 {
6793 gnttab_interface->unmap_frames();
6794@@ -1118,9 +1125,10 @@ static int gnttab_expand(unsigned int req_entries)
6795 int rc;
6796 unsigned int cur, extra;
6797
6798+ BUG_ON(grefs_per_grant_frame == 0);
6799 cur = nr_grant_frames;
6800- extra = ((req_entries + (GREFS_PER_GRANT_FRAME-1)) /
6801- GREFS_PER_GRANT_FRAME);
6802+ extra = ((req_entries + (grefs_per_grant_frame-1)) /
6803+ grefs_per_grant_frame);
6804 if (cur + extra > gnttab_max_grant_frames())
6805 return -ENOSPC;
6806
6807@@ -1138,21 +1146,23 @@ int gnttab_init(void)
6808 unsigned int nr_init_grefs;
6809 int ret;
6810
6811+ gnttab_request_version();
6812 nr_grant_frames = 1;
6813 boot_max_nr_grant_frames = __max_nr_grant_frames();
6814
6815 /* Determine the maximum number of frames required for the
6816 * grant reference free list on the current hypervisor.
6817 */
6818+ BUG_ON(grefs_per_grant_frame == 0);
6819 max_nr_glist_frames = (boot_max_nr_grant_frames *
6820- GREFS_PER_GRANT_FRAME / RPP);
6821+ grefs_per_grant_frame / RPP);
6822
6823 gnttab_list = kmalloc(max_nr_glist_frames * sizeof(grant_ref_t *),
6824 GFP_KERNEL);
6825 if (gnttab_list == NULL)
6826 return -ENOMEM;
6827
6828- nr_glist_frames = (nr_grant_frames * GREFS_PER_GRANT_FRAME + RPP - 1) / RPP;
6829+ nr_glist_frames = (nr_grant_frames * grefs_per_grant_frame + RPP - 1) / RPP;
6830 for (i = 0; i < nr_glist_frames; i++) {
6831 gnttab_list[i] = (grant_ref_t *)__get_free_page(GFP_KERNEL);
6832 if (gnttab_list[i] == NULL) {
6833@@ -1161,12 +1171,12 @@ int gnttab_init(void)
6834 }
6835 }
6836
6837- if (gnttab_resume() < 0) {
6838+ if (gnttab_setup() < 0) {
6839 ret = -ENODEV;
6840 goto ini_nomem;
6841 }
6842
6843- nr_init_grefs = nr_grant_frames * GREFS_PER_GRANT_FRAME;
6844+ nr_init_grefs = nr_grant_frames * grefs_per_grant_frame;
6845
6846 for (i = NR_RESERVED_ENTRIES; i < nr_init_grefs - 1; i++)
6847 gnttab_entry(i) = i + 1;
6848diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c
6849index 790b3cd..772428d 100644
6850--- a/fs/binfmt_misc.c
6851+++ b/fs/binfmt_misc.c
6852@@ -176,7 +176,10 @@ static int load_misc_binary(struct linux_binprm *bprm, struct pt_regs *regs)
6853 goto _error;
6854 bprm->argc ++;
6855
6856- bprm->interp = iname; /* for binfmt_script */
6857+ /* Update interp in case binfmt_script needs it. */
6858+ retval = bprm_change_interp(iname, bprm);
6859+ if (retval < 0)
6860+ goto _error;
6861
6862 interp_file = open_exec (iname);
6863 retval = PTR_ERR (interp_file);
6864diff --git a/fs/binfmt_script.c b/fs/binfmt_script.c
6865index d3b8c1f..df49d48 100644
6866--- a/fs/binfmt_script.c
6867+++ b/fs/binfmt_script.c
6868@@ -82,7 +82,9 @@ static int load_script(struct linux_binprm *bprm,struct pt_regs *regs)
6869 retval = copy_strings_kernel(1, &i_name, bprm);
6870 if (retval) return retval;
6871 bprm->argc++;
6872- bprm->interp = interp;
6873+ retval = bprm_change_interp(interp, bprm);
6874+ if (retval < 0)
6875+ return retval;
6876
6877 /*
6878 * OK, now restart the process with the interpreter's dentry.
6879diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
6880index 1ced2d8..a2e0b94 100644
6881--- a/fs/ceph/addr.c
6882+++ b/fs/ceph/addr.c
6883@@ -267,6 +267,14 @@ static void finish_read(struct ceph_osd_request *req, struct ceph_msg *msg)
6884 kfree(req->r_pages);
6885 }
6886
6887+static void ceph_unlock_page_vector(struct page **pages, int num_pages)
6888+{
6889+ int i;
6890+
6891+ for (i = 0; i < num_pages; i++)
6892+ unlock_page(pages[i]);
6893+}
6894+
6895 /*
6896 * start an async read(ahead) operation. return nr_pages we submitted
6897 * a read for on success, or negative error code.
6898@@ -308,8 +316,8 @@ static int start_read(struct inode *inode, struct list_head *page_list, int max)
6899 NULL, 0,
6900 ci->i_truncate_seq, ci->i_truncate_size,
6901 NULL, false, 1, 0);
6902- if (!req)
6903- return -ENOMEM;
6904+ if (IS_ERR(req))
6905+ return PTR_ERR(req);
6906
6907 /* build page vector */
6908 nr_pages = len >> PAGE_CACHE_SHIFT;
6909@@ -347,6 +355,7 @@ static int start_read(struct inode *inode, struct list_head *page_list, int max)
6910 return nr_pages;
6911
6912 out_pages:
6913+ ceph_unlock_page_vector(pages, nr_pages);
6914 ceph_release_page_vector(pages, nr_pages);
6915 out:
6916 ceph_osdc_put_request(req);
6917@@ -831,8 +840,8 @@ get_more_pages:
6918 ci->i_truncate_size,
6919 &inode->i_mtime, true, 1, 0);
6920
6921- if (!req) {
6922- rc = -ENOMEM;
6923+ if (IS_ERR(req)) {
6924+ rc = PTR_ERR(req);
6925 unlock_page(page);
6926 break;
6927 }
6928diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
6929index 620daad..e7d4077 100644
6930--- a/fs/ceph/caps.c
6931+++ b/fs/ceph/caps.c
6932@@ -1349,11 +1349,15 @@ int __ceph_mark_dirty_caps(struct ceph_inode_info *ci, int mask)
6933 if (!ci->i_head_snapc)
6934 ci->i_head_snapc = ceph_get_snap_context(
6935 ci->i_snap_realm->cached_context);
6936- dout(" inode %p now dirty snapc %p\n", &ci->vfs_inode,
6937- ci->i_head_snapc);
6938+ dout(" inode %p now dirty snapc %p auth cap %p\n",
6939+ &ci->vfs_inode, ci->i_head_snapc, ci->i_auth_cap);
6940 BUG_ON(!list_empty(&ci->i_dirty_item));
6941 spin_lock(&mdsc->cap_dirty_lock);
6942- list_add(&ci->i_dirty_item, &mdsc->cap_dirty);
6943+ if (ci->i_auth_cap)
6944+ list_add(&ci->i_dirty_item, &mdsc->cap_dirty);
6945+ else
6946+ list_add(&ci->i_dirty_item,
6947+ &mdsc->cap_dirty_migrating);
6948 spin_unlock(&mdsc->cap_dirty_lock);
6949 if (ci->i_flushing_caps == 0) {
6950 ihold(inode);
6951@@ -2388,7 +2392,7 @@ static void handle_cap_grant(struct inode *inode, struct ceph_mds_caps *grant,
6952 &atime);
6953
6954 /* max size increase? */
6955- if (max_size != ci->i_max_size) {
6956+ if (ci->i_auth_cap == cap && max_size != ci->i_max_size) {
6957 dout("max_size %lld -> %llu\n", ci->i_max_size, max_size);
6958 ci->i_max_size = max_size;
6959 if (max_size >= ci->i_wanted_max_size) {
6960@@ -2745,6 +2749,7 @@ static void handle_cap_import(struct ceph_mds_client *mdsc,
6961
6962 /* make sure we re-request max_size, if necessary */
6963 spin_lock(&ci->i_ceph_lock);
6964+ ci->i_wanted_max_size = 0; /* reset */
6965 ci->i_requested_max_size = 0;
6966 spin_unlock(&ci->i_ceph_lock);
6967 }
6968@@ -2840,8 +2845,6 @@ void ceph_handle_caps(struct ceph_mds_session *session,
6969 case CEPH_CAP_OP_IMPORT:
6970 handle_cap_import(mdsc, inode, h, session,
6971 snaptrace, snaptrace_len);
6972- ceph_check_caps(ceph_inode(inode), 0, session);
6973- goto done_unlocked;
6974 }
6975
6976 /* the rest require a cap */
6977@@ -2858,6 +2861,7 @@ void ceph_handle_caps(struct ceph_mds_session *session,
6978 switch (op) {
6979 case CEPH_CAP_OP_REVOKE:
6980 case CEPH_CAP_OP_GRANT:
6981+ case CEPH_CAP_OP_IMPORT:
6982 handle_cap_grant(inode, h, session, cap, msg->middle);
6983 goto done_unlocked;
6984
6985diff --git a/fs/ceph/file.c b/fs/ceph/file.c
6986index ecebbc0..5840d2a 100644
6987--- a/fs/ceph/file.c
6988+++ b/fs/ceph/file.c
6989@@ -536,8 +536,8 @@ more:
6990 do_sync,
6991 ci->i_truncate_seq, ci->i_truncate_size,
6992 &mtime, false, 2, page_align);
6993- if (!req)
6994- return -ENOMEM;
6995+ if (IS_ERR(req))
6996+ return PTR_ERR(req);
6997
6998 if (file->f_flags & O_DIRECT) {
6999 pages = ceph_get_direct_page_vector(data, num_pages, false);
7000diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
7001index 4b5762e..81613bc 100644
7002--- a/fs/ceph/inode.c
7003+++ b/fs/ceph/inode.c
7004@@ -1466,7 +1466,7 @@ void __ceph_do_pending_vmtruncate(struct inode *inode)
7005 {
7006 struct ceph_inode_info *ci = ceph_inode(inode);
7007 u64 to;
7008- int wrbuffer_refs, wake = 0;
7009+ int wrbuffer_refs, finish = 0;
7010
7011 retry:
7012 spin_lock(&ci->i_ceph_lock);
7013@@ -1498,15 +1498,18 @@ retry:
7014 truncate_inode_pages(inode->i_mapping, to);
7015
7016 spin_lock(&ci->i_ceph_lock);
7017- ci->i_truncate_pending--;
7018- if (ci->i_truncate_pending == 0)
7019- wake = 1;
7020+ if (to == ci->i_truncate_size) {
7021+ ci->i_truncate_pending = 0;
7022+ finish = 1;
7023+ }
7024 spin_unlock(&ci->i_ceph_lock);
7025+ if (!finish)
7026+ goto retry;
7027
7028 if (wrbuffer_refs == 0)
7029 ceph_check_caps(ci, CHECK_CAPS_AUTHONLY, NULL);
7030- if (wake)
7031- wake_up_all(&ci->i_cap_wq);
7032+
7033+ wake_up_all(&ci->i_cap_wq);
7034 }
7035
7036
7037diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
7038index 1bcf712..0d9864f 100644
7039--- a/fs/ceph/mds_client.c
7040+++ b/fs/ceph/mds_client.c
7041@@ -1876,9 +1876,14 @@ finish:
7042 static void __wake_requests(struct ceph_mds_client *mdsc,
7043 struct list_head *head)
7044 {
7045- struct ceph_mds_request *req, *nreq;
7046+ struct ceph_mds_request *req;
7047+ LIST_HEAD(tmp_list);
7048+
7049+ list_splice_init(head, &tmp_list);
7050
7051- list_for_each_entry_safe(req, nreq, head, r_wait) {
7052+ while (!list_empty(&tmp_list)) {
7053+ req = list_entry(tmp_list.next,
7054+ struct ceph_mds_request, r_wait);
7055 list_del_init(&req->r_wait);
7056 __do_request(mdsc, req);
7057 }
7058diff --git a/fs/ceph/super.c b/fs/ceph/super.c
7059index b982239..2f6212e 100644
7060--- a/fs/ceph/super.c
7061+++ b/fs/ceph/super.c
7062@@ -388,8 +388,6 @@ static int ceph_show_options(struct seq_file *m, struct dentry *root)
7063 seq_printf(m, ",mount_timeout=%d", opt->mount_timeout);
7064 if (opt->osd_idle_ttl != CEPH_OSD_IDLE_TTL_DEFAULT)
7065 seq_printf(m, ",osd_idle_ttl=%d", opt->osd_idle_ttl);
7066- if (opt->osd_timeout != CEPH_OSD_TIMEOUT_DEFAULT)
7067- seq_printf(m, ",osdtimeout=%d", opt->osd_timeout);
7068 if (opt->osd_keepalive_timeout != CEPH_OSD_KEEPALIVE_DEFAULT)
7069 seq_printf(m, ",osdkeepalivetimeout=%d",
7070 opt->osd_keepalive_timeout);
7071diff --git a/fs/cifs/cifs_dfs_ref.c b/fs/cifs/cifs_dfs_ref.c
7072index ce5cbd7..210fce2 100644
7073--- a/fs/cifs/cifs_dfs_ref.c
7074+++ b/fs/cifs/cifs_dfs_ref.c
7075@@ -226,6 +226,8 @@ compose_mount_options_out:
7076 compose_mount_options_err:
7077 kfree(mountdata);
7078 mountdata = ERR_PTR(rc);
7079+ kfree(*devname);
7080+ *devname = NULL;
7081 goto compose_mount_options_out;
7082 }
7083
7084diff --git a/fs/eventpoll.c b/fs/eventpoll.c
7085index eedec84..3b032dd 100644
7086--- a/fs/eventpoll.c
7087+++ b/fs/eventpoll.c
7088@@ -1285,7 +1285,7 @@ static int ep_modify(struct eventpoll *ep, struct epitem *epi, struct epoll_even
7089 * otherwise we might miss an event that happens between the
7090 * f_op->poll() call and the new event set registering.
7091 */
7092- epi->event.events = event->events;
7093+ epi->event.events = event->events; /* need barrier below */
7094 pt._key = event->events;
7095 epi->event.data = event->data; /* protected by mtx */
7096 if (epi->event.events & EPOLLWAKEUP) {
7097@@ -1296,6 +1296,26 @@ static int ep_modify(struct eventpoll *ep, struct epitem *epi, struct epoll_even
7098 }
7099
7100 /*
7101+ * The following barrier has two effects:
7102+ *
7103+ * 1) Flush epi changes above to other CPUs. This ensures
7104+ * we do not miss events from ep_poll_callback if an
7105+ * event occurs immediately after we call f_op->poll().
7106+ * We need this because we did not take ep->lock while
7107+ * changing epi above (but ep_poll_callback does take
7108+ * ep->lock).
7109+ *
7110+ * 2) We also need to ensure we do not miss _past_ events
7111+ * when calling f_op->poll(). This barrier also
7112+ * pairs with the barrier in wq_has_sleeper (see
7113+ * comments for wq_has_sleeper).
7114+ *
7115+ * This barrier will now guarantee ep_poll_callback or f_op->poll
7116+ * (or both) will notice the readiness of an item.
7117+ */
7118+ smp_mb();
7119+
7120+ /*
7121 * Get current event bits. We can safely use the file* here because
7122 * its usage count has been increased by the caller of this function.
7123 */
7124diff --git a/fs/exec.c b/fs/exec.c
7125index fab2c6d..59896ae 100644
7126--- a/fs/exec.c
7127+++ b/fs/exec.c
7128@@ -1202,9 +1202,24 @@ void free_bprm(struct linux_binprm *bprm)
7129 mutex_unlock(&current->signal->cred_guard_mutex);
7130 abort_creds(bprm->cred);
7131 }
7132+ /* If a binfmt changed the interp, free it. */
7133+ if (bprm->interp != bprm->filename)
7134+ kfree(bprm->interp);
7135 kfree(bprm);
7136 }
7137
7138+int bprm_change_interp(char *interp, struct linux_binprm *bprm)
7139+{
7140+ /* If a binfmt changed the interp, free it first. */
7141+ if (bprm->interp != bprm->filename)
7142+ kfree(bprm->interp);
7143+ bprm->interp = kstrdup(interp, GFP_KERNEL);
7144+ if (!bprm->interp)
7145+ return -ENOMEM;
7146+ return 0;
7147+}
7148+EXPORT_SYMBOL(bprm_change_interp);
7149+
7150 /*
7151 * install the new credentials for this executable
7152 */
7153diff --git a/fs/ext4/acl.c b/fs/ext4/acl.c
7154index a5c29bb..8535c45 100644
7155--- a/fs/ext4/acl.c
7156+++ b/fs/ext4/acl.c
7157@@ -410,8 +410,10 @@ ext4_xattr_set_acl(struct dentry *dentry, const char *name, const void *value,
7158
7159 retry:
7160 handle = ext4_journal_start(inode, EXT4_DATA_TRANS_BLOCKS(inode->i_sb));
7161- if (IS_ERR(handle))
7162- return PTR_ERR(handle);
7163+ if (IS_ERR(handle)) {
7164+ error = PTR_ERR(handle);
7165+ goto release_and_out;
7166+ }
7167 error = ext4_set_acl(handle, inode, type, acl);
7168 ext4_journal_stop(handle);
7169 if (error == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries))
7170diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
7171index 741bb94..31be24d 100644
7172--- a/fs/ext4/extents.c
7173+++ b/fs/ext4/extents.c
7174@@ -2176,13 +2176,14 @@ ext4_ext_in_cache(struct inode *inode, ext4_lblk_t block,
7175 * removes index from the index block.
7176 */
7177 static int ext4_ext_rm_idx(handle_t *handle, struct inode *inode,
7178- struct ext4_ext_path *path)
7179+ struct ext4_ext_path *path, int depth)
7180 {
7181 int err;
7182 ext4_fsblk_t leaf;
7183
7184 /* free index block */
7185- path--;
7186+ depth--;
7187+ path = path + depth;
7188 leaf = ext4_idx_pblock(path->p_idx);
7189 if (unlikely(path->p_hdr->eh_entries == 0)) {
7190 EXT4_ERROR_INODE(inode, "path->p_hdr->eh_entries == 0");
7191@@ -2207,6 +2208,19 @@ static int ext4_ext_rm_idx(handle_t *handle, struct inode *inode,
7192
7193 ext4_free_blocks(handle, inode, NULL, leaf, 1,
7194 EXT4_FREE_BLOCKS_METADATA | EXT4_FREE_BLOCKS_FORGET);
7195+
7196+ while (--depth >= 0) {
7197+ if (path->p_idx != EXT_FIRST_INDEX(path->p_hdr))
7198+ break;
7199+ path--;
7200+ err = ext4_ext_get_access(handle, inode, path);
7201+ if (err)
7202+ break;
7203+ path->p_idx->ei_block = (path+1)->p_idx->ei_block;
7204+ err = ext4_ext_dirty(handle, inode, path);
7205+ if (err)
7206+ break;
7207+ }
7208 return err;
7209 }
7210
7211@@ -2540,7 +2554,7 @@ ext4_ext_rm_leaf(handle_t *handle, struct inode *inode,
7212 /* if this leaf is free, then we should
7213 * remove it from index block above */
7214 if (err == 0 && eh->eh_entries == 0 && path[depth].p_bh != NULL)
7215- err = ext4_ext_rm_idx(handle, inode, path + depth);
7216+ err = ext4_ext_rm_idx(handle, inode, path, depth);
7217
7218 out:
7219 return err;
7220@@ -2741,7 +2755,7 @@ cont:
7221 /* index is empty, remove it;
7222 * handle must be already prepared by the
7223 * truncatei_leaf() */
7224- err = ext4_ext_rm_idx(handle, inode, path + i);
7225+ err = ext4_ext_rm_idx(handle, inode, path, i);
7226 }
7227 /* root level has p_bh == NULL, brelse() eats this */
7228 brelse(path[i].p_bh);
7229diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
7230index cc2d77c..c7c6e09 100644
7231--- a/fs/ext4/ialloc.c
7232+++ b/fs/ext4/ialloc.c
7233@@ -753,7 +753,6 @@ got:
7234
7235 BUFFER_TRACE(block_bitmap_bh, "dirty block bitmap");
7236 err = ext4_handle_dirty_metadata(handle, NULL, block_bitmap_bh);
7237- brelse(block_bitmap_bh);
7238
7239 /* recheck and clear flag under lock if we still need to */
7240 ext4_lock_group(sb, group);
7241@@ -766,6 +765,7 @@ got:
7242 ext4_group_desc_csum_set(sb, group, gdp);
7243 }
7244 ext4_unlock_group(sb, group);
7245+ brelse(block_bitmap_bh);
7246
7247 if (err)
7248 goto fail;
7249diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
7250index 2ce16af..7e424eb 100644
7251--- a/fs/ext4/inode.c
7252+++ b/fs/ext4/inode.c
7253@@ -1501,6 +1501,8 @@ static void ext4_da_block_invalidatepages(struct mpage_da_data *mpd)
7254
7255 index = mpd->first_page;
7256 end = mpd->next_page - 1;
7257+
7258+ pagevec_init(&pvec, 0);
7259 while (index <= end) {
7260 nr_pages = pagevec_lookup(&pvec, mapping, index, PAGEVEC_SIZE);
7261 if (nr_pages == 0)
7262diff --git a/fs/ext4/super.c b/fs/ext4/super.c
7263index 2b5fb60..f4665ec 100644
7264--- a/fs/ext4/super.c
7265+++ b/fs/ext4/super.c
7266@@ -1643,9 +1643,7 @@ static int parse_options(char *options, struct super_block *sb,
7267 unsigned int *journal_ioprio,
7268 int is_remount)
7269 {
7270-#ifdef CONFIG_QUOTA
7271 struct ext4_sb_info *sbi = EXT4_SB(sb);
7272-#endif
7273 char *p;
7274 substring_t args[MAX_OPT_ARGS];
7275 int token;
7276@@ -1694,6 +1692,16 @@ static int parse_options(char *options, struct super_block *sb,
7277 }
7278 }
7279 #endif
7280+ if (test_opt(sb, DIOREAD_NOLOCK)) {
7281+ int blocksize =
7282+ BLOCK_SIZE << le32_to_cpu(sbi->s_es->s_log_block_size);
7283+
7284+ if (blocksize < PAGE_CACHE_SIZE) {
7285+ ext4_msg(sb, KERN_ERR, "can't mount with "
7286+ "dioread_nolock if block size != PAGE_SIZE");
7287+ return 0;
7288+ }
7289+ }
7290 return 1;
7291 }
7292
7293@@ -2184,7 +2192,9 @@ static void ext4_orphan_cleanup(struct super_block *sb,
7294 __func__, inode->i_ino, inode->i_size);
7295 jbd_debug(2, "truncating inode %lu to %lld bytes\n",
7296 inode->i_ino, inode->i_size);
7297+ mutex_lock(&inode->i_mutex);
7298 ext4_truncate(inode);
7299+ mutex_unlock(&inode->i_mutex);
7300 nr_truncates++;
7301 } else {
7302 ext4_msg(sb, KERN_DEBUG,
7303@@ -3409,15 +3419,6 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
7304 clear_opt(sb, DELALLOC);
7305 }
7306
7307- blocksize = BLOCK_SIZE << le32_to_cpu(es->s_log_block_size);
7308- if (test_opt(sb, DIOREAD_NOLOCK)) {
7309- if (blocksize < PAGE_SIZE) {
7310- ext4_msg(sb, KERN_ERR, "can't mount with "
7311- "dioread_nolock if block size != PAGE_SIZE");
7312- goto failed_mount;
7313- }
7314- }
7315-
7316 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
7317 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
7318
7319@@ -3459,6 +3460,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
7320 if (!ext4_feature_set_ok(sb, (sb->s_flags & MS_RDONLY)))
7321 goto failed_mount;
7322
7323+ blocksize = BLOCK_SIZE << le32_to_cpu(es->s_log_block_size);
7324 if (blocksize < EXT4_MIN_BLOCK_SIZE ||
7325 blocksize > EXT4_MAX_BLOCK_SIZE) {
7326 ext4_msg(sb, KERN_ERR,
7327@@ -4694,7 +4696,7 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
7328 }
7329
7330 ext4_setup_system_zone(sb);
7331- if (sbi->s_journal == NULL)
7332+ if (sbi->s_journal == NULL && !(old_sb_flags & MS_RDONLY))
7333 ext4_commit_super(sb, 1);
7334
7335 unlock_super(sb);
7336diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c
7337index fb1ab953..2fb20f5 100644
7338--- a/fs/jbd2/transaction.c
7339+++ b/fs/jbd2/transaction.c
7340@@ -209,7 +209,8 @@ repeat:
7341 if (!new_transaction)
7342 goto alloc_transaction;
7343 write_lock(&journal->j_state_lock);
7344- if (!journal->j_running_transaction) {
7345+ if (!journal->j_running_transaction &&
7346+ !journal->j_barrier_count) {
7347 jbd2_get_transaction(journal, new_transaction);
7348 new_transaction = NULL;
7349 }
7350diff --git a/fs/jffs2/nodemgmt.c b/fs/jffs2/nodemgmt.c
7351index 0c96eb5..0331072 100644
7352--- a/fs/jffs2/nodemgmt.c
7353+++ b/fs/jffs2/nodemgmt.c
7354@@ -417,14 +417,16 @@ static int jffs2_do_reserve_space(struct jffs2_sb_info *c, uint32_t minsize,
7355 spin_unlock(&c->erase_completion_lock);
7356
7357 ret = jffs2_prealloc_raw_node_refs(c, jeb, 1);
7358- if (ret)
7359- return ret;
7360+
7361 /* Just lock it again and continue. Nothing much can change because
7362 we hold c->alloc_sem anyway. In fact, it's not entirely clear why
7363 we hold c->erase_completion_lock in the majority of this function...
7364 but that's a question for another (more caffeine-rich) day. */
7365 spin_lock(&c->erase_completion_lock);
7366
7367+ if (ret)
7368+ return ret;
7369+
7370 waste = jeb->free_size;
7371 jffs2_link_node_ref(c, jeb,
7372 (jeb->offset + c->sector_size - waste) | REF_OBSOLETE,
7373diff --git a/fs/nfs/client.c b/fs/nfs/client.c
7374index 0e7cd89..b59f1d8 100644
7375--- a/fs/nfs/client.c
7376+++ b/fs/nfs/client.c
7377@@ -614,8 +614,7 @@ EXPORT_SYMBOL_GPL(nfs_create_rpc_client);
7378 */
7379 static void nfs_destroy_server(struct nfs_server *server)
7380 {
7381- if (!(server->flags & NFS_MOUNT_LOCAL_FLOCK) ||
7382- !(server->flags & NFS_MOUNT_LOCAL_FCNTL))
7383+ if (server->nlm_host)
7384 nlmclnt_done(server->nlm_host);
7385 }
7386
7387diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
7388index 627f108..e210a66 100644
7389--- a/fs/nfs/dir.c
7390+++ b/fs/nfs/dir.c
7391@@ -1155,11 +1155,14 @@ static int nfs_dentry_delete(const struct dentry *dentry)
7392
7393 }
7394
7395+/* Ensure that we revalidate inode->i_nlink */
7396 static void nfs_drop_nlink(struct inode *inode)
7397 {
7398 spin_lock(&inode->i_lock);
7399- if (inode->i_nlink > 0)
7400- drop_nlink(inode);
7401+ /* drop the inode if we're reasonably sure this is the last link */
7402+ if (inode->i_nlink == 1)
7403+ clear_nlink(inode);
7404+ NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ATTR;
7405 spin_unlock(&inode->i_lock);
7406 }
7407
7408@@ -1174,8 +1177,8 @@ static void nfs_dentry_iput(struct dentry *dentry, struct inode *inode)
7409 NFS_I(inode)->cache_validity |= NFS_INO_INVALID_DATA;
7410
7411 if (dentry->d_flags & DCACHE_NFSFS_RENAMED) {
7412- drop_nlink(inode);
7413 nfs_complete_unlink(dentry, inode);
7414+ nfs_drop_nlink(inode);
7415 }
7416 iput(inode);
7417 }
7418@@ -1646,10 +1649,8 @@ static int nfs_safe_remove(struct dentry *dentry)
7419 if (inode != NULL) {
7420 NFS_PROTO(inode)->return_delegation(inode);
7421 error = NFS_PROTO(dir)->remove(dir, &dentry->d_name);
7422- /* The VFS may want to delete this inode */
7423 if (error == 0)
7424 nfs_drop_nlink(inode);
7425- nfs_mark_for_revalidate(inode);
7426 } else
7427 error = NFS_PROTO(dir)->remove(dir, &dentry->d_name);
7428 if (error == -ENOENT)
7429diff --git a/fs/nfs/namespace.c b/fs/nfs/namespace.c
7430index dd057bc..fc8dc20 100644
7431--- a/fs/nfs/namespace.c
7432+++ b/fs/nfs/namespace.c
7433@@ -177,11 +177,31 @@ out_nofree:
7434 return mnt;
7435 }
7436
7437+static int
7438+nfs_namespace_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
7439+{
7440+ if (NFS_FH(dentry->d_inode)->size != 0)
7441+ return nfs_getattr(mnt, dentry, stat);
7442+ generic_fillattr(dentry->d_inode, stat);
7443+ return 0;
7444+}
7445+
7446+static int
7447+nfs_namespace_setattr(struct dentry *dentry, struct iattr *attr)
7448+{
7449+ if (NFS_FH(dentry->d_inode)->size != 0)
7450+ return nfs_setattr(dentry, attr);
7451+ return -EACCES;
7452+}
7453+
7454 const struct inode_operations nfs_mountpoint_inode_operations = {
7455 .getattr = nfs_getattr,
7456+ .setattr = nfs_setattr,
7457 };
7458
7459 const struct inode_operations nfs_referral_inode_operations = {
7460+ .getattr = nfs_namespace_getattr,
7461+ .setattr = nfs_namespace_setattr,
7462 };
7463
7464 static void nfs_expire_automounts(struct work_struct *work)
7465diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
7466index 7bff871..5e61aac 100644
7467--- a/fs/nfs/nfs4proc.c
7468+++ b/fs/nfs/nfs4proc.c
7469@@ -5999,13 +5999,26 @@ static void nfs41_sequence_prepare(struct rpc_task *task, void *data)
7470 rpc_call_start(task);
7471 }
7472
7473+static void nfs41_sequence_prepare_privileged(struct rpc_task *task, void *data)
7474+{
7475+ rpc_task_set_priority(task, RPC_PRIORITY_PRIVILEGED);
7476+ nfs41_sequence_prepare(task, data);
7477+}
7478+
7479 static const struct rpc_call_ops nfs41_sequence_ops = {
7480 .rpc_call_done = nfs41_sequence_call_done,
7481 .rpc_call_prepare = nfs41_sequence_prepare,
7482 .rpc_release = nfs41_sequence_release,
7483 };
7484
7485-static struct rpc_task *_nfs41_proc_sequence(struct nfs_client *clp, struct rpc_cred *cred)
7486+static const struct rpc_call_ops nfs41_sequence_privileged_ops = {
7487+ .rpc_call_done = nfs41_sequence_call_done,
7488+ .rpc_call_prepare = nfs41_sequence_prepare_privileged,
7489+ .rpc_release = nfs41_sequence_release,
7490+};
7491+
7492+static struct rpc_task *_nfs41_proc_sequence(struct nfs_client *clp, struct rpc_cred *cred,
7493+ const struct rpc_call_ops *seq_ops)
7494 {
7495 struct nfs4_sequence_data *calldata;
7496 struct rpc_message msg = {
7497@@ -6015,7 +6028,7 @@ static struct rpc_task *_nfs41_proc_sequence(struct nfs_client *clp, struct rpc_
7498 struct rpc_task_setup task_setup_data = {
7499 .rpc_client = clp->cl_rpcclient,
7500 .rpc_message = &msg,
7501- .callback_ops = &nfs41_sequence_ops,
7502+ .callback_ops = seq_ops,
7503 .flags = RPC_TASK_ASYNC | RPC_TASK_SOFT,
7504 };
7505
7506@@ -6042,7 +6055,7 @@ static int nfs41_proc_async_sequence(struct nfs_client *clp, struct rpc_cred *cr
7507
7508 if ((renew_flags & NFS4_RENEW_TIMEOUT) == 0)
7509 return 0;
7510- task = _nfs41_proc_sequence(clp, cred);
7511+ task = _nfs41_proc_sequence(clp, cred, &nfs41_sequence_ops);
7512 if (IS_ERR(task))
7513 ret = PTR_ERR(task);
7514 else
7515@@ -6056,7 +6069,7 @@ static int nfs4_proc_sequence(struct nfs_client *clp, struct rpc_cred *cred)
7516 struct rpc_task *task;
7517 int ret;
7518
7519- task = _nfs41_proc_sequence(clp, cred);
7520+ task = _nfs41_proc_sequence(clp, cred, &nfs41_sequence_privileged_ops);
7521 if (IS_ERR(task)) {
7522 ret = PTR_ERR(task);
7523 goto out;
7524diff --git a/fs/nfs/super.c b/fs/nfs/super.c
7525index d8d7396..2a31c7f 100644
7526--- a/fs/nfs/super.c
7527+++ b/fs/nfs/super.c
7528@@ -1095,7 +1095,7 @@ static int nfs_get_option_str(substring_t args[], char **option)
7529 {
7530 kfree(*option);
7531 *option = match_strdup(args);
7532- return !option;
7533+ return !*option;
7534 }
7535
7536 static int nfs_get_option_ul(substring_t args[], unsigned long *option)
7537diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
7538index c9c1c0a..ac784eb 100644
7539--- a/fs/nfsd/nfs4proc.c
7540+++ b/fs/nfsd/nfs4proc.c
7541@@ -194,6 +194,7 @@ static __be32
7542 do_open_lookup(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_open *open)
7543 {
7544 struct svc_fh *resfh;
7545+ int accmode;
7546 __be32 status;
7547
7548 resfh = kmalloc(sizeof(struct svc_fh), GFP_KERNEL);
7549@@ -253,9 +254,10 @@ do_open_lookup(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_o
7550 /* set reply cache */
7551 fh_copy_shallow(&open->op_openowner->oo_owner.so_replay.rp_openfh,
7552 &resfh->fh_handle);
7553- if (!open->op_created)
7554- status = do_open_permission(rqstp, resfh, open,
7555- NFSD_MAY_NOP);
7556+ accmode = NFSD_MAY_NOP;
7557+ if (open->op_created)
7558+ accmode |= NFSD_MAY_OWNER_OVERRIDE;
7559+ status = do_open_permission(rqstp, resfh, open, accmode);
7560 set_change_info(&open->op_cinfo, current_fh);
7561 fh_dup2(current_fh, resfh);
7562 out:
7563diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
7564index 5b3224c..0953c6c 100644
7565--- a/fs/nfsd/nfs4state.c
7566+++ b/fs/nfsd/nfs4state.c
7567@@ -2341,7 +2341,7 @@ nfsd4_init_slabs(void)
7568 if (openowner_slab == NULL)
7569 goto out_nomem;
7570 lockowner_slab = kmem_cache_create("nfsd4_lockowners",
7571- sizeof(struct nfs4_openowner), 0, 0, NULL);
7572+ sizeof(struct nfs4_lockowner), 0, 0, NULL);
7573 if (lockowner_slab == NULL)
7574 goto out_nomem;
7575 file_slab = kmem_cache_create("nfsd4_files",
7576diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
7577index 6322df3..1e83186 100644
7578--- a/fs/nfsd/nfs4xdr.c
7579+++ b/fs/nfsd/nfs4xdr.c
7580@@ -2946,11 +2946,16 @@ nfsd4_encode_read(struct nfsd4_compoundres *resp, __be32 nfserr,
7581 len = maxcount;
7582 v = 0;
7583 while (len > 0) {
7584- pn = resp->rqstp->rq_resused++;
7585+ pn = resp->rqstp->rq_resused;
7586+ if (!resp->rqstp->rq_respages[pn]) { /* ran out of pages */
7587+ maxcount -= len;
7588+ break;
7589+ }
7590 resp->rqstp->rq_vec[v].iov_base =
7591 page_address(resp->rqstp->rq_respages[pn]);
7592 resp->rqstp->rq_vec[v].iov_len =
7593 len < PAGE_SIZE ? len : PAGE_SIZE;
7594+ resp->rqstp->rq_resused++;
7595 v++;
7596 len -= PAGE_SIZE;
7597 }
7598@@ -2996,6 +3001,8 @@ nfsd4_encode_readlink(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd
7599 return nfserr;
7600 if (resp->xbuf->page_len)
7601 return nfserr_resource;
7602+ if (!resp->rqstp->rq_respages[resp->rqstp->rq_resused])
7603+ return nfserr_resource;
7604
7605 page = page_address(resp->rqstp->rq_respages[resp->rqstp->rq_resused++]);
7606
7607@@ -3045,6 +3052,8 @@ nfsd4_encode_readdir(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4
7608 return nfserr;
7609 if (resp->xbuf->page_len)
7610 return nfserr_resource;
7611+ if (!resp->rqstp->rq_respages[resp->rqstp->rq_resused])
7612+ return nfserr_resource;
7613
7614 RESERVE_SPACE(NFS4_VERIFIER_SIZE);
7615 savep = p;
7616diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c
7617index 240473c..0d5e021 100644
7618--- a/fs/nfsd/nfssvc.c
7619+++ b/fs/nfsd/nfssvc.c
7620@@ -650,7 +650,7 @@ nfsd_dispatch(struct svc_rqst *rqstp, __be32 *statp)
7621 }
7622
7623 /* Store reply in cache. */
7624- nfsd_cache_update(rqstp, proc->pc_cachetype, statp + 1);
7625+ nfsd_cache_update(rqstp, rqstp->rq_cachetype, statp + 1);
7626 return 1;
7627 }
7628
7629diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
7630index a9269f1..e1b40c7 100644
7631--- a/fs/nfsd/vfs.c
7632+++ b/fs/nfsd/vfs.c
7633@@ -1485,13 +1485,19 @@ do_nfsd_create(struct svc_rqst *rqstp, struct svc_fh *fhp,
7634 case NFS3_CREATE_EXCLUSIVE:
7635 if ( dchild->d_inode->i_mtime.tv_sec == v_mtime
7636 && dchild->d_inode->i_atime.tv_sec == v_atime
7637- && dchild->d_inode->i_size == 0 )
7638+ && dchild->d_inode->i_size == 0 ) {
7639+ if (created)
7640+ *created = 1;
7641 break;
7642+ }
7643 case NFS4_CREATE_EXCLUSIVE4_1:
7644 if ( dchild->d_inode->i_mtime.tv_sec == v_mtime
7645 && dchild->d_inode->i_atime.tv_sec == v_atime
7646- && dchild->d_inode->i_size == 0 )
7647+ && dchild->d_inode->i_size == 0 ) {
7648+ if (created)
7649+ *created = 1;
7650 goto set_attr;
7651+ }
7652 /* fallthru */
7653 case NFS3_CREATE_GUARDED:
7654 err = nfserr_exist;
7655diff --git a/fs/splice.c b/fs/splice.c
7656index 41514dd..c69fbb7 100644
7657--- a/fs/splice.c
7658+++ b/fs/splice.c
7659@@ -696,8 +696,10 @@ static int pipe_to_sendpage(struct pipe_inode_info *pipe,
7660 return -EINVAL;
7661
7662 more = (sd->flags & SPLICE_F_MORE) ? MSG_MORE : 0;
7663- if (sd->len < sd->total_len)
7664+
7665+ if (sd->len < sd->total_len && pipe->nrbufs > 1)
7666 more |= MSG_SENDPAGE_NOTLAST;
7667+
7668 return file->f_op->sendpage(file, buf->page, buf->offset,
7669 sd->len, &pos, more);
7670 }
7671diff --git a/fs/udf/inode.c b/fs/udf/inode.c
7672index aa23346..585ee1c 100644
7673--- a/fs/udf/inode.c
7674+++ b/fs/udf/inode.c
7675@@ -574,6 +574,7 @@ static sector_t inode_getblk(struct inode *inode, sector_t block,
7676 struct udf_inode_info *iinfo = UDF_I(inode);
7677 int goal = 0, pgoal = iinfo->i_location.logicalBlockNum;
7678 int lastblock = 0;
7679+ bool isBeyondEOF;
7680
7681 *err = 0;
7682 *new = 0;
7683@@ -653,7 +654,7 @@ static sector_t inode_getblk(struct inode *inode, sector_t block,
7684 /* Are we beyond EOF? */
7685 if (etype == -1) {
7686 int ret;
7687-
7688+ isBeyondEOF = 1;
7689 if (count) {
7690 if (c)
7691 laarr[0] = laarr[1];
7692@@ -696,6 +697,7 @@ static sector_t inode_getblk(struct inode *inode, sector_t block,
7693 endnum = c + 1;
7694 lastblock = 1;
7695 } else {
7696+ isBeyondEOF = 0;
7697 endnum = startnum = ((count > 2) ? 2 : count);
7698
7699 /* if the current extent is in position 0,
7700@@ -738,10 +740,13 @@ static sector_t inode_getblk(struct inode *inode, sector_t block,
7701 goal, err);
7702 if (!newblocknum) {
7703 brelse(prev_epos.bh);
7704+ brelse(cur_epos.bh);
7705+ brelse(next_epos.bh);
7706 *err = -ENOSPC;
7707 return 0;
7708 }
7709- iinfo->i_lenExtents += inode->i_sb->s_blocksize;
7710+ if (isBeyondEOF)
7711+ iinfo->i_lenExtents += inode->i_sb->s_blocksize;
7712 }
7713
7714 /* if the extent the requsted block is located in contains multiple
7715@@ -768,6 +773,8 @@ static sector_t inode_getblk(struct inode *inode, sector_t block,
7716 udf_update_extents(inode, laarr, startnum, endnum, &prev_epos);
7717
7718 brelse(prev_epos.bh);
7719+ brelse(cur_epos.bh);
7720+ brelse(next_epos.bh);
7721
7722 newblock = udf_get_pblock(inode->i_sb, newblocknum,
7723 iinfo->i_location.partitionReferenceNum, 0);
7724diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c
7725index e562dd4..1236b8c 100644
7726--- a/fs/xfs/xfs_aops.c
7727+++ b/fs/xfs/xfs_aops.c
7728@@ -86,11 +86,11 @@ xfs_destroy_ioend(
7729 }
7730
7731 if (ioend->io_iocb) {
7732+ inode_dio_done(ioend->io_inode);
7733 if (ioend->io_isasync) {
7734 aio_complete(ioend->io_iocb, ioend->io_error ?
7735 ioend->io_error : ioend->io_result, 0);
7736 }
7737- inode_dio_done(ioend->io_inode);
7738 }
7739
7740 mempool_free(ioend, xfs_ioend_pool);
7741diff --git a/include/asm-generic/tlb.h b/include/asm-generic/tlb.h
7742index ed6642a..25f01d0 100644
7743--- a/include/asm-generic/tlb.h
7744+++ b/include/asm-generic/tlb.h
7745@@ -78,6 +78,14 @@ struct mmu_gather_batch {
7746 #define MAX_GATHER_BATCH \
7747 ((PAGE_SIZE - sizeof(struct mmu_gather_batch)) / sizeof(void *))
7748
7749+/*
7750+ * Limit the maximum number of mmu_gather batches to reduce a risk of soft
7751+ * lockups for non-preemptible kernels on huge machines when a lot of memory
7752+ * is zapped during unmapping.
7753+ * 10K pages freed at once should be safe even without a preemption point.
7754+ */
7755+#define MAX_GATHER_BATCH_COUNT (10000UL/MAX_GATHER_BATCH)
7756+
7757 /* struct mmu_gather is an opaque type used by the mm code for passing around
7758 * any data needed by arch specific code for tlb_remove_page.
7759 */
7760@@ -96,6 +104,7 @@ struct mmu_gather {
7761 struct mmu_gather_batch *active;
7762 struct mmu_gather_batch local;
7763 struct page *__pages[MMU_GATHER_BUNDLE];
7764+ unsigned int batch_count;
7765 };
7766
7767 #define HAVE_GENERIC_MMU_GATHER
7768diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
7769index 366422b..eb53e15 100644
7770--- a/include/linux/binfmts.h
7771+++ b/include/linux/binfmts.h
7772@@ -128,6 +128,7 @@ extern int setup_arg_pages(struct linux_binprm * bprm,
7773 unsigned long stack_top,
7774 int executable_stack);
7775 extern int bprm_mm_init(struct linux_binprm *bprm);
7776+extern int bprm_change_interp(char *interp, struct linux_binprm *bprm);
7777 extern int copy_strings_kernel(int argc, const char *const *argv,
7778 struct linux_binprm *bprm);
7779 extern int prepare_bprm_creds(struct linux_binprm *bprm);
7780diff --git a/include/linux/ceph/libceph.h b/include/linux/ceph/libceph.h
7781index 4262478..317aff8 100644
7782--- a/include/linux/ceph/libceph.h
7783+++ b/include/linux/ceph/libceph.h
7784@@ -43,7 +43,6 @@ struct ceph_options {
7785 struct ceph_entity_addr my_addr;
7786 int mount_timeout;
7787 int osd_idle_ttl;
7788- int osd_timeout;
7789 int osd_keepalive_timeout;
7790
7791 /*
7792@@ -63,7 +62,6 @@ struct ceph_options {
7793 * defaults
7794 */
7795 #define CEPH_MOUNT_TIMEOUT_DEFAULT 60
7796-#define CEPH_OSD_TIMEOUT_DEFAULT 60 /* seconds */
7797 #define CEPH_OSD_KEEPALIVE_DEFAULT 5
7798 #define CEPH_OSD_IDLE_TTL_DEFAULT 60
7799
7800diff --git a/include/linux/freezer.h b/include/linux/freezer.h
7801index d09af4b..ee89932 100644
7802--- a/include/linux/freezer.h
7803+++ b/include/linux/freezer.h
7804@@ -75,28 +75,62 @@ static inline bool cgroup_freezing(struct task_struct *task)
7805 */
7806
7807
7808-/* Tell the freezer not to count the current task as freezable. */
7809+/**
7810+ * freezer_do_not_count - tell freezer to ignore %current
7811+ *
7812+ * Tell freezers to ignore the current task when determining whether the
7813+ * target frozen state is reached. IOW, the current task will be
7814+ * considered frozen enough by freezers.
7815+ *
7816+ * The caller shouldn't do anything which isn't allowed for a frozen task
7817+ * until freezer_cont() is called. Usually, freezer[_do_not]_count() pair
7818+ * wrap a scheduling operation and nothing much else.
7819+ */
7820 static inline void freezer_do_not_count(void)
7821 {
7822 current->flags |= PF_FREEZER_SKIP;
7823 }
7824
7825-/*
7826- * Tell the freezer to count the current task as freezable again and try to
7827- * freeze it.
7828+/**
7829+ * freezer_count - tell freezer to stop ignoring %current
7830+ *
7831+ * Undo freezer_do_not_count(). It tells freezers that %current should be
7832+ * considered again and tries to freeze if freezing condition is already in
7833+ * effect.
7834 */
7835 static inline void freezer_count(void)
7836 {
7837 current->flags &= ~PF_FREEZER_SKIP;
7838+ /*
7839+ * If freezing is in progress, the following paired with smp_mb()
7840+ * in freezer_should_skip() ensures that either we see %true
7841+ * freezing() or freezer_should_skip() sees !PF_FREEZER_SKIP.
7842+ */
7843+ smp_mb();
7844 try_to_freeze();
7845 }
7846
7847-/*
7848- * Check if the task should be counted as freezable by the freezer
7849+/**
7850+ * freezer_should_skip - whether to skip a task when determining frozen
7851+ * state is reached
7852+ * @p: task in quesion
7853+ *
7854+ * This function is used by freezers after establishing %true freezing() to
7855+ * test whether a task should be skipped when determining the target frozen
7856+ * state is reached. IOW, if this function returns %true, @p is considered
7857+ * frozen enough.
7858 */
7859-static inline int freezer_should_skip(struct task_struct *p)
7860+static inline bool freezer_should_skip(struct task_struct *p)
7861 {
7862- return !!(p->flags & PF_FREEZER_SKIP);
7863+ /*
7864+ * The following smp_mb() paired with the one in freezer_count()
7865+ * ensures that either freezer_count() sees %true freezing() or we
7866+ * see cleared %PF_FREEZER_SKIP and return %false. This makes it
7867+ * impossible for a task to slip frozen state testing after
7868+ * clearing %PF_FREEZER_SKIP.
7869+ */
7870+ smp_mb();
7871+ return p->flags & PF_FREEZER_SKIP;
7872 }
7873
7874 /*
7875diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
7876index b5d1384..70473da 100644
7877--- a/include/linux/page-flags.h
7878+++ b/include/linux/page-flags.h
7879@@ -362,7 +362,7 @@ static inline void ClearPageCompound(struct page *page)
7880 * pages on the LRU and/or pagecache.
7881 */
7882 TESTPAGEFLAG(Compound, compound)
7883-__PAGEFLAG(Head, compound)
7884+__SETPAGEFLAG(Head, compound) __CLEARPAGEFLAG(Head, compound)
7885
7886 /*
7887 * PG_reclaim is used in combination with PG_compound to mark the
7888@@ -374,8 +374,14 @@ __PAGEFLAG(Head, compound)
7889 * PG_compound & PG_reclaim => Tail page
7890 * PG_compound & ~PG_reclaim => Head page
7891 */
7892+#define PG_head_mask ((1L << PG_compound))
7893 #define PG_head_tail_mask ((1L << PG_compound) | (1L << PG_reclaim))
7894
7895+static inline int PageHead(struct page *page)
7896+{
7897+ return ((page->flags & PG_head_tail_mask) == PG_head_mask);
7898+}
7899+
7900 static inline int PageTail(struct page *page)
7901 {
7902 return ((page->flags & PG_head_tail_mask) == PG_head_tail_mask);
7903diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
7904index 8d3c427..50a6cbe 100644
7905--- a/include/linux/pci_ids.h
7906+++ b/include/linux/pci_ids.h
7907@@ -1566,6 +1566,7 @@
7908 #define PCI_DEVICE_ID_RICOH_RL5C476 0x0476
7909 #define PCI_DEVICE_ID_RICOH_RL5C478 0x0478
7910 #define PCI_DEVICE_ID_RICOH_R5C822 0x0822
7911+#define PCI_DEVICE_ID_RICOH_R5CE822 0xe822
7912 #define PCI_DEVICE_ID_RICOH_R5CE823 0xe823
7913 #define PCI_DEVICE_ID_RICOH_R5C832 0x0832
7914 #define PCI_DEVICE_ID_RICOH_R5C843 0x0843
7915diff --git a/include/linux/sched.h b/include/linux/sched.h
7916index 23bddac..d2bbc12 100644
7917--- a/include/linux/sched.h
7918+++ b/include/linux/sched.h
7919@@ -2684,7 +2684,16 @@ static inline void thread_group_cputime_init(struct signal_struct *sig)
7920 extern void recalc_sigpending_and_wake(struct task_struct *t);
7921 extern void recalc_sigpending(void);
7922
7923-extern void signal_wake_up(struct task_struct *t, int resume_stopped);
7924+extern void signal_wake_up_state(struct task_struct *t, unsigned int state);
7925+
7926+static inline void signal_wake_up(struct task_struct *t, bool resume)
7927+{
7928+ signal_wake_up_state(t, resume ? TASK_WAKEKILL : 0);
7929+}
7930+static inline void ptrace_signal_wake_up(struct task_struct *t, bool resume)
7931+{
7932+ signal_wake_up_state(t, resume ? __TASK_TRACED : 0);
7933+}
7934
7935 /*
7936 * Wrappers for p->thread_info->cpu access. No-op on UP.
7937diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
7938index ba1d361..1832927 100644
7939--- a/include/net/inet_connection_sock.h
7940+++ b/include/net/inet_connection_sock.h
7941@@ -318,6 +318,7 @@ extern void inet_csk_reqsk_queue_prune(struct sock *parent,
7942 const unsigned long max_rto);
7943
7944 extern void inet_csk_destroy_sock(struct sock *sk);
7945+extern void inet_csk_prepare_forced_close(struct sock *sk);
7946
7947 /*
7948 * LISTEN is a special case for poll..
7949diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
7950index 5be8937..fca8bbe 100644
7951--- a/include/target/target_core_base.h
7952+++ b/include/target/target_core_base.h
7953@@ -734,6 +734,8 @@ struct se_subsystem_dev {
7954 };
7955
7956 struct se_device {
7957+#define SE_DEV_LINK_MAGIC 0xfeeddeef
7958+ u32 dev_link_magic;
7959 /* RELATIVE TARGET PORT IDENTIFER Counter */
7960 u16 dev_rpti_counter;
7961 /* Used for SAM Task Attribute ordering */
7962@@ -820,6 +822,8 @@ struct se_port_stat_grps {
7963 };
7964
7965 struct se_lun {
7966+#define SE_LUN_LINK_MAGIC 0xffff7771
7967+ u32 lun_link_magic;
7968 /* See transport_lun_status_table */
7969 enum transport_lun_status_table lun_status;
7970 u32 lun_access;
7971diff --git a/kernel/cgroup.c b/kernel/cgroup.c
7972index ff2bce5..2c0d5d0 100644
7973--- a/kernel/cgroup.c
7974+++ b/kernel/cgroup.c
7975@@ -2635,9 +2635,7 @@ static int cgroup_create_dir(struct cgroup *cgrp, struct dentry *dentry,
7976 dentry->d_fsdata = cgrp;
7977 inc_nlink(parent->d_inode);
7978 rcu_assign_pointer(cgrp->dentry, dentry);
7979- dget(dentry);
7980 }
7981- dput(dentry);
7982
7983 return error;
7984 }
7985diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
7986index 4c69326..e48caf8 100644
7987--- a/kernel/irq/manage.c
7988+++ b/kernel/irq/manage.c
7989@@ -716,6 +716,7 @@ static void
7990 irq_thread_check_affinity(struct irq_desc *desc, struct irqaction *action)
7991 {
7992 cpumask_var_t mask;
7993+ bool valid = true;
7994
7995 if (!test_and_clear_bit(IRQTF_AFFINITY, &action->thread_flags))
7996 return;
7997@@ -730,10 +731,18 @@ irq_thread_check_affinity(struct irq_desc *desc, struct irqaction *action)
7998 }
7999
8000 raw_spin_lock_irq(&desc->lock);
8001- cpumask_copy(mask, desc->irq_data.affinity);
8002+ /*
8003+ * This code is triggered unconditionally. Check the affinity
8004+ * mask pointer. For CPU_MASK_OFFSTACK=n this is optimized out.
8005+ */
8006+ if (desc->irq_data.affinity)
8007+ cpumask_copy(mask, desc->irq_data.affinity);
8008+ else
8009+ valid = false;
8010 raw_spin_unlock_irq(&desc->lock);
8011
8012- set_cpus_allowed_ptr(current, mask);
8013+ if (valid)
8014+ set_cpus_allowed_ptr(current, mask);
8015 free_cpumask_var(mask);
8016 }
8017 #else
8018@@ -936,6 +945,16 @@ __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new)
8019 */
8020 get_task_struct(t);
8021 new->thread = t;
8022+ /*
8023+ * Tell the thread to set its affinity. This is
8024+ * important for shared interrupt handlers as we do
8025+ * not invoke setup_affinity() for the secondary
8026+ * handlers as everything is already set up. Even for
8027+ * interrupts marked with IRQF_NO_BALANCE this is
8028+ * correct as we want the thread to move to the cpu(s)
8029+ * on which the requesting code placed the interrupt.
8030+ */
8031+ set_bit(IRQTF_AFFINITY, &new->thread_flags);
8032 }
8033
8034 if (!alloc_cpumask_var(&mask, GFP_KERNEL)) {
8035diff --git a/kernel/ptrace.c b/kernel/ptrace.c
8036index a232bb5..b96de86b4 100644
8037--- a/kernel/ptrace.c
8038+++ b/kernel/ptrace.c
8039@@ -117,11 +117,45 @@ void __ptrace_unlink(struct task_struct *child)
8040 * TASK_KILLABLE sleeps.
8041 */
8042 if (child->jobctl & JOBCTL_STOP_PENDING || task_is_traced(child))
8043- signal_wake_up(child, task_is_traced(child));
8044+ ptrace_signal_wake_up(child, true);
8045
8046 spin_unlock(&child->sighand->siglock);
8047 }
8048
8049+/* Ensure that nothing can wake it up, even SIGKILL */
8050+static bool ptrace_freeze_traced(struct task_struct *task)
8051+{
8052+ bool ret = false;
8053+
8054+ /* Lockless, nobody but us can set this flag */
8055+ if (task->jobctl & JOBCTL_LISTENING)
8056+ return ret;
8057+
8058+ spin_lock_irq(&task->sighand->siglock);
8059+ if (task_is_traced(task) && !__fatal_signal_pending(task)) {
8060+ task->state = __TASK_TRACED;
8061+ ret = true;
8062+ }
8063+ spin_unlock_irq(&task->sighand->siglock);
8064+
8065+ return ret;
8066+}
8067+
8068+static void ptrace_unfreeze_traced(struct task_struct *task)
8069+{
8070+ if (task->state != __TASK_TRACED)
8071+ return;
8072+
8073+ WARN_ON(!task->ptrace || task->parent != current);
8074+
8075+ spin_lock_irq(&task->sighand->siglock);
8076+ if (__fatal_signal_pending(task))
8077+ wake_up_state(task, __TASK_TRACED);
8078+ else
8079+ task->state = TASK_TRACED;
8080+ spin_unlock_irq(&task->sighand->siglock);
8081+}
8082+
8083 /**
8084 * ptrace_check_attach - check whether ptracee is ready for ptrace operation
8085 * @child: ptracee to check for
8086@@ -151,24 +185,29 @@ int ptrace_check_attach(struct task_struct *child, bool ignore_state)
8087 * be changed by us so it's not changing right after this.
8088 */
8089 read_lock(&tasklist_lock);
8090- if ((child->ptrace & PT_PTRACED) && child->parent == current) {
8091+ if (child->ptrace && child->parent == current) {
8092+ WARN_ON(child->state == __TASK_TRACED);
8093 /*
8094 * child->sighand can't be NULL, release_task()
8095 * does ptrace_unlink() before __exit_signal().
8096 */
8097- spin_lock_irq(&child->sighand->siglock);
8098- WARN_ON_ONCE(task_is_stopped(child));
8099- if (ignore_state || (task_is_traced(child) &&
8100- !(child->jobctl & JOBCTL_LISTENING)))
8101+ if (ignore_state || ptrace_freeze_traced(child))
8102 ret = 0;
8103- spin_unlock_irq(&child->sighand->siglock);
8104 }
8105 read_unlock(&tasklist_lock);
8106
8107- if (!ret && !ignore_state)
8108- ret = wait_task_inactive(child, TASK_TRACED) ? 0 : -ESRCH;
8109+ if (!ret && !ignore_state) {
8110+ if (!wait_task_inactive(child, __TASK_TRACED)) {
8111+ /*
8112+ * This can only happen if may_ptrace_stop() fails and
8113+ * ptrace_stop() changes ->state back to TASK_RUNNING,
8114+ * so we should not worry about leaking __TASK_TRACED.
8115+ */
8116+ WARN_ON(child->state == __TASK_TRACED);
8117+ ret = -ESRCH;
8118+ }
8119+ }
8120
8121- /* All systems go.. */
8122 return ret;
8123 }
8124
8125@@ -310,7 +349,7 @@ static int ptrace_attach(struct task_struct *task, long request,
8126 */
8127 if (task_is_stopped(task) &&
8128 task_set_jobctl_pending(task, JOBCTL_TRAP_STOP | JOBCTL_TRAPPING))
8129- signal_wake_up(task, 1);
8130+ signal_wake_up_state(task, __TASK_STOPPED);
8131
8132 spin_unlock(&task->sighand->siglock);
8133
8134@@ -727,7 +766,7 @@ int ptrace_request(struct task_struct *child, long request,
8135 * tracee into STOP.
8136 */
8137 if (likely(task_set_jobctl_pending(child, JOBCTL_TRAP_STOP)))
8138- signal_wake_up(child, child->jobctl & JOBCTL_LISTENING);
8139+ ptrace_signal_wake_up(child, child->jobctl & JOBCTL_LISTENING);
8140
8141 unlock_task_sighand(child, &flags);
8142 ret = 0;
8143@@ -753,7 +792,7 @@ int ptrace_request(struct task_struct *child, long request,
8144 * start of this trap and now. Trigger re-trap.
8145 */
8146 if (child->jobctl & JOBCTL_TRAP_NOTIFY)
8147- signal_wake_up(child, true);
8148+ ptrace_signal_wake_up(child, true);
8149 ret = 0;
8150 }
8151 unlock_task_sighand(child, &flags);
8152@@ -890,6 +929,8 @@ SYSCALL_DEFINE4(ptrace, long, request, long, pid, unsigned long, addr,
8153 goto out_put_task_struct;
8154
8155 ret = arch_ptrace(child, request, addr, data);
8156+ if (ret || request != PTRACE_DETACH)
8157+ ptrace_unfreeze_traced(child);
8158
8159 out_put_task_struct:
8160 put_task_struct(child);
8161@@ -1029,8 +1070,11 @@ asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
8162
8163 ret = ptrace_check_attach(child, request == PTRACE_KILL ||
8164 request == PTRACE_INTERRUPT);
8165- if (!ret)
8166+ if (!ret) {
8167 ret = compat_arch_ptrace(child, request, addr, data);
8168+ if (ret || request != PTRACE_DETACH)
8169+ ptrace_unfreeze_traced(child);
8170+ }
8171
8172 out_put_task_struct:
8173 put_task_struct(child);
8174diff --git a/kernel/sched/core.c b/kernel/sched/core.c
8175index 1a48cdb..5eb6c96 100644
8176--- a/kernel/sched/core.c
8177+++ b/kernel/sched/core.c
8178@@ -1686,7 +1686,8 @@ out:
8179 */
8180 int wake_up_process(struct task_struct *p)
8181 {
8182- return try_to_wake_up(p, TASK_ALL, 0);
8183+ WARN_ON(task_is_stopped_or_traced(p));
8184+ return try_to_wake_up(p, TASK_NORMAL, 0);
8185 }
8186 EXPORT_SYMBOL(wake_up_process);
8187
8188diff --git a/kernel/signal.c b/kernel/signal.c
8189index be4f856..67b64be 100644
8190--- a/kernel/signal.c
8191+++ b/kernel/signal.c
8192@@ -678,23 +678,17 @@ int dequeue_signal(struct task_struct *tsk, sigset_t *mask, siginfo_t *info)
8193 * No need to set need_resched since signal event passing
8194 * goes through ->blocked
8195 */
8196-void signal_wake_up(struct task_struct *t, int resume)
8197+void signal_wake_up_state(struct task_struct *t, unsigned int state)
8198 {
8199- unsigned int mask;
8200-
8201 set_tsk_thread_flag(t, TIF_SIGPENDING);
8202-
8203 /*
8204- * For SIGKILL, we want to wake it up in the stopped/traced/killable
8205+ * TASK_WAKEKILL also means wake it up in the stopped/traced/killable
8206 * case. We don't check t->state here because there is a race with it
8207 * executing another processor and just now entering stopped state.
8208 * By using wake_up_state, we ensure the process will wake up and
8209 * handle its death signal.
8210 */
8211- mask = TASK_INTERRUPTIBLE;
8212- if (resume)
8213- mask |= TASK_WAKEKILL;
8214- if (!wake_up_state(t, mask))
8215+ if (!wake_up_state(t, state | TASK_INTERRUPTIBLE))
8216 kick_process(t);
8217 }
8218
8219@@ -842,7 +836,7 @@ static void ptrace_trap_notify(struct task_struct *t)
8220 assert_spin_locked(&t->sighand->siglock);
8221
8222 task_set_jobctl_pending(t, JOBCTL_TRAP_NOTIFY);
8223- signal_wake_up(t, t->jobctl & JOBCTL_LISTENING);
8224+ ptrace_signal_wake_up(t, t->jobctl & JOBCTL_LISTENING);
8225 }
8226
8227 /*
8228@@ -1797,6 +1791,10 @@ static inline int may_ptrace_stop(void)
8229 * If SIGKILL was already sent before the caller unlocked
8230 * ->siglock we must see ->core_state != NULL. Otherwise it
8231 * is safe to enter schedule().
8232+ *
8233+ * This is almost outdated, a task with the pending SIGKILL can't
8234+ * block in TASK_TRACED. But PTRACE_EVENT_EXIT can be reported
8235+ * after SIGKILL was already dequeued.
8236 */
8237 if (unlikely(current->mm->core_state) &&
8238 unlikely(current->mm == current->parent->mm))
8239@@ -1922,6 +1920,7 @@ static void ptrace_stop(int exit_code, int why, int clear_code, siginfo_t *info)
8240 if (gstop_done)
8241 do_notify_parent_cldstop(current, false, why);
8242
8243+ /* tasklist protects us from ptrace_freeze_traced() */
8244 __set_current_state(TASK_RUNNING);
8245 if (clear_code)
8246 current->exit_code = 0;
8247diff --git a/kernel/smp.c b/kernel/smp.c
8248index 29dd40a..69f38bd 100644
8249--- a/kernel/smp.c
8250+++ b/kernel/smp.c
8251@@ -33,6 +33,7 @@ struct call_function_data {
8252 struct call_single_data csd;
8253 atomic_t refs;
8254 cpumask_var_t cpumask;
8255+ cpumask_var_t cpumask_ipi;
8256 };
8257
8258 static DEFINE_PER_CPU_SHARED_ALIGNED(struct call_function_data, cfd_data);
8259@@ -56,6 +57,9 @@ hotplug_cfd(struct notifier_block *nfb, unsigned long action, void *hcpu)
8260 if (!zalloc_cpumask_var_node(&cfd->cpumask, GFP_KERNEL,
8261 cpu_to_node(cpu)))
8262 return notifier_from_errno(-ENOMEM);
8263+ if (!zalloc_cpumask_var_node(&cfd->cpumask_ipi, GFP_KERNEL,
8264+ cpu_to_node(cpu)))
8265+ return notifier_from_errno(-ENOMEM);
8266 break;
8267
8268 #ifdef CONFIG_HOTPLUG_CPU
8269@@ -65,6 +69,7 @@ hotplug_cfd(struct notifier_block *nfb, unsigned long action, void *hcpu)
8270 case CPU_DEAD:
8271 case CPU_DEAD_FROZEN:
8272 free_cpumask_var(cfd->cpumask);
8273+ free_cpumask_var(cfd->cpumask_ipi);
8274 break;
8275 #endif
8276 };
8277@@ -526,6 +531,12 @@ void smp_call_function_many(const struct cpumask *mask,
8278 return;
8279 }
8280
8281+ /*
8282+ * After we put an entry into the list, data->cpumask
8283+ * may be cleared again when another CPU sends another IPI for
8284+ * a SMP function call, so data->cpumask will be zero.
8285+ */
8286+ cpumask_copy(data->cpumask_ipi, data->cpumask);
8287 raw_spin_lock_irqsave(&call_function.lock, flags);
8288 /*
8289 * Place entry at the _HEAD_ of the list, so that any cpu still
8290@@ -549,7 +560,7 @@ void smp_call_function_many(const struct cpumask *mask,
8291 smp_mb();
8292
8293 /* Send a message to all CPUs in the map */
8294- arch_send_call_function_ipi_mask(data->cpumask);
8295+ arch_send_call_function_ipi_mask(data->cpumask_ipi);
8296
8297 /* Optionally wait for the CPUs to complete */
8298 if (wait)
8299diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
8300index 781ecc2..7f8a8df 100644
8301--- a/kernel/trace/ftrace.c
8302+++ b/kernel/trace/ftrace.c
8303@@ -3863,7 +3863,7 @@ static int ftrace_module_notify(struct notifier_block *self,
8304
8305 struct notifier_block ftrace_module_nb = {
8306 .notifier_call = ftrace_module_notify,
8307- .priority = 0,
8308+ .priority = INT_MAX, /* Run before anything that can use kprobes */
8309 };
8310
8311 extern unsigned long __start_mcount_loc[];
8312diff --git a/lib/atomic64.c b/lib/atomic64.c
8313index 9785378..08a4f06 100644
8314--- a/lib/atomic64.c
8315+++ b/lib/atomic64.c
8316@@ -31,7 +31,11 @@
8317 static union {
8318 raw_spinlock_t lock;
8319 char pad[L1_CACHE_BYTES];
8320-} atomic64_lock[NR_LOCKS] __cacheline_aligned_in_smp;
8321+} atomic64_lock[NR_LOCKS] __cacheline_aligned_in_smp = {
8322+ [0 ... (NR_LOCKS - 1)] = {
8323+ .lock = __RAW_SPIN_LOCK_UNLOCKED(atomic64_lock.lock),
8324+ },
8325+};
8326
8327 static inline raw_spinlock_t *lock_addr(const atomic64_t *v)
8328 {
8329@@ -173,14 +177,3 @@ int atomic64_add_unless(atomic64_t *v, long long a, long long u)
8330 return ret;
8331 }
8332 EXPORT_SYMBOL(atomic64_add_unless);
8333-
8334-static int init_atomic64_lock(void)
8335-{
8336- int i;
8337-
8338- for (i = 0; i < NR_LOCKS; ++i)
8339- raw_spin_lock_init(&atomic64_lock[i].lock);
8340- return 0;
8341-}
8342-
8343-pure_initcall(init_atomic64_lock);
8344diff --git a/mm/compaction.c b/mm/compaction.c
8345index 7fcd3a5..214944a 100644
8346--- a/mm/compaction.c
8347+++ b/mm/compaction.c
8348@@ -956,7 +956,7 @@ static int compact_node(int nid)
8349 }
8350
8351 /* Compact all nodes in the system */
8352-static int compact_nodes(void)
8353+static void compact_nodes(void)
8354 {
8355 int nid;
8356
8357@@ -965,8 +965,6 @@ static int compact_nodes(void)
8358
8359 for_each_online_node(nid)
8360 compact_node(nid);
8361-
8362- return COMPACT_COMPLETE;
8363 }
8364
8365 /* The written value is actually unused, all memory is compacted */
8366@@ -977,7 +975,7 @@ int sysctl_compaction_handler(struct ctl_table *table, int write,
8367 void __user *buffer, size_t *length, loff_t *ppos)
8368 {
8369 if (write)
8370- return compact_nodes();
8371+ compact_nodes();
8372
8373 return 0;
8374 }
8375diff --git a/mm/memory.c b/mm/memory.c
8376index 5736170..29ffb5c 100644
8377--- a/mm/memory.c
8378+++ b/mm/memory.c
8379@@ -182,10 +182,14 @@ static int tlb_next_batch(struct mmu_gather *tlb)
8380 return 1;
8381 }
8382
8383+ if (tlb->batch_count == MAX_GATHER_BATCH_COUNT)
8384+ return 0;
8385+
8386 batch = (void *)__get_free_pages(GFP_NOWAIT | __GFP_NOWARN, 0);
8387 if (!batch)
8388 return 0;
8389
8390+ tlb->batch_count++;
8391 batch->next = NULL;
8392 batch->nr = 0;
8393 batch->max = MAX_GATHER_BATCH;
8394@@ -214,6 +218,7 @@ void tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, bool fullmm)
8395 tlb->local.nr = 0;
8396 tlb->local.max = ARRAY_SIZE(tlb->__pages);
8397 tlb->active = &tlb->local;
8398+ tlb->batch_count = 0;
8399
8400 #ifdef CONFIG_HAVE_RCU_TABLE_FREE
8401 tlb->batch = NULL;
8402diff --git a/mm/mempolicy.c b/mm/mempolicy.c
8403index 01350d3..5e0fea1 100644
8404--- a/mm/mempolicy.c
8405+++ b/mm/mempolicy.c
8406@@ -2370,8 +2370,7 @@ void numa_default_policy(void)
8407 */
8408
8409 /*
8410- * "local" is pseudo-policy: MPOL_PREFERRED with MPOL_F_LOCAL flag
8411- * Used only for mpol_parse_str() and mpol_to_str()
8412+ * "local" is implemented internally by MPOL_PREFERRED with MPOL_F_LOCAL flag.
8413 */
8414 #define MPOL_LOCAL MPOL_MAX
8415 static const char * const policy_modes[] =
8416@@ -2386,28 +2385,21 @@ static const char * const policy_modes[] =
8417
8418 #ifdef CONFIG_TMPFS
8419 /**
8420- * mpol_parse_str - parse string to mempolicy
8421+ * mpol_parse_str - parse string to mempolicy, for tmpfs mpol mount option.
8422 * @str: string containing mempolicy to parse
8423 * @mpol: pointer to struct mempolicy pointer, returned on success.
8424- * @no_context: flag whether to "contextualize" the mempolicy
8425+ * @unused: redundant argument, to be removed later.
8426 *
8427 * Format of input:
8428 * <mode>[=<flags>][:<nodelist>]
8429 *
8430- * if @no_context is true, save the input nodemask in w.user_nodemask in
8431- * the returned mempolicy. This will be used to "clone" the mempolicy in
8432- * a specific context [cpuset] at a later time. Used to parse tmpfs mpol
8433- * mount option. Note that if 'static' or 'relative' mode flags were
8434- * specified, the input nodemask will already have been saved. Saving
8435- * it again is redundant, but safe.
8436- *
8437 * On success, returns 0, else 1
8438 */
8439-int mpol_parse_str(char *str, struct mempolicy **mpol, int no_context)
8440+int mpol_parse_str(char *str, struct mempolicy **mpol, int unused)
8441 {
8442 struct mempolicy *new = NULL;
8443 unsigned short mode;
8444- unsigned short uninitialized_var(mode_flags);
8445+ unsigned short mode_flags;
8446 nodemask_t nodes;
8447 char *nodelist = strchr(str, ':');
8448 char *flags = strchr(str, '=');
8449@@ -2495,24 +2487,23 @@ int mpol_parse_str(char *str, struct mempolicy **mpol, int no_context)
8450 if (IS_ERR(new))
8451 goto out;
8452
8453- if (no_context) {
8454- /* save for contextualization */
8455- new->w.user_nodemask = nodes;
8456- } else {
8457- int ret;
8458- NODEMASK_SCRATCH(scratch);
8459- if (scratch) {
8460- task_lock(current);
8461- ret = mpol_set_nodemask(new, &nodes, scratch);
8462- task_unlock(current);
8463- } else
8464- ret = -ENOMEM;
8465- NODEMASK_SCRATCH_FREE(scratch);
8466- if (ret) {
8467- mpol_put(new);
8468- goto out;
8469- }
8470- }
8471+ /*
8472+ * Save nodes for mpol_to_str() to show the tmpfs mount options
8473+ * for /proc/mounts, /proc/pid/mounts and /proc/pid/mountinfo.
8474+ */
8475+ if (mode != MPOL_PREFERRED)
8476+ new->v.nodes = nodes;
8477+ else if (nodelist)
8478+ new->v.preferred_node = first_node(nodes);
8479+ else
8480+ new->flags |= MPOL_F_LOCAL;
8481+
8482+ /*
8483+ * Save nodes for contextualization: this will be used to "clone"
8484+ * the mempolicy in a specific context [cpuset] at a later time.
8485+ */
8486+ new->w.user_nodemask = nodes;
8487+
8488 err = 0;
8489
8490 out:
8491@@ -2532,13 +2523,13 @@ out:
8492 * @buffer: to contain formatted mempolicy string
8493 * @maxlen: length of @buffer
8494 * @pol: pointer to mempolicy to be formatted
8495- * @no_context: "context free" mempolicy - use nodemask in w.user_nodemask
8496+ * @unused: redundant argument, to be removed later.
8497 *
8498 * Convert a mempolicy into a string.
8499 * Returns the number of characters in buffer (if positive)
8500 * or an error (negative)
8501 */
8502-int mpol_to_str(char *buffer, int maxlen, struct mempolicy *pol, int no_context)
8503+int mpol_to_str(char *buffer, int maxlen, struct mempolicy *pol, int unused)
8504 {
8505 char *p = buffer;
8506 int l;
8507@@ -2564,7 +2555,7 @@ int mpol_to_str(char *buffer, int maxlen, struct mempolicy *pol, int no_context)
8508 case MPOL_PREFERRED:
8509 nodes_clear(nodes);
8510 if (flags & MPOL_F_LOCAL)
8511- mode = MPOL_LOCAL; /* pseudo-policy */
8512+ mode = MPOL_LOCAL;
8513 else
8514 node_set(pol->v.preferred_node, nodes);
8515 break;
8516@@ -2572,10 +2563,7 @@ int mpol_to_str(char *buffer, int maxlen, struct mempolicy *pol, int no_context)
8517 case MPOL_BIND:
8518 /* Fall through */
8519 case MPOL_INTERLEAVE:
8520- if (no_context)
8521- nodes = pol->w.user_nodemask;
8522- else
8523- nodes = pol->v.nodes;
8524+ nodes = pol->v.nodes;
8525 break;
8526
8527 default:
8528diff --git a/mm/page-writeback.c b/mm/page-writeback.c
8529index 5ad5ce2..7a5f842 100644
8530--- a/mm/page-writeback.c
8531+++ b/mm/page-writeback.c
8532@@ -201,6 +201,18 @@ static unsigned long highmem_dirtyable_memory(unsigned long total)
8533 zone_reclaimable_pages(z) - z->dirty_balance_reserve;
8534 }
8535 /*
8536+ * Unreclaimable memory (kernel memory or anonymous memory
8537+ * without swap) can bring down the dirtyable pages below
8538+ * the zone's dirty balance reserve and the above calculation
8539+ * will underflow. However we still want to add in nodes
8540+ * which are below threshold (negative values) to get a more
8541+ * accurate calculation but make sure that the total never
8542+ * underflows.
8543+ */
8544+ if ((long)x < 0)
8545+ x = 0;
8546+
8547+ /*
8548 * Make sure that the number of highmem pages is never larger
8549 * than the number of the total dirtyable memory. This can only
8550 * occur in very strange VM situations but we want to make sure
8551@@ -222,8 +234,8 @@ static unsigned long global_dirtyable_memory(void)
8552 {
8553 unsigned long x;
8554
8555- x = global_page_state(NR_FREE_PAGES) + global_reclaimable_pages() -
8556- dirty_balance_reserve;
8557+ x = global_page_state(NR_FREE_PAGES) + global_reclaimable_pages();
8558+ x -= min(x, dirty_balance_reserve);
8559
8560 if (!vm_highmem_is_dirtyable)
8561 x -= highmem_dirtyable_memory(x);
8562@@ -290,9 +302,12 @@ static unsigned long zone_dirtyable_memory(struct zone *zone)
8563 * highmem zone can hold its share of dirty pages, so we don't
8564 * care about vm_highmem_is_dirtyable here.
8565 */
8566- return zone_page_state(zone, NR_FREE_PAGES) +
8567- zone_reclaimable_pages(zone) -
8568- zone->dirty_balance_reserve;
8569+ unsigned long nr_pages = zone_page_state(zone, NR_FREE_PAGES) +
8570+ zone_reclaimable_pages(zone);
8571+
8572+ /* don't allow this to underflow */
8573+ nr_pages -= min(nr_pages, zone->dirty_balance_reserve);
8574+ return nr_pages;
8575 }
8576
8577 /**
8578diff --git a/mm/page_alloc.c b/mm/page_alloc.c
8579index d2d8f54..fd56833 100644
8580--- a/mm/page_alloc.c
8581+++ b/mm/page_alloc.c
8582@@ -5455,7 +5455,7 @@ static inline int pfn_to_bitidx(struct zone *zone, unsigned long pfn)
8583 pfn &= (PAGES_PER_SECTION-1);
8584 return (pfn >> pageblock_order) * NR_PAGEBLOCK_BITS;
8585 #else
8586- pfn = pfn - zone->zone_start_pfn;
8587+ pfn = pfn - round_down(zone->zone_start_pfn, pageblock_nr_pages);
8588 return (pfn >> pageblock_order) * NR_PAGEBLOCK_BITS;
8589 #endif /* CONFIG_SPARSEMEM */
8590 }
8591diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
8592index 469daab..1476f26 100644
8593--- a/net/batman-adv/bat_iv_ogm.c
8594+++ b/net/batman-adv/bat_iv_ogm.c
8595@@ -119,7 +119,7 @@ batadv_iv_ogm_emit_send_time(const struct batadv_priv *bat_priv)
8596 unsigned int msecs;
8597
8598 msecs = atomic_read(&bat_priv->orig_interval) - BATADV_JITTER;
8599- msecs += (random32() % 2 * BATADV_JITTER);
8600+ msecs += random32() % (2 * BATADV_JITTER);
8601
8602 return jiffies + msecs_to_jiffies(msecs);
8603 }
8604diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
8605index 0b997c8..aeb0962 100644
8606--- a/net/bluetooth/hci_core.c
8607+++ b/net/bluetooth/hci_core.c
8608@@ -1789,6 +1789,8 @@ void hci_unregister_dev(struct hci_dev *hdev)
8609 for (i = 0; i < NUM_REASSEMBLY; i++)
8610 kfree_skb(hdev->reassembly[i]);
8611
8612+ cancel_work_sync(&hdev->power_on);
8613+
8614 if (!test_bit(HCI_INIT, &hdev->flags) &&
8615 !test_bit(HCI_SETUP, &hdev->dev_flags)) {
8616 hci_dev_lock(hdev);
8617diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
8618index 715d7e3..67d1893 100644
8619--- a/net/bluetooth/hci_event.c
8620+++ b/net/bluetooth/hci_event.c
8621@@ -2387,7 +2387,7 @@ static void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
8622 if (ev->opcode != HCI_OP_NOP)
8623 del_timer(&hdev->cmd_timer);
8624
8625- if (ev->ncmd) {
8626+ if (ev->ncmd && !test_bit(HCI_RESET, &hdev->flags)) {
8627 atomic_set(&hdev->cmd_cnt, 1);
8628 if (!skb_queue_empty(&hdev->cmd_q))
8629 queue_work(hdev->workqueue, &hdev->cmd_work);
8630diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c
8631index ccd985d..03652f3 100644
8632--- a/net/bluetooth/hidp/core.c
8633+++ b/net/bluetooth/hidp/core.c
8634@@ -931,7 +931,7 @@ static int hidp_setup_hid(struct hidp_session *session,
8635 hid->version = req->version;
8636 hid->country = req->country;
8637
8638- strncpy(hid->name, req->name, 128);
8639+ strncpy(hid->name, req->name, sizeof(req->name) - 1);
8640 strncpy(hid->phys, batostr(&bt_sk(session->ctrl_sock->sk)->src), 64);
8641 strncpy(hid->uniq, batostr(&bt_sk(session->ctrl_sock->sk)->dst), 64);
8642
8643diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
8644index 1a17850..32893a0 100644
8645--- a/net/bluetooth/rfcomm/sock.c
8646+++ b/net/bluetooth/rfcomm/sock.c
8647@@ -467,7 +467,7 @@ static int rfcomm_sock_accept(struct socket *sock, struct socket *newsock, int f
8648 long timeo;
8649 int err = 0;
8650
8651- lock_sock(sk);
8652+ lock_sock_nested(sk, SINGLE_DEPTH_NESTING);
8653
8654 if (sk->sk_type != SOCK_STREAM) {
8655 err = -EINVAL;
8656@@ -504,7 +504,7 @@ static int rfcomm_sock_accept(struct socket *sock, struct socket *newsock, int f
8657
8658 release_sock(sk);
8659 timeo = schedule_timeout(timeo);
8660- lock_sock(sk);
8661+ lock_sock_nested(sk, SINGLE_DEPTH_NESTING);
8662 }
8663 __set_current_state(TASK_RUNNING);
8664 remove_wait_queue(sk_sleep(sk), &wait);
8665diff --git a/net/ceph/ceph_common.c b/net/ceph/ceph_common.c
8666index a802029..ee71ea2 100644
8667--- a/net/ceph/ceph_common.c
8668+++ b/net/ceph/ceph_common.c
8669@@ -305,7 +305,6 @@ ceph_parse_options(char *options, const char *dev_name,
8670
8671 /* start with defaults */
8672 opt->flags = CEPH_OPT_DEFAULT;
8673- opt->osd_timeout = CEPH_OSD_TIMEOUT_DEFAULT;
8674 opt->osd_keepalive_timeout = CEPH_OSD_KEEPALIVE_DEFAULT;
8675 opt->mount_timeout = CEPH_MOUNT_TIMEOUT_DEFAULT; /* seconds */
8676 opt->osd_idle_ttl = CEPH_OSD_IDLE_TTL_DEFAULT; /* seconds */
8677@@ -391,7 +390,7 @@ ceph_parse_options(char *options, const char *dev_name,
8678
8679 /* misc */
8680 case Opt_osdtimeout:
8681- opt->osd_timeout = intval;
8682+ pr_warning("ignoring deprecated osdtimeout option\n");
8683 break;
8684 case Opt_osdkeepalivetimeout:
8685 opt->osd_keepalive_timeout = intval;
8686diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
8687index 3ef1759..e9f2159 100644
8688--- a/net/ceph/messenger.c
8689+++ b/net/ceph/messenger.c
8690@@ -506,6 +506,7 @@ static void reset_connection(struct ceph_connection *con)
8691 {
8692 /* reset connection, out_queue, msg_ and connect_seq */
8693 /* discard existing out_queue and msg_seq */
8694+ dout("reset_connection %p\n", con);
8695 ceph_msg_remove_list(&con->out_queue);
8696 ceph_msg_remove_list(&con->out_sent);
8697
8698@@ -561,7 +562,7 @@ void ceph_con_open(struct ceph_connection *con,
8699 mutex_lock(&con->mutex);
8700 dout("con_open %p %s\n", con, ceph_pr_addr(&addr->in_addr));
8701
8702- BUG_ON(con->state != CON_STATE_CLOSED);
8703+ WARN_ON(con->state != CON_STATE_CLOSED);
8704 con->state = CON_STATE_PREOPEN;
8705
8706 con->peer_name.type = (__u8) entity_type;
8707@@ -1506,13 +1507,6 @@ static int process_banner(struct ceph_connection *con)
8708 return 0;
8709 }
8710
8711-static void fail_protocol(struct ceph_connection *con)
8712-{
8713- reset_connection(con);
8714- BUG_ON(con->state != CON_STATE_NEGOTIATING);
8715- con->state = CON_STATE_CLOSED;
8716-}
8717-
8718 static int process_connect(struct ceph_connection *con)
8719 {
8720 u64 sup_feat = con->msgr->supported_features;
8721@@ -1530,7 +1524,7 @@ static int process_connect(struct ceph_connection *con)
8722 ceph_pr_addr(&con->peer_addr.in_addr),
8723 sup_feat, server_feat, server_feat & ~sup_feat);
8724 con->error_msg = "missing required protocol features";
8725- fail_protocol(con);
8726+ reset_connection(con);
8727 return -1;
8728
8729 case CEPH_MSGR_TAG_BADPROTOVER:
8730@@ -1541,7 +1535,7 @@ static int process_connect(struct ceph_connection *con)
8731 le32_to_cpu(con->out_connect.protocol_version),
8732 le32_to_cpu(con->in_reply.protocol_version));
8733 con->error_msg = "protocol version mismatch";
8734- fail_protocol(con);
8735+ reset_connection(con);
8736 return -1;
8737
8738 case CEPH_MSGR_TAG_BADAUTHORIZER:
8739@@ -1631,11 +1625,11 @@ static int process_connect(struct ceph_connection *con)
8740 ceph_pr_addr(&con->peer_addr.in_addr),
8741 req_feat, server_feat, req_feat & ~server_feat);
8742 con->error_msg = "missing required protocol features";
8743- fail_protocol(con);
8744+ reset_connection(con);
8745 return -1;
8746 }
8747
8748- BUG_ON(con->state != CON_STATE_NEGOTIATING);
8749+ WARN_ON(con->state != CON_STATE_NEGOTIATING);
8750 con->state = CON_STATE_OPEN;
8751
8752 con->peer_global_seq = le32_to_cpu(con->in_reply.global_seq);
8753@@ -2132,7 +2126,6 @@ more:
8754 if (ret < 0)
8755 goto out;
8756
8757- BUG_ON(con->state != CON_STATE_CONNECTING);
8758 con->state = CON_STATE_NEGOTIATING;
8759
8760 /*
8761@@ -2160,7 +2153,7 @@ more:
8762 goto more;
8763 }
8764
8765- BUG_ON(con->state != CON_STATE_OPEN);
8766+ WARN_ON(con->state != CON_STATE_OPEN);
8767
8768 if (con->in_base_pos < 0) {
8769 /*
8770@@ -2262,6 +2255,35 @@ static void queue_con(struct ceph_connection *con)
8771 }
8772 }
8773
8774+static bool con_sock_closed(struct ceph_connection *con)
8775+{
8776+ if (!test_and_clear_bit(CON_FLAG_SOCK_CLOSED, &con->flags))
8777+ return false;
8778+
8779+#define CASE(x) \
8780+ case CON_STATE_ ## x: \
8781+ con->error_msg = "socket closed (con state " #x ")"; \
8782+ break;
8783+
8784+ switch (con->state) {
8785+ CASE(CLOSED);
8786+ CASE(PREOPEN);
8787+ CASE(CONNECTING);
8788+ CASE(NEGOTIATING);
8789+ CASE(OPEN);
8790+ CASE(STANDBY);
8791+ default:
8792+ pr_warning("%s con %p unrecognized state %lu\n",
8793+ __func__, con, con->state);
8794+ con->error_msg = "unrecognized con state";
8795+ BUG();
8796+ break;
8797+ }
8798+#undef CASE
8799+
8800+ return true;
8801+}
8802+
8803 /*
8804 * Do some work on a connection. Drop a connection ref when we're done.
8805 */
8806@@ -2273,24 +2295,8 @@ static void con_work(struct work_struct *work)
8807
8808 mutex_lock(&con->mutex);
8809 restart:
8810- if (test_and_clear_bit(CON_FLAG_SOCK_CLOSED, &con->flags)) {
8811- switch (con->state) {
8812- case CON_STATE_CONNECTING:
8813- con->error_msg = "connection failed";
8814- break;
8815- case CON_STATE_NEGOTIATING:
8816- con->error_msg = "negotiation failed";
8817- break;
8818- case CON_STATE_OPEN:
8819- con->error_msg = "socket closed";
8820- break;
8821- default:
8822- dout("unrecognized con state %d\n", (int)con->state);
8823- con->error_msg = "unrecognized con state";
8824- BUG();
8825- }
8826+ if (con_sock_closed(con))
8827 goto fault;
8828- }
8829
8830 if (test_and_clear_bit(CON_FLAG_BACKOFF, &con->flags)) {
8831 dout("con_work %p backing off\n", con);
8832@@ -2356,12 +2362,12 @@ fault:
8833 static void ceph_fault(struct ceph_connection *con)
8834 __releases(con->mutex)
8835 {
8836- pr_err("%s%lld %s %s\n", ENTITY_NAME(con->peer_name),
8837+ pr_warning("%s%lld %s %s\n", ENTITY_NAME(con->peer_name),
8838 ceph_pr_addr(&con->peer_addr.in_addr), con->error_msg);
8839 dout("fault %p state %lu to peer %s\n",
8840 con, con->state, ceph_pr_addr(&con->peer_addr.in_addr));
8841
8842- BUG_ON(con->state != CON_STATE_CONNECTING &&
8843+ WARN_ON(con->state != CON_STATE_CONNECTING &&
8844 con->state != CON_STATE_NEGOTIATING &&
8845 con->state != CON_STATE_OPEN);
8846
8847diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
8848index f7b56e2..eb9a444 100644
8849--- a/net/ceph/osd_client.c
8850+++ b/net/ceph/osd_client.c
8851@@ -221,7 +221,7 @@ struct ceph_osd_request *ceph_osdc_alloc_request(struct ceph_osd_client *osdc,
8852 kref_init(&req->r_kref);
8853 init_completion(&req->r_completion);
8854 init_completion(&req->r_safe_completion);
8855- rb_init_node(&req->r_node);
8856+ RB_CLEAR_NODE(&req->r_node);
8857 INIT_LIST_HEAD(&req->r_unsafe_item);
8858 INIT_LIST_HEAD(&req->r_linger_item);
8859 INIT_LIST_HEAD(&req->r_linger_osd);
8860@@ -464,6 +464,7 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc,
8861 {
8862 struct ceph_osd_req_op ops[3];
8863 struct ceph_osd_request *req;
8864+ int r;
8865
8866 ops[0].op = opcode;
8867 ops[0].extent.truncate_seq = truncate_seq;
8868@@ -482,10 +483,12 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc,
8869 use_mempool,
8870 GFP_NOFS, NULL, NULL);
8871 if (!req)
8872- return NULL;
8873+ return ERR_PTR(-ENOMEM);
8874
8875 /* calculate max write size */
8876- calc_layout(osdc, vino, layout, off, plen, req, ops);
8877+ r = calc_layout(osdc, vino, layout, off, plen, req, ops);
8878+ if (r < 0)
8879+ return ERR_PTR(r);
8880 req->r_file_layout = *layout; /* keep a copy */
8881
8882 /* in case it differs from natural (file) alignment that
8883@@ -578,7 +581,7 @@ static void __kick_osd_requests(struct ceph_osd_client *osdc,
8884
8885 dout("__kick_osd_requests osd%d\n", osd->o_osd);
8886 err = __reset_osd(osdc, osd);
8887- if (err == -EAGAIN)
8888+ if (err)
8889 return;
8890
8891 list_for_each_entry(req, &osd->o_requests, r_osd_item) {
8892@@ -605,14 +608,6 @@ static void __kick_osd_requests(struct ceph_osd_client *osdc,
8893 }
8894 }
8895
8896-static void kick_osd_requests(struct ceph_osd_client *osdc,
8897- struct ceph_osd *kickosd)
8898-{
8899- mutex_lock(&osdc->request_mutex);
8900- __kick_osd_requests(osdc, kickosd);
8901- mutex_unlock(&osdc->request_mutex);
8902-}
8903-
8904 /*
8905 * If the osd connection drops, we need to resubmit all requests.
8906 */
8907@@ -626,7 +621,9 @@ static void osd_reset(struct ceph_connection *con)
8908 dout("osd_reset osd%d\n", osd->o_osd);
8909 osdc = osd->o_osdc;
8910 down_read(&osdc->map_sem);
8911- kick_osd_requests(osdc, osd);
8912+ mutex_lock(&osdc->request_mutex);
8913+ __kick_osd_requests(osdc, osd);
8914+ mutex_unlock(&osdc->request_mutex);
8915 send_queued(osdc);
8916 up_read(&osdc->map_sem);
8917 }
8918@@ -645,6 +642,7 @@ static struct ceph_osd *create_osd(struct ceph_osd_client *osdc, int onum)
8919 atomic_set(&osd->o_ref, 1);
8920 osd->o_osdc = osdc;
8921 osd->o_osd = onum;
8922+ RB_CLEAR_NODE(&osd->o_node);
8923 INIT_LIST_HEAD(&osd->o_requests);
8924 INIT_LIST_HEAD(&osd->o_linger_requests);
8925 INIT_LIST_HEAD(&osd->o_osd_lru);
8926@@ -748,6 +746,7 @@ static int __reset_osd(struct ceph_osd_client *osdc, struct ceph_osd *osd)
8927 if (list_empty(&osd->o_requests) &&
8928 list_empty(&osd->o_linger_requests)) {
8929 __remove_osd(osdc, osd);
8930+ ret = -ENODEV;
8931 } else if (memcmp(&osdc->osdmap->osd_addr[osd->o_osd],
8932 &osd->o_con.peer_addr,
8933 sizeof(osd->o_con.peer_addr)) == 0 &&
8934@@ -874,9 +873,9 @@ static void __unregister_request(struct ceph_osd_client *osdc,
8935 req->r_osd = NULL;
8936 }
8937
8938+ list_del_init(&req->r_req_lru_item);
8939 ceph_osdc_put_request(req);
8940
8941- list_del_init(&req->r_req_lru_item);
8942 if (osdc->num_requests == 0) {
8943 dout(" no requests, canceling timeout\n");
8944 __cancel_osd_timeout(osdc);
8945@@ -908,8 +907,8 @@ static void __unregister_linger_request(struct ceph_osd_client *osdc,
8946 struct ceph_osd_request *req)
8947 {
8948 dout("__unregister_linger_request %p\n", req);
8949+ list_del_init(&req->r_linger_item);
8950 if (req->r_osd) {
8951- list_del_init(&req->r_linger_item);
8952 list_del_init(&req->r_linger_osd);
8953
8954 if (list_empty(&req->r_osd->o_requests) &&
8955@@ -1088,12 +1087,10 @@ static void handle_timeout(struct work_struct *work)
8956 {
8957 struct ceph_osd_client *osdc =
8958 container_of(work, struct ceph_osd_client, timeout_work.work);
8959- struct ceph_osd_request *req, *last_req = NULL;
8960+ struct ceph_osd_request *req;
8961 struct ceph_osd *osd;
8962- unsigned long timeout = osdc->client->options->osd_timeout * HZ;
8963 unsigned long keepalive =
8964 osdc->client->options->osd_keepalive_timeout * HZ;
8965- unsigned long last_stamp = 0;
8966 struct list_head slow_osds;
8967 dout("timeout\n");
8968 down_read(&osdc->map_sem);
8969@@ -1103,37 +1100,6 @@ static void handle_timeout(struct work_struct *work)
8970 mutex_lock(&osdc->request_mutex);
8971
8972 /*
8973- * reset osds that appear to be _really_ unresponsive. this
8974- * is a failsafe measure.. we really shouldn't be getting to
8975- * this point if the system is working properly. the monitors
8976- * should mark the osd as failed and we should find out about
8977- * it from an updated osd map.
8978- */
8979- while (timeout && !list_empty(&osdc->req_lru)) {
8980- req = list_entry(osdc->req_lru.next, struct ceph_osd_request,
8981- r_req_lru_item);
8982-
8983- /* hasn't been long enough since we sent it? */
8984- if (time_before(jiffies, req->r_stamp + timeout))
8985- break;
8986-
8987- /* hasn't been long enough since it was acked? */
8988- if (req->r_request->ack_stamp == 0 ||
8989- time_before(jiffies, req->r_request->ack_stamp + timeout))
8990- break;
8991-
8992- BUG_ON(req == last_req && req->r_stamp == last_stamp);
8993- last_req = req;
8994- last_stamp = req->r_stamp;
8995-
8996- osd = req->r_osd;
8997- BUG_ON(!osd);
8998- pr_warning(" tid %llu timed out on osd%d, will reset osd\n",
8999- req->r_tid, osd->o_osd);
9000- __kick_osd_requests(osdc, osd);
9001- }
9002-
9003- /*
9004 * ping osds that are a bit slow. this ensures that if there
9005 * is a break in the TCP connection we will notice, and reopen
9006 * a connection with that osd (from the fault callback).
9007@@ -1304,7 +1270,7 @@ static void reset_changed_osds(struct ceph_osd_client *osdc)
9008 * Requeue requests whose mapping to an OSD has changed. If requests map to
9009 * no osd, request a new map.
9010 *
9011- * Caller should hold map_sem for read and request_mutex.
9012+ * Caller should hold map_sem for read.
9013 */
9014 static void kick_requests(struct ceph_osd_client *osdc, int force_resend)
9015 {
9016@@ -1318,6 +1284,24 @@ static void kick_requests(struct ceph_osd_client *osdc, int force_resend)
9017 for (p = rb_first(&osdc->requests); p; ) {
9018 req = rb_entry(p, struct ceph_osd_request, r_node);
9019 p = rb_next(p);
9020+
9021+ /*
9022+ * For linger requests that have not yet been
9023+ * registered, move them to the linger list; they'll
9024+ * be sent to the osd in the loop below. Unregister
9025+ * the request before re-registering it as a linger
9026+ * request to ensure the __map_request() below
9027+ * will decide it needs to be sent.
9028+ */
9029+ if (req->r_linger && list_empty(&req->r_linger_item)) {
9030+ dout("%p tid %llu restart on osd%d\n",
9031+ req, req->r_tid,
9032+ req->r_osd ? req->r_osd->o_osd : -1);
9033+ __unregister_request(osdc, req);
9034+ __register_linger_request(osdc, req);
9035+ continue;
9036+ }
9037+
9038 err = __map_request(osdc, req, force_resend);
9039 if (err < 0)
9040 continue; /* error */
9041@@ -1332,17 +1316,6 @@ static void kick_requests(struct ceph_osd_client *osdc, int force_resend)
9042 req->r_flags |= CEPH_OSD_FLAG_RETRY;
9043 }
9044 }
9045- if (req->r_linger && list_empty(&req->r_linger_item)) {
9046- /*
9047- * register as a linger so that we will
9048- * re-submit below and get a new tid
9049- */
9050- dout("%p tid %llu restart on osd%d\n",
9051- req, req->r_tid,
9052- req->r_osd ? req->r_osd->o_osd : -1);
9053- __register_linger_request(osdc, req);
9054- __unregister_request(osdc, req);
9055- }
9056 }
9057
9058 list_for_each_entry_safe(req, nreq, &osdc->req_linger,
9059@@ -1350,6 +1323,7 @@ static void kick_requests(struct ceph_osd_client *osdc, int force_resend)
9060 dout("linger req=%p req->r_osd=%p\n", req, req->r_osd);
9061
9062 err = __map_request(osdc, req, force_resend);
9063+ dout("__map_request returned %d\n", err);
9064 if (err == 0)
9065 continue; /* no change and no osd was specified */
9066 if (err < 0)
9067@@ -1362,8 +1336,8 @@ static void kick_requests(struct ceph_osd_client *osdc, int force_resend)
9068
9069 dout("kicking lingering %p tid %llu osd%d\n", req, req->r_tid,
9070 req->r_osd ? req->r_osd->o_osd : -1);
9071- __unregister_linger_request(osdc, req);
9072 __register_request(osdc, req);
9073+ __unregister_linger_request(osdc, req);
9074 }
9075 mutex_unlock(&osdc->request_mutex);
9076
9077@@ -1371,6 +1345,7 @@ static void kick_requests(struct ceph_osd_client *osdc, int force_resend)
9078 dout("%d requests for down osds, need new map\n", needmap);
9079 ceph_monc_request_next_osdmap(&osdc->client->monc);
9080 }
9081+ reset_changed_osds(osdc);
9082 }
9083
9084
9085@@ -1427,7 +1402,6 @@ void ceph_osdc_handle_map(struct ceph_osd_client *osdc, struct ceph_msg *msg)
9086 osdc->osdmap = newmap;
9087 }
9088 kick_requests(osdc, 0);
9089- reset_changed_osds(osdc);
9090 } else {
9091 dout("ignoring incremental map %u len %d\n",
9092 epoch, maplen);
9093@@ -1597,6 +1571,7 @@ int ceph_osdc_create_event(struct ceph_osd_client *osdc,
9094 event->data = data;
9095 event->osdc = osdc;
9096 INIT_LIST_HEAD(&event->osd_node);
9097+ RB_CLEAR_NODE(&event->node);
9098 kref_init(&event->kref); /* one ref for us */
9099 kref_get(&event->kref); /* one ref for the caller */
9100 init_completion(&event->completion);
9101@@ -1928,8 +1903,8 @@ int ceph_osdc_readpages(struct ceph_osd_client *osdc,
9102 CEPH_OSD_OP_READ, CEPH_OSD_FLAG_READ,
9103 NULL, 0, truncate_seq, truncate_size, NULL,
9104 false, 1, page_align);
9105- if (!req)
9106- return -ENOMEM;
9107+ if (IS_ERR(req))
9108+ return PTR_ERR(req);
9109
9110 /* it may be a short read due to an object boundary */
9111 req->r_pages = pages;
9112@@ -1971,8 +1946,8 @@ int ceph_osdc_writepages(struct ceph_osd_client *osdc, struct ceph_vino vino,
9113 snapc, do_sync,
9114 truncate_seq, truncate_size, mtime,
9115 nofail, 1, page_align);
9116- if (!req)
9117- return -ENOMEM;
9118+ if (IS_ERR(req))
9119+ return PTR_ERR(req);
9120
9121 /* it may be a short write due to an object boundary */
9122 req->r_pages = pages;
9123diff --git a/net/ceph/osdmap.c b/net/ceph/osdmap.c
9124index 5433fb0..f552aa4 100644
9125--- a/net/ceph/osdmap.c
9126+++ b/net/ceph/osdmap.c
9127@@ -645,10 +645,12 @@ struct ceph_osdmap *osdmap_decode(void **p, void *end)
9128 ceph_decode_32_safe(p, end, max, bad);
9129 while (max--) {
9130 ceph_decode_need(p, end, 4 + 1 + sizeof(pi->v), bad);
9131+ err = -ENOMEM;
9132 pi = kzalloc(sizeof(*pi), GFP_NOFS);
9133 if (!pi)
9134 goto bad;
9135 pi->id = ceph_decode_32(p);
9136+ err = -EINVAL;
9137 ev = ceph_decode_8(p); /* encoding version */
9138 if (ev > CEPH_PG_POOL_VERSION) {
9139 pr_warning("got unknown v %d > %d of ceph_pg_pool\n",
9140@@ -664,8 +666,13 @@ struct ceph_osdmap *osdmap_decode(void **p, void *end)
9141 __insert_pg_pool(&map->pg_pools, pi);
9142 }
9143
9144- if (version >= 5 && __decode_pool_names(p, end, map) < 0)
9145- goto bad;
9146+ if (version >= 5) {
9147+ err = __decode_pool_names(p, end, map);
9148+ if (err < 0) {
9149+ dout("fail to decode pool names");
9150+ goto bad;
9151+ }
9152+ }
9153
9154 ceph_decode_32_safe(p, end, map->pool_max, bad);
9155
9156@@ -745,7 +752,7 @@ struct ceph_osdmap *osdmap_decode(void **p, void *end)
9157 return map;
9158
9159 bad:
9160- dout("osdmap_decode fail\n");
9161+ dout("osdmap_decode fail err %d\n", err);
9162 ceph_osdmap_destroy(map);
9163 return ERR_PTR(err);
9164 }
9165@@ -839,6 +846,7 @@ struct ceph_osdmap *osdmap_apply_incremental(void **p, void *end,
9166 if (ev > CEPH_PG_POOL_VERSION) {
9167 pr_warning("got unknown v %d > %d of ceph_pg_pool\n",
9168 ev, CEPH_PG_POOL_VERSION);
9169+ err = -EINVAL;
9170 goto bad;
9171 }
9172 pi = __lookup_pg_pool(&map->pg_pools, pool);
9173@@ -855,8 +863,11 @@ struct ceph_osdmap *osdmap_apply_incremental(void **p, void *end,
9174 if (err < 0)
9175 goto bad;
9176 }
9177- if (version >= 5 && __decode_pool_names(p, end, map) < 0)
9178- goto bad;
9179+ if (version >= 5) {
9180+ err = __decode_pool_names(p, end, map);
9181+ if (err < 0)
9182+ goto bad;
9183+ }
9184
9185 /* old_pool */
9186 ceph_decode_32_safe(p, end, len, bad);
9187@@ -932,15 +943,13 @@ struct ceph_osdmap *osdmap_apply_incremental(void **p, void *end,
9188 (void) __remove_pg_mapping(&map->pg_temp, pgid);
9189
9190 /* insert */
9191- if (pglen > (UINT_MAX - sizeof(*pg)) / sizeof(u32)) {
9192- err = -EINVAL;
9193+ err = -EINVAL;
9194+ if (pglen > (UINT_MAX - sizeof(*pg)) / sizeof(u32))
9195 goto bad;
9196- }
9197+ err = -ENOMEM;
9198 pg = kmalloc(sizeof(*pg) + sizeof(u32)*pglen, GFP_NOFS);
9199- if (!pg) {
9200- err = -ENOMEM;
9201+ if (!pg)
9202 goto bad;
9203- }
9204 pg->pgid = pgid;
9205 pg->len = pglen;
9206 for (j = 0; j < pglen; j++)
9207diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c
9208index 176ecdb..4f9f5eb 100644
9209--- a/net/dccp/ipv4.c
9210+++ b/net/dccp/ipv4.c
9211@@ -439,8 +439,8 @@ exit:
9212 NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_LISTENDROPS);
9213 return NULL;
9214 put_and_exit:
9215- bh_unlock_sock(newsk);
9216- sock_put(newsk);
9217+ inet_csk_prepare_forced_close(newsk);
9218+ dccp_done(newsk);
9219 goto exit;
9220 }
9221
9222diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c
9223index 56840b2..6e05981 100644
9224--- a/net/dccp/ipv6.c
9225+++ b/net/dccp/ipv6.c
9226@@ -585,7 +585,8 @@ static struct sock *dccp_v6_request_recv_sock(struct sock *sk,
9227 newinet->inet_rcv_saddr = LOOPBACK4_IPV6;
9228
9229 if (__inet_inherit_port(sk, newsk) < 0) {
9230- sock_put(newsk);
9231+ inet_csk_prepare_forced_close(newsk);
9232+ dccp_done(newsk);
9233 goto out;
9234 }
9235 __inet6_hash(newsk, NULL);
9236diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
9237index 0405cc8..567c31f 100644
9238--- a/net/ipv4/inet_connection_sock.c
9239+++ b/net/ipv4/inet_connection_sock.c
9240@@ -679,6 +679,22 @@ void inet_csk_destroy_sock(struct sock *sk)
9241 }
9242 EXPORT_SYMBOL(inet_csk_destroy_sock);
9243
9244+/* This function allows to force a closure of a socket after the call to
9245+ * tcp/dccp_create_openreq_child().
9246+ */
9247+void inet_csk_prepare_forced_close(struct sock *sk)
9248+{
9249+ /* sk_clone_lock locked the socket and set refcnt to 2 */
9250+ bh_unlock_sock(sk);
9251+ sock_put(sk);
9252+
9253+ /* The below has to be done to allow calling inet_csk_destroy_sock */
9254+ sock_set_flag(sk, SOCK_DEAD);
9255+ percpu_counter_inc(sk->sk_prot->orphan_count);
9256+ inet_sk(sk)->inet_num = 0;
9257+}
9258+EXPORT_SYMBOL(inet_csk_prepare_forced_close);
9259+
9260 int inet_csk_listen_start(struct sock *sk, const int nr_table_entries)
9261 {
9262 struct inet_sock *inet = inet_sk(sk);
9263diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
9264index c92c4da..4b3f448 100644
9265--- a/net/ipv4/tcp_input.c
9266+++ b/net/ipv4/tcp_input.c
9267@@ -3579,6 +3579,24 @@ static bool tcp_process_frto(struct sock *sk, int flag)
9268 return false;
9269 }
9270
9271+/* RFC 5961 7 [ACK Throttling] */
9272+static void tcp_send_challenge_ack(struct sock *sk)
9273+{
9274+ /* unprotected vars, we dont care of overwrites */
9275+ static u32 challenge_timestamp;
9276+ static unsigned int challenge_count;
9277+ u32 now = jiffies / HZ;
9278+
9279+ if (now != challenge_timestamp) {
9280+ challenge_timestamp = now;
9281+ challenge_count = 0;
9282+ }
9283+ if (++challenge_count <= sysctl_tcp_challenge_ack_limit) {
9284+ NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPCHALLENGEACK);
9285+ tcp_send_ack(sk);
9286+ }
9287+}
9288+
9289 /* This routine deals with incoming acks, but not outgoing ones. */
9290 static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag)
9291 {
9292@@ -3598,8 +3616,14 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag)
9293 /* If the ack is older than previous acks
9294 * then we can probably ignore it.
9295 */
9296- if (before(ack, prior_snd_una))
9297+ if (before(ack, prior_snd_una)) {
9298+ /* RFC 5961 5.2 [Blind Data Injection Attack].[Mitigation] */
9299+ if (before(ack, prior_snd_una - tp->max_window)) {
9300+ tcp_send_challenge_ack(sk);
9301+ return -1;
9302+ }
9303 goto old_ack;
9304+ }
9305
9306 /* If the ack includes data we haven't sent yet, discard
9307 * this segment (RFC793 Section 3.9).
9308@@ -5271,23 +5295,6 @@ out:
9309 }
9310 #endif /* CONFIG_NET_DMA */
9311
9312-static void tcp_send_challenge_ack(struct sock *sk)
9313-{
9314- /* unprotected vars, we dont care of overwrites */
9315- static u32 challenge_timestamp;
9316- static unsigned int challenge_count;
9317- u32 now = jiffies / HZ;
9318-
9319- if (now != challenge_timestamp) {
9320- challenge_timestamp = now;
9321- challenge_count = 0;
9322- }
9323- if (++challenge_count <= sysctl_tcp_challenge_ack_limit) {
9324- NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPCHALLENGEACK);
9325- tcp_send_ack(sk);
9326- }
9327-}
9328-
9329 /* Does PAWS and seqno based validation of an incoming segment, flags will
9330 * play significant role here.
9331 */
9332@@ -5340,11 +5347,6 @@ static bool tcp_validate_incoming(struct sock *sk, struct sk_buff *skb,
9333 goto discard;
9334 }
9335
9336- /* ts_recent update must be made after we are sure that the packet
9337- * is in window.
9338- */
9339- tcp_replace_ts_recent(tp, TCP_SKB_CB(skb)->seq);
9340-
9341 /* step 3: check security and precedence [ignored] */
9342
9343 /* step 4: Check for a SYN
9344@@ -5579,6 +5581,11 @@ step5:
9345 if (th->ack && tcp_ack(sk, skb, FLAG_SLOWPATH) < 0)
9346 goto discard;
9347
9348+ /* ts_recent update must be made after we are sure that the packet
9349+ * is in window.
9350+ */
9351+ tcp_replace_ts_recent(tp, TCP_SKB_CB(skb)->seq);
9352+
9353 tcp_rcv_rtt_measure_ts(sk, skb);
9354
9355 /* Process urgent data. */
9356@@ -6106,6 +6113,11 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
9357 } else
9358 goto discard;
9359
9360+ /* ts_recent update must be made after we are sure that the packet
9361+ * is in window.
9362+ */
9363+ tcp_replace_ts_recent(tp, TCP_SKB_CB(skb)->seq);
9364+
9365 /* step 6: check the URG bit */
9366 tcp_urg(sk, skb, th);
9367
9368diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
9369index db7bfad..4705caf 100644
9370--- a/net/ipv4/tcp_ipv4.c
9371+++ b/net/ipv4/tcp_ipv4.c
9372@@ -1537,10 +1537,8 @@ exit:
9373 NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_LISTENDROPS);
9374 return NULL;
9375 put_and_exit:
9376- tcp_clear_xmit_timers(newsk);
9377- tcp_cleanup_congestion_control(newsk);
9378- bh_unlock_sock(newsk);
9379- sock_put(newsk);
9380+ inet_csk_prepare_forced_close(newsk);
9381+ tcp_done(newsk);
9382 goto exit;
9383 }
9384 EXPORT_SYMBOL(tcp_v4_syn_recv_sock);
9385diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
9386index 7e32d42..8b45fb4 100644
9387--- a/net/ipv6/tcp_ipv6.c
9388+++ b/net/ipv6/tcp_ipv6.c
9389@@ -1371,7 +1371,8 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
9390 #endif
9391
9392 if (__inet_inherit_port(sk, newsk) < 0) {
9393- sock_put(newsk);
9394+ inet_csk_prepare_forced_close(newsk);
9395+ tcp_done(newsk);
9396 goto out;
9397 }
9398 __inet6_hash(newsk, NULL);
9399diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
9400index a58c0b6..f985911 100644
9401--- a/net/mac80211/cfg.c
9402+++ b/net/mac80211/cfg.c
9403@@ -151,7 +151,17 @@ static int ieee80211_add_key(struct wiphy *wiphy, struct net_device *dev,
9404 sta = sta_info_get(sdata, mac_addr);
9405 else
9406 sta = sta_info_get_bss(sdata, mac_addr);
9407- if (!sta) {
9408+ /*
9409+ * The ASSOC test makes sure the driver is ready to
9410+ * receive the key. When wpa_supplicant has roamed
9411+ * using FT, it attempts to set the key before
9412+ * association has completed, this rejects that attempt
9413+ * so it will set the key again after assocation.
9414+ *
9415+ * TODO: accept the key if we have a station entry and
9416+ * add it to the device after the station.
9417+ */
9418+ if (!sta || !test_sta_flag(sta, WLAN_STA_ASSOC)) {
9419 ieee80211_key_free(sdata->local, key);
9420 err = -ENOENT;
9421 goto out_unlock;
9422diff --git a/net/mac80211/ibss.c b/net/mac80211/ibss.c
9423index a5894dd..c55eacc 100644
9424--- a/net/mac80211/ibss.c
9425+++ b/net/mac80211/ibss.c
9426@@ -647,8 +647,8 @@ static void ieee80211_sta_merge_ibss(struct ieee80211_sub_if_data *sdata)
9427 sdata_info(sdata,
9428 "No active IBSS STAs - trying to scan for other IBSS networks with same SSID (merge)\n");
9429
9430- ieee80211_request_internal_scan(sdata,
9431- ifibss->ssid, ifibss->ssid_len, NULL);
9432+ ieee80211_request_ibss_scan(sdata, ifibss->ssid, ifibss->ssid_len,
9433+ NULL);
9434 }
9435
9436 static void ieee80211_sta_create_ibss(struct ieee80211_sub_if_data *sdata)
9437@@ -746,9 +746,8 @@ static void ieee80211_sta_find_ibss(struct ieee80211_sub_if_data *sdata)
9438 IEEE80211_SCAN_INTERVAL)) {
9439 sdata_info(sdata, "Trigger new scan to find an IBSS to join\n");
9440
9441- ieee80211_request_internal_scan(sdata,
9442- ifibss->ssid, ifibss->ssid_len,
9443- ifibss->fixed_channel ? ifibss->channel : NULL);
9444+ ieee80211_request_ibss_scan(sdata, ifibss->ssid,
9445+ ifibss->ssid_len, chan);
9446 } else {
9447 int interval = IEEE80211_SCAN_INTERVAL;
9448
9449diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
9450index 642a2a3..fcab057 100644
9451--- a/net/mac80211/ieee80211_i.h
9452+++ b/net/mac80211/ieee80211_i.h
9453@@ -1239,9 +1239,9 @@ void ieee80211_mesh_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
9454
9455 /* scan/BSS handling */
9456 void ieee80211_scan_work(struct work_struct *work);
9457-int ieee80211_request_internal_scan(struct ieee80211_sub_if_data *sdata,
9458- const u8 *ssid, u8 ssid_len,
9459- struct ieee80211_channel *chan);
9460+int ieee80211_request_ibss_scan(struct ieee80211_sub_if_data *sdata,
9461+ const u8 *ssid, u8 ssid_len,
9462+ struct ieee80211_channel *chan);
9463 int ieee80211_request_scan(struct ieee80211_sub_if_data *sdata,
9464 struct cfg80211_scan_request *req);
9465 void ieee80211_scan_cancel(struct ieee80211_local *local);
9466@@ -1267,10 +1267,8 @@ int ieee80211_request_sched_scan_stop(struct ieee80211_sub_if_data *sdata);
9467 void ieee80211_sched_scan_stopped_work(struct work_struct *work);
9468
9469 /* off-channel helpers */
9470-void ieee80211_offchannel_stop_vifs(struct ieee80211_local *local,
9471- bool offchannel_ps_enable);
9472-void ieee80211_offchannel_return(struct ieee80211_local *local,
9473- bool offchannel_ps_disable);
9474+void ieee80211_offchannel_stop_vifs(struct ieee80211_local *local);
9475+void ieee80211_offchannel_return(struct ieee80211_local *local);
9476 void ieee80211_roc_setup(struct ieee80211_local *local);
9477 void ieee80211_start_next_roc(struct ieee80211_local *local);
9478 void ieee80211_roc_purge(struct ieee80211_sub_if_data *sdata);
9479diff --git a/net/mac80211/offchannel.c b/net/mac80211/offchannel.c
9480index 2138dc3..37e3028 100644
9481--- a/net/mac80211/offchannel.c
9482+++ b/net/mac80211/offchannel.c
9483@@ -102,8 +102,7 @@ static void ieee80211_offchannel_ps_disable(struct ieee80211_sub_if_data *sdata)
9484 ieee80211_sta_reset_conn_monitor(sdata);
9485 }
9486
9487-void ieee80211_offchannel_stop_vifs(struct ieee80211_local *local,
9488- bool offchannel_ps_enable)
9489+void ieee80211_offchannel_stop_vifs(struct ieee80211_local *local)
9490 {
9491 struct ieee80211_sub_if_data *sdata;
9492
9493@@ -128,8 +127,7 @@ void ieee80211_offchannel_stop_vifs(struct ieee80211_local *local,
9494
9495 if (sdata->vif.type != NL80211_IFTYPE_MONITOR) {
9496 netif_tx_stop_all_queues(sdata->dev);
9497- if (offchannel_ps_enable &&
9498- (sdata->vif.type == NL80211_IFTYPE_STATION) &&
9499+ if (sdata->vif.type == NL80211_IFTYPE_STATION &&
9500 sdata->u.mgd.associated)
9501 ieee80211_offchannel_ps_enable(sdata);
9502 }
9503@@ -137,8 +135,7 @@ void ieee80211_offchannel_stop_vifs(struct ieee80211_local *local,
9504 mutex_unlock(&local->iflist_mtx);
9505 }
9506
9507-void ieee80211_offchannel_return(struct ieee80211_local *local,
9508- bool offchannel_ps_disable)
9509+void ieee80211_offchannel_return(struct ieee80211_local *local)
9510 {
9511 struct ieee80211_sub_if_data *sdata;
9512
9513@@ -151,11 +148,9 @@ void ieee80211_offchannel_return(struct ieee80211_local *local,
9514 continue;
9515
9516 /* Tell AP we're back */
9517- if (offchannel_ps_disable &&
9518- sdata->vif.type == NL80211_IFTYPE_STATION) {
9519- if (sdata->u.mgd.associated)
9520- ieee80211_offchannel_ps_disable(sdata);
9521- }
9522+ if (sdata->vif.type == NL80211_IFTYPE_STATION &&
9523+ sdata->u.mgd.associated)
9524+ ieee80211_offchannel_ps_disable(sdata);
9525
9526 if (sdata->vif.type != NL80211_IFTYPE_MONITOR) {
9527 /*
9528@@ -376,7 +371,7 @@ void ieee80211_sw_roc_work(struct work_struct *work)
9529 local->tmp_channel = NULL;
9530 ieee80211_hw_config(local, 0);
9531
9532- ieee80211_offchannel_return(local, true);
9533+ ieee80211_offchannel_return(local);
9534 }
9535
9536 ieee80211_recalc_idle(local);
9537diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c
9538index 839dd97..8719635 100644
9539--- a/net/mac80211/scan.c
9540+++ b/net/mac80211/scan.c
9541@@ -310,7 +310,7 @@ static void __ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted,
9542 if (!was_hw_scan) {
9543 ieee80211_configure_filter(local);
9544 drv_sw_scan_complete(local);
9545- ieee80211_offchannel_return(local, true);
9546+ ieee80211_offchannel_return(local);
9547 }
9548
9549 ieee80211_recalc_idle(local);
9550@@ -355,7 +355,7 @@ static int ieee80211_start_sw_scan(struct ieee80211_local *local)
9551 local->next_scan_state = SCAN_DECISION;
9552 local->scan_channel_idx = 0;
9553
9554- ieee80211_offchannel_stop_vifs(local, true);
9555+ ieee80211_offchannel_stop_vifs(local);
9556
9557 ieee80211_configure_filter(local);
9558
9559@@ -680,12 +680,8 @@ static void ieee80211_scan_state_suspend(struct ieee80211_local *local,
9560 local->scan_channel = NULL;
9561 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL);
9562
9563- /*
9564- * Re-enable vifs and beaconing. Leave PS
9565- * in off-channel state..will put that back
9566- * on-channel at the end of scanning.
9567- */
9568- ieee80211_offchannel_return(local, false);
9569+ /* disable PS */
9570+ ieee80211_offchannel_return(local);
9571
9572 *next_delay = HZ / 5;
9573 /* afterwards, resume scan & go to next channel */
9574@@ -695,8 +691,7 @@ static void ieee80211_scan_state_suspend(struct ieee80211_local *local,
9575 static void ieee80211_scan_state_resume(struct ieee80211_local *local,
9576 unsigned long *next_delay)
9577 {
9578- /* PS already is in off-channel mode */
9579- ieee80211_offchannel_stop_vifs(local, false);
9580+ ieee80211_offchannel_stop_vifs(local);
9581
9582 if (local->ops->flush) {
9583 drv_flush(local, false);
9584@@ -819,9 +814,9 @@ int ieee80211_request_scan(struct ieee80211_sub_if_data *sdata,
9585 return res;
9586 }
9587
9588-int ieee80211_request_internal_scan(struct ieee80211_sub_if_data *sdata,
9589- const u8 *ssid, u8 ssid_len,
9590- struct ieee80211_channel *chan)
9591+int ieee80211_request_ibss_scan(struct ieee80211_sub_if_data *sdata,
9592+ const u8 *ssid, u8 ssid_len,
9593+ struct ieee80211_channel *chan)
9594 {
9595 struct ieee80211_local *local = sdata->local;
9596 int ret = -EBUSY;
9597@@ -835,22 +830,36 @@ int ieee80211_request_internal_scan(struct ieee80211_sub_if_data *sdata,
9598
9599 /* fill internal scan request */
9600 if (!chan) {
9601- int i, nchan = 0;
9602+ int i, max_n;
9603+ int n_ch = 0;
9604
9605 for (band = 0; band < IEEE80211_NUM_BANDS; band++) {
9606 if (!local->hw.wiphy->bands[band])
9607 continue;
9608- for (i = 0;
9609- i < local->hw.wiphy->bands[band]->n_channels;
9610- i++) {
9611- local->int_scan_req->channels[nchan] =
9612+
9613+ max_n = local->hw.wiphy->bands[band]->n_channels;
9614+ for (i = 0; i < max_n; i++) {
9615+ struct ieee80211_channel *tmp_ch =
9616 &local->hw.wiphy->bands[band]->channels[i];
9617- nchan++;
9618+
9619+ if (tmp_ch->flags & (IEEE80211_CHAN_NO_IBSS |
9620+ IEEE80211_CHAN_DISABLED))
9621+ continue;
9622+
9623+ local->int_scan_req->channels[n_ch] = tmp_ch;
9624+ n_ch++;
9625 }
9626 }
9627
9628- local->int_scan_req->n_channels = nchan;
9629+ if (WARN_ON_ONCE(n_ch == 0))
9630+ goto unlock;
9631+
9632+ local->int_scan_req->n_channels = n_ch;
9633 } else {
9634+ if (WARN_ON_ONCE(chan->flags & (IEEE80211_CHAN_NO_IBSS |
9635+ IEEE80211_CHAN_DISABLED)))
9636+ goto unlock;
9637+
9638 local->int_scan_req->channels[0] = chan;
9639 local->int_scan_req->n_channels = 1;
9640 }
9641diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c
9642index 31aa8b8..cd7ca8d 100644
9643--- a/net/mac80211/sta_info.c
9644+++ b/net/mac80211/sta_info.c
9645@@ -835,7 +835,7 @@ void sta_info_init(struct ieee80211_local *local)
9646
9647 void sta_info_stop(struct ieee80211_local *local)
9648 {
9649- del_timer(&local->sta_cleanup);
9650+ del_timer_sync(&local->sta_cleanup);
9651 sta_info_flush(local, NULL);
9652 }
9653
9654diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c
9655index 9d75b77..e9ea2f3 100644
9656--- a/net/sched/sch_htb.c
9657+++ b/net/sched/sch_htb.c
9658@@ -874,7 +874,7 @@ ok:
9659 q->now = psched_get_time();
9660 start_at = jiffies;
9661
9662- next_event = q->now + 5 * PSCHED_TICKS_PER_SEC;
9663+ next_event = q->now + 5LLU * PSCHED_TICKS_PER_SEC;
9664
9665 for (level = 0; level < TC_HTB_MAXDEPTH; level++) {
9666 /* common case optimization - skip event handler quickly */
9667diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
9668index fa48c60..346c387 100644
9669--- a/net/sunrpc/clnt.c
9670+++ b/net/sunrpc/clnt.c
9671@@ -234,7 +234,7 @@ static struct rpc_clnt *rpc_get_client_for_event(struct net *net, int event)
9672 spin_lock(&sn->rpc_client_lock);
9673 list_for_each_entry(clnt, &sn->all_clients, cl_clients) {
9674 if (clnt->cl_program->pipe_dir_name == NULL)
9675- break;
9676+ continue;
9677 if (rpc_clnt_skip_event(clnt, event))
9678 continue;
9679 if (atomic_inc_not_zero(&clnt->cl_count) == 0)
9680diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c
9681index 21fde99..2a419f1 100644
9682--- a/net/sunrpc/rpc_pipe.c
9683+++ b/net/sunrpc/rpc_pipe.c
9684@@ -1152,14 +1152,19 @@ static void rpc_kill_sb(struct super_block *sb)
9685 struct sunrpc_net *sn = net_generic(net, sunrpc_net_id);
9686
9687 mutex_lock(&sn->pipefs_sb_lock);
9688+ if (sn->pipefs_sb != sb) {
9689+ mutex_unlock(&sn->pipefs_sb_lock);
9690+ goto out;
9691+ }
9692 sn->pipefs_sb = NULL;
9693 mutex_unlock(&sn->pipefs_sb_lock);
9694- put_net(net);
9695 dprintk("RPC: sending pipefs UMOUNT notification for net %p%s\n", net,
9696 NET_NAME(net));
9697 blocking_notifier_call_chain(&rpc_pipefs_notifier_list,
9698 RPC_PIPEFS_UMOUNT,
9699 sb);
9700+ put_net(net);
9701+out:
9702 kill_litter_super(sb);
9703 }
9704
9705diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
9706index 128494e..7fc5846 100644
9707--- a/net/sunrpc/sched.c
9708+++ b/net/sunrpc/sched.c
9709@@ -919,16 +919,35 @@ struct rpc_task *rpc_new_task(const struct rpc_task_setup *setup_data)
9710 return task;
9711 }
9712
9713+/*
9714+ * rpc_free_task - release rpc task and perform cleanups
9715+ *
9716+ * Note that we free up the rpc_task _after_ rpc_release_calldata()
9717+ * in order to work around a workqueue dependency issue.
9718+ *
9719+ * Tejun Heo states:
9720+ * "Workqueue currently considers two work items to be the same if they're
9721+ * on the same address and won't execute them concurrently - ie. it
9722+ * makes a work item which is queued again while being executed wait
9723+ * for the previous execution to complete.
9724+ *
9725+ * If a work function frees the work item, and then waits for an event
9726+ * which should be performed by another work item and *that* work item
9727+ * recycles the freed work item, it can create a false dependency loop.
9728+ * There really is no reliable way to detect this short of verifying
9729+ * every memory free."
9730+ *
9731+ */
9732 static void rpc_free_task(struct rpc_task *task)
9733 {
9734- const struct rpc_call_ops *tk_ops = task->tk_ops;
9735- void *calldata = task->tk_calldata;
9736+ unsigned short tk_flags = task->tk_flags;
9737+
9738+ rpc_release_calldata(task->tk_ops, task->tk_calldata);
9739
9740- if (task->tk_flags & RPC_TASK_DYNAMIC) {
9741+ if (tk_flags & RPC_TASK_DYNAMIC) {
9742 dprintk("RPC: %5u freeing task\n", task->tk_pid);
9743 mempool_free(task, rpc_task_mempool);
9744 }
9745- rpc_release_calldata(tk_ops, calldata);
9746 }
9747
9748 static void rpc_async_release(struct work_struct *work)
9749@@ -938,8 +957,7 @@ static void rpc_async_release(struct work_struct *work)
9750
9751 static void rpc_release_resources_task(struct rpc_task *task)
9752 {
9753- if (task->tk_rqstp)
9754- xprt_release(task);
9755+ xprt_release(task);
9756 if (task->tk_msg.rpc_cred) {
9757 put_rpccred(task->tk_msg.rpc_cred);
9758 task->tk_msg.rpc_cred = NULL;
9759diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c
9760index 5d7f61d..2480c01 100644
9761--- a/net/sunrpc/xprt.c
9762+++ b/net/sunrpc/xprt.c
9763@@ -1139,10 +1139,18 @@ static void xprt_request_init(struct rpc_task *task, struct rpc_xprt *xprt)
9764 void xprt_release(struct rpc_task *task)
9765 {
9766 struct rpc_xprt *xprt;
9767- struct rpc_rqst *req;
9768+ struct rpc_rqst *req = task->tk_rqstp;
9769
9770- if (!(req = task->tk_rqstp))
9771+ if (req == NULL) {
9772+ if (task->tk_client) {
9773+ rcu_read_lock();
9774+ xprt = rcu_dereference(task->tk_client->cl_xprt);
9775+ if (xprt->snd_task == task)
9776+ xprt_release_write(xprt, task);
9777+ rcu_read_unlock();
9778+ }
9779 return;
9780+ }
9781
9782 xprt = req->rq_xprt;
9783 if (task->tk_ops->rpc_count_stats != NULL)
9784diff --git a/security/integrity/evm/evm_crypto.c b/security/integrity/evm/evm_crypto.c
9785index 49a464f..62fa2c5 100644
9786--- a/security/integrity/evm/evm_crypto.c
9787+++ b/security/integrity/evm/evm_crypto.c
9788@@ -205,9 +205,9 @@ int evm_update_evmxattr(struct dentry *dentry, const char *xattr_name,
9789 rc = __vfs_setxattr_noperm(dentry, XATTR_NAME_EVM,
9790 &xattr_data,
9791 sizeof(xattr_data), 0);
9792- }
9793- else if (rc == -ENODATA)
9794+ } else if (rc == -ENODATA && inode->i_op->removexattr) {
9795 rc = inode->i_op->removexattr(dentry, XATTR_NAME_EVM);
9796+ }
9797 return rc;
9798 }
9799
9800diff --git a/sound/arm/pxa2xx-ac97-lib.c b/sound/arm/pxa2xx-ac97-lib.c
9801index 48d7c0a..bd3ba88 100644
9802--- a/sound/arm/pxa2xx-ac97-lib.c
9803+++ b/sound/arm/pxa2xx-ac97-lib.c
9804@@ -18,6 +18,7 @@
9805 #include <linux/delay.h>
9806 #include <linux/module.h>
9807 #include <linux/io.h>
9808+#include <linux/gpio.h>
9809
9810 #include <sound/ac97_codec.h>
9811 #include <sound/pxa2xx-lib.h>
9812@@ -148,6 +149,8 @@ static inline void pxa_ac97_warm_pxa27x(void)
9813
9814 static inline void pxa_ac97_cold_pxa27x(void)
9815 {
9816+ unsigned int timeout;
9817+
9818 GCR &= GCR_COLD_RST; /* clear everything but nCRST */
9819 GCR &= ~GCR_COLD_RST; /* then assert nCRST */
9820
9821@@ -157,8 +160,10 @@ static inline void pxa_ac97_cold_pxa27x(void)
9822 clk_enable(ac97conf_clk);
9823 udelay(5);
9824 clk_disable(ac97conf_clk);
9825- GCR = GCR_COLD_RST;
9826- udelay(50);
9827+ GCR = GCR_COLD_RST | GCR_WARM_RST;
9828+ timeout = 100; /* wait for the codec-ready bit to be set */
9829+ while (!((GSR | gsr_bits) & (GSR_PCR | GSR_SCR)) && timeout--)
9830+ mdelay(1);
9831 }
9832 #endif
9833
9834@@ -340,8 +345,21 @@ int __devinit pxa2xx_ac97_hw_probe(struct platform_device *dev)
9835 }
9836
9837 if (cpu_is_pxa27x()) {
9838- /* Use GPIO 113 as AC97 Reset on Bulverde */
9839+ /*
9840+ * This gpio is needed for a work-around to a bug in the ac97
9841+ * controller during warm reset. The direction and level is set
9842+ * here so that it is an output driven high when switching from
9843+ * AC97_nRESET alt function to generic gpio.
9844+ */
9845+ ret = gpio_request_one(reset_gpio, GPIOF_OUT_INIT_HIGH,
9846+ "pxa27x ac97 reset");
9847+ if (ret < 0) {
9848+ pr_err("%s: gpio_request_one() failed: %d\n",
9849+ __func__, ret);
9850+ goto err_conf;
9851+ }
9852 pxa27x_assert_ac97reset(reset_gpio, 0);
9853+
9854 ac97conf_clk = clk_get(&dev->dev, "AC97CONFCLK");
9855 if (IS_ERR(ac97conf_clk)) {
9856 ret = PTR_ERR(ac97conf_clk);
9857@@ -384,6 +402,8 @@ EXPORT_SYMBOL_GPL(pxa2xx_ac97_hw_probe);
9858
9859 void pxa2xx_ac97_hw_remove(struct platform_device *dev)
9860 {
9861+ if (cpu_is_pxa27x())
9862+ gpio_free(reset_gpio);
9863 GCR |= GCR_ACLINK_OFF;
9864 free_irq(IRQ_AC97, NULL);
9865 if (ac97conf_clk) {
9866diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
9867index e1b7061..c6646d9 100644
9868--- a/sound/pci/hda/patch_realtek.c
9869+++ b/sound/pci/hda/patch_realtek.c
9870@@ -4719,6 +4719,7 @@ static const struct snd_pci_quirk alc880_fixup_tbl[] = {
9871 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_FIXUP_VOL_KNOB),
9872 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_FIXUP_W810),
9873 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_FIXUP_MEDION_RIM),
9874+ SND_PCI_QUIRK(0x1631, 0xe011, "PB 13201056", ALC880_FIXUP_6ST),
9875 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_FIXUP_F1734),
9876 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FIXUP_FUJITSU),
9877 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_FIXUP_F1734),
9878@@ -6562,8 +6563,8 @@ static void alc861vd_fixup_dallas(struct hda_codec *codec,
9879 const struct alc_fixup *fix, int action)
9880 {
9881 if (action == ALC_FIXUP_ACT_PRE_PROBE) {
9882- snd_hda_override_pin_caps(codec, 0x18, 0x00001714);
9883- snd_hda_override_pin_caps(codec, 0x19, 0x0000171c);
9884+ snd_hda_override_pin_caps(codec, 0x18, 0x00000734);
9885+ snd_hda_override_pin_caps(codec, 0x19, 0x0000073c);
9886 }
9887 }
9888
9889diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
9890index 3d4722f..f206117 100644
9891--- a/sound/pci/hda/patch_sigmatel.c
9892+++ b/sound/pci/hda/patch_sigmatel.c
9893@@ -1698,7 +1698,7 @@ static const struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
9894 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1658,
9895 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
9896 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1659,
9897- "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
9898+ "HP Pavilion dv7", STAC_HP_DV7_4000),
9899 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x165A,
9900 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
9901 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x165B,
9902diff --git a/sound/soc/codecs/sigmadsp.c b/sound/soc/codecs/sigmadsp.c
9903index 5be42bf..4068f24 100644
9904--- a/sound/soc/codecs/sigmadsp.c
9905+++ b/sound/soc/codecs/sigmadsp.c
9906@@ -225,7 +225,7 @@ EXPORT_SYMBOL(process_sigma_firmware);
9907 static int sigma_action_write_regmap(void *control_data,
9908 const struct sigma_action *sa, size_t len)
9909 {
9910- return regmap_raw_write(control_data, le16_to_cpu(sa->addr),
9911+ return regmap_raw_write(control_data, be16_to_cpu(sa->addr),
9912 sa->payload, len - 2);
9913 }
9914
9915diff --git a/sound/soc/codecs/wm2000.c b/sound/soc/codecs/wm2000.c
9916index a3acb7a..6275a2b 100644
9917--- a/sound/soc/codecs/wm2000.c
9918+++ b/sound/soc/codecs/wm2000.c
9919@@ -188,9 +188,9 @@ static int wm2000_power_up(struct i2c_client *i2c, int analogue)
9920
9921 ret = wm2000_read(i2c, WM2000_REG_SPEECH_CLARITY);
9922 if (wm2000->speech_clarity)
9923- ret &= ~WM2000_SPEECH_CLARITY;
9924- else
9925 ret |= WM2000_SPEECH_CLARITY;
9926+ else
9927+ ret &= ~WM2000_SPEECH_CLARITY;
9928 wm2000_write(i2c, WM2000_REG_SPEECH_CLARITY, ret);
9929
9930 wm2000_write(i2c, WM2000_REG_SYS_START0, 0x33);
9931diff --git a/sound/soc/codecs/wm2200.c b/sound/soc/codecs/wm2200.c
9932index c8bff6d..8e0cf14 100644
9933--- a/sound/soc/codecs/wm2200.c
9934+++ b/sound/soc/codecs/wm2200.c
9935@@ -897,8 +897,6 @@ static const char *wm2200_mixer_texts[] = {
9936 "EQR",
9937 "LHPF1",
9938 "LHPF2",
9939- "LHPF3",
9940- "LHPF4",
9941 "DSP1.1",
9942 "DSP1.2",
9943 "DSP1.3",
9944@@ -931,7 +929,6 @@ static int wm2200_mixer_values[] = {
9945 0x25,
9946 0x50, /* EQ */
9947 0x51,
9948- 0x52,
9949 0x60, /* LHPF1 */
9950 0x61, /* LHPF2 */
9951 0x68, /* DSP1 */
9952@@ -1380,15 +1377,9 @@ static int wm2200_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
9953 case SND_SOC_DAIFMT_DSP_A:
9954 fmt_val = 0;
9955 break;
9956- case SND_SOC_DAIFMT_DSP_B:
9957- fmt_val = 1;
9958- break;
9959 case SND_SOC_DAIFMT_I2S:
9960 fmt_val = 2;
9961 break;
9962- case SND_SOC_DAIFMT_LEFT_J:
9963- fmt_val = 3;
9964- break;
9965 default:
9966 dev_err(codec->dev, "Unsupported DAI format %d\n",
9967 fmt & SND_SOC_DAIFMT_FORMAT_MASK);
9968@@ -1440,7 +1431,7 @@ static int wm2200_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
9969 WM2200_AIF1TX_LRCLK_MSTR | WM2200_AIF1TX_LRCLK_INV,
9970 lrclk);
9971 snd_soc_update_bits(codec, WM2200_AUDIO_IF_1_5,
9972- WM2200_AIF1_FMT_MASK << 1, fmt_val << 1);
9973+ WM2200_AIF1_FMT_MASK, fmt_val);
9974
9975 return 0;
9976 }
9977diff --git a/sound/soc/codecs/wm5100.c b/sound/soc/codecs/wm5100.c
9978index f481729..10d48cd 100644
9979--- a/sound/soc/codecs/wm5100.c
9980+++ b/sound/soc/codecs/wm5100.c
9981@@ -1279,15 +1279,9 @@ static int wm5100_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
9982 case SND_SOC_DAIFMT_DSP_A:
9983 mask = 0;
9984 break;
9985- case SND_SOC_DAIFMT_DSP_B:
9986- mask = 1;
9987- break;
9988 case SND_SOC_DAIFMT_I2S:
9989 mask = 2;
9990 break;
9991- case SND_SOC_DAIFMT_LEFT_J:
9992- mask = 3;
9993- break;
9994 default:
9995 dev_err(codec->dev, "Unsupported DAI format %d\n",
9996 fmt & SND_SOC_DAIFMT_FORMAT_MASK);
9997diff --git a/sound/usb/midi.c b/sound/usb/midi.c
9998index eeefbce..34b9bb7 100644
9999--- a/sound/usb/midi.c
10000+++ b/sound/usb/midi.c
10001@@ -116,6 +116,7 @@ struct snd_usb_midi {
10002 struct list_head list;
10003 struct timer_list error_timer;
10004 spinlock_t disc_lock;
10005+ struct rw_semaphore disc_rwsem;
10006 struct mutex mutex;
10007 u32 usb_id;
10008 int next_midi_device;
10009@@ -125,8 +126,10 @@ struct snd_usb_midi {
10010 struct snd_usb_midi_in_endpoint *in;
10011 } endpoints[MIDI_MAX_ENDPOINTS];
10012 unsigned long input_triggered;
10013- unsigned int opened;
10014+ bool autopm_reference;
10015+ unsigned int opened[2];
10016 unsigned char disconnected;
10017+ unsigned char input_running;
10018
10019 struct snd_kcontrol *roland_load_ctl;
10020 };
10021@@ -148,7 +151,6 @@ struct snd_usb_midi_out_endpoint {
10022 struct snd_usb_midi_out_endpoint* ep;
10023 struct snd_rawmidi_substream *substream;
10024 int active;
10025- bool autopm_reference;
10026 uint8_t cable; /* cable number << 4 */
10027 uint8_t state;
10028 #define STATE_UNKNOWN 0
10029@@ -1033,29 +1035,58 @@ static void update_roland_altsetting(struct snd_usb_midi* umidi)
10030 snd_usbmidi_input_start(&umidi->list);
10031 }
10032
10033-static void substream_open(struct snd_rawmidi_substream *substream, int open)
10034+static int substream_open(struct snd_rawmidi_substream *substream, int dir,
10035+ int open)
10036 {
10037 struct snd_usb_midi* umidi = substream->rmidi->private_data;
10038 struct snd_kcontrol *ctl;
10039+ int err;
10040+
10041+ down_read(&umidi->disc_rwsem);
10042+ if (umidi->disconnected) {
10043+ up_read(&umidi->disc_rwsem);
10044+ return open ? -ENODEV : 0;
10045+ }
10046
10047 mutex_lock(&umidi->mutex);
10048 if (open) {
10049- if (umidi->opened++ == 0 && umidi->roland_load_ctl) {
10050- ctl = umidi->roland_load_ctl;
10051- ctl->vd[0].access |= SNDRV_CTL_ELEM_ACCESS_INACTIVE;
10052- snd_ctl_notify(umidi->card,
10053+ if (!umidi->opened[0] && !umidi->opened[1]) {
10054+ err = usb_autopm_get_interface(umidi->iface);
10055+ umidi->autopm_reference = err >= 0;
10056+ if (err < 0 && err != -EACCES) {
10057+ mutex_unlock(&umidi->mutex);
10058+ up_read(&umidi->disc_rwsem);
10059+ return -EIO;
10060+ }
10061+ if (umidi->roland_load_ctl) {
10062+ ctl = umidi->roland_load_ctl;
10063+ ctl->vd[0].access |= SNDRV_CTL_ELEM_ACCESS_INACTIVE;
10064+ snd_ctl_notify(umidi->card,
10065 SNDRV_CTL_EVENT_MASK_INFO, &ctl->id);
10066- update_roland_altsetting(umidi);
10067+ update_roland_altsetting(umidi);
10068+ }
10069 }
10070+ umidi->opened[dir]++;
10071+ if (umidi->opened[1])
10072+ snd_usbmidi_input_start(&umidi->list);
10073 } else {
10074- if (--umidi->opened == 0 && umidi->roland_load_ctl) {
10075- ctl = umidi->roland_load_ctl;
10076- ctl->vd[0].access &= ~SNDRV_CTL_ELEM_ACCESS_INACTIVE;
10077- snd_ctl_notify(umidi->card,
10078+ umidi->opened[dir]--;
10079+ if (!umidi->opened[1])
10080+ snd_usbmidi_input_stop(&umidi->list);
10081+ if (!umidi->opened[0] && !umidi->opened[1]) {
10082+ if (umidi->roland_load_ctl) {
10083+ ctl = umidi->roland_load_ctl;
10084+ ctl->vd[0].access &= ~SNDRV_CTL_ELEM_ACCESS_INACTIVE;
10085+ snd_ctl_notify(umidi->card,
10086 SNDRV_CTL_EVENT_MASK_INFO, &ctl->id);
10087+ }
10088+ if (umidi->autopm_reference)
10089+ usb_autopm_put_interface(umidi->iface);
10090 }
10091 }
10092 mutex_unlock(&umidi->mutex);
10093+ up_read(&umidi->disc_rwsem);
10094+ return 0;
10095 }
10096
10097 static int snd_usbmidi_output_open(struct snd_rawmidi_substream *substream)
10098@@ -1063,7 +1094,6 @@ static int snd_usbmidi_output_open(struct snd_rawmidi_substream *substream)
10099 struct snd_usb_midi* umidi = substream->rmidi->private_data;
10100 struct usbmidi_out_port* port = NULL;
10101 int i, j;
10102- int err;
10103
10104 for (i = 0; i < MIDI_MAX_ENDPOINTS; ++i)
10105 if (umidi->endpoints[i].out)
10106@@ -1076,25 +1106,15 @@ static int snd_usbmidi_output_open(struct snd_rawmidi_substream *substream)
10107 snd_BUG();
10108 return -ENXIO;
10109 }
10110- err = usb_autopm_get_interface(umidi->iface);
10111- port->autopm_reference = err >= 0;
10112- if (err < 0 && err != -EACCES)
10113- return -EIO;
10114+
10115 substream->runtime->private_data = port;
10116 port->state = STATE_UNKNOWN;
10117- substream_open(substream, 1);
10118- return 0;
10119+ return substream_open(substream, 0, 1);
10120 }
10121
10122 static int snd_usbmidi_output_close(struct snd_rawmidi_substream *substream)
10123 {
10124- struct snd_usb_midi* umidi = substream->rmidi->private_data;
10125- struct usbmidi_out_port *port = substream->runtime->private_data;
10126-
10127- substream_open(substream, 0);
10128- if (port->autopm_reference)
10129- usb_autopm_put_interface(umidi->iface);
10130- return 0;
10131+ return substream_open(substream, 0, 0);
10132 }
10133
10134 static void snd_usbmidi_output_trigger(struct snd_rawmidi_substream *substream, int up)
10135@@ -1147,14 +1167,12 @@ static void snd_usbmidi_output_drain(struct snd_rawmidi_substream *substream)
10136
10137 static int snd_usbmidi_input_open(struct snd_rawmidi_substream *substream)
10138 {
10139- substream_open(substream, 1);
10140- return 0;
10141+ return substream_open(substream, 1, 1);
10142 }
10143
10144 static int snd_usbmidi_input_close(struct snd_rawmidi_substream *substream)
10145 {
10146- substream_open(substream, 0);
10147- return 0;
10148+ return substream_open(substream, 1, 0);
10149 }
10150
10151 static void snd_usbmidi_input_trigger(struct snd_rawmidi_substream *substream, int up)
10152@@ -1403,9 +1421,12 @@ void snd_usbmidi_disconnect(struct list_head* p)
10153 * a timer may submit an URB. To reliably break the cycle
10154 * a flag under lock must be used
10155 */
10156+ down_write(&umidi->disc_rwsem);
10157 spin_lock_irq(&umidi->disc_lock);
10158 umidi->disconnected = 1;
10159 spin_unlock_irq(&umidi->disc_lock);
10160+ up_write(&umidi->disc_rwsem);
10161+
10162 for (i = 0; i < MIDI_MAX_ENDPOINTS; ++i) {
10163 struct snd_usb_midi_endpoint* ep = &umidi->endpoints[i];
10164 if (ep->out)
10165@@ -2060,12 +2081,15 @@ void snd_usbmidi_input_stop(struct list_head* p)
10166 unsigned int i, j;
10167
10168 umidi = list_entry(p, struct snd_usb_midi, list);
10169+ if (!umidi->input_running)
10170+ return;
10171 for (i = 0; i < MIDI_MAX_ENDPOINTS; ++i) {
10172 struct snd_usb_midi_endpoint* ep = &umidi->endpoints[i];
10173 if (ep->in)
10174 for (j = 0; j < INPUT_URBS; ++j)
10175 usb_kill_urb(ep->in->urbs[j]);
10176 }
10177+ umidi->input_running = 0;
10178 }
10179
10180 static void snd_usbmidi_input_start_ep(struct snd_usb_midi_in_endpoint* ep)
10181@@ -2090,8 +2114,11 @@ void snd_usbmidi_input_start(struct list_head* p)
10182 int i;
10183
10184 umidi = list_entry(p, struct snd_usb_midi, list);
10185+ if (umidi->input_running || !umidi->opened[1])
10186+ return;
10187 for (i = 0; i < MIDI_MAX_ENDPOINTS; ++i)
10188 snd_usbmidi_input_start_ep(umidi->endpoints[i].in);
10189+ umidi->input_running = 1;
10190 }
10191
10192 /*
10193@@ -2117,6 +2144,7 @@ int snd_usbmidi_create(struct snd_card *card,
10194 umidi->usb_protocol_ops = &snd_usbmidi_standard_ops;
10195 init_timer(&umidi->error_timer);
10196 spin_lock_init(&umidi->disc_lock);
10197+ init_rwsem(&umidi->disc_rwsem);
10198 mutex_init(&umidi->mutex);
10199 umidi->usb_id = USB_ID(le16_to_cpu(umidi->dev->descriptor.idVendor),
10200 le16_to_cpu(umidi->dev->descriptor.idProduct));
10201@@ -2229,9 +2257,6 @@ int snd_usbmidi_create(struct snd_card *card,
10202 }
10203
10204 list_add_tail(&umidi->list, midi_list);
10205-
10206- for (i = 0; i < MIDI_MAX_ENDPOINTS; ++i)
10207- snd_usbmidi_input_start_ep(umidi->endpoints[i].in);
10208 return 0;
10209 }
10210
10211diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
10212index 298070e..41e8bfb 100644
10213--- a/sound/usb/mixer.c
10214+++ b/sound/usb/mixer.c
10215@@ -1259,16 +1259,23 @@ static int parse_audio_feature_unit(struct mixer_build *state, int unitid, void
10216 }
10217 channels = (hdr->bLength - 7) / csize - 1;
10218 bmaControls = hdr->bmaControls;
10219+ if (hdr->bLength < 7 + csize) {
10220+ snd_printk(KERN_ERR "usbaudio: unit %u: "
10221+ "invalid UAC_FEATURE_UNIT descriptor\n",
10222+ unitid);
10223+ return -EINVAL;
10224+ }
10225 } else {
10226 struct uac2_feature_unit_descriptor *ftr = _ftr;
10227 csize = 4;
10228 channels = (hdr->bLength - 6) / 4 - 1;
10229 bmaControls = ftr->bmaControls;
10230- }
10231-
10232- if (hdr->bLength < 7 || !csize || hdr->bLength < 7 + csize) {
10233- snd_printk(KERN_ERR "usbaudio: unit %u: invalid UAC_FEATURE_UNIT descriptor\n", unitid);
10234- return -EINVAL;
10235+ if (hdr->bLength < 6 + csize) {
10236+ snd_printk(KERN_ERR "usbaudio: unit %u: "
10237+ "invalid UAC_FEATURE_UNIT descriptor\n",
10238+ unitid);
10239+ return -EINVAL;
10240+ }
10241 }
10242
10243 /* parse the source unit */
10244diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c
10245index 0f58b4b..b8d1ad1 100644
10246--- a/sound/usb/quirks.c
10247+++ b/sound/usb/quirks.c
10248@@ -387,11 +387,13 @@ static int snd_usb_fasttrackpro_boot_quirk(struct usb_device *dev)
10249 * rules
10250 */
10251 err = usb_driver_set_configuration(dev, 2);
10252- if (err < 0) {
10253+ if (err < 0)
10254 snd_printdd("error usb_driver_set_configuration: %d\n",
10255 err);
10256- return -ENODEV;
10257- }
10258+ /* Always return an error, so that we stop creating a device
10259+ that will just be destroyed and recreated with a new
10260+ configuration */
10261+ return -ENODEV;
10262 } else
10263 snd_printk(KERN_INFO "usb-audio: Fast Track Pro config OK\n");
10264
10265diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
10266index d617f69..cd197be 100644
10267--- a/virt/kvm/kvm_main.c
10268+++ b/virt/kvm/kvm_main.c
10269@@ -701,8 +701,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
10270 int r;
10271 gfn_t base_gfn;
10272 unsigned long npages;
10273- unsigned long i;
10274- struct kvm_memory_slot *memslot;
10275+ struct kvm_memory_slot *memslot, *slot;
10276 struct kvm_memory_slot old, new;
10277 struct kvm_memslots *slots, *old_memslots;
10278
10279@@ -749,13 +748,11 @@ int __kvm_set_memory_region(struct kvm *kvm,
10280
10281 /* Check for overlaps */
10282 r = -EEXIST;
10283- for (i = 0; i < KVM_MEMORY_SLOTS; ++i) {
10284- struct kvm_memory_slot *s = &kvm->memslots->memslots[i];
10285-
10286- if (s == memslot || !s->npages)
10287+ kvm_for_each_memslot(slot, kvm->memslots) {
10288+ if (slot->id >= KVM_MEMORY_SLOTS || slot == memslot)
10289 continue;
10290- if (!((base_gfn + npages <= s->base_gfn) ||
10291- (base_gfn >= s->base_gfn + s->npages)))
10292+ if (!((base_gfn + npages <= slot->base_gfn) ||
10293+ (base_gfn >= slot->base_gfn + slot->npages)))
10294 goto out_free;
10295 }
10296