1 From 4180ca5827fe3ac377a8a71fca955c99ad6a2b5b Mon Sep 17 00:00:00 2001
2 From: Gabor Juhos <juhosg@openwrt.org>
3 Date: Mon, 5 Jan 2009 10:50:30 +0100
4 Subject: [PATCH v3 02/11] ath9k: convert to use bus-agnostic DMA routines
6 Convert to use bus-agnostic DMA routines to make it usable on AHB bus as well.
8 Changes-licensed-under: ISC
10 Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
11 Signed-off-by: Imre Kaloz <kaloz@openwrt.org>
13 drivers/net/wireless/ath9k/beacon.c | 31 ++++++++++++++-----------------
14 drivers/net/wireless/ath9k/main.c | 13 ++++++-------
15 drivers/net/wireless/ath9k/recv.c | 27 ++++++++++++---------------
16 drivers/net/wireless/ath9k/xmit.c | 15 ++++++---------
17 4 files changed, 38 insertions(+), 48 deletions(-)
19 --- a/drivers/net/wireless/ath9k/beacon.c
20 +++ b/drivers/net/wireless/ath9k/beacon.c
21 @@ -164,9 +164,9 @@ static struct ath_buf *ath_beacon_genera
23 skb = (struct sk_buff *)bf->bf_mpdu;
25 - pci_unmap_single(to_pci_dev(sc->dev), bf->bf_dmacontext,
26 + dma_unmap_single(sc->dev, bf->bf_dmacontext,
30 dev_kfree_skb_any(skb);
33 @@ -188,15 +188,14 @@ static struct ath_buf *ath_beacon_genera
36 bf->bf_buf_addr = bf->bf_dmacontext =
37 - pci_map_single(to_pci_dev(sc->dev), skb->data,
38 + dma_map_single(sc->dev, skb->data,
41 - if (unlikely(pci_dma_mapping_error(to_pci_dev(sc->dev),
42 - bf->bf_buf_addr))) {
44 + if (unlikely(dma_mapping_error(sc->dev, bf->bf_buf_addr))) {
45 dev_kfree_skb_any(skb);
47 DPRINTF(sc, ATH_DBG_CONFIG,
48 - "pci_dma_mapping_error() on beaconing\n");
49 + "dma_mapping_error() on beaconing\n");
53 @@ -344,9 +343,9 @@ int ath_beacon_alloc(struct ath_softc *s
55 if (bf->bf_mpdu != NULL) {
56 skb = (struct sk_buff *)bf->bf_mpdu;
57 - pci_unmap_single(to_pci_dev(sc->dev), bf->bf_dmacontext,
58 + dma_unmap_single(sc->dev, bf->bf_dmacontext,
62 dev_kfree_skb_any(skb);
65 @@ -403,15 +402,14 @@ int ath_beacon_alloc(struct ath_softc *s
68 bf->bf_buf_addr = bf->bf_dmacontext =
69 - pci_map_single(to_pci_dev(sc->dev), skb->data,
70 + dma_map_single(sc->dev, skb->data,
73 - if (unlikely(pci_dma_mapping_error(to_pci_dev(sc->dev),
74 - bf->bf_buf_addr))) {
76 + if (unlikely(dma_mapping_error(sc->dev, bf->bf_buf_addr))) {
77 dev_kfree_skb_any(skb);
79 DPRINTF(sc, ATH_DBG_CONFIG,
80 - "pci_dma_mapping_error() on beacon alloc\n");
81 + "dma_mapping_error() on beacon alloc\n");
85 @@ -431,10 +429,9 @@ void ath_beacon_return(struct ath_softc
87 if (bf->bf_mpdu != NULL) {
88 struct sk_buff *skb = (struct sk_buff *)bf->bf_mpdu;
89 - pci_unmap_single(to_pci_dev(sc->dev),
91 + dma_unmap_single(sc->dev, bf->bf_dmacontext,
95 dev_kfree_skb_any(skb);
98 --- a/drivers/net/wireless/ath9k/main.c
99 +++ b/drivers/net/wireless/ath9k/main.c
100 @@ -1717,9 +1717,8 @@ int ath_descdma_setup(struct ath_softc *
103 /* allocate descriptors */
104 - dd->dd_desc = pci_alloc_consistent(to_pci_dev(sc->dev),
106 - &dd->dd_desc_paddr);
107 + dd->dd_desc = dma_alloc_coherent(sc->dev, dd->dd_desc_len,
108 + &dd->dd_desc_paddr, GFP_ATOMIC);
109 if (dd->dd_desc == NULL) {
112 @@ -1765,8 +1764,8 @@ int ath_descdma_setup(struct ath_softc *
116 - pci_free_consistent(to_pci_dev(sc->dev),
117 - dd->dd_desc_len, dd->dd_desc, dd->dd_desc_paddr);
118 + dma_free_coherent(sc->dev, dd->dd_desc_len, dd->dd_desc,
119 + dd->dd_desc_paddr);
121 memset(dd, 0, sizeof(*dd));
123 @@ -1779,8 +1778,8 @@ void ath_descdma_cleanup(struct ath_soft
124 struct ath_descdma *dd,
125 struct list_head *head)
127 - pci_free_consistent(to_pci_dev(sc->dev),
128 - dd->dd_desc_len, dd->dd_desc, dd->dd_desc_paddr);
129 + dma_free_coherent(sc->dev, dd->dd_desc_len, dd->dd_desc,
130 + dd->dd_desc_paddr);
132 INIT_LIST_HEAD(head);
133 kfree(dd->dd_bufptr);
134 --- a/drivers/net/wireless/ath9k/recv.c
135 +++ b/drivers/net/wireless/ath9k/recv.c
136 @@ -291,16 +291,15 @@ int ath_rx_init(struct ath_softc *sc, in
140 - bf->bf_buf_addr = pci_map_single(to_pci_dev(sc->dev),
142 + bf->bf_buf_addr = dma_map_single(sc->dev, skb->data,
144 - PCI_DMA_FROMDEVICE);
145 - if (unlikely(pci_dma_mapping_error(to_pci_dev(sc->dev),
147 + if (unlikely(dma_mapping_error(sc->dev,
149 dev_kfree_skb_any(skb);
151 DPRINTF(sc, ATH_DBG_CONFIG,
152 - "pci_dma_mapping_error() on RX init\n");
153 + "dma_mapping_error() on RX init\n");
157 @@ -525,10 +524,9 @@ int ath_rx_tasklet(struct ath_softc *sc,
158 * 1. accessing the frame
159 * 2. requeueing the same buffer to h/w
161 - pci_dma_sync_single_for_cpu(to_pci_dev(sc->dev),
163 + dma_sync_single_for_cpu(sc->dev, bf->bf_buf_addr,
165 - PCI_DMA_FROMDEVICE);
169 * If we're asked to flush receive queue, directly
170 @@ -559,9 +557,9 @@ int ath_rx_tasklet(struct ath_softc *sc,
173 /* Unmap the frame */
174 - pci_unmap_single(to_pci_dev(sc->dev), bf->bf_buf_addr,
175 + dma_unmap_single(sc->dev, bf->bf_buf_addr,
177 - PCI_DMA_FROMDEVICE);
180 skb_put(skb, ds->ds_rxstat.rs_datalen);
181 skb->protocol = cpu_to_be16(ETH_P_CONTROL);
182 @@ -607,16 +605,15 @@ int ath_rx_tasklet(struct ath_softc *sc,
184 /* We will now give hardware our shiny new allocated skb */
185 bf->bf_mpdu = requeue_skb;
186 - bf->bf_buf_addr = pci_map_single(to_pci_dev(sc->dev),
188 + bf->bf_buf_addr = dma_map_single(sc->dev, requeue_skb->data,
190 - PCI_DMA_FROMDEVICE);
191 - if (unlikely(pci_dma_mapping_error(to_pci_dev(sc->dev),
193 + if (unlikely(dma_mapping_error(sc->dev,
195 dev_kfree_skb_any(requeue_skb);
197 DPRINTF(sc, ATH_DBG_CONFIG,
198 - "pci_dma_mapping_error() on RX\n");
199 + "dma_mapping_error() on RX\n");
202 bf->bf_dmacontext = bf->bf_buf_addr;
203 --- a/drivers/net/wireless/ath9k/xmit.c
204 +++ b/drivers/net/wireless/ath9k/xmit.c
205 @@ -340,10 +340,8 @@ static void ath_tx_complete_buf(struct a
208 /* Unmap this frame */
209 - pci_unmap_single(to_pci_dev(sc->dev),
213 + dma_unmap_single(sc->dev, bf->bf_dmacontext, skb->len, DMA_TO_DEVICE);
215 /* complete this frame */
216 ath_tx_complete(sc, skb, &tx_status);
218 @@ -1716,13 +1714,12 @@ static int ath_tx_setup_buffer(struct at
222 - bf->bf_dmacontext = pci_map_single(to_pci_dev(sc->dev), skb->data,
223 - skb->len, PCI_DMA_TODEVICE);
224 - if (unlikely(pci_dma_mapping_error(to_pci_dev(sc->dev),
225 - bf->bf_dmacontext))) {
226 + bf->bf_dmacontext = dma_map_single(sc->dev, skb->data,
227 + skb->len, DMA_TO_DEVICE);
228 + if (unlikely(dma_mapping_error(sc->dev, bf->bf_dmacontext))) {
230 DPRINTF(sc, ATH_DBG_CONFIG,
231 - "pci_dma_mapping_error() on TX\n");
232 + "dma_mapping_error() on TX\n");