aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/b43/dma.c
diff options
context:
space:
mode:
authorMichael Buesch <mb@bu3sch.de>2008-06-20 05:50:29 -0400
committerJohn W. Linville <linville@tuxdriver.com>2008-06-27 09:09:15 -0400
commitf225763a7d6c92c4932dbd528437997078496fcc (patch)
tree5d787c7c0bdabcf72e98603a85672ebe95a3682e /drivers/net/wireless/b43/dma.c
parent316af76f3475bb73dbb11f1c6d549ae589efb3d0 (diff)
ssb, b43, b43legacy, b44: Rewrite SSB DMA API
This is a rewrite of the DMA API for SSB devices. This is needed, because the old (non-existing) "API" made too many bad assumptions on the API of the host-bus (PCI). This introduces an almost complete SSB-DMA-API that maps to the lowlevel bus-API based on the bustype. Signed-off-by: Michael Buesch <mb@bu3sch.de> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/b43/dma.c')
-rw-r--r--drivers/net/wireless/b43/dma.c65
1 files changed, 35 insertions, 30 deletions
diff --git a/drivers/net/wireless/b43/dma.c b/drivers/net/wireless/b43/dma.c
index 8a09a1db08db..098f886976f6 100644
--- a/drivers/net/wireless/b43/dma.c
+++ b/drivers/net/wireless/b43/dma.c
@@ -328,11 +328,11 @@ static inline
328 dma_addr_t dmaaddr; 328 dma_addr_t dmaaddr;
329 329
330 if (tx) { 330 if (tx) {
331 dmaaddr = dma_map_single(ring->dev->dev->dma_dev, 331 dmaaddr = ssb_dma_map_single(ring->dev->dev,
332 buf, len, DMA_TO_DEVICE); 332 buf, len, DMA_TO_DEVICE);
333 } else { 333 } else {
334 dmaaddr = dma_map_single(ring->dev->dev->dma_dev, 334 dmaaddr = ssb_dma_map_single(ring->dev->dev,
335 buf, len, DMA_FROM_DEVICE); 335 buf, len, DMA_FROM_DEVICE);
336 } 336 }
337 337
338 return dmaaddr; 338 return dmaaddr;
@@ -343,11 +343,11 @@ static inline
343 dma_addr_t addr, size_t len, int tx) 343 dma_addr_t addr, size_t len, int tx)
344{ 344{
345 if (tx) { 345 if (tx) {
346 dma_unmap_single(ring->dev->dev->dma_dev, 346 ssb_dma_unmap_single(ring->dev->dev,
347 addr, len, DMA_TO_DEVICE); 347 addr, len, DMA_TO_DEVICE);
348 } else { 348 } else {
349 dma_unmap_single(ring->dev->dev->dma_dev, 349 ssb_dma_unmap_single(ring->dev->dev,
350 addr, len, DMA_FROM_DEVICE); 350 addr, len, DMA_FROM_DEVICE);
351 } 351 }
352} 352}
353 353
@@ -356,8 +356,8 @@ static inline
356 dma_addr_t addr, size_t len) 356 dma_addr_t addr, size_t len)
357{ 357{
358 B43_WARN_ON(ring->tx); 358 B43_WARN_ON(ring->tx);
359 dma_sync_single_for_cpu(ring->dev->dev->dma_dev, 359 ssb_dma_sync_single_for_cpu(ring->dev->dev,
360 addr, len, DMA_FROM_DEVICE); 360 addr, len, DMA_FROM_DEVICE);
361} 361}
362 362
363static inline 363static inline
@@ -365,8 +365,8 @@ static inline
365 dma_addr_t addr, size_t len) 365 dma_addr_t addr, size_t len)
366{ 366{
367 B43_WARN_ON(ring->tx); 367 B43_WARN_ON(ring->tx);
368 dma_sync_single_for_device(ring->dev->dev->dma_dev, 368 ssb_dma_sync_single_for_device(ring->dev->dev,
369 addr, len, DMA_FROM_DEVICE); 369 addr, len, DMA_FROM_DEVICE);
370} 370}
371 371
372static inline 372static inline
@@ -381,7 +381,6 @@ static inline
381 381
382static int alloc_ringmemory(struct b43_dmaring *ring) 382static int alloc_ringmemory(struct b43_dmaring *ring)
383{ 383{
384 struct device *dma_dev = ring->dev->dev->dma_dev;
385 gfp_t flags = GFP_KERNEL; 384 gfp_t flags = GFP_KERNEL;
386 385
387 /* The specs call for 4K buffers for 30- and 32-bit DMA with 4K 386 /* The specs call for 4K buffers for 30- and 32-bit DMA with 4K
@@ -392,11 +391,14 @@ static int alloc_ringmemory(struct b43_dmaring *ring)
392 * For unknown reasons - possibly a hardware error - the BCM4311 rev 391 * For unknown reasons - possibly a hardware error - the BCM4311 rev
393 * 02, which uses 64-bit DMA, needs the ring buffer in very low memory, 392 * 02, which uses 64-bit DMA, needs the ring buffer in very low memory,
394 * which accounts for the GFP_DMA flag below. 393 * which accounts for the GFP_DMA flag below.
394 *
395 * The flags here must match the flags in free_ringmemory below!
395 */ 396 */
396 if (ring->type == B43_DMA_64BIT) 397 if (ring->type == B43_DMA_64BIT)
397 flags |= GFP_DMA; 398 flags |= GFP_DMA;
398 ring->descbase = dma_alloc_coherent(dma_dev, B43_DMA_RINGMEMSIZE, 399 ring->descbase = ssb_dma_alloc_consistent(ring->dev->dev,
399 &(ring->dmabase), flags); 400 B43_DMA_RINGMEMSIZE,
401 &(ring->dmabase), flags);
400 if (!ring->descbase) { 402 if (!ring->descbase) {
401 b43err(ring->dev->wl, "DMA ringmemory allocation failed\n"); 403 b43err(ring->dev->wl, "DMA ringmemory allocation failed\n");
402 return -ENOMEM; 404 return -ENOMEM;
@@ -408,10 +410,13 @@ static int alloc_ringmemory(struct b43_dmaring *ring)
408 410
409static void free_ringmemory(struct b43_dmaring *ring) 411static void free_ringmemory(struct b43_dmaring *ring)
410{ 412{
411 struct device *dma_dev = ring->dev->dev->dma_dev; 413 gfp_t flags = GFP_KERNEL;
414
415 if (ring->type == B43_DMA_64BIT)
416 flags |= GFP_DMA;
412 417
413 dma_free_coherent(dma_dev, B43_DMA_RINGMEMSIZE, 418 ssb_dma_free_consistent(ring->dev->dev, B43_DMA_RINGMEMSIZE,
414 ring->descbase, ring->dmabase); 419 ring->descbase, ring->dmabase, flags);
415} 420}
416 421
417/* Reset the RX DMA channel */ 422/* Reset the RX DMA channel */
@@ -518,7 +523,7 @@ static bool b43_dma_mapping_error(struct b43_dmaring *ring,
518 dma_addr_t addr, 523 dma_addr_t addr,
519 size_t buffersize, bool dma_to_device) 524 size_t buffersize, bool dma_to_device)
520{ 525{
521 if (unlikely(dma_mapping_error(addr))) 526 if (unlikely(ssb_dma_mapping_error(ring->dev->dev, addr)))
522 return 1; 527 return 1;
523 528
524 switch (ring->type) { 529 switch (ring->type) {
@@ -844,10 +849,10 @@ struct b43_dmaring *b43_setup_dmaring(struct b43_wldev *dev,
844 goto err_kfree_meta; 849 goto err_kfree_meta;
845 850
846 /* test for ability to dma to txhdr_cache */ 851 /* test for ability to dma to txhdr_cache */
847 dma_test = dma_map_single(dev->dev->dma_dev, 852 dma_test = ssb_dma_map_single(dev->dev,
848 ring->txhdr_cache, 853 ring->txhdr_cache,
849 b43_txhdr_size(dev), 854 b43_txhdr_size(dev),
850 DMA_TO_DEVICE); 855 DMA_TO_DEVICE);
851 856
852 if (b43_dma_mapping_error(ring, dma_test, 857 if (b43_dma_mapping_error(ring, dma_test,
853 b43_txhdr_size(dev), 1)) { 858 b43_txhdr_size(dev), 1)) {
@@ -859,10 +864,10 @@ struct b43_dmaring *b43_setup_dmaring(struct b43_wldev *dev,
859 if (!ring->txhdr_cache) 864 if (!ring->txhdr_cache)
860 goto err_kfree_meta; 865 goto err_kfree_meta;
861 866
862 dma_test = dma_map_single(dev->dev->dma_dev, 867 dma_test = ssb_dma_map_single(dev->dev,
863 ring->txhdr_cache, 868 ring->txhdr_cache,
864 b43_txhdr_size(dev), 869 b43_txhdr_size(dev),
865 DMA_TO_DEVICE); 870 DMA_TO_DEVICE);
866 871
867 if (b43_dma_mapping_error(ring, dma_test, 872 if (b43_dma_mapping_error(ring, dma_test,
868 b43_txhdr_size(dev), 1)) { 873 b43_txhdr_size(dev), 1)) {
@@ -873,9 +878,9 @@ struct b43_dmaring *b43_setup_dmaring(struct b43_wldev *dev,
873 } 878 }
874 } 879 }
875 880
876 dma_unmap_single(dev->dev->dma_dev, 881 ssb_dma_unmap_single(dev->dev,
877 dma_test, b43_txhdr_size(dev), 882 dma_test, b43_txhdr_size(dev),
878 DMA_TO_DEVICE); 883 DMA_TO_DEVICE);
879 } 884 }
880 885
881 err = alloc_ringmemory(ring); 886 err = alloc_ringmemory(ring);