Magellan Linux

Annotation of /trunk/kernel-mcore/patches-3.0-r1/0100-3.0.1-all-fixes.patch

Parent Directory Parent Directory | Revision Log Revision Log


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