aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@suse.de>2011-06-06 11:08:28 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2011-06-06 11:08:38 -0400
commit163baa33552bb1c08b6bf109319505570658a8f3 (patch)
treedb130209cf27ec72ecd5a7121a3c91543badc8f3 /drivers
parenteb7073db1076777496495483854993165e14790f (diff)
parent59c5f46fbe01a00eedf54a23789634438bb80603 (diff)
Merge 3.0-rc2 into tty-linus
This is needed to catch the tty patch revert in the 3.0-rc2 tree. Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/block/nbd.c22
-rw-r--r--drivers/block/paride/pcd.c1
-rw-r--r--drivers/block/virtio_blk.c91
-rw-r--r--drivers/block/xen-blkback/blkback.c10
-rw-r--r--drivers/block/xen-blkback/xenbus.c3
-rw-r--r--drivers/bluetooth/hci_ldisc.c17
-rw-r--r--drivers/cdrom/viocd.c1
-rw-r--r--drivers/char/virtio_console.c5
-rw-r--r--drivers/clocksource/sh_cmt.c12
-rw-r--r--drivers/clocksource/sh_tmu.c12
-rw-r--r--drivers/dma/shdma.c9
-rw-r--r--drivers/hwmon/coretemp.c23
-rw-r--r--drivers/hwmon/max6642.c22
-rw-r--r--drivers/ide/ide-cd.c1
-rw-r--r--drivers/input/serio/serport.c10
-rw-r--r--drivers/isdn/gigaset/ser-gigaset.c8
-rw-r--r--drivers/misc/kgdbts.c5
-rw-r--r--drivers/misc/ti-st/st_core.c6
-rw-r--r--drivers/net/3c509.c14
-rw-r--r--drivers/net/3c59x.c4
-rw-r--r--drivers/net/caif/caif_serial.c6
-rw-r--r--drivers/net/can/flexcan.c5
-rw-r--r--drivers/net/can/slcan.c9
-rw-r--r--drivers/net/davinci_emac.c10
-rw-r--r--drivers/net/depca.c35
-rw-r--r--drivers/net/dm9000.c6
-rw-r--r--drivers/net/hamradio/6pack.c8
-rw-r--r--drivers/net/hamradio/mkiss.c11
-rw-r--r--drivers/net/hp100.c12
-rw-r--r--drivers/net/ibmlana.c4
-rw-r--r--drivers/net/irda/irtty-sir.c16
-rw-r--r--drivers/net/irda/smsc-ircc2.c44
-rw-r--r--drivers/net/ks8842.c2
-rw-r--r--drivers/net/ne3210.c15
-rw-r--r--drivers/net/ppp_async.c6
-rw-r--r--drivers/net/ppp_synctty.c6
-rw-r--r--drivers/net/slip.c11
-rw-r--r--drivers/net/smc-mca.c6
-rw-r--r--drivers/net/tg3.c2
-rw-r--r--drivers/net/tokenring/madgemc.c2
-rw-r--r--drivers/net/tulip/de4x5.c4
-rw-r--r--drivers/net/usb/catc.c2
-rw-r--r--drivers/net/usb/cdc_ncm.c3
-rw-r--r--drivers/net/virtio_net.c2
-rw-r--r--drivers/net/wan/x25_asy.c7
-rw-r--r--drivers/net/wireless/ath/ath9k/Kconfig1
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9002_calib.c2
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9003_eeprom.c10
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9003_phy.c22
-rw-r--r--drivers/net/wireless/ath/ath9k/eeprom_9287.c10
-rw-r--r--drivers/net/wireless/ath/ath9k/hw.c5
-rw-r--r--drivers/net/wireless/ath/ath9k/hw.h2
-rw-r--r--drivers/net/wireless/ath/ath9k/main.c4
-rw-r--r--drivers/net/wireless/ath/ath9k/rc.c3
-rw-r--r--drivers/net/wireless/b43/phy_n.c2
-rw-r--r--drivers/net/wireless/iwlegacy/iwl-4965-lib.c4
-rw-r--r--drivers/net/wireless/iwlegacy/iwl-4965.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-6000.c28
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn.c6
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn.h1
-rw-r--r--drivers/net/wireless/libertas/cmd.c6
-rw-r--r--drivers/net/wireless/mwifiex/sdio.h4
-rw-r--r--drivers/net/wireless/rt2x00/Kconfig1
-rw-r--r--drivers/net/wireless/rtlwifi/pci.c35
-rw-r--r--drivers/net/wireless/wl12xx/conf.h3
-rw-r--r--drivers/net/wireless/wl12xx/main.c1
-rw-r--r--drivers/net/wireless/wl12xx/scan.c49
-rw-r--r--drivers/net/wireless/wl12xx/scan.h3
-rw-r--r--drivers/net/wireless/zd1211rw/zd_usb.c53
-rw-r--r--drivers/pci/dmar.c7
-rw-r--r--drivers/pci/intel-iommu.c240
-rw-r--r--drivers/pci/iova.c12
-rw-r--r--drivers/scsi/scsi_scan.c2
-rw-r--r--drivers/scsi/scsi_sysfs.c1
-rw-r--r--drivers/tty/n_gsm.c6
-rw-r--r--drivers/tty/n_hdlc.c18
-rw-r--r--drivers/tty/n_r3964.c10
-rw-r--r--drivers/tty/n_tty.c61
-rw-r--r--drivers/tty/tty_buffer.c15
-rw-r--r--drivers/tty/vt/selection.c3
-rw-r--r--drivers/vhost/net.c12
-rw-r--r--drivers/vhost/test.c6
-rw-r--r--drivers/vhost/vhost.c138
-rw-r--r--drivers/vhost/vhost.h21
-rw-r--r--drivers/virtio/virtio_balloon.c21
-rw-r--r--drivers/virtio/virtio_ring.c53
86 files changed, 925 insertions, 468 deletions
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index e6fc716aca45..f533f3375e24 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -192,7 +192,8 @@ static int sock_xmit(struct nbd_device *lo, int send, void *buf, int size,
192 if (lo->xmit_timeout) 192 if (lo->xmit_timeout)
193 del_timer_sync(&ti); 193 del_timer_sync(&ti);
194 } else 194 } else
195 result = kernel_recvmsg(sock, &msg, &iov, 1, size, 0); 195 result = kernel_recvmsg(sock, &msg, &iov, 1, size,
196 msg.msg_flags);
196 197
197 if (signal_pending(current)) { 198 if (signal_pending(current)) {
198 siginfo_t info; 199 siginfo_t info;
@@ -753,9 +754,26 @@ static int __init nbd_init(void)
753 return -ENOMEM; 754 return -ENOMEM;
754 755
755 part_shift = 0; 756 part_shift = 0;
756 if (max_part > 0) 757 if (max_part > 0) {
757 part_shift = fls(max_part); 758 part_shift = fls(max_part);
758 759
760 /*
761 * Adjust max_part according to part_shift as it is exported
762 * to user space so that user can know the max number of
763 * partition kernel should be able to manage.
764 *
765 * Note that -1 is required because partition 0 is reserved
766 * for the whole disk.
767 */
768 max_part = (1UL << part_shift) - 1;
769 }
770
771 if ((1UL << part_shift) > DISK_MAX_PARTS)
772 return -EINVAL;
773
774 if (nbds_max > 1UL << (MINORBITS - part_shift))
775 return -EINVAL;
776
759 for (i = 0; i < nbds_max; i++) { 777 for (i = 0; i < nbds_max; i++) {
760 struct gendisk *disk = alloc_disk(1 << part_shift); 778 struct gendisk *disk = alloc_disk(1 << part_shift);
761 if (!disk) 779 if (!disk)
diff --git a/drivers/block/paride/pcd.c b/drivers/block/paride/pcd.c
index a0aabd904a51..46b8136c31bb 100644
--- a/drivers/block/paride/pcd.c
+++ b/drivers/block/paride/pcd.c
@@ -321,7 +321,6 @@ static void pcd_init_units(void)
321 strcpy(disk->disk_name, cd->name); /* umm... */ 321 strcpy(disk->disk_name, cd->name); /* umm... */
322 disk->fops = &pcd_bdops; 322 disk->fops = &pcd_bdops;
323 disk->flags = GENHD_FL_BLOCK_EVENTS_ON_EXCL_WRITE; 323 disk->flags = GENHD_FL_BLOCK_EVENTS_ON_EXCL_WRITE;
324 disk->events = DISK_EVENT_MEDIA_CHANGE;
325 } 324 }
326} 325}
327 326
diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
index 6ecf89cdf006..079c08808d8a 100644
--- a/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c
@@ -6,10 +6,13 @@
6#include <linux/virtio.h> 6#include <linux/virtio.h>
7#include <linux/virtio_blk.h> 7#include <linux/virtio_blk.h>
8#include <linux/scatterlist.h> 8#include <linux/scatterlist.h>
9#include <linux/string_helpers.h>
10#include <scsi/scsi_cmnd.h>
9 11
10#define PART_BITS 4 12#define PART_BITS 4
11 13
12static int major, index; 14static int major, index;
15struct workqueue_struct *virtblk_wq;
13 16
14struct virtio_blk 17struct virtio_blk
15{ 18{
@@ -26,6 +29,9 @@ struct virtio_blk
26 29
27 mempool_t *pool; 30 mempool_t *pool;
28 31
32 /* Process context for config space updates */
33 struct work_struct config_work;
34
29 /* What host tells us, plus 2 for header & tailer. */ 35 /* What host tells us, plus 2 for header & tailer. */
30 unsigned int sg_elems; 36 unsigned int sg_elems;
31 37
@@ -141,7 +147,7 @@ static bool do_req(struct request_queue *q, struct virtio_blk *vblk,
141 num = blk_rq_map_sg(q, vbr->req, vblk->sg + out); 147 num = blk_rq_map_sg(q, vbr->req, vblk->sg + out);
142 148
143 if (vbr->req->cmd_type == REQ_TYPE_BLOCK_PC) { 149 if (vbr->req->cmd_type == REQ_TYPE_BLOCK_PC) {
144 sg_set_buf(&vblk->sg[num + out + in++], vbr->req->sense, 96); 150 sg_set_buf(&vblk->sg[num + out + in++], vbr->req->sense, SCSI_SENSE_BUFFERSIZE);
145 sg_set_buf(&vblk->sg[num + out + in++], &vbr->in_hdr, 151 sg_set_buf(&vblk->sg[num + out + in++], &vbr->in_hdr,
146 sizeof(vbr->in_hdr)); 152 sizeof(vbr->in_hdr));
147 } 153 }
@@ -291,6 +297,46 @@ static ssize_t virtblk_serial_show(struct device *dev,
291} 297}
292DEVICE_ATTR(serial, S_IRUGO, virtblk_serial_show, NULL); 298DEVICE_ATTR(serial, S_IRUGO, virtblk_serial_show, NULL);
293 299
300static void virtblk_config_changed_work(struct work_struct *work)
301{
302 struct virtio_blk *vblk =
303 container_of(work, struct virtio_blk, config_work);
304 struct virtio_device *vdev = vblk->vdev;
305 struct request_queue *q = vblk->disk->queue;
306 char cap_str_2[10], cap_str_10[10];
307 u64 capacity, size;
308
309 /* Host must always specify the capacity. */
310 vdev->config->get(vdev, offsetof(struct virtio_blk_config, capacity),
311 &capacity, sizeof(capacity));
312
313 /* If capacity is too big, truncate with warning. */
314 if ((sector_t)capacity != capacity) {
315 dev_warn(&vdev->dev, "Capacity %llu too large: truncating\n",
316 (unsigned long long)capacity);
317 capacity = (sector_t)-1;
318 }
319
320 size = capacity * queue_logical_block_size(q);
321 string_get_size(size, STRING_UNITS_2, cap_str_2, sizeof(cap_str_2));
322 string_get_size(size, STRING_UNITS_10, cap_str_10, sizeof(cap_str_10));
323
324 dev_notice(&vdev->dev,
325 "new size: %llu %d-byte logical blocks (%s/%s)\n",
326 (unsigned long long)capacity,
327 queue_logical_block_size(q),
328 cap_str_10, cap_str_2);
329
330 set_capacity(vblk->disk, capacity);
331}
332
333static void virtblk_config_changed(struct virtio_device *vdev)
334{
335 struct virtio_blk *vblk = vdev->priv;
336
337 queue_work(virtblk_wq, &vblk->config_work);
338}
339
294static int __devinit virtblk_probe(struct virtio_device *vdev) 340static int __devinit virtblk_probe(struct virtio_device *vdev)
295{ 341{
296 struct virtio_blk *vblk; 342 struct virtio_blk *vblk;
@@ -327,6 +373,7 @@ static int __devinit virtblk_probe(struct virtio_device *vdev)
327 vblk->vdev = vdev; 373 vblk->vdev = vdev;
328 vblk->sg_elems = sg_elems; 374 vblk->sg_elems = sg_elems;
329 sg_init_table(vblk->sg, vblk->sg_elems); 375 sg_init_table(vblk->sg, vblk->sg_elems);
376 INIT_WORK(&vblk->config_work, virtblk_config_changed_work);
330 377
331 /* We expect one virtqueue, for output. */ 378 /* We expect one virtqueue, for output. */
332 vblk->vq = virtio_find_single_vq(vdev, blk_done, "requests"); 379 vblk->vq = virtio_find_single_vq(vdev, blk_done, "requests");
@@ -477,6 +524,8 @@ static void __devexit virtblk_remove(struct virtio_device *vdev)
477{ 524{
478 struct virtio_blk *vblk = vdev->priv; 525 struct virtio_blk *vblk = vdev->priv;
479 526
527 flush_work(&vblk->config_work);
528
480 /* Nothing should be pending. */ 529 /* Nothing should be pending. */
481 BUG_ON(!list_empty(&vblk->reqs)); 530 BUG_ON(!list_empty(&vblk->reqs));
482 531
@@ -508,27 +557,47 @@ static unsigned int features[] = {
508 * Use __refdata to avoid this warning. 557 * Use __refdata to avoid this warning.
509 */ 558 */
510static struct virtio_driver __refdata virtio_blk = { 559static struct virtio_driver __refdata virtio_blk = {
511 .feature_table = features, 560 .feature_table = features,
512 .feature_table_size = ARRAY_SIZE(features), 561 .feature_table_size = ARRAY_SIZE(features),
513 .driver.name = KBUILD_MODNAME, 562 .driver.name = KBUILD_MODNAME,
514 .driver.owner = THIS_MODULE, 563 .driver.owner = THIS_MODULE,
515 .id_table = id_table, 564 .id_table = id_table,
516 .probe = virtblk_probe, 565 .probe = virtblk_probe,
517 .remove = __devexit_p(virtblk_remove), 566 .remove = __devexit_p(virtblk_remove),
567 .config_changed = virtblk_config_changed,
518}; 568};
519 569
520static int __init init(void) 570static int __init init(void)
521{ 571{
572 int error;
573
574 virtblk_wq = alloc_workqueue("virtio-blk", 0, 0);
575 if (!virtblk_wq)
576 return -ENOMEM;
577
522 major = register_blkdev(0, "virtblk"); 578 major = register_blkdev(0, "virtblk");
523 if (major < 0) 579 if (major < 0) {
524 return major; 580 error = major;
525 return register_virtio_driver(&virtio_blk); 581 goto out_destroy_workqueue;
582 }
583
584 error = register_virtio_driver(&virtio_blk);
585 if (error)
586 goto out_unregister_blkdev;
587 return 0;
588
589out_unregister_blkdev:
590 unregister_blkdev(major, "virtblk");
591out_destroy_workqueue:
592 destroy_workqueue(virtblk_wq);
593 return error;
526} 594}
527 595
528static void __exit fini(void) 596static void __exit fini(void)
529{ 597{
530 unregister_blkdev(major, "virtblk"); 598 unregister_blkdev(major, "virtblk");
531 unregister_virtio_driver(&virtio_blk); 599 unregister_virtio_driver(&virtio_blk);
600 destroy_workqueue(virtblk_wq);
532} 601}
533module_init(init); 602module_init(init);
534module_exit(fini); 603module_exit(fini);
diff --git a/drivers/block/xen-blkback/blkback.c b/drivers/block/xen-blkback/blkback.c
index c73910cc28c9..5cf2993a8338 100644
--- a/drivers/block/xen-blkback/blkback.c
+++ b/drivers/block/xen-blkback/blkback.c
@@ -809,11 +809,13 @@ static int __init xen_blkif_init(void)
809 failed_init: 809 failed_init:
810 kfree(blkbk->pending_reqs); 810 kfree(blkbk->pending_reqs);
811 kfree(blkbk->pending_grant_handles); 811 kfree(blkbk->pending_grant_handles);
812 for (i = 0; i < mmap_pages; i++) { 812 if (blkbk->pending_pages) {
813 if (blkbk->pending_pages[i]) 813 for (i = 0; i < mmap_pages; i++) {
814 __free_page(blkbk->pending_pages[i]); 814 if (blkbk->pending_pages[i])
815 __free_page(blkbk->pending_pages[i]);
816 }
817 kfree(blkbk->pending_pages);
815 } 818 }
816 kfree(blkbk->pending_pages);
817 kfree(blkbk); 819 kfree(blkbk);
818 blkbk = NULL; 820 blkbk = NULL;
819 return rc; 821 return rc;
diff --git a/drivers/block/xen-blkback/xenbus.c b/drivers/block/xen-blkback/xenbus.c
index 34570823355b..6cc0db1bf522 100644
--- a/drivers/block/xen-blkback/xenbus.c
+++ b/drivers/block/xen-blkback/xenbus.c
@@ -357,14 +357,13 @@ static int xen_vbd_create(struct xen_blkif *blkif, blkif_vdev_t handle,
357 } 357 }
358 358
359 vbd->bdev = bdev; 359 vbd->bdev = bdev;
360 vbd->size = vbd_sz(vbd);
361
362 if (vbd->bdev->bd_disk == NULL) { 360 if (vbd->bdev->bd_disk == NULL) {
363 DPRINTK("xen_vbd_create: device %08x doesn't exist.\n", 361 DPRINTK("xen_vbd_create: device %08x doesn't exist.\n",
364 vbd->pdevice); 362 vbd->pdevice);
365 xen_vbd_free(vbd); 363 xen_vbd_free(vbd);
366 return -ENOENT; 364 return -ENOENT;
367 } 365 }
366 vbd->size = vbd_sz(vbd);
368 367
369 if (vbd->bdev->bd_disk->flags & GENHD_FL_CD || cdrom) 368 if (vbd->bdev->bd_disk->flags & GENHD_FL_CD || cdrom)
370 vbd->type |= VDISK_CDROM; 369 vbd->type |= VDISK_CDROM;
diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c
index b3f01996318f..48ad2a7ab080 100644
--- a/drivers/bluetooth/hci_ldisc.c
+++ b/drivers/bluetooth/hci_ldisc.c
@@ -355,29 +355,24 @@ static void hci_uart_tty_wakeup(struct tty_struct *tty)
355 * flags pointer to flags for data 355 * flags pointer to flags for data
356 * count count of received data in bytes 356 * count count of received data in bytes
357 * 357 *
358 * Return Value: Number of bytes received 358 * Return Value: None
359 */ 359 */
360static unsigned int hci_uart_tty_receive(struct tty_struct *tty, 360static void hci_uart_tty_receive(struct tty_struct *tty, const u8 *data, char *flags, int count)
361 const u8 *data, char *flags, int count)
362{ 361{
363 struct hci_uart *hu = (void *)tty->disc_data; 362 struct hci_uart *hu = (void *)tty->disc_data;
364 int received;
365 363
366 if (!hu || tty != hu->tty) 364 if (!hu || tty != hu->tty)
367 return -ENODEV; 365 return;
368 366
369 if (!test_bit(HCI_UART_PROTO_SET, &hu->flags)) 367 if (!test_bit(HCI_UART_PROTO_SET, &hu->flags))
370 return -EINVAL; 368 return;
371 369
372 spin_lock(&hu->rx_lock); 370 spin_lock(&hu->rx_lock);
373 received = hu->proto->recv(hu, (void *) data, count); 371 hu->proto->recv(hu, (void *) data, count);
374 if (received > 0) 372 hu->hdev->stat.byte_rx += count;
375 hu->hdev->stat.byte_rx += received;
376 spin_unlock(&hu->rx_lock); 373 spin_unlock(&hu->rx_lock);
377 374
378 tty_unthrottle(tty); 375 tty_unthrottle(tty);
379
380 return received;
381} 376}
382 377
383static int hci_uart_register_dev(struct hci_uart *hu) 378static int hci_uart_register_dev(struct hci_uart *hu)
diff --git a/drivers/cdrom/viocd.c b/drivers/cdrom/viocd.c
index ae15a4ddaa9b..7878da89d29e 100644
--- a/drivers/cdrom/viocd.c
+++ b/drivers/cdrom/viocd.c
@@ -627,7 +627,6 @@ static int viocd_probe(struct vio_dev *vdev, const struct vio_device_id *id)
627 gendisk->fops = &viocd_fops; 627 gendisk->fops = &viocd_fops;
628 gendisk->flags = GENHD_FL_CD | GENHD_FL_REMOVABLE | 628 gendisk->flags = GENHD_FL_CD | GENHD_FL_REMOVABLE |
629 GENHD_FL_BLOCK_EVENTS_ON_EXCL_WRITE; 629 GENHD_FL_BLOCK_EVENTS_ON_EXCL_WRITE;
630 gendisk->events = DISK_EVENT_MEDIA_CHANGE;
631 set_capacity(gendisk, 0); 630 set_capacity(gendisk, 0);
632 gendisk->private_data = d; 631 gendisk->private_data = d;
633 d->viocd_disk = gendisk; 632 d->viocd_disk = gendisk;
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index 838568a7dbf5..fb68b1295373 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -1677,17 +1677,12 @@ static int __devinit virtcons_probe(struct virtio_device *vdev)
1677 portdev->config.max_nr_ports = 1; 1677 portdev->config.max_nr_ports = 1;
1678 if (virtio_has_feature(vdev, VIRTIO_CONSOLE_F_MULTIPORT)) { 1678 if (virtio_has_feature(vdev, VIRTIO_CONSOLE_F_MULTIPORT)) {
1679 multiport = true; 1679 multiport = true;
1680 vdev->features[0] |= 1 << VIRTIO_CONSOLE_F_MULTIPORT;
1681
1682 vdev->config->get(vdev, offsetof(struct virtio_console_config, 1680 vdev->config->get(vdev, offsetof(struct virtio_console_config,
1683 max_nr_ports), 1681 max_nr_ports),
1684 &portdev->config.max_nr_ports, 1682 &portdev->config.max_nr_ports,
1685 sizeof(portdev->config.max_nr_ports)); 1683 sizeof(portdev->config.max_nr_ports));
1686 } 1684 }
1687 1685
1688 /* Let the Host know we support multiple ports.*/
1689 vdev->config->finalize_features(vdev);
1690
1691 err = init_vqs(portdev); 1686 err = init_vqs(portdev);
1692 if (err < 0) { 1687 if (err < 0) {
1693 dev_err(&vdev->dev, "Error %d initializing vqs\n", err); 1688 dev_err(&vdev->dev, "Error %d initializing vqs\n", err);
diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c
index 036e5865eb40..dc7c033ef587 100644
--- a/drivers/clocksource/sh_cmt.c
+++ b/drivers/clocksource/sh_cmt.c
@@ -24,7 +24,6 @@
24#include <linux/ioport.h> 24#include <linux/ioport.h>
25#include <linux/io.h> 25#include <linux/io.h>
26#include <linux/clk.h> 26#include <linux/clk.h>
27#include <linux/pm_runtime.h>
28#include <linux/irq.h> 27#include <linux/irq.h>
29#include <linux/err.h> 28#include <linux/err.h>
30#include <linux/clocksource.h> 29#include <linux/clocksource.h>
@@ -153,12 +152,10 @@ static int sh_cmt_enable(struct sh_cmt_priv *p, unsigned long *rate)
153{ 152{
154 int ret; 153 int ret;
155 154
156 /* wake up device and enable clock */ 155 /* enable clock */
157 pm_runtime_get_sync(&p->pdev->dev);
158 ret = clk_enable(p->clk); 156 ret = clk_enable(p->clk);
159 if (ret) { 157 if (ret) {
160 dev_err(&p->pdev->dev, "cannot enable clock\n"); 158 dev_err(&p->pdev->dev, "cannot enable clock\n");
161 pm_runtime_put_sync(&p->pdev->dev);
162 return ret; 159 return ret;
163 } 160 }
164 161
@@ -190,9 +187,8 @@ static void sh_cmt_disable(struct sh_cmt_priv *p)
190 /* disable interrupts in CMT block */ 187 /* disable interrupts in CMT block */
191 sh_cmt_write(p, CMCSR, 0); 188 sh_cmt_write(p, CMCSR, 0);
192 189
193 /* stop clock and mark device as idle */ 190 /* stop clock */
194 clk_disable(p->clk); 191 clk_disable(p->clk);
195 pm_runtime_put_sync(&p->pdev->dev);
196} 192}
197 193
198/* private flags */ 194/* private flags */
@@ -664,7 +660,6 @@ static int __devinit sh_cmt_probe(struct platform_device *pdev)
664 660
665 if (p) { 661 if (p) {
666 dev_info(&pdev->dev, "kept as earlytimer\n"); 662 dev_info(&pdev->dev, "kept as earlytimer\n");
667 pm_runtime_enable(&pdev->dev);
668 return 0; 663 return 0;
669 } 664 }
670 665
@@ -679,9 +674,6 @@ static int __devinit sh_cmt_probe(struct platform_device *pdev)
679 kfree(p); 674 kfree(p);
680 platform_set_drvdata(pdev, NULL); 675 platform_set_drvdata(pdev, NULL);
681 } 676 }
682
683 if (!is_early_platform_device(pdev))
684 pm_runtime_enable(&pdev->dev);
685 return ret; 677 return ret;
686} 678}
687 679
diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c
index 17296288a205..808135768617 100644
--- a/drivers/clocksource/sh_tmu.c
+++ b/drivers/clocksource/sh_tmu.c
@@ -25,7 +25,6 @@
25#include <linux/delay.h> 25#include <linux/delay.h>
26#include <linux/io.h> 26#include <linux/io.h>
27#include <linux/clk.h> 27#include <linux/clk.h>
28#include <linux/pm_runtime.h>
29#include <linux/irq.h> 28#include <linux/irq.h>
30#include <linux/err.h> 29#include <linux/err.h>
31#include <linux/clocksource.h> 30#include <linux/clocksource.h>
@@ -110,12 +109,10 @@ static int sh_tmu_enable(struct sh_tmu_priv *p)
110{ 109{
111 int ret; 110 int ret;
112 111
113 /* wake up device and enable clock */ 112 /* enable clock */
114 pm_runtime_get_sync(&p->pdev->dev);
115 ret = clk_enable(p->clk); 113 ret = clk_enable(p->clk);
116 if (ret) { 114 if (ret) {
117 dev_err(&p->pdev->dev, "cannot enable clock\n"); 115 dev_err(&p->pdev->dev, "cannot enable clock\n");
118 pm_runtime_put_sync(&p->pdev->dev);
119 return ret; 116 return ret;
120 } 117 }
121 118
@@ -144,9 +141,8 @@ static void sh_tmu_disable(struct sh_tmu_priv *p)
144 /* disable interrupts in TMU block */ 141 /* disable interrupts in TMU block */
145 sh_tmu_write(p, TCR, 0x0000); 142 sh_tmu_write(p, TCR, 0x0000);
146 143
147 /* stop clock and mark device as idle */ 144 /* stop clock */
148 clk_disable(p->clk); 145 clk_disable(p->clk);
149 pm_runtime_put_sync(&p->pdev->dev);
150} 146}
151 147
152static void sh_tmu_set_next(struct sh_tmu_priv *p, unsigned long delta, 148static void sh_tmu_set_next(struct sh_tmu_priv *p, unsigned long delta,
@@ -415,7 +411,6 @@ static int __devinit sh_tmu_probe(struct platform_device *pdev)
415 411
416 if (p) { 412 if (p) {
417 dev_info(&pdev->dev, "kept as earlytimer\n"); 413 dev_info(&pdev->dev, "kept as earlytimer\n");
418 pm_runtime_enable(&pdev->dev);
419 return 0; 414 return 0;
420 } 415 }
421 416
@@ -430,9 +425,6 @@ static int __devinit sh_tmu_probe(struct platform_device *pdev)
430 kfree(p); 425 kfree(p);
431 platform_set_drvdata(pdev, NULL); 426 platform_set_drvdata(pdev, NULL);
432 } 427 }
433
434 if (!is_early_platform_device(pdev))
435 pm_runtime_enable(&pdev->dev);
436 return ret; 428 return ret;
437} 429}
438 430
diff --git a/drivers/dma/shdma.c b/drivers/dma/shdma.c
index 636e40925b16..2a638f9f09a2 100644
--- a/drivers/dma/shdma.c
+++ b/drivers/dma/shdma.c
@@ -343,7 +343,7 @@ static int sh_dmae_alloc_chan_resources(struct dma_chan *chan)
343 343
344 dmae_set_dmars(sh_chan, cfg->mid_rid); 344 dmae_set_dmars(sh_chan, cfg->mid_rid);
345 dmae_set_chcr(sh_chan, cfg->chcr); 345 dmae_set_chcr(sh_chan, cfg->chcr);
346 } else if ((sh_dmae_readl(sh_chan, CHCR) & 0xf00) != 0x400) { 346 } else {
347 dmae_init(sh_chan); 347 dmae_init(sh_chan);
348 } 348 }
349 349
@@ -1144,6 +1144,8 @@ static int __init sh_dmae_probe(struct platform_device *pdev)
1144 /* platform data */ 1144 /* platform data */
1145 shdev->pdata = pdata; 1145 shdev->pdata = pdata;
1146 1146
1147 platform_set_drvdata(pdev, shdev);
1148
1147 pm_runtime_enable(&pdev->dev); 1149 pm_runtime_enable(&pdev->dev);
1148 pm_runtime_get_sync(&pdev->dev); 1150 pm_runtime_get_sync(&pdev->dev);
1149 1151
@@ -1256,7 +1258,6 @@ static int __init sh_dmae_probe(struct platform_device *pdev)
1256 1258
1257 pm_runtime_put(&pdev->dev); 1259 pm_runtime_put(&pdev->dev);
1258 1260
1259 platform_set_drvdata(pdev, shdev);
1260 dma_async_device_register(&shdev->common); 1261 dma_async_device_register(&shdev->common);
1261 1262
1262 return err; 1263 return err;
@@ -1278,6 +1279,8 @@ rst_err:
1278 1279
1279 if (dmars) 1280 if (dmars)
1280 iounmap(shdev->dmars); 1281 iounmap(shdev->dmars);
1282
1283 platform_set_drvdata(pdev, NULL);
1281emapdmars: 1284emapdmars:
1282 iounmap(shdev->chan_reg); 1285 iounmap(shdev->chan_reg);
1283 synchronize_rcu(); 1286 synchronize_rcu();
@@ -1316,6 +1319,8 @@ static int __exit sh_dmae_remove(struct platform_device *pdev)
1316 iounmap(shdev->dmars); 1319 iounmap(shdev->dmars);
1317 iounmap(shdev->chan_reg); 1320 iounmap(shdev->chan_reg);
1318 1321
1322 platform_set_drvdata(pdev, NULL);
1323
1319 synchronize_rcu(); 1324 synchronize_rcu();
1320 kfree(shdev); 1325 kfree(shdev);
1321 1326
diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
index de3d2465fe24..85e937984ff7 100644
--- a/drivers/hwmon/coretemp.c
+++ b/drivers/hwmon/coretemp.c
@@ -296,7 +296,7 @@ static int get_tjmax(struct cpuinfo_x86 *c, u32 id, struct device *dev)
296 * If the TjMax is not plausible, an assumption 296 * If the TjMax is not plausible, an assumption
297 * will be used 297 * will be used
298 */ 298 */
299 if (val > 80 && val < 120) { 299 if (val) {
300 dev_info(dev, "TjMax is %d C.\n", val); 300 dev_info(dev, "TjMax is %d C.\n", val);
301 return val * 1000; 301 return val * 1000;
302 } 302 }
@@ -304,24 +304,9 @@ static int get_tjmax(struct cpuinfo_x86 *c, u32 id, struct device *dev)
304 304
305 /* 305 /*
306 * An assumption is made for early CPUs and unreadable MSR. 306 * An assumption is made for early CPUs and unreadable MSR.
307 * NOTE: the given value may not be correct. 307 * NOTE: the calculated value may not be correct.
308 */ 308 */
309 309 return adjust_tjmax(c, id, dev);
310 switch (c->x86_model) {
311 case 0xe:
312 case 0xf:
313 case 0x16:
314 case 0x1a:
315 dev_warn(dev, "TjMax is assumed as 100 C!\n");
316 return 100000;
317 case 0x17:
318 case 0x1c: /* Atom CPUs */
319 return adjust_tjmax(c, id, dev);
320 default:
321 dev_warn(dev, "CPU (model=0x%x) is not supported yet,"
322 " using default TjMax of 100C.\n", c->x86_model);
323 return 100000;
324 }
325} 310}
326 311
327static void __devinit get_ucode_rev_on_cpu(void *edx) 312static void __devinit get_ucode_rev_on_cpu(void *edx)
@@ -341,7 +326,7 @@ static int get_pkg_tjmax(unsigned int cpu, struct device *dev)
341 err = rdmsr_safe_on_cpu(cpu, MSR_IA32_TEMPERATURE_TARGET, &eax, &edx); 326 err = rdmsr_safe_on_cpu(cpu, MSR_IA32_TEMPERATURE_TARGET, &eax, &edx);
342 if (!err) { 327 if (!err) {
343 val = (eax >> 16) & 0xff; 328 val = (eax >> 16) & 0xff;
344 if (val > 80 && val < 120) 329 if (val)
345 return val * 1000; 330 return val * 1000;
346 } 331 }
347 dev_warn(dev, "Unable to read Pkg-TjMax from CPU:%u\n", cpu); 332 dev_warn(dev, "Unable to read Pkg-TjMax from CPU:%u\n", cpu);
diff --git a/drivers/hwmon/max6642.c b/drivers/hwmon/max6642.c
index 0f9fc40379cd..e855d3b0bd1f 100644
--- a/drivers/hwmon/max6642.c
+++ b/drivers/hwmon/max6642.c
@@ -136,15 +136,29 @@ static int max6642_detect(struct i2c_client *client,
136 if (man_id != 0x4D) 136 if (man_id != 0x4D)
137 return -ENODEV; 137 return -ENODEV;
138 138
139 /* sanity check */
140 if (i2c_smbus_read_byte_data(client, 0x04) != 0x4D
141 || i2c_smbus_read_byte_data(client, 0x06) != 0x4D
142 || i2c_smbus_read_byte_data(client, 0xff) != 0x4D)
143 return -ENODEV;
144
139 /* 145 /*
140 * We read the config and status register, the 4 lower bits in the 146 * We read the config and status register, the 4 lower bits in the
141 * config register should be zero and bit 5, 3, 1 and 0 should be 147 * config register should be zero and bit 5, 3, 1 and 0 should be
142 * zero in the status register. 148 * zero in the status register.
143 */ 149 */
144 reg_config = i2c_smbus_read_byte_data(client, MAX6642_REG_R_CONFIG); 150 reg_config = i2c_smbus_read_byte_data(client, MAX6642_REG_R_CONFIG);
151 if ((reg_config & 0x0f) != 0x00)
152 return -ENODEV;
153
154 /* in between, another round of sanity checks */
155 if (i2c_smbus_read_byte_data(client, 0x04) != reg_config
156 || i2c_smbus_read_byte_data(client, 0x06) != reg_config
157 || i2c_smbus_read_byte_data(client, 0xff) != reg_config)
158 return -ENODEV;
159
145 reg_status = i2c_smbus_read_byte_data(client, MAX6642_REG_R_STATUS); 160 reg_status = i2c_smbus_read_byte_data(client, MAX6642_REG_R_STATUS);
146 if (((reg_config & 0x0f) != 0x00) || 161 if ((reg_status & 0x2b) != 0x00)
147 ((reg_status & 0x2b) != 0x00))
148 return -ENODEV; 162 return -ENODEV;
149 163
150 strlcpy(info->type, "max6642", I2C_NAME_SIZE); 164 strlcpy(info->type, "max6642", I2C_NAME_SIZE);
@@ -246,7 +260,7 @@ static SENSOR_DEVICE_ATTR_2(temp1_max, S_IWUSR | S_IRUGO, show_temp_max,
246 set_temp_max, 0, MAX6642_REG_W_LOCAL_HIGH); 260 set_temp_max, 0, MAX6642_REG_W_LOCAL_HIGH);
247static SENSOR_DEVICE_ATTR_2(temp2_max, S_IWUSR | S_IRUGO, show_temp_max, 261static SENSOR_DEVICE_ATTR_2(temp2_max, S_IWUSR | S_IRUGO, show_temp_max,
248 set_temp_max, 1, MAX6642_REG_W_REMOTE_HIGH); 262 set_temp_max, 1, MAX6642_REG_W_REMOTE_HIGH);
249static SENSOR_DEVICE_ATTR(temp_fault, S_IRUGO, show_alarm, NULL, 2); 263static SENSOR_DEVICE_ATTR(temp2_fault, S_IRUGO, show_alarm, NULL, 2);
250static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, show_alarm, NULL, 6); 264static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, show_alarm, NULL, 6);
251static SENSOR_DEVICE_ATTR(temp2_max_alarm, S_IRUGO, show_alarm, NULL, 4); 265static SENSOR_DEVICE_ATTR(temp2_max_alarm, S_IRUGO, show_alarm, NULL, 4);
252 266
@@ -256,7 +270,7 @@ static struct attribute *max6642_attributes[] = {
256 &sensor_dev_attr_temp1_max.dev_attr.attr, 270 &sensor_dev_attr_temp1_max.dev_attr.attr,
257 &sensor_dev_attr_temp2_max.dev_attr.attr, 271 &sensor_dev_attr_temp2_max.dev_attr.attr,
258 272
259 &sensor_dev_attr_temp_fault.dev_attr.attr, 273 &sensor_dev_attr_temp2_fault.dev_attr.attr,
260 &sensor_dev_attr_temp1_max_alarm.dev_attr.attr, 274 &sensor_dev_attr_temp1_max_alarm.dev_attr.attr,
261 &sensor_dev_attr_temp2_max_alarm.dev_attr.attr, 275 &sensor_dev_attr_temp2_max_alarm.dev_attr.attr,
262 NULL 276 NULL
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index 6e5123b1d341..144d27261e43 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -1782,7 +1782,6 @@ static int ide_cd_probe(ide_drive_t *drive)
1782 ide_cd_read_toc(drive, &sense); 1782 ide_cd_read_toc(drive, &sense);
1783 g->fops = &idecd_ops; 1783 g->fops = &idecd_ops;
1784 g->flags |= GENHD_FL_REMOVABLE | GENHD_FL_BLOCK_EVENTS_ON_EXCL_WRITE; 1784 g->flags |= GENHD_FL_REMOVABLE | GENHD_FL_BLOCK_EVENTS_ON_EXCL_WRITE;
1785 g->events = DISK_EVENT_MEDIA_CHANGE;
1786 add_disk(g); 1785 add_disk(g);
1787 return 0; 1786 return 0;
1788 1787
diff --git a/drivers/input/serio/serport.c b/drivers/input/serio/serport.c
index f3698967edf6..8755f5f3ad37 100644
--- a/drivers/input/serio/serport.c
+++ b/drivers/input/serio/serport.c
@@ -120,21 +120,17 @@ static void serport_ldisc_close(struct tty_struct *tty)
120 * 'interrupt' routine. 120 * 'interrupt' routine.
121 */ 121 */
122 122
123static unsigned int serport_ldisc_receive(struct tty_struct *tty, 123static void serport_ldisc_receive(struct tty_struct *tty, const unsigned char *cp, char *fp, int count)
124 const unsigned char *cp, char *fp, int count)
125{ 124{
126 struct serport *serport = (struct serport*) tty->disc_data; 125 struct serport *serport = (struct serport*) tty->disc_data;
127 unsigned long flags; 126 unsigned long flags;
128 unsigned int ch_flags; 127 unsigned int ch_flags;
129 int ret = 0;
130 int i; 128 int i;
131 129
132 spin_lock_irqsave(&serport->lock, flags); 130 spin_lock_irqsave(&serport->lock, flags);
133 131
134 if (!test_bit(SERPORT_ACTIVE, &serport->flags)) { 132 if (!test_bit(SERPORT_ACTIVE, &serport->flags))
135 ret = -EINVAL;
136 goto out; 133 goto out;
137 }
138 134
139 for (i = 0; i < count; i++) { 135 for (i = 0; i < count; i++) {
140 switch (fp[i]) { 136 switch (fp[i]) {
@@ -156,8 +152,6 @@ static unsigned int serport_ldisc_receive(struct tty_struct *tty,
156 152
157out: 153out:
158 spin_unlock_irqrestore(&serport->lock, flags); 154 spin_unlock_irqrestore(&serport->lock, flags);
159
160 return ret == 0 ? count : ret;
161} 155}
162 156
163/* 157/*
diff --git a/drivers/isdn/gigaset/ser-gigaset.c b/drivers/isdn/gigaset/ser-gigaset.c
index 1d44d470897c..86a5c4f7775e 100644
--- a/drivers/isdn/gigaset/ser-gigaset.c
+++ b/drivers/isdn/gigaset/ser-gigaset.c
@@ -674,7 +674,7 @@ gigaset_tty_ioctl(struct tty_struct *tty, struct file *file,
674 * cflags buffer containing error flags for received characters (ignored) 674 * cflags buffer containing error flags for received characters (ignored)
675 * count number of received characters 675 * count number of received characters
676 */ 676 */
677static unsigned int 677static void
678gigaset_tty_receive(struct tty_struct *tty, const unsigned char *buf, 678gigaset_tty_receive(struct tty_struct *tty, const unsigned char *buf,
679 char *cflags, int count) 679 char *cflags, int count)
680{ 680{
@@ -683,12 +683,12 @@ gigaset_tty_receive(struct tty_struct *tty, const unsigned char *buf,
683 struct inbuf_t *inbuf; 683 struct inbuf_t *inbuf;
684 684
685 if (!cs) 685 if (!cs)
686 return -ENODEV; 686 return;
687 inbuf = cs->inbuf; 687 inbuf = cs->inbuf;
688 if (!inbuf) { 688 if (!inbuf) {
689 dev_err(cs->dev, "%s: no inbuf\n", __func__); 689 dev_err(cs->dev, "%s: no inbuf\n", __func__);
690 cs_put(cs); 690 cs_put(cs);
691 return -EINVAL; 691 return;
692 } 692 }
693 693
694 tail = inbuf->tail; 694 tail = inbuf->tail;
@@ -725,8 +725,6 @@ gigaset_tty_receive(struct tty_struct *tty, const unsigned char *buf,
725 gig_dbg(DEBUG_INTR, "%s-->BH", __func__); 725 gig_dbg(DEBUG_INTR, "%s-->BH", __func__);
726 gigaset_schedule_event(cs); 726 gigaset_schedule_event(cs);
727 cs_put(cs); 727 cs_put(cs);
728
729 return count;
730} 728}
731 729
732/* 730/*
diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
index b0c56313dbbb..8cebec5e85ee 100644
--- a/drivers/misc/kgdbts.c
+++ b/drivers/misc/kgdbts.c
@@ -304,7 +304,10 @@ static int check_and_rewind_pc(char *put_str, char *arg)
304 return 1; 304 return 1;
305 } 305 }
306 /* Readjust the instruction pointer if needed */ 306 /* Readjust the instruction pointer if needed */
307 instruction_pointer_set(&kgdbts_regs, ip + offset); 307 ip += offset;
308#ifdef GDB_ADJUSTS_BREAK_OFFSET
309 instruction_pointer_set(&kgdbts_regs, ip);
310#endif
308 return 0; 311 return 0;
309} 312}
310 313
diff --git a/drivers/misc/ti-st/st_core.c b/drivers/misc/ti-st/st_core.c
index 1a05fe08e2cb..f91f82eabda7 100644
--- a/drivers/misc/ti-st/st_core.c
+++ b/drivers/misc/ti-st/st_core.c
@@ -747,8 +747,8 @@ static void st_tty_close(struct tty_struct *tty)
747 pr_debug("%s: done ", __func__); 747 pr_debug("%s: done ", __func__);
748} 748}
749 749
750static unsigned int st_tty_receive(struct tty_struct *tty, 750static void st_tty_receive(struct tty_struct *tty, const unsigned char *data,
751 const unsigned char *data, char *tty_flags, int count) 751 char *tty_flags, int count)
752{ 752{
753#ifdef VERBOSE 753#ifdef VERBOSE
754 print_hex_dump(KERN_DEBUG, ">in>", DUMP_PREFIX_NONE, 754 print_hex_dump(KERN_DEBUG, ">in>", DUMP_PREFIX_NONE,
@@ -761,8 +761,6 @@ static unsigned int st_tty_receive(struct tty_struct *tty,
761 */ 761 */
762 st_recv(tty->disc_data, data, count); 762 st_recv(tty->disc_data, data, count);
763 pr_debug("done %s", __func__); 763 pr_debug("done %s", __func__);
764
765 return count;
766} 764}
767 765
768/* wake-up function called in from the TTY layer 766/* wake-up function called in from the TTY layer
diff --git a/drivers/net/3c509.c b/drivers/net/3c509.c
index 5f25889e27ef..44b28b2d7003 100644
--- a/drivers/net/3c509.c
+++ b/drivers/net/3c509.c
@@ -185,7 +185,7 @@ static int max_interrupt_work = 10;
185static int nopnp; 185static int nopnp;
186#endif 186#endif
187 187
188static int el3_common_init(struct net_device *dev); 188static int __devinit el3_common_init(struct net_device *dev);
189static void el3_common_remove(struct net_device *dev); 189static void el3_common_remove(struct net_device *dev);
190static ushort id_read_eeprom(int index); 190static ushort id_read_eeprom(int index);
191static ushort read_eeprom(int ioaddr, int index); 191static ushort read_eeprom(int ioaddr, int index);
@@ -395,7 +395,7 @@ static struct isa_driver el3_isa_driver = {
395static int isa_registered; 395static int isa_registered;
396 396
397#ifdef CONFIG_PNP 397#ifdef CONFIG_PNP
398static const struct pnp_device_id el3_pnp_ids[] __devinitconst = { 398static struct pnp_device_id el3_pnp_ids[] = {
399 { .id = "TCM5090" }, /* 3Com Etherlink III (TP) */ 399 { .id = "TCM5090" }, /* 3Com Etherlink III (TP) */
400 { .id = "TCM5091" }, /* 3Com Etherlink III */ 400 { .id = "TCM5091" }, /* 3Com Etherlink III */
401 { .id = "TCM5094" }, /* 3Com Etherlink III (combo) */ 401 { .id = "TCM5094" }, /* 3Com Etherlink III (combo) */
@@ -478,7 +478,7 @@ static int pnp_registered;
478#endif /* CONFIG_PNP */ 478#endif /* CONFIG_PNP */
479 479
480#ifdef CONFIG_EISA 480#ifdef CONFIG_EISA
481static const struct eisa_device_id el3_eisa_ids[] __devinitconst = { 481static struct eisa_device_id el3_eisa_ids[] = {
482 { "TCM5090" }, 482 { "TCM5090" },
483 { "TCM5091" }, 483 { "TCM5091" },
484 { "TCM5092" }, 484 { "TCM5092" },
@@ -508,7 +508,7 @@ static int eisa_registered;
508#ifdef CONFIG_MCA 508#ifdef CONFIG_MCA
509static int el3_mca_probe(struct device *dev); 509static int el3_mca_probe(struct device *dev);
510 510
511static const short el3_mca_adapter_ids[] __devinitconst = { 511static short el3_mca_adapter_ids[] __initdata = {
512 0x627c, 512 0x627c,
513 0x627d, 513 0x627d,
514 0x62db, 514 0x62db,
@@ -517,7 +517,7 @@ static const short el3_mca_adapter_ids[] __devinitconst = {
517 0x0000 517 0x0000
518}; 518};
519 519
520static const char *const el3_mca_adapter_names[] __devinitconst = { 520static char *el3_mca_adapter_names[] __initdata = {
521 "3Com 3c529 EtherLink III (10base2)", 521 "3Com 3c529 EtherLink III (10base2)",
522 "3Com 3c529 EtherLink III (10baseT)", 522 "3Com 3c529 EtherLink III (10baseT)",
523 "3Com 3c529 EtherLink III (test mode)", 523 "3Com 3c529 EtherLink III (test mode)",
@@ -601,7 +601,7 @@ static void el3_common_remove (struct net_device *dev)
601} 601}
602 602
603#ifdef CONFIG_MCA 603#ifdef CONFIG_MCA
604static int __devinit el3_mca_probe(struct device *device) 604static int __init el3_mca_probe(struct device *device)
605{ 605{
606 /* Based on Erik Nygren's (nygren@mit.edu) 3c529 patch, 606 /* Based on Erik Nygren's (nygren@mit.edu) 3c529 patch,
607 * heavily modified by Chris Beauregard 607 * heavily modified by Chris Beauregard
@@ -671,7 +671,7 @@ static int __devinit el3_mca_probe(struct device *device)
671#endif /* CONFIG_MCA */ 671#endif /* CONFIG_MCA */
672 672
673#ifdef CONFIG_EISA 673#ifdef CONFIG_EISA
674static int __devinit el3_eisa_probe (struct device *device) 674static int __init el3_eisa_probe (struct device *device)
675{ 675{
676 short i; 676 short i;
677 int ioaddr, irq, if_port; 677 int ioaddr, irq, if_port;
diff --git a/drivers/net/3c59x.c b/drivers/net/3c59x.c
index 99f43d275442..8cc22568ebd3 100644
--- a/drivers/net/3c59x.c
+++ b/drivers/net/3c59x.c
@@ -901,14 +901,14 @@ static const struct dev_pm_ops vortex_pm_ops = {
901#endif /* !CONFIG_PM */ 901#endif /* !CONFIG_PM */
902 902
903#ifdef CONFIG_EISA 903#ifdef CONFIG_EISA
904static const struct eisa_device_id vortex_eisa_ids[] __devinitconst = { 904static struct eisa_device_id vortex_eisa_ids[] = {
905 { "TCM5920", CH_3C592 }, 905 { "TCM5920", CH_3C592 },
906 { "TCM5970", CH_3C597 }, 906 { "TCM5970", CH_3C597 },
907 { "" } 907 { "" }
908}; 908};
909MODULE_DEVICE_TABLE(eisa, vortex_eisa_ids); 909MODULE_DEVICE_TABLE(eisa, vortex_eisa_ids);
910 910
911static int __devinit vortex_eisa_probe(struct device *device) 911static int __init vortex_eisa_probe(struct device *device)
912{ 912{
913 void __iomem *ioaddr; 913 void __iomem *ioaddr;
914 struct eisa_device *edev; 914 struct eisa_device *edev;
diff --git a/drivers/net/caif/caif_serial.c b/drivers/net/caif/caif_serial.c
index 73c7e03617ec..3df0c0f8b8bf 100644
--- a/drivers/net/caif/caif_serial.c
+++ b/drivers/net/caif/caif_serial.c
@@ -167,8 +167,8 @@ static inline void debugfs_tx(struct ser_device *ser, const u8 *data, int size)
167 167
168#endif 168#endif
169 169
170static unsigned int ldisc_receive(struct tty_struct *tty, 170static void ldisc_receive(struct tty_struct *tty, const u8 *data,
171 const u8 *data, char *flags, int count) 171 char *flags, int count)
172{ 172{
173 struct sk_buff *skb = NULL; 173 struct sk_buff *skb = NULL;
174 struct ser_device *ser; 174 struct ser_device *ser;
@@ -215,8 +215,6 @@ static unsigned int ldisc_receive(struct tty_struct *tty,
215 } else 215 } else
216 ++ser->dev->stats.rx_dropped; 216 ++ser->dev->stats.rx_dropped;
217 update_tty_status(ser); 217 update_tty_status(ser);
218
219 return count;
220} 218}
221 219
222static int handle_tx(struct ser_device *ser) 220static int handle_tx(struct ser_device *ser)
diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
index d4990568baee..17678117ed69 100644
--- a/drivers/net/can/flexcan.c
+++ b/drivers/net/can/flexcan.c
@@ -923,7 +923,7 @@ static int __devinit flexcan_probe(struct platform_device *pdev)
923 mem_size = resource_size(mem); 923 mem_size = resource_size(mem);
924 if (!request_mem_region(mem->start, mem_size, pdev->name)) { 924 if (!request_mem_region(mem->start, mem_size, pdev->name)) {
925 err = -EBUSY; 925 err = -EBUSY;
926 goto failed_req; 926 goto failed_get;
927 } 927 }
928 928
929 base = ioremap(mem->start, mem_size); 929 base = ioremap(mem->start, mem_size);
@@ -977,9 +977,8 @@ static int __devinit flexcan_probe(struct platform_device *pdev)
977 iounmap(base); 977 iounmap(base);
978 failed_map: 978 failed_map:
979 release_mem_region(mem->start, mem_size); 979 release_mem_region(mem->start, mem_size);
980 failed_req:
981 clk_put(clk);
982 failed_get: 980 failed_get:
981 clk_put(clk);
983 failed_clock: 982 failed_clock:
984 return err; 983 return err;
985} 984}
diff --git a/drivers/net/can/slcan.c b/drivers/net/can/slcan.c
index 75622d54581f..1b49df6b2470 100644
--- a/drivers/net/can/slcan.c
+++ b/drivers/net/can/slcan.c
@@ -425,17 +425,16 @@ static void slc_setup(struct net_device *dev)
425 * in parallel 425 * in parallel
426 */ 426 */
427 427
428static unsigned int slcan_receive_buf(struct tty_struct *tty, 428static void slcan_receive_buf(struct tty_struct *tty,
429 const unsigned char *cp, char *fp, int count) 429 const unsigned char *cp, char *fp, int count)
430{ 430{
431 struct slcan *sl = (struct slcan *) tty->disc_data; 431 struct slcan *sl = (struct slcan *) tty->disc_data;
432 int bytes = count;
433 432
434 if (!sl || sl->magic != SLCAN_MAGIC || !netif_running(sl->dev)) 433 if (!sl || sl->magic != SLCAN_MAGIC || !netif_running(sl->dev))
435 return -ENODEV; 434 return;
436 435
437 /* Read the characters out of the buffer */ 436 /* Read the characters out of the buffer */
438 while (bytes--) { 437 while (count--) {
439 if (fp && *fp++) { 438 if (fp && *fp++) {
440 if (!test_and_set_bit(SLF_ERROR, &sl->flags)) 439 if (!test_and_set_bit(SLF_ERROR, &sl->flags))
441 sl->dev->stats.rx_errors++; 440 sl->dev->stats.rx_errors++;
@@ -444,8 +443,6 @@ static unsigned int slcan_receive_buf(struct tty_struct *tty,
444 } 443 }
445 slcan_unesc(sl, *cp++); 444 slcan_unesc(sl, *cp++);
446 } 445 }
447
448 return count;
449} 446}
450 447
451/************************************ 448/************************************
diff --git a/drivers/net/davinci_emac.c b/drivers/net/davinci_emac.c
index 29a4f06fbfcf..dcc4a170b0f3 100644
--- a/drivers/net/davinci_emac.c
+++ b/drivers/net/davinci_emac.c
@@ -1781,8 +1781,8 @@ static int __devinit davinci_emac_probe(struct platform_device *pdev)
1781 ndev = alloc_etherdev(sizeof(struct emac_priv)); 1781 ndev = alloc_etherdev(sizeof(struct emac_priv));
1782 if (!ndev) { 1782 if (!ndev) {
1783 dev_err(&pdev->dev, "error allocating net_device\n"); 1783 dev_err(&pdev->dev, "error allocating net_device\n");
1784 clk_put(emac_clk); 1784 rc = -ENOMEM;
1785 return -ENOMEM; 1785 goto free_clk;
1786 } 1786 }
1787 1787
1788 platform_set_drvdata(pdev, ndev); 1788 platform_set_drvdata(pdev, ndev);
@@ -1796,7 +1796,8 @@ static int __devinit davinci_emac_probe(struct platform_device *pdev)
1796 pdata = pdev->dev.platform_data; 1796 pdata = pdev->dev.platform_data;
1797 if (!pdata) { 1797 if (!pdata) {
1798 dev_err(&pdev->dev, "no platform data\n"); 1798 dev_err(&pdev->dev, "no platform data\n");
1799 return -ENODEV; 1799 rc = -ENODEV;
1800 goto probe_quit;
1800 } 1801 }
1801 1802
1802 /* MAC addr and PHY mask , RMII enable info from platform_data */ 1803 /* MAC addr and PHY mask , RMII enable info from platform_data */
@@ -1929,8 +1930,9 @@ no_dma:
1929 iounmap(priv->remap_addr); 1930 iounmap(priv->remap_addr);
1930 1931
1931probe_quit: 1932probe_quit:
1932 clk_put(emac_clk);
1933 free_netdev(ndev); 1933 free_netdev(ndev);
1934free_clk:
1935 clk_put(emac_clk);
1934 return rc; 1936 return rc;
1935} 1937}
1936 1938
diff --git a/drivers/net/depca.c b/drivers/net/depca.c
index 17654059922d..8b0084d17c8c 100644
--- a/drivers/net/depca.c
+++ b/drivers/net/depca.c
@@ -331,18 +331,18 @@ static struct {
331 "DE422",\ 331 "DE422",\
332 ""} 332 ""}
333 333
334static const char* const depca_signature[] __devinitconst = DEPCA_SIGNATURE; 334static char* __initdata depca_signature[] = DEPCA_SIGNATURE;
335 335
336enum depca_type { 336enum depca_type {
337 DEPCA, de100, de101, de200, de201, de202, de210, de212, de422, unknown 337 DEPCA, de100, de101, de200, de201, de202, de210, de212, de422, unknown
338}; 338};
339 339
340static const char depca_string[] = "depca"; 340static char depca_string[] = "depca";
341 341
342static int depca_device_remove (struct device *device); 342static int depca_device_remove (struct device *device);
343 343
344#ifdef CONFIG_EISA 344#ifdef CONFIG_EISA
345static const struct eisa_device_id depca_eisa_ids[] __devinitconst = { 345static struct eisa_device_id depca_eisa_ids[] = {
346 { "DEC4220", de422 }, 346 { "DEC4220", de422 },
347 { "" } 347 { "" }
348}; 348};
@@ -367,19 +367,19 @@ static struct eisa_driver depca_eisa_driver = {
367#define DE210_ID 0x628d 367#define DE210_ID 0x628d
368#define DE212_ID 0x6def 368#define DE212_ID 0x6def
369 369
370static const short depca_mca_adapter_ids[] __devinitconst = { 370static short depca_mca_adapter_ids[] = {
371 DE210_ID, 371 DE210_ID,
372 DE212_ID, 372 DE212_ID,
373 0x0000 373 0x0000
374}; 374};
375 375
376static const char *depca_mca_adapter_name[] = { 376static char *depca_mca_adapter_name[] = {
377 "DEC EtherWORKS MC Adapter (DE210)", 377 "DEC EtherWORKS MC Adapter (DE210)",
378 "DEC EtherWORKS MC Adapter (DE212)", 378 "DEC EtherWORKS MC Adapter (DE212)",
379 NULL 379 NULL
380}; 380};
381 381
382static const enum depca_type depca_mca_adapter_type[] = { 382static enum depca_type depca_mca_adapter_type[] = {
383 de210, 383 de210,
384 de212, 384 de212,
385 0 385 0
@@ -541,9 +541,10 @@ static void SetMulticastFilter(struct net_device *dev);
541static int load_packet(struct net_device *dev, struct sk_buff *skb); 541static int load_packet(struct net_device *dev, struct sk_buff *skb);
542static void depca_dbg_open(struct net_device *dev); 542static void depca_dbg_open(struct net_device *dev);
543 543
544static const u_char de1xx_irq[] __devinitconst = { 2, 3, 4, 5, 7, 9, 0 }; 544static u_char de1xx_irq[] __initdata = { 2, 3, 4, 5, 7, 9, 0 };
545static const u_char de2xx_irq[] __devinitconst = { 5, 9, 10, 11, 15, 0 }; 545static u_char de2xx_irq[] __initdata = { 5, 9, 10, 11, 15, 0 };
546static const u_char de422_irq[] __devinitconst = { 5, 9, 10, 11, 0 }; 546static u_char de422_irq[] __initdata = { 5, 9, 10, 11, 0 };
547static u_char *depca_irq;
547 548
548static int irq; 549static int irq;
549static int io; 550static int io;
@@ -579,7 +580,7 @@ static const struct net_device_ops depca_netdev_ops = {
579 .ndo_validate_addr = eth_validate_addr, 580 .ndo_validate_addr = eth_validate_addr,
580}; 581};
581 582
582static int __devinit depca_hw_init (struct net_device *dev, struct device *device) 583static int __init depca_hw_init (struct net_device *dev, struct device *device)
583{ 584{
584 struct depca_private *lp; 585 struct depca_private *lp;
585 int i, j, offset, netRAM, mem_len, status = 0; 586 int i, j, offset, netRAM, mem_len, status = 0;
@@ -747,7 +748,6 @@ static int __devinit depca_hw_init (struct net_device *dev, struct device *devic
747 if (dev->irq < 2) { 748 if (dev->irq < 2) {
748 unsigned char irqnum; 749 unsigned char irqnum;
749 unsigned long irq_mask, delay; 750 unsigned long irq_mask, delay;
750 const u_char *depca_irq;
751 751
752 irq_mask = probe_irq_on(); 752 irq_mask = probe_irq_on();
753 753
@@ -770,7 +770,6 @@ static int __devinit depca_hw_init (struct net_device *dev, struct device *devic
770 break; 770 break;
771 771
772 default: 772 default:
773 depca_irq = NULL;
774 break; /* Not reached */ 773 break; /* Not reached */
775 } 774 }
776 775
@@ -1303,7 +1302,7 @@ static void SetMulticastFilter(struct net_device *dev)
1303 } 1302 }
1304} 1303}
1305 1304
1306static int __devinit depca_common_init (u_long ioaddr, struct net_device **devp) 1305static int __init depca_common_init (u_long ioaddr, struct net_device **devp)
1307{ 1306{
1308 int status = 0; 1307 int status = 0;
1309 1308
@@ -1334,7 +1333,7 @@ static int __devinit depca_common_init (u_long ioaddr, struct net_device **devp)
1334/* 1333/*
1335** Microchannel bus I/O device probe 1334** Microchannel bus I/O device probe
1336*/ 1335*/
1337static int __devinit depca_mca_probe(struct device *device) 1336static int __init depca_mca_probe(struct device *device)
1338{ 1337{
1339 unsigned char pos[2]; 1338 unsigned char pos[2];
1340 unsigned char where; 1339 unsigned char where;
@@ -1458,7 +1457,7 @@ static int __devinit depca_mca_probe(struct device *device)
1458** ISA bus I/O device probe 1457** ISA bus I/O device probe
1459*/ 1458*/
1460 1459
1461static void __devinit depca_platform_probe (void) 1460static void __init depca_platform_probe (void)
1462{ 1461{
1463 int i; 1462 int i;
1464 struct platform_device *pldev; 1463 struct platform_device *pldev;
@@ -1498,7 +1497,7 @@ static void __devinit depca_platform_probe (void)
1498 } 1497 }
1499} 1498}
1500 1499
1501static enum depca_type __devinit depca_shmem_probe (ulong *mem_start) 1500static enum depca_type __init depca_shmem_probe (ulong *mem_start)
1502{ 1501{
1503 u_long mem_base[] = DEPCA_RAM_BASE_ADDRESSES; 1502 u_long mem_base[] = DEPCA_RAM_BASE_ADDRESSES;
1504 enum depca_type adapter = unknown; 1503 enum depca_type adapter = unknown;
@@ -1559,7 +1558,7 @@ static int __devinit depca_isa_probe (struct platform_device *device)
1559*/ 1558*/
1560 1559
1561#ifdef CONFIG_EISA 1560#ifdef CONFIG_EISA
1562static int __devinit depca_eisa_probe (struct device *device) 1561static int __init depca_eisa_probe (struct device *device)
1563{ 1562{
1564 enum depca_type adapter = unknown; 1563 enum depca_type adapter = unknown;
1565 struct eisa_device *edev; 1564 struct eisa_device *edev;
@@ -1630,7 +1629,7 @@ static int __devexit depca_device_remove (struct device *device)
1630** and Boot (readb) ROM. This will also give us a clue to the network RAM 1629** and Boot (readb) ROM. This will also give us a clue to the network RAM
1631** base address. 1630** base address.
1632*/ 1631*/
1633static int __devinit DepcaSignature(char *name, u_long base_addr) 1632static int __init DepcaSignature(char *name, u_long base_addr)
1634{ 1633{
1635 u_int i, j, k; 1634 u_int i, j, k;
1636 void __iomem *ptr; 1635 void __iomem *ptr;
diff --git a/drivers/net/dm9000.c b/drivers/net/dm9000.c
index fbaff3584bd4..ee597e676ee5 100644
--- a/drivers/net/dm9000.c
+++ b/drivers/net/dm9000.c
@@ -1157,9 +1157,6 @@ dm9000_open(struct net_device *dev)
1157 1157
1158 irqflags |= IRQF_SHARED; 1158 irqflags |= IRQF_SHARED;
1159 1159
1160 if (request_irq(dev->irq, dm9000_interrupt, irqflags, dev->name, dev))
1161 return -EAGAIN;
1162
1163 /* GPIO0 on pre-activate PHY, Reg 1F is not set by reset */ 1160 /* GPIO0 on pre-activate PHY, Reg 1F is not set by reset */
1164 iow(db, DM9000_GPR, 0); /* REG_1F bit0 activate phyxcer */ 1161 iow(db, DM9000_GPR, 0); /* REG_1F bit0 activate phyxcer */
1165 mdelay(1); /* delay needs by DM9000B */ 1162 mdelay(1); /* delay needs by DM9000B */
@@ -1168,6 +1165,9 @@ dm9000_open(struct net_device *dev)
1168 dm9000_reset(db); 1165 dm9000_reset(db);
1169 dm9000_init_dm9000(dev); 1166 dm9000_init_dm9000(dev);
1170 1167
1168 if (request_irq(dev->irq, dm9000_interrupt, irqflags, dev->name, dev))
1169 return -EAGAIN;
1170
1171 /* Init driver variable */ 1171 /* Init driver variable */
1172 db->dbug_cnt = 0; 1172 db->dbug_cnt = 0;
1173 1173
diff --git a/drivers/net/hamradio/6pack.c b/drivers/net/hamradio/6pack.c
index 992089639ea4..3e5d0b6b6516 100644
--- a/drivers/net/hamradio/6pack.c
+++ b/drivers/net/hamradio/6pack.c
@@ -456,7 +456,7 @@ out:
456 * a block of 6pack data has been received, which can now be decapsulated 456 * a block of 6pack data has been received, which can now be decapsulated
457 * and sent on to some IP layer for further processing. 457 * and sent on to some IP layer for further processing.
458 */ 458 */
459static unsigned int sixpack_receive_buf(struct tty_struct *tty, 459static void sixpack_receive_buf(struct tty_struct *tty,
460 const unsigned char *cp, char *fp, int count) 460 const unsigned char *cp, char *fp, int count)
461{ 461{
462 struct sixpack *sp; 462 struct sixpack *sp;
@@ -464,11 +464,11 @@ static unsigned int sixpack_receive_buf(struct tty_struct *tty,
464 int count1; 464 int count1;
465 465
466 if (!count) 466 if (!count)
467 return 0; 467 return;
468 468
469 sp = sp_get(tty); 469 sp = sp_get(tty);
470 if (!sp) 470 if (!sp)
471 return -ENODEV; 471 return;
472 472
473 memcpy(buf, cp, count < sizeof(buf) ? count : sizeof(buf)); 473 memcpy(buf, cp, count < sizeof(buf) ? count : sizeof(buf));
474 474
@@ -487,8 +487,6 @@ static unsigned int sixpack_receive_buf(struct tty_struct *tty,
487 487
488 sp_put(sp); 488 sp_put(sp);
489 tty_unthrottle(tty); 489 tty_unthrottle(tty);
490
491 return count1;
492} 490}
493 491
494/* 492/*
diff --git a/drivers/net/hamradio/mkiss.c b/drivers/net/hamradio/mkiss.c
index 0e4f23531140..4c628393c8b1 100644
--- a/drivers/net/hamradio/mkiss.c
+++ b/drivers/net/hamradio/mkiss.c
@@ -923,14 +923,13 @@ static long mkiss_compat_ioctl(struct tty_struct *tty, struct file *file,
923 * a block of data has been received, which can now be decapsulated 923 * a block of data has been received, which can now be decapsulated
924 * and sent on to the AX.25 layer for further processing. 924 * and sent on to the AX.25 layer for further processing.
925 */ 925 */
926static unsigned int mkiss_receive_buf(struct tty_struct *tty, 926static void mkiss_receive_buf(struct tty_struct *tty, const unsigned char *cp,
927 const unsigned char *cp, char *fp, int count) 927 char *fp, int count)
928{ 928{
929 struct mkiss *ax = mkiss_get(tty); 929 struct mkiss *ax = mkiss_get(tty);
930 int bytes = count;
931 930
932 if (!ax) 931 if (!ax)
933 return -ENODEV; 932 return;
934 933
935 /* 934 /*
936 * Argh! mtu change time! - costs us the packet part received 935 * Argh! mtu change time! - costs us the packet part received
@@ -940,7 +939,7 @@ static unsigned int mkiss_receive_buf(struct tty_struct *tty,
940 ax_changedmtu(ax); 939 ax_changedmtu(ax);
941 940
942 /* Read the characters out of the buffer */ 941 /* Read the characters out of the buffer */
943 while (bytes--) { 942 while (count--) {
944 if (fp != NULL && *fp++) { 943 if (fp != NULL && *fp++) {
945 if (!test_and_set_bit(AXF_ERROR, &ax->flags)) 944 if (!test_and_set_bit(AXF_ERROR, &ax->flags))
946 ax->dev->stats.rx_errors++; 945 ax->dev->stats.rx_errors++;
@@ -953,8 +952,6 @@ static unsigned int mkiss_receive_buf(struct tty_struct *tty,
953 952
954 mkiss_put(ax); 953 mkiss_put(ax);
955 tty_unthrottle(tty); 954 tty_unthrottle(tty);
956
957 return count;
958} 955}
959 956
960/* 957/*
diff --git a/drivers/net/hp100.c b/drivers/net/hp100.c
index c52a1df5d922..8e10d2f6a5ad 100644
--- a/drivers/net/hp100.c
+++ b/drivers/net/hp100.c
@@ -188,14 +188,14 @@ struct hp100_private {
188 * variables 188 * variables
189 */ 189 */
190#ifdef CONFIG_ISA 190#ifdef CONFIG_ISA
191static const char *const hp100_isa_tbl[] __devinitconst = { 191static const char *hp100_isa_tbl[] = {
192 "HWPF150", /* HP J2573 rev A */ 192 "HWPF150", /* HP J2573 rev A */
193 "HWP1950", /* HP J2573 */ 193 "HWP1950", /* HP J2573 */
194}; 194};
195#endif 195#endif
196 196
197#ifdef CONFIG_EISA 197#ifdef CONFIG_EISA
198static const struct eisa_device_id hp100_eisa_tbl[] __devinitconst = { 198static struct eisa_device_id hp100_eisa_tbl[] = {
199 { "HWPF180" }, /* HP J2577 rev A */ 199 { "HWPF180" }, /* HP J2577 rev A */
200 { "HWP1920" }, /* HP 27248B */ 200 { "HWP1920" }, /* HP 27248B */
201 { "HWP1940" }, /* HP J2577 */ 201 { "HWP1940" }, /* HP J2577 */
@@ -336,7 +336,7 @@ static __devinit const char *hp100_read_id(int ioaddr)
336} 336}
337 337
338#ifdef CONFIG_ISA 338#ifdef CONFIG_ISA
339static __devinit int hp100_isa_probe1(struct net_device *dev, int ioaddr) 339static __init int hp100_isa_probe1(struct net_device *dev, int ioaddr)
340{ 340{
341 const char *sig; 341 const char *sig;
342 int i; 342 int i;
@@ -372,7 +372,7 @@ static __devinit int hp100_isa_probe1(struct net_device *dev, int ioaddr)
372 * EISA and PCI are handled by device infrastructure. 372 * EISA and PCI are handled by device infrastructure.
373 */ 373 */
374 374
375static int __devinit hp100_isa_probe(struct net_device *dev, int addr) 375static int __init hp100_isa_probe(struct net_device *dev, int addr)
376{ 376{
377 int err = -ENODEV; 377 int err = -ENODEV;
378 378
@@ -396,7 +396,7 @@ static int __devinit hp100_isa_probe(struct net_device *dev, int addr)
396#endif /* CONFIG_ISA */ 396#endif /* CONFIG_ISA */
397 397
398#if !defined(MODULE) && defined(CONFIG_ISA) 398#if !defined(MODULE) && defined(CONFIG_ISA)
399struct net_device * __devinit hp100_probe(int unit) 399struct net_device * __init hp100_probe(int unit)
400{ 400{
401 struct net_device *dev = alloc_etherdev(sizeof(struct hp100_private)); 401 struct net_device *dev = alloc_etherdev(sizeof(struct hp100_private));
402 int err; 402 int err;
@@ -2843,7 +2843,7 @@ static void cleanup_dev(struct net_device *d)
2843} 2843}
2844 2844
2845#ifdef CONFIG_EISA 2845#ifdef CONFIG_EISA
2846static int __devinit hp100_eisa_probe (struct device *gendev) 2846static int __init hp100_eisa_probe (struct device *gendev)
2847{ 2847{
2848 struct net_device *dev = alloc_etherdev(sizeof(struct hp100_private)); 2848 struct net_device *dev = alloc_etherdev(sizeof(struct hp100_private));
2849 struct eisa_device *edev = to_eisa_device(gendev); 2849 struct eisa_device *edev = to_eisa_device(gendev);
diff --git a/drivers/net/ibmlana.c b/drivers/net/ibmlana.c
index 136d7544cc33..a7d6cad32953 100644
--- a/drivers/net/ibmlana.c
+++ b/drivers/net/ibmlana.c
@@ -895,12 +895,12 @@ static int ibmlana_irq;
895static int ibmlana_io; 895static int ibmlana_io;
896static int startslot; /* counts through slots when probing multiple devices */ 896static int startslot; /* counts through slots when probing multiple devices */
897 897
898static const short ibmlana_adapter_ids[] __devinitconst = { 898static short ibmlana_adapter_ids[] __initdata = {
899 IBM_LANA_ID, 899 IBM_LANA_ID,
900 0x0000 900 0x0000
901}; 901};
902 902
903static const char *const ibmlana_adapter_names[] __devinitconst = { 903static char *ibmlana_adapter_names[] __devinitdata = {
904 "IBM LAN Adapter/A", 904 "IBM LAN Adapter/A",
905 NULL 905 NULL
906}; 906};
diff --git a/drivers/net/irda/irtty-sir.c b/drivers/net/irda/irtty-sir.c
index 035861d8acb1..3352b2443e58 100644
--- a/drivers/net/irda/irtty-sir.c
+++ b/drivers/net/irda/irtty-sir.c
@@ -216,23 +216,23 @@ static int irtty_do_write(struct sir_dev *dev, const unsigned char *ptr, size_t
216 * usbserial: urb-complete-interrupt / softint 216 * usbserial: urb-complete-interrupt / softint
217 */ 217 */
218 218
219static unsigned int irtty_receive_buf(struct tty_struct *tty, 219static void irtty_receive_buf(struct tty_struct *tty, const unsigned char *cp,
220 const unsigned char *cp, char *fp, int count) 220 char *fp, int count)
221{ 221{
222 struct sir_dev *dev; 222 struct sir_dev *dev;
223 struct sirtty_cb *priv = tty->disc_data; 223 struct sirtty_cb *priv = tty->disc_data;
224 int i; 224 int i;
225 225
226 IRDA_ASSERT(priv != NULL, return -ENODEV;); 226 IRDA_ASSERT(priv != NULL, return;);
227 IRDA_ASSERT(priv->magic == IRTTY_MAGIC, return -EINVAL;); 227 IRDA_ASSERT(priv->magic == IRTTY_MAGIC, return;);
228 228
229 if (unlikely(count==0)) /* yes, this happens */ 229 if (unlikely(count==0)) /* yes, this happens */
230 return 0; 230 return;
231 231
232 dev = priv->dev; 232 dev = priv->dev;
233 if (!dev) { 233 if (!dev) {
234 IRDA_WARNING("%s(), not ready yet!\n", __func__); 234 IRDA_WARNING("%s(), not ready yet!\n", __func__);
235 return -ENODEV; 235 return;
236 } 236 }
237 237
238 for (i = 0; i < count; i++) { 238 for (i = 0; i < count; i++) {
@@ -242,13 +242,11 @@ static unsigned int irtty_receive_buf(struct tty_struct *tty,
242 if (fp && *fp++) { 242 if (fp && *fp++) {
243 IRDA_DEBUG(0, "Framing or parity error!\n"); 243 IRDA_DEBUG(0, "Framing or parity error!\n");
244 sirdev_receive(dev, NULL, 0); /* notify sir_dev (updating stats) */ 244 sirdev_receive(dev, NULL, 0); /* notify sir_dev (updating stats) */
245 return -EINVAL; 245 return;
246 } 246 }
247 } 247 }
248 248
249 sirdev_receive(dev, cp, count); 249 sirdev_receive(dev, cp, count);
250
251 return count;
252} 250}
253 251
254/* 252/*
diff --git a/drivers/net/irda/smsc-ircc2.c b/drivers/net/irda/smsc-ircc2.c
index 69b5707db369..8800e1fe4129 100644
--- a/drivers/net/irda/smsc-ircc2.c
+++ b/drivers/net/irda/smsc-ircc2.c
@@ -222,19 +222,19 @@ static void smsc_ircc_set_transceiver_for_speed(struct smsc_ircc_cb *self, u32 s
222static void smsc_ircc_sir_wait_hw_transmitter_finish(struct smsc_ircc_cb *self); 222static void smsc_ircc_sir_wait_hw_transmitter_finish(struct smsc_ircc_cb *self);
223 223
224/* Probing */ 224/* Probing */
225static int smsc_ircc_look_for_chips(void); 225static int __init smsc_ircc_look_for_chips(void);
226static const struct smsc_chip * smsc_ircc_probe(unsigned short cfg_base, u8 reg, const struct smsc_chip *chip, char *type); 226static const struct smsc_chip * __init smsc_ircc_probe(unsigned short cfg_base, u8 reg, const struct smsc_chip *chip, char *type);
227static int smsc_superio_flat(const struct smsc_chip *chips, unsigned short cfg_base, char *type); 227static int __init smsc_superio_flat(const struct smsc_chip *chips, unsigned short cfg_base, char *type);
228static int smsc_superio_paged(const struct smsc_chip *chips, unsigned short cfg_base, char *type); 228static int __init smsc_superio_paged(const struct smsc_chip *chips, unsigned short cfg_base, char *type);
229static int smsc_superio_fdc(unsigned short cfg_base); 229static int __init smsc_superio_fdc(unsigned short cfg_base);
230static int smsc_superio_lpc(unsigned short cfg_base); 230static int __init smsc_superio_lpc(unsigned short cfg_base);
231#ifdef CONFIG_PCI 231#ifdef CONFIG_PCI
232static int preconfigure_smsc_chip(struct smsc_ircc_subsystem_configuration *conf); 232static int __init preconfigure_smsc_chip(struct smsc_ircc_subsystem_configuration *conf);
233static int preconfigure_through_82801(struct pci_dev *dev, struct smsc_ircc_subsystem_configuration *conf); 233static int __init preconfigure_through_82801(struct pci_dev *dev, struct smsc_ircc_subsystem_configuration *conf);
234static void preconfigure_ali_port(struct pci_dev *dev, 234static void __init preconfigure_ali_port(struct pci_dev *dev,
235 unsigned short port); 235 unsigned short port);
236static int preconfigure_through_ali(struct pci_dev *dev, struct smsc_ircc_subsystem_configuration *conf); 236static int __init preconfigure_through_ali(struct pci_dev *dev, struct smsc_ircc_subsystem_configuration *conf);
237static int smsc_ircc_preconfigure_subsystems(unsigned short ircc_cfg, 237static int __init smsc_ircc_preconfigure_subsystems(unsigned short ircc_cfg,
238 unsigned short ircc_fir, 238 unsigned short ircc_fir,
239 unsigned short ircc_sir, 239 unsigned short ircc_sir,
240 unsigned char ircc_dma, 240 unsigned char ircc_dma,
@@ -366,7 +366,7 @@ static inline void register_bank(int iobase, int bank)
366} 366}
367 367
368/* PNP hotplug support */ 368/* PNP hotplug support */
369static const struct pnp_device_id smsc_ircc_pnp_table[] __devinitconst = { 369static const struct pnp_device_id smsc_ircc_pnp_table[] = {
370 { .id = "SMCf010", .driver_data = 0 }, 370 { .id = "SMCf010", .driver_data = 0 },
371 /* and presumably others */ 371 /* and presumably others */
372 { } 372 { }
@@ -515,7 +515,7 @@ static const struct net_device_ops smsc_ircc_netdev_ops = {
515 * Try to open driver instance 515 * Try to open driver instance
516 * 516 *
517 */ 517 */
518static int __devinit smsc_ircc_open(unsigned int fir_base, unsigned int sir_base, u8 dma, u8 irq) 518static int __init smsc_ircc_open(unsigned int fir_base, unsigned int sir_base, u8 dma, u8 irq)
519{ 519{
520 struct smsc_ircc_cb *self; 520 struct smsc_ircc_cb *self;
521 struct net_device *dev; 521 struct net_device *dev;
@@ -2273,7 +2273,7 @@ static int __init smsc_superio_paged(const struct smsc_chip *chips, unsigned sho
2273} 2273}
2274 2274
2275 2275
2276static int __devinit smsc_access(unsigned short cfg_base, unsigned char reg) 2276static int __init smsc_access(unsigned short cfg_base, unsigned char reg)
2277{ 2277{
2278 IRDA_DEBUG(1, "%s\n", __func__); 2278 IRDA_DEBUG(1, "%s\n", __func__);
2279 2279
@@ -2281,7 +2281,7 @@ static int __devinit smsc_access(unsigned short cfg_base, unsigned char reg)
2281 return inb(cfg_base) != reg ? -1 : 0; 2281 return inb(cfg_base) != reg ? -1 : 0;
2282} 2282}
2283 2283
2284static const struct smsc_chip * __devinit smsc_ircc_probe(unsigned short cfg_base, u8 reg, const struct smsc_chip *chip, char *type) 2284static const struct smsc_chip * __init smsc_ircc_probe(unsigned short cfg_base, u8 reg, const struct smsc_chip *chip, char *type)
2285{ 2285{
2286 u8 devid, xdevid, rev; 2286 u8 devid, xdevid, rev;
2287 2287
@@ -2406,7 +2406,7 @@ static int __init smsc_superio_lpc(unsigned short cfg_base)
2406#ifdef CONFIG_PCI 2406#ifdef CONFIG_PCI
2407#define PCIID_VENDOR_INTEL 0x8086 2407#define PCIID_VENDOR_INTEL 0x8086
2408#define PCIID_VENDOR_ALI 0x10b9 2408#define PCIID_VENDOR_ALI 0x10b9
2409static const struct smsc_ircc_subsystem_configuration subsystem_configurations[] __devinitconst = { 2409static struct smsc_ircc_subsystem_configuration subsystem_configurations[] __initdata = {
2410 /* 2410 /*
2411 * Subsystems needing entries: 2411 * Subsystems needing entries:
2412 * 0x10b9:0x1533 0x103c:0x0850 HP nx9010 family 2412 * 0x10b9:0x1533 0x103c:0x0850 HP nx9010 family
@@ -2532,7 +2532,7 @@ static const struct smsc_ircc_subsystem_configuration subsystem_configurations[]
2532 * (FIR port, SIR port, FIR DMA, FIR IRQ) 2532 * (FIR port, SIR port, FIR DMA, FIR IRQ)
2533 * through the chip configuration port. 2533 * through the chip configuration port.
2534 */ 2534 */
2535static int __devinit preconfigure_smsc_chip(struct 2535static int __init preconfigure_smsc_chip(struct
2536 smsc_ircc_subsystem_configuration 2536 smsc_ircc_subsystem_configuration
2537 *conf) 2537 *conf)
2538{ 2538{
@@ -2633,7 +2633,7 @@ static int __devinit preconfigure_smsc_chip(struct
2633 * or Intel 82801DB/DBL (ICH4/ICH4-L) LPC Interface Bridge. 2633 * or Intel 82801DB/DBL (ICH4/ICH4-L) LPC Interface Bridge.
2634 * They all work the same way! 2634 * They all work the same way!
2635 */ 2635 */
2636static int __devinit preconfigure_through_82801(struct pci_dev *dev, 2636static int __init preconfigure_through_82801(struct pci_dev *dev,
2637 struct 2637 struct
2638 smsc_ircc_subsystem_configuration 2638 smsc_ircc_subsystem_configuration
2639 *conf) 2639 *conf)
@@ -2786,7 +2786,7 @@ static int __devinit preconfigure_through_82801(struct pci_dev *dev,
2786 * This is based on reverse-engineering since ALi does not 2786 * This is based on reverse-engineering since ALi does not
2787 * provide any data sheet for the 1533 chip. 2787 * provide any data sheet for the 1533 chip.
2788 */ 2788 */
2789static void __devinit preconfigure_ali_port(struct pci_dev *dev, 2789static void __init preconfigure_ali_port(struct pci_dev *dev,
2790 unsigned short port) 2790 unsigned short port)
2791{ 2791{
2792 unsigned char reg; 2792 unsigned char reg;
@@ -2824,7 +2824,7 @@ static void __devinit preconfigure_ali_port(struct pci_dev *dev,
2824 IRDA_MESSAGE("Activated ALi 1533 ISA bridge port 0x%04x.\n", port); 2824 IRDA_MESSAGE("Activated ALi 1533 ISA bridge port 0x%04x.\n", port);
2825} 2825}
2826 2826
2827static int __devinit preconfigure_through_ali(struct pci_dev *dev, 2827static int __init preconfigure_through_ali(struct pci_dev *dev,
2828 struct 2828 struct
2829 smsc_ircc_subsystem_configuration 2829 smsc_ircc_subsystem_configuration
2830 *conf) 2830 *conf)
@@ -2837,7 +2837,7 @@ static int __devinit preconfigure_through_ali(struct pci_dev *dev,
2837 return preconfigure_smsc_chip(conf); 2837 return preconfigure_smsc_chip(conf);
2838} 2838}
2839 2839
2840static int __devinit smsc_ircc_preconfigure_subsystems(unsigned short ircc_cfg, 2840static int __init smsc_ircc_preconfigure_subsystems(unsigned short ircc_cfg,
2841 unsigned short ircc_fir, 2841 unsigned short ircc_fir,
2842 unsigned short ircc_sir, 2842 unsigned short ircc_sir,
2843 unsigned char ircc_dma, 2843 unsigned char ircc_dma,
@@ -2849,7 +2849,7 @@ static int __devinit smsc_ircc_preconfigure_subsystems(unsigned short ircc_cfg,
2849 int ret = 0; 2849 int ret = 0;
2850 2850
2851 for_each_pci_dev(dev) { 2851 for_each_pci_dev(dev) {
2852 const struct smsc_ircc_subsystem_configuration *conf; 2852 struct smsc_ircc_subsystem_configuration *conf;
2853 2853
2854 /* 2854 /*
2855 * Cache the subsystem vendor/device: 2855 * Cache the subsystem vendor/device:
diff --git a/drivers/net/ks8842.c b/drivers/net/ks8842.c
index 4d40626b3bfa..fc12ac0d9f2e 100644
--- a/drivers/net/ks8842.c
+++ b/drivers/net/ks8842.c
@@ -661,7 +661,7 @@ static void ks8842_rx_frame(struct net_device *netdev,
661 661
662 /* check the status */ 662 /* check the status */
663 if ((status & RXSR_VALID) && !(status & RXSR_ERROR)) { 663 if ((status & RXSR_VALID) && !(status & RXSR_ERROR)) {
664 struct sk_buff *skb = netdev_alloc_skb_ip_align(netdev, len); 664 struct sk_buff *skb = netdev_alloc_skb_ip_align(netdev, len + 3);
665 665
666 if (skb) { 666 if (skb) {
667 667
diff --git a/drivers/net/ne3210.c b/drivers/net/ne3210.c
index e8984b0ca521..243ed2aee88e 100644
--- a/drivers/net/ne3210.c
+++ b/drivers/net/ne3210.c
@@ -80,20 +80,17 @@ static void ne3210_block_output(struct net_device *dev, int count, const unsigne
80 80
81#define NE3210_DEBUG 0x0 81#define NE3210_DEBUG 0x0
82 82
83static const unsigned char irq_map[] __devinitconst = 83static unsigned char irq_map[] __initdata = {15, 12, 11, 10, 9, 7, 5, 3};
84 { 15, 12, 11, 10, 9, 7, 5, 3 }; 84static unsigned int shmem_map[] __initdata = {0xff0, 0xfe0, 0xfff0, 0xd8, 0xffe0, 0xffc0, 0xd0, 0x0};
85static const unsigned int shmem_map[] __devinitconst = 85static const char *ifmap[] __initdata = {"UTP", "?", "BNC", "AUI"};
86 { 0xff0, 0xfe0, 0xfff0, 0xd8, 0xffe0, 0xffc0, 0xd0, 0x0 }; 86static int ifmap_val[] __initdata = {
87static const char *const ifmap[] __devinitconst =
88 { "UTP", "?", "BNC", "AUI" };
89static const int ifmap_val[] __devinitconst = {
90 IF_PORT_10BASET, 87 IF_PORT_10BASET,
91 IF_PORT_UNKNOWN, 88 IF_PORT_UNKNOWN,
92 IF_PORT_10BASE2, 89 IF_PORT_10BASE2,
93 IF_PORT_AUI, 90 IF_PORT_AUI,
94}; 91};
95 92
96static int __devinit ne3210_eisa_probe (struct device *device) 93static int __init ne3210_eisa_probe (struct device *device)
97{ 94{
98 unsigned long ioaddr, phys_mem; 95 unsigned long ioaddr, phys_mem;
99 int i, retval, port_index; 96 int i, retval, port_index;
@@ -316,7 +313,7 @@ static void ne3210_block_output(struct net_device *dev, int count,
316 memcpy_toio(shmem, buf, count); 313 memcpy_toio(shmem, buf, count);
317} 314}
318 315
319static const struct eisa_device_id ne3210_ids[] __devinitconst = { 316static struct eisa_device_id ne3210_ids[] = {
320 { "EGL0101" }, 317 { "EGL0101" },
321 { "NVL1801" }, 318 { "NVL1801" },
322 { "" }, 319 { "" },
diff --git a/drivers/net/ppp_async.c b/drivers/net/ppp_async.c
index 53872d7d7382..a1b82c9c67d2 100644
--- a/drivers/net/ppp_async.c
+++ b/drivers/net/ppp_async.c
@@ -340,7 +340,7 @@ ppp_asynctty_poll(struct tty_struct *tty, struct file *file, poll_table *wait)
340} 340}
341 341
342/* May sleep, don't call from interrupt level or with interrupts disabled */ 342/* May sleep, don't call from interrupt level or with interrupts disabled */
343static unsigned int 343static void
344ppp_asynctty_receive(struct tty_struct *tty, const unsigned char *buf, 344ppp_asynctty_receive(struct tty_struct *tty, const unsigned char *buf,
345 char *cflags, int count) 345 char *cflags, int count)
346{ 346{
@@ -348,7 +348,7 @@ ppp_asynctty_receive(struct tty_struct *tty, const unsigned char *buf,
348 unsigned long flags; 348 unsigned long flags;
349 349
350 if (!ap) 350 if (!ap)
351 return -ENODEV; 351 return;
352 spin_lock_irqsave(&ap->recv_lock, flags); 352 spin_lock_irqsave(&ap->recv_lock, flags);
353 ppp_async_input(ap, buf, cflags, count); 353 ppp_async_input(ap, buf, cflags, count);
354 spin_unlock_irqrestore(&ap->recv_lock, flags); 354 spin_unlock_irqrestore(&ap->recv_lock, flags);
@@ -356,8 +356,6 @@ ppp_asynctty_receive(struct tty_struct *tty, const unsigned char *buf,
356 tasklet_schedule(&ap->tsk); 356 tasklet_schedule(&ap->tsk);
357 ap_put(ap); 357 ap_put(ap);
358 tty_unthrottle(tty); 358 tty_unthrottle(tty);
359
360 return count;
361} 359}
362 360
363static void 361static void
diff --git a/drivers/net/ppp_synctty.c b/drivers/net/ppp_synctty.c
index 0815790a5cf9..2573f525f11c 100644
--- a/drivers/net/ppp_synctty.c
+++ b/drivers/net/ppp_synctty.c
@@ -381,7 +381,7 @@ ppp_sync_poll(struct tty_struct *tty, struct file *file, poll_table *wait)
381} 381}
382 382
383/* May sleep, don't call from interrupt level or with interrupts disabled */ 383/* May sleep, don't call from interrupt level or with interrupts disabled */
384static unsigned int 384static void
385ppp_sync_receive(struct tty_struct *tty, const unsigned char *buf, 385ppp_sync_receive(struct tty_struct *tty, const unsigned char *buf,
386 char *cflags, int count) 386 char *cflags, int count)
387{ 387{
@@ -389,7 +389,7 @@ ppp_sync_receive(struct tty_struct *tty, const unsigned char *buf,
389 unsigned long flags; 389 unsigned long flags;
390 390
391 if (!ap) 391 if (!ap)
392 return -ENODEV; 392 return;
393 spin_lock_irqsave(&ap->recv_lock, flags); 393 spin_lock_irqsave(&ap->recv_lock, flags);
394 ppp_sync_input(ap, buf, cflags, count); 394 ppp_sync_input(ap, buf, cflags, count);
395 spin_unlock_irqrestore(&ap->recv_lock, flags); 395 spin_unlock_irqrestore(&ap->recv_lock, flags);
@@ -397,8 +397,6 @@ ppp_sync_receive(struct tty_struct *tty, const unsigned char *buf,
397 tasklet_schedule(&ap->tsk); 397 tasklet_schedule(&ap->tsk);
398 sp_put(ap); 398 sp_put(ap);
399 tty_unthrottle(tty); 399 tty_unthrottle(tty);
400
401 return count;
402} 400}
403 401
404static void 402static void
diff --git a/drivers/net/slip.c b/drivers/net/slip.c
index 584809c656d5..8ec1a9a0bb9a 100644
--- a/drivers/net/slip.c
+++ b/drivers/net/slip.c
@@ -670,17 +670,16 @@ static void sl_setup(struct net_device *dev)
670 * in parallel 670 * in parallel
671 */ 671 */
672 672
673static unsigned int slip_receive_buf(struct tty_struct *tty, 673static void slip_receive_buf(struct tty_struct *tty, const unsigned char *cp,
674 const unsigned char *cp, char *fp, int count) 674 char *fp, int count)
675{ 675{
676 struct slip *sl = tty->disc_data; 676 struct slip *sl = tty->disc_data;
677 int bytes = count;
678 677
679 if (!sl || sl->magic != SLIP_MAGIC || !netif_running(sl->dev)) 678 if (!sl || sl->magic != SLIP_MAGIC || !netif_running(sl->dev))
680 return -ENODEV; 679 return;
681 680
682 /* Read the characters out of the buffer */ 681 /* Read the characters out of the buffer */
683 while (bytes--) { 682 while (count--) {
684 if (fp && *fp++) { 683 if (fp && *fp++) {
685 if (!test_and_set_bit(SLF_ERROR, &sl->flags)) 684 if (!test_and_set_bit(SLF_ERROR, &sl->flags))
686 sl->dev->stats.rx_errors++; 685 sl->dev->stats.rx_errors++;
@@ -694,8 +693,6 @@ static unsigned int slip_receive_buf(struct tty_struct *tty,
694#endif 693#endif
695 slip_unesc(sl, *cp++); 694 slip_unesc(sl, *cp++);
696 } 695 }
697
698 return count;
699} 696}
700 697
701/************************************ 698/************************************
diff --git a/drivers/net/smc-mca.c b/drivers/net/smc-mca.c
index 0f29f261fcfe..d07c39cb4daf 100644
--- a/drivers/net/smc-mca.c
+++ b/drivers/net/smc-mca.c
@@ -156,7 +156,7 @@ static const struct {
156 { 14, 15 } 156 { 14, 15 }
157}; 157};
158 158
159static const short smc_mca_adapter_ids[] __devinitconst = { 159static short smc_mca_adapter_ids[] __initdata = {
160 0x61c8, 160 0x61c8,
161 0x61c9, 161 0x61c9,
162 0x6fc0, 162 0x6fc0,
@@ -168,7 +168,7 @@ static const short smc_mca_adapter_ids[] __devinitconst = {
168 0x0000 168 0x0000
169}; 169};
170 170
171static const char *const smc_mca_adapter_names[] __devinitconst = { 171static char *smc_mca_adapter_names[] __initdata = {
172 "SMC Ethercard PLUS Elite/A BNC/AUI (WD8013EP/A)", 172 "SMC Ethercard PLUS Elite/A BNC/AUI (WD8013EP/A)",
173 "SMC Ethercard PLUS Elite/A UTP/AUI (WD8013WP/A)", 173 "SMC Ethercard PLUS Elite/A UTP/AUI (WD8013WP/A)",
174 "WD Ethercard PLUS/A (WD8003E/A or WD8003ET/A)", 174 "WD Ethercard PLUS/A (WD8003E/A or WD8003ET/A)",
@@ -199,7 +199,7 @@ static const struct net_device_ops ultramca_netdev_ops = {
199#endif 199#endif
200}; 200};
201 201
202static int __devinit ultramca_probe(struct device *gen_dev) 202static int __init ultramca_probe(struct device *gen_dev)
203{ 203{
204 unsigned short ioaddr; 204 unsigned short ioaddr;
205 struct net_device *dev; 205 struct net_device *dev;
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index f4b01c638a33..a1f9f9eef37d 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -5774,7 +5774,7 @@ static void tg3_skb_error_unmap(struct tg3_napi *tnapi,
5774 dma_unmap_addr(txb, mapping), 5774 dma_unmap_addr(txb, mapping),
5775 skb_headlen(skb), 5775 skb_headlen(skb),
5776 PCI_DMA_TODEVICE); 5776 PCI_DMA_TODEVICE);
5777 for (i = 0; i <= last; i++) { 5777 for (i = 0; i < last; i++) {
5778 skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; 5778 skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
5779 5779
5780 entry = NEXT_TX(entry); 5780 entry = NEXT_TX(entry);
diff --git a/drivers/net/tokenring/madgemc.c b/drivers/net/tokenring/madgemc.c
index 1313aa1315f0..2bedc0ace812 100644
--- a/drivers/net/tokenring/madgemc.c
+++ b/drivers/net/tokenring/madgemc.c
@@ -727,7 +727,7 @@ static int __devexit madgemc_remove(struct device *device)
727 return 0; 727 return 0;
728} 728}
729 729
730static const short madgemc_adapter_ids[] __devinitconst = { 730static short madgemc_adapter_ids[] __initdata = {
731 0x002d, 731 0x002d,
732 0x0000 732 0x0000
733}; 733};
diff --git a/drivers/net/tulip/de4x5.c b/drivers/net/tulip/de4x5.c
index 45144d5bd11b..efaa1d69b720 100644
--- a/drivers/net/tulip/de4x5.c
+++ b/drivers/net/tulip/de4x5.c
@@ -1995,7 +1995,7 @@ SetMulticastFilter(struct net_device *dev)
1995 1995
1996static u_char de4x5_irq[] = EISA_ALLOWED_IRQ_LIST; 1996static u_char de4x5_irq[] = EISA_ALLOWED_IRQ_LIST;
1997 1997
1998static int __devinit de4x5_eisa_probe (struct device *gendev) 1998static int __init de4x5_eisa_probe (struct device *gendev)
1999{ 1999{
2000 struct eisa_device *edev; 2000 struct eisa_device *edev;
2001 u_long iobase; 2001 u_long iobase;
@@ -2097,7 +2097,7 @@ static int __devexit de4x5_eisa_remove (struct device *device)
2097 return 0; 2097 return 0;
2098} 2098}
2099 2099
2100static const struct eisa_device_id de4x5_eisa_ids[] __devinitconst = { 2100static struct eisa_device_id de4x5_eisa_ids[] = {
2101 { "DEC4250", 0 }, /* 0 is the board name index... */ 2101 { "DEC4250", 0 }, /* 0 is the board name index... */
2102 { "" } 2102 { "" }
2103}; 2103};
diff --git a/drivers/net/usb/catc.c b/drivers/net/usb/catc.c
index d7221c4a5dcf..8056f8a27c6a 100644
--- a/drivers/net/usb/catc.c
+++ b/drivers/net/usb/catc.c
@@ -495,7 +495,7 @@ static void catc_ctrl_run(struct catc *catc)
495 if (!q->dir && q->buf && q->len) 495 if (!q->dir && q->buf && q->len)
496 memcpy(catc->ctrl_buf, q->buf, q->len); 496 memcpy(catc->ctrl_buf, q->buf, q->len);
497 497
498 if ((status = usb_submit_urb(catc->ctrl_urb, GFP_KERNEL))) 498 if ((status = usb_submit_urb(catc->ctrl_urb, GFP_ATOMIC)))
499 err("submit(ctrl_urb) status %d", status); 499 err("submit(ctrl_urb) status %d", status);
500} 500}
501 501
diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index cdd3ae486109..f33ca6aa29e9 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -54,7 +54,7 @@
54#include <linux/usb/usbnet.h> 54#include <linux/usb/usbnet.h>
55#include <linux/usb/cdc.h> 55#include <linux/usb/cdc.h>
56 56
57#define DRIVER_VERSION "24-May-2011" 57#define DRIVER_VERSION "01-June-2011"
58 58
59/* CDC NCM subclass 3.2.1 */ 59/* CDC NCM subclass 3.2.1 */
60#define USB_CDC_NCM_NDP16_LENGTH_MIN 0x10 60#define USB_CDC_NCM_NDP16_LENGTH_MIN 0x10
@@ -1234,6 +1234,7 @@ static struct usb_driver cdc_ncm_driver = {
1234 .disconnect = cdc_ncm_disconnect, 1234 .disconnect = cdc_ncm_disconnect,
1235 .suspend = usbnet_suspend, 1235 .suspend = usbnet_suspend,
1236 .resume = usbnet_resume, 1236 .resume = usbnet_resume,
1237 .reset_resume = usbnet_resume,
1237 .supports_autosuspend = 1, 1238 .supports_autosuspend = 1,
1238}; 1239};
1239 1240
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 0cb0b0632672..f6853247a620 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -609,7 +609,7 @@ static netdev_tx_t start_xmit(struct sk_buff *skb, struct net_device *dev)
609 * before it gets out of hand. Naturally, this wastes entries. */ 609 * before it gets out of hand. Naturally, this wastes entries. */
610 if (capacity < 2+MAX_SKB_FRAGS) { 610 if (capacity < 2+MAX_SKB_FRAGS) {
611 netif_stop_queue(dev); 611 netif_stop_queue(dev);
612 if (unlikely(!virtqueue_enable_cb(vi->svq))) { 612 if (unlikely(!virtqueue_enable_cb_delayed(vi->svq))) {
613 /* More just got used, free them then recheck. */ 613 /* More just got used, free them then recheck. */
614 capacity += free_old_xmit_skbs(vi); 614 capacity += free_old_xmit_skbs(vi);
615 if (capacity >= 2+MAX_SKB_FRAGS) { 615 if (capacity >= 2+MAX_SKB_FRAGS) {
diff --git a/drivers/net/wan/x25_asy.c b/drivers/net/wan/x25_asy.c
index 40398bf7d036..24297b274cd4 100644
--- a/drivers/net/wan/x25_asy.c
+++ b/drivers/net/wan/x25_asy.c
@@ -517,18 +517,17 @@ static int x25_asy_close(struct net_device *dev)
517 * and sent on to some IP layer for further processing. 517 * and sent on to some IP layer for further processing.
518 */ 518 */
519 519
520static unsigned int x25_asy_receive_buf(struct tty_struct *tty, 520static void x25_asy_receive_buf(struct tty_struct *tty,
521 const unsigned char *cp, char *fp, int count) 521 const unsigned char *cp, char *fp, int count)
522{ 522{
523 struct x25_asy *sl = tty->disc_data; 523 struct x25_asy *sl = tty->disc_data;
524 int bytes = count;
525 524
526 if (!sl || sl->magic != X25_ASY_MAGIC || !netif_running(sl->dev)) 525 if (!sl || sl->magic != X25_ASY_MAGIC || !netif_running(sl->dev))
527 return; 526 return;
528 527
529 528
530 /* Read the characters out of the buffer */ 529 /* Read the characters out of the buffer */
531 while (bytes--) { 530 while (count--) {
532 if (fp && *fp++) { 531 if (fp && *fp++) {
533 if (!test_and_set_bit(SLF_ERROR, &sl->flags)) 532 if (!test_and_set_bit(SLF_ERROR, &sl->flags))
534 sl->dev->stats.rx_errors++; 533 sl->dev->stats.rx_errors++;
@@ -537,8 +536,6 @@ static unsigned int x25_asy_receive_buf(struct tty_struct *tty,
537 } 536 }
538 x25_asy_unesc(sl, *cp++); 537 x25_asy_unesc(sl, *cp++);
539 } 538 }
540
541 return count;
542} 539}
543 540
544/* 541/*
diff --git a/drivers/net/wireless/ath/ath9k/Kconfig b/drivers/net/wireless/ath/ath9k/Kconfig
index d9ff8413ab9a..d9c08c619a3a 100644
--- a/drivers/net/wireless/ath/ath9k/Kconfig
+++ b/drivers/net/wireless/ath/ath9k/Kconfig
@@ -26,7 +26,6 @@ config ATH9K
26config ATH9K_PCI 26config ATH9K_PCI
27 bool "Atheros ath9k PCI/PCIe bus support" 27 bool "Atheros ath9k PCI/PCIe bus support"
28 depends on ATH9K && PCI 28 depends on ATH9K && PCI
29 default PCI
30 ---help--- 29 ---help---
31 This option enables the PCI bus support in ath9k. 30 This option enables the PCI bus support in ath9k.
32 31
diff --git a/drivers/net/wireless/ath/ath9k/ar9002_calib.c b/drivers/net/wireless/ath/ath9k/ar9002_calib.c
index 015d97439935..2d4c0910295b 100644
--- a/drivers/net/wireless/ath/ath9k/ar9002_calib.c
+++ b/drivers/net/wireless/ath/ath9k/ar9002_calib.c
@@ -829,7 +829,7 @@ static bool ar9002_hw_init_cal(struct ath_hw *ah, struct ath9k_channel *chan)
829 if (AR_SREV_9271(ah)) { 829 if (AR_SREV_9271(ah)) {
830 if (!ar9285_hw_cl_cal(ah, chan)) 830 if (!ar9285_hw_cl_cal(ah, chan))
831 return false; 831 return false;
832 } else if (AR_SREV_9285_12_OR_LATER(ah)) { 832 } else if (AR_SREV_9285(ah) && AR_SREV_9285_12_OR_LATER(ah)) {
833 if (!ar9285_hw_clc(ah, chan)) 833 if (!ar9285_hw_clc(ah, chan))
834 return false; 834 return false;
835 } else { 835 } else {
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
index 0ca7635d0669..ff8150e46f0e 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
@@ -4645,10 +4645,16 @@ static void ar9003_hw_set_power_per_rate_table(struct ath_hw *ah,
4645 case 1: 4645 case 1:
4646 break; 4646 break;
4647 case 2: 4647 case 2:
4648 scaledPower -= REDUCE_SCALED_POWER_BY_TWO_CHAIN; 4648 if (scaledPower > REDUCE_SCALED_POWER_BY_TWO_CHAIN)
4649 scaledPower -= REDUCE_SCALED_POWER_BY_TWO_CHAIN;
4650 else
4651 scaledPower = 0;
4649 break; 4652 break;
4650 case 3: 4653 case 3:
4651 scaledPower -= REDUCE_SCALED_POWER_BY_THREE_CHAIN; 4654 if (scaledPower > REDUCE_SCALED_POWER_BY_THREE_CHAIN)
4655 scaledPower -= REDUCE_SCALED_POWER_BY_THREE_CHAIN;
4656 else
4657 scaledPower = 0;
4652 break; 4658 break;
4653 } 4659 }
4654 4660
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_phy.c b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
index eee23ecd118a..892c48b15434 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_phy.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
@@ -1381,3 +1381,25 @@ void ar9003_hw_bb_watchdog_dbg_info(struct ath_hw *ah)
1381 "==== BB update: done ====\n\n"); 1381 "==== BB update: done ====\n\n");
1382} 1382}
1383EXPORT_SYMBOL(ar9003_hw_bb_watchdog_dbg_info); 1383EXPORT_SYMBOL(ar9003_hw_bb_watchdog_dbg_info);
1384
1385void ar9003_hw_disable_phy_restart(struct ath_hw *ah)
1386{
1387 u32 val;
1388
1389 /* While receiving unsupported rate frame rx state machine
1390 * gets into a state 0xb and if phy_restart happens in that
1391 * state, BB would go hang. If RXSM is in 0xb state after
1392 * first bb panic, ensure to disable the phy_restart.
1393 */
1394 if (!((MS(ah->bb_watchdog_last_status,
1395 AR_PHY_WATCHDOG_RX_OFDM_SM) == 0xb) ||
1396 ah->bb_hang_rx_ofdm))
1397 return;
1398
1399 ah->bb_hang_rx_ofdm = true;
1400 val = REG_READ(ah, AR_PHY_RESTART);
1401 val &= ~AR_PHY_RESTART_ENA;
1402
1403 REG_WRITE(ah, AR_PHY_RESTART, val);
1404}
1405EXPORT_SYMBOL(ar9003_hw_disable_phy_restart);
diff --git a/drivers/net/wireless/ath/ath9k/eeprom_9287.c b/drivers/net/wireless/ath/ath9k/eeprom_9287.c
index 7856f0d4512d..343fc9f946db 100644
--- a/drivers/net/wireless/ath/ath9k/eeprom_9287.c
+++ b/drivers/net/wireless/ath/ath9k/eeprom_9287.c
@@ -524,10 +524,16 @@ static void ath9k_hw_set_ar9287_power_per_rate_table(struct ath_hw *ah,
524 case 1: 524 case 1:
525 break; 525 break;
526 case 2: 526 case 2:
527 scaledPower -= REDUCE_SCALED_POWER_BY_TWO_CHAIN; 527 if (scaledPower > REDUCE_SCALED_POWER_BY_TWO_CHAIN)
528 scaledPower -= REDUCE_SCALED_POWER_BY_TWO_CHAIN;
529 else
530 scaledPower = 0;
528 break; 531 break;
529 case 3: 532 case 3:
530 scaledPower -= REDUCE_SCALED_POWER_BY_THREE_CHAIN; 533 if (scaledPower > REDUCE_SCALED_POWER_BY_THREE_CHAIN)
534 scaledPower -= REDUCE_SCALED_POWER_BY_THREE_CHAIN;
535 else
536 scaledPower = 0;
531 break; 537 break;
532 } 538 }
533 scaledPower = max((u16)0, scaledPower); 539 scaledPower = max((u16)0, scaledPower);
diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c
index 72543ce8f616..1be7c8bbef84 100644
--- a/drivers/net/wireless/ath/ath9k/hw.c
+++ b/drivers/net/wireless/ath/ath9k/hw.c
@@ -1555,9 +1555,12 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,
1555 if (ah->btcoex_hw.enabled) 1555 if (ah->btcoex_hw.enabled)
1556 ath9k_hw_btcoex_enable(ah); 1556 ath9k_hw_btcoex_enable(ah);
1557 1557
1558 if (AR_SREV_9300_20_OR_LATER(ah)) 1558 if (AR_SREV_9300_20_OR_LATER(ah)) {
1559 ar9003_hw_bb_watchdog_config(ah); 1559 ar9003_hw_bb_watchdog_config(ah);
1560 1560
1561 ar9003_hw_disable_phy_restart(ah);
1562 }
1563
1561 ath9k_hw_apply_gpio_override(ah); 1564 ath9k_hw_apply_gpio_override(ah);
1562 1565
1563 return 0; 1566 return 0;
diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
index 57435ce62792..4b157c53d1a8 100644
--- a/drivers/net/wireless/ath/ath9k/hw.h
+++ b/drivers/net/wireless/ath/ath9k/hw.h
@@ -842,6 +842,7 @@ struct ath_hw {
842 842
843 u32 bb_watchdog_last_status; 843 u32 bb_watchdog_last_status;
844 u32 bb_watchdog_timeout_ms; /* in ms, 0 to disable */ 844 u32 bb_watchdog_timeout_ms; /* in ms, 0 to disable */
845 u8 bb_hang_rx_ofdm; /* true if bb hang due to rx_ofdm */
845 846
846 unsigned int paprd_target_power; 847 unsigned int paprd_target_power;
847 unsigned int paprd_training_power; 848 unsigned int paprd_training_power;
@@ -990,6 +991,7 @@ void ar9002_hw_enable_wep_aggregation(struct ath_hw *ah);
990void ar9003_hw_bb_watchdog_config(struct ath_hw *ah); 991void ar9003_hw_bb_watchdog_config(struct ath_hw *ah);
991void ar9003_hw_bb_watchdog_read(struct ath_hw *ah); 992void ar9003_hw_bb_watchdog_read(struct ath_hw *ah);
992void ar9003_hw_bb_watchdog_dbg_info(struct ath_hw *ah); 993void ar9003_hw_bb_watchdog_dbg_info(struct ath_hw *ah);
994void ar9003_hw_disable_phy_restart(struct ath_hw *ah);
993void ar9003_paprd_enable(struct ath_hw *ah, bool val); 995void ar9003_paprd_enable(struct ath_hw *ah, bool val);
994void ar9003_paprd_populate_single_table(struct ath_hw *ah, 996void ar9003_paprd_populate_single_table(struct ath_hw *ah,
995 struct ath9k_hw_cal_data *caldata, 997 struct ath9k_hw_cal_data *caldata,
diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
index a198ee374b05..2ca351fe6d3c 100644
--- a/drivers/net/wireless/ath/ath9k/main.c
+++ b/drivers/net/wireless/ath/ath9k/main.c
@@ -670,7 +670,8 @@ void ath9k_tasklet(unsigned long data)
670 u32 status = sc->intrstatus; 670 u32 status = sc->intrstatus;
671 u32 rxmask; 671 u32 rxmask;
672 672
673 if (status & ATH9K_INT_FATAL) { 673 if ((status & ATH9K_INT_FATAL) ||
674 (status & ATH9K_INT_BB_WATCHDOG)) {
674 ath_reset(sc, true); 675 ath_reset(sc, true);
675 return; 676 return;
676 } 677 }
@@ -737,6 +738,7 @@ irqreturn_t ath_isr(int irq, void *dev)
737{ 738{
738#define SCHED_INTR ( \ 739#define SCHED_INTR ( \
739 ATH9K_INT_FATAL | \ 740 ATH9K_INT_FATAL | \
741 ATH9K_INT_BB_WATCHDOG | \
740 ATH9K_INT_RXORN | \ 742 ATH9K_INT_RXORN | \
741 ATH9K_INT_RXEOL | \ 743 ATH9K_INT_RXEOL | \
742 ATH9K_INT_RX | \ 744 ATH9K_INT_RX | \
diff --git a/drivers/net/wireless/ath/ath9k/rc.c b/drivers/net/wireless/ath/ath9k/rc.c
index 17542214c93f..ba7f36ab0a74 100644
--- a/drivers/net/wireless/ath/ath9k/rc.c
+++ b/drivers/net/wireless/ath/ath9k/rc.c
@@ -689,7 +689,8 @@ static void ath_rc_rate_set_series(const struct ath_rate_table *rate_table,
689 689
690 if (WLAN_RC_PHY_HT(rate_table->info[rix].phy)) { 690 if (WLAN_RC_PHY_HT(rate_table->info[rix].phy)) {
691 rate->flags |= IEEE80211_TX_RC_MCS; 691 rate->flags |= IEEE80211_TX_RC_MCS;
692 if (WLAN_RC_PHY_40(rate_table->info[rix].phy)) 692 if (WLAN_RC_PHY_40(rate_table->info[rix].phy) &&
693 conf_is_ht40(&txrc->hw->conf))
693 rate->flags |= IEEE80211_TX_RC_40_MHZ_WIDTH; 694 rate->flags |= IEEE80211_TX_RC_40_MHZ_WIDTH;
694 if (WLAN_RC_PHY_SGI(rate_table->info[rix].phy)) 695 if (WLAN_RC_PHY_SGI(rate_table->info[rix].phy))
695 rate->flags |= IEEE80211_TX_RC_SHORT_GI; 696 rate->flags |= IEEE80211_TX_RC_SHORT_GI;
diff --git a/drivers/net/wireless/b43/phy_n.c b/drivers/net/wireless/b43/phy_n.c
index 9ed65157bef5..05960ddde24e 100644
--- a/drivers/net/wireless/b43/phy_n.c
+++ b/drivers/net/wireless/b43/phy_n.c
@@ -3093,7 +3093,7 @@ static int b43_nphy_cal_tx_iq_lo(struct b43_wldev *dev,
3093 int freq; 3093 int freq;
3094 bool avoid = false; 3094 bool avoid = false;
3095 u8 length; 3095 u8 length;
3096 u16 tmp, core, type, count, max, numb, last, cmd; 3096 u16 tmp, core, type, count, max, numb, last = 0, cmd;
3097 const u16 *table; 3097 const u16 *table;
3098 bool phy6or5x; 3098 bool phy6or5x;
3099 3099
diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c
index 7e5e85a017b5..a7a4739880dc 100644
--- a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c
+++ b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c
@@ -628,11 +628,11 @@ void iwl4965_rx_reply_rx(struct iwl_priv *priv,
628 628
629 /* rx_status carries information about the packet to mac80211 */ 629 /* rx_status carries information about the packet to mac80211 */
630 rx_status.mactime = le64_to_cpu(phy_res->timestamp); 630 rx_status.mactime = le64_to_cpu(phy_res->timestamp);
631 rx_status.band = (phy_res->phy_flags & RX_RES_PHY_FLAGS_BAND_24_MSK) ?
632 IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ;
631 rx_status.freq = 633 rx_status.freq =
632 ieee80211_channel_to_frequency(le16_to_cpu(phy_res->channel), 634 ieee80211_channel_to_frequency(le16_to_cpu(phy_res->channel),
633 rx_status.band); 635 rx_status.band);
634 rx_status.band = (phy_res->phy_flags & RX_RES_PHY_FLAGS_BAND_24_MSK) ?
635 IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ;
636 rx_status.rate_idx = 636 rx_status.rate_idx =
637 iwl4965_hwrate_to_mac80211_idx(rate_n_flags, rx_status.band); 637 iwl4965_hwrate_to_mac80211_idx(rate_n_flags, rx_status.band);
638 rx_status.flag = 0; 638 rx_status.flag = 0;
diff --git a/drivers/net/wireless/iwlegacy/iwl-4965.c b/drivers/net/wireless/iwlegacy/iwl-4965.c
index f5433c74b845..f9db25bb35c3 100644
--- a/drivers/net/wireless/iwlegacy/iwl-4965.c
+++ b/drivers/net/wireless/iwlegacy/iwl-4965.c
@@ -1543,7 +1543,7 @@ static void iwl4965_temperature_calib(struct iwl_priv *priv)
1543 s32 temp; 1543 s32 temp;
1544 1544
1545 temp = iwl4965_hw_get_temperature(priv); 1545 temp = iwl4965_hw_get_temperature(priv);
1546 if (temp < 0) 1546 if (IWL_TX_POWER_TEMPERATURE_OUT_OF_RANGE(temp))
1547 return; 1547 return;
1548 1548
1549 if (priv->temperature != temp) { 1549 if (priv->temperature != temp) {
diff --git a/drivers/net/wireless/iwlwifi/iwl-6000.c b/drivers/net/wireless/iwlwifi/iwl-6000.c
index f8c710db6e6f..fda6fe08cf91 100644
--- a/drivers/net/wireless/iwlwifi/iwl-6000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-6000.c
@@ -603,19 +603,27 @@ struct iwl_cfg iwl6050_2abg_cfg = {
603 IWL_DEVICE_6050, 603 IWL_DEVICE_6050,
604}; 604};
605 605
606#define IWL_DEVICE_6150 \
607 .fw_name_pre = IWL6050_FW_PRE, \
608 .ucode_api_max = IWL6050_UCODE_API_MAX, \
609 .ucode_api_min = IWL6050_UCODE_API_MIN, \
610 .ops = &iwl6150_ops, \
611 .eeprom_ver = EEPROM_6150_EEPROM_VERSION, \
612 .eeprom_calib_ver = EEPROM_6150_TX_POWER_VERSION, \
613 .base_params = &iwl6050_base_params, \
614 .need_dc_calib = true, \
615 .led_mode = IWL_LED_BLINK, \
616 .internal_wimax_coex = true
617
606struct iwl_cfg iwl6150_bgn_cfg = { 618struct iwl_cfg iwl6150_bgn_cfg = {
607 .name = "Intel(R) Centrino(R) Wireless-N + WiMAX 6150 BGN", 619 .name = "Intel(R) Centrino(R) Wireless-N + WiMAX 6150 BGN",
608 .fw_name_pre = IWL6050_FW_PRE, 620 IWL_DEVICE_6150,
609 .ucode_api_max = IWL6050_UCODE_API_MAX,
610 .ucode_api_min = IWL6050_UCODE_API_MIN,
611 .eeprom_ver = EEPROM_6150_EEPROM_VERSION,
612 .eeprom_calib_ver = EEPROM_6150_TX_POWER_VERSION,
613 .ops = &iwl6150_ops,
614 .base_params = &iwl6050_base_params,
615 .ht_params = &iwl6000_ht_params, 621 .ht_params = &iwl6000_ht_params,
616 .need_dc_calib = true, 622};
617 .led_mode = IWL_LED_RF_STATE, 623
618 .internal_wimax_coex = true, 624struct iwl_cfg iwl6150_bg_cfg = {
625 .name = "Intel(R) Centrino(R) Wireless-N + WiMAX 6150 BG",
626 IWL_DEVICE_6150,
619}; 627};
620 628
621struct iwl_cfg iwl6000_3agn_cfg = { 629struct iwl_cfg iwl6000_3agn_cfg = {
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
index 11c6c1169e78..a662adcb2adb 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
@@ -3831,11 +3831,11 @@ static DEFINE_PCI_DEVICE_TABLE(iwl_hw_card_ids) = {
3831 3831
3832/* 6150 WiFi/WiMax Series */ 3832/* 6150 WiFi/WiMax Series */
3833 {IWL_PCI_DEVICE(0x0885, 0x1305, iwl6150_bgn_cfg)}, 3833 {IWL_PCI_DEVICE(0x0885, 0x1305, iwl6150_bgn_cfg)},
3834 {IWL_PCI_DEVICE(0x0885, 0x1306, iwl6150_bgn_cfg)}, 3834 {IWL_PCI_DEVICE(0x0885, 0x1307, iwl6150_bg_cfg)},
3835 {IWL_PCI_DEVICE(0x0885, 0x1325, iwl6150_bgn_cfg)}, 3835 {IWL_PCI_DEVICE(0x0885, 0x1325, iwl6150_bgn_cfg)},
3836 {IWL_PCI_DEVICE(0x0885, 0x1326, iwl6150_bgn_cfg)}, 3836 {IWL_PCI_DEVICE(0x0885, 0x1327, iwl6150_bg_cfg)},
3837 {IWL_PCI_DEVICE(0x0886, 0x1315, iwl6150_bgn_cfg)}, 3837 {IWL_PCI_DEVICE(0x0886, 0x1315, iwl6150_bgn_cfg)},
3838 {IWL_PCI_DEVICE(0x0886, 0x1316, iwl6150_bgn_cfg)}, 3838 {IWL_PCI_DEVICE(0x0886, 0x1317, iwl6150_bg_cfg)},
3839 3839
3840/* 1000 Series WiFi */ 3840/* 1000 Series WiFi */
3841 {IWL_PCI_DEVICE(0x0083, 0x1205, iwl1000_bgn_cfg)}, 3841 {IWL_PCI_DEVICE(0x0083, 0x1205, iwl1000_bgn_cfg)},
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.h b/drivers/net/wireless/iwlwifi/iwl-agn.h
index 2495fe7a58cb..d1716844002e 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.h
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.h
@@ -89,6 +89,7 @@ extern struct iwl_cfg iwl6000_3agn_cfg;
89extern struct iwl_cfg iwl6050_2agn_cfg; 89extern struct iwl_cfg iwl6050_2agn_cfg;
90extern struct iwl_cfg iwl6050_2abg_cfg; 90extern struct iwl_cfg iwl6050_2abg_cfg;
91extern struct iwl_cfg iwl6150_bgn_cfg; 91extern struct iwl_cfg iwl6150_bgn_cfg;
92extern struct iwl_cfg iwl6150_bg_cfg;
92extern struct iwl_cfg iwl1000_bgn_cfg; 93extern struct iwl_cfg iwl1000_bgn_cfg;
93extern struct iwl_cfg iwl1000_bg_cfg; 94extern struct iwl_cfg iwl1000_bg_cfg;
94extern struct iwl_cfg iwl100_bgn_cfg; 95extern struct iwl_cfg iwl100_bgn_cfg;
diff --git a/drivers/net/wireless/libertas/cmd.c b/drivers/net/wireless/libertas/cmd.c
index 84566db486d2..71c8f3fccfa1 100644
--- a/drivers/net/wireless/libertas/cmd.c
+++ b/drivers/net/wireless/libertas/cmd.c
@@ -994,6 +994,8 @@ static void lbs_submit_command(struct lbs_private *priv,
994 cmd = cmdnode->cmdbuf; 994 cmd = cmdnode->cmdbuf;
995 995
996 spin_lock_irqsave(&priv->driver_lock, flags); 996 spin_lock_irqsave(&priv->driver_lock, flags);
997 priv->seqnum++;
998 cmd->seqnum = cpu_to_le16(priv->seqnum);
997 priv->cur_cmd = cmdnode; 999 priv->cur_cmd = cmdnode;
998 spin_unlock_irqrestore(&priv->driver_lock, flags); 1000 spin_unlock_irqrestore(&priv->driver_lock, flags);
999 1001
@@ -1621,11 +1623,9 @@ struct cmd_ctrl_node *__lbs_cmd_async(struct lbs_private *priv,
1621 /* Copy the incoming command to the buffer */ 1623 /* Copy the incoming command to the buffer */
1622 memcpy(cmdnode->cmdbuf, in_cmd, in_cmd_size); 1624 memcpy(cmdnode->cmdbuf, in_cmd, in_cmd_size);
1623 1625
1624 /* Set sequence number, clean result, move to buffer */ 1626 /* Set command, clean result, move to buffer */
1625 priv->seqnum++;
1626 cmdnode->cmdbuf->command = cpu_to_le16(command); 1627 cmdnode->cmdbuf->command = cpu_to_le16(command);
1627 cmdnode->cmdbuf->size = cpu_to_le16(in_cmd_size); 1628 cmdnode->cmdbuf->size = cpu_to_le16(in_cmd_size);
1628 cmdnode->cmdbuf->seqnum = cpu_to_le16(priv->seqnum);
1629 cmdnode->cmdbuf->result = 0; 1629 cmdnode->cmdbuf->result = 0;
1630 1630
1631 lbs_deb_host("PREP_CMD: command 0x%04x\n", command); 1631 lbs_deb_host("PREP_CMD: command 0x%04x\n", command);
diff --git a/drivers/net/wireless/mwifiex/sdio.h b/drivers/net/wireless/mwifiex/sdio.h
index a0e9bc5253e0..4e97e90aa399 100644
--- a/drivers/net/wireless/mwifiex/sdio.h
+++ b/drivers/net/wireless/mwifiex/sdio.h
@@ -167,8 +167,8 @@
167/* Rx unit register */ 167/* Rx unit register */
168#define CARD_RX_UNIT_REG 0x63 168#define CARD_RX_UNIT_REG 0x63
169 169
170/* Event header Len*/ 170/* Event header len w/o 4 bytes of interface header */
171#define MWIFIEX_EVENT_HEADER_LEN 8 171#define MWIFIEX_EVENT_HEADER_LEN 4
172 172
173/* Max retry number of CMD53 write */ 173/* Max retry number of CMD53 write */
174#define MAX_WRITE_IOMEM_RETRY 2 174#define MAX_WRITE_IOMEM_RETRY 2
diff --git a/drivers/net/wireless/rt2x00/Kconfig b/drivers/net/wireless/rt2x00/Kconfig
index 9def1e5369a1..b2f8b8fd4d2d 100644
--- a/drivers/net/wireless/rt2x00/Kconfig
+++ b/drivers/net/wireless/rt2x00/Kconfig
@@ -166,7 +166,6 @@ config RT2800USB_RT35XX
166config RT2800USB_RT53XX 166config RT2800USB_RT53XX
167 bool "rt2800usb - Include support for rt53xx devices (EXPERIMENTAL)" 167 bool "rt2800usb - Include support for rt53xx devices (EXPERIMENTAL)"
168 depends on EXPERIMENTAL 168 depends on EXPERIMENTAL
169 default y
170 ---help--- 169 ---help---
171 This adds support for rt53xx wireless chipset family to the 170 This adds support for rt53xx wireless chipset family to the
172 rt2800pci driver. 171 rt2800pci driver.
diff --git a/drivers/net/wireless/rtlwifi/pci.c b/drivers/net/wireless/rtlwifi/pci.c
index a40952845436..89100e7c553b 100644
--- a/drivers/net/wireless/rtlwifi/pci.c
+++ b/drivers/net/wireless/rtlwifi/pci.c
@@ -669,11 +669,6 @@ static void _rtl_pci_rx_interrupt(struct ieee80211_hw *hw)
669 &rx_status, 669 &rx_status,
670 (u8 *) pdesc, skb); 670 (u8 *) pdesc, skb);
671 671
672 pci_unmap_single(rtlpci->pdev,
673 *((dma_addr_t *) skb->cb),
674 rtlpci->rxbuffersize,
675 PCI_DMA_FROMDEVICE);
676
677 skb_put(skb, rtlpriv->cfg->ops->get_desc((u8 *) pdesc, 672 skb_put(skb, rtlpriv->cfg->ops->get_desc((u8 *) pdesc,
678 false, 673 false,
679 HW_DESC_RXPKT_LEN)); 674 HW_DESC_RXPKT_LEN));
@@ -690,6 +685,21 @@ static void _rtl_pci_rx_interrupt(struct ieee80211_hw *hw)
690 hdr = rtl_get_hdr(skb); 685 hdr = rtl_get_hdr(skb);
691 fc = rtl_get_fc(skb); 686 fc = rtl_get_fc(skb);
692 687
688 /* try for new buffer - if allocation fails, drop
689 * frame and reuse old buffer
690 */
691 new_skb = dev_alloc_skb(rtlpci->rxbuffersize);
692 if (unlikely(!new_skb)) {
693 RT_TRACE(rtlpriv, (COMP_INTR | COMP_RECV),
694 DBG_DMESG,
695 ("can't alloc skb for rx\n"));
696 goto done;
697 }
698 pci_unmap_single(rtlpci->pdev,
699 *((dma_addr_t *) skb->cb),
700 rtlpci->rxbuffersize,
701 PCI_DMA_FROMDEVICE);
702
693 if (!stats.crc || !stats.hwerror) { 703 if (!stats.crc || !stats.hwerror) {
694 memcpy(IEEE80211_SKB_RXCB(skb), &rx_status, 704 memcpy(IEEE80211_SKB_RXCB(skb), &rx_status,
695 sizeof(rx_status)); 705 sizeof(rx_status));
@@ -758,15 +768,7 @@ static void _rtl_pci_rx_interrupt(struct ieee80211_hw *hw)
758 rtl_lps_leave(hw); 768 rtl_lps_leave(hw);
759 } 769 }
760 770
761 new_skb = dev_alloc_skb(rtlpci->rxbuffersize);
762 if (unlikely(!new_skb)) {
763 RT_TRACE(rtlpriv, (COMP_INTR | COMP_RECV),
764 DBG_DMESG,
765 ("can't alloc skb for rx\n"));
766 goto done;
767 }
768 skb = new_skb; 771 skb = new_skb;
769 /*skb->dev = dev; */
770 772
771 rtlpci->rx_ring[rx_queue_idx].rx_buf[rtlpci-> 773 rtlpci->rx_ring[rx_queue_idx].rx_buf[rtlpci->
772 rx_ring 774 rx_ring
@@ -1113,6 +1115,13 @@ static int _rtl_pci_init_rx_ring(struct ieee80211_hw *hw)
1113 1115
1114 rtlpci->rx_ring[rx_queue_idx].idx = 0; 1116 rtlpci->rx_ring[rx_queue_idx].idx = 0;
1115 1117
1118 /* If amsdu_8k is disabled, set buffersize to 4096. This
1119 * change will reduce memory fragmentation.
1120 */
1121 if (rtlpci->rxbuffersize > 4096 &&
1122 rtlpriv->rtlhal.disable_amsdu_8k)
1123 rtlpci->rxbuffersize = 4096;
1124
1116 for (i = 0; i < rtlpci->rxringcount; i++) { 1125 for (i = 0; i < rtlpci->rxringcount; i++) {
1117 struct sk_buff *skb = 1126 struct sk_buff *skb =
1118 dev_alloc_skb(rtlpci->rxbuffersize); 1127 dev_alloc_skb(rtlpci->rxbuffersize);
diff --git a/drivers/net/wireless/wl12xx/conf.h b/drivers/net/wireless/wl12xx/conf.h
index 1ab6c86aac40..c83fefb6662f 100644
--- a/drivers/net/wireless/wl12xx/conf.h
+++ b/drivers/net/wireless/wl12xx/conf.h
@@ -1157,6 +1157,9 @@ struct conf_sched_scan_settings {
1157 /* time to wait on the channel for passive scans (in TUs) */ 1157 /* time to wait on the channel for passive scans (in TUs) */
1158 u32 dwell_time_passive; 1158 u32 dwell_time_passive;
1159 1159
1160 /* time to wait on the channel for DFS scans (in TUs) */
1161 u32 dwell_time_dfs;
1162
1160 /* number of probe requests to send on each channel in active scans */ 1163 /* number of probe requests to send on each channel in active scans */
1161 u8 num_probe_reqs; 1164 u8 num_probe_reqs;
1162 1165
diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c
index bc00e52f6445..e6497dc669df 100644
--- a/drivers/net/wireless/wl12xx/main.c
+++ b/drivers/net/wireless/wl12xx/main.c
@@ -311,6 +311,7 @@ static struct conf_drv_settings default_conf = {
311 .min_dwell_time_active = 8, 311 .min_dwell_time_active = 8,
312 .max_dwell_time_active = 30, 312 .max_dwell_time_active = 30,
313 .dwell_time_passive = 100, 313 .dwell_time_passive = 100,
314 .dwell_time_dfs = 150,
314 .num_probe_reqs = 2, 315 .num_probe_reqs = 2,
315 .rssi_threshold = -90, 316 .rssi_threshold = -90,
316 .snr_threshold = 0, 317 .snr_threshold = 0,
diff --git a/drivers/net/wireless/wl12xx/scan.c b/drivers/net/wireless/wl12xx/scan.c
index f37e5a391976..56f76abc754d 100644
--- a/drivers/net/wireless/wl12xx/scan.c
+++ b/drivers/net/wireless/wl12xx/scan.c
@@ -331,16 +331,22 @@ wl1271_scan_get_sched_scan_channels(struct wl1271 *wl,
331 struct conf_sched_scan_settings *c = &wl->conf.sched_scan; 331 struct conf_sched_scan_settings *c = &wl->conf.sched_scan;
332 int i, j; 332 int i, j;
333 u32 flags; 333 u32 flags;
334 bool force_passive = !req->n_ssids;
334 335
335 for (i = 0, j = start; 336 for (i = 0, j = start;
336 i < req->n_channels && j < MAX_CHANNELS_ALL_BANDS; 337 i < req->n_channels && j < MAX_CHANNELS_ALL_BANDS;
337 i++) { 338 i++) {
338 flags = req->channels[i]->flags; 339 flags = req->channels[i]->flags;
339 340
340 if (!(flags & IEEE80211_CHAN_DISABLED) && 341 if (force_passive)
341 ((flags & IEEE80211_CHAN_PASSIVE_SCAN) == passive) && 342 flags |= IEEE80211_CHAN_PASSIVE_SCAN;
342 ((flags & IEEE80211_CHAN_RADAR) == radar) && 343
343 (req->channels[i]->band == band)) { 344 if ((req->channels[i]->band == band) &&
345 !(flags & IEEE80211_CHAN_DISABLED) &&
346 (!!(flags & IEEE80211_CHAN_RADAR) == radar) &&
347 /* if radar is set, we ignore the passive flag */
348 (radar ||
349 !!(flags & IEEE80211_CHAN_PASSIVE_SCAN) == passive)) {
344 wl1271_debug(DEBUG_SCAN, "band %d, center_freq %d ", 350 wl1271_debug(DEBUG_SCAN, "band %d, center_freq %d ",
345 req->channels[i]->band, 351 req->channels[i]->band,
346 req->channels[i]->center_freq); 352 req->channels[i]->center_freq);
@@ -350,7 +356,12 @@ wl1271_scan_get_sched_scan_channels(struct wl1271 *wl,
350 wl1271_debug(DEBUG_SCAN, "max_power %d", 356 wl1271_debug(DEBUG_SCAN, "max_power %d",
351 req->channels[i]->max_power); 357 req->channels[i]->max_power);
352 358
353 if (flags & IEEE80211_CHAN_PASSIVE_SCAN) { 359 if (flags & IEEE80211_CHAN_RADAR) {
360 channels[j].flags |= SCAN_CHANNEL_FLAGS_DFS;
361 channels[j].passive_duration =
362 cpu_to_le16(c->dwell_time_dfs);
363 }
364 else if (flags & IEEE80211_CHAN_PASSIVE_SCAN) {
354 channels[j].passive_duration = 365 channels[j].passive_duration =
355 cpu_to_le16(c->dwell_time_passive); 366 cpu_to_le16(c->dwell_time_passive);
356 } else { 367 } else {
@@ -359,7 +370,7 @@ wl1271_scan_get_sched_scan_channels(struct wl1271 *wl,
359 channels[j].max_duration = 370 channels[j].max_duration =
360 cpu_to_le16(c->max_dwell_time_active); 371 cpu_to_le16(c->max_dwell_time_active);
361 } 372 }
362 channels[j].tx_power_att = req->channels[j]->max_power; 373 channels[j].tx_power_att = req->channels[i]->max_power;
363 channels[j].channel = req->channels[i]->hw_value; 374 channels[j].channel = req->channels[i]->hw_value;
364 375
365 j++; 376 j++;
@@ -386,7 +397,11 @@ wl1271_scan_sched_scan_channels(struct wl1271 *wl,
386 wl1271_scan_get_sched_scan_channels(wl, req, cfg->channels, 397 wl1271_scan_get_sched_scan_channels(wl, req, cfg->channels,
387 IEEE80211_BAND_2GHZ, 398 IEEE80211_BAND_2GHZ,
388 false, false, idx); 399 false, false, idx);
389 idx += cfg->active[0]; 400 /*
401 * 5GHz channels always start at position 14, not immediately
402 * after the last 2.4GHz channel
403 */
404 idx = 14;
390 405
391 cfg->passive[1] = 406 cfg->passive[1] =
392 wl1271_scan_get_sched_scan_channels(wl, req, cfg->channels, 407 wl1271_scan_get_sched_scan_channels(wl, req, cfg->channels,
@@ -394,22 +409,23 @@ wl1271_scan_sched_scan_channels(struct wl1271 *wl,
394 false, true, idx); 409 false, true, idx);
395 idx += cfg->passive[1]; 410 idx += cfg->passive[1];
396 411
397 cfg->active[1] = 412 cfg->dfs =
398 wl1271_scan_get_sched_scan_channels(wl, req, cfg->channels, 413 wl1271_scan_get_sched_scan_channels(wl, req, cfg->channels,
399 IEEE80211_BAND_5GHZ, 414 IEEE80211_BAND_5GHZ,
400 false, false, 14); 415 true, true, idx);
401 idx += cfg->active[1]; 416 idx += cfg->dfs;
402 417
403 cfg->dfs = 418 cfg->active[1] =
404 wl1271_scan_get_sched_scan_channels(wl, req, cfg->channels, 419 wl1271_scan_get_sched_scan_channels(wl, req, cfg->channels,
405 IEEE80211_BAND_5GHZ, 420 IEEE80211_BAND_5GHZ,
406 true, false, idx); 421 false, false, idx);
407 idx += cfg->dfs; 422 idx += cfg->active[1];
408 423
409 wl1271_debug(DEBUG_SCAN, " 2.4GHz: active %d passive %d", 424 wl1271_debug(DEBUG_SCAN, " 2.4GHz: active %d passive %d",
410 cfg->active[0], cfg->passive[0]); 425 cfg->active[0], cfg->passive[0]);
411 wl1271_debug(DEBUG_SCAN, " 5GHz: active %d passive %d", 426 wl1271_debug(DEBUG_SCAN, " 5GHz: active %d passive %d",
412 cfg->active[1], cfg->passive[1]); 427 cfg->active[1], cfg->passive[1]);
428 wl1271_debug(DEBUG_SCAN, " DFS: %d", cfg->dfs);
413 429
414 return idx; 430 return idx;
415} 431}
@@ -421,6 +437,7 @@ int wl1271_scan_sched_scan_config(struct wl1271 *wl,
421 struct wl1271_cmd_sched_scan_config *cfg = NULL; 437 struct wl1271_cmd_sched_scan_config *cfg = NULL;
422 struct conf_sched_scan_settings *c = &wl->conf.sched_scan; 438 struct conf_sched_scan_settings *c = &wl->conf.sched_scan;
423 int i, total_channels, ret; 439 int i, total_channels, ret;
440 bool force_passive = !req->n_ssids;
424 441
425 wl1271_debug(DEBUG_CMD, "cmd sched_scan scan config"); 442 wl1271_debug(DEBUG_CMD, "cmd sched_scan scan config");
426 443
@@ -444,7 +461,7 @@ int wl1271_scan_sched_scan_config(struct wl1271 *wl,
444 for (i = 0; i < SCAN_MAX_CYCLE_INTERVALS; i++) 461 for (i = 0; i < SCAN_MAX_CYCLE_INTERVALS; i++)
445 cfg->intervals[i] = cpu_to_le32(req->interval); 462 cfg->intervals[i] = cpu_to_le32(req->interval);
446 463
447 if (req->ssids[0].ssid_len && req->ssids[0].ssid) { 464 if (!force_passive && req->ssids[0].ssid_len && req->ssids[0].ssid) {
448 cfg->filter_type = SCAN_SSID_FILTER_SPECIFIC; 465 cfg->filter_type = SCAN_SSID_FILTER_SPECIFIC;
449 cfg->ssid_len = req->ssids[0].ssid_len; 466 cfg->ssid_len = req->ssids[0].ssid_len;
450 memcpy(cfg->ssid, req->ssids[0].ssid, 467 memcpy(cfg->ssid, req->ssids[0].ssid,
@@ -461,7 +478,7 @@ int wl1271_scan_sched_scan_config(struct wl1271 *wl,
461 goto out; 478 goto out;
462 } 479 }
463 480
464 if (cfg->active[0]) { 481 if (!force_passive && cfg->active[0]) {
465 ret = wl1271_cmd_build_probe_req(wl, req->ssids[0].ssid, 482 ret = wl1271_cmd_build_probe_req(wl, req->ssids[0].ssid,
466 req->ssids[0].ssid_len, 483 req->ssids[0].ssid_len,
467 ies->ie[IEEE80211_BAND_2GHZ], 484 ies->ie[IEEE80211_BAND_2GHZ],
@@ -473,7 +490,7 @@ int wl1271_scan_sched_scan_config(struct wl1271 *wl,
473 } 490 }
474 } 491 }
475 492
476 if (cfg->active[1]) { 493 if (!force_passive && cfg->active[1]) {
477 ret = wl1271_cmd_build_probe_req(wl, req->ssids[0].ssid, 494 ret = wl1271_cmd_build_probe_req(wl, req->ssids[0].ssid,
478 req->ssids[0].ssid_len, 495 req->ssids[0].ssid_len,
479 ies->ie[IEEE80211_BAND_5GHZ], 496 ies->ie[IEEE80211_BAND_5GHZ],
diff --git a/drivers/net/wireless/wl12xx/scan.h b/drivers/net/wireless/wl12xx/scan.h
index c83319579ca3..a0b6c5d67b07 100644
--- a/drivers/net/wireless/wl12xx/scan.h
+++ b/drivers/net/wireless/wl12xx/scan.h
@@ -137,6 +137,9 @@ enum {
137 SCAN_BSS_TYPE_ANY, 137 SCAN_BSS_TYPE_ANY,
138}; 138};
139 139
140#define SCAN_CHANNEL_FLAGS_DFS BIT(0)
141#define SCAN_CHANNEL_FLAGS_DFS_ENABLED BIT(1)
142
140struct conn_scan_ch_params { 143struct conn_scan_ch_params {
141 __le16 min_duration; 144 __le16 min_duration;
142 __le16 max_duration; 145 __le16 max_duration;
diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
index 0e819943b9e4..631194d49828 100644
--- a/drivers/net/wireless/zd1211rw/zd_usb.c
+++ b/drivers/net/wireless/zd1211rw/zd_usb.c
@@ -1533,6 +1533,31 @@ static void __exit usb_exit(void)
1533module_init(usb_init); 1533module_init(usb_init);
1534module_exit(usb_exit); 1534module_exit(usb_exit);
1535 1535
1536static int zd_ep_regs_out_msg(struct usb_device *udev, void *data, int len,
1537 int *actual_length, int timeout)
1538{
1539 /* In USB 2.0 mode EP_REGS_OUT endpoint is interrupt type. However in
1540 * USB 1.1 mode endpoint is bulk. Select correct type URB by endpoint
1541 * descriptor.
1542 */
1543 struct usb_host_endpoint *ep;
1544 unsigned int pipe;
1545
1546 pipe = usb_sndintpipe(udev, EP_REGS_OUT);
1547 ep = usb_pipe_endpoint(udev, pipe);
1548 if (!ep)
1549 return -EINVAL;
1550
1551 if (usb_endpoint_xfer_int(&ep->desc)) {
1552 return usb_interrupt_msg(udev, pipe, data, len,
1553 actual_length, timeout);
1554 } else {
1555 pipe = usb_sndbulkpipe(udev, EP_REGS_OUT);
1556 return usb_bulk_msg(udev, pipe, data, len, actual_length,
1557 timeout);
1558 }
1559}
1560
1536static int usb_int_regs_length(unsigned int count) 1561static int usb_int_regs_length(unsigned int count)
1537{ 1562{
1538 return sizeof(struct usb_int_regs) + count * sizeof(struct reg_data); 1563 return sizeof(struct usb_int_regs) + count * sizeof(struct reg_data);
@@ -1648,15 +1673,14 @@ int zd_usb_ioread16v(struct zd_usb *usb, u16 *values,
1648 1673
1649 udev = zd_usb_to_usbdev(usb); 1674 udev = zd_usb_to_usbdev(usb);
1650 prepare_read_regs_int(usb); 1675 prepare_read_regs_int(usb);
1651 r = usb_interrupt_msg(udev, usb_sndintpipe(udev, EP_REGS_OUT), 1676 r = zd_ep_regs_out_msg(udev, req, req_len, &actual_req_len, 50 /*ms*/);
1652 req, req_len, &actual_req_len, 50 /* ms */);
1653 if (r) { 1677 if (r) {
1654 dev_dbg_f(zd_usb_dev(usb), 1678 dev_dbg_f(zd_usb_dev(usb),
1655 "error in usb_interrupt_msg(). Error number %d\n", r); 1679 "error in zd_ep_regs_out_msg(). Error number %d\n", r);
1656 goto error; 1680 goto error;
1657 } 1681 }
1658 if (req_len != actual_req_len) { 1682 if (req_len != actual_req_len) {
1659 dev_dbg_f(zd_usb_dev(usb), "error in usb_interrupt_msg()\n" 1683 dev_dbg_f(zd_usb_dev(usb), "error in zd_ep_regs_out_msg()\n"
1660 " req_len %d != actual_req_len %d\n", 1684 " req_len %d != actual_req_len %d\n",
1661 req_len, actual_req_len); 1685 req_len, actual_req_len);
1662 r = -EIO; 1686 r = -EIO;
@@ -1818,9 +1842,17 @@ int zd_usb_iowrite16v_async(struct zd_usb *usb, const struct zd_ioreq16 *ioreqs,
1818 rw->value = cpu_to_le16(ioreqs[i].value); 1842 rw->value = cpu_to_le16(ioreqs[i].value);
1819 } 1843 }
1820 1844
1821 usb_fill_int_urb(urb, udev, usb_sndintpipe(udev, EP_REGS_OUT), 1845 /* In USB 2.0 mode endpoint is interrupt type. However in USB 1.1 mode
1822 req, req_len, iowrite16v_urb_complete, usb, 1846 * endpoint is bulk. Select correct type URB by endpoint descriptor.
1823 ep->desc.bInterval); 1847 */
1848 if (usb_endpoint_xfer_int(&ep->desc))
1849 usb_fill_int_urb(urb, udev, usb_sndintpipe(udev, EP_REGS_OUT),
1850 req, req_len, iowrite16v_urb_complete, usb,
1851 ep->desc.bInterval);
1852 else
1853 usb_fill_bulk_urb(urb, udev, usb_sndbulkpipe(udev, EP_REGS_OUT),
1854 req, req_len, iowrite16v_urb_complete, usb);
1855
1824 urb->transfer_flags |= URB_FREE_BUFFER; 1856 urb->transfer_flags |= URB_FREE_BUFFER;
1825 1857
1826 /* Submit previous URB */ 1858 /* Submit previous URB */
@@ -1924,15 +1956,14 @@ int zd_usb_rfwrite(struct zd_usb *usb, u32 value, u8 bits)
1924 } 1956 }
1925 1957
1926 udev = zd_usb_to_usbdev(usb); 1958 udev = zd_usb_to_usbdev(usb);
1927 r = usb_interrupt_msg(udev, usb_sndintpipe(udev, EP_REGS_OUT), 1959 r = zd_ep_regs_out_msg(udev, req, req_len, &actual_req_len, 50 /*ms*/);
1928 req, req_len, &actual_req_len, 50 /* ms */);
1929 if (r) { 1960 if (r) {
1930 dev_dbg_f(zd_usb_dev(usb), 1961 dev_dbg_f(zd_usb_dev(usb),
1931 "error in usb_interrupt_msg(). Error number %d\n", r); 1962 "error in zd_ep_regs_out_msg(). Error number %d\n", r);
1932 goto out; 1963 goto out;
1933 } 1964 }
1934 if (req_len != actual_req_len) { 1965 if (req_len != actual_req_len) {
1935 dev_dbg_f(zd_usb_dev(usb), "error in usb_interrupt_msg()" 1966 dev_dbg_f(zd_usb_dev(usb), "error in zd_ep_regs_out_msg()"
1936 " req_len %d != actual_req_len %d\n", 1967 " req_len %d != actual_req_len %d\n",
1937 req_len, actual_req_len); 1968 req_len, actual_req_len);
1938 r = -EIO; 1969 r = -EIO;
diff --git a/drivers/pci/dmar.c b/drivers/pci/dmar.c
index 12e02bf92c4a..3dc9befa5aec 100644
--- a/drivers/pci/dmar.c
+++ b/drivers/pci/dmar.c
@@ -698,12 +698,7 @@ int __init detect_intel_iommu(void)
698 { 698 {
699#ifdef CONFIG_INTR_REMAP 699#ifdef CONFIG_INTR_REMAP
700 struct acpi_table_dmar *dmar; 700 struct acpi_table_dmar *dmar;
701 /* 701
702 * for now we will disable dma-remapping when interrupt
703 * remapping is enabled.
704 * When support for queued invalidation for IOTLB invalidation
705 * is added, we will not need this any more.
706 */
707 dmar = (struct acpi_table_dmar *) dmar_tbl; 702 dmar = (struct acpi_table_dmar *) dmar_tbl;
708 if (ret && cpu_has_x2apic && dmar->flags & 0x1) 703 if (ret && cpu_has_x2apic && dmar->flags & 0x1)
709 printk(KERN_INFO 704 printk(KERN_INFO
diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c
index 6af6b628175b..59f17acf7f68 100644
--- a/drivers/pci/intel-iommu.c
+++ b/drivers/pci/intel-iommu.c
@@ -47,6 +47,8 @@
47#define ROOT_SIZE VTD_PAGE_SIZE 47#define ROOT_SIZE VTD_PAGE_SIZE
48#define CONTEXT_SIZE VTD_PAGE_SIZE 48#define CONTEXT_SIZE VTD_PAGE_SIZE
49 49
50#define IS_BRIDGE_HOST_DEVICE(pdev) \
51 ((pdev->class >> 8) == PCI_CLASS_BRIDGE_HOST)
50#define IS_GFX_DEVICE(pdev) ((pdev->class >> 16) == PCI_BASE_CLASS_DISPLAY) 52#define IS_GFX_DEVICE(pdev) ((pdev->class >> 16) == PCI_BASE_CLASS_DISPLAY)
51#define IS_ISA_DEVICE(pdev) ((pdev->class >> 8) == PCI_CLASS_BRIDGE_ISA) 53#define IS_ISA_DEVICE(pdev) ((pdev->class >> 8) == PCI_CLASS_BRIDGE_ISA)
52#define IS_AZALIA(pdev) ((pdev)->vendor == 0x8086 && (pdev)->device == 0x3a3e) 54#define IS_AZALIA(pdev) ((pdev)->vendor == 0x8086 && (pdev)->device == 0x3a3e)
@@ -116,6 +118,11 @@ static inline unsigned long align_to_level(unsigned long pfn, int level)
116 return (pfn + level_size(level) - 1) & level_mask(level); 118 return (pfn + level_size(level) - 1) & level_mask(level);
117} 119}
118 120
121static inline unsigned long lvl_to_nr_pages(unsigned int lvl)
122{
123 return 1 << ((lvl - 1) * LEVEL_STRIDE);
124}
125
119/* VT-d pages must always be _smaller_ than MM pages. Otherwise things 126/* VT-d pages must always be _smaller_ than MM pages. Otherwise things
120 are never going to work. */ 127 are never going to work. */
121static inline unsigned long dma_to_mm_pfn(unsigned long dma_pfn) 128static inline unsigned long dma_to_mm_pfn(unsigned long dma_pfn)
@@ -143,6 +150,12 @@ static void __init check_tylersburg_isoch(void);
143static int rwbf_quirk; 150static int rwbf_quirk;
144 151
145/* 152/*
153 * set to 1 to panic kernel if can't successfully enable VT-d
154 * (used when kernel is launched w/ TXT)
155 */
156static int force_on = 0;
157
158/*
146 * 0: Present 159 * 0: Present
147 * 1-11: Reserved 160 * 1-11: Reserved
148 * 12-63: Context Ptr (12 - (haw-1)) 161 * 12-63: Context Ptr (12 - (haw-1))
@@ -338,6 +351,9 @@ struct dmar_domain {
338 int iommu_coherency;/* indicate coherency of iommu access */ 351 int iommu_coherency;/* indicate coherency of iommu access */
339 int iommu_snooping; /* indicate snooping control feature*/ 352 int iommu_snooping; /* indicate snooping control feature*/
340 int iommu_count; /* reference count of iommu */ 353 int iommu_count; /* reference count of iommu */
354 int iommu_superpage;/* Level of superpages supported:
355 0 == 4KiB (no superpages), 1 == 2MiB,
356 2 == 1GiB, 3 == 512GiB, 4 == 1TiB */
341 spinlock_t iommu_lock; /* protect iommu set in domain */ 357 spinlock_t iommu_lock; /* protect iommu set in domain */
342 u64 max_addr; /* maximum mapped address */ 358 u64 max_addr; /* maximum mapped address */
343}; 359};
@@ -387,6 +403,7 @@ int dmar_disabled = 1;
387static int dmar_map_gfx = 1; 403static int dmar_map_gfx = 1;
388static int dmar_forcedac; 404static int dmar_forcedac;
389static int intel_iommu_strict; 405static int intel_iommu_strict;
406static int intel_iommu_superpage = 1;
390 407
391#define DUMMY_DEVICE_DOMAIN_INFO ((struct device_domain_info *)(-1)) 408#define DUMMY_DEVICE_DOMAIN_INFO ((struct device_domain_info *)(-1))
392static DEFINE_SPINLOCK(device_domain_lock); 409static DEFINE_SPINLOCK(device_domain_lock);
@@ -417,6 +434,10 @@ static int __init intel_iommu_setup(char *str)
417 printk(KERN_INFO 434 printk(KERN_INFO
418 "Intel-IOMMU: disable batched IOTLB flush\n"); 435 "Intel-IOMMU: disable batched IOTLB flush\n");
419 intel_iommu_strict = 1; 436 intel_iommu_strict = 1;
437 } else if (!strncmp(str, "sp_off", 6)) {
438 printk(KERN_INFO
439 "Intel-IOMMU: disable supported super page\n");
440 intel_iommu_superpage = 0;
420 } 441 }
421 442
422 str += strcspn(str, ","); 443 str += strcspn(str, ",");
@@ -555,11 +576,32 @@ static void domain_update_iommu_snooping(struct dmar_domain *domain)
555 } 576 }
556} 577}
557 578
579static void domain_update_iommu_superpage(struct dmar_domain *domain)
580{
581 int i, mask = 0xf;
582
583 if (!intel_iommu_superpage) {
584 domain->iommu_superpage = 0;
585 return;
586 }
587
588 domain->iommu_superpage = 4; /* 1TiB */
589
590 for_each_set_bit(i, &domain->iommu_bmp, g_num_of_iommus) {
591 mask |= cap_super_page_val(g_iommus[i]->cap);
592 if (!mask) {
593 break;
594 }
595 }
596 domain->iommu_superpage = fls(mask);
597}
598
558/* Some capabilities may be different across iommus */ 599/* Some capabilities may be different across iommus */
559static void domain_update_iommu_cap(struct dmar_domain *domain) 600static void domain_update_iommu_cap(struct dmar_domain *domain)
560{ 601{
561 domain_update_iommu_coherency(domain); 602 domain_update_iommu_coherency(domain);
562 domain_update_iommu_snooping(domain); 603 domain_update_iommu_snooping(domain);
604 domain_update_iommu_superpage(domain);
563} 605}
564 606
565static struct intel_iommu *device_to_iommu(int segment, u8 bus, u8 devfn) 607static struct intel_iommu *device_to_iommu(int segment, u8 bus, u8 devfn)
@@ -689,23 +731,31 @@ out:
689} 731}
690 732
691static struct dma_pte *pfn_to_dma_pte(struct dmar_domain *domain, 733static struct dma_pte *pfn_to_dma_pte(struct dmar_domain *domain,
692 unsigned long pfn) 734 unsigned long pfn, int large_level)
693{ 735{
694 int addr_width = agaw_to_width(domain->agaw) - VTD_PAGE_SHIFT; 736 int addr_width = agaw_to_width(domain->agaw) - VTD_PAGE_SHIFT;
695 struct dma_pte *parent, *pte = NULL; 737 struct dma_pte *parent, *pte = NULL;
696 int level = agaw_to_level(domain->agaw); 738 int level = agaw_to_level(domain->agaw);
697 int offset; 739 int offset, target_level;
698 740
699 BUG_ON(!domain->pgd); 741 BUG_ON(!domain->pgd);
700 BUG_ON(addr_width < BITS_PER_LONG && pfn >> addr_width); 742 BUG_ON(addr_width < BITS_PER_LONG && pfn >> addr_width);
701 parent = domain->pgd; 743 parent = domain->pgd;
702 744
745 /* Search pte */
746 if (!large_level)
747 target_level = 1;
748 else
749 target_level = large_level;
750
703 while (level > 0) { 751 while (level > 0) {
704 void *tmp_page; 752 void *tmp_page;
705 753
706 offset = pfn_level_offset(pfn, level); 754 offset = pfn_level_offset(pfn, level);
707 pte = &parent[offset]; 755 pte = &parent[offset];
708 if (level == 1) 756 if (!large_level && (pte->val & DMA_PTE_LARGE_PAGE))
757 break;
758 if (level == target_level)
709 break; 759 break;
710 760
711 if (!dma_pte_present(pte)) { 761 if (!dma_pte_present(pte)) {
@@ -733,10 +783,11 @@ static struct dma_pte *pfn_to_dma_pte(struct dmar_domain *domain,
733 return pte; 783 return pte;
734} 784}
735 785
786
736/* return address's pte at specific level */ 787/* return address's pte at specific level */
737static struct dma_pte *dma_pfn_level_pte(struct dmar_domain *domain, 788static struct dma_pte *dma_pfn_level_pte(struct dmar_domain *domain,
738 unsigned long pfn, 789 unsigned long pfn,
739 int level) 790 int level, int *large_page)
740{ 791{
741 struct dma_pte *parent, *pte = NULL; 792 struct dma_pte *parent, *pte = NULL;
742 int total = agaw_to_level(domain->agaw); 793 int total = agaw_to_level(domain->agaw);
@@ -749,8 +800,16 @@ static struct dma_pte *dma_pfn_level_pte(struct dmar_domain *domain,
749 if (level == total) 800 if (level == total)
750 return pte; 801 return pte;
751 802
752 if (!dma_pte_present(pte)) 803 if (!dma_pte_present(pte)) {
804 *large_page = total;
753 break; 805 break;
806 }
807
808 if (pte->val & DMA_PTE_LARGE_PAGE) {
809 *large_page = total;
810 return pte;
811 }
812
754 parent = phys_to_virt(dma_pte_addr(pte)); 813 parent = phys_to_virt(dma_pte_addr(pte));
755 total--; 814 total--;
756 } 815 }
@@ -763,6 +822,7 @@ static void dma_pte_clear_range(struct dmar_domain *domain,
763 unsigned long last_pfn) 822 unsigned long last_pfn)
764{ 823{
765 int addr_width = agaw_to_width(domain->agaw) - VTD_PAGE_SHIFT; 824 int addr_width = agaw_to_width(domain->agaw) - VTD_PAGE_SHIFT;
825 unsigned int large_page = 1;
766 struct dma_pte *first_pte, *pte; 826 struct dma_pte *first_pte, *pte;
767 827
768 BUG_ON(addr_width < BITS_PER_LONG && start_pfn >> addr_width); 828 BUG_ON(addr_width < BITS_PER_LONG && start_pfn >> addr_width);
@@ -771,14 +831,15 @@ static void dma_pte_clear_range(struct dmar_domain *domain,
771 831
772 /* we don't need lock here; nobody else touches the iova range */ 832 /* we don't need lock here; nobody else touches the iova range */
773 do { 833 do {
774 first_pte = pte = dma_pfn_level_pte(domain, start_pfn, 1); 834 large_page = 1;
835 first_pte = pte = dma_pfn_level_pte(domain, start_pfn, 1, &large_page);
775 if (!pte) { 836 if (!pte) {
776 start_pfn = align_to_level(start_pfn + 1, 2); 837 start_pfn = align_to_level(start_pfn + 1, large_page + 1);
777 continue; 838 continue;
778 } 839 }
779 do { 840 do {
780 dma_clear_pte(pte); 841 dma_clear_pte(pte);
781 start_pfn++; 842 start_pfn += lvl_to_nr_pages(large_page);
782 pte++; 843 pte++;
783 } while (start_pfn <= last_pfn && !first_pte_in_page(pte)); 844 } while (start_pfn <= last_pfn && !first_pte_in_page(pte));
784 845
@@ -798,6 +859,7 @@ static void dma_pte_free_pagetable(struct dmar_domain *domain,
798 int total = agaw_to_level(domain->agaw); 859 int total = agaw_to_level(domain->agaw);
799 int level; 860 int level;
800 unsigned long tmp; 861 unsigned long tmp;
862 int large_page = 2;
801 863
802 BUG_ON(addr_width < BITS_PER_LONG && start_pfn >> addr_width); 864 BUG_ON(addr_width < BITS_PER_LONG && start_pfn >> addr_width);
803 BUG_ON(addr_width < BITS_PER_LONG && last_pfn >> addr_width); 865 BUG_ON(addr_width < BITS_PER_LONG && last_pfn >> addr_width);
@@ -813,7 +875,10 @@ static void dma_pte_free_pagetable(struct dmar_domain *domain,
813 return; 875 return;
814 876
815 do { 877 do {
816 first_pte = pte = dma_pfn_level_pte(domain, tmp, level); 878 large_page = level;
879 first_pte = pte = dma_pfn_level_pte(domain, tmp, level, &large_page);
880 if (large_page > level)
881 level = large_page + 1;
817 if (!pte) { 882 if (!pte) {
818 tmp = align_to_level(tmp + 1, level + 1); 883 tmp = align_to_level(tmp + 1, level + 1);
819 continue; 884 continue;
@@ -1397,6 +1462,7 @@ static int domain_init(struct dmar_domain *domain, int guest_width)
1397 else 1462 else
1398 domain->iommu_snooping = 0; 1463 domain->iommu_snooping = 0;
1399 1464
1465 domain->iommu_superpage = fls(cap_super_page_val(iommu->cap));
1400 domain->iommu_count = 1; 1466 domain->iommu_count = 1;
1401 domain->nid = iommu->node; 1467 domain->nid = iommu->node;
1402 1468
@@ -1417,6 +1483,10 @@ static void domain_exit(struct dmar_domain *domain)
1417 if (!domain) 1483 if (!domain)
1418 return; 1484 return;
1419 1485
1486 /* Flush any lazy unmaps that may reference this domain */
1487 if (!intel_iommu_strict)
1488 flush_unmaps_timeout(0);
1489
1420 domain_remove_dev_info(domain); 1490 domain_remove_dev_info(domain);
1421 /* destroy iovas */ 1491 /* destroy iovas */
1422 put_iova_domain(&domain->iovad); 1492 put_iova_domain(&domain->iovad);
@@ -1648,6 +1718,34 @@ static inline unsigned long aligned_nrpages(unsigned long host_addr,
1648 return PAGE_ALIGN(host_addr + size) >> VTD_PAGE_SHIFT; 1718 return PAGE_ALIGN(host_addr + size) >> VTD_PAGE_SHIFT;
1649} 1719}
1650 1720
1721/* Return largest possible superpage level for a given mapping */
1722static inline int hardware_largepage_caps(struct dmar_domain *domain,
1723 unsigned long iov_pfn,
1724 unsigned long phy_pfn,
1725 unsigned long pages)
1726{
1727 int support, level = 1;
1728 unsigned long pfnmerge;
1729
1730 support = domain->iommu_superpage;
1731
1732 /* To use a large page, the virtual *and* physical addresses
1733 must be aligned to 2MiB/1GiB/etc. Lower bits set in either
1734 of them will mean we have to use smaller pages. So just
1735 merge them and check both at once. */
1736 pfnmerge = iov_pfn | phy_pfn;
1737
1738 while (support && !(pfnmerge & ~VTD_STRIDE_MASK)) {
1739 pages >>= VTD_STRIDE_SHIFT;
1740 if (!pages)
1741 break;
1742 pfnmerge >>= VTD_STRIDE_SHIFT;
1743 level++;
1744 support--;
1745 }
1746 return level;
1747}
1748
1651static int __domain_mapping(struct dmar_domain *domain, unsigned long iov_pfn, 1749static int __domain_mapping(struct dmar_domain *domain, unsigned long iov_pfn,
1652 struct scatterlist *sg, unsigned long phys_pfn, 1750 struct scatterlist *sg, unsigned long phys_pfn,
1653 unsigned long nr_pages, int prot) 1751 unsigned long nr_pages, int prot)
@@ -1656,6 +1754,8 @@ static int __domain_mapping(struct dmar_domain *domain, unsigned long iov_pfn,
1656 phys_addr_t uninitialized_var(pteval); 1754 phys_addr_t uninitialized_var(pteval);
1657 int addr_width = agaw_to_width(domain->agaw) - VTD_PAGE_SHIFT; 1755 int addr_width = agaw_to_width(domain->agaw) - VTD_PAGE_SHIFT;
1658 unsigned long sg_res; 1756 unsigned long sg_res;
1757 unsigned int largepage_lvl = 0;
1758 unsigned long lvl_pages = 0;
1659 1759
1660 BUG_ON(addr_width < BITS_PER_LONG && (iov_pfn + nr_pages - 1) >> addr_width); 1760 BUG_ON(addr_width < BITS_PER_LONG && (iov_pfn + nr_pages - 1) >> addr_width);
1661 1761
@@ -1671,7 +1771,7 @@ static int __domain_mapping(struct dmar_domain *domain, unsigned long iov_pfn,
1671 pteval = ((phys_addr_t)phys_pfn << VTD_PAGE_SHIFT) | prot; 1771 pteval = ((phys_addr_t)phys_pfn << VTD_PAGE_SHIFT) | prot;
1672 } 1772 }
1673 1773
1674 while (nr_pages--) { 1774 while (nr_pages > 0) {
1675 uint64_t tmp; 1775 uint64_t tmp;
1676 1776
1677 if (!sg_res) { 1777 if (!sg_res) {
@@ -1679,11 +1779,21 @@ static int __domain_mapping(struct dmar_domain *domain, unsigned long iov_pfn,
1679 sg->dma_address = ((dma_addr_t)iov_pfn << VTD_PAGE_SHIFT) + sg->offset; 1779 sg->dma_address = ((dma_addr_t)iov_pfn << VTD_PAGE_SHIFT) + sg->offset;
1680 sg->dma_length = sg->length; 1780 sg->dma_length = sg->length;
1681 pteval = page_to_phys(sg_page(sg)) | prot; 1781 pteval = page_to_phys(sg_page(sg)) | prot;
1782 phys_pfn = pteval >> VTD_PAGE_SHIFT;
1682 } 1783 }
1784
1683 if (!pte) { 1785 if (!pte) {
1684 first_pte = pte = pfn_to_dma_pte(domain, iov_pfn); 1786 largepage_lvl = hardware_largepage_caps(domain, iov_pfn, phys_pfn, sg_res);
1787
1788 first_pte = pte = pfn_to_dma_pte(domain, iov_pfn, largepage_lvl);
1685 if (!pte) 1789 if (!pte)
1686 return -ENOMEM; 1790 return -ENOMEM;
1791 /* It is large page*/
1792 if (largepage_lvl > 1)
1793 pteval |= DMA_PTE_LARGE_PAGE;
1794 else
1795 pteval &= ~(uint64_t)DMA_PTE_LARGE_PAGE;
1796
1687 } 1797 }
1688 /* We don't need lock here, nobody else 1798 /* We don't need lock here, nobody else
1689 * touches the iova range 1799 * touches the iova range
@@ -1699,16 +1809,38 @@ static int __domain_mapping(struct dmar_domain *domain, unsigned long iov_pfn,
1699 } 1809 }
1700 WARN_ON(1); 1810 WARN_ON(1);
1701 } 1811 }
1812
1813 lvl_pages = lvl_to_nr_pages(largepage_lvl);
1814
1815 BUG_ON(nr_pages < lvl_pages);
1816 BUG_ON(sg_res < lvl_pages);
1817
1818 nr_pages -= lvl_pages;
1819 iov_pfn += lvl_pages;
1820 phys_pfn += lvl_pages;
1821 pteval += lvl_pages * VTD_PAGE_SIZE;
1822 sg_res -= lvl_pages;
1823
1824 /* If the next PTE would be the first in a new page, then we
1825 need to flush the cache on the entries we've just written.
1826 And then we'll need to recalculate 'pte', so clear it and
1827 let it get set again in the if (!pte) block above.
1828
1829 If we're done (!nr_pages) we need to flush the cache too.
1830
1831 Also if we've been setting superpages, we may need to
1832 recalculate 'pte' and switch back to smaller pages for the
1833 end of the mapping, if the trailing size is not enough to
1834 use another superpage (i.e. sg_res < lvl_pages). */
1702 pte++; 1835 pte++;
1703 if (!nr_pages || first_pte_in_page(pte)) { 1836 if (!nr_pages || first_pte_in_page(pte) ||
1837 (largepage_lvl > 1 && sg_res < lvl_pages)) {
1704 domain_flush_cache(domain, first_pte, 1838 domain_flush_cache(domain, first_pte,
1705 (void *)pte - (void *)first_pte); 1839 (void *)pte - (void *)first_pte);
1706 pte = NULL; 1840 pte = NULL;
1707 } 1841 }
1708 iov_pfn++; 1842
1709 pteval += VTD_PAGE_SIZE; 1843 if (!sg_res && nr_pages)
1710 sg_res--;
1711 if (!sg_res)
1712 sg = sg_next(sg); 1844 sg = sg_next(sg);
1713 } 1845 }
1714 return 0; 1846 return 0;
@@ -2016,7 +2148,7 @@ static inline int iommu_prepare_rmrr_dev(struct dmar_rmrr_unit *rmrr,
2016 if (pdev->dev.archdata.iommu == DUMMY_DEVICE_DOMAIN_INFO) 2148 if (pdev->dev.archdata.iommu == DUMMY_DEVICE_DOMAIN_INFO)
2017 return 0; 2149 return 0;
2018 return iommu_prepare_identity_map(pdev, rmrr->base_address, 2150 return iommu_prepare_identity_map(pdev, rmrr->base_address,
2019 rmrr->end_address + 1); 2151 rmrr->end_address);
2020} 2152}
2021 2153
2022#ifdef CONFIG_DMAR_FLOPPY_WA 2154#ifdef CONFIG_DMAR_FLOPPY_WA
@@ -2030,7 +2162,7 @@ static inline void iommu_prepare_isa(void)
2030 return; 2162 return;
2031 2163
2032 printk(KERN_INFO "IOMMU: Prepare 0-16MiB unity mapping for LPC\n"); 2164 printk(KERN_INFO "IOMMU: Prepare 0-16MiB unity mapping for LPC\n");
2033 ret = iommu_prepare_identity_map(pdev, 0, 16*1024*1024); 2165 ret = iommu_prepare_identity_map(pdev, 0, 16*1024*1024 - 1);
2034 2166
2035 if (ret) 2167 if (ret)
2036 printk(KERN_ERR "IOMMU: Failed to create 0-16MiB identity map; " 2168 printk(KERN_ERR "IOMMU: Failed to create 0-16MiB identity map; "
@@ -2106,10 +2238,10 @@ static int identity_mapping(struct pci_dev *pdev)
2106 if (likely(!iommu_identity_mapping)) 2238 if (likely(!iommu_identity_mapping))
2107 return 0; 2239 return 0;
2108 2240
2241 info = pdev->dev.archdata.iommu;
2242 if (info && info != DUMMY_DEVICE_DOMAIN_INFO)
2243 return (info->domain == si_domain);
2109 2244
2110 list_for_each_entry(info, &si_domain->devices, link)
2111 if (info->dev == pdev)
2112 return 1;
2113 return 0; 2245 return 0;
2114} 2246}
2115 2247
@@ -2187,8 +2319,19 @@ static int iommu_should_identity_map(struct pci_dev *pdev, int startup)
2187 * Assume that they will -- if they turn out not to be, then we can 2319 * Assume that they will -- if they turn out not to be, then we can
2188 * take them out of the 1:1 domain later. 2320 * take them out of the 1:1 domain later.
2189 */ 2321 */
2190 if (!startup) 2322 if (!startup) {
2191 return pdev->dma_mask > DMA_BIT_MASK(32); 2323 /*
2324 * If the device's dma_mask is less than the system's memory
2325 * size then this is not a candidate for identity mapping.
2326 */
2327 u64 dma_mask = pdev->dma_mask;
2328
2329 if (pdev->dev.coherent_dma_mask &&
2330 pdev->dev.coherent_dma_mask < dma_mask)
2331 dma_mask = pdev->dev.coherent_dma_mask;
2332
2333 return dma_mask >= dma_get_required_mask(&pdev->dev);
2334 }
2192 2335
2193 return 1; 2336 return 1;
2194} 2337}
@@ -2203,6 +2346,9 @@ static int __init iommu_prepare_static_identity_mapping(int hw)
2203 return -EFAULT; 2346 return -EFAULT;
2204 2347
2205 for_each_pci_dev(pdev) { 2348 for_each_pci_dev(pdev) {
2349 /* Skip Host/PCI Bridge devices */
2350 if (IS_BRIDGE_HOST_DEVICE(pdev))
2351 continue;
2206 if (iommu_should_identity_map(pdev, 1)) { 2352 if (iommu_should_identity_map(pdev, 1)) {
2207 printk(KERN_INFO "IOMMU: %s identity mapping for device %s\n", 2353 printk(KERN_INFO "IOMMU: %s identity mapping for device %s\n",
2208 hw ? "hardware" : "software", pci_name(pdev)); 2354 hw ? "hardware" : "software", pci_name(pdev));
@@ -2218,7 +2364,7 @@ static int __init iommu_prepare_static_identity_mapping(int hw)
2218 return 0; 2364 return 0;
2219} 2365}
2220 2366
2221static int __init init_dmars(int force_on) 2367static int __init init_dmars(void)
2222{ 2368{
2223 struct dmar_drhd_unit *drhd; 2369 struct dmar_drhd_unit *drhd;
2224 struct dmar_rmrr_unit *rmrr; 2370 struct dmar_rmrr_unit *rmrr;
@@ -2592,8 +2738,7 @@ static dma_addr_t __intel_map_single(struct device *hwdev, phys_addr_t paddr,
2592 iommu = domain_get_iommu(domain); 2738 iommu = domain_get_iommu(domain);
2593 size = aligned_nrpages(paddr, size); 2739 size = aligned_nrpages(paddr, size);
2594 2740
2595 iova = intel_alloc_iova(hwdev, domain, dma_to_mm_pfn(size), 2741 iova = intel_alloc_iova(hwdev, domain, dma_to_mm_pfn(size), dma_mask);
2596 pdev->dma_mask);
2597 if (!iova) 2742 if (!iova)
2598 goto error; 2743 goto error;
2599 2744
@@ -3118,7 +3263,17 @@ static int init_iommu_hw(void)
3118 if (iommu->qi) 3263 if (iommu->qi)
3119 dmar_reenable_qi(iommu); 3264 dmar_reenable_qi(iommu);
3120 3265
3121 for_each_active_iommu(iommu, drhd) { 3266 for_each_iommu(iommu, drhd) {
3267 if (drhd->ignored) {
3268 /*
3269 * we always have to disable PMRs or DMA may fail on
3270 * this device
3271 */
3272 if (force_on)
3273 iommu_disable_protect_mem_regions(iommu);
3274 continue;
3275 }
3276
3122 iommu_flush_write_buffer(iommu); 3277 iommu_flush_write_buffer(iommu);
3123 3278
3124 iommu_set_root_entry(iommu); 3279 iommu_set_root_entry(iommu);
@@ -3127,7 +3282,8 @@ static int init_iommu_hw(void)
3127 DMA_CCMD_GLOBAL_INVL); 3282 DMA_CCMD_GLOBAL_INVL);
3128 iommu->flush.flush_iotlb(iommu, 0, 0, 0, 3283 iommu->flush.flush_iotlb(iommu, 0, 0, 0,
3129 DMA_TLB_GLOBAL_FLUSH); 3284 DMA_TLB_GLOBAL_FLUSH);
3130 iommu_enable_translation(iommu); 3285 if (iommu_enable_translation(iommu))
3286 return 1;
3131 iommu_disable_protect_mem_regions(iommu); 3287 iommu_disable_protect_mem_regions(iommu);
3132 } 3288 }
3133 3289
@@ -3194,7 +3350,10 @@ static void iommu_resume(void)
3194 unsigned long flag; 3350 unsigned long flag;
3195 3351
3196 if (init_iommu_hw()) { 3352 if (init_iommu_hw()) {
3197 WARN(1, "IOMMU setup failed, DMAR can not resume!\n"); 3353 if (force_on)
3354 panic("tboot: IOMMU setup failed, DMAR can not resume!\n");
3355 else
3356 WARN(1, "IOMMU setup failed, DMAR can not resume!\n");
3198 return; 3357 return;
3199 } 3358 }
3200 3359
@@ -3271,7 +3430,6 @@ static struct notifier_block device_nb = {
3271int __init intel_iommu_init(void) 3430int __init intel_iommu_init(void)
3272{ 3431{
3273 int ret = 0; 3432 int ret = 0;
3274 int force_on = 0;
3275 3433
3276 /* VT-d is required for a TXT/tboot launch, so enforce that */ 3434 /* VT-d is required for a TXT/tboot launch, so enforce that */
3277 force_on = tboot_force_iommu(); 3435 force_on = tboot_force_iommu();
@@ -3309,7 +3467,7 @@ int __init intel_iommu_init(void)
3309 3467
3310 init_no_remapping_devices(); 3468 init_no_remapping_devices();
3311 3469
3312 ret = init_dmars(force_on); 3470 ret = init_dmars();
3313 if (ret) { 3471 if (ret) {
3314 if (force_on) 3472 if (force_on)
3315 panic("tboot: Failed to initialize DMARs\n"); 3473 panic("tboot: Failed to initialize DMARs\n");
@@ -3380,8 +3538,8 @@ static void domain_remove_one_dev_info(struct dmar_domain *domain,
3380 spin_lock_irqsave(&device_domain_lock, flags); 3538 spin_lock_irqsave(&device_domain_lock, flags);
3381 list_for_each_safe(entry, tmp, &domain->devices) { 3539 list_for_each_safe(entry, tmp, &domain->devices) {
3382 info = list_entry(entry, struct device_domain_info, link); 3540 info = list_entry(entry, struct device_domain_info, link);
3383 /* No need to compare PCI domain; it has to be the same */ 3541 if (info->segment == pci_domain_nr(pdev->bus) &&
3384 if (info->bus == pdev->bus->number && 3542 info->bus == pdev->bus->number &&
3385 info->devfn == pdev->devfn) { 3543 info->devfn == pdev->devfn) {
3386 list_del(&info->link); 3544 list_del(&info->link);
3387 list_del(&info->global); 3545 list_del(&info->global);
@@ -3419,10 +3577,13 @@ static void domain_remove_one_dev_info(struct dmar_domain *domain,
3419 domain_update_iommu_cap(domain); 3577 domain_update_iommu_cap(domain);
3420 spin_unlock_irqrestore(&domain->iommu_lock, tmp_flags); 3578 spin_unlock_irqrestore(&domain->iommu_lock, tmp_flags);
3421 3579
3422 spin_lock_irqsave(&iommu->lock, tmp_flags); 3580 if (!(domain->flags & DOMAIN_FLAG_VIRTUAL_MACHINE) &&
3423 clear_bit(domain->id, iommu->domain_ids); 3581 !(domain->flags & DOMAIN_FLAG_STATIC_IDENTITY)) {
3424 iommu->domains[domain->id] = NULL; 3582 spin_lock_irqsave(&iommu->lock, tmp_flags);
3425 spin_unlock_irqrestore(&iommu->lock, tmp_flags); 3583 clear_bit(domain->id, iommu->domain_ids);
3584 iommu->domains[domain->id] = NULL;
3585 spin_unlock_irqrestore(&iommu->lock, tmp_flags);
3586 }
3426 } 3587 }
3427 3588
3428 spin_unlock_irqrestore(&device_domain_lock, flags); 3589 spin_unlock_irqrestore(&device_domain_lock, flags);
@@ -3505,6 +3666,7 @@ static int md_domain_init(struct dmar_domain *domain, int guest_width)
3505 domain->iommu_count = 0; 3666 domain->iommu_count = 0;
3506 domain->iommu_coherency = 0; 3667 domain->iommu_coherency = 0;
3507 domain->iommu_snooping = 0; 3668 domain->iommu_snooping = 0;
3669 domain->iommu_superpage = 0;
3508 domain->max_addr = 0; 3670 domain->max_addr = 0;
3509 domain->nid = -1; 3671 domain->nid = -1;
3510 3672
@@ -3720,7 +3882,7 @@ static phys_addr_t intel_iommu_iova_to_phys(struct iommu_domain *domain,
3720 struct dma_pte *pte; 3882 struct dma_pte *pte;
3721 u64 phys = 0; 3883 u64 phys = 0;
3722 3884
3723 pte = pfn_to_dma_pte(dmar_domain, iova >> VTD_PAGE_SHIFT); 3885 pte = pfn_to_dma_pte(dmar_domain, iova >> VTD_PAGE_SHIFT, 0);
3724 if (pte) 3886 if (pte)
3725 phys = dma_pte_addr(pte); 3887 phys = dma_pte_addr(pte);
3726 3888
diff --git a/drivers/pci/iova.c b/drivers/pci/iova.c
index 9606e599a475..c5c274ab5c5a 100644
--- a/drivers/pci/iova.c
+++ b/drivers/pci/iova.c
@@ -63,8 +63,16 @@ __cached_rbnode_delete_update(struct iova_domain *iovad, struct iova *free)
63 curr = iovad->cached32_node; 63 curr = iovad->cached32_node;
64 cached_iova = container_of(curr, struct iova, node); 64 cached_iova = container_of(curr, struct iova, node);
65 65
66 if (free->pfn_lo >= cached_iova->pfn_lo) 66 if (free->pfn_lo >= cached_iova->pfn_lo) {
67 iovad->cached32_node = rb_next(&free->node); 67 struct rb_node *node = rb_next(&free->node);
68 struct iova *iova = container_of(node, struct iova, node);
69
70 /* only cache if it's below 32bit pfn */
71 if (node && iova->pfn_lo < iovad->dma_32bit_pfn)
72 iovad->cached32_node = node;
73 else
74 iovad->cached32_node = NULL;
75 }
68} 76}
69 77
70/* Computes the padding size required, to make the 78/* Computes the padding size required, to make the
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 58584dc0724a..44e8ca398efa 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -297,7 +297,7 @@ static struct scsi_device *scsi_alloc_sdev(struct scsi_target *starget,
297 kfree(sdev); 297 kfree(sdev);
298 goto out; 298 goto out;
299 } 299 }
300 300 blk_get_queue(sdev->request_queue);
301 sdev->request_queue->queuedata = sdev; 301 sdev->request_queue->queuedata = sdev;
302 scsi_adjust_queue_depth(sdev, 0, sdev->host->cmd_per_lun); 302 scsi_adjust_queue_depth(sdev, 0, sdev->host->cmd_per_lun);
303 303
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index e63912510fb9..e0bd3f790fca 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -322,6 +322,7 @@ static void scsi_device_dev_release_usercontext(struct work_struct *work)
322 kfree(evt); 322 kfree(evt);
323 } 323 }
324 324
325 blk_put_queue(sdev->request_queue);
325 /* NULL queue means the device can't be used */ 326 /* NULL queue means the device can't be used */
326 sdev->request_queue = NULL; 327 sdev->request_queue = NULL;
327 328
diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
index a4c42a75a3bf..09e8c7d53af3 100644
--- a/drivers/tty/n_gsm.c
+++ b/drivers/tty/n_gsm.c
@@ -2128,8 +2128,8 @@ static void gsmld_detach_gsm(struct tty_struct *tty, struct gsm_mux *gsm)
2128 gsm->tty = NULL; 2128 gsm->tty = NULL;
2129} 2129}
2130 2130
2131static unsigned int gsmld_receive_buf(struct tty_struct *tty, 2131static void gsmld_receive_buf(struct tty_struct *tty, const unsigned char *cp,
2132 const unsigned char *cp, char *fp, int count) 2132 char *fp, int count)
2133{ 2133{
2134 struct gsm_mux *gsm = tty->disc_data; 2134 struct gsm_mux *gsm = tty->disc_data;
2135 const unsigned char *dp; 2135 const unsigned char *dp;
@@ -2162,8 +2162,6 @@ static unsigned int gsmld_receive_buf(struct tty_struct *tty,
2162 } 2162 }
2163 /* FASYNC if needed ? */ 2163 /* FASYNC if needed ? */
2164 /* If clogged call tty_throttle(tty); */ 2164 /* If clogged call tty_throttle(tty); */
2165
2166 return count;
2167} 2165}
2168 2166
2169/** 2167/**
diff --git a/drivers/tty/n_hdlc.c b/drivers/tty/n_hdlc.c
index cac666314aef..cea56033b34c 100644
--- a/drivers/tty/n_hdlc.c
+++ b/drivers/tty/n_hdlc.c
@@ -188,8 +188,8 @@ static unsigned int n_hdlc_tty_poll(struct tty_struct *tty, struct file *filp,
188 poll_table *wait); 188 poll_table *wait);
189static int n_hdlc_tty_open(struct tty_struct *tty); 189static int n_hdlc_tty_open(struct tty_struct *tty);
190static void n_hdlc_tty_close(struct tty_struct *tty); 190static void n_hdlc_tty_close(struct tty_struct *tty);
191static unsigned int n_hdlc_tty_receive(struct tty_struct *tty, 191static void n_hdlc_tty_receive(struct tty_struct *tty, const __u8 *cp,
192 const __u8 *cp, char *fp, int count); 192 char *fp, int count);
193static void n_hdlc_tty_wakeup(struct tty_struct *tty); 193static void n_hdlc_tty_wakeup(struct tty_struct *tty);
194 194
195#define bset(p,b) ((p)[(b) >> 5] |= (1 << ((b) & 0x1f))) 195#define bset(p,b) ((p)[(b) >> 5] |= (1 << ((b) & 0x1f)))
@@ -509,8 +509,8 @@ static void n_hdlc_tty_wakeup(struct tty_struct *tty)
509 * Called by tty low level driver when receive data is available. Data is 509 * Called by tty low level driver when receive data is available. Data is
510 * interpreted as one HDLC frame. 510 * interpreted as one HDLC frame.
511 */ 511 */
512static unsigned int n_hdlc_tty_receive(struct tty_struct *tty, 512static void n_hdlc_tty_receive(struct tty_struct *tty, const __u8 *data,
513 const __u8 *data, char *flags, int count) 513 char *flags, int count)
514{ 514{
515 register struct n_hdlc *n_hdlc = tty2n_hdlc (tty); 515 register struct n_hdlc *n_hdlc = tty2n_hdlc (tty);
516 register struct n_hdlc_buf *buf; 516 register struct n_hdlc_buf *buf;
@@ -521,20 +521,20 @@ static unsigned int n_hdlc_tty_receive(struct tty_struct *tty,
521 521
522 /* This can happen if stuff comes in on the backup tty */ 522 /* This can happen if stuff comes in on the backup tty */
523 if (!n_hdlc || tty != n_hdlc->tty) 523 if (!n_hdlc || tty != n_hdlc->tty)
524 return -ENODEV; 524 return;
525 525
526 /* verify line is using HDLC discipline */ 526 /* verify line is using HDLC discipline */
527 if (n_hdlc->magic != HDLC_MAGIC) { 527 if (n_hdlc->magic != HDLC_MAGIC) {
528 printk("%s(%d) line not using HDLC discipline\n", 528 printk("%s(%d) line not using HDLC discipline\n",
529 __FILE__,__LINE__); 529 __FILE__,__LINE__);
530 return -EINVAL; 530 return;
531 } 531 }
532 532
533 if ( count>maxframe ) { 533 if ( count>maxframe ) {
534 if (debuglevel >= DEBUG_LEVEL_INFO) 534 if (debuglevel >= DEBUG_LEVEL_INFO)
535 printk("%s(%d) rx count>maxframesize, data discarded\n", 535 printk("%s(%d) rx count>maxframesize, data discarded\n",
536 __FILE__,__LINE__); 536 __FILE__,__LINE__);
537 return -EINVAL; 537 return;
538 } 538 }
539 539
540 /* get a free HDLC buffer */ 540 /* get a free HDLC buffer */
@@ -550,7 +550,7 @@ static unsigned int n_hdlc_tty_receive(struct tty_struct *tty,
550 if (debuglevel >= DEBUG_LEVEL_INFO) 550 if (debuglevel >= DEBUG_LEVEL_INFO)
551 printk("%s(%d) no more rx buffers, data discarded\n", 551 printk("%s(%d) no more rx buffers, data discarded\n",
552 __FILE__,__LINE__); 552 __FILE__,__LINE__);
553 return -EINVAL; 553 return;
554 } 554 }
555 555
556 /* copy received data to HDLC buffer */ 556 /* copy received data to HDLC buffer */
@@ -565,8 +565,6 @@ static unsigned int n_hdlc_tty_receive(struct tty_struct *tty,
565 if (n_hdlc->tty->fasync != NULL) 565 if (n_hdlc->tty->fasync != NULL)
566 kill_fasync (&n_hdlc->tty->fasync, SIGIO, POLL_IN); 566 kill_fasync (&n_hdlc->tty->fasync, SIGIO, POLL_IN);
567 567
568 return count;
569
570} /* end of n_hdlc_tty_receive() */ 568} /* end of n_hdlc_tty_receive() */
571 569
572/** 570/**
diff --git a/drivers/tty/n_r3964.c b/drivers/tty/n_r3964.c
index a4bc39c21a43..5c6c31459a2f 100644
--- a/drivers/tty/n_r3964.c
+++ b/drivers/tty/n_r3964.c
@@ -139,8 +139,8 @@ static int r3964_ioctl(struct tty_struct *tty, struct file *file,
139static void r3964_set_termios(struct tty_struct *tty, struct ktermios *old); 139static void r3964_set_termios(struct tty_struct *tty, struct ktermios *old);
140static unsigned int r3964_poll(struct tty_struct *tty, struct file *file, 140static unsigned int r3964_poll(struct tty_struct *tty, struct file *file,
141 struct poll_table_struct *wait); 141 struct poll_table_struct *wait);
142static unsigned int r3964_receive_buf(struct tty_struct *tty, 142static void r3964_receive_buf(struct tty_struct *tty, const unsigned char *cp,
143 const unsigned char *cp, char *fp, int count); 143 char *fp, int count);
144 144
145static struct tty_ldisc_ops tty_ldisc_N_R3964 = { 145static struct tty_ldisc_ops tty_ldisc_N_R3964 = {
146 .owner = THIS_MODULE, 146 .owner = THIS_MODULE,
@@ -1239,8 +1239,8 @@ static unsigned int r3964_poll(struct tty_struct *tty, struct file *file,
1239 return result; 1239 return result;
1240} 1240}
1241 1241
1242static unsigned int r3964_receive_buf(struct tty_struct *tty, 1242static void r3964_receive_buf(struct tty_struct *tty, const unsigned char *cp,
1243 const unsigned char *cp, char *fp, int count) 1243 char *fp, int count)
1244{ 1244{
1245 struct r3964_info *pInfo = tty->disc_data; 1245 struct r3964_info *pInfo = tty->disc_data;
1246 const unsigned char *p; 1246 const unsigned char *p;
@@ -1257,8 +1257,6 @@ static unsigned int r3964_receive_buf(struct tty_struct *tty,
1257 } 1257 }
1258 1258
1259 } 1259 }
1260
1261 return count;
1262} 1260}
1263 1261
1264MODULE_LICENSE("GPL"); 1262MODULE_LICENSE("GPL");
diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
index 95d0a9c2dd13..0ad32888091c 100644
--- a/drivers/tty/n_tty.c
+++ b/drivers/tty/n_tty.c
@@ -81,6 +81,38 @@ static inline int tty_put_user(struct tty_struct *tty, unsigned char x,
81 return put_user(x, ptr); 81 return put_user(x, ptr);
82} 82}
83 83
84/**
85 * n_tty_set__room - receive space
86 * @tty: terminal
87 *
88 * Called by the driver to find out how much data it is
89 * permitted to feed to the line discipline without any being lost
90 * and thus to manage flow control. Not serialized. Answers for the
91 * "instant".
92 */
93
94static void n_tty_set_room(struct tty_struct *tty)
95{
96 /* tty->read_cnt is not read locked ? */
97 int left = N_TTY_BUF_SIZE - tty->read_cnt - 1;
98 int old_left;
99
100 /*
101 * If we are doing input canonicalization, and there are no
102 * pending newlines, let characters through without limit, so
103 * that erase characters will be handled. Other excess
104 * characters will be beeped.
105 */
106 if (left <= 0)
107 left = tty->icanon && !tty->canon_data;
108 old_left = tty->receive_room;
109 tty->receive_room = left;
110
111 /* Did this open up the receive buffer? We may need to flip */
112 if (left && !old_left)
113 schedule_work(&tty->buf.work);
114}
115
84static void put_tty_queue_nolock(unsigned char c, struct tty_struct *tty) 116static void put_tty_queue_nolock(unsigned char c, struct tty_struct *tty)
85{ 117{
86 if (tty->read_cnt < N_TTY_BUF_SIZE) { 118 if (tty->read_cnt < N_TTY_BUF_SIZE) {
@@ -152,6 +184,7 @@ static void reset_buffer_flags(struct tty_struct *tty)
152 184
153 tty->canon_head = tty->canon_data = tty->erasing = 0; 185 tty->canon_head = tty->canon_data = tty->erasing = 0;
154 memset(&tty->read_flags, 0, sizeof tty->read_flags); 186 memset(&tty->read_flags, 0, sizeof tty->read_flags);
187 n_tty_set_room(tty);
155 check_unthrottle(tty); 188 check_unthrottle(tty);
156} 189}
157 190
@@ -1327,19 +1360,17 @@ static void n_tty_write_wakeup(struct tty_struct *tty)
1327 * calls one at a time and in order (or using flush_to_ldisc) 1360 * calls one at a time and in order (or using flush_to_ldisc)
1328 */ 1361 */
1329 1362
1330static unsigned int n_tty_receive_buf(struct tty_struct *tty, 1363static void n_tty_receive_buf(struct tty_struct *tty, const unsigned char *cp,
1331 const unsigned char *cp, char *fp, int count) 1364 char *fp, int count)
1332{ 1365{
1333 const unsigned char *p; 1366 const unsigned char *p;
1334 char *f, flags = TTY_NORMAL; 1367 char *f, flags = TTY_NORMAL;
1335 int i; 1368 int i;
1336 char buf[64]; 1369 char buf[64];
1337 unsigned long cpuflags; 1370 unsigned long cpuflags;
1338 int left;
1339 int ret = 0;
1340 1371
1341 if (!tty->read_buf) 1372 if (!tty->read_buf)
1342 return 0; 1373 return;
1343 1374
1344 if (tty->real_raw) { 1375 if (tty->real_raw) {
1345 spin_lock_irqsave(&tty->read_lock, cpuflags); 1376 spin_lock_irqsave(&tty->read_lock, cpuflags);
@@ -1349,7 +1380,6 @@ static unsigned int n_tty_receive_buf(struct tty_struct *tty,
1349 memcpy(tty->read_buf + tty->read_head, cp, i); 1380 memcpy(tty->read_buf + tty->read_head, cp, i);
1350 tty->read_head = (tty->read_head + i) & (N_TTY_BUF_SIZE-1); 1381 tty->read_head = (tty->read_head + i) & (N_TTY_BUF_SIZE-1);
1351 tty->read_cnt += i; 1382 tty->read_cnt += i;
1352 ret += i;
1353 cp += i; 1383 cp += i;
1354 count -= i; 1384 count -= i;
1355 1385
@@ -1359,10 +1389,8 @@ static unsigned int n_tty_receive_buf(struct tty_struct *tty,
1359 memcpy(tty->read_buf + tty->read_head, cp, i); 1389 memcpy(tty->read_buf + tty->read_head, cp, i);
1360 tty->read_head = (tty->read_head + i) & (N_TTY_BUF_SIZE-1); 1390 tty->read_head = (tty->read_head + i) & (N_TTY_BUF_SIZE-1);
1361 tty->read_cnt += i; 1391 tty->read_cnt += i;
1362 ret += i;
1363 spin_unlock_irqrestore(&tty->read_lock, cpuflags); 1392 spin_unlock_irqrestore(&tty->read_lock, cpuflags);
1364 } else { 1393 } else {
1365 ret = count;
1366 for (i = count, p = cp, f = fp; i; i--, p++) { 1394 for (i = count, p = cp, f = fp; i; i--, p++) {
1367 if (f) 1395 if (f)
1368 flags = *f++; 1396 flags = *f++;
@@ -1390,6 +1418,8 @@ static unsigned int n_tty_receive_buf(struct tty_struct *tty,
1390 tty->ops->flush_chars(tty); 1418 tty->ops->flush_chars(tty);
1391 } 1419 }
1392 1420
1421 n_tty_set_room(tty);
1422
1393 if ((!tty->icanon && (tty->read_cnt >= tty->minimum_to_wake)) || 1423 if ((!tty->icanon && (tty->read_cnt >= tty->minimum_to_wake)) ||
1394 L_EXTPROC(tty)) { 1424 L_EXTPROC(tty)) {
1395 kill_fasync(&tty->fasync, SIGIO, POLL_IN); 1425 kill_fasync(&tty->fasync, SIGIO, POLL_IN);
@@ -1402,12 +1432,8 @@ static unsigned int n_tty_receive_buf(struct tty_struct *tty,
1402 * mode. We don't want to throttle the driver if we're in 1432 * mode. We don't want to throttle the driver if we're in
1403 * canonical mode and don't have a newline yet! 1433 * canonical mode and don't have a newline yet!
1404 */ 1434 */
1405 left = N_TTY_BUF_SIZE - tty->read_cnt - 1; 1435 if (tty->receive_room < TTY_THRESHOLD_THROTTLE)
1406
1407 if (left < TTY_THRESHOLD_THROTTLE)
1408 tty_throttle(tty); 1436 tty_throttle(tty);
1409
1410 return ret;
1411} 1437}
1412 1438
1413int is_ignored(int sig) 1439int is_ignored(int sig)
@@ -1451,6 +1477,7 @@ static void n_tty_set_termios(struct tty_struct *tty, struct ktermios *old)
1451 if (test_bit(TTY_HW_COOK_IN, &tty->flags)) { 1477 if (test_bit(TTY_HW_COOK_IN, &tty->flags)) {
1452 tty->raw = 1; 1478 tty->raw = 1;
1453 tty->real_raw = 1; 1479 tty->real_raw = 1;
1480 n_tty_set_room(tty);
1454 return; 1481 return;
1455 } 1482 }
1456 if (I_ISTRIP(tty) || I_IUCLC(tty) || I_IGNCR(tty) || 1483 if (I_ISTRIP(tty) || I_IUCLC(tty) || I_IGNCR(tty) ||
@@ -1503,6 +1530,7 @@ static void n_tty_set_termios(struct tty_struct *tty, struct ktermios *old)
1503 else 1530 else
1504 tty->real_raw = 0; 1531 tty->real_raw = 0;
1505 } 1532 }
1533 n_tty_set_room(tty);
1506 /* The termios change make the tty ready for I/O */ 1534 /* The termios change make the tty ready for I/O */
1507 wake_up_interruptible(&tty->write_wait); 1535 wake_up_interruptible(&tty->write_wait);
1508 wake_up_interruptible(&tty->read_wait); 1536 wake_up_interruptible(&tty->read_wait);
@@ -1784,6 +1812,8 @@ do_it_again:
1784 retval = -ERESTARTSYS; 1812 retval = -ERESTARTSYS;
1785 break; 1813 break;
1786 } 1814 }
1815 /* FIXME: does n_tty_set_room need locking ? */
1816 n_tty_set_room(tty);
1787 timeout = schedule_timeout(timeout); 1817 timeout = schedule_timeout(timeout);
1788 continue; 1818 continue;
1789 } 1819 }
@@ -1855,8 +1885,10 @@ do_it_again:
1855 * longer than TTY_THRESHOLD_UNTHROTTLE in canonical mode, 1885 * longer than TTY_THRESHOLD_UNTHROTTLE in canonical mode,
1856 * we won't get any more characters. 1886 * we won't get any more characters.
1857 */ 1887 */
1858 if (n_tty_chars_in_buffer(tty) <= TTY_THRESHOLD_UNTHROTTLE) 1888 if (n_tty_chars_in_buffer(tty) <= TTY_THRESHOLD_UNTHROTTLE) {
1889 n_tty_set_room(tty);
1859 check_unthrottle(tty); 1890 check_unthrottle(tty);
1891 }
1860 1892
1861 if (b - buf >= minimum) 1893 if (b - buf >= minimum)
1862 break; 1894 break;
@@ -1878,6 +1910,7 @@ do_it_again:
1878 } else if (test_and_clear_bit(TTY_PUSH, &tty->flags)) 1910 } else if (test_and_clear_bit(TTY_PUSH, &tty->flags))
1879 goto do_it_again; 1911 goto do_it_again;
1880 1912
1913 n_tty_set_room(tty);
1881 return retval; 1914 return retval;
1882} 1915}
1883 1916
diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c
index 46de2e075dac..f1a7918d71aa 100644
--- a/drivers/tty/tty_buffer.c
+++ b/drivers/tty/tty_buffer.c
@@ -416,7 +416,6 @@ static void flush_to_ldisc(struct work_struct *work)
416 struct tty_buffer *head, *tail = tty->buf.tail; 416 struct tty_buffer *head, *tail = tty->buf.tail;
417 int seen_tail = 0; 417 int seen_tail = 0;
418 while ((head = tty->buf.head) != NULL) { 418 while ((head = tty->buf.head) != NULL) {
419 int copied;
420 int count; 419 int count;
421 char *char_buf; 420 char *char_buf;
422 unsigned char *flag_buf; 421 unsigned char *flag_buf;
@@ -443,19 +442,17 @@ static void flush_to_ldisc(struct work_struct *work)
443 line discipline as we want to empty the queue */ 442 line discipline as we want to empty the queue */
444 if (test_bit(TTY_FLUSHPENDING, &tty->flags)) 443 if (test_bit(TTY_FLUSHPENDING, &tty->flags))
445 break; 444 break;
445 if (!tty->receive_room || seen_tail)
446 break;
447 if (count > tty->receive_room)
448 count = tty->receive_room;
446 char_buf = head->char_buf_ptr + head->read; 449 char_buf = head->char_buf_ptr + head->read;
447 flag_buf = head->flag_buf_ptr + head->read; 450 flag_buf = head->flag_buf_ptr + head->read;
451 head->read += count;
448 spin_unlock_irqrestore(&tty->buf.lock, flags); 452 spin_unlock_irqrestore(&tty->buf.lock, flags);
449 copied = disc->ops->receive_buf(tty, char_buf, 453 disc->ops->receive_buf(tty, char_buf,
450 flag_buf, count); 454 flag_buf, count);
451 spin_lock_irqsave(&tty->buf.lock, flags); 455 spin_lock_irqsave(&tty->buf.lock, flags);
452
453 head->read += copied;
454
455 if (copied == 0 || seen_tail) {
456 schedule_work(&tty->buf.work);
457 break;
458 }
459 } 456 }
460 clear_bit(TTY_FLUSHING, &tty->flags); 457 clear_bit(TTY_FLUSHING, &tty->flags);
461 } 458 }
diff --git a/drivers/tty/vt/selection.c b/drivers/tty/vt/selection.c
index 67b1d0d7c8ac..fb864e7fcd13 100644
--- a/drivers/tty/vt/selection.c
+++ b/drivers/tty/vt/selection.c
@@ -332,7 +332,8 @@ int paste_selection(struct tty_struct *tty)
332 continue; 332 continue;
333 } 333 }
334 count = sel_buffer_lth - pasted; 334 count = sel_buffer_lth - pasted;
335 count = tty->ldisc->ops->receive_buf(tty, sel_buffer + pasted, 335 count = min(count, tty->receive_room);
336 tty->ldisc->ops->receive_buf(tty, sel_buffer + pasted,
336 NULL, count); 337 NULL, count);
337 pasted += count; 338 pasted += count;
338 } 339 }
diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index 2f7c76a85e53..e224a92baa16 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -144,7 +144,7 @@ static void handle_tx(struct vhost_net *net)
144 } 144 }
145 145
146 mutex_lock(&vq->mutex); 146 mutex_lock(&vq->mutex);
147 vhost_disable_notify(vq); 147 vhost_disable_notify(&net->dev, vq);
148 148
149 if (wmem < sock->sk->sk_sndbuf / 2) 149 if (wmem < sock->sk->sk_sndbuf / 2)
150 tx_poll_stop(net); 150 tx_poll_stop(net);
@@ -166,8 +166,8 @@ static void handle_tx(struct vhost_net *net)
166 set_bit(SOCK_ASYNC_NOSPACE, &sock->flags); 166 set_bit(SOCK_ASYNC_NOSPACE, &sock->flags);
167 break; 167 break;
168 } 168 }
169 if (unlikely(vhost_enable_notify(vq))) { 169 if (unlikely(vhost_enable_notify(&net->dev, vq))) {
170 vhost_disable_notify(vq); 170 vhost_disable_notify(&net->dev, vq);
171 continue; 171 continue;
172 } 172 }
173 break; 173 break;
@@ -315,7 +315,7 @@ static void handle_rx(struct vhost_net *net)
315 return; 315 return;
316 316
317 mutex_lock(&vq->mutex); 317 mutex_lock(&vq->mutex);
318 vhost_disable_notify(vq); 318 vhost_disable_notify(&net->dev, vq);
319 vhost_hlen = vq->vhost_hlen; 319 vhost_hlen = vq->vhost_hlen;
320 sock_hlen = vq->sock_hlen; 320 sock_hlen = vq->sock_hlen;
321 321
@@ -334,10 +334,10 @@ static void handle_rx(struct vhost_net *net)
334 break; 334 break;
335 /* OK, now we need to know about added descriptors. */ 335 /* OK, now we need to know about added descriptors. */
336 if (!headcount) { 336 if (!headcount) {
337 if (unlikely(vhost_enable_notify(vq))) { 337 if (unlikely(vhost_enable_notify(&net->dev, vq))) {
338 /* They have slipped one in as we were 338 /* They have slipped one in as we were
339 * doing that: check again. */ 339 * doing that: check again. */
340 vhost_disable_notify(vq); 340 vhost_disable_notify(&net->dev, vq);
341 continue; 341 continue;
342 } 342 }
343 /* Nothing new? Wait for eventfd to tell us 343 /* Nothing new? Wait for eventfd to tell us
diff --git a/drivers/vhost/test.c b/drivers/vhost/test.c
index 099f30230d06..734e1d74ad80 100644
--- a/drivers/vhost/test.c
+++ b/drivers/vhost/test.c
@@ -49,7 +49,7 @@ static void handle_vq(struct vhost_test *n)
49 return; 49 return;
50 50
51 mutex_lock(&vq->mutex); 51 mutex_lock(&vq->mutex);
52 vhost_disable_notify(vq); 52 vhost_disable_notify(&n->dev, vq);
53 53
54 for (;;) { 54 for (;;) {
55 head = vhost_get_vq_desc(&n->dev, vq, vq->iov, 55 head = vhost_get_vq_desc(&n->dev, vq, vq->iov,
@@ -61,8 +61,8 @@ static void handle_vq(struct vhost_test *n)
61 break; 61 break;
62 /* Nothing new? Wait for eventfd to tell us they refilled. */ 62 /* Nothing new? Wait for eventfd to tell us they refilled. */
63 if (head == vq->num) { 63 if (head == vq->num) {
64 if (unlikely(vhost_enable_notify(vq))) { 64 if (unlikely(vhost_enable_notify(&n->dev, vq))) {
65 vhost_disable_notify(vq); 65 vhost_disable_notify(&n->dev, vq);
66 continue; 66 continue;
67 } 67 }
68 break; 68 break;
diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index 7aa4eea930f1..ea966b356352 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -37,6 +37,9 @@ enum {
37 VHOST_MEMORY_F_LOG = 0x1, 37 VHOST_MEMORY_F_LOG = 0x1,
38}; 38};
39 39
40#define vhost_used_event(vq) ((u16 __user *)&vq->avail->ring[vq->num])
41#define vhost_avail_event(vq) ((u16 __user *)&vq->used->ring[vq->num])
42
40static void vhost_poll_func(struct file *file, wait_queue_head_t *wqh, 43static void vhost_poll_func(struct file *file, wait_queue_head_t *wqh,
41 poll_table *pt) 44 poll_table *pt)
42{ 45{
@@ -161,6 +164,8 @@ static void vhost_vq_reset(struct vhost_dev *dev,
161 vq->last_avail_idx = 0; 164 vq->last_avail_idx = 0;
162 vq->avail_idx = 0; 165 vq->avail_idx = 0;
163 vq->last_used_idx = 0; 166 vq->last_used_idx = 0;
167 vq->signalled_used = 0;
168 vq->signalled_used_valid = false;
164 vq->used_flags = 0; 169 vq->used_flags = 0;
165 vq->log_used = false; 170 vq->log_used = false;
166 vq->log_addr = -1ull; 171 vq->log_addr = -1ull;
@@ -489,16 +494,17 @@ static int memory_access_ok(struct vhost_dev *d, struct vhost_memory *mem,
489 return 1; 494 return 1;
490} 495}
491 496
492static int vq_access_ok(unsigned int num, 497static int vq_access_ok(struct vhost_dev *d, unsigned int num,
493 struct vring_desc __user *desc, 498 struct vring_desc __user *desc,
494 struct vring_avail __user *avail, 499 struct vring_avail __user *avail,
495 struct vring_used __user *used) 500 struct vring_used __user *used)
496{ 501{
502 size_t s = vhost_has_feature(d, VIRTIO_RING_F_EVENT_IDX) ? 2 : 0;
497 return access_ok(VERIFY_READ, desc, num * sizeof *desc) && 503 return access_ok(VERIFY_READ, desc, num * sizeof *desc) &&
498 access_ok(VERIFY_READ, avail, 504 access_ok(VERIFY_READ, avail,
499 sizeof *avail + num * sizeof *avail->ring) && 505 sizeof *avail + num * sizeof *avail->ring + s) &&
500 access_ok(VERIFY_WRITE, used, 506 access_ok(VERIFY_WRITE, used,
501 sizeof *used + num * sizeof *used->ring); 507 sizeof *used + num * sizeof *used->ring + s);
502} 508}
503 509
504/* Can we log writes? */ 510/* Can we log writes? */
@@ -514,9 +520,11 @@ int vhost_log_access_ok(struct vhost_dev *dev)
514 520
515/* Verify access for write logging. */ 521/* Verify access for write logging. */
516/* Caller should have vq mutex and device mutex */ 522/* Caller should have vq mutex and device mutex */
517static int vq_log_access_ok(struct vhost_virtqueue *vq, void __user *log_base) 523static int vq_log_access_ok(struct vhost_dev *d, struct vhost_virtqueue *vq,
524 void __user *log_base)
518{ 525{
519 struct vhost_memory *mp; 526 struct vhost_memory *mp;
527 size_t s = vhost_has_feature(d, VIRTIO_RING_F_EVENT_IDX) ? 2 : 0;
520 528
521 mp = rcu_dereference_protected(vq->dev->memory, 529 mp = rcu_dereference_protected(vq->dev->memory,
522 lockdep_is_held(&vq->mutex)); 530 lockdep_is_held(&vq->mutex));
@@ -524,15 +532,15 @@ static int vq_log_access_ok(struct vhost_virtqueue *vq, void __user *log_base)
524 vhost_has_feature(vq->dev, VHOST_F_LOG_ALL)) && 532 vhost_has_feature(vq->dev, VHOST_F_LOG_ALL)) &&
525 (!vq->log_used || log_access_ok(log_base, vq->log_addr, 533 (!vq->log_used || log_access_ok(log_base, vq->log_addr,
526 sizeof *vq->used + 534 sizeof *vq->used +
527 vq->num * sizeof *vq->used->ring)); 535 vq->num * sizeof *vq->used->ring + s));
528} 536}
529 537
530/* Can we start vq? */ 538/* Can we start vq? */
531/* Caller should have vq mutex and device mutex */ 539/* Caller should have vq mutex and device mutex */
532int vhost_vq_access_ok(struct vhost_virtqueue *vq) 540int vhost_vq_access_ok(struct vhost_virtqueue *vq)
533{ 541{
534 return vq_access_ok(vq->num, vq->desc, vq->avail, vq->used) && 542 return vq_access_ok(vq->dev, vq->num, vq->desc, vq->avail, vq->used) &&
535 vq_log_access_ok(vq, vq->log_base); 543 vq_log_access_ok(vq->dev, vq, vq->log_base);
536} 544}
537 545
538static long vhost_set_memory(struct vhost_dev *d, struct vhost_memory __user *m) 546static long vhost_set_memory(struct vhost_dev *d, struct vhost_memory __user *m)
@@ -577,6 +585,7 @@ static int init_used(struct vhost_virtqueue *vq,
577 585
578 if (r) 586 if (r)
579 return r; 587 return r;
588 vq->signalled_used_valid = false;
580 return get_user(vq->last_used_idx, &used->idx); 589 return get_user(vq->last_used_idx, &used->idx);
581} 590}
582 591
@@ -674,7 +683,7 @@ static long vhost_set_vring(struct vhost_dev *d, int ioctl, void __user *argp)
674 * If it is not, we don't as size might not have been setup. 683 * If it is not, we don't as size might not have been setup.
675 * We will verify when backend is configured. */ 684 * We will verify when backend is configured. */
676 if (vq->private_data) { 685 if (vq->private_data) {
677 if (!vq_access_ok(vq->num, 686 if (!vq_access_ok(d, vq->num,
678 (void __user *)(unsigned long)a.desc_user_addr, 687 (void __user *)(unsigned long)a.desc_user_addr,
679 (void __user *)(unsigned long)a.avail_user_addr, 688 (void __user *)(unsigned long)a.avail_user_addr,
680 (void __user *)(unsigned long)a.used_user_addr)) { 689 (void __user *)(unsigned long)a.used_user_addr)) {
@@ -818,7 +827,7 @@ long vhost_dev_ioctl(struct vhost_dev *d, unsigned int ioctl, unsigned long arg)
818 vq = d->vqs + i; 827 vq = d->vqs + i;
819 mutex_lock(&vq->mutex); 828 mutex_lock(&vq->mutex);
820 /* If ring is inactive, will check when it's enabled. */ 829 /* If ring is inactive, will check when it's enabled. */
821 if (vq->private_data && !vq_log_access_ok(vq, base)) 830 if (vq->private_data && !vq_log_access_ok(d, vq, base))
822 r = -EFAULT; 831 r = -EFAULT;
823 else 832 else
824 vq->log_base = base; 833 vq->log_base = base;
@@ -1219,6 +1228,10 @@ int vhost_get_vq_desc(struct vhost_dev *dev, struct vhost_virtqueue *vq,
1219 1228
1220 /* On success, increment avail index. */ 1229 /* On success, increment avail index. */
1221 vq->last_avail_idx++; 1230 vq->last_avail_idx++;
1231
1232 /* Assume notifications from guest are disabled at this point,
1233 * if they aren't we would need to update avail_event index. */
1234 BUG_ON(!(vq->used_flags & VRING_USED_F_NO_NOTIFY));
1222 return head; 1235 return head;
1223} 1236}
1224 1237
@@ -1267,6 +1280,12 @@ int vhost_add_used(struct vhost_virtqueue *vq, unsigned int head, int len)
1267 eventfd_signal(vq->log_ctx, 1); 1280 eventfd_signal(vq->log_ctx, 1);
1268 } 1281 }
1269 vq->last_used_idx++; 1282 vq->last_used_idx++;
1283 /* If the driver never bothers to signal in a very long while,
1284 * used index might wrap around. If that happens, invalidate
1285 * signalled_used index we stored. TODO: make sure driver
1286 * signals at least once in 2^16 and remove this. */
1287 if (unlikely(vq->last_used_idx == vq->signalled_used))
1288 vq->signalled_used_valid = false;
1270 return 0; 1289 return 0;
1271} 1290}
1272 1291
@@ -1275,6 +1294,7 @@ static int __vhost_add_used_n(struct vhost_virtqueue *vq,
1275 unsigned count) 1294 unsigned count)
1276{ 1295{
1277 struct vring_used_elem __user *used; 1296 struct vring_used_elem __user *used;
1297 u16 old, new;
1278 int start; 1298 int start;
1279 1299
1280 start = vq->last_used_idx % vq->num; 1300 start = vq->last_used_idx % vq->num;
@@ -1292,7 +1312,14 @@ static int __vhost_add_used_n(struct vhost_virtqueue *vq,
1292 ((void __user *)used - (void __user *)vq->used), 1312 ((void __user *)used - (void __user *)vq->used),
1293 count * sizeof *used); 1313 count * sizeof *used);
1294 } 1314 }
1295 vq->last_used_idx += count; 1315 old = vq->last_used_idx;
1316 new = (vq->last_used_idx += count);
1317 /* If the driver never bothers to signal in a very long while,
1318 * used index might wrap around. If that happens, invalidate
1319 * signalled_used index we stored. TODO: make sure driver
1320 * signals at least once in 2^16 and remove this. */
1321 if (unlikely((u16)(new - vq->signalled_used) < (u16)(new - old)))
1322 vq->signalled_used_valid = false;
1296 return 0; 1323 return 0;
1297} 1324}
1298 1325
@@ -1331,29 +1358,47 @@ int vhost_add_used_n(struct vhost_virtqueue *vq, struct vring_used_elem *heads,
1331 return r; 1358 return r;
1332} 1359}
1333 1360
1334/* This actually signals the guest, using eventfd. */ 1361static bool vhost_notify(struct vhost_dev *dev, struct vhost_virtqueue *vq)
1335void vhost_signal(struct vhost_dev *dev, struct vhost_virtqueue *vq)
1336{ 1362{
1337 __u16 flags; 1363 __u16 old, new, event;
1338 1364 bool v;
1339 /* Flush out used index updates. This is paired 1365 /* Flush out used index updates. This is paired
1340 * with the barrier that the Guest executes when enabling 1366 * with the barrier that the Guest executes when enabling
1341 * interrupts. */ 1367 * interrupts. */
1342 smp_mb(); 1368 smp_mb();
1343 1369
1344 if (__get_user(flags, &vq->avail->flags)) { 1370 if (vhost_has_feature(dev, VIRTIO_F_NOTIFY_ON_EMPTY) &&
1345 vq_err(vq, "Failed to get flags"); 1371 unlikely(vq->avail_idx == vq->last_avail_idx))
1346 return; 1372 return true;
1373
1374 if (!vhost_has_feature(dev, VIRTIO_RING_F_EVENT_IDX)) {
1375 __u16 flags;
1376 if (__get_user(flags, &vq->avail->flags)) {
1377 vq_err(vq, "Failed to get flags");
1378 return true;
1379 }
1380 return !(flags & VRING_AVAIL_F_NO_INTERRUPT);
1347 } 1381 }
1382 old = vq->signalled_used;
1383 v = vq->signalled_used_valid;
1384 new = vq->signalled_used = vq->last_used_idx;
1385 vq->signalled_used_valid = true;
1348 1386
1349 /* If they don't want an interrupt, don't signal, unless empty. */ 1387 if (unlikely(!v))
1350 if ((flags & VRING_AVAIL_F_NO_INTERRUPT) && 1388 return true;
1351 (vq->avail_idx != vq->last_avail_idx ||
1352 !vhost_has_feature(dev, VIRTIO_F_NOTIFY_ON_EMPTY)))
1353 return;
1354 1389
1390 if (get_user(event, vhost_used_event(vq))) {
1391 vq_err(vq, "Failed to get used event idx");
1392 return true;
1393 }
1394 return vring_need_event(event, new, old);
1395}
1396
1397/* This actually signals the guest, using eventfd. */
1398void vhost_signal(struct vhost_dev *dev, struct vhost_virtqueue *vq)
1399{
1355 /* Signal the Guest tell them we used something up. */ 1400 /* Signal the Guest tell them we used something up. */
1356 if (vq->call_ctx) 1401 if (vq->call_ctx && vhost_notify(dev, vq))
1357 eventfd_signal(vq->call_ctx, 1); 1402 eventfd_signal(vq->call_ctx, 1);
1358} 1403}
1359 1404
@@ -1376,7 +1421,7 @@ void vhost_add_used_and_signal_n(struct vhost_dev *dev,
1376} 1421}
1377 1422
1378/* OK, now we need to know about added descriptors. */ 1423/* OK, now we need to know about added descriptors. */
1379bool vhost_enable_notify(struct vhost_virtqueue *vq) 1424bool vhost_enable_notify(struct vhost_dev *dev, struct vhost_virtqueue *vq)
1380{ 1425{
1381 u16 avail_idx; 1426 u16 avail_idx;
1382 int r; 1427 int r;
@@ -1384,11 +1429,34 @@ bool vhost_enable_notify(struct vhost_virtqueue *vq)
1384 if (!(vq->used_flags & VRING_USED_F_NO_NOTIFY)) 1429 if (!(vq->used_flags & VRING_USED_F_NO_NOTIFY))
1385 return false; 1430 return false;
1386 vq->used_flags &= ~VRING_USED_F_NO_NOTIFY; 1431 vq->used_flags &= ~VRING_USED_F_NO_NOTIFY;
1387 r = put_user(vq->used_flags, &vq->used->flags); 1432 if (!vhost_has_feature(dev, VIRTIO_RING_F_EVENT_IDX)) {
1388 if (r) { 1433 r = put_user(vq->used_flags, &vq->used->flags);
1389 vq_err(vq, "Failed to enable notification at %p: %d\n", 1434 if (r) {
1390 &vq->used->flags, r); 1435 vq_err(vq, "Failed to enable notification at %p: %d\n",
1391 return false; 1436 &vq->used->flags, r);
1437 return false;
1438 }
1439 } else {
1440 r = put_user(vq->avail_idx, vhost_avail_event(vq));
1441 if (r) {
1442 vq_err(vq, "Failed to update avail event index at %p: %d\n",
1443 vhost_avail_event(vq), r);
1444 return false;
1445 }
1446 }
1447 if (unlikely(vq->log_used)) {
1448 void __user *used;
1449 /* Make sure data is seen before log. */
1450 smp_wmb();
1451 used = vhost_has_feature(dev, VIRTIO_RING_F_EVENT_IDX) ?
1452 &vq->used->flags : vhost_avail_event(vq);
1453 /* Log used flags or event index entry write. Both are 16 bit
1454 * fields. */
1455 log_write(vq->log_base, vq->log_addr +
1456 (used - (void __user *)vq->used),
1457 sizeof(u16));
1458 if (vq->log_ctx)
1459 eventfd_signal(vq->log_ctx, 1);
1392 } 1460 }
1393 /* They could have slipped one in as we were doing that: make 1461 /* They could have slipped one in as we were doing that: make
1394 * sure it's written, then check again. */ 1462 * sure it's written, then check again. */
@@ -1404,15 +1472,17 @@ bool vhost_enable_notify(struct vhost_virtqueue *vq)
1404} 1472}
1405 1473
1406/* We don't need to be notified again. */ 1474/* We don't need to be notified again. */
1407void vhost_disable_notify(struct vhost_virtqueue *vq) 1475void vhost_disable_notify(struct vhost_dev *dev, struct vhost_virtqueue *vq)
1408{ 1476{
1409 int r; 1477 int r;
1410 1478
1411 if (vq->used_flags & VRING_USED_F_NO_NOTIFY) 1479 if (vq->used_flags & VRING_USED_F_NO_NOTIFY)
1412 return; 1480 return;
1413 vq->used_flags |= VRING_USED_F_NO_NOTIFY; 1481 vq->used_flags |= VRING_USED_F_NO_NOTIFY;
1414 r = put_user(vq->used_flags, &vq->used->flags); 1482 if (!vhost_has_feature(dev, VIRTIO_RING_F_EVENT_IDX)) {
1415 if (r) 1483 r = put_user(vq->used_flags, &vq->used->flags);
1416 vq_err(vq, "Failed to enable notification at %p: %d\n", 1484 if (r)
1417 &vq->used->flags, r); 1485 vq_err(vq, "Failed to enable notification at %p: %d\n",
1486 &vq->used->flags, r);
1487 }
1418} 1488}
diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h
index b3363ae38518..8e03379dd30f 100644
--- a/drivers/vhost/vhost.h
+++ b/drivers/vhost/vhost.h
@@ -84,6 +84,12 @@ struct vhost_virtqueue {
84 /* Used flags */ 84 /* Used flags */
85 u16 used_flags; 85 u16 used_flags;
86 86
87 /* Last used index value we have signalled on */
88 u16 signalled_used;
89
90 /* Last used index value we have signalled on */
91 bool signalled_used_valid;
92
87 /* Log writes to used structure. */ 93 /* Log writes to used structure. */
88 bool log_used; 94 bool log_used;
89 u64 log_addr; 95 u64 log_addr;
@@ -149,8 +155,8 @@ void vhost_add_used_and_signal(struct vhost_dev *, struct vhost_virtqueue *,
149void vhost_add_used_and_signal_n(struct vhost_dev *, struct vhost_virtqueue *, 155void vhost_add_used_and_signal_n(struct vhost_dev *, struct vhost_virtqueue *,
150 struct vring_used_elem *heads, unsigned count); 156 struct vring_used_elem *heads, unsigned count);
151void vhost_signal(struct vhost_dev *, struct vhost_virtqueue *); 157void vhost_signal(struct vhost_dev *, struct vhost_virtqueue *);
152void vhost_disable_notify(struct vhost_virtqueue *); 158void vhost_disable_notify(struct vhost_dev *, struct vhost_virtqueue *);
153bool vhost_enable_notify(struct vhost_virtqueue *); 159bool vhost_enable_notify(struct vhost_dev *, struct vhost_virtqueue *);
154 160
155int vhost_log_write(struct vhost_virtqueue *vq, struct vhost_log *log, 161int vhost_log_write(struct vhost_virtqueue *vq, struct vhost_log *log,
156 unsigned int log_num, u64 len); 162 unsigned int log_num, u64 len);
@@ -162,11 +168,12 @@ int vhost_log_write(struct vhost_virtqueue *vq, struct vhost_log *log,
162 } while (0) 168 } while (0)
163 169
164enum { 170enum {
165 VHOST_FEATURES = (1 << VIRTIO_F_NOTIFY_ON_EMPTY) | 171 VHOST_FEATURES = (1ULL << VIRTIO_F_NOTIFY_ON_EMPTY) |
166 (1 << VIRTIO_RING_F_INDIRECT_DESC) | 172 (1ULL << VIRTIO_RING_F_INDIRECT_DESC) |
167 (1 << VHOST_F_LOG_ALL) | 173 (1ULL << VIRTIO_RING_F_EVENT_IDX) |
168 (1 << VHOST_NET_F_VIRTIO_NET_HDR) | 174 (1ULL << VHOST_F_LOG_ALL) |
169 (1 << VIRTIO_NET_F_MRG_RXBUF), 175 (1ULL << VHOST_NET_F_VIRTIO_NET_HDR) |
176 (1ULL << VIRTIO_NET_F_MRG_RXBUF),
170}; 177};
171 178
172static inline int vhost_has_feature(struct vhost_dev *dev, int bit) 179static inline int vhost_has_feature(struct vhost_dev *dev, int bit)
diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c
index 0f1da45ba47d..e058ace2a4ad 100644
--- a/drivers/virtio/virtio_balloon.c
+++ b/drivers/virtio/virtio_balloon.c
@@ -40,9 +40,6 @@ struct virtio_balloon
40 /* Waiting for host to ack the pages we released. */ 40 /* Waiting for host to ack the pages we released. */
41 struct completion acked; 41 struct completion acked;
42 42
43 /* Do we have to tell Host *before* we reuse pages? */
44 bool tell_host_first;
45
46 /* The pages we've told the Host we're not using. */ 43 /* The pages we've told the Host we're not using. */
47 unsigned int num_pages; 44 unsigned int num_pages;
48 struct list_head pages; 45 struct list_head pages;
@@ -151,13 +148,14 @@ static void leak_balloon(struct virtio_balloon *vb, size_t num)
151 vb->num_pages--; 148 vb->num_pages--;
152 } 149 }
153 150
154 if (vb->tell_host_first) { 151
155 tell_host(vb, vb->deflate_vq); 152 /*
156 release_pages_by_pfn(vb->pfns, vb->num_pfns); 153 * Note that if
157 } else { 154 * virtio_has_feature(vdev, VIRTIO_BALLOON_F_MUST_TELL_HOST);
158 release_pages_by_pfn(vb->pfns, vb->num_pfns); 155 * is true, we *have* to do it in this order
159 tell_host(vb, vb->deflate_vq); 156 */
160 } 157 tell_host(vb, vb->deflate_vq);
158 release_pages_by_pfn(vb->pfns, vb->num_pfns);
161} 159}
162 160
163static inline void update_stat(struct virtio_balloon *vb, int idx, 161static inline void update_stat(struct virtio_balloon *vb, int idx,
@@ -325,9 +323,6 @@ static int virtballoon_probe(struct virtio_device *vdev)
325 goto out_del_vqs; 323 goto out_del_vqs;
326 } 324 }
327 325
328 vb->tell_host_first
329 = virtio_has_feature(vdev, VIRTIO_BALLOON_F_MUST_TELL_HOST);
330
331 return 0; 326 return 0;
332 327
333out_del_vqs: 328out_del_vqs:
diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index b0043fb26a4d..68b9136847af 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -82,6 +82,9 @@ struct vring_virtqueue
82 /* Host supports indirect buffers */ 82 /* Host supports indirect buffers */
83 bool indirect; 83 bool indirect;
84 84
85 /* Host publishes avail event idx */
86 bool event;
87
85 /* Number of free buffers */ 88 /* Number of free buffers */
86 unsigned int num_free; 89 unsigned int num_free;
87 /* Head of free buffer list. */ 90 /* Head of free buffer list. */
@@ -237,18 +240,22 @@ EXPORT_SYMBOL_GPL(virtqueue_add_buf_gfp);
237void virtqueue_kick(struct virtqueue *_vq) 240void virtqueue_kick(struct virtqueue *_vq)
238{ 241{
239 struct vring_virtqueue *vq = to_vvq(_vq); 242 struct vring_virtqueue *vq = to_vvq(_vq);
243 u16 new, old;
240 START_USE(vq); 244 START_USE(vq);
241 /* Descriptors and available array need to be set before we expose the 245 /* Descriptors and available array need to be set before we expose the
242 * new available array entries. */ 246 * new available array entries. */
243 virtio_wmb(); 247 virtio_wmb();
244 248
245 vq->vring.avail->idx += vq->num_added; 249 old = vq->vring.avail->idx;
250 new = vq->vring.avail->idx = old + vq->num_added;
246 vq->num_added = 0; 251 vq->num_added = 0;
247 252
248 /* Need to update avail index before checking if we should notify */ 253 /* Need to update avail index before checking if we should notify */
249 virtio_mb(); 254 virtio_mb();
250 255
251 if (!(vq->vring.used->flags & VRING_USED_F_NO_NOTIFY)) 256 if (vq->event ?
257 vring_need_event(vring_avail_event(&vq->vring), new, old) :
258 !(vq->vring.used->flags & VRING_USED_F_NO_NOTIFY))
252 /* Prod other side to tell it about changes. */ 259 /* Prod other side to tell it about changes. */
253 vq->notify(&vq->vq); 260 vq->notify(&vq->vq);
254 261
@@ -324,6 +331,14 @@ void *virtqueue_get_buf(struct virtqueue *_vq, unsigned int *len)
324 ret = vq->data[i]; 331 ret = vq->data[i];
325 detach_buf(vq, i); 332 detach_buf(vq, i);
326 vq->last_used_idx++; 333 vq->last_used_idx++;
334 /* If we expect an interrupt for the next entry, tell host
335 * by writing event index and flush out the write before
336 * the read in the next get_buf call. */
337 if (!(vq->vring.avail->flags & VRING_AVAIL_F_NO_INTERRUPT)) {
338 vring_used_event(&vq->vring) = vq->last_used_idx;
339 virtio_mb();
340 }
341
327 END_USE(vq); 342 END_USE(vq);
328 return ret; 343 return ret;
329} 344}
@@ -345,7 +360,11 @@ bool virtqueue_enable_cb(struct virtqueue *_vq)
345 360
346 /* We optimistically turn back on interrupts, then check if there was 361 /* We optimistically turn back on interrupts, then check if there was
347 * more to do. */ 362 * more to do. */
363 /* Depending on the VIRTIO_RING_F_EVENT_IDX feature, we need to
364 * either clear the flags bit or point the event index at the next
365 * entry. Always do both to keep code simple. */
348 vq->vring.avail->flags &= ~VRING_AVAIL_F_NO_INTERRUPT; 366 vq->vring.avail->flags &= ~VRING_AVAIL_F_NO_INTERRUPT;
367 vring_used_event(&vq->vring) = vq->last_used_idx;
349 virtio_mb(); 368 virtio_mb();
350 if (unlikely(more_used(vq))) { 369 if (unlikely(more_used(vq))) {
351 END_USE(vq); 370 END_USE(vq);
@@ -357,6 +376,33 @@ bool virtqueue_enable_cb(struct virtqueue *_vq)
357} 376}
358EXPORT_SYMBOL_GPL(virtqueue_enable_cb); 377EXPORT_SYMBOL_GPL(virtqueue_enable_cb);
359 378
379bool virtqueue_enable_cb_delayed(struct virtqueue *_vq)
380{
381 struct vring_virtqueue *vq = to_vvq(_vq);
382 u16 bufs;
383
384 START_USE(vq);
385
386 /* We optimistically turn back on interrupts, then check if there was
387 * more to do. */
388 /* Depending on the VIRTIO_RING_F_USED_EVENT_IDX feature, we need to
389 * either clear the flags bit or point the event index at the next
390 * entry. Always do both to keep code simple. */
391 vq->vring.avail->flags &= ~VRING_AVAIL_F_NO_INTERRUPT;
392 /* TODO: tune this threshold */
393 bufs = (u16)(vq->vring.avail->idx - vq->last_used_idx) * 3 / 4;
394 vring_used_event(&vq->vring) = vq->last_used_idx + bufs;
395 virtio_mb();
396 if (unlikely((u16)(vq->vring.used->idx - vq->last_used_idx) > bufs)) {
397 END_USE(vq);
398 return false;
399 }
400
401 END_USE(vq);
402 return true;
403}
404EXPORT_SYMBOL_GPL(virtqueue_enable_cb_delayed);
405
360void *virtqueue_detach_unused_buf(struct virtqueue *_vq) 406void *virtqueue_detach_unused_buf(struct virtqueue *_vq)
361{ 407{
362 struct vring_virtqueue *vq = to_vvq(_vq); 408 struct vring_virtqueue *vq = to_vvq(_vq);
@@ -438,6 +484,7 @@ struct virtqueue *vring_new_virtqueue(unsigned int num,
438#endif 484#endif
439 485
440 vq->indirect = virtio_has_feature(vdev, VIRTIO_RING_F_INDIRECT_DESC); 486 vq->indirect = virtio_has_feature(vdev, VIRTIO_RING_F_INDIRECT_DESC);
487 vq->event = virtio_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX);
441 488
442 /* No callback? Tell other side not to bother us. */ 489 /* No callback? Tell other side not to bother us. */
443 if (!callback) 490 if (!callback)
@@ -472,6 +519,8 @@ void vring_transport_features(struct virtio_device *vdev)
472 switch (i) { 519 switch (i) {
473 case VIRTIO_RING_F_INDIRECT_DESC: 520 case VIRTIO_RING_F_INDIRECT_DESC:
474 break; 521 break;
522 case VIRTIO_RING_F_EVENT_IDX:
523 break;
475 default: 524 default:
476 /* We don't understand this bit. */ 525 /* We don't understand this bit. */
477 clear_bit(i, vdev->features); 526 clear_bit(i, vdev->features);