]> xenbits.xensource.com Git - people/hx242/xen.git/commitdiff
AMD/IOMMU: tidy struct ivrs_mappings
authorJan Beulich <jbeulich@suse.com>
Wed, 25 Sep 2019 14:03:48 +0000 (16:03 +0200)
committerJan Beulich <jbeulich@suse.com>
Wed, 25 Sep 2019 14:03:48 +0000 (16:03 +0200)
Move the device flags field up into an unused hole, thus shrinking
overall structure size by 8 bytes. Use bool and uint<N>_t as
appropriate. Drop pointless (redundant) initializations.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Paul Durrant <paul.durrant@citrix.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/drivers/passthrough/amd/iommu_acpi.c
xen/drivers/passthrough/amd/iommu_init.c
xen/include/asm-x86/amd-iommu.h

index d87dc1170cb2ca2109469d7cacbc42db9da00d49..9fbc343c58be50fcd478552e2cb0950bedc74cc6 100644 (file)
@@ -165,7 +165,7 @@ static void __init reserve_unity_map_for_device(
     /* extend r/w permissioms and keep aggregate */
     ivrs_mappings[bdf].write_permission = iw;
     ivrs_mappings[bdf].read_permission = ir;
-    ivrs_mappings[bdf].unity_map_enable = IOMMU_CONTROL_ENABLED;
+    ivrs_mappings[bdf].unity_map_enable = true;
     ivrs_mappings[bdf].addr_range_start = base;
     ivrs_mappings[bdf].addr_range_length = length;
 }
@@ -242,8 +242,8 @@ static int __init register_exclusion_range_for_device(
     if ( limit >= iommu_top  )
     {
         reserve_iommu_exclusion_range(iommu, base, limit);
-        ivrs_mappings[bdf].dte_allow_exclusion = IOMMU_CONTROL_ENABLED;
-        ivrs_mappings[req].dte_allow_exclusion = IOMMU_CONTROL_ENABLED;
+        ivrs_mappings[bdf].dte_allow_exclusion = true;
+        ivrs_mappings[req].dte_allow_exclusion = true;
     }
 
     return 0;
index b2e81a61653e710fd6d957b967b6ad618d5a9ecd..574f04dd81c82ee25d5c402d420918e19761b6f3 100644 (file)
@@ -1222,12 +1222,6 @@ static int __init alloc_ivrs_mappings(u16 seg)
     for ( bdf = 0; bdf < ivrs_bdf_entries; bdf++ )
     {
         ivrs_mappings[bdf].dte_requestor_id = bdf;
-        ivrs_mappings[bdf].dte_allow_exclusion = IOMMU_CONTROL_DISABLED;
-        ivrs_mappings[bdf].unity_map_enable = IOMMU_CONTROL_DISABLED;
-        ivrs_mappings[bdf].iommu = NULL;
-
-        ivrs_mappings[bdf].intremap_table = NULL;
-        ivrs_mappings[bdf].device_flags = 0;
 
         if ( amd_iommu_perdev_intremap )
             spin_lock_init(&ivrs_mappings[bdf].intremap_lock);
index 0cf642f6f505dfd7ae6b5cc055681ec5dfe50748..83ababdc8c401636183c0e5e3d782fcde327e024 100644 (file)
@@ -106,12 +106,16 @@ struct amd_iommu {
 };
 
 struct ivrs_mappings {
-    u16 dte_requestor_id;
-    u8 dte_allow_exclusion;
-    u8 unity_map_enable;
-    u8 write_permission;
-    u8 read_permission;
-    bool valid;
+    uint16_t dte_requestor_id;
+    bool valid:1;
+    bool dte_allow_exclusion:1;
+    bool unity_map_enable:1;
+    bool write_permission:1;
+    bool read_permission:1;
+
+    /* ivhd device data settings */
+    uint8_t device_flags;
+
     unsigned long addr_range_start;
     unsigned long addr_range_length;
     struct amd_iommu *iommu;
@@ -120,9 +124,6 @@ struct ivrs_mappings {
     void *intremap_table;
     unsigned long *intremap_inuse;
     spinlock_t intremap_lock;
-
-    /* ivhd device data settings */
-    u8 device_flags;
 };
 
 extern unsigned int ivrs_bdf_entries;