Gentoo Archives: gentoo-commits

From: "Mike Pagano (mpagano)" <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] linux-patches r2084 - genpatches-2.6/trunk/3.0
Date: Tue, 07 Feb 2012 14:13:21
Message-Id: 20120207141303.EBD142004B@flycatcher.gentoo.org
1 Author: mpagano
2 Date: 2012-02-07 14:13:03 +0000 (Tue, 07 Feb 2012)
3 New Revision: 2084
4
5 Added:
6 genpatches-2.6/trunk/3.0/1017_linux-3.0.18.patch
7 genpatches-2.6/trunk/3.0/1018_linux-3.0.19.patch
8 genpatches-2.6/trunk/3.0/1019_linux-3.0.20.patch
9 Log:
10 Add Linux patches 3.0.18, 3.0.19 and 3.0.20
11
12 Added: genpatches-2.6/trunk/3.0/1017_linux-3.0.18.patch
13 ===================================================================
14 --- genpatches-2.6/trunk/3.0/1017_linux-3.0.18.patch (rev 0)
15 +++ genpatches-2.6/trunk/3.0/1017_linux-3.0.18.patch 2012-02-07 14:13:03 UTC (rev 2084)
16 @@ -0,0 +1,3389 @@
17 +diff --git a/Makefile b/Makefile
18 +index 295fbda..581b8e9 100644
19 +--- a/Makefile
20 ++++ b/Makefile
21 +@@ -1,6 +1,6 @@
22 + VERSION = 3
23 + PATCHLEVEL = 0
24 +-SUBLEVEL = 17
25 ++SUBLEVEL = 18
26 + EXTRAVERSION =
27 + NAME = Sneaky Weasel
28 +
29 +diff --git a/arch/ia64/kernel/acpi.c b/arch/ia64/kernel/acpi.c
30 +index 3be485a..f19de9f 100644
31 +--- a/arch/ia64/kernel/acpi.c
32 ++++ b/arch/ia64/kernel/acpi.c
33 +@@ -429,22 +429,24 @@ static u32 __devinitdata pxm_flag[PXM_FLAG_LEN];
34 + static struct acpi_table_slit __initdata *slit_table;
35 + cpumask_t early_cpu_possible_map = CPU_MASK_NONE;
36 +
37 +-static int get_processor_proximity_domain(struct acpi_srat_cpu_affinity *pa)
38 ++static int __init
39 ++get_processor_proximity_domain(struct acpi_srat_cpu_affinity *pa)
40 + {
41 + int pxm;
42 +
43 + pxm = pa->proximity_domain_lo;
44 +- if (ia64_platform_is("sn2"))
45 ++ if (ia64_platform_is("sn2") || acpi_srat_revision >= 2)
46 + pxm += pa->proximity_domain_hi[0] << 8;
47 + return pxm;
48 + }
49 +
50 +-static int get_memory_proximity_domain(struct acpi_srat_mem_affinity *ma)
51 ++static int __init
52 ++get_memory_proximity_domain(struct acpi_srat_mem_affinity *ma)
53 + {
54 + int pxm;
55 +
56 + pxm = ma->proximity_domain;
57 +- if (!ia64_platform_is("sn2"))
58 ++ if (!ia64_platform_is("sn2") && acpi_srat_revision <= 1)
59 + pxm &= 0xff;
60 +
61 + return pxm;
62 +diff --git a/arch/score/kernel/entry.S b/arch/score/kernel/entry.S
63 +index 577abba..83bb960 100644
64 +--- a/arch/score/kernel/entry.S
65 ++++ b/arch/score/kernel/entry.S
66 +@@ -408,7 +408,7 @@ ENTRY(handle_sys)
67 + sw r9, [r0, PT_EPC]
68 +
69 + cmpi.c r27, __NR_syscalls # check syscall number
70 +- bgtu illegal_syscall
71 ++ bgeu illegal_syscall
72 +
73 + slli r8, r27, 2 # get syscall routine
74 + la r11, sys_call_table
75 +diff --git a/arch/x86/include/asm/amd_nb.h b/arch/x86/include/asm/amd_nb.h
76 +index 67f87f2..78a1eff 100644
77 +--- a/arch/x86/include/asm/amd_nb.h
78 ++++ b/arch/x86/include/asm/amd_nb.h
79 +@@ -1,6 +1,7 @@
80 + #ifndef _ASM_X86_AMD_NB_H
81 + #define _ASM_X86_AMD_NB_H
82 +
83 ++#include <linux/ioport.h>
84 + #include <linux/pci.h>
85 +
86 + struct amd_nb_bus_dev_range {
87 +@@ -13,6 +14,7 @@ extern const struct pci_device_id amd_nb_misc_ids[];
88 + extern const struct amd_nb_bus_dev_range amd_nb_bus_dev_ranges[];
89 +
90 + extern bool early_is_amd_nb(u32 value);
91 ++extern struct resource *amd_get_mmconfig_range(struct resource *res);
92 + extern int amd_cache_northbridges(void);
93 + extern void amd_flush_garts(void);
94 + extern int amd_numa_init(void);
95 +diff --git a/arch/x86/kernel/amd_nb.c b/arch/x86/kernel/amd_nb.c
96 +index 4c39baa..bae1efe 100644
97 +--- a/arch/x86/kernel/amd_nb.c
98 ++++ b/arch/x86/kernel/amd_nb.c
99 +@@ -119,6 +119,37 @@ bool __init early_is_amd_nb(u32 device)
100 + return false;
101 + }
102 +
103 ++struct resource *amd_get_mmconfig_range(struct resource *res)
104 ++{
105 ++ u32 address;
106 ++ u64 base, msr;
107 ++ unsigned segn_busn_bits;
108 ++
109 ++ if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD)
110 ++ return NULL;
111 ++
112 ++ /* assume all cpus from fam10h have mmconfig */
113 ++ if (boot_cpu_data.x86 < 0x10)
114 ++ return NULL;
115 ++
116 ++ address = MSR_FAM10H_MMIO_CONF_BASE;
117 ++ rdmsrl(address, msr);
118 ++
119 ++ /* mmconfig is not enabled */
120 ++ if (!(msr & FAM10H_MMIO_CONF_ENABLE))
121 ++ return NULL;
122 ++
123 ++ base = msr & (FAM10H_MMIO_CONF_BASE_MASK<<FAM10H_MMIO_CONF_BASE_SHIFT);
124 ++
125 ++ segn_busn_bits = (msr >> FAM10H_MMIO_CONF_BUSRANGE_SHIFT) &
126 ++ FAM10H_MMIO_CONF_BUSRANGE_MASK;
127 ++
128 ++ res->flags = IORESOURCE_MEM;
129 ++ res->start = base;
130 ++ res->end = base + (1ULL<<(segn_busn_bits + 20)) - 1;
131 ++ return res;
132 ++}
133 ++
134 + int amd_get_subcaches(int cpu)
135 + {
136 + struct pci_dev *link = node_to_amd_nb(amd_get_nb_id(cpu))->link;
137 +diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
138 +index cfeb978..874c208 100644
139 +--- a/arch/x86/kernel/apic/x2apic_uv_x.c
140 ++++ b/arch/x86/kernel/apic/x2apic_uv_x.c
141 +@@ -779,7 +779,12 @@ void __init uv_system_init(void)
142 + for(i = 0; i < UVH_NODE_PRESENT_TABLE_DEPTH; i++)
143 + uv_possible_blades +=
144 + hweight64(uv_read_local_mmr( UVH_NODE_PRESENT_TABLE + i * 8));
145 +- printk(KERN_DEBUG "UV: Found %d blades\n", uv_num_possible_blades());
146 ++
147 ++ /* uv_num_possible_blades() is really the hub count */
148 ++ printk(KERN_INFO "UV: Found %d blades, %d hubs\n",
149 ++ is_uv1_hub() ? uv_num_possible_blades() :
150 ++ (uv_num_possible_blades() + 1) / 2,
151 ++ uv_num_possible_blades());
152 +
153 + bytes = sizeof(struct uv_blade_info) * uv_num_possible_blades();
154 + uv_blade_info = kzalloc(bytes, GFP_KERNEL);
155 +diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
156 +index 1dab519..f927429 100644
157 +--- a/arch/x86/mm/mmap.c
158 ++++ b/arch/x86/mm/mmap.c
159 +@@ -87,9 +87,9 @@ static unsigned long mmap_rnd(void)
160 + */
161 + if (current->flags & PF_RANDOMIZE) {
162 + if (mmap_is_ia32())
163 +- rnd = (long)get_random_int() % (1<<8);
164 ++ rnd = get_random_int() % (1<<8);
165 + else
166 +- rnd = (long)(get_random_int() % (1<<28));
167 ++ rnd = get_random_int() % (1<<28);
168 + }
169 + return rnd << PAGE_SHIFT;
170 + }
171 +diff --git a/arch/x86/mm/srat.c b/arch/x86/mm/srat.c
172 +index 81dbfde..7efd0c6 100644
173 +--- a/arch/x86/mm/srat.c
174 ++++ b/arch/x86/mm/srat.c
175 +@@ -104,6 +104,8 @@ acpi_numa_processor_affinity_init(struct acpi_srat_cpu_affinity *pa)
176 + if ((pa->flags & ACPI_SRAT_CPU_ENABLED) == 0)
177 + return;
178 + pxm = pa->proximity_domain_lo;
179 ++ if (acpi_srat_revision >= 2)
180 ++ pxm |= *((unsigned int*)pa->proximity_domain_hi) << 8;
181 + node = setup_node(pxm);
182 + if (node < 0) {
183 + printk(KERN_ERR "SRAT: Too many proximity domains %x\n", pxm);
184 +@@ -155,6 +157,8 @@ acpi_numa_memory_affinity_init(struct acpi_srat_mem_affinity *ma)
185 + start = ma->base_address;
186 + end = start + ma->length;
187 + pxm = ma->proximity_domain;
188 ++ if (acpi_srat_revision <= 1)
189 ++ pxm &= 0xff;
190 + node = setup_node(pxm);
191 + if (node < 0) {
192 + printk(KERN_ERR "SRAT: Too many proximity domains.\n");
193 +diff --git a/arch/x86/pci/Makefile b/arch/x86/pci/Makefile
194 +index 6b8759f..d24d3da 100644
195 +--- a/arch/x86/pci/Makefile
196 ++++ b/arch/x86/pci/Makefile
197 +@@ -18,8 +18,9 @@ obj-$(CONFIG_X86_NUMAQ) += numaq_32.o
198 + obj-$(CONFIG_X86_MRST) += mrst.o
199 +
200 + obj-y += common.o early.o
201 +-obj-y += amd_bus.o bus_numa.o
202 ++obj-y += bus_numa.o
203 +
204 ++obj-$(CONFIG_AMD_NB) += amd_bus.o
205 + obj-$(CONFIG_PCI_CNB20LE_QUIRK) += broadcom_bus.o
206 +
207 + ifeq ($(CONFIG_PCI_DEBUG),y)
208 +diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
209 +index 50b3f14..53f9e68 100644
210 +--- a/arch/x86/pci/acpi.c
211 ++++ b/arch/x86/pci/acpi.c
212 +@@ -149,7 +149,7 @@ setup_resource(struct acpi_resource *acpi_res, void *data)
213 + struct acpi_resource_address64 addr;
214 + acpi_status status;
215 + unsigned long flags;
216 +- u64 start, end;
217 ++ u64 start, orig_end, end;
218 +
219 + status = resource_to_addr(acpi_res, &addr);
220 + if (!ACPI_SUCCESS(status))
221 +@@ -165,7 +165,21 @@ setup_resource(struct acpi_resource *acpi_res, void *data)
222 + return AE_OK;
223 +
224 + start = addr.minimum + addr.translation_offset;
225 +- end = addr.maximum + addr.translation_offset;
226 ++ orig_end = end = addr.maximum + addr.translation_offset;
227 ++
228 ++ /* Exclude non-addressable range or non-addressable portion of range */
229 ++ end = min(end, (u64)iomem_resource.end);
230 ++ if (end <= start) {
231 ++ dev_info(&info->bridge->dev,
232 ++ "host bridge window [%#llx-%#llx] "
233 ++ "(ignored, not CPU addressable)\n", start, orig_end);
234 ++ return AE_OK;
235 ++ } else if (orig_end != end) {
236 ++ dev_info(&info->bridge->dev,
237 ++ "host bridge window [%#llx-%#llx] "
238 ++ "([%#llx-%#llx] ignored, not CPU addressable)\n",
239 ++ start, orig_end, end + 1, orig_end);
240 ++ }
241 +
242 + res = &info->res[info->res_num];
243 + res->name = info->name;
244 +diff --git a/arch/x86/pci/amd_bus.c b/arch/x86/pci/amd_bus.c
245 +index 026e493..385a940 100644
246 +--- a/arch/x86/pci/amd_bus.c
247 ++++ b/arch/x86/pci/amd_bus.c
248 +@@ -30,34 +30,6 @@ static struct pci_hostbridge_probe pci_probes[] __initdata = {
249 + { 0, 0x18, PCI_VENDOR_ID_AMD, 0x1300 },
250 + };
251 +
252 +-static u64 __initdata fam10h_mmconf_start;
253 +-static u64 __initdata fam10h_mmconf_end;
254 +-static void __init get_pci_mmcfg_amd_fam10h_range(void)
255 +-{
256 +- u32 address;
257 +- u64 base, msr;
258 +- unsigned segn_busn_bits;
259 +-
260 +- /* assume all cpus from fam10h have mmconf */
261 +- if (boot_cpu_data.x86 < 0x10)
262 +- return;
263 +-
264 +- address = MSR_FAM10H_MMIO_CONF_BASE;
265 +- rdmsrl(address, msr);
266 +-
267 +- /* mmconfig is not enable */
268 +- if (!(msr & FAM10H_MMIO_CONF_ENABLE))
269 +- return;
270 +-
271 +- base = msr & (FAM10H_MMIO_CONF_BASE_MASK<<FAM10H_MMIO_CONF_BASE_SHIFT);
272 +-
273 +- segn_busn_bits = (msr >> FAM10H_MMIO_CONF_BUSRANGE_SHIFT) &
274 +- FAM10H_MMIO_CONF_BUSRANGE_MASK;
275 +-
276 +- fam10h_mmconf_start = base;
277 +- fam10h_mmconf_end = base + (1ULL<<(segn_busn_bits + 20)) - 1;
278 +-}
279 +-
280 + #define RANGE_NUM 16
281 +
282 + /**
283 +@@ -85,6 +57,9 @@ static int __init early_fill_mp_bus_info(void)
284 + u64 val;
285 + u32 address;
286 + bool found;
287 ++ struct resource fam10h_mmconf_res, *fam10h_mmconf;
288 ++ u64 fam10h_mmconf_start;
289 ++ u64 fam10h_mmconf_end;
290 +
291 + if (!early_pci_allowed())
292 + return -1;
293 +@@ -211,12 +186,17 @@ static int __init early_fill_mp_bus_info(void)
294 + subtract_range(range, RANGE_NUM, 0, end);
295 +
296 + /* get mmconfig */
297 +- get_pci_mmcfg_amd_fam10h_range();
298 ++ fam10h_mmconf = amd_get_mmconfig_range(&fam10h_mmconf_res);
299 + /* need to take out mmconf range */
300 +- if (fam10h_mmconf_end) {
301 +- printk(KERN_DEBUG "Fam 10h mmconf [%llx, %llx]\n", fam10h_mmconf_start, fam10h_mmconf_end);
302 ++ if (fam10h_mmconf) {
303 ++ printk(KERN_DEBUG "Fam 10h mmconf %pR\n", fam10h_mmconf);
304 ++ fam10h_mmconf_start = fam10h_mmconf->start;
305 ++ fam10h_mmconf_end = fam10h_mmconf->end;
306 + subtract_range(range, RANGE_NUM, fam10h_mmconf_start,
307 + fam10h_mmconf_end + 1);
308 ++ } else {
309 ++ fam10h_mmconf_start = 0;
310 ++ fam10h_mmconf_end = 0;
311 + }
312 +
313 + /* mmio resource */
314 +diff --git a/arch/x86/platform/uv/tlb_uv.c b/arch/x86/platform/uv/tlb_uv.c
315 +index 82cff4a..edf435b 100644
316 +--- a/arch/x86/platform/uv/tlb_uv.c
317 ++++ b/arch/x86/platform/uv/tlb_uv.c
318 +@@ -1575,14 +1575,14 @@ static int calculate_destination_timeout(void)
319 + ts_ns = base * mult1 * mult2;
320 + ret = ts_ns / 1000;
321 + } else {
322 +- /* 4 bits 0/1 for 10/80us, 3 bits of multiplier */
323 +- mmr_image = uv_read_local_mmr(UVH_AGING_PRESCALE_SEL);
324 ++ /* 4 bits 0/1 for 10/80us base, 3 bits of multiplier */
325 ++ mmr_image = uv_read_local_mmr(UVH_LB_BAU_MISC_CONTROL);
326 + mmr_image = (mmr_image & UV_SA_MASK) >> UV_SA_SHFT;
327 + if (mmr_image & (1L << UV2_ACK_UNITS_SHFT))
328 +- mult1 = 80;
329 ++ base = 80;
330 + else
331 +- mult1 = 10;
332 +- base = mmr_image & UV2_ACK_MASK;
333 ++ base = 10;
334 ++ mult1 = mmr_image & UV2_ACK_MASK;
335 + ret = mult1 * base;
336 + }
337 + return ret;
338 +@@ -1820,6 +1820,8 @@ static int __init uv_bau_init(void)
339 + uv_base_pnode = uv_blade_to_pnode(uvhub);
340 + }
341 +
342 ++ enable_timeouts();
343 ++
344 + if (init_per_cpu(nuvhubs, uv_base_pnode)) {
345 + nobau = 1;
346 + return 0;
347 +@@ -1830,7 +1832,6 @@ static int __init uv_bau_init(void)
348 + if (uv_blade_nr_possible_cpus(uvhub))
349 + init_uvhub(uvhub, vector, uv_base_pnode);
350 +
351 +- enable_timeouts();
352 + alloc_intr_gate(vector, uv_bau_message_intr1);
353 +
354 + for_each_possible_blade(uvhub) {
355 +diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
356 +index 4f4230b..5ef1f4c 100644
357 +--- a/block/scsi_ioctl.c
358 ++++ b/block/scsi_ioctl.c
359 +@@ -24,6 +24,7 @@
360 + #include <linux/capability.h>
361 + #include <linux/completion.h>
362 + #include <linux/cdrom.h>
363 ++#include <linux/ratelimit.h>
364 + #include <linux/slab.h>
365 + #include <linux/times.h>
366 + #include <asm/uaccess.h>
367 +@@ -691,6 +692,57 @@ int scsi_cmd_ioctl(struct request_queue *q, struct gendisk *bd_disk, fmode_t mod
368 + }
369 + EXPORT_SYMBOL(scsi_cmd_ioctl);
370 +
371 ++int scsi_verify_blk_ioctl(struct block_device *bd, unsigned int cmd)
372 ++{
373 ++ if (bd && bd == bd->bd_contains)
374 ++ return 0;
375 ++
376 ++ /* Actually none of these is particularly useful on a partition,
377 ++ * but they are safe.
378 ++ */
379 ++ switch (cmd) {
380 ++ case SCSI_IOCTL_GET_IDLUN:
381 ++ case SCSI_IOCTL_GET_BUS_NUMBER:
382 ++ case SCSI_IOCTL_GET_PCI:
383 ++ case SCSI_IOCTL_PROBE_HOST:
384 ++ case SG_GET_VERSION_NUM:
385 ++ case SG_SET_TIMEOUT:
386 ++ case SG_GET_TIMEOUT:
387 ++ case SG_GET_RESERVED_SIZE:
388 ++ case SG_SET_RESERVED_SIZE:
389 ++ case SG_EMULATED_HOST:
390 ++ return 0;
391 ++ case CDROM_GET_CAPABILITY:
392 ++ /* Keep this until we remove the printk below. udev sends it
393 ++ * and we do not want to spam dmesg about it. CD-ROMs do
394 ++ * not have partitions, so we get here only for disks.
395 ++ */
396 ++ return -ENOTTY;
397 ++ default:
398 ++ break;
399 ++ }
400 ++
401 ++ /* In particular, rule out all resets and host-specific ioctls. */
402 ++ printk_ratelimited(KERN_WARNING
403 ++ "%s: sending ioctl %x to a partition!\n", current->comm, cmd);
404 ++
405 ++ return capable(CAP_SYS_RAWIO) ? 0 : -ENOTTY;
406 ++}
407 ++EXPORT_SYMBOL(scsi_verify_blk_ioctl);
408 ++
409 ++int scsi_cmd_blk_ioctl(struct block_device *bd, fmode_t mode,
410 ++ unsigned int cmd, void __user *arg)
411 ++{
412 ++ int ret;
413 ++
414 ++ ret = scsi_verify_blk_ioctl(bd, cmd);
415 ++ if (ret < 0)
416 ++ return ret;
417 ++
418 ++ return scsi_cmd_ioctl(bd->bd_disk->queue, bd->bd_disk, mode, cmd, arg);
419 ++}
420 ++EXPORT_SYMBOL(scsi_cmd_blk_ioctl);
421 ++
422 + static int __init blk_scsi_ioctl_init(void)
423 + {
424 + blk_set_cmd_filter_defaults(&blk_default_cmd_filter);
425 +diff --git a/drivers/acpi/acpica/dsargs.c b/drivers/acpi/acpica/dsargs.c
426 +index 8c7b997..42163d8 100644
427 +--- a/drivers/acpi/acpica/dsargs.c
428 ++++ b/drivers/acpi/acpica/dsargs.c
429 +@@ -387,5 +387,29 @@ acpi_status acpi_ds_get_region_arguments(union acpi_operand_object *obj_desc)
430 + status = acpi_ds_execute_arguments(node, node->parent,
431 + extra_desc->extra.aml_length,
432 + extra_desc->extra.aml_start);
433 ++ if (ACPI_FAILURE(status)) {
434 ++ return_ACPI_STATUS(status);
435 ++ }
436 ++
437 ++ /* Validate the region address/length via the host OS */
438 ++
439 ++ status = acpi_os_validate_address(obj_desc->region.space_id,
440 ++ obj_desc->region.address,
441 ++ (acpi_size) obj_desc->region.length,
442 ++ acpi_ut_get_node_name(node));
443 ++
444 ++ if (ACPI_FAILURE(status)) {
445 ++ /*
446 ++ * Invalid address/length. We will emit an error message and mark
447 ++ * the region as invalid, so that it will cause an additional error if
448 ++ * it is ever used. Then return AE_OK.
449 ++ */
450 ++ ACPI_EXCEPTION((AE_INFO, status,
451 ++ "During address validation of OpRegion [%4.4s]",
452 ++ node->name.ascii));
453 ++ obj_desc->common.flags |= AOPOBJ_INVALID;
454 ++ status = AE_OK;
455 ++ }
456 ++
457 + return_ACPI_STATUS(status);
458 + }
459 +diff --git a/drivers/acpi/numa.c b/drivers/acpi/numa.c
460 +index 3b5c318..e56f3be 100644
461 +--- a/drivers/acpi/numa.c
462 ++++ b/drivers/acpi/numa.c
463 +@@ -45,6 +45,8 @@ static int pxm_to_node_map[MAX_PXM_DOMAINS]
464 + static int node_to_pxm_map[MAX_NUMNODES]
465 + = { [0 ... MAX_NUMNODES - 1] = PXM_INVAL };
466 +
467 ++unsigned char acpi_srat_revision __initdata;
468 ++
469 + int pxm_to_node(int pxm)
470 + {
471 + if (pxm < 0)
472 +@@ -255,9 +257,13 @@ acpi_parse_memory_affinity(struct acpi_subtable_header * header,
473 +
474 + static int __init acpi_parse_srat(struct acpi_table_header *table)
475 + {
476 ++ struct acpi_table_srat *srat;
477 + if (!table)
478 + return -EINVAL;
479 +
480 ++ srat = (struct acpi_table_srat *)table;
481 ++ acpi_srat_revision = srat->header.revision;
482 ++
483 + /* Real work done in acpi_table_parse_srat below. */
484 +
485 + return 0;
486 +diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
487 +index 02d2a4c..0c0669f 100644
488 +--- a/drivers/acpi/processor_core.c
489 ++++ b/drivers/acpi/processor_core.c
490 +@@ -172,8 +172,30 @@ int acpi_get_cpuid(acpi_handle handle, int type, u32 acpi_id)
491 + apic_id = map_mat_entry(handle, type, acpi_id);
492 + if (apic_id == -1)
493 + apic_id = map_madt_entry(type, acpi_id);
494 +- if (apic_id == -1)
495 +- return apic_id;
496 ++ if (apic_id == -1) {
497 ++ /*
498 ++ * On UP processor, there is no _MAT or MADT table.
499 ++ * So above apic_id is always set to -1.
500 ++ *
501 ++ * BIOS may define multiple CPU handles even for UP processor.
502 ++ * For example,
503 ++ *
504 ++ * Scope (_PR)
505 ++ * {
506 ++ * Processor (CPU0, 0x00, 0x00000410, 0x06) {}
507 ++ * Processor (CPU1, 0x01, 0x00000410, 0x06) {}
508 ++ * Processor (CPU2, 0x02, 0x00000410, 0x06) {}
509 ++ * Processor (CPU3, 0x03, 0x00000410, 0x06) {}
510 ++ * }
511 ++ *
512 ++ * Ignores apic_id and always return 0 for CPU0's handle.
513 ++ * Return -1 for other CPU's handle.
514 ++ */
515 ++ if (acpi_id == 0)
516 ++ return acpi_id;
517 ++ else
518 ++ return apic_id;
519 ++ }
520 +
521 + #ifdef CONFIG_SMP
522 + for_each_possible_cpu(i) {
523 +diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
524 +index c2f9b3e..1dab802 100644
525 +--- a/drivers/block/cciss.c
526 ++++ b/drivers/block/cciss.c
527 +@@ -1716,7 +1716,7 @@ static int cciss_ioctl(struct block_device *bdev, fmode_t mode,
528 + case CCISS_BIG_PASSTHRU:
529 + return cciss_bigpassthru(h, argp);
530 +
531 +- /* scsi_cmd_ioctl handles these, below, though some are not */
532 ++ /* scsi_cmd_blk_ioctl handles these, below, though some are not */
533 + /* very meaningful for cciss. SG_IO is the main one people want. */
534 +
535 + case SG_GET_VERSION_NUM:
536 +@@ -1727,9 +1727,9 @@ static int cciss_ioctl(struct block_device *bdev, fmode_t mode,
537 + case SG_EMULATED_HOST:
538 + case SG_IO:
539 + case SCSI_IOCTL_SEND_COMMAND:
540 +- return scsi_cmd_ioctl(disk->queue, disk, mode, cmd, argp);
541 ++ return scsi_cmd_blk_ioctl(bdev, mode, cmd, argp);
542 +
543 +- /* scsi_cmd_ioctl would normally handle these, below, but */
544 ++ /* scsi_cmd_blk_ioctl would normally handle these, below, but */
545 + /* they aren't a good fit for cciss, as CD-ROMs are */
546 + /* not supported, and we don't have any bus/target/lun */
547 + /* which we present to the kernel. */
548 +diff --git a/drivers/block/ub.c b/drivers/block/ub.c
549 +index 0e376d4..7333b9e 100644
550 +--- a/drivers/block/ub.c
551 ++++ b/drivers/block/ub.c
552 +@@ -1744,12 +1744,11 @@ static int ub_bd_release(struct gendisk *disk, fmode_t mode)
553 + static int ub_bd_ioctl(struct block_device *bdev, fmode_t mode,
554 + unsigned int cmd, unsigned long arg)
555 + {
556 +- struct gendisk *disk = bdev->bd_disk;
557 + void __user *usermem = (void __user *) arg;
558 + int ret;
559 +
560 + mutex_lock(&ub_mutex);
561 +- ret = scsi_cmd_ioctl(disk->queue, disk, mode, cmd, usermem);
562 ++ ret = scsi_cmd_blk_ioctl(bdev, mode, cmd, usermem);
563 + mutex_unlock(&ub_mutex);
564 +
565 + return ret;
566 +diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
567 +index 079c088..5d7a934 100644
568 +--- a/drivers/block/virtio_blk.c
569 ++++ b/drivers/block/virtio_blk.c
570 +@@ -236,8 +236,8 @@ static int virtblk_ioctl(struct block_device *bdev, fmode_t mode,
571 + if (!virtio_has_feature(vblk->vdev, VIRTIO_BLK_F_SCSI))
572 + return -ENOTTY;
573 +
574 +- return scsi_cmd_ioctl(disk->queue, disk, mode, cmd,
575 +- (void __user *)data);
576 ++ return scsi_cmd_blk_ioctl(bdev, mode, cmd,
577 ++ (void __user *)data);
578 + }
579 +
580 + /* We provide getgeo only to please some old bootloader/partitioning tools */
581 +diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
582 +index 75fb965..b693cbd 100644
583 +--- a/drivers/cdrom/cdrom.c
584 ++++ b/drivers/cdrom/cdrom.c
585 +@@ -2741,12 +2741,11 @@ int cdrom_ioctl(struct cdrom_device_info *cdi, struct block_device *bdev,
586 + {
587 + void __user *argp = (void __user *)arg;
588 + int ret;
589 +- struct gendisk *disk = bdev->bd_disk;
590 +
591 + /*
592 + * Try the generic SCSI command ioctl's first.
593 + */
594 +- ret = scsi_cmd_ioctl(disk->queue, disk, mode, cmd, argp);
595 ++ ret = scsi_cmd_blk_ioctl(bdev, mode, cmd, argp);
596 + if (ret != -ENOTTY)
597 + return ret;
598 +
599 +diff --git a/drivers/gpu/drm/radeon/r100.c b/drivers/gpu/drm/radeon/r100.c
600 +index b94d871..7642495 100644
601 +--- a/drivers/gpu/drm/radeon/r100.c
602 ++++ b/drivers/gpu/drm/radeon/r100.c
603 +@@ -2069,6 +2069,7 @@ bool r100_gpu_is_lockup(struct radeon_device *rdev)
604 + void r100_bm_disable(struct radeon_device *rdev)
605 + {
606 + u32 tmp;
607 ++ u16 tmp16;
608 +
609 + /* disable bus mastering */
610 + tmp = RREG32(R_000030_BUS_CNTL);
611 +@@ -2079,8 +2080,8 @@ void r100_bm_disable(struct radeon_device *rdev)
612 + WREG32(R_000030_BUS_CNTL, (tmp & 0xFFFFFFFF) | 0x00000040);
613 + tmp = RREG32(RADEON_BUS_CNTL);
614 + mdelay(1);
615 +- pci_read_config_word(rdev->pdev, 0x4, (u16*)&tmp);
616 +- pci_write_config_word(rdev->pdev, 0x4, tmp & 0xFFFB);
617 ++ pci_read_config_word(rdev->pdev, 0x4, &tmp16);
618 ++ pci_write_config_word(rdev->pdev, 0x4, tmp16 & 0xFFFB);
619 + mdelay(1);
620 + }
621 +
622 +diff --git a/drivers/gpu/drm/radeon/r600_hdmi.c b/drivers/gpu/drm/radeon/r600_hdmi.c
623 +index f5ac7e7..c45d921 100644
624 +--- a/drivers/gpu/drm/radeon/r600_hdmi.c
625 ++++ b/drivers/gpu/drm/radeon/r600_hdmi.c
626 +@@ -196,6 +196,13 @@ static void r600_hdmi_videoinfoframe(
627 + frame[0xD] = (right_bar >> 8);
628 +
629 + r600_hdmi_infoframe_checksum(0x82, 0x02, 0x0D, frame);
630 ++ /* Our header values (type, version, length) should be alright, Intel
631 ++ * is using the same. Checksum function also seems to be OK, it works
632 ++ * fine for audio infoframe. However calculated value is always lower
633 ++ * by 2 in comparison to fglrx. It breaks displaying anything in case
634 ++ * of TVs that strictly check the checksum. Hack it manually here to
635 ++ * workaround this issue. */
636 ++ frame[0x0] += 2;
637 +
638 + WREG32(offset+R600_HDMI_VIDEOINFOFRAME_0,
639 + frame[0x0] | (frame[0x1] << 8) | (frame[0x2] << 16) | (frame[0x3] << 24));
640 +diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
641 +index 440e6ec..5d0c123 100644
642 +--- a/drivers/gpu/drm/radeon/radeon_device.c
643 ++++ b/drivers/gpu/drm/radeon/radeon_device.c
644 +@@ -223,8 +223,11 @@ int radeon_wb_init(struct radeon_device *rdev)
645 + if (radeon_no_wb == 1)
646 + rdev->wb.enabled = false;
647 + else {
648 +- /* often unreliable on AGP */
649 + if (rdev->flags & RADEON_IS_AGP) {
650 ++ /* often unreliable on AGP */
651 ++ rdev->wb.enabled = false;
652 ++ } else if (rdev->family < CHIP_R300) {
653 ++ /* often unreliable on pre-r300 */
654 + rdev->wb.enabled = false;
655 + } else {
656 + rdev->wb.enabled = true;
657 +diff --git a/drivers/gpu/drm/radeon/rs600.c b/drivers/gpu/drm/radeon/rs600.c
658 +index a37a1ef..21acfb5 100644
659 +--- a/drivers/gpu/drm/radeon/rs600.c
660 ++++ b/drivers/gpu/drm/radeon/rs600.c
661 +@@ -324,10 +324,10 @@ void rs600_hpd_fini(struct radeon_device *rdev)
662 +
663 + void rs600_bm_disable(struct radeon_device *rdev)
664 + {
665 +- u32 tmp;
666 ++ u16 tmp;
667 +
668 + /* disable bus mastering */
669 +- pci_read_config_word(rdev->pdev, 0x4, (u16*)&tmp);
670 ++ pci_read_config_word(rdev->pdev, 0x4, &tmp);
671 + pci_write_config_word(rdev->pdev, 0x4, tmp & 0xFFFB);
672 + mdelay(1);
673 + }
674 +diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
675 +index 763797d..2f855b1 100644
676 +--- a/drivers/hid/hid-core.c
677 ++++ b/drivers/hid/hid-core.c
678 +@@ -361,7 +361,7 @@ static int hid_parser_global(struct hid_parser *parser, struct hid_item *item)
679 +
680 + case HID_GLOBAL_ITEM_TAG_REPORT_SIZE:
681 + parser->global.report_size = item_udata(item);
682 +- if (parser->global.report_size > 32) {
683 ++ if (parser->global.report_size > 96) {
684 + dbg_hid("invalid report_size %d\n",
685 + parser->global.report_size);
686 + return -1;
687 +@@ -1382,11 +1382,13 @@ static const struct hid_device_id hid_have_special_driver[] = {
688 + { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_TRUETOUCH) },
689 + { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, 0x0006) },
690 + { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, 0x0011) },
691 +- { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH) },
692 +- { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH1) },
693 +- { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH2) },
694 +- { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH3) },
695 +- { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH4) },
696 ++ { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_480D) },
697 ++ { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_480E) },
698 ++ { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_720C) },
699 ++ { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_726B) },
700 ++ { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72A1) },
701 ++ { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7302) },
702 ++ { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_A001) },
703 + { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_BM084) },
704 + { HID_USB_DEVICE(USB_VENDOR_ID_ELO, USB_DEVICE_ID_ELO_TS2515) },
705 + { HID_USB_DEVICE(USB_VENDOR_ID_EMS, USB_DEVICE_ID_EMS_TRIO_LINKER_PLUS_II) },
706 +diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
707 +index 206f750..e0a28ad 100644
708 +--- a/drivers/hid/hid-ids.h
709 ++++ b/drivers/hid/hid-ids.h
710 +@@ -21,6 +21,7 @@
711 + #define USB_VENDOR_ID_3M 0x0596
712 + #define USB_DEVICE_ID_3M1968 0x0500
713 + #define USB_DEVICE_ID_3M2256 0x0502
714 ++#define USB_DEVICE_ID_3M3266 0x0506
715 +
716 + #define USB_VENDOR_ID_A4TECH 0x09da
717 + #define USB_DEVICE_ID_A4TECH_WCP32PU 0x0006
718 +@@ -230,11 +231,14 @@
719 +
720 + #define USB_VENDOR_ID_DWAV 0x0eef
721 + #define USB_DEVICE_ID_EGALAX_TOUCHCONTROLLER 0x0001
722 +-#define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH 0x480d
723 +-#define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH1 0x720c
724 +-#define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH2 0x72a1
725 +-#define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH3 0x480e
726 +-#define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH4 0x726b
727 ++#define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_480D 0x480d
728 ++#define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_480E 0x480e
729 ++#define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_720C 0x720c
730 ++#define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_726B 0x726b
731 ++#define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72A1 0x72a1
732 ++#define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72FA 0x72fa
733 ++#define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7302 0x7302
734 ++#define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_A001 0xa001
735 +
736 + #define USB_VENDOR_ID_ELECOM 0x056e
737 + #define USB_DEVICE_ID_ELECOM_BM084 0x0061
738 +diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
739 +index 685d8e4..1308703 100644
740 +--- a/drivers/hid/hid-multitouch.c
741 ++++ b/drivers/hid/hid-multitouch.c
742 +@@ -593,6 +593,9 @@ static const struct hid_device_id mt_devices[] = {
743 + { .driver_data = MT_CLS_3M,
744 + HID_USB_DEVICE(USB_VENDOR_ID_3M,
745 + USB_DEVICE_ID_3M2256) },
746 ++ { .driver_data = MT_CLS_3M,
747 ++ HID_USB_DEVICE(USB_VENDOR_ID_3M,
748 ++ USB_DEVICE_ID_3M3266) },
749 +
750 + /* ActionStar panels */
751 + { .driver_data = MT_CLS_DEFAULT,
752 +@@ -629,23 +632,32 @@ static const struct hid_device_id mt_devices[] = {
753 + USB_DEVICE_ID_CYPRESS_TRUETOUCH) },
754 +
755 + /* eGalax devices (resistive) */
756 +- { .driver_data = MT_CLS_EGALAX,
757 ++ { .driver_data = MT_CLS_EGALAX,
758 + HID_USB_DEVICE(USB_VENDOR_ID_DWAV,
759 +- USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH) },
760 +- { .driver_data = MT_CLS_EGALAX,
761 ++ USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_480D) },
762 ++ { .driver_data = MT_CLS_EGALAX,
763 + HID_USB_DEVICE(USB_VENDOR_ID_DWAV,
764 +- USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH3) },
765 ++ USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_480E) },
766 +
767 + /* eGalax devices (capacitive) */
768 +- { .driver_data = MT_CLS_EGALAX,
769 ++ { .driver_data = MT_CLS_EGALAX,
770 ++ HID_USB_DEVICE(USB_VENDOR_ID_DWAV,
771 ++ USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_720C) },
772 ++ { .driver_data = MT_CLS_EGALAX,
773 ++ HID_USB_DEVICE(USB_VENDOR_ID_DWAV,
774 ++ USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_726B) },
775 ++ { .driver_data = MT_CLS_EGALAX,
776 ++ HID_USB_DEVICE(USB_VENDOR_ID_DWAV,
777 ++ USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72A1) },
778 ++ { .driver_data = MT_CLS_EGALAX,
779 + HID_USB_DEVICE(USB_VENDOR_ID_DWAV,
780 +- USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH1) },
781 +- { .driver_data = MT_CLS_EGALAX,
782 ++ USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72FA) },
783 ++ { .driver_data = MT_CLS_EGALAX,
784 + HID_USB_DEVICE(USB_VENDOR_ID_DWAV,
785 +- USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH2) },
786 +- { .driver_data = MT_CLS_EGALAX,
787 ++ USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7302) },
788 ++ { .driver_data = MT_CLS_EGALAX,
789 + HID_USB_DEVICE(USB_VENDOR_ID_DWAV,
790 +- USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH4) },
791 ++ USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_A001) },
792 +
793 + /* Elo TouchSystems IntelliTouch Plus panel */
794 + { .driver_data = MT_CLS_DUAL_NSMU_CONTACTID,
795 +diff --git a/drivers/i2c/busses/i2c-ali1535.c b/drivers/i2c/busses/i2c-ali1535.c
796 +index dd36417..cd7ac5c 100644
797 +--- a/drivers/i2c/busses/i2c-ali1535.c
798 ++++ b/drivers/i2c/busses/i2c-ali1535.c
799 +@@ -140,7 +140,7 @@ static unsigned short ali1535_smba;
800 + defined to make the transition easier. */
801 + static int __devinit ali1535_setup(struct pci_dev *dev)
802 + {
803 +- int retval = -ENODEV;
804 ++ int retval;
805 + unsigned char temp;
806 +
807 + /* Check the following things:
808 +@@ -155,6 +155,7 @@ static int __devinit ali1535_setup(struct pci_dev *dev)
809 + if (ali1535_smba == 0) {
810 + dev_warn(&dev->dev,
811 + "ALI1535_smb region uninitialized - upgrade BIOS?\n");
812 ++ retval = -ENODEV;
813 + goto exit;
814 + }
815 +
816 +@@ -167,6 +168,7 @@ static int __devinit ali1535_setup(struct pci_dev *dev)
817 + ali1535_driver.name)) {
818 + dev_err(&dev->dev, "ALI1535_smb region 0x%x already in use!\n",
819 + ali1535_smba);
820 ++ retval = -EBUSY;
821 + goto exit;
822 + }
823 +
824 +@@ -174,6 +176,7 @@ static int __devinit ali1535_setup(struct pci_dev *dev)
825 + pci_read_config_byte(dev, SMBCFG, &temp);
826 + if ((temp & ALI1535_SMBIO_EN) == 0) {
827 + dev_err(&dev->dev, "SMB device not enabled - upgrade BIOS?\n");
828 ++ retval = -ENODEV;
829 + goto exit_free;
830 + }
831 +
832 +@@ -181,6 +184,7 @@ static int __devinit ali1535_setup(struct pci_dev *dev)
833 + pci_read_config_byte(dev, SMBHSTCFG, &temp);
834 + if ((temp & 1) == 0) {
835 + dev_err(&dev->dev, "SMBus controller not enabled - upgrade BIOS?\n");
836 ++ retval = -ENODEV;
837 + goto exit_free;
838 + }
839 +
840 +@@ -198,12 +202,11 @@ static int __devinit ali1535_setup(struct pci_dev *dev)
841 + dev_dbg(&dev->dev, "SMBREV = 0x%X\n", temp);
842 + dev_dbg(&dev->dev, "ALI1535_smba = 0x%X\n", ali1535_smba);
843 +
844 +- retval = 0;
845 +-exit:
846 +- return retval;
847 ++ return 0;
848 +
849 + exit_free:
850 + release_region(ali1535_smba, ALI1535_SMB_IOSIZE);
851 ++exit:
852 + return retval;
853 + }
854 +
855 +diff --git a/drivers/i2c/busses/i2c-eg20t.c b/drivers/i2c/busses/i2c-eg20t.c
856 +index 8abfa4a..656b028 100644
857 +--- a/drivers/i2c/busses/i2c-eg20t.c
858 ++++ b/drivers/i2c/busses/i2c-eg20t.c
859 +@@ -242,7 +242,7 @@ static void pch_i2c_init(struct i2c_algo_pch_data *adap)
860 + if (pch_clk > PCH_MAX_CLK)
861 + pch_clk = 62500;
862 +
863 +- pch_i2cbc = (pch_clk + (pch_i2c_speed * 4)) / pch_i2c_speed * 8;
864 ++ pch_i2cbc = (pch_clk + (pch_i2c_speed * 4)) / (pch_i2c_speed * 8);
865 + /* Set transfer speed in I2CBC */
866 + iowrite32(pch_i2cbc, p + PCH_I2CBC);
867 +
868 +diff --git a/drivers/i2c/busses/i2c-nforce2.c b/drivers/i2c/busses/i2c-nforce2.c
869 +index ff1e127..4853b52 100644
870 +--- a/drivers/i2c/busses/i2c-nforce2.c
871 ++++ b/drivers/i2c/busses/i2c-nforce2.c
872 +@@ -356,7 +356,7 @@ static int __devinit nforce2_probe_smb (struct pci_dev *dev, int bar,
873 + error = acpi_check_region(smbus->base, smbus->size,
874 + nforce2_driver.name);
875 + if (error)
876 +- return -1;
877 ++ return error;
878 +
879 + if (!request_region(smbus->base, smbus->size, nforce2_driver.name)) {
880 + dev_err(&smbus->adapter.dev, "Error requesting region %02x .. %02X for %s\n",
881 +diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
882 +index 58a58c7..137e1a3 100644
883 +--- a/drivers/i2c/busses/i2c-omap.c
884 ++++ b/drivers/i2c/busses/i2c-omap.c
885 +@@ -235,7 +235,7 @@ const static u8 omap4_reg_map[] = {
886 + [OMAP_I2C_BUF_REG] = 0x94,
887 + [OMAP_I2C_CNT_REG] = 0x98,
888 + [OMAP_I2C_DATA_REG] = 0x9c,
889 +- [OMAP_I2C_SYSC_REG] = 0x20,
890 ++ [OMAP_I2C_SYSC_REG] = 0x10,
891 + [OMAP_I2C_CON_REG] = 0xa4,
892 + [OMAP_I2C_OA_REG] = 0xa8,
893 + [OMAP_I2C_SA_REG] = 0xac,
894 +diff --git a/drivers/i2c/busses/i2c-sis5595.c b/drivers/i2c/busses/i2c-sis5595.c
895 +index 4375866..6d60284 100644
896 +--- a/drivers/i2c/busses/i2c-sis5595.c
897 ++++ b/drivers/i2c/busses/i2c-sis5595.c
898 +@@ -147,7 +147,7 @@ static int __devinit sis5595_setup(struct pci_dev *SIS5595_dev)
899 + u16 a;
900 + u8 val;
901 + int *i;
902 +- int retval = -ENODEV;
903 ++ int retval;
904 +
905 + /* Look for imposters */
906 + for (i = blacklist; *i != 0; i++) {
907 +@@ -223,7 +223,7 @@ static int __devinit sis5595_setup(struct pci_dev *SIS5595_dev)
908 +
909 + error:
910 + release_region(sis5595_base + SMB_INDEX, 2);
911 +- return retval;
912 ++ return -ENODEV;
913 + }
914 +
915 + static int sis5595_transaction(struct i2c_adapter *adap)
916 +diff --git a/drivers/i2c/busses/i2c-sis630.c b/drivers/i2c/busses/i2c-sis630.c
917 +index e6f539e..b617fd0 100644
918 +--- a/drivers/i2c/busses/i2c-sis630.c
919 ++++ b/drivers/i2c/busses/i2c-sis630.c
920 +@@ -393,7 +393,7 @@ static int __devinit sis630_setup(struct pci_dev *sis630_dev)
921 + {
922 + unsigned char b;
923 + struct pci_dev *dummy = NULL;
924 +- int retval = -ENODEV, i;
925 ++ int retval, i;
926 +
927 + /* check for supported SiS devices */
928 + for (i=0; supported[i] > 0 ; i++) {
929 +@@ -418,18 +418,21 @@ static int __devinit sis630_setup(struct pci_dev *sis630_dev)
930 + */
931 + if (pci_read_config_byte(sis630_dev, SIS630_BIOS_CTL_REG,&b)) {
932 + dev_err(&sis630_dev->dev, "Error: Can't read bios ctl reg\n");
933 ++ retval = -ENODEV;
934 + goto exit;
935 + }
936 + /* if ACPI already enabled , do nothing */
937 + if (!(b & 0x80) &&
938 + pci_write_config_byte(sis630_dev, SIS630_BIOS_CTL_REG, b | 0x80)) {
939 + dev_err(&sis630_dev->dev, "Error: Can't enable ACPI\n");
940 ++ retval = -ENODEV;
941 + goto exit;
942 + }
943 +
944 + /* Determine the ACPI base address */
945 + if (pci_read_config_word(sis630_dev,SIS630_ACPI_BASE_REG,&acpi_base)) {
946 + dev_err(&sis630_dev->dev, "Error: Can't determine ACPI base address\n");
947 ++ retval = -ENODEV;
948 + goto exit;
949 + }
950 +
951 +@@ -445,6 +448,7 @@ static int __devinit sis630_setup(struct pci_dev *sis630_dev)
952 + sis630_driver.name)) {
953 + dev_err(&sis630_dev->dev, "SMBus registers 0x%04x-0x%04x already "
954 + "in use!\n", acpi_base + SMB_STS, acpi_base + SMB_SAA);
955 ++ retval = -EBUSY;
956 + goto exit;
957 + }
958 +
959 +diff --git a/drivers/i2c/busses/i2c-viapro.c b/drivers/i2c/busses/i2c-viapro.c
960 +index 0b012f1..58261d4 100644
961 +--- a/drivers/i2c/busses/i2c-viapro.c
962 ++++ b/drivers/i2c/busses/i2c-viapro.c
963 +@@ -324,7 +324,7 @@ static int __devinit vt596_probe(struct pci_dev *pdev,
964 + const struct pci_device_id *id)
965 + {
966 + unsigned char temp;
967 +- int error = -ENODEV;
968 ++ int error;
969 +
970 + /* Determine the address of the SMBus areas */
971 + if (force_addr) {
972 +@@ -390,6 +390,7 @@ found:
973 + dev_err(&pdev->dev, "SMBUS: Error: Host SMBus "
974 + "controller not enabled! - upgrade BIOS or "
975 + "use force=1\n");
976 ++ error = -ENODEV;
977 + goto release_region;
978 + }
979 + }
980 +@@ -422,9 +423,11 @@ found:
981 + "SMBus Via Pro adapter at %04x", vt596_smba);
982 +
983 + vt596_pdev = pci_dev_get(pdev);
984 +- if (i2c_add_adapter(&vt596_adapter)) {
985 ++ error = i2c_add_adapter(&vt596_adapter);
986 ++ if (error) {
987 + pci_dev_put(vt596_pdev);
988 + vt596_pdev = NULL;
989 ++ goto release_region;
990 + }
991 +
992 + /* Always return failure here. This is to allow other drivers to bind
993 +diff --git a/drivers/ide/ide-floppy_ioctl.c b/drivers/ide/ide-floppy_ioctl.c
994 +index d267b7a..a22ca84 100644
995 +--- a/drivers/ide/ide-floppy_ioctl.c
996 ++++ b/drivers/ide/ide-floppy_ioctl.c
997 +@@ -292,8 +292,7 @@ int ide_floppy_ioctl(ide_drive_t *drive, struct block_device *bdev,
998 + * and CDROM_SEND_PACKET (legacy) ioctls
999 + */
1000 + if (cmd != CDROM_SEND_PACKET && cmd != SCSI_IOCTL_SEND_COMMAND)
1001 +- err = scsi_cmd_ioctl(bdev->bd_disk->queue, bdev->bd_disk,
1002 +- mode, cmd, argp);
1003 ++ err = scsi_cmd_blk_ioctl(bdev, mode, cmd, argp);
1004 +
1005 + if (err == -ENOTTY)
1006 + err = generic_ide_ioctl(drive, bdev, cmd, arg);
1007 +diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c
1008 +index a46dddf..026f9aa 100644
1009 +--- a/drivers/idle/intel_idle.c
1010 ++++ b/drivers/idle/intel_idle.c
1011 +@@ -321,7 +321,8 @@ static int intel_idle_probe(void)
1012 + cpuid(CPUID_MWAIT_LEAF, &eax, &ebx, &ecx, &mwait_substates);
1013 +
1014 + if (!(ecx & CPUID5_ECX_EXTENSIONS_SUPPORTED) ||
1015 +- !(ecx & CPUID5_ECX_INTERRUPT_BREAK))
1016 ++ !(ecx & CPUID5_ECX_INTERRUPT_BREAK) ||
1017 ++ !mwait_substates)
1018 + return -ENODEV;
1019 +
1020 + pr_debug(PREFIX "MWAIT substates: 0x%x\n", mwait_substates);
1021 +@@ -367,7 +368,7 @@ static int intel_idle_probe(void)
1022 + if (boot_cpu_has(X86_FEATURE_ARAT)) /* Always Reliable APIC Timer */
1023 + lapic_timer_reliable_states = LAPIC_TIMER_ALWAYS_RELIABLE;
1024 + else {
1025 +- smp_call_function(__setup_broadcast_timer, (void *)true, 1);
1026 ++ on_each_cpu(__setup_broadcast_timer, (void *)true, 1);
1027 + register_cpu_notifier(&setup_broadcast_notifier);
1028 + }
1029 +
1030 +@@ -459,7 +460,7 @@ static int intel_idle_cpuidle_devices_init(void)
1031 + }
1032 + }
1033 + if (auto_demotion_disable_flags)
1034 +- smp_call_function(auto_demotion_disable, NULL, 1);
1035 ++ on_each_cpu(auto_demotion_disable, NULL, 1);
1036 +
1037 + return 0;
1038 + }
1039 +@@ -499,7 +500,7 @@ static void __exit intel_idle_exit(void)
1040 + cpuidle_unregister_driver(&intel_idle_driver);
1041 +
1042 + if (lapic_timer_reliable_states != LAPIC_TIMER_ALWAYS_RELIABLE) {
1043 +- smp_call_function(__setup_broadcast_timer, (void *)false, 1);
1044 ++ on_each_cpu(__setup_broadcast_timer, (void *)false, 1);
1045 + unregister_cpu_notifier(&setup_broadcast_notifier);
1046 + }
1047 +
1048 +diff --git a/drivers/md/dm-flakey.c b/drivers/md/dm-flakey.c
1049 +index ea79062..3e90b80 100644
1050 +--- a/drivers/md/dm-flakey.c
1051 ++++ b/drivers/md/dm-flakey.c
1052 +@@ -149,8 +149,17 @@ static int flakey_status(struct dm_target *ti, status_type_t type,
1053 + static int flakey_ioctl(struct dm_target *ti, unsigned int cmd, unsigned long arg)
1054 + {
1055 + struct flakey_c *fc = ti->private;
1056 ++ struct dm_dev *dev = fc->dev;
1057 ++ int r = 0;
1058 +
1059 +- return __blkdev_driver_ioctl(fc->dev->bdev, fc->dev->mode, cmd, arg);
1060 ++ /*
1061 ++ * Only pass ioctls through if the device sizes match exactly.
1062 ++ */
1063 ++ if (fc->start ||
1064 ++ ti->len != i_size_read(dev->bdev->bd_inode) >> SECTOR_SHIFT)
1065 ++ r = scsi_verify_blk_ioctl(NULL, cmd);
1066 ++
1067 ++ return r ? : __blkdev_driver_ioctl(dev->bdev, dev->mode, cmd, arg);
1068 + }
1069 +
1070 + static int flakey_merge(struct dm_target *ti, struct bvec_merge_data *bvm,
1071 +diff --git a/drivers/md/dm-linear.c b/drivers/md/dm-linear.c
1072 +index 3921e3b..9728839 100644
1073 +--- a/drivers/md/dm-linear.c
1074 ++++ b/drivers/md/dm-linear.c
1075 +@@ -116,7 +116,17 @@ static int linear_ioctl(struct dm_target *ti, unsigned int cmd,
1076 + unsigned long arg)
1077 + {
1078 + struct linear_c *lc = (struct linear_c *) ti->private;
1079 +- return __blkdev_driver_ioctl(lc->dev->bdev, lc->dev->mode, cmd, arg);
1080 ++ struct dm_dev *dev = lc->dev;
1081 ++ int r = 0;
1082 ++
1083 ++ /*
1084 ++ * Only pass ioctls through if the device sizes match exactly.
1085 ++ */
1086 ++ if (lc->start ||
1087 ++ ti->len != i_size_read(dev->bdev->bd_inode) >> SECTOR_SHIFT)
1088 ++ r = scsi_verify_blk_ioctl(NULL, cmd);
1089 ++
1090 ++ return r ? : __blkdev_driver_ioctl(dev->bdev, dev->mode, cmd, arg);
1091 + }
1092 +
1093 + static int linear_merge(struct dm_target *ti, struct bvec_merge_data *bvm,
1094 +diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c
1095 +index 209991b..70373bf 100644
1096 +--- a/drivers/md/dm-mpath.c
1097 ++++ b/drivers/md/dm-mpath.c
1098 +@@ -1584,6 +1584,12 @@ static int multipath_ioctl(struct dm_target *ti, unsigned int cmd,
1099 +
1100 + spin_unlock_irqrestore(&m->lock, flags);
1101 +
1102 ++ /*
1103 ++ * Only pass ioctls through if the device sizes match exactly.
1104 ++ */
1105 ++ if (!r && ti->len != i_size_read(bdev->bd_inode) >> SECTOR_SHIFT)
1106 ++ r = scsi_verify_blk_ioctl(NULL, cmd);
1107 ++
1108 + return r ? : __blkdev_driver_ioctl(bdev, mode, cmd, arg);
1109 + }
1110 +
1111 +diff --git a/drivers/media/video/uvc/uvc_v4l2.c b/drivers/media/video/uvc/uvc_v4l2.c
1112 +index 543a803..dbefdb0 100644
1113 +--- a/drivers/media/video/uvc/uvc_v4l2.c
1114 ++++ b/drivers/media/video/uvc/uvc_v4l2.c
1115 +@@ -65,6 +65,15 @@ static int uvc_ioctl_ctrl_map(struct uvc_video_chain *chain,
1116 + goto done;
1117 + }
1118 +
1119 ++ /* Prevent excessive memory consumption, as well as integer
1120 ++ * overflows.
1121 ++ */
1122 ++ if (xmap->menu_count == 0 ||
1123 ++ xmap->menu_count > UVC_MAX_CONTROL_MENU_ENTRIES) {
1124 ++ ret = -EINVAL;
1125 ++ goto done;
1126 ++ }
1127 ++
1128 + size = xmap->menu_count * sizeof(*map->menu_info);
1129 + map->menu_info = kmalloc(size, GFP_KERNEL);
1130 + if (map->menu_info == NULL) {
1131 +diff --git a/drivers/media/video/uvc/uvcvideo.h b/drivers/media/video/uvc/uvcvideo.h
1132 +index 2a38d5e..cf2401a 100644
1133 +--- a/drivers/media/video/uvc/uvcvideo.h
1134 ++++ b/drivers/media/video/uvc/uvcvideo.h
1135 +@@ -200,6 +200,7 @@ struct uvc_xu_control {
1136 +
1137 + /* Maximum allowed number of control mappings per device */
1138 + #define UVC_MAX_CONTROL_MAPPINGS 1024
1139 ++#define UVC_MAX_CONTROL_MENU_ENTRIES 32
1140 +
1141 + /* Devices quirks */
1142 + #define UVC_QUIRK_STATUS_INTERVAL 0x00000001
1143 +diff --git a/drivers/media/video/v4l2-ioctl.c b/drivers/media/video/v4l2-ioctl.c
1144 +index 69e8c6f..bda252f 100644
1145 +--- a/drivers/media/video/v4l2-ioctl.c
1146 ++++ b/drivers/media/video/v4l2-ioctl.c
1147 +@@ -2289,6 +2289,10 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
1148 + struct v4l2_ext_controls *ctrls = parg;
1149 +
1150 + if (ctrls->count != 0) {
1151 ++ if (ctrls->count > V4L2_CID_MAX_CTRLS) {
1152 ++ ret = -EINVAL;
1153 ++ break;
1154 ++ }
1155 + *user_ptr = (void __user *)ctrls->controls;
1156 + *kernel_ptr = (void **)&ctrls->controls;
1157 + *array_size = sizeof(struct v4l2_ext_control)
1158 +diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
1159 +index 20b42c8..f601180 100644
1160 +--- a/drivers/mmc/core/mmc.c
1161 ++++ b/drivers/mmc/core/mmc.c
1162 +@@ -830,7 +830,7 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
1163 + *
1164 + * WARNING: eMMC rules are NOT the same as SD DDR
1165 + */
1166 +- if (ddr == EXT_CSD_CARD_TYPE_DDR_1_2V) {
1167 ++ if (ddr == MMC_1_2V_DDR_MODE) {
1168 + err = mmc_set_signal_voltage(host,
1169 + MMC_SIGNAL_VOLTAGE_120, 0);
1170 + if (err)
1171 +diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
1172 +index 6d3de08..153008f 100644
1173 +--- a/drivers/mmc/host/sdhci.c
1174 ++++ b/drivers/mmc/host/sdhci.c
1175 +@@ -1340,8 +1340,7 @@ static void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
1176 + if ((ios->timing == MMC_TIMING_UHS_SDR50) ||
1177 + (ios->timing == MMC_TIMING_UHS_SDR104) ||
1178 + (ios->timing == MMC_TIMING_UHS_DDR50) ||
1179 +- (ios->timing == MMC_TIMING_UHS_SDR25) ||
1180 +- (ios->timing == MMC_TIMING_UHS_SDR12))
1181 ++ (ios->timing == MMC_TIMING_UHS_SDR25))
1182 + ctrl |= SDHCI_CTRL_HISPD;
1183 +
1184 + ctrl_2 = sdhci_readw(host, SDHCI_HOST_CONTROL2);
1185 +@@ -2227,9 +2226,8 @@ int sdhci_suspend_host(struct sdhci_host *host, pm_message_t state)
1186 + /* Disable tuning since we are suspending */
1187 + if (host->version >= SDHCI_SPEC_300 && host->tuning_count &&
1188 + host->tuning_mode == SDHCI_TUNING_MODE_1) {
1189 ++ del_timer_sync(&host->tuning_timer);
1190 + host->flags &= ~SDHCI_NEEDS_RETUNING;
1191 +- mod_timer(&host->tuning_timer, jiffies +
1192 +- host->tuning_count * HZ);
1193 + }
1194 +
1195 + ret = mmc_suspend_host(host->mmc);
1196 +diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c
1197 +index ca38569..bff8d46 100644
1198 +--- a/drivers/mtd/mtd_blkdevs.c
1199 ++++ b/drivers/mtd/mtd_blkdevs.c
1200 +@@ -215,7 +215,7 @@ static int blktrans_open(struct block_device *bdev, fmode_t mode)
1201 +
1202 + mutex_lock(&dev->lock);
1203 +
1204 +- if (dev->open++)
1205 ++ if (dev->open)
1206 + goto unlock;
1207 +
1208 + kref_get(&dev->ref);
1209 +@@ -235,6 +235,7 @@ static int blktrans_open(struct block_device *bdev, fmode_t mode)
1210 + goto error_release;
1211 +
1212 + unlock:
1213 ++ dev->open++;
1214 + mutex_unlock(&dev->lock);
1215 + blktrans_dev_put(dev);
1216 + return ret;
1217 +diff --git a/drivers/mtd/mtdoops.c b/drivers/mtd/mtdoops.c
1218 +index e3e40f4..43130e8 100644
1219 +--- a/drivers/mtd/mtdoops.c
1220 ++++ b/drivers/mtd/mtdoops.c
1221 +@@ -253,6 +253,9 @@ static void find_next_position(struct mtdoops_context *cxt)
1222 + size_t retlen;
1223 +
1224 + for (page = 0; page < cxt->oops_pages; page++) {
1225 ++ if (mtd->block_isbad &&
1226 ++ mtd->block_isbad(mtd, page * record_size))
1227 ++ continue;
1228 + /* Assume the page is used */
1229 + mark_page_used(cxt, page);
1230 + ret = mtd->read(mtd, page * record_size, MTDOOPS_HEADER_SIZE,
1231 +@@ -369,7 +372,7 @@ static void mtdoops_notify_add(struct mtd_info *mtd)
1232 +
1233 + /* oops_page_used is a bit field */
1234 + cxt->oops_page_used = vmalloc(DIV_ROUND_UP(mtdoops_pages,
1235 +- BITS_PER_LONG));
1236 ++ BITS_PER_LONG) * sizeof(unsigned long));
1237 + if (!cxt->oops_page_used) {
1238 + printk(KERN_ERR "mtdoops: could not allocate page array\n");
1239 + return;
1240 +diff --git a/drivers/mtd/tests/mtd_stresstest.c b/drivers/mtd/tests/mtd_stresstest.c
1241 +index 531625f..129bad2 100644
1242 +--- a/drivers/mtd/tests/mtd_stresstest.c
1243 ++++ b/drivers/mtd/tests/mtd_stresstest.c
1244 +@@ -277,6 +277,12 @@ static int __init mtd_stresstest_init(void)
1245 + (unsigned long long)mtd->size, mtd->erasesize,
1246 + pgsize, ebcnt, pgcnt, mtd->oobsize);
1247 +
1248 ++ if (ebcnt < 2) {
1249 ++ printk(PRINT_PREF "error: need at least 2 eraseblocks\n");
1250 ++ err = -ENOSPC;
1251 ++ goto out_put_mtd;
1252 ++ }
1253 ++
1254 + /* Read or write up 2 eraseblocks at a time */
1255 + bufsize = mtd->erasesize * 2;
1256 +
1257 +@@ -315,6 +321,7 @@ out:
1258 + kfree(bbt);
1259 + vfree(writebuf);
1260 + vfree(readbuf);
1261 ++out_put_mtd:
1262 + put_mtd_device(mtd);
1263 + if (err)
1264 + printk(PRINT_PREF "error %d occurred\n", err);
1265 +diff --git a/drivers/mtd/ubi/cdev.c b/drivers/mtd/ubi/cdev.c
1266 +index 191f3bb..cdea669 100644
1267 +--- a/drivers/mtd/ubi/cdev.c
1268 ++++ b/drivers/mtd/ubi/cdev.c
1269 +@@ -628,6 +628,9 @@ static int verify_mkvol_req(const struct ubi_device *ubi,
1270 + if (req->alignment != 1 && n)
1271 + goto bad;
1272 +
1273 ++ if (!req->name[0] || !req->name_len)
1274 ++ goto bad;
1275 ++
1276 + if (req->name_len > UBI_VOL_NAME_MAX) {
1277 + err = -ENAMETOOLONG;
1278 + goto bad;
1279 +diff --git a/drivers/mtd/ubi/debug.h b/drivers/mtd/ubi/debug.h
1280 +index 3f1a09c..5f0e4c2 100644
1281 +--- a/drivers/mtd/ubi/debug.h
1282 ++++ b/drivers/mtd/ubi/debug.h
1283 +@@ -51,7 +51,10 @@ struct ubi_mkvol_req;
1284 + pr_debug("UBI DBG " type ": " fmt "\n", ##__VA_ARGS__)
1285 +
1286 + /* Just a debugging messages not related to any specific UBI subsystem */
1287 +-#define dbg_msg(fmt, ...) ubi_dbg_msg("msg", fmt, ##__VA_ARGS__)
1288 ++#define dbg_msg(fmt, ...) \
1289 ++ printk(KERN_DEBUG "UBI DBG (pid %d): %s: " fmt "\n", \
1290 ++ current->pid, __func__, ##__VA_ARGS__)
1291 ++
1292 + /* General debugging messages */
1293 + #define dbg_gen(fmt, ...) ubi_dbg_msg("gen", fmt, ##__VA_ARGS__)
1294 + /* Messages from the eraseblock association sub-system */
1295 +diff --git a/drivers/mtd/ubi/eba.c b/drivers/mtd/ubi/eba.c
1296 +index 4be6718..c696c94 100644
1297 +--- a/drivers/mtd/ubi/eba.c
1298 ++++ b/drivers/mtd/ubi/eba.c
1299 +@@ -1028,12 +1028,14 @@ int ubi_eba_copy_leb(struct ubi_device *ubi, int from, int to,
1300 + * 'ubi_wl_put_peb()' function on the @ubi->move_mutex. In turn, we are
1301 + * holding @ubi->move_mutex and go sleep on the LEB lock. So, if the
1302 + * LEB is already locked, we just do not move it and return
1303 +- * %MOVE_CANCEL_RACE, which means that UBI will re-try, but later.
1304 ++ * %MOVE_RETRY. Note, we do not return %MOVE_CANCEL_RACE here because
1305 ++ * we do not know the reasons of the contention - it may be just a
1306 ++ * normal I/O on this LEB, so we want to re-try.
1307 + */
1308 + err = leb_write_trylock(ubi, vol_id, lnum);
1309 + if (err) {
1310 + dbg_wl("contention on LEB %d:%d, cancel", vol_id, lnum);
1311 +- return MOVE_CANCEL_RACE;
1312 ++ return MOVE_RETRY;
1313 + }
1314 +
1315 + /*
1316 +diff --git a/drivers/mtd/ubi/ubi.h b/drivers/mtd/ubi/ubi.h
1317 +index c6c2229..bbfa88d 100644
1318 +--- a/drivers/mtd/ubi/ubi.h
1319 ++++ b/drivers/mtd/ubi/ubi.h
1320 +@@ -121,6 +121,7 @@ enum {
1321 + * PEB
1322 + * MOVE_CANCEL_BITFLIPS: canceled because a bit-flip was detected in the
1323 + * target PEB
1324 ++ * MOVE_RETRY: retry scrubbing the PEB
1325 + */
1326 + enum {
1327 + MOVE_CANCEL_RACE = 1,
1328 +@@ -128,6 +129,7 @@ enum {
1329 + MOVE_TARGET_RD_ERR,
1330 + MOVE_TARGET_WR_ERR,
1331 + MOVE_CANCEL_BITFLIPS,
1332 ++ MOVE_RETRY,
1333 + };
1334 +
1335 + /**
1336 +diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c
1337 +index ff2c495..12e44c9 100644
1338 +--- a/drivers/mtd/ubi/wl.c
1339 ++++ b/drivers/mtd/ubi/wl.c
1340 +@@ -792,7 +792,10 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk,
1341 + protect = 1;
1342 + goto out_not_moved;
1343 + }
1344 +-
1345 ++ if (err == MOVE_RETRY) {
1346 ++ scrubbing = 1;
1347 ++ goto out_not_moved;
1348 ++ }
1349 + if (err == MOVE_CANCEL_BITFLIPS || err == MOVE_TARGET_WR_ERR ||
1350 + err == MOVE_TARGET_RD_ERR) {
1351 + /*
1352 +@@ -1046,7 +1049,6 @@ static int erase_worker(struct ubi_device *ubi, struct ubi_work *wl_wrk,
1353 +
1354 + ubi_err("failed to erase PEB %d, error %d", pnum, err);
1355 + kfree(wl_wrk);
1356 +- kmem_cache_free(ubi_wl_entry_slab, e);
1357 +
1358 + if (err == -EINTR || err == -ENOMEM || err == -EAGAIN ||
1359 + err == -EBUSY) {
1360 +@@ -1059,14 +1061,16 @@ static int erase_worker(struct ubi_device *ubi, struct ubi_work *wl_wrk,
1361 + goto out_ro;
1362 + }
1363 + return err;
1364 +- } else if (err != -EIO) {
1365 ++ }
1366 ++
1367 ++ kmem_cache_free(ubi_wl_entry_slab, e);
1368 ++ if (err != -EIO)
1369 + /*
1370 + * If this is not %-EIO, we have no idea what to do. Scheduling
1371 + * this physical eraseblock for erasure again would cause
1372 + * errors again and again. Well, lets switch to R/O mode.
1373 + */
1374 + goto out_ro;
1375 +- }
1376 +
1377 + /* It is %-EIO, the PEB went bad */
1378 +
1379 +diff --git a/drivers/net/phy/mdio-gpio.c b/drivers/net/phy/mdio-gpio.c
1380 +index 47c8339a..2843c90 100644
1381 +--- a/drivers/net/phy/mdio-gpio.c
1382 ++++ b/drivers/net/phy/mdio-gpio.c
1383 +@@ -241,7 +241,7 @@ MODULE_DEVICE_TABLE(of, mdio_ofgpio_match);
1384 +
1385 + static struct platform_driver mdio_ofgpio_driver = {
1386 + .driver = {
1387 +- .name = "mdio-gpio",
1388 ++ .name = "mdio-ofgpio",
1389 + .owner = THIS_MODULE,
1390 + .of_match_table = mdio_ofgpio_match,
1391 + },
1392 +diff --git a/drivers/net/wireless/iwlegacy/iwl3945-base.c b/drivers/net/wireless/iwlegacy/iwl3945-base.c
1393 +index 421d5c8..a935585 100644
1394 +--- a/drivers/net/wireless/iwlegacy/iwl3945-base.c
1395 ++++ b/drivers/net/wireless/iwlegacy/iwl3945-base.c
1396 +@@ -2910,14 +2910,13 @@ int iwl3945_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
1397 + IWL_WARN(priv, "Invalid scan band\n");
1398 + return -EIO;
1399 + }
1400 +-
1401 + /*
1402 +- * If active scaning is requested but a certain channel
1403 +- * is marked passive, we can do active scanning if we
1404 +- * detect transmissions.
1405 ++ * If active scaning is requested but a certain channel is marked
1406 ++ * passive, we can do active scanning if we detect transmissions. For
1407 ++ * passive only scanning disable switching to active on any channel.
1408 + */
1409 + scan->good_CRC_th = is_active ? IWL_GOOD_CRC_TH_DEFAULT :
1410 +- IWL_GOOD_CRC_TH_DISABLED;
1411 ++ IWL_GOOD_CRC_TH_NEVER;
1412 +
1413 + if (!priv->is_internal_short_scan) {
1414 + scan->tx_cmd.len = cpu_to_le16(
1415 +diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c
1416 +index f803fb6..857cf61 100644
1417 +--- a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c
1418 ++++ b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c
1419 +@@ -2023,6 +2023,7 @@ static int iwl_get_idle_rx_chain_count(struct iwl_priv *priv, int active_cnt)
1420 + case IEEE80211_SMPS_STATIC:
1421 + case IEEE80211_SMPS_DYNAMIC:
1422 + return IWL_NUM_IDLE_CHAINS_SINGLE;
1423 ++ case IEEE80211_SMPS_AUTOMATIC:
1424 + case IEEE80211_SMPS_OFF:
1425 + return active_cnt;
1426 + default:
1427 +diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c
1428 +index 39a3c9c..272bcdf 100644
1429 +--- a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c
1430 ++++ b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c
1431 +@@ -442,6 +442,9 @@ int iwlagn_mac_config(struct ieee80211_hw *hw, u32 changed)
1432 +
1433 + mutex_lock(&priv->mutex);
1434 +
1435 ++ if (test_bit(STATUS_EXIT_PENDING, &priv->status))
1436 ++ goto out;
1437 ++
1438 + if (unlikely(test_bit(STATUS_SCANNING, &priv->status))) {
1439 + IWL_DEBUG_MAC80211(priv, "leave - scanning\n");
1440 + goto out;
1441 +diff --git a/drivers/net/wireless/rt2x00/rt2800pci.c b/drivers/net/wireless/rt2x00/rt2800pci.c
1442 +index 55cd3e1..dab7dc1 100644
1443 +--- a/drivers/net/wireless/rt2x00/rt2800pci.c
1444 ++++ b/drivers/net/wireless/rt2x00/rt2800pci.c
1445 +@@ -426,7 +426,6 @@ static int rt2800pci_init_queues(struct rt2x00_dev *rt2x00dev)
1446 + static void rt2800pci_toggle_irq(struct rt2x00_dev *rt2x00dev,
1447 + enum dev_state state)
1448 + {
1449 +- int mask = (state == STATE_RADIO_IRQ_ON);
1450 + u32 reg;
1451 + unsigned long flags;
1452 +
1453 +@@ -448,25 +447,14 @@ static void rt2800pci_toggle_irq(struct rt2x00_dev *rt2x00dev,
1454 + }
1455 +
1456 + spin_lock_irqsave(&rt2x00dev->irqmask_lock, flags);
1457 +- rt2x00pci_register_read(rt2x00dev, INT_MASK_CSR, &reg);
1458 +- rt2x00_set_field32(&reg, INT_MASK_CSR_RXDELAYINT, 0);
1459 +- rt2x00_set_field32(&reg, INT_MASK_CSR_TXDELAYINT, 0);
1460 +- rt2x00_set_field32(&reg, INT_MASK_CSR_RX_DONE, mask);
1461 +- rt2x00_set_field32(&reg, INT_MASK_CSR_AC0_DMA_DONE, 0);
1462 +- rt2x00_set_field32(&reg, INT_MASK_CSR_AC1_DMA_DONE, 0);
1463 +- rt2x00_set_field32(&reg, INT_MASK_CSR_AC2_DMA_DONE, 0);
1464 +- rt2x00_set_field32(&reg, INT_MASK_CSR_AC3_DMA_DONE, 0);
1465 +- rt2x00_set_field32(&reg, INT_MASK_CSR_HCCA_DMA_DONE, 0);
1466 +- rt2x00_set_field32(&reg, INT_MASK_CSR_MGMT_DMA_DONE, 0);
1467 +- rt2x00_set_field32(&reg, INT_MASK_CSR_MCU_COMMAND, 0);
1468 +- rt2x00_set_field32(&reg, INT_MASK_CSR_RXTX_COHERENT, 0);
1469 +- rt2x00_set_field32(&reg, INT_MASK_CSR_TBTT, mask);
1470 +- rt2x00_set_field32(&reg, INT_MASK_CSR_PRE_TBTT, mask);
1471 +- rt2x00_set_field32(&reg, INT_MASK_CSR_TX_FIFO_STATUS, mask);
1472 +- rt2x00_set_field32(&reg, INT_MASK_CSR_AUTO_WAKEUP, mask);
1473 +- rt2x00_set_field32(&reg, INT_MASK_CSR_GPTIMER, 0);
1474 +- rt2x00_set_field32(&reg, INT_MASK_CSR_RX_COHERENT, 0);
1475 +- rt2x00_set_field32(&reg, INT_MASK_CSR_TX_COHERENT, 0);
1476 ++ reg = 0;
1477 ++ if (state == STATE_RADIO_IRQ_ON) {
1478 ++ rt2x00_set_field32(&reg, INT_MASK_CSR_RX_DONE, 1);
1479 ++ rt2x00_set_field32(&reg, INT_MASK_CSR_TBTT, 1);
1480 ++ rt2x00_set_field32(&reg, INT_MASK_CSR_PRE_TBTT, 1);
1481 ++ rt2x00_set_field32(&reg, INT_MASK_CSR_TX_FIFO_STATUS, 1);
1482 ++ rt2x00_set_field32(&reg, INT_MASK_CSR_AUTO_WAKEUP, 1);
1483 ++ }
1484 + rt2x00pci_register_write(rt2x00dev, INT_MASK_CSR, reg);
1485 + spin_unlock_irqrestore(&rt2x00dev->irqmask_lock, flags);
1486 +
1487 +diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/fw.c b/drivers/net/wireless/rtlwifi/rtl8192se/fw.c
1488 +index 3b5af01..0c77a14 100644
1489 +--- a/drivers/net/wireless/rtlwifi/rtl8192se/fw.c
1490 ++++ b/drivers/net/wireless/rtlwifi/rtl8192se/fw.c
1491 +@@ -196,6 +196,8 @@ static bool _rtl92s_firmware_downloadcode(struct ieee80211_hw *hw,
1492 + /* Allocate skb buffer to contain firmware */
1493 + /* info and tx descriptor info. */
1494 + skb = dev_alloc_skb(frag_length);
1495 ++ if (!skb)
1496 ++ return false;
1497 + skb_reserve(skb, extra_descoffset);
1498 + seg_ptr = (u8 *)skb_put(skb, (u32)(frag_length -
1499 + extra_descoffset));
1500 +@@ -575,6 +577,8 @@ static bool _rtl92s_firmware_set_h2c_cmd(struct ieee80211_hw *hw, u8 h2c_cmd,
1501 +
1502 + len = _rtl92s_get_h2c_cmdlen(MAX_TRANSMIT_BUFFER_SIZE, 1, &cmd_len);
1503 + skb = dev_alloc_skb(len);
1504 ++ if (!skb)
1505 ++ return false;
1506 + cb_desc = (struct rtl_tcb_desc *)(skb->cb);
1507 + cb_desc->queue_index = TXCMD_QUEUE;
1508 + cb_desc->cmd_or_init = DESC_PACKET_TYPE_NORMAL;
1509 +diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
1510 +index 2f10328..e174982 100644
1511 +--- a/drivers/pci/msi.c
1512 ++++ b/drivers/pci/msi.c
1513 +@@ -869,5 +869,15 @@ EXPORT_SYMBOL(pci_msi_enabled);
1514 +
1515 + void pci_msi_init_pci_dev(struct pci_dev *dev)
1516 + {
1517 ++ int pos;
1518 + INIT_LIST_HEAD(&dev->msi_list);
1519 ++
1520 ++ /* Disable the msi hardware to avoid screaming interrupts
1521 ++ * during boot. This is the power on reset default so
1522 ++ * usually this should be a noop.
1523 ++ */
1524 ++ pos = pci_find_capability(dev, PCI_CAP_ID_MSI);
1525 ++ if (pos)
1526 ++ msi_set_enable(dev, pos, 0);
1527 ++ msix_set_enable(dev, 0);
1528 + }
1529 +diff --git a/drivers/pnp/quirks.c b/drivers/pnp/quirks.c
1530 +index dfbd5a6..258fef2 100644
1531 +--- a/drivers/pnp/quirks.c
1532 ++++ b/drivers/pnp/quirks.c
1533 +@@ -295,6 +295,45 @@ static void quirk_system_pci_resources(struct pnp_dev *dev)
1534 + }
1535 + }
1536 +
1537 ++#ifdef CONFIG_AMD_NB
1538 ++
1539 ++#include <asm/amd_nb.h>
1540 ++
1541 ++static void quirk_amd_mmconfig_area(struct pnp_dev *dev)
1542 ++{
1543 ++ resource_size_t start, end;
1544 ++ struct pnp_resource *pnp_res;
1545 ++ struct resource *res;
1546 ++ struct resource mmconfig_res, *mmconfig;
1547 ++
1548 ++ mmconfig = amd_get_mmconfig_range(&mmconfig_res);
1549 ++ if (!mmconfig)
1550 ++ return;
1551 ++
1552 ++ list_for_each_entry(pnp_res, &dev->resources, list) {
1553 ++ res = &pnp_res->res;
1554 ++ if (res->end < mmconfig->start || res->start > mmconfig->end ||
1555 ++ (res->start == mmconfig->start && res->end == mmconfig->end))
1556 ++ continue;
1557 ++
1558 ++ dev_info(&dev->dev, FW_BUG
1559 ++ "%pR covers only part of AMD MMCONFIG area %pR; adding more reservations\n",
1560 ++ res, mmconfig);
1561 ++ if (mmconfig->start < res->start) {
1562 ++ start = mmconfig->start;
1563 ++ end = res->start - 1;
1564 ++ pnp_add_mem_resource(dev, start, end, 0);
1565 ++ }
1566 ++ if (mmconfig->end > res->end) {
1567 ++ start = res->end + 1;
1568 ++ end = mmconfig->end;
1569 ++ pnp_add_mem_resource(dev, start, end, 0);
1570 ++ }
1571 ++ break;
1572 ++ }
1573 ++}
1574 ++#endif
1575 ++
1576 + /*
1577 + * PnP Quirks
1578 + * Cards or devices that need some tweaking due to incomplete resource info
1579 +@@ -322,6 +361,9 @@ static struct pnp_fixup pnp_fixups[] = {
1580 + /* PnP resources that might overlap PCI BARs */
1581 + {"PNP0c01", quirk_system_pci_resources},
1582 + {"PNP0c02", quirk_system_pci_resources},
1583 ++#ifdef CONFIG_AMD_NB
1584 ++ {"PNP0c01", quirk_amd_mmconfig_area},
1585 ++#endif
1586 + {""}
1587 + };
1588 +
1589 +diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c
1590 +index eb4c883..38d1dc7 100644
1591 +--- a/drivers/rtc/interface.c
1592 ++++ b/drivers/rtc/interface.c
1593 +@@ -227,11 +227,11 @@ int __rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
1594 + alarm->time.tm_hour = now.tm_hour;
1595 +
1596 + /* For simplicity, only support date rollover for now */
1597 +- if (alarm->time.tm_mday == -1) {
1598 ++ if (alarm->time.tm_mday < 1 || alarm->time.tm_mday > 31) {
1599 + alarm->time.tm_mday = now.tm_mday;
1600 + missing = day;
1601 + }
1602 +- if (alarm->time.tm_mon == -1) {
1603 ++ if ((unsigned)alarm->time.tm_mon >= 12) {
1604 + alarm->time.tm_mon = now.tm_mon;
1605 + if (missing == none)
1606 + missing = month;
1607 +diff --git a/drivers/scsi/mpt2sas/mpt2sas_base.c b/drivers/scsi/mpt2sas/mpt2sas_base.c
1608 +index 39e81cd..10f16a3 100644
1609 +--- a/drivers/scsi/mpt2sas/mpt2sas_base.c
1610 ++++ b/drivers/scsi/mpt2sas/mpt2sas_base.c
1611 +@@ -66,6 +66,8 @@ static MPT_CALLBACK mpt_callbacks[MPT_MAX_CALLBACKS];
1612 +
1613 + #define FAULT_POLLING_INTERVAL 1000 /* in milliseconds */
1614 +
1615 ++#define MAX_HBA_QUEUE_DEPTH 30000
1616 ++#define MAX_CHAIN_DEPTH 100000
1617 + static int max_queue_depth = -1;
1618 + module_param(max_queue_depth, int, 0);
1619 + MODULE_PARM_DESC(max_queue_depth, " max controller queue depth ");
1620 +@@ -2098,8 +2100,6 @@ _base_release_memory_pools(struct MPT2SAS_ADAPTER *ioc)
1621 + }
1622 + if (ioc->chain_dma_pool)
1623 + pci_pool_destroy(ioc->chain_dma_pool);
1624 +- }
1625 +- if (ioc->chain_lookup) {
1626 + free_pages((ulong)ioc->chain_lookup, ioc->chain_pages);
1627 + ioc->chain_lookup = NULL;
1628 + }
1629 +@@ -2117,9 +2117,7 @@ static int
1630 + _base_allocate_memory_pools(struct MPT2SAS_ADAPTER *ioc, int sleep_flag)
1631 + {
1632 + struct mpt2sas_facts *facts;
1633 +- u32 queue_size, queue_diff;
1634 + u16 max_sge_elements;
1635 +- u16 num_of_reply_frames;
1636 + u16 chains_needed_per_io;
1637 + u32 sz, total_sz;
1638 + u32 retry_sz;
1639 +@@ -2146,7 +2144,8 @@ _base_allocate_memory_pools(struct MPT2SAS_ADAPTER *ioc, int sleep_flag)
1640 + max_request_credit = (max_queue_depth < facts->RequestCredit)
1641 + ? max_queue_depth : facts->RequestCredit;
1642 + else
1643 +- max_request_credit = facts->RequestCredit;
1644 ++ max_request_credit = min_t(u16, facts->RequestCredit,
1645 ++ MAX_HBA_QUEUE_DEPTH);
1646 +
1647 + ioc->hba_queue_depth = max_request_credit;
1648 + ioc->hi_priority_depth = facts->HighPriorityCredit;
1649 +@@ -2187,50 +2186,25 @@ _base_allocate_memory_pools(struct MPT2SAS_ADAPTER *ioc, int sleep_flag)
1650 + }
1651 + ioc->chains_needed_per_io = chains_needed_per_io;
1652 +
1653 +- /* reply free queue sizing - taking into account for events */
1654 +- num_of_reply_frames = ioc->hba_queue_depth + 32;
1655 +-
1656 +- /* number of replies frames can't be a multiple of 16 */
1657 +- /* decrease number of reply frames by 1 */
1658 +- if (!(num_of_reply_frames % 16))
1659 +- num_of_reply_frames--;
1660 +-
1661 +- /* calculate number of reply free queue entries
1662 +- * (must be multiple of 16)
1663 +- */
1664 +-
1665 +- /* (we know reply_free_queue_depth is not a multiple of 16) */
1666 +- queue_size = num_of_reply_frames;
1667 +- queue_size += 16 - (queue_size % 16);
1668 +- ioc->reply_free_queue_depth = queue_size;
1669 +-
1670 +- /* reply descriptor post queue sizing */
1671 +- /* this size should be the number of request frames + number of reply
1672 +- * frames
1673 +- */
1674 +-
1675 +- queue_size = ioc->hba_queue_depth + num_of_reply_frames + 1;
1676 +- /* round up to 16 byte boundary */
1677 +- if (queue_size % 16)
1678 +- queue_size += 16 - (queue_size % 16);
1679 +-
1680 +- /* check against IOC maximum reply post queue depth */
1681 +- if (queue_size > facts->MaxReplyDescriptorPostQueueDepth) {
1682 +- queue_diff = queue_size -
1683 +- facts->MaxReplyDescriptorPostQueueDepth;
1684 ++ /* reply free queue sizing - taking into account for 64 FW events */
1685 ++ ioc->reply_free_queue_depth = ioc->hba_queue_depth + 64;
1686 +
1687 +- /* round queue_diff up to multiple of 16 */
1688 +- if (queue_diff % 16)
1689 +- queue_diff += 16 - (queue_diff % 16);
1690 +-
1691 +- /* adjust hba_queue_depth, reply_free_queue_depth,
1692 +- * and queue_size
1693 +- */
1694 +- ioc->hba_queue_depth -= (queue_diff / 2);
1695 +- ioc->reply_free_queue_depth -= (queue_diff / 2);
1696 +- queue_size = facts->MaxReplyDescriptorPostQueueDepth;
1697 ++ /* align the reply post queue on the next 16 count boundary */
1698 ++ if (!ioc->reply_free_queue_depth % 16)
1699 ++ ioc->reply_post_queue_depth = ioc->reply_free_queue_depth + 16;
1700 ++ else
1701 ++ ioc->reply_post_queue_depth = ioc->reply_free_queue_depth +
1702 ++ 32 - (ioc->reply_free_queue_depth % 16);
1703 ++ if (ioc->reply_post_queue_depth >
1704 ++ facts->MaxReplyDescriptorPostQueueDepth) {
1705 ++ ioc->reply_post_queue_depth = min_t(u16,
1706 ++ (facts->MaxReplyDescriptorPostQueueDepth -
1707 ++ (facts->MaxReplyDescriptorPostQueueDepth % 16)),
1708 ++ (ioc->hba_queue_depth - (ioc->hba_queue_depth % 16)));
1709 ++ ioc->reply_free_queue_depth = ioc->reply_post_queue_depth - 16;
1710 ++ ioc->hba_queue_depth = ioc->reply_free_queue_depth - 64;
1711 + }
1712 +- ioc->reply_post_queue_depth = queue_size;
1713 ++
1714 +
1715 + dinitprintk(ioc, printk(MPT2SAS_INFO_FMT "scatter gather: "
1716 + "sge_in_main_msg(%d), sge_per_chain(%d), sge_per_io(%d), "
1717 +@@ -2316,15 +2290,12 @@ _base_allocate_memory_pools(struct MPT2SAS_ADAPTER *ioc, int sleep_flag)
1718 + "depth(%d)\n", ioc->name, ioc->request,
1719 + ioc->scsiio_depth));
1720 +
1721 +- /* loop till the allocation succeeds */
1722 +- do {
1723 +- sz = ioc->chain_depth * sizeof(struct chain_tracker);
1724 +- ioc->chain_pages = get_order(sz);
1725 +- ioc->chain_lookup = (struct chain_tracker *)__get_free_pages(
1726 +- GFP_KERNEL, ioc->chain_pages);
1727 +- if (ioc->chain_lookup == NULL)
1728 +- ioc->chain_depth -= 100;
1729 +- } while (ioc->chain_lookup == NULL);
1730 ++ ioc->chain_depth = min_t(u32, ioc->chain_depth, MAX_CHAIN_DEPTH);
1731 ++ sz = ioc->chain_depth * sizeof(struct chain_tracker);
1732 ++ ioc->chain_pages = get_order(sz);
1733 ++
1734 ++ ioc->chain_lookup = (struct chain_tracker *)__get_free_pages(
1735 ++ GFP_KERNEL, ioc->chain_pages);
1736 + ioc->chain_dma_pool = pci_pool_create("chain pool", ioc->pdev,
1737 + ioc->request_sz, 16, 0);
1738 + if (!ioc->chain_dma_pool) {
1739 +diff --git a/drivers/scsi/mpt2sas/mpt2sas_scsih.c b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
1740 +index c79857e..aa51195 100644
1741 +--- a/drivers/scsi/mpt2sas/mpt2sas_scsih.c
1742 ++++ b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
1743 +@@ -974,8 +974,8 @@ _scsih_get_chain_buffer_tracker(struct MPT2SAS_ADAPTER *ioc, u16 smid)
1744 + spin_lock_irqsave(&ioc->scsi_lookup_lock, flags);
1745 + if (list_empty(&ioc->free_chain_list)) {
1746 + spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags);
1747 +- printk(MPT2SAS_WARN_FMT "chain buffers not available\n",
1748 +- ioc->name);
1749 ++ dfailprintk(ioc, printk(MPT2SAS_WARN_FMT "chain buffers not "
1750 ++ "available\n", ioc->name));
1751 + return NULL;
1752 + }
1753 + chain_req = list_entry(ioc->free_chain_list.next,
1754 +@@ -6425,6 +6425,7 @@ _scsih_mark_responding_raid_device(struct MPT2SAS_ADAPTER *ioc, u64 wwid,
1755 + } else
1756 + sas_target_priv_data = NULL;
1757 + raid_device->responding = 1;
1758 ++ spin_unlock_irqrestore(&ioc->raid_device_lock, flags);
1759 + starget_printk(KERN_INFO, raid_device->starget,
1760 + "handle(0x%04x), wwid(0x%016llx)\n", handle,
1761 + (unsigned long long)raid_device->wwid);
1762 +@@ -6435,16 +6436,16 @@ _scsih_mark_responding_raid_device(struct MPT2SAS_ADAPTER *ioc, u64 wwid,
1763 + */
1764 + _scsih_init_warpdrive_properties(ioc, raid_device);
1765 + if (raid_device->handle == handle)
1766 +- goto out;
1767 ++ return;
1768 + printk(KERN_INFO "\thandle changed from(0x%04x)!!!\n",
1769 + raid_device->handle);
1770 + raid_device->handle = handle;
1771 + if (sas_target_priv_data)
1772 + sas_target_priv_data->handle = handle;
1773 +- goto out;
1774 ++ return;
1775 + }
1776 + }
1777 +- out:
1778 ++
1779 + spin_unlock_irqrestore(&ioc->raid_device_lock, flags);
1780 + }
1781 +
1782 +diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
1783 +index 953773c..7d8b5d8 100644
1784 +--- a/drivers/scsi/sd.c
1785 ++++ b/drivers/scsi/sd.c
1786 +@@ -1073,6 +1073,10 @@ static int sd_ioctl(struct block_device *bdev, fmode_t mode,
1787 + SCSI_LOG_IOCTL(1, printk("sd_ioctl: disk=%s, cmd=0x%x\n",
1788 + disk->disk_name, cmd));
1789 +
1790 ++ error = scsi_verify_blk_ioctl(bdev, cmd);
1791 ++ if (error < 0)
1792 ++ return error;
1793 ++
1794 + /*
1795 + * If we are in the middle of error recovery, don't let anyone
1796 + * else try and use this device. Also, if error recovery fails, it
1797 +@@ -1095,7 +1099,7 @@ static int sd_ioctl(struct block_device *bdev, fmode_t mode,
1798 + error = scsi_ioctl(sdp, cmd, p);
1799 + break;
1800 + default:
1801 +- error = scsi_cmd_ioctl(disk->queue, disk, mode, cmd, p);
1802 ++ error = scsi_cmd_blk_ioctl(bdev, mode, cmd, p);
1803 + if (error != -ENOTTY)
1804 + break;
1805 + error = scsi_ioctl(sdp, cmd, p);
1806 +@@ -1265,6 +1269,11 @@ static int sd_compat_ioctl(struct block_device *bdev, fmode_t mode,
1807 + unsigned int cmd, unsigned long arg)
1808 + {
1809 + struct scsi_device *sdev = scsi_disk(bdev->bd_disk)->device;
1810 ++ int ret;
1811 ++
1812 ++ ret = scsi_verify_blk_ioctl(bdev, cmd);
1813 ++ if (ret < 0)
1814 ++ return -ENOIOCTLCMD;
1815 +
1816 + /*
1817 + * If we are in the middle of error recovery, don't let anyone
1818 +@@ -1276,8 +1285,6 @@ static int sd_compat_ioctl(struct block_device *bdev, fmode_t mode,
1819 + return -ENODEV;
1820 +
1821 + if (sdev->host->hostt->compat_ioctl) {
1822 +- int ret;
1823 +-
1824 + ret = sdev->host->hostt->compat_ioctl(sdev, cmd, (void __user *)arg);
1825 +
1826 + return ret;
1827 +diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c
1828 +index b4543f5..36d1ed7 100644
1829 +--- a/drivers/scsi/sym53c8xx_2/sym_glue.c
1830 ++++ b/drivers/scsi/sym53c8xx_2/sym_glue.c
1831 +@@ -839,6 +839,10 @@ static void sym53c8xx_slave_destroy(struct scsi_device *sdev)
1832 + struct sym_lcb *lp = sym_lp(tp, sdev->lun);
1833 + unsigned long flags;
1834 +
1835 ++ /* if slave_alloc returned before allocating a sym_lcb, return */
1836 ++ if (!lp)
1837 ++ return;
1838 ++
1839 + spin_lock_irqsave(np->s.host->host_lock, flags);
1840 +
1841 + if (lp->busy_itlq || lp->busy_itl) {
1842 +diff --git a/drivers/target/target_core_cdb.c b/drivers/target/target_core_cdb.c
1843 +index 7f19c8b..f044d45 100644
1844 +--- a/drivers/target/target_core_cdb.c
1845 ++++ b/drivers/target/target_core_cdb.c
1846 +@@ -84,6 +84,18 @@ target_emulate_inquiry_std(struct se_cmd *cmd)
1847 + buf[2] = dev->transport->get_device_rev(dev);
1848 +
1849 + /*
1850 ++ * NORMACA and HISUP = 0, RESPONSE DATA FORMAT = 2
1851 ++ *
1852 ++ * SPC4 says:
1853 ++ * A RESPONSE DATA FORMAT field set to 2h indicates that the
1854 ++ * standard INQUIRY data is in the format defined in this
1855 ++ * standard. Response data format values less than 2h are
1856 ++ * obsolete. Response data format values greater than 2h are
1857 ++ * reserved.
1858 ++ */
1859 ++ buf[3] = 2;
1860 ++
1861 ++ /*
1862 + * Enable SCCS and TPGS fields for Emulated ALUA
1863 + */
1864 + if (T10_ALUA(dev->se_sub_dev)->alua_type == SPC3_ALUA_EMULATED)
1865 +diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
1866 +index 1340ffd..bb86655 100644
1867 +--- a/drivers/target/target_core_transport.c
1868 ++++ b/drivers/target/target_core_transport.c
1869 +@@ -5668,6 +5668,8 @@ int transport_send_check_condition_and_sense(
1870 + case TCM_SECTOR_COUNT_TOO_MANY:
1871 + /* CURRENT ERROR */
1872 + buffer[offset] = 0x70;
1873 ++ buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10;
1874 ++ buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10;
1875 + /* ILLEGAL REQUEST */
1876 + buffer[offset+SPC_SENSE_KEY_OFFSET] = ILLEGAL_REQUEST;
1877 + /* INVALID COMMAND OPERATION CODE */
1878 +@@ -5676,6 +5678,7 @@ int transport_send_check_condition_and_sense(
1879 + case TCM_UNKNOWN_MODE_PAGE:
1880 + /* CURRENT ERROR */
1881 + buffer[offset] = 0x70;
1882 ++ buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10;
1883 + /* ILLEGAL REQUEST */
1884 + buffer[offset+SPC_SENSE_KEY_OFFSET] = ILLEGAL_REQUEST;
1885 + /* INVALID FIELD IN CDB */
1886 +@@ -5684,6 +5687,7 @@ int transport_send_check_condition_and_sense(
1887 + case TCM_CHECK_CONDITION_ABORT_CMD:
1888 + /* CURRENT ERROR */
1889 + buffer[offset] = 0x70;
1890 ++ buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10;
1891 + /* ABORTED COMMAND */
1892 + buffer[offset+SPC_SENSE_KEY_OFFSET] = ABORTED_COMMAND;
1893 + /* BUS DEVICE RESET FUNCTION OCCURRED */
1894 +@@ -5693,6 +5697,7 @@ int transport_send_check_condition_and_sense(
1895 + case TCM_INCORRECT_AMOUNT_OF_DATA:
1896 + /* CURRENT ERROR */
1897 + buffer[offset] = 0x70;
1898 ++ buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10;
1899 + /* ABORTED COMMAND */
1900 + buffer[offset+SPC_SENSE_KEY_OFFSET] = ABORTED_COMMAND;
1901 + /* WRITE ERROR */
1902 +@@ -5703,6 +5708,7 @@ int transport_send_check_condition_and_sense(
1903 + case TCM_INVALID_CDB_FIELD:
1904 + /* CURRENT ERROR */
1905 + buffer[offset] = 0x70;
1906 ++ buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10;
1907 + /* ABORTED COMMAND */
1908 + buffer[offset+SPC_SENSE_KEY_OFFSET] = ABORTED_COMMAND;
1909 + /* INVALID FIELD IN CDB */
1910 +@@ -5711,6 +5717,7 @@ int transport_send_check_condition_and_sense(
1911 + case TCM_INVALID_PARAMETER_LIST:
1912 + /* CURRENT ERROR */
1913 + buffer[offset] = 0x70;
1914 ++ buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10;
1915 + /* ABORTED COMMAND */
1916 + buffer[offset+SPC_SENSE_KEY_OFFSET] = ABORTED_COMMAND;
1917 + /* INVALID FIELD IN PARAMETER LIST */
1918 +@@ -5719,6 +5726,7 @@ int transport_send_check_condition_and_sense(
1919 + case TCM_UNEXPECTED_UNSOLICITED_DATA:
1920 + /* CURRENT ERROR */
1921 + buffer[offset] = 0x70;
1922 ++ buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10;
1923 + /* ABORTED COMMAND */
1924 + buffer[offset+SPC_SENSE_KEY_OFFSET] = ABORTED_COMMAND;
1925 + /* WRITE ERROR */
1926 +@@ -5729,6 +5737,7 @@ int transport_send_check_condition_and_sense(
1927 + case TCM_SERVICE_CRC_ERROR:
1928 + /* CURRENT ERROR */
1929 + buffer[offset] = 0x70;
1930 ++ buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10;
1931 + /* ABORTED COMMAND */
1932 + buffer[offset+SPC_SENSE_KEY_OFFSET] = ABORTED_COMMAND;
1933 + /* PROTOCOL SERVICE CRC ERROR */
1934 +@@ -5739,6 +5748,7 @@ int transport_send_check_condition_and_sense(
1935 + case TCM_SNACK_REJECTED:
1936 + /* CURRENT ERROR */
1937 + buffer[offset] = 0x70;
1938 ++ buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10;
1939 + /* ABORTED COMMAND */
1940 + buffer[offset+SPC_SENSE_KEY_OFFSET] = ABORTED_COMMAND;
1941 + /* READ ERROR */
1942 +@@ -5749,6 +5759,7 @@ int transport_send_check_condition_and_sense(
1943 + case TCM_WRITE_PROTECTED:
1944 + /* CURRENT ERROR */
1945 + buffer[offset] = 0x70;
1946 ++ buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10;
1947 + /* DATA PROTECT */
1948 + buffer[offset+SPC_SENSE_KEY_OFFSET] = DATA_PROTECT;
1949 + /* WRITE PROTECTED */
1950 +@@ -5757,6 +5768,7 @@ int transport_send_check_condition_and_sense(
1951 + case TCM_CHECK_CONDITION_UNIT_ATTENTION:
1952 + /* CURRENT ERROR */
1953 + buffer[offset] = 0x70;
1954 ++ buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10;
1955 + /* UNIT ATTENTION */
1956 + buffer[offset+SPC_SENSE_KEY_OFFSET] = UNIT_ATTENTION;
1957 + core_scsi3_ua_for_check_condition(cmd, &asc, &ascq);
1958 +@@ -5766,6 +5778,7 @@ int transport_send_check_condition_and_sense(
1959 + case TCM_CHECK_CONDITION_NOT_READY:
1960 + /* CURRENT ERROR */
1961 + buffer[offset] = 0x70;
1962 ++ buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10;
1963 + /* Not Ready */
1964 + buffer[offset+SPC_SENSE_KEY_OFFSET] = NOT_READY;
1965 + transport_get_sense_codes(cmd, &asc, &ascq);
1966 +@@ -5776,6 +5789,7 @@ int transport_send_check_condition_and_sense(
1967 + default:
1968 + /* CURRENT ERROR */
1969 + buffer[offset] = 0x70;
1970 ++ buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10;
1971 + /* ILLEGAL REQUEST */
1972 + buffer[offset+SPC_SENSE_KEY_OFFSET] = ILLEGAL_REQUEST;
1973 + /* LOGICAL UNIT COMMUNICATION FAILURE */
1974 +diff --git a/drivers/xen/xenbus/xenbus_xs.c b/drivers/xen/xenbus/xenbus_xs.c
1975 +index 5534690..daee5db 100644
1976 +--- a/drivers/xen/xenbus/xenbus_xs.c
1977 ++++ b/drivers/xen/xenbus/xenbus_xs.c
1978 +@@ -801,6 +801,12 @@ static int process_msg(void)
1979 + goto out;
1980 + }
1981 +
1982 ++ if (msg->hdr.len > XENSTORE_PAYLOAD_MAX) {
1983 ++ kfree(msg);
1984 ++ err = -EINVAL;
1985 ++ goto out;
1986 ++ }
1987 ++
1988 + body = kmalloc(msg->hdr.len + 1, GFP_NOIO | __GFP_HIGH);
1989 + if (body == NULL) {
1990 + kfree(msg);
1991 +diff --git a/fs/dcache.c b/fs/dcache.c
1992 +index d2f8feb..f598b98 100644
1993 +--- a/fs/dcache.c
1994 ++++ b/fs/dcache.c
1995 +@@ -241,6 +241,7 @@ static void dentry_lru_add(struct dentry *dentry)
1996 + static void __dentry_lru_del(struct dentry *dentry)
1997 + {
1998 + list_del_init(&dentry->d_lru);
1999 ++ dentry->d_flags &= ~DCACHE_SHRINK_LIST;
2000 + dentry->d_sb->s_nr_dentry_unused--;
2001 + dentry_stat.nr_unused--;
2002 + }
2003 +@@ -753,6 +754,7 @@ relock:
2004 + spin_unlock(&dentry->d_lock);
2005 + } else {
2006 + list_move_tail(&dentry->d_lru, &tmp);
2007 ++ dentry->d_flags |= DCACHE_SHRINK_LIST;
2008 + spin_unlock(&dentry->d_lock);
2009 + if (!--cnt)
2010 + break;
2011 +@@ -1144,14 +1146,18 @@ resume:
2012 + /*
2013 + * move only zero ref count dentries to the end
2014 + * of the unused list for prune_dcache
2015 ++ *
2016 ++ * Those which are presently on the shrink list, being processed
2017 ++ * by shrink_dentry_list(), shouldn't be moved. Otherwise the
2018 ++ * loop in shrink_dcache_parent() might not make any progress
2019 ++ * and loop forever.
2020 + */
2021 +- if (!dentry->d_count) {
2022 ++ if (dentry->d_count) {
2023 ++ dentry_lru_del(dentry);
2024 ++ } else if (!(dentry->d_flags & DCACHE_SHRINK_LIST)) {
2025 + dentry_lru_move_tail(dentry);
2026 + found++;
2027 +- } else {
2028 +- dentry_lru_del(dentry);
2029 + }
2030 +-
2031 + /*
2032 + * We can return to the caller if we have found some (this
2033 + * ensures forward progress). We'll be coming back to find
2034 +diff --git a/fs/ext4/super.c b/fs/ext4/super.c
2035 +index 7aa77f0..df121b2 100644
2036 +--- a/fs/ext4/super.c
2037 ++++ b/fs/ext4/super.c
2038 +@@ -1957,17 +1957,16 @@ static int ext4_fill_flex_info(struct super_block *sb)
2039 + struct ext4_group_desc *gdp = NULL;
2040 + ext4_group_t flex_group_count;
2041 + ext4_group_t flex_group;
2042 +- int groups_per_flex = 0;
2043 ++ unsigned int groups_per_flex = 0;
2044 + size_t size;
2045 + int i;
2046 +
2047 + sbi->s_log_groups_per_flex = sbi->s_es->s_log_groups_per_flex;
2048 +- groups_per_flex = 1 << sbi->s_log_groups_per_flex;
2049 +-
2050 +- if (groups_per_flex < 2) {
2051 ++ if (sbi->s_log_groups_per_flex < 1 || sbi->s_log_groups_per_flex > 31) {
2052 + sbi->s_log_groups_per_flex = 0;
2053 + return 1;
2054 + }
2055 ++ groups_per_flex = 1 << sbi->s_log_groups_per_flex;
2056 +
2057 + /* We allocate both existing and potentially added groups */
2058 + flex_group_count = ((sbi->s_groups_count + groups_per_flex - 1) +
2059 +diff --git a/fs/nfs/callback_proc.c b/fs/nfs/callback_proc.c
2060 +index aaa09e9..b5c826e 100644
2061 +--- a/fs/nfs/callback_proc.c
2062 ++++ b/fs/nfs/callback_proc.c
2063 +@@ -324,7 +324,7 @@ validate_seqid(struct nfs4_slot_table *tbl, struct cb_sequenceargs * args)
2064 + dprintk("%s enter. slotid %d seqid %d\n",
2065 + __func__, args->csa_slotid, args->csa_sequenceid);
2066 +
2067 +- if (args->csa_slotid > NFS41_BC_MAX_CALLBACKS)
2068 ++ if (args->csa_slotid >= NFS41_BC_MAX_CALLBACKS)
2069 + return htonl(NFS4ERR_BADSLOT);
2070 +
2071 + slot = tbl->slots + args->csa_slotid;
2072 +diff --git a/fs/nfs/objlayout/objio_osd.c b/fs/nfs/objlayout/objio_osd.c
2073 +index 1d1dc1e..75fe694 100644
2074 +--- a/fs/nfs/objlayout/objio_osd.c
2075 ++++ b/fs/nfs/objlayout/objio_osd.c
2076 +@@ -1006,7 +1006,8 @@ static bool objio_pg_test(struct nfs_pageio_descriptor *pgio,
2077 + static struct pnfs_layoutdriver_type objlayout_type = {
2078 + .id = LAYOUT_OSD2_OBJECTS,
2079 + .name = "LAYOUT_OSD2_OBJECTS",
2080 +- .flags = PNFS_LAYOUTRET_ON_SETATTR,
2081 ++ .flags = PNFS_LAYOUTRET_ON_SETATTR |
2082 ++ PNFS_LAYOUTRET_ON_ERROR,
2083 +
2084 + .alloc_layout_hdr = objlayout_alloc_layout_hdr,
2085 + .free_layout_hdr = objlayout_free_layout_hdr,
2086 +diff --git a/fs/nfs/objlayout/objlayout.c b/fs/nfs/objlayout/objlayout.c
2087 +index 1d06f8e..fefa122 100644
2088 +--- a/fs/nfs/objlayout/objlayout.c
2089 ++++ b/fs/nfs/objlayout/objlayout.c
2090 +@@ -294,9 +294,11 @@ objlayout_read_done(struct objlayout_io_state *state, ssize_t status, bool sync)
2091 + dprintk("%s: Begin status=%zd eof=%d\n", __func__, status, eof);
2092 + rdata = state->rpcdata;
2093 + rdata->task.tk_status = status;
2094 +- if (status >= 0) {
2095 ++ if (likely(status >= 0)) {
2096 + rdata->res.count = status;
2097 + rdata->res.eof = eof;
2098 ++ } else {
2099 ++ rdata->pnfs_error = status;
2100 + }
2101 + objlayout_iodone(state);
2102 + /* must not use state after this point */
2103 +@@ -380,15 +382,17 @@ objlayout_write_done(struct objlayout_io_state *state, ssize_t status,
2104 + wdata = state->rpcdata;
2105 + state->status = status;
2106 + wdata->task.tk_status = status;
2107 +- if (status >= 0) {
2108 ++ if (likely(status >= 0)) {
2109 + wdata->res.count = status;
2110 + wdata->verf.committed = state->committed;
2111 + dprintk("%s: Return status %d committed %d\n",
2112 + __func__, wdata->task.tk_status,
2113 + wdata->verf.committed);
2114 +- } else
2115 ++ } else {
2116 ++ wdata->pnfs_error = status;
2117 + dprintk("%s: Return status %d\n",
2118 + __func__, wdata->task.tk_status);
2119 ++ }
2120 + objlayout_iodone(state);
2121 + /* must not use state after this point */
2122 +
2123 +diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
2124 +index 36d2a29..9951887 100644
2125 +--- a/fs/nfs/pnfs.c
2126 ++++ b/fs/nfs/pnfs.c
2127 +@@ -1119,6 +1119,14 @@ pnfs_ld_write_done(struct nfs_write_data *data)
2128 + data->mds_ops->rpc_release(data);
2129 + return 0;
2130 + }
2131 ++ if (NFS_SERVER(data->inode)->pnfs_curr_ld->flags &
2132 ++ PNFS_LAYOUTRET_ON_ERROR) {
2133 ++ /* Don't lo_commit on error, Server will needs to
2134 ++ * preform a file recovery.
2135 ++ */
2136 ++ clear_bit(NFS_INO_LAYOUTCOMMIT, &NFS_I(data->inode)->flags);
2137 ++ pnfs_return_layout(data->inode);
2138 ++ }
2139 +
2140 + dprintk("%s: pnfs_error=%d, retry via MDS\n", __func__,
2141 + data->pnfs_error);
2142 +@@ -1167,6 +1175,10 @@ pnfs_ld_read_done(struct nfs_read_data *data)
2143 + return 0;
2144 + }
2145 +
2146 ++ if (NFS_SERVER(data->inode)->pnfs_curr_ld->flags &
2147 ++ PNFS_LAYOUTRET_ON_ERROR)
2148 ++ pnfs_return_layout(data->inode);
2149 ++
2150 + dprintk("%s: pnfs_error=%d, retry via MDS\n", __func__,
2151 + data->pnfs_error);
2152 + status = nfs_initiate_read(data, NFS_CLIENT(data->inode),
2153 +diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h
2154 +index 9d147d9..bb8b324 100644
2155 +--- a/fs/nfs/pnfs.h
2156 ++++ b/fs/nfs/pnfs.h
2157 +@@ -68,6 +68,7 @@ enum {
2158 + enum layoutdriver_policy_flags {
2159 + /* Should the pNFS client commit and return the layout upon a setattr */
2160 + PNFS_LAYOUTRET_ON_SETATTR = 1 << 0,
2161 ++ PNFS_LAYOUTRET_ON_ERROR = 1 << 1,
2162 + };
2163 +
2164 + struct nfs4_deviceid_node;
2165 +diff --git a/fs/nfs/super.c b/fs/nfs/super.c
2166 +index 858d31b..7e8b07d 100644
2167 +--- a/fs/nfs/super.c
2168 ++++ b/fs/nfs/super.c
2169 +@@ -904,10 +904,24 @@ static struct nfs_parsed_mount_data *nfs_alloc_parsed_mount_data(unsigned int ve
2170 + data->auth_flavor_len = 1;
2171 + data->version = version;
2172 + data->minorversion = 0;
2173 ++ security_init_mnt_opts(&data->lsm_opts);
2174 + }
2175 + return data;
2176 + }
2177 +
2178 ++static void nfs_free_parsed_mount_data(struct nfs_parsed_mount_data *data)
2179 ++{
2180 ++ if (data) {
2181 ++ kfree(data->client_address);
2182 ++ kfree(data->mount_server.hostname);
2183 ++ kfree(data->nfs_server.export_path);
2184 ++ kfree(data->nfs_server.hostname);
2185 ++ kfree(data->fscache_uniq);
2186 ++ security_free_mnt_opts(&data->lsm_opts);
2187 ++ kfree(data);
2188 ++ }
2189 ++}
2190 ++
2191 + /*
2192 + * Sanity-check a server address provided by the mount command.
2193 + *
2194 +@@ -2218,9 +2232,7 @@ static struct dentry *nfs_fs_mount(struct file_system_type *fs_type,
2195 + data = nfs_alloc_parsed_mount_data(NFS_DEFAULT_VERSION);
2196 + mntfh = nfs_alloc_fhandle();
2197 + if (data == NULL || mntfh == NULL)
2198 +- goto out_free_fh;
2199 +-
2200 +- security_init_mnt_opts(&data->lsm_opts);
2201 ++ goto out;
2202 +
2203 + /* Validate the mount data */
2204 + error = nfs_validate_mount_data(raw_data, data, mntfh, dev_name);
2205 +@@ -2232,8 +2244,6 @@ static struct dentry *nfs_fs_mount(struct file_system_type *fs_type,
2206 + #ifdef CONFIG_NFS_V4
2207 + if (data->version == 4) {
2208 + mntroot = nfs4_try_mount(flags, dev_name, data);
2209 +- kfree(data->client_address);
2210 +- kfree(data->nfs_server.export_path);
2211 + goto out;
2212 + }
2213 + #endif /* CONFIG_NFS_V4 */
2214 +@@ -2284,13 +2294,8 @@ static struct dentry *nfs_fs_mount(struct file_system_type *fs_type,
2215 + s->s_flags |= MS_ACTIVE;
2216 +
2217 + out:
2218 +- kfree(data->nfs_server.hostname);
2219 +- kfree(data->mount_server.hostname);
2220 +- kfree(data->fscache_uniq);
2221 +- security_free_mnt_opts(&data->lsm_opts);
2222 +-out_free_fh:
2223 ++ nfs_free_parsed_mount_data(data);
2224 + nfs_free_fhandle(mntfh);
2225 +- kfree(data);
2226 + return mntroot;
2227 +
2228 + out_err_nosb:
2229 +@@ -2613,9 +2618,7 @@ nfs4_remote_mount(struct file_system_type *fs_type, int flags,
2230 +
2231 + mntfh = nfs_alloc_fhandle();
2232 + if (data == NULL || mntfh == NULL)
2233 +- goto out_free_fh;
2234 +-
2235 +- security_init_mnt_opts(&data->lsm_opts);
2236 ++ goto out;
2237 +
2238 + /* Get a volume representation */
2239 + server = nfs4_create_server(data, mntfh);
2240 +@@ -2663,13 +2666,10 @@ nfs4_remote_mount(struct file_system_type *fs_type, int flags,
2241 +
2242 + s->s_flags |= MS_ACTIVE;
2243 +
2244 +- security_free_mnt_opts(&data->lsm_opts);
2245 + nfs_free_fhandle(mntfh);
2246 + return mntroot;
2247 +
2248 + out:
2249 +- security_free_mnt_opts(&data->lsm_opts);
2250 +-out_free_fh:
2251 + nfs_free_fhandle(mntfh);
2252 + return ERR_PTR(error);
2253 +
2254 +@@ -2855,7 +2855,7 @@ static struct dentry *nfs4_mount(struct file_system_type *fs_type,
2255 +
2256 + data = nfs_alloc_parsed_mount_data(4);
2257 + if (data == NULL)
2258 +- goto out_free_data;
2259 ++ goto out;
2260 +
2261 + /* Validate the mount data */
2262 + error = nfs4_validate_mount_data(raw_data, data, dev_name);
2263 +@@ -2869,12 +2869,7 @@ static struct dentry *nfs4_mount(struct file_system_type *fs_type,
2264 + error = PTR_ERR(res);
2265 +
2266 + out:
2267 +- kfree(data->client_address);
2268 +- kfree(data->nfs_server.export_path);
2269 +- kfree(data->nfs_server.hostname);
2270 +- kfree(data->fscache_uniq);
2271 +-out_free_data:
2272 +- kfree(data);
2273 ++ nfs_free_parsed_mount_data(data);
2274 + dprintk("<-- nfs4_mount() = %d%s\n", error,
2275 + error != 0 ? " [error]" : "");
2276 + return res;
2277 +diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c
2278 +index b9566e4..4b470f6 100644
2279 +--- a/fs/nfsd/export.c
2280 ++++ b/fs/nfsd/export.c
2281 +@@ -88,7 +88,7 @@ static int expkey_parse(struct cache_detail *cd, char *mesg, int mlen)
2282 + struct svc_expkey key;
2283 + struct svc_expkey *ek = NULL;
2284 +
2285 +- if (mesg[mlen-1] != '\n')
2286 ++ if (mlen < 1 || mesg[mlen-1] != '\n')
2287 + return -EINVAL;
2288 + mesg[mlen-1] = 0;
2289 +
2290 +diff --git a/fs/notify/mark.c b/fs/notify/mark.c
2291 +index 252ab1f..42ed195 100644
2292 +--- a/fs/notify/mark.c
2293 ++++ b/fs/notify/mark.c
2294 +@@ -135,9 +135,6 @@ void fsnotify_destroy_mark(struct fsnotify_mark *mark)
2295 +
2296 + mark->flags &= ~FSNOTIFY_MARK_FLAG_ALIVE;
2297 +
2298 +- /* 1 from caller and 1 for being on i_list/g_list */
2299 +- BUG_ON(atomic_read(&mark->refcnt) < 2);
2300 +-
2301 + spin_lock(&group->mark_lock);
2302 +
2303 + if (mark->flags & FSNOTIFY_MARK_FLAG_INODE) {
2304 +@@ -182,6 +179,11 @@ void fsnotify_destroy_mark(struct fsnotify_mark *mark)
2305 + iput(inode);
2306 +
2307 + /*
2308 ++ * We don't necessarily have a ref on mark from caller so the above iput
2309 ++ * may have already destroyed it. Don't touch from now on.
2310 ++ */
2311 ++
2312 ++ /*
2313 + * it's possible that this group tried to destroy itself, but this
2314 + * this mark was simultaneously being freed by inode. If that's the
2315 + * case, we finish freeing the group here.
2316 +diff --git a/fs/proc/base.c b/fs/proc/base.c
2317 +index f039017..7b28f27 100644
2318 +--- a/fs/proc/base.c
2319 ++++ b/fs/proc/base.c
2320 +@@ -194,65 +194,7 @@ static int proc_root_link(struct inode *inode, struct path *path)
2321 + return result;
2322 + }
2323 +
2324 +-static struct mm_struct *__check_mem_permission(struct task_struct *task)
2325 +-{
2326 +- struct mm_struct *mm;
2327 +-
2328 +- mm = get_task_mm(task);
2329 +- if (!mm)
2330 +- return ERR_PTR(-EINVAL);
2331 +-
2332 +- /*
2333 +- * A task can always look at itself, in case it chooses
2334 +- * to use system calls instead of load instructions.
2335 +- */
2336 +- if (task == current)
2337 +- return mm;
2338 +-
2339 +- /*
2340 +- * If current is actively ptrace'ing, and would also be
2341 +- * permitted to freshly attach with ptrace now, permit it.
2342 +- */
2343 +- if (task_is_stopped_or_traced(task)) {
2344 +- int match;
2345 +- rcu_read_lock();
2346 +- match = (tracehook_tracer_task(task) == current);
2347 +- rcu_read_unlock();
2348 +- if (match && ptrace_may_access(task, PTRACE_MODE_ATTACH))
2349 +- return mm;
2350 +- }
2351 +-
2352 +- /*
2353 +- * No one else is allowed.
2354 +- */
2355 +- mmput(mm);
2356 +- return ERR_PTR(-EPERM);
2357 +-}
2358 +-
2359 +-/*
2360 +- * If current may access user memory in @task return a reference to the
2361 +- * corresponding mm, otherwise ERR_PTR.
2362 +- */
2363 +-static struct mm_struct *check_mem_permission(struct task_struct *task)
2364 +-{
2365 +- struct mm_struct *mm;
2366 +- int err;
2367 +-
2368 +- /*
2369 +- * Avoid racing if task exec's as we might get a new mm but validate
2370 +- * against old credentials.
2371 +- */
2372 +- err = mutex_lock_killable(&task->signal->cred_guard_mutex);
2373 +- if (err)
2374 +- return ERR_PTR(err);
2375 +-
2376 +- mm = __check_mem_permission(task);
2377 +- mutex_unlock(&task->signal->cred_guard_mutex);
2378 +-
2379 +- return mm;
2380 +-}
2381 +-
2382 +-struct mm_struct *mm_for_maps(struct task_struct *task)
2383 ++static struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)
2384 + {
2385 + struct mm_struct *mm;
2386 + int err;
2387 +@@ -263,7 +205,7 @@ struct mm_struct *mm_for_maps(struct task_struct *task)
2388 +
2389 + mm = get_task_mm(task);
2390 + if (mm && mm != current->mm &&
2391 +- !ptrace_may_access(task, PTRACE_MODE_READ)) {
2392 ++ !ptrace_may_access(task, mode)) {
2393 + mmput(mm);
2394 + mm = ERR_PTR(-EACCES);
2395 + }
2396 +@@ -272,6 +214,11 @@ struct mm_struct *mm_for_maps(struct task_struct *task)
2397 + return mm;
2398 + }
2399 +
2400 ++struct mm_struct *mm_for_maps(struct task_struct *task)
2401 ++{
2402 ++ return mm_access(task, PTRACE_MODE_READ);
2403 ++}
2404 ++
2405 + static int proc_pid_cmdline(struct task_struct *task, char * buffer)
2406 + {
2407 + int res = 0;
2408 +@@ -816,38 +763,39 @@ static const struct file_operations proc_single_file_operations = {
2409 +
2410 + static int mem_open(struct inode* inode, struct file* file)
2411 + {
2412 +- file->private_data = (void*)((long)current->self_exec_id);
2413 ++ struct task_struct *task = get_proc_task(file->f_path.dentry->d_inode);
2414 ++ struct mm_struct *mm;
2415 ++
2416 ++ if (!task)
2417 ++ return -ESRCH;
2418 ++
2419 ++ mm = mm_access(task, PTRACE_MODE_ATTACH);
2420 ++ put_task_struct(task);
2421 ++
2422 ++ if (IS_ERR(mm))
2423 ++ return PTR_ERR(mm);
2424 ++
2425 + /* OK to pass negative loff_t, we can catch out-of-range */
2426 + file->f_mode |= FMODE_UNSIGNED_OFFSET;
2427 ++ file->private_data = mm;
2428 ++
2429 + return 0;
2430 + }
2431 +
2432 + static ssize_t mem_read(struct file * file, char __user * buf,
2433 + size_t count, loff_t *ppos)
2434 + {
2435 +- struct task_struct *task = get_proc_task(file->f_path.dentry->d_inode);
2436 ++ int ret;
2437 + char *page;
2438 + unsigned long src = *ppos;
2439 +- int ret = -ESRCH;
2440 +- struct mm_struct *mm;
2441 ++ struct mm_struct *mm = file->private_data;
2442 +
2443 +- if (!task)
2444 +- goto out_no_task;
2445 ++ if (!mm)
2446 ++ return 0;
2447 +
2448 +- ret = -ENOMEM;
2449 + page = (char *)__get_free_page(GFP_TEMPORARY);
2450 + if (!page)
2451 +- goto out;
2452 +-
2453 +- mm = check_mem_permission(task);
2454 +- ret = PTR_ERR(mm);
2455 +- if (IS_ERR(mm))
2456 +- goto out_free;
2457 +-
2458 +- ret = -EIO;
2459 +-
2460 +- if (file->private_data != (void*)((long)current->self_exec_id))
2461 +- goto out_put;
2462 ++ return -ENOMEM;
2463 +
2464 + ret = 0;
2465 +
2466 +@@ -874,13 +822,7 @@ static ssize_t mem_read(struct file * file, char __user * buf,
2467 + }
2468 + *ppos = src;
2469 +
2470 +-out_put:
2471 +- mmput(mm);
2472 +-out_free:
2473 + free_page((unsigned long) page);
2474 +-out:
2475 +- put_task_struct(task);
2476 +-out_no_task:
2477 + return ret;
2478 + }
2479 +
2480 +@@ -889,27 +831,15 @@ static ssize_t mem_write(struct file * file, const char __user *buf,
2481 + {
2482 + int copied;
2483 + char *page;
2484 +- struct task_struct *task = get_proc_task(file->f_path.dentry->d_inode);
2485 + unsigned long dst = *ppos;
2486 +- struct mm_struct *mm;
2487 ++ struct mm_struct *mm = file->private_data;
2488 +
2489 +- copied = -ESRCH;
2490 +- if (!task)
2491 +- goto out_no_task;
2492 ++ if (!mm)
2493 ++ return 0;
2494 +
2495 +- copied = -ENOMEM;
2496 + page = (char *)__get_free_page(GFP_TEMPORARY);
2497 + if (!page)
2498 +- goto out_task;
2499 +-
2500 +- mm = check_mem_permission(task);
2501 +- copied = PTR_ERR(mm);
2502 +- if (IS_ERR(mm))
2503 +- goto out_free;
2504 +-
2505 +- copied = -EIO;
2506 +- if (file->private_data != (void *)((long)current->self_exec_id))
2507 +- goto out_mm;
2508 ++ return -ENOMEM;
2509 +
2510 + copied = 0;
2511 + while (count > 0) {
2512 +@@ -933,13 +863,7 @@ static ssize_t mem_write(struct file * file, const char __user *buf,
2513 + }
2514 + *ppos = dst;
2515 +
2516 +-out_mm:
2517 +- mmput(mm);
2518 +-out_free:
2519 + free_page((unsigned long) page);
2520 +-out_task:
2521 +- put_task_struct(task);
2522 +-out_no_task:
2523 + return copied;
2524 + }
2525 +
2526 +@@ -959,11 +883,20 @@ loff_t mem_lseek(struct file *file, loff_t offset, int orig)
2527 + return file->f_pos;
2528 + }
2529 +
2530 ++static int mem_release(struct inode *inode, struct file *file)
2531 ++{
2532 ++ struct mm_struct *mm = file->private_data;
2533 ++
2534 ++ mmput(mm);
2535 ++ return 0;
2536 ++}
2537 ++
2538 + static const struct file_operations proc_mem_operations = {
2539 + .llseek = mem_lseek,
2540 + .read = mem_read,
2541 + .write = mem_write,
2542 + .open = mem_open,
2543 ++ .release = mem_release,
2544 + };
2545 +
2546 + static ssize_t environ_read(struct file *file, char __user *buf,
2547 +diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
2548 +index c7d4ee6..3487b06 100644
2549 +--- a/fs/proc/task_mmu.c
2550 ++++ b/fs/proc/task_mmu.c
2551 +@@ -516,6 +516,9 @@ static int clear_refs_pte_range(pmd_t *pmd, unsigned long addr,
2552 + if (!page)
2553 + continue;
2554 +
2555 ++ if (PageReserved(page))
2556 ++ continue;
2557 ++
2558 + /* Clear accessed and referenced bits. */
2559 + ptep_test_and_clear_young(vma, addr, pte);
2560 + ClearPageReferenced(page);
2561 +diff --git a/fs/proc/uptime.c b/fs/proc/uptime.c
2562 +index 766b1d4..29166ec 100644
2563 +--- a/fs/proc/uptime.c
2564 ++++ b/fs/proc/uptime.c
2565 +@@ -11,15 +11,20 @@ static int uptime_proc_show(struct seq_file *m, void *v)
2566 + {
2567 + struct timespec uptime;
2568 + struct timespec idle;
2569 ++ cputime64_t idletime;
2570 ++ u64 nsec;
2571 ++ u32 rem;
2572 + int i;
2573 +- cputime_t idletime = cputime_zero;
2574 +
2575 ++ idletime = 0;
2576 + for_each_possible_cpu(i)
2577 + idletime = cputime64_add(idletime, kstat_cpu(i).cpustat.idle);
2578 +
2579 + do_posix_clock_monotonic_gettime(&uptime);
2580 + monotonic_to_bootbased(&uptime);
2581 +- cputime_to_timespec(idletime, &idle);
2582 ++ nsec = cputime64_to_jiffies64(idletime) * TICK_NSEC;
2583 ++ idle.tv_sec = div_u64_rem(nsec, NSEC_PER_SEC, &rem);
2584 ++ idle.tv_nsec = rem;
2585 + seq_printf(m, "%lu.%02lu %lu.%02lu\n",
2586 + (unsigned long) uptime.tv_sec,
2587 + (uptime.tv_nsec / (NSEC_PER_SEC / 100)),
2588 +diff --git a/fs/ubifs/debug.h b/fs/ubifs/debug.h
2589 +index a811ac4..fd75b63 100644
2590 +--- a/fs/ubifs/debug.h
2591 ++++ b/fs/ubifs/debug.h
2592 +@@ -121,20 +121,21 @@ const char *dbg_key_str1(const struct ubifs_info *c,
2593 + const union ubifs_key *key);
2594 +
2595 + /*
2596 +- * DBGKEY macros require @dbg_lock to be held, which it is in the dbg message
2597 +- * macros.
2598 ++ * TODO: these macros are now broken because there is no locking around them
2599 ++ * and we use a global buffer for the key string. This means that in case of
2600 ++ * concurrent execution we will end up with incorrect and messy key strings.
2601 + */
2602 + #define DBGKEY(key) dbg_key_str0(c, (key))
2603 + #define DBGKEY1(key) dbg_key_str1(c, (key))
2604 +
2605 +-#define ubifs_dbg_msg(type, fmt, ...) do { \
2606 +- spin_lock(&dbg_lock); \
2607 +- pr_debug("UBIFS DBG " type ": " fmt "\n", ##__VA_ARGS__); \
2608 +- spin_unlock(&dbg_lock); \
2609 +-} while (0)
2610 ++#define ubifs_dbg_msg(type, fmt, ...) \
2611 ++ pr_debug("UBIFS DBG " type ": " fmt "\n", ##__VA_ARGS__)
2612 +
2613 + /* Just a debugging messages not related to any specific UBIFS subsystem */
2614 +-#define dbg_msg(fmt, ...) ubifs_dbg_msg("msg", fmt, ##__VA_ARGS__)
2615 ++#define dbg_msg(fmt, ...) \
2616 ++ printk(KERN_DEBUG "UBIFS DBG (pid %d): %s: " fmt "\n", current->pid, \
2617 ++ __func__, ##__VA_ARGS__)
2618 ++
2619 + /* General messages */
2620 + #define dbg_gen(fmt, ...) ubifs_dbg_msg("gen", fmt, ##__VA_ARGS__)
2621 + /* Additional journal messages */
2622 +diff --git a/include/acpi/acpi_numa.h b/include/acpi/acpi_numa.h
2623 +index 1739726..451823c 100644
2624 +--- a/include/acpi/acpi_numa.h
2625 ++++ b/include/acpi/acpi_numa.h
2626 +@@ -15,6 +15,7 @@ extern int pxm_to_node(int);
2627 + extern int node_to_pxm(int);
2628 + extern void __acpi_map_pxm_to_node(int, int);
2629 + extern int acpi_map_pxm_to_node(int);
2630 ++extern unsigned char acpi_srat_revision;
2631 +
2632 + #endif /* CONFIG_ACPI_NUMA */
2633 + #endif /* __ACP_NUMA_H */
2634 +diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
2635 +index cd93f99..1b13021 100644
2636 +--- a/include/linux/blkdev.h
2637 ++++ b/include/linux/blkdev.h
2638 +@@ -670,6 +670,9 @@ extern int blk_insert_cloned_request(struct request_queue *q,
2639 + struct request *rq);
2640 + extern void blk_delay_queue(struct request_queue *, unsigned long);
2641 + extern void blk_recount_segments(struct request_queue *, struct bio *);
2642 ++extern int scsi_verify_blk_ioctl(struct block_device *, unsigned int);
2643 ++extern int scsi_cmd_blk_ioctl(struct block_device *, fmode_t,
2644 ++ unsigned int, void __user *);
2645 + extern int scsi_cmd_ioctl(struct request_queue *, struct gendisk *, fmode_t,
2646 + unsigned int, void __user *);
2647 + extern int sg_scsi_ioctl(struct request_queue *, struct gendisk *, fmode_t,
2648 +diff --git a/include/linux/dcache.h b/include/linux/dcache.h
2649 +index 8f848e4..f13bb6d 100644
2650 +--- a/include/linux/dcache.h
2651 ++++ b/include/linux/dcache.h
2652 +@@ -207,6 +207,7 @@ struct dentry_operations {
2653 +
2654 + #define DCACHE_CANT_MOUNT 0x0100
2655 + #define DCACHE_GENOCIDE 0x0200
2656 ++#define DCACHE_SHRINK_LIST 0x0400
2657 +
2658 + #define DCACHE_OP_HASH 0x1000
2659 + #define DCACHE_OP_COMPARE 0x2000
2660 +diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
2661 +index 50940da..313a00e 100644
2662 +--- a/include/linux/memcontrol.h
2663 ++++ b/include/linux/memcontrol.h
2664 +@@ -119,6 +119,8 @@ struct zone_reclaim_stat*
2665 + mem_cgroup_get_reclaim_stat_from_page(struct page *page);
2666 + extern void mem_cgroup_print_oom_info(struct mem_cgroup *memcg,
2667 + struct task_struct *p);
2668 ++extern void mem_cgroup_replace_page_cache(struct page *oldpage,
2669 ++ struct page *newpage);
2670 +
2671 + #ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP
2672 + extern int do_swap_account;
2673 +@@ -370,6 +372,10 @@ static inline
2674 + void mem_cgroup_count_vm_event(struct mm_struct *mm, enum vm_event_item idx)
2675 + {
2676 + }
2677 ++static inline void mem_cgroup_replace_page_cache(struct page *oldpage,
2678 ++ struct page *newpage)
2679 ++{
2680 ++}
2681 + #endif /* CONFIG_CGROUP_MEM_CONT */
2682 +
2683 + #if !defined(CONFIG_CGROUP_MEM_RES_CTLR) || !defined(CONFIG_DEBUG_VM)
2684 +diff --git a/include/linux/pci_regs.h b/include/linux/pci_regs.h
2685 +index e884096..dad7d9a 100644
2686 +--- a/include/linux/pci_regs.h
2687 ++++ b/include/linux/pci_regs.h
2688 +@@ -392,7 +392,7 @@
2689 + #define PCI_EXP_TYPE_DOWNSTREAM 0x6 /* Downstream Port */
2690 + #define PCI_EXP_TYPE_PCI_BRIDGE 0x7 /* PCI/PCI-X Bridge */
2691 + #define PCI_EXP_TYPE_RC_END 0x9 /* Root Complex Integrated Endpoint */
2692 +-#define PCI_EXP_TYPE_RC_EC 0x10 /* Root Complex Event Collector */
2693 ++#define PCI_EXP_TYPE_RC_EC 0xa /* Root Complex Event Collector */
2694 + #define PCI_EXP_FLAGS_SLOT 0x0100 /* Slot implemented */
2695 + #define PCI_EXP_FLAGS_IRQ 0x3e00 /* Interrupt message number */
2696 + #define PCI_EXP_DEVCAP 4 /* Device capabilities */
2697 +diff --git a/include/linux/sunrpc/svcsock.h b/include/linux/sunrpc/svcsock.h
2698 +index 85c50b4..c84e974 100644
2699 +--- a/include/linux/sunrpc/svcsock.h
2700 ++++ b/include/linux/sunrpc/svcsock.h
2701 +@@ -34,7 +34,7 @@ struct svc_sock {
2702 + /*
2703 + * Function prototypes.
2704 + */
2705 +-void svc_close_all(struct list_head *);
2706 ++void svc_close_all(struct svc_serv *);
2707 + int svc_recv(struct svc_rqst *, long);
2708 + int svc_send(struct svc_rqst *);
2709 + void svc_drop(struct svc_rqst *);
2710 +diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
2711 +index 8a4c309..eeeda13 100644
2712 +--- a/include/linux/videodev2.h
2713 ++++ b/include/linux/videodev2.h
2714 +@@ -1075,6 +1075,7 @@ struct v4l2_querymenu {
2715 + #define V4L2_CTRL_FLAG_NEXT_CTRL 0x80000000
2716 +
2717 + /* User-class control IDs defined by V4L2 */
2718 ++#define V4L2_CID_MAX_CTRLS 1024
2719 + #define V4L2_CID_BASE (V4L2_CTRL_CLASS_USER | 0x900)
2720 + #define V4L2_CID_USER_BASE V4L2_CID_BASE
2721 + /* IDs reserved for driver specific controls */
2722 +diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
2723 +index 561ac99..0fe6679 100644
2724 +--- a/include/target/target_core_base.h
2725 ++++ b/include/target/target_core_base.h
2726 +@@ -36,6 +36,7 @@
2727 + #define TRANSPORT_SENSE_BUFFER SCSI_SENSE_BUFFERSIZE
2728 + /* Used by transport_send_check_condition_and_sense() */
2729 + #define SPC_SENSE_KEY_OFFSET 2
2730 ++#define SPC_ADD_SENSE_LEN_OFFSET 7
2731 + #define SPC_ASC_KEY_OFFSET 12
2732 + #define SPC_ASCQ_KEY_OFFSET 13
2733 + #define TRANSPORT_IQN_LEN 224
2734 +diff --git a/include/xen/interface/io/xs_wire.h b/include/xen/interface/io/xs_wire.h
2735 +index 99fcffb..454ee26 100644
2736 +--- a/include/xen/interface/io/xs_wire.h
2737 ++++ b/include/xen/interface/io/xs_wire.h
2738 +@@ -84,4 +84,7 @@ struct xenstore_domain_interface {
2739 + XENSTORE_RING_IDX rsp_cons, rsp_prod;
2740 + };
2741 +
2742 ++/* Violating this is very bad. See docs/misc/xenstore.txt. */
2743 ++#define XENSTORE_PAYLOAD_MAX 4096
2744 ++
2745 + #endif /* _XS_WIRE_H */
2746 +diff --git a/init/do_mounts.c b/init/do_mounts.c
2747 +index c0851a8..ef6478f 100644
2748 +--- a/init/do_mounts.c
2749 ++++ b/init/do_mounts.c
2750 +@@ -360,15 +360,42 @@ out:
2751 + }
2752 +
2753 + #ifdef CONFIG_ROOT_NFS
2754 ++
2755 ++#define NFSROOT_TIMEOUT_MIN 5
2756 ++#define NFSROOT_TIMEOUT_MAX 30
2757 ++#define NFSROOT_RETRY_MAX 5
2758 ++
2759 + static int __init mount_nfs_root(void)
2760 + {
2761 + char *root_dev, *root_data;
2762 ++ unsigned int timeout;
2763 ++ int try, err;
2764 +
2765 +- if (nfs_root_data(&root_dev, &root_data) != 0)
2766 +- return 0;
2767 +- if (do_mount_root(root_dev, "nfs", root_mountflags, root_data) != 0)
2768 ++ err = nfs_root_data(&root_dev, &root_data);
2769 ++ if (err != 0)
2770 + return 0;
2771 +- return 1;
2772 ++
2773 ++ /*
2774 ++ * The server or network may not be ready, so try several
2775 ++ * times. Stop after a few tries in case the client wants
2776 ++ * to fall back to other boot methods.
2777 ++ */
2778 ++ timeout = NFSROOT_TIMEOUT_MIN;
2779 ++ for (try = 1; ; try++) {
2780 ++ err = do_mount_root(root_dev, "nfs",
2781 ++ root_mountflags, root_data);
2782 ++ if (err == 0)
2783 ++ return 1;
2784 ++ if (try > NFSROOT_RETRY_MAX)
2785 ++ break;
2786 ++
2787 ++ /* Wait, in case the server refused us immediately */
2788 ++ ssleep(timeout);
2789 ++ timeout <<= 1;
2790 ++ if (timeout > NFSROOT_TIMEOUT_MAX)
2791 ++ timeout = NFSROOT_TIMEOUT_MAX;
2792 ++ }
2793 ++ return 0;
2794 + }
2795 + #endif
2796 +
2797 +diff --git a/kernel/kprobes.c b/kernel/kprobes.c
2798 +index 7798181..e0f0bdd 100644
2799 +--- a/kernel/kprobes.c
2800 ++++ b/kernel/kprobes.c
2801 +@@ -1077,6 +1077,7 @@ void __kprobes kprobe_flush_task(struct task_struct *tk)
2802 + /* Early boot. kretprobe_table_locks not yet initialized. */
2803 + return;
2804 +
2805 ++ INIT_HLIST_HEAD(&empty_rp);
2806 + hash = hash_ptr(tk, KPROBE_HASH_BITS);
2807 + head = &kretprobe_inst_table[hash];
2808 + kretprobe_table_lock(hash, &flags);
2809 +@@ -1085,7 +1086,6 @@ void __kprobes kprobe_flush_task(struct task_struct *tk)
2810 + recycle_rp_inst(ri, &empty_rp);
2811 + }
2812 + kretprobe_table_unlock(hash, &flags);
2813 +- INIT_HLIST_HEAD(&empty_rp);
2814 + hlist_for_each_entry_safe(ri, node, tmp, &empty_rp, hlist) {
2815 + hlist_del(&ri->hlist);
2816 + kfree(ri);
2817 +diff --git a/mm/filemap.c b/mm/filemap.c
2818 +index dd828ea..3c981ba 100644
2819 +--- a/mm/filemap.c
2820 ++++ b/mm/filemap.c
2821 +@@ -396,24 +396,11 @@ EXPORT_SYMBOL(filemap_write_and_wait_range);
2822 + int replace_page_cache_page(struct page *old, struct page *new, gfp_t gfp_mask)
2823 + {
2824 + int error;
2825 +- struct mem_cgroup *memcg = NULL;
2826 +
2827 + VM_BUG_ON(!PageLocked(old));
2828 + VM_BUG_ON(!PageLocked(new));
2829 + VM_BUG_ON(new->mapping);
2830 +
2831 +- /*
2832 +- * This is not page migration, but prepare_migration and
2833 +- * end_migration does enough work for charge replacement.
2834 +- *
2835 +- * In the longer term we probably want a specialized function
2836 +- * for moving the charge from old to new in a more efficient
2837 +- * manner.
2838 +- */
2839 +- error = mem_cgroup_prepare_migration(old, new, &memcg, gfp_mask);
2840 +- if (error)
2841 +- return error;
2842 +-
2843 + error = radix_tree_preload(gfp_mask & ~__GFP_HIGHMEM);
2844 + if (!error) {
2845 + struct address_space *mapping = old->mapping;
2846 +@@ -435,13 +422,12 @@ int replace_page_cache_page(struct page *old, struct page *new, gfp_t gfp_mask)
2847 + if (PageSwapBacked(new))
2848 + __inc_zone_page_state(new, NR_SHMEM);
2849 + spin_unlock_irq(&mapping->tree_lock);
2850 ++ /* mem_cgroup codes must not be called under tree_lock */
2851 ++ mem_cgroup_replace_page_cache(old, new);
2852 + radix_tree_preload_end();
2853 + if (freepage)
2854 + freepage(old);
2855 + page_cache_release(old);
2856 +- mem_cgroup_end_migration(memcg, old, new, true);
2857 +- } else {
2858 +- mem_cgroup_end_migration(memcg, old, new, false);
2859 + }
2860 +
2861 + return error;
2862 +diff --git a/mm/memcontrol.c b/mm/memcontrol.c
2863 +index d99217b..3791581 100644
2864 +--- a/mm/memcontrol.c
2865 ++++ b/mm/memcontrol.c
2866 +@@ -3422,6 +3422,50 @@ int mem_cgroup_shmem_charge_fallback(struct page *page,
2867 + return ret;
2868 + }
2869 +
2870 ++/*
2871 ++ * At replace page cache, newpage is not under any memcg but it's on
2872 ++ * LRU. So, this function doesn't touch res_counter but handles LRU
2873 ++ * in correct way. Both pages are locked so we cannot race with uncharge.
2874 ++ */
2875 ++void mem_cgroup_replace_page_cache(struct page *oldpage,
2876 ++ struct page *newpage)
2877 ++{
2878 ++ struct mem_cgroup *memcg;
2879 ++ struct page_cgroup *pc;
2880 ++ struct zone *zone;
2881 ++ enum charge_type type = MEM_CGROUP_CHARGE_TYPE_CACHE;
2882 ++ unsigned long flags;
2883 ++
2884 ++ if (mem_cgroup_disabled())
2885 ++ return;
2886 ++
2887 ++ pc = lookup_page_cgroup(oldpage);
2888 ++ /* fix accounting on old pages */
2889 ++ lock_page_cgroup(pc);
2890 ++ memcg = pc->mem_cgroup;
2891 ++ mem_cgroup_charge_statistics(memcg, PageCgroupCache(pc), -1);
2892 ++ ClearPageCgroupUsed(pc);
2893 ++ unlock_page_cgroup(pc);
2894 ++
2895 ++ if (PageSwapBacked(oldpage))
2896 ++ type = MEM_CGROUP_CHARGE_TYPE_SHMEM;
2897 ++
2898 ++ zone = page_zone(newpage);
2899 ++ pc = lookup_page_cgroup(newpage);
2900 ++ /*
2901 ++ * Even if newpage->mapping was NULL before starting replacement,
2902 ++ * the newpage may be on LRU(or pagevec for LRU) already. We lock
2903 ++ * LRU while we overwrite pc->mem_cgroup.
2904 ++ */
2905 ++ spin_lock_irqsave(&zone->lru_lock, flags);
2906 ++ if (PageLRU(newpage))
2907 ++ del_page_from_lru_list(zone, newpage, page_lru(newpage));
2908 ++ __mem_cgroup_commit_charge(memcg, newpage, 1, pc, type);
2909 ++ if (PageLRU(newpage))
2910 ++ add_page_to_lru_list(zone, newpage, page_lru(newpage));
2911 ++ spin_unlock_irqrestore(&zone->lru_lock, flags);
2912 ++}
2913 ++
2914 + #ifdef CONFIG_DEBUG_VM
2915 + static struct page_cgroup *lookup_page_cgroup_used(struct page *page)
2916 + {
2917 +diff --git a/mm/page_alloc.c b/mm/page_alloc.c
2918 +index 8439d2a..947a7e9 100644
2919 +--- a/mm/page_alloc.c
2920 ++++ b/mm/page_alloc.c
2921 +@@ -5565,6 +5565,17 @@ __count_immobile_pages(struct zone *zone, struct page *page, int count)
2922 + bool is_pageblock_removable_nolock(struct page *page)
2923 + {
2924 + struct zone *zone = page_zone(page);
2925 ++ unsigned long pfn = page_to_pfn(page);
2926 ++
2927 ++ /*
2928 ++ * We have to be careful here because we are iterating over memory
2929 ++ * sections which are not zone aware so we might end up outside of
2930 ++ * the zone but still within the section.
2931 ++ */
2932 ++ if (!zone || zone->zone_start_pfn > pfn ||
2933 ++ zone->zone_start_pfn + zone->spanned_pages <= pfn)
2934 ++ return false;
2935 ++
2936 + return __count_immobile_pages(zone, page, 0);
2937 + }
2938 +
2939 +diff --git a/net/ipv4/ah4.c b/net/ipv4/ah4.c
2940 +index c1f4154..c7056b2 100644
2941 +--- a/net/ipv4/ah4.c
2942 ++++ b/net/ipv4/ah4.c
2943 +@@ -136,8 +136,6 @@ static void ah_output_done(struct crypto_async_request *base, int err)
2944 + memcpy(top_iph+1, iph+1, top_iph->ihl*4 - sizeof(struct iphdr));
2945 + }
2946 +
2947 +- err = ah->nexthdr;
2948 +-
2949 + kfree(AH_SKB_CB(skb)->tmp);
2950 + xfrm_output_resume(skb, err);
2951 + }
2952 +@@ -264,12 +262,12 @@ static void ah_input_done(struct crypto_async_request *base, int err)
2953 + if (err)
2954 + goto out;
2955 +
2956 ++ err = ah->nexthdr;
2957 ++
2958 + skb->network_header += ah_hlen;
2959 + memcpy(skb_network_header(skb), work_iph, ihl);
2960 + __skb_pull(skb, ah_hlen + ihl);
2961 + skb_set_transport_header(skb, -ihl);
2962 +-
2963 +- err = ah->nexthdr;
2964 + out:
2965 + kfree(AH_SKB_CB(skb)->tmp);
2966 + xfrm_input_resume(skb, err);
2967 +diff --git a/net/ipv6/ah6.c b/net/ipv6/ah6.c
2968 +index 2195ae6..7a33aaa 100644
2969 +--- a/net/ipv6/ah6.c
2970 ++++ b/net/ipv6/ah6.c
2971 +@@ -324,8 +324,6 @@ static void ah6_output_done(struct crypto_async_request *base, int err)
2972 + #endif
2973 + }
2974 +
2975 +- err = ah->nexthdr;
2976 +-
2977 + kfree(AH_SKB_CB(skb)->tmp);
2978 + xfrm_output_resume(skb, err);
2979 + }
2980 +@@ -466,12 +464,12 @@ static void ah6_input_done(struct crypto_async_request *base, int err)
2981 + if (err)
2982 + goto out;
2983 +
2984 ++ err = ah->nexthdr;
2985 ++
2986 + skb->network_header += ah_hlen;
2987 + memcpy(skb_network_header(skb), work_iph, hdr_len);
2988 + __skb_pull(skb, ah_hlen + hdr_len);
2989 + skb_set_transport_header(skb, -hdr_len);
2990 +-
2991 +- err = ah->nexthdr;
2992 + out:
2993 + kfree(AH_SKB_CB(skb)->tmp);
2994 + xfrm_input_resume(skb, err);
2995 +diff --git a/net/mac80211/wpa.c b/net/mac80211/wpa.c
2996 +index 8f6a302..aa1c40a 100644
2997 +--- a/net/mac80211/wpa.c
2998 ++++ b/net/mac80211/wpa.c
2999 +@@ -109,7 +109,7 @@ ieee80211_rx_h_michael_mic_verify(struct ieee80211_rx_data *rx)
3000 + if (status->flag & RX_FLAG_MMIC_ERROR)
3001 + goto mic_fail;
3002 +
3003 +- if (!(status->flag & RX_FLAG_IV_STRIPPED))
3004 ++ if (!(status->flag & RX_FLAG_IV_STRIPPED) && rx->key)
3005 + goto update_iv;
3006 +
3007 + return RX_CONTINUE;
3008 +diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
3009 +index 2b90292..ce5f111 100644
3010 +--- a/net/sunrpc/svc.c
3011 ++++ b/net/sunrpc/svc.c
3012 +@@ -167,6 +167,7 @@ svc_pool_map_alloc_arrays(struct svc_pool_map *m, unsigned int maxpools)
3013 +
3014 + fail_free:
3015 + kfree(m->to_pool);
3016 ++ m->to_pool = NULL;
3017 + fail:
3018 + return -ENOMEM;
3019 + }
3020 +@@ -287,7 +288,9 @@ svc_pool_map_put(void)
3021 + if (!--m->count) {
3022 + m->mode = SVC_POOL_DEFAULT;
3023 + kfree(m->to_pool);
3024 ++ m->to_pool = NULL;
3025 + kfree(m->pool_to);
3026 ++ m->pool_to = NULL;
3027 + m->npools = 0;
3028 + }
3029 +
3030 +@@ -472,17 +475,20 @@ svc_destroy(struct svc_serv *serv)
3031 + printk("svc_destroy: no threads for serv=%p!\n", serv);
3032 +
3033 + del_timer_sync(&serv->sv_temptimer);
3034 +-
3035 +- svc_close_all(&serv->sv_tempsocks);
3036 ++ /*
3037 ++ * The set of xprts (contained in the sv_tempsocks and
3038 ++ * sv_permsocks lists) is now constant, since it is modified
3039 ++ * only by accepting new sockets (done by service threads in
3040 ++ * svc_recv) or aging old ones (done by sv_temptimer), or
3041 ++ * configuration changes (excluded by whatever locking the
3042 ++ * caller is using--nfsd_mutex in the case of nfsd). So it's
3043 ++ * safe to traverse those lists and shut everything down:
3044 ++ */
3045 ++ svc_close_all(serv);
3046 +
3047 + if (serv->sv_shutdown)
3048 + serv->sv_shutdown(serv);
3049 +
3050 +- svc_close_all(&serv->sv_permsocks);
3051 +-
3052 +- BUG_ON(!list_empty(&serv->sv_permsocks));
3053 +- BUG_ON(!list_empty(&serv->sv_tempsocks));
3054 +-
3055 + cache_clean_deferred(serv);
3056 +
3057 + if (svc_serv_is_pooled(serv))
3058 +diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c
3059 +index bd31208..9d7ed0b 100644
3060 +--- a/net/sunrpc/svc_xprt.c
3061 ++++ b/net/sunrpc/svc_xprt.c
3062 +@@ -901,14 +901,7 @@ void svc_delete_xprt(struct svc_xprt *xprt)
3063 + spin_lock_bh(&serv->sv_lock);
3064 + if (!test_and_set_bit(XPT_DETACHED, &xprt->xpt_flags))
3065 + list_del_init(&xprt->xpt_list);
3066 +- /*
3067 +- * The only time we're called while xpt_ready is still on a list
3068 +- * is while the list itself is about to be destroyed (in
3069 +- * svc_destroy). BUT svc_xprt_enqueue could still be attempting
3070 +- * to add new entries to the sp_sockets list, so we can't leave
3071 +- * a freed xprt on it.
3072 +- */
3073 +- list_del_init(&xprt->xpt_ready);
3074 ++ BUG_ON(!list_empty(&xprt->xpt_ready));
3075 + if (test_bit(XPT_TEMP, &xprt->xpt_flags))
3076 + serv->sv_tmpcnt--;
3077 + spin_unlock_bh(&serv->sv_lock);
3078 +@@ -936,22 +929,48 @@ void svc_close_xprt(struct svc_xprt *xprt)
3079 + }
3080 + EXPORT_SYMBOL_GPL(svc_close_xprt);
3081 +
3082 +-void svc_close_all(struct list_head *xprt_list)
3083 ++static void svc_close_list(struct list_head *xprt_list)
3084 ++{
3085 ++ struct svc_xprt *xprt;
3086 ++
3087 ++ list_for_each_entry(xprt, xprt_list, xpt_list) {
3088 ++ set_bit(XPT_CLOSE, &xprt->xpt_flags);
3089 ++ set_bit(XPT_BUSY, &xprt->xpt_flags);
3090 ++ }
3091 ++}
3092 ++
3093 ++void svc_close_all(struct svc_serv *serv)
3094 + {
3095 ++ struct svc_pool *pool;
3096 + struct svc_xprt *xprt;
3097 + struct svc_xprt *tmp;
3098 ++ int i;
3099 ++
3100 ++ svc_close_list(&serv->sv_tempsocks);
3101 ++ svc_close_list(&serv->sv_permsocks);
3102 +
3103 ++ for (i = 0; i < serv->sv_nrpools; i++) {
3104 ++ pool = &serv->sv_pools[i];
3105 ++
3106 ++ spin_lock_bh(&pool->sp_lock);
3107 ++ while (!list_empty(&pool->sp_sockets)) {
3108 ++ xprt = list_first_entry(&pool->sp_sockets, struct svc_xprt, xpt_ready);
3109 ++ list_del_init(&xprt->xpt_ready);
3110 ++ }
3111 ++ spin_unlock_bh(&pool->sp_lock);
3112 ++ }
3113 + /*
3114 +- * The server is shutting down, and no more threads are running.
3115 +- * svc_xprt_enqueue() might still be running, but at worst it
3116 +- * will re-add the xprt to sp_sockets, which will soon get
3117 +- * freed. So we don't bother with any more locking, and don't
3118 +- * leave the close to the (nonexistent) server threads:
3119 ++ * At this point the sp_sockets lists will stay empty, since
3120 ++ * svc_enqueue will not add new entries without taking the
3121 ++ * sp_lock and checking XPT_BUSY.
3122 + */
3123 +- list_for_each_entry_safe(xprt, tmp, xprt_list, xpt_list) {
3124 +- set_bit(XPT_CLOSE, &xprt->xpt_flags);
3125 ++ list_for_each_entry_safe(xprt, tmp, &serv->sv_tempsocks, xpt_list)
3126 + svc_delete_xprt(xprt);
3127 +- }
3128 ++ list_for_each_entry_safe(xprt, tmp, &serv->sv_permsocks, xpt_list)
3129 ++ svc_delete_xprt(xprt);
3130 ++
3131 ++ BUG_ON(!list_empty(&serv->sv_permsocks));
3132 ++ BUG_ON(!list_empty(&serv->sv_tempsocks));
3133 + }
3134 +
3135 + /*
3136 +diff --git a/scripts/kconfig/streamline_config.pl b/scripts/kconfig/streamline_config.pl
3137 +index a4fe923..25f1e71 100644
3138 +--- a/scripts/kconfig/streamline_config.pl
3139 ++++ b/scripts/kconfig/streamline_config.pl
3140 +@@ -242,33 +242,61 @@ if ($kconfig) {
3141 + read_kconfig($kconfig);
3142 + }
3143 +
3144 ++sub convert_vars {
3145 ++ my ($line, %vars) = @_;
3146 ++
3147 ++ my $process = "";
3148 ++
3149 ++ while ($line =~ s/^(.*?)(\$\((.*?)\))//) {
3150 ++ my $start = $1;
3151 ++ my $variable = $2;
3152 ++ my $var = $3;
3153 ++
3154 ++ if (defined($vars{$var})) {
3155 ++ $process .= $start . $vars{$var};
3156 ++ } else {
3157 ++ $process .= $start . $variable;
3158 ++ }
3159 ++ }
3160 ++
3161 ++ $process .= $line;
3162 ++
3163 ++ return $process;
3164 ++}
3165 ++
3166 + # Read all Makefiles to map the configs to the objects
3167 + foreach my $makefile (@makefiles) {
3168 +
3169 +- my $cont = 0;
3170 ++ my $line = "";
3171 ++ my %make_vars;
3172 +
3173 + open(MIN,$makefile) || die "Can't open $makefile";
3174 + while (<MIN>) {
3175 ++ # if this line ends with a backslash, continue
3176 ++ chomp;
3177 ++ if (/^(.*)\\$/) {
3178 ++ $line .= $1;
3179 ++ next;
3180 ++ }
3181 ++
3182 ++ $line .= $_;
3183 ++ $_ = $line;
3184 ++ $line = "";
3185 ++
3186 + my $objs;
3187 +
3188 +- # is this a line after a line with a backslash?
3189 +- if ($cont && /(\S.*)$/) {
3190 +- $objs = $1;
3191 +- }
3192 +- $cont = 0;
3193 ++ $_ = convert_vars($_, %make_vars);
3194 +
3195 + # collect objects after obj-$(CONFIG_FOO_BAR)
3196 + if (/obj-\$\((CONFIG_[^\)]*)\)\s*[+:]?=\s*(.*)/) {
3197 + $var = $1;
3198 + $objs = $2;
3199 ++
3200 ++ # check if variables are set
3201 ++ } elsif (/^\s*(\S+)\s*[:]?=\s*(.*\S)/) {
3202 ++ $make_vars{$1} = $2;
3203 + }
3204 + if (defined($objs)) {
3205 +- # test if the line ends with a backslash
3206 +- if ($objs =~ m,(.*)\\$,) {
3207 +- $objs = $1;
3208 +- $cont = 1;
3209 +- }
3210 +-
3211 + foreach my $obj (split /\s+/,$objs) {
3212 + $obj =~ s/-/_/g;
3213 + if ($obj =~ /(.*)\.o$/) {
3214 +diff --git a/scripts/recordmcount.h b/scripts/recordmcount.h
3215 +index f40a6af6..54e35c1 100644
3216 +--- a/scripts/recordmcount.h
3217 ++++ b/scripts/recordmcount.h
3218 +@@ -462,7 +462,7 @@ __has_rel_mcount(Elf_Shdr const *const relhdr, /* is SHT_REL or SHT_RELA */
3219 + succeed_file();
3220 + }
3221 + if (w(txthdr->sh_type) != SHT_PROGBITS ||
3222 +- !(w(txthdr->sh_flags) & SHF_EXECINSTR))
3223 ++ !(_w(txthdr->sh_flags) & SHF_EXECINSTR))
3224 + return NULL;
3225 + return txtname;
3226 + }
3227 +diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
3228 +index da36d2c..5335605 100644
3229 +--- a/security/integrity/ima/ima_api.c
3230 ++++ b/security/integrity/ima/ima_api.c
3231 +@@ -177,8 +177,8 @@ void ima_store_measurement(struct ima_iint_cache *iint, struct file *file,
3232 + strncpy(entry->template.file_name, filename, IMA_EVENT_NAME_LEN_MAX);
3233 +
3234 + result = ima_store_template(entry, violation, inode);
3235 +- if (!result)
3236 ++ if (!result || result == -EEXIST)
3237 + iint->flags |= IMA_MEASURED;
3238 +- else
3239 ++ if (result < 0)
3240 + kfree(entry);
3241 + }
3242 +diff --git a/security/integrity/ima/ima_queue.c b/security/integrity/ima/ima_queue.c
3243 +index 8e28f04..55a6271 100644
3244 +--- a/security/integrity/ima/ima_queue.c
3245 ++++ b/security/integrity/ima/ima_queue.c
3246 +@@ -23,6 +23,8 @@
3247 + #include <linux/slab.h>
3248 + #include "ima.h"
3249 +
3250 ++#define AUDIT_CAUSE_LEN_MAX 32
3251 ++
3252 + LIST_HEAD(ima_measurements); /* list of all measurements */
3253 +
3254 + /* key: inode (before secure-hashing a file) */
3255 +@@ -94,7 +96,8 @@ static int ima_pcr_extend(const u8 *hash)
3256 +
3257 + result = tpm_pcr_extend(TPM_ANY_NUM, CONFIG_IMA_MEASURE_PCR_IDX, hash);
3258 + if (result != 0)
3259 +- pr_err("IMA: Error Communicating to TPM chip\n");
3260 ++ pr_err("IMA: Error Communicating to TPM chip, result: %d\n",
3261 ++ result);
3262 + return result;
3263 + }
3264 +
3265 +@@ -106,14 +109,16 @@ int ima_add_template_entry(struct ima_template_entry *entry, int violation,
3266 + {
3267 + u8 digest[IMA_DIGEST_SIZE];
3268 + const char *audit_cause = "hash_added";
3269 ++ char tpm_audit_cause[AUDIT_CAUSE_LEN_MAX];
3270 + int audit_info = 1;
3271 +- int result = 0;
3272 ++ int result = 0, tpmresult = 0;
3273 +
3274 + mutex_lock(&ima_extend_list_mutex);
3275 + if (!violation) {
3276 + memcpy(digest, entry->digest, sizeof digest);
3277 + if (ima_lookup_digest_entry(digest)) {
3278 + audit_cause = "hash_exists";
3279 ++ result = -EEXIST;
3280 + goto out;
3281 + }
3282 + }
3283 +@@ -128,9 +133,11 @@ int ima_add_template_entry(struct ima_template_entry *entry, int violation,
3284 + if (violation) /* invalidate pcr */
3285 + memset(digest, 0xff, sizeof digest);
3286 +
3287 +- result = ima_pcr_extend(digest);
3288 +- if (result != 0) {
3289 +- audit_cause = "TPM error";
3290 ++ tpmresult = ima_pcr_extend(digest);
3291 ++ if (tpmresult != 0) {
3292 ++ snprintf(tpm_audit_cause, AUDIT_CAUSE_LEN_MAX, "TPM_error(%d)",
3293 ++ tpmresult);
3294 ++ audit_cause = tpm_audit_cause;
3295 + audit_info = 0;
3296 + }
3297 + out:
3298 +diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h
3299 +index 08ec073..e289a13 100644
3300 +--- a/sound/pci/hda/hda_local.h
3301 ++++ b/sound/pci/hda/hda_local.h
3302 +@@ -474,7 +474,12 @@ static inline u32 get_wcaps(struct hda_codec *codec, hda_nid_t nid)
3303 + }
3304 +
3305 + /* get the widget type from widget capability bits */
3306 +-#define get_wcaps_type(wcaps) (((wcaps) & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT)
3307 ++static inline int get_wcaps_type(unsigned int wcaps)
3308 ++{
3309 ++ if (!wcaps)
3310 ++ return -1; /* invalid type */
3311 ++ return (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
3312 ++}
3313 +
3314 + static inline unsigned int get_wcaps_channels(u32 wcaps)
3315 + {
3316 +diff --git a/sound/pci/hda/hda_proc.c b/sound/pci/hda/hda_proc.c
3317 +index bfe74c2..6fe944a 100644
3318 +--- a/sound/pci/hda/hda_proc.c
3319 ++++ b/sound/pci/hda/hda_proc.c
3320 +@@ -54,6 +54,8 @@ static const char *get_wid_type_name(unsigned int wid_value)
3321 + [AC_WID_BEEP] = "Beep Generator Widget",
3322 + [AC_WID_VENDOR] = "Vendor Defined Widget",
3323 + };
3324 ++ if (wid_value == -1)
3325 ++ return "UNKNOWN Widget";
3326 + wid_value &= 0xf;
3327 + if (names[wid_value])
3328 + return names[wid_value];
3329 +diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
3330 +index 5d2e97a..0d8db75 100644
3331 +--- a/sound/pci/hda/patch_sigmatel.c
3332 ++++ b/sound/pci/hda/patch_sigmatel.c
3333 +@@ -1602,7 +1602,7 @@ static const struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
3334 + SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02bd,
3335 + "Dell Studio 1557", STAC_DELL_M6_DMIC),
3336 + SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02fe,
3337 +- "Dell Studio XPS 1645", STAC_DELL_M6_BOTH),
3338 ++ "Dell Studio XPS 1645", STAC_DELL_M6_DMIC),
3339 + SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0413,
3340 + "Dell Studio 1558", STAC_DELL_M6_DMIC),
3341 + {} /* terminator */
3342 +diff --git a/sound/pci/ice1712/amp.c b/sound/pci/ice1712/amp.c
3343 +index e328cfb..e525da2 100644
3344 +--- a/sound/pci/ice1712/amp.c
3345 ++++ b/sound/pci/ice1712/amp.c
3346 +@@ -68,8 +68,11 @@ static int __devinit snd_vt1724_amp_init(struct snd_ice1712 *ice)
3347 +
3348 + static int __devinit snd_vt1724_amp_add_controls(struct snd_ice1712 *ice)
3349 + {
3350 +- /* we use pins 39 and 41 of the VT1616 for left and right read outputs */
3351 +- snd_ac97_write_cache(ice->ac97, 0x5a, snd_ac97_read(ice->ac97, 0x5a) & ~0x8000);
3352 ++ if (ice->ac97)
3353 ++ /* we use pins 39 and 41 of the VT1616 for left and right
3354 ++ read outputs */
3355 ++ snd_ac97_write_cache(ice->ac97, 0x5a,
3356 ++ snd_ac97_read(ice->ac97, 0x5a) & ~0x8000);
3357 + return 0;
3358 + }
3359 +
3360 +diff --git a/sound/pci/oxygen/xonar_wm87x6.c b/sound/pci/oxygen/xonar_wm87x6.c
3361 +index 42d1ab1..915546a 100644
3362 +--- a/sound/pci/oxygen/xonar_wm87x6.c
3363 ++++ b/sound/pci/oxygen/xonar_wm87x6.c
3364 +@@ -177,6 +177,7 @@ static void wm8776_registers_init(struct oxygen *chip)
3365 + struct xonar_wm87x6 *data = chip->model_data;
3366 +
3367 + wm8776_write(chip, WM8776_RESET, 0);
3368 ++ wm8776_write(chip, WM8776_PHASESWAP, WM8776_PH_MASK);
3369 + wm8776_write(chip, WM8776_DACCTRL1, WM8776_DZCEN |
3370 + WM8776_PL_LEFT_LEFT | WM8776_PL_RIGHT_RIGHT);
3371 + wm8776_write(chip, WM8776_DACMUTE, chip->dac_mute ? WM8776_DMUTE : 0);
3372 +diff --git a/sound/usb/usx2y/usb_stream.c b/sound/usb/usx2y/usb_stream.c
3373 +index c400ade..1e7a47a 100644
3374 +--- a/sound/usb/usx2y/usb_stream.c
3375 ++++ b/sound/usb/usx2y/usb_stream.c
3376 +@@ -674,7 +674,7 @@ dotry:
3377 + inurb->transfer_buffer_length =
3378 + inurb->number_of_packets *
3379 + inurb->iso_frame_desc[0].length;
3380 +- preempt_disable();
3381 ++
3382 + if (u == 0) {
3383 + int now;
3384 + struct usb_device *dev = inurb->dev;
3385 +@@ -686,19 +686,17 @@ dotry:
3386 + }
3387 + err = usb_submit_urb(inurb, GFP_ATOMIC);
3388 + if (err < 0) {
3389 +- preempt_enable();
3390 + snd_printk(KERN_ERR"usb_submit_urb(sk->inurb[%i])"
3391 + " returned %i\n", u, err);
3392 + return err;
3393 + }
3394 + err = usb_submit_urb(outurb, GFP_ATOMIC);
3395 + if (err < 0) {
3396 +- preempt_enable();
3397 + snd_printk(KERN_ERR"usb_submit_urb(sk->outurb[%i])"
3398 + " returned %i\n", u, err);
3399 + return err;
3400 + }
3401 +- preempt_enable();
3402 ++
3403 + if (inurb->start_frame != outurb->start_frame) {
3404 + snd_printd(KERN_DEBUG
3405 + "u[%i] start_frames differ in:%u out:%u\n",
3406
3407 Added: genpatches-2.6/trunk/3.0/1018_linux-3.0.19.patch
3408 ===================================================================
3409 --- genpatches-2.6/trunk/3.0/1018_linux-3.0.19.patch (rev 0)
3410 +++ genpatches-2.6/trunk/3.0/1018_linux-3.0.19.patch 2012-02-07 14:13:03 UTC (rev 2084)
3411 @@ -0,0 +1,2220 @@
3412 +diff --git a/Makefile b/Makefile
3413 +index 581b8e9..1e57901 100644
3414 +--- a/Makefile
3415 ++++ b/Makefile
3416 +@@ -1,6 +1,6 @@
3417 + VERSION = 3
3418 + PATCHLEVEL = 0
3419 +-SUBLEVEL = 18
3420 ++SUBLEVEL = 19
3421 + EXTRAVERSION =
3422 + NAME = Sneaky Weasel
3423 +
3424 +diff --git a/arch/arm/mach-ux500/Kconfig b/arch/arm/mach-ux500/Kconfig
3425 +index 9a9706c..6ebdb0d 100644
3426 +--- a/arch/arm/mach-ux500/Kconfig
3427 ++++ b/arch/arm/mach-ux500/Kconfig
3428 +@@ -7,6 +7,7 @@ config UX500_SOC_COMMON
3429 + select HAS_MTU
3430 + select ARM_ERRATA_753970
3431 + select ARM_ERRATA_754322
3432 ++ select ARM_ERRATA_764369
3433 +
3434 + menu "Ux500 SoC"
3435 +
3436 +diff --git a/arch/arm/mm/proc-v7.S b/arch/arm/mm/proc-v7.S
3437 +index 089c0b5..b6ba103 100644
3438 +--- a/arch/arm/mm/proc-v7.S
3439 ++++ b/arch/arm/mm/proc-v7.S
3440 +@@ -270,10 +270,6 @@ cpu_resume_l1_flags:
3441 + * Initialise TLB, Caches, and MMU state ready to switch the MMU
3442 + * on. Return in r0 the new CP15 C1 control register setting.
3443 + *
3444 +- * We automatically detect if we have a Harvard cache, and use the
3445 +- * Harvard cache control instructions insead of the unified cache
3446 +- * control instructions.
3447 +- *
3448 + * This should be able to cover all ARMv7 cores.
3449 + *
3450 + * It is assumed that:
3451 +@@ -363,9 +359,7 @@ __v7_setup:
3452 + #endif
3453 +
3454 + 3: mov r10, #0
3455 +-#ifdef HARVARD_CACHE
3456 + mcr p15, 0, r10, c7, c5, 0 @ I+BTB cache invalidate
3457 +-#endif
3458 + dsb
3459 + #ifdef CONFIG_MMU
3460 + mcr p15, 0, r10, c8, c7, 0 @ invalidate I + D TLBs
3461 +diff --git a/arch/x86/include/asm/uv/uv_hub.h b/arch/x86/include/asm/uv/uv_hub.h
3462 +index 54a13aa..21f7385 100644
3463 +--- a/arch/x86/include/asm/uv/uv_hub.h
3464 ++++ b/arch/x86/include/asm/uv/uv_hub.h
3465 +@@ -318,13 +318,13 @@ uv_gpa_in_mmr_space(unsigned long gpa)
3466 + /* UV global physical address --> socket phys RAM */
3467 + static inline unsigned long uv_gpa_to_soc_phys_ram(unsigned long gpa)
3468 + {
3469 +- unsigned long paddr = gpa & uv_hub_info->gpa_mask;
3470 ++ unsigned long paddr;
3471 + unsigned long remap_base = uv_hub_info->lowmem_remap_base;
3472 + unsigned long remap_top = uv_hub_info->lowmem_remap_top;
3473 +
3474 + gpa = ((gpa << uv_hub_info->m_shift) >> uv_hub_info->m_shift) |
3475 + ((gpa >> uv_hub_info->n_lshift) << uv_hub_info->m_val);
3476 +- gpa = gpa & uv_hub_info->gpa_mask;
3477 ++ paddr = gpa & uv_hub_info->gpa_mask;
3478 + if (paddr >= remap_base && paddr < remap_base + remap_top)
3479 + paddr -= remap_base;
3480 + return paddr;
3481 +diff --git a/arch/x86/kernel/microcode_amd.c b/arch/x86/kernel/microcode_amd.c
3482 +index c561038..b727450 100644
3483 +--- a/arch/x86/kernel/microcode_amd.c
3484 ++++ b/arch/x86/kernel/microcode_amd.c
3485 +@@ -298,13 +298,33 @@ free_table:
3486 + return state;
3487 + }
3488 +
3489 ++/*
3490 ++ * AMD microcode firmware naming convention, up to family 15h they are in
3491 ++ * the legacy file:
3492 ++ *
3493 ++ * amd-ucode/microcode_amd.bin
3494 ++ *
3495 ++ * This legacy file is always smaller than 2K in size.
3496 ++ *
3497 ++ * Starting at family 15h they are in family specific firmware files:
3498 ++ *
3499 ++ * amd-ucode/microcode_amd_fam15h.bin
3500 ++ * amd-ucode/microcode_amd_fam16h.bin
3501 ++ * ...
3502 ++ *
3503 ++ * These might be larger than 2K.
3504 ++ */
3505 + static enum ucode_state request_microcode_amd(int cpu, struct device *device)
3506 + {
3507 +- const char *fw_name = "amd-ucode/microcode_amd.bin";
3508 ++ char fw_name[36] = "amd-ucode/microcode_amd.bin";
3509 + const struct firmware *fw;
3510 + enum ucode_state ret = UCODE_NFOUND;
3511 ++ struct cpuinfo_x86 *c = &cpu_data(cpu);
3512 ++
3513 ++ if (c->x86 >= 0x15)
3514 ++ snprintf(fw_name, sizeof(fw_name), "amd-ucode/microcode_amd_fam%.2xh.bin", c->x86);
3515 +
3516 +- if (request_firmware(&fw, fw_name, device)) {
3517 ++ if (request_firmware(&fw, (const char *)fw_name, device)) {
3518 + pr_err("failed to load file %s\n", fw_name);
3519 + goto out;
3520 + }
3521 +diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
3522 +index 7b65f75..7c1b765 100644
3523 +--- a/arch/x86/net/bpf_jit_comp.c
3524 ++++ b/arch/x86/net/bpf_jit_comp.c
3525 +@@ -151,17 +151,18 @@ void bpf_jit_compile(struct sk_filter *fp)
3526 + cleanup_addr = proglen; /* epilogue address */
3527 +
3528 + for (pass = 0; pass < 10; pass++) {
3529 ++ u8 seen_or_pass0 = (pass == 0) ? (SEEN_XREG | SEEN_DATAREF | SEEN_MEM) : seen;
3530 + /* no prologue/epilogue for trivial filters (RET something) */
3531 + proglen = 0;
3532 + prog = temp;
3533 +
3534 +- if (seen) {
3535 ++ if (seen_or_pass0) {
3536 + EMIT4(0x55, 0x48, 0x89, 0xe5); /* push %rbp; mov %rsp,%rbp */
3537 + EMIT4(0x48, 0x83, 0xec, 96); /* subq $96,%rsp */
3538 + /* note : must save %rbx in case bpf_error is hit */
3539 +- if (seen & (SEEN_XREG | SEEN_DATAREF))
3540 ++ if (seen_or_pass0 & (SEEN_XREG | SEEN_DATAREF))
3541 + EMIT4(0x48, 0x89, 0x5d, 0xf8); /* mov %rbx, -8(%rbp) */
3542 +- if (seen & SEEN_XREG)
3543 ++ if (seen_or_pass0 & SEEN_XREG)
3544 + CLEAR_X(); /* make sure we dont leek kernel memory */
3545 +
3546 + /*
3547 +@@ -170,7 +171,7 @@ void bpf_jit_compile(struct sk_filter *fp)
3548 + * r9 = skb->len - skb->data_len
3549 + * r8 = skb->data
3550 + */
3551 +- if (seen & SEEN_DATAREF) {
3552 ++ if (seen_or_pass0 & SEEN_DATAREF) {
3553 + if (offsetof(struct sk_buff, len) <= 127)
3554 + /* mov off8(%rdi),%r9d */
3555 + EMIT4(0x44, 0x8b, 0x4f, offsetof(struct sk_buff, len));
3556 +@@ -260,9 +261,14 @@ void bpf_jit_compile(struct sk_filter *fp)
3557 + case BPF_S_ALU_DIV_X: /* A /= X; */
3558 + seen |= SEEN_XREG;
3559 + EMIT2(0x85, 0xdb); /* test %ebx,%ebx */
3560 +- if (pc_ret0 != -1)
3561 +- EMIT_COND_JMP(X86_JE, addrs[pc_ret0] - (addrs[i] - 4));
3562 +- else {
3563 ++ if (pc_ret0 > 0) {
3564 ++ /* addrs[pc_ret0 - 1] is start address of target
3565 ++ * (addrs[i] - 4) is the address following this jmp
3566 ++ * ("xor %edx,%edx; div %ebx" being 4 bytes long)
3567 ++ */
3568 ++ EMIT_COND_JMP(X86_JE, addrs[pc_ret0 - 1] -
3569 ++ (addrs[i] - 4));
3570 ++ } else {
3571 + EMIT_COND_JMP(X86_JNE, 2 + 5);
3572 + CLEAR_A();
3573 + EMIT1_off32(0xe9, cleanup_addr - (addrs[i] - 4)); /* jmp .+off32 */
3574 +@@ -335,12 +341,12 @@ void bpf_jit_compile(struct sk_filter *fp)
3575 + }
3576 + /* fallinto */
3577 + case BPF_S_RET_A:
3578 +- if (seen) {
3579 ++ if (seen_or_pass0) {
3580 + if (i != flen - 1) {
3581 + EMIT_JMP(cleanup_addr - addrs[i]);
3582 + break;
3583 + }
3584 +- if (seen & SEEN_XREG)
3585 ++ if (seen_or_pass0 & SEEN_XREG)
3586 + EMIT4(0x48, 0x8b, 0x5d, 0xf8); /* mov -8(%rbp),%rbx */
3587 + EMIT1(0xc9); /* leaveq */
3588 + }
3589 +@@ -483,8 +489,9 @@ common_load: seen |= SEEN_DATAREF;
3590 + goto common_load;
3591 + case BPF_S_LDX_B_MSH:
3592 + if ((int)K < 0) {
3593 +- if (pc_ret0 != -1) {
3594 +- EMIT_JMP(addrs[pc_ret0] - addrs[i]);
3595 ++ if (pc_ret0 > 0) {
3596 ++ /* addrs[pc_ret0 - 1] is the start address */
3597 ++ EMIT_JMP(addrs[pc_ret0 - 1] - addrs[i]);
3598 + break;
3599 + }
3600 + CLEAR_A();
3601 +@@ -599,13 +606,14 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
3602 + * use it to give the cleanup instruction(s) addr
3603 + */
3604 + cleanup_addr = proglen - 1; /* ret */
3605 +- if (seen)
3606 ++ if (seen_or_pass0)
3607 + cleanup_addr -= 1; /* leaveq */
3608 +- if (seen & SEEN_XREG)
3609 ++ if (seen_or_pass0 & SEEN_XREG)
3610 + cleanup_addr -= 4; /* mov -8(%rbp),%rbx */
3611 +
3612 + if (image) {
3613 +- WARN_ON(proglen != oldproglen);
3614 ++ if (proglen != oldproglen)
3615 ++ pr_err("bpb_jit_compile proglen=%u != oldproglen=%u\n", proglen, oldproglen);
3616 + break;
3617 + }
3618 + if (proglen == oldproglen) {
3619 +diff --git a/crypto/sha512_generic.c b/crypto/sha512_generic.c
3620 +index 9ed9f60..88f160b 100644
3621 +--- a/crypto/sha512_generic.c
3622 ++++ b/crypto/sha512_generic.c
3623 +@@ -21,8 +21,6 @@
3624 + #include <linux/percpu.h>
3625 + #include <asm/byteorder.h>
3626 +
3627 +-static DEFINE_PER_CPU(u64[80], msg_schedule);
3628 +-
3629 + static inline u64 Ch(u64 x, u64 y, u64 z)
3630 + {
3631 + return z ^ (x & (y ^ z));
3632 +@@ -80,7 +78,7 @@ static inline void LOAD_OP(int I, u64 *W, const u8 *input)
3633 +
3634 + static inline void BLEND_OP(int I, u64 *W)
3635 + {
3636 +- W[I] = s1(W[I-2]) + W[I-7] + s0(W[I-15]) + W[I-16];
3637 ++ W[I % 16] += s1(W[(I-2) % 16]) + W[(I-7) % 16] + s0(W[(I-15) % 16]);
3638 + }
3639 +
3640 + static void
3641 +@@ -89,38 +87,48 @@ sha512_transform(u64 *state, const u8 *input)
3642 + u64 a, b, c, d, e, f, g, h, t1, t2;
3643 +
3644 + int i;
3645 +- u64 *W = get_cpu_var(msg_schedule);
3646 ++ u64 W[16];
3647 +
3648 + /* load the input */
3649 + for (i = 0; i < 16; i++)
3650 + LOAD_OP(i, W, input);
3651 +
3652 +- for (i = 16; i < 80; i++) {
3653 +- BLEND_OP(i, W);
3654 +- }
3655 +-
3656 + /* load the state into our registers */
3657 + a=state[0]; b=state[1]; c=state[2]; d=state[3];
3658 + e=state[4]; f=state[5]; g=state[6]; h=state[7];
3659 +
3660 +- /* now iterate */
3661 +- for (i=0; i<80; i+=8) {
3662 +- t1 = h + e1(e) + Ch(e,f,g) + sha512_K[i ] + W[i ];
3663 +- t2 = e0(a) + Maj(a,b,c); d+=t1; h=t1+t2;
3664 +- t1 = g + e1(d) + Ch(d,e,f) + sha512_K[i+1] + W[i+1];
3665 +- t2 = e0(h) + Maj(h,a,b); c+=t1; g=t1+t2;
3666 +- t1 = f + e1(c) + Ch(c,d,e) + sha512_K[i+2] + W[i+2];
3667 +- t2 = e0(g) + Maj(g,h,a); b+=t1; f=t1+t2;
3668 +- t1 = e + e1(b) + Ch(b,c,d) + sha512_K[i+3] + W[i+3];
3669 +- t2 = e0(f) + Maj(f,g,h); a+=t1; e=t1+t2;
3670 +- t1 = d + e1(a) + Ch(a,b,c) + sha512_K[i+4] + W[i+4];
3671 +- t2 = e0(e) + Maj(e,f,g); h+=t1; d=t1+t2;
3672 +- t1 = c + e1(h) + Ch(h,a,b) + sha512_K[i+5] + W[i+5];
3673 +- t2 = e0(d) + Maj(d,e,f); g+=t1; c=t1+t2;
3674 +- t1 = b + e1(g) + Ch(g,h,a) + sha512_K[i+6] + W[i+6];
3675 +- t2 = e0(c) + Maj(c,d,e); f+=t1; b=t1+t2;
3676 +- t1 = a + e1(f) + Ch(f,g,h) + sha512_K[i+7] + W[i+7];
3677 +- t2 = e0(b) + Maj(b,c,d); e+=t1; a=t1+t2;
3678 ++#define SHA512_0_15(i, a, b, c, d, e, f, g, h) \
3679 ++ t1 = h + e1(e) + Ch(e, f, g) + sha512_K[i] + W[i]; \
3680 ++ t2 = e0(a) + Maj(a, b, c); \
3681 ++ d += t1; \
3682 ++ h = t1 + t2
3683 ++
3684 ++#define SHA512_16_79(i, a, b, c, d, e, f, g, h) \
3685 ++ BLEND_OP(i, W); \
3686 ++ t1 = h + e1(e) + Ch(e, f, g) + sha512_K[i] + W[(i)%16]; \
3687 ++ t2 = e0(a) + Maj(a, b, c); \
3688 ++ d += t1; \
3689 ++ h = t1 + t2
3690 ++
3691 ++ for (i = 0; i < 16; i += 8) {
3692 ++ SHA512_0_15(i, a, b, c, d, e, f, g, h);
3693 ++ SHA512_0_15(i + 1, h, a, b, c, d, e, f, g);
3694 ++ SHA512_0_15(i + 2, g, h, a, b, c, d, e, f);
3695 ++ SHA512_0_15(i + 3, f, g, h, a, b, c, d, e);
3696 ++ SHA512_0_15(i + 4, e, f, g, h, a, b, c, d);
3697 ++ SHA512_0_15(i + 5, d, e, f, g, h, a, b, c);
3698 ++ SHA512_0_15(i + 6, c, d, e, f, g, h, a, b);
3699 ++ SHA512_0_15(i + 7, b, c, d, e, f, g, h, a);
3700 ++ }
3701 ++ for (i = 16; i < 80; i += 8) {
3702 ++ SHA512_16_79(i, a, b, c, d, e, f, g, h);
3703 ++ SHA512_16_79(i + 1, h, a, b, c, d, e, f, g);
3704 ++ SHA512_16_79(i + 2, g, h, a, b, c, d, e, f);
3705 ++ SHA512_16_79(i + 3, f, g, h, a, b, c, d, e);
3706 ++ SHA512_16_79(i + 4, e, f, g, h, a, b, c, d);
3707 ++ SHA512_16_79(i + 5, d, e, f, g, h, a, b, c);
3708 ++ SHA512_16_79(i + 6, c, d, e, f, g, h, a, b);
3709 ++ SHA512_16_79(i + 7, b, c, d, e, f, g, h, a);
3710 + }
3711 +
3712 + state[0] += a; state[1] += b; state[2] += c; state[3] += d;
3713 +@@ -128,8 +136,6 @@ sha512_transform(u64 *state, const u8 *input)
3714 +
3715 + /* erase our data */
3716 + a = b = c = d = e = f = g = h = t1 = t2 = 0;
3717 +- memset(W, 0, sizeof(__get_cpu_var(msg_schedule)));
3718 +- put_cpu_var(msg_schedule);
3719 + }
3720 +
3721 + static int
3722 +diff --git a/drivers/gpu/drm/drm_auth.c b/drivers/gpu/drm/drm_auth.c
3723 +index 3f46772..ba23790 100644
3724 +--- a/drivers/gpu/drm/drm_auth.c
3725 ++++ b/drivers/gpu/drm/drm_auth.c
3726 +@@ -101,7 +101,7 @@ static int drm_add_magic(struct drm_master *master, struct drm_file *priv,
3727 + * Searches and unlinks the entry in drm_device::magiclist with the magic
3728 + * number hash key, while holding the drm_device::struct_mutex lock.
3729 + */
3730 +-static int drm_remove_magic(struct drm_master *master, drm_magic_t magic)
3731 ++int drm_remove_magic(struct drm_master *master, drm_magic_t magic)
3732 + {
3733 + struct drm_magic_entry *pt;
3734 + struct drm_hash_item *hash;
3735 +@@ -136,6 +136,8 @@ static int drm_remove_magic(struct drm_master *master, drm_magic_t magic)
3736 + * If there is a magic number in drm_file::magic then use it, otherwise
3737 + * searches an unique non-zero magic number and add it associating it with \p
3738 + * file_priv.
3739 ++ * This ioctl needs protection by the drm_global_mutex, which protects
3740 ++ * struct drm_file::magic and struct drm_magic_entry::priv.
3741 + */
3742 + int drm_getmagic(struct drm_device *dev, void *data, struct drm_file *file_priv)
3743 + {
3744 +@@ -173,6 +175,8 @@ int drm_getmagic(struct drm_device *dev, void *data, struct drm_file *file_priv)
3745 + * \return zero if authentication successed, or a negative number otherwise.
3746 + *
3747 + * Checks if \p file_priv is associated with the magic number passed in \arg.
3748 ++ * This ioctl needs protection by the drm_global_mutex, which protects
3749 ++ * struct drm_file::magic and struct drm_magic_entry::priv.
3750 + */
3751 + int drm_authmagic(struct drm_device *dev, void *data,
3752 + struct drm_file *file_priv)
3753 +diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
3754 +index 2ec7d48..c42e12c 100644
3755 +--- a/drivers/gpu/drm/drm_fops.c
3756 ++++ b/drivers/gpu/drm/drm_fops.c
3757 +@@ -486,6 +486,11 @@ int drm_release(struct inode *inode, struct file *filp)
3758 + (long)old_encode_dev(file_priv->minor->device),
3759 + dev->open_count);
3760 +
3761 ++ /* Release any auth tokens that might point to this file_priv,
3762 ++ (do that under the drm_global_mutex) */
3763 ++ if (file_priv->magic)
3764 ++ (void) drm_remove_magic(file_priv->master, file_priv->magic);
3765 ++
3766 + /* if the master has gone away we can't do anything with the lock */
3767 + if (file_priv->minor->master)
3768 + drm_master_release(dev, filp);
3769 +diff --git a/drivers/gpu/drm/i915/intel_sdvo.c b/drivers/gpu/drm/i915/intel_sdvo.c
3770 +index 30fe554..bdda08e 100644
3771 +--- a/drivers/gpu/drm/i915/intel_sdvo.c
3772 ++++ b/drivers/gpu/drm/i915/intel_sdvo.c
3773 +@@ -1059,15 +1059,13 @@ static void intel_sdvo_mode_set(struct drm_encoder *encoder,
3774 +
3775 + /* Set the SDVO control regs. */
3776 + if (INTEL_INFO(dev)->gen >= 4) {
3777 +- sdvox = 0;
3778 ++ /* The real mode polarity is set by the SDVO commands, using
3779 ++ * struct intel_sdvo_dtd. */
3780 ++ sdvox = SDVO_VSYNC_ACTIVE_HIGH | SDVO_HSYNC_ACTIVE_HIGH;
3781 + if (intel_sdvo->is_hdmi)
3782 + sdvox |= intel_sdvo->color_range;
3783 + if (INTEL_INFO(dev)->gen < 5)
3784 + sdvox |= SDVO_BORDER_ENABLE;
3785 +- if (adjusted_mode->flags & DRM_MODE_FLAG_PVSYNC)
3786 +- sdvox |= SDVO_VSYNC_ACTIVE_HIGH;
3787 +- if (adjusted_mode->flags & DRM_MODE_FLAG_PHSYNC)
3788 +- sdvox |= SDVO_HSYNC_ACTIVE_HIGH;
3789 + } else {
3790 + sdvox = I915_READ(intel_sdvo->sdvo_reg);
3791 + switch (intel_sdvo->sdvo_reg) {
3792 +diff --git a/drivers/gpu/drm/radeon/radeon_irq_kms.c b/drivers/gpu/drm/radeon/radeon_irq_kms.c
3793 +index fecc1aa..5feb6e9 100644
3794 +--- a/drivers/gpu/drm/radeon/radeon_irq_kms.c
3795 ++++ b/drivers/gpu/drm/radeon/radeon_irq_kms.c
3796 +@@ -134,6 +134,12 @@ static bool radeon_msi_ok(struct radeon_device *rdev)
3797 + /* Dell RS690 only seems to work with MSIs. */
3798 + if ((rdev->pdev->device == 0x791f) &&
3799 + (rdev->pdev->subsystem_vendor == 0x1028) &&
3800 ++ (rdev->pdev->subsystem_device == 0x01fc))
3801 ++ return true;
3802 ++
3803 ++ /* Dell RS690 only seems to work with MSIs. */
3804 ++ if ((rdev->pdev->device == 0x791f) &&
3805 ++ (rdev->pdev->subsystem_vendor == 0x1028) &&
3806 + (rdev->pdev->subsystem_device == 0x01fd))
3807 + return true;
3808 +
3809 +diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
3810 +index dfe32e6..8a38c91 100644
3811 +--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
3812 ++++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
3813 +@@ -313,7 +313,7 @@ int vmw_framebuffer_create_handle(struct drm_framebuffer *fb,
3814 + unsigned int *handle)
3815 + {
3816 + if (handle)
3817 +- handle = 0;
3818 ++ *handle = 0;
3819 +
3820 + return 0;
3821 + }
3822 +diff --git a/drivers/hwmon/f71805f.c b/drivers/hwmon/f71805f.c
3823 +index 92f9497..6dbfd3e 100644
3824 +--- a/drivers/hwmon/f71805f.c
3825 ++++ b/drivers/hwmon/f71805f.c
3826 +@@ -283,11 +283,11 @@ static inline long temp_from_reg(u8 reg)
3827 +
3828 + static inline u8 temp_to_reg(long val)
3829 + {
3830 +- if (val < 0)
3831 +- val = 0;
3832 +- else if (val > 1000 * 0xff)
3833 +- val = 0xff;
3834 +- return ((val + 500) / 1000);
3835 ++ if (val <= 0)
3836 ++ return 0;
3837 ++ if (val >= 1000 * 0xff)
3838 ++ return 0xff;
3839 ++ return (val + 500) / 1000;
3840 + }
3841 +
3842 + /*
3843 +diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
3844 +index cf4330b..9594cdb 100644
3845 +--- a/drivers/hwmon/sht15.c
3846 ++++ b/drivers/hwmon/sht15.c
3847 +@@ -883,7 +883,7 @@ static int sht15_invalidate_voltage(struct notifier_block *nb,
3848 +
3849 + static int __devinit sht15_probe(struct platform_device *pdev)
3850 + {
3851 +- int ret = 0;
3852 ++ int ret;
3853 + struct sht15_data *data = kzalloc(sizeof(*data), GFP_KERNEL);
3854 + u8 status = 0;
3855 +
3856 +@@ -901,6 +901,7 @@ static int __devinit sht15_probe(struct platform_device *pdev)
3857 + init_waitqueue_head(&data->wait_queue);
3858 +
3859 + if (pdev->dev.platform_data == NULL) {
3860 ++ ret = -EINVAL;
3861 + dev_err(&pdev->dev, "no platform data supplied\n");
3862 + goto err_free_data;
3863 + }
3864 +diff --git a/drivers/hwmon/w83627ehf.c b/drivers/hwmon/w83627ehf.c
3865 +index 4b2fc50..6284515 100644
3866 +--- a/drivers/hwmon/w83627ehf.c
3867 ++++ b/drivers/hwmon/w83627ehf.c
3868 +@@ -1295,6 +1295,7 @@ store_pwm_mode(struct device *dev, struct device_attribute *attr,
3869 + {
3870 + struct w83627ehf_data *data = dev_get_drvdata(dev);
3871 + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
3872 ++ struct w83627ehf_sio_data *sio_data = dev->platform_data;
3873 + int nr = sensor_attr->index;
3874 + unsigned long val;
3875 + int err;
3876 +@@ -1306,6 +1307,11 @@ store_pwm_mode(struct device *dev, struct device_attribute *attr,
3877 +
3878 + if (val > 1)
3879 + return -EINVAL;
3880 ++
3881 ++ /* On NCT67766F, DC mode is only supported for pwm1 */
3882 ++ if (sio_data->kind == nct6776 && nr && val != 1)
3883 ++ return -EINVAL;
3884 ++
3885 + mutex_lock(&data->update_lock);
3886 + reg = w83627ehf_read_value(data, W83627EHF_REG_PWM_ENABLE[nr]);
3887 + data->pwm_mode[nr] = val;
3888 +diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c
3889 +index 2df9276..5e725e0 100644
3890 +--- a/drivers/net/bonding/bond_alb.c
3891 ++++ b/drivers/net/bonding/bond_alb.c
3892 +@@ -871,16 +871,12 @@ static void alb_send_learning_packets(struct slave *slave, u8 mac_addr[])
3893 + }
3894 + }
3895 +
3896 +-/* hw is a boolean parameter that determines whether we should try and
3897 +- * set the hw address of the device as well as the hw address of the
3898 +- * net_device
3899 +- */
3900 +-static int alb_set_slave_mac_addr(struct slave *slave, u8 addr[], int hw)
3901 ++static int alb_set_slave_mac_addr(struct slave *slave, u8 addr[])
3902 + {
3903 + struct net_device *dev = slave->dev;
3904 + struct sockaddr s_addr;
3905 +
3906 +- if (!hw) {
3907 ++ if (slave->bond->params.mode == BOND_MODE_TLB) {
3908 + memcpy(dev->dev_addr, addr, dev->addr_len);
3909 + return 0;
3910 + }
3911 +@@ -910,8 +906,8 @@ static void alb_swap_mac_addr(struct bonding *bond, struct slave *slave1, struct
3912 + u8 tmp_mac_addr[ETH_ALEN];
3913 +
3914 + memcpy(tmp_mac_addr, slave1->dev->dev_addr, ETH_ALEN);
3915 +- alb_set_slave_mac_addr(slave1, slave2->dev->dev_addr, bond->alb_info.rlb_enabled);
3916 +- alb_set_slave_mac_addr(slave2, tmp_mac_addr, bond->alb_info.rlb_enabled);
3917 ++ alb_set_slave_mac_addr(slave1, slave2->dev->dev_addr);
3918 ++ alb_set_slave_mac_addr(slave2, tmp_mac_addr);
3919 +
3920 + }
3921 +
3922 +@@ -1058,8 +1054,7 @@ static int alb_handle_addr_collision_on_attach(struct bonding *bond, struct slav
3923 +
3924 + /* Try setting slave mac to bond address and fall-through
3925 + to code handling that situation below... */
3926 +- alb_set_slave_mac_addr(slave, bond->dev->dev_addr,
3927 +- bond->alb_info.rlb_enabled);
3928 ++ alb_set_slave_mac_addr(slave, bond->dev->dev_addr);
3929 + }
3930 +
3931 + /* The slave's address is equal to the address of the bond.
3932 +@@ -1095,8 +1090,7 @@ static int alb_handle_addr_collision_on_attach(struct bonding *bond, struct slav
3933 + }
3934 +
3935 + if (free_mac_slave) {
3936 +- alb_set_slave_mac_addr(slave, free_mac_slave->perm_hwaddr,
3937 +- bond->alb_info.rlb_enabled);
3938 ++ alb_set_slave_mac_addr(slave, free_mac_slave->perm_hwaddr);
3939 +
3940 + pr_warning("%s: Warning: the hw address of slave %s is in use by the bond; giving it the hw address of %s\n",
3941 + bond->dev->name, slave->dev->name,
3942 +@@ -1452,8 +1446,7 @@ int bond_alb_init_slave(struct bonding *bond, struct slave *slave)
3943 + {
3944 + int res;
3945 +
3946 +- res = alb_set_slave_mac_addr(slave, slave->perm_hwaddr,
3947 +- bond->alb_info.rlb_enabled);
3948 ++ res = alb_set_slave_mac_addr(slave, slave->perm_hwaddr);
3949 + if (res) {
3950 + return res;
3951 + }
3952 +@@ -1604,8 +1597,7 @@ void bond_alb_handle_active_change(struct bonding *bond, struct slave *new_slave
3953 + alb_swap_mac_addr(bond, swap_slave, new_slave);
3954 + } else {
3955 + /* set the new_slave to the bond mac address */
3956 +- alb_set_slave_mac_addr(new_slave, bond->dev->dev_addr,
3957 +- bond->alb_info.rlb_enabled);
3958 ++ alb_set_slave_mac_addr(new_slave, bond->dev->dev_addr);
3959 + }
3960 +
3961 + if (swap_slave) {
3962 +@@ -1665,8 +1657,7 @@ int bond_alb_set_mac_address(struct net_device *bond_dev, void *addr)
3963 + alb_swap_mac_addr(bond, swap_slave, bond->curr_active_slave);
3964 + alb_fasten_mac_swap(bond, swap_slave, bond->curr_active_slave);
3965 + } else {
3966 +- alb_set_slave_mac_addr(bond->curr_active_slave, bond_dev->dev_addr,
3967 +- bond->alb_info.rlb_enabled);
3968 ++ alb_set_slave_mac_addr(bond->curr_active_slave, bond_dev->dev_addr);
3969 +
3970 + read_lock(&bond->lock);
3971 + alb_send_learning_packets(bond->curr_active_slave, bond_dev->dev_addr);
3972 +diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
3973 +index f5f6831..4a4733e 100644
3974 +--- a/drivers/tty/serial/amba-pl011.c
3975 ++++ b/drivers/tty/serial/amba-pl011.c
3976 +@@ -1733,9 +1733,19 @@ pl011_console_write(struct console *co, const char *s, unsigned int count)
3977 + {
3978 + struct uart_amba_port *uap = amba_ports[co->index];
3979 + unsigned int status, old_cr, new_cr;
3980 ++ unsigned long flags;
3981 ++ int locked = 1;
3982 +
3983 + clk_enable(uap->clk);
3984 +
3985 ++ local_irq_save(flags);
3986 ++ if (uap->port.sysrq)
3987 ++ locked = 0;
3988 ++ else if (oops_in_progress)
3989 ++ locked = spin_trylock(&uap->port.lock);
3990 ++ else
3991 ++ spin_lock(&uap->port.lock);
3992 ++
3993 + /*
3994 + * First save the CR then disable the interrupts
3995 + */
3996 +@@ -1755,6 +1765,10 @@ pl011_console_write(struct console *co, const char *s, unsigned int count)
3997 + } while (status & UART01x_FR_BUSY);
3998 + writew(old_cr, uap->port.membase + UART011_CR);
3999 +
4000 ++ if (locked)
4001 ++ spin_unlock(&uap->port.lock);
4002 ++ local_irq_restore(flags);
4003 ++
4004 + clk_disable(uap->clk);
4005 + }
4006 +
4007 +diff --git a/drivers/tty/serial/jsm/jsm_driver.c b/drivers/tty/serial/jsm/jsm_driver.c
4008 +index 2aaafa9..6c12d94 100644
4009 +--- a/drivers/tty/serial/jsm/jsm_driver.c
4010 ++++ b/drivers/tty/serial/jsm/jsm_driver.c
4011 +@@ -269,6 +269,7 @@ static void jsm_io_resume(struct pci_dev *pdev)
4012 + struct jsm_board *brd = pci_get_drvdata(pdev);
4013 +
4014 + pci_restore_state(pdev);
4015 ++ pci_save_state(pdev);
4016 +
4017 + jsm_uart_port_init(brd);
4018 + }
4019 +diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
4020 +index 33d37d2..a4aaca0 100644
4021 +--- a/drivers/tty/tty_port.c
4022 ++++ b/drivers/tty/tty_port.c
4023 +@@ -227,7 +227,6 @@ int tty_port_block_til_ready(struct tty_port *port,
4024 + int do_clocal = 0, retval;
4025 + unsigned long flags;
4026 + DEFINE_WAIT(wait);
4027 +- int cd;
4028 +
4029 + /* block if port is in the process of being closed */
4030 + if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING) {
4031 +@@ -284,11 +283,14 @@ int tty_port_block_til_ready(struct tty_port *port,
4032 + retval = -ERESTARTSYS;
4033 + break;
4034 + }
4035 +- /* Probe the carrier. For devices with no carrier detect this
4036 +- will always return true */
4037 +- cd = tty_port_carrier_raised(port);
4038 ++ /*
4039 ++ * Probe the carrier. For devices with no carrier detect
4040 ++ * tty_port_carrier_raised will always return true.
4041 ++ * Never ask drivers if CLOCAL is set, this causes troubles
4042 ++ * on some hardware.
4043 ++ */
4044 + if (!(port->flags & ASYNC_CLOSING) &&
4045 +- (do_clocal || cd))
4046 ++ (do_clocal || tty_port_carrier_raised(port)))
4047 + break;
4048 + if (signal_pending(current)) {
4049 + retval = -ERESTARTSYS;
4050 +diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c
4051 +index 2b9ff51..90581a8 100644
4052 +--- a/drivers/usb/class/cdc-wdm.c
4053 ++++ b/drivers/usb/class/cdc-wdm.c
4054 +@@ -57,6 +57,8 @@ MODULE_DEVICE_TABLE (usb, wdm_ids);
4055 +
4056 + #define WDM_MAX 16
4057 +
4058 ++/* CDC-WMC r1.1 requires wMaxCommand to be "at least 256 decimal (0x100)" */
4059 ++#define WDM_DEFAULT_BUFSIZE 256
4060 +
4061 + static DEFINE_MUTEX(wdm_mutex);
4062 +
4063 +@@ -88,7 +90,8 @@ struct wdm_device {
4064 + int count;
4065 + dma_addr_t shandle;
4066 + dma_addr_t ihandle;
4067 +- struct mutex lock;
4068 ++ struct mutex wlock;
4069 ++ struct mutex rlock;
4070 + wait_queue_head_t wait;
4071 + struct work_struct rxwork;
4072 + int werr;
4073 +@@ -323,7 +326,7 @@ static ssize_t wdm_write
4074 + }
4075 +
4076 + /* concurrent writes and disconnect */
4077 +- r = mutex_lock_interruptible(&desc->lock);
4078 ++ r = mutex_lock_interruptible(&desc->wlock);
4079 + rv = -ERESTARTSYS;
4080 + if (r) {
4081 + kfree(buf);
4082 +@@ -386,7 +389,7 @@ static ssize_t wdm_write
4083 + out:
4084 + usb_autopm_put_interface(desc->intf);
4085 + outnp:
4086 +- mutex_unlock(&desc->lock);
4087 ++ mutex_unlock(&desc->wlock);
4088 + outnl:
4089 + return rv < 0 ? rv : count;
4090 + }
4091 +@@ -399,7 +402,7 @@ static ssize_t wdm_read
4092 + struct wdm_device *desc = file->private_data;
4093 +
4094 +
4095 +- rv = mutex_lock_interruptible(&desc->lock); /*concurrent reads */
4096 ++ rv = mutex_lock_interruptible(&desc->rlock); /*concurrent reads */
4097 + if (rv < 0)
4098 + return -ERESTARTSYS;
4099 +
4100 +@@ -467,14 +470,16 @@ retry:
4101 + for (i = 0; i < desc->length - cntr; i++)
4102 + desc->ubuf[i] = desc->ubuf[i + cntr];
4103 +
4104 ++ spin_lock_irq(&desc->iuspin);
4105 + desc->length -= cntr;
4106 ++ spin_unlock_irq(&desc->iuspin);
4107 + /* in case we had outstanding data */
4108 + if (!desc->length)
4109 + clear_bit(WDM_READ, &desc->flags);
4110 + rv = cntr;
4111 +
4112 + err:
4113 +- mutex_unlock(&desc->lock);
4114 ++ mutex_unlock(&desc->rlock);
4115 + return rv;
4116 + }
4117 +
4118 +@@ -540,7 +545,8 @@ static int wdm_open(struct inode *inode, struct file *file)
4119 + }
4120 + intf->needs_remote_wakeup = 1;
4121 +
4122 +- mutex_lock(&desc->lock);
4123 ++ /* using write lock to protect desc->count */
4124 ++ mutex_lock(&desc->wlock);
4125 + if (!desc->count++) {
4126 + desc->werr = 0;
4127 + desc->rerr = 0;
4128 +@@ -553,7 +559,7 @@ static int wdm_open(struct inode *inode, struct file *file)
4129 + } else {
4130 + rv = 0;
4131 + }
4132 +- mutex_unlock(&desc->lock);
4133 ++ mutex_unlock(&desc->wlock);
4134 + usb_autopm_put_interface(desc->intf);
4135 + out:
4136 + mutex_unlock(&wdm_mutex);
4137 +@@ -565,9 +571,11 @@ static int wdm_release(struct inode *inode, struct file *file)
4138 + struct wdm_device *desc = file->private_data;
4139 +
4140 + mutex_lock(&wdm_mutex);
4141 +- mutex_lock(&desc->lock);
4142 ++
4143 ++ /* using write lock to protect desc->count */
4144 ++ mutex_lock(&desc->wlock);
4145 + desc->count--;
4146 +- mutex_unlock(&desc->lock);
4147 ++ mutex_unlock(&desc->wlock);
4148 +
4149 + if (!desc->count) {
4150 + dev_dbg(&desc->intf->dev, "wdm_release: cleanup");
4151 +@@ -630,7 +638,7 @@ static int wdm_probe(struct usb_interface *intf, const struct usb_device_id *id)
4152 + struct usb_cdc_dmm_desc *dmhd;
4153 + u8 *buffer = intf->altsetting->extra;
4154 + int buflen = intf->altsetting->extralen;
4155 +- u16 maxcom = 0;
4156 ++ u16 maxcom = WDM_DEFAULT_BUFSIZE;
4157 +
4158 + if (!buffer)
4159 + goto out;
4160 +@@ -665,7 +673,8 @@ next_desc:
4161 + desc = kzalloc(sizeof(struct wdm_device), GFP_KERNEL);
4162 + if (!desc)
4163 + goto out;
4164 +- mutex_init(&desc->lock);
4165 ++ mutex_init(&desc->rlock);
4166 ++ mutex_init(&desc->wlock);
4167 + spin_lock_init(&desc->iuspin);
4168 + init_waitqueue_head(&desc->wait);
4169 + desc->wMaxCommand = maxcom;
4170 +@@ -716,7 +725,7 @@ next_desc:
4171 + goto err;
4172 +
4173 + desc->inbuf = usb_alloc_coherent(interface_to_usbdev(intf),
4174 +- desc->bMaxPacketSize0,
4175 ++ desc->wMaxCommand,
4176 + GFP_KERNEL,
4177 + &desc->response->transfer_dma);
4178 + if (!desc->inbuf)
4179 +@@ -779,11 +788,13 @@ static void wdm_disconnect(struct usb_interface *intf)
4180 + /* to terminate pending flushes */
4181 + clear_bit(WDM_IN_USE, &desc->flags);
4182 + spin_unlock_irqrestore(&desc->iuspin, flags);
4183 +- mutex_lock(&desc->lock);
4184 ++ wake_up_all(&desc->wait);
4185 ++ mutex_lock(&desc->rlock);
4186 ++ mutex_lock(&desc->wlock);
4187 + kill_urbs(desc);
4188 + cancel_work_sync(&desc->rxwork);
4189 +- mutex_unlock(&desc->lock);
4190 +- wake_up_all(&desc->wait);
4191 ++ mutex_unlock(&desc->wlock);
4192 ++ mutex_unlock(&desc->rlock);
4193 + if (!desc->count)
4194 + cleanup(desc);
4195 + mutex_unlock(&wdm_mutex);
4196 +@@ -798,8 +809,10 @@ static int wdm_suspend(struct usb_interface *intf, pm_message_t message)
4197 + dev_dbg(&desc->intf->dev, "wdm%d_suspend\n", intf->minor);
4198 +
4199 + /* if this is an autosuspend the caller does the locking */
4200 +- if (!(message.event & PM_EVENT_AUTO))
4201 +- mutex_lock(&desc->lock);
4202 ++ if (!(message.event & PM_EVENT_AUTO)) {
4203 ++ mutex_lock(&desc->rlock);
4204 ++ mutex_lock(&desc->wlock);
4205 ++ }
4206 + spin_lock_irq(&desc->iuspin);
4207 +
4208 + if ((message.event & PM_EVENT_AUTO) &&
4209 +@@ -815,8 +828,10 @@ static int wdm_suspend(struct usb_interface *intf, pm_message_t message)
4210 + kill_urbs(desc);
4211 + cancel_work_sync(&desc->rxwork);
4212 + }
4213 +- if (!(message.event & PM_EVENT_AUTO))
4214 +- mutex_unlock(&desc->lock);
4215 ++ if (!(message.event & PM_EVENT_AUTO)) {
4216 ++ mutex_unlock(&desc->wlock);
4217 ++ mutex_unlock(&desc->rlock);
4218 ++ }
4219 +
4220 + return rv;
4221 + }
4222 +@@ -854,7 +869,8 @@ static int wdm_pre_reset(struct usb_interface *intf)
4223 + {
4224 + struct wdm_device *desc = usb_get_intfdata(intf);
4225 +
4226 +- mutex_lock(&desc->lock);
4227 ++ mutex_lock(&desc->rlock);
4228 ++ mutex_lock(&desc->wlock);
4229 + kill_urbs(desc);
4230 +
4231 + /*
4232 +@@ -876,7 +892,8 @@ static int wdm_post_reset(struct usb_interface *intf)
4233 + int rv;
4234 +
4235 + rv = recover_from_urb_loss(desc);
4236 +- mutex_unlock(&desc->lock);
4237 ++ mutex_unlock(&desc->wlock);
4238 ++ mutex_unlock(&desc->rlock);
4239 + return 0;
4240 + }
4241 +
4242 +diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
4243 +index f380bf9..bc7f166 100644
4244 +--- a/drivers/usb/host/ehci-fsl.c
4245 ++++ b/drivers/usb/host/ehci-fsl.c
4246 +@@ -125,7 +125,7 @@ static int usb_hcd_fsl_probe(const struct hc_driver *driver,
4247 + */
4248 + if (pdata->init && pdata->init(pdev)) {
4249 + retval = -ENODEV;
4250 +- goto err3;
4251 ++ goto err4;
4252 + }
4253 +
4254 + /* Enable USB controller, 83xx or 8536 */
4255 +diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
4256 +index c0c5d6c..edcedc4 100644
4257 +--- a/drivers/usb/host/xhci-ring.c
4258 ++++ b/drivers/usb/host/xhci-ring.c
4259 +@@ -1218,6 +1218,7 @@ static void handle_vendor_event(struct xhci_hcd *xhci,
4260 + *
4261 + * Returns a zero-based port number, which is suitable for indexing into each of
4262 + * the split roothubs' port arrays and bus state arrays.
4263 ++ * Add one to it in order to call xhci_find_slot_id_by_port.
4264 + */
4265 + static unsigned int find_faked_portnum_from_hw_portnum(struct usb_hcd *hcd,
4266 + struct xhci_hcd *xhci, u32 port_id)
4267 +@@ -1340,7 +1341,7 @@ static void handle_port_status(struct xhci_hcd *xhci,
4268 + temp |= PORT_LINK_STROBE | XDEV_U0;
4269 + xhci_writel(xhci, temp, port_array[faked_port_index]);
4270 + slot_id = xhci_find_slot_id_by_port(hcd, xhci,
4271 +- faked_port_index);
4272 ++ faked_port_index + 1);
4273 + if (!slot_id) {
4274 + xhci_dbg(xhci, "slot_id is zero\n");
4275 + goto cleanup;
4276 +@@ -3381,7 +3382,8 @@ static int xhci_queue_isoc_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
4277 + /* Check TD length */
4278 + if (running_total != td_len) {
4279 + xhci_err(xhci, "ISOC TD length unmatch\n");
4280 +- return -EINVAL;
4281 ++ ret = -EINVAL;
4282 ++ goto cleanup;
4283 + }
4284 + }
4285 +
4286 +diff --git a/drivers/usb/misc/usbsevseg.c b/drivers/usb/misc/usbsevseg.c
4287 +index 417b8f2..59689fa 100644
4288 +--- a/drivers/usb/misc/usbsevseg.c
4289 ++++ b/drivers/usb/misc/usbsevseg.c
4290 +@@ -24,7 +24,7 @@
4291 +
4292 + #define VENDOR_ID 0x0fc5
4293 + #define PRODUCT_ID 0x1227
4294 +-#define MAXLEN 6
4295 ++#define MAXLEN 8
4296 +
4297 + /* table of devices that work with this driver */
4298 + static const struct usb_device_id id_table[] = {
4299 +diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
4300 +index a1a324b..a515237 100644
4301 +--- a/drivers/usb/serial/cp210x.c
4302 ++++ b/drivers/usb/serial/cp210x.c
4303 +@@ -39,6 +39,8 @@ static void cp210x_get_termios(struct tty_struct *,
4304 + struct usb_serial_port *port);
4305 + static void cp210x_get_termios_port(struct usb_serial_port *port,
4306 + unsigned int *cflagp, unsigned int *baudp);
4307 ++static void cp210x_change_speed(struct tty_struct *, struct usb_serial_port *,
4308 ++ struct ktermios *);
4309 + static void cp210x_set_termios(struct tty_struct *, struct usb_serial_port *,
4310 + struct ktermios*);
4311 + static int cp210x_tiocmget(struct tty_struct *);
4312 +@@ -138,6 +140,7 @@ static const struct usb_device_id id_table[] = {
4313 + { USB_DEVICE(0x1843, 0x0200) }, /* Vaisala USB Instrument Cable */
4314 + { USB_DEVICE(0x18EF, 0xE00F) }, /* ELV USB-I2C-Interface */
4315 + { USB_DEVICE(0x1BE3, 0x07A6) }, /* WAGO 750-923 USB Service Cable */
4316 ++ { USB_DEVICE(0x3195, 0xF190) }, /* Link Instruments MSO-19 */
4317 + { USB_DEVICE(0x413C, 0x9500) }, /* DW700 GPS USB interface */
4318 + { } /* Terminating Entry */
4319 + };
4320 +@@ -201,6 +204,8 @@ static struct usb_serial_driver cp210x_device = {
4321 + #define CP210X_EMBED_EVENTS 0x15
4322 + #define CP210X_GET_EVENTSTATE 0x16
4323 + #define CP210X_SET_CHARS 0x19
4324 ++#define CP210X_GET_BAUDRATE 0x1D
4325 ++#define CP210X_SET_BAUDRATE 0x1E
4326 +
4327 + /* CP210X_IFC_ENABLE */
4328 + #define UART_ENABLE 0x0001
4329 +@@ -354,8 +359,8 @@ static inline int cp210x_set_config_single(struct usb_serial_port *port,
4330 + * Quantises the baud rate as per AN205 Table 1
4331 + */
4332 + static unsigned int cp210x_quantise_baudrate(unsigned int baud) {
4333 +- if (baud <= 56) baud = 0;
4334 +- else if (baud <= 300) baud = 300;
4335 ++ if (baud <= 300)
4336 ++ baud = 300;
4337 + else if (baud <= 600) baud = 600;
4338 + else if (baud <= 1200) baud = 1200;
4339 + else if (baud <= 1800) baud = 1800;
4340 +@@ -383,17 +388,15 @@ static unsigned int cp210x_quantise_baudrate(unsigned int baud) {
4341 + else if (baud <= 491520) baud = 460800;
4342 + else if (baud <= 567138) baud = 500000;
4343 + else if (baud <= 670254) baud = 576000;
4344 +- else if (baud <= 1053257) baud = 921600;
4345 +- else if (baud <= 1474560) baud = 1228800;
4346 +- else if (baud <= 2457600) baud = 1843200;
4347 +- else baud = 3686400;
4348 ++ else if (baud < 1000000)
4349 ++ baud = 921600;
4350 ++ else if (baud > 2000000)
4351 ++ baud = 2000000;
4352 + return baud;
4353 + }
4354 +
4355 + static int cp210x_open(struct tty_struct *tty, struct usb_serial_port *port)
4356 + {
4357 +- int result;
4358 +-
4359 + dbg("%s - port %d", __func__, port->number);
4360 +
4361 + if (cp210x_set_config_single(port, CP210X_IFC_ENABLE, UART_ENABLE)) {
4362 +@@ -402,13 +405,14 @@ static int cp210x_open(struct tty_struct *tty, struct usb_serial_port *port)
4363 + return -EPROTO;
4364 + }
4365 +
4366 +- result = usb_serial_generic_open(tty, port);
4367 +- if (result)
4368 +- return result;
4369 +-
4370 + /* Configure the termios structure */
4371 + cp210x_get_termios(tty, port);
4372 +- return 0;
4373 ++
4374 ++ /* The baud rate must be initialised on cp2104 */
4375 ++ if (tty)
4376 ++ cp210x_change_speed(tty, port, NULL);
4377 ++
4378 ++ return usb_serial_generic_open(tty, port);
4379 + }
4380 +
4381 + static void cp210x_close(struct usb_serial_port *port)
4382 +@@ -460,10 +464,7 @@ static void cp210x_get_termios_port(struct usb_serial_port *port,
4383 +
4384 + dbg("%s - port %d", __func__, port->number);
4385 +
4386 +- cp210x_get_config(port, CP210X_GET_BAUDDIV, &baud, 2);
4387 +- /* Convert to baudrate */
4388 +- if (baud)
4389 +- baud = cp210x_quantise_baudrate((BAUD_RATE_GEN_FREQ + baud/2)/ baud);
4390 ++ cp210x_get_config(port, CP210X_GET_BAUDRATE, &baud, 4);
4391 +
4392 + dbg("%s - baud rate = %d", __func__, baud);
4393 + *baudp = baud;
4394 +@@ -577,11 +578,64 @@ static void cp210x_get_termios_port(struct usb_serial_port *port,
4395 + *cflagp = cflag;
4396 + }
4397 +
4398 ++/*
4399 ++ * CP2101 supports the following baud rates:
4400 ++ *
4401 ++ * 300, 600, 1200, 1800, 2400, 4800, 7200, 9600, 14400, 19200, 28800,
4402 ++ * 38400, 56000, 57600, 115200, 128000, 230400, 460800, 921600
4403 ++ *
4404 ++ * CP2102 and CP2103 support the following additional rates:
4405 ++ *
4406 ++ * 4000, 16000, 51200, 64000, 76800, 153600, 250000, 256000, 500000,
4407 ++ * 576000
4408 ++ *
4409 ++ * The device will map a requested rate to a supported one, but the result
4410 ++ * of requests for rates greater than 1053257 is undefined (see AN205).
4411 ++ *
4412 ++ * CP2104, CP2105 and CP2110 support most rates up to 2M, 921k and 1M baud,
4413 ++ * respectively, with an error less than 1%. The actual rates are determined
4414 ++ * by
4415 ++ *
4416 ++ * div = round(freq / (2 x prescale x request))
4417 ++ * actual = freq / (2 x prescale x div)
4418 ++ *
4419 ++ * For CP2104 and CP2105 freq is 48Mhz and prescale is 4 for request <= 365bps
4420 ++ * or 1 otherwise.
4421 ++ * For CP2110 freq is 24Mhz and prescale is 4 for request <= 300bps or 1
4422 ++ * otherwise.
4423 ++ */
4424 ++static void cp210x_change_speed(struct tty_struct *tty,
4425 ++ struct usb_serial_port *port, struct ktermios *old_termios)
4426 ++{
4427 ++ u32 baud;
4428 ++
4429 ++ baud = tty->termios->c_ospeed;
4430 ++
4431 ++ /* This maps the requested rate to a rate valid on cp2102 or cp2103,
4432 ++ * or to an arbitrary rate in [1M,2M].
4433 ++ *
4434 ++ * NOTE: B0 is not implemented.
4435 ++ */
4436 ++ baud = cp210x_quantise_baudrate(baud);
4437 ++
4438 ++ dbg("%s - setting baud rate to %u", __func__, baud);
4439 ++ if (cp210x_set_config(port, CP210X_SET_BAUDRATE, &baud,
4440 ++ sizeof(baud))) {
4441 ++ dev_warn(&port->dev, "failed to set baud rate to %u\n", baud);
4442 ++ if (old_termios)
4443 ++ baud = old_termios->c_ospeed;
4444 ++ else
4445 ++ baud = 9600;
4446 ++ }
4447 ++
4448 ++ tty_encode_baud_rate(tty, baud, baud);
4449 ++}
4450 ++
4451 + static void cp210x_set_termios(struct tty_struct *tty,
4452 + struct usb_serial_port *port, struct ktermios *old_termios)
4453 + {
4454 + unsigned int cflag, old_cflag;
4455 +- unsigned int baud = 0, bits;
4456 ++ unsigned int bits;
4457 + unsigned int modem_ctl[4];
4458 +
4459 + dbg("%s - port %d", __func__, port->number);
4460 +@@ -592,20 +646,9 @@ static void cp210x_set_termios(struct tty_struct *tty,
4461 + tty->termios->c_cflag &= ~CMSPAR;
4462 + cflag = tty->termios->c_cflag;
4463 + old_cflag = old_termios->c_cflag;
4464 +- baud = cp210x_quantise_baudrate(tty_get_baud_rate(tty));
4465 +-
4466 +- /* If the baud rate is to be updated*/
4467 +- if (baud != tty_termios_baud_rate(old_termios) && baud != 0) {
4468 +- dbg("%s - Setting baud rate to %d baud", __func__,
4469 +- baud);
4470 +- if (cp210x_set_config_single(port, CP210X_SET_BAUDDIV,
4471 +- ((BAUD_RATE_GEN_FREQ + baud/2) / baud))) {
4472 +- dbg("Baud rate requested not supported by device");
4473 +- baud = tty_termios_baud_rate(old_termios);
4474 +- }
4475 +- }
4476 +- /* Report back the resulting baud rate */
4477 +- tty_encode_baud_rate(tty, baud, baud);
4478 ++
4479 ++ if (tty->termios->c_ospeed != old_termios->c_ospeed)
4480 ++ cp210x_change_speed(tty, port, old_termios);
4481 +
4482 + /* If the number of data bits is to be updated */
4483 + if ((cflag & CSIZE) != (old_cflag & CSIZE)) {
4484 +diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
4485 +index b02fd50..a872cc2 100644
4486 +--- a/drivers/usb/serial/ftdi_sio.c
4487 ++++ b/drivers/usb/serial/ftdi_sio.c
4488 +@@ -796,6 +796,7 @@ static struct usb_device_id id_table_combined [] = {
4489 + .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
4490 + { USB_DEVICE(ADI_VID, ADI_GNICEPLUS_PID),
4491 + .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
4492 ++ { USB_DEVICE(HORNBY_VID, HORNBY_ELITE_PID) },
4493 + { USB_DEVICE(JETI_VID, JETI_SPC1201_PID) },
4494 + { USB_DEVICE(MARVELL_VID, MARVELL_SHEEVAPLUG_PID),
4495 + .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
4496 +@@ -804,6 +805,8 @@ static struct usb_device_id id_table_combined [] = {
4497 + { USB_DEVICE(BAYER_VID, BAYER_CONTOUR_CABLE_PID) },
4498 + { USB_DEVICE(FTDI_VID, MARVELL_OPENRD_PID),
4499 + .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
4500 ++ { USB_DEVICE(FTDI_VID, TI_XDS100V2_PID),
4501 ++ .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
4502 + { USB_DEVICE(FTDI_VID, HAMEG_HO820_PID) },
4503 + { USB_DEVICE(FTDI_VID, HAMEG_HO720_PID) },
4504 + { USB_DEVICE(FTDI_VID, HAMEG_HO730_PID) },
4505 +@@ -840,6 +843,7 @@ static struct usb_device_id id_table_combined [] = {
4506 + .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
4507 + { USB_DEVICE(ST_VID, ST_STMCLT1030_PID),
4508 + .driver_info = (kernel_ulong_t)&ftdi_stmclite_quirk },
4509 ++ { USB_DEVICE(FTDI_VID, FTDI_RF_R106) },
4510 + { }, /* Optional parameter entry */
4511 + { } /* Terminating entry */
4512 + };
4513 +@@ -1326,8 +1330,7 @@ static int set_serial_info(struct tty_struct *tty,
4514 + goto check_and_exit;
4515 + }
4516 +
4517 +- if ((new_serial.baud_base != priv->baud_base) &&
4518 +- (new_serial.baud_base < 9600)) {
4519 ++ if (new_serial.baud_base != priv->baud_base) {
4520 + mutex_unlock(&priv->cfg_lock);
4521 + return -EINVAL;
4522 + }
4523 +@@ -1816,6 +1819,7 @@ static int ftdi_sio_port_remove(struct usb_serial_port *port)
4524 +
4525 + static int ftdi_open(struct tty_struct *tty, struct usb_serial_port *port)
4526 + {
4527 ++ struct ktermios dummy;
4528 + struct usb_device *dev = port->serial->dev;
4529 + struct ftdi_private *priv = usb_get_serial_port_data(port);
4530 + int result;
4531 +@@ -1834,8 +1838,10 @@ static int ftdi_open(struct tty_struct *tty, struct usb_serial_port *port)
4532 + This is same behaviour as serial.c/rs_open() - Kuba */
4533 +
4534 + /* ftdi_set_termios will send usb control messages */
4535 +- if (tty)
4536 +- ftdi_set_termios(tty, port, tty->termios);
4537 ++ if (tty) {
4538 ++ memset(&dummy, 0, sizeof(dummy));
4539 ++ ftdi_set_termios(tty, port, &dummy);
4540 ++ }
4541 +
4542 + /* Start reading from the device */
4543 + result = usb_serial_generic_open(tty, port);
4544 +diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h
4545 +index 055b64e..76d4f31 100644
4546 +--- a/drivers/usb/serial/ftdi_sio_ids.h
4547 ++++ b/drivers/usb/serial/ftdi_sio_ids.h
4548 +@@ -39,6 +39,13 @@
4549 + /* www.candapter.com Ewert Energy Systems CANdapter device */
4550 + #define FTDI_CANDAPTER_PID 0x9F80 /* Product Id */
4551 +
4552 ++/*
4553 ++ * Texas Instruments XDS100v2 JTAG / BeagleBone A3
4554 ++ * http://processors.wiki.ti.com/index.php/XDS100
4555 ++ * http://beagleboard.org/bone
4556 ++ */
4557 ++#define TI_XDS100V2_PID 0xa6d0
4558 ++
4559 + #define FTDI_NXTCAM_PID 0xABB8 /* NXTCam for Mindstorms NXT */
4560 +
4561 + /* US Interface Navigator (http://www.usinterface.com/) */
4562 +@@ -525,6 +532,12 @@
4563 + #define ADI_GNICEPLUS_PID 0xF001
4564 +
4565 + /*
4566 ++ * Hornby Elite
4567 ++ */
4568 ++#define HORNBY_VID 0x04D8
4569 ++#define HORNBY_ELITE_PID 0x000A
4570 ++
4571 ++/*
4572 + * RATOC REX-USB60F
4573 + */
4574 + #define RATOC_VENDOR_ID 0x0584
4575 +@@ -1168,3 +1181,9 @@
4576 + */
4577 + /* TagTracer MIFARE*/
4578 + #define FTDI_ZEITCONTROL_TAGTRACE_MIFARE_PID 0xF7C0
4579 ++
4580 ++/*
4581 ++ * Rainforest Automation
4582 ++ */
4583 ++/* ZigBee controller */
4584 ++#define FTDI_RF_R106 0x8A28
4585 +diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c
4586 +index 0aac00a..8a90d58 100644
4587 +--- a/drivers/usb/serial/io_ti.c
4588 ++++ b/drivers/usb/serial/io_ti.c
4589 +@@ -2677,15 +2677,7 @@ cleanup:
4590 +
4591 + static void edge_disconnect(struct usb_serial *serial)
4592 + {
4593 +- int i;
4594 +- struct edgeport_port *edge_port;
4595 +-
4596 + dbg("%s", __func__);
4597 +-
4598 +- for (i = 0; i < serial->num_ports; ++i) {
4599 +- edge_port = usb_get_serial_port_data(serial->port[i]);
4600 +- edge_remove_sysfs_attrs(edge_port->port);
4601 +- }
4602 + }
4603 +
4604 + static void edge_release(struct usb_serial *serial)
4605 +@@ -2764,6 +2756,7 @@ static struct usb_serial_driver edgeport_1port_device = {
4606 + .disconnect = edge_disconnect,
4607 + .release = edge_release,
4608 + .port_probe = edge_create_sysfs_attrs,
4609 ++ .port_remove = edge_remove_sysfs_attrs,
4610 + .ioctl = edge_ioctl,
4611 + .set_termios = edge_set_termios,
4612 + .tiocmget = edge_tiocmget,
4613 +@@ -2795,6 +2788,7 @@ static struct usb_serial_driver edgeport_2port_device = {
4614 + .disconnect = edge_disconnect,
4615 + .release = edge_release,
4616 + .port_probe = edge_create_sysfs_attrs,
4617 ++ .port_remove = edge_remove_sysfs_attrs,
4618 + .ioctl = edge_ioctl,
4619 + .set_termios = edge_set_termios,
4620 + .tiocmget = edge_tiocmget,
4621 +diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
4622 +index c96b6b6..2a9ed6e 100644
4623 +--- a/drivers/usb/serial/option.c
4624 ++++ b/drivers/usb/serial/option.c
4625 +@@ -480,6 +480,10 @@ static void option_instat_callback(struct urb *urb);
4626 + #define ZD_VENDOR_ID 0x0685
4627 + #define ZD_PRODUCT_7000 0x7000
4628 +
4629 ++/* LG products */
4630 ++#define LG_VENDOR_ID 0x1004
4631 ++#define LG_PRODUCT_L02C 0x618f
4632 ++
4633 + /* some devices interfaces need special handling due to a number of reasons */
4634 + enum option_blacklist_reason {
4635 + OPTION_BLACKLIST_NONE = 0,
4636 +@@ -1183,6 +1187,7 @@ static const struct usb_device_id option_ids[] = {
4637 + { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CLU526) },
4638 + { USB_DEVICE_AND_INTERFACE_INFO(VIETTEL_VENDOR_ID, VIETTEL_PRODUCT_VT1000, 0xff, 0xff, 0xff) },
4639 + { USB_DEVICE_AND_INTERFACE_INFO(ZD_VENDOR_ID, ZD_PRODUCT_7000, 0xff, 0xff, 0xff) },
4640 ++ { USB_DEVICE(LG_VENDOR_ID, LG_PRODUCT_L02C) }, /* docomo L-02C modem */
4641 + { } /* Terminating entry */
4642 + };
4643 + MODULE_DEVICE_TABLE(usb, option_ids);
4644 +diff --git a/drivers/usb/serial/qcaux.c b/drivers/usb/serial/qcaux.c
4645 +index 30b73e6..a348198 100644
4646 +--- a/drivers/usb/serial/qcaux.c
4647 ++++ b/drivers/usb/serial/qcaux.c
4648 +@@ -36,6 +36,7 @@
4649 + #define UTSTARCOM_PRODUCT_UM175_V1 0x3712
4650 + #define UTSTARCOM_PRODUCT_UM175_V2 0x3714
4651 + #define UTSTARCOM_PRODUCT_UM175_ALLTEL 0x3715
4652 ++#define PANTECH_PRODUCT_UML190_VZW 0x3716
4653 + #define PANTECH_PRODUCT_UML290_VZW 0x3718
4654 +
4655 + /* CMOTECH devices */
4656 +@@ -67,7 +68,11 @@ static struct usb_device_id id_table[] = {
4657 + { USB_DEVICE_AND_INTERFACE_INFO(LG_VENDOR_ID, LG_PRODUCT_VX4400_6000, 0xff, 0xff, 0x00) },
4658 + { USB_DEVICE_AND_INTERFACE_INFO(SANYO_VENDOR_ID, SANYO_PRODUCT_KATANA_LX, 0xff, 0xff, 0x00) },
4659 + { USB_DEVICE_AND_INTERFACE_INFO(SAMSUNG_VENDOR_ID, SAMSUNG_PRODUCT_U520, 0xff, 0x00, 0x00) },
4660 +- { USB_DEVICE_AND_INTERFACE_INFO(UTSTARCOM_VENDOR_ID, PANTECH_PRODUCT_UML290_VZW, 0xff, 0xff, 0xff) },
4661 ++ { USB_DEVICE_AND_INTERFACE_INFO(UTSTARCOM_VENDOR_ID, PANTECH_PRODUCT_UML190_VZW, 0xff, 0xff, 0xff) },
4662 ++ { USB_DEVICE_AND_INTERFACE_INFO(UTSTARCOM_VENDOR_ID, PANTECH_PRODUCT_UML190_VZW, 0xff, 0xfe, 0xff) },
4663 ++ { USB_DEVICE_AND_INTERFACE_INFO(UTSTARCOM_VENDOR_ID, PANTECH_PRODUCT_UML290_VZW, 0xff, 0xfd, 0xff) }, /* NMEA */
4664 ++ { USB_DEVICE_AND_INTERFACE_INFO(UTSTARCOM_VENDOR_ID, PANTECH_PRODUCT_UML290_VZW, 0xff, 0xfe, 0xff) }, /* WMC */
4665 ++ { USB_DEVICE_AND_INTERFACE_INFO(UTSTARCOM_VENDOR_ID, PANTECH_PRODUCT_UML290_VZW, 0xff, 0xff, 0xff) }, /* DIAG */
4666 + { },
4667 + };
4668 + MODULE_DEVICE_TABLE(usb, id_table);
4669 +diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c
4670 +index 7cf5c3e..c6602d2 100644
4671 +--- a/fs/ecryptfs/crypto.c
4672 ++++ b/fs/ecryptfs/crypto.c
4673 +@@ -417,17 +417,6 @@ static int ecryptfs_encrypt_extent(struct page *enc_extent_page,
4674 + (unsigned long long)(extent_base + extent_offset), rc);
4675 + goto out;
4676 + }
4677 +- if (unlikely(ecryptfs_verbosity > 0)) {
4678 +- ecryptfs_printk(KERN_DEBUG, "Encrypting extent "
4679 +- "with iv:\n");
4680 +- ecryptfs_dump_hex(extent_iv, crypt_stat->iv_bytes);
4681 +- ecryptfs_printk(KERN_DEBUG, "First 8 bytes before "
4682 +- "encryption:\n");
4683 +- ecryptfs_dump_hex((char *)
4684 +- (page_address(page)
4685 +- + (extent_offset * crypt_stat->extent_size)),
4686 +- 8);
4687 +- }
4688 + rc = ecryptfs_encrypt_page_offset(crypt_stat, enc_extent_page, 0,
4689 + page, (extent_offset
4690 + * crypt_stat->extent_size),
4691 +@@ -440,14 +429,6 @@ static int ecryptfs_encrypt_extent(struct page *enc_extent_page,
4692 + goto out;
4693 + }
4694 + rc = 0;
4695 +- if (unlikely(ecryptfs_verbosity > 0)) {
4696 +- ecryptfs_printk(KERN_DEBUG, "Encrypt extent [0x%.16llx]; "
4697 +- "rc = [%d]\n",
4698 +- (unsigned long long)(extent_base + extent_offset), rc);
4699 +- ecryptfs_printk(KERN_DEBUG, "First 8 bytes after "
4700 +- "encryption:\n");
4701 +- ecryptfs_dump_hex((char *)(page_address(enc_extent_page)), 8);
4702 +- }
4703 + out:
4704 + return rc;
4705 + }
4706 +@@ -543,17 +524,6 @@ static int ecryptfs_decrypt_extent(struct page *page,
4707 + (unsigned long long)(extent_base + extent_offset), rc);
4708 + goto out;
4709 + }
4710 +- if (unlikely(ecryptfs_verbosity > 0)) {
4711 +- ecryptfs_printk(KERN_DEBUG, "Decrypting extent "
4712 +- "with iv:\n");
4713 +- ecryptfs_dump_hex(extent_iv, crypt_stat->iv_bytes);
4714 +- ecryptfs_printk(KERN_DEBUG, "First 8 bytes before "
4715 +- "decryption:\n");
4716 +- ecryptfs_dump_hex((char *)
4717 +- (page_address(enc_extent_page)
4718 +- + (extent_offset * crypt_stat->extent_size)),
4719 +- 8);
4720 +- }
4721 + rc = ecryptfs_decrypt_page_offset(crypt_stat, page,
4722 + (extent_offset
4723 + * crypt_stat->extent_size),
4724 +@@ -567,16 +537,6 @@ static int ecryptfs_decrypt_extent(struct page *page,
4725 + goto out;
4726 + }
4727 + rc = 0;
4728 +- if (unlikely(ecryptfs_verbosity > 0)) {
4729 +- ecryptfs_printk(KERN_DEBUG, "Decrypt extent [0x%.16llx]; "
4730 +- "rc = [%d]\n",
4731 +- (unsigned long long)(extent_base + extent_offset), rc);
4732 +- ecryptfs_printk(KERN_DEBUG, "First 8 bytes after "
4733 +- "decryption:\n");
4734 +- ecryptfs_dump_hex((char *)(page_address(page)
4735 +- + (extent_offset
4736 +- * crypt_stat->extent_size)), 8);
4737 +- }
4738 + out:
4739 + return rc;
4740 + }
4741 +@@ -1618,7 +1578,8 @@ int ecryptfs_read_metadata(struct dentry *ecryptfs_dentry)
4742 + rc = ecryptfs_read_xattr_region(page_virt, ecryptfs_inode);
4743 + if (rc) {
4744 + printk(KERN_DEBUG "Valid eCryptfs headers not found in "
4745 +- "file header region or xattr region\n");
4746 ++ "file header region or xattr region, inode %lu\n",
4747 ++ ecryptfs_inode->i_ino);
4748 + rc = -EINVAL;
4749 + goto out;
4750 + }
4751 +@@ -1627,7 +1588,8 @@ int ecryptfs_read_metadata(struct dentry *ecryptfs_dentry)
4752 + ECRYPTFS_DONT_VALIDATE_HEADER_SIZE);
4753 + if (rc) {
4754 + printk(KERN_DEBUG "Valid eCryptfs headers not found in "
4755 +- "file xattr region either\n");
4756 ++ "file xattr region either, inode %lu\n",
4757 ++ ecryptfs_inode->i_ino);
4758 + rc = -EINVAL;
4759 + }
4760 + if (crypt_stat->mount_crypt_stat->flags
4761 +@@ -1638,7 +1600,8 @@ int ecryptfs_read_metadata(struct dentry *ecryptfs_dentry)
4762 + "crypto metadata only in the extended attribute "
4763 + "region, but eCryptfs was mounted without "
4764 + "xattr support enabled. eCryptfs will not treat "
4765 +- "this like an encrypted file.\n");
4766 ++ "this like an encrypted file, inode %lu\n",
4767 ++ ecryptfs_inode->i_ino);
4768 + rc = -EINVAL;
4769 + }
4770 + }
4771 +diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
4772 +index 4a4fad7f..e3562f2 100644
4773 +--- a/fs/ecryptfs/inode.c
4774 ++++ b/fs/ecryptfs/inode.c
4775 +@@ -854,18 +854,6 @@ static int truncate_upper(struct dentry *dentry, struct iattr *ia,
4776 + size_t num_zeros = (PAGE_CACHE_SIZE
4777 + - (ia->ia_size & ~PAGE_CACHE_MASK));
4778 +
4779 +-
4780 +- /*
4781 +- * XXX(truncate) this should really happen at the begginning
4782 +- * of ->setattr. But the code is too messy to that as part
4783 +- * of a larger patch. ecryptfs is also totally missing out
4784 +- * on the inode_change_ok check at the beginning of
4785 +- * ->setattr while would include this.
4786 +- */
4787 +- rc = inode_newsize_ok(inode, ia->ia_size);
4788 +- if (rc)
4789 +- goto out;
4790 +-
4791 + if (!(crypt_stat->flags & ECRYPTFS_ENCRYPTED)) {
4792 + truncate_setsize(inode, ia->ia_size);
4793 + lower_ia->ia_size = ia->ia_size;
4794 +@@ -915,6 +903,28 @@ out:
4795 + return rc;
4796 + }
4797 +
4798 ++static int ecryptfs_inode_newsize_ok(struct inode *inode, loff_t offset)
4799 ++{
4800 ++ struct ecryptfs_crypt_stat *crypt_stat;
4801 ++ loff_t lower_oldsize, lower_newsize;
4802 ++
4803 ++ crypt_stat = &ecryptfs_inode_to_private(inode)->crypt_stat;
4804 ++ lower_oldsize = upper_size_to_lower_size(crypt_stat,
4805 ++ i_size_read(inode));
4806 ++ lower_newsize = upper_size_to_lower_size(crypt_stat, offset);
4807 ++ if (lower_newsize > lower_oldsize) {
4808 ++ /*
4809 ++ * The eCryptfs inode and the new *lower* size are mixed here
4810 ++ * because we may not have the lower i_mutex held and/or it may
4811 ++ * not be appropriate to call inode_newsize_ok() with inodes
4812 ++ * from other filesystems.
4813 ++ */
4814 ++ return inode_newsize_ok(inode, lower_newsize);
4815 ++ }
4816 ++
4817 ++ return 0;
4818 ++}
4819 ++
4820 + /**
4821 + * ecryptfs_truncate
4822 + * @dentry: The ecryptfs layer dentry
4823 +@@ -931,6 +941,10 @@ int ecryptfs_truncate(struct dentry *dentry, loff_t new_length)
4824 + struct iattr lower_ia = { .ia_valid = 0 };
4825 + int rc;
4826 +
4827 ++ rc = ecryptfs_inode_newsize_ok(dentry->d_inode, new_length);
4828 ++ if (rc)
4829 ++ return rc;
4830 ++
4831 + rc = truncate_upper(dentry, &ia, &lower_ia);
4832 + if (!rc && lower_ia.ia_valid & ATTR_SIZE) {
4833 + struct dentry *lower_dentry = ecryptfs_dentry_to_lower(dentry);
4834 +@@ -1012,6 +1026,16 @@ static int ecryptfs_setattr(struct dentry *dentry, struct iattr *ia)
4835 + }
4836 + }
4837 + mutex_unlock(&crypt_stat->cs_mutex);
4838 ++
4839 ++ rc = inode_change_ok(inode, ia);
4840 ++ if (rc)
4841 ++ goto out;
4842 ++ if (ia->ia_valid & ATTR_SIZE) {
4843 ++ rc = ecryptfs_inode_newsize_ok(inode, ia->ia_size);
4844 ++ if (rc)
4845 ++ goto out;
4846 ++ }
4847 ++
4848 + if (S_ISREG(inode->i_mode)) {
4849 + rc = filemap_write_and_wait(inode->i_mapping);
4850 + if (rc)
4851 +diff --git a/fs/ecryptfs/miscdev.c b/fs/ecryptfs/miscdev.c
4852 +index 940a82e..0dc5a3d 100644
4853 +--- a/fs/ecryptfs/miscdev.c
4854 ++++ b/fs/ecryptfs/miscdev.c
4855 +@@ -409,11 +409,47 @@ ecryptfs_miscdev_write(struct file *file, const char __user *buf,
4856 + ssize_t sz = 0;
4857 + char *data;
4858 + uid_t euid = current_euid();
4859 ++ unsigned char packet_size_peek[3];
4860 + int rc;
4861 +
4862 +- if (count == 0)
4863 ++ if (count == 0) {
4864 + goto out;
4865 ++ } else if (count == (1 + 4)) {
4866 ++ /* Likely a harmless MSG_HELO or MSG_QUIT - no packet length */
4867 ++ goto memdup;
4868 ++ } else if (count < (1 + 4 + 1)
4869 ++ || count > (1 + 4 + 2 + sizeof(struct ecryptfs_message) + 4
4870 ++ + ECRYPTFS_MAX_ENCRYPTED_KEY_BYTES)) {
4871 ++ printk(KERN_WARNING "%s: Acceptable packet size range is "
4872 ++ "[%d-%lu], but amount of data written is [%zu].",
4873 ++ __func__, (1 + 4 + 1),
4874 ++ (1 + 4 + 2 + sizeof(struct ecryptfs_message) + 4
4875 ++ + ECRYPTFS_MAX_ENCRYPTED_KEY_BYTES), count);
4876 ++ return -EINVAL;
4877 ++ }
4878 ++
4879 ++ if (copy_from_user(packet_size_peek, (buf + 1 + 4),
4880 ++ sizeof(packet_size_peek))) {
4881 ++ printk(KERN_WARNING "%s: Error while inspecting packet size\n",
4882 ++ __func__);
4883 ++ return -EFAULT;
4884 ++ }
4885 ++
4886 ++ rc = ecryptfs_parse_packet_length(packet_size_peek, &packet_size,
4887 ++ &packet_size_length);
4888 ++ if (rc) {
4889 ++ printk(KERN_WARNING "%s: Error parsing packet length; "
4890 ++ "rc = [%d]\n", __func__, rc);
4891 ++ return rc;
4892 ++ }
4893 ++
4894 ++ if ((1 + 4 + packet_size_length + packet_size) != count) {
4895 ++ printk(KERN_WARNING "%s: Invalid packet size [%zu]\n", __func__,
4896 ++ packet_size);
4897 ++ return -EINVAL;
4898 ++ }
4899 +
4900 ++memdup:
4901 + data = memdup_user(buf, count);
4902 + if (IS_ERR(data)) {
4903 + printk(KERN_ERR "%s: memdup_user returned error [%ld]\n",
4904 +@@ -435,23 +471,7 @@ ecryptfs_miscdev_write(struct file *file, const char __user *buf,
4905 + }
4906 + memcpy(&counter_nbo, &data[i], 4);
4907 + seq = be32_to_cpu(counter_nbo);
4908 +- i += 4;
4909 +- rc = ecryptfs_parse_packet_length(&data[i], &packet_size,
4910 +- &packet_size_length);
4911 +- if (rc) {
4912 +- printk(KERN_WARNING "%s: Error parsing packet length; "
4913 +- "rc = [%d]\n", __func__, rc);
4914 +- goto out_free;
4915 +- }
4916 +- i += packet_size_length;
4917 +- if ((1 + 4 + packet_size_length + packet_size) != count) {
4918 +- printk(KERN_WARNING "%s: (1 + packet_size_length([%zd])"
4919 +- " + packet_size([%zd]))([%zd]) != "
4920 +- "count([%zd]). Invalid packet format.\n",
4921 +- __func__, packet_size_length, packet_size,
4922 +- (1 + packet_size_length + packet_size), count);
4923 +- goto out_free;
4924 +- }
4925 ++ i += 4 + packet_size_length;
4926 + rc = ecryptfs_miscdev_response(&data[i], packet_size,
4927 + euid, current_user_ns(),
4928 + task_pid(current), seq);
4929 +diff --git a/fs/ecryptfs/read_write.c b/fs/ecryptfs/read_write.c
4930 +index 3745f7c..54eb14c 100644
4931 +--- a/fs/ecryptfs/read_write.c
4932 ++++ b/fs/ecryptfs/read_write.c
4933 +@@ -132,6 +132,11 @@ int ecryptfs_write(struct inode *ecryptfs_inode, char *data, loff_t offset,
4934 + size_t num_bytes = (PAGE_CACHE_SIZE - start_offset_in_page);
4935 + size_t total_remaining_bytes = ((offset + size) - pos);
4936 +
4937 ++ if (fatal_signal_pending(current)) {
4938 ++ rc = -EINTR;
4939 ++ break;
4940 ++ }
4941 ++
4942 + if (num_bytes > total_remaining_bytes)
4943 + num_bytes = total_remaining_bytes;
4944 + if (pos < offset) {
4945 +@@ -193,15 +198,19 @@ int ecryptfs_write(struct inode *ecryptfs_inode, char *data, loff_t offset,
4946 + }
4947 + pos += num_bytes;
4948 + }
4949 +- if ((offset + size) > ecryptfs_file_size) {
4950 +- i_size_write(ecryptfs_inode, (offset + size));
4951 ++ if (pos > ecryptfs_file_size) {
4952 ++ i_size_write(ecryptfs_inode, pos);
4953 + if (crypt_stat->flags & ECRYPTFS_ENCRYPTED) {
4954 +- rc = ecryptfs_write_inode_size_to_metadata(
4955 ++ int rc2;
4956 ++
4957 ++ rc2 = ecryptfs_write_inode_size_to_metadata(
4958 + ecryptfs_inode);
4959 +- if (rc) {
4960 ++ if (rc2) {
4961 + printk(KERN_ERR "Problem with "
4962 + "ecryptfs_write_inode_size_to_metadata; "
4963 +- "rc = [%d]\n", rc);
4964 ++ "rc = [%d]\n", rc2);
4965 ++ if (!rc)
4966 ++ rc = rc2;
4967 + goto out;
4968 + }
4969 + }
4970 +diff --git a/fs/xfs/linux-2.6/xfs_discard.c b/fs/xfs/linux-2.6/xfs_discard.c
4971 +index 244e797..572494f 100644
4972 +--- a/fs/xfs/linux-2.6/xfs_discard.c
4973 ++++ b/fs/xfs/linux-2.6/xfs_discard.c
4974 +@@ -68,7 +68,7 @@ xfs_trim_extents(
4975 + * Look up the longest btree in the AGF and start with it.
4976 + */
4977 + error = xfs_alloc_lookup_le(cur, 0,
4978 +- XFS_BUF_TO_AGF(agbp)->agf_longest, &i);
4979 ++ be32_to_cpu(XFS_BUF_TO_AGF(agbp)->agf_longest), &i);
4980 + if (error)
4981 + goto out_del_cursor;
4982 +
4983 +@@ -84,7 +84,7 @@ xfs_trim_extents(
4984 + if (error)
4985 + goto out_del_cursor;
4986 + XFS_WANT_CORRUPTED_GOTO(i == 1, out_del_cursor);
4987 +- ASSERT(flen <= XFS_BUF_TO_AGF(agbp)->agf_longest);
4988 ++ ASSERT(flen <= be32_to_cpu(XFS_BUF_TO_AGF(agbp)->agf_longest));
4989 +
4990 + /*
4991 + * Too small? Give up.
4992 +diff --git a/fs/xfs/xfs_vnodeops.c b/fs/xfs/xfs_vnodeops.c
4993 +index 6cc4d41..59509ae 100644
4994 +--- a/fs/xfs/xfs_vnodeops.c
4995 ++++ b/fs/xfs/xfs_vnodeops.c
4996 +@@ -554,7 +554,8 @@ xfs_readlink(
4997 + __func__, (unsigned long long) ip->i_ino,
4998 + (long long) pathlen);
4999 + ASSERT(0);
5000 +- return XFS_ERROR(EFSCORRUPTED);
5001 ++ error = XFS_ERROR(EFSCORRUPTED);
5002 ++ goto out;
5003 + }
5004 +
5005 +
5006 +diff --git a/include/drm/drmP.h b/include/drm/drmP.h
5007 +index 738b3a5..40aaebf 100644
5008 +--- a/include/drm/drmP.h
5009 ++++ b/include/drm/drmP.h
5010 +@@ -1323,6 +1323,7 @@ extern int drm_getmagic(struct drm_device *dev, void *data,
5011 + struct drm_file *file_priv);
5012 + extern int drm_authmagic(struct drm_device *dev, void *data,
5013 + struct drm_file *file_priv);
5014 ++extern int drm_remove_magic(struct drm_master *master, drm_magic_t magic);
5015 +
5016 + /* Cache management (drm_cache.c) */
5017 + void drm_clflush_pages(struct page *pages[], unsigned long num_pages);
5018 +diff --git a/include/net/netns/generic.h b/include/net/netns/generic.h
5019 +index 3419bf5..d55f434 100644
5020 +--- a/include/net/netns/generic.h
5021 ++++ b/include/net/netns/generic.h
5022 +@@ -41,6 +41,7 @@ static inline void *net_generic(const struct net *net, int id)
5023 + ptr = ng->ptr[id - 1];
5024 + rcu_read_unlock();
5025 +
5026 ++ BUG_ON(!ptr);
5027 + return ptr;
5028 + }
5029 + #endif
5030 +diff --git a/kernel/printk.c b/kernel/printk.c
5031 +index 084982f..3fc4708 100644
5032 +--- a/kernel/printk.c
5033 ++++ b/kernel/printk.c
5034 +@@ -318,8 +318,10 @@ static int check_syslog_permissions(int type, bool from_file)
5035 + return 0;
5036 + /* For historical reasons, accept CAP_SYS_ADMIN too, with a warning */
5037 + if (capable(CAP_SYS_ADMIN)) {
5038 +- WARN_ONCE(1, "Attempt to access syslog with CAP_SYS_ADMIN "
5039 +- "but no CAP_SYSLOG (deprecated).\n");
5040 ++ printk_once(KERN_WARNING "%s (%d): "
5041 ++ "Attempt to access syslog with CAP_SYS_ADMIN "
5042 ++ "but no CAP_SYSLOG (deprecated).\n",
5043 ++ current->comm, task_pid_nr(current));
5044 + return 0;
5045 + }
5046 + return -EPERM;
5047 +diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
5048 +index ef9271b..9f8e2e1 100644
5049 +--- a/kernel/trace/ftrace.c
5050 ++++ b/kernel/trace/ftrace.c
5051 +@@ -952,7 +952,7 @@ struct ftrace_func_probe {
5052 + };
5053 +
5054 + enum {
5055 +- FTRACE_ENABLE_CALLS = (1 << 0),
5056 ++ FTRACE_UPDATE_CALLS = (1 << 0),
5057 + FTRACE_DISABLE_CALLS = (1 << 1),
5058 + FTRACE_UPDATE_TRACE_FUNC = (1 << 2),
5059 + FTRACE_START_FUNC_RET = (1 << 3),
5060 +@@ -1182,8 +1182,14 @@ alloc_and_copy_ftrace_hash(int size_bits, struct ftrace_hash *hash)
5061 + return NULL;
5062 + }
5063 +
5064 ++static void
5065 ++ftrace_hash_rec_disable(struct ftrace_ops *ops, int filter_hash);
5066 ++static void
5067 ++ftrace_hash_rec_enable(struct ftrace_ops *ops, int filter_hash);
5068 ++
5069 + static int
5070 +-ftrace_hash_move(struct ftrace_hash **dst, struct ftrace_hash *src)
5071 ++ftrace_hash_move(struct ftrace_ops *ops, int enable,
5072 ++ struct ftrace_hash **dst, struct ftrace_hash *src)
5073 + {
5074 + struct ftrace_func_entry *entry;
5075 + struct hlist_node *tp, *tn;
5076 +@@ -1193,9 +1199,16 @@ ftrace_hash_move(struct ftrace_hash **dst, struct ftrace_hash *src)
5077 + unsigned long key;
5078 + int size = src->count;
5079 + int bits = 0;
5080 ++ int ret;
5081 + int i;
5082 +
5083 + /*
5084 ++ * Remove the current set, update the hash and add
5085 ++ * them back.
5086 ++ */
5087 ++ ftrace_hash_rec_disable(ops, enable);
5088 ++
5089 ++ /*
5090 + * If the new source is empty, just free dst and assign it
5091 + * the empty_hash.
5092 + */
5093 +@@ -1215,9 +1228,10 @@ ftrace_hash_move(struct ftrace_hash **dst, struct ftrace_hash *src)
5094 + if (bits > FTRACE_HASH_MAX_BITS)
5095 + bits = FTRACE_HASH_MAX_BITS;
5096 +
5097 ++ ret = -ENOMEM;
5098 + new_hash = alloc_ftrace_hash(bits);
5099 + if (!new_hash)
5100 +- return -ENOMEM;
5101 ++ goto out;
5102 +
5103 + size = 1 << src->size_bits;
5104 + for (i = 0; i < size; i++) {
5105 +@@ -1236,7 +1250,16 @@ ftrace_hash_move(struct ftrace_hash **dst, struct ftrace_hash *src)
5106 + rcu_assign_pointer(*dst, new_hash);
5107 + free_ftrace_hash_rcu(old_hash);
5108 +
5109 +- return 0;
5110 ++ ret = 0;
5111 ++ out:
5112 ++ /*
5113 ++ * Enable regardless of ret:
5114 ++ * On success, we enable the new hash.
5115 ++ * On failure, we re-enable the original hash.
5116 ++ */
5117 ++ ftrace_hash_rec_enable(ops, enable);
5118 ++
5119 ++ return ret;
5120 + }
5121 +
5122 + /*
5123 +@@ -1498,7 +1521,7 @@ int ftrace_text_reserved(void *start, void *end)
5124 +
5125 +
5126 + static int
5127 +-__ftrace_replace_code(struct dyn_ftrace *rec, int enable)
5128 ++__ftrace_replace_code(struct dyn_ftrace *rec, int update)
5129 + {
5130 + unsigned long ftrace_addr;
5131 + unsigned long flag = 0UL;
5132 +@@ -1506,17 +1529,17 @@ __ftrace_replace_code(struct dyn_ftrace *rec, int enable)
5133 + ftrace_addr = (unsigned long)FTRACE_ADDR;
5134 +
5135 + /*
5136 +- * If we are enabling tracing:
5137 ++ * If we are updating calls:
5138 + *
5139 + * If the record has a ref count, then we need to enable it
5140 + * because someone is using it.
5141 + *
5142 + * Otherwise we make sure its disabled.
5143 + *
5144 +- * If we are disabling tracing, then disable all records that
5145 ++ * If we are disabling calls, then disable all records that
5146 + * are enabled.
5147 + */
5148 +- if (enable && (rec->flags & ~FTRACE_FL_MASK))
5149 ++ if (update && (rec->flags & ~FTRACE_FL_MASK))
5150 + flag = FTRACE_FL_ENABLED;
5151 +
5152 + /* If the state of this record hasn't changed, then do nothing */
5153 +@@ -1532,7 +1555,7 @@ __ftrace_replace_code(struct dyn_ftrace *rec, int enable)
5154 + return ftrace_make_nop(NULL, rec, ftrace_addr);
5155 + }
5156 +
5157 +-static void ftrace_replace_code(int enable)
5158 ++static void ftrace_replace_code(int update)
5159 + {
5160 + struct dyn_ftrace *rec;
5161 + struct ftrace_page *pg;
5162 +@@ -1546,7 +1569,7 @@ static void ftrace_replace_code(int enable)
5163 + if (rec->flags & FTRACE_FL_FREE)
5164 + continue;
5165 +
5166 +- failed = __ftrace_replace_code(rec, enable);
5167 ++ failed = __ftrace_replace_code(rec, update);
5168 + if (failed) {
5169 + ftrace_bug(failed, rec->ip);
5170 + /* Stop processing */
5171 +@@ -1596,7 +1619,7 @@ static int __ftrace_modify_code(void *data)
5172 + {
5173 + int *command = data;
5174 +
5175 +- if (*command & FTRACE_ENABLE_CALLS)
5176 ++ if (*command & FTRACE_UPDATE_CALLS)
5177 + ftrace_replace_code(1);
5178 + else if (*command & FTRACE_DISABLE_CALLS)
5179 + ftrace_replace_code(0);
5180 +@@ -1652,7 +1675,7 @@ static int ftrace_startup(struct ftrace_ops *ops, int command)
5181 + return -ENODEV;
5182 +
5183 + ftrace_start_up++;
5184 +- command |= FTRACE_ENABLE_CALLS;
5185 ++ command |= FTRACE_UPDATE_CALLS;
5186 +
5187 + /* ops marked global share the filter hashes */
5188 + if (ops->flags & FTRACE_OPS_FL_GLOBAL) {
5189 +@@ -1704,8 +1727,7 @@ static void ftrace_shutdown(struct ftrace_ops *ops, int command)
5190 + if (ops != &global_ops || !global_start_up)
5191 + ops->flags &= ~FTRACE_OPS_FL_ENABLED;
5192 +
5193 +- if (!ftrace_start_up)
5194 +- command |= FTRACE_DISABLE_CALLS;
5195 ++ command |= FTRACE_UPDATE_CALLS;
5196 +
5197 + if (saved_ftrace_func != ftrace_trace_function) {
5198 + saved_ftrace_func = ftrace_trace_function;
5199 +@@ -1727,7 +1749,7 @@ static void ftrace_startup_sysctl(void)
5200 + saved_ftrace_func = NULL;
5201 + /* ftrace_start_up is true if we want ftrace running */
5202 + if (ftrace_start_up)
5203 +- ftrace_run_update_code(FTRACE_ENABLE_CALLS);
5204 ++ ftrace_run_update_code(FTRACE_UPDATE_CALLS);
5205 + }
5206 +
5207 + static void ftrace_shutdown_sysctl(void)
5208 +@@ -2877,7 +2899,11 @@ ftrace_set_regex(struct ftrace_ops *ops, unsigned char *buf, int len,
5209 + ftrace_match_records(hash, buf, len);
5210 +
5211 + mutex_lock(&ftrace_lock);
5212 +- ret = ftrace_hash_move(orig_hash, hash);
5213 ++ ret = ftrace_hash_move(ops, enable, orig_hash, hash);
5214 ++ if (!ret && ops->flags & FTRACE_OPS_FL_ENABLED
5215 ++ && ftrace_enabled)
5216 ++ ftrace_run_update_code(FTRACE_UPDATE_CALLS);
5217 ++
5218 + mutex_unlock(&ftrace_lock);
5219 +
5220 + mutex_unlock(&ftrace_regex_lock);
5221 +@@ -3060,18 +3086,12 @@ ftrace_regex_release(struct inode *inode, struct file *file)
5222 + orig_hash = &iter->ops->notrace_hash;
5223 +
5224 + mutex_lock(&ftrace_lock);
5225 +- /*
5226 +- * Remove the current set, update the hash and add
5227 +- * them back.
5228 +- */
5229 +- ftrace_hash_rec_disable(iter->ops, filter_hash);
5230 +- ret = ftrace_hash_move(orig_hash, iter->hash);
5231 +- if (!ret) {
5232 +- ftrace_hash_rec_enable(iter->ops, filter_hash);
5233 +- if (iter->ops->flags & FTRACE_OPS_FL_ENABLED
5234 +- && ftrace_enabled)
5235 +- ftrace_run_update_code(FTRACE_ENABLE_CALLS);
5236 +- }
5237 ++ ret = ftrace_hash_move(iter->ops, filter_hash,
5238 ++ orig_hash, iter->hash);
5239 ++ if (!ret && (iter->ops->flags & FTRACE_OPS_FL_ENABLED)
5240 ++ && ftrace_enabled)
5241 ++ ftrace_run_update_code(FTRACE_UPDATE_CALLS);
5242 ++
5243 + mutex_unlock(&ftrace_lock);
5244 + }
5245 + free_ftrace_hash(iter->hash);
5246 +diff --git a/net/caif/caif_dev.c b/net/caif/caif_dev.c
5247 +index dbdaa95..5ba4366 100644
5248 +--- a/net/caif/caif_dev.c
5249 ++++ b/net/caif/caif_dev.c
5250 +@@ -53,7 +53,6 @@ struct cfcnfg *get_cfcnfg(struct net *net)
5251 + struct caif_net *caifn;
5252 + BUG_ON(!net);
5253 + caifn = net_generic(net, caif_net_id);
5254 +- BUG_ON(!caifn);
5255 + return caifn->cfg;
5256 + }
5257 + EXPORT_SYMBOL(get_cfcnfg);
5258 +@@ -63,7 +62,6 @@ static struct caif_device_entry_list *caif_device_list(struct net *net)
5259 + struct caif_net *caifn;
5260 + BUG_ON(!net);
5261 + caifn = net_generic(net, caif_net_id);
5262 +- BUG_ON(!caifn);
5263 + return &caifn->caifdevs;
5264 + }
5265 +
5266 +@@ -92,7 +90,6 @@ static struct caif_device_entry *caif_device_alloc(struct net_device *dev)
5267 + struct caif_device_entry *caifd;
5268 +
5269 + caifdevs = caif_device_list(dev_net(dev));
5270 +- BUG_ON(!caifdevs);
5271 +
5272 + caifd = kzalloc(sizeof(*caifd), GFP_ATOMIC);
5273 + if (!caifd)
5274 +@@ -108,7 +105,7 @@ static struct caif_device_entry *caif_get(struct net_device *dev)
5275 + struct caif_device_entry_list *caifdevs =
5276 + caif_device_list(dev_net(dev));
5277 + struct caif_device_entry *caifd;
5278 +- BUG_ON(!caifdevs);
5279 ++
5280 + list_for_each_entry_rcu(caifd, &caifdevs->list, list) {
5281 + if (caifd->netdev == dev)
5282 + return caifd;
5283 +@@ -349,7 +346,7 @@ static struct notifier_block caif_device_notifier = {
5284 + static int caif_init_net(struct net *net)
5285 + {
5286 + struct caif_net *caifn = net_generic(net, caif_net_id);
5287 +- BUG_ON(!caifn);
5288 ++
5289 + INIT_LIST_HEAD(&caifn->caifdevs.list);
5290 + mutex_init(&caifn->caifdevs.lock);
5291 +
5292 +@@ -414,7 +411,7 @@ static int __init caif_device_init(void)
5293 + {
5294 + int result;
5295 +
5296 +- result = register_pernet_device(&caif_net_ops);
5297 ++ result = register_pernet_subsys(&caif_net_ops);
5298 +
5299 + if (result)
5300 + return result;
5301 +@@ -427,7 +424,7 @@ static int __init caif_device_init(void)
5302 +
5303 + static void __exit caif_device_exit(void)
5304 + {
5305 +- unregister_pernet_device(&caif_net_ops);
5306 ++ unregister_pernet_subsys(&caif_net_ops);
5307 + unregister_netdevice_notifier(&caif_device_notifier);
5308 + dev_remove_pack(&caif_packet_type);
5309 + }
5310 +diff --git a/net/caif/cfcnfg.c b/net/caif/cfcnfg.c
5311 +index 52fe33b..bca32d7 100644
5312 +--- a/net/caif/cfcnfg.c
5313 ++++ b/net/caif/cfcnfg.c
5314 +@@ -313,7 +313,6 @@ int caif_connect_client(struct net *net, struct caif_connect_request *conn_req,
5315 + int err;
5316 + struct cfctrl_link_param param;
5317 + struct cfcnfg *cfg = get_cfcnfg(net);
5318 +- caif_assert(cfg != NULL);
5319 +
5320 + rcu_read_lock();
5321 + err = caif_connect_req_to_link_param(cfg, conn_req, &param);
5322 +diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
5323 +index ea489db..0b0211d 100644
5324 +--- a/net/core/net_namespace.c
5325 ++++ b/net/core/net_namespace.c
5326 +@@ -29,6 +29,20 @@ EXPORT_SYMBOL(init_net);
5327 +
5328 + #define INITIAL_NET_GEN_PTRS 13 /* +1 for len +2 for rcu_head */
5329 +
5330 ++static unsigned int max_gen_ptrs = INITIAL_NET_GEN_PTRS;
5331 ++
5332 ++static struct net_generic *net_alloc_generic(void)
5333 ++{
5334 ++ struct net_generic *ng;
5335 ++ size_t generic_size = offsetof(struct net_generic, ptr[max_gen_ptrs]);
5336 ++
5337 ++ ng = kzalloc(generic_size, GFP_KERNEL);
5338 ++ if (ng)
5339 ++ ng->len = max_gen_ptrs;
5340 ++
5341 ++ return ng;
5342 ++}
5343 ++
5344 + static int net_assign_generic(struct net *net, int id, void *data)
5345 + {
5346 + struct net_generic *ng, *old_ng;
5347 +@@ -42,8 +56,7 @@ static int net_assign_generic(struct net *net, int id, void *data)
5348 + if (old_ng->len >= id)
5349 + goto assign;
5350 +
5351 +- ng = kzalloc(sizeof(struct net_generic) +
5352 +- id * sizeof(void *), GFP_KERNEL);
5353 ++ ng = net_alloc_generic();
5354 + if (ng == NULL)
5355 + return -ENOMEM;
5356 +
5357 +@@ -58,7 +71,6 @@ static int net_assign_generic(struct net *net, int id, void *data)
5358 + * the old copy for kfree after a grace period.
5359 + */
5360 +
5361 +- ng->len = id;
5362 + memcpy(&ng->ptr, &old_ng->ptr, old_ng->len * sizeof(void*));
5363 +
5364 + rcu_assign_pointer(net->gen, ng);
5365 +@@ -159,18 +171,6 @@ out_undo:
5366 + goto out;
5367 + }
5368 +
5369 +-static struct net_generic *net_alloc_generic(void)
5370 +-{
5371 +- struct net_generic *ng;
5372 +- size_t generic_size = sizeof(struct net_generic) +
5373 +- INITIAL_NET_GEN_PTRS * sizeof(void *);
5374 +-
5375 +- ng = kzalloc(generic_size, GFP_KERNEL);
5376 +- if (ng)
5377 +- ng->len = INITIAL_NET_GEN_PTRS;
5378 +-
5379 +- return ng;
5380 +-}
5381 +
5382 + #ifdef CONFIG_NET_NS
5383 + static struct kmem_cache *net_cachep;
5384 +@@ -481,6 +481,7 @@ again:
5385 + }
5386 + return error;
5387 + }
5388 ++ max_gen_ptrs = max_t(unsigned int, max_gen_ptrs, *ops->id);
5389 + }
5390 + error = __register_pernet_operations(list, ops);
5391 + if (error) {
5392 +diff --git a/net/ipv4/ah4.c b/net/ipv4/ah4.c
5393 +index c7056b2..36d1440 100644
5394 +--- a/net/ipv4/ah4.c
5395 ++++ b/net/ipv4/ah4.c
5396 +@@ -369,8 +369,6 @@ static int ah_input(struct xfrm_state *x, struct sk_buff *skb)
5397 + if (err == -EINPROGRESS)
5398 + goto out;
5399 +
5400 +- if (err == -EBUSY)
5401 +- err = NET_XMIT_DROP;
5402 + goto out_free;
5403 + }
5404 +
5405 +diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
5406 +index 69790aa..53b0125 100644
5407 +--- a/net/ipv4/tcp_ipv4.c
5408 ++++ b/net/ipv4/tcp_ipv4.c
5409 +@@ -630,7 +630,7 @@ static void tcp_v4_send_reset(struct sock *sk, struct sk_buff *skb)
5410 + arg.iov[0].iov_len = sizeof(rep.th);
5411 +
5412 + #ifdef CONFIG_TCP_MD5SIG
5413 +- key = sk ? tcp_v4_md5_do_lookup(sk, ip_hdr(skb)->daddr) : NULL;
5414 ++ key = sk ? tcp_v4_md5_do_lookup(sk, ip_hdr(skb)->saddr) : NULL;
5415 + if (key) {
5416 + rep.opt[0] = htonl((TCPOPT_NOP << 24) |
5417 + (TCPOPT_NOP << 16) |
5418 +diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
5419 +index 882e0b0..faf257b 100644
5420 +--- a/net/ipv4/tcp_output.c
5421 ++++ b/net/ipv4/tcp_output.c
5422 +@@ -1134,11 +1134,9 @@ int tcp_trim_head(struct sock *sk, struct sk_buff *skb, u32 len)
5423 + sk_mem_uncharge(sk, len);
5424 + sock_set_flag(sk, SOCK_QUEUE_SHRUNK);
5425 +
5426 +- /* Any change of skb->len requires recalculation of tso
5427 +- * factor and mss.
5428 +- */
5429 ++ /* Any change of skb->len requires recalculation of tso factor. */
5430 + if (tcp_skb_pcount(skb) > 1)
5431 +- tcp_set_skb_tso_segs(sk, skb, tcp_current_mss(sk));
5432 ++ tcp_set_skb_tso_segs(sk, skb, tcp_skb_mss(skb));
5433 +
5434 + return 0;
5435 + }
5436 +diff --git a/net/ipv6/ah6.c b/net/ipv6/ah6.c
5437 +index 7a33aaa..4c0f894 100644
5438 +--- a/net/ipv6/ah6.c
5439 ++++ b/net/ipv6/ah6.c
5440 +@@ -581,8 +581,6 @@ static int ah6_input(struct xfrm_state *x, struct sk_buff *skb)
5441 + if (err == -EINPROGRESS)
5442 + goto out;
5443 +
5444 +- if (err == -EBUSY)
5445 +- err = NET_XMIT_DROP;
5446 + goto out_free;
5447 + }
5448 +
5449 +diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
5450 +index 296510a..51587a0 100644
5451 +--- a/net/ipv6/tcp_ipv6.c
5452 ++++ b/net/ipv6/tcp_ipv6.c
5453 +@@ -1096,7 +1096,7 @@ static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb)
5454 +
5455 + #ifdef CONFIG_TCP_MD5SIG
5456 + if (sk)
5457 +- key = tcp_v6_md5_do_lookup(sk, &ipv6_hdr(skb)->daddr);
5458 ++ key = tcp_v6_md5_do_lookup(sk, &ipv6_hdr(skb)->saddr);
5459 + #endif
5460 +
5461 + if (th->ack)
5462 +diff --git a/net/l2tp/l2tp_ip.c b/net/l2tp/l2tp_ip.c
5463 +index b6466e7..858ca23 100644
5464 +--- a/net/l2tp/l2tp_ip.c
5465 ++++ b/net/l2tp/l2tp_ip.c
5466 +@@ -393,11 +393,6 @@ static int l2tp_ip_backlog_recv(struct sock *sk, struct sk_buff *skb)
5467 + {
5468 + int rc;
5469 +
5470 +- if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb))
5471 +- goto drop;
5472 +-
5473 +- nf_reset(skb);
5474 +-
5475 + /* Charge it to the socket, dropping if the queue is full. */
5476 + rc = sock_queue_rcv_skb(sk, skb);
5477 + if (rc < 0)
5478 +diff --git a/net/rds/af_rds.c b/net/rds/af_rds.c
5479 +index bb6ad81..424ff62 100644
5480 +--- a/net/rds/af_rds.c
5481 ++++ b/net/rds/af_rds.c
5482 +@@ -68,7 +68,6 @@ static int rds_release(struct socket *sock)
5483 + {
5484 + struct sock *sk = sock->sk;
5485 + struct rds_sock *rs;
5486 +- unsigned long flags;
5487 +
5488 + if (!sk)
5489 + goto out;
5490 +@@ -94,10 +93,10 @@ static int rds_release(struct socket *sock)
5491 + rds_rdma_drop_keys(rs);
5492 + rds_notify_queue_get(rs, NULL);
5493 +
5494 +- spin_lock_irqsave(&rds_sock_lock, flags);
5495 ++ spin_lock_bh(&rds_sock_lock);
5496 + list_del_init(&rs->rs_item);
5497 + rds_sock_count--;
5498 +- spin_unlock_irqrestore(&rds_sock_lock, flags);
5499 ++ spin_unlock_bh(&rds_sock_lock);
5500 +
5501 + rds_trans_put(rs->rs_transport);
5502 +
5503 +@@ -409,7 +408,6 @@ static const struct proto_ops rds_proto_ops = {
5504 +
5505 + static int __rds_create(struct socket *sock, struct sock *sk, int protocol)
5506 + {
5507 +- unsigned long flags;
5508 + struct rds_sock *rs;
5509 +
5510 + sock_init_data(sock, sk);
5511 +@@ -426,10 +424,10 @@ static int __rds_create(struct socket *sock, struct sock *sk, int protocol)
5512 + spin_lock_init(&rs->rs_rdma_lock);
5513 + rs->rs_rdma_keys = RB_ROOT;
5514 +
5515 +- spin_lock_irqsave(&rds_sock_lock, flags);
5516 ++ spin_lock_bh(&rds_sock_lock);
5517 + list_add_tail(&rs->rs_item, &rds_sock_list);
5518 + rds_sock_count++;
5519 +- spin_unlock_irqrestore(&rds_sock_lock, flags);
5520 ++ spin_unlock_bh(&rds_sock_lock);
5521 +
5522 + return 0;
5523 + }
5524 +@@ -471,12 +469,11 @@ static void rds_sock_inc_info(struct socket *sock, unsigned int len,
5525 + {
5526 + struct rds_sock *rs;
5527 + struct rds_incoming *inc;
5528 +- unsigned long flags;
5529 + unsigned int total = 0;
5530 +
5531 + len /= sizeof(struct rds_info_message);
5532 +
5533 +- spin_lock_irqsave(&rds_sock_lock, flags);
5534 ++ spin_lock_bh(&rds_sock_lock);
5535 +
5536 + list_for_each_entry(rs, &rds_sock_list, rs_item) {
5537 + read_lock(&rs->rs_recv_lock);
5538 +@@ -492,7 +489,7 @@ static void rds_sock_inc_info(struct socket *sock, unsigned int len,
5539 + read_unlock(&rs->rs_recv_lock);
5540 + }
5541 +
5542 +- spin_unlock_irqrestore(&rds_sock_lock, flags);
5543 ++ spin_unlock_bh(&rds_sock_lock);
5544 +
5545 + lens->nr = total;
5546 + lens->each = sizeof(struct rds_info_message);
5547 +@@ -504,11 +501,10 @@ static void rds_sock_info(struct socket *sock, unsigned int len,
5548 + {
5549 + struct rds_info_socket sinfo;
5550 + struct rds_sock *rs;
5551 +- unsigned long flags;
5552 +
5553 + len /= sizeof(struct rds_info_socket);
5554 +
5555 +- spin_lock_irqsave(&rds_sock_lock, flags);
5556 ++ spin_lock_bh(&rds_sock_lock);
5557 +
5558 + if (len < rds_sock_count)
5559 + goto out;
5560 +@@ -529,7 +525,7 @@ out:
5561 + lens->nr = rds_sock_count;
5562 + lens->each = sizeof(struct rds_info_socket);
5563 +
5564 +- spin_unlock_irqrestore(&rds_sock_lock, flags);
5565 ++ spin_unlock_bh(&rds_sock_lock);
5566 + }
5567 +
5568 + static void rds_exit(void)
5569 +diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
5570 +index eb0a141..51412e1 100644
5571 +--- a/sound/pci/hda/patch_realtek.c
5572 ++++ b/sound/pci/hda/patch_realtek.c
5573 +@@ -16419,6 +16419,7 @@ static const struct alc_config_preset alc861_presets[] = {
5574 + /* Pin config fixes */
5575 + enum {
5576 + PINFIX_FSC_AMILO_PI1505,
5577 ++ PINFIX_ASUS_A6RP,
5578 + };
5579 +
5580 + static const struct alc_fixup alc861_fixups[] = {
5581 +@@ -16430,9 +16431,19 @@ static const struct alc_fixup alc861_fixups[] = {
5582 + { }
5583 + }
5584 + },
5585 ++ [PINFIX_ASUS_A6RP] = {
5586 ++ .type = ALC_FIXUP_VERBS,
5587 ++ .v.verbs = (const struct hda_verb[]) {
5588 ++ /* node 0x0f VREF seems controlling the master output */
5589 ++ { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 },
5590 ++ { }
5591 ++ },
5592 ++ },
5593 + };
5594 +
5595 + static const struct snd_pci_quirk alc861_fixup_tbl[] = {
5596 ++ SND_PCI_QUIRK(0x1043, 0x1393, "ASUS A6Rp", PINFIX_ASUS_A6RP),
5597 ++ SND_PCI_QUIRK(0x1584, 0x2b01, "Haier W18", PINFIX_ASUS_A6RP),
5598 + SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", PINFIX_FSC_AMILO_PI1505),
5599 + {}
5600 + };
5601 +diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
5602 +index 0d8db75..43d88c7 100644
5603 +--- a/sound/pci/hda/patch_sigmatel.c
5604 ++++ b/sound/pci/hda/patch_sigmatel.c
5605 +@@ -4162,13 +4162,15 @@ static int enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
5606 + return 1;
5607 + }
5608 +
5609 +-static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
5610 ++static int is_nid_out_jack_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
5611 + {
5612 + int i;
5613 + for (i = 0; i < cfg->hp_outs; i++)
5614 + if (cfg->hp_pins[i] == nid)
5615 + return 1; /* nid is a HP-Out */
5616 +-
5617 ++ for (i = 0; i < cfg->line_outs; i++)
5618 ++ if (cfg->line_out_pins[i] == nid)
5619 ++ return 1; /* nid is a line-Out */
5620 + return 0; /* nid is not a HP-Out */
5621 + };
5622 +
5623 +@@ -4354,7 +4356,7 @@ static int stac92xx_init(struct hda_codec *codec)
5624 + continue;
5625 + }
5626 +
5627 +- if (is_nid_hp_pin(cfg, nid))
5628 ++ if (is_nid_out_jack_pin(cfg, nid))
5629 + continue; /* already has an unsol event */
5630 +
5631 + pinctl = snd_hda_codec_read(codec, nid, 0,
5632
5633 Added: genpatches-2.6/trunk/3.0/1019_linux-3.0.20.patch
5634 ===================================================================
5635 --- genpatches-2.6/trunk/3.0/1019_linux-3.0.20.patch (rev 0)
5636 +++ genpatches-2.6/trunk/3.0/1019_linux-3.0.20.patch 2012-02-07 14:13:03 UTC (rev 2084)
5637 @@ -0,0 +1,205 @@
5638 +diff --git a/Makefile b/Makefile
5639 +index 1e57901..c060c58 100644
5640 +--- a/Makefile
5641 ++++ b/Makefile
5642 +@@ -1,6 +1,6 @@
5643 + VERSION = 3
5644 + PATCHLEVEL = 0
5645 +-SUBLEVEL = 19
5646 ++SUBLEVEL = 20
5647 + EXTRAVERSION =
5648 + NAME = Sneaky Weasel
5649 +
5650 +diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
5651 +index d06078d..dfafecb 100644
5652 +--- a/drivers/acpi/pci_root.c
5653 ++++ b/drivers/acpi/pci_root.c
5654 +@@ -595,6 +595,13 @@ static int __devinit acpi_pci_root_add(struct acpi_device *device)
5655 + if (ACPI_SUCCESS(status)) {
5656 + dev_info(root->bus->bridge,
5657 + "ACPI _OSC control (0x%02x) granted\n", flags);
5658 ++ if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_ASPM) {
5659 ++ /*
5660 ++ * We have ASPM control, but the FADT indicates
5661 ++ * that it's unsupported. Clear it.
5662 ++ */
5663 ++ pcie_clear_aspm(root->bus);
5664 ++ }
5665 + } else {
5666 + dev_info(root->bus->bridge,
5667 + "ACPI _OSC request failed (%s), "
5668 +diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
5669 +index d36f41e..56b04bc 100644
5670 +--- a/drivers/pci/pci-acpi.c
5671 ++++ b/drivers/pci/pci-acpi.c
5672 +@@ -393,7 +393,6 @@ static int __init acpi_pci_init(void)
5673 +
5674 + if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_ASPM) {
5675 + printk(KERN_INFO"ACPI FADT declares the system doesn't support PCIe ASPM, so disable it\n");
5676 +- pcie_clear_aspm();
5677 + pcie_no_aspm();
5678 + }
5679 +
5680 +diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
5681 +index 6892601..e25af67 100644
5682 +--- a/drivers/pci/pcie/aspm.c
5683 ++++ b/drivers/pci/pcie/aspm.c
5684 +@@ -68,7 +68,7 @@ struct pcie_link_state {
5685 + struct aspm_latency acceptable[8];
5686 + };
5687 +
5688 +-static int aspm_disabled, aspm_force, aspm_clear_state;
5689 ++static int aspm_disabled, aspm_force;
5690 + static bool aspm_support_enabled = true;
5691 + static DEFINE_MUTEX(aspm_lock);
5692 + static LIST_HEAD(link_list);
5693 +@@ -500,9 +500,6 @@ static int pcie_aspm_sanity_check(struct pci_dev *pdev)
5694 + int pos;
5695 + u32 reg32;
5696 +
5697 +- if (aspm_clear_state)
5698 +- return -EINVAL;
5699 +-
5700 + /*
5701 + * Some functions in a slot might not all be PCIe functions,
5702 + * very strange. Disable ASPM for the whole slot
5703 +@@ -574,9 +571,6 @@ void pcie_aspm_init_link_state(struct pci_dev *pdev)
5704 + pdev->pcie_type != PCI_EXP_TYPE_DOWNSTREAM)
5705 + return;
5706 +
5707 +- if (aspm_disabled && !aspm_clear_state)
5708 +- return;
5709 +-
5710 + /* VIA has a strange chipset, root port is under a bridge */
5711 + if (pdev->pcie_type == PCI_EXP_TYPE_ROOT_PORT &&
5712 + pdev->bus->self)
5713 +@@ -608,7 +602,7 @@ void pcie_aspm_init_link_state(struct pci_dev *pdev)
5714 + * the BIOS's expectation, we'll do so once pci_enable_device() is
5715 + * called.
5716 + */
5717 +- if (aspm_policy != POLICY_POWERSAVE || aspm_clear_state) {
5718 ++ if (aspm_policy != POLICY_POWERSAVE) {
5719 + pcie_config_aspm_path(link);
5720 + pcie_set_clkpm(link, policy_to_clkpm_state(link));
5721 + }
5722 +@@ -649,8 +643,7 @@ void pcie_aspm_exit_link_state(struct pci_dev *pdev)
5723 + struct pci_dev *parent = pdev->bus->self;
5724 + struct pcie_link_state *link, *root, *parent_link;
5725 +
5726 +- if ((aspm_disabled && !aspm_clear_state) || !pci_is_pcie(pdev) ||
5727 +- !parent || !parent->link_state)
5728 ++ if (!pci_is_pcie(pdev) || !parent || !parent->link_state)
5729 + return;
5730 + if ((parent->pcie_type != PCI_EXP_TYPE_ROOT_PORT) &&
5731 + (parent->pcie_type != PCI_EXP_TYPE_DOWNSTREAM))
5732 +@@ -734,13 +727,18 @@ void pcie_aspm_powersave_config_link(struct pci_dev *pdev)
5733 + * pci_disable_link_state - disable pci device's link state, so the link will
5734 + * never enter specific states
5735 + */
5736 +-static void __pci_disable_link_state(struct pci_dev *pdev, int state, bool sem)
5737 ++static void __pci_disable_link_state(struct pci_dev *pdev, int state, bool sem,
5738 ++ bool force)
5739 + {
5740 + struct pci_dev *parent = pdev->bus->self;
5741 + struct pcie_link_state *link;
5742 +
5743 +- if (aspm_disabled || !pci_is_pcie(pdev))
5744 ++ if (aspm_disabled && !force)
5745 ++ return;
5746 ++
5747 ++ if (!pci_is_pcie(pdev))
5748 + return;
5749 ++
5750 + if (pdev->pcie_type == PCI_EXP_TYPE_ROOT_PORT ||
5751 + pdev->pcie_type == PCI_EXP_TYPE_DOWNSTREAM)
5752 + parent = pdev;
5753 +@@ -768,16 +766,31 @@ static void __pci_disable_link_state(struct pci_dev *pdev, int state, bool sem)
5754 +
5755 + void pci_disable_link_state_locked(struct pci_dev *pdev, int state)
5756 + {
5757 +- __pci_disable_link_state(pdev, state, false);
5758 ++ __pci_disable_link_state(pdev, state, false, false);
5759 + }
5760 + EXPORT_SYMBOL(pci_disable_link_state_locked);
5761 +
5762 + void pci_disable_link_state(struct pci_dev *pdev, int state)
5763 + {
5764 +- __pci_disable_link_state(pdev, state, true);
5765 ++ __pci_disable_link_state(pdev, state, true, false);
5766 + }
5767 + EXPORT_SYMBOL(pci_disable_link_state);
5768 +
5769 ++void pcie_clear_aspm(struct pci_bus *bus)
5770 ++{
5771 ++ struct pci_dev *child;
5772 ++
5773 ++ /*
5774 ++ * Clear any ASPM setup that the firmware has carried out on this bus
5775 ++ */
5776 ++ list_for_each_entry(child, &bus->devices, bus_list) {
5777 ++ __pci_disable_link_state(child, PCIE_LINK_STATE_L0S |
5778 ++ PCIE_LINK_STATE_L1 |
5779 ++ PCIE_LINK_STATE_CLKPM,
5780 ++ false, true);
5781 ++ }
5782 ++}
5783 ++
5784 + static int pcie_aspm_set_policy(const char *val, struct kernel_param *kp)
5785 + {
5786 + int i;
5787 +@@ -935,6 +948,7 @@ void pcie_aspm_remove_sysfs_dev_files(struct pci_dev *pdev)
5788 + static int __init pcie_aspm_disable(char *str)
5789 + {
5790 + if (!strcmp(str, "off")) {
5791 ++ aspm_policy = POLICY_DEFAULT;
5792 + aspm_disabled = 1;
5793 + aspm_support_enabled = false;
5794 + printk(KERN_INFO "PCIe ASPM is disabled\n");
5795 +@@ -947,16 +961,18 @@ static int __init pcie_aspm_disable(char *str)
5796 +
5797 + __setup("pcie_aspm=", pcie_aspm_disable);
5798 +
5799 +-void pcie_clear_aspm(void)
5800 +-{
5801 +- if (!aspm_force)
5802 +- aspm_clear_state = 1;
5803 +-}
5804 +-
5805 + void pcie_no_aspm(void)
5806 + {
5807 +- if (!aspm_force)
5808 ++ /*
5809 ++ * Disabling ASPM is intended to prevent the kernel from modifying
5810 ++ * existing hardware state, not to clear existing state. To that end:
5811 ++ * (a) set policy to POLICY_DEFAULT in order to avoid changing state
5812 ++ * (b) prevent userspace from changing policy
5813 ++ */
5814 ++ if (!aspm_force) {
5815 ++ aspm_policy = POLICY_DEFAULT;
5816 + aspm_disabled = 1;
5817 ++ }
5818 + }
5819 +
5820 + /**
5821 +diff --git a/include/linux/pci-aspm.h b/include/linux/pci-aspm.h
5822 +index 7cea7b6..c832014 100644
5823 +--- a/include/linux/pci-aspm.h
5824 ++++ b/include/linux/pci-aspm.h
5825 +@@ -29,7 +29,7 @@ extern void pcie_aspm_pm_state_change(struct pci_dev *pdev);
5826 + extern void pcie_aspm_powersave_config_link(struct pci_dev *pdev);
5827 + extern void pci_disable_link_state(struct pci_dev *pdev, int state);
5828 + extern void pci_disable_link_state_locked(struct pci_dev *pdev, int state);
5829 +-extern void pcie_clear_aspm(void);
5830 ++extern void pcie_clear_aspm(struct pci_bus *bus);
5831 + extern void pcie_no_aspm(void);
5832 + #else
5833 + static inline void pcie_aspm_init_link_state(struct pci_dev *pdev)
5834 +@@ -47,7 +47,7 @@ static inline void pcie_aspm_powersave_config_link(struct pci_dev *pdev)
5835 + static inline void pci_disable_link_state(struct pci_dev *pdev, int state)
5836 + {
5837 + }
5838 +-static inline void pcie_clear_aspm(void)
5839 ++static inline void pcie_clear_aspm(struct pci_bus *bus)
5840 + {
5841 + }
5842 + static inline void pcie_no_aspm(void)