diff options
Diffstat (limited to 'arch')
-rw-r--r-- | arch/arm/common/dmabounce.c | 46 | ||||
-rw-r--r-- | arch/arm/mm/dma-mapping.c | 24 |
2 files changed, 16 insertions, 54 deletions
diff --git a/arch/arm/common/dmabounce.c b/arch/arm/common/dmabounce.c index c7f23ced0a36..20d967376fa9 100644 --- a/arch/arm/common/dmabounce.c +++ b/arch/arm/common/dmabounce.c | |||
@@ -444,50 +444,6 @@ dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size, | |||
444 | unmap_single(dev, dma_addr, size, dir); | 444 | unmap_single(dev, dma_addr, size, dir); |
445 | } | 445 | } |
446 | 446 | ||
447 | int | ||
448 | dma_map_sg(struct device *dev, struct scatterlist *sg, int nents, | ||
449 | enum dma_data_direction dir) | ||
450 | { | ||
451 | struct scatterlist *s; | ||
452 | int i; | ||
453 | |||
454 | dev_dbg(dev, "%s(sg=%p,nents=%d,dir=%x)\n", | ||
455 | __func__, sg, nents, dir); | ||
456 | |||
457 | BUG_ON(dir == DMA_NONE); | ||
458 | |||
459 | for_each_sg(sg, s, nents, i) { | ||
460 | struct page *page = sg_page(s); | ||
461 | unsigned int offset = s->offset; | ||
462 | unsigned int length = s->length; | ||
463 | void *ptr = page_address(page) + offset; | ||
464 | |||
465 | s->dma_address = map_single(dev, ptr, length, dir); | ||
466 | } | ||
467 | |||
468 | return nents; | ||
469 | } | ||
470 | |||
471 | void | ||
472 | dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nents, | ||
473 | enum dma_data_direction dir) | ||
474 | { | ||
475 | struct scatterlist *s; | ||
476 | int i; | ||
477 | |||
478 | dev_dbg(dev, "%s(sg=%p,nents=%d,dir=%x)\n", | ||
479 | __func__, sg, nents, dir); | ||
480 | |||
481 | BUG_ON(dir == DMA_NONE); | ||
482 | |||
483 | for_each_sg(sg, s, nents, i) { | ||
484 | dma_addr_t dma_addr = s->dma_address; | ||
485 | unsigned int length = s->length; | ||
486 | |||
487 | unmap_single(dev, dma_addr, length, dir); | ||
488 | } | ||
489 | } | ||
490 | |||
491 | void dma_sync_single_range_for_cpu(struct device *dev, dma_addr_t dma_addr, | 447 | void dma_sync_single_range_for_cpu(struct device *dev, dma_addr_t dma_addr, |
492 | unsigned long offset, size_t size, | 448 | unsigned long offset, size_t size, |
493 | enum dma_data_direction dir) | 449 | enum dma_data_direction dir) |
@@ -662,8 +618,6 @@ dmabounce_unregister_dev(struct device *dev) | |||
662 | 618 | ||
663 | EXPORT_SYMBOL(dma_map_single); | 619 | EXPORT_SYMBOL(dma_map_single); |
664 | EXPORT_SYMBOL(dma_unmap_single); | 620 | EXPORT_SYMBOL(dma_unmap_single); |
665 | EXPORT_SYMBOL(dma_map_sg); | ||
666 | EXPORT_SYMBOL(dma_unmap_sg); | ||
667 | EXPORT_SYMBOL(dma_sync_sg_for_cpu); | 621 | EXPORT_SYMBOL(dma_sync_sg_for_cpu); |
668 | EXPORT_SYMBOL(dma_sync_sg_for_device); | 622 | EXPORT_SYMBOL(dma_sync_sg_for_device); |
669 | EXPORT_SYMBOL(dmabounce_register_dev); | 623 | EXPORT_SYMBOL(dmabounce_register_dev); |
diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index 7bf3e6fdfb57..c9c1206e358c 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c | |||
@@ -513,7 +513,6 @@ void dma_cache_maint(const void *start, size_t size, int direction) | |||
513 | } | 513 | } |
514 | EXPORT_SYMBOL(dma_cache_maint); | 514 | EXPORT_SYMBOL(dma_cache_maint); |
515 | 515 | ||
516 | #ifndef CONFIG_DMABOUNCE | ||
517 | /** | 516 | /** |
518 | * dma_map_sg - map a set of SG buffers for streaming mode DMA | 517 | * dma_map_sg - map a set of SG buffers for streaming mode DMA |
519 | * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices | 518 | * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices |
@@ -534,16 +533,20 @@ int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents, | |||
534 | enum dma_data_direction dir) | 533 | enum dma_data_direction dir) |
535 | { | 534 | { |
536 | struct scatterlist *s; | 535 | struct scatterlist *s; |
537 | int i; | 536 | int i, j; |
538 | 537 | ||
539 | for_each_sg(sg, s, nents, i) { | 538 | for_each_sg(sg, s, nents, i) { |
540 | s->dma_address = page_to_dma(dev, sg_page(s)) + s->offset; | 539 | s->dma_address = dma_map_page(dev, sg_page(s), s->offset, |
541 | 540 | s->length, dir); | |
542 | if (!arch_is_coherent()) | 541 | if (dma_mapping_error(dev, s->dma_address)) |
543 | dma_cache_maint(sg_virt(s), s->length, dir); | 542 | goto bad_mapping; |
544 | } | 543 | } |
545 | |||
546 | return nents; | 544 | return nents; |
545 | |||
546 | bad_mapping: | ||
547 | for_each_sg(sg, s, i, j) | ||
548 | dma_unmap_page(dev, sg_dma_address(s), sg_dma_len(s), dir); | ||
549 | return 0; | ||
547 | } | 550 | } |
548 | EXPORT_SYMBOL(dma_map_sg); | 551 | EXPORT_SYMBOL(dma_map_sg); |
549 | 552 | ||
@@ -560,10 +563,15 @@ EXPORT_SYMBOL(dma_map_sg); | |||
560 | void dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nents, | 563 | void dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nents, |
561 | enum dma_data_direction dir) | 564 | enum dma_data_direction dir) |
562 | { | 565 | { |
563 | /* nothing to do */ | 566 | struct scatterlist *s; |
567 | int i; | ||
568 | |||
569 | for_each_sg(sg, s, nents, i) | ||
570 | dma_unmap_page(dev, sg_dma_address(s), sg_dma_len(s), dir); | ||
564 | } | 571 | } |
565 | EXPORT_SYMBOL(dma_unmap_sg); | 572 | EXPORT_SYMBOL(dma_unmap_sg); |
566 | 573 | ||
574 | #ifndef CONFIG_DMABOUNCE | ||
567 | /** | 575 | /** |
568 | * dma_sync_sg_for_cpu | 576 | * dma_sync_sg_for_cpu |
569 | * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices | 577 | * @dev: valid struct device pointer, or NULL for ISA and EISA-like devices |