]> err.no Git - linux-2.6/blobdiff - arch/x86/kernel/amd_iommu_init.c
x86, AMD IOMMU: replace self made size parsing with memparse call
[linux-2.6] / arch / x86 / kernel / amd_iommu_init.c
index 0124995c7b5d2fb88b8b982927c955c7a2ceb342..e0ff9404e6c94bd7e4fbd24f41bbd2ae65db1168 100644 (file)
@@ -118,12 +118,12 @@ static int __initdata amd_iommu_detected;
 
 u16 amd_iommu_last_bdf;                        /* largest PCI device id we have
                                           to handle */
-struct list_head amd_iommu_unity_map;  /* a list of required unity mappings
+LIST_HEAD(amd_iommu_unity_map);                /* a list of required unity mappings
                                           we find in ACPI */
 unsigned amd_iommu_aperture_order = 26; /* size of aperture in power of 2 */
 int amd_iommu_isolate;                 /* if 1, device isolation is enabled */
 
-struct list_head amd_iommu_list;       /* list of all AMD IOMMUs in the
+LIST_HEAD(amd_iommu_list);             /* list of all AMD IOMMUs in the
                                           system */
 
 /*
@@ -509,7 +509,7 @@ static void __init init_iommu_from_acpi(struct amd_iommu *iommu,
        u8 *end = p, flags = 0;
        u16 dev_i, devid = 0, devid_start = 0, devid_to = 0;
        u32 ext_flags = 0;
-       bool alias = 0;
+       bool alias = false;
        struct ivhd_entry *e;
 
        /*
@@ -559,7 +559,7 @@ static void __init init_iommu_from_acpi(struct amd_iommu *iommu,
                        devid_start = e->devid;
                        flags = e->flags;
                        ext_flags = 0;
-                       alias = 0;
+                       alias = false;
                        break;
                case IVHD_DEV_ALIAS:
                        devid = e->devid;
@@ -572,7 +572,7 @@ static void __init init_iommu_from_acpi(struct amd_iommu *iommu,
                        flags = e->flags;
                        devid_to = e->ext >> 8;
                        ext_flags = 0;
-                       alias = 1;
+                       alias = true;
                        break;
                case IVHD_DEV_EXT_SELECT:
                        devid = e->devid;
@@ -582,7 +582,7 @@ static void __init init_iommu_from_acpi(struct amd_iommu *iommu,
                        devid_start = e->devid;
                        flags = e->flags;
                        ext_flags = e->ext;
-                       alias = 0;
+                       alias = false;
                        break;
                case IVHD_DEV_RANGE_END:
                        devid = e->devid;
@@ -673,8 +673,6 @@ static int __init init_iommu_all(struct acpi_table_header *table)
        struct amd_iommu *iommu;
        int ret;
 
-       INIT_LIST_HEAD(&amd_iommu_list);
-
        end += table->length;
        p += IVRS_HEADER_LENGTH;
 
@@ -780,8 +778,6 @@ static int __init init_memory_definitions(struct acpi_table_header *table)
        u8 *p = (u8 *)table, *end = (u8 *)table;
        struct ivmd_header *m;
 
-       INIT_LIST_HEAD(&amd_iommu_unity_map);
-
        end += table->length;
        p += IVRS_HEADER_LENGTH;
 
@@ -894,7 +890,7 @@ int __init amd_iommu_init(void)
        ret = -ENOMEM;
 
        /* Device table - directly used by all IOMMUs */
-       amd_iommu_dev_table = (void *)__get_free_pages(GFP_KERNEL,
+       amd_iommu_dev_table = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO,
                                      get_order(dev_table_size));
        if (amd_iommu_dev_table == NULL)
                goto out;
@@ -918,27 +914,23 @@ int __init amd_iommu_init(void)
         * Protection Domain table - maps devices to protection domains
         * This table has the same size as the rlookup_table
         */
-       amd_iommu_pd_table = (void *)__get_free_pages(GFP_KERNEL,
+       amd_iommu_pd_table = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO,
                                     get_order(rlookup_table_size));
        if (amd_iommu_pd_table == NULL)
                goto free;
 
-       amd_iommu_pd_alloc_bitmap = (void *)__get_free_pages(GFP_KERNEL,
+       amd_iommu_pd_alloc_bitmap = (void *)__get_free_pages(
+                                           GFP_KERNEL | __GFP_ZERO,
                                            get_order(MAX_DOMAIN_ID/8));
        if (amd_iommu_pd_alloc_bitmap == NULL)
                goto free;
 
        /*
-        * memory is allocated now; initialize the device table with all zeroes
-        * and let all alias entries point to itself
+        * let all alias entries point to itself
         */
-       memset(amd_iommu_dev_table, 0, dev_table_size);
        for (i = 0; i < amd_iommu_last_bdf; ++i)
                amd_iommu_alias_table[i] = i;
 
-       memset(amd_iommu_pd_table, 0, rlookup_table_size);
-       memset(amd_iommu_pd_alloc_bitmap, 0, MAX_DOMAIN_ID / 8);
-
        /*
         * never allocate domain 0 because its used as the non-allocated and
         * error value placeholder
@@ -1050,20 +1042,10 @@ static int __init parse_amd_iommu_options(char *str)
 
 static int __init parse_amd_iommu_size_options(char *str)
 {
-       for (; *str; ++str) {
-               if (strcmp(str, "32M") == 0)
-                       amd_iommu_aperture_order = 25;
-               if (strcmp(str, "64M") == 0)
-                       amd_iommu_aperture_order = 26;
-               if (strcmp(str, "128M") == 0)
-                       amd_iommu_aperture_order = 27;
-               if (strcmp(str, "256M") == 0)
-                       amd_iommu_aperture_order = 28;
-               if (strcmp(str, "512M") == 0)
-                       amd_iommu_aperture_order = 29;
-               if (strcmp(str, "1G") == 0)
-                       amd_iommu_aperture_order = 30;
-       }
+       unsigned order = PAGE_SHIFT + get_order(memparse(str, &str));
+
+       if ((order > 24) && (order < 31))
+               amd_iommu_aperture_order = order;
 
        return 1;
 }