diff options
author | Lu Baolu <baolu.lu@linux.intel.com> | 2019-05-25 01:41:36 -0400 |
---|---|---|
committer | Joerg Roedel <jroedel@suse.de> | 2019-05-28 04:19:13 -0400 |
commit | df4f3c603aeb6dd40b74b93bf2db6d9c3213d4e1 (patch) | |
tree | f77acfc5fa9fedfc4333a972f3768bfeb7fa6493 /drivers/iommu/intel-iommu.c | |
parent | b7297783c2bb6fa7bd557842657bed7e95220978 (diff) |
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>
Diffstat (limited to 'drivers/iommu/intel-iommu.c')
-rw-r--r-- | drivers/iommu/intel-iommu.c | 144 |
1 files changed, 1 insertions, 143 deletions
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c index 007aac554b37..d9d7d669de81 100644 --- a/drivers/iommu/intel-iommu.c +++ b/drivers/iommu/intel-iommu.c | |||
@@ -2762,31 +2762,6 @@ static inline int iommu_prepare_rmrr_dev(struct dmar_rmrr_unit *rmrr, | |||
2762 | rmrr->end_address); | 2762 | rmrr->end_address); |
2763 | } | 2763 | } |
2764 | 2764 | ||
2765 | #ifdef CONFIG_INTEL_IOMMU_FLOPPY_WA | ||
2766 | static inline void iommu_prepare_isa(void) | ||
2767 | { | ||
2768 | struct pci_dev *pdev; | ||
2769 | int ret; | ||
2770 | |||
2771 | pdev = pci_get_class(PCI_CLASS_BRIDGE_ISA << 8, NULL); | ||
2772 | if (!pdev) | ||
2773 | return; | ||
2774 | |||
2775 | pr_info("Prepare 0-16MiB unity mapping for LPC\n"); | ||
2776 | ret = iommu_prepare_identity_map(&pdev->dev, 0, 16*1024*1024 - 1); | ||
2777 | |||
2778 | if (ret) | ||
2779 | pr_err("Failed to create 0-16MiB identity map - floppy might not work\n"); | ||
2780 | |||
2781 | pci_dev_put(pdev); | ||
2782 | } | ||
2783 | #else | ||
2784 | static inline void iommu_prepare_isa(void) | ||
2785 | { | ||
2786 | return; | ||
2787 | } | ||
2788 | #endif /* !CONFIG_INTEL_IOMMU_FLPY_WA */ | ||
2789 | |||
2790 | static int md_domain_init(struct dmar_domain *domain, int guest_width); | 2765 | static int md_domain_init(struct dmar_domain *domain, int guest_width); |
2791 | 2766 | ||
2792 | static int __init si_domain_init(int hw) | 2767 | static int __init si_domain_init(int hw) |
@@ -3000,68 +2975,6 @@ static int device_def_domain_type(struct device *dev) | |||
3000 | IOMMU_DOMAIN_IDENTITY : 0; | 2975 | IOMMU_DOMAIN_IDENTITY : 0; |
3001 | } | 2976 | } |
3002 | 2977 | ||
3003 | static inline int iommu_should_identity_map(struct device *dev) | ||
3004 | { | ||
3005 | return device_def_domain_type(dev) == IOMMU_DOMAIN_IDENTITY; | ||
3006 | } | ||
3007 | |||
3008 | static int __init dev_prepare_static_identity_mapping(struct device *dev, int hw) | ||
3009 | { | ||
3010 | int ret; | ||
3011 | |||
3012 | if (!iommu_should_identity_map(dev)) | ||
3013 | return 0; | ||
3014 | |||
3015 | ret = domain_add_dev_info(si_domain, dev); | ||
3016 | if (!ret) | ||
3017 | dev_info(dev, "%s identity mapping\n", | ||
3018 | hw ? "Hardware" : "Software"); | ||
3019 | else if (ret == -ENODEV) | ||
3020 | /* device not associated with an iommu */ | ||
3021 | ret = 0; | ||
3022 | |||
3023 | return ret; | ||
3024 | } | ||
3025 | |||
3026 | |||
3027 | static int __init iommu_prepare_static_identity_mapping(int hw) | ||
3028 | { | ||
3029 | struct pci_dev *pdev = NULL; | ||
3030 | struct dmar_drhd_unit *drhd; | ||
3031 | struct intel_iommu *iommu; | ||
3032 | struct device *dev; | ||
3033 | int i; | ||
3034 | int ret = 0; | ||
3035 | |||
3036 | for_each_pci_dev(pdev) { | ||
3037 | ret = dev_prepare_static_identity_mapping(&pdev->dev, hw); | ||
3038 | if (ret) | ||
3039 | return ret; | ||
3040 | } | ||
3041 | |||
3042 | for_each_active_iommu(iommu, drhd) | ||
3043 | for_each_active_dev_scope(drhd->devices, drhd->devices_cnt, i, dev) { | ||
3044 | struct acpi_device_physical_node *pn; | ||
3045 | struct acpi_device *adev; | ||
3046 | |||
3047 | if (dev->bus != &acpi_bus_type) | ||
3048 | continue; | ||
3049 | |||
3050 | adev= to_acpi_device(dev); | ||
3051 | mutex_lock(&adev->physical_node_lock); | ||
3052 | list_for_each_entry(pn, &adev->physical_node_list, node) { | ||
3053 | ret = dev_prepare_static_identity_mapping(pn->dev, hw); | ||
3054 | if (ret) | ||
3055 | break; | ||
3056 | } | ||
3057 | mutex_unlock(&adev->physical_node_lock); | ||
3058 | if (ret) | ||
3059 | return ret; | ||
3060 | } | ||
3061 | |||
3062 | return 0; | ||
3063 | } | ||
3064 | |||
3065 | static void intel_iommu_init_qi(struct intel_iommu *iommu) | 2978 | static void intel_iommu_init_qi(struct intel_iommu *iommu) |
3066 | { | 2979 | { |
3067 | /* | 2980 | /* |
@@ -3284,11 +3197,8 @@ out_unmap: | |||
3284 | static int __init init_dmars(void) | 3197 | static int __init init_dmars(void) |
3285 | { | 3198 | { |
3286 | struct dmar_drhd_unit *drhd; | 3199 | struct dmar_drhd_unit *drhd; |
3287 | struct dmar_rmrr_unit *rmrr; | ||
3288 | bool copied_tables = false; | ||
3289 | struct device *dev; | ||
3290 | struct intel_iommu *iommu; | 3200 | struct intel_iommu *iommu; |
3291 | int i, ret; | 3201 | int ret; |
3292 | 3202 | ||
3293 | /* | 3203 | /* |
3294 | * for each drhd | 3204 | * for each drhd |
@@ -3381,7 +3291,6 @@ static int __init init_dmars(void) | |||
3381 | } else { | 3291 | } else { |
3382 | pr_info("Copied translation tables from previous kernel for %s\n", | 3292 | pr_info("Copied translation tables from previous kernel for %s\n", |
3383 | iommu->name); | 3293 | iommu->name); |
3384 | copied_tables = true; | ||
3385 | } | 3294 | } |
3386 | } | 3295 | } |
3387 | 3296 | ||
@@ -3421,57 +3330,6 @@ static int __init init_dmars(void) | |||
3421 | if (ret) | 3330 | if (ret) |
3422 | goto free_iommu; | 3331 | goto free_iommu; |
3423 | 3332 | ||
3424 | |||
3425 | /* | ||
3426 | * If we copied translations from a previous kernel in the kdump | ||
3427 | * case, we can not assign the devices to domains now, as that | ||
3428 | * would eliminate the old mappings. So skip this part and defer | ||
3429 | * the assignment to device driver initialization time. | ||
3430 | */ | ||
3431 | if (copied_tables) | ||
3432 | goto domains_done; | ||
3433 | |||
3434 | /* | ||
3435 | * If pass through is not set or not enabled, setup context entries for | ||
3436 | * identity mappings for rmrr, gfx, and isa and may fall back to static | ||
3437 | * identity mapping if iommu_identity_mapping is set. | ||
3438 | */ | ||
3439 | if (iommu_identity_mapping) { | ||
3440 | ret = iommu_prepare_static_identity_mapping(hw_pass_through); | ||
3441 | if (ret) { | ||
3442 | pr_crit("Failed to setup IOMMU pass-through\n"); | ||
3443 | goto free_iommu; | ||
3444 | } | ||
3445 | } | ||
3446 | /* | ||
3447 | * For each rmrr | ||
3448 | * for each dev attached to rmrr | ||
3449 | * do | ||
3450 | * locate drhd for dev, alloc domain for dev | ||
3451 | * allocate free domain | ||
3452 | * allocate page table entries for rmrr | ||
3453 | * if context not allocated for bus | ||
3454 | * allocate and init context | ||
3455 | * set present in root table for this bus | ||
3456 | * init context with domain, translation etc | ||
3457 | * endfor | ||
3458 | * endfor | ||
3459 | */ | ||
3460 | pr_info("Setting RMRR:\n"); | ||
3461 | for_each_rmrr_units(rmrr) { | ||
3462 | /* some BIOS lists non-exist devices in DMAR table. */ | ||
3463 | for_each_active_dev_scope(rmrr->devices, rmrr->devices_cnt, | ||
3464 | i, dev) { | ||
3465 | ret = iommu_prepare_rmrr_dev(rmrr, dev); | ||
3466 | if (ret) | ||
3467 | pr_err("Mapping reserved region failed\n"); | ||
3468 | } | ||
3469 | } | ||
3470 | |||
3471 | iommu_prepare_isa(); | ||
3472 | |||
3473 | domains_done: | ||
3474 | |||
3475 | /* | 3333 | /* |
3476 | * for each drhd | 3334 | * for each drhd |
3477 | * enable fault log | 3335 | * enable fault log |