mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-04-24 15:24:03 +00:00
iommu/vt-d: Simplify domain_context_mapping_one
Get rid of the special cases for VM domains vs. non-VM domains and simplify the code further to just handle the hardware passthrough vs. page-table case. Signed-off-by: Joerg Roedel <jroedel@suse.de>
This commit is contained in:
parent
28ccce0d95
commit
de24e55395
1 changed files with 26 additions and 34 deletions
|
@ -1942,24 +1942,21 @@ static int domain_context_mapping_one(struct dmar_domain *domain,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
context_clear_entry(context);
|
|
||||||
|
|
||||||
id = domain->id;
|
|
||||||
pgd = domain->pgd;
|
pgd = domain->pgd;
|
||||||
|
|
||||||
if (domain_type_is_vm_or_si(domain)) {
|
|
||||||
if (domain_type_is_vm(domain)) {
|
|
||||||
id = __iommu_attach_domain(domain, iommu);
|
id = __iommu_attach_domain(domain, iommu);
|
||||||
if (id < 0) {
|
if (id < 0) {
|
||||||
spin_unlock_irqrestore(&iommu->lock, flags);
|
spin_unlock_irqrestore(&iommu->lock, flags);
|
||||||
pr_err("%s: No free domain ids\n", iommu->name);
|
pr_err("%s: No free domain ids\n", iommu->name);
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* Skip top levels of page tables for
|
context_clear_entry(context);
|
||||||
* iommu which has less agaw than default.
|
context_set_domain_id(context, id);
|
||||||
* Unnecessary for PT mode.
|
|
||||||
|
/*
|
||||||
|
* Skip top levels of page tables for iommu which has less agaw
|
||||||
|
* than default. Unnecessary for PT mode.
|
||||||
*/
|
*/
|
||||||
if (translation != CONTEXT_TT_PASS_THROUGH) {
|
if (translation != CONTEXT_TT_PASS_THROUGH) {
|
||||||
for (agaw = domain->agaw; agaw != iommu->agaw; agaw--) {
|
for (agaw = domain->agaw; agaw != iommu->agaw; agaw--) {
|
||||||
|
@ -1969,25 +1966,20 @@ static int domain_context_mapping_one(struct dmar_domain *domain,
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
context_set_domain_id(context, id);
|
|
||||||
|
|
||||||
if (translation != CONTEXT_TT_PASS_THROUGH) {
|
|
||||||
info = iommu_support_dev_iotlb(domain, iommu, bus, devfn);
|
info = iommu_support_dev_iotlb(domain, iommu, bus, devfn);
|
||||||
translation = info ? CONTEXT_TT_DEV_IOTLB :
|
translation = info ? CONTEXT_TT_DEV_IOTLB :
|
||||||
CONTEXT_TT_MULTI_LEVEL;
|
CONTEXT_TT_MULTI_LEVEL;
|
||||||
}
|
|
||||||
/*
|
|
||||||
* In pass through mode, AW must be programmed to indicate the largest
|
|
||||||
* AGAW value supported by hardware. And ASR is ignored by hardware.
|
|
||||||
*/
|
|
||||||
if (unlikely(translation == CONTEXT_TT_PASS_THROUGH))
|
|
||||||
context_set_address_width(context, iommu->msagaw);
|
|
||||||
else {
|
|
||||||
context_set_address_root(context, virt_to_phys(pgd));
|
context_set_address_root(context, virt_to_phys(pgd));
|
||||||
context_set_address_width(context, iommu->agaw);
|
context_set_address_width(context, iommu->agaw);
|
||||||
|
} else {
|
||||||
|
/*
|
||||||
|
* In pass through mode, AW must be programmed to
|
||||||
|
* indicate the largest AGAW value supported by
|
||||||
|
* hardware. And ASR is ignored by hardware.
|
||||||
|
*/
|
||||||
|
context_set_address_width(context, iommu->msagaw);
|
||||||
}
|
}
|
||||||
|
|
||||||
context_set_translation_type(context, translation);
|
context_set_translation_type(context, translation);
|
||||||
|
|
Loading…
Add table
Reference in a new issue