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 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 Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
9 Signed-off-by: Imre Kaloz <kaloz@openwrt.org>
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(-)
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
21 skb = (struct sk_buff *)bf->bf_mpdu;
23 - pci_unmap_single(to_pci_dev(sc->dev), bf->bf_dmacontext,
24 + dma_unmap_single(sc->dev, bf->bf_dmacontext,
28 dev_kfree_skb_any(skb);
31 @@ -188,15 +188,14 @@ static struct ath_buf *ath_beacon_genera
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,
39 - if (unlikely(pci_dma_mapping_error(to_pci_dev(sc->dev),
40 - bf->bf_buf_addr))) {
42 + if (unlikely(dma_mapping_error(sc->dev, bf->bf_buf_addr))) {
43 dev_kfree_skb_any(skb);
45 DPRINTF(sc, ATH_DBG_CONFIG,
46 - "pci_dma_mapping_error() on beaconing\n");
47 + "dma_mapping_error() on beaconing\n");
51 @@ -344,9 +343,9 @@ int ath_beacon_alloc(struct ath_softc *s
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,
60 dev_kfree_skb_any(skb);
63 @@ -403,15 +402,14 @@ int ath_beacon_alloc(struct ath_softc *s
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,
71 - if (unlikely(pci_dma_mapping_error(to_pci_dev(sc->dev),
72 - bf->bf_buf_addr))) {
74 + if (unlikely(dma_mapping_error(sc->dev, bf->bf_buf_addr))) {
75 dev_kfree_skb_any(skb);
77 DPRINTF(sc, ATH_DBG_CONFIG,
78 - "pci_dma_mapping_error() on beacon alloc\n");
79 + "dma_mapping_error() on beacon alloc\n");
83 @@ -431,10 +429,9 @@ void ath_beacon_return(struct ath_softc
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),
89 + dma_unmap_single(sc->dev, bf->bf_dmacontext,
93 dev_kfree_skb_any(skb);
96 --- a/drivers/net/wireless/ath9k/main.c
97 +++ b/drivers/net/wireless/ath9k/main.c
98 @@ -1709,9 +1709,8 @@ int ath_descdma_setup(struct ath_softc *
101 /* allocate descriptors */
102 - dd->dd_desc = pci_alloc_consistent(to_pci_dev(sc->dev),
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) {
110 @@ -1757,8 +1756,8 @@ int ath_descdma_setup(struct ath_softc *
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);
119 memset(dd, 0, sizeof(*dd));
121 @@ -1771,8 +1770,8 @@ void ath_descdma_cleanup(struct ath_soft
122 struct ath_descdma *dd,
123 struct list_head *head)
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);
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
138 - bf->bf_buf_addr = pci_map_single(to_pci_dev(sc->dev),
140 + bf->bf_buf_addr = dma_map_single(sc->dev, skb->data,
142 - PCI_DMA_FROMDEVICE);
143 - if (unlikely(pci_dma_mapping_error(to_pci_dev(sc->dev),
145 + if (unlikely(dma_mapping_error(sc->dev,
147 dev_kfree_skb_any(skb);
149 DPRINTF(sc, ATH_DBG_CONFIG,
150 - "pci_dma_mapping_error() on RX init\n");
151 + "dma_mapping_error() on RX init\n");
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
159 - pci_dma_sync_single_for_cpu(to_pci_dev(sc->dev),
161 + dma_sync_single_for_cpu(sc->dev, bf->bf_buf_addr,
163 - PCI_DMA_FROMDEVICE);
167 * If we're asked to flush receive queue, directly
168 @@ -559,9 +557,9 @@ int ath_rx_tasklet(struct ath_softc *sc,
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,
175 - PCI_DMA_FROMDEVICE);
178 skb_put(skb, ds->ds_rxstat.rs_datalen);
179 skb->protocol = cpu_to_be16(ETH_P_CONTROL);
180 @@ -601,16 +599,15 @@ int ath_rx_tasklet(struct ath_softc *sc,
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),
186 + bf->bf_buf_addr = dma_map_single(sc->dev, requeue_skb->data,
188 - PCI_DMA_FROMDEVICE);
189 - if (unlikely(pci_dma_mapping_error(to_pci_dev(sc->dev),
191 + if (unlikely(dma_mapping_error(sc->dev,
193 dev_kfree_skb_any(requeue_skb);
195 DPRINTF(sc, ATH_DBG_CONFIG,
196 - "pci_dma_mapping_error() on RX\n");
197 + "dma_mapping_error() on RX\n");
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
206 /* Unmap this frame */
207 - pci_unmap_single(to_pci_dev(sc->dev),
211 + dma_unmap_single(sc->dev, bf->bf_dmacontext, skb->len, DMA_TO_DEVICE);
213 /* complete this frame */
214 ath_tx_complete(sc, skb, &tx_status);
216 @@ -1716,13 +1714,12 @@ static int ath_tx_setup_buffer(struct at
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))) {
228 DPRINTF(sc, ATH_DBG_CONFIG,
229 - "pci_dma_mapping_error() on TX\n");
230 + "dma_mapping_error() on TX\n");