summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJoerg Roedel <jroedel@suse.de>2015-07-21 18:19:08 +0200
committerJoerg Roedel <jroedel@suse.de>2015-08-12 16:23:34 +0200
commitb608ac3b6d54c38d6cf0eb91547f0f960633eb2d (patch)
tree679d0b843dbc011273b50be6c1f0877f2707504f /drivers
parent42e8c186b595a32918933b3dec445f0bf0f486f6 (diff)
downloadblackbird-op-linux-b608ac3b6d54c38d6cf0eb91547f0f960633eb2d.tar.gz
blackbird-op-linux-b608ac3b6d54c38d6cf0eb91547f0f960633eb2d.zip
iommu/vt-d: Simplify domain_remove_one_dev_info()
Simplify this function as much as possible with the new iommu_refcnt field. Signed-off-by: Joerg Roedel <jroedel@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/iommu/intel-iommu.c50
1 files changed, 16 insertions, 34 deletions
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index 57c115cb351b..d241353226c5 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -4610,52 +4610,34 @@ static void iommu_detach_dependent_devices(struct intel_iommu *iommu,
static void domain_remove_one_dev_info(struct dmar_domain *domain,
struct device *dev)
{
- struct device_domain_info *info, *tmp;
+ struct device_domain_info *info;
struct intel_iommu *iommu;
unsigned long flags;
- bool found = false;
u8 bus, devfn;
iommu = device_to_iommu(dev, &bus, &devfn);
if (!iommu)
return;
- spin_lock_irqsave(&device_domain_lock, flags);
- list_for_each_entry_safe(info, tmp, &domain->devices, link) {
- if (info->iommu == iommu && info->bus == bus &&
- info->devfn == devfn) {
- unlink_domain_info(info);
- spin_unlock_irqrestore(&device_domain_lock, flags);
-
- iommu_disable_dev_iotlb(info);
- iommu_detach_dev(iommu, info->bus, info->devfn);
- iommu_detach_dependent_devices(iommu, dev);
- free_devinfo_mem(info);
-
- spin_lock_irqsave(&device_domain_lock, flags);
-
- if (found)
- break;
- else
- continue;
- }
+ info = dev->archdata.iommu;
- /*
- * If there is no other devices under the same iommu owned by
- * this domain, clear this iommu in iommu_refcnt update iommu
- * count and coherency.
- */
- if (info->iommu == iommu)
- found = true;
- }
+ if (WARN_ON(!info))
+ return;
+ spin_lock_irqsave(&device_domain_lock, flags);
+ unlink_domain_info(info);
spin_unlock_irqrestore(&device_domain_lock, flags);
- if (found == 0) {
- domain_detach_iommu(domain, iommu);
- if (!domain_type_is_vm_or_si(domain))
- iommu_detach_domain(domain, iommu);
- }
+ iommu_disable_dev_iotlb(info);
+ iommu_detach_dev(iommu, info->bus, info->devfn);
+ iommu_detach_dependent_devices(iommu, dev);
+ free_devinfo_mem(info);
+ domain_detach_iommu(domain, iommu);
+
+ spin_lock_irqsave(&domain->iommu_lock, flags);
+ if (!domain->iommu_refcnt[iommu->seq_id])
+ iommu_detach_domain(domain, iommu);
+ spin_unlock_irqrestore(&domain->iommu_lock, flags);
}
static int md_domain_init(struct dmar_domain *domain, int guest_width)
OpenPOWER on IntegriCloud