aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iommu
diff options
context:
space:
mode:
authorDavid Woodhouse <dwmw2@infradead.org>2014-03-11 20:10:29 -0400
committerDavid Woodhouse <David.Woodhouse@intel.com>2014-03-19 13:25:48 -0400
commitd05019608746240d86a406fbf8d8c1fc71a87101 (patch)
tree8a5732ae72564c14dfa1013f7904be53b911734c /drivers/iommu
parent214e39aa36c9c02355d388f20d83b93fc2fa7298 (diff)
iommu/vt-d: Be less pessimistic about domain coherency where possible
In commit 2e12bc29 ("intel-iommu: Default to non-coherent for domains unattached to iommus") we decided to err on the side of caution and always assume that it's possible that a device will be attached which is behind a non-coherent IOMMU. In some cases, however, that just *cannot* happen. If there *are* no IOMMUs in the system which are non-coherent, then we don't need to do it. And flushing the dcache is a *significant* performance hit. Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers/iommu')
-rw-r--r--drivers/iommu/intel-iommu.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index c3d4bc91a189..1599cb1e041c 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -592,18 +592,31 @@ static struct intel_iommu *domain_get_iommu(struct dmar_domain *domain)
592 592
593static void domain_update_iommu_coherency(struct dmar_domain *domain) 593static void domain_update_iommu_coherency(struct dmar_domain *domain)
594{ 594{
595 int i; 595 struct dmar_drhd_unit *drhd;
596 596 struct intel_iommu *iommu;
597 i = find_first_bit(domain->iommu_bmp, g_num_of_iommus); 597 int i, found = 0;
598 598
599 domain->iommu_coherency = i < g_num_of_iommus ? 1 : 0; 599 domain->iommu_coherency = 1;
600 600
601 for_each_set_bit(i, domain->iommu_bmp, g_num_of_iommus) { 601 for_each_set_bit(i, domain->iommu_bmp, g_num_of_iommus) {
602 found = 1;
602 if (!ecap_coherent(g_iommus[i]->ecap)) { 603 if (!ecap_coherent(g_iommus[i]->ecap)) {
603 domain->iommu_coherency = 0; 604 domain->iommu_coherency = 0;
604 break; 605 break;
605 } 606 }
606 } 607 }
608 if (found)
609 return;
610
611 /* No hardware attached; use lowest common denominator */
612 rcu_read_lock();
613 for_each_active_iommu(iommu, drhd) {
614 if (!ecap_coherent(iommu->ecap)) {
615 domain->iommu_coherency = 0;
616 break;
617 }
618 }
619 rcu_read_unlock();
607} 620}
608 621
609static void domain_update_iommu_snooping(struct dmar_domain *domain) 622static void domain_update_iommu_snooping(struct dmar_domain *domain)