diff options
author | David Woodhouse <David.Woodhouse@intel.com> | 2014-03-07 09:39:27 -0500 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2014-03-20 10:25:33 -0400 |
commit | 07cb52ff6aadac0ad68b29be2ef73dba3111c5ec (patch) | |
tree | 0286a495c79944d886482110c27fecc808ac5672 | |
parent | e625b4a95d50fa2f2d2fd0ab4b9ac9d6b6c2474c (diff) |
iommu/vt-d: Allocate space for ACPI devices
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
-rw-r--r-- | drivers/iommu/dmar.c | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/drivers/iommu/dmar.c b/drivers/iommu/dmar.c index eb95020c2314..4c6297d1b421 100644 --- a/drivers/iommu/dmar.c +++ b/drivers/iommu/dmar.c | |||
@@ -84,7 +84,8 @@ void *dmar_alloc_dev_scope(void *start, void *end, int *cnt) | |||
84 | *cnt = 0; | 84 | *cnt = 0; |
85 | while (start < end) { | 85 | while (start < end) { |
86 | scope = start; | 86 | scope = start; |
87 | if (scope->entry_type == ACPI_DMAR_SCOPE_TYPE_ENDPOINT || | 87 | if (scope->entry_type == ACPI_DMAR_SCOPE_TYPE_ACPI || |
88 | scope->entry_type == ACPI_DMAR_SCOPE_TYPE_ENDPOINT || | ||
88 | scope->entry_type == ACPI_DMAR_SCOPE_TYPE_BRIDGE) | 89 | scope->entry_type == ACPI_DMAR_SCOPE_TYPE_BRIDGE) |
89 | (*cnt)++; | 90 | (*cnt)++; |
90 | else if (scope->entry_type != ACPI_DMAR_SCOPE_TYPE_IOAPIC && | 91 | else if (scope->entry_type != ACPI_DMAR_SCOPE_TYPE_IOAPIC && |
@@ -342,21 +343,18 @@ dmar_parse_one_drhd(struct acpi_dmar_header *header) | |||
342 | dmaru->reg_base_addr = drhd->address; | 343 | dmaru->reg_base_addr = drhd->address; |
343 | dmaru->segment = drhd->segment; | 344 | dmaru->segment = drhd->segment; |
344 | dmaru->include_all = drhd->flags & 0x1; /* BIT0: INCLUDE_ALL */ | 345 | dmaru->include_all = drhd->flags & 0x1; /* BIT0: INCLUDE_ALL */ |
345 | if (!dmaru->include_all) { | 346 | dmaru->devices = dmar_alloc_dev_scope((void *)(drhd + 1), |
346 | dmaru->devices = dmar_alloc_dev_scope((void *)(drhd + 1), | 347 | ((void *)drhd) + drhd->header.length, |
347 | ((void *)drhd) + drhd->header.length, | 348 | &dmaru->devices_cnt); |
348 | &dmaru->devices_cnt); | 349 | if (dmaru->devices_cnt && dmaru->devices == NULL) { |
349 | if (dmaru->devices_cnt && dmaru->devices == NULL) { | 350 | kfree(dmaru); |
350 | kfree(dmaru); | 351 | return -ENOMEM; |
351 | return -ENOMEM; | ||
352 | } | ||
353 | } | 352 | } |
354 | 353 | ||
355 | ret = alloc_iommu(dmaru); | 354 | ret = alloc_iommu(dmaru); |
356 | if (ret) { | 355 | if (ret) { |
357 | if (!dmaru->include_all) | 356 | dmar_free_dev_scope(&dmaru->devices, |
358 | dmar_free_dev_scope(&dmaru->devices, | 357 | &dmaru->devices_cnt); |
359 | &dmaru->devices_cnt); | ||
360 | kfree(dmaru); | 358 | kfree(dmaru); |
361 | return ret; | 359 | return ret; |
362 | } | 360 | } |