/[linux-patches]/genpatches-2.6/trunk/3.0/1057_linux-3.0.58.patch
Gentoo

Contents of /genpatches-2.6/trunk/3.0/1057_linux-3.0.58.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2267 - (show annotations) (download)
Tue Jan 29 00:51:38 2013 UTC (17 months, 4 weeks ago) by mpagano
File size: 56063 byte(s)
Linux patches 3.0.58, 3.0.59, 3.0.60 and 3.0.61
1 diff --git a/Documentation/networking/ip-sysctl.txt b/Documentation/networking/ip-sysctl.txt
2 index 7d4ecaa..890fce9 100644
3 --- a/Documentation/networking/ip-sysctl.txt
4 +++ b/Documentation/networking/ip-sysctl.txt
5 @@ -534,6 +534,11 @@ tcp_thin_dupack - BOOLEAN
6 Documentation/networking/tcp-thin.txt
7 Default: 0
8
9 +tcp_challenge_ack_limit - INTEGER
10 + Limits number of Challenge ACK sent per second, as recommended
11 + in RFC 5961 (Improving TCP's Robustness to Blind In-Window Attacks)
12 + Default: 100
13 +
14 UDP variables:
15
16 udp_mem - vector of 3 INTEGERs: min, pressure, max
17 diff --git a/Makefile b/Makefile
18 index cc6805f..9564edf 100644
19 --- a/Makefile
20 +++ b/Makefile
21 @@ -1,6 +1,6 @@
22 VERSION = 3
23 PATCHLEVEL = 0
24 -SUBLEVEL = 57
25 +SUBLEVEL = 58
26 EXTRAVERSION =
27 NAME = Sneaky Weasel
28
29 diff --git a/arch/arm/kernel/swp_emulate.c b/arch/arm/kernel/swp_emulate.c
30 index 40ee7e5..0951a32 100644
31 --- a/arch/arm/kernel/swp_emulate.c
32 +++ b/arch/arm/kernel/swp_emulate.c
33 @@ -108,10 +108,12 @@ static void set_segfault(struct pt_regs *regs, unsigned long addr)
34 {
35 siginfo_t info;
36
37 + down_read(&current->mm->mmap_sem);
38 if (find_vma(current->mm, addr) == NULL)
39 info.si_code = SEGV_MAPERR;
40 else
41 info.si_code = SEGV_ACCERR;
42 + up_read(&current->mm->mmap_sem);
43
44 info.si_signo = SIGSEGV;
45 info.si_errno = 0;
46 diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
47 index 594d677..19d9369 100644
48 --- a/arch/arm/mm/mmu.c
49 +++ b/arch/arm/mm/mmu.c
50 @@ -467,7 +467,7 @@ static void __init build_mem_type_table(void)
51 }
52
53 for (i = 0; i < 16; i++) {
54 - unsigned long v = pgprot_val(protection_map[i]);
55 + pteval_t v = pgprot_val(protection_map[i]);
56 protection_map[i] = __pgprot(v | user_pgprot);
57 }
58
59 diff --git a/arch/cris/include/asm/io.h b/arch/cris/include/asm/io.h
60 index 32567bc..ac12ae2 100644
61 --- a/arch/cris/include/asm/io.h
62 +++ b/arch/cris/include/asm/io.h
63 @@ -133,12 +133,39 @@ static inline void writel(unsigned int b, volatile void __iomem *addr)
64 #define insb(port,addr,count) (cris_iops ? cris_iops->read_io(port,addr,1,count) : 0)
65 #define insw(port,addr,count) (cris_iops ? cris_iops->read_io(port,addr,2,count) : 0)
66 #define insl(port,addr,count) (cris_iops ? cris_iops->read_io(port,addr,4,count) : 0)
67 -#define outb(data,port) if (cris_iops) cris_iops->write_io(port,(void*)(unsigned)data,1,1)
68 -#define outw(data,port) if (cris_iops) cris_iops->write_io(port,(void*)(unsigned)data,2,1)
69 -#define outl(data,port) if (cris_iops) cris_iops->write_io(port,(void*)(unsigned)data,4,1)
70 -#define outsb(port,addr,count) if(cris_iops) cris_iops->write_io(port,(void*)addr,1,count)
71 -#define outsw(port,addr,count) if(cris_iops) cris_iops->write_io(port,(void*)addr,2,count)
72 -#define outsl(port,addr,count) if(cris_iops) cris_iops->write_io(port,(void*)addr,3,count)
73 +static inline void outb(unsigned char data, unsigned int port)
74 +{
75 + if (cris_iops)
76 + cris_iops->write_io(port, (void *) &data, 1, 1);
77 +}
78 +static inline void outw(unsigned short data, unsigned int port)
79 +{
80 + if (cris_iops)
81 + cris_iops->write_io(port, (void *) &data, 2, 1);
82 +}
83 +static inline void outl(unsigned int data, unsigned int port)
84 +{
85 + if (cris_iops)
86 + cris_iops->write_io(port, (void *) &data, 4, 1);
87 +}
88 +static inline void outsb(unsigned int port, const void *addr,
89 + unsigned long count)
90 +{
91 + if (cris_iops)
92 + cris_iops->write_io(port, (void *)addr, 1, count);
93 +}
94 +static inline void outsw(unsigned int port, const void *addr,
95 + unsigned long count)
96 +{
97 + if (cris_iops)
98 + cris_iops->write_io(port, (void *)addr, 2, count);
99 +}
100 +static inline void outsl(unsigned int port, const void *addr,
101 + unsigned long count)
102 +{
103 + if (cris_iops)
104 + cris_iops->write_io(port, (void *)addr, 4, count);
105 +}
106
107 /*
108 * Convert a physical pointer to a virtual kernel pointer for /dev/mem
109 diff --git a/arch/sparc/include/asm/hugetlb.h b/arch/sparc/include/asm/hugetlb.h
110 index 1770610..f368cef 100644
111 --- a/arch/sparc/include/asm/hugetlb.h
112 +++ b/arch/sparc/include/asm/hugetlb.h
113 @@ -58,14 +58,20 @@ static inline pte_t huge_pte_wrprotect(pte_t pte)
114 static inline void huge_ptep_set_wrprotect(struct mm_struct *mm,
115 unsigned long addr, pte_t *ptep)
116 {
117 - ptep_set_wrprotect(mm, addr, ptep);
118 + pte_t old_pte = *ptep;
119 + set_huge_pte_at(mm, addr, ptep, pte_wrprotect(old_pte));
120 }
121
122 static inline int huge_ptep_set_access_flags(struct vm_area_struct *vma,
123 unsigned long addr, pte_t *ptep,
124 pte_t pte, int dirty)
125 {
126 - return ptep_set_access_flags(vma, addr, ptep, pte, dirty);
127 + int changed = !pte_same(*ptep, pte);
128 + if (changed) {
129 + set_huge_pte_at(vma->vm_mm, addr, ptep, pte);
130 + flush_tlb_page(vma, addr);
131 + }
132 + return changed;
133 }
134
135 static inline pte_t huge_ptep_get(pte_t *ptep)
136 diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
137 index 8115040..3f4b6da 100644
138 --- a/arch/x86/kernel/cpu/amd.c
139 +++ b/arch/x86/kernel/cpu/amd.c
140 @@ -554,6 +554,20 @@ static void __cpuinit init_amd(struct cpuinfo_x86 *c)
141 }
142 }
143
144 + /*
145 + * The way access filter has a performance penalty on some workloads.
146 + * Disable it on the affected CPUs.
147 + */
148 + if ((c->x86 == 0x15) &&
149 + (c->x86_model >= 0x02) && (c->x86_model < 0x20)) {
150 + u64 val;
151 +
152 + if (!rdmsrl_safe(0xc0011021, &val) && !(val & 0x1E)) {
153 + val |= 0x1E;
154 + checking_wrmsrl(0xc0011021, val);
155 + }
156 + }
157 +
158 cpu_detect_cache_sizes(c);
159
160 /* Multi core CPU? */
161 diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
162 index 449c556..8cb9742 100644
163 --- a/drivers/acpi/scan.c
164 +++ b/drivers/acpi/scan.c
165 @@ -1153,7 +1153,7 @@ static void acpi_device_set_id(struct acpi_device *device)
166 acpi_add_id(device, ACPI_DOCK_HID);
167 else if (!acpi_ibm_smbus_match(device))
168 acpi_add_id(device, ACPI_SMBUS_IBM_HID);
169 - else if (!acpi_device_hid(device) &&
170 + else if (list_empty(&device->pnp.ids) &&
171 ACPI_IS_ROOT_DEVICE(device->parent)) {
172 acpi_add_id(device, ACPI_BUS_HID); /* \_SB, LNXSYBUS */
173 strcpy(device->pnp.device_name, ACPI_BUS_DEVICE_NAME);
174 diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
175 index d452592..adfce9f 100644
176 --- a/drivers/atm/solos-pci.c
177 +++ b/drivers/atm/solos-pci.c
178 @@ -967,10 +967,11 @@ static uint32_t fpga_tx(struct solos_card *card)
179 for (port = 0; tx_pending; tx_pending >>= 1, port++) {
180 if (tx_pending & 1) {
181 struct sk_buff *oldskb = card->tx_skb[port];
182 - if (oldskb)
183 + if (oldskb) {
184 pci_unmap_single(card->dev, SKB_CB(oldskb)->dma_addr,
185 oldskb->len, PCI_DMA_TODEVICE);
186 -
187 + card->tx_skb[port] = NULL;
188 + }
189 spin_lock(&card->tx_queue_lock);
190 skb = skb_dequeue(&card->tx_queue[port]);
191 if (!skb)
192 diff --git a/drivers/bluetooth/ath3k.c b/drivers/bluetooth/ath3k.c
193 index 305e752..85e1ad6 100644
194 --- a/drivers/bluetooth/ath3k.c
195 +++ b/drivers/bluetooth/ath3k.c
196 @@ -65,6 +65,7 @@ static struct usb_device_id ath3k_table[] = {
197 { USB_DEVICE(0x13d3, 0x3304) },
198 { USB_DEVICE(0x0930, 0x0215) },
199 { USB_DEVICE(0x0489, 0xE03D) },
200 + { USB_DEVICE(0x0489, 0xE027) },
201
202 /* Atheros AR9285 Malbec with sflash firmware */
203 { USB_DEVICE(0x03F0, 0x311D) },
204 diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
205 index 71346fe..4b764f8 100644
206 --- a/drivers/bluetooth/btusb.c
207 +++ b/drivers/bluetooth/btusb.c
208 @@ -130,6 +130,7 @@ static struct usb_device_id blacklist_table[] = {
209 { USB_DEVICE(0x13d3, 0x3304), .driver_info = BTUSB_IGNORE },
210 { USB_DEVICE(0x0930, 0x0215), .driver_info = BTUSB_IGNORE },
211 { USB_DEVICE(0x0489, 0xe03d), .driver_info = BTUSB_IGNORE },
212 + { USB_DEVICE(0x0489, 0xe027), .driver_info = BTUSB_IGNORE },
213
214 /* Atheros AR9285 Malbec with sflash firmware */
215 { USB_DEVICE(0x03f0, 0x311d), .driver_info = BTUSB_IGNORE },
216 diff --git a/drivers/input/joystick/walkera0701.c b/drivers/input/joystick/walkera0701.c
217 index 4dfa1ee..f8f892b 100644
218 --- a/drivers/input/joystick/walkera0701.c
219 +++ b/drivers/input/joystick/walkera0701.c
220 @@ -196,6 +196,7 @@ static void walkera0701_close(struct input_dev *dev)
221 struct walkera_dev *w = input_get_drvdata(dev);
222
223 parport_disable_irq(w->parport);
224 + hrtimer_cancel(&w->timer);
225 }
226
227 static int walkera0701_connect(struct walkera_dev *w, int parport)
228 @@ -224,6 +225,9 @@ static int walkera0701_connect(struct walkera_dev *w, int parport)
229 if (parport_claim(w->pardevice))
230 goto init_err1;
231
232 + hrtimer_init(&w->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
233 + w->timer.function = timer_handler;
234 +
235 w->input_dev = input_allocate_device();
236 if (!w->input_dev)
237 goto init_err2;
238 @@ -254,8 +258,6 @@ static int walkera0701_connect(struct walkera_dev *w, int parport)
239 if (err)
240 goto init_err3;
241
242 - hrtimer_init(&w->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
243 - w->timer.function = timer_handler;
244 return 0;
245
246 init_err3:
247 @@ -271,7 +273,6 @@ static int walkera0701_connect(struct walkera_dev *w, int parport)
248
249 static void walkera0701_disconnect(struct walkera_dev *w)
250 {
251 - hrtimer_cancel(&w->timer);
252 input_unregister_device(w->input_dev);
253 parport_release(w->pardevice);
254 parport_unregister_device(w->pardevice);
255 diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h
256 index e01fd4c..20153fe 100644
257 --- a/drivers/input/serio/i8042-x86ia64io.h
258 +++ b/drivers/input/serio/i8042-x86ia64io.h
259 @@ -900,6 +900,7 @@ static int __init i8042_platform_init(void)
260 int retval;
261
262 #ifdef CONFIG_X86
263 + u8 a20_on = 0xdf;
264 /* Just return if pre-detection shows no i8042 controller exist */
265 if (!x86_platform.i8042_detect())
266 return -ENODEV;
267 @@ -939,6 +940,14 @@ static int __init i8042_platform_init(void)
268
269 if (dmi_check_system(i8042_dmi_dritek_table))
270 i8042_dritek = true;
271 +
272 + /*
273 + * A20 was already enabled during early kernel init. But some buggy
274 + * BIOSes (in MSI Laptops) require A20 to be enabled using 8042 to
275 + * resume from S3. So we do it here and hope that nothing breaks.
276 + */
277 + i8042_command(&a20_on, 0x10d1);
278 + i8042_command(NULL, 0x00ff); /* Null command for SMM firmware */
279 #endif /* CONFIG_X86 */
280
281 return retval;
282 diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
283 index 504e201..6f8b268 100644
284 --- a/drivers/net/bonding/bond_main.c
285 +++ b/drivers/net/bonding/bond_main.c
286 @@ -1439,6 +1439,8 @@ static void bond_compute_features(struct bonding *bond)
287 struct net_device *bond_dev = bond->dev;
288 u32 vlan_features = BOND_VLAN_FEATURES;
289 unsigned short max_hard_header_len = ETH_HLEN;
290 + unsigned int gso_max_size = GSO_MAX_SIZE;
291 + u16 gso_max_segs = GSO_MAX_SEGS;
292 int i;
293
294 read_lock(&bond->lock);
295 @@ -1452,11 +1454,16 @@ static void bond_compute_features(struct bonding *bond)
296
297 if (slave->dev->hard_header_len > max_hard_header_len)
298 max_hard_header_len = slave->dev->hard_header_len;
299 +
300 + gso_max_size = min(gso_max_size, slave->dev->gso_max_size);
301 + gso_max_segs = min(gso_max_segs, slave->dev->gso_max_segs);
302 }
303
304 done:
305 bond_dev->vlan_features = vlan_features;
306 bond_dev->hard_header_len = max_hard_header_len;
307 + bond_dev->gso_max_segs = gso_max_segs;
308 + netif_set_gso_max_size(bond_dev, gso_max_size);
309
310 read_unlock(&bond->lock);
311
312 diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
313 index 0624610..8a96735 100644
314 --- a/drivers/net/bonding/bond_sysfs.c
315 +++ b/drivers/net/bonding/bond_sysfs.c
316 @@ -1524,6 +1524,7 @@ static ssize_t bonding_store_slaves_active(struct device *d,
317 goto out;
318 }
319
320 + read_lock(&bond->lock);
321 bond_for_each_slave(bond, slave, i) {
322 if (!bond_is_active_slave(slave)) {
323 if (new_value)
324 @@ -1532,6 +1533,7 @@ static ssize_t bonding_store_slaves_active(struct device *d,
325 slave->inactive = 1;
326 }
327 }
328 + read_unlock(&bond->lock);
329 out:
330 return ret;
331 }
332 diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c
333 index d0f8c7e..cc3ea0d 100644
334 --- a/drivers/net/can/dev.c
335 +++ b/drivers/net/can/dev.c
336 @@ -557,8 +557,7 @@ void close_candev(struct net_device *dev)
337 {
338 struct can_priv *priv = netdev_priv(dev);
339
340 - if (del_timer_sync(&priv->restart_timer))
341 - dev_put(dev);
342 + del_timer_sync(&priv->restart_timer);
343 can_flush_echo_skb(dev);
344 }
345 EXPORT_SYMBOL_GPL(close_candev);
346 diff --git a/drivers/net/irda/sir_dev.c b/drivers/net/irda/sir_dev.c
347 index efe05bb..ddec154 100644
348 --- a/drivers/net/irda/sir_dev.c
349 +++ b/drivers/net/irda/sir_dev.c
350 @@ -221,7 +221,7 @@ static void sirdev_config_fsm(struct work_struct *work)
351 break;
352
353 case SIRDEV_STATE_DONGLE_SPEED:
354 - if (dev->dongle_drv->reset) {
355 + if (dev->dongle_drv->set_speed) {
356 ret = dev->dongle_drv->set_speed(dev, fsm->param);
357 if (ret < 0) {
358 fsm->result = ret;
359 diff --git a/drivers/net/ne.c b/drivers/net/ne.c
360 index 1063093..e8ee2bc 100644
361 --- a/drivers/net/ne.c
362 +++ b/drivers/net/ne.c
363 @@ -814,6 +814,7 @@ static int __init ne_drv_probe(struct platform_device *pdev)
364 dev->irq = irq[this_dev];
365 dev->mem_end = bad[this_dev];
366 }
367 + SET_NETDEV_DEV(dev, &pdev->dev);
368 err = do_ne_probe(dev);
369 if (err) {
370 free_netdev(dev);
371 diff --git a/drivers/net/usb/ipheth.c b/drivers/net/usb/ipheth.c
372 index db9b212..ab43674 100644
373 --- a/drivers/net/usb/ipheth.c
374 +++ b/drivers/net/usb/ipheth.c
375 @@ -62,6 +62,7 @@
376 #define USB_PRODUCT_IPAD 0x129a
377 #define USB_PRODUCT_IPHONE_4_VZW 0x129c
378 #define USB_PRODUCT_IPHONE_4S 0x12a0
379 +#define USB_PRODUCT_IPHONE_5 0x12a8
380
381 #define IPHETH_USBINTF_CLASS 255
382 #define IPHETH_USBINTF_SUBCLASS 253
383 @@ -113,6 +114,10 @@ static struct usb_device_id ipheth_table[] = {
384 USB_VENDOR_APPLE, USB_PRODUCT_IPHONE_4S,
385 IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS,
386 IPHETH_USBINTF_PROTO) },
387 + { USB_DEVICE_AND_INTERFACE_INFO(
388 + USB_VENDOR_APPLE, USB_PRODUCT_IPHONE_5,
389 + IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS,
390 + IPHETH_USBINTF_PROTO) },
391 { }
392 };
393 MODULE_DEVICE_TABLE(usb, ipheth_table);
394 diff --git a/drivers/net/wireless/p54/p54usb.c b/drivers/net/wireless/p54/p54usb.c
395 index f44f2f3..f1fa763 100644
396 --- a/drivers/net/wireless/p54/p54usb.c
397 +++ b/drivers/net/wireless/p54/p54usb.c
398 @@ -46,6 +46,7 @@ static struct usb_device_id p54u_table[] = {
399 {USB_DEVICE(0x0411, 0x0050)}, /* Buffalo WLI2-USB2-G54 */
400 {USB_DEVICE(0x045e, 0x00c2)}, /* Microsoft MN-710 */
401 {USB_DEVICE(0x0506, 0x0a11)}, /* 3COM 3CRWE254G72 */
402 + {USB_DEVICE(0x0675, 0x0530)}, /* DrayTek Vigor 530 */
403 {USB_DEVICE(0x06b9, 0x0120)}, /* Thomson SpeedTouch 120g */
404 {USB_DEVICE(0x0707, 0xee06)}, /* SMC 2862W-G */
405 {USB_DEVICE(0x07aa, 0x001c)}, /* Corega CG-WLUSB2GT */
406 @@ -81,6 +82,8 @@ static struct usb_device_id p54u_table[] = {
407 {USB_DEVICE(0x06a9, 0x000e)}, /* Westell 802.11g USB (A90-211WG-01) */
408 {USB_DEVICE(0x06b9, 0x0121)}, /* Thomson SpeedTouch 121g */
409 {USB_DEVICE(0x0707, 0xee13)}, /* SMC 2862W-G version 2 */
410 + {USB_DEVICE(0x0803, 0x4310)}, /* Zoom 4410a */
411 + {USB_DEVICE(0x083a, 0x4503)}, /* T-Com Sinus 154 data II */
412 {USB_DEVICE(0x083a, 0x4521)}, /* Siemens Gigaset USB Adapter 54 version 2 */
413 {USB_DEVICE(0x083a, 0xc501)}, /* Zoom Wireless-G 4410 */
414 {USB_DEVICE(0x083a, 0xf503)}, /* Accton FD7050E ver 1010ec */
415 @@ -100,6 +103,7 @@ static struct usb_device_id p54u_table[] = {
416 {USB_DEVICE(0x13B1, 0x000C)}, /* Linksys WUSB54AG */
417 {USB_DEVICE(0x1413, 0x5400)}, /* Telsey 802.11g USB2.0 Adapter */
418 {USB_DEVICE(0x1435, 0x0427)}, /* Inventel UR054G */
419 + /* {USB_DEVICE(0x15a9, 0x0002)}, * Also SparkLAN WL-682 with 3887 */
420 {USB_DEVICE(0x1668, 0x1050)}, /* Actiontec 802UIG-1 */
421 {USB_DEVICE(0x1740, 0x1000)}, /* Senao NUB-350 */
422 {USB_DEVICE(0x2001, 0x3704)}, /* DLink DWL-G122 rev A2 */
423 diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
424 index a6b07dd..a9b1249 100644
425 --- a/drivers/pci/quirks.c
426 +++ b/drivers/pci/quirks.c
427 @@ -2746,7 +2746,7 @@ static void ricoh_mmc_fixup_r5c832(struct pci_dev *dev)
428 if (PCI_FUNC(dev->devfn))
429 return;
430 /*
431 - * RICOH 0xe823 SD/MMC card reader fails to recognize
432 + * RICOH 0xe822 and 0xe823 SD/MMC card readers fail to recognize
433 * certain types of SD/MMC cards. Lowering the SD base
434 * clock frequency from 200Mhz to 50Mhz fixes this issue.
435 *
436 @@ -2757,7 +2757,8 @@ static void ricoh_mmc_fixup_r5c832(struct pci_dev *dev)
437 * 0xf9 - Key register for 0x150
438 * 0xfc - key register for 0xe1
439 */
440 - if (dev->device == PCI_DEVICE_ID_RICOH_R5CE823) {
441 + if (dev->device == PCI_DEVICE_ID_RICOH_R5CE822 ||
442 + dev->device == PCI_DEVICE_ID_RICOH_R5CE823) {
443 pci_write_config_byte(dev, 0xf9, 0xfc);
444 pci_write_config_byte(dev, 0x150, 0x10);
445 pci_write_config_byte(dev, 0xf9, 0x00);
446 @@ -2784,6 +2785,8 @@ static void ricoh_mmc_fixup_r5c832(struct pci_dev *dev)
447 }
448 DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_R5C832, ricoh_mmc_fixup_r5c832);
449 DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_R5C832, ricoh_mmc_fixup_r5c832);
450 +DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_R5CE822, ricoh_mmc_fixup_r5c832);
451 +DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_R5CE822, ricoh_mmc_fixup_r5c832);
452 DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_R5CE823, ricoh_mmc_fixup_r5c832);
453 DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_R5CE823, ricoh_mmc_fixup_r5c832);
454 #endif /*CONFIG_MMC_RICOH_MMC*/
455 diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c
456 index 3f84f84..8ac530a 100644
457 --- a/drivers/pnp/pnpacpi/core.c
458 +++ b/drivers/pnp/pnpacpi/core.c
459 @@ -57,7 +57,7 @@ static inline int __init is_exclusive_device(struct acpi_device *dev)
460 if (!(('0' <= (c) && (c) <= '9') || ('A' <= (c) && (c) <= 'F'))) \
461 return 0
462 #define TEST_ALPHA(c) \
463 - if (!('@' <= (c) || (c) <= 'Z')) \
464 + if (!('A' <= (c) && (c) <= 'Z')) \
465 return 0
466 static int __init ispnpidacpi(const char *id)
467 {
468 diff --git a/drivers/rtc/rtc-vt8500.c b/drivers/rtc/rtc-vt8500.c
469 index efd6066..8a16f2c 100644
470 --- a/drivers/rtc/rtc-vt8500.c
471 +++ b/drivers/rtc/rtc-vt8500.c
472 @@ -69,7 +69,7 @@
473 | ALARM_SEC_BIT)
474
475 #define VT8500_RTC_CR_ENABLE (1 << 0) /* Enable RTC */
476 -#define VT8500_RTC_CR_24H (1 << 1) /* 24h time format */
477 +#define VT8500_RTC_CR_12H (1 << 1) /* 12h time format */
478 #define VT8500_RTC_CR_SM_ENABLE (1 << 2) /* Enable periodic irqs */
479 #define VT8500_RTC_CR_SM_SEC (1 << 3) /* 0: 1Hz/60, 1: 1Hz */
480 #define VT8500_RTC_CR_CALIB (1 << 4) /* Enable calibration */
481 @@ -116,7 +116,7 @@ static int vt8500_rtc_read_time(struct device *dev, struct rtc_time *tm)
482 tm->tm_min = bcd2bin((time & TIME_MIN_MASK) >> TIME_MIN_S);
483 tm->tm_hour = bcd2bin((time & TIME_HOUR_MASK) >> TIME_HOUR_S);
484 tm->tm_mday = bcd2bin(date & DATE_DAY_MASK);
485 - tm->tm_mon = bcd2bin((date & DATE_MONTH_MASK) >> DATE_MONTH_S);
486 + tm->tm_mon = bcd2bin((date & DATE_MONTH_MASK) >> DATE_MONTH_S) - 1;
487 tm->tm_year = bcd2bin((date & DATE_YEAR_MASK) >> DATE_YEAR_S)
488 + ((date >> DATE_CENTURY_S) & 1 ? 200 : 100);
489 tm->tm_wday = (time & TIME_DOW_MASK) >> TIME_DOW_S;
490 @@ -135,8 +135,9 @@ static int vt8500_rtc_set_time(struct device *dev, struct rtc_time *tm)
491 }
492
493 writel((bin2bcd(tm->tm_year - 100) << DATE_YEAR_S)
494 - | (bin2bcd(tm->tm_mon) << DATE_MONTH_S)
495 - | (bin2bcd(tm->tm_mday)),
496 + | (bin2bcd(tm->tm_mon + 1) << DATE_MONTH_S)
497 + | (bin2bcd(tm->tm_mday))
498 + | ((tm->tm_year >= 200) << DATE_CENTURY_S),
499 vt8500_rtc->regbase + VT8500_RTC_DS);
500 writel((bin2bcd(tm->tm_wday) << TIME_DOW_S)
501 | (bin2bcd(tm->tm_hour) << TIME_HOUR_S)
502 @@ -246,7 +247,7 @@ static int __devinit vt8500_rtc_probe(struct platform_device *pdev)
503 }
504
505 /* Enable RTC and set it to 24-hour mode */
506 - writel(VT8500_RTC_CR_ENABLE | VT8500_RTC_CR_24H,
507 + writel(VT8500_RTC_CR_ENABLE,
508 vt8500_rtc->regbase + VT8500_RTC_CR);
509
510 vt8500_rtc->rtc = rtc_device_register("vt8500-rtc", &pdev->dev,
511 diff --git a/drivers/usb/gadget/f_phonet.c b/drivers/usb/gadget/f_phonet.c
512 index 5e14950..459dbde 100644
513 --- a/drivers/usb/gadget/f_phonet.c
514 +++ b/drivers/usb/gadget/f_phonet.c
515 @@ -541,7 +541,7 @@ int pn_bind(struct usb_configuration *c, struct usb_function *f)
516
517 req = usb_ep_alloc_request(fp->out_ep, GFP_KERNEL);
518 if (!req)
519 - goto err;
520 + goto err_req;
521
522 req->complete = pn_rx_complete;
523 fp->out_reqv[i] = req;
524 @@ -550,14 +550,18 @@ int pn_bind(struct usb_configuration *c, struct usb_function *f)
525 /* Outgoing USB requests */
526 fp->in_req = usb_ep_alloc_request(fp->in_ep, GFP_KERNEL);
527 if (!fp->in_req)
528 - goto err;
529 + goto err_req;
530
531 INFO(cdev, "USB CDC Phonet function\n");
532 INFO(cdev, "using %s, OUT %s, IN %s\n", cdev->gadget->name,
533 fp->out_ep->name, fp->in_ep->name);
534 return 0;
535
536 +err_req:
537 + for (i = 0; i < phonet_rxq_size && fp->out_reqv[i]; i++)
538 + usb_ep_free_request(fp->out_ep, fp->out_reqv[i]);
539 err:
540 +
541 if (fp->out_ep)
542 fp->out_ep->driver_data = NULL;
543 if (fp->in_ep)
544 diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
545 index f768314..175c574 100644
546 --- a/drivers/usb/host/ehci-pci.c
547 +++ b/drivers/usb/host/ehci-pci.c
548 @@ -359,7 +359,8 @@ static bool usb_is_intel_switchable_ehci(struct pci_dev *pdev)
549 pdev->vendor == PCI_VENDOR_ID_INTEL &&
550 (pdev->device == 0x1E26 ||
551 pdev->device == 0x8C2D ||
552 - pdev->device == 0x8C26);
553 + pdev->device == 0x8C26 ||
554 + pdev->device == 0x9C26);
555 }
556
557 static void ehci_enable_xhci_companion(void)
558 diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c
559 index 3f623fb..0f097d3 100644
560 --- a/drivers/usb/host/pci-quirks.c
561 +++ b/drivers/usb/host/pci-quirks.c
562 @@ -721,6 +721,7 @@ static int handshake(void __iomem *ptr, u32 mask, u32 done,
563 }
564
565 #define PCI_DEVICE_ID_INTEL_LYNX_POINT_XHCI 0x8C31
566 +#define PCI_DEVICE_ID_INTEL_LYNX_POINT_LP_XHCI 0x9C31
567
568 bool usb_is_intel_ppt_switchable_xhci(struct pci_dev *pdev)
569 {
570 @@ -734,7 +735,8 @@ bool usb_is_intel_lpt_switchable_xhci(struct pci_dev *pdev)
571 {
572 return pdev->class == PCI_CLASS_SERIAL_USB_XHCI &&
573 pdev->vendor == PCI_VENDOR_ID_INTEL &&
574 - pdev->device == PCI_DEVICE_ID_INTEL_LYNX_POINT_XHCI;
575 + (pdev->device == PCI_DEVICE_ID_INTEL_LYNX_POINT_XHCI ||
576 + pdev->device == PCI_DEVICE_ID_INTEL_LYNX_POINT_LP_XHCI);
577 }
578
579 bool usb_is_intel_switchable_xhci(struct pci_dev *pdev)
580 diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
581 index 68b9136..92bd773 100644
582 --- a/drivers/virtio/virtio_ring.c
583 +++ b/drivers/virtio/virtio_ring.c
584 @@ -120,6 +120,13 @@ static int vring_add_indirect(struct vring_virtqueue *vq,
585 unsigned head;
586 int i;
587
588 + /*
589 + * We require lowmem mappings for the descriptors because
590 + * otherwise virt_to_phys will give us bogus addresses in the
591 + * virtqueue.
592 + */
593 + gfp &= ~(__GFP_HIGHMEM | __GFP_HIGH);
594 +
595 desc = kmalloc((out + in) * sizeof(struct vring_desc), gfp);
596 if (!desc)
597 return -ENOMEM;
598 diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c
599 index 1befe2e..5463952 100644
600 --- a/fs/binfmt_misc.c
601 +++ b/fs/binfmt_misc.c
602 @@ -176,7 +176,10 @@ static int load_misc_binary(struct linux_binprm *bprm, struct pt_regs *regs)
603 goto _error;
604 bprm->argc ++;
605
606 - bprm->interp = iname; /* for binfmt_script */
607 + /* Update interp in case binfmt_script needs it. */
608 + retval = bprm_change_interp(iname, bprm);
609 + if (retval < 0)
610 + goto _error;
611
612 interp_file = open_exec (iname);
613 retval = PTR_ERR (interp_file);
614 diff --git a/fs/binfmt_script.c b/fs/binfmt_script.c
615 index 396a988..e39c18a 100644
616 --- a/fs/binfmt_script.c
617 +++ b/fs/binfmt_script.c
618 @@ -82,7 +82,9 @@ static int load_script(struct linux_binprm *bprm,struct pt_regs *regs)
619 retval = copy_strings_kernel(1, &i_name, bprm);
620 if (retval) return retval;
621 bprm->argc++;
622 - bprm->interp = interp;
623 + retval = bprm_change_interp(interp, bprm);
624 + if (retval < 0)
625 + return retval;
626
627 /*
628 * OK, now restart the process with the interpreter's dentry.
629 diff --git a/fs/exec.c b/fs/exec.c
630 index 044c13f..08f3e4e 100644
631 --- a/fs/exec.c
632 +++ b/fs/exec.c
633 @@ -1192,9 +1192,24 @@ void free_bprm(struct linux_binprm *bprm)
634 mutex_unlock(&current->signal->cred_guard_mutex);
635 abort_creds(bprm->cred);
636 }
637 + /* If a binfmt changed the interp, free it. */
638 + if (bprm->interp != bprm->filename)
639 + kfree(bprm->interp);
640 kfree(bprm);
641 }
642
643 +int bprm_change_interp(char *interp, struct linux_binprm *bprm)
644 +{
645 + /* If a binfmt changed the interp, free it first. */
646 + if (bprm->interp != bprm->filename)
647 + kfree(bprm->interp);
648 + bprm->interp = kstrdup(interp, GFP_KERNEL);
649 + if (!bprm->interp)
650 + return -ENOMEM;
651 + return 0;
652 +}
653 +EXPORT_SYMBOL(bprm_change_interp);
654 +
655 /*
656 * install the new credentials for this executable
657 */
658 diff --git a/fs/nfs/client.c b/fs/nfs/client.c
659 index b3dc2b8..0cb731f 100644
660 --- a/fs/nfs/client.c
661 +++ b/fs/nfs/client.c
662 @@ -673,8 +673,7 @@ static int nfs_create_rpc_client(struct nfs_client *clp,
663 */
664 static void nfs_destroy_server(struct nfs_server *server)
665 {
666 - if (!(server->flags & NFS_MOUNT_LOCAL_FLOCK) ||
667 - !(server->flags & NFS_MOUNT_LOCAL_FCNTL))
668 + if (server->nlm_host)
669 nlmclnt_done(server->nlm_host);
670 }
671
672 diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
673 index 9515bc5..4033264 100644
674 --- a/fs/nfs/dir.c
675 +++ b/fs/nfs/dir.c
676 @@ -1216,11 +1216,14 @@ static int nfs_dentry_delete(const struct dentry *dentry)
677
678 }
679
680 +/* Ensure that we revalidate inode->i_nlink */
681 static void nfs_drop_nlink(struct inode *inode)
682 {
683 spin_lock(&inode->i_lock);
684 - if (inode->i_nlink > 0)
685 - drop_nlink(inode);
686 + /* drop the inode if we're reasonably sure this is the last link */
687 + if (inode->i_nlink == 1)
688 + clear_nlink(inode);
689 + NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ATTR;
690 spin_unlock(&inode->i_lock);
691 }
692
693 @@ -1235,8 +1238,8 @@ static void nfs_dentry_iput(struct dentry *dentry, struct inode *inode)
694 NFS_I(inode)->cache_validity |= NFS_INO_INVALID_DATA;
695
696 if (dentry->d_flags & DCACHE_NFSFS_RENAMED) {
697 - drop_nlink(inode);
698 nfs_complete_unlink(dentry, inode);
699 + nfs_drop_nlink(inode);
700 }
701 iput(inode);
702 }
703 @@ -1788,10 +1791,8 @@ static int nfs_safe_remove(struct dentry *dentry)
704 if (inode != NULL) {
705 nfs_inode_return_delegation(inode);
706 error = NFS_PROTO(dir)->remove(dir, &dentry->d_name);
707 - /* The VFS may want to delete this inode */
708 if (error == 0)
709 nfs_drop_nlink(inode);
710 - nfs_mark_for_revalidate(inode);
711 } else
712 error = NFS_PROTO(dir)->remove(dir, &dentry->d_name);
713 if (error == -ENOENT)
714 diff --git a/fs/nfs/super.c b/fs/nfs/super.c
715 index 23f0223..a5b2419 100644
716 --- a/fs/nfs/super.c
717 +++ b/fs/nfs/super.c
718 @@ -1052,7 +1052,7 @@ static int nfs_get_option_str(substring_t args[], char **option)
719 {
720 kfree(*option);
721 *option = match_strdup(args);
722 - return !option;
723 + return !*option;
724 }
725
726 static int nfs_get_option_ul(substring_t args[], unsigned long *option)
727 diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
728 index f91d589..ecdd18a 100644
729 --- a/fs/nfsd/nfs4xdr.c
730 +++ b/fs/nfsd/nfs4xdr.c
731 @@ -2682,11 +2682,16 @@ nfsd4_encode_read(struct nfsd4_compoundres *resp, __be32 nfserr,
732 len = maxcount;
733 v = 0;
734 while (len > 0) {
735 - pn = resp->rqstp->rq_resused++;
736 + pn = resp->rqstp->rq_resused;
737 + if (!resp->rqstp->rq_respages[pn]) { /* ran out of pages */
738 + maxcount -= len;
739 + break;
740 + }
741 resp->rqstp->rq_vec[v].iov_base =
742 page_address(resp->rqstp->rq_respages[pn]);
743 resp->rqstp->rq_vec[v].iov_len =
744 len < PAGE_SIZE ? len : PAGE_SIZE;
745 + resp->rqstp->rq_resused++;
746 v++;
747 len -= PAGE_SIZE;
748 }
749 @@ -2734,6 +2739,8 @@ nfsd4_encode_readlink(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd
750 return nfserr;
751 if (resp->xbuf->page_len)
752 return nfserr_resource;
753 + if (!resp->rqstp->rq_respages[resp->rqstp->rq_resused])
754 + return nfserr_resource;
755
756 page = page_address(resp->rqstp->rq_respages[resp->rqstp->rq_resused++]);
757
758 @@ -2783,6 +2790,8 @@ nfsd4_encode_readdir(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4
759 return nfserr;
760 if (resp->xbuf->page_len)
761 return nfserr_resource;
762 + if (!resp->rqstp->rq_respages[resp->rqstp->rq_resused])
763 + return nfserr_resource;
764
765 RESERVE_SPACE(8); /* verifier */
766 savep = p;
767 diff --git a/include/asm-generic/tlb.h b/include/asm-generic/tlb.h
768 index e58fa77..34e0274 100644
769 --- a/include/asm-generic/tlb.h
770 +++ b/include/asm-generic/tlb.h
771 @@ -78,6 +78,14 @@ struct mmu_gather_batch {
772 #define MAX_GATHER_BATCH \
773 ((PAGE_SIZE - sizeof(struct mmu_gather_batch)) / sizeof(void *))
774
775 +/*
776 + * Limit the maximum number of mmu_gather batches to reduce a risk of soft
777 + * lockups for non-preemptible kernels on huge machines when a lot of memory
778 + * is zapped during unmapping.
779 + * 10K pages freed at once should be safe even without a preemption point.
780 + */
781 +#define MAX_GATHER_BATCH_COUNT (10000UL/MAX_GATHER_BATCH)
782 +
783 /* struct mmu_gather is an opaque type used by the mm code for passing around
784 * any data needed by arch specific code for tlb_remove_page.
785 */
786 @@ -94,6 +102,7 @@ struct mmu_gather {
787 struct mmu_gather_batch *active;
788 struct mmu_gather_batch local;
789 struct page *__pages[MMU_GATHER_BUNDLE];
790 + unsigned int batch_count;
791 };
792
793 #define HAVE_GENERIC_MMU_GATHER
794 diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
795 index 8845613..384e37f 100644
796 --- a/include/linux/binfmts.h
797 +++ b/include/linux/binfmts.h
798 @@ -126,6 +126,7 @@ extern int setup_arg_pages(struct linux_binprm * bprm,
799 unsigned long stack_top,
800 int executable_stack);
801 extern int bprm_mm_init(struct linux_binprm *bprm);
802 +extern int bprm_change_interp(char *interp, struct linux_binprm *bprm);
803 extern int copy_strings_kernel(int argc, const char *const *argv,
804 struct linux_binprm *bprm);
805 extern int prepare_bprm_creds(struct linux_binprm *bprm);
806 diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
807 index 59e4028..3fd17c2 100644
808 --- a/include/linux/compiler-gcc.h
809 +++ b/include/linux/compiler-gcc.h
810 @@ -50,6 +50,11 @@
811 # define inline inline __attribute__((always_inline))
812 # define __inline__ __inline__ __attribute__((always_inline))
813 # define __inline __inline __attribute__((always_inline))
814 +#else
815 +/* A lot of inline functions can cause havoc with function tracing */
816 +# define inline inline notrace
817 +# define __inline__ __inline__ notrace
818 +# define __inline __inline notrace
819 #endif
820
821 #define __deprecated __attribute__((deprecated))
822 diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
823 index 6081493..cfd7702 100644
824 --- a/include/linux/page-flags.h
825 +++ b/include/linux/page-flags.h
826 @@ -365,7 +365,7 @@ static inline void ClearPageCompound(struct page *page)
827 * pages on the LRU and/or pagecache.
828 */
829 TESTPAGEFLAG(Compound, compound)
830 -__PAGEFLAG(Head, compound)
831 +__SETPAGEFLAG(Head, compound) __CLEARPAGEFLAG(Head, compound)
832
833 /*
834 * PG_reclaim is used in combination with PG_compound to mark the
835 @@ -377,8 +377,14 @@ __PAGEFLAG(Head, compound)
836 * PG_compound & PG_reclaim => Tail page
837 * PG_compound & ~PG_reclaim => Head page
838 */
839 +#define PG_head_mask ((1L << PG_compound))
840 #define PG_head_tail_mask ((1L << PG_compound) | (1L << PG_reclaim))
841
842 +static inline int PageHead(struct page *page)
843 +{
844 + return ((page->flags & PG_head_tail_mask) == PG_head_mask);
845 +}
846 +
847 static inline int PageTail(struct page *page)
848 {
849 return ((page->flags & PG_head_tail_mask) == PG_head_tail_mask);
850 diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
851 index 864daf3..f269c03 100644
852 --- a/include/linux/pci_ids.h
853 +++ b/include/linux/pci_ids.h
854 @@ -1537,6 +1537,7 @@
855 #define PCI_DEVICE_ID_RICOH_RL5C476 0x0476
856 #define PCI_DEVICE_ID_RICOH_RL5C478 0x0478
857 #define PCI_DEVICE_ID_RICOH_R5C822 0x0822
858 +#define PCI_DEVICE_ID_RICOH_R5CE822 0xe822
859 #define PCI_DEVICE_ID_RICOH_R5CE823 0xe823
860 #define PCI_DEVICE_ID_RICOH_R5C832 0x0832
861 #define PCI_DEVICE_ID_RICOH_R5C843 0x0843
862 diff --git a/include/linux/snmp.h b/include/linux/snmp.h
863 index 12b2b18..10360c7 100644
864 --- a/include/linux/snmp.h
865 +++ b/include/linux/snmp.h
866 @@ -209,7 +209,6 @@ enum
867 LINUX_MIB_TCPDSACKOFOSENT, /* TCPDSACKOfoSent */
868 LINUX_MIB_TCPDSACKRECV, /* TCPDSACKRecv */
869 LINUX_MIB_TCPDSACKOFORECV, /* TCPDSACKOfoRecv */
870 - LINUX_MIB_TCPABORTONSYN, /* TCPAbortOnSyn */
871 LINUX_MIB_TCPABORTONDATA, /* TCPAbortOnData */
872 LINUX_MIB_TCPABORTONCLOSE, /* TCPAbortOnClose */
873 LINUX_MIB_TCPABORTONMEMORY, /* TCPAbortOnMemory */
874 @@ -231,6 +230,8 @@ enum
875 LINUX_MIB_TCPDEFERACCEPTDROP,
876 LINUX_MIB_IPRPFILTER, /* IP Reverse Path Filter (rp_filter) */
877 LINUX_MIB_TCPTIMEWAITOVERFLOW, /* TCPTimeWaitOverflow */
878 + LINUX_MIB_TCPCHALLENGEACK, /* TCPChallengeACK */
879 + LINUX_MIB_TCPSYNCHALLENGE, /* TCPSYNChallenge */
880 __LINUX_MIB_MAX
881 };
882
883 diff --git a/include/net/tcp.h b/include/net/tcp.h
884 index cda30ea..b28a49f 100644
885 --- a/include/net/tcp.h
886 +++ b/include/net/tcp.h
887 @@ -246,6 +246,7 @@ extern int sysctl_tcp_max_ssthresh;
888 extern int sysctl_tcp_cookie_size;
889 extern int sysctl_tcp_thin_linear_timeouts;
890 extern int sysctl_tcp_thin_dupack;
891 +extern int sysctl_tcp_challenge_ack_limit;
892
893 extern atomic_long_t tcp_memory_allocated;
894 extern struct percpu_counter tcp_sockets_allocated;
895 diff --git a/kernel/cgroup.c b/kernel/cgroup.c
896 index 69158d5..1749dcd 100644
897 --- a/kernel/cgroup.c
898 +++ b/kernel/cgroup.c
899 @@ -2630,9 +2630,7 @@ static int cgroup_create_dir(struct cgroup *cgrp, struct dentry *dentry,
900 dentry->d_fsdata = cgrp;
901 inc_nlink(parent->d_inode);
902 rcu_assign_pointer(cgrp->dentry, dentry);
903 - dget(dentry);
904 }
905 - dput(dentry);
906
907 return error;
908 }
909 diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
910 index fa4a70e..3e1bdf9 100644
911 --- a/kernel/irq/manage.c
912 +++ b/kernel/irq/manage.c
913 @@ -698,6 +698,7 @@ static void
914 irq_thread_check_affinity(struct irq_desc *desc, struct irqaction *action)
915 {
916 cpumask_var_t mask;
917 + bool valid = true;
918
919 if (!test_and_clear_bit(IRQTF_AFFINITY, &action->thread_flags))
920 return;
921 @@ -712,10 +713,18 @@ irq_thread_check_affinity(struct irq_desc *desc, struct irqaction *action)
922 }
923
924 raw_spin_lock_irq(&desc->lock);
925 - cpumask_copy(mask, desc->irq_data.affinity);
926 + /*
927 + * This code is triggered unconditionally. Check the affinity
928 + * mask pointer. For CPU_MASK_OFFSTACK=n this is optimized out.
929 + */
930 + if (desc->irq_data.affinity)
931 + cpumask_copy(mask, desc->irq_data.affinity);
932 + else
933 + valid = false;
934 raw_spin_unlock_irq(&desc->lock);
935
936 - set_cpus_allowed_ptr(current, mask);
937 + if (valid)
938 + set_cpus_allowed_ptr(current, mask);
939 free_cpumask_var(mask);
940 }
941 #else
942 @@ -925,6 +934,16 @@ __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new)
943 */
944 get_task_struct(t);
945 new->thread = t;
946 + /*
947 + * Tell the thread to set its affinity. This is
948 + * important for shared interrupt handlers as we do
949 + * not invoke setup_affinity() for the secondary
950 + * handlers as everything is already set up. Even for
951 + * interrupts marked with IRQF_NO_BALANCE this is
952 + * correct as we want the thread to move to the cpu(s)
953 + * on which the requesting code placed the interrupt.
954 + */
955 + set_bit(IRQTF_AFFINITY, &new->thread_flags);
956 }
957
958 if (!alloc_cpumask_var(&mask, GFP_KERNEL)) {
959 diff --git a/mm/memory.c b/mm/memory.c
960 index d49b58a..7292acb 100644
961 --- a/mm/memory.c
962 +++ b/mm/memory.c
963 @@ -205,10 +205,14 @@ static int tlb_next_batch(struct mmu_gather *tlb)
964 return 1;
965 }
966
967 + if (tlb->batch_count == MAX_GATHER_BATCH_COUNT)
968 + return 0;
969 +
970 batch = (void *)__get_free_pages(GFP_NOWAIT | __GFP_NOWARN, 0);
971 if (!batch)
972 return 0;
973
974 + tlb->batch_count++;
975 batch->next = NULL;
976 batch->nr = 0;
977 batch->max = MAX_GATHER_BATCH;
978 @@ -235,6 +239,7 @@ void tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, bool fullmm)
979 tlb->local.nr = 0;
980 tlb->local.max = ARRAY_SIZE(tlb->__pages);
981 tlb->active = &tlb->local;
982 + tlb->batch_count = 0;
983
984 #ifdef CONFIG_HAVE_RCU_TABLE_FREE
985 tlb->batch = NULL;
986 diff --git a/mm/mempolicy.c b/mm/mempolicy.c
987 index 04282ba..0367beb 100644
988 --- a/mm/mempolicy.c
989 +++ b/mm/mempolicy.c
990 @@ -2308,8 +2308,7 @@ void numa_default_policy(void)
991 */
992
993 /*
994 - * "local" is pseudo-policy: MPOL_PREFERRED with MPOL_F_LOCAL flag
995 - * Used only for mpol_parse_str() and mpol_to_str()
996 + * "local" is implemented internally by MPOL_PREFERRED with MPOL_F_LOCAL flag.
997 */
998 #define MPOL_LOCAL MPOL_MAX
999 static const char * const policy_modes[] =
1000 @@ -2324,28 +2323,21 @@ static const char * const policy_modes[] =
1001
1002 #ifdef CONFIG_TMPFS
1003 /**
1004 - * mpol_parse_str - parse string to mempolicy
1005 + * mpol_parse_str - parse string to mempolicy, for tmpfs mpol mount option.
1006 * @str: string containing mempolicy to parse
1007 * @mpol: pointer to struct mempolicy pointer, returned on success.
1008 - * @no_context: flag whether to "contextualize" the mempolicy
1009 + * @unused: redundant argument, to be removed later.
1010 *
1011 * Format of input:
1012 * <mode>[=<flags>][:<nodelist>]
1013 *
1014 - * if @no_context is true, save the input nodemask in w.user_nodemask in
1015 - * the returned mempolicy. This will be used to "clone" the mempolicy in
1016 - * a specific context [cpuset] at a later time. Used to parse tmpfs mpol
1017 - * mount option. Note that if 'static' or 'relative' mode flags were
1018 - * specified, the input nodemask will already have been saved. Saving
1019 - * it again is redundant, but safe.
1020 - *
1021 * On success, returns 0, else 1
1022 */
1023 -int mpol_parse_str(char *str, struct mempolicy **mpol, int no_context)
1024 +int mpol_parse_str(char *str, struct mempolicy **mpol, int unused)
1025 {
1026 struct mempolicy *new = NULL;
1027 unsigned short mode;
1028 - unsigned short uninitialized_var(mode_flags);
1029 + unsigned short mode_flags;
1030 nodemask_t nodes;
1031 char *nodelist = strchr(str, ':');
1032 char *flags = strchr(str, '=');
1033 @@ -2433,24 +2425,23 @@ int mpol_parse_str(char *str, struct mempolicy **mpol, int no_context)
1034 if (IS_ERR(new))
1035 goto out;
1036
1037 - if (no_context) {
1038 - /* save for contextualization */
1039 - new->w.user_nodemask = nodes;
1040 - } else {
1041 - int ret;
1042 - NODEMASK_SCRATCH(scratch);
1043 - if (scratch) {
1044 - task_lock(current);
1045 - ret = mpol_set_nodemask(new, &nodes, scratch);
1046 - task_unlock(current);
1047 - } else
1048 - ret = -ENOMEM;
1049 - NODEMASK_SCRATCH_FREE(scratch);
1050 - if (ret) {
1051 - mpol_put(new);
1052 - goto out;
1053 - }
1054 - }
1055 + /*
1056 + * Save nodes for mpol_to_str() to show the tmpfs mount options
1057 + * for /proc/mounts, /proc/pid/mounts and /proc/pid/mountinfo.
1058 + */
1059 + if (mode != MPOL_PREFERRED)
1060 + new->v.nodes = nodes;
1061 + else if (nodelist)
1062 + new->v.preferred_node = first_node(nodes);
1063 + else
1064 + new->flags |= MPOL_F_LOCAL;
1065 +
1066 + /*
1067 + * Save nodes for contextualization: this will be used to "clone"
1068 + * the mempolicy in a specific context [cpuset] at a later time.
1069 + */
1070 + new->w.user_nodemask = nodes;
1071 +
1072 err = 0;
1073
1074 out:
1075 @@ -2470,13 +2461,13 @@ out:
1076 * @buffer: to contain formatted mempolicy string
1077 * @maxlen: length of @buffer
1078 * @pol: pointer to mempolicy to be formatted
1079 - * @no_context: "context free" mempolicy - use nodemask in w.user_nodemask
1080 + * @unused: redundant argument, to be removed later.
1081 *
1082 * Convert a mempolicy into a string.
1083 * Returns the number of characters in buffer (if positive)
1084 * or an error (negative)
1085 */
1086 -int mpol_to_str(char *buffer, int maxlen, struct mempolicy *pol, int no_context)
1087 +int mpol_to_str(char *buffer, int maxlen, struct mempolicy *pol, int unused)
1088 {
1089 char *p = buffer;
1090 int l;
1091 @@ -2502,7 +2493,7 @@ int mpol_to_str(char *buffer, int maxlen, struct mempolicy *pol, int no_context)
1092 case MPOL_PREFERRED:
1093 nodes_clear(nodes);
1094 if (flags & MPOL_F_LOCAL)
1095 - mode = MPOL_LOCAL; /* pseudo-policy */
1096 + mode = MPOL_LOCAL;
1097 else
1098 node_set(pol->v.preferred_node, nodes);
1099 break;
1100 @@ -2510,10 +2501,7 @@ int mpol_to_str(char *buffer, int maxlen, struct mempolicy *pol, int no_context)
1101 case MPOL_BIND:
1102 /* Fall through */
1103 case MPOL_INTERLEAVE:
1104 - if (no_context)
1105 - nodes = pol->w.user_nodemask;
1106 - else
1107 - nodes = pol->v.nodes;
1108 + nodes = pol->v.nodes;
1109 break;
1110
1111 default:
1112 diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
1113 index cb9cb48..7cd0072 100644
1114 --- a/net/bluetooth/hci_core.c
1115 +++ b/net/bluetooth/hci_core.c
1116 @@ -1333,6 +1333,8 @@ int hci_unregister_dev(struct hci_dev *hdev)
1117 for (i = 0; i < NUM_REASSEMBLY; i++)
1118 kfree_skb(hdev->reassembly[i]);
1119
1120 + cancel_work_sync(&hdev->power_on);
1121 +
1122 if (!test_bit(HCI_INIT, &hdev->flags) &&
1123 !test_bit(HCI_SETUP, &hdev->flags))
1124 mgmt_index_removed(hdev->id);
1125 diff --git a/net/ipv4/proc.c b/net/ipv4/proc.c
1126 index b14ec7d..df0f815 100644
1127 --- a/net/ipv4/proc.c
1128 +++ b/net/ipv4/proc.c
1129 @@ -232,7 +232,6 @@ static const struct snmp_mib snmp4_net_list[] = {
1130 SNMP_MIB_ITEM("TCPDSACKOfoSent", LINUX_MIB_TCPDSACKOFOSENT),
1131 SNMP_MIB_ITEM("TCPDSACKRecv", LINUX_MIB_TCPDSACKRECV),
1132 SNMP_MIB_ITEM("TCPDSACKOfoRecv", LINUX_MIB_TCPDSACKOFORECV),
1133 - SNMP_MIB_ITEM("TCPAbortOnSyn", LINUX_MIB_TCPABORTONSYN),
1134 SNMP_MIB_ITEM("TCPAbortOnData", LINUX_MIB_TCPABORTONDATA),
1135 SNMP_MIB_ITEM("TCPAbortOnClose", LINUX_MIB_TCPABORTONCLOSE),
1136 SNMP_MIB_ITEM("TCPAbortOnMemory", LINUX_MIB_TCPABORTONMEMORY),
1137 @@ -254,6 +253,8 @@ static const struct snmp_mib snmp4_net_list[] = {
1138 SNMP_MIB_ITEM("TCPDeferAcceptDrop", LINUX_MIB_TCPDEFERACCEPTDROP),
1139 SNMP_MIB_ITEM("IPReversePathFilter", LINUX_MIB_IPRPFILTER),
1140 SNMP_MIB_ITEM("TCPTimeWaitOverflow", LINUX_MIB_TCPTIMEWAITOVERFLOW),
1141 + SNMP_MIB_ITEM("TCPChallengeACK", LINUX_MIB_TCPCHALLENGEACK),
1142 + SNMP_MIB_ITEM("TCPSYNChallenge", LINUX_MIB_TCPSYNCHALLENGE),
1143 SNMP_MIB_SENTINEL
1144 };
1145
1146 diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
1147 index 57d0752..46b5950 100644
1148 --- a/net/ipv4/sysctl_net_ipv4.c
1149 +++ b/net/ipv4/sysctl_net_ipv4.c
1150 @@ -566,6 +566,13 @@ static struct ctl_table ipv4_table[] = {
1151 .mode = 0644,
1152 .proc_handler = proc_dointvec
1153 },
1154 + {
1155 + .procname = "tcp_challenge_ack_limit",
1156 + .data = &sysctl_tcp_challenge_ack_limit,
1157 + .maxlen = sizeof(int),
1158 + .mode = 0644,
1159 + .proc_handler = proc_dointvec
1160 + },
1161 #ifdef CONFIG_NET_DMA
1162 {
1163 .procname = "tcp_dma_copybreak",
1164 diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
1165 index b76aa2d..56545b9 100644
1166 --- a/net/ipv4/tcp_input.c
1167 +++ b/net/ipv4/tcp_input.c
1168 @@ -86,6 +86,9 @@ int sysctl_tcp_app_win __read_mostly = 31;
1169 int sysctl_tcp_adv_win_scale __read_mostly = 1;
1170 EXPORT_SYMBOL(sysctl_tcp_adv_win_scale);
1171
1172 +/* rfc5961 challenge ack rate limiting */
1173 +int sysctl_tcp_challenge_ack_limit = 100;
1174 +
1175 int sysctl_tcp_stdurg __read_mostly;
1176 int sysctl_tcp_rfc1337 __read_mostly;
1177 int sysctl_tcp_max_orphans __read_mostly = NR_FILE;
1178 @@ -3633,6 +3636,24 @@ static int tcp_process_frto(struct sock *sk, int flag)
1179 return 0;
1180 }
1181
1182 +/* RFC 5961 7 [ACK Throttling] */
1183 +static void tcp_send_challenge_ack(struct sock *sk)
1184 +{
1185 + /* unprotected vars, we dont care of overwrites */
1186 + static u32 challenge_timestamp;
1187 + static unsigned int challenge_count;
1188 + u32 now = jiffies / HZ;
1189 +
1190 + if (now != challenge_timestamp) {
1191 + challenge_timestamp = now;
1192 + challenge_count = 0;
1193 + }
1194 + if (++challenge_count <= sysctl_tcp_challenge_ack_limit) {
1195 + NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPCHALLENGEACK);
1196 + tcp_send_ack(sk);
1197 + }
1198 +}
1199 +
1200 /* This routine deals with incoming acks, but not outgoing ones. */
1201 static int tcp_ack(struct sock *sk, struct sk_buff *skb, int flag)
1202 {
1203 @@ -3649,8 +3670,14 @@ static int tcp_ack(struct sock *sk, struct sk_buff *skb, int flag)
1204 /* If the ack is older than previous acks
1205 * then we can probably ignore it.
1206 */
1207 - if (before(ack, prior_snd_una))
1208 + if (before(ack, prior_snd_una)) {
1209 + /* RFC 5961 5.2 [Blind Data Injection Attack].[Mitigation] */
1210 + if (before(ack, prior_snd_una - tp->max_window)) {
1211 + tcp_send_challenge_ack(sk);
1212 + return -1;
1213 + }
1214 goto old_ack;
1215 + }
1216
1217 /* If the ack includes data we haven't sent yet, discard
1218 * this segment (RFC793 Section 3.9).
1219 @@ -5168,8 +5195,8 @@ out:
1220 /* Does PAWS and seqno based validation of an incoming segment, flags will
1221 * play significant role here.
1222 */
1223 -static int tcp_validate_incoming(struct sock *sk, struct sk_buff *skb,
1224 - struct tcphdr *th, int syn_inerr)
1225 +static bool tcp_validate_incoming(struct sock *sk, struct sk_buff *skb,
1226 + struct tcphdr *th, int syn_inerr)
1227 {
1228 u8 *hash_location;
1229 struct tcp_sock *tp = tcp_sk(sk);
1230 @@ -5194,38 +5221,48 @@ static int tcp_validate_incoming(struct sock *sk, struct sk_buff *skb,
1231 * an acknowledgment should be sent in reply (unless the RST
1232 * bit is set, if so drop the segment and return)".
1233 */
1234 - if (!th->rst)
1235 + if (!th->rst) {
1236 + if (th->syn)
1237 + goto syn_challenge;
1238 tcp_send_dupack(sk, skb);
1239 + }
1240 goto discard;
1241 }
1242
1243 /* Step 2: check RST bit */
1244 if (th->rst) {
1245 - tcp_reset(sk);
1246 + /* RFC 5961 3.2 :
1247 + * If sequence number exactly matches RCV.NXT, then
1248 + * RESET the connection
1249 + * else
1250 + * Send a challenge ACK
1251 + */
1252 + if (TCP_SKB_CB(skb)->seq == tp->rcv_nxt)
1253 + tcp_reset(sk);
1254 + else
1255 + tcp_send_challenge_ack(sk);
1256 goto discard;
1257 }
1258
1259 - /* ts_recent update must be made after we are sure that the packet
1260 - * is in window.
1261 - */
1262 - tcp_replace_ts_recent(tp, TCP_SKB_CB(skb)->seq);
1263 -
1264 /* step 3: check security and precedence [ignored] */
1265
1266 - /* step 4: Check for a SYN in window. */
1267 - if (th->syn && !before(TCP_SKB_CB(skb)->seq, tp->rcv_nxt)) {
1268 + /* step 4: Check for a SYN
1269 + * RFC 5691 4.2 : Send a challenge ack
1270 + */
1271 + if (th->syn) {
1272 +syn_challenge:
1273 if (syn_inerr)
1274 TCP_INC_STATS_BH(sock_net(sk), TCP_MIB_INERRS);
1275 - NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPABORTONSYN);
1276 - tcp_reset(sk);
1277 - return -1;
1278 + NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPSYNCHALLENGE);
1279 + tcp_send_challenge_ack(sk);
1280 + goto discard;
1281 }
1282
1283 - return 1;
1284 + return true;
1285
1286 discard:
1287 __kfree_skb(skb);
1288 - return 0;
1289 + return false;
1290 }
1291
1292 /*
1293 @@ -5255,7 +5292,6 @@ int tcp_rcv_established(struct sock *sk, struct sk_buff *skb,
1294 struct tcphdr *th, unsigned len)
1295 {
1296 struct tcp_sock *tp = tcp_sk(sk);
1297 - int res;
1298
1299 /*
1300 * Header prediction.
1301 @@ -5435,14 +5471,18 @@ slow_path:
1302 * Standard slow path.
1303 */
1304
1305 - res = tcp_validate_incoming(sk, skb, th, 1);
1306 - if (res <= 0)
1307 - return -res;
1308 + if (!tcp_validate_incoming(sk, skb, th, 1))
1309 + return 0;
1310
1311 step5:
1312 if (th->ack && tcp_ack(sk, skb, FLAG_SLOWPATH) < 0)
1313 goto discard;
1314
1315 + /* ts_recent update must be made after we are sure that the packet
1316 + * is in window.
1317 + */
1318 + tcp_replace_ts_recent(tp, TCP_SKB_CB(skb)->seq);
1319 +
1320 tcp_rcv_rtt_measure_ts(sk, skb);
1321
1322 /* Process urgent data. */
1323 @@ -5747,7 +5787,6 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
1324 struct tcp_sock *tp = tcp_sk(sk);
1325 struct inet_connection_sock *icsk = inet_csk(sk);
1326 int queued = 0;
1327 - int res;
1328
1329 tp->rx_opt.saw_tstamp = 0;
1330
1331 @@ -5802,9 +5841,8 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
1332 return 0;
1333 }
1334
1335 - res = tcp_validate_incoming(sk, skb, th, 0);
1336 - if (res <= 0)
1337 - return -res;
1338 + if (!tcp_validate_incoming(sk, skb, th, 0))
1339 + return 0;
1340
1341 /* step 5: check the ACK field */
1342 if (th->ack) {
1343 @@ -5921,6 +5959,11 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
1344 } else
1345 goto discard;
1346
1347 + /* ts_recent update must be made after we are sure that the packet
1348 + * is in window.
1349 + */
1350 + tcp_replace_ts_recent(tp, TCP_SKB_CB(skb)->seq);
1351 +
1352 /* step 6: check the URG bit */
1353 tcp_urg(sk, skb, th);
1354
1355 diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c
1356 index 29b942c..f08b9166 100644
1357 --- a/net/sched/sch_htb.c
1358 +++ b/net/sched/sch_htb.c
1359 @@ -876,7 +876,7 @@ ok:
1360 q->now = psched_get_time();
1361 start_at = jiffies;
1362
1363 - next_event = q->now + 5 * PSCHED_TICKS_PER_SEC;
1364 + next_event = q->now + 5LLU * PSCHED_TICKS_PER_SEC;
1365
1366 for (level = 0; level < TC_HTB_MAXDEPTH; level++) {
1367 /* common case optimization - skip event handler quickly */
1368 diff --git a/net/sctp/chunk.c b/net/sctp/chunk.c
1369 index 6c85564..0018b65 100644
1370 --- a/net/sctp/chunk.c
1371 +++ b/net/sctp/chunk.c
1372 @@ -183,7 +183,7 @@ struct sctp_datamsg *sctp_datamsg_from_user(struct sctp_association *asoc,
1373
1374 msg = sctp_datamsg_new(GFP_KERNEL);
1375 if (!msg)
1376 - return NULL;
1377 + return ERR_PTR(-ENOMEM);
1378
1379 /* Note: Calculate this outside of the loop, so that all fragments
1380 * have the same expiration.
1381 @@ -280,11 +280,14 @@ struct sctp_datamsg *sctp_datamsg_from_user(struct sctp_association *asoc,
1382
1383 chunk = sctp_make_datafrag_empty(asoc, sinfo, len, frag, 0);
1384
1385 - if (!chunk)
1386 + if (!chunk) {
1387 + err = -ENOMEM;
1388 goto errout;
1389 + }
1390 +
1391 err = sctp_user_addto_chunk(chunk, offset, len, msgh->msg_iov);
1392 if (err < 0)
1393 - goto errout;
1394 + goto errout_chunk_free;
1395
1396 offset += len;
1397
1398 @@ -315,8 +318,10 @@ struct sctp_datamsg *sctp_datamsg_from_user(struct sctp_association *asoc,
1399
1400 chunk = sctp_make_datafrag_empty(asoc, sinfo, over, frag, 0);
1401
1402 - if (!chunk)
1403 + if (!chunk) {
1404 + err = -ENOMEM;
1405 goto errout;
1406 + }
1407
1408 err = sctp_user_addto_chunk(chunk, offset, over,msgh->msg_iov);
1409
1410 @@ -324,7 +329,7 @@ struct sctp_datamsg *sctp_datamsg_from_user(struct sctp_association *asoc,
1411 __skb_pull(chunk->skb, (__u8 *)chunk->chunk_hdr
1412 - (__u8 *)chunk->skb->data);
1413 if (err < 0)
1414 - goto errout;
1415 + goto errout_chunk_free;
1416
1417 sctp_datamsg_assign(msg, chunk);
1418 list_add_tail(&chunk->frag_list, &msg->chunks);
1419 @@ -332,6 +337,9 @@ struct sctp_datamsg *sctp_datamsg_from_user(struct sctp_association *asoc,
1420
1421 return msg;
1422
1423 +errout_chunk_free:
1424 + sctp_chunk_free(chunk);
1425 +
1426 errout:
1427 list_for_each_safe(pos, temp, &msg->chunks) {
1428 list_del_init(pos);
1429 @@ -339,7 +347,7 @@ errout:
1430 sctp_chunk_free(chunk);
1431 }
1432 sctp_datamsg_put(msg);
1433 - return NULL;
1434 + return ERR_PTR(err);
1435 }
1436
1437 /* Check whether this message has expired. */
1438 diff --git a/net/sctp/socket.c b/net/sctp/socket.c
1439 index b70a3ee..8ac6d0b 100644
1440 --- a/net/sctp/socket.c
1441 +++ b/net/sctp/socket.c
1442 @@ -1837,8 +1837,8 @@ SCTP_STATIC int sctp_sendmsg(struct kiocb *iocb, struct sock *sk,
1443
1444 /* Break the message into multiple chunks of maximum size. */
1445 datamsg = sctp_datamsg_from_user(asoc, sinfo, msg, msg_len);
1446 - if (!datamsg) {
1447 - err = -ENOMEM;
1448 + if (IS_ERR(datamsg)) {
1449 + err = PTR_ERR(datamsg);
1450 goto out_free;
1451 }
1452
1453 diff --git a/sound/usb/midi.c b/sound/usb/midi.c
1454 index a0fe5dd..4376215 100644
1455 --- a/sound/usb/midi.c
1456 +++ b/sound/usb/midi.c
1457 @@ -115,6 +115,7 @@ struct snd_usb_midi {
1458 struct list_head list;
1459 struct timer_list error_timer;
1460 spinlock_t disc_lock;
1461 + struct rw_semaphore disc_rwsem;
1462 struct mutex mutex;
1463 u32 usb_id;
1464 int next_midi_device;
1465 @@ -124,8 +125,10 @@ struct snd_usb_midi {
1466 struct snd_usb_midi_in_endpoint *in;
1467 } endpoints[MIDI_MAX_ENDPOINTS];
1468 unsigned long input_triggered;
1469 - unsigned int opened;
1470 + bool autopm_reference;
1471 + unsigned int opened[2];
1472 unsigned char disconnected;
1473 + unsigned char input_running;
1474
1475 struct snd_kcontrol *roland_load_ctl;
1476 };
1477 @@ -147,7 +150,6 @@ struct snd_usb_midi_out_endpoint {
1478 struct snd_usb_midi_out_endpoint* ep;
1479 struct snd_rawmidi_substream *substream;
1480 int active;
1481 - bool autopm_reference;
1482 uint8_t cable; /* cable number << 4 */
1483 uint8_t state;
1484 #define STATE_UNKNOWN 0
1485 @@ -1016,29 +1018,58 @@ static void update_roland_altsetting(struct snd_usb_midi* umidi)
1486 snd_usbmidi_input_start(&umidi->list);
1487 }
1488
1489 -static void substream_open(struct snd_rawmidi_substream *substream, int open)
1490 +static int substream_open(struct snd_rawmidi_substream *substream, int dir,
1491 + int open)
1492 {
1493 struct snd_usb_midi* umidi = substream->rmidi->private_data;
1494 struct snd_kcontrol *ctl;
1495 + int err;
1496 +
1497 + down_read(&umidi->disc_rwsem);
1498 + if (umidi->disconnected) {
1499 + up_read(&umidi->disc_rwsem);
1500 + return open ? -ENODEV : 0;
1501 + }
1502
1503 mutex_lock(&umidi->mutex);
1504 if (open) {
1505 - if (umidi->opened++ == 0 && umidi->roland_load_ctl) {
1506 - ctl = umidi->roland_load_ctl;
1507 - ctl->vd[0].access |= SNDRV_CTL_ELEM_ACCESS_INACTIVE;
1508 - snd_ctl_notify(umidi->card,
1509 + if (!umidi->opened[0] && !umidi->opened[1]) {
1510 + err = usb_autopm_get_interface(umidi->iface);
1511 + umidi->autopm_reference = err >= 0;
1512 + if (err < 0 && err != -EACCES) {
1513 + mutex_unlock(&umidi->mutex);
1514 + up_read(&umidi->disc_rwsem);
1515 + return -EIO;
1516 + }
1517 + if (umidi->roland_load_ctl) {
1518 + ctl = umidi->roland_load_ctl;
1519 + ctl->vd[0].access |= SNDRV_CTL_ELEM_ACCESS_INACTIVE;
1520 + snd_ctl_notify(umidi->card,
1521 SNDRV_CTL_EVENT_MASK_INFO, &ctl->id);
1522 - update_roland_altsetting(umidi);
1523 + update_roland_altsetting(umidi);
1524 + }
1525 }
1526 + umidi->opened[dir]++;
1527 + if (umidi->opened[1])
1528 + snd_usbmidi_input_start(&umidi->list);
1529 } else {
1530 - if (--umidi->opened == 0 && umidi->roland_load_ctl) {
1531 - ctl = umidi->roland_load_ctl;
1532 - ctl->vd[0].access &= ~SNDRV_CTL_ELEM_ACCESS_INACTIVE;
1533 - snd_ctl_notify(umidi->card,
1534 + umidi->opened[dir]--;
1535 + if (!umidi->opened[1])
1536 + snd_usbmidi_input_stop(&umidi->list);
1537 + if (!umidi->opened[0] && !umidi->opened[1]) {
1538 + if (umidi->roland_load_ctl) {
1539 + ctl = umidi->roland_load_ctl;
1540 + ctl->vd[0].access &= ~SNDRV_CTL_ELEM_ACCESS_INACTIVE;
1541 + snd_ctl_notify(umidi->card,
1542 SNDRV_CTL_EVENT_MASK_INFO, &ctl->id);
1543 + }
1544 + if (umidi->autopm_reference)
1545 + usb_autopm_put_interface(umidi->iface);
1546 }
1547 }
1548 mutex_unlock(&umidi->mutex);
1549 + up_read(&umidi->disc_rwsem);
1550 + return 0;
1551 }
1552
1553 static int snd_usbmidi_output_open(struct snd_rawmidi_substream *substream)
1554 @@ -1046,7 +1077,6 @@ static int snd_usbmidi_output_open(struct snd_rawmidi_substream *substream)
1555 struct snd_usb_midi* umidi = substream->rmidi->private_data;
1556 struct usbmidi_out_port* port = NULL;
1557 int i, j;
1558 - int err;
1559
1560 for (i = 0; i < MIDI_MAX_ENDPOINTS; ++i)
1561 if (umidi->endpoints[i].out)
1562 @@ -1059,25 +1089,15 @@ static int snd_usbmidi_output_open(struct snd_rawmidi_substream *substream)
1563 snd_BUG();
1564 return -ENXIO;
1565 }
1566 - err = usb_autopm_get_interface(umidi->iface);
1567 - port->autopm_reference = err >= 0;
1568 - if (err < 0 && err != -EACCES)
1569 - return -EIO;
1570 +
1571 substream->runtime->private_data = port;
1572 port->state = STATE_UNKNOWN;
1573 - substream_open(substream, 1);
1574 - return 0;
1575 + return substream_open(substream, 0, 1);
1576 }
1577
1578 static int snd_usbmidi_output_close(struct snd_rawmidi_substream *substream)
1579 {
1580 - struct snd_usb_midi* umidi = substream->rmidi->private_data;
1581 - struct usbmidi_out_port *port = substream->runtime->private_data;
1582 -
1583 - substream_open(substream, 0);
1584 - if (port->autopm_reference)
1585 - usb_autopm_put_interface(umidi->iface);
1586 - return 0;
1587 + return substream_open(substream, 0, 0);
1588 }
1589
1590 static void snd_usbmidi_output_trigger(struct snd_rawmidi_substream *substream, int up)
1591 @@ -1130,14 +1150,12 @@ static void snd_usbmidi_output_drain(struct snd_rawmidi_substream *substream)
1592
1593 static int snd_usbmidi_input_open(struct snd_rawmidi_substream *substream)
1594 {
1595 - substream_open(substream, 1);
1596 - return 0;
1597 + return substream_open(substream, 1, 1);
1598 }
1599
1600 static int snd_usbmidi_input_close(struct snd_rawmidi_substream *substream)
1601 {
1602 - substream_open(substream, 0);
1603 - return 0;
1604 + return substream_open(substream, 1, 0);
1605 }
1606
1607 static void snd_usbmidi_input_trigger(struct snd_rawmidi_substream *substream, int up)
1608 @@ -1386,9 +1404,12 @@ void snd_usbmidi_disconnect(struct list_head* p)
1609 * a timer may submit an URB. To reliably break the cycle
1610 * a flag under lock must be used
1611 */
1612 + down_write(&umidi->disc_rwsem);
1613 spin_lock_irq(&umidi->disc_lock);
1614 umidi->disconnected = 1;
1615 spin_unlock_irq(&umidi->disc_lock);
1616 + up_write(&umidi->disc_rwsem);
1617 +
1618 for (i = 0; i < MIDI_MAX_ENDPOINTS; ++i) {
1619 struct snd_usb_midi_endpoint* ep = &umidi->endpoints[i];
1620 if (ep->out)
1621 @@ -2043,12 +2064,15 @@ void snd_usbmidi_input_stop(struct list_head* p)
1622 unsigned int i, j;
1623
1624 umidi = list_entry(p, struct snd_usb_midi, list);
1625 + if (!umidi->input_running)
1626 + return;
1627 for (i = 0; i < MIDI_MAX_ENDPOINTS; ++i) {
1628 struct snd_usb_midi_endpoint* ep = &umidi->endpoints[i];
1629 if (ep->in)
1630 for (j = 0; j < INPUT_URBS; ++j)
1631 usb_kill_urb(ep->in->urbs[j]);
1632 }
1633 + umidi->input_running = 0;
1634 }
1635
1636 static void snd_usbmidi_input_start_ep(struct snd_usb_midi_in_endpoint* ep)
1637 @@ -2073,8 +2097,11 @@ void snd_usbmidi_input_start(struct list_head* p)
1638 int i;
1639
1640 umidi = list_entry(p, struct snd_usb_midi, list);
1641 + if (umidi->input_running || !umidi->opened[1])
1642 + return;
1643 for (i = 0; i < MIDI_MAX_ENDPOINTS; ++i)
1644 snd_usbmidi_input_start_ep(umidi->endpoints[i].in);
1645 + umidi->input_running = 1;
1646 }
1647
1648 /*
1649 @@ -2100,6 +2127,7 @@ int snd_usbmidi_create(struct snd_card *card,
1650 umidi->usb_protocol_ops = &snd_usbmidi_standard_ops;
1651 init_timer(&umidi->error_timer);
1652 spin_lock_init(&umidi->disc_lock);
1653 + init_rwsem(&umidi->disc_rwsem);
1654 mutex_init(&umidi->mutex);
1655 umidi->usb_id = USB_ID(le16_to_cpu(umidi->dev->descriptor.idVendor),
1656 le16_to_cpu(umidi->dev->descriptor.idProduct));
1657 @@ -2201,9 +2229,6 @@ int snd_usbmidi_create(struct snd_card *card,
1658 }
1659
1660 list_add_tail(&umidi->list, midi_list);
1661 -
1662 - for (i = 0; i < MIDI_MAX_ENDPOINTS; ++i)
1663 - snd_usbmidi_input_start_ep(umidi->endpoints[i].in);
1664 return 0;
1665 }
1666

  ViewVC Help
Powered by ViewVC 1.1.20