]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/2.6.33.2/iwlwifi-use-dma_alloc_coherent.patch
5.0-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 2.6.33.2 / iwlwifi-use-dma_alloc_coherent.patch
CommitLineData
df00aad9
GKH
1From f36d04abe684f9e2b07c6ebe9f77ae20eb5c1e84 Mon Sep 17 00:00:00 2001
2From: Stanislaw Gruszka <sgruszka@redhat.com>
3Date: Wed, 10 Feb 2010 05:07:45 -0800
4Subject: iwlwifi: use dma_alloc_coherent
5
6From: Stanislaw Gruszka <sgruszka@redhat.com>
7
8commit f36d04abe684f9e2b07c6ebe9f77ae20eb5c1e84 upstream.
9
10Change pci_alloc_consistent() to dma_alloc_coherent() so we can use
11GFP_KERNEL flag.
12
13Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
14Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
15Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
16
17---
18 drivers/net/wireless/iwlwifi/iwl-3945.c | 8 +++-----
19 drivers/net/wireless/iwlwifi/iwl-core.c | 12 ++++++------
20 drivers/net/wireless/iwlwifi/iwl-helpers.h | 7 ++++---
21 drivers/net/wireless/iwlwifi/iwl-rx.c | 21 +++++++++++----------
22 drivers/net/wireless/iwlwifi/iwl-tx.c | 23 ++++++++++++-----------
23 drivers/net/wireless/iwlwifi/iwl3945-base.c | 16 ++++++++--------
24 6 files changed, 44 insertions(+), 43 deletions(-)
25
26--- a/drivers/net/wireless/iwlwifi/iwl-3945.c
27+++ b/drivers/net/wireless/iwlwifi/iwl-3945.c
28@@ -2474,11 +2474,9 @@ int iwl3945_hw_set_hw_params(struct iwl_
29 memset((void *)&priv->hw_params, 0,
30 sizeof(struct iwl_hw_params));
31
32- priv->shared_virt =
33- pci_alloc_consistent(priv->pci_dev,
34- sizeof(struct iwl3945_shared),
35- &priv->shared_phys);
36-
37+ priv->shared_virt = dma_alloc_coherent(&priv->pci_dev->dev,
38+ sizeof(struct iwl3945_shared),
39+ &priv->shared_phys, GFP_KERNEL);
40 if (!priv->shared_virt) {
41 IWL_ERR(priv, "failed to allocate pci memory\n");
42 mutex_unlock(&priv->mutex);
43--- a/drivers/net/wireless/iwlwifi/iwl-core.c
44+++ b/drivers/net/wireless/iwlwifi/iwl-core.c
45@@ -1658,9 +1658,9 @@ EXPORT_SYMBOL(iwl_set_tx_power);
46 void iwl_free_isr_ict(struct iwl_priv *priv)
47 {
48 if (priv->ict_tbl_vir) {
49- pci_free_consistent(priv->pci_dev, (sizeof(u32) * ICT_COUNT) +
50- PAGE_SIZE, priv->ict_tbl_vir,
51- priv->ict_tbl_dma);
52+ dma_free_coherent(&priv->pci_dev->dev,
53+ (sizeof(u32) * ICT_COUNT) + PAGE_SIZE,
54+ priv->ict_tbl_vir, priv->ict_tbl_dma);
55 priv->ict_tbl_vir = NULL;
56 }
57 }
58@@ -1676,9 +1676,9 @@ int iwl_alloc_isr_ict(struct iwl_priv *p
59 if (priv->cfg->use_isr_legacy)
60 return 0;
61 /* allocate shrared data table */
62- priv->ict_tbl_vir = pci_alloc_consistent(priv->pci_dev, (sizeof(u32) *
63- ICT_COUNT) + PAGE_SIZE,
64- &priv->ict_tbl_dma);
65+ priv->ict_tbl_vir = dma_alloc_coherent(&priv->pci_dev->dev,
66+ (sizeof(u32) * ICT_COUNT) + PAGE_SIZE,
67+ &priv->ict_tbl_dma, GFP_KERNEL);
68 if (!priv->ict_tbl_vir)
69 return -ENOMEM;
70
71--- a/drivers/net/wireless/iwlwifi/iwl-helpers.h
72+++ b/drivers/net/wireless/iwlwifi/iwl-helpers.h
73@@ -80,8 +80,8 @@ static inline void iwl_free_fw_desc(stru
74 struct fw_desc *desc)
75 {
76 if (desc->v_addr)
77- pci_free_consistent(pci_dev, desc->len,
78- desc->v_addr, desc->p_addr);
79+ dma_free_coherent(&pci_dev->dev, desc->len,
80+ desc->v_addr, desc->p_addr);
81 desc->v_addr = NULL;
82 desc->len = 0;
83 }
84@@ -89,7 +89,8 @@ static inline void iwl_free_fw_desc(stru
85 static inline int iwl_alloc_fw_desc(struct pci_dev *pci_dev,
86 struct fw_desc *desc)
87 {
88- desc->v_addr = pci_alloc_consistent(pci_dev, desc->len, &desc->p_addr);
89+ desc->v_addr = dma_alloc_coherent(&pci_dev->dev, desc->len,
90+ &desc->p_addr, GFP_KERNEL);
91 return (desc->v_addr != NULL) ? 0 : -ENOMEM;
92 }
93
94--- a/drivers/net/wireless/iwlwifi/iwl-rx.c
95+++ b/drivers/net/wireless/iwlwifi/iwl-rx.c
96@@ -350,10 +350,10 @@ void iwl_rx_queue_free(struct iwl_priv *
97 }
98 }
99
100- pci_free_consistent(priv->pci_dev, 4 * RX_QUEUE_SIZE, rxq->bd,
101- rxq->dma_addr);
102- pci_free_consistent(priv->pci_dev, sizeof(struct iwl_rb_status),
103- rxq->rb_stts, rxq->rb_stts_dma);
104+ dma_free_coherent(&priv->pci_dev->dev, 4 * RX_QUEUE_SIZE, rxq->bd,
105+ rxq->dma_addr);
106+ dma_free_coherent(&priv->pci_dev->dev, sizeof(struct iwl_rb_status),
107+ rxq->rb_stts, rxq->rb_stts_dma);
108 rxq->bd = NULL;
109 rxq->rb_stts = NULL;
110 }
111@@ -362,7 +362,7 @@ EXPORT_SYMBOL(iwl_rx_queue_free);
112 int iwl_rx_queue_alloc(struct iwl_priv *priv)
113 {
114 struct iwl_rx_queue *rxq = &priv->rxq;
115- struct pci_dev *dev = priv->pci_dev;
116+ struct device *dev = &priv->pci_dev->dev;
117 int i;
118
119 spin_lock_init(&rxq->lock);
120@@ -370,12 +370,13 @@ int iwl_rx_queue_alloc(struct iwl_priv *
121 INIT_LIST_HEAD(&rxq->rx_used);
122
123 /* Alloc the circular buffer of Read Buffer Descriptors (RBDs) */
124- rxq->bd = pci_alloc_consistent(dev, 4 * RX_QUEUE_SIZE, &rxq->dma_addr);
125+ rxq->bd = dma_alloc_coherent(dev, 4 * RX_QUEUE_SIZE, &rxq->dma_addr,
126+ GFP_KERNEL);
127 if (!rxq->bd)
128 goto err_bd;
129
130- rxq->rb_stts = pci_alloc_consistent(dev, sizeof(struct iwl_rb_status),
131- &rxq->rb_stts_dma);
132+ rxq->rb_stts = dma_alloc_coherent(dev, sizeof(struct iwl_rb_status),
133+ &rxq->rb_stts_dma, GFP_KERNEL);
134 if (!rxq->rb_stts)
135 goto err_rb;
136
137@@ -392,8 +393,8 @@ int iwl_rx_queue_alloc(struct iwl_priv *
138 return 0;
139
140 err_rb:
141- pci_free_consistent(priv->pci_dev, 4 * RX_QUEUE_SIZE, rxq->bd,
142- rxq->dma_addr);
143+ dma_free_coherent(&priv->pci_dev->dev, 4 * RX_QUEUE_SIZE, rxq->bd,
144+ rxq->dma_addr);
145 err_bd:
146 return -ENOMEM;
147 }
148--- a/drivers/net/wireless/iwlwifi/iwl-tx.c
149+++ b/drivers/net/wireless/iwlwifi/iwl-tx.c
150@@ -60,7 +60,8 @@ static const u16 default_tid_to_tx_fifo[
151 static inline int iwl_alloc_dma_ptr(struct iwl_priv *priv,
152 struct iwl_dma_ptr *ptr, size_t size)
153 {
154- ptr->addr = pci_alloc_consistent(priv->pci_dev, size, &ptr->dma);
155+ ptr->addr = dma_alloc_coherent(&priv->pci_dev->dev, size, &ptr->dma,
156+ GFP_KERNEL);
157 if (!ptr->addr)
158 return -ENOMEM;
159 ptr->size = size;
160@@ -73,7 +74,7 @@ static inline void iwl_free_dma_ptr(stru
161 if (unlikely(!ptr->addr))
162 return;
163
164- pci_free_consistent(priv->pci_dev, ptr->size, ptr->addr, ptr->dma);
165+ dma_free_coherent(&priv->pci_dev->dev, ptr->size, ptr->addr, ptr->dma);
166 memset(ptr, 0, sizeof(*ptr));
167 }
168
169@@ -146,7 +147,7 @@ void iwl_tx_queue_free(struct iwl_priv *
170 {
171 struct iwl_tx_queue *txq = &priv->txq[txq_id];
172 struct iwl_queue *q = &txq->q;
173- struct pci_dev *dev = priv->pci_dev;
174+ struct device *dev = &priv->pci_dev->dev;
175 int i;
176
177 if (q->n_bd == 0)
178@@ -163,8 +164,8 @@ void iwl_tx_queue_free(struct iwl_priv *
179
180 /* De-alloc circular buffer of TFDs */
181 if (txq->q.n_bd)
182- pci_free_consistent(dev, priv->hw_params.tfd_size *
183- txq->q.n_bd, txq->tfds, txq->q.dma_addr);
184+ dma_free_coherent(dev, priv->hw_params.tfd_size *
185+ txq->q.n_bd, txq->tfds, txq->q.dma_addr);
186
187 /* De-alloc array of per-TFD driver data */
188 kfree(txq->txb);
189@@ -193,7 +194,7 @@ void iwl_cmd_queue_free(struct iwl_priv
190 {
191 struct iwl_tx_queue *txq = &priv->txq[IWL_CMD_QUEUE_NUM];
192 struct iwl_queue *q = &txq->q;
193- struct pci_dev *dev = priv->pci_dev;
194+ struct device *dev = &priv->pci_dev->dev;
195 int i;
196
197 if (q->n_bd == 0)
198@@ -205,8 +206,8 @@ void iwl_cmd_queue_free(struct iwl_priv
199
200 /* De-alloc circular buffer of TFDs */
201 if (txq->q.n_bd)
202- pci_free_consistent(dev, priv->hw_params.tfd_size *
203- txq->q.n_bd, txq->tfds, txq->q.dma_addr);
204+ dma_free_coherent(dev, priv->hw_params.tfd_size * txq->q.n_bd,
205+ txq->tfds, txq->q.dma_addr);
206
207 /* deallocate arrays */
208 kfree(txq->cmd);
209@@ -297,7 +298,7 @@ static int iwl_queue_init(struct iwl_pri
210 static int iwl_tx_queue_alloc(struct iwl_priv *priv,
211 struct iwl_tx_queue *txq, u32 id)
212 {
213- struct pci_dev *dev = priv->pci_dev;
214+ struct device *dev = &priv->pci_dev->dev;
215 size_t tfd_sz = priv->hw_params.tfd_size * TFD_QUEUE_SIZE_MAX;
216
217 /* Driver private data, only for Tx (not command) queues,
218@@ -316,8 +317,8 @@ static int iwl_tx_queue_alloc(struct iwl
219
220 /* Circular buffer of transmit frame descriptors (TFDs),
221 * shared with device */
222- txq->tfds = pci_alloc_consistent(dev, tfd_sz, &txq->q.dma_addr);
223-
224+ txq->tfds = dma_alloc_coherent(dev, tfd_sz, &txq->q.dma_addr,
225+ GFP_KERNEL);
226 if (!txq->tfds) {
227 IWL_ERR(priv, "pci_alloc_consistent(%zd) failed\n", tfd_sz);
228 goto error;
229--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
230+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
231@@ -352,10 +352,10 @@ static int iwl3945_send_beacon_cmd(struc
232 static void iwl3945_unset_hw_params(struct iwl_priv *priv)
233 {
234 if (priv->shared_virt)
235- pci_free_consistent(priv->pci_dev,
236- sizeof(struct iwl3945_shared),
237- priv->shared_virt,
238- priv->shared_phys);
239+ dma_free_coherent(&priv->pci_dev->dev,
240+ sizeof(struct iwl3945_shared),
241+ priv->shared_virt,
242+ priv->shared_phys);
243 }
244
245 static void iwl3945_build_tx_cmd_hwcrypto(struct iwl_priv *priv,
246@@ -1253,10 +1253,10 @@ static void iwl3945_rx_queue_free(struct
247 }
248 }
249
250- pci_free_consistent(priv->pci_dev, 4 * RX_QUEUE_SIZE, rxq->bd,
251- rxq->dma_addr);
252- pci_free_consistent(priv->pci_dev, sizeof(struct iwl_rb_status),
253- rxq->rb_stts, rxq->rb_stts_dma);
254+ dma_free_coherent(&priv->pci_dev->dev, 4 * RX_QUEUE_SIZE, rxq->bd,
255+ rxq->dma_addr);
256+ dma_free_coherent(&priv->pci_dev->dev, sizeof(struct iwl_rb_status),
257+ rxq->rb_stts, rxq->rb_stts_dma);
258 rxq->bd = NULL;
259 rxq->rb_stts = NULL;
260 }