aboutsummaryrefslogtreecommitdiffstats
path: root/lib/swiotlb.c
diff options
context:
space:
mode:
authorArthur Kepner <akepner@sgi.com>2008-04-29 04:00:32 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-04-29 11:06:12 -0400
commit309df0c503c35fbb5a09537fcbb1f4967b9ca489 (patch)
tree56a9df627a229bd64b934608b5f84d20bdaabf3a /lib/swiotlb.c
parenta75b0a2f68d3937f96ed39525e4750601483e3b4 (diff)
dma/ia64: update ia64 machvecs, swiotlb.c
Change all ia64 machvecs to use the new dma_*map*_attrs() interfaces. Implement the old dma_*map_*() interfaces in terms of the corresponding new interfaces. For ia64/sn, make use of one dma attribute, DMA_ATTR_WRITE_BARRIER. Introduce swiotlb_*map*_attrs() functions. Signed-off-by: Arthur Kepner <akepner@sgi.com> Cc: Tony Luck <tony.luck@intel.com> Cc: Jesse Barnes <jbarnes@virtuousgeek.org> Cc: Jes Sorensen <jes@sgi.com> Cc: Randy Dunlap <randy.dunlap@oracle.com> Cc: Roland Dreier <rdreier@cisco.com> Cc: James Bottomley <James.Bottomley@HansenPartnership.com> Cc: David Miller <davem@davemloft.net> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Grant Grundler <grundler@parisc-linux.org> Cc: Michael Ellerman <michael@ellerman.id.au> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'lib/swiotlb.c')
-rw-r--r--lib/swiotlb.c50
1 files changed, 42 insertions, 8 deletions
diff --git a/lib/swiotlb.c b/lib/swiotlb.c
index 3c95922e51e7..d568894df8cc 100644
--- a/lib/swiotlb.c
+++ b/lib/swiotlb.c
@@ -555,7 +555,8 @@ swiotlb_full(struct device *dev, size_t size, int dir, int do_panic)
555 * either swiotlb_unmap_single or swiotlb_dma_sync_single is performed. 555 * either swiotlb_unmap_single or swiotlb_dma_sync_single is performed.
556 */ 556 */
557dma_addr_t 557dma_addr_t
558swiotlb_map_single(struct device *hwdev, void *ptr, size_t size, int dir) 558swiotlb_map_single_attrs(struct device *hwdev, void *ptr, size_t size,
559 int dir, struct dma_attrs *attrs)
559{ 560{
560 dma_addr_t dev_addr = virt_to_bus(ptr); 561 dma_addr_t dev_addr = virt_to_bus(ptr);
561 void *map; 562 void *map;
@@ -588,6 +589,13 @@ swiotlb_map_single(struct device *hwdev, void *ptr, size_t size, int dir)
588 589
589 return dev_addr; 590 return dev_addr;
590} 591}
592EXPORT_SYMBOL(swiotlb_map_single_attrs);
593
594dma_addr_t
595swiotlb_map_single(struct device *hwdev, void *ptr, size_t size, int dir)
596{
597 return swiotlb_map_single_attrs(hwdev, ptr, size, dir, NULL);
598}
591 599
592/* 600/*
593 * Unmap a single streaming mode DMA translation. The dma_addr and size must 601 * Unmap a single streaming mode DMA translation. The dma_addr and size must
@@ -598,8 +606,8 @@ swiotlb_map_single(struct device *hwdev, void *ptr, size_t size, int dir)
598 * whatever the device wrote there. 606 * whatever the device wrote there.
599 */ 607 */
600void 608void
601swiotlb_unmap_single(struct device *hwdev, dma_addr_t dev_addr, size_t size, 609swiotlb_unmap_single_attrs(struct device *hwdev, dma_addr_t dev_addr,
602 int dir) 610 size_t size, int dir, struct dma_attrs *attrs)
603{ 611{
604 char *dma_addr = bus_to_virt(dev_addr); 612 char *dma_addr = bus_to_virt(dev_addr);
605 613
@@ -609,7 +617,14 @@ swiotlb_unmap_single(struct device *hwdev, dma_addr_t dev_addr, size_t size,
609 else if (dir == DMA_FROM_DEVICE) 617 else if (dir == DMA_FROM_DEVICE)
610 dma_mark_clean(dma_addr, size); 618 dma_mark_clean(dma_addr, size);
611} 619}
620EXPORT_SYMBOL(swiotlb_unmap_single_attrs);
612 621
622void
623swiotlb_unmap_single(struct device *hwdev, dma_addr_t dev_addr, size_t size,
624 int dir)
625{
626 return swiotlb_unmap_single_attrs(hwdev, dev_addr, size, dir, NULL);
627}
613/* 628/*
614 * Make physical memory consistent for a single streaming mode DMA translation 629 * Make physical memory consistent for a single streaming mode DMA translation
615 * after a transfer. 630 * after a transfer.
@@ -680,6 +695,8 @@ swiotlb_sync_single_range_for_device(struct device *hwdev, dma_addr_t dev_addr,
680 SYNC_FOR_DEVICE); 695 SYNC_FOR_DEVICE);
681} 696}
682 697
698void swiotlb_unmap_sg_attrs(struct device *, struct scatterlist *, int, int,
699 struct dma_attrs *);
683/* 700/*
684 * Map a set of buffers described by scatterlist in streaming mode for DMA. 701 * Map a set of buffers described by scatterlist in streaming mode for DMA.
685 * This is the scatter-gather version of the above swiotlb_map_single 702 * This is the scatter-gather version of the above swiotlb_map_single
@@ -697,8 +714,8 @@ swiotlb_sync_single_range_for_device(struct device *hwdev, dma_addr_t dev_addr,
697 * same here. 714 * same here.
698 */ 715 */
699int 716int
700swiotlb_map_sg(struct device *hwdev, struct scatterlist *sgl, int nelems, 717swiotlb_map_sg_attrs(struct device *hwdev, struct scatterlist *sgl, int nelems,
701 int dir) 718 int dir, struct dma_attrs *attrs)
702{ 719{
703 struct scatterlist *sg; 720 struct scatterlist *sg;
704 void *addr; 721 void *addr;
@@ -716,7 +733,8 @@ swiotlb_map_sg(struct device *hwdev, struct scatterlist *sgl, int nelems,
716 /* Don't panic here, we expect map_sg users 733 /* Don't panic here, we expect map_sg users
717 to do proper error handling. */ 734 to do proper error handling. */
718 swiotlb_full(hwdev, sg->length, dir, 0); 735 swiotlb_full(hwdev, sg->length, dir, 0);
719 swiotlb_unmap_sg(hwdev, sgl, i, dir); 736 swiotlb_unmap_sg_attrs(hwdev, sgl, i, dir,
737 attrs);
720 sgl[0].dma_length = 0; 738 sgl[0].dma_length = 0;
721 return 0; 739 return 0;
722 } 740 }
@@ -727,14 +745,22 @@ swiotlb_map_sg(struct device *hwdev, struct scatterlist *sgl, int nelems,
727 } 745 }
728 return nelems; 746 return nelems;
729} 747}
748EXPORT_SYMBOL(swiotlb_map_sg_attrs);
749
750int
751swiotlb_map_sg(struct device *hwdev, struct scatterlist *sgl, int nelems,
752 int dir)
753{
754 return swiotlb_map_sg_attrs(hwdev, sgl, nelems, dir, NULL);
755}
730 756
731/* 757/*
732 * Unmap a set of streaming mode DMA translations. Again, cpu read rules 758 * Unmap a set of streaming mode DMA translations. Again, cpu read rules
733 * concerning calls here are the same as for swiotlb_unmap_single() above. 759 * concerning calls here are the same as for swiotlb_unmap_single() above.
734 */ 760 */
735void 761void
736swiotlb_unmap_sg(struct device *hwdev, struct scatterlist *sgl, int nelems, 762swiotlb_unmap_sg_attrs(struct device *hwdev, struct scatterlist *sgl,
737 int dir) 763 int nelems, int dir, struct dma_attrs *attrs)
738{ 764{
739 struct scatterlist *sg; 765 struct scatterlist *sg;
740 int i; 766 int i;
@@ -749,6 +775,14 @@ swiotlb_unmap_sg(struct device *hwdev, struct scatterlist *sgl, int nelems,
749 dma_mark_clean(SG_ENT_VIRT_ADDRESS(sg), sg->dma_length); 775 dma_mark_clean(SG_ENT_VIRT_ADDRESS(sg), sg->dma_length);
750 } 776 }
751} 777}
778EXPORT_SYMBOL(swiotlb_unmap_sg_attrs);
779
780void
781swiotlb_unmap_sg(struct device *hwdev, struct scatterlist *sgl, int nelems,
782 int dir)
783{
784 return swiotlb_unmap_sg_attrs(hwdev, sgl, nelems, dir, NULL);
785}
752 786
753/* 787/*
754 * Make physical memory consistent for a set of streaming mode DMA translations 788 * Make physical memory consistent for a set of streaming mode DMA translations