mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-25 05:34:00 +08:00
iommu/vt-d: Remove static identity map code
The code to prepare the static identity map for various reserved memory ranges in intel_iommu_init() is duplicated with the default domain mechanism now. Remove it to avoid duplication. Signed-off-by: James Sewart <jamessewart@arista.com> Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com> Signed-off-by: Joerg Roedel <jroedel@suse.de>
This commit is contained in:
parent
b7297783c2
commit
df4f3c603a
@ -2762,31 +2762,6 @@ static inline int iommu_prepare_rmrr_dev(struct dmar_rmrr_unit *rmrr,
|
||||
rmrr->end_address);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_INTEL_IOMMU_FLOPPY_WA
|
||||
static inline void iommu_prepare_isa(void)
|
||||
{
|
||||
struct pci_dev *pdev;
|
||||
int ret;
|
||||
|
||||
pdev = pci_get_class(PCI_CLASS_BRIDGE_ISA << 8, NULL);
|
||||
if (!pdev)
|
||||
return;
|
||||
|
||||
pr_info("Prepare 0-16MiB unity mapping for LPC\n");
|
||||
ret = iommu_prepare_identity_map(&pdev->dev, 0, 16*1024*1024 - 1);
|
||||
|
||||
if (ret)
|
||||
pr_err("Failed to create 0-16MiB identity map - floppy might not work\n");
|
||||
|
||||
pci_dev_put(pdev);
|
||||
}
|
||||
#else
|
||||
static inline void iommu_prepare_isa(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
#endif /* !CONFIG_INTEL_IOMMU_FLPY_WA */
|
||||
|
||||
static int md_domain_init(struct dmar_domain *domain, int guest_width);
|
||||
|
||||
static int __init si_domain_init(int hw)
|
||||
@ -3000,68 +2975,6 @@ static int device_def_domain_type(struct device *dev)
|
||||
IOMMU_DOMAIN_IDENTITY : 0;
|
||||
}
|
||||
|
||||
static inline int iommu_should_identity_map(struct device *dev)
|
||||
{
|
||||
return device_def_domain_type(dev) == IOMMU_DOMAIN_IDENTITY;
|
||||
}
|
||||
|
||||
static int __init dev_prepare_static_identity_mapping(struct device *dev, int hw)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (!iommu_should_identity_map(dev))
|
||||
return 0;
|
||||
|
||||
ret = domain_add_dev_info(si_domain, dev);
|
||||
if (!ret)
|
||||
dev_info(dev, "%s identity mapping\n",
|
||||
hw ? "Hardware" : "Software");
|
||||
else if (ret == -ENODEV)
|
||||
/* device not associated with an iommu */
|
||||
ret = 0;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static int __init iommu_prepare_static_identity_mapping(int hw)
|
||||
{
|
||||
struct pci_dev *pdev = NULL;
|
||||
struct dmar_drhd_unit *drhd;
|
||||
struct intel_iommu *iommu;
|
||||
struct device *dev;
|
||||
int i;
|
||||
int ret = 0;
|
||||
|
||||
for_each_pci_dev(pdev) {
|
||||
ret = dev_prepare_static_identity_mapping(&pdev->dev, hw);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
for_each_active_iommu(iommu, drhd)
|
||||
for_each_active_dev_scope(drhd->devices, drhd->devices_cnt, i, dev) {
|
||||
struct acpi_device_physical_node *pn;
|
||||
struct acpi_device *adev;
|
||||
|
||||
if (dev->bus != &acpi_bus_type)
|
||||
continue;
|
||||
|
||||
adev= to_acpi_device(dev);
|
||||
mutex_lock(&adev->physical_node_lock);
|
||||
list_for_each_entry(pn, &adev->physical_node_list, node) {
|
||||
ret = dev_prepare_static_identity_mapping(pn->dev, hw);
|
||||
if (ret)
|
||||
break;
|
||||
}
|
||||
mutex_unlock(&adev->physical_node_lock);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void intel_iommu_init_qi(struct intel_iommu *iommu)
|
||||
{
|
||||
/*
|
||||
@ -3284,11 +3197,8 @@ out_unmap:
|
||||
static int __init init_dmars(void)
|
||||
{
|
||||
struct dmar_drhd_unit *drhd;
|
||||
struct dmar_rmrr_unit *rmrr;
|
||||
bool copied_tables = false;
|
||||
struct device *dev;
|
||||
struct intel_iommu *iommu;
|
||||
int i, ret;
|
||||
int ret;
|
||||
|
||||
/*
|
||||
* for each drhd
|
||||
@ -3381,7 +3291,6 @@ static int __init init_dmars(void)
|
||||
} else {
|
||||
pr_info("Copied translation tables from previous kernel for %s\n",
|
||||
iommu->name);
|
||||
copied_tables = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -3421,57 +3330,6 @@ static int __init init_dmars(void)
|
||||
if (ret)
|
||||
goto free_iommu;
|
||||
|
||||
|
||||
/*
|
||||
* If we copied translations from a previous kernel in the kdump
|
||||
* case, we can not assign the devices to domains now, as that
|
||||
* would eliminate the old mappings. So skip this part and defer
|
||||
* the assignment to device driver initialization time.
|
||||
*/
|
||||
if (copied_tables)
|
||||
goto domains_done;
|
||||
|
||||
/*
|
||||
* If pass through is not set or not enabled, setup context entries for
|
||||
* identity mappings for rmrr, gfx, and isa and may fall back to static
|
||||
* identity mapping if iommu_identity_mapping is set.
|
||||
*/
|
||||
if (iommu_identity_mapping) {
|
||||
ret = iommu_prepare_static_identity_mapping(hw_pass_through);
|
||||
if (ret) {
|
||||
pr_crit("Failed to setup IOMMU pass-through\n");
|
||||
goto free_iommu;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* For each rmrr
|
||||
* for each dev attached to rmrr
|
||||
* do
|
||||
* locate drhd for dev, alloc domain for dev
|
||||
* allocate free domain
|
||||
* allocate page table entries for rmrr
|
||||
* if context not allocated for bus
|
||||
* allocate and init context
|
||||
* set present in root table for this bus
|
||||
* init context with domain, translation etc
|
||||
* endfor
|
||||
* endfor
|
||||
*/
|
||||
pr_info("Setting RMRR:\n");
|
||||
for_each_rmrr_units(rmrr) {
|
||||
/* some BIOS lists non-exist devices in DMAR table. */
|
||||
for_each_active_dev_scope(rmrr->devices, rmrr->devices_cnt,
|
||||
i, dev) {
|
||||
ret = iommu_prepare_rmrr_dev(rmrr, dev);
|
||||
if (ret)
|
||||
pr_err("Mapping reserved region failed\n");
|
||||
}
|
||||
}
|
||||
|
||||
iommu_prepare_isa();
|
||||
|
||||
domains_done:
|
||||
|
||||
/*
|
||||
* for each drhd
|
||||
* enable fault log
|
||||
|
Loading…
Reference in New Issue
Block a user