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