/[linux-patches]/genpatches-2.6/tags/3.0-30/1026_linux-3.0.27.patch
Gentoo

Contents of /genpatches-2.6/tags/3.0-30/1026_linux-3.0.27.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2206 - (show annotations) (download)
Mon Sep 17 18:58:14 2012 UTC (2 years, 1 month ago) by mpagano
File size: 139304 byte(s)
3.0-30 release
1 diff --git a/Makefile b/Makefile
2 index a04eef4..2996cbf 100644
3 --- a/Makefile
4 +++ b/Makefile
5 @@ -1,6 +1,6 @@
6 VERSION = 3
7 PATCHLEVEL = 0
8 -SUBLEVEL = 26
9 +SUBLEVEL = 27
10 EXTRAVERSION =
11 NAME = Sneaky Weasel
12
13 diff --git a/arch/x86/include/asm/kvm_emulate.h b/arch/x86/include/asm/kvm_emulate.h
14 index 0049211..0ab6a4d 100644
15 --- a/arch/x86/include/asm/kvm_emulate.h
16 +++ b/arch/x86/include/asm/kvm_emulate.h
17 @@ -189,6 +189,9 @@ struct x86_emulate_ops {
18 int (*intercept)(struct x86_emulate_ctxt *ctxt,
19 struct x86_instruction_info *info,
20 enum x86_intercept_stage stage);
21 +
22 + bool (*get_cpuid)(struct x86_emulate_ctxt *ctxt,
23 + u32 *eax, u32 *ebx, u32 *ecx, u32 *edx);
24 };
25
26 typedef u32 __attribute__((vector_size(16))) sse128_t;
27 @@ -298,6 +301,19 @@ struct x86_emulate_ctxt {
28 #define X86EMUL_MODE_PROT (X86EMUL_MODE_PROT16|X86EMUL_MODE_PROT32| \
29 X86EMUL_MODE_PROT64)
30
31 +/* CPUID vendors */
32 +#define X86EMUL_CPUID_VENDOR_AuthenticAMD_ebx 0x68747541
33 +#define X86EMUL_CPUID_VENDOR_AuthenticAMD_ecx 0x444d4163
34 +#define X86EMUL_CPUID_VENDOR_AuthenticAMD_edx 0x69746e65
35 +
36 +#define X86EMUL_CPUID_VENDOR_AMDisbetterI_ebx 0x69444d41
37 +#define X86EMUL_CPUID_VENDOR_AMDisbetterI_ecx 0x21726574
38 +#define X86EMUL_CPUID_VENDOR_AMDisbetterI_edx 0x74656273
39 +
40 +#define X86EMUL_CPUID_VENDOR_GenuineIntel_ebx 0x756e6547
41 +#define X86EMUL_CPUID_VENDOR_GenuineIntel_ecx 0x6c65746e
42 +#define X86EMUL_CPUID_VENDOR_GenuineIntel_edx 0x49656e69
43 +
44 enum x86_intercept_stage {
45 X86_ICTP_NONE = 0, /* Allow zero-init to not match anything */
46 X86_ICPT_PRE_EXCEPT,
47 diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
48 index e529339..16e9d94 100644
49 --- a/arch/x86/kernel/apic/io_apic.c
50 +++ b/arch/x86/kernel/apic/io_apic.c
51 @@ -3927,18 +3927,36 @@ int mp_find_ioapic_pin(int ioapic, u32 gsi)
52 static __init int bad_ioapic(unsigned long address)
53 {
54 if (nr_ioapics >= MAX_IO_APICS) {
55 - printk(KERN_WARNING "WARNING: Max # of I/O APICs (%d) exceeded "
56 - "(found %d), skipping\n", MAX_IO_APICS, nr_ioapics);
57 + pr_warn("WARNING: Max # of I/O APICs (%d) exceeded (found %d), skipping\n",
58 + MAX_IO_APICS, nr_ioapics);
59 return 1;
60 }
61 if (!address) {
62 - printk(KERN_WARNING "WARNING: Bogus (zero) I/O APIC address"
63 - " found in table, skipping!\n");
64 + pr_warn("WARNING: Bogus (zero) I/O APIC address found in table, skipping!\n");
65 return 1;
66 }
67 return 0;
68 }
69
70 +static __init int bad_ioapic_register(int idx)
71 +{
72 + union IO_APIC_reg_00 reg_00;
73 + union IO_APIC_reg_01 reg_01;
74 + union IO_APIC_reg_02 reg_02;
75 +
76 + reg_00.raw = io_apic_read(idx, 0);
77 + reg_01.raw = io_apic_read(idx, 1);
78 + reg_02.raw = io_apic_read(idx, 2);
79 +
80 + if (reg_00.raw == -1 && reg_01.raw == -1 && reg_02.raw == -1) {
81 + pr_warn("I/O APIC 0x%x registers return all ones, skipping!\n",
82 + mpc_ioapic_addr(idx));
83 + return 1;
84 + }
85 +
86 + return 0;
87 +}
88 +
89 void __init mp_register_ioapic(int id, u32 address, u32 gsi_base)
90 {
91 int idx = 0;
92 @@ -3955,6 +3973,12 @@ void __init mp_register_ioapic(int id, u32 address, u32 gsi_base)
93 ioapics[idx].mp_config.apicaddr = address;
94
95 set_fixmap_nocache(FIX_IO_APIC_BASE_0 + idx, address);
96 +
97 + if (bad_ioapic_register(idx)) {
98 + clear_fixmap(FIX_IO_APIC_BASE_0 + idx);
99 + return;
100 + }
101 +
102 ioapics[idx].mp_config.apicid = io_apic_unique_id(id);
103 ioapics[idx].mp_config.apicver = io_apic_get_version(idx);
104
105 @@ -3975,10 +3999,10 @@ void __init mp_register_ioapic(int id, u32 address, u32 gsi_base)
106 if (gsi_cfg->gsi_end >= gsi_top)
107 gsi_top = gsi_cfg->gsi_end + 1;
108
109 - printk(KERN_INFO "IOAPIC[%d]: apic_id %d, version %d, address 0x%x, "
110 - "GSI %d-%d\n", idx, mpc_ioapic_id(idx),
111 - mpc_ioapic_ver(idx), mpc_ioapic_addr(idx),
112 - gsi_cfg->gsi_base, gsi_cfg->gsi_end);
113 + pr_info("IOAPIC[%d]: apic_id %d, version %d, address 0x%x, GSI %d-%d\n",
114 + idx, mpc_ioapic_id(idx),
115 + mpc_ioapic_ver(idx), mpc_ioapic_addr(idx),
116 + gsi_cfg->gsi_base, gsi_cfg->gsi_end);
117
118 nr_ioapics++;
119 }
120 diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
121 index 5c1a9197..edb3d46 100644
122 --- a/arch/x86/kernel/entry_32.S
123 +++ b/arch/x86/kernel/entry_32.S
124 @@ -98,12 +98,6 @@
125 #endif
126 .endm
127
128 -#ifdef CONFIG_VM86
129 -#define resume_userspace_sig check_userspace
130 -#else
131 -#define resume_userspace_sig resume_userspace
132 -#endif
133 -
134 /*
135 * User gs save/restore
136 *
137 @@ -327,10 +321,19 @@ ret_from_exception:
138 preempt_stop(CLBR_ANY)
139 ret_from_intr:
140 GET_THREAD_INFO(%ebp)
141 -check_userspace:
142 +resume_userspace_sig:
143 +#ifdef CONFIG_VM86
144 movl PT_EFLAGS(%esp), %eax # mix EFLAGS and CS
145 movb PT_CS(%esp), %al
146 andl $(X86_EFLAGS_VM | SEGMENT_RPL_MASK), %eax
147 +#else
148 + /*
149 + * We can be coming here from a syscall done in the kernel space,
150 + * e.g. a failed kernel_execve().
151 + */
152 + movl PT_CS(%esp), %eax
153 + andl $SEGMENT_RPL_MASK, %eax
154 +#endif
155 cmpl $USER_RPL, %eax
156 jb resume_kernel # not returning to v8086 or userspace
157
158 diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c
159 index 6bb7b85..bcfec2d 100644
160 --- a/arch/x86/kernel/tls.c
161 +++ b/arch/x86/kernel/tls.c
162 @@ -163,7 +163,7 @@ int regset_tls_get(struct task_struct *target, const struct user_regset *regset,
163 {
164 const struct desc_struct *tls;
165
166 - if (pos > GDT_ENTRY_TLS_ENTRIES * sizeof(struct user_desc) ||
167 + if (pos >= GDT_ENTRY_TLS_ENTRIES * sizeof(struct user_desc) ||
168 (pos % sizeof(struct user_desc)) != 0 ||
169 (count % sizeof(struct user_desc)) != 0)
170 return -EINVAL;
171 @@ -198,7 +198,7 @@ int regset_tls_set(struct task_struct *target, const struct user_regset *regset,
172 struct user_desc infobuf[GDT_ENTRY_TLS_ENTRIES];
173 const struct user_desc *info;
174
175 - if (pos > GDT_ENTRY_TLS_ENTRIES * sizeof(struct user_desc) ||
176 + if (pos >= GDT_ENTRY_TLS_ENTRIES * sizeof(struct user_desc) ||
177 (pos % sizeof(struct user_desc)) != 0 ||
178 (count % sizeof(struct user_desc)) != 0)
179 return -EINVAL;
180 diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
181 index 6cc6922..63fed52 100644
182 --- a/arch/x86/kernel/tsc.c
183 +++ b/arch/x86/kernel/tsc.c
184 @@ -956,6 +956,16 @@ static int __init init_tsc_clocksource(void)
185 clocksource_tsc.rating = 0;
186 clocksource_tsc.flags &= ~CLOCK_SOURCE_IS_CONTINUOUS;
187 }
188 +
189 + /*
190 + * Trust the results of the earlier calibration on systems
191 + * exporting a reliable TSC.
192 + */
193 + if (boot_cpu_has(X86_FEATURE_TSC_RELIABLE)) {
194 + clocksource_register_khz(&clocksource_tsc, tsc_khz);
195 + return 0;
196 + }
197 +
198 schedule_delayed_work(&tsc_irqwork, 0);
199 return 0;
200 }
201 diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c
202 index 863f875..04b8726 100644
203 --- a/arch/x86/kernel/vm86_32.c
204 +++ b/arch/x86/kernel/vm86_32.c
205 @@ -172,6 +172,7 @@ static void mark_screen_rdonly(struct mm_struct *mm)
206 spinlock_t *ptl;
207 int i;
208
209 + down_write(&mm->mmap_sem);
210 pgd = pgd_offset(mm, 0xA0000);
211 if (pgd_none_or_clear_bad(pgd))
212 goto out;
213 @@ -190,6 +191,7 @@ static void mark_screen_rdonly(struct mm_struct *mm)
214 }
215 pte_unmap_unlock(pte, ptl);
216 out:
217 + up_write(&mm->mmap_sem);
218 flush_tlb();
219 }
220
221 diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
222 index adc9867..3e7d913 100644
223 --- a/arch/x86/kvm/emulate.c
224 +++ b/arch/x86/kvm/emulate.c
225 @@ -1901,6 +1901,51 @@ setup_syscalls_segments(struct x86_emulate_ctxt *ctxt,
226 ss->p = 1;
227 }
228
229 +static bool em_syscall_is_enabled(struct x86_emulate_ctxt *ctxt)
230 +{
231 + struct x86_emulate_ops *ops = ctxt->ops;
232 + u32 eax, ebx, ecx, edx;
233 +
234 + /*
235 + * syscall should always be enabled in longmode - so only become
236 + * vendor specific (cpuid) if other modes are active...
237 + */
238 + if (ctxt->mode == X86EMUL_MODE_PROT64)
239 + return true;
240 +
241 + eax = 0x00000000;
242 + ecx = 0x00000000;
243 + if (ops->get_cpuid(ctxt, &eax, &ebx, &ecx, &edx)) {
244 + /*
245 + * Intel ("GenuineIntel")
246 + * remark: Intel CPUs only support "syscall" in 64bit
247 + * longmode. Also an 64bit guest with a
248 + * 32bit compat-app running will #UD !! While this
249 + * behaviour can be fixed (by emulating) into AMD
250 + * response - CPUs of AMD can't behave like Intel.
251 + */
252 + if (ebx == X86EMUL_CPUID_VENDOR_GenuineIntel_ebx &&
253 + ecx == X86EMUL_CPUID_VENDOR_GenuineIntel_ecx &&
254 + edx == X86EMUL_CPUID_VENDOR_GenuineIntel_edx)
255 + return false;
256 +
257 + /* AMD ("AuthenticAMD") */
258 + if (ebx == X86EMUL_CPUID_VENDOR_AuthenticAMD_ebx &&
259 + ecx == X86EMUL_CPUID_VENDOR_AuthenticAMD_ecx &&
260 + edx == X86EMUL_CPUID_VENDOR_AuthenticAMD_edx)
261 + return true;
262 +
263 + /* AMD ("AMDisbetter!") */
264 + if (ebx == X86EMUL_CPUID_VENDOR_AMDisbetterI_ebx &&
265 + ecx == X86EMUL_CPUID_VENDOR_AMDisbetterI_ecx &&
266 + edx == X86EMUL_CPUID_VENDOR_AMDisbetterI_edx)
267 + return true;
268 + }
269 +
270 + /* default: (not Intel, not AMD), apply Intel's stricter rules... */
271 + return false;
272 +}
273 +
274 static int
275 emulate_syscall(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops)
276 {
277 @@ -1915,9 +1960,15 @@ emulate_syscall(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops)
278 ctxt->mode == X86EMUL_MODE_VM86)
279 return emulate_ud(ctxt);
280
281 + if (!(em_syscall_is_enabled(ctxt)))
282 + return emulate_ud(ctxt);
283 +
284 ops->get_msr(ctxt, MSR_EFER, &efer);
285 setup_syscalls_segments(ctxt, ops, &cs, &ss);
286
287 + if (!(efer & EFER_SCE))
288 + return emulate_ud(ctxt);
289 +
290 ops->get_msr(ctxt, MSR_STAR, &msr_data);
291 msr_data >>= 32;
292 cs_sel = (u16)(msr_data & 0xfffc);
293 diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
294 index 77c9d86..fbb0936 100644
295 --- a/arch/x86/kvm/x86.c
296 +++ b/arch/x86/kvm/x86.c
297 @@ -4407,6 +4407,28 @@ static int emulator_intercept(struct x86_emulate_ctxt *ctxt,
298 return kvm_x86_ops->check_intercept(emul_to_vcpu(ctxt), info, stage);
299 }
300
301 +static bool emulator_get_cpuid(struct x86_emulate_ctxt *ctxt,
302 + u32 *eax, u32 *ebx, u32 *ecx, u32 *edx)
303 +{
304 + struct kvm_cpuid_entry2 *cpuid = NULL;
305 +
306 + if (eax && ecx)
307 + cpuid = kvm_find_cpuid_entry(emul_to_vcpu(ctxt),
308 + *eax, *ecx);
309 +
310 + if (cpuid) {
311 + *eax = cpuid->eax;
312 + *ecx = cpuid->ecx;
313 + if (ebx)
314 + *ebx = cpuid->ebx;
315 + if (edx)
316 + *edx = cpuid->edx;
317 + return true;
318 + }
319 +
320 + return false;
321 +}
322 +
323 static struct x86_emulate_ops emulate_ops = {
324 .read_std = kvm_read_guest_virt_system,
325 .write_std = kvm_write_guest_virt_system,
326 @@ -4437,6 +4459,7 @@ static struct x86_emulate_ops emulate_ops = {
327 .get_fpu = emulator_get_fpu,
328 .put_fpu = emulator_put_fpu,
329 .intercept = emulator_intercept,
330 + .get_cpuid = emulator_get_cpuid,
331 };
332
333 static void cache_all_regs(struct kvm_vcpu *vcpu)
334 diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
335 index 7c1b765..5671752 100644
336 --- a/arch/x86/net/bpf_jit_comp.c
337 +++ b/arch/x86/net/bpf_jit_comp.c
338 @@ -475,8 +475,10 @@ void bpf_jit_compile(struct sk_filter *fp)
339 case BPF_S_LD_W_ABS:
340 func = sk_load_word;
341 common_load: seen |= SEEN_DATAREF;
342 - if ((int)K < 0)
343 + if ((int)K < 0) {
344 + /* Abort the JIT because __load_pointer() is needed. */
345 goto out;
346 + }
347 t_offset = func - (image + addrs[i]);
348 EMIT1_off32(0xbe, K); /* mov imm32,%esi */
349 EMIT1_off32(0xe8, t_offset); /* call */
350 @@ -489,14 +491,8 @@ common_load: seen |= SEEN_DATAREF;
351 goto common_load;
352 case BPF_S_LDX_B_MSH:
353 if ((int)K < 0) {
354 - if (pc_ret0 > 0) {
355 - /* addrs[pc_ret0 - 1] is the start address */
356 - EMIT_JMP(addrs[pc_ret0 - 1] - addrs[i]);
357 - break;
358 - }
359 - CLEAR_A();
360 - EMIT_JMP(cleanup_addr - addrs[i]);
361 - break;
362 + /* Abort the JIT because __load_pointer() is needed. */
363 + goto out;
364 }
365 seen |= SEEN_DATAREF | SEEN_XREG;
366 t_offset = sk_load_byte_msh - (image + addrs[i]);
367 diff --git a/drivers/ata/pata_legacy.c b/drivers/ata/pata_legacy.c
368 index 6bd9425..d750962 100644
369 --- a/drivers/ata/pata_legacy.c
370 +++ b/drivers/ata/pata_legacy.c
371 @@ -396,8 +396,7 @@ static void ht6560b_set_piomode(struct ata_port *ap, struct ata_device *adev)
372 ata_timing_compute(adev, adev->pio_mode, &t, 20000, 1000);
373
374 active = clamp_val(t.active, 2, 15);
375 - recover = clamp_val(t.recover, 2, 16);
376 - recover &= 0x15;
377 + recover = clamp_val(t.recover, 2, 16) & 0x0F;
378
379 inb(0x3E6);
380 inb(0x3E6);
381 diff --git a/drivers/bluetooth/ath3k.c b/drivers/bluetooth/ath3k.c
382 index db7cb81..5c2a722 100644
383 --- a/drivers/bluetooth/ath3k.c
384 +++ b/drivers/bluetooth/ath3k.c
385 @@ -64,6 +64,7 @@ static struct usb_device_id ath3k_table[] = {
386 { USB_DEVICE(0x0CF3, 0x3002) },
387 { USB_DEVICE(0x13d3, 0x3304) },
388 { USB_DEVICE(0x0930, 0x0215) },
389 + { USB_DEVICE(0x0489, 0xE03D) },
390
391 /* Atheros AR9285 Malbec with sflash firmware */
392 { USB_DEVICE(0x03F0, 0x311D) },
393 diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
394 index b9af6db..9f3a8b3 100644
395 --- a/drivers/bluetooth/btusb.c
396 +++ b/drivers/bluetooth/btusb.c
397 @@ -116,6 +116,7 @@ static struct usb_device_id blacklist_table[] = {
398 { USB_DEVICE(0x0cf3, 0x3002), .driver_info = BTUSB_IGNORE },
399 { USB_DEVICE(0x13d3, 0x3304), .driver_info = BTUSB_IGNORE },
400 { USB_DEVICE(0x0930, 0x0215), .driver_info = BTUSB_IGNORE },
401 + { USB_DEVICE(0x0489, 0xe03d), .driver_info = BTUSB_IGNORE },
402
403 /* Atheros AR9285 Malbec with sflash firmware */
404 { USB_DEVICE(0x03f0, 0x311d), .driver_info = BTUSB_IGNORE },
405 @@ -497,15 +498,10 @@ static int btusb_submit_isoc_urb(struct hci_dev *hdev, gfp_t mem_flags)
406
407 pipe = usb_rcvisocpipe(data->udev, data->isoc_rx_ep->bEndpointAddress);
408
409 - urb->dev = data->udev;
410 - urb->pipe = pipe;
411 - urb->context = hdev;
412 - urb->complete = btusb_isoc_complete;
413 - urb->interval = data->isoc_rx_ep->bInterval;
414 + usb_fill_int_urb(urb, data->udev, pipe, buf, size, btusb_isoc_complete,
415 + hdev, data->isoc_rx_ep->bInterval);
416
417 urb->transfer_flags = URB_FREE_BUFFER | URB_ISO_ASAP;
418 - urb->transfer_buffer = buf;
419 - urb->transfer_buffer_length = size;
420
421 __fill_isoc_descriptor(urb, size,
422 le16_to_cpu(data->isoc_rx_ep->wMaxPacketSize));
423 diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c
424 index 7f97c30..271fc51 100644
425 --- a/drivers/firewire/ohci.c
426 +++ b/drivers/firewire/ohci.c
427 @@ -2558,15 +2558,14 @@ static int handle_ir_buffer_fill(struct context *context,
428 struct iso_context *ctx =
429 container_of(context, struct iso_context, context);
430
431 - if (!last->transfer_status)
432 + if (last->res_count != 0)
433 /* Descriptor(s) not done yet, stop iteration */
434 return 0;
435
436 if (le16_to_cpu(last->control) & DESCRIPTOR_IRQ_ALWAYS)
437 ctx->base.callback.mc(&ctx->base,
438 le32_to_cpu(last->data_address) +
439 - le16_to_cpu(last->req_count) -
440 - le16_to_cpu(last->res_count),
441 + le16_to_cpu(last->req_count),
442 ctx->base.callback_data);
443
444 return 1;
445 diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
446 index eb91e2d..2d3e16b 100644
447 --- a/drivers/gpu/drm/i915/i915_drv.c
448 +++ b/drivers/gpu/drm/i915/i915_drv.c
449 @@ -379,6 +379,10 @@ static int i915_drm_freeze(struct drm_device *dev)
450 /* Modeset on resume, not lid events */
451 dev_priv->modeset_on_lid = 0;
452
453 + console_lock();
454 + intel_fbdev_set_suspend(dev, 1);
455 + console_unlock();
456 +
457 return 0;
458 }
459
460 @@ -448,6 +452,9 @@ static int i915_drm_thaw(struct drm_device *dev)
461
462 dev_priv->modeset_on_lid = 0;
463
464 + console_lock();
465 + intel_fbdev_set_suspend(dev, 0);
466 + console_unlock();
467 return error;
468 }
469
470 diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
471 index 9ffa61e..47bf5e1 100644
472 --- a/drivers/gpu/drm/i915/intel_drv.h
473 +++ b/drivers/gpu/drm/i915/intel_drv.h
474 @@ -330,7 +330,7 @@ extern int intel_framebuffer_init(struct drm_device *dev,
475 struct drm_i915_gem_object *obj);
476 extern int intel_fbdev_init(struct drm_device *dev);
477 extern void intel_fbdev_fini(struct drm_device *dev);
478 -
479 +extern void intel_fbdev_set_suspend(struct drm_device *dev, int state);
480 extern void intel_prepare_page_flip(struct drm_device *dev, int plane);
481 extern void intel_finish_page_flip(struct drm_device *dev, int pipe);
482 extern void intel_finish_page_flip_plane(struct drm_device *dev, int plane);
483 diff --git a/drivers/gpu/drm/i915/intel_fb.c b/drivers/gpu/drm/i915/intel_fb.c
484 index ec49bae..d0ce34b 100644
485 --- a/drivers/gpu/drm/i915/intel_fb.c
486 +++ b/drivers/gpu/drm/i915/intel_fb.c
487 @@ -257,6 +257,16 @@ void intel_fbdev_fini(struct drm_device *dev)
488 kfree(dev_priv->fbdev);
489 dev_priv->fbdev = NULL;
490 }
491 +
492 +void intel_fbdev_set_suspend(struct drm_device *dev, int state)
493 +{
494 + drm_i915_private_t *dev_priv = dev->dev_private;
495 + if (!dev_priv->fbdev)
496 + return;
497 +
498 + fb_set_suspend(dev_priv->fbdev->helper.fbdev, state);
499 +}
500 +
501 MODULE_LICENSE("GPL and additional rights");
502
503 void intel_fb_output_poll_changed(struct drm_device *dev)
504 diff --git a/drivers/gpu/drm/radeon/radeon_atombios.c b/drivers/gpu/drm/radeon/radeon_atombios.c
505 index a098edc..a324564 100644
506 --- a/drivers/gpu/drm/radeon/radeon_atombios.c
507 +++ b/drivers/gpu/drm/radeon/radeon_atombios.c
508 @@ -484,6 +484,20 @@ static bool radeon_atom_apply_quirks(struct drm_device *dev,
509 struct radeon_device *rdev = dev->dev_private;
510 *i2c_bus = radeon_lookup_i2c_gpio(rdev, 0x93);
511 }
512 +
513 + /* Fujitsu D3003-S2 board lists DVI-I as DVI-D and VGA */
514 + if ((dev->pdev->device == 0x9802) &&
515 + (dev->pdev->subsystem_vendor == 0x1734) &&
516 + (dev->pdev->subsystem_device == 0x11bd)) {
517 + if (*connector_type == DRM_MODE_CONNECTOR_VGA) {
518 + *connector_type = DRM_MODE_CONNECTOR_DVII;
519 + *line_mux = 0x3103;
520 + } else if (*connector_type == DRM_MODE_CONNECTOR_DVID) {
521 + *connector_type = DRM_MODE_CONNECTOR_DVII;
522 + }
523 + }
524 +
525 +
526 return true;
527 }
528
529 diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c b/drivers/gpu/drm/radeon/radeon_connectors.c
530 index 2109c17..6ceb3c8 100644
531 --- a/drivers/gpu/drm/radeon/radeon_connectors.c
532 +++ b/drivers/gpu/drm/radeon/radeon_connectors.c
533 @@ -990,6 +990,10 @@ radeon_dvi_detect(struct drm_connector *connector, bool force)
534
535 encoder = obj_to_encoder(obj);
536
537 + if (encoder->encoder_type != DRM_MODE_ENCODER_DAC ||
538 + encoder->encoder_type != DRM_MODE_ENCODER_TVDAC)
539 + continue;
540 +
541 encoder_funcs = encoder->helper_private;
542 if (encoder_funcs->detect) {
543 if (ret != connector_status_connected) {
544 diff --git a/drivers/gpu/drm/radeon/radeon_cursor.c b/drivers/gpu/drm/radeon/radeon_cursor.c
545 index f59a682..3fb2226 100644
546 --- a/drivers/gpu/drm/radeon/radeon_cursor.c
547 +++ b/drivers/gpu/drm/radeon/radeon_cursor.c
548 @@ -151,7 +151,9 @@ int radeon_crtc_cursor_set(struct drm_crtc *crtc,
549 uint32_t height)
550 {
551 struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
552 + struct radeon_device *rdev = crtc->dev->dev_private;
553 struct drm_gem_object *obj;
554 + struct radeon_bo *robj;
555 uint64_t gpu_addr;
556 int ret;
557
558 @@ -173,7 +175,15 @@ int radeon_crtc_cursor_set(struct drm_crtc *crtc,
559 return -ENOENT;
560 }
561
562 - ret = radeon_gem_object_pin(obj, RADEON_GEM_DOMAIN_VRAM, &gpu_addr);
563 + robj = gem_to_radeon_bo(obj);
564 + ret = radeon_bo_reserve(robj, false);
565 + if (unlikely(ret != 0))
566 + goto fail;
567 + /* Only 27 bit offset for legacy cursor */
568 + ret = radeon_bo_pin_restricted(robj, RADEON_GEM_DOMAIN_VRAM,
569 + ASIC_IS_AVIVO(rdev) ? 0 : 1 << 27,
570 + &gpu_addr);
571 + radeon_bo_unreserve(robj);
572 if (ret)
573 goto fail;
574
575 @@ -181,7 +191,6 @@ int radeon_crtc_cursor_set(struct drm_crtc *crtc,
576 radeon_crtc->cursor_height = height;
577
578 radeon_lock_cursor(crtc, true);
579 - /* XXX only 27 bit offset for legacy cursor */
580 radeon_set_cursor(crtc, obj, gpu_addr);
581 radeon_show_cursor(crtc);
582 radeon_lock_cursor(crtc, false);
583 diff --git a/drivers/gpu/drm/radeon/radeon_object.c b/drivers/gpu/drm/radeon/radeon_object.c
584 index 976c3b1..35da1b4 100644
585 --- a/drivers/gpu/drm/radeon/radeon_object.c
586 +++ b/drivers/gpu/drm/radeon/radeon_object.c
587 @@ -204,7 +204,8 @@ void radeon_bo_unref(struct radeon_bo **bo)
588 *bo = NULL;
589 }
590
591 -int radeon_bo_pin(struct radeon_bo *bo, u32 domain, u64 *gpu_addr)
592 +int radeon_bo_pin_restricted(struct radeon_bo *bo, u32 domain, u64 max_offset,
593 + u64 *gpu_addr)
594 {
595 int r, i;
596
597 @@ -212,6 +213,7 @@ int radeon_bo_pin(struct radeon_bo *bo, u32 domain, u64 *gpu_addr)
598 bo->pin_count++;
599 if (gpu_addr)
600 *gpu_addr = radeon_bo_gpu_offset(bo);
601 + WARN_ON_ONCE(max_offset != 0);
602 return 0;
603 }
604 radeon_ttm_placement_from_domain(bo, domain);
605 @@ -219,6 +221,15 @@ int radeon_bo_pin(struct radeon_bo *bo, u32 domain, u64 *gpu_addr)
606 /* force to pin into visible video ram */
607 bo->placement.lpfn = bo->rdev->mc.visible_vram_size >> PAGE_SHIFT;
608 }
609 + if (max_offset) {
610 + u64 lpfn = max_offset >> PAGE_SHIFT;
611 +
612 + if (!bo->placement.lpfn)
613 + bo->placement.lpfn = bo->rdev->mc.gtt_size >> PAGE_SHIFT;
614 +
615 + if (lpfn < bo->placement.lpfn)
616 + bo->placement.lpfn = lpfn;
617 + }
618 for (i = 0; i < bo->placement.num_placement; i++)
619 bo->placements[i] |= TTM_PL_FLAG_NO_EVICT;
620 r = ttm_bo_validate(&bo->tbo, &bo->placement, false, false, false);
621 @@ -232,6 +243,11 @@ int radeon_bo_pin(struct radeon_bo *bo, u32 domain, u64 *gpu_addr)
622 return r;
623 }
624
625 +int radeon_bo_pin(struct radeon_bo *bo, u32 domain, u64 *gpu_addr)
626 +{
627 + return radeon_bo_pin_restricted(bo, domain, 0, gpu_addr);
628 +}
629 +
630 int radeon_bo_unpin(struct radeon_bo *bo)
631 {
632 int r, i;
633 diff --git a/drivers/gpu/drm/radeon/radeon_object.h b/drivers/gpu/drm/radeon/radeon_object.h
634 index ede6c13..7199c6a 100644
635 --- a/drivers/gpu/drm/radeon/radeon_object.h
636 +++ b/drivers/gpu/drm/radeon/radeon_object.h
637 @@ -144,6 +144,8 @@ extern int radeon_bo_kmap(struct radeon_bo *bo, void **ptr);
638 extern void radeon_bo_kunmap(struct radeon_bo *bo);
639 extern void radeon_bo_unref(struct radeon_bo **bo);
640 extern int radeon_bo_pin(struct radeon_bo *bo, u32 domain, u64 *gpu_addr);
641 +extern int radeon_bo_pin_restricted(struct radeon_bo *bo, u32 domain,
642 + u64 max_offset, u64 *gpu_addr);
643 extern int radeon_bo_unpin(struct radeon_bo *bo);
644 extern int radeon_bo_evict_vram(struct radeon_device *rdev);
645 extern void radeon_bo_force_delete(struct radeon_device *rdev);
646 diff --git a/drivers/hid/hid-chicony.c b/drivers/hid/hid-chicony.c
647 index 8965ad9..b99af34 100644
648 --- a/drivers/hid/hid-chicony.c
649 +++ b/drivers/hid/hid-chicony.c
650 @@ -45,6 +45,12 @@ static int ch_input_mapping(struct hid_device *hdev, struct hid_input *hi,
651 case 0xff09: ch_map_key_clear(BTN_9); break;
652 case 0xff0a: ch_map_key_clear(BTN_A); break;
653 case 0xff0b: ch_map_key_clear(BTN_B); break;
654 + case 0x00f1: ch_map_key_clear(KEY_WLAN); break;
655 + case 0x00f2: ch_map_key_clear(KEY_BRIGHTNESSDOWN); break;
656 + case 0x00f3: ch_map_key_clear(KEY_BRIGHTNESSUP); break;
657 + case 0x00f4: ch_map_key_clear(KEY_DISPLAY_OFF); break;
658 + case 0x00f7: ch_map_key_clear(KEY_CAMERA); break;
659 + case 0x00f8: ch_map_key_clear(KEY_PROG1); break;
660 default:
661 return 0;
662 }
663 @@ -53,6 +59,7 @@ static int ch_input_mapping(struct hid_device *hdev, struct hid_input *hi,
664
665 static const struct hid_device_id ch_devices[] = {
666 { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_TACTICAL_PAD) },
667 + { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_WIRELESS2) },
668 { }
669 };
670 MODULE_DEVICE_TABLE(hid, ch_devices);
671 diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
672 index 2f855b1..53576e7 100644
673 --- a/drivers/hid/hid-core.c
674 +++ b/drivers/hid/hid-core.c
675 @@ -1372,6 +1372,7 @@ static const struct hid_device_id hid_have_special_driver[] = {
676 { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION_SOLAR) },
677 { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_TACTICAL_PAD) },
678 { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_WIRELESS) },
679 + { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_WIRELESS2) },
680 { HID_USB_DEVICE(USB_VENDOR_ID_CHUNGHWAT, USB_DEVICE_ID_CHUNGHWAT_MULTITOUCH) },
681 { HID_USB_DEVICE(USB_VENDOR_ID_CREATIVELABS, USB_DEVICE_ID_PRODIKEYS_PCMIDI) },
682 { HID_USB_DEVICE(USB_VENDOR_ID_CVTOUCH, USB_DEVICE_ID_CVTOUCH_SCREEN) },
683 diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
684 index 6781fe0..08cc68b 100644
685 --- a/drivers/hid/hid-ids.h
686 +++ b/drivers/hid/hid-ids.h
687 @@ -189,6 +189,7 @@
688 #define USB_DEVICE_ID_CHICONY_TACTICAL_PAD 0x0418
689 #define USB_DEVICE_ID_CHICONY_MULTI_TOUCH 0xb19d
690 #define USB_DEVICE_ID_CHICONY_WIRELESS 0x0618
691 +#define USB_DEVICE_ID_CHICONY_WIRELESS2 0x1123
692
693 #define USB_VENDOR_ID_CHUNGHWAT 0x2247
694 #define USB_DEVICE_ID_CHUNGHWAT_MULTITOUCH 0x0001
695 diff --git a/drivers/hwmon/fam15h_power.c b/drivers/hwmon/fam15h_power.c
696 index 523f8fb..930370d 100644
697 --- a/drivers/hwmon/fam15h_power.c
698 +++ b/drivers/hwmon/fam15h_power.c
699 @@ -60,7 +60,7 @@ static ssize_t show_power(struct device *dev,
700 pci_bus_read_config_dword(f4->bus, PCI_DEVFN(PCI_SLOT(f4->devfn), 5),
701 REG_TDP_RUNNING_AVERAGE, &val);
702 running_avg_capture = (val >> 4) & 0x3fffff;
703 - running_avg_capture = sign_extend32(running_avg_capture, 22);
704 + running_avg_capture = sign_extend32(running_avg_capture, 21);
705 running_avg_range = val & 0xf;
706
707 pci_bus_read_config_dword(f4->bus, PCI_DEVFN(PCI_SLOT(f4->devfn), 5),
708 diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.c b/drivers/infiniband/ulp/iser/iscsi_iser.c
709 index 8db008d..f8f5758 100644
710 --- a/drivers/infiniband/ulp/iser/iscsi_iser.c
711 +++ b/drivers/infiniband/ulp/iser/iscsi_iser.c
712 @@ -354,6 +354,9 @@ iscsi_iser_conn_bind(struct iscsi_cls_session *cls_session,
713 }
714 ib_conn = ep->dd_data;
715
716 + if (iser_alloc_rx_descriptors(ib_conn))
717 + return -ENOMEM;
718 +
719 /* binds the iSER connection retrieved from the previously
720 * connected ep_handle to the iSCSI layer connection. exchanges
721 * connection pointers */
722 @@ -388,19 +391,6 @@ iscsi_iser_conn_stop(struct iscsi_cls_conn *cls_conn, int flag)
723 iser_conn->ib_conn = NULL;
724 }
725
726 -static int
727 -iscsi_iser_conn_start(struct iscsi_cls_conn *cls_conn)
728 -{
729 - struct iscsi_conn *conn = cls_conn->dd_data;
730 - int err;
731 -
732 - err = iser_conn_set_full_featured_mode(conn);
733 - if (err)
734 - return err;
735 -
736 - return iscsi_conn_start(cls_conn);
737 -}
738 -
739 static void iscsi_iser_session_destroy(struct iscsi_cls_session *cls_session)
740 {
741 struct Scsi_Host *shost = iscsi_session_to_shost(cls_session);
742 @@ -686,7 +676,7 @@ static struct iscsi_transport iscsi_iser_transport = {
743 .get_conn_param = iscsi_conn_get_param,
744 .get_ep_param = iscsi_iser_get_ep_param,
745 .get_session_param = iscsi_session_get_param,
746 - .start_conn = iscsi_iser_conn_start,
747 + .start_conn = iscsi_conn_start,
748 .stop_conn = iscsi_iser_conn_stop,
749 /* iscsi host params */
750 .get_host_param = iscsi_host_get_param,
751 diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.h b/drivers/infiniband/ulp/iser/iscsi_iser.h
752 index 2f02ab0..634aef0 100644
753 --- a/drivers/infiniband/ulp/iser/iscsi_iser.h
754 +++ b/drivers/infiniband/ulp/iser/iscsi_iser.h
755 @@ -365,4 +365,5 @@ int iser_dma_map_task_data(struct iscsi_iser_task *iser_task,
756 void iser_dma_unmap_task_data(struct iscsi_iser_task *iser_task);
757 int iser_initialize_task_headers(struct iscsi_task *task,
758 struct iser_tx_desc *tx_desc);
759 +int iser_alloc_rx_descriptors(struct iser_conn *ib_conn);
760 #endif
761 diff --git a/drivers/infiniband/ulp/iser/iser_initiator.c b/drivers/infiniband/ulp/iser/iser_initiator.c
762 index 95a08a8..eb1ee6f 100644
763 --- a/drivers/infiniband/ulp/iser/iser_initiator.c
764 +++ b/drivers/infiniband/ulp/iser/iser_initiator.c
765 @@ -170,7 +170,7 @@ static void iser_create_send_desc(struct iser_conn *ib_conn,
766 }
767
768
769 -static int iser_alloc_rx_descriptors(struct iser_conn *ib_conn)
770 +int iser_alloc_rx_descriptors(struct iser_conn *ib_conn)
771 {
772 int i, j;
773 u64 dma_addr;
774 @@ -236,23 +236,24 @@ void iser_free_rx_descriptors(struct iser_conn *ib_conn)
775 kfree(ib_conn->rx_descs);
776 }
777
778 -/**
779 - * iser_conn_set_full_featured_mode - (iSER API)
780 - */
781 -int iser_conn_set_full_featured_mode(struct iscsi_conn *conn)
782 +static int iser_post_rx_bufs(struct iscsi_conn *conn, struct iscsi_hdr *req)
783 {
784 struct iscsi_iser_conn *iser_conn = conn->dd_data;
785
786 - iser_dbg("Initially post: %d\n", ISER_MIN_POSTED_RX);
787 -
788 - /* Check that there is no posted recv or send buffers left - */
789 - /* they must be consumed during the login phase */
790 - BUG_ON(iser_conn->ib_conn->post_recv_buf_count != 0);
791 - BUG_ON(atomic_read(&iser_conn->ib_conn->post_send_buf_count) != 0);
792 + iser_dbg("req op %x flags %x\n", req->opcode, req->flags);
793 + /* check if this is the last login - going to full feature phase */
794 + if ((req->flags & ISCSI_FULL_FEATURE_PHASE) != ISCSI_FULL_FEATURE_PHASE)
795 + return 0;
796
797 - if (iser_alloc_rx_descriptors(iser_conn->ib_conn))
798 - return -ENOMEM;
799 + /*
800 + * Check that there is one posted recv buffer (for the last login
801 + * response) and no posted send buffers left - they must have been
802 + * consumed during previous login phases.
803 + */
804 + WARN_ON(iser_conn->ib_conn->post_recv_buf_count != 1);
805 + WARN_ON(atomic_read(&iser_conn->ib_conn->post_send_buf_count) != 0);
806
807 + iser_dbg("Initially post: %d\n", ISER_MIN_POSTED_RX);
808 /* Initial post receive buffers */
809 if (iser_post_recvm(iser_conn->ib_conn, ISER_MIN_POSTED_RX))
810 return -ENOMEM;
811 @@ -421,6 +422,9 @@ int iser_send_control(struct iscsi_conn *conn,
812 err = iser_post_recvl(iser_conn->ib_conn);
813 if (err)
814 goto send_control_error;
815 + err = iser_post_rx_bufs(conn, task->hdr);
816 + if (err)
817 + goto send_control_error;
818 }
819
820 err = iser_post_send(iser_conn->ib_conn, mdesc);
821 diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
822 index 574b09a..703a3fa 100644
823 --- a/drivers/md/bitmap.c
824 +++ b/drivers/md/bitmap.c
825 @@ -1982,6 +1982,8 @@ location_store(mddev_t *mddev, const char *buf, size_t len)
826 if (mddev->pers) {
827 mddev->pers->quiesce(mddev, 1);
828 rv = bitmap_create(mddev);
829 + if (!rv)
830 + rv = bitmap_load(mddev);
831 if (rv) {
832 bitmap_destroy(mddev);
833 mddev->bitmap_info.offset = 0;
834 diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
835 index c8827ff..6f906bc 100644
836 --- a/drivers/md/dm-crypt.c
837 +++ b/drivers/md/dm-crypt.c
838 @@ -177,7 +177,6 @@ struct crypt_config {
839
840 #define MIN_IOS 16
841 #define MIN_POOL_PAGES 32
842 -#define MIN_BIO_PAGES 8
843
844 static struct kmem_cache *_crypt_io_pool;
845
846 @@ -849,12 +848,11 @@ static struct bio *crypt_alloc_buffer(struct dm_crypt_io *io, unsigned size,
847 }
848
849 /*
850 - * if additional pages cannot be allocated without waiting,
851 - * return a partially allocated bio, the caller will then try
852 - * to allocate additional bios while submitting this partial bio
853 + * If additional pages cannot be allocated without waiting,
854 + * return a partially-allocated bio. The caller will then try
855 + * to allocate more bios while submitting this partial bio.
856 */
857 - if (i == (MIN_BIO_PAGES - 1))
858 - gfp_mask = (gfp_mask | __GFP_NOWARN) & ~__GFP_WAIT;
859 + gfp_mask = (gfp_mask | __GFP_NOWARN) & ~__GFP_WAIT;
860
861 len = (size > PAGE_SIZE) ? PAGE_SIZE : size;
862
863 @@ -1047,16 +1045,14 @@ static void kcryptd_queue_io(struct dm_crypt_io *io)
864 queue_work(cc->io_queue, &io->work);
865 }
866
867 -static void kcryptd_crypt_write_io_submit(struct dm_crypt_io *io,
868 - int error, int async)
869 +static void kcryptd_crypt_write_io_submit(struct dm_crypt_io *io, int async)
870 {
871 struct bio *clone = io->ctx.bio_out;
872 struct crypt_config *cc = io->target->private;
873
874 - if (unlikely(error < 0)) {
875 + if (unlikely(io->error < 0)) {
876 crypt_free_buffer_pages(cc, clone);
877 bio_put(clone);
878 - io->error = -EIO;
879 crypt_dec_pending(io);
880 return;
881 }
882 @@ -1107,12 +1103,16 @@ static void kcryptd_crypt_write_convert(struct dm_crypt_io *io)
883 sector += bio_sectors(clone);
884
885 crypt_inc_pending(io);
886 +
887 r = crypt_convert(cc, &io->ctx);
888 + if (r < 0)
889 + io->error = -EIO;
890 +
891 crypt_finished = atomic_dec_and_test(&io->ctx.pending);
892
893 /* Encryption was already finished, submit io now */
894 if (crypt_finished) {
895 - kcryptd_crypt_write_io_submit(io, r, 0);
896 + kcryptd_crypt_write_io_submit(io, 0);
897
898 /*
899 * If there was an error, do not try next fragments.
900 @@ -1163,11 +1163,8 @@ static void kcryptd_crypt_write_convert(struct dm_crypt_io *io)
901 crypt_dec_pending(io);
902 }
903
904 -static void kcryptd_crypt_read_done(struct dm_crypt_io *io, int error)
905 +static void kcryptd_crypt_read_done(struct dm_crypt_io *io)
906 {
907 - if (unlikely(error < 0))
908 - io->error = -EIO;
909 -
910 crypt_dec_pending(io);
911 }
912
913 @@ -1182,9 +1179,11 @@ static void kcryptd_crypt_read_convert(struct dm_crypt_io *io)
914 io->sector);
915
916 r = crypt_convert(cc, &io->ctx);
917 + if (r < 0)
918 + io->error = -EIO;
919
920 if (atomic_dec_and_test(&io->ctx.pending))
921 - kcryptd_crypt_read_done(io, r);
922 + kcryptd_crypt_read_done(io);
923
924 crypt_dec_pending(io);
925 }
926 @@ -1205,15 +1204,18 @@ static void kcryptd_async_done(struct crypto_async_request *async_req,
927 if (!error && cc->iv_gen_ops && cc->iv_gen_ops->post)
928 error = cc->iv_gen_ops->post(cc, iv_of_dmreq(cc, dmreq), dmreq);
929
930 + if (error < 0)
931 + io->error = -EIO;
932 +
933 mempool_free(req_of_dmreq(cc, dmreq), cc->req_pool);
934
935 if (!atomic_dec_and_test(&ctx->pending))
936 return;
937
938 if (bio_data_dir(io->base_bio) == READ)
939 - kcryptd_crypt_read_done(io, error);
940 + kcryptd_crypt_read_done(io);
941 else
942 - kcryptd_crypt_write_io_submit(io, error, 1);
943 + kcryptd_crypt_write_io_submit(io, 1);
944 }
945
946 static void kcryptd_crypt(struct work_struct *work)
947 diff --git a/drivers/md/dm-exception-store.c b/drivers/md/dm-exception-store.c
948 index 0bdb201..7344534 100644
949 --- a/drivers/md/dm-exception-store.c
950 +++ b/drivers/md/dm-exception-store.c
951 @@ -282,7 +282,7 @@ int dm_exception_store_init(void)
952 return 0;
953
954 persistent_fail:
955 - dm_persistent_snapshot_exit();
956 + dm_transient_snapshot_exit();
957 transient_fail:
958 return r;
959 }
960 diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
961 index 3a9e59f..36f1ed3 100644
962 --- a/drivers/md/raid1.c
963 +++ b/drivers/md/raid1.c
964 @@ -614,9 +614,22 @@ static void wait_barrier(conf_t *conf)
965 spin_lock_irq(&conf->resync_lock);
966 if (conf->barrier) {
967 conf->nr_waiting++;
968 - wait_event_lock_irq(conf->wait_barrier, !conf->barrier,
969 + /* Wait for the barrier to drop.
970 + * However if there are already pending
971 + * requests (preventing the barrier from
972 + * rising completely), and the
973 + * pre-process bio queue isn't empty,
974 + * then don't wait, as we need to empty
975 + * that queue to get the nr_pending
976 + * count down.
977 + */
978 + wait_event_lock_irq(conf->wait_barrier,
979 + !conf->barrier ||
980 + (conf->nr_pending &&
981 + current->bio_list &&
982 + !bio_list_empty(current->bio_list)),
983 conf->resync_lock,
984 - );
985 + );
986 conf->nr_waiting--;
987 }
988 conf->nr_pending++;
989 diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
990 index 17cb6ab..0d6c42f 100644
991 --- a/drivers/md/raid10.c
992 +++ b/drivers/md/raid10.c
993 @@ -667,9 +667,22 @@ static void wait_barrier(conf_t *conf)
994 spin_lock_irq(&conf->resync_lock);
995 if (conf->barrier) {
996 conf->nr_waiting++;
997 - wait_event_lock_irq(conf->wait_barrier, !conf->barrier,
998 + /* Wait for the barrier to drop.
999 + * However if there are already pending
1000 + * requests (preventing the barrier from
1001 + * rising completely), and the
1002 + * pre-process bio queue isn't empty,
1003 + * then don't wait, as we need to empty
1004 + * that queue to get the nr_pending
1005 + * count down.
1006 + */
1007 + wait_event_lock_irq(conf->wait_barrier,
1008 + !conf->barrier ||
1009 + (conf->nr_pending &&
1010 + current->bio_list &&
1011 + !bio_list_empty(current->bio_list)),
1012 conf->resync_lock,
1013 - );
1014 + );
1015 conf->nr_waiting--;
1016 }
1017 conf->nr_pending++;
1018 diff --git a/drivers/media/dvb/frontends/lgdt330x.c b/drivers/media/dvb/frontends/lgdt330x.c
1019 index 43971e6..aa63d68 100644
1020 --- a/drivers/media/dvb/frontends/lgdt330x.c
1021 +++ b/drivers/media/dvb/frontends/lgdt330x.c
1022 @@ -104,8 +104,8 @@ static int i2c_write_demod_bytes (struct lgdt330x_state* state,
1023 * then reads the data returned for (len) bytes.
1024 */
1025
1026 -static u8 i2c_read_demod_bytes (struct lgdt330x_state* state,
1027 - enum I2C_REG reg, u8* buf, int len)
1028 +static int i2c_read_demod_bytes(struct lgdt330x_state *state,
1029 + enum I2C_REG reg, u8 *buf, int len)
1030 {
1031 u8 wr [] = { reg };
1032 struct i2c_msg msg [] = {
1033 @@ -118,6 +118,8 @@ static u8 i2c_read_demod_bytes (struct lgdt330x_state* state,
1034 ret = i2c_transfer(state->i2c, msg, 2);
1035 if (ret != 2) {
1036 printk(KERN_WARNING "lgdt330x: %s: addr 0x%02x select 0x%02x error (ret == %i)\n", __func__, state->config->demod_address, reg, ret);
1037 + if (ret >= 0)
1038 + ret = -EIO;
1039 } else {
1040 ret = 0;
1041 }
1042 diff --git a/drivers/media/video/pvrusb2/pvrusb2-devattr.c b/drivers/media/video/pvrusb2/pvrusb2-devattr.c
1043 index e799331..c4eca15 100644
1044 --- a/drivers/media/video/pvrusb2/pvrusb2-devattr.c
1045 +++ b/drivers/media/video/pvrusb2/pvrusb2-devattr.c
1046 @@ -319,7 +319,17 @@ static struct tda829x_config tda829x_no_probe = {
1047 .probe_tuner = TDA829X_DONT_PROBE,
1048 };
1049
1050 +static struct tda18271_std_map hauppauge_tda18271_dvbt_std_map = {
1051 + .dvbt_6 = { .if_freq = 3300, .agc_mode = 3, .std = 4,
1052 + .if_lvl = 1, .rfagc_top = 0x37, },
1053 + .dvbt_7 = { .if_freq = 3800, .agc_mode = 3, .std = 5,
1054 + .if_lvl = 1, .rfagc_top = 0x37, },
1055 + .dvbt_8 = { .if_freq = 4300, .agc_mode = 3, .std = 6,
1056 + .if_lvl = 1, .rfagc_top = 0x37, },
1057 +};
1058 +
1059 static struct tda18271_config hauppauge_tda18271_dvb_config = {
1060 + .std_map = &hauppauge_tda18271_dvbt_std_map,
1061 .gate = TDA18271_GATE_ANALOG,
1062 .output_opt = TDA18271_OUTPUT_LT_OFF,
1063 };
1064 diff --git a/drivers/mtd/ubi/scan.c b/drivers/mtd/ubi/scan.c
1065 index 2135a53..0b49ead 100644
1066 --- a/drivers/mtd/ubi/scan.c
1067 +++ b/drivers/mtd/ubi/scan.c
1068 @@ -1174,7 +1174,7 @@ struct ubi_scan_info *ubi_scan(struct ubi_device *ubi)
1069
1070 ech = kzalloc(ubi->ec_hdr_alsize, GFP_KERNEL);
1071 if (!ech)
1072 - goto out_slab;
1073 + goto out_si;
1074
1075 vidh = ubi_zalloc_vid_hdr(ubi, GFP_KERNEL);
1076 if (!vidh)
1077 @@ -1235,8 +1235,6 @@ out_vidh:
1078 ubi_free_vid_hdr(ubi, vidh);
1079 out_ech:
1080 kfree(ech);
1081 -out_slab:
1082 - kmem_cache_destroy(si->scan_leb_slab);
1083 out_si:
1084 ubi_scan_destroy_si(si);
1085 return ERR_PTR(err);
1086 @@ -1325,7 +1323,9 @@ void ubi_scan_destroy_si(struct ubi_scan_info *si)
1087 }
1088 }
1089
1090 - kmem_cache_destroy(si->scan_leb_slab);
1091 + if (si->scan_leb_slab)
1092 + kmem_cache_destroy(si->scan_leb_slab);
1093 +
1094 kfree(si);
1095 }
1096
1097 diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c
1098 index 12e44c9..25f18e9 100644
1099 --- a/drivers/mtd/ubi/wl.c
1100 +++ b/drivers/mtd/ubi/wl.c
1101 @@ -386,7 +386,7 @@ static struct ubi_wl_entry *find_wl_entry(struct rb_root *root, int max)
1102 */
1103 int ubi_wl_get_peb(struct ubi_device *ubi, int dtype)
1104 {
1105 - int err, medium_ec;
1106 + int err;
1107 struct ubi_wl_entry *e, *first, *last;
1108
1109 ubi_assert(dtype == UBI_LONGTERM || dtype == UBI_SHORTTERM ||
1110 @@ -424,7 +424,7 @@ retry:
1111 * For unknown data we pick a physical eraseblock with medium
1112 * erase counter. But we by no means can pick a physical
1113 * eraseblock with erase counter greater or equivalent than the
1114 - * lowest erase counter plus %WL_FREE_MAX_DIFF.
1115 + * lowest erase counter plus %WL_FREE_MAX_DIFF/2.
1116 */
1117 first = rb_entry(rb_first(&ubi->free), struct ubi_wl_entry,
1118 u.rb);
1119 @@ -433,10 +433,8 @@ retry:
1120 if (last->ec - first->ec < WL_FREE_MAX_DIFF)
1121 e = rb_entry(ubi->free.rb_node,
1122 struct ubi_wl_entry, u.rb);
1123 - else {
1124 - medium_ec = (first->ec + WL_FREE_MAX_DIFF)/2;
1125 - e = find_wl_entry(&ubi->free, medium_ec);
1126 - }
1127 + else
1128 + e = find_wl_entry(&ubi->free, WL_FREE_MAX_DIFF/2);
1129 break;
1130 case UBI_SHORTTERM:
1131 /*
1132 diff --git a/drivers/net/e1000e/e1000.h b/drivers/net/e1000e/e1000.h
1133 index 9549879..8a265f35 100644
1134 --- a/drivers/net/e1000e/e1000.h
1135 +++ b/drivers/net/e1000e/e1000.h
1136 @@ -311,6 +311,7 @@ struct e1000_adapter {
1137 u32 txd_cmd;
1138
1139 bool detect_tx_hung;
1140 + bool tx_hang_recheck;
1141 u8 tx_timeout_factor;
1142
1143 u32 tx_int_delay;
1144 diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
1145 index 3310c3d..5430a9a 100644
1146 --- a/drivers/net/e1000e/netdev.c
1147 +++ b/drivers/net/e1000e/netdev.c
1148 @@ -930,6 +930,7 @@ static void e1000_print_hw_hang(struct work_struct *work)
1149 struct e1000_adapter *adapter = container_of(work,
1150 struct e1000_adapter,
1151 print_hang_task);
1152 + struct net_device *netdev = adapter->netdev;
1153 struct e1000_ring *tx_ring = adapter->tx_ring;
1154 unsigned int i = tx_ring->next_to_clean;
1155 unsigned int eop = tx_ring->buffer_info[i].next_to_watch;
1156 @@ -941,6 +942,21 @@ static void e1000_print_hw_hang(struct work_struct *work)
1157 if (test_bit(__E1000_DOWN, &adapter->state))
1158 return;
1159
1160 + if (!adapter->tx_hang_recheck &&
1161 + (adapter->flags2 & FLAG2_DMA_BURST)) {
1162 + /* May be block on write-back, flush and detect again
1163 + * flush pending descriptor writebacks to memory
1164 + */
1165 + ew32(TIDV, adapter->tx_int_delay | E1000_TIDV_FPD);
1166 + /* execute the writes immediately */
1167 + e1e_flush();
1168 + adapter->tx_hang_recheck = true;
1169 + return;
1170 + }
1171 + /* Real hang detected */
1172 + adapter->tx_hang_recheck = false;
1173 + netif_stop_queue(netdev);
1174 +
1175 e1e_rphy(hw, PHY_STATUS, &phy_status);
1176 e1e_rphy(hw, PHY_1000T_STATUS, &phy_1000t_status);
1177 e1e_rphy(hw, PHY_EXT_STATUS, &phy_ext_status);
1178 @@ -1054,10 +1070,10 @@ static bool e1000_clean_tx_irq(struct e1000_adapter *adapter)
1179 if (tx_ring->buffer_info[i].time_stamp &&
1180 time_after(jiffies, tx_ring->buffer_info[i].time_stamp
1181 + (adapter->tx_timeout_factor * HZ)) &&
1182 - !(er32(STATUS) & E1000_STATUS_TXOFF)) {
1183 + !(er32(STATUS) & E1000_STATUS_TXOFF))
1184 schedule_work(&adapter->print_hang_task);
1185 - netif_stop_queue(netdev);
1186 - }
1187 + else
1188 + adapter->tx_hang_recheck = false;
1189 }
1190 adapter->total_tx_bytes += total_tx_bytes;
1191 adapter->total_tx_packets += total_tx_packets;
1192 @@ -3678,6 +3694,7 @@ static int e1000_open(struct net_device *netdev)
1193
1194 e1000_irq_enable(adapter);
1195
1196 + adapter->tx_hang_recheck = false;
1197 netif_start_queue(netdev);
1198
1199 adapter->idle_check = true;
1200 diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c
1201 index 3ee41da..80df3a8 100644
1202 --- a/drivers/net/sky2.c
1203 +++ b/drivers/net/sky2.c
1204 @@ -94,6 +94,10 @@ static int disable_msi = 0;
1205 module_param(disable_msi, int, 0);
1206 MODULE_PARM_DESC(disable_msi, "Disable Message Signaled Interrupt (MSI)");
1207
1208 +static int legacy_pme = 0;
1209 +module_param(legacy_pme, int, 0);
1210 +MODULE_PARM_DESC(legacy_pme, "Legacy power management");
1211 +
1212 static DEFINE_PCI_DEVICE_TABLE(sky2_id_table) = {
1213 { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9000) }, /* SK-9Sxx */
1214 { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9E00) }, /* SK-9Exx */
1215 @@ -794,6 +798,13 @@ static void sky2_wol_init(struct sky2_port *sky2)
1216 /* Disable PiG firmware */
1217 sky2_write16(hw, B0_CTST, Y2_HW_WOL_OFF);
1218
1219 + /* Needed by some broken BIOSes, use PCI rather than PCI-e for WOL */
1220 + if (legacy_pme) {
1221 + u32 reg1 = sky2_pci_read32(hw, PCI_DEV_REG1);
1222 + reg1 |= PCI_Y2_PME_LEGACY;
1223 + sky2_pci_write32(hw, PCI_DEV_REG1, reg1);
1224 + }
1225 +
1226 /* block receiver */
1227 sky2_write8(hw, SK_REG(port, RX_GMF_CTRL_T), GMF_RST_SET);
1228 }
1229 diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
1230 index 4918cf5..46a6b67 100644
1231 --- a/drivers/net/usb/usbnet.c
1232 +++ b/drivers/net/usb/usbnet.c
1233 @@ -585,6 +585,14 @@ static int unlink_urbs (struct usbnet *dev, struct sk_buff_head *q)
1234 entry = (struct skb_data *) skb->cb;
1235 urb = entry->urb;
1236
1237 + /*
1238 + * Get reference count of the URB to avoid it to be
1239 + * freed during usb_unlink_urb, which may trigger
1240 + * use-after-free problem inside usb_unlink_urb since
1241 + * usb_unlink_urb is always racing with .complete
1242 + * handler(include defer_bh).
1243 + */
1244 + usb_get_urb(urb);
1245 spin_unlock_irqrestore(&q->lock, flags);
1246 // during some PM-driven resume scenarios,
1247 // these (async) unlinks complete immediately
1248 @@ -593,6 +601,7 @@ static int unlink_urbs (struct usbnet *dev, struct sk_buff_head *q)
1249 netdev_dbg(dev->net, "unlink urb err, %d\n", retval);
1250 else
1251 count++;
1252 + usb_put_urb(urb);
1253 spin_lock_irqsave(&q->lock, flags);
1254 }
1255 spin_unlock_irqrestore (&q->lock, flags);
1256 @@ -1024,7 +1033,6 @@ static void tx_complete (struct urb *urb)
1257 }
1258
1259 usb_autopm_put_interface_async(dev->intf);
1260 - urb->dev = NULL;
1261 entry->state = tx_done;
1262 defer_bh(dev, skb, &dev->txq);
1263 }
1264 diff --git a/drivers/net/wireless/p54/p54spi.c b/drivers/net/wireless/p54/p54spi.c
1265 index b33ceb1..d895ff9 100644
1266 --- a/drivers/net/wireless/p54/p54spi.c
1267 +++ b/drivers/net/wireless/p54/p54spi.c
1268 @@ -623,19 +623,19 @@ static int __devinit p54spi_probe(struct spi_device *spi)
1269 ret = spi_setup(spi);
1270 if (ret < 0) {
1271 dev_err(&priv->spi->dev, "spi_setup failed");
1272 - goto err_free_common;
1273 + goto err_free;
1274 }
1275
1276 ret = gpio_request(p54spi_gpio_power, "p54spi power");
1277 if (ret < 0) {
1278 dev_err(&priv->spi->dev, "power GPIO request failed: %d", ret);
1279 - goto err_free_common;
1280 + goto err_free;
1281 }
1282
1283 ret = gpio_request(p54spi_gpio_irq, "p54spi irq");
1284 if (ret < 0) {
1285 dev_err(&priv->spi->dev, "irq GPIO request failed: %d", ret);
1286 - goto err_free_common;
1287 + goto err_free_gpio_power;
1288 }
1289
1290 gpio_direction_output(p54spi_gpio_power, 0);
1291 @@ -646,7 +646,7 @@ static int __devinit p54spi_probe(struct spi_device *spi)
1292 priv->spi);
1293 if (ret < 0) {
1294 dev_err(&priv->spi->dev, "request_irq() failed");
1295 - goto err_free_common;
1296 + goto err_free_gpio_irq;
1297 }
1298
1299 irq_set_irq_type(gpio_to_irq(p54spi_gpio_irq), IRQ_TYPE_EDGE_RISING);
1300 @@ -678,6 +678,12 @@ static int __devinit p54spi_probe(struct spi_device *spi)
1301 return 0;
1302
1303 err_free_common:
1304 + free_irq(gpio_to_irq(p54spi_gpio_irq), spi);
1305 +err_free_gpio_irq:
1306 + gpio_free(p54spi_gpio_irq);
1307 +err_free_gpio_power:
1308 + gpio_free(p54spi_gpio_power);
1309 +err_free:
1310 p54_free_common(priv->hw);
1311 return ret;
1312 }
1313 diff --git a/drivers/net/wireless/rt2x00/rt2800usb.c b/drivers/net/wireless/rt2x00/rt2800usb.c
1314 index d4e9eac..97edee2 100644
1315 --- a/drivers/net/wireless/rt2x00/rt2800usb.c
1316 +++ b/drivers/net/wireless/rt2x00/rt2800usb.c
1317 @@ -839,6 +839,7 @@ static struct usb_device_id rt2800usb_device_table[] = {
1318 { USB_DEVICE(0x07d1, 0x3c0f) },
1319 { USB_DEVICE(0x07d1, 0x3c11) },
1320 { USB_DEVICE(0x07d1, 0x3c16) },
1321 + { USB_DEVICE(0x2001, 0x3c1b) },
1322 /* Draytek */
1323 { USB_DEVICE(0x07fa, 0x7712) },
1324 /* Edimax */
1325 diff --git a/drivers/net/wireless/rtlwifi/pci.c b/drivers/net/wireless/rtlwifi/pci.c
1326 index c872a23..6c56198 100644
1327 --- a/drivers/net/wireless/rtlwifi/pci.c
1328 +++ b/drivers/net/wireless/rtlwifi/pci.c
1329 @@ -1180,10 +1180,12 @@ static void _rtl_pci_free_tx_ring(struct ieee80211_hw *hw,
1330 ring->idx = (ring->idx + 1) % ring->entries;
1331 }
1332
1333 - pci_free_consistent(rtlpci->pdev,
1334 - sizeof(*ring->desc) * ring->entries,
1335 - ring->desc, ring->dma);
1336 - ring->desc = NULL;
1337 + if (ring->desc) {
1338 + pci_free_consistent(rtlpci->pdev,
1339 + sizeof(*ring->desc) * ring->entries,
1340 + ring->desc, ring->dma);
1341 + ring->desc = NULL;
1342 + }
1343 }
1344
1345 static void _rtl_pci_free_rx_ring(struct rtl_pci *rtlpci)
1346 @@ -1207,12 +1209,14 @@ static void _rtl_pci_free_rx_ring(struct rtl_pci *rtlpci)
1347 kfree_skb(skb);
1348 }
1349
1350 - pci_free_consistent(rtlpci->pdev,
1351 + if (rtlpci->rx_ring[rx_queue_idx].desc) {
1352 + pci_free_consistent(rtlpci->pdev,
1353 sizeof(*rtlpci->rx_ring[rx_queue_idx].
1354 desc) * rtlpci->rxringcount,
1355 rtlpci->rx_ring[rx_queue_idx].desc,
1356 rtlpci->rx_ring[rx_queue_idx].dma);
1357 - rtlpci->rx_ring[rx_queue_idx].desc = NULL;
1358 + rtlpci->rx_ring[rx_queue_idx].desc = NULL;
1359 + }
1360 }
1361 }
1362
1363 diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c b/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c
1364 index 9718382..2d33d7d 100644
1365 --- a/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c
1366 +++ b/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c
1367 @@ -523,6 +523,10 @@ void rtl92c_dm_write_dig(struct ieee80211_hw *hw)
1368 dm_digtable.cur_igvalue, dm_digtable.pre_igvalue,
1369 dm_digtable.backoff_val));
1370
1371 + dm_digtable.cur_igvalue += 2;
1372 + if (dm_digtable.cur_igvalue > 0x3f)
1373 + dm_digtable.cur_igvalue = 0x3f;
1374 +
1375 if (dm_digtable.pre_igvalue != dm_digtable.cur_igvalue) {
1376 rtl_set_bbreg(hw, ROFDM0_XAAGCCORE1, 0x7f,
1377 dm_digtable.cur_igvalue);
1378 @@ -1218,13 +1222,18 @@ static void rtl92c_dm_refresh_rate_adaptive_mask(struct ieee80211_hw *hw)
1379 ("PreState = %d, CurState = %d\n",
1380 p_ra->pre_ratr_state, p_ra->ratr_state));
1381
1382 - rcu_read_lock();
1383 - sta = ieee80211_find_sta(mac->vif, mac->bssid);
1384 + /* Only the PCI card uses sta in the update rate table
1385 + * callback routine */
1386 + if (rtlhal->interface == INTF_PCI) {
1387 + rcu_read_lock();
1388 + sta = ieee80211_find_sta(mac->vif, mac->bssid);
1389 + }
1390 rtlpriv->cfg->ops->update_rate_tbl(hw, sta,
1391 p_ra->ratr_state);
1392
1393 p_ra->pre_ratr_state = p_ra->ratr_state;
1394 - rcu_read_unlock();
1395 + if (rtlhal->interface == INTF_PCI)
1396 + rcu_read_unlock();
1397 }
1398 }
1399 }
1400 diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
1401 index 56a6966..0ff0182 100644
1402 --- a/drivers/pci/pcie/aspm.c
1403 +++ b/drivers/pci/pcie/aspm.c
1404 @@ -500,9 +500,6 @@ static int pcie_aspm_sanity_check(struct pci_dev *pdev)
1405 int pos;
1406 u32 reg32;
1407
1408 - if (aspm_disabled)
1409 - return 0;
1410 -
1411 /*
1412 * Some functions in a slot might not all be PCIe functions,
1413 * very strange. Disable ASPM for the whole slot
1414 @@ -511,6 +508,16 @@ static int pcie_aspm_sanity_check(struct pci_dev *pdev)
1415 pos = pci_pcie_cap(child);
1416 if (!pos)
1417 return -EINVAL;
1418 +
1419 + /*
1420 + * If ASPM is disabled then we're not going to change
1421 + * the BIOS state. It's safe to continue even if it's a
1422 + * pre-1.1 device
1423 + */
1424 +
1425 + if (aspm_disabled)
1426 + continue;
1427 +
1428 /*
1429 * Disable ASPM for pre-1.1 PCIe device, we follow MS to use
1430 * RBER bit to determine if a function is 1.1 version device
1431 diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c
1432 index 38d1dc7..636a2ec 100644
1433 --- a/drivers/rtc/interface.c
1434 +++ b/drivers/rtc/interface.c
1435 @@ -762,6 +762,14 @@ static int rtc_timer_enqueue(struct rtc_device *rtc, struct rtc_timer *timer)
1436 return 0;
1437 }
1438
1439 +static void rtc_alarm_disable(struct rtc_device *rtc)
1440 +{
1441 + if (!rtc->ops || !rtc->ops->alarm_irq_enable)
1442 + return;
1443 +
1444 + rtc->ops->alarm_irq_enable(rtc->dev.parent, false);
1445 +}
1446 +
1447 /**
1448 * rtc_timer_remove - Removes a rtc_timer from the rtc_device timerqueue
1449 * @rtc rtc device
1450 @@ -783,8 +791,10 @@ static void rtc_timer_remove(struct rtc_device *rtc, struct rtc_timer *timer)
1451 struct rtc_wkalrm alarm;
1452 int err;
1453 next = timerqueue_getnext(&rtc->timerqueue);
1454 - if (!next)
1455 + if (!next) {
1456 + rtc_alarm_disable(rtc);
1457 return;
1458 + }
1459 alarm.time = rtc_ktime_to_tm(next->expires);
1460 alarm.enabled = 1;
1461 err = __rtc_set_alarm(rtc, &alarm);
1462 @@ -846,7 +856,8 @@ again:
1463 err = __rtc_set_alarm(rtc, &alarm);
1464 if (err == -ETIME)
1465 goto again;
1466 - }
1467 + } else
1468 + rtc_alarm_disable(rtc);
1469
1470 mutex_unlock(&rtc->ops_lock);
1471 }
1472 diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c
1473 index 4b5421b..f7c3cfb 100644
1474 --- a/drivers/target/loopback/tcm_loop.c
1475 +++ b/drivers/target/loopback/tcm_loop.c
1476 @@ -905,6 +905,9 @@ static int tcm_loop_queue_data_in(struct se_cmd *se_cmd)
1477
1478 sc->result = SAM_STAT_GOOD;
1479 set_host_byte(sc, DID_OK);
1480 + if ((se_cmd->se_cmd_flags & SCF_OVERFLOW_BIT) ||
1481 + (se_cmd->se_cmd_flags & SCF_UNDERFLOW_BIT))
1482 + scsi_set_resid(sc, se_cmd->residual_count);
1483 sc->scsi_done(sc);
1484 return 0;
1485 }
1486 @@ -930,6 +933,9 @@ static int tcm_loop_queue_status(struct se_cmd *se_cmd)
1487 sc->result = se_cmd->scsi_status;
1488
1489 set_host_byte(sc, DID_OK);
1490 + if ((se_cmd->se_cmd_flags & SCF_OVERFLOW_BIT) ||
1491 + (se_cmd->se_cmd_flags & SCF_UNDERFLOW_BIT))
1492 + scsi_set_resid(sc, se_cmd->residual_count);
1493 sc->scsi_done(sc);
1494 return 0;
1495 }
1496 diff --git a/drivers/target/target_core_alua.c b/drivers/target/target_core_alua.c
1497 index 86b3660..c967405 100644
1498 --- a/drivers/target/target_core_alua.c
1499 +++ b/drivers/target/target_core_alua.c
1500 @@ -30,6 +30,7 @@
1501 #include <linux/configfs.h>
1502 #include <scsi/scsi.h>
1503 #include <scsi/scsi_cmnd.h>
1504 +#include <asm/unaligned.h>
1505
1506 #include <target/target_core_base.h>
1507 #include <target/target_core_device.h>
1508 @@ -238,8 +239,7 @@ int core_emulate_set_target_port_groups(struct se_cmd *cmd)
1509 * changed.
1510 */
1511 if (primary) {
1512 - tg_pt_id = ((ptr[2] << 8) & 0xff);
1513 - tg_pt_id |= (ptr[3] & 0xff);
1514 + tg_pt_id = get_unaligned_be16(ptr + 2);
1515 /*
1516 * Locate the matching target port group ID from
1517 * the global tg_pt_gp list
1518 @@ -280,8 +280,7 @@ int core_emulate_set_target_port_groups(struct se_cmd *cmd)
1519 * the Target Port in question for the the incoming
1520 * SET_TARGET_PORT_GROUPS op.
1521 */
1522 - rtpi = ((ptr[2] << 8) & 0xff);
1523 - rtpi |= (ptr[3] & 0xff);
1524 + rtpi = get_unaligned_be16(ptr + 2);
1525 /*
1526 * Locate the matching relative target port identifer
1527 * for the struct se_device storage object.
1528 diff --git a/drivers/target/target_core_cdb.c b/drivers/target/target_core_cdb.c
1529 index f044d45..0558401 100644
1530 --- a/drivers/target/target_core_cdb.c
1531 +++ b/drivers/target/target_core_cdb.c
1532 @@ -106,7 +106,7 @@ target_emulate_inquiry_std(struct se_cmd *cmd)
1533 return 0;
1534 }
1535
1536 - buf[7] = 0x32; /* Sync=1 and CmdQue=1 */
1537 + buf[7] = 0x2; /* CmdQue=1 */
1538
1539 /*
1540 * Do not include vendor, product, reversion info in INQUIRY
1541 diff --git a/drivers/target/tcm_fc/tfc_cmd.c b/drivers/target/tcm_fc/tfc_cmd.c
1542 index b2a1067..3c3fa84 100644
1543 --- a/drivers/target/tcm_fc/tfc_cmd.c
1544 +++ b/drivers/target/tcm_fc/tfc_cmd.c
1545 @@ -371,10 +371,12 @@ static void ft_send_resp_status(struct fc_lport *lport,
1546
1547 fc_fill_reply_hdr(fp, rx_fp, FC_RCTL_DD_CMD_STATUS, 0);
1548 sp = fr_seq(fp);
1549 - if (sp)
1550 + if (sp) {
1551 lport->tt.seq_send(lport, sp, fp);
1552 - else
1553 + lport->tt.exch_done(sp);
1554 + } else {
1555 lport->tt.frame_send(lport, fp);
1556 + }
1557 }
1558
1559 /*
1560 diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
1561 index ba679ce..8f82f7a 100644
1562 --- a/drivers/tty/moxa.c
1563 +++ b/drivers/tty/moxa.c
1564 @@ -1330,7 +1330,7 @@ static void moxa_start(struct tty_struct *tty)
1565 if (ch == NULL)
1566 return;
1567
1568 - if (!(ch->statusflags & TXSTOPPED))
1569 + if (!test_bit(TXSTOPPED, &ch->statusflags))
1570 return;
1571
1572 MoxaPortTxEnable(ch);
1573 diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
1574 index ebd8629..bead17e 100644
1575 --- a/drivers/tty/serial/sh-sci.c
1576 +++ b/drivers/tty/serial/sh-sci.c
1577 @@ -953,17 +953,20 @@ static void sci_dma_tx_complete(void *arg)
1578 port->icount.tx += sg_dma_len(&s->sg_tx);
1579
1580 async_tx_ack(s->desc_tx);
1581 - s->cookie_tx = -EINVAL;
1582 s->desc_tx = NULL;
1583
1584 if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
1585 uart_write_wakeup(port);
1586
1587 if (!uart_circ_empty(xmit)) {
1588 + s->cookie_tx = 0;
1589 schedule_work(&s->work_tx);
1590 - } else if (port->type == PORT_SCIFA || port->type == PORT_SCIFB) {
1591 - u16 ctrl = sci_in(port, SCSCR);
1592 - sci_out(port, SCSCR, ctrl & ~SCSCR_TIE);
1593 + } else {
1594 + s->cookie_tx = -EINVAL;
1595 + if (port->type == PORT_SCIFA || port->type == PORT_SCIFB) {
1596 + u16 ctrl = sci_in(port, SCSCR);
1597 + sci_out(port, SCSCR, ctrl & ~SCSCR_TIE);
1598 + }
1599 }
1600
1601 spin_unlock_irqrestore(&port->lock, flags);
1602 @@ -1225,8 +1228,10 @@ static void sci_start_tx(struct uart_port *port)
1603 }
1604
1605 if (s->chan_tx && !uart_circ_empty(&s->port.state->xmit) &&
1606 - s->cookie_tx < 0)
1607 + s->cookie_tx < 0) {
1608 + s->cookie_tx = 0;
1609 schedule_work(&s->work_tx);
1610 + }
1611 #endif
1612
1613 if (!s->chan_tx || port->type == PORT_SCIFA || port->type == PORT_SCIFB) {
1614 diff --git a/drivers/tty/vt/consolemap.c b/drivers/tty/vt/consolemap.c
1615 index 45d3e80..f343808 100644
1616 --- a/drivers/tty/vt/consolemap.c
1617 +++ b/drivers/tty/vt/consolemap.c
1618 @@ -516,6 +516,7 @@ int con_set_unimap(struct vc_data *vc, ushort ct, struct unipair __user *list)
1619 int err = 0, err1, i;
1620 struct uni_pagedir *p, *q;
1621
1622 + /* Save original vc_unipagdir_loc in case we allocate a new one */
1623 p = (struct uni_pagedir *)*vc->vc_uni_pagedir_loc;
1624 if (p->readonly) return -EIO;
1625
1626 @@ -528,26 +529,57 @@ int con_set_unimap(struct vc_data *vc, ushort ct, struct unipair __user *list)
1627 err1 = con_clear_unimap(vc, NULL);
1628 if (err1) return err1;
1629
1630 + /*
1631 + * Since refcount was > 1, con_clear_unimap() allocated a
1632 + * a new uni_pagedir for this vc. Re: p != q
1633 + */
1634 q = (struct uni_pagedir *)*vc->vc_uni_pagedir_loc;
1635 - for (i = 0, l = 0; i < 32; i++)
1636 +
1637 + /*
1638 + * uni_pgdir is a 32*32*64 table with rows allocated
1639 + * when its first entry is added. The unicode value must
1640 + * still be incremented for empty rows. We are copying
1641 + * entries from "p" (old) to "q" (new).
1642 + */
1643 + l = 0; /* unicode value */
1644 + for (i = 0; i < 32; i++)
1645 if ((p1 = p->uni_pgdir[i]))
1646 for (j = 0; j < 32; j++)
1647 - if ((p2 = p1[j]))
1648 + if ((p2 = p1[j])) {
1649 for (k = 0; k < 64; k++, l++)
1650 if (p2[k] != 0xffff) {
1651 + /*
1652 + * Found one, copy entry for unicode
1653 + * l with fontpos value p2[k].
1654 + */
1655 err1 = con_insert_unipair(q, l, p2[k]);
1656 if (err1) {
1657 p->refcount++;
1658 *vc->vc_uni_pagedir_loc = (unsigned long)p;
1659 con_release_unimap(q);
1660 kfree(q);
1661 - return err1;
1662 + return err1;
1663 }
1664 - }
1665 - p = q;
1666 - } else if (p == dflt)
1667 + }
1668 + } else {
1669 + /* Account for row of 64 empty entries */
1670 + l += 64;
1671 + }
1672 + else
1673 + /* Account for empty table */
1674 + l += 32 * 64;
1675 +
1676 + /*
1677 + * Finished copying font table, set vc_uni_pagedir to new table
1678 + */
1679 + p = q;
1680 + } else if (p == dflt) {
1681 dflt = NULL;
1682 -
1683 + }
1684 +
1685 + /*
1686 + * Insert user specified unicode pairs into new table.
1687 + */
1688 while (ct--) {
1689 unsigned short unicode, fontpos;
1690 __get_user(unicode, &list->unicode);
1691 @@ -557,11 +589,14 @@ int con_set_unimap(struct vc_data *vc, ushort ct, struct unipair __user *list)
1692 list++;
1693 }
1694
1695 + /*
1696 + * Merge with fontmaps of any other virtual consoles.
1697 + */
1698 if (con_unify_unimap(vc, p))
1699 return err;
1700
1701 for (i = 0; i <= 3; i++)
1702 - set_inverse_transl(vc, p, i); /* Update all inverse translations */
1703 + set_inverse_transl(vc, p, i); /* Update inverse translations */
1704 set_inverse_trans_unicode(vc, p);
1705
1706 return err;
1707 diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c
1708 index 90581a8..76f0613 100644
1709 --- a/drivers/usb/class/cdc-wdm.c
1710 +++ b/drivers/usb/class/cdc-wdm.c
1711 @@ -397,7 +397,7 @@ outnl:
1712 static ssize_t wdm_read
1713 (struct file *file, char __user *buffer, size_t count, loff_t *ppos)
1714 {
1715 - int rv, cntr = 0;
1716 + int rv, cntr;
1717 int i = 0;
1718 struct wdm_device *desc = file->private_data;
1719
1720 @@ -406,7 +406,8 @@ static ssize_t wdm_read
1721 if (rv < 0)
1722 return -ERESTARTSYS;
1723
1724 - if (desc->length == 0) {
1725 + cntr = ACCESS_ONCE(desc->length);
1726 + if (cntr == 0) {
1727 desc->read = 0;
1728 retry:
1729 if (test_bit(WDM_DISCONNECTING, &desc->flags)) {
1730 @@ -456,26 +457,30 @@ retry:
1731 spin_unlock_irq(&desc->iuspin);
1732 goto retry;
1733 }
1734 - clear_bit(WDM_READ, &desc->flags);
1735 + cntr = desc->length;
1736 spin_unlock_irq(&desc->iuspin);
1737 }
1738
1739 - cntr = count > desc->length ? desc->length : count;
1740 + if (cntr > count)
1741 + cntr = count;
1742 rv = copy_to_user(buffer, desc->ubuf, cntr);
1743 if (rv > 0) {
1744 rv = -EFAULT;
1745 goto err;
1746 }
1747
1748 + spin_lock_irq(&desc->iuspin);
1749 +
1750 for (i = 0; i < desc->length - cntr; i++)
1751 desc->ubuf[i] = desc->ubuf[i + cntr];
1752
1753 - spin_lock_irq(&desc->iuspin);
1754 desc->length -= cntr;
1755 - spin_unlock_irq(&desc->iuspin);
1756 /* in case we had outstanding data */
1757 if (!desc->length)
1758 clear_bit(WDM_READ, &desc->flags);
1759 +
1760 + spin_unlock_irq(&desc->iuspin);
1761 +
1762 rv = cntr;
1763
1764 err:
1765 diff --git a/drivers/usb/gadget/fsl_udc_core.c b/drivers/usb/gadget/fsl_udc_core.c
1766 index 4e48331..5308381 100644
1767 --- a/drivers/usb/gadget/fsl_udc_core.c
1768 +++ b/drivers/usb/gadget/fsl_udc_core.c
1769 @@ -767,7 +767,7 @@ out:
1770 * @is_last: return flag if it is the last dTD of the request
1771 * return: pointer to the built dTD */
1772 static struct ep_td_struct *fsl_build_dtd(struct fsl_req *req, unsigned *length,
1773 - dma_addr_t *dma, int *is_last)
1774 + dma_addr_t *dma, int *is_last, gfp_t gfp_flags)
1775 {
1776 u32 swap_temp;
1777 struct ep_td_struct *dtd;
1778 @@ -776,7 +776,7 @@ static struct ep_td_struct *fsl_build_dtd(struct fsl_req *req, unsigned *length,
1779 *length = min(req->req.length - req->req.actual,
1780 (unsigned)EP_MAX_LENGTH_TRANSFER);
1781
1782 - dtd = dma_pool_alloc(udc_controller->td_pool, GFP_KERNEL, dma);
1783 + dtd = dma_pool_alloc(udc_controller->td_pool, gfp_flags, dma);
1784 if (dtd == NULL)
1785 return dtd;
1786
1787 @@ -826,7 +826,7 @@ static struct ep_td_struct *fsl_build_dtd(struct fsl_req *req, unsigned *length,
1788 }
1789
1790 /* Generate dtd chain for a request */
1791 -static int fsl_req_to_dtd(struct fsl_req *req)
1792 +static int fsl_req_to_dtd(struct fsl_req *req, gfp_t gfp_flags)
1793 {
1794 unsigned count;
1795 int is_last;
1796 @@ -835,7 +835,7 @@ static int fsl_req_to_dtd(struct fsl_req *req)
1797 dma_addr_t dma;
1798
1799 do {
1800 - dtd = fsl_build_dtd(req, &count, &dma, &is_last);
1801 + dtd = fsl_build_dtd(req, &count, &dma, &is_last, gfp_flags);
1802 if (dtd == NULL)
1803 return -ENOMEM;
1804
1805 @@ -909,13 +909,11 @@ fsl_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags)
1806 req->req.actual = 0;
1807 req->dtd_count = 0;
1808
1809 - spin_lock_irqsave(&udc->lock, flags);
1810 -
1811 /* build dtds and push them to device queue */
1812 - if (!fsl_req_to_dtd(req)) {
1813 + if (!fsl_req_to_dtd(req, gfp_flags)) {
1814 + spin_lock_irqsave(&udc->lock, flags);
1815 fsl_queue_td(ep, req);
1816 } else {
1817 - spin_unlock_irqrestore(&udc->lock, flags);
1818 return -ENOMEM;
1819 }
1820
1821 @@ -1294,7 +1292,7 @@ static int ep0_prime_status(struct fsl_udc *udc, int direction)
1822 ep_is_in(ep) ? DMA_TO_DEVICE : DMA_FROM_DEVICE);
1823 req->mapped = 1;
1824
1825 - if (fsl_req_to_dtd(req) == 0)
1826 + if (fsl_req_to_dtd(req, GFP_ATOMIC) == 0)
1827 fsl_queue_td(ep, req);
1828 else
1829 return -ENOMEM;
1830 @@ -1378,7 +1376,7 @@ static void ch9getstatus(struct fsl_udc *udc, u8 request_type, u16 value,
1831 req->mapped = 1;
1832
1833 /* prime the data phase */
1834 - if ((fsl_req_to_dtd(req) == 0))
1835 + if ((fsl_req_to_dtd(req, GFP_ATOMIC) == 0))
1836 fsl_queue_td(ep, req);
1837 else /* no mem */
1838 goto stall;
1839 diff --git a/drivers/usb/gadget/hid.c b/drivers/usb/gadget/hid.c
1840 index 2523e54..79afa82 100644
1841 --- a/drivers/usb/gadget/hid.c
1842 +++ b/drivers/usb/gadget/hid.c
1843 @@ -69,9 +69,9 @@ static struct usb_device_descriptor device_desc = {
1844 /* .bDeviceClass = USB_CLASS_COMM, */
1845 /* .bDeviceSubClass = 0, */
1846 /* .bDeviceProtocol = 0, */
1847 - .bDeviceClass = 0xEF,
1848 - .bDeviceSubClass = 2,
1849 - .bDeviceProtocol = 1,
1850 + .bDeviceClass = USB_CLASS_PER_INTERFACE,
1851 + .bDeviceSubClass = 0,
1852 + .bDeviceProtocol = 0,
1853 /* .bMaxPacketSize0 = f(hardware) */
1854
1855 /* Vendor and product id can be overridden by module parameters. */
1856 diff --git a/drivers/usb/gadget/inode.c b/drivers/usb/gadget/inode.c
1857 index a56876a..febadaa 100644
1858 --- a/drivers/usb/gadget/inode.c
1859 +++ b/drivers/usb/gadget/inode.c
1860 @@ -1050,6 +1050,8 @@ ep0_read (struct file *fd, char __user *buf, size_t len, loff_t *ptr)
1861 // FIXME don't call this with the spinlock held ...
1862 if (copy_to_user (buf, dev->req->buf, len))
1863 retval = -EFAULT;
1864 + else
1865 + retval = len;
1866 clean_req (dev->gadget->ep0, dev->req);
1867 /* NOTE userspace can't yet choose to stall */
1868 }
1869 diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
1870 index bc7f166..fc93d57 100644
1871 --- a/drivers/usb/host/ehci-fsl.c
1872 +++ b/drivers/usb/host/ehci-fsl.c
1873 @@ -216,6 +216,8 @@ static void ehci_fsl_setup_phy(struct ehci_hcd *ehci,
1874 unsigned int port_offset)
1875 {
1876 u32 portsc;
1877 + struct usb_hcd *hcd = ehci_to_hcd(ehci);
1878 + void __iomem *non_ehci = hcd->regs;
1879
1880 portsc = ehci_readl(ehci, &ehci->regs->port_status[port_offset]);
1881 portsc &= ~(PORT_PTS_MSK | PORT_PTS_PTW);
1882 @@ -231,6 +233,8 @@ static void ehci_fsl_setup_phy(struct ehci_hcd *ehci,
1883 portsc |= PORT_PTS_PTW;
1884 /* fall through */
1885 case FSL_USB2_PHY_UTMI:
1886 + /* enable UTMI PHY */
1887 + setbits32(non_ehci + FSL_SOC_USB_CTRL, CTRL_UTMI_PHY_EN);
1888 portsc |= PORT_PTS_UTMI;
1889 break;
1890 case FSL_USB2_PHY_NONE:
1891 diff --git a/drivers/usb/host/ehci-fsl.h b/drivers/usb/host/ehci-fsl.h
1892 index 4918062..bea5013 100644
1893 --- a/drivers/usb/host/ehci-fsl.h
1894 +++ b/drivers/usb/host/ehci-fsl.h
1895 @@ -45,5 +45,6 @@
1896 #define FSL_SOC_USB_PRICTRL 0x40c /* NOTE: big-endian */
1897 #define FSL_SOC_USB_SICTRL 0x410 /* NOTE: big-endian */
1898 #define FSL_SOC_USB_CTRL 0x500 /* NOTE: big-endian */
1899 +#define CTRL_UTMI_PHY_EN (1<<9)
1900 #define SNOOP_SIZE_2GB 0x1e
1901 #endif /* _EHCI_FSL_H */
1902 diff --git a/drivers/usb/host/fsl-mph-dr-of.c b/drivers/usb/host/fsl-mph-dr-of.c
1903 index 79a66d6..8388771 100644
1904 --- a/drivers/usb/host/fsl-mph-dr-of.c
1905 +++ b/drivers/usb/host/fsl-mph-dr-of.c
1906 @@ -93,7 +93,6 @@ struct platform_device * __devinit fsl_usb2_device_register(
1907 pdev->dev.parent = &ofdev->dev;
1908
1909 pdev->dev.coherent_dma_mask = ofdev->dev.coherent_dma_mask;
1910 - pdev->dev.dma_mask = &pdev->archdata.dma_mask;
1911 *pdev->dev.dma_mask = *ofdev->dev.dma_mask;
1912
1913 retval = platform_device_add_data(pdev, pdata, sizeof(*pdata));
1914 diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
1915 index 548338c..99ceaef 100644
1916 --- a/drivers/usb/musb/musb_gadget.c
1917 +++ b/drivers/usb/musb/musb_gadget.c
1918 @@ -576,6 +576,15 @@ void musb_g_tx(struct musb *musb, u8 epnum)
1919
1920 if (request->actual == request->length) {
1921 musb_g_giveback(musb_ep, request, 0);
1922 + /*
1923 + * In the giveback function the MUSB lock is
1924 + * released and acquired after sometime. During
1925 + * this time period the INDEX register could get
1926 + * changed by the gadget_queue function especially
1927 + * on SMP systems. Reselect the INDEX to be sure
1928 + * we are reading/modifying the right registers
1929 + */
1930 + musb_ep_select(mbase, epnum);
1931 req = musb_ep->desc ? next_request(musb_ep) : NULL;
1932 if (!req) {
1933 dev_dbg(musb->controller, "%s idle now\n",
1934 @@ -968,6 +977,15 @@ void musb_g_rx(struct musb *musb, u8 epnum)
1935 }
1936 #endif
1937 musb_g_giveback(musb_ep, request, 0);
1938 + /*
1939 + * In the giveback function the MUSB lock is
1940 + * released and acquired after sometime. During
1941 + * this time period the INDEX register could get
1942 + * changed by the gadget_queue function especially
1943 + * on SMP systems. Reselect the INDEX to be sure
1944 + * we are reading/modifying the right registers
1945 + */
1946 + musb_ep_select(mbase, epnum);
1947
1948 req = next_request(musb_ep);
1949 if (!req)
1950 diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
1951 index 33d25d4..4c12404 100644
1952 --- a/drivers/usb/serial/cp210x.c
1953 +++ b/drivers/usb/serial/cp210x.c
1954 @@ -49,6 +49,7 @@ static int cp210x_tiocmset_port(struct usb_serial_port *port,
1955 unsigned int, unsigned int);
1956 static void cp210x_break_ctl(struct tty_struct *, int);
1957 static int cp210x_startup(struct usb_serial *);
1958 +static void cp210x_release(struct usb_serial *);
1959 static void cp210x_dtr_rts(struct usb_serial_port *p, int on);
1960
1961 static int debug;
1962 @@ -121,6 +122,8 @@ static const struct usb_device_id id_table[] = {
1963 { USB_DEVICE(0x10C4, 0x8665) }, /* AC-Services OBD-IF */
1964 { USB_DEVICE(0x10C4, 0xEA60) }, /* Silicon Labs factory default */
1965 { USB_DEVICE(0x10C4, 0xEA61) }, /* Silicon Labs factory default */
1966 + { USB_DEVICE(0x10C4, 0xEA70) }, /* Silicon Labs factory default */
1967 + { USB_DEVICE(0x10C4, 0xEA80) }, /* Silicon Labs factory default */
1968 { USB_DEVICE(0x10C4, 0xEA71) }, /* Infinity GPS-MIC-1 Radio Monophone */
1969 { USB_DEVICE(0x10C4, 0xF001) }, /* Elan Digital Systems USBscope50 */
1970 { USB_DEVICE(0x10C4, 0xF002) }, /* Elan Digital Systems USBwave12 */
1971 @@ -149,6 +152,10 @@ static const struct usb_device_id id_table[] = {
1972
1973 MODULE_DEVICE_TABLE(usb, id_table);
1974
1975 +struct cp210x_port_private {
1976 + __u8 bInterfaceNumber;
1977 +};
1978 +
1979 static struct usb_driver cp210x_driver = {
1980 .name = "cp210x",
1981 .probe = usb_serial_probe,
1982 @@ -174,6 +181,7 @@ static struct usb_serial_driver cp210x_device = {
1983 .tiocmget = cp210x_tiocmget,
1984 .tiocmset = cp210x_tiocmset,
1985 .attach = cp210x_startup,
1986 + .release = cp210x_release,
1987 .dtr_rts = cp210x_dtr_rts
1988 };
1989
1990 @@ -261,6 +269,7 @@ static int cp210x_get_config(struct usb_serial_port *port, u8 request,
1991 unsigned int *data, int size)
1992 {
1993 struct usb_serial *serial = port->serial;
1994 + struct cp210x_port_private *port_priv = usb_get_serial_port_data(port);
1995 __le32 *buf;
1996 int result, i, length;
1997
1998 @@ -276,7 +285,7 @@ static int cp210x_get_config(struct usb_serial_port *port, u8 request,
1999 /* Issue the request, attempting to read 'size' bytes */
2000 result = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0),
2001 request, REQTYPE_DEVICE_TO_HOST, 0x0000,
2002 - 0, buf, size, 300);
2003 + port_priv->bInterfaceNumber, buf, size, 300);
2004
2005 /* Convert data into an array of integers */
2006 for (i = 0; i < length; i++)
2007 @@ -304,6 +313,7 @@ static int cp210x_set_config(struct usb_serial_port *port, u8 request,
2008 unsigned int *data, int size)
2009 {
2010 struct usb_serial *serial = port->serial;
2011 + struct cp210x_port_private *port_priv = usb_get_serial_port_data(port);
2012 __le32 *buf;
2013 int result, i, length;
2014
2015 @@ -325,12 +335,12 @@ static int cp210x_set_config(struct usb_serial_port *port, u8 request,
2016 result = usb_control_msg(serial->dev,
2017 usb_sndctrlpipe(serial->dev, 0),
2018 request, REQTYPE_HOST_TO_DEVICE, 0x0000,
2019 - 0, buf, size, 300);
2020 + port_priv->bInterfaceNumber, buf, size, 300);
2021 } else {
2022 result = usb_control_msg(serial->dev,
2023 usb_sndctrlpipe(serial->dev, 0),
2024 request, REQTYPE_HOST_TO_DEVICE, data[0],
2025 - 0, NULL, 0, 300);
2026 + port_priv->bInterfaceNumber, NULL, 0, 300);
2027 }
2028
2029 kfree(buf);
2030 @@ -830,11 +840,39 @@ static void cp210x_break_ctl (struct tty_struct *tty, int break_state)
2031
2032 static int cp210x_startup(struct usb_serial *serial)
2033 {
2034 + struct cp210x_port_private *port_priv;
2035 + int i;
2036 +
2037 /* cp210x buffers behave strangely unless device is reset */
2038 usb_reset_device(serial->dev);
2039 +
2040 + for (i = 0; i < serial->num_ports; i++) {
2041 + port_priv = kzalloc(sizeof(*port_priv), GFP_KERNEL);
2042 + if (!port_priv)
2043 + return -ENOMEM;
2044 +
2045 + memset(port_priv, 0x00, sizeof(*port_priv));
2046 + port_priv->bInterfaceNumber =
2047 + serial->interface->cur_altsetting->desc.bInterfaceNumber;
2048 +
2049 + usb_set_serial_port_data(serial->port[i], port_priv);
2050 + }
2051 +
2052 return 0;
2053 }
2054
2055 +static void cp210x_release(struct usb_serial *serial)
2056 +{
2057 + struct cp210x_port_private *port_priv;
2058 + int i;
2059 +
2060 + for (i = 0; i < serial->num_ports; i++) {
2061 + port_priv = usb_get_serial_port_data(serial->port[i]);
2062 + kfree(port_priv);
2063 + usb_set_serial_port_data(serial->port[i], NULL);
2064 + }
2065 +}
2066 +
2067 static int __init cp210x_init(void)
2068 {
2069 int retval;
2070 diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
2071 index 78c7d42..60d7b1eb 100644
2072 --- a/drivers/usb/serial/ftdi_sio.c
2073 +++ b/drivers/usb/serial/ftdi_sio.c
2074 @@ -187,6 +187,7 @@ static struct usb_device_id id_table_combined [] = {
2075 .driver_info = (kernel_ulong_t)&ftdi_8u2232c_quirk },
2076 { USB_DEVICE(FTDI_VID, FTDI_4232H_PID) },
2077 { USB_DEVICE(FTDI_VID, FTDI_232H_PID) },
2078 + { USB_DEVICE(FTDI_VID, FTDI_FTX_PID) },
2079 { USB_DEVICE(FTDI_VID, FTDI_MICRO_CHAMELEON_PID) },
2080 { USB_DEVICE(FTDI_VID, FTDI_RELAIS_PID) },
2081 { USB_DEVICE(FTDI_VID, FTDI_OPENDCC_PID) },
2082 @@ -535,6 +536,10 @@ static struct usb_device_id id_table_combined [] = {
2083 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2803_6_PID) },
2084 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2803_7_PID) },
2085 { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2803_8_PID) },
2086 + { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2803R_1_PID) },
2087 + { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2803R_2_PID) },
2088 + { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2803R_3_PID) },
2089 + { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2803R_4_PID) },
2090 { USB_DEVICE(IDTECH_VID, IDTECH_IDT1221U_PID) },
2091 { USB_DEVICE(OCT_VID, OCT_US101_PID) },
2092 { USB_DEVICE(OCT_VID, OCT_DK201_PID) },
2093 @@ -796,7 +801,7 @@ static struct usb_device_id id_table_combined [] = {
2094 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
2095 { USB_DEVICE(ADI_VID, ADI_GNICEPLUS_PID),
2096 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
2097 - { USB_DEVICE(HORNBY_VID, HORNBY_ELITE_PID) },
2098 + { USB_DEVICE(MICROCHIP_VID, MICROCHIP_USB_BOARD_PID) },
2099 { USB_DEVICE(JETI_VID, JETI_SPC1201_PID) },
2100 { USB_DEVICE(MARVELL_VID, MARVELL_SHEEVAPLUG_PID),
2101 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
2102 @@ -845,6 +850,9 @@ static struct usb_device_id id_table_combined [] = {
2103 { USB_DEVICE(ST_VID, ST_STMCLT1030_PID),
2104 .driver_info = (kernel_ulong_t)&ftdi_stmclite_quirk },
2105 { USB_DEVICE(FTDI_VID, FTDI_RF_R106) },
2106 + { USB_DEVICE(FTDI_VID, FTDI_DISTORTEC_JTAG_LOCK_PICK_PID),
2107 + .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
2108 + { USB_DEVICE(FTDI_VID, FTDI_LUMEL_PD12_PID) },
2109 { }, /* Optional parameter entry */
2110 { } /* Terminating entry */
2111 };
2112 @@ -867,7 +875,8 @@ static const char *ftdi_chip_name[] = {
2113 [FT232RL] = "FT232RL",
2114 [FT2232H] = "FT2232H",
2115 [FT4232H] = "FT4232H",
2116 - [FT232H] = "FT232H"
2117 + [FT232H] = "FT232H",
2118 + [FTX] = "FT-X"
2119 };
2120
2121
2122 @@ -1165,7 +1174,8 @@ static __u32 get_ftdi_divisor(struct tty_struct *tty,
2123 break;
2124 case FT232BM: /* FT232BM chip */
2125 case FT2232C: /* FT2232C chip */
2126 - case FT232RL:
2127 + case FT232RL: /* FT232RL chip */
2128 + case FTX: /* FT-X series */
2129 if (baud <= 3000000) {
2130 __u16 product_id = le16_to_cpu(
2131 port->serial->dev->descriptor.idProduct);
2132 @@ -1451,10 +1461,14 @@ static void ftdi_determine_type(struct usb_serial_port *port)
2133 } else if (version < 0x900) {
2134 /* Assume it's an FT232RL */
2135 priv->chip_type = FT232RL;
2136 - } else {
2137 + } else if (version < 0x1000) {
2138 /* Assume it's an FT232H */
2139 priv->chip_type = FT232H;
2140 + } else {
2141 + /* Assume it's an FT-X series device */
2142 + priv->chip_type = FTX;
2143 }
2144 +
2145 dev_info(&udev->dev, "Detected %s\n", ftdi_chip_name[priv->chip_type]);
2146 }
2147
2148 @@ -1582,7 +1596,8 @@ static int create_sysfs_attrs(struct usb_serial_port *port)
2149 priv->chip_type == FT232RL ||
2150 priv->chip_type == FT2232H ||
2151 priv->chip_type == FT4232H ||
2152 - priv->chip_type == FT232H)) {
2153 + priv->chip_type == FT232H ||
2154 + priv->chip_type == FTX)) {
2155 retval = device_create_file(&port->dev,
2156 &dev_attr_latency_timer);
2157 }
2158 @@ -1604,7 +1619,8 @@ static void remove_sysfs_attrs(struct usb_serial_port *port)
2159 priv->chip_type == FT232RL ||
2160 priv->chip_type == FT2232H ||
2161 priv->chip_type == FT4232H ||
2162 - priv->chip_type == FT232H) {
2163 + priv->chip_type == FT232H ||
2164 + priv->chip_type == FTX) {
2165 device_remove_file(&port->dev, &dev_attr_latency_timer);
2166 }
2167 }
2168 @@ -1755,7 +1771,8 @@ static int ftdi_8u2232c_probe(struct usb_serial *serial)
2169
2170 dbg("%s", __func__);
2171
2172 - if (strcmp(udev->manufacturer, "CALAO Systems") == 0)
2173 + if ((udev->manufacturer && !strcmp(udev->manufacturer, "CALAO Systems")) ||
2174 + (udev->product && !strcmp(udev->product, "BeagleBone/XDS100")))
2175 return ftdi_jtag_probe(serial);
2176
2177 return 0;
2178 @@ -2260,6 +2277,7 @@ static int ftdi_tiocmget(struct tty_struct *tty)
2179 case FT2232H:
2180 case FT4232H:
2181 case FT232H:
2182 + case FTX:
2183 len = 2;
2184 break;
2185 default:
2186 diff --git a/drivers/usb/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h
2187 index 19584fa..ed58c6f 100644
2188 --- a/drivers/usb/serial/ftdi_sio.h
2189 +++ b/drivers/usb/serial/ftdi_sio.h
2190 @@ -157,7 +157,8 @@ enum ftdi_chip_type {
2191 FT232RL = 5,
2192 FT2232H = 6,
2193 FT4232H = 7,
2194 - FT232H = 8
2195 + FT232H = 8,
2196 + FTX = 9,
2197 };
2198
2199 enum ftdi_sio_baudrate {
2200 diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h
2201 index 4eb7715..c6dd18e 100644
2202 --- a/drivers/usb/serial/ftdi_sio_ids.h
2203 +++ b/drivers/usb/serial/ftdi_sio_ids.h
2204 @@ -23,12 +23,15 @@
2205 #define FTDI_8U2232C_PID 0x6010 /* Dual channel device */
2206 #define FTDI_4232H_PID 0x6011 /* Quad channel hi-speed device */
2207 #define FTDI_232H_PID 0x6014 /* Single channel hi-speed device */
2208 +#define FTDI_FTX_PID 0x6015 /* FT-X series (FT201X, FT230X, FT231X, etc) */
2209 #define FTDI_SIO_PID 0x8372 /* Product Id SIO application of 8U100AX */
2210 #define FTDI_232RL_PID 0xFBFA /* Product ID for FT232RL */
2211
2212
2213 /*** third-party PIDs (using FTDI_VID) ***/
2214
2215 +#define FTDI_LUMEL_PD12_PID 0x6002
2216 +
2217 /*
2218 * Marvell OpenRD Base, Client
2219 * http://www.open-rd.org
2220 @@ -97,6 +100,8 @@
2221 #define FTDI_TACTRIX_OPENPORT_13S_PID 0xCC49 /* OpenPort 1.3 Subaru */
2222 #define FTDI_TACTRIX_OPENPORT_13U_PID 0xCC4A /* OpenPort 1.3 Universal */
2223
2224 +#define FTDI_DISTORTEC_JTAG_LOCK_PICK_PID 0xCFF8
2225 +
2226 /* SCS HF Radio Modems PID's (http://www.scs-ptc.com) */
2227 /* the VID is the standard ftdi vid (FTDI_VID) */
2228 #define FTDI_SCS_DEVICE_0_PID 0xD010 /* SCS PTC-IIusb */
2229 @@ -532,10 +537,14 @@
2230 #define ADI_GNICEPLUS_PID 0xF001
2231
2232 /*
2233 - * Hornby Elite
2234 + * Microchip Technology, Inc.
2235 + *
2236 + * MICROCHIP_VID (0x04D8) and MICROCHIP_USB_BOARD_PID (0x000A) are also used by:
2237 + * Hornby Elite - Digital Command Control Console
2238 + * http://www.hornby.com/hornby-dcc/controllers/
2239 */
2240 -#define HORNBY_VID 0x04D8
2241 -#define HORNBY_ELITE_PID 0x000A
2242 +#define MICROCHIP_VID 0x04D8
2243 +#define MICROCHIP_USB_BOARD_PID 0x000A /* CDC RS-232 Emulation Demo */
2244
2245 /*
2246 * RATOC REX-USB60F
2247 @@ -680,6 +689,10 @@
2248 #define SEALEVEL_2803_6_PID 0X2863 /* SeaLINK+8 (2803) Port 6 */
2249 #define SEALEVEL_2803_7_PID 0X2873 /* SeaLINK+8 (2803) Port 7 */
2250 #define SEALEVEL_2803_8_PID 0X2883 /* SeaLINK+8 (2803) Port 8 */
2251 +#define SEALEVEL_2803R_1_PID 0Xa02a /* SeaLINK+8 (2803-ROHS) Port 1+2 */
2252 +#define SEALEVEL_2803R_2_PID 0Xa02b /* SeaLINK+8 (2803-ROHS) Port 3+4 */
2253 +#define SEALEVEL_2803R_3_PID 0Xa02c /* SeaLINK+8 (2803-ROHS) Port 5+6 */
2254 +#define SEALEVEL_2803R_4_PID 0Xa02d /* SeaLINK+8 (2803-ROHS) Port 7+8 */
2255
2256 /*
2257 * JETI SPECTROMETER SPECBOS 1201
2258 diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c
2259 index e4db5ad..9f0b2bf 100644
2260 --- a/drivers/usb/serial/generic.c
2261 +++ b/drivers/usb/serial/generic.c
2262 @@ -215,8 +215,10 @@ retry:
2263 clear_bit(i, &port->write_urbs_free);
2264 result = usb_submit_urb(urb, GFP_ATOMIC);
2265 if (result) {
2266 - dev_err(&port->dev, "%s - error submitting urb: %d\n",
2267 + if (!port->port.console) {
2268 + dev_err(&port->dev, "%s - error submitting urb: %d\n",
2269 __func__, result);
2270 + }
2271 set_bit(i, &port->write_urbs_free);
2272 spin_lock_irqsave(&port->lock, flags);
2273 port->tx_bytes -= count;
2274 diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
2275 index 7b50aa1..3257519 100644
2276 --- a/drivers/usb/serial/mos7840.c
2277 +++ b/drivers/usb/serial/mos7840.c
2278 @@ -174,6 +174,7 @@
2279
2280 #define CLK_MULTI_REGISTER ((__u16)(0x02))
2281 #define CLK_START_VALUE_REGISTER ((__u16)(0x03))
2282 +#define GPIO_REGISTER ((__u16)(0x07))
2283
2284 #define SERIAL_LCR_DLAB ((__u16)(0x0080))
2285
2286 @@ -1103,14 +1104,25 @@ static int mos7840_open(struct tty_struct *tty, struct usb_serial_port *port)
2287 mos7840_port->read_urb = port->read_urb;
2288
2289 /* set up our bulk in urb */
2290 -
2291 - usb_fill_bulk_urb(mos7840_port->read_urb,
2292 - serial->dev,
2293 - usb_rcvbulkpipe(serial->dev,
2294 - port->bulk_in_endpointAddress),
2295 - port->bulk_in_buffer,
2296 - mos7840_port->read_urb->transfer_buffer_length,
2297 - mos7840_bulk_in_callback, mos7840_port);
2298 + if ((serial->num_ports == 2)
2299 + && ((((__u16)port->number -
2300 + (__u16)(port->serial->minor)) % 2) != 0)) {
2301 + usb_fill_bulk_urb(mos7840_port->read_urb,
2302 + serial->dev,
2303 + usb_rcvbulkpipe(serial->dev,
2304 + (port->bulk_in_endpointAddress) + 2),
2305 + port->bulk_in_buffer,
2306 + mos7840_port->read_urb->transfer_buffer_length,
2307 + mos7840_bulk_in_callback, mos7840_port);
2308 + } else {
2309 + usb_fill_bulk_urb(mos7840_port->read_urb,
2310 + serial->dev,
2311 + usb_rcvbulkpipe(serial->dev,
2312 + port->bulk_in_endpointAddress),
2313 + port->bulk_in_buffer,
2314 + mos7840_port->read_urb->transfer_buffer_length,
2315 + mos7840_bulk_in_callback, mos7840_port);
2316 + }
2317
2318 dbg("mos7840_open: bulkin endpoint is %d",
2319 port->bulk_in_endpointAddress);
2320 @@ -1521,13 +1533,25 @@ static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port,
2321 memcpy(urb->transfer_buffer, current_position, transfer_size);
2322
2323 /* fill urb with data and submit */
2324 - usb_fill_bulk_urb(urb,
2325 - serial->dev,
2326 - usb_sndbulkpipe(serial->dev,
2327 - port->bulk_out_endpointAddress),
2328 - urb->transfer_buffer,
2329 - transfer_size,
2330 - mos7840_bulk_out_data_callback, mos7840_port);
2331 + if ((serial->num_ports == 2)
2332 + && ((((__u16)port->number -
2333 + (__u16)(port->serial->minor)) % 2) != 0)) {
2334 + usb_fill_bulk_urb(urb,
2335 + serial->dev,
2336 + usb_sndbulkpipe(serial->dev,
2337 + (port->bulk_out_endpointAddress) + 2),
2338 + urb->transfer_buffer,
2339 + transfer_size,
2340 + mos7840_bulk_out_data_callback, mos7840_port);
2341 + } else {
2342 + usb_fill_bulk_urb(urb,
2343 + serial->dev,
2344 + usb_sndbulkpipe(serial->dev,
2345 + port->bulk_out_endpointAddress),
2346 + urb->transfer_buffer,
2347 + transfer_size,
2348 + mos7840_bulk_out_data_callback, mos7840_port);
2349 + }
2350
2351 data1 = urb->transfer_buffer;
2352 dbg("bulkout endpoint is %d", port->bulk_out_endpointAddress);
2353 @@ -1840,7 +1864,7 @@ static int mos7840_send_cmd_write_baud_rate(struct moschip_port *mos7840_port,
2354
2355 } else {
2356 #ifdef HW_flow_control
2357 - / *setting h/w flow control bit to 0 */
2358 + /* setting h/w flow control bit to 0 */
2359 Data = 0xb;
2360 mos7840_port->shadowMCR = Data;
2361 status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER,
2362 @@ -2310,19 +2334,26 @@ static int mos7840_ioctl(struct tty_struct *tty,
2363
2364 static int mos7840_calc_num_ports(struct usb_serial *serial)
2365 {
2366 - int mos7840_num_ports = 0;
2367 -
2368 - dbg("numberofendpoints: cur %d, alt %d",
2369 - (int)serial->interface->cur_altsetting->desc.bNumEndpoints,
2370 - (int)serial->interface->altsetting->desc.bNumEndpoints);
2371 - if (serial->interface->cur_altsetting->desc.bNumEndpoints == 5) {
2372 - mos7840_num_ports = serial->num_ports = 2;
2373 - } else if (serial->interface->cur_altsetting->desc.bNumEndpoints == 9) {
2374 + __u16 Data = 0x00;
2375 + int ret = 0;
2376 + int mos7840_num_ports;
2377 +
2378 + ret = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0),
2379 + MCS_RDREQ, MCS_RD_RTYPE, 0, GPIO_REGISTER, &Data,
2380 + VENDOR_READ_LENGTH, MOS_WDR_TIMEOUT);
2381 +
2382 + if ((Data & 0x01) == 0) {
2383 + mos7840_num_ports = 2;
2384 + serial->num_bulk_in = 2;
2385 + serial->num_bulk_out = 2;
2386 + serial->num_ports = 2;
2387 + } else {
2388 + mos7840_num_ports = 4;
2389 serial->num_bulk_in = 4;
2390 serial->num_bulk_out = 4;
2391 - mos7840_num_ports = serial->num_ports = 4;
2392 + serial->num_ports = 4;
2393 }
2394 - dbg ("mos7840_num_ports = %d", mos7840_num_ports);
2395 +
2396 return mos7840_num_ports;
2397 }
2398
2399 diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
2400 index 68fa8c7..54898c9 100644
2401 --- a/drivers/usb/serial/option.c
2402 +++ b/drivers/usb/serial/option.c
2403 @@ -307,6 +307,9 @@ static void option_instat_callback(struct urb *urb);
2404 #define TELIT_VENDOR_ID 0x1bc7
2405 #define TELIT_PRODUCT_UC864E 0x1003
2406 #define TELIT_PRODUCT_UC864G 0x1004
2407 +#define TELIT_PRODUCT_CC864_DUAL 0x1005
2408 +#define TELIT_PRODUCT_CC864_SINGLE 0x1006
2409 +#define TELIT_PRODUCT_DE910_DUAL 0x1010
2410
2411 /* ZTE PRODUCTS */
2412 #define ZTE_VENDOR_ID 0x19d2
2413 @@ -484,6 +487,9 @@ static void option_instat_callback(struct urb *urb);
2414 #define LG_VENDOR_ID 0x1004
2415 #define LG_PRODUCT_L02C 0x618f
2416
2417 +/* MediaTek products */
2418 +#define MEDIATEK_VENDOR_ID 0x0e8d
2419 +
2420 /* some devices interfaces need special handling due to a number of reasons */
2421 enum option_blacklist_reason {
2422 OPTION_BLACKLIST_NONE = 0,
2423 @@ -768,6 +774,9 @@ static const struct usb_device_id option_ids[] = {
2424 { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6008) },
2425 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_UC864E) },
2426 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_UC864G) },
2427 + { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_CC864_DUAL) },
2428 + { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_CC864_SINGLE) },
2429 + { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_DE910_DUAL) },
2430 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_MF622, 0xff, 0xff, 0xff) }, /* ZTE WCDMA products */
2431 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0002, 0xff, 0xff, 0xff),
2432 .driver_info = (kernel_ulong_t)&net_intf1_blacklist },
2433 @@ -892,6 +901,8 @@ static const struct usb_device_id option_ids[] = {
2434 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0162, 0xff, 0xff, 0xff) },
2435 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0164, 0xff, 0xff, 0xff) },
2436 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0165, 0xff, 0xff, 0xff) },
2437 + { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0167, 0xff, 0xff, 0xff),
2438 + .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
2439 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1008, 0xff, 0xff, 0xff) },
2440 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1010, 0xff, 0xff, 0xff) },
2441 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1012, 0xff, 0xff, 0xff) },
2442 @@ -1198,6 +1209,10 @@ static const struct usb_device_id option_ids[] = {
2443 { USB_DEVICE_AND_INTERFACE_INFO(VIETTEL_VENDOR_ID, VIETTEL_PRODUCT_VT1000, 0xff, 0xff, 0xff) },
2444 { USB_DEVICE_AND_INTERFACE_INFO(ZD_VENDOR_ID, ZD_PRODUCT_7000, 0xff, 0xff, 0xff) },
2445 { USB_DEVICE(LG_VENDOR_ID, LG_PRODUCT_L02C) }, /* docomo L-02C modem */
2446 + { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, 0x00a1, 0xff, 0x00, 0x00) },
2447 + { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, 0x00a1, 0xff, 0x02, 0x01) },
2448 + { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, 0x00a2, 0xff, 0x00, 0x00) },
2449 + { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, 0x00a2, 0xff, 0x02, 0x01) }, /* MediaTek MT6276M modem & app port */
2450 { } /* Terminating entry */
2451 };
2452 MODULE_DEVICE_TABLE(usb, option_ids);
2453 @@ -1360,6 +1375,7 @@ static int option_probe(struct usb_serial *serial,
2454 serial->interface->cur_altsetting->desc.bInterfaceNumber,
2455 OPTION_BLACKLIST_RESERVED_IF,
2456 (const struct option_blacklist_info *) id->driver_info))
2457 + return -ENODEV;
2458
2459 /* Don't bind network interface on Samsung GT-B3730, it is handled by a separate module */
2460 if (serial->dev->descriptor.idVendor == SAMSUNG_VENDOR_ID &&
2461 diff --git a/drivers/usb/serial/qcserial.c b/drivers/usb/serial/qcserial.c
2462 index b9bb247..247c014 100644
2463 --- a/drivers/usb/serial/qcserial.c
2464 +++ b/drivers/usb/serial/qcserial.c
2465 @@ -23,34 +23,44 @@
2466
2467 static int debug;
2468
2469 +#define DEVICE_G1K(v, p) \
2470 + USB_DEVICE(v, p), .driver_info = 1
2471 +
2472 static const struct usb_device_id id_table[] = {
2473 - {USB_DEVICE(0x05c6, 0x9211)}, /* Acer Gobi QDL device */
2474 - {USB_DEVICE(0x05c6, 0x9212)}, /* Acer Gobi Modem Device */
2475 - {USB_DEVICE(0x03f0, 0x1f1d)}, /* HP un2400 Gobi Modem Device */
2476 - {USB_DEVICE(0x03f0, 0x201d)}, /* HP un2400 Gobi QDL Device */
2477 - {USB_DEVICE(0x03f0, 0x371d)}, /* HP un2430 Mobile Broadband Module */
2478 - {USB_DEVICE(0x04da, 0x250d)}, /* Panasonic Gobi Modem device */
2479 - {USB_DEVICE(0x04da, 0x250c)}, /* Panasonic Gobi QDL device */
2480 - {USB_DEVICE(0x413c, 0x8172)}, /* Dell Gobi Modem device */
2481 - {USB_DEVICE(0x413c, 0x8171)}, /* Dell Gobi QDL device */
2482 - {USB_DEVICE(0x1410, 0xa001)}, /* Novatel Gobi Modem device */
2483 - {USB_DEVICE(0x1410, 0xa008)}, /* Novatel Gobi QDL device */
2484 - {USB_DEVICE(0x0b05, 0x1776)}, /* Asus Gobi Modem device */
2485 - {USB_DEVICE(0x0b05, 0x1774)}, /* Asus Gobi QDL device */
2486 - {USB_DEVICE(0x19d2, 0xfff3)}, /* ONDA Gobi Modem device */
2487 - {USB_DEVICE(0x19d2, 0xfff2)}, /* ONDA Gobi QDL device */
2488 - {USB_DEVICE(0x1557, 0x0a80)}, /* OQO Gobi QDL device */
2489 - {USB_DEVICE(0x05c6, 0x9001)}, /* Generic Gobi Modem device */
2490 - {USB_DEVICE(0x05c6, 0x9002)}, /* Generic Gobi Modem device */
2491 - {USB_DEVICE(0x05c6, 0x9202)}, /* Generic Gobi Modem device */
2492 - {USB_DEVICE(0x05c6, 0x9203)}, /* Generic Gobi Modem device */
2493 - {USB_DEVICE(0x05c6, 0x9222)}, /* Generic Gobi Modem device */
2494 - {USB_DEVICE(0x05c6, 0x9008)}, /* Generic Gobi QDL device */
2495 - {USB_DEVICE(0x05c6, 0x9009)}, /* Generic Gobi Modem device */
2496 - {USB_DEVICE(0x05c6, 0x9201)}, /* Generic Gobi QDL device */
2497 - {USB_DEVICE(0x05c6, 0x9221)}, /* Generic Gobi QDL device */
2498 - {USB_DEVICE(0x05c6, 0x9231)}, /* Generic Gobi QDL device */
2499 - {USB_DEVICE(0x1f45, 0x0001)}, /* Unknown Gobi QDL device */
2500 + /* Gobi 1000 devices */
2501 + {DEVICE_G1K(0x05c6, 0x9211)}, /* Acer Gobi QDL device */
2502 + {DEVICE_G1K(0x05c6, 0x9212)}, /* Acer Gobi Modem Device */
2503 + {DEVICE_G1K(0x03f0, 0x1f1d)}, /* HP un2400 Gobi Modem Device */
2504 + {DEVICE_G1K(0x03f0, 0x201d)}, /* HP un2400 Gobi QDL Device */
2505 + {DEVICE_G1K(0x04da, 0x250d)}, /* Panasonic Gobi Modem device */
2506 + {DEVICE_G1K(0x04da, 0x250c)}, /* Panasonic Gobi QDL device */
2507 + {DEVICE_G1K(0x413c, 0x8172)}, /* Dell Gobi Modem device */
2508 + {DEVICE_G1K(0x413c, 0x8171)}, /* Dell Gobi QDL device */
2509 + {DEVICE_G1K(0x1410, 0xa001)}, /* Novatel Gobi Modem device */
2510 + {DEVICE_G1K(0x1410, 0xa008)}, /* Novatel Gobi QDL device */
2511 + {DEVICE_G1K(0x0b05, 0x1776)}, /* Asus Gobi Modem device */
2512 + {DEVICE_G1K(0x0b05, 0x1774)}, /* Asus Gobi QDL device */
2513 + {DEVICE_G1K(0x19d2, 0xfff3)}, /* ONDA Gobi Modem device */
2514 + {DEVICE_G1K(0x19d2, 0xfff2)}, /* ONDA Gobi QDL device */
2515 + {DEVICE_G1K(0x1557, 0x0a80)}, /* OQO Gobi QDL device */
2516 + {DEVICE_G1K(0x05c6, 0x9001)}, /* Generic Gobi Modem device */
2517 + {DEVICE_G1K(0x05c6, 0x9002)}, /* Generic Gobi Modem device */
2518 + {DEVICE_G1K(0x05c6, 0x9202)}, /* Generic Gobi Modem device */
2519 + {DEVICE_G1K(0x05c6, 0x9203)}, /* Generic Gobi Modem device */
2520 + {DEVICE_G1K(0x05c6, 0x9222)}, /* Generic Gobi Modem device */
2521 + {DEVICE_G1K(0x05c6, 0x9008)}, /* Generic Gobi QDL device */
2522 + {DEVICE_G1K(0x05c6, 0x9009)}, /* Generic Gobi Modem device */
2523 + {DEVICE_G1K(0x05c6, 0x9201)}, /* Generic Gobi QDL device */
2524 + {DEVICE_G1K(0x05c6, 0x9221)}, /* Generic Gobi QDL device */
2525 + {DEVICE_G1K(0x05c6, 0x9231)}, /* Generic Gobi QDL device */
2526 + {DEVICE_G1K(0x1f45, 0x0001)}, /* Unknown Gobi QDL device */
2527 +
2528 + /* Gobi 2000 devices */
2529 + {USB_DEVICE(0x1410, 0xa010)}, /* Novatel Gobi 2000 QDL device */
2530 + {USB_DEVICE(0x1410, 0xa011)}, /* Novatel Gobi 2000 QDL device */
2531 + {USB_DEVICE(0x1410, 0xa012)}, /* Novatel Gobi 2000 QDL device */
2532 + {USB_DEVICE(0x1410, 0xa013)}, /* Novatel Gobi 2000 QDL device */
2533 + {USB_DEVICE(0x1410, 0xa014)}, /* Novatel Gobi 2000 QDL device */
2534 {USB_DEVICE(0x413c, 0x8185)}, /* Dell Gobi 2000 QDL device (N0218, VU936) */
2535 {USB_DEVICE(0x413c, 0x8186)}, /* Dell Gobi 2000 Modem device (N0218, VU936) */
2536 {USB_DEVICE(0x05c6, 0x9208)}, /* Generic Gobi 2000 QDL device */
2537 @@ -85,7 +95,18 @@ static const struct usb_device_id id_table[] = {
2538 {USB_DEVICE(0x16d8, 0x8002)}, /* CMDTech Gobi 2000 Modem device (VU922) */
2539 {USB_DEVICE(0x05c6, 0x9204)}, /* Gobi 2000 QDL device */
2540 {USB_DEVICE(0x05c6, 0x9205)}, /* Gobi 2000 Modem device */
2541 +
2542 + /* Gobi 3000 devices */
2543 + {USB_DEVICE(0x03f0, 0x371d)}, /* HP un2430 Gobi 3000 QDL */
2544 + {USB_DEVICE(0x05c6, 0x920c)}, /* Gobi 3000 QDL */
2545 + {USB_DEVICE(0x05c6, 0x920d)}, /* Gobi 3000 Composite */
2546 + {USB_DEVICE(0x1410, 0xa020)}, /* Novatel Gobi 3000 QDL */
2547 + {USB_DEVICE(0x1410, 0xa021)}, /* Novatel Gobi 3000 Composite */
2548 + {USB_DEVICE(0x413c, 0x8193)}, /* Dell Gobi 3000 QDL */
2549 + {USB_DEVICE(0x413c, 0x8194)}, /* Dell Gobi 3000 Composite */
2550 {USB_DEVICE(0x1199, 0x9013)}, /* Sierra Wireless Gobi 3000 Modem device (MC8355) */
2551 + {USB_DEVICE(0x12D1, 0x14F0)}, /* Sony Gobi 3000 QDL */
2552 + {USB_DEVICE(0x12D1, 0x14F1)}, /* Sony Gobi 3000 Composite */
2553 { } /* Terminating entry */
2554 };
2555 MODULE_DEVICE_TABLE(usb, id_table);
2556 @@ -107,8 +128,10 @@ static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id)
2557 int retval = -ENODEV;
2558 __u8 nintf;
2559 __u8 ifnum;
2560 + bool is_gobi1k = id->driver_info ? true : false;
2561
2562 dbg("%s", __func__);
2563 + dbg("Is Gobi 1000 = %d", is_gobi1k);
2564
2565 nintf = serial->dev->actconfig->desc.bNumInterfaces;
2566 dbg("Num Interfaces = %d", nintf);
2567 @@ -156,15 +179,25 @@ static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id)
2568
2569 case 3:
2570 case 4:
2571 - /* Composite mode */
2572 - /* ifnum == 0 is a broadband network adapter */
2573 - if (ifnum == 1) {
2574 - /*
2575 - * Diagnostics Monitor (serial line 9600 8N1)
2576 - * Qualcomm DM protocol
2577 - * use "libqcdm" (ModemManager) for communication
2578 - */
2579 - dbg("Diagnostics Monitor found");
2580 + /* Composite mode; don't bind to the QMI/net interface as that
2581 + * gets handled by other drivers.
2582 + */
2583 +
2584 + /* Gobi 1K USB layout:
2585 + * 0: serial port (doesn't respond)
2586 + * 1: serial port (doesn't respond)
2587 + * 2: AT-capable modem port
2588 + * 3: QMI/net
2589 + *
2590 + * Gobi 2K+ USB layout:
2591 + * 0: QMI/net
2592 + * 1: DM/DIAG (use libqcdm from ModemManager for communication)
2593 + * 2: AT-capable modem port
2594 + * 3: NMEA
2595 + */
2596 +
2597 + if (ifnum == 1 && !is_gobi1k) {
2598 + dbg("Gobi 2K+ DM/DIAG interface found");
2599 retval = usb_set_interface(serial->dev, ifnum, 0);
2600 if (retval < 0) {
2601 dev_err(&serial->dev->dev,
2602 @@ -183,13 +216,13 @@ static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id)
2603 retval = -ENODEV;
2604 kfree(data);
2605 }
2606 - } else if (ifnum==3) {
2607 + } else if (ifnum==3 && !is_gobi1k) {
2608 /*
2609 * NMEA (serial line 9600 8N1)
2610 * # echo "\$GPS_START" > /dev/ttyUSBx
2611 * # echo "\$GPS_STOP" > /dev/ttyUSBx
2612 */
2613 - dbg("NMEA GPS interface found");
2614 + dbg("Gobi 2K+ NMEA GPS interface found");
2615 retval = usb_set_interface(serial->dev, ifnum, 0);
2616 if (retval < 0) {
2617 dev_err(&serial->dev->dev,
2618 diff --git a/drivers/video/backlight/tosa_lcd.c b/drivers/video/backlight/tosa_lcd.c
2619 index 772f601..6f54f74 100644
2620 --- a/drivers/video/backlight/tosa_lcd.c
2621 +++ b/drivers/video/backlight/tosa_lcd.c
2622 @@ -271,7 +271,7 @@ static int tosa_lcd_resume(struct spi_device *spi)
2623 }
2624 #else
2625 #define tosa_lcd_suspend NULL
2626 -#define tosa_lcd_reume NULL
2627 +#define tosa_lcd_resume NULL
2628 #endif
2629
2630 static struct spi_driver tosa_lcd_driver = {
2631 diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
2632 index ad93629..7a41220 100644
2633 --- a/drivers/video/fbmem.c
2634 +++ b/drivers/video/fbmem.c
2635 @@ -1651,6 +1651,7 @@ static int do_unregister_framebuffer(struct fb_info *fb_info)
2636 if (ret)
2637 return -EINVAL;
2638
2639 + unlink_framebuffer(fb_info);
2640 if (fb_info->pixmap.addr &&
2641 (fb_info->pixmap.flags & FB_PIXMAP_DEFAULT))
2642 kfree(fb_info->pixmap.addr);
2643 @@ -1658,7 +1659,6 @@ static int do_unregister_framebuffer(struct fb_info *fb_info)
2644 registered_fb[i] = NULL;
2645 num_registered_fb--;
2646 fb_cleanup_device(fb_info);
2647 - device_destroy(fb_class, MKDEV(FB_MAJOR, i));
2648 event.info = fb_info;
2649 fb_notifier_call_chain(FB_EVENT_FB_UNREGISTERED, &event);
2650
2651 @@ -1667,6 +1667,22 @@ static int do_unregister_framebuffer(struct fb_info *fb_info)
2652 return 0;
2653 }
2654
2655 +int unlink_framebuffer(struct fb_info *fb_info)
2656 +{
2657 + int i;
2658 +
2659 + i = fb_info->node;
2660 + if (i < 0 || i >= FB_MAX || registered_fb[i] != fb_info)
2661 + return -EINVAL;
2662 +
2663 + if (fb_info->dev) {
2664 + device_destroy(fb_class, MKDEV(FB_MAJOR, i));
2665 + fb_info->dev = NULL;
2666 + }
2667 + return 0;
2668 +}
2669 +EXPORT_SYMBOL(unlink_framebuffer);
2670 +
2671 void remove_conflicting_framebuffers(struct apertures_struct *a,
2672 const char *name, bool primary)
2673 {
2674 diff --git a/drivers/video/udlfb.c b/drivers/video/udlfb.c
2675 index 816a4fd..415e9b2 100644
2676 --- a/drivers/video/udlfb.c
2677 +++ b/drivers/video/udlfb.c
2678 @@ -1666,7 +1666,7 @@ static void dlfb_usb_disconnect(struct usb_interface *interface)
2679 for (i = 0; i < ARRAY_SIZE(fb_device_attrs); i++)
2680 device_remove_file(info->dev, &fb_device_attrs[i]);
2681 device_remove_bin_file(info->dev, &edid_attr);
2682 -
2683 + unlink_framebuffer(info);
2684 usb_set_intfdata(interface, NULL);
2685
2686 /* if clients still have us open, will be freed on last close */
2687 diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
2688 index cb85825..b775809 100644
2689 --- a/fs/cifs/connect.c
2690 +++ b/fs/cifs/connect.c
2691 @@ -3004,7 +3004,7 @@ cifs_get_volume_info(char *mount_data, const char *devname)
2692 int
2693 cifs_mount(struct cifs_sb_info *cifs_sb, struct smb_vol *volume_info)
2694 {
2695 - int rc = 0;
2696 + int rc;
2697 int xid;
2698 struct cifs_ses *pSesInfo;
2699 struct cifs_tcon *tcon;
2700 @@ -3033,6 +3033,7 @@ try_mount_again:
2701 FreeXid(xid);
2702 }
2703 #endif
2704 + rc = 0;
2705 tcon = NULL;
2706 pSesInfo = NULL;
2707 srvTcp = NULL;
2708 diff --git a/fs/dcache.c b/fs/dcache.c
2709 index f598b98..0b51cfc9 100644
2710 --- a/fs/dcache.c
2711 +++ b/fs/dcache.c
2712 @@ -2433,6 +2433,7 @@ struct dentry *d_materialise_unique(struct dentry *dentry, struct inode *inode)
2713 if (d_ancestor(alias, dentry)) {
2714 /* Check for loops */
2715 actual = ERR_PTR(-ELOOP);
2716 + spin_unlock(&inode->i_lock);
2717 } else if (IS_ROOT(alias)) {
2718 /* Is this an anonymous mountpoint that we
2719 * could splice into our tree? */
2720 @@ -2442,7 +2443,7 @@ struct dentry *d_materialise_unique(struct dentry *dentry, struct inode *inode)
2721 goto found;
2722 } else {
2723 /* Nope, but we must(!) avoid directory
2724 - * aliasing */
2725 + * aliasing. This drops inode->i_lock */
2726 actual = __d_unalias(inode, dentry, alias);
2727 }
2728 write_sequnlock(&rename_lock);
2729 diff --git a/fs/ext4/ext4_jbd2.h b/fs/ext4/ext4_jbd2.h
2730 index 5802fa1..95af6f8 100644
2731 --- a/fs/ext4/ext4_jbd2.h
2732 +++ b/fs/ext4/ext4_jbd2.h
2733 @@ -261,43 +261,45 @@ static inline void ext4_update_inode_fsync_trans(handle_t *handle,
2734 /* super.c */
2735 int ext4_force_commit(struct super_block *sb);
2736
2737 -static inline int ext4_should_journal_data(struct inode *inode)
2738 +/*
2739 + * Ext4 inode journal modes
2740 + */
2741 +#define EXT4_INODE_JOURNAL_DATA_MODE 0x01 /* journal data mode */
2742 +#define EXT4_INODE_ORDERED_DATA_MODE 0x02 /* ordered data mode */
2743 +#define EXT4_INODE_WRITEBACK_DATA_MODE 0x04 /* writeback data mode */
2744 +
2745 +static inline int ext4_inode_journal_mode(struct inode *inode)
2746 {
2747 if (EXT4_JOURNAL(inode) == NULL)
2748 - return 0;
2749 - if (!S_ISREG(inode->i_mode))
2750 - return 1;
2751 - if (test_opt(inode->i_sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA)
2752 - return 1;
2753 - if (ext4_test_inode_flag(inode, EXT4_INODE_JOURNAL_DATA))
2754 - return 1;
2755 - return 0;
2756 + return EXT4_INODE_WRITEBACK_DATA_MODE; /* writeback */
2757 + /* We do not support data journalling with delayed allocation */
2758 + if (!S_ISREG(inode->i_mode) ||
2759 + test_opt(inode->i_sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA)
2760 + return EXT4_INODE_JOURNAL_DATA_MODE; /* journal data */
2761 + if (ext4_test_inode_flag(inode, EXT4_INODE_JOURNAL_DATA) &&
2762 + !test_opt(inode->i_sb, DELALLOC))
2763 + return EXT4_INODE_JOURNAL_DATA_MODE; /* journal data */
2764 + if (test_opt(inode->i_sb, DATA_FLAGS) == EXT4_MOUNT_ORDERED_DATA)
2765 + return EXT4_INODE_ORDERED_DATA_MODE; /* ordered */
2766 + if (test_opt(inode->i_sb, DATA_FLAGS) == EXT4_MOUNT_WRITEBACK_DATA)
2767 + return EXT4_INODE_WRITEBACK_DATA_MODE; /* writeback */
2768 + else
2769 + BUG();
2770 +}
2771 +
2772 +static inline int ext4_should_journal_data(struct inode *inode)
2773 +{
2774 + return ext4_inode_journal_mode(inode) & EXT4_INODE_JOURNAL_DATA_MODE;
2775 }
2776
2777 static inline int ext4_should_order_data(struct inode *inode)
2778 {
2779 - if (EXT4_JOURNAL(inode) == NULL)
2780 - return 0;
2781 - if (!S_ISREG(inode->i_mode))
2782 - return 0;
2783 - if (ext4_test_inode_flag(inode, EXT4_INODE_JOURNAL_DATA))
2784 - return 0;
2785 - if (test_opt(inode->i_sb, DATA_FLAGS) == EXT4_MOUNT_ORDERED_DATA)
2786 - return 1;
2787 - return 0;
2788 + return ext4_inode_journal_mode(inode) & EXT4_INODE_ORDERED_DATA_MODE;
2789 }
2790
2791 static inline int ext4_should_writeback_data(struct inode *inode)
2792 {
2793 - if (EXT4_JOURNAL(inode) == NULL)
2794 - return 1;
2795 - if (!S_ISREG(inode->i_mode))
2796 - return 0;
2797 - if (ext4_test_inode_flag(inode, EXT4_INODE_JOURNAL_DATA))
2798 - return 0;
2799 - if (test_opt(inode->i_sb, DATA_FLAGS) == EXT4_MOUNT_WRITEBACK_DATA)
2800 - return 1;
2801 - return 0;
2802 + return ext4_inode_journal_mode(inode) & EXT4_INODE_WRITEBACK_DATA_MODE;
2803 }
2804
2805 /*
2806 diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
2807 index f3aacb3..7fc10ed 100644
2808 --- a/fs/ext4/extents.c
2809 +++ b/fs/ext4/extents.c
2810 @@ -341,6 +341,8 @@ static int ext4_valid_extent(struct inode *inode, struct ext4_extent *ext)
2811 ext4_fsblk_t block = ext4_ext_pblock(ext);
2812 int len = ext4_ext_get_actual_len(ext);
2813
2814 + if (len == 0)
2815 + return 0;
2816 return ext4_data_block_valid(EXT4_SB(inode->i_sb), block, len);
2817 }
2818
2819 diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
2820 index af09060..c1e6a72 100644
2821 --- a/fs/ext4/inode.c
2822 +++ b/fs/ext4/inode.c
2823 @@ -3212,13 +3212,14 @@ static int ext4_da_write_end(struct file *file,
2824 int write_mode = (int)(unsigned long)fsdata;
2825
2826 if (write_mode == FALL_BACK_TO_NONDELALLOC) {
2827 - if (ext4_should_order_data(inode)) {
2828 + switch (ext4_inode_journal_mode(inode)) {
2829 + case EXT4_INODE_ORDERED_DATA_MODE:
2830 return ext4_ordered_write_end(file, mapping, pos,
2831 len, copied, page, fsdata);
2832 - } else if (ext4_should_writeback_data(inode)) {
2833 + case EXT4_INODE_WRITEBACK_DATA_MODE:
2834 return ext4_writeback_write_end(file, mapping, pos,
2835 len, copied, page, fsdata);
2836 - } else {
2837 + default:
2838 BUG();
2839 }
2840 }
2841 @@ -3510,12 +3511,17 @@ static ssize_t ext4_ind_direct_IO(int rw, struct kiocb *iocb,
2842 }
2843
2844 retry:
2845 - if (rw == READ && ext4_should_dioread_nolock(inode))
2846 + if (rw == READ && ext4_should_dioread_nolock(inode)) {
2847 + if (unlikely(!list_empty(&ei->i_completed_io_list))) {
2848 + mutex_lock(&inode->i_mutex);
2849 + ext4_flush_completed_IO(inode);
2850 + mutex_unlock(&inode->i_mutex);
2851 + }
2852 ret = __blockdev_direct_IO(rw, iocb, inode,
2853 inode->i_sb->s_bdev, iov,
2854 offset, nr_segs,
2855 ext4_get_block, NULL, NULL, 0);
2856 - else {
2857 + } else {
2858 ret = blockdev_direct_IO(rw, iocb, inode,
2859 inode->i_sb->s_bdev, iov,
2860 offset, nr_segs,
2861 @@ -3913,18 +3919,25 @@ static const struct address_space_operations ext4_da_aops = {
2862
2863 void ext4_set_aops(struct inode *inode)
2864 {
2865 - if (ext4_should_order_data(inode) &&
2866 - test_opt(inode->i_sb, DELALLOC))
2867 - inode->i_mapping->a_ops = &ext4_da_aops;
2868 - else if (ext4_should_order_data(inode))
2869 - inode->i_mapping->a_ops = &ext4_ordered_aops;
2870 - else if (ext4_should_writeback_data(inode) &&
2871 - test_opt(inode->i_sb, DELALLOC))
2872 - inode->i_mapping->a_ops = &ext4_da_aops;
2873 - else if (ext4_should_writeback_data(inode))
2874 - inode->i_mapping->a_ops = &ext4_writeback_aops;
2875 - else
2876 + switch (ext4_inode_journal_mode(inode)) {
2877 + case EXT4_INODE_ORDERED_DATA_MODE:
2878 + if (test_opt(inode->i_sb, DELALLOC))
2879 + inode->i_mapping->a_ops = &ext4_da_aops;
2880 + else
2881 + inode->i_mapping->a_ops = &ext4_ordered_aops;
2882 + break;
2883 + case EXT4_INODE_WRITEBACK_DATA_MODE:
2884 + if (test_opt(inode->i_sb, DELALLOC))
2885 + inode->i_mapping->a_ops = &ext4_da_aops;
2886 + else
2887 + inode->i_mapping->a_ops = &ext4_writeback_aops;
2888 + break;
2889 + case EXT4_INODE_JOURNAL_DATA_MODE:
2890 inode->i_mapping->a_ops = &ext4_journalled_aops;
2891 + break;
2892 + default:
2893 + BUG();
2894 + }
2895 }
2896
2897 /*
2898 diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
2899 index 7aafeb8..8b0c875 100644
2900 --- a/fs/hugetlbfs/inode.c
2901 +++ b/fs/hugetlbfs/inode.c
2902 @@ -238,17 +238,10 @@ static ssize_t hugetlbfs_read(struct file *filp, char __user *buf,
2903 loff_t isize;
2904 ssize_t retval = 0;
2905
2906 - mutex_lock(&inode->i_mutex);
2907 -
2908 /* validate length */
2909 if (len == 0)
2910 goto out;
2911
2912 - isize = i_size_read(inode);
2913 - if (!isize)
2914 - goto out;
2915 -
2916 - end_index = (isize - 1) >> huge_page_shift(h);
2917 for (;;) {
2918 struct page *page;
2919 unsigned long nr, ret;
2920 @@ -256,18 +249,21 @@ static ssize_t hugetlbfs_read(struct file *filp, char __user *buf,
2921
2922 /* nr is the maximum number of bytes to copy from this page */
2923 nr = huge_page_size(h);
2924 + isize = i_size_read(inode);
2925 + if (!isize)
2926 + goto out;
2927 + end_index = (isize - 1) >> huge_page_shift(h);
2928 if (index >= end_index) {
2929 if (index > end_index)
2930 goto out;
2931 nr = ((isize - 1) & ~huge_page_mask(h)) + 1;
2932 - if (nr <= offset) {
2933 + if (nr <= offset)
2934 goto out;
2935 - }
2936 }
2937 nr = nr - offset;
2938
2939 /* Find the page */
2940 - page = find_get_page(mapping, index);
2941 + page = find_lock_page(mapping, index);
2942 if (unlikely(page == NULL)) {
2943 /*
2944 * We have a HOLE, zero out the user-buffer for the
2945 @@ -279,17 +275,18 @@ static ssize_t hugetlbfs_read(struct file *filp, char __user *buf,
2946 else
2947 ra = 0;
2948 } else {
2949 + unlock_page(page);
2950 +
2951 /*
2952 * We have the page, copy it to user space buffer.
2953 */
2954 ra = hugetlbfs_read_actor(page, offset, buf, len, nr);
2955 ret = ra;
2956 + page_cache_release(page);
2957 }
2958 if (ra < 0) {
2959 if (retval == 0)
2960 retval = ra;
2961 - if (page)
2962 - page_cache_release(page);
2963 goto out;
2964 }
2965
2966 @@ -299,16 +296,12 @@ static ssize_t hugetlbfs_read(struct file *filp, char __user *buf,
2967 index += offset >> huge_page_shift(h);
2968 offset &= ~huge_page_mask(h);
2969
2970 - if (page)
2971 - page_cache_release(page);
2972 -
2973 /* short read or no more work */
2974 if ((ret != nr) || (len == 0))
2975 break;
2976 }
2977 out:
2978 *ppos = ((loff_t)index << huge_page_shift(h)) + offset;
2979 - mutex_unlock(&inode->i_mutex);
2980 return retval;
2981 }
2982
2983 diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c
2984 index 2d71094..9baa39e 100644
2985 --- a/fs/jbd2/transaction.c
2986 +++ b/fs/jbd2/transaction.c
2987 @@ -1902,6 +1902,8 @@ zap_buffer_unlocked:
2988 clear_buffer_mapped(bh);
2989 clear_buffer_req(bh);
2990 clear_buffer_new(bh);
2991 + clear_buffer_delay(bh);
2992 + clear_buffer_unwritten(bh);
2993 bh->b_bdev = NULL;
2994 return may_free;
2995 }
2996 diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c
2997 index abfff9d..1743064 100644
2998 --- a/fs/lockd/svc.c
2999 +++ b/fs/lockd/svc.c
3000 @@ -440,7 +440,7 @@ static int param_set_##name(const char *val, struct kernel_param *kp) \
3001 __typeof__(type) num = which_strtol(val, &endp, 0); \
3002 if (endp == val || *endp || num < (min) || num > (max)) \
3003 return -EINVAL; \
3004 - *((int *) kp->arg) = num; \
3005 + *((type *) kp->arg) = num; \
3006 return 0; \
3007 }
3008
3009 diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c
3010 index 321a66b..ecabbd8 100644
3011 --- a/fs/nfs/delegation.c
3012 +++ b/fs/nfs/delegation.c
3013 @@ -466,6 +466,17 @@ static void nfs_delegation_run_state_manager(struct nfs_client *clp)
3014 nfs4_schedule_state_manager(clp);
3015 }
3016
3017 +void nfs_remove_bad_delegation(struct inode *inode)
3018 +{
3019 + struct nfs_delegation *delegation;
3020 +
3021 + delegation = nfs_detach_delegation(NFS_I(inode), NFS_SERVER(inode));
3022 + if (delegation) {
3023 + nfs_inode_find_state_and_recover(inode, &delegation->stateid);
3024 + nfs_free_delegation(delegation);
3025 + }
3026 +}
3027 +
3028 /**
3029 * nfs_expire_all_delegation_types
3030 * @clp: client to process
3031 diff --git a/fs/nfs/delegation.h b/fs/nfs/delegation.h
3032 index d9322e4..691a796 100644
3033 --- a/fs/nfs/delegation.h
3034 +++ b/fs/nfs/delegation.h
3035 @@ -45,6 +45,7 @@ void nfs_expire_unreferenced_delegations(struct nfs_client *clp);
3036 void nfs_handle_cb_pathdown(struct nfs_client *clp);
3037 int nfs_client_return_marked_delegations(struct nfs_client *clp);
3038 int nfs_delegations_present(struct nfs_client *clp);
3039 +void nfs_remove_bad_delegation(struct inode *inode);
3040
3041 void nfs_delegation_mark_reclaim(struct nfs_client *clp);
3042 void nfs_delegation_reap_unclaimed(struct nfs_client *clp);
3043 diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h
3044 index c4a6983..e1c1365 100644
3045 --- a/fs/nfs/nfs4_fs.h
3046 +++ b/fs/nfs/nfs4_fs.h
3047 @@ -209,6 +209,7 @@ struct nfs4_exception {
3048 long timeout;
3049 int retry;
3050 struct nfs4_state *state;
3051 + struct inode *inode;
3052 };
3053
3054 struct nfs4_state_recovery_ops {
3055 @@ -344,6 +345,8 @@ extern void nfs4_put_open_state(struct nfs4_state *);
3056 extern void nfs4_close_state(struct path *, struct nfs4_state *, fmode_t);
3057 extern void nfs4_close_sync(struct path *, struct nfs4_state *, fmode_t);
3058 extern void nfs4_state_set_mode_locked(struct nfs4_state *, fmode_t);
3059 +extern void nfs_inode_find_state_and_recover(struct inode *inode,
3060 + const nfs4_stateid *stateid);
3061 extern void nfs4_schedule_lease_recovery(struct nfs_client *);
3062 extern void nfs4_schedule_state_manager(struct nfs_client *);
3063 extern void nfs4_schedule_stateid_recovery(const struct nfs_server *, struct nfs4_state *);
3064 diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
3065 index a2a7d0a..301b0c9 100644
3066 --- a/fs/nfs/nfs4proc.c
3067 +++ b/fs/nfs/nfs4proc.c
3068 @@ -254,15 +254,28 @@ static int nfs4_handle_exception(struct nfs_server *server, int errorcode, struc
3069 {
3070 struct nfs_client *clp = server->nfs_client;
3071 struct nfs4_state *state = exception->state;
3072 + struct inode *inode = exception->inode;
3073 int ret = errorcode;
3074
3075 exception->retry = 0;
3076 switch(errorcode) {
3077 case 0:
3078 return 0;
3079 + case -NFS4ERR_OPENMODE:
3080 + if (nfs_have_delegation(inode, FMODE_READ)) {
3081 + nfs_inode_return_delegation(inode);
3082 + exception->retry = 1;
3083 + return 0;
3084 + }
3085 + if (state == NULL)
3086 + break;
3087 + nfs4_schedule_stateid_recovery(server, state);
3088 + goto wait_on_recovery;
3089 + case -NFS4ERR_DELEG_REVOKED:
3090 case -NFS4ERR_ADMIN_REVOKED:
3091 case -NFS4ERR_BAD_STATEID:
3092 - case -NFS4ERR_OPENMODE:
3093 + if (state != NULL)
3094 + nfs_remove_bad_delegation(state->inode);
3095 if (state == NULL)
3096 break;
3097 nfs4_schedule_stateid_recovery(server, state);
3098 @@ -1305,8 +1318,11 @@ int nfs4_open_delegation_recall(struct nfs_open_context *ctx, struct nfs4_state
3099 * The show must go on: exit, but mark the
3100 * stateid as needing recovery.
3101 */
3102 + case -NFS4ERR_DELEG_REVOKED:
3103 case -NFS4ERR_ADMIN_REVOKED:
3104 case -NFS4ERR_BAD_STATEID:
3105 + nfs_inode_find_state_and_recover(state->inode,
3106 + stateid);
3107 nfs4_schedule_stateid_recovery(server, state);
3108 case -EKEYEXPIRED:
3109 /*
3110 @@ -1862,7 +1878,10 @@ static int nfs4_do_setattr(struct inode *inode, struct rpc_cred *cred,
3111 struct nfs4_state *state)
3112 {
3113 struct nfs_server *server = NFS_SERVER(inode);
3114 - struct nfs4_exception exception = { };
3115 + struct nfs4_exception exception = {
3116 + .state = state,
3117 + .inode = inode,
3118 + };
3119 int err;
3120 do {
3121 err = nfs4_handle_exception(server,
3122 @@ -3678,8 +3697,11 @@ nfs4_async_handle_error(struct rpc_task *task, const struct nfs_server *server,
3123 if (task->tk_status >= 0)
3124 return 0;
3125 switch(task->tk_status) {
3126 + case -NFS4ERR_DELEG_REVOKED:
3127 case -NFS4ERR_ADMIN_REVOKED:
3128 case -NFS4ERR_BAD_STATEID:
3129 + if (state != NULL)
3130 + nfs_remove_bad_delegation(state->inode);
3131 case -NFS4ERR_OPENMODE:
3132 if (state == NULL)
3133 break;
3134 @@ -4484,7 +4506,9 @@ out:
3135
3136 static int nfs4_proc_setlk(struct nfs4_state *state, int cmd, struct file_lock *request)
3137 {
3138 - struct nfs4_exception exception = { };
3139 + struct nfs4_exception exception = {
3140 + .state = state,
3141 + };
3142 int err;
3143
3144 do {
3145 @@ -4577,6 +4601,7 @@ int nfs4_lock_delegation_recall(struct nfs4_state *state, struct file_lock *fl)
3146 * The show must go on: exit, but mark the
3147 * stateid as needing recovery.
3148 */
3149 + case -NFS4ERR_DELEG_REVOKED:
3150 case -NFS4ERR_ADMIN_REVOKED:
3151 case -NFS4ERR_BAD_STATEID:
3152 case -NFS4ERR_OPENMODE:
3153 diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
3154 index 9e7e9a5..c6e2769 100644
3155 --- a/fs/nfs/nfs4state.c
3156 +++ b/fs/nfs/nfs4state.c
3157 @@ -1065,12 +1065,37 @@ void nfs4_schedule_stateid_recovery(const struct nfs_server *server, struct nfs4
3158 {
3159 struct nfs_client *clp = server->nfs_client;
3160
3161 - if (test_and_clear_bit(NFS_DELEGATED_STATE, &state->flags))
3162 - nfs_async_inode_return_delegation(state->inode, &state->stateid);
3163 nfs4_state_mark_reclaim_nograce(clp, state);
3164 nfs4_schedule_state_manager(clp);
3165 }
3166
3167 +void nfs_inode_find_state_and_recover(struct inode *inode,
3168 + const nfs4_stateid *stateid)
3169 +{
3170 + struct nfs_client *clp = NFS_SERVER(inode)->nfs_client;
3171 + struct nfs_inode *nfsi = NFS_I(inode);
3172 + struct nfs_open_context *ctx;
3173 + struct nfs4_state *state;
3174 + bool found = false;
3175 +
3176 + spin_lock(&inode->i_lock);
3177 + list_for_each_entry(ctx, &nfsi->open_files, list) {
3178 + state = ctx->state;
3179 + if (state == NULL)
3180 + continue;
3181 + if (!test_bit(NFS_DELEGATED_STATE, &state->flags))
3182 + continue;
3183 + if (memcmp(state->stateid.data, stateid->data, sizeof(state->stateid.data)) != 0)
3184 + continue;
3185 + nfs4_state_mark_reclaim_nograce(clp, state);
3186 + found = true;
3187 + }
3188 + spin_unlock(&inode->i_lock);
3189 + if (found)
3190 + nfs4_schedule_state_manager(clp);
3191 +}
3192 +
3193 +
3194 static int nfs4_reclaim_locks(struct nfs4_state *state, const struct nfs4_state_recovery_ops *ops)
3195 {
3196 struct inode *inode = state->inode;
3197 diff --git a/fs/proc/namespaces.c b/fs/proc/namespaces.c
3198 index be177f7..d6c078e 100644
3199 --- a/fs/proc/namespaces.c
3200 +++ b/fs/proc/namespaces.c
3201 @@ -54,7 +54,7 @@ static struct dentry *proc_ns_instantiate(struct inode *dir,
3202 ei->ns_ops = ns_ops;
3203 ei->ns = ns;
3204
3205 - dentry->d_op = &pid_dentry_operations;
3206 + d_set_d_op(dentry, &pid_dentry_operations);
3207 d_add(dentry, inode);
3208 /* Close the race of the process dying before we return the dentry */
3209 if (pid_revalidate(dentry, NULL))
3210 diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
3211 index 3487b06..55a1f49 100644
3212 --- a/fs/proc/task_mmu.c
3213 +++ b/fs/proc/task_mmu.c
3214 @@ -407,6 +407,9 @@ static int smaps_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end,
3215 } else {
3216 spin_unlock(&walk->mm->page_table_lock);
3217 }
3218 +
3219 + if (pmd_trans_unstable(pmd))
3220 + return 0;
3221 /*
3222 * The mmap_sem held all the way back in m_start() is what
3223 * keeps khugepaged out of here and from collapsing things
3224 @@ -505,6 +508,8 @@ static int clear_refs_pte_range(pmd_t *pmd, unsigned long addr,
3225 struct page *page;
3226
3227 split_huge_page_pmd(walk->mm, pmd);
3228 + if (pmd_trans_unstable(pmd))
3229 + return 0;
3230
3231 pte = pte_offset_map_lock(vma->vm_mm, pmd, addr, &ptl);
3232 for (; addr != end; pte++, addr += PAGE_SIZE) {
3233 @@ -668,6 +673,8 @@ static int pagemap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end,
3234 int err = 0;
3235
3236 split_huge_page_pmd(walk->mm, pmd);
3237 + if (pmd_trans_unstable(pmd))
3238 + return 0;
3239
3240 /* find the first VMA at or above 'addr' */
3241 vma = find_vma(walk->mm, addr);
3242 @@ -959,6 +966,8 @@ static int gather_pte_stats(pmd_t *pmd, unsigned long addr,
3243 spin_unlock(&walk->mm->page_table_lock);
3244 }
3245
3246 + if (pmd_trans_unstable(pmd))
3247 + return 0;
3248 orig_pte = pte = pte_offset_map_lock(walk->mm, pmd, addr, &ptl);
3249 do {
3250 struct page *page = can_gather_numa_stats(*pte, md->vma, addr);
3251 diff --git a/fs/sysfs/inode.c b/fs/sysfs/inode.c
3252 index 0a12eb8..a494413 100644
3253 --- a/fs/sysfs/inode.c
3254 +++ b/fs/sysfs/inode.c
3255 @@ -136,12 +136,13 @@ static int sysfs_sd_setsecdata(struct sysfs_dirent *sd, void **secdata, u32 *sec
3256 void *old_secdata;
3257 size_t old_secdata_len;
3258
3259 - iattrs = sd->s_iattr;
3260 - if (!iattrs)
3261 - iattrs = sysfs_init_inode_attrs(sd);
3262 - if (!iattrs)
3263 - return -ENOMEM;
3264 + if (!sd->s_iattr) {
3265 + sd->s_iattr = sysfs_init_inode_attrs(sd);
3266 + if (!sd->s_iattr)
3267 + return -ENOMEM;
3268 + }
3269
3270 + iattrs = sd->s_iattr;
3271 old_secdata = iattrs->ia_secdata;
3272 old_secdata_len = iattrs->ia_secdata_len;
3273
3274 diff --git a/fs/udf/file.c b/fs/udf/file.c
3275 index 0c0c9d3..3438b00 100644
3276 --- a/fs/udf/file.c
3277 +++ b/fs/udf/file.c
3278 @@ -201,12 +201,10 @@ out:
3279 static int udf_release_file(struct inode *inode, struct file *filp)
3280 {
3281 if (filp->f_mode & FMODE_WRITE) {
3282 - mutex_lock(&inode->i_mutex);
3283 down_write(&UDF_I(inode)->i_data_sem);
3284 udf_discard_prealloc(inode);
3285 udf_truncate_tail_extent(inode);
3286 up_write(&UDF_I(inode)->i_data_sem);
3287 - mutex_unlock(&inode->i_mutex);
3288 }
3289 return 0;
3290 }
3291 diff --git a/fs/xfs/xfs_iget.c b/fs/xfs/xfs_iget.c
3292 index 3631783..ca752f0 100644
3293 --- a/fs/xfs/xfs_iget.c
3294 +++ b/fs/xfs/xfs_iget.c
3295 @@ -356,9 +356,20 @@ xfs_iget_cache_miss(
3296 BUG();
3297 }
3298
3299 - spin_lock(&pag->pag_ici_lock);
3300 + /*
3301 + * These values must be set before inserting the inode into the radix
3302 + * tree as the moment it is inserted a concurrent lookup (allowed by the
3303 + * RCU locking mechanism) can find it and that lookup must see that this
3304 + * is an inode currently under construction (i.e. that XFS_INEW is set).
3305 + * The ip->i_flags_lock that protects the XFS_INEW flag forms the
3306 + * memory barrier that ensures this detection works correctly at lookup
3307 + * time.
3308 + */
3309 + ip->i_udquot = ip->i_gdquot = NULL;
3310 + xfs_iflags_set(ip, XFS_INEW);
3311
3312 /* insert the new inode */
3313 + spin_lock(&pag->pag_ici_lock);
3314 error = radix_tree_insert(&pag->pag_ici_root, agino, ip);
3315 if (unlikely(error)) {
3316 WARN_ON(error != -EEXIST);
3317 @@ -366,11 +377,6 @@ xfs_iget_cache_miss(
3318 error = EAGAIN;
3319 goto out_preload_end;
3320 }
3321 -
3322 - /* These values _must_ be set before releasing the radix tree lock! */
3323 - ip->i_udquot = ip->i_gdquot = NULL;
3324 - xfs_iflags_set(ip, XFS_INEW);
3325 -
3326 spin_unlock(&pag->pag_ici_lock);
3327 radix_tree_preload_end();
3328
3329 diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
3330 index 04142ca..b75fd67 100644
3331 --- a/fs/xfs/xfs_log_recover.c
3332 +++ b/fs/xfs/xfs_log_recover.c
3333 @@ -3159,37 +3159,26 @@ xlog_recover_process_iunlinks(
3334 */
3335 continue;
3336 }
3337 + /*
3338 + * Unlock the buffer so that it can be acquired in the normal
3339 + * course of the transaction to truncate and free each inode.
3340 + * Because we are not racing with anyone else here for the AGI
3341 + * buffer, we don't even need to hold it locked to read the
3342 + * initial unlinked bucket entries out of the buffer. We keep
3343 + * buffer reference though, so that it stays pinned in memory
3344 + * while we need the buffer.
3345 + */
3346 agi = XFS_BUF_TO_AGI(agibp);
3347 + xfs_buf_unlock(agibp);
3348
3349 for (bucket = 0; bucket < XFS_AGI_UNLINKED_BUCKETS; bucket++) {
3350 agino = be32_to_cpu(agi->agi_unlinked[bucket]);
3351 while (agino != NULLAGINO) {
3352 - /*
3353 - * Release the agi buffer so that it can
3354 - * be acquired in the normal course of the
3355 - * transaction to truncate and free the inode.
3356 - */
3357 - xfs_buf_relse(agibp);
3358 -
3359 agino = xlog_recover_process_one_iunlink(mp,
3360 agno, agino, bucket);
3361 -
3362 - /*
3363 - * Reacquire the agibuffer and continue around
3364 - * the loop. This should never fail as we know
3365 - * the buffer was good earlier on.
3366 - */
3367 - error = xfs_read_agi(mp, NULL, agno, &agibp);
3368 - ASSERT(error == 0);
3369 - agi = XFS_BUF_TO_AGI(agibp);
3370 }
3371 }
3372 -
3373 - /*
3374 - * Release the buffer for the current agi so we can
3375 - * go on to the next one.
3376 - */
3377 - xfs_buf_relse(agibp);
3378 + xfs_buf_rele(agibp);
3379 }
3380
3381 mp->m_dmevmask = mp_dmevmask;
3382 diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
3383 index 76bff2b..a03c098 100644
3384 --- a/include/asm-generic/pgtable.h
3385 +++ b/include/asm-generic/pgtable.h
3386 @@ -425,6 +425,8 @@ extern void untrack_pfn_vma(struct vm_area_struct *vma, unsigned long pfn,
3387 unsigned long size);
3388 #endif
3389
3390 +#ifdef CONFIG_MMU
3391 +
3392 #ifndef CONFIG_TRANSPARENT_HUGEPAGE
3393 static inline int pmd_trans_huge(pmd_t pmd)
3394 {
3395 @@ -441,7 +443,66 @@ static inline int pmd_write(pmd_t pmd)
3396 return 0;
3397 }
3398 #endif /* __HAVE_ARCH_PMD_WRITE */
3399 +#endif /* CONFIG_TRANSPARENT_HUGEPAGE */
3400 +
3401 +/*
3402 + * This function is meant to be used by sites walking pagetables with
3403 + * the mmap_sem hold in read mode to protect against MADV_DONTNEED and
3404 + * transhuge page faults. MADV_DONTNEED can convert a transhuge pmd
3405 + * into a null pmd and the transhuge page fault can convert a null pmd
3406 + * into an hugepmd or into a regular pmd (if the hugepage allocation
3407 + * fails). While holding the mmap_sem in read mode the pmd becomes
3408 + * stable and stops changing under us only if it's not null and not a
3409 + * transhuge pmd. When those races occurs and this function makes a
3410 + * difference vs the standard pmd_none_or_clear_bad, the result is
3411 + * undefined so behaving like if the pmd was none is safe (because it
3412 + * can return none anyway). The compiler level barrier() is critically
3413 + * important to compute the two checks atomically on the same pmdval.
3414 + */
3415 +static inline int pmd_none_or_trans_huge_or_clear_bad(pmd_t *pmd)
3416 +{
3417 + /* depend on compiler for an atomic pmd read */
3418 + pmd_t pmdval = *pmd;
3419 + /*
3420 + * The barrier will stabilize the pmdval in a register or on
3421 + * the stack so that it will stop changing under the code.
3422 + */
3423 +#ifdef CONFIG_TRANSPARENT_HUGEPAGE
3424 + barrier();
3425 +#endif
3426 + if (pmd_none(pmdval))
3427 + return 1;
3428 + if (unlikely(pmd_bad(pmdval))) {
3429 + if (!pmd_trans_huge(pmdval))
3430 + pmd_clear_bad(pmd);
3431 + return 1;
3432 + }
3433 + return 0;
3434 +}
3435 +
3436 +/*
3437 + * This is a noop if Transparent Hugepage Support is not built into
3438 + * the kernel. Otherwise it is equivalent to
3439 + * pmd_none_or_trans_huge_or_clear_bad(), and shall only be called in
3440 + * places that already verified the pmd is not none and they want to
3441 + * walk ptes while holding the mmap sem in read mode (write mode don't
3442 + * need this). If THP is not enabled, the pmd can't go away under the
3443 + * code even if MADV_DONTNEED runs, but if THP is enabled we need to
3444 + * run a pmd_trans_unstable before walking the ptes after
3445 + * split_huge_page_pmd returns (because it may have run when the pmd
3446 + * become null, but then a page fault can map in a THP and not a
3447 + * regular page).
3448 + */
3449 +static inline int pmd_trans_unstable(pmd_t *pmd)
3450 +{
3451 +#ifdef CONFIG_TRANSPARENT_HUGEPAGE
3452 + return pmd_none_or_trans_huge_or_clear_bad(pmd);
3453 +#else
3454 + return 0;
3455 #endif
3456 +}
3457 +
3458 +#endif /* CONFIG_MMU */
3459
3460 #endif /* !__ASSEMBLY__ */
3461
3462 diff --git a/include/asm-generic/unistd.h b/include/asm-generic/unistd.h
3463 index 4f769593..5518963 100644
3464 --- a/include/asm-generic/unistd.h
3465 +++ b/include/asm-generic/unistd.h
3466 @@ -218,7 +218,7 @@ __SC_COMP(__NR_pwritev, sys_pwritev, compat_sys_pwritev)
3467
3468 /* fs/sendfile.c */
3469 #define __NR3264_sendfile 71
3470 -__SC_3264(__NR3264_sendfile, sys_sendfile64, sys_sendfile)
3471 +__SYSCALL(__NR3264_sendfile, sys_sendfile64)
3472
3473 /* fs/select.c */
3474 #define __NR_pselect6 72
3475 diff --git a/include/linux/fb.h b/include/linux/fb.h
3476 index 6a82748..f9d013d 100644
3477 --- a/include/linux/fb.h
3478 +++ b/include/linux/fb.h
3479 @@ -997,6 +997,7 @@ extern ssize_t fb_sys_write(struct fb_info *info, const char __user *buf,
3480 /* drivers/video/fbmem.c */
3481 extern int register_framebuffer(struct fb_info *fb_info);
3482 extern int unregister_framebuffer(struct fb_info *fb_info);
3483 +extern int unlink_framebuffer(struct fb_info *fb_info);
3484 extern void remove_conflicting_framebuffers(struct apertures_struct *a,
3485 const char *name, bool primary);
3486 extern int fb_prepare_logo(struct fb_info *fb_info, int rotate);
3487 diff --git a/include/linux/math64.h b/include/linux/math64.h
3488 index 23fcdfc..b8ba855 100644
3489 --- a/include/linux/math64.h
3490 +++ b/include/linux/math64.h
3491 @@ -6,6 +6,8 @@
3492
3493 #if BITS_PER_LONG == 64
3494
3495 +#define div64_long(x,y) div64_s64((x),(y))
3496 +
3497 /**
3498 * div_u64_rem - unsigned 64bit divide with 32bit divisor with remainder
3499 *
3500 @@ -45,6 +47,8 @@ static inline s64 div64_s64(s64 dividend, s64 divisor)
3501
3502 #elif BITS_PER_LONG == 32
3503
3504 +#define div64_long(x,y) div_s64((x),(y))
3505 +
3506 #ifndef div_u64_rem
3507 static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
3508 {
3509 diff --git a/kernel/futex.c b/kernel/futex.c
3510 index 6487e4c..a2a01ef 100644
3511 --- a/kernel/futex.c
3512 +++ b/kernel/futex.c
3513 @@ -2641,6 +2641,16 @@ long do_futex(u32 __user *uaddr, int op, u32 val, ktime_t *timeout,
3514 }
3515
3516 switch (cmd) {
3517 + case FUTEX_LOCK_PI:
3518 + case FUTEX_UNLOCK_PI:
3519 + case FUTEX_TRYLOCK_PI:
3520 + case FUTEX_WAIT_REQUEUE_PI:
3521 + case FUTEX_CMP_REQUEUE_PI:
3522 + if (!futex_cmpxchg_enabled)
3523 + return -ENOSYS;
3524 + }
3525 +
3526 + switch (cmd) {
3527 case FUTEX_WAIT:
3528 val3 = FUTEX_BITSET_MATCH_ANY;
3529 case FUTEX_WAIT_BITSET:
3530 @@ -2661,16 +2671,13 @@ long do_futex(u32 __user *uaddr, int op, u32 val, ktime_t *timeout,
3531 ret = futex_wake_op(uaddr, flags, uaddr2, val, val2, val3);
3532 break;
3533 case FUTEX_LOCK_PI:
3534 - if (futex_cmpxchg_enabled)
3535 - ret = futex_lock_pi(uaddr, flags, val, timeout, 0);
3536 + ret = futex_lock_pi(uaddr, flags, val, timeout, 0);
3537 break;
3538 case FUTEX_UNLOCK_PI:
3539 - if (futex_cmpxchg_enabled)
3540 - ret = futex_unlock_pi(uaddr, flags);
3541 + ret = futex_unlock_pi(uaddr, flags);
3542 break;
3543 case FUTEX_TRYLOCK_PI:
3544 - if (futex_cmpxchg_enabled)
3545 - ret = futex_lock_pi(uaddr, flags, 0, timeout, 1);
3546 + ret = futex_lock_pi(uaddr, flags, 0, timeout, 1);
3547 break;
3548 case FUTEX_WAIT_REQUEUE_PI:
3549 val3 = FUTEX_BITSET_MATCH_ANY;
3550 diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c
3551 index ca14f5d..990965e 100644
3552 --- a/kernel/irq/chip.c
3553 +++ b/kernel/irq/chip.c
3554 @@ -61,8 +61,7 @@ int irq_set_irq_type(unsigned int irq, unsigned int type)
3555 return -EINVAL;
3556
3557 type &= IRQ_TYPE_SENSE_MASK;
3558 - if (type != IRQ_TYPE_NONE)
3559 - ret = __irq_set_trigger(desc, irq, type);
3560 + ret = __irq_set_trigger(desc, irq, type);
3561 irq_put_desc_busunlock(desc, flags);
3562 return ret;
3563 }
3564 diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
3565 index e4eedb1..df8136f 100644
3566 --- a/kernel/irq/manage.c
3567 +++ b/kernel/irq/manage.c
3568 @@ -770,7 +770,7 @@ static int irq_thread(void *data)
3569 struct irqaction *action);
3570 int wake;
3571
3572 - if (force_irqthreads & test_bit(IRQTF_FORCED_THREAD,
3573 + if (force_irqthreads && test_bit(IRQTF_FORCED_THREAD,
3574 &action->thread_flags))
3575 handler_fn = irq_forced_thread_fn;
3576 else
3577 diff --git a/kernel/module.c b/kernel/module.c
3578 index 795bdc7..b9d0667 100644
3579 --- a/kernel/module.c
3580 +++ b/kernel/module.c
3581 @@ -2290,8 +2290,7 @@ static int copy_and_check(struct load_info *info,
3582 return -ENOEXEC;
3583
3584 /* Suck in entire file: we'll want most of it. */
3585 - /* vmalloc barfs on "unusual" numbers. Check here */
3586 - if (len > 64 * 1024 * 1024 || (hdr = vmalloc(len)) == NULL)
3587 + if ((hdr = vmalloc(len)) == NULL)
3588 return -ENOMEM;
3589
3590 if (copy_from_user(hdr, umod, len) != 0) {
3591 diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
3592 index 8f7b1db..8884c27 100644
3593 --- a/kernel/power/hibernate.c
3594 +++ b/kernel/power/hibernate.c
3595 @@ -623,7 +623,7 @@ int hibernate(void)
3596 /* Allocate memory management structures */
3597 error = create_basic_memory_bitmaps();
3598 if (error)
3599 - goto Exit;
3600 + goto Enable_umh;
3601
3602 printk(KERN_INFO "PM: Syncing filesystems ... ");
3603 sys_sync();
3604 @@ -631,7 +631,7 @@ int hibernate(void)
3605
3606 error = prepare_processes();
3607 if (error)
3608 - goto Finish;
3609 + goto Free_bitmaps;
3610
3611 if (hibernation_test(TEST_FREEZER))
3612 goto Thaw;
3613 @@ -663,8 +663,9 @@ int hibernate(void)
3614
3615 Thaw:
3616 thaw_processes();
3617 - Finish:
3618 + Free_bitmaps:
3619 free_basic_memory_bitmaps();
3620 + Enable_umh:
3621 usermodehelper_enable();
3622 Exit:
3623 pm_notifier_call_chain(PM_POST_HIBERNATION);
3624 diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
3625 index f6117a4..4b85a7a 100644
3626 --- a/kernel/time/ntp.c
3627 +++ b/kernel/time/ntp.c
3628 @@ -275,7 +275,7 @@ static inline s64 ntp_update_offset_fll(s64 offset64, long secs)
3629
3630 time_status |= STA_MODE;
3631
3632 - return div_s64(offset64 << (NTP_SCALE_SHIFT - SHIFT_FLL), secs);
3633 + return div64_long(offset64 << (NTP_SCALE_SHIFT - SHIFT_FLL), secs);
3634 }
3635
3636 static void ntp_update_offset(long offset)
3637 diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c
3638 index ad72a03..6d40244 100644
3639 --- a/lib/kobject_uevent.c
3640 +++ b/lib/kobject_uevent.c
3641 @@ -29,16 +29,17 @@
3642
3643 u64 uevent_seqnum;
3644 char uevent_helper[UEVENT_HELPER_PATH_LEN] = CONFIG_UEVENT_HELPER_PATH;
3645 -static DEFINE_SPINLOCK(sequence_lock);
3646 #ifdef CONFIG_NET
3647 struct uevent_sock {
3648 struct list_head list;
3649 struct sock *sk;
3650 };
3651 static LIST_HEAD(uevent_sock_list);
3652 -static DEFINE_MUTEX(uevent_sock_mutex);
3653 #endif
3654
3655 +/* This lock protects uevent_seqnum and uevent_sock_list */
3656 +static DEFINE_MUTEX(uevent_sock_mutex);
3657 +
3658 /* the strings here must match the enum in include/linux/kobject.h */
3659 static const char *kobject_actions[] = {
3660 [KOBJ_ADD] = "add",
3661 @@ -136,7 +137,6 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
3662 struct kobject *top_kobj;
3663 struct kset *kset;
3664 const struct kset_uevent_ops *uevent_ops;
3665 - u64 seq;
3666 int i = 0;
3667 int retval = 0;
3668 #ifdef CONFIG_NET
3669 @@ -243,17 +243,16 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
3670 else if (action == KOBJ_REMOVE)
3671 kobj->state_remove_uevent_sent = 1;
3672
3673 + mutex_lock(&uevent_sock_mutex);
3674 /* we will send an event, so request a new sequence number */
3675 - spin_lock(&sequence_lock);
3676 - seq = ++uevent_seqnum;
3677 - spin_unlock(&sequence_lock);
3678 - retval = add_uevent_var(env, "SEQNUM=%llu", (unsigned long long)seq);
3679 - if (retval)
3680 + retval = add_uevent_var(env, "SEQNUM=%llu", (unsigned long long)++uevent_seqnum);
3681 + if (retval) {
3682 + mutex_unlock(&uevent_sock_mutex);
3683 goto exit;
3684 + }
3685
3686 #if defined(CONFIG_NET)
3687 /* send netlink message */
3688 - mutex_lock(&uevent_sock_mutex);
3689 list_for_each_entry(ue_sk, &uevent_sock_list, list) {
3690 struct sock *uevent_sock = ue_sk->sk;
3691 struct sk_buff *skb;
3692 @@ -287,8 +286,8 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
3693 } else
3694 retval = -ENOMEM;
3695 }
3696 - mutex_unlock(&uevent_sock_mutex);
3697 #endif
3698 + mutex_unlock(&uevent_sock_mutex);
3699
3700 /* call uevent_helper, usually only enabled during early boot */
3701 if (uevent_helper[0] && !kobj_usermode_filter(kobj)) {
3702 diff --git a/mm/bootmem.c b/mm/bootmem.c
3703 index 01d5a4b3..9686c4e 100644
3704 --- a/mm/bootmem.c
3705 +++ b/mm/bootmem.c
3706 @@ -768,14 +768,13 @@ void * __init alloc_bootmem_section(unsigned long size,
3707 unsigned long section_nr)
3708 {
3709 bootmem_data_t *bdata;
3710 - unsigned long pfn, goal, limit;
3711 + unsigned long pfn, goal;
3712
3713 pfn = section_nr_to_pfn(section_nr);
3714 goal = pfn << PAGE_SHIFT;
3715 - limit = section_nr_to_pfn(section_nr + 1) << PAGE_SHIFT;
3716 bdata = &bootmem_node_data[early_pfn_to_nid(pfn)];
3717
3718 - return alloc_bootmem_core(bdata, size, SMP_CACHE_BYTES, goal, limit);
3719 + return alloc_bootmem_core(bdata, size, SMP_CACHE_BYTES, goal, 0);
3720 }
3721 #endif
3722
3723 diff --git a/mm/memcontrol.c b/mm/memcontrol.c
3724 index 45059db..283068f 100644
3725 --- a/mm/memcontrol.c
3726 +++ b/mm/memcontrol.c
3727 @@ -5290,6 +5290,8 @@ static int mem_cgroup_count_precharge_pte_range(pmd_t *pmd,
3728 spinlock_t *ptl;
3729
3730 split_huge_page_pmd(walk->mm, pmd);
3731 + if (pmd_trans_unstable(pmd))
3732 + return 0;
3733
3734 pte = pte_offset_map_lock(vma->vm_mm, pmd, addr, &ptl);
3735 for (; addr != end; pte++, addr += PAGE_SIZE)
3736 @@ -5451,6 +5453,8 @@ static int mem_cgroup_move_charge_pte_range(pmd_t *pmd,
3737 spinlock_t *ptl;
3738
3739 split_huge_page_pmd(walk->mm, pmd);
3740 + if (pmd_trans_unstable(pmd))
3741 + return 0;
3742 retry:
3743 pte = pte_offset_map_lock(vma->vm_mm, pmd, addr, &ptl);
3744 for (; addr != end; addr += PAGE_SIZE) {
3745 diff --git a/mm/memory.c b/mm/memory.c
3746 index 95a7799..d49b58a 100644
3747 --- a/mm/memory.c
3748 +++ b/mm/memory.c
3749 @@ -1228,16 +1228,24 @@ static inline unsigned long zap_pmd_range(struct mmu_gather *tlb,
3750 do {
3751 next = pmd_addr_end(addr, end);
3752 if (pmd_trans_huge(*pmd)) {
3753 - if (next-addr != HPAGE_PMD_SIZE) {
3754 + if (next - addr != HPAGE_PMD_SIZE) {
3755 VM_BUG_ON(!rwsem_is_locked(&tlb->mm->mmap_sem));
3756 split_huge_page_pmd(vma->vm_mm, pmd);
3757 } else if (zap_huge_pmd(tlb, vma, pmd))
3758 - continue;
3759 + goto next;
3760 /* fall through */
3761 }
3762 - if (pmd_none_or_clear_bad(pmd))
3763 - continue;
3764 + /*
3765 + * Here there can be other concurrent MADV_DONTNEED or
3766 + * trans huge page faults running, and if the pmd is
3767 + * none or trans huge it can change under us. This is
3768 + * because MADV_DONTNEED holds the mmap_sem in read
3769 + * mode.
3770 + */
3771 + if (pmd_none_or_trans_huge_or_clear_bad(pmd))
3772 + goto next;
3773 next = zap_pte_range(tlb, vma, pmd, addr, next, details);
3774 +next:
3775 cond_resched();
3776 } while (pmd++, addr = next, addr != end);
3777
3778 diff --git a/mm/mempolicy.c b/mm/mempolicy.c
3779 index e7fb9d2..a85171d 100644
3780 --- a/mm/mempolicy.c
3781 +++ b/mm/mempolicy.c
3782 @@ -511,7 +511,7 @@ static inline int check_pmd_range(struct vm_area_struct *vma, pud_t *pud,
3783 do {
3784 next = pmd_addr_end(addr, end);
3785 split_huge_page_pmd(vma->vm_mm, pmd);
3786 - if (pmd_none_or_clear_bad(pmd))
3787 + if (pmd_none_or_trans_huge_or_clear_bad(pmd))
3788 continue;
3789 if (check_pte_range(vma, pmd, addr, next, nodes,
3790 flags, private))
3791 diff --git a/mm/mincore.c b/mm/mincore.c
3792 index a4e6b9d..117ff54 100644
3793 --- a/mm/mincore.c
3794 +++ b/mm/mincore.c
3795 @@ -161,7 +161,7 @@ static void mincore_pmd_range(struct vm_area_struct *vma, pud_t *pud,
3796 }
3797 /* fall through */
3798 }
3799 - if (pmd_none_or_clear_bad(pmd))
3800 + if (pmd_none_or_trans_huge_or_clear_bad(pmd))
3801 mincore_unmapped_range(vma, addr, next, vec);
3802 else
3803 mincore_pte_range(vma, pmd, addr, next, vec);
3804 diff --git a/mm/pagewalk.c b/mm/pagewalk.c
3805 index c3450d5..87eac0e 100644
3806 --- a/mm/pagewalk.c
3807 +++ b/mm/pagewalk.c
3808 @@ -59,7 +59,7 @@ again:
3809 continue;
3810
3811 split_huge_page_pmd(walk->mm, pmd);
3812 - if (pmd_none_or_clear_bad(pmd))
3813 + if (pmd_none_or_trans_huge_or_clear_bad(pmd))
3814 goto again;
3815 err = walk_pte_range(pmd, addr, next, walk);
3816 if (err)
3817 diff --git a/mm/slub.c b/mm/slub.c
3818 index 0d0901e..10ab233 100644
3819 --- a/mm/slub.c
3820 +++ b/mm/slub.c
3821 @@ -3439,13 +3439,14 @@ struct kmem_cache *kmem_cache_create(const char *name, size_t size,
3822 if (kmem_cache_open(s, n,
3823 size, align, flags, ctor)) {
3824 list_add(&s->list, &slab_caches);
3825 + up_write(&slub_lock);
3826 if (sysfs_slab_add(s)) {
3827 + down_write(&slub_lock);
3828 list_del(&s->list);
3829 kfree(n);
3830 kfree(s);
3831 goto err;
3832 }
3833 - up_write(&slub_lock);
3834 return s;
3835 }
3836 kfree(n);
3837 diff --git a/mm/sparse.c b/mm/sparse.c
3838 index aa64b12..4cd05e5 100644
3839 --- a/mm/sparse.c
3840 +++ b/mm/sparse.c
3841 @@ -353,29 +353,21 @@ static void __init sparse_early_usemaps_alloc_node(unsigned long**usemap_map,
3842
3843 usemap = sparse_early_usemaps_alloc_pgdat_section(NODE_DATA(nodeid),
3844 usemap_count);
3845 - if (usemap) {
3846 - for (pnum = pnum_begin; pnum < pnum_end; pnum++) {
3847 - if (!present_section_nr(pnum))
3848 - continue;
3849 - usemap_map[pnum] = usemap;
3850 - usemap += size;
3851 + if (!usemap) {
3852 + usemap = alloc_bootmem_node(NODE_DATA(nodeid), size * usemap_count);
3853 + if (!usemap) {
3854 + printk(KERN_WARNING "%s: allocation failed\n", __func__);
3855 + return;
3856 }
3857 - return;
3858 }
3859
3860 - usemap = alloc_bootmem_node(NODE_DATA(nodeid), size * usemap_count);
3861 - if (usemap) {
3862 - for (pnum = pnum_begin; pnum < pnum_end; pnum++) {
3863 - if (!present_section_nr(pnum))
3864 - continue;
3865 - usemap_map[pnum] = usemap;
3866 - usemap += size;
3867 - check_usemap_section_nr(nodeid, usemap_map[pnum]);
3868 - }
3869 - return;
3870 + for (pnum = pnum_begin; pnum < pnum_end; pnum++) {
3871 + if (!present_section_nr(pnum))
3872 + continue;
3873 + usemap_map[pnum] = usemap;
3874 + usemap += size;
3875 + check_usemap_section_nr(nodeid, usemap_map[pnum]);
3876 }
3877 -
3878 - printk(KERN_WARNING "%s: allocation failed\n", __func__);
3879 }
3880
3881 #ifndef CONFIG_SPARSEMEM_VMEMMAP
3882 diff --git a/mm/swapfile.c b/mm/swapfile.c
3883 index ff8dc1a..c8f4338 100644
3884 --- a/mm/swapfile.c
3885 +++ b/mm/swapfile.c
3886 @@ -932,9 +932,7 @@ static inline int unuse_pmd_range(struct vm_area_struct *vma, pud_t *pud,
3887 pmd = pmd_offset(pud, addr);
3888 do {
3889 next = pmd_addr_end(addr, end);
3890 - if (unlikely(pmd_trans_huge(*pmd)))
3891 - continue;
3892 - if (pmd_none_or_clear_bad(pmd))
3893 + if (pmd_none_or_trans_huge_or_clear_bad(pmd))
3894 continue;
3895 ret = unuse_pte_range(vma, pmd, addr, next, entry, page);
3896 if (ret)
3897 diff --git a/net/core/dev.c b/net/core/dev.c
3898 index 17fdbf8..f134f88 100644
3899 --- a/net/core/dev.c
3900 +++ b/net/core/dev.c
3901 @@ -3504,7 +3504,8 @@ EXPORT_SYMBOL(napi_gro_receive);
3902 static void napi_reuse_skb(struct napi_struct *napi, struct sk_buff *skb)
3903 {
3904 __skb_pull(skb, skb_headlen(skb));
3905 - skb_reserve(skb, NET_IP_ALIGN - skb_headroom(skb));
3906 + /* restore the reserve we had after netdev_alloc_skb_ip_align() */
3907 + skb_reserve(skb, NET_SKB_PAD + NET_IP_ALIGN - skb_headroom(skb));
3908 skb->vlan_tci = 0;
3909 skb->dev = napi->dev;
3910 skb->skb_iif = 0;
3911 diff --git a/net/ipv6/route.c b/net/ipv6/route.c
3912 index e70e902..8e600f8 100644
3913 --- a/net/ipv6/route.c
3914 +++ b/net/ipv6/route.c
3915 @@ -2411,8 +2411,12 @@ static int rt6_fill_node(struct net *net,
3916
3917 rcu_read_lock();
3918 n = dst_get_neighbour(&rt->dst);
3919 - if (n)
3920 - NLA_PUT(skb, RTA_GATEWAY, 16, &n->primary_key);
3921 + if (n) {
3922 + if (nla_put(skb, RTA_GATEWAY, 16, &n->primary_key) < 0) {
3923 + rcu_read_unlock();
3924 + goto nla_put_failure;
3925 + }
3926 + }
3927 rcu_read_unlock();
3928
3929 if (rt->dst.dev)
3930 diff --git a/net/l2tp/l2tp_ppp.c b/net/l2tp/l2tp_ppp.c
3931 index 39a21d0..13f9868 100644
3932 --- a/net/l2tp/l2tp_ppp.c
3933 +++ b/net/l2tp/l2tp_ppp.c
3934 @@ -908,7 +908,7 @@ static int pppol2tp_getname(struct socket *sock, struct sockaddr *uaddr,
3935 goto end_put_sess;
3936 }
3937
3938 - inet = inet_sk(sk);
3939 + inet = inet_sk(tunnel->sock);
3940 if (tunnel->version == 2) {
3941 struct sockaddr_pppol2tp sp;
3942 len = sizeof(sp);
3943 diff --git a/net/rds/send.c b/net/rds/send.c
3944 index d58ae5f..c803341 100644
3945 --- a/net/rds/send.c
3946 +++ b/net/rds/send.c
3947 @@ -932,7 +932,6 @@ int rds_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg,
3948 /* Mirror Linux UDP mirror of BSD error message compatibility */
3949 /* XXX: Perhaps MSG_MORE someday */
3950 if (msg->msg_flags & ~(MSG_DONTWAIT | MSG_CMSG_COMPAT)) {
3951 - printk(KERN_INFO "msg_flags 0x%08X\n", msg->msg_flags);
3952 ret = -EOPNOTSUPP;
3953 goto out;
3954 }
3955 diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c
3956 index 72ad836..4530a91 100644
3957 --- a/net/sunrpc/cache.c
3958 +++ b/net/sunrpc/cache.c
3959 @@ -828,6 +828,8 @@ static ssize_t cache_do_downcall(char *kaddr, const char __user *buf,
3960 {
3961 ssize_t ret;
3962
3963 + if (count == 0)
3964 + return -EINVAL;
3965 if (copy_from_user(kaddr, buf, count))
3966 return -EFAULT;
3967 kaddr[count] = '\0';
3968 diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
3969 index 4814e24..b6bb225 100644
3970 --- a/net/sunrpc/sched.c
3971 +++ b/net/sunrpc/sched.c
3972 @@ -480,14 +480,18 @@ EXPORT_SYMBOL_GPL(rpc_wake_up_next);
3973 */
3974 void rpc_wake_up(struct rpc_wait_queue *queue)
3975 {
3976 - struct rpc_task *task, *next;
3977 struct list_head *head;
3978
3979 spin_lock_bh(&queue->lock);
3980 head = &queue->tasks[queue->maxpriority];
3981 for (;;) {
3982 - list_for_each_entry_safe(task, next, head, u.tk_wait.list)
3983 + while (!list_empty(head)) {
3984 + struct rpc_task *task;
3985 + task = list_first_entry(head,
3986 + struct rpc_task,
3987 + u.tk_wait.list);
3988 rpc_wake_up_task_queue_locked(queue, task);
3989 + }
3990 if (head == &queue->tasks[0])
3991 break;
3992 head--;
3993 @@ -505,13 +509,16 @@ EXPORT_SYMBOL_GPL(rpc_wake_up);
3994 */
3995 void rpc_wake_up_status(struct rpc_wait_queue *queue, int status)
3996 {
3997 - struct rpc_task *task, *next;
3998 struct list_head *head;
3999
4000 spin_lock_bh(&queue->lock);
4001 head = &queue->tasks[queue->maxpriority];
4002 for (;;) {
4003 - list_for_each_entry_safe(task, next, head, u.tk_wait.list) {
4004 + while (!list_empty(head)) {
4005 + struct rpc_task *task;
4006 + task = list_first_entry(head,
4007 + struct rpc_task,
4008 + u.tk_wait.list);
4009 task->tk_status = status;
4010 rpc_wake_up_task_queue_locked(queue, task);
4011 }
4012 diff --git a/net/xfrm/xfrm_replay.c b/net/xfrm/xfrm_replay.c
4013 index b11ea69..3235023 100644
4014 --- a/net/xfrm/xfrm_replay.c
4015 +++ b/net/xfrm/xfrm_replay.c
4016 @@ -166,7 +166,7 @@ static void xfrm_replay_advance(struct xfrm_state *x, __be32 net_seq)
4017 }
4018
4019 if (xfrm_aevent_is_on(xs_net(x)))
4020 - xfrm_replay_notify(x, XFRM_REPLAY_UPDATE);
4021 + x->repl->notify(x, XFRM_REPLAY_UPDATE);
4022 }
4023
4024 static int xfrm_replay_overflow_bmp(struct xfrm_state *x, struct sk_buff *skb)
4025 @@ -293,7 +293,7 @@ static void xfrm_replay_advance_bmp(struct xfrm_state *x, __be32 net_seq)
4026 }
4027
4028 if (xfrm_aevent_is_on(xs_net(x)))
4029 - xfrm_replay_notify(x, XFRM_REPLAY_UPDATE);
4030 + x->repl->notify(x, XFRM_REPLAY_UPDATE);
4031 }
4032
4033 static void xfrm_replay_notify_bmp(struct xfrm_state *x, int event)
4034 @@ -502,7 +502,7 @@ static void xfrm_replay_advance_esn(struct xfrm_state *x, __be32 net_seq)
4035 }
4036
4037 if (xfrm_aevent_is_on(xs_net(x)))
4038 - xfrm_replay_notify(x, XFRM_REPLAY_UPDATE);
4039 + x->repl->notify(x, XFRM_REPLAY_UPDATE);
4040 }
4041
4042 static struct xfrm_replay xfrm_replay_legacy = {
4043 diff --git a/sound/soc/pxa/pxa-ssp.c b/sound/soc/pxa/pxa-ssp.c
4044 index 8ad93ee..b583e60 100644
4045 --- a/sound/soc/pxa/pxa-ssp.c
4046 +++ b/sound/soc/pxa/pxa-ssp.c
4047 @@ -668,6 +668,38 @@ static int pxa_ssp_hw_params(struct snd_pcm_substream *substream,
4048 return 0;
4049 }
4050
4051 +static void pxa_ssp_set_running_bit(struct snd_pcm_substream *substream,
4052 + struct ssp_device *ssp, int value)
4053 +{
4054 + uint32_t sscr0 = pxa_ssp_read_reg(ssp, SSCR0);
4055 + uint32_t sscr1 = pxa_ssp_read_reg(ssp, SSCR1);
4056 + uint32_t sspsp = pxa_ssp_read_reg(ssp, SSPSP);
4057 + uint32_t sssr = pxa_ssp_read_reg(ssp, SSSR);
4058 +
4059 + if (value && (sscr0 & SSCR0_SSE))
4060 + pxa_ssp_write_reg(ssp, SSCR0, sscr0 & ~SSCR0_SSE);
4061 +
4062 + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
4063 + if (value)
4064 + sscr1 |= SSCR1_TSRE;
4065 + else
4066 + sscr1 &= ~SSCR1_TSRE;
4067 + } else {
4068 + if (value)
4069 + sscr1 |= SSCR1_RSRE;
4070 + else
4071 + sscr1 &= ~SSCR1_RSRE;
4072 + }
4073 +
4074 + pxa_ssp_write_reg(ssp, SSCR1, sscr1);
4075 +
4076 + if (value) {
4077 + pxa_ssp_write_reg(ssp, SSSR, sssr);
4078 + pxa_ssp_write_reg(ssp, SSPSP, sspsp);
4079 + pxa_ssp_write_reg(ssp, SSCR0, sscr0 | SSCR0_SSE);
4080 + }
4081 +}
4082 +
4083 static int pxa_ssp_trigger(struct snd_pcm_substream *substream, int cmd,
4084 struct snd_soc_dai *cpu_dai)
4085 {
4086 @@ -681,42 +713,21 @@ static int pxa_ssp_trigger(struct snd_pcm_substream *substream, int cmd,
4087 pxa_ssp_enable(ssp);
4088 break;
4089 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
4090 - val = pxa_ssp_read_reg(ssp, SSCR1);
4091 - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
4092 - val |= SSCR1_TSRE;
4093 - else
4094 - val |= SSCR1_RSRE;
4095 - pxa_ssp_write_reg(ssp, SSCR1, val);
4096 + pxa_ssp_set_running_bit(substream, ssp, 1);
4097 val = pxa_ssp_read_reg(ssp, SSSR);
4098 pxa_ssp_write_reg(ssp, SSSR, val);
4099 break;
4100 case SNDRV_PCM_TRIGGER_START:
4101 - val = pxa_ssp_read_reg(ssp, SSCR1);
4102 - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
4103 - val |= SSCR1_TSRE;
4104 - else
4105 - val |= SSCR1_RSRE;
4106 - pxa_ssp_write_reg(ssp, SSCR1, val);
4107 - pxa_ssp_enable(ssp);
4108 + pxa_ssp_set_running_bit(substream, ssp, 1);
4109 break;
4110 case SNDRV_PCM_TRIGGER_STOP:
4111 - val = pxa_ssp_read_reg(ssp, SSCR1);
4112 - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
4113 - val &= ~SSCR1_TSRE;
4114 - else
4115 - val &= ~SSCR1_RSRE;
4116 - pxa_ssp_write_reg(ssp, SSCR1, val);
4117 + pxa_ssp_set_running_bit(substream, ssp, 0);
4118 break;
4119 case SNDRV_PCM_TRIGGER_SUSPEND:
4120 pxa_ssp_disable(ssp);
4121 break;
4122 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
4123 - val = pxa_ssp_read_reg(ssp, SSCR1);
4124 - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
4125 - val &= ~SSCR1_TSRE;
4126 - else
4127 - val &= ~SSCR1_RSRE;
4128 - pxa_ssp_write_reg(ssp, SSCR1, val);
4129 + pxa_ssp_set_running_bit(substream, ssp, 0);
4130 break;
4131
4132 default:

  ViewVC Help
Powered by ViewVC 1.1.20