diff options
author | Felix Fietkau <nbd@openwrt.org> | 2010-12-02 04:26:51 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2010-12-02 15:17:50 -0500 |
commit | aeae4ac9090462ea38387dcdbac4f01b944af6a4 (patch) | |
tree | 4996bb7bbc0f3342a19b88437688b2be46270045 | |
parent | c30ae138aa0570665725166679bdf4207041c8df (diff) |
ath5k: Use Generic DMA for later support of AHB bus.
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: Wojciech Dubowik <Wojciech.Dubowik@neratec.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r-- | drivers/net/wireless/ath/ath5k/base.c | 66 | ||||
-rw-r--r-- | drivers/net/wireless/ath/ath5k/base.h | 4 |
2 files changed, 39 insertions, 31 deletions
diff --git a/drivers/net/wireless/ath/ath5k/base.c b/drivers/net/wireless/ath/ath5k/base.c index a8d380aae658..2d7d8bac4610 100644 --- a/drivers/net/wireless/ath/ath5k/base.c +++ b/drivers/net/wireless/ath/ath5k/base.c | |||
@@ -198,8 +198,8 @@ static inline void ath5k_txbuf_free_skb(struct ath5k_softc *sc, | |||
198 | BUG_ON(!bf); | 198 | BUG_ON(!bf); |
199 | if (!bf->skb) | 199 | if (!bf->skb) |
200 | return; | 200 | return; |
201 | pci_unmap_single(sc->pdev, bf->skbaddr, bf->skb->len, | 201 | dma_unmap_single(sc->dev, bf->skbaddr, bf->skb->len, |
202 | PCI_DMA_TODEVICE); | 202 | DMA_TO_DEVICE); |
203 | dev_kfree_skb_any(bf->skb); | 203 | dev_kfree_skb_any(bf->skb); |
204 | bf->skb = NULL; | 204 | bf->skb = NULL; |
205 | bf->skbaddr = 0; | 205 | bf->skbaddr = 0; |
@@ -215,8 +215,8 @@ static inline void ath5k_rxbuf_free_skb(struct ath5k_softc *sc, | |||
215 | BUG_ON(!bf); | 215 | BUG_ON(!bf); |
216 | if (!bf->skb) | 216 | if (!bf->skb) |
217 | return; | 217 | return; |
218 | pci_unmap_single(sc->pdev, bf->skbaddr, common->rx_bufsize, | 218 | dma_unmap_single(sc->dev, bf->skbaddr, common->rx_bufsize, |
219 | PCI_DMA_FROMDEVICE); | 219 | DMA_FROM_DEVICE); |
220 | dev_kfree_skb_any(bf->skb); | 220 | dev_kfree_skb_any(bf->skb); |
221 | bf->skb = NULL; | 221 | bf->skb = NULL; |
222 | bf->skbaddr = 0; | 222 | bf->skbaddr = 0; |
@@ -647,10 +647,11 @@ struct sk_buff *ath5k_rx_skb_alloc(struct ath5k_softc *sc, dma_addr_t *skb_addr) | |||
647 | return NULL; | 647 | return NULL; |
648 | } | 648 | } |
649 | 649 | ||
650 | *skb_addr = pci_map_single(sc->pdev, | 650 | *skb_addr = dma_map_single(sc->dev, |
651 | skb->data, common->rx_bufsize, | 651 | skb->data, common->rx_bufsize, |
652 | PCI_DMA_FROMDEVICE); | 652 | DMA_FROM_DEVICE); |
653 | if (unlikely(pci_dma_mapping_error(sc->pdev, *skb_addr))) { | 653 | |
654 | if (unlikely(dma_mapping_error(sc->dev, *skb_addr))) { | ||
654 | ATH5K_ERR(sc, "%s: DMA mapping failed\n", __func__); | 655 | ATH5K_ERR(sc, "%s: DMA mapping failed\n", __func__); |
655 | dev_kfree_skb(skb); | 656 | dev_kfree_skb(skb); |
656 | return NULL; | 657 | return NULL; |
@@ -746,8 +747,8 @@ ath5k_txbuf_setup(struct ath5k_softc *sc, struct ath5k_buf *bf, | |||
746 | flags = AR5K_TXDESC_INTREQ | AR5K_TXDESC_CLRDMASK; | 747 | flags = AR5K_TXDESC_INTREQ | AR5K_TXDESC_CLRDMASK; |
747 | 748 | ||
748 | /* XXX endianness */ | 749 | /* XXX endianness */ |
749 | bf->skbaddr = pci_map_single(sc->pdev, skb->data, skb->len, | 750 | bf->skbaddr = dma_map_single(sc->dev, skb->data, skb->len, |
750 | PCI_DMA_TODEVICE); | 751 | DMA_TO_DEVICE); |
751 | 752 | ||
752 | rate = ieee80211_get_tx_rate(sc->hw, info); | 753 | rate = ieee80211_get_tx_rate(sc->hw, info); |
753 | if (!rate) { | 754 | if (!rate) { |
@@ -827,7 +828,7 @@ ath5k_txbuf_setup(struct ath5k_softc *sc, struct ath5k_buf *bf, | |||
827 | 828 | ||
828 | return 0; | 829 | return 0; |
829 | err_unmap: | 830 | err_unmap: |
830 | pci_unmap_single(sc->pdev, bf->skbaddr, skb->len, PCI_DMA_TODEVICE); | 831 | dma_unmap_single(sc->dev, bf->skbaddr, skb->len, DMA_TO_DEVICE); |
831 | return ret; | 832 | return ret; |
832 | } | 833 | } |
833 | 834 | ||
@@ -836,7 +837,7 @@ err_unmap: | |||
836 | \*******************/ | 837 | \*******************/ |
837 | 838 | ||
838 | static int | 839 | static int |
839 | ath5k_desc_alloc(struct ath5k_softc *sc, struct pci_dev *pdev) | 840 | ath5k_desc_alloc(struct ath5k_softc *sc) |
840 | { | 841 | { |
841 | struct ath5k_desc *ds; | 842 | struct ath5k_desc *ds; |
842 | struct ath5k_buf *bf; | 843 | struct ath5k_buf *bf; |
@@ -847,7 +848,9 @@ ath5k_desc_alloc(struct ath5k_softc *sc, struct pci_dev *pdev) | |||
847 | /* allocate descriptors */ | 848 | /* allocate descriptors */ |
848 | sc->desc_len = sizeof(struct ath5k_desc) * | 849 | sc->desc_len = sizeof(struct ath5k_desc) * |
849 | (ATH_TXBUF + ATH_RXBUF + ATH_BCBUF + 1); | 850 | (ATH_TXBUF + ATH_RXBUF + ATH_BCBUF + 1); |
850 | sc->desc = pci_alloc_consistent(pdev, sc->desc_len, &sc->desc_daddr); | 851 | |
852 | sc->desc = dma_alloc_coherent(sc->dev, sc->desc_len, | ||
853 | &sc->desc_daddr, GFP_KERNEL); | ||
851 | if (sc->desc == NULL) { | 854 | if (sc->desc == NULL) { |
852 | ATH5K_ERR(sc, "can't allocate descriptors\n"); | 855 | ATH5K_ERR(sc, "can't allocate descriptors\n"); |
853 | ret = -ENOMEM; | 856 | ret = -ENOMEM; |
@@ -893,14 +896,14 @@ ath5k_desc_alloc(struct ath5k_softc *sc, struct pci_dev *pdev) | |||
893 | 896 | ||
894 | return 0; | 897 | return 0; |
895 | err_free: | 898 | err_free: |
896 | pci_free_consistent(pdev, sc->desc_len, sc->desc, sc->desc_daddr); | 899 | dma_free_coherent(sc->dev, sc->desc_len, sc->desc, sc->desc_daddr); |
897 | err: | 900 | err: |
898 | sc->desc = NULL; | 901 | sc->desc = NULL; |
899 | return ret; | 902 | return ret; |
900 | } | 903 | } |
901 | 904 | ||
902 | static void | 905 | static void |
903 | ath5k_desc_free(struct ath5k_softc *sc, struct pci_dev *pdev) | 906 | ath5k_desc_free(struct ath5k_softc *sc) |
904 | { | 907 | { |
905 | struct ath5k_buf *bf; | 908 | struct ath5k_buf *bf; |
906 | 909 | ||
@@ -912,7 +915,7 @@ ath5k_desc_free(struct ath5k_softc *sc, struct pci_dev *pdev) | |||
912 | ath5k_txbuf_free_skb(sc, bf); | 915 | ath5k_txbuf_free_skb(sc, bf); |
913 | 916 | ||
914 | /* Free memory associated with all descriptors */ | 917 | /* Free memory associated with all descriptors */ |
915 | pci_free_consistent(pdev, sc->desc_len, sc->desc, sc->desc_daddr); | 918 | dma_free_coherent(sc->dev, sc->desc_len, sc->desc, sc->desc_daddr); |
916 | sc->desc = NULL; | 919 | sc->desc = NULL; |
917 | sc->desc_daddr = 0; | 920 | sc->desc_daddr = 0; |
918 | 921 | ||
@@ -1523,9 +1526,9 @@ ath5k_tasklet_rx(unsigned long data) | |||
1523 | if (!next_skb) | 1526 | if (!next_skb) |
1524 | goto next; | 1527 | goto next; |
1525 | 1528 | ||
1526 | pci_unmap_single(sc->pdev, bf->skbaddr, | 1529 | dma_unmap_single(sc->dev, bf->skbaddr, |
1527 | common->rx_bufsize, | 1530 | common->rx_bufsize, |
1528 | PCI_DMA_FROMDEVICE); | 1531 | DMA_FROM_DEVICE); |
1529 | 1532 | ||
1530 | skb_put(skb, rs.rs_datalen); | 1533 | skb_put(skb, rs.rs_datalen); |
1531 | 1534 | ||
@@ -1688,8 +1691,9 @@ ath5k_tx_processq(struct ath5k_softc *sc, struct ath5k_txq *txq) | |||
1688 | 1691 | ||
1689 | skb = bf->skb; | 1692 | skb = bf->skb; |
1690 | bf->skb = NULL; | 1693 | bf->skb = NULL; |
1691 | pci_unmap_single(sc->pdev, bf->skbaddr, skb->len, | 1694 | |
1692 | PCI_DMA_TODEVICE); | 1695 | dma_unmap_single(sc->dev, bf->skbaddr, skb->len, |
1696 | DMA_TO_DEVICE); | ||
1693 | ath5k_tx_frame_completed(sc, skb, &ts); | 1697 | ath5k_tx_frame_completed(sc, skb, &ts); |
1694 | } | 1698 | } |
1695 | 1699 | ||
@@ -1743,12 +1747,13 @@ ath5k_beacon_setup(struct ath5k_softc *sc, struct ath5k_buf *bf) | |||
1743 | u32 flags; | 1747 | u32 flags; |
1744 | const int padsize = 0; | 1748 | const int padsize = 0; |
1745 | 1749 | ||
1746 | bf->skbaddr = pci_map_single(sc->pdev, skb->data, skb->len, | 1750 | bf->skbaddr = dma_map_single(sc->dev, skb->data, skb->len, |
1747 | PCI_DMA_TODEVICE); | 1751 | DMA_TO_DEVICE); |
1748 | ATH5K_DBG(sc, ATH5K_DEBUG_BEACON, "skb %p [data %p len %u] " | 1752 | ATH5K_DBG(sc, ATH5K_DEBUG_BEACON, "skb %p [data %p len %u] " |
1749 | "skbaddr %llx\n", skb, skb->data, skb->len, | 1753 | "skbaddr %llx\n", skb, skb->data, skb->len, |
1750 | (unsigned long long)bf->skbaddr); | 1754 | (unsigned long long)bf->skbaddr); |
1751 | if (pci_dma_mapping_error(sc->pdev, bf->skbaddr)) { | 1755 | |
1756 | if (dma_mapping_error(sc->dev, bf->skbaddr)) { | ||
1752 | ATH5K_ERR(sc, "beacon DMA mapping failed\n"); | 1757 | ATH5K_ERR(sc, "beacon DMA mapping failed\n"); |
1753 | return -EIO; | 1758 | return -EIO; |
1754 | } | 1759 | } |
@@ -1800,7 +1805,7 @@ ath5k_beacon_setup(struct ath5k_softc *sc, struct ath5k_buf *bf) | |||
1800 | 1805 | ||
1801 | return 0; | 1806 | return 0; |
1802 | err_unmap: | 1807 | err_unmap: |
1803 | pci_unmap_single(sc->pdev, bf->skbaddr, skb->len, PCI_DMA_TODEVICE); | 1808 | dma_unmap_single(sc->dev, bf->skbaddr, skb->len, DMA_TO_DEVICE); |
1804 | return ret; | 1809 | return ret; |
1805 | } | 1810 | } |
1806 | 1811 | ||
@@ -2361,7 +2366,7 @@ ath5k_stop_locked(struct ath5k_softc *sc) | |||
2361 | if (!test_bit(ATH_STAT_INVALID, sc->status)) { | 2366 | if (!test_bit(ATH_STAT_INVALID, sc->status)) { |
2362 | ath5k_led_off(sc); | 2367 | ath5k_led_off(sc); |
2363 | ath5k_hw_set_imr(ah, 0); | 2368 | ath5k_hw_set_imr(ah, 0); |
2364 | synchronize_irq(sc->pdev->irq); | 2369 | synchronize_irq(sc->irq); |
2365 | ath5k_rx_stop(sc); | 2370 | ath5k_rx_stop(sc); |
2366 | ath5k_hw_dma_stop(ah); | 2371 | ath5k_hw_dma_stop(ah); |
2367 | ath5k_drain_tx_buffs(sc); | 2372 | ath5k_drain_tx_buffs(sc); |
@@ -2509,7 +2514,7 @@ ath5k_reset(struct ath5k_softc *sc, struct ieee80211_channel *chan, | |||
2509 | ATH5K_DBG(sc, ATH5K_DEBUG_RESET, "resetting\n"); | 2514 | ATH5K_DBG(sc, ATH5K_DEBUG_RESET, "resetting\n"); |
2510 | 2515 | ||
2511 | ath5k_hw_set_imr(ah, 0); | 2516 | ath5k_hw_set_imr(ah, 0); |
2512 | synchronize_irq(sc->pdev->irq); | 2517 | synchronize_irq(sc->irq); |
2513 | stop_tasklets(sc); | 2518 | stop_tasklets(sc); |
2514 | 2519 | ||
2515 | if (chan) { | 2520 | if (chan) { |
@@ -2616,7 +2621,7 @@ ath5k_attach(struct pci_dev *pdev, struct ieee80211_hw *hw) | |||
2616 | /* | 2621 | /* |
2617 | * Allocate tx+rx descriptors and populate the lists. | 2622 | * Allocate tx+rx descriptors and populate the lists. |
2618 | */ | 2623 | */ |
2619 | ret = ath5k_desc_alloc(sc, pdev); | 2624 | ret = ath5k_desc_alloc(sc); |
2620 | if (ret) { | 2625 | if (ret) { |
2621 | ATH5K_ERR(sc, "can't allocate descriptors\n"); | 2626 | ATH5K_ERR(sc, "can't allocate descriptors\n"); |
2622 | goto err; | 2627 | goto err; |
@@ -2680,8 +2685,7 @@ ath5k_attach(struct pci_dev *pdev, struct ieee80211_hw *hw) | |||
2680 | 2685 | ||
2681 | ret = ath5k_eeprom_read_mac(ah, mac); | 2686 | ret = ath5k_eeprom_read_mac(ah, mac); |
2682 | if (ret) { | 2687 | if (ret) { |
2683 | ATH5K_ERR(sc, "unable to read address from EEPROM: 0x%04x\n", | 2688 | ATH5K_ERR(sc, "unable to read address from EEPROM\n"); |
2684 | sc->pdev->device); | ||
2685 | goto err_queues; | 2689 | goto err_queues; |
2686 | } | 2690 | } |
2687 | 2691 | ||
@@ -2716,7 +2720,7 @@ err_queues: | |||
2716 | err_bhal: | 2720 | err_bhal: |
2717 | ath5k_hw_release_tx_queue(ah, sc->bhalq); | 2721 | ath5k_hw_release_tx_queue(ah, sc->bhalq); |
2718 | err_desc: | 2722 | err_desc: |
2719 | ath5k_desc_free(sc, pdev); | 2723 | ath5k_desc_free(sc); |
2720 | err: | 2724 | err: |
2721 | return ret; | 2725 | return ret; |
2722 | } | 2726 | } |
@@ -2740,7 +2744,7 @@ ath5k_detach(struct pci_dev *pdev, struct ieee80211_hw *hw) | |||
2740 | * Other than that, it's straightforward... | 2744 | * Other than that, it's straightforward... |
2741 | */ | 2745 | */ |
2742 | ieee80211_unregister_hw(hw); | 2746 | ieee80211_unregister_hw(hw); |
2743 | ath5k_desc_free(sc, pdev); | 2747 | ath5k_desc_free(sc); |
2744 | ath5k_txq_release(sc); | 2748 | ath5k_txq_release(sc); |
2745 | ath5k_hw_release_tx_queue(sc->ah, sc->bhalq); | 2749 | ath5k_hw_release_tx_queue(sc->ah, sc->bhalq); |
2746 | ath5k_unregister_leds(sc); | 2750 | ath5k_unregister_leds(sc); |
@@ -3565,6 +3569,8 @@ ath5k_pci_probe(struct pci_dev *pdev, | |||
3565 | sc = hw->priv; | 3569 | sc = hw->priv; |
3566 | sc->hw = hw; | 3570 | sc->hw = hw; |
3567 | sc->pdev = pdev; | 3571 | sc->pdev = pdev; |
3572 | sc->dev = &pdev->dev; | ||
3573 | sc->irq = pdev->irq; | ||
3568 | 3574 | ||
3569 | /* | 3575 | /* |
3570 | * Mark the device as detached to avoid processing | 3576 | * Mark the device as detached to avoid processing |
diff --git a/drivers/net/wireless/ath/ath5k/base.h b/drivers/net/wireless/ath/ath5k/base.h index 9a79773cdc2a..0362f8eb9510 100644 --- a/drivers/net/wireless/ath/ath5k/base.h +++ b/drivers/net/wireless/ath/ath5k/base.h | |||
@@ -169,7 +169,9 @@ struct ath5k_vif { | |||
169 | /* Software Carrier, keeps track of the driver state | 169 | /* Software Carrier, keeps track of the driver state |
170 | * associated with an instance of a device */ | 170 | * associated with an instance of a device */ |
171 | struct ath5k_softc { | 171 | struct ath5k_softc { |
172 | struct pci_dev *pdev; /* for dma mapping */ | 172 | struct pci_dev *pdev; |
173 | struct device *dev; /* for dma mapping */ | ||
174 | int irq; | ||
173 | void __iomem *iobase; /* address of the device */ | 175 | void __iomem *iobase; /* address of the device */ |
174 | struct mutex lock; /* dev-level lock */ | 176 | struct mutex lock; /* dev-level lock */ |
175 | struct ieee80211_hw *hw; /* IEEE 802.11 common */ | 177 | struct ieee80211_hw *hw; /* IEEE 802.11 common */ |