808c1116cf561af36a8ee3c0dc5c6a850452375e
[openwrt/svn-archive/archive.git] / package / mac80211 / patches / 402-ath9k-convert-to-use-bus-agnostic-DMA-routines.patch
1 From 57b901b5ceb401006a278bc1ad224f0ac88d4f08 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 v2 02/11] ath9k: convert to use bus-agnostic DMA routines
5
6 Convert to use bus-agnostic DMA routines to make it usable on AHB bus as well.
7
8 Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
9 Signed-off-by: Imre Kaloz <kaloz@openwrt.org>
10 ---
11 drivers/net/wireless/ath9k/beacon.c | 31 ++++++++++++++-----------------
12 drivers/net/wireless/ath9k/main.c | 13 ++++++-------
13 drivers/net/wireless/ath9k/recv.c | 27 ++++++++++++---------------
14 drivers/net/wireless/ath9k/xmit.c | 15 ++++++---------
15 4 files changed, 38 insertions(+), 48 deletions(-)
16
17 --- a/drivers/net/wireless/ath9k/beacon.c
18 +++ b/drivers/net/wireless/ath9k/beacon.c
19 @@ -164,9 +164,9 @@ static struct ath_buf *ath_beacon_genera
20 bf = avp->av_bcbuf;
21 skb = (struct sk_buff *)bf->bf_mpdu;
22 if (skb) {
23 - pci_unmap_single(to_pci_dev(sc->dev), bf->bf_dmacontext,
24 + dma_unmap_single(sc->dev, bf->bf_dmacontext,
25 skb->len,
26 - PCI_DMA_TODEVICE);
27 + DMA_TO_DEVICE);
28 dev_kfree_skb_any(skb);
29 }
30
31 @@ -188,15 +188,14 @@ static struct ath_buf *ath_beacon_genera
32 }
33
34 bf->bf_buf_addr = bf->bf_dmacontext =
35 - pci_map_single(to_pci_dev(sc->dev), skb->data,
36 + dma_map_single(sc->dev, skb->data,
37 skb->len,
38 - PCI_DMA_TODEVICE);
39 - if (unlikely(pci_dma_mapping_error(to_pci_dev(sc->dev),
40 - bf->bf_buf_addr))) {
41 + DMA_TO_DEVICE);
42 + if (unlikely(dma_mapping_error(sc->dev, bf->bf_buf_addr))) {
43 dev_kfree_skb_any(skb);
44 bf->bf_mpdu = NULL;
45 DPRINTF(sc, ATH_DBG_CONFIG,
46 - "pci_dma_mapping_error() on beaconing\n");
47 + "dma_mapping_error() on beaconing\n");
48 return NULL;
49 }
50
51 @@ -344,9 +343,9 @@ int ath_beacon_alloc(struct ath_softc *s
52 bf = avp->av_bcbuf;
53 if (bf->bf_mpdu != NULL) {
54 skb = (struct sk_buff *)bf->bf_mpdu;
55 - pci_unmap_single(to_pci_dev(sc->dev), bf->bf_dmacontext,
56 + dma_unmap_single(sc->dev, bf->bf_dmacontext,
57 skb->len,
58 - PCI_DMA_TODEVICE);
59 + DMA_TO_DEVICE);
60 dev_kfree_skb_any(skb);
61 bf->bf_mpdu = NULL;
62 }
63 @@ -403,15 +402,14 @@ int ath_beacon_alloc(struct ath_softc *s
64
65 bf->bf_mpdu = skb;
66 bf->bf_buf_addr = bf->bf_dmacontext =
67 - pci_map_single(to_pci_dev(sc->dev), skb->data,
68 + dma_map_single(sc->dev, skb->data,
69 skb->len,
70 - PCI_DMA_TODEVICE);
71 - if (unlikely(pci_dma_mapping_error(to_pci_dev(sc->dev),
72 - bf->bf_buf_addr))) {
73 + DMA_TO_DEVICE);
74 + if (unlikely(dma_mapping_error(sc->dev, bf->bf_buf_addr))) {
75 dev_kfree_skb_any(skb);
76 bf->bf_mpdu = NULL;
77 DPRINTF(sc, ATH_DBG_CONFIG,
78 - "pci_dma_mapping_error() on beacon alloc\n");
79 + "dma_mapping_error() on beacon alloc\n");
80 return -ENOMEM;
81 }
82
83 @@ -431,10 +429,9 @@ void ath_beacon_return(struct ath_softc
84 bf = avp->av_bcbuf;
85 if (bf->bf_mpdu != NULL) {
86 struct sk_buff *skb = (struct sk_buff *)bf->bf_mpdu;
87 - pci_unmap_single(to_pci_dev(sc->dev),
88 - bf->bf_dmacontext,
89 + dma_unmap_single(sc->dev, bf->bf_dmacontext,
90 skb->len,
91 - PCI_DMA_TODEVICE);
92 + DMA_TO_DEVICE);
93 dev_kfree_skb_any(skb);
94 bf->bf_mpdu = NULL;
95 }
96 --- a/drivers/net/wireless/ath9k/main.c
97 +++ b/drivers/net/wireless/ath9k/main.c
98 @@ -1717,9 +1717,8 @@ int ath_descdma_setup(struct ath_softc *
99 }
100
101 /* allocate descriptors */
102 - dd->dd_desc = pci_alloc_consistent(to_pci_dev(sc->dev),
103 - dd->dd_desc_len,
104 - &dd->dd_desc_paddr);
105 + dd->dd_desc = dma_alloc_coherent(sc->dev, dd->dd_desc_len,
106 + &dd->dd_desc_paddr, GFP_ATOMIC);
107 if (dd->dd_desc == NULL) {
108 error = -ENOMEM;
109 goto fail;
110 @@ -1765,8 +1764,8 @@ int ath_descdma_setup(struct ath_softc *
111 }
112 return 0;
113 fail2:
114 - pci_free_consistent(to_pci_dev(sc->dev),
115 - dd->dd_desc_len, dd->dd_desc, dd->dd_desc_paddr);
116 + dma_free_coherent(sc->dev, dd->dd_desc_len, dd->dd_desc,
117 + dd->dd_desc_paddr);
118 fail:
119 memset(dd, 0, sizeof(*dd));
120 return error;
121 @@ -1779,8 +1778,8 @@ void ath_descdma_cleanup(struct ath_soft
122 struct ath_descdma *dd,
123 struct list_head *head)
124 {
125 - pci_free_consistent(to_pci_dev(sc->dev),
126 - dd->dd_desc_len, dd->dd_desc, dd->dd_desc_paddr);
127 + dma_free_coherent(sc->dev, dd->dd_desc_len, dd->dd_desc,
128 + dd->dd_desc_paddr);
129
130 INIT_LIST_HEAD(head);
131 kfree(dd->dd_bufptr);
132 --- a/drivers/net/wireless/ath9k/recv.c
133 +++ b/drivers/net/wireless/ath9k/recv.c
134 @@ -291,16 +291,15 @@ int ath_rx_init(struct ath_softc *sc, in
135 }
136
137 bf->bf_mpdu = skb;
138 - bf->bf_buf_addr = pci_map_single(to_pci_dev(sc->dev),
139 - skb->data,
140 + bf->bf_buf_addr = dma_map_single(sc->dev, skb->data,
141 sc->rx.bufsize,
142 - PCI_DMA_FROMDEVICE);
143 - if (unlikely(pci_dma_mapping_error(to_pci_dev(sc->dev),
144 + DMA_FROM_DEVICE);
145 + if (unlikely(dma_mapping_error(sc->dev,
146 bf->bf_buf_addr))) {
147 dev_kfree_skb_any(skb);
148 bf->bf_mpdu = NULL;
149 DPRINTF(sc, ATH_DBG_CONFIG,
150 - "pci_dma_mapping_error() on RX init\n");
151 + "dma_mapping_error() on RX init\n");
152 error = -ENOMEM;
153 break;
154 }
155 @@ -525,10 +524,9 @@ int ath_rx_tasklet(struct ath_softc *sc,
156 * 1. accessing the frame
157 * 2. requeueing the same buffer to h/w
158 */
159 - pci_dma_sync_single_for_cpu(to_pci_dev(sc->dev),
160 - bf->bf_buf_addr,
161 + dma_sync_single_for_cpu(sc->dev, bf->bf_buf_addr,
162 sc->rx.bufsize,
163 - PCI_DMA_FROMDEVICE);
164 + DMA_FROM_DEVICE);
165
166 /*
167 * If we're asked to flush receive queue, directly
168 @@ -559,9 +557,9 @@ int ath_rx_tasklet(struct ath_softc *sc,
169 goto requeue;
170
171 /* Unmap the frame */
172 - pci_unmap_single(to_pci_dev(sc->dev), bf->bf_buf_addr,
173 + dma_unmap_single(sc->dev, bf->bf_buf_addr,
174 sc->rx.bufsize,
175 - PCI_DMA_FROMDEVICE);
176 + DMA_FROM_DEVICE);
177
178 skb_put(skb, ds->ds_rxstat.rs_datalen);
179 skb->protocol = cpu_to_be16(ETH_P_CONTROL);
180 @@ -607,16 +605,15 @@ int ath_rx_tasklet(struct ath_softc *sc,
181
182 /* We will now give hardware our shiny new allocated skb */
183 bf->bf_mpdu = requeue_skb;
184 - bf->bf_buf_addr = pci_map_single(to_pci_dev(sc->dev),
185 - requeue_skb->data,
186 + bf->bf_buf_addr = dma_map_single(sc->dev, requeue_skb->data,
187 sc->rx.bufsize,
188 - PCI_DMA_FROMDEVICE);
189 - if (unlikely(pci_dma_mapping_error(to_pci_dev(sc->dev),
190 + DMA_FROM_DEVICE);
191 + if (unlikely(dma_mapping_error(sc->dev,
192 bf->bf_buf_addr))) {
193 dev_kfree_skb_any(requeue_skb);
194 bf->bf_mpdu = NULL;
195 DPRINTF(sc, ATH_DBG_CONFIG,
196 - "pci_dma_mapping_error() on RX\n");
197 + "dma_mapping_error() on RX\n");
198 break;
199 }
200 bf->bf_dmacontext = bf->bf_buf_addr;
201 --- a/drivers/net/wireless/ath9k/xmit.c
202 +++ b/drivers/net/wireless/ath9k/xmit.c
203 @@ -340,10 +340,8 @@ static void ath_tx_complete_buf(struct a
204 }
205
206 /* Unmap this frame */
207 - pci_unmap_single(to_pci_dev(sc->dev),
208 - bf->bf_dmacontext,
209 - skb->len,
210 - PCI_DMA_TODEVICE);
211 + dma_unmap_single(sc->dev, bf->bf_dmacontext, skb->len, DMA_TO_DEVICE);
212 +
213 /* complete this frame */
214 ath_tx_complete(sc, skb, &tx_status);
215
216 @@ -1716,13 +1714,12 @@ static int ath_tx_setup_buffer(struct at
217 /* DMA setup */
218 bf->bf_mpdu = skb;
219
220 - bf->bf_dmacontext = pci_map_single(to_pci_dev(sc->dev), skb->data,
221 - skb->len, PCI_DMA_TODEVICE);
222 - if (unlikely(pci_dma_mapping_error(to_pci_dev(sc->dev),
223 - bf->bf_dmacontext))) {
224 + bf->bf_dmacontext = dma_map_single(sc->dev, skb->data,
225 + skb->len, DMA_TO_DEVICE);
226 + if (unlikely(dma_mapping_error(sc->dev, bf->bf_dmacontext))) {
227 bf->bf_mpdu = NULL;
228 DPRINTF(sc, ATH_DBG_CONFIG,
229 - "pci_dma_mapping_error() on TX\n");
230 + "dma_mapping_error() on TX\n");
231 return -ENOMEM;
232 }
233