Skip to content

Commit e241142

Browse files
committed
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>
1 parent 8bf4781 commit e241142

File tree

1 file changed

+10
-16
lines changed

1 file changed

+10
-16
lines changed

drivers/iommu/intel-iommu.c

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1671,8 +1671,13 @@ static int __iommu_attach_domain(struct dmar_domain *domain,
16711671
int num;
16721672
unsigned long ndomains;
16731673

1674+
num = domain->iommu_did[iommu->seq_id];
1675+
if (num)
1676+
return num;
1677+
16741678
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+
16761681
if (num < ndomains) {
16771682
set_bit(num, iommu->domain_ids);
16781683
set_iommu_domain(iommu, num, domain);
@@ -1681,6 +1686,9 @@ static int __iommu_attach_domain(struct dmar_domain *domain,
16811686
num = -ENOSPC;
16821687
}
16831688

1689+
if (num < 0)
1690+
pr_err("%s: No free domain ids\n", iommu->name);
1691+
16841692
return num;
16851693
}
16861694

@@ -1693,24 +1701,10 @@ static int iommu_attach_domain(struct dmar_domain *domain,
16931701
spin_lock_irqsave(&iommu->lock, flags);
16941702
num = __iommu_attach_domain(domain, iommu);
16951703
spin_unlock_irqrestore(&iommu->lock, flags);
1696-
if (num < 0)
1697-
pr_err("%s: No free domain ids\n", iommu->name);
16981704

16991705
return num;
17001706
}
17011707

1702-
static 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-
17141708
static void iommu_detach_domain(struct dmar_domain *domain,
17151709
struct intel_iommu *iommu)
17161710
{
@@ -1947,7 +1941,7 @@ static int domain_context_mapping_one(struct dmar_domain *domain,
19471941

19481942
if (domain_type_is_vm_or_si(domain)) {
19491943
if (domain_type_is_vm(domain)) {
1950-
id = iommu_attach_vm_domain(domain, iommu);
1944+
id = __iommu_attach_domain(domain, iommu);
19511945
if (id < 0) {
19521946
spin_unlock_irqrestore(&iommu->lock, flags);
19531947
pr_err("%s: No free domain ids\n", iommu->name);

0 commit comments

Comments
 (0)