/[linux-patches]/genpatches-2.6/tags/3.0-30/1000_linux-3.0.1.patch
Gentoo

Contents of /genpatches-2.6/tags/3.0-30/1000_linux-3.0.1.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2206 - (show annotations) (download)
Mon Sep 17 18:58:14 2012 UTC (3 years, 10 months ago) by mpagano
File size: 123558 byte(s)
3.0-30 release
1 diff --git a/Makefile b/Makefile
2 index 6a5bdad..f124b18 100644
3 --- a/Makefile
4 +++ b/Makefile
5 @@ -1,6 +1,6 @@
6 VERSION = 3
7 PATCHLEVEL = 0
8 -SUBLEVEL = 0
9 +SUBLEVEL = 1
10 EXTRAVERSION =
11 NAME = Sneaky Weasel
12
13 diff --git a/arch/alpha/kernel/time.c b/arch/alpha/kernel/time.c
14 index 818e74e..f20d1b5 100644
15 --- a/arch/alpha/kernel/time.c
16 +++ b/arch/alpha/kernel/time.c
17 @@ -91,7 +91,7 @@ DEFINE_PER_CPU(u8, irq_work_pending);
18 #define test_irq_work_pending() __get_cpu_var(irq_work_pending)
19 #define clear_irq_work_pending() __get_cpu_var(irq_work_pending) = 0
20
21 -void set_irq_work_pending(void)
22 +void arch_irq_work_raise(void)
23 {
24 set_irq_work_pending_flag();
25 }
26 diff --git a/arch/arm/mach-pxa/cm-x300.c b/arch/arm/mach-pxa/cm-x300.c
27 index b2248e7..8a03487 100644
28 --- a/arch/arm/mach-pxa/cm-x300.c
29 +++ b/arch/arm/mach-pxa/cm-x300.c
30 @@ -161,10 +161,10 @@ static mfp_cfg_t cm_x3xx_mfp_cfg[] __initdata = {
31 GPIO99_GPIO, /* Ethernet IRQ */
32
33 /* RTC GPIOs */
34 - GPIO95_GPIO, /* RTC CS */
35 - GPIO96_GPIO, /* RTC WR */
36 - GPIO97_GPIO, /* RTC RD */
37 - GPIO98_GPIO, /* RTC IO */
38 + GPIO95_GPIO | MFP_LPM_DRIVE_HIGH, /* RTC CS */
39 + GPIO96_GPIO | MFP_LPM_DRIVE_HIGH, /* RTC WR */
40 + GPIO97_GPIO | MFP_LPM_DRIVE_HIGH, /* RTC RD */
41 + GPIO98_GPIO, /* RTC IO */
42
43 /* Standard I2C */
44 GPIO21_I2C_SCL,
45 diff --git a/arch/powerpc/kernel/crash.c b/arch/powerpc/kernel/crash.c
46 index 4e6ee94..cc6a9d5 100644
47 --- a/arch/powerpc/kernel/crash.c
48 +++ b/arch/powerpc/kernel/crash.c
49 @@ -242,12 +242,8 @@ static void crash_kexec_wait_realmode(int cpu)
50
51 while (paca[i].kexec_state < KEXEC_STATE_REAL_MODE) {
52 barrier();
53 - if (!cpu_possible(i)) {
54 + if (!cpu_possible(i) || !cpu_online(i) || (msecs <= 0))
55 break;
56 - }
57 - if (!cpu_online(i)) {
58 - break;
59 - }
60 msecs--;
61 mdelay(1);
62 }
63 diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c
64 index f33acfd..03b29a6 100644
65 --- a/arch/powerpc/kernel/time.c
66 +++ b/arch/powerpc/kernel/time.c
67 @@ -544,7 +544,7 @@ DEFINE_PER_CPU(u8, irq_work_pending);
68
69 #endif /* 32 vs 64 bit */
70
71 -void set_irq_work_pending(void)
72 +void arch_irq_work_raise(void)
73 {
74 preempt_disable();
75 set_irq_work_pending_flag();
76 diff --git a/arch/powerpc/platforms/pseries/hvconsole.c b/arch/powerpc/platforms/pseries/hvconsole.c
77 index 3f6a89b..041e87c 100644
78 --- a/arch/powerpc/platforms/pseries/hvconsole.c
79 +++ b/arch/powerpc/platforms/pseries/hvconsole.c
80 @@ -73,7 +73,7 @@ int hvc_put_chars(uint32_t vtermno, const char *buf, int count)
81 if (ret == H_SUCCESS)
82 return count;
83 if (ret == H_BUSY)
84 - return 0;
85 + return -EAGAIN;
86 return -EIO;
87 }
88
89 diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h
90 index 485b4f1..23a9d89 100644
91 --- a/arch/x86/include/asm/msr-index.h
92 +++ b/arch/x86/include/asm/msr-index.h
93 @@ -259,6 +259,9 @@
94 #define MSR_IA32_TEMPERATURE_TARGET 0x000001a2
95
96 #define MSR_IA32_ENERGY_PERF_BIAS 0x000001b0
97 +#define ENERGY_PERF_BIAS_PERFORMANCE 0
98 +#define ENERGY_PERF_BIAS_NORMAL 6
99 +#define ENERGY_PERF_BIAS_POWERSWAVE 15
100
101 #define MSR_IA32_PACKAGE_THERM_STATUS 0x000001b1
102
103 diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
104 index 1edf5ba..da0d779 100644
105 --- a/arch/x86/kernel/cpu/intel.c
106 +++ b/arch/x86/kernel/cpu/intel.c
107 @@ -456,6 +456,24 @@ static void __cpuinit init_intel(struct cpuinfo_x86 *c)
108
109 if (cpu_has(c, X86_FEATURE_VMX))
110 detect_vmx_virtcap(c);
111 +
112 + /*
113 + * Initialize MSR_IA32_ENERGY_PERF_BIAS if BIOS did not.
114 + * x86_energy_perf_policy(8) is available to change it at run-time
115 + */
116 + if (cpu_has(c, X86_FEATURE_EPB)) {
117 + u64 epb;
118 +
119 + rdmsrl(MSR_IA32_ENERGY_PERF_BIAS, epb);
120 + if ((epb & 0xF) == 0) {
121 + printk_once(KERN_WARNING, "x86: updated energy_perf_bias"
122 + " to 'normal' from 'performance'\n"
123 + "You can view and update epb via utility,"
124 + " such as x86_energy_perf_policy(8)\n");
125 + epb = (epb & ~0xF) | ENERGY_PERF_BIAS_NORMAL;
126 + wrmsrl(MSR_IA32_ENERGY_PERF_BIAS, epb);
127 + }
128 + }
129 }
130
131 #ifdef CONFIG_X86_32
132 diff --git a/arch/x86/kernel/relocate_kernel_32.S b/arch/x86/kernel/relocate_kernel_32.S
133 index 4123553..36818f8 100644
134 --- a/arch/x86/kernel/relocate_kernel_32.S
135 +++ b/arch/x86/kernel/relocate_kernel_32.S
136 @@ -97,6 +97,8 @@ relocate_kernel:
137 ret
138
139 identity_mapped:
140 + /* set return address to 0 if not preserving context */
141 + pushl $0
142 /* store the start address on the stack */
143 pushl %edx
144
145 diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S
146 index 4de8f5b..7a6f3b3 100644
147 --- a/arch/x86/kernel/relocate_kernel_64.S
148 +++ b/arch/x86/kernel/relocate_kernel_64.S
149 @@ -100,6 +100,8 @@ relocate_kernel:
150 ret
151
152 identity_mapped:
153 + /* set return address to 0 if not preserving context */
154 + pushq $0
155 /* store the start address on the stack */
156 pushq %rdx
157
158 diff --git a/arch/x86/oprofile/backtrace.c b/arch/x86/oprofile/backtrace.c
159 index a5b64ab..32f78eb 100644
160 --- a/arch/x86/oprofile/backtrace.c
161 +++ b/arch/x86/oprofile/backtrace.c
162 @@ -11,10 +11,12 @@
163 #include <linux/oprofile.h>
164 #include <linux/sched.h>
165 #include <linux/mm.h>
166 +#include <linux/compat.h>
167 +#include <linux/highmem.h>
168 +
169 #include <asm/ptrace.h>
170 #include <asm/uaccess.h>
171 #include <asm/stacktrace.h>
172 -#include <linux/compat.h>
173
174 static int backtrace_stack(void *data, char *name)
175 {
176 @@ -36,17 +38,53 @@ static struct stacktrace_ops backtrace_ops = {
177 .walk_stack = print_context_stack,
178 };
179
180 +/* from arch/x86/kernel/cpu/perf_event.c: */
181 +
182 +/*
183 + * best effort, GUP based copy_from_user() that assumes IRQ or NMI context
184 + */
185 +static unsigned long
186 +copy_from_user_nmi(void *to, const void __user *from, unsigned long n)
187 +{
188 + unsigned long offset, addr = (unsigned long)from;
189 + unsigned long size, len = 0;
190 + struct page *page;
191 + void *map;
192 + int ret;
193 +
194 + do {
195 + ret = __get_user_pages_fast(addr, 1, 0, &page);
196 + if (!ret)
197 + break;
198 +
199 + offset = addr & (PAGE_SIZE - 1);
200 + size = min(PAGE_SIZE - offset, n - len);
201 +
202 + map = kmap_atomic(page);
203 + memcpy(to, map+offset, size);
204 + kunmap_atomic(map);
205 + put_page(page);
206 +
207 + len += size;
208 + to += size;
209 + addr += size;
210 +
211 + } while (len < n);
212 +
213 + return len;
214 +}
215 +
216 #ifdef CONFIG_COMPAT
217 static struct stack_frame_ia32 *
218 dump_user_backtrace_32(struct stack_frame_ia32 *head)
219 {
220 + /* Also check accessibility of one struct frame_head beyond: */
221 struct stack_frame_ia32 bufhead[2];
222 struct stack_frame_ia32 *fp;
223 + unsigned long bytes;
224
225 - /* Also check accessibility of one struct frame_head beyond */
226 - if (!access_ok(VERIFY_READ, head, sizeof(bufhead)))
227 - return NULL;
228 - if (__copy_from_user_inatomic(bufhead, head, sizeof(bufhead)))
229 + bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
230 + if (bytes != sizeof(bufhead))
231 return NULL;
232
233 fp = (struct stack_frame_ia32 *) compat_ptr(bufhead[0].next_frame);
234 @@ -87,12 +125,12 @@ x86_backtrace_32(struct pt_regs * const regs, unsigned int depth)
235
236 static struct stack_frame *dump_user_backtrace(struct stack_frame *head)
237 {
238 + /* Also check accessibility of one struct frame_head beyond: */
239 struct stack_frame bufhead[2];
240 + unsigned long bytes;
241
242 - /* Also check accessibility of one struct stack_frame beyond */
243 - if (!access_ok(VERIFY_READ, head, sizeof(bufhead)))
244 - return NULL;
245 - if (__copy_from_user_inatomic(bufhead, head, sizeof(bufhead)))
246 + bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
247 + if (bytes != sizeof(bufhead))
248 return NULL;
249
250 oprofile_add_trace(bufhead[0].return_address);
251 diff --git a/arch/xtensa/kernel/ptrace.c b/arch/xtensa/kernel/ptrace.c
252 index c72c947..a0d042a 100644
253 --- a/arch/xtensa/kernel/ptrace.c
254 +++ b/arch/xtensa/kernel/ptrace.c
255 @@ -147,6 +147,9 @@ int ptrace_setxregs(struct task_struct *child, void __user *uregs)
256 elf_xtregs_t *xtregs = uregs;
257 int ret = 0;
258
259 + if (!access_ok(VERIFY_READ, uregs, sizeof(elf_xtregs_t)))
260 + return -EFAULT;
261 +
262 #if XTENSA_HAVE_COPROCESSORS
263 /* Flush all coprocessors before we overwrite them. */
264 coprocessor_flush_all(ti);
265 diff --git a/block/blk-core.c b/block/blk-core.c
266 index d2f8f40..1d49e1c 100644
267 --- a/block/blk-core.c
268 +++ b/block/blk-core.c
269 @@ -839,6 +839,9 @@ struct request *blk_get_request(struct request_queue *q, int rw, gfp_t gfp_mask)
270 {
271 struct request *rq;
272
273 + if (unlikely(test_bit(QUEUE_FLAG_DEAD, &q->queue_flags)))
274 + return NULL;
275 +
276 BUG_ON(rw != READ && rw != WRITE);
277
278 spin_lock_irq(q->queue_lock);
279 diff --git a/block/blk-exec.c b/block/blk-exec.c
280 index 8a0e7ec..a1ebceb 100644
281 --- a/block/blk-exec.c
282 +++ b/block/blk-exec.c
283 @@ -50,6 +50,13 @@ void blk_execute_rq_nowait(struct request_queue *q, struct gendisk *bd_disk,
284 {
285 int where = at_head ? ELEVATOR_INSERT_FRONT : ELEVATOR_INSERT_BACK;
286
287 + if (unlikely(test_bit(QUEUE_FLAG_DEAD, &q->queue_flags))) {
288 + rq->errors = -ENXIO;
289 + if (rq->end_io)
290 + rq->end_io(rq, rq->errors);
291 + return;
292 + }
293 +
294 rq->rq_disk = bd_disk;
295 rq->end_io = done;
296 WARN_ON(irqs_disabled());
297 diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
298 index 16b4d58..c049548 100644
299 --- a/drivers/block/cciss.h
300 +++ b/drivers/block/cciss.h
301 @@ -223,7 +223,7 @@ static void SA5_submit_command( ctlr_info_t *h, CommandList_struct *c)
302 h->ctlr, c->busaddr);
303 #endif /* CCISS_DEBUG */
304 writel(c->busaddr, h->vaddr + SA5_REQUEST_PORT_OFFSET);
305 - readl(h->vaddr + SA5_REQUEST_PORT_OFFSET);
306 + readl(h->vaddr + SA5_SCRATCHPAD_OFFSET);
307 h->commands_outstanding++;
308 if ( h->commands_outstanding > h->max_outstanding)
309 h->max_outstanding = h->commands_outstanding;
310 diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c
311 index b1c1177..e6ad3bb 100644
312 --- a/drivers/firewire/core-cdev.c
313 +++ b/drivers/firewire/core-cdev.c
314 @@ -253,14 +253,11 @@ static int fw_device_op_open(struct inode *inode, struct file *file)
315 init_waitqueue_head(&client->wait);
316 init_waitqueue_head(&client->tx_flush_wait);
317 INIT_LIST_HEAD(&client->phy_receiver_link);
318 + INIT_LIST_HEAD(&client->link);
319 kref_init(&client->kref);
320
321 file->private_data = client;
322
323 - mutex_lock(&device->client_list_mutex);
324 - list_add_tail(&client->link, &device->client_list);
325 - mutex_unlock(&device->client_list_mutex);
326 -
327 return nonseekable_open(inode, file);
328 }
329
330 @@ -451,15 +448,20 @@ static int ioctl_get_info(struct client *client, union ioctl_arg *arg)
331 if (ret != 0)
332 return -EFAULT;
333
334 + mutex_lock(&client->device->client_list_mutex);
335 +
336 client->bus_reset_closure = a->bus_reset_closure;
337 if (a->bus_reset != 0) {
338 fill_bus_reset_event(&bus_reset, client);
339 - if (copy_to_user(u64_to_uptr(a->bus_reset),
340 - &bus_reset, sizeof(bus_reset)))
341 - return -EFAULT;
342 + ret = copy_to_user(u64_to_uptr(a->bus_reset),
343 + &bus_reset, sizeof(bus_reset));
344 }
345 + if (ret == 0 && list_empty(&client->link))
346 + list_add_tail(&client->link, &client->device->client_list);
347
348 - return 0;
349 + mutex_unlock(&client->device->client_list_mutex);
350 +
351 + return ret ? -EFAULT : 0;
352 }
353
354 static int add_client_resource(struct client *client,
355 @@ -1583,7 +1585,7 @@ static int dispatch_ioctl(struct client *client,
356 if (_IOC_TYPE(cmd) != '#' ||
357 _IOC_NR(cmd) >= ARRAY_SIZE(ioctl_handlers) ||
358 _IOC_SIZE(cmd) > sizeof(buffer))
359 - return -EINVAL;
360 + return -ENOTTY;
361
362 if (_IOC_DIR(cmd) == _IOC_READ)
363 memset(&buffer, 0, _IOC_SIZE(cmd));
364 diff --git a/drivers/firmware/sigma.c b/drivers/firmware/sigma.c
365 index c19cd2c..f10fc52 100644
366 --- a/drivers/firmware/sigma.c
367 +++ b/drivers/firmware/sigma.c
368 @@ -11,6 +11,7 @@
369 #include <linux/firmware.h>
370 #include <linux/kernel.h>
371 #include <linux/i2c.h>
372 +#include <linux/module.h>
373 #include <linux/sigma.h>
374
375 /* Return: 0==OK, <0==error, =1 ==no more actions */
376 @@ -113,3 +114,5 @@ int process_sigma_firmware(struct i2c_client *client, const char *name)
377 return ret;
378 }
379 EXPORT_SYMBOL(process_sigma_firmware);
380 +
381 +MODULE_LICENSE("GPL");
382 diff --git a/drivers/gpu/drm/radeon/atombios_dp.c b/drivers/gpu/drm/radeon/atombios_dp.c
383 index 8c0f9e3..645b84b 100644
384 --- a/drivers/gpu/drm/radeon/atombios_dp.c
385 +++ b/drivers/gpu/drm/radeon/atombios_dp.c
386 @@ -627,6 +627,7 @@ struct radeon_dp_link_train_info {
387 u8 train_set[4];
388 u8 link_status[DP_LINK_STATUS_SIZE];
389 u8 tries;
390 + bool use_dpencoder;
391 };
392
393 static void radeon_dp_update_vs_emph(struct radeon_dp_link_train_info *dp_info)
394 @@ -646,7 +647,7 @@ static void radeon_dp_set_tp(struct radeon_dp_link_train_info *dp_info, int tp)
395 int rtp = 0;
396
397 /* set training pattern on the source */
398 - if (ASIC_IS_DCE4(dp_info->rdev)) {
399 + if (ASIC_IS_DCE4(dp_info->rdev) || !dp_info->use_dpencoder) {
400 switch (tp) {
401 case DP_TRAINING_PATTERN_1:
402 rtp = ATOM_ENCODER_CMD_DP_LINK_TRAINING_PATTERN1;
403 @@ -706,7 +707,7 @@ static int radeon_dp_link_train_init(struct radeon_dp_link_train_info *dp_info)
404 radeon_write_dpcd_reg(dp_info->radeon_connector, DP_LINK_BW_SET, tmp);
405
406 /* start training on the source */
407 - if (ASIC_IS_DCE4(dp_info->rdev))
408 + if (ASIC_IS_DCE4(dp_info->rdev) || !dp_info->use_dpencoder)
409 atombios_dig_encoder_setup(dp_info->encoder,
410 ATOM_ENCODER_CMD_DP_LINK_TRAINING_START, 0);
411 else
412 @@ -731,7 +732,7 @@ static int radeon_dp_link_train_finish(struct radeon_dp_link_train_info *dp_info
413 DP_TRAINING_PATTERN_DISABLE);
414
415 /* disable the training pattern on the source */
416 - if (ASIC_IS_DCE4(dp_info->rdev))
417 + if (ASIC_IS_DCE4(dp_info->rdev) || !dp_info->use_dpencoder)
418 atombios_dig_encoder_setup(dp_info->encoder,
419 ATOM_ENCODER_CMD_DP_LINK_TRAINING_COMPLETE, 0);
420 else
421 @@ -869,7 +870,8 @@ void radeon_dp_link_train(struct drm_encoder *encoder,
422 struct radeon_connector *radeon_connector;
423 struct radeon_connector_atom_dig *dig_connector;
424 struct radeon_dp_link_train_info dp_info;
425 - u8 tmp;
426 + int index;
427 + u8 tmp, frev, crev;
428
429 if (!radeon_encoder->enc_priv)
430 return;
431 @@ -884,6 +886,18 @@ void radeon_dp_link_train(struct drm_encoder *encoder,
432 (dig_connector->dp_sink_type != CONNECTOR_OBJECT_ID_eDP))
433 return;
434
435 + /* DPEncoderService newer than 1.1 can't program properly the
436 + * training pattern. When facing such version use the
437 + * DIGXEncoderControl (X== 1 | 2)
438 + */
439 + dp_info.use_dpencoder = true;
440 + index = GetIndexIntoMasterTable(COMMAND, DPEncoderService);
441 + if (atom_parse_cmd_header(rdev->mode_info.atom_context, index, &frev, &crev)) {
442 + if (crev > 1) {
443 + dp_info.use_dpencoder = false;
444 + }
445 + }
446 +
447 dp_info.enc_id = 0;
448 if (dig->dig_encoder)
449 dp_info.enc_id |= ATOM_DP_CONFIG_DIG2_ENCODER;
450 diff --git a/drivers/gpu/drm/radeon/radeon_combios.c b/drivers/gpu/drm/radeon/radeon_combios.c
451 index e459467..a74217c 100644
452 --- a/drivers/gpu/drm/radeon/radeon_combios.c
453 +++ b/drivers/gpu/drm/radeon/radeon_combios.c
454 @@ -779,7 +779,8 @@ void radeon_combios_i2c_init(struct radeon_device *rdev)
455 }
456 }
457 }
458 - } else if (rdev->family >= CHIP_R200) {
459 + } else if ((rdev->family == CHIP_R200) ||
460 + (rdev->family >= CHIP_R300)) {
461 /* 0x68 */
462 i2c = combios_setup_i2c_bus(rdev, DDC_MONID, 0, 0);
463 rdev->i2c_bus[3] = radeon_i2c_create(dev, &i2c, "MONID");
464 diff --git a/drivers/gpu/drm/radeon/radeon_pm.c b/drivers/gpu/drm/radeon/radeon_pm.c
465 index aaa19dc..6fabe89 100644
466 --- a/drivers/gpu/drm/radeon/radeon_pm.c
467 +++ b/drivers/gpu/drm/radeon/radeon_pm.c
468 @@ -594,6 +594,9 @@ int radeon_pm_init(struct radeon_device *rdev)
469 if (rdev->pm.default_vddc)
470 radeon_atom_set_voltage(rdev, rdev->pm.default_vddc,
471 SET_VOLTAGE_TYPE_ASIC_VDDC);
472 + if (rdev->pm.default_vddci)
473 + radeon_atom_set_voltage(rdev, rdev->pm.default_vddci,
474 + SET_VOLTAGE_TYPE_ASIC_VDDCI);
475 if (rdev->pm.default_sclk)
476 radeon_set_engine_clock(rdev, rdev->pm.default_sclk);
477 if (rdev->pm.default_mclk)
478 diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
479 index ee165fd..7d5109b 100644
480 --- a/drivers/infiniband/ulp/srp/ib_srp.c
481 +++ b/drivers/infiniband/ulp/srp/ib_srp.c
482 @@ -2127,6 +2127,8 @@ static ssize_t srp_create_target(struct device *dev,
483 return -ENOMEM;
484
485 target_host->transportt = ib_srp_transport_template;
486 + target_host->max_channel = 0;
487 + target_host->max_id = 1;
488 target_host->max_lun = SRP_MAX_LUN;
489 target_host->max_cmd_len = sizeof ((struct srp_cmd *) (void *) 0L)->cdb;
490
491 diff --git a/drivers/md/dm-io.c b/drivers/md/dm-io.c
492 index 2067288..ad2eba4 100644
493 --- a/drivers/md/dm-io.c
494 +++ b/drivers/md/dm-io.c
495 @@ -38,6 +38,8 @@ struct io {
496 struct dm_io_client *client;
497 io_notify_fn callback;
498 void *context;
499 + void *vma_invalidate_address;
500 + unsigned long vma_invalidate_size;
501 } __attribute__((aligned(DM_IO_MAX_REGIONS)));
502
503 static struct kmem_cache *_dm_io_cache;
504 @@ -116,6 +118,10 @@ static void dec_count(struct io *io, unsigned int region, int error)
505 set_bit(region, &io->error_bits);
506
507 if (atomic_dec_and_test(&io->count)) {
508 + if (io->vma_invalidate_size)
509 + invalidate_kernel_vmap_range(io->vma_invalidate_address,
510 + io->vma_invalidate_size);
511 +
512 if (io->sleeper)
513 wake_up_process(io->sleeper);
514
515 @@ -159,6 +165,9 @@ struct dpages {
516
517 unsigned context_u;
518 void *context_ptr;
519 +
520 + void *vma_invalidate_address;
521 + unsigned long vma_invalidate_size;
522 };
523
524 /*
525 @@ -377,6 +386,9 @@ static int sync_io(struct dm_io_client *client, unsigned int num_regions,
526 io->sleeper = current;
527 io->client = client;
528
529 + io->vma_invalidate_address = dp->vma_invalidate_address;
530 + io->vma_invalidate_size = dp->vma_invalidate_size;
531 +
532 dispatch_io(rw, num_regions, where, dp, io, 1);
533
534 while (1) {
535 @@ -415,13 +427,21 @@ static int async_io(struct dm_io_client *client, unsigned int num_regions,
536 io->callback = fn;
537 io->context = context;
538
539 + io->vma_invalidate_address = dp->vma_invalidate_address;
540 + io->vma_invalidate_size = dp->vma_invalidate_size;
541 +
542 dispatch_io(rw, num_regions, where, dp, io, 0);
543 return 0;
544 }
545
546 -static int dp_init(struct dm_io_request *io_req, struct dpages *dp)
547 +static int dp_init(struct dm_io_request *io_req, struct dpages *dp,
548 + unsigned long size)
549 {
550 /* Set up dpages based on memory type */
551 +
552 + dp->vma_invalidate_address = NULL;
553 + dp->vma_invalidate_size = 0;
554 +
555 switch (io_req->mem.type) {
556 case DM_IO_PAGE_LIST:
557 list_dp_init(dp, io_req->mem.ptr.pl, io_req->mem.offset);
558 @@ -432,6 +452,11 @@ static int dp_init(struct dm_io_request *io_req, struct dpages *dp)
559 break;
560
561 case DM_IO_VMA:
562 + flush_kernel_vmap_range(io_req->mem.ptr.vma, size);
563 + if ((io_req->bi_rw & RW_MASK) == READ) {
564 + dp->vma_invalidate_address = io_req->mem.ptr.vma;
565 + dp->vma_invalidate_size = size;
566 + }
567 vm_dp_init(dp, io_req->mem.ptr.vma);
568 break;
569
570 @@ -460,7 +485,7 @@ int dm_io(struct dm_io_request *io_req, unsigned num_regions,
571 int r;
572 struct dpages dp;
573
574 - r = dp_init(io_req, &dp);
575 + r = dp_init(io_req, &dp, (unsigned long)where->count << SECTOR_SHIFT);
576 if (r)
577 return r;
578
579 diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c
580 index aa4e570..209991b 100644
581 --- a/drivers/md/dm-mpath.c
582 +++ b/drivers/md/dm-mpath.c
583 @@ -807,6 +807,11 @@ static int parse_features(struct arg_set *as, struct multipath *m)
584 if (!argc)
585 return 0;
586
587 + if (argc > as->argc) {
588 + ti->error = "not enough arguments for features";
589 + return -EINVAL;
590 + }
591 +
592 do {
593 param_name = shift(as);
594 argc--;
595 diff --git a/drivers/md/dm-snap-persistent.c b/drivers/md/dm-snap-persistent.c
596 index 135c2f1..e4ecadf 100644
597 --- a/drivers/md/dm-snap-persistent.c
598 +++ b/drivers/md/dm-snap-persistent.c
599 @@ -753,7 +753,7 @@ static int persistent_commit_merge(struct dm_exception_store *store,
600 for (i = 0; i < nr_merged; i++)
601 clear_exception(ps, ps->current_committed - 1 - i);
602
603 - r = area_io(ps, WRITE);
604 + r = area_io(ps, WRITE_FLUSH_FUA);
605 if (r < 0)
606 return r;
607
608 diff --git a/drivers/md/dm.c b/drivers/md/dm.c
609 index 0cf68b4..41abc6d 100644
610 --- a/drivers/md/dm.c
611 +++ b/drivers/md/dm.c
612 @@ -37,6 +37,8 @@ static const char *_name = DM_NAME;
613 static unsigned int major = 0;
614 static unsigned int _major = 0;
615
616 +static DEFINE_IDR(_minor_idr);
617 +
618 static DEFINE_SPINLOCK(_minor_lock);
619 /*
620 * For bio-based dm.
621 @@ -313,6 +315,12 @@ static void __exit dm_exit(void)
622
623 while (i--)
624 _exits[i]();
625 +
626 + /*
627 + * Should be empty by this point.
628 + */
629 + idr_remove_all(&_minor_idr);
630 + idr_destroy(&_minor_idr);
631 }
632
633 /*
634 @@ -1705,8 +1713,6 @@ static int dm_any_congested(void *congested_data, int bdi_bits)
635 /*-----------------------------------------------------------------
636 * An IDR is used to keep track of allocated minor numbers.
637 *---------------------------------------------------------------*/
638 -static DEFINE_IDR(_minor_idr);
639 -
640 static void free_minor(int minor)
641 {
642 spin_lock(&_minor_lock);
643 diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
644 index 4e349cd..3546474 100644
645 --- a/drivers/misc/Kconfig
646 +++ b/drivers/misc/Kconfig
647 @@ -245,8 +245,7 @@ config SGI_XP
648
649 config CS5535_MFGPT
650 tristate "CS5535/CS5536 Geode Multi-Function General Purpose Timer (MFGPT) support"
651 - depends on PCI
652 - depends on X86
653 + depends on PCI && X86 && MFD_CS5535
654 default n
655 help
656 This driver provides access to MFGPT functionality for other
657 diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
658 index a19967d..ba31abe 100644
659 --- a/drivers/mmc/host/sdhci-esdhc-imx.c
660 +++ b/drivers/mmc/host/sdhci-esdhc-imx.c
661 @@ -74,7 +74,7 @@ static u32 esdhc_readl_le(struct sdhci_host *host, int reg)
662 if (boarddata && gpio_is_valid(boarddata->cd_gpio)
663 && gpio_get_value(boarddata->cd_gpio))
664 /* no card, if a valid gpio says so... */
665 - val &= SDHCI_CARD_PRESENT;
666 + val &= ~SDHCI_CARD_PRESENT;
667 else
668 /* ... in all other cases assume card is present */
669 val |= SDHCI_CARD_PRESENT;
670 diff --git a/drivers/net/jme.c b/drivers/net/jme.c
671 index b5b174a..1973814 100644
672 --- a/drivers/net/jme.c
673 +++ b/drivers/net/jme.c
674 @@ -753,20 +753,28 @@ jme_make_new_rx_buf(struct jme_adapter *jme, int i)
675 struct jme_ring *rxring = &(jme->rxring[0]);
676 struct jme_buffer_info *rxbi = rxring->bufinf + i;
677 struct sk_buff *skb;
678 + dma_addr_t mapping;
679
680 skb = netdev_alloc_skb(jme->dev,
681 jme->dev->mtu + RX_EXTRA_LEN);
682 if (unlikely(!skb))
683 return -ENOMEM;
684
685 + mapping = pci_map_page(jme->pdev, virt_to_page(skb->data),
686 + offset_in_page(skb->data), skb_tailroom(skb),
687 + PCI_DMA_FROMDEVICE);
688 + if (unlikely(pci_dma_mapping_error(jme->pdev, mapping))) {
689 + dev_kfree_skb(skb);
690 + return -ENOMEM;
691 + }
692 +
693 + if (likely(rxbi->mapping))
694 + pci_unmap_page(jme->pdev, rxbi->mapping,
695 + rxbi->len, PCI_DMA_FROMDEVICE);
696 +
697 rxbi->skb = skb;
698 rxbi->len = skb_tailroom(skb);
699 - rxbi->mapping = pci_map_page(jme->pdev,
700 - virt_to_page(skb->data),
701 - offset_in_page(skb->data),
702 - rxbi->len,
703 - PCI_DMA_FROMDEVICE);
704 -
705 + rxbi->mapping = mapping;
706 return 0;
707 }
708
709 diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
710 index 10d71f7..1f99249 100644
711 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
712 +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
713 @@ -629,8 +629,7 @@ int ath9k_hw_process_rxdesc_edma(struct ath_hw *ah, struct ath_rx_status *rxs,
714 rxs->rs_status |= ATH9K_RXERR_DECRYPT;
715 else if (rxsp->status11 & AR_MichaelErr)
716 rxs->rs_status |= ATH9K_RXERR_MIC;
717 -
718 - if (rxsp->status11 & AR_KeyMiss)
719 + else if (rxsp->status11 & AR_KeyMiss)
720 rxs->rs_status |= ATH9K_RXERR_DECRYPT;
721 }
722
723 diff --git a/drivers/net/wireless/ath/ath9k/mac.c b/drivers/net/wireless/ath/ath9k/mac.c
724 index c2091f1..b6b523a 100644
725 --- a/drivers/net/wireless/ath/ath9k/mac.c
726 +++ b/drivers/net/wireless/ath/ath9k/mac.c
727 @@ -645,8 +645,7 @@ int ath9k_hw_rxprocdesc(struct ath_hw *ah, struct ath_desc *ds,
728 rs->rs_status |= ATH9K_RXERR_DECRYPT;
729 else if (ads.ds_rxstatus8 & AR_MichaelErr)
730 rs->rs_status |= ATH9K_RXERR_MIC;
731 -
732 - if (ads.ds_rxstatus8 & AR_KeyMiss)
733 + else if (ads.ds_rxstatus8 & AR_KeyMiss)
734 rs->rs_status |= ATH9K_RXERR_DECRYPT;
735 }
736
737 diff --git a/drivers/net/wireless/rt2x00/rt2800pci.c b/drivers/net/wireless/rt2x00/rt2800pci.c
738 index cc4a54f..55cd3e1 100644
739 --- a/drivers/net/wireless/rt2x00/rt2800pci.c
740 +++ b/drivers/net/wireless/rt2x00/rt2800pci.c
741 @@ -1158,6 +1158,7 @@ static DEFINE_PCI_DEVICE_TABLE(rt2800pci_device_table) = {
742 #endif
743 #ifdef CONFIG_RT2800PCI_RT53XX
744 { PCI_DEVICE(0x1814, 0x5390) },
745 + { PCI_DEVICE(0x1814, 0x539f) },
746 #endif
747 { 0, }
748 };
749 diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/rf.c b/drivers/net/wireless/rtlwifi/rtl8192cu/rf.c
750 index c7576ec..3bee79e 100644
751 --- a/drivers/net/wireless/rtlwifi/rtl8192cu/rf.c
752 +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/rf.c
753 @@ -104,7 +104,7 @@ void rtl92cu_phy_rf6052_set_cck_txpower(struct ieee80211_hw *hw,
754 tx_agc[RF90_PATH_A] = 0x10101010;
755 tx_agc[RF90_PATH_B] = 0x10101010;
756 } else if (rtlpriv->dm.dynamic_txhighpower_lvl ==
757 - TXHIGHPWRLEVEL_LEVEL1) {
758 + TXHIGHPWRLEVEL_LEVEL2) {
759 tx_agc[RF90_PATH_A] = 0x00000000;
760 tx_agc[RF90_PATH_B] = 0x00000000;
761 } else{
762 diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
763 index 692671b..d549bbc 100644
764 --- a/drivers/pci/pci.c
765 +++ b/drivers/pci/pci.c
766 @@ -1905,7 +1905,7 @@ void pci_enable_ari(struct pci_dev *dev)
767 {
768 int pos;
769 u32 cap;
770 - u16 ctrl;
771 + u16 flags, ctrl;
772 struct pci_dev *bridge;
773
774 if (!pci_is_pcie(dev) || dev->devfn)
775 @@ -1923,6 +1923,11 @@ void pci_enable_ari(struct pci_dev *dev)
776 if (!pos)
777 return;
778
779 + /* ARI is a PCIe v2 feature */
780 + pci_read_config_word(bridge, pos + PCI_EXP_FLAGS, &flags);
781 + if ((flags & PCI_EXP_FLAGS_VERS) < 2)
782 + return;
783 +
784 pci_read_config_dword(bridge, pos + PCI_EXP_DEVCAP2, &cap);
785 if (!(cap & PCI_EXP_DEVCAP2_ARI))
786 return;
787 diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
788 index 02145e9..1196f61 100644
789 --- a/drivers/pci/quirks.c
790 +++ b/drivers/pci/quirks.c
791 @@ -2758,6 +2758,29 @@ static void ricoh_mmc_fixup_r5c832(struct pci_dev *dev)
792
793 dev_notice(&dev->dev, "proprietary Ricoh MMC controller disabled (via firewire function)\n");
794 dev_notice(&dev->dev, "MMC cards are now supported by standard SDHCI controller\n");
795 +
796 + /*
797 + * RICOH 0xe823 SD/MMC card reader fails to recognize
798 + * certain types of SD/MMC cards. Lowering the SD base
799 + * clock frequency from 200Mhz to 50Mhz fixes this issue.
800 + *
801 + * 0x150 - SD2.0 mode enable for changing base clock
802 + * frequency to 50Mhz
803 + * 0xe1 - Base clock frequency
804 + * 0x32 - 50Mhz new clock frequency
805 + * 0xf9 - Key register for 0x150
806 + * 0xfc - key register for 0xe1
807 + */
808 + if (dev->device == PCI_DEVICE_ID_RICOH_R5CE823) {
809 + pci_write_config_byte(dev, 0xf9, 0xfc);
810 + pci_write_config_byte(dev, 0x150, 0x10);
811 + pci_write_config_byte(dev, 0xf9, 0x00);
812 + pci_write_config_byte(dev, 0xfc, 0x01);
813 + pci_write_config_byte(dev, 0xe1, 0x32);
814 + pci_write_config_byte(dev, 0xfc, 0x00);
815 +
816 + dev_notice(&dev->dev, "MMC controller base frequency changed to 50Mhz.\n");
817 + }
818 }
819 DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_R5C832, ricoh_mmc_fixup_r5c832);
820 DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_R5C832, ricoh_mmc_fixup_r5c832);
821 diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c
822 index df68618..3195dbd 100644
823 --- a/drivers/rtc/interface.c
824 +++ b/drivers/rtc/interface.c
825 @@ -636,6 +636,29 @@ void rtc_irq_unregister(struct rtc_device *rtc, struct rtc_task *task)
826 }
827 EXPORT_SYMBOL_GPL(rtc_irq_unregister);
828
829 +static int rtc_update_hrtimer(struct rtc_device *rtc, int enabled)
830 +{
831 + /*
832 + * We unconditionally cancel the timer here, because otherwise
833 + * we could run into BUG_ON(timer->state != HRTIMER_STATE_CALLBACK);
834 + * when we manage to start the timer before the callback
835 + * returns HRTIMER_RESTART.
836 + *
837 + * We cannot use hrtimer_cancel() here as a running callback
838 + * could be blocked on rtc->irq_task_lock and hrtimer_cancel()
839 + * would spin forever.
840 + */
841 + if (hrtimer_try_to_cancel(&rtc->pie_timer) < 0)
842 + return -1;
843 +
844 + if (enabled) {
845 + ktime_t period = ktime_set(0, NSEC_PER_SEC / rtc->irq_freq);
846 +
847 + hrtimer_start(&rtc->pie_timer, period, HRTIMER_MODE_REL);
848 + }
849 + return 0;
850 +}
851 +
852 /**
853 * rtc_irq_set_state - enable/disable 2^N Hz periodic IRQs
854 * @rtc: the rtc device
855 @@ -651,21 +674,21 @@ int rtc_irq_set_state(struct rtc_device *rtc, struct rtc_task *task, int enabled
856 int err = 0;
857 unsigned long flags;
858
859 +retry:
860 spin_lock_irqsave(&rtc->irq_task_lock, flags);
861 if (rtc->irq_task != NULL && task == NULL)
862 err = -EBUSY;
863 if (rtc->irq_task != task)
864 err = -EACCES;
865 -
866 - if (enabled) {
867 - ktime_t period = ktime_set(0, NSEC_PER_SEC/rtc->irq_freq);
868 - hrtimer_start(&rtc->pie_timer, period, HRTIMER_MODE_REL);
869 - } else {
870 - hrtimer_cancel(&rtc->pie_timer);
871 + if (!err) {
872 + if (rtc_update_hrtimer(rtc, enabled) < 0) {
873 + spin_unlock_irqrestore(&rtc->irq_task_lock, flags);
874 + cpu_relax();
875 + goto retry;
876 + }
877 + rtc->pie_enabled = enabled;
878 }
879 - rtc->pie_enabled = enabled;
880 spin_unlock_irqrestore(&rtc->irq_task_lock, flags);
881 -
882 return err;
883 }
884 EXPORT_SYMBOL_GPL(rtc_irq_set_state);
885 @@ -685,22 +708,20 @@ int rtc_irq_set_freq(struct rtc_device *rtc, struct rtc_task *task, int freq)
886 int err = 0;
887 unsigned long flags;
888
889 - if (freq <= 0)
890 + if (freq <= 0 || freq > 5000)
891 return -EINVAL;
892 -
893 +retry:
894 spin_lock_irqsave(&rtc->irq_task_lock, flags);
895 if (rtc->irq_task != NULL && task == NULL)
896 err = -EBUSY;
897 if (rtc->irq_task != task)
898 err = -EACCES;
899 - if (err == 0) {
900 + if (!err) {
901 rtc->irq_freq = freq;
902 - if (rtc->pie_enabled) {
903 - ktime_t period;
904 - hrtimer_cancel(&rtc->pie_timer);
905 - period = ktime_set(0, NSEC_PER_SEC/rtc->irq_freq);
906 - hrtimer_start(&rtc->pie_timer, period,
907 - HRTIMER_MODE_REL);
908 + if (rtc->pie_enabled && rtc_update_hrtimer(rtc, 1) < 0) {
909 + spin_unlock_irqrestore(&rtc->irq_task_lock, flags);
910 + cpu_relax();
911 + goto retry;
912 }
913 }
914 spin_unlock_irqrestore(&rtc->irq_task_lock, flags);
915 diff --git a/drivers/rtc/rtc-tegra.c b/drivers/rtc/rtc-tegra.c
916 index 2fc31aa..75259fe 100644
917 --- a/drivers/rtc/rtc-tegra.c
918 +++ b/drivers/rtc/rtc-tegra.c
919 @@ -343,7 +343,7 @@ static int __devinit tegra_rtc_probe(struct platform_device *pdev)
920
921 /* set context info. */
922 info->pdev = pdev;
923 - info->tegra_rtc_lock = __SPIN_LOCK_UNLOCKED(info->tegra_rtc_lock);
924 + spin_lock_init(&info->tegra_rtc_lock);
925
926 platform_set_drvdata(pdev, info);
927
928 diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
929 index 6d8dcd4..7f53cea 100644
930 --- a/drivers/scsi/hpsa.h
931 +++ b/drivers/scsi/hpsa.h
932 @@ -214,7 +214,7 @@ static void SA5_submit_command(struct ctlr_info *h,
933 dev_dbg(&h->pdev->dev, "Sending %x, tag = %x\n", c->busaddr,
934 c->Header.Tag.lower);
935 writel(c->busaddr, h->vaddr + SA5_REQUEST_PORT_OFFSET);
936 - (void) readl(h->vaddr + SA5_REQUEST_PORT_OFFSET);
937 + (void) readl(h->vaddr + SA5_SCRATCHPAD_OFFSET);
938 h->commands_outstanding++;
939 if (h->commands_outstanding > h->max_outstanding)
940 h->max_outstanding = h->commands_outstanding;
941 diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c
942 index 874e29d..f84084b 100644
943 --- a/drivers/scsi/libsas/sas_expander.c
944 +++ b/drivers/scsi/libsas/sas_expander.c
945 @@ -849,6 +849,9 @@ static struct domain_device *sas_ex_discover_expander(
946
947 res = sas_discover_expander(child);
948 if (res) {
949 + spin_lock_irq(&parent->port->dev_list_lock);
950 + list_del(&child->dev_list_node);
951 + spin_unlock_irq(&parent->port->dev_list_lock);
952 kfree(child);
953 return NULL;
954 }
955 diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
956 index fca6a89..d079f9a 100644
957 --- a/drivers/scsi/pmcraid.c
958 +++ b/drivers/scsi/pmcraid.c
959 @@ -3871,6 +3871,9 @@ static long pmcraid_ioctl_passthrough(
960 pmcraid_err("couldn't build passthrough ioadls\n");
961 goto out_free_buffer;
962 }
963 + } else if (request_size < 0) {
964 + rc = -EINVAL;
965 + goto out_free_buffer;
966 }
967
968 /* If data is being written into the device, copy the data from user
969 diff --git a/drivers/scsi/scsi_devinfo.c b/drivers/scsi/scsi_devinfo.c
970 index 82e9e5c..cf8dfab 100644
971 --- a/drivers/scsi/scsi_devinfo.c
972 +++ b/drivers/scsi/scsi_devinfo.c
973 @@ -197,6 +197,7 @@ static struct {
974 {"IBM", "ProFibre 4000R", "*", BLIST_SPARSELUN | BLIST_LARGELUN},
975 {"IBM", "2105", NULL, BLIST_RETRY_HWERROR},
976 {"iomega", "jaz 1GB", "J.86", BLIST_NOTQ | BLIST_NOLUN},
977 + {"IOMEGA", "ZIP", NULL, BLIST_NOTQ | BLIST_NOLUN},
978 {"IOMEGA", "Io20S *F", NULL, BLIST_KEY},
979 {"INSITE", "Floptical F*8I", NULL, BLIST_KEY},
980 {"INSITE", "I325VM", NULL, BLIST_KEY},
981 @@ -243,6 +244,7 @@ static struct {
982 {"Tornado-", "F4", "*", BLIST_NOREPORTLUN},
983 {"TOSHIBA", "CDROM", NULL, BLIST_ISROM},
984 {"TOSHIBA", "CD-ROM", NULL, BLIST_ISROM},
985 + {"Traxdata", "CDR4120", NULL, BLIST_NOLUN}, /* locks up */
986 {"USB2.0", "SMARTMEDIA/XD", NULL, BLIST_FORCELUN | BLIST_INQUIRY_36},
987 {"WangDAT", "Model 2600", "01.7", BLIST_SELECT_NO_ATN},
988 {"WangDAT", "Model 3200", "02.2", BLIST_SELECT_NO_ATN},
989 diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
990 index ec1803a..28d9c9d 100644
991 --- a/drivers/scsi/scsi_lib.c
992 +++ b/drivers/scsi/scsi_lib.c
993 @@ -213,6 +213,8 @@ int scsi_execute(struct scsi_device *sdev, const unsigned char *cmd,
994 int ret = DRIVER_ERROR << 24;
995
996 req = blk_get_request(sdev->request_queue, write, __GFP_WAIT);
997 + if (!req)
998 + return ret;
999
1000 if (bufflen && blk_rq_map_kern(sdev->request_queue, req,
1001 buffer, bufflen, __GFP_WAIT))
1002 diff --git a/drivers/scsi/ses.c b/drivers/scsi/ses.c
1003 index eb7a3e8..eba183c 100644
1004 --- a/drivers/scsi/ses.c
1005 +++ b/drivers/scsi/ses.c
1006 @@ -160,6 +160,10 @@ static unsigned char *ses_get_page2_descriptor(struct enclosure_device *edev,
1007 return NULL;
1008 }
1009
1010 +/* For device slot and array device slot elements, byte 3 bit 6
1011 + * is "fault sensed" while byte 3 bit 5 is "fault reqstd". As this
1012 + * code stands these bits are shifted 4 positions right so in
1013 + * sysfs they will appear as bits 2 and 1 respectively. Strange. */
1014 static void ses_get_fault(struct enclosure_device *edev,
1015 struct enclosure_component *ecomp)
1016 {
1017 @@ -181,7 +185,7 @@ static int ses_set_fault(struct enclosure_device *edev,
1018 /* zero is disabled */
1019 break;
1020 case ENCLOSURE_SETTING_ENABLED:
1021 - desc[2] = 0x02;
1022 + desc[3] = 0x20;
1023 break;
1024 default:
1025 /* SES doesn't do the SGPIO blink settings */
1026 diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
1027 index 4778e27..5fc97d2 100644
1028 --- a/drivers/scsi/sr.c
1029 +++ b/drivers/scsi/sr.c
1030 @@ -221,14 +221,33 @@ static unsigned int sr_check_events(struct cdrom_device_info *cdi,
1031 return 0;
1032
1033 events = sr_get_events(cd->device);
1034 + cd->get_event_changed |= events & DISK_EVENT_MEDIA_CHANGE;
1035 +
1036 + /*
1037 + * If earlier GET_EVENT_STATUS_NOTIFICATION and TUR did not agree
1038 + * for several times in a row. We rely on TUR only for this likely
1039 + * broken device, to prevent generating incorrect media changed
1040 + * events for every open().
1041 + */
1042 + if (cd->ignore_get_event) {
1043 + events &= ~DISK_EVENT_MEDIA_CHANGE;
1044 + goto do_tur;
1045 + }
1046 +
1047 /*
1048 * GET_EVENT_STATUS_NOTIFICATION is enough unless MEDIA_CHANGE
1049 * is being cleared. Note that there are devices which hang
1050 * if asked to execute TUR repeatedly.
1051 */
1052 - if (!(clearing & DISK_EVENT_MEDIA_CHANGE))
1053 - goto skip_tur;
1054 + if (cd->device->changed) {
1055 + events |= DISK_EVENT_MEDIA_CHANGE;
1056 + cd->device->changed = 0;
1057 + cd->tur_changed = true;
1058 + }
1059
1060 + if (!(clearing & DISK_EVENT_MEDIA_CHANGE))
1061 + return events;
1062 +do_tur:
1063 /* let's see whether the media is there with TUR */
1064 last_present = cd->media_present;
1065 ret = scsi_test_unit_ready(cd->device, SR_TIMEOUT, MAX_RETRIES, &sshdr);
1066 @@ -242,12 +261,31 @@ static unsigned int sr_check_events(struct cdrom_device_info *cdi,
1067 (scsi_sense_valid(&sshdr) && sshdr.asc != 0x3a);
1068
1069 if (last_present != cd->media_present)
1070 - events |= DISK_EVENT_MEDIA_CHANGE;
1071 -skip_tur:
1072 + cd->device->changed = 1;
1073 +
1074 if (cd->device->changed) {
1075 events |= DISK_EVENT_MEDIA_CHANGE;
1076 cd->device->changed = 0;
1077 + cd->tur_changed = true;
1078 + }
1079 +
1080 + if (cd->ignore_get_event)
1081 + return events;
1082 +
1083 + /* check whether GET_EVENT is reporting spurious MEDIA_CHANGE */
1084 + if (!cd->tur_changed) {
1085 + if (cd->get_event_changed) {
1086 + if (cd->tur_mismatch++ > 8) {
1087 + sdev_printk(KERN_WARNING, cd->device,
1088 + "GET_EVENT and TUR disagree continuously, suppress GET_EVENT events\n");
1089 + cd->ignore_get_event = true;
1090 + }
1091 + } else {
1092 + cd->tur_mismatch = 0;
1093 + }
1094 }
1095 + cd->tur_changed = false;
1096 + cd->get_event_changed = false;
1097
1098 return events;
1099 }
1100 diff --git a/drivers/scsi/sr.h b/drivers/scsi/sr.h
1101 index e036f1d..37c8f6b 100644
1102 --- a/drivers/scsi/sr.h
1103 +++ b/drivers/scsi/sr.h
1104 @@ -41,6 +41,13 @@ typedef struct scsi_cd {
1105 unsigned readcd_known:1; /* drive supports READ_CD (0xbe) */
1106 unsigned readcd_cdda:1; /* reading audio data using READ_CD */
1107 unsigned media_present:1; /* media is present */
1108 +
1109 + /* GET_EVENT spurious event handling, blk layer guarantees exclusion */
1110 + int tur_mismatch; /* nr of get_event TUR mismatches */
1111 + bool tur_changed:1; /* changed according to TUR */
1112 + bool get_event_changed:1; /* changed according to GET_EVENT */
1113 + bool ignore_get_event:1; /* GET_EVENT is unreliable, use TUR */
1114 +
1115 struct cdrom_device_info cdi;
1116 /* We hold gendisk and scsi_device references on probe and use
1117 * the refs on this kref to decide when to release them */
1118 diff --git a/drivers/staging/ath6kl/os/linux/ar6000_drv.c b/drivers/staging/ath6kl/os/linux/ar6000_drv.c
1119 index 48dd9e3..aa97efc 100644
1120 --- a/drivers/staging/ath6kl/os/linux/ar6000_drv.c
1121 +++ b/drivers/staging/ath6kl/os/linux/ar6000_drv.c
1122 @@ -954,9 +954,13 @@ ar6000_transfer_bin_file(struct ar6_softc *ar, AR6K_BIN_FILE file, u32 address,
1123 const char *filename;
1124 const struct firmware *fw_entry;
1125 u32 fw_entry_size;
1126 + u8 **buf;
1127 + size_t *buf_len;
1128
1129 switch (file) {
1130 case AR6K_OTP_FILE:
1131 + buf = &ar->fw_otp;
1132 + buf_len = &ar->fw_otp_len;
1133 if (ar->arVersion.target_ver == AR6003_REV1_VERSION) {
1134 filename = AR6003_REV1_OTP_FILE;
1135 } else if (ar->arVersion.target_ver == AR6003_REV2_VERSION) {
1136 @@ -970,6 +974,8 @@ ar6000_transfer_bin_file(struct ar6_softc *ar, AR6K_BIN_FILE file, u32 address,
1137 break;
1138
1139 case AR6K_FIRMWARE_FILE:
1140 + buf = &ar->fw;
1141 + buf_len = &ar->fw_len;
1142 if (ar->arVersion.target_ver == AR6003_REV1_VERSION) {
1143 filename = AR6003_REV1_FIRMWARE_FILE;
1144 } else if (ar->arVersion.target_ver == AR6003_REV2_VERSION) {
1145 @@ -1028,6 +1034,8 @@ ar6000_transfer_bin_file(struct ar6_softc *ar, AR6K_BIN_FILE file, u32 address,
1146 break;
1147
1148 case AR6K_PATCH_FILE:
1149 + buf = &ar->fw_patch;
1150 + buf_len = &ar->fw_patch_len;
1151 if (ar->arVersion.target_ver == AR6003_REV1_VERSION) {
1152 filename = AR6003_REV1_PATCH_FILE;
1153 } else if (ar->arVersion.target_ver == AR6003_REV2_VERSION) {
1154 @@ -1041,6 +1049,8 @@ ar6000_transfer_bin_file(struct ar6_softc *ar, AR6K_BIN_FILE file, u32 address,
1155 break;
1156
1157 case AR6K_BOARD_DATA_FILE:
1158 + buf = &ar->fw_data;
1159 + buf_len = &ar->fw_data_len;
1160 if (ar->arVersion.target_ver == AR6003_REV1_VERSION) {
1161 filename = AR6003_REV1_BOARD_DATA_FILE;
1162 } else if (ar->arVersion.target_ver == AR6003_REV2_VERSION) {
1163 @@ -1057,23 +1067,29 @@ ar6000_transfer_bin_file(struct ar6_softc *ar, AR6K_BIN_FILE file, u32 address,
1164 AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Unknown file type: %d\n", file));
1165 return A_ERROR;
1166 }
1167 - if ((A_REQUEST_FIRMWARE(&fw_entry, filename, ((struct device *)ar->osDevInfo.pOSDevice))) != 0)
1168 - {
1169 - AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Failed to get %s\n", filename));
1170 - return A_ENOENT;
1171 +
1172 + if (*buf == NULL) {
1173 + if ((A_REQUEST_FIRMWARE(&fw_entry, filename, ((struct device *)ar->osDevInfo.pOSDevice))) != 0) {
1174 + AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("Failed to get %s\n", filename));
1175 + return A_ENOENT;
1176 + }
1177 +
1178 + *buf = kmemdup(fw_entry->data, fw_entry->size, GFP_KERNEL);
1179 + *buf_len = fw_entry->size;
1180 + A_RELEASE_FIRMWARE(fw_entry);
1181 }
1182
1183 #ifdef SOFTMAC_FILE_USED
1184 - if (file==AR6K_BOARD_DATA_FILE && fw_entry->data) {
1185 - ar6000_softmac_update(ar, (u8 *)fw_entry->data, fw_entry->size);
1186 + if (file==AR6K_BOARD_DATA_FILE && *buf_len) {
1187 + ar6000_softmac_update(ar, *buf, *buf_len);
1188 }
1189 #endif
1190
1191
1192 - fw_entry_size = fw_entry->size;
1193 + fw_entry_size = *buf_len;
1194
1195 /* Load extended board data for AR6003 */
1196 - if ((file==AR6K_BOARD_DATA_FILE) && (fw_entry->data)) {
1197 + if ((file==AR6K_BOARD_DATA_FILE) && *buf) {
1198 u32 board_ext_address;
1199 u32 board_ext_data_size;
1200 u32 board_data_size;
1201 @@ -1089,14 +1105,13 @@ ar6000_transfer_bin_file(struct ar6_softc *ar, AR6K_BIN_FILE file, u32 address,
1202 AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("Board extended Data download address: 0x%x\n", board_ext_address));
1203
1204 /* check whether the target has allocated memory for extended board data and file contains extended board data */
1205 - if ((board_ext_address) && (fw_entry->size == (board_data_size + board_ext_data_size))) {
1206 + if ((board_ext_address) && (*buf_len == (board_data_size + board_ext_data_size))) {
1207 u32 param;
1208
1209 - status = BMIWriteMemory(ar->arHifDevice, board_ext_address, (u8 *)(fw_entry->data + board_data_size), board_ext_data_size);
1210 + status = BMIWriteMemory(ar->arHifDevice, board_ext_address, (u8 *)(*buf + board_data_size), board_ext_data_size);
1211
1212 if (status) {
1213 AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("BMI operation failed: %d\n", __LINE__));
1214 - A_RELEASE_FIRMWARE(fw_entry);
1215 return A_ERROR;
1216 }
1217
1218 @@ -1110,17 +1125,16 @@ ar6000_transfer_bin_file(struct ar6_softc *ar, AR6K_BIN_FILE file, u32 address,
1219 }
1220
1221 if (compressed) {
1222 - status = BMIFastDownload(ar->arHifDevice, address, (u8 *)fw_entry->data, fw_entry_size);
1223 + status = BMIFastDownload(ar->arHifDevice, address, *buf, fw_entry_size);
1224 } else {
1225 - status = BMIWriteMemory(ar->arHifDevice, address, (u8 *)fw_entry->data, fw_entry_size);
1226 + status = BMIWriteMemory(ar->arHifDevice, address, *buf, fw_entry_size);
1227 }
1228
1229 if (status) {
1230 AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("BMI operation failed: %d\n", __LINE__));
1231 - A_RELEASE_FIRMWARE(fw_entry);
1232 return A_ERROR;
1233 }
1234 - A_RELEASE_FIRMWARE(fw_entry);
1235 +
1236 return 0;
1237 }
1238
1239 @@ -2088,6 +2102,11 @@ ar6000_destroy(struct net_device *dev, unsigned int unregister)
1240 ar6000_remove_ap_interface();
1241 #endif /*CONFIG_AP_VIRTUAL_ADAPTER_SUPPORT */
1242
1243 + kfree(ar->fw_otp);
1244 + kfree(ar->fw);
1245 + kfree(ar->fw_patch);
1246 + kfree(ar->fw_data);
1247 +
1248 AR_DEBUG_PRINTF(ATH_DEBUG_INFO,("-ar6000_destroy \n"));
1249 }
1250
1251 diff --git a/drivers/staging/ath6kl/os/linux/cfg80211.c b/drivers/staging/ath6kl/os/linux/cfg80211.c
1252 index d3a774d..32e3197 100644
1253 --- a/drivers/staging/ath6kl/os/linux/cfg80211.c
1254 +++ b/drivers/staging/ath6kl/os/linux/cfg80211.c
1255 @@ -867,26 +867,31 @@ ar6k_cfg80211_scanComplete_event(struct ar6_softc *ar, int status)
1256
1257 AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("%s: status %d\n", __func__, status));
1258
1259 - if(ar->scan_request)
1260 - {
1261 - /* Translate data to cfg80211 mgmt format */
1262 - if (ar->arWmi)
1263 - wmi_iterate_nodes(ar->arWmi, ar6k_cfg80211_scan_node, ar->wdev->wiphy);
1264 + if (!ar->scan_request)
1265 + return;
1266 +
1267 + if ((status == A_ECANCELED) || (status == A_EBUSY)) {
1268 + cfg80211_scan_done(ar->scan_request, true);
1269 + goto out;
1270 + }
1271 +
1272 + /* Translate data to cfg80211 mgmt format */
1273 + wmi_iterate_nodes(ar->arWmi, ar6k_cfg80211_scan_node, ar->wdev->wiphy);
1274
1275 - cfg80211_scan_done(ar->scan_request,
1276 - ((status & A_ECANCELED) || (status & A_EBUSY)) ? true : false);
1277 + cfg80211_scan_done(ar->scan_request, false);
1278
1279 - if(ar->scan_request->n_ssids &&
1280 - ar->scan_request->ssids[0].ssid_len) {
1281 + if(ar->scan_request->n_ssids &&
1282 + ar->scan_request->ssids[0].ssid_len) {
1283 u8 i;
1284
1285 for (i = 0; i < ar->scan_request->n_ssids; i++) {
1286 - wmi_probedSsid_cmd(ar->arWmi, i+1, DISABLE_SSID_FLAG,
1287 - 0, NULL);
1288 + wmi_probedSsid_cmd(ar->arWmi, i+1, DISABLE_SSID_FLAG,
1289 + 0, NULL);
1290 }
1291 - }
1292 - ar->scan_request = NULL;
1293 }
1294 +
1295 +out:
1296 + ar->scan_request = NULL;
1297 }
1298
1299 static int
1300 diff --git a/drivers/staging/ath6kl/os/linux/include/ar6000_drv.h b/drivers/staging/ath6kl/os/linux/include/ar6000_drv.h
1301 index 22453b0..2911ea0 100644
1302 --- a/drivers/staging/ath6kl/os/linux/include/ar6000_drv.h
1303 +++ b/drivers/staging/ath6kl/os/linux/include/ar6000_drv.h
1304 @@ -651,6 +651,15 @@ struct ar6_softc {
1305 void *arApDev;
1306 #endif
1307 u8 arAutoAuthStage;
1308 +
1309 + u8 *fw_otp;
1310 + size_t fw_otp_len;
1311 + u8 *fw;
1312 + size_t fw_len;
1313 + u8 *fw_patch;
1314 + size_t fw_patch_len;
1315 + u8 *fw_data;
1316 + size_t fw_data_len;
1317 };
1318
1319 #ifdef CONFIG_AP_VIRTUAL_ADAPTER_SUPPORT
1320 diff --git a/drivers/staging/brcm80211/brcmsmac/wl_mac80211.c b/drivers/staging/brcm80211/brcmsmac/wl_mac80211.c
1321 index 6c6236c..aa0d127 100644
1322 --- a/drivers/staging/brcm80211/brcmsmac/wl_mac80211.c
1323 +++ b/drivers/staging/brcm80211/brcmsmac/wl_mac80211.c
1324 @@ -449,11 +449,6 @@ wl_ops_bss_info_changed(struct ieee80211_hw *hw,
1325 wiphy_err(wiphy, "%s: qos enabled: %s (implement)\n", __func__,
1326 info->qos ? "true" : "false");
1327 }
1328 - if (changed & BSS_CHANGED_IDLE) {
1329 - /* Idle changed for this BSS/interface */
1330 - wiphy_err(wiphy, "%s: BSS idle: %s (implement)\n", __func__,
1331 - info->idle ? "true" : "false");
1332 - }
1333 return;
1334 }
1335
1336 diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c
1337 index e7e72b8..c20694e 100644
1338 --- a/drivers/staging/comedi/comedi_fops.c
1339 +++ b/drivers/staging/comedi/comedi_fops.c
1340 @@ -383,8 +383,8 @@ static int do_devinfo_ioctl(struct comedi_device *dev,
1341 /* fill devinfo structure */
1342 devinfo.version_code = COMEDI_VERSION_CODE;
1343 devinfo.n_subdevs = dev->n_subdevices;
1344 - memcpy(devinfo.driver_name, dev->driver->driver_name, COMEDI_NAMELEN);
1345 - memcpy(devinfo.board_name, dev->board_name, COMEDI_NAMELEN);
1346 + strlcpy(devinfo.driver_name, dev->driver->driver_name, COMEDI_NAMELEN);
1347 + strlcpy(devinfo.board_name, dev->board_name, COMEDI_NAMELEN);
1348
1349 if (read_subdev)
1350 devinfo.read_subdevice = read_subdev - dev->subdevices;
1351 diff --git a/drivers/staging/hv/channel.c b/drivers/staging/hv/channel.c
1352 index f655e59..d971bab 100644
1353 --- a/drivers/staging/hv/channel.c
1354 +++ b/drivers/staging/hv/channel.c
1355 @@ -212,7 +212,7 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
1356 if (ret != 0)
1357 goto Cleanup;
1358
1359 - t = wait_for_completion_timeout(&openInfo->waitevent, HZ);
1360 + t = wait_for_completion_timeout(&openInfo->waitevent, 5*HZ);
1361 if (t == 0) {
1362 err = -ETIMEDOUT;
1363 goto errorout;
1364 diff --git a/drivers/staging/hv/channel_mgmt.c b/drivers/staging/hv/channel_mgmt.c
1365 index 957d61e..e2e7d05 100644
1366 --- a/drivers/staging/hv/channel_mgmt.c
1367 +++ b/drivers/staging/hv/channel_mgmt.c
1368 @@ -773,7 +773,7 @@ int vmbus_request_offers(void)
1369 goto cleanup;
1370 }
1371
1372 - t = wait_for_completion_timeout(&msginfo->waitevent, HZ);
1373 + t = wait_for_completion_timeout(&msginfo->waitevent, 5*HZ);
1374 if (t == 0) {
1375 ret = -ETIMEDOUT;
1376 goto cleanup;
1377 diff --git a/drivers/staging/hv/connection.c b/drivers/staging/hv/connection.c
1378 index 37bbf77..91c65ad 100644
1379 --- a/drivers/staging/hv/connection.c
1380 +++ b/drivers/staging/hv/connection.c
1381 @@ -135,7 +135,7 @@ int vmbus_connect(void)
1382 }
1383
1384 /* Wait for the connection response */
1385 - t = wait_for_completion_timeout(&msginfo->waitevent, HZ);
1386 + t = wait_for_completion_timeout(&msginfo->waitevent, 5*HZ);
1387 if (t == 0) {
1388 spin_lock_irqsave(&vmbus_connection.channelmsg_lock,
1389 flags);
1390 diff --git a/drivers/staging/hv/netvsc.c b/drivers/staging/hv/netvsc.c
1391 index 41cbb26..4742b68 100644
1392 --- a/drivers/staging/hv/netvsc.c
1393 +++ b/drivers/staging/hv/netvsc.c
1394 @@ -270,7 +270,7 @@ static int netvsc_init_recv_buf(struct hv_device *device)
1395 goto cleanup;
1396 }
1397
1398 - t = wait_for_completion_timeout(&net_device->channel_init_wait, HZ);
1399 + t = wait_for_completion_timeout(&net_device->channel_init_wait, 5*HZ);
1400 BUG_ON(t == 0);
1401
1402
1403 @@ -513,7 +513,7 @@ static int netvsc_connect_vsp(struct hv_device *device)
1404 if (ret != 0)
1405 goto cleanup;
1406
1407 - t = wait_for_completion_timeout(&net_device->channel_init_wait, HZ);
1408 + t = wait_for_completion_timeout(&net_device->channel_init_wait, 5*HZ);
1409
1410 if (t == 0) {
1411 ret = -ETIMEDOUT;
1412 diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c
1413 index 60ebdb1..b47ebb3 100644
1414 --- a/drivers/staging/hv/rndis_filter.c
1415 +++ b/drivers/staging/hv/rndis_filter.c
1416 @@ -467,7 +467,7 @@ static int rndis_filter_query_device(struct rndis_device *dev, u32 oid,
1417 if (ret != 0)
1418 goto Cleanup;
1419
1420 - t = wait_for_completion_timeout(&request->wait_event, HZ);
1421 + t = wait_for_completion_timeout(&request->wait_event, 5*HZ);
1422 if (t == 0) {
1423 ret = -ETIMEDOUT;
1424 goto Cleanup;
1425 @@ -543,7 +543,7 @@ static int rndis_filter_set_packet_filter(struct rndis_device *dev,
1426 if (ret != 0)
1427 goto Cleanup;
1428
1429 - t = wait_for_completion_timeout(&request->wait_event, HZ);
1430 + t = wait_for_completion_timeout(&request->wait_event, 5*HZ);
1431
1432 if (t == 0) {
1433 ret = -1;
1434 @@ -600,7 +600,7 @@ static int rndis_filter_init_device(struct rndis_device *dev)
1435 }
1436
1437
1438 - t = wait_for_completion_timeout(&request->wait_event, HZ);
1439 + t = wait_for_completion_timeout(&request->wait_event, 5*HZ);
1440
1441 if (t == 0) {
1442 ret = -ETIMEDOUT;
1443 diff --git a/drivers/staging/hv/storvsc.c b/drivers/staging/hv/storvsc.c
1444 index 06cd327..3029786 100644
1445 --- a/drivers/staging/hv/storvsc.c
1446 +++ b/drivers/staging/hv/storvsc.c
1447 @@ -135,7 +135,7 @@ static int storvsc_channel_init(struct hv_device *device)
1448 if (ret != 0)
1449 goto cleanup;
1450
1451 - t = wait_for_completion_timeout(&request->wait_event, HZ);
1452 + t = wait_for_completion_timeout(&request->wait_event, 5*HZ);
1453 if (t == 0) {
1454 ret = -ETIMEDOUT;
1455 goto cleanup;
1456 @@ -163,7 +163,7 @@ static int storvsc_channel_init(struct hv_device *device)
1457 if (ret != 0)
1458 goto cleanup;
1459
1460 - t = wait_for_completion_timeout(&request->wait_event, HZ);
1461 + t = wait_for_completion_timeout(&request->wait_event, 5*HZ);
1462 if (t == 0) {
1463 ret = -ETIMEDOUT;
1464 goto cleanup;
1465 @@ -192,7 +192,7 @@ static int storvsc_channel_init(struct hv_device *device)
1466 if (ret != 0)
1467 goto cleanup;
1468
1469 - t = wait_for_completion_timeout(&request->wait_event, HZ);
1470 + t = wait_for_completion_timeout(&request->wait_event, 5*HZ);
1471 if (t == 0) {
1472 ret = -ETIMEDOUT;
1473 goto cleanup;
1474 @@ -222,7 +222,7 @@ static int storvsc_channel_init(struct hv_device *device)
1475 if (ret != 0)
1476 goto cleanup;
1477
1478 - t = wait_for_completion_timeout(&request->wait_event, HZ);
1479 + t = wait_for_completion_timeout(&request->wait_event, 5*HZ);
1480 if (t == 0) {
1481 ret = -ETIMEDOUT;
1482 goto cleanup;
1483 diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c
1484 index 942cc5f..cb4a25b 100644
1485 --- a/drivers/staging/hv/storvsc_drv.c
1486 +++ b/drivers/staging/hv/storvsc_drv.c
1487 @@ -393,7 +393,7 @@ static int storvsc_host_reset(struct hv_device *device)
1488 if (ret != 0)
1489 goto cleanup;
1490
1491 - t = wait_for_completion_timeout(&request->wait_event, HZ);
1492 + t = wait_for_completion_timeout(&request->wait_event, 5*HZ);
1493 if (t == 0) {
1494 ret = -ETIMEDOUT;
1495 goto cleanup;
1496 diff --git a/drivers/staging/rtl8192e/r8192E_core.c b/drivers/staging/rtl8192e/r8192E_core.c
1497 index 58d800f..cd98f89 100644
1498 --- a/drivers/staging/rtl8192e/r8192E_core.c
1499 +++ b/drivers/staging/rtl8192e/r8192E_core.c
1500 @@ -4532,6 +4532,7 @@ static int __devinit rtl8192_pci_probe(struct pci_dev *pdev,
1501 u8 unit = 0;
1502 int ret = -ENODEV;
1503 unsigned long pmem_start, pmem_len, pmem_flags;
1504 + u8 revisionid;
1505
1506 RT_TRACE(COMP_INIT,"Configuring chip resources\n");
1507
1508 @@ -4592,6 +4593,11 @@ static int __devinit rtl8192_pci_probe(struct pci_dev *pdev,
1509 pci_write_config_byte(pdev, 0x41, 0x00);
1510
1511
1512 + pci_read_config_byte(pdev, 0x08, &revisionid);
1513 + /* If the revisionid is 0x10, the device uses rtl8192se. */
1514 + if (pdev->device == 0x8192 && revisionid == 0x10)
1515 + goto fail1;
1516 +
1517 pci_read_config_byte(pdev, 0x05, &unit);
1518 pci_write_config_byte(pdev, 0x05, unit & (~0x04));
1519
1520 diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c
1521 index a76e8fa..76d7485 100644
1522 --- a/drivers/staging/usbip/vhci_hcd.c
1523 +++ b/drivers/staging/usbip/vhci_hcd.c
1524 @@ -846,9 +846,9 @@ static void vhci_shutdown_connection(struct usbip_device *ud)
1525 }
1526
1527 /* kill threads related to this sdev, if v.c. exists */
1528 - if (vdev->ud.tcp_rx)
1529 + if (vdev->ud.tcp_rx && !task_is_dead(vdev->ud.tcp_rx))
1530 kthread_stop(vdev->ud.tcp_rx);
1531 - if (vdev->ud.tcp_tx)
1532 + if (vdev->ud.tcp_tx && !task_is_dead(vdev->ud.tcp_tx))
1533 kthread_stop(vdev->ud.tcp_tx);
1534
1535 pr_info("stop threads\n");
1536 diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
1537 index e9cba13..aa84555 100644
1538 --- a/drivers/tty/hvc/hvc_console.c
1539 +++ b/drivers/tty/hvc/hvc_console.c
1540 @@ -163,8 +163,10 @@ static void hvc_console_print(struct console *co, const char *b,
1541 } else {
1542 r = cons_ops[index]->put_chars(vtermnos[index], c, i);
1543 if (r <= 0) {
1544 - /* throw away chars on error */
1545 - i = 0;
1546 + /* throw away characters on error
1547 + * but spin in case of -EAGAIN */
1548 + if (r != -EAGAIN)
1549 + i = 0;
1550 } else if (r > 0) {
1551 i -= r;
1552 if (i > 0)
1553 @@ -448,7 +450,7 @@ static int hvc_push(struct hvc_struct *hp)
1554
1555 n = hp->ops->put_chars(hp->vtermno, hp->outbuf, hp->n_outbuf);
1556 if (n <= 0) {
1557 - if (n == 0) {
1558 + if (n == 0 || n == -EAGAIN) {
1559 hp->do_wakeup = 1;
1560 return 0;
1561 }
1562 diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
1563 index 19b4ae0..c0d34ad 100644
1564 --- a/drivers/tty/n_gsm.c
1565 +++ b/drivers/tty/n_gsm.c
1566 @@ -1823,10 +1823,6 @@ static void gsm0_receive(struct gsm_mux *gsm, unsigned char c)
1567 break;
1568 case GSM_FCS: /* FCS follows the packet */
1569 gsm->received_fcs = c;
1570 - if (c == GSM0_SOF) {
1571 - gsm->state = GSM_SEARCH;
1572 - break;
1573 - }
1574 gsm_queue(gsm);
1575 gsm->state = GSM_SSOF;
1576 break;
1577 diff --git a/drivers/tty/serial/8250.c b/drivers/tty/serial/8250.c
1578 index b4129f5..d32b5bb 100644
1579 --- a/drivers/tty/serial/8250.c
1580 +++ b/drivers/tty/serial/8250.c
1581 @@ -1107,7 +1107,7 @@ static void autoconfig_16550a(struct uart_8250_port *up)
1582 */
1583 DEBUG_AUTOCONF("Xscale ");
1584 up->port.type = PORT_XSCALE;
1585 - up->capabilities |= UART_CAP_UUE;
1586 + up->capabilities |= UART_CAP_UUE | UART_CAP_RTOIE;
1587 return;
1588 }
1589 } else {
1590 diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig
1591 index 636144c..b3692e6 100644
1592 --- a/drivers/tty/serial/Kconfig
1593 +++ b/drivers/tty/serial/Kconfig
1594 @@ -1419,7 +1419,7 @@ config SERIAL_SC26XX
1595
1596 config SERIAL_SC26XX_CONSOLE
1597 bool "Console on SC2681/SC2692 serial port"
1598 - depends on SERIAL_SC26XX
1599 + depends on SERIAL_SC26XX=y
1600 select SERIAL_CORE_CONSOLE
1601 help
1602 Support for Console on SC2681/SC2692 serial ports.
1603 diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
1604 index f8030ee..9ff9abc 100644
1605 --- a/drivers/usb/host/ehci-hcd.c
1606 +++ b/drivers/usb/host/ehci-hcd.c
1607 @@ -94,7 +94,8 @@ static const char hcd_name [] = "ehci_hcd";
1608 #define EHCI_IAA_MSECS 10 /* arbitrary */
1609 #define EHCI_IO_JIFFIES (HZ/10) /* io watchdog > irq_thresh */
1610 #define EHCI_ASYNC_JIFFIES (HZ/20) /* async idle timeout */
1611 -#define EHCI_SHRINK_FRAMES 5 /* async qh unlink delay */
1612 +#define EHCI_SHRINK_JIFFIES (DIV_ROUND_UP(HZ, 200) + 1)
1613 + /* 200-ms async qh unlink delay */
1614
1615 /* Initial IRQ latency: faster than hw default */
1616 static int log2_irq_thresh = 0; // 0 to 6
1617 @@ -152,10 +153,7 @@ timer_action(struct ehci_hcd *ehci, enum ehci_timer_action action)
1618 break;
1619 /* case TIMER_ASYNC_SHRINK: */
1620 default:
1621 - /* add a jiffie since we synch against the
1622 - * 8 KHz uframe counter.
1623 - */
1624 - t = DIV_ROUND_UP(EHCI_SHRINK_FRAMES * HZ, 1000) + 1;
1625 + t = EHCI_SHRINK_JIFFIES;
1626 break;
1627 }
1628 mod_timer(&ehci->watchdog, t + jiffies);
1629 diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
1630 index ea6184b..88cfb8f 100644
1631 --- a/drivers/usb/host/ehci-hub.c
1632 +++ b/drivers/usb/host/ehci-hub.c
1633 @@ -891,10 +891,11 @@ static int ehci_hub_control (
1634 * power switching; they're allowed to just limit the
1635 * current. khubd will turn the power back on.
1636 */
1637 - if (HCS_PPC (ehci->hcs_params)){
1638 + if ((temp & PORT_OC) && HCS_PPC(ehci->hcs_params)) {
1639 ehci_writel(ehci,
1640 temp & ~(PORT_RWC_BITS | PORT_POWER),
1641 status_reg);
1642 + temp = ehci_readl(ehci, status_reg);
1643 }
1644 }
1645
1646 diff --git a/drivers/usb/host/ehci-q.c b/drivers/usb/host/ehci-q.c
1647 index 5d6bc62..0917e3a 100644
1648 --- a/drivers/usb/host/ehci-q.c
1649 +++ b/drivers/usb/host/ehci-q.c
1650 @@ -103,7 +103,7 @@ qh_update (struct ehci_hcd *ehci, struct ehci_qh *qh, struct ehci_qtd *qtd)
1651 if (!(hw->hw_info1 & cpu_to_hc32(ehci, 1 << 14))) {
1652 unsigned is_out, epnum;
1653
1654 - is_out = !(qtd->hw_token & cpu_to_hc32(ehci, 1 << 8));
1655 + is_out = qh->is_out;
1656 epnum = (hc32_to_cpup(ehci, &hw->hw_info1) >> 8) & 0x0f;
1657 if (unlikely (!usb_gettoggle (qh->dev, epnum, is_out))) {
1658 hw->hw_token &= ~cpu_to_hc32(ehci, QTD_TOGGLE);
1659 @@ -946,6 +946,7 @@ done:
1660 hw = qh->hw;
1661 hw->hw_info1 = cpu_to_hc32(ehci, info1);
1662 hw->hw_info2 = cpu_to_hc32(ehci, info2);
1663 + qh->is_out = !is_input;
1664 usb_settoggle (urb->dev, usb_pipeendpoint (urb->pipe), !is_input, 1);
1665 qh_refresh (ehci, qh);
1666 return qh;
1667 @@ -1231,6 +1232,8 @@ static void start_unlink_async (struct ehci_hcd *ehci, struct ehci_qh *qh)
1668
1669 prev->hw->hw_next = qh->hw->hw_next;
1670 prev->qh_next = qh->qh_next;
1671 + if (ehci->qh_scan_next == qh)
1672 + ehci->qh_scan_next = qh->qh_next.qh;
1673 wmb ();
1674
1675 /* If the controller isn't running, we don't have to wait for it */
1676 @@ -1256,53 +1259,49 @@ static void scan_async (struct ehci_hcd *ehci)
1677 struct ehci_qh *qh;
1678 enum ehci_timer_action action = TIMER_IO_WATCHDOG;
1679
1680 - ehci->stamp = ehci_readl(ehci, &ehci->regs->frame_index);
1681 timer_action_done (ehci, TIMER_ASYNC_SHRINK);
1682 -rescan:
1683 stopped = !HC_IS_RUNNING(ehci_to_hcd(ehci)->state);
1684 - qh = ehci->async->qh_next.qh;
1685 - if (likely (qh != NULL)) {
1686 - do {
1687 - /* clean any finished work for this qh */
1688 - if (!list_empty(&qh->qtd_list) && (stopped ||
1689 - qh->stamp != ehci->stamp)) {
1690 - int temp;
1691 -
1692 - /* unlinks could happen here; completion
1693 - * reporting drops the lock. rescan using
1694 - * the latest schedule, but don't rescan
1695 - * qhs we already finished (no looping)
1696 - * unless the controller is stopped.
1697 - */
1698 - qh = qh_get (qh);
1699 - qh->stamp = ehci->stamp;
1700 - temp = qh_completions (ehci, qh);
1701 - if (qh->needs_rescan)
1702 - unlink_async(ehci, qh);
1703 - qh_put (qh);
1704 - if (temp != 0) {
1705 - goto rescan;
1706 - }
1707 - }
1708
1709 - /* unlink idle entries, reducing DMA usage as well
1710 - * as HCD schedule-scanning costs. delay for any qh
1711 - * we just scanned, there's a not-unusual case that it
1712 - * doesn't stay idle for long.
1713 - * (plus, avoids some kind of re-activation race.)
1714 + ehci->qh_scan_next = ehci->async->qh_next.qh;
1715 + while (ehci->qh_scan_next) {
1716 + qh = ehci->qh_scan_next;
1717 + ehci->qh_scan_next = qh->qh_next.qh;
1718 + rescan:
1719 + /* clean any finished work for this qh */
1720 + if (!list_empty(&qh->qtd_list)) {
1721 + int temp;
1722 +
1723 + /*
1724 + * Unlinks could happen here; completion reporting
1725 + * drops the lock. That's why ehci->qh_scan_next
1726 + * always holds the next qh to scan; if the next qh
1727 + * gets unlinked then ehci->qh_scan_next is adjusted
1728 + * in start_unlink_async().
1729 */
1730 - if (list_empty(&qh->qtd_list)
1731 - && qh->qh_state == QH_STATE_LINKED) {
1732 - if (!ehci->reclaim && (stopped ||
1733 - ((ehci->stamp - qh->stamp) & 0x1fff)
1734 - >= EHCI_SHRINK_FRAMES * 8))
1735 - start_unlink_async(ehci, qh);
1736 - else
1737 - action = TIMER_ASYNC_SHRINK;
1738 - }
1739 + qh = qh_get(qh);
1740 + temp = qh_completions(ehci, qh);
1741 + if (qh->needs_rescan)
1742 + unlink_async(ehci, qh);
1743 + qh->unlink_time = jiffies + EHCI_SHRINK_JIFFIES;
1744 + qh_put(qh);
1745 + if (temp != 0)
1746 + goto rescan;
1747 + }
1748
1749 - qh = qh->qh_next.qh;
1750 - } while (qh);
1751 + /* unlink idle entries, reducing DMA usage as well
1752 + * as HCD schedule-scanning costs. delay for any qh
1753 + * we just scanned, there's a not-unusual case that it
1754 + * doesn't stay idle for long.
1755 + * (plus, avoids some kind of re-activation race.)
1756 + */
1757 + if (list_empty(&qh->qtd_list)
1758 + && qh->qh_state == QH_STATE_LINKED) {
1759 + if (!ehci->reclaim && (stopped ||
1760 + time_after_eq(jiffies, qh->unlink_time)))
1761 + start_unlink_async(ehci, qh);
1762 + else
1763 + action = TIMER_ASYNC_SHRINK;
1764 + }
1765 }
1766 if (action == TIMER_ASYNC_SHRINK)
1767 timer_action (ehci, TIMER_ASYNC_SHRINK);
1768 diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
1769 index bd6ff48..989e0a8 100644
1770 --- a/drivers/usb/host/ehci.h
1771 +++ b/drivers/usb/host/ehci.h
1772 @@ -75,6 +75,7 @@ struct ehci_hcd { /* one per controller */
1773 struct ehci_qh *async;
1774 struct ehci_qh *dummy; /* For AMD quirk use */
1775 struct ehci_qh *reclaim;
1776 + struct ehci_qh *qh_scan_next;
1777 unsigned scanning : 1;
1778
1779 /* periodic schedule support */
1780 @@ -117,7 +118,6 @@ struct ehci_hcd { /* one per controller */
1781 struct timer_list iaa_watchdog;
1782 struct timer_list watchdog;
1783 unsigned long actions;
1784 - unsigned stamp;
1785 unsigned periodic_stamp;
1786 unsigned random_frame;
1787 unsigned long next_statechange;
1788 @@ -343,6 +343,7 @@ struct ehci_qh {
1789 struct ehci_qh *reclaim; /* next to reclaim */
1790
1791 struct ehci_hcd *ehci;
1792 + unsigned long unlink_time;
1793
1794 /*
1795 * Do NOT use atomic operations for QH refcounting. On some CPUs
1796 @@ -374,6 +375,7 @@ struct ehci_qh {
1797 #define NO_FRAME ((unsigned short)~0) /* pick new start */
1798
1799 struct usb_device *dev; /* access to TT */
1800 + unsigned is_out:1; /* bulk or intr OUT */
1801 unsigned clearing_tt:1; /* Clear-TT-Buf in progress */
1802 };
1803
1804 diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c
1805 index fd93061..04b90ad 100644
1806 --- a/drivers/usb/host/pci-quirks.c
1807 +++ b/drivers/usb/host/pci-quirks.c
1808 @@ -35,6 +35,8 @@
1809 #define OHCI_INTRSTATUS 0x0c
1810 #define OHCI_INTRENABLE 0x10
1811 #define OHCI_INTRDISABLE 0x14
1812 +#define OHCI_FMINTERVAL 0x34
1813 +#define OHCI_HCR (1 << 0) /* host controller reset */
1814 #define OHCI_OCR (1 << 3) /* ownership change request */
1815 #define OHCI_CTRL_RWC (1 << 9) /* remote wakeup connected */
1816 #define OHCI_CTRL_IR (1 << 8) /* interrupt routing */
1817 @@ -497,6 +499,32 @@ static void __devinit quirk_usb_handoff_ohci(struct pci_dev *pdev)
1818
1819 /* reset controller, preserving RWC (and possibly IR) */
1820 writel(control & OHCI_CTRL_MASK, base + OHCI_CONTROL);
1821 + readl(base + OHCI_CONTROL);
1822 +
1823 + /* Some NVIDIA controllers stop working if kept in RESET for too long */
1824 + if (pdev->vendor == PCI_VENDOR_ID_NVIDIA) {
1825 + u32 fminterval;
1826 + int cnt;
1827 +
1828 + /* drive reset for at least 50 ms (7.1.7.5) */
1829 + msleep(50);
1830 +
1831 + /* software reset of the controller, preserving HcFmInterval */
1832 + fminterval = readl(base + OHCI_FMINTERVAL);
1833 + writel(OHCI_HCR, base + OHCI_CMDSTATUS);
1834 +
1835 + /* reset requires max 10 us delay */
1836 + for (cnt = 30; cnt > 0; --cnt) { /* ... allow extra time */
1837 + if ((readl(base + OHCI_CMDSTATUS) & OHCI_HCR) == 0)
1838 + break;
1839 + udelay(1);
1840 + }
1841 + writel(fminterval, base + OHCI_FMINTERVAL);
1842 +
1843 + /* Now we're in the SUSPEND state with all devices reset
1844 + * and wakeups and interrupts disabled
1845 + */
1846 + }
1847
1848 /*
1849 * disable interrupts
1850 diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
1851 index c71b037..dce7182 100644
1852 --- a/drivers/usb/musb/musb_core.c
1853 +++ b/drivers/usb/musb/musb_core.c
1854 @@ -2329,6 +2329,7 @@ static void musb_restore_context(struct musb *musb)
1855 musb->context.index_regs[i].rxhubport);
1856 }
1857 }
1858 + musb_writeb(musb_base, MUSB_INDEX, musb->context.index);
1859 }
1860
1861 static int musb_suspend(struct device *dev)
1862 diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
1863 index 30461fc..0c20831 100644
1864 --- a/drivers/usb/serial/pl2303.c
1865 +++ b/drivers/usb/serial/pl2303.c
1866 @@ -91,6 +91,7 @@ static const struct usb_device_id id_table[] = {
1867 { USB_DEVICE(SONY_VENDOR_ID, SONY_QN3USB_PRODUCT_ID) },
1868 { USB_DEVICE(SANWA_VENDOR_ID, SANWA_PRODUCT_ID) },
1869 { USB_DEVICE(ADLINK_VENDOR_ID, ADLINK_ND6530_PRODUCT_ID) },
1870 + { USB_DEVICE(WINCHIPHEAD_VENDOR_ID, WINCHIPHEAD_USBSER_PRODUCT_ID) },
1871 { } /* Terminating entry */
1872 };
1873
1874 diff --git a/drivers/usb/serial/pl2303.h b/drivers/usb/serial/pl2303.h
1875 index 1b025f7..ca0d237 100644
1876 --- a/drivers/usb/serial/pl2303.h
1877 +++ b/drivers/usb/serial/pl2303.h
1878 @@ -144,3 +144,7 @@
1879 /* ADLINK ND-6530 RS232,RS485 and RS422 adapter */
1880 #define ADLINK_VENDOR_ID 0x0b63
1881 #define ADLINK_ND6530_PRODUCT_ID 0x6530
1882 +
1883 +/* WinChipHead USB->RS 232 adapter */
1884 +#define WINCHIPHEAD_VENDOR_ID 0x4348
1885 +#define WINCHIPHEAD_USBSER_PRODUCT_ID 0x5523
1886 diff --git a/drivers/watchdog/shwdt.c b/drivers/watchdog/shwdt.c
1887 index db84f23..a267dc0 100644
1888 --- a/drivers/watchdog/shwdt.c
1889 +++ b/drivers/watchdog/shwdt.c
1890 @@ -64,7 +64,7 @@
1891 * misses its deadline, the kernel timer will allow the WDT to overflow.
1892 */
1893 static int clock_division_ratio = WTCSR_CKS_4096;
1894 -#define next_ping_period(cks) msecs_to_jiffies(cks - 4)
1895 +#define next_ping_period(cks) (jiffies + msecs_to_jiffies(cks - 4))
1896
1897 static const struct watchdog_info sh_wdt_info;
1898 static struct platform_device *sh_wdt_dev;
1899 diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c
1900 index fa8c21d..d8d26f3 100644
1901 --- a/fs/cifs/dir.c
1902 +++ b/fs/cifs/dir.c
1903 @@ -641,7 +641,7 @@ lookup_out:
1904 static int
1905 cifs_d_revalidate(struct dentry *direntry, struct nameidata *nd)
1906 {
1907 - if (nd->flags & LOOKUP_RCU)
1908 + if (nd && (nd->flags & LOOKUP_RCU))
1909 return -ECHILD;
1910
1911 if (direntry->d_inode) {
1912 diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
1913 index 7349ade..4a4fad7 100644
1914 --- a/fs/ecryptfs/inode.c
1915 +++ b/fs/ecryptfs/inode.c
1916 @@ -69,6 +69,7 @@ static int ecryptfs_inode_set(struct inode *inode, void *opaque)
1917 inode->i_ino = lower_inode->i_ino;
1918 inode->i_version++;
1919 inode->i_mapping->a_ops = &ecryptfs_aops;
1920 + inode->i_mapping->backing_dev_info = inode->i_sb->s_bdi;
1921
1922 if (S_ISLNK(inode->i_mode))
1923 inode->i_op = &ecryptfs_symlink_iops;
1924 diff --git a/fs/ecryptfs/keystore.c b/fs/ecryptfs/keystore.c
1925 index 27a7fef..89dc18e 100644
1926 --- a/fs/ecryptfs/keystore.c
1927 +++ b/fs/ecryptfs/keystore.c
1928 @@ -1868,11 +1868,6 @@ int ecryptfs_parse_packet_set(struct ecryptfs_crypt_stat *crypt_stat,
1929 * just one will be sufficient to decrypt to get the FEK. */
1930 find_next_matching_auth_tok:
1931 found_auth_tok = 0;
1932 - if (auth_tok_key) {
1933 - up_write(&(auth_tok_key->sem));
1934 - key_put(auth_tok_key);
1935 - auth_tok_key = NULL;
1936 - }
1937 list_for_each_entry(auth_tok_list_item, &auth_tok_list, list) {
1938 candidate_auth_tok = &auth_tok_list_item->auth_tok;
1939 if (unlikely(ecryptfs_verbosity > 0)) {
1940 @@ -1909,14 +1904,22 @@ found_matching_auth_tok:
1941 memcpy(&(candidate_auth_tok->token.private_key),
1942 &(matching_auth_tok->token.private_key),
1943 sizeof(struct ecryptfs_private_key));
1944 + up_write(&(auth_tok_key->sem));
1945 + key_put(auth_tok_key);
1946 rc = decrypt_pki_encrypted_session_key(candidate_auth_tok,
1947 crypt_stat);
1948 } else if (candidate_auth_tok->token_type == ECRYPTFS_PASSWORD) {
1949 memcpy(&(candidate_auth_tok->token.password),
1950 &(matching_auth_tok->token.password),
1951 sizeof(struct ecryptfs_password));
1952 + up_write(&(auth_tok_key->sem));
1953 + key_put(auth_tok_key);
1954 rc = decrypt_passphrase_encrypted_session_key(
1955 candidate_auth_tok, crypt_stat);
1956 + } else {
1957 + up_write(&(auth_tok_key->sem));
1958 + key_put(auth_tok_key);
1959 + rc = -EINVAL;
1960 }
1961 if (rc) {
1962 struct ecryptfs_auth_tok_list_item *auth_tok_list_item_tmp;
1963 @@ -1956,15 +1959,12 @@ found_matching_auth_tok:
1964 out_wipe_list:
1965 wipe_auth_tok_list(&auth_tok_list);
1966 out:
1967 - if (auth_tok_key) {
1968 - up_write(&(auth_tok_key->sem));
1969 - key_put(auth_tok_key);
1970 - }
1971 return rc;
1972 }
1973
1974 static int
1975 -pki_encrypt_session_key(struct ecryptfs_auth_tok *auth_tok,
1976 +pki_encrypt_session_key(struct key *auth_tok_key,
1977 + struct ecryptfs_auth_tok *auth_tok,
1978 struct ecryptfs_crypt_stat *crypt_stat,
1979 struct ecryptfs_key_record *key_rec)
1980 {
1981 @@ -1979,6 +1979,8 @@ pki_encrypt_session_key(struct ecryptfs_auth_tok *auth_tok,
1982 crypt_stat->cipher,
1983 crypt_stat->key_size),
1984 crypt_stat, &payload, &payload_len);
1985 + up_write(&(auth_tok_key->sem));
1986 + key_put(auth_tok_key);
1987 if (rc) {
1988 ecryptfs_printk(KERN_ERR, "Error generating tag 66 packet\n");
1989 goto out;
1990 @@ -2008,6 +2010,8 @@ out:
1991 * write_tag_1_packet - Write an RFC2440-compatible tag 1 (public key) packet
1992 * @dest: Buffer into which to write the packet
1993 * @remaining_bytes: Maximum number of bytes that can be writtn
1994 + * @auth_tok_key: The authentication token key to unlock and put when done with
1995 + * @auth_tok
1996 * @auth_tok: The authentication token used for generating the tag 1 packet
1997 * @crypt_stat: The cryptographic context
1998 * @key_rec: The key record struct for the tag 1 packet
1999 @@ -2018,7 +2022,7 @@ out:
2000 */
2001 static int
2002 write_tag_1_packet(char *dest, size_t *remaining_bytes,
2003 - struct ecryptfs_auth_tok *auth_tok,
2004 + struct key *auth_tok_key, struct ecryptfs_auth_tok *auth_tok,
2005 struct ecryptfs_crypt_stat *crypt_stat,
2006 struct ecryptfs_key_record *key_rec, size_t *packet_size)
2007 {
2008 @@ -2039,12 +2043,15 @@ write_tag_1_packet(char *dest, size_t *remaining_bytes,
2009 memcpy(key_rec->enc_key,
2010 auth_tok->session_key.encrypted_key,
2011 auth_tok->session_key.encrypted_key_size);
2012 + up_write(&(auth_tok_key->sem));
2013 + key_put(auth_tok_key);
2014 goto encrypted_session_key_set;
2015 }
2016 if (auth_tok->session_key.encrypted_key_size == 0)
2017 auth_tok->session_key.encrypted_key_size =
2018 auth_tok->token.private_key.key_size;
2019 - rc = pki_encrypt_session_key(auth_tok, crypt_stat, key_rec);
2020 + rc = pki_encrypt_session_key(auth_tok_key, auth_tok, crypt_stat,
2021 + key_rec);
2022 if (rc) {
2023 printk(KERN_ERR "Failed to encrypt session key via a key "
2024 "module; rc = [%d]\n", rc);
2025 @@ -2421,6 +2428,8 @@ ecryptfs_generate_key_packet_set(char *dest_base,
2026 &max, auth_tok,
2027 crypt_stat, key_rec,
2028 &written);
2029 + up_write(&(auth_tok_key->sem));
2030 + key_put(auth_tok_key);
2031 if (rc) {
2032 ecryptfs_printk(KERN_WARNING, "Error "
2033 "writing tag 3 packet\n");
2034 @@ -2438,8 +2447,8 @@ ecryptfs_generate_key_packet_set(char *dest_base,
2035 }
2036 (*len) += written;
2037 } else if (auth_tok->token_type == ECRYPTFS_PRIVATE_KEY) {
2038 - rc = write_tag_1_packet(dest_base + (*len),
2039 - &max, auth_tok,
2040 + rc = write_tag_1_packet(dest_base + (*len), &max,
2041 + auth_tok_key, auth_tok,
2042 crypt_stat, key_rec, &written);
2043 if (rc) {
2044 ecryptfs_printk(KERN_WARNING, "Error "
2045 @@ -2448,14 +2457,13 @@ ecryptfs_generate_key_packet_set(char *dest_base,
2046 }
2047 (*len) += written;
2048 } else {
2049 + up_write(&(auth_tok_key->sem));
2050 + key_put(auth_tok_key);
2051 ecryptfs_printk(KERN_WARNING, "Unsupported "
2052 "authentication token type\n");
2053 rc = -EINVAL;
2054 goto out_free;
2055 }
2056 - up_write(&(auth_tok_key->sem));
2057 - key_put(auth_tok_key);
2058 - auth_tok_key = NULL;
2059 }
2060 if (likely(max > 0)) {
2061 dest_base[(*len)] = 0x00;
2062 @@ -2468,11 +2476,6 @@ out_free:
2063 out:
2064 if (rc)
2065 (*len) = 0;
2066 - if (auth_tok_key) {
2067 - up_write(&(auth_tok_key->sem));
2068 - key_put(auth_tok_key);
2069 - }
2070 -
2071 mutex_unlock(&crypt_stat->keysig_list_mutex);
2072 return rc;
2073 }
2074 diff --git a/fs/ext3/xattr.c b/fs/ext3/xattr.c
2075 index 32e6cc2..d565759 100644
2076 --- a/fs/ext3/xattr.c
2077 +++ b/fs/ext3/xattr.c
2078 @@ -803,8 +803,16 @@ inserted:
2079 /* We need to allocate a new block */
2080 ext3_fsblk_t goal = ext3_group_first_block_no(sb,
2081 EXT3_I(inode)->i_block_group);
2082 - ext3_fsblk_t block = ext3_new_block(handle, inode,
2083 - goal, &error);
2084 + ext3_fsblk_t block;
2085 +
2086 + /*
2087 + * Protect us agaist concurrent allocations to the
2088 + * same inode from ext3_..._writepage(). Reservation
2089 + * code does not expect racing allocations.
2090 + */
2091 + mutex_lock(&EXT3_I(inode)->truncate_mutex);
2092 + block = ext3_new_block(handle, inode, goal, &error);
2093 + mutex_unlock(&EXT3_I(inode)->truncate_mutex);
2094 if (error)
2095 goto cleanup;
2096 ea_idebug(inode, "creating block %d", block);
2097 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
2098 index 1921392..354619a 100644
2099 --- a/fs/ext4/ext4.h
2100 +++ b/fs/ext4/ext4.h
2101 @@ -526,6 +526,7 @@ struct ext4_new_group_data {
2102 #define EXT4_FREE_BLOCKS_METADATA 0x0001
2103 #define EXT4_FREE_BLOCKS_FORGET 0x0002
2104 #define EXT4_FREE_BLOCKS_VALIDATED 0x0004
2105 +#define EXT4_FREE_BLOCKS_NO_QUOT_UPDATE 0x0008
2106
2107 /*
2108 * ioctl commands
2109 diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
2110 index f815cc8..f3aacb3 100644
2111 --- a/fs/ext4/extents.c
2112 +++ b/fs/ext4/extents.c
2113 @@ -3596,17 +3596,18 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode,
2114 }
2115
2116 err = check_eofblocks_fl(handle, inode, map->m_lblk, path, ar.len);
2117 - if (err)
2118 - goto out2;
2119 -
2120 - err = ext4_ext_insert_extent(handle, inode, path, &newex, flags);
2121 + if (!err)
2122 + err = ext4_ext_insert_extent(handle, inode, path,
2123 + &newex, flags);
2124 if (err) {
2125 + int fb_flags = flags & EXT4_GET_BLOCKS_DELALLOC_RESERVE ?
2126 + EXT4_FREE_BLOCKS_NO_QUOT_UPDATE : 0;
2127 /* free data blocks we just allocated */
2128 /* not a good idea to call discard here directly,
2129 * but otherwise we'd need to call it every free() */
2130 ext4_discard_preallocations(inode);
2131 ext4_free_blocks(handle, inode, NULL, ext4_ext_pblock(&newex),
2132 - ext4_ext_get_actual_len(&newex), 0);
2133 + ext4_ext_get_actual_len(&newex), fb_flags);
2134 goto out2;
2135 }
2136
2137 diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
2138 index 6ed859d..0f1be7f 100644
2139 --- a/fs/ext4/mballoc.c
2140 +++ b/fs/ext4/mballoc.c
2141 @@ -4637,7 +4637,7 @@ do_more:
2142 }
2143 ext4_mark_super_dirty(sb);
2144 error_return:
2145 - if (freed)
2146 + if (freed && !(flags & EXT4_FREE_BLOCKS_NO_QUOT_UPDATE))
2147 dquot_free_block(inode, freed);
2148 brelse(bitmap_bh);
2149 ext4_std_error(sb, err);
2150 diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c
2151 index 2a77071..fa780e6 100644
2152 --- a/fs/gfs2/ops_fstype.c
2153 +++ b/fs/gfs2/ops_fstype.c
2154 @@ -1018,13 +1018,13 @@ hostdata_error:
2155 fsname++;
2156 if (lm->lm_mount == NULL) {
2157 fs_info(sdp, "Now mounting FS...\n");
2158 - complete(&sdp->sd_locking_init);
2159 + complete_all(&sdp->sd_locking_init);
2160 return 0;
2161 }
2162 ret = lm->lm_mount(sdp, fsname);
2163 if (ret == 0)
2164 fs_info(sdp, "Joined cluster. Now mounting FS...\n");
2165 - complete(&sdp->sd_locking_init);
2166 + complete_all(&sdp->sd_locking_init);
2167 return ret;
2168 }
2169
2170 diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c
2171 index dd25c2a..321a66b 100644
2172 --- a/fs/nfs/delegation.c
2173 +++ b/fs/nfs/delegation.c
2174 @@ -398,12 +398,11 @@ int nfs_inode_return_delegation(struct inode *inode)
2175 return err;
2176 }
2177
2178 -static void nfs_mark_return_delegation(struct nfs_delegation *delegation)
2179 +static void nfs_mark_return_delegation(struct nfs_server *server,
2180 + struct nfs_delegation *delegation)
2181 {
2182 - struct nfs_client *clp = NFS_SERVER(delegation->inode)->nfs_client;
2183 -
2184 set_bit(NFS_DELEGATION_RETURN, &delegation->flags);
2185 - set_bit(NFS4CLNT_DELEGRETURN, &clp->cl_state);
2186 + set_bit(NFS4CLNT_DELEGRETURN, &server->nfs_client->cl_state);
2187 }
2188
2189 /**
2190 @@ -441,7 +440,7 @@ static void nfs_mark_return_all_delegation_types(struct nfs_server *server,
2191 if ((delegation->type == (FMODE_READ|FMODE_WRITE)) && !(flags & FMODE_WRITE))
2192 continue;
2193 if (delegation->type & flags)
2194 - nfs_mark_return_delegation(delegation);
2195 + nfs_mark_return_delegation(server, delegation);
2196 }
2197 }
2198
2199 @@ -508,7 +507,7 @@ static void nfs_mark_return_unreferenced_delegations(struct nfs_server *server)
2200 list_for_each_entry_rcu(delegation, &server->delegations, super_list) {
2201 if (test_and_clear_bit(NFS_DELEGATION_REFERENCED, &delegation->flags))
2202 continue;
2203 - nfs_mark_return_delegation(delegation);
2204 + nfs_mark_return_delegation(server, delegation);
2205 }
2206 }
2207
2208 @@ -539,7 +538,8 @@ void nfs_expire_unreferenced_delegations(struct nfs_client *clp)
2209 int nfs_async_inode_return_delegation(struct inode *inode,
2210 const nfs4_stateid *stateid)
2211 {
2212 - struct nfs_client *clp = NFS_SERVER(inode)->nfs_client;
2213 + struct nfs_server *server = NFS_SERVER(inode);
2214 + struct nfs_client *clp = server->nfs_client;
2215 struct nfs_delegation *delegation;
2216
2217 rcu_read_lock();
2218 @@ -549,7 +549,7 @@ int nfs_async_inode_return_delegation(struct inode *inode,
2219 rcu_read_unlock();
2220 return -ENOENT;
2221 }
2222 - nfs_mark_return_delegation(delegation);
2223 + nfs_mark_return_delegation(server, delegation);
2224 rcu_read_unlock();
2225
2226 nfs_delegation_run_state_manager(clp);
2227 diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
2228 index ededdbd..f91c62d 100644
2229 --- a/fs/nfs/dir.c
2230 +++ b/fs/nfs/dir.c
2231 @@ -134,18 +134,19 @@ const struct inode_operations nfs4_dir_inode_operations = {
2232
2233 #endif /* CONFIG_NFS_V4 */
2234
2235 -static struct nfs_open_dir_context *alloc_nfs_open_dir_context(struct rpc_cred *cred)
2236 +static struct nfs_open_dir_context *alloc_nfs_open_dir_context(struct inode *dir, struct rpc_cred *cred)
2237 {
2238 struct nfs_open_dir_context *ctx;
2239 ctx = kmalloc(sizeof(*ctx), GFP_KERNEL);
2240 if (ctx != NULL) {
2241 ctx->duped = 0;
2242 + ctx->attr_gencount = NFS_I(dir)->attr_gencount;
2243 ctx->dir_cookie = 0;
2244 ctx->dup_cookie = 0;
2245 ctx->cred = get_rpccred(cred);
2246 - } else
2247 - ctx = ERR_PTR(-ENOMEM);
2248 - return ctx;
2249 + return ctx;
2250 + }
2251 + return ERR_PTR(-ENOMEM);
2252 }
2253
2254 static void put_nfs_open_dir_context(struct nfs_open_dir_context *ctx)
2255 @@ -173,7 +174,7 @@ nfs_opendir(struct inode *inode, struct file *filp)
2256 cred = rpc_lookup_cred();
2257 if (IS_ERR(cred))
2258 return PTR_ERR(cred);
2259 - ctx = alloc_nfs_open_dir_context(cred);
2260 + ctx = alloc_nfs_open_dir_context(inode, cred);
2261 if (IS_ERR(ctx)) {
2262 res = PTR_ERR(ctx);
2263 goto out;
2264 @@ -323,7 +324,6 @@ int nfs_readdir_search_for_pos(struct nfs_cache_array *array, nfs_readdir_descri
2265 {
2266 loff_t diff = desc->file->f_pos - desc->current_index;
2267 unsigned int index;
2268 - struct nfs_open_dir_context *ctx = desc->file->private_data;
2269
2270 if (diff < 0)
2271 goto out_eof;
2272 @@ -336,7 +336,6 @@ int nfs_readdir_search_for_pos(struct nfs_cache_array *array, nfs_readdir_descri
2273 index = (unsigned int)diff;
2274 *desc->dir_cookie = array->array[index].cookie;
2275 desc->cache_entry_index = index;
2276 - ctx->duped = 0;
2277 return 0;
2278 out_eof:
2279 desc->eof = 1;
2280 @@ -349,14 +348,33 @@ int nfs_readdir_search_for_cookie(struct nfs_cache_array *array, nfs_readdir_des
2281 int i;
2282 loff_t new_pos;
2283 int status = -EAGAIN;
2284 - struct nfs_open_dir_context *ctx = desc->file->private_data;
2285
2286 for (i = 0; i < array->size; i++) {
2287 if (array->array[i].cookie == *desc->dir_cookie) {
2288 + struct nfs_inode *nfsi = NFS_I(desc->file->f_path.dentry->d_inode);
2289 + struct nfs_open_dir_context *ctx = desc->file->private_data;
2290 +
2291 new_pos = desc->current_index + i;
2292 - if (new_pos < desc->file->f_pos) {
2293 + if (ctx->attr_gencount != nfsi->attr_gencount
2294 + || (nfsi->cache_validity & (NFS_INO_INVALID_ATTR|NFS_INO_INVALID_DATA))) {
2295 + ctx->duped = 0;
2296 + ctx->attr_gencount = nfsi->attr_gencount;
2297 + } else if (new_pos < desc->file->f_pos) {
2298 + if (ctx->duped > 0
2299 + && ctx->dup_cookie == *desc->dir_cookie) {
2300 + if (printk_ratelimit()) {
2301 + pr_notice("NFS: directory %s/%s contains a readdir loop."
2302 + "Please contact your server vendor. "
2303 + "Offending cookie: %llu\n",
2304 + desc->file->f_dentry->d_parent->d_name.name,
2305 + desc->file->f_dentry->d_name.name,
2306 + *desc->dir_cookie);
2307 + }
2308 + status = -ELOOP;
2309 + goto out;
2310 + }
2311 ctx->dup_cookie = *desc->dir_cookie;
2312 - ctx->duped = 1;
2313 + ctx->duped = -1;
2314 }
2315 desc->file->f_pos = new_pos;
2316 desc->cache_entry_index = i;
2317 @@ -368,6 +386,7 @@ int nfs_readdir_search_for_cookie(struct nfs_cache_array *array, nfs_readdir_des
2318 if (*desc->dir_cookie == array->last_cookie)
2319 desc->eof = 1;
2320 }
2321 +out:
2322 return status;
2323 }
2324
2325 @@ -740,19 +759,6 @@ int nfs_do_filldir(nfs_readdir_descriptor_t *desc, void *dirent,
2326 struct nfs_cache_array *array = NULL;
2327 struct nfs_open_dir_context *ctx = file->private_data;
2328
2329 - if (ctx->duped != 0 && ctx->dup_cookie == *desc->dir_cookie) {
2330 - if (printk_ratelimit()) {
2331 - pr_notice("NFS: directory %s/%s contains a readdir loop. "
2332 - "Please contact your server vendor. "
2333 - "Offending cookie: %llu\n",
2334 - file->f_dentry->d_parent->d_name.name,
2335 - file->f_dentry->d_name.name,
2336 - *desc->dir_cookie);
2337 - }
2338 - res = -ELOOP;
2339 - goto out;
2340 - }
2341 -
2342 array = nfs_readdir_get_array(desc->page);
2343 if (IS_ERR(array)) {
2344 res = PTR_ERR(array);
2345 @@ -774,6 +780,8 @@ int nfs_do_filldir(nfs_readdir_descriptor_t *desc, void *dirent,
2346 *desc->dir_cookie = array->array[i+1].cookie;
2347 else
2348 *desc->dir_cookie = array->last_cookie;
2349 + if (ctx->duped != 0)
2350 + ctx->duped = 1;
2351 }
2352 if (array->eof_index >= 0)
2353 desc->eof = 1;
2354 @@ -805,6 +813,7 @@ int uncached_readdir(nfs_readdir_descriptor_t *desc, void *dirent,
2355 struct page *page = NULL;
2356 int status;
2357 struct inode *inode = desc->file->f_path.dentry->d_inode;
2358 + struct nfs_open_dir_context *ctx = desc->file->private_data;
2359
2360 dfprintk(DIRCACHE, "NFS: uncached_readdir() searching for cookie %Lu\n",
2361 (unsigned long long)*desc->dir_cookie);
2362 @@ -818,6 +827,7 @@ int uncached_readdir(nfs_readdir_descriptor_t *desc, void *dirent,
2363 desc->page_index = 0;
2364 desc->last_cookie = *desc->dir_cookie;
2365 desc->page = page;
2366 + ctx->duped = 0;
2367
2368 status = nfs_readdir_xdr_to_array(desc, page, inode);
2369 if (status < 0)
2370 diff --git a/fs/nfs/nfs4filelayout.c b/fs/nfs/nfs4filelayout.c
2371 index f9d03ab..614c4d2 100644
2372 --- a/fs/nfs/nfs4filelayout.c
2373 +++ b/fs/nfs/nfs4filelayout.c
2374 @@ -170,7 +170,7 @@ filelayout_set_layoutcommit(struct nfs_write_data *wdata)
2375
2376 pnfs_set_layoutcommit(wdata);
2377 dprintk("%s ionde %lu pls_end_pos %lu\n", __func__, wdata->inode->i_ino,
2378 - (unsigned long) wdata->lseg->pls_end_pos);
2379 + (unsigned long) NFS_I(wdata->inode)->layout->plh_lwb);
2380 }
2381
2382 /*
2383 diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
2384 index 5879b23..92cfd2e 100644
2385 --- a/fs/nfs/nfs4proc.c
2386 +++ b/fs/nfs/nfs4proc.c
2387 @@ -5850,9 +5850,15 @@ nfs4_layoutcommit_done(struct rpc_task *task, void *calldata)
2388 static void nfs4_layoutcommit_release(void *calldata)
2389 {
2390 struct nfs4_layoutcommit_data *data = calldata;
2391 + struct pnfs_layout_segment *lseg, *tmp;
2392
2393 /* Matched by references in pnfs_set_layoutcommit */
2394 - put_lseg(data->lseg);
2395 + list_for_each_entry_safe(lseg, tmp, &data->lseg_list, pls_lc_list) {
2396 + list_del_init(&lseg->pls_lc_list);
2397 + if (test_and_clear_bit(NFS_LSEG_LAYOUTCOMMIT,
2398 + &lseg->pls_flags))
2399 + put_lseg(lseg);
2400 + }
2401 put_rpccred(data->cred);
2402 kfree(data);
2403 }
2404 diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
2405 index e6e8f3b..fc97fd5 100644
2406 --- a/fs/nfs/nfs4xdr.c
2407 +++ b/fs/nfs/nfs4xdr.c
2408 @@ -1888,7 +1888,7 @@ encode_layoutcommit(struct xdr_stream *xdr,
2409 *p++ = cpu_to_be32(OP_LAYOUTCOMMIT);
2410 /* Only whole file layouts */
2411 p = xdr_encode_hyper(p, 0); /* offset */
2412 - p = xdr_encode_hyper(p, NFS4_MAX_UINT64); /* length */
2413 + p = xdr_encode_hyper(p, args->lastbytewritten + 1); /* length */
2414 *p++ = cpu_to_be32(0); /* reclaim */
2415 p = xdr_encode_opaque_fixed(p, args->stateid.data, NFS4_STATEID_SIZE);
2416 *p++ = cpu_to_be32(1); /* newoffset = TRUE */
2417 diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
2418 index 29c0ca7..a726c0a 100644
2419 --- a/fs/nfs/pnfs.c
2420 +++ b/fs/nfs/pnfs.c
2421 @@ -189,6 +189,7 @@ static void
2422 pnfs_free_layout_hdr(struct pnfs_layout_hdr *lo)
2423 {
2424 struct pnfs_layoutdriver_type *ld = NFS_SERVER(lo->plh_inode)->pnfs_curr_ld;
2425 + put_rpccred(lo->plh_lc_cred);
2426 return ld->alloc_layout_hdr ? ld->free_layout_hdr(lo) : kfree(lo);
2427 }
2428
2429 @@ -223,6 +224,7 @@ static void
2430 init_lseg(struct pnfs_layout_hdr *lo, struct pnfs_layout_segment *lseg)
2431 {
2432 INIT_LIST_HEAD(&lseg->pls_list);
2433 + INIT_LIST_HEAD(&lseg->pls_lc_list);
2434 atomic_set(&lseg->pls_refcount, 1);
2435 smp_mb();
2436 set_bit(NFS_LSEG_VALID, &lseg->pls_flags);
2437 @@ -805,7 +807,9 @@ out:
2438 }
2439
2440 static struct pnfs_layout_hdr *
2441 -alloc_init_layout_hdr(struct inode *ino, gfp_t gfp_flags)
2442 +alloc_init_layout_hdr(struct inode *ino,
2443 + struct nfs_open_context *ctx,
2444 + gfp_t gfp_flags)
2445 {
2446 struct pnfs_layout_hdr *lo;
2447
2448 @@ -817,11 +821,14 @@ alloc_init_layout_hdr(struct inode *ino, gfp_t gfp_flags)
2449 INIT_LIST_HEAD(&lo->plh_segs);
2450 INIT_LIST_HEAD(&lo->plh_bulk_recall);
2451 lo->plh_inode = ino;
2452 + lo->plh_lc_cred = get_rpccred(ctx->state->owner->so_cred);
2453 return lo;
2454 }
2455
2456 static struct pnfs_layout_hdr *
2457 -pnfs_find_alloc_layout(struct inode *ino, gfp_t gfp_flags)
2458 +pnfs_find_alloc_layout(struct inode *ino,
2459 + struct nfs_open_context *ctx,
2460 + gfp_t gfp_flags)
2461 {
2462 struct nfs_inode *nfsi = NFS_I(ino);
2463 struct pnfs_layout_hdr *new = NULL;
2464 @@ -836,7 +843,7 @@ pnfs_find_alloc_layout(struct inode *ino, gfp_t gfp_flags)
2465 return nfsi->layout;
2466 }
2467 spin_unlock(&ino->i_lock);
2468 - new = alloc_init_layout_hdr(ino, gfp_flags);
2469 + new = alloc_init_layout_hdr(ino, ctx, gfp_flags);
2470 spin_lock(&ino->i_lock);
2471
2472 if (likely(nfsi->layout == NULL)) /* Won the race? */
2473 @@ -928,7 +935,7 @@ pnfs_update_layout(struct inode *ino,
2474 if (!pnfs_enabled_sb(NFS_SERVER(ino)))
2475 return NULL;
2476 spin_lock(&ino->i_lock);
2477 - lo = pnfs_find_alloc_layout(ino, gfp_flags);
2478 + lo = pnfs_find_alloc_layout(ino, ctx, gfp_flags);
2479 if (lo == NULL) {
2480 dprintk("%s ERROR: can't get pnfs_layout_hdr\n", __func__);
2481 goto out_unlock;
2482 @@ -1195,16 +1202,17 @@ pnfs_try_to_read_data(struct nfs_read_data *rdata,
2483 }
2484
2485 /*
2486 - * Currently there is only one (whole file) write lseg.
2487 + * There can be multiple RW segments.
2488 */
2489 -static struct pnfs_layout_segment *pnfs_list_write_lseg(struct inode *inode)
2490 +static void pnfs_list_write_lseg(struct inode *inode, struct list_head *listp)
2491 {
2492 - struct pnfs_layout_segment *lseg, *rv = NULL;
2493 + struct pnfs_layout_segment *lseg;
2494
2495 - list_for_each_entry(lseg, &NFS_I(inode)->layout->plh_segs, pls_list)
2496 - if (lseg->pls_range.iomode == IOMODE_RW)
2497 - rv = lseg;
2498 - return rv;
2499 + list_for_each_entry(lseg, &NFS_I(inode)->layout->plh_segs, pls_list) {
2500 + if (lseg->pls_range.iomode == IOMODE_RW &&
2501 + test_bit(NFS_LSEG_LAYOUTCOMMIT, &lseg->pls_flags))
2502 + list_add(&lseg->pls_lc_list, listp);
2503 + }
2504 }
2505
2506 void
2507 @@ -1216,17 +1224,19 @@ pnfs_set_layoutcommit(struct nfs_write_data *wdata)
2508
2509 spin_lock(&nfsi->vfs_inode.i_lock);
2510 if (!test_and_set_bit(NFS_INO_LAYOUTCOMMIT, &nfsi->flags)) {
2511 - /* references matched in nfs4_layoutcommit_release */
2512 - get_lseg(wdata->lseg);
2513 - wdata->lseg->pls_lc_cred =
2514 - get_rpccred(wdata->args.context->state->owner->so_cred);
2515 mark_as_dirty = true;
2516 dprintk("%s: Set layoutcommit for inode %lu ",
2517 __func__, wdata->inode->i_ino);
2518 }
2519 - if (end_pos > wdata->lseg->pls_end_pos)
2520 - wdata->lseg->pls_end_pos = end_pos;
2521 + if (!test_and_set_bit(NFS_LSEG_LAYOUTCOMMIT, &wdata->lseg->pls_flags)) {
2522 + /* references matched in nfs4_layoutcommit_release */
2523 + get_lseg(wdata->lseg);
2524 + }
2525 + if (end_pos > nfsi->layout->plh_lwb)
2526 + nfsi->layout->plh_lwb = end_pos;
2527 spin_unlock(&nfsi->vfs_inode.i_lock);
2528 + dprintk("%s: lseg %p end_pos %llu\n",
2529 + __func__, wdata->lseg, nfsi->layout->plh_lwb);
2530
2531 /* if pnfs_layoutcommit_inode() runs between inode locks, the next one
2532 * will be a noop because NFS_INO_LAYOUTCOMMIT will not be set */
2533 @@ -1248,8 +1258,6 @@ pnfs_layoutcommit_inode(struct inode *inode, bool sync)
2534 {
2535 struct nfs4_layoutcommit_data *data;
2536 struct nfs_inode *nfsi = NFS_I(inode);
2537 - struct pnfs_layout_segment *lseg;
2538 - struct rpc_cred *cred;
2539 loff_t end_pos;
2540 int status = 0;
2541
2542 @@ -1266,30 +1274,25 @@ pnfs_layoutcommit_inode(struct inode *inode, bool sync)
2543 goto out;
2544 }
2545
2546 + INIT_LIST_HEAD(&data->lseg_list);
2547 spin_lock(&inode->i_lock);
2548 if (!test_and_clear_bit(NFS_INO_LAYOUTCOMMIT, &nfsi->flags)) {
2549 spin_unlock(&inode->i_lock);
2550 kfree(data);
2551 goto out;
2552 }
2553 - /*
2554 - * Currently only one (whole file) write lseg which is referenced
2555 - * in pnfs_set_layoutcommit and will be found.
2556 - */
2557 - lseg = pnfs_list_write_lseg(inode);
2558
2559 - end_pos = lseg->pls_end_pos;
2560 - cred = lseg->pls_lc_cred;
2561 - lseg->pls_end_pos = 0;
2562 - lseg->pls_lc_cred = NULL;
2563 + pnfs_list_write_lseg(inode, &data->lseg_list);
2564 +
2565 + end_pos = nfsi->layout->plh_lwb;
2566 + nfsi->layout->plh_lwb = 0;
2567
2568 memcpy(&data->args.stateid.data, nfsi->layout->plh_stateid.data,
2569 sizeof(nfsi->layout->plh_stateid.data));
2570 spin_unlock(&inode->i_lock);
2571
2572 data->args.inode = inode;
2573 - data->lseg = lseg;
2574 - data->cred = cred;
2575 + data->cred = get_rpccred(nfsi->layout->plh_lc_cred);
2576 nfs_fattr_init(&data->fattr);
2577 data->args.bitmask = NFS_SERVER(inode)->cache_consistency_bitmask;
2578 data->res.fattr = &data->fattr;
2579 diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h
2580 index 96bf4e6..9d147d9 100644
2581 --- a/fs/nfs/pnfs.h
2582 +++ b/fs/nfs/pnfs.h
2583 @@ -36,16 +36,16 @@
2584 enum {
2585 NFS_LSEG_VALID = 0, /* cleared when lseg is recalled/returned */
2586 NFS_LSEG_ROC, /* roc bit received from server */
2587 + NFS_LSEG_LAYOUTCOMMIT, /* layoutcommit bit set for layoutcommit */
2588 };
2589
2590 struct pnfs_layout_segment {
2591 struct list_head pls_list;
2592 + struct list_head pls_lc_list;
2593 struct pnfs_layout_range pls_range;
2594 atomic_t pls_refcount;
2595 unsigned long pls_flags;
2596 struct pnfs_layout_hdr *pls_layout;
2597 - struct rpc_cred *pls_lc_cred; /* LAYOUTCOMMIT credential */
2598 - loff_t pls_end_pos; /* LAYOUTCOMMIT write end */
2599 };
2600
2601 enum pnfs_try_status {
2602 @@ -124,6 +124,8 @@ struct pnfs_layout_hdr {
2603 unsigned long plh_block_lgets; /* block LAYOUTGET if >0 */
2604 u32 plh_barrier; /* ignore lower seqids */
2605 unsigned long plh_flags;
2606 + loff_t plh_lwb; /* last write byte for layoutcommit */
2607 + struct rpc_cred *plh_lc_cred; /* layoutcommit cred */
2608 struct inode *plh_inode;
2609 };
2610
2611 diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
2612 index e98f3c2..3b8ad35 100644
2613 --- a/fs/nfsd/nfs4state.c
2614 +++ b/fs/nfsd/nfs4state.c
2615 @@ -381,14 +381,6 @@ static int nfs4_access_to_omode(u32 access)
2616 BUG();
2617 }
2618
2619 -static int nfs4_access_bmap_to_omode(struct nfs4_stateid *stp)
2620 -{
2621 - unsigned int access;
2622 -
2623 - set_access(&access, stp->st_access_bmap);
2624 - return nfs4_access_to_omode(access);
2625 -}
2626 -
2627 static void unhash_generic_stateid(struct nfs4_stateid *stp)
2628 {
2629 list_del(&stp->st_hash);
2630 @@ -398,11 +390,14 @@ static void unhash_generic_stateid(struct nfs4_stateid *stp)
2631
2632 static void free_generic_stateid(struct nfs4_stateid *stp)
2633 {
2634 - int oflag;
2635 + int i;
2636
2637 if (stp->st_access_bmap) {
2638 - oflag = nfs4_access_bmap_to_omode(stp);
2639 - nfs4_file_put_access(stp->st_file, oflag);
2640 + for (i = 1; i < 4; i++) {
2641 + if (test_bit(i, &stp->st_access_bmap))
2642 + nfs4_file_put_access(stp->st_file,
2643 + nfs4_access_to_omode(i));
2644 + }
2645 }
2646 put_nfs4_file(stp->st_file);
2647 kmem_cache_free(stateid_slab, stp);
2648 @@ -2337,15 +2332,6 @@ out:
2649 return ret;
2650 }
2651
2652 -static inline void
2653 -nfs4_file_downgrade(struct nfs4_file *fp, unsigned int share_access)
2654 -{
2655 - if (share_access & NFS4_SHARE_ACCESS_WRITE)
2656 - nfs4_file_put_access(fp, O_WRONLY);
2657 - if (share_access & NFS4_SHARE_ACCESS_READ)
2658 - nfs4_file_put_access(fp, O_RDONLY);
2659 -}
2660 -
2661 static void nfsd_break_one_deleg(struct nfs4_delegation *dp)
2662 {
2663 /* We're assuming the state code never drops its reference
2664 @@ -2556,12 +2542,18 @@ static inline int nfs4_access_to_access(u32 nfs4_access)
2665 return flags;
2666 }
2667
2668 -static __be32 nfs4_get_vfs_file(struct svc_rqst *rqstp, struct nfs4_file
2669 -*fp, struct svc_fh *cur_fh, u32 nfs4_access)
2670 +static __be32 nfs4_get_vfs_file(struct svc_rqst *rqstp, struct nfs4_file *fp,
2671 + struct svc_fh *cur_fh, struct nfsd4_open *open)
2672 {
2673 __be32 status;
2674 - int oflag = nfs4_access_to_omode(nfs4_access);
2675 - int access = nfs4_access_to_access(nfs4_access);
2676 + int oflag = nfs4_access_to_omode(open->op_share_access);
2677 + int access = nfs4_access_to_access(open->op_share_access);
2678 +
2679 + /* CLAIM_DELEGATE_CUR is used in response to a broken lease;
2680 + * allowing it to break the lease and return EAGAIN leaves the
2681 + * client unable to make progress in returning the delegation */
2682 + if (open->op_claim_type == NFS4_OPEN_CLAIM_DELEGATE_CUR)
2683 + access |= NFSD_MAY_NOT_BREAK_LEASE;
2684
2685 if (!fp->fi_fds[oflag]) {
2686 status = nfsd_open(rqstp, cur_fh, S_IFREG, access,
2687 @@ -2586,7 +2578,7 @@ nfs4_new_open(struct svc_rqst *rqstp, struct nfs4_stateid **stpp,
2688 if (stp == NULL)
2689 return nfserr_resource;
2690
2691 - status = nfs4_get_vfs_file(rqstp, fp, cur_fh, open->op_share_access);
2692 + status = nfs4_get_vfs_file(rqstp, fp, cur_fh, open);
2693 if (status) {
2694 kmem_cache_free(stateid_slab, stp);
2695 return status;
2696 @@ -2619,14 +2611,14 @@ nfs4_upgrade_open(struct svc_rqst *rqstp, struct nfs4_file *fp, struct svc_fh *c
2697
2698 new_access = !test_bit(op_share_access, &stp->st_access_bmap);
2699 if (new_access) {
2700 - status = nfs4_get_vfs_file(rqstp, fp, cur_fh, op_share_access);
2701 + status = nfs4_get_vfs_file(rqstp, fp, cur_fh, open);
2702 if (status)
2703 return status;
2704 }
2705 status = nfsd4_truncate(rqstp, cur_fh, open);
2706 if (status) {
2707 if (new_access) {
2708 - int oflag = nfs4_access_to_omode(new_access);
2709 + int oflag = nfs4_access_to_omode(op_share_access);
2710 nfs4_file_put_access(fp, oflag);
2711 }
2712 return status;
2713 @@ -3384,18 +3376,15 @@ out:
2714 return status;
2715 }
2716
2717 -
2718 -/*
2719 - * unset all bits in union bitmap (bmap) that
2720 - * do not exist in share (from successful OPEN_DOWNGRADE)
2721 - */
2722 -static void
2723 -reset_union_bmap_access(unsigned long access, unsigned long *bmap)
2724 +static inline void nfs4_file_downgrade(struct nfs4_stateid *stp, unsigned int to_access)
2725 {
2726 int i;
2727 +
2728 for (i = 1; i < 4; i++) {
2729 - if ((i & access) != i)
2730 - __clear_bit(i, bmap);
2731 + if (test_bit(i, &stp->st_access_bmap) && !(i & to_access)) {
2732 + nfs4_file_put_access(stp->st_file, i);
2733 + __clear_bit(i, &stp->st_access_bmap);
2734 + }
2735 }
2736 }
2737
2738 @@ -3416,7 +3405,6 @@ nfsd4_open_downgrade(struct svc_rqst *rqstp,
2739 {
2740 __be32 status;
2741 struct nfs4_stateid *stp;
2742 - unsigned int share_access;
2743
2744 dprintk("NFSD: nfsd4_open_downgrade on file %.*s\n",
2745 (int)cstate->current_fh.fh_dentry->d_name.len,
2746 @@ -3445,10 +3433,8 @@ nfsd4_open_downgrade(struct svc_rqst *rqstp,
2747 stp->st_deny_bmap, od->od_share_deny);
2748 goto out;
2749 }
2750 - set_access(&share_access, stp->st_access_bmap);
2751 - nfs4_file_downgrade(stp->st_file, share_access & ~od->od_share_access);
2752 + nfs4_file_downgrade(stp, od->od_share_access);
2753
2754 - reset_union_bmap_access(od->od_share_access, &stp->st_access_bmap);
2755 reset_union_bmap_deny(od->od_share_deny, &stp->st_deny_bmap);
2756
2757 update_stateid(&stp->st_stateid);
2758 diff --git a/fs/proc/base.c b/fs/proc/base.c
2759 index fc5bc27..5bff4c6 100644
2760 --- a/fs/proc/base.c
2761 +++ b/fs/proc/base.c
2762 @@ -2707,9 +2707,16 @@ static int do_io_accounting(struct task_struct *task, char *buffer, int whole)
2763 {
2764 struct task_io_accounting acct = task->ioac;
2765 unsigned long flags;
2766 + int result;
2767
2768 - if (!ptrace_may_access(task, PTRACE_MODE_READ))
2769 - return -EACCES;
2770 + result = mutex_lock_killable(&task->signal->cred_guard_mutex);
2771 + if (result)
2772 + return result;
2773 +
2774 + if (!ptrace_may_access(task, PTRACE_MODE_READ)) {
2775 + result = -EACCES;
2776 + goto out_unlock;
2777 + }
2778
2779 if (whole && lock_task_sighand(task, &flags)) {
2780 struct task_struct *t = task;
2781 @@ -2720,7 +2727,7 @@ static int do_io_accounting(struct task_struct *task, char *buffer, int whole)
2782
2783 unlock_task_sighand(task, &flags);
2784 }
2785 - return sprintf(buffer,
2786 + result = sprintf(buffer,
2787 "rchar: %llu\n"
2788 "wchar: %llu\n"
2789 "syscr: %llu\n"
2790 @@ -2735,6 +2742,9 @@ static int do_io_accounting(struct task_struct *task, char *buffer, int whole)
2791 (unsigned long long)acct.read_bytes,
2792 (unsigned long long)acct.write_bytes,
2793 (unsigned long long)acct.cancelled_write_bytes);
2794 +out_unlock:
2795 + mutex_unlock(&task->signal->cred_guard_mutex);
2796 + return result;
2797 }
2798
2799 static int proc_tid_io_accounting(struct task_struct *task, char *buffer)
2800 diff --git a/include/linux/firewire-cdev.h b/include/linux/firewire-cdev.h
2801 index 4ff0988..55814aa 100644
2802 --- a/include/linux/firewire-cdev.h
2803 +++ b/include/linux/firewire-cdev.h
2804 @@ -475,6 +475,9 @@ union fw_cdev_event {
2805 * of the bus. This does not cause a bus reset to happen.
2806 * @bus_reset_closure: Value of &closure in this and subsequent bus reset events
2807 * @card: The index of the card this device belongs to
2808 + *
2809 + * As a side effect, reception of %FW_CDEV_EVENT_BUS_RESET events to be read(2)
2810 + * is started by this ioctl.
2811 */
2812 struct fw_cdev_get_info {
2813 __u32 version;
2814 diff --git a/include/linux/mm.h b/include/linux/mm.h
2815 index 9670f71..1036614 100644
2816 --- a/include/linux/mm.h
2817 +++ b/include/linux/mm.h
2818 @@ -985,6 +985,8 @@ int get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
2819 int get_user_pages_fast(unsigned long start, int nr_pages, int write,
2820 struct page **pages);
2821 struct page *get_dump_page(unsigned long addr);
2822 +extern int fixup_user_fault(struct task_struct *tsk, struct mm_struct *mm,
2823 + unsigned long address, unsigned int fault_flags);
2824
2825 extern int try_to_release_page(struct page * page, gfp_t gfp_mask);
2826 extern void do_invalidatepage(struct page *page, unsigned long offset);
2827 diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
2828 index 9e19477..33b5968 100644
2829 --- a/include/linux/netdevice.h
2830 +++ b/include/linux/netdevice.h
2831 @@ -1688,9 +1688,12 @@ static inline int skb_gro_header_hard(struct sk_buff *skb, unsigned int hlen)
2832 static inline void *skb_gro_header_slow(struct sk_buff *skb, unsigned int hlen,
2833 unsigned int offset)
2834 {
2835 + if (!pskb_may_pull(skb, hlen))
2836 + return NULL;
2837 +
2838 NAPI_GRO_CB(skb)->frag0 = NULL;
2839 NAPI_GRO_CB(skb)->frag0_len = 0;
2840 - return pskb_may_pull(skb, hlen) ? skb->data + offset : NULL;
2841 + return skb->data + offset;
2842 }
2843
2844 static inline void *skb_gro_mac_header(struct sk_buff *skb)
2845 diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h
2846 index 1b93b9c..b522370 100644
2847 --- a/include/linux/nfs_fs.h
2848 +++ b/include/linux/nfs_fs.h
2849 @@ -99,9 +99,10 @@ struct nfs_open_context {
2850
2851 struct nfs_open_dir_context {
2852 struct rpc_cred *cred;
2853 + unsigned long attr_gencount;
2854 __u64 dir_cookie;
2855 __u64 dup_cookie;
2856 - int duped;
2857 + signed char duped;
2858 };
2859
2860 /*
2861 diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h
2862 index 00848d8..be2eba7 100644
2863 --- a/include/linux/nfs_xdr.h
2864 +++ b/include/linux/nfs_xdr.h
2865 @@ -262,7 +262,7 @@ struct nfs4_layoutcommit_res {
2866 struct nfs4_layoutcommit_data {
2867 struct rpc_task task;
2868 struct nfs_fattr fattr;
2869 - struct pnfs_layout_segment *lseg;
2870 + struct list_head lseg_list;
2871 struct rpc_cred *cred;
2872 struct nfs4_layoutcommit_args args;
2873 struct nfs4_layoutcommit_res res;
2874 diff --git a/ipc/sem.c b/ipc/sem.c
2875 index 34193ed..e68a8f5 100644
2876 --- a/ipc/sem.c
2877 +++ b/ipc/sem.c
2878 @@ -1456,15 +1456,24 @@ SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsops,
2879 }
2880
2881 sma = sem_lock(ns, semid);
2882 +
2883 + /*
2884 + * Wait until it's guaranteed that no wakeup_sem_queue_do() is ongoing.
2885 + */
2886 + error = get_queue_result(&queue);
2887 +
2888 + /*
2889 + * Array removed? If yes, leave without sem_unlock().
2890 + */
2891 if (IS_ERR(sma)) {
2892 error = -EIDRM;
2893 goto out_free;
2894 }
2895
2896 - error = get_queue_result(&queue);
2897
2898 /*
2899 - * If queue.status != -EINTR we are woken up by another process
2900 + * If queue.status != -EINTR we are woken up by another process.
2901 + * Leave without unlink_queue(), but with sem_unlock().
2902 */
2903
2904 if (error != -EINTR) {
2905 diff --git a/kernel/events/core.c b/kernel/events/core.c
2906 index 9efe710..32a6151 100644
2907 --- a/kernel/events/core.c
2908 +++ b/kernel/events/core.c
2909 @@ -5016,11 +5016,8 @@ static int __perf_event_overflow(struct perf_event *event, int nmi,
2910 if (events && atomic_dec_and_test(&event->event_limit)) {
2911 ret = 1;
2912 event->pending_kill = POLL_HUP;
2913 - if (nmi) {
2914 - event->pending_disable = 1;
2915 - irq_work_queue(&event->pending);
2916 - } else
2917 - perf_event_disable(event);
2918 + event->pending_disable = 1;
2919 + irq_work_queue(&event->pending);
2920 }
2921
2922 if (event->overflow_handler)
2923 diff --git a/kernel/futex.c b/kernel/futex.c
2924 index fe28dc2..7a0a4ed 100644
2925 --- a/kernel/futex.c
2926 +++ b/kernel/futex.c
2927 @@ -355,8 +355,8 @@ static int fault_in_user_writeable(u32 __user *uaddr)
2928 int ret;
2929
2930 down_read(&mm->mmap_sem);
2931 - ret = get_user_pages(current, mm, (unsigned long)uaddr,
2932 - 1, 1, 0, NULL, NULL);
2933 + ret = fixup_user_fault(current, mm, (unsigned long)uaddr,
2934 + FAULT_FLAG_WRITE);
2935 up_read(&mm->mmap_sem);
2936
2937 return ret < 0 ? ret : 0;
2938 diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
2939 index 229f859..f807407 100644
2940 --- a/kernel/trace/trace.h
2941 +++ b/kernel/trace/trace.h
2942 @@ -677,6 +677,7 @@ struct event_subsystem {
2943 struct dentry *entry;
2944 struct event_filter *filter;
2945 int nr_events;
2946 + int ref_count;
2947 };
2948
2949 #define FILTER_PRED_INVALID ((unsigned short)-1)
2950 diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
2951 index 686ec39..3e2a7c9 100644
2952 --- a/kernel/trace/trace_events.c
2953 +++ b/kernel/trace/trace_events.c
2954 @@ -244,6 +244,35 @@ static void ftrace_clear_events(void)
2955 mutex_unlock(&event_mutex);
2956 }
2957
2958 +static void __put_system(struct event_subsystem *system)
2959 +{
2960 + struct event_filter *filter = system->filter;
2961 +
2962 + WARN_ON_ONCE(system->ref_count == 0);
2963 + if (--system->ref_count)
2964 + return;
2965 +
2966 + if (filter) {
2967 + kfree(filter->filter_string);
2968 + kfree(filter);
2969 + }
2970 + kfree(system->name);
2971 + kfree(system);
2972 +}
2973 +
2974 +static void __get_system(struct event_subsystem *system)
2975 +{
2976 + WARN_ON_ONCE(system->ref_count == 0);
2977 + system->ref_count++;
2978 +}
2979 +
2980 +static void put_system(struct event_subsystem *system)
2981 +{
2982 + mutex_lock(&event_mutex);
2983 + __put_system(system);
2984 + mutex_unlock(&event_mutex);
2985 +}
2986 +
2987 /*
2988 * __ftrace_set_clr_event(NULL, NULL, NULL, set) will set/unset all events.
2989 */
2990 @@ -528,7 +557,7 @@ system_enable_read(struct file *filp, char __user *ubuf, size_t cnt,
2991 loff_t *ppos)
2992 {
2993 const char set_to_char[4] = { '?', '0', '1', 'X' };
2994 - const char *system = filp->private_data;
2995 + struct event_subsystem *system = filp->private_data;
2996 struct ftrace_event_call *call;
2997 char buf[2];
2998 int set = 0;
2999 @@ -539,7 +568,7 @@ system_enable_read(struct file *filp, char __user *ubuf, size_t cnt,
3000 if (!call->name || !call->class || !call->class->reg)
3001 continue;
3002
3003 - if (system && strcmp(call->class->system, system) != 0)
3004 + if (system && strcmp(call->class->system, system->name) != 0)
3005 continue;
3006
3007 /*
3008 @@ -569,7 +598,8 @@ static ssize_t
3009 system_enable_write(struct file *filp, const char __user *ubuf, size_t cnt,
3010 loff_t *ppos)
3011 {
3012 - const char *system = filp->private_data;
3013 + struct event_subsystem *system = filp->private_data;
3014 + const char *name = NULL;
3015 unsigned long val;
3016 char buf[64];
3017 ssize_t ret;
3018 @@ -593,7 +623,14 @@ system_enable_write(struct file *filp, const char __user *ubuf, size_t cnt,
3019 if (val != 0 && val != 1)
3020 return -EINVAL;
3021
3022 - ret = __ftrace_set_clr_event(NULL, system, NULL, val);
3023 + /*
3024 + * Opening of "enable" adds a ref count to system,
3025 + * so the name is safe to use.
3026 + */
3027 + if (system)
3028 + name = system->name;
3029 +
3030 + ret = __ftrace_set_clr_event(NULL, name, NULL, val);
3031 if (ret)
3032 goto out;
3033
3034 @@ -826,6 +863,52 @@ event_filter_write(struct file *filp, const char __user *ubuf, size_t cnt,
3035 return cnt;
3036 }
3037
3038 +static LIST_HEAD(event_subsystems);
3039 +
3040 +static int subsystem_open(struct inode *inode, struct file *filp)
3041 +{
3042 + struct event_subsystem *system = NULL;
3043 + int ret;
3044 +
3045 + if (!inode->i_private)
3046 + goto skip_search;
3047 +
3048 + /* Make sure the system still exists */
3049 + mutex_lock(&event_mutex);
3050 + list_for_each_entry(system, &event_subsystems, list) {
3051 + if (system == inode->i_private) {
3052 + /* Don't open systems with no events */
3053 + if (!system->nr_events) {
3054 + system = NULL;
3055 + break;
3056 + }
3057 + __get_system(system);
3058 + break;
3059 + }
3060 + }
3061 + mutex_unlock(&event_mutex);
3062 +
3063 + if (system != inode->i_private)
3064 + return -ENODEV;
3065 +
3066 + skip_search:
3067 + ret = tracing_open_generic(inode, filp);
3068 + if (ret < 0 && system)
3069 + put_system(system);
3070 +
3071 + return ret;
3072 +}
3073 +
3074 +static int subsystem_release(struct inode *inode, struct file *file)
3075 +{
3076 + struct event_subsystem *system = inode->i_private;
3077 +
3078 + if (system)
3079 + put_system(system);
3080 +
3081 + return 0;
3082 +}
3083 +
3084 static ssize_t
3085 subsystem_filter_read(struct file *filp, char __user *ubuf, size_t cnt,
3086 loff_t *ppos)
3087 @@ -963,17 +1046,19 @@ static const struct file_operations ftrace_event_filter_fops = {
3088 };
3089
3090 static const struct file_operations ftrace_subsystem_filter_fops = {
3091 - .open = tracing_open_generic,
3092 + .open = subsystem_open,
3093 .read = subsystem_filter_read,
3094 .write = subsystem_filter_write,
3095 .llseek = default_llseek,
3096 + .release = subsystem_release,
3097 };
3098
3099 static const struct file_operations ftrace_system_enable_fops = {
3100 - .open = tracing_open_generic,
3101 + .open = subsystem_open,
3102 .read = system_enable_read,
3103 .write = system_enable_write,
3104 .llseek = default_llseek,
3105 + .release = subsystem_release,
3106 };
3107
3108 static const struct file_operations ftrace_show_header_fops = {
3109 @@ -1002,8 +1087,6 @@ static struct dentry *event_trace_events_dir(void)
3110 return d_events;
3111 }
3112
3113 -static LIST_HEAD(event_subsystems);
3114 -
3115 static struct dentry *
3116 event_subsystem_dir(const char *name, struct dentry *d_events)
3117 {
3118 @@ -1013,6 +1096,7 @@ event_subsystem_dir(const char *name, struct dentry *d_events)
3119 /* First see if we did not already create this dir */
3120 list_for_each_entry(system, &event_subsystems, list) {
3121 if (strcmp(system->name, name) == 0) {
3122 + __get_system(system);
3123 system->nr_events++;
3124 return system->entry;
3125 }
3126 @@ -1035,6 +1119,7 @@ event_subsystem_dir(const char *name, struct dentry *d_events)
3127 }
3128
3129 system->nr_events = 1;
3130 + system->ref_count = 1;
3131 system->name = kstrdup(name, GFP_KERNEL);
3132 if (!system->name) {
3133 debugfs_remove(system->entry);
3134 @@ -1062,8 +1147,7 @@ event_subsystem_dir(const char *name, struct dentry *d_events)
3135 "'%s/filter' entry\n", name);
3136 }
3137
3138 - trace_create_file("enable", 0644, system->entry,
3139 - (void *)system->name,
3140 + trace_create_file("enable", 0644, system->entry, system,
3141 &ftrace_system_enable_fops);
3142
3143 return system->entry;
3144 @@ -1184,16 +1268,9 @@ static void remove_subsystem_dir(const char *name)
3145 list_for_each_entry(system, &event_subsystems, list) {
3146 if (strcmp(system->name, name) == 0) {
3147 if (!--system->nr_events) {
3148 - struct event_filter *filter = system->filter;
3149 -
3150 debugfs_remove_recursive(system->entry);
3151 list_del(&system->list);
3152 - if (filter) {
3153 - kfree(filter->filter_string);
3154 - kfree(filter);
3155 - }
3156 - kfree(system->name);
3157 - kfree(system);
3158 + __put_system(system);
3159 }
3160 break;
3161 }
3162 diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c
3163 index 8008ddc..256764e 100644
3164 --- a/kernel/trace/trace_events_filter.c
3165 +++ b/kernel/trace/trace_events_filter.c
3166 @@ -1886,6 +1886,12 @@ int apply_subsystem_event_filter(struct event_subsystem *system,
3167
3168 mutex_lock(&event_mutex);
3169
3170 + /* Make sure the system still has events */
3171 + if (!system->nr_events) {
3172 + err = -ENODEV;
3173 + goto out_unlock;
3174 + }
3175 +
3176 if (!strcmp(strstrip(filter_string), "0")) {
3177 filter_free_subsystem_preds(system);
3178 remove_filter_string(system->filter);
3179 diff --git a/lib/xz/xz_private.h b/lib/xz/xz_private.h
3180 index a65633e..482b90f 100644
3181 --- a/lib/xz/xz_private.h
3182 +++ b/lib/xz/xz_private.h
3183 @@ -12,7 +12,7 @@
3184
3185 #ifdef __KERNEL__
3186 # include <linux/xz.h>
3187 -# include <asm/byteorder.h>
3188 +# include <linux/kernel.h>
3189 # include <asm/unaligned.h>
3190 /* XZ_PREBOOT may be defined only via decompress_unxz.c. */
3191 # ifndef XZ_PREBOOT
3192 diff --git a/mm/backing-dev.c b/mm/backing-dev.c
3193 index f032e6e..e56fe35 100644
3194 --- a/mm/backing-dev.c
3195 +++ b/mm/backing-dev.c
3196 @@ -606,6 +606,7 @@ static void bdi_prune_sb(struct backing_dev_info *bdi)
3197 void bdi_unregister(struct backing_dev_info *bdi)
3198 {
3199 if (bdi->dev) {
3200 + bdi_set_min_ratio(bdi, 0);
3201 trace_writeback_bdi_unregister(bdi);
3202 bdi_prune_sb(bdi);
3203 del_timer_sync(&bdi->wb.wakeup_timer);
3204 diff --git a/mm/memcontrol.c b/mm/memcontrol.c
3205 index e013b8e..59ac5d6 100644
3206 --- a/mm/memcontrol.c
3207 +++ b/mm/memcontrol.c
3208 @@ -1730,7 +1730,7 @@ static int mem_cgroup_hierarchical_reclaim(struct mem_cgroup *root_mem,
3209 excess = res_counter_soft_limit_excess(&root_mem->res) >> PAGE_SHIFT;
3210
3211 /* If memsw_is_minimum==1, swap-out is of-no-use. */
3212 - if (!check_soft && root_mem->memsw_is_minimum)
3213 + if (!check_soft && !shrink && root_mem->memsw_is_minimum)
3214 noswap = true;
3215
3216 while (1) {
3217 diff --git a/mm/memory.c b/mm/memory.c
3218 index 9b8a01d..d961e19 100644
3219 --- a/mm/memory.c
3220 +++ b/mm/memory.c
3221 @@ -1816,7 +1816,63 @@ next_page:
3222 }
3223 EXPORT_SYMBOL(__get_user_pages);
3224
3225 -/**
3226 +/*
3227 + * fixup_user_fault() - manually resolve a user page fault
3228 + * @tsk: the task_struct to use for page fault accounting, or
3229 + * NULL if faults are not to be recorded.
3230 + * @mm: mm_struct of target mm
3231 + * @address: user address
3232 + * @fault_flags:flags to pass down to handle_mm_fault()
3233 + *
3234 + * This is meant to be called in the specific scenario where for locking reasons
3235 + * we try to access user memory in atomic context (within a pagefault_disable()
3236 + * section), this returns -EFAULT, and we want to resolve the user fault before
3237 + * trying again.
3238 + *
3239 + * Typically this is meant to be used by the futex code.
3240 + *
3241 + * The main difference with get_user_pages() is that this function will
3242 + * unconditionally call handle_mm_fault() which will in turn perform all the
3243 + * necessary SW fixup of the dirty and young bits in the PTE, while
3244 + * handle_mm_fault() only guarantees to update these in the struct page.
3245 + *
3246 + * This is important for some architectures where those bits also gate the
3247 + * access permission to the page because they are maintained in software. On
3248 + * such architectures, gup() will not be enough to make a subsequent access
3249 + * succeed.
3250 + *
3251 + * This should be called with the mm_sem held for read.
3252 + */
3253 +int fixup_user_fault(struct task_struct *tsk, struct mm_struct *mm,
3254 + unsigned long address, unsigned int fault_flags)
3255 +{
3256 + struct vm_area_struct *vma;
3257 + int ret;
3258 +
3259 + vma = find_extend_vma(mm, address);
3260 + if (!vma || address < vma->vm_start)
3261 + return -EFAULT;
3262 +
3263 + ret = handle_mm_fault(mm, vma, address, fault_flags);
3264 + if (ret & VM_FAULT_ERROR) {
3265 + if (ret & VM_FAULT_OOM)
3266 + return -ENOMEM;
3267 + if (ret & (VM_FAULT_HWPOISON | VM_FAULT_HWPOISON_LARGE))
3268 + return -EHWPOISON;
3269 + if (ret & VM_FAULT_SIGBUS)
3270 + return -EFAULT;
3271 + BUG();
3272 + }
3273 + if (tsk) {
3274 + if (ret & VM_FAULT_MAJOR)
3275 + tsk->maj_flt++;
3276 + else
3277 + tsk->min_flt++;
3278 + }
3279 + return 0;
3280 +}
3281 +
3282 +/*
3283 * get_user_pages() - pin user pages in memory
3284 * @tsk: the task_struct to use for page fault accounting, or
3285 * NULL if faults are not to be recorded.
3286 diff --git a/mm/oom_kill.c b/mm/oom_kill.c
3287 index e4b0991..8093fc7 100644
3288 --- a/mm/oom_kill.c
3289 +++ b/mm/oom_kill.c
3290 @@ -303,7 +303,7 @@ static struct task_struct *select_bad_process(unsigned int *ppoints,
3291 do_each_thread(g, p) {
3292 unsigned int points;
3293
3294 - if (!p->mm)
3295 + if (p->exit_state)
3296 continue;
3297 if (oom_unkillable_task(p, mem, nodemask))
3298 continue;
3299 @@ -319,6 +319,8 @@ static struct task_struct *select_bad_process(unsigned int *ppoints,
3300 */
3301 if (test_tsk_thread_flag(p, TIF_MEMDIE))
3302 return ERR_PTR(-1UL);
3303 + if (!p->mm)
3304 + continue;
3305
3306 if (p->flags & PF_EXITING) {
3307 /*
3308 diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h
3309 index 54578f2..78cc364 100644
3310 --- a/net/bridge/br_private.h
3311 +++ b/net/bridge/br_private.h
3312 @@ -124,6 +124,7 @@ struct net_bridge_port
3313 bridge_id designated_bridge;
3314 u32 path_cost;
3315 u32 designated_cost;
3316 + unsigned long designated_age;
3317
3318 struct timer_list forward_delay_timer;
3319 struct timer_list hold_timer;
3320 diff --git a/net/bridge/br_stp.c b/net/bridge/br_stp.c
3321 index bb4383e..fcff622 100644
3322 --- a/net/bridge/br_stp.c
3323 +++ b/net/bridge/br_stp.c
3324 @@ -164,8 +164,7 @@ void br_transmit_config(struct net_bridge_port *p)
3325 else {
3326 struct net_bridge_port *root
3327 = br_get_port(br, br->root_port);
3328 - bpdu.message_age = br->max_age
3329 - - (root->message_age_timer.expires - jiffies)
3330 + bpdu.message_age = (jiffies - root->designated_age)
3331 + MESSAGE_AGE_INCR;
3332 }
3333 bpdu.max_age = br->max_age;
3334 @@ -189,6 +188,7 @@ static inline void br_record_config_information(struct net_bridge_port *p,
3335 p->designated_cost = bpdu->root_path_cost;
3336 p->designated_bridge = bpdu->bridge_id;
3337 p->designated_port = bpdu->port_id;
3338 + p->designated_age = jiffies + bpdu->message_age;
3339
3340 mod_timer(&p->message_age_timer, jiffies
3341 + (p->br->max_age - bpdu->message_age));
3342 diff --git a/net/core/ethtool.c b/net/core/ethtool.c
3343 index fd14116..4fb7704 100644
3344 --- a/net/core/ethtool.c
3345 +++ b/net/core/ethtool.c
3346 @@ -1227,7 +1227,7 @@ static int ethtool_get_regs(struct net_device *dev, char __user *useraddr)
3347 regs.len = reglen;
3348
3349 regbuf = vzalloc(reglen);
3350 - if (!regbuf)
3351 + if (reglen && !regbuf)
3352 return -ENOMEM;
3353
3354 ops->get_regs(dev, &regs, regbuf);
3355 @@ -1236,7 +1236,7 @@ static int ethtool_get_regs(struct net_device *dev, char __user *useraddr)
3356 if (copy_to_user(useraddr, &regs, sizeof(regs)))
3357 goto out;
3358 useraddr += offsetof(struct ethtool_regs, data);
3359 - if (copy_to_user(useraddr, regbuf, regs.len))
3360 + if (regbuf && copy_to_user(useraddr, regbuf, regs.len))
3361 goto out;
3362 ret = 0;
3363
3364 diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
3365 index d595265..7a334fd 100644
3366 --- a/net/mac80211/mlme.c
3367 +++ b/net/mac80211/mlme.c
3368 @@ -2200,6 +2200,9 @@ void ieee80211_sta_restart(struct ieee80211_sub_if_data *sdata)
3369 {
3370 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
3371
3372 + if (!ifmgd->associated)
3373 + return;
3374 +
3375 if (test_and_clear_bit(TMR_RUNNING_TIMER, &ifmgd->timers_running))
3376 add_timer(&ifmgd->timer);
3377 if (test_and_clear_bit(TMR_RUNNING_CHANSW, &ifmgd->timers_running))
3378 diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c
3379 index ab86b79..bd31208 100644
3380 --- a/net/sunrpc/svc_xprt.c
3381 +++ b/net/sunrpc/svc_xprt.c
3382 @@ -902,12 +902,13 @@ void svc_delete_xprt(struct svc_xprt *xprt)
3383 if (!test_and_set_bit(XPT_DETACHED, &xprt->xpt_flags))
3384 list_del_init(&xprt->xpt_list);
3385 /*
3386 - * We used to delete the transport from whichever list
3387 - * it's sk_xprt.xpt_ready node was on, but we don't actually
3388 - * need to. This is because the only time we're called
3389 - * while still attached to a queue, the queue itself
3390 - * is about to be destroyed (in svc_destroy).
3391 + * The only time we're called while xpt_ready is still on a list
3392 + * is while the list itself is about to be destroyed (in
3393 + * svc_destroy). BUT svc_xprt_enqueue could still be attempting
3394 + * to add new entries to the sp_sockets list, so we can't leave
3395 + * a freed xprt on it.
3396 */
3397 + list_del_init(&xprt->xpt_ready);
3398 if (test_bit(XPT_TEMP, &xprt->xpt_flags))
3399 serv->sv_tmpcnt--;
3400 spin_unlock_bh(&serv->sv_lock);
3401 diff --git a/net/wireless/reg.c b/net/wireless/reg.c
3402 index 1ad0f39..4453eb7 100644
3403 --- a/net/wireless/reg.c
3404 +++ b/net/wireless/reg.c
3405 @@ -1125,12 +1125,13 @@ void wiphy_update_regulatory(struct wiphy *wiphy,
3406 enum ieee80211_band band;
3407
3408 if (ignore_reg_update(wiphy, initiator))
3409 - goto out;
3410 + return;
3411 +
3412 for (band = 0; band < IEEE80211_NUM_BANDS; band++) {
3413 if (wiphy->bands[band])
3414 handle_band(wiphy, band, initiator);
3415 }
3416 -out:
3417 +
3418 reg_process_beacons(wiphy);
3419 reg_process_ht_flags(wiphy);
3420 if (wiphy->reg_notifier)
3421 diff --git a/security/apparmor/domain.c b/security/apparmor/domain.c
3422 index c825c6e..78adc43 100644
3423 --- a/security/apparmor/domain.c
3424 +++ b/security/apparmor/domain.c
3425 @@ -73,7 +73,6 @@ static int may_change_ptraced_domain(struct task_struct *task,
3426 cred = get_task_cred(tracer);
3427 tracerp = aa_cred_profile(cred);
3428 }
3429 - rcu_read_unlock();
3430
3431 /* not ptraced */
3432 if (!tracer || unconfined(tracerp))
3433 @@ -82,6 +81,7 @@ static int may_change_ptraced_domain(struct task_struct *task,
3434 error = aa_may_ptrace(tracer, tracerp, to_profile, PTRACE_MODE_ATTACH);
3435
3436 out:
3437 + rcu_read_unlock();
3438 if (cred)
3439 put_cred(cred);
3440
3441 diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
3442 index 3d2fd14..3783202 100644
3443 --- a/security/apparmor/lsm.c
3444 +++ b/security/apparmor/lsm.c
3445 @@ -127,7 +127,7 @@ static int apparmor_capget(struct task_struct *target, kernel_cap_t *effective,
3446 *inheritable = cred->cap_inheritable;
3447 *permitted = cred->cap_permitted;
3448
3449 - if (!unconfined(profile)) {
3450 + if (!unconfined(profile) && !COMPLAIN_MODE(profile)) {
3451 *effective = cap_intersect(*effective, profile->caps.allow);
3452 *permitted = cap_intersect(*permitted, profile->caps.allow);
3453 }
3454 diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c
3455 index 5fb2e28..91cdf94 100644
3456 --- a/sound/core/pcm_compat.c
3457 +++ b/sound/core/pcm_compat.c
3458 @@ -342,7 +342,7 @@ static int snd_pcm_ioctl_xfern_compat(struct snd_pcm_substream *substream,
3459 kfree(bufs);
3460 return -EFAULT;
3461 }
3462 - bufs[ch] = compat_ptr(ptr);
3463 + bufs[i] = compat_ptr(ptr);
3464 bufptr++;
3465 }
3466 if (dir == SNDRV_PCM_STREAM_PLAYBACK)
3467 diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
3468 index b48fb43..524ff26 100644
3469 --- a/sound/pci/hda/patch_realtek.c
3470 +++ b/sound/pci/hda/patch_realtek.c
3471 @@ -1578,13 +1578,15 @@ static void alc_init_auto_hp(struct hda_codec *codec)
3472 if (present == 3)
3473 spec->automute_hp_lo = 1; /* both HP and LO automute */
3474
3475 - if (!cfg->speaker_pins[0]) {
3476 + if (!cfg->speaker_pins[0] &&
3477 + cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
3478 memcpy(cfg->speaker_pins, cfg->line_out_pins,
3479 sizeof(cfg->speaker_pins));
3480 cfg->speaker_outs = cfg->line_outs;
3481 }
3482
3483 - if (!cfg->hp_pins[0]) {
3484 + if (!cfg->hp_pins[0] &&
3485 + cfg->line_out_type == AUTO_PIN_HP_OUT) {
3486 memcpy(cfg->hp_pins, cfg->line_out_pins,
3487 sizeof(cfg->hp_pins));
3488 cfg->hp_outs = cfg->line_outs;
3489 @@ -1603,6 +1605,7 @@ static void alc_init_auto_hp(struct hda_codec *codec)
3490 spec->automute_mode = ALC_AUTOMUTE_PIN;
3491 }
3492 if (spec->automute && cfg->line_out_pins[0] &&
3493 + cfg->speaker_pins[0] &&
3494 cfg->line_out_pins[0] != cfg->hp_pins[0] &&
3495 cfg->line_out_pins[0] != cfg->speaker_pins[0]) {
3496 for (i = 0; i < cfg->line_outs; i++) {
3497 diff --git a/sound/pci/oxygen/xonar_pcm179x.c b/sound/pci/oxygen/xonar_pcm179x.c
3498 index 54cad38..32d096c 100644
3499 --- a/sound/pci/oxygen/xonar_pcm179x.c
3500 +++ b/sound/pci/oxygen/xonar_pcm179x.c
3501 @@ -327,8 +327,10 @@ static void pcm1796_init(struct oxygen *chip)
3502 {
3503 struct xonar_pcm179x *data = chip->model_data;
3504
3505 - data->pcm1796_regs[0][18 - PCM1796_REG_BASE] = PCM1796_MUTE |
3506 + data->pcm1796_regs[0][18 - PCM1796_REG_BASE] =
3507 PCM1796_DMF_DISABLED | PCM1796_FMT_24_I2S | PCM1796_ATLD;
3508 + if (!data->broken_i2c)
3509 + data->pcm1796_regs[0][18 - PCM1796_REG_BASE] |= PCM1796_MUTE;
3510 data->pcm1796_regs[0][19 - PCM1796_REG_BASE] =
3511 PCM1796_FLT_SHARP | PCM1796_ATS_1;
3512 data->pcm1796_regs[0][20 - PCM1796_REG_BASE] =
3513 @@ -1123,6 +1125,7 @@ int __devinit get_xonar_pcm179x_model(struct oxygen *chip,
3514 chip->model.control_filter = xonar_st_h6_control_filter;
3515 chip->model.dac_channels_pcm = 8;
3516 chip->model.dac_channels_mixer = 8;
3517 + chip->model.dac_volume_min = 255;
3518 chip->model.dac_mclks = OXYGEN_MCLKS(256, 128, 128);
3519 break;
3520 }
3521 diff --git a/sound/soc/davinci/davinci-vcif.c b/sound/soc/davinci/davinci-vcif.c
3522 index 9259f1f..1f11525 100644
3523 --- a/sound/soc/davinci/davinci-vcif.c
3524 +++ b/sound/soc/davinci/davinci-vcif.c
3525 @@ -62,9 +62,9 @@ static void davinci_vcif_start(struct snd_pcm_substream *substream)
3526 w = readl(davinci_vc->base + DAVINCI_VC_CTRL);
3527
3528 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
3529 - MOD_REG_BIT(w, DAVINCI_VC_CTRL_RSTDAC, 1);
3530 + MOD_REG_BIT(w, DAVINCI_VC_CTRL_RSTDAC, 0);
3531 else
3532 - MOD_REG_BIT(w, DAVINCI_VC_CTRL_RSTADC, 1);
3533 + MOD_REG_BIT(w, DAVINCI_VC_CTRL_RSTADC, 0);
3534
3535 writel(w, davinci_vc->base + DAVINCI_VC_CTRL);
3536 }
3537 @@ -80,9 +80,9 @@ static void davinci_vcif_stop(struct snd_pcm_substream *substream)
3538 /* Reset transmitter/receiver and sample rate/frame sync generators */
3539 w = readl(davinci_vc->base + DAVINCI_VC_CTRL);
3540 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
3541 - MOD_REG_BIT(w, DAVINCI_VC_CTRL_RSTDAC, 0);
3542 + MOD_REG_BIT(w, DAVINCI_VC_CTRL_RSTDAC, 1);
3543 else
3544 - MOD_REG_BIT(w, DAVINCI_VC_CTRL_RSTADC, 0);
3545 + MOD_REG_BIT(w, DAVINCI_VC_CTRL_RSTADC, 1);
3546
3547 writel(w, davinci_vc->base + DAVINCI_VC_CTRL);
3548 }
3549 @@ -159,6 +159,7 @@ static int davinci_vcif_trigger(struct snd_pcm_substream *substream, int cmd,
3550 case SNDRV_PCM_TRIGGER_RESUME:
3551 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
3552 davinci_vcif_start(substream);
3553 + break;
3554 case SNDRV_PCM_TRIGGER_STOP:
3555 case SNDRV_PCM_TRIGGER_SUSPEND:
3556 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
3557 diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
3558 index b194be0..59abd84 100644
3559 --- a/sound/soc/soc-core.c
3560 +++ b/sound/soc/soc-core.c
3561 @@ -1124,6 +1124,7 @@ int snd_soc_suspend(struct device *dev)
3562 case SND_SOC_BIAS_OFF:
3563 codec->driver->suspend(codec, PMSG_SUSPEND);
3564 codec->suspended = 1;
3565 + codec->cache_sync = 1;
3566 break;
3567 default:
3568 dev_dbg(codec->dev, "CODEC is on over suspend\n");
3569 diff --git a/tools/perf/Makefile b/tools/perf/Makefile
3570 index 940257b..c168366 100644
3571 --- a/tools/perf/Makefile
3572 +++ b/tools/perf/Makefile
3573 @@ -52,7 +52,10 @@ ifeq ($(ARCH),i386)
3574 endif
3575 ifeq ($(ARCH),x86_64)
3576 ARCH := x86
3577 - IS_X86_64 := $(shell echo __x86_64__ | ${CC} -E -xc - | tail -n 1)
3578 + IS_X86_64 := 0
3579 + ifeq (, $(findstring m32,$(EXTRA_CFLAGS)))
3580 + IS_X86_64 := $(shell echo __x86_64__ | ${CC} -E -xc - | tail -n 1)
3581 + endif
3582 ifeq (${IS_X86_64}, 1)
3583 RAW_ARCH := x86_64
3584 ARCH_CFLAGS := -DARCH_X86_64
3585 diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
3586 index afb0849..cb2959a 100644
3587 --- a/tools/perf/util/header.c
3588 +++ b/tools/perf/util/header.c
3589 @@ -877,9 +877,12 @@ int perf_session__read_header(struct perf_session *session, int fd)
3590 struct perf_evsel *evsel;
3591 off_t tmp;
3592
3593 - if (perf_header__getbuffer64(header, fd, &f_attr, sizeof(f_attr)))
3594 + if (readn(fd, &f_attr, sizeof(f_attr)) <= 0)
3595 goto out_errno;
3596
3597 + if (header->needs_swap)
3598 + perf_event__attr_swap(&f_attr.attr);
3599 +
3600 tmp = lseek(fd, 0, SEEK_CUR);
3601 evsel = perf_evsel__new(&f_attr.attr, i);
3602
3603 diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
3604 index f5a8fbd..2dbf0ab 100644
3605 --- a/tools/perf/util/session.c
3606 +++ b/tools/perf/util/session.c
3607 @@ -407,20 +407,26 @@ static void perf_event__read_swap(union perf_event *event)
3608 event->read.id = bswap_64(event->read.id);
3609 }
3610
3611 -static void perf_event__attr_swap(union perf_event *event)
3612 +/* exported for swapping attributes in file header */
3613 +void perf_event__attr_swap(struct perf_event_attr *attr)
3614 +{
3615 + attr->type = bswap_32(attr->type);
3616 + attr->size = bswap_32(attr->size);
3617 + attr->config = bswap_64(attr->config);
3618 + attr->sample_period = bswap_64(attr->sample_period);
3619 + attr->sample_type = bswap_64(attr->sample_type);
3620 + attr->read_format = bswap_64(attr->read_format);
3621 + attr->wakeup_events = bswap_32(attr->wakeup_events);
3622 + attr->bp_type = bswap_32(attr->bp_type);
3623 + attr->bp_addr = bswap_64(attr->bp_addr);
3624 + attr->bp_len = bswap_64(attr->bp_len);
3625 +}
3626 +
3627 +static void perf_event__hdr_attr_swap(union perf_event *event)
3628 {
3629 size_t size;
3630
3631 - event->attr.attr.type = bswap_32(event->attr.attr.type);
3632 - event->attr.attr.size = bswap_32(event->attr.attr.size);
3633 - event->attr.attr.config = bswap_64(event->attr.attr.config);
3634 - event->attr.attr.sample_period = bswap_64(event->attr.attr.sample_period);
3635 - event->attr.attr.sample_type = bswap_64(event->attr.attr.sample_type);
3636 - event->attr.attr.read_format = bswap_64(event->attr.attr.read_format);
3637 - event->attr.attr.wakeup_events = bswap_32(event->attr.attr.wakeup_events);
3638 - event->attr.attr.bp_type = bswap_32(event->attr.attr.bp_type);
3639 - event->attr.attr.bp_addr = bswap_64(event->attr.attr.bp_addr);
3640 - event->attr.attr.bp_len = bswap_64(event->attr.attr.bp_len);
3641 + perf_event__attr_swap(&event->attr.attr);
3642
3643 size = event->header.size;
3644 size -= (void *)&event->attr.id - (void *)event;
3645 @@ -448,7 +454,7 @@ static perf_event__swap_op perf_event__swap_ops[] = {
3646 [PERF_RECORD_LOST] = perf_event__all64_swap,
3647 [PERF_RECORD_READ] = perf_event__read_swap,
3648 [PERF_RECORD_SAMPLE] = perf_event__all64_swap,
3649 - [PERF_RECORD_HEADER_ATTR] = perf_event__attr_swap,
3650 + [PERF_RECORD_HEADER_ATTR] = perf_event__hdr_attr_swap,
3651 [PERF_RECORD_HEADER_EVENT_TYPE] = perf_event__event_type_swap,
3652 [PERF_RECORD_HEADER_TRACING_DATA] = perf_event__tracing_data_swap,
3653 [PERF_RECORD_HEADER_BUILD_ID] = NULL,
3654 diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h
3655 index 66d4e14..b84c003 100644
3656 --- a/tools/perf/util/session.h
3657 +++ b/tools/perf/util/session.h
3658 @@ -112,6 +112,7 @@ int perf_session__set_kallsyms_ref_reloc_sym(struct map **maps,
3659 u64 addr);
3660
3661 void mem_bswap_64(void *src, int byte_size);
3662 +void perf_event__attr_swap(struct perf_event_attr *attr);
3663
3664 int perf_session__create_kernel_maps(struct perf_session *self);
3665

  ViewVC Help
Powered by ViewVC 1.1.20