aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iommu
diff options
context:
space:
mode:
authorJoerg Roedel <jroedel@suse.de>2015-07-21 05:18:21 -0400
committerJoerg Roedel <jroedel@suse.de>2015-08-12 10:23:33 -0400
commite2411427f7d3ddcf8d5f35d5ab0a397180deac3a (patch)
tree3feaaf3680770bf12713d58da5692e3931c2e0d0 /drivers/iommu
parent8bf478163e69e42973c7070179a11815139e5bf0 (diff)
iommu/vt-d: Get rid of iommu_attach_vm_domain()
The special case for VM domains is not needed, as other domains could be attached to the iommu in the same way. So get rid of this special case. Signed-off-by: Joerg Roedel <jroedel@suse.de>
Diffstat (limited to 'drivers/iommu')
-rw-r--r--drivers/iommu/intel-iommu.c26
1 files changed, 10 insertions, 16 deletions
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index 90ab4b0d975c..0a07b44fbc82 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -1671,8 +1671,13 @@ static int __iommu_attach_domain(struct dmar_domain *domain,
1671 int num; 1671 int num;
1672 unsigned long ndomains; 1672 unsigned long ndomains;
1673 1673
1674 num = domain->iommu_did[iommu->seq_id];
1675 if (num)
1676 return num;
1677
1674 ndomains = cap_ndoms(iommu->cap); 1678 ndomains = cap_ndoms(iommu->cap);
1675 num = find_first_zero_bit(iommu->domain_ids, ndomains); 1679 num = find_first_zero_bit(iommu->domain_ids, ndomains);
1680
1676 if (num < ndomains) { 1681 if (num < ndomains) {
1677 set_bit(num, iommu->domain_ids); 1682 set_bit(num, iommu->domain_ids);
1678 set_iommu_domain(iommu, num, domain); 1683 set_iommu_domain(iommu, num, domain);
@@ -1681,6 +1686,9 @@ static int __iommu_attach_domain(struct dmar_domain *domain,
1681 num = -ENOSPC; 1686 num = -ENOSPC;
1682 } 1687 }
1683 1688
1689 if (num < 0)
1690 pr_err("%s: No free domain ids\n", iommu->name);
1691
1684 return num; 1692 return num;
1685} 1693}
1686 1694
@@ -1693,24 +1701,10 @@ static int iommu_attach_domain(struct dmar_domain *domain,
1693 spin_lock_irqsave(&iommu->lock, flags); 1701 spin_lock_irqsave(&iommu->lock, flags);
1694 num = __iommu_attach_domain(domain, iommu); 1702 num = __iommu_attach_domain(domain, iommu);
1695 spin_unlock_irqrestore(&iommu->lock, flags); 1703 spin_unlock_irqrestore(&iommu->lock, flags);
1696 if (num < 0)
1697 pr_err("%s: No free domain ids\n", iommu->name);
1698 1704
1699 return num; 1705 return num;
1700} 1706}
1701 1707
1702static int iommu_attach_vm_domain(struct dmar_domain *domain,
1703 struct intel_iommu *iommu)
1704{
1705 int num;
1706
1707 num = domain->iommu_did[iommu->seq_id];
1708 if (num)
1709 return num;
1710
1711 return __iommu_attach_domain(domain, iommu);
1712}
1713
1714static void iommu_detach_domain(struct dmar_domain *domain, 1708static void iommu_detach_domain(struct dmar_domain *domain,
1715 struct intel_iommu *iommu) 1709 struct intel_iommu *iommu)
1716{ 1710{
@@ -1947,7 +1941,7 @@ static int domain_context_mapping_one(struct dmar_domain *domain,
1947 1941
1948 if (domain_type_is_vm_or_si(domain)) { 1942 if (domain_type_is_vm_or_si(domain)) {
1949 if (domain_type_is_vm(domain)) { 1943 if (domain_type_is_vm(domain)) {
1950 id = iommu_attach_vm_domain(domain, iommu); 1944 id = __iommu_attach_domain(domain, iommu);
1951 if (id < 0) { 1945 if (id < 0) {
1952 spin_unlock_irqrestore(&iommu->lock, flags); 1946 spin_unlock_irqrestore(&iommu->lock, flags);
1953 pr_err("%s: No free domain ids\n", iommu->name); 1947 pr_err("%s: No free domain ids\n", iommu->name);