diff options
author | Alex Williamson <alex.williamson@redhat.com> | 2011-03-04 16:52:16 -0500 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2011-03-12 09:37:26 -0500 |
commit | a97590e56d0d58e1dd262353f7cbd84e81d8e600 (patch) | |
tree | 8e85cd61adfb8b40f0fb4af0d46e652c665da099 /drivers | |
parent | 7a6610139a1e1d9297dd1c5d178022eac36839cb (diff) |
intel-iommu: Unlink domain from iommu
When we remove a device, we unlink the iommu from the domain, but
we never do the reverse unlinking of the domain from the iommu.
This means that we never clear iommu->domain_ids, eventually leading
to resource exhaustion if we repeatedly bind and unbind a device
to a driver. Also free empty domains to avoid a resource leak.
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Acked-by: Donald Dutile <ddutile@redhat.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Cc: stable@kernel.org
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/pci/intel-iommu.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c index 35463ddf10a1..292f2233295e 100644 --- a/drivers/pci/intel-iommu.c +++ b/drivers/pci/intel-iommu.c | |||
@@ -3260,9 +3260,15 @@ static int device_notifier(struct notifier_block *nb, | |||
3260 | if (!domain) | 3260 | if (!domain) |
3261 | return 0; | 3261 | return 0; |
3262 | 3262 | ||
3263 | if (action == BUS_NOTIFY_UNBOUND_DRIVER && !iommu_pass_through) | 3263 | if (action == BUS_NOTIFY_UNBOUND_DRIVER && !iommu_pass_through) { |
3264 | domain_remove_one_dev_info(domain, pdev); | 3264 | domain_remove_one_dev_info(domain, pdev); |
3265 | 3265 | ||
3266 | if (!(domain->flags & DOMAIN_FLAG_VIRTUAL_MACHINE) && | ||
3267 | !(domain->flags & DOMAIN_FLAG_STATIC_IDENTITY) && | ||
3268 | list_empty(&domain->devices)) | ||
3269 | domain_exit(domain); | ||
3270 | } | ||
3271 | |||
3266 | return 0; | 3272 | return 0; |
3267 | } | 3273 | } |
3268 | 3274 | ||
@@ -3411,6 +3417,11 @@ static void domain_remove_one_dev_info(struct dmar_domain *domain, | |||
3411 | domain->iommu_count--; | 3417 | domain->iommu_count--; |
3412 | domain_update_iommu_cap(domain); | 3418 | domain_update_iommu_cap(domain); |
3413 | spin_unlock_irqrestore(&domain->iommu_lock, tmp_flags); | 3419 | spin_unlock_irqrestore(&domain->iommu_lock, tmp_flags); |
3420 | |||
3421 | spin_lock_irqsave(&iommu->lock, tmp_flags); | ||
3422 | clear_bit(domain->id, iommu->domain_ids); | ||
3423 | iommu->domains[domain->id] = NULL; | ||
3424 | spin_unlock_irqrestore(&iommu->lock, tmp_flags); | ||
3414 | } | 3425 | } |
3415 | 3426 | ||
3416 | spin_unlock_irqrestore(&device_domain_lock, flags); | 3427 | spin_unlock_irqrestore(&device_domain_lock, flags); |