diff options
author | Joerg Roedel <joerg.roedel@amd.com> | 2008-09-04 09:49:46 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-09-19 06:59:04 -0400 |
commit | 270cab2426cdc6307725e4f1f46ecf8ab8e69193 (patch) | |
tree | 1a0910df4d496b6535fe4e7e063a8e1fac902180 /arch/x86/kernel/amd_iommu.c | |
parent | dbcc112e3b5367e81a845b082933506b0ff1d1e2 (diff) |
AMD IOMMU: move TLB flushing to the map/unmap helper functions
This patch moves the invocation of the flushing functions to the
map/unmap helpers because its common code in all dma_ops relevant
mapping/unmapping code.
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86/kernel/amd_iommu.c')
-rw-r--r-- | arch/x86/kernel/amd_iommu.c | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c index 695e0fc41b10..691e023695ad 100644 --- a/arch/x86/kernel/amd_iommu.c +++ b/arch/x86/kernel/amd_iommu.c | |||
@@ -795,6 +795,9 @@ static dma_addr_t __map_single(struct device *dev, | |||
795 | } | 795 | } |
796 | address += offset; | 796 | address += offset; |
797 | 797 | ||
798 | if (unlikely(iommu_has_npcache(iommu))) | ||
799 | iommu_flush_pages(iommu, dma_dom->domain.id, address, size); | ||
800 | |||
798 | out: | 801 | out: |
799 | return address; | 802 | return address; |
800 | } | 803 | } |
@@ -825,6 +828,8 @@ static void __unmap_single(struct amd_iommu *iommu, | |||
825 | } | 828 | } |
826 | 829 | ||
827 | dma_ops_free_addresses(dma_dom, dma_addr, pages); | 830 | dma_ops_free_addresses(dma_dom, dma_addr, pages); |
831 | |||
832 | iommu_flush_pages(iommu, dma_dom->domain.id, dma_addr, size); | ||
828 | } | 833 | } |
829 | 834 | ||
830 | /* | 835 | /* |
@@ -853,9 +858,6 @@ static dma_addr_t map_single(struct device *dev, phys_addr_t paddr, | |||
853 | if (addr == bad_dma_address) | 858 | if (addr == bad_dma_address) |
854 | goto out; | 859 | goto out; |
855 | 860 | ||
856 | if (iommu_has_npcache(iommu)) | ||
857 | iommu_flush_pages(iommu, domain->id, addr, size); | ||
858 | |||
859 | if (iommu->need_sync) | 861 | if (iommu->need_sync) |
860 | iommu_completion_wait(iommu); | 862 | iommu_completion_wait(iommu); |
861 | 863 | ||
@@ -885,8 +887,6 @@ static void unmap_single(struct device *dev, dma_addr_t dma_addr, | |||
885 | 887 | ||
886 | __unmap_single(iommu, domain->priv, dma_addr, size, dir); | 888 | __unmap_single(iommu, domain->priv, dma_addr, size, dir); |
887 | 889 | ||
888 | iommu_flush_pages(iommu, domain->id, dma_addr, size); | ||
889 | |||
890 | if (iommu->need_sync) | 890 | if (iommu->need_sync) |
891 | iommu_completion_wait(iommu); | 891 | iommu_completion_wait(iommu); |
892 | 892 | ||
@@ -948,9 +948,6 @@ static int map_sg(struct device *dev, struct scatterlist *sglist, | |||
948 | mapped_elems++; | 948 | mapped_elems++; |
949 | } else | 949 | } else |
950 | goto unmap; | 950 | goto unmap; |
951 | if (iommu_has_npcache(iommu)) | ||
952 | iommu_flush_pages(iommu, domain->id, s->dma_address, | ||
953 | s->dma_length); | ||
954 | } | 951 | } |
955 | 952 | ||
956 | if (iommu->need_sync) | 953 | if (iommu->need_sync) |
@@ -996,8 +993,6 @@ static void unmap_sg(struct device *dev, struct scatterlist *sglist, | |||
996 | for_each_sg(sglist, s, nelems, i) { | 993 | for_each_sg(sglist, s, nelems, i) { |
997 | __unmap_single(iommu, domain->priv, s->dma_address, | 994 | __unmap_single(iommu, domain->priv, s->dma_address, |
998 | s->dma_length, dir); | 995 | s->dma_length, dir); |
999 | iommu_flush_pages(iommu, domain->id, s->dma_address, | ||
1000 | s->dma_length); | ||
1001 | s->dma_address = s->dma_length = 0; | 996 | s->dma_address = s->dma_length = 0; |
1002 | } | 997 | } |
1003 | 998 | ||
@@ -1048,9 +1043,6 @@ static void *alloc_coherent(struct device *dev, size_t size, | |||
1048 | goto out; | 1043 | goto out; |
1049 | } | 1044 | } |
1050 | 1045 | ||
1051 | if (iommu_has_npcache(iommu)) | ||
1052 | iommu_flush_pages(iommu, domain->id, *dma_addr, size); | ||
1053 | |||
1054 | if (iommu->need_sync) | 1046 | if (iommu->need_sync) |
1055 | iommu_completion_wait(iommu); | 1047 | iommu_completion_wait(iommu); |
1056 | 1048 | ||
@@ -1082,7 +1074,6 @@ static void free_coherent(struct device *dev, size_t size, | |||
1082 | spin_lock_irqsave(&domain->lock, flags); | 1074 | spin_lock_irqsave(&domain->lock, flags); |
1083 | 1075 | ||
1084 | __unmap_single(iommu, domain->priv, dma_addr, size, DMA_BIDIRECTIONAL); | 1076 | __unmap_single(iommu, domain->priv, dma_addr, size, DMA_BIDIRECTIONAL); |
1085 | iommu_flush_pages(iommu, domain->id, dma_addr, size); | ||
1086 | 1077 | ||
1087 | if (iommu->need_sync) | 1078 | if (iommu->need_sync) |
1088 | iommu_completion_wait(iommu); | 1079 | iommu_completion_wait(iommu); |