diff options
author | Joerg Roedel <joerg.roedel@amd.com> | 2008-12-02 12:13:27 -0500 |
---|---|---|
committer | Joerg Roedel <joerg.roedel@amd.com> | 2009-01-03 08:11:55 -0500 |
commit | c156e347d6d3c36b6843c3b168eda61b9a02c827 (patch) | |
tree | d175cd43d1f70e5d10d4f27bf0f5eb2e268ec6fe /arch/x86/kernel/amd_iommu.c | |
parent | 6d98cd8043c13438e4ca8a9464893f0224198a30 (diff) |
AMD IOMMU: add domain init function for IOMMU API
Impact: add a generic function for allocation protection domains
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Diffstat (limited to 'arch/x86/kernel/amd_iommu.c')
-rw-r--r-- | arch/x86/kernel/amd_iommu.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c index 5d3f085289eb..6c0bd49cee5f 100644 --- a/arch/x86/kernel/amd_iommu.c +++ b/arch/x86/kernel/amd_iommu.c | |||
@@ -22,6 +22,9 @@ | |||
22 | #include <linux/bitops.h> | 22 | #include <linux/bitops.h> |
23 | #include <linux/scatterlist.h> | 23 | #include <linux/scatterlist.h> |
24 | #include <linux/iommu-helper.h> | 24 | #include <linux/iommu-helper.h> |
25 | #ifdef CONFIG_IOMMU_API | ||
26 | #include <linux/iommu.h> | ||
27 | #endif | ||
25 | #include <asm/proto.h> | 28 | #include <asm/proto.h> |
26 | #include <asm/iommu.h> | 29 | #include <asm/iommu.h> |
27 | #include <asm/gart.h> | 30 | #include <asm/gart.h> |
@@ -1606,4 +1609,31 @@ static void cleanup_domain(struct protection_domain *domain) | |||
1606 | write_unlock_irqrestore(&amd_iommu_devtable_lock, flags); | 1609 | write_unlock_irqrestore(&amd_iommu_devtable_lock, flags); |
1607 | } | 1610 | } |
1608 | 1611 | ||
1612 | static int amd_iommu_domain_init(struct iommu_domain *dom) | ||
1613 | { | ||
1614 | struct protection_domain *domain; | ||
1615 | |||
1616 | domain = kzalloc(sizeof(*domain), GFP_KERNEL); | ||
1617 | if (!domain) | ||
1618 | return -ENOMEM; | ||
1619 | |||
1620 | spin_lock_init(&domain->lock); | ||
1621 | domain->mode = PAGE_MODE_3_LEVEL; | ||
1622 | domain->id = domain_id_alloc(); | ||
1623 | if (!domain->id) | ||
1624 | goto out_free; | ||
1625 | domain->pt_root = (void *)get_zeroed_page(GFP_KERNEL); | ||
1626 | if (!domain->pt_root) | ||
1627 | goto out_free; | ||
1628 | |||
1629 | dom->priv = domain; | ||
1630 | |||
1631 | return 0; | ||
1632 | |||
1633 | out_free: | ||
1634 | kfree(domain); | ||
1635 | |||
1636 | return -ENOMEM; | ||
1637 | } | ||
1638 | |||
1609 | #endif | 1639 | #endif |