diff mbox series

[v3,09/14] AMD/IOMMU: split amd_iommu_init_one()

Message ID 5edb6957-62b2-6dc7-c873-e7b3c5794f89@suse.com (mailing list archive)
State New, archived
Headers show
Series [v3,01/14] AMD/IOMMU: free more memory when cleaning up after error | expand

Commit Message

Jan Beulich July 16, 2019, 4:39 p.m. UTC
Mapping the MMIO space and obtaining feature information needs to happen
slightly earlier, such that for x2APIC support we can set XTEn prior to
calling amd_iommu_update_ivrs_mapping_acpi() and
amd_iommu_setup_ioapic_remapping().

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>

Comments

Woods, Brian July 19, 2019, 6:36 p.m. UTC | #1
On Tue, Jul 16, 2019 at 04:39:10PM +0000, Jan Beulich wrote:
> Mapping the MMIO space and obtaining feature information needs to happen
> slightly earlier, such that for x2APIC support we can set XTEn prior to
> calling amd_iommu_update_ivrs_mapping_acpi() and
> amd_iommu_setup_ioapic_remapping().
> 
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>

Acked-by: Brian Woods <brian.woods@amd.com>

> --- a/xen/drivers/passthrough/amd/iommu_init.c
> +++ b/xen/drivers/passthrough/amd/iommu_init.c
> @@ -970,14 +970,6 @@ static void * __init allocate_ppr_log(st
>   
>   static int __init amd_iommu_init_one(struct amd_iommu *iommu)
>   {
> -    if ( map_iommu_mmio_region(iommu) != 0 )
> -        goto error_out;
> -
> -    get_iommu_features(iommu);
> -
> -    if ( iommu->features.raw )
> -        iommuv2_enabled = 1;
> -
>       if ( allocate_cmd_buffer(iommu) == NULL )
>           goto error_out;
>   
> @@ -1202,6 +1194,23 @@ static bool_t __init amd_sp5100_erratum2
>       return 0;
>   }
>   
> +static int __init amd_iommu_prepare_one(struct amd_iommu *iommu)
> +{
> +    int rc = alloc_ivrs_mappings(iommu->seg);
> +
> +    if ( !rc )
> +        rc = map_iommu_mmio_region(iommu);
> +    if ( rc )
> +        return rc;
> +
> +    get_iommu_features(iommu);
> +
> +    if ( iommu->features.raw )
> +        iommuv2_enabled = true;
> +
> +    return 0;
> +}
> +
>   int __init amd_iommu_init(void)
>   {
>       struct amd_iommu *iommu;
> @@ -1232,7 +1241,7 @@ int __init amd_iommu_init(void)
>       radix_tree_init(&ivrs_maps);
>       for_each_amd_iommu ( iommu )
>       {
> -        rc = alloc_ivrs_mappings(iommu->seg);
> +        rc = amd_iommu_prepare_one(iommu);
>           if ( rc )
>               goto error_out;
>       }
>
diff mbox series

Patch

--- a/xen/drivers/passthrough/amd/iommu_init.c
+++ b/xen/drivers/passthrough/amd/iommu_init.c
@@ -970,14 +970,6 @@  static void * __init allocate_ppr_log(st
  
  static int __init amd_iommu_init_one(struct amd_iommu *iommu)
  {
-    if ( map_iommu_mmio_region(iommu) != 0 )
-        goto error_out;
-
-    get_iommu_features(iommu);
-
-    if ( iommu->features.raw )
-        iommuv2_enabled = 1;
-
      if ( allocate_cmd_buffer(iommu) == NULL )
          goto error_out;
  
@@ -1202,6 +1194,23 @@  static bool_t __init amd_sp5100_erratum2
      return 0;
  }
  
+static int __init amd_iommu_prepare_one(struct amd_iommu *iommu)
+{
+    int rc = alloc_ivrs_mappings(iommu->seg);
+
+    if ( !rc )
+        rc = map_iommu_mmio_region(iommu);
+    if ( rc )
+        return rc;
+
+    get_iommu_features(iommu);
+
+    if ( iommu->features.raw )
+        iommuv2_enabled = true;
+
+    return 0;
+}
+
  int __init amd_iommu_init(void)
  {
      struct amd_iommu *iommu;
@@ -1232,7 +1241,7 @@  int __init amd_iommu_init(void)
      radix_tree_init(&ivrs_maps);
      for_each_amd_iommu ( iommu )
      {
-        rc = alloc_ivrs_mappings(iommu->seg);
+        rc = amd_iommu_prepare_one(iommu);
          if ( rc )
              goto error_out;
      }