aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/iommu/dmar.c14
-rw-r--r--include/linux/dmar.h5
2 files changed, 15 insertions, 4 deletions
diff --git a/drivers/iommu/dmar.c b/drivers/iommu/dmar.c
index fb35d1bd19e1..28d93b68ff02 100644
--- a/drivers/iommu/dmar.c
+++ b/drivers/iommu/dmar.c
@@ -100,7 +100,6 @@ static int __init dmar_parse_one_dev_scope(struct acpi_dmar_device_scope *scope,
100 if (!pdev) { 100 if (!pdev) {
101 pr_warn("Device scope device [%04x:%02x:%02x.%02x] not found\n", 101 pr_warn("Device scope device [%04x:%02x:%02x.%02x] not found\n",
102 segment, scope->bus, path->device, path->function); 102 segment, scope->bus, path->device, path->function);
103 *dev = NULL;
104 return 0; 103 return 0;
105 } 104 }
106 if ((scope->entry_type == ACPI_DMAR_SCOPE_TYPE_ENDPOINT && \ 105 if ((scope->entry_type == ACPI_DMAR_SCOPE_TYPE_ENDPOINT && \
@@ -151,7 +150,7 @@ int __init dmar_parse_dev_scope(void *start, void *end, int *cnt,
151 ret = dmar_parse_one_dev_scope(scope, 150 ret = dmar_parse_one_dev_scope(scope,
152 &(*devices)[index], segment); 151 &(*devices)[index], segment);
153 if (ret) { 152 if (ret) {
154 kfree(*devices); 153 dmar_free_dev_scope(devices, cnt);
155 return ret; 154 return ret;
156 } 155 }
157 index ++; 156 index ++;
@@ -162,6 +161,17 @@ int __init dmar_parse_dev_scope(void *start, void *end, int *cnt,
162 return 0; 161 return 0;
163} 162}
164 163
164void dmar_free_dev_scope(struct pci_dev ***devices, int *cnt)
165{
166 if (*devices && *cnt) {
167 while (--*cnt >= 0)
168 pci_dev_put((*devices)[*cnt]);
169 kfree(*devices);
170 *devices = NULL;
171 *cnt = 0;
172 }
173}
174
165/** 175/**
166 * dmar_parse_one_drhd - parses exactly one DMA remapping hardware definition 176 * dmar_parse_one_drhd - parses exactly one DMA remapping hardware definition
167 * structure which uniquely represent one DMA remapping hardware unit 177 * structure which uniquely represent one DMA remapping hardware unit
diff --git a/include/linux/dmar.h b/include/linux/dmar.h
index b029d1aa2d12..205ee37eed73 100644
--- a/include/linux/dmar.h
+++ b/include/linux/dmar.h
@@ -62,6 +62,9 @@ extern struct list_head dmar_drhd_units;
62 62
63extern int dmar_table_init(void); 63extern int dmar_table_init(void);
64extern int dmar_dev_scope_init(void); 64extern int dmar_dev_scope_init(void);
65extern int dmar_parse_dev_scope(void *start, void *end, int *cnt,
66 struct pci_dev ***devices, u16 segment);
67extern void dmar_free_dev_scope(struct pci_dev ***devices, int *cnt);
65 68
66/* Intel IOMMU detection */ 69/* Intel IOMMU detection */
67extern int detect_intel_iommu(void); 70extern int detect_intel_iommu(void);
@@ -157,8 +160,6 @@ struct dmar_atsr_unit {
157int dmar_parse_rmrr_atsr_dev(void); 160int dmar_parse_rmrr_atsr_dev(void);
158extern int dmar_parse_one_rmrr(struct acpi_dmar_header *header); 161extern int dmar_parse_one_rmrr(struct acpi_dmar_header *header);
159extern int dmar_parse_one_atsr(struct acpi_dmar_header *header); 162extern int dmar_parse_one_atsr(struct acpi_dmar_header *header);
160extern int dmar_parse_dev_scope(void *start, void *end, int *cnt,
161 struct pci_dev ***devices, u16 segment);
162extern int intel_iommu_init(void); 163extern int intel_iommu_init(void);
163#else /* !CONFIG_INTEL_IOMMU: */ 164#else /* !CONFIG_INTEL_IOMMU: */
164static inline int intel_iommu_init(void) { return -ENODEV; } 165static inline int intel_iommu_init(void) { return -ENODEV; }