diff options
author | Ira Snyder <iws@ovro.caltech.edu> | 2010-01-06 08:33:59 -0500 |
---|---|---|
committer | Dan Williams <dan.j.williams@intel.com> | 2010-02-02 16:51:40 -0500 |
commit | 272ca655090978bdaa2630fc44fb2c03da5576fd (patch) | |
tree | 3ad63195951405f4a51c44f1a57f125415d649e6 /drivers/dma/fsldma.c | |
parent | abe94c756c08d50566c09a65b9c7fe72f83071c5 (diff) |
fsldma: reduce kernel text size
Some of the functions are written in a way where they use multiple reads
and writes where a single read/write pair could suffice. This shrinks the
kernel text size measurably, while making the functions easier to
understand.
add/remove: 0/0 grow/shrink: 1/4 up/down: 4/-196 (-192)
function old new delta
fsl_chan_set_request_count 120 124 +4
dma_halt 300 272 -28
fsl_chan_set_src_loop_size 208 156 -52
fsl_chan_set_dest_loop_size 208 156 -52
fsl_chan_xfer_ld_queue 500 436 -64
Signed-off-by: Ira W. Snyder <iws@ovro.caltech.edu>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'drivers/dma/fsldma.c')
-rw-r--r-- | drivers/dma/fsldma.c | 83 |
1 files changed, 45 insertions, 38 deletions
diff --git a/drivers/dma/fsldma.c b/drivers/dma/fsldma.c index 296f9e747fac..0bad741765c6 100644 --- a/drivers/dma/fsldma.c +++ b/drivers/dma/fsldma.c | |||
@@ -143,43 +143,45 @@ static int dma_is_idle(struct fsl_dma_chan *fsl_chan) | |||
143 | 143 | ||
144 | static void dma_start(struct fsl_dma_chan *fsl_chan) | 144 | static void dma_start(struct fsl_dma_chan *fsl_chan) |
145 | { | 145 | { |
146 | u32 mr_set = 0; | 146 | u32 mode; |
147 | 147 | ||
148 | if (fsl_chan->feature & FSL_DMA_CHAN_PAUSE_EXT) { | 148 | mode = DMA_IN(fsl_chan, &fsl_chan->reg_base->mr, 32); |
149 | DMA_OUT(fsl_chan, &fsl_chan->reg_base->bcr, 0, 32); | 149 | |
150 | mr_set |= FSL_DMA_MR_EMP_EN; | 150 | if ((fsl_chan->feature & FSL_DMA_IP_MASK) == FSL_DMA_IP_85XX) { |
151 | } else if ((fsl_chan->feature & FSL_DMA_IP_MASK) == FSL_DMA_IP_85XX) { | 151 | if (fsl_chan->feature & FSL_DMA_CHAN_PAUSE_EXT) { |
152 | DMA_OUT(fsl_chan, &fsl_chan->reg_base->mr, | 152 | DMA_OUT(fsl_chan, &fsl_chan->reg_base->bcr, 0, 32); |
153 | DMA_IN(fsl_chan, &fsl_chan->reg_base->mr, 32) | 153 | mode |= FSL_DMA_MR_EMP_EN; |
154 | & ~FSL_DMA_MR_EMP_EN, 32); | 154 | } else { |
155 | mode &= ~FSL_DMA_MR_EMP_EN; | ||
156 | } | ||
155 | } | 157 | } |
156 | 158 | ||
157 | if (fsl_chan->feature & FSL_DMA_CHAN_START_EXT) | 159 | if (fsl_chan->feature & FSL_DMA_CHAN_START_EXT) |
158 | mr_set |= FSL_DMA_MR_EMS_EN; | 160 | mode |= FSL_DMA_MR_EMS_EN; |
159 | else | 161 | else |
160 | mr_set |= FSL_DMA_MR_CS; | 162 | mode |= FSL_DMA_MR_CS; |
161 | 163 | ||
162 | DMA_OUT(fsl_chan, &fsl_chan->reg_base->mr, | 164 | DMA_OUT(fsl_chan, &fsl_chan->reg_base->mr, mode, 32); |
163 | DMA_IN(fsl_chan, &fsl_chan->reg_base->mr, 32) | ||
164 | | mr_set, 32); | ||
165 | } | 165 | } |
166 | 166 | ||
167 | static void dma_halt(struct fsl_dma_chan *fsl_chan) | 167 | static void dma_halt(struct fsl_dma_chan *fsl_chan) |
168 | { | 168 | { |
169 | u32 mode; | ||
169 | int i; | 170 | int i; |
170 | 171 | ||
171 | DMA_OUT(fsl_chan, &fsl_chan->reg_base->mr, | 172 | mode = DMA_IN(fsl_chan, &fsl_chan->reg_base->mr, 32); |
172 | DMA_IN(fsl_chan, &fsl_chan->reg_base->mr, 32) | FSL_DMA_MR_CA, | 173 | mode |= FSL_DMA_MR_CA; |
173 | 32); | 174 | DMA_OUT(fsl_chan, &fsl_chan->reg_base->mr, mode, 32); |
174 | DMA_OUT(fsl_chan, &fsl_chan->reg_base->mr, | 175 | |
175 | DMA_IN(fsl_chan, &fsl_chan->reg_base->mr, 32) & ~(FSL_DMA_MR_CS | 176 | mode &= ~(FSL_DMA_MR_CS | FSL_DMA_MR_EMS_EN | FSL_DMA_MR_CA); |
176 | | FSL_DMA_MR_EMS_EN | FSL_DMA_MR_CA), 32); | 177 | DMA_OUT(fsl_chan, &fsl_chan->reg_base->mr, mode, 32); |
177 | 178 | ||
178 | for (i = 0; i < 100; i++) { | 179 | for (i = 0; i < 100; i++) { |
179 | if (dma_is_idle(fsl_chan)) | 180 | if (dma_is_idle(fsl_chan)) |
180 | break; | 181 | break; |
181 | udelay(10); | 182 | udelay(10); |
182 | } | 183 | } |
184 | |||
183 | if (i >= 100 && !dma_is_idle(fsl_chan)) | 185 | if (i >= 100 && !dma_is_idle(fsl_chan)) |
184 | dev_err(fsl_chan->dev, "DMA halt timeout!\n"); | 186 | dev_err(fsl_chan->dev, "DMA halt timeout!\n"); |
185 | } | 187 | } |
@@ -231,22 +233,23 @@ static void append_ld_queue(struct fsl_dma_chan *fsl_chan, | |||
231 | */ | 233 | */ |
232 | static void fsl_chan_set_src_loop_size(struct fsl_dma_chan *fsl_chan, int size) | 234 | static void fsl_chan_set_src_loop_size(struct fsl_dma_chan *fsl_chan, int size) |
233 | { | 235 | { |
236 | u32 mode; | ||
237 | |||
238 | mode = DMA_IN(fsl_chan, &fsl_chan->reg_base->mr, 32); | ||
239 | |||
234 | switch (size) { | 240 | switch (size) { |
235 | case 0: | 241 | case 0: |
236 | DMA_OUT(fsl_chan, &fsl_chan->reg_base->mr, | 242 | mode &= ~FSL_DMA_MR_SAHE; |
237 | DMA_IN(fsl_chan, &fsl_chan->reg_base->mr, 32) & | ||
238 | (~FSL_DMA_MR_SAHE), 32); | ||
239 | break; | 243 | break; |
240 | case 1: | 244 | case 1: |
241 | case 2: | 245 | case 2: |
242 | case 4: | 246 | case 4: |
243 | case 8: | 247 | case 8: |
244 | DMA_OUT(fsl_chan, &fsl_chan->reg_base->mr, | 248 | mode |= FSL_DMA_MR_SAHE | (__ilog2(size) << 14); |
245 | DMA_IN(fsl_chan, &fsl_chan->reg_base->mr, 32) | | ||
246 | FSL_DMA_MR_SAHE | (__ilog2(size) << 14), | ||
247 | 32); | ||
248 | break; | 249 | break; |
249 | } | 250 | } |
251 | |||
252 | DMA_OUT(fsl_chan, &fsl_chan->reg_base->mr, mode, 32); | ||
250 | } | 253 | } |
251 | 254 | ||
252 | /** | 255 | /** |
@@ -262,22 +265,23 @@ static void fsl_chan_set_src_loop_size(struct fsl_dma_chan *fsl_chan, int size) | |||
262 | */ | 265 | */ |
263 | static void fsl_chan_set_dest_loop_size(struct fsl_dma_chan *fsl_chan, int size) | 266 | static void fsl_chan_set_dest_loop_size(struct fsl_dma_chan *fsl_chan, int size) |
264 | { | 267 | { |
268 | u32 mode; | ||
269 | |||
270 | mode = DMA_IN(fsl_chan, &fsl_chan->reg_base->mr, 32); | ||
271 | |||
265 | switch (size) { | 272 | switch (size) { |
266 | case 0: | 273 | case 0: |
267 | DMA_OUT(fsl_chan, &fsl_chan->reg_base->mr, | 274 | mode &= ~FSL_DMA_MR_DAHE; |
268 | DMA_IN(fsl_chan, &fsl_chan->reg_base->mr, 32) & | ||
269 | (~FSL_DMA_MR_DAHE), 32); | ||
270 | break; | 275 | break; |
271 | case 1: | 276 | case 1: |
272 | case 2: | 277 | case 2: |
273 | case 4: | 278 | case 4: |
274 | case 8: | 279 | case 8: |
275 | DMA_OUT(fsl_chan, &fsl_chan->reg_base->mr, | 280 | mode |= FSL_DMA_MR_DAHE | (__ilog2(size) << 16); |
276 | DMA_IN(fsl_chan, &fsl_chan->reg_base->mr, 32) | | ||
277 | FSL_DMA_MR_DAHE | (__ilog2(size) << 16), | ||
278 | 32); | ||
279 | break; | 281 | break; |
280 | } | 282 | } |
283 | |||
284 | DMA_OUT(fsl_chan, &fsl_chan->reg_base->mr, mode, 32); | ||
281 | } | 285 | } |
282 | 286 | ||
283 | /** | 287 | /** |
@@ -294,11 +298,14 @@ static void fsl_chan_set_dest_loop_size(struct fsl_dma_chan *fsl_chan, int size) | |||
294 | */ | 298 | */ |
295 | static void fsl_chan_set_request_count(struct fsl_dma_chan *fsl_chan, int size) | 299 | static void fsl_chan_set_request_count(struct fsl_dma_chan *fsl_chan, int size) |
296 | { | 300 | { |
301 | u32 mode; | ||
302 | |||
297 | BUG_ON(size > 1024); | 303 | BUG_ON(size > 1024); |
298 | DMA_OUT(fsl_chan, &fsl_chan->reg_base->mr, | 304 | |
299 | DMA_IN(fsl_chan, &fsl_chan->reg_base->mr, 32) | 305 | mode = DMA_IN(fsl_chan, &fsl_chan->reg_base->mr, 32); |
300 | | ((__ilog2(size) << 24) & 0x0f000000), | 306 | mode |= (__ilog2(size) << 24) & 0x0f000000; |
301 | 32); | 307 | |
308 | DMA_OUT(fsl_chan, &fsl_chan->reg_base->mr, mode, 32); | ||
302 | } | 309 | } |
303 | 310 | ||
304 | /** | 311 | /** |