Commit 161f6934 authored by Jiang Liu's avatar Jiang Liu Committed by Joerg Roedel

iommu/vt-d: Fix issue in computing domain's iommu_snooping flag

IOMMU units may dynamically attached to/detached from domains,
so we should scan all active IOMMU units when computing iommu_snooping
flag for a domain instead of only scanning IOMMU units associated
with the domain.

Also check snooping and superpage capabilities when hot-adding DMAR units.
Signed-off-by: default avatarJiang Liu <jiang.liu@linux.intel.com>
Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
parent a156ef99
...@@ -633,50 +633,56 @@ static void domain_update_iommu_coherency(struct dmar_domain *domain) ...@@ -633,50 +633,56 @@ static void domain_update_iommu_coherency(struct dmar_domain *domain)
rcu_read_unlock(); rcu_read_unlock();
} }
static void domain_update_iommu_snooping(struct dmar_domain *domain) static int domain_update_iommu_snooping(struct intel_iommu *skip)
{ {
int i; struct dmar_drhd_unit *drhd;
struct intel_iommu *iommu;
domain->iommu_snooping = 1; int ret = 1;
for_each_set_bit(i, domain->iommu_bmp, g_num_of_iommus) { rcu_read_lock();
if (!ecap_sc_support(g_iommus[i]->ecap)) { for_each_active_iommu(iommu, drhd) {
domain->iommu_snooping = 0; if (iommu != skip) {
break; if (!ecap_sc_support(iommu->ecap)) {
ret = 0;
break;
}
} }
} }
rcu_read_unlock();
return ret;
} }
static void domain_update_iommu_superpage(struct dmar_domain *domain) static int domain_update_iommu_superpage(struct intel_iommu *skip)
{ {
struct dmar_drhd_unit *drhd; struct dmar_drhd_unit *drhd;
struct intel_iommu *iommu = NULL; struct intel_iommu *iommu;
int mask = 0xf; int mask = 0xf;
if (!intel_iommu_superpage) { if (!intel_iommu_superpage) {
domain->iommu_superpage = 0; return 0;
return;
} }
/* set iommu_superpage to the smallest common denominator */ /* set iommu_superpage to the smallest common denominator */
rcu_read_lock(); rcu_read_lock();
for_each_active_iommu(iommu, drhd) { for_each_active_iommu(iommu, drhd) {
mask &= cap_super_page_val(iommu->cap); if (iommu != skip) {
if (!mask) { mask &= cap_super_page_val(iommu->cap);
break; if (!mask)
break;
} }
} }
rcu_read_unlock(); rcu_read_unlock();
domain->iommu_superpage = fls(mask); return fls(mask);
} }
/* Some capabilities may be different across iommus */ /* Some capabilities may be different across iommus */
static void domain_update_iommu_cap(struct dmar_domain *domain) static void domain_update_iommu_cap(struct dmar_domain *domain)
{ {
domain_update_iommu_coherency(domain); domain_update_iommu_coherency(domain);
domain_update_iommu_snooping(domain); domain->iommu_snooping = domain_update_iommu_snooping(NULL);
domain_update_iommu_superpage(domain); domain->iommu_superpage = domain_update_iommu_superpage(NULL);
} }
static struct intel_iommu *device_to_iommu(struct device *dev, u8 *bus, u8 *devfn) static struct intel_iommu *device_to_iommu(struct device *dev, u8 *bus, u8 *devfn)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment