aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2008-02-05 22:58:05 -0500
committerDavid S. Miller <davem@davemloft.net>2008-02-05 22:58:05 -0500
commita29961b33b089cf4d252ac125891a2784d20ef2f (patch)
tree8fcaa56db74d1357b73ddebb33fadba410ed1439
parent731a0609df9cef35ae861d31004f50a02ebde6c2 (diff)
parentb79caa68c0d48477453a90d12be34b47cb75f3a8 (diff)
Merge branch 'fixes' of master.kernel.org:/pub/scm/linux/kernel/git/linville/wireless-2.6
-rw-r--r--drivers/net/wireless/b43/dma.c137
-rw-r--r--drivers/net/wireless/b43/dma.h20
-rw-r--r--drivers/net/wireless/b43legacy/dma.c23
-rw-r--r--drivers/net/wireless/b43legacy/main.c9
-rw-r--r--drivers/net/wireless/b43legacy/pio.c21
-rw-r--r--drivers/net/wireless/b43legacy/xmit.c15
-rw-r--r--drivers/net/wireless/b43legacy/xmit.h2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl3945-base.c8
-rw-r--r--include/linux/ssb/ssb.h9
-rw-r--r--net/mac80211/Kconfig1
10 files changed, 171 insertions, 74 deletions
diff --git a/drivers/net/wireless/b43/dma.c b/drivers/net/wireless/b43/dma.c
index 8a708b77925d..3dfb28a34be9 100644
--- a/drivers/net/wireless/b43/dma.c
+++ b/drivers/net/wireless/b43/dma.c
@@ -337,7 +337,7 @@ static inline int txring_to_priority(struct b43_dmaring *ring)
337 return idx_to_prio[index]; 337 return idx_to_prio[index];
338} 338}
339 339
340u16 b43_dmacontroller_base(int dma64bit, int controller_idx) 340static u16 b43_dmacontroller_base(enum b43_dmatype type, int controller_idx)
341{ 341{
342 static const u16 map64[] = { 342 static const u16 map64[] = {
343 B43_MMIO_DMA64_BASE0, 343 B43_MMIO_DMA64_BASE0,
@@ -356,7 +356,7 @@ u16 b43_dmacontroller_base(int dma64bit, int controller_idx)
356 B43_MMIO_DMA32_BASE5, 356 B43_MMIO_DMA32_BASE5,
357 }; 357 };
358 358
359 if (dma64bit) { 359 if (type == B43_DMA_64BIT) {
360 B43_WARN_ON(!(controller_idx >= 0 && 360 B43_WARN_ON(!(controller_idx >= 0 &&
361 controller_idx < ARRAY_SIZE(map64))); 361 controller_idx < ARRAY_SIZE(map64)));
362 return map64[controller_idx]; 362 return map64[controller_idx];
@@ -437,7 +437,7 @@ static int alloc_ringmemory(struct b43_dmaring *ring)
437 * 02, which uses 64-bit DMA, needs the ring buffer in very low memory, 437 * 02, which uses 64-bit DMA, needs the ring buffer in very low memory,
438 * which accounts for the GFP_DMA flag below. 438 * which accounts for the GFP_DMA flag below.
439 */ 439 */
440 if (ring->dma64) 440 if (ring->type == B43_DMA_64BIT)
441 flags |= GFP_DMA; 441 flags |= GFP_DMA;
442 ring->descbase = dma_alloc_coherent(dev, B43_DMA_RINGMEMSIZE, 442 ring->descbase = dma_alloc_coherent(dev, B43_DMA_RINGMEMSIZE,
443 &(ring->dmabase), flags); 443 &(ring->dmabase), flags);
@@ -459,7 +459,8 @@ static void free_ringmemory(struct b43_dmaring *ring)
459} 459}
460 460
461/* Reset the RX DMA channel */ 461/* Reset the RX DMA channel */
462int b43_dmacontroller_rx_reset(struct b43_wldev *dev, u16 mmio_base, int dma64) 462static int b43_dmacontroller_rx_reset(struct b43_wldev *dev, u16 mmio_base,
463 enum b43_dmatype type)
463{ 464{
464 int i; 465 int i;
465 u32 value; 466 u32 value;
@@ -467,12 +468,13 @@ int b43_dmacontroller_rx_reset(struct b43_wldev *dev, u16 mmio_base, int dma64)
467 468
468 might_sleep(); 469 might_sleep();
469 470
470 offset = dma64 ? B43_DMA64_RXCTL : B43_DMA32_RXCTL; 471 offset = (type == B43_DMA_64BIT) ? B43_DMA64_RXCTL : B43_DMA32_RXCTL;
471 b43_write32(dev, mmio_base + offset, 0); 472 b43_write32(dev, mmio_base + offset, 0);
472 for (i = 0; i < 10; i++) { 473 for (i = 0; i < 10; i++) {
473 offset = dma64 ? B43_DMA64_RXSTATUS : B43_DMA32_RXSTATUS; 474 offset = (type == B43_DMA_64BIT) ? B43_DMA64_RXSTATUS :
475 B43_DMA32_RXSTATUS;
474 value = b43_read32(dev, mmio_base + offset); 476 value = b43_read32(dev, mmio_base + offset);
475 if (dma64) { 477 if (type == B43_DMA_64BIT) {
476 value &= B43_DMA64_RXSTAT; 478 value &= B43_DMA64_RXSTAT;
477 if (value == B43_DMA64_RXSTAT_DISABLED) { 479 if (value == B43_DMA64_RXSTAT_DISABLED) {
478 i = -1; 480 i = -1;
@@ -496,7 +498,8 @@ int b43_dmacontroller_rx_reset(struct b43_wldev *dev, u16 mmio_base, int dma64)
496} 498}
497 499
498/* Reset the TX DMA channel */ 500/* Reset the TX DMA channel */
499int b43_dmacontroller_tx_reset(struct b43_wldev *dev, u16 mmio_base, int dma64) 501static int b43_dmacontroller_tx_reset(struct b43_wldev *dev, u16 mmio_base,
502 enum b43_dmatype type)
500{ 503{
501 int i; 504 int i;
502 u32 value; 505 u32 value;
@@ -505,9 +508,10 @@ int b43_dmacontroller_tx_reset(struct b43_wldev *dev, u16 mmio_base, int dma64)
505 might_sleep(); 508 might_sleep();
506 509
507 for (i = 0; i < 10; i++) { 510 for (i = 0; i < 10; i++) {
508 offset = dma64 ? B43_DMA64_TXSTATUS : B43_DMA32_TXSTATUS; 511 offset = (type == B43_DMA_64BIT) ? B43_DMA64_TXSTATUS :
512 B43_DMA32_TXSTATUS;
509 value = b43_read32(dev, mmio_base + offset); 513 value = b43_read32(dev, mmio_base + offset);
510 if (dma64) { 514 if (type == B43_DMA_64BIT) {
511 value &= B43_DMA64_TXSTAT; 515 value &= B43_DMA64_TXSTAT;
512 if (value == B43_DMA64_TXSTAT_DISABLED || 516 if (value == B43_DMA64_TXSTAT_DISABLED ||
513 value == B43_DMA64_TXSTAT_IDLEWAIT || 517 value == B43_DMA64_TXSTAT_IDLEWAIT ||
@@ -522,12 +526,13 @@ int b43_dmacontroller_tx_reset(struct b43_wldev *dev, u16 mmio_base, int dma64)
522 } 526 }
523 msleep(1); 527 msleep(1);
524 } 528 }
525 offset = dma64 ? B43_DMA64_TXCTL : B43_DMA32_TXCTL; 529 offset = (type == B43_DMA_64BIT) ? B43_DMA64_TXCTL : B43_DMA32_TXCTL;
526 b43_write32(dev, mmio_base + offset, 0); 530 b43_write32(dev, mmio_base + offset, 0);
527 for (i = 0; i < 10; i++) { 531 for (i = 0; i < 10; i++) {
528 offset = dma64 ? B43_DMA64_TXSTATUS : B43_DMA32_TXSTATUS; 532 offset = (type == B43_DMA_64BIT) ? B43_DMA64_TXSTATUS :
533 B43_DMA32_TXSTATUS;
529 value = b43_read32(dev, mmio_base + offset); 534 value = b43_read32(dev, mmio_base + offset);
530 if (dma64) { 535 if (type == B43_DMA_64BIT) {
531 value &= B43_DMA64_TXSTAT; 536 value &= B43_DMA64_TXSTAT;
532 if (value == B43_DMA64_TXSTAT_DISABLED) { 537 if (value == B43_DMA64_TXSTAT_DISABLED) {
533 i = -1; 538 i = -1;
@@ -552,6 +557,33 @@ int b43_dmacontroller_tx_reset(struct b43_wldev *dev, u16 mmio_base, int dma64)
552 return 0; 557 return 0;
553} 558}
554 559
560/* Check if a DMA mapping address is invalid. */
561static bool b43_dma_mapping_error(struct b43_dmaring *ring,
562 dma_addr_t addr,
563 size_t buffersize)
564{
565 if (unlikely(dma_mapping_error(addr)))
566 return 1;
567
568 switch (ring->type) {
569 case B43_DMA_30BIT:
570 if ((u64)addr + buffersize > (1ULL << 30))
571 return 1;
572 break;
573 case B43_DMA_32BIT:
574 if ((u64)addr + buffersize > (1ULL << 32))
575 return 1;
576 break;
577 case B43_DMA_64BIT:
578 /* Currently we can't have addresses beyond
579 * 64bit in the kernel. */
580 break;
581 }
582
583 /* The address is OK. */
584 return 0;
585}
586
555static int setup_rx_descbuffer(struct b43_dmaring *ring, 587static int setup_rx_descbuffer(struct b43_dmaring *ring,
556 struct b43_dmadesc_generic *desc, 588 struct b43_dmadesc_generic *desc,
557 struct b43_dmadesc_meta *meta, gfp_t gfp_flags) 589 struct b43_dmadesc_meta *meta, gfp_t gfp_flags)
@@ -567,7 +599,7 @@ static int setup_rx_descbuffer(struct b43_dmaring *ring,
567 if (unlikely(!skb)) 599 if (unlikely(!skb))
568 return -ENOMEM; 600 return -ENOMEM;
569 dmaaddr = map_descbuffer(ring, skb->data, ring->rx_buffersize, 0); 601 dmaaddr = map_descbuffer(ring, skb->data, ring->rx_buffersize, 0);
570 if (dma_mapping_error(dmaaddr)) { 602 if (b43_dma_mapping_error(ring, dmaaddr, ring->rx_buffersize)) {
571 /* ugh. try to realloc in zone_dma */ 603 /* ugh. try to realloc in zone_dma */
572 gfp_flags |= GFP_DMA; 604 gfp_flags |= GFP_DMA;
573 605
@@ -580,7 +612,7 @@ static int setup_rx_descbuffer(struct b43_dmaring *ring,
580 ring->rx_buffersize, 0); 612 ring->rx_buffersize, 0);
581 } 613 }
582 614
583 if (dma_mapping_error(dmaaddr)) { 615 if (b43_dma_mapping_error(ring, dmaaddr, ring->rx_buffersize)) {
584 dev_kfree_skb_any(skb); 616 dev_kfree_skb_any(skb);
585 return -EIO; 617 return -EIO;
586 } 618 }
@@ -645,7 +677,7 @@ static int dmacontroller_setup(struct b43_dmaring *ring)
645 u32 trans = ssb_dma_translation(ring->dev->dev); 677 u32 trans = ssb_dma_translation(ring->dev->dev);
646 678
647 if (ring->tx) { 679 if (ring->tx) {
648 if (ring->dma64) { 680 if (ring->type == B43_DMA_64BIT) {
649 u64 ringbase = (u64) (ring->dmabase); 681 u64 ringbase = (u64) (ring->dmabase);
650 682
651 addrext = ((ringbase >> 32) & SSB_DMA_TRANSLATION_MASK) 683 addrext = ((ringbase >> 32) & SSB_DMA_TRANSLATION_MASK)
@@ -677,7 +709,7 @@ static int dmacontroller_setup(struct b43_dmaring *ring)
677 err = alloc_initial_descbuffers(ring); 709 err = alloc_initial_descbuffers(ring);
678 if (err) 710 if (err)
679 goto out; 711 goto out;
680 if (ring->dma64) { 712 if (ring->type == B43_DMA_64BIT) {
681 u64 ringbase = (u64) (ring->dmabase); 713 u64 ringbase = (u64) (ring->dmabase);
682 714
683 addrext = ((ringbase >> 32) & SSB_DMA_TRANSLATION_MASK) 715 addrext = ((ringbase >> 32) & SSB_DMA_TRANSLATION_MASK)
@@ -722,16 +754,16 @@ static void dmacontroller_cleanup(struct b43_dmaring *ring)
722{ 754{
723 if (ring->tx) { 755 if (ring->tx) {
724 b43_dmacontroller_tx_reset(ring->dev, ring->mmio_base, 756 b43_dmacontroller_tx_reset(ring->dev, ring->mmio_base,
725 ring->dma64); 757 ring->type);
726 if (ring->dma64) { 758 if (ring->type == B43_DMA_64BIT) {
727 b43_dma_write(ring, B43_DMA64_TXRINGLO, 0); 759 b43_dma_write(ring, B43_DMA64_TXRINGLO, 0);
728 b43_dma_write(ring, B43_DMA64_TXRINGHI, 0); 760 b43_dma_write(ring, B43_DMA64_TXRINGHI, 0);
729 } else 761 } else
730 b43_dma_write(ring, B43_DMA32_TXRING, 0); 762 b43_dma_write(ring, B43_DMA32_TXRING, 0);
731 } else { 763 } else {
732 b43_dmacontroller_rx_reset(ring->dev, ring->mmio_base, 764 b43_dmacontroller_rx_reset(ring->dev, ring->mmio_base,
733 ring->dma64); 765 ring->type);
734 if (ring->dma64) { 766 if (ring->type == B43_DMA_64BIT) {
735 b43_dma_write(ring, B43_DMA64_RXRINGLO, 0); 767 b43_dma_write(ring, B43_DMA64_RXRINGLO, 0);
736 b43_dma_write(ring, B43_DMA64_RXRINGHI, 0); 768 b43_dma_write(ring, B43_DMA64_RXRINGHI, 0);
737 } else 769 } else
@@ -786,7 +818,8 @@ static u64 supported_dma_mask(struct b43_wldev *dev)
786static 818static
787struct b43_dmaring *b43_setup_dmaring(struct b43_wldev *dev, 819struct b43_dmaring *b43_setup_dmaring(struct b43_wldev *dev,
788 int controller_index, 820 int controller_index,
789 int for_tx, int dma64) 821 int for_tx,
822 enum b43_dmatype type)
790{ 823{
791 struct b43_dmaring *ring; 824 struct b43_dmaring *ring;
792 int err; 825 int err;
@@ -796,6 +829,7 @@ struct b43_dmaring *b43_setup_dmaring(struct b43_wldev *dev,
796 ring = kzalloc(sizeof(*ring), GFP_KERNEL); 829 ring = kzalloc(sizeof(*ring), GFP_KERNEL);
797 if (!ring) 830 if (!ring)
798 goto out; 831 goto out;
832 ring->type = type;
799 833
800 nr_slots = B43_RXRING_SLOTS; 834 nr_slots = B43_RXRING_SLOTS;
801 if (for_tx) 835 if (for_tx)
@@ -818,7 +852,7 @@ struct b43_dmaring *b43_setup_dmaring(struct b43_wldev *dev,
818 b43_txhdr_size(dev), 852 b43_txhdr_size(dev),
819 DMA_TO_DEVICE); 853 DMA_TO_DEVICE);
820 854
821 if (dma_mapping_error(dma_test)) { 855 if (b43_dma_mapping_error(ring, dma_test, b43_txhdr_size(dev))) {
822 /* ugh realloc */ 856 /* ugh realloc */
823 kfree(ring->txhdr_cache); 857 kfree(ring->txhdr_cache);
824 ring->txhdr_cache = kcalloc(nr_slots, 858 ring->txhdr_cache = kcalloc(nr_slots,
@@ -832,7 +866,8 @@ struct b43_dmaring *b43_setup_dmaring(struct b43_wldev *dev,
832 b43_txhdr_size(dev), 866 b43_txhdr_size(dev),
833 DMA_TO_DEVICE); 867 DMA_TO_DEVICE);
834 868
835 if (dma_mapping_error(dma_test)) 869 if (b43_dma_mapping_error(ring, dma_test,
870 b43_txhdr_size(dev)))
836 goto err_kfree_txhdr_cache; 871 goto err_kfree_txhdr_cache;
837 } 872 }
838 873
@@ -843,10 +878,9 @@ struct b43_dmaring *b43_setup_dmaring(struct b43_wldev *dev,
843 878
844 ring->dev = dev; 879 ring->dev = dev;
845 ring->nr_slots = nr_slots; 880 ring->nr_slots = nr_slots;
846 ring->mmio_base = b43_dmacontroller_base(dma64, controller_index); 881 ring->mmio_base = b43_dmacontroller_base(type, controller_index);
847 ring->index = controller_index; 882 ring->index = controller_index;
848 ring->dma64 = !!dma64; 883 if (type == B43_DMA_64BIT)
849 if (dma64)
850 ring->ops = &dma64_ops; 884 ring->ops = &dma64_ops;
851 else 885 else
852 ring->ops = &dma32_ops; 886 ring->ops = &dma32_ops;
@@ -896,8 +930,8 @@ static void b43_destroy_dmaring(struct b43_dmaring *ring)
896 if (!ring) 930 if (!ring)
897 return; 931 return;
898 932
899 b43dbg(ring->dev->wl, "DMA-%s 0x%04X (%s) max used slots: %d/%d\n", 933 b43dbg(ring->dev->wl, "DMA-%u 0x%04X (%s) max used slots: %d/%d\n",
900 (ring->dma64) ? "64" : "32", 934 (unsigned int)(ring->type),
901 ring->mmio_base, 935 ring->mmio_base,
902 (ring->tx) ? "TX" : "RX", ring->max_used_slots, ring->nr_slots); 936 (ring->tx) ? "TX" : "RX", ring->max_used_slots, ring->nr_slots);
903 /* Device IRQs are disabled prior entering this function, 937 /* Device IRQs are disabled prior entering this function,
@@ -941,12 +975,22 @@ int b43_dma_init(struct b43_wldev *dev)
941 struct b43_dmaring *ring; 975 struct b43_dmaring *ring;
942 int err; 976 int err;
943 u64 dmamask; 977 u64 dmamask;
944 int dma64 = 0; 978 enum b43_dmatype type;
945 979
946 dmamask = supported_dma_mask(dev); 980 dmamask = supported_dma_mask(dev);
947 if (dmamask == DMA_64BIT_MASK) 981 switch (dmamask) {
948 dma64 = 1; 982 default:
949 983 B43_WARN_ON(1);
984 case DMA_30BIT_MASK:
985 type = B43_DMA_30BIT;
986 break;
987 case DMA_32BIT_MASK:
988 type = B43_DMA_32BIT;
989 break;
990 case DMA_64BIT_MASK:
991 type = B43_DMA_64BIT;
992 break;
993 }
950 err = ssb_dma_set_mask(dev->dev, dmamask); 994 err = ssb_dma_set_mask(dev->dev, dmamask);
951 if (err) { 995 if (err) {
952 b43err(dev->wl, "The machine/kernel does not support " 996 b43err(dev->wl, "The machine/kernel does not support "
@@ -958,52 +1002,51 @@ int b43_dma_init(struct b43_wldev *dev)
958 1002
959 err = -ENOMEM; 1003 err = -ENOMEM;
960 /* setup TX DMA channels. */ 1004 /* setup TX DMA channels. */
961 ring = b43_setup_dmaring(dev, 0, 1, dma64); 1005 ring = b43_setup_dmaring(dev, 0, 1, type);
962 if (!ring) 1006 if (!ring)
963 goto out; 1007 goto out;
964 dma->tx_ring0 = ring; 1008 dma->tx_ring0 = ring;
965 1009
966 ring = b43_setup_dmaring(dev, 1, 1, dma64); 1010 ring = b43_setup_dmaring(dev, 1, 1, type);
967 if (!ring) 1011 if (!ring)
968 goto err_destroy_tx0; 1012 goto err_destroy_tx0;
969 dma->tx_ring1 = ring; 1013 dma->tx_ring1 = ring;
970 1014
971 ring = b43_setup_dmaring(dev, 2, 1, dma64); 1015 ring = b43_setup_dmaring(dev, 2, 1, type);
972 if (!ring) 1016 if (!ring)
973 goto err_destroy_tx1; 1017 goto err_destroy_tx1;
974 dma->tx_ring2 = ring; 1018 dma->tx_ring2 = ring;
975 1019
976 ring = b43_setup_dmaring(dev, 3, 1, dma64); 1020 ring = b43_setup_dmaring(dev, 3, 1, type);
977 if (!ring) 1021 if (!ring)
978 goto err_destroy_tx2; 1022 goto err_destroy_tx2;
979 dma->tx_ring3 = ring; 1023 dma->tx_ring3 = ring;
980 1024
981 ring = b43_setup_dmaring(dev, 4, 1, dma64); 1025 ring = b43_setup_dmaring(dev, 4, 1, type);
982 if (!ring) 1026 if (!ring)
983 goto err_destroy_tx3; 1027 goto err_destroy_tx3;
984 dma->tx_ring4 = ring; 1028 dma->tx_ring4 = ring;
985 1029
986 ring = b43_setup_dmaring(dev, 5, 1, dma64); 1030 ring = b43_setup_dmaring(dev, 5, 1, type);
987 if (!ring) 1031 if (!ring)
988 goto err_destroy_tx4; 1032 goto err_destroy_tx4;
989 dma->tx_ring5 = ring; 1033 dma->tx_ring5 = ring;
990 1034
991 /* setup RX DMA channels. */ 1035 /* setup RX DMA channels. */
992 ring = b43_setup_dmaring(dev, 0, 0, dma64); 1036 ring = b43_setup_dmaring(dev, 0, 0, type);
993 if (!ring) 1037 if (!ring)
994 goto err_destroy_tx5; 1038 goto err_destroy_tx5;
995 dma->rx_ring0 = ring; 1039 dma->rx_ring0 = ring;
996 1040
997 if (dev->dev->id.revision < 5) { 1041 if (dev->dev->id.revision < 5) {
998 ring = b43_setup_dmaring(dev, 3, 0, dma64); 1042 ring = b43_setup_dmaring(dev, 3, 0, type);
999 if (!ring) 1043 if (!ring)
1000 goto err_destroy_rx0; 1044 goto err_destroy_rx0;
1001 dma->rx_ring3 = ring; 1045 dma->rx_ring3 = ring;
1002 } 1046 }
1003 1047
1004 b43dbg(dev->wl, "%d-bit DMA initialized\n", 1048 b43dbg(dev->wl, "%u-bit DMA initialized\n",
1005 (dmamask == DMA_64BIT_MASK) ? 64 : 1049 (unsigned int)type);
1006 (dmamask == DMA_32BIT_MASK) ? 32 : 30);
1007 err = 0; 1050 err = 0;
1008 out: 1051 out:
1009 return err; 1052 return err;
@@ -1146,7 +1189,7 @@ static int dma_tx_fragment(struct b43_dmaring *ring,
1146 1189
1147 meta_hdr->dmaaddr = map_descbuffer(ring, (unsigned char *)header, 1190 meta_hdr->dmaaddr = map_descbuffer(ring, (unsigned char *)header,
1148 hdrsize, 1); 1191 hdrsize, 1);
1149 if (dma_mapping_error(meta_hdr->dmaaddr)) { 1192 if (b43_dma_mapping_error(ring, meta_hdr->dmaaddr, hdrsize)) {
1150 ring->current_slot = old_top_slot; 1193 ring->current_slot = old_top_slot;
1151 ring->used_slots = old_used_slots; 1194 ring->used_slots = old_used_slots;
1152 return -EIO; 1195 return -EIO;
@@ -1165,7 +1208,7 @@ static int dma_tx_fragment(struct b43_dmaring *ring,
1165 1208
1166 meta->dmaaddr = map_descbuffer(ring, skb->data, skb->len, 1); 1209 meta->dmaaddr = map_descbuffer(ring, skb->data, skb->len, 1);
1167 /* create a bounce buffer in zone_dma on mapping failure. */ 1210 /* create a bounce buffer in zone_dma on mapping failure. */
1168 if (dma_mapping_error(meta->dmaaddr)) { 1211 if (b43_dma_mapping_error(ring, meta->dmaaddr, skb->len)) {
1169 bounce_skb = __dev_alloc_skb(skb->len, GFP_ATOMIC | GFP_DMA); 1212 bounce_skb = __dev_alloc_skb(skb->len, GFP_ATOMIC | GFP_DMA);
1170 if (!bounce_skb) { 1213 if (!bounce_skb) {
1171 ring->current_slot = old_top_slot; 1214 ring->current_slot = old_top_slot;
@@ -1179,7 +1222,7 @@ static int dma_tx_fragment(struct b43_dmaring *ring,
1179 skb = bounce_skb; 1222 skb = bounce_skb;
1180 meta->skb = skb; 1223 meta->skb = skb;
1181 meta->dmaaddr = map_descbuffer(ring, skb->data, skb->len, 1); 1224 meta->dmaaddr = map_descbuffer(ring, skb->data, skb->len, 1);
1182 if (dma_mapping_error(meta->dmaaddr)) { 1225 if (b43_dma_mapping_error(ring, meta->dmaaddr, skb->len)) {
1183 ring->current_slot = old_top_slot; 1226 ring->current_slot = old_top_slot;
1184 ring->used_slots = old_used_slots; 1227 ring->used_slots = old_used_slots;
1185 err = -EIO; 1228 err = -EIO;
diff --git a/drivers/net/wireless/b43/dma.h b/drivers/net/wireless/b43/dma.h
index 58db03ac536e..c0d6b69e6501 100644
--- a/drivers/net/wireless/b43/dma.h
+++ b/drivers/net/wireless/b43/dma.h
@@ -203,6 +203,12 @@ struct b43_dma_ops {
203 void (*set_current_rxslot) (struct b43_dmaring * ring, int slot); 203 void (*set_current_rxslot) (struct b43_dmaring * ring, int slot);
204}; 204};
205 205
206enum b43_dmatype {
207 B43_DMA_30BIT = 30,
208 B43_DMA_32BIT = 32,
209 B43_DMA_64BIT = 64,
210};
211
206struct b43_dmaring { 212struct b43_dmaring {
207 /* Lowlevel DMA ops. */ 213 /* Lowlevel DMA ops. */
208 const struct b43_dma_ops *ops; 214 const struct b43_dma_ops *ops;
@@ -235,8 +241,8 @@ struct b43_dmaring {
235 int index; 241 int index;
236 /* Boolean. Is this a TX ring? */ 242 /* Boolean. Is this a TX ring? */
237 bool tx; 243 bool tx;
238 /* Boolean. 64bit DMA if true, 32bit DMA otherwise. */ 244 /* The type of DMA engine used. */
239 bool dma64; 245 enum b43_dmatype type;
240 /* Boolean. Is this ring stopped at ieee80211 level? */ 246 /* Boolean. Is this ring stopped at ieee80211 level? */
241 bool stopped; 247 bool stopped;
242 /* Lock, only used for TX. */ 248 /* Lock, only used for TX. */
@@ -255,8 +261,7 @@ static inline u32 b43_dma_read(struct b43_dmaring *ring, u16 offset)
255 return b43_read32(ring->dev, ring->mmio_base + offset); 261 return b43_read32(ring->dev, ring->mmio_base + offset);
256} 262}
257 263
258static inline 264static inline void b43_dma_write(struct b43_dmaring *ring, u16 offset, u32 value)
259 void b43_dma_write(struct b43_dmaring *ring, u16 offset, u32 value)
260{ 265{
261 b43_write32(ring->dev, ring->mmio_base + offset, value); 266 b43_write32(ring->dev, ring->mmio_base + offset, value);
262} 267}
@@ -264,13 +269,6 @@ static inline
264int b43_dma_init(struct b43_wldev *dev); 269int b43_dma_init(struct b43_wldev *dev);
265void b43_dma_free(struct b43_wldev *dev); 270void b43_dma_free(struct b43_wldev *dev);
266 271
267int b43_dmacontroller_rx_reset(struct b43_wldev *dev,
268 u16 dmacontroller_mmio_base, int dma64);
269int b43_dmacontroller_tx_reset(struct b43_wldev *dev,
270 u16 dmacontroller_mmio_base, int dma64);
271
272u16 b43_dmacontroller_base(int dma64bit, int dmacontroller_idx);
273
274void b43_dma_tx_suspend(struct b43_wldev *dev); 272void b43_dma_tx_suspend(struct b43_wldev *dev);
275void b43_dma_tx_resume(struct b43_wldev *dev); 273void b43_dma_tx_resume(struct b43_wldev *dev);
276 274
diff --git a/drivers/net/wireless/b43legacy/dma.c b/drivers/net/wireless/b43legacy/dma.c
index 83161d9af813..6e08405e8026 100644
--- a/drivers/net/wireless/b43legacy/dma.c
+++ b/drivers/net/wireless/b43legacy/dma.c
@@ -1164,7 +1164,7 @@ static int dma_tx_fragment(struct b43legacy_dmaring *ring,
1164{ 1164{
1165 const struct b43legacy_dma_ops *ops = ring->ops; 1165 const struct b43legacy_dma_ops *ops = ring->ops;
1166 u8 *header; 1166 u8 *header;
1167 int slot; 1167 int slot, old_top_slot, old_used_slots;
1168 int err; 1168 int err;
1169 struct b43legacy_dmadesc_generic *desc; 1169 struct b43legacy_dmadesc_generic *desc;
1170 struct b43legacy_dmadesc_meta *meta; 1170 struct b43legacy_dmadesc_meta *meta;
@@ -1174,6 +1174,9 @@ static int dma_tx_fragment(struct b43legacy_dmaring *ring,
1174#define SLOTS_PER_PACKET 2 1174#define SLOTS_PER_PACKET 2
1175 B43legacy_WARN_ON(skb_shinfo(skb)->nr_frags != 0); 1175 B43legacy_WARN_ON(skb_shinfo(skb)->nr_frags != 0);
1176 1176
1177 old_top_slot = ring->current_slot;
1178 old_used_slots = ring->used_slots;
1179
1177 /* Get a slot for the header. */ 1180 /* Get a slot for the header. */
1178 slot = request_slot(ring); 1181 slot = request_slot(ring);
1179 desc = ops->idx2desc(ring, slot, &meta_hdr); 1182 desc = ops->idx2desc(ring, slot, &meta_hdr);
@@ -1181,9 +1184,14 @@ static int dma_tx_fragment(struct b43legacy_dmaring *ring,
1181 1184
1182 header = &(ring->txhdr_cache[slot * sizeof( 1185 header = &(ring->txhdr_cache[slot * sizeof(
1183 struct b43legacy_txhdr_fw3)]); 1186 struct b43legacy_txhdr_fw3)]);
1184 b43legacy_generate_txhdr(ring->dev, header, 1187 err = b43legacy_generate_txhdr(ring->dev, header,
1185 skb->data, skb->len, ctl, 1188 skb->data, skb->len, ctl,
1186 generate_cookie(ring, slot)); 1189 generate_cookie(ring, slot));
1190 if (unlikely(err)) {
1191 ring->current_slot = old_top_slot;
1192 ring->used_slots = old_used_slots;
1193 return err;
1194 }
1187 1195
1188 meta_hdr->dmaaddr = map_descbuffer(ring, (unsigned char *)header, 1196 meta_hdr->dmaaddr = map_descbuffer(ring, (unsigned char *)header,
1189 sizeof(struct b43legacy_txhdr_fw3), 1); 1197 sizeof(struct b43legacy_txhdr_fw3), 1);
@@ -1206,6 +1214,8 @@ static int dma_tx_fragment(struct b43legacy_dmaring *ring,
1206 if (dma_mapping_error(meta->dmaaddr)) { 1214 if (dma_mapping_error(meta->dmaaddr)) {
1207 bounce_skb = __dev_alloc_skb(skb->len, GFP_ATOMIC | GFP_DMA); 1215 bounce_skb = __dev_alloc_skb(skb->len, GFP_ATOMIC | GFP_DMA);
1208 if (!bounce_skb) { 1216 if (!bounce_skb) {
1217 ring->current_slot = old_top_slot;
1218 ring->used_slots = old_used_slots;
1209 err = -ENOMEM; 1219 err = -ENOMEM;
1210 goto out_unmap_hdr; 1220 goto out_unmap_hdr;
1211 } 1221 }
@@ -1216,6 +1226,8 @@ static int dma_tx_fragment(struct b43legacy_dmaring *ring,
1216 meta->skb = skb; 1226 meta->skb = skb;
1217 meta->dmaaddr = map_descbuffer(ring, skb->data, skb->len, 1); 1227 meta->dmaaddr = map_descbuffer(ring, skb->data, skb->len, 1);
1218 if (dma_mapping_error(meta->dmaaddr)) { 1228 if (dma_mapping_error(meta->dmaaddr)) {
1229 ring->current_slot = old_top_slot;
1230 ring->used_slots = old_used_slots;
1219 err = -EIO; 1231 err = -EIO;
1220 goto out_free_bounce; 1232 goto out_free_bounce;
1221 } 1233 }
@@ -1282,6 +1294,13 @@ int b43legacy_dma_tx(struct b43legacy_wldev *dev,
1282 B43legacy_BUG_ON(ring->stopped); 1294 B43legacy_BUG_ON(ring->stopped);
1283 1295
1284 err = dma_tx_fragment(ring, skb, ctl); 1296 err = dma_tx_fragment(ring, skb, ctl);
1297 if (unlikely(err == -ENOKEY)) {
1298 /* Drop this packet, as we don't have the encryption key
1299 * anymore and must not transmit it unencrypted. */
1300 dev_kfree_skb_any(skb);
1301 err = 0;
1302 goto out_unlock;
1303 }
1285 if (unlikely(err)) { 1304 if (unlikely(err)) {
1286 b43legacyerr(dev->wl, "DMA tx mapping failure\n"); 1305 b43legacyerr(dev->wl, "DMA tx mapping failure\n");
1287 goto out_unlock; 1306 goto out_unlock;
diff --git a/drivers/net/wireless/b43legacy/main.c b/drivers/net/wireless/b43legacy/main.c
index aa20d5d56e2f..53f7f2e97615 100644
--- a/drivers/net/wireless/b43legacy/main.c
+++ b/drivers/net/wireless/b43legacy/main.c
@@ -3160,8 +3160,6 @@ static int b43legacy_wireless_core_init(struct b43legacy_wldev *dev)
3160 b43legacy_shm_write16(dev, B43legacy_SHM_SHARED, 0x0414, 0x01F4); 3160 b43legacy_shm_write16(dev, B43legacy_SHM_SHARED, 0x0414, 0x01F4);
3161 3161
3162 ssb_bus_powerup(bus, 1); /* Enable dynamic PCTL */ 3162 ssb_bus_powerup(bus, 1); /* Enable dynamic PCTL */
3163 memset(wl->bssid, 0, ETH_ALEN);
3164 memset(wl->mac_addr, 0, ETH_ALEN);
3165 b43legacy_upload_card_macaddress(dev); 3163 b43legacy_upload_card_macaddress(dev);
3166 b43legacy_security_init(dev); 3164 b43legacy_security_init(dev);
3167 b43legacy_rng_init(wl); 3165 b43legacy_rng_init(wl);
@@ -3263,6 +3261,13 @@ static int b43legacy_op_start(struct ieee80211_hw *hw)
3263 * LEDs that are registered later depend on it. */ 3261 * LEDs that are registered later depend on it. */
3264 b43legacy_rfkill_init(dev); 3262 b43legacy_rfkill_init(dev);
3265 3263
3264 /* Kill all old instance specific information to make sure
3265 * the card won't use it in the short timeframe between start
3266 * and mac80211 reconfiguring it. */
3267 memset(wl->bssid, 0, ETH_ALEN);
3268 memset(wl->mac_addr, 0, ETH_ALEN);
3269 wl->filter_flags = 0;
3270
3266 mutex_lock(&wl->mutex); 3271 mutex_lock(&wl->mutex);
3267 3272
3268 if (b43legacy_status(dev) < B43legacy_STAT_INITIALIZED) { 3273 if (b43legacy_status(dev) < B43legacy_STAT_INITIALIZED) {
diff --git a/drivers/net/wireless/b43legacy/pio.c b/drivers/net/wireless/b43legacy/pio.c
index e4f4c5c39e33..bcdd54eb2edb 100644
--- a/drivers/net/wireless/b43legacy/pio.c
+++ b/drivers/net/wireless/b43legacy/pio.c
@@ -181,7 +181,7 @@ union txhdr_union {
181 struct b43legacy_txhdr_fw3 txhdr_fw3; 181 struct b43legacy_txhdr_fw3 txhdr_fw3;
182}; 182};
183 183
184static void pio_tx_write_fragment(struct b43legacy_pioqueue *queue, 184static int pio_tx_write_fragment(struct b43legacy_pioqueue *queue,
185 struct sk_buff *skb, 185 struct sk_buff *skb,
186 struct b43legacy_pio_txpacket *packet, 186 struct b43legacy_pio_txpacket *packet,
187 size_t txhdr_size) 187 size_t txhdr_size)
@@ -189,14 +189,17 @@ static void pio_tx_write_fragment(struct b43legacy_pioqueue *queue,
189 union txhdr_union txhdr_data; 189 union txhdr_union txhdr_data;
190 u8 *txhdr = NULL; 190 u8 *txhdr = NULL;
191 unsigned int octets; 191 unsigned int octets;
192 int err;
192 193
193 txhdr = (u8 *)(&txhdr_data.txhdr_fw3); 194 txhdr = (u8 *)(&txhdr_data.txhdr_fw3);
194 195
195 B43legacy_WARN_ON(skb_shinfo(skb)->nr_frags != 0); 196 B43legacy_WARN_ON(skb_shinfo(skb)->nr_frags != 0);
196 b43legacy_generate_txhdr(queue->dev, 197 err = b43legacy_generate_txhdr(queue->dev,
197 txhdr, skb->data, skb->len, 198 txhdr, skb->data, skb->len,
198 &packet->txstat.control, 199 &packet->txstat.control,
199 generate_cookie(queue, packet)); 200 generate_cookie(queue, packet));
201 if (err)
202 return err;
200 203
201 tx_start(queue); 204 tx_start(queue);
202 octets = skb->len + txhdr_size; 205 octets = skb->len + txhdr_size;
@@ -204,6 +207,8 @@ static void pio_tx_write_fragment(struct b43legacy_pioqueue *queue,
204 octets--; 207 octets--;
205 tx_data(queue, txhdr, (u8 *)skb->data, octets); 208 tx_data(queue, txhdr, (u8 *)skb->data, octets);
206 tx_complete(queue, skb); 209 tx_complete(queue, skb);
210
211 return 0;
207} 212}
208 213
209static void free_txpacket(struct b43legacy_pio_txpacket *packet, 214static void free_txpacket(struct b43legacy_pio_txpacket *packet,
@@ -226,6 +231,7 @@ static int pio_tx_packet(struct b43legacy_pio_txpacket *packet)
226 struct b43legacy_pioqueue *queue = packet->queue; 231 struct b43legacy_pioqueue *queue = packet->queue;
227 struct sk_buff *skb = packet->skb; 232 struct sk_buff *skb = packet->skb;
228 u16 octets; 233 u16 octets;
234 int err;
229 235
230 octets = (u16)skb->len + sizeof(struct b43legacy_txhdr_fw3); 236 octets = (u16)skb->len + sizeof(struct b43legacy_txhdr_fw3);
231 if (queue->tx_devq_size < octets) { 237 if (queue->tx_devq_size < octets) {
@@ -247,8 +253,14 @@ static int pio_tx_packet(struct b43legacy_pio_txpacket *packet)
247 if (queue->tx_devq_used + octets > queue->tx_devq_size) 253 if (queue->tx_devq_used + octets > queue->tx_devq_size)
248 return -EBUSY; 254 return -EBUSY;
249 /* Now poke the device. */ 255 /* Now poke the device. */
250 pio_tx_write_fragment(queue, skb, packet, 256 err = pio_tx_write_fragment(queue, skb, packet,
251 sizeof(struct b43legacy_txhdr_fw3)); 257 sizeof(struct b43legacy_txhdr_fw3));
258 if (unlikely(err == -ENOKEY)) {
259 /* Drop this packet, as we don't have the encryption key
260 * anymore and must not transmit it unencrypted. */
261 free_txpacket(packet, 1);
262 return 0;
263 }
252 264
253 /* Account for the packet size. 265 /* Account for the packet size.
254 * (We must not overflow the device TX queue) 266 * (We must not overflow the device TX queue)
@@ -486,6 +498,9 @@ void b43legacy_pio_handle_txstatus(struct b43legacy_wldev *dev,
486 queue = parse_cookie(dev, status->cookie, &packet); 498 queue = parse_cookie(dev, status->cookie, &packet);
487 B43legacy_WARN_ON(!queue); 499 B43legacy_WARN_ON(!queue);
488 500
501 if (!packet->skb)
502 return;
503
489 queue->tx_devq_packets--; 504 queue->tx_devq_packets--;
490 queue->tx_devq_used -= (packet->skb->len + 505 queue->tx_devq_used -= (packet->skb->len +
491 sizeof(struct b43legacy_txhdr_fw3)); 506 sizeof(struct b43legacy_txhdr_fw3));
diff --git a/drivers/net/wireless/b43legacy/xmit.c b/drivers/net/wireless/b43legacy/xmit.c
index e20c552442d5..d84408a82db9 100644
--- a/drivers/net/wireless/b43legacy/xmit.c
+++ b/drivers/net/wireless/b43legacy/xmit.c
@@ -181,7 +181,7 @@ static u8 b43legacy_calc_fallback_rate(u8 bitrate)
181 return 0; 181 return 0;
182} 182}
183 183
184static void generate_txhdr_fw3(struct b43legacy_wldev *dev, 184static int generate_txhdr_fw3(struct b43legacy_wldev *dev,
185 struct b43legacy_txhdr_fw3 *txhdr, 185 struct b43legacy_txhdr_fw3 *txhdr,
186 const unsigned char *fragment_data, 186 const unsigned char *fragment_data,
187 unsigned int fragment_len, 187 unsigned int fragment_len,
@@ -252,6 +252,13 @@ static void generate_txhdr_fw3(struct b43legacy_wldev *dev,
252 iv_len = min((size_t)txctl->iv_len, 252 iv_len = min((size_t)txctl->iv_len,
253 ARRAY_SIZE(txhdr->iv)); 253 ARRAY_SIZE(txhdr->iv));
254 memcpy(txhdr->iv, ((u8 *)wlhdr) + wlhdr_len, iv_len); 254 memcpy(txhdr->iv, ((u8 *)wlhdr) + wlhdr_len, iv_len);
255 } else {
256 /* This key is invalid. This might only happen
257 * in a short timeframe after machine resume before
258 * we were able to reconfigure keys.
259 * Drop this packet completely. Do not transmit it
260 * unencrypted to avoid leaking information. */
261 return -ENOKEY;
255 } 262 }
256 } 263 }
257 b43legacy_generate_plcp_hdr((struct b43legacy_plcp_hdr4 *) 264 b43legacy_generate_plcp_hdr((struct b43legacy_plcp_hdr4 *)
@@ -345,16 +352,18 @@ static void generate_txhdr_fw3(struct b43legacy_wldev *dev,
345 /* Apply the bitfields */ 352 /* Apply the bitfields */
346 txhdr->mac_ctl = cpu_to_le32(mac_ctl); 353 txhdr->mac_ctl = cpu_to_le32(mac_ctl);
347 txhdr->phy_ctl = cpu_to_le16(phy_ctl); 354 txhdr->phy_ctl = cpu_to_le16(phy_ctl);
355
356 return 0;
348} 357}
349 358
350void b43legacy_generate_txhdr(struct b43legacy_wldev *dev, 359int b43legacy_generate_txhdr(struct b43legacy_wldev *dev,
351 u8 *txhdr, 360 u8 *txhdr,
352 const unsigned char *fragment_data, 361 const unsigned char *fragment_data,
353 unsigned int fragment_len, 362 unsigned int fragment_len,
354 const struct ieee80211_tx_control *txctl, 363 const struct ieee80211_tx_control *txctl,
355 u16 cookie) 364 u16 cookie)
356{ 365{
357 generate_txhdr_fw3(dev, (struct b43legacy_txhdr_fw3 *)txhdr, 366 return generate_txhdr_fw3(dev, (struct b43legacy_txhdr_fw3 *)txhdr,
358 fragment_data, fragment_len, 367 fragment_data, fragment_len,
359 txctl, cookie); 368 txctl, cookie);
360} 369}
diff --git a/drivers/net/wireless/b43legacy/xmit.h b/drivers/net/wireless/b43legacy/xmit.h
index 8a155d0a5d1f..bab47928a0c9 100644
--- a/drivers/net/wireless/b43legacy/xmit.h
+++ b/drivers/net/wireless/b43legacy/xmit.h
@@ -76,7 +76,7 @@ struct b43legacy_txhdr_fw3 {
76 76
77 77
78 78
79void b43legacy_generate_txhdr(struct b43legacy_wldev *dev, 79int b43legacy_generate_txhdr(struct b43legacy_wldev *dev,
80 u8 *txhdr, 80 u8 *txhdr,
81 const unsigned char *fragment_data, 81 const unsigned char *fragment_data,
82 unsigned int fragment_len, 82 unsigned int fragment_len,
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index f55c75712b55..5ee1ad69898b 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -4207,13 +4207,13 @@ static u8 ratio2dB[100] = {
4207 * Conversion assumes that levels are voltages (20*log), not powers (10*log). */ 4207 * Conversion assumes that levels are voltages (20*log), not powers (10*log). */
4208int iwl3945_calc_db_from_ratio(int sig_ratio) 4208int iwl3945_calc_db_from_ratio(int sig_ratio)
4209{ 4209{
4210 /* Anything above 1000:1 just report as 60 dB */ 4210 /* 1000:1 or higher just report as 60 dB */
4211 if (sig_ratio > 1000) 4211 if (sig_ratio >= 1000)
4212 return 60; 4212 return 60;
4213 4213
4214 /* Above 100:1, divide by 10 and use table, 4214 /* 100:1 or higher, divide by 10 and use table,
4215 * add 20 dB to make up for divide by 10 */ 4215 * add 20 dB to make up for divide by 10 */
4216 if (sig_ratio > 100) 4216 if (sig_ratio >= 100)
4217 return (20 + (int)ratio2dB[sig_ratio/10]); 4217 return (20 + (int)ratio2dB[sig_ratio/10]);
4218 4218
4219 /* We shouldn't see this */ 4219 /* We shouldn't see this */
diff --git a/include/linux/ssb/ssb.h b/include/linux/ssb/ssb.h
index e18f5c23b930..9d5da8b2ccf9 100644
--- a/include/linux/ssb/ssb.h
+++ b/include/linux/ssb/ssb.h
@@ -373,6 +373,15 @@ void ssb_pcihost_set_power_state(struct ssb_device *sdev, pci_power_t state)
373 if (sdev->bus->bustype == SSB_BUSTYPE_PCI) 373 if (sdev->bus->bustype == SSB_BUSTYPE_PCI)
374 pci_set_power_state(sdev->bus->host_pci, state); 374 pci_set_power_state(sdev->bus->host_pci, state);
375} 375}
376#else
377static inline void ssb_pcihost_unregister(struct pci_driver *driver)
378{
379}
380
381static inline
382void ssb_pcihost_set_power_state(struct ssb_device *sdev, pci_power_t state)
383{
384}
376#endif /* CONFIG_SSB_PCIHOST */ 385#endif /* CONFIG_SSB_PCIHOST */
377 386
378 387
diff --git a/net/mac80211/Kconfig b/net/mac80211/Kconfig
index e77592d050ce..45c7c0c3875e 100644
--- a/net/mac80211/Kconfig
+++ b/net/mac80211/Kconfig
@@ -1,6 +1,5 @@
1config MAC80211 1config MAC80211
2 tristate "Generic IEEE 802.11 Networking Stack (mac80211)" 2 tristate "Generic IEEE 802.11 Networking Stack (mac80211)"
3 depends on EXPERIMENTAL
4 select CRYPTO 3 select CRYPTO
5 select CRYPTO_ECB 4 select CRYPTO_ECB
6 select CRYPTO_ARC4 5 select CRYPTO_ARC4