aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/amd_iommu.c
diff options
context:
space:
mode:
authorJoerg Roedel <joerg.roedel@amd.com>2008-06-26 15:28:05 -0400
committerIngo Molnar <mingo@elte.hu>2008-06-27 04:12:20 -0400
commit6631ee9d00996e7663a086b5abceba65c89ff8f6 (patch)
tree69031709fde8581aae29b6ffd6fda8c2e5535326 /arch/x86/kernel/amd_iommu.c
parentc432f3df8ea740e2ecb27da88bd6b5a254714959 (diff)
x86, AMD IOMMU: add dma_ops initialization function
This patch adds the function to initialize the dma_ops for the AMD IOMMU. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Cc: iommu@lists.linux-foundation.org Cc: bhavna.sarathy@amd.com Cc: Sebastian.Biemueller@amd.com Cc: robert.richter@amd.com Cc: joro@8bytes.org 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.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c
index bed5f820898d..c282bdec1650 100644
--- a/arch/x86/kernel/amd_iommu.c
+++ b/arch/x86/kernel/amd_iommu.c
@@ -906,3 +906,49 @@ void prealloc_protection_domains(void)
906 } 906 }
907} 907}
908 908
909static struct dma_mapping_ops amd_iommu_dma_ops = {
910 .alloc_coherent = alloc_coherent,
911 .free_coherent = free_coherent,
912 .map_single = map_single,
913 .unmap_single = unmap_single,
914 .map_sg = map_sg,
915 .unmap_sg = unmap_sg,
916};
917
918int __init amd_iommu_init_dma_ops(void)
919{
920 struct amd_iommu *iommu;
921 int order = amd_iommu_aperture_order;
922 int ret;
923
924 list_for_each_entry(iommu, &amd_iommu_list, list) {
925 iommu->default_dom = dma_ops_domain_alloc(iommu, order);
926 if (iommu->default_dom == NULL)
927 return -ENOMEM;
928 ret = iommu_init_unity_mappings(iommu);
929 if (ret)
930 goto free_domains;
931 }
932
933 if (amd_iommu_isolate)
934 prealloc_protection_domains();
935
936 iommu_detected = 1;
937 force_iommu = 1;
938 bad_dma_address = 0;
939 gart_iommu_aperture_disabled = 1;
940 gart_iommu_aperture = 0;
941
942 dma_ops = &amd_iommu_dma_ops;
943
944 return 0;
945
946free_domains:
947
948 list_for_each_entry(iommu, &amd_iommu_list, list) {
949 if (iommu->default_dom)
950 dma_ops_domain_free(iommu->default_dom);
951 }
952
953 return ret;
954}