diff options
author | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-16 13:09:16 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-16 13:09:16 -0400 |
commit | 92d15c2ccbb3e31a3fc71ad28fdb55e1319383c0 (patch) | |
tree | 8d83c0dc3c6b935d8367e331872f242b742f0a8a /lib | |
parent | f20bf6125605acbbc7eb8c9420d7221c91aa83eb (diff) | |
parent | 644bd2f048972d75eb1979b1fdca257d528ce687 (diff) |
Merge branch 'for-linus' of git://git.kernel.dk/data/git/linux-2.6-block
* 'for-linus' of git://git.kernel.dk/data/git/linux-2.6-block: (63 commits)
Fix memory leak in dm-crypt
SPARC64: sg chaining support
SPARC: sg chaining support
PPC: sg chaining support
PS3: sg chaining support
IA64: sg chaining support
x86-64: enable sg chaining
x86-64: update pci-gart iommu to sg helpers
x86-64: update nommu to sg helpers
x86-64: update calgary iommu to sg helpers
swiotlb: sg chaining support
i386: enable sg chaining
i386 dma_map_sg: convert to using sg helpers
mmc: need to zero sglist on init
Panic in blk_rq_map_sg() from CCISS driver
remove sglist_len
remove blk_queue_max_phys_segments in libata
revert sg segment size ifdefs
Fixup u14-34f ENABLE_SG_CHAINING
qla1280: enable use_sg_chaining option
...
Diffstat (limited to 'lib')
-rw-r--r-- | lib/swiotlb.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/lib/swiotlb.c b/lib/swiotlb.c index 30c1400e749e..c419ecf334c3 100644 --- a/lib/swiotlb.c +++ b/lib/swiotlb.c | |||
@@ -677,16 +677,17 @@ swiotlb_sync_single_range_for_device(struct device *hwdev, dma_addr_t dev_addr, | |||
677 | * same here. | 677 | * same here. |
678 | */ | 678 | */ |
679 | int | 679 | int |
680 | swiotlb_map_sg(struct device *hwdev, struct scatterlist *sg, int nelems, | 680 | swiotlb_map_sg(struct device *hwdev, struct scatterlist *sgl, int nelems, |
681 | int dir) | 681 | int dir) |
682 | { | 682 | { |
683 | struct scatterlist *sg; | ||
683 | void *addr; | 684 | void *addr; |
684 | dma_addr_t dev_addr; | 685 | dma_addr_t dev_addr; |
685 | int i; | 686 | int i; |
686 | 687 | ||
687 | BUG_ON(dir == DMA_NONE); | 688 | BUG_ON(dir == DMA_NONE); |
688 | 689 | ||
689 | for (i = 0; i < nelems; i++, sg++) { | 690 | for_each_sg(sgl, sg, nelems, i) { |
690 | addr = SG_ENT_VIRT_ADDRESS(sg); | 691 | addr = SG_ENT_VIRT_ADDRESS(sg); |
691 | dev_addr = virt_to_bus(addr); | 692 | dev_addr = virt_to_bus(addr); |
692 | if (swiotlb_force || address_needs_mapping(hwdev, dev_addr)) { | 693 | if (swiotlb_force || address_needs_mapping(hwdev, dev_addr)) { |
@@ -696,7 +697,7 @@ swiotlb_map_sg(struct device *hwdev, struct scatterlist *sg, int nelems, | |||
696 | to do proper error handling. */ | 697 | to do proper error handling. */ |
697 | swiotlb_full(hwdev, sg->length, dir, 0); | 698 | swiotlb_full(hwdev, sg->length, dir, 0); |
698 | swiotlb_unmap_sg(hwdev, sg - i, i, dir); | 699 | swiotlb_unmap_sg(hwdev, sg - i, i, dir); |
699 | sg[0].dma_length = 0; | 700 | sgl[0].dma_length = 0; |
700 | return 0; | 701 | return 0; |
701 | } | 702 | } |
702 | sg->dma_address = virt_to_bus(map); | 703 | sg->dma_address = virt_to_bus(map); |
@@ -712,19 +713,21 @@ swiotlb_map_sg(struct device *hwdev, struct scatterlist *sg, int nelems, | |||
712 | * concerning calls here are the same as for swiotlb_unmap_single() above. | 713 | * concerning calls here are the same as for swiotlb_unmap_single() above. |
713 | */ | 714 | */ |
714 | void | 715 | void |
715 | swiotlb_unmap_sg(struct device *hwdev, struct scatterlist *sg, int nelems, | 716 | swiotlb_unmap_sg(struct device *hwdev, struct scatterlist *sgl, int nelems, |
716 | int dir) | 717 | int dir) |
717 | { | 718 | { |
719 | struct scatterlist *sg; | ||
718 | int i; | 720 | int i; |
719 | 721 | ||
720 | BUG_ON(dir == DMA_NONE); | 722 | BUG_ON(dir == DMA_NONE); |
721 | 723 | ||
722 | for (i = 0; i < nelems; i++, sg++) | 724 | for_each_sg(sgl, sg, nelems, i) { |
723 | if (sg->dma_address != SG_ENT_PHYS_ADDRESS(sg)) | 725 | if (sg->dma_address != SG_ENT_PHYS_ADDRESS(sg)) |
724 | unmap_single(hwdev, bus_to_virt(sg->dma_address), | 726 | unmap_single(hwdev, bus_to_virt(sg->dma_address), |
725 | sg->dma_length, dir); | 727 | sg->dma_length, dir); |
726 | else if (dir == DMA_FROM_DEVICE) | 728 | else if (dir == DMA_FROM_DEVICE) |
727 | dma_mark_clean(SG_ENT_VIRT_ADDRESS(sg), sg->dma_length); | 729 | dma_mark_clean(SG_ENT_VIRT_ADDRESS(sg), sg->dma_length); |
730 | } | ||
728 | } | 731 | } |
729 | 732 | ||
730 | /* | 733 | /* |
@@ -735,19 +738,21 @@ swiotlb_unmap_sg(struct device *hwdev, struct scatterlist *sg, int nelems, | |||
735 | * and usage. | 738 | * and usage. |
736 | */ | 739 | */ |
737 | static void | 740 | static void |
738 | swiotlb_sync_sg(struct device *hwdev, struct scatterlist *sg, | 741 | swiotlb_sync_sg(struct device *hwdev, struct scatterlist *sgl, |
739 | int nelems, int dir, int target) | 742 | int nelems, int dir, int target) |
740 | { | 743 | { |
744 | struct scatterlist *sg; | ||
741 | int i; | 745 | int i; |
742 | 746 | ||
743 | BUG_ON(dir == DMA_NONE); | 747 | BUG_ON(dir == DMA_NONE); |
744 | 748 | ||
745 | for (i = 0; i < nelems; i++, sg++) | 749 | for_each_sg(sgl, sg, nelems, i) { |
746 | if (sg->dma_address != SG_ENT_PHYS_ADDRESS(sg)) | 750 | if (sg->dma_address != SG_ENT_PHYS_ADDRESS(sg)) |
747 | sync_single(hwdev, bus_to_virt(sg->dma_address), | 751 | sync_single(hwdev, bus_to_virt(sg->dma_address), |
748 | sg->dma_length, dir, target); | 752 | sg->dma_length, dir, target); |
749 | else if (dir == DMA_FROM_DEVICE) | 753 | else if (dir == DMA_FROM_DEVICE) |
750 | dma_mark_clean(SG_ENT_VIRT_ADDRESS(sg), sg->dma_length); | 754 | dma_mark_clean(SG_ENT_VIRT_ADDRESS(sg), sg->dma_length); |
755 | } | ||
751 | } | 756 | } |
752 | 757 | ||
753 | void | 758 | void |