[package] mac80211: update ath9k patches
[openwrt/svn-archive/archive.git] / package / mac80211 / patches / 402-ath9k-convert-to-use-bus-agnostic-DMA-routines.patch
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
5
6 Convert to use bus-agnostic DMA routines to make it usable on AHB bus as well.
7
8 Changes-licensed-under: ISC
9
10 Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
11 Signed-off-by: Imre Kaloz <kaloz@openwrt.org>
12 ---
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(-)
18
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
22 bf = avp->av_bcbuf;
23 skb = (struct sk_buff *)bf->bf_mpdu;
24 if (skb) {
25 - pci_unmap_single(to_pci_dev(sc->dev), bf->bf_dmacontext,
26 + dma_unmap_single(sc->dev, bf->bf_dmacontext,
27 skb->len,
28 - PCI_DMA_TODEVICE);
29 + DMA_TO_DEVICE);
30 dev_kfree_skb_any(skb);
31 }
32
33 @@ -188,15 +188,14 @@ static struct ath_buf *ath_beacon_genera
34 }
35
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,
39 skb->len,
40 - PCI_DMA_TODEVICE);
41 - if (unlikely(pci_dma_mapping_error(to_pci_dev(sc->dev),
42 - bf->bf_buf_addr))) {
43 + DMA_TO_DEVICE);
44 + if (unlikely(dma_mapping_error(sc->dev, bf->bf_buf_addr))) {
45 dev_kfree_skb_any(skb);
46 bf->bf_mpdu = NULL;
47 DPRINTF(sc, ATH_DBG_CONFIG,
48 - "pci_dma_mapping_error() on beaconing\n");
49 + "dma_mapping_error() on beaconing\n");
50 return NULL;
51 }
52
53 @@ -344,9 +343,9 @@ int ath_beacon_alloc(struct ath_softc *s
54 bf = avp->av_bcbuf;
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,
59 skb->len,
60 - PCI_DMA_TODEVICE);
61 + DMA_TO_DEVICE);
62 dev_kfree_skb_any(skb);
63 bf->bf_mpdu = NULL;
64 }
65 @@ -403,15 +402,14 @@ int ath_beacon_alloc(struct ath_softc *s
66
67 bf->bf_mpdu = skb;
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,
71 skb->len,
72 - PCI_DMA_TODEVICE);
73 - if (unlikely(pci_dma_mapping_error(to_pci_dev(sc->dev),
74 - bf->bf_buf_addr))) {
75 + DMA_TO_DEVICE);
76 + if (unlikely(dma_mapping_error(sc->dev, bf->bf_buf_addr))) {
77 dev_kfree_skb_any(skb);
78 bf->bf_mpdu = NULL;
79 DPRINTF(sc, ATH_DBG_CONFIG,
80 - "pci_dma_mapping_error() on beacon alloc\n");
81 + "dma_mapping_error() on beacon alloc\n");
82 return -ENOMEM;
83 }
84
85 @@ -431,10 +429,9 @@ void ath_beacon_return(struct ath_softc
86 bf = avp->av_bcbuf;
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),
90 - bf->bf_dmacontext,
91 + dma_unmap_single(sc->dev, bf->bf_dmacontext,
92 skb->len,
93 - PCI_DMA_TODEVICE);
94 + DMA_TO_DEVICE);
95 dev_kfree_skb_any(skb);
96 bf->bf_mpdu = NULL;
97 }
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 *
101 }
102
103 /* allocate descriptors */
104 - dd->dd_desc = pci_alloc_consistent(to_pci_dev(sc->dev),
105 - dd->dd_desc_len,
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) {
110 error = -ENOMEM;
111 goto fail;
112 @@ -1765,8 +1764,8 @@ int ath_descdma_setup(struct ath_softc *
113 }
114 return 0;
115 fail2:
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);
120 fail:
121 memset(dd, 0, sizeof(*dd));
122 return error;
123 @@ -1779,8 +1778,8 @@ void ath_descdma_cleanup(struct ath_soft
124 struct ath_descdma *dd,
125 struct list_head *head)
126 {
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);
131
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
137 }
138
139 bf->bf_mpdu = skb;
140 - bf->bf_buf_addr = pci_map_single(to_pci_dev(sc->dev),
141 - skb->data,
142 + bf->bf_buf_addr = dma_map_single(sc->dev, skb->data,
143 sc->rx.bufsize,
144 - PCI_DMA_FROMDEVICE);
145 - if (unlikely(pci_dma_mapping_error(to_pci_dev(sc->dev),
146 + DMA_FROM_DEVICE);
147 + if (unlikely(dma_mapping_error(sc->dev,
148 bf->bf_buf_addr))) {
149 dev_kfree_skb_any(skb);
150 bf->bf_mpdu = NULL;
151 DPRINTF(sc, ATH_DBG_CONFIG,
152 - "pci_dma_mapping_error() on RX init\n");
153 + "dma_mapping_error() on RX init\n");
154 error = -ENOMEM;
155 break;
156 }
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
160 */
161 - pci_dma_sync_single_for_cpu(to_pci_dev(sc->dev),
162 - bf->bf_buf_addr,
163 + dma_sync_single_for_cpu(sc->dev, bf->bf_buf_addr,
164 sc->rx.bufsize,
165 - PCI_DMA_FROMDEVICE);
166 + DMA_FROM_DEVICE);
167
168 /*
169 * If we're asked to flush receive queue, directly
170 @@ -559,9 +557,9 @@ int ath_rx_tasklet(struct ath_softc *sc,
171 goto requeue;
172
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,
176 sc->rx.bufsize,
177 - PCI_DMA_FROMDEVICE);
178 + DMA_FROM_DEVICE);
179
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,
183
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),
187 - requeue_skb->data,
188 + bf->bf_buf_addr = dma_map_single(sc->dev, requeue_skb->data,
189 sc->rx.bufsize,
190 - PCI_DMA_FROMDEVICE);
191 - if (unlikely(pci_dma_mapping_error(to_pci_dev(sc->dev),
192 + DMA_FROM_DEVICE);
193 + if (unlikely(dma_mapping_error(sc->dev,
194 bf->bf_buf_addr))) {
195 dev_kfree_skb_any(requeue_skb);
196 bf->bf_mpdu = NULL;
197 DPRINTF(sc, ATH_DBG_CONFIG,
198 - "pci_dma_mapping_error() on RX\n");
199 + "dma_mapping_error() on RX\n");
200 break;
201 }
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
206 }
207
208 /* Unmap this frame */
209 - pci_unmap_single(to_pci_dev(sc->dev),
210 - bf->bf_dmacontext,
211 - skb->len,
212 - PCI_DMA_TODEVICE);
213 + dma_unmap_single(sc->dev, bf->bf_dmacontext, skb->len, DMA_TO_DEVICE);
214 +
215 /* complete this frame */
216 ath_tx_complete(sc, skb, &tx_status);
217
218 @@ -1716,13 +1714,12 @@ static int ath_tx_setup_buffer(struct at
219 /* DMA setup */
220 bf->bf_mpdu = skb;
221
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))) {
229 bf->bf_mpdu = NULL;
230 DPRINTF(sc, ATH_DBG_CONFIG,
231 - "pci_dma_mapping_error() on TX\n");
232 + "dma_mapping_error() on TX\n");
233 return -ENOMEM;
234 }
235